diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 156142c..1ec0d3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,5 +39,5 @@ jobs: go-version-file: go.mod - name: cmd/generate output is committed and current run: | - go run ./cmd/generate -aliases -keywords + go run ./cmd/generate -aliases -keywords -plpgsql git diff --exit-code diff --git a/CLAUDE.md b/CLAUDE.md index 880e022..3e18a37 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,7 +23,8 @@ the main module; the only module allowed to link pg_query_go (cgo) is - **Expected outputs are never edited by hand.** Goldens come from `cmd/regenerate` (the pinned oracle) or not at all. - Generated files (`ast/pg_query.pb.go`, `aliases.go`, - `internal/lexer/keywords.go`) are only ever written by `cmd/generate`. + `internal/lexer/keywords.go`, `internal/plpgsql/tables.go`) are only ever + written by `cmd/generate`. - The public API mirrors pg_query_go exactly; consumers must migrate by changing one import path. Never rename, add, or remove exported symbols without checking pg_query_go v6.2.2. diff --git a/PLAN.md b/PLAN.md index bbf847c..7d820f9 100644 --- a/PLAN.md +++ b/PLAN.md @@ -417,12 +417,19 @@ gate; the corpus harness exists before the first line of the lexer. reference's parse → deparse → reparse roundtrip criterion, since the goldens are the oracle's own deparse output). See "As-built notes (milestones 8–9)". -10. **Summary.** Port the summary API (classification + smart truncation). -11. **PL/pgSQL.** Port `pl_gram.y` + `pl_comp` subset + the JSON serializer - behind `ParsePlPgSqlToJSON`. Deliberately last: self-contained, and the - only piece whose deferral wouldn't block sqlc. If v1.0 ships without it, - the function returns a clear unimplemented error — flagged for an - explicit scope call rather than silently dropped. +10. **Summary.** ✅ *Landed 2026-08-17.* Port the summary API + (classification + smart truncation). **Gate:** the deferred summary + corpus extracted and green — met: all 43,992 summary and 43,345 + summary_truncate cases pass (the regress tiers untruncated and at limit + 100, plus libpg_query's summary test-call inputs at their upstream + limits). See "As-built notes (milestones 10–11)". +11. **PL/pgSQL.** ✅ *Landed 2026-08-17.* Port `pl_gram.y` + `pl_comp` + subset + the JSON serializer behind `ParsePlPgSqlToJSON`. **Gate:** the + deferred `plpgsql_regress/` + `plpgsql_samples` corpus green — met: all + 690 plpgsql cases pass, and the plpgsql_regress files also feed the + standard SQL suites (all passing on arrival). Every corpus suite's todo + list is empty: 2,067 files / 308,561 cases across eleven suites. See + "As-built notes (milestones 10–11)". 12. **Hardening.** `cmd/difftest` mutation fuzzing vs the live oracle as a scheduled CI job; `go test -race` over the parallel corpus run; benchmarks vs pg_query_go (cgo) and wasilibs (wasm) — expect wins from @@ -460,7 +467,10 @@ Measured at the pin, where the plan's estimates differ: - Deferred, deliberately: the **sqlc endtoend tier** (needs per-directory engine classification in the sqlc repo; import it alongside milestone 4), **`plpgsql_regress/`** (milestone 11), and **summary** golden extraction - (milestone 10). The stretch tarball tier remains stretch. + (milestone 10). The stretch tarball tier remains stretch. *(The plpgsql + and summary tiers landed with milestones 10–11: the corpus is now 2,067 + files / 308,561 cases across eleven suites; only the sqlc endtoend and + stretch tiers remain out.)* ### As-built notes (milestone 3) @@ -648,6 +658,70 @@ Measured at the pin, where the plan's estimates differ: unimplemented entry points are `Summary` (milestone 10) and `ParsePlPgSqlToJSON` (milestone 11). +### As-built notes (milestones 10–11) + +- The deferred corpus tiers landed first, as their own commit: `summary` + (regress + plpgsql_regress + libpg_query's summary test-call inputs, + untruncated), `summary_truncate` (the same regress statements at limit + 100 — the limit rides along as a `-- truncate_limit: N` directive line in + the case input, stripped by both sides — plus the upstream truncate tests + at their exact limits and every summary input at limit 50), and `plpgsql` + (`plpgsql_regress/` + `plpgsql_samples.sql`, one `ParsePlPgSqlToJSON` + golden per statement). libpg_query's summary tests are call sites, not + `tests[]` tables, so `cmd/regenerate` grew a call extractor + (`summary("...", 0, limit)` with C line splices removed); inputs are + transcribed mechanically, expectations always from the oracle. The + plpgsql_regress files also feed the five standard SQL suites — all of + those passed the existing implementation on arrival. +- Summary (`internal/summary`) is three ports over one shared + `raw_expression_tree_walker` (now `internal/rawwalk`, PostgreSQL 17's + nodeFuncs.c gated by `pg_query_raw_tree_walker_supports`): the + table/alias/CTE/function/filter-column walk with its quirks preserved + (WHERE clauses walked twice, so functions there are recorded once per + pass; the filter-column pass aborts at sub-SELECTs; `MERGE ... USING` + sources are never tables), the statement-type walk (insertion-ordered + set), and deparse-driven truncation. Truncation ordering needed the exact + `pg_qsort` algorithm again — `list_sort` maps to `pg_qsort` at the pin, + and equal (depth, length) pairs are ordered by the partition scheme, not + the comparator. List nodes count as depth levels, matching `WALK` on a + List field. The `"…"` dummy-node replacements and the multibyte fallback + chop (`pg_mbcharcliplen` over UTF-8) are byte-exact ports. +- PL/pgSQL (`internal/plpgsql`) ports what libpg_query *builds*, not + vanilla PostgreSQL: `extract_source.rb` mocks `parse_datatype` (type text + kept verbatim; only RECORD/REFCURSOR/CURSOR/TEXT recognized, by + length-limited case-insensitive prefix), stubs the `%TYPE`/`%ROWTYPE` + lookups to NULL (so `foo%rowtype` falls through to the verbatim-text + path), replaces `make_return_stmt` (no return-type checks; RETURN never + captures a varno), and fails `function_parse_error_transpose` + unconditionally — so compile errors carry `compilation of PL/pgSQL + function "f" near line N` context and no cursor, with filenames as the + vendored build's `__FILE__` (`pl_gram.y`, + `src_pl_plpgsql_src_pl_scanner.c`, ...). +- The pl scanner layers on the milestone-3 lexer: the core scanner runs + with the PL reserved keyword list, modeled by re-classifying the SQL + lexer's output (SQL keywords become plain identifiers unless + PL-reserved; the `n'...'` NCHAR special falls back to IDENT `"n"`), plus + the pushback stack, `A.B.C` datum composition, and the + statement-start/unreserved-keyword dance. `pl_gram.y` became recursive + descent with statement linenos computed at bison's reduce points — + `plpgsql_latest_lineno` is stateful and feeds the error context, so call + order is part of conformance. +- `check_sql_expr` needed the core grammar's PL/pgSQL raw-parse modes: + `parse.ParseWithMode` adds `RAW_PARSE_PLPGSQL_EXPR` (the `PLpgSQL_Expr` + production — everything that can follow SELECT, minus SELECT) and + `ASSIGN1..3` (`PLAssignStmt`). Embedded-SQL errors keep the core + message/filename/funcname but lose their cursor + (`plpgsql_sql_error_callback` flushes the external position). +- `cmd/generate -plpgsql` emits `internal/plpgsql/tables.go` from the newly + vendored `pl_reserved_kwlist.h`/`pl_unreserved_kwlist.h`/`plerrcodes.h` + (condition names with their duplicate counts — duplicate names produce + condition chains of that length). +- Corpus effect: all 43,992 summary, 43,345 summary_truncate, and 690 + plpgsql todos graduated; every suite's todo list is empty (2,067 files / + 308,561 cases). pg_query_go's `summary_test.go` is ported verbatim and + `TestParsePlPgSQL` now runs green; no entry point returns + not-implemented anymore. + ## Regeneration (the PostgreSQL-upgrade story) Everything derived is derived by committed tooling from the pin: diff --git a/README.md b/README.md index a1b3b79..a677004 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,15 @@ for the development loop. | Milestone | State | |---|---| | 1. Scaffolding + codegen | ✅ module, licenses, CI, vendored pin, `ast/` protobuf types, aliases, keyword tables, API surface, `parser.Error`; pg_query_go's parse_test tree literals compile unchanged | -| 2. Corpus + oracle | ✅ cgo oracle (`oracle/`), `cmd/regenerate`, 1,525 golden files / 217k cases across 8 suites, byte-reproducible; harness + `cmd/next-test` running everything as todo | -| 3. Lexer | — | -| 4. Expressions + SELECT | — | -| 5–7. DML, DDL, utility | — | -| 8. Normalize + fingerprint | — | -| 9. Deparse | — | -| 10–13. Summary, PL/pgSQL, hardening, sqlc integration | — | +| 2. Corpus + oracle | ✅ cgo oracle (`oracle/`), `cmd/regenerate`, byte-reproducible goldens; harness + `cmd/next-test` | +| 3. Lexer | ✅ `Scan`, `SplitWithScanner`, `HashXXH3_64`; token streams byte-identical across the corpus | +| 4. Expressions + SELECT | ✅ `Parse`/`ParseToJSON` for the SELECT family | +| 5–7. DML, DDL, utility | ✅ the full statement grammar; `SplitWithParser`, `IsUtilityStmt`; parse corpus at 100% | +| 8. Normalize + fingerprint | ✅ `Normalize`, `NormalizeUtility`, `Fingerprint` | +| 9. Deparse | ✅ `Deparse`, byte-equal to the oracle across the corpus | +| 10. Summary | ✅ `Summary` (classification + smart truncation) | +| 11. PL/pgSQL | ✅ `ParsePlPgSqlToJSON` (pl_gram + pl_comp subset + JSON dump) | +| 12–13. Hardening, sqlc integration | — | -Until the parser milestones land, every public entry point returns (or -panics with, for `HashXXH3_64`) a clear not-implemented error. +Every public entry point is implemented; the corpus — 2,067 golden files / +308,561 cases across eleven suites — passes with an empty todo list. diff --git a/cmd/difftodo/main.go b/cmd/difftodo/main.go index 80f567b..1708e16 100644 --- a/cmd/difftodo/main.go +++ b/cmd/difftodo/main.go @@ -23,7 +23,8 @@ func main() { } suite := "parse" for _, s := range []string{"parse", "scan", "normalize", "normalize_utility", - "fingerprint", "deparse", "split_scanner", "split_parser"} { + "fingerprint", "deparse", "split_scanner", "split_parser", + "summary", "summary_truncate", "plpgsql"} { if strings.Contains(path, "/"+s+"/") { suite = s } @@ -76,6 +77,42 @@ func evaluate(suite, input string) string { if err == nil { out, err = pg_query.Deparse(tree) } + case "summary", "summary_truncate": + limit, sql := -1, input + if suite == "summary_truncate" { + limit, sql, err = testfile.SplitTruncateLimit(input) + if err != nil { + return "BAD CASE: " + err.Error() + } + } + var res *pg_query.SummaryResult + res, err = pg_query.Summary(sql, limit) + if err == nil { + e := testfile.SummaryExpectation{ + Aliases: res.Aliases, + CteNames: res.CteNames, + StatementTypes: res.StatementTypes, + TruncatedQuery: res.TruncatedQuery, + } + for _, t := range res.Tables { + e.Tables = append(e.Tables, testfile.SummaryTable{ + Name: t.Name, SchemaName: t.SchemaName, TableName: t.TableName, Context: t.Context.String(), + }) + } + for _, f := range res.Functions { + e.Functions = append(e.Functions, testfile.SummaryFunction{ + Name: f.Name, FunctionName: f.FunctionName, SchemaName: f.SchemaName, Context: f.Context.String(), + }) + } + for _, f := range res.FilterColumns { + e.FilterColumns = append(e.FilterColumns, testfile.SummaryFilterColumn{ + SchemaName: f.SchemaName, TableName: f.TableName, Column: f.Column, + }) + } + out = testfile.RenderSummary(e) + } + case "plpgsql": + out, err = pg_query.ParsePlPgSqlToJSON(input) default: panic("difftodo: unsupported suite " + suite) } diff --git a/cmd/generate/main.go b/cmd/generate/main.go index 653056f..37da929 100644 --- a/cmd/generate/main.go +++ b/cmd/generate/main.go @@ -21,10 +21,11 @@ func main() { proto := flag.Bool("proto", false, "regenerate ast/pg_query.pb.go (needs protoc + protoc-gen-go)") aliases := flag.Bool("aliases", false, "regenerate aliases.go") keywords := flag.Bool("keywords", false, "regenerate internal/lexer/keywords.go") + plpgsql := flag.Bool("plpgsql", false, "regenerate internal/plpgsql/tables.go") flag.Parse() - if !*proto && !*aliases && !*keywords { - *aliases, *keywords = true, true + if !*proto && !*aliases && !*keywords && !*plpgsql { + *aliases, *keywords, *plpgsql = true, true, true } if *proto { @@ -47,6 +48,12 @@ func main() { } fmt.Println("wrote internal/lexer/keywords.go") } + if *plpgsql { + if err := generatePlpgsql("internal/reference", "internal/plpgsql/tables.go"); err != nil { + fatal(err) + } + fmt.Println("wrote internal/plpgsql/tables.go") + } } func run(name string, args ...string) { diff --git a/cmd/generate/plpgsql.go b/cmd/generate/plpgsql.go new file mode 100644 index 0000000..77cee46 --- /dev/null +++ b/cmd/generate/plpgsql.go @@ -0,0 +1,97 @@ +package main + +import ( + "fmt" + "go/format" + "os" + "regexp" + "sort" + "strings" +) + +// generatePlpgsql emits internal/plpgsql/tables.go from the pinned +// pl_reserved_kwlist.h / pl_unreserved_kwlist.h (keyword → token maps, the +// data pl_scanner.c compiles in) and plerrcodes.h (the exception condition +// name table pl_comp.c's exception_label_map includes; only the name and its +// number of entries matter — dump_condition serializes condname alone, and +// duplicate names produce chains of that length). +func generatePlpgsql(refDir, outPath string) error { + kwRe := regexp.MustCompile(`PG_KEYWORD\("([a-z_]+)",\s*(K_[A-Z_]+)\)`) + readKeywords := func(file string) ([][2]string, error) { + src, err := os.ReadFile(refDir + "/" + file) + if err != nil { + return nil, err + } + var out [][2]string + for _, m := range kwRe.FindAllStringSubmatch(string(src), -1) { + out = append(out, [2]string{m[1], m[2]}) + } + if len(out) == 0 { + return nil, fmt.Errorf("%s: no PG_KEYWORD entries found", file) + } + return out, nil + } + + reserved, err := readKeywords("pl_reserved_kwlist.h") + if err != nil { + return err + } + unreserved, err := readKeywords("pl_unreserved_kwlist.h") + if err != nil { + return err + } + + errSrc, err := os.ReadFile(refDir + "/plerrcodes.h") + if err != nil { + return err + } + condRe := regexp.MustCompile(`"([a-z_]+)",\s*ERRCODE_[A-Z_0-9]+`) + condCount := map[string]int{} + var condOrder []string + for _, m := range condRe.FindAllStringSubmatch(string(errSrc), -1) { + if condCount[m[1]] == 0 { + condOrder = append(condOrder, m[1]) + } + condCount[m[1]]++ + } + if len(condOrder) == 0 { + return fmt.Errorf("plerrcodes.h: no condition entries found") + } + sort.Strings(condOrder) + + var b strings.Builder + b.WriteString("// Code generated by cmd/generate -plpgsql from internal/reference/\n") + b.WriteString("// pl_reserved_kwlist.h, pl_unreserved_kwlist.h, and plerrcodes.h\n") + b.WriteString("// (libpg_query 17-6.2.2). DO NOT EDIT.\n\npackage plpgsql\n\n") + + b.WriteString("// reservedKeywords is pl_reserved_kwlist.h: these are passed to the core\n") + b.WriteString("// scanner's keyword list, so they win over any variable name.\n") + b.WriteString("var reservedKeywords = map[string]plToken{\n") + for _, kw := range reserved { + fmt.Fprintf(&b, "\t%q: %s,\n", kw[0], kw[1]) + } + b.WriteString("}\n\n") + + b.WriteString("// unreservedKeywords is pl_unreserved_kwlist.h: checked only where the\n") + b.WriteString("// grammar wants a keyword and no variable matched.\n") + b.WriteString("var unreservedKeywords = map[string]plToken{\n") + for _, kw := range unreserved { + fmt.Fprintf(&b, "\t%q: %s,\n", kw[0], kw[1]) + } + b.WriteString("}\n\n") + + b.WriteString("// errConditions maps exception condition names to their number of\n") + b.WriteString("// entries in exception_label_map (plpgsql_parse_err_condition returns a\n") + b.WriteString("// chain with one node per entry).\n") + b.WriteString("var errConditions = map[string]int{\n") + for _, name := range condOrder { + fmt.Fprintf(&b, "\t%q: %d,\n", name, condCount[name]) + } + b.WriteString("}\n") + + src, err := format.Source([]byte(b.String())) + if err != nil { + return fmt.Errorf("gofmt plpgsql tables: %w", err) + } + return os.WriteFile(outPath, src, 0o644) +} diff --git a/cmd/next-test/main.go b/cmd/next-test/main.go index 33afa05..18b641a 100644 --- a/cmd/next-test/main.go +++ b/cmd/next-test/main.go @@ -22,6 +22,7 @@ import ( var suiteOrder = []string{ "scan", "split_scanner", "parse", "deparse", "normalize", "normalize_utility", "fingerprint", "split_parser", + "summary", "summary_truncate", "plpgsql", } func main() { diff --git a/cmd/regenerate/extract_summary.go b/cmd/regenerate/extract_summary.go new file mode 100644 index 0000000..a84ed00 --- /dev/null +++ b/cmd/regenerate/extract_summary.go @@ -0,0 +1,80 @@ +package main + +import ( + "regexp" + "strconv" + "strings" +) + +// --- summary test-call extraction -------------------------------------------- +// +// libpg_query's summary tests (test/summary_tests.c, test/summary_truncate.c) +// are not tests[] tables: each test body calls summary("...", 0, limit) or +// summary(query, 0, limit) after a `char *query = "...";` assignment. The +// INPUTS (query text + truncation limit) are transcribed mechanically here; +// the EXPECTATIONS always come from the live oracle, never from the C +// asserts, so a pattern drift can only lose cases (visible in review), not +// corrupt goldens. + +type summaryCall struct { + SQL string + Limit int +} + +var ( + // `char *query = "...";` (or `char* sql = "..."`): the identifier and its + // string literal, which summary(, ...) calls resolve against. + summaryAssignRe = regexp.MustCompile(`\*\s*(\w+)\s*=\s*("(?:[^"\\]|\\.)*")`) + // summary("...", 0, -1) / summary_internal(query, 0, 40): first argument + // is a string literal or an identifier; second is parser_options; third + // is the truncation limit. + summaryCallRe = regexp.MustCompile(`\bsummary(?:_internal)?\s*\(\s*(?:("(?:[^"\\]|\\.)*")|(\w+))\s*,\s*(-?\d+)\s*,\s*(-?\d+)\s*\)`) +) + +// extractSummaryCalls returns the (query, limit) pairs of every summary()/ +// summary_internal() call with parser_options 0 whose query is a string +// literal or resolvable single-assignment identifier. C line splices +// (backslash-newline, translation phase 2) are removed up front, exactly as +// the C compiler does before tokenization. +func extractSummaryCalls(src string) ([]summaryCall, error) { + src = strings.ReplaceAll(src, "\\\n", "") + + assigns := summaryAssignRe.FindAllStringSubmatchIndex(src, -1) + calls := summaryCallRe.FindAllStringSubmatchIndex(src, -1) + + var out []summaryCall + for _, m := range calls { + var lit string + switch { + case m[2] >= 0: // literal first argument + lit = src[m[2]:m[3]] + case m[4] >= 0: // identifier: latest preceding assignment wins + ident := src[m[4]:m[5]] + for _, a := range assigns { + if a[0] > m[0] { + break + } + if src[a[2]:a[3]] == ident { + lit = src[a[4]:a[5]] + } + } + if lit == "" { + continue // unresolvable identifier: lose the case, visibly + } + } + opts := src[m[6]:m[7]] + if opts != "0" { + continue // oracle always calls with parser_options 0 + } + limit, err := strconv.Atoi(src[m[8]:m[9]]) + if err != nil { + return nil, err + } + sql, _, err := readCStringLiteral(lit) + if err != nil { + return nil, err + } + out = append(out, summaryCall{SQL: sql, Limit: limit}) + } + return out, nil +} diff --git a/cmd/regenerate/main.go b/cmd/regenerate/main.go index 5272ab4..7cc1225 100644 --- a/cmd/regenerate/main.go +++ b/cmd/regenerate/main.go @@ -49,7 +49,10 @@ func main() { check(err) defer oracle.Close() - // Tier: PostgreSQL regression suite. + // Tier: PostgreSQL regression suite. The summary suite runs untruncated; + // summary_truncate re-runs every statement at limit 100 (the limit rides + // along as a directive line in the case input) to exercise the + // deparse-driven truncation machinery across the whole corpus. regressDir := filepath.Join(*libpgQuery, "test", "sql", "postgres_regress") regressFiles := sqlFiles(regressDir) fmt.Fprintf(os.Stderr, "regenerate: postgres_regress: %d files\n", len(regressFiles)) @@ -59,9 +62,34 @@ func main() { stmts := splitStatements(oracle, preprocessRegress(string(src))) base := strings.TrimSuffix(f, ".sql") emitSQLSuites(oracle, *out, "postgres_regress", base, stmts, - []string{"parse", "scan", "normalize", "fingerprint", "deparse"}) + []string{"parse", "scan", "normalize", "fingerprint", "deparse", "summary"}) + emitSQLSuites(oracle, *out, "postgres_regress", base, withTruncateLimit(stmts, 100), + []string{"summary_truncate"}) } + // Tier: PL/pgSQL regression suite (test/sql/plpgsql_regress). The plpgsql + // suite is the milestone-11 gate; the standard SQL suites run over the + // same statements since CREATE FUNCTION bodies are plain SQL to them. + plpgsqlDir := filepath.Join(*libpgQuery, "test", "sql", "plpgsql_regress") + plpgsqlFiles := sqlFiles(plpgsqlDir) + fmt.Fprintf(os.Stderr, "regenerate: plpgsql_regress: %d files\n", len(plpgsqlFiles)) + for _, f := range plpgsqlFiles { + src, err := os.ReadFile(filepath.Join(plpgsqlDir, f)) + check(err) + stmts := splitStatements(oracle, preprocessRegress(string(src))) + base := strings.TrimSuffix(f, ".sql") + emitSQLSuites(oracle, *out, "plpgsql_regress", base, stmts, + []string{"parse", "scan", "normalize", "fingerprint", "deparse", "summary", "plpgsql"}) + } + + // Tier: libpg_query's PL/pgSQL samples (test/plpgsql_samples.sql, the + // upstream acceptance corpus for pg_query_parse_plpgsql). + samplesSrc, err := os.ReadFile(filepath.Join(*libpgQuery, "test", "plpgsql_samples.sql")) + check(err) + samples := splitStatements(oracle, string(samplesSrc)) + fmt.Fprintf(os.Stderr, "regenerate: plpgsql_samples.sql: %d statements\n", len(samples)) + emitSQLSuites(oracle, *out, "", "plpgsql_samples", samples, []string{"plpgsql"}) + // Tier: deparser roundtrip corpora. deparse/ is flat .sql files; // deparse-depesz/ is .d/ directories of .psql files. deparseDir := filepath.Join(*libpgQuery, "test", "sql", "deparse") @@ -134,6 +162,35 @@ func main() { emitSQLSuites(oracle, *out, "", "libpg_query", inputs, tbl.suites) } + // Tier: libpg_query summary test calls (test/summary_tests.c, + // test/summary_truncate.c — call sites, not tests[] tables; see + // extract_summary.go). Untruncated calls feed the summary suite; + // truncating calls keep their exact upstream limits. + var summaryInputs, truncateInputs []string + for _, file := range []string{"summary_tests.c", "summary_truncate.c"} { + src, err := os.ReadFile(filepath.Join(*libpgQuery, "test", file)) + check(err) + calls, err := extractSummaryCalls(string(src)) + if err != nil { + check(fmt.Errorf("%s: %w", file, err)) + } + fmt.Fprintf(os.Stderr, "regenerate: %s: %d calls\n", file, len(calls)) + for _, c := range calls { + if c.Limit == -1 { + summaryInputs = append(summaryInputs, c.SQL) + } else { + truncateInputs = append(truncateInputs, testfile.WithTruncateLimit(c.Limit, c.SQL)) + } + } + } + // Every untruncated summary input also runs at limit 50, so the inline + // tier exercises truncation beyond the handful of upstream limits. + for _, sql := range summaryInputs { + truncateInputs = append(truncateInputs, testfile.WithTruncateLimit(50, sql)) + } + emitSQLSuites(oracle, *out, "", "libpg_query", summaryInputs, []string{"summary"}) + emitSQLSuites(oracle, *out, "", "libpg_query", truncateInputs, []string{"summary_truncate"}) + // Tier: pg_query_go fingerprint corpus (incl. the 1.1 MB stress insert). var fpCases []struct { Input string `json:"input"` @@ -281,10 +338,66 @@ func goldenFor(oracle *Oracle, suite, sql string) string { return renderOracleError(oerr) } return testfile.RenderSplit(stmts) + case "summary": + sum, oerr, err := oracle.Summary(sql, -1) + check(err) + if oerr != nil { + return renderOracleError(oerr) + } + return renderOracleSummary(sum) + case "summary_truncate": + limit, raw, err := testfile.SplitTruncateLimit(sql) + check(err) + sum, oerr, err := oracle.Summary(raw, limit) + check(err) + if oerr != nil { + return renderOracleError(oerr) + } + return renderOracleSummary(sum) + case "plpgsql": + text, oerr, err := oracle.Text("parse_plpgsql", sql) + check(err) + if oerr != nil { + return renderOracleError(oerr) + } + return text } panic("unknown suite " + suite) } +func withTruncateLimit(stmts []string, limit int) []string { + out := make([]string, len(stmts)) + for i, s := range stmts { + out[i] = testfile.WithTruncateLimit(limit, s) + } + return out +} + +func renderOracleSummary(s *oracleSummary) string { + e := testfile.SummaryExpectation{ + Aliases: s.Aliases, + CteNames: s.CteNames, + StatementTypes: s.StatementTypes, + TruncatedQuery: s.TruncatedQuery, + } + for _, t := range s.Tables { + e.Tables = append(e.Tables, testfile.SummaryTable{ + Name: t.Name, SchemaName: t.SchemaName, TableName: t.TableName, Context: t.Context, + }) + } + for _, f := range s.Functions { + e.Functions = append(e.Functions, testfile.SummaryFunction{ + Name: f.Name, FunctionName: f.FunctionName, SchemaName: f.SchemaName, Context: f.Context, + }) + } + for _, f := range s.FilterColumns { + e.FilterColumns = append(e.FilterColumns, testfile.SummaryFilterColumn{ + SchemaName: f.SchemaName, TableName: f.TableName, Column: f.Column, + }) + } + return testfile.RenderSummary(e) +} + func renderOracleError(e *oracleError) string { return testfile.RenderError(testfile.ErrorExpectation{ Message: e.Message, diff --git a/cmd/regenerate/oracle.go b/cmd/regenerate/oracle.go index 81e1b35..25c9111 100644 --- a/cmd/regenerate/oracle.go +++ b/cmd/regenerate/oracle.go @@ -19,9 +19,10 @@ type Oracle struct { } type oracleReq struct { - Op string `json:"op"` - SQL string `json:"sql"` - TrimSpace bool `json:"trim_space,omitempty"` + Op string `json:"op"` + SQL string `json:"sql"` + TrimSpace bool `json:"trim_space,omitempty"` + TruncateLimit *int `json:"truncate_limit,omitempty"` } type oracleError struct { @@ -40,10 +41,41 @@ type oracleToken struct { } type oracleRes struct { - Text *string `json:"text"` - Stmts []string `json:"stmts"` - Tokens []oracleToken `json:"tokens"` - Err *oracleError `json:"error"` + Text *string `json:"text"` + Stmts []string `json:"stmts"` + Tokens []oracleToken `json:"tokens"` + Summary *oracleSummary `json:"summary"` + Err *oracleError `json:"error"` +} + +type oracleSummaryTable struct { + Name string `json:"name"` + SchemaName string `json:"schema_name"` + TableName string `json:"table_name"` + Context string `json:"context"` +} + +type oracleSummaryFunction struct { + Name string `json:"name"` + FunctionName string `json:"function_name"` + SchemaName string `json:"schema_name"` + Context string `json:"context"` +} + +type oracleSummaryFilterColumn struct { + SchemaName string `json:"schema_name"` + TableName string `json:"table_name"` + Column string `json:"column"` +} + +type oracleSummary struct { + Tables []oracleSummaryTable `json:"tables"` + Aliases map[string]string `json:"aliases"` + CteNames []string `json:"cte_names"` + Functions []oracleSummaryFunction `json:"functions"` + FilterColumns []oracleSummaryFilterColumn `json:"filter_columns"` + StatementTypes []string `json:"statement_types"` + TruncatedQuery string `json:"truncated_query"` } // StartOracle builds (if needed) and starts the oracle binary. bin may name a @@ -123,6 +155,22 @@ func (o *Oracle) Scan(sql string) ([]oracleToken, *oracleError, error) { return res.Tokens, res.Err, nil } +// Summary runs the summary op at the given truncation limit (-1 disables +// truncation, matching pg_query.Summary). +func (o *Oracle) Summary(sql string, truncateLimit int) (*oracleSummary, *oracleError, error) { + res, err := o.call(oracleReq{Op: "summary", SQL: sql, TruncateLimit: &truncateLimit}) + if err != nil { + return nil, nil, err + } + if res.Err != nil { + return nil, res.Err, nil + } + if res.Summary == nil { + return nil, nil, fmt.Errorf("oracle op summary returned neither summary nor error") + } + return res.Summary, nil, nil +} + func (o *Oracle) Split(op, sql string, trimSpace bool) ([]string, *oracleError, error) { res, err := o.call(oracleReq{Op: op, SQL: sql, TrimSpace: trimSpace}) if err != nil { diff --git a/compat_test.go b/compat_test.go index 3085e28..70193af 100644 --- a/compat_test.go +++ b/compat_test.go @@ -19,26 +19,6 @@ func skipUnlessImplemented(t *testing.T) { } } -// TestNotImplementedErrors pins the milestone-1 API contract: every entry -// point exists with pg_query_go's exact signature and fails loudly (not -// silently) until its milestone lands. -func TestNotImplementedErrors(t *testing.T) { - check := func(name string, err error) { - t.Helper() - if err == nil { - t.Fatalf("%s: expected a not-implemented error, got nil", name) - } - if !strings.Contains(err.Error(), "not implemented") { - t.Fatalf("%s: unexpected error %q", name, err) - } - } - - _, err := pg_query.ParsePlPgSqlToJSON("SELECT 1") - check("ParsePlPgSqlToJSON", err) - _, err = pg_query.Summary("SELECT 1", 0) - check("Summary", err) -} - // TestScanTokens pins one token stream end-to-end through the public Scan // API (pg_query_go's TestScan is a smoke test; the corpus goldens carry the // exhaustive coverage). diff --git a/internal/deparse/state.go b/internal/deparse/state.go index 43fe263..dad01bb 100644 --- a/internal/deparse/state.go +++ b/internal/deparse/state.go @@ -332,6 +332,11 @@ func Deparse(tree *ast.ParseResult) (result string, err error) { return string(out), nil } +// QuoteIdentifier exposes quoteIdentifier to the other internal packages +// that need ruleutils.c's quote_identifier (the summary walk renders table +// names with it). +func QuoteIdentifier(ident string) string { return quoteIdentifier(ident) } + // quoteIdentifier is ruleutils.c's quote_identifier (quote_all_identifiers // is always false in libpg_query). func quoteIdentifier(ident string) string { diff --git a/internal/emit/emit.go b/internal/emit/emit.go index fb55ab4..ffd6168 100644 --- a/internal/emit/emit.go +++ b/internal/emit/emit.go @@ -270,6 +270,11 @@ func emitAConst(b *strings.Builder, m protoreflect.Message) { fmt.Fprintf(b, `,"location":%d`, loc) } +// Token exposes emitToken to the other internal packages that emit the same +// JSON string encoding (the PL/pgSQL dump shares _outToken with this +// emitter via pg_query_json_helper.c). +func Token(b *strings.Builder, s string) { emitToken(b, s) } + // emitToken is _outToken: JSON string quoting with the reference's exact // escape set — \b \f \n \r \t \" \\ as two-character escapes, and \u%04x for // other control bytes plus '<' and '>'. diff --git a/internal/parse/modes.go b/internal/parse/modes.go new file mode 100644 index 0000000..6fd3f75 --- /dev/null +++ b/internal/parse/modes.go @@ -0,0 +1,174 @@ +package parse + +import ( + "fmt" + + "github.com/sqlc-dev/oliphant/ast" + "github.com/sqlc-dev/oliphant/internal/lexer" +) + +// Mode mirrors RawParseMode for the entry points raw_parser exposes beyond +// RAW_PARSE_DEFAULT. The PL/pgSQL compiler's check_sql_expr drives the +// non-default modes; RAW_PARSE_TYPE_NAME has no caller here (libpg_query +// mocks parse_datatype away). +type Mode int + +const ( + ModeDefault Mode = iota + ModeTypeName + ModePlpgsqlExpr + ModePlpgsqlAssign1 + ModePlpgsqlAssign2 + ModePlpgsqlAssign3 +) + +// ParseWithMode is raw_parser: parse_toplevel's MODE_* alternatives, each +// wrapping its result in a RawStmt exactly as the grammar actions do. +func ParseWithMode(input string, mode Mode) (res *ast.ParseResult, err *lexer.Error) { + if mode == ModeDefault { + return Parse(input) + } + s := lexer.New(input) + p := &parser{src: s.Input(), filter: lexer.NewFilter(s)} + defer func() { + if r := recover(); r != nil { + if b, ok := r.(bail); ok { + res, err = nil, b.err + return + } + panic(r) + } + }() + + res = &ast.ParseResult{Version: pgVersionNum} + var stmt *ast.Node + switch mode { + case ModePlpgsqlExpr: + // parse_toplevel: MODE_PLPGSQL_EXPR PLpgSQL_Expr + stmt = p.parsePLpgSQLExpr() + case ModePlpgsqlAssign1, ModePlpgsqlAssign2, ModePlpgsqlAssign3: + // parse_toplevel: MODE_PLPGSQL_ASSIGNn PLAssignStmt + nnames := int32(1 + int(mode-ModePlpgsqlAssign1)) + stmt = p.parsePLAssignStmt(nnames) + default: + panic(fmt.Sprintf("parse mode %d not supported", mode)) + } + + // The mode productions cover the whole input; anything left over is a + // syntax error at that token, as in bison. + if tok := p.peek(); tok.Kind != 0 { + p.syntaxError(tok) + } + + res.Stmts = []*ast.RawStmt{{Stmt: stmt, StmtLocation: 0}} + return res, nil +} + +// parsePLpgSQLExpr is gram.y's PLpgSQL_Expr: everything that can follow +// SELECT, without the SELECT keyword; the result is a SelectStmt. +func (p *parser) parsePLpgSQLExpr() *ast.Node { + n := &ast.SelectStmt{ + LimitOption: ast.LimitOption_LIMIT_OPTION_DEFAULT, + Op: ast.SetOperation_SETOP_NONE, + } + + // opt_distinct_clause: distinct_clause | opt_all_clause + requireTargets := false + switch p.kind() { + case ast.Token_ALL: + p.next() + case ast.Token_DISTINCT: + p.next() + if p.have(ast.Token_ON) { + p.expect(ast.Token('(')) + n.DistinctClause = p.parseExprList() + p.expect(ast.Token(')')) + } else { + // DISTINCT: list_make1(NIL) — a single empty-list placeholder. + n.DistinctClause = []*ast.Node{{}} + } + requireTargets = true + } + + // opt_target_list + if requireTargets || p.startsTargetEl() { + n.TargetList = p.parseTargetList() + } + // from_clause + if p.have(ast.Token_FROM) { + n.FromClause = p.parseFromList() + } + // where_clause + if p.have(ast.Token_WHERE) { + n.WhereClause = p.parseAExpr(0) + } + // group_clause + if p.kind() == ast.Token_GROUP_P { + p.next() + p.expect(ast.Token_BY) + if p.have(ast.Token_ALL) { + } else if p.have(ast.Token_DISTINCT) { + n.GroupDistinct = true + } + n.GroupClause = p.parseGroupByList() + } + // having_clause + if p.have(ast.Token_HAVING) { + n.HavingClause = p.parseAExpr(0) + } + // window_clause + if p.have(ast.Token_WINDOW) { + n.WindowClause = p.parseWindowDefinitionList() + } + // opt_sort_clause + if p.kind() == ast.Token_ORDER { + n.SortClause = p.parseSortClauseKeyword() + } + // opt_select_limit + if p.kind() == ast.Token_LIMIT || p.kind() == ast.Token_OFFSET || + p.kind() == ast.Token_FETCH { + limit := p.parseSelectLimit() + n.LimitOffset = limit.limitOffset + n.LimitCount = limit.limitCount + if n.SortClause == nil && limit.limitOption == ast.LimitOption_LIMIT_OPTION_WITH_TIES { + p.ereport("base_yyparse", "WITH TIES cannot be specified without ORDER BY clause", -1) + } + n.LimitOption = limit.limitOption + } + // opt_for_locking_clause + for p.kind() == ast.Token_FOR { + n.LockingClause = append(n.LockingClause, p.parseForLockingClause()...) + } + + return nSelectStmt(n) +} + +// parsePLAssignStmt is gram.y's PLAssignStmt: +// plassign_target opt_indirection plassign_equals PLpgSQL_Expr. +func (p *parser) parsePLAssignStmt(nnames int32) *ast.Node { + n := &ast.PLAssignStmt{Nnames: nnames} + + // plassign_target: ColId | PARAM + tok := p.peek() + n.Location = tok.Start + if tok.Kind == ast.Token_PARAM { + p.next() + n.Name = fmt.Sprintf("$%d", tok.Ival) + } else { + n.Name = p.colId() + } + + n.Indirection = p.check_indirection(p.parseOptIndirection()) + + // plassign_equals: COLON_EQUALS | '=' + tok = p.peek() + if tok.Kind != ast.Token_COLON_EQUALS && tok.Kind != ast.Token('=') { + p.syntaxError(tok) + } + p.next() + + val := p.parsePLpgSQLExpr() + n.Val = val.GetSelectStmt() + + return &ast.Node{Node: &ast.Node_PlassignStmt{PlassignStmt: n}} +} diff --git a/internal/plpgsql/ast.go b/internal/plpgsql/ast.go new file mode 100644 index 0000000..f3d751c --- /dev/null +++ b/internal/plpgsql/ast.go @@ -0,0 +1,533 @@ +// Package plpgsql is the hand-written port of libpg_query's PL/pgSQL support +// as pinned at 17-6.2.2: pl_gram.y + pl_scanner.c (patched, see +// internal/reference/), the pl_comp.c / pl_funcs.c subset libpg_query +// extracts (including its mocks — parse_datatype and friends do not consult +// the catalogs), pg_query_json_plpgsql.c, and the pg_query_parse_plpgsql.c +// driver behind ParsePlPgSqlToJSON. +package plpgsql + +// The execution-tree node structs mirror plpgsql.h field-for-field, limited +// to what the parser fills in and the JSON dump reads. + +// plpgsql.h: PLpgSQL_datum_type +type datumType int + +const ( + dtypeVar datumType = iota + dtypeRow + dtypeRec + dtypeRecfield + dtypePromise +) + +// plpgsql.h: PLpgSQL_type_type +type typeType int + +const ( + ttypeScalar typeType = iota + ttypeRec + ttypePseudo +) + +// plpgsql.h: PLpgSQL_nsitem_type / PLpgSQL_label_type +type nsItemType int + +const ( + nsTypeLabel nsItemType = iota + nsTypeVar + nsTypeRec +) + +type labelType int + +const ( + labelBlock labelType = iota + labelLoop + labelOther +) + +// plpgsql.h: PLpgSQL_getdiag_kind +type getdiagKind int + +const ( + getdiagRowCount getdiagKind = iota + getdiagRoutineOid + getdiagContext + getdiagErrorContext + getdiagErrorDetail + getdiagErrorHint + getdiagReturnedSqlstate + getdiagColumnName + getdiagConstraintName + getdiagDatatypeName + getdiagMessageText + getdiagTableName + getdiagSchemaName +) + +// pl_funcs.c: plpgsql_getdiag_kindname +func getdiagKindname(kind getdiagKind) string { + switch kind { + case getdiagRowCount: + return "ROW_COUNT" + case getdiagRoutineOid: + return "PG_ROUTINE_OID" + case getdiagContext: + return "PG_CONTEXT" + case getdiagErrorContext: + return "PG_EXCEPTION_CONTEXT" + case getdiagErrorDetail: + return "PG_EXCEPTION_DETAIL" + case getdiagErrorHint: + return "PG_EXCEPTION_HINT" + case getdiagReturnedSqlstate: + return "RETURNED_SQLSTATE" + case getdiagColumnName: + return "COLUMN_NAME" + case getdiagConstraintName: + return "CONSTRAINT_NAME" + case getdiagDatatypeName: + return "PG_DATATYPE_NAME" + case getdiagMessageText: + return "MESSAGE_TEXT" + case getdiagTableName: + return "TABLE_NAME" + case getdiagSchemaName: + return "SCHEMA_NAME" + } + return "unknown" +} + +// plpgsql.h: PLpgSQL_raise_option_type +type raiseOptionType int + +const ( + raiseOptionErrcode raiseOptionType = iota + raiseOptionMessage + raiseOptionDetail + raiseOptionHint + raiseOptionColumn + raiseOptionConstraint + raiseOptionDatatype + raiseOptionTable + raiseOptionSchema +) + +// utils/elog.h severity levels (the subset RAISE uses). +const ( + elogDebug1 = 14 + elogLog = 15 + elogInfo = 17 + elogNotice = 18 + elogWarning = 19 + elogError = 21 +) + +// nodes/parsenodes.h: cursor options and FETCH_ALL +const ( + cursorOptScroll = 0x0002 + cursorOptNoScroll = 0x0004 + cursorOptFastPlan = 0x0100 + + fetchAll = int64(^uint64(0) >> 1) // FETCH_ALL = LONG_MAX +) + +// nodes/parsenodes.h: FetchDirection +type fetchDirection int + +const ( + fetchForward fetchDirection = iota + fetchBackward + fetchAbsolute + fetchRelative +) + +// nodes/parsenodes.h: RawParseMode +type rawParseMode int + +const ( + rawParseDefault rawParseMode = iota + rawParseTypeName + rawParsePlpgsqlExpr + rawParsePlpgsqlAssign1 + rawParsePlpgsqlAssign2 + rawParsePlpgsqlAssign3 +) + +// plpgsql.h: PLpgSQL_resolve_option +type resolveOption int + +const ( + resolveError resolveOption = iota + resolveVariable + resolveColumn +) + +// --- datums ------------------------------------------------------------------ + +// datum is the common interface of PLpgSQL_datum structs (dno + dtype). +type datum interface { + datumNo() int + setDatumNo(int) + datumType() datumType +} + +type datumCommon struct { + dno int +} + +func (d *datumCommon) datumNo() int { return d.dno } +func (d *datumCommon) setDatumNo(n int) { d.dno = n } + +// plType is PLpgSQL_type (the fields the libpg_query build fills). +type plType struct { + typname string // patched in: the source spelling (or quoted qualified name) + ttype typeType + typoid uint32 // only refcursor/text/bool/int4 distinctions matter + atttypmod int32 + collation uint32 + typisarray bool +} + +// plVar is PLpgSQL_var. +type plVar struct { + datumCommon + refname string + lineno int + datatype *plType + isconst bool + notnull bool + + defaultVal *plExpr + cursorExplicitExpr *plExpr + cursorExplicitArgrow int + cursorOptions int +} + +func (*plVar) datumType() datumType { return dtypeVar } + +// plRow is PLpgSQL_row. +type plRow struct { + datumCommon + refname string + lineno int + fieldnames []string + varnos []int +} + +func (*plRow) datumType() datumType { return dtypeRow } + +// plRec is PLpgSQL_rec. +type plRec struct { + datumCommon + refname string + lineno int + datatype *plType + rectypeid uint32 + firstfield int +} + +func (*plRec) datumType() datumType { return dtypeRec } + +// plRecfield is PLpgSQL_recfield. +type plRecfield struct { + datumCommon + fieldname string + recparentno int + nextfield int +} + +func (*plRecfield) datumType() datumType { return dtypeRecfield } + +// variable() reports whether a datum is a PLpgSQL_variable (var/row/rec) and +// gives access to the shared header fields. +type plVariable interface { + datum + varRefname() string + varIsConst() bool +} + +func (v *plVar) varRefname() string { return v.refname } +func (v *plVar) varIsConst() bool { return v.isconst } +func (r *plRow) varRefname() string { return r.refname } +func (r *plRow) varIsConst() bool { return false } +func (r *plRec) varRefname() string { return r.refname } +func (r *plRec) varIsConst() bool { return false } + +// plExpr is PLpgSQL_expr. +type plExpr struct { + query string + parseMode rawParseMode +} + +// --- statements -------------------------------------------------------------- + +type plStmt interface{ stmtLineno() int } + +type stmtCommon struct { + lineno int +} + +func (s *stmtCommon) stmtLineno() int { return s.lineno } + +type stmtBlock struct { + stmtCommon + label string + body []plStmt + initVarnos []int // n_initvars/initvarnos (not serialized) + exceptions *exceptionBlock +} + +type exceptionBlock struct { + sqlstateVarno int + sqlerrmVarno int + excList []*plException +} + +type plException struct { + lineno int + conditions *plCondition + action []plStmt +} + +type plCondition struct { + sqlerrstate int + condname string + next *plCondition +} + +type stmtAssign struct { + stmtCommon + varno int + expr *plExpr +} + +type stmtIf struct { + stmtCommon + cond *plExpr + thenBody []plStmt + elsifList []*ifElsif + elseBody []plStmt +} + +type ifElsif struct { + lineno int + cond *plExpr + stmts []plStmt +} + +type stmtCase struct { + stmtCommon + tExpr *plExpr + tVarno int + caseWhenList []*caseWhen + haveElse bool + elseStmts []plStmt +} + +type caseWhen struct { + lineno int + expr *plExpr + stmts []plStmt +} + +type stmtLoop struct { + stmtCommon + label string + body []plStmt +} + +type stmtWhile struct { + stmtCommon + label string + cond *plExpr + body []plStmt +} + +type stmtFori struct { + stmtCommon + label string + varDat *plVar + lower *plExpr + upper *plExpr + step *plExpr + reverse bool + body []plStmt +} + +type stmtFors struct { + stmtCommon + label string + varDat plVariable + body []plStmt + query *plExpr +} + +type stmtForc struct { + stmtCommon + label string + varDat plVariable + body []plStmt + curvar int + argquery *plExpr +} + +type stmtDynfors struct { + stmtCommon + label string + varDat plVariable + body []plStmt + query *plExpr + params []*plExpr +} + +type stmtForeachA struct { + stmtCommon + label string + varno int + slice int + expr *plExpr + body []plStmt +} + +type stmtExit struct { + stmtCommon + isExit bool + label string + cond *plExpr +} + +type stmtReturn struct { + stmtCommon + expr *plExpr + retvarno int +} + +type stmtReturnNext struct { + stmtCommon + expr *plExpr + retvarno int +} + +type stmtReturnQuery struct { + stmtCommon + query *plExpr + dynquery *plExpr + params []*plExpr +} + +type stmtRaise struct { + stmtCommon + elogLevel int + condname string + message string + hasMessage bool + params []*plExpr + options []*raiseOption +} + +type raiseOption struct { + optType raiseOptionType + expr *plExpr +} + +type stmtAssert struct { + stmtCommon + cond *plExpr + message *plExpr +} + +type stmtExecsql struct { + stmtCommon + sqlstmt *plExpr + into bool + strict bool + target plVariable +} + +type stmtDynexecute struct { + stmtCommon + query *plExpr + into bool + strict bool + target plVariable + params []*plExpr +} + +type stmtGetdiag struct { + stmtCommon + isStacked bool + diagItems []*diagItem +} + +type diagItem struct { + kind getdiagKind + target int +} + +type stmtOpen struct { + stmtCommon + curvar int + cursorOptions int + argquery *plExpr + query *plExpr + dynquery *plExpr + params []*plExpr +} + +type stmtFetch struct { + stmtCommon + target plVariable + curvar int + direction fetchDirection + howMany int64 + expr *plExpr + isMove bool + returnsMultipleRows bool +} + +type stmtClose struct { + stmtCommon + curvar int +} + +type stmtPerform struct { + stmtCommon + expr *plExpr +} + +type stmtCall struct { + stmtCommon + expr *plExpr + isCall bool + target plVariable +} + +type stmtCommit struct { + stmtCommon + chain bool +} + +type stmtRollback struct { + stmtCommon + chain bool +} + +// plFunction is PLpgSQL_function (the serialized subset). +type plFunction struct { + fnSignature string + fnRetset bool + fnIsProc bool // PROKIND_PROCEDURE (unused: driver always compiles as FUNCTION) + + newVarno int + oldVarno int + foundVarno int + outParamVarno int + + datums []datum + action *stmtBlock + nstatements uint32 + + printStrictParams bool + resolveOption resolveOption +} diff --git a/internal/plpgsql/comp.go b/internal/plpgsql/comp.go new file mode 100644 index 0000000..2ef0048 --- /dev/null +++ b/internal/plpgsql/comp.go @@ -0,0 +1,461 @@ +package plpgsql + +import ( + "github.com/sqlc-dev/oliphant/ast" + "github.com/sqlc-dev/oliphant/internal/deparse" +) + +// compileError carries an ereport out of the compile (message and the C +// error-data fields the golden format serializes). Context is attached at +// the catch site by the compile error callback logic. +type compileError struct { + Message string + Filename string + Funcname string + Cursorpos int + Context string +} + +func (e *compileError) Error() string { return e.Message } + +// Filenames as __FILE__ expands in the vendored libpg_query build. +const ( + plGramFilename = "pl_gram.y" + plCompFilename = "src_pl_plpgsql_src_pl_comp.c" +) + +// pg_type.h OIDs (the ones the stripped pl_comp build distinguishes). +const ( + oidBool = 16 + oidInt4 = 23 + oidText = 25 + oidUnknown = 705 + oidRefcursor = 1790 + oidRecord = 2249 + oidVoid = 2278 + + oidDefaultCollation = 100 +) + +// compiler bundles the per-compile globals of pl_comp.c / pl_scanner.c. +type compiler struct { + scan *plScanner + + fn *plFunction + + nsTop *nsItem + + datums []datum // plpgsql_Datums + datumsLast int // datums_last + + checkSyntax bool // plpgsql_check_syntax (always true here) + errFuncname string // plpgsql_error_funcname + nDatums int // plpgsql_nDatums (== len(datums)) +} + +// --- namespace (pl_funcs.c) -------------------------------------------------- + +type nsItem struct { + itemtype nsItemType + itemno int + prev *nsItem + name string +} + +// nsInit is plpgsql_ns_init. +func (c *compiler) nsInit() { c.nsTop = nil } + +// nsPush is plpgsql_ns_push. +func (c *compiler) nsPush(label string, labelType labelType) { + c.nsAdditem(nsTypeLabel, int(labelType), label) +} + +// nsPop is plpgsql_ns_pop. +func (c *compiler) nsPop() { + for c.nsTop.itemtype != nsTypeLabel { + c.nsTop = c.nsTop.prev + } + c.nsTop = c.nsTop.prev +} + +// nsAdditem is plpgsql_ns_additem. +func (c *compiler) nsAdditem(itemtype nsItemType, itemno int, name string) { + c.nsTop = &nsItem{itemtype: itemtype, itemno: itemno, prev: c.nsTop, name: name} +} + +// nsLookup is plpgsql_ns_lookup. name2/name3 empty mean NULL. +func (c *compiler) nsLookup(nsCur *nsItem, localmode bool, name1, name2, name3 string) (*nsItem, int) { + for nsCur != nil { + var nsitem *nsItem + + // Check this level for unqualified match to variable name + for nsitem = nsCur; nsitem.itemtype != nsTypeLabel; nsitem = nsitem.prev { + if nsitem.name == name1 { + if name2 == "" || nsitem.itemtype != nsTypeVar { + return nsitem, 1 + } + } + } + + // Check this level for qualified match to variable name + if name2 != "" && nsitem.name == name1 { + for inner := nsCur; inner.itemtype != nsTypeLabel; inner = inner.prev { + if inner.name == name2 { + if name3 == "" || inner.itemtype != nsTypeVar { + return inner, 2 + } + } + } + } + + if localmode { + break // do not look into upper levels + } + nsCur = nsitem.prev + } + return nil, 0 +} + +// nsLookupLabel is plpgsql_ns_lookup_label. +func (c *compiler) nsLookupLabel(nsCur *nsItem, name string) *nsItem { + for ; nsCur != nil; nsCur = nsCur.prev { + if nsCur.itemtype == nsTypeLabel && nsCur.name == name { + return nsCur + } + } + return nil +} + +// nsFindNearestLoop is plpgsql_ns_find_nearest_loop. +func (c *compiler) nsFindNearestLoop(nsCur *nsItem) *nsItem { + for ; nsCur != nil; nsCur = nsCur.prev { + if nsCur.itemtype == nsTypeLabel && nsCur.itemno == int(labelLoop) { + return nsCur + } + } + return nil +} + +// --- datums ------------------------------------------------------------------ + +// startDatums is plpgsql_start_datums. +func (c *compiler) startDatums() { + c.datums = nil + c.datumsLast = 0 +} + +// addDatum is plpgsql_adddatum. +func (c *compiler) addDatum(d datum) { + d.setDatumNo(len(c.datums)) + c.datums = append(c.datums, d) +} + +// finishDatums is plpgsql_finish_datums. +func (c *compiler) finishDatums() { + c.fn.datums = append([]datum(nil), c.datums...) +} + +// addInitdatums is plpgsql_add_initdatums; varnos == nil forgets. +func (c *compiler) addInitdatums(collect bool) []int { + var varnos []int + for i := c.datumsLast; i < len(c.datums); i++ { + switch c.datums[i].datumType() { + case dtypeVar, dtypeRec: + if collect { + varnos = append(varnos, c.datums[i].datumNo()) + } + } + } + c.datumsLast = len(c.datums) + return varnos +} + +// --- variable building ------------------------------------------------------- + +// buildVariable is plpgsql_build_variable. +func (c *compiler) buildVariable(refname string, lineno int, dtype *plType, add2namespace bool) plVariable { + switch dtype.ttype { + case ttypeScalar: + v := &plVar{ + refname: refname, + lineno: lineno, + datatype: dtype, + cursorExplicitArgrow: 0, + } + c.addDatum(v) + if add2namespace { + c.nsAdditem(nsTypeVar, v.dno, refname) + } + return v + case ttypeRec: + return c.buildRecord(refname, lineno, dtype, dtype.typoid, add2namespace) + case ttypePseudo: + // format_type_be is mocked to "-" in the vendored build. + panic(&compileError{ + Message: `variable "` + refname + `" has pseudo-type -`, + Filename: plCompFilename, + Funcname: "plpgsql_build_variable", + }) + } + return nil +} + +// buildRecord is plpgsql_build_record. +func (c *compiler) buildRecord(refname string, lineno int, dtype *plType, rectypeid uint32, add2namespace bool) *plRec { + rec := &plRec{ + refname: refname, + lineno: lineno, + datatype: dtype, + rectypeid: rectypeid, + firstfield: -1, + } + c.addDatum(rec) + if add2namespace { + c.nsAdditem(nsTypeRec, rec.dno, rec.refname) + } + return rec +} + +// buildRecfield is plpgsql_build_recfield. +func (c *compiler) buildRecfield(rec *plRec, fldname string) *plRecfield { + for i := rec.firstfield; i >= 0; { + fld := c.datums[i].(*plRecfield) + if fld.fieldname == fldname { + return fld + } + i = fld.nextfield + } + recfield := &plRecfield{ + fieldname: fldname, + recparentno: rec.dno, + } + c.addDatum(recfield) + recfield.nextfield = rec.firstfield + rec.firstfield = recfield.dno + return recfield +} + +// buildDatatype is the vendored plpgsql_build_datatype mock: no catalog +// access; the type name comes from the parsed TypeName (or the handful of +// hardwired OIDs). +func buildDatatype(typeOid uint32, typmod int32, collation uint32, origtypname *ast.TypeName) *plType { + typ := &plType{ + ttype: ttypeScalar, + atttypmod: typmod, + collation: collation, + } + var ident, ns string + if origtypname != nil { + typ.typoid = uint32(origtypname.TypeOid) + switch len(origtypname.Names) { + case 1: + ident = origtypname.Names[0].GetString_().GetSval() + case 2: + ns = origtypname.Names[0].GetString_().GetSval() + ident = origtypname.Names[1].GetString_().GetSval() + if ns != "pg_catalog" { + typ.ttype = ttypeRec + } + } + } else { + typ.typoid = typeOid + ns = "pg_catalog" + switch typeOid { + case oidBool: + ident = "boolean" + case oidInt4: + ident = "integer" + case oidText: + ident = "text" + case oidRefcursor: + ident = "refcursor" + } + } + if ident != "" { + typ.typname = quoteQualifiedIdentifier(ns, ident) + } + return typ +} + +// buildDatatypeArrayof is the vendored plpgsql_build_datatype_arrayof mock. +func buildDatatypeArrayof(dtype *plType) *plType { + if dtype.typisarray { + return dtype + } + arr := &plType{ + ttype: ttypeRec, + atttypmod: dtype.atttypmod, + collation: dtype.collation, + typisarray: true, + } + switch dtype.typoid { + case oidBool: + arr.typname = "boolean[]" + case oidInt4: + arr.typname = "integer[]" + case oidText: + arr.typname = "text[]" + default: + arr.typname = "UNKNOWN" + } + arr.typoid = dtype.typoid + return arr +} + +// quoteQualifiedIdentifier is ruleutils.c's quote_qualified_identifier. +func quoteQualifiedIdentifier(qualifier, ident string) string { + if qualifier != "" { + return deparse.QuoteIdentifier(qualifier) + "." + deparse.QuoteIdentifier(ident) + } + return deparse.QuoteIdentifier(ident) +} + +// --- word lookup (pl_comp.c) ------------------------------------------------- + +// parseWord is plpgsql_parse_word. +func (c *compiler) parseWord(word1 string, quoted bool, lookup bool, wdatum *plWdatum, word *plWord) bool { + if lookup && c.scan.identifierLookup == lookupNormal { + if ns, _ := c.nsLookup(c.nsTop, false, word1, "", ""); ns != nil { + switch ns.itemtype { + case nsTypeVar, nsTypeRec: + wdatum.datum = c.datums[ns.itemno] + wdatum.ident = word1 + wdatum.quoted = quoted + wdatum.idents = nil + return true + } + } + } + word.ident = word1 + word.quoted = quoted + return false +} + +// parseDblword is plpgsql_parse_dblword. +func (c *compiler) parseDblword(word1, word2 string, wdatum *plWdatum, cword *[]string) bool { + idents := []string{word1, word2} + if c.scan.identifierLookup != lookupDeclare { + ns, nnames := c.nsLookup(c.nsTop, false, word1, word2, "") + if ns != nil { + switch ns.itemtype { + case nsTypeVar: + // Block-qualified reference to scalar variable. + wdatum.datum = c.datums[ns.itemno] + wdatum.ident = "" + wdatum.quoted = false + wdatum.idents = idents + return true + case nsTypeRec: + if nnames == 1 { + // First word is a record name; second could be a field. + rec := c.datums[ns.itemno].(*plRec) + wdatum.datum = c.buildRecfield(rec, word2) + } else { + // Block-qualified reference to record variable. + wdatum.datum = c.datums[ns.itemno] + } + wdatum.ident = "" + wdatum.quoted = false + wdatum.idents = idents + return true + } + } + } + *cword = idents + return false +} + +// parseTripword is plpgsql_parse_tripword. +func (c *compiler) parseTripword(word1, word2, word3 string, wdatum *plWdatum, cword *[]string) bool { + if c.scan.identifierLookup != lookupDeclare { + ns, nnames := c.nsLookup(c.nsTop, false, word1, word2, word3) + if ns != nil && ns.itemtype == nsTypeRec { + rec := c.datums[ns.itemno].(*plRec) + var idents []string + var fld *plRecfield + if nnames == 1 { + fld = c.buildRecfield(rec, word2) + idents = []string{word1, word2} + } else { + fld = c.buildRecfield(rec, word3) + idents = []string{word1, word2, word3} + } + wdatum.datum = fld + wdatum.ident = "" + wdatum.quoted = false + wdatum.idents = idents + return true + } + } + *cword = []string{word1, word2, word3} + return false +} + +// %TYPE / %ROWTYPE lookups are mocked to NULL in the vendored build. +func (c *compiler) parseWordType(string) *plType { return nil } +func (c *compiler) parseWordRowType(string) *plType { return nil } +func (c *compiler) parseCwordType([]string) *plType { return nil } +func (c *compiler) parseCwordRowType([]string) *plType { + return nil +} + +// --- exception conditions ---------------------------------------------------- + +// recognizeErrCondition is plpgsql_recognize_err_condition (the returned +// SQLSTATE value is never serialized, so only validity matters). +func recognizeErrCondition(condname string, allowSqlstate bool) { + if allowSqlstate && len(condname) == 5 && isSqlstate(condname) { + return + } + if errConditions[condname] > 0 { + return + } + panic(&compileError{ + Message: `unrecognized exception condition "` + condname + `"`, + Filename: plCompFilename, + Funcname: "plpgsql_recognize_err_condition", + }) +} + +// parseErrCondition is plpgsql_parse_err_condition: one chain node per +// exception_label_map entry with the name (duplicates produce chains). +func parseErrCondition(condname string) *plCondition { + if condname == "others" { + return &plCondition{condname: condname} + } + n := errConditions[condname] + if n == 0 { + panic(&compileError{ + Message: `unrecognized exception condition "` + condname + `"`, + Filename: plCompFilename, + Funcname: "plpgsql_parse_err_condition", + }) + } + var prev *plCondition + for i := 0; i < n; i++ { + prev = &plCondition{condname: condname, next: prev} + } + return prev +} + +func isSqlstate(s string) bool { + for i := 0; i < len(s); i++ { + c := s[i] + if !(c >= '0' && c <= '9' || c >= 'A' && c <= 'Z') { + return false + } + } + return true +} + +// nameListToString is NameListToString over plain identifier lists. +func nameListToString(names []string) string { + out := "" + for i, n := range names { + if i > 0 { + out += "." + } + out += n + } + return out +} diff --git a/internal/plpgsql/entry.go b/internal/plpgsql/entry.go new file mode 100644 index 0000000..d347bc2 --- /dev/null +++ b/internal/plpgsql/entry.go @@ -0,0 +1,329 @@ +package plpgsql + +import ( + "fmt" + "strings" + + "github.com/sqlc-dev/oliphant/ast" + "github.com/sqlc-dev/oliphant/internal/parse" + "github.com/sqlc-dev/oliphant/internal/rawwalk" +) + +// Error is the public error shape of a PL/pgSQL parse or compile failure. +type Error struct { + Message string + Filename string + Funcname string + Cursorpos int + Context string +} + +func (e *Error) Error() string { return e.Message } + +// ParseToJSON is pg_query_parse_plpgsql: parse the whole input with the SQL +// parser, collect CREATE FUNCTION/PROCEDURE and DO statements, compile each +// with the PL/pgSQL parser, and emit the JSON array of function dumps. +func ParseToJSON(input string) (string, *Error) { + tree, perr := parse.Parse(input) + if perr != nil { + return "", &Error{ + Message: perr.Message, + Filename: perr.Filename, + Funcname: perr.Funcname, + Cursorpos: perr.Cursorpos, + } + } + + // stmts_walker: collect CreateFunctionStmt and DoStmt nodes. + var stmts []any + var walk func(item any) bool + walk = func(item any) bool { + c := rawwalk.Concrete(item) + if rawwalk.IsNil(c) { + return false + } + switch v := c.(type) { + case *ast.CreateFunctionStmt: + stmts = append(stmts, v) + case *ast.DoStmt: + stmts = append(stmts, v) + case *ast.RawStmt: + return walk(v.Stmt) + } + return rawwalk.WalkChildren(item, walk) + } + if len(tree.Stmts) > 0 { + walk(rawwalk.RawStmtList(tree.Stmts)) + } + + if len(stmts) == 0 { + return "[]", nil + } + + var out strings.Builder + out.WriteString("[\n") + for _, stmt := range stmts { + fn, cerr := rawParsePlpgsql(stmt) + if cerr != nil { + return "", cerr + } + out.WriteString(toJSON(fn)) + out.WriteString(",\n") + } + // Replace the trailing ",\n" with "\n]". + s := out.String() + return s[:len(s)-2] + "\n]", nil +} + +// rawParsePlpgsql is pg_query_raw_parse_plpgsql: compile one statement, +// catching ereports and decorating them with the compile error context +// (function_parse_error_transpose is mocked to false in this build, so the +// "near line N" context is always used). +func rawParsePlpgsql(stmt any) (fn *plFunction, outErr *Error) { + c := &compiler{checkSyntax: true} + + defer func() { + if r := recover(); r != nil { + ce, ok := r.(*compileError) + if !ok { + panic(r) + } + e := &Error{ + Message: ce.Message, + Filename: ce.Filename, + Funcname: ce.Funcname, + Cursorpos: ce.Cursorpos, + } + // plpgsql_compile_error_callback. + if c.errFuncname != "" { + lineno := 0 + if c.scan != nil { + lineno = c.scan.latestLineno() + } + e.Context = fmt.Sprintf("compilation of PL/pgSQL function \"%s\" near line %d", + c.errFuncname, lineno) + } + fn, outErr = nil, e + } + }() + + switch v := stmt.(type) { + case *ast.CreateFunctionStmt: + return c.compileCreateFunctionStmt(v), nil + case *ast.DoStmt: + return c.compileDoStmt(v), nil + } + return nil, nil +} + +// compileDoStmt is compile_do_stmt. +func (c *compiler) compileDoStmt(stmt *ast.DoStmt) *plFunction { + procSource := "" + haveSource := false + language := "plpgsql" + for _, arg := range stmt.Args { + elem := arg.GetDefElem() + if elem == nil { + continue + } + switch elem.Defname { + case "as": + procSource = elem.Arg.GetString_().GetSval() + haveSource = true + case "language": + language = elem.Arg.GetString_().GetSval() + } + } + _ = haveSource + + if language != "plpgsql" { + return &plFunction{} + } + return c.compileInline(procSource) +} + +// compileInline is plpgsql_compile_inline (pl_comp.c). +func (c *compiler) compileInline(procSource string) *plFunction { + funcName := "inline_code_block" + + c.scan = newScanner(procSource, c) + c.errFuncname = funcName + + // Do extra syntax checking if check_function_bodies is on (it is). + c.checkSyntax = true + + fn := &plFunction{ + fnSignature: funcName, + outParamVarno: -1, + resolveOption: resolveError, + } + c.fn = fn + + c.nsInit() + c.nsPush(funcName, labelBlock) + c.startDatums() + + // Set up as though in a function returning VOID. + fn.fnRetset = false + + // Create the magic FOUND variable. + v := c.buildVariable("found", 0, buildDatatype(oidBool, -1, 0, nil), true) + fn.foundVarno = v.datumNo() + + // Now parse the function's text. + fn.action = c.parseFunction() + + // If it returns VOID (always true at the moment), we allow control to + // fall off the end without an explicit RETURN statement. + c.addDummyReturnInline() + + c.finishDatums() + c.errFuncname = "" + return fn +} + +// addDummyReturnInline is pl_comp.c's add_dummy_return (checks label as well +// as exceptions when deciding to wrap the outer block). +func (c *compiler) addDummyReturnInline() { + fn := c.fn + if fn.action.exceptions != nil || fn.action.label != "" { + wrap := &stmtBlock{body: []plStmt{fn.action}} + fn.action = wrap + } + c.appendDummyReturn() +} + +// addDummyReturnDriver is pg_query_parse_plpgsql.c's local add_dummy_return +// (only the EXCEPTION clause forces the wrapper block). +func (c *compiler) addDummyReturnDriver() { + fn := c.fn + if fn.action.exceptions != nil { + wrap := &stmtBlock{body: []plStmt{fn.action}} + fn.action = wrap + } + c.appendDummyReturn() +} + +func (c *compiler) appendDummyReturn() { + fn := c.fn + body := fn.action.body + needReturn := len(body) == 0 + if !needReturn { + _, isReturn := body[len(body)-1].(*stmtReturn) + needReturn = !isReturn + } + if needReturn { + fn.action.body = append(fn.action.body, &stmtReturn{retvarno: fn.outParamVarno}) + } +} + +// compileCreateFunctionStmt is pg_query_parse_plpgsql.c's +// compile_create_function_stmt. +func (c *compiler) compileCreateFunctionStmt(stmt *ast.CreateFunctionStmt) *plFunction { + funcName := "" + if len(stmt.Funcname) > 0 { + funcName = stmt.Funcname[0].GetString_().GetSval() + } + + procSource := "" + language := "plpgsql" + for _, opt := range stmt.Options { + elem := opt.GetDefElem() + if elem == nil { + continue + } + switch elem.Defname { + case "as": + for _, item := range elem.Arg.GetList().GetItems() { + procSource = item.GetString_().GetSval() + } + case "language": + language = elem.Arg.GetString_().GetSval() + } + } + + if language != "plpgsql" { + return &plFunction{} + } + + isTrigger := false + isSetof := false + if stmt.ReturnType != nil { + for _, n := range stmt.ReturnType.Names { + if n.GetString_().GetSval() == "trigger" { + isTrigger = true + } + } + if stmt.ReturnType.Setof { + isSetof = true + } + } + + c.scan = newScanner(procSource, c) + c.errFuncname = funcName + c.checkSyntax = true + + fn := &plFunction{ + fnSignature: funcName, + outParamVarno: -1, + resolveOption: resolveError, + } + c.fn = fn + + c.nsInit() + c.nsPush(funcName, labelBlock) + c.startDatums() + + // Setup parameter names. + for i, p := range stmt.Parameters { + param := p.GetFunctionParameter() + if param == nil { + continue + } + buf := fmt.Sprintf("$%d", i+1) + argdtype := buildDatatype(oidUnknown, -1, 0, param.ArgType) + name := param.Name + if name == "" { + name = buf + } + argvariable := c.buildVariable(name, 0, argdtype, false) + if param.Mode == ast.FunctionParameterMode_FUNC_PARAM_OUT || + param.Mode == ast.FunctionParameterMode_FUNC_PARAM_INOUT || + param.Mode == ast.FunctionParameterMode_FUNC_PARAM_TABLE { + fn.outParamVarno = argvariable.datumNo() + } + argitemtype := nsTypeVar + if argvariable.datumType() != dtypeVar { + argitemtype = nsTypeRec + } + c.nsAdditem(argitemtype, argvariable.datumNo(), buf) + if param.Name != "" { + c.nsAdditem(argitemtype, argvariable.datumNo(), param.Name) + } + } + + // Set up as though in a function returning VOID. + fn.fnRetset = isSetof + + // Create the magic FOUND variable. + v := c.buildVariable("found", 0, buildDatatype(oidBool, -1, 0, nil), true) + fn.foundVarno = v.datumNo() + + if isTrigger { + // Add the records for referencing NEW and OLD. + rec := c.buildRecord("new", 0, nil, oidRecord, true) + fn.newVarno = rec.dno + rec = c.buildRecord("old", 0, nil, oidRecord, true) + fn.oldVarno = rec.dno + } + + // Now parse the function's text. + fn.action = c.parseFunction() + + // Allow control to fall off the end without an explicit RETURN. + c.addDummyReturnDriver() + + c.finishDatums() + c.errFuncname = "" + return fn +} diff --git a/internal/plpgsql/gram.go b/internal/plpgsql/gram.go new file mode 100644 index 0000000..d286c85 --- /dev/null +++ b/internal/plpgsql/gram.go @@ -0,0 +1,1518 @@ +package plpgsql + +// The productions of pl_gram.y as recursive descent. Support functions live +// in gram_support.go; the scanner interface layer in scanner.go. Actions run +// where bison runs them (statement linenos are computed at the C action's +// point in the token stream, since plpgsql_latest_lineno is stateful and +// feeds the compile error context). + +// parseFunction is pl_function: comp_options pl_block opt_semi. +func (c *compiler) parseFunction() *stmtBlock { + tok := c.compOptions() + + // pl_block's opt_block_label. + var label string + if tok == LESS_LESS { + label = c.anyIdentifier(c.lex()) + c.expect(GREATER_GREATER) + tok = c.lex() + } + c.nsPush(label, labelBlock) + blk := c.plBlock(label, tok) + + // opt_semi, then end of input. + tok = c.lex() + if tok == plToken(';') { + tok = c.lex() + } + if tok != 0 { + c.scan.yyerror("syntax error") + } + return blk +} + +// compOptions is comp_options/comp_option: leading '#' directives. Returns +// the first token that is not part of an option. +func (c *compiler) compOptions() plToken { + for { + tok := c.lex() + if tok != plToken('#') { + return tok + } + tok = c.lex() + switch tok { + case K_OPTION: + c.expect(K_DUMP) + // plpgsql_DumpExecTree = true: no output effect here + case K_PRINT_STRICT_PARAMS: + val := c.optionValue() + switch val { + case "on": + c.fn.printStrictParams = true + case "off": + c.fn.printStrictParams = false + default: + c.ereportGram("unrecognized print_strict_params option %s", val) + } + case K_VARIABLE_CONFLICT: + tok = c.lex() + switch tok { + case K_ERROR: + c.fn.resolveOption = resolveError + case K_USE_VARIABLE: + c.fn.resolveOption = resolveVariable + case K_USE_COLUMN: + c.fn.resolveOption = resolveColumn + default: + c.scan.yyerror("syntax error") + } + default: + c.scan.yyerror("syntax error") + } + } +} + +// option_value: T_WORD | unreserved_keyword. +func (c *compiler) optionValue() string { + tok := c.lex() + if tok == T_WORD { + return c.cur().word.ident + } + if tokenIsUnreservedKeyword(tok) { + return c.cur().keyword + } + c.scan.yyerror("syntax error") + return "" +} + +// plBlock is pl_block minus opt_block_label (the caller parsed the label and +// pushed the namespace); firstTok is the already-consumed K_DECLARE or +// K_BEGIN (or anything else, which is a syntax error exactly as bison finds +// when it can't shift into decl_sect/K_BEGIN). +func (c *compiler) plBlock(label string, firstTok plToken) *stmtBlock { + var initVarnos []int + + tok := firstTok + if tok == K_DECLARE { + // decl_start action: forget variables created before the block and + // disable identifier lookup during declarations. + c.addInitdatums(false) + c.scan.identifierLookup = lookupDeclare + + declared := false + decls: + for { + tok = c.lex() + switch { + case tok == K_DECLARE: + // We allow useless extra DECLAREs + case tok == LESS_LESS: + c.ereportGram("block label must be placed before DECLARE, not after") + case tok == T_WORD || tokenIsUnreservedKeyword(tok): + c.declStatement(tok) + declared = true + default: + break decls + } + } + if declared { + initVarnos = c.addInitdatums(true) + } + } + + // decl_sect action: done with decls, so resume identifier lookup. + c.scan.identifierLookup = lookupNormal + + if tok != K_BEGIN { + c.scan.yyerror("syntax error") + } + beginLoc := c.loc() + + body := c.procSect() + exceptions := c.exceptionSect() + c.expect(K_END) + endLabel := c.optLabel() + + blk := &stmtBlock{ + label: label, + initVarnos: initVarnos, + body: body, + exceptions: exceptions, + } + blk.lineno = c.scan.locationToLineno(beginLoc) + + checkLabels(label, endLabel) + c.nsPop() + + return blk +} + +// declStatement is decl_statement; firstTok is the decl_varname's token. +func (c *compiler) declStatement(firstTok plToken) { + name, lineno := c.declVarname(firstTok) + + tok := c.lex() + switch tok { + case K_ALIAS: + // decl_varname K_ALIAS K_FOR decl_aliasitem ';' + c.expect(K_FOR) + nsi := c.declAliasitem() + c.expect(plToken(';')) + c.nsAdditem(nsi.itemtype, nsi.itemno, name) + return + + case K_NO: + c.expect(K_SCROLL) + c.expect(K_CURSOR) + c.declCursor(name, lineno, cursorOptNoScroll) + return + case K_SCROLL: + c.expect(K_CURSOR) + c.declCursor(name, lineno, cursorOptScroll) + return + case K_CURSOR: + c.declCursor(name, lineno, 0) + return + } + + // Ordinary variable declaration. + isConst := false + if tok == K_CONSTANT { + isConst = true + } else { + c.scan.pushBackToken(tok) + } + + dtype := c.readDatatype(0, false) + + // decl_collate (get_collation_oid is mocked to the default collation). + collation := uint32(0) + tok = c.lex() + if tok == K_COLLATE { + tok = c.lex() + if tok == T_WORD || tokenIsUnreservedKeyword(tok) || tok == T_CWORD { + collation = oidDefaultCollation + } else { + c.scan.yyerror("syntax error") + } + } else { + c.scan.pushBackToken(tok) + } + + // decl_notnull. + notnull := false + tok = c.lex() + if tok == K_NOT { + c.expect(K_NULL) + notnull = true + } else { + c.scan.pushBackToken(tok) + } + + // decl_defval. + var defval *plExpr + tok = c.lex() + switch tok { + case plToken(';'): + case plToken('='), tokCOLON_EQUALS, K_DEFAULT: + defval = c.readSQLExpression(plToken(';'), ";") + default: + c.scan.yyerror("syntax error") + } + + // decl_statement action. + if collation != 0 { + if dtype.collation == 0 { + // format_type_be is mocked to "-". + c.ereportGram("collations are not supported by type -") + } + dtype.collation = collation + } + + v := c.buildVariable(name, lineno, dtype, true) + if vr, ok := v.(*plVar); ok { + vr.isconst = isConst + vr.notnull = notnull + vr.defaultVal = defval + if vr.notnull && vr.defaultVal == nil { + c.ereportGram(`variable "%s" must have a default value, since it's declared NOT NULL`, vr.refname) + } + } else if rec, ok := v.(*plRec); ok { + // PLpgSQL_variable header fields: isconst/notnull/default_val live on + // the C supertype; only the NOT NULL check reads them afterwards. + _ = rec + if notnull && defval == nil { + c.ereportGram(`variable "%s" must have a default value, since it's declared NOT NULL`, rec.refname) + } + } +} + +// declVarname is decl_varname. +func (c *compiler) declVarname(tok plToken) (string, int) { + var name string + switch { + case tok == T_WORD: + name = c.cur().word.ident + case tokenIsUnreservedKeyword(tok): + name = c.cur().keyword + default: + c.scan.yyerror("syntax error") + } + lineno := c.scan.locationToLineno(c.loc()) + // Check to make sure name isn't already declared in the current block. + if ns, _ := c.nsLookup(c.nsTop, true, name, "", ""); ns != nil { + c.scan.yyerror("duplicate declaration") + } + // XCHECK_SHADOWVAR warnings are disabled (extra_warnings/errors are 0). + return name, lineno +} + +// declAliasitem is decl_aliasitem. +func (c *compiler) declAliasitem() *nsItem { + tok := c.lex() + switch { + case tok == T_WORD: + ident := c.cur().word.ident + nsi, _ := c.nsLookup(c.nsTop, false, ident, "", "") + if nsi == nil { + c.ereportGram(`variable "%s" does not exist`, ident) + } + return nsi + case tokenIsUnreservedKeyword(tok): + ident := c.cur().keyword + nsi, _ := c.nsLookup(c.nsTop, false, ident, "", "") + if nsi == nil { + c.ereportGram(`variable "%s" does not exist`, ident) + } + return nsi + case tok == T_CWORD: + idents := c.cur().cword + var nsi *nsItem + if len(idents) == 2 { + nsi, _ = c.nsLookup(c.nsTop, false, idents[0], idents[1], "") + } else if len(idents) == 3 { + nsi, _ = c.nsLookup(c.nsTop, false, idents[0], idents[1], idents[2]) + } + if nsi == nil { + c.ereportGram(`variable "%s" does not exist`, nameListToString(idents)) + } + return nsi + default: + c.scan.yyerror("syntax error") + return nil + } +} + +// declCursor is the cursor arm of decl_statement (after K_CURSOR). +func (c *compiler) declCursor(name string, lineno int, scrollOption int) { + // Mid-rule action: push a private namespace level for the cursor args. + c.nsPush(name, labelOther) + + // decl_cursor_args. + var argrow *plRow + tok := c.lex() + if tok == plToken('(') { + openLoc := c.loc() + var args []plVariable + for { + args = append(args, c.declCursorArg()) + tok = c.lex() + if tok != plToken(',') { + break + } + } + if tok != plToken(')') { + c.scan.yyerror("syntax error") + } + row := &plRow{ + refname: "(unnamed row)", + lineno: c.scan.locationToLineno(openLoc), + } + for _, arg := range args { + row.fieldnames = append(row.fieldnames, arg.varRefname()) + row.varnos = append(row.varnos, arg.datumNo()) + } + c.addDatum(row) + argrow = row + } else { + c.scan.pushBackToken(tok) + } + + // decl_is_for. + tok = c.lex() + if tok != K_IS && tok != K_FOR { + c.scan.yyerror("syntax error") + } + + // decl_cursor_query. + query := c.readSQLStmt() + + // decl_statement's cursor action: pop the arg namespace, then build. + c.nsPop() + + nv := c.buildVariable(name, lineno, + buildDatatype(oidRefcursor, -1, 0, nil), true).(*plVar) + nv.cursorExplicitExpr = query + if argrow == nil { + nv.cursorExplicitArgrow = -1 + } else { + nv.cursorExplicitArgrow = argrow.dno + } + nv.cursorOptions = cursorOptFastPlan | scrollOption +} + +// decl_cursor_arg: decl_varname decl_datatype. +func (c *compiler) declCursorArg() plVariable { + name, lineno := c.declVarname(c.lex()) + dtype := c.readDatatype(0, false) + return c.buildVariable(name, lineno, dtype, true) +} + +// optLabel is opt_label. +func (c *compiler) optLabel() string { + tok := c.lex() + if tok == T_WORD || tok == T_DATUM || tokenIsUnreservedKeyword(tok) { + return c.anyIdentifier(tok) + } + c.scan.pushBackToken(tok) + return "" +} + +// anyIdentifier is any_identifier; tok is the already-consumed token. +func (c *compiler) anyIdentifier(tok plToken) string { + switch { + case tok == T_WORD: + return c.cur().word.ident + case tokenIsUnreservedKeyword(tok): + return c.cur().keyword + case tok == T_DATUM: + if c.cur().wdatum.ident == "" { + c.scan.yyerror("syntax error") // composite name not OK + } + return c.cur().wdatum.ident + default: + c.scan.yyerror("syntax error") + return "" + } +} + +// procSect is proc_sect: statements until a token that cannot start one. +func (c *compiler) procSect() []plStmt { + var stmts []plStmt + for { + tok := c.lex() + if !isStmtStart(tok) { + c.scan.pushBackToken(tok) + return stmts + } + st := c.procStmt(tok) + if st != nil { + stmts = append(stmts, st) + } + } +} + +// isStmtStart is FIRST(proc_stmt). +func isStmtStart(tok plToken) bool { + switch tok { + case LESS_LESS, K_DECLARE, K_BEGIN, T_DATUM, K_IF, K_CASE, K_LOOP, + K_WHILE, K_FOR, K_FOREACH, K_EXIT, K_CONTINUE, K_RETURN, K_RAISE, + K_ASSERT, K_IMPORT, K_INSERT, K_MERGE, T_WORD, T_CWORD, K_EXECUTE, + K_PERFORM, K_CALL, K_DO, K_GET, K_OPEN, K_FETCH, K_MOVE, K_CLOSE, + K_NULL, K_COMMIT, K_ROLLBACK: + return true + } + return false +} + +// procStmt is proc_stmt; tok is the statement's first token, consumed. +func (c *compiler) procStmt(tok plToken) plStmt { + loc := c.loc() + switch tok { + case LESS_LESS: + label := c.anyIdentifier(c.lex()) + c.expect(GREATER_GREATER) + tok = c.lex() + switch tok { + case K_DECLARE, K_BEGIN: + c.nsPush(label, labelBlock) + blk := c.plBlock(label, tok) + c.expect(plToken(';')) + return blk + case K_LOOP: + c.nsPush(label, labelLoop) + return c.stmtLoop(label) + case K_WHILE: + c.nsPush(label, labelLoop) + return c.stmtWhile(label) + case K_FOR: + c.nsPush(label, labelLoop) + return c.stmtFor(label) + case K_FOREACH: + c.nsPush(label, labelLoop) + return c.stmtForeachA(label) + default: + c.scan.yyerror("syntax error") + return nil + } + + case K_DECLARE, K_BEGIN: + c.nsPush("", labelBlock) + blk := c.plBlock("", tok) + c.expect(plToken(';')) + return blk + + case K_LOOP: + c.nsPush("", labelLoop) + return c.stmtLoop("") + case K_WHILE: + c.nsPush("", labelLoop) + return c.stmtWhile("") + case K_FOR: + c.nsPush("", labelLoop) + return c.stmtFor("") + case K_FOREACH: + c.nsPush("", labelLoop) + return c.stmtForeachA("") + + case T_DATUM: + return c.stmtAssign() + + case K_IF: + return c.stmtIf(loc) + case K_CASE: + return c.stmtCase(loc) + case K_EXIT: + return c.stmtExit(true, loc) + case K_CONTINUE: + return c.stmtExit(false, loc) + case K_RETURN: + return c.stmtReturn(loc) + case K_RAISE: + return c.stmtRaise(loc) + case K_ASSERT: + return c.stmtAssert(loc) + + case K_IMPORT, K_INSERT, K_MERGE: + return c.makeExecsqlStmt(tok, loc, nil) + case T_WORD: + word := c.cur().word + next := c.lex() + c.scan.pushBackToken(next) + if next == plToken('=') || next == tokCOLON_EQUALS || + next == plToken('[') || next == plToken('.') { + wordIsNotVariable(&word) + } + return c.makeExecsqlStmt(T_WORD, loc, &word) + case T_CWORD: + cword := c.cur().cword + next := c.lex() + c.scan.pushBackToken(next) + if next == plToken('=') || next == tokCOLON_EQUALS || + next == plToken('[') || next == plToken('.') { + cwordIsNotVariable(cword) + } + return c.makeExecsqlStmt(T_CWORD, loc, nil) + + case K_EXECUTE: + return c.stmtDynexecute(loc) + case K_PERFORM: + return c.stmtPerform(loc) + case K_CALL: + return c.stmtCallOrDo(loc, true) + case K_DO: + return c.stmtCallOrDo(loc, false) + case K_GET: + return c.stmtGetdiag(loc) + case K_OPEN: + return c.stmtOpen(loc) + case K_FETCH: + return c.stmtFetchOrMove(loc, false) + case K_MOVE: + return c.stmtFetchOrMove(loc, true) + case K_CLOSE: + return c.stmtClose(loc) + case K_NULL: + // stmt_null: K_NULL ';' — we do not bother building a node for NULL. + c.expect(plToken(';')) + return nil + case K_COMMIT: + return c.stmtCommit(loc) + case K_ROLLBACK: + return c.stmtRollback(loc) + } + c.scan.yyerror("syntax error") + return nil +} + +// stmt_perform. +func (c *compiler) stmtPerform(loc int) plStmt { + st := &stmtPerform{} + st.lineno = c.scan.locationToLineno(loc) + c.scan.pushBackToken(K_PERFORM) + + // Substitute "SELECT" for "PERFORM" in the parsed text; syntax checking + // happens after the substitution. + var startloc int + expr, _ := c.readSQLConstruct(plToken(';'), 0, 0, ";", + rawParseDefault, false, false, &startloc) + // overwrite "perform" (and the space the C memmove drops) + expr.query = "SELECT" + expr.query[7:] + c.checkSQLExpr(expr.query, expr.parseMode, startloc+1) + st.expr = expr + return st +} + +// stmt_call: K_CALL / K_DO. +func (c *compiler) stmtCallOrDo(loc int, isCall bool) plStmt { + st := &stmtCall{isCall: isCall} + st.lineno = c.scan.locationToLineno(loc) + if isCall { + c.scan.pushBackToken(K_CALL) + } else { + c.scan.pushBackToken(K_DO) + } + st.expr = c.readSQLStmt() + return st +} + +// stmt_assign (current token is T_DATUM). +func (c *compiler) stmtAssign() plStmt { + loc := c.loc() + w := c.cur().wdatum + + // see how many names identify the datum + nnames := 1 + if w.ident == "" { + nnames = len(w.idents) + } + var pmode rawParseMode + switch nnames { + case 1: + pmode = rawParsePlpgsqlAssign1 + case 2: + pmode = rawParsePlpgsqlAssign2 + case 3: + pmode = rawParsePlpgsqlAssign3 + } + + c.checkAssignable(w.datum) + st := &stmtAssign{varno: w.datum.datumNo()} + st.lineno = c.scan.locationToLineno(loc) + // Push back the head name to include it in the stmt + c.scan.pushBackToken(T_DATUM) + st.expr, _ = c.readSQLConstruct(plToken(';'), 0, 0, ";", pmode, false, true, nil) + return st +} + +// stmt_getdiag. +func (c *compiler) stmtGetdiag(loc int) plStmt { + st := &stmtGetdiag{} + + // getdiag_area_opt. + tok := c.lex() + switch tok { + case K_CURRENT: + case K_STACKED: + st.isStacked = true + default: + c.scan.pushBackToken(tok) + } + c.expect(K_DIAGNOSTICS) + + // getdiag_list. + for { + item := &diagItem{} + item.target = c.getdiagTarget() + // assign_operator. + tok = c.lex() + if tok != plToken('=') && tok != tokCOLON_EQUALS { + c.scan.yyerror("syntax error") + } + item.kind = c.getdiagItem() + st.diagItems = append(st.diagItems, item) + tok = c.lex() + if tok != plToken(',') { + break + } + } + if tok != plToken(';') { + c.scan.yyerror("syntax error") + } + + st.lineno = c.scan.locationToLineno(loc) + + // Check information items are valid for area option. + for _, ditem := range st.diagItems { + switch ditem.kind { + case getdiagRowCount, getdiagRoutineOid: + if st.isStacked { + c.ereportGram("diagnostics item %s is not allowed in GET STACKED DIAGNOSTICS", + getdiagKindname(ditem.kind)) + } + case getdiagErrorContext, getdiagErrorDetail, getdiagErrorHint, + getdiagReturnedSqlstate, getdiagColumnName, getdiagConstraintName, + getdiagDatatypeName, getdiagMessageText, getdiagTableName, + getdiagSchemaName: + if !st.isStacked { + c.ereportGram("diagnostics item %s is not allowed in GET CURRENT DIAGNOSTICS", + getdiagKindname(ditem.kind)) + } + case getdiagContext: + } + } + + return st +} + +// getdiag_item. +func (c *compiler) getdiagItem() getdiagKind { + tok := c.lex() + switch { + case c.tokIsKeyword(tok, K_ROW_COUNT, "row_count"): + return getdiagRowCount + case c.tokIsKeyword(tok, K_PG_ROUTINE_OID, "pg_routine_oid"): + return getdiagRoutineOid + case c.tokIsKeyword(tok, K_PG_CONTEXT, "pg_context"): + return getdiagContext + case c.tokIsKeyword(tok, K_PG_EXCEPTION_DETAIL, "pg_exception_detail"): + return getdiagErrorDetail + case c.tokIsKeyword(tok, K_PG_EXCEPTION_HINT, "pg_exception_hint"): + return getdiagErrorHint + case c.tokIsKeyword(tok, K_PG_EXCEPTION_CONTEXT, "pg_exception_context"): + return getdiagErrorContext + case c.tokIsKeyword(tok, K_COLUMN_NAME, "column_name"): + return getdiagColumnName + case c.tokIsKeyword(tok, K_CONSTRAINT_NAME, "constraint_name"): + return getdiagConstraintName + case c.tokIsKeyword(tok, K_PG_DATATYPE_NAME, "pg_datatype_name"): + return getdiagDatatypeName + case c.tokIsKeyword(tok, K_MESSAGE_TEXT, "message_text"): + return getdiagMessageText + case c.tokIsKeyword(tok, K_TABLE_NAME, "table_name"): + return getdiagTableName + case c.tokIsKeyword(tok, K_SCHEMA_NAME, "schema_name"): + return getdiagSchemaName + case c.tokIsKeyword(tok, K_RETURNED_SQLSTATE, "returned_sqlstate"): + return getdiagReturnedSqlstate + default: + c.scan.yyerror("unrecognized GET DIAGNOSTICS item") + return 0 + } +} + +// getdiag_target. +func (c *compiler) getdiagTarget() int { + tok := c.lex() + switch tok { + case T_DATUM: + w := c.cur().wdatum + if w.datum.datumType() == dtypeRow || w.datum.datumType() == dtypeRec || + c.scan.peek() == plToken('[') { + c.ereportGram(`"%s" is not a scalar variable`, nameOfDatum(&w)) + } + c.checkAssignable(w.datum) + return w.datum.datumNo() + case T_WORD: + wordIsNotVariable(&c.cur().word) + case T_CWORD: + cwordIsNotVariable(c.cur().cword) + default: + c.scan.yyerror("syntax error") + } + return 0 +} + +// stmt_if. +func (c *compiler) stmtIf(loc int) plStmt { + st := &stmtIf{} + st.cond = c.readSQLExpression(K_THEN, "THEN") + st.thenBody = c.procSect() + + // stmt_elsifs (lineno computed at the C reduce point: after the body). + tok := c.lex() + for tok == K_ELSIF { + elsifLoc := c.loc() + e := &ifElsif{} + e.cond = c.readSQLExpression(K_THEN, "THEN") + e.stmts = c.procSect() + e.lineno = c.scan.locationToLineno(elsifLoc) + st.elsifList = append(st.elsifList, e) + tok = c.lex() + } + + // stmt_else. + if tok == K_ELSE { + st.elseBody = c.procSect() + tok = c.lex() + } + if tok != K_END { + c.scan.yyerror("syntax error") + } + c.expect(K_IF) + c.expect(plToken(';')) + + st.lineno = c.scan.locationToLineno(loc) + return st +} + +// stmt_case. +func (c *compiler) stmtCase(loc int) plStmt { + // opt_expr_until_when. + var tExpr *plExpr + tok := c.lex() + if tok != K_WHEN { + c.scan.pushBackToken(tok) + tExpr = c.readSQLExpression(K_WHEN, "WHEN") + } + + // case_when_list (lineno at the C reduce point: after the body). + var whens []*caseWhen + for { + whenLoc := c.loc() // location of K_WHEN + w := &caseWhen{} + w.expr = c.readSQLExpression(K_THEN, "THEN") + w.stmts = c.procSect() + w.lineno = c.scan.locationToLineno(whenLoc) + whens = append(whens, w) + tok = c.lex() + if tok != K_WHEN { + break + } + } + + // opt_case_else. + var elseStmts []plStmt + if tok == K_ELSE { + elseStmts = c.procSect() + if elseStmts == nil { + // distinguish empty ELSE from no ELSE: list with one NULL + elseStmts = []plStmt{nil} + } + tok = c.lex() + } + if tok != K_END { + c.scan.yyerror("syntax error") + } + c.expect(K_CASE) + c.expect(plToken(';')) + + return c.makeCase(loc, tExpr, whens, elseStmts) +} + +// loop_body: proc_sect K_END K_LOOP opt_label ';'. +func (c *compiler) loopBody() ([]plStmt, string) { + stmts := c.procSect() + c.expect(K_END) + c.expect(K_LOOP) + endLabel := c.optLabel() + c.expect(plToken(';')) + return stmts, endLabel +} + +// stmt_loop (K_LOOP consumed; its location is current). +func (c *compiler) stmtLoop(label string) plStmt { + loopLoc := c.loc() + body, endLabel := c.loopBody() + + st := &stmtLoop{label: label, body: body} + st.lineno = c.scan.locationToLineno(loopLoc) + checkLabels(label, endLabel) + c.nsPop() + return st +} + +// stmt_while. +func (c *compiler) stmtWhile(label string) plStmt { + whileLoc := c.loc() + cond := c.readSQLExpression(K_LOOP, "LOOP") + body, endLabel := c.loopBody() + + st := &stmtWhile{label: label, cond: cond, body: body} + st.lineno = c.scan.locationToLineno(whileLoc) + checkLabels(label, endLabel) + c.nsPop() + return st +} + +// stmt_for: opt_loop_label K_FOR for_control loop_body. +func (c *compiler) stmtFor(label string) plStmt { + forLoc := c.loc() + ctrl := c.forControl() + body, endLabel := c.loopBody() + + lineno := c.scan.locationToLineno(forLoc) + switch st := ctrl.(type) { + case *stmtFori: + st.lineno = lineno + st.label = label + st.body = body + case *stmtFors: + st.lineno = lineno + st.label = label + st.body = body + case *stmtForc: + st.lineno = lineno + st.label = label + st.body = body + case *stmtDynfors: + st.lineno = lineno + st.label = label + st.body = body + } + + checkLabels(label, endLabel) + c.nsPop() + return ctrl +} + +// forVariable is for_variable. +type forVariableResult struct { + name string + lineno int + scalar datum + row datum +} + +func (c *compiler) forVariable() forVariableResult { + var fv forVariableResult + tok := c.lex() + switch tok { + case T_DATUM: + w := c.cur().wdatum + loc := c.loc() + fv.name = nameOfDatum(&w) + fv.lineno = c.scan.locationToLineno(loc) + if w.datum.datumType() == dtypeRow || w.datum.datumType() == dtypeRec { + fv.row = w.datum + } else { + fv.scalar = w.datum + // check for comma-separated list + tok = c.lex() + c.scan.pushBackToken(tok) + if tok == plToken(',') { + fv.row = c.readIntoScalarList(fv.name, fv.scalar, loc) + } + } + case T_WORD: + word := c.cur().word + fv.name = word.ident + fv.lineno = c.scan.locationToLineno(c.loc()) + // check for comma-separated list + tok = c.lex() + c.scan.pushBackToken(tok) + if tok == plToken(',') { + wordIsNotVariable(&word) + } + case T_CWORD: + cwordIsNotVariable(c.cur().cword) + default: + c.scan.yyerror("syntax error") + } + return fv +} + +// forControl is for_control. +func (c *compiler) forControl() plStmt { + fv := c.forVariable() + c.expect(K_IN) + + tok := c.lex() + if tok == K_EXECUTE { + // EXECUTE means it's a dynamic FOR loop. + expr, term := c.readSQLExpression2(K_LOOP, K_USING, "LOOP or USING") + + st := &stmtDynfors{} + if fv.row != nil { + st.varDat = fv.row.(plVariable) + c.checkAssignable(fv.row) + } else if fv.scalar != nil { + st.varDat = c.makeScalarList1(fv.name, fv.scalar, fv.lineno) + } else { + c.ereportGram("loop variable of loop over rows must be a record variable or list of scalar variables") + } + st.query = expr + + if term == K_USING { + for { + expr, term = c.readSQLExpression2(plToken(','), K_LOOP, ", or LOOP") + st.params = append(st.params, expr) + if term != plToken(',') { + break + } + } + } + return st + } + + if tok == T_DATUM && c.cur().wdatum.datum.datumType() == dtypeVar && + c.cur().wdatum.datum.(*plVar).datatype.typoid == oidRefcursor { + // It's FOR var IN cursor. + cursor := c.cur().wdatum.datum.(*plVar) + st := &stmtForc{curvar: cursor.dno} + + // Should have had a single variable name. + if fv.scalar != nil && fv.row != nil { + c.ereportGram("cursor FOR loop must have only one target variable") + } + + // can't use an unbound cursor this way + if cursor.cursorExplicitExpr == nil { + c.ereportGram("cursor FOR loop must use a bound cursor variable") + } + + // collect cursor's parameters if any + st.argquery = c.readCursorArgs(cursor, K_LOOP) + + // create loop's private RECORD variable + st.varDat = c.buildRecord(fv.name, fv.lineno, nil, oidRecord, true) + return st + } + + // FOR var IN a..b or FOR var IN query. + reverse := false + if c.tokIsKeyword(tok, K_REVERSE, "reverse") { + reverse = true + } else { + c.scan.pushBackToken(tok) + } + + var expr1loc int + expr1, term := c.readSQLConstruct(tokDOT_DOT, K_LOOP, 0, "LOOP", + rawParseDefault, true, false, &expr1loc) + + if term == tokDOT_DOT { + // Saw "..", so it must be an integer loop. + + // Relabel first expression as an expression; then check its syntax. + expr1.parseMode = rawParsePlpgsqlExpr + c.checkSQLExpr(expr1.query, expr1.parseMode, expr1loc) + + // Read and check the second one + expr2, term2 := c.readSQLExpression2(K_LOOP, K_BY, "LOOP") + + // Get the BY clause if any + var exprBy *plExpr + if term2 == K_BY { + exprBy = c.readSQLExpression(K_LOOP, "LOOP") + } + + // Should have had a single variable name + if fv.scalar != nil && fv.row != nil { + c.ereportGram("integer FOR loop must have only one target variable") + } + + // create loop's private variable + fvar := c.buildVariable(fv.name, fv.lineno, + buildDatatype(oidInt4, -1, 0, nil), true).(*plVar) + + st := &stmtFori{ + varDat: fvar, + reverse: reverse, + lower: expr1, + upper: expr2, + step: exprBy, + } + return st + } + + // No "..", so it must be a query loop. + if reverse { + c.ereportGram("cannot specify REVERSE in query FOR loop") + } + + // Check syntax as a regular query + c.checkSQLExpr(expr1.query, expr1.parseMode, expr1loc) + + st := &stmtFors{} + if fv.row != nil { + st.varDat = fv.row.(plVariable) + c.checkAssignable(fv.row) + } else if fv.scalar != nil { + st.varDat = c.makeScalarList1(fv.name, fv.scalar, fv.lineno) + } else { + c.ereportGram("loop variable of loop over rows must be a record variable or list of scalar variables") + } + st.query = expr1 + return st +} + +// stmt_foreach_a. +func (c *compiler) stmtForeachA(label string) plStmt { + foreachLoc := c.loc() + fv := c.forVariable() + + // foreach_slice. + slice := 0 + tok := c.lex() + if tok == K_SLICE { + c.expect(tokICONST) + slice = int(c.cur().ival) + } else { + c.scan.pushBackToken(tok) + } + + c.expect(K_IN) + c.expect(K_ARRAY) + expr := c.readSQLExpression(K_LOOP, "LOOP") + body, endLabel := c.loopBody() + + st := &stmtForeachA{ + label: label, + slice: slice, + expr: expr, + body: body, + } + st.lineno = c.scan.locationToLineno(foreachLoc) + + if fv.row != nil { + st.varno = fv.row.datumNo() + c.checkAssignable(fv.row) + } else if fv.scalar != nil { + st.varno = fv.scalar.datumNo() + c.checkAssignable(fv.scalar) + } else { + c.ereportGram("loop variable of FOREACH must be a known variable or list of variables") + } + + checkLabels(label, endLabel) + c.nsPop() + return st +} + +// stmt_exit (exit_type consumed; loc is its location). +func (c *compiler) stmtExit(isExit bool, loc int) plStmt { + st := &stmtExit{isExit: isExit} + st.label = c.optLabel() + + // opt_exitcond. + tok := c.lex() + switch tok { + case plToken(';'): + case K_WHEN: + st.cond = c.readSQLExpression(plToken(';'), ";") + default: + c.scan.yyerror("syntax error") + } + + st.lineno = c.scan.locationToLineno(loc) + + if st.label != "" { + // We have a label, so verify it exists + labelItem := c.nsLookupLabel(c.nsTop, st.label) + if labelItem == nil { + c.ereportGram(`there is no label "%s" attached to any block or loop enclosing this statement`, st.label) + } + // CONTINUE only allows loop labels + if labelItem.itemno != int(labelLoop) && !st.isExit { + c.ereportGram(`block label "%s" cannot be used in CONTINUE`, st.label) + } + } else { + // No label, so make sure there is some loop + if c.nsFindNearestLoop(c.nsTop) == nil { + if st.isExit { + c.ereportGram("EXIT cannot be used outside a loop, unless it has a label") + } else { + c.ereportGram("CONTINUE cannot be used outside a loop") + } + } + } + + return st +} + +// stmt_return. +func (c *compiler) stmtReturn(loc int) plStmt { + tok := c.lex() + if tok == 0 { + c.scan.yyerror("unexpected end of function definition") + } + if c.tokIsKeyword(tok, K_NEXT, "next") { + return c.makeReturnNextStmt(loc) + } + if c.tokIsKeyword(tok, K_QUERY, "query") { + return c.makeReturnQueryStmt(loc) + } + c.scan.pushBackToken(tok) + return c.makeReturnStmt(loc) +} + +// stmt_raise. +func (c *compiler) stmtRaise(loc int) plStmt { + st := &stmtRaise{elogLevel: elogError} + st.lineno = c.scan.locationToLineno(loc) + + tok := c.lex() + if tok == 0 { + c.scan.yyerror("unexpected end of function definition") + } + + // We could have just RAISE, meaning to re-throw the current error. + if tok != plToken(';') { + // First is an optional elog severity level. + levelSet := true + switch { + case c.tokIsKeyword(tok, K_EXCEPTION, "exception"): + st.elogLevel = elogError + case c.tokIsKeyword(tok, K_WARNING, "warning"): + st.elogLevel = elogWarning + case c.tokIsKeyword(tok, K_NOTICE, "notice"): + st.elogLevel = elogNotice + case c.tokIsKeyword(tok, K_INFO, "info"): + st.elogLevel = elogInfo + case c.tokIsKeyword(tok, K_LOG, "log"): + st.elogLevel = elogLog + case c.tokIsKeyword(tok, K_DEBUG, "debug"): + st.elogLevel = elogDebug1 + default: + levelSet = false + } + if levelSet { + tok = c.lex() + } + if tok == 0 { + c.scan.yyerror("unexpected end of function definition") + } + + // Next: condition name, SQLSTATE 'xxxxx', old-style message string, + // or USING. + if tok == tokSCONST { + // old style message and parameters + st.message = c.cur().str + st.hasMessage = true + tok = c.lex() + if tok != plToken(',') && tok != plToken(';') && tok != K_USING { + c.scan.yyerror("syntax error") + } + for tok == plToken(',') { + var expr *plExpr + expr, tok = c.readSQLConstruct2(plToken(','), plToken(';'), K_USING, + ", or ; or USING") + st.params = append(st.params, expr) + } + } else if tok != K_USING { + // must be condition name or SQLSTATE + if c.tokIsKeyword(tok, K_SQLSTATE, "sqlstate") { + // next token should be a string literal + if c.lex() != tokSCONST { + c.scan.yyerror("syntax error") + } + sqlstatestr := c.cur().str + if len(sqlstatestr) != 5 { + c.scan.yyerror("invalid SQLSTATE code") + } + if !isSqlstate(sqlstatestr) { + c.scan.yyerror("invalid SQLSTATE code") + } + st.condname = sqlstatestr + } else { + if tok == T_WORD { + st.condname = c.cur().word.ident + } else if tokenIsUnreservedKeyword(tok) { + st.condname = c.cur().keyword + } else { + c.scan.yyerror("syntax error") + } + recognizeErrCondition(st.condname, false) + } + tok = c.lex() + if tok != plToken(';') && tok != K_USING { + c.scan.yyerror("syntax error") + } + } + + if tok == K_USING { + st.options = c.readRaiseOptions() + } + } + + checkRaiseParameters(st) + return st +} + +// readSQLConstruct2 is read_sql_construct with three terminators and the +// PLPGSQL_EXPR parse mode (the RAISE parameter shape). +func (c *compiler) readSQLConstruct2(until, until2, until3 plToken, expected string) (*plExpr, plToken) { + return c.readSQLConstruct(until, until2, until3, expected, + rawParsePlpgsqlExpr, true, true, nil) +} + +// stmt_assert. +func (c *compiler) stmtAssert(loc int) plStmt { + st := &stmtAssert{} + st.lineno = c.scan.locationToLineno(loc) + + var tok plToken + st.cond, tok = c.readSQLExpression2(plToken(','), plToken(';'), ", or ;") + if tok == plToken(',') { + st.message = c.readSQLExpression(plToken(';'), ";") + } + return st +} + +// stmt_dynexecute. +func (c *compiler) stmtDynexecute(loc int) plStmt { + expr, endtoken := c.readSQLConstruct(K_INTO, K_USING, plToken(';'), + "INTO or USING or ;", rawParsePlpgsqlExpr, true, true, nil) + + st := &stmtDynexecute{query: expr} + st.lineno = c.scan.locationToLineno(loc) + + for { + if endtoken == K_INTO { + if st.into { // multiple INTO + c.scan.yyerror("syntax error") + } + st.into = true + st.target, st.strict = c.readIntoTarget(true) + endtoken = c.lex() + } else if endtoken == K_USING { + if len(st.params) > 0 { // multiple USING + c.scan.yyerror("syntax error") + } + for { + expr, endtoken = c.readSQLConstruct(plToken(','), plToken(';'), K_INTO, + ", or ; or INTO", rawParsePlpgsqlExpr, true, true, nil) + st.params = append(st.params, expr) + if endtoken != plToken(',') { + break + } + } + } else if endtoken == plToken(';') { + break + } else { + c.scan.yyerror("syntax error") + } + } + + return st +} + +// cursor_variable. +func (c *compiler) cursorVariable() *plVar { + tok := c.lex() + switch tok { + case T_DATUM: + w := c.cur().wdatum + if w.datum.datumType() != dtypeVar || c.scan.peek() == plToken('[') { + c.ereportGram("cursor variable must be a simple variable") + } + v := w.datum.(*plVar) + if v.datatype.typoid != oidRefcursor { + c.ereportGram(`variable "%s" must be of type cursor or refcursor`, v.refname) + } + return v + case T_WORD: + wordIsNotVariable(&c.cur().word) + case T_CWORD: + cwordIsNotVariable(c.cur().cword) + default: + c.scan.yyerror("syntax error") + } + return nil +} + +// stmt_open. +func (c *compiler) stmtOpen(loc int) plStmt { + cursor := c.cursorVariable() + st := &stmtOpen{cursorOptions: cursorOptFastPlan} + st.lineno = c.scan.locationToLineno(loc) + st.curvar = cursor.dno + + if cursor.cursorExplicitExpr == nil { + // be nice if we could use opt_scrollable here + tok := c.lex() + if c.tokIsKeyword(tok, K_NO, "no") { + tok = c.lex() + if c.tokIsKeyword(tok, K_SCROLL, "scroll") { + st.cursorOptions |= cursorOptNoScroll + tok = c.lex() + } + } else if c.tokIsKeyword(tok, K_SCROLL, "scroll") { + st.cursorOptions |= cursorOptScroll + tok = c.lex() + } + + if tok != K_FOR { + c.scan.yyerror(`syntax error, expected "FOR"`) + } + + tok = c.lex() + if tok == K_EXECUTE { + var endtoken plToken + st.dynquery, endtoken = c.readSQLExpression2(K_USING, plToken(';'), "USING or ;") + + // If we found "USING", collect argument(s) + if endtoken == K_USING { + for { + var expr *plExpr + expr, endtoken = c.readSQLExpression2(plToken(','), plToken(';'), ", or ;") + st.params = append(st.params, expr) + if endtoken != plToken(',') { + break + } + } + } + } else { + c.scan.pushBackToken(tok) + st.query = c.readSQLStmt() + } + } else { + // predefined cursor query, so read args + st.argquery = c.readCursorArgs(cursor, plToken(';')) + } + + return st +} + +// stmt_fetch / stmt_move. +func (c *compiler) stmtFetchOrMove(loc int, isMove bool) plStmt { + fetch := c.readFetchDirection() + cursor := c.cursorVariable() + + if !isMove { + c.expect(K_INTO) + target, _ := c.readIntoTarget(false) + if c.lex() != plToken(';') { + c.scan.yyerror("syntax error") + } + // We don't allow multiple rows in PL/pgSQL's FETCH statement. + if fetch.returnsMultipleRows { + c.ereportGram("FETCH statement cannot return multiple rows") + } + fetch.target = target + } else { + c.expect(plToken(';')) + } + + fetch.lineno = c.scan.locationToLineno(loc) + fetch.curvar = cursor.dno + fetch.isMove = isMove + return fetch +} + +// stmt_close. +func (c *compiler) stmtClose(loc int) plStmt { + curvar := c.cursorVariable().dno + c.expect(plToken(';')) + st := &stmtClose{curvar: curvar} + st.lineno = c.scan.locationToLineno(loc) + return st +} + +// stmt_commit / stmt_rollback with opt_transaction_chain. +func (c *compiler) stmtCommit(loc int) plStmt { + chain := c.optTransactionChain() + c.expect(plToken(';')) + st := &stmtCommit{chain: chain} + st.lineno = c.scan.locationToLineno(loc) + return st +} + +func (c *compiler) stmtRollback(loc int) plStmt { + chain := c.optTransactionChain() + c.expect(plToken(';')) + st := &stmtRollback{chain: chain} + st.lineno = c.scan.locationToLineno(loc) + return st +} + +func (c *compiler) optTransactionChain() bool { + tok := c.lex() + if tok != K_AND { + c.scan.pushBackToken(tok) + return false + } + tok = c.lex() + if tok == K_CHAIN { + return true + } + if tok == K_NO { + c.expect(K_CHAIN) + return false + } + c.scan.yyerror("syntax error") + return false +} + +// exceptionSect is exception_sect. +func (c *compiler) exceptionSect() *exceptionBlock { + tok := c.lex() + if tok != K_EXCEPTION { + c.scan.pushBackToken(tok) + return nil + } + + // Mid-rule action: create the sqlstate/sqlerrm variables before parsing + // the WHEN clauses; their scope extends to the end of the current block. + lineno := c.scan.locationToLineno(c.loc()) + blk := &exceptionBlock{} + + v := c.buildVariable("sqlstate", lineno, + buildDatatype(oidText, -1, 0, nil), true).(*plVar) + v.isconst = true + blk.sqlstateVarno = v.dno + + v = c.buildVariable("sqlerrm", lineno, + buildDatatype(oidText, -1, 0, nil), true).(*plVar) + v.isconst = true + blk.sqlerrmVarno = v.dno + + // proc_exceptions (lineno at the C reduce point: after the action body). + for { + c.expect(K_WHEN) + whenLoc := c.loc() + exc := &plException{} + exc.conditions = c.procConditions() + c.expect(K_THEN) + exc.action = c.procSect() + exc.lineno = c.scan.locationToLineno(whenLoc) + blk.excList = append(blk.excList, exc) + + tok = c.lex() + c.scan.pushBackToken(tok) + if tok != K_WHEN { + break + } + } + + return blk +} + +// procConditions is proc_conditions: OR-joined condition chains. +func (c *compiler) procConditions() *plCondition { + head := c.procCondition() + for { + tok := c.lex() + if tok != K_OR { + c.scan.pushBackToken(tok) + return head + } + next := c.procCondition() + old := head + for old.next != nil { + old = old.next + } + old.next = next + } +} + +// procCondition is proc_condition. +func (c *compiler) procCondition() *plCondition { + name := c.anyIdentifier(c.lex()) + if name != "sqlstate" { + return parseErrCondition(name) + } + // next token should be a string literal + if c.lex() != tokSCONST { + c.scan.yyerror("syntax error") + } + sqlstatestr := c.cur().str + if len(sqlstatestr) != 5 { + c.scan.yyerror("invalid SQLSTATE code") + } + if !isSqlstate(sqlstatestr) { + c.scan.yyerror("invalid SQLSTATE code") + } + return &plCondition{condname: sqlstatestr} +} diff --git a/internal/plpgsql/gram_support.go b/internal/plpgsql/gram_support.go new file mode 100644 index 0000000..585d501 --- /dev/null +++ b/internal/plpgsql/gram_support.go @@ -0,0 +1,960 @@ +package plpgsql + +import ( + "fmt" + "strings" + + "github.com/sqlc-dev/oliphant/internal/deparse" + "github.com/sqlc-dev/oliphant/internal/parse" +) + +// The support functions from the bottom half of pl_gram.y, as built by +// libpg_query (parse_datatype and make_return_stmt are the mocked versions; +// %TYPE/%ROWTYPE lookups return NULL). + +// lex/expect/ereport plumbing ------------------------------------------------ + +func (c *compiler) lex() plToken { return c.scan.yylex() } +func (c *compiler) cur() *tokenAux { return &c.scan.cur } +func (c *compiler) loc() int { return c.scan.cur.lloc } + +// expect consumes one token and reports bison's plain "syntax error" at it +// when it is not the wanted one. +func (c *compiler) expect(tok plToken) { + if c.lex() != tok { + c.scan.yyerror("syntax error") + } +} + +// ereportGram is an ereport from a grammar action (funcname plpgsql_yyparse). +func (c *compiler) ereportGram(format string, args ...any) { + panic(&compileError{ + Message: fmt.Sprintf(format, args...), + Filename: plGramFilename, + Funcname: "plpgsql_yyparse", + }) +} + +// ereportFn is an ereport from a named pl_gram.y support function. +func ereportFn(funcname, format string, args ...any) { + panic(&compileError{ + Message: fmt.Sprintf(format, args...), + Filename: plGramFilename, + Funcname: funcname, + }) +} + +// tok_is_keyword (pl_gram.y). +func (c *compiler) tokIsKeyword(token plToken, kwToken plToken, kwStr string) bool { + if token == kwToken { + return true + } + if token == T_DATUM { + w := &c.cur().wdatum + if !w.quoted && w.ident != "" && w.ident == kwStr { + return true + } + } + return false +} + +// word_is_not_variable / cword_is_not_variable / current_token_is_not_variable. +func wordIsNotVariable(word *plWord) { + ereportFn("word_is_not_variable", `"%s" is not a known variable`, word.ident) +} + +func cwordIsNotVariable(idents []string) { + ereportFn("cword_is_not_variable", `"%s" is not a known variable`, nameListToString(idents)) +} + +func (c *compiler) currentTokenIsNotVariable(tok plToken) { + switch tok { + case T_WORD: + wordIsNotVariable(&c.cur().word) + case T_CWORD: + cwordIsNotVariable(c.cur().cword) + default: + c.scan.yyerror("syntax error") + } +} + +// read_sql_expression / read_sql_expression2 / read_sql_stmt ------------------ + +func (c *compiler) readSQLExpression(until plToken, expected string) *plExpr { + expr, _ := c.readSQLConstruct(until, 0, 0, expected, rawParsePlpgsqlExpr, true, true, nil) + return expr +} + +func (c *compiler) readSQLExpression2(until, until2 plToken, expected string) (*plExpr, plToken) { + return c.readSQLConstruct(until, until2, 0, expected, rawParsePlpgsqlExpr, true, true, nil) +} + +func (c *compiler) readSQLStmt() *plExpr { + expr, _ := c.readSQLConstruct(plToken(';'), 0, 0, ";", rawParseDefault, false, true, nil) + return expr +} + +// read_sql_construct (pl_gram.y). +func (c *compiler) readSQLConstruct(until, until2, until3 plToken, expected string, + parsemode rawParseMode, isexpression, validSQL bool, startloc *int) (*plExpr, plToken) { + + saveLookup := c.scan.identifierLookup + c.scan.identifierLookup = lookupExpr + + startlocation := -1 + endlocation := -1 + parenlevel := 0 + var tok plToken + + for { + tok = c.lex() + if startlocation < 0 { + startlocation = c.loc() + } + if tok == until && parenlevel == 0 { + break + } + if tok == until2 && parenlevel == 0 { + break + } + if until3 != 0 && tok == until3 && parenlevel == 0 { + break + } + if tok == plToken('(') || tok == plToken('[') { + parenlevel++ + } else if tok == plToken(')') || tok == plToken(']') { + parenlevel-- + if parenlevel < 0 { + c.scan.yyerror("mismatched parentheses") + } + } + if tok == 0 || tok == plToken(';') { + if parenlevel != 0 { + c.scan.yyerror("mismatched parentheses") + } + if isexpression { + c.ereportGram(`missing "%s" at end of SQL expression`, expected) + } + c.ereportGram(`missing "%s" at end of SQL statement`, expected) + } + endlocation = c.loc() + c.scan.tokenLength() + } + + c.scan.identifierLookup = saveLookup + + if startloc != nil { + *startloc = startlocation + } + + if startlocation >= endlocation { + if isexpression { + c.scan.yyerror("missing expression") + } + c.scan.yyerror("missing SQL statement") + } + + expr := &plExpr{ + query: c.scan.sourceText(startlocation, endlocation), + parseMode: parsemode, + } + + if validSQL { + c.checkSQLExpr(expr.query, expr.parseMode, startlocation) + } + + return expr, tok +} + +// read_datatype (pl_gram.y). tok < 0 means no lookahead (YYEMPTY). +func (c *compiler) readDatatype(tok plToken, haveTok bool) *plType { + var result *plType + + if !haveTok { + tok = c.lex() + } + + startlocation := c.loc() + parenlevel := 0 + + // If we have a simple or composite identifier, check for %TYPE and + // %ROWTYPE constructs (mocked to NULL lookups in this build). + if tok == T_WORD { + tok = c.lex() + if tok == plToken('%') { + tok = c.lex() + if c.tokIsKeyword(tok, K_TYPE, "type") { + result = c.parseWordType("") + } else if c.tokIsKeyword(tok, K_ROWTYPE, "rowtype") { + result = c.parseWordRowType("") + } + } + } else if tokenIsUnreservedKeyword(tok) { + tok = c.lex() + if tok == plToken('%') { + tok = c.lex() + if c.tokIsKeyword(tok, K_TYPE, "type") { + result = c.parseWordType("") + } else if c.tokIsKeyword(tok, K_ROWTYPE, "rowtype") { + result = c.parseWordRowType("") + } + } + } else if tok == T_CWORD { + tok = c.lex() + if tok == plToken('%') { + tok = c.lex() + if c.tokIsKeyword(tok, K_TYPE, "type") { + result = c.parseCwordType(nil) + } else if c.tokIsKeyword(tok, K_ROWTYPE, "rowtype") { + result = c.parseCwordRowType(nil) + } + } + } + + if result != nil { + // %TYPE/%ROWTYPE recognized: check for array decoration. (Unreachable + // in this build — the lookups above always return NULL — but kept for + // shape parity.) + isArray := false + tok = c.lex() + if c.tokIsKeyword(tok, K_ARRAY, "array") { + isArray = true + tok = c.lex() + } + for tok == plToken('[') { + isArray = true + tok = c.lex() + if tok == tokICONST { + tok = c.lex() + } + if tok != plToken(']') { + c.scan.yyerror(`syntax error, expected "]"`) + } + tok = c.lex() + } + c.scan.pushBackToken(tok) + if isArray { + result = buildDatatypeArrayof(result) + } + return result + } + + // Not %TYPE or %ROWTYPE: scan to the end of the datatype declaration. + for tok != plToken(';') { + if tok == 0 { + if parenlevel != 0 { + c.scan.yyerror("mismatched parentheses") + } + c.scan.yyerror("incomplete data type declaration") + } + // Possible followers for datatype in a declaration + if tok == K_COLLATE || tok == K_NOT || + tok == plToken('=') || tok == tokCOLON_EQUALS || tok == K_DEFAULT { + break + } + // Possible followers for datatype in a cursor_arg list + if (tok == plToken(',') || tok == plToken(')')) && parenlevel == 0 { + break + } + if tok == plToken('(') { + parenlevel++ + } else if tok == plToken(')') { + parenlevel-- + } + tok = c.lex() + } + + typeName := c.scan.sourceText(startlocation, c.loc()) + if typeName == "" { + c.scan.yyerror("missing data type declaration") + } + + result = parseDatatype(typeName) + + c.scan.pushBackToken(tok) + return result +} + +// parse_datatype — the vendored mock: no core-parser round trip; the type +// name is kept verbatim, with only RECORD/REFCURSOR/CURSOR/TEXT recognized +// by (length-limited, case-insensitive) prefix comparison. +func parseDatatype(s string) *plType { + n := len(s) + for n > 0 && isSpaceByte(s[n-1]) { + n-- + } + typ := &plType{typname: s, ttype: ttypeScalar} + if pgStrncasecmpEqual(s, "RECORD", n) { + typ.ttype = ttypeRec + } + if pgStrncasecmpEqual(s, "REFCURSOR", n) || pgStrncasecmpEqual(s, "CURSOR", n) { + typ.typoid = oidRefcursor + } else if pgStrncasecmpEqual(s, "TEXT", n) { + typ.typoid = oidText + typ.collation = oidDefaultCollation + } + return typ +} + +// pgStrncasecmpEqual is pg_strncasecmp(s, target, n) == 0, with C string +// semantics (target's NUL participates in the comparison). +func pgStrncasecmpEqual(s, target string, n int) bool { + for i := 0; i < n; i++ { + var a, b byte + if i < len(s) { + a = asciiLower(s[i]) + } + if i < len(target) { + b = asciiLower(target[i]) + } + if a != b { + return false + } + if a == 0 { + return true + } + } + return true +} + +func asciiLower(c byte) byte { + if c >= 'A' && c <= 'Z' { + return c + ('a' - 'A') + } + return c +} + +// scanner_isspace (scansup.c). +func isSpaceByte(c byte) bool { + return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v' +} + +// make_execsql_stmt (pl_gram.y): read a generic SQL statement, spotting a +// PL/pgSQL INTO clause. +func (c *compiler) makeExecsqlStmt(firsttoken plToken, location int, word *plWord) plStmt { + saveLookup := c.scan.identifierLookup + c.scan.identifierLookup = lookupExpr + + var target plVariable + haveInto := false + haveStrict := false + intoStartLoc := -1 + intoEndLoc := -1 + parenDepth := 0 + beginDepth := 0 + inRoutineDefinition := false + tokenCount := 0 + var tokens [4]byte + + tok := firsttoken + if tok == T_WORD && word != nil && word.ident == "create" { + tokens[tokenCount] = 'c' + } + tokenCount++ + + for { + prevTok := tok + tok = c.lex() + if haveInto && intoEndLoc < 0 { + intoEndLoc = c.loc() // token after the INTO part + } + // Detect CREATE [OR REPLACE] {FUNCTION|PROCEDURE} + if tokens[0] == 'c' && tokenCount < len(tokens) { + if tok == K_OR { + tokens[tokenCount] = 'o' + } else if tok == T_WORD && c.cur().word.ident == "replace" { + tokens[tokenCount] = 'r' + } else if tok == T_WORD && c.cur().word.ident == "function" { + tokens[tokenCount] = 'f' + } else if tok == T_WORD && c.cur().word.ident == "procedure" { + tokens[tokenCount] = 'f' // treat same as "function" + } + if tokens[1] == 'f' || + (tokens[1] == 'o' && tokens[2] == 'r' && tokens[3] == 'f') { + inRoutineDefinition = true + } + tokenCount++ + } + // Track paren nesting (needed for CREATE RULE syntax) + if tok == plToken('(') { + parenDepth++ + } else if tok == plToken(')') && parenDepth > 0 { + parenDepth-- + } + // We need track BEGIN/END nesting only in a routine definition + if inRoutineDefinition && parenDepth == 0 { + if tok == K_BEGIN || tok == K_CASE { + beginDepth++ + } else if tok == K_END && beginDepth > 0 { + beginDepth-- + } + } + // Command-ending semicolon? + if tok == plToken(';') && parenDepth == 0 && beginDepth == 0 { + break + } + if tok == 0 { + c.scan.yyerror("unexpected end of function definition") + } + if tok == K_INTO { + if prevTok == K_INSERT { + continue // INSERT INTO is not an INTO-target + } + if prevTok == K_MERGE { + continue // MERGE INTO is not an INTO-target + } + if firsttoken == K_IMPORT { + continue // IMPORT ... INTO is not an INTO-target + } + if haveInto { + c.scan.yyerror("INTO specified more than once") + } + haveInto = true + intoStartLoc = c.loc() + c.scan.identifierLookup = lookupNormal + target, haveStrict = c.readIntoTarget(true) + c.scan.identifierLookup = lookupExpr + } + } + + c.scan.identifierLookup = saveLookup + + var ds string + if haveInto { + // Insert spaces for the INTO text so locations still line up. + ds = c.scan.sourceText(location, intoStartLoc) + + strings.Repeat(" ", intoEndLoc-intoStartLoc) + + c.scan.sourceText(intoEndLoc, c.loc()) + } else { + ds = c.scan.sourceText(location, c.loc()) + } + + // trim any trailing whitespace, for neatness + for len(ds) > 0 && isSpaceByte(ds[len(ds)-1]) { + ds = ds[:len(ds)-1] + } + + expr := &plExpr{query: ds, parseMode: rawParseDefault} + c.checkSQLExpr(expr.query, expr.parseMode, location) + + execsql := &stmtExecsql{ + sqlstmt: expr, + into: haveInto, + strict: haveStrict, + target: target, + } + execsql.lineno = c.scan.locationToLineno(location) + return execsql +} + +// read_fetch_direction (pl_gram.y). +func (c *compiler) readFetchDirection() *stmtFetch { + fetch := &stmtFetch{ + direction: fetchForward, + howMany: 1, + } + checkFROM := true + + tok := c.lex() + if tok == 0 { + c.scan.yyerror("unexpected end of function definition") + } + + switch { + case c.tokIsKeyword(tok, K_NEXT, "next"): + // use defaults + case c.tokIsKeyword(tok, K_PRIOR, "prior"): + fetch.direction = fetchBackward + case c.tokIsKeyword(tok, K_FIRST, "first"): + fetch.direction = fetchAbsolute + case c.tokIsKeyword(tok, K_LAST, "last"): + fetch.direction = fetchAbsolute + fetch.howMany = -1 + case c.tokIsKeyword(tok, K_ABSOLUTE, "absolute"): + fetch.direction = fetchAbsolute + fetch.expr, _ = c.readSQLExpression2(K_FROM, K_IN, "FROM or IN") + checkFROM = false + case c.tokIsKeyword(tok, K_RELATIVE, "relative"): + fetch.direction = fetchRelative + fetch.expr, _ = c.readSQLExpression2(K_FROM, K_IN, "FROM or IN") + checkFROM = false + case c.tokIsKeyword(tok, K_ALL, "all"): + fetch.howMany = fetchAll + fetch.returnsMultipleRows = true + case c.tokIsKeyword(tok, K_FORWARD, "forward"): + c.completeDirection(fetch, &checkFROM) + case c.tokIsKeyword(tok, K_BACKWARD, "backward"): + fetch.direction = fetchBackward + c.completeDirection(fetch, &checkFROM) + case tok == K_FROM || tok == K_IN: + // empty direction + checkFROM = false + case tok == T_DATUM: + // Assume there's no direction clause and tok is a cursor name + c.scan.pushBackToken(tok) + checkFROM = false + default: + // Assume it's a count expression with no preceding keyword. + c.scan.pushBackToken(tok) + fetch.expr, _ = c.readSQLExpression2(K_FROM, K_IN, "FROM or IN") + fetch.returnsMultipleRows = true + checkFROM = false + } + + if checkFROM { + tok = c.lex() + if tok != K_FROM && tok != K_IN { + c.scan.yyerror("expected FROM or IN") + } + } + + return fetch +} + +// complete_direction (pl_gram.y). +func (c *compiler) completeDirection(fetch *stmtFetch, checkFROM *bool) { + tok := c.lex() + if tok == 0 { + c.scan.yyerror("unexpected end of function definition") + } + if tok == K_FROM || tok == K_IN { + *checkFROM = false + return + } + if tok == K_ALL { + fetch.howMany = fetchAll + fetch.returnsMultipleRows = true + *checkFROM = true + return + } + c.scan.pushBackToken(tok) + fetch.expr, _ = c.readSQLExpression2(K_FROM, K_IN, "FROM or IN") + fetch.returnsMultipleRows = true + *checkFROM = false +} + +// make_return_stmt — the vendored mock: fn_rettype is always VOID here, so +// RETURN takes an optional expression and never captures a variable number. +func (c *compiler) makeReturnStmt(location int) plStmt { + st := &stmtReturn{retvarno: -1} + st.lineno = c.scan.locationToLineno(location) + tok := c.lex() + if tok != plToken(';') { + c.scan.pushBackToken(tok) + st.expr = c.readSQLExpression(plToken(';'), ";") + } + return st +} + +// make_return_next_stmt (pl_gram.y, unmocked). +func (c *compiler) makeReturnNextStmt(location int) plStmt { + if !c.fn.fnRetset { + ereportFn("make_return_next_stmt", "cannot use RETURN NEXT in a non-SETOF function") + } + st := &stmtReturnNext{retvarno: -1} + st.lineno = c.scan.locationToLineno(location) + if c.fn.outParamVarno >= 0 { + if c.lex() != plToken(';') { + ereportFn("make_return_next_stmt", "RETURN NEXT cannot have a parameter in function with OUT parameters") + } + st.retvarno = c.fn.outParamVarno + } else { + tok := c.lex() + if tok == T_DATUM && c.scan.peek() == plToken(';') && + isSimpleReturnDatum(c.cur().wdatum.datum) { + st.retvarno = c.cur().wdatum.datum.datumNo() + c.lex() // eat the semicolon token that we only peeked at above + } else { + c.scan.pushBackToken(tok) + st.expr = c.readSQLExpression(plToken(';'), ";") + } + } + return st +} + +func isSimpleReturnDatum(d datum) bool { + switch d.datumType() { + case dtypeVar, dtypePromise, dtypeRow, dtypeRec: + return true + } + return false +} + +// make_return_query_stmt (pl_gram.y). +func (c *compiler) makeReturnQueryStmt(location int) plStmt { + if !c.fn.fnRetset { + ereportFn("make_return_query_stmt", "cannot use RETURN QUERY in a non-SETOF function") + } + st := &stmtReturnQuery{} + st.lineno = c.scan.locationToLineno(location) + + if tok := c.lex(); tok != K_EXECUTE { + c.scan.pushBackToken(tok) + st.query = c.readSQLStmt() + } else { + var term plToken + st.dynquery, term = c.readSQLExpression2(plToken(';'), K_USING, "; or USING") + if term == K_USING { + for { + expr, t := c.readSQLExpression2(plToken(','), plToken(';'), ", or ;") + st.params = append(st.params, expr) + if t != plToken(',') { + break + } + } + } + } + return st +} + +// NameOfDatum (pl_gram.y). +func nameOfDatum(w *plWdatum) string { + if w.ident != "" { + return w.ident + } + return nameListToString(w.idents) +} + +// check_assignable (pl_gram.y). +func (c *compiler) checkAssignable(d datum) { + switch d.datumType() { + case dtypeVar, dtypePromise, dtypeRec: + v := d.(plVariable) + if v.varIsConst() { + ereportFn("check_assignable", `variable "%s" is declared CONSTANT`, v.varRefname()) + } + case dtypeRow: + // always assignable; member vars were checked at compile time + case dtypeRecfield: + // assignable if parent record is + c.checkAssignable(c.datums[d.(*plRecfield).recparentno]) + } +} + +// read_into_target (pl_gram.y). wantStrict selects whether STRICT is legal +// (the C signature's strict != NULL). +func (c *compiler) readIntoTarget(wantStrict bool) (target plVariable, strict bool) { + tok := c.lex() + if wantStrict && tok == K_STRICT { + strict = true + tok = c.lex() + } + + switch tok { + case T_DATUM: + w := c.cur().wdatum + if w.datum.datumType() == dtypeRow || w.datum.datumType() == dtypeRec { + c.checkAssignable(w.datum) + target = w.datum.(plVariable) + if tok = c.lex(); tok == plToken(',') { + c.ereportGram("record variable cannot be part of multiple-item INTO list") + } + c.scan.pushBackToken(tok) + } else { + target = c.readIntoScalarList(nameOfDatum(&w), w.datum, c.loc()) + } + default: + // just to give a better message than "syntax error" + c.currentTokenIsNotVariable(tok) + } + return target, strict +} + +// read_into_scalar_list (pl_gram.y). +func (c *compiler) readIntoScalarList(initialName string, initialDatum datum, initialLocation int) *plRow { + c.checkAssignable(initialDatum) + fieldnames := []string{initialName} + varnos := []int{initialDatum.datumNo()} + + var tok plToken + for { + tok = c.lex() + if tok != plToken(',') { + break + } + if len(fieldnames) >= 1024 { + c.ereportGram("too many INTO variables specified") + } + tok = c.lex() + switch tok { + case T_DATUM: + w := c.cur().wdatum + c.checkAssignable(w.datum) + if w.datum.datumType() == dtypeRow || w.datum.datumType() == dtypeRec { + c.ereportGram(`"%s" is not a scalar variable`, nameOfDatum(&w)) + } + fieldnames = append(fieldnames, nameOfDatum(&w)) + varnos = append(varnos, w.datum.datumNo()) + default: + c.currentTokenIsNotVariable(tok) + } + } + c.scan.pushBackToken(tok) + + row := &plRow{ + refname: "(unnamed row)", + lineno: c.scan.locationToLineno(initialLocation), + fieldnames: fieldnames, + varnos: varnos, + } + c.addDatum(row) + return row +} + +// make_scalar_list1 (pl_gram.y). +func (c *compiler) makeScalarList1(initialName string, initialDatum datum, lineno int) *plRow { + c.checkAssignable(initialDatum) + row := &plRow{ + refname: "(unnamed row)", + lineno: lineno, + fieldnames: []string{initialName}, + varnos: []int{initialDatum.datumNo()}, + } + c.addDatum(row) + return row +} + +// check_sql_expr (pl_gram.y): run the embedded SQL through the main parser. +// On failure, plpgsql_sql_error_callback flushes the external error cursor +// (only an internal one is kept), so the reported error loses its position +// but keeps message/filename/funcname. +func (c *compiler) checkSQLExpr(stmt string, parseMode rawParseMode, location int) { + if !c.checkSyntax { + return + } + var mode parse.Mode + switch parseMode { + case rawParsePlpgsqlExpr: + mode = parse.ModePlpgsqlExpr + case rawParsePlpgsqlAssign1: + mode = parse.ModePlpgsqlAssign1 + case rawParsePlpgsqlAssign2: + mode = parse.ModePlpgsqlAssign2 + case rawParsePlpgsqlAssign3: + mode = parse.ModePlpgsqlAssign3 + default: + mode = parse.ModeDefault + } + if _, err := parse.ParseWithMode(stmt, mode); err != nil { + panic(&compileError{ + Message: err.Message, + Filename: err.Filename, + Funcname: err.Funcname, + }) + } +} + +// check_labels (pl_gram.y). +func checkLabels(startLabel, endLabel string) { + if endLabel != "" { + if startLabel == "" { + ereportFn("check_labels", `end label "%s" specified for unlabeled block`, endLabel) + } + if startLabel != endLabel { + ereportFn("check_labels", `end label "%s" differs from block's label "%s"`, endLabel, startLabel) + } + } +} + +// read_cursor_args (pl_gram.y). +func (c *compiler) readCursorArgs(cursor *plVar, until plToken) *plExpr { + tok := c.lex() + if cursor.cursorExplicitArgrow < 0 { + // No arguments expected + if tok == plToken('(') { + c.ereportGram(`cursor "%s" has no arguments`, cursor.refname) + } + if tok != until { + c.scan.yyerror("syntax error") + } + return nil + } + + // Else better provide arguments + if tok != plToken('(') { + c.ereportGram(`cursor "%s" has arguments`, cursor.refname) + } + + row := c.datums[cursor.cursorExplicitArgrow].(*plRow) + argv := make([]string, len(row.fieldnames)) + filled := make([]bool, len(row.fieldnames)) + anyNamed := false + + for argc := 0; argc < len(row.fieldnames); argc++ { + argpos := argc + + // Check if it's a named parameter: "param := value" + tok1, tok2, _, _ := c.scan.peek2() + if tok1 == tokIDENT && tok2 == tokCOLON_EQUALS { + // Read the argument name, ignoring any matching variable + saveLookup := c.scan.identifierLookup + c.scan.identifierLookup = lookupDeclare + c.lex() + argname := c.cur().str + c.scan.identifierLookup = saveLookup + + // Match argument name to cursor arguments + argpos = -1 + for i, fn := range row.fieldnames { + if fn == argname { + argpos = i + break + } + } + if argpos < 0 { + c.ereportGram(`cursor "%s" has no argument named "%s"`, cursor.refname, argname) + } + + // Eat the ":=". + if c.lex() != tokCOLON_EQUALS { + c.scan.yyerror("syntax error") + } + + anyNamed = true + } + + if filled[argpos] { + c.ereportGram(`value for parameter "%s" of cursor "%s" specified more than once`, + row.fieldnames[argpos], cursor.refname) + } + + item, endtoken := c.readSQLConstruct(plToken(','), plToken(')'), 0, + ",\" or \")", rawParsePlpgsqlExpr, true, true, nil) + + argv[argpos] = item.query + filled[argpos] = true + + if endtoken == plToken(')') && argc != len(row.fieldnames)-1 { + c.ereportGram(`not enough arguments for cursor "%s"`, cursor.refname) + } + if endtoken == plToken(',') && argc == len(row.fieldnames)-1 { + c.ereportGram(`too many arguments for cursor "%s"`, cursor.refname) + } + } + + // Make positional argument list + var ds strings.Builder + for argc := 0; argc < len(row.fieldnames); argc++ { + ds.WriteString(argv[argc]) + if anyNamed { + ds.WriteString(" AS " + deparse.QuoteIdentifier(row.fieldnames[argc])) + } + if argc < len(row.fieldnames)-1 { + ds.WriteString(", ") + } + } + + expr := &plExpr{query: ds.String(), parseMode: rawParsePlpgsqlExpr} + + // Next we'd better find the until token + if c.lex() != until { + c.scan.yyerror("syntax error") + } + + return expr +} + +// read_raise_options (pl_gram.y). +func (c *compiler) readRaiseOptions() []*raiseOption { + var result []*raiseOption + for { + tok := c.lex() + if tok == 0 { + c.scan.yyerror("unexpected end of function definition") + } + + opt := &raiseOption{} + switch { + case c.tokIsKeyword(tok, K_ERRCODE, "errcode"): + opt.optType = raiseOptionErrcode + case c.tokIsKeyword(tok, K_MESSAGE, "message"): + opt.optType = raiseOptionMessage + case c.tokIsKeyword(tok, K_DETAIL, "detail"): + opt.optType = raiseOptionDetail + case c.tokIsKeyword(tok, K_HINT, "hint"): + opt.optType = raiseOptionHint + case c.tokIsKeyword(tok, K_COLUMN, "column"): + opt.optType = raiseOptionColumn + case c.tokIsKeyword(tok, K_CONSTRAINT, "constraint"): + opt.optType = raiseOptionConstraint + case c.tokIsKeyword(tok, K_DATATYPE, "datatype"): + opt.optType = raiseOptionDatatype + case c.tokIsKeyword(tok, K_TABLE, "table"): + opt.optType = raiseOptionTable + case c.tokIsKeyword(tok, K_SCHEMA, "schema"): + opt.optType = raiseOptionSchema + default: + c.scan.yyerror("unrecognized RAISE statement option") + } + + tok = c.lex() + if tok != plToken('=') && tok != tokCOLON_EQUALS { + c.scan.yyerror(`syntax error, expected "="`) + } + + var endTok plToken + opt.expr, endTok = c.readSQLExpression2(plToken(','), plToken(';'), ", or ;") + + result = append(result, opt) + + if endTok == plToken(';') { + break + } + } + return result +} + +// check_raise_parameters (pl_gram.y). +func checkRaiseParameters(st *stmtRaise) { + if !st.hasMessage { + return + } + expected := 0 + msg := st.message + for i := 0; i < len(msg); i++ { + if msg[i] == '%' { + if i+1 < len(msg) && msg[i+1] == '%' { + i++ + } else { + expected++ + } + } + } + if expected < len(st.params) { + ereportFn("check_raise_parameters", "too many parameters specified for RAISE") + } + if expected > len(st.params) { + ereportFn("check_raise_parameters", "too few parameters specified for RAISE") + } +} + +// make_case (pl_gram.y). +func (c *compiler) makeCase(location int, tExpr *plExpr, caseWhenList []*caseWhen, elseStmts []plStmt) plStmt { + st := &stmtCase{ + tExpr: tExpr, + caseWhenList: caseWhenList, + haveElse: elseStmts != nil, + } + st.lineno = c.scan.locationToLineno(location) + // Get rid of list-with-NULL hack + if len(elseStmts) == 1 && elseStmts[0] == nil { + st.elseStmts = nil + } else { + st.elseStmts = elseStmts + } + + if tExpr != nil { + // use a name unlikely to collide with any user names + varname := fmt.Sprintf("__Case__Variable_%d__", len(c.datums)) + + tVar := c.buildVariable(varname, st.lineno, + buildDatatype(oidInt4, -1, 0, nil), true).(*plVar) + st.tVarno = tVar.dno + + for _, cwt := range caseWhenList { + expr := cwt.expr + expr.query = fmt.Sprintf(`"%s" IN (%s)`, varname, expr.query) + } + } + + return st +} diff --git a/internal/plpgsql/json.go b/internal/plpgsql/json.go new file mode 100644 index 0000000..d384751 --- /dev/null +++ b/internal/plpgsql/json.go @@ -0,0 +1,456 @@ +package plpgsql + +import ( + "fmt" + "strings" + + "github.com/sqlc-dev/oliphant/internal/emit" +) + +// Port of pg_query_json_plpgsql.c: the hand-rolled JSON dump of a compiled +// function. Field order, zero-suppression, and the trailing-delimiter dance +// are the C macros' exactly; strings escape through the same _outToken as +// the parse-tree emitter. + +type jbuf struct { + b strings.Builder +} + +func (j *jbuf) s(s string) { j.b.WriteString(s) } +func (j *jbuf) c(c byte) { j.b.WriteByte(c) } +func (j *jbuf) tok(s string) { emit.Token(&j.b, s) } + +// removeTrailingDelimiter is the helper from pg_query_json_helper.c. +func (j *jbuf) removeTrailingDelimiter() { + s := j.b.String() + if len(s) > 0 && s[len(s)-1] == ',' { + j.b.Reset() + j.b.WriteString(s[:len(s)-1]) + } +} + +func (j *jbuf) nodeType(label string) { j.s(`"` + label + `":{`) } + +func (j *jbuf) intField(name string, v int) { + if v != 0 { + fmt.Fprintf(&j.b, `"%s":%d,`, name, v) + } +} + +func (j *jbuf) longField(name string, v int64) { + if v != 0 { + fmt.Fprintf(&j.b, `"%s":%d,`, name, v) + } +} + +func (j *jbuf) enumField(name string, v int) { + fmt.Fprintf(&j.b, `"%s":%d,`, name, v) +} + +func (j *jbuf) boolField(name string, v bool) { + if v { + j.s(`"` + name + `":true,`) + } +} + +func (j *jbuf) stringField(name, v string) { + j.s(`"` + name + `":`) + j.tok(v) + j.s(",") +} + +// objField is WRITE_OBJ_FIELD: `"name":{` + dump + `}},`. +func (j *jbuf) objField(name string, dump func()) { + j.s(`"` + name + `":{`) + dump() + j.removeTrailingDelimiter() + j.s("}},") +} + +func (j *jbuf) exprField(name string, e *plExpr) { + if e != nil { + j.objField(name, func() { j.dumpExpr(e) }) + } +} + +func (j *jbuf) variableField(name string, v plVariable) { + if v != nil { + j.objField(name, func() { j.dumpVariable(v) }) + } +} + +// stmtsField is WRITE_STATEMENTS_FIELD. +func (j *jbuf) stmtsField(name string, stmts []plStmt) { + if len(stmts) == 0 { + return + } + j.s(`"` + name + `":[`) + for _, st := range stmts { + j.dumpStmt(st) + } + j.removeTrailingDelimiter() + j.s("],") +} + +// listField is WRITE_LIST_FIELD. +func listField[T any](j *jbuf, name string, items []T, dump func(T)) { + if len(items) == 0 { + return + } + j.s(`"` + name + `":[`) + for _, it := range items { + j.s("{") + dump(it) + j.removeTrailingDelimiter() + j.s("}},") + } + j.removeTrailingDelimiter() + j.s("],") +} + +func (j *jbuf) dumpStmt(st plStmt) { + j.c('{') + switch v := st.(type) { + case *stmtBlock: + j.dumpBlock(v) + case *stmtAssign: + j.nodeType("PLpgSQL_stmt_assign") + j.intField("lineno", v.lineno) + j.intField("varno", v.varno) + j.exprField("expr", v.expr) + case *stmtIf: + j.nodeType("PLpgSQL_stmt_if") + j.intField("lineno", v.lineno) + j.exprField("cond", v.cond) + j.stmtsField("then_body", v.thenBody) + listField(j, "elsif_list", v.elsifList, func(e *ifElsif) { + j.nodeType("PLpgSQL_if_elsif") + j.intField("lineno", e.lineno) + j.exprField("cond", e.cond) + j.stmtsField("stmts", e.stmts) + }) + j.stmtsField("else_body", v.elseBody) + case *stmtCase: + j.nodeType("PLpgSQL_stmt_case") + j.intField("lineno", v.lineno) + j.exprField("t_expr", v.tExpr) + j.intField("t_varno", v.tVarno) + listField(j, "case_when_list", v.caseWhenList, func(w *caseWhen) { + j.nodeType("PLpgSQL_case_when") + j.intField("lineno", w.lineno) + j.exprField("expr", w.expr) + j.stmtsField("stmts", w.stmts) + }) + j.boolField("have_else", v.haveElse) + j.stmtsField("else_stmts", v.elseStmts) + case *stmtLoop: + j.nodeType("PLpgSQL_stmt_loop") + j.intField("lineno", v.lineno) + j.labelField(v.label) + j.stmtsField("body", v.body) + case *stmtWhile: + j.nodeType("PLpgSQL_stmt_while") + j.intField("lineno", v.lineno) + j.labelField(v.label) + j.exprField("cond", v.cond) + j.stmtsField("body", v.body) + case *stmtFori: + j.nodeType("PLpgSQL_stmt_fori") + j.intField("lineno", v.lineno) + j.labelField(v.label) + if v.varDat != nil { + j.objField("var", func() { j.dumpVar(v.varDat) }) + } + j.exprField("lower", v.lower) + j.exprField("upper", v.upper) + j.exprField("step", v.step) + j.boolField("reverse", v.reverse) + j.stmtsField("body", v.body) + case *stmtFors: + j.nodeType("PLpgSQL_stmt_fors") + j.intField("lineno", v.lineno) + j.labelField(v.label) + j.variableField("var", v.varDat) + j.stmtsField("body", v.body) + j.exprField("query", v.query) + case *stmtForc: + j.nodeType("PLpgSQL_stmt_forc") + j.intField("lineno", v.lineno) + j.labelField(v.label) + j.variableField("var", v.varDat) + j.stmtsField("body", v.body) + j.intField("curvar", v.curvar) + j.exprField("argquery", v.argquery) + case *stmtDynfors: + j.nodeType("PLpgSQL_stmt_dynfors") + j.intField("lineno", v.lineno) + j.labelField(v.label) + j.variableField("var", v.varDat) + j.stmtsField("body", v.body) + j.exprField("query", v.query) + listField(j, "params", v.params, func(e *plExpr) { j.dumpExpr(e) }) + case *stmtForeachA: + j.nodeType("PLpgSQL_stmt_foreach_a") + j.intField("lineno", v.lineno) + j.labelField(v.label) + j.intField("varno", v.varno) + j.intField("slice", v.slice) + j.exprField("expr", v.expr) + j.stmtsField("body", v.body) + case *stmtExit: + j.nodeType("PLpgSQL_stmt_exit") + j.intField("lineno", v.lineno) + j.boolField("is_exit", v.isExit) + j.labelField(v.label) + j.exprField("cond", v.cond) + case *stmtReturn: + j.nodeType("PLpgSQL_stmt_return") + j.intField("lineno", v.lineno) + j.exprField("expr", v.expr) + case *stmtReturnNext: + j.nodeType("PLpgSQL_stmt_return_next") + j.intField("lineno", v.lineno) + j.exprField("expr", v.expr) + case *stmtReturnQuery: + j.nodeType("PLpgSQL_stmt_return_query") + j.intField("lineno", v.lineno) + j.exprField("query", v.query) + j.exprField("dynquery", v.dynquery) + listField(j, "params", v.params, func(e *plExpr) { j.dumpExpr(e) }) + case *stmtRaise: + j.nodeType("PLpgSQL_stmt_raise") + j.intField("lineno", v.lineno) + j.intField("elog_level", v.elogLevel) + if v.condname != "" { + j.stringField("condname", v.condname) + } + if v.hasMessage { + j.stringField("message", v.message) + } + listField(j, "params", v.params, func(e *plExpr) { j.dumpExpr(e) }) + listField(j, "options", v.options, func(o *raiseOption) { + j.nodeType("PLpgSQL_raise_option") + j.enumField("opt_type", int(o.optType)) + j.exprField("expr", o.expr) + }) + case *stmtAssert: + j.nodeType("PLpgSQL_stmt_assert") + j.intField("lineno", v.lineno) + j.exprField("cond", v.cond) + j.exprField("message", v.message) + case *stmtExecsql: + j.nodeType("PLpgSQL_stmt_execsql") + j.intField("lineno", v.lineno) + j.exprField("sqlstmt", v.sqlstmt) + j.boolField("into", v.into) + j.boolField("strict", v.strict) + j.variableField("target", v.target) + case *stmtDynexecute: + j.nodeType("PLpgSQL_stmt_dynexecute") + j.intField("lineno", v.lineno) + j.exprField("query", v.query) + j.boolField("into", v.into) + j.boolField("strict", v.strict) + j.variableField("target", v.target) + listField(j, "params", v.params, func(e *plExpr) { j.dumpExpr(e) }) + case *stmtGetdiag: + j.nodeType("PLpgSQL_stmt_getdiag") + j.intField("lineno", v.lineno) + j.boolField("is_stacked", v.isStacked) + listField(j, "diag_items", v.diagItems, func(d *diagItem) { + j.nodeType("PLpgSQL_diag_item") + j.stringField("kind", getdiagKindname(d.kind)) + j.intField("target", d.target) + }) + case *stmtOpen: + j.nodeType("PLpgSQL_stmt_open") + j.intField("lineno", v.lineno) + j.intField("curvar", v.curvar) + j.intField("cursor_options", v.cursorOptions) + j.exprField("argquery", v.argquery) + j.exprField("query", v.query) + j.exprField("dynquery", v.dynquery) + listField(j, "params", v.params, func(e *plExpr) { j.dumpExpr(e) }) + case *stmtFetch: + j.nodeType("PLpgSQL_stmt_fetch") + j.intField("lineno", v.lineno) + j.variableField("target", v.target) + j.intField("curvar", v.curvar) + j.enumField("direction", int(v.direction)) + j.longField("how_many", v.howMany) + j.exprField("expr", v.expr) + j.boolField("is_move", v.isMove) + j.boolField("returns_multiple_rows", v.returnsMultipleRows) + case *stmtClose: + j.nodeType("PLpgSQL_stmt_close") + j.intField("lineno", v.lineno) + j.intField("curvar", v.curvar) + case *stmtPerform: + j.nodeType("PLpgSQL_stmt_perform") + j.intField("lineno", v.lineno) + j.exprField("expr", v.expr) + case *stmtCall: + j.nodeType("PLpgSQL_stmt_call") + j.intField("lineno", v.lineno) + j.exprField("expr", v.expr) + j.boolField("is_call", v.isCall) + j.variableField("target", v.target) + case *stmtCommit: + j.nodeType("PLpgSQL_stmt_commit") + j.intField("lineno", v.lineno) + j.boolField("chain", v.chain) + case *stmtRollback: + j.nodeType("PLpgSQL_stmt_rollback") + j.intField("lineno", v.lineno) + j.boolField("chain", v.chain) + } + j.removeTrailingDelimiter() + j.s("}},") +} + +// labelField is WRITE_STRING_FIELD(label): NULL labels ("" here) are omitted. +func (j *jbuf) labelField(label string) { + if label != "" { + j.stringField("label", label) + } +} + +func (j *jbuf) dumpBlock(v *stmtBlock) { + j.nodeType("PLpgSQL_stmt_block") + j.intField("lineno", v.lineno) + j.labelField(v.label) + j.stmtsField("body", v.body) + if v.exceptions != nil { + j.objField("exceptions", func() { + j.nodeType("PLpgSQL_exception_block") + listField(j, "exc_list", v.exceptions.excList, func(e *plException) { + j.nodeType("PLpgSQL_exception") + j.s(`"conditions":[`) + for cond := e.conditions; cond != nil; cond = cond.next { + j.s("{") + j.nodeType("PLpgSQL_condition") + if cond.condname != "" { + j.stringField("condname", cond.condname) + } + j.removeTrailingDelimiter() + j.s("}},") + } + j.removeTrailingDelimiter() + j.s("],") + j.stmtsField("action", e.action) + }) + }) + } + j.removeTrailingDelimiter() +} + +func (j *jbuf) dumpExpr(e *plExpr) { + j.nodeType("PLpgSQL_expr") + j.stringField("query", e.query) + j.enumField("parseMode", int(e.parseMode)) +} + +func (j *jbuf) dumpVariable(v plVariable) { + switch d := v.(type) { + case *plRec: + j.dumpRecord(d) + case *plVar: + j.dumpVar(d) + case *plRow: + j.dumpRow(d) + } +} + +func (j *jbuf) dumpType(t *plType) { + j.nodeType("PLpgSQL_type") + if t.typname != "" { + j.stringField("typname", t.typname) + } +} + +func (j *jbuf) dumpVar(v *plVar) { + j.nodeType("PLpgSQL_var") + j.stringField("refname", v.refname) + j.intField("lineno", v.lineno) + if v.datatype != nil { + j.objField("datatype", func() { j.dumpType(v.datatype) }) + } + j.boolField("isconst", v.isconst) + j.boolField("notnull", v.notnull) + j.exprField("default_val", v.defaultVal) + j.exprField("cursor_explicit_expr", v.cursorExplicitExpr) + j.intField("cursor_explicit_argrow", v.cursorExplicitArgrow) + j.intField("cursor_options", v.cursorOptions) +} + +func (j *jbuf) dumpRow(v *plRow) { + j.nodeType("PLpgSQL_row") + j.stringField("refname", v.refname) + j.intField("lineno", v.lineno) + j.s(`"fields":`) + j.c('[') + for i := range v.fieldnames { + if v.fieldnames[i] != "" { + j.c('{') + j.stringField("name", v.fieldnames[i]) + j.intField("varno", v.varnos[i]) + j.removeTrailingDelimiter() + j.s("},") + } else { + j.s("null,") + } + } + j.removeTrailingDelimiter() + j.s("],") +} + +func (j *jbuf) dumpRecord(v *plRec) { + j.nodeType("PLpgSQL_rec") + j.stringField("refname", v.refname) + j.intField("dno", v.dno) + j.intField("lineno", v.lineno) +} + +func (j *jbuf) dumpRecordField(v *plRecfield) { + j.nodeType("PLpgSQL_recfield") + j.stringField("fieldname", v.fieldname) + j.intField("recparentno", v.recparentno) +} + +// toJSON is plpgsqlToJSON. +func toJSON(fn *plFunction) string { + j := &jbuf{} + j.c('{') + + j.nodeType("PLpgSQL_function") + j.intField("new_varno", fn.newVarno) + j.intField("old_varno", fn.oldVarno) + + j.s(`"datums":`) + j.c('[') + for _, d := range fn.datums { + j.c('{') + switch v := d.(type) { + case *plVar: + j.dumpVar(v) + case *plRow: + j.dumpRow(v) + case *plRec: + j.dumpRecord(v) + case *plRecfield: + j.dumpRecordField(v) + } + j.removeTrailingDelimiter() + j.s("}},") + } + j.removeTrailingDelimiter() + j.s("],") + + if fn.action != nil { + j.objField("action", func() { j.dumpBlock(fn.action) }) + } + + j.removeTrailingDelimiter() + j.s("}}") + return j.b.String() +} diff --git a/internal/plpgsql/scanner.go b/internal/plpgsql/scanner.go new file mode 100644 index 0000000..f737efe --- /dev/null +++ b/internal/plpgsql/scanner.go @@ -0,0 +1,513 @@ +package plpgsql + +import ( + "strings" + + "github.com/sqlc-dev/oliphant/ast" + "github.com/sqlc-dev/oliphant/internal/lexer" +) + +// plToken is a token code as pl_gram.y sees it: single characters are their +// byte values, core-lexer tokens keep the bison numbers of the pinned SQL +// grammar (the ast.Token values), and the PL-specific tokens (T_WORD, +// T_CWORD, T_DATUM, LESS_LESS, GREATER_GREATER, and the K_* keywords) get +// codes far above that range. +type plToken int32 + +const ( + tokEOF = plToken(0) + tokIDENT = plToken(ast.Token_IDENT) + tokUIDENT = plToken(ast.Token_UIDENT) + tokFCONST = plToken(ast.Token_FCONST) + tokSCONST = plToken(ast.Token_SCONST) + tokUSCONST = plToken(ast.Token_USCONST) + tokBCONST = plToken(ast.Token_BCONST) + tokXCONST = plToken(ast.Token_XCONST) + tokOp = plToken(ast.Token_Op) + tokICONST = plToken(ast.Token_ICONST) + tokPARAM = plToken(ast.Token_PARAM) + tokTYPECAST = plToken(ast.Token_TYPECAST) + tokDOT_DOT = plToken(ast.Token_DOT_DOT) + tokCOLON_EQUALS = plToken(ast.Token_COLON_EQUALS) +) + +// pl_gram.y token declarations (the PL-specific ones). +const ( + T_WORD plToken = 20000 + iota + T_CWORD + T_DATUM + LESS_LESS + GREATER_GREATER + K_ABSOLUTE + K_ALIAS + K_ALL + K_AND + K_ARRAY + K_ASSERT + K_BACKWARD + K_BEGIN + K_BY + K_CALL + K_CASE + K_CHAIN + K_CLOSE + K_COLLATE + K_COLUMN + K_COLUMN_NAME + K_COMMIT + K_CONSTANT + K_CONSTRAINT + K_CONSTRAINT_NAME + K_CONTINUE + K_CURRENT + K_CURSOR + K_DATATYPE + K_DEBUG + K_DECLARE + K_DEFAULT + K_DETAIL + K_DIAGNOSTICS + K_DO + K_DUMP + K_ELSE + K_ELSIF + K_END + K_ERRCODE + K_ERROR + K_EXCEPTION + K_EXECUTE + K_EXIT + K_FETCH + K_FIRST + K_FOR + K_FOREACH + K_FORWARD + K_FROM + K_GET + K_HINT + K_IF + K_IMPORT + K_IN + K_INFO + K_INSERT + K_INTO + K_IS + K_LAST + K_LOG + K_LOOP + K_MERGE + K_MESSAGE + K_MESSAGE_TEXT + K_MOVE + K_NEXT + K_NO + K_NOT + K_NOTICE + K_NULL + K_OPEN + K_OPTION + K_OR + K_PERFORM + K_PG_CONTEXT + K_PG_DATATYPE_NAME + K_PG_EXCEPTION_CONTEXT + K_PG_EXCEPTION_DETAIL + K_PG_EXCEPTION_HINT + K_PG_ROUTINE_OID + K_PRINT_STRICT_PARAMS + K_PRIOR + K_QUERY + K_RAISE + K_RELATIVE + K_RETURN + K_RETURNED_SQLSTATE + K_REVERSE + K_ROLLBACK + K_ROW_COUNT + K_ROWTYPE + K_SCHEMA + K_SCHEMA_NAME + K_SCROLL + K_SLICE + K_SQLSTATE + K_STACKED + K_STRICT + K_TABLE + K_TABLE_NAME + K_THEN + K_TO + K_TYPE + K_USE_COLUMN + K_USE_VARIABLE + K_USING + K_VARIABLE_CONFLICT + K_WARNING + K_WHEN + K_WHILE +) + +// IdentifierLookup modes (plpgsql.h). +type identifierLookup int + +const ( + lookupNormal identifierLookup = iota + lookupDeclare + lookupExpr +) + +// plWord / plCword / plWdatum are PLword / PLcword / PLwdatum. +type plWord struct { + ident string + quoted bool +} + +type plWdatum struct { + datum datum + ident string + quoted bool + idents []string +} + +// tokenAux carries one token plus its auxiliary data (TokenAuxData: the +// YYSTYPE union collapses to a struct here; str doubles as the union's +// leading char* member, so it stays filled alongside word/keyword). +type tokenAux struct { + tok plToken + lloc int + leng int + + str string + ival int32 + keyword string + word plWord + cword []string + wdatum plWdatum +} + +// plScanner is pl_scanner.c's state: the core scanner (initialized with the +// PL reserved keyword list — modeled by re-classifying the SQL lexer's +// output), the pushback stack, and the location-to-lineno tracker. +type plScanner struct { + src string + core *lexer.Scanner + + identifierLookup identifierLookup + + cur tokenAux // token last returned by yylex (yylval/yylloc/yyleng/yytoken) + + pushback []tokenAux + + curLineStart int + curLineEnd int // byte index of the next '\n', or -1 + curLineNum int + + comp *compiler // for plpgsql_parse_word and friends +} + +// newScanner is plpgsql_scanner_init. +func newScanner(src string, comp *compiler) *plScanner { + core := lexer.New(src) + s := &plScanner{ + src: core.Input(), + core: core, + identifierLookup: lookupNormal, + comp: comp, + } + s.locationLinenoInit() + return s +} + +// internalYylex wraps the core lexer: pushback stack, the << >> # operator +// translations, PARAM-as-text, and comment-token skipping. The keyword +// re-classification models scanner_init with ReservedPLKeywords: SQL +// keywords come back as plain identifiers unless they are PL-reserved. +func (s *plScanner) internalYylex(aux *tokenAux) plToken { + if n := len(s.pushback); n > 0 { + *aux = s.pushback[n-1] + s.pushback = s.pushback[:n-1] + return aux.tok + } + + tok, lerr := s.core.Next() + if lerr != nil { + // A core-scanner ereport (scan.l): external error position, reported + // through the compile error path with context attached. + panic(&compileError{ + Message: lerr.Message, + Filename: lerr.Filename, + Funcname: lerr.Funcname, + Cursorpos: lerr.Cursorpos, + }) + } + + *aux = tokenAux{ + tok: plToken(tok.Kind), + lloc: int(tok.Start), + leng: int(tok.End - tok.Start), + str: tok.Str, + ival: tok.Ival, + } + + switch { + case tok.Kind == 0: + aux.tok = tokEOF + + case tok.Kind == ast.Token_SQL_COMMENT || tok.Kind == ast.Token_C_COMMENT: + return s.internalYylex(aux) + + case tok.Kind == ast.Token_Op: + // Check for << >> and #, which the core considers operators. + switch tok.Str { + case "<<": + aux.tok = LESS_LESS + case ">>": + aux.tok = GREATER_GREATER + case "#": + aux.tok = plToken('#') + } + + case tok.Kind == ast.Token_PARAM: + // The core returns PARAM as ival, but we treat it like IDENT. + aux.str = s.src[tok.Start:tok.End] + + case tok.KeywordKind != ast.KeywordKind_NO_KEYWORD: + // A keyword of the SQL scanner. With the PL reserved list installed + // instead, all of these lex as plain identifiers — except the ones + // that are PL-reserved, and the n'...' NCHAR special (which falls + // back to a 1-byte IDENT "n" when "nchar" is not in the list). + if int(tok.End-tok.Start) != len(tok.Str) && tok.Str == "nchar" { + aux.tok = tokIDENT + aux.str = "n" + break + } + if kw, ok := reservedKeywords[tok.Str]; ok { + aux.tok = kw + aux.keyword = tok.Str + break + } + aux.tok = tokIDENT + + case tok.Kind == ast.Token_IDENT: + // Unquoted identifiers can still match PL-reserved words the SQL + // scanner has no keyword for (LOOP, FOREACH, WHILE, ...). + if s.src[tok.Start] != '"' { + if kw, ok := reservedKeywords[tok.Str]; ok { + aux.tok = kw + aux.keyword = tok.Str + } + } + } + + return aux.tok +} + +// pushBackTokenAux is push_back_token. +func (s *plScanner) pushBackTokenAux(tok plToken, aux *tokenAux) { + a := *aux + a.tok = tok + s.pushback = append(s.pushback, a) +} + +// pushBackToken is plpgsql_push_back_token: re-queue the current token. +func (s *plScanner) pushBackToken(tok plToken) { + s.pushBackTokenAux(tok, &s.cur) +} + +// yylex is plpgsql_yylex: compose A.B.C identifiers and classify them as +// T_DATUM / T_CWORD / T_WORD / unreserved keyword. +func (s *plScanner) yylex() plToken { + var aux1 tokenAux + tok1 := s.internalYylex(&aux1) + if tok1 == tokIDENT || tok1 == tokPARAM { + var aux2 tokenAux + tok2 := s.internalYylex(&aux2) + if tok2 == plToken('.') { + var aux3 tokenAux + tok3 := s.internalYylex(&aux3) + if tok3 == tokIDENT { + var aux4 tokenAux + tok4 := s.internalYylex(&aux4) + if tok4 == plToken('.') { + var aux5 tokenAux + tok5 := s.internalYylex(&aux5) + if tok5 == tokIDENT { + if s.comp.parseTripword(aux1.str, aux3.str, aux5.str, &aux1.wdatum, &aux1.cword) { + tok1 = T_DATUM + } else { + tok1 = T_CWORD + } + // Adjust token length to include A.B.C + aux1.leng = aux5.lloc - aux1.lloc + aux5.leng + } else { + // not A.B.C, so just process A.B + s.pushBackTokenAux(tok5, &aux5) + s.pushBackTokenAux(tok4, &aux4) + if s.comp.parseDblword(aux1.str, aux3.str, &aux1.wdatum, &aux1.cword) { + tok1 = T_DATUM + } else { + tok1 = T_CWORD + } + aux1.leng = aux3.lloc - aux1.lloc + aux3.leng + } + } else { + // not A.B.C, so just process A.B + s.pushBackTokenAux(tok4, &aux4) + if s.comp.parseDblword(aux1.str, aux3.str, &aux1.wdatum, &aux1.cword) { + tok1 = T_DATUM + } else { + tok1 = T_CWORD + } + aux1.leng = aux3.lloc - aux1.lloc + aux3.leng + } + } else { + // not A.B, so just process A + s.pushBackTokenAux(tok3, &aux3) + s.pushBackTokenAux(tok2, &aux2) + if s.comp.parseWord(aux1.str, s.quotedAt(aux1.lloc), true, &aux1.wdatum, &aux1.word) { + tok1 = T_DATUM + } else if kw, ok := s.unreservedCheck(&aux1); ok { + tok1 = kw + } else { + tok1 = T_WORD + } + } + } else { + // not A.B, so just process A + s.pushBackTokenAux(tok2, &aux2) + + // See if it matches a variable name, except at start of statement + // when the next token isn't assignment or '['. + lookup := !atStmtStart(s.cur.tok) || + (tok2 == plToken('=') || tok2 == tokCOLON_EQUALS || tok2 == plToken('[')) + if s.comp.parseWord(aux1.str, s.quotedAt(aux1.lloc), lookup, &aux1.wdatum, &aux1.word) { + tok1 = T_DATUM + } else if kw, ok := s.unreservedCheck(&aux1); ok { + tok1 = kw + } else { + tok1 = T_WORD + } + } + } + + s.cur = aux1 + s.cur.tok = tok1 + return tok1 +} + +// unreservedCheck applies the unreserved-keyword lookup that follows a +// failed variable lookup (aux.word was filled in by parseWord). +func (s *plScanner) unreservedCheck(aux *tokenAux) (plToken, bool) { + if aux.word.quoted { + return 0, false + } + if kw, ok := unreservedKeywords[aux.word.ident]; ok { + aux.keyword = aux.word.ident + return kw, true + } + return 0, false +} + +// quotedAt reports whether the token starting at lloc was written quoted +// (yytxt[0] == '"' in the C checks). +func (s *plScanner) quotedAt(lloc int) bool { + return lloc < len(s.src) && s.src[lloc] == '"' +} + +// AT_STMT_START (pl_scanner.c). +func atStmtStart(prevToken plToken) bool { + return prevToken == plToken(';') || prevToken == K_BEGIN || + prevToken == K_THEN || prevToken == K_ELSE || prevToken == K_LOOP +} + +// tokenLength is plpgsql_token_length. +func (s *plScanner) tokenLength() int { return s.cur.leng } + +// peek is plpgsql_peek. +func (s *plScanner) peek() plToken { + var aux tokenAux + tok := s.internalYylex(&aux) + s.pushBackTokenAux(tok, &aux) + return tok +} + +// peek2 is plpgsql_peek2. +func (s *plScanner) peek2() (tok1, tok2 plToken, tok1loc, tok2loc int) { + var aux1, aux2 tokenAux + tok1 = s.internalYylex(&aux1) + tok2 = s.internalYylex(&aux2) + tok1loc, tok2loc = aux1.lloc, aux2.lloc + s.pushBackTokenAux(tok2, &aux2) + s.pushBackTokenAux(tok1, &aux1) + return +} + +// tokenIsUnreservedKeyword is plpgsql_token_is_unreserved_keyword. +func tokenIsUnreservedKeyword(tok plToken) bool { + for _, t := range unreservedKeywords { + if t == tok { + return true + } + } + return false +} + +// appendSourceText is plpgsql_append_source_text. +func (s *plScanner) sourceText(startLocation, endLocation int) string { + return s.src[startLocation:endLocation] +} + +// yyerror is plpgsql_yyerror: report at the current token. +func (s *plScanner) yyerror(message string) { + if s.cur.lloc >= len(s.src) { + panic(&compileError{ + Message: message + " at end of input", + Filename: plScannerFilename, + Funcname: "plpgsql_yyerror", + }) + } + yytext := s.src[s.cur.lloc:min(s.cur.lloc+s.cur.leng, len(s.src))] + panic(&compileError{ + Message: message + ` at or near "` + yytext + `"`, + Filename: plScannerFilename, + Funcname: "plpgsql_yyerror", + }) +} + +// plScannerFilename is what __FILE__ expands to in the vendored build. +const plScannerFilename = "src_pl_plpgsql_src_pl_scanner.c" + +// locationToLineno is plpgsql_location_to_lineno. +func (s *plScanner) locationToLineno(location int) int { + if location < 0 { + return 0 + } + if location < s.curLineStart { + s.locationLinenoInit() + } + for s.curLineEnd >= 0 && location > s.curLineEnd { + s.curLineStart = s.curLineEnd + 1 + s.curLineNum++ + s.curLineEnd = nextNewline(s.src, s.curLineStart) + } + return s.curLineNum +} + +func (s *plScanner) locationLinenoInit() { + s.curLineStart = 0 + s.curLineNum = 1 + s.curLineEnd = nextNewline(s.src, 0) +} + +// latestLineno is plpgsql_latest_lineno. +func (s *plScanner) latestLineno() int { return s.curLineNum } + +func nextNewline(src string, from int) int { + if from > len(src) { + return -1 + } + idx := strings.IndexByte(src[from:], '\n') + if idx < 0 { + return -1 + } + return from + idx +} diff --git a/internal/plpgsql/tables.go b/internal/plpgsql/tables.go new file mode 100644 index 0000000..b595fdf --- /dev/null +++ b/internal/plpgsql/tables.go @@ -0,0 +1,373 @@ +// Code generated by cmd/generate -plpgsql from internal/reference/ +// pl_reserved_kwlist.h, pl_unreserved_kwlist.h, and plerrcodes.h +// (libpg_query 17-6.2.2). DO NOT EDIT. + +package plpgsql + +// reservedKeywords is pl_reserved_kwlist.h: these are passed to the core +// scanner's keyword list, so they win over any variable name. +var reservedKeywords = map[string]plToken{ + "all": K_ALL, + "begin": K_BEGIN, + "by": K_BY, + "case": K_CASE, + "declare": K_DECLARE, + "else": K_ELSE, + "end": K_END, + "execute": K_EXECUTE, + "for": K_FOR, + "foreach": K_FOREACH, + "from": K_FROM, + "if": K_IF, + "in": K_IN, + "into": K_INTO, + "loop": K_LOOP, + "not": K_NOT, + "null": K_NULL, + "or": K_OR, + "strict": K_STRICT, + "then": K_THEN, + "to": K_TO, + "using": K_USING, + "when": K_WHEN, + "while": K_WHILE, +} + +// unreservedKeywords is pl_unreserved_kwlist.h: checked only where the +// grammar wants a keyword and no variable matched. +var unreservedKeywords = map[string]plToken{ + "absolute": K_ABSOLUTE, + "alias": K_ALIAS, + "and": K_AND, + "array": K_ARRAY, + "assert": K_ASSERT, + "backward": K_BACKWARD, + "call": K_CALL, + "chain": K_CHAIN, + "close": K_CLOSE, + "collate": K_COLLATE, + "column": K_COLUMN, + "column_name": K_COLUMN_NAME, + "commit": K_COMMIT, + "constant": K_CONSTANT, + "constraint": K_CONSTRAINT, + "constraint_name": K_CONSTRAINT_NAME, + "continue": K_CONTINUE, + "current": K_CURRENT, + "cursor": K_CURSOR, + "datatype": K_DATATYPE, + "debug": K_DEBUG, + "default": K_DEFAULT, + "detail": K_DETAIL, + "diagnostics": K_DIAGNOSTICS, + "do": K_DO, + "dump": K_DUMP, + "elseif": K_ELSIF, + "elsif": K_ELSIF, + "errcode": K_ERRCODE, + "error": K_ERROR, + "exception": K_EXCEPTION, + "exit": K_EXIT, + "fetch": K_FETCH, + "first": K_FIRST, + "forward": K_FORWARD, + "get": K_GET, + "hint": K_HINT, + "import": K_IMPORT, + "info": K_INFO, + "insert": K_INSERT, + "is": K_IS, + "last": K_LAST, + "log": K_LOG, + "merge": K_MERGE, + "message": K_MESSAGE, + "message_text": K_MESSAGE_TEXT, + "move": K_MOVE, + "next": K_NEXT, + "no": K_NO, + "notice": K_NOTICE, + "open": K_OPEN, + "option": K_OPTION, + "perform": K_PERFORM, + "pg_context": K_PG_CONTEXT, + "pg_datatype_name": K_PG_DATATYPE_NAME, + "pg_exception_context": K_PG_EXCEPTION_CONTEXT, + "pg_exception_detail": K_PG_EXCEPTION_DETAIL, + "pg_exception_hint": K_PG_EXCEPTION_HINT, + "pg_routine_oid": K_PG_ROUTINE_OID, + "print_strict_params": K_PRINT_STRICT_PARAMS, + "prior": K_PRIOR, + "query": K_QUERY, + "raise": K_RAISE, + "relative": K_RELATIVE, + "return": K_RETURN, + "returned_sqlstate": K_RETURNED_SQLSTATE, + "reverse": K_REVERSE, + "rollback": K_ROLLBACK, + "row_count": K_ROW_COUNT, + "rowtype": K_ROWTYPE, + "schema": K_SCHEMA, + "schema_name": K_SCHEMA_NAME, + "scroll": K_SCROLL, + "slice": K_SLICE, + "sqlstate": K_SQLSTATE, + "stacked": K_STACKED, + "table": K_TABLE, + "table_name": K_TABLE_NAME, + "type": K_TYPE, + "use_column": K_USE_COLUMN, + "use_variable": K_USE_VARIABLE, + "variable_conflict": K_VARIABLE_CONFLICT, + "warning": K_WARNING, +} + +// errConditions maps exception condition names to their number of +// entries in exception_label_map (plpgsql_parse_err_condition returns a +// chain with one node per entry). +var errConditions = map[string]int{ + "active_sql_transaction": 1, + "admin_shutdown": 1, + "ambiguous_alias": 1, + "ambiguous_column": 1, + "ambiguous_function": 1, + "ambiguous_parameter": 1, + "array_subscript_error": 1, + "assert_failure": 1, + "bad_copy_file_format": 1, + "branch_transaction_already_active": 1, + "cannot_coerce": 1, + "cannot_connect_now": 1, + "cant_change_runtime_param": 1, + "cardinality_violation": 1, + "case_not_found": 1, + "character_not_in_repertoire": 1, + "check_violation": 1, + "collation_mismatch": 1, + "config_file_error": 1, + "configuration_limit_exceeded": 1, + "connection_does_not_exist": 1, + "connection_exception": 1, + "connection_failure": 1, + "containing_sql_not_permitted": 1, + "crash_shutdown": 1, + "data_corrupted": 1, + "data_exception": 1, + "database_dropped": 1, + "datatype_mismatch": 1, + "datetime_field_overflow": 1, + "deadlock_detected": 1, + "dependent_objects_still_exist": 1, + "dependent_privilege_descriptors_still_exist": 1, + "diagnostics_exception": 1, + "disk_full": 1, + "division_by_zero": 1, + "duplicate_alias": 1, + "duplicate_column": 1, + "duplicate_cursor": 1, + "duplicate_database": 1, + "duplicate_file": 1, + "duplicate_function": 1, + "duplicate_json_object_key_value": 1, + "duplicate_object": 1, + "duplicate_prepared_statement": 1, + "duplicate_schema": 1, + "duplicate_table": 1, + "error_in_assignment": 1, + "escape_character_conflict": 1, + "event_trigger_protocol_violated": 1, + "exclusion_violation": 1, + "external_routine_exception": 1, + "external_routine_invocation_exception": 1, + "fdw_column_name_not_found": 1, + "fdw_dynamic_parameter_value_needed": 1, + "fdw_error": 1, + "fdw_function_sequence_error": 1, + "fdw_inconsistent_descriptor_information": 1, + "fdw_invalid_attribute_value": 1, + "fdw_invalid_column_name": 1, + "fdw_invalid_column_number": 1, + "fdw_invalid_data_type": 1, + "fdw_invalid_data_type_descriptors": 1, + "fdw_invalid_descriptor_field_identifier": 1, + "fdw_invalid_handle": 1, + "fdw_invalid_option_index": 1, + "fdw_invalid_option_name": 1, + "fdw_invalid_string_format": 1, + "fdw_invalid_string_length_or_buffer_length": 1, + "fdw_invalid_use_of_null_pointer": 1, + "fdw_no_schemas": 1, + "fdw_option_name_not_found": 1, + "fdw_out_of_memory": 1, + "fdw_reply_handle": 1, + "fdw_schema_not_found": 1, + "fdw_table_not_found": 1, + "fdw_too_many_handles": 1, + "fdw_unable_to_create_execution": 1, + "fdw_unable_to_create_reply": 1, + "fdw_unable_to_establish_connection": 1, + "feature_not_supported": 1, + "floating_point_exception": 1, + "foreign_key_violation": 1, + "function_executed_no_return_statement": 1, + "generated_always": 1, + "grouping_error": 1, + "held_cursor_requires_same_isolation_level": 1, + "idle_in_transaction_session_timeout": 1, + "idle_session_timeout": 1, + "in_failed_sql_transaction": 1, + "inappropriate_access_mode_for_branch_transaction": 1, + "inappropriate_isolation_level_for_branch_transaction": 1, + "indeterminate_collation": 1, + "indeterminate_datatype": 1, + "index_corrupted": 1, + "indicator_overflow": 1, + "insufficient_privilege": 1, + "insufficient_resources": 1, + "integrity_constraint_violation": 1, + "internal_error": 1, + "interval_field_overflow": 1, + "invalid_argument_for_logarithm": 1, + "invalid_argument_for_nth_value_function": 1, + "invalid_argument_for_ntile_function": 1, + "invalid_argument_for_power_function": 1, + "invalid_argument_for_sql_json_datetime_function": 1, + "invalid_argument_for_width_bucket_function": 1, + "invalid_authorization_specification": 1, + "invalid_binary_representation": 1, + "invalid_catalog_name": 1, + "invalid_character_value_for_cast": 1, + "invalid_column_definition": 1, + "invalid_column_reference": 1, + "invalid_cursor_definition": 1, + "invalid_cursor_name": 1, + "invalid_cursor_state": 1, + "invalid_database_definition": 1, + "invalid_datetime_format": 1, + "invalid_escape_character": 1, + "invalid_escape_octet": 1, + "invalid_escape_sequence": 1, + "invalid_foreign_key": 1, + "invalid_function_definition": 1, + "invalid_grant_operation": 1, + "invalid_grantor": 1, + "invalid_indicator_parameter_value": 1, + "invalid_json_text": 1, + "invalid_locator_specification": 1, + "invalid_name": 1, + "invalid_object_definition": 1, + "invalid_parameter_value": 1, + "invalid_password": 1, + "invalid_preceding_or_following_size": 1, + "invalid_prepared_statement_definition": 1, + "invalid_recursion": 1, + "invalid_regular_expression": 1, + "invalid_role_specification": 1, + "invalid_row_count_in_limit_clause": 1, + "invalid_row_count_in_result_offset_clause": 1, + "invalid_savepoint_specification": 1, + "invalid_schema_definition": 1, + "invalid_schema_name": 1, + "invalid_sql_json_subscript": 1, + "invalid_sql_statement_name": 1, + "invalid_sqlstate_returned": 1, + "invalid_table_definition": 1, + "invalid_tablesample_argument": 1, + "invalid_tablesample_repeat": 1, + "invalid_text_representation": 1, + "invalid_time_zone_displacement_value": 1, + "invalid_transaction_initiation": 1, + "invalid_transaction_state": 1, + "invalid_transaction_termination": 1, + "invalid_use_of_escape_character": 1, + "invalid_xml_comment": 1, + "invalid_xml_content": 1, + "invalid_xml_document": 1, + "invalid_xml_processing_instruction": 1, + "io_error": 1, + "locator_exception": 1, + "lock_file_exists": 1, + "lock_not_available": 1, + "modifying_sql_data_not_permitted": 2, + "more_than_one_sql_json_item": 1, + "most_specific_type_mismatch": 1, + "name_too_long": 1, + "no_active_sql_transaction": 1, + "no_active_sql_transaction_for_branch_transaction": 1, + "no_data_found": 1, + "no_sql_json_item": 1, + "non_numeric_sql_json_item": 1, + "non_unique_keys_in_a_json_object": 1, + "nonstandard_use_of_escape_character": 1, + "not_an_xml_document": 1, + "not_null_violation": 1, + "null_value_no_indicator_parameter": 1, + "null_value_not_allowed": 2, + "numeric_value_out_of_range": 1, + "object_in_use": 1, + "object_not_in_prerequisite_state": 1, + "operator_intervention": 1, + "out_of_memory": 1, + "plpgsql_error": 1, + "program_limit_exceeded": 1, + "prohibited_sql_statement_attempted": 2, + "protocol_violation": 1, + "query_canceled": 1, + "raise_exception": 1, + "read_only_sql_transaction": 1, + "reading_sql_data_not_permitted": 2, + "reserved_name": 1, + "restrict_violation": 1, + "savepoint_exception": 1, + "schema_and_data_statement_mixing_not_supported": 1, + "sequence_generator_limit_exceeded": 1, + "serialization_failure": 1, + "singleton_sql_json_item_required": 1, + "sql_json_array_not_found": 1, + "sql_json_item_cannot_be_cast_to_target_type": 1, + "sql_json_member_not_found": 1, + "sql_json_number_not_found": 1, + "sql_json_object_not_found": 1, + "sql_json_scalar_required": 1, + "sql_routine_exception": 1, + "sql_statement_not_yet_complete": 1, + "sqlclient_unable_to_establish_sqlconnection": 1, + "sqlserver_rejected_establishment_of_sqlconnection": 1, + "srf_protocol_violated": 1, + "stacked_diagnostics_accessed_without_active_handler": 1, + "statement_completion_unknown": 1, + "statement_too_complex": 1, + "string_data_length_mismatch": 1, + "string_data_right_truncation": 1, + "substring_error": 1, + "syntax_error": 1, + "syntax_error_or_access_rule_violation": 1, + "system_error": 1, + "too_many_arguments": 1, + "too_many_columns": 1, + "too_many_connections": 1, + "too_many_json_array_elements": 1, + "too_many_json_object_members": 1, + "too_many_rows": 1, + "transaction_integrity_constraint_violation": 1, + "transaction_resolution_unknown": 1, + "transaction_rollback": 1, + "transaction_timeout": 1, + "trigger_protocol_violated": 1, + "triggered_action_exception": 1, + "triggered_data_change_violation": 1, + "trim_error": 1, + "undefined_column": 1, + "undefined_file": 1, + "undefined_function": 1, + "undefined_object": 1, + "undefined_parameter": 1, + "undefined_table": 1, + "unique_violation": 1, + "unsafe_new_enum_value_usage": 1, + "unterminated_c_string": 1, + "untranslatable_character": 1, + "windowing_error": 1, + "with_check_option_violation": 1, + "wrong_object_type": 1, + "zero_length_character_string": 1, +} diff --git a/internal/rawwalk/walker.go b/internal/rawwalk/walker.go new file mode 100644 index 0000000..5a6e14f --- /dev/null +++ b/internal/rawwalk/walker.go @@ -0,0 +1,287 @@ +// Package rawwalk is raw_expression_tree_walker (src/backend/nodes/ +// nodeFuncs.c, PostgreSQL 17) over the protobuf tree, gated exactly as +// pg_query_raw_tree_walker_supports allows: node types outside the walker's +// switch return false without descending. It drives the summary walks and +// the PL/pgSQL driver's statement collection. +package rawwalk + +import ( + "reflect" + + "github.com/sqlc-dev/oliphant/ast" +) + +// The C walks operate on Node* where a node may be a T_List; the callback is +// invoked for list nodes too (which matters for the truncation walk's depth +// accounting). NodeList and RawStmtList model those list nodes over the +// protobuf tree. +type NodeList []*ast.Node + +type RawStmtList []*ast.RawStmt + +// concrete unwraps an *ast.Node into its inner concrete pointer (the oneof +// member), so callbacks can switch on one representation regardless of +// whether a child arrived generically (*ast.Node) or as a typed field +// (*ast.RangeVar, *ast.FuncCall, ...). +func Concrete(item any) any { + n, ok := item.(*ast.Node) + if !ok { + return item + } + if n == nil || n.Node == nil { + return nil + } + // Every oneof wrapper (ast.Node_SelectStmt, ...) has exactly one field. + return reflect.ValueOf(n.Node).Elem().Field(0).Interface() +} + +// wl boxes a list-valued child the way the C walker passes a List node to the +// callback: NIL (empty) lists short-circuit to "no child". +func wl(list []*ast.Node) any { + if len(list) == 0 { + return nil + } + return NodeList(list) +} + +// isNil reports whether a child slot is empty (NULL in the C tree). +func IsNil(item any) bool { + if item == nil { + return true + } + v := reflect.ValueOf(item) + return v.Kind() == reflect.Pointer && v.IsNil() +} + +// walkChildren is raw_expression_tree_walker_impl (src/backend/nodes/ +// nodeFuncs.c, PostgreSQL 17) gated exactly as pg_query_raw_tree_walker_supports +// allows: node types outside the walker's switch return false without +// descending (the summary C files check the gate before calling the walker; +// folding it into the default arm is equivalent). Child order is the C +// walker's, verbatim — it decides the order of every summary list. +func WalkChildren(item any, cb func(any) bool) bool { + w := func(children ...any) bool { + for _, c := range children { + if IsNil(c) { + continue + } + if cb(c) { + return true + } + } + return false + } + + switch v := Concrete(item).(type) { + case RawStmtList: + for _, rs := range v { + if cb(rs) { + return true + } + } + return false + case NodeList: + for _, n := range v { + if n == nil || n.Node == nil { + continue + } + if cb(n) { + return true + } + } + return false + case *ast.List: + // A List that appears as a node (e.g. the [function, coldeflist] + // sublists of RangeFunction->functions). + for _, n := range v.Items { + if n == nil || n.Node == nil { + continue + } + if cb(n) { + return true + } + } + return false + case *ast.JsonFormat, *ast.SetToDefault, *ast.CurrentOfExpr, + *ast.SQLValueFunction, *ast.Integer, *ast.Float, *ast.Boolean, + *ast.String, *ast.BitString, *ast.ParamRef, *ast.A_Const, *ast.A_Star, + *ast.MergeSupportFunc: + // primitive node types with no subnodes + return false + case *ast.Alias: + // we assume the colnames list isn't interesting + return false + case *ast.RangeVar: + return w(v.Alias) + case *ast.GroupingFunc: + return w(wl(v.Args)) + case *ast.SubLink: + return w(v.Testexpr, v.Subselect) + case *ast.CaseExpr: + if w(v.Arg) { + return true + } + // we assume walker doesn't care about CaseWhens, either + for _, item := range v.Args { + when := item.GetCaseWhen() + if w(when.GetExpr(), when.GetResult()) { + return true + } + } + return w(v.Defresult) + case *ast.RowExpr: + // Assume colnames isn't interesting + return w(wl(v.Args)) + case *ast.CoalesceExpr: + return w(wl(v.Args)) + case *ast.MinMaxExpr: + return w(wl(v.Args)) + case *ast.XmlExpr: + // we assume walker doesn't care about arg_names + return w(wl(v.NamedArgs), wl(v.Args)) + case *ast.JsonReturning: + return w(v.Format) + case *ast.JsonValueExpr: + return w(v.RawExpr, v.FormattedExpr, v.Format) + case *ast.JsonParseExpr: + return w(v.Expr, v.Output) + case *ast.JsonScalarExpr: + return w(v.Expr, v.Output) + case *ast.JsonSerializeExpr: + return w(v.Expr, v.Output) + case *ast.JsonConstructorExpr: + return w(wl(v.Args), v.Func, v.Coercion, v.Returning) + case *ast.JsonIsPredicate: + return w(v.Expr) + case *ast.JsonArgument: + return w(v.Val) + case *ast.JsonFuncExpr: + return w(v.ContextItem, v.Pathspec, wl(v.Passing), v.Output, v.OnEmpty, v.OnError) + case *ast.JsonBehavior: + return w(v.Expr) + case *ast.JsonTable: + return w(v.ContextItem, v.Pathspec, wl(v.Passing), wl(v.Columns), v.OnError) + case *ast.JsonTableColumn: + return w(v.TypeName, v.OnEmpty, v.OnError, wl(v.Columns)) + case *ast.JsonTablePathSpec: + return w(v.String_) + case *ast.NullTest: + return w(v.Arg) + case *ast.BooleanTest: + return w(v.Arg) + case *ast.JoinExpr: + // using list is deemed uninteresting + return w(v.Larg, v.Rarg, v.Quals, v.Alias) + case *ast.IntoClause: + // colNames, options are deemed uninteresting + // viewQuery should be null in raw parsetree, but check it + return w(v.Rel, v.ViewQuery) + case *ast.InsertStmt: + return w(v.Relation, wl(v.Cols), v.SelectStmt, v.OnConflictClause, + wl(v.ReturningList), v.WithClause) + case *ast.DeleteStmt: + return w(v.Relation, wl(v.UsingClause), v.WhereClause, + wl(v.ReturningList), v.WithClause) + case *ast.UpdateStmt: + return w(v.Relation, wl(v.TargetList), v.WhereClause, wl(v.FromClause), + wl(v.ReturningList), v.WithClause) + case *ast.MergeStmt: + return w(v.Relation, v.SourceRelation, v.JoinCondition, + wl(v.MergeWhenClauses), wl(v.ReturningList), v.WithClause) + case *ast.MergeWhenClause: + return w(v.Condition, wl(v.TargetList), wl(v.Values)) + case *ast.SelectStmt: + return w(wl(v.DistinctClause), v.IntoClause, wl(v.TargetList), + wl(v.FromClause), v.WhereClause, wl(v.GroupClause), v.HavingClause, + wl(v.WindowClause), wl(v.ValuesLists), wl(v.SortClause), + v.LimitOffset, v.LimitCount, wl(v.LockingClause), v.WithClause, + v.Larg, v.Rarg) + case *ast.PLAssignStmt: + return w(wl(v.Indirection), v.Val) + case *ast.A_Expr: + // operator name is deemed uninteresting + return w(v.Lexpr, v.Rexpr) + case *ast.BoolExpr: + return w(wl(v.Args)) + case *ast.ColumnRef: + // we assume the fields contain nothing interesting + return false + case *ast.FuncCall: + // function name is deemed uninteresting + return w(wl(v.Args), wl(v.AggOrder), v.AggFilter, v.Over) + case *ast.NamedArgExpr: + return w(v.Arg) + case *ast.A_Indices: + return w(v.Lidx, v.Uidx) + case *ast.A_Indirection: + return w(v.Arg, wl(v.Indirection)) + case *ast.A_ArrayExpr: + return w(wl(v.Elements)) + case *ast.ResTarget: + return w(wl(v.Indirection), v.Val) + case *ast.MultiAssignRef: + return w(v.Source) + case *ast.TypeCast: + return w(v.Arg, v.TypeName) + case *ast.CollateClause: + return w(v.Arg) + case *ast.SortBy: + return w(v.Node) + case *ast.WindowDef: + return w(wl(v.PartitionClause), wl(v.OrderClause), v.StartOffset, v.EndOffset) + case *ast.RangeSubselect: + return w(v.Subquery, v.Alias) + case *ast.RangeFunction: + return w(wl(v.Functions), v.Alias, wl(v.Coldeflist)) + case *ast.RangeTableSample: + // method name is deemed uninteresting + return w(v.Relation, wl(v.Args), v.Repeatable) + case *ast.RangeTableFunc: + return w(v.Docexpr, v.Rowexpr, wl(v.Namespaces), wl(v.Columns), v.Alias) + case *ast.RangeTableFuncCol: + return w(v.Colexpr, v.Coldefexpr) + case *ast.TypeName: + // type name itself is deemed uninteresting + return w(wl(v.Typmods), wl(v.ArrayBounds)) + case *ast.ColumnDef: + // for now, constraints are ignored + return w(v.TypeName, v.RawDefault, v.CollClause) + case *ast.IndexElem: + // collation and opclass names are deemed uninteresting + return w(v.Expr) + case *ast.GroupingSet: + return w(wl(v.Content)) + case *ast.LockingClause: + return w(wl(v.LockedRels)) + case *ast.XmlSerialize: + return w(v.Expr, v.TypeName) + case *ast.WithClause: + return w(wl(v.Ctes)) + case *ast.InferClause: + return w(wl(v.IndexElems), v.WhereClause) + case *ast.OnConflictClause: + return w(v.Infer, wl(v.TargetList), v.WhereClause) + case *ast.CommonTableExpr: + // search_clause and cycle_clause are not interesting here + return w(v.Ctequery) + case *ast.JsonOutput: + return w(v.TypeName, v.Returning) + case *ast.JsonKeyValue: + return w(v.Key, v.Value) + case *ast.JsonObjectConstructor: + return w(v.Output, wl(v.Exprs)) + case *ast.JsonArrayConstructor: + return w(v.Output, wl(v.Exprs)) + case *ast.JsonAggConstructor: + return w(v.Output, wl(v.AggOrder), v.AggFilter, v.Over) + case *ast.JsonObjectAgg: + return w(v.Constructor, v.Arg) + case *ast.JsonArrayAgg: + return w(v.Constructor, v.Arg) + case *ast.JsonArrayQueryConstructor: + return w(v.Output, v.Query) + default: + // Not covered by pg_query_raw_tree_walker_supports: no descent. + return false + } +} diff --git a/internal/reference/README.md b/internal/reference/README.md index 39c21de..94133a3 100644 --- a/internal/reference/README.md +++ b/internal/reference/README.md @@ -1,8 +1,8 @@ # internal/reference — the pinned grammar, for humans These files are **documentation only**: nothing in the build reads them except -the keyword-table generator (`kwlist.h`). They are the source of truth every -`parse*` method's attribution comment points at. +the table generators (`kwlist.h`, `pl_*_kwlist.h`, `plerrcodes.h`). They are +the source of truth every `parse*` method's attribution comment points at. Provenance — PostgreSQL **17.7** source tarball with libpg_query **`17-6.2.2`**'s patches applied (the ones that touch these files): @@ -13,12 +13,27 @@ Provenance — PostgreSQL **17.7** source tarball with libpg_query | `scan.l` | `src/backend/parser/scan.l` | 03 (`yyllocend` token-end tracking), 04 (comments as tokens), 09 (`param_junk` removed) | | `parser.c` | `src/backend/parser/parser.c` | 03, 04 (`base_yylex` lookahead filter — the NOT_LA/NULLS_LA/WITH_LA/WITHOUT_LA/FORMAT_LA merges live here) | | `kwlist.h` | `src/include/parser/kwlist.h` | none (copied from libpg_query's extracted `src/postgres/include/parser/kwlist.h`) | +| `pl_gram.y` | `src/pl/plpgsql/src/pl_gram.y` | 04 (SQL_COMMENT/C_COMMENT token declarations) | +| `pl_scanner.c` | `src/pl/plpgsql/src/pl_scanner.c` | 04 (comment tokens skipped in `internal_yylex`) | +| `pl_reserved_kwlist.h` | `src/pl/plpgsql/src/pl_reserved_kwlist.h` | none (copied from libpg_query's `src/postgres/include/`) | +| `pl_unreserved_kwlist.h` | `src/pl/plpgsql/src/pl_unreserved_kwlist.h` | none (same) | +| `plerrcodes.h` | generated from `src/backend/utils/errcodes.txt` | none (copied from libpg_query's `src/postgres/include/`) | oliphant ports **patched** PostgreSQL, never vanilla: `$1` parameter references are legal in more grammar positions, the lexer tracks token end offsets and emits comments as tokens, and `param_junk` does not exist. The oracle for every golden is the pinned libpg_query build, not upstream PostgreSQL. -To re-derive: download `postgresql-17.7.tar.gz`, extract these four paths, and +For PL/pgSQL, the reference is further from vanilla than for SQL: libpg_query's +`extract_source.rb` **mocks** several pl_comp.c functions in the build the +oracle runs (see `internal/plpgsql`'s attribution comments) — `parse_datatype` +keeps the type text verbatim instead of consulting the catalogs, +`plpgsql_parse_wordtype`/`%ROWTYPE` lookups return NULL, `make_return_stmt` +drops the return-type checks, and `function_parse_error_transpose` always +fails (so compile errors carry a "near line N" context instead of a cursor). +The vendored `src/postgres/src_pl_plpgsql_src_pl_gram.c` at the pin is the +authority where it differs from `pl_gram.y`. + +To re-derive: download `postgresql-17.7.tar.gz`, extract these paths, and apply `patches/01,03,04,09` from the libpg_query tag (hunks touching other files skipped). diff --git a/internal/reference/pl_gram.y b/internal/reference/pl_gram.y new file mode 100644 index 0000000..165b9b0 --- /dev/null +++ b/internal/reference/pl_gram.y @@ -0,0 +1,4173 @@ +%{ +/*------------------------------------------------------------------------- + * + * pl_gram.y - Parser for the PL/pgSQL procedural language + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * src/pl/plpgsql/src/pl_gram.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres.h" + +#include "catalog/namespace.h" +#include "catalog/pg_proc.h" +#include "catalog/pg_type.h" +#include "parser/parser.h" +#include "parser/parse_type.h" +#include "parser/scanner.h" +#include "parser/scansup.h" +#include "utils/builtins.h" + +#include "plpgsql.h" + + +/* Location tracking support --- simpler than bison's default */ +#define YYLLOC_DEFAULT(Current, Rhs, N) \ + do { \ + if (N) \ + (Current) = (Rhs)[1]; \ + else \ + (Current) = (Rhs)[0]; \ + } while (0) + +/* + * Bison doesn't allocate anything that needs to live across parser calls, + * so we can easily have it use palloc instead of malloc. This prevents + * memory leaks if we error out during parsing. + */ +#define YYMALLOC palloc +#define YYFREE pfree + + +typedef struct +{ + int location; +} sql_error_callback_arg; + +#define parser_errposition(pos) plpgsql_scanner_errposition(pos) + +union YYSTYPE; /* need forward reference for tok_is_keyword */ + +static bool tok_is_keyword(int token, union YYSTYPE *lval, + int kw_token, const char *kw_str); +static void word_is_not_variable(PLword *word, int location); +static void cword_is_not_variable(PLcword *cword, int location); +static void current_token_is_not_variable(int tok); +static PLpgSQL_expr *read_sql_construct(int until, + int until2, + int until3, + const char *expected, + RawParseMode parsemode, + bool isexpression, + bool valid_sql, + int *startloc, + int *endtoken); +static PLpgSQL_expr *read_sql_expression(int until, + const char *expected); +static PLpgSQL_expr *read_sql_expression2(int until, int until2, + const char *expected, + int *endtoken); +static PLpgSQL_expr *read_sql_stmt(void); +static PLpgSQL_type *read_datatype(int tok); +static PLpgSQL_stmt *make_execsql_stmt(int firsttoken, int location, + PLword *word); +static PLpgSQL_stmt_fetch *read_fetch_direction(void); +static void complete_direction(PLpgSQL_stmt_fetch *fetch, + bool *check_FROM); +static PLpgSQL_stmt *make_return_stmt(int location); +static PLpgSQL_stmt *make_return_next_stmt(int location); +static PLpgSQL_stmt *make_return_query_stmt(int location); +static PLpgSQL_stmt *make_case(int location, PLpgSQL_expr *t_expr, + List *case_when_list, List *else_stmts); +static char *NameOfDatum(PLwdatum *wdatum); +static void check_assignable(PLpgSQL_datum *datum, int location); +static void read_into_target(PLpgSQL_variable **target, + bool *strict); +static PLpgSQL_row *read_into_scalar_list(char *initial_name, + PLpgSQL_datum *initial_datum, + int initial_location); +static PLpgSQL_row *make_scalar_list1(char *initial_name, + PLpgSQL_datum *initial_datum, + int lineno, int location); +static void check_sql_expr(const char *stmt, + RawParseMode parseMode, int location); +static void plpgsql_sql_error_callback(void *arg); +static PLpgSQL_type *parse_datatype(const char *string, int location); +static void check_labels(const char *start_label, + const char *end_label, + int end_location); +static PLpgSQL_expr *read_cursor_args(PLpgSQL_var *cursor, + int until); +static List *read_raise_options(void); +static void check_raise_parameters(PLpgSQL_stmt_raise *stmt); + +%} + +%expect 0 +%name-prefix="plpgsql_yy" +%locations + +%union +{ + core_YYSTYPE core_yystype; + /* these fields must match core_YYSTYPE: */ + int ival; + char *str; + const char *keyword; + + PLword word; + PLcword cword; + PLwdatum wdatum; + bool boolean; + Oid oid; + struct + { + char *name; + int lineno; + } varname; + struct + { + char *name; + int lineno; + PLpgSQL_datum *scalar; + PLpgSQL_datum *row; + } forvariable; + struct + { + char *label; + int n_initvars; + int *initvarnos; + } declhdr; + struct + { + List *stmts; + char *end_label; + int end_label_location; + } loop_body; + List *list; + PLpgSQL_type *dtype; + PLpgSQL_datum *datum; + PLpgSQL_var *var; + PLpgSQL_expr *expr; + PLpgSQL_stmt *stmt; + PLpgSQL_condition *condition; + PLpgSQL_exception *exception; + PLpgSQL_exception_block *exception_block; + PLpgSQL_nsitem *nsitem; + PLpgSQL_diag_item *diagitem; + PLpgSQL_stmt_fetch *fetch; + PLpgSQL_case_when *casewhen; +} + +%type decl_sect +%type decl_varname +%type decl_const decl_notnull exit_type +%type decl_defval decl_cursor_query +%type decl_datatype +%type decl_collate +%type decl_cursor_args +%type decl_cursor_arglist +%type decl_aliasitem + +%type expr_until_semi +%type expr_until_then expr_until_loop opt_expr_until_when +%type opt_exitcond + +%type cursor_variable +%type decl_cursor_arg +%type for_variable +%type foreach_slice +%type for_control + +%type any_identifier opt_block_label opt_loop_label opt_label +%type option_value + +%type proc_sect stmt_elsifs stmt_else +%type loop_body +%type proc_stmt pl_block +%type stmt_assign stmt_if stmt_loop stmt_while stmt_exit +%type stmt_return stmt_raise stmt_assert stmt_execsql +%type stmt_dynexecute stmt_for stmt_perform stmt_call stmt_getdiag +%type stmt_open stmt_fetch stmt_move stmt_close stmt_null +%type stmt_commit stmt_rollback +%type stmt_case stmt_foreach_a + +%type proc_exceptions +%type exception_sect +%type proc_exception +%type proc_conditions proc_condition + +%type case_when +%type case_when_list opt_case_else + +%type getdiag_area_opt +%type getdiag_list +%type getdiag_list_item +%type getdiag_target +%type getdiag_item + +%type opt_scrollable +%type opt_fetch_direction + +%type opt_transaction_chain + +%type unreserved_keyword + + +/* + * Basic non-keyword token types. These are hard-wired into the core lexer. + * They must be listed first so that their numeric codes do not depend on + * the set of keywords. Keep this list in sync with backend/parser/gram.y! + * + * Some of these are not directly referenced in this file, but they must be + * here anyway. + */ +%token IDENT UIDENT FCONST SCONST USCONST BCONST XCONST Op +%token ICONST PARAM +%token TYPECAST DOT_DOT COLON_EQUALS EQUALS_GREATER +%token LESS_EQUALS GREATER_EQUALS NOT_EQUALS +%token SQL_COMMENT C_COMMENT + +/* + * Other tokens recognized by plpgsql's lexer interface layer (pl_scanner.c). + */ +%token T_WORD /* unrecognized simple identifier */ +%token T_CWORD /* unrecognized composite identifier */ +%token T_DATUM /* a VAR, ROW, REC, or RECFIELD variable */ +%token LESS_LESS +%token GREATER_GREATER + +/* + * Keyword tokens. Some of these are reserved and some are not; + * see pl_scanner.c for info. Be sure unreserved keywords are listed + * in the "unreserved_keyword" production below. + */ +%token K_ABSOLUTE +%token K_ALIAS +%token K_ALL +%token K_AND +%token K_ARRAY +%token K_ASSERT +%token K_BACKWARD +%token K_BEGIN +%token K_BY +%token K_CALL +%token K_CASE +%token K_CHAIN +%token K_CLOSE +%token K_COLLATE +%token K_COLUMN +%token K_COLUMN_NAME +%token K_COMMIT +%token K_CONSTANT +%token K_CONSTRAINT +%token K_CONSTRAINT_NAME +%token K_CONTINUE +%token K_CURRENT +%token K_CURSOR +%token K_DATATYPE +%token K_DEBUG +%token K_DECLARE +%token K_DEFAULT +%token K_DETAIL +%token K_DIAGNOSTICS +%token K_DO +%token K_DUMP +%token K_ELSE +%token K_ELSIF +%token K_END +%token K_ERRCODE +%token K_ERROR +%token K_EXCEPTION +%token K_EXECUTE +%token K_EXIT +%token K_FETCH +%token K_FIRST +%token K_FOR +%token K_FOREACH +%token K_FORWARD +%token K_FROM +%token K_GET +%token K_HINT +%token K_IF +%token K_IMPORT +%token K_IN +%token K_INFO +%token K_INSERT +%token K_INTO +%token K_IS +%token K_LAST +%token K_LOG +%token K_LOOP +%token K_MERGE +%token K_MESSAGE +%token K_MESSAGE_TEXT +%token K_MOVE +%token K_NEXT +%token K_NO +%token K_NOT +%token K_NOTICE +%token K_NULL +%token K_OPEN +%token K_OPTION +%token K_OR +%token K_PERFORM +%token K_PG_CONTEXT +%token K_PG_DATATYPE_NAME +%token K_PG_EXCEPTION_CONTEXT +%token K_PG_EXCEPTION_DETAIL +%token K_PG_EXCEPTION_HINT +%token K_PG_ROUTINE_OID +%token K_PRINT_STRICT_PARAMS +%token K_PRIOR +%token K_QUERY +%token K_RAISE +%token K_RELATIVE +%token K_RETURN +%token K_RETURNED_SQLSTATE +%token K_REVERSE +%token K_ROLLBACK +%token K_ROW_COUNT +%token K_ROWTYPE +%token K_SCHEMA +%token K_SCHEMA_NAME +%token K_SCROLL +%token K_SLICE +%token K_SQLSTATE +%token K_STACKED +%token K_STRICT +%token K_TABLE +%token K_TABLE_NAME +%token K_THEN +%token K_TO +%token K_TYPE +%token K_USE_COLUMN +%token K_USE_VARIABLE +%token K_USING +%token K_VARIABLE_CONFLICT +%token K_WARNING +%token K_WHEN +%token K_WHILE + +%% + +pl_function : comp_options pl_block opt_semi + { + plpgsql_parse_result = (PLpgSQL_stmt_block *) $2; + } + ; + +comp_options : + | comp_options comp_option + ; + +comp_option : '#' K_OPTION K_DUMP + { + plpgsql_DumpExecTree = true; + } + | '#' K_PRINT_STRICT_PARAMS option_value + { + if (strcmp($3, "on") == 0) + plpgsql_curr_compile->print_strict_params = true; + else if (strcmp($3, "off") == 0) + plpgsql_curr_compile->print_strict_params = false; + else + elog(ERROR, "unrecognized print_strict_params option %s", $3); + } + | '#' K_VARIABLE_CONFLICT K_ERROR + { + plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_ERROR; + } + | '#' K_VARIABLE_CONFLICT K_USE_VARIABLE + { + plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_VARIABLE; + } + | '#' K_VARIABLE_CONFLICT K_USE_COLUMN + { + plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_COLUMN; + } + ; + +option_value : T_WORD + { + $$ = $1.ident; + } + | unreserved_keyword + { + $$ = pstrdup($1); + } + +opt_semi : + | ';' + ; + +pl_block : decl_sect K_BEGIN proc_sect exception_sect K_END opt_label + { + PLpgSQL_stmt_block *new; + + new = palloc0(sizeof(PLpgSQL_stmt_block)); + + new->cmd_type = PLPGSQL_STMT_BLOCK; + new->lineno = plpgsql_location_to_lineno(@2); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->label = $1.label; + new->n_initvars = $1.n_initvars; + new->initvarnos = $1.initvarnos; + new->body = $3; + new->exceptions = $4; + + check_labels($1.label, $6, @6); + plpgsql_ns_pop(); + + $$ = (PLpgSQL_stmt *) new; + } + ; + + +decl_sect : opt_block_label + { + /* done with decls, so resume identifier lookup */ + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL; + $$.label = $1; + $$.n_initvars = 0; + $$.initvarnos = NULL; + } + | opt_block_label decl_start + { + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL; + $$.label = $1; + $$.n_initvars = 0; + $$.initvarnos = NULL; + } + | opt_block_label decl_start decl_stmts + { + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL; + $$.label = $1; + /* Remember variables declared in decl_stmts */ + $$.n_initvars = plpgsql_add_initdatums(&($$.initvarnos)); + } + ; + +decl_start : K_DECLARE + { + /* Forget any variables created before block */ + plpgsql_add_initdatums(NULL); + /* + * Disable scanner lookup of identifiers while + * we process the decl_stmts + */ + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_DECLARE; + } + ; + +decl_stmts : decl_stmts decl_stmt + | decl_stmt + ; + +decl_stmt : decl_statement + | K_DECLARE + { + /* We allow useless extra DECLAREs */ + } + | LESS_LESS any_identifier GREATER_GREATER + { + /* + * Throw a helpful error if user tries to put block + * label just before BEGIN, instead of before DECLARE. + */ + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("block label must be placed before DECLARE, not after"), + parser_errposition(@1))); + } + ; + +decl_statement : decl_varname decl_const decl_datatype decl_collate decl_notnull decl_defval + { + PLpgSQL_variable *var; + + /* + * If a collation is supplied, insert it into the + * datatype. We assume decl_datatype always returns + * a freshly built struct not shared with other + * variables. + */ + if (OidIsValid($4)) + { + if (!OidIsValid($3->collation)) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("collations are not supported by type %s", + format_type_be($3->typoid)), + parser_errposition(@4))); + $3->collation = $4; + } + + var = plpgsql_build_variable($1.name, $1.lineno, + $3, true); + var->isconst = $2; + var->notnull = $5; + var->default_val = $6; + + /* + * The combination of NOT NULL without an initializer + * can't work, so let's reject it at compile time. + */ + if (var->notnull && var->default_val == NULL) + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("variable \"%s\" must have a default value, since it's declared NOT NULL", + var->refname), + parser_errposition(@5))); + } + | decl_varname K_ALIAS K_FOR decl_aliasitem ';' + { + plpgsql_ns_additem($4->itemtype, + $4->itemno, $1.name); + } + | decl_varname opt_scrollable K_CURSOR + { plpgsql_ns_push($1.name, PLPGSQL_LABEL_OTHER); } + decl_cursor_args decl_is_for decl_cursor_query + { + PLpgSQL_var *new; + + /* pop local namespace for cursor args */ + plpgsql_ns_pop(); + + new = (PLpgSQL_var *) + plpgsql_build_variable($1.name, $1.lineno, + plpgsql_build_datatype(REFCURSOROID, + -1, + InvalidOid, + NULL), + true); + + new->cursor_explicit_expr = $7; + if ($5 == NULL) + new->cursor_explicit_argrow = -1; + else + new->cursor_explicit_argrow = $5->dno; + new->cursor_options = CURSOR_OPT_FAST_PLAN | $2; + } + ; + +opt_scrollable : + { + $$ = 0; + } + | K_NO K_SCROLL + { + $$ = CURSOR_OPT_NO_SCROLL; + } + | K_SCROLL + { + $$ = CURSOR_OPT_SCROLL; + } + ; + +decl_cursor_query : + { + $$ = read_sql_stmt(); + } + ; + +decl_cursor_args : + { + $$ = NULL; + } + | '(' decl_cursor_arglist ')' + { + PLpgSQL_row *new; + int i; + ListCell *l; + + new = palloc0(sizeof(PLpgSQL_row)); + new->dtype = PLPGSQL_DTYPE_ROW; + new->refname = "(unnamed row)"; + new->lineno = plpgsql_location_to_lineno(@1); + new->rowtupdesc = NULL; + new->nfields = list_length($2); + new->fieldnames = palloc(new->nfields * sizeof(char *)); + new->varnos = palloc(new->nfields * sizeof(int)); + + i = 0; + foreach (l, $2) + { + PLpgSQL_variable *arg = (PLpgSQL_variable *) lfirst(l); + Assert(!arg->isconst); + new->fieldnames[i] = arg->refname; + new->varnos[i] = arg->dno; + i++; + } + list_free($2); + + plpgsql_adddatum((PLpgSQL_datum *) new); + $$ = (PLpgSQL_datum *) new; + } + ; + +decl_cursor_arglist : decl_cursor_arg + { + $$ = list_make1($1); + } + | decl_cursor_arglist ',' decl_cursor_arg + { + $$ = lappend($1, $3); + } + ; + +decl_cursor_arg : decl_varname decl_datatype + { + $$ = (PLpgSQL_datum *) + plpgsql_build_variable($1.name, $1.lineno, + $2, true); + } + ; + +decl_is_for : K_IS | /* Oracle */ + K_FOR; /* SQL standard */ + +decl_aliasitem : T_WORD + { + PLpgSQL_nsitem *nsi; + + nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false, + $1.ident, NULL, NULL, + NULL); + if (nsi == NULL) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("variable \"%s\" does not exist", + $1.ident), + parser_errposition(@1))); + $$ = nsi; + } + | unreserved_keyword + { + PLpgSQL_nsitem *nsi; + + nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false, + $1, NULL, NULL, + NULL); + if (nsi == NULL) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("variable \"%s\" does not exist", + $1), + parser_errposition(@1))); + $$ = nsi; + } + | T_CWORD + { + PLpgSQL_nsitem *nsi; + + if (list_length($1.idents) == 2) + nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false, + strVal(linitial($1.idents)), + strVal(lsecond($1.idents)), + NULL, + NULL); + else if (list_length($1.idents) == 3) + nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false, + strVal(linitial($1.idents)), + strVal(lsecond($1.idents)), + strVal(lthird($1.idents)), + NULL); + else + nsi = NULL; + if (nsi == NULL) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("variable \"%s\" does not exist", + NameListToString($1.idents)), + parser_errposition(@1))); + $$ = nsi; + } + ; + +decl_varname : T_WORD + { + $$.name = $1.ident; + $$.lineno = plpgsql_location_to_lineno(@1); + /* + * Check to make sure name isn't already declared + * in the current block. + */ + if (plpgsql_ns_lookup(plpgsql_ns_top(), true, + $1.ident, NULL, NULL, + NULL) != NULL) + yyerror("duplicate declaration"); + + if (plpgsql_curr_compile->extra_warnings & PLPGSQL_XCHECK_SHADOWVAR || + plpgsql_curr_compile->extra_errors & PLPGSQL_XCHECK_SHADOWVAR) + { + PLpgSQL_nsitem *nsi; + nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false, + $1.ident, NULL, NULL, NULL); + if (nsi != NULL) + ereport(plpgsql_curr_compile->extra_errors & PLPGSQL_XCHECK_SHADOWVAR ? ERROR : WARNING, + (errcode(ERRCODE_DUPLICATE_ALIAS), + errmsg("variable \"%s\" shadows a previously defined variable", + $1.ident), + parser_errposition(@1))); + } + + } + | unreserved_keyword + { + $$.name = pstrdup($1); + $$.lineno = plpgsql_location_to_lineno(@1); + /* + * Check to make sure name isn't already declared + * in the current block. + */ + if (plpgsql_ns_lookup(plpgsql_ns_top(), true, + $1, NULL, NULL, + NULL) != NULL) + yyerror("duplicate declaration"); + + if (plpgsql_curr_compile->extra_warnings & PLPGSQL_XCHECK_SHADOWVAR || + plpgsql_curr_compile->extra_errors & PLPGSQL_XCHECK_SHADOWVAR) + { + PLpgSQL_nsitem *nsi; + nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false, + $1, NULL, NULL, NULL); + if (nsi != NULL) + ereport(plpgsql_curr_compile->extra_errors & PLPGSQL_XCHECK_SHADOWVAR ? ERROR : WARNING, + (errcode(ERRCODE_DUPLICATE_ALIAS), + errmsg("variable \"%s\" shadows a previously defined variable", + $1), + parser_errposition(@1))); + } + + } + ; + +decl_const : + { $$ = false; } + | K_CONSTANT + { $$ = true; } + ; + +decl_datatype : + { + /* + * If there's a lookahead token, read_datatype() will + * consume it, and then we must tell bison to forget + * it. + */ + $$ = read_datatype(yychar); + yyclearin; + } + ; + +decl_collate : + { $$ = InvalidOid; } + | K_COLLATE T_WORD + { + $$ = get_collation_oid(list_make1(makeString($2.ident)), + false); + } + | K_COLLATE unreserved_keyword + { + $$ = get_collation_oid(list_make1(makeString(pstrdup($2))), + false); + } + | K_COLLATE T_CWORD + { + $$ = get_collation_oid($2.idents, false); + } + ; + +decl_notnull : + { $$ = false; } + | K_NOT K_NULL + { $$ = true; } + ; + +decl_defval : ';' + { $$ = NULL; } + | decl_defkey + { + $$ = read_sql_expression(';', ";"); + } + ; + +decl_defkey : assign_operator + | K_DEFAULT + ; + +/* + * Ada-based PL/SQL uses := for assignment and variable defaults, while + * the SQL standard uses equals for these cases and for GET + * DIAGNOSTICS, so we support both. FOR and OPEN only support :=. + */ +assign_operator : '=' + | COLON_EQUALS + ; + +proc_sect : + { $$ = NIL; } + | proc_sect proc_stmt + { + /* don't bother linking null statements into list */ + if ($2 == NULL) + $$ = $1; + else + $$ = lappend($1, $2); + } + ; + +proc_stmt : pl_block ';' + { $$ = $1; } + | stmt_assign + { $$ = $1; } + | stmt_if + { $$ = $1; } + | stmt_case + { $$ = $1; } + | stmt_loop + { $$ = $1; } + | stmt_while + { $$ = $1; } + | stmt_for + { $$ = $1; } + | stmt_foreach_a + { $$ = $1; } + | stmt_exit + { $$ = $1; } + | stmt_return + { $$ = $1; } + | stmt_raise + { $$ = $1; } + | stmt_assert + { $$ = $1; } + | stmt_execsql + { $$ = $1; } + | stmt_dynexecute + { $$ = $1; } + | stmt_perform + { $$ = $1; } + | stmt_call + { $$ = $1; } + | stmt_getdiag + { $$ = $1; } + | stmt_open + { $$ = $1; } + | stmt_fetch + { $$ = $1; } + | stmt_move + { $$ = $1; } + | stmt_close + { $$ = $1; } + | stmt_null + { $$ = $1; } + | stmt_commit + { $$ = $1; } + | stmt_rollback + { $$ = $1; } + ; + +stmt_perform : K_PERFORM + { + PLpgSQL_stmt_perform *new; + int startloc; + + new = palloc0(sizeof(PLpgSQL_stmt_perform)); + new->cmd_type = PLPGSQL_STMT_PERFORM; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + plpgsql_push_back_token(K_PERFORM); + + /* + * Since PERFORM isn't legal SQL, we have to cheat to + * the extent of substituting "SELECT" for "PERFORM" + * in the parsed text. It does not seem worth + * inventing a separate parse mode for this one case. + * We can't do syntax-checking until after we make the + * substitution. + */ + new->expr = read_sql_construct(';', 0, 0, ";", + RAW_PARSE_DEFAULT, + false, false, + &startloc, NULL); + /* overwrite "perform" ... */ + memcpy(new->expr->query, " SELECT", 7); + /* left-justify to get rid of the leading space */ + memmove(new->expr->query, new->expr->query + 1, + strlen(new->expr->query)); + /* offset syntax error position to account for that */ + check_sql_expr(new->expr->query, new->expr->parseMode, + startloc + 1); + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_call : K_CALL + { + PLpgSQL_stmt_call *new; + + new = palloc0(sizeof(PLpgSQL_stmt_call)); + new->cmd_type = PLPGSQL_STMT_CALL; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + plpgsql_push_back_token(K_CALL); + new->expr = read_sql_stmt(); + new->is_call = true; + + /* Remember we may need a procedure resource owner */ + plpgsql_curr_compile->requires_procedure_resowner = true; + + $$ = (PLpgSQL_stmt *) new; + + } + | K_DO + { + /* use the same structures as for CALL, for simplicity */ + PLpgSQL_stmt_call *new; + + new = palloc0(sizeof(PLpgSQL_stmt_call)); + new->cmd_type = PLPGSQL_STMT_CALL; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + plpgsql_push_back_token(K_DO); + new->expr = read_sql_stmt(); + new->is_call = false; + + /* Remember we may need a procedure resource owner */ + plpgsql_curr_compile->requires_procedure_resowner = true; + + $$ = (PLpgSQL_stmt *) new; + + } + ; + +stmt_assign : T_DATUM + { + PLpgSQL_stmt_assign *new; + RawParseMode pmode; + + /* see how many names identify the datum */ + switch ($1.ident ? 1 : list_length($1.idents)) + { + case 1: + pmode = RAW_PARSE_PLPGSQL_ASSIGN1; + break; + case 2: + pmode = RAW_PARSE_PLPGSQL_ASSIGN2; + break; + case 3: + pmode = RAW_PARSE_PLPGSQL_ASSIGN3; + break; + default: + elog(ERROR, "unexpected number of names"); + pmode = 0; /* keep compiler quiet */ + } + + check_assignable($1.datum, @1); + new = palloc0(sizeof(PLpgSQL_stmt_assign)); + new->cmd_type = PLPGSQL_STMT_ASSIGN; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->varno = $1.datum->dno; + /* Push back the head name to include it in the stmt */ + plpgsql_push_back_token(T_DATUM); + new->expr = read_sql_construct(';', 0, 0, ";", + pmode, + false, true, + NULL, NULL); + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';' + { + PLpgSQL_stmt_getdiag *new; + ListCell *lc; + + new = palloc0(sizeof(PLpgSQL_stmt_getdiag)); + new->cmd_type = PLPGSQL_STMT_GETDIAG; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->is_stacked = $2; + new->diag_items = $4; + + /* + * Check information items are valid for area option. + */ + foreach(lc, new->diag_items) + { + PLpgSQL_diag_item *ditem = (PLpgSQL_diag_item *) lfirst(lc); + + switch (ditem->kind) + { + /* these fields are disallowed in stacked case */ + case PLPGSQL_GETDIAG_ROW_COUNT: + case PLPGSQL_GETDIAG_ROUTINE_OID: + if (new->is_stacked) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("diagnostics item %s is not allowed in GET STACKED DIAGNOSTICS", + plpgsql_getdiag_kindname(ditem->kind)), + parser_errposition(@1))); + break; + /* these fields are disallowed in current case */ + case PLPGSQL_GETDIAG_ERROR_CONTEXT: + case PLPGSQL_GETDIAG_ERROR_DETAIL: + case PLPGSQL_GETDIAG_ERROR_HINT: + case PLPGSQL_GETDIAG_RETURNED_SQLSTATE: + case PLPGSQL_GETDIAG_COLUMN_NAME: + case PLPGSQL_GETDIAG_CONSTRAINT_NAME: + case PLPGSQL_GETDIAG_DATATYPE_NAME: + case PLPGSQL_GETDIAG_MESSAGE_TEXT: + case PLPGSQL_GETDIAG_TABLE_NAME: + case PLPGSQL_GETDIAG_SCHEMA_NAME: + if (!new->is_stacked) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("diagnostics item %s is not allowed in GET CURRENT DIAGNOSTICS", + plpgsql_getdiag_kindname(ditem->kind)), + parser_errposition(@1))); + break; + /* these fields are allowed in either case */ + case PLPGSQL_GETDIAG_CONTEXT: + break; + default: + elog(ERROR, "unrecognized diagnostic item kind: %d", + ditem->kind); + break; + } + } + + $$ = (PLpgSQL_stmt *) new; + } + ; + +getdiag_area_opt : + { + $$ = false; + } + | K_CURRENT + { + $$ = false; + } + | K_STACKED + { + $$ = true; + } + ; + +getdiag_list : getdiag_list ',' getdiag_list_item + { + $$ = lappend($1, $3); + } + | getdiag_list_item + { + $$ = list_make1($1); + } + ; + +getdiag_list_item : getdiag_target assign_operator getdiag_item + { + PLpgSQL_diag_item *new; + + new = palloc(sizeof(PLpgSQL_diag_item)); + new->target = $1->dno; + new->kind = $3; + + $$ = new; + } + ; + +getdiag_item : + { + int tok = yylex(); + + if (tok_is_keyword(tok, &yylval, + K_ROW_COUNT, "row_count")) + $$ = PLPGSQL_GETDIAG_ROW_COUNT; + else if (tok_is_keyword(tok, &yylval, + K_PG_ROUTINE_OID, "pg_routine_oid")) + $$ = PLPGSQL_GETDIAG_ROUTINE_OID; + else if (tok_is_keyword(tok, &yylval, + K_PG_CONTEXT, "pg_context")) + $$ = PLPGSQL_GETDIAG_CONTEXT; + else if (tok_is_keyword(tok, &yylval, + K_PG_EXCEPTION_DETAIL, "pg_exception_detail")) + $$ = PLPGSQL_GETDIAG_ERROR_DETAIL; + else if (tok_is_keyword(tok, &yylval, + K_PG_EXCEPTION_HINT, "pg_exception_hint")) + $$ = PLPGSQL_GETDIAG_ERROR_HINT; + else if (tok_is_keyword(tok, &yylval, + K_PG_EXCEPTION_CONTEXT, "pg_exception_context")) + $$ = PLPGSQL_GETDIAG_ERROR_CONTEXT; + else if (tok_is_keyword(tok, &yylval, + K_COLUMN_NAME, "column_name")) + $$ = PLPGSQL_GETDIAG_COLUMN_NAME; + else if (tok_is_keyword(tok, &yylval, + K_CONSTRAINT_NAME, "constraint_name")) + $$ = PLPGSQL_GETDIAG_CONSTRAINT_NAME; + else if (tok_is_keyword(tok, &yylval, + K_PG_DATATYPE_NAME, "pg_datatype_name")) + $$ = PLPGSQL_GETDIAG_DATATYPE_NAME; + else if (tok_is_keyword(tok, &yylval, + K_MESSAGE_TEXT, "message_text")) + $$ = PLPGSQL_GETDIAG_MESSAGE_TEXT; + else if (tok_is_keyword(tok, &yylval, + K_TABLE_NAME, "table_name")) + $$ = PLPGSQL_GETDIAG_TABLE_NAME; + else if (tok_is_keyword(tok, &yylval, + K_SCHEMA_NAME, "schema_name")) + $$ = PLPGSQL_GETDIAG_SCHEMA_NAME; + else if (tok_is_keyword(tok, &yylval, + K_RETURNED_SQLSTATE, "returned_sqlstate")) + $$ = PLPGSQL_GETDIAG_RETURNED_SQLSTATE; + else + yyerror("unrecognized GET DIAGNOSTICS item"); + } + ; + +getdiag_target : T_DATUM + { + /* + * In principle we should support a getdiag_target + * that is an array element, but for now we don't, so + * just throw an error if next token is '['. + */ + if ($1.datum->dtype == PLPGSQL_DTYPE_ROW || + $1.datum->dtype == PLPGSQL_DTYPE_REC || + plpgsql_peek() == '[') + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("\"%s\" is not a scalar variable", + NameOfDatum(&($1))), + parser_errposition(@1))); + check_assignable($1.datum, @1); + $$ = $1.datum; + } + | T_WORD + { + /* just to give a better message than "syntax error" */ + word_is_not_variable(&($1), @1); + } + | T_CWORD + { + /* just to give a better message than "syntax error" */ + cword_is_not_variable(&($1), @1); + } + ; + +stmt_if : K_IF expr_until_then proc_sect stmt_elsifs stmt_else K_END K_IF ';' + { + PLpgSQL_stmt_if *new; + + new = palloc0(sizeof(PLpgSQL_stmt_if)); + new->cmd_type = PLPGSQL_STMT_IF; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->cond = $2; + new->then_body = $3; + new->elsif_list = $4; + new->else_body = $5; + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_elsifs : + { + $$ = NIL; + } + | stmt_elsifs K_ELSIF expr_until_then proc_sect + { + PLpgSQL_if_elsif *new; + + new = palloc0(sizeof(PLpgSQL_if_elsif)); + new->lineno = plpgsql_location_to_lineno(@2); + new->cond = $3; + new->stmts = $4; + + $$ = lappend($1, new); + } + ; + +stmt_else : + { + $$ = NIL; + } + | K_ELSE proc_sect + { + $$ = $2; + } + ; + +stmt_case : K_CASE opt_expr_until_when case_when_list opt_case_else K_END K_CASE ';' + { + $$ = make_case(@1, $2, $3, $4); + } + ; + +opt_expr_until_when : + { + PLpgSQL_expr *expr = NULL; + int tok = yylex(); + + if (tok != K_WHEN) + { + plpgsql_push_back_token(tok); + expr = read_sql_expression(K_WHEN, "WHEN"); + } + plpgsql_push_back_token(K_WHEN); + $$ = expr; + } + ; + +case_when_list : case_when_list case_when + { + $$ = lappend($1, $2); + } + | case_when + { + $$ = list_make1($1); + } + ; + +case_when : K_WHEN expr_until_then proc_sect + { + PLpgSQL_case_when *new = palloc(sizeof(PLpgSQL_case_when)); + + new->lineno = plpgsql_location_to_lineno(@1); + new->expr = $2; + new->stmts = $3; + $$ = new; + } + ; + +opt_case_else : + { + $$ = NIL; + } + | K_ELSE proc_sect + { + /* + * proc_sect could return an empty list, but we + * must distinguish that from not having ELSE at all. + * Simplest fix is to return a list with one NULL + * pointer, which make_case() must take care of. + */ + if ($2 != NIL) + $$ = $2; + else + $$ = list_make1(NULL); + } + ; + +stmt_loop : opt_loop_label K_LOOP loop_body + { + PLpgSQL_stmt_loop *new; + + new = palloc0(sizeof(PLpgSQL_stmt_loop)); + new->cmd_type = PLPGSQL_STMT_LOOP; + new->lineno = plpgsql_location_to_lineno(@2); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->label = $1; + new->body = $3.stmts; + + check_labels($1, $3.end_label, $3.end_label_location); + plpgsql_ns_pop(); + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_while : opt_loop_label K_WHILE expr_until_loop loop_body + { + PLpgSQL_stmt_while *new; + + new = palloc0(sizeof(PLpgSQL_stmt_while)); + new->cmd_type = PLPGSQL_STMT_WHILE; + new->lineno = plpgsql_location_to_lineno(@2); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->label = $1; + new->cond = $3; + new->body = $4.stmts; + + check_labels($1, $4.end_label, $4.end_label_location); + plpgsql_ns_pop(); + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_for : opt_loop_label K_FOR for_control loop_body + { + /* This runs after we've scanned the loop body */ + if ($3->cmd_type == PLPGSQL_STMT_FORI) + { + PLpgSQL_stmt_fori *new; + + new = (PLpgSQL_stmt_fori *) $3; + new->lineno = plpgsql_location_to_lineno(@2); + new->label = $1; + new->body = $4.stmts; + $$ = (PLpgSQL_stmt *) new; + } + else + { + PLpgSQL_stmt_forq *new; + + Assert($3->cmd_type == PLPGSQL_STMT_FORS || + $3->cmd_type == PLPGSQL_STMT_FORC || + $3->cmd_type == PLPGSQL_STMT_DYNFORS); + /* forq is the common supertype of all three */ + new = (PLpgSQL_stmt_forq *) $3; + new->lineno = plpgsql_location_to_lineno(@2); + new->label = $1; + new->body = $4.stmts; + $$ = (PLpgSQL_stmt *) new; + } + + check_labels($1, $4.end_label, $4.end_label_location); + /* close namespace started in opt_loop_label */ + plpgsql_ns_pop(); + } + ; + +for_control : for_variable K_IN + { + int tok = yylex(); + int tokloc = yylloc; + + if (tok == K_EXECUTE) + { + /* EXECUTE means it's a dynamic FOR loop */ + PLpgSQL_stmt_dynfors *new; + PLpgSQL_expr *expr; + int term; + + expr = read_sql_expression2(K_LOOP, K_USING, + "LOOP or USING", + &term); + + new = palloc0(sizeof(PLpgSQL_stmt_dynfors)); + new->cmd_type = PLPGSQL_STMT_DYNFORS; + new->stmtid = ++plpgsql_curr_compile->nstatements; + if ($1.row) + { + new->var = (PLpgSQL_variable *) $1.row; + check_assignable($1.row, @1); + } + else if ($1.scalar) + { + /* convert single scalar to list */ + new->var = (PLpgSQL_variable *) + make_scalar_list1($1.name, $1.scalar, + $1.lineno, @1); + /* make_scalar_list1 did check_assignable */ + } + else + { + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("loop variable of loop over rows must be a record variable or list of scalar variables"), + parser_errposition(@1))); + } + new->query = expr; + + if (term == K_USING) + { + do + { + expr = read_sql_expression2(',', K_LOOP, + ", or LOOP", + &term); + new->params = lappend(new->params, expr); + } while (term == ','); + } + + $$ = (PLpgSQL_stmt *) new; + } + else if (tok == T_DATUM && + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR && + ((PLpgSQL_var *) yylval.wdatum.datum)->datatype->typoid == REFCURSOROID) + { + /* It's FOR var IN cursor */ + PLpgSQL_stmt_forc *new; + PLpgSQL_var *cursor = (PLpgSQL_var *) yylval.wdatum.datum; + + new = (PLpgSQL_stmt_forc *) palloc0(sizeof(PLpgSQL_stmt_forc)); + new->cmd_type = PLPGSQL_STMT_FORC; + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->curvar = cursor->dno; + + /* Should have had a single variable name */ + if ($1.scalar && $1.row) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cursor FOR loop must have only one target variable"), + parser_errposition(@1))); + + /* can't use an unbound cursor this way */ + if (cursor->cursor_explicit_expr == NULL) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cursor FOR loop must use a bound cursor variable"), + parser_errposition(tokloc))); + + /* collect cursor's parameters if any */ + new->argquery = read_cursor_args(cursor, + K_LOOP); + + /* create loop's private RECORD variable */ + new->var = (PLpgSQL_variable *) + plpgsql_build_record($1.name, + $1.lineno, + NULL, + RECORDOID, + true); + + $$ = (PLpgSQL_stmt *) new; + } + else + { + PLpgSQL_expr *expr1; + int expr1loc; + bool reverse = false; + + /* + * We have to distinguish between two + * alternatives: FOR var IN a .. b and FOR + * var IN query. Unfortunately this is + * tricky, since the query in the second + * form needn't start with a SELECT + * keyword. We use the ugly hack of + * looking for two periods after the first + * token. We also check for the REVERSE + * keyword, which means it must be an + * integer loop. + */ + if (tok_is_keyword(tok, &yylval, + K_REVERSE, "reverse")) + reverse = true; + else + plpgsql_push_back_token(tok); + + /* + * Read tokens until we see either a ".." + * or a LOOP. The text we read may be either + * an expression or a whole SQL statement, so + * we need to invoke read_sql_construct directly, + * and tell it not to check syntax yet. + */ + expr1 = read_sql_construct(DOT_DOT, + K_LOOP, + 0, + "LOOP", + RAW_PARSE_DEFAULT, + true, + false, + &expr1loc, + &tok); + + if (tok == DOT_DOT) + { + /* Saw "..", so it must be an integer loop */ + PLpgSQL_expr *expr2; + PLpgSQL_expr *expr_by; + PLpgSQL_var *fvar; + PLpgSQL_stmt_fori *new; + + /* + * Relabel first expression as an expression; + * then we can check its syntax. + */ + expr1->parseMode = RAW_PARSE_PLPGSQL_EXPR; + check_sql_expr(expr1->query, expr1->parseMode, + expr1loc); + + /* Read and check the second one */ + expr2 = read_sql_expression2(K_LOOP, K_BY, + "LOOP", + &tok); + + /* Get the BY clause if any */ + if (tok == K_BY) + expr_by = read_sql_expression(K_LOOP, + "LOOP"); + else + expr_by = NULL; + + /* Should have had a single variable name */ + if ($1.scalar && $1.row) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("integer FOR loop must have only one target variable"), + parser_errposition(@1))); + + /* create loop's private variable */ + fvar = (PLpgSQL_var *) + plpgsql_build_variable($1.name, + $1.lineno, + plpgsql_build_datatype(INT4OID, + -1, + InvalidOid, + NULL), + true); + + new = palloc0(sizeof(PLpgSQL_stmt_fori)); + new->cmd_type = PLPGSQL_STMT_FORI; + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->var = fvar; + new->reverse = reverse; + new->lower = expr1; + new->upper = expr2; + new->step = expr_by; + + $$ = (PLpgSQL_stmt *) new; + } + else + { + /* + * No "..", so it must be a query loop. + */ + PLpgSQL_stmt_fors *new; + + if (reverse) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cannot specify REVERSE in query FOR loop"), + parser_errposition(tokloc))); + + /* Check syntax as a regular query */ + check_sql_expr(expr1->query, expr1->parseMode, + expr1loc); + + new = palloc0(sizeof(PLpgSQL_stmt_fors)); + new->cmd_type = PLPGSQL_STMT_FORS; + new->stmtid = ++plpgsql_curr_compile->nstatements; + if ($1.row) + { + new->var = (PLpgSQL_variable *) $1.row; + check_assignable($1.row, @1); + } + else if ($1.scalar) + { + /* convert single scalar to list */ + new->var = (PLpgSQL_variable *) + make_scalar_list1($1.name, $1.scalar, + $1.lineno, @1); + /* make_scalar_list1 did check_assignable */ + } + else + { + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("loop variable of loop over rows must be a record variable or list of scalar variables"), + parser_errposition(@1))); + } + + new->query = expr1; + $$ = (PLpgSQL_stmt *) new; + } + } + } + ; + +/* + * Processing the for_variable is tricky because we don't yet know if the + * FOR is an integer FOR loop or a loop over query results. In the former + * case, the variable is just a name that we must instantiate as a loop + * local variable, regardless of any other definition it might have. + * Therefore, we always save the actual identifier into $$.name where it + * can be used for that case. We also save the outer-variable definition, + * if any, because that's what we need for the loop-over-query case. Note + * that we must NOT apply check_assignable() or any other semantic check + * until we know what's what. + * + * However, if we see a comma-separated list of names, we know that it + * can't be an integer FOR loop and so it's OK to check the variables + * immediately. In particular, for T_WORD followed by comma, we should + * complain that the name is not known rather than say it's a syntax error. + * Note that the non-error result of this case sets *both* $$.scalar and + * $$.row; see the for_control production. + */ +for_variable : T_DATUM + { + $$.name = NameOfDatum(&($1)); + $$.lineno = plpgsql_location_to_lineno(@1); + if ($1.datum->dtype == PLPGSQL_DTYPE_ROW || + $1.datum->dtype == PLPGSQL_DTYPE_REC) + { + $$.scalar = NULL; + $$.row = $1.datum; + } + else + { + int tok; + + $$.scalar = $1.datum; + $$.row = NULL; + /* check for comma-separated list */ + tok = yylex(); + plpgsql_push_back_token(tok); + if (tok == ',') + $$.row = (PLpgSQL_datum *) + read_into_scalar_list($$.name, + $$.scalar, + @1); + } + } + | T_WORD + { + int tok; + + $$.name = $1.ident; + $$.lineno = plpgsql_location_to_lineno(@1); + $$.scalar = NULL; + $$.row = NULL; + /* check for comma-separated list */ + tok = yylex(); + plpgsql_push_back_token(tok); + if (tok == ',') + word_is_not_variable(&($1), @1); + } + | T_CWORD + { + /* just to give a better message than "syntax error" */ + cword_is_not_variable(&($1), @1); + } + ; + +stmt_foreach_a : opt_loop_label K_FOREACH for_variable foreach_slice K_IN K_ARRAY expr_until_loop loop_body + { + PLpgSQL_stmt_foreach_a *new; + + new = palloc0(sizeof(PLpgSQL_stmt_foreach_a)); + new->cmd_type = PLPGSQL_STMT_FOREACH_A; + new->lineno = plpgsql_location_to_lineno(@2); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->label = $1; + new->slice = $4; + new->expr = $7; + new->body = $8.stmts; + + if ($3.row) + { + new->varno = $3.row->dno; + check_assignable($3.row, @3); + } + else if ($3.scalar) + { + new->varno = $3.scalar->dno; + check_assignable($3.scalar, @3); + } + else + { + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("loop variable of FOREACH must be a known variable or list of variables"), + parser_errposition(@3))); + } + + check_labels($1, $8.end_label, $8.end_label_location); + plpgsql_ns_pop(); + + $$ = (PLpgSQL_stmt *) new; + } + ; + +foreach_slice : + { + $$ = 0; + } + | K_SLICE ICONST + { + $$ = $2; + } + ; + +stmt_exit : exit_type opt_label opt_exitcond + { + PLpgSQL_stmt_exit *new; + + new = palloc0(sizeof(PLpgSQL_stmt_exit)); + new->cmd_type = PLPGSQL_STMT_EXIT; + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->is_exit = $1; + new->lineno = plpgsql_location_to_lineno(@1); + new->label = $2; + new->cond = $3; + + if ($2) + { + /* We have a label, so verify it exists */ + PLpgSQL_nsitem *label; + + label = plpgsql_ns_lookup_label(plpgsql_ns_top(), $2); + if (label == NULL) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("there is no label \"%s\" " + "attached to any block or loop enclosing this statement", + $2), + parser_errposition(@2))); + /* CONTINUE only allows loop labels */ + if (label->itemno != PLPGSQL_LABEL_LOOP && !new->is_exit) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("block label \"%s\" cannot be used in CONTINUE", + $2), + parser_errposition(@2))); + } + else + { + /* + * No label, so make sure there is some loop (an + * unlabeled EXIT does not match a block, so this + * is the same test for both EXIT and CONTINUE) + */ + if (plpgsql_ns_find_nearest_loop(plpgsql_ns_top()) == NULL) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + new->is_exit ? + errmsg("EXIT cannot be used outside a loop, unless it has a label") : + errmsg("CONTINUE cannot be used outside a loop"), + parser_errposition(@1))); + } + + $$ = (PLpgSQL_stmt *) new; + } + ; + +exit_type : K_EXIT + { + $$ = true; + } + | K_CONTINUE + { + $$ = false; + } + ; + +stmt_return : K_RETURN + { + int tok; + + tok = yylex(); + if (tok == 0) + yyerror("unexpected end of function definition"); + + if (tok_is_keyword(tok, &yylval, + K_NEXT, "next")) + { + $$ = make_return_next_stmt(@1); + } + else if (tok_is_keyword(tok, &yylval, + K_QUERY, "query")) + { + $$ = make_return_query_stmt(@1); + } + else + { + plpgsql_push_back_token(tok); + $$ = make_return_stmt(@1); + } + } + ; + +stmt_raise : K_RAISE + { + PLpgSQL_stmt_raise *new; + int tok; + + new = palloc(sizeof(PLpgSQL_stmt_raise)); + + new->cmd_type = PLPGSQL_STMT_RAISE; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->elog_level = ERROR; /* default */ + new->condname = NULL; + new->message = NULL; + new->params = NIL; + new->options = NIL; + + tok = yylex(); + if (tok == 0) + yyerror("unexpected end of function definition"); + + /* + * We could have just RAISE, meaning to re-throw + * the current error. + */ + if (tok != ';') + { + /* + * First is an optional elog severity level. + */ + if (tok_is_keyword(tok, &yylval, + K_EXCEPTION, "exception")) + { + new->elog_level = ERROR; + tok = yylex(); + } + else if (tok_is_keyword(tok, &yylval, + K_WARNING, "warning")) + { + new->elog_level = WARNING; + tok = yylex(); + } + else if (tok_is_keyword(tok, &yylval, + K_NOTICE, "notice")) + { + new->elog_level = NOTICE; + tok = yylex(); + } + else if (tok_is_keyword(tok, &yylval, + K_INFO, "info")) + { + new->elog_level = INFO; + tok = yylex(); + } + else if (tok_is_keyword(tok, &yylval, + K_LOG, "log")) + { + new->elog_level = LOG; + tok = yylex(); + } + else if (tok_is_keyword(tok, &yylval, + K_DEBUG, "debug")) + { + new->elog_level = DEBUG1; + tok = yylex(); + } + if (tok == 0) + yyerror("unexpected end of function definition"); + + /* + * Next we can have a condition name, or + * equivalently SQLSTATE 'xxxxx', or a string + * literal that is the old-style message format, + * or USING to start the option list immediately. + */ + if (tok == SCONST) + { + /* old style message and parameters */ + new->message = yylval.str; + /* + * We expect either a semi-colon, which + * indicates no parameters, or a comma that + * begins the list of parameter expressions, + * or USING to begin the options list. + */ + tok = yylex(); + if (tok != ',' && tok != ';' && tok != K_USING) + yyerror("syntax error"); + + while (tok == ',') + { + PLpgSQL_expr *expr; + + expr = read_sql_construct(',', ';', K_USING, + ", or ; or USING", + RAW_PARSE_PLPGSQL_EXPR, + true, true, + NULL, &tok); + new->params = lappend(new->params, expr); + } + } + else if (tok != K_USING) + { + /* must be condition name or SQLSTATE */ + if (tok_is_keyword(tok, &yylval, + K_SQLSTATE, "sqlstate")) + { + /* next token should be a string literal */ + char *sqlstatestr; + + if (yylex() != SCONST) + yyerror("syntax error"); + sqlstatestr = yylval.str; + + if (strlen(sqlstatestr) != 5) + yyerror("invalid SQLSTATE code"); + if (strspn(sqlstatestr, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != 5) + yyerror("invalid SQLSTATE code"); + new->condname = sqlstatestr; + } + else + { + if (tok == T_WORD) + new->condname = yylval.word.ident; + else if (plpgsql_token_is_unreserved_keyword(tok)) + new->condname = pstrdup(yylval.keyword); + else + yyerror("syntax error"); + plpgsql_recognize_err_condition(new->condname, + false); + } + tok = yylex(); + if (tok != ';' && tok != K_USING) + yyerror("syntax error"); + } + + if (tok == K_USING) + new->options = read_raise_options(); + } + + check_raise_parameters(new); + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_assert : K_ASSERT + { + PLpgSQL_stmt_assert *new; + int tok; + + new = palloc(sizeof(PLpgSQL_stmt_assert)); + + new->cmd_type = PLPGSQL_STMT_ASSERT; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + + new->cond = read_sql_expression2(',', ';', + ", or ;", + &tok); + + if (tok == ',') + new->message = read_sql_expression(';', ";"); + else + new->message = NULL; + + $$ = (PLpgSQL_stmt *) new; + } + ; + +loop_body : proc_sect K_END K_LOOP opt_label ';' + { + $$.stmts = $1; + $$.end_label = $4; + $$.end_label_location = @4; + } + ; + +/* + * T_WORD+T_CWORD match any initial identifier that is not a known plpgsql + * variable. (The composite case is probably a syntax error, but we'll let + * the core parser decide that.) Normally, we should assume that such a + * word is a SQL statement keyword that isn't also a plpgsql keyword. + * However, if the next token is assignment or '[' or '.', it can't be a valid + * SQL statement, and what we're probably looking at is an intended variable + * assignment. Give an appropriate complaint for that, instead of letting + * the core parser throw an unhelpful "syntax error". + */ +stmt_execsql : K_IMPORT + { + $$ = make_execsql_stmt(K_IMPORT, @1, NULL); + } + | K_INSERT + { + $$ = make_execsql_stmt(K_INSERT, @1, NULL); + } + | K_MERGE + { + $$ = make_execsql_stmt(K_MERGE, @1, NULL); + } + | T_WORD + { + int tok; + + tok = yylex(); + plpgsql_push_back_token(tok); + if (tok == '=' || tok == COLON_EQUALS || + tok == '[' || tok == '.') + word_is_not_variable(&($1), @1); + $$ = make_execsql_stmt(T_WORD, @1, &($1)); + } + | T_CWORD + { + int tok; + + tok = yylex(); + plpgsql_push_back_token(tok); + if (tok == '=' || tok == COLON_EQUALS || + tok == '[' || tok == '.') + cword_is_not_variable(&($1), @1); + $$ = make_execsql_stmt(T_CWORD, @1, NULL); + } + ; + +stmt_dynexecute : K_EXECUTE + { + PLpgSQL_stmt_dynexecute *new; + PLpgSQL_expr *expr; + int endtoken; + + expr = read_sql_construct(K_INTO, K_USING, ';', + "INTO or USING or ;", + RAW_PARSE_PLPGSQL_EXPR, + true, true, + NULL, &endtoken); + + new = palloc(sizeof(PLpgSQL_stmt_dynexecute)); + new->cmd_type = PLPGSQL_STMT_DYNEXECUTE; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->query = expr; + new->into = false; + new->strict = false; + new->target = NULL; + new->params = NIL; + + /* + * We loop to allow the INTO and USING clauses to + * appear in either order, since people easily get + * that wrong. This coding also prevents "INTO foo" + * from getting absorbed into a USING expression, + * which is *really* confusing. + */ + for (;;) + { + if (endtoken == K_INTO) + { + if (new->into) /* multiple INTO */ + yyerror("syntax error"); + new->into = true; + read_into_target(&new->target, &new->strict); + endtoken = yylex(); + } + else if (endtoken == K_USING) + { + if (new->params) /* multiple USING */ + yyerror("syntax error"); + do + { + expr = read_sql_construct(',', ';', K_INTO, + ", or ; or INTO", + RAW_PARSE_PLPGSQL_EXPR, + true, true, + NULL, &endtoken); + new->params = lappend(new->params, expr); + } while (endtoken == ','); + } + else if (endtoken == ';') + break; + else + yyerror("syntax error"); + } + + $$ = (PLpgSQL_stmt *) new; + } + ; + + +stmt_open : K_OPEN cursor_variable + { + PLpgSQL_stmt_open *new; + int tok; + + new = palloc0(sizeof(PLpgSQL_stmt_open)); + new->cmd_type = PLPGSQL_STMT_OPEN; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->curvar = $2->dno; + new->cursor_options = CURSOR_OPT_FAST_PLAN; + + if ($2->cursor_explicit_expr == NULL) + { + /* be nice if we could use opt_scrollable here */ + tok = yylex(); + if (tok_is_keyword(tok, &yylval, + K_NO, "no")) + { + tok = yylex(); + if (tok_is_keyword(tok, &yylval, + K_SCROLL, "scroll")) + { + new->cursor_options |= CURSOR_OPT_NO_SCROLL; + tok = yylex(); + } + } + else if (tok_is_keyword(tok, &yylval, + K_SCROLL, "scroll")) + { + new->cursor_options |= CURSOR_OPT_SCROLL; + tok = yylex(); + } + + if (tok != K_FOR) + yyerror("syntax error, expected \"FOR\""); + + tok = yylex(); + if (tok == K_EXECUTE) + { + int endtoken; + + new->dynquery = + read_sql_expression2(K_USING, ';', + "USING or ;", + &endtoken); + + /* If we found "USING", collect argument(s) */ + if (endtoken == K_USING) + { + PLpgSQL_expr *expr; + + do + { + expr = read_sql_expression2(',', ';', + ", or ;", + &endtoken); + new->params = lappend(new->params, + expr); + } while (endtoken == ','); + } + } + else + { + plpgsql_push_back_token(tok); + new->query = read_sql_stmt(); + } + } + else + { + /* predefined cursor query, so read args */ + new->argquery = read_cursor_args($2, ';'); + } + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_fetch : K_FETCH opt_fetch_direction cursor_variable K_INTO + { + PLpgSQL_stmt_fetch *fetch = $2; + PLpgSQL_variable *target; + + /* We have already parsed everything through the INTO keyword */ + read_into_target(&target, NULL); + + if (yylex() != ';') + yyerror("syntax error"); + + /* + * We don't allow multiple rows in PL/pgSQL's FETCH + * statement, only in MOVE. + */ + if (fetch->returns_multiple_rows) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("FETCH statement cannot return multiple rows"), + parser_errposition(@1))); + + fetch->lineno = plpgsql_location_to_lineno(@1); + fetch->target = target; + fetch->curvar = $3->dno; + fetch->is_move = false; + + $$ = (PLpgSQL_stmt *) fetch; + } + ; + +stmt_move : K_MOVE opt_fetch_direction cursor_variable ';' + { + PLpgSQL_stmt_fetch *fetch = $2; + + fetch->lineno = plpgsql_location_to_lineno(@1); + fetch->curvar = $3->dno; + fetch->is_move = true; + + $$ = (PLpgSQL_stmt *) fetch; + } + ; + +opt_fetch_direction : + { + $$ = read_fetch_direction(); + } + ; + +stmt_close : K_CLOSE cursor_variable ';' + { + PLpgSQL_stmt_close *new; + + new = palloc(sizeof(PLpgSQL_stmt_close)); + new->cmd_type = PLPGSQL_STMT_CLOSE; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->curvar = $2->dno; + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_null : K_NULL ';' + { + /* We do not bother building a node for NULL */ + $$ = NULL; + } + ; + +stmt_commit : K_COMMIT opt_transaction_chain ';' + { + PLpgSQL_stmt_commit *new; + + new = palloc(sizeof(PLpgSQL_stmt_commit)); + new->cmd_type = PLPGSQL_STMT_COMMIT; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->chain = $2; + + $$ = (PLpgSQL_stmt *) new; + } + ; + +stmt_rollback : K_ROLLBACK opt_transaction_chain ';' + { + PLpgSQL_stmt_rollback *new; + + new = palloc(sizeof(PLpgSQL_stmt_rollback)); + new->cmd_type = PLPGSQL_STMT_ROLLBACK; + new->lineno = plpgsql_location_to_lineno(@1); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->chain = $2; + + $$ = (PLpgSQL_stmt *) new; + } + ; + +opt_transaction_chain: + K_AND K_CHAIN { $$ = true; } + | K_AND K_NO K_CHAIN { $$ = false; } + | /* EMPTY */ { $$ = false; } + ; + + +cursor_variable : T_DATUM + { + /* + * In principle we should support a cursor_variable + * that is an array element, but for now we don't, so + * just throw an error if next token is '['. + */ + if ($1.datum->dtype != PLPGSQL_DTYPE_VAR || + plpgsql_peek() == '[') + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("cursor variable must be a simple variable"), + parser_errposition(@1))); + + if (((PLpgSQL_var *) $1.datum)->datatype->typoid != REFCURSOROID) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("variable \"%s\" must be of type cursor or refcursor", + ((PLpgSQL_var *) $1.datum)->refname), + parser_errposition(@1))); + $$ = (PLpgSQL_var *) $1.datum; + } + | T_WORD + { + /* just to give a better message than "syntax error" */ + word_is_not_variable(&($1), @1); + } + | T_CWORD + { + /* just to give a better message than "syntax error" */ + cword_is_not_variable(&($1), @1); + } + ; + +exception_sect : + { $$ = NULL; } + | K_EXCEPTION + { + /* + * We use a mid-rule action to add these + * special variables to the namespace before + * parsing the WHEN clauses themselves. The + * scope of the names extends to the end of the + * current block. + */ + int lineno = plpgsql_location_to_lineno(@1); + PLpgSQL_exception_block *new = palloc(sizeof(PLpgSQL_exception_block)); + PLpgSQL_variable *var; + + var = plpgsql_build_variable("sqlstate", lineno, + plpgsql_build_datatype(TEXTOID, + -1, + plpgsql_curr_compile->fn_input_collation, + NULL), + true); + var->isconst = true; + new->sqlstate_varno = var->dno; + + var = plpgsql_build_variable("sqlerrm", lineno, + plpgsql_build_datatype(TEXTOID, + -1, + plpgsql_curr_compile->fn_input_collation, + NULL), + true); + var->isconst = true; + new->sqlerrm_varno = var->dno; + + $$ = new; + } + proc_exceptions + { + PLpgSQL_exception_block *new = $2; + new->exc_list = $3; + + $$ = new; + } + ; + +proc_exceptions : proc_exceptions proc_exception + { + $$ = lappend($1, $2); + } + | proc_exception + { + $$ = list_make1($1); + } + ; + +proc_exception : K_WHEN proc_conditions K_THEN proc_sect + { + PLpgSQL_exception *new; + + new = palloc0(sizeof(PLpgSQL_exception)); + new->lineno = plpgsql_location_to_lineno(@1); + new->conditions = $2; + new->action = $4; + + $$ = new; + } + ; + +proc_conditions : proc_conditions K_OR proc_condition + { + PLpgSQL_condition *old; + + for (old = $1; old->next != NULL; old = old->next) + /* skip */ ; + old->next = $3; + $$ = $1; + } + | proc_condition + { + $$ = $1; + } + ; + +proc_condition : any_identifier + { + if (strcmp($1, "sqlstate") != 0) + { + $$ = plpgsql_parse_err_condition($1); + } + else + { + PLpgSQL_condition *new; + char *sqlstatestr; + + /* next token should be a string literal */ + if (yylex() != SCONST) + yyerror("syntax error"); + sqlstatestr = yylval.str; + + if (strlen(sqlstatestr) != 5) + yyerror("invalid SQLSTATE code"); + if (strspn(sqlstatestr, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != 5) + yyerror("invalid SQLSTATE code"); + + new = palloc(sizeof(PLpgSQL_condition)); + new->sqlerrstate = + MAKE_SQLSTATE(sqlstatestr[0], + sqlstatestr[1], + sqlstatestr[2], + sqlstatestr[3], + sqlstatestr[4]); + new->condname = sqlstatestr; + new->next = NULL; + + $$ = new; + } + } + ; + +expr_until_semi : + { $$ = read_sql_expression(';', ";"); } + ; + +expr_until_then : + { $$ = read_sql_expression(K_THEN, "THEN"); } + ; + +expr_until_loop : + { $$ = read_sql_expression(K_LOOP, "LOOP"); } + ; + +opt_block_label : + { + plpgsql_ns_push(NULL, PLPGSQL_LABEL_BLOCK); + $$ = NULL; + } + | LESS_LESS any_identifier GREATER_GREATER + { + plpgsql_ns_push($2, PLPGSQL_LABEL_BLOCK); + $$ = $2; + } + ; + +opt_loop_label : + { + plpgsql_ns_push(NULL, PLPGSQL_LABEL_LOOP); + $$ = NULL; + } + | LESS_LESS any_identifier GREATER_GREATER + { + plpgsql_ns_push($2, PLPGSQL_LABEL_LOOP); + $$ = $2; + } + ; + +opt_label : + { + $$ = NULL; + } + | any_identifier + { + /* label validity will be checked by outer production */ + $$ = $1; + } + ; + +opt_exitcond : ';' + { $$ = NULL; } + | K_WHEN expr_until_semi + { $$ = $2; } + ; + +/* + * need to allow DATUM because scanner will have tried to resolve as variable + */ +any_identifier : T_WORD + { + $$ = $1.ident; + } + | unreserved_keyword + { + $$ = pstrdup($1); + } + | T_DATUM + { + if ($1.ident == NULL) /* composite name not OK */ + yyerror("syntax error"); + $$ = $1.ident; + } + ; + +unreserved_keyword : + K_ABSOLUTE + | K_ALIAS + | K_AND + | K_ARRAY + | K_ASSERT + | K_BACKWARD + | K_CALL + | K_CHAIN + | K_CLOSE + | K_COLLATE + | K_COLUMN + | K_COLUMN_NAME + | K_COMMIT + | K_CONSTANT + | K_CONSTRAINT + | K_CONSTRAINT_NAME + | K_CONTINUE + | K_CURRENT + | K_CURSOR + | K_DATATYPE + | K_DEBUG + | K_DEFAULT + | K_DETAIL + | K_DIAGNOSTICS + | K_DO + | K_DUMP + | K_ELSIF + | K_ERRCODE + | K_ERROR + | K_EXCEPTION + | K_EXIT + | K_FETCH + | K_FIRST + | K_FORWARD + | K_GET + | K_HINT + | K_IMPORT + | K_INFO + | K_INSERT + | K_IS + | K_LAST + | K_LOG + | K_MERGE + | K_MESSAGE + | K_MESSAGE_TEXT + | K_MOVE + | K_NEXT + | K_NO + | K_NOTICE + | K_OPEN + | K_OPTION + | K_PERFORM + | K_PG_CONTEXT + | K_PG_DATATYPE_NAME + | K_PG_EXCEPTION_CONTEXT + | K_PG_EXCEPTION_DETAIL + | K_PG_EXCEPTION_HINT + | K_PG_ROUTINE_OID + | K_PRINT_STRICT_PARAMS + | K_PRIOR + | K_QUERY + | K_RAISE + | K_RELATIVE + | K_RETURN + | K_RETURNED_SQLSTATE + | K_REVERSE + | K_ROLLBACK + | K_ROW_COUNT + | K_ROWTYPE + | K_SCHEMA + | K_SCHEMA_NAME + | K_SCROLL + | K_SLICE + | K_SQLSTATE + | K_STACKED + | K_TABLE + | K_TABLE_NAME + | K_TYPE + | K_USE_COLUMN + | K_USE_VARIABLE + | K_VARIABLE_CONFLICT + | K_WARNING + ; + +%% + +/* + * Check whether a token represents an "unreserved keyword". + * We have various places where we want to recognize a keyword in preference + * to a variable name, but not reserve that keyword in other contexts. + * Hence, this kluge. + */ +static bool +tok_is_keyword(int token, union YYSTYPE *lval, + int kw_token, const char *kw_str) +{ + if (token == kw_token) + { + /* Normal case, was recognized by scanner (no conflicting variable) */ + return true; + } + else if (token == T_DATUM) + { + /* + * It's a variable, so recheck the string name. Note we will not + * match composite names (hence an unreserved word followed by "." + * will not be recognized). + */ + if (!lval->wdatum.quoted && lval->wdatum.ident != NULL && + strcmp(lval->wdatum.ident, kw_str) == 0) + return true; + } + return false; /* not the keyword */ +} + +/* + * Convenience routine to complain when we expected T_DATUM and got T_WORD, + * ie, unrecognized variable. + */ +static void +word_is_not_variable(PLword *word, int location) +{ + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("\"%s\" is not a known variable", + word->ident), + parser_errposition(location))); +} + +/* Same, for a CWORD */ +static void +cword_is_not_variable(PLcword *cword, int location) +{ + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("\"%s\" is not a known variable", + NameListToString(cword->idents)), + parser_errposition(location))); +} + +/* + * Convenience routine to complain when we expected T_DATUM and got + * something else. "tok" must be the current token, since we also + * look at yylval and yylloc. + */ +static void +current_token_is_not_variable(int tok) +{ + if (tok == T_WORD) + word_is_not_variable(&(yylval.word), yylloc); + else if (tok == T_CWORD) + cword_is_not_variable(&(yylval.cword), yylloc); + else + yyerror("syntax error"); +} + +/* Convenience routine to read an expression with one possible terminator */ +static PLpgSQL_expr * +read_sql_expression(int until, const char *expected) +{ + return read_sql_construct(until, 0, 0, expected, + RAW_PARSE_PLPGSQL_EXPR, + true, true, NULL, NULL); +} + +/* Convenience routine to read an expression with two possible terminators */ +static PLpgSQL_expr * +read_sql_expression2(int until, int until2, const char *expected, + int *endtoken) +{ + return read_sql_construct(until, until2, 0, expected, + RAW_PARSE_PLPGSQL_EXPR, + true, true, NULL, endtoken); +} + +/* Convenience routine to read a SQL statement that must end with ';' */ +static PLpgSQL_expr * +read_sql_stmt(void) +{ + return read_sql_construct(';', 0, 0, ";", + RAW_PARSE_DEFAULT, + false, true, NULL, NULL); +} + +/* + * Read a SQL construct and build a PLpgSQL_expr for it. + * + * until: token code for expected terminator + * until2: token code for alternate terminator (pass 0 if none) + * until3: token code for another alternate terminator (pass 0 if none) + * expected: text to use in complaining that terminator was not found + * parsemode: raw_parser() mode to use + * isexpression: whether to say we're reading an "expression" or a "statement" + * valid_sql: whether to check the syntax of the expr + * startloc: if not NULL, location of first token is stored at *startloc + * endtoken: if not NULL, ending token is stored at *endtoken + * (this is only interesting if until2 or until3 isn't zero) + */ +static PLpgSQL_expr * +read_sql_construct(int until, + int until2, + int until3, + const char *expected, + RawParseMode parsemode, + bool isexpression, + bool valid_sql, + int *startloc, + int *endtoken) +{ + int tok; + StringInfoData ds; + IdentifierLookup save_IdentifierLookup; + int startlocation = -1; + int endlocation = -1; + int parenlevel = 0; + PLpgSQL_expr *expr; + + initStringInfo(&ds); + + /* special lookup mode for identifiers within the SQL text */ + save_IdentifierLookup = plpgsql_IdentifierLookup; + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR; + + for (;;) + { + tok = yylex(); + if (startlocation < 0) /* remember loc of first token */ + startlocation = yylloc; + if (tok == until && parenlevel == 0) + break; + if (tok == until2 && parenlevel == 0) + break; + if (tok == until3 && parenlevel == 0) + break; + if (tok == '(' || tok == '[') + parenlevel++; + else if (tok == ')' || tok == ']') + { + parenlevel--; + if (parenlevel < 0) + yyerror("mismatched parentheses"); + } + /* + * End of function definition is an error, and we don't expect to + * hit a semicolon either (unless it's the until symbol, in which + * case we should have fallen out above). + */ + if (tok == 0 || tok == ';') + { + if (parenlevel != 0) + yyerror("mismatched parentheses"); + if (isexpression) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("missing \"%s\" at end of SQL expression", + expected), + parser_errposition(yylloc))); + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("missing \"%s\" at end of SQL statement", + expected), + parser_errposition(yylloc))); + } + /* Remember end+1 location of last accepted token */ + endlocation = yylloc + plpgsql_token_length(); + } + + plpgsql_IdentifierLookup = save_IdentifierLookup; + + if (startloc) + *startloc = startlocation; + if (endtoken) + *endtoken = tok; + + /* give helpful complaint about empty input */ + if (startlocation >= endlocation) + { + if (isexpression) + yyerror("missing expression"); + else + yyerror("missing SQL statement"); + } + + /* + * We save only the text from startlocation to endlocation-1. This + * suppresses the "until" token as well as any whitespace or comments + * following the last accepted token. (We used to strip such trailing + * whitespace by hand, but that causes problems if there's a "-- comment" + * in front of said whitespace.) + */ + plpgsql_append_source_text(&ds, startlocation, endlocation); + + expr = palloc0(sizeof(PLpgSQL_expr)); + expr->query = pstrdup(ds.data); + expr->parseMode = parsemode; + expr->plan = NULL; + expr->paramnos = NULL; + expr->target_param = -1; + expr->ns = plpgsql_ns_top(); + pfree(ds.data); + + if (valid_sql) + check_sql_expr(expr->query, expr->parseMode, startlocation); + + return expr; +} + +/* + * Read a datatype declaration, consuming the current lookahead token if any. + * Returns a PLpgSQL_type struct. + */ +static PLpgSQL_type * +read_datatype(int tok) +{ + StringInfoData ds; + char *type_name; + int startlocation; + PLpgSQL_type *result = NULL; + int parenlevel = 0; + + /* Should only be called while parsing DECLARE sections */ + Assert(plpgsql_IdentifierLookup == IDENTIFIER_LOOKUP_DECLARE); + + /* Often there will be a lookahead token, but if not, get one */ + if (tok == YYEMPTY) + tok = yylex(); + + /* The current token is the start of what we'll pass to parse_datatype */ + startlocation = yylloc; + + /* + * If we have a simple or composite identifier, check for %TYPE and + * %ROWTYPE constructs. + */ + if (tok == T_WORD) + { + char *dtname = yylval.word.ident; + + tok = yylex(); + if (tok == '%') + { + tok = yylex(); + if (tok_is_keyword(tok, &yylval, + K_TYPE, "type")) + result = plpgsql_parse_wordtype(dtname); + else if (tok_is_keyword(tok, &yylval, + K_ROWTYPE, "rowtype")) + result = plpgsql_parse_wordrowtype(dtname); + } + } + else if (plpgsql_token_is_unreserved_keyword(tok)) + { + char *dtname = pstrdup(yylval.keyword); + + tok = yylex(); + if (tok == '%') + { + tok = yylex(); + if (tok_is_keyword(tok, &yylval, + K_TYPE, "type")) + result = plpgsql_parse_wordtype(dtname); + else if (tok_is_keyword(tok, &yylval, + K_ROWTYPE, "rowtype")) + result = plpgsql_parse_wordrowtype(dtname); + } + } + else if (tok == T_CWORD) + { + List *dtnames = yylval.cword.idents; + + tok = yylex(); + if (tok == '%') + { + tok = yylex(); + if (tok_is_keyword(tok, &yylval, + K_TYPE, "type")) + result = plpgsql_parse_cwordtype(dtnames); + else if (tok_is_keyword(tok, &yylval, + K_ROWTYPE, "rowtype")) + result = plpgsql_parse_cwordrowtype(dtnames); + } + } + + /* + * If we recognized a %TYPE or %ROWTYPE construct, see if it is followed + * by array decoration: [ ARRAY ] [ '[' [ iconst ] ']' [ ... ] ] + * + * Like the core parser, we ignore the specific numbers and sizes of + * dimensions; arrays of different dimensionality are still the same type + * in Postgres. + */ + if (result) + { + bool is_array = false; + + tok = yylex(); + if (tok_is_keyword(tok, &yylval, + K_ARRAY, "array")) + { + is_array = true; + tok = yylex(); + } + while (tok == '[') + { + is_array = true; + tok = yylex(); + if (tok == ICONST) + tok = yylex(); + if (tok != ']') + yyerror("syntax error, expected \"]\""); + tok = yylex(); + } + plpgsql_push_back_token(tok); + + if (is_array) + result = plpgsql_build_datatype_arrayof(result); + + return result; + } + + /* + * Not %TYPE or %ROWTYPE, so scan to the end of the datatype declaration, + * which could include typmod or array decoration. We are not very picky + * here, instead relying on parse_datatype to complain about garbage. But + * we must count parens to handle typmods within cursor_arg correctly. + */ + while (tok != ';') + { + if (tok == 0) + { + if (parenlevel != 0) + yyerror("mismatched parentheses"); + else + yyerror("incomplete data type declaration"); + } + /* Possible followers for datatype in a declaration */ + if (tok == K_COLLATE || tok == K_NOT || + tok == '=' || tok == COLON_EQUALS || tok == K_DEFAULT) + break; + /* Possible followers for datatype in a cursor_arg list */ + if ((tok == ',' || tok == ')') && parenlevel == 0) + break; + if (tok == '(') + parenlevel++; + else if (tok == ')') + parenlevel--; + + tok = yylex(); + } + + /* set up ds to contain complete typename text */ + initStringInfo(&ds); + plpgsql_append_source_text(&ds, startlocation, yylloc); + type_name = ds.data; + + if (type_name[0] == '\0') + yyerror("missing data type declaration"); + + result = parse_datatype(type_name, startlocation); + + pfree(ds.data); + + plpgsql_push_back_token(tok); + + return result; +} + +/* + * Read a generic SQL statement. We have already read its first token; + * firsttoken is that token's code and location its starting location. + * If firsttoken == T_WORD, pass its yylval value as "word", else pass NULL. + */ +static PLpgSQL_stmt * +make_execsql_stmt(int firsttoken, int location, PLword *word) +{ + StringInfoData ds; + IdentifierLookup save_IdentifierLookup; + PLpgSQL_stmt_execsql *execsql; + PLpgSQL_expr *expr; + PLpgSQL_variable *target = NULL; + int tok; + int prev_tok; + bool have_into = false; + bool have_strict = false; + int into_start_loc = -1; + int into_end_loc = -1; + int paren_depth = 0; + int begin_depth = 0; + bool in_routine_definition = false; + int token_count = 0; + char tokens[4]; /* records the first few tokens */ + + initStringInfo(&ds); + + memset(tokens, 0, sizeof(tokens)); + + /* special lookup mode for identifiers within the SQL text */ + save_IdentifierLookup = plpgsql_IdentifierLookup; + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR; + + /* + * Scan to the end of the SQL command. Identify any INTO-variables + * clause lurking within it, and parse that via read_into_target(). + * + * The end of the statement is defined by a semicolon ... except that + * semicolons within parentheses or BEGIN/END blocks don't terminate a + * statement. We follow psql's lead in not recognizing BEGIN/END except + * after CREATE [OR REPLACE] {FUNCTION|PROCEDURE}. END can also appear + * within a CASE construct, so we treat CASE/END like BEGIN/END. + * + * Because INTO is sometimes used in the main SQL grammar, we have to be + * careful not to take any such usage of INTO as a PL/pgSQL INTO clause. + * There are currently three such cases: + * + * 1. SELECT ... INTO. We don't care, we just override that with the + * PL/pgSQL definition. + * + * 2. INSERT INTO. This is relatively easy to recognize since the words + * must appear adjacently; but we can't assume INSERT starts the command, + * because it can appear in CREATE RULE or WITH. Unfortunately, INSERT is + * *not* fully reserved, so that means there is a chance of a false match; + * but it's not very likely. + * + * 3. IMPORT FOREIGN SCHEMA ... INTO. This is not allowed in CREATE RULE + * or WITH, so we just check for IMPORT as the command's first token. + * (If IMPORT FOREIGN SCHEMA returned data someone might wish to capture + * with an INTO-variables clause, we'd have to work much harder here.) + * + * Fortunately, INTO is a fully reserved word in the main grammar, so + * at least we need not worry about it appearing as an identifier. + * + * Any future additional uses of INTO in the main grammar will doubtless + * break this logic again ... beware! + */ + tok = firsttoken; + if (tok == T_WORD && strcmp(word->ident, "create") == 0) + tokens[token_count] = 'c'; + token_count++; + + for (;;) + { + prev_tok = tok; + tok = yylex(); + if (have_into && into_end_loc < 0) + into_end_loc = yylloc; /* token after the INTO part */ + /* Detect CREATE [OR REPLACE] {FUNCTION|PROCEDURE} */ + if (tokens[0] == 'c' && token_count < sizeof(tokens)) + { + if (tok == K_OR) + tokens[token_count] = 'o'; + else if (tok == T_WORD && + strcmp(yylval.word.ident, "replace") == 0) + tokens[token_count] = 'r'; + else if (tok == T_WORD && + strcmp(yylval.word.ident, "function") == 0) + tokens[token_count] = 'f'; + else if (tok == T_WORD && + strcmp(yylval.word.ident, "procedure") == 0) + tokens[token_count] = 'f'; /* treat same as "function" */ + if (tokens[1] == 'f' || + (tokens[1] == 'o' && tokens[2] == 'r' && tokens[3] == 'f')) + in_routine_definition = true; + token_count++; + } + /* Track paren nesting (needed for CREATE RULE syntax) */ + if (tok == '(') + paren_depth++; + else if (tok == ')' && paren_depth > 0) + paren_depth--; + /* We need track BEGIN/END nesting only in a routine definition */ + if (in_routine_definition && paren_depth == 0) + { + if (tok == K_BEGIN || tok == K_CASE) + begin_depth++; + else if (tok == K_END && begin_depth > 0) + begin_depth--; + } + /* Command-ending semicolon? */ + if (tok == ';' && paren_depth == 0 && begin_depth == 0) + break; + if (tok == 0) + yyerror("unexpected end of function definition"); + if (tok == K_INTO) + { + if (prev_tok == K_INSERT) + continue; /* INSERT INTO is not an INTO-target */ + if (prev_tok == K_MERGE) + continue; /* MERGE INTO is not an INTO-target */ + if (firsttoken == K_IMPORT) + continue; /* IMPORT ... INTO is not an INTO-target */ + if (have_into) + yyerror("INTO specified more than once"); + have_into = true; + into_start_loc = yylloc; + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL; + read_into_target(&target, &have_strict); + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR; + } + } + + plpgsql_IdentifierLookup = save_IdentifierLookup; + + if (have_into) + { + /* + * Insert an appropriate number of spaces corresponding to the + * INTO text, so that locations within the redacted SQL statement + * still line up with those in the original source text. + */ + plpgsql_append_source_text(&ds, location, into_start_loc); + appendStringInfoSpaces(&ds, into_end_loc - into_start_loc); + plpgsql_append_source_text(&ds, into_end_loc, yylloc); + } + else + plpgsql_append_source_text(&ds, location, yylloc); + + /* trim any trailing whitespace, for neatness */ + while (ds.len > 0 && scanner_isspace(ds.data[ds.len - 1])) + ds.data[--ds.len] = '\0'; + + expr = palloc0(sizeof(PLpgSQL_expr)); + expr->query = pstrdup(ds.data); + expr->parseMode = RAW_PARSE_DEFAULT; + expr->plan = NULL; + expr->paramnos = NULL; + expr->target_param = -1; + expr->ns = plpgsql_ns_top(); + pfree(ds.data); + + check_sql_expr(expr->query, expr->parseMode, location); + + execsql = palloc0(sizeof(PLpgSQL_stmt_execsql)); + execsql->cmd_type = PLPGSQL_STMT_EXECSQL; + execsql->lineno = plpgsql_location_to_lineno(location); + execsql->stmtid = ++plpgsql_curr_compile->nstatements; + execsql->sqlstmt = expr; + execsql->into = have_into; + execsql->strict = have_strict; + execsql->target = target; + + return (PLpgSQL_stmt *) execsql; +} + + +/* + * Read FETCH or MOVE direction clause (everything through FROM/IN). + */ +static PLpgSQL_stmt_fetch * +read_fetch_direction(void) +{ + PLpgSQL_stmt_fetch *fetch; + int tok; + bool check_FROM = true; + + /* + * We create the PLpgSQL_stmt_fetch struct here, but only fill in + * the fields arising from the optional direction clause + */ + fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch)); + fetch->cmd_type = PLPGSQL_STMT_FETCH; + fetch->stmtid = ++plpgsql_curr_compile->nstatements; + /* set direction defaults: */ + fetch->direction = FETCH_FORWARD; + fetch->how_many = 1; + fetch->expr = NULL; + fetch->returns_multiple_rows = false; + + tok = yylex(); + if (tok == 0) + yyerror("unexpected end of function definition"); + + if (tok_is_keyword(tok, &yylval, + K_NEXT, "next")) + { + /* use defaults */ + } + else if (tok_is_keyword(tok, &yylval, + K_PRIOR, "prior")) + { + fetch->direction = FETCH_BACKWARD; + } + else if (tok_is_keyword(tok, &yylval, + K_FIRST, "first")) + { + fetch->direction = FETCH_ABSOLUTE; + } + else if (tok_is_keyword(tok, &yylval, + K_LAST, "last")) + { + fetch->direction = FETCH_ABSOLUTE; + fetch->how_many = -1; + } + else if (tok_is_keyword(tok, &yylval, + K_ABSOLUTE, "absolute")) + { + fetch->direction = FETCH_ABSOLUTE; + fetch->expr = read_sql_expression2(K_FROM, K_IN, + "FROM or IN", + NULL); + check_FROM = false; + } + else if (tok_is_keyword(tok, &yylval, + K_RELATIVE, "relative")) + { + fetch->direction = FETCH_RELATIVE; + fetch->expr = read_sql_expression2(K_FROM, K_IN, + "FROM or IN", + NULL); + check_FROM = false; + } + else if (tok_is_keyword(tok, &yylval, + K_ALL, "all")) + { + fetch->how_many = FETCH_ALL; + fetch->returns_multiple_rows = true; + } + else if (tok_is_keyword(tok, &yylval, + K_FORWARD, "forward")) + { + complete_direction(fetch, &check_FROM); + } + else if (tok_is_keyword(tok, &yylval, + K_BACKWARD, "backward")) + { + fetch->direction = FETCH_BACKWARD; + complete_direction(fetch, &check_FROM); + } + else if (tok == K_FROM || tok == K_IN) + { + /* empty direction */ + check_FROM = false; + } + else if (tok == T_DATUM) + { + /* Assume there's no direction clause and tok is a cursor name */ + plpgsql_push_back_token(tok); + check_FROM = false; + } + else + { + /* + * Assume it's a count expression with no preceding keyword. + * Note: we allow this syntax because core SQL does, but it's + * ambiguous with the case of an omitted direction clause; for + * instance, "MOVE n IN c" will fail if n is a variable, because the + * preceding else-arm will trigger. Perhaps this can be improved + * someday, but it hardly seems worth a lot of work. + */ + plpgsql_push_back_token(tok); + fetch->expr = read_sql_expression2(K_FROM, K_IN, + "FROM or IN", + NULL); + fetch->returns_multiple_rows = true; + check_FROM = false; + } + + /* check FROM or IN keyword after direction's specification */ + if (check_FROM) + { + tok = yylex(); + if (tok != K_FROM && tok != K_IN) + yyerror("expected FROM or IN"); + } + + return fetch; +} + +/* + * Process remainder of FETCH/MOVE direction after FORWARD or BACKWARD. + * Allows these cases: + * FORWARD expr, FORWARD ALL, FORWARD + * BACKWARD expr, BACKWARD ALL, BACKWARD + */ +static void +complete_direction(PLpgSQL_stmt_fetch *fetch, bool *check_FROM) +{ + int tok; + + tok = yylex(); + if (tok == 0) + yyerror("unexpected end of function definition"); + + if (tok == K_FROM || tok == K_IN) + { + *check_FROM = false; + return; + } + + if (tok == K_ALL) + { + fetch->how_many = FETCH_ALL; + fetch->returns_multiple_rows = true; + *check_FROM = true; + return; + } + + plpgsql_push_back_token(tok); + fetch->expr = read_sql_expression2(K_FROM, K_IN, + "FROM or IN", + NULL); + fetch->returns_multiple_rows = true; + *check_FROM = false; +} + + +static PLpgSQL_stmt * +make_return_stmt(int location) +{ + PLpgSQL_stmt_return *new; + + new = palloc0(sizeof(PLpgSQL_stmt_return)); + new->cmd_type = PLPGSQL_STMT_RETURN; + new->lineno = plpgsql_location_to_lineno(location); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->expr = NULL; + new->retvarno = -1; + + if (plpgsql_curr_compile->fn_retset) + { + if (yylex() != ';') + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("RETURN cannot have a parameter in function returning set"), + errhint("Use RETURN NEXT or RETURN QUERY."), + parser_errposition(yylloc))); + } + else if (plpgsql_curr_compile->fn_rettype == VOIDOID) + { + if (yylex() != ';') + { + if (plpgsql_curr_compile->fn_prokind == PROKIND_PROCEDURE) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("RETURN cannot have a parameter in a procedure"), + parser_errposition(yylloc))); + else + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("RETURN cannot have a parameter in function returning void"), + parser_errposition(yylloc))); + } + } + else if (plpgsql_curr_compile->out_param_varno >= 0) + { + if (yylex() != ';') + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("RETURN cannot have a parameter in function with OUT parameters"), + parser_errposition(yylloc))); + new->retvarno = plpgsql_curr_compile->out_param_varno; + } + else + { + /* + * We want to special-case simple variable references for efficiency. + * So peek ahead to see if that's what we have. + */ + int tok = yylex(); + + if (tok == T_DATUM && plpgsql_peek() == ';' && + (yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR || + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_PROMISE || + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_ROW || + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_REC)) + { + new->retvarno = yylval.wdatum.datum->dno; + /* eat the semicolon token that we only peeked at above */ + tok = yylex(); + Assert(tok == ';'); + } + else + { + /* + * Not (just) a variable name, so treat as expression. + * + * Note that a well-formed expression is _required_ here; + * anything else is a compile-time error. + */ + plpgsql_push_back_token(tok); + new->expr = read_sql_expression(';', ";"); + } + } + + return (PLpgSQL_stmt *) new; +} + + +static PLpgSQL_stmt * +make_return_next_stmt(int location) +{ + PLpgSQL_stmt_return_next *new; + + if (!plpgsql_curr_compile->fn_retset) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("cannot use RETURN NEXT in a non-SETOF function"), + parser_errposition(location))); + + new = palloc0(sizeof(PLpgSQL_stmt_return_next)); + new->cmd_type = PLPGSQL_STMT_RETURN_NEXT; + new->lineno = plpgsql_location_to_lineno(location); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->expr = NULL; + new->retvarno = -1; + + if (plpgsql_curr_compile->out_param_varno >= 0) + { + if (yylex() != ';') + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("RETURN NEXT cannot have a parameter in function with OUT parameters"), + parser_errposition(yylloc))); + new->retvarno = plpgsql_curr_compile->out_param_varno; + } + else + { + /* + * We want to special-case simple variable references for efficiency. + * So peek ahead to see if that's what we have. + */ + int tok = yylex(); + + if (tok == T_DATUM && plpgsql_peek() == ';' && + (yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR || + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_PROMISE || + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_ROW || + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_REC)) + { + new->retvarno = yylval.wdatum.datum->dno; + /* eat the semicolon token that we only peeked at above */ + tok = yylex(); + Assert(tok == ';'); + } + else + { + /* + * Not (just) a variable name, so treat as expression. + * + * Note that a well-formed expression is _required_ here; + * anything else is a compile-time error. + */ + plpgsql_push_back_token(tok); + new->expr = read_sql_expression(';', ";"); + } + } + + return (PLpgSQL_stmt *) new; +} + + +static PLpgSQL_stmt * +make_return_query_stmt(int location) +{ + PLpgSQL_stmt_return_query *new; + int tok; + + if (!plpgsql_curr_compile->fn_retset) + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), + errmsg("cannot use RETURN QUERY in a non-SETOF function"), + parser_errposition(location))); + + new = palloc0(sizeof(PLpgSQL_stmt_return_query)); + new->cmd_type = PLPGSQL_STMT_RETURN_QUERY; + new->lineno = plpgsql_location_to_lineno(location); + new->stmtid = ++plpgsql_curr_compile->nstatements; + + /* check for RETURN QUERY EXECUTE */ + if ((tok = yylex()) != K_EXECUTE) + { + /* ordinary static query */ + plpgsql_push_back_token(tok); + new->query = read_sql_stmt(); + } + else + { + /* dynamic SQL */ + int term; + + new->dynquery = read_sql_expression2(';', K_USING, "; or USING", + &term); + if (term == K_USING) + { + do + { + PLpgSQL_expr *expr; + + expr = read_sql_expression2(',', ';', ", or ;", &term); + new->params = lappend(new->params, expr); + } while (term == ','); + } + } + + return (PLpgSQL_stmt *) new; +} + + +/* convenience routine to fetch the name of a T_DATUM */ +static char * +NameOfDatum(PLwdatum *wdatum) +{ + if (wdatum->ident) + return wdatum->ident; + Assert(wdatum->idents != NIL); + return NameListToString(wdatum->idents); +} + +static void +check_assignable(PLpgSQL_datum *datum, int location) +{ + switch (datum->dtype) + { + case PLPGSQL_DTYPE_VAR: + case PLPGSQL_DTYPE_PROMISE: + case PLPGSQL_DTYPE_REC: + if (((PLpgSQL_variable *) datum)->isconst) + ereport(ERROR, + (errcode(ERRCODE_ERROR_IN_ASSIGNMENT), + errmsg("variable \"%s\" is declared CONSTANT", + ((PLpgSQL_variable *) datum)->refname), + parser_errposition(location))); + break; + case PLPGSQL_DTYPE_ROW: + /* always assignable; member vars were checked at compile time */ + break; + case PLPGSQL_DTYPE_RECFIELD: + /* assignable if parent record is */ + check_assignable(plpgsql_Datums[((PLpgSQL_recfield *) datum)->recparentno], + location); + break; + default: + elog(ERROR, "unrecognized dtype: %d", datum->dtype); + break; + } +} + +/* + * Read the argument of an INTO clause. On entry, we have just read the + * INTO keyword. + */ +static void +read_into_target(PLpgSQL_variable **target, bool *strict) +{ + int tok; + + /* Set default results */ + *target = NULL; + if (strict) + *strict = false; + + tok = yylex(); + if (strict && tok == K_STRICT) + { + *strict = true; + tok = yylex(); + } + + /* + * Currently, a row or record variable can be the single INTO target, + * but not a member of a multi-target list. So we throw error if there + * is a comma after it, because that probably means the user tried to + * write a multi-target list. If this ever gets generalized, we should + * probably refactor read_into_scalar_list so it handles all cases. + */ + switch (tok) + { + case T_DATUM: + if (yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_ROW || + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_REC) + { + check_assignable(yylval.wdatum.datum, yylloc); + *target = (PLpgSQL_variable *) yylval.wdatum.datum; + + if ((tok = yylex()) == ',') + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("record variable cannot be part of multiple-item INTO list"), + parser_errposition(yylloc))); + plpgsql_push_back_token(tok); + } + else + { + *target = (PLpgSQL_variable *) + read_into_scalar_list(NameOfDatum(&(yylval.wdatum)), + yylval.wdatum.datum, yylloc); + } + break; + + default: + /* just to give a better message than "syntax error" */ + current_token_is_not_variable(tok); + } +} + +/* + * Given the first datum and name in the INTO list, continue to read + * comma-separated scalar variables until we run out. Then construct + * and return a fake "row" variable that represents the list of + * scalars. + */ +static PLpgSQL_row * +read_into_scalar_list(char *initial_name, + PLpgSQL_datum *initial_datum, + int initial_location) +{ + int nfields; + char *fieldnames[1024]; + int varnos[1024]; + PLpgSQL_row *row; + int tok; + + check_assignable(initial_datum, initial_location); + fieldnames[0] = initial_name; + varnos[0] = initial_datum->dno; + nfields = 1; + + while ((tok = yylex()) == ',') + { + /* Check for array overflow */ + if (nfields >= 1024) + ereport(ERROR, + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("too many INTO variables specified"), + parser_errposition(yylloc))); + + tok = yylex(); + switch (tok) + { + case T_DATUM: + check_assignable(yylval.wdatum.datum, yylloc); + if (yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_ROW || + yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_REC) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("\"%s\" is not a scalar variable", + NameOfDatum(&(yylval.wdatum))), + parser_errposition(yylloc))); + fieldnames[nfields] = NameOfDatum(&(yylval.wdatum)); + varnos[nfields++] = yylval.wdatum.datum->dno; + break; + + default: + /* just to give a better message than "syntax error" */ + current_token_is_not_variable(tok); + } + } + + /* + * We read an extra, non-comma token from yylex(), so push it + * back onto the input stream + */ + plpgsql_push_back_token(tok); + + row = palloc0(sizeof(PLpgSQL_row)); + row->dtype = PLPGSQL_DTYPE_ROW; + row->refname = "(unnamed row)"; + row->lineno = plpgsql_location_to_lineno(initial_location); + row->rowtupdesc = NULL; + row->nfields = nfields; + row->fieldnames = palloc(sizeof(char *) * nfields); + row->varnos = palloc(sizeof(int) * nfields); + while (--nfields >= 0) + { + row->fieldnames[nfields] = fieldnames[nfields]; + row->varnos[nfields] = varnos[nfields]; + } + + plpgsql_adddatum((PLpgSQL_datum *) row); + + return row; +} + +/* + * Convert a single scalar into a "row" list. This is exactly + * like read_into_scalar_list except we never consume any input. + * + * Note: lineno could be computed from location, but since callers + * have it at hand already, we may as well pass it in. + */ +static PLpgSQL_row * +make_scalar_list1(char *initial_name, + PLpgSQL_datum *initial_datum, + int lineno, int location) +{ + PLpgSQL_row *row; + + check_assignable(initial_datum, location); + + row = palloc0(sizeof(PLpgSQL_row)); + row->dtype = PLPGSQL_DTYPE_ROW; + row->refname = "(unnamed row)"; + row->lineno = lineno; + row->rowtupdesc = NULL; + row->nfields = 1; + row->fieldnames = palloc(sizeof(char *)); + row->varnos = palloc(sizeof(int)); + row->fieldnames[0] = initial_name; + row->varnos[0] = initial_datum->dno; + + plpgsql_adddatum((PLpgSQL_datum *) row); + + return row; +} + +/* + * When the PL/pgSQL parser expects to see a SQL statement, it is very + * liberal in what it accepts; for example, we often assume an + * unrecognized keyword is the beginning of a SQL statement. This + * avoids the need to duplicate parts of the SQL grammar in the + * PL/pgSQL grammar, but it means we can accept wildly malformed + * input. To try and catch some of the more obviously invalid input, + * we run the strings we expect to be SQL statements through the main + * SQL parser. + * + * We only invoke the raw parser (not the analyzer); this doesn't do + * any database access and does not check any semantic rules, it just + * checks for basic syntactic correctness. We do this here, rather + * than after parsing has finished, because a malformed SQL statement + * may cause the PL/pgSQL parser to become confused about statement + * borders. So it is best to bail out as early as we can. + * + * It is assumed that "stmt" represents a copy of the function source text + * beginning at offset "location". We use this assumption to transpose + * any error cursor position back to the function source text. + * If no error cursor is provided, we'll just point at "location". + */ +static void +check_sql_expr(const char *stmt, RawParseMode parseMode, int location) +{ + sql_error_callback_arg cbarg; + ErrorContextCallback syntax_errcontext; + MemoryContext oldCxt; + + if (!plpgsql_check_syntax) + return; + + cbarg.location = location; + + syntax_errcontext.callback = plpgsql_sql_error_callback; + syntax_errcontext.arg = &cbarg; + syntax_errcontext.previous = error_context_stack; + error_context_stack = &syntax_errcontext; + + oldCxt = MemoryContextSwitchTo(plpgsql_compile_tmp_cxt); + (void) raw_parser(stmt, parseMode); + MemoryContextSwitchTo(oldCxt); + + /* Restore former ereport callback */ + error_context_stack = syntax_errcontext.previous; +} + +static void +plpgsql_sql_error_callback(void *arg) +{ + sql_error_callback_arg *cbarg = (sql_error_callback_arg *) arg; + int errpos; + + /* + * First, set up internalerrposition to point to the start of the + * statement text within the function text. Note this converts + * location (a byte offset) to a character number. + */ + parser_errposition(cbarg->location); + + /* + * If the core parser provided an error position, transpose it. + * Note we are dealing with 1-based character numbers at this point. + */ + errpos = geterrposition(); + if (errpos > 0) + { + int myerrpos = getinternalerrposition(); + + if (myerrpos > 0) /* safety check */ + internalerrposition(myerrpos + errpos - 1); + } + + /* In any case, flush errposition --- we want internalerrposition only */ + errposition(0); +} + +/* + * Parse a SQL datatype name and produce a PLpgSQL_type structure. + * + * The heavy lifting is done elsewhere. Here we are only concerned + * with setting up an errcontext link that will let us give an error + * cursor pointing into the plpgsql function source, if necessary. + * This is handled the same as in check_sql_expr(), and we likewise + * expect that the given string is a copy from the source text. + */ +static PLpgSQL_type * +parse_datatype(const char *string, int location) +{ + TypeName *typeName; + Oid type_id; + int32 typmod; + sql_error_callback_arg cbarg; + ErrorContextCallback syntax_errcontext; + + cbarg.location = location; + + syntax_errcontext.callback = plpgsql_sql_error_callback; + syntax_errcontext.arg = &cbarg; + syntax_errcontext.previous = error_context_stack; + error_context_stack = &syntax_errcontext; + + /* Let the main parser try to parse it under standard SQL rules */ + typeName = typeStringToTypeName(string, NULL); + typenameTypeIdAndMod(NULL, typeName, &type_id, &typmod); + + /* Restore former ereport callback */ + error_context_stack = syntax_errcontext.previous; + + /* Okay, build a PLpgSQL_type data structure for it */ + return plpgsql_build_datatype(type_id, typmod, + plpgsql_curr_compile->fn_input_collation, + typeName); +} + +/* + * Check block starting and ending labels match. + */ +static void +check_labels(const char *start_label, const char *end_label, int end_location) +{ + if (end_label) + { + if (!start_label) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("end label \"%s\" specified for unlabeled block", + end_label), + parser_errposition(end_location))); + + if (strcmp(start_label, end_label) != 0) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("end label \"%s\" differs from block's label \"%s\"", + end_label, start_label), + parser_errposition(end_location))); + } +} + +/* + * Read the arguments (if any) for a cursor, followed by the until token + * + * If cursor has no args, just swallow the until token and return NULL. + * If it does have args, we expect to see "( arg [, arg ...] )" followed + * by the until token, where arg may be a plain expression, or a named + * parameter assignment of the form argname := expr. Consume all that and + * return a SELECT query that evaluates the expression(s) (without the outer + * parens). + */ +static PLpgSQL_expr * +read_cursor_args(PLpgSQL_var *cursor, int until) +{ + PLpgSQL_expr *expr; + PLpgSQL_row *row; + int tok; + int argc; + char **argv; + StringInfoData ds; + bool any_named = false; + + tok = yylex(); + if (cursor->cursor_explicit_argrow < 0) + { + /* No arguments expected */ + if (tok == '(') + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cursor \"%s\" has no arguments", + cursor->refname), + parser_errposition(yylloc))); + + if (tok != until) + yyerror("syntax error"); + + return NULL; + } + + /* Else better provide arguments */ + if (tok != '(') + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cursor \"%s\" has arguments", + cursor->refname), + parser_errposition(yylloc))); + + /* + * Read the arguments, one by one. + */ + row = (PLpgSQL_row *) plpgsql_Datums[cursor->cursor_explicit_argrow]; + argv = (char **) palloc0(row->nfields * sizeof(char *)); + + for (argc = 0; argc < row->nfields; argc++) + { + PLpgSQL_expr *item; + int endtoken; + int argpos; + int tok1, + tok2; + int arglocation; + + /* Check if it's a named parameter: "param := value" */ + plpgsql_peek2(&tok1, &tok2, &arglocation, NULL); + if (tok1 == IDENT && tok2 == COLON_EQUALS) + { + char *argname; + IdentifierLookup save_IdentifierLookup; + + /* Read the argument name, ignoring any matching variable */ + save_IdentifierLookup = plpgsql_IdentifierLookup; + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_DECLARE; + yylex(); + argname = yylval.str; + plpgsql_IdentifierLookup = save_IdentifierLookup; + + /* Match argument name to cursor arguments */ + for (argpos = 0; argpos < row->nfields; argpos++) + { + if (strcmp(row->fieldnames[argpos], argname) == 0) + break; + } + if (argpos == row->nfields) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("cursor \"%s\" has no argument named \"%s\"", + cursor->refname, argname), + parser_errposition(yylloc))); + + /* + * Eat the ":=". We already peeked, so the error should never + * happen. + */ + tok2 = yylex(); + if (tok2 != COLON_EQUALS) + yyerror("syntax error"); + + any_named = true; + } + else + argpos = argc; + + if (argv[argpos] != NULL) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("value for parameter \"%s\" of cursor \"%s\" specified more than once", + row->fieldnames[argpos], cursor->refname), + parser_errposition(arglocation))); + + /* + * Read the value expression. To provide the user with meaningful + * parse error positions, we check the syntax immediately, instead of + * checking the final expression that may have the arguments + * reordered. + */ + item = read_sql_construct(',', ')', 0, + ",\" or \")", + RAW_PARSE_PLPGSQL_EXPR, + true, true, + NULL, &endtoken); + + argv[argpos] = item->query; + + if (endtoken == ')' && !(argc == row->nfields - 1)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("not enough arguments for cursor \"%s\"", + cursor->refname), + parser_errposition(yylloc))); + + if (endtoken == ',' && (argc == row->nfields - 1)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("too many arguments for cursor \"%s\"", + cursor->refname), + parser_errposition(yylloc))); + } + + /* Make positional argument list */ + initStringInfo(&ds); + for (argc = 0; argc < row->nfields; argc++) + { + Assert(argv[argc] != NULL); + + /* + * Because named notation allows permutated argument lists, include + * the parameter name for meaningful runtime errors. + */ + appendStringInfoString(&ds, argv[argc]); + if (any_named) + appendStringInfo(&ds, " AS %s", + quote_identifier(row->fieldnames[argc])); + if (argc < row->nfields - 1) + appendStringInfoString(&ds, ", "); + } + + expr = palloc0(sizeof(PLpgSQL_expr)); + expr->query = pstrdup(ds.data); + expr->parseMode = RAW_PARSE_PLPGSQL_EXPR; + expr->plan = NULL; + expr->paramnos = NULL; + expr->target_param = -1; + expr->ns = plpgsql_ns_top(); + pfree(ds.data); + + /* Next we'd better find the until token */ + tok = yylex(); + if (tok != until) + yyerror("syntax error"); + + return expr; +} + +/* + * Parse RAISE ... USING options + */ +static List * +read_raise_options(void) +{ + List *result = NIL; + + for (;;) + { + PLpgSQL_raise_option *opt; + int tok; + + if ((tok = yylex()) == 0) + yyerror("unexpected end of function definition"); + + opt = (PLpgSQL_raise_option *) palloc(sizeof(PLpgSQL_raise_option)); + + if (tok_is_keyword(tok, &yylval, + K_ERRCODE, "errcode")) + opt->opt_type = PLPGSQL_RAISEOPTION_ERRCODE; + else if (tok_is_keyword(tok, &yylval, + K_MESSAGE, "message")) + opt->opt_type = PLPGSQL_RAISEOPTION_MESSAGE; + else if (tok_is_keyword(tok, &yylval, + K_DETAIL, "detail")) + opt->opt_type = PLPGSQL_RAISEOPTION_DETAIL; + else if (tok_is_keyword(tok, &yylval, + K_HINT, "hint")) + opt->opt_type = PLPGSQL_RAISEOPTION_HINT; + else if (tok_is_keyword(tok, &yylval, + K_COLUMN, "column")) + opt->opt_type = PLPGSQL_RAISEOPTION_COLUMN; + else if (tok_is_keyword(tok, &yylval, + K_CONSTRAINT, "constraint")) + opt->opt_type = PLPGSQL_RAISEOPTION_CONSTRAINT; + else if (tok_is_keyword(tok, &yylval, + K_DATATYPE, "datatype")) + opt->opt_type = PLPGSQL_RAISEOPTION_DATATYPE; + else if (tok_is_keyword(tok, &yylval, + K_TABLE, "table")) + opt->opt_type = PLPGSQL_RAISEOPTION_TABLE; + else if (tok_is_keyword(tok, &yylval, + K_SCHEMA, "schema")) + opt->opt_type = PLPGSQL_RAISEOPTION_SCHEMA; + else + yyerror("unrecognized RAISE statement option"); + + tok = yylex(); + if (tok != '=' && tok != COLON_EQUALS) + yyerror("syntax error, expected \"=\""); + + opt->expr = read_sql_expression2(',', ';', ", or ;", &tok); + + result = lappend(result, opt); + + if (tok == ';') + break; + } + + return result; +} + +/* + * Check that the number of parameter placeholders in the message matches the + * number of parameters passed to it, if a message was given. + */ +static void +check_raise_parameters(PLpgSQL_stmt_raise *stmt) +{ + char *cp; + int expected_nparams = 0; + + if (stmt->message == NULL) + return; + + for (cp = stmt->message; *cp; cp++) + { + if (cp[0] == '%') + { + /* ignore literal % characters */ + if (cp[1] == '%') + cp++; + else + expected_nparams++; + } + } + + if (expected_nparams < list_length(stmt->params)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("too many parameters specified for RAISE"))); + if (expected_nparams > list_length(stmt->params)) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("too few parameters specified for RAISE"))); +} + +/* + * Fix up CASE statement + */ +static PLpgSQL_stmt * +make_case(int location, PLpgSQL_expr *t_expr, + List *case_when_list, List *else_stmts) +{ + PLpgSQL_stmt_case *new; + + new = palloc(sizeof(PLpgSQL_stmt_case)); + new->cmd_type = PLPGSQL_STMT_CASE; + new->lineno = plpgsql_location_to_lineno(location); + new->stmtid = ++plpgsql_curr_compile->nstatements; + new->t_expr = t_expr; + new->t_varno = 0; + new->case_when_list = case_when_list; + new->have_else = (else_stmts != NIL); + /* Get rid of list-with-NULL hack */ + if (list_length(else_stmts) == 1 && linitial(else_stmts) == NULL) + new->else_stmts = NIL; + else + new->else_stmts = else_stmts; + + /* + * When test expression is present, we create a var for it and then + * convert all the WHEN expressions to "VAR IN (original_expression)". + * This is a bit klugy, but okay since we haven't yet done more than + * read the expressions as text. (Note that previous parsing won't + * have complained if the WHEN ... THEN expression contained multiple + * comma-separated values.) + */ + if (t_expr) + { + char varname[32]; + PLpgSQL_var *t_var; + ListCell *l; + + /* use a name unlikely to collide with any user names */ + snprintf(varname, sizeof(varname), "__Case__Variable_%d__", + plpgsql_nDatums); + + /* + * We don't yet know the result datatype of t_expr. Build the + * variable as if it were INT4; we'll fix this at runtime if needed. + */ + t_var = (PLpgSQL_var *) + plpgsql_build_variable(varname, new->lineno, + plpgsql_build_datatype(INT4OID, + -1, + InvalidOid, + NULL), + true); + new->t_varno = t_var->dno; + + foreach(l, case_when_list) + { + PLpgSQL_case_when *cwt = (PLpgSQL_case_when *) lfirst(l); + PLpgSQL_expr *expr = cwt->expr; + StringInfoData ds; + + /* We expect to have expressions not statements */ + Assert(expr->parseMode == RAW_PARSE_PLPGSQL_EXPR); + + /* Do the string hacking */ + initStringInfo(&ds); + + appendStringInfo(&ds, "\"%s\" IN (%s)", + varname, expr->query); + + pfree(expr->query); + expr->query = pstrdup(ds.data); + /* Adjust expr's namespace to include the case variable */ + expr->ns = plpgsql_ns_top(); + + pfree(ds.data); + } + } + + return (PLpgSQL_stmt *) new; +} diff --git a/internal/reference/pl_reserved_kwlist.h b/internal/reference/pl_reserved_kwlist.h new file mode 100644 index 0000000..d338e9f --- /dev/null +++ b/internal/reference/pl_reserved_kwlist.h @@ -0,0 +1,52 @@ +/*------------------------------------------------------------------------- + * + * pl_reserved_kwlist.h + * + * The keyword lists are kept in their own source files for use by + * automatic tools. The exact representation of a keyword is determined + * by the PG_KEYWORD macro, which is not defined in this file; it can + * be defined by the caller for special purposes. + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/pl/plpgsql/src/pl_reserved_kwlist.h + * + *------------------------------------------------------------------------- + */ + +/* There is deliberately not an #ifndef PL_RESERVED_KWLIST_H here. */ + +/* + * List of (keyword-name, keyword-token-value) pairs. + * + * Be careful not to put the same word into pl_unreserved_kwlist.h. + * + * Note: gen_keywordlist.pl requires the entries to appear in ASCII order. + */ + +/* name, value */ +PG_KEYWORD("all", K_ALL) +PG_KEYWORD("begin", K_BEGIN) +PG_KEYWORD("by", K_BY) +PG_KEYWORD("case", K_CASE) +PG_KEYWORD("declare", K_DECLARE) +PG_KEYWORD("else", K_ELSE) +PG_KEYWORD("end", K_END) +PG_KEYWORD("execute", K_EXECUTE) +PG_KEYWORD("for", K_FOR) +PG_KEYWORD("foreach", K_FOREACH) +PG_KEYWORD("from", K_FROM) +PG_KEYWORD("if", K_IF) +PG_KEYWORD("in", K_IN) +PG_KEYWORD("into", K_INTO) +PG_KEYWORD("loop", K_LOOP) +PG_KEYWORD("not", K_NOT) +PG_KEYWORD("null", K_NULL) +PG_KEYWORD("or", K_OR) +PG_KEYWORD("strict", K_STRICT) +PG_KEYWORD("then", K_THEN) +PG_KEYWORD("to", K_TO) +PG_KEYWORD("using", K_USING) +PG_KEYWORD("when", K_WHEN) +PG_KEYWORD("while", K_WHILE) diff --git a/internal/reference/pl_scanner.c b/internal/reference/pl_scanner.c new file mode 100644 index 0000000..51919fe --- /dev/null +++ b/internal/reference/pl_scanner.c @@ -0,0 +1,642 @@ +/*------------------------------------------------------------------------- + * + * pl_scanner.c + * lexical scanning for PL/pgSQL + * + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * src/pl/plpgsql/src/pl_scanner.c + * + *------------------------------------------------------------------------- + */ +#include "postgres.h" + +#include "mb/pg_wchar.h" +#include "parser/scanner.h" + +#include "plpgsql.h" +#include "pl_gram.h" /* must be after parser/scanner.h */ + + +/* Klugy flag to tell scanner how to look up identifiers */ +IdentifierLookup plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL; + +/* + * A word about keywords: + * + * We keep reserved and unreserved keywords in separate headers. Be careful + * not to put the same word in both headers. Also be sure that pl_gram.y's + * unreserved_keyword production agrees with the unreserved header. The + * reserved keywords are passed to the core scanner, so they will be + * recognized before (and instead of) any variable name. Unreserved words + * are checked for separately, usually after determining that the identifier + * isn't a known variable name. If plpgsql_IdentifierLookup is DECLARE then + * no variable names will be recognized, so the unreserved words always work. + * (Note in particular that this helps us avoid reserving keywords that are + * only needed in DECLARE sections.) + * + * In certain contexts it is desirable to prefer recognizing an unreserved + * keyword over recognizing a variable name. In particular, at the start + * of a statement we should prefer unreserved keywords unless the statement + * looks like an assignment (i.e., first token is followed by ':=' or '['). + * This rule allows most statement-introducing keywords to be kept unreserved. + * (We still have to reserve initial keywords that might follow a block + * label, unfortunately, since the method used to determine if we are at + * start of statement doesn't recognize such cases. We'd also have to + * reserve any keyword that could legitimately be followed by ':=' or '['.) + * Some additional cases are handled in pl_gram.y using tok_is_keyword(). + * + * We try to avoid reserving more keywords than we have to; but there's + * little point in not reserving a word if it's reserved in the core grammar. + * Currently, the following words are reserved here but not in the core: + * BEGIN BY DECLARE EXECUTE FOREACH IF LOOP STRICT WHILE + */ + +/* ScanKeywordList lookup data for PL/pgSQL keywords */ +#include "pl_reserved_kwlist_d.h" +#include "pl_unreserved_kwlist_d.h" + +/* Token codes for PL/pgSQL keywords */ +#define PG_KEYWORD(kwname, value) value, + +static const uint16 ReservedPLKeywordTokens[] = { +#include "pl_reserved_kwlist.h" +}; + +static const uint16 UnreservedPLKeywordTokens[] = { +#include "pl_unreserved_kwlist.h" +}; + +#undef PG_KEYWORD + +/* + * This macro must recognize all tokens that can immediately precede a + * PL/pgSQL executable statement (that is, proc_sect or proc_stmt in the + * grammar). Fortunately, there are not very many, so hard-coding in this + * fashion seems sufficient. + */ +#define AT_STMT_START(prev_token) \ + ((prev_token) == ';' || \ + (prev_token) == K_BEGIN || \ + (prev_token) == K_THEN || \ + (prev_token) == K_ELSE || \ + (prev_token) == K_LOOP) + + +/* Auxiliary data about a token (other than the token type) */ +typedef struct +{ + YYSTYPE lval; /* semantic information */ + YYLTYPE lloc; /* offset in scanbuf */ + int leng; /* length in bytes */ +} TokenAuxData; + +/* + * Scanner working state. At some point we might wish to fold all this + * into a YY_EXTRA struct. For the moment, there is no need for plpgsql's + * lexer to be re-entrant, and the notational burden of passing a yyscanner + * pointer around is great enough to not want to do it without need. + */ + +/* The stuff the core lexer needs */ +static core_yyscan_t yyscanner = NULL; +static core_yy_extra_type core_yy; + +/* The original input string */ +static const char *scanorig; + +/* Current token's length (corresponds to plpgsql_yylval and plpgsql_yylloc) */ +static int plpgsql_yyleng; + +/* Current token's code (corresponds to plpgsql_yylval and plpgsql_yylloc) */ +static int plpgsql_yytoken; + +/* Token pushback stack */ +#define MAX_PUSHBACKS 4 + +static int num_pushbacks; +static int pushback_token[MAX_PUSHBACKS]; +static TokenAuxData pushback_auxdata[MAX_PUSHBACKS]; + +/* State for plpgsql_location_to_lineno() */ +static const char *cur_line_start; +static const char *cur_line_end; +static int cur_line_num; + +/* Internal functions */ +static int internal_yylex(TokenAuxData *auxdata); +static void push_back_token(int token, TokenAuxData *auxdata); +static void location_lineno_init(void); + + +/* + * This is the yylex routine called from the PL/pgSQL grammar. + * It is a wrapper around the core lexer, with the ability to recognize + * PL/pgSQL variables and return them as special T_DATUM tokens. If a + * word or compound word does not match any variable name, or if matching + * is turned off by plpgsql_IdentifierLookup, it is returned as + * T_WORD or T_CWORD respectively, or as an unreserved keyword if it + * matches one of those. + */ +int +plpgsql_yylex(void) +{ + int tok1; + TokenAuxData aux1; + int kwnum; + + tok1 = internal_yylex(&aux1); + if (tok1 == IDENT || tok1 == PARAM) + { + int tok2; + TokenAuxData aux2; + + tok2 = internal_yylex(&aux2); + if (tok2 == '.') + { + int tok3; + TokenAuxData aux3; + + tok3 = internal_yylex(&aux3); + if (tok3 == IDENT) + { + int tok4; + TokenAuxData aux4; + + tok4 = internal_yylex(&aux4); + if (tok4 == '.') + { + int tok5; + TokenAuxData aux5; + + tok5 = internal_yylex(&aux5); + if (tok5 == IDENT) + { + if (plpgsql_parse_tripword(aux1.lval.str, + aux3.lval.str, + aux5.lval.str, + &aux1.lval.wdatum, + &aux1.lval.cword)) + tok1 = T_DATUM; + else + tok1 = T_CWORD; + /* Adjust token length to include A.B.C */ + aux1.leng = aux5.lloc - aux1.lloc + aux5.leng; + } + else + { + /* not A.B.C, so just process A.B */ + push_back_token(tok5, &aux5); + push_back_token(tok4, &aux4); + if (plpgsql_parse_dblword(aux1.lval.str, + aux3.lval.str, + &aux1.lval.wdatum, + &aux1.lval.cword)) + tok1 = T_DATUM; + else + tok1 = T_CWORD; + /* Adjust token length to include A.B */ + aux1.leng = aux3.lloc - aux1.lloc + aux3.leng; + } + } + else + { + /* not A.B.C, so just process A.B */ + push_back_token(tok4, &aux4); + if (plpgsql_parse_dblword(aux1.lval.str, + aux3.lval.str, + &aux1.lval.wdatum, + &aux1.lval.cword)) + tok1 = T_DATUM; + else + tok1 = T_CWORD; + /* Adjust token length to include A.B */ + aux1.leng = aux3.lloc - aux1.lloc + aux3.leng; + } + } + else + { + /* not A.B, so just process A */ + push_back_token(tok3, &aux3); + push_back_token(tok2, &aux2); + if (plpgsql_parse_word(aux1.lval.str, + core_yy.scanbuf + aux1.lloc, + true, + &aux1.lval.wdatum, + &aux1.lval.word)) + tok1 = T_DATUM; + else if (!aux1.lval.word.quoted && + (kwnum = ScanKeywordLookup(aux1.lval.word.ident, + &UnreservedPLKeywords)) >= 0) + { + aux1.lval.keyword = GetScanKeyword(kwnum, + &UnreservedPLKeywords); + tok1 = UnreservedPLKeywordTokens[kwnum]; + } + else + tok1 = T_WORD; + } + } + else + { + /* not A.B, so just process A */ + push_back_token(tok2, &aux2); + + /* + * See if it matches a variable name, except in the context where + * we are at start of statement and the next token isn't + * assignment or '['. In that case, it couldn't validly be a + * variable name, and skipping the lookup allows variable names to + * be used that would conflict with plpgsql or core keywords that + * introduce statements (e.g., "comment"). Without this special + * logic, every statement-introducing keyword would effectively be + * reserved in PL/pgSQL, which would be unpleasant. + * + * If it isn't a variable name, try to match against unreserved + * plpgsql keywords. If not one of those either, it's T_WORD. + * + * Note: we must call plpgsql_parse_word even if we don't want to + * do variable lookup, because it sets up aux1.lval.word for the + * non-variable cases. + */ + if (plpgsql_parse_word(aux1.lval.str, + core_yy.scanbuf + aux1.lloc, + (!AT_STMT_START(plpgsql_yytoken) || + (tok2 == '=' || tok2 == COLON_EQUALS || + tok2 == '[')), + &aux1.lval.wdatum, + &aux1.lval.word)) + tok1 = T_DATUM; + else if (!aux1.lval.word.quoted && + (kwnum = ScanKeywordLookup(aux1.lval.word.ident, + &UnreservedPLKeywords)) >= 0) + { + aux1.lval.keyword = GetScanKeyword(kwnum, + &UnreservedPLKeywords); + tok1 = UnreservedPLKeywordTokens[kwnum]; + } + else + tok1 = T_WORD; + } + } + else + { + /* + * Not a potential plpgsql variable name, just return the data. + * + * Note that we also come through here if the grammar pushed back a + * T_DATUM, T_CWORD, T_WORD, or unreserved-keyword token returned by a + * previous lookup cycle; thus, pushbacks do not incur extra lookup + * work, since we'll never do the above code twice for the same token. + * This property also makes it safe to rely on the old value of + * plpgsql_yytoken in the is-this-start-of-statement test above. + */ + } + + plpgsql_yylval = aux1.lval; + plpgsql_yylloc = aux1.lloc; + plpgsql_yyleng = aux1.leng; + plpgsql_yytoken = tok1; + return tok1; +} + +/* + * Return the length of the token last returned by plpgsql_yylex(). + * + * In the case of compound tokens, the length includes all the parts. + */ +int +plpgsql_token_length(void) +{ + return plpgsql_yyleng; +} + +/* + * Internal yylex function. This wraps the core lexer and adds one feature: + * a token pushback stack. We also make a couple of trivial single-token + * translations from what the core lexer does to what we want, in particular + * interfacing from the core_YYSTYPE to YYSTYPE union. + */ +static int +internal_yylex(TokenAuxData *auxdata) +{ + int token; + const char *yytext; + + if (num_pushbacks > 0) + { + num_pushbacks--; + token = pushback_token[num_pushbacks]; + *auxdata = pushback_auxdata[num_pushbacks]; + } + else + { + token = core_yylex(&auxdata->lval.core_yystype, + &auxdata->lloc, + yyscanner); + + /* remember the length of yytext before it gets changed */ + yytext = core_yy.scanbuf + auxdata->lloc; + auxdata->leng = strlen(yytext); + + /* Check for << >> and #, which the core considers operators */ + if (token == Op) + { + if (strcmp(auxdata->lval.str, "<<") == 0) + token = LESS_LESS; + else if (strcmp(auxdata->lval.str, ">>") == 0) + token = GREATER_GREATER; + else if (strcmp(auxdata->lval.str, "#") == 0) + token = '#'; + } + + /* The core returns PARAM as ival, but we treat it like IDENT */ + else if (token == PARAM) + { + auxdata->lval.str = pstrdup(yytext); + } + + else if (token == SQL_COMMENT || token == C_COMMENT) + { + token = internal_yylex(auxdata); + } + } + + return token; +} + +/* + * Push back a token to be re-read by next internal_yylex() call. + */ +static void +push_back_token(int token, TokenAuxData *auxdata) +{ + if (num_pushbacks >= MAX_PUSHBACKS) + elog(ERROR, "too many tokens pushed back"); + pushback_token[num_pushbacks] = token; + pushback_auxdata[num_pushbacks] = *auxdata; + num_pushbacks++; +} + +/* + * Push back a single token to be re-read by next plpgsql_yylex() call. + * + * NOTE: this does not cause yylval or yylloc to "back up". Also, it + * is not a good idea to push back a token code other than what you read. + */ +void +plpgsql_push_back_token(int token) +{ + TokenAuxData auxdata; + + auxdata.lval = plpgsql_yylval; + auxdata.lloc = plpgsql_yylloc; + auxdata.leng = plpgsql_yyleng; + push_back_token(token, &auxdata); +} + +/* + * Tell whether a token is an unreserved keyword. + * + * (If it is, its lowercased form was returned as the token value, so we + * do not need to offer that data here.) + */ +bool +plpgsql_token_is_unreserved_keyword(int token) +{ + int i; + + for (i = 0; i < lengthof(UnreservedPLKeywordTokens); i++) + { + if (UnreservedPLKeywordTokens[i] == token) + return true; + } + return false; +} + +/* + * Append the function text starting at startlocation and extending to + * (not including) endlocation onto the existing contents of "buf". + */ +void +plpgsql_append_source_text(StringInfo buf, + int startlocation, int endlocation) +{ + Assert(startlocation <= endlocation); + appendBinaryStringInfo(buf, scanorig + startlocation, + endlocation - startlocation); +} + +/* + * Peek one token ahead in the input stream. Only the token code is + * made available, not any of the auxiliary info such as location. + * + * NB: no variable or unreserved keyword lookup is performed here, they will + * be returned as IDENT. Reserved keywords are resolved as usual. + */ +int +plpgsql_peek(void) +{ + int tok1; + TokenAuxData aux1; + + tok1 = internal_yylex(&aux1); + push_back_token(tok1, &aux1); + return tok1; +} + +/* + * Peek two tokens ahead in the input stream. The first token and its + * location in the query are returned in *tok1_p and *tok1_loc, second token + * and its location in *tok2_p and *tok2_loc. + * + * NB: no variable or unreserved keyword lookup is performed here, they will + * be returned as IDENT. Reserved keywords are resolved as usual. + */ +void +plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc, int *tok2_loc) +{ + int tok1, + tok2; + TokenAuxData aux1, + aux2; + + tok1 = internal_yylex(&aux1); + tok2 = internal_yylex(&aux2); + + *tok1_p = tok1; + if (tok1_loc) + *tok1_loc = aux1.lloc; + *tok2_p = tok2; + if (tok2_loc) + *tok2_loc = aux2.lloc; + + push_back_token(tok2, &aux2); + push_back_token(tok1, &aux1); +} + +/* + * plpgsql_scanner_errposition + * Report an error cursor position, if possible. + * + * This is expected to be used within an ereport() call. The return value + * is a dummy (always 0, in fact). + * + * Note that this can only be used for messages emitted during initial + * parsing of a plpgsql function, since it requires the scanorig string + * to still be available. + */ +int +plpgsql_scanner_errposition(int location) +{ + int pos; + + if (location < 0 || scanorig == NULL) + return 0; /* no-op if location is unknown */ + + /* Convert byte offset to character number */ + pos = pg_mbstrlen_with_len(scanorig, location) + 1; + /* And pass it to the ereport mechanism */ + (void) internalerrposition(pos); + /* Also pass the function body string */ + return internalerrquery(scanorig); +} + +/* + * plpgsql_yyerror + * Report a lexer or grammar error. + * + * The message's cursor position refers to the current token (the one + * last returned by plpgsql_yylex()). + * This is OK for syntax error messages from the Bison parser, because Bison + * parsers report error as soon as the first unparsable token is reached. + * Beware of using yyerror for other purposes, as the cursor position might + * be misleading! + */ +void +plpgsql_yyerror(const char *message) +{ + char *yytext = core_yy.scanbuf + plpgsql_yylloc; + + if (*yytext == '\0') + { + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + /* translator: %s is typically the translation of "syntax error" */ + errmsg("%s at end of input", _(message)), + plpgsql_scanner_errposition(plpgsql_yylloc))); + } + else + { + /* + * If we have done any lookahead then flex will have restored the + * character after the end-of-token. Zap it again so that we report + * only the single token here. This modifies scanbuf but we no longer + * care about that. + */ + yytext[plpgsql_yyleng] = '\0'; + + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + /* translator: first %s is typically the translation of "syntax error" */ + errmsg("%s at or near \"%s\"", _(message), yytext), + plpgsql_scanner_errposition(plpgsql_yylloc))); + } +} + +/* + * Given a location (a byte offset in the function source text), + * return a line number. + * + * We expect that this is typically called for a sequence of increasing + * location values, so optimize accordingly by tracking the endpoints + * of the "current" line. + */ +int +plpgsql_location_to_lineno(int location) +{ + const char *loc; + + if (location < 0 || scanorig == NULL) + return 0; /* garbage in, garbage out */ + loc = scanorig + location; + + /* be correct, but not fast, if input location goes backwards */ + if (loc < cur_line_start) + location_lineno_init(); + + while (cur_line_end != NULL && loc > cur_line_end) + { + cur_line_start = cur_line_end + 1; + cur_line_num++; + cur_line_end = strchr(cur_line_start, '\n'); + } + + return cur_line_num; +} + +/* initialize or reset the state for plpgsql_location_to_lineno */ +static void +location_lineno_init(void) +{ + cur_line_start = scanorig; + cur_line_num = 1; + + cur_line_end = strchr(cur_line_start, '\n'); +} + +/* return the most recently computed lineno */ +int +plpgsql_latest_lineno(void) +{ + return cur_line_num; +} + + +/* + * Called before any actual parsing is done + * + * Note: the passed "str" must remain valid until plpgsql_scanner_finish(). + * Although it is not fed directly to flex, we need the original string + * to cite in error messages. + */ +void +plpgsql_scanner_init(const char *str) +{ + /* Start up the core scanner */ + yyscanner = scanner_init(str, &core_yy, + &ReservedPLKeywords, ReservedPLKeywordTokens); + + /* + * scanorig points to the original string, which unlike the scanner's + * scanbuf won't be modified on-the-fly by flex. Notice that although + * yytext points into scanbuf, we rely on being able to apply locations + * (offsets from string start) to scanorig as well. + */ + scanorig = str; + + /* Other setup */ + plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL; + plpgsql_yytoken = 0; + + num_pushbacks = 0; + + location_lineno_init(); +} + +/* + * Called after parsing is done to clean up after plpgsql_scanner_init() + */ +void +plpgsql_scanner_finish(void) +{ + /* release storage */ + scanner_finish(yyscanner); + /* avoid leaving any dangling pointers */ + yyscanner = NULL; + scanorig = NULL; +} diff --git a/internal/reference/pl_unreserved_kwlist.h b/internal/reference/pl_unreserved_kwlist.h new file mode 100644 index 0000000..670b4cf --- /dev/null +++ b/internal/reference/pl_unreserved_kwlist.h @@ -0,0 +1,112 @@ +/*------------------------------------------------------------------------- + * + * pl_unreserved_kwlist.h + * + * The keyword lists are kept in their own source files for use by + * automatic tools. The exact representation of a keyword is determined + * by the PG_KEYWORD macro, which is not defined in this file; it can + * be defined by the caller for special purposes. + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/pl/plpgsql/src/pl_unreserved_kwlist.h + * + *------------------------------------------------------------------------- + */ + +/* There is deliberately not an #ifndef PL_UNRESERVED_KWLIST_H here. */ + +/* + * List of (keyword-name, keyword-token-value) pairs. + * + * Be careful not to put the same word into pl_reserved_kwlist.h. Also be + * sure that pl_gram.y's unreserved_keyword production agrees with this list. + * + * Note: gen_keywordlist.pl requires the entries to appear in ASCII order. + */ + +/* name, value */ +PG_KEYWORD("absolute", K_ABSOLUTE) +PG_KEYWORD("alias", K_ALIAS) +PG_KEYWORD("and", K_AND) +PG_KEYWORD("array", K_ARRAY) +PG_KEYWORD("assert", K_ASSERT) +PG_KEYWORD("backward", K_BACKWARD) +PG_KEYWORD("call", K_CALL) +PG_KEYWORD("chain", K_CHAIN) +PG_KEYWORD("close", K_CLOSE) +PG_KEYWORD("collate", K_COLLATE) +PG_KEYWORD("column", K_COLUMN) +PG_KEYWORD("column_name", K_COLUMN_NAME) +PG_KEYWORD("commit", K_COMMIT) +PG_KEYWORD("constant", K_CONSTANT) +PG_KEYWORD("constraint", K_CONSTRAINT) +PG_KEYWORD("constraint_name", K_CONSTRAINT_NAME) +PG_KEYWORD("continue", K_CONTINUE) +PG_KEYWORD("current", K_CURRENT) +PG_KEYWORD("cursor", K_CURSOR) +PG_KEYWORD("datatype", K_DATATYPE) +PG_KEYWORD("debug", K_DEBUG) +PG_KEYWORD("default", K_DEFAULT) +PG_KEYWORD("detail", K_DETAIL) +PG_KEYWORD("diagnostics", K_DIAGNOSTICS) +PG_KEYWORD("do", K_DO) +PG_KEYWORD("dump", K_DUMP) +PG_KEYWORD("elseif", K_ELSIF) +PG_KEYWORD("elsif", K_ELSIF) +PG_KEYWORD("errcode", K_ERRCODE) +PG_KEYWORD("error", K_ERROR) +PG_KEYWORD("exception", K_EXCEPTION) +PG_KEYWORD("exit", K_EXIT) +PG_KEYWORD("fetch", K_FETCH) +PG_KEYWORD("first", K_FIRST) +PG_KEYWORD("forward", K_FORWARD) +PG_KEYWORD("get", K_GET) +PG_KEYWORD("hint", K_HINT) +PG_KEYWORD("import", K_IMPORT) +PG_KEYWORD("info", K_INFO) +PG_KEYWORD("insert", K_INSERT) +PG_KEYWORD("is", K_IS) +PG_KEYWORD("last", K_LAST) +PG_KEYWORD("log", K_LOG) +PG_KEYWORD("merge", K_MERGE) +PG_KEYWORD("message", K_MESSAGE) +PG_KEYWORD("message_text", K_MESSAGE_TEXT) +PG_KEYWORD("move", K_MOVE) +PG_KEYWORD("next", K_NEXT) +PG_KEYWORD("no", K_NO) +PG_KEYWORD("notice", K_NOTICE) +PG_KEYWORD("open", K_OPEN) +PG_KEYWORD("option", K_OPTION) +PG_KEYWORD("perform", K_PERFORM) +PG_KEYWORD("pg_context", K_PG_CONTEXT) +PG_KEYWORD("pg_datatype_name", K_PG_DATATYPE_NAME) +PG_KEYWORD("pg_exception_context", K_PG_EXCEPTION_CONTEXT) +PG_KEYWORD("pg_exception_detail", K_PG_EXCEPTION_DETAIL) +PG_KEYWORD("pg_exception_hint", K_PG_EXCEPTION_HINT) +PG_KEYWORD("pg_routine_oid", K_PG_ROUTINE_OID) +PG_KEYWORD("print_strict_params", K_PRINT_STRICT_PARAMS) +PG_KEYWORD("prior", K_PRIOR) +PG_KEYWORD("query", K_QUERY) +PG_KEYWORD("raise", K_RAISE) +PG_KEYWORD("relative", K_RELATIVE) +PG_KEYWORD("return", K_RETURN) +PG_KEYWORD("returned_sqlstate", K_RETURNED_SQLSTATE) +PG_KEYWORD("reverse", K_REVERSE) +PG_KEYWORD("rollback", K_ROLLBACK) +PG_KEYWORD("row_count", K_ROW_COUNT) +PG_KEYWORD("rowtype", K_ROWTYPE) +PG_KEYWORD("schema", K_SCHEMA) +PG_KEYWORD("schema_name", K_SCHEMA_NAME) +PG_KEYWORD("scroll", K_SCROLL) +PG_KEYWORD("slice", K_SLICE) +PG_KEYWORD("sqlstate", K_SQLSTATE) +PG_KEYWORD("stacked", K_STACKED) +PG_KEYWORD("table", K_TABLE) +PG_KEYWORD("table_name", K_TABLE_NAME) +PG_KEYWORD("type", K_TYPE) +PG_KEYWORD("use_column", K_USE_COLUMN) +PG_KEYWORD("use_variable", K_USE_VARIABLE) +PG_KEYWORD("variable_conflict", K_VARIABLE_CONFLICT) +PG_KEYWORD("warning", K_WARNING) diff --git a/internal/reference/plerrcodes.h b/internal/reference/plerrcodes.h new file mode 100644 index 0000000..c9900ac --- /dev/null +++ b/internal/reference/plerrcodes.h @@ -0,0 +1,998 @@ +/* autogenerated from src/backend/utils/errcodes.txt, do not edit */ +/* there is deliberately not an #ifndef PLERRCODES_H here */ + +{ + "sql_statement_not_yet_complete", ERRCODE_SQL_STATEMENT_NOT_YET_COMPLETE +}, + +{ + "connection_exception", ERRCODE_CONNECTION_EXCEPTION +}, + +{ + "connection_does_not_exist", ERRCODE_CONNECTION_DOES_NOT_EXIST +}, + +{ + "connection_failure", ERRCODE_CONNECTION_FAILURE +}, + +{ + "sqlclient_unable_to_establish_sqlconnection", ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION +}, + +{ + "sqlserver_rejected_establishment_of_sqlconnection", ERRCODE_SQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION +}, + +{ + "transaction_resolution_unknown", ERRCODE_TRANSACTION_RESOLUTION_UNKNOWN +}, + +{ + "protocol_violation", ERRCODE_PROTOCOL_VIOLATION +}, + +{ + "triggered_action_exception", ERRCODE_TRIGGERED_ACTION_EXCEPTION +}, + +{ + "feature_not_supported", ERRCODE_FEATURE_NOT_SUPPORTED +}, + +{ + "invalid_transaction_initiation", ERRCODE_INVALID_TRANSACTION_INITIATION +}, + +{ + "locator_exception", ERRCODE_LOCATOR_EXCEPTION +}, + +{ + "invalid_locator_specification", ERRCODE_L_E_INVALID_SPECIFICATION +}, + +{ + "invalid_grantor", ERRCODE_INVALID_GRANTOR +}, + +{ + "invalid_grant_operation", ERRCODE_INVALID_GRANT_OPERATION +}, + +{ + "invalid_role_specification", ERRCODE_INVALID_ROLE_SPECIFICATION +}, + +{ + "diagnostics_exception", ERRCODE_DIAGNOSTICS_EXCEPTION +}, + +{ + "stacked_diagnostics_accessed_without_active_handler", ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER +}, + +{ + "case_not_found", ERRCODE_CASE_NOT_FOUND +}, + +{ + "cardinality_violation", ERRCODE_CARDINALITY_VIOLATION +}, + +{ + "data_exception", ERRCODE_DATA_EXCEPTION +}, + +{ + "array_subscript_error", ERRCODE_ARRAY_SUBSCRIPT_ERROR +}, + +{ + "character_not_in_repertoire", ERRCODE_CHARACTER_NOT_IN_REPERTOIRE +}, + +{ + "datetime_field_overflow", ERRCODE_DATETIME_FIELD_OVERFLOW +}, + +{ + "division_by_zero", ERRCODE_DIVISION_BY_ZERO +}, + +{ + "error_in_assignment", ERRCODE_ERROR_IN_ASSIGNMENT +}, + +{ + "escape_character_conflict", ERRCODE_ESCAPE_CHARACTER_CONFLICT +}, + +{ + "indicator_overflow", ERRCODE_INDICATOR_OVERFLOW +}, + +{ + "interval_field_overflow", ERRCODE_INTERVAL_FIELD_OVERFLOW +}, + +{ + "invalid_argument_for_logarithm", ERRCODE_INVALID_ARGUMENT_FOR_LOG +}, + +{ + "invalid_argument_for_ntile_function", ERRCODE_INVALID_ARGUMENT_FOR_NTILE +}, + +{ + "invalid_argument_for_nth_value_function", ERRCODE_INVALID_ARGUMENT_FOR_NTH_VALUE +}, + +{ + "invalid_argument_for_power_function", ERRCODE_INVALID_ARGUMENT_FOR_POWER_FUNCTION +}, + +{ + "invalid_argument_for_width_bucket_function", ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION +}, + +{ + "invalid_character_value_for_cast", ERRCODE_INVALID_CHARACTER_VALUE_FOR_CAST +}, + +{ + "invalid_datetime_format", ERRCODE_INVALID_DATETIME_FORMAT +}, + +{ + "invalid_escape_character", ERRCODE_INVALID_ESCAPE_CHARACTER +}, + +{ + "invalid_escape_octet", ERRCODE_INVALID_ESCAPE_OCTET +}, + +{ + "invalid_escape_sequence", ERRCODE_INVALID_ESCAPE_SEQUENCE +}, + +{ + "nonstandard_use_of_escape_character", ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER +}, + +{ + "invalid_indicator_parameter_value", ERRCODE_INVALID_INDICATOR_PARAMETER_VALUE +}, + +{ + "invalid_parameter_value", ERRCODE_INVALID_PARAMETER_VALUE +}, + +{ + "invalid_preceding_or_following_size", ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE +}, + +{ + "invalid_regular_expression", ERRCODE_INVALID_REGULAR_EXPRESSION +}, + +{ + "invalid_row_count_in_limit_clause", ERRCODE_INVALID_ROW_COUNT_IN_LIMIT_CLAUSE +}, + +{ + "invalid_row_count_in_result_offset_clause", ERRCODE_INVALID_ROW_COUNT_IN_RESULT_OFFSET_CLAUSE +}, + +{ + "invalid_tablesample_argument", ERRCODE_INVALID_TABLESAMPLE_ARGUMENT +}, + +{ + "invalid_tablesample_repeat", ERRCODE_INVALID_TABLESAMPLE_REPEAT +}, + +{ + "invalid_time_zone_displacement_value", ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE +}, + +{ + "invalid_use_of_escape_character", ERRCODE_INVALID_USE_OF_ESCAPE_CHARACTER +}, + +{ + "most_specific_type_mismatch", ERRCODE_MOST_SPECIFIC_TYPE_MISMATCH +}, + +{ + "null_value_not_allowed", ERRCODE_NULL_VALUE_NOT_ALLOWED +}, + +{ + "null_value_no_indicator_parameter", ERRCODE_NULL_VALUE_NO_INDICATOR_PARAMETER +}, + +{ + "numeric_value_out_of_range", ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE +}, + +{ + "sequence_generator_limit_exceeded", ERRCODE_SEQUENCE_GENERATOR_LIMIT_EXCEEDED +}, + +{ + "string_data_length_mismatch", ERRCODE_STRING_DATA_LENGTH_MISMATCH +}, + +{ + "string_data_right_truncation", ERRCODE_STRING_DATA_RIGHT_TRUNCATION +}, + +{ + "substring_error", ERRCODE_SUBSTRING_ERROR +}, + +{ + "trim_error", ERRCODE_TRIM_ERROR +}, + +{ + "unterminated_c_string", ERRCODE_UNTERMINATED_C_STRING +}, + +{ + "zero_length_character_string", ERRCODE_ZERO_LENGTH_CHARACTER_STRING +}, + +{ + "floating_point_exception", ERRCODE_FLOATING_POINT_EXCEPTION +}, + +{ + "invalid_text_representation", ERRCODE_INVALID_TEXT_REPRESENTATION +}, + +{ + "invalid_binary_representation", ERRCODE_INVALID_BINARY_REPRESENTATION +}, + +{ + "bad_copy_file_format", ERRCODE_BAD_COPY_FILE_FORMAT +}, + +{ + "untranslatable_character", ERRCODE_UNTRANSLATABLE_CHARACTER +}, + +{ + "not_an_xml_document", ERRCODE_NOT_AN_XML_DOCUMENT +}, + +{ + "invalid_xml_document", ERRCODE_INVALID_XML_DOCUMENT +}, + +{ + "invalid_xml_content", ERRCODE_INVALID_XML_CONTENT +}, + +{ + "invalid_xml_comment", ERRCODE_INVALID_XML_COMMENT +}, + +{ + "invalid_xml_processing_instruction", ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION +}, + +{ + "duplicate_json_object_key_value", ERRCODE_DUPLICATE_JSON_OBJECT_KEY_VALUE +}, + +{ + "invalid_argument_for_sql_json_datetime_function", ERRCODE_INVALID_ARGUMENT_FOR_SQL_JSON_DATETIME_FUNCTION +}, + +{ + "invalid_json_text", ERRCODE_INVALID_JSON_TEXT +}, + +{ + "invalid_sql_json_subscript", ERRCODE_INVALID_SQL_JSON_SUBSCRIPT +}, + +{ + "more_than_one_sql_json_item", ERRCODE_MORE_THAN_ONE_SQL_JSON_ITEM +}, + +{ + "no_sql_json_item", ERRCODE_NO_SQL_JSON_ITEM +}, + +{ + "non_numeric_sql_json_item", ERRCODE_NON_NUMERIC_SQL_JSON_ITEM +}, + +{ + "non_unique_keys_in_a_json_object", ERRCODE_NON_UNIQUE_KEYS_IN_A_JSON_OBJECT +}, + +{ + "singleton_sql_json_item_required", ERRCODE_SINGLETON_SQL_JSON_ITEM_REQUIRED +}, + +{ + "sql_json_array_not_found", ERRCODE_SQL_JSON_ARRAY_NOT_FOUND +}, + +{ + "sql_json_member_not_found", ERRCODE_SQL_JSON_MEMBER_NOT_FOUND +}, + +{ + "sql_json_number_not_found", ERRCODE_SQL_JSON_NUMBER_NOT_FOUND +}, + +{ + "sql_json_object_not_found", ERRCODE_SQL_JSON_OBJECT_NOT_FOUND +}, + +{ + "too_many_json_array_elements", ERRCODE_TOO_MANY_JSON_ARRAY_ELEMENTS +}, + +{ + "too_many_json_object_members", ERRCODE_TOO_MANY_JSON_OBJECT_MEMBERS +}, + +{ + "sql_json_scalar_required", ERRCODE_SQL_JSON_SCALAR_REQUIRED +}, + +{ + "sql_json_item_cannot_be_cast_to_target_type", ERRCODE_SQL_JSON_ITEM_CANNOT_BE_CAST_TO_TARGET_TYPE +}, + +{ + "integrity_constraint_violation", ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION +}, + +{ + "restrict_violation", ERRCODE_RESTRICT_VIOLATION +}, + +{ + "not_null_violation", ERRCODE_NOT_NULL_VIOLATION +}, + +{ + "foreign_key_violation", ERRCODE_FOREIGN_KEY_VIOLATION +}, + +{ + "unique_violation", ERRCODE_UNIQUE_VIOLATION +}, + +{ + "check_violation", ERRCODE_CHECK_VIOLATION +}, + +{ + "exclusion_violation", ERRCODE_EXCLUSION_VIOLATION +}, + +{ + "invalid_cursor_state", ERRCODE_INVALID_CURSOR_STATE +}, + +{ + "invalid_transaction_state", ERRCODE_INVALID_TRANSACTION_STATE +}, + +{ + "active_sql_transaction", ERRCODE_ACTIVE_SQL_TRANSACTION +}, + +{ + "branch_transaction_already_active", ERRCODE_BRANCH_TRANSACTION_ALREADY_ACTIVE +}, + +{ + "held_cursor_requires_same_isolation_level", ERRCODE_HELD_CURSOR_REQUIRES_SAME_ISOLATION_LEVEL +}, + +{ + "inappropriate_access_mode_for_branch_transaction", ERRCODE_INAPPROPRIATE_ACCESS_MODE_FOR_BRANCH_TRANSACTION +}, + +{ + "inappropriate_isolation_level_for_branch_transaction", ERRCODE_INAPPROPRIATE_ISOLATION_LEVEL_FOR_BRANCH_TRANSACTION +}, + +{ + "no_active_sql_transaction_for_branch_transaction", ERRCODE_NO_ACTIVE_SQL_TRANSACTION_FOR_BRANCH_TRANSACTION +}, + +{ + "read_only_sql_transaction", ERRCODE_READ_ONLY_SQL_TRANSACTION +}, + +{ + "schema_and_data_statement_mixing_not_supported", ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED +}, + +{ + "no_active_sql_transaction", ERRCODE_NO_ACTIVE_SQL_TRANSACTION +}, + +{ + "in_failed_sql_transaction", ERRCODE_IN_FAILED_SQL_TRANSACTION +}, + +{ + "idle_in_transaction_session_timeout", ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT +}, + +{ + "transaction_timeout", ERRCODE_TRANSACTION_TIMEOUT +}, + +{ + "invalid_sql_statement_name", ERRCODE_INVALID_SQL_STATEMENT_NAME +}, + +{ + "triggered_data_change_violation", ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION +}, + +{ + "invalid_authorization_specification", ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION +}, + +{ + "invalid_password", ERRCODE_INVALID_PASSWORD +}, + +{ + "dependent_privilege_descriptors_still_exist", ERRCODE_DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST +}, + +{ + "dependent_objects_still_exist", ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST +}, + +{ + "invalid_transaction_termination", ERRCODE_INVALID_TRANSACTION_TERMINATION +}, + +{ + "sql_routine_exception", ERRCODE_SQL_ROUTINE_EXCEPTION +}, + +{ + "function_executed_no_return_statement", ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT +}, + +{ + "modifying_sql_data_not_permitted", ERRCODE_S_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED +}, + +{ + "prohibited_sql_statement_attempted", ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED +}, + +{ + "reading_sql_data_not_permitted", ERRCODE_S_R_E_READING_SQL_DATA_NOT_PERMITTED +}, + +{ + "invalid_cursor_name", ERRCODE_INVALID_CURSOR_NAME +}, + +{ + "external_routine_exception", ERRCODE_EXTERNAL_ROUTINE_EXCEPTION +}, + +{ + "containing_sql_not_permitted", ERRCODE_E_R_E_CONTAINING_SQL_NOT_PERMITTED +}, + +{ + "modifying_sql_data_not_permitted", ERRCODE_E_R_E_MODIFYING_SQL_DATA_NOT_PERMITTED +}, + +{ + "prohibited_sql_statement_attempted", ERRCODE_E_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED +}, + +{ + "reading_sql_data_not_permitted", ERRCODE_E_R_E_READING_SQL_DATA_NOT_PERMITTED +}, + +{ + "external_routine_invocation_exception", ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION +}, + +{ + "invalid_sqlstate_returned", ERRCODE_E_R_I_E_INVALID_SQLSTATE_RETURNED +}, + +{ + "null_value_not_allowed", ERRCODE_E_R_I_E_NULL_VALUE_NOT_ALLOWED +}, + +{ + "trigger_protocol_violated", ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED +}, + +{ + "srf_protocol_violated", ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED +}, + +{ + "event_trigger_protocol_violated", ERRCODE_E_R_I_E_EVENT_TRIGGER_PROTOCOL_VIOLATED +}, + +{ + "savepoint_exception", ERRCODE_SAVEPOINT_EXCEPTION +}, + +{ + "invalid_savepoint_specification", ERRCODE_S_E_INVALID_SPECIFICATION +}, + +{ + "invalid_catalog_name", ERRCODE_INVALID_CATALOG_NAME +}, + +{ + "invalid_schema_name", ERRCODE_INVALID_SCHEMA_NAME +}, + +{ + "transaction_rollback", ERRCODE_TRANSACTION_ROLLBACK +}, + +{ + "transaction_integrity_constraint_violation", ERRCODE_T_R_INTEGRITY_CONSTRAINT_VIOLATION +}, + +{ + "serialization_failure", ERRCODE_T_R_SERIALIZATION_FAILURE +}, + +{ + "statement_completion_unknown", ERRCODE_T_R_STATEMENT_COMPLETION_UNKNOWN +}, + +{ + "deadlock_detected", ERRCODE_T_R_DEADLOCK_DETECTED +}, + +{ + "syntax_error_or_access_rule_violation", ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION +}, + +{ + "syntax_error", ERRCODE_SYNTAX_ERROR +}, + +{ + "insufficient_privilege", ERRCODE_INSUFFICIENT_PRIVILEGE +}, + +{ + "cannot_coerce", ERRCODE_CANNOT_COERCE +}, + +{ + "grouping_error", ERRCODE_GROUPING_ERROR +}, + +{ + "windowing_error", ERRCODE_WINDOWING_ERROR +}, + +{ + "invalid_recursion", ERRCODE_INVALID_RECURSION +}, + +{ + "invalid_foreign_key", ERRCODE_INVALID_FOREIGN_KEY +}, + +{ + "invalid_name", ERRCODE_INVALID_NAME +}, + +{ + "name_too_long", ERRCODE_NAME_TOO_LONG +}, + +{ + "reserved_name", ERRCODE_RESERVED_NAME +}, + +{ + "datatype_mismatch", ERRCODE_DATATYPE_MISMATCH +}, + +{ + "indeterminate_datatype", ERRCODE_INDETERMINATE_DATATYPE +}, + +{ + "collation_mismatch", ERRCODE_COLLATION_MISMATCH +}, + +{ + "indeterminate_collation", ERRCODE_INDETERMINATE_COLLATION +}, + +{ + "wrong_object_type", ERRCODE_WRONG_OBJECT_TYPE +}, + +{ + "generated_always", ERRCODE_GENERATED_ALWAYS +}, + +{ + "undefined_column", ERRCODE_UNDEFINED_COLUMN +}, + +{ + "undefined_function", ERRCODE_UNDEFINED_FUNCTION +}, + +{ + "undefined_table", ERRCODE_UNDEFINED_TABLE +}, + +{ + "undefined_parameter", ERRCODE_UNDEFINED_PARAMETER +}, + +{ + "undefined_object", ERRCODE_UNDEFINED_OBJECT +}, + +{ + "duplicate_column", ERRCODE_DUPLICATE_COLUMN +}, + +{ + "duplicate_cursor", ERRCODE_DUPLICATE_CURSOR +}, + +{ + "duplicate_database", ERRCODE_DUPLICATE_DATABASE +}, + +{ + "duplicate_function", ERRCODE_DUPLICATE_FUNCTION +}, + +{ + "duplicate_prepared_statement", ERRCODE_DUPLICATE_PSTATEMENT +}, + +{ + "duplicate_schema", ERRCODE_DUPLICATE_SCHEMA +}, + +{ + "duplicate_table", ERRCODE_DUPLICATE_TABLE +}, + +{ + "duplicate_alias", ERRCODE_DUPLICATE_ALIAS +}, + +{ + "duplicate_object", ERRCODE_DUPLICATE_OBJECT +}, + +{ + "ambiguous_column", ERRCODE_AMBIGUOUS_COLUMN +}, + +{ + "ambiguous_function", ERRCODE_AMBIGUOUS_FUNCTION +}, + +{ + "ambiguous_parameter", ERRCODE_AMBIGUOUS_PARAMETER +}, + +{ + "ambiguous_alias", ERRCODE_AMBIGUOUS_ALIAS +}, + +{ + "invalid_column_reference", ERRCODE_INVALID_COLUMN_REFERENCE +}, + +{ + "invalid_column_definition", ERRCODE_INVALID_COLUMN_DEFINITION +}, + +{ + "invalid_cursor_definition", ERRCODE_INVALID_CURSOR_DEFINITION +}, + +{ + "invalid_database_definition", ERRCODE_INVALID_DATABASE_DEFINITION +}, + +{ + "invalid_function_definition", ERRCODE_INVALID_FUNCTION_DEFINITION +}, + +{ + "invalid_prepared_statement_definition", ERRCODE_INVALID_PSTATEMENT_DEFINITION +}, + +{ + "invalid_schema_definition", ERRCODE_INVALID_SCHEMA_DEFINITION +}, + +{ + "invalid_table_definition", ERRCODE_INVALID_TABLE_DEFINITION +}, + +{ + "invalid_object_definition", ERRCODE_INVALID_OBJECT_DEFINITION +}, + +{ + "with_check_option_violation", ERRCODE_WITH_CHECK_OPTION_VIOLATION +}, + +{ + "insufficient_resources", ERRCODE_INSUFFICIENT_RESOURCES +}, + +{ + "disk_full", ERRCODE_DISK_FULL +}, + +{ + "out_of_memory", ERRCODE_OUT_OF_MEMORY +}, + +{ + "too_many_connections", ERRCODE_TOO_MANY_CONNECTIONS +}, + +{ + "configuration_limit_exceeded", ERRCODE_CONFIGURATION_LIMIT_EXCEEDED +}, + +{ + "program_limit_exceeded", ERRCODE_PROGRAM_LIMIT_EXCEEDED +}, + +{ + "statement_too_complex", ERRCODE_STATEMENT_TOO_COMPLEX +}, + +{ + "too_many_columns", ERRCODE_TOO_MANY_COLUMNS +}, + +{ + "too_many_arguments", ERRCODE_TOO_MANY_ARGUMENTS +}, + +{ + "object_not_in_prerequisite_state", ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE +}, + +{ + "object_in_use", ERRCODE_OBJECT_IN_USE +}, + +{ + "cant_change_runtime_param", ERRCODE_CANT_CHANGE_RUNTIME_PARAM +}, + +{ + "lock_not_available", ERRCODE_LOCK_NOT_AVAILABLE +}, + +{ + "unsafe_new_enum_value_usage", ERRCODE_UNSAFE_NEW_ENUM_VALUE_USAGE +}, + +{ + "operator_intervention", ERRCODE_OPERATOR_INTERVENTION +}, + +{ + "query_canceled", ERRCODE_QUERY_CANCELED +}, + +{ + "admin_shutdown", ERRCODE_ADMIN_SHUTDOWN +}, + +{ + "crash_shutdown", ERRCODE_CRASH_SHUTDOWN +}, + +{ + "cannot_connect_now", ERRCODE_CANNOT_CONNECT_NOW +}, + +{ + "database_dropped", ERRCODE_DATABASE_DROPPED +}, + +{ + "idle_session_timeout", ERRCODE_IDLE_SESSION_TIMEOUT +}, + +{ + "system_error", ERRCODE_SYSTEM_ERROR +}, + +{ + "io_error", ERRCODE_IO_ERROR +}, + +{ + "undefined_file", ERRCODE_UNDEFINED_FILE +}, + +{ + "duplicate_file", ERRCODE_DUPLICATE_FILE +}, + +{ + "config_file_error", ERRCODE_CONFIG_FILE_ERROR +}, + +{ + "lock_file_exists", ERRCODE_LOCK_FILE_EXISTS +}, + +{ + "fdw_error", ERRCODE_FDW_ERROR +}, + +{ + "fdw_column_name_not_found", ERRCODE_FDW_COLUMN_NAME_NOT_FOUND +}, + +{ + "fdw_dynamic_parameter_value_needed", ERRCODE_FDW_DYNAMIC_PARAMETER_VALUE_NEEDED +}, + +{ + "fdw_function_sequence_error", ERRCODE_FDW_FUNCTION_SEQUENCE_ERROR +}, + +{ + "fdw_inconsistent_descriptor_information", ERRCODE_FDW_INCONSISTENT_DESCRIPTOR_INFORMATION +}, + +{ + "fdw_invalid_attribute_value", ERRCODE_FDW_INVALID_ATTRIBUTE_VALUE +}, + +{ + "fdw_invalid_column_name", ERRCODE_FDW_INVALID_COLUMN_NAME +}, + +{ + "fdw_invalid_column_number", ERRCODE_FDW_INVALID_COLUMN_NUMBER +}, + +{ + "fdw_invalid_data_type", ERRCODE_FDW_INVALID_DATA_TYPE +}, + +{ + "fdw_invalid_data_type_descriptors", ERRCODE_FDW_INVALID_DATA_TYPE_DESCRIPTORS +}, + +{ + "fdw_invalid_descriptor_field_identifier", ERRCODE_FDW_INVALID_DESCRIPTOR_FIELD_IDENTIFIER +}, + +{ + "fdw_invalid_handle", ERRCODE_FDW_INVALID_HANDLE +}, + +{ + "fdw_invalid_option_index", ERRCODE_FDW_INVALID_OPTION_INDEX +}, + +{ + "fdw_invalid_option_name", ERRCODE_FDW_INVALID_OPTION_NAME +}, + +{ + "fdw_invalid_string_length_or_buffer_length", ERRCODE_FDW_INVALID_STRING_LENGTH_OR_BUFFER_LENGTH +}, + +{ + "fdw_invalid_string_format", ERRCODE_FDW_INVALID_STRING_FORMAT +}, + +{ + "fdw_invalid_use_of_null_pointer", ERRCODE_FDW_INVALID_USE_OF_NULL_POINTER +}, + +{ + "fdw_too_many_handles", ERRCODE_FDW_TOO_MANY_HANDLES +}, + +{ + "fdw_out_of_memory", ERRCODE_FDW_OUT_OF_MEMORY +}, + +{ + "fdw_no_schemas", ERRCODE_FDW_NO_SCHEMAS +}, + +{ + "fdw_option_name_not_found", ERRCODE_FDW_OPTION_NAME_NOT_FOUND +}, + +{ + "fdw_reply_handle", ERRCODE_FDW_REPLY_HANDLE +}, + +{ + "fdw_schema_not_found", ERRCODE_FDW_SCHEMA_NOT_FOUND +}, + +{ + "fdw_table_not_found", ERRCODE_FDW_TABLE_NOT_FOUND +}, + +{ + "fdw_unable_to_create_execution", ERRCODE_FDW_UNABLE_TO_CREATE_EXECUTION +}, + +{ + "fdw_unable_to_create_reply", ERRCODE_FDW_UNABLE_TO_CREATE_REPLY +}, + +{ + "fdw_unable_to_establish_connection", ERRCODE_FDW_UNABLE_TO_ESTABLISH_CONNECTION +}, + +{ + "plpgsql_error", ERRCODE_PLPGSQL_ERROR +}, + +{ + "raise_exception", ERRCODE_RAISE_EXCEPTION +}, + +{ + "no_data_found", ERRCODE_NO_DATA_FOUND +}, + +{ + "too_many_rows", ERRCODE_TOO_MANY_ROWS +}, + +{ + "assert_failure", ERRCODE_ASSERT_FAILURE +}, + +{ + "internal_error", ERRCODE_INTERNAL_ERROR +}, + +{ + "data_corrupted", ERRCODE_DATA_CORRUPTED +}, + +{ + "index_corrupted", ERRCODE_INDEX_CORRUPTED +}, diff --git a/internal/summary/qsort.go b/internal/summary/qsort.go new file mode 100644 index 0000000..b892777 --- /dev/null +++ b/internal/summary/qsort.go @@ -0,0 +1,128 @@ +// pg_qsort (src/port/qsort.c via lib/sort_template.h): the Bentley & McIlroy +// quicksort PostgreSQL uses — list_sort() maps to it at the pin (port.h +// defines qsort as pg_qsort). It is not stable, so the order of +// equal-priority truncations depends on the exact algorithm; byte-parity +// needs the algorithm, not just the comparator. Same port as +// internal/normalize/qsort.go, over possible truncations. +package summary + +func med3T(a []*possibleTruncation, x, y, z int) int { + if cmpPossibleTruncations(a[x], a[y]) < 0 { + if cmpPossibleTruncations(a[y], a[z]) < 0 { + return y + } + if cmpPossibleTruncations(a[x], a[z]) < 0 { + return z + } + return x + } + if cmpPossibleTruncations(a[y], a[z]) > 0 { + return y + } + if cmpPossibleTruncations(a[x], a[z]) < 0 { + return x + } + return z +} + +func swapNT(a []*possibleTruncation, x, y, n int) { + for i := 0; i < n; i++ { + a[x+i], a[y+i] = a[y+i], a[x+i] + } +} + +// pgQsortTruncations sorts a exactly as ST_SORT in sort_template.h. +func pgQsortTruncations(a []*possibleTruncation) { + n := len(a) +loop: + if n < 7 { + for pm := 1; pm < n; pm++ { + for pl := pm; pl > 0 && cmpPossibleTruncations(a[pl-1], a[pl]) > 0; pl-- { + a[pl], a[pl-1] = a[pl-1], a[pl] + } + } + return + } + presorted := true + for pm := 1; pm < n; pm++ { + if cmpPossibleTruncations(a[pm-1], a[pm]) > 0 { + presorted = false + break + } + } + if presorted { + return + } + pm := n / 2 + if n > 7 { + pl := 0 + pn := n - 1 + if n > 40 { + d := n / 8 + pl = med3T(a, pl, pl+d, pl+2*d) + pm = med3T(a, pm-d, pm, pm+d) + pn = med3T(a, pn-2*d, pn-d, pn) + } + pm = med3T(a, pl, pm, pn) + } + a[0], a[pm] = a[pm], a[0] + pa, pb := 1, 1 + pc, pd := n-1, n-1 + for { + var r int + for pb <= pc { + if r = cmpPossibleTruncations(a[pb], a[0]); r > 0 { + break + } + if r == 0 { + a[pa], a[pb] = a[pb], a[pa] + pa++ + } + pb++ + } + for pb <= pc { + if r = cmpPossibleTruncations(a[pc], a[0]); r < 0 { + break + } + if r == 0 { + a[pc], a[pd] = a[pd], a[pc] + pd-- + } + pc-- + } + if pb > pc { + break + } + a[pb], a[pc] = a[pc], a[pb] + pb++ + pc-- + } + pn := n + d1 := min(pa, pb-pa) + swapNT(a, 0, pb-d1, d1) + d1 = min(pd-pc, pn-pd-1) + swapNT(a, pb, pn-d1, d1) + d1 = pb - pa + d2 := pd - pc + if d1 <= d2 { + // Recurse on left partition, then iterate on right partition. + if d1 > 1 { + pgQsortTruncations(a[:d1]) + } + if d2 > 1 { + a = a[pn-d2:] + n = d2 + goto loop + } + } else { + // Recurse on right partition, then iterate on left partition. + if d2 > 1 { + pgQsortTruncations(a[pn-d2 : pn]) + } + if d1 > 1 { + a = a[:d1] + n = d1 + goto loop + } + } +} diff --git a/internal/summary/stmt_types.go b/internal/summary/stmt_types.go new file mode 100644 index 0000000..51ad2e1 --- /dev/null +++ b/internal/summary/stmt_types.go @@ -0,0 +1,274 @@ +package summary + +import ( + "github.com/sqlc-dev/oliphant/ast" + "github.com/sqlc-dev/oliphant/internal/rawwalk" +) + +// addStmtType is add_stmt_type_if_needed: an insertion-ordered set. +func (s *state) addStmtType(name string) { + for _, t := range s.statementTypes { + if t == name { + return + } + } + s.statementTypes = append(s.statementTypes, name) +} + +// stmtWalk is pg_query_summary_stmt_walk_impl +// (pg_query_summary_statement_type.c): record the statement type of every +// node the raw walker can reach, with explicit sub-walks for the four +// utility statements that wrap a query but are not raw-walkable themselves. +func (s *state) stmtWalk(item any) bool { + c := rawwalk.Concrete(item) + if rawwalk.IsNil(c) { + return false + } + + switch v := c.(type) { + case *ast.RawStmt: + return s.stmtWalk(v.Stmt) + case *ast.CreateTableAsStmt: + s.addStmtType("CreateTableAsStmt") + if v.Query != nil { + s.stmtWalk(v.Query) + } + case *ast.ExplainStmt: + s.addStmtType("ExplainStmt") + if v.Query != nil { + s.stmtWalk(v.Query) + } + case *ast.PrepareStmt: + s.addStmtType("PrepareStmt") + if v.Query != nil { + s.stmtWalk(v.Query) + } + case *ast.ViewStmt: + s.addStmtType("ViewStmt") + if v.Query != nil { + s.stmtWalk(v.Query) + } + case *ast.AlterCollationStmt: + s.addStmtType("AlterCollationStmt") + case *ast.AlterDatabaseSetStmt: + s.addStmtType("AlterDatabaseSetStmt") + case *ast.AlterDatabaseStmt: + s.addStmtType("AlterDatabaseStmt") + case *ast.AlterDefaultPrivilegesStmt: + s.addStmtType("AlterDefaultPrivilegesStmt") + case *ast.AlterDomainStmt: + s.addStmtType("AlterDomainStmt") + case *ast.AlterEnumStmt: + s.addStmtType("AlterEnumStmt") + case *ast.AlterEventTrigStmt: + s.addStmtType("AlterEventTrigStmt") + case *ast.AlterExtensionContentsStmt: + s.addStmtType("AlterExtensionContentsStmt") + case *ast.AlterExtensionStmt: + s.addStmtType("AlterExtensionStmt") + case *ast.AlterFdwStmt: + s.addStmtType("AlterFdwStmt") + case *ast.AlterForeignServerStmt: + s.addStmtType("AlterForeignServerStmt") + case *ast.AlterFunctionStmt: + s.addStmtType("AlterFunctionStmt") + case *ast.AlterObjectDependsStmt: + s.addStmtType("AlterObjectDependsStmt") + case *ast.AlterObjectSchemaStmt: + s.addStmtType("AlterObjectSchemaStmt") + case *ast.AlterOpFamilyStmt: + s.addStmtType("AlterOpFamilyStmt") + case *ast.AlterOperatorStmt: + s.addStmtType("AlterOperatorStmt") + case *ast.AlterOwnerStmt: + s.addStmtType("AlterOwnerStmt") + case *ast.AlterPolicyStmt: + s.addStmtType("AlterPolicyStmt") + case *ast.AlterPublicationStmt: + s.addStmtType("AlterPublicationStmt") + case *ast.AlterRoleSetStmt: + s.addStmtType("AlterRoleSetStmt") + case *ast.AlterRoleStmt: + s.addStmtType("AlterRoleStmt") + case *ast.AlterSeqStmt: + s.addStmtType("AlterSeqStmt") + case *ast.AlterStatsStmt: + s.addStmtType("AlterStatsStmt") + case *ast.AlterSubscriptionStmt: + s.addStmtType("AlterSubscriptionStmt") + case *ast.AlterSystemStmt: + s.addStmtType("AlterSystemStmt") + case *ast.AlterTableCmd: + s.addStmtType("AlterTableCmd") + case *ast.AlterTableMoveAllStmt: + s.addStmtType("AlterTableMoveAllStmt") + case *ast.AlterTableSpaceOptionsStmt: + s.addStmtType("AlterTableSpaceOptionsStmt") + case *ast.AlterTableStmt: + s.addStmtType("AlterTableStmt") + case *ast.AlterTSConfigurationStmt: + s.addStmtType("AlterTSConfigurationStmt") + case *ast.AlterTSDictionaryStmt: + s.addStmtType("AlterTSDictionaryStmt") + case *ast.AlterTypeStmt: + s.addStmtType("AlterTypeStmt") + case *ast.AlterUserMappingStmt: + s.addStmtType("AlterUserMappingStmt") + case *ast.CallStmt: + s.addStmtType("CallStmt") + case *ast.CheckPointStmt: + s.addStmtType("CheckPointStmt") + case *ast.ClosePortalStmt: + s.addStmtType("ClosePortalStmt") + case *ast.ClusterStmt: + s.addStmtType("ClusterStmt") + case *ast.CommentStmt: + s.addStmtType("CommentStmt") + case *ast.CompositeTypeStmt: + s.addStmtType("CompositeTypeStmt") + case *ast.ConstraintsSetStmt: + s.addStmtType("ConstraintsSetStmt") + case *ast.CopyStmt: + s.addStmtType("CopyStmt") + case *ast.CreateAmStmt: + s.addStmtType("CreateAmStmt") + case *ast.CreateCastStmt: + s.addStmtType("CreateCastStmt") + case *ast.CreateConversionStmt: + s.addStmtType("CreateConversionStmt") + case *ast.CreateDomainStmt: + s.addStmtType("CreateDomainStmt") + case *ast.CreateEnumStmt: + s.addStmtType("CreateEnumStmt") + case *ast.CreateEventTrigStmt: + s.addStmtType("CreateEventTrigStmt") + case *ast.CreateExtensionStmt: + s.addStmtType("CreateExtensionStmt") + case *ast.CreateFdwStmt: + s.addStmtType("CreateFdwStmt") + case *ast.CreateForeignServerStmt: + s.addStmtType("CreateForeignServerStmt") + case *ast.CreateForeignTableStmt: + s.addStmtType("CreateForeignTableStmt") + case *ast.CreateFunctionStmt: + s.addStmtType("CreateFunctionStmt") + case *ast.CreateOpClassStmt: + s.addStmtType("CreateOpClassStmt") + case *ast.CreateOpFamilyStmt: + s.addStmtType("CreateOpFamilyStmt") + case *ast.CreatePLangStmt: + s.addStmtType("CreatePLangStmt") + case *ast.CreatePolicyStmt: + s.addStmtType("CreatePolicyStmt") + case *ast.CreatePublicationStmt: + s.addStmtType("CreatePublicationStmt") + case *ast.CreateRangeStmt: + s.addStmtType("CreateRangeStmt") + case *ast.CreateRoleStmt: + s.addStmtType("CreateRoleStmt") + case *ast.CreateSchemaStmt: + s.addStmtType("CreateSchemaStmt") + case *ast.CreateSeqStmt: + s.addStmtType("CreateSeqStmt") + case *ast.CreateStatsStmt: + s.addStmtType("CreateStatsStmt") + case *ast.CreateStmt: + s.addStmtType("CreateStmt") + case *ast.CreateSubscriptionStmt: + s.addStmtType("CreateSubscriptionStmt") + case *ast.CreateTableSpaceStmt: + s.addStmtType("CreateTableSpaceStmt") + case *ast.CreateTransformStmt: + s.addStmtType("CreateTransformStmt") + case *ast.CreateTrigStmt: + s.addStmtType("CreateTrigStmt") + case *ast.CreateUserMappingStmt: + s.addStmtType("CreateUserMappingStmt") + case *ast.CreatedbStmt: + s.addStmtType("CreatedbStmt") + case *ast.DeallocateStmt: + s.addStmtType("DeallocateStmt") + case *ast.DeclareCursorStmt: + s.addStmtType("DeclareCursorStmt") + case *ast.DefineStmt: + s.addStmtType("DefineStmt") + case *ast.DeleteStmt: + s.addStmtType("DeleteStmt") + case *ast.DiscardStmt: + s.addStmtType("DiscardStmt") + case *ast.DoStmt: + s.addStmtType("DoStmt") + case *ast.DropOwnedStmt: + s.addStmtType("DropOwnedStmt") + case *ast.DropRoleStmt: + s.addStmtType("DropRoleStmt") + case *ast.DropStmt: + s.addStmtType("DropStmt") + case *ast.DropSubscriptionStmt: + s.addStmtType("DropSubscriptionStmt") + case *ast.DropTableSpaceStmt: + s.addStmtType("DropTableSpaceStmt") + case *ast.DropUserMappingStmt: + s.addStmtType("DropUserMappingStmt") + case *ast.DropdbStmt: + s.addStmtType("DropdbStmt") + case *ast.ExecuteStmt: + s.addStmtType("ExecuteStmt") + case *ast.FetchStmt: + s.addStmtType("FetchStmt") + case *ast.GrantRoleStmt: + s.addStmtType("GrantRoleStmt") + case *ast.GrantStmt: + s.addStmtType("GrantStmt") + case *ast.ImportForeignSchemaStmt: + s.addStmtType("ImportForeignSchemaStmt") + case *ast.IndexStmt: + s.addStmtType("IndexStmt") + case *ast.InsertStmt: + s.addStmtType("InsertStmt") + case *ast.ListenStmt: + s.addStmtType("ListenStmt") + case *ast.LoadStmt: + s.addStmtType("LoadStmt") + case *ast.LockStmt: + s.addStmtType("LockStmt") + case *ast.MergeStmt: + s.addStmtType("MergeStmt") + case *ast.NotifyStmt: + s.addStmtType("NotifyStmt") + case *ast.ReassignOwnedStmt: + s.addStmtType("ReassignOwnedStmt") + case *ast.RefreshMatViewStmt: + s.addStmtType("RefreshMatViewStmt") + case *ast.ReindexStmt: + s.addStmtType("ReindexStmt") + case *ast.RenameStmt: + s.addStmtType("RenameStmt") + case *ast.ReplicaIdentityStmt: + s.addStmtType("ReplicaIdentityStmt") + case *ast.RuleStmt: + s.addStmtType("RuleStmt") + case *ast.SecLabelStmt: + s.addStmtType("SecLabelStmt") + case *ast.SelectStmt: + s.addStmtType("SelectStmt") + case *ast.SetOperationStmt: + s.addStmtType("SetOperationStmt") + case *ast.TransactionStmt: + s.addStmtType("TransactionStmt") + case *ast.TruncateStmt: + s.addStmtType("TruncateStmt") + case *ast.UnlistenStmt: + s.addStmtType("UnlistenStmt") + case *ast.UpdateStmt: + s.addStmtType("UpdateStmt") + case *ast.VacuumStmt: + s.addStmtType("VacuumStmt") + case *ast.VariableSetStmt: + s.addStmtType("VariableSetStmt") + case *ast.VariableShowStmt: + s.addStmtType("VariableShowStmt") + } + + return rawwalk.WalkChildren(item, s.stmtWalk) +} diff --git a/internal/summary/summary.go b/internal/summary/summary.go new file mode 100644 index 0000000..e755dfe --- /dev/null +++ b/internal/summary/summary.go @@ -0,0 +1,442 @@ +package summary + +import ( + "strings" + + "github.com/sqlc-dev/oliphant/ast" + "github.com/sqlc-dev/oliphant/internal/deparse" + "github.com/sqlc-dev/oliphant/internal/rawwalk" +) + +// Error carries an ereport raised during the summary walk (there is exactly +// one reachable site: makeRangeVarFromNameList). +type Error struct { + Message string + Filename string + Funcname string +} + +func (e *Error) Error() string { return e.Message } + +// Summarize is pg_query_summary_internal (pg_query_summary.c) minus the raw +// parse, which the caller has already done: the summary walk, the +// statement-type walk, and — when truncateLimit is not -1 — the truncation +// pass. +func Summarize(tree *ast.ParseResult, truncateLimit int) (result *ast.SummaryResult, err error) { + defer func() { + if r := recover(); r != nil { + if se, ok := r.(*Error); ok { + result, err = nil, se + return + } + panic(r) + } + }() + + s := &state{} + root := rawwalk.RawStmtList(tree.Stmts) + + // pg_query_summary_walk: the main walk, then the deferred range-var pass + // (CTEs can be referenced before they are defined, so tables are only + // resolved against cte_names once the walk has seen everything). + if len(root) > 0 { + s.walk(root) + } + for _, rv := range s.rangeVars { + s.handleRangeVar(rv.node, rv.context) + } + + // pg_query_summary_statement_walk. + if len(root) > 0 { + s.stmtWalk(root) + } + + res := &ast.SummaryResult{ + Tables: s.tables, + CteNames: s.cteNames, + Functions: s.functions, + FilterColumns: s.filterColumns, + StatementTypes: s.statementTypes, + } + if len(s.aliases) > 0 { + // The C list becomes a protobuf map; duplicate keys collapse with the + // last occurrence winning, exactly as protobuf map decoding does. + res.Aliases = map[string]string{} + for _, kv := range s.aliases { + res.Aliases[kv.key] = kv.value + } + } + + if truncateLimit != -1 { + res.TruncatedQuery = truncate(tree.Stmts, truncateLimit) + } + return res, nil +} + +type rangeVarCtx struct { + node *ast.RangeVar + context ast.SummaryResult_Context +} + +type aliasKV struct{ key, value string } + +type state struct { + rangeVars []rangeVarCtx + tables []*ast.SummaryResult_Table + aliases []aliasKV + cteNames []string + functions []*ast.SummaryResult_Function + filterColumns []*ast.SummaryResult_FilterColumn + statementTypes []string + saveFilterColumns bool +} + +// addRangeVar is add_range_var (pg_query_summary.c): wrap a FROM-clause item +// (or statement target relation) and stash it for the deferred pass. +func (s *state) addRangeVar(item any, context ast.SummaryResult_Context) { + c := rawwalk.Concrete(item) + if rawwalk.IsNil(c) { + return + } + switch v := c.(type) { + case *ast.JoinExpr: + s.addRangeVar(v.Larg, context) + s.addRangeVar(v.Rarg, context) + // je->quals is handled by the regular tree walk. + case *ast.RangeTableSample: + s.addRangeVar(v.Relation, context) + case *ast.JsonTable, *ast.RangeTableFunc, *ast.RangeFunction, *ast.RangeSubselect: + // These are handled by the tree walker. + case *ast.RangeVar: + s.rangeVars = append(s.rangeVars, rangeVarCtx{node: v, context: context}) + default: + // elog(ERROR, "unexpected node type"): unreachable for grammar-built + // trees (table_ref only produces the shapes above). + panic(&Error{Message: "unexpected node type in add_range_var"}) + } +} + +func (s *state) addRangeVarList(clause []*ast.Node, context ast.SummaryResult_Context) { + for _, n := range clause { + s.addRangeVar(n, context) + } +} + +// addFunction is add_function: name via NameListToString, schema from the +// qualification, function from the last name part. +func (s *state) addFunction(funcname []*ast.Node, context ast.SummaryResult_Context) { + fn := &ast.SummaryResult_Function{ + Name: nameListToString(funcname), + Context: context, + } + switch len(funcname) { + case 3: + fn.SchemaName = funcname[1].GetString_().GetSval() + case 2: + fn.SchemaName = funcname[0].GetString_().GetSval() + } + if len(funcname) > 0 { + fn.FunctionName = funcname[len(funcname)-1].GetString_().GetSval() + } + s.functions = append(s.functions, fn) +} + +// walk is pg_query_summary_walk_impl. Returning true aborts the walk up the +// chain, exactly like a C tree-walker callback. +func (s *state) walk(item any) bool { + c := rawwalk.Concrete(item) + if rawwalk.IsNil(c) { + return false + } + + switch v := c.(type) { + case *ast.CommonTableExpr: + s.cteNames = append(s.cteNames, v.Ctename) + + case *ast.CallStmt: + if v.Funccall != nil { + return s.walk(v.Funccall) + } + // The C case falls through into the SelectStmt arm and reads garbage; + // unreachable, since the grammar always sets funccall. + return false + + case *ast.SelectStmt: + // Don't descend into sub-SELECTs in the WHERE clause when saving + // filter columns. + if s.saveFilterColumns { + return true + } + if v.Op == ast.SetOperation_SETOP_NONE { + s.addRangeVarList(v.FromClause, ast.SummaryResult_Select) + } + // For SETOP_UNION/EXCEPT/INTERSECT the walkChildren call at the end + // handles larg/rarg. + if v.IntoClause != nil { + s.addRangeVar(v.IntoClause.Rel, ast.SummaryResult_DDL) + } + if v.WhereClause != nil { + // The WHERE clause is intentionally walked twice; when saving + // filter columns we don't descend into sub-SELECTs. + s.saveFilterColumns = true + s.walk(v.WhereClause) + s.saveFilterColumns = false + } + + case *ast.InsertStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DML) + + case *ast.UpdateStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DML) + s.addRangeVarList(v.FromClause, ast.SummaryResult_Select) + + case *ast.MergeStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DML) + + case *ast.DeleteStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DML) + s.addRangeVarList(v.UsingClause, ast.SummaryResult_Select) + + case *ast.CopyStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_Select) + s.walk(v.Query) + + case *ast.AlterTableStmt: + // `ALTER INDEX index_name` is ignored. + if v.Objtype != ast.ObjectType_OBJECT_INDEX { + s.addRangeVar(v.Relation, ast.SummaryResult_DDL) + } + + case *ast.CreateStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DDL) + + case *ast.CreateTableAsStmt: + if v.Into != nil && v.Into.Rel != nil { + s.addRangeVar(v.Into.Rel, ast.SummaryResult_DDL) + } + s.walk(v.Query) + + case *ast.TruncateStmt: + s.addRangeVarList(v.Relations, ast.SummaryResult_DDL) + + case *ast.ViewStmt: + s.addRangeVar(v.View, ast.SummaryResult_DDL) + s.walk(v.Query) + + case *ast.IndexStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DDL) + for _, ie := range v.IndexParams { + s.walk(ie.GetIndexElem().GetExpr()) + } + s.walk(v.WhereClause) + + case *ast.CreateTrigStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DDL) + + case *ast.RuleStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DDL) + + case *ast.VacuumStmt: + for _, r := range v.Rels { + s.addRangeVar(r.GetVacuumRelation().GetRelation(), ast.SummaryResult_DDL) + } + + case *ast.RefreshMatViewStmt: + s.addRangeVar(v.Relation, ast.SummaryResult_DDL) + + case *ast.DropStmt: + switch v.RemoveType { + case ast.ObjectType_OBJECT_TABLE: + for _, obj := range v.Objects { + if list := obj.GetList(); list != nil { + if len(list.Items) == 0 { + continue + } + s.addRangeVar(makeRangeVarFromNameList(list.Items), ast.SummaryResult_DDL) + } + } + case ast.ObjectType_OBJECT_RULE, ast.ObjectType_OBJECT_TRIGGER: + for _, obj := range v.Objects { + if list := obj.GetList(); list != nil { + // Ignore the last string (the rule/trigger name). + items := list.Items[:max(len(list.Items)-1, 0)] + if len(items) == 0 { + continue + } + s.addRangeVar(makeRangeVarFromNameList(items), ast.SummaryResult_DDL) + } + } + case ast.ObjectType_OBJECT_FUNCTION: + if len(v.Objects) > 0 { + if obj := v.Objects[0].GetObjectWithArgs(); obj != nil && len(obj.Objname) > 0 { + s.addFunction(obj.Objname, ast.SummaryResult_DDL) + } + } + } + + case *ast.GrantStmt: + switch v.Objtype { + case ast.ObjectType_OBJECT_TABLE: + for _, obj := range v.Objects { + if rv := obj.GetRangeVar(); rv != nil { + s.addRangeVar(rv, ast.SummaryResult_DDL) + } + } + case ast.ObjectType_OBJECT_FUNCTION, ast.ObjectType_OBJECT_PROCEDURE, + ast.ObjectType_OBJECT_ROUTINE: + for _, obj := range v.Objects { + if owa := obj.GetObjectWithArgs(); owa != nil && len(owa.Objname) > 0 { + s.addFunction(owa.Objname, ast.SummaryResult_DDL) + } + } + } + + case *ast.LockStmt: + s.addRangeVarList(v.Relations, ast.SummaryResult_DDL) + + case *ast.ExplainStmt: + return s.walk(v.Query) + + case *ast.CreateFunctionStmt: + s.addFunction(v.Funcname, ast.SummaryResult_DDL) + + case *ast.RenameStmt: + switch v.RenameType { + case ast.ObjectType_OBJECT_TABLE: + s.addRangeVar(v.Relation, ast.SummaryResult_DDL) + s.addRangeVar(&ast.RangeVar{ + Schemaname: v.Relation.GetSchemaname(), + Relname: v.Newname, + Inh: true, + Relpersistence: "p", + Location: -1, + }, ast.SummaryResult_DDL) + case ast.ObjectType_OBJECT_FUNCTION, ast.ObjectType_OBJECT_PROCEDURE, + ast.ObjectType_OBJECT_ROUTINE: + if owa := v.Object.GetObjectWithArgs(); owa != nil { + s.addFunction(owa.Objname, ast.SummaryResult_DDL) + s.addFunction([]*ast.Node{makeStringNode(v.Newname)}, ast.SummaryResult_DDL) + } + } + + case *ast.PrepareStmt: + return s.walk(v.Query) + + case *ast.RawStmt: + return s.walk(v.Stmt) + + case *ast.FuncCall: + s.addFunction(v.Funcname, ast.SummaryResult_Call) + + case *ast.ColumnRef: + // Added to avoid needing subselect_items, like Rust and Ruby use. + if !s.saveFilterColumns { + break + } + if len(v.Fields) == 0 { + break + } + column := v.Fields[len(v.Fields)-1].GetString_() + // Check that we are not in the A_Star case here. (Columns can be + // stars, but nothing else can.) + if column == nil { + break + } + fc := &ast.SummaryResult_FilterColumn{Column: column.Sval} + switch len(v.Fields) { + case 2: + fc.TableName = v.Fields[0].GetString_().GetSval() + case 3: + fc.SchemaName = v.Fields[0].GetString_().GetSval() + fc.TableName = v.Fields[1].GetString_().GetSval() + } + s.filterColumns = append(s.filterColumns, fc) + } + + return rawwalk.WalkChildren(item, s.walk) +} + +// rangeVarToName is range_var_to_name: quote_identifier-rendered, dotted. +func rangeVarToName(rv *ast.RangeVar) string { + var b strings.Builder + if rv.Schemaname != "" { + b.WriteString(deparse.QuoteIdentifier(rv.Schemaname)) + b.WriteByte('.') + } + b.WriteString(deparse.QuoteIdentifier(rv.Relname)) + return b.String() +} + +// cteNamesInclude is cte_names_include: exact-match scan. +func (s *state) cteNamesInclude(relname string) bool { + for _, name := range s.cteNames { + if name == relname { + return true + } + } + return false +} + +// handleRangeVar is handle_range_var: emit a table (unless the name is a CTE) +// and an alias entry. +func (s *state) handleRangeVar(rv *ast.RangeVar, context ast.SummaryResult_Context) { + if rv == nil { + return + } + if !s.cteNamesInclude(rv.Relname) { + s.tables = append(s.tables, &ast.SummaryResult_Table{ + Name: rangeVarToName(rv), + SchemaName: rv.Schemaname, + TableName: rv.Relname, + Context: context, + }) + } + if rv.Alias != nil { + s.aliases = append(s.aliases, aliasKV{key: rv.Alias.Aliasname, value: rangeVarToName(rv)}) + } +} + +// nameListToString is NameListToString (catalog/namespace.c): dotted, no +// quoting; A_Star renders as "*". +func nameListToString(names []*ast.Node) string { + var b strings.Builder + for i, n := range names { + if i > 0 { + b.WriteByte('.') + } + if s := n.GetString_(); s != nil { + b.WriteString(s.Sval) + } else { + b.WriteString("*") + } + } + return b.String() +} + +// makeRangeVarFromNameList (makefuncs.c; vendored by libpg_query into +// src_backend_catalog_namespace.c, which is the filename its ereport carries). +func makeRangeVarFromNameList(names []*ast.Node) *ast.RangeVar { + rv := &ast.RangeVar{Inh: true, Relpersistence: "p", Location: -1} + switch len(names) { + case 1: + rv.Relname = names[0].GetString_().GetSval() + case 2: + rv.Schemaname = names[0].GetString_().GetSval() + rv.Relname = names[1].GetString_().GetSval() + case 3: + rv.Catalogname = names[0].GetString_().GetSval() + rv.Schemaname = names[1].GetString_().GetSval() + rv.Relname = names[2].GetString_().GetSval() + default: + panic(&Error{ + Message: "improper relation name (too many dotted names): " + nameListToString(names), + Filename: "src_backend_catalog_namespace.c", + Funcname: "makeRangeVarFromNameList", + }) + } + return rv +} + +func makeStringNode(s string) *ast.Node { + return &ast.Node{Node: &ast.Node_String_{String_: &ast.String{Sval: s}}} +} diff --git a/internal/summary/truncate.go b/internal/summary/truncate.go new file mode 100644 index 0000000..0411cf7 --- /dev/null +++ b/internal/summary/truncate.go @@ -0,0 +1,376 @@ +package summary + +import ( + "strings" + + "github.com/sqlc-dev/oliphant/ast" + "github.com/sqlc-dev/oliphant/internal/deparse" + "github.com/sqlc-dev/oliphant/internal/rawwalk" +) + +// Port of pg_query_summary_truncate.c: deparse the statements; if the result +// is over the limit, collect the possible truncations (target lists, WHERE +// clauses, VALUES lists, INSERT column lists, CTE bodies), sort them deepest +// then longest first, and apply them cumulatively until the deparse fits; +// fall back to a plain multibyte-aware chop. + +type truncationAttr int + +const ( + truncTargetList truncationAttr = iota + truncWhereClause + truncValuesLists + truncCols + truncCTEQuery +) + +type possibleTruncation struct { + attr truncationAttr + node any + depth int32 + length int32 +} + +type truncationState struct { + truncations []*possibleTruncation + depth int32 +} + +// truncate is pg_query_summary_truncate. +func truncate(stmts []*ast.RawStmt, truncateLimit int) string { + state := &truncationState{} + + output := deparseRawStmtList(stmts) + if len(output) <= truncateLimit { + return output + } + + if len(stmts) > 0 { + state.generate(rawwalk.RawStmtList(stmts)) + } + pgQsortTruncations(state.truncations) + return applyTruncations(stmts, state, truncateLimit) +} + +// truncateMbstr is truncate_mbstr: chop to max_chars characters (multibyte +// aware, pg_mblen-style) with a "..." suffix. max_chars is a size_t in C, so +// a limit below 3 wraps around and the clip keeps everything, appending the +// ellipsis to the full string. +func truncateMbstr(s string, maxChars int) string { + if mbstrlen(s) <= maxChars { + return s + } + nBytes := len(s) + if maxChars >= 3 { + nBytes = mbCharClipLen(s, maxChars-3) + } + return s[:nBytes] + "..." +} + +func (ts *truncationState) add(attr truncationAttr, node any, length int32) { + // Don't bother truncating if it won't become shorter. + if length <= 3 { + return + } + ts.truncations = append(ts.truncations, &possibleTruncation{ + attr: attr, + node: node, + depth: ts.depth, + length: length, + }) +} + +func (ts *truncationState) addWhereClause(node any, whereClause *ast.Node) { + if whereClause == nil { + return + } + ts.add(truncWhereClause, node, whereClauseLen(whereClause)) +} + +// generate is generate_possible_truncations. +func (ts *truncationState) generate(item any) bool { + c := rawwalk.Concrete(item) + if rawwalk.IsNil(c) { + return false + } + + switch v := c.(type) { + case *ast.RawStmt: + return ts.generate(v.Stmt) + + case *ast.SelectStmt: + if len(v.TargetList) != 0 { + ts.add(truncTargetList, v, selectTargetListLen(v.TargetList)) + } + ts.addWhereClause(v, v.WhereClause) + if len(v.ValuesLists) != 0 { + ts.add(truncValuesLists, v, selectValuesListsLen(v.ValuesLists)) + } + + case *ast.InsertStmt: + if len(v.Cols) != 0 { + ts.add(truncCols, v, colsLen(v.Cols)) + } + + case *ast.UpdateStmt: + if len(v.TargetList) != 0 { + ts.add(truncTargetList, v, updateTargetListLen(v.TargetList)) + } + ts.addWhereClause(v, v.WhereClause) + + case *ast.DeleteStmt: + ts.addWhereClause(v, v.WhereClause) + + case *ast.CopyStmt: + ts.addWhereClause(v, v.WhereClause) + + case *ast.IndexStmt: + ts.addWhereClause(v, v.WhereClause) + + case *ast.RuleStmt: + ts.addWhereClause(v, v.WhereClause) + + case *ast.CommonTableExpr: + if v.Ctequery != nil { + ts.add(truncCTEQuery, v, int32(deparseStmtLen(v.Ctequery))) + } + + case *ast.InferClause: + ts.addWhereClause(v, v.WhereClause) + + case *ast.OnConflictClause: + if len(v.TargetList) != 0 { + ts.add(truncTargetList, v, updateTargetListLen(v.TargetList)) + } + ts.addWhereClause(v, v.WhereClause) + } + + // The supports gate lives in walkChildren's default arm; the depth + // save/restore brackets the descent exactly as the C walker call does + // (list nodes count as a level, matching WALK on a List field). + oldDepth := ts.depth + ts.depth++ + result := rawwalk.WalkChildren(item, ts.generate) + ts.depth = oldDepth + return result +} + +// cmpPossibleTruncations is cmp_possible_truncations: deepest first, then +// longest first. +func cmpPossibleTruncations(a, b *possibleTruncation) int { + if d := b.depth - a.depth; d != 0 { + return int(d) + } + return int(b.length - a.length) +} + +// globalReplace is global_replace: in-place scan-and-splice; equivalent to a +// left-to-right non-overlapping replace when the replacement is no longer +// than the pattern (asserted in C). +func globalReplace(s, pattern, replacement string) string { + return strings.ReplaceAll(s, pattern, replacement) +} + +// applyTruncations is apply_truncations: apply cumulatively in sorted order, +// re-deparsing after each, until the output fits. +func applyTruncations(stmts []*ast.RawStmt, state *truncationState, truncationLimit int) string { + output := "" + deparsed := false + + for _, truncation := range state.truncations { + switch v := truncation.node.(type) { + case *ast.SelectStmt: + switch truncation.attr { + case truncTargetList: + v.TargetList = []*ast.Node{dummyTargetNode()} + case truncWhereClause: + v.WhereClause = dummyColumnNode() + case truncValuesLists: + v.ValuesLists = []*ast.Node{{Node: &ast.Node_List{List: &ast.List{Items: []*ast.Node{dummyColumnNode()}}}}} + } + case *ast.UpdateStmt: + switch truncation.attr { + case truncTargetList: + v.TargetList = []*ast.Node{dummyTargetNode()} + case truncWhereClause: + v.WhereClause = dummyColumnNode() + } + case *ast.InsertStmt: + v.Cols = []*ast.Node{dummyTargetNode()} + case *ast.DeleteStmt: + v.WhereClause = dummyColumnNode() + case *ast.CopyStmt: + v.WhereClause = dummyColumnNode() + case *ast.IndexStmt: + v.WhereClause = dummyColumnNode() + case *ast.RuleStmt: + v.WhereClause = dummyColumnNode() + case *ast.CommonTableExpr: + v.Ctequery = dummySelectNode(nil, dummyColumnNode(), nil) + case *ast.InferClause: + v.WhereClause = dummyColumnNode() + case *ast.OnConflictClause: + switch truncation.attr { + case truncTargetList: + v.TargetList = []*ast.Node{dummyTargetNode()} + case truncWhereClause: + v.WhereClause = dummyColumnNode() + } + default: + panic(&Error{Message: "apply_truncations() got unknown truncation type"}) + } + + output = deparseRawStmtList(stmts) + deparsed = true + + output = globalReplace(output, `SELECT "…" AS "…"`, `SELECT "…"`) + output = globalReplace(output, `SELECT WHERE "…"`, `"…"`) + output = globalReplace(output, `"…"`, `...`) + + if len(output) <= truncationLimit { + return output + } + } + + if !deparsed { + output = deparseRawStmtList(stmts) + } + return truncateMbstr(output, truncationLimit) +} + +// --- dummy nodes ------------------------------------------------------------- + +func dummyColumnNode() *ast.Node { + return &ast.Node{Node: &ast.Node_ColumnRef{ColumnRef: &ast.ColumnRef{ + Fields: []*ast.Node{makeStringNode("…")}, + Location: 0, + }}} +} + +func dummyTargetNode() *ast.Node { + return &ast.Node{Node: &ast.Node_ResTarget{ResTarget: &ast.ResTarget{ + Name: "…", + Val: dummyColumnNode(), + Location: 0, + }}} +} + +// dummySelect leaves every other field zeroed, like makeNode does; the +// protobuf enums for op/limitOption are their explicit SETOP_NONE / +// LIMIT_OPTION_DEFAULT values (the C zero values at the pin, patch 05). +func dummySelect(targetList []*ast.Node, whereClause *ast.Node, valuesLists []*ast.Node) *ast.SelectStmt { + return &ast.SelectStmt{ + TargetList: targetList, + WhereClause: whereClause, + ValuesLists: valuesLists, + LimitOption: ast.LimitOption_LIMIT_OPTION_DEFAULT, + Op: ast.SetOperation_SETOP_NONE, + } +} + +func dummySelectNode(targetList []*ast.Node, whereClause *ast.Node, valuesLists []*ast.Node) *ast.Node { + return &ast.Node{Node: &ast.Node_SelectStmt{SelectStmt: dummySelect(targetList, whereClause, valuesLists)}} +} + +func dummyRangeVarX() *ast.RangeVar { + return &ast.RangeVar{Relname: "x", Inh: true, Relpersistence: "p", Location: 0} +} + +// dummyInsert sets override = 1 exactly as the C code does — which is +// OVERRIDING_USER_VALUE in the C enum (protobuf value 2, after the UNDEFINED +// slot), inflating the measured length by "OVERRIDING USER VALUE ". A sort +// key quirk, ported faithfully. +func dummyInsert(cols []*ast.Node) *ast.Node { + return &ast.Node{Node: &ast.Node_InsertStmt{InsertStmt: &ast.InsertStmt{ + Relation: dummyRangeVarX(), + Cols: cols, + Override: ast.OverridingKind_OVERRIDING_USER_VALUE, + }}} +} + +func dummyUpdate(targetList []*ast.Node) *ast.Node { + return &ast.Node{Node: &ast.Node_UpdateStmt{UpdateStmt: &ast.UpdateStmt{ + Relation: dummyRangeVarX(), + TargetList: targetList, + }}} +} + +// --- length measurement ------------------------------------------------------ + +func selectTargetListLen(nodes []*ast.Node) int32 { + return int32(deparseStmtLen(dummySelectNode(nodes, nil, nil))) - 7 /* "SELECT " */ +} + +func selectValuesListsLen(nodes []*ast.Node) int32 { + return int32(deparseStmtLen(dummySelectNode(nil, nil, nodes))) - 9 /* "VALUES ()" */ +} + +func updateTargetListLen(nodes []*ast.Node) int32 { + return int32(deparseStmtLen(dummyUpdate(nodes))) - 13 /* "UPDATE x SET " */ +} + +func whereClauseLen(node *ast.Node) int32 { + return int32(deparseStmtLen(dummySelectNode(nil, node, nil))) - 13 /* "SELECT WHERE " */ +} + +func colsLen(nodes []*ast.Node) int32 { + return int32(deparseStmtLen(dummyInsert(nodes))) - 31 /* "INSERT INTO x () DEFAULT VALUES" */ +} + +// deparseStmtLen is deparse_stmt_len: wrap in a RawStmt and measure. +func deparseStmtLen(node *ast.Node) int { + raw := &ast.RawStmt{Stmt: node, StmtLocation: -1, StmtLen: 0} + return len(deparseRawStmtList([]*ast.RawStmt{raw})) +} + +// deparseRawStmtList is deparse_raw_stmt_list: statements joined with "; ". +// A deparse failure ereports in C and unwinds to pg_query_summary's catch +// block; the panic here unwinds to Summarize's recover the same way. +func deparseRawStmtList(stmts []*ast.RawStmt) string { + out, err := deparse.Deparse(&ast.ParseResult{Stmts: stmts}) + if err != nil { + panic(&Error{Message: err.Error()}) + } + return out +} + +// --- multibyte helpers (mb/mbutils.c, UTF-8 database encoding) --------------- + +// pgUtfMblen is pg_utf_mblen: sequence length from the first byte. +func pgUtfMblen(b byte) int { + switch { + case b&0x80 == 0: + return 1 + case b&0xE0 == 0xC0: + return 2 + case b&0xF0 == 0xE0: + return 3 + case b&0xF8 == 0xF0: + return 4 + default: + return 1 + } +} + +// mbstrlen is pg_mbstrlen. +func mbstrlen(s string) int { + n := 0 + for i := 0; i < len(s); i += pgUtfMblen(s[i]) { + n++ + } + return n +} + +// mbCharClipLen is pg_mbcharcliplen: byte length of the first limit +// characters. +func mbCharClipLen(s string, limit int) int { + chars, i := 0, 0 + for i < len(s) && chars < limit { + i += pgUtfMblen(s[i]) + chars++ + } + if i > len(s) { + return len(s) + } + return i +} diff --git a/internal/testfile/golden.go b/internal/testfile/golden.go index 80ffc58..60abacc 100644 --- a/internal/testfile/golden.go +++ b/internal/testfile/golden.go @@ -2,6 +2,7 @@ package testfile import ( "fmt" + "sort" "strconv" "strings" ) @@ -106,3 +107,114 @@ func RenderSplit(stmts []string) string { } return strings.Join(lines, "\n") } + +// --- summary goldens --------------------------------------------------------- + +// SummaryTable / SummaryFunction / SummaryFilterColumn / SummaryExpectation +// mirror the SummaryResult protobuf field-for-field, with Context enums as +// their protobuf value names ("None", "Select", "DML", "DDL", "Call"). +type SummaryTable struct { + Name string + SchemaName string + TableName string + Context string +} + +type SummaryFunction struct { + Name string + FunctionName string + SchemaName string + Context string +} + +type SummaryFilterColumn struct { + SchemaName string + TableName string + Column string +} + +type SummaryExpectation struct { + Tables []SummaryTable + Aliases map[string]string + CteNames []string + Functions []SummaryFunction + FilterColumns []SummaryFilterColumn + StatementTypes []string + TruncatedQuery string +} + +// RenderSummary encodes a SummaryResult golden, one entry per line. Repeated +// fields keep their protobuf order; aliases (a protobuf map, unordered by +// definition) are sorted by key. The empty summary renders as "". +// +// TABLE: name="public.x" schema="public" table="x" ctx=DDL +// ALIAS: "a"="b" +// CTE: "cte" +// FUNCTION: name="pg_catalog.substr" function="substr" schema="pg_catalog" ctx=Call +// FILTER: schema="" table="t" column="c" +// STMT: SelectStmt +// TRUNCATED: "SELECT ..." +func RenderSummary(s SummaryExpectation) string { + var lines []string + for _, t := range s.Tables { + lines = append(lines, fmt.Sprintf("TABLE: name=%q schema=%q table=%q ctx=%s", + t.Name, t.SchemaName, t.TableName, t.Context)) + } + keys := make([]string, 0, len(s.Aliases)) + for k := range s.Aliases { + keys = append(keys, k) + } + sort.Strings(keys) + for _, k := range keys { + lines = append(lines, fmt.Sprintf("ALIAS: %q=%q", k, s.Aliases[k])) + } + for _, c := range s.CteNames { + lines = append(lines, fmt.Sprintf("CTE: %q", c)) + } + for _, f := range s.Functions { + lines = append(lines, fmt.Sprintf("FUNCTION: name=%q function=%q schema=%q ctx=%s", + f.Name, f.FunctionName, f.SchemaName, f.Context)) + } + for _, f := range s.FilterColumns { + lines = append(lines, fmt.Sprintf("FILTER: schema=%q table=%q column=%q", + f.SchemaName, f.TableName, f.Column)) + } + for _, t := range s.StatementTypes { + lines = append(lines, "STMT: "+t) + } + if s.TruncatedQuery != "" { + lines = append(lines, fmt.Sprintf("TRUNCATED: %q", s.TruncatedQuery)) + } + return strings.Join(lines, "\n") +} + +// --- summary_truncate case inputs -------------------------------------------- + +// The summary_truncate suite carries the truncation limit as a leading +// comment line in the case input; both cmd/regenerate and the corpus harness +// strip it before calling Summary, so the SQL the oracle and oliphant see is +// byte-identical to the raw statement. +const TruncateLimitPrefix = "-- truncate_limit: " + +// WithTruncateLimit prepends the truncation-limit directive to a statement. +func WithTruncateLimit(limit int, sql string) string { + return fmt.Sprintf("%s%d\n%s", TruncateLimitPrefix, limit, sql) +} + +// SplitTruncateLimit strips the truncation-limit directive from a +// summary_truncate case input. +func SplitTruncateLimit(input string) (limit int, sql string, err error) { + if !strings.HasPrefix(input, TruncateLimitPrefix) { + return 0, "", fmt.Errorf("summary_truncate input missing %q directive", TruncateLimitPrefix) + } + rest := input[len(TruncateLimitPrefix):] + line, sql, ok := strings.Cut(rest, "\n") + if !ok { + return 0, "", fmt.Errorf("summary_truncate input is only a directive line") + } + limit, err = strconv.Atoi(line) + if err != nil { + return 0, "", fmt.Errorf("bad truncate_limit %q: %w", line, err) + } + return limit, sql, nil +} diff --git a/oracle/main.go b/oracle/main.go index 0dc4711..cc83e9a 100644 --- a/oracle/main.go +++ b/oracle/main.go @@ -25,6 +25,9 @@ type req struct { Op string `json:"op"` SQL string `json:"sql"` TrimSpace bool `json:"trim_space,omitempty"` + // TruncateLimit is the summary op's truncation limit; nil means -1 + // (no truncation), matching pg_query.Summary's convention. + TruncateLimit *int `json:"truncate_limit,omitempty"` } type oracleError struct { @@ -43,10 +46,43 @@ type token struct { } type res struct { - Text *string `json:"text,omitempty"` - Stmts []string `json:"stmts,omitempty"` - Tokens []token `json:"tokens,omitempty"` - Err *oracleError `json:"error,omitempty"` + Text *string `json:"text,omitempty"` + Stmts []string `json:"stmts,omitempty"` + Tokens []token `json:"tokens,omitempty"` + Summary *summaryRes `json:"summary,omitempty"` + Err *oracleError `json:"error,omitempty"` +} + +// summaryRes mirrors SummaryResult field-for-field, with Context enums +// rendered as their protobuf value names. +type summaryTable struct { + Name string `json:"name"` + SchemaName string `json:"schema_name"` + TableName string `json:"table_name"` + Context string `json:"context"` +} + +type summaryFunction struct { + Name string `json:"name"` + FunctionName string `json:"function_name"` + SchemaName string `json:"schema_name"` + Context string `json:"context"` +} + +type summaryFilterColumn struct { + SchemaName string `json:"schema_name"` + TableName string `json:"table_name"` + Column string `json:"column"` +} + +type summaryRes struct { + Tables []summaryTable `json:"tables"` + Aliases map[string]string `json:"aliases"` + CteNames []string `json:"cte_names"` + Functions []summaryFunction `json:"functions"` + FilterColumns []summaryFilterColumn `json:"filter_columns"` + StatementTypes []string `json:"statement_types"` + TruncatedQuery string `json:"truncated_query"` } func main() { @@ -131,6 +167,51 @@ func handle(r req) res { return errRes(err) } return res{Stmts: emptyNotNil(stmts)} + case "summary": + limit := -1 + if r.TruncateLimit != nil { + limit = *r.TruncateLimit + } + sr, err := pg_query.Summary(r.SQL, limit) + if err != nil { + return errRes(err) + } + out := &summaryRes{ + Aliases: sr.Aliases, + CteNames: sr.CteNames, + StatementTypes: sr.StatementTypes, + TruncatedQuery: sr.TruncatedQuery, + } + for _, t := range sr.Tables { + out.Tables = append(out.Tables, summaryTable{ + Name: t.Name, + SchemaName: t.SchemaName, + TableName: t.TableName, + Context: t.Context.String(), + }) + } + for _, f := range sr.Functions { + out.Functions = append(out.Functions, summaryFunction{ + Name: f.Name, + FunctionName: f.FunctionName, + SchemaName: f.SchemaName, + Context: f.Context.String(), + }) + } + for _, f := range sr.FilterColumns { + out.FilterColumns = append(out.FilterColumns, summaryFilterColumn{ + SchemaName: f.SchemaName, + TableName: f.TableName, + Column: f.Column, + }) + } + return res{Summary: out} + case "parse_plpgsql": + out, err := pg_query.ParsePlPgSqlToJSON(r.SQL) + if err != nil { + return errRes(err) + } + return res{Text: &out} default: return res{Err: &oracleError{Message: "unknown op " + r.Op}} } diff --git a/oracle/oracle b/oracle/oracle index 19b19c1..f3c374e 100755 Binary files a/oracle/oracle and b/oracle/oracle differ diff --git a/parser/corpus_test.go b/parser/corpus_test.go index 1534356..57d5a84 100644 --- a/parser/corpus_test.go +++ b/parser/corpus_test.go @@ -22,6 +22,7 @@ var checkParse = flag.Bool("check-parse", false, "run todo cases and remove newl var suites = []string{ "parse", "scan", "normalize", "normalize_utility", "fingerprint", "deparse", "split_scanner", "split_parser", + "summary", "summary_truncate", "plpgsql", } func TestCorpus(t *testing.T) { @@ -162,10 +163,59 @@ func evaluate(suite, input string) string { return renderErr(err) } return testfile.RenderSplit(stmts) + case "summary": + res, err := pg_query.Summary(input, -1) + if err != nil { + return renderErr(err) + } + return renderSummary(res) + case "summary_truncate": + limit, sql, err := testfile.SplitTruncateLimit(input) + if err != nil { + return "BAD CASE: " + err.Error() + } + res, err := pg_query.Summary(sql, limit) + if err != nil { + return renderErr(err) + } + return renderSummary(res) + case "plpgsql": + out, err := pg_query.ParsePlPgSqlToJSON(input) + if err != nil { + return renderErr(err) + } + return out } panic("unknown suite " + suite) } +// renderSummary encodes a SummaryResult in the same byte format +// cmd/regenerate writes from the oracle. +func renderSummary(res *pg_query.SummaryResult) string { + e := testfile.SummaryExpectation{ + Aliases: res.Aliases, + CteNames: res.CteNames, + StatementTypes: res.StatementTypes, + TruncatedQuery: res.TruncatedQuery, + } + for _, t := range res.Tables { + e.Tables = append(e.Tables, testfile.SummaryTable{ + Name: t.Name, SchemaName: t.SchemaName, TableName: t.TableName, Context: t.Context.String(), + }) + } + for _, f := range res.Functions { + e.Functions = append(e.Functions, testfile.SummaryFunction{ + Name: f.Name, FunctionName: f.FunctionName, SchemaName: f.SchemaName, Context: f.Context.String(), + }) + } + for _, f := range res.FilterColumns { + e.FilterColumns = append(e.FilterColumns, testfile.SummaryFilterColumn{ + SchemaName: f.SchemaName, TableName: f.TableName, Column: f.Column, + }) + } + return testfile.RenderSummary(e) +} + func renderErr(err error) string { var pe *parser.Error if errors.As(err, &pe) { diff --git a/parser/parser.go b/parser/parser.go index 7100fac..634b7e3 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -8,6 +8,7 @@ package parser import ( + "errors" "fmt" "strings" @@ -20,6 +21,8 @@ import ( "github.com/sqlc-dev/oliphant/internal/lexer" "github.com/sqlc-dev/oliphant/internal/normalize" "github.com/sqlc-dev/oliphant/internal/parse" + "github.com/sqlc-dev/oliphant/internal/plpgsql" + "github.com/sqlc-dev/oliphant/internal/summary" "github.com/sqlc-dev/oliphant/internal/xxh3" ) @@ -116,8 +119,21 @@ func DeparseFromProtobuf(input []byte) (result string, err error) { return out, nil } +// ParsePlPgSqlToJSON is pg_query_parse_plpgsql: compile every CREATE +// FUNCTION/PROCEDURE and DO statement with the PL/pgSQL parser and render +// the JSON array of function dumps. func ParsePlPgSqlToJSON(input string) (result string, err error) { - return "", errNotImplemented("ParsePlPgSqlToJSON") + out, perr := plpgsql.ParseToJSON(input) + if perr != nil { + return "", &Error{ + Message: perr.Message, + Filename: perr.Filename, + Funcname: perr.Funcname, + Cursorpos: perr.Cursorpos, + Context: perr.Context, + } + } + return out, nil } // Normalize is pg_query_normalize: constants become $n parameter references. @@ -247,6 +263,25 @@ func IsUtilityStmt(input string) (result []bool, err error) { return result, nil } +// SummaryToProtobuf is pg_query_summary: parse, walk for tables/aliases/ +// CTEs/functions/filter columns/statement types, and — unless truncateLimit +// is -1 — produce the smart-truncated query text. func SummaryToProtobuf(input string, truncateLimit int) ([]byte, error) { - return nil, errNotImplemented("SummaryToProtobuf") + tree, perr := parse.Parse(input) + if perr != nil { + return nil, scanErr(perr) + } + res, serr := summary.Summarize(tree, truncateLimit) + if serr != nil { + var se *summary.Error + if errors.As(serr, &se) { + return nil, &Error{ + Message: se.Message, + Filename: se.Filename, + Funcname: se.Funcname, + } + } + return nil, &Error{Message: serr.Error()} + } + return proto.Marshal(res) } diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_array.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_array.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_array.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_array.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_array.test new file mode 100644 index 0000000..65d9a0f --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_array.test @@ -0,0 +1,291 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of array variables +|-- +-- We also check arrays of composites here, so this has some overlap +-- with the plpgsql_record tests. +|-- + +create type complex as (r float8, i float8) +-- +CREATE TYPE complex AS (r float8, i float8) +== 002 +create type quadarray as (c1 complex[], c2 complex) +-- +CREATE TYPE quadarray AS (c1 complex[], c2 complex) +== 003 +do $$ declare a int[]; +begin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end$$ +== 004 +do $$ declare a int[]; +begin a[3] := 4; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a[3] := 4; raise notice 'a = %', a; end$$ +== 005 +do $$ declare a int[]; +begin a[1][4] := 4; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a[1][4] := 4; raise notice 'a = %', a; end$$ +== 006 +do $$ declare a int[]; +begin a[1] := 23::text; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a[1] := 23::text; raise notice 'a = %', a; end$$ +== 007 +-- lax typing + +do $$ declare a int[]; +begin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end$$ +== 008 +do $$ declare a int[]; +begin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end$$ +== 009 +do $$ declare a int[]; +begin a[1:2] := array[3,4]; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a[1:2] := array[3,4]; raise notice 'a = %', a; end$$ +== 010 +do $$ declare a int[]; +begin a[1:2] := 4; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a[1:2] := 4; raise notice 'a = %', a; end$$ +== 011 +-- error + +do $$ declare a complex[]; +begin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end$$ +-- +DO $$ declare a complex[]; +begin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end$$ +== 012 +do $$ declare a complex[]; +begin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end$$ +-- +DO $$ declare a complex[]; +begin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end$$ +== 013 +-- perhaps this ought to work, but for now it doesn't: +do $$ declare a complex[]; +begin a[1:2].i := array[11,12]; raise notice 'a = %', a; end$$ +-- +DO $$ declare a complex[]; +begin a[1:2].i := array[11,12]; raise notice 'a = %', a; end$$ +== 014 +do $$ declare a quadarray; +begin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end$$ +-- +DO $$ declare a quadarray; +begin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end$$ +== 015 +do $$ declare a int[]; +begin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end$$ +== 016 +create temp table onecol as select array[1,2] as f1 +-- +CREATE TEMPORARY TABLE onecol AS SELECT ARRAY[1, 2] AS f1 +== 017 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +== 018 +do $$ declare a int[]; +begin a := * from onecol for update; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := * from onecol for update; raise notice 'a = %', a; end$$ +== 019 +-- error cases: + +do $$ declare a int[]; +begin a := from onecol; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := from onecol; raise notice 'a = %', a; end$$ +== 020 +do $$ declare a int[]; +begin a := f1, f1 from onecol; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := f1, f1 from onecol; raise notice 'a = %', a; end$$ +== 021 +insert into onecol values(array[11]) +-- +INSERT INTO onecol VALUES (ARRAY[11]) +== 022 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +== 023 +do $$ declare a int[]; +begin a := f1 from onecol limit 1; raise notice 'a = %', a; end$$ +-- +DO $$ declare a int[]; +begin a := f1 from onecol limit 1; raise notice 'a = %', a; end$$ +== 024 +do $$ declare a real; +begin a[1] := 2; raise notice 'a = %', a; end$$ +-- +DO $$ declare a real; +begin a[1] := 2; raise notice 'a = %', a; end$$ +== 025 +do $$ declare a complex; +begin a.r[1] := 2; raise notice 'a = %', a; end$$ +-- +DO $$ declare a complex; +begin a.r[1] := 2; raise notice 'a = %', a; end$$ +== 026 +|-- +-- test of %type[] and %rowtype[] syntax +|-- + +-- check supported syntax +do $$ +declare + v int; + v1 v%type; + v2 v%type[]; + v3 v%type[1]; + v4 v%type[][]; + v5 v%type[1][3]; + v6 v%type array; + v7 v%type array[]; + v8 v%type array[1]; + v9 v%type array[1][1]; + v10 pg_catalog.pg_class%rowtype[]; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(v3); + raise notice '%', pg_typeof(v4); + raise notice '%', pg_typeof(v5); + raise notice '%', pg_typeof(v6); + raise notice '%', pg_typeof(v7); + raise notice '%', pg_typeof(v8); + raise notice '%', pg_typeof(v9); + raise notice '%', pg_typeof(v10); +end; +$$ +-- +DO $$ +declare + v int; + v1 v%type; + v2 v%type[]; + v3 v%type[1]; + v4 v%type[][]; + v5 v%type[1][3]; + v6 v%type array; + v7 v%type array[]; + v8 v%type array[1]; + v9 v%type array[1][1]; + v10 pg_catalog.pg_class%rowtype[]; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(v3); + raise notice '%', pg_typeof(v4); + raise notice '%', pg_typeof(v5); + raise notice '%', pg_typeof(v6); + raise notice '%', pg_typeof(v7); + raise notice '%', pg_typeof(v8); + raise notice '%', pg_typeof(v9); + raise notice '%', pg_typeof(v10); +end; +$$ +== 027 +-- some types don't support arrays +do $$ +declare + v pg_node_tree; + v1 v%type[]; +begin +end; +$$ +-- +DO $$ +declare + v pg_node_tree; + v1 v%type[]; +begin +end; +$$ +== 028 +-- check functionality +do $$ +declare + v1 int; + v2 varchar; + a1 v1%type[]; + a2 v2%type[]; +begin + v1 := 10; + v2 := 'Hi'; + a1 := array[v1,v1]; + a2 := array[v2,v2]; + raise notice '% %', a1, a2; +end; +$$ +-- +DO $$ +declare + v1 int; + v2 varchar; + a1 v1%type[]; + a2 v2%type[]; +begin + v1 := 10; + v2 := 'Hi'; + a1 := array[v1,v1]; + a2 := array[v2,v2]; + raise notice '% %', a1, a2; +end; +$$ +== 029 +create table array_test_table(a int, b varchar) +-- +CREATE TABLE array_test_table (a int, b varchar) +== 030 +insert into array_test_table values(1, 'first'), (2, 'second') +-- +INSERT INTO array_test_table VALUES (1, 'first'), (2, 'second') +== 031 +do $$ +declare tg array_test_table%rowtype[]; +begin + tg := array(select array_test_table from array_test_table); + raise notice '%', tg; + tg := array(select row(a,b) from array_test_table); + raise notice '%', tg; +end; +$$ +-- +DO $$ +declare tg array_test_table%rowtype[]; +begin + tg := array(select array_test_table from array_test_table); + raise notice '%', tg; + tg := array(select row(a,b) from array_test_table); + raise notice '%', tg; +end; +$$ diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_cache.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_cache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_cache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_cache.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_cache.test new file mode 100644 index 0000000..5ec8c0a --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_cache.test @@ -0,0 +1,91 @@ +== 001 +|-- +-- Cache-behavior-dependent test cases +|-- +-- These tests logically belong in plpgsql_record.sql, and perhaps someday +-- can be merged back into it. For now, however, their results are different +-- depending on debug_discard_caches, so we must have two expected-output +-- files to cover both cases. To minimize the maintenance effort resulting +-- from that, this file should contain only tests that do have different +-- results under debug_discard_caches. +|-- + +-- check behavior with changes of a named rowtype +create table c_mutable(f1 int, f2 text) +-- +CREATE TABLE c_mutable (f1 int, f2 text) +== 002 +create function c_sillyaddone(int) returns int language plpgsql as +$$ declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +CREATE FUNCTION c_sillyaddone(int) RETURNS int LANGUAGE plpgsql AS $$ declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +== 003 +select c_sillyaddone(42) +-- +SELECT c_sillyaddone(42) +== 004 +alter table c_mutable drop column f1 +-- +ALTER TABLE c_mutable DROP f1 +== 005 +alter table c_mutable add column f1 float8 +-- +ALTER TABLE c_mutable ADD COLUMN f1 float8 +== 006 +-- currently, this fails due to cached plan for "r.f1 + 1" expression +-- (but if debug_discard_caches is on, it will succeed) +select c_sillyaddone(42) +-- +SELECT c_sillyaddone(42) +== 007 +-- but it's OK if we force plan rebuilding +discard plans +-- +DISCARD PLANS +== 008 +select c_sillyaddone(42) +-- +SELECT c_sillyaddone(42) +== 009 +-- check behavior with changes in a record rowtype +create function show_result_type(text) returns text language plpgsql as +$$ + declare + r record; + t text; + begin + execute $1 into r; + select pg_typeof(r.a) into t; + return format('type %s value %s', t, r.a::text); + end; +$$ +-- +CREATE FUNCTION show_result_type(text) RETURNS text LANGUAGE plpgsql AS $$ + declare + r record; + t text; + begin + execute $1 into r; + select pg_typeof(r.a) into t; + return format('type %s value %s', t, r.a::text); + end; +$$ +== 010 +select show_result_type('select 1 as a') +-- +SELECT show_result_type('select 1 as a') +== 011 +-- currently this fails due to cached plan for pg_typeof expression +-- (but if debug_discard_caches is on, it will succeed) +select show_result_type('select 2.0 as a') +-- +SELECT show_result_type('select 2.0 as a') +== 012 +-- but it's OK if we force plan rebuilding +discard plans +-- +DISCARD PLANS +== 013 +select show_result_type('select 2.0 as a') +-- +SELECT show_result_type('select 2.0 as a') diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_call.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_call.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_call.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_call.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_call.test new file mode 100644 index 0000000..86c0073 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_call.test @@ -0,0 +1,1079 @@ +== 001 +|-- +-- Tests for procedures / CALL syntax +|-- + +CREATE PROCEDURE test_proc1() +LANGUAGE plpgsql +AS $$ +BEGIN + NULL; +END; +$$ +-- +CREATE PROCEDURE test_proc1() LANGUAGE plpgsql AS $$ +BEGIN + NULL; +END; +$$ +== 002 +CALL test_proc1() +-- +CALL test_proc1() +== 003 +-- error: can't return non-NULL +CREATE PROCEDURE test_proc2() +LANGUAGE plpgsql +AS $$ +BEGIN + RETURN 5; +END; +$$ +-- +CREATE PROCEDURE test_proc2() LANGUAGE plpgsql AS $$ +BEGIN + RETURN 5; +END; +$$ +== 004 +CREATE TABLE test1 (a int) +-- +CREATE TABLE test1 (a int) +== 005 +CREATE PROCEDURE test_proc3(x int) +LANGUAGE plpgsql +AS $$ +BEGIN + INSERT INTO test1 VALUES (x); +END; +$$ +-- +CREATE PROCEDURE test_proc3(x int) LANGUAGE plpgsql AS $$ +BEGIN + INSERT INTO test1 VALUES (x); +END; +$$ +== 006 +CALL test_proc3(55) +-- +CALL test_proc3(55) +== 007 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 008 +-- Check that plan revalidation doesn't prevent setting transaction properties +-- (bug #18059). This test must include the first temp-object creation in +-- this script, or it won't exercise the bug scenario. Hence we put it early. +CREATE PROCEDURE test_proc3a() +LANGUAGE plpgsql +AS $$ +BEGIN + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + RAISE NOTICE 'done'; +END; +$$ +-- +CREATE PROCEDURE test_proc3a() LANGUAGE plpgsql AS $$ +BEGIN + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + RAISE NOTICE 'done'; +END; +$$ +== 009 +CALL test_proc3a() +-- +CALL test_proc3a() +== 010 +CREATE TEMP TABLE tt1(f1 int) +-- +CREATE TEMPORARY TABLE tt1 (f1 int) +== 011 +CALL test_proc3a() +-- +CALL test_proc3a() +== 012 +-- nested CALL +TRUNCATE TABLE test1 +-- +TRUNCATE test1 +== 013 +CREATE PROCEDURE test_proc4(y int) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL test_proc3(y); + CALL test_proc3($1); +END; +$$ +-- +CREATE PROCEDURE test_proc4(y int) LANGUAGE plpgsql AS $$ +BEGIN + CALL test_proc3(y); + CALL test_proc3($1); +END; +$$ +== 014 +CALL test_proc4(66) +-- +CALL test_proc4(66) +== 015 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 016 +CALL test_proc4(66) +-- +CALL test_proc4(66) +== 017 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 018 +-- output arguments + +CREATE PROCEDURE test_proc5(INOUT a text) +LANGUAGE plpgsql +AS $$ +BEGIN + a := a || '+' || a; +END; +$$ +-- +CREATE PROCEDURE test_proc5(INOUT a text) LANGUAGE plpgsql AS $$ +BEGIN + a := a || '+' || a; +END; +$$ +== 019 +CALL test_proc5('abc') +-- +CALL test_proc5('abc') +== 020 +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + b := b * a; + c := c * a; +END; +$$ +-- +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) LANGUAGE plpgsql AS $$ +BEGIN + b := b * a; + c := c * a; +END; +$$ +== 021 +CALL test_proc6(2, 3, 4) +-- +CALL test_proc6(2, 3, 4) +== 022 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); + RAISE INFO 'x = %, y = %', x, y; + CALL test_proc6(2, c => y, b => x); + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); + RAISE INFO 'x = %, y = %', x, y; + CALL test_proc6(2, c => y, b => x); + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +== 023 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x + 1, y); -- error + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x + 1, y); -- error + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +== 024 +DO +LANGUAGE plpgsql +$$ +DECLARE + x constant int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); -- error because x is constant +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + x constant int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); -- error because x is constant +END; +$$ +== 025 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + FOR i IN 1..5 LOOP + CALL test_proc6(i, x, y); + RAISE INFO 'x = %, y = %', x, y; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + x int := 3; + y int := 4; +BEGIN + FOR i IN 1..5 LOOP + CALL test_proc6(i, x, y); + RAISE INFO 'x = %, y = %', x, y; + END LOOP; +END; +$$ +== 026 +-- recursive with output arguments + +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN +IF x > 1 THEN + a := x / 10; + b := x / 2; + CALL test_proc7(b::int, a, b); +END IF; +END; +$$ +-- +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) LANGUAGE plpgsql AS $$ +BEGIN +IF x > 1 THEN + a := x / 10; + b := x / 2; + CALL test_proc7(b::int, a, b); +END IF; +END; +$$ +== 027 +CALL test_proc7(100, -1, -1) +-- +CALL test_proc7(100, -1, -1) +== 028 +-- inner COMMIT with output arguments + +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN + a := x / 10; + b := x / 2; + COMMIT; +END; +$$ +-- +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) LANGUAGE plpgsql AS $$ +BEGIN + a := x / 10; + b := x / 2; + COMMIT; +END; +$$ +== 029 +CREATE PROCEDURE test_proc7cc(_x int) +LANGUAGE plpgsql +AS $$ +DECLARE _a int; _b numeric; +BEGIN + CALL test_proc7c(_x, _a, _b); + RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b; +END +$$ +-- +CREATE PROCEDURE test_proc7cc(_x int) LANGUAGE plpgsql AS $$ +DECLARE _a int; _b numeric; +BEGIN + CALL test_proc7c(_x, _a, _b); + RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b; +END +$$ +== 030 +CALL test_proc7cc(10) +-- +CALL test_proc7cc(10) +== 031 +-- named parameters and defaults + +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := a * 10; + b := b + 10; +END; +$$ +-- +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := a * 10; + b := b + 10; +END; +$$ +== 032 +CALL test_proc8a(10, 20) +-- +CALL test_proc8a(10, 20) +== 033 +CALL test_proc8a(b => 20, a => 10) +-- +CALL test_proc8a(b := 20, a := 10) +== 034 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc8a(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; + CALL test_proc8a(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc8a(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; + CALL test_proc8a(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +== 035 +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +== 036 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8b(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + CALL test_proc8b(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8b(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + CALL test_proc8b(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +== 037 +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int = 11) LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +== 038 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(c => _c, b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(c => _c, b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +== 039 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +== 040 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, b => _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, b => _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +== 041 +-- OUT parameters + +CREATE PROCEDURE test_proc9(IN a int, OUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + b := a * 2; +END; +$$ +-- +CREATE PROCEDURE test_proc9(IN a int, OUT b int) LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + b := a * 2; +END; +$$ +== 042 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc9(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc9(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +== 043 +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + b := a - c; +END; +$$ +-- +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int = 11) LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + b := a - c; +END; +$$ +== 044 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(a => _a, b => _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(a => _a, b => _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +== 045 +-- OUT + VARIADIC + +CREATE PROCEDURE test_proc11(a OUT int, VARIADIC b int[]) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := b[1] + b[2]; +END; +$$ +-- +CREATE PROCEDURE test_proc11(OUT a int, VARIADIC b int[]) LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := b[1] + b[2]; +END; +$$ +== 046 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc11(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc11(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +== 047 +-- polymorphic OUT arguments + +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %', a; + b := a; + c := array[a]; +END; +$$ +-- +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'a: %', a; + b := a; + c := array[a]; +END; +$$ +== 048 +DO $$ +DECLARE _a int; _b int; _c int[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; _c int[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +== 049 +DO $$ +DECLARE _a int; _b int; _c text[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); -- error + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $$ +DECLARE _a int; _b int; _c text[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); -- error + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +== 050 +-- transition variable assignment + +TRUNCATE test1 +-- +TRUNCATE test1 +== 051 +CREATE FUNCTION triggerfunc1() RETURNS trigger +LANGUAGE plpgsql +AS $$ +DECLARE + z int := 0; +BEGIN + CALL test_proc6(2, NEW.a, NEW.a); + RETURN NEW; +END; +$$ +-- +CREATE FUNCTION triggerfunc1() RETURNS trigger LANGUAGE plpgsql AS $$ +DECLARE + z int := 0; +BEGIN + CALL test_proc6(2, NEW.a, NEW.a); + RETURN NEW; +END; +$$ +== 052 +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE PROCEDURE triggerfunc1() +-- +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE FUNCTION triggerfunc1() +== 053 +INSERT INTO test1 VALUES (1), (2), (3) +-- +INSERT INTO test1 VALUES (1), (2), (3) +== 054 +UPDATE test1 SET a = 22 WHERE a = 2 +-- +UPDATE test1 SET a = 22 WHERE a = 2 +== 055 +SELECT * FROM test1 ORDER BY a +-- +SELECT * FROM test1 ORDER BY a +== 056 +DROP PROCEDURE test_proc1 +-- +DROP PROCEDURE test_proc1 +== 057 +DROP PROCEDURE test_proc3 +-- +DROP PROCEDURE test_proc3 +== 058 +DROP PROCEDURE test_proc4 +-- +DROP PROCEDURE test_proc4 +== 059 +DROP TABLE test1 +-- +DROP TABLE test1 +== 060 +-- more checks for named-parameter handling + +CREATE PROCEDURE p1(v_cnt int, v_Text inout text = NULL) +AS $$ +BEGIN + v_Text := 'v_cnt = ' || v_cnt; +END +$$ LANGUAGE plpgsql +-- +CREATE PROCEDURE p1(v_cnt int, INOUT v_text text = NULL) AS $$ +BEGIN + v_Text := 'v_cnt = ' || v_cnt; +END +$$ LANGUAGE plpgsql +== 061 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text + RAISE NOTICE '%', v_Text; +END; +$$ +-- +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text + RAISE NOTICE '%', v_Text; +END; +$$ +== 062 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +== 063 +DO $$ +DECLARE + v_Text text; +BEGIN + CALL p1(10, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +DO $$ +DECLARE + v_Text text; +BEGIN + CALL p1(10, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +== 064 +DO $$ +DECLARE + v_Text text; + v_cnt integer; +BEGIN + CALL p1(v_Text := v_Text, v_cnt := v_cnt); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +DO $$ +DECLARE + v_Text text; + v_cnt integer; +BEGIN + CALL p1(v_Text := v_Text, v_cnt := v_cnt); + RAISE NOTICE '%', v_Text; +END; +$$ +== 065 +-- check that we detect change of dependencies in CALL +-- atomic and non-atomic call sites used to do this differently, so check both + +CREATE PROCEDURE inner_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'inner_p(%)', f1; +END +$$ LANGUAGE plpgsql +-- +CREATE PROCEDURE inner_p(f1 int) AS $$ +BEGIN + RAISE NOTICE 'inner_p(%)', f1; +END +$$ LANGUAGE plpgsql +== 066 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 1 $$ LANGUAGE sql +-- +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 1 $$ LANGUAGE sql +== 067 +CREATE PROCEDURE outer_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'outer_p(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +CREATE PROCEDURE outer_p(f1 int) AS $$ +BEGIN + RAISE NOTICE 'outer_p(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +== 068 +CREATE FUNCTION outer_f (f1 int) RETURNS void +AS $$ +BEGIN + RAISE NOTICE 'outer_f(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION outer_f(f1 int) RETURNS void AS $$ +BEGIN + RAISE NOTICE 'outer_f(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +== 069 +CALL outer_p(42) +-- +CALL outer_p(42) +== 070 +SELECT outer_f(42) +-- +SELECT outer_f(42) +== 071 +DROP FUNCTION f(int) +-- +DROP FUNCTION f(int) +== 072 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 2 $$ LANGUAGE sql +-- +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 2 $$ LANGUAGE sql +== 073 +CALL outer_p(42) +-- +CALL outer_p(42) +== 074 +SELECT outer_f(42) +-- +SELECT outer_f(42) +== 075 +-- Check that stable functions in CALL see the correct snapshot + +CREATE TABLE t_test (x int) +-- +CREATE TABLE t_test (x int) +== 076 +INSERT INTO t_test VALUES (0) +-- +INSERT INTO t_test VALUES (0) +== 077 +CREATE FUNCTION f_get_x () RETURNS int +AS $$ +DECLARE l_result int; +BEGIN + SELECT x INTO l_result FROM t_test; + RETURN l_result; +END +$$ LANGUAGE plpgsql STABLE +-- +CREATE FUNCTION f_get_x() RETURNS int AS $$ +DECLARE l_result int; +BEGIN + SELECT x INTO l_result FROM t_test; + RETURN l_result; +END +$$ LANGUAGE plpgsql STABLE +== 078 +CREATE PROCEDURE f_print_x (x int) +AS $$ +BEGIN + RAISE NOTICE 'f_print_x(%)', x; +END +$$ LANGUAGE plpgsql +-- +CREATE PROCEDURE f_print_x(x int) AS $$ +BEGIN + RAISE NOTICE 'f_print_x(%)', x; +END +$$ LANGUAGE plpgsql +== 079 +-- test in non-atomic context +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + ROLLBACK; +END +$$ +-- +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + ROLLBACK; +END +$$ +== 080 +-- test in non-atomic context, except exception block is locally atomic +DO $$ +BEGIN + BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + EXCEPTION WHEN division_by_zero THEN + RAISE NOTICE '%', SQLERRM; + END; + ROLLBACK; +END +$$ +-- +DO $$ +BEGIN + BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + EXCEPTION WHEN division_by_zero THEN + RAISE NOTICE '%', SQLERRM; + END; + ROLLBACK; +END +$$ +== 081 +-- test in atomic context +BEGIN +-- +BEGIN +== 082 +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); +END +$$ +-- +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); +END +$$ +== 083 +ROLLBACK +-- +ROLLBACK diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_control.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_control.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_control.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_control.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_control.test new file mode 100644 index 0000000..e4389b4 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_control.test @@ -0,0 +1,1008 @@ +== 001 +|-- +-- Tests for PL/pgSQL control structures +|-- + +-- integer FOR loop + +do $$ +begin + -- basic case + for i in 1..3 loop + raise notice '1..3: i = %', i; + end loop; + -- with BY, end matches exactly + for i in 1..10 by 3 loop + raise notice '1..10 by 3: i = %', i; + end loop; + -- with BY, end does not match + for i in 1..11 by 3 loop + raise notice '1..11 by 3: i = %', i; + end loop; + -- zero iterations + for i in 1..0 by 3 loop + raise notice '1..0 by 3: i = %', i; + end loop; + -- REVERSE + for i in reverse 10..0 by 3 loop + raise notice 'reverse 10..0 by 3: i = %', i; + end loop; + -- potential overflow + for i in 2147483620..2147483647 by 10 loop + raise notice '2147483620..2147483647 by 10: i = %', i; + end loop; + -- potential overflow, reverse direction + for i in reverse -2147483620..-2147483647 by 10 loop + raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i; + end loop; +end$$ +-- +DO $$ +begin + -- basic case + for i in 1..3 loop + raise notice '1..3: i = %', i; + end loop; + -- with BY, end matches exactly + for i in 1..10 by 3 loop + raise notice '1..10 by 3: i = %', i; + end loop; + -- with BY, end does not match + for i in 1..11 by 3 loop + raise notice '1..11 by 3: i = %', i; + end loop; + -- zero iterations + for i in 1..0 by 3 loop + raise notice '1..0 by 3: i = %', i; + end loop; + -- REVERSE + for i in reverse 10..0 by 3 loop + raise notice 'reverse 10..0 by 3: i = %', i; + end loop; + -- potential overflow + for i in 2147483620..2147483647 by 10 loop + raise notice '2147483620..2147483647 by 10: i = %', i; + end loop; + -- potential overflow, reverse direction + for i in reverse -2147483620..-2147483647 by 10 loop + raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i; + end loop; +end$$ +== 002 +-- BY can't be zero or negative +do $$ +begin + for i in 1..3 by 0 loop + raise notice '1..3 by 0: i = %', i; + end loop; +end$$ +-- +DO $$ +begin + for i in 1..3 by 0 loop + raise notice '1..3 by 0: i = %', i; + end loop; +end$$ +== 003 +do $$ +begin + for i in 1..3 by -1 loop + raise notice '1..3 by -1: i = %', i; + end loop; +end$$ +-- +DO $$ +begin + for i in 1..3 by -1 loop + raise notice '1..3 by -1: i = %', i; + end loop; +end$$ +== 004 +do $$ +begin + for i in reverse 1..3 by -1 loop + raise notice 'reverse 1..3 by -1: i = %', i; + end loop; +end$$ +-- +DO $$ +begin + for i in reverse 1..3 by -1 loop + raise notice 'reverse 1..3 by -1: i = %', i; + end loop; +end$$ +== 005 +-- CONTINUE statement + +create table conttesttbl(idx serial, v integer) +-- +CREATE TABLE conttesttbl (idx serial, v int) +== 006 +insert into conttesttbl(v) values(10) +-- +INSERT INTO conttesttbl (v) VALUES (10) +== 007 +insert into conttesttbl(v) values(20) +-- +INSERT INTO conttesttbl (v) VALUES (20) +== 008 +insert into conttesttbl(v) values(30) +-- +INSERT INTO conttesttbl (v) VALUES (30) +== 009 +insert into conttesttbl(v) values(40) +-- +INSERT INTO conttesttbl (v) VALUES (40) +== 010 +create function continue_test1() returns void as $$ +declare _i integer = 0; _r record; +begin + raise notice '---1---'; + loop + _i := _i + 1; + raise notice '%', _i; + continue when _i < 10; + exit; + end loop; + + raise notice '---2---'; + <> + loop + _i := _i - 1; + loop + raise notice '%', _i; + continue lbl when _i > 0; + exit lbl; + end loop; + end loop; + + raise notice '---3---'; + <> + while _i < 10 loop + _i := _i + 1; + continue the_loop when _i % 2 = 0; + raise notice '%', _i; + end loop; + + raise notice '---4---'; + for _i in 1..10 loop + begin + -- applies to outer loop, not the nested begin block + continue when _i < 5; + raise notice '%', _i; + end; + end loop; + + raise notice '---5---'; + for _r in select * from conttesttbl loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---6---'; + for _r in execute 'select * from conttesttbl' loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---7---'; + <> + for _i in 1..3 loop + continue looplabel when _i = 2; + raise notice '%', _i; + end loop; + + raise notice '---8---'; + _i := 1; + while _i <= 3 loop + raise notice '%', _i; + _i := _i + 1; + continue when _i = 3; + end loop; + + raise notice '---9---'; + for _r in select * from conttesttbl order by v limit 1 loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---10---'; + for _r in execute 'select * from conttesttbl order by v limit 1' loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---11---'; + <> + for _i in 1..2 loop + raise notice 'outer %', _i; + <> + for _j in 1..3 loop + continue outerlooplabel when _j = 2; + raise notice 'inner %', _j; + end loop; + end loop; +end; $$ language plpgsql +-- +CREATE FUNCTION continue_test1() RETURNS void AS $$ +declare _i integer = 0; _r record; +begin + raise notice '---1---'; + loop + _i := _i + 1; + raise notice '%', _i; + continue when _i < 10; + exit; + end loop; + + raise notice '---2---'; + <> + loop + _i := _i - 1; + loop + raise notice '%', _i; + continue lbl when _i > 0; + exit lbl; + end loop; + end loop; + + raise notice '---3---'; + <> + while _i < 10 loop + _i := _i + 1; + continue the_loop when _i % 2 = 0; + raise notice '%', _i; + end loop; + + raise notice '---4---'; + for _i in 1..10 loop + begin + -- applies to outer loop, not the nested begin block + continue when _i < 5; + raise notice '%', _i; + end; + end loop; + + raise notice '---5---'; + for _r in select * from conttesttbl loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---6---'; + for _r in execute 'select * from conttesttbl' loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---7---'; + <> + for _i in 1..3 loop + continue looplabel when _i = 2; + raise notice '%', _i; + end loop; + + raise notice '---8---'; + _i := 1; + while _i <= 3 loop + raise notice '%', _i; + _i := _i + 1; + continue when _i = 3; + end loop; + + raise notice '---9---'; + for _r in select * from conttesttbl order by v limit 1 loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---10---'; + for _r in execute 'select * from conttesttbl order by v limit 1' loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---11---'; + <> + for _i in 1..2 loop + raise notice 'outer %', _i; + <> + for _j in 1..3 loop + continue outerlooplabel when _j = 2; + raise notice 'inner %', _j; + end loop; + end loop; +end; $$ LANGUAGE plpgsql +== 011 +select continue_test1() +-- +SELECT continue_test1() +== 012 +-- should fail: CONTINUE is only legal inside a loop +create function continue_error1() returns void as $$ +begin + begin + continue; + end; +end; +$$ language plpgsql +-- +CREATE FUNCTION continue_error1() RETURNS void AS $$ +begin + begin + continue; + end; +end; +$$ LANGUAGE plpgsql +== 013 +-- should fail: unlabeled EXIT is only legal inside a loop +create function exit_error1() returns void as $$ +begin + begin + exit; + end; +end; +$$ language plpgsql +-- +CREATE FUNCTION exit_error1() RETURNS void AS $$ +begin + begin + exit; + end; +end; +$$ LANGUAGE plpgsql +== 014 +-- should fail: no such label +create function continue_error2() returns void as $$ +begin + begin + loop + continue no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +CREATE FUNCTION continue_error2() RETURNS void AS $$ +begin + begin + loop + continue no_such_label; + end loop; + end; +end; +$$ LANGUAGE plpgsql +== 015 +-- should fail: no such label +create function exit_error2() returns void as $$ +begin + begin + loop + exit no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +CREATE FUNCTION exit_error2() RETURNS void AS $$ +begin + begin + loop + exit no_such_label; + end loop; + end; +end; +$$ LANGUAGE plpgsql +== 016 +-- should fail: CONTINUE can't reference the label of a named block +create function continue_error3() returns void as $$ +begin + <> + begin + loop + continue begin_block1; + end loop; + end; +end; +$$ language plpgsql +-- +CREATE FUNCTION continue_error3() RETURNS void AS $$ +begin + <> + begin + loop + continue begin_block1; + end loop; + end; +end; +$$ LANGUAGE plpgsql +== 017 +-- On the other hand, EXIT *can* reference the label of a named block +create function exit_block1() returns void as $$ +begin + <> + begin + loop + exit begin_block1; + raise exception 'should not get here'; + end loop; + end; +end; +$$ language plpgsql +-- +CREATE FUNCTION exit_block1() RETURNS void AS $$ +begin + <> + begin + loop + exit begin_block1; + raise exception 'should not get here'; + end loop; + end; +end; +$$ LANGUAGE plpgsql +== 018 +select exit_block1() +-- +SELECT exit_block1() +== 019 +-- verbose end block and end loop +create function end_label1() returns void as $$ +<> +begin + <> + for i in 1 .. 10 loop + raise notice 'i = %', i; + exit flbl1; + end loop flbl1; + <> + for j in 1 .. 10 loop + raise notice 'j = %', j; + exit flbl2; + end loop; +end blbl; +$$ language plpgsql +-- +CREATE FUNCTION end_label1() RETURNS void AS $$ +<> +begin + <> + for i in 1 .. 10 loop + raise notice 'i = %', i; + exit flbl1; + end loop flbl1; + <> + for j in 1 .. 10 loop + raise notice 'j = %', j; + exit flbl2; + end loop; +end blbl; +$$ LANGUAGE plpgsql +== 020 +select end_label1() +-- +SELECT end_label1() +== 021 +-- should fail: undefined end label +create function end_label2() returns void as $$ +begin + for _i in 1 .. 10 loop + exit; + end loop flbl1; +end; +$$ language plpgsql +-- +CREATE FUNCTION end_label2() RETURNS void AS $$ +begin + for _i in 1 .. 10 loop + exit; + end loop flbl1; +end; +$$ LANGUAGE plpgsql +== 022 +-- should fail: end label does not match start label +create function end_label3() returns void as $$ +<> +begin + <> + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +CREATE FUNCTION end_label3() RETURNS void AS $$ +<> +begin + <> + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ LANGUAGE plpgsql +== 023 +-- should fail: end label on a block without a start label +create function end_label4() returns void as $$ +<> +begin + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +CREATE FUNCTION end_label4() RETURNS void AS $$ +<> +begin + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ LANGUAGE plpgsql +== 024 +-- unlabeled exit matches no blocks +do $$ +begin +for i in 1..10 loop + <> + begin + begin -- unlabeled block + exit; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; +end loop; +raise notice 'should get here'; +end$$ +-- +DO $$ +begin +for i in 1..10 loop + <> + begin + begin -- unlabeled block + exit; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; +end loop; +raise notice 'should get here'; +end$$ +== 025 +-- check exit out of an unlabeled block to a labeled one +do $$ +<> +begin + <> + begin + <> + begin + begin -- unlabeled block + exit innerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; + end; + raise notice 'should get here'; +end$$ +-- +DO $$ +<> +begin + <> + begin + <> + begin + begin -- unlabeled block + exit innerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; + end; + raise notice 'should get here'; +end$$ +== 026 +-- check exit out of outermost block +do $$ +<> +begin + <> + begin + exit outerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; +end$$ +-- +DO $$ +<> +begin + <> + begin + exit outerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; +end$$ +== 027 +-- unlabeled exit does match a while loop +do $$ +begin + <> + while 1 > 0 loop + <> + while 1 > 0 loop + <> + while 1 > 0 loop + exit; + raise notice 'should not get here'; + end loop; + raise notice 'should get here'; + exit outermostwhile; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'should get here, too'; +end$$ +-- +DO $$ +begin + <> + while 1 > 0 loop + <> + while 1 > 0 loop + <> + while 1 > 0 loop + exit; + raise notice 'should not get here'; + end loop; + raise notice 'should get here'; + exit outermostwhile; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'should get here, too'; +end$$ +== 028 +-- check exit out of an unlabeled while to a labeled one +do $$ +begin + <> + while 1 > 0 loop + while 1 > 0 loop + exit outerwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'should get here'; +end$$ +-- +DO $$ +begin + <> + while 1 > 0 loop + while 1 > 0 loop + exit outerwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'should get here'; +end$$ +== 029 +-- continue to an outer while +do $$ +declare i int := 0; +begin + <> + while i < 2 loop + raise notice 'outermostwhile, i = %', i; + i := i + 1; + <> + while 1 > 0 loop + <> + while 1 > 0 loop + continue outermostwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'out of outermostwhile, i = %', i; +end$$ +-- +DO $$ +declare i int := 0; +begin + <> + while i < 2 loop + raise notice 'outermostwhile, i = %', i; + i := i + 1; + <> + while 1 > 0 loop + <> + while 1 > 0 loop + continue outermostwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'out of outermostwhile, i = %', i; +end$$ +== 030 +-- return out of a while +create function return_from_while() returns int language plpgsql as $$ +declare i int := 0; +begin + while i < 10 loop + if i > 2 then + return i; + end if; + i := i + 1; + end loop; + return null; +end$$ +-- +CREATE FUNCTION return_from_while() RETURNS int LANGUAGE plpgsql AS $$ +declare i int := 0; +begin + while i < 10 loop + if i > 2 then + return i; + end if; + i := i + 1; + end loop; + return null; +end$$ +== 031 +select return_from_while() +-- +SELECT return_from_while() +== 032 +-- using list of scalars in fori and fore stmts +create function for_vect() returns void as $proc$ +<>declare a integer; b varchar; c varchar; r record; +begin + -- fori + for i in 1 .. 3 loop + raise notice '%', i; + end loop; + -- fore with record var + for r in select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs loop + raise notice '% % %', r.aa, r.bb, r.cc; + end loop; + -- fore with single scalar + for a in select gs from generate_series(1,4) gs loop + raise notice '%', a; + end loop; + -- fore with multiple scalars + for a,b,c in select gs, 'BB','CC' from generate_series(1,4) gs loop + raise notice '% % %', a, b, c; + end loop; + -- using qualified names in fors, fore is enabled, disabled only for fori + for lbl.a, lbl.b, lbl.c in execute $$select gs, 'bb','cc' from generate_series(1,4) gs$$ loop + raise notice '% % %', a, b, c; + end loop; +end; +$proc$ language plpgsql +-- +CREATE FUNCTION for_vect() RETURNS void AS ' +<>declare a integer; b varchar; c varchar; r record; +begin + -- fori + for i in 1 .. 3 loop + raise notice ''%'', i; + end loop; + -- fore with record var + for r in select gs as aa, ''BB'' as bb, ''CC'' as cc from generate_series(1,4) gs loop + raise notice ''% % %'', r.aa, r.bb, r.cc; + end loop; + -- fore with single scalar + for a in select gs from generate_series(1,4) gs loop + raise notice ''%'', a; + end loop; + -- fore with multiple scalars + for a,b,c in select gs, ''BB'',''CC'' from generate_series(1,4) gs loop + raise notice ''% % %'', a, b, c; + end loop; + -- using qualified names in fors, fore is enabled, disabled only for fori + for lbl.a, lbl.b, lbl.c in execute $$select gs, ''bb'',''cc'' from generate_series(1,4) gs$$ loop + raise notice ''% % %'', a, b, c; + end loop; +end; +' LANGUAGE plpgsql +== 033 +select for_vect() +-- +SELECT for_vect() +== 034 +-- CASE statement + +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; + b int = 1; +begin + case $1 + when 1 then + return 'one'; + when 2 then + return 'two'; + when 3,4,3+5 then + return 'three, four or eight'; + when a then + return 'ten'; + when a+b, a+b+1 then + return 'eleven, twelve'; + end case; +end; +$$ language plpgsql immutable +-- +CREATE OR REPLACE FUNCTION case_test(bigint) RETURNS text AS $$ +declare a int = 10; + b int = 1; +begin + case $1 + when 1 then + return 'one'; + when 2 then + return 'two'; + when 3,4,3+5 then + return 'three, four or eight'; + when a then + return 'ten'; + when a+b, a+b+1 then + return 'eleven, twelve'; + end case; +end; +$$ LANGUAGE plpgsql IMMUTABLE +== 035 +select case_test(1) +-- +SELECT case_test(1) +== 036 +select case_test(2) +-- +SELECT case_test(2) +== 037 +select case_test(3) +-- +SELECT case_test(3) +== 038 +select case_test(4) +-- +SELECT case_test(4) +== 039 +select case_test(5) +-- +SELECT case_test(5) +== 040 +-- fails +select case_test(8) +-- +SELECT case_test(8) +== 041 +select case_test(10) +-- +SELECT case_test(10) +== 042 +select case_test(11) +-- +SELECT case_test(11) +== 043 +select case_test(12) +-- +SELECT case_test(12) +== 044 +select case_test(13) +-- +SELECT case_test(13) +== 045 +-- fails + +create or replace function catch() returns void as $$ +begin + raise notice '%', case_test(6); +exception + when case_not_found then + raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM; +end +$$ language plpgsql +-- +CREATE OR REPLACE FUNCTION catch() RETURNS void AS $$ +begin + raise notice '%', case_test(6); +exception + when case_not_found then + raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM; +end +$$ LANGUAGE plpgsql +== 046 +select catch() +-- +SELECT catch() +== 047 +-- test the searched variant too, as well as ELSE +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; +begin + case + when $1 = 1 then + return 'one'; + when $1 = a + 2 then + return 'twelve'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +CREATE OR REPLACE FUNCTION case_test(bigint) RETURNS text AS $$ +declare a int = 10; +begin + case + when $1 = 1 then + return 'one'; + when $1 = a + 2 then + return 'twelve'; + else + return 'other'; + end case; +end; +$$ LANGUAGE plpgsql IMMUTABLE +== 048 +select case_test(1) +-- +SELECT case_test(1) +== 049 +select case_test(2) +-- +SELECT case_test(2) +== 050 +select case_test(12) +-- +SELECT case_test(12) +== 051 +select case_test(13) +-- +SELECT case_test(13) +== 052 +-- test line comment between WHEN and THEN +create or replace function case_comment(int) returns text as $$ +begin + case $1 + when 1 -- comment before THEN + then return 'one'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +CREATE OR REPLACE FUNCTION case_comment(int) RETURNS text AS $$ +begin + case $1 + when 1 -- comment before THEN + then return 'one'; + else + return 'other'; + end case; +end; +$$ LANGUAGE plpgsql IMMUTABLE +== 053 +select case_comment(1) +-- +SELECT case_comment(1) diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_copy.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_copy.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_copy.test new file mode 100644 index 0000000..2788c56 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_copy.test @@ -0,0 +1,21 @@ +== 001 +-- directory paths are passed to us in environment variables + +-- set up file names to use + +CREATE TABLE copy1 (a int, b float); + +-- COPY TO/FROM not authorized from client. +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 TO stdout; +END; +$$; +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 FROM stdin; +-- +ERROR: "unterminated dollar-quoted string at or near \"$$\nBEGIN\n COPY copy1 FROM stdin;\"" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_domain.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_domain.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_domain.test new file mode 100644 index 0000000..3daf488 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_domain.test @@ -0,0 +1,588 @@ +== 001 +|-- +-- Tests for PL/pgSQL's behavior with domain types +|-- + +CREATE DOMAIN booltrue AS bool CHECK (VALUE IS TRUE OR VALUE IS NULL) +-- +CREATE DOMAIN booltrue AS bool CHECK (value IS TRUE OR value IS NULL) +== 002 +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +== 003 +SELECT * FROM test_argresult_booltrue(true, true) +-- +SELECT * FROM test_argresult_booltrue(true, true) +== 004 +SELECT * FROM test_argresult_booltrue(false, true) +-- +SELECT * FROM test_argresult_booltrue(false, true) +== 005 +SELECT * FROM test_argresult_booltrue(true, false) +-- +SELECT * FROM test_argresult_booltrue(true, false) +== 006 +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $$ +declare v booltrue := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $$ +declare v booltrue := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +== 007 +SELECT * FROM test_assign_booltrue(true, true) +-- +SELECT * FROM test_assign_booltrue(true, true) +== 008 +SELECT * FROM test_assign_booltrue(false, true) +-- +SELECT * FROM test_assign_booltrue(false, true) +== 009 +SELECT * FROM test_assign_booltrue(true, false) +-- +SELECT * FROM test_assign_booltrue(true, false) +== 010 +CREATE DOMAIN uint2 AS int2 CHECK (VALUE >= 0) +-- +CREATE DOMAIN uint2 AS int2 CHECK (value >= 0) +== 011 +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +== 012 +SELECT * FROM test_argresult_uint2(100::uint2, 50) +-- +SELECT * FROM test_argresult_uint2(100::uint2, 50) +== 013 +SELECT * FROM test_argresult_uint2(100::uint2, -50) +-- +SELECT * FROM test_argresult_uint2(100::uint2, -50) +== 014 +SELECT * FROM test_argresult_uint2(null, 1) +-- +SELECT * FROM test_argresult_uint2(NULL, 1) +== 015 +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $$ +declare v uint2 := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $$ +declare v uint2 := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +== 016 +SELECT * FROM test_assign_uint2(100, 50) +-- +SELECT * FROM test_assign_uint2(100, 50) +== 017 +SELECT * FROM test_assign_uint2(100, -50) +-- +SELECT * FROM test_assign_uint2(100, -50) +== 018 +SELECT * FROM test_assign_uint2(-100, 50) +-- +SELECT * FROM test_assign_uint2(-100, 50) +== 019 +SELECT * FROM test_assign_uint2(null, 1) +-- +SELECT * FROM test_assign_uint2(NULL, 1) +== 020 +CREATE DOMAIN nnint AS int NOT NULL +-- +CREATE DOMAIN nnint AS int NOT NULL +== 021 +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +== 022 +SELECT * FROM test_argresult_nnint(10, 20) +-- +SELECT * FROM test_argresult_nnint(10, 20) +== 023 +SELECT * FROM test_argresult_nnint(null, 20) +-- +SELECT * FROM test_argresult_nnint(NULL, 20) +== 024 +SELECT * FROM test_argresult_nnint(10, null) +-- +SELECT * FROM test_argresult_nnint(10, NULL) +== 025 +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $$ +declare v nnint := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $$ +declare v nnint := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +== 026 +SELECT * FROM test_assign_nnint(10, 20) +-- +SELECT * FROM test_assign_nnint(10, 20) +== 027 +SELECT * FROM test_assign_nnint(null, 20) +-- +SELECT * FROM test_assign_nnint(NULL, 20) +== 028 +SELECT * FROM test_assign_nnint(10, null) +-- +SELECT * FROM test_assign_nnint(10, NULL) +== 029 +|-- +-- Domains over arrays +|-- + +CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]) +-- +CREATE DOMAIN ordered_pair_domain AS int[] CHECK (array_length(value, 1) = 2 AND value[1] < value[2]) +== 030 +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) + RETURNS ordered_pair_domain AS $$ +begin +return x; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) RETURNS ordered_pair_domain AS $$ +begin +return x; +end +$$ LANGUAGE plpgsql +== 031 +SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain) +-- +SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain) +== 032 +SELECT * FROM test_argresult_array_domain(NULL::ordered_pair_domain) +-- +SELECT * FROM test_argresult_array_domain(NULL::ordered_pair_domain) +== 033 +CREATE FUNCTION test_argresult_array_domain_check_violation() + RETURNS ordered_pair_domain AS $$ +begin +return array[2,1]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_array_domain_check_violation() RETURNS ordered_pair_domain AS $$ +begin +return array[2,1]; +end +$$ LANGUAGE plpgsql +== 034 +SELECT * FROM test_argresult_array_domain_check_violation() +-- +SELECT * FROM test_argresult_array_domain_check_violation() +== 035 +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $$ +declare v ordered_pair_domain := array[x, y]; +begin +v[2] := z; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $$ +declare v ordered_pair_domain := array[x, y]; +begin +v[2] := z; +return v; +end +$$ LANGUAGE plpgsql +== 036 +SELECT * FROM test_assign_ordered_pair_domain(1,2,3) +-- +SELECT * FROM test_assign_ordered_pair_domain(1, 2, 3) +== 037 +SELECT * FROM test_assign_ordered_pair_domain(1,2,0) +-- +SELECT * FROM test_assign_ordered_pair_domain(1, 2, 0) +== 038 +SELECT * FROM test_assign_ordered_pair_domain(2,1,3) +-- +SELECT * FROM test_assign_ordered_pair_domain(2, 1, 3) +== 039 +|-- +-- Arrays of domains +|-- + +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +== 040 +select test_read_uint2_array(array[1::uint2]) +-- +SELECT test_read_uint2_array(ARRAY[1::uint2]) +== 041 +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $$ +begin +return array[x, x]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $$ +begin +return array[x, x]; +end +$$ LANGUAGE plpgsql +== 042 +select test_build_uint2_array(1::int2) +-- +SELECT test_build_uint2_array(1::int2) +== 043 +select test_build_uint2_array(-1::int2) +-- +SELECT test_build_uint2_array(- 1::int2) +== 044 +-- fail + +CREATE FUNCTION test_argresult_domain_array(x integer[]) + RETURNS ordered_pair_domain[] AS $$ +begin +return array[x::ordered_pair_domain, x::ordered_pair_domain]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_domain_array(x int[]) RETURNS ordered_pair_domain[] AS $$ +begin +return array[x::ordered_pair_domain, x::ordered_pair_domain]; +end +$$ LANGUAGE plpgsql +== 045 +select test_argresult_domain_array(array[2,4]) +-- +SELECT test_argresult_domain_array(ARRAY[2, 4]) +== 046 +select test_argresult_domain_array(array[4,2]) +-- +SELECT test_argresult_domain_array(ARRAY[4, 2]) +== 047 +-- fail + +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) + RETURNS integer AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) RETURNS int AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +== 048 +select test_argresult_domain_array2(array[2,4]) +-- +SELECT test_argresult_domain_array2(ARRAY[2, 4]) +== 049 +select test_argresult_domain_array2(array[4,2]) +-- +SELECT test_argresult_domain_array2(ARRAY[4, 2]) +== 050 +-- fail + +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) + RETURNS ordered_pair_domain AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) RETURNS ordered_pair_domain AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +== 051 +select test_argresult_array_domain_array(array[array[2,4]::ordered_pair_domain]) +-- +SELECT test_argresult_array_domain_array(ARRAY[ARRAY[2, 4]::ordered_pair_domain]) +== 052 +|-- +-- Domains within composite +|-- + +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +-- +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +== 053 +CREATE FUNCTION test_result_nnint_container(x int, y int) + RETURNS nnint_container AS $$ +begin +return row(x, y)::nnint_container; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_result_nnint_container(x int, y int) RETURNS nnint_container AS $$ +begin +return row(x, y)::nnint_container; +end +$$ LANGUAGE plpgsql +== 054 +SELECT test_result_nnint_container(null, 3) +-- +SELECT test_result_nnint_container(NULL, 3) +== 055 +SELECT test_result_nnint_container(3, null) +-- +SELECT test_result_nnint_container(3, NULL) +== 056 +-- fail + +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container := row(x, y); +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) RETURNS nnint_container AS $$ +declare v nnint_container := row(x, y); +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +== 057 +SELECT * FROM test_assign_nnint_container(1,2,3) +-- +SELECT * FROM test_assign_nnint_container(1, 2, 3) +== 058 +SELECT * FROM test_assign_nnint_container(1,2,null) +-- +SELECT * FROM test_assign_nnint_container(1, 2, NULL) +== 059 +SELECT * FROM test_assign_nnint_container(1,null,3) +-- +SELECT * FROM test_assign_nnint_container(1, NULL, 3) +== 060 +-- Since core system allows this: +SELECT null::nnint_container +-- +SELECT NULL::nnint_container +== 061 +-- so should PL/PgSQL + +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container; +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) RETURNS nnint_container AS $$ +declare v nnint_container; +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +== 062 +SELECT * FROM test_assign_nnint_container2(1,2,3) +-- +SELECT * FROM test_assign_nnint_container2(1, 2, 3) +== 063 +SELECT * FROM test_assign_nnint_container2(1,2,null) +-- +SELECT * FROM test_assign_nnint_container2(1, 2, NULL) +== 064 +|-- +-- Domains of composite +|-- + +CREATE TYPE named_pair AS ( + i integer, + j integer +) +-- +CREATE TYPE named_pair AS (i int, j int) +== 065 +CREATE DOMAIN ordered_named_pair AS named_pair CHECK((VALUE).i <= (VALUE).j) +-- +CREATE DOMAIN ordered_named_pair AS named_pair CHECK ((value).i <= (value).j) +== 066 +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS integer AS $$ +begin +return p.i + p.j; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS int AS $$ +begin +return p.i + p.j; +end +$$ LANGUAGE plpgsql +== 067 +SELECT read_ordered_named_pair(row(1, 2)) +-- +SELECT read_ordered_named_pair(ROW(1, 2)) +== 068 +SELECT read_ordered_named_pair(row(2, 1)) +-- +SELECT read_ordered_named_pair(ROW(2, 1)) +== 069 +-- fail + +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $$ +begin +return row(i, j); +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $$ +begin +return row(i, j); +end +$$ LANGUAGE plpgsql +== 070 +SELECT build_ordered_named_pair(1,2) +-- +SELECT build_ordered_named_pair(1, 2) +== 071 +SELECT build_ordered_named_pair(2,1) +-- +SELECT build_ordered_named_pair(2, 1) +== 072 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) + RETURNS ordered_named_pair AS $$ +declare v ordered_named_pair := row(x, y); +begin +v.j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) RETURNS ordered_named_pair AS $$ +declare v ordered_named_pair := row(x, y); +begin +v.j := z; +return v; +end +$$ LANGUAGE plpgsql +== 073 +SELECT * FROM test_assign_ordered_named_pair(1,2,3) +-- +SELECT * FROM test_assign_ordered_named_pair(1, 2, 3) +== 074 +SELECT * FROM test_assign_ordered_named_pair(1,2,0) +-- +SELECT * FROM test_assign_ordered_named_pair(1, 2, 0) +== 075 +SELECT * FROM test_assign_ordered_named_pair(2,1,3) +-- +SELECT * FROM test_assign_ordered_named_pair(2, 1, 3) +== 076 +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $$ +begin +return array[row(i, j), row(i, j+1)]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $$ +begin +return array[row(i, j), row(i, j+1)]; +end +$$ LANGUAGE plpgsql +== 077 +SELECT build_ordered_named_pairs(1,2) +-- +SELECT build_ordered_named_pairs(1, 2) +== 078 +SELECT build_ordered_named_pairs(2,1) +-- +SELECT build_ordered_named_pairs(2, 1) +== 079 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) + RETURNS ordered_named_pair[] AS $$ +declare v ordered_named_pair[] := array[row(x, y)]; +begin +-- ideally this would work, but it doesn't yet: +-- v[1].j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) RETURNS ordered_named_pair[] AS $$ +declare v ordered_named_pair[] := array[row(x, y)]; +begin +-- ideally this would work, but it doesn't yet: +-- v[1].j := z; +return v; +end +$$ LANGUAGE plpgsql +== 080 +SELECT * FROM test_assign_ordered_named_pairs(1,2,3) +-- +SELECT * FROM test_assign_ordered_named_pairs(1, 2, 3) +== 081 +SELECT * FROM test_assign_ordered_named_pairs(2,1,3) +-- +SELECT * FROM test_assign_ordered_named_pairs(2, 1, 3) +== 082 +SELECT * FROM test_assign_ordered_named_pairs(1,2,0) +-- +SELECT * FROM test_assign_ordered_named_pairs(1, 2, 0) diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_misc.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_misc.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_misc.test new file mode 100644 index 0000000..e27ac16 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_misc.test @@ -0,0 +1,89 @@ +== 001 +|-- +-- Miscellaneous topics +|-- + +-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE +do +$$ + declare procedure int; -- check we still recognize non-keywords as vars + begin + create function test1() returns int + begin atomic + select 2 + 2; + end; + create or replace procedure test2(x int) + begin atomic + select x + 2; + end; + end +$$ +-- +DO $$ + declare procedure int; -- check we still recognize non-keywords as vars + begin + create function test1() returns int + begin atomic + select 2 + 2; + end; + create or replace procedure test2(x int) + begin atomic + select x + 2; + end; + end +$$ +== 002 +-- Test %TYPE and %ROWTYPE error cases +create table misc_table(f1 int) +-- +CREATE TABLE misc_table (f1 int) +== 003 +do $$ declare x foo%type; begin end $$ +-- +DO $$ declare x foo%type; begin end $$ +== 004 +do $$ declare x notice%type; begin end $$ +-- +DO $$ declare x notice%type; begin end $$ +== 005 +-- covers unreserved-keyword case +do $$ declare x foo.bar%type; begin end $$ +-- +DO $$ declare x foo.bar%type; begin end $$ +== 006 +do $$ declare x foo.bar.baz%type; begin end $$ +-- +DO $$ declare x foo.bar.baz%type; begin end $$ +== 007 +do $$ declare x public.foo.bar%type; begin end $$ +-- +DO $$ declare x public.foo.bar%type; begin end $$ +== 008 +do $$ declare x public.misc_table.zed%type; begin end $$ +-- +DO $$ declare x public.misc_table.zed%type; begin end $$ +== 009 +do $$ declare x foo%rowtype; begin end $$ +-- +DO $$ declare x foo%rowtype; begin end $$ +== 010 +do $$ declare x notice%rowtype; begin end $$ +-- +DO $$ declare x notice%rowtype; begin end $$ +== 011 +-- covers unreserved-keyword case +do $$ declare x foo.bar%rowtype; begin end $$ +-- +DO $$ declare x foo.bar%rowtype; begin end $$ +== 012 +do $$ declare x foo.bar.baz%rowtype; begin end $$ +-- +DO $$ declare x foo.bar.baz%rowtype; begin end $$ +== 013 +do $$ declare x public.foo%rowtype; begin end $$ +-- +DO $$ declare x public.foo%rowtype; begin end $$ +== 014 +do $$ declare x public.misc_table%rowtype; begin end $$ +-- +DO $$ declare x public.misc_table%rowtype; begin end $$ diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_record.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_record.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_record.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_record.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_record.test new file mode 100644 index 0000000..5ae0b19 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_record.test @@ -0,0 +1,1225 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of composite (record) variables +|-- + +create type two_int4s as (f1 int4, f2 int4) +-- +CREATE TYPE two_int4s AS (f1 int4, f2 int4) +== 002 +create type more_int4s as (f0 text, f1 int4, f2 int4) +-- +CREATE TYPE more_int4s AS (f0 text, f1 int4, f2 int4) +== 003 +create type two_int8s as (q1 int8, q2 int8) +-- +CREATE TYPE two_int8s AS (q1 int8, q2 int8) +== 004 +create type nested_int8s as (c1 two_int8s, c2 two_int8s) +-- +CREATE TYPE nested_int8s AS (c1 two_int8s, c2 two_int8s) +== 005 +-- base-case return of a composite type +create function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1)::two_int8s; end $$ +-- +CREATE FUNCTION retc(int) RETURNS two_int8s LANGUAGE plpgsql AS $$ begin return row($1,1)::two_int8s; end $$ +== 006 +select retc(42) +-- +SELECT retc(42) +== 007 +-- ok to return a matching record type +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8); end $$ +-- +CREATE OR REPLACE FUNCTION retc(int) RETURNS two_int8s LANGUAGE plpgsql AS $$ begin return row($1::int8, 1::int8); end $$ +== 008 +select retc(42) +-- +SELECT retc(42) +== 009 +-- we don't currently support implicit casting +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1); end $$ +-- +CREATE OR REPLACE FUNCTION retc(int) RETURNS two_int8s LANGUAGE plpgsql AS $$ begin return row($1,1); end $$ +== 010 +select retc(42) +-- +SELECT retc(42) +== 011 +-- nor extra columns +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8, 42); end $$ +-- +CREATE OR REPLACE FUNCTION retc(int) RETURNS two_int8s LANGUAGE plpgsql AS $$ begin return row($1::int8, 1::int8, 42); end $$ +== 012 +select retc(42) +-- +SELECT retc(42) +== 013 +-- same cases with an intermediate "record" variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8); return r; end $$ +-- +CREATE OR REPLACE FUNCTION retc(int) RETURNS two_int8s LANGUAGE plpgsql AS $$ declare r record; begin r := row($1::int8, 1::int8); return r; end $$ +== 014 +select retc(42) +-- +SELECT retc(42) +== 015 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,1); return r; end $$ +-- +CREATE OR REPLACE FUNCTION retc(int) RETURNS two_int8s LANGUAGE plpgsql AS $$ declare r record; begin r := row($1,1); return r; end $$ +== 016 +select retc(42) +-- +SELECT retc(42) +== 017 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +CREATE OR REPLACE FUNCTION retc(int) RETURNS two_int8s LANGUAGE plpgsql AS $$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$ +== 018 +select retc(42) +-- +SELECT retc(42) +== 019 +-- but, for mostly historical reasons, we do convert when assigning +-- to a named-composite-type variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +CREATE OR REPLACE FUNCTION retc(int) RETURNS two_int8s LANGUAGE plpgsql AS $$ declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end $$ +== 020 +select retc(42) +-- +SELECT retc(42) +== 021 +do $$ declare c two_int8s; +begin c := row(1,2); raise notice 'c = %', c; end$$ +-- +DO $$ declare c two_int8s; +begin c := row(1,2); raise notice 'c = %', c; end$$ +== 022 +do $$ declare c two_int8s; +begin for c in select 1,2 loop raise notice 'c = %', c; end loop; end$$ +-- +DO $$ declare c two_int8s; +begin for c in select 1,2 loop raise notice 'c = %', c; end loop; end$$ +== 023 +do $$ declare c4 two_int4s; c8 two_int8s; +begin + c8 := row(1,2); + c4 := c8; + c8 := c4; + raise notice 'c4 = %', c4; + raise notice 'c8 = %', c8; +end$$ +-- +DO $$ declare c4 two_int4s; c8 two_int8s; +begin + c8 := row(1,2); + c4 := c8; + c8 := c4; + raise notice 'c4 = %', c4; + raise notice 'c8 = %', c8; +end$$ +== 024 +do $$ declare c two_int8s; d nested_int8s; +begin + c := row(1,2); + d := row(c, row(c.q1, c.q2+1)); + raise notice 'c = %, d = %', c, d; + c.q1 := 10; + d.c1 := row(11,12); + d.c2.q2 := 42; + raise notice 'c = %, d = %', c, d; + raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2; + raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens + raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens +end$$ +-- +DO $$ declare c two_int8s; d nested_int8s; +begin + c := row(1,2); + d := row(c, row(c.q1, c.q2+1)); + raise notice 'c = %, d = %', c, d; + c.q1 := 10; + d.c1 := row(11,12); + d.c2.q2 := 42; + raise notice 'c = %, d = %', c, d; + raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2; + raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens + raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens +end$$ +== 025 +-- block-qualified naming +do $$ <> declare c two_int8s; d nested_int8s; +begin + b.c := row(1,2); + b.d := row(b.c, row(b.c.q1, b.c.q2+1)); + raise notice 'b.c = %, b.d = %', b.c, b.d; + b.c.q1 := 10; + b.d.c1 := row(11,12); + b.d.c2.q2 := 42; + raise notice 'b.c = %, b.d = %', b.c, b.d; + raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2; + raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens + raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens +end$$ +-- +DO $$ <> declare c two_int8s; d nested_int8s; +begin + b.c := row(1,2); + b.d := row(b.c, row(b.c.q1, b.c.q2+1)); + raise notice 'b.c = %, b.d = %', b.c, b.d; + b.c.q1 := 10; + b.d.c1 := row(11,12); + b.d.c2.q2 := 42; + raise notice 'b.c = %, b.d = %', b.c, b.d; + raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2; + raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens + raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens +end$$ +== 026 +-- error cases +do $$ declare c two_int8s; begin c.x = 1; end $$ +-- +DO $$ declare c two_int8s; begin c.x = 1; end $$ +== 027 +do $$ declare c nested_int8s; begin c.x = 1; end $$ +-- +DO $$ declare c nested_int8s; begin c.x = 1; end $$ +== 028 +do $$ declare c nested_int8s; begin c.x.q1 = 1; end $$ +-- +DO $$ declare c nested_int8s; begin c.x.q1 = 1; end $$ +== 029 +do $$ declare c nested_int8s; begin c.c2.x = 1; end $$ +-- +DO $$ declare c nested_int8s; begin c.c2.x = 1; end $$ +== 030 +do $$ declare c nested_int8s; begin d.c2.x = 1; end $$ +-- +DO $$ declare c nested_int8s; begin d.c2.x = 1; end $$ +== 031 +do $$ <> declare c two_int8s; begin b.c.x = 1; end $$ +-- +DO $$ <> declare c two_int8s; begin b.c.x = 1; end $$ +== 032 +do $$ <> declare c nested_int8s; begin b.c.x = 1; end $$ +-- +DO $$ <> declare c nested_int8s; begin b.c.x = 1; end $$ +== 033 +do $$ <> declare c nested_int8s; begin b.c.x.q1 = 1; end $$ +-- +DO $$ <> declare c nested_int8s; begin b.c.x.q1 = 1; end $$ +== 034 +do $$ <> declare c nested_int8s; begin b.c.c2.x = 1; end $$ +-- +DO $$ <> declare c nested_int8s; begin b.c.c2.x = 1; end $$ +== 035 +do $$ <> declare c nested_int8s; begin b.d.c2.x = 1; end $$ +-- +DO $$ <> declare c nested_int8s; begin b.d.c2.x = 1; end $$ +== 036 +-- check passing composite result to another function +create function getq1(two_int8s) returns int8 language plpgsql as $$ +declare r two_int8s; begin r := $1; return r.q1; end $$ +-- +CREATE FUNCTION getq1(two_int8s) RETURNS int8 LANGUAGE plpgsql AS $$ +declare r two_int8s; begin r := $1; return r.q1; end $$ +== 037 +select getq1(retc(344)) +-- +SELECT getq1(retc(344)) +== 038 +select getq1(row(1,2)) +-- +SELECT getq1(ROW(1, 2)) +== 039 +do $$ +declare r1 two_int8s; r2 record; x int8; +begin + r1 := retc(345); + perform getq1(r1); + x := getq1(r1); + raise notice 'x = %', x; + r2 := retc(346); + perform getq1(r2); + x := getq1(r2); + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare r1 two_int8s; r2 record; x int8; +begin + r1 := retc(345); + perform getq1(r1); + x := getq1(r1); + raise notice 'x = %', x; + r2 := retc(346); + perform getq1(r2); + x := getq1(r2); + raise notice 'x = %', x; +end$$ +== 040 +-- check assignments of composites +do $$ +declare r1 two_int8s; r2 two_int8s; r3 record; r4 record; +begin + r1 := row(1,2); + raise notice 'r1 = %', r1; + r1 := r1; -- shouldn't do anything + raise notice 'r1 = %', r1; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := null; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := row(7,11)::two_int8s; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r3 := row(1,2); + r4 := r3; + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r1 := r3; + raise notice 'r1 = %', r1; + r4 := r1; + raise notice 'r4 = %', r4; + r4.q2 := r4.q2 + 1; -- r4's field names have changed + raise notice 'r4 = %', r4; +end$$ +-- +DO $$ +declare r1 two_int8s; r2 two_int8s; r3 record; r4 record; +begin + r1 := row(1,2); + raise notice 'r1 = %', r1; + r1 := r1; -- shouldn't do anything + raise notice 'r1 = %', r1; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := null; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := row(7,11)::two_int8s; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r3 := row(1,2); + r4 := r3; + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r1 := r3; + raise notice 'r1 = %', r1; + r4 := r1; + raise notice 'r4 = %', r4; + r4.q2 := r4.q2 + 1; -- r4's field names have changed + raise notice 'r4 = %', r4; +end$$ +== 041 +-- fields of named-type vars read as null if uninitialized +do $$ +declare r1 two_int8s; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; +end$$ +-- +DO $$ +declare r1 two_int8s; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; +end$$ +== 042 +do $$ +declare r1 two_int8s; +begin + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +DO $$ +declare r1 two_int8s; +begin + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +== 043 +-- records, not so much +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; +end$$ +-- +DO $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; +end$$ +== 044 +-- but OK if you assign first +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + r1 := row(1,2); + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +DO $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + r1 := row(1,2); + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +== 045 +-- check %type with block-qualified variable names +do $$ +<> +declare + v int; + r two_int8s; + v1 v%type; + v2 blk.v%type; + r1 r%type; + r2 blk.r%type; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(r1); + raise notice '%', pg_typeof(r2); +end$$ +-- +DO $$ +<> +declare + v int; + r two_int8s; + v1 v%type; + v2 blk.v%type; + r1 r%type; + r2 blk.r%type; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(r1); + raise notice '%', pg_typeof(r2); +end$$ +== 046 +-- check that type record can be passed through %type +do $$ +declare r1 record; + r2 r1%type; +begin + r2 := row(1,2); + raise notice 'r2 = %', r2; + r2 := row(3,4,5); + raise notice 'r2 = %', r2; +end$$ +-- +DO $$ +declare r1 record; + r2 r1%type; +begin + r2 := row(1,2); + raise notice 'r2 = %', r2; + r2 := row(3,4,5); + raise notice 'r2 = %', r2; +end$$ +== 047 +-- arrays of record are not supported at the moment +do $$ +declare r1 record[]; +begin +end$$ +-- +DO $$ +declare r1 record[]; +begin +end$$ +== 048 +do $$ +declare r1 record; + r2 r1%type[]; +begin +end$$ +-- +DO $$ +declare r1 record; + r2 r1%type[]; +begin +end$$ +== 049 +-- check repeated assignments to composite fields +create table some_table (id int, data text) +-- +CREATE TABLE some_table (id int, data text) +== 050 +do $$ +declare r some_table; +begin + r := (23, 'skidoo'); + for i in 1 .. 10 loop + r.id := r.id + i; + r.data := r.data || ' ' || i; + end loop; + raise notice 'r = %', r; +end$$ +-- +DO $$ +declare r some_table; +begin + r := (23, 'skidoo'); + for i in 1 .. 10 loop + r.id := r.id + i; + r.data := r.data || ' ' || i; + end loop; + raise notice 'r = %', r; +end$$ +== 051 +-- check behavior of function declared to return "record" + +create function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1); end $$ +-- +CREATE FUNCTION returnsrecord(int) RETURNS record LANGUAGE plpgsql AS $$ begin return row($1,$1+1); end $$ +== 052 +select returnsrecord(42) +-- +SELECT returnsrecord(42) +== 053 +select * from returnsrecord(42) as r(x int, y int) +-- +SELECT * FROM returnsrecord(42) r (x int, y int) +== 054 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +SELECT * FROM returnsrecord(42) r (x int, y int, z int) +== 055 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +SELECT * FROM returnsrecord(42) r (x int, y bigint) +== 056 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1); return r; end $$ +-- +CREATE OR REPLACE FUNCTION returnsrecord(int) RETURNS record LANGUAGE plpgsql AS $$ declare r record; begin r := row($1,$1+1); return r; end $$ +== 057 +select returnsrecord(42) +-- +SELECT returnsrecord(42) +== 058 +select * from returnsrecord(42) as r(x int, y int) +-- +SELECT * FROM returnsrecord(42) r (x int, y int) +== 059 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +SELECT * FROM returnsrecord(42) r (x int, y int, z int) +== 060 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +SELECT * FROM returnsrecord(42) r (x int, y bigint) +== 061 +-- fail + +-- should work the same with a missing column in the actual result value +create table has_hole(f1 int, f2 int, f3 int) +-- +CREATE TABLE has_hole (f1 int, f2 int, f3 int) +== 062 +alter table has_hole drop column f2 +-- +ALTER TABLE has_hole DROP f2 +== 063 +create or replace function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1)::has_hole; end $$ +-- +CREATE OR REPLACE FUNCTION returnsrecord(int) RETURNS record LANGUAGE plpgsql AS $$ begin return row($1,$1+1)::has_hole; end $$ +== 064 +select returnsrecord(42) +-- +SELECT returnsrecord(42) +== 065 +select * from returnsrecord(42) as r(x int, y int) +-- +SELECT * FROM returnsrecord(42) r (x int, y int) +== 066 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +SELECT * FROM returnsrecord(42) r (x int, y int, z int) +== 067 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +SELECT * FROM returnsrecord(42) r (x int, y bigint) +== 068 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1)::has_hole; return r; end $$ +-- +CREATE OR REPLACE FUNCTION returnsrecord(int) RETURNS record LANGUAGE plpgsql AS $$ declare r record; begin r := row($1,$1+1)::has_hole; return r; end $$ +== 069 +select returnsrecord(42) +-- +SELECT returnsrecord(42) +== 070 +select * from returnsrecord(42) as r(x int, y int) +-- +SELECT * FROM returnsrecord(42) r (x int, y int) +== 071 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +SELECT * FROM returnsrecord(42) r (x int, y int, z int) +== 072 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +SELECT * FROM returnsrecord(42) r (x int, y bigint) +== 073 +-- fail + +-- check access to a field of an argument declared "record" +create function getf1(x record) returns int language plpgsql as +$$ begin return x.f1; end $$ +-- +CREATE FUNCTION getf1(x record) RETURNS int LANGUAGE plpgsql AS $$ begin return x.f1; end $$ +== 074 +select getf1(1) +-- +SELECT getf1(1) +== 075 +select getf1(row(1,2)) +-- +SELECT getf1(ROW(1, 2)) +== 076 +select getf1(row(1,2)::two_int4s) +-- +SELECT getf1(ROW(1, 2)::two_int4s) +== 077 +select getf1(row('foo',123,456)::more_int4s) +-- +SELECT getf1(ROW('foo', 123, 456)::more_int4s) +== 078 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf1(row(1,2)::two_int8s) +-- +SELECT getf1(ROW(1, 2)::two_int8s) +== 079 +select getf1(row(1,2)) +-- +SELECT getf1(ROW(1, 2)) +== 080 +-- this seemingly-equivalent case behaves a bit differently, +-- because the core parser's handling of $N symbols is simplistic +create function getf2(record) returns int language plpgsql as +$$ begin return $1.f2; end $$ +-- +CREATE FUNCTION getf2(record) RETURNS int LANGUAGE plpgsql AS $$ begin return $1.f2; end $$ +== 081 +select getf2(row(1,2)) +-- +SELECT getf2(ROW(1, 2)) +== 082 +-- ideally would work, but does not +select getf2(row(1,2)::two_int4s) +-- +SELECT getf2(ROW(1, 2)::two_int4s) +== 083 +select getf2(row('foo',123,456)::more_int4s) +-- +SELECT getf2(ROW('foo', 123, 456)::more_int4s) +== 084 +-- check behavior when assignment to FOR-loop variable requires coercion +do $$ +declare r two_int8s; +begin + for r in select i, i+1 from generate_series(1,4) i + loop + raise notice 'r = %', r; + end loop; +end$$ +-- +DO $$ +declare r two_int8s; +begin + for r in select i, i+1 from generate_series(1,4) i + loop + raise notice 'r = %', r; + end loop; +end$$ +== 085 +-- check behavior when returning setof composite +create function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; + h has_hole; +begin + return next h; + r := (1,2); + h := (3,4); + return next r; + return next h; + return next row(5,6); + return next row(7,8)::has_hole; +end$$ +-- +CREATE FUNCTION returnssetofholes() RETURNS SETOF has_hole LANGUAGE plpgsql AS $$ +declare r record; + h has_hole; +begin + return next h; + r := (1,2); + h := (3,4); + return next r; + return next h; + return next row(5,6); + return next row(7,8)::has_hole; +end$$ +== 086 +select returnssetofholes() +-- +SELECT returnssetofholes() +== 087 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; +begin + return next r; -- fails, not assigned yet +end$$ +-- +CREATE OR REPLACE FUNCTION returnssetofholes() RETURNS SETOF has_hole LANGUAGE plpgsql AS $$ +declare r record; +begin + return next r; -- fails, not assigned yet +end$$ +== 088 +select returnssetofholes() +-- +SELECT returnssetofholes() +== 089 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +begin + return next row(1,2,3); -- fails +end$$ +-- +CREATE OR REPLACE FUNCTION returnssetofholes() RETURNS SETOF has_hole LANGUAGE plpgsql AS $$ +begin + return next row(1,2,3); -- fails +end$$ +== 090 +select returnssetofholes() +-- +SELECT returnssetofholes() +== 091 +-- check behavior with changes of a named rowtype +create table mutable(f1 int, f2 text) +-- +CREATE TABLE mutable (f1 int, f2 text) +== 092 +create function sillyaddone(int) returns int language plpgsql as +$$ declare r mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +CREATE FUNCTION sillyaddone(int) RETURNS int LANGUAGE plpgsql AS $$ declare r mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +== 093 +select sillyaddone(42) +-- +SELECT sillyaddone(42) +== 094 +-- test for change of type of column f1 should be here someday; +-- for now see plpgsql_cache test + +alter table mutable drop column f1 +-- +ALTER TABLE mutable DROP f1 +== 095 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddone(42) +-- +SELECT sillyaddone(42) +== 096 +-- fail + +create function getf3(x mutable) returns int language plpgsql as +$$ begin return x.f3; end $$ +-- +CREATE FUNCTION getf3(x mutable) RETURNS int LANGUAGE plpgsql AS $$ begin return x.f3; end $$ +== 097 +select getf3(null::mutable) +-- +SELECT getf3(NULL::mutable) +== 098 +-- doesn't work yet +alter table mutable add column f3 int +-- +ALTER TABLE mutable ADD COLUMN f3 int +== 099 +select getf3(null::mutable) +-- +SELECT getf3(NULL::mutable) +== 100 +-- now it works +alter table mutable drop column f3 +-- +ALTER TABLE mutable DROP f3 +== 101 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf3(null::mutable) +-- +SELECT getf3(NULL::mutable) +== 102 +-- fails again + +-- check behavior with creating/dropping a named rowtype +set check_function_bodies = off +-- +SET check_function_bodies TO OFF +== 103 +-- else reference to nonexistent type fails + +create function sillyaddtwo(int) returns int language plpgsql as +$$ declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end $$ +-- +CREATE FUNCTION sillyaddtwo(int) RETURNS int LANGUAGE plpgsql AS $$ declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end $$ +== 104 +reset check_function_bodies +-- +RESET check_function_bodies +== 105 +select sillyaddtwo(42) +-- +SELECT sillyaddtwo(42) +== 106 +-- fail +create table mutable2(f1 int, f2 text) +-- +CREATE TABLE mutable2 (f1 int, f2 text) +== 107 +select sillyaddtwo(42) +-- +SELECT sillyaddtwo(42) +== 108 +drop table mutable2 +-- +DROP TABLE mutable2 +== 109 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddtwo(42) +-- +SELECT sillyaddtwo(42) +== 110 +-- fail +create table mutable2(f0 text, f1 int, f2 text) +-- +CREATE TABLE mutable2 (f0 text, f1 int, f2 text) +== 111 +select sillyaddtwo(42) +-- +SELECT sillyaddtwo(42) +== 112 +select sillyaddtwo(43) +-- +SELECT sillyaddtwo(43) +== 113 +-- check access to system columns in a record variable + +create function sillytrig() returns trigger language plpgsql as +$$begin + raise notice 'old.ctid = %', old.ctid; + raise notice 'old.tableoid = %', old.tableoid::regclass; + return new; +end$$ +-- +CREATE FUNCTION sillytrig() RETURNS trigger LANGUAGE plpgsql AS $$begin + raise notice 'old.ctid = %', old.ctid; + raise notice 'old.tableoid = %', old.tableoid::regclass; + return new; +end$$ +== 114 +create trigger mutable_trig before update on mutable for each row +execute procedure sillytrig() +-- +CREATE TRIGGER mutable_trig BEFORE UPDATE ON mutable FOR EACH ROW EXECUTE FUNCTION sillytrig() +== 115 +insert into mutable values ('foo'), ('bar') +-- +INSERT INTO mutable VALUES ('foo'), ('bar') +== 116 +update mutable set f2 = f2 || ' baz' +-- +UPDATE mutable SET f2 = f2 || ' baz' +== 117 +table mutable +-- +SELECT * FROM mutable +== 118 +-- check returning a composite datum from a trigger + +create or replace function sillytrig() returns trigger language plpgsql as +$$begin + return row(new.*); +end$$ +-- +CREATE OR REPLACE FUNCTION sillytrig() RETURNS trigger LANGUAGE plpgsql AS $$begin + return row(new.*); +end$$ +== 119 +update mutable set f2 = f2 || ' baz' +-- +UPDATE mutable SET f2 = f2 || ' baz' +== 120 +table mutable +-- +SELECT * FROM mutable +== 121 +create or replace function sillytrig() returns trigger language plpgsql as +$$declare r record; +begin + r := row(new.*); + return r; +end$$ +-- +CREATE OR REPLACE FUNCTION sillytrig() RETURNS trigger LANGUAGE plpgsql AS $$declare r record; +begin + r := row(new.*); + return r; +end$$ +== 122 +update mutable set f2 = f2 || ' baz' +-- +UPDATE mutable SET f2 = f2 || ' baz' +== 123 +table mutable +-- +SELECT * FROM mutable +== 124 +|-- +-- Domains of composite +|-- + +create domain ordered_int8s as two_int8s check((value).q1 <= (value).q2) +-- +CREATE DOMAIN ordered_int8s AS two_int8s CHECK ((value).q1 <= (value).q2) +== 125 +create function read_ordered_int8s(p ordered_int8s) returns int8 as $$ +begin return p.q1 + p.q2; end +$$ language plpgsql +-- +CREATE FUNCTION read_ordered_int8s(p ordered_int8s) RETURNS int8 AS $$ +begin return p.q1 + p.q2; end +$$ LANGUAGE plpgsql +== 126 +select read_ordered_int8s(row(1, 2)) +-- +SELECT read_ordered_int8s(ROW(1, 2)) +== 127 +select read_ordered_int8s(row(2, 1)) +-- +SELECT read_ordered_int8s(ROW(2, 1)) +== 128 +-- fail + +create function build_ordered_int8s(i int8, j int8) returns ordered_int8s as $$ +begin return row(i,j); end +$$ language plpgsql +-- +CREATE FUNCTION build_ordered_int8s(i int8, j int8) RETURNS ordered_int8s AS $$ +begin return row(i,j); end +$$ LANGUAGE plpgsql +== 129 +select build_ordered_int8s(1,2) +-- +SELECT build_ordered_int8s(1, 2) +== 130 +select build_ordered_int8s(2,1) +-- +SELECT build_ordered_int8s(2, 1) +== 131 +-- fail + +create function build_ordered_int8s_2(i int8, j int8) returns ordered_int8s as $$ +declare r record; begin r := row(i,j); return r; end +$$ language plpgsql +-- +CREATE FUNCTION build_ordered_int8s_2(i int8, j int8) RETURNS ordered_int8s AS $$ +declare r record; begin r := row(i,j); return r; end +$$ LANGUAGE plpgsql +== 132 +select build_ordered_int8s_2(1,2) +-- +SELECT build_ordered_int8s_2(1, 2) +== 133 +select build_ordered_int8s_2(2,1) +-- +SELECT build_ordered_int8s_2(2, 1) +== 134 +-- fail + +create function build_ordered_int8s_3(i int8, j int8) returns ordered_int8s as $$ +declare r two_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +CREATE FUNCTION build_ordered_int8s_3(i int8, j int8) RETURNS ordered_int8s AS $$ +declare r two_int8s; begin r := row(i,j); return r; end +$$ LANGUAGE plpgsql +== 135 +select build_ordered_int8s_3(1,2) +-- +SELECT build_ordered_int8s_3(1, 2) +== 136 +select build_ordered_int8s_3(2,1) +-- +SELECT build_ordered_int8s_3(2, 1) +== 137 +-- fail + +create function build_ordered_int8s_4(i int8, j int8) returns ordered_int8s as $$ +declare r ordered_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +CREATE FUNCTION build_ordered_int8s_4(i int8, j int8) RETURNS ordered_int8s AS $$ +declare r ordered_int8s; begin r := row(i,j); return r; end +$$ LANGUAGE plpgsql +== 138 +select build_ordered_int8s_4(1,2) +-- +SELECT build_ordered_int8s_4(1, 2) +== 139 +select build_ordered_int8s_4(2,1) +-- +SELECT build_ordered_int8s_4(2, 1) +== 140 +-- fail + +create function build_ordered_int8s_a(i int8, j int8) returns ordered_int8s[] as $$ +begin return array[row(i,j), row(i,j+1)]; end +$$ language plpgsql +-- +CREATE FUNCTION build_ordered_int8s_a(i int8, j int8) RETURNS ordered_int8s[] AS $$ +begin return array[row(i,j), row(i,j+1)]; end +$$ LANGUAGE plpgsql +== 141 +select build_ordered_int8s_a(1,2) +-- +SELECT build_ordered_int8s_a(1, 2) +== 142 +select build_ordered_int8s_a(2,1) +-- +SELECT build_ordered_int8s_a(2, 1) +== 143 +-- fail + +-- check field assignment +do $$ +declare r ordered_int8s; +begin + r.q1 := null; + r.q2 := 43; + r.q1 := 42; + r.q2 := 41; -- fail +end$$ +-- +DO $$ +declare r ordered_int8s; +begin + r.q1 := null; + r.q2 := 43; + r.q1 := 42; + r.q2 := 41; -- fail +end$$ +== 144 +-- check whole-row assignment +do $$ +declare r ordered_int8s; +begin + r := null; + r := row(null,null); + r := row(1,2); + r := row(2,1); -- fail +end$$ +-- +DO $$ +declare r ordered_int8s; +begin + r := null; + r := row(null,null); + r := row(1,2); + r := row(2,1); -- fail +end$$ +== 145 +-- check assignment in for-loop +do $$ +declare r ordered_int8s; +begin + for r in values (1,2),(3,4),(6,5) loop + raise notice 'r = %', r; + end loop; +end$$ +-- +DO $$ +declare r ordered_int8s; +begin + for r in values (1,2),(3,4),(6,5) loop + raise notice 'r = %', r; + end loop; +end$$ +== 146 +-- check behavior with toastable fields, too + +create type two_texts as (f1 text, f2 text) +-- +CREATE TYPE two_texts AS (f1 text, f2 text) +== 147 +create domain ordered_texts as two_texts check((value).f1 <= (value).f2) +-- +CREATE DOMAIN ordered_texts AS two_texts CHECK ((value).f1 <= (value).f2) +== 148 +create table sometable (id int, a text, b text) +-- +CREATE TABLE sometable (id int, a text, b text) +== 149 +-- b should be compressed, but in-line +insert into sometable values (1, 'a', repeat('ffoob',1000)) +-- +INSERT INTO sometable VALUES (1, 'a', repeat('ffoob', 1000)) +== 150 +-- this b should be out-of-line +insert into sometable values (2, 'a', repeat('ffoob',100000)) +-- +INSERT INTO sometable VALUES (2, 'a', repeat('ffoob', 100000)) +== 151 +-- this pair should fail the domain check +insert into sometable values (3, 'z', repeat('ffoob',100000)) +-- +INSERT INTO sometable VALUES (3, 'z', repeat('ffoob', 100000)) +== 152 +do $$ +declare d ordered_texts; +begin + for d in select a, b from sometable loop + raise notice 'succeeded at "%"', d.f1; + end loop; +end$$ +-- +DO $$ +declare d ordered_texts; +begin + for d in select a, b from sometable loop + raise notice 'succeeded at "%"', d.f1; + end loop; +end$$ +== 153 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := row(r.a, r.b); + end loop; +end$$ +-- +DO $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := row(r.a, r.b); + end loop; +end$$ +== 154 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := null; + d.f1 := r.a; + d.f2 := r.b; + end loop; +end$$ +-- +DO $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := null; + d.f1 := r.a; + d.f2 := r.b; + end loop; +end$$ +== 155 +-- check coercion of a record result to named-composite function output type +create function compresult(int8) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,$1); return r; end $$ +-- +CREATE FUNCTION compresult(int8) RETURNS two_int8s LANGUAGE plpgsql AS $$ declare r record; begin r := row($1,$1); return r; end $$ +== 156 +create table two_int8s_tab (f1 two_int8s) +-- +CREATE TABLE two_int8s_tab (f1 two_int8s) +== 157 +insert into two_int8s_tab values (compresult(42)) +-- +INSERT INTO two_int8s_tab VALUES (compresult(42)) +== 158 +-- reconnect so we lose any local knowledge of anonymous record types +table two_int8s_tab +-- +SELECT * FROM two_int8s_tab diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_simple.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_simple.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_simple.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_simple.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_simple.test new file mode 100644 index 0000000..265b847 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_simple.test @@ -0,0 +1,205 @@ +== 001 +|-- +-- Tests for plpgsql's handling of "simple" expressions +|-- + +-- Check that changes to an inline-able function are handled correctly +create function simplesql(int) returns int language sql +as 'select $1' +-- +CREATE FUNCTION simplesql(int) RETURNS int LANGUAGE sql AS $$select $1$$ +== 002 +create function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simplesql(n); + if n = 5 then + create or replace function simplesql(int) returns int language sql + as 'select $1 + 100'; + end if; + end loop; + return sum; +end$$ +-- +CREATE FUNCTION simplecaller() RETURNS int LANGUAGE plpgsql AS $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simplesql(n); + if n = 5 then + create or replace function simplesql(int) returns int language sql + as 'select $1 + 100'; + end if; + end loop; + return sum; +end$$ +== 003 +select simplecaller() +-- +SELECT simplecaller() +== 004 +-- Check that changes in search path are dealt with correctly +create schema simple1 +-- +CREATE SCHEMA simple1 +== 005 +create function simple1.simpletarget(int) returns int language plpgsql +as $$begin return $1; end$$ +-- +CREATE FUNCTION simple1.simpletarget(int) RETURNS int LANGUAGE plpgsql AS $$begin return $1; end$$ +== 006 +create function simpletarget(int) returns int language plpgsql +as $$begin return $1 + 100; end$$ +-- +CREATE FUNCTION simpletarget(int) RETURNS int LANGUAGE plpgsql AS $$begin return $1 + 100; end$$ +== 007 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simpletarget(n); + if n = 5 then + set local search_path = 'simple1'; + end if; + end loop; + return sum; +end$$ +-- +CREATE OR REPLACE FUNCTION simplecaller() RETURNS int LANGUAGE plpgsql AS $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simpletarget(n); + if n = 5 then + set local search_path = 'simple1'; + end if; + end loop; + return sum; +end$$ +== 008 +select simplecaller() +-- +SELECT simplecaller() +== 009 +-- try it with non-volatile functions, too +alter function simple1.simpletarget(int) immutable +-- +ALTER FUNCTION simple1.simpletarget(int) IMMUTABLE +== 010 +alter function simpletarget(int) immutable +-- +ALTER FUNCTION simpletarget(int) IMMUTABLE +== 011 +select simplecaller() +-- +SELECT simplecaller() +== 012 +-- make sure flushing local caches changes nothing + +select simplecaller() +-- +SELECT simplecaller() +== 013 +-- Check case where first attempt to determine if it's simple fails + +create function simplesql() returns int language sql +as $$select 1 / 0$$ +-- +CREATE FUNCTION simplesql() RETURNS int LANGUAGE sql AS $$select 1 / 0$$ +== 014 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + select simplesql() into x; + return x; +end$$ +-- +CREATE OR REPLACE FUNCTION simplecaller() RETURNS int LANGUAGE plpgsql AS $$ +declare x int; +begin + select simplesql() into x; + return x; +end$$ +== 015 +select simplecaller() +-- +SELECT simplecaller() +== 016 +-- division by zero occurs during simple-expr check + +create or replace function simplesql() returns int language sql +as $$select 2 + 2$$ +-- +CREATE OR REPLACE FUNCTION simplesql() RETURNS int LANGUAGE sql AS $$select 2 + 2$$ +== 017 +select simplecaller() +-- +SELECT simplecaller() +== 018 +-- Check case where called function changes from non-SRF to SRF (bug #18497) + +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + x := simplesql(); + return x; +end$$ +-- +CREATE OR REPLACE FUNCTION simplecaller() RETURNS int LANGUAGE plpgsql AS $$ +declare x int; +begin + x := simplesql(); + return x; +end$$ +== 019 +select simplecaller() +-- +SELECT simplecaller() +== 020 +drop function simplesql() +-- +DROP FUNCTION simplesql() +== 021 +create function simplesql() returns setof int language sql +as $$select 22 + 22$$ +-- +CREATE FUNCTION simplesql() RETURNS SETOF int LANGUAGE sql AS $$select 22 + 22$$ +== 022 +select simplecaller() +-- +SELECT simplecaller() +== 023 +select simplecaller() +-- +SELECT simplecaller() +== 024 +-- Check handling of simple expression in a scrollable cursor (bug #18859) + +do $$ +declare + p_CurData refcursor; + val int; +begin + open p_CurData scroll for select 42; + fetch p_CurData into val; + raise notice 'val = %', val; +end; $$ +-- +DO $$ +declare + p_CurData refcursor; + val int; +begin + open p_CurData scroll for select 42; + fetch p_CurData into val; + raise notice 'val = %', val; +end; $$ diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_transaction.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_transaction.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_transaction.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_transaction.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_transaction.test new file mode 100644 index 0000000..ebd107b --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_transaction.test @@ -0,0 +1,1163 @@ +== 001 +CREATE TABLE test1 (a int, b text) +-- +CREATE TABLE test1 (a int, b text) +== 002 +CREATE PROCEDURE transaction_test1(x int, y text) +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..x LOOP + INSERT INTO test1 (a, b) VALUES (i, y); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +CREATE PROCEDURE transaction_test1(x int, y text) LANGUAGE plpgsql AS $$ +BEGIN + FOR i IN 0..x LOOP + INSERT INTO test1 (a, b) VALUES (i, y); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +== 003 +CALL transaction_test1(9, 'foo') +-- +CALL transaction_test1(9, 'foo') +== 004 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 005 +TRUNCATE test1 +-- +TRUNCATE test1 +== 006 +DO +LANGUAGE plpgsql +$$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +== 007 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 008 +-- transaction commands not allowed when called in transaction block +START TRANSACTION +-- +START TRANSACTION +== 009 +CALL transaction_test1(9, 'error') +-- +CALL transaction_test1(9, 'error') +== 010 +COMMIT +-- +COMMIT +== 011 +START TRANSACTION +-- +START TRANSACTION +== 012 +DO LANGUAGE plpgsql $$ BEGIN COMMIT; END $$ +-- +DO LANGUAGE plpgsql $$ BEGIN COMMIT; END $$ +== 013 +COMMIT +-- +COMMIT +== 014 +TRUNCATE test1 +-- +TRUNCATE test1 +== 015 +-- not allowed in a function +CREATE FUNCTION transaction_test2() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; + RETURN 1; +END +$$ +-- +CREATE FUNCTION transaction_test2() RETURNS int LANGUAGE plpgsql AS $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; + RETURN 1; +END +$$ +== 016 +SELECT transaction_test2() +-- +SELECT transaction_test2() +== 017 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 018 +-- also not allowed if procedure is called from a function +CREATE FUNCTION transaction_test3() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, 'error'); + RETURN 1; +END; +$$ +-- +CREATE FUNCTION transaction_test3() RETURNS int LANGUAGE plpgsql AS $$ +BEGIN + CALL transaction_test1(9, 'error'); + RETURN 1; +END; +$$ +== 019 +SELECT transaction_test3() +-- +SELECT transaction_test3() +== 020 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 021 +-- DO block inside function +CREATE FUNCTION transaction_test4() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'; + RETURN 1; +END; +$$ +-- +CREATE FUNCTION transaction_test4() RETURNS int LANGUAGE plpgsql AS $$ +BEGIN + EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'; + RETURN 1; +END; +$$ +== 022 +SELECT transaction_test4() +-- +SELECT transaction_test4() +== 023 +-- proconfig settings currently disallow transaction statements +CREATE PROCEDURE transaction_test5() +LANGUAGE plpgsql +SET work_mem = 555 +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +CREATE PROCEDURE transaction_test5() LANGUAGE plpgsql SET work_mem TO 555 AS $$ +BEGIN + COMMIT; +END; +$$ +== 024 +CALL transaction_test5() +-- +CALL transaction_test5() +== 025 +-- SECURITY DEFINER currently disallow transaction statements +CREATE PROCEDURE transaction_test5b() +LANGUAGE plpgsql +SECURITY DEFINER +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +CREATE PROCEDURE transaction_test5b() LANGUAGE plpgsql SECURITY DEFINER AS $$ +BEGIN + COMMIT; +END; +$$ +== 026 +CALL transaction_test5b() +-- +CALL transaction_test5b() +== 027 +TRUNCATE test1 +-- +TRUNCATE test1 +== 028 +-- nested procedure calls +CREATE PROCEDURE transaction_test6(c text) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, c); +END; +$$ +-- +CREATE PROCEDURE transaction_test6(c text) LANGUAGE plpgsql AS $$ +BEGIN + CALL transaction_test1(9, c); +END; +$$ +== 029 +CALL transaction_test6('bar') +-- +CALL transaction_test6('bar') +== 030 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 031 +TRUNCATE test1 +-- +TRUNCATE test1 +== 032 +CREATE PROCEDURE transaction_test7() +LANGUAGE plpgsql +AS $$ +BEGIN + DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'; +END; +$$ +-- +CREATE PROCEDURE transaction_test7() LANGUAGE plpgsql AS $$ +BEGIN + DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'; +END; +$$ +== 033 +CALL transaction_test7() +-- +CALL transaction_test7() +== 034 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 035 +CREATE PROCEDURE transaction_test8() +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'CALL transaction_test1(10, $x$baz$x$)'; +END; +$$ +-- +CREATE PROCEDURE transaction_test8() LANGUAGE plpgsql AS $$ +BEGIN + EXECUTE 'CALL transaction_test1(10, $x$baz$x$)'; +END; +$$ +== 036 +CALL transaction_test8() +-- +CALL transaction_test8() +== 037 +-- commit inside cursor loop +CREATE TABLE test2 (x int) +-- +CREATE TABLE test2 (x int) +== 038 +INSERT INTO test2 VALUES (0), (1), (2), (3), (4) +-- +INSERT INTO test2 VALUES (0), (1), (2), (3), (4) +== 039 +TRUNCATE test1 +-- +TRUNCATE test1 +== 040 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + COMMIT; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + COMMIT; + END LOOP; +END; +$$ +== 041 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 042 +-- check that this doesn't leak a holdable portal +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 043 +-- error in cursor loop with commit +TRUNCATE test1 +-- +TRUNCATE test1 +== 044 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (12/(r.x-2)); + COMMIT; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (12/(r.x-2)); + COMMIT; + END LOOP; +END; +$$ +== 045 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 046 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 047 +-- rollback inside cursor loop +TRUNCATE test1 +-- +TRUNCATE test1 +== 048 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +== 049 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 050 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 051 +-- first commit then rollback inside cursor loop +TRUNCATE test1 +-- +TRUNCATE test1 +== 052 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + IF r.x % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + IF r.x % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END; +$$ +== 053 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 054 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 055 +-- rollback inside cursor loop +TRUNCATE test1 +-- +TRUNCATE test1 +== 056 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +== 057 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 058 +SELECT * FROM test2 +-- +SELECT * FROM test2 +== 059 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 060 +-- interaction of FOR UPDATE cursor with subsequent updates (bug #17050) +TRUNCATE test1 +-- +TRUNCATE test1 +== 061 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +INSERT INTO test1 VALUES (1, 'one'), (2, 'two'), (3, 'three') +== 062 +DO LANGUAGE plpgsql $$ +DECLARE + l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE; +BEGIN + FOR r IN l_cur LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE + l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE; +BEGIN + FOR r IN l_cur LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +== 063 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 064 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 065 +-- like bug #17050, but with implicit cursor +TRUNCATE test1 +-- +TRUNCATE test1 +== 066 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +INSERT INTO test1 VALUES (1, 'one'), (2, 'two'), (3, 'three') +== 067 +DO LANGUAGE plpgsql $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT a FROM test1 FOR UPDATE LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT a FROM test1 FOR UPDATE LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +== 068 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 069 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 070 +-- commit inside block with exception handler +TRUNCATE test1 +-- +TRUNCATE test1 +== 071 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + COMMIT; + INSERT INTO test1 (a) VALUES (1/0); + COMMIT; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + COMMIT; + INSERT INTO test1 (a) VALUES (1/0); + COMMIT; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +== 072 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 073 +-- rollback inside block with exception handler +TRUNCATE test1 +-- +TRUNCATE test1 +== 074 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + ROLLBACK; + INSERT INTO test1 (a) VALUES (1/0); + ROLLBACK; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + ROLLBACK; + INSERT INTO test1 (a) VALUES (1/0); + ROLLBACK; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +== 075 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 076 +-- test commit/rollback inside exception handler, too +TRUNCATE test1 +-- +TRUNCATE test1 +== 077 +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 1..10 LOOP + BEGIN + INSERT INTO test1 VALUES (i, 'good'); + INSERT INTO test1 VALUES (i/0, 'bad'); + EXCEPTION + WHEN division_by_zero THEN + INSERT INTO test1 VALUES (i, 'exception'); + IF (i % 3) > 0 THEN COMMIT; ELSE ROLLBACK; END IF; + END; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 1..10 LOOP + BEGIN + INSERT INTO test1 VALUES (i, 'good'); + INSERT INTO test1 VALUES (i/0, 'bad'); + EXCEPTION + WHEN division_by_zero THEN + INSERT INTO test1 VALUES (i, 'exception'); + IF (i % 3) > 0 THEN COMMIT; ELSE ROLLBACK; END IF; + END; + END LOOP; +END; +$$ +== 078 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 079 +-- detoast result of simple expression after commit +CREATE TEMP TABLE test4(f1 text) +-- +CREATE TEMPORARY TABLE test4 (f1 text) +== 080 +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE EXTERNAL +-- +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE external +== 081 +-- disable compression +INSERT INTO test4 SELECT repeat('xyzzy', 2000) +-- +INSERT INTO test4 SELECT repeat('xyzzy', 2000) +== 082 +-- immutable mark is a bit of a lie, but it serves to make call a simple expr +-- that will return a still-toasted value +CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql +AS 'select f1 from test4' IMMUTABLE +-- +CREATE FUNCTION data_source(i int) RETURNS text LANGUAGE sql AS $$select f1 from test4$$ IMMUTABLE +== 083 +DO $$ +declare x text; +begin + for i in 1..3 loop + x := data_source(i); + commit; + end loop; + raise notice 'length(x) = %', length(x); +end $$ +-- +DO $$ +declare x text; +begin + for i in 1..3 loop + x := data_source(i); + commit; + end loop; + raise notice 'length(x) = %', length(x); +end $$ +== 084 +-- operations on composite types vs. internal transactions +DO LANGUAGE plpgsql $$ +declare + c test1 := row(42, 'hello'); + r bool; +begin + for i in 1..3 loop + r := c is not null; + raise notice 'r = %', r; + commit; + end loop; + for i in 1..3 loop + r := c is null; + raise notice 'r = %', r; + rollback; + end loop; +end +$$ +-- +DO LANGUAGE plpgsql $$ +declare + c test1 := row(42, 'hello'); + r bool; +begin + for i in 1..3 loop + r := c is not null; + raise notice 'r = %', r; + commit; + end loop; + for i in 1..3 loop + r := c is null; + raise notice 'r = %', r; + rollback; + end loop; +end +$$ +== 085 +-- COMMIT failures +DO LANGUAGE plpgsql $$ +BEGIN + CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + INSERT INTO test3 (y) VALUES (2); + COMMIT; + INSERT INTO test3 (y) VALUES (3); -- won't get here +END; +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + INSERT INTO test3 (y) VALUES (2); + COMMIT; + INSERT INTO test3 (y) VALUES (3); -- won't get here +END; +$$ +== 086 +SELECT * FROM test3 +-- +SELECT * FROM test3 +== 087 +-- failure while trying to persist a cursor across a transaction (bug #15703) +CREATE PROCEDURE cursor_fail_during_commit() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + COMMIT; + END LOOP; + END; +$$ +-- +CREATE PROCEDURE cursor_fail_during_commit() LANGUAGE plpgsql AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + COMMIT; + END LOOP; + END; +$$ +== 088 +TRUNCATE test1 +-- +TRUNCATE test1 +== 089 +CALL cursor_fail_during_commit() +-- +CALL cursor_fail_during_commit() +== 090 +-- note that error occurs during first COMMIT, hence nothing is in test1 +SELECT count(*) FROM test1 +-- +SELECT count(*) FROM test1 +== 091 +CREATE PROCEDURE cursor_fail_during_rollback() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + ROLLBACK; + END LOOP; + END; +$$ +-- +CREATE PROCEDURE cursor_fail_during_rollback() LANGUAGE plpgsql AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + ROLLBACK; + END LOOP; + END; +$$ +== 092 +TRUNCATE test1 +-- +TRUNCATE test1 +== 093 +CALL cursor_fail_during_rollback() +-- +CALL cursor_fail_during_rollback() +== 094 +SELECT count(*) FROM test1 +-- +SELECT count(*) FROM test1 +== 095 +-- SET TRANSACTION +DO LANGUAGE plpgsql $$ +BEGIN + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; +END; +$$ +== 096 +-- error cases +DO LANGUAGE plpgsql $$ +BEGIN + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +END; +$$ +== 097 +DO LANGUAGE plpgsql $$ +BEGIN + SAVEPOINT foo; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + SAVEPOINT foo; +END; +$$ +== 098 +DO LANGUAGE plpgsql $$ +BEGIN + EXECUTE 'COMMIT'; +END; +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + EXECUTE 'COMMIT'; +END; +$$ +== 099 +-- snapshot handling test +TRUNCATE test2 +-- +TRUNCATE test2 +== 100 +CREATE PROCEDURE transaction_test9() +LANGUAGE SQL +AS $$ +INSERT INTO test2 VALUES (42); +$$ +-- +CREATE PROCEDURE transaction_test9() LANGUAGE sql AS $$ +INSERT INTO test2 VALUES (42); +$$ +== 101 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + CALL transaction_test9(); +END +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + CALL transaction_test9(); +END +$$ +== 102 +SELECT * FROM test2 +-- +SELECT * FROM test2 +== 103 +-- another snapshot handling case: argument expressions of a CALL need +-- to be evaluated with an up-to-date snapshot +CREATE FUNCTION report_count() RETURNS int +STABLE LANGUAGE sql +AS $$ SELECT COUNT(*) FROM test2 $$ +-- +CREATE FUNCTION report_count() RETURNS int STABLE LANGUAGE sql AS $$ SELECT COUNT(*) FROM test2 $$ +== 104 +CREATE PROCEDURE transaction_test9b(cnt int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'count = %', cnt; +END +$$ +-- +CREATE PROCEDURE transaction_test9b(cnt int) LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'count = %', cnt; +END +$$ +== 105 +DO $$ +BEGIN + CALL transaction_test9b(report_count()); + INSERT INTO test2 VALUES(43); + CALL transaction_test9b(report_count()); +END +$$ +-- +DO $$ +BEGIN + CALL transaction_test9b(report_count()); + INSERT INTO test2 VALUES(43); + CALL transaction_test9b(report_count()); +END +$$ +== 106 +-- Test transaction in procedure with output parameters. This uses a +-- different portal strategy and different code paths in pquery.c. +CREATE PROCEDURE transaction_test10a(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x + 1; + COMMIT; +END; +$$ +-- +CREATE PROCEDURE transaction_test10a(INOUT x int) LANGUAGE plpgsql AS $$ +BEGIN + x := x + 1; + COMMIT; +END; +$$ +== 107 +CALL transaction_test10a(10) +-- +CALL transaction_test10a(10) +== 108 +CREATE PROCEDURE transaction_test10b(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x - 1; + ROLLBACK; +END; +$$ +-- +CREATE PROCEDURE transaction_test10b(INOUT x int) LANGUAGE plpgsql AS $$ +BEGIN + x := x - 1; + ROLLBACK; +END; +$$ +== 109 +CALL transaction_test10b(10) +-- +CALL transaction_test10b(10) +== 110 +-- transaction timestamp vs. statement timestamp +CREATE PROCEDURE transaction_test11() +LANGUAGE plpgsql +AS $$ +DECLARE + s1 timestamp with time zone; + s2 timestamp with time zone; + s3 timestamp with time zone; + t1 timestamp with time zone; + t2 timestamp with time zone; + t3 timestamp with time zone; +BEGIN + s1 := statement_timestamp(); + t1 := transaction_timestamp(); + ASSERT s1 = t1; + PERFORM pg_sleep(0.001); + COMMIT; + s2 := statement_timestamp(); + t2 := transaction_timestamp(); + ASSERT s2 = s1; + ASSERT t2 > t1; + PERFORM pg_sleep(0.001); + ROLLBACK; + s3 := statement_timestamp(); + t3 := transaction_timestamp(); + ASSERT s3 = s1; + ASSERT t3 > t2; +END; +$$ +-- +CREATE PROCEDURE transaction_test11() LANGUAGE plpgsql AS $$ +DECLARE + s1 timestamp with time zone; + s2 timestamp with time zone; + s3 timestamp with time zone; + t1 timestamp with time zone; + t2 timestamp with time zone; + t3 timestamp with time zone; +BEGIN + s1 := statement_timestamp(); + t1 := transaction_timestamp(); + ASSERT s1 = t1; + PERFORM pg_sleep(0.001); + COMMIT; + s2 := statement_timestamp(); + t2 := transaction_timestamp(); + ASSERT s2 = s1; + ASSERT t2 > t1; + PERFORM pg_sleep(0.001); + ROLLBACK; + s3 := statement_timestamp(); + t3 := transaction_timestamp(); + ASSERT s3 = s1; + ASSERT t3 > t2; +END; +$$ +== 111 +CALL transaction_test11() +-- +CALL transaction_test11() +== 112 +-- transaction chain + +TRUNCATE test1 +-- +TRUNCATE test1 +== 113 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + FOR i IN 0..3 LOOP + RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT AND CHAIN; + ELSE + ROLLBACK AND CHAIN; + END IF; + END LOOP; +END +$$ +-- +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + FOR i IN 0..3 LOOP + RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT AND CHAIN; + ELSE + ROLLBACK AND CHAIN; + END IF; + END LOOP; +END +$$ +== 114 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 115 +DROP TABLE test1 +-- +DROP TABLE test1 +== 116 +DROP TABLE test2 +-- +DROP TABLE test2 +== 117 +DROP TABLE test3 +-- +DROP TABLE test3 diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_trap.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_trap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_trap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_trap.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_trap.test new file mode 100644 index 0000000..169a0c4 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_trap.test @@ -0,0 +1,395 @@ +== 001 +|-- +-- Test error trapping +|-- + +create function trap_zero_divide(int) returns int as $$ +declare x int; + sx smallint; +begin + begin -- start a subtransaction + raise notice 'should see this'; + x := 100 / $1; + raise notice 'should see this only if % <> 0', $1; + sx := $1; + raise notice 'should see this only if % fits in smallint', $1; + if $1 < 0 then + raise exception '% is less than zero', $1; + end if; + exception + when division_by_zero then + raise notice 'caught division_by_zero'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE then + raise notice 'caught numeric_value_out_of_range'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +CREATE FUNCTION trap_zero_divide(int) RETURNS int AS $$ +declare x int; + sx smallint; +begin + begin -- start a subtransaction + raise notice 'should see this'; + x := 100 / $1; + raise notice 'should see this only if % <> 0', $1; + sx := $1; + raise notice 'should see this only if % fits in smallint', $1; + if $1 < 0 then + raise exception '% is less than zero', $1; + end if; + exception + when division_by_zero then + raise notice 'caught division_by_zero'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE then + raise notice 'caught numeric_value_out_of_range'; + x := -2; + end; + return x; +end$$ LANGUAGE plpgsql +== 002 +select trap_zero_divide(50) +-- +SELECT trap_zero_divide(50) +== 003 +select trap_zero_divide(0) +-- +SELECT trap_zero_divide(0) +== 004 +select trap_zero_divide(100000) +-- +SELECT trap_zero_divide(100000) +== 005 +select trap_zero_divide(-100) +-- +SELECT trap_zero_divide(-100) +== 006 +create table match_source as + select x as id, x*10 as data, x/10 as ten from generate_series(1,100) x +-- +CREATE TABLE match_source AS SELECT x AS id, x * 10 AS data, x / 10 AS ten FROM generate_series(1, 100) x +== 007 +create function trap_matching_test(int) returns int as $$ +declare x int; + sx smallint; + y int; +begin + begin -- start a subtransaction + x := 100 / $1; + sx := $1; + select into y data from match_source where id = + (select id from match_source b where ten = $1); + exception + when data_exception then -- category match + raise notice 'caught data_exception'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then + raise notice 'caught numeric_value_out_of_range or cardinality_violation'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +CREATE FUNCTION trap_matching_test(int) RETURNS int AS $$ +declare x int; + sx smallint; + y int; +begin + begin -- start a subtransaction + x := 100 / $1; + sx := $1; + select into y data from match_source where id = + (select id from match_source b where ten = $1); + exception + when data_exception then -- category match + raise notice 'caught data_exception'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then + raise notice 'caught numeric_value_out_of_range or cardinality_violation'; + x := -2; + end; + return x; +end$$ LANGUAGE plpgsql +== 008 +select trap_matching_test(50) +-- +SELECT trap_matching_test(50) +== 009 +select trap_matching_test(0) +-- +SELECT trap_matching_test(0) +== 010 +select trap_matching_test(100000) +-- +SELECT trap_matching_test(100000) +== 011 +select trap_matching_test(1) +-- +SELECT trap_matching_test(1) +== 012 +create temp table foo (f1 int) +-- +CREATE TEMPORARY TABLE foo (f1 int) +== 013 +create function subxact_rollback_semantics() returns int as $$ +declare x int; +begin + x := 1; + insert into foo values(x); + begin + x := x + 1; + insert into foo values(x); + raise exception 'inner'; + exception + when others then + x := x * 10; + end; + insert into foo values(x); + return x; +end$$ language plpgsql +-- +CREATE FUNCTION subxact_rollback_semantics() RETURNS int AS $$ +declare x int; +begin + x := 1; + insert into foo values(x); + begin + x := x + 1; + insert into foo values(x); + raise exception 'inner'; + exception + when others then + x := x * 10; + end; + insert into foo values(x); + return x; +end$$ LANGUAGE plpgsql +== 014 +select subxact_rollback_semantics() +-- +SELECT subxact_rollback_semantics() +== 015 +select * from foo +-- +SELECT * FROM foo +== 016 +drop table foo +-- +DROP TABLE foo +== 017 +create function trap_timeout() returns void as $$ +begin + declare x int; + begin + -- we assume this will take longer than 1 second: + select count(*) into x from generate_series(1, 1_000_000_000_000); + exception + when others then + raise notice 'caught others?'; + when query_canceled then + raise notice 'nyeah nyeah, can''t stop me'; + end; + -- Abort transaction to abandon the statement_timeout setting. Otherwise, + -- the next top-level statement would be vulnerable to the timeout. + raise exception 'end of function'; +end$$ language plpgsql +-- +CREATE FUNCTION trap_timeout() RETURNS void AS $$ +begin + declare x int; + begin + -- we assume this will take longer than 1 second: + select count(*) into x from generate_series(1, 1_000_000_000_000); + exception + when others then + raise notice 'caught others?'; + when query_canceled then + raise notice 'nyeah nyeah, can''t stop me'; + end; + -- Abort transaction to abandon the statement_timeout setting. Otherwise, + -- the next top-level statement would be vulnerable to the timeout. + raise exception 'end of function'; +end$$ LANGUAGE plpgsql +== 018 +begin +-- +BEGIN +== 019 +set statement_timeout to 1000 +-- +SET statement_timeout TO 1000 +== 020 +select trap_timeout() +-- +SELECT trap_timeout() +== 021 +rollback +-- +ROLLBACK +== 022 +-- Test for pass-by-ref values being stored in proper context +create function test_variable_storage() returns text as $$ +declare x text; +begin + x := '1234'; + begin + x := x || '5678'; + -- force error inside subtransaction SPI context + perform trap_zero_divide(-100); + exception + when others then + x := x || '9012'; + end; + return x; +end$$ language plpgsql +-- +CREATE FUNCTION test_variable_storage() RETURNS text AS $$ +declare x text; +begin + x := '1234'; + begin + x := x || '5678'; + -- force error inside subtransaction SPI context + perform trap_zero_divide(-100); + exception + when others then + x := x || '9012'; + end; + return x; +end$$ LANGUAGE plpgsql +== 023 +select test_variable_storage() +-- +SELECT test_variable_storage() +== 024 +|-- +-- test foreign key error trapping +|-- + +create temp table root(f1 int primary key) +-- +CREATE TEMPORARY TABLE root (f1 int PRIMARY KEY) +== 025 +create temp table leaf(f1 int references root deferrable) +-- +CREATE TEMPORARY TABLE leaf (f1 int REFERENCES root DEFERRABLE) +== 026 +insert into root values(1) +-- +INSERT INTO root VALUES (1) +== 027 +insert into leaf values(1) +-- +INSERT INTO leaf VALUES (1) +== 028 +insert into leaf values(2) +-- +INSERT INTO leaf VALUES (2) +== 029 +-- fails + +create function trap_foreign_key(int) returns int as $$ +begin + begin -- start a subtransaction + insert into leaf values($1); + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +CREATE FUNCTION trap_foreign_key(int) RETURNS int AS $$ +begin + begin -- start a subtransaction + insert into leaf values($1); + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ LANGUAGE plpgsql +== 030 +create function trap_foreign_key_2() returns int as $$ +begin + begin -- start a subtransaction + set constraints all immediate; + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +CREATE FUNCTION trap_foreign_key_2() RETURNS int AS $$ +begin + begin -- start a subtransaction + set constraints all immediate; + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ LANGUAGE plpgsql +== 031 +select trap_foreign_key(1) +-- +SELECT trap_foreign_key(1) +== 032 +select trap_foreign_key(2) +-- +SELECT trap_foreign_key(2) +== 033 +-- detects FK violation + +begin +-- +BEGIN +== 034 +set constraints all deferred +-- +SET CONSTRAINTS ALL DEFERRED +== 035 +select trap_foreign_key(2) +-- +SELECT trap_foreign_key(2) +== 036 +-- should not detect FK violation + savepoint x +-- +SAVEPOINT x +== 037 +set constraints all immediate +-- +SET CONSTRAINTS ALL IMMEDIATE +== 038 +-- fails + rollback to x +-- +ROLLBACK TO SAVEPOINT x +== 039 +select trap_foreign_key_2() +-- +SELECT trap_foreign_key_2() +== 040 +-- detects FK violation +commit +-- +COMMIT +== 041 +-- still fails + +drop function trap_foreign_key(int) +-- +DROP FUNCTION trap_foreign_key(int) +== 042 +drop function trap_foreign_key_2() +-- +DROP FUNCTION trap_foreign_key_2() diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_trigger.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_trigger.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_trigger.test new file mode 100644 index 0000000..5ecb682 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_trigger.test @@ -0,0 +1,46 @@ +== 001 +-- Simple test to verify accessibility of the OLD and NEW trigger variables + +create table testtr (a int, b text) +-- +CREATE TABLE testtr (a int, b text) +== 002 +create function testtr_trigger() returns trigger language plpgsql as +$$begin + raise notice 'tg_op = %', tg_op; + raise notice 'old(%) = %', old.a, row(old.*); + raise notice 'new(%) = %', new.a, row(new.*); + if (tg_op = 'DELETE') then + return old; + else + return new; + end if; +end$$ +-- +CREATE FUNCTION testtr_trigger() RETURNS trigger LANGUAGE plpgsql AS $$begin + raise notice 'tg_op = %', tg_op; + raise notice 'old(%) = %', old.a, row(old.*); + raise notice 'new(%) = %', new.a, row(new.*); + if (tg_op = 'DELETE') then + return old; + else + return new; + end if; +end$$ +== 003 +create trigger testtr_trigger before insert or delete or update on testtr + for each row execute function testtr_trigger() +-- +CREATE TRIGGER testtr_trigger BEFORE INSERT OR DELETE OR UPDATE ON testtr FOR EACH ROW EXECUTE FUNCTION testtr_trigger() +== 004 +insert into testtr values (1, 'one'), (2, 'two') +-- +INSERT INTO testtr VALUES (1, 'one'), (2, 'two') +== 005 +update testtr set a = a + 1 +-- +UPDATE testtr SET a = a + 1 +== 006 +delete from testtr +-- +DELETE FROM testtr diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_varprops.metadata.json b/parser/testdata/deparse/plpgsql_regress/plpgsql_varprops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_varprops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/deparse/plpgsql_regress/plpgsql_varprops.test b/parser/testdata/deparse/plpgsql_regress/plpgsql_varprops.test new file mode 100644 index 0000000..b8a3c76 --- /dev/null +++ b/parser/testdata/deparse/plpgsql_regress/plpgsql_varprops.test @@ -0,0 +1,488 @@ +== 001 +|-- +-- Tests for PL/pgSQL variable properties: CONSTANT, NOT NULL, initializers +|-- + +create type var_record as (f1 int4, f2 int4) +-- +CREATE TYPE var_record AS (f1 int4, f2 int4) +== 002 +create domain int_nn as int not null +-- +CREATE DOMAIN int_nn AS int NOT NULL +== 003 +create domain var_record_nn as var_record not null +-- +CREATE DOMAIN var_record_nn AS var_record NOT NULL +== 004 +create domain var_record_colnn as var_record check((value).f2 is not null) +-- +CREATE DOMAIN var_record_colnn AS var_record CHECK ((value).f2 IS NOT NULL) +== 005 +-- CONSTANT + +do $$ +declare x constant int := 42; +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x constant int := 42; +begin + raise notice 'x = %', x; +end$$ +== 006 +do $$ +declare x constant int; +begin + x := 42; -- fail +end$$ +-- +DO $$ +declare x constant int; +begin + x := 42; -- fail +end$$ +== 007 +do $$ +declare x constant int; y int; +begin + for x, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +DO $$ +declare x constant int; y int; +begin + for x, y in select 1, 2 loop -- fail + end loop; +end$$ +== 008 +do $$ +declare x constant int[]; +begin + x[1] := 42; -- fail +end$$ +-- +DO $$ +declare x constant int[]; +begin + x[1] := 42; -- fail +end$$ +== 009 +do $$ +declare x constant int[]; y int; +begin + for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax) + end loop; +end$$ +-- +DO $$ +declare x constant int[]; y int; +begin + for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax) + end loop; +end$$ +== 010 +do $$ +declare x constant var_record; +begin + x.f1 := 42; -- fail +end$$ +-- +DO $$ +declare x constant var_record; +begin + x.f1 := 42; -- fail +end$$ +== 011 +do $$ +declare x constant var_record; y int; +begin + for x.f1, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +DO $$ +declare x constant var_record; y int; +begin + for x.f1, y in select 1, 2 loop -- fail + end loop; +end$$ +== 012 +-- initializer expressions + +do $$ +declare x int := sin(0); +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x int := sin(0); +begin + raise notice 'x = %', x; +end$$ +== 013 +do $$ +declare x int := 1/0; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x int := 1/0; -- fail +begin + raise notice 'x = %', x; +end$$ +== 014 +do $$ +declare x bigint[] := array[1,3,5]; +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x bigint[] := array[1,3,5]; +begin + raise notice 'x = %', x; +end$$ +== 015 +do $$ +declare x record := row(1,2,3); +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x record := row(1,2,3); +begin + raise notice 'x = %', x; +end$$ +== 016 +do $$ +declare x var_record := row(1,2); +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x var_record := row(1,2); +begin + raise notice 'x = %', x; +end$$ +== 017 +-- NOT NULL + +do $$ +declare x int not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x int not null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 018 +do $$ +declare x int not null := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +DO $$ +declare x int not null := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +== 019 +do $$ +declare x int not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x int not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 020 +do $$ +declare x record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 021 +do $$ +declare x record not null := row(42); +begin + raise notice 'x = %', x; + x := row(null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +DO $$ +declare x record not null := row(42); +begin + raise notice 'x = %', x; + x := row(null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +== 022 +do $$ +declare x record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 023 +do $$ +declare x var_record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x var_record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 024 +do $$ +declare x var_record not null := row(41,42); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +DO $$ +declare x var_record not null := row(41,42); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +== 025 +do $$ +declare x var_record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x var_record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 026 +-- Check that variables are reinitialized on block re-entry. + +do $$ +begin + for i in 1..3 loop + declare + x int; + y int := i; + r record; + c var_record; + begin + if i = 1 then + x := 42; + r := row(i, i+1); + c := row(i, i+1); + end if; + raise notice 'x = %', x; + raise notice 'y = %', y; + raise notice 'r = %', r; + raise notice 'c = %', c; + end; + end loop; +end$$ +-- +DO $$ +begin + for i in 1..3 loop + declare + x int; + y int := i; + r record; + c var_record; + begin + if i = 1 then + x := 42; + r := row(i, i+1); + c := row(i, i+1); + end if; + raise notice 'x = %', x; + raise notice 'y = %', y; + raise notice 'r = %', r; + raise notice 'c = %', c; + end; + end loop; +end$$ +== 027 +-- Check enforcement of domain constraints during initialization + +do $$ +declare x int_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x int_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +== 028 +do $$ +declare x int_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x int_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 029 +do $$ +declare x int_nn := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +DO $$ +declare x int_nn := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +== 030 +do $$ +declare x var_record_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x var_record_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +== 031 +do $$ +declare x var_record_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x var_record_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 032 +do $$ +declare x var_record_nn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + x := null; -- fail +end$$ +-- +DO $$ +declare x var_record_nn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + x := null; -- fail +end$$ +== 033 +do $$ +declare x var_record_colnn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x var_record_colnn; -- fail +begin + raise notice 'x = %', x; +end$$ +== 034 +do $$ +declare x var_record_colnn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x var_record_colnn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +== 035 +do $$ +declare x var_record_colnn := row(1,null); -- fail +begin + raise notice 'x = %', x; +end$$ +-- +DO $$ +declare x var_record_colnn := row(1,null); -- fail +begin + raise notice 'x = %', x; +end$$ +== 036 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +DO $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +== 037 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- fail +end$$ +-- +DO $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- fail +end$$ diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_array.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_array.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_array.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_array.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_array.test new file mode 100644 index 0000000..d64dd6f --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_array.test @@ -0,0 +1,218 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of array variables +|-- +-- We also check arrays of composites here, so this has some overlap +-- with the plpgsql_record tests. +|-- + +create type complex as (r float8, i float8) +-- +9b73912a478ebdaf +== 002 +create type quadarray as (c1 complex[], c2 complex) +-- +9767160e950143ef +== 003 +do $$ declare a int[]; +begin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 004 +do $$ declare a int[]; +begin a[3] := 4; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 005 +do $$ declare a int[]; +begin a[1][4] := 4; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 006 +do $$ declare a int[]; +begin a[1] := 23::text; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 007 +-- lax typing + +do $$ declare a int[]; +begin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 008 +do $$ declare a int[]; +begin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 009 +do $$ declare a int[]; +begin a[1:2] := array[3,4]; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 010 +do $$ declare a int[]; +begin a[1:2] := 4; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 011 +-- error + +do $$ declare a complex[]; +begin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 012 +do $$ declare a complex[]; +begin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end$$ +-- +f936eab75b8c1b90 +== 013 +-- perhaps this ought to work, but for now it doesn't: +do $$ declare a complex[]; +begin a[1:2].i := array[11,12]; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 014 +do $$ declare a quadarray; +begin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end$$ +-- +f936eab75b8c1b90 +== 015 +do $$ declare a int[]; +begin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 016 +create temp table onecol as select array[1,2] as f1 +-- +1a341c41250d954c +== 017 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 018 +do $$ declare a int[]; +begin a := * from onecol for update; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 019 +-- error cases: + +do $$ declare a int[]; +begin a := from onecol; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 020 +do $$ declare a int[]; +begin a := f1, f1 from onecol; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 021 +insert into onecol values(array[11]) +-- +9eb30ae770fe7be0 +== 022 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 023 +do $$ declare a int[]; +begin a := f1 from onecol limit 1; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 024 +do $$ declare a real; +begin a[1] := 2; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 025 +do $$ declare a complex; +begin a.r[1] := 2; raise notice 'a = %', a; end$$ +-- +f936eab75b8c1b90 +== 026 +|-- +-- test of %type[] and %rowtype[] syntax +|-- + +-- check supported syntax +do $$ +declare + v int; + v1 v%type; + v2 v%type[]; + v3 v%type[1]; + v4 v%type[][]; + v5 v%type[1][3]; + v6 v%type array; + v7 v%type array[]; + v8 v%type array[1]; + v9 v%type array[1][1]; + v10 pg_catalog.pg_class%rowtype[]; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(v3); + raise notice '%', pg_typeof(v4); + raise notice '%', pg_typeof(v5); + raise notice '%', pg_typeof(v6); + raise notice '%', pg_typeof(v7); + raise notice '%', pg_typeof(v8); + raise notice '%', pg_typeof(v9); + raise notice '%', pg_typeof(v10); +end; +$$ +-- +f936eab75b8c1b90 +== 027 +-- some types don't support arrays +do $$ +declare + v pg_node_tree; + v1 v%type[]; +begin +end; +$$ +-- +f936eab75b8c1b90 +== 028 +-- check functionality +do $$ +declare + v1 int; + v2 varchar; + a1 v1%type[]; + a2 v2%type[]; +begin + v1 := 10; + v2 := 'Hi'; + a1 := array[v1,v1]; + a2 := array[v2,v2]; + raise notice '% %', a1, a2; +end; +$$ +-- +f936eab75b8c1b90 +== 029 +create table array_test_table(a int, b varchar) +-- +5175081ae65e3bc6 +== 030 +insert into array_test_table values(1, 'first'), (2, 'second') +-- +6b5a91a8a312e633 +== 031 +do $$ +declare tg array_test_table%rowtype[]; +begin + tg := array(select array_test_table from array_test_table); + raise notice '%', tg; + tg := array(select row(a,b) from array_test_table); + raise notice '%', tg; +end; +$$ +-- +f936eab75b8c1b90 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_cache.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_cache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_cache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_cache.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_cache.test new file mode 100644 index 0000000..04a2aed --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_cache.test @@ -0,0 +1,82 @@ +== 001 +|-- +-- Cache-behavior-dependent test cases +|-- +-- These tests logically belong in plpgsql_record.sql, and perhaps someday +-- can be merged back into it. For now, however, their results are different +-- depending on debug_discard_caches, so we must have two expected-output +-- files to cover both cases. To minimize the maintenance effort resulting +-- from that, this file should contain only tests that do have different +-- results under debug_discard_caches. +|-- + +-- check behavior with changes of a named rowtype +create table c_mutable(f1 int, f2 text) +-- +ba5c14746e7b2b98 +== 002 +create function c_sillyaddone(int) returns int language plpgsql as +$$ declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +f8f8fbcaba44ec6c +== 003 +select c_sillyaddone(42) +-- +55e0b998386fc67e +== 004 +alter table c_mutable drop column f1 +-- +c75396a33282b8f4 +== 005 +alter table c_mutable add column f1 float8 +-- +467a28ec0cd9f5ac +== 006 +-- currently, this fails due to cached plan for "r.f1 + 1" expression +-- (but if debug_discard_caches is on, it will succeed) +select c_sillyaddone(42) +-- +55e0b998386fc67e +== 007 +-- but it's OK if we force plan rebuilding +discard plans +-- +6e200ea45baf3637 +== 008 +select c_sillyaddone(42) +-- +55e0b998386fc67e +== 009 +-- check behavior with changes in a record rowtype +create function show_result_type(text) returns text language plpgsql as +$$ + declare + r record; + t text; + begin + execute $1 into r; + select pg_typeof(r.a) into t; + return format('type %s value %s', t, r.a::text); + end; +$$ +-- +dc44c7b2134dd920 +== 010 +select show_result_type('select 1 as a') +-- +12fbce0557f5f36b +== 011 +-- currently this fails due to cached plan for pg_typeof expression +-- (but if debug_discard_caches is on, it will succeed) +select show_result_type('select 2.0 as a') +-- +12fbce0557f5f36b +== 012 +-- but it's OK if we force plan rebuilding +discard plans +-- +6e200ea45baf3637 +== 013 +select show_result_type('select 2.0 as a') +-- +12fbce0557f5f36b diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_call.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_call.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_call.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_call.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_call.test new file mode 100644 index 0000000..0724f82 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_call.test @@ -0,0 +1,748 @@ +== 001 +|-- +-- Tests for procedures / CALL syntax +|-- + +CREATE PROCEDURE test_proc1() +LANGUAGE plpgsql +AS $$ +BEGIN + NULL; +END; +$$ +-- +e9dd3336c4aa28f3 +== 002 +CALL test_proc1() +-- +3d6abb3a56fcc481 +== 003 +-- error: can't return non-NULL +CREATE PROCEDURE test_proc2() +LANGUAGE plpgsql +AS $$ +BEGIN + RETURN 5; +END; +$$ +-- +b5f7d687dcf57801 +== 004 +CREATE TABLE test1 (a int) +-- +5d991a76abfb450a +== 005 +CREATE PROCEDURE test_proc3(x int) +LANGUAGE plpgsql +AS $$ +BEGIN + INSERT INTO test1 VALUES (x); +END; +$$ +-- +866232853128ca34 +== 006 +CALL test_proc3(55) +-- +431da5ad31538a6b +== 007 +SELECT * FROM test1 +-- +57550c6644afee58 +== 008 +-- Check that plan revalidation doesn't prevent setting transaction properties +-- (bug #18059). This test must include the first temp-object creation in +-- this script, or it won't exercise the bug scenario. Hence we put it early. +CREATE PROCEDURE test_proc3a() +LANGUAGE plpgsql +AS $$ +BEGIN + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + RAISE NOTICE 'done'; +END; +$$ +-- +17b6bc3126a1f1e7 +== 009 +CALL test_proc3a() +-- +322b42515635f84a +== 010 +CREATE TEMP TABLE tt1(f1 int) +-- +cecd718310a73ba0 +== 011 +CALL test_proc3a() +-- +322b42515635f84a +== 012 +-- nested CALL +TRUNCATE TABLE test1 +-- +5270aa06ddf1345c +== 013 +CREATE PROCEDURE test_proc4(y int) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL test_proc3(y); + CALL test_proc3($1); +END; +$$ +-- +5bfb8aab078a294d +== 014 +CALL test_proc4(66) +-- +fc948affa2254718 +== 015 +SELECT * FROM test1 +-- +57550c6644afee58 +== 016 +CALL test_proc4(66) +-- +fc948affa2254718 +== 017 +SELECT * FROM test1 +-- +57550c6644afee58 +== 018 +-- output arguments + +CREATE PROCEDURE test_proc5(INOUT a text) +LANGUAGE plpgsql +AS $$ +BEGIN + a := a || '+' || a; +END; +$$ +-- +af71540045d2690e +== 019 +CALL test_proc5('abc') +-- +83d041a11f606bd8 +== 020 +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + b := b * a; + c := c * a; +END; +$$ +-- +a8d1fe8db1fa00dc +== 021 +CALL test_proc6(2, 3, 4) +-- +b04b4952f4321a1e +== 022 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); + RAISE INFO 'x = %, y = %', x, y; + CALL test_proc6(2, c => y, b => x); + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +f936eab75b8c1b90 +== 023 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x + 1, y); -- error + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +f936eab75b8c1b90 +== 024 +DO +LANGUAGE plpgsql +$$ +DECLARE + x constant int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); -- error because x is constant +END; +$$ +-- +f936eab75b8c1b90 +== 025 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + FOR i IN 1..5 LOOP + CALL test_proc6(i, x, y); + RAISE INFO 'x = %, y = %', x, y; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 026 +-- recursive with output arguments + +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN +IF x > 1 THEN + a := x / 10; + b := x / 2; + CALL test_proc7(b::int, a, b); +END IF; +END; +$$ +-- +03ca97f927b47af3 +== 027 +CALL test_proc7(100, -1, -1) +-- +48bd0eabd8627223 +== 028 +-- inner COMMIT with output arguments + +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN + a := x / 10; + b := x / 2; + COMMIT; +END; +$$ +-- +b585a526e7a169c8 +== 029 +CREATE PROCEDURE test_proc7cc(_x int) +LANGUAGE plpgsql +AS $$ +DECLARE _a int; _b numeric; +BEGIN + CALL test_proc7c(_x, _a, _b); + RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b; +END +$$ +-- +95d88b16513ff4b1 +== 030 +CALL test_proc7cc(10) +-- +3424ffefe2bbc51f +== 031 +-- named parameters and defaults + +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := a * 10; + b := b + 10; +END; +$$ +-- +2075976b27f4e886 +== 032 +CALL test_proc8a(10, 20) +-- +b84a8c2dbe3dc4f0 +== 033 +CALL test_proc8a(b => 20, a => 10) +-- +d0cd181cb59220f6 +== 034 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc8a(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; + CALL test_proc8a(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +f936eab75b8c1b90 +== 035 +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +687d3c801927d20e +== 036 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8b(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + CALL test_proc8b(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +f936eab75b8c1b90 +== 037 +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +d4a8196e77430542 +== 038 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(c => _c, b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +f936eab75b8c1b90 +== 039 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +f936eab75b8c1b90 +== 040 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, b => _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +f936eab75b8c1b90 +== 041 +-- OUT parameters + +CREATE PROCEDURE test_proc9(IN a int, OUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + b := a * 2; +END; +$$ +-- +3acc392753e1f2c2 +== 042 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc9(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +f936eab75b8c1b90 +== 043 +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + b := a - c; +END; +$$ +-- +0d4d81ff81a348a1 +== 044 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(a => _a, b => _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +f936eab75b8c1b90 +== 045 +-- OUT + VARIADIC + +CREATE PROCEDURE test_proc11(a OUT int, VARIADIC b int[]) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := b[1] + b[2]; +END; +$$ +-- +a70a29eeba8be880 +== 046 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc11(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +f936eab75b8c1b90 +== 047 +-- polymorphic OUT arguments + +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %', a; + b := a; + c := array[a]; +END; +$$ +-- +0a3596dde6e74d78 +== 048 +DO $$ +DECLARE _a int; _b int; _c int[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +f936eab75b8c1b90 +== 049 +DO $$ +DECLARE _a int; _b int; _c text[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); -- error + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +f936eab75b8c1b90 +== 050 +-- transition variable assignment + +TRUNCATE test1 +-- +5270aa06ddf1345c +== 051 +CREATE FUNCTION triggerfunc1() RETURNS trigger +LANGUAGE plpgsql +AS $$ +DECLARE + z int := 0; +BEGIN + CALL test_proc6(2, NEW.a, NEW.a); + RETURN NEW; +END; +$$ +-- +8fdfbce35a1ebb83 +== 052 +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE PROCEDURE triggerfunc1() +-- +6e7fdd5607284b34 +== 053 +INSERT INTO test1 VALUES (1), (2), (3) +-- +8c91d6c1e15fa014 +== 054 +UPDATE test1 SET a = 22 WHERE a = 2 +-- +188f76fda8d32674 +== 055 +SELECT * FROM test1 ORDER BY a +-- +8c2f028d19e22473 +== 056 +DROP PROCEDURE test_proc1 +-- +21e1fe5c0562ec99 +== 057 +DROP PROCEDURE test_proc3 +-- +5fee600485c371b6 +== 058 +DROP PROCEDURE test_proc4 +-- +7e41ba85b2b2a6ae +== 059 +DROP TABLE test1 +-- +9fdd9d3006af8e29 +== 060 +-- more checks for named-parameter handling + +CREATE PROCEDURE p1(v_cnt int, v_Text inout text = NULL) +AS $$ +BEGIN + v_Text := 'v_cnt = ' || v_cnt; +END +$$ LANGUAGE plpgsql +-- +bed5f4fec9529681 +== 061 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text + RAISE NOTICE '%', v_Text; +END; +$$ +-- +f936eab75b8c1b90 +== 062 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +f936eab75b8c1b90 +== 063 +DO $$ +DECLARE + v_Text text; +BEGIN + CALL p1(10, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +f936eab75b8c1b90 +== 064 +DO $$ +DECLARE + v_Text text; + v_cnt integer; +BEGIN + CALL p1(v_Text := v_Text, v_cnt := v_cnt); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +f936eab75b8c1b90 +== 065 +-- check that we detect change of dependencies in CALL +-- atomic and non-atomic call sites used to do this differently, so check both + +CREATE PROCEDURE inner_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'inner_p(%)', f1; +END +$$ LANGUAGE plpgsql +-- +76d7981eac9aaec5 +== 066 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 1 $$ LANGUAGE sql +-- +af1ccbbbfac0e515 +== 067 +CREATE PROCEDURE outer_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'outer_p(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +2448e38ee42bcea2 +== 068 +CREATE FUNCTION outer_f (f1 int) RETURNS void +AS $$ +BEGIN + RAISE NOTICE 'outer_f(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +13311a0879c5418b +== 069 +CALL outer_p(42) +-- +1230824a2dc132db +== 070 +SELECT outer_f(42) +-- +275b575dbfc1c2e7 +== 071 +DROP FUNCTION f(int) +-- +d32f4a9fe630273b +== 072 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 2 $$ LANGUAGE sql +-- +af1ccbbbfac0e515 +== 073 +CALL outer_p(42) +-- +1230824a2dc132db +== 074 +SELECT outer_f(42) +-- +275b575dbfc1c2e7 +== 075 +-- Check that stable functions in CALL see the correct snapshot + +CREATE TABLE t_test (x int) +-- +7d6c6c8cc430cfec +== 076 +INSERT INTO t_test VALUES (0) +-- +1a0c8dc5f97f5d8c +== 077 +CREATE FUNCTION f_get_x () RETURNS int +AS $$ +DECLARE l_result int; +BEGIN + SELECT x INTO l_result FROM t_test; + RETURN l_result; +END +$$ LANGUAGE plpgsql STABLE +-- +aa553f4de4ea282c +== 078 +CREATE PROCEDURE f_print_x (x int) +AS $$ +BEGIN + RAISE NOTICE 'f_print_x(%)', x; +END +$$ LANGUAGE plpgsql +-- +f599f9d54ea6a780 +== 079 +-- test in non-atomic context +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + ROLLBACK; +END +$$ +-- +f936eab75b8c1b90 +== 080 +-- test in non-atomic context, except exception block is locally atomic +DO $$ +BEGIN + BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + EXCEPTION WHEN division_by_zero THEN + RAISE NOTICE '%', SQLERRM; + END; + ROLLBACK; +END +$$ +-- +f936eab75b8c1b90 +== 081 +-- test in atomic context +BEGIN +-- +b16b431979fc3e05 +== 082 +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); +END +$$ +-- +f936eab75b8c1b90 +== 083 +ROLLBACK +-- +a46081a556fda027 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_control.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_control.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_control.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_control.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_control.test new file mode 100644 index 0000000..673c49c --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_control.test @@ -0,0 +1,627 @@ +== 001 +|-- +-- Tests for PL/pgSQL control structures +|-- + +-- integer FOR loop + +do $$ +begin + -- basic case + for i in 1..3 loop + raise notice '1..3: i = %', i; + end loop; + -- with BY, end matches exactly + for i in 1..10 by 3 loop + raise notice '1..10 by 3: i = %', i; + end loop; + -- with BY, end does not match + for i in 1..11 by 3 loop + raise notice '1..11 by 3: i = %', i; + end loop; + -- zero iterations + for i in 1..0 by 3 loop + raise notice '1..0 by 3: i = %', i; + end loop; + -- REVERSE + for i in reverse 10..0 by 3 loop + raise notice 'reverse 10..0 by 3: i = %', i; + end loop; + -- potential overflow + for i in 2147483620..2147483647 by 10 loop + raise notice '2147483620..2147483647 by 10: i = %', i; + end loop; + -- potential overflow, reverse direction + for i in reverse -2147483620..-2147483647 by 10 loop + raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 002 +-- BY can't be zero or negative +do $$ +begin + for i in 1..3 by 0 loop + raise notice '1..3 by 0: i = %', i; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 003 +do $$ +begin + for i in 1..3 by -1 loop + raise notice '1..3 by -1: i = %', i; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 004 +do $$ +begin + for i in reverse 1..3 by -1 loop + raise notice 'reverse 1..3 by -1: i = %', i; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 005 +-- CONTINUE statement + +create table conttesttbl(idx serial, v integer) +-- +96c84b60e0663c15 +== 006 +insert into conttesttbl(v) values(10) +-- +81c5163797b3e367 +== 007 +insert into conttesttbl(v) values(20) +-- +81c5163797b3e367 +== 008 +insert into conttesttbl(v) values(30) +-- +81c5163797b3e367 +== 009 +insert into conttesttbl(v) values(40) +-- +81c5163797b3e367 +== 010 +create function continue_test1() returns void as $$ +declare _i integer = 0; _r record; +begin + raise notice '---1---'; + loop + _i := _i + 1; + raise notice '%', _i; + continue when _i < 10; + exit; + end loop; + + raise notice '---2---'; + <> + loop + _i := _i - 1; + loop + raise notice '%', _i; + continue lbl when _i > 0; + exit lbl; + end loop; + end loop; + + raise notice '---3---'; + <> + while _i < 10 loop + _i := _i + 1; + continue the_loop when _i % 2 = 0; + raise notice '%', _i; + end loop; + + raise notice '---4---'; + for _i in 1..10 loop + begin + -- applies to outer loop, not the nested begin block + continue when _i < 5; + raise notice '%', _i; + end; + end loop; + + raise notice '---5---'; + for _r in select * from conttesttbl loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---6---'; + for _r in execute 'select * from conttesttbl' loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---7---'; + <> + for _i in 1..3 loop + continue looplabel when _i = 2; + raise notice '%', _i; + end loop; + + raise notice '---8---'; + _i := 1; + while _i <= 3 loop + raise notice '%', _i; + _i := _i + 1; + continue when _i = 3; + end loop; + + raise notice '---9---'; + for _r in select * from conttesttbl order by v limit 1 loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---10---'; + for _r in execute 'select * from conttesttbl order by v limit 1' loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---11---'; + <> + for _i in 1..2 loop + raise notice 'outer %', _i; + <> + for _j in 1..3 loop + continue outerlooplabel when _j = 2; + raise notice 'inner %', _j; + end loop; + end loop; +end; $$ language plpgsql +-- +23017af17050a0ff +== 011 +select continue_test1() +-- +56a2eff9030d6a03 +== 012 +-- should fail: CONTINUE is only legal inside a loop +create function continue_error1() returns void as $$ +begin + begin + continue; + end; +end; +$$ language plpgsql +-- +3544bac913ab9916 +== 013 +-- should fail: unlabeled EXIT is only legal inside a loop +create function exit_error1() returns void as $$ +begin + begin + exit; + end; +end; +$$ language plpgsql +-- +3138c9300d8a8018 +== 014 +-- should fail: no such label +create function continue_error2() returns void as $$ +begin + begin + loop + continue no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +951ce6db50cf2013 +== 015 +-- should fail: no such label +create function exit_error2() returns void as $$ +begin + begin + loop + exit no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +b86df4d6b04598f0 +== 016 +-- should fail: CONTINUE can't reference the label of a named block +create function continue_error3() returns void as $$ +begin + <> + begin + loop + continue begin_block1; + end loop; + end; +end; +$$ language plpgsql +-- +e36577ac743cce59 +== 017 +-- On the other hand, EXIT *can* reference the label of a named block +create function exit_block1() returns void as $$ +begin + <> + begin + loop + exit begin_block1; + raise exception 'should not get here'; + end loop; + end; +end; +$$ language plpgsql +-- +a86649bfc445511a +== 018 +select exit_block1() +-- +d25bcc8f3324ec9f +== 019 +-- verbose end block and end loop +create function end_label1() returns void as $$ +<> +begin + <> + for i in 1 .. 10 loop + raise notice 'i = %', i; + exit flbl1; + end loop flbl1; + <> + for j in 1 .. 10 loop + raise notice 'j = %', j; + exit flbl2; + end loop; +end blbl; +$$ language plpgsql +-- +3b484e47afc38700 +== 020 +select end_label1() +-- +426409857206cd96 +== 021 +-- should fail: undefined end label +create function end_label2() returns void as $$ +begin + for _i in 1 .. 10 loop + exit; + end loop flbl1; +end; +$$ language plpgsql +-- +e99320a55304a15c +== 022 +-- should fail: end label does not match start label +create function end_label3() returns void as $$ +<> +begin + <> + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +29aa52982dd97b28 +== 023 +-- should fail: end label on a block without a start label +create function end_label4() returns void as $$ +<> +begin + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +3ce5dcc3733a0fd1 +== 024 +-- unlabeled exit matches no blocks +do $$ +begin +for i in 1..10 loop + <> + begin + begin -- unlabeled block + exit; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; +end loop; +raise notice 'should get here'; +end$$ +-- +f936eab75b8c1b90 +== 025 +-- check exit out of an unlabeled block to a labeled one +do $$ +<> +begin + <> + begin + <> + begin + begin -- unlabeled block + exit innerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; + end; + raise notice 'should get here'; +end$$ +-- +f936eab75b8c1b90 +== 026 +-- check exit out of outermost block +do $$ +<> +begin + <> + begin + exit outerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; +end$$ +-- +f936eab75b8c1b90 +== 027 +-- unlabeled exit does match a while loop +do $$ +begin + <> + while 1 > 0 loop + <> + while 1 > 0 loop + <> + while 1 > 0 loop + exit; + raise notice 'should not get here'; + end loop; + raise notice 'should get here'; + exit outermostwhile; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'should get here, too'; +end$$ +-- +f936eab75b8c1b90 +== 028 +-- check exit out of an unlabeled while to a labeled one +do $$ +begin + <> + while 1 > 0 loop + while 1 > 0 loop + exit outerwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'should get here'; +end$$ +-- +f936eab75b8c1b90 +== 029 +-- continue to an outer while +do $$ +declare i int := 0; +begin + <> + while i < 2 loop + raise notice 'outermostwhile, i = %', i; + i := i + 1; + <> + while 1 > 0 loop + <> + while 1 > 0 loop + continue outermostwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'out of outermostwhile, i = %', i; +end$$ +-- +f936eab75b8c1b90 +== 030 +-- return out of a while +create function return_from_while() returns int language plpgsql as $$ +declare i int := 0; +begin + while i < 10 loop + if i > 2 then + return i; + end if; + i := i + 1; + end loop; + return null; +end$$ +-- +d1c13ef629707f4d +== 031 +select return_from_while() +-- +d19da47eaba6bbfe +== 032 +-- using list of scalars in fori and fore stmts +create function for_vect() returns void as $proc$ +<>declare a integer; b varchar; c varchar; r record; +begin + -- fori + for i in 1 .. 3 loop + raise notice '%', i; + end loop; + -- fore with record var + for r in select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs loop + raise notice '% % %', r.aa, r.bb, r.cc; + end loop; + -- fore with single scalar + for a in select gs from generate_series(1,4) gs loop + raise notice '%', a; + end loop; + -- fore with multiple scalars + for a,b,c in select gs, 'BB','CC' from generate_series(1,4) gs loop + raise notice '% % %', a, b, c; + end loop; + -- using qualified names in fors, fore is enabled, disabled only for fori + for lbl.a, lbl.b, lbl.c in execute $$select gs, 'bb','cc' from generate_series(1,4) gs$$ loop + raise notice '% % %', a, b, c; + end loop; +end; +$proc$ language plpgsql +-- +e08c9dabeec0efa8 +== 033 +select for_vect() +-- +b0f6142c08412ede +== 034 +-- CASE statement + +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; + b int = 1; +begin + case $1 + when 1 then + return 'one'; + when 2 then + return 'two'; + when 3,4,3+5 then + return 'three, four or eight'; + when a then + return 'ten'; + when a+b, a+b+1 then + return 'eleven, twelve'; + end case; +end; +$$ language plpgsql immutable +-- +dc36eb4267ae485a +== 035 +select case_test(1) +-- +25b1382a48c321f7 +== 036 +select case_test(2) +-- +25b1382a48c321f7 +== 037 +select case_test(3) +-- +25b1382a48c321f7 +== 038 +select case_test(4) +-- +25b1382a48c321f7 +== 039 +select case_test(5) +-- +25b1382a48c321f7 +== 040 +-- fails +select case_test(8) +-- +25b1382a48c321f7 +== 041 +select case_test(10) +-- +25b1382a48c321f7 +== 042 +select case_test(11) +-- +25b1382a48c321f7 +== 043 +select case_test(12) +-- +25b1382a48c321f7 +== 044 +select case_test(13) +-- +25b1382a48c321f7 +== 045 +-- fails + +create or replace function catch() returns void as $$ +begin + raise notice '%', case_test(6); +exception + when case_not_found then + raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM; +end +$$ language plpgsql +-- +d4cf615ef8422787 +== 046 +select catch() +-- +eb7514820113c76c +== 047 +-- test the searched variant too, as well as ELSE +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; +begin + case + when $1 = 1 then + return 'one'; + when $1 = a + 2 then + return 'twelve'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +dc36eb4267ae485a +== 048 +select case_test(1) +-- +25b1382a48c321f7 +== 049 +select case_test(2) +-- +25b1382a48c321f7 +== 050 +select case_test(12) +-- +25b1382a48c321f7 +== 051 +select case_test(13) +-- +25b1382a48c321f7 +== 052 +-- test line comment between WHEN and THEN +create or replace function case_comment(int) returns text as $$ +begin + case $1 + when 1 -- comment before THEN + then return 'one'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +5c017dd6a0b0b605 +== 053 +select case_comment(1) +-- +cb83a6cbf93bda28 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_copy.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_copy.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_copy.test new file mode 100644 index 0000000..2788c56 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_copy.test @@ -0,0 +1,21 @@ +== 001 +-- directory paths are passed to us in environment variables + +-- set up file names to use + +CREATE TABLE copy1 (a int, b float); + +-- COPY TO/FROM not authorized from client. +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 TO stdout; +END; +$$; +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 FROM stdin; +-- +ERROR: "unterminated dollar-quoted string at or near \"$$\nBEGIN\n COPY copy1 FROM stdin;\"" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_domain.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_domain.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_domain.test new file mode 100644 index 0000000..6ed168d --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_domain.test @@ -0,0 +1,483 @@ +== 001 +|-- +-- Tests for PL/pgSQL's behavior with domain types +|-- + +CREATE DOMAIN booltrue AS bool CHECK (VALUE IS TRUE OR VALUE IS NULL) +-- +69370178a944aef6 +== 002 +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +74a64ea51e65b183 +== 003 +SELECT * FROM test_argresult_booltrue(true, true) +-- +593384214f9540c2 +== 004 +SELECT * FROM test_argresult_booltrue(false, true) +-- +593384214f9540c2 +== 005 +SELECT * FROM test_argresult_booltrue(true, false) +-- +593384214f9540c2 +== 006 +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $$ +declare v booltrue := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +3d8911e942aee034 +== 007 +SELECT * FROM test_assign_booltrue(true, true) +-- +ff497d95c79fe36d +== 008 +SELECT * FROM test_assign_booltrue(false, true) +-- +ff497d95c79fe36d +== 009 +SELECT * FROM test_assign_booltrue(true, false) +-- +ff497d95c79fe36d +== 010 +CREATE DOMAIN uint2 AS int2 CHECK (VALUE >= 0) +-- +0d9162e9122b24bb +== 011 +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +d9dd266e971f0878 +== 012 +SELECT * FROM test_argresult_uint2(100::uint2, 50) +-- +16eb0e0503b4dd49 +== 013 +SELECT * FROM test_argresult_uint2(100::uint2, -50) +-- +16eb0e0503b4dd49 +== 014 +SELECT * FROM test_argresult_uint2(null, 1) +-- +16eb0e0503b4dd49 +== 015 +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $$ +declare v uint2 := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +0c5cc9372a53cf11 +== 016 +SELECT * FROM test_assign_uint2(100, 50) +-- +a9222b86a0db996e +== 017 +SELECT * FROM test_assign_uint2(100, -50) +-- +a9222b86a0db996e +== 018 +SELECT * FROM test_assign_uint2(-100, 50) +-- +a9222b86a0db996e +== 019 +SELECT * FROM test_assign_uint2(null, 1) +-- +a9222b86a0db996e +== 020 +CREATE DOMAIN nnint AS int NOT NULL +-- +520b04831cc1ff7f +== 021 +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +aef122d32b05027b +== 022 +SELECT * FROM test_argresult_nnint(10, 20) +-- +3325272165b1809a +== 023 +SELECT * FROM test_argresult_nnint(null, 20) +-- +3325272165b1809a +== 024 +SELECT * FROM test_argresult_nnint(10, null) +-- +3325272165b1809a +== 025 +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $$ +declare v nnint := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +d4dff5e37a8053dd +== 026 +SELECT * FROM test_assign_nnint(10, 20) +-- +b9ce10d353f45dec +== 027 +SELECT * FROM test_assign_nnint(null, 20) +-- +b9ce10d353f45dec +== 028 +SELECT * FROM test_assign_nnint(10, null) +-- +b9ce10d353f45dec +== 029 +|-- +-- Domains over arrays +|-- + +CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]) +-- +1f50674eeebfb0fa +== 030 +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) + RETURNS ordered_pair_domain AS $$ +begin +return x; +end +$$ LANGUAGE plpgsql +-- +513e509c7977a4dd +== 031 +SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain) +-- +03c4e1dbbbb8e703 +== 032 +SELECT * FROM test_argresult_array_domain(NULL::ordered_pair_domain) +-- +4b22b0fc3151b8fa +== 033 +CREATE FUNCTION test_argresult_array_domain_check_violation() + RETURNS ordered_pair_domain AS $$ +begin +return array[2,1]; +end +$$ LANGUAGE plpgsql +-- +c2ca4b8de182b1fb +== 034 +SELECT * FROM test_argresult_array_domain_check_violation() +-- +ec920a6d65c94883 +== 035 +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $$ +declare v ordered_pair_domain := array[x, y]; +begin +v[2] := z; +return v; +end +$$ LANGUAGE plpgsql +-- +6dd3dfeda7281efa +== 036 +SELECT * FROM test_assign_ordered_pair_domain(1,2,3) +-- +bf34e6db717719b0 +== 037 +SELECT * FROM test_assign_ordered_pair_domain(1,2,0) +-- +bf34e6db717719b0 +== 038 +SELECT * FROM test_assign_ordered_pair_domain(2,1,3) +-- +bf34e6db717719b0 +== 039 +|-- +-- Arrays of domains +|-- + +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +bf9e107bd9c2e65c +== 040 +select test_read_uint2_array(array[1::uint2]) +-- +4766659b49f4383b +== 041 +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $$ +begin +return array[x, x]; +end +$$ LANGUAGE plpgsql +-- +a69ebefc5925f8a5 +== 042 +select test_build_uint2_array(1::int2) +-- +3cad921290368c5c +== 043 +select test_build_uint2_array(-1::int2) +-- +4c8e4aff79477a13 +== 044 +-- fail + +CREATE FUNCTION test_argresult_domain_array(x integer[]) + RETURNS ordered_pair_domain[] AS $$ +begin +return array[x::ordered_pair_domain, x::ordered_pair_domain]; +end +$$ LANGUAGE plpgsql +-- +3475547a538dbdcd +== 045 +select test_argresult_domain_array(array[2,4]) +-- +388a34e1f616c7d1 +== 046 +select test_argresult_domain_array(array[4,2]) +-- +388a34e1f616c7d1 +== 047 +-- fail + +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) + RETURNS integer AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +4d2e87d61fa34eca +== 048 +select test_argresult_domain_array2(array[2,4]) +-- +0f71233a196a9545 +== 049 +select test_argresult_domain_array2(array[4,2]) +-- +0f71233a196a9545 +== 050 +-- fail + +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) + RETURNS ordered_pair_domain AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +38800d15407f49f2 +== 051 +select test_argresult_array_domain_array(array[array[2,4]::ordered_pair_domain]) +-- +28f96aaffb5f93c8 +== 052 +|-- +-- Domains within composite +|-- + +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +-- +fed8252ea7ebb7cf +== 053 +CREATE FUNCTION test_result_nnint_container(x int, y int) + RETURNS nnint_container AS $$ +begin +return row(x, y)::nnint_container; +end +$$ LANGUAGE plpgsql +-- +56a9b84d3f2866fa +== 054 +SELECT test_result_nnint_container(null, 3) +-- +39c9f00133e056f8 +== 055 +SELECT test_result_nnint_container(3, null) +-- +39c9f00133e056f8 +== 056 +-- fail + +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container := row(x, y); +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +14fbd54ec4c1d083 +== 057 +SELECT * FROM test_assign_nnint_container(1,2,3) +-- +51282e382b0662d6 +== 058 +SELECT * FROM test_assign_nnint_container(1,2,null) +-- +51282e382b0662d6 +== 059 +SELECT * FROM test_assign_nnint_container(1,null,3) +-- +51282e382b0662d6 +== 060 +-- Since core system allows this: +SELECT null::nnint_container +-- +50fde20626009aba +== 061 +-- so should PL/PgSQL + +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container; +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +95aa56170d8a8000 +== 062 +SELECT * FROM test_assign_nnint_container2(1,2,3) +-- +e39c33bdd101ccbe +== 063 +SELECT * FROM test_assign_nnint_container2(1,2,null) +-- +e39c33bdd101ccbe +== 064 +|-- +-- Domains of composite +|-- + +CREATE TYPE named_pair AS ( + i integer, + j integer +) +-- +db9827d9a76c7f34 +== 065 +CREATE DOMAIN ordered_named_pair AS named_pair CHECK((VALUE).i <= (VALUE).j) +-- +b125c9d27057ed9d +== 066 +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS integer AS $$ +begin +return p.i + p.j; +end +$$ LANGUAGE plpgsql +-- +af732c5102df0fb9 +== 067 +SELECT read_ordered_named_pair(row(1, 2)) +-- +99ab12d530b4c8f6 +== 068 +SELECT read_ordered_named_pair(row(2, 1)) +-- +99ab12d530b4c8f6 +== 069 +-- fail + +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $$ +begin +return row(i, j); +end +$$ LANGUAGE plpgsql +-- +8d4cab8e5d21a6bd +== 070 +SELECT build_ordered_named_pair(1,2) +-- +2e8e719e7086bcfb +== 071 +SELECT build_ordered_named_pair(2,1) +-- +2e8e719e7086bcfb +== 072 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) + RETURNS ordered_named_pair AS $$ +declare v ordered_named_pair := row(x, y); +begin +v.j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +c3cf333d0584116b +== 073 +SELECT * FROM test_assign_ordered_named_pair(1,2,3) +-- +d217c8ce1c60387e +== 074 +SELECT * FROM test_assign_ordered_named_pair(1,2,0) +-- +d217c8ce1c60387e +== 075 +SELECT * FROM test_assign_ordered_named_pair(2,1,3) +-- +d217c8ce1c60387e +== 076 +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $$ +begin +return array[row(i, j), row(i, j+1)]; +end +$$ LANGUAGE plpgsql +-- +d92acb3b6fa1faa8 +== 077 +SELECT build_ordered_named_pairs(1,2) +-- +412ede52728698e8 +== 078 +SELECT build_ordered_named_pairs(2,1) +-- +412ede52728698e8 +== 079 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) + RETURNS ordered_named_pair[] AS $$ +declare v ordered_named_pair[] := array[row(x, y)]; +begin +-- ideally this would work, but it doesn't yet: +-- v[1].j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +f88b5f02dd081a96 +== 080 +SELECT * FROM test_assign_ordered_named_pairs(1,2,3) +-- +eaf6cdf00d44e9f2 +== 081 +SELECT * FROM test_assign_ordered_named_pairs(2,1,3) +-- +eaf6cdf00d44e9f2 +== 082 +SELECT * FROM test_assign_ordered_named_pairs(1,2,0) +-- +eaf6cdf00d44e9f2 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_misc.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_misc.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_misc.test new file mode 100644 index 0000000..d0ae262 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_misc.test @@ -0,0 +1,77 @@ +== 001 +|-- +-- Miscellaneous topics +|-- + +-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE +do +$$ + declare procedure int; -- check we still recognize non-keywords as vars + begin + create function test1() returns int + begin atomic + select 2 + 2; + end; + create or replace procedure test2(x int) + begin atomic + select x + 2; + end; + end +$$ +-- +f936eab75b8c1b90 +== 002 +-- Test %TYPE and %ROWTYPE error cases +create table misc_table(f1 int) +-- +aa00ab4efdbf21c6 +== 003 +do $$ declare x foo%type; begin end $$ +-- +f936eab75b8c1b90 +== 004 +do $$ declare x notice%type; begin end $$ +-- +f936eab75b8c1b90 +== 005 +-- covers unreserved-keyword case +do $$ declare x foo.bar%type; begin end $$ +-- +f936eab75b8c1b90 +== 006 +do $$ declare x foo.bar.baz%type; begin end $$ +-- +f936eab75b8c1b90 +== 007 +do $$ declare x public.foo.bar%type; begin end $$ +-- +f936eab75b8c1b90 +== 008 +do $$ declare x public.misc_table.zed%type; begin end $$ +-- +f936eab75b8c1b90 +== 009 +do $$ declare x foo%rowtype; begin end $$ +-- +f936eab75b8c1b90 +== 010 +do $$ declare x notice%rowtype; begin end $$ +-- +f936eab75b8c1b90 +== 011 +-- covers unreserved-keyword case +do $$ declare x foo.bar%rowtype; begin end $$ +-- +f936eab75b8c1b90 +== 012 +do $$ declare x foo.bar.baz%rowtype; begin end $$ +-- +f936eab75b8c1b90 +== 013 +do $$ declare x public.foo%rowtype; begin end $$ +-- +f936eab75b8c1b90 +== 014 +do $$ declare x public.misc_table%rowtype; begin end $$ +-- +f936eab75b8c1b90 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_record.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_record.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_record.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_record.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_record.test new file mode 100644 index 0000000..f662b31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_record.test @@ -0,0 +1,990 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of composite (record) variables +|-- + +create type two_int4s as (f1 int4, f2 int4) +-- +beec9e99b48bd933 +== 002 +create type more_int4s as (f0 text, f1 int4, f2 int4) +-- +870a6ac953d930e0 +== 003 +create type two_int8s as (q1 int8, q2 int8) +-- +489ac2c2ae61e609 +== 004 +create type nested_int8s as (c1 two_int8s, c2 two_int8s) +-- +4b99a0af17044d9d +== 005 +-- base-case return of a composite type +create function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1)::two_int8s; end $$ +-- +dd1c31f6aa367c45 +== 006 +select retc(42) +-- +0f388b2602dd5c3b +== 007 +-- ok to return a matching record type +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8); end $$ +-- +d53a9736868e4965 +== 008 +select retc(42) +-- +0f388b2602dd5c3b +== 009 +-- we don't currently support implicit casting +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1); end $$ +-- +d53a9736868e4965 +== 010 +select retc(42) +-- +0f388b2602dd5c3b +== 011 +-- nor extra columns +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8, 42); end $$ +-- +d53a9736868e4965 +== 012 +select retc(42) +-- +0f388b2602dd5c3b +== 013 +-- same cases with an intermediate "record" variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8); return r; end $$ +-- +d53a9736868e4965 +== 014 +select retc(42) +-- +0f388b2602dd5c3b +== 015 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,1); return r; end $$ +-- +d53a9736868e4965 +== 016 +select retc(42) +-- +0f388b2602dd5c3b +== 017 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +d53a9736868e4965 +== 018 +select retc(42) +-- +0f388b2602dd5c3b +== 019 +-- but, for mostly historical reasons, we do convert when assigning +-- to a named-composite-type variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +d53a9736868e4965 +== 020 +select retc(42) +-- +0f388b2602dd5c3b +== 021 +do $$ declare c two_int8s; +begin c := row(1,2); raise notice 'c = %', c; end$$ +-- +f936eab75b8c1b90 +== 022 +do $$ declare c two_int8s; +begin for c in select 1,2 loop raise notice 'c = %', c; end loop; end$$ +-- +f936eab75b8c1b90 +== 023 +do $$ declare c4 two_int4s; c8 two_int8s; +begin + c8 := row(1,2); + c4 := c8; + c8 := c4; + raise notice 'c4 = %', c4; + raise notice 'c8 = %', c8; +end$$ +-- +f936eab75b8c1b90 +== 024 +do $$ declare c two_int8s; d nested_int8s; +begin + c := row(1,2); + d := row(c, row(c.q1, c.q2+1)); + raise notice 'c = %, d = %', c, d; + c.q1 := 10; + d.c1 := row(11,12); + d.c2.q2 := 42; + raise notice 'c = %, d = %', c, d; + raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2; + raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens + raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens +end$$ +-- +f936eab75b8c1b90 +== 025 +-- block-qualified naming +do $$ <> declare c two_int8s; d nested_int8s; +begin + b.c := row(1,2); + b.d := row(b.c, row(b.c.q1, b.c.q2+1)); + raise notice 'b.c = %, b.d = %', b.c, b.d; + b.c.q1 := 10; + b.d.c1 := row(11,12); + b.d.c2.q2 := 42; + raise notice 'b.c = %, b.d = %', b.c, b.d; + raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2; + raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens + raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens +end$$ +-- +f936eab75b8c1b90 +== 026 +-- error cases +do $$ declare c two_int8s; begin c.x = 1; end $$ +-- +f936eab75b8c1b90 +== 027 +do $$ declare c nested_int8s; begin c.x = 1; end $$ +-- +f936eab75b8c1b90 +== 028 +do $$ declare c nested_int8s; begin c.x.q1 = 1; end $$ +-- +f936eab75b8c1b90 +== 029 +do $$ declare c nested_int8s; begin c.c2.x = 1; end $$ +-- +f936eab75b8c1b90 +== 030 +do $$ declare c nested_int8s; begin d.c2.x = 1; end $$ +-- +f936eab75b8c1b90 +== 031 +do $$ <> declare c two_int8s; begin b.c.x = 1; end $$ +-- +f936eab75b8c1b90 +== 032 +do $$ <> declare c nested_int8s; begin b.c.x = 1; end $$ +-- +f936eab75b8c1b90 +== 033 +do $$ <> declare c nested_int8s; begin b.c.x.q1 = 1; end $$ +-- +f936eab75b8c1b90 +== 034 +do $$ <> declare c nested_int8s; begin b.c.c2.x = 1; end $$ +-- +f936eab75b8c1b90 +== 035 +do $$ <> declare c nested_int8s; begin b.d.c2.x = 1; end $$ +-- +f936eab75b8c1b90 +== 036 +-- check passing composite result to another function +create function getq1(two_int8s) returns int8 language plpgsql as $$ +declare r two_int8s; begin r := $1; return r.q1; end $$ +-- +4f324f6b3490e353 +== 037 +select getq1(retc(344)) +-- +f8d60b3f490377b2 +== 038 +select getq1(row(1,2)) +-- +f3e68499b1c67ff3 +== 039 +do $$ +declare r1 two_int8s; r2 record; x int8; +begin + r1 := retc(345); + perform getq1(r1); + x := getq1(r1); + raise notice 'x = %', x; + r2 := retc(346); + perform getq1(r2); + x := getq1(r2); + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 040 +-- check assignments of composites +do $$ +declare r1 two_int8s; r2 two_int8s; r3 record; r4 record; +begin + r1 := row(1,2); + raise notice 'r1 = %', r1; + r1 := r1; -- shouldn't do anything + raise notice 'r1 = %', r1; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := null; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := row(7,11)::two_int8s; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r3 := row(1,2); + r4 := r3; + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r1 := r3; + raise notice 'r1 = %', r1; + r4 := r1; + raise notice 'r4 = %', r4; + r4.q2 := r4.q2 + 1; -- r4's field names have changed + raise notice 'r4 = %', r4; +end$$ +-- +f936eab75b8c1b90 +== 041 +-- fields of named-type vars read as null if uninitialized +do $$ +declare r1 two_int8s; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; +end$$ +-- +f936eab75b8c1b90 +== 042 +do $$ +declare r1 two_int8s; +begin + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +f936eab75b8c1b90 +== 043 +-- records, not so much +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; +end$$ +-- +f936eab75b8c1b90 +== 044 +-- but OK if you assign first +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + r1 := row(1,2); + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +f936eab75b8c1b90 +== 045 +-- check %type with block-qualified variable names +do $$ +<> +declare + v int; + r two_int8s; + v1 v%type; + v2 blk.v%type; + r1 r%type; + r2 blk.r%type; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(r1); + raise notice '%', pg_typeof(r2); +end$$ +-- +f936eab75b8c1b90 +== 046 +-- check that type record can be passed through %type +do $$ +declare r1 record; + r2 r1%type; +begin + r2 := row(1,2); + raise notice 'r2 = %', r2; + r2 := row(3,4,5); + raise notice 'r2 = %', r2; +end$$ +-- +f936eab75b8c1b90 +== 047 +-- arrays of record are not supported at the moment +do $$ +declare r1 record[]; +begin +end$$ +-- +f936eab75b8c1b90 +== 048 +do $$ +declare r1 record; + r2 r1%type[]; +begin +end$$ +-- +f936eab75b8c1b90 +== 049 +-- check repeated assignments to composite fields +create table some_table (id int, data text) +-- +3d5673c2182fd703 +== 050 +do $$ +declare r some_table; +begin + r := (23, 'skidoo'); + for i in 1 .. 10 loop + r.id := r.id + i; + r.data := r.data || ' ' || i; + end loop; + raise notice 'r = %', r; +end$$ +-- +f936eab75b8c1b90 +== 051 +-- check behavior of function declared to return "record" + +create function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1); end $$ +-- +8a8ebef209b2e0ad +== 052 +select returnsrecord(42) +-- +45ab315a2f768e0e +== 053 +select * from returnsrecord(42) as r(x int, y int) +-- +cdeb7c1b5cf2cd43 +== 054 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +216d87745f41273c +== 055 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +184298095c814cd1 +== 056 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1); return r; end $$ +-- +5af4f0a64afdeac4 +== 057 +select returnsrecord(42) +-- +45ab315a2f768e0e +== 058 +select * from returnsrecord(42) as r(x int, y int) +-- +cdeb7c1b5cf2cd43 +== 059 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +216d87745f41273c +== 060 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +184298095c814cd1 +== 061 +-- fail + +-- should work the same with a missing column in the actual result value +create table has_hole(f1 int, f2 int, f3 int) +-- +1b70c47c0821c3c2 +== 062 +alter table has_hole drop column f2 +-- +69f1362388cb8399 +== 063 +create or replace function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1)::has_hole; end $$ +-- +5af4f0a64afdeac4 +== 064 +select returnsrecord(42) +-- +45ab315a2f768e0e +== 065 +select * from returnsrecord(42) as r(x int, y int) +-- +cdeb7c1b5cf2cd43 +== 066 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +216d87745f41273c +== 067 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +184298095c814cd1 +== 068 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1)::has_hole; return r; end $$ +-- +5af4f0a64afdeac4 +== 069 +select returnsrecord(42) +-- +45ab315a2f768e0e +== 070 +select * from returnsrecord(42) as r(x int, y int) +-- +cdeb7c1b5cf2cd43 +== 071 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +216d87745f41273c +== 072 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +184298095c814cd1 +== 073 +-- fail + +-- check access to a field of an argument declared "record" +create function getf1(x record) returns int language plpgsql as +$$ begin return x.f1; end $$ +-- +3022ce6d0870e014 +== 074 +select getf1(1) +-- +7de13ad2fa71cae8 +== 075 +select getf1(row(1,2)) +-- +b7239cb129a0647a +== 076 +select getf1(row(1,2)::two_int4s) +-- +2ec68937a66e7f4b +== 077 +select getf1(row('foo',123,456)::more_int4s) +-- +d9707a25b1084cc7 +== 078 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf1(row(1,2)::two_int8s) +-- +b0f12f8013d83beb +== 079 +select getf1(row(1,2)) +-- +b7239cb129a0647a +== 080 +-- this seemingly-equivalent case behaves a bit differently, +-- because the core parser's handling of $N symbols is simplistic +create function getf2(record) returns int language plpgsql as +$$ begin return $1.f2; end $$ +-- +2dbd3b08b3db8f0b +== 081 +select getf2(row(1,2)) +-- +b37566d209b13f41 +== 082 +-- ideally would work, but does not +select getf2(row(1,2)::two_int4s) +-- +ae5d997f2625cd5f +== 083 +select getf2(row('foo',123,456)::more_int4s) +-- +8b9d582719207525 +== 084 +-- check behavior when assignment to FOR-loop variable requires coercion +do $$ +declare r two_int8s; +begin + for r in select i, i+1 from generate_series(1,4) i + loop + raise notice 'r = %', r; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 085 +-- check behavior when returning setof composite +create function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; + h has_hole; +begin + return next h; + r := (1,2); + h := (3,4); + return next r; + return next h; + return next row(5,6); + return next row(7,8)::has_hole; +end$$ +-- +2bc4f6f4ec20f9dc +== 086 +select returnssetofholes() +-- +cc564d34f7dd4ad0 +== 087 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; +begin + return next r; -- fails, not assigned yet +end$$ +-- +53ee1becf6a2677a +== 088 +select returnssetofholes() +-- +cc564d34f7dd4ad0 +== 089 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +begin + return next row(1,2,3); -- fails +end$$ +-- +53ee1becf6a2677a +== 090 +select returnssetofholes() +-- +cc564d34f7dd4ad0 +== 091 +-- check behavior with changes of a named rowtype +create table mutable(f1 int, f2 text) +-- +399c9615f41783ee +== 092 +create function sillyaddone(int) returns int language plpgsql as +$$ declare r mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +e004e78d7dc89716 +== 093 +select sillyaddone(42) +-- +72c91c0ff0daf28f +== 094 +-- test for change of type of column f1 should be here someday; +-- for now see plpgsql_cache test + +alter table mutable drop column f1 +-- +2d6722abd5871810 +== 095 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddone(42) +-- +72c91c0ff0daf28f +== 096 +-- fail + +create function getf3(x mutable) returns int language plpgsql as +$$ begin return x.f3; end $$ +-- +95daa0e80befc108 +== 097 +select getf3(null::mutable) +-- +f1aaf7660139c314 +== 098 +-- doesn't work yet +alter table mutable add column f3 int +-- +11573d958da6948c +== 099 +select getf3(null::mutable) +-- +f1aaf7660139c314 +== 100 +-- now it works +alter table mutable drop column f3 +-- +a4c0f5606421f3dc +== 101 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf3(null::mutable) +-- +f1aaf7660139c314 +== 102 +-- fails again + +-- check behavior with creating/dropping a named rowtype +set check_function_bodies = off +-- +f8d4a000b73082a4 +== 103 +-- else reference to nonexistent type fails + +create function sillyaddtwo(int) returns int language plpgsql as +$$ declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end $$ +-- +93f412cfccac2d88 +== 104 +reset check_function_bodies +-- +507d70c54f92e61b +== 105 +select sillyaddtwo(42) +-- +f553c3580fb50a15 +== 106 +-- fail +create table mutable2(f1 int, f2 text) +-- +70b73cede4134f10 +== 107 +select sillyaddtwo(42) +-- +f553c3580fb50a15 +== 108 +drop table mutable2 +-- +6efea2a02986013c +== 109 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddtwo(42) +-- +f553c3580fb50a15 +== 110 +-- fail +create table mutable2(f0 text, f1 int, f2 text) +-- +63f274197c355177 +== 111 +select sillyaddtwo(42) +-- +f553c3580fb50a15 +== 112 +select sillyaddtwo(43) +-- +f553c3580fb50a15 +== 113 +-- check access to system columns in a record variable + +create function sillytrig() returns trigger language plpgsql as +$$begin + raise notice 'old.ctid = %', old.ctid; + raise notice 'old.tableoid = %', old.tableoid::regclass; + return new; +end$$ +-- +f7d7356f6933307a +== 114 +create trigger mutable_trig before update on mutable for each row +execute procedure sillytrig() +-- +8a16021e4853656d +== 115 +insert into mutable values ('foo'), ('bar') +-- +c958c44442943532 +== 116 +update mutable set f2 = f2 || ' baz' +-- +199ed2107f52c5b0 +== 117 +table mutable +-- +6628f285331408be +== 118 +-- check returning a composite datum from a trigger + +create or replace function sillytrig() returns trigger language plpgsql as +$$begin + return row(new.*); +end$$ +-- +32a152421f4c5480 +== 119 +update mutable set f2 = f2 || ' baz' +-- +199ed2107f52c5b0 +== 120 +table mutable +-- +6628f285331408be +== 121 +create or replace function sillytrig() returns trigger language plpgsql as +$$declare r record; +begin + r := row(new.*); + return r; +end$$ +-- +32a152421f4c5480 +== 122 +update mutable set f2 = f2 || ' baz' +-- +199ed2107f52c5b0 +== 123 +table mutable +-- +6628f285331408be +== 124 +|-- +-- Domains of composite +|-- + +create domain ordered_int8s as two_int8s check((value).q1 <= (value).q2) +-- +007f203b2858f04c +== 125 +create function read_ordered_int8s(p ordered_int8s) returns int8 as $$ +begin return p.q1 + p.q2; end +$$ language plpgsql +-- +da46572d125775f7 +== 126 +select read_ordered_int8s(row(1, 2)) +-- +5909bb9e251c9dc5 +== 127 +select read_ordered_int8s(row(2, 1)) +-- +5909bb9e251c9dc5 +== 128 +-- fail + +create function build_ordered_int8s(i int8, j int8) returns ordered_int8s as $$ +begin return row(i,j); end +$$ language plpgsql +-- +c558ce340f32c308 +== 129 +select build_ordered_int8s(1,2) +-- +5e8c235269a5dc11 +== 130 +select build_ordered_int8s(2,1) +-- +5e8c235269a5dc11 +== 131 +-- fail + +create function build_ordered_int8s_2(i int8, j int8) returns ordered_int8s as $$ +declare r record; begin r := row(i,j); return r; end +$$ language plpgsql +-- +d9ff9f21fb47525d +== 132 +select build_ordered_int8s_2(1,2) +-- +2888bb305ce4bbc4 +== 133 +select build_ordered_int8s_2(2,1) +-- +2888bb305ce4bbc4 +== 134 +-- fail + +create function build_ordered_int8s_3(i int8, j int8) returns ordered_int8s as $$ +declare r two_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +d6a8f1c1171d9b4f +== 135 +select build_ordered_int8s_3(1,2) +-- +f352ab0b3c879e26 +== 136 +select build_ordered_int8s_3(2,1) +-- +f352ab0b3c879e26 +== 137 +-- fail + +create function build_ordered_int8s_4(i int8, j int8) returns ordered_int8s as $$ +declare r ordered_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +c0bb7a6096372a95 +== 138 +select build_ordered_int8s_4(1,2) +-- +b47ca5f3e93cd1e6 +== 139 +select build_ordered_int8s_4(2,1) +-- +b47ca5f3e93cd1e6 +== 140 +-- fail + +create function build_ordered_int8s_a(i int8, j int8) returns ordered_int8s[] as $$ +begin return array[row(i,j), row(i,j+1)]; end +$$ language plpgsql +-- +538b16284108d4fd +== 141 +select build_ordered_int8s_a(1,2) +-- +40b2459a90b3f23c +== 142 +select build_ordered_int8s_a(2,1) +-- +40b2459a90b3f23c +== 143 +-- fail + +-- check field assignment +do $$ +declare r ordered_int8s; +begin + r.q1 := null; + r.q2 := 43; + r.q1 := 42; + r.q2 := 41; -- fail +end$$ +-- +f936eab75b8c1b90 +== 144 +-- check whole-row assignment +do $$ +declare r ordered_int8s; +begin + r := null; + r := row(null,null); + r := row(1,2); + r := row(2,1); -- fail +end$$ +-- +f936eab75b8c1b90 +== 145 +-- check assignment in for-loop +do $$ +declare r ordered_int8s; +begin + for r in values (1,2),(3,4),(6,5) loop + raise notice 'r = %', r; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 146 +-- check behavior with toastable fields, too + +create type two_texts as (f1 text, f2 text) +-- +f1d3bb611e7aa58d +== 147 +create domain ordered_texts as two_texts check((value).f1 <= (value).f2) +-- +318168cb672a6cf8 +== 148 +create table sometable (id int, a text, b text) +-- +4f147bbee6d1fa56 +== 149 +-- b should be compressed, but in-line +insert into sometable values (1, 'a', repeat('ffoob',1000)) +-- +f2f9ceb7ae00dcaf +== 150 +-- this b should be out-of-line +insert into sometable values (2, 'a', repeat('ffoob',100000)) +-- +f2f9ceb7ae00dcaf +== 151 +-- this pair should fail the domain check +insert into sometable values (3, 'z', repeat('ffoob',100000)) +-- +f2f9ceb7ae00dcaf +== 152 +do $$ +declare d ordered_texts; +begin + for d in select a, b from sometable loop + raise notice 'succeeded at "%"', d.f1; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 153 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := row(r.a, r.b); + end loop; +end$$ +-- +f936eab75b8c1b90 +== 154 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := null; + d.f1 := r.a; + d.f2 := r.b; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 155 +-- check coercion of a record result to named-composite function output type +create function compresult(int8) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,$1); return r; end $$ +-- +ff451c154b6dd3b8 +== 156 +create table two_int8s_tab (f1 two_int8s) +-- +ddde24e70645e4a6 +== 157 +insert into two_int8s_tab values (compresult(42)) +-- +b9fdfa09349645a2 +== 158 +-- reconnect so we lose any local knowledge of anonymous record types +table two_int8s_tab +-- +f961d045d8fb63d1 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_simple.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_simple.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_simple.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_simple.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_simple.test new file mode 100644 index 0000000..251a6cd --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_simple.test @@ -0,0 +1,164 @@ +== 001 +|-- +-- Tests for plpgsql's handling of "simple" expressions +|-- + +-- Check that changes to an inline-able function are handled correctly +create function simplesql(int) returns int language sql +as 'select $1' +-- +783ef15990c552ff +== 002 +create function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simplesql(n); + if n = 5 then + create or replace function simplesql(int) returns int language sql + as 'select $1 + 100'; + end if; + end loop; + return sum; +end$$ +-- +d8872044e04b8a81 +== 003 +select simplecaller() +-- +a95148bc1c9c7d17 +== 004 +-- Check that changes in search path are dealt with correctly +create schema simple1 +-- +d031bf9fd3fa1db9 +== 005 +create function simple1.simpletarget(int) returns int language plpgsql +as $$begin return $1; end$$ +-- +9e6421a8d6d3ec20 +== 006 +create function simpletarget(int) returns int language plpgsql +as $$begin return $1 + 100; end$$ +-- +d34839c95f66568a +== 007 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simpletarget(n); + if n = 5 then + set local search_path = 'simple1'; + end if; + end loop; + return sum; +end$$ +-- +2cf6983ca6dd1c57 +== 008 +select simplecaller() +-- +a95148bc1c9c7d17 +== 009 +-- try it with non-volatile functions, too +alter function simple1.simpletarget(int) immutable +-- +67cd42590375fd8d +== 010 +alter function simpletarget(int) immutable +-- +b4073d41bf67acdf +== 011 +select simplecaller() +-- +a95148bc1c9c7d17 +== 012 +-- make sure flushing local caches changes nothing + +select simplecaller() +-- +a95148bc1c9c7d17 +== 013 +-- Check case where first attempt to determine if it's simple fails + +create function simplesql() returns int language sql +as $$select 1 / 0$$ +-- +622a52bb06b85a4d +== 014 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + select simplesql() into x; + return x; +end$$ +-- +2cf6983ca6dd1c57 +== 015 +select simplecaller() +-- +a95148bc1c9c7d17 +== 016 +-- division by zero occurs during simple-expr check + +create or replace function simplesql() returns int language sql +as $$select 2 + 2$$ +-- +14234346f0950c33 +== 017 +select simplecaller() +-- +a95148bc1c9c7d17 +== 018 +-- Check case where called function changes from non-SRF to SRF (bug #18497) + +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + x := simplesql(); + return x; +end$$ +-- +2cf6983ca6dd1c57 +== 019 +select simplecaller() +-- +a95148bc1c9c7d17 +== 020 +drop function simplesql() +-- +708466fde18d7326 +== 021 +create function simplesql() returns setof int language sql +as $$select 22 + 22$$ +-- +491d881dd0d40368 +== 022 +select simplecaller() +-- +a95148bc1c9c7d17 +== 023 +select simplecaller() +-- +a95148bc1c9c7d17 +== 024 +-- Check handling of simple expression in a scrollable cursor (bug #18859) + +do $$ +declare + p_CurData refcursor; + val int; +begin + open p_CurData scroll for select 42; + fetch p_CurData into val; + raise notice 'val = %', val; +end; $$ +-- +f936eab75b8c1b90 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_transaction.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_transaction.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_transaction.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_transaction.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_transaction.test new file mode 100644 index 0000000..b8ee38a --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_transaction.test @@ -0,0 +1,853 @@ +== 001 +CREATE TABLE test1 (a int, b text) +-- +310497266bba736f +== 002 +CREATE PROCEDURE transaction_test1(x int, y text) +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..x LOOP + INSERT INTO test1 (a, b) VALUES (i, y); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +8cb979b355d54145 +== 003 +CALL transaction_test1(9, 'foo') +-- +999fcfadcca15917 +== 004 +SELECT * FROM test1 +-- +57550c6644afee58 +== 005 +TRUNCATE test1 +-- +5270aa06ddf1345c +== 006 +DO +LANGUAGE plpgsql +$$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +f936eab75b8c1b90 +== 007 +SELECT * FROM test1 +-- +57550c6644afee58 +== 008 +-- transaction commands not allowed when called in transaction block +START TRANSACTION +-- +4ca25828c835d55a +== 009 +CALL transaction_test1(9, 'error') +-- +999fcfadcca15917 +== 010 +COMMIT +-- +7bbcde9cfab6c79c +== 011 +START TRANSACTION +-- +4ca25828c835d55a +== 012 +DO LANGUAGE plpgsql $$ BEGIN COMMIT; END $$ +-- +f936eab75b8c1b90 +== 013 +COMMIT +-- +7bbcde9cfab6c79c +== 014 +TRUNCATE test1 +-- +5270aa06ddf1345c +== 015 +-- not allowed in a function +CREATE FUNCTION transaction_test2() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; + RETURN 1; +END +$$ +-- +e780925bc9c169f2 +== 016 +SELECT transaction_test2() +-- +3d23c908ed564388 +== 017 +SELECT * FROM test1 +-- +57550c6644afee58 +== 018 +-- also not allowed if procedure is called from a function +CREATE FUNCTION transaction_test3() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, 'error'); + RETURN 1; +END; +$$ +-- +068faaa67249da56 +== 019 +SELECT transaction_test3() +-- +75224f68d20688c7 +== 020 +SELECT * FROM test1 +-- +57550c6644afee58 +== 021 +-- DO block inside function +CREATE FUNCTION transaction_test4() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'; + RETURN 1; +END; +$$ +-- +0e6be338e1c8bcdb +== 022 +SELECT transaction_test4() +-- +05d5664b277b08fc +== 023 +-- proconfig settings currently disallow transaction statements +CREATE PROCEDURE transaction_test5() +LANGUAGE plpgsql +SET work_mem = 555 +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +237043e2ca19568e +== 024 +CALL transaction_test5() +-- +9f83214af562a680 +== 025 +-- SECURITY DEFINER currently disallow transaction statements +CREATE PROCEDURE transaction_test5b() +LANGUAGE plpgsql +SECURITY DEFINER +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +8dfd0c0c1fddd321 +== 026 +CALL transaction_test5b() +-- +5b0faea7cc860fec +== 027 +TRUNCATE test1 +-- +5270aa06ddf1345c +== 028 +-- nested procedure calls +CREATE PROCEDURE transaction_test6(c text) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, c); +END; +$$ +-- +3912d73101e04905 +== 029 +CALL transaction_test6('bar') +-- +1cd0a9856b436d21 +== 030 +SELECT * FROM test1 +-- +57550c6644afee58 +== 031 +TRUNCATE test1 +-- +5270aa06ddf1345c +== 032 +CREATE PROCEDURE transaction_test7() +LANGUAGE plpgsql +AS $$ +BEGIN + DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'; +END; +$$ +-- +aba28920fc1e1097 +== 033 +CALL transaction_test7() +-- +1310913c7455b2ac +== 034 +SELECT * FROM test1 +-- +57550c6644afee58 +== 035 +CREATE PROCEDURE transaction_test8() +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'CALL transaction_test1(10, $x$baz$x$)'; +END; +$$ +-- +7323ae1ad1582190 +== 036 +CALL transaction_test8() +-- +1b7e5c74d5564e3e +== 037 +-- commit inside cursor loop +CREATE TABLE test2 (x int) +-- +c2b08f4f9618da43 +== 038 +INSERT INTO test2 VALUES (0), (1), (2), (3), (4) +-- +787d4df9296af90d +== 039 +TRUNCATE test1 +-- +5270aa06ddf1345c +== 040 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + COMMIT; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 041 +SELECT * FROM test1 +-- +57550c6644afee58 +== 042 +-- check that this doesn't leak a holdable portal +SELECT * FROM pg_cursors +-- +9deb0bd4b88ee03c +== 043 +-- error in cursor loop with commit +TRUNCATE test1 +-- +5270aa06ddf1345c +== 044 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (12/(r.x-2)); + COMMIT; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 045 +SELECT * FROM test1 +-- +57550c6644afee58 +== 046 +SELECT * FROM pg_cursors +-- +9deb0bd4b88ee03c +== 047 +-- rollback inside cursor loop +TRUNCATE test1 +-- +5270aa06ddf1345c +== 048 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 049 +SELECT * FROM test1 +-- +57550c6644afee58 +== 050 +SELECT * FROM pg_cursors +-- +9deb0bd4b88ee03c +== 051 +-- first commit then rollback inside cursor loop +TRUNCATE test1 +-- +5270aa06ddf1345c +== 052 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + IF r.x % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 053 +SELECT * FROM test1 +-- +57550c6644afee58 +== 054 +SELECT * FROM pg_cursors +-- +9deb0bd4b88ee03c +== 055 +-- rollback inside cursor loop +TRUNCATE test1 +-- +5270aa06ddf1345c +== 056 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 057 +SELECT * FROM test1 +-- +57550c6644afee58 +== 058 +SELECT * FROM test2 +-- +81c0729760618373 +== 059 +SELECT * FROM pg_cursors +-- +9deb0bd4b88ee03c +== 060 +-- interaction of FOR UPDATE cursor with subsequent updates (bug #17050) +TRUNCATE test1 +-- +5270aa06ddf1345c +== 061 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +8c91d6c1e15fa014 +== 062 +DO LANGUAGE plpgsql $$ +DECLARE + l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE; +BEGIN + FOR r IN l_cur LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 063 +SELECT * FROM test1 +-- +57550c6644afee58 +== 064 +SELECT * FROM pg_cursors +-- +9deb0bd4b88ee03c +== 065 +-- like bug #17050, but with implicit cursor +TRUNCATE test1 +-- +5270aa06ddf1345c +== 066 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +8c91d6c1e15fa014 +== 067 +DO LANGUAGE plpgsql $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT a FROM test1 FOR UPDATE LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 068 +SELECT * FROM test1 +-- +57550c6644afee58 +== 069 +SELECT * FROM pg_cursors +-- +9deb0bd4b88ee03c +== 070 +-- commit inside block with exception handler +TRUNCATE test1 +-- +5270aa06ddf1345c +== 071 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + COMMIT; + INSERT INTO test1 (a) VALUES (1/0); + COMMIT; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +f936eab75b8c1b90 +== 072 +SELECT * FROM test1 +-- +57550c6644afee58 +== 073 +-- rollback inside block with exception handler +TRUNCATE test1 +-- +5270aa06ddf1345c +== 074 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + ROLLBACK; + INSERT INTO test1 (a) VALUES (1/0); + ROLLBACK; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +f936eab75b8c1b90 +== 075 +SELECT * FROM test1 +-- +57550c6644afee58 +== 076 +-- test commit/rollback inside exception handler, too +TRUNCATE test1 +-- +5270aa06ddf1345c +== 077 +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 1..10 LOOP + BEGIN + INSERT INTO test1 VALUES (i, 'good'); + INSERT INTO test1 VALUES (i/0, 'bad'); + EXCEPTION + WHEN division_by_zero THEN + INSERT INTO test1 VALUES (i, 'exception'); + IF (i % 3) > 0 THEN COMMIT; ELSE ROLLBACK; END IF; + END; + END LOOP; +END; +$$ +-- +f936eab75b8c1b90 +== 078 +SELECT * FROM test1 +-- +57550c6644afee58 +== 079 +-- detoast result of simple expression after commit +CREATE TEMP TABLE test4(f1 text) +-- +7ea44b42efa9163f +== 080 +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE EXTERNAL +-- +a6e6ed8d9804cac5 +== 081 +-- disable compression +INSERT INTO test4 SELECT repeat('xyzzy', 2000) +-- +402b9851977a408b +== 082 +-- immutable mark is a bit of a lie, but it serves to make call a simple expr +-- that will return a still-toasted value +CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql +AS 'select f1 from test4' IMMUTABLE +-- +457d6b414127e3f6 +== 083 +DO $$ +declare x text; +begin + for i in 1..3 loop + x := data_source(i); + commit; + end loop; + raise notice 'length(x) = %', length(x); +end $$ +-- +f936eab75b8c1b90 +== 084 +-- operations on composite types vs. internal transactions +DO LANGUAGE plpgsql $$ +declare + c test1 := row(42, 'hello'); + r bool; +begin + for i in 1..3 loop + r := c is not null; + raise notice 'r = %', r; + commit; + end loop; + for i in 1..3 loop + r := c is null; + raise notice 'r = %', r; + rollback; + end loop; +end +$$ +-- +f936eab75b8c1b90 +== 085 +-- COMMIT failures +DO LANGUAGE plpgsql $$ +BEGIN + CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + INSERT INTO test3 (y) VALUES (2); + COMMIT; + INSERT INTO test3 (y) VALUES (3); -- won't get here +END; +$$ +-- +f936eab75b8c1b90 +== 086 +SELECT * FROM test3 +-- +f4be0d9907a2fc72 +== 087 +-- failure while trying to persist a cursor across a transaction (bug #15703) +CREATE PROCEDURE cursor_fail_during_commit() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + COMMIT; + END LOOP; + END; +$$ +-- +3d6801a97d776bac +== 088 +TRUNCATE test1 +-- +5270aa06ddf1345c +== 089 +CALL cursor_fail_during_commit() +-- +ea534c392cb2ac7a +== 090 +-- note that error occurs during first COMMIT, hence nothing is in test1 +SELECT count(*) FROM test1 +-- +454db05f0e610aee +== 091 +CREATE PROCEDURE cursor_fail_during_rollback() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + ROLLBACK; + END LOOP; + END; +$$ +-- +24807733fc8e10b6 +== 092 +TRUNCATE test1 +-- +5270aa06ddf1345c +== 093 +CALL cursor_fail_during_rollback() +-- +0091c4d7de036dc4 +== 094 +SELECT count(*) FROM test1 +-- +454db05f0e610aee +== 095 +-- SET TRANSACTION +DO LANGUAGE plpgsql $$ +BEGIN + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; +END; +$$ +-- +f936eab75b8c1b90 +== 096 +-- error cases +DO LANGUAGE plpgsql $$ +BEGIN + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +END; +$$ +-- +f936eab75b8c1b90 +== 097 +DO LANGUAGE plpgsql $$ +BEGIN + SAVEPOINT foo; +END; +$$ +-- +f936eab75b8c1b90 +== 098 +DO LANGUAGE plpgsql $$ +BEGIN + EXECUTE 'COMMIT'; +END; +$$ +-- +f936eab75b8c1b90 +== 099 +-- snapshot handling test +TRUNCATE test2 +-- +69c51800d2467c57 +== 100 +CREATE PROCEDURE transaction_test9() +LANGUAGE SQL +AS $$ +INSERT INTO test2 VALUES (42); +$$ +-- +4610387d7fe5b84d +== 101 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + CALL transaction_test9(); +END +$$ +-- +f936eab75b8c1b90 +== 102 +SELECT * FROM test2 +-- +81c0729760618373 +== 103 +-- another snapshot handling case: argument expressions of a CALL need +-- to be evaluated with an up-to-date snapshot +CREATE FUNCTION report_count() RETURNS int +STABLE LANGUAGE sql +AS $$ SELECT COUNT(*) FROM test2 $$ +-- +eb1a26b11a95899a +== 104 +CREATE PROCEDURE transaction_test9b(cnt int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'count = %', cnt; +END +$$ +-- +0c1cfaa2489cc2ef +== 105 +DO $$ +BEGIN + CALL transaction_test9b(report_count()); + INSERT INTO test2 VALUES(43); + CALL transaction_test9b(report_count()); +END +$$ +-- +f936eab75b8c1b90 +== 106 +-- Test transaction in procedure with output parameters. This uses a +-- different portal strategy and different code paths in pquery.c. +CREATE PROCEDURE transaction_test10a(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x + 1; + COMMIT; +END; +$$ +-- +d699fe6dc61bd7c5 +== 107 +CALL transaction_test10a(10) +-- +3baf7be226f567ab +== 108 +CREATE PROCEDURE transaction_test10b(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x - 1; + ROLLBACK; +END; +$$ +-- +97e3bd4c609be7f7 +== 109 +CALL transaction_test10b(10) +-- +eb7ff4efb90f679f +== 110 +-- transaction timestamp vs. statement timestamp +CREATE PROCEDURE transaction_test11() +LANGUAGE plpgsql +AS $$ +DECLARE + s1 timestamp with time zone; + s2 timestamp with time zone; + s3 timestamp with time zone; + t1 timestamp with time zone; + t2 timestamp with time zone; + t3 timestamp with time zone; +BEGIN + s1 := statement_timestamp(); + t1 := transaction_timestamp(); + ASSERT s1 = t1; + PERFORM pg_sleep(0.001); + COMMIT; + s2 := statement_timestamp(); + t2 := transaction_timestamp(); + ASSERT s2 = s1; + ASSERT t2 > t1; + PERFORM pg_sleep(0.001); + ROLLBACK; + s3 := statement_timestamp(); + t3 := transaction_timestamp(); + ASSERT s3 = s1; + ASSERT t3 > t2; +END; +$$ +-- +b10aa0009a0ff1c3 +== 111 +CALL transaction_test11() +-- +5ee95d212cdf7687 +== 112 +-- transaction chain + +TRUNCATE test1 +-- +5270aa06ddf1345c +== 113 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + FOR i IN 0..3 LOOP + RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT AND CHAIN; + ELSE + ROLLBACK AND CHAIN; + END IF; + END LOOP; +END +$$ +-- +f936eab75b8c1b90 +== 114 +SELECT * FROM test1 +-- +57550c6644afee58 +== 115 +DROP TABLE test1 +-- +9fdd9d3006af8e29 +== 116 +DROP TABLE test2 +-- +bf67a7944ee4e24d +== 117 +DROP TABLE test3 +-- +993db9da3609cea1 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trap.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trap.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trap.test new file mode 100644 index 0000000..ec99b13 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trap.test @@ -0,0 +1,291 @@ +== 001 +|-- +-- Test error trapping +|-- + +create function trap_zero_divide(int) returns int as $$ +declare x int; + sx smallint; +begin + begin -- start a subtransaction + raise notice 'should see this'; + x := 100 / $1; + raise notice 'should see this only if % <> 0', $1; + sx := $1; + raise notice 'should see this only if % fits in smallint', $1; + if $1 < 0 then + raise exception '% is less than zero', $1; + end if; + exception + when division_by_zero then + raise notice 'caught division_by_zero'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE then + raise notice 'caught numeric_value_out_of_range'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +bd1aa8e9d66bf52c +== 002 +select trap_zero_divide(50) +-- +2bbb1cbdaaa0ded3 +== 003 +select trap_zero_divide(0) +-- +2bbb1cbdaaa0ded3 +== 004 +select trap_zero_divide(100000) +-- +2bbb1cbdaaa0ded3 +== 005 +select trap_zero_divide(-100) +-- +2bbb1cbdaaa0ded3 +== 006 +create table match_source as + select x as id, x*10 as data, x/10 as ten from generate_series(1,100) x +-- +da74b730bbf89a6a +== 007 +create function trap_matching_test(int) returns int as $$ +declare x int; + sx smallint; + y int; +begin + begin -- start a subtransaction + x := 100 / $1; + sx := $1; + select into y data from match_source where id = + (select id from match_source b where ten = $1); + exception + when data_exception then -- category match + raise notice 'caught data_exception'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then + raise notice 'caught numeric_value_out_of_range or cardinality_violation'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +9293e840e4e15232 +== 008 +select trap_matching_test(50) +-- +e4601855319c5095 +== 009 +select trap_matching_test(0) +-- +e4601855319c5095 +== 010 +select trap_matching_test(100000) +-- +e4601855319c5095 +== 011 +select trap_matching_test(1) +-- +e4601855319c5095 +== 012 +create temp table foo (f1 int) +-- +cecd718310a73ba0 +== 013 +create function subxact_rollback_semantics() returns int as $$ +declare x int; +begin + x := 1; + insert into foo values(x); + begin + x := x + 1; + insert into foo values(x); + raise exception 'inner'; + exception + when others then + x := x * 10; + end; + insert into foo values(x); + return x; +end$$ language plpgsql +-- +2f0e8d9eb784dbb3 +== 014 +select subxact_rollback_semantics() +-- +02150efd8727d69d +== 015 +select * from foo +-- +671ce24f54594ab4 +== 016 +drop table foo +-- +fdd1164b8bc60029 +== 017 +create function trap_timeout() returns void as $$ +begin + declare x int; + begin + -- we assume this will take longer than 1 second: + select count(*) into x from generate_series(1, 1_000_000_000_000); + exception + when others then + raise notice 'caught others?'; + when query_canceled then + raise notice 'nyeah nyeah, can''t stop me'; + end; + -- Abort transaction to abandon the statement_timeout setting. Otherwise, + -- the next top-level statement would be vulnerable to the timeout. + raise exception 'end of function'; +end$$ language plpgsql +-- +0184881afc2baf3f +== 018 +begin +-- +b16b431979fc3e05 +== 019 +set statement_timeout to 1000 +-- +c943c893daafa8b8 +== 020 +select trap_timeout() +-- +d26946d60332bcd6 +== 021 +rollback +-- +a46081a556fda027 +== 022 +-- Test for pass-by-ref values being stored in proper context +create function test_variable_storage() returns text as $$ +declare x text; +begin + x := '1234'; + begin + x := x || '5678'; + -- force error inside subtransaction SPI context + perform trap_zero_divide(-100); + exception + when others then + x := x || '9012'; + end; + return x; +end$$ language plpgsql +-- +f04ec1c5918fc4d4 +== 023 +select test_variable_storage() +-- +0303027e0cdd55fb +== 024 +|-- +-- test foreign key error trapping +|-- + +create temp table root(f1 int primary key) +-- +18b9bc59d0e6f1a9 +== 025 +create temp table leaf(f1 int references root deferrable) +-- +a8b99a618f059e46 +== 026 +insert into root values(1) +-- +a92eba14c9f19381 +== 027 +insert into leaf values(1) +-- +62387c2b723b4df8 +== 028 +insert into leaf values(2) +-- +62387c2b723b4df8 +== 029 +-- fails + +create function trap_foreign_key(int) returns int as $$ +begin + begin -- start a subtransaction + insert into leaf values($1); + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +647a265123653108 +== 030 +create function trap_foreign_key_2() returns int as $$ +begin + begin -- start a subtransaction + set constraints all immediate; + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +d17b895494e93efc +== 031 +select trap_foreign_key(1) +-- +223f4703fe1f56b4 +== 032 +select trap_foreign_key(2) +-- +223f4703fe1f56b4 +== 033 +-- detects FK violation + +begin +-- +b16b431979fc3e05 +== 034 +set constraints all deferred +-- +8d0c5ef5969a4768 +== 035 +select trap_foreign_key(2) +-- +223f4703fe1f56b4 +== 036 +-- should not detect FK violation + savepoint x +-- +8ebd566ea1bf947b +== 037 +set constraints all immediate +-- +893dbdab72abe4b5 +== 038 +-- fails + rollback to x +-- +ede7bfabb934a1db +== 039 +select trap_foreign_key_2() +-- +ebd72c69eba4d60a +== 040 +-- detects FK violation +commit +-- +7bbcde9cfab6c79c +== 041 +-- still fails + +drop function trap_foreign_key(int) +-- +d171dab74d844f75 +== 042 +drop function trap_foreign_key_2() +-- +58c782aa3f7416e8 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trigger.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trigger.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trigger.test new file mode 100644 index 0000000..c28c85f --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_trigger.test @@ -0,0 +1,37 @@ +== 001 +-- Simple test to verify accessibility of the OLD and NEW trigger variables + +create table testtr (a int, b text) +-- +454099cc06c22e27 +== 002 +create function testtr_trigger() returns trigger language plpgsql as +$$begin + raise notice 'tg_op = %', tg_op; + raise notice 'old(%) = %', old.a, row(old.*); + raise notice 'new(%) = %', new.a, row(new.*); + if (tg_op = 'DELETE') then + return old; + else + return new; + end if; +end$$ +-- +7a024a9a2eeef6d6 +== 003 +create trigger testtr_trigger before insert or delete or update on testtr + for each row execute function testtr_trigger() +-- +b50479ce4d6d3755 +== 004 +insert into testtr values (1, 'one'), (2, 'two') +-- +99a6b39b45595a36 +== 005 +update testtr set a = a + 1 +-- +c191d316e9970716 +== 006 +delete from testtr +-- +4e0537b873f19003 diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_varprops.metadata.json b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_varprops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_varprops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/fingerprint/plpgsql_regress/plpgsql_varprops.test b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_varprops.test new file mode 100644 index 0000000..18141d5 --- /dev/null +++ b/parser/testdata/fingerprint/plpgsql_regress/plpgsql_varprops.test @@ -0,0 +1,325 @@ +== 001 +|-- +-- Tests for PL/pgSQL variable properties: CONSTANT, NOT NULL, initializers +|-- + +create type var_record as (f1 int4, f2 int4) +-- +ce91632adb82917c +== 002 +create domain int_nn as int not null +-- +1d48e6d7e6371daf +== 003 +create domain var_record_nn as var_record not null +-- +3fbf080f7452caf1 +== 004 +create domain var_record_colnn as var_record check((value).f2 is not null) +-- +c932943a61e9b591 +== 005 +-- CONSTANT + +do $$ +declare x constant int := 42; +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 006 +do $$ +declare x constant int; +begin + x := 42; -- fail +end$$ +-- +f936eab75b8c1b90 +== 007 +do $$ +declare x constant int; y int; +begin + for x, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +f936eab75b8c1b90 +== 008 +do $$ +declare x constant int[]; +begin + x[1] := 42; -- fail +end$$ +-- +f936eab75b8c1b90 +== 009 +do $$ +declare x constant int[]; y int; +begin + for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax) + end loop; +end$$ +-- +f936eab75b8c1b90 +== 010 +do $$ +declare x constant var_record; +begin + x.f1 := 42; -- fail +end$$ +-- +f936eab75b8c1b90 +== 011 +do $$ +declare x constant var_record; y int; +begin + for x.f1, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +f936eab75b8c1b90 +== 012 +-- initializer expressions + +do $$ +declare x int := sin(0); +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 013 +do $$ +declare x int := 1/0; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 014 +do $$ +declare x bigint[] := array[1,3,5]; +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 015 +do $$ +declare x record := row(1,2,3); +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 016 +do $$ +declare x var_record := row(1,2); +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 017 +-- NOT NULL + +do $$ +declare x int not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 018 +do $$ +declare x int not null := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +f936eab75b8c1b90 +== 019 +do $$ +declare x int not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 020 +do $$ +declare x record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 021 +do $$ +declare x record not null := row(42); +begin + raise notice 'x = %', x; + x := row(null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +f936eab75b8c1b90 +== 022 +do $$ +declare x record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 023 +do $$ +declare x var_record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 024 +do $$ +declare x var_record not null := row(41,42); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +f936eab75b8c1b90 +== 025 +do $$ +declare x var_record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 026 +-- Check that variables are reinitialized on block re-entry. + +do $$ +begin + for i in 1..3 loop + declare + x int; + y int := i; + r record; + c var_record; + begin + if i = 1 then + x := 42; + r := row(i, i+1); + c := row(i, i+1); + end if; + raise notice 'x = %', x; + raise notice 'y = %', y; + raise notice 'r = %', r; + raise notice 'c = %', c; + end; + end loop; +end$$ +-- +f936eab75b8c1b90 +== 027 +-- Check enforcement of domain constraints during initialization + +do $$ +declare x int_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 028 +do $$ +declare x int_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 029 +do $$ +declare x int_nn := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +f936eab75b8c1b90 +== 030 +do $$ +declare x var_record_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 031 +do $$ +declare x var_record_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 032 +do $$ +declare x var_record_nn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + x := null; -- fail +end$$ +-- +f936eab75b8c1b90 +== 033 +do $$ +declare x var_record_colnn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 034 +do $$ +declare x var_record_colnn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 035 +do $$ +declare x var_record_colnn := row(1,null); -- fail +begin + raise notice 'x = %', x; +end$$ +-- +f936eab75b8c1b90 +== 036 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +f936eab75b8c1b90 +== 037 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- fail +end$$ +-- +f936eab75b8c1b90 diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_array.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_array.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_array.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_array.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_array.test new file mode 100644 index 0000000..c2a2652 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_array.test @@ -0,0 +1,239 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of array variables +|-- +-- We also check arrays of composites here, so this has some overlap +-- with the plpgsql_record tests. +|-- + +create type complex as (r float8, i float8) +-- +|-- +-- Tests for PL/pgSQL handling of array variables +|-- +-- We also check arrays of composites here, so this has some overlap +-- with the plpgsql_record tests. +|-- + +create type complex as (r float8, i float8) +== 002 +create type quadarray as (c1 complex[], c2 complex) +-- +create type quadarray as (c1 complex[], c2 complex) +== 003 +do $$ declare a int[]; +begin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end$$ +-- +do $1 +== 004 +do $$ declare a int[]; +begin a[3] := 4; raise notice 'a = %', a; end$$ +-- +do $1 +== 005 +do $$ declare a int[]; +begin a[1][4] := 4; raise notice 'a = %', a; end$$ +-- +do $1 +== 006 +do $$ declare a int[]; +begin a[1] := 23::text; raise notice 'a = %', a; end$$ +-- +do $1 +== 007 +-- lax typing + +do $$ declare a int[]; +begin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end$$ +-- +-- lax typing + +do $1 +== 008 +do $$ declare a int[]; +begin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end$$ +-- +do $1 +== 009 +do $$ declare a int[]; +begin a[1:2] := array[3,4]; raise notice 'a = %', a; end$$ +-- +do $1 +== 010 +do $$ declare a int[]; +begin a[1:2] := 4; raise notice 'a = %', a; end$$ +-- +do $1 +== 011 +-- error + +do $$ declare a complex[]; +begin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end$$ +-- +-- error + +do $1 +== 012 +do $$ declare a complex[]; +begin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end$$ +-- +do $1 +== 013 +-- perhaps this ought to work, but for now it doesn't: +do $$ declare a complex[]; +begin a[1:2].i := array[11,12]; raise notice 'a = %', a; end$$ +-- +-- perhaps this ought to work, but for now it doesn't: +do $1 +== 014 +do $$ declare a quadarray; +begin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end$$ +-- +do $1 +== 015 +do $$ declare a int[]; +begin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end$$ +-- +do $1 +== 016 +create temp table onecol as select array[1,2] as f1 +-- +create temp table onecol as select array[1,2] as f1 +== 017 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +do $1 +== 018 +do $$ declare a int[]; +begin a := * from onecol for update; raise notice 'a = %', a; end$$ +-- +do $1 +== 019 +-- error cases: + +do $$ declare a int[]; +begin a := from onecol; raise notice 'a = %', a; end$$ +-- +-- error cases: + +do $1 +== 020 +do $$ declare a int[]; +begin a := f1, f1 from onecol; raise notice 'a = %', a; end$$ +-- +do $1 +== 021 +insert into onecol values(array[11]) +-- +insert into onecol values(array[$1]) +== 022 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +do $1 +== 023 +do $$ declare a int[]; +begin a := f1 from onecol limit 1; raise notice 'a = %', a; end$$ +-- +do $1 +== 024 +do $$ declare a real; +begin a[1] := 2; raise notice 'a = %', a; end$$ +-- +do $1 +== 025 +do $$ declare a complex; +begin a.r[1] := 2; raise notice 'a = %', a; end$$ +-- +do $1 +== 026 +|-- +-- test of %type[] and %rowtype[] syntax +|-- + +-- check supported syntax +do $$ +declare + v int; + v1 v%type; + v2 v%type[]; + v3 v%type[1]; + v4 v%type[][]; + v5 v%type[1][3]; + v6 v%type array; + v7 v%type array[]; + v8 v%type array[1]; + v9 v%type array[1][1]; + v10 pg_catalog.pg_class%rowtype[]; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(v3); + raise notice '%', pg_typeof(v4); + raise notice '%', pg_typeof(v5); + raise notice '%', pg_typeof(v6); + raise notice '%', pg_typeof(v7); + raise notice '%', pg_typeof(v8); + raise notice '%', pg_typeof(v9); + raise notice '%', pg_typeof(v10); +end; +$$ +-- +|-- +-- test of %type[] and %rowtype[] syntax +|-- + +-- check supported syntax +do $1 +== 027 +-- some types don't support arrays +do $$ +declare + v pg_node_tree; + v1 v%type[]; +begin +end; +$$ +-- +-- some types don't support arrays +do $1 +== 028 +-- check functionality +do $$ +declare + v1 int; + v2 varchar; + a1 v1%type[]; + a2 v2%type[]; +begin + v1 := 10; + v2 := 'Hi'; + a1 := array[v1,v1]; + a2 := array[v2,v2]; + raise notice '% %', a1, a2; +end; +$$ +-- +-- check functionality +do $1 +== 029 +create table array_test_table(a int, b varchar) +-- +create table array_test_table(a int, b varchar) +== 030 +insert into array_test_table values(1, 'first'), (2, 'second') +-- +insert into array_test_table values($1, $2), ($3, $4) +== 031 +do $$ +declare tg array_test_table%rowtype[]; +begin + tg := array(select array_test_table from array_test_table); + raise notice '%', tg; + tg := array(select row(a,b) from array_test_table); + raise notice '%', tg; +end; +$$ +-- +do $1 diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_cache.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_cache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_cache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_cache.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_cache.test new file mode 100644 index 0000000..3fda2f6 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_cache.test @@ -0,0 +1,103 @@ +== 001 +|-- +-- Cache-behavior-dependent test cases +|-- +-- These tests logically belong in plpgsql_record.sql, and perhaps someday +-- can be merged back into it. For now, however, their results are different +-- depending on debug_discard_caches, so we must have two expected-output +-- files to cover both cases. To minimize the maintenance effort resulting +-- from that, this file should contain only tests that do have different +-- results under debug_discard_caches. +|-- + +-- check behavior with changes of a named rowtype +create table c_mutable(f1 int, f2 text) +-- +|-- +-- Cache-behavior-dependent test cases +|-- +-- These tests logically belong in plpgsql_record.sql, and perhaps someday +-- can be merged back into it. For now, however, their results are different +-- depending on debug_discard_caches, so we must have two expected-output +-- files to cover both cases. To minimize the maintenance effort resulting +-- from that, this file should contain only tests that do have different +-- results under debug_discard_caches. +|-- + +-- check behavior with changes of a named rowtype +create table c_mutable(f1 int, f2 text) +== 002 +create function c_sillyaddone(int) returns int language plpgsql as +$$ declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +create function c_sillyaddone(int) returns int language plpgsql as +$1 +== 003 +select c_sillyaddone(42) +-- +select c_sillyaddone($1) +== 004 +alter table c_mutable drop column f1 +-- +alter table c_mutable drop column f1 +== 005 +alter table c_mutable add column f1 float8 +-- +alter table c_mutable add column f1 float8 +== 006 +-- currently, this fails due to cached plan for "r.f1 + 1" expression +-- (but if debug_discard_caches is on, it will succeed) +select c_sillyaddone(42) +-- +-- currently, this fails due to cached plan for "r.f1 + 1" expression +-- (but if debug_discard_caches is on, it will succeed) +select c_sillyaddone($1) +== 007 +-- but it's OK if we force plan rebuilding +discard plans +-- +-- but it's OK if we force plan rebuilding +discard plans +== 008 +select c_sillyaddone(42) +-- +select c_sillyaddone($1) +== 009 +-- check behavior with changes in a record rowtype +create function show_result_type(text) returns text language plpgsql as +$$ + declare + r record; + t text; + begin + execute $1 into r; + select pg_typeof(r.a) into t; + return format('type %s value %s', t, r.a::text); + end; +$$ +-- +-- check behavior with changes in a record rowtype +create function show_result_type(text) returns text language plpgsql as +$1 +== 010 +select show_result_type('select 1 as a') +-- +select show_result_type($1) +== 011 +-- currently this fails due to cached plan for pg_typeof expression +-- (but if debug_discard_caches is on, it will succeed) +select show_result_type('select 2.0 as a') +-- +-- currently this fails due to cached plan for pg_typeof expression +-- (but if debug_discard_caches is on, it will succeed) +select show_result_type($1) +== 012 +-- but it's OK if we force plan rebuilding +discard plans +-- +-- but it's OK if we force plan rebuilding +discard plans +== 013 +select show_result_type('select 2.0 as a') +-- +select show_result_type($1) diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_call.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_call.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_call.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_call.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_call.test new file mode 100644 index 0000000..a1bf916 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_call.test @@ -0,0 +1,833 @@ +== 001 +|-- +-- Tests for procedures / CALL syntax +|-- + +CREATE PROCEDURE test_proc1() +LANGUAGE plpgsql +AS $$ +BEGIN + NULL; +END; +$$ +-- +|-- +-- Tests for procedures / CALL syntax +|-- + +CREATE PROCEDURE test_proc1() +LANGUAGE plpgsql +AS $1 +== 002 +CALL test_proc1() +-- +CALL test_proc1() +== 003 +-- error: can't return non-NULL +CREATE PROCEDURE test_proc2() +LANGUAGE plpgsql +AS $$ +BEGIN + RETURN 5; +END; +$$ +-- +-- error: can't return non-NULL +CREATE PROCEDURE test_proc2() +LANGUAGE plpgsql +AS $1 +== 004 +CREATE TABLE test1 (a int) +-- +CREATE TABLE test1 (a int) +== 005 +CREATE PROCEDURE test_proc3(x int) +LANGUAGE plpgsql +AS $$ +BEGIN + INSERT INTO test1 VALUES (x); +END; +$$ +-- +CREATE PROCEDURE test_proc3(x int) +LANGUAGE plpgsql +AS $1 +== 006 +CALL test_proc3(55) +-- +CALL test_proc3($1) +== 007 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 008 +-- Check that plan revalidation doesn't prevent setting transaction properties +-- (bug #18059). This test must include the first temp-object creation in +-- this script, or it won't exercise the bug scenario. Hence we put it early. +CREATE PROCEDURE test_proc3a() +LANGUAGE plpgsql +AS $$ +BEGIN + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + RAISE NOTICE 'done'; +END; +$$ +-- +-- Check that plan revalidation doesn't prevent setting transaction properties +-- (bug #18059). This test must include the first temp-object creation in +-- this script, or it won't exercise the bug scenario. Hence we put it early. +CREATE PROCEDURE test_proc3a() +LANGUAGE plpgsql +AS $1 +== 009 +CALL test_proc3a() +-- +CALL test_proc3a() +== 010 +CREATE TEMP TABLE tt1(f1 int) +-- +CREATE TEMP TABLE tt1(f1 int) +== 011 +CALL test_proc3a() +-- +CALL test_proc3a() +== 012 +-- nested CALL +TRUNCATE TABLE test1 +-- +-- nested CALL +TRUNCATE TABLE test1 +== 013 +CREATE PROCEDURE test_proc4(y int) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL test_proc3(y); + CALL test_proc3($1); +END; +$$ +-- +CREATE PROCEDURE test_proc4(y int) +LANGUAGE plpgsql +AS $1 +== 014 +CALL test_proc4(66) +-- +CALL test_proc4($1) +== 015 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 016 +CALL test_proc4(66) +-- +CALL test_proc4($1) +== 017 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 018 +-- output arguments + +CREATE PROCEDURE test_proc5(INOUT a text) +LANGUAGE plpgsql +AS $$ +BEGIN + a := a || '+' || a; +END; +$$ +-- +-- output arguments + +CREATE PROCEDURE test_proc5(INOUT a text) +LANGUAGE plpgsql +AS $1 +== 019 +CALL test_proc5('abc') +-- +CALL test_proc5($1) +== 020 +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + b := b * a; + c := c * a; +END; +$$ +-- +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $1 +== 021 +CALL test_proc6(2, 3, 4) +-- +CALL test_proc6($1, $2, $3) +== 022 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); + RAISE INFO 'x = %, y = %', x, y; + CALL test_proc6(2, c => y, b => x); + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +DO +LANGUAGE plpgsql +$1 +== 023 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x + 1, y); -- error + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +DO +LANGUAGE plpgsql +$1 +== 024 +DO +LANGUAGE plpgsql +$$ +DECLARE + x constant int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); -- error because x is constant +END; +$$ +-- +DO +LANGUAGE plpgsql +$1 +== 025 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + FOR i IN 1..5 LOOP + CALL test_proc6(i, x, y); + RAISE INFO 'x = %, y = %', x, y; + END LOOP; +END; +$$ +-- +DO +LANGUAGE plpgsql +$1 +== 026 +-- recursive with output arguments + +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN +IF x > 1 THEN + a := x / 10; + b := x / 2; + CALL test_proc7(b::int, a, b); +END IF; +END; +$$ +-- +-- recursive with output arguments + +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $1 +== 027 +CALL test_proc7(100, -1, -1) +-- +CALL test_proc7($1, $2, $3) +== 028 +-- inner COMMIT with output arguments + +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN + a := x / 10; + b := x / 2; + COMMIT; +END; +$$ +-- +-- inner COMMIT with output arguments + +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $1 +== 029 +CREATE PROCEDURE test_proc7cc(_x int) +LANGUAGE plpgsql +AS $$ +DECLARE _a int; _b numeric; +BEGIN + CALL test_proc7c(_x, _a, _b); + RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b; +END +$$ +-- +CREATE PROCEDURE test_proc7cc(_x int) +LANGUAGE plpgsql +AS $1 +== 030 +CALL test_proc7cc(10) +-- +CALL test_proc7cc($1) +== 031 +-- named parameters and defaults + +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := a * 10; + b := b + 10; +END; +$$ +-- +-- named parameters and defaults + +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) +LANGUAGE plpgsql +AS $1 +== 032 +CALL test_proc8a(10, 20) +-- +CALL test_proc8a($1, $2) +== 033 +CALL test_proc8a(b => 20, a => 10) +-- +CALL test_proc8a(b => $1, a => $2) +== 034 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc8a(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; + CALL test_proc8a(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +DO $1 +== 035 +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $1 +== 036 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8b(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + CALL test_proc8b(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $1 +== 037 +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int DEFAULT 11) +LANGUAGE plpgsql +AS $1 +== 038 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(c => _c, b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $1 +== 039 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $1 +== 040 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, b => _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $1 +== 041 +-- OUT parameters + +CREATE PROCEDURE test_proc9(IN a int, OUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + b := a * 2; +END; +$$ +-- +-- OUT parameters + +CREATE PROCEDURE test_proc9(IN a int, OUT b int) +LANGUAGE plpgsql +AS $1 +== 042 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc9(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +DO $1 +== 043 +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + b := a - c; +END; +$$ +-- +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int DEFAULT 11) +LANGUAGE plpgsql +AS $1 +== 044 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(a => _a, b => _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $1 +== 045 +-- OUT + VARIADIC + +CREATE PROCEDURE test_proc11(a OUT int, VARIADIC b int[]) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := b[1] + b[2]; +END; +$$ +-- +-- OUT + VARIADIC + +CREATE PROCEDURE test_proc11(a OUT int, VARIADIC b int[]) +LANGUAGE plpgsql +AS $1 +== 046 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc11(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $1 +== 047 +-- polymorphic OUT arguments + +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %', a; + b := a; + c := array[a]; +END; +$$ +-- +-- polymorphic OUT arguments + +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) +LANGUAGE plpgsql +AS $1 +== 048 +DO $$ +DECLARE _a int; _b int; _c int[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $1 +== 049 +DO $$ +DECLARE _a int; _b int; _c text[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); -- error + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +DO $1 +== 050 +-- transition variable assignment + +TRUNCATE test1 +-- +-- transition variable assignment + +TRUNCATE test1 +== 051 +CREATE FUNCTION triggerfunc1() RETURNS trigger +LANGUAGE plpgsql +AS $$ +DECLARE + z int := 0; +BEGIN + CALL test_proc6(2, NEW.a, NEW.a); + RETURN NEW; +END; +$$ +-- +CREATE FUNCTION triggerfunc1() RETURNS trigger +LANGUAGE plpgsql +AS $1 +== 052 +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE PROCEDURE triggerfunc1() +-- +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE PROCEDURE triggerfunc1() +== 053 +INSERT INTO test1 VALUES (1), (2), (3) +-- +INSERT INTO test1 VALUES ($1), ($2), ($3) +== 054 +UPDATE test1 SET a = 22 WHERE a = 2 +-- +UPDATE test1 SET a = $1 WHERE a = $2 +== 055 +SELECT * FROM test1 ORDER BY a +-- +SELECT * FROM test1 ORDER BY a +== 056 +DROP PROCEDURE test_proc1 +-- +DROP PROCEDURE test_proc1 +== 057 +DROP PROCEDURE test_proc3 +-- +DROP PROCEDURE test_proc3 +== 058 +DROP PROCEDURE test_proc4 +-- +DROP PROCEDURE test_proc4 +== 059 +DROP TABLE test1 +-- +DROP TABLE test1 +== 060 +-- more checks for named-parameter handling + +CREATE PROCEDURE p1(v_cnt int, v_Text inout text = NULL) +AS $$ +BEGIN + v_Text := 'v_cnt = ' || v_cnt; +END +$$ LANGUAGE plpgsql +-- +-- more checks for named-parameter handling + +CREATE PROCEDURE p1(v_cnt int, v_Text inout text = NULL) +AS $1 LANGUAGE plpgsql +== 061 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text + RAISE NOTICE '%', v_Text; +END; +$$ +-- +DO $1 +== 062 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +DO $1 +== 063 +DO $$ +DECLARE + v_Text text; +BEGIN + CALL p1(10, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +DO $1 +== 064 +DO $$ +DECLARE + v_Text text; + v_cnt integer; +BEGIN + CALL p1(v_Text := v_Text, v_cnt := v_cnt); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +DO $1 +== 065 +-- check that we detect change of dependencies in CALL +-- atomic and non-atomic call sites used to do this differently, so check both + +CREATE PROCEDURE inner_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'inner_p(%)', f1; +END +$$ LANGUAGE plpgsql +-- +-- check that we detect change of dependencies in CALL +-- atomic and non-atomic call sites used to do this differently, so check both + +CREATE PROCEDURE inner_p (f1 int) +AS $1 LANGUAGE plpgsql +== 066 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 1 $$ LANGUAGE sql +-- +CREATE FUNCTION f(int) RETURNS int AS $1 LANGUAGE sql +== 067 +CREATE PROCEDURE outer_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'outer_p(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +CREATE PROCEDURE outer_p (f1 int) +AS $1 LANGUAGE plpgsql +== 068 +CREATE FUNCTION outer_f (f1 int) RETURNS void +AS $$ +BEGIN + RAISE NOTICE 'outer_f(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION outer_f (f1 int) RETURNS void +AS $1 LANGUAGE plpgsql +== 069 +CALL outer_p(42) +-- +CALL outer_p($1) +== 070 +SELECT outer_f(42) +-- +SELECT outer_f($1) +== 071 +DROP FUNCTION f(int) +-- +DROP FUNCTION f(int) +== 072 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 2 $$ LANGUAGE sql +-- +CREATE FUNCTION f(int) RETURNS int AS $1 LANGUAGE sql +== 073 +CALL outer_p(42) +-- +CALL outer_p($1) +== 074 +SELECT outer_f(42) +-- +SELECT outer_f($1) +== 075 +-- Check that stable functions in CALL see the correct snapshot + +CREATE TABLE t_test (x int) +-- +-- Check that stable functions in CALL see the correct snapshot + +CREATE TABLE t_test (x int) +== 076 +INSERT INTO t_test VALUES (0) +-- +INSERT INTO t_test VALUES ($1) +== 077 +CREATE FUNCTION f_get_x () RETURNS int +AS $$ +DECLARE l_result int; +BEGIN + SELECT x INTO l_result FROM t_test; + RETURN l_result; +END +$$ LANGUAGE plpgsql STABLE +-- +CREATE FUNCTION f_get_x () RETURNS int +AS $1 LANGUAGE plpgsql STABLE +== 078 +CREATE PROCEDURE f_print_x (x int) +AS $$ +BEGIN + RAISE NOTICE 'f_print_x(%)', x; +END +$$ LANGUAGE plpgsql +-- +CREATE PROCEDURE f_print_x (x int) +AS $1 LANGUAGE plpgsql +== 079 +-- test in non-atomic context +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + ROLLBACK; +END +$$ +-- +-- test in non-atomic context +DO $1 +== 080 +-- test in non-atomic context, except exception block is locally atomic +DO $$ +BEGIN + BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + EXCEPTION WHEN division_by_zero THEN + RAISE NOTICE '%', SQLERRM; + END; + ROLLBACK; +END +$$ +-- +-- test in non-atomic context, except exception block is locally atomic +DO $1 +== 081 +-- test in atomic context +BEGIN +-- +-- test in atomic context +BEGIN +== 082 +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); +END +$$ +-- +DO $1 +== 083 +ROLLBACK +-- +ROLLBACK diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_control.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_control.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_control.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_control.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_control.test new file mode 100644 index 0000000..8b34cbc --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_control.test @@ -0,0 +1,661 @@ +== 001 +|-- +-- Tests for PL/pgSQL control structures +|-- + +-- integer FOR loop + +do $$ +begin + -- basic case + for i in 1..3 loop + raise notice '1..3: i = %', i; + end loop; + -- with BY, end matches exactly + for i in 1..10 by 3 loop + raise notice '1..10 by 3: i = %', i; + end loop; + -- with BY, end does not match + for i in 1..11 by 3 loop + raise notice '1..11 by 3: i = %', i; + end loop; + -- zero iterations + for i in 1..0 by 3 loop + raise notice '1..0 by 3: i = %', i; + end loop; + -- REVERSE + for i in reverse 10..0 by 3 loop + raise notice 'reverse 10..0 by 3: i = %', i; + end loop; + -- potential overflow + for i in 2147483620..2147483647 by 10 loop + raise notice '2147483620..2147483647 by 10: i = %', i; + end loop; + -- potential overflow, reverse direction + for i in reverse -2147483620..-2147483647 by 10 loop + raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i; + end loop; +end$$ +-- +|-- +-- Tests for PL/pgSQL control structures +|-- + +-- integer FOR loop + +do $1 +== 002 +-- BY can't be zero or negative +do $$ +begin + for i in 1..3 by 0 loop + raise notice '1..3 by 0: i = %', i; + end loop; +end$$ +-- +-- BY can't be zero or negative +do $1 +== 003 +do $$ +begin + for i in 1..3 by -1 loop + raise notice '1..3 by -1: i = %', i; + end loop; +end$$ +-- +do $1 +== 004 +do $$ +begin + for i in reverse 1..3 by -1 loop + raise notice 'reverse 1..3 by -1: i = %', i; + end loop; +end$$ +-- +do $1 +== 005 +-- CONTINUE statement + +create table conttesttbl(idx serial, v integer) +-- +-- CONTINUE statement + +create table conttesttbl(idx serial, v integer) +== 006 +insert into conttesttbl(v) values(10) +-- +insert into conttesttbl(v) values($1) +== 007 +insert into conttesttbl(v) values(20) +-- +insert into conttesttbl(v) values($1) +== 008 +insert into conttesttbl(v) values(30) +-- +insert into conttesttbl(v) values($1) +== 009 +insert into conttesttbl(v) values(40) +-- +insert into conttesttbl(v) values($1) +== 010 +create function continue_test1() returns void as $$ +declare _i integer = 0; _r record; +begin + raise notice '---1---'; + loop + _i := _i + 1; + raise notice '%', _i; + continue when _i < 10; + exit; + end loop; + + raise notice '---2---'; + <> + loop + _i := _i - 1; + loop + raise notice '%', _i; + continue lbl when _i > 0; + exit lbl; + end loop; + end loop; + + raise notice '---3---'; + <> + while _i < 10 loop + _i := _i + 1; + continue the_loop when _i % 2 = 0; + raise notice '%', _i; + end loop; + + raise notice '---4---'; + for _i in 1..10 loop + begin + -- applies to outer loop, not the nested begin block + continue when _i < 5; + raise notice '%', _i; + end; + end loop; + + raise notice '---5---'; + for _r in select * from conttesttbl loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---6---'; + for _r in execute 'select * from conttesttbl' loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---7---'; + <> + for _i in 1..3 loop + continue looplabel when _i = 2; + raise notice '%', _i; + end loop; + + raise notice '---8---'; + _i := 1; + while _i <= 3 loop + raise notice '%', _i; + _i := _i + 1; + continue when _i = 3; + end loop; + + raise notice '---9---'; + for _r in select * from conttesttbl order by v limit 1 loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---10---'; + for _r in execute 'select * from conttesttbl order by v limit 1' loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---11---'; + <> + for _i in 1..2 loop + raise notice 'outer %', _i; + <> + for _j in 1..3 loop + continue outerlooplabel when _j = 2; + raise notice 'inner %', _j; + end loop; + end loop; +end; $$ language plpgsql +-- +create function continue_test1() returns void as $1 language plpgsql +== 011 +select continue_test1() +-- +select continue_test1() +== 012 +-- should fail: CONTINUE is only legal inside a loop +create function continue_error1() returns void as $$ +begin + begin + continue; + end; +end; +$$ language plpgsql +-- +-- should fail: CONTINUE is only legal inside a loop +create function continue_error1() returns void as $1 language plpgsql +== 013 +-- should fail: unlabeled EXIT is only legal inside a loop +create function exit_error1() returns void as $$ +begin + begin + exit; + end; +end; +$$ language plpgsql +-- +-- should fail: unlabeled EXIT is only legal inside a loop +create function exit_error1() returns void as $1 language plpgsql +== 014 +-- should fail: no such label +create function continue_error2() returns void as $$ +begin + begin + loop + continue no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +-- should fail: no such label +create function continue_error2() returns void as $1 language plpgsql +== 015 +-- should fail: no such label +create function exit_error2() returns void as $$ +begin + begin + loop + exit no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +-- should fail: no such label +create function exit_error2() returns void as $1 language plpgsql +== 016 +-- should fail: CONTINUE can't reference the label of a named block +create function continue_error3() returns void as $$ +begin + <> + begin + loop + continue begin_block1; + end loop; + end; +end; +$$ language plpgsql +-- +-- should fail: CONTINUE can't reference the label of a named block +create function continue_error3() returns void as $1 language plpgsql +== 017 +-- On the other hand, EXIT *can* reference the label of a named block +create function exit_block1() returns void as $$ +begin + <> + begin + loop + exit begin_block1; + raise exception 'should not get here'; + end loop; + end; +end; +$$ language plpgsql +-- +-- On the other hand, EXIT *can* reference the label of a named block +create function exit_block1() returns void as $1 language plpgsql +== 018 +select exit_block1() +-- +select exit_block1() +== 019 +-- verbose end block and end loop +create function end_label1() returns void as $$ +<> +begin + <> + for i in 1 .. 10 loop + raise notice 'i = %', i; + exit flbl1; + end loop flbl1; + <> + for j in 1 .. 10 loop + raise notice 'j = %', j; + exit flbl2; + end loop; +end blbl; +$$ language plpgsql +-- +-- verbose end block and end loop +create function end_label1() returns void as $1 language plpgsql +== 020 +select end_label1() +-- +select end_label1() +== 021 +-- should fail: undefined end label +create function end_label2() returns void as $$ +begin + for _i in 1 .. 10 loop + exit; + end loop flbl1; +end; +$$ language plpgsql +-- +-- should fail: undefined end label +create function end_label2() returns void as $1 language plpgsql +== 022 +-- should fail: end label does not match start label +create function end_label3() returns void as $$ +<> +begin + <> + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +-- should fail: end label does not match start label +create function end_label3() returns void as $1 language plpgsql +== 023 +-- should fail: end label on a block without a start label +create function end_label4() returns void as $$ +<> +begin + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +-- should fail: end label on a block without a start label +create function end_label4() returns void as $1 language plpgsql +== 024 +-- unlabeled exit matches no blocks +do $$ +begin +for i in 1..10 loop + <> + begin + begin -- unlabeled block + exit; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; +end loop; +raise notice 'should get here'; +end$$ +-- +-- unlabeled exit matches no blocks +do $1 +== 025 +-- check exit out of an unlabeled block to a labeled one +do $$ +<> +begin + <> + begin + <> + begin + begin -- unlabeled block + exit innerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; + end; + raise notice 'should get here'; +end$$ +-- +-- check exit out of an unlabeled block to a labeled one +do $1 +== 026 +-- check exit out of outermost block +do $$ +<> +begin + <> + begin + exit outerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; +end$$ +-- +-- check exit out of outermost block +do $1 +== 027 +-- unlabeled exit does match a while loop +do $$ +begin + <> + while 1 > 0 loop + <> + while 1 > 0 loop + <> + while 1 > 0 loop + exit; + raise notice 'should not get here'; + end loop; + raise notice 'should get here'; + exit outermostwhile; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'should get here, too'; +end$$ +-- +-- unlabeled exit does match a while loop +do $1 +== 028 +-- check exit out of an unlabeled while to a labeled one +do $$ +begin + <> + while 1 > 0 loop + while 1 > 0 loop + exit outerwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'should get here'; +end$$ +-- +-- check exit out of an unlabeled while to a labeled one +do $1 +== 029 +-- continue to an outer while +do $$ +declare i int := 0; +begin + <> + while i < 2 loop + raise notice 'outermostwhile, i = %', i; + i := i + 1; + <> + while 1 > 0 loop + <> + while 1 > 0 loop + continue outermostwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'out of outermostwhile, i = %', i; +end$$ +-- +-- continue to an outer while +do $1 +== 030 +-- return out of a while +create function return_from_while() returns int language plpgsql as $$ +declare i int := 0; +begin + while i < 10 loop + if i > 2 then + return i; + end if; + i := i + 1; + end loop; + return null; +end$$ +-- +-- return out of a while +create function return_from_while() returns int language plpgsql as $1 +== 031 +select return_from_while() +-- +select return_from_while() +== 032 +-- using list of scalars in fori and fore stmts +create function for_vect() returns void as $proc$ +<>declare a integer; b varchar; c varchar; r record; +begin + -- fori + for i in 1 .. 3 loop + raise notice '%', i; + end loop; + -- fore with record var + for r in select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs loop + raise notice '% % %', r.aa, r.bb, r.cc; + end loop; + -- fore with single scalar + for a in select gs from generate_series(1,4) gs loop + raise notice '%', a; + end loop; + -- fore with multiple scalars + for a,b,c in select gs, 'BB','CC' from generate_series(1,4) gs loop + raise notice '% % %', a, b, c; + end loop; + -- using qualified names in fors, fore is enabled, disabled only for fori + for lbl.a, lbl.b, lbl.c in execute $$select gs, 'bb','cc' from generate_series(1,4) gs$$ loop + raise notice '% % %', a, b, c; + end loop; +end; +$proc$ language plpgsql +-- +-- using list of scalars in fori and fore stmts +create function for_vect() returns void as $1 language plpgsql +== 033 +select for_vect() +-- +select for_vect() +== 034 +-- CASE statement + +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; + b int = 1; +begin + case $1 + when 1 then + return 'one'; + when 2 then + return 'two'; + when 3,4,3+5 then + return 'three, four or eight'; + when a then + return 'ten'; + when a+b, a+b+1 then + return 'eleven, twelve'; + end case; +end; +$$ language plpgsql immutable +-- +-- CASE statement + +create or replace function case_test(bigint) returns text as $1 language plpgsql immutable +== 035 +select case_test(1) +-- +select case_test($1) +== 036 +select case_test(2) +-- +select case_test($1) +== 037 +select case_test(3) +-- +select case_test($1) +== 038 +select case_test(4) +-- +select case_test($1) +== 039 +select case_test(5) +-- +select case_test($1) +== 040 +-- fails +select case_test(8) +-- +-- fails +select case_test($1) +== 041 +select case_test(10) +-- +select case_test($1) +== 042 +select case_test(11) +-- +select case_test($1) +== 043 +select case_test(12) +-- +select case_test($1) +== 044 +select case_test(13) +-- +select case_test($1) +== 045 +-- fails + +create or replace function catch() returns void as $$ +begin + raise notice '%', case_test(6); +exception + when case_not_found then + raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM; +end +$$ language plpgsql +-- +-- fails + +create or replace function catch() returns void as $1 language plpgsql +== 046 +select catch() +-- +select catch() +== 047 +-- test the searched variant too, as well as ELSE +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; +begin + case + when $1 = 1 then + return 'one'; + when $1 = a + 2 then + return 'twelve'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +-- test the searched variant too, as well as ELSE +create or replace function case_test(bigint) returns text as $1 language plpgsql immutable +== 048 +select case_test(1) +-- +select case_test($1) +== 049 +select case_test(2) +-- +select case_test($1) +== 050 +select case_test(12) +-- +select case_test($1) +== 051 +select case_test(13) +-- +select case_test($1) +== 052 +-- test line comment between WHEN and THEN +create or replace function case_comment(int) returns text as $$ +begin + case $1 + when 1 -- comment before THEN + then return 'one'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +-- test line comment between WHEN and THEN +create or replace function case_comment(int) returns text as $1 language plpgsql immutable +== 053 +select case_comment(1) +-- +select case_comment($1) diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_copy.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_copy.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_copy.test new file mode 100644 index 0000000..2788c56 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_copy.test @@ -0,0 +1,21 @@ +== 001 +-- directory paths are passed to us in environment variables + +-- set up file names to use + +CREATE TABLE copy1 (a int, b float); + +-- COPY TO/FROM not authorized from client. +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 TO stdout; +END; +$$; +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 FROM stdin; +-- +ERROR: "unterminated dollar-quoted string at or near \"$$\nBEGIN\n COPY copy1 FROM stdin;\"" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_domain.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_domain.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_domain.test new file mode 100644 index 0000000..ec6ada2 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_domain.test @@ -0,0 +1,533 @@ +== 001 +|-- +-- Tests for PL/pgSQL's behavior with domain types +|-- + +CREATE DOMAIN booltrue AS bool CHECK (VALUE IS TRUE OR VALUE IS NULL) +-- +|-- +-- Tests for PL/pgSQL's behavior with domain types +|-- + +CREATE DOMAIN booltrue AS bool CHECK (VALUE IS TRUE OR VALUE IS NULL) +== 002 +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $1 LANGUAGE plpgsql +== 003 +SELECT * FROM test_argresult_booltrue(true, true) +-- +SELECT * FROM test_argresult_booltrue($1, $2) +== 004 +SELECT * FROM test_argresult_booltrue(false, true) +-- +SELECT * FROM test_argresult_booltrue($1, $2) +== 005 +SELECT * FROM test_argresult_booltrue(true, false) +-- +SELECT * FROM test_argresult_booltrue($1, $2) +== 006 +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $$ +declare v booltrue := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $1 LANGUAGE plpgsql +== 007 +SELECT * FROM test_assign_booltrue(true, true) +-- +SELECT * FROM test_assign_booltrue($1, $2) +== 008 +SELECT * FROM test_assign_booltrue(false, true) +-- +SELECT * FROM test_assign_booltrue($1, $2) +== 009 +SELECT * FROM test_assign_booltrue(true, false) +-- +SELECT * FROM test_assign_booltrue($1, $2) +== 010 +CREATE DOMAIN uint2 AS int2 CHECK (VALUE >= 0) +-- +CREATE DOMAIN uint2 AS int2 CHECK (VALUE >= 0) +== 011 +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $1 LANGUAGE plpgsql +== 012 +SELECT * FROM test_argresult_uint2(100::uint2, 50) +-- +SELECT * FROM test_argresult_uint2($1::uint2, $2) +== 013 +SELECT * FROM test_argresult_uint2(100::uint2, -50) +-- +SELECT * FROM test_argresult_uint2($1::uint2, $2) +== 014 +SELECT * FROM test_argresult_uint2(null, 1) +-- +SELECT * FROM test_argresult_uint2($1, $2) +== 015 +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $$ +declare v uint2 := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $1 LANGUAGE plpgsql +== 016 +SELECT * FROM test_assign_uint2(100, 50) +-- +SELECT * FROM test_assign_uint2($1, $2) +== 017 +SELECT * FROM test_assign_uint2(100, -50) +-- +SELECT * FROM test_assign_uint2($1, $2) +== 018 +SELECT * FROM test_assign_uint2(-100, 50) +-- +SELECT * FROM test_assign_uint2($1, $2) +== 019 +SELECT * FROM test_assign_uint2(null, 1) +-- +SELECT * FROM test_assign_uint2($1, $2) +== 020 +CREATE DOMAIN nnint AS int NOT NULL +-- +CREATE DOMAIN nnint AS int NOT NULL +== 021 +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $1 LANGUAGE plpgsql +== 022 +SELECT * FROM test_argresult_nnint(10, 20) +-- +SELECT * FROM test_argresult_nnint($1, $2) +== 023 +SELECT * FROM test_argresult_nnint(null, 20) +-- +SELECT * FROM test_argresult_nnint($1, $2) +== 024 +SELECT * FROM test_argresult_nnint(10, null) +-- +SELECT * FROM test_argresult_nnint($1, $2) +== 025 +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $$ +declare v nnint := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $1 LANGUAGE plpgsql +== 026 +SELECT * FROM test_assign_nnint(10, 20) +-- +SELECT * FROM test_assign_nnint($1, $2) +== 027 +SELECT * FROM test_assign_nnint(null, 20) +-- +SELECT * FROM test_assign_nnint($1, $2) +== 028 +SELECT * FROM test_assign_nnint(10, null) +-- +SELECT * FROM test_assign_nnint($1, $2) +== 029 +|-- +-- Domains over arrays +|-- + +CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]) +-- +|-- +-- Domains over arrays +|-- + +CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]) +== 030 +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) + RETURNS ordered_pair_domain AS $$ +begin +return x; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) + RETURNS ordered_pair_domain AS $1 LANGUAGE plpgsql +== 031 +SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain) +-- +SELECT * FROM test_argresult_array_domain(ARRAY[$1, $2]::ordered_pair_domain) +== 032 +SELECT * FROM test_argresult_array_domain(NULL::ordered_pair_domain) +-- +SELECT * FROM test_argresult_array_domain($1::ordered_pair_domain) +== 033 +CREATE FUNCTION test_argresult_array_domain_check_violation() + RETURNS ordered_pair_domain AS $$ +begin +return array[2,1]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_argresult_array_domain_check_violation() + RETURNS ordered_pair_domain AS $1 LANGUAGE plpgsql +== 034 +SELECT * FROM test_argresult_array_domain_check_violation() +-- +SELECT * FROM test_argresult_array_domain_check_violation() +== 035 +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $$ +declare v ordered_pair_domain := array[x, y]; +begin +v[2] := z; +return v; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $1 LANGUAGE plpgsql +== 036 +SELECT * FROM test_assign_ordered_pair_domain(1,2,3) +-- +SELECT * FROM test_assign_ordered_pair_domain($1,$2,$3) +== 037 +SELECT * FROM test_assign_ordered_pair_domain(1,2,0) +-- +SELECT * FROM test_assign_ordered_pair_domain($1,$2,$3) +== 038 +SELECT * FROM test_assign_ordered_pair_domain(2,1,3) +-- +SELECT * FROM test_assign_ordered_pair_domain($1,$2,$3) +== 039 +|-- +-- Arrays of domains +|-- + +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +|-- +-- Arrays of domains +|-- + +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $1 LANGUAGE plpgsql +== 040 +select test_read_uint2_array(array[1::uint2]) +-- +select test_read_uint2_array(array[$1::uint2]) +== 041 +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $$ +begin +return array[x, x]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $1 LANGUAGE plpgsql +== 042 +select test_build_uint2_array(1::int2) +-- +select test_build_uint2_array($1::int2) +== 043 +select test_build_uint2_array(-1::int2) +-- +select test_build_uint2_array(-$1::int2) +== 044 +-- fail + +CREATE FUNCTION test_argresult_domain_array(x integer[]) + RETURNS ordered_pair_domain[] AS $$ +begin +return array[x::ordered_pair_domain, x::ordered_pair_domain]; +end +$$ LANGUAGE plpgsql +-- +-- fail + +CREATE FUNCTION test_argresult_domain_array(x integer[]) + RETURNS ordered_pair_domain[] AS $1 LANGUAGE plpgsql +== 045 +select test_argresult_domain_array(array[2,4]) +-- +select test_argresult_domain_array(array[$1,$2]) +== 046 +select test_argresult_domain_array(array[4,2]) +-- +select test_argresult_domain_array(array[$1,$2]) +== 047 +-- fail + +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) + RETURNS integer AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +-- fail + +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) + RETURNS integer AS $1 LANGUAGE plpgsql +== 048 +select test_argresult_domain_array2(array[2,4]) +-- +select test_argresult_domain_array2(array[$1,$2]) +== 049 +select test_argresult_domain_array2(array[4,2]) +-- +select test_argresult_domain_array2(array[$1,$2]) +== 050 +-- fail + +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) + RETURNS ordered_pair_domain AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +-- fail + +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) + RETURNS ordered_pair_domain AS $1 LANGUAGE plpgsql +== 051 +select test_argresult_array_domain_array(array[array[2,4]::ordered_pair_domain]) +-- +select test_argresult_array_domain_array(array[array[$1,$2]::ordered_pair_domain]) +== 052 +|-- +-- Domains within composite +|-- + +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +-- +|-- +-- Domains within composite +|-- + +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +== 053 +CREATE FUNCTION test_result_nnint_container(x int, y int) + RETURNS nnint_container AS $$ +begin +return row(x, y)::nnint_container; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION test_result_nnint_container(x int, y int) + RETURNS nnint_container AS $1 LANGUAGE plpgsql +== 054 +SELECT test_result_nnint_container(null, 3) +-- +SELECT test_result_nnint_container($1, $2) +== 055 +SELECT test_result_nnint_container(3, null) +-- +SELECT test_result_nnint_container($1, $2) +== 056 +-- fail + +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container := row(x, y); +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +-- fail + +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) + RETURNS nnint_container AS $1 LANGUAGE plpgsql +== 057 +SELECT * FROM test_assign_nnint_container(1,2,3) +-- +SELECT * FROM test_assign_nnint_container($1,$2,$3) +== 058 +SELECT * FROM test_assign_nnint_container(1,2,null) +-- +SELECT * FROM test_assign_nnint_container($1,$2,$3) +== 059 +SELECT * FROM test_assign_nnint_container(1,null,3) +-- +SELECT * FROM test_assign_nnint_container($1,$2,$3) +== 060 +-- Since core system allows this: +SELECT null::nnint_container +-- +-- Since core system allows this: +SELECT $1::nnint_container +== 061 +-- so should PL/PgSQL + +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container; +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +-- so should PL/PgSQL + +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) + RETURNS nnint_container AS $1 LANGUAGE plpgsql +== 062 +SELECT * FROM test_assign_nnint_container2(1,2,3) +-- +SELECT * FROM test_assign_nnint_container2($1,$2,$3) +== 063 +SELECT * FROM test_assign_nnint_container2(1,2,null) +-- +SELECT * FROM test_assign_nnint_container2($1,$2,$3) +== 064 +|-- +-- Domains of composite +|-- + +CREATE TYPE named_pair AS ( + i integer, + j integer +) +-- +|-- +-- Domains of composite +|-- + +CREATE TYPE named_pair AS ( + i integer, + j integer +) +== 065 +CREATE DOMAIN ordered_named_pair AS named_pair CHECK((VALUE).i <= (VALUE).j) +-- +CREATE DOMAIN ordered_named_pair AS named_pair CHECK((VALUE).i <= (VALUE).j) +== 066 +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS integer AS $$ +begin +return p.i + p.j; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS integer AS $1 LANGUAGE plpgsql +== 067 +SELECT read_ordered_named_pair(row(1, 2)) +-- +SELECT read_ordered_named_pair(row($1, $2)) +== 068 +SELECT read_ordered_named_pair(row(2, 1)) +-- +SELECT read_ordered_named_pair(row($1, $2)) +== 069 +-- fail + +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $$ +begin +return row(i, j); +end +$$ LANGUAGE plpgsql +-- +-- fail + +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $1 LANGUAGE plpgsql +== 070 +SELECT build_ordered_named_pair(1,2) +-- +SELECT build_ordered_named_pair($1,$2) +== 071 +SELECT build_ordered_named_pair(2,1) +-- +SELECT build_ordered_named_pair($1,$2) +== 072 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) + RETURNS ordered_named_pair AS $$ +declare v ordered_named_pair := row(x, y); +begin +v.j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +-- fail + +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) + RETURNS ordered_named_pair AS $1 LANGUAGE plpgsql +== 073 +SELECT * FROM test_assign_ordered_named_pair(1,2,3) +-- +SELECT * FROM test_assign_ordered_named_pair($1,$2,$3) +== 074 +SELECT * FROM test_assign_ordered_named_pair(1,2,0) +-- +SELECT * FROM test_assign_ordered_named_pair($1,$2,$3) +== 075 +SELECT * FROM test_assign_ordered_named_pair(2,1,3) +-- +SELECT * FROM test_assign_ordered_named_pair($1,$2,$3) +== 076 +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $$ +begin +return array[row(i, j), row(i, j+1)]; +end +$$ LANGUAGE plpgsql +-- +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $1 LANGUAGE plpgsql +== 077 +SELECT build_ordered_named_pairs(1,2) +-- +SELECT build_ordered_named_pairs($1,$2) +== 078 +SELECT build_ordered_named_pairs(2,1) +-- +SELECT build_ordered_named_pairs($1,$2) +== 079 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) + RETURNS ordered_named_pair[] AS $$ +declare v ordered_named_pair[] := array[row(x, y)]; +begin +-- ideally this would work, but it doesn't yet: +-- v[1].j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +-- fail + +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) + RETURNS ordered_named_pair[] AS $1 LANGUAGE plpgsql +== 080 +SELECT * FROM test_assign_ordered_named_pairs(1,2,3) +-- +SELECT * FROM test_assign_ordered_named_pairs($1,$2,$3) +== 081 +SELECT * FROM test_assign_ordered_named_pairs(2,1,3) +-- +SELECT * FROM test_assign_ordered_named_pairs($1,$2,$3) +== 082 +SELECT * FROM test_assign_ordered_named_pairs(1,2,0) +-- +SELECT * FROM test_assign_ordered_named_pairs($1,$2,$3) diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_misc.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_misc.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_misc.test new file mode 100644 index 0000000..a34edeb --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_misc.test @@ -0,0 +1,86 @@ +== 001 +|-- +-- Miscellaneous topics +|-- + +-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE +do +$$ + declare procedure int; -- check we still recognize non-keywords as vars + begin + create function test1() returns int + begin atomic + select 2 + 2; + end; + create or replace procedure test2(x int) + begin atomic + select x + 2; + end; + end +$$ +-- +|-- +-- Miscellaneous topics +|-- + +-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE +do +$1 +== 002 +-- Test %TYPE and %ROWTYPE error cases +create table misc_table(f1 int) +-- +-- Test %TYPE and %ROWTYPE error cases +create table misc_table(f1 int) +== 003 +do $$ declare x foo%type; begin end $$ +-- +do $1 +== 004 +do $$ declare x notice%type; begin end $$ +-- +do $1 +== 005 +-- covers unreserved-keyword case +do $$ declare x foo.bar%type; begin end $$ +-- +-- covers unreserved-keyword case +do $1 +== 006 +do $$ declare x foo.bar.baz%type; begin end $$ +-- +do $1 +== 007 +do $$ declare x public.foo.bar%type; begin end $$ +-- +do $1 +== 008 +do $$ declare x public.misc_table.zed%type; begin end $$ +-- +do $1 +== 009 +do $$ declare x foo%rowtype; begin end $$ +-- +do $1 +== 010 +do $$ declare x notice%rowtype; begin end $$ +-- +do $1 +== 011 +-- covers unreserved-keyword case +do $$ declare x foo.bar%rowtype; begin end $$ +-- +-- covers unreserved-keyword case +do $1 +== 012 +do $$ declare x foo.bar.baz%rowtype; begin end $$ +-- +do $1 +== 013 +do $$ declare x public.foo%rowtype; begin end $$ +-- +do $1 +== 014 +do $$ declare x public.misc_table%rowtype; begin end $$ +-- +do $1 diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_record.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_record.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_record.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_record.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_record.test new file mode 100644 index 0000000..f7c8eba --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_record.test @@ -0,0 +1,1113 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of composite (record) variables +|-- + +create type two_int4s as (f1 int4, f2 int4) +-- +|-- +-- Tests for PL/pgSQL handling of composite (record) variables +|-- + +create type two_int4s as (f1 int4, f2 int4) +== 002 +create type more_int4s as (f0 text, f1 int4, f2 int4) +-- +create type more_int4s as (f0 text, f1 int4, f2 int4) +== 003 +create type two_int8s as (q1 int8, q2 int8) +-- +create type two_int8s as (q1 int8, q2 int8) +== 004 +create type nested_int8s as (c1 two_int8s, c2 two_int8s) +-- +create type nested_int8s as (c1 two_int8s, c2 two_int8s) +== 005 +-- base-case return of a composite type +create function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1)::two_int8s; end $$ +-- +-- base-case return of a composite type +create function retc(int) returns two_int8s language plpgsql as +$1 +== 006 +select retc(42) +-- +select retc($1) +== 007 +-- ok to return a matching record type +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8); end $$ +-- +-- ok to return a matching record type +create or replace function retc(int) returns two_int8s language plpgsql as +$1 +== 008 +select retc(42) +-- +select retc($1) +== 009 +-- we don't currently support implicit casting +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1); end $$ +-- +-- we don't currently support implicit casting +create or replace function retc(int) returns two_int8s language plpgsql as +$1 +== 010 +select retc(42) +-- +select retc($1) +== 011 +-- nor extra columns +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8, 42); end $$ +-- +-- nor extra columns +create or replace function retc(int) returns two_int8s language plpgsql as +$1 +== 012 +select retc(42) +-- +select retc($1) +== 013 +-- same cases with an intermediate "record" variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8); return r; end $$ +-- +-- same cases with an intermediate "record" variable +create or replace function retc(int) returns two_int8s language plpgsql as +$1 +== 014 +select retc(42) +-- +select retc($1) +== 015 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,1); return r; end $$ +-- +create or replace function retc(int) returns two_int8s language plpgsql as +$1 +== 016 +select retc(42) +-- +select retc($1) +== 017 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +create or replace function retc(int) returns two_int8s language plpgsql as +$1 +== 018 +select retc(42) +-- +select retc($1) +== 019 +-- but, for mostly historical reasons, we do convert when assigning +-- to a named-composite-type variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +-- but, for mostly historical reasons, we do convert when assigning +-- to a named-composite-type variable +create or replace function retc(int) returns two_int8s language plpgsql as +$1 +== 020 +select retc(42) +-- +select retc($1) +== 021 +do $$ declare c two_int8s; +begin c := row(1,2); raise notice 'c = %', c; end$$ +-- +do $1 +== 022 +do $$ declare c two_int8s; +begin for c in select 1,2 loop raise notice 'c = %', c; end loop; end$$ +-- +do $1 +== 023 +do $$ declare c4 two_int4s; c8 two_int8s; +begin + c8 := row(1,2); + c4 := c8; + c8 := c4; + raise notice 'c4 = %', c4; + raise notice 'c8 = %', c8; +end$$ +-- +do $1 +== 024 +do $$ declare c two_int8s; d nested_int8s; +begin + c := row(1,2); + d := row(c, row(c.q1, c.q2+1)); + raise notice 'c = %, d = %', c, d; + c.q1 := 10; + d.c1 := row(11,12); + d.c2.q2 := 42; + raise notice 'c = %, d = %', c, d; + raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2; + raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens + raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens +end$$ +-- +do $1 +== 025 +-- block-qualified naming +do $$ <> declare c two_int8s; d nested_int8s; +begin + b.c := row(1,2); + b.d := row(b.c, row(b.c.q1, b.c.q2+1)); + raise notice 'b.c = %, b.d = %', b.c, b.d; + b.c.q1 := 10; + b.d.c1 := row(11,12); + b.d.c2.q2 := 42; + raise notice 'b.c = %, b.d = %', b.c, b.d; + raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2; + raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens + raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens +end$$ +-- +-- block-qualified naming +do $1 +== 026 +-- error cases +do $$ declare c two_int8s; begin c.x = 1; end $$ +-- +-- error cases +do $1 +== 027 +do $$ declare c nested_int8s; begin c.x = 1; end $$ +-- +do $1 +== 028 +do $$ declare c nested_int8s; begin c.x.q1 = 1; end $$ +-- +do $1 +== 029 +do $$ declare c nested_int8s; begin c.c2.x = 1; end $$ +-- +do $1 +== 030 +do $$ declare c nested_int8s; begin d.c2.x = 1; end $$ +-- +do $1 +== 031 +do $$ <> declare c two_int8s; begin b.c.x = 1; end $$ +-- +do $1 +== 032 +do $$ <> declare c nested_int8s; begin b.c.x = 1; end $$ +-- +do $1 +== 033 +do $$ <> declare c nested_int8s; begin b.c.x.q1 = 1; end $$ +-- +do $1 +== 034 +do $$ <> declare c nested_int8s; begin b.c.c2.x = 1; end $$ +-- +do $1 +== 035 +do $$ <> declare c nested_int8s; begin b.d.c2.x = 1; end $$ +-- +do $1 +== 036 +-- check passing composite result to another function +create function getq1(two_int8s) returns int8 language plpgsql as $$ +declare r two_int8s; begin r := $1; return r.q1; end $$ +-- +-- check passing composite result to another function +create function getq1(two_int8s) returns int8 language plpgsql as $1 +== 037 +select getq1(retc(344)) +-- +select getq1(retc($1)) +== 038 +select getq1(row(1,2)) +-- +select getq1(row($1,$2)) +== 039 +do $$ +declare r1 two_int8s; r2 record; x int8; +begin + r1 := retc(345); + perform getq1(r1); + x := getq1(r1); + raise notice 'x = %', x; + r2 := retc(346); + perform getq1(r2); + x := getq1(r2); + raise notice 'x = %', x; +end$$ +-- +do $1 +== 040 +-- check assignments of composites +do $$ +declare r1 two_int8s; r2 two_int8s; r3 record; r4 record; +begin + r1 := row(1,2); + raise notice 'r1 = %', r1; + r1 := r1; -- shouldn't do anything + raise notice 'r1 = %', r1; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := null; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := row(7,11)::two_int8s; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r3 := row(1,2); + r4 := r3; + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r1 := r3; + raise notice 'r1 = %', r1; + r4 := r1; + raise notice 'r4 = %', r4; + r4.q2 := r4.q2 + 1; -- r4's field names have changed + raise notice 'r4 = %', r4; +end$$ +-- +-- check assignments of composites +do $1 +== 041 +-- fields of named-type vars read as null if uninitialized +do $$ +declare r1 two_int8s; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; +end$$ +-- +-- fields of named-type vars read as null if uninitialized +do $1 +== 042 +do $$ +declare r1 two_int8s; +begin + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +do $1 +== 043 +-- records, not so much +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; +end$$ +-- +-- records, not so much +do $1 +== 044 +-- but OK if you assign first +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + r1 := row(1,2); + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +-- but OK if you assign first +do $1 +== 045 +-- check %type with block-qualified variable names +do $$ +<> +declare + v int; + r two_int8s; + v1 v%type; + v2 blk.v%type; + r1 r%type; + r2 blk.r%type; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(r1); + raise notice '%', pg_typeof(r2); +end$$ +-- +-- check %type with block-qualified variable names +do $1 +== 046 +-- check that type record can be passed through %type +do $$ +declare r1 record; + r2 r1%type; +begin + r2 := row(1,2); + raise notice 'r2 = %', r2; + r2 := row(3,4,5); + raise notice 'r2 = %', r2; +end$$ +-- +-- check that type record can be passed through %type +do $1 +== 047 +-- arrays of record are not supported at the moment +do $$ +declare r1 record[]; +begin +end$$ +-- +-- arrays of record are not supported at the moment +do $1 +== 048 +do $$ +declare r1 record; + r2 r1%type[]; +begin +end$$ +-- +do $1 +== 049 +-- check repeated assignments to composite fields +create table some_table (id int, data text) +-- +-- check repeated assignments to composite fields +create table some_table (id int, data text) +== 050 +do $$ +declare r some_table; +begin + r := (23, 'skidoo'); + for i in 1 .. 10 loop + r.id := r.id + i; + r.data := r.data || ' ' || i; + end loop; + raise notice 'r = %', r; +end$$ +-- +do $1 +== 051 +-- check behavior of function declared to return "record" + +create function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1); end $$ +-- +-- check behavior of function declared to return "record" + +create function returnsrecord(int) returns record language plpgsql as +$1 +== 052 +select returnsrecord(42) +-- +select returnsrecord($1) +== 053 +select * from returnsrecord(42) as r(x int, y int) +-- +select * from returnsrecord($1) as r(x int, y int) +== 054 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +select * from returnsrecord($1) as r(x int, y int, z int) +== 055 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +-- fail +select * from returnsrecord($1) as r(x int, y bigint) +== 056 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1); return r; end $$ +-- +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$1 +== 057 +select returnsrecord(42) +-- +select returnsrecord($1) +== 058 +select * from returnsrecord(42) as r(x int, y int) +-- +select * from returnsrecord($1) as r(x int, y int) +== 059 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +select * from returnsrecord($1) as r(x int, y int, z int) +== 060 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +-- fail +select * from returnsrecord($1) as r(x int, y bigint) +== 061 +-- fail + +-- should work the same with a missing column in the actual result value +create table has_hole(f1 int, f2 int, f3 int) +-- +-- fail + +-- should work the same with a missing column in the actual result value +create table has_hole(f1 int, f2 int, f3 int) +== 062 +alter table has_hole drop column f2 +-- +alter table has_hole drop column f2 +== 063 +create or replace function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1)::has_hole; end $$ +-- +create or replace function returnsrecord(int) returns record language plpgsql as +$1 +== 064 +select returnsrecord(42) +-- +select returnsrecord($1) +== 065 +select * from returnsrecord(42) as r(x int, y int) +-- +select * from returnsrecord($1) as r(x int, y int) +== 066 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +select * from returnsrecord($1) as r(x int, y int, z int) +== 067 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +-- fail +select * from returnsrecord($1) as r(x int, y bigint) +== 068 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1)::has_hole; return r; end $$ +-- +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$1 +== 069 +select returnsrecord(42) +-- +select returnsrecord($1) +== 070 +select * from returnsrecord(42) as r(x int, y int) +-- +select * from returnsrecord($1) as r(x int, y int) +== 071 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +select * from returnsrecord($1) as r(x int, y int, z int) +== 072 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +-- fail +select * from returnsrecord($1) as r(x int, y bigint) +== 073 +-- fail + +-- check access to a field of an argument declared "record" +create function getf1(x record) returns int language plpgsql as +$$ begin return x.f1; end $$ +-- +-- fail + +-- check access to a field of an argument declared "record" +create function getf1(x record) returns int language plpgsql as +$1 +== 074 +select getf1(1) +-- +select getf1($1) +== 075 +select getf1(row(1,2)) +-- +select getf1(row($1,$2)) +== 076 +select getf1(row(1,2)::two_int4s) +-- +select getf1(row($1,$2)::two_int4s) +== 077 +select getf1(row('foo',123,456)::more_int4s) +-- +select getf1(row($1,$2,$3)::more_int4s) +== 078 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf1(row(1,2)::two_int8s) +-- +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf1(row($1,$2)::two_int8s) +== 079 +select getf1(row(1,2)) +-- +select getf1(row($1,$2)) +== 080 +-- this seemingly-equivalent case behaves a bit differently, +-- because the core parser's handling of $N symbols is simplistic +create function getf2(record) returns int language plpgsql as +$$ begin return $1.f2; end $$ +-- +-- this seemingly-equivalent case behaves a bit differently, +-- because the core parser's handling of $N symbols is simplistic +create function getf2(record) returns int language plpgsql as +$1 +== 081 +select getf2(row(1,2)) +-- +select getf2(row($1,$2)) +== 082 +-- ideally would work, but does not +select getf2(row(1,2)::two_int4s) +-- +-- ideally would work, but does not +select getf2(row($1,$2)::two_int4s) +== 083 +select getf2(row('foo',123,456)::more_int4s) +-- +select getf2(row($1,$2,$3)::more_int4s) +== 084 +-- check behavior when assignment to FOR-loop variable requires coercion +do $$ +declare r two_int8s; +begin + for r in select i, i+1 from generate_series(1,4) i + loop + raise notice 'r = %', r; + end loop; +end$$ +-- +-- check behavior when assignment to FOR-loop variable requires coercion +do $1 +== 085 +-- check behavior when returning setof composite +create function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; + h has_hole; +begin + return next h; + r := (1,2); + h := (3,4); + return next r; + return next h; + return next row(5,6); + return next row(7,8)::has_hole; +end$$ +-- +-- check behavior when returning setof composite +create function returnssetofholes() returns setof has_hole language plpgsql as +$1 +== 086 +select returnssetofholes() +-- +select returnssetofholes() +== 087 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; +begin + return next r; -- fails, not assigned yet +end$$ +-- +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$1 +== 088 +select returnssetofholes() +-- +select returnssetofholes() +== 089 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +begin + return next row(1,2,3); -- fails +end$$ +-- +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$1 +== 090 +select returnssetofholes() +-- +select returnssetofholes() +== 091 +-- check behavior with changes of a named rowtype +create table mutable(f1 int, f2 text) +-- +-- check behavior with changes of a named rowtype +create table mutable(f1 int, f2 text) +== 092 +create function sillyaddone(int) returns int language plpgsql as +$$ declare r mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +create function sillyaddone(int) returns int language plpgsql as +$1 +== 093 +select sillyaddone(42) +-- +select sillyaddone($1) +== 094 +-- test for change of type of column f1 should be here someday; +-- for now see plpgsql_cache test + +alter table mutable drop column f1 +-- +-- test for change of type of column f1 should be here someday; +-- for now see plpgsql_cache test + +alter table mutable drop column f1 +== 095 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddone(42) +-- +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddone($1) +== 096 +-- fail + +create function getf3(x mutable) returns int language plpgsql as +$$ begin return x.f3; end $$ +-- +-- fail + +create function getf3(x mutable) returns int language plpgsql as +$1 +== 097 +select getf3(null::mutable) +-- +select getf3($1::mutable) +== 098 +-- doesn't work yet +alter table mutable add column f3 int +-- +-- doesn't work yet +alter table mutable add column f3 int +== 099 +select getf3(null::mutable) +-- +select getf3($1::mutable) +== 100 +-- now it works +alter table mutable drop column f3 +-- +-- now it works +alter table mutable drop column f3 +== 101 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf3(null::mutable) +-- +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf3($1::mutable) +== 102 +-- fails again + +-- check behavior with creating/dropping a named rowtype +set check_function_bodies = off +-- +-- fails again + +-- check behavior with creating/dropping a named rowtype +set check_function_bodies = $1 +== 103 +-- else reference to nonexistent type fails + +create function sillyaddtwo(int) returns int language plpgsql as +$$ declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end $$ +-- +-- else reference to nonexistent type fails + +create function sillyaddtwo(int) returns int language plpgsql as +$1 +== 104 +reset check_function_bodies +-- +reset check_function_bodies +== 105 +select sillyaddtwo(42) +-- +select sillyaddtwo($1) +== 106 +-- fail +create table mutable2(f1 int, f2 text) +-- +-- fail +create table mutable2(f1 int, f2 text) +== 107 +select sillyaddtwo(42) +-- +select sillyaddtwo($1) +== 108 +drop table mutable2 +-- +drop table mutable2 +== 109 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddtwo(42) +-- +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddtwo($1) +== 110 +-- fail +create table mutable2(f0 text, f1 int, f2 text) +-- +-- fail +create table mutable2(f0 text, f1 int, f2 text) +== 111 +select sillyaddtwo(42) +-- +select sillyaddtwo($1) +== 112 +select sillyaddtwo(43) +-- +select sillyaddtwo($1) +== 113 +-- check access to system columns in a record variable + +create function sillytrig() returns trigger language plpgsql as +$$begin + raise notice 'old.ctid = %', old.ctid; + raise notice 'old.tableoid = %', old.tableoid::regclass; + return new; +end$$ +-- +-- check access to system columns in a record variable + +create function sillytrig() returns trigger language plpgsql as +$1 +== 114 +create trigger mutable_trig before update on mutable for each row +execute procedure sillytrig() +-- +create trigger mutable_trig before update on mutable for each row +execute procedure sillytrig() +== 115 +insert into mutable values ('foo'), ('bar') +-- +insert into mutable values ($1), ($2) +== 116 +update mutable set f2 = f2 || ' baz' +-- +update mutable set f2 = f2 || $1 +== 117 +table mutable +-- +table mutable +== 118 +-- check returning a composite datum from a trigger + +create or replace function sillytrig() returns trigger language plpgsql as +$$begin + return row(new.*); +end$$ +-- +-- check returning a composite datum from a trigger + +create or replace function sillytrig() returns trigger language plpgsql as +$1 +== 119 +update mutable set f2 = f2 || ' baz' +-- +update mutable set f2 = f2 || $1 +== 120 +table mutable +-- +table mutable +== 121 +create or replace function sillytrig() returns trigger language plpgsql as +$$declare r record; +begin + r := row(new.*); + return r; +end$$ +-- +create or replace function sillytrig() returns trigger language plpgsql as +$1 +== 122 +update mutable set f2 = f2 || ' baz' +-- +update mutable set f2 = f2 || $1 +== 123 +table mutable +-- +table mutable +== 124 +|-- +-- Domains of composite +|-- + +create domain ordered_int8s as two_int8s check((value).q1 <= (value).q2) +-- +|-- +-- Domains of composite +|-- + +create domain ordered_int8s as two_int8s check((value).q1 <= (value).q2) +== 125 +create function read_ordered_int8s(p ordered_int8s) returns int8 as $$ +begin return p.q1 + p.q2; end +$$ language plpgsql +-- +create function read_ordered_int8s(p ordered_int8s) returns int8 as $1 language plpgsql +== 126 +select read_ordered_int8s(row(1, 2)) +-- +select read_ordered_int8s(row($1, $2)) +== 127 +select read_ordered_int8s(row(2, 1)) +-- +select read_ordered_int8s(row($1, $2)) +== 128 +-- fail + +create function build_ordered_int8s(i int8, j int8) returns ordered_int8s as $$ +begin return row(i,j); end +$$ language plpgsql +-- +-- fail + +create function build_ordered_int8s(i int8, j int8) returns ordered_int8s as $1 language plpgsql +== 129 +select build_ordered_int8s(1,2) +-- +select build_ordered_int8s($1,$2) +== 130 +select build_ordered_int8s(2,1) +-- +select build_ordered_int8s($1,$2) +== 131 +-- fail + +create function build_ordered_int8s_2(i int8, j int8) returns ordered_int8s as $$ +declare r record; begin r := row(i,j); return r; end +$$ language plpgsql +-- +-- fail + +create function build_ordered_int8s_2(i int8, j int8) returns ordered_int8s as $1 language plpgsql +== 132 +select build_ordered_int8s_2(1,2) +-- +select build_ordered_int8s_2($1,$2) +== 133 +select build_ordered_int8s_2(2,1) +-- +select build_ordered_int8s_2($1,$2) +== 134 +-- fail + +create function build_ordered_int8s_3(i int8, j int8) returns ordered_int8s as $$ +declare r two_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +-- fail + +create function build_ordered_int8s_3(i int8, j int8) returns ordered_int8s as $1 language plpgsql +== 135 +select build_ordered_int8s_3(1,2) +-- +select build_ordered_int8s_3($1,$2) +== 136 +select build_ordered_int8s_3(2,1) +-- +select build_ordered_int8s_3($1,$2) +== 137 +-- fail + +create function build_ordered_int8s_4(i int8, j int8) returns ordered_int8s as $$ +declare r ordered_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +-- fail + +create function build_ordered_int8s_4(i int8, j int8) returns ordered_int8s as $1 language plpgsql +== 138 +select build_ordered_int8s_4(1,2) +-- +select build_ordered_int8s_4($1,$2) +== 139 +select build_ordered_int8s_4(2,1) +-- +select build_ordered_int8s_4($1,$2) +== 140 +-- fail + +create function build_ordered_int8s_a(i int8, j int8) returns ordered_int8s[] as $$ +begin return array[row(i,j), row(i,j+1)]; end +$$ language plpgsql +-- +-- fail + +create function build_ordered_int8s_a(i int8, j int8) returns ordered_int8s[] as $1 language plpgsql +== 141 +select build_ordered_int8s_a(1,2) +-- +select build_ordered_int8s_a($1,$2) +== 142 +select build_ordered_int8s_a(2,1) +-- +select build_ordered_int8s_a($1,$2) +== 143 +-- fail + +-- check field assignment +do $$ +declare r ordered_int8s; +begin + r.q1 := null; + r.q2 := 43; + r.q1 := 42; + r.q2 := 41; -- fail +end$$ +-- +-- fail + +-- check field assignment +do $1 +== 144 +-- check whole-row assignment +do $$ +declare r ordered_int8s; +begin + r := null; + r := row(null,null); + r := row(1,2); + r := row(2,1); -- fail +end$$ +-- +-- check whole-row assignment +do $1 +== 145 +-- check assignment in for-loop +do $$ +declare r ordered_int8s; +begin + for r in values (1,2),(3,4),(6,5) loop + raise notice 'r = %', r; + end loop; +end$$ +-- +-- check assignment in for-loop +do $1 +== 146 +-- check behavior with toastable fields, too + +create type two_texts as (f1 text, f2 text) +-- +-- check behavior with toastable fields, too + +create type two_texts as (f1 text, f2 text) +== 147 +create domain ordered_texts as two_texts check((value).f1 <= (value).f2) +-- +create domain ordered_texts as two_texts check((value).f1 <= (value).f2) +== 148 +create table sometable (id int, a text, b text) +-- +create table sometable (id int, a text, b text) +== 149 +-- b should be compressed, but in-line +insert into sometable values (1, 'a', repeat('ffoob',1000)) +-- +-- b should be compressed, but in-line +insert into sometable values ($1, $2, repeat($3,$4)) +== 150 +-- this b should be out-of-line +insert into sometable values (2, 'a', repeat('ffoob',100000)) +-- +-- this b should be out-of-line +insert into sometable values ($1, $2, repeat($3,$4)) +== 151 +-- this pair should fail the domain check +insert into sometable values (3, 'z', repeat('ffoob',100000)) +-- +-- this pair should fail the domain check +insert into sometable values ($1, $2, repeat($3,$4)) +== 152 +do $$ +declare d ordered_texts; +begin + for d in select a, b from sometable loop + raise notice 'succeeded at "%"', d.f1; + end loop; +end$$ +-- +do $1 +== 153 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := row(r.a, r.b); + end loop; +end$$ +-- +do $1 +== 154 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := null; + d.f1 := r.a; + d.f2 := r.b; + end loop; +end$$ +-- +do $1 +== 155 +-- check coercion of a record result to named-composite function output type +create function compresult(int8) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,$1); return r; end $$ +-- +-- check coercion of a record result to named-composite function output type +create function compresult(int8) returns two_int8s language plpgsql as +$1 +== 156 +create table two_int8s_tab (f1 two_int8s) +-- +create table two_int8s_tab (f1 two_int8s) +== 157 +insert into two_int8s_tab values (compresult(42)) +-- +insert into two_int8s_tab values (compresult($1)) +== 158 +-- reconnect so we lose any local knowledge of anonymous record types +table two_int8s_tab +-- +-- reconnect so we lose any local knowledge of anonymous record types +table two_int8s_tab diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_simple.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_simple.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_simple.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_simple.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_simple.test new file mode 100644 index 0000000..2699b6c --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_simple.test @@ -0,0 +1,191 @@ +== 001 +|-- +-- Tests for plpgsql's handling of "simple" expressions +|-- + +-- Check that changes to an inline-able function are handled correctly +create function simplesql(int) returns int language sql +as 'select $1' +-- +|-- +-- Tests for plpgsql's handling of "simple" expressions +|-- + +-- Check that changes to an inline-able function are handled correctly +create function simplesql(int) returns int language sql +as $1 +== 002 +create function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simplesql(n); + if n = 5 then + create or replace function simplesql(int) returns int language sql + as 'select $1 + 100'; + end if; + end loop; + return sum; +end$$ +-- +create function simplecaller() returns int language plpgsql +as $1 +== 003 +select simplecaller() +-- +select simplecaller() +== 004 +-- Check that changes in search path are dealt with correctly +create schema simple1 +-- +-- Check that changes in search path are dealt with correctly +create schema simple1 +== 005 +create function simple1.simpletarget(int) returns int language plpgsql +as $$begin return $1; end$$ +-- +create function simple1.simpletarget(int) returns int language plpgsql +as $1 +== 006 +create function simpletarget(int) returns int language plpgsql +as $$begin return $1 + 100; end$$ +-- +create function simpletarget(int) returns int language plpgsql +as $1 +== 007 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simpletarget(n); + if n = 5 then + set local search_path = 'simple1'; + end if; + end loop; + return sum; +end$$ +-- +create or replace function simplecaller() returns int language plpgsql +as $1 +== 008 +select simplecaller() +-- +select simplecaller() +== 009 +-- try it with non-volatile functions, too +alter function simple1.simpletarget(int) immutable +-- +-- try it with non-volatile functions, too +alter function simple1.simpletarget(int) immutable +== 010 +alter function simpletarget(int) immutable +-- +alter function simpletarget(int) immutable +== 011 +select simplecaller() +-- +select simplecaller() +== 012 +-- make sure flushing local caches changes nothing + +select simplecaller() +-- +-- make sure flushing local caches changes nothing + +select simplecaller() +== 013 +-- Check case where first attempt to determine if it's simple fails + +create function simplesql() returns int language sql +as $$select 1 / 0$$ +-- +-- Check case where first attempt to determine if it's simple fails + +create function simplesql() returns int language sql +as $1 +== 014 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + select simplesql() into x; + return x; +end$$ +-- +create or replace function simplecaller() returns int language plpgsql +as $1 +== 015 +select simplecaller() +-- +select simplecaller() +== 016 +-- division by zero occurs during simple-expr check + +create or replace function simplesql() returns int language sql +as $$select 2 + 2$$ +-- +-- division by zero occurs during simple-expr check + +create or replace function simplesql() returns int language sql +as $1 +== 017 +select simplecaller() +-- +select simplecaller() +== 018 +-- Check case where called function changes from non-SRF to SRF (bug #18497) + +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + x := simplesql(); + return x; +end$$ +-- +-- Check case where called function changes from non-SRF to SRF (bug #18497) + +create or replace function simplecaller() returns int language plpgsql +as $1 +== 019 +select simplecaller() +-- +select simplecaller() +== 020 +drop function simplesql() +-- +drop function simplesql() +== 021 +create function simplesql() returns setof int language sql +as $$select 22 + 22$$ +-- +create function simplesql() returns setof int language sql +as $1 +== 022 +select simplecaller() +-- +select simplecaller() +== 023 +select simplecaller() +-- +select simplecaller() +== 024 +-- Check handling of simple expression in a scrollable cursor (bug #18859) + +do $$ +declare + p_CurData refcursor; + val int; +begin + open p_CurData scroll for select 42; + fetch p_CurData into val; + raise notice 'val = %', val; +end; $$ +-- +-- Check handling of simple expression in a scrollable cursor (bug #18859) + +do $1 diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_transaction.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_transaction.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_transaction.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_transaction.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_transaction.test new file mode 100644 index 0000000..9bc1ce6 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_transaction.test @@ -0,0 +1,928 @@ +== 001 +CREATE TABLE test1 (a int, b text) +-- +CREATE TABLE test1 (a int, b text) +== 002 +CREATE PROCEDURE transaction_test1(x int, y text) +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..x LOOP + INSERT INTO test1 (a, b) VALUES (i, y); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +CREATE PROCEDURE transaction_test1(x int, y text) +LANGUAGE plpgsql +AS $1 +== 003 +CALL transaction_test1(9, 'foo') +-- +CALL transaction_test1($1, $2) +== 004 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 005 +TRUNCATE test1 +-- +TRUNCATE test1 +== 006 +DO +LANGUAGE plpgsql +$$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +DO +LANGUAGE plpgsql +$1 +== 007 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 008 +-- transaction commands not allowed when called in transaction block +START TRANSACTION +-- +-- transaction commands not allowed when called in transaction block +START TRANSACTION +== 009 +CALL transaction_test1(9, 'error') +-- +CALL transaction_test1($1, $2) +== 010 +COMMIT +-- +COMMIT +== 011 +START TRANSACTION +-- +START TRANSACTION +== 012 +DO LANGUAGE plpgsql $$ BEGIN COMMIT; END $$ +-- +DO LANGUAGE plpgsql $1 +== 013 +COMMIT +-- +COMMIT +== 014 +TRUNCATE test1 +-- +TRUNCATE test1 +== 015 +-- not allowed in a function +CREATE FUNCTION transaction_test2() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; + RETURN 1; +END +$$ +-- +-- not allowed in a function +CREATE FUNCTION transaction_test2() RETURNS int +LANGUAGE plpgsql +AS $1 +== 016 +SELECT transaction_test2() +-- +SELECT transaction_test2() +== 017 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 018 +-- also not allowed if procedure is called from a function +CREATE FUNCTION transaction_test3() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, 'error'); + RETURN 1; +END; +$$ +-- +-- also not allowed if procedure is called from a function +CREATE FUNCTION transaction_test3() RETURNS int +LANGUAGE plpgsql +AS $1 +== 019 +SELECT transaction_test3() +-- +SELECT transaction_test3() +== 020 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 021 +-- DO block inside function +CREATE FUNCTION transaction_test4() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'; + RETURN 1; +END; +$$ +-- +-- DO block inside function +CREATE FUNCTION transaction_test4() RETURNS int +LANGUAGE plpgsql +AS $1 +== 022 +SELECT transaction_test4() +-- +SELECT transaction_test4() +== 023 +-- proconfig settings currently disallow transaction statements +CREATE PROCEDURE transaction_test5() +LANGUAGE plpgsql +SET work_mem = 555 +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +-- proconfig settings currently disallow transaction statements +CREATE PROCEDURE transaction_test5() +LANGUAGE plpgsql +SET work_mem = $2 +AS $1 +== 024 +CALL transaction_test5() +-- +CALL transaction_test5() +== 025 +-- SECURITY DEFINER currently disallow transaction statements +CREATE PROCEDURE transaction_test5b() +LANGUAGE plpgsql +SECURITY DEFINER +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +-- SECURITY DEFINER currently disallow transaction statements +CREATE PROCEDURE transaction_test5b() +LANGUAGE plpgsql +SECURITY DEFINER +AS $1 +== 026 +CALL transaction_test5b() +-- +CALL transaction_test5b() +== 027 +TRUNCATE test1 +-- +TRUNCATE test1 +== 028 +-- nested procedure calls +CREATE PROCEDURE transaction_test6(c text) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, c); +END; +$$ +-- +-- nested procedure calls +CREATE PROCEDURE transaction_test6(c text) +LANGUAGE plpgsql +AS $1 +== 029 +CALL transaction_test6('bar') +-- +CALL transaction_test6($1) +== 030 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 031 +TRUNCATE test1 +-- +TRUNCATE test1 +== 032 +CREATE PROCEDURE transaction_test7() +LANGUAGE plpgsql +AS $$ +BEGIN + DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'; +END; +$$ +-- +CREATE PROCEDURE transaction_test7() +LANGUAGE plpgsql +AS $1 +== 033 +CALL transaction_test7() +-- +CALL transaction_test7() +== 034 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 035 +CREATE PROCEDURE transaction_test8() +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'CALL transaction_test1(10, $x$baz$x$)'; +END; +$$ +-- +CREATE PROCEDURE transaction_test8() +LANGUAGE plpgsql +AS $1 +== 036 +CALL transaction_test8() +-- +CALL transaction_test8() +== 037 +-- commit inside cursor loop +CREATE TABLE test2 (x int) +-- +-- commit inside cursor loop +CREATE TABLE test2 (x int) +== 038 +INSERT INTO test2 VALUES (0), (1), (2), (3), (4) +-- +INSERT INTO test2 VALUES ($1), ($2), ($3), ($4), ($5) +== 039 +TRUNCATE test1 +-- +TRUNCATE test1 +== 040 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + COMMIT; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 041 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 042 +-- check that this doesn't leak a holdable portal +SELECT * FROM pg_cursors +-- +-- check that this doesn't leak a holdable portal +SELECT * FROM pg_cursors +== 043 +-- error in cursor loop with commit +TRUNCATE test1 +-- +-- error in cursor loop with commit +TRUNCATE test1 +== 044 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (12/(r.x-2)); + COMMIT; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 045 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 046 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 047 +-- rollback inside cursor loop +TRUNCATE test1 +-- +-- rollback inside cursor loop +TRUNCATE test1 +== 048 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 049 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 050 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 051 +-- first commit then rollback inside cursor loop +TRUNCATE test1 +-- +-- first commit then rollback inside cursor loop +TRUNCATE test1 +== 052 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + IF r.x % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 053 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 054 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 055 +-- rollback inside cursor loop +TRUNCATE test1 +-- +-- rollback inside cursor loop +TRUNCATE test1 +== 056 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 057 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 058 +SELECT * FROM test2 +-- +SELECT * FROM test2 +== 059 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 060 +-- interaction of FOR UPDATE cursor with subsequent updates (bug #17050) +TRUNCATE test1 +-- +-- interaction of FOR UPDATE cursor with subsequent updates (bug #17050) +TRUNCATE test1 +== 061 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +INSERT INTO test1 VALUES ($1,$2), ($3,$4), ($5,$6) +== 062 +DO LANGUAGE plpgsql $$ +DECLARE + l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE; +BEGIN + FOR r IN l_cur LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 063 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 064 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 065 +-- like bug #17050, but with implicit cursor +TRUNCATE test1 +-- +-- like bug #17050, but with implicit cursor +TRUNCATE test1 +== 066 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +INSERT INTO test1 VALUES ($1,$2), ($3,$4), ($5,$6) +== 067 +DO LANGUAGE plpgsql $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT a FROM test1 FOR UPDATE LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 068 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 069 +SELECT * FROM pg_cursors +-- +SELECT * FROM pg_cursors +== 070 +-- commit inside block with exception handler +TRUNCATE test1 +-- +-- commit inside block with exception handler +TRUNCATE test1 +== 071 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + COMMIT; + INSERT INTO test1 (a) VALUES (1/0); + COMMIT; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 072 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 073 +-- rollback inside block with exception handler +TRUNCATE test1 +-- +-- rollback inside block with exception handler +TRUNCATE test1 +== 074 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + ROLLBACK; + INSERT INTO test1 (a) VALUES (1/0); + ROLLBACK; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 075 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 076 +-- test commit/rollback inside exception handler, too +TRUNCATE test1 +-- +-- test commit/rollback inside exception handler, too +TRUNCATE test1 +== 077 +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 1..10 LOOP + BEGIN + INSERT INTO test1 VALUES (i, 'good'); + INSERT INTO test1 VALUES (i/0, 'bad'); + EXCEPTION + WHEN division_by_zero THEN + INSERT INTO test1 VALUES (i, 'exception'); + IF (i % 3) > 0 THEN COMMIT; ELSE ROLLBACK; END IF; + END; + END LOOP; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 078 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 079 +-- detoast result of simple expression after commit +CREATE TEMP TABLE test4(f1 text) +-- +-- detoast result of simple expression after commit +CREATE TEMP TABLE test4(f1 text) +== 080 +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE EXTERNAL +-- +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE EXTERNAL +== 081 +-- disable compression +INSERT INTO test4 SELECT repeat('xyzzy', 2000) +-- +-- disable compression +INSERT INTO test4 SELECT repeat($1, $2) +== 082 +-- immutable mark is a bit of a lie, but it serves to make call a simple expr +-- that will return a still-toasted value +CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql +AS 'select f1 from test4' IMMUTABLE +-- +-- immutable mark is a bit of a lie, but it serves to make call a simple expr +-- that will return a still-toasted value +CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql +AS $1 IMMUTABLE +== 083 +DO $$ +declare x text; +begin + for i in 1..3 loop + x := data_source(i); + commit; + end loop; + raise notice 'length(x) = %', length(x); +end $$ +-- +DO $1 +== 084 +-- operations on composite types vs. internal transactions +DO LANGUAGE plpgsql $$ +declare + c test1 := row(42, 'hello'); + r bool; +begin + for i in 1..3 loop + r := c is not null; + raise notice 'r = %', r; + commit; + end loop; + for i in 1..3 loop + r := c is null; + raise notice 'r = %', r; + rollback; + end loop; +end +$$ +-- +-- operations on composite types vs. internal transactions +DO LANGUAGE plpgsql $1 +== 085 +-- COMMIT failures +DO LANGUAGE plpgsql $$ +BEGIN + CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + INSERT INTO test3 (y) VALUES (2); + COMMIT; + INSERT INTO test3 (y) VALUES (3); -- won't get here +END; +$$ +-- +-- COMMIT failures +DO LANGUAGE plpgsql $1 +== 086 +SELECT * FROM test3 +-- +SELECT * FROM test3 +== 087 +-- failure while trying to persist a cursor across a transaction (bug #15703) +CREATE PROCEDURE cursor_fail_during_commit() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + COMMIT; + END LOOP; + END; +$$ +-- +-- failure while trying to persist a cursor across a transaction (bug #15703) +CREATE PROCEDURE cursor_fail_during_commit() + LANGUAGE plpgsql +AS $1 +== 088 +TRUNCATE test1 +-- +TRUNCATE test1 +== 089 +CALL cursor_fail_during_commit() +-- +CALL cursor_fail_during_commit() +== 090 +-- note that error occurs during first COMMIT, hence nothing is in test1 +SELECT count(*) FROM test1 +-- +-- note that error occurs during first COMMIT, hence nothing is in test1 +SELECT count(*) FROM test1 +== 091 +CREATE PROCEDURE cursor_fail_during_rollback() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + ROLLBACK; + END LOOP; + END; +$$ +-- +CREATE PROCEDURE cursor_fail_during_rollback() + LANGUAGE plpgsql +AS $1 +== 092 +TRUNCATE test1 +-- +TRUNCATE test1 +== 093 +CALL cursor_fail_during_rollback() +-- +CALL cursor_fail_during_rollback() +== 094 +SELECT count(*) FROM test1 +-- +SELECT count(*) FROM test1 +== 095 +-- SET TRANSACTION +DO LANGUAGE plpgsql $$ +BEGIN + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; +END; +$$ +-- +-- SET TRANSACTION +DO LANGUAGE plpgsql $1 +== 096 +-- error cases +DO LANGUAGE plpgsql $$ +BEGIN + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +END; +$$ +-- +-- error cases +DO LANGUAGE plpgsql $1 +== 097 +DO LANGUAGE plpgsql $$ +BEGIN + SAVEPOINT foo; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 098 +DO LANGUAGE plpgsql $$ +BEGIN + EXECUTE 'COMMIT'; +END; +$$ +-- +DO LANGUAGE plpgsql $1 +== 099 +-- snapshot handling test +TRUNCATE test2 +-- +-- snapshot handling test +TRUNCATE test2 +== 100 +CREATE PROCEDURE transaction_test9() +LANGUAGE SQL +AS $$ +INSERT INTO test2 VALUES (42); +$$ +-- +CREATE PROCEDURE transaction_test9() +LANGUAGE SQL +AS $1 +== 101 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + CALL transaction_test9(); +END +$$ +-- +DO LANGUAGE plpgsql $1 +== 102 +SELECT * FROM test2 +-- +SELECT * FROM test2 +== 103 +-- another snapshot handling case: argument expressions of a CALL need +-- to be evaluated with an up-to-date snapshot +CREATE FUNCTION report_count() RETURNS int +STABLE LANGUAGE sql +AS $$ SELECT COUNT(*) FROM test2 $$ +-- +-- another snapshot handling case: argument expressions of a CALL need +-- to be evaluated with an up-to-date snapshot +CREATE FUNCTION report_count() RETURNS int +STABLE LANGUAGE sql +AS $1 +== 104 +CREATE PROCEDURE transaction_test9b(cnt int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'count = %', cnt; +END +$$ +-- +CREATE PROCEDURE transaction_test9b(cnt int) +LANGUAGE plpgsql +AS $1 +== 105 +DO $$ +BEGIN + CALL transaction_test9b(report_count()); + INSERT INTO test2 VALUES(43); + CALL transaction_test9b(report_count()); +END +$$ +-- +DO $1 +== 106 +-- Test transaction in procedure with output parameters. This uses a +-- different portal strategy and different code paths in pquery.c. +CREATE PROCEDURE transaction_test10a(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x + 1; + COMMIT; +END; +$$ +-- +-- Test transaction in procedure with output parameters. This uses a +-- different portal strategy and different code paths in pquery.c. +CREATE PROCEDURE transaction_test10a(INOUT x int) +LANGUAGE plpgsql +AS $1 +== 107 +CALL transaction_test10a(10) +-- +CALL transaction_test10a($1) +== 108 +CREATE PROCEDURE transaction_test10b(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x - 1; + ROLLBACK; +END; +$$ +-- +CREATE PROCEDURE transaction_test10b(INOUT x int) +LANGUAGE plpgsql +AS $1 +== 109 +CALL transaction_test10b(10) +-- +CALL transaction_test10b($1) +== 110 +-- transaction timestamp vs. statement timestamp +CREATE PROCEDURE transaction_test11() +LANGUAGE plpgsql +AS $$ +DECLARE + s1 timestamp with time zone; + s2 timestamp with time zone; + s3 timestamp with time zone; + t1 timestamp with time zone; + t2 timestamp with time zone; + t3 timestamp with time zone; +BEGIN + s1 := statement_timestamp(); + t1 := transaction_timestamp(); + ASSERT s1 = t1; + PERFORM pg_sleep(0.001); + COMMIT; + s2 := statement_timestamp(); + t2 := transaction_timestamp(); + ASSERT s2 = s1; + ASSERT t2 > t1; + PERFORM pg_sleep(0.001); + ROLLBACK; + s3 := statement_timestamp(); + t3 := transaction_timestamp(); + ASSERT s3 = s1; + ASSERT t3 > t2; +END; +$$ +-- +-- transaction timestamp vs. statement timestamp +CREATE PROCEDURE transaction_test11() +LANGUAGE plpgsql +AS $1 +== 111 +CALL transaction_test11() +-- +CALL transaction_test11() +== 112 +-- transaction chain + +TRUNCATE test1 +-- +-- transaction chain + +TRUNCATE test1 +== 113 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + FOR i IN 0..3 LOOP + RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT AND CHAIN; + ELSE + ROLLBACK AND CHAIN; + END IF; + END LOOP; +END +$$ +-- +DO LANGUAGE plpgsql $1 +== 114 +SELECT * FROM test1 +-- +SELECT * FROM test1 +== 115 +DROP TABLE test1 +-- +DROP TABLE test1 +== 116 +DROP TABLE test2 +-- +DROP TABLE test2 +== 117 +DROP TABLE test3 +-- +DROP TABLE test3 diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_trap.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_trap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_trap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_trap.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_trap.test new file mode 100644 index 0000000..057eada --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_trap.test @@ -0,0 +1,310 @@ +== 001 +|-- +-- Test error trapping +|-- + +create function trap_zero_divide(int) returns int as $$ +declare x int; + sx smallint; +begin + begin -- start a subtransaction + raise notice 'should see this'; + x := 100 / $1; + raise notice 'should see this only if % <> 0', $1; + sx := $1; + raise notice 'should see this only if % fits in smallint', $1; + if $1 < 0 then + raise exception '% is less than zero', $1; + end if; + exception + when division_by_zero then + raise notice 'caught division_by_zero'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE then + raise notice 'caught numeric_value_out_of_range'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +|-- +-- Test error trapping +|-- + +create function trap_zero_divide(int) returns int as $1 language plpgsql +== 002 +select trap_zero_divide(50) +-- +select trap_zero_divide($1) +== 003 +select trap_zero_divide(0) +-- +select trap_zero_divide($1) +== 004 +select trap_zero_divide(100000) +-- +select trap_zero_divide($1) +== 005 +select trap_zero_divide(-100) +-- +select trap_zero_divide($1) +== 006 +create table match_source as + select x as id, x*10 as data, x/10 as ten from generate_series(1,100) x +-- +create table match_source as + select x as id, x*10 as data, x/10 as ten from generate_series(1,100) x +== 007 +create function trap_matching_test(int) returns int as $$ +declare x int; + sx smallint; + y int; +begin + begin -- start a subtransaction + x := 100 / $1; + sx := $1; + select into y data from match_source where id = + (select id from match_source b where ten = $1); + exception + when data_exception then -- category match + raise notice 'caught data_exception'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then + raise notice 'caught numeric_value_out_of_range or cardinality_violation'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +create function trap_matching_test(int) returns int as $1 language plpgsql +== 008 +select trap_matching_test(50) +-- +select trap_matching_test($1) +== 009 +select trap_matching_test(0) +-- +select trap_matching_test($1) +== 010 +select trap_matching_test(100000) +-- +select trap_matching_test($1) +== 011 +select trap_matching_test(1) +-- +select trap_matching_test($1) +== 012 +create temp table foo (f1 int) +-- +create temp table foo (f1 int) +== 013 +create function subxact_rollback_semantics() returns int as $$ +declare x int; +begin + x := 1; + insert into foo values(x); + begin + x := x + 1; + insert into foo values(x); + raise exception 'inner'; + exception + when others then + x := x * 10; + end; + insert into foo values(x); + return x; +end$$ language plpgsql +-- +create function subxact_rollback_semantics() returns int as $1 language plpgsql +== 014 +select subxact_rollback_semantics() +-- +select subxact_rollback_semantics() +== 015 +select * from foo +-- +select * from foo +== 016 +drop table foo +-- +drop table foo +== 017 +create function trap_timeout() returns void as $$ +begin + declare x int; + begin + -- we assume this will take longer than 1 second: + select count(*) into x from generate_series(1, 1_000_000_000_000); + exception + when others then + raise notice 'caught others?'; + when query_canceled then + raise notice 'nyeah nyeah, can''t stop me'; + end; + -- Abort transaction to abandon the statement_timeout setting. Otherwise, + -- the next top-level statement would be vulnerable to the timeout. + raise exception 'end of function'; +end$$ language plpgsql +-- +create function trap_timeout() returns void as $1 language plpgsql +== 018 +begin +-- +begin +== 019 +set statement_timeout to 1000 +-- +set statement_timeout to $1 +== 020 +select trap_timeout() +-- +select trap_timeout() +== 021 +rollback +-- +rollback +== 022 +-- Test for pass-by-ref values being stored in proper context +create function test_variable_storage() returns text as $$ +declare x text; +begin + x := '1234'; + begin + x := x || '5678'; + -- force error inside subtransaction SPI context + perform trap_zero_divide(-100); + exception + when others then + x := x || '9012'; + end; + return x; +end$$ language plpgsql +-- +-- Test for pass-by-ref values being stored in proper context +create function test_variable_storage() returns text as $1 language plpgsql +== 023 +select test_variable_storage() +-- +select test_variable_storage() +== 024 +|-- +-- test foreign key error trapping +|-- + +create temp table root(f1 int primary key) +-- +|-- +-- test foreign key error trapping +|-- + +create temp table root(f1 int primary key) +== 025 +create temp table leaf(f1 int references root deferrable) +-- +create temp table leaf(f1 int references root deferrable) +== 026 +insert into root values(1) +-- +insert into root values($1) +== 027 +insert into leaf values(1) +-- +insert into leaf values($1) +== 028 +insert into leaf values(2) +-- +insert into leaf values($1) +== 029 +-- fails + +create function trap_foreign_key(int) returns int as $$ +begin + begin -- start a subtransaction + insert into leaf values($1); + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +-- fails + +create function trap_foreign_key(int) returns int as $1 language plpgsql +== 030 +create function trap_foreign_key_2() returns int as $$ +begin + begin -- start a subtransaction + set constraints all immediate; + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +create function trap_foreign_key_2() returns int as $1 language plpgsql +== 031 +select trap_foreign_key(1) +-- +select trap_foreign_key($1) +== 032 +select trap_foreign_key(2) +-- +select trap_foreign_key($1) +== 033 +-- detects FK violation + +begin +-- +-- detects FK violation + +begin +== 034 +set constraints all deferred +-- +set constraints all deferred +== 035 +select trap_foreign_key(2) +-- +select trap_foreign_key($1) +== 036 +-- should not detect FK violation + savepoint x +-- +-- should not detect FK violation + savepoint x +== 037 +set constraints all immediate +-- +set constraints all immediate +== 038 +-- fails + rollback to x +-- +-- fails + rollback to x +== 039 +select trap_foreign_key_2() +-- +select trap_foreign_key_2() +== 040 +-- detects FK violation +commit +-- +-- detects FK violation +commit +== 041 +-- still fails + +drop function trap_foreign_key(int) +-- +-- still fails + +drop function trap_foreign_key(int) +== 042 +drop function trap_foreign_key_2() +-- +drop function trap_foreign_key_2() diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_trigger.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_trigger.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_trigger.test new file mode 100644 index 0000000..100da3c --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_trigger.test @@ -0,0 +1,41 @@ +== 001 +-- Simple test to verify accessibility of the OLD and NEW trigger variables + +create table testtr (a int, b text) +-- +-- Simple test to verify accessibility of the OLD and NEW trigger variables + +create table testtr (a int, b text) +== 002 +create function testtr_trigger() returns trigger language plpgsql as +$$begin + raise notice 'tg_op = %', tg_op; + raise notice 'old(%) = %', old.a, row(old.*); + raise notice 'new(%) = %', new.a, row(new.*); + if (tg_op = 'DELETE') then + return old; + else + return new; + end if; +end$$ +-- +create function testtr_trigger() returns trigger language plpgsql as +$1 +== 003 +create trigger testtr_trigger before insert or delete or update on testtr + for each row execute function testtr_trigger() +-- +create trigger testtr_trigger before insert or delete or update on testtr + for each row execute function testtr_trigger() +== 004 +insert into testtr values (1, 'one'), (2, 'two') +-- +insert into testtr values ($1, $2), ($3, $4) +== 005 +update testtr set a = a + 1 +-- +update testtr set a = a + $1 +== 006 +delete from testtr +-- +delete from testtr diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_varprops.metadata.json b/parser/testdata/normalize/plpgsql_regress/plpgsql_varprops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_varprops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/normalize/plpgsql_regress/plpgsql_varprops.test b/parser/testdata/normalize/plpgsql_regress/plpgsql_varprops.test new file mode 100644 index 0000000..feb57c4 --- /dev/null +++ b/parser/testdata/normalize/plpgsql_regress/plpgsql_varprops.test @@ -0,0 +1,339 @@ +== 001 +|-- +-- Tests for PL/pgSQL variable properties: CONSTANT, NOT NULL, initializers +|-- + +create type var_record as (f1 int4, f2 int4) +-- +|-- +-- Tests for PL/pgSQL variable properties: CONSTANT, NOT NULL, initializers +|-- + +create type var_record as (f1 int4, f2 int4) +== 002 +create domain int_nn as int not null +-- +create domain int_nn as int not null +== 003 +create domain var_record_nn as var_record not null +-- +create domain var_record_nn as var_record not null +== 004 +create domain var_record_colnn as var_record check((value).f2 is not null) +-- +create domain var_record_colnn as var_record check((value).f2 is not null) +== 005 +-- CONSTANT + +do $$ +declare x constant int := 42; +begin + raise notice 'x = %', x; +end$$ +-- +-- CONSTANT + +do $1 +== 006 +do $$ +declare x constant int; +begin + x := 42; -- fail +end$$ +-- +do $1 +== 007 +do $$ +declare x constant int; y int; +begin + for x, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +do $1 +== 008 +do $$ +declare x constant int[]; +begin + x[1] := 42; -- fail +end$$ +-- +do $1 +== 009 +do $$ +declare x constant int[]; y int; +begin + for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax) + end loop; +end$$ +-- +do $1 +== 010 +do $$ +declare x constant var_record; +begin + x.f1 := 42; -- fail +end$$ +-- +do $1 +== 011 +do $$ +declare x constant var_record; y int; +begin + for x.f1, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +do $1 +== 012 +-- initializer expressions + +do $$ +declare x int := sin(0); +begin + raise notice 'x = %', x; +end$$ +-- +-- initializer expressions + +do $1 +== 013 +do $$ +declare x int := 1/0; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 014 +do $$ +declare x bigint[] := array[1,3,5]; +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 015 +do $$ +declare x record := row(1,2,3); +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 016 +do $$ +declare x var_record := row(1,2); +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 017 +-- NOT NULL + +do $$ +declare x int not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +-- NOT NULL + +do $1 +== 018 +do $$ +declare x int not null := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +do $1 +== 019 +do $$ +declare x int not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 020 +do $$ +declare x record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 021 +do $$ +declare x record not null := row(42); +begin + raise notice 'x = %', x; + x := row(null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +do $1 +== 022 +do $$ +declare x record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 023 +do $$ +declare x var_record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 024 +do $$ +declare x var_record not null := row(41,42); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +do $1 +== 025 +do $$ +declare x var_record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 026 +-- Check that variables are reinitialized on block re-entry. + +do $$ +begin + for i in 1..3 loop + declare + x int; + y int := i; + r record; + c var_record; + begin + if i = 1 then + x := 42; + r := row(i, i+1); + c := row(i, i+1); + end if; + raise notice 'x = %', x; + raise notice 'y = %', y; + raise notice 'r = %', r; + raise notice 'c = %', c; + end; + end loop; +end$$ +-- +-- Check that variables are reinitialized on block re-entry. + +do $1 +== 027 +-- Check enforcement of domain constraints during initialization + +do $$ +declare x int_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +-- Check enforcement of domain constraints during initialization + +do $1 +== 028 +do $$ +declare x int_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 029 +do $$ +declare x int_nn := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +do $1 +== 030 +do $$ +declare x var_record_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 031 +do $$ +declare x var_record_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 032 +do $$ +declare x var_record_nn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + x := null; -- fail +end$$ +-- +do $1 +== 033 +do $$ +declare x var_record_colnn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 034 +do $$ +declare x var_record_colnn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 035 +do $$ +declare x var_record_colnn := row(1,null); -- fail +begin + raise notice 'x = %', x; +end$$ +-- +do $1 +== 036 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +do $1 +== 037 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- fail +end$$ +-- +do $1 diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_array.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_array.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_array.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_array.test b/parser/testdata/parse/plpgsql_regress/plpgsql_array.test new file mode 100644 index 0000000..29f70aa --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_array.test @@ -0,0 +1,218 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of array variables +|-- +-- We also check arrays of composites here, so this has some overlap +-- with the plpgsql_record tests. +|-- + +create type complex as (r float8, i float8) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"complex","relpersistence":"p","location":175},"coldeflist":[{"ColumnDef":{"colname":"r","typeName":{"names":[{"String":{"sval":"float8"}}],"typemod":-1,"location":189},"is_local":true,"location":187}},{"ColumnDef":{"colname":"i","typeName":{"names":[{"String":{"sval":"float8"}}],"typemod":-1,"location":199},"is_local":true,"location":197}}]}}}]} +== 002 +create type quadarray as (c1 complex[], c2 complex) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"quadarray","relpersistence":"p","location":12},"coldeflist":[{"ColumnDef":{"colname":"c1","typeName":{"names":[{"String":{"sval":"complex"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":29},"is_local":true,"location":26}},{"ColumnDef":{"colname":"c2","typeName":{"names":[{"String":{"sval":"complex"}}],"typemod":-1,"location":43},"is_local":true,"location":40}}]}}}]} +== 003 +do $$ declare a int[]; +begin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 004 +do $$ declare a int[]; +begin a[3] := 4; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a[3] := 4; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 005 +do $$ declare a int[]; +begin a[1][4] := 4; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a[1][4] := 4; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 006 +do $$ declare a int[]; +begin a[1] := 23::text; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a[1] := 23::text; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 007 +-- lax typing + +do $$ declare a int[]; +begin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":18}}]}}}]} +== 008 +do $$ declare a int[]; +begin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 009 +do $$ declare a int[]; +begin a[1:2] := array[3,4]; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a[1:2] := array[3,4]; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 010 +do $$ declare a int[]; +begin a[1:2] := 4; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a[1:2] := 4; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 011 +-- error + +do $$ declare a complex[]; +begin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a complex[];\nbegin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":13}}]}}}]} +== 012 +do $$ declare a complex[]; +begin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a complex[];\nbegin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 013 +-- perhaps this ought to work, but for now it doesn't: +do $$ declare a complex[]; +begin a[1:2].i := array[11,12]; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a complex[];\nbegin a[1:2].i := array[11,12]; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":58}}]}}}]} +== 014 +do $$ declare a quadarray; +begin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a quadarray;\nbegin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 015 +do $$ declare a int[]; +begin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 016 +create temp table onecol as select array[1,2] as f1 +-- +{"version":170007,"stmts":[{"stmt":{"CreateTableAsStmt":{"query":{"SelectStmt":{"targetList":[{"ResTarget":{"name":"f1","val":{"A_ArrayExpr":{"elements":[{"A_Const":{"ival":{"ival":1},"location":41}},{"A_Const":{"ival":{"ival":2},"location":43}}],"location":35}},"location":35}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"into":{"rel":{"relname":"onecol","inh":true,"relpersistence":"t","location":18},"onCommit":"ONCOMMIT_NOOP"},"objtype":"OBJECT_TABLE"}}}]} +== 017 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := f1 from onecol; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 018 +do $$ declare a int[]; +begin a := * from onecol for update; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := * from onecol for update; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 019 +-- error cases: + +do $$ declare a int[]; +begin a := from onecol; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := from onecol; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 020 +do $$ declare a int[]; +begin a := f1, f1 from onecol; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := f1, f1 from onecol; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 021 +insert into onecol values(array[11]) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"onecol","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_ArrayExpr":{"elements":[{"A_Const":{"ival":{"ival":11},"location":32}}],"location":26}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 022 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := f1 from onecol; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 023 +do $$ declare a int[]; +begin a := f1 from onecol limit 1; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a int[];\nbegin a := f1 from onecol limit 1; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 024 +do $$ declare a real; +begin a[1] := 2; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a real;\nbegin a[1] := 2; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 025 +do $$ declare a complex; +begin a.r[1] := 2; raise notice 'a = %', a; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare a complex;\nbegin a.r[1] := 2; raise notice 'a = %', a; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 026 +|-- +-- test of %type[] and %rowtype[] syntax +|-- + +-- check supported syntax +do $$ +declare + v int; + v1 v%type; + v2 v%type[]; + v3 v%type[1]; + v4 v%type[][]; + v5 v%type[1][3]; + v6 v%type array; + v7 v%type array[]; + v8 v%type array[1]; + v9 v%type array[1][1]; + v10 pg_catalog.pg_class%rowtype[]; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(v3); + raise notice '%', pg_typeof(v4); + raise notice '%', pg_typeof(v5); + raise notice '%', pg_typeof(v6); + raise notice '%', pg_typeof(v7); + raise notice '%', pg_typeof(v8); + raise notice '%', pg_typeof(v9); + raise notice '%', pg_typeof(v10); +end; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare\n v int;\n v1 v%type;\n v2 v%type[];\n v3 v%type[1];\n v4 v%type[][];\n v5 v%type[1][3];\n v6 v%type array;\n v7 v%type array[];\n v8 v%type array[1];\n v9 v%type array[1][1];\n v10 pg_catalog.pg_class%rowtype[];\nbegin\n raise notice '%', pg_typeof(v1);\n raise notice '%', pg_typeof(v2);\n raise notice '%', pg_typeof(v3);\n raise notice '%', pg_typeof(v4);\n raise notice '%', pg_typeof(v5);\n raise notice '%', pg_typeof(v6);\n raise notice '%', pg_typeof(v7);\n raise notice '%', pg_typeof(v8);\n raise notice '%', pg_typeof(v9);\n raise notice '%', pg_typeof(v10);\nend;\n"}},"defaction":"DEFELEM_UNSPEC","location":77}}]}}}]} +== 027 +-- some types don't support arrays +do $$ +declare + v pg_node_tree; + v1 v%type[]; +begin +end; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare\n v pg_node_tree;\n v1 v%type[];\nbegin\nend;\n"}},"defaction":"DEFELEM_UNSPEC","location":38}}]}}}]} +== 028 +-- check functionality +do $$ +declare + v1 int; + v2 varchar; + a1 v1%type[]; + a2 v2%type[]; +begin + v1 := 10; + v2 := 'Hi'; + a1 := array[v1,v1]; + a2 := array[v2,v2]; + raise notice '% %', a1, a2; +end; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare\n v1 int;\n v2 varchar;\n a1 v1%type[];\n a2 v2%type[];\nbegin\n v1 := 10;\n v2 := 'Hi';\n a1 := array[v1,v1];\n a2 := array[v2,v2];\n raise notice '% %', a1, a2;\nend;\n"}},"defaction":"DEFELEM_UNSPEC","location":26}}]}}}]} +== 029 +create table array_test_table(a int, b varchar) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"array_test_table","inh":true,"relpersistence":"p","location":13},"tableElts":[{"ColumnDef":{"colname":"a","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":32},"is_local":true,"location":30}},{"ColumnDef":{"colname":"b","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"varchar"}}],"typemod":-1,"location":39},"is_local":true,"location":37}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 030 +insert into array_test_table values(1, 'first'), (2, 'second') +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"array_test_table","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":36}},{"A_Const":{"sval":{"sval":"first"},"location":39}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":2},"location":50}},{"A_Const":{"sval":{"sval":"second"},"location":53}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 031 +do $$ +declare tg array_test_table%rowtype[]; +begin + tg := array(select array_test_table from array_test_table); + raise notice '%', tg; + tg := array(select row(a,b) from array_test_table); + raise notice '%', tg; +end; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare tg array_test_table%rowtype[];\nbegin\n tg := array(select array_test_table from array_test_table);\n raise notice '%', tg;\n tg := array(select row(a,b) from array_test_table);\n raise notice '%', tg;\nend;\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_cache.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_cache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_cache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_cache.test b/parser/testdata/parse/plpgsql_regress/plpgsql_cache.test new file mode 100644 index 0000000..52fae3f --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_cache.test @@ -0,0 +1,82 @@ +== 001 +|-- +-- Cache-behavior-dependent test cases +|-- +-- These tests logically belong in plpgsql_record.sql, and perhaps someday +-- can be merged back into it. For now, however, their results are different +-- depending on debug_discard_caches, so we must have two expected-output +-- files to cover both cases. To minimize the maintenance effort resulting +-- from that, this file should contain only tests that do have different +-- results under debug_discard_caches. +|-- + +-- check behavior with changes of a named rowtype +create table c_mutable(f1 int, f2 text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"c_mutable","inh":true,"relpersistence":"p","location":527},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":540},"is_local":true,"location":537}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":548},"is_local":true,"location":545}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 002 +create function c_sillyaddone(int) returns int language plpgsql as +$$ declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"c_sillyaddone"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":30},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":43},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":47}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":64}}]}}}]} +== 003 +select c_sillyaddone(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"c_sillyaddone"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":21}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 004 +alter table c_mutable drop column f1 +-- +{"version":170007,"stmts":[{"stmt":{"AlterTableStmt":{"relation":{"relname":"c_mutable","inh":true,"relpersistence":"p","location":12},"cmds":[{"AlterTableCmd":{"subtype":"AT_DropColumn","name":"f1","behavior":"DROP_RESTRICT"}}],"objtype":"OBJECT_TABLE"}}}]} +== 005 +alter table c_mutable add column f1 float8 +-- +{"version":170007,"stmts":[{"stmt":{"AlterTableStmt":{"relation":{"relname":"c_mutable","inh":true,"relpersistence":"p","location":12},"cmds":[{"AlterTableCmd":{"subtype":"AT_AddColumn","def":{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"float8"}}],"typemod":-1,"location":36},"is_local":true,"location":33}},"behavior":"DROP_RESTRICT"}}],"objtype":"OBJECT_TABLE"}}}]} +== 006 +-- currently, this fails due to cached plan for "r.f1 + 1" expression +-- (but if debug_discard_caches is on, it will succeed) +select c_sillyaddone(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"c_sillyaddone"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":147}}],"funcformat":"COERCE_EXPLICIT_CALL","location":133}},"location":133}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 007 +-- but it's OK if we force plan rebuilding +discard plans +-- +{"version":170007,"stmts":[{"stmt":{"DiscardStmt":{"target":"DISCARD_PLANS"}}}]} +== 008 +select c_sillyaddone(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"c_sillyaddone"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":21}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 009 +-- check behavior with changes in a record rowtype +create function show_result_type(text) returns text language plpgsql as +$$ + declare + r record; + t text; + begin + execute $1 into r; + select pg_typeof(r.a) into t; + return format('type %s value %s', t, r.a::text); + end; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"show_result_type"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":84},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":98},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":103}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\n declare\n r record;\n t text;\n begin\n execute $1 into r;\n select pg_typeof(r.a) into t;\n return format('type %s value %s', t, r.a::text);\n end;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":120}}]}}}]} +== 010 +select show_result_type('select 1 as a') +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"show_result_type"}}],"args":[{"A_Const":{"sval":{"sval":"select 1 as a"},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 011 +-- currently this fails due to cached plan for pg_typeof expression +-- (but if debug_discard_caches is on, it will succeed) +select show_result_type('select 2.0 as a') +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"show_result_type"}}],"args":[{"A_Const":{"sval":{"sval":"select 2.0 as a"},"location":148}}],"funcformat":"COERCE_EXPLICIT_CALL","location":131}},"location":131}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 012 +-- but it's OK if we force plan rebuilding +discard plans +-- +{"version":170007,"stmts":[{"stmt":{"DiscardStmt":{"target":"DISCARD_PLANS"}}}]} +== 013 +select show_result_type('select 2.0 as a') +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"show_result_type"}}],"args":[{"A_Const":{"sval":{"sval":"select 2.0 as a"},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_call.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_call.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_call.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_call.test b/parser/testdata/parse/plpgsql_regress/plpgsql_call.test new file mode 100644 index 0000000..3ee8766 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_call.test @@ -0,0 +1,748 @@ +== 001 +|-- +-- Tests for procedures / CALL syntax +|-- + +CREATE PROCEDURE test_proc1() +LANGUAGE plpgsql +AS $$ +BEGIN + NULL; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc1"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":75}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n NULL;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":92}}]}}}]} +== 002 +CALL test_proc1() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc1"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 003 +-- error: can't return non-NULL +CREATE PROCEDURE test_proc2() +LANGUAGE plpgsql +AS $$ +BEGIN + RETURN 5; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc2"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":62}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RETURN 5;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":79}}]}}}]} +== 004 +CREATE TABLE test1 (a int) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"test1","inh":true,"relpersistence":"p","location":13},"tableElts":[{"ColumnDef":{"colname":"a","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":22},"is_local":true,"location":20}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 005 +CREATE PROCEDURE test_proc3(x int) +LANGUAGE plpgsql +AS $$ +BEGIN + INSERT INTO test1 VALUES (x); +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc3"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":30},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":35}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n INSERT INTO test1 VALUES (x);\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":52}}]}}}]} +== 006 +CALL test_proc3(55) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc3"}}],"args":[{"A_Const":{"ival":{"ival":55},"location":16}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 007 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 008 +-- Check that plan revalidation doesn't prevent setting transaction properties +-- (bug #18059). This test must include the first temp-object creation in +-- this script, or it won't exercise the bug scenario. Hence we put it early. +CREATE PROCEDURE test_proc3a() +LANGUAGE plpgsql +AS $$ +BEGIN + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + RAISE NOTICE 'done'; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc3a"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":264}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n COMMIT;\n SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;\n RAISE NOTICE 'done';\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":281}}]}}}]} +== 009 +CALL test_proc3a() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc3a"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 010 +CREATE TEMP TABLE tt1(f1 int) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"tt1","inh":true,"relpersistence":"t","location":18},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":25},"is_local":true,"location":22}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 011 +CALL test_proc3a() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc3a"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 012 +-- nested CALL +TRUNCATE TABLE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":30}}],"behavior":"DROP_RESTRICT"}}}]} +== 013 +CREATE PROCEDURE test_proc4(y int) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL test_proc3(y); + CALL test_proc3($1); +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc4"}}],"parameters":[{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":30},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":35}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n CALL test_proc3(y);\n CALL test_proc3($1);\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":52}}]}}}]} +== 014 +CALL test_proc4(66) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc4"}}],"args":[{"A_Const":{"ival":{"ival":66},"location":16}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 015 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 016 +CALL test_proc4(66) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc4"}}],"args":[{"A_Const":{"ival":{"ival":66},"location":16}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 017 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 018 +-- output arguments + +CREATE PROCEDURE test_proc5(INOUT a text) +LANGUAGE plpgsql +AS $$ +BEGIN + a := a || '+' || a; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc5"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":57},"mode":"FUNC_PARAM_INOUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":63}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n a := a || '+' || a;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":80}}]}}}]} +== 019 +CALL test_proc5('abc') +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc5"}}],"args":[{"A_Const":{"sval":{"sval":"abc"},"location":16}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 020 +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + b := b * a; + c := c * a; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc6"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":30},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":43},"mode":"FUNC_PARAM_INOUT"}},{"FunctionParameter":{"name":"c","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":56},"mode":"FUNC_PARAM_INOUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":61}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n b := b * a;\n c := c * a;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":78}}]}}}]} +== 021 +CALL test_proc6(2, 3, 4) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc6"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":16}},{"A_Const":{"ival":{"ival":3},"location":19}},{"A_Const":{"ival":{"ival":4},"location":22}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 022 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); + RAISE INFO 'x = %, y = %', x, y; + CALL test_proc6(2, c => y, b => x); + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n x int := 3;\n y int := 4;\nBEGIN\n CALL test_proc6(2, x, y);\n RAISE INFO 'x = %, y = %', x, y;\n CALL test_proc6(2, c =\u003e y, b =\u003e x);\n RAISE INFO 'x = %, y = %', x, y;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 023 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x + 1, y); -- error + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n x int := 3;\n y int := 4;\nBEGIN\n CALL test_proc6(2, x + 1, y); -- error\n RAISE INFO 'x = %, y = %', x, y;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 024 +DO +LANGUAGE plpgsql +$$ +DECLARE + x constant int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); -- error because x is constant +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n x constant int := 3;\n y int := 4;\nBEGIN\n CALL test_proc6(2, x, y); -- error because x is constant\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 025 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + FOR i IN 1..5 LOOP + CALL test_proc6(i, x, y); + RAISE INFO 'x = %, y = %', x, y; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n x int := 3;\n y int := 4;\nBEGIN\n FOR i IN 1..5 LOOP\n CALL test_proc6(i, x, y);\n RAISE INFO 'x = %, y = %', x, y;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 026 +-- recursive with output arguments + +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN +IF x > 1 THEN + a := x / 10; + b := x / 2; + CALL test_proc7(b::int, a, b); +END IF; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc7"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":66},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":79},"mode":"FUNC_PARAM_INOUT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"numeric"}}],"typemod":-1,"location":92},"mode":"FUNC_PARAM_INOUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":101}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\nIF x \u003e 1 THEN\n a := x / 10;\n b := x / 2;\n CALL test_proc7(b::int, a, b);\nEND IF;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":118}}]}}}]} +== 027 +CALL test_proc7(100, -1, -1) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc7"}}],"args":[{"A_Const":{"ival":{"ival":100},"location":16}},{"A_Const":{"ival":{"ival":-1},"location":21}},{"A_Const":{"ival":{"ival":-1},"location":25}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 028 +-- inner COMMIT with output arguments + +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN + a := x / 10; + b := x / 2; + COMMIT; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc7c"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":70},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":83},"mode":"FUNC_PARAM_INOUT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"numeric"}}],"typemod":-1,"location":96},"mode":"FUNC_PARAM_INOUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":105}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n a := x / 10;\n b := x / 2;\n COMMIT;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":122}}]}}}]} +== 029 +CREATE PROCEDURE test_proc7cc(_x int) +LANGUAGE plpgsql +AS $$ +DECLARE _a int; _b numeric; +BEGIN + CALL test_proc7c(_x, _a, _b); + RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc7cc"}}],"parameters":[{"FunctionParameter":{"name":"_x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":33},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":38}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nDECLARE _a int; _b numeric;\nBEGIN\n CALL test_proc7c(_x, _a, _b);\n RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b;\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":55}}]}}}]} +== 030 +CALL test_proc7cc(10) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc7cc"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":18}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 031 +-- named parameters and defaults + +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := a * 10; + b := b + 10; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc8a"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":71},"mode":"FUNC_PARAM_INOUT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":84},"mode":"FUNC_PARAM_INOUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":89}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'a: %, b: %', a, b;\n a := a * 10;\n b := b + 10;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":106}}]}}}]} +== 032 +CALL test_proc8a(10, 20) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc8a"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":17}},{"A_Const":{"ival":{"ival":20},"location":21}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 033 +CALL test_proc8a(b => 20, a => 10) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"test_proc8a"}}],"args":[{"NamedArgExpr":{"arg":{"A_Const":{"ival":{"ival":20},"location":22}},"name":"b","argnumber":-1,"location":17}},{"NamedArgExpr":{"arg":{"A_Const":{"ival":{"ival":10},"location":31}},"name":"a","argnumber":-1,"location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 034 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc8a(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; + CALL test_proc8a(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int;\nBEGIN\n _a := 10; _b := 30;\n CALL test_proc8a(_a, _b);\n RAISE NOTICE '_a: %, _b: %', _a, _b;\n CALL test_proc8a(b =\u003e _b, a =\u003e _a);\n RAISE NOTICE '_a: %, _b: %', _a, _b;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 035 +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc8b"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":37},"mode":"FUNC_PARAM_INOUT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":50},"mode":"FUNC_PARAM_INOUT"}},{"FunctionParameter":{"name":"c","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":63},"mode":"FUNC_PARAM_INOUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":68}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'a: %, b: %, c: %', a, b, c;\n a := a * 10;\n b := b + 10;\n c := c * -10;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":85}}]}}}]} +== 036 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8b(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + CALL test_proc8b(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int; _c int;\nBEGIN\n _a := 10; _b := 30; _c := 50;\n CALL test_proc8b(_a, _b, _c);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n CALL test_proc8b(_a, c =\u003e _c, b =\u003e _b);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 037 +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc8c"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":37},"mode":"FUNC_PARAM_INOUT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":50},"mode":"FUNC_PARAM_INOUT"}},{"FunctionParameter":{"name":"c","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":63},"mode":"FUNC_PARAM_INOUT","defexpr":{"A_Const":{"ival":{"ival":11},"location":75}}}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":79}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'a: %, b: %, c: %', a, b, c;\n a := a * 10;\n b := b + 10;\n c := c * -10;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":96}}]}}}]} +== 038 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(c => _c, b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int; _c int;\nBEGIN\n _a := 10; _b := 30; _c := 50;\n CALL test_proc8c(_a, _b, _c);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n _a := 10; _b := 30; _c := 50;\n CALL test_proc8c(_a, c =\u003e _c, b =\u003e _b);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n _a := 10; _b := 30; _c := 50;\n CALL test_proc8c(c =\u003e _c, b =\u003e _b, a =\u003e _a);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 039 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int; _c int;\nBEGIN\n _a := 10; _b := 30; _c := 50;\n CALL test_proc8c(_a, _b); -- fail, no output argument for c\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 040 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, b => _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int; _c int;\nBEGIN\n _a := 10; _b := 30; _c := 50;\n CALL test_proc8c(_a, b =\u003e _b); -- fail, no output argument for c\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 041 +-- OUT parameters + +CREATE PROCEDURE test_proc9(IN a int, OUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + b := a * 2; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc9"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":52},"mode":"FUNC_PARAM_IN"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":63},"mode":"FUNC_PARAM_OUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":68}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'a: %, b: %', a, b;\n b := a * 2;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":85}}]}}}]} +== 042 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc9(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int;\nBEGIN\n _a := 10; _b := 30;\n CALL test_proc9(_a, _b);\n RAISE NOTICE '_a: %, _b: %', _a, _b;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 043 +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + b := a - c; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc10"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":34},"mode":"FUNC_PARAM_IN"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":45},"mode":"FUNC_PARAM_OUT"}},{"FunctionParameter":{"name":"c","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":55},"mode":"FUNC_PARAM_IN","defexpr":{"A_Const":{"ival":{"ival":11},"location":67}}}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":71}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'a: %, b: %, c: %', a, b, c;\n b := a - c;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":88}}]}}}]} +== 044 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(a => _a, b => _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int; _c int;\nBEGIN\n _a := 10; _b := 30; _c := 7;\n CALL test_proc10(_a, _b, _c);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n\n _a := 10; _b := 30; _c := 7;\n CALL test_proc10(_a, _b, c =\u003e _c);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n\n _a := 10; _b := 30; _c := 7;\n CALL test_proc10(a =\u003e _a, b =\u003e _b, c =\u003e _c);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n\n _a := 10; _b := 30; _c := 7;\n CALL test_proc10(_a, c =\u003e _c, b =\u003e _b);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n\n _a := 10; _b := 30; _c := 7;\n CALL test_proc10(_a, _b);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n\n _a := 10; _b := 30; _c := 7;\n CALL test_proc10(_a, b =\u003e _b);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\n\n _a := 10; _b := 30; _c := 7;\n CALL test_proc10(b =\u003e _b, a =\u003e _a);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 045 +-- OUT + VARIADIC + +CREATE PROCEDURE test_proc11(a OUT int, VARIADIC b int[]) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := b[1] + b[2]; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc11"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":54},"mode":"FUNC_PARAM_OUT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":70},"mode":"FUNC_PARAM_VARIADIC"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":77}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'a: %, b: %', a, b;\n a := b[1] + b[2];\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":94}}]}}}]} +== 046 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc11(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int; _c int;\nBEGIN\n _a := 10; _b := 30; _c := 7;\n CALL test_proc11(_a, _b, _c);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 047 +-- polymorphic OUT arguments + +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %', a; + b := a; + c := array[a]; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"test_proc12"}}],"parameters":[{"FunctionParameter":{"name":"a","argType":{"names":[{"String":{"sval":"anyelement"}}],"typemod":-1,"location":61},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"b","argType":{"names":[{"String":{"sval":"anyelement"}}],"typemod":-1,"location":79},"mode":"FUNC_PARAM_OUT"}},{"FunctionParameter":{"name":"c","argType":{"names":[{"String":{"sval":"anyarray"}}],"typemod":-1,"location":97},"mode":"FUNC_PARAM_OUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":107}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'a: %', a;\n b := a;\n c := array[a];\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":124}}]}}}]} +== 048 +DO $$ +DECLARE _a int; _b int; _c int[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int; _c int[];\nBEGIN\n _a := 10;\n CALL test_proc12(_a, _b, _c);\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 049 +DO $$ +DECLARE _a int; _b int; _c text[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); -- error + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE _a int; _b int; _c text[];\nBEGIN\n _a := 10;\n CALL test_proc12(_a, _b, _c); -- error\n RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 050 +-- transition variable assignment + +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":44}}],"behavior":"DROP_RESTRICT"}}}]} +== 051 +CREATE FUNCTION triggerfunc1() RETURNS trigger +LANGUAGE plpgsql +AS $$ +DECLARE + z int := 0; +BEGIN + CALL test_proc6(2, NEW.a, NEW.a); + RETURN NEW; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"triggerfunc1"}}],"returnType":{"names":[{"String":{"sval":"trigger"}}],"typemod":-1,"location":39},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":47}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nDECLARE\n z int := 0;\nBEGIN\n CALL test_proc6(2, NEW.a, NEW.a);\n RETURN NEW;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":64}}]}}}]} +== 052 +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE PROCEDURE triggerfunc1() +-- +{"version":170007,"stmts":[{"stmt":{"CreateTrigStmt":{"trigname":"t1","relation":{"relname":"test1","inh":true,"relpersistence":"p","location":35},"funcname":[{"String":{"sval":"triggerfunc1"}}],"timing":2,"events":4}}}]} +== 053 +INSERT INTO test1 VALUES (1), (2), (3) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"test1","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":26}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":2},"location":31}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":3},"location":36}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 054 +UPDATE test1 SET a = 22 WHERE a = 2 +-- +{"version":170007,"stmts":[{"stmt":{"UpdateStmt":{"relation":{"relname":"test1","inh":true,"relpersistence":"p","location":7},"targetList":[{"ResTarget":{"name":"a","val":{"A_Const":{"ival":{"ival":22},"location":21}},"location":17}}],"whereClause":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"="}}],"lexpr":{"ColumnRef":{"fields":[{"String":{"sval":"a"}}],"location":30}},"rexpr":{"A_Const":{"ival":{"ival":2},"location":34}},"location":32}}}}}]} +== 055 +SELECT * FROM test1 ORDER BY a +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"sortClause":[{"SortBy":{"node":{"ColumnRef":{"fields":[{"String":{"sval":"a"}}],"location":29}},"sortby_dir":"SORTBY_DEFAULT","sortby_nulls":"SORTBY_NULLS_DEFAULT","location":-1}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 056 +DROP PROCEDURE test_proc1 +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"ObjectWithArgs":{"objname":[{"String":{"sval":"test_proc1"}}],"args_unspecified":true}}],"removeType":"OBJECT_PROCEDURE","behavior":"DROP_RESTRICT"}}}]} +== 057 +DROP PROCEDURE test_proc3 +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"ObjectWithArgs":{"objname":[{"String":{"sval":"test_proc3"}}],"args_unspecified":true}}],"removeType":"OBJECT_PROCEDURE","behavior":"DROP_RESTRICT"}}}]} +== 058 +DROP PROCEDURE test_proc4 +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"ObjectWithArgs":{"objname":[{"String":{"sval":"test_proc4"}}],"args_unspecified":true}}],"removeType":"OBJECT_PROCEDURE","behavior":"DROP_RESTRICT"}}}]} +== 059 +DROP TABLE test1 +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"List":{"items":[{"String":{"sval":"test1"}}]}}],"removeType":"OBJECT_TABLE","behavior":"DROP_RESTRICT"}}}]} +== 060 +-- more checks for named-parameter handling + +CREATE PROCEDURE p1(v_cnt int, v_Text inout text = NULL) +AS $$ +BEGIN + v_Text := 'v_cnt = ' || v_cnt; +END +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"p1"}}],"parameters":[{"FunctionParameter":{"name":"v_cnt","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":71},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"v_text","argType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":89},"mode":"FUNC_PARAM_INOUT","defexpr":{"A_Const":{"isnull":true,"location":96}}}}],"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n v_Text := 'v_cnt = ' || v_cnt;\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":102}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":154}}]}}}]} +== 061 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text + RAISE NOTICE '%', v_Text; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n v_Text text;\n v_cnt integer := 42;\nBEGIN\n CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text\n RAISE NOTICE '%', v_Text;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 062 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n v_Text text;\n v_cnt integer := 42;\nBEGIN\n CALL p1(v_cnt := v_cnt, v_Text := v_Text);\n RAISE NOTICE '%', v_Text;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 063 +DO $$ +DECLARE + v_Text text; +BEGIN + CALL p1(10, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n v_Text text;\nBEGIN\n CALL p1(10, v_Text := v_Text);\n RAISE NOTICE '%', v_Text;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 064 +DO $$ +DECLARE + v_Text text; + v_cnt integer; +BEGIN + CALL p1(v_Text := v_Text, v_cnt := v_cnt); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n v_Text text;\n v_cnt integer;\nBEGIN\n CALL p1(v_Text := v_Text, v_cnt := v_cnt);\n RAISE NOTICE '%', v_Text;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 065 +-- check that we detect change of dependencies in CALL +-- atomic and non-atomic call sites used to do this differently, so check both + +CREATE PROCEDURE inner_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'inner_p(%)', f1; +END +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"inner_p"}}],"parameters":[{"FunctionParameter":{"name":"f1","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":164},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'inner_p(%)', f1;\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":169}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":221}}]}}}]} +== 066 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 1 $$ LANGUAGE sql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"f"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":18},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":31},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" SELECT $1 + 1 "}}]}},"defaction":"DEFELEM_UNSPEC","location":35}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":58}}]}}}]} +== 067 +CREATE PROCEDURE outer_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'outer_p(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"outer_p"}}],"parameters":[{"FunctionParameter":{"name":"f1","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":29},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'outer_p(%)', f1;\n CALL inner_p(f(f1));\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":34}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":109}}]}}}]} +== 068 +CREATE FUNCTION outer_f (f1 int) RETURNS void +AS $$ +BEGIN + RAISE NOTICE 'outer_f(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"outer_f"}}],"parameters":[{"FunctionParameter":{"name":"f1","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":28},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":41},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'outer_f(%)', f1;\n CALL inner_p(f(f1));\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":46}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":121}}]}}}]} +== 069 +CALL outer_p(42) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"outer_p"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":13}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 070 +SELECT outer_f(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"outer_f"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":15}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 071 +DROP FUNCTION f(int) +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"ObjectWithArgs":{"objname":[{"String":{"sval":"f"}}],"objargs":[{"TypeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":16}}],"objfuncargs":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":16},"mode":"FUNC_PARAM_DEFAULT"}}]}}],"removeType":"OBJECT_FUNCTION","behavior":"DROP_RESTRICT"}}}]} +== 072 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 2 $$ LANGUAGE sql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"f"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":18},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":31},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" SELECT $1 + 2 "}}]}},"defaction":"DEFELEM_UNSPEC","location":35}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":58}}]}}}]} +== 073 +CALL outer_p(42) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"outer_p"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":13}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 074 +SELECT outer_f(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"outer_f"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":15}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 075 +-- Check that stable functions in CALL see the correct snapshot + +CREATE TABLE t_test (x int) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"t_test","inh":true,"relpersistence":"p","location":78},"tableElts":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":88},"is_local":true,"location":86}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 076 +INSERT INTO t_test VALUES (0) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"t_test","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{},"location":27}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 077 +CREATE FUNCTION f_get_x () RETURNS int +AS $$ +DECLARE l_result int; +BEGIN + SELECT x INTO l_result FROM t_test; + RETURN l_result; +END +$$ LANGUAGE plpgsql STABLE +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"f_get_x"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":35},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nDECLARE l_result int;\nBEGIN\n SELECT x INTO l_result FROM t_test;\n RETURN l_result;\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":39}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":137}},{"DefElem":{"defname":"volatility","arg":{"String":{"sval":"stable"}},"defaction":"DEFELEM_UNSPEC","location":154}}]}}}]} +== 078 +CREATE PROCEDURE f_print_x (x int) +AS $$ +BEGIN + RAISE NOTICE 'f_print_x(%)', x; +END +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"f_print_x"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":30},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'f_print_x(%)', x;\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":35}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":88}}]}}}]} +== 079 +-- test in non-atomic context +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + ROLLBACK; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n UPDATE t_test SET x = x + 1;\n RAISE NOTICE 'f_get_x(%)', f_get_x();\n CALL f_print_x(f_get_x());\n UPDATE t_test SET x = x + 1;\n RAISE NOTICE 'f_get_x(%)', f_get_x();\n CALL f_print_x(f_get_x());\n ROLLBACK;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":33}}]}}}]} +== 080 +-- test in non-atomic context, except exception block is locally atomic +DO $$ +BEGIN + BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + EXCEPTION WHEN division_by_zero THEN + RAISE NOTICE '%', SQLERRM; + END; + ROLLBACK; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n BEGIN\n UPDATE t_test SET x = x + 1;\n RAISE NOTICE 'f_get_x(%)', f_get_x();\n CALL f_print_x(f_get_x());\n UPDATE t_test SET x = x + 1;\n RAISE NOTICE 'f_get_x(%)', f_get_x();\n CALL f_print_x(f_get_x());\n EXCEPTION WHEN division_by_zero THEN\n RAISE NOTICE '%', SQLERRM;\n END;\n ROLLBACK;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":75}}]}}}]} +== 081 +-- test in atomic context +BEGIN +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_BEGIN","location":-1}}}]} +== 082 +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n UPDATE t_test SET x = x + 1;\n RAISE NOTICE 'f_get_x(%)', f_get_x();\n CALL f_print_x(f_get_x());\n UPDATE t_test SET x = x + 1;\n RAISE NOTICE 'f_get_x(%)', f_get_x();\n CALL f_print_x(f_get_x());\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 083 +ROLLBACK +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_ROLLBACK","location":-1}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_control.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_control.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_control.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_control.test b/parser/testdata/parse/plpgsql_regress/plpgsql_control.test new file mode 100644 index 0000000..d127671 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_control.test @@ -0,0 +1,627 @@ +== 001 +|-- +-- Tests for PL/pgSQL control structures +|-- + +-- integer FOR loop + +do $$ +begin + -- basic case + for i in 1..3 loop + raise notice '1..3: i = %', i; + end loop; + -- with BY, end matches exactly + for i in 1..10 by 3 loop + raise notice '1..10 by 3: i = %', i; + end loop; + -- with BY, end does not match + for i in 1..11 by 3 loop + raise notice '1..11 by 3: i = %', i; + end loop; + -- zero iterations + for i in 1..0 by 3 loop + raise notice '1..0 by 3: i = %', i; + end loop; + -- REVERSE + for i in reverse 10..0 by 3 loop + raise notice 'reverse 10..0 by 3: i = %', i; + end loop; + -- potential overflow + for i in 2147483620..2147483647 by 10 loop + raise notice '2147483620..2147483647 by 10: i = %', i; + end loop; + -- potential overflow, reverse direction + for i in reverse -2147483620..-2147483647 by 10 loop + raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nbegin\n -- basic case\n for i in 1..3 loop\n raise notice '1..3: i = %', i;\n end loop;\n -- with BY, end matches exactly\n for i in 1..10 by 3 loop\n raise notice '1..10 by 3: i = %', i;\n end loop;\n -- with BY, end does not match\n for i in 1..11 by 3 loop\n raise notice '1..11 by 3: i = %', i;\n end loop;\n -- zero iterations\n for i in 1..0 by 3 loop\n raise notice '1..0 by 3: i = %', i;\n end loop;\n -- REVERSE\n for i in reverse 10..0 by 3 loop\n raise notice 'reverse 10..0 by 3: i = %', i;\n end loop;\n -- potential overflow\n for i in 2147483620..2147483647 by 10 loop\n raise notice '2147483620..2147483647 by 10: i = %', i;\n end loop;\n -- potential overflow, reverse direction\n for i in reverse -2147483620..-2147483647 by 10 loop\n raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":72}}]}}}]} +== 002 +-- BY can't be zero or negative +do $$ +begin + for i in 1..3 by 0 loop + raise notice '1..3 by 0: i = %', i; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nbegin\n for i in 1..3 by 0 loop\n raise notice '1..3 by 0: i = %', i;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":35}}]}}}]} +== 003 +do $$ +begin + for i in 1..3 by -1 loop + raise notice '1..3 by -1: i = %', i; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nbegin\n for i in 1..3 by -1 loop\n raise notice '1..3 by -1: i = %', i;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 004 +do $$ +begin + for i in reverse 1..3 by -1 loop + raise notice 'reverse 1..3 by -1: i = %', i; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nbegin\n for i in reverse 1..3 by -1 loop\n raise notice 'reverse 1..3 by -1: i = %', i;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 005 +-- CONTINUE statement + +create table conttesttbl(idx serial, v integer) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"conttesttbl","inh":true,"relpersistence":"p","location":36},"tableElts":[{"ColumnDef":{"colname":"idx","typeName":{"names":[{"String":{"sval":"serial"}}],"typemod":-1,"location":52},"is_local":true,"location":48}},{"ColumnDef":{"colname":"v","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":62},"is_local":true,"location":60}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 006 +insert into conttesttbl(v) values(10) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"conttesttbl","inh":true,"relpersistence":"p","location":12},"cols":[{"ResTarget":{"name":"v","location":24}}],"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":10},"location":34}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 007 +insert into conttesttbl(v) values(20) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"conttesttbl","inh":true,"relpersistence":"p","location":12},"cols":[{"ResTarget":{"name":"v","location":24}}],"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":20},"location":34}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 008 +insert into conttesttbl(v) values(30) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"conttesttbl","inh":true,"relpersistence":"p","location":12},"cols":[{"ResTarget":{"name":"v","location":24}}],"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":30},"location":34}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 009 +insert into conttesttbl(v) values(40) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"conttesttbl","inh":true,"relpersistence":"p","location":12},"cols":[{"ResTarget":{"name":"v","location":24}}],"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":40},"location":34}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 010 +create function continue_test1() returns void as $$ +declare _i integer = 0; _r record; +begin + raise notice '---1---'; + loop + _i := _i + 1; + raise notice '%', _i; + continue when _i < 10; + exit; + end loop; + + raise notice '---2---'; + <> + loop + _i := _i - 1; + loop + raise notice '%', _i; + continue lbl when _i > 0; + exit lbl; + end loop; + end loop; + + raise notice '---3---'; + <> + while _i < 10 loop + _i := _i + 1; + continue the_loop when _i % 2 = 0; + raise notice '%', _i; + end loop; + + raise notice '---4---'; + for _i in 1..10 loop + begin + -- applies to outer loop, not the nested begin block + continue when _i < 5; + raise notice '%', _i; + end; + end loop; + + raise notice '---5---'; + for _r in select * from conttesttbl loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---6---'; + for _r in execute 'select * from conttesttbl' loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---7---'; + <> + for _i in 1..3 loop + continue looplabel when _i = 2; + raise notice '%', _i; + end loop; + + raise notice '---8---'; + _i := 1; + while _i <= 3 loop + raise notice '%', _i; + _i := _i + 1; + continue when _i = 3; + end loop; + + raise notice '---9---'; + for _r in select * from conttesttbl order by v limit 1 loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---10---'; + for _r in execute 'select * from conttesttbl order by v limit 1' loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---11---'; + <> + for _i in 1..2 loop + raise notice 'outer %', _i; + <> + for _j in 1..3 loop + continue outerlooplabel when _j = 2; + raise notice 'inner %', _j; + end loop; + end loop; +end; $$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"continue_test1"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":41},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare _i integer = 0; _r record;\nbegin\n raise notice '---1---';\n loop\n _i := _i + 1;\n raise notice '%', _i;\n continue when _i \u003c 10;\n exit;\n end loop;\n\n raise notice '---2---';\n \u003c\u003clbl\u003e\u003e\n loop\n _i := _i - 1;\n loop\n raise notice '%', _i;\n continue lbl when _i \u003e 0;\n exit lbl;\n end loop;\n end loop;\n\n raise notice '---3---';\n \u003c\u003cthe_loop\u003e\u003e\n while _i \u003c 10 loop\n _i := _i + 1;\n continue the_loop when _i % 2 = 0;\n raise notice '%', _i;\n end loop;\n\n raise notice '---4---';\n for _i in 1..10 loop\n begin\n -- applies to outer loop, not the nested begin block\n continue when _i \u003c 5;\n raise notice '%', _i;\n end;\n end loop;\n\n raise notice '---5---';\n for _r in select * from conttesttbl loop\n continue when _r.v \u003c= 20;\n raise notice '%', _r.v;\n end loop;\n\n raise notice '---6---';\n for _r in execute 'select * from conttesttbl' loop\n continue when _r.v \u003c= 20;\n raise notice '%', _r.v;\n end loop;\n\n raise notice '---7---';\n \u003c\u003clooplabel\u003e\u003e\n for _i in 1..3 loop\n continue looplabel when _i = 2;\n raise notice '%', _i;\n end loop;\n\n raise notice '---8---';\n _i := 1;\n while _i \u003c= 3 loop\n raise notice '%', _i;\n _i := _i + 1;\n continue when _i = 3;\n end loop;\n\n raise notice '---9---';\n for _r in select * from conttesttbl order by v limit 1 loop\n raise notice '%', _r.v;\n continue;\n end loop;\n\n raise notice '---10---';\n for _r in execute 'select * from conttesttbl order by v limit 1' loop\n raise notice '%', _r.v;\n continue;\n end loop;\n\n raise notice '---11---';\n \u003c\u003couterlooplabel\u003e\u003e\n for _i in 1..2 loop\n raise notice 'outer %', _i;\n \u003c\u003cinnerlooplabel\u003e\u003e\n for _j in 1..3 loop\n continue outerlooplabel when _j = 2;\n raise notice 'inner %', _j;\n end loop;\n end loop;\nend; "}}]}},"defaction":"DEFELEM_UNSPEC","location":46}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":1874}}]}}}]} +== 011 +select continue_test1() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"continue_test1"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 012 +-- should fail: CONTINUE is only legal inside a loop +create function continue_error1() returns void as $$ +begin + begin + continue; + end; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"continue_error1"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":95},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n begin\n continue;\n end;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":100}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":157}}]}}}]} +== 013 +-- should fail: unlabeled EXIT is only legal inside a loop +create function exit_error1() returns void as $$ +begin + begin + exit; + end; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"exit_error1"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":97},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n begin\n exit;\n end;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":102}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":155}}]}}}]} +== 014 +-- should fail: no such label +create function continue_error2() returns void as $$ +begin + begin + loop + continue no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"continue_error2"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":72},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n begin\n loop\n continue no_such_label;\n end loop;\n end;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":77}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":183}}]}}}]} +== 015 +-- should fail: no such label +create function exit_error2() returns void as $$ +begin + begin + loop + exit no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"exit_error2"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":68},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n begin\n loop\n exit no_such_label;\n end loop;\n end;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":73}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":175}}]}}}]} +== 016 +-- should fail: CONTINUE can't reference the label of a named block +create function continue_error3() returns void as $$ +begin + <> + begin + loop + continue begin_block1; + end loop; + end; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"continue_error3"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":110},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n \u003c\u003cbegin_block1\u003e\u003e\n begin\n loop\n continue begin_block1;\n end loop;\n end;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":115}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":241}}]}}}]} +== 017 +-- On the other hand, EXIT *can* reference the label of a named block +create function exit_block1() returns void as $$ +begin + <> + begin + loop + exit begin_block1; + raise exception 'should not get here'; + end loop; + end; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"exit_block1"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":108},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n \u003c\u003cbegin_block1\u003e\u003e\n begin\n loop\n exit begin_block1;\n raise exception 'should not get here';\n end loop;\n end;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":113}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":286}}]}}}]} +== 018 +select exit_block1() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"exit_block1"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 019 +-- verbose end block and end loop +create function end_label1() returns void as $$ +<> +begin + <> + for i in 1 .. 10 loop + raise notice 'i = %', i; + exit flbl1; + end loop flbl1; + <> + for j in 1 .. 10 loop + raise notice 'j = %', j; + exit flbl2; + end loop; +end blbl; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"end_label1"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":71},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\n\u003c\u003cblbl\u003e\u003e\nbegin\n \u003c\u003cflbl1\u003e\u003e\n for i in 1 .. 10 loop\n raise notice 'i = %', i;\n exit flbl1;\n end loop flbl1;\n \u003c\u003cflbl2\u003e\u003e\n for j in 1 .. 10 loop\n raise notice 'j = %', j;\n exit flbl2;\n end loop;\nend blbl;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":76}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":302}}]}}}]} +== 020 +select end_label1() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"end_label1"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 021 +-- should fail: undefined end label +create function end_label2() returns void as $$ +begin + for _i in 1 .. 10 loop + exit; + end loop flbl1; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"end_label2"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":73},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n for _i in 1 .. 10 loop\n exit;\n end loop flbl1;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":78}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":151}}]}}}]} +== 022 +-- should fail: end label does not match start label +create function end_label3() returns void as $$ +<> +begin + <> + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"end_label3"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":90},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\n\u003c\u003couter_label\u003e\u003e\nbegin\n \u003c\u003cinner_label\u003e\u003e\n for _i in 1 .. 10 loop\n exit;\n end loop outer_label;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":95}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":208}}]}}}]} +== 023 +-- should fail: end label on a block without a start label +create function end_label4() returns void as $$ +<> +begin + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"end_label4"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":96},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\n\u003c\u003couter_label\u003e\u003e\nbegin\n for _i in 1 .. 10 loop\n exit;\n end loop outer_label;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":101}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":196}}]}}}]} +== 024 +-- unlabeled exit matches no blocks +do $$ +begin +for i in 1..10 loop + <> + begin + begin -- unlabeled block + exit; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; +end loop; +raise notice 'should get here'; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nbegin\nfor i in 1..10 loop\n \u003c\u003cinnerblock\u003e\u003e\n begin\n begin -- unlabeled block\n exit;\n raise notice 'should not get here';\n end;\n raise notice 'should not get here, either';\n end;\n raise notice 'nor here';\nend loop;\nraise notice 'should get here';\nend"}},"defaction":"DEFELEM_UNSPEC","location":39}}]}}}]} +== 025 +-- check exit out of an unlabeled block to a labeled one +do $$ +<> +begin + <> + begin + <> + begin + begin -- unlabeled block + exit innerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; + end; + raise notice 'should get here'; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\n\u003c\u003couterblock\u003e\u003e\nbegin\n \u003c\u003cinnerblock\u003e\u003e\n begin\n \u003c\u003cmoreinnerblock\u003e\u003e\n begin\n begin -- unlabeled block\n exit innerblock;\n raise notice 'should not get here';\n end;\n raise notice 'should not get here, either';\n end;\n raise notice 'nor here';\n end;\n raise notice 'should get here';\nend"}},"defaction":"DEFELEM_UNSPEC","location":60}}]}}}]} +== 026 +-- check exit out of outermost block +do $$ +<> +begin + <> + begin + exit outerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\n\u003c\u003couterblock\u003e\u003e\nbegin\n \u003c\u003cinnerblock\u003e\u003e\n begin\n exit outerblock;\n raise notice 'should not get here';\n end;\n raise notice 'should not get here, either';\nend"}},"defaction":"DEFELEM_UNSPEC","location":40}}]}}}]} +== 027 +-- unlabeled exit does match a while loop +do $$ +begin + <> + while 1 > 0 loop + <> + while 1 > 0 loop + <> + while 1 > 0 loop + exit; + raise notice 'should not get here'; + end loop; + raise notice 'should get here'; + exit outermostwhile; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'should get here, too'; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nbegin\n \u003c\u003coutermostwhile\u003e\u003e\n while 1 \u003e 0 loop\n \u003c\u003couterwhile\u003e\u003e\n while 1 \u003e 0 loop\n \u003c\u003cinnerwhile\u003e\u003e\n while 1 \u003e 0 loop\n exit;\n raise notice 'should not get here';\n end loop;\n raise notice 'should get here';\n exit outermostwhile;\n raise notice 'should not get here, either';\n end loop;\n raise notice 'nor here';\n end loop;\n raise notice 'should get here, too';\nend"}},"defaction":"DEFELEM_UNSPEC","location":45}}]}}}]} +== 028 +-- check exit out of an unlabeled while to a labeled one +do $$ +begin + <> + while 1 > 0 loop + while 1 > 0 loop + exit outerwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'should get here'; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nbegin\n \u003c\u003couterwhile\u003e\u003e\n while 1 \u003e 0 loop\n while 1 \u003e 0 loop\n exit outerwhile;\n raise notice 'should not get here';\n end loop;\n raise notice 'should not get here, either';\n end loop;\n raise notice 'should get here';\nend"}},"defaction":"DEFELEM_UNSPEC","location":60}}]}}}]} +== 029 +-- continue to an outer while +do $$ +declare i int := 0; +begin + <> + while i < 2 loop + raise notice 'outermostwhile, i = %', i; + i := i + 1; + <> + while 1 > 0 loop + <> + while 1 > 0 loop + continue outermostwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'out of outermostwhile, i = %', i; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare i int := 0;\nbegin\n \u003c\u003coutermostwhile\u003e\u003e\n while i \u003c 2 loop\n raise notice 'outermostwhile, i = %', i;\n i := i + 1;\n \u003c\u003couterwhile\u003e\u003e\n while 1 \u003e 0 loop\n \u003c\u003cinnerwhile\u003e\u003e\n while 1 \u003e 0 loop\n continue outermostwhile;\n raise notice 'should not get here';\n end loop;\n raise notice 'should not get here, either';\n end loop;\n raise notice 'nor here';\n end loop;\n raise notice 'out of outermostwhile, i = %', i;\nend"}},"defaction":"DEFELEM_UNSPEC","location":33}}]}}}]} +== 030 +-- return out of a while +create function return_from_while() returns int language plpgsql as $$ +declare i int := 0; +begin + while i < 10 loop + if i > 2 then + return i; + end if; + i := i + 1; + end loop; + return null; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"return_from_while"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":69},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":73}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare i int := 0;\nbegin\n while i \u003c 10 loop\n if i \u003e 2 then\n return i;\n end if;\n i := i + 1;\n end loop;\n return null;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":90}}]}}}]} +== 031 +select return_from_while() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"return_from_while"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 032 +-- using list of scalars in fori and fore stmts +create function for_vect() returns void as $proc$ +<>declare a integer; b varchar; c varchar; r record; +begin + -- fori + for i in 1 .. 3 loop + raise notice '%', i; + end loop; + -- fore with record var + for r in select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs loop + raise notice '% % %', r.aa, r.bb, r.cc; + end loop; + -- fore with single scalar + for a in select gs from generate_series(1,4) gs loop + raise notice '%', a; + end loop; + -- fore with multiple scalars + for a,b,c in select gs, 'BB','CC' from generate_series(1,4) gs loop + raise notice '% % %', a, b, c; + end loop; + -- using qualified names in fors, fore is enabled, disabled only for fori + for lbl.a, lbl.b, lbl.c in execute $$select gs, 'bb','cc' from generate_series(1,4) gs$$ loop + raise notice '% % %', a, b, c; + end loop; +end; +$proc$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"for_vect"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":83},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\n\u003c\u003clbl\u003e\u003edeclare a integer; b varchar; c varchar; r record;\nbegin\n -- fori\n for i in 1 .. 3 loop\n raise notice '%', i;\n end loop;\n -- fore with record var\n for r in select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs loop\n raise notice '% % %', r.aa, r.bb, r.cc;\n end loop;\n -- fore with single scalar\n for a in select gs from generate_series(1,4) gs loop\n raise notice '%', a;\n end loop;\n -- fore with multiple scalars\n for a,b,c in select gs, 'BB','CC' from generate_series(1,4) gs loop\n raise notice '% % %', a, b, c;\n end loop;\n -- using qualified names in fors, fore is enabled, disabled only for fori\n for lbl.a, lbl.b, lbl.c in execute $$select gs, 'bb','cc' from generate_series(1,4) gs$$ loop\n raise notice '% % %', a, b, c;\n end loop;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":88}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":900}}]}}}]} +== 033 +select for_vect() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"for_vect"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 034 +-- CASE statement + +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; + b int = 1; +begin + case $1 + when 1 then + return 'one'; + when 2 then + return 'two'; + when 3,4,3+5 then + return 'three, four or eight'; + when a then + return 'ten'; + when a+b, a+b+1 then + return 'eleven, twelve'; + end case; +end; +$$ language plpgsql immutable +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"case_test"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int8"}}],"typemod":-1,"location":56},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":72},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare a int = 10;\n b int = 1;\nbegin\n case $1\n when 1 then\n return 'one';\n when 2 then\n return 'two';\n when 3,4,3+5 then\n return 'three, four or eight';\n when a then\n return 'ten';\n when a+b, a+b+1 then\n return 'eleven, twelve';\n end case;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":77}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":381}},{"DefElem":{"defname":"volatility","arg":{"String":{"sval":"immutable"}},"defaction":"DEFELEM_UNSPEC","location":398}}]}}}]} +== 035 +select case_test(1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 036 +select case_test(2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 037 +select case_test(3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":3},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 038 +select case_test(4) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":4},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 039 +select case_test(5) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":5},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 040 +-- fails +select case_test(8) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":8},"location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":16}},"location":16}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 041 +select case_test(10) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 042 +select case_test(11) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":11},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 043 +select case_test(12) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":12},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 044 +select case_test(13) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":13},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 045 +-- fails + +create or replace function catch() returns void as $$ +begin + raise notice '%', case_test(6); +exception + when case_not_found then + raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM; +end +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"catch"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":53},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n raise notice '%', case_test(6);\nexception\n when case_not_found then\n raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":58}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":213}}]}}}]} +== 046 +select catch() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"catch"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 047 +-- test the searched variant too, as well as ELSE +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; +begin + case + when $1 = 1 then + return 'one'; + when $1 = a + 2 then + return 'twelve'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"case_test"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int8"}}],"typemod":-1,"location":87},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":103},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare a int = 10;\nbegin\n case\n when $1 = 1 then\n return 'one';\n when $1 = a + 2 then\n return 'twelve';\n else\n return 'other';\n end case;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":108}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":287}},{"DefElem":{"defname":"volatility","arg":{"String":{"sval":"immutable"}},"defaction":"DEFELEM_UNSPEC","location":304}}]}}}]} +== 048 +select case_test(1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 049 +select case_test(2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 050 +select case_test(12) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":12},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 051 +select case_test(13) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_test"}}],"args":[{"A_Const":{"ival":{"ival":13},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 052 +-- test line comment between WHEN and THEN +create or replace function case_comment(int) returns text as $$ +begin + case $1 + when 1 -- comment before THEN + then return 'one'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"case_comment"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":83},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":96},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n case $1\n when 1 -- comment before THEN\n then return 'one';\n else\n return 'other';\n end case;\nend;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":101}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":233}},{"DefElem":{"defname":"volatility","arg":{"String":{"sval":"immutable"}},"defaction":"DEFELEM_UNSPEC","location":250}}]}}}]} +== 053 +select case_comment(1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"case_comment"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":20}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_copy.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_copy.test b/parser/testdata/parse/plpgsql_regress/plpgsql_copy.test new file mode 100644 index 0000000..2788c56 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_copy.test @@ -0,0 +1,21 @@ +== 001 +-- directory paths are passed to us in environment variables + +-- set up file names to use + +CREATE TABLE copy1 (a int, b float); + +-- COPY TO/FROM not authorized from client. +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 TO stdout; +END; +$$; +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 FROM stdin; +-- +ERROR: "unterminated dollar-quoted string at or near \"$$\nBEGIN\n COPY copy1 FROM stdin;\"" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_domain.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_domain.test b/parser/testdata/parse/plpgsql_regress/plpgsql_domain.test new file mode 100644 index 0000000..77bf696 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_domain.test @@ -0,0 +1,483 @@ +== 001 +|-- +-- Tests for PL/pgSQL's behavior with domain types +|-- + +CREATE DOMAIN booltrue AS bool CHECK (VALUE IS TRUE OR VALUE IS NULL) +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"booltrue"}}],"typeName":{"names":[{"String":{"sval":"bool"}}],"typemod":-1,"location":84},"constraints":[{"Constraint":{"contype":"CONSTR_CHECK","initially_valid":true,"raw_expr":{"BoolExpr":{"boolop":"OR_EXPR","args":[{"BooleanTest":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":96}},"booltesttype":"IS_TRUE","location":102}},{"NullTest":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":113}},"nulltesttype":"IS_NULL","location":119}}],"location":110}},"location":89}}]}}}]} +== 002 +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_argresult_booltrue"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"booltrue"}}],"typemod":-1,"location":42},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"bool"}}],"typemod":-1,"location":54},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"booltrue"}}],"typemod":-1,"location":68},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn y;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":77}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":106}}]}}}]} +== 003 +SELECT * FROM test_argresult_booltrue(true, true) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_booltrue"}}],"args":[{"A_Const":{"boolval":{"boolval":true},"location":38}},{"A_Const":{"boolval":{"boolval":true},"location":44}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 004 +SELECT * FROM test_argresult_booltrue(false, true) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_booltrue"}}],"args":[{"A_Const":{"boolval":{},"location":38}},{"A_Const":{"boolval":{"boolval":true},"location":45}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 005 +SELECT * FROM test_argresult_booltrue(true, false) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_booltrue"}}],"args":[{"A_Const":{"boolval":{"boolval":true},"location":38}},{"A_Const":{"boolval":{},"location":44}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 006 +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $$ +declare v booltrue := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_assign_booltrue"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"bool"}}],"typemod":-1,"location":39},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"bool"}}],"typemod":-1,"location":47},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"booltrue"}}],"typemod":-1,"location":61},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare v booltrue := x;\nbegin\nv := y;\nreturn v;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":70}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":132}}]}}}]} +== 007 +SELECT * FROM test_assign_booltrue(true, true) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_booltrue"}}],"args":[{"A_Const":{"boolval":{"boolval":true},"location":35}},{"A_Const":{"boolval":{"boolval":true},"location":41}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 008 +SELECT * FROM test_assign_booltrue(false, true) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_booltrue"}}],"args":[{"A_Const":{"boolval":{},"location":35}},{"A_Const":{"boolval":{"boolval":true},"location":42}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 009 +SELECT * FROM test_assign_booltrue(true, false) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_booltrue"}}],"args":[{"A_Const":{"boolval":{"boolval":true},"location":35}},{"A_Const":{"boolval":{},"location":41}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 010 +CREATE DOMAIN uint2 AS int2 CHECK (VALUE >= 0) +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"uint2"}}],"typeName":{"names":[{"String":{"sval":"int2"}}],"typemod":-1,"location":23},"constraints":[{"Constraint":{"contype":"CONSTR_CHECK","initially_valid":true,"raw_expr":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"\u003e="}}],"lexpr":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":35}},"rexpr":{"A_Const":{"ival":{},"location":44}},"location":41}},"location":28}}]}}}]} +== 011 +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_argresult_uint2"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"location":39},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":48},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"location":61},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn y;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":67}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":96}}]}}}]} +== 012 +SELECT * FROM test_argresult_uint2(100::uint2, 50) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_uint2"}}],"args":[{"TypeCast":{"arg":{"A_Const":{"ival":{"ival":100},"location":35}},"typeName":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"location":40},"location":38}},{"A_Const":{"ival":{"ival":50},"location":47}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 013 +SELECT * FROM test_argresult_uint2(100::uint2, -50) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_uint2"}}],"args":[{"TypeCast":{"arg":{"A_Const":{"ival":{"ival":100},"location":35}},"typeName":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"location":40},"location":38}},{"A_Const":{"ival":{"ival":-50},"location":47}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 014 +SELECT * FROM test_argresult_uint2(null, 1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_uint2"}}],"args":[{"A_Const":{"isnull":true,"location":35}},{"A_Const":{"ival":{"ival":1},"location":41}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 015 +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $$ +declare v uint2 := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_assign_uint2"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":36},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":43},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"location":56},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare v uint2 := x;\nbegin\nv := y;\nreturn v;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":62}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":121}}]}}}]} +== 016 +SELECT * FROM test_assign_uint2(100, 50) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_uint2"}}],"args":[{"A_Const":{"ival":{"ival":100},"location":32}},{"A_Const":{"ival":{"ival":50},"location":37}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 017 +SELECT * FROM test_assign_uint2(100, -50) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_uint2"}}],"args":[{"A_Const":{"ival":{"ival":100},"location":32}},{"A_Const":{"ival":{"ival":-50},"location":37}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 018 +SELECT * FROM test_assign_uint2(-100, 50) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_uint2"}}],"args":[{"A_Const":{"ival":{"ival":-100},"location":32}},{"A_Const":{"ival":{"ival":50},"location":38}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 019 +SELECT * FROM test_assign_uint2(null, 1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_uint2"}}],"args":[{"A_Const":{"isnull":true,"location":32}},{"A_Const":{"ival":{"ival":1},"location":38}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 020 +CREATE DOMAIN nnint AS int NOT NULL +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"nnint"}}],"typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":23},"constraints":[{"Constraint":{"contype":"CONSTR_NOTNULL","location":27}}]}}}]} +== 021 +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_argresult_nnint"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"nnint"}}],"typemod":-1,"location":39},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":48},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"nnint"}}],"typemod":-1,"location":61},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn y;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":67}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":96}}]}}}]} +== 022 +SELECT * FROM test_argresult_nnint(10, 20) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_nnint"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":35}},{"A_Const":{"ival":{"ival":20},"location":39}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 023 +SELECT * FROM test_argresult_nnint(null, 20) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_nnint"}}],"args":[{"A_Const":{"isnull":true,"location":35}},{"A_Const":{"ival":{"ival":20},"location":41}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 024 +SELECT * FROM test_argresult_nnint(10, null) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_nnint"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":35}},{"A_Const":{"isnull":true,"location":39}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 025 +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $$ +declare v nnint := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_assign_nnint"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":36},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":43},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"nnint"}}],"typemod":-1,"location":56},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare v nnint := x;\nbegin\nv := y;\nreturn v;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":62}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":121}}]}}}]} +== 026 +SELECT * FROM test_assign_nnint(10, 20) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_nnint"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":32}},{"A_Const":{"ival":{"ival":20},"location":36}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 027 +SELECT * FROM test_assign_nnint(null, 20) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_nnint"}}],"args":[{"A_Const":{"isnull":true,"location":32}},{"A_Const":{"ival":{"ival":20},"location":38}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 028 +SELECT * FROM test_assign_nnint(10, null) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_nnint"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":32}},{"A_Const":{"isnull":true,"location":36}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 029 +|-- +-- Domains over arrays +|-- + +CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]) +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"ordered_pair_domain"}}],"typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":67},"constraints":[{"Constraint":{"contype":"CONSTR_CHECK","initially_valid":true,"raw_expr":{"BoolExpr":{"boolop":"AND_EXPR","args":[{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"="}}],"lexpr":{"FuncCall":{"funcname":[{"String":{"sval":"array_length"}}],"args":[{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":97}},{"A_Const":{"ival":{"ival":1},"location":103}}],"funcformat":"COERCE_EXPLICIT_CALL","location":84}},"rexpr":{"A_Const":{"ival":{"ival":2},"location":106}},"location":105}},{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"\u003c"}}],"lexpr":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":112}},"indirection":[{"A_Indices":{"uidx":{"A_Const":{"ival":{"ival":1},"location":118}}}}]}},"rexpr":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":123}},"indirection":[{"A_Indices":{"uidx":{"A_Const":{"ival":{"ival":2},"location":129}}}}]}},"location":121}}],"location":108}},"location":77}}]}}}]} +== 030 +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) + RETURNS ordered_pair_domain AS $$ +begin +return x; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_argresult_array_domain"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":46},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":77},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn x;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":97}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":126}}]}}}]} +== 031 +SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_array_domain"}}],"args":[{"TypeCast":{"arg":{"A_ArrayExpr":{"elements":[{"A_Const":{"ival":{},"location":48}},{"A_Const":{"ival":{"ival":100},"location":51}}],"location":42}},"typeName":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":57},"location":55}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 032 +SELECT * FROM test_argresult_array_domain(NULL::ordered_pair_domain) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_array_domain"}}],"args":[{"TypeCast":{"arg":{"A_Const":{"isnull":true,"location":42}},"typeName":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":48},"location":46}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 033 +CREATE FUNCTION test_argresult_array_domain_check_violation() + RETURNS ordered_pair_domain AS $$ +begin +return array[2,1]; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_argresult_array_domain_check_violation"}}],"returnType":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":72},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn array[2,1];\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":92}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":130}}]}}}]} +== 034 +SELECT * FROM test_argresult_array_domain_check_violation() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_array_domain_check_violation"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 035 +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $$ +declare v ordered_pair_domain := array[x, y]; +begin +v[2] := z; +return v; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_assign_ordered_pair_domain"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":50},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":57},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"z","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":64},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":77},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare v ordered_pair_domain := array[x, y];\nbegin\nv[2] := z;\nreturn v;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":97}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":183}}]}}}]} +== 036 +SELECT * FROM test_assign_ordered_pair_domain(1,2,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_pair_domain"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":46}},{"A_Const":{"ival":{"ival":2},"location":48}},{"A_Const":{"ival":{"ival":3},"location":50}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 037 +SELECT * FROM test_assign_ordered_pair_domain(1,2,0) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_pair_domain"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":46}},{"A_Const":{"ival":{"ival":2},"location":48}},{"A_Const":{"ival":{},"location":50}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 038 +SELECT * FROM test_assign_ordered_pair_domain(2,1,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_pair_domain"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":46}},{"A_Const":{"ival":{"ival":1},"location":48}},{"A_Const":{"ival":{"ival":3},"location":50}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 039 +|-- +-- Arrays of domains +|-- + +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_read_uint2_array"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":68},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"location":85},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn x[1];\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":91}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":123}}]}}}]} +== 040 +select test_read_uint2_array(array[1::uint2]) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_read_uint2_array"}}],"args":[{"A_ArrayExpr":{"elements":[{"TypeCast":{"arg":{"A_Const":{"ival":{"ival":1},"location":35}},"typeName":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"location":38},"location":36}}],"location":29}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 041 +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $$ +begin +return array[x, x]; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_build_uint2_array"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"int2"}}],"typemod":-1,"location":41},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"uint2"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":55},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn array[x, x];\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":63}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":102}}]}}}]} +== 042 +select test_build_uint2_array(1::int2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_build_uint2_array"}}],"args":[{"TypeCast":{"arg":{"A_Const":{"ival":{"ival":1},"location":30}},"typeName":{"names":[{"String":{"sval":"int2"}}],"typemod":-1,"location":33},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 043 +select test_build_uint2_array(-1::int2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_build_uint2_array"}}],"args":[{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"-"}}],"rexpr":{"TypeCast":{"arg":{"A_Const":{"ival":{"ival":1},"location":31}},"typeName":{"names":[{"String":{"sval":"int2"}}],"typemod":-1,"location":34},"location":32}},"location":30}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 044 +-- fail + +CREATE FUNCTION test_argresult_domain_array(x integer[]) + RETURNS ordered_pair_domain[] AS $$ +begin +return array[x::ordered_pair_domain, x::ordered_pair_domain]; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_argresult_domain_array"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":55},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":76},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn array[x::ordered_pair_domain, x::ordered_pair_domain];\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":98}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":179}}]}}}]} +== 045 +select test_argresult_domain_array(array[2,4]) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_domain_array"}}],"args":[{"A_ArrayExpr":{"elements":[{"A_Const":{"ival":{"ival":2},"location":41}},{"A_Const":{"ival":{"ival":4},"location":43}}],"location":35}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 046 +select test_argresult_domain_array(array[4,2]) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_domain_array"}}],"args":[{"A_ArrayExpr":{"elements":[{"A_Const":{"ival":{"ival":4},"location":41}},{"A_Const":{"ival":{"ival":2},"location":43}}],"location":35}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 047 +-- fail + +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) + RETURNS integer AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_argresult_domain_array2"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":56},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":87},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn x[1];\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":95}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":127}}]}}}]} +== 048 +select test_argresult_domain_array2(array[2,4]) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_domain_array2"}}],"args":[{"A_ArrayExpr":{"elements":[{"A_Const":{"ival":{"ival":2},"location":42}},{"A_Const":{"ival":{"ival":4},"location":44}}],"location":36}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 049 +select test_argresult_domain_array2(array[4,2]) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_domain_array2"}}],"args":[{"A_ArrayExpr":{"elements":[{"A_Const":{"ival":{"ival":4},"location":42}},{"A_Const":{"ival":{"ival":2},"location":44}}],"location":36}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 050 +-- fail + +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) + RETURNS ordered_pair_domain AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_argresult_array_domain_array"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":61},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":94},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn x[1];\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":114}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":146}}]}}}]} +== 051 +select test_argresult_array_domain_array(array[array[2,4]::ordered_pair_domain]) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_argresult_array_domain_array"}}],"args":[{"A_ArrayExpr":{"elements":[{"TypeCast":{"arg":{"A_ArrayExpr":{"elements":[{"A_Const":{"ival":{"ival":2},"location":53}},{"A_Const":{"ival":{"ival":4},"location":55}}],"location":47}},"typeName":{"names":[{"String":{"sval":"ordered_pair_domain"}}],"typemod":-1,"location":59},"location":57}}],"location":41}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 052 +|-- +-- Domains within composite +|-- + +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"nnint_container","relpersistence":"p","location":47},"coldeflist":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":70},"is_local":true,"location":67}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"nnint"}}],"typemod":-1,"location":78},"is_local":true,"location":75}}]}}}]} +== 053 +CREATE FUNCTION test_result_nnint_container(x int, y int) + RETURNS nnint_container AS $$ +begin +return row(x, y)::nnint_container; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_result_nnint_container"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":53},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"nnint_container"}}],"typemod":-1,"location":68},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn row(x, y)::nnint_container;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":84}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":138}}]}}}]} +== 054 +SELECT test_result_nnint_container(null, 3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_result_nnint_container"}}],"args":[{"A_Const":{"isnull":true,"location":35}},{"A_Const":{"ival":{"ival":3},"location":41}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 055 +SELECT test_result_nnint_container(3, null) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_result_nnint_container"}}],"args":[{"A_Const":{"ival":{"ival":3},"location":35}},{"A_Const":{"isnull":true,"location":38}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 056 +-- fail + +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container := row(x, y); +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_assign_nnint_container"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":55},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":62},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"z","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":69},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"nnint_container"}}],"typemod":-1,"location":84},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare v nnint_container := row(x, y);\nbegin\nv.f2 := z;\nreturn v;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":100}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":180}}]}}}]} +== 057 +SELECT * FROM test_assign_nnint_container(1,2,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_nnint_container"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":42}},{"A_Const":{"ival":{"ival":2},"location":44}},{"A_Const":{"ival":{"ival":3},"location":46}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 058 +SELECT * FROM test_assign_nnint_container(1,2,null) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_nnint_container"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":42}},{"A_Const":{"ival":{"ival":2},"location":44}},{"A_Const":{"isnull":true,"location":46}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 059 +SELECT * FROM test_assign_nnint_container(1,null,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_nnint_container"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":42}},{"A_Const":{"isnull":true,"location":44}},{"A_Const":{"ival":{"ival":3},"location":49}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 060 +-- Since core system allows this: +SELECT null::nnint_container +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"TypeCast":{"arg":{"A_Const":{"isnull":true,"location":41}},"typeName":{"names":[{"String":{"sval":"nnint_container"}}],"typemod":-1,"location":47},"location":45}},"location":41}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 061 +-- so should PL/PgSQL + +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container; +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_assign_nnint_container2"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":70},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":77},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"z","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":84},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"nnint_container"}}],"typemod":-1,"location":99},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare v nnint_container;\nbegin\nv.f2 := z;\nreturn v;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":115}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":182}}]}}}]} +== 062 +SELECT * FROM test_assign_nnint_container2(1,2,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_nnint_container2"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":43}},{"A_Const":{"ival":{"ival":2},"location":45}},{"A_Const":{"ival":{"ival":3},"location":47}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 063 +SELECT * FROM test_assign_nnint_container2(1,2,null) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_nnint_container2"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":43}},{"A_Const":{"ival":{"ival":2},"location":45}},{"A_Const":{"isnull":true,"location":47}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 064 +|-- +-- Domains of composite +|-- + +CREATE TYPE named_pair AS ( + i integer, + j integer +) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"named_pair","relpersistence":"p","location":43},"coldeflist":[{"ColumnDef":{"colname":"i","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":65},"is_local":true,"location":63}},{"ColumnDef":{"colname":"j","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":80},"is_local":true,"location":78}}]}}}]} +== 065 +CREATE DOMAIN ordered_named_pair AS named_pair CHECK((VALUE).i <= (VALUE).j) +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"ordered_named_pair"}}],"typeName":{"names":[{"String":{"sval":"named_pair"}}],"typemod":-1,"location":36},"constraints":[{"Constraint":{"contype":"CONSTR_CHECK","initially_valid":true,"raw_expr":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"\u003c="}}],"lexpr":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":54}},"indirection":[{"String":{"sval":"i"}}]}},"rexpr":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":67}},"indirection":[{"String":{"sval":"j"}}]}},"location":63}},"location":47}}]}}}]} +== 066 +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS integer AS $$ +begin +return p.i + p.j; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"read_ordered_named_pair"}}],"parameters":[{"FunctionParameter":{"name":"p","argType":{"names":[{"String":{"sval":"ordered_named_pair"}}],"typemod":-1,"location":42},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":70},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn p.i + p.j;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":78}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":115}}]}}}]} +== 067 +SELECT read_ordered_named_pair(row(1, 2)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"read_ordered_named_pair"}}],"args":[{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":35}},{"A_Const":{"ival":{"ival":2},"location":38}}],"row_format":"COERCE_EXPLICIT_CALL","location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 068 +SELECT read_ordered_named_pair(row(2, 1)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"read_ordered_named_pair"}}],"args":[{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":2},"location":35}},{"A_Const":{"ival":{"ival":1},"location":38}}],"row_format":"COERCE_EXPLICIT_CALL","location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 069 +-- fail + +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $$ +begin +return row(i, j); +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"build_ordered_named_pair"}}],"parameters":[{"FunctionParameter":{"name":"i","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":52},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"j","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":59},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_named_pair"}}],"typemod":-1,"location":72},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn row(i, j);\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":91}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":128}}]}}}]} +== 070 +SELECT build_ordered_named_pair(1,2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_named_pair"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":32}},{"A_Const":{"ival":{"ival":2},"location":34}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 071 +SELECT build_ordered_named_pair(2,1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_named_pair"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":32}},{"A_Const":{"ival":{"ival":1},"location":34}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 072 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) + RETURNS ordered_named_pair AS $$ +declare v ordered_named_pair := row(x, y); +begin +v.j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_assign_ordered_named_pair"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":58},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":65},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"z","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":72},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_named_pair"}}],"typemod":-1,"location":87},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare v ordered_named_pair := row(x, y);\nbegin\nv.j := z;\nreturn v;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":106}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":188}}]}}}]} +== 073 +SELECT * FROM test_assign_ordered_named_pair(1,2,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_named_pair"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":45}},{"A_Const":{"ival":{"ival":2},"location":47}},{"A_Const":{"ival":{"ival":3},"location":49}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 074 +SELECT * FROM test_assign_ordered_named_pair(1,2,0) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_named_pair"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":45}},{"A_Const":{"ival":{"ival":2},"location":47}},{"A_Const":{"ival":{},"location":49}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 075 +SELECT * FROM test_assign_ordered_named_pair(2,1,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_named_pair"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":45}},{"A_Const":{"ival":{"ival":1},"location":47}},{"A_Const":{"ival":{"ival":3},"location":49}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 076 +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $$ +begin +return array[row(i, j), row(i, j+1)]; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"build_ordered_named_pairs"}}],"parameters":[{"FunctionParameter":{"name":"i","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":44},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"j","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":51},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_named_pair"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":64},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\nreturn array[row(i, j), row(i, j+1)];\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":85}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":142}}]}}}]} +== 077 +SELECT build_ordered_named_pairs(1,2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_named_pairs"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":33}},{"A_Const":{"ival":{"ival":2},"location":35}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 078 +SELECT build_ordered_named_pairs(2,1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_named_pairs"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":33}},{"A_Const":{"ival":{"ival":1},"location":35}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 079 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) + RETURNS ordered_named_pair[] AS $$ +declare v ordered_named_pair[] := array[row(x, y)]; +begin +-- ideally this would work, but it doesn't yet: +-- v[1].j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_assign_ordered_named_pairs"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":59},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":66},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"z","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":73},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_named_pair"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":88},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare v ordered_named_pair[] := array[row(x, y)];\nbegin\n-- ideally this would work, but it doesn't yet:\n-- v[1].j := z;\nreturn v;\nend\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":109}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":254}}]}}}]} +== 080 +SELECT * FROM test_assign_ordered_named_pairs(1,2,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_named_pairs"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":46}},{"A_Const":{"ival":{"ival":2},"location":48}},{"A_Const":{"ival":{"ival":3},"location":50}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 081 +SELECT * FROM test_assign_ordered_named_pairs(2,1,3) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_named_pairs"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":46}},{"A_Const":{"ival":{"ival":1},"location":48}},{"A_Const":{"ival":{"ival":3},"location":50}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 082 +SELECT * FROM test_assign_ordered_named_pairs(1,2,0) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"test_assign_ordered_named_pairs"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":46}},{"A_Const":{"ival":{"ival":2},"location":48}},{"A_Const":{"ival":{},"location":50}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_misc.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_misc.test b/parser/testdata/parse/plpgsql_regress/plpgsql_misc.test new file mode 100644 index 0000000..f6b8829 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_misc.test @@ -0,0 +1,77 @@ +== 001 +|-- +-- Miscellaneous topics +|-- + +-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE +do +$$ + declare procedure int; -- check we still recognize non-keywords as vars + begin + create function test1() returns int + begin atomic + select 2 + 2; + end; + create or replace procedure test2(x int) + begin atomic + select x + 2; + end; + end +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\n declare procedure int; -- check we still recognize non-keywords as vars\n begin\n create function test1() returns int\n begin atomic\n select 2 + 2;\n end;\n create or replace procedure test2(x int)\n begin atomic\n select x + 2;\n end;\n end\n"}},"defaction":"DEFELEM_UNSPEC","location":98}}]}}}]} +== 002 +-- Test %TYPE and %ROWTYPE error cases +create table misc_table(f1 int) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"misc_table","inh":true,"relpersistence":"p","location":52},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":66},"is_local":true,"location":63}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 003 +do $$ declare x foo%type; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x foo%type; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 004 +do $$ declare x notice%type; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x notice%type; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 005 +-- covers unreserved-keyword case +do $$ declare x foo.bar%type; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x foo.bar%type; begin end "}},"defaction":"DEFELEM_UNSPEC","location":37}}]}}}]} +== 006 +do $$ declare x foo.bar.baz%type; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x foo.bar.baz%type; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 007 +do $$ declare x public.foo.bar%type; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x public.foo.bar%type; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 008 +do $$ declare x public.misc_table.zed%type; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x public.misc_table.zed%type; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 009 +do $$ declare x foo%rowtype; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x foo%rowtype; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 010 +do $$ declare x notice%rowtype; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x notice%rowtype; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 011 +-- covers unreserved-keyword case +do $$ declare x foo.bar%rowtype; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x foo.bar%rowtype; begin end "}},"defaction":"DEFELEM_UNSPEC","location":37}}]}}}]} +== 012 +do $$ declare x foo.bar.baz%rowtype; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x foo.bar.baz%rowtype; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 013 +do $$ declare x public.foo%rowtype; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x public.foo%rowtype; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 014 +do $$ declare x public.misc_table%rowtype; begin end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare x public.misc_table%rowtype; begin end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_record.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_record.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_record.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_record.test b/parser/testdata/parse/plpgsql_regress/plpgsql_record.test new file mode 100644 index 0000000..25a35f0 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_record.test @@ -0,0 +1,990 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of composite (record) variables +|-- + +create type two_int4s as (f1 int4, f2 int4) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"two_int4s","relpersistence":"p","location":82},"coldeflist":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"int4"}}],"typemod":-1,"location":99},"is_local":true,"location":96}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"int4"}}],"typemod":-1,"location":108},"is_local":true,"location":105}}]}}}]} +== 002 +create type more_int4s as (f0 text, f1 int4, f2 int4) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"more_int4s","relpersistence":"p","location":12},"coldeflist":[{"ColumnDef":{"colname":"f0","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":30},"is_local":true,"location":27}},{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":36}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"int4"}}],"typemod":-1,"location":48},"is_local":true,"location":45}}]}}}]} +== 003 +create type two_int8s as (q1 int8, q2 int8) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"two_int8s","relpersistence":"p","location":12},"coldeflist":[{"ColumnDef":{"colname":"q1","typeName":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":29},"is_local":true,"location":26}},{"ColumnDef":{"colname":"q2","typeName":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":38},"is_local":true,"location":35}}]}}}]} +== 004 +create type nested_int8s as (c1 two_int8s, c2 two_int8s) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"nested_int8s","relpersistence":"p","location":12},"coldeflist":[{"ColumnDef":{"colname":"c1","typeName":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":32},"is_local":true,"location":29}},{"ColumnDef":{"colname":"c2","typeName":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":46},"is_local":true,"location":43}}]}}}]} +== 005 +-- base-case return of a composite type +create function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1)::two_int8s; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"retc"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":61},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":74},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":84}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return row($1,1)::two_int8s; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":101}}]}}}]} +== 006 +select retc(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":12}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 007 +-- ok to return a matching record type +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8); end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"retc"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":71},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":84},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":94}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return row($1::int8, 1::int8); end "}}]}},"defaction":"DEFELEM_UNSPEC","location":111}}]}}}]} +== 008 +select retc(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":12}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 009 +-- we don't currently support implicit casting +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1); end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"retc"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":79},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":92},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":102}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return row($1,1); end "}}]}},"defaction":"DEFELEM_UNSPEC","location":119}}]}}}]} +== 010 +select retc(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":12}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 011 +-- nor extra columns +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8, 42); end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"retc"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":53},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":66},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":76}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return row($1::int8, 1::int8, 42); end "}}]}},"defaction":"DEFELEM_UNSPEC","location":93}}]}}}]} +== 012 +select retc(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":12}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 013 +-- same cases with an intermediate "record" variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8); return r; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"retc"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":85},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":98},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":108}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r record; begin r := row($1::int8, 1::int8); return r; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":125}}]}}}]} +== 014 +select retc(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":12}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 015 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,1); return r; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"retc"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":32},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":45},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":55}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r record; begin r := row($1,1); return r; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":72}}]}}}]} +== 016 +select retc(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":12}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 017 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"retc"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":32},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":45},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":55}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r record; begin r := row($1::int8, 1::int8, 42); return r; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":72}}]}}}]} +== 018 +select retc(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":12}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 019 +-- but, for mostly historical reasons, we do convert when assigning +-- to a named-composite-type variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"retc"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":138},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":151},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":161}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":178}}]}}}]} +== 020 +select retc(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":12}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 021 +do $$ declare c two_int8s; +begin c := row(1,2); raise notice 'c = %', c; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c two_int8s;\nbegin c := row(1,2); raise notice 'c = %', c; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 022 +do $$ declare c two_int8s; +begin for c in select 1,2 loop raise notice 'c = %', c; end loop; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c two_int8s;\nbegin for c in select 1,2 loop raise notice 'c = %', c; end loop; end"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 023 +do $$ declare c4 two_int4s; c8 two_int8s; +begin + c8 := row(1,2); + c4 := c8; + c8 := c4; + raise notice 'c4 = %', c4; + raise notice 'c8 = %', c8; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c4 two_int4s; c8 two_int8s;\nbegin\n c8 := row(1,2);\n c4 := c8;\n c8 := c4;\n raise notice 'c4 = %', c4;\n raise notice 'c8 = %', c8;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 024 +do $$ declare c two_int8s; d nested_int8s; +begin + c := row(1,2); + d := row(c, row(c.q1, c.q2+1)); + raise notice 'c = %, d = %', c, d; + c.q1 := 10; + d.c1 := row(11,12); + d.c2.q2 := 42; + raise notice 'c = %, d = %', c, d; + raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2; + raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens + raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c two_int8s; d nested_int8s;\nbegin\n c := row(1,2);\n d := row(c, row(c.q1, c.q2+1));\n raise notice 'c = %, d = %', c, d;\n c.q1 := 10;\n d.c1 := row(11,12);\n d.c2.q2 := 42;\n raise notice 'c = %, d = %', c, d;\n raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2;\n raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens\n raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 025 +-- block-qualified naming +do $$ <> declare c two_int8s; d nested_int8s; +begin + b.c := row(1,2); + b.d := row(b.c, row(b.c.q1, b.c.q2+1)); + raise notice 'b.c = %, b.d = %', b.c, b.d; + b.c.q1 := 10; + b.d.c1 := row(11,12); + b.d.c2.q2 := 42; + raise notice 'b.c = %, b.d = %', b.c, b.d; + raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2; + raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens + raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" \u003c\u003cb\u003e\u003e declare c two_int8s; d nested_int8s;\nbegin\n b.c := row(1,2);\n b.d := row(b.c, row(b.c.q1, b.c.q2+1));\n raise notice 'b.c = %, b.d = %', b.c, b.d;\n b.c.q1 := 10;\n b.d.c1 := row(11,12);\n b.d.c2.q2 := 42;\n raise notice 'b.c = %, b.d = %', b.c, b.d;\n raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2;\n raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens\n raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens\nend"}},"defaction":"DEFELEM_UNSPEC","location":29}}]}}}]} +== 026 +-- error cases +do $$ declare c two_int8s; begin c.x = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c two_int8s; begin c.x = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":18}}]}}}]} +== 027 +do $$ declare c nested_int8s; begin c.x = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c nested_int8s; begin c.x = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 028 +do $$ declare c nested_int8s; begin c.x.q1 = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c nested_int8s; begin c.x.q1 = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 029 +do $$ declare c nested_int8s; begin c.c2.x = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c nested_int8s; begin c.c2.x = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 030 +do $$ declare c nested_int8s; begin d.c2.x = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" declare c nested_int8s; begin d.c2.x = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 031 +do $$ <> declare c two_int8s; begin b.c.x = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" \u003c\u003cb\u003e\u003e declare c two_int8s; begin b.c.x = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 032 +do $$ <> declare c nested_int8s; begin b.c.x = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" \u003c\u003cb\u003e\u003e declare c nested_int8s; begin b.c.x = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 033 +do $$ <> declare c nested_int8s; begin b.c.x.q1 = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" \u003c\u003cb\u003e\u003e declare c nested_int8s; begin b.c.x.q1 = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 034 +do $$ <> declare c nested_int8s; begin b.c.c2.x = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" \u003c\u003cb\u003e\u003e declare c nested_int8s; begin b.c.c2.x = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 035 +do $$ <> declare c nested_int8s; begin b.d.c2.x = 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":" \u003c\u003cb\u003e\u003e declare c nested_int8s; begin b.d.c2.x = 1; end "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 036 +-- check passing composite result to another function +create function getq1(two_int8s) returns int8 language plpgsql as $$ +declare r two_int8s; begin r := $1; return r.q1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"getq1"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":76},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":95},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":100}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare r two_int8s; begin r := $1; return r.q1; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":117}}]}}}]} +== 037 +select getq1(retc(344)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getq1"}}],"args":[{"FuncCall":{"funcname":[{"String":{"sval":"retc"}}],"args":[{"A_Const":{"ival":{"ival":344},"location":18}}],"funcformat":"COERCE_EXPLICIT_CALL","location":13}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 038 +select getq1(row(1,2)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getq1"}}],"args":[{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":17}},{"A_Const":{"ival":{"ival":2},"location":19}}],"row_format":"COERCE_EXPLICIT_CALL","location":13}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 039 +do $$ +declare r1 two_int8s; r2 record; x int8; +begin + r1 := retc(345); + perform getq1(r1); + x := getq1(r1); + raise notice 'x = %', x; + r2 := retc(346); + perform getq1(r2); + x := getq1(r2); + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 two_int8s; r2 record; x int8;\nbegin\n r1 := retc(345);\n perform getq1(r1);\n x := getq1(r1);\n raise notice 'x = %', x;\n r2 := retc(346);\n perform getq1(r2);\n x := getq1(r2);\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 040 +-- check assignments of composites +do $$ +declare r1 two_int8s; r2 two_int8s; r3 record; r4 record; +begin + r1 := row(1,2); + raise notice 'r1 = %', r1; + r1 := r1; -- shouldn't do anything + raise notice 'r1 = %', r1; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := null; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := row(7,11)::two_int8s; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r3 := row(1,2); + r4 := r3; + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r1 := r3; + raise notice 'r1 = %', r1; + r4 := r1; + raise notice 'r4 = %', r4; + r4.q2 := r4.q2 + 1; -- r4's field names have changed + raise notice 'r4 = %', r4; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 two_int8s; r2 two_int8s; r3 record; r4 record;\nbegin\n r1 := row(1,2);\n raise notice 'r1 = %', r1;\n r1 := r1; -- shouldn't do anything\n raise notice 'r1 = %', r1;\n r2 := r1;\n raise notice 'r1 = %', r1;\n raise notice 'r2 = %', r2;\n r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage\n raise notice 'r1 = %', r1;\n raise notice 'r2 = %', r2;\n r1 := null;\n raise notice 'r1 = %', r1;\n raise notice 'r2 = %', r2;\n r1 := row(7,11)::two_int8s;\n r2 := r1;\n raise notice 'r1 = %', r1;\n raise notice 'r2 = %', r2;\n r3 := row(1,2);\n r4 := r3;\n raise notice 'r3 = %', r3;\n raise notice 'r4 = %', r4;\n r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage\n raise notice 'r3 = %', r3;\n raise notice 'r4 = %', r4;\n r1 := r3;\n raise notice 'r1 = %', r1;\n r4 := r1;\n raise notice 'r4 = %', r4;\n r4.q2 := r4.q2 + 1; -- r4's field names have changed\n raise notice 'r4 = %', r4;\nend"}},"defaction":"DEFELEM_UNSPEC","location":38}}]}}}]} +== 041 +-- fields of named-type vars read as null if uninitialized +do $$ +declare r1 two_int8s; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 two_int8s;\nbegin\n raise notice 'r1 = %', r1;\n raise notice 'r1.q1 = %', r1.q1;\n raise notice 'r1.q2 = %', r1.q2;\n raise notice 'r1 = %', r1;\nend"}},"defaction":"DEFELEM_UNSPEC","location":62}}]}}}]} +== 042 +do $$ +declare r1 two_int8s; +begin + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 two_int8s;\nbegin\n raise notice 'r1.q1 = %', r1.q1;\n raise notice 'r1.q2 = %', r1.q2;\n raise notice 'r1 = %', r1;\n raise notice 'r1.nosuchfield = %', r1.nosuchfield;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 043 +-- records, not so much +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 record;\nbegin\n raise notice 'r1 = %', r1;\n raise notice 'r1.f1 = %', r1.f1;\n raise notice 'r1.f2 = %', r1.f2;\n raise notice 'r1 = %', r1;\nend"}},"defaction":"DEFELEM_UNSPEC","location":27}}]}}}]} +== 044 +-- but OK if you assign first +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + r1 := row(1,2); + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 record;\nbegin\n raise notice 'r1 = %', r1;\n r1 := row(1,2);\n raise notice 'r1.f1 = %', r1.f1;\n raise notice 'r1.f2 = %', r1.f2;\n raise notice 'r1 = %', r1;\n raise notice 'r1.nosuchfield = %', r1.nosuchfield;\nend"}},"defaction":"DEFELEM_UNSPEC","location":33}}]}}}]} +== 045 +-- check %type with block-qualified variable names +do $$ +<> +declare + v int; + r two_int8s; + v1 v%type; + v2 blk.v%type; + r1 r%type; + r2 blk.r%type; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(r1); + raise notice '%', pg_typeof(r2); +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\n\u003c\u003cblk\u003e\u003e\ndeclare\n v int;\n r two_int8s;\n v1 v%type;\n v2 blk.v%type;\n r1 r%type;\n r2 blk.r%type;\nbegin\n raise notice '%', pg_typeof(v1);\n raise notice '%', pg_typeof(v2);\n raise notice '%', pg_typeof(r1);\n raise notice '%', pg_typeof(r2);\nend"}},"defaction":"DEFELEM_UNSPEC","location":54}}]}}}]} +== 046 +-- check that type record can be passed through %type +do $$ +declare r1 record; + r2 r1%type; +begin + r2 := row(1,2); + raise notice 'r2 = %', r2; + r2 := row(3,4,5); + raise notice 'r2 = %', r2; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 record;\n r2 r1%type;\nbegin\n r2 := row(1,2);\n raise notice 'r2 = %', r2;\n r2 := row(3,4,5);\n raise notice 'r2 = %', r2;\nend"}},"defaction":"DEFELEM_UNSPEC","location":57}}]}}}]} +== 047 +-- arrays of record are not supported at the moment +do $$ +declare r1 record[]; +begin +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 record[];\nbegin\nend"}},"defaction":"DEFELEM_UNSPEC","location":55}}]}}}]} +== 048 +do $$ +declare r1 record; + r2 r1%type[]; +begin +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r1 record;\n r2 r1%type[];\nbegin\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 049 +-- check repeated assignments to composite fields +create table some_table (id int, data text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"some_table","inh":true,"relpersistence":"p","location":63},"tableElts":[{"ColumnDef":{"colname":"id","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":78},"is_local":true,"location":75}},{"ColumnDef":{"colname":"data","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":88},"is_local":true,"location":83}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 050 +do $$ +declare r some_table; +begin + r := (23, 'skidoo'); + for i in 1 .. 10 loop + r.id := r.id + i; + r.data := r.data || ' ' || i; + end loop; + raise notice 'r = %', r; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r some_table;\nbegin\n r := (23, 'skidoo');\n for i in 1 .. 10 loop\n r.id := r.id + i;\n r.data := r.data || ' ' || i;\n end loop;\n raise notice 'r = %', r;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 051 +-- check behavior of function declared to return "record" + +create function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1); end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"returnsrecord"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":89},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"record"}}],"typemod":-1,"location":102},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":109}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return row($1,$1+1); end "}}]}},"defaction":"DEFELEM_UNSPEC","location":126}}]}}}]} +== 052 +select returnsrecord(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":21}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 053 +select * from returnsrecord(42) as r(x int, y int) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":28}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":37}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"is_local":true,"location":44}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 054 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":28}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":37}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"is_local":true,"location":44}},{"ColumnDef":{"colname":"z","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":53},"is_local":true,"location":51}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 055 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":15}},"location":15}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":36}}],"funcformat":"COERCE_EXPLICIT_CALL","location":22}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":47},"is_local":true,"location":45}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int8"}}],"typemod":-1,"location":54},"is_local":true,"location":52}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 056 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1); return r; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"returnsrecord"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":95},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"record"}}],"typemod":-1,"location":108},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":115}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r record; begin r := row($1,$1+1); return r; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":132}}]}}}]} +== 057 +select returnsrecord(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":21}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 058 +select * from returnsrecord(42) as r(x int, y int) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":28}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":37}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"is_local":true,"location":44}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 059 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":28}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":37}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"is_local":true,"location":44}},{"ColumnDef":{"colname":"z","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":53},"is_local":true,"location":51}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 060 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":15}},"location":15}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":36}}],"funcformat":"COERCE_EXPLICIT_CALL","location":22}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":47},"is_local":true,"location":45}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int8"}}],"typemod":-1,"location":54},"is_local":true,"location":52}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 061 +-- fail + +-- should work the same with a missing column in the actual result value +create table has_hole(f1 int, f2 int, f3 int) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"has_hole","inh":true,"relpersistence":"p","location":95},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":107},"is_local":true,"location":104}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":115},"is_local":true,"location":112}},{"ColumnDef":{"colname":"f3","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":123},"is_local":true,"location":120}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 062 +alter table has_hole drop column f2 +-- +{"version":170007,"stmts":[{"stmt":{"AlterTableStmt":{"relation":{"relname":"has_hole","inh":true,"relpersistence":"p","location":12},"cmds":[{"AlterTableCmd":{"subtype":"AT_DropColumn","name":"f2","behavior":"DROP_RESTRICT"}}],"objtype":"OBJECT_TABLE"}}}]} +== 063 +create or replace function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1)::has_hole; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"returnsrecord"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":41},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"record"}}],"typemod":-1,"location":54},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":61}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return row($1,$1+1)::has_hole; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":78}}]}}}]} +== 064 +select returnsrecord(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":21}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 065 +select * from returnsrecord(42) as r(x int, y int) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":28}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":37}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"is_local":true,"location":44}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 066 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":28}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":37}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"is_local":true,"location":44}},{"ColumnDef":{"colname":"z","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":53},"is_local":true,"location":51}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 067 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":15}},"location":15}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":36}}],"funcformat":"COERCE_EXPLICIT_CALL","location":22}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":47},"is_local":true,"location":45}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int8"}}],"typemod":-1,"location":54},"is_local":true,"location":52}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 068 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1)::has_hole; return r; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"returnsrecord"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":95},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"record"}}],"typemod":-1,"location":108},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":115}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r record; begin r := row($1,$1+1)::has_hole; return r; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":132}}]}}}]} +== 069 +select returnsrecord(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":21}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 070 +select * from returnsrecord(42) as r(x int, y int) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":28}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":37}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"is_local":true,"location":44}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 071 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":28}}],"funcformat":"COERCE_EXPLICIT_CALL","location":14}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"is_local":true,"location":37}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":46},"is_local":true,"location":44}},{"ColumnDef":{"colname":"z","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":53},"is_local":true,"location":51}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 072 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":15}},"location":15}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"returnsrecord"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":36}}],"funcformat":"COERCE_EXPLICIT_CALL","location":22}},{}]}}],"alias":{"aliasname":"r"},"coldeflist":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":47},"is_local":true,"location":45}},{"ColumnDef":{"colname":"y","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int8"}}],"typemod":-1,"location":54},"is_local":true,"location":52}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 073 +-- fail + +-- check access to a field of an argument declared "record" +create function getf1(x record) returns int language plpgsql as +$$ begin return x.f1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"getf1"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"record"}}],"typemod":-1,"location":93},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":109},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":113}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return x.f1; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":130}}]}}}]} +== 074 +select getf1(1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf1"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":13}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 075 +select getf1(row(1,2)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf1"}}],"args":[{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":17}},{"A_Const":{"ival":{"ival":2},"location":19}}],"row_format":"COERCE_EXPLICIT_CALL","location":13}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 076 +select getf1(row(1,2)::two_int4s) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf1"}}],"args":[{"TypeCast":{"arg":{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":17}},{"A_Const":{"ival":{"ival":2},"location":19}}],"row_format":"COERCE_EXPLICIT_CALL","location":13}},"typeName":{"names":[{"String":{"sval":"two_int4s"}}],"typemod":-1,"location":23},"location":21}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 077 +select getf1(row('foo',123,456)::more_int4s) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf1"}}],"args":[{"TypeCast":{"arg":{"RowExpr":{"args":[{"A_Const":{"sval":{"sval":"foo"},"location":17}},{"A_Const":{"ival":{"ival":123},"location":23}},{"A_Const":{"ival":{"ival":456},"location":27}}],"row_format":"COERCE_EXPLICIT_CALL","location":13}},"typeName":{"names":[{"String":{"sval":"more_int4s"}}],"typemod":-1,"location":33},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 078 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf1(row(1,2)::two_int8s) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf1"}}],"args":[{"TypeCast":{"arg":{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":115}},{"A_Const":{"ival":{"ival":2},"location":117}}],"row_format":"COERCE_EXPLICIT_CALL","location":111}},"typeName":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":121},"location":119}}],"funcformat":"COERCE_EXPLICIT_CALL","location":105}},"location":105}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 079 +select getf1(row(1,2)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf1"}}],"args":[{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":17}},{"A_Const":{"ival":{"ival":2},"location":19}}],"row_format":"COERCE_EXPLICIT_CALL","location":13}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 080 +-- this seemingly-equivalent case behaves a bit differently, +-- because the core parser's handling of $N symbols is simplistic +create function getf2(record) returns int language plpgsql as +$$ begin return $1.f2; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"getf2"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"record"}}],"typemod":-1,"location":149},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":165},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":169}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return $1.f2; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":186}}]}}}]} +== 081 +select getf2(row(1,2)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf2"}}],"args":[{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":17}},{"A_Const":{"ival":{"ival":2},"location":19}}],"row_format":"COERCE_EXPLICIT_CALL","location":13}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 082 +-- ideally would work, but does not +select getf2(row(1,2)::two_int4s) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf2"}}],"args":[{"TypeCast":{"arg":{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":53}},{"A_Const":{"ival":{"ival":2},"location":55}}],"row_format":"COERCE_EXPLICIT_CALL","location":49}},"typeName":{"names":[{"String":{"sval":"two_int4s"}}],"typemod":-1,"location":59},"location":57}}],"funcformat":"COERCE_EXPLICIT_CALL","location":43}},"location":43}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 083 +select getf2(row('foo',123,456)::more_int4s) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf2"}}],"args":[{"TypeCast":{"arg":{"RowExpr":{"args":[{"A_Const":{"sval":{"sval":"foo"},"location":17}},{"A_Const":{"ival":{"ival":123},"location":23}},{"A_Const":{"ival":{"ival":456},"location":27}}],"row_format":"COERCE_EXPLICIT_CALL","location":13}},"typeName":{"names":[{"String":{"sval":"more_int4s"}}],"typemod":-1,"location":33},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 084 +-- check behavior when assignment to FOR-loop variable requires coercion +do $$ +declare r two_int8s; +begin + for r in select i, i+1 from generate_series(1,4) i + loop + raise notice 'r = %', r; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r two_int8s;\nbegin\n for r in select i, i+1 from generate_series(1,4) i\n loop\n raise notice 'r = %', r;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":76}}]}}}]} +== 085 +-- check behavior when returning setof composite +create function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; + h has_hole; +begin + return next h; + r := (1,2); + h := (3,4); + return next r; + return next h; + return next row(5,6); + return next row(7,8)::has_hole; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"returnssetofholes"}}],"returnType":{"names":[{"String":{"sval":"has_hole"}}],"setof":true,"typemod":-1,"location":99},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":108}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare r record;\n h has_hole;\nbegin\n return next h;\n r := (1,2);\n h := (3,4);\n return next r;\n return next h;\n return next row(5,6);\n return next row(7,8)::has_hole;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":125}}]}}}]} +== 086 +select returnssetofholes() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"returnssetofholes"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 087 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; +begin + return next r; -- fails, not assigned yet +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"returnssetofholes"}}],"returnType":{"names":[{"String":{"sval":"has_hole"}}],"setof":true,"typemod":-1,"location":61},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":70}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare r record;\nbegin\n return next r; -- fails, not assigned yet\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":87}}]}}}]} +== 088 +select returnssetofholes() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"returnssetofholes"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 089 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +begin + return next row(1,2,3); -- fails +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"returnssetofholes"}}],"returnType":{"names":[{"String":{"sval":"has_hole"}}],"setof":true,"typemod":-1,"location":61},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":70}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n return next row(1,2,3); -- fails\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":87}}]}}}]} +== 090 +select returnssetofholes() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"returnssetofholes"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 091 +-- check behavior with changes of a named rowtype +create table mutable(f1 int, f2 text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":63},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":74},"is_local":true,"location":71}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":82},"is_local":true,"location":79}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 092 +create function sillyaddone(int) returns int language plpgsql as +$$ declare r mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"sillyaddone"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":28},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":41},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":45}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r mutable; begin r.f1 := $1; return r.f1 + 1; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":62}}]}}}]} +== 093 +select sillyaddone(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"sillyaddone"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":19}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 094 +-- test for change of type of column f1 should be here someday; +-- for now see plpgsql_cache test + +alter table mutable drop column f1 +-- +{"version":170007,"stmts":[{"stmt":{"AlterTableStmt":{"relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":111},"cmds":[{"AlterTableCmd":{"subtype":"AT_DropColumn","name":"f1","behavior":"DROP_RESTRICT"}}],"objtype":"OBJECT_TABLE"}}}]} +== 095 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddone(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"sillyaddone"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":117}}],"funcformat":"COERCE_EXPLICIT_CALL","location":105}},"location":105}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 096 +-- fail + +create function getf3(x mutable) returns int language plpgsql as +$$ begin return x.f3; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"getf3"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"mutable"}}],"typemod":-1,"location":33},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":50},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":54}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" begin return x.f3; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":71}}]}}}]} +== 097 +select getf3(null::mutable) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf3"}}],"args":[{"TypeCast":{"arg":{"A_Const":{"isnull":true,"location":13}},"typeName":{"names":[{"String":{"sval":"mutable"}}],"typemod":-1,"location":19},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 098 +-- doesn't work yet +alter table mutable add column f3 int +-- +{"version":170007,"stmts":[{"stmt":{"AlterTableStmt":{"relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":32},"cmds":[{"AlterTableCmd":{"subtype":"AT_AddColumn","def":{"ColumnDef":{"colname":"f3","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":54},"is_local":true,"location":51}},"behavior":"DROP_RESTRICT"}}],"objtype":"OBJECT_TABLE"}}}]} +== 099 +select getf3(null::mutable) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf3"}}],"args":[{"TypeCast":{"arg":{"A_Const":{"isnull":true,"location":13}},"typeName":{"names":[{"String":{"sval":"mutable"}}],"typemod":-1,"location":19},"location":17}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 100 +-- now it works +alter table mutable drop column f3 +-- +{"version":170007,"stmts":[{"stmt":{"AlterTableStmt":{"relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":28},"cmds":[{"AlterTableCmd":{"subtype":"AT_DropColumn","name":"f3","behavior":"DROP_RESTRICT"}}],"objtype":"OBJECT_TABLE"}}}]} +== 101 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf3(null::mutable) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"getf3"}}],"args":[{"TypeCast":{"arg":{"A_Const":{"isnull":true,"location":111}},"typeName":{"names":[{"String":{"sval":"mutable"}}],"typemod":-1,"location":117},"location":115}}],"funcformat":"COERCE_EXPLICIT_CALL","location":105}},"location":105}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 102 +-- fails again + +-- check behavior with creating/dropping a named rowtype +set check_function_bodies = off +-- +{"version":170007,"stmts":[{"stmt":{"VariableSetStmt":{"kind":"VAR_SET_VALUE","name":"check_function_bodies","args":[{"A_Const":{"sval":{"sval":"off"},"location":101}}]}}}]} +== 103 +-- else reference to nonexistent type fails + +create function sillyaddtwo(int) returns int language plpgsql as +$$ declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"sillyaddtwo"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":73},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":86},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":90}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":107}}]}}}]} +== 104 +reset check_function_bodies +-- +{"version":170007,"stmts":[{"stmt":{"VariableSetStmt":{"kind":"VAR_RESET","name":"check_function_bodies"}}}]} +== 105 +select sillyaddtwo(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"sillyaddtwo"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":19}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 106 +-- fail +create table mutable2(f1 int, f2 text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"mutable2","inh":true,"relpersistence":"p","location":21},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":33},"is_local":true,"location":30}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":41},"is_local":true,"location":38}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 107 +select sillyaddtwo(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"sillyaddtwo"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":19}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 108 +drop table mutable2 +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"List":{"items":[{"String":{"sval":"mutable2"}}]}}],"removeType":"OBJECT_TABLE","behavior":"DROP_RESTRICT"}}}]} +== 109 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddtwo(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"sillyaddtwo"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":117}}],"funcformat":"COERCE_EXPLICIT_CALL","location":105}},"location":105}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 110 +-- fail +create table mutable2(f0 text, f1 int, f2 text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"mutable2","inh":true,"relpersistence":"p","location":21},"tableElts":[{"ColumnDef":{"colname":"f0","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":33},"is_local":true,"location":30}},{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":42},"is_local":true,"location":39}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":50},"is_local":true,"location":47}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 111 +select sillyaddtwo(42) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"sillyaddtwo"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":19}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 112 +select sillyaddtwo(43) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"sillyaddtwo"}}],"args":[{"A_Const":{"ival":{"ival":43},"location":19}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 113 +-- check access to system columns in a record variable + +create function sillytrig() returns trigger language plpgsql as +$$begin + raise notice 'old.ctid = %', old.ctid; + raise notice 'old.tableoid = %', old.tableoid::regclass; + return new; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"sillytrig"}}],"returnType":{"names":[{"String":{"sval":"trigger"}}],"typemod":-1,"location":92},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":100}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"begin\n raise notice 'old.ctid = %', old.ctid;\n raise notice 'old.tableoid = %', old.tableoid::regclass;\n return new;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":117}}]}}}]} +== 114 +create trigger mutable_trig before update on mutable for each row +execute procedure sillytrig() +-- +{"version":170007,"stmts":[{"stmt":{"CreateTrigStmt":{"trigname":"mutable_trig","relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":45},"funcname":[{"String":{"sval":"sillytrig"}}],"row":true,"timing":2,"events":16}}}]} +== 115 +insert into mutable values ('foo'), ('bar') +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"sval":{"sval":"foo"},"location":28}}]}},{"List":{"items":[{"A_Const":{"sval":{"sval":"bar"},"location":37}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 116 +update mutable set f2 = f2 || ' baz' +-- +{"version":170007,"stmts":[{"stmt":{"UpdateStmt":{"relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":7},"targetList":[{"ResTarget":{"name":"f2","val":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"||"}}],"lexpr":{"ColumnRef":{"fields":[{"String":{"sval":"f2"}}],"location":24}},"rexpr":{"A_Const":{"sval":{"sval":" baz"},"location":30}},"location":27}},"location":19}}]}}}]} +== 117 +table mutable +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":-1}},"location":-1}}],"fromClause":[{"RangeVar":{"relname":"mutable","inh":true,"relpersistence":"p","location":6}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 118 +-- check returning a composite datum from a trigger + +create or replace function sillytrig() returns trigger language plpgsql as +$$begin + return row(new.*); +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"sillytrig"}}],"returnType":{"names":[{"String":{"sval":"trigger"}}],"typemod":-1,"location":100},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":108}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"begin\n return row(new.*);\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":125}}]}}}]} +== 119 +update mutable set f2 = f2 || ' baz' +-- +{"version":170007,"stmts":[{"stmt":{"UpdateStmt":{"relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":7},"targetList":[{"ResTarget":{"name":"f2","val":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"||"}}],"lexpr":{"ColumnRef":{"fields":[{"String":{"sval":"f2"}}],"location":24}},"rexpr":{"A_Const":{"sval":{"sval":" baz"},"location":30}},"location":27}},"location":19}}]}}}]} +== 120 +table mutable +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":-1}},"location":-1}}],"fromClause":[{"RangeVar":{"relname":"mutable","inh":true,"relpersistence":"p","location":6}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 121 +create or replace function sillytrig() returns trigger language plpgsql as +$$declare r record; +begin + r := row(new.*); + return r; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"sillytrig"}}],"returnType":{"names":[{"String":{"sval":"trigger"}}],"typemod":-1,"location":47},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":55}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"declare r record;\nbegin\n r := row(new.*);\n return r;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":72}}]}}}]} +== 122 +update mutable set f2 = f2 || ' baz' +-- +{"version":170007,"stmts":[{"stmt":{"UpdateStmt":{"relation":{"relname":"mutable","inh":true,"relpersistence":"p","location":7},"targetList":[{"ResTarget":{"name":"f2","val":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"||"}}],"lexpr":{"ColumnRef":{"fields":[{"String":{"sval":"f2"}}],"location":24}},"rexpr":{"A_Const":{"sval":{"sval":" baz"},"location":30}},"location":27}},"location":19}}]}}}]} +== 123 +table mutable +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":-1}},"location":-1}}],"fromClause":[{"RangeVar":{"relname":"mutable","inh":true,"relpersistence":"p","location":6}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 124 +|-- +-- Domains of composite +|-- + +create domain ordered_int8s as two_int8s check((value).q1 <= (value).q2) +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"ordered_int8s"}}],"typeName":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":62},"constraints":[{"Constraint":{"contype":"CONSTR_CHECK","initially_valid":true,"raw_expr":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"\u003c="}}],"lexpr":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":79}},"indirection":[{"String":{"sval":"q1"}}]}},"rexpr":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":93}},"indirection":[{"String":{"sval":"q2"}}]}},"location":89}},"location":72}}]}}}]} +== 125 +create function read_ordered_int8s(p ordered_int8s) returns int8 as $$ +begin return p.q1 + p.q2; end +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"read_ordered_int8s"}}],"parameters":[{"FunctionParameter":{"name":"p","argType":{"names":[{"String":{"sval":"ordered_int8s"}}],"typemod":-1,"location":37},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":60},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin return p.q1 + p.q2; end\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":65}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":104}}]}}}]} +== 126 +select read_ordered_int8s(row(1, 2)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"read_ordered_int8s"}}],"args":[{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":1},"location":30}},{"A_Const":{"ival":{"ival":2},"location":33}}],"row_format":"COERCE_EXPLICIT_CALL","location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 127 +select read_ordered_int8s(row(2, 1)) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"read_ordered_int8s"}}],"args":[{"RowExpr":{"args":[{"A_Const":{"ival":{"ival":2},"location":30}},{"A_Const":{"ival":{"ival":1},"location":33}}],"row_format":"COERCE_EXPLICIT_CALL","location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 128 +-- fail + +create function build_ordered_int8s(i int8, j int8) returns ordered_int8s as $$ +begin return row(i,j); end +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"build_ordered_int8s"}}],"parameters":[{"FunctionParameter":{"name":"i","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":47},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"j","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":55},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_int8s"}}],"typemod":-1,"location":69},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin return row(i,j); end\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":83}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":119}}]}}}]} +== 129 +select build_ordered_int8s(1,2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":27}},{"A_Const":{"ival":{"ival":2},"location":29}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 130 +select build_ordered_int8s(2,1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":27}},{"A_Const":{"ival":{"ival":1},"location":29}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 131 +-- fail + +create function build_ordered_int8s_2(i int8, j int8) returns ordered_int8s as $$ +declare r record; begin r := row(i,j); return r; end +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"build_ordered_int8s_2"}}],"parameters":[{"FunctionParameter":{"name":"i","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":49},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"j","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":57},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_int8s"}}],"typemod":-1,"location":71},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare r record; begin r := row(i,j); return r; end\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":85}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":147}}]}}}]} +== 132 +select build_ordered_int8s_2(1,2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s_2"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":29}},{"A_Const":{"ival":{"ival":2},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 133 +select build_ordered_int8s_2(2,1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s_2"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":29}},{"A_Const":{"ival":{"ival":1},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 134 +-- fail + +create function build_ordered_int8s_3(i int8, j int8) returns ordered_int8s as $$ +declare r two_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"build_ordered_int8s_3"}}],"parameters":[{"FunctionParameter":{"name":"i","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":49},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"j","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":57},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_int8s"}}],"typemod":-1,"location":71},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare r two_int8s; begin r := row(i,j); return r; end\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":85}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":150}}]}}}]} +== 135 +select build_ordered_int8s_3(1,2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s_3"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":29}},{"A_Const":{"ival":{"ival":2},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 136 +select build_ordered_int8s_3(2,1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s_3"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":29}},{"A_Const":{"ival":{"ival":1},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 137 +-- fail + +create function build_ordered_int8s_4(i int8, j int8) returns ordered_int8s as $$ +declare r ordered_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"build_ordered_int8s_4"}}],"parameters":[{"FunctionParameter":{"name":"i","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":49},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"j","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":57},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_int8s"}}],"typemod":-1,"location":71},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare r ordered_int8s; begin r := row(i,j); return r; end\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":85}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":154}}]}}}]} +== 138 +select build_ordered_int8s_4(1,2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s_4"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":29}},{"A_Const":{"ival":{"ival":2},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 139 +select build_ordered_int8s_4(2,1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s_4"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":29}},{"A_Const":{"ival":{"ival":1},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 140 +-- fail + +create function build_ordered_int8s_a(i int8, j int8) returns ordered_int8s[] as $$ +begin return array[row(i,j), row(i,j+1)]; end +$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"build_ordered_int8s_a"}}],"parameters":[{"FunctionParameter":{"name":"i","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":49},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"j","argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":57},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"ordered_int8s"}}],"typemod":-1,"arrayBounds":[{"Integer":{"ival":-1}}],"location":71},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin return array[row(i,j), row(i,j+1)]; end\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":87}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":142}}]}}}]} +== 141 +select build_ordered_int8s_a(1,2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s_a"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":29}},{"A_Const":{"ival":{"ival":2},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 142 +select build_ordered_int8s_a(2,1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"build_ordered_int8s_a"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":29}},{"A_Const":{"ival":{"ival":1},"location":31}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 143 +-- fail + +-- check field assignment +do $$ +declare r ordered_int8s; +begin + r.q1 := null; + r.q2 := 43; + r.q1 := 42; + r.q2 := 41; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r ordered_int8s;\nbegin\n r.q1 := null;\n r.q2 := 43;\n r.q1 := 42;\n r.q2 := 41; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":38}}]}}}]} +== 144 +-- check whole-row assignment +do $$ +declare r ordered_int8s; +begin + r := null; + r := row(null,null); + r := row(1,2); + r := row(2,1); -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r ordered_int8s;\nbegin\n r := null;\n r := row(null,null);\n r := row(1,2);\n r := row(2,1); -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":33}}]}}}]} +== 145 +-- check assignment in for-loop +do $$ +declare r ordered_int8s; +begin + for r in values (1,2),(3,4),(6,5) loop + raise notice 'r = %', r; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r ordered_int8s;\nbegin\n for r in values (1,2),(3,4),(6,5) loop\n raise notice 'r = %', r;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":35}}]}}}]} +== 146 +-- check behavior with toastable fields, too + +create type two_texts as (f1 text, f2 text) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"two_texts","relpersistence":"p","location":58},"coldeflist":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":75},"is_local":true,"location":72}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":84},"is_local":true,"location":81}}]}}}]} +== 147 +create domain ordered_texts as two_texts check((value).f1 <= (value).f2) +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"ordered_texts"}}],"typeName":{"names":[{"String":{"sval":"two_texts"}}],"typemod":-1,"location":31},"constraints":[{"Constraint":{"contype":"CONSTR_CHECK","initially_valid":true,"raw_expr":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"\u003c="}}],"lexpr":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":48}},"indirection":[{"String":{"sval":"f1"}}]}},"rexpr":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":62}},"indirection":[{"String":{"sval":"f2"}}]}},"location":58}},"location":41}}]}}}]} +== 148 +create table sometable (id int, a text, b text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"sometable","inh":true,"relpersistence":"p","location":13},"tableElts":[{"ColumnDef":{"colname":"id","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":27},"is_local":true,"location":24}},{"ColumnDef":{"colname":"a","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":34},"is_local":true,"location":32}},{"ColumnDef":{"colname":"b","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":42},"is_local":true,"location":40}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 149 +-- b should be compressed, but in-line +insert into sometable values (1, 'a', repeat('ffoob',1000)) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"sometable","inh":true,"relpersistence":"p","location":51},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":69}},{"A_Const":{"sval":{"sval":"a"},"location":72}},{"FuncCall":{"funcname":[{"String":{"sval":"repeat"}}],"args":[{"A_Const":{"sval":{"sval":"ffoob"},"location":84}},{"A_Const":{"ival":{"ival":1000},"location":92}}],"funcformat":"COERCE_EXPLICIT_CALL","location":77}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 150 +-- this b should be out-of-line +insert into sometable values (2, 'a', repeat('ffoob',100000)) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"sometable","inh":true,"relpersistence":"p","location":44},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":2},"location":62}},{"A_Const":{"sval":{"sval":"a"},"location":65}},{"FuncCall":{"funcname":[{"String":{"sval":"repeat"}}],"args":[{"A_Const":{"sval":{"sval":"ffoob"},"location":77}},{"A_Const":{"ival":{"ival":100000},"location":85}}],"funcformat":"COERCE_EXPLICIT_CALL","location":70}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 151 +-- this pair should fail the domain check +insert into sometable values (3, 'z', repeat('ffoob',100000)) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"sometable","inh":true,"relpersistence":"p","location":54},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":3},"location":72}},{"A_Const":{"sval":{"sval":"z"},"location":75}},{"FuncCall":{"funcname":[{"String":{"sval":"repeat"}}],"args":[{"A_Const":{"sval":{"sval":"ffoob"},"location":87}},{"A_Const":{"ival":{"ival":100000},"location":95}}],"funcformat":"COERCE_EXPLICIT_CALL","location":80}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 152 +do $$ +declare d ordered_texts; +begin + for d in select a, b from sometable loop + raise notice 'succeeded at "%"', d.f1; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare d ordered_texts;\nbegin\n for d in select a, b from sometable loop\n raise notice 'succeeded at \"%\"', d.f1;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 153 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := row(r.a, r.b); + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r record; d ordered_texts;\nbegin\n for r in select * from sometable loop\n raise notice 'processing row %', r.id;\n d := row(r.a, r.b);\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 154 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := null; + d.f1 := r.a; + d.f2 := r.b; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare r record; d ordered_texts;\nbegin\n for r in select * from sometable loop\n raise notice 'processing row %', r.id;\n d := null;\n d.f1 := r.a;\n d.f2 := r.b;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 155 +-- check coercion of a record result to named-composite function output type +create function compresult(int8) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,$1); return r; end $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"compresult"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"int8"}}],"typemod":-1,"location":104},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":118},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":128}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" declare r record; begin r := row($1,$1); return r; end "}}]}},"defaction":"DEFELEM_UNSPEC","location":145}}]}}}]} +== 156 +create table two_int8s_tab (f1 two_int8s) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"two_int8s_tab","inh":true,"relpersistence":"p","location":13},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"two_int8s"}}],"typemod":-1,"location":31},"is_local":true,"location":28}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 157 +insert into two_int8s_tab values (compresult(42)) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"two_int8s_tab","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"compresult"}}],"args":[{"A_Const":{"ival":{"ival":42},"location":45}}],"funcformat":"COERCE_EXPLICIT_CALL","location":34}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 158 +-- reconnect so we lose any local knowledge of anonymous record types +table two_int8s_tab +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":-1}},"location":-1}}],"fromClause":[{"RangeVar":{"relname":"two_int8s_tab","inh":true,"relpersistence":"p","location":76}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_simple.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_simple.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_simple.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_simple.test b/parser/testdata/parse/plpgsql_regress/plpgsql_simple.test new file mode 100644 index 0000000..b0c1b2b --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_simple.test @@ -0,0 +1,164 @@ +== 001 +|-- +-- Tests for plpgsql's handling of "simple" expressions +|-- + +-- Check that changes to an inline-able function are handled correctly +create function simplesql(int) returns int language sql +as 'select $1' +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"simplesql"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":160},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":173},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":177}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"select $1"}}]}},"defaction":"DEFELEM_UNSPEC","location":190}}]}}}]} +== 002 +create function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simplesql(n); + if n = 5 then + create or replace function simplesql(int) returns int language sql + as 'select $1 + 100'; + end if; + end loop; + return sum; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"simplecaller"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":39},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":43}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare\n sum int := 0;\nbegin\n for n in 1..10 loop\n sum := sum + simplesql(n);\n if n = 5 then\n create or replace function simplesql(int) returns int language sql\n as 'select $1 + 100';\n end if;\n end loop;\n return sum;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":60}}]}}}]} +== 003 +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 004 +-- Check that changes in search path are dealt with correctly +create schema simple1 +-- +{"version":170007,"stmts":[{"stmt":{"CreateSchemaStmt":{"schemaname":"simple1"}}}]} +== 005 +create function simple1.simpletarget(int) returns int language plpgsql +as $$begin return $1; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"simple1"}},{"String":{"sval":"simpletarget"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":37},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":50},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":54}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"begin return $1; end"}}]}},"defaction":"DEFELEM_UNSPEC","location":71}}]}}}]} +== 006 +create function simpletarget(int) returns int language plpgsql +as $$begin return $1 + 100; end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"simpletarget"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":29},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":42},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":46}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"begin return $1 + 100; end"}}]}},"defaction":"DEFELEM_UNSPEC","location":63}}]}}}]} +== 007 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simpletarget(n); + if n = 5 then + set local search_path = 'simple1'; + end if; + end loop; + return sum; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"simplecaller"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":50},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":54}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare\n sum int := 0;\nbegin\n for n in 1..10 loop\n sum := sum + simpletarget(n);\n if n = 5 then\n set local search_path = 'simple1';\n end if;\n end loop;\n return sum;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":71}}]}}}]} +== 008 +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 009 +-- try it with non-volatile functions, too +alter function simple1.simpletarget(int) immutable +-- +{"version":170007,"stmts":[{"stmt":{"AlterFunctionStmt":{"objtype":"OBJECT_FUNCTION","func":{"objname":[{"String":{"sval":"simple1"}},{"String":{"sval":"simpletarget"}}],"objargs":[{"TypeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":79}}],"objfuncargs":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":79},"mode":"FUNC_PARAM_DEFAULT"}}]},"actions":[{"DefElem":{"defname":"volatility","arg":{"String":{"sval":"immutable"}},"defaction":"DEFELEM_UNSPEC","location":84}}]}}}]} +== 010 +alter function simpletarget(int) immutable +-- +{"version":170007,"stmts":[{"stmt":{"AlterFunctionStmt":{"objtype":"OBJECT_FUNCTION","func":{"objname":[{"String":{"sval":"simpletarget"}}],"objargs":[{"TypeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":28}}],"objfuncargs":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":28},"mode":"FUNC_PARAM_DEFAULT"}}]},"actions":[{"DefElem":{"defname":"volatility","arg":{"String":{"sval":"immutable"}},"defaction":"DEFELEM_UNSPEC","location":33}}]}}}]} +== 011 +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 012 +-- make sure flushing local caches changes nothing + +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":59}},"location":59}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 013 +-- Check case where first attempt to determine if it's simple fails + +create function simplesql() returns int language sql +as $$select 1 / 0$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"simplesql"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":105},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":109}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"select 1 / 0"}}]}},"defaction":"DEFELEM_UNSPEC","location":122}}]}}}]} +== 014 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + select simplesql() into x; + return x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"simplecaller"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":50},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":54}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare x int;\nbegin\n select simplesql() into x;\n return x;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":71}}]}}}]} +== 015 +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 016 +-- division by zero occurs during simple-expr check + +create or replace function simplesql() returns int language sql +as $$select 2 + 2$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"simplesql"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":100},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":104}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"select 2 + 2"}}]}},"defaction":"DEFELEM_UNSPEC","location":117}}]}}}]} +== 017 +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 018 +-- Check case where called function changes from non-SRF to SRF (bug #18497) + +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + x := simplesql(); + return x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"replace":true,"funcname":[{"String":{"sval":"simplecaller"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":128},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":132}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare x int;\nbegin\n x := simplesql();\n return x;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":149}}]}}}]} +== 019 +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 020 +drop function simplesql() +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"ObjectWithArgs":{"objname":[{"String":{"sval":"simplesql"}}]}}],"removeType":"OBJECT_FUNCTION","behavior":"DROP_RESTRICT"}}}]} +== 021 +create function simplesql() returns setof int language sql +as $$select 22 + 22$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"simplesql"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"setof":true,"typemod":-1,"location":42},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":46}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"select 22 + 22"}}]}},"defaction":"DEFELEM_UNSPEC","location":59}}]}}}]} +== 022 +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 023 +select simplecaller() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"simplecaller"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 024 +-- Check handling of simple expression in a scrollable cursor (bug #18859) + +do $$ +declare + p_CurData refcursor; + val int; +begin + open p_CurData scroll for select 42; + fetch p_CurData into val; + raise notice 'val = %', val; +end; $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare\n p_CurData refcursor;\n val int;\nbegin\n open p_CurData scroll for select 42;\n fetch p_CurData into val;\n raise notice 'val = %', val;\nend; "}},"defaction":"DEFELEM_UNSPEC","location":79}}]}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_transaction.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_transaction.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_transaction.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_transaction.test b/parser/testdata/parse/plpgsql_regress/plpgsql_transaction.test new file mode 100644 index 0000000..23effe9 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_transaction.test @@ -0,0 +1,853 @@ +== 001 +CREATE TABLE test1 (a int, b text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"test1","inh":true,"relpersistence":"p","location":13},"tableElts":[{"ColumnDef":{"colname":"a","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":22},"is_local":true,"location":20}},{"ColumnDef":{"colname":"b","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":29},"is_local":true,"location":27}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 002 +CREATE PROCEDURE transaction_test1(x int, y text) +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..x LOOP + INSERT INTO test1 (a, b) VALUES (i, y); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test1"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":37},"mode":"FUNC_PARAM_DEFAULT"}},{"FunctionParameter":{"name":"y","argType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":44},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":50}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n FOR i IN 0..x LOOP\n INSERT INTO test1 (a, b) VALUES (i, y);\n IF i % 2 = 0 THEN\n COMMIT;\n ELSE\n ROLLBACK;\n END IF;\n END LOOP;\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":67}}]}}}]} +== 003 +CALL transaction_test1(9, 'foo') +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test1"}}],"args":[{"A_Const":{"ival":{"ival":9},"location":23}},{"A_Const":{"sval":{"sval":"foo"},"location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 004 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 005 +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":9}}],"behavior":"DROP_RESTRICT"}}}]} +== 006 +DO +LANGUAGE plpgsql +$$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n FOR i IN 0..9 LOOP\n INSERT INTO test1 (a) VALUES (i);\n IF i % 2 = 0 THEN\n COMMIT;\n ELSE\n ROLLBACK;\n END IF;\n END LOOP;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 007 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 008 +-- transaction commands not allowed when called in transaction block +START TRANSACTION +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_START","location":-1}}}]} +== 009 +CALL transaction_test1(9, 'error') +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test1"}}],"args":[{"A_Const":{"ival":{"ival":9},"location":23}},{"A_Const":{"sval":{"sval":"error"},"location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 010 +COMMIT +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_COMMIT","location":-1}}}]} +== 011 +START TRANSACTION +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_START","location":-1}}}]} +== 012 +DO LANGUAGE plpgsql $$ BEGIN COMMIT; END $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":" BEGIN COMMIT; END "}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 013 +COMMIT +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_COMMIT","location":-1}}}]} +== 014 +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":9}}],"behavior":"DROP_RESTRICT"}}}]} +== 015 +-- not allowed in a function +CREATE FUNCTION transaction_test2() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; + RETURN 1; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"transaction_test2"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":73},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":77}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n FOR i IN 0..9 LOOP\n INSERT INTO test1 (a) VALUES (i);\n IF i % 2 = 0 THEN\n COMMIT;\n ELSE\n ROLLBACK;\n END IF;\n END LOOP;\n RETURN 1;\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":94}}]}}}]} +== 016 +SELECT transaction_test2() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"transaction_test2"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 017 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 018 +-- also not allowed if procedure is called from a function +CREATE FUNCTION transaction_test3() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, 'error'); + RETURN 1; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"transaction_test3"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":103},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":107}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n CALL transaction_test1(9, 'error');\n RETURN 1;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":124}}]}}}]} +== 019 +SELECT transaction_test3() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"transaction_test3"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 020 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 021 +-- DO block inside function +CREATE FUNCTION transaction_test4() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'; + RETURN 1; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"transaction_test4"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":72},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":76}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$';\n RETURN 1;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":93}}]}}}]} +== 022 +SELECT transaction_test4() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"transaction_test4"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 023 +-- proconfig settings currently disallow transaction statements +CREATE PROCEDURE transaction_test5() +LANGUAGE plpgsql +SET work_mem = 555 +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test5"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":101}},{"DefElem":{"defname":"set","arg":{"VariableSetStmt":{"kind":"VAR_SET_VALUE","name":"work_mem","args":[{"A_Const":{"ival":{"ival":555},"location":133}}]}},"defaction":"DEFELEM_UNSPEC","location":118}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n COMMIT;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":137}}]}}}]} +== 024 +CALL transaction_test5() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test5"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 025 +-- SECURITY DEFINER currently disallow transaction statements +CREATE PROCEDURE transaction_test5b() +LANGUAGE plpgsql +SECURITY DEFINER +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test5b"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":100}},{"DefElem":{"defname":"security","arg":{"Boolean":{"boolval":true}},"defaction":"DEFELEM_UNSPEC","location":117}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n COMMIT;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":134}}]}}}]} +== 026 +CALL transaction_test5b() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test5b"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 027 +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":9}}],"behavior":"DROP_RESTRICT"}}}]} +== 028 +-- nested procedure calls +CREATE PROCEDURE transaction_test6(c text) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, c); +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test6"}}],"parameters":[{"FunctionParameter":{"name":"c","argType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":63},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":69}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n CALL transaction_test1(9, c);\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":86}}]}}}]} +== 029 +CALL transaction_test6('bar') +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test6"}}],"args":[{"A_Const":{"sval":{"sval":"bar"},"location":23}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 030 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 031 +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":9}}],"behavior":"DROP_RESTRICT"}}}]} +== 032 +CREATE PROCEDURE transaction_test7() +LANGUAGE plpgsql +AS $$ +BEGIN + DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test7"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":37}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;';\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":54}}]}}}]} +== 033 +CALL transaction_test7() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test7"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 034 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 035 +CREATE PROCEDURE transaction_test8() +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'CALL transaction_test1(10, $x$baz$x$)'; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test8"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":37}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n EXECUTE 'CALL transaction_test1(10, $x$baz$x$)';\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":54}}]}}}]} +== 036 +CALL transaction_test8() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test8"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 037 +-- commit inside cursor loop +CREATE TABLE test2 (x int) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"test2","inh":true,"relpersistence":"p","location":42},"tableElts":[{"ColumnDef":{"colname":"x","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":51},"is_local":true,"location":49}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 038 +INSERT INTO test2 VALUES (0), (1), (2), (3), (4) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"test2","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{},"location":26}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":31}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":2},"location":36}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":3},"location":41}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":4},"location":46}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 039 +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":9}}],"behavior":"DROP_RESTRICT"}}}]} +== 040 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + COMMIT; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n r RECORD;\nBEGIN\n FOR r IN SELECT * FROM test2 ORDER BY x LOOP\n INSERT INTO test1 (a) VALUES (r.x);\n COMMIT;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 041 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 042 +-- check that this doesn't leak a holdable portal +SELECT * FROM pg_cursors +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":57}},"location":57}}],"fromClause":[{"RangeVar":{"relname":"pg_cursors","inh":true,"relpersistence":"p","location":64}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 043 +-- error in cursor loop with commit +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":45}}],"behavior":"DROP_RESTRICT"}}}]} +== 044 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (12/(r.x-2)); + COMMIT; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n r RECORD;\nBEGIN\n FOR r IN SELECT * FROM test2 ORDER BY x LOOP\n INSERT INTO test1 (a) VALUES (12/(r.x-2));\n COMMIT;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 045 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 046 +SELECT * FROM pg_cursors +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"pg_cursors","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 047 +-- rollback inside cursor loop +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":40}}],"behavior":"DROP_RESTRICT"}}}]} +== 048 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n r RECORD;\nBEGIN\n FOR r IN SELECT * FROM test2 ORDER BY x LOOP\n INSERT INTO test1 (a) VALUES (r.x);\n ROLLBACK;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 049 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 050 +SELECT * FROM pg_cursors +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"pg_cursors","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 051 +-- first commit then rollback inside cursor loop +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":58}}],"behavior":"DROP_RESTRICT"}}}]} +== 052 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + IF r.x % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n r RECORD;\nBEGIN\n FOR r IN SELECT * FROM test2 ORDER BY x LOOP\n INSERT INTO test1 (a) VALUES (r.x);\n IF r.x % 2 = 0 THEN\n COMMIT;\n ELSE\n ROLLBACK;\n END IF;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 053 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 054 +SELECT * FROM pg_cursors +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"pg_cursors","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 055 +-- rollback inside cursor loop +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":40}}],"behavior":"DROP_RESTRICT"}}}]} +== 056 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n r RECORD;\nBEGIN\n FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP\n INSERT INTO test1 (a) VALUES (r.x);\n ROLLBACK;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 057 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 058 +SELECT * FROM test2 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test2","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 059 +SELECT * FROM pg_cursors +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"pg_cursors","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 060 +-- interaction of FOR UPDATE cursor with subsequent updates (bug #17050) +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":82}}],"behavior":"DROP_RESTRICT"}}}]} +== 061 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"test1","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":26}},{"A_Const":{"sval":{"sval":"one"},"location":28}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":2},"location":37}},{"A_Const":{"sval":{"sval":"two"},"location":39}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":3},"location":48}},{"A_Const":{"sval":{"sval":"three"},"location":50}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 062 +DO LANGUAGE plpgsql $$ +DECLARE + l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE; +BEGIN + FOR r IN l_cur LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE\n l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE;\nBEGIN\n FOR r IN l_cur LOOP\n UPDATE test1 SET b = b || ' ' || b WHERE a = r.a;\n COMMIT;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 063 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 064 +SELECT * FROM pg_cursors +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"pg_cursors","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 065 +-- like bug #17050, but with implicit cursor +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":54}}],"behavior":"DROP_RESTRICT"}}}]} +== 066 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"test1","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":26}},{"A_Const":{"sval":{"sval":"one"},"location":28}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":2},"location":37}},{"A_Const":{"sval":{"sval":"two"},"location":39}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":3},"location":48}},{"A_Const":{"sval":{"sval":"three"},"location":50}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 067 +DO LANGUAGE plpgsql $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT a FROM test1 FOR UPDATE LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nDECLARE r RECORD;\nBEGIN\n FOR r IN SELECT a FROM test1 FOR UPDATE LOOP\n UPDATE test1 SET b = b || ' ' || b WHERE a = r.a;\n COMMIT;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 068 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 069 +SELECT * FROM pg_cursors +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"pg_cursors","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 070 +-- commit inside block with exception handler +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":55}}],"behavior":"DROP_RESTRICT"}}}]} +== 071 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + COMMIT; + INSERT INTO test1 (a) VALUES (1/0); + COMMIT; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n BEGIN\n INSERT INTO test1 (a) VALUES (1);\n COMMIT;\n INSERT INTO test1 (a) VALUES (1/0);\n COMMIT;\n EXCEPTION\n WHEN division_by_zero THEN\n RAISE NOTICE 'caught division_by_zero';\n END;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 072 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 073 +-- rollback inside block with exception handler +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":57}}],"behavior":"DROP_RESTRICT"}}}]} +== 074 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + ROLLBACK; + INSERT INTO test1 (a) VALUES (1/0); + ROLLBACK; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n BEGIN\n INSERT INTO test1 (a) VALUES (1);\n ROLLBACK;\n INSERT INTO test1 (a) VALUES (1/0);\n ROLLBACK;\n EXCEPTION\n WHEN division_by_zero THEN\n RAISE NOTICE 'caught division_by_zero';\n END;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 075 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 076 +-- test commit/rollback inside exception handler, too +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":63}}],"behavior":"DROP_RESTRICT"}}}]} +== 077 +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 1..10 LOOP + BEGIN + INSERT INTO test1 VALUES (i, 'good'); + INSERT INTO test1 VALUES (i/0, 'bad'); + EXCEPTION + WHEN division_by_zero THEN + INSERT INTO test1 VALUES (i, 'exception'); + IF (i % 3) > 0 THEN COMMIT; ELSE ROLLBACK; END IF; + END; + END LOOP; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n FOR i IN 1..10 LOOP\n BEGIN\n INSERT INTO test1 VALUES (i, 'good');\n INSERT INTO test1 VALUES (i/0, 'bad');\n EXCEPTION\n WHEN division_by_zero THEN\n INSERT INTO test1 VALUES (i, 'exception');\n IF (i % 3) \u003e 0 THEN COMMIT; ELSE ROLLBACK; END IF;\n END;\n END LOOP;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 078 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 079 +-- detoast result of simple expression after commit +CREATE TEMP TABLE test4(f1 text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"test4","inh":true,"relpersistence":"t","location":70},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":79},"is_local":true,"location":76}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 080 +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE EXTERNAL +-- +{"version":170007,"stmts":[{"stmt":{"AlterTableStmt":{"relation":{"relname":"test4","inh":true,"relpersistence":"p","location":12},"cmds":[{"AlterTableCmd":{"subtype":"AT_SetStorage","name":"f1","def":{"String":{"sval":"external"}},"behavior":"DROP_RESTRICT"}}],"objtype":"OBJECT_TABLE"}}}]} +== 081 +-- disable compression +INSERT INTO test4 SELECT repeat('xyzzy', 2000) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"test4","inh":true,"relpersistence":"p","location":35},"selectStmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"repeat"}}],"args":[{"A_Const":{"sval":{"sval":"xyzzy"},"location":55}},{"A_Const":{"ival":{"ival":2000},"location":64}}],"funcformat":"COERCE_EXPLICIT_CALL","location":48}},"location":48}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 082 +-- immutable mark is a bit of a lie, but it serves to make call a simple expr +-- that will return a still-toasted value +CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql +AS 'select f1 from test4' IMMUTABLE +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"data_source"}}],"parameters":[{"FunctionParameter":{"name":"i","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":150},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":163},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":168}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"select f1 from test4"}}]}},"defaction":"DEFELEM_UNSPEC","location":181}},{"DefElem":{"defname":"volatility","arg":{"String":{"sval":"immutable"}},"defaction":"DEFELEM_UNSPEC","location":207}}]}}}]} +== 083 +DO $$ +declare x text; +begin + for i in 1..3 loop + x := data_source(i); + commit; + end loop; + raise notice 'length(x) = %', length(x); +end $$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x text;\nbegin\n for i in 1..3 loop\n x := data_source(i);\n commit;\n end loop;\n raise notice 'length(x) = %', length(x);\nend "}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 084 +-- operations on composite types vs. internal transactions +DO LANGUAGE plpgsql $$ +declare + c test1 := row(42, 'hello'); + r bool; +begin + for i in 1..3 loop + r := c is not null; + raise notice 'r = %', r; + commit; + end loop; + for i in 1..3 loop + r := c is null; + raise notice 'r = %', r; + rollback; + end loop; +end +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":62}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare\n c test1 := row(42, 'hello');\n r bool;\nbegin\n for i in 1..3 loop\n r := c is not null;\n raise notice 'r = %', r;\n commit;\n end loop;\n for i in 1..3 loop\n r := c is null;\n raise notice 'r = %', r;\n rollback;\n end loop;\nend\n"}},"defaction":"DEFELEM_UNSPEC","location":79}}]}}}]} +== 085 +-- COMMIT failures +DO LANGUAGE plpgsql $$ +BEGIN + CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + INSERT INTO test3 (y) VALUES (2); + COMMIT; + INSERT INTO test3 (y) VALUES (3); -- won't get here +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":22}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED);\n COMMIT;\n INSERT INTO test3 (y) VALUES (1);\n COMMIT;\n INSERT INTO test3 (y) VALUES (1);\n INSERT INTO test3 (y) VALUES (2);\n COMMIT;\n INSERT INTO test3 (y) VALUES (3); -- won't get here\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":39}}]}}}]} +== 086 +SELECT * FROM test3 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test3","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 087 +-- failure while trying to persist a cursor across a transaction (bug #15703) +CREATE PROCEDURE cursor_fail_during_commit() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + COMMIT; + END LOOP; + END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"cursor_fail_during_commit"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":124}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\n DECLARE id int;\n BEGIN\n FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP\n INSERT INTO test1 VALUES(id);\n COMMIT;\n END LOOP;\n END;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":141}}]}}}]} +== 088 +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":9}}],"behavior":"DROP_RESTRICT"}}}]} +== 089 +CALL cursor_fail_during_commit() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"cursor_fail_during_commit"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 090 +-- note that error occurs during first COMMIT, hence nothing is in test1 +SELECT count(*) FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"count"}}],"agg_star":true,"funcformat":"COERCE_EXPLICIT_CALL","location":80}},"location":80}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":94}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 091 +CREATE PROCEDURE cursor_fail_during_rollback() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + ROLLBACK; + END LOOP; + END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"cursor_fail_during_rollback"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":48}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\n DECLARE id int;\n BEGIN\n FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP\n INSERT INTO test1 VALUES(id);\n ROLLBACK;\n END LOOP;\n END;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":65}}]}}}]} +== 092 +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":9}}],"behavior":"DROP_RESTRICT"}}}]} +== 093 +CALL cursor_fail_during_rollback() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"cursor_fail_during_rollback"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 094 +SELECT count(*) FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"count"}}],"agg_star":true,"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":21}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 095 +-- SET TRANSACTION +DO LANGUAGE plpgsql $$ +BEGIN + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":22}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n PERFORM 1;\n RAISE INFO '%', current_setting('transaction_isolation');\n COMMIT;\n SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;\n PERFORM 1;\n RAISE INFO '%', current_setting('transaction_isolation');\n COMMIT;\n SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;\n PERFORM 1;\n RAISE INFO '%', current_setting('transaction_isolation');\n COMMIT;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":39}}]}}}]} +== 096 +-- error cases +DO LANGUAGE plpgsql $$ +BEGIN + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":18}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":35}}]}}}]} +== 097 +DO LANGUAGE plpgsql $$ +BEGIN + SAVEPOINT foo; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n SAVEPOINT foo;\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 098 +DO LANGUAGE plpgsql $$ +BEGIN + EXECUTE 'COMMIT'; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n EXECUTE 'COMMIT';\nEND;\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 099 +-- snapshot handling test +TRUNCATE test2 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test2","inh":true,"relpersistence":"p","location":35}}],"behavior":"DROP_RESTRICT"}}}]} +== 100 +CREATE PROCEDURE transaction_test9() +LANGUAGE SQL +AS $$ +INSERT INTO test2 VALUES (42); +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test9"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":37}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nINSERT INTO test2 VALUES (42);\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":50}}]}}}]} +== 101 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + CALL transaction_test9(); +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n ROLLBACK;\n CALL transaction_test9();\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 102 +SELECT * FROM test2 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test2","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 103 +-- another snapshot handling case: argument expressions of a CALL need +-- to be evaluated with an up-to-date snapshot +CREATE FUNCTION report_count() RETURNS int +STABLE LANGUAGE sql +AS $$ SELECT COUNT(*) FROM test2 $$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"report_count"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":157},"options":[{"DefElem":{"defname":"volatility","arg":{"String":{"sval":"stable"}},"defaction":"DEFELEM_UNSPEC","location":161}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"sql"}},"defaction":"DEFELEM_UNSPEC","location":168}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":" SELECT COUNT(*) FROM test2 "}}]}},"defaction":"DEFELEM_UNSPEC","location":181}}]}}}]} +== 104 +CREATE PROCEDURE transaction_test9b(cnt int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'count = %', cnt; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test9b"}}],"parameters":[{"FunctionParameter":{"name":"cnt","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":40},"mode":"FUNC_PARAM_DEFAULT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":45}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n RAISE NOTICE 'count = %', cnt;\nEND\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":62}}]}}}]} +== 105 +DO $$ +BEGIN + CALL transaction_test9b(report_count()); + INSERT INTO test2 VALUES(43); + CALL transaction_test9b(report_count()); +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n CALL transaction_test9b(report_count());\n INSERT INTO test2 VALUES(43);\n CALL transaction_test9b(report_count());\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 106 +-- Test transaction in procedure with output parameters. This uses a +-- different portal strategy and different code paths in pquery.c. +CREATE PROCEDURE transaction_test10a(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x + 1; + COMMIT; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test10a"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":182},"mode":"FUNC_PARAM_INOUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":187}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n x := x + 1;\n COMMIT;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":204}}]}}}]} +== 107 +CALL transaction_test10a(10) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test10a"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":25}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 108 +CREATE PROCEDURE transaction_test10b(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x - 1; + ROLLBACK; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test10b"}}],"parameters":[{"FunctionParameter":{"name":"x","argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":45},"mode":"FUNC_PARAM_INOUT"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":50}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nBEGIN\n x := x - 1;\n ROLLBACK;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":67}}]}}}]} +== 109 +CALL transaction_test10b(10) +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test10b"}}],"args":[{"A_Const":{"ival":{"ival":10},"location":25}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 110 +-- transaction timestamp vs. statement timestamp +CREATE PROCEDURE transaction_test11() +LANGUAGE plpgsql +AS $$ +DECLARE + s1 timestamp with time zone; + s2 timestamp with time zone; + s3 timestamp with time zone; + t1 timestamp with time zone; + t2 timestamp with time zone; + t3 timestamp with time zone; +BEGIN + s1 := statement_timestamp(); + t1 := transaction_timestamp(); + ASSERT s1 = t1; + PERFORM pg_sleep(0.001); + COMMIT; + s2 := statement_timestamp(); + t2 := transaction_timestamp(); + ASSERT s2 = s1; + ASSERT t2 > t1; + PERFORM pg_sleep(0.001); + ROLLBACK; + s3 := statement_timestamp(); + t3 := transaction_timestamp(); + ASSERT s3 = s1; + ASSERT t3 > t2; +END; +$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"is_procedure":true,"funcname":[{"String":{"sval":"transaction_test11"}}],"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":87}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nDECLARE\n s1 timestamp with time zone;\n s2 timestamp with time zone;\n s3 timestamp with time zone;\n t1 timestamp with time zone;\n t2 timestamp with time zone;\n t3 timestamp with time zone;\nBEGIN\n s1 := statement_timestamp();\n t1 := transaction_timestamp();\n ASSERT s1 = t1;\n PERFORM pg_sleep(0.001);\n COMMIT;\n s2 := statement_timestamp();\n t2 := transaction_timestamp();\n ASSERT s2 = s1;\n ASSERT t2 \u003e t1;\n PERFORM pg_sleep(0.001);\n ROLLBACK;\n s3 := statement_timestamp();\n t3 := transaction_timestamp();\n ASSERT s3 = s1;\n ASSERT t3 \u003e t2;\nEND;\n"}}]}},"defaction":"DEFELEM_UNSPEC","location":104}}]}}}]} +== 111 +CALL transaction_test11() +-- +{"version":170007,"stmts":[{"stmt":{"CallStmt":{"funccall":{"funcname":[{"String":{"sval":"transaction_test11"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":5}}}}]} +== 112 +-- transaction chain + +TRUNCATE test1 +-- +{"version":170007,"stmts":[{"stmt":{"TruncateStmt":{"relations":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":31}}],"behavior":"DROP_RESTRICT"}}}]} +== 113 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + FOR i IN 0..3 LOOP + RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT AND CHAIN; + ELSE + ROLLBACK AND CHAIN; + END IF; + END LOOP; +END +$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":3}},{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nBEGIN\n ROLLBACK;\n SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;\n FOR i IN 0..3 LOOP\n RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation');\n INSERT INTO test1 (a) VALUES (i);\n IF i % 2 = 0 THEN\n COMMIT AND CHAIN;\n ELSE\n ROLLBACK AND CHAIN;\n END IF;\n END LOOP;\nEND\n"}},"defaction":"DEFELEM_UNSPEC","location":20}}]}}}]} +== 114 +SELECT * FROM test1 +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"test1","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 115 +DROP TABLE test1 +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"List":{"items":[{"String":{"sval":"test1"}}]}}],"removeType":"OBJECT_TABLE","behavior":"DROP_RESTRICT"}}}]} +== 116 +DROP TABLE test2 +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"List":{"items":[{"String":{"sval":"test2"}}]}}],"removeType":"OBJECT_TABLE","behavior":"DROP_RESTRICT"}}}]} +== 117 +DROP TABLE test3 +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"List":{"items":[{"String":{"sval":"test3"}}]}}],"removeType":"OBJECT_TABLE","behavior":"DROP_RESTRICT"}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_trap.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_trap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_trap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_trap.test b/parser/testdata/parse/plpgsql_regress/plpgsql_trap.test new file mode 100644 index 0000000..4db7298 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_trap.test @@ -0,0 +1,291 @@ +== 001 +|-- +-- Test error trapping +|-- + +create function trap_zero_divide(int) returns int as $$ +declare x int; + sx smallint; +begin + begin -- start a subtransaction + raise notice 'should see this'; + x := 100 / $1; + raise notice 'should see this only if % <> 0', $1; + sx := $1; + raise notice 'should see this only if % fits in smallint', $1; + if $1 < 0 then + raise exception '% is less than zero', $1; + end if; + exception + when division_by_zero then + raise notice 'caught division_by_zero'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE then + raise notice 'caught numeric_value_out_of_range'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"trap_zero_divide"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":63},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":76},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare x int;\n\tsx smallint;\nbegin\n\tbegin\t-- start a subtransaction\n\t\traise notice 'should see this';\n\t\tx := 100 / $1;\n\t\traise notice 'should see this only if % \u003c\u003e 0', $1;\n\t\tsx := $1;\n\t\traise notice 'should see this only if % fits in smallint', $1;\n\t\tif $1 \u003c 0 then\n\t\t\traise exception '% is less than zero', $1;\n\t\tend if;\n\texception\n\t\twhen division_by_zero then\n\t\t\traise notice 'caught division_by_zero';\n\t\t\tx := -1;\n\t\twhen NUMERIC_VALUE_OUT_OF_RANGE then\n\t\t\traise notice 'caught numeric_value_out_of_range';\n\t\t\tx := -2;\n\tend;\n\treturn x;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":80}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":630}}]}}}]} +== 002 +select trap_zero_divide(50) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_zero_divide"}}],"args":[{"A_Const":{"ival":{"ival":50},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 003 +select trap_zero_divide(0) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_zero_divide"}}],"args":[{"A_Const":{"ival":{},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 004 +select trap_zero_divide(100000) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_zero_divide"}}],"args":[{"A_Const":{"ival":{"ival":100000},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 005 +select trap_zero_divide(-100) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_zero_divide"}}],"args":[{"A_Const":{"ival":{"ival":-100},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 006 +create table match_source as + select x as id, x*10 as data, x/10 as ten from generate_series(1,100) x +-- +{"version":170007,"stmts":[{"stmt":{"CreateTableAsStmt":{"query":{"SelectStmt":{"targetList":[{"ResTarget":{"name":"id","val":{"ColumnRef":{"fields":[{"String":{"sval":"x"}}],"location":38}},"location":38}},{"ResTarget":{"name":"data","val":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"*"}}],"lexpr":{"ColumnRef":{"fields":[{"String":{"sval":"x"}}],"location":47}},"rexpr":{"A_Const":{"ival":{"ival":10},"location":49}},"location":48}},"location":47}},{"ResTarget":{"name":"ten","val":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"/"}}],"lexpr":{"ColumnRef":{"fields":[{"String":{"sval":"x"}}],"location":61}},"rexpr":{"A_Const":{"ival":{"ival":10},"location":63}},"location":62}},"location":61}}],"fromClause":[{"RangeFunction":{"functions":[{"List":{"items":[{"FuncCall":{"funcname":[{"String":{"sval":"generate_series"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":94}},{"A_Const":{"ival":{"ival":100},"location":96}}],"funcformat":"COERCE_EXPLICIT_CALL","location":78}},{}]}}],"alias":{"aliasname":"x"}}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"into":{"rel":{"relname":"match_source","inh":true,"relpersistence":"p","location":13},"onCommit":"ONCOMMIT_NOOP"},"objtype":"OBJECT_TABLE"}}}]} +== 007 +create function trap_matching_test(int) returns int as $$ +declare x int; + sx smallint; + y int; +begin + begin -- start a subtransaction + x := 100 / $1; + sx := $1; + select into y data from match_source where id = + (select id from match_source b where ten = $1); + exception + when data_exception then -- category match + raise notice 'caught data_exception'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then + raise notice 'caught numeric_value_out_of_range or cardinality_violation'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"trap_matching_test"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":35},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":48},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare x int;\n\tsx smallint;\n\ty int;\nbegin\n\tbegin\t-- start a subtransaction\n\t\tx := 100 / $1;\n\t\tsx := $1;\n\t\tselect into y data from match_source where id =\n\t\t\t(select id from match_source b where ten = $1);\n\texception\n\t\twhen data_exception then -- category match\n\t\t\traise notice 'caught data_exception';\n\t\t\tx := -1;\n\t\twhen NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then\n\t\t\traise notice 'caught numeric_value_out_of_range or cardinality_violation';\n\t\t\tx := -2;\n\tend;\n\treturn x;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":52}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":551}}]}}}]} +== 008 +select trap_matching_test(50) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_matching_test"}}],"args":[{"A_Const":{"ival":{"ival":50},"location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 009 +select trap_matching_test(0) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_matching_test"}}],"args":[{"A_Const":{"ival":{},"location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 010 +select trap_matching_test(100000) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_matching_test"}}],"args":[{"A_Const":{"ival":{"ival":100000},"location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 011 +select trap_matching_test(1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_matching_test"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":26}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 012 +create temp table foo (f1 int) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"foo","inh":true,"relpersistence":"t","location":18},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":26},"is_local":true,"location":23}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 013 +create function subxact_rollback_semantics() returns int as $$ +declare x int; +begin + x := 1; + insert into foo values(x); + begin + x := x + 1; + insert into foo values(x); + raise exception 'inner'; + exception + when others then + x := x * 10; + end; + insert into foo values(x); + return x; +end$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"subxact_rollback_semantics"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":53},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare x int;\nbegin\n x := 1;\n insert into foo values(x);\n begin\n x := x + 1;\n insert into foo values(x);\n raise exception 'inner';\n exception\n when others then\n x := x * 10;\n end;\n insert into foo values(x);\n return x;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":57}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":313}}]}}}]} +== 014 +select subxact_rollback_semantics() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"subxact_rollback_semantics"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 015 +select * from foo +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"A_Star":{}}],"location":7}},"location":7}}],"fromClause":[{"RangeVar":{"relname":"foo","inh":true,"relpersistence":"p","location":14}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 016 +drop table foo +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"List":{"items":[{"String":{"sval":"foo"}}]}}],"removeType":"OBJECT_TABLE","behavior":"DROP_RESTRICT"}}}]} +== 017 +create function trap_timeout() returns void as $$ +begin + declare x int; + begin + -- we assume this will take longer than 1 second: + select count(*) into x from generate_series(1, 1_000_000_000_000); + exception + when others then + raise notice 'caught others?'; + when query_canceled then + raise notice 'nyeah nyeah, can''t stop me'; + end; + -- Abort transaction to abandon the statement_timeout setting. Otherwise, + -- the next top-level statement would be vulnerable to the timeout. + raise exception 'end of function'; +end$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"trap_timeout"}}],"returnType":{"names":[{"String":{"sval":"void"}}],"typemod":-1,"location":39},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n declare x int;\n begin\n -- we assume this will take longer than 1 second:\n select count(*) into x from generate_series(1, 1_000_000_000_000);\n exception\n when others then\n raise notice 'caught others?';\n when query_canceled then\n raise notice 'nyeah nyeah, can''t stop me';\n end;\n -- Abort transaction to abandon the statement_timeout setting. Otherwise,\n -- the next top-level statement would be vulnerable to the timeout.\n raise exception 'end of function';\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":44}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":552}}]}}}]} +== 018 +begin +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_BEGIN","location":-1}}}]} +== 019 +set statement_timeout to 1000 +-- +{"version":170007,"stmts":[{"stmt":{"VariableSetStmt":{"kind":"VAR_SET_VALUE","name":"statement_timeout","args":[{"A_Const":{"ival":{"ival":1000},"location":25}}]}}}]} +== 020 +select trap_timeout() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_timeout"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 021 +rollback +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_ROLLBACK","location":-1}}}]} +== 022 +-- Test for pass-by-ref values being stored in proper context +create function test_variable_storage() returns text as $$ +declare x text; +begin + x := '1234'; + begin + x := x || '5678'; + -- force error inside subtransaction SPI context + perform trap_zero_divide(-100); + exception + when others then + x := x || '9012'; + end; + return x; +end$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"test_variable_storage"}}],"returnType":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":110},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\ndeclare x text;\nbegin\n x := '1234';\n begin\n x := x || '5678';\n -- force error inside subtransaction SPI context\n perform trap_zero_divide(-100);\n exception\n when others then\n x := x || '9012';\n end;\n return x;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":115}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":359}}]}}}]} +== 023 +select test_variable_storage() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"test_variable_storage"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 024 +|-- +-- test foreign key error trapping +|-- + +create temp table root(f1 int primary key) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"root","inh":true,"relpersistence":"t","location":60},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":68},"is_local":true,"constraints":[{"Constraint":{"contype":"CONSTR_PRIMARY","location":72}}],"location":65}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 025 +create temp table leaf(f1 int references root deferrable) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"leaf","inh":true,"relpersistence":"t","location":18},"tableElts":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":26},"is_local":true,"constraints":[{"Constraint":{"contype":"CONSTR_FOREIGN","initially_valid":true,"pktable":{"relname":"root","inh":true,"relpersistence":"p","location":41},"fk_matchtype":"s","fk_upd_action":"a","fk_del_action":"a","location":30}},{"Constraint":{"contype":"CONSTR_ATTR_DEFERRABLE","location":46}}],"location":23}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 026 +insert into root values(1) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"root","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":24}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 027 +insert into leaf values(1) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"leaf","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":24}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 028 +insert into leaf values(2) +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"leaf","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":2},"location":24}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 029 +-- fails + +create function trap_foreign_key(int) returns int as $$ +begin + begin -- start a subtransaction + insert into leaf values($1); + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"trap_foreign_key"}}],"parameters":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":43},"mode":"FUNC_PARAM_DEFAULT"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":56},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n\tbegin\t-- start a subtransaction\n\t\tinsert into leaf values($1);\n\texception\n\t\twhen foreign_key_violation then\n\t\t\traise notice 'caught foreign_key_violation';\n\t\t\treturn 0;\n\tend;\n\treturn 1;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":60}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":265}}]}}}]} +== 030 +create function trap_foreign_key_2() returns int as $$ +begin + begin -- start a subtransaction + set constraints all immediate; + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"trap_foreign_key_2"}}],"returnType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":45},"options":[{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"\nbegin\n\tbegin\t-- start a subtransaction\n\t\tset constraints all immediate;\n\texception\n\t\twhen foreign_key_violation then\n\t\t\traise notice 'caught foreign_key_violation';\n\t\t\treturn 0;\n\tend;\n\treturn 1;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":49}},{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":256}}]}}}]} +== 031 +select trap_foreign_key(1) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_foreign_key"}}],"args":[{"A_Const":{"ival":{"ival":1},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 032 +select trap_foreign_key(2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_foreign_key"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 033 +-- detects FK violation + +begin +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_BEGIN","location":-1}}}]} +== 034 +set constraints all deferred +-- +{"version":170007,"stmts":[{"stmt":{"ConstraintsSetStmt":{"deferred":true}}}]} +== 035 +select trap_foreign_key(2) +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_foreign_key"}}],"args":[{"A_Const":{"ival":{"ival":2},"location":24}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 036 +-- should not detect FK violation + savepoint x +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_SAVEPOINT","savepoint_name":"x","location":46}}}]} +== 037 +set constraints all immediate +-- +{"version":170007,"stmts":[{"stmt":{"ConstraintsSetStmt":{}}}]} +== 038 +-- fails + rollback to x +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_ROLLBACK_TO","savepoint_name":"x","location":23}}}]} +== 039 +select trap_foreign_key_2() +-- +{"version":170007,"stmts":[{"stmt":{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"FuncCall":{"funcname":[{"String":{"sval":"trap_foreign_key_2"}}],"funcformat":"COERCE_EXPLICIT_CALL","location":7}},"location":7}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}}}]} +== 040 +-- detects FK violation +commit +-- +{"version":170007,"stmts":[{"stmt":{"TransactionStmt":{"kind":"TRANS_STMT_COMMIT","location":-1}}}]} +== 041 +-- still fails + +drop function trap_foreign_key(int) +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"ObjectWithArgs":{"objname":[{"String":{"sval":"trap_foreign_key"}}],"objargs":[{"TypeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":47}}],"objfuncargs":[{"FunctionParameter":{"argType":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":47},"mode":"FUNC_PARAM_DEFAULT"}}]}}],"removeType":"OBJECT_FUNCTION","behavior":"DROP_RESTRICT"}}}]} +== 042 +drop function trap_foreign_key_2() +-- +{"version":170007,"stmts":[{"stmt":{"DropStmt":{"objects":[{"ObjectWithArgs":{"objname":[{"String":{"sval":"trap_foreign_key_2"}}]}}],"removeType":"OBJECT_FUNCTION","behavior":"DROP_RESTRICT"}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_trigger.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_trigger.test b/parser/testdata/parse/plpgsql_regress/plpgsql_trigger.test new file mode 100644 index 0000000..7e169c5 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_trigger.test @@ -0,0 +1,37 @@ +== 001 +-- Simple test to verify accessibility of the OLD and NEW trigger variables + +create table testtr (a int, b text) +-- +{"version":170007,"stmts":[{"stmt":{"CreateStmt":{"relation":{"relname":"testtr","inh":true,"relpersistence":"p","location":90},"tableElts":[{"ColumnDef":{"colname":"a","typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":100},"is_local":true,"location":98}},{"ColumnDef":{"colname":"b","typeName":{"names":[{"String":{"sval":"text"}}],"typemod":-1,"location":107},"is_local":true,"location":105}}],"oncommit":"ONCOMMIT_NOOP"}}}]} +== 002 +create function testtr_trigger() returns trigger language plpgsql as +$$begin + raise notice 'tg_op = %', tg_op; + raise notice 'old(%) = %', old.a, row(old.*); + raise notice 'new(%) = %', new.a, row(new.*); + if (tg_op = 'DELETE') then + return old; + else + return new; + end if; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"CreateFunctionStmt":{"funcname":[{"String":{"sval":"testtr_trigger"}}],"returnType":{"names":[{"String":{"sval":"trigger"}}],"typemod":-1,"location":41},"options":[{"DefElem":{"defname":"language","arg":{"String":{"sval":"plpgsql"}},"defaction":"DEFELEM_UNSPEC","location":49}},{"DefElem":{"defname":"as","arg":{"List":{"items":[{"String":{"sval":"begin\n raise notice 'tg_op = %', tg_op;\n raise notice 'old(%) = %', old.a, row(old.*);\n raise notice 'new(%) = %', new.a, row(new.*);\n if (tg_op = 'DELETE') then\n return old;\n else\n return new;\n end if;\nend"}}]}},"defaction":"DEFELEM_UNSPEC","location":66}}]}}}]} +== 003 +create trigger testtr_trigger before insert or delete or update on testtr + for each row execute function testtr_trigger() +-- +{"version":170007,"stmts":[{"stmt":{"CreateTrigStmt":{"trigname":"testtr_trigger","relation":{"relname":"testtr","inh":true,"relpersistence":"p","location":67},"funcname":[{"String":{"sval":"testtr_trigger"}}],"row":true,"timing":2,"events":28}}}]} +== 004 +insert into testtr values (1, 'one'), (2, 'two') +-- +{"version":170007,"stmts":[{"stmt":{"InsertStmt":{"relation":{"relname":"testtr","inh":true,"relpersistence":"p","location":12},"selectStmt":{"SelectStmt":{"valuesLists":[{"List":{"items":[{"A_Const":{"ival":{"ival":1},"location":27}},{"A_Const":{"sval":{"sval":"one"},"location":30}}]}},{"List":{"items":[{"A_Const":{"ival":{"ival":2},"location":39}},{"A_Const":{"sval":{"sval":"two"},"location":42}}]}}],"limitOption":"LIMIT_OPTION_DEFAULT","op":"SETOP_NONE"}},"override":"OVERRIDING_NOT_SET"}}}]} +== 005 +update testtr set a = a + 1 +-- +{"version":170007,"stmts":[{"stmt":{"UpdateStmt":{"relation":{"relname":"testtr","inh":true,"relpersistence":"p","location":7},"targetList":[{"ResTarget":{"name":"a","val":{"A_Expr":{"kind":"AEXPR_OP","name":[{"String":{"sval":"+"}}],"lexpr":{"ColumnRef":{"fields":[{"String":{"sval":"a"}}],"location":22}},"rexpr":{"A_Const":{"ival":{"ival":1},"location":26}},"location":24}},"location":18}}]}}}]} +== 006 +delete from testtr +-- +{"version":170007,"stmts":[{"stmt":{"DeleteStmt":{"relation":{"relname":"testtr","inh":true,"relpersistence":"p","location":12}}}}]} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_varprops.metadata.json b/parser/testdata/parse/plpgsql_regress/plpgsql_varprops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_varprops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/parse/plpgsql_regress/plpgsql_varprops.test b/parser/testdata/parse/plpgsql_regress/plpgsql_varprops.test new file mode 100644 index 0000000..4931575 --- /dev/null +++ b/parser/testdata/parse/plpgsql_regress/plpgsql_varprops.test @@ -0,0 +1,325 @@ +== 001 +|-- +-- Tests for PL/pgSQL variable properties: CONSTANT, NOT NULL, initializers +|-- + +create type var_record as (f1 int4, f2 int4) +-- +{"version":170007,"stmts":[{"stmt":{"CompositeTypeStmt":{"typevar":{"relname":"var_record","relpersistence":"p","location":95},"coldeflist":[{"ColumnDef":{"colname":"f1","typeName":{"names":[{"String":{"sval":"int4"}}],"typemod":-1,"location":113},"is_local":true,"location":110}},{"ColumnDef":{"colname":"f2","typeName":{"names":[{"String":{"sval":"int4"}}],"typemod":-1,"location":122},"is_local":true,"location":119}}]}}}]} +== 002 +create domain int_nn as int not null +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"int_nn"}}],"typeName":{"names":[{"String":{"sval":"pg_catalog"}},{"String":{"sval":"int4"}}],"typemod":-1,"location":24},"constraints":[{"Constraint":{"contype":"CONSTR_NOTNULL","location":28}}]}}}]} +== 003 +create domain var_record_nn as var_record not null +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"var_record_nn"}}],"typeName":{"names":[{"String":{"sval":"var_record"}}],"typemod":-1,"location":31},"constraints":[{"Constraint":{"contype":"CONSTR_NOTNULL","location":42}}]}}}]} +== 004 +create domain var_record_colnn as var_record check((value).f2 is not null) +-- +{"version":170007,"stmts":[{"stmt":{"CreateDomainStmt":{"domainname":[{"String":{"sval":"var_record_colnn"}}],"typeName":{"names":[{"String":{"sval":"var_record"}}],"typemod":-1,"location":34},"constraints":[{"Constraint":{"contype":"CONSTR_CHECK","initially_valid":true,"raw_expr":{"NullTest":{"arg":{"A_Indirection":{"arg":{"ColumnRef":{"fields":[{"String":{"sval":"value"}}],"location":52}},"indirection":[{"String":{"sval":"f2"}}]}},"nulltesttype":"IS_NOT_NULL","location":62}},"location":45}}]}}}]} +== 005 +-- CONSTANT + +do $$ +declare x constant int := 42; +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x constant int := 42;\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":16}}]}}}]} +== 006 +do $$ +declare x constant int; +begin + x := 42; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x constant int;\nbegin\n x := 42; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 007 +do $$ +declare x constant int; y int; +begin + for x, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x constant int; y int;\nbegin\n for x, y in select 1, 2 loop -- fail\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 008 +do $$ +declare x constant int[]; +begin + x[1] := 42; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x constant int[];\nbegin\n x[1] := 42; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 009 +do $$ +declare x constant int[]; y int; +begin + for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax) + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x constant int[]; y int;\nbegin\n for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax)\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 010 +do $$ +declare x constant var_record; +begin + x.f1 := 42; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x constant var_record;\nbegin\n x.f1 := 42; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 011 +do $$ +declare x constant var_record; y int; +begin + for x.f1, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x constant var_record; y int;\nbegin\n for x.f1, y in select 1, 2 loop -- fail\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 012 +-- initializer expressions + +do $$ +declare x int := sin(0); +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x int := sin(0);\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":31}}]}}}]} +== 013 +do $$ +declare x int := 1/0; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x int := 1/0; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 014 +do $$ +declare x bigint[] := array[1,3,5]; +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x bigint[] := array[1,3,5];\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 015 +do $$ +declare x record := row(1,2,3); +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x record := row(1,2,3);\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 016 +do $$ +declare x var_record := row(1,2); +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record := row(1,2);\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 017 +-- NOT NULL + +do $$ +declare x int not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x int not null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":16}}]}}}]} +== 018 +do $$ +declare x int not null := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x int not null := 42;\nbegin\n raise notice 'x = %', x;\n x := null; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 019 +do $$ +declare x int not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x int not null := null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 020 +do $$ +declare x record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x record not null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 021 +do $$ +declare x record not null := row(42); +begin + raise notice 'x = %', x; + x := row(null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x record not null := row(42);\nbegin\n raise notice 'x = %', x;\n x := row(null); -- ok\n raise notice 'x = %', x;\n x := null; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 022 +do $$ +declare x record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x record not null := null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 023 +do $$ +declare x var_record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record not null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 024 +do $$ +declare x var_record not null := row(41,42); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record not null := row(41,42);\nbegin\n raise notice 'x = %', x;\n x := row(null,null); -- ok\n raise notice 'x = %', x;\n x := null; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 025 +do $$ +declare x var_record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record not null := null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 026 +-- Check that variables are reinitialized on block re-entry. + +do $$ +begin + for i in 1..3 loop + declare + x int; + y int := i; + r record; + c var_record; + begin + if i = 1 then + x := 42; + r := row(i, i+1); + c := row(i, i+1); + end if; + raise notice 'x = %', x; + raise notice 'y = %', y; + raise notice 'r = %', r; + raise notice 'c = %', c; + end; + end loop; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\nbegin\n for i in 1..3 loop\n declare\n x int;\n y int := i;\n r record;\n c var_record;\n begin\n if i = 1 then\n x := 42;\n r := row(i, i+1);\n c := row(i, i+1);\n end if;\n raise notice 'x = %', x;\n raise notice 'y = %', y;\n raise notice 'r = %', r;\n raise notice 'c = %', c;\n end;\n end loop;\nend"}},"defaction":"DEFELEM_UNSPEC","location":65}}]}}}]} +== 027 +-- Check enforcement of domain constraints during initialization + +do $$ +declare x int_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x int_nn; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":69}}]}}}]} +== 028 +do $$ +declare x int_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x int_nn := null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 029 +do $$ +declare x int_nn := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x int_nn := 42;\nbegin\n raise notice 'x = %', x;\n x := null; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 030 +do $$ +declare x var_record_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record_nn; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 031 +do $$ +declare x var_record_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record_nn := null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 032 +do $$ +declare x var_record_nn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + x := null; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record_nn := row(1,2);\nbegin\n raise notice 'x = %', x;\n x := row(null,null); -- ok\n x := null; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 033 +do $$ +declare x var_record_colnn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record_colnn; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 034 +do $$ +declare x var_record_colnn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record_colnn := null; -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 035 +do $$ +declare x var_record_colnn := row(1,null); -- fail +begin + raise notice 'x = %', x; +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record_colnn := row(1,null); -- fail\nbegin\n raise notice 'x = %', x;\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 036 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record_colnn := row(1,2);\nbegin\n raise notice 'x = %', x;\n x := null; -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} +== 037 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- fail +end$$ +-- +{"version":170007,"stmts":[{"stmt":{"DoStmt":{"args":[{"DefElem":{"defname":"as","arg":{"String":{"sval":"\ndeclare x var_record_colnn := row(1,2);\nbegin\n raise notice 'x = %', x;\n x := row(null,null); -- fail\nend"}},"defaction":"DEFELEM_UNSPEC","location":3}}]}}}]} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_array.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_array.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_array.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_array.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_array.test new file mode 100644 index 0000000..8ee83ff --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_array.test @@ -0,0 +1,270 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of array variables +|-- +-- We also check arrays of composites here, so this has some overlap +-- with the plpgsql_record tests. +|-- + +create type complex as (r float8, i float8) +-- +[] +== 002 +create type quadarray as (c1 complex[], c2 complex) +-- +[] +== 003 +do $$ declare a int[]; +begin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := array[1,2]","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[3] := 4","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 004 +do $$ declare a int[]; +begin a[3] := 4; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[3] := 4","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 005 +do $$ declare a int[]; +begin a[1][4] := 4; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1][4] := 4","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 006 +do $$ declare a int[]; +begin a[1] := 23::text; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1] := 23::text","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 007 +-- lax typing + +do $$ declare a int[]; +begin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := array[1,2]","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[2:3] := array[3,4]","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 008 +do $$ declare a int[]; +begin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := array[1,2]","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[2] := a[2] + 1","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 009 +do $$ declare a int[]; +begin a[1:2] := array[3,4]; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1:2] := array[3,4]","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 010 +do $$ declare a int[]; +begin a[1:2] := 4; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1:2] := 4","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 011 +-- error + +do $$ declare a complex[]; +begin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"complex[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1] := (1,2)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1].i := 11","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 012 +do $$ declare a complex[]; +begin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"complex[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1].i := 11","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %, a[1].i = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"a[1].i","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 013 +-- perhaps this ought to work, but for now it doesn't: +do $$ declare a complex[]; +begin a[1:2].i := array[11,12]; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"complex[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1:2].i := array[11,12]","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 014 +do $$ declare a quadarray; +begin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end$$ +-- +ERROR: "a.c1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 015 +do $$ declare a int[]; +begin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := array_agg(x) from (values(1),(2),(3)) v(x)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 016 +create temp table onecol as select array[1,2] as f1 +-- +[] +== 017 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := f1 from onecol","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 018 +do $$ declare a int[]; +begin a := * from onecol for update; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := * from onecol for update","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 019 +-- error cases: + +do $$ declare a int[]; +begin a := from onecol; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := from onecol","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 020 +do $$ declare a int[]; +begin a := f1, f1 from onecol; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := f1, f1 from onecol","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 021 +insert into onecol values(array[11]) +-- +[] +== 022 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := f1 from onecol","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 023 +do $$ declare a int[]; +begin a := f1 from onecol limit 1; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := f1 from onecol limit 1","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 024 +do $$ declare a real; +begin a[1] := 2; raise notice 'a = %', a; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"real"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a[1] := 2","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"a = %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 025 +do $$ declare a complex; +begin a.r[1] := 2; raise notice 'a = %', a; end$$ +-- +ERROR: "a.r" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 026 +|-- +-- test of %type[] and %rowtype[] syntax +|-- + +-- check supported syntax +do $$ +declare + v int; + v1 v%type; + v2 v%type[]; + v3 v%type[1]; + v4 v%type[][]; + v5 v%type[1][3]; + v6 v%type array; + v7 v%type array[]; + v8 v%type array[1]; + v9 v%type array[1][1]; + v10 pg_catalog.pg_class%rowtype[]; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(v3); + raise notice '%', pg_typeof(v4); + raise notice '%', pg_typeof(v5); + raise notice '%', pg_typeof(v6); + raise notice '%', pg_typeof(v7); + raise notice '%', pg_typeof(v8); + raise notice '%', pg_typeof(v9); + raise notice '%', pg_typeof(v10); +end; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"v1","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"v%type"}}}},{"PLpgSQL_var":{"refname":"v2","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"v%type[]"}}}},{"PLpgSQL_var":{"refname":"v3","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"v%type[1]"}}}},{"PLpgSQL_var":{"refname":"v4","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"v%type[][]"}}}},{"PLpgSQL_var":{"refname":"v5","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"v%type[1][3]"}}}},{"PLpgSQL_var":{"refname":"v6","lineno":9,"datatype":{"PLpgSQL_type":{"typname":"v%type array"}}}},{"PLpgSQL_var":{"refname":"v7","lineno":10,"datatype":{"PLpgSQL_type":{"typname":"v%type array[]"}}}},{"PLpgSQL_var":{"refname":"v8","lineno":11,"datatype":{"PLpgSQL_type":{"typname":"v%type array[1]"}}}},{"PLpgSQL_var":{"refname":"v9","lineno":12,"datatype":{"PLpgSQL_type":{"typname":"v%type array[1][1]"}}}},{"PLpgSQL_var":{"refname":"v10","lineno":13,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.pg_class%rowtype[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":14,"body":[{"PLpgSQL_stmt_raise":{"lineno":15,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v1)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":16,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v2)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":17,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v3)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":18,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v4)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":19,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v5)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":20,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v6)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":21,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v7)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":22,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v8)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":23,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v9)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":24,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v10)","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 027 +-- some types don't support arrays +do $$ +declare + v pg_node_tree; + v1 v%type[]; +begin +end; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_node_tree"}}}},{"PLpgSQL_var":{"refname":"v1","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"v%type[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 028 +-- check functionality +do $$ +declare + v1 int; + v2 varchar; + a1 v1%type[]; + a2 v2%type[]; +begin + v1 := 10; + v2 := 'Hi'; + a1 := array[v1,v1]; + a2 := array[v2,v2]; + raise notice '% %', a1, a2; +end; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v1","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"v2","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"varchar"}}}},{"PLpgSQL_var":{"refname":"a1","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"v1%type[]"}}}},{"PLpgSQL_var":{"refname":"a2","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"v2%type[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":7,"body":[{"PLpgSQL_stmt_assign":{"lineno":8,"varno":1,"expr":{"PLpgSQL_expr":{"query":"v1 := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":9,"varno":2,"expr":{"PLpgSQL_expr":{"query":"v2 := 'Hi'","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":10,"varno":3,"expr":{"PLpgSQL_expr":{"query":"a1 := array[v1,v1]","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":11,"varno":4,"expr":{"PLpgSQL_expr":{"query":"a2 := array[v2,v2]","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":18,"message":"% %","params":[{"PLpgSQL_expr":{"query":"a1","parseMode":2}},{"PLpgSQL_expr":{"query":"a2","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 029 +create table array_test_table(a int, b varchar) +-- +[] +== 030 +insert into array_test_table values(1, 'first'), (2, 'second') +-- +[] +== 031 +do $$ +declare tg array_test_table%rowtype[]; +begin + tg := array(select array_test_table from array_test_table); + raise notice '%', tg; + tg := array(select row(a,b) from array_test_table); + raise notice '%', tg; +end; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"tg","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"array_test_table%rowtype[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"tg := array(select array_test_table from array_test_table)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"tg","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"tg := array(select row(a,b) from array_test_table)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"tg","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_cache.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_cache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_cache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_cache.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_cache.test new file mode 100644 index 0000000..07f6d4d --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_cache.test @@ -0,0 +1,87 @@ +== 001 +|-- +-- Cache-behavior-dependent test cases +|-- +-- These tests logically belong in plpgsql_record.sql, and perhaps someday +-- can be merged back into it. For now, however, their results are different +-- depending on debug_discard_caches, so we must have two expected-output +-- files to cover both cases. To minimize the maintenance effort resulting +-- from that, this file should contain only tests that do have different +-- results under debug_discard_caches. +|-- + +-- check behavior with changes of a named rowtype +create table c_mutable(f1 int, f2 text) +-- +[] +== 002 +create function c_sillyaddone(int) returns int language plpgsql as +$$ declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +ERROR: "r.f1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"c_sillyaddone\" near line 1" +== 003 +select c_sillyaddone(42) +-- +[] +== 004 +alter table c_mutable drop column f1 +-- +[] +== 005 +alter table c_mutable add column f1 float8 +-- +[] +== 006 +-- currently, this fails due to cached plan for "r.f1 + 1" expression +-- (but if debug_discard_caches is on, it will succeed) +select c_sillyaddone(42) +-- +[] +== 007 +-- but it's OK if we force plan rebuilding +discard plans +-- +[] +== 008 +select c_sillyaddone(42) +-- +[] +== 009 +-- check behavior with changes in a record rowtype +create function show_result_type(text) returns text language plpgsql as +$$ + declare + r record; + t text; + begin + execute $1 into r; + select pg_typeof(r.a) into t; + return format('type %s value %s', t, r.a::text); + end; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":3}},{"PLpgSQL_var":{"refname":"t","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_recfield":{"fieldname":"a","recparentno":2}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":7,"fields":[{"name":"t","varno":3}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_dynexecute":{"lineno":6,"query":{"PLpgSQL_expr":{"query":"$1","parseMode":2}},"into":true,"target":{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":3}}}},{"PLpgSQL_stmt_execsql":{"lineno":7,"sqlstmt":{"PLpgSQL_expr":{"query":"select pg_typeof(r.a)","parseMode":0}},"into":true,"target":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":7,"fields":[{"name":"t","varno":3}]}}}},{"PLpgSQL_stmt_return":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"format('type %s value %s', t, r.a::text)","parseMode":2}}}}]}}}} +] +== 010 +select show_result_type('select 1 as a') +-- +[] +== 011 +-- currently this fails due to cached plan for pg_typeof expression +-- (but if debug_discard_caches is on, it will succeed) +select show_result_type('select 2.0 as a') +-- +[] +== 012 +-- but it's OK if we force plan rebuilding +discard plans +-- +[] +== 013 +select show_result_type('select 2.0 as a') +-- +[] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_call.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_call.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_call.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_call.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_call.test new file mode 100644 index 0000000..1d57855 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_call.test @@ -0,0 +1,842 @@ +== 001 +|-- +-- Tests for procedures / CALL syntax +|-- + +CREATE PROCEDURE test_proc1() +LANGUAGE plpgsql +AS $$ +BEGIN + NULL; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 002 +CALL test_proc1() +-- +[] +== 003 +-- error: can't return non-NULL +CREATE PROCEDURE test_proc2() +LANGUAGE plpgsql +AS $$ +BEGIN + RETURN 5; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"5","parseMode":2}}}}]}}}} +] +== 004 +CREATE TABLE test1 (a int) +-- +[] +== 005 +CREATE PROCEDURE test_proc3(x int) +LANGUAGE plpgsql +AS $$ +BEGIN + INSERT INTO test1 VALUES (x); +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_execsql":{"lineno":3,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 VALUES (x)","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 006 +CALL test_proc3(55) +-- +[] +== 007 +SELECT * FROM test1 +-- +[] +== 008 +-- Check that plan revalidation doesn't prevent setting transaction properties +-- (bug #18059). This test must include the first temp-object creation in +-- this script, or it won't exercise the bug scenario. Hence we put it early. +CREATE PROCEDURE test_proc3a() +LANGUAGE plpgsql +AS $$ +BEGIN + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + RAISE NOTICE 'done'; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_commit":{"lineno":3}},{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"SET TRANSACTION ISOLATION LEVEL REPEATABLE READ","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"done"}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 009 +CALL test_proc3a() +-- +[] +== 010 +CREATE TEMP TABLE tt1(f1 int) +-- +[] +== 011 +CALL test_proc3a() +-- +[] +== 012 +-- nested CALL +TRUNCATE TABLE test1 +-- +[] +== 013 +CREATE PROCEDURE test_proc4(y int) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL test_proc3(y); + CALL test_proc3($1); +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_call":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc3(y)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_call":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc3($1)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 014 +CALL test_proc4(66) +-- +[] +== 015 +SELECT * FROM test1 +-- +[] +== 016 +CALL test_proc4(66) +-- +[] +== 017 +SELECT * FROM test1 +-- +[] +== 018 +-- output arguments + +CREATE PROCEDURE test_proc5(INOUT a text) +LANGUAGE plpgsql +AS $$ +BEGIN + a := a || '+' || a; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"a := a || '+' || a","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 019 +CALL test_proc5('abc') +-- +[] +== 020 +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + b := b * a; + c := c * a; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"c","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"varno":1,"expr":{"PLpgSQL_expr":{"query":"b := b * a","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"c := c * a","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 021 +CALL test_proc6(2, 3, 4) +-- +[] +== 022 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); + RAISE INFO 'x = %, y = %', x, y; + CALL test_proc6(2, c => y, b => x); + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"3","parseMode":2}}}},{"PLpgSQL_var":{"refname":"y","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"4","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_call":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc6(2, x, y)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":17,"message":"x = %, y = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}},{"PLpgSQL_expr":{"query":"y","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc6(2, c =\u003e y, b =\u003e x)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":9,"elog_level":17,"message":"x = %, y = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}},{"PLpgSQL_expr":{"query":"y","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 023 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x + 1, y); -- error + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"3","parseMode":2}}}},{"PLpgSQL_var":{"refname":"y","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"4","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_call":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc6(2, x + 1, y)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":17,"message":"x = %, y = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}},{"PLpgSQL_expr":{"query":"y","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 024 +DO +LANGUAGE plpgsql +$$ +DECLARE + x constant int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); -- error because x is constant +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int "}},"isconst":true,"default_val":{"PLpgSQL_expr":{"query":"3","parseMode":2}}}},{"PLpgSQL_var":{"refname":"y","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"4","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_call":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc6(2, x, y)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 025 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + FOR i IN 1..5 LOOP + CALL test_proc6(i, x, y); + RAISE INFO 'x = %, y = %', x, y; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"3","parseMode":2}}}},{"PLpgSQL_var":{"refname":"y","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"4","parseMode":2}}}},{"PLpgSQL_var":{"refname":"i","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_fori":{"lineno":6,"var":{"PLpgSQL_var":{"refname":"i","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"5","parseMode":2}},"body":[{"PLpgSQL_stmt_call":{"lineno":7,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc6(i, x, y)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":17,"message":"x = %, y = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}},{"PLpgSQL_expr":{"query":"y","parseMode":2}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 026 +-- recursive with output arguments + +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN +IF x > 1 THEN + a := x / 10; + b := x / 2; + CALL test_proc7(b::int, a, b); +END IF; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"numeric\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_if":{"lineno":3,"cond":{"PLpgSQL_expr":{"query":"x \u003e 1","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := x / 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":2,"expr":{"PLpgSQL_expr":{"query":"b := x / 2","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc7(b::int, a, b)","parseMode":0}},"is_call":true}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 027 +CALL test_proc7(100, -1, -1) +-- +[] +== 028 +-- inner COMMIT with output arguments + +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN + a := x / 10; + b := x / 2; + COMMIT; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"numeric\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"varno":1,"expr":{"PLpgSQL_expr":{"query":"a := x / 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"b := x / 2","parseMode":3}}}},{"PLpgSQL_stmt_commit":{"lineno":5}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 029 +CREATE PROCEDURE test_proc7cc(_x int) +LANGUAGE plpgsql +AS $$ +DECLARE _a int; _b numeric; +BEGIN + CALL test_proc7c(_x, _a, _b); + RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"_x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"numeric"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_call":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc7c(_x, _a, _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"_x: %,_a: %, _b: %","params":[{"PLpgSQL_expr":{"query":"_x","parseMode":2}},{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 030 +CALL test_proc7cc(10) +-- +[] +== 031 +-- named parameters and defaults + +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := a * 10; + b := b + 10; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"a: %, b: %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"b","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"a := a * 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"b := b + 10","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 032 +CALL test_proc8a(10, 20) +-- +[] +== 033 +CALL test_proc8a(b => 20, a => 10) +-- +[] +== 034 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc8a(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; + CALL test_proc8a(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8a(_a, _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":7,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8a(b =\u003e _b, a =\u003e _a)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"_a: %, _b: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 035 +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"c","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"a: %, b: %, c: %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"b","parseMode":2}},{"PLpgSQL_expr":{"query":"c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"a := a * 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"b := b + 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":6,"varno":2,"expr":{"PLpgSQL_expr":{"query":"c := c * -10","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 036 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8b(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + CALL test_proc8b(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 50","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8b(_a, _b, _c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":7,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8b(_a, c =\u003e _c, b =\u003e _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 037 +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"c","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"a: %, b: %, c: %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"b","parseMode":2}},{"PLpgSQL_expr":{"query":"c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"a := a * 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"b := b + 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":6,"varno":2,"expr":{"PLpgSQL_expr":{"query":"c := c * -10","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 038 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(c => _c, b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 50","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8c(_a, _b, _c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 50","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8c(_a, c =\u003e _c, b =\u003e _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":9,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":10,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":10,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":10,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 50","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":11,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8c(c =\u003e _c, b =\u003e _b, a =\u003e _a)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 039 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 50","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8c(_a, _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 040 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, b => _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 50","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc8c(_a, b =\u003e _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 041 +-- OUT parameters + +CREATE PROCEDURE test_proc9(IN a int, OUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + b := a * 2; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"a: %, b: %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"b","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"b := a * 2","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 042 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc9(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc9(_a, _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 043 +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + b := a - c; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"c","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"a: %, b: %, c: %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"b","parseMode":2}},{"PLpgSQL_expr":{"query":"c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"b := a - c","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 044 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(a => _a, b => _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 7","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc10(_a, _b, _c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":8,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":8,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":8,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 7","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":9,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc10(_a, _b, c =\u003e _c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":12,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":12,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":12,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 7","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":13,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc10(a =\u003e _a, b =\u003e _b, c =\u003e _c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":14,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":16,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":16,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":16,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 7","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":17,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc10(_a, c =\u003e _c, b =\u003e _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":18,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":20,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":20,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":20,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 7","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":21,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc10(_a, _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":22,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":24,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":24,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":24,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 7","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":25,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc10(_a, b =\u003e _b)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":26,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":28,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":28,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":28,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 7","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":29,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc10(b =\u003e _b, a =\u003e _a)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":30,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 045 +-- OUT + VARIADIC + +CREATE PROCEDURE test_proc11(a OUT int, VARIADIC b int[]) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := b[1] + b[2]; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"a: %, b: %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"b","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"a := b[1] + b[2]","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 046 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc11(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":2,"expr":{"PLpgSQL_expr":{"query":"_b := 30","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"_c := 7","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc11(_a, _b, _c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 047 +-- polymorphic OUT arguments + +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %', a; + b := a; + c := array[a]; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"anyelement"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"anyelement"}}}},{"PLpgSQL_var":{"refname":"c","datatype":{"PLpgSQL_type":{"typname":"anyarray"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"a: %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"b := a","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":2,"expr":{"PLpgSQL_expr":{"query":"c := array[a]","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 048 +DO $$ +DECLARE _a int; _b int; _c int[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc12(_a, _b, _c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 049 +DO $$ +DECLARE _a int; _b int; _c text[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); -- error + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"_c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"text[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_a := 10","parseMode":3}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc12(_a, _b, _c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"_a: %, _b: %, _c: %","params":[{"PLpgSQL_expr":{"query":"_a","parseMode":2}},{"PLpgSQL_expr":{"query":"_b","parseMode":2}},{"PLpgSQL_expr":{"query":"_c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 050 +-- transition variable assignment + +TRUNCATE test1 +-- +[] +== 051 +CREATE FUNCTION triggerfunc1() RETURNS trigger +LANGUAGE plpgsql +AS $$ +DECLARE + z int := 0; +BEGIN + CALL test_proc6(2, NEW.a, NEW.a); + RETURN NEW; +END; +$$ +-- +[ +{"PLpgSQL_function":{"new_varno":1,"old_varno":2,"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"new","dno":1}},{"PLpgSQL_rec":{"refname":"old","dno":2}},{"PLpgSQL_var":{"refname":"z","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}},{"PLpgSQL_recfield":{"fieldname":"a","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL test_proc6(2, NEW.a, NEW.a)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"NEW","parseMode":2}}}}]}}}} +] +== 052 +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE PROCEDURE triggerfunc1() +-- +[] +== 053 +INSERT INTO test1 VALUES (1), (2), (3) +-- +[] +== 054 +UPDATE test1 SET a = 22 WHERE a = 2 +-- +[] +== 055 +SELECT * FROM test1 ORDER BY a +-- +[] +== 056 +DROP PROCEDURE test_proc1 +-- +[] +== 057 +DROP PROCEDURE test_proc3 +-- +[] +== 058 +DROP PROCEDURE test_proc4 +-- +[] +== 059 +DROP TABLE test1 +-- +[] +== 060 +-- more checks for named-parameter handling + +CREATE PROCEDURE p1(v_cnt int, v_Text inout text = NULL) +AS $$ +BEGIN + v_Text := 'v_cnt = ' || v_cnt; +END +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"v_cnt","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"v_text","datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"varno":1,"expr":{"PLpgSQL_expr":{"query":"v_Text := 'v_cnt = ' || v_cnt","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 061 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text + RAISE NOTICE '%', v_Text; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v_text","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"v_cnt","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"integer "}},"default_val":{"PLpgSQL_expr":{"query":"42","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_call":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"CALL p1(v_cnt := v_cnt)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"v_Text","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 062 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v_text","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"v_cnt","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"integer "}},"default_val":{"PLpgSQL_expr":{"query":"42","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_call":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"CALL p1(v_cnt := v_cnt, v_Text := v_Text)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"v_Text","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 063 +DO $$ +DECLARE + v_Text text; +BEGIN + CALL p1(10, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v_text","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"text"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL p1(10, v_Text := v_Text)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"v_Text","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 064 +DO $$ +DECLARE + v_Text text; + v_cnt integer; +BEGIN + CALL p1(v_Text := v_Text, v_cnt := v_cnt); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v_text","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"v_cnt","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_call":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"CALL p1(v_Text := v_Text, v_cnt := v_cnt)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"v_Text","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 065 +-- check that we detect change of dependencies in CALL +-- atomic and non-atomic call sites used to do this differently, so check both + +CREATE PROCEDURE inner_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'inner_p(%)', f1; +END +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"f1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"inner_p(%)","params":[{"PLpgSQL_expr":{"query":"f1","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 066 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 1 $$ LANGUAGE sql +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 067 +CREATE PROCEDURE outer_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'outer_p(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"f1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"outer_p(%)","params":[{"PLpgSQL_expr":{"query":"f1","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"CALL inner_p(f(f1))","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 068 +CREATE FUNCTION outer_f (f1 int) RETURNS void +AS $$ +BEGIN + RAISE NOTICE 'outer_f(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"f1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"outer_f(%)","params":[{"PLpgSQL_expr":{"query":"f1","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"CALL inner_p(f(f1))","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 069 +CALL outer_p(42) +-- +[] +== 070 +SELECT outer_f(42) +-- +[] +== 071 +DROP FUNCTION f(int) +-- +[] +== 072 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 2 $$ LANGUAGE sql +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 073 +CALL outer_p(42) +-- +[] +== 074 +SELECT outer_f(42) +-- +[] +== 075 +-- Check that stable functions in CALL see the correct snapshot + +CREATE TABLE t_test (x int) +-- +[] +== 076 +INSERT INTO t_test VALUES (0) +-- +[] +== 077 +CREATE FUNCTION f_get_x () RETURNS int +AS $$ +DECLARE l_result int; +BEGIN + SELECT x INTO l_result FROM t_test; + RETURN l_result; +END +$$ LANGUAGE plpgsql STABLE +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"l_result","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"l_result","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"SELECT x FROM t_test","parseMode":0}},"into":true,"target":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"l_result","varno":1}]}}}},{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"l_result","parseMode":2}}}}]}}}} +] +== 078 +CREATE PROCEDURE f_print_x (x int) +AS $$ +BEGIN + RAISE NOTICE 'f_print_x(%)', x; +END +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"f_print_x(%)","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 079 +-- test in non-atomic context +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + ROLLBACK; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_execsql":{"lineno":3,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE t_test SET x = x + 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"f_get_x(%)","params":[{"PLpgSQL_expr":{"query":"f_get_x()","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL f_print_x(f_get_x())","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE t_test SET x = x + 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"f_get_x(%)","params":[{"PLpgSQL_expr":{"query":"f_get_x()","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"CALL f_print_x(f_get_x())","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_rollback":{"lineno":9}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 080 +-- test in non-atomic context, except exception block is locally atomic +DO $$ +BEGIN + BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + EXCEPTION WHEN division_by_zero THEN + RAISE NOTICE '%', SQLERRM; + END; + ROLLBACK; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":10,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":10,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE t_test SET x = x + 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"f_get_x(%)","params":[{"PLpgSQL_expr":{"query":"f_get_x()","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"CALL f_print_x(f_get_x())","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_execsql":{"lineno":7,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE t_test SET x = x + 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"f_get_x(%)","params":[{"PLpgSQL_expr":{"query":"f_get_x()","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":9,"expr":{"PLpgSQL_expr":{"query":"CALL f_print_x(f_get_x())","parseMode":0}},"is_call":true}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"division_by_zero"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":11,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"SQLERRM","parseMode":2}}]}}]}}]}}}},{"PLpgSQL_stmt_rollback":{"lineno":13}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 081 +-- test in atomic context +BEGIN +-- +[] +== 082 +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_execsql":{"lineno":3,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE t_test SET x = x + 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"f_get_x(%)","params":[{"PLpgSQL_expr":{"query":"f_get_x()","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL f_print_x(f_get_x())","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE t_test SET x = x + 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"f_get_x(%)","params":[{"PLpgSQL_expr":{"query":"f_get_x()","parseMode":2}}]}},{"PLpgSQL_stmt_call":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"CALL f_print_x(f_get_x())","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 083 +ROLLBACK +-- +[] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_control.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_control.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_control.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_control.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_control.test new file mode 100644 index 0000000..5545eec --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_control.test @@ -0,0 +1,689 @@ +== 001 +|-- +-- Tests for PL/pgSQL control structures +|-- + +-- integer FOR loop + +do $$ +begin + -- basic case + for i in 1..3 loop + raise notice '1..3: i = %', i; + end loop; + -- with BY, end matches exactly + for i in 1..10 by 3 loop + raise notice '1..10 by 3: i = %', i; + end loop; + -- with BY, end does not match + for i in 1..11 by 3 loop + raise notice '1..11 by 3: i = %', i; + end loop; + -- zero iterations + for i in 1..0 by 3 loop + raise notice '1..0 by 3: i = %', i; + end loop; + -- REVERSE + for i in reverse 10..0 by 3 loop + raise notice 'reverse 10..0 by 3: i = %', i; + end loop; + -- potential overflow + for i in 2147483620..2147483647 by 10 loop + raise notice '2147483620..2147483647 by 10: i = %', i; + end loop; + -- potential overflow, reverse direction + for i in reverse -2147483620..-2147483647 by 10 loop + raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i; + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":12,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":16,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":20,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":24,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":28,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":4,"var":{"PLpgSQL_var":{"refname":"i","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"1..3: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_fori":{"lineno":8,"var":{"PLpgSQL_var":{"refname":"i","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":9,"elog_level":18,"message":"1..10 by 3: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_fori":{"lineno":12,"var":{"PLpgSQL_var":{"refname":"i","lineno":12,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"11","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":13,"elog_level":18,"message":"1..11 by 3: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_fori":{"lineno":16,"var":{"PLpgSQL_var":{"refname":"i","lineno":16,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"0","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":17,"elog_level":18,"message":"1..0 by 3: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_fori":{"lineno":20,"var":{"PLpgSQL_var":{"refname":"i","lineno":20,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"0","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"reverse":true,"body":[{"PLpgSQL_stmt_raise":{"lineno":21,"elog_level":18,"message":"reverse 10..0 by 3: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_fori":{"lineno":24,"var":{"PLpgSQL_var":{"refname":"i","lineno":24,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"2147483620","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"2147483647","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":25,"elog_level":18,"message":"2147483620..2147483647 by 10: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_fori":{"lineno":28,"var":{"PLpgSQL_var":{"refname":"i","lineno":28,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"-2147483620","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"-2147483647","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"reverse":true,"body":[{"PLpgSQL_stmt_raise":{"lineno":29,"elog_level":18,"message":"reverse -2147483620..-2147483647 by 10: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 002 +-- BY can't be zero or negative +do $$ +begin + for i in 1..3 by 0 loop + raise notice '1..3 by 0: i = %', i; + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"0","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"1..3 by 0: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 003 +do $$ +begin + for i in 1..3 by -1 loop + raise notice '1..3 by -1: i = %', i; + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"-1","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"1..3 by -1: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 004 +do $$ +begin + for i in reverse 1..3 by -1 loop + raise notice 'reverse 1..3 by -1: i = %', i; + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"step":{"PLpgSQL_expr":{"query":"-1","parseMode":2}},"reverse":true,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"reverse 1..3 by -1: i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 005 +-- CONTINUE statement + +create table conttesttbl(idx serial, v integer) +-- +[] +== 006 +insert into conttesttbl(v) values(10) +-- +[] +== 007 +insert into conttesttbl(v) values(20) +-- +[] +== 008 +insert into conttesttbl(v) values(30) +-- +[] +== 009 +insert into conttesttbl(v) values(40) +-- +[] +== 010 +create function continue_test1() returns void as $$ +declare _i integer = 0; _r record; +begin + raise notice '---1---'; + loop + _i := _i + 1; + raise notice '%', _i; + continue when _i < 10; + exit; + end loop; + + raise notice '---2---'; + <> + loop + _i := _i - 1; + loop + raise notice '%', _i; + continue lbl when _i > 0; + exit lbl; + end loop; + end loop; + + raise notice '---3---'; + <> + while _i < 10 loop + _i := _i + 1; + continue the_loop when _i % 2 = 0; + raise notice '%', _i; + end loop; + + raise notice '---4---'; + for _i in 1..10 loop + begin + -- applies to outer loop, not the nested begin block + continue when _i < 5; + raise notice '%', _i; + end; + end loop; + + raise notice '---5---'; + for _r in select * from conttesttbl loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---6---'; + for _r in execute 'select * from conttesttbl' loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---7---'; + <> + for _i in 1..3 loop + continue looplabel when _i = 2; + raise notice '%', _i; + end loop; + + raise notice '---8---'; + _i := 1; + while _i <= 3 loop + raise notice '%', _i; + _i := _i + 1; + continue when _i = 3; + end loop; + + raise notice '---9---'; + for _r in select * from conttesttbl order by v limit 1 loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---10---'; + for _r in execute 'select * from conttesttbl order by v limit 1' loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---11---'; + <> + for _i in 1..2 loop + raise notice 'outer %', _i; + <> + for _j in 1..3 loop + continue outerlooplabel when _j = 2; + raise notice 'inner %', _j; + end loop; + end loop; +end; $$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_i","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"integer "}},"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}},{"PLpgSQL_rec":{"refname":"_r","dno":2,"lineno":2}},{"PLpgSQL_var":{"refname":"_i","lineno":32,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_recfield":{"fieldname":"v","recparentno":2}},{"PLpgSQL_var":{"refname":"_i","lineno":54,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"_i","lineno":81,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"_j","lineno":84,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"---1---"}},{"PLpgSQL_stmt_loop":{"lineno":5,"body":[{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_i := _i + 1","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_i","parseMode":2}}]}},{"PLpgSQL_stmt_exit":{"lineno":8,"cond":{"PLpgSQL_expr":{"query":"_i \u003c 10","parseMode":2}}}},{"PLpgSQL_stmt_exit":{"lineno":9,"is_exit":true}}]}},{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":18,"message":"---2---"}},{"PLpgSQL_stmt_loop":{"lineno":14,"label":"lbl","body":[{"PLpgSQL_stmt_assign":{"lineno":15,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_i := _i - 1","parseMode":3}}}},{"PLpgSQL_stmt_loop":{"lineno":16,"body":[{"PLpgSQL_stmt_raise":{"lineno":17,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_i","parseMode":2}}]}},{"PLpgSQL_stmt_exit":{"lineno":18,"label":"lbl","cond":{"PLpgSQL_expr":{"query":"_i \u003e 0","parseMode":2}}}},{"PLpgSQL_stmt_exit":{"lineno":19,"is_exit":true,"label":"lbl"}}]}}]}},{"PLpgSQL_stmt_raise":{"lineno":23,"elog_level":18,"message":"---3---"}},{"PLpgSQL_stmt_while":{"lineno":25,"label":"the_loop","cond":{"PLpgSQL_expr":{"query":"_i \u003c 10","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":26,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_i := _i + 1","parseMode":3}}}},{"PLpgSQL_stmt_exit":{"lineno":27,"label":"the_loop","cond":{"PLpgSQL_expr":{"query":"_i % 2 = 0","parseMode":2}}}},{"PLpgSQL_stmt_raise":{"lineno":28,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_raise":{"lineno":31,"elog_level":18,"message":"---4---"}},{"PLpgSQL_stmt_fori":{"lineno":32,"var":{"PLpgSQL_var":{"refname":"_i","lineno":32,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"body":[{"PLpgSQL_stmt_block":{"lineno":33,"body":[{"PLpgSQL_stmt_exit":{"lineno":35,"cond":{"PLpgSQL_expr":{"query":"_i \u003c 5","parseMode":2}}}},{"PLpgSQL_stmt_raise":{"lineno":36,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_i","parseMode":2}}]}}]}}]}},{"PLpgSQL_stmt_raise":{"lineno":40,"elog_level":18,"message":"---5---"}},{"PLpgSQL_stmt_fors":{"lineno":41,"var":{"PLpgSQL_rec":{"refname":"_r","dno":2,"lineno":2}},"body":[{"PLpgSQL_stmt_exit":{"lineno":42,"cond":{"PLpgSQL_expr":{"query":"_r.v \u003c= 20","parseMode":2}}}},{"PLpgSQL_stmt_raise":{"lineno":43,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_r.v","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"select * from conttesttbl","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":46,"elog_level":18,"message":"---6---"}},{"PLpgSQL_stmt_dynfors":{"lineno":47,"var":{"PLpgSQL_rec":{"refname":"_r","dno":2,"lineno":2}},"body":[{"PLpgSQL_stmt_exit":{"lineno":48,"cond":{"PLpgSQL_expr":{"query":"_r.v \u003c= 20","parseMode":2}}}},{"PLpgSQL_stmt_raise":{"lineno":49,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_r.v","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"'select * from conttesttbl'","parseMode":2}}}},{"PLpgSQL_stmt_raise":{"lineno":52,"elog_level":18,"message":"---7---"}},{"PLpgSQL_stmt_fori":{"lineno":54,"label":"looplabel","var":{"PLpgSQL_var":{"refname":"_i","lineno":54,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_exit":{"lineno":55,"label":"looplabel","cond":{"PLpgSQL_expr":{"query":"_i = 2","parseMode":2}}}},{"PLpgSQL_stmt_raise":{"lineno":56,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_raise":{"lineno":59,"elog_level":18,"message":"---8---"}},{"PLpgSQL_stmt_assign":{"lineno":60,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_i := 1","parseMode":3}}}},{"PLpgSQL_stmt_while":{"lineno":61,"cond":{"PLpgSQL_expr":{"query":"_i \u003c= 3","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":62,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_i","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":63,"varno":1,"expr":{"PLpgSQL_expr":{"query":"_i := _i + 1","parseMode":3}}}},{"PLpgSQL_stmt_exit":{"lineno":64,"cond":{"PLpgSQL_expr":{"query":"_i = 3","parseMode":2}}}}]}},{"PLpgSQL_stmt_raise":{"lineno":67,"elog_level":18,"message":"---9---"}},{"PLpgSQL_stmt_fors":{"lineno":68,"var":{"PLpgSQL_rec":{"refname":"_r","dno":2,"lineno":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":69,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_r.v","parseMode":2}}]}},{"PLpgSQL_stmt_exit":{"lineno":70}}],"query":{"PLpgSQL_expr":{"query":"select * from conttesttbl order by v limit 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":73,"elog_level":18,"message":"---10---"}},{"PLpgSQL_stmt_dynfors":{"lineno":74,"var":{"PLpgSQL_rec":{"refname":"_r","dno":2,"lineno":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":75,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"_r.v","parseMode":2}}]}},{"PLpgSQL_stmt_exit":{"lineno":76}}],"query":{"PLpgSQL_expr":{"query":"'select * from conttesttbl order by v limit 1'","parseMode":2}}}},{"PLpgSQL_stmt_raise":{"lineno":79,"elog_level":18,"message":"---11---"}},{"PLpgSQL_stmt_fori":{"lineno":81,"label":"outerlooplabel","var":{"PLpgSQL_var":{"refname":"_i","lineno":81,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"2","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":82,"elog_level":18,"message":"outer %","params":[{"PLpgSQL_expr":{"query":"_i","parseMode":2}}]}},{"PLpgSQL_stmt_fori":{"lineno":84,"label":"innerlooplabel","var":{"PLpgSQL_var":{"refname":"_j","lineno":84,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_exit":{"lineno":85,"label":"outerlooplabel","cond":{"PLpgSQL_expr":{"query":"_j = 2","parseMode":2}}}},{"PLpgSQL_stmt_raise":{"lineno":86,"elog_level":18,"message":"inner %","params":[{"PLpgSQL_expr":{"query":"_j","parseMode":2}}]}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 011 +select continue_test1() +-- +[] +== 012 +-- should fail: CONTINUE is only legal inside a loop +create function continue_error1() returns void as $$ +begin + begin + continue; + end; +end; +$$ language plpgsql +-- +ERROR: CONTINUE cannot be used outside a loop +FILENAME: pl_gram.y +FUNCNAME: plpgsql_yyparse +CONTEXT: "compilation of PL/pgSQL function \"continue_error1\" near line 4" +== 013 +-- should fail: unlabeled EXIT is only legal inside a loop +create function exit_error1() returns void as $$ +begin + begin + exit; + end; +end; +$$ language plpgsql +-- +ERROR: EXIT cannot be used outside a loop, unless it has a label +FILENAME: pl_gram.y +FUNCNAME: plpgsql_yyparse +CONTEXT: "compilation of PL/pgSQL function \"exit_error1\" near line 4" +== 014 +-- should fail: no such label +create function continue_error2() returns void as $$ +begin + begin + loop + continue no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +ERROR: there is no label "no_such_label" attached to any block or loop enclosing this statement +FILENAME: pl_gram.y +FUNCNAME: plpgsql_yyparse +CONTEXT: "compilation of PL/pgSQL function \"continue_error2\" near line 5" +== 015 +-- should fail: no such label +create function exit_error2() returns void as $$ +begin + begin + loop + exit no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +ERROR: there is no label "no_such_label" attached to any block or loop enclosing this statement +FILENAME: pl_gram.y +FUNCNAME: plpgsql_yyparse +CONTEXT: "compilation of PL/pgSQL function \"exit_error2\" near line 5" +== 016 +-- should fail: CONTINUE can't reference the label of a named block +create function continue_error3() returns void as $$ +begin + <> + begin + loop + continue begin_block1; + end loop; + end; +end; +$$ language plpgsql +-- +ERROR: block label "begin_block1" cannot be used in CONTINUE +FILENAME: pl_gram.y +FUNCNAME: plpgsql_yyparse +CONTEXT: "compilation of PL/pgSQL function \"continue_error3\" near line 6" +== 017 +-- On the other hand, EXIT *can* reference the label of a named block +create function exit_block1() returns void as $$ +begin + <> + begin + loop + exit begin_block1; + raise exception 'should not get here'; + end loop; + end; +end; +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_block":{"lineno":4,"label":"begin_block1","body":[{"PLpgSQL_stmt_loop":{"lineno":5,"body":[{"PLpgSQL_stmt_exit":{"lineno":6,"is_exit":true,"label":"begin_block1"}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":21,"message":"should not get here"}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 018 +select exit_block1() +-- +[] +== 019 +-- verbose end block and end loop +create function end_label1() returns void as $$ +<> +begin + <> + for i in 1 .. 10 loop + raise notice 'i = %', i; + exit flbl1; + end loop flbl1; + <> + for j in 1 .. 10 loop + raise notice 'j = %', j; + exit flbl2; + end loop; +end blbl; +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"j","lineno":10,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"label":"blbl","body":[{"PLpgSQL_stmt_fori":{"lineno":5,"label":"flbl1","var":{"PLpgSQL_var":{"refname":"i","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}},{"PLpgSQL_stmt_exit":{"lineno":7,"is_exit":true,"label":"flbl1"}}]}},{"PLpgSQL_stmt_fori":{"lineno":10,"label":"flbl2","var":{"PLpgSQL_var":{"refname":"j","lineno":10,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":11,"elog_level":18,"message":"j = %","params":[{"PLpgSQL_expr":{"query":"j","parseMode":2}}]}},{"PLpgSQL_stmt_exit":{"lineno":12,"is_exit":true,"label":"flbl2"}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 020 +select end_label1() +-- +[] +== 021 +-- should fail: undefined end label +create function end_label2() returns void as $$ +begin + for _i in 1 .. 10 loop + exit; + end loop flbl1; +end; +$$ language plpgsql +-- +ERROR: end label "flbl1" specified for unlabeled block +FILENAME: pl_gram.y +FUNCNAME: check_labels +CONTEXT: "compilation of PL/pgSQL function \"end_label2\" near line 3" +== 022 +-- should fail: end label does not match start label +create function end_label3() returns void as $$ +<> +begin + <> + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +ERROR: end label "outer_label" differs from block's label "inner_label" +FILENAME: pl_gram.y +FUNCNAME: check_labels +CONTEXT: "compilation of PL/pgSQL function \"end_label3\" near line 5" +== 023 +-- should fail: end label on a block without a start label +create function end_label4() returns void as $$ +<> +begin + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +ERROR: end label "outer_label" specified for unlabeled block +FILENAME: pl_gram.y +FUNCNAME: check_labels +CONTEXT: "compilation of PL/pgSQL function \"end_label4\" near line 4" +== 024 +-- unlabeled exit matches no blocks +do $$ +begin +for i in 1..10 loop + <> + begin + begin -- unlabeled block + exit; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; +end loop; +raise notice 'should get here'; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"body":[{"PLpgSQL_stmt_block":{"lineno":5,"label":"innerblock","body":[{"PLpgSQL_stmt_block":{"lineno":6,"body":[{"PLpgSQL_stmt_exit":{"lineno":7,"is_exit":true}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"should not get here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":18,"message":"should not get here, either"}}]}},{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":18,"message":"nor here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":14,"elog_level":18,"message":"should get here"}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 025 +-- check exit out of an unlabeled block to a labeled one +do $$ +<> +begin + <> + begin + <> + begin + begin -- unlabeled block + exit innerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; + end; + raise notice 'should get here'; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"body":[{"PLpgSQL_stmt_block":{"lineno":3,"label":"outerblock","body":[{"PLpgSQL_stmt_block":{"lineno":5,"label":"innerblock","body":[{"PLpgSQL_stmt_block":{"lineno":7,"label":"moreinnerblock","body":[{"PLpgSQL_stmt_block":{"lineno":8,"body":[{"PLpgSQL_stmt_exit":{"lineno":9,"is_exit":true,"label":"innerblock"}},{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":18,"message":"should not get here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":18,"message":"should not get here, either"}}]}},{"PLpgSQL_stmt_raise":{"lineno":14,"elog_level":18,"message":"nor here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":16,"elog_level":18,"message":"should get here"}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 026 +-- check exit out of outermost block +do $$ +<> +begin + <> + begin + exit outerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"body":[{"PLpgSQL_stmt_block":{"lineno":3,"label":"outerblock","body":[{"PLpgSQL_stmt_block":{"lineno":5,"label":"innerblock","body":[{"PLpgSQL_stmt_exit":{"lineno":6,"is_exit":true,"label":"outerblock"}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"should not get here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":9,"elog_level":18,"message":"should not get here, either"}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 027 +-- unlabeled exit does match a while loop +do $$ +begin + <> + while 1 > 0 loop + <> + while 1 > 0 loop + <> + while 1 > 0 loop + exit; + raise notice 'should not get here'; + end loop; + raise notice 'should get here'; + exit outermostwhile; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'should get here, too'; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_while":{"lineno":4,"label":"outermostwhile","cond":{"PLpgSQL_expr":{"query":"1 \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_while":{"lineno":6,"label":"outerwhile","cond":{"PLpgSQL_expr":{"query":"1 \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_while":{"lineno":8,"label":"innerwhile","cond":{"PLpgSQL_expr":{"query":"1 \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_exit":{"lineno":9,"is_exit":true}},{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":18,"message":"should not get here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":18,"message":"should get here"}},{"PLpgSQL_stmt_exit":{"lineno":13,"is_exit":true,"label":"outermostwhile"}},{"PLpgSQL_stmt_raise":{"lineno":14,"elog_level":18,"message":"should not get here, either"}}]}},{"PLpgSQL_stmt_raise":{"lineno":16,"elog_level":18,"message":"nor here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":18,"elog_level":18,"message":"should get here, too"}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 028 +-- check exit out of an unlabeled while to a labeled one +do $$ +begin + <> + while 1 > 0 loop + while 1 > 0 loop + exit outerwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'should get here'; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_while":{"lineno":4,"label":"outerwhile","cond":{"PLpgSQL_expr":{"query":"1 \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_while":{"lineno":5,"cond":{"PLpgSQL_expr":{"query":"1 \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_exit":{"lineno":6,"is_exit":true,"label":"outerwhile"}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"should not get here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":9,"elog_level":18,"message":"should not get here, either"}}]}},{"PLpgSQL_stmt_raise":{"lineno":11,"elog_level":18,"message":"should get here"}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 029 +-- continue to an outer while +do $$ +declare i int := 0; +begin + <> + while i < 2 loop + raise notice 'outermostwhile, i = %', i; + i := i + 1; + <> + while 1 > 0 loop + <> + while 1 > 0 loop + continue outermostwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'out of outermostwhile, i = %', i; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_while":{"lineno":5,"label":"outermostwhile","cond":{"PLpgSQL_expr":{"query":"i \u003c 2","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"outermostwhile, i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":1,"expr":{"PLpgSQL_expr":{"query":"i := i + 1","parseMode":3}}}},{"PLpgSQL_stmt_while":{"lineno":9,"label":"outerwhile","cond":{"PLpgSQL_expr":{"query":"1 \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_while":{"lineno":11,"label":"innerwhile","cond":{"PLpgSQL_expr":{"query":"1 \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_exit":{"lineno":12,"label":"outermostwhile"}},{"PLpgSQL_stmt_raise":{"lineno":13,"elog_level":18,"message":"should not get here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":15,"elog_level":18,"message":"should not get here, either"}}]}},{"PLpgSQL_stmt_raise":{"lineno":17,"elog_level":18,"message":"nor here"}}]}},{"PLpgSQL_stmt_raise":{"lineno":19,"elog_level":18,"message":"out of outermostwhile, i = %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 030 +-- return out of a while +create function return_from_while() returns int language plpgsql as $$ +declare i int := 0; +begin + while i < 10 loop + if i > 2 then + return i; + end if; + i := i + 1; + end loop; + return null; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_while":{"lineno":4,"cond":{"PLpgSQL_expr":{"query":"i \u003c 10","parseMode":2}},"body":[{"PLpgSQL_stmt_if":{"lineno":5,"cond":{"PLpgSQL_expr":{"query":"i \u003e 2","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"i","parseMode":2}}}}]}},{"PLpgSQL_stmt_assign":{"lineno":8,"varno":1,"expr":{"PLpgSQL_expr":{"query":"i := i + 1","parseMode":3}}}}]}},{"PLpgSQL_stmt_return":{"lineno":10,"expr":{"PLpgSQL_expr":{"query":"null","parseMode":2}}}}]}}}} +] +== 031 +select return_from_while() +-- +[] +== 032 +-- using list of scalars in fori and fore stmts +create function for_vect() returns void as $proc$ +<>declare a integer; b varchar; c varchar; r record; +begin + -- fori + for i in 1 .. 3 loop + raise notice '%', i; + end loop; + -- fore with record var + for r in select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs loop + raise notice '% % %', r.aa, r.bb, r.cc; + end loop; + -- fore with single scalar + for a in select gs from generate_series(1,4) gs loop + raise notice '%', a; + end loop; + -- fore with multiple scalars + for a,b,c in select gs, 'BB','CC' from generate_series(1,4) gs loop + raise notice '% % %', a, b, c; + end loop; + -- using qualified names in fors, fore is enabled, disabled only for fori + for lbl.a, lbl.b, lbl.c in execute $$select gs, 'bb','cc' from generate_series(1,4) gs$$ loop + raise notice '% % %', a, b, c; + end loop; +end; +$proc$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_var":{"refname":"b","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"varchar"}}}},{"PLpgSQL_var":{"refname":"c","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"varchar"}}}},{"PLpgSQL_rec":{"refname":"r","dno":4,"lineno":2}},{"PLpgSQL_var":{"refname":"i","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_recfield":{"fieldname":"aa","recparentno":4}},{"PLpgSQL_recfield":{"fieldname":"bb","recparentno":4}},{"PLpgSQL_recfield":{"fieldname":"cc","recparentno":4}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":13,"fields":[{"name":"a","varno":1}]}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":17,"fields":[{"name":"a","varno":1},{"name":"b","varno":2},{"name":"c","varno":3}]}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":21,"fields":[{"name":"lbl.a","varno":1},{"name":"lbl.b","varno":2},{"name":"lbl.c","varno":3}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"label":"lbl","body":[{"PLpgSQL_stmt_fori":{"lineno":5,"var":{"PLpgSQL_var":{"refname":"i","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}]}},{"PLpgSQL_stmt_fors":{"lineno":9,"var":{"PLpgSQL_rec":{"refname":"r","dno":4,"lineno":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":18,"message":"% % %","params":[{"PLpgSQL_expr":{"query":"r.aa","parseMode":2}},{"PLpgSQL_expr":{"query":"r.bb","parseMode":2}},{"PLpgSQL_expr":{"query":"r.cc","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs","parseMode":0}}}},{"PLpgSQL_stmt_fors":{"lineno":13,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":13,"fields":[{"name":"a","varno":1}]}},"body":[{"PLpgSQL_stmt_raise":{"lineno":14,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"select gs from generate_series(1,4) gs","parseMode":0}}}},{"PLpgSQL_stmt_fors":{"lineno":17,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":17,"fields":[{"name":"a","varno":1},{"name":"b","varno":2},{"name":"c","varno":3}]}},"body":[{"PLpgSQL_stmt_raise":{"lineno":18,"elog_level":18,"message":"% % %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"b","parseMode":2}},{"PLpgSQL_expr":{"query":"c","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"select gs, 'BB','CC' from generate_series(1,4) gs","parseMode":0}}}},{"PLpgSQL_stmt_dynfors":{"lineno":21,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":21,"fields":[{"name":"lbl.a","varno":1},{"name":"lbl.b","varno":2},{"name":"lbl.c","varno":3}]}},"body":[{"PLpgSQL_stmt_raise":{"lineno":22,"elog_level":18,"message":"% % %","params":[{"PLpgSQL_expr":{"query":"a","parseMode":2}},{"PLpgSQL_expr":{"query":"b","parseMode":2}},{"PLpgSQL_expr":{"query":"c","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"$$select gs, 'bb','cc' from generate_series(1,4) gs$$","parseMode":2}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 033 +select for_vect() +-- +[] +== 034 +-- CASE statement + +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; + b int = 1; +begin + case $1 + when 1 then + return 'one'; + when 2 then + return 'two'; + when 3,4,3+5 then + return 'three, four or eight'; + when a then + return 'ten'; + when a+b, a+b+1 then + return 'eleven, twelve'; + end case; +end; +$$ language plpgsql immutable +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"10","parseMode":2}}}},{"PLpgSQL_var":{"refname":"b","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"1","parseMode":2}}}},{"PLpgSQL_var":{"refname":"__Case__Variable_4__","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_case":{"lineno":5,"t_expr":{"PLpgSQL_expr":{"query":"$1","parseMode":2}},"t_varno":4,"case_when_list":[{"PLpgSQL_case_when":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"\"__Case__Variable_4__\" IN (1)","parseMode":2}},"stmts":[{"PLpgSQL_stmt_return":{"lineno":7,"expr":{"PLpgSQL_expr":{"query":"'one'","parseMode":2}}}}]}},{"PLpgSQL_case_when":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"\"__Case__Variable_4__\" IN (2)","parseMode":2}},"stmts":[{"PLpgSQL_stmt_return":{"lineno":9,"expr":{"PLpgSQL_expr":{"query":"'two'","parseMode":2}}}}]}},{"PLpgSQL_case_when":{"lineno":10,"expr":{"PLpgSQL_expr":{"query":"\"__Case__Variable_4__\" IN (3,4,3+5)","parseMode":2}},"stmts":[{"PLpgSQL_stmt_return":{"lineno":11,"expr":{"PLpgSQL_expr":{"query":"'three, four or eight'","parseMode":2}}}}]}},{"PLpgSQL_case_when":{"lineno":12,"expr":{"PLpgSQL_expr":{"query":"\"__Case__Variable_4__\" IN (a)","parseMode":2}},"stmts":[{"PLpgSQL_stmt_return":{"lineno":13,"expr":{"PLpgSQL_expr":{"query":"'ten'","parseMode":2}}}}]}},{"PLpgSQL_case_when":{"lineno":14,"expr":{"PLpgSQL_expr":{"query":"\"__Case__Variable_4__\" IN (a+b, a+b+1)","parseMode":2}},"stmts":[{"PLpgSQL_stmt_return":{"lineno":15,"expr":{"PLpgSQL_expr":{"query":"'eleven, twelve'","parseMode":2}}}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 035 +select case_test(1) +-- +[] +== 036 +select case_test(2) +-- +[] +== 037 +select case_test(3) +-- +[] +== 038 +select case_test(4) +-- +[] +== 039 +select case_test(5) +-- +[] +== 040 +-- fails +select case_test(8) +-- +[] +== 041 +select case_test(10) +-- +[] +== 042 +select case_test(11) +-- +[] +== 043 +select case_test(12) +-- +[] +== 044 +select case_test(13) +-- +[] +== 045 +-- fails + +create or replace function catch() returns void as $$ +begin + raise notice '%', case_test(6); +exception + when case_not_found then + raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM; +end +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"body":[{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"case_test(6)","parseMode":2}}]}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"case_not_found"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"caught case_not_found % %","params":[{"PLpgSQL_expr":{"query":"SQLSTATE","parseMode":2}},{"PLpgSQL_expr":{"query":"SQLERRM","parseMode":2}}]}}]}}]}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 046 +select catch() +-- +[] +== 047 +-- test the searched variant too, as well as ELSE +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; +begin + case + when $1 = 1 then + return 'one'; + when $1 = a + 2 then + return 'twelve'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"10","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_case":{"lineno":4,"case_when_list":[{"PLpgSQL_case_when":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"$1 = 1","parseMode":2}},"stmts":[{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"'one'","parseMode":2}}}}]}},{"PLpgSQL_case_when":{"lineno":7,"expr":{"PLpgSQL_expr":{"query":"$1 = a + 2","parseMode":2}},"stmts":[{"PLpgSQL_stmt_return":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"'twelve'","parseMode":2}}}}]}}],"have_else":true,"else_stmts":[{"PLpgSQL_stmt_return":{"lineno":10,"expr":{"PLpgSQL_expr":{"query":"'other'","parseMode":2}}}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 048 +select case_test(1) +-- +[] +== 049 +select case_test(2) +-- +[] +== 050 +select case_test(12) +-- +[] +== 051 +select case_test(13) +-- +[] +== 052 +-- test line comment between WHEN and THEN +create or replace function case_comment(int) returns text as $$ +begin + case $1 + when 1 -- comment before THEN + then return 'one'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"__Case__Variable_2__","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_case":{"lineno":3,"t_expr":{"PLpgSQL_expr":{"query":"$1","parseMode":2}},"t_varno":2,"case_when_list":[{"PLpgSQL_case_when":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"\"__Case__Variable_2__\" IN (1)","parseMode":2}},"stmts":[{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"'one'","parseMode":2}}}}]}}],"have_else":true,"else_stmts":[{"PLpgSQL_stmt_return":{"lineno":7,"expr":{"PLpgSQL_expr":{"query":"'other'","parseMode":2}}}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 053 +select case_comment(1) +-- +[] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_copy.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_copy.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_copy.test new file mode 100644 index 0000000..2788c56 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_copy.test @@ -0,0 +1,21 @@ +== 001 +-- directory paths are passed to us in environment variables + +-- set up file names to use + +CREATE TABLE copy1 (a int, b float); + +-- COPY TO/FROM not authorized from client. +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 TO stdout; +END; +$$; +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 FROM stdin; +-- +ERROR: "unterminated dollar-quoted string at or near \"$$\nBEGIN\n COPY copy1 FROM stdin;\"" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_domain.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_domain.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_domain.test new file mode 100644 index 0000000..aca9591 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_domain.test @@ -0,0 +1,530 @@ +== 001 +|-- +-- Tests for PL/pgSQL's behavior with domain types +|-- + +CREATE DOMAIN booltrue AS bool CHECK (VALUE IS TRUE OR VALUE IS NULL) +-- +[] +== 002 +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"booltrue"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"bool"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"y","parseMode":2}}}}]}}}} +] +== 003 +SELECT * FROM test_argresult_booltrue(true, true) +-- +[] +== 004 +SELECT * FROM test_argresult_booltrue(false, true) +-- +[] +== 005 +SELECT * FROM test_argresult_booltrue(true, false) +-- +[] +== 006 +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $$ +declare v booltrue := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"bool"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"bool"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"booltrue "}},"default_val":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"v := y","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"v","parseMode":2}}}}]}}}} +] +== 007 +SELECT * FROM test_assign_booltrue(true, true) +-- +[] +== 008 +SELECT * FROM test_assign_booltrue(false, true) +-- +[] +== 009 +SELECT * FROM test_assign_booltrue(true, false) +-- +[] +== 010 +CREATE DOMAIN uint2 AS int2 CHECK (VALUE >= 0) +-- +[] +== 011 +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"uint2"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"y","parseMode":2}}}}]}}}} +] +== 012 +SELECT * FROM test_argresult_uint2(100::uint2, 50) +-- +[] +== 013 +SELECT * FROM test_argresult_uint2(100::uint2, -50) +-- +[] +== 014 +SELECT * FROM test_argresult_uint2(null, 1) +-- +[] +== 015 +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $$ +declare v uint2 := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"uint2 "}},"default_val":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"v := y","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"v","parseMode":2}}}}]}}}} +] +== 016 +SELECT * FROM test_assign_uint2(100, 50) +-- +[] +== 017 +SELECT * FROM test_assign_uint2(100, -50) +-- +[] +== 018 +SELECT * FROM test_assign_uint2(-100, 50) +-- +[] +== 019 +SELECT * FROM test_assign_uint2(null, 1) +-- +[] +== 020 +CREATE DOMAIN nnint AS int NOT NULL +-- +[] +== 021 +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"nnint"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"y","parseMode":2}}}}]}}}} +] +== 022 +SELECT * FROM test_argresult_nnint(10, 20) +-- +[] +== 023 +SELECT * FROM test_argresult_nnint(null, 20) +-- +[] +== 024 +SELECT * FROM test_argresult_nnint(10, null) +-- +[] +== 025 +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $$ +declare v nnint := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"nnint "}},"default_val":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"v := y","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"v","parseMode":2}}}}]}}}} +] +== 026 +SELECT * FROM test_assign_nnint(10, 20) +-- +[] +== 027 +SELECT * FROM test_assign_nnint(null, 20) +-- +[] +== 028 +SELECT * FROM test_assign_nnint(10, null) +-- +[] +== 029 +|-- +-- Domains over arrays +|-- + +CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]) +-- +[] +== 030 +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) + RETURNS ordered_pair_domain AS $$ +begin +return x; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"ordered_pair_domain"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}]}}}} +] +== 031 +SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain) +-- +[] +== 032 +SELECT * FROM test_argresult_array_domain(NULL::ordered_pair_domain) +-- +[] +== 033 +CREATE FUNCTION test_argresult_array_domain_check_violation() + RETURNS ordered_pair_domain AS $$ +begin +return array[2,1]; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"array[2,1]","parseMode":2}}}}]}}}} +] +== 034 +SELECT * FROM test_argresult_array_domain_check_violation() +-- +[] +== 035 +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $$ +declare v ordered_pair_domain := array[x, y]; +begin +v[2] := z; +return v; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"z","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"ordered_pair_domain "}},"default_val":{"PLpgSQL_expr":{"query":"array[x, y]","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":4,"expr":{"PLpgSQL_expr":{"query":"v[2] := z","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"v","parseMode":2}}}}]}}}} +] +== 036 +SELECT * FROM test_assign_ordered_pair_domain(1,2,3) +-- +[] +== 037 +SELECT * FROM test_assign_ordered_pair_domain(1,2,0) +-- +[] +== 038 +SELECT * FROM test_assign_ordered_pair_domain(2,1,3) +-- +[] +== 039 +|-- +-- Arrays of domains +|-- + +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"uint2"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"x[1]","parseMode":2}}}}]}}}} +] +== 040 +select test_read_uint2_array(array[1::uint2]) +-- +[] +== 041 +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $$ +begin +return array[x, x]; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"int2"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"array[x, x]","parseMode":2}}}}]}}}} +] +== 042 +select test_build_uint2_array(1::int2) +-- +[] +== 043 +select test_build_uint2_array(-1::int2) +-- +[] +== 044 +-- fail + +CREATE FUNCTION test_argresult_domain_array(x integer[]) + RETURNS ordered_pair_domain[] AS $$ +begin +return array[x::ordered_pair_domain, x::ordered_pair_domain]; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"array[x::ordered_pair_domain, x::ordered_pair_domain]","parseMode":2}}}}]}}}} +] +== 045 +select test_argresult_domain_array(array[2,4]) +-- +[] +== 046 +select test_argresult_domain_array(array[4,2]) +-- +[] +== 047 +-- fail + +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) + RETURNS integer AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"ordered_pair_domain"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"x[1]","parseMode":2}}}}]}}}} +] +== 048 +select test_argresult_domain_array2(array[2,4]) +-- +[] +== 049 +select test_argresult_domain_array2(array[4,2]) +-- +[] +== 050 +-- fail + +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) + RETURNS ordered_pair_domain AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"ordered_pair_domain"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"x[1]","parseMode":2}}}}]}}}} +] +== 051 +select test_argresult_array_domain_array(array[array[2,4]::ordered_pair_domain]) +-- +[] +== 052 +|-- +-- Domains within composite +|-- + +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +-- +[] +== 053 +CREATE FUNCTION test_result_nnint_container(x int, y int) + RETURNS nnint_container AS $$ +begin +return row(x, y)::nnint_container; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"row(x, y)::nnint_container","parseMode":2}}}}]}}}} +] +== 054 +SELECT test_result_nnint_container(null, 3) +-- +[] +== 055 +SELECT test_result_nnint_container(3, null) +-- +[] +== 056 +-- fail + +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container := row(x, y); +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +ERROR: "v.f2" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"test_assign_nnint_container\" near line 2" +== 057 +SELECT * FROM test_assign_nnint_container(1,2,3) +-- +[] +== 058 +SELECT * FROM test_assign_nnint_container(1,2,null) +-- +[] +== 059 +SELECT * FROM test_assign_nnint_container(1,null,3) +-- +[] +== 060 +-- Since core system allows this: +SELECT null::nnint_container +-- +[] +== 061 +-- so should PL/PgSQL + +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container; +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +ERROR: "v.f2" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"test_assign_nnint_container2\" near line 2" +== 062 +SELECT * FROM test_assign_nnint_container2(1,2,3) +-- +[] +== 063 +SELECT * FROM test_assign_nnint_container2(1,2,null) +-- +[] +== 064 +|-- +-- Domains of composite +|-- + +CREATE TYPE named_pair AS ( + i integer, + j integer +) +-- +[] +== 065 +CREATE DOMAIN ordered_named_pair AS named_pair CHECK((VALUE).i <= (VALUE).j) +-- +[] +== 066 +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS integer AS $$ +begin +return p.i + p.j; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"p","datatype":{"PLpgSQL_type":{"typname":"ordered_named_pair"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"p.i + p.j","parseMode":2}}}}]}}}} +] +== 067 +SELECT read_ordered_named_pair(row(1, 2)) +-- +[] +== 068 +SELECT read_ordered_named_pair(row(2, 1)) +-- +[] +== 069 +-- fail + +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $$ +begin +return row(i, j); +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"i","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"j","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"row(i, j)","parseMode":2}}}}]}}}} +] +== 070 +SELECT build_ordered_named_pair(1,2) +-- +[] +== 071 +SELECT build_ordered_named_pair(2,1) +-- +[] +== 072 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) + RETURNS ordered_named_pair AS $$ +declare v ordered_named_pair := row(x, y); +begin +v.j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +ERROR: "v.j" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"test_assign_ordered_named_pair\" near line 2" +== 073 +SELECT * FROM test_assign_ordered_named_pair(1,2,3) +-- +[] +== 074 +SELECT * FROM test_assign_ordered_named_pair(1,2,0) +-- +[] +== 075 +SELECT * FROM test_assign_ordered_named_pair(2,1,3) +-- +[] +== 076 +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $$ +begin +return array[row(i, j), row(i, j+1)]; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"i","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"j","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"array[row(i, j), row(i, j+1)]","parseMode":2}}}}]}}}} +] +== 077 +SELECT build_ordered_named_pairs(1,2) +-- +[] +== 078 +SELECT build_ordered_named_pairs(2,1) +-- +[] +== 079 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) + RETURNS ordered_named_pair[] AS $$ +declare v ordered_named_pair[] := array[row(x, y)]; +begin +-- ideally this would work, but it doesn't yet: +-- v[1].j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"z","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"ordered_named_pair[] "}},"default_val":{"PLpgSQL_expr":{"query":"array[row(x, y)]","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"v","parseMode":2}}}}]}}}} +] +== 080 +SELECT * FROM test_assign_ordered_named_pairs(1,2,3) +-- +[] +== 081 +SELECT * FROM test_assign_ordered_named_pairs(2,1,3) +-- +[] +== 082 +SELECT * FROM test_assign_ordered_named_pairs(1,2,0) +-- +[] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_misc.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_misc.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_misc.test new file mode 100644 index 0000000..6ae0e96 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_misc.test @@ -0,0 +1,103 @@ +== 001 +|-- +-- Miscellaneous topics +|-- + +-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE +do +$$ + declare procedure int; -- check we still recognize non-keywords as vars + begin + create function test1() returns int + begin atomic + select 2 + 2; + end; + create or replace procedure test2(x int) + begin atomic + select x + 2; + end; + end +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"procedure","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"create function test1() returns int\n begin atomic\n select 2 + 2;\n end","parseMode":0}}}},{"PLpgSQL_stmt_execsql":{"lineno":8,"sqlstmt":{"PLpgSQL_expr":{"query":"create or replace procedure test2(x int)\n begin atomic\n select x + 2;\n end","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 002 +-- Test %TYPE and %ROWTYPE error cases +create table misc_table(f1 int) +-- +[] +== 003 +do $$ declare x foo%type; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"foo%type"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 004 +do $$ declare x notice%type; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"notice%type"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 005 +-- covers unreserved-keyword case +do $$ declare x foo.bar%type; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"foo.bar%type"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 006 +do $$ declare x foo.bar.baz%type; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"foo.bar.baz%type"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 007 +do $$ declare x public.foo.bar%type; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"public.foo.bar%type"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 008 +do $$ declare x public.misc_table.zed%type; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"public.misc_table.zed%type"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 009 +do $$ declare x foo%rowtype; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"foo%rowtype"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 010 +do $$ declare x notice%rowtype; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"notice%rowtype"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 011 +-- covers unreserved-keyword case +do $$ declare x foo.bar%rowtype; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"foo.bar%rowtype"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 012 +do $$ declare x foo.bar.baz%rowtype; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"foo.bar.baz%rowtype"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 013 +do $$ declare x public.foo%rowtype; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"public.foo%rowtype"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 014 +do $$ declare x public.misc_table%rowtype; begin end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"public.misc_table%rowtype"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_record.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_record.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_record.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_record.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_record.test new file mode 100644 index 0000000..e63c9e5 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_record.test @@ -0,0 +1,1136 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of composite (record) variables +|-- + +create type two_int4s as (f1 int4, f2 int4) +-- +[] +== 002 +create type more_int4s as (f0 text, f1 int4, f2 int4) +-- +[] +== 003 +create type two_int8s as (q1 int8, q2 int8) +-- +[] +== 004 +create type nested_int8s as (c1 two_int8s, c2 two_int8s) +-- +[] +== 005 +-- base-case return of a composite type +create function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1)::two_int8s; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"row($1,1)::two_int8s","parseMode":2}}}}]}}}} +] +== 006 +select retc(42) +-- +[] +== 007 +-- ok to return a matching record type +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8); end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"row($1::int8, 1::int8)","parseMode":2}}}}]}}}} +] +== 008 +select retc(42) +-- +[] +== 009 +-- we don't currently support implicit casting +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1); end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"row($1,1)","parseMode":2}}}}]}}}} +] +== 010 +select retc(42) +-- +[] +== 011 +-- nor extra columns +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8, 42); end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"row($1::int8, 1::int8, 42)","parseMode":2}}}}]}}}} +] +== 012 +select retc(42) +-- +[] +== 013 +-- same cases with an intermediate "record" variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8); return r; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_assign":{"lineno":1,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := row($1::int8, 1::int8)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 014 +select retc(42) +-- +[] +== 015 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,1); return r; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_assign":{"lineno":1,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := row($1,1)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 016 +select retc(42) +-- +[] +== 017 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_assign":{"lineno":1,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := row($1::int8, 1::int8, 42)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 018 +select retc(42) +-- +[] +== 019 +-- but, for mostly historical reasons, we do convert when assigning +-- to a named-composite-type variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_assign":{"lineno":1,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := row($1::int8, 1::int8, 42)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 020 +select retc(42) +-- +[] +== 021 +do $$ declare c two_int8s; +begin c := row(1,2); raise notice 'c = %', c; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"c","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":1,"expr":{"PLpgSQL_expr":{"query":"c := row(1,2)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"c = %","params":[{"PLpgSQL_expr":{"query":"c","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 022 +do $$ declare c two_int8s; +begin for c in select 1,2 loop raise notice 'c = %', c; end loop; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"c","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":2,"fields":[{"name":"c","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fors":{"lineno":2,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":2,"fields":[{"name":"c","varno":1}]}},"body":[{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"c = %","params":[{"PLpgSQL_expr":{"query":"c","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"select 1,2","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 023 +do $$ declare c4 two_int4s; c8 two_int8s; +begin + c8 := row(1,2); + c4 := c8; + c8 := c4; + raise notice 'c4 = %', c4; + raise notice 'c8 = %', c8; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"c4","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"two_int4s"}}}},{"PLpgSQL_var":{"refname":"c8","lineno":1,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"varno":2,"expr":{"PLpgSQL_expr":{"query":"c8 := row(1,2)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"c4 := c8","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":2,"expr":{"PLpgSQL_expr":{"query":"c8 := c4","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"c4 = %","params":[{"PLpgSQL_expr":{"query":"c4","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"c8 = %","params":[{"PLpgSQL_expr":{"query":"c8","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 024 +do $$ declare c two_int8s; d nested_int8s; +begin + c := row(1,2); + d := row(c, row(c.q1, c.q2+1)); + raise notice 'c = %, d = %', c, d; + c.q1 := 10; + d.c1 := row(11,12); + d.c2.q2 := 42; + raise notice 'c = %, d = %', c, d; + raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2; + raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens + raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens +end$$ +-- +ERROR: "c.q1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 5" +== 025 +-- block-qualified naming +do $$ <> declare c two_int8s; d nested_int8s; +begin + b.c := row(1,2); + b.d := row(b.c, row(b.c.q1, b.c.q2+1)); + raise notice 'b.c = %, b.d = %', b.c, b.d; + b.c.q1 := 10; + b.d.c1 := row(11,12); + b.d.c2.q2 := 42; + raise notice 'b.c = %, b.d = %', b.c, b.d; + raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2; + raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens + raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens +end$$ +-- +ERROR: "b.c.q1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 5" +== 026 +-- error cases +do $$ declare c two_int8s; begin c.x = 1; end $$ +-- +ERROR: "c.x" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 027 +do $$ declare c nested_int8s; begin c.x = 1; end $$ +-- +ERROR: "c.x" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 028 +do $$ declare c nested_int8s; begin c.x.q1 = 1; end $$ +-- +ERROR: "c.x.q1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 029 +do $$ declare c nested_int8s; begin c.c2.x = 1; end $$ +-- +ERROR: "c.c2.x" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 030 +do $$ declare c nested_int8s; begin d.c2.x = 1; end $$ +-- +ERROR: "d.c2.x" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 031 +do $$ <> declare c two_int8s; begin b.c.x = 1; end $$ +-- +ERROR: "b.c.x" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 032 +do $$ <> declare c nested_int8s; begin b.c.x = 1; end $$ +-- +ERROR: "b.c.x" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 033 +do $$ <> declare c nested_int8s; begin b.c.x.q1 = 1; end $$ +-- +ERROR: "b.c.x" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 034 +do $$ <> declare c nested_int8s; begin b.c.c2.x = 1; end $$ +-- +ERROR: "b.c.c2" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 035 +do $$ <> declare c nested_int8s; begin b.d.c2.x = 1; end $$ +-- +ERROR: "b.d.c2" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 1" +== 036 +-- check passing composite result to another function +create function getq1(two_int8s) returns int8 language plpgsql as $$ +declare r two_int8s; begin r := $1; return r.q1; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := $1","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"r.q1","parseMode":2}}}}]}}}} +] +== 037 +select getq1(retc(344)) +-- +[] +== 038 +select getq1(row(1,2)) +-- +[] +== 039 +do $$ +declare r1 two_int8s; r2 record; x int8; +begin + r1 := retc(345); + perform getq1(r1); + x := getq1(r1); + raise notice 'x = %', x; + r2 := retc(346); + perform getq1(r2); + x := getq1(r2); + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r1","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}},{"PLpgSQL_rec":{"refname":"r2","dno":2,"lineno":2}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int8"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"r1 := retc(345)","parseMode":3}}}},{"PLpgSQL_stmt_perform":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"SELECT getq1(r1)","parseMode":0}}}},{"PLpgSQL_stmt_assign":{"lineno":6,"varno":3,"expr":{"PLpgSQL_expr":{"query":"x := getq1(r1)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":8,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r2 := retc(346)","parseMode":3}}}},{"PLpgSQL_stmt_perform":{"lineno":9,"expr":{"PLpgSQL_expr":{"query":"SELECT getq1(r2)","parseMode":0}}}},{"PLpgSQL_stmt_assign":{"lineno":10,"varno":3,"expr":{"PLpgSQL_expr":{"query":"x := getq1(r2)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":11,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 040 +-- check assignments of composites +do $$ +declare r1 two_int8s; r2 two_int8s; r3 record; r4 record; +begin + r1 := row(1,2); + raise notice 'r1 = %', r1; + r1 := r1; -- shouldn't do anything + raise notice 'r1 = %', r1; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := null; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := row(7,11)::two_int8s; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r3 := row(1,2); + r4 := r3; + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r1 := r3; + raise notice 'r1 = %', r1; + r4 := r1; + raise notice 'r4 = %', r4; + r4.q2 := r4.q2 + 1; -- r4's field names have changed + raise notice 'r4 = %', r4; +end$$ +-- +ERROR: "r2.q2" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 10" +== 041 +-- fields of named-type vars read as null if uninitialized +do $$ +declare r1 two_int8s; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r1","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"r1 = %","params":[{"PLpgSQL_expr":{"query":"r1","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"r1.q1 = %","params":[{"PLpgSQL_expr":{"query":"r1.q1","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"r1.q2 = %","params":[{"PLpgSQL_expr":{"query":"r1.q2","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"r1 = %","params":[{"PLpgSQL_expr":{"query":"r1","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 042 +do $$ +declare r1 two_int8s; +begin + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r1","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"r1.q1 = %","params":[{"PLpgSQL_expr":{"query":"r1.q1","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"r1.q2 = %","params":[{"PLpgSQL_expr":{"query":"r1.q2","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"r1 = %","params":[{"PLpgSQL_expr":{"query":"r1","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"r1.nosuchfield = %","params":[{"PLpgSQL_expr":{"query":"r1.nosuchfield","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 043 +-- records, not so much +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r1","dno":1,"lineno":2}},{"PLpgSQL_recfield":{"fieldname":"f1","recparentno":1}},{"PLpgSQL_recfield":{"fieldname":"f2","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"r1 = %","params":[{"PLpgSQL_expr":{"query":"r1","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"r1.f1 = %","params":[{"PLpgSQL_expr":{"query":"r1.f1","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"r1.f2 = %","params":[{"PLpgSQL_expr":{"query":"r1.f2","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"r1 = %","params":[{"PLpgSQL_expr":{"query":"r1","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 044 +-- but OK if you assign first +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + r1 := row(1,2); + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r1","dno":1,"lineno":2}},{"PLpgSQL_recfield":{"fieldname":"f1","recparentno":1}},{"PLpgSQL_recfield":{"fieldname":"f2","recparentno":1}},{"PLpgSQL_recfield":{"fieldname":"nosuchfield","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"r1 = %","params":[{"PLpgSQL_expr":{"query":"r1","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"r1 := row(1,2)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"r1.f1 = %","params":[{"PLpgSQL_expr":{"query":"r1.f1","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"r1.f2 = %","params":[{"PLpgSQL_expr":{"query":"r1.f2","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"r1 = %","params":[{"PLpgSQL_expr":{"query":"r1","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":9,"elog_level":18,"message":"r1.nosuchfield = %","params":[{"PLpgSQL_expr":{"query":"r1.nosuchfield","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 045 +-- check %type with block-qualified variable names +do $$ +<> +declare + v int; + r two_int8s; + v1 v%type; + v2 blk.v%type; + r1 r%type; + r2 blk.r%type; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(r1); + raise notice '%', pg_typeof(r2); +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"v","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"r","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}},{"PLpgSQL_var":{"refname":"v1","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"v%type"}}}},{"PLpgSQL_var":{"refname":"v2","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"blk.v%type"}}}},{"PLpgSQL_var":{"refname":"r1","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"r%type"}}}},{"PLpgSQL_var":{"refname":"r2","lineno":9,"datatype":{"PLpgSQL_type":{"typname":"blk.r%type"}}}}],"action":{"PLpgSQL_stmt_block":{"body":[{"PLpgSQL_stmt_block":{"lineno":10,"label":"blk","body":[{"PLpgSQL_stmt_raise":{"lineno":11,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v1)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(v2)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":13,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(r1)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":14,"elog_level":18,"message":"%","params":[{"PLpgSQL_expr":{"query":"pg_typeof(r2)","parseMode":2}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 046 +-- check that type record can be passed through %type +do $$ +declare r1 record; + r2 r1%type; +begin + r2 := row(1,2); + raise notice 'r2 = %', r2; + r2 := row(3,4,5); + raise notice 'r2 = %', r2; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r1","dno":1,"lineno":2}},{"PLpgSQL_var":{"refname":"r2","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"r1%type"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_assign":{"lineno":5,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r2 := row(1,2)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"r2 = %","params":[{"PLpgSQL_expr":{"query":"r2","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r2 := row(3,4,5)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"r2 = %","params":[{"PLpgSQL_expr":{"query":"r2","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 047 +-- arrays of record are not supported at the moment +do $$ +declare r1 record[]; +begin +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r1","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"record[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 048 +do $$ +declare r1 record; + r2 r1%type[]; +begin +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r1","dno":1,"lineno":2}},{"PLpgSQL_var":{"refname":"r2","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"r1%type[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_return":{}}]}}}} +] +== 049 +-- check repeated assignments to composite fields +create table some_table (id int, data text) +-- +[] +== 050 +do $$ +declare r some_table; +begin + r := (23, 'skidoo'); + for i in 1 .. 10 loop + r.id := r.id + i; + r.data := r.data || ' ' || i; + end loop; + raise notice 'r = %', r; +end$$ +-- +ERROR: "r.id" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 5" +== 051 +-- check behavior of function declared to return "record" + +create function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1); end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"row($1,$1+1)","parseMode":2}}}}]}}}} +] +== 052 +select returnsrecord(42) +-- +[] +== 053 +select * from returnsrecord(42) as r(x int, y int) +-- +[] +== 054 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +[] +== 055 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +[] +== 056 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1); return r; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_assign":{"lineno":1,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := row($1,$1+1)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 057 +select returnsrecord(42) +-- +[] +== 058 +select * from returnsrecord(42) as r(x int, y int) +-- +[] +== 059 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +[] +== 060 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +[] +== 061 +-- fail + +-- should work the same with a missing column in the actual result value +create table has_hole(f1 int, f2 int, f3 int) +-- +[] +== 062 +alter table has_hole drop column f2 +-- +[] +== 063 +create or replace function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1)::has_hole; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"row($1,$1+1)::has_hole","parseMode":2}}}}]}}}} +] +== 064 +select returnsrecord(42) +-- +[] +== 065 +select * from returnsrecord(42) as r(x int, y int) +-- +[] +== 066 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +[] +== 067 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +[] +== 068 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1)::has_hole; return r; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_assign":{"lineno":1,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := row($1,$1+1)::has_hole","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 069 +select returnsrecord(42) +-- +[] +== 070 +select * from returnsrecord(42) as r(x int, y int) +-- +[] +== 071 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +[] +== 072 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +[] +== 073 +-- fail + +-- check access to a field of an argument declared "record" +create function getf1(x record) returns int language plpgsql as +$$ begin return x.f1; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"record"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"x.f1","parseMode":2}}}}]}}}} +] +== 074 +select getf1(1) +-- +[] +== 075 +select getf1(row(1,2)) +-- +[] +== 076 +select getf1(row(1,2)::two_int4s) +-- +[] +== 077 +select getf1(row('foo',123,456)::more_int4s) +-- +[] +== 078 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf1(row(1,2)::two_int8s) +-- +[] +== 079 +select getf1(row(1,2)) +-- +[] +== 080 +-- this seemingly-equivalent case behaves a bit differently, +-- because the core parser's handling of $N symbols is simplistic +create function getf2(record) returns int language plpgsql as +$$ begin return $1.f2; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"record"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"$1.f2","parseMode":2}}}}]}}}} +] +== 081 +select getf2(row(1,2)) +-- +[] +== 082 +-- ideally would work, but does not +select getf2(row(1,2)::two_int4s) +-- +[] +== 083 +select getf2(row('foo',123,456)::more_int4s) +-- +[] +== 084 +-- check behavior when assignment to FOR-loop variable requires coercion +do $$ +declare r two_int8s; +begin + for r in select i, i+1 from generate_series(1,4) i + loop + raise notice 'r = %', r; + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"r","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_fors":{"lineno":4,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"r","varno":1}]}},"body":[{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"r = %","params":[{"PLpgSQL_expr":{"query":"r","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"select i, i+1 from generate_series(1,4) i","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 085 +-- check behavior when returning setof composite +create function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; + h has_hole; +begin + return next h; + r := (1,2); + h := (3,4); + return next r; + return next h; + return next row(5,6); + return next row(7,8)::has_hole; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":2}},{"PLpgSQL_var":{"refname":"h","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"has_hole"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_return_next":{"lineno":5}},{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"r := (1,2)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"h := (3,4)","parseMode":3}}}},{"PLpgSQL_stmt_return_next":{"lineno":8}},{"PLpgSQL_stmt_return_next":{"lineno":9}},{"PLpgSQL_stmt_return_next":{"lineno":10,"expr":{"PLpgSQL_expr":{"query":"row(5,6)","parseMode":2}}}},{"PLpgSQL_stmt_return_next":{"lineno":11,"expr":{"PLpgSQL_expr":{"query":"row(7,8)::has_hole","parseMode":2}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 086 +select returnssetofholes() +-- +[] +== 087 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; +begin + return next r; -- fails, not assigned yet +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_return_next":{"lineno":4}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 088 +select returnssetofholes() +-- +[] +== 089 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +begin + return next row(1,2,3); -- fails +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return_next":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"row(1,2,3)","parseMode":2}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 090 +select returnssetofholes() +-- +[] +== 091 +-- check behavior with changes of a named rowtype +create table mutable(f1 int, f2 text) +-- +[] +== 092 +create function sillyaddone(int) returns int language plpgsql as +$$ declare r mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +ERROR: "r.f1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"sillyaddone\" near line 1" +== 093 +select sillyaddone(42) +-- +[] +== 094 +-- test for change of type of column f1 should be here someday; +-- for now see plpgsql_cache test + +alter table mutable drop column f1 +-- +[] +== 095 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddone(42) +-- +[] +== 096 +-- fail + +create function getf3(x mutable) returns int language plpgsql as +$$ begin return x.f3; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"mutable"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"x.f3","parseMode":2}}}}]}}}} +] +== 097 +select getf3(null::mutable) +-- +[] +== 098 +-- doesn't work yet +alter table mutable add column f3 int +-- +[] +== 099 +select getf3(null::mutable) +-- +[] +== 100 +-- now it works +alter table mutable drop column f3 +-- +[] +== 101 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf3(null::mutable) +-- +[] +== 102 +-- fails again + +-- check behavior with creating/dropping a named rowtype +set check_function_bodies = off +-- +[] +== 103 +-- else reference to nonexistent type fails + +create function sillyaddtwo(int) returns int language plpgsql as +$$ declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end $$ +-- +ERROR: "r.f1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"sillyaddtwo\" near line 1" +== 104 +reset check_function_bodies +-- +[] +== 105 +select sillyaddtwo(42) +-- +[] +== 106 +-- fail +create table mutable2(f1 int, f2 text) +-- +[] +== 107 +select sillyaddtwo(42) +-- +[] +== 108 +drop table mutable2 +-- +[] +== 109 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddtwo(42) +-- +[] +== 110 +-- fail +create table mutable2(f0 text, f1 int, f2 text) +-- +[] +== 111 +select sillyaddtwo(42) +-- +[] +== 112 +select sillyaddtwo(43) +-- +[] +== 113 +-- check access to system columns in a record variable + +create function sillytrig() returns trigger language plpgsql as +$$begin + raise notice 'old.ctid = %', old.ctid; + raise notice 'old.tableoid = %', old.tableoid::regclass; + return new; +end$$ +-- +[ +{"PLpgSQL_function":{"new_varno":1,"old_varno":2,"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"new","dno":1}},{"PLpgSQL_rec":{"refname":"old","dno":2}},{"PLpgSQL_recfield":{"fieldname":"ctid","recparentno":2}},{"PLpgSQL_recfield":{"fieldname":"tableoid","recparentno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"old.ctid = %","params":[{"PLpgSQL_expr":{"query":"old.ctid","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"old.tableoid = %","params":[{"PLpgSQL_expr":{"query":"old.tableoid::regclass","parseMode":2}}]}},{"PLpgSQL_stmt_return":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"new","parseMode":2}}}}]}}}} +] +== 114 +create trigger mutable_trig before update on mutable for each row +execute procedure sillytrig() +-- +[] +== 115 +insert into mutable values ('foo'), ('bar') +-- +[] +== 116 +update mutable set f2 = f2 || ' baz' +-- +[] +== 117 +table mutable +-- +[] +== 118 +-- check returning a composite datum from a trigger + +create or replace function sillytrig() returns trigger language plpgsql as +$$begin + return row(new.*); +end$$ +-- +[ +{"PLpgSQL_function":{"new_varno":1,"old_varno":2,"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"new","dno":1}},{"PLpgSQL_rec":{"refname":"old","dno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"row(new.*)","parseMode":2}}}}]}}}} +] +== 119 +update mutable set f2 = f2 || ' baz' +-- +[] +== 120 +table mutable +-- +[] +== 121 +create or replace function sillytrig() returns trigger language plpgsql as +$$declare r record; +begin + r := row(new.*); + return r; +end$$ +-- +[ +{"PLpgSQL_function":{"new_varno":1,"old_varno":2,"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"new","dno":1}},{"PLpgSQL_rec":{"refname":"old","dno":2}},{"PLpgSQL_rec":{"refname":"r","dno":3,"lineno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"varno":3,"expr":{"PLpgSQL_expr":{"query":"r := row(new.*)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 122 +update mutable set f2 = f2 || ' baz' +-- +[] +== 123 +table mutable +-- +[] +== 124 +|-- +-- Domains of composite +|-- + +create domain ordered_int8s as two_int8s check((value).q1 <= (value).q2) +-- +[] +== 125 +create function read_ordered_int8s(p ordered_int8s) returns int8 as $$ +begin return p.q1 + p.q2; end +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"p","datatype":{"PLpgSQL_type":{"typname":"ordered_int8s"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"p.q1 + p.q2","parseMode":2}}}}]}}}} +] +== 126 +select read_ordered_int8s(row(1, 2)) +-- +[] +== 127 +select read_ordered_int8s(row(2, 1)) +-- +[] +== 128 +-- fail + +create function build_ordered_int8s(i int8, j int8) returns ordered_int8s as $$ +begin return row(i,j); end +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"i","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"j","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"row(i,j)","parseMode":2}}}}]}}}} +] +== 129 +select build_ordered_int8s(1,2) +-- +[] +== 130 +select build_ordered_int8s(2,1) +-- +[] +== 131 +-- fail + +create function build_ordered_int8s_2(i int8, j int8) returns ordered_int8s as $$ +declare r record; begin r := row(i,j); return r; end +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"i","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"j","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":3,"lineno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":3,"expr":{"PLpgSQL_expr":{"query":"r := row(i,j)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 132 +select build_ordered_int8s_2(1,2) +-- +[] +== 133 +select build_ordered_int8s_2(2,1) +-- +[] +== 134 +-- fail + +create function build_ordered_int8s_3(i int8, j int8) returns ordered_int8s as $$ +declare r two_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"i","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"j","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"two_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":3,"expr":{"PLpgSQL_expr":{"query":"r := row(i,j)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 135 +select build_ordered_int8s_3(1,2) +-- +[] +== 136 +select build_ordered_int8s_3(2,1) +-- +[] +== 137 +-- fail + +create function build_ordered_int8s_4(i int8, j int8) returns ordered_int8s as $$ +declare r ordered_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"i","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"j","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"ordered_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":2,"varno":3,"expr":{"PLpgSQL_expr":{"query":"r := row(i,j)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 138 +select build_ordered_int8s_4(1,2) +-- +[] +== 139 +select build_ordered_int8s_4(2,1) +-- +[] +== 140 +-- fail + +create function build_ordered_int8s_a(i int8, j int8) returns ordered_int8s[] as $$ +begin return array[row(i,j), row(i,j+1)]; end +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"i","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"j","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"array[row(i,j), row(i,j+1)]","parseMode":2}}}}]}}}} +] +== 141 +select build_ordered_int8s_a(1,2) +-- +[] +== 142 +select build_ordered_int8s_a(2,1) +-- +[] +== 143 +-- fail + +-- check field assignment +do $$ +declare r ordered_int8s; +begin + r.q1 := null; + r.q2 := 43; + r.q1 := 42; + r.q2 := 41; -- fail +end$$ +-- +ERROR: "r.q1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 2" +== 144 +-- check whole-row assignment +do $$ +declare r ordered_int8s; +begin + r := null; + r := row(null,null); + r := row(1,2); + r := row(2,1); -- fail +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"ordered_int8s"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"r := null","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"r := row(null,null)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"r := row(1,2)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":1,"expr":{"PLpgSQL_expr":{"query":"r := row(2,1)","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 145 +-- check assignment in for-loop +do $$ +declare r ordered_int8s; +begin + for r in values (1,2),(3,4),(6,5) loop + raise notice 'r = %', r; + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"ordered_int8s"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"r","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_fors":{"lineno":4,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"r","varno":1}]}},"body":[{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"r = %","params":[{"PLpgSQL_expr":{"query":"r","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"values (1,2),(3,4),(6,5)","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 146 +-- check behavior with toastable fields, too + +create type two_texts as (f1 text, f2 text) +-- +[] +== 147 +create domain ordered_texts as two_texts check((value).f1 <= (value).f2) +-- +[] +== 148 +create table sometable (id int, a text, b text) +-- +[] +== 149 +-- b should be compressed, but in-line +insert into sometable values (1, 'a', repeat('ffoob',1000)) +-- +[] +== 150 +-- this b should be out-of-line +insert into sometable values (2, 'a', repeat('ffoob',100000)) +-- +[] +== 151 +-- this pair should fail the domain check +insert into sometable values (3, 'z', repeat('ffoob',100000)) +-- +[] +== 152 +do $$ +declare d ordered_texts; +begin + for d in select a, b from sometable loop + raise notice 'succeeded at "%"', d.f1; + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"d","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"ordered_texts"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"d","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_fors":{"lineno":4,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"d","varno":1}]}},"body":[{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"succeeded at \"%\"","params":[{"PLpgSQL_expr":{"query":"d.f1","parseMode":2}}]}}],"query":{"PLpgSQL_expr":{"query":"select a, b from sometable","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 153 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := row(r.a, r.b); + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":2}},{"PLpgSQL_var":{"refname":"d","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"ordered_texts"}}}},{"PLpgSQL_recfield":{"fieldname":"id","recparentno":1}},{"PLpgSQL_recfield":{"fieldname":"a","recparentno":1}},{"PLpgSQL_recfield":{"fieldname":"b","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_fors":{"lineno":4,"var":{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":5,"elog_level":18,"message":"processing row %","params":[{"PLpgSQL_expr":{"query":"r.id","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":6,"varno":2,"expr":{"PLpgSQL_expr":{"query":"d := row(r.a, r.b)","parseMode":3}}}}],"query":{"PLpgSQL_expr":{"query":"select * from sometable","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 154 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := null; + d.f1 := r.a; + d.f2 := r.b; + end loop; +end$$ +-- +ERROR: "d.f1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 6" +== 155 +-- check coercion of a record result to named-composite function output type +create function compresult(int8) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,$1); return r; end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_assign":{"lineno":1,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := row($1,$1)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"r","parseMode":2}}}}]}}}} +] +== 156 +create table two_int8s_tab (f1 two_int8s) +-- +[] +== 157 +insert into two_int8s_tab values (compresult(42)) +-- +[] +== 158 +-- reconnect so we lose any local knowledge of anonymous record types +table two_int8s_tab +-- +[] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_simple.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_simple.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_simple.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_simple.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_simple.test new file mode 100644 index 0000000..fdc29c8 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_simple.test @@ -0,0 +1,186 @@ +== 001 +|-- +-- Tests for plpgsql's handling of "simple" expressions +|-- + +-- Check that changes to an inline-able function are handled correctly +create function simplesql(int) returns int language sql +as 'select $1' +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 002 +create function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simplesql(n); + if n = 5 then + create or replace function simplesql(int) returns int language sql + as 'select $1 + 100'; + end if; + end loop; + return sum; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"sum","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}},{"PLpgSQL_var":{"refname":"n","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_fori":{"lineno":5,"var":{"PLpgSQL_var":{"refname":"n","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"sum := sum + simplesql(n)","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":7,"cond":{"PLpgSQL_expr":{"query":"n = 5","parseMode":2}},"then_body":[{"PLpgSQL_stmt_execsql":{"lineno":8,"sqlstmt":{"PLpgSQL_expr":{"query":"create or replace function simplesql(int) returns int language sql\n as 'select $1 + 100'","parseMode":0}}}}]}}]}},{"PLpgSQL_stmt_return":{"lineno":12,"expr":{"PLpgSQL_expr":{"query":"sum","parseMode":2}}}}]}}}} +] +== 003 +select simplecaller() +-- +[] +== 004 +-- Check that changes in search path are dealt with correctly +create schema simple1 +-- +[] +== 005 +create function simple1.simpletarget(int) returns int language plpgsql +as $$begin return $1; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"$1","parseMode":2}}}}]}}}} +] +== 006 +create function simpletarget(int) returns int language plpgsql +as $$begin return $1 + 100; end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":1,"expr":{"PLpgSQL_expr":{"query":"$1 + 100","parseMode":2}}}}]}}}} +] +== 007 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simpletarget(n); + if n = 5 then + set local search_path = 'simple1'; + end if; + end loop; + return sum; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"sum","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}},{"PLpgSQL_var":{"refname":"n","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_fori":{"lineno":5,"var":{"PLpgSQL_var":{"refname":"n","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"sum := sum + simpletarget(n)","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":7,"cond":{"PLpgSQL_expr":{"query":"n = 5","parseMode":2}},"then_body":[{"PLpgSQL_stmt_execsql":{"lineno":8,"sqlstmt":{"PLpgSQL_expr":{"query":"set local search_path = 'simple1'","parseMode":0}}}}]}}]}},{"PLpgSQL_stmt_return":{"lineno":11,"expr":{"PLpgSQL_expr":{"query":"sum","parseMode":2}}}}]}}}} +] +== 008 +select simplecaller() +-- +[] +== 009 +-- try it with non-volatile functions, too +alter function simple1.simpletarget(int) immutable +-- +[] +== 010 +alter function simpletarget(int) immutable +-- +[] +== 011 +select simplecaller() +-- +[] +== 012 +-- make sure flushing local caches changes nothing + +select simplecaller() +-- +[] +== 013 +-- Check case where first attempt to determine if it's simple fails + +create function simplesql() returns int language sql +as $$select 1 / 0$$ +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 014 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + select simplesql() into x; + return x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"x","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"select simplesql()","parseMode":0}},"into":true,"target":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"x","varno":1}]}}}},{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}]}}}} +] +== 015 +select simplecaller() +-- +[] +== 016 +-- division by zero occurs during simple-expr check + +create or replace function simplesql() returns int language sql +as $$select 2 + 2$$ +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 017 +select simplecaller() +-- +[] +== 018 +-- Check case where called function changes from non-SRF to SRF (bug #18497) + +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + x := simplesql(); + return x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := simplesql()","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}]}}}} +] +== 019 +select simplecaller() +-- +[] +== 020 +drop function simplesql() +-- +[] +== 021 +create function simplesql() returns setof int language sql +as $$select 22 + 22$$ +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 022 +select simplecaller() +-- +[] +== 023 +select simplecaller() +-- +[] +== 024 +-- Check handling of simple expression in a scrollable cursor (bug #18859) + +do $$ +declare + p_CurData refcursor; + val int; +begin + open p_CurData scroll for select 42; + fetch p_CurData into val; + raise notice 'val = %', val; +end; $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"p_curdata","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"refcursor"}}}},{"PLpgSQL_var":{"refname":"val","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":7,"fields":[{"name":"val","varno":2}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_open":{"lineno":6,"curvar":1,"cursor_options":258,"query":{"PLpgSQL_expr":{"query":"select 42","parseMode":0}}}},{"PLpgSQL_stmt_fetch":{"lineno":7,"target":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":7,"fields":[{"name":"val","varno":2}]}},"curvar":1,"direction":0,"how_many":1}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"val = %","params":[{"PLpgSQL_expr":{"query":"val","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_transaction.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_transaction.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_transaction.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_transaction.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_transaction.test new file mode 100644 index 0000000..a26ac63 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_transaction.test @@ -0,0 +1,933 @@ +== 001 +CREATE TABLE test1 (a int, b text) +-- +[] +== 002 +CREATE PROCEDURE transaction_test1(x int, y text) +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..x LOOP + INSERT INTO test1 (a, b) VALUES (i, y); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"y","datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"0","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"x","parseMode":2}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a, b) VALUES (i, y)","parseMode":0}}}},{"PLpgSQL_stmt_if":{"lineno":5,"cond":{"PLpgSQL_expr":{"query":"i % 2 = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_commit":{"lineno":6}}],"else_body":[{"PLpgSQL_stmt_rollback":{"lineno":8}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 003 +CALL transaction_test1(9, 'foo') +-- +[] +== 004 +SELECT * FROM test1 +-- +[] +== 005 +TRUNCATE test1 +-- +[] +== 006 +DO +LANGUAGE plpgsql +$$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"0","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"9","parseMode":2}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (i)","parseMode":0}}}},{"PLpgSQL_stmt_if":{"lineno":5,"cond":{"PLpgSQL_expr":{"query":"i % 2 = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_commit":{"lineno":6}}],"else_body":[{"PLpgSQL_stmt_rollback":{"lineno":8}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 007 +SELECT * FROM test1 +-- +[] +== 008 +-- transaction commands not allowed when called in transaction block +START TRANSACTION +-- +[] +== 009 +CALL transaction_test1(9, 'error') +-- +[] +== 010 +COMMIT +-- +[] +== 011 +START TRANSACTION +-- +[] +== 012 +DO LANGUAGE plpgsql $$ BEGIN COMMIT; END $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_commit":{"lineno":1}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 013 +COMMIT +-- +[] +== 014 +TRUNCATE test1 +-- +[] +== 015 +-- not allowed in a function +CREATE FUNCTION transaction_test2() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; + RETURN 1; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"0","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"9","parseMode":2}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (i)","parseMode":0}}}},{"PLpgSQL_stmt_if":{"lineno":5,"cond":{"PLpgSQL_expr":{"query":"i % 2 = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_commit":{"lineno":6}}],"else_body":[{"PLpgSQL_stmt_rollback":{"lineno":8}}]}}]}},{"PLpgSQL_stmt_return":{"lineno":11,"expr":{"PLpgSQL_expr":{"query":"1","parseMode":2}}}}]}}}} +] +== 016 +SELECT transaction_test2() +-- +[] +== 017 +SELECT * FROM test1 +-- +[] +== 018 +-- also not allowed if procedure is called from a function +CREATE FUNCTION transaction_test3() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, 'error'); + RETURN 1; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_call":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"CALL transaction_test1(9, 'error')","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"1","parseMode":2}}}}]}}}} +] +== 019 +SELECT transaction_test3() +-- +[] +== 020 +SELECT * FROM test1 +-- +[] +== 021 +-- DO block inside function +CREATE FUNCTION transaction_test4() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'; + RETURN 1; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_dynexecute":{"lineno":3,"query":{"PLpgSQL_expr":{"query":"'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'","parseMode":2}}}},{"PLpgSQL_stmt_return":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"1","parseMode":2}}}}]}}}} +] +== 022 +SELECT transaction_test4() +-- +[] +== 023 +-- proconfig settings currently disallow transaction statements +CREATE PROCEDURE transaction_test5() +LANGUAGE plpgsql +SET work_mem = 555 +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_commit":{"lineno":3}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 024 +CALL transaction_test5() +-- +[] +== 025 +-- SECURITY DEFINER currently disallow transaction statements +CREATE PROCEDURE transaction_test5b() +LANGUAGE plpgsql +SECURITY DEFINER +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_commit":{"lineno":3}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 026 +CALL transaction_test5b() +-- +[] +== 027 +TRUNCATE test1 +-- +[] +== 028 +-- nested procedure calls +CREATE PROCEDURE transaction_test6(c text) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, c); +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"c","datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_call":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"CALL transaction_test1(9, c)","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 029 +CALL transaction_test6('bar') +-- +[] +== 030 +SELECT * FROM test1 +-- +[] +== 031 +TRUNCATE test1 +-- +[] +== 032 +CREATE PROCEDURE transaction_test7() +LANGUAGE plpgsql +AS $$ +BEGIN + DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_call":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 033 +CALL transaction_test7() +-- +[] +== 034 +SELECT * FROM test1 +-- +[] +== 035 +CREATE PROCEDURE transaction_test8() +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'CALL transaction_test1(10, $x$baz$x$)'; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_dynexecute":{"lineno":3,"query":{"PLpgSQL_expr":{"query":"'CALL transaction_test1(10, $x$baz$x$)'","parseMode":2}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 036 +CALL transaction_test8() +-- +[] +== 037 +-- commit inside cursor loop +CREATE TABLE test2 (x int) +-- +[] +== 038 +INSERT INTO test2 VALUES (0), (1), (2), (3), (4) +-- +[] +== 039 +TRUNCATE test1 +-- +[] +== 040 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + COMMIT; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},{"PLpgSQL_recfield":{"fieldname":"x","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_fors":{"lineno":5,"var":{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (r.x)","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":7}}],"query":{"PLpgSQL_expr":{"query":"SELECT * FROM test2 ORDER BY x","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 041 +SELECT * FROM test1 +-- +[] +== 042 +-- check that this doesn't leak a holdable portal +SELECT * FROM pg_cursors +-- +[] +== 043 +-- error in cursor loop with commit +TRUNCATE test1 +-- +[] +== 044 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (12/(r.x-2)); + COMMIT; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},{"PLpgSQL_recfield":{"fieldname":"x","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_fors":{"lineno":5,"var":{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (12/(r.x-2))","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":7}}],"query":{"PLpgSQL_expr":{"query":"SELECT * FROM test2 ORDER BY x","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 045 +SELECT * FROM test1 +-- +[] +== 046 +SELECT * FROM pg_cursors +-- +[] +== 047 +-- rollback inside cursor loop +TRUNCATE test1 +-- +[] +== 048 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},{"PLpgSQL_recfield":{"fieldname":"x","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_fors":{"lineno":5,"var":{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (r.x)","parseMode":0}}}},{"PLpgSQL_stmt_rollback":{"lineno":7}}],"query":{"PLpgSQL_expr":{"query":"SELECT * FROM test2 ORDER BY x","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 049 +SELECT * FROM test1 +-- +[] +== 050 +SELECT * FROM pg_cursors +-- +[] +== 051 +-- first commit then rollback inside cursor loop +TRUNCATE test1 +-- +[] +== 052 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + IF r.x % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},{"PLpgSQL_recfield":{"fieldname":"x","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_fors":{"lineno":5,"var":{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (r.x)","parseMode":0}}}},{"PLpgSQL_stmt_if":{"lineno":7,"cond":{"PLpgSQL_expr":{"query":"r.x % 2 = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_commit":{"lineno":8}}],"else_body":[{"PLpgSQL_stmt_rollback":{"lineno":10}}]}}],"query":{"PLpgSQL_expr":{"query":"SELECT * FROM test2 ORDER BY x","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 053 +SELECT * FROM test1 +-- +[] +== 054 +SELECT * FROM pg_cursors +-- +[] +== 055 +-- rollback inside cursor loop +TRUNCATE test1 +-- +[] +== 056 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},{"PLpgSQL_recfield":{"fieldname":"x","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_fors":{"lineno":5,"var":{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":3}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (r.x)","parseMode":0}}}},{"PLpgSQL_stmt_rollback":{"lineno":7}}],"query":{"PLpgSQL_expr":{"query":"UPDATE test2 SET x = x * 2 RETURNING x","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 057 +SELECT * FROM test1 +-- +[] +== 058 +SELECT * FROM test2 +-- +[] +== 059 +SELECT * FROM pg_cursors +-- +[] +== 060 +-- interaction of FOR UPDATE cursor with subsequent updates (bug #17050) +TRUNCATE test1 +-- +[] +== 061 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +[] +== 062 +DO LANGUAGE plpgsql $$ +DECLARE + l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE; +BEGIN + FOR r IN l_cur LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"l_cur","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.refcursor"}},"cursor_explicit_expr":{"PLpgSQL_expr":{"query":"SELECT a FROM test1 ORDER BY 1 FOR UPDATE","parseMode":0}},"cursor_explicit_argrow":-1,"cursor_options":256}},{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":5}},{"PLpgSQL_recfield":{"fieldname":"a","recparentno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_forc":{"lineno":5,"var":{"PLpgSQL_rec":{"refname":"r","dno":2,"lineno":5}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE test1 SET b = b || ' ' || b WHERE a = r.a","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":7}}],"curvar":1}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 063 +SELECT * FROM test1 +-- +[] +== 064 +SELECT * FROM pg_cursors +-- +[] +== 065 +-- like bug #17050, but with implicit cursor +TRUNCATE test1 +-- +[] +== 066 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +[] +== 067 +DO LANGUAGE plpgsql $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT a FROM test1 FOR UPDATE LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":2}},{"PLpgSQL_recfield":{"fieldname":"a","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_fors":{"lineno":4,"var":{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":2}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":5,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE test1 SET b = b || ' ' || b WHERE a = r.a","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":6}}],"query":{"PLpgSQL_expr":{"query":"SELECT a FROM test1 FOR UPDATE","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 068 +SELECT * FROM test1 +-- +[] +== 069 +SELECT * FROM pg_cursors +-- +[] +== 070 +-- commit inside block with exception handler +TRUNCATE test1 +-- +[] +== 071 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + COMMIT; + INSERT INTO test1 (a) VALUES (1/0); + COMMIT; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (1)","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":5}},{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (1/0)","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":7}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"division_by_zero"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":18,"message":"caught division_by_zero"}}]}}]}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 072 +SELECT * FROM test1 +-- +[] +== 073 +-- rollback inside block with exception handler +TRUNCATE test1 +-- +[] +== 074 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + ROLLBACK; + INSERT INTO test1 (a) VALUES (1/0); + ROLLBACK; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (1)","parseMode":0}}}},{"PLpgSQL_stmt_rollback":{"lineno":5}},{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (1/0)","parseMode":0}}}},{"PLpgSQL_stmt_rollback":{"lineno":7}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"division_by_zero"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":18,"message":"caught division_by_zero"}}]}}]}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 075 +SELECT * FROM test1 +-- +[] +== 076 +-- test commit/rollback inside exception handler, too +TRUNCATE test1 +-- +[] +== 077 +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 1..10 LOOP + BEGIN + INSERT INTO test1 VALUES (i, 'good'); + INSERT INTO test1 VALUES (i/0, 'bad'); + EXCEPTION + WHEN division_by_zero THEN + INSERT INTO test1 VALUES (i, 'exception'); + IF (i % 3) > 0 THEN COMMIT; ELSE ROLLBACK; END IF; + END; + END LOOP; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"10","parseMode":2}},"body":[{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_execsql":{"lineno":5,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 VALUES (i, 'good')","parseMode":0}}}},{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 VALUES (i/0, 'bad')","parseMode":0}}}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"division_by_zero"}}],"action":[{"PLpgSQL_stmt_execsql":{"lineno":9,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 VALUES (i, 'exception')","parseMode":0}}}},{"PLpgSQL_stmt_if":{"lineno":10,"cond":{"PLpgSQL_expr":{"query":"(i % 3) \u003e 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_commit":{"lineno":10}}],"else_body":[{"PLpgSQL_stmt_rollback":{"lineno":10}}]}}]}}]}}}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 078 +SELECT * FROM test1 +-- +[] +== 079 +-- detoast result of simple expression after commit +CREATE TEMP TABLE test4(f1 text) +-- +[] +== 080 +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE EXTERNAL +-- +[] +== 081 +-- disable compression +INSERT INTO test4 SELECT repeat('xyzzy', 2000) +-- +[] +== 082 +-- immutable mark is a bit of a lie, but it serves to make call a simple expr +-- that will return a still-toasted value +CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql +AS 'select f1 from test4' IMMUTABLE +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 083 +DO $$ +declare x text; +begin + for i in 1..3 loop + x := data_source(i); + commit; + end loop; + raise notice 'length(x) = %', length(x); +end $$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"i","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_fori":{"lineno":4,"var":{"PLpgSQL_var":{"refname":"i","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := data_source(i)","parseMode":3}}}},{"PLpgSQL_stmt_commit":{"lineno":6}}]}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"length(x) = %","params":[{"PLpgSQL_expr":{"query":"length(x)","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 084 +-- operations on composite types vs. internal transactions +DO LANGUAGE plpgsql $$ +declare + c test1 := row(42, 'hello'); + r bool; +begin + for i in 1..3 loop + r := c is not null; + raise notice 'r = %', r; + commit; + end loop; + for i in 1..3 loop + r := c is null; + raise notice 'r = %', r; + rollback; + end loop; +end +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"c","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"test1 "}},"default_val":{"PLpgSQL_expr":{"query":"row(42, 'hello')","parseMode":2}}}},{"PLpgSQL_var":{"refname":"r","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"bool"}}}},{"PLpgSQL_var":{"refname":"i","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":11,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_fori":{"lineno":6,"var":{"PLpgSQL_var":{"refname":"i","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := c is not null","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"r = %","params":[{"PLpgSQL_expr":{"query":"r","parseMode":2}}]}},{"PLpgSQL_stmt_commit":{"lineno":9}}]}},{"PLpgSQL_stmt_fori":{"lineno":11,"var":{"PLpgSQL_var":{"refname":"i","lineno":11,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":12,"varno":2,"expr":{"PLpgSQL_expr":{"query":"r := c is null","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":13,"elog_level":18,"message":"r = %","params":[{"PLpgSQL_expr":{"query":"r","parseMode":2}}]}},{"PLpgSQL_stmt_rollback":{"lineno":14}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 085 +-- COMMIT failures +DO LANGUAGE plpgsql $$ +BEGIN + CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + INSERT INTO test3 (y) VALUES (2); + COMMIT; + INSERT INTO test3 (y) VALUES (3); -- won't get here +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_execsql":{"lineno":3,"sqlstmt":{"PLpgSQL_expr":{"query":"CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED)","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":4}},{"PLpgSQL_stmt_execsql":{"lineno":5,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test3 (y) VALUES (1)","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":6}},{"PLpgSQL_stmt_execsql":{"lineno":7,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test3 (y) VALUES (1)","parseMode":0}}}},{"PLpgSQL_stmt_execsql":{"lineno":8,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test3 (y) VALUES (2)","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":9}},{"PLpgSQL_stmt_execsql":{"lineno":10,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test3 (y) VALUES (3)","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 086 +SELECT * FROM test3 +-- +[] +== 087 +-- failure while trying to persist a cursor across a transaction (bug #15703) +CREATE PROCEDURE cursor_fail_during_commit() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + COMMIT; + END LOOP; + END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"id","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"id","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_fors":{"lineno":4,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"id","varno":1}]}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":5,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 VALUES(id)","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":6}}],"query":{"PLpgSQL_expr":{"query":"SELECT 1/(x-1000) FROM generate_series(1,1000) x","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 088 +TRUNCATE test1 +-- +[] +== 089 +CALL cursor_fail_during_commit() +-- +[] +== 090 +-- note that error occurs during first COMMIT, hence nothing is in test1 +SELECT count(*) FROM test1 +-- +[] +== 091 +CREATE PROCEDURE cursor_fail_during_rollback() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + ROLLBACK; + END LOOP; + END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"id","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"id","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_fors":{"lineno":4,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":4,"fields":[{"name":"id","varno":1}]}},"body":[{"PLpgSQL_stmt_execsql":{"lineno":5,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 VALUES(id)","parseMode":0}}}},{"PLpgSQL_stmt_rollback":{"lineno":6}}],"query":{"PLpgSQL_expr":{"query":"SELECT 1/(x-1000) FROM generate_series(1,1000) x","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 092 +TRUNCATE test1 +-- +[] +== 093 +CALL cursor_fail_during_rollback() +-- +[] +== 094 +SELECT count(*) FROM test1 +-- +[] +== 095 +-- SET TRANSACTION +DO LANGUAGE plpgsql $$ +BEGIN + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_perform":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"SELECT 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":17,"message":"%","params":[{"PLpgSQL_expr":{"query":"current_setting('transaction_isolation')","parseMode":2}}]}},{"PLpgSQL_stmt_commit":{"lineno":5}},{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"SET TRANSACTION ISOLATION LEVEL REPEATABLE READ","parseMode":0}}}},{"PLpgSQL_stmt_perform":{"lineno":7,"expr":{"PLpgSQL_expr":{"query":"SELECT 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":17,"message":"%","params":[{"PLpgSQL_expr":{"query":"current_setting('transaction_isolation')","parseMode":2}}]}},{"PLpgSQL_stmt_commit":{"lineno":9}},{"PLpgSQL_stmt_execsql":{"lineno":10,"sqlstmt":{"PLpgSQL_expr":{"query":"SET TRANSACTION ISOLATION LEVEL SERIALIZABLE","parseMode":0}}}},{"PLpgSQL_stmt_perform":{"lineno":11,"expr":{"PLpgSQL_expr":{"query":"SELECT 1","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":17,"message":"%","params":[{"PLpgSQL_expr":{"query":"current_setting('transaction_isolation')","parseMode":2}}]}},{"PLpgSQL_stmt_commit":{"lineno":13}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 096 +-- error cases +DO LANGUAGE plpgsql $$ +BEGIN + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_execsql":{"lineno":3,"sqlstmt":{"PLpgSQL_expr":{"query":"SET TRANSACTION ISOLATION LEVEL REPEATABLE READ","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 097 +DO LANGUAGE plpgsql $$ +BEGIN + SAVEPOINT foo; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_execsql":{"lineno":3,"sqlstmt":{"PLpgSQL_expr":{"query":"SAVEPOINT foo","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 098 +DO LANGUAGE plpgsql $$ +BEGIN + EXECUTE 'COMMIT'; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_dynexecute":{"lineno":3,"query":{"PLpgSQL_expr":{"query":"'COMMIT'","parseMode":2}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 099 +-- snapshot handling test +TRUNCATE test2 +-- +[] +== 100 +CREATE PROCEDURE transaction_test9() +LANGUAGE SQL +AS $$ +INSERT INTO test2 VALUES (42); +$$ +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 101 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + CALL transaction_test9(); +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_rollback":{"lineno":3}},{"PLpgSQL_stmt_call":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"CALL transaction_test9()","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 102 +SELECT * FROM test2 +-- +[] +== 103 +-- another snapshot handling case: argument expressions of a CALL need +-- to be evaluated with an up-to-date snapshot +CREATE FUNCTION report_count() RETURNS int +STABLE LANGUAGE sql +AS $$ SELECT COUNT(*) FROM test2 $$ +-- +[ +{"PLpgSQL_function":{"datums":[]}} +] +== 104 +CREATE PROCEDURE transaction_test9b(cnt int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'count = %', cnt; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"cnt","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"count = %","params":[{"PLpgSQL_expr":{"query":"cnt","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 105 +DO $$ +BEGIN + CALL transaction_test9b(report_count()); + INSERT INTO test2 VALUES(43); + CALL transaction_test9b(report_count()); +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_call":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"CALL transaction_test9b(report_count())","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test2 VALUES(43)","parseMode":0}}}},{"PLpgSQL_stmt_call":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"CALL transaction_test9b(report_count())","parseMode":0}},"is_call":true}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 106 +-- Test transaction in procedure with output parameters. This uses a +-- different portal strategy and different code paths in pquery.c. +CREATE PROCEDURE transaction_test10a(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x + 1; + COMMIT; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"x := x + 1","parseMode":3}}}},{"PLpgSQL_stmt_commit":{"lineno":4}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 107 +CALL transaction_test10a(10) +-- +[] +== 108 +CREATE PROCEDURE transaction_test10b(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x - 1; + ROLLBACK; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"x","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"x := x - 1","parseMode":3}}}},{"PLpgSQL_stmt_rollback":{"lineno":4}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 109 +CALL transaction_test10b(10) +-- +[] +== 110 +-- transaction timestamp vs. statement timestamp +CREATE PROCEDURE transaction_test11() +LANGUAGE plpgsql +AS $$ +DECLARE + s1 timestamp with time zone; + s2 timestamp with time zone; + s3 timestamp with time zone; + t1 timestamp with time zone; + t2 timestamp with time zone; + t3 timestamp with time zone; +BEGIN + s1 := statement_timestamp(); + t1 := transaction_timestamp(); + ASSERT s1 = t1; + PERFORM pg_sleep(0.001); + COMMIT; + s2 := statement_timestamp(); + t2 := transaction_timestamp(); + ASSERT s2 = s1; + ASSERT t2 > t1; + PERFORM pg_sleep(0.001); + ROLLBACK; + s3 := statement_timestamp(); + t3 := transaction_timestamp(); + ASSERT s3 = s1; + ASSERT t3 > t2; +END; +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"s1","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"timestamp with time zone"}}}},{"PLpgSQL_var":{"refname":"s2","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"timestamp with time zone"}}}},{"PLpgSQL_var":{"refname":"s3","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"timestamp with time zone"}}}},{"PLpgSQL_var":{"refname":"t1","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"timestamp with time zone"}}}},{"PLpgSQL_var":{"refname":"t2","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"timestamp with time zone"}}}},{"PLpgSQL_var":{"refname":"t3","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"timestamp with time zone"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":9,"body":[{"PLpgSQL_stmt_assign":{"lineno":10,"varno":1,"expr":{"PLpgSQL_expr":{"query":"s1 := statement_timestamp()","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":11,"varno":4,"expr":{"PLpgSQL_expr":{"query":"t1 := transaction_timestamp()","parseMode":3}}}},{"PLpgSQL_stmt_assert":{"lineno":12,"cond":{"PLpgSQL_expr":{"query":"s1 = t1","parseMode":2}}}},{"PLpgSQL_stmt_perform":{"lineno":13,"expr":{"PLpgSQL_expr":{"query":"SELECT pg_sleep(0.001)","parseMode":0}}}},{"PLpgSQL_stmt_commit":{"lineno":14}},{"PLpgSQL_stmt_assign":{"lineno":15,"varno":2,"expr":{"PLpgSQL_expr":{"query":"s2 := statement_timestamp()","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":16,"varno":5,"expr":{"PLpgSQL_expr":{"query":"t2 := transaction_timestamp()","parseMode":3}}}},{"PLpgSQL_stmt_assert":{"lineno":17,"cond":{"PLpgSQL_expr":{"query":"s2 = s1","parseMode":2}}}},{"PLpgSQL_stmt_assert":{"lineno":18,"cond":{"PLpgSQL_expr":{"query":"t2 \u003e t1","parseMode":2}}}},{"PLpgSQL_stmt_perform":{"lineno":19,"expr":{"PLpgSQL_expr":{"query":"SELECT pg_sleep(0.001)","parseMode":0}}}},{"PLpgSQL_stmt_rollback":{"lineno":20}},{"PLpgSQL_stmt_assign":{"lineno":21,"varno":3,"expr":{"PLpgSQL_expr":{"query":"s3 := statement_timestamp()","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":22,"varno":6,"expr":{"PLpgSQL_expr":{"query":"t3 := transaction_timestamp()","parseMode":3}}}},{"PLpgSQL_stmt_assert":{"lineno":23,"cond":{"PLpgSQL_expr":{"query":"s3 = s1","parseMode":2}}}},{"PLpgSQL_stmt_assert":{"lineno":24,"cond":{"PLpgSQL_expr":{"query":"t3 \u003e t2","parseMode":2}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 111 +CALL transaction_test11() +-- +[] +== 112 +-- transaction chain + +TRUNCATE test1 +-- +[] +== 113 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + FOR i IN 0..3 LOOP + RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT AND CHAIN; + ELSE + ROLLBACK AND CHAIN; + END IF; + END LOOP; +END +$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_rollback":{"lineno":3}},{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"SET TRANSACTION ISOLATION LEVEL REPEATABLE READ","parseMode":0}}}},{"PLpgSQL_stmt_fori":{"lineno":5,"var":{"PLpgSQL_var":{"refname":"i","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"0","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":17,"message":"transaction_isolation = %","params":[{"PLpgSQL_expr":{"query":"current_setting('transaction_isolation')","parseMode":2}}]}},{"PLpgSQL_stmt_execsql":{"lineno":7,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO test1 (a) VALUES (i)","parseMode":0}}}},{"PLpgSQL_stmt_if":{"lineno":8,"cond":{"PLpgSQL_expr":{"query":"i % 2 = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_commit":{"lineno":9,"chain":true}}],"else_body":[{"PLpgSQL_stmt_rollback":{"lineno":11,"chain":true}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 114 +SELECT * FROM test1 +-- +[] +== 115 +DROP TABLE test1 +-- +[] +== 116 +DROP TABLE test2 +-- +[] +== 117 +DROP TABLE test3 +-- +[] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trap.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trap.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trap.test new file mode 100644 index 0000000..cd3c220 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trap.test @@ -0,0 +1,305 @@ +== 001 +|-- +-- Test error trapping +|-- + +create function trap_zero_divide(int) returns int as $$ +declare x int; + sx smallint; +begin + begin -- start a subtransaction + raise notice 'should see this'; + x := 100 / $1; + raise notice 'should see this only if % <> 0', $1; + sx := $1; + raise notice 'should see this only if % fits in smallint', $1; + if $1 < 0 then + raise exception '% is less than zero', $1; + end if; + exception + when division_by_zero then + raise notice 'caught division_by_zero'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE then + raise notice 'caught numeric_value_out_of_range'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"sx","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"smallint"}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":14,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":14,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"should see this"}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"x := 100 / $1","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":8,"elog_level":18,"message":"should see this only if % \u003c\u003e 0","params":[{"PLpgSQL_expr":{"query":"$1","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":9,"varno":3,"expr":{"PLpgSQL_expr":{"query":"sx := $1","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":18,"message":"should see this only if % fits in smallint","params":[{"PLpgSQL_expr":{"query":"$1","parseMode":2}}]}},{"PLpgSQL_stmt_if":{"lineno":11,"cond":{"PLpgSQL_expr":{"query":"$1 \u003c 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_raise":{"lineno":12,"elog_level":21,"message":"% is less than zero","params":[{"PLpgSQL_expr":{"query":"$1","parseMode":2}}]}}]}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"division_by_zero"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":16,"elog_level":18,"message":"caught division_by_zero"}},{"PLpgSQL_stmt_assign":{"lineno":17,"varno":2,"expr":{"PLpgSQL_expr":{"query":"x := -1","parseMode":3}}}}]}},{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"numeric_value_out_of_range"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":19,"elog_level":18,"message":"caught numeric_value_out_of_range"}},{"PLpgSQL_stmt_assign":{"lineno":20,"varno":2,"expr":{"PLpgSQL_expr":{"query":"x := -2","parseMode":3}}}}]}}]}}}},{"PLpgSQL_stmt_return":{"lineno":22,"expr":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}]}}}} +] +== 002 +select trap_zero_divide(50) +-- +[] +== 003 +select trap_zero_divide(0) +-- +[] +== 004 +select trap_zero_divide(100000) +-- +[] +== 005 +select trap_zero_divide(-100) +-- +[] +== 006 +create table match_source as + select x as id, x*10 as data, x/10 as ten from generate_series(1,100) x +-- +[] +== 007 +create function trap_matching_test(int) returns int as $$ +declare x int; + sx smallint; + y int; +begin + begin -- start a subtransaction + x := 100 / $1; + sx := $1; + select into y data from match_source where id = + (select id from match_source b where ten = $1); + exception + when data_exception then -- category match + raise notice 'caught data_exception'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then + raise notice 'caught numeric_value_out_of_range or cardinality_violation'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"sx","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"smallint"}}}},{"PLpgSQL_var":{"refname":"y","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":9,"fields":[{"name":"y","varno":4}]}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":11,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":11,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_block":{"lineno":6,"body":[{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"x := 100 / $1","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":8,"varno":3,"expr":{"PLpgSQL_expr":{"query":"sx := $1","parseMode":3}}}},{"PLpgSQL_stmt_execsql":{"lineno":9,"sqlstmt":{"PLpgSQL_expr":{"query":"select data from match_source where id =\n\t\t\t(select id from match_source b where ten = $1)","parseMode":0}},"into":true,"target":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":9,"fields":[{"name":"y","varno":4}]}}}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"data_exception"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":13,"elog_level":18,"message":"caught data_exception"}},{"PLpgSQL_stmt_assign":{"lineno":14,"varno":2,"expr":{"PLpgSQL_expr":{"query":"x := -1","parseMode":3}}}}]}},{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"numeric_value_out_of_range"}},{"PLpgSQL_condition":{"condname":"cardinality_violation"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":16,"elog_level":18,"message":"caught numeric_value_out_of_range or cardinality_violation"}},{"PLpgSQL_stmt_assign":{"lineno":17,"varno":2,"expr":{"PLpgSQL_expr":{"query":"x := -2","parseMode":3}}}}]}}]}}}},{"PLpgSQL_stmt_return":{"lineno":19,"expr":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}]}}}} +] +== 008 +select trap_matching_test(50) +-- +[] +== 009 +select trap_matching_test(0) +-- +[] +== 010 +select trap_matching_test(100000) +-- +[] +== 011 +select trap_matching_test(1) +-- +[] +== 012 +create temp table foo (f1 int) +-- +[] +== 013 +create function subxact_rollback_semantics() returns int as $$ +declare x int; +begin + x := 1; + insert into foo values(x); + begin + x := x + 1; + insert into foo values(x); + raise exception 'inner'; + exception + when others then + x := x * 10; + end; + insert into foo values(x); + return x; +end$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":10,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":10,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := 1","parseMode":3}}}},{"PLpgSQL_stmt_execsql":{"lineno":5,"sqlstmt":{"PLpgSQL_expr":{"query":"insert into foo values(x)","parseMode":0}}}},{"PLpgSQL_stmt_block":{"lineno":6,"body":[{"PLpgSQL_stmt_assign":{"lineno":7,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := x + 1","parseMode":3}}}},{"PLpgSQL_stmt_execsql":{"lineno":8,"sqlstmt":{"PLpgSQL_expr":{"query":"insert into foo values(x)","parseMode":0}}}},{"PLpgSQL_stmt_raise":{"lineno":9,"elog_level":21,"message":"inner"}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"others"}}],"action":[{"PLpgSQL_stmt_assign":{"lineno":12,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := x * 10","parseMode":3}}}}]}}]}}}},{"PLpgSQL_stmt_execsql":{"lineno":14,"sqlstmt":{"PLpgSQL_expr":{"query":"insert into foo values(x)","parseMode":0}}}},{"PLpgSQL_stmt_return":{"lineno":15,"expr":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}]}}}} +] +== 014 +select subxact_rollback_semantics() +-- +[] +== 015 +select * from foo +-- +[] +== 016 +drop table foo +-- +[] +== 017 +create function trap_timeout() returns void as $$ +begin + declare x int; + begin + -- we assume this will take longer than 1 second: + select count(*) into x from generate_series(1, 1_000_000_000_000); + exception + when others then + raise notice 'caught others?'; + when query_canceled then + raise notice 'nyeah nyeah, can''t stop me'; + end; + -- Abort transaction to abandon the statement_timeout setting. Otherwise, + -- the next top-level statement would be vulnerable to the timeout. + raise exception 'end of function'; +end$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":6,"fields":[{"name":"x","varno":1}]}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"select count(*) from generate_series(1, 1_000_000_000_000)","parseMode":0}},"into":true,"target":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":6,"fields":[{"name":"x","varno":1}]}}}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"others"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":9,"elog_level":18,"message":"caught others?"}}]}},{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"query_canceled"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":11,"elog_level":18,"message":"nyeah nyeah, can't stop me"}}]}}]}}}},{"PLpgSQL_stmt_raise":{"lineno":15,"elog_level":21,"message":"end of function"}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 018 +begin +-- +[] +== 019 +set statement_timeout to 1000 +-- +[] +== 020 +select trap_timeout() +-- +[] +== 021 +rollback +-- +[] +== 022 +-- Test for pass-by-ref values being stored in proper context +create function test_variable_storage() returns text as $$ +declare x text; +begin + x := '1234'; + begin + x := x || '5678'; + -- force error inside subtransaction SPI context + perform trap_zero_divide(-100); + exception + when others then + x := x || '9012'; + end; + return x; +end$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":9,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":9,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := '1234'","parseMode":3}}}},{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := x || '5678'","parseMode":3}}}},{"PLpgSQL_stmt_perform":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"SELECT trap_zero_divide(-100)","parseMode":0}}}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"others"}}],"action":[{"PLpgSQL_stmt_assign":{"lineno":11,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := x || '9012'","parseMode":3}}}}]}}]}}}},{"PLpgSQL_stmt_return":{"lineno":13,"expr":{"PLpgSQL_expr":{"query":"x","parseMode":2}}}}]}}}} +] +== 023 +select test_variable_storage() +-- +[] +== 024 +|-- +-- test foreign key error trapping +|-- + +create temp table root(f1 int primary key) +-- +[] +== 025 +create temp table leaf(f1 int references root deferrable) +-- +[] +== 026 +insert into root values(1) +-- +[] +== 027 +insert into leaf values(1) +-- +[] +== 028 +insert into leaf values(2) +-- +[] +== 029 +-- fails + +create function trap_foreign_key(int) returns int as $$ +begin + begin -- start a subtransaction + insert into leaf values($1); + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"insert into leaf values($1)","parseMode":0}}}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"foreign_key_violation"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"caught foreign_key_violation"}},{"PLpgSQL_stmt_return":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}]}}]}}}},{"PLpgSQL_stmt_return":{"lineno":10,"expr":{"PLpgSQL_expr":{"query":"1","parseMode":2}}}}]}}}} +] +== 030 +create function trap_foreign_key_2() returns int as $$ +begin + begin -- start a subtransaction + set constraints all immediate; + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_execsql":{"lineno":4,"sqlstmt":{"PLpgSQL_expr":{"query":"set constraints all immediate","parseMode":0}}}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"foreign_key_violation"}}],"action":[{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"caught foreign_key_violation"}},{"PLpgSQL_stmt_return":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}]}}]}}}},{"PLpgSQL_stmt_return":{"lineno":10,"expr":{"PLpgSQL_expr":{"query":"1","parseMode":2}}}}]}}}} +] +== 031 +select trap_foreign_key(1) +-- +[] +== 032 +select trap_foreign_key(2) +-- +[] +== 033 +-- detects FK violation + +begin +-- +[] +== 034 +set constraints all deferred +-- +[] +== 035 +select trap_foreign_key(2) +-- +[] +== 036 +-- should not detect FK violation + savepoint x +-- +[] +== 037 +set constraints all immediate +-- +[] +== 038 +-- fails + rollback to x +-- +[] +== 039 +select trap_foreign_key_2() +-- +[] +== 040 +-- detects FK violation +commit +-- +[] +== 041 +-- still fails + +drop function trap_foreign_key(int) +-- +[] +== 042 +drop function trap_foreign_key_2() +-- +[] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trigger.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trigger.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trigger.test new file mode 100644 index 0000000..76890f9 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_trigger.test @@ -0,0 +1,39 @@ +== 001 +-- Simple test to verify accessibility of the OLD and NEW trigger variables + +create table testtr (a int, b text) +-- +[] +== 002 +create function testtr_trigger() returns trigger language plpgsql as +$$begin + raise notice 'tg_op = %', tg_op; + raise notice 'old(%) = %', old.a, row(old.*); + raise notice 'new(%) = %', new.a, row(new.*); + if (tg_op = 'DELETE') then + return old; + else + return new; + end if; +end$$ +-- +[ +{"PLpgSQL_function":{"new_varno":1,"old_varno":2,"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"new","dno":1}},{"PLpgSQL_rec":{"refname":"old","dno":2}},{"PLpgSQL_recfield":{"fieldname":"a","recparentno":2}},{"PLpgSQL_recfield":{"fieldname":"a","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_raise":{"lineno":2,"elog_level":18,"message":"tg_op = %","params":[{"PLpgSQL_expr":{"query":"tg_op","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":3,"elog_level":18,"message":"old(%) = %","params":[{"PLpgSQL_expr":{"query":"old.a","parseMode":2}},{"PLpgSQL_expr":{"query":"row(old.*)","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"new(%) = %","params":[{"PLpgSQL_expr":{"query":"new.a","parseMode":2}},{"PLpgSQL_expr":{"query":"row(new.*)","parseMode":2}}]}},{"PLpgSQL_stmt_if":{"lineno":5,"cond":{"PLpgSQL_expr":{"query":"(tg_op = 'DELETE')","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"old","parseMode":2}}}}],"else_body":[{"PLpgSQL_stmt_return":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"new","parseMode":2}}}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 003 +create trigger testtr_trigger before insert or delete or update on testtr + for each row execute function testtr_trigger() +-- +[] +== 004 +insert into testtr values (1, 'one'), (2, 'two') +-- +[] +== 005 +update testtr set a = a + 1 +-- +[] +== 006 +delete from testtr +-- +[] diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_varprops.metadata.json b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_varprops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_varprops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_regress/plpgsql_varprops.test b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_varprops.test new file mode 100644 index 0000000..0c2059f --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_regress/plpgsql_varprops.test @@ -0,0 +1,400 @@ +== 001 +|-- +-- Tests for PL/pgSQL variable properties: CONSTANT, NOT NULL, initializers +|-- + +create type var_record as (f1 int4, f2 int4) +-- +[] +== 002 +create domain int_nn as int not null +-- +[] +== 003 +create domain var_record_nn as var_record not null +-- +[] +== 004 +create domain var_record_colnn as var_record check((value).f2 is not null) +-- +[] +== 005 +-- CONSTANT + +do $$ +declare x constant int := 42; +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"isconst":true,"default_val":{"PLpgSQL_expr":{"query":"42","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 006 +do $$ +declare x constant int; +begin + x := 42; -- fail +end$$ +-- +ERROR: variable "x" is declared CONSTANT +FILENAME: pl_gram.y +FUNCNAME: check_assignable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 2" +== 007 +do $$ +declare x constant int; y int; +begin + for x, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +ERROR: variable "x" is declared CONSTANT +FILENAME: pl_gram.y +FUNCNAME: check_assignable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 4" +== 008 +do $$ +declare x constant int[]; +begin + x[1] := 42; -- fail +end$$ +-- +ERROR: variable "x" is declared CONSTANT +FILENAME: pl_gram.y +FUNCNAME: check_assignable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 2" +== 009 +do $$ +declare x constant int[]; y int; +begin + for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax) + end loop; +end$$ +-- +ERROR: syntax error at or near "[" +FILENAME: src_pl_plpgsql_src_pl_scanner.c +FUNCNAME: plpgsql_yyerror +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 4" +== 010 +do $$ +declare x constant var_record; +begin + x.f1 := 42; -- fail +end$$ +-- +ERROR: "x.f1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 2" +== 011 +do $$ +declare x constant var_record; y int; +begin + for x.f1, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +ERROR: "x.f1" is not a known variable +FILENAME: pl_gram.y +FUNCNAME: cword_is_not_variable +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 2" +== 012 +-- initializer expressions + +do $$ +declare x int := sin(0); +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"sin(0)","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 013 +do $$ +declare x int := 1/0; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"1/0","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 014 +do $$ +declare x bigint[] := array[1,3,5]; +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"bigint[] "}},"default_val":{"PLpgSQL_expr":{"query":"array[1,3,5]","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 015 +do $$ +declare x record := row(1,2,3); +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"x","dno":1,"lineno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 016 +do $$ +declare x var_record := row(1,2); +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record "}},"default_val":{"PLpgSQL_expr":{"query":"row(1,2)","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 017 +-- NOT NULL + +do $$ +declare x int not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +ERROR: variable "x" must have a default value, since it's declared NOT NULL +FILENAME: pl_gram.y +FUNCNAME: plpgsql_yyparse +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 2" +== 018 +do $$ +declare x int not null := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"notnull":true,"default_val":{"PLpgSQL_expr":{"query":"42","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := null","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 019 +do $$ +declare x int not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int "}},"notnull":true,"default_val":{"PLpgSQL_expr":{"query":"null","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 020 +do $$ +declare x record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +ERROR: variable "x" must have a default value, since it's declared NOT NULL +FILENAME: pl_gram.y +FUNCNAME: plpgsql_yyparse +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 2" +== 021 +do $$ +declare x record not null := row(42); +begin + raise notice 'x = %', x; + x := row(null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"x","dno":1,"lineno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := row(null)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := null","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 022 +do $$ +declare x record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"x","dno":1,"lineno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 023 +do $$ +declare x var_record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +ERROR: variable "x" must have a default value, since it's declared NOT NULL +FILENAME: pl_gram.y +FUNCNAME: plpgsql_yyparse +CONTEXT: "compilation of PL/pgSQL function \"inline_code_block\" near line 2" +== 024 +do $$ +declare x var_record not null := row(41,42); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record "}},"notnull":true,"default_val":{"PLpgSQL_expr":{"query":"row(41,42)","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := row(null,null)","parseMode":3}}}},{"PLpgSQL_stmt_raise":{"lineno":6,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := null","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 025 +do $$ +declare x var_record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record "}},"notnull":true,"default_val":{"PLpgSQL_expr":{"query":"null","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 026 +-- Check that variables are reinitialized on block re-entry. + +do $$ +begin + for i in 1..3 loop + declare + x int; + y int := i; + r record; + c var_record; + begin + if i = 1 then + x := 42; + r := row(i, i+1); + c := row(i, i+1); + end if; + raise notice 'x = %', x; + raise notice 'y = %', y; + raise notice 'r = %', r; + raise notice 'c = %', c; + end; + end loop; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"int"}}}},{"PLpgSQL_var":{"refname":"y","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"int "}},"default_val":{"PLpgSQL_expr":{"query":"i","parseMode":2}}}},{"PLpgSQL_rec":{"refname":"r","dno":4,"lineno":7}},{"PLpgSQL_var":{"refname":"c","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"var_record"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fori":{"lineno":3,"var":{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"3","parseMode":2}},"body":[{"PLpgSQL_stmt_block":{"lineno":9,"body":[{"PLpgSQL_stmt_if":{"lineno":10,"cond":{"PLpgSQL_expr":{"query":"i = 1","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":11,"varno":2,"expr":{"PLpgSQL_expr":{"query":"x := 42","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":12,"varno":4,"expr":{"PLpgSQL_expr":{"query":"r := row(i, i+1)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":13,"varno":5,"expr":{"PLpgSQL_expr":{"query":"c := row(i, i+1)","parseMode":3}}}}]}},{"PLpgSQL_stmt_raise":{"lineno":15,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":16,"elog_level":18,"message":"y = %","params":[{"PLpgSQL_expr":{"query":"y","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":17,"elog_level":18,"message":"r = %","params":[{"PLpgSQL_expr":{"query":"r","parseMode":2}}]}},{"PLpgSQL_stmt_raise":{"lineno":18,"elog_level":18,"message":"c = %","params":[{"PLpgSQL_expr":{"query":"c","parseMode":2}}]}}]}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 027 +-- Check enforcement of domain constraints during initialization + +do $$ +declare x int_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int_nn"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 028 +do $$ +declare x int_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int_nn "}},"default_val":{"PLpgSQL_expr":{"query":"null","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 029 +do $$ +declare x int_nn := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int_nn "}},"default_val":{"PLpgSQL_expr":{"query":"42","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := null","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 030 +do $$ +declare x var_record_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record_nn"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 031 +do $$ +declare x var_record_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record_nn "}},"default_val":{"PLpgSQL_expr":{"query":"null","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 032 +do $$ +declare x var_record_nn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + x := null; -- fail +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record_nn "}},"default_val":{"PLpgSQL_expr":{"query":"row(1,2)","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := row(null,null)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := null","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 033 +do $$ +declare x var_record_colnn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record_colnn"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 034 +do $$ +declare x var_record_colnn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record_colnn "}},"default_val":{"PLpgSQL_expr":{"query":"null","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 035 +do $$ +declare x var_record_colnn := row(1,null); -- fail +begin + raise notice 'x = %', x; +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record_colnn "}},"default_val":{"PLpgSQL_expr":{"query":"row(1,null)","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 036 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record_colnn "}},"default_val":{"PLpgSQL_expr":{"query":"row(1,2)","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := null","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 037 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- fail +end$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"x","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"var_record_colnn "}},"default_val":{"PLpgSQL_expr":{"query":"row(1,2)","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_raise":{"lineno":4,"elog_level":18,"message":"x = %","params":[{"PLpgSQL_expr":{"query":"x","parseMode":2}}]}},{"PLpgSQL_stmt_assign":{"lineno":5,"varno":1,"expr":{"PLpgSQL_expr":{"query":"x := row(null,null)","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] diff --git a/parser/testdata/plpgsql/plpgsql_samples.metadata.json b/parser/testdata/plpgsql/plpgsql_samples.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_samples.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/plpgsql/plpgsql_samples.test b/parser/testdata/plpgsql/plpgsql_samples.test new file mode 100644 index 0000000..188d145 --- /dev/null +++ b/parser/testdata/plpgsql/plpgsql_samples.test @@ -0,0 +1,728 @@ +== 001 +-- Examples from https://www.postgresql.org/docs/9.6/static/plpgsql-control-structures.html + +CREATE OR REPLACE FUNCTION get_all_foo() RETURNS SETOF foo AS +$BODY$ +DECLARE + r foo%rowtype; +BEGIN + FOR r IN + SELECT * FROM foo WHERE fooid > 0 + LOOP + -- can do some processing here + RETURN NEXT r; -- return current row of SELECT + END LOOP; + RETURN; +END +$BODY$ +LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"r","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"foo%rowtype"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":5,"fields":[{"name":"r","varno":1}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_fors":{"lineno":5,"var":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":5,"fields":[{"name":"r","varno":1}]}},"body":[{"PLpgSQL_stmt_return_next":{"lineno":9}}],"query":{"PLpgSQL_expr":{"query":"SELECT * FROM foo WHERE fooid \u003e 0","parseMode":0}}}},{"PLpgSQL_stmt_return":{"lineno":11}}]}}}} +] +== 002 +CREATE FUNCTION get_available_flightid(date) RETURNS SETOF integer AS +$BODY$ +BEGIN + RETURN QUERY SELECT flightid + FROM flight + WHERE flightdate >= $1 + AND flightdate < ($1 + 1); + + -- Since execution is not finished, we can check whether rows were returned + -- and raise exception if not. + IF NOT FOUND THEN + RAISE EXCEPTION 'No flight at %.', $1; + END IF; + + RETURN; + END +$BODY$ +LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"date"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_return_query":{"lineno":3,"query":{"PLpgSQL_expr":{"query":"SELECT flightid\n FROM flight\n WHERE flightdate \u003e= $1\n AND flightdate \u003c ($1 + 1)","parseMode":0}}}},{"PLpgSQL_stmt_if":{"lineno":10,"cond":{"PLpgSQL_expr":{"query":"NOT FOUND","parseMode":2}},"then_body":[{"PLpgSQL_stmt_raise":{"lineno":11,"elog_level":21,"message":"No flight at %.","params":[{"PLpgSQL_expr":{"query":"$1","parseMode":2}}]}}]}},{"PLpgSQL_stmt_return":{"lineno":14}}]}}}} +] +== 003 +-- Examples from https://www.postgresql.org/docs/9.6/static/plpgsql-porting.html + +CREATE OR REPLACE FUNCTION cs_fmt_browser_version(v_name varchar, + v_version varchar) +RETURNS varchar AS $$ +BEGIN + IF v_version IS NULL THEN + RETURN v_name; + END IF; + RETURN v_name || '/' || v_version; +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"v_name","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"v_version","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_if":{"lineno":3,"cond":{"PLpgSQL_expr":{"query":"v_version IS NULL","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"v_name","parseMode":2}}}}]}},{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"v_name || '/' || v_version","parseMode":2}}}}]}}}} +] +== 004 +-- CREATE OR REPLACE FUNCTION cs_update_referrer_type_proc() RETURNS void AS $func$ +-- DECLARE +-- referrer_keys CURSOR IS +-- SELECT * FROM cs_referrer_keys +-- ORDER BY try_order; +-- func_body text; +-- func_cmd text; +-- BEGIN +-- func_body := 'BEGIN'; +-- -- Notice how we scan through the results of a query in a FOR loop +-- -- using the FOR construct. +-- FOR referrer_key IN SELECT * FROM cs_referrer_keys ORDER BY try_order LOOP +-- func_body := func_body || +-- ' IF v_' || referrer_key.kind +-- || ' LIKE ' || quote_literal(referrer_key.key_string) +-- || ' THEN RETURN ' || quote_literal(referrer_key.referrer_type) +-- || '; END IF;' ; +-- END LOOP; +-- func_body := func_body || ' RETURN NULL; END;'; +-- func_cmd := +-- 'CREATE OR REPLACE FUNCTION cs_find_referrer_type(v_host varchar, +-- v_domain varchar, +-- v_url varchar) +-- RETURNS varchar AS ' +-- || quote_literal(func_body) +-- || ' LANGUAGE plpgsql;' ; +-- EXECUTE func_cmd; +-- END;$func$; + +CREATE OR REPLACE FUNCTION cs_parse_url( + v_url IN VARCHAR, + v_host OUT VARCHAR, -- This will be passed back + v_path OUT VARCHAR, -- This one too + v_query OUT VARCHAR) -- And this one +AS $$ +DECLARE + a_pos1 INTEGER; + a_pos2 INTEGER; +BEGIN + v_host := NULL; + v_path := NULL; + v_query := NULL; + a_pos1 := instr(v_url, '//'); + + IF a_pos1 = 0 THEN + RETURN; + END IF; + a_pos2 := instr(v_url, '/', a_pos1 + 2); + IF a_pos2 = 0 THEN + v_host := substr(v_url, a_pos1 + 2); + v_path := '/'; + RETURN; + END IF; + + v_host := substr(v_url, a_pos1 + 2, a_pos2 - a_pos1 - 2); + a_pos1 := instr(v_url, '?', a_pos2 + 1); + + IF a_pos1 = 0 THEN + v_path := substr(v_url, a_pos2); + RETURN; + END IF; + + v_path := substr(v_url, a_pos2, a_pos1 - a_pos2); + v_query := substr(v_url, a_pos1 + 1); +END; +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"v_url","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"v_host","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"v_path","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"v_query","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a_pos1","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"INTEGER"}}}},{"PLpgSQL_var":{"refname":"a_pos2","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"INTEGER"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_assign":{"lineno":6,"varno":1,"expr":{"PLpgSQL_expr":{"query":"v_host := NULL","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"v_path := NULL","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":8,"varno":3,"expr":{"PLpgSQL_expr":{"query":"v_query := NULL","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":9,"varno":5,"expr":{"PLpgSQL_expr":{"query":"a_pos1 := instr(v_url, '//')","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":11,"cond":{"PLpgSQL_expr":{"query":"a_pos1 = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":12}}]}},{"PLpgSQL_stmt_assign":{"lineno":14,"varno":6,"expr":{"PLpgSQL_expr":{"query":"a_pos2 := instr(v_url, '/', a_pos1 + 2)","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":15,"cond":{"PLpgSQL_expr":{"query":"a_pos2 = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":16,"varno":1,"expr":{"PLpgSQL_expr":{"query":"v_host := substr(v_url, a_pos1 + 2)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":17,"varno":2,"expr":{"PLpgSQL_expr":{"query":"v_path := '/'","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":18}}]}},{"PLpgSQL_stmt_assign":{"lineno":21,"varno":1,"expr":{"PLpgSQL_expr":{"query":"v_host := substr(v_url, a_pos1 + 2, a_pos2 - a_pos1 - 2)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":22,"varno":5,"expr":{"PLpgSQL_expr":{"query":"a_pos1 := instr(v_url, '?', a_pos2 + 1)","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":24,"cond":{"PLpgSQL_expr":{"query":"a_pos1 = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":25,"varno":2,"expr":{"PLpgSQL_expr":{"query":"v_path := substr(v_url, a_pos2)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":26}}]}},{"PLpgSQL_stmt_assign":{"lineno":29,"varno":2,"expr":{"PLpgSQL_expr":{"query":"v_path := substr(v_url, a_pos2, a_pos1 - a_pos2)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":30,"varno":3,"expr":{"PLpgSQL_expr":{"query":"v_query := substr(v_url, a_pos1 + 1)","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 005 +CREATE OR REPLACE FUNCTION cs_create_job(v_job_id integer) RETURNS void AS $$ +DECLARE + a_running_job_count integer; +BEGIN + LOCK TABLE cs_jobs IN EXCLUSIVE MODE; + + SELECT count(*) INTO a_running_job_count FROM cs_jobs WHERE end_stamp IS NULL; + + IF a_running_job_count > 0 THEN + RAISE EXCEPTION 'Unable to create a new job: a job is currently running'; + END IF; + + DELETE FROM cs_active_job; + INSERT INTO cs_active_job(job_id) VALUES (v_job_id); + + BEGIN + INSERT INTO cs_jobs (job_id, start_stamp) VALUES (v_job_id, now()); + EXCEPTION + WHEN unique_violation THEN + -- don't worry if it already exists + END; +END; +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"v_job_id","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"a_running_job_count","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":7,"fields":[{"name":"a_running_job_count","varno":2}]}},{"PLpgSQL_var":{"refname":"sqlstate","lineno":18,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}},{"PLpgSQL_var":{"refname":"sqlerrm","lineno":18,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.text"}},"isconst":true}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_execsql":{"lineno":5,"sqlstmt":{"PLpgSQL_expr":{"query":"LOCK TABLE cs_jobs IN EXCLUSIVE MODE","parseMode":0}}}},{"PLpgSQL_stmt_execsql":{"lineno":7,"sqlstmt":{"PLpgSQL_expr":{"query":"SELECT count(*) FROM cs_jobs WHERE end_stamp IS NULL","parseMode":0}},"into":true,"target":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":7,"fields":[{"name":"a_running_job_count","varno":2}]}}}},{"PLpgSQL_stmt_if":{"lineno":9,"cond":{"PLpgSQL_expr":{"query":"a_running_job_count \u003e 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_raise":{"lineno":10,"elog_level":21,"message":"Unable to create a new job: a job is currently running"}}]}},{"PLpgSQL_stmt_execsql":{"lineno":13,"sqlstmt":{"PLpgSQL_expr":{"query":"DELETE FROM cs_active_job","parseMode":0}}}},{"PLpgSQL_stmt_execsql":{"lineno":14,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO cs_active_job(job_id) VALUES (v_job_id)","parseMode":0}}}},{"PLpgSQL_stmt_block":{"lineno":16,"body":[{"PLpgSQL_stmt_execsql":{"lineno":17,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO cs_jobs (job_id, start_stamp) VALUES (v_job_id, now())","parseMode":0}}}}],"exceptions":{"PLpgSQL_exception_block":{"exc_list":[{"PLpgSQL_exception":{"conditions":[{"PLpgSQL_condition":{"condname":"unique_violation"}}]}}]}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 006 +CREATE FUNCTION instr(varchar, varchar) RETURNS integer AS $$ +DECLARE + pos integer; +BEGIN + pos:= instr($1, $2, 1); + RETURN pos; +END; +$$ LANGUAGE plpgsql STRICT IMMUTABLE +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"$2","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"pos","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_assign":{"lineno":5,"varno":3,"expr":{"PLpgSQL_expr":{"query":"pos:= instr($1, $2, 1)","parseMode":3}}}},{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"pos","parseMode":2}}}}]}}}} +] +== 007 +CREATE FUNCTION instr(string varchar, string_to_search varchar, beg_index integer) +RETURNS integer AS $$ +DECLARE + pos integer NOT NULL DEFAULT 0; + temp_str varchar; + beg integer; + length integer; + ss_length integer; +BEGIN + IF beg_index > 0 THEN + temp_str := substring(string FROM beg_index); + pos := position(string_to_search IN temp_str); + + IF pos = 0 THEN + RETURN 0; + ELSE + RETURN pos + beg_index - 1; + END IF; + ELSIF beg_index < 0 THEN + ss_length := char_length(string_to_search); + length := char_length(string); + beg := length + beg_index - ss_length + 2; + + WHILE beg > 0 LOOP + temp_str := substring(string FROM beg FOR ss_length); + pos := position(string_to_search IN temp_str); + + IF pos > 0 THEN + RETURN beg; + END IF; + + beg := beg - 1; + END LOOP; + + RETURN 0; + ELSE + RETURN 0; + END IF; +END; +$$ LANGUAGE plpgsql STRICT IMMUTABLE +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"string","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"string_to_search","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"beg_index","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"pos","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"integer "}},"notnull":true,"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}},{"PLpgSQL_var":{"refname":"temp_str","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"varchar"}}}},{"PLpgSQL_var":{"refname":"beg","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_var":{"refname":"length","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_var":{"refname":"ss_length","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":8,"body":[{"PLpgSQL_stmt_if":{"lineno":9,"cond":{"PLpgSQL_expr":{"query":"beg_index \u003e 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":10,"varno":5,"expr":{"PLpgSQL_expr":{"query":"temp_str := substring(string FROM beg_index)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":11,"varno":4,"expr":{"PLpgSQL_expr":{"query":"pos := position(string_to_search IN temp_str)","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":13,"cond":{"PLpgSQL_expr":{"query":"pos = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":14,"expr":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}],"else_body":[{"PLpgSQL_stmt_return":{"lineno":16,"expr":{"PLpgSQL_expr":{"query":"pos + beg_index - 1","parseMode":2}}}}]}}],"elsif_list":[{"PLpgSQL_if_elsif":{"lineno":18,"cond":{"PLpgSQL_expr":{"query":"beg_index \u003c 0","parseMode":2}},"stmts":[{"PLpgSQL_stmt_assign":{"lineno":19,"varno":8,"expr":{"PLpgSQL_expr":{"query":"ss_length := char_length(string_to_search)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":20,"varno":7,"expr":{"PLpgSQL_expr":{"query":"length := char_length(string)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":21,"varno":6,"expr":{"PLpgSQL_expr":{"query":"beg := length + beg_index - ss_length + 2","parseMode":3}}}},{"PLpgSQL_stmt_while":{"lineno":23,"cond":{"PLpgSQL_expr":{"query":"beg \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":24,"varno":5,"expr":{"PLpgSQL_expr":{"query":"temp_str := substring(string FROM beg FOR ss_length)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":25,"varno":4,"expr":{"PLpgSQL_expr":{"query":"pos := position(string_to_search IN temp_str)","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":27,"cond":{"PLpgSQL_expr":{"query":"pos \u003e 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":28,"expr":{"PLpgSQL_expr":{"query":"beg","parseMode":2}}}}]}},{"PLpgSQL_stmt_assign":{"lineno":31,"varno":6,"expr":{"PLpgSQL_expr":{"query":"beg := beg - 1","parseMode":3}}}}]}},{"PLpgSQL_stmt_return":{"lineno":34,"expr":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}]}}],"else_body":[{"PLpgSQL_stmt_return":{"lineno":36,"expr":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 008 +CREATE FUNCTION instr(string varchar, string_to_search varchar, + beg_index integer, occur_index integer) +RETURNS integer AS $$ +DECLARE + pos integer NOT NULL DEFAULT 0; + occur_number integer NOT NULL DEFAULT 0; + temp_str varchar; + beg integer; + i integer; + length integer; + ss_length integer; +BEGIN + IF beg_index > 0 THEN + beg := beg_index; + temp_str := substring(string FROM beg_index); + + FOR i IN 1..occur_index LOOP + pos := position(string_to_search IN temp_str); + + IF i = 1 THEN + beg := beg + pos - 1; + ELSE + beg := beg + pos; + END IF; + + temp_str := substring(string FROM beg + 1); + END LOOP; + + IF pos = 0 THEN + RETURN 0; + ELSE + RETURN beg; + END IF; + ELSIF beg_index < 0 THEN + ss_length := char_length(string_to_search); + length := char_length(string); + beg := length + beg_index - ss_length + 2; + + WHILE beg > 0 LOOP + temp_str := substring(string FROM beg FOR ss_length); + pos := position(string_to_search IN temp_str); + + IF pos > 0 THEN + occur_number := occur_number + 1; + + IF occur_number = occur_index THEN + RETURN beg; + END IF; + END IF; + + beg := beg - 1; + END LOOP; + + RETURN 0; + ELSE + RETURN 0; + END IF; +END; +$$ LANGUAGE plpgsql STRICT IMMUTABLE +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"string","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"string_to_search","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"beg_index","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"occur_index","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"pos","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"integer "}},"notnull":true,"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}},{"PLpgSQL_var":{"refname":"occur_number","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"integer "}},"notnull":true,"default_val":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}},{"PLpgSQL_var":{"refname":"temp_str","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"varchar"}}}},{"PLpgSQL_var":{"refname":"beg","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_var":{"refname":"i","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_var":{"refname":"length","lineno":8,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_var":{"refname":"ss_length","lineno":9,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_var":{"refname":"i","lineno":15,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":10,"body":[{"PLpgSQL_stmt_if":{"lineno":11,"cond":{"PLpgSQL_expr":{"query":"beg_index \u003e 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":12,"varno":8,"expr":{"PLpgSQL_expr":{"query":"beg := beg_index","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":13,"varno":7,"expr":{"PLpgSQL_expr":{"query":"temp_str := substring(string FROM beg_index)","parseMode":3}}}},{"PLpgSQL_stmt_fori":{"lineno":15,"var":{"PLpgSQL_var":{"refname":"i","lineno":15,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"occur_index","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":16,"varno":5,"expr":{"PLpgSQL_expr":{"query":"pos := position(string_to_search IN temp_str)","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":18,"cond":{"PLpgSQL_expr":{"query":"i = 1","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":19,"varno":8,"expr":{"PLpgSQL_expr":{"query":"beg := beg + pos - 1","parseMode":3}}}}],"else_body":[{"PLpgSQL_stmt_assign":{"lineno":21,"varno":8,"expr":{"PLpgSQL_expr":{"query":"beg := beg + pos","parseMode":3}}}}]}},{"PLpgSQL_stmt_assign":{"lineno":24,"varno":7,"expr":{"PLpgSQL_expr":{"query":"temp_str := substring(string FROM beg + 1)","parseMode":3}}}}]}},{"PLpgSQL_stmt_if":{"lineno":27,"cond":{"PLpgSQL_expr":{"query":"pos = 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":28,"expr":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}],"else_body":[{"PLpgSQL_stmt_return":{"lineno":30,"expr":{"PLpgSQL_expr":{"query":"beg","parseMode":2}}}}]}}],"elsif_list":[{"PLpgSQL_if_elsif":{"lineno":32,"cond":{"PLpgSQL_expr":{"query":"beg_index \u003c 0","parseMode":2}},"stmts":[{"PLpgSQL_stmt_assign":{"lineno":33,"varno":11,"expr":{"PLpgSQL_expr":{"query":"ss_length := char_length(string_to_search)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":34,"varno":10,"expr":{"PLpgSQL_expr":{"query":"length := char_length(string)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":35,"varno":8,"expr":{"PLpgSQL_expr":{"query":"beg := length + beg_index - ss_length + 2","parseMode":3}}}},{"PLpgSQL_stmt_while":{"lineno":37,"cond":{"PLpgSQL_expr":{"query":"beg \u003e 0","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":38,"varno":7,"expr":{"PLpgSQL_expr":{"query":"temp_str := substring(string FROM beg FOR ss_length)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":39,"varno":5,"expr":{"PLpgSQL_expr":{"query":"pos := position(string_to_search IN temp_str)","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":41,"cond":{"PLpgSQL_expr":{"query":"pos \u003e 0","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":42,"varno":6,"expr":{"PLpgSQL_expr":{"query":"occur_number := occur_number + 1","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":44,"cond":{"PLpgSQL_expr":{"query":"occur_number = occur_index","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":45,"expr":{"PLpgSQL_expr":{"query":"beg","parseMode":2}}}}]}}]}},{"PLpgSQL_stmt_assign":{"lineno":49,"varno":8,"expr":{"PLpgSQL_expr":{"query":"beg := beg - 1","parseMode":3}}}}]}},{"PLpgSQL_stmt_return":{"lineno":52,"expr":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}]}}],"else_body":[{"PLpgSQL_stmt_return":{"lineno":54,"expr":{"PLpgSQL_expr":{"query":"0","parseMode":2}}}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 009 +-- Additional test data below kindly provided by Olivier Auverlot and used with permission + +CREATE FUNCTION displayDate(endDate date, canceled boolean) RETURNS text + LANGUAGE plpgsql + AS $$BEGIN + IF canceled = true THEN + return null; + ELSE + return endDate; + END IF; +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"enddate","datatype":{"PLpgSQL_type":{"typname":"date"}}}},{"PLpgSQL_var":{"refname":"canceled","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.bool"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_if":{"lineno":2,"cond":{"PLpgSQL_expr":{"query":"canceled = true","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":3,"expr":{"PLpgSQL_expr":{"query":"null","parseMode":2}}}}],"else_body":[{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"endDate","parseMode":2}}}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 010 +CREATE FUNCTION calcule_theYear_these(date_inscription date, date_observation date) RETURNS smallint + LANGUAGE plpgsql + AS $$BEGIN + return (calcule_duree(date_inscription,date_observation) + 1); +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"date_inscription","datatype":{"PLpgSQL_type":{"typname":"date"}}}},{"PLpgSQL_var":{"refname":"date_observation","datatype":{"PLpgSQL_type":{"typname":"date"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":1,"body":[{"PLpgSQL_stmt_return":{"lineno":2,"expr":{"PLpgSQL_expr":{"query":"(calcule_duree(date_inscription,date_observation) + 1)","parseMode":2}}}}]}}}} +] +== 011 +CREATE FUNCTION calcule_duree(origine date, atDate date) RETURNS integer + LANGUAGE plpgsql + AS $$DECLARE + theDay INTEGER; + theMonth INTEGER; + theYear INTEGER; + theDay_now INTEGER; + theMonth_now INTEGER; + theYear_now INTEGER; +BEGIN + theDay := EXTRACT(DAY FROM origine); + theMonth := EXTRACT(MONTH FROM origine); + theYear := EXTRACT(YEAR FROM origine); + + theDay_now := EXTRACT(DAY FROM atDate); + theMonth_now := EXTRACT(MONTH FROM atDate); + theYear_now := EXTRACT(YEAR FROM atDate); + + theYear := theYear_now - theYear; + if theMonth_now <= theMonth THEN + IF theMonth = theMonth_now THEN + IF theDay > theDay_now THEN + theYear := theYear - 1; + END IF; + ELSE + theYear := theYear - 1; + END IF; + END IF; + + return theYear; +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"origine","datatype":{"PLpgSQL_type":{"typname":"date"}}}},{"PLpgSQL_var":{"refname":"atdate","datatype":{"PLpgSQL_type":{"typname":"date"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"theday","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"INTEGER"}}}},{"PLpgSQL_var":{"refname":"themonth","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"INTEGER"}}}},{"PLpgSQL_var":{"refname":"theyear","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"INTEGER"}}}},{"PLpgSQL_var":{"refname":"theday_now","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"INTEGER"}}}},{"PLpgSQL_var":{"refname":"themonth_now","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"INTEGER"}}}},{"PLpgSQL_var":{"refname":"theyear_now","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"INTEGER"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":8,"body":[{"PLpgSQL_stmt_assign":{"lineno":9,"varno":3,"expr":{"PLpgSQL_expr":{"query":"theDay := EXTRACT(DAY FROM origine)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":10,"varno":4,"expr":{"PLpgSQL_expr":{"query":"theMonth := EXTRACT(MONTH FROM origine)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":11,"varno":5,"expr":{"PLpgSQL_expr":{"query":"theYear := EXTRACT(YEAR FROM origine)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":13,"varno":6,"expr":{"PLpgSQL_expr":{"query":"theDay_now := EXTRACT(DAY FROM atDate)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":14,"varno":7,"expr":{"PLpgSQL_expr":{"query":"theMonth_now := EXTRACT(MONTH FROM atDate)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":15,"varno":8,"expr":{"PLpgSQL_expr":{"query":"theYear_now := EXTRACT(YEAR FROM atDate)","parseMode":3}}}},{"PLpgSQL_stmt_assign":{"lineno":17,"varno":5,"expr":{"PLpgSQL_expr":{"query":"theYear := theYear_now - theYear","parseMode":3}}}},{"PLpgSQL_stmt_if":{"lineno":18,"cond":{"PLpgSQL_expr":{"query":"theMonth_now \u003c= theMonth","parseMode":2}},"then_body":[{"PLpgSQL_stmt_if":{"lineno":19,"cond":{"PLpgSQL_expr":{"query":"theMonth = theMonth_now","parseMode":2}},"then_body":[{"PLpgSQL_stmt_if":{"lineno":20,"cond":{"PLpgSQL_expr":{"query":"theDay \u003e theDay_now","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":21,"varno":5,"expr":{"PLpgSQL_expr":{"query":"theYear := theYear - 1","parseMode":3}}}}]}}],"else_body":[{"PLpgSQL_stmt_assign":{"lineno":24,"varno":5,"expr":{"PLpgSQL_expr":{"query":"theYear := theYear - 1","parseMode":3}}}}]}}]}},{"PLpgSQL_stmt_return":{"lineno":28,"expr":{"PLpgSQL_expr":{"query":"theYear","parseMode":2}}}}]}}}} +] +== 012 +CREATE FUNCTION endDatedUID(uidmember character varying) RETURNS integer + LANGUAGE plpgsql + AS $$DECLARE + memberID int4; + +BEGIN + SELECT key INTO memberID + FROM + member + WHERE + uidmember = uid; + + RETURN memberID; +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"uidmember","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"memberid","lineno":2,"datatype":{"PLpgSQL_type":{"typname":"int4"}}}},{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":5,"fields":[{"name":"memberid","varno":2}]}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_execsql":{"lineno":5,"sqlstmt":{"PLpgSQL_expr":{"query":"SELECT key FROM\n\t\tmember\n\tWHERE\n\t\tuidmember = uid","parseMode":0}},"into":true,"target":{"PLpgSQL_row":{"refname":"(unnamed row)","lineno":5,"fields":[{"name":"memberid","varno":2}]}}}},{"PLpgSQL_stmt_return":{"lineno":11,"expr":{"PLpgSQL_expr":{"query":"memberID","parseMode":2}}}}]}}}} +] +== 013 +CREATE FUNCTION currentEmployer(memberID integer, jobID integer, jobEnd date) RETURNS boolean + LANGUAGE plpgsql + AS $$DECLARE + lastJob RECORD; + lastEmployer record; + updateJob BOOL; +BEGIN + updateJob := false; + + SELECT * INTO lastJob FROM lire_lastJob(memberID) AS (jobID INT,startsupport DATE,jobEnd DATE); + IF lastJob.jobID = jobID THEN + SELECT + r_perlab.key AS positionHeld, + r_perlab.endDate AS positionEnd + INTO lastEmployer + FROM + r_perlab, + (SELECT + r_perlab.key_member AS col_memberID, + max(r_perlab.start) AS startrattachement + FROM r_perlab + GROUP BY col_memberID) positions + WHERE ((positions.col_memberID = memberID) AND (r_perlab.key_member = positions.col_memberID) AND (r_perlab.start = startrattachement)); + + IF lastEmployer.positionHeld IS NOT NULL THEN + updateJob := true; + UPDATE r_perlab SET endDate = jobEnd WHERE key = lastEmployer.positionHeld; + END IF; + END IF; + + RETURN updateJob; +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"memberid","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"jobid","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"jobend","datatype":{"PLpgSQL_type":{"typname":"date"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"lastjob","dno":4,"lineno":2}},{"PLpgSQL_rec":{"refname":"lastemployer","dno":5,"lineno":3}},{"PLpgSQL_var":{"refname":"updatejob","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"BOOL"}}}},{"PLpgSQL_recfield":{"fieldname":"jobid","recparentno":4}},{"PLpgSQL_recfield":{"fieldname":"positionheld","recparentno":5}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_assign":{"lineno":6,"varno":6,"expr":{"PLpgSQL_expr":{"query":"updateJob := false","parseMode":3}}}},{"PLpgSQL_stmt_execsql":{"lineno":8,"sqlstmt":{"PLpgSQL_expr":{"query":"SELECT * FROM lire_lastJob(memberID) AS (jobID INT,startsupport DATE,jobEnd DATE)","parseMode":0}},"into":true,"target":{"PLpgSQL_rec":{"refname":"lastjob","dno":4,"lineno":2}}}},{"PLpgSQL_stmt_if":{"lineno":9,"cond":{"PLpgSQL_expr":{"query":"lastJob.jobID = jobID","parseMode":2}},"then_body":[{"PLpgSQL_stmt_execsql":{"lineno":10,"sqlstmt":{"PLpgSQL_expr":{"query":"SELECT\n\t\t\tr_perlab.key AS positionHeld,\n\t\t\tr_perlab.endDate AS positionEnd\n\t\t FROM\n\t\t\tr_perlab,\n\t\t\t(SELECT\n\t\t\t\tr_perlab.key_member AS col_memberID,\n\t\t\t\tmax(r_perlab.start) AS startrattachement\n\t\t\tFROM r_perlab\n\t\t\tGROUP BY col_memberID) positions\n\t\tWHERE ((positions.col_memberID = memberID) AND (r_perlab.key_member = positions.col_memberID) AND (r_perlab.start = startrattachement))","parseMode":0}},"into":true,"target":{"PLpgSQL_rec":{"refname":"lastemployer","dno":5,"lineno":3}}}},{"PLpgSQL_stmt_if":{"lineno":23,"cond":{"PLpgSQL_expr":{"query":"lastEmployer.positionHeld IS NOT NULL","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":24,"varno":6,"expr":{"PLpgSQL_expr":{"query":"updateJob := true","parseMode":3}}}},{"PLpgSQL_stmt_execsql":{"lineno":25,"sqlstmt":{"PLpgSQL_expr":{"query":"UPDATE r_perlab SET endDate = jobEnd WHERE key = lastEmployer.positionHeld","parseMode":0}}}}]}}]}},{"PLpgSQL_stmt_return":{"lineno":29,"expr":{"PLpgSQL_expr":{"query":"updateJob","parseMode":2}}}}]}}}} +] +== 014 +-- CREATE FUNCTION getArrivalDate(memberID integer, teamID integer, atDate date) RETURNS date +-- LANGUAGE plpgsql +-- AS $$ +-- DECLARE +-- affectations affectation[]; +-- aff affectation; +|-- +-- DELAI_MAX CONSTANT INTEGER := 30; +|-- +-- idx INTEGER; +-- nbr_aff INTEGER; +-- start DATE; +-- endDate DATE; +-- sortie BOOLEAN; +|-- +-- arrivalDate DATE; +|-- +-- crs_affectation CURSOR (memberID INTEGER) FOR +-- SELECT +-- affectation.key, +-- affectation.key_team, +-- affectation.key_support, +-- affectation.start, +-- affectation.endDate, +-- affectation.repartition, +-- affectation.key_typeaffectation +-- FROM support,affectation +-- WHERE +-- support.key_member = memberID +-- AND affectation.key_support = support.key +-- AND affectation.start <= atDate +-- AND affectation.key_team = teamID +-- ORDER BY affectation.start DESC; +-- BEGIN +-- OPEN crs_affectation(memberID); +-- LOOP +-- IF NOT FOUND THEN +-- EXIT; +-- END IF; +-- FETCH crs_affectation into aff.key,aff.key_team,aff.key_support,aff.start,aff.endDate,aff.repartition,aff.key_typeaffectation; +-- affectations := ARRAY_APPEND(affectations,aff); +-- END LOOP; +-- CLOSE crs_affectation; +|-- +-- nbr_aff := ARRAY_LENGTH(affectations, 1); +-- idx := 1; +-- sortie := FALSE; +|-- +-- WHILE (idx <= nbr_aff AND sortie = FALSE) LOOP +-- IF(arrivalDate IS NULL) THEN +-- arrivalDate := affectations[idx].start; +-- endDate := affectations[idx].endDate; +-- ELSE +-- IF(arrivalDate - affectations[idx].endDate) < DELAI_MAX THEN +-- arrivalDate := affectations[idx].start; +-- endDate := affectations[idx].endDate; +-- ELSE +-- sortie := TRUE; +-- END IF; +-- END IF; +-- idx := idx + 1; +-- END LOOP; +|-- +-- RETURN arrivalDate; +-- END;$$; + +CREATE FUNCTION cleanString(str character varying) RETURNS character varying + LANGUAGE plpgsql + AS $$ + +DECLARE + spechar VARCHAR[ ] := ARRAY['à','â','é','è','ê','ë','ï','î','ô','û','ù','À','Â','É','È','Ê','Ë','Ï','Î','ô','û','ù','ç' ]; + lettres VARCHAR[ ] := ARRAY['a','a','e','e','e','e','i','i','o','u','u','a','a','e','e','e','e','i','i','o','u','u','c' ]; + resultat VARCHAR; + nbrspechar INTEGER := 23; + +BEGIN + IF (str IS NOT NULL) THEN + resultat := str; + FOR i IN 1..nbrspechar LOOP + resultat := regexp_replace(resultat,spechar[i],lettres[i],'g'); + END LOOP; + END IF; + RETURN resultat; +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"str","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"spechar","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"VARCHAR[ ] "}},"default_val":{"PLpgSQL_expr":{"query":"ARRAY['à','â','é','è','ê','ë','ï','î','ô','û','ù','À','Â','É','È','Ê','Ë','Ï','Î','ô','û','ù','ç' ]","parseMode":2}}}},{"PLpgSQL_var":{"refname":"lettres","lineno":5,"datatype":{"PLpgSQL_type":{"typname":"VARCHAR[ ] "}},"default_val":{"PLpgSQL_expr":{"query":"ARRAY['a','a','e','e','e','e','i','i','o','u','u','a','a','e','e','e','e','i','i','o','u','u','c' ]","parseMode":2}}}},{"PLpgSQL_var":{"refname":"resultat","lineno":6,"datatype":{"PLpgSQL_type":{"typname":"VARCHAR"}}}},{"PLpgSQL_var":{"refname":"nbrspechar","lineno":7,"datatype":{"PLpgSQL_type":{"typname":"INTEGER "}},"default_val":{"PLpgSQL_expr":{"query":"23","parseMode":2}}}},{"PLpgSQL_var":{"refname":"i","lineno":12,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":9,"body":[{"PLpgSQL_stmt_if":{"lineno":10,"cond":{"PLpgSQL_expr":{"query":"(str IS NOT NULL)","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":11,"varno":4,"expr":{"PLpgSQL_expr":{"query":"resultat := str","parseMode":3}}}},{"PLpgSQL_stmt_fori":{"lineno":12,"var":{"PLpgSQL_var":{"refname":"i","lineno":12,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"integer\""}}}},"lower":{"PLpgSQL_expr":{"query":"1","parseMode":2}},"upper":{"PLpgSQL_expr":{"query":"nbrspechar","parseMode":2}},"body":[{"PLpgSQL_stmt_assign":{"lineno":13,"varno":4,"expr":{"PLpgSQL_expr":{"query":"resultat := regexp_replace(resultat,spechar[i],lettres[i],'g')","parseMode":3}}}}]}}]}},{"PLpgSQL_stmt_return":{"lineno":16,"expr":{"PLpgSQL_expr":{"query":"resultat","parseMode":2}}}}]}}}} +] +== 015 +CREATE FUNCTION t_update() RETURNS trigger + LANGUAGE plpgsql + AS $$ + +BEGIN + NEW.name = upper(cleanString(NEW.name)); + return NEW; +END;$$ +-- +[ +{"PLpgSQL_function":{"new_varno":1,"old_varno":2,"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"new","dno":1}},{"PLpgSQL_rec":{"refname":"old","dno":2}},{"PLpgSQL_recfield":{"fieldname":"name","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"NEW.name = upper(cleanString(NEW.name))","parseMode":4}}}},{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"NEW","parseMode":2}}}}]}}}} +] +== 016 +CREATE FUNCTION t_create() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + INSERT INTO list(key,date) VALUES(NEW.key,NEW.end); + RETURN NEW; +END;$$ +-- +[ +{"PLpgSQL_function":{"new_varno":1,"old_varno":2,"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"new","dno":1}},{"PLpgSQL_rec":{"refname":"old","dno":2}},{"PLpgSQL_recfield":{"fieldname":"key","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_execsql":{"lineno":3,"sqlstmt":{"PLpgSQL_expr":{"query":"INSERT INTO list(key,date) VALUES(NEW.key,NEW.end)","parseMode":0}}}},{"PLpgSQL_stmt_return":{"lineno":4,"expr":{"PLpgSQL_expr":{"query":"NEW","parseMode":2}}}}]}}}} +] +== 017 +CREATE OR REPLACE FUNCTION test.test_parse ( + p_time_start timestamptz, + p_time_end timestamptz, + p_time_interval interval default NULL +) RETURNS TABLE ( + ts timestamptz, + arbitrary_return bigint +) AS $$ +BEGIN + -- some comment + -- some other comment + + IF p_time_interval IS NULL + THEN p_time_interval := interval_from_start_end(p_time_start, p_time_end); + END IF; + RETURN QUERY + SELECT + bucket_function(p_time_interval, timestamp) AS ts, + arbitrary_return + FROM test.some_table + WHERE + start >= p_time_start + AND "end" < p_time_end + GROUP BY 1; +END; $$ LANGUAGE plpgsql SECURITY DEFINER PARALLEL UNSAFE +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"p_time_start","datatype":{"PLpgSQL_type":{"typname":"timestamptz"}}}},{"PLpgSQL_var":{"refname":"p_time_end","datatype":{"PLpgSQL_type":{"typname":"timestamptz"}}}},{"PLpgSQL_var":{"refname":"p_time_interval","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"interval\""}}}},{"PLpgSQL_var":{"refname":"ts","datatype":{"PLpgSQL_type":{"typname":"timestamptz"}}}},{"PLpgSQL_var":{"refname":"arbitrary_return","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int8"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_if":{"lineno":6,"cond":{"PLpgSQL_expr":{"query":"p_time_interval IS NULL","parseMode":2}},"then_body":[{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"p_time_interval := interval_from_start_end(p_time_start, p_time_end)","parseMode":3}}}}]}},{"PLpgSQL_stmt_return_query":{"lineno":9,"query":{"PLpgSQL_expr":{"query":"SELECT\n bucket_function(p_time_interval, timestamp) AS ts,\n arbitrary_return\n FROM test.some_table\n WHERE\n start \u003e= p_time_start\n AND \"end\" \u003c p_time_end\n GROUP BY 1","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 018 +CREATE FUNCTION public.somefunc(OUT _result uuid[]) + RETURNS uuid[] + LANGUAGE 'plpgsql' + +AS $BODY$ +DECLARE + active_on_to_date uuid[]; +BEGIN +_result := ARRAY( SELECT some_id FROM some_table); +END; +$BODY$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"_result","datatype":{"PLpgSQL_type":{"typname":"uuid"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"active_on_to_date","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"uuid[]"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_assign":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"_result := ARRAY( SELECT some_id FROM some_table)","parseMode":3}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 019 +CREATE OR REPLACE FUNCTION cs_fmt_browser_version(v_name varchar, v_version varchar) +RETURNS varchar AS $$ +DECLARE +_a int; +_v_name_alias ALIAS FOR $1; +BEGIN +IF v_version IS NULL THEN +RETURN v_name; +END IF; + +RETURN v_name || '/' || v_version; +END; $$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"v_name","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"v_version","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"_a","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"int"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_if":{"lineno":6,"cond":{"PLpgSQL_expr":{"query":"v_version IS NULL","parseMode":2}},"then_body":[{"PLpgSQL_stmt_return":{"lineno":7,"expr":{"PLpgSQL_expr":{"query":"v_name","parseMode":2}}}}]}},{"PLpgSQL_stmt_return":{"lineno":10,"expr":{"PLpgSQL_expr":{"query":"v_name || '/' || v_version","parseMode":2}}}}]}}}} +] +== 020 +CREATE FUNCTION test(str character varying) RETURNS integer +LANGUAGE plpgsql +AS $$ +DECLARE + v3 RECORD; + v4 integer; +BEGIN + select 1 as c1, 2 as c2 into v3; + v3.c1 := 4; +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"str","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"varchar\""}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"v3","dno":2,"lineno":3}},{"PLpgSQL_var":{"refname":"v4","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"integer"}}}},{"PLpgSQL_recfield":{"fieldname":"c1","recparentno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_execsql":{"lineno":6,"sqlstmt":{"PLpgSQL_expr":{"query":"select 1 as c1, 2 as c2","parseMode":0}},"into":true,"target":{"PLpgSQL_rec":{"refname":"v3","dno":2,"lineno":3}}}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":4,"expr":{"PLpgSQL_expr":{"query":"v3.c1 := 4","parseMode":4}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 021 +CREATE FUNCTION test_assert() RETURNS integer +LANGUAGE plpgsql +AS $$ +BEGIN + ASSERT true; + ASSERT now() < '2000-01-01'; + ASSERT false, 'msg'; + ASSERT false, version(); + + RETURN 1; +END;$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assert":{"lineno":3,"cond":{"PLpgSQL_expr":{"query":"true","parseMode":2}}}},{"PLpgSQL_stmt_assert":{"lineno":4,"cond":{"PLpgSQL_expr":{"query":"now() \u003c '2000-01-01'","parseMode":2}}}},{"PLpgSQL_stmt_assert":{"lineno":5,"cond":{"PLpgSQL_expr":{"query":"false","parseMode":2}},"message":{"PLpgSQL_expr":{"query":"'msg'","parseMode":2}}}},{"PLpgSQL_stmt_assert":{"lineno":6,"cond":{"PLpgSQL_expr":{"query":"false","parseMode":2}},"message":{"PLpgSQL_expr":{"query":"version()","parseMode":2}}}},{"PLpgSQL_stmt_return":{"lineno":8,"expr":{"PLpgSQL_expr":{"query":"1","parseMode":2}}}}]}}}} +] +== 022 +-- Example from https://www.postgresql.org/docs/current/sql-do.html +DO $$DECLARE r record; +BEGIN + FOR r IN SELECT table_schema, table_name FROM information_schema.tables + WHERE table_type = 'VIEW' AND table_schema = 'public' + LOOP + EXECUTE 'GRANT ALL ON ' || quote_ident(r.table_schema) || '.' || quote_ident(r.table_name) || ' TO webuser'; + END LOOP; +END$$ +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":1}},{"PLpgSQL_recfield":{"fieldname":"table_schema","recparentno":1}},{"PLpgSQL_recfield":{"fieldname":"table_name","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_fors":{"lineno":3,"var":{"PLpgSQL_rec":{"refname":"r","dno":1,"lineno":1}},"body":[{"PLpgSQL_stmt_dynexecute":{"lineno":6,"query":{"PLpgSQL_expr":{"query":"'GRANT ALL ON ' || quote_ident(r.table_schema) || '.' || quote_ident(r.table_name) || ' TO webuser'","parseMode":2}}}}],"query":{"PLpgSQL_expr":{"query":"SELECT table_schema, table_name FROM information_schema.tables\n WHERE table_type = 'VIEW' AND table_schema = 'public'","parseMode":0}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 023 +CREATE FUNCTION test_cursor() RETURNS void AS $$ + DECLARE + i INT; + c CURSOR FOR SELECT generate_series(1,10); + BEGIN + FOR i IN c LOOP + RAISE NOTICE 'i is %',i; + END LOOP; + END +$$ language plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"i","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"INT"}}}},{"PLpgSQL_var":{"refname":"c","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"pg_catalog.refcursor"}},"cursor_explicit_expr":{"PLpgSQL_expr":{"query":"SELECT generate_series(1,10)","parseMode":0}},"cursor_explicit_argrow":-1,"cursor_options":256}},{"PLpgSQL_rec":{"refname":"i","dno":3,"lineno":6}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_forc":{"lineno":6,"var":{"PLpgSQL_rec":{"refname":"i","dno":3,"lineno":6}},"body":[{"PLpgSQL_stmt_raise":{"lineno":7,"elog_level":18,"message":"i is %","params":[{"PLpgSQL_expr":{"query":"i","parseMode":2}}]}}],"curvar":2}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 024 +CREATE FUNCTION public.dz_sumfunc( + IN p_in INTEGER + ,OUT p_out public.dz_sumthing +) +AS $BODY$ +DECLARE +BEGIN + p_out.sumattribute := p_in; +END; +$BODY$ +LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"p_in","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_rec":{"refname":"p_out","dno":1}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_recfield":{"fieldname":"sumattribute","recparentno":1}}],"action":{"PLpgSQL_stmt_block":{"lineno":3,"body":[{"PLpgSQL_stmt_assign":{"lineno":4,"varno":3,"expr":{"PLpgSQL_expr":{"query":"p_out.sumattribute := p_in","parseMode":4}}}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 025 +-- Examples from https://www.postgresql.org/docs/16/plpgsql-declarations.html#PLPGSQL-DECLARATION-PARAMETERS +CREATE FUNCTION sales_tax(real) RETURNS real AS $$ +DECLARE + subtotal ALIAS FOR $1; +BEGIN + RETURN subtotal * 0.06; +END; +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"$1","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.float4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_return":{"lineno":5,"expr":{"PLpgSQL_expr":{"query":"subtotal * 0.06","parseMode":2}}}}]}}}} +] +== 026 +-- RETURN NEXT; with no expression https://www.postgresql.org/docs/16/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING-RETURN-NEXT +CREATE OR REPLACE FUNCTION public.test_pl(s integer, e integer) + RETURNS TABLE(id INTEGER) AS $$ +BEGIN + id := s; +LOOP + EXIT WHEN id>e; + RETURN NEXT; + id := id + 1; +END LOOP; +END +$$ + LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"s","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"e","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"id","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.int4"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":2,"body":[{"PLpgSQL_stmt_assign":{"lineno":3,"varno":2,"expr":{"PLpgSQL_expr":{"query":"id := s","parseMode":3}}}},{"PLpgSQL_stmt_loop":{"lineno":4,"body":[{"PLpgSQL_stmt_exit":{"lineno":5,"is_exit":true,"cond":{"PLpgSQL_expr":{"query":"id\u003ee","parseMode":2}}}},{"PLpgSQL_stmt_return_next":{"lineno":6}},{"PLpgSQL_stmt_assign":{"lineno":7,"varno":2,"expr":{"PLpgSQL_expr":{"query":"id := id + 1","parseMode":3}}}}]}},{"PLpgSQL_stmt_return":{}}]}}}} +] +== 027 +CREATE OR REPLACE FUNCTION trgfn() + RETURNS trigger AS $$ +DECLARE + prior ALIAS FOR old; + updated ALIAS FOR new; +BEGIN + RETURN; +END; +$$ + LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"new_varno":1,"old_varno":2,"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_rec":{"refname":"new","dno":1}},{"PLpgSQL_rec":{"refname":"old","dno":2}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_return":{"lineno":6}}]}}}} +] +== 028 +-- Example from https://www.postgresql.org/docs/16/plpgsql-cursors.html +CREATE FUNCTION reffunc2() RETURNS refcursor AS ' +DECLARE + ref refcursor; +BEGIN + OPEN ref FOR SELECT col FROM test; + RETURN ref; +END; +' LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"ref","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"refcursor"}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":4,"body":[{"PLpgSQL_stmt_open":{"lineno":5,"curvar":1,"cursor_options":256,"query":{"PLpgSQL_expr":{"query":"SELECT col FROM test","parseMode":0}}}},{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"ref","parseMode":2}}}}]}}}} +] +== 029 +-- Example from https://www.postgresql.org/docs/16/plpgsql-declarations.html#PLPGSQL-DECLARATION-COLLATION +CREATE FUNCTION less_than(a text, b text) RETURNS boolean AS $$ +DECLARE + local_a text COLLATE "en_US" := a; + local_b text := b; +BEGIN + RETURN local_a < local_b; +END; +$$ LANGUAGE plpgsql +-- +[ +{"PLpgSQL_function":{"datums":[{"PLpgSQL_var":{"refname":"a","datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"b","datatype":{"PLpgSQL_type":{"typname":"text"}}}},{"PLpgSQL_var":{"refname":"found","datatype":{"PLpgSQL_type":{"typname":"pg_catalog.\"boolean\""}}}},{"PLpgSQL_var":{"refname":"local_a","lineno":3,"datatype":{"PLpgSQL_type":{"typname":"text "}},"default_val":{"PLpgSQL_expr":{"query":"a","parseMode":2}}}},{"PLpgSQL_var":{"refname":"local_b","lineno":4,"datatype":{"PLpgSQL_type":{"typname":"text "}},"default_val":{"PLpgSQL_expr":{"query":"b","parseMode":2}}}}],"action":{"PLpgSQL_stmt_block":{"lineno":5,"body":[{"PLpgSQL_stmt_return":{"lineno":6,"expr":{"PLpgSQL_expr":{"query":"local_a \u003c local_b","parseMode":2}}}}]}}}} +] diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_array.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_array.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_array.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_array.test b/parser/testdata/scan/plpgsql_regress/plpgsql_array.test new file mode 100644 index 0000000..b400188 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_array.test @@ -0,0 +1,326 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of array variables +|-- +-- We also check arrays of composites here, so this has some overlap +-- with the plpgsql_record tests. +|-- + +create type complex as (r float8, i float8) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 52 SQL_COMMENT NO_KEYWORD +53 55 SQL_COMMENT NO_KEYWORD +56 124 SQL_COMMENT NO_KEYWORD +125 158 SQL_COMMENT NO_KEYWORD +159 161 SQL_COMMENT NO_KEYWORD +163 169 CREATE RESERVED_KEYWORD +170 174 TYPE_P UNRESERVED_KEYWORD +175 182 IDENT NO_KEYWORD +183 185 AS RESERVED_KEYWORD +186 187 ASCII_40 NO_KEYWORD +187 188 IDENT NO_KEYWORD +189 195 IDENT NO_KEYWORD +195 196 ASCII_44 NO_KEYWORD +197 198 IDENT NO_KEYWORD +199 205 IDENT NO_KEYWORD +205 206 ASCII_41 NO_KEYWORD +== 002 +create type quadarray as (c1 complex[], c2 complex) +-- +0 6 CREATE RESERVED_KEYWORD +7 11 TYPE_P UNRESERVED_KEYWORD +12 21 IDENT NO_KEYWORD +22 24 AS RESERVED_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 28 IDENT NO_KEYWORD +29 36 IDENT NO_KEYWORD +36 37 ASCII_91 NO_KEYWORD +37 38 ASCII_93 NO_KEYWORD +38 39 ASCII_44 NO_KEYWORD +40 42 IDENT NO_KEYWORD +43 50 IDENT NO_KEYWORD +50 51 ASCII_41 NO_KEYWORD +== 003 +do $$ declare a int[]; +begin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 87 SCONST NO_KEYWORD +== 004 +do $$ declare a int[]; +begin a[3] := 4; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 70 SCONST NO_KEYWORD +== 005 +do $$ declare a int[]; +begin a[1][4] := 4; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 73 SCONST NO_KEYWORD +== 006 +do $$ declare a int[]; +begin a[1] := 23::text; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 77 SCONST NO_KEYWORD +== 007 +-- lax typing + +do $$ declare a int[]; +begin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end$$ +-- +0 13 SQL_COMMENT NO_KEYWORD +15 17 DO RESERVED_KEYWORD +18 113 SCONST NO_KEYWORD +== 008 +do $$ declare a int[]; +begin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 94 SCONST NO_KEYWORD +== 009 +do $$ declare a int[]; +begin a[1:2] := array[3,4]; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 81 SCONST NO_KEYWORD +== 010 +do $$ declare a int[]; +begin a[1:2] := 4; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 72 SCONST NO_KEYWORD +== 011 +-- error + +do $$ declare a complex[]; +begin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end$$ +-- +0 8 SQL_COMMENT NO_KEYWORD +10 12 DO RESERVED_KEYWORD +13 102 SCONST NO_KEYWORD +== 012 +do $$ declare a complex[]; +begin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 97 SCONST NO_KEYWORD +== 013 +-- perhaps this ought to work, but for now it doesn't: +do $$ declare a complex[]; +begin a[1:2].i := array[11,12]; raise notice 'a = %', a; end$$ +-- +0 54 SQL_COMMENT NO_KEYWORD +55 57 DO RESERVED_KEYWORD +58 144 SCONST NO_KEYWORD +== 014 +do $$ declare a quadarray; +begin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 106 SCONST NO_KEYWORD +== 015 +do $$ declare a int[]; +begin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 108 SCONST NO_KEYWORD +== 016 +create temp table onecol as select array[1,2] as f1 +-- +0 6 CREATE RESERVED_KEYWORD +7 11 TEMP UNRESERVED_KEYWORD +12 17 TABLE RESERVED_KEYWORD +18 24 IDENT NO_KEYWORD +25 27 AS RESERVED_KEYWORD +28 34 SELECT RESERVED_KEYWORD +35 40 ARRAY RESERVED_KEYWORD +40 41 ASCII_91 NO_KEYWORD +41 42 ICONST NO_KEYWORD +42 43 ASCII_44 NO_KEYWORD +43 44 ICONST NO_KEYWORD +44 45 ASCII_93 NO_KEYWORD +46 48 AS RESERVED_KEYWORD +49 51 IDENT NO_KEYWORD +== 017 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 80 SCONST NO_KEYWORD +== 018 +do $$ declare a int[]; +begin a := * from onecol for update; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 90 SCONST NO_KEYWORD +== 019 +-- error cases: + +do $$ declare a int[]; +begin a := from onecol; raise notice 'a = %', a; end$$ +-- +0 15 SQL_COMMENT NO_KEYWORD +17 19 DO RESERVED_KEYWORD +20 94 SCONST NO_KEYWORD +== 020 +do $$ declare a int[]; +begin a := f1, f1 from onecol; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 84 SCONST NO_KEYWORD +== 021 +insert into onecol values(array[11]) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 18 IDENT NO_KEYWORD +19 25 VALUES COL_NAME_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 31 ARRAY RESERVED_KEYWORD +31 32 ASCII_91 NO_KEYWORD +32 34 ICONST NO_KEYWORD +34 35 ASCII_93 NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +== 022 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 80 SCONST NO_KEYWORD +== 023 +do $$ declare a int[]; +begin a := f1 from onecol limit 1; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 88 SCONST NO_KEYWORD +== 024 +do $$ declare a real; +begin a[1] := 2; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 69 SCONST NO_KEYWORD +== 025 +do $$ declare a complex; +begin a.r[1] := 2; raise notice 'a = %', a; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 74 SCONST NO_KEYWORD +== 026 +|-- +-- test of %type[] and %rowtype[] syntax +|-- + +-- check supported syntax +do $$ +declare + v int; + v1 v%type; + v2 v%type[]; + v3 v%type[1]; + v4 v%type[][]; + v5 v%type[1][3]; + v6 v%type array; + v7 v%type array[]; + v8 v%type array[1]; + v9 v%type array[1][1]; + v10 pg_catalog.pg_class%rowtype[]; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(v3); + raise notice '%', pg_typeof(v4); + raise notice '%', pg_typeof(v5); + raise notice '%', pg_typeof(v6); + raise notice '%', pg_typeof(v7); + raise notice '%', pg_typeof(v8); + raise notice '%', pg_typeof(v9); + raise notice '%', pg_typeof(v10); +end; +$$ +-- +0 2 SQL_COMMENT NO_KEYWORD +3 43 SQL_COMMENT NO_KEYWORD +44 46 SQL_COMMENT NO_KEYWORD +48 73 SQL_COMMENT NO_KEYWORD +74 76 DO RESERVED_KEYWORD +77 665 SCONST NO_KEYWORD +== 027 +-- some types don't support arrays +do $$ +declare + v pg_node_tree; + v1 v%type[]; +begin +end; +$$ +-- +0 34 SQL_COMMENT NO_KEYWORD +35 37 DO RESERVED_KEYWORD +38 95 SCONST NO_KEYWORD +== 028 +-- check functionality +do $$ +declare + v1 int; + v2 varchar; + a1 v1%type[]; + a2 v2%type[]; +begin + v1 := 10; + v2 := 'Hi'; + a1 := array[v1,v1]; + a2 := array[v2,v2]; + raise notice '% %', a1, a2; +end; +$$ +-- +0 22 SQL_COMMENT NO_KEYWORD +23 25 DO RESERVED_KEYWORD +26 206 SCONST NO_KEYWORD +== 029 +create table array_test_table(a int, b varchar) +-- +0 6 CREATE RESERVED_KEYWORD +7 12 TABLE RESERVED_KEYWORD +13 29 IDENT NO_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 31 IDENT NO_KEYWORD +32 35 INT_P COL_NAME_KEYWORD +35 36 ASCII_44 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 46 VARCHAR COL_NAME_KEYWORD +46 47 ASCII_41 NO_KEYWORD +== 030 +insert into array_test_table values(1, 'first'), (2, 'second') +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 28 IDENT NO_KEYWORD +29 35 VALUES COL_NAME_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 37 ICONST NO_KEYWORD +37 38 ASCII_44 NO_KEYWORD +39 46 SCONST NO_KEYWORD +46 47 ASCII_41 NO_KEYWORD +47 48 ASCII_44 NO_KEYWORD +49 50 ASCII_40 NO_KEYWORD +50 51 ICONST NO_KEYWORD +51 52 ASCII_44 NO_KEYWORD +53 61 SCONST NO_KEYWORD +61 62 ASCII_41 NO_KEYWORD +== 031 +do $$ +declare tg array_test_table%rowtype[]; +begin + tg := array(select array_test_table from array_test_table); + raise notice '%', tg; + tg := array(select row(a,b) from array_test_table); + raise notice '%', tg; +end; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 222 SCONST NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_cache.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_cache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_cache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_cache.test b/parser/testdata/scan/plpgsql_regress/plpgsql_cache.test new file mode 100644 index 0000000..58b7737 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_cache.test @@ -0,0 +1,168 @@ +== 001 +|-- +-- Cache-behavior-dependent test cases +|-- +-- These tests logically belong in plpgsql_record.sql, and perhaps someday +-- can be merged back into it. For now, however, their results are different +-- depending on debug_discard_caches, so we must have two expected-output +-- files to cover both cases. To minimize the maintenance effort resulting +-- from that, this file should contain only tests that do have different +-- results under debug_discard_caches. +|-- + +-- check behavior with changes of a named rowtype +create table c_mutable(f1 int, f2 text) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 41 SQL_COMMENT NO_KEYWORD +42 44 SQL_COMMENT NO_KEYWORD +45 119 SQL_COMMENT NO_KEYWORD +120 197 SQL_COMMENT NO_KEYWORD +198 271 SQL_COMMENT NO_KEYWORD +272 347 SQL_COMMENT NO_KEYWORD +348 420 SQL_COMMENT NO_KEYWORD +421 459 SQL_COMMENT NO_KEYWORD +460 462 SQL_COMMENT NO_KEYWORD +464 513 SQL_COMMENT NO_KEYWORD +514 520 CREATE RESERVED_KEYWORD +521 526 TABLE RESERVED_KEYWORD +527 536 IDENT NO_KEYWORD +536 537 ASCII_40 NO_KEYWORD +537 539 IDENT NO_KEYWORD +540 543 INT_P COL_NAME_KEYWORD +543 544 ASCII_44 NO_KEYWORD +545 547 IDENT NO_KEYWORD +548 552 TEXT_P UNRESERVED_KEYWORD +552 553 ASCII_41 NO_KEYWORD +== 002 +create function c_sillyaddone(int) returns int language plpgsql as +$$ declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 29 IDENT NO_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 33 INT_P COL_NAME_KEYWORD +33 34 ASCII_41 NO_KEYWORD +35 42 RETURNS UNRESERVED_KEYWORD +43 46 INT_P COL_NAME_KEYWORD +47 55 LANGUAGE UNRESERVED_KEYWORD +56 63 IDENT NO_KEYWORD +64 66 AS RESERVED_KEYWORD +67 132 SCONST NO_KEYWORD +== 003 +select c_sillyaddone(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 20 IDENT NO_KEYWORD +20 21 ASCII_40 NO_KEYWORD +21 23 ICONST NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 004 +alter table c_mutable drop column f1 +-- +0 5 ALTER UNRESERVED_KEYWORD +6 11 TABLE RESERVED_KEYWORD +12 21 IDENT NO_KEYWORD +22 26 DROP UNRESERVED_KEYWORD +27 33 COLUMN RESERVED_KEYWORD +34 36 IDENT NO_KEYWORD +== 005 +alter table c_mutable add column f1 float8 +-- +0 5 ALTER UNRESERVED_KEYWORD +6 11 TABLE RESERVED_KEYWORD +12 21 IDENT NO_KEYWORD +22 25 ADD_P UNRESERVED_KEYWORD +26 32 COLUMN RESERVED_KEYWORD +33 35 IDENT NO_KEYWORD +36 42 IDENT NO_KEYWORD +== 006 +-- currently, this fails due to cached plan for "r.f1 + 1" expression +-- (but if debug_discard_caches is on, it will succeed) +select c_sillyaddone(42) +-- +0 69 SQL_COMMENT NO_KEYWORD +70 125 SQL_COMMENT NO_KEYWORD +126 132 SELECT RESERVED_KEYWORD +133 146 IDENT NO_KEYWORD +146 147 ASCII_40 NO_KEYWORD +147 149 ICONST NO_KEYWORD +149 150 ASCII_41 NO_KEYWORD +== 007 +-- but it's OK if we force plan rebuilding +discard plans +-- +0 42 SQL_COMMENT NO_KEYWORD +43 50 DISCARD UNRESERVED_KEYWORD +51 56 PLANS UNRESERVED_KEYWORD +== 008 +select c_sillyaddone(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 20 IDENT NO_KEYWORD +20 21 ASCII_40 NO_KEYWORD +21 23 ICONST NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 009 +-- check behavior with changes in a record rowtype +create function show_result_type(text) returns text language plpgsql as +$$ + declare + r record; + t text; + begin + execute $1 into r; + select pg_typeof(r.a) into t; + return format('type %s value %s', t, r.a::text); + end; +$$ +-- +0 50 SQL_COMMENT NO_KEYWORD +51 57 CREATE RESERVED_KEYWORD +58 66 FUNCTION UNRESERVED_KEYWORD +67 83 IDENT NO_KEYWORD +83 84 ASCII_40 NO_KEYWORD +84 88 TEXT_P UNRESERVED_KEYWORD +88 89 ASCII_41 NO_KEYWORD +90 97 RETURNS UNRESERVED_KEYWORD +98 102 TEXT_P UNRESERVED_KEYWORD +103 111 LANGUAGE UNRESERVED_KEYWORD +112 119 IDENT NO_KEYWORD +120 122 AS RESERVED_KEYWORD +123 315 SCONST NO_KEYWORD +== 010 +select show_result_type('select 1 as a') +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 39 SCONST NO_KEYWORD +39 40 ASCII_41 NO_KEYWORD +== 011 +-- currently this fails due to cached plan for pg_typeof expression +-- (but if debug_discard_caches is on, it will succeed) +select show_result_type('select 2.0 as a') +-- +0 67 SQL_COMMENT NO_KEYWORD +68 123 SQL_COMMENT NO_KEYWORD +124 130 SELECT RESERVED_KEYWORD +131 147 IDENT NO_KEYWORD +147 148 ASCII_40 NO_KEYWORD +148 165 SCONST NO_KEYWORD +165 166 ASCII_41 NO_KEYWORD +== 012 +-- but it's OK if we force plan rebuilding +discard plans +-- +0 42 SQL_COMMENT NO_KEYWORD +43 50 DISCARD UNRESERVED_KEYWORD +51 56 PLANS UNRESERVED_KEYWORD +== 013 +select show_result_type('select 2.0 as a') +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 41 SCONST NO_KEYWORD +41 42 ASCII_41 NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_call.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_call.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_call.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_call.test b/parser/testdata/scan/plpgsql_regress/plpgsql_call.test new file mode 100644 index 0000000..0dd32d1 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_call.test @@ -0,0 +1,1315 @@ +== 001 +|-- +-- Tests for procedures / CALL syntax +|-- + +CREATE PROCEDURE test_proc1() +LANGUAGE plpgsql +AS $$ +BEGIN + NULL; +END; +$$ +-- +0 2 SQL_COMMENT NO_KEYWORD +3 40 SQL_COMMENT NO_KEYWORD +41 43 SQL_COMMENT NO_KEYWORD +45 51 CREATE RESERVED_KEYWORD +52 61 PROCEDURE UNRESERVED_KEYWORD +62 72 IDENT NO_KEYWORD +72 73 ASCII_40 NO_KEYWORD +73 74 ASCII_41 NO_KEYWORD +75 83 LANGUAGE UNRESERVED_KEYWORD +84 91 IDENT NO_KEYWORD +92 94 AS RESERVED_KEYWORD +95 121 SCONST NO_KEYWORD +== 002 +CALL test_proc1() +-- +0 4 CALL UNRESERVED_KEYWORD +5 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 17 ASCII_41 NO_KEYWORD +== 003 +-- error: can't return non-NULL +CREATE PROCEDURE test_proc2() +LANGUAGE plpgsql +AS $$ +BEGIN + RETURN 5; +END; +$$ +-- +0 31 SQL_COMMENT NO_KEYWORD +32 38 CREATE RESERVED_KEYWORD +39 48 PROCEDURE UNRESERVED_KEYWORD +49 59 IDENT NO_KEYWORD +59 60 ASCII_40 NO_KEYWORD +60 61 ASCII_41 NO_KEYWORD +62 70 LANGUAGE UNRESERVED_KEYWORD +71 78 IDENT NO_KEYWORD +79 81 AS RESERVED_KEYWORD +82 112 SCONST NO_KEYWORD +== 004 +CREATE TABLE test1 (a int) +-- +0 6 CREATE RESERVED_KEYWORD +7 12 TABLE RESERVED_KEYWORD +13 18 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 IDENT NO_KEYWORD +22 25 INT_P COL_NAME_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 005 +CREATE PROCEDURE test_proc3(x int) +LANGUAGE plpgsql +AS $$ +BEGIN + INSERT INTO test1 VALUES (x); +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 29 IDENT NO_KEYWORD +30 33 INT_P COL_NAME_KEYWORD +33 34 ASCII_41 NO_KEYWORD +35 43 LANGUAGE UNRESERVED_KEYWORD +44 51 IDENT NO_KEYWORD +52 54 AS RESERVED_KEYWORD +55 105 SCONST NO_KEYWORD +== 006 +CALL test_proc3(55) +-- +0 4 CALL UNRESERVED_KEYWORD +5 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 007 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 008 +-- Check that plan revalidation doesn't prevent setting transaction properties +-- (bug #18059). This test must include the first temp-object creation in +-- this script, or it won't exercise the bug scenario. Hence we put it early. +CREATE PROCEDURE test_proc3a() +LANGUAGE plpgsql +AS $$ +BEGIN + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + RAISE NOTICE 'done'; +END; +$$ +-- +0 78 SQL_COMMENT NO_KEYWORD +79 153 SQL_COMMENT NO_KEYWORD +154 232 SQL_COMMENT NO_KEYWORD +233 239 CREATE RESERVED_KEYWORD +240 249 PROCEDURE UNRESERVED_KEYWORD +250 261 IDENT NO_KEYWORD +261 262 ASCII_40 NO_KEYWORD +262 263 ASCII_41 NO_KEYWORD +264 272 LANGUAGE UNRESERVED_KEYWORD +273 280 IDENT NO_KEYWORD +281 283 AS RESERVED_KEYWORD +284 387 SCONST NO_KEYWORD +== 009 +CALL test_proc3a() +-- +0 4 CALL UNRESERVED_KEYWORD +5 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ASCII_41 NO_KEYWORD +== 010 +CREATE TEMP TABLE tt1(f1 int) +-- +0 6 CREATE RESERVED_KEYWORD +7 11 TEMP UNRESERVED_KEYWORD +12 17 TABLE RESERVED_KEYWORD +18 21 IDENT NO_KEYWORD +21 22 ASCII_40 NO_KEYWORD +22 24 IDENT NO_KEYWORD +25 28 INT_P COL_NAME_KEYWORD +28 29 ASCII_41 NO_KEYWORD +== 011 +CALL test_proc3a() +-- +0 4 CALL UNRESERVED_KEYWORD +5 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ASCII_41 NO_KEYWORD +== 012 +-- nested CALL +TRUNCATE TABLE test1 +-- +0 14 SQL_COMMENT NO_KEYWORD +15 23 TRUNCATE UNRESERVED_KEYWORD +24 29 TABLE RESERVED_KEYWORD +30 35 IDENT NO_KEYWORD +== 013 +CREATE PROCEDURE test_proc4(y int) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL test_proc3(y); + CALL test_proc3($1); +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 29 IDENT NO_KEYWORD +30 33 INT_P COL_NAME_KEYWORD +33 34 ASCII_41 NO_KEYWORD +35 43 LANGUAGE UNRESERVED_KEYWORD +44 51 IDENT NO_KEYWORD +52 54 AS RESERVED_KEYWORD +55 120 SCONST NO_KEYWORD +== 014 +CALL test_proc4(66) +-- +0 4 CALL UNRESERVED_KEYWORD +5 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 015 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 016 +CALL test_proc4(66) +-- +0 4 CALL UNRESERVED_KEYWORD +5 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 017 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 018 +-- output arguments + +CREATE PROCEDURE test_proc5(INOUT a text) +LANGUAGE plpgsql +AS $$ +BEGIN + a := a || '+' || a; +END; +$$ +-- +0 19 SQL_COMMENT NO_KEYWORD +21 27 CREATE RESERVED_KEYWORD +28 37 PROCEDURE UNRESERVED_KEYWORD +38 48 IDENT NO_KEYWORD +48 49 ASCII_40 NO_KEYWORD +49 54 INOUT COL_NAME_KEYWORD +55 56 IDENT NO_KEYWORD +57 61 TEXT_P UNRESERVED_KEYWORD +61 62 ASCII_41 NO_KEYWORD +63 71 LANGUAGE UNRESERVED_KEYWORD +72 79 IDENT NO_KEYWORD +80 82 AS RESERVED_KEYWORD +83 123 SCONST NO_KEYWORD +== 019 +CALL test_proc5('abc') +-- +0 4 CALL UNRESERVED_KEYWORD +5 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 21 SCONST NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 020 +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + b := b * a; + c := c * a; +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 29 IDENT NO_KEYWORD +30 33 INT_P COL_NAME_KEYWORD +33 34 ASCII_44 NO_KEYWORD +35 40 INOUT COL_NAME_KEYWORD +41 42 IDENT NO_KEYWORD +43 46 INT_P COL_NAME_KEYWORD +46 47 ASCII_44 NO_KEYWORD +48 53 INOUT COL_NAME_KEYWORD +54 55 IDENT NO_KEYWORD +56 59 INT_P COL_NAME_KEYWORD +59 60 ASCII_41 NO_KEYWORD +61 69 LANGUAGE UNRESERVED_KEYWORD +70 77 IDENT NO_KEYWORD +78 80 AS RESERVED_KEYWORD +81 129 SCONST NO_KEYWORD +== 021 +CALL test_proc6(2, 3, 4) +-- +0 4 CALL UNRESERVED_KEYWORD +5 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 17 ICONST NO_KEYWORD +17 18 ASCII_44 NO_KEYWORD +19 20 ICONST NO_KEYWORD +20 21 ASCII_44 NO_KEYWORD +22 23 ICONST NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 022 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); + RAISE INFO 'x = %, y = %', x, y; + CALL test_proc6(2, c => y, b => x); + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 220 SCONST NO_KEYWORD +== 023 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x + 1, y); -- error + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 157 SCONST NO_KEYWORD +== 024 +DO +LANGUAGE plpgsql +$$ +DECLARE + x constant int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); -- error because x is constant +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 147 SCONST NO_KEYWORD +== 025 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + FOR i IN 1..5 LOOP + CALL test_proc6(i, x, y); + RAISE INFO 'x = %, y = %', x, y; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 188 SCONST NO_KEYWORD +== 026 +-- recursive with output arguments + +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN +IF x > 1 THEN + a := x / 10; + b := x / 2; + CALL test_proc7(b::int, a, b); +END IF; +END; +$$ +-- +0 34 SQL_COMMENT NO_KEYWORD +36 42 CREATE RESERVED_KEYWORD +43 52 PROCEDURE UNRESERVED_KEYWORD +53 63 IDENT NO_KEYWORD +63 64 ASCII_40 NO_KEYWORD +64 65 IDENT NO_KEYWORD +66 69 INT_P COL_NAME_KEYWORD +69 70 ASCII_44 NO_KEYWORD +71 76 INOUT COL_NAME_KEYWORD +77 78 IDENT NO_KEYWORD +79 82 INT_P COL_NAME_KEYWORD +82 83 ASCII_44 NO_KEYWORD +84 89 INOUT COL_NAME_KEYWORD +90 91 IDENT NO_KEYWORD +92 99 NUMERIC COL_NAME_KEYWORD +99 100 ASCII_41 NO_KEYWORD +101 109 LANGUAGE UNRESERVED_KEYWORD +110 117 IDENT NO_KEYWORD +118 120 AS RESERVED_KEYWORD +121 227 SCONST NO_KEYWORD +== 027 +CALL test_proc7(100, -1, -1) +-- +0 4 CALL UNRESERVED_KEYWORD +5 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 19 ICONST NO_KEYWORD +19 20 ASCII_44 NO_KEYWORD +21 22 ASCII_45 NO_KEYWORD +22 23 ICONST NO_KEYWORD +23 24 ASCII_44 NO_KEYWORD +25 26 ASCII_45 NO_KEYWORD +26 27 ICONST NO_KEYWORD +27 28 ASCII_41 NO_KEYWORD +== 028 +-- inner COMMIT with output arguments + +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN + a := x / 10; + b := x / 2; + COMMIT; +END; +$$ +-- +0 37 SQL_COMMENT NO_KEYWORD +39 45 CREATE RESERVED_KEYWORD +46 55 PROCEDURE UNRESERVED_KEYWORD +56 67 IDENT NO_KEYWORD +67 68 ASCII_40 NO_KEYWORD +68 69 IDENT NO_KEYWORD +70 73 INT_P COL_NAME_KEYWORD +73 74 ASCII_44 NO_KEYWORD +75 80 INOUT COL_NAME_KEYWORD +81 82 IDENT NO_KEYWORD +83 86 INT_P COL_NAME_KEYWORD +86 87 ASCII_44 NO_KEYWORD +88 93 INOUT COL_NAME_KEYWORD +94 95 IDENT NO_KEYWORD +96 103 NUMERIC COL_NAME_KEYWORD +103 104 ASCII_41 NO_KEYWORD +105 113 LANGUAGE UNRESERVED_KEYWORD +114 121 IDENT NO_KEYWORD +122 124 AS RESERVED_KEYWORD +125 180 SCONST NO_KEYWORD +== 029 +CREATE PROCEDURE test_proc7cc(_x int) +LANGUAGE plpgsql +AS $$ +DECLARE _a int; _b numeric; +BEGIN + CALL test_proc7c(_x, _a, _b); + RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b; +END +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 29 IDENT NO_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 32 IDENT NO_KEYWORD +33 36 INT_P COL_NAME_KEYWORD +36 37 ASCII_41 NO_KEYWORD +38 46 LANGUAGE UNRESERVED_KEYWORD +47 54 IDENT NO_KEYWORD +55 57 AS RESERVED_KEYWORD +58 182 SCONST NO_KEYWORD +== 030 +CALL test_proc7cc(10) +-- +0 4 CALL UNRESERVED_KEYWORD +5 17 IDENT NO_KEYWORD +17 18 ASCII_40 NO_KEYWORD +18 20 ICONST NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 031 +-- named parameters and defaults + +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := a * 10; + b := b + 10; +END; +$$ +-- +0 32 SQL_COMMENT NO_KEYWORD +34 40 CREATE RESERVED_KEYWORD +41 50 PROCEDURE UNRESERVED_KEYWORD +51 62 IDENT NO_KEYWORD +62 63 ASCII_40 NO_KEYWORD +63 68 INOUT COL_NAME_KEYWORD +69 70 IDENT NO_KEYWORD +71 74 INT_P COL_NAME_KEYWORD +74 75 ASCII_44 NO_KEYWORD +76 81 INOUT COL_NAME_KEYWORD +82 83 IDENT NO_KEYWORD +84 87 INT_P COL_NAME_KEYWORD +87 88 ASCII_41 NO_KEYWORD +89 97 LANGUAGE UNRESERVED_KEYWORD +98 105 IDENT NO_KEYWORD +106 108 AS RESERVED_KEYWORD +109 190 SCONST NO_KEYWORD +== 032 +CALL test_proc8a(10, 20) +-- +0 4 CALL UNRESERVED_KEYWORD +5 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 19 ICONST NO_KEYWORD +19 20 ASCII_44 NO_KEYWORD +21 23 ICONST NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 033 +CALL test_proc8a(b => 20, a => 10) +-- +0 4 CALL UNRESERVED_KEYWORD +5 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 IDENT NO_KEYWORD +19 21 EQUALS_GREATER NO_KEYWORD +22 24 ICONST NO_KEYWORD +24 25 ASCII_44 NO_KEYWORD +26 27 IDENT NO_KEYWORD +28 30 EQUALS_GREATER NO_KEYWORD +31 33 ICONST NO_KEYWORD +33 34 ASCII_41 NO_KEYWORD +== 034 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc8a(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; + CALL test_proc8a(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 208 SCONST NO_KEYWORD +== 035 +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 34 INOUT COL_NAME_KEYWORD +35 36 IDENT NO_KEYWORD +37 40 INT_P COL_NAME_KEYWORD +40 41 ASCII_44 NO_KEYWORD +42 47 INOUT COL_NAME_KEYWORD +48 49 IDENT NO_KEYWORD +50 53 INT_P COL_NAME_KEYWORD +53 54 ASCII_44 NO_KEYWORD +55 60 INOUT COL_NAME_KEYWORD +61 62 IDENT NO_KEYWORD +63 66 INT_P COL_NAME_KEYWORD +66 67 ASCII_41 NO_KEYWORD +68 76 LANGUAGE UNRESERVED_KEYWORD +77 84 IDENT NO_KEYWORD +85 87 AS RESERVED_KEYWORD +88 194 SCONST NO_KEYWORD +== 036 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8b(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + CALL test_proc8b(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 256 SCONST NO_KEYWORD +== 037 +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 34 INOUT COL_NAME_KEYWORD +35 36 IDENT NO_KEYWORD +37 40 INT_P COL_NAME_KEYWORD +40 41 ASCII_44 NO_KEYWORD +42 47 INOUT COL_NAME_KEYWORD +48 49 IDENT NO_KEYWORD +50 53 INT_P COL_NAME_KEYWORD +53 54 ASCII_44 NO_KEYWORD +55 60 INOUT COL_NAME_KEYWORD +61 62 IDENT NO_KEYWORD +63 66 INT_P COL_NAME_KEYWORD +67 74 DEFAULT RESERVED_KEYWORD +75 77 ICONST NO_KEYWORD +77 78 ASCII_41 NO_KEYWORD +79 87 LANGUAGE UNRESERVED_KEYWORD +88 95 IDENT NO_KEYWORD +96 98 AS RESERVED_KEYWORD +99 205 SCONST NO_KEYWORD +== 038 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(c => _c, b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 417 SCONST NO_KEYWORD +== 039 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 195 SCONST NO_KEYWORD +== 040 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, b => _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 200 SCONST NO_KEYWORD +== 041 +-- OUT parameters + +CREATE PROCEDURE test_proc9(IN a int, OUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + b := a * 2; +END; +$$ +-- +0 17 SQL_COMMENT NO_KEYWORD +19 25 CREATE RESERVED_KEYWORD +26 35 PROCEDURE UNRESERVED_KEYWORD +36 46 IDENT NO_KEYWORD +46 47 ASCII_40 NO_KEYWORD +47 49 IN_P RESERVED_KEYWORD +50 51 IDENT NO_KEYWORD +52 55 INT_P COL_NAME_KEYWORD +55 56 ASCII_44 NO_KEYWORD +57 60 OUT_P COL_NAME_KEYWORD +61 62 IDENT NO_KEYWORD +63 66 INT_P COL_NAME_KEYWORD +66 67 ASCII_41 NO_KEYWORD +68 76 LANGUAGE UNRESERVED_KEYWORD +77 84 IDENT NO_KEYWORD +85 87 AS RESERVED_KEYWORD +88 153 SCONST NO_KEYWORD +== 042 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc9(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 130 SCONST NO_KEYWORD +== 043 +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + b := a - c; +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 31 IN_P RESERVED_KEYWORD +32 33 IDENT NO_KEYWORD +34 37 INT_P COL_NAME_KEYWORD +37 38 ASCII_44 NO_KEYWORD +39 42 OUT_P COL_NAME_KEYWORD +43 44 IDENT NO_KEYWORD +45 48 INT_P COL_NAME_KEYWORD +48 49 ASCII_44 NO_KEYWORD +50 52 IN_P RESERVED_KEYWORD +53 54 IDENT NO_KEYWORD +55 58 INT_P COL_NAME_KEYWORD +59 66 DEFAULT RESERVED_KEYWORD +67 69 ICONST NO_KEYWORD +69 70 ASCII_41 NO_KEYWORD +71 79 LANGUAGE UNRESERVED_KEYWORD +80 87 IDENT NO_KEYWORD +88 90 AS RESERVED_KEYWORD +91 165 SCONST NO_KEYWORD +== 044 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(a => _a, b => _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 880 SCONST NO_KEYWORD +== 045 +-- OUT + VARIADIC + +CREATE PROCEDURE test_proc11(a OUT int, VARIADIC b int[]) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := b[1] + b[2]; +END; +$$ +-- +0 17 SQL_COMMENT NO_KEYWORD +19 25 CREATE RESERVED_KEYWORD +26 35 PROCEDURE UNRESERVED_KEYWORD +36 47 IDENT NO_KEYWORD +47 48 ASCII_40 NO_KEYWORD +48 49 IDENT NO_KEYWORD +50 53 OUT_P COL_NAME_KEYWORD +54 57 INT_P COL_NAME_KEYWORD +57 58 ASCII_44 NO_KEYWORD +59 67 VARIADIC RESERVED_KEYWORD +68 69 IDENT NO_KEYWORD +70 73 INT_P COL_NAME_KEYWORD +73 74 ASCII_91 NO_KEYWORD +74 75 ASCII_93 NO_KEYWORD +75 76 ASCII_41 NO_KEYWORD +77 85 LANGUAGE UNRESERVED_KEYWORD +86 93 IDENT NO_KEYWORD +94 96 AS RESERVED_KEYWORD +97 168 SCONST NO_KEYWORD +== 046 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc11(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 163 SCONST NO_KEYWORD +== 047 +-- polymorphic OUT arguments + +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %', a; + b := a; + c := array[a]; +END; +$$ +-- +0 28 SQL_COMMENT NO_KEYWORD +30 36 CREATE RESERVED_KEYWORD +37 46 PROCEDURE UNRESERVED_KEYWORD +47 58 IDENT NO_KEYWORD +58 59 ASCII_40 NO_KEYWORD +59 60 IDENT NO_KEYWORD +61 71 IDENT NO_KEYWORD +71 72 ASCII_44 NO_KEYWORD +73 76 OUT_P COL_NAME_KEYWORD +77 78 IDENT NO_KEYWORD +79 89 IDENT NO_KEYWORD +89 90 ASCII_44 NO_KEYWORD +91 94 OUT_P COL_NAME_KEYWORD +95 96 IDENT NO_KEYWORD +97 105 IDENT NO_KEYWORD +105 106 ASCII_41 NO_KEYWORD +107 115 LANGUAGE UNRESERVED_KEYWORD +116 123 IDENT NO_KEYWORD +124 126 AS RESERVED_KEYWORD +127 196 SCONST NO_KEYWORD +== 048 +DO $$ +DECLARE _a int; _b int; _c int[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 146 SCONST NO_KEYWORD +== 049 +DO $$ +DECLARE _a int; _b int; _c text[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); -- error + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 157 SCONST NO_KEYWORD +== 050 +-- transition variable assignment + +TRUNCATE test1 +-- +0 33 SQL_COMMENT NO_KEYWORD +35 43 TRUNCATE UNRESERVED_KEYWORD +44 49 IDENT NO_KEYWORD +== 051 +CREATE FUNCTION triggerfunc1() RETURNS trigger +LANGUAGE plpgsql +AS $$ +DECLARE + z int := 0; +BEGIN + CALL test_proc6(2, NEW.a, NEW.a); + RETURN NEW; +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ASCII_41 NO_KEYWORD +31 38 RETURNS UNRESERVED_KEYWORD +39 46 TRIGGER UNRESERVED_KEYWORD +47 55 LANGUAGE UNRESERVED_KEYWORD +56 63 IDENT NO_KEYWORD +64 66 AS RESERVED_KEYWORD +67 161 SCONST NO_KEYWORD +== 052 +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE PROCEDURE triggerfunc1() +-- +0 6 CREATE RESERVED_KEYWORD +7 14 TRIGGER UNRESERVED_KEYWORD +15 17 IDENT NO_KEYWORD +18 24 BEFORE UNRESERVED_KEYWORD +25 31 INSERT UNRESERVED_KEYWORD +32 34 ON RESERVED_KEYWORD +35 40 IDENT NO_KEYWORD +41 48 EXECUTE UNRESERVED_KEYWORD +49 58 PROCEDURE UNRESERVED_KEYWORD +59 71 IDENT NO_KEYWORD +71 72 ASCII_40 NO_KEYWORD +72 73 ASCII_41 NO_KEYWORD +== 053 +INSERT INTO test1 VALUES (1), (2), (3) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 17 IDENT NO_KEYWORD +18 24 VALUES COL_NAME_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ICONST NO_KEYWORD +27 28 ASCII_41 NO_KEYWORD +28 29 ASCII_44 NO_KEYWORD +30 31 ASCII_40 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +33 34 ASCII_44 NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 37 ICONST NO_KEYWORD +37 38 ASCII_41 NO_KEYWORD +== 054 +UPDATE test1 SET a = 22 WHERE a = 2 +-- +0 6 UPDATE UNRESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +13 16 SET UNRESERVED_KEYWORD +17 18 IDENT NO_KEYWORD +19 20 ASCII_61 NO_KEYWORD +21 23 ICONST NO_KEYWORD +24 29 WHERE RESERVED_KEYWORD +30 31 IDENT NO_KEYWORD +32 33 ASCII_61 NO_KEYWORD +34 35 ICONST NO_KEYWORD +== 055 +SELECT * FROM test1 ORDER BY a +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +20 25 ORDER RESERVED_KEYWORD +26 28 BY UNRESERVED_KEYWORD +29 30 IDENT NO_KEYWORD +== 056 +DROP PROCEDURE test_proc1 +-- +0 4 DROP UNRESERVED_KEYWORD +5 14 PROCEDURE UNRESERVED_KEYWORD +15 25 IDENT NO_KEYWORD +== 057 +DROP PROCEDURE test_proc3 +-- +0 4 DROP UNRESERVED_KEYWORD +5 14 PROCEDURE UNRESERVED_KEYWORD +15 25 IDENT NO_KEYWORD +== 058 +DROP PROCEDURE test_proc4 +-- +0 4 DROP UNRESERVED_KEYWORD +5 14 PROCEDURE UNRESERVED_KEYWORD +15 25 IDENT NO_KEYWORD +== 059 +DROP TABLE test1 +-- +0 4 DROP UNRESERVED_KEYWORD +5 10 TABLE RESERVED_KEYWORD +11 16 IDENT NO_KEYWORD +== 060 +-- more checks for named-parameter handling + +CREATE PROCEDURE p1(v_cnt int, v_Text inout text = NULL) +AS $$ +BEGIN + v_Text := 'v_cnt = ' || v_cnt; +END +$$ LANGUAGE plpgsql +-- +0 43 SQL_COMMENT NO_KEYWORD +45 51 CREATE RESERVED_KEYWORD +52 61 PROCEDURE UNRESERVED_KEYWORD +62 64 IDENT NO_KEYWORD +64 65 ASCII_40 NO_KEYWORD +65 70 IDENT NO_KEYWORD +71 74 INT_P COL_NAME_KEYWORD +74 75 ASCII_44 NO_KEYWORD +76 82 IDENT NO_KEYWORD +83 88 INOUT COL_NAME_KEYWORD +89 93 TEXT_P UNRESERVED_KEYWORD +94 95 ASCII_61 NO_KEYWORD +96 100 NULL_P RESERVED_KEYWORD +100 101 ASCII_41 NO_KEYWORD +102 104 AS RESERVED_KEYWORD +105 153 SCONST NO_KEYWORD +154 162 LANGUAGE UNRESERVED_KEYWORD +163 170 IDENT NO_KEYWORD +== 061 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text + RAISE NOTICE '%', v_Text; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 165 SCONST NO_KEYWORD +== 062 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 139 SCONST NO_KEYWORD +== 063 +DO $$ +DECLARE + v_Text text; +BEGIN + CALL p1(10, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 103 SCONST NO_KEYWORD +== 064 +DO $$ +DECLARE + v_Text text; + v_cnt integer; +BEGIN + CALL p1(v_Text := v_Text, v_cnt := v_cnt); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 133 SCONST NO_KEYWORD +== 065 +-- check that we detect change of dependencies in CALL +-- atomic and non-atomic call sites used to do this differently, so check both + +CREATE PROCEDURE inner_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'inner_p(%)', f1; +END +$$ LANGUAGE plpgsql +-- +0 54 SQL_COMMENT NO_KEYWORD +55 133 SQL_COMMENT NO_KEYWORD +135 141 CREATE RESERVED_KEYWORD +142 151 PROCEDURE UNRESERVED_KEYWORD +152 159 IDENT NO_KEYWORD +160 161 ASCII_40 NO_KEYWORD +161 163 IDENT NO_KEYWORD +164 167 INT_P COL_NAME_KEYWORD +167 168 ASCII_41 NO_KEYWORD +169 171 AS RESERVED_KEYWORD +172 220 SCONST NO_KEYWORD +221 229 LANGUAGE UNRESERVED_KEYWORD +230 237 IDENT NO_KEYWORD +== 066 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 1 $$ LANGUAGE sql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 17 IDENT NO_KEYWORD +17 18 ASCII_40 NO_KEYWORD +18 21 INT_P COL_NAME_KEYWORD +21 22 ASCII_41 NO_KEYWORD +23 30 RETURNS UNRESERVED_KEYWORD +31 34 INT_P COL_NAME_KEYWORD +35 37 AS RESERVED_KEYWORD +38 57 SCONST NO_KEYWORD +58 66 LANGUAGE UNRESERVED_KEYWORD +67 70 SQL_P UNRESERVED_KEYWORD +== 067 +CREATE PROCEDURE outer_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'outer_p(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 24 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 28 IDENT NO_KEYWORD +29 32 INT_P COL_NAME_KEYWORD +32 33 ASCII_41 NO_KEYWORD +34 36 AS RESERVED_KEYWORD +37 108 SCONST NO_KEYWORD +109 117 LANGUAGE UNRESERVED_KEYWORD +118 125 IDENT NO_KEYWORD +== 068 +CREATE FUNCTION outer_f (f1 int) RETURNS void +AS $$ +BEGIN + RAISE NOTICE 'outer_f(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 23 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 27 IDENT NO_KEYWORD +28 31 INT_P COL_NAME_KEYWORD +31 32 ASCII_41 NO_KEYWORD +33 40 RETURNS UNRESERVED_KEYWORD +41 45 IDENT NO_KEYWORD +46 48 AS RESERVED_KEYWORD +49 120 SCONST NO_KEYWORD +121 129 LANGUAGE UNRESERVED_KEYWORD +130 137 IDENT NO_KEYWORD +== 069 +CALL outer_p(42) +-- +0 4 CALL UNRESERVED_KEYWORD +5 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 15 ICONST NO_KEYWORD +15 16 ASCII_41 NO_KEYWORD +== 070 +SELECT outer_f(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 14 IDENT NO_KEYWORD +14 15 ASCII_40 NO_KEYWORD +15 17 ICONST NO_KEYWORD +17 18 ASCII_41 NO_KEYWORD +== 071 +DROP FUNCTION f(int) +-- +0 4 DROP UNRESERVED_KEYWORD +5 13 FUNCTION UNRESERVED_KEYWORD +14 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 19 INT_P COL_NAME_KEYWORD +19 20 ASCII_41 NO_KEYWORD +== 072 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 2 $$ LANGUAGE sql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 17 IDENT NO_KEYWORD +17 18 ASCII_40 NO_KEYWORD +18 21 INT_P COL_NAME_KEYWORD +21 22 ASCII_41 NO_KEYWORD +23 30 RETURNS UNRESERVED_KEYWORD +31 34 INT_P COL_NAME_KEYWORD +35 37 AS RESERVED_KEYWORD +38 57 SCONST NO_KEYWORD +58 66 LANGUAGE UNRESERVED_KEYWORD +67 70 SQL_P UNRESERVED_KEYWORD +== 073 +CALL outer_p(42) +-- +0 4 CALL UNRESERVED_KEYWORD +5 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 15 ICONST NO_KEYWORD +15 16 ASCII_41 NO_KEYWORD +== 074 +SELECT outer_f(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 14 IDENT NO_KEYWORD +14 15 ASCII_40 NO_KEYWORD +15 17 ICONST NO_KEYWORD +17 18 ASCII_41 NO_KEYWORD +== 075 +-- Check that stable functions in CALL see the correct snapshot + +CREATE TABLE t_test (x int) +-- +0 63 SQL_COMMENT NO_KEYWORD +65 71 CREATE RESERVED_KEYWORD +72 77 TABLE RESERVED_KEYWORD +78 84 IDENT NO_KEYWORD +85 86 ASCII_40 NO_KEYWORD +86 87 IDENT NO_KEYWORD +88 91 INT_P COL_NAME_KEYWORD +91 92 ASCII_41 NO_KEYWORD +== 076 +INSERT INTO t_test VALUES (0) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 18 IDENT NO_KEYWORD +19 25 VALUES COL_NAME_KEYWORD +26 27 ASCII_40 NO_KEYWORD +27 28 ICONST NO_KEYWORD +28 29 ASCII_41 NO_KEYWORD +== 077 +CREATE FUNCTION f_get_x () RETURNS int +AS $$ +DECLARE l_result int; +BEGIN + SELECT x INTO l_result FROM t_test; + RETURN l_result; +END +$$ LANGUAGE plpgsql STABLE +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 23 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +27 34 RETURNS UNRESERVED_KEYWORD +35 38 INT_P COL_NAME_KEYWORD +39 41 AS RESERVED_KEYWORD +42 136 SCONST NO_KEYWORD +137 145 LANGUAGE UNRESERVED_KEYWORD +146 153 IDENT NO_KEYWORD +154 160 STABLE UNRESERVED_KEYWORD +== 078 +CREATE PROCEDURE f_print_x (x int) +AS $$ +BEGIN + RAISE NOTICE 'f_print_x(%)', x; +END +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 26 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 29 IDENT NO_KEYWORD +30 33 INT_P COL_NAME_KEYWORD +33 34 ASCII_41 NO_KEYWORD +35 37 AS RESERVED_KEYWORD +38 87 SCONST NO_KEYWORD +88 96 LANGUAGE UNRESERVED_KEYWORD +97 104 IDENT NO_KEYWORD +== 079 +-- test in non-atomic context +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + ROLLBACK; +END +$$ +-- +0 29 SQL_COMMENT NO_KEYWORD +30 32 DO RESERVED_KEYWORD +33 260 SCONST NO_KEYWORD +== 080 +-- test in non-atomic context, except exception block is locally atomic +DO $$ +BEGIN + BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + EXCEPTION WHEN division_by_zero THEN + RAISE NOTICE '%', SQLERRM; + END; + ROLLBACK; +END +$$ +-- +0 71 SQL_COMMENT NO_KEYWORD +72 74 DO RESERVED_KEYWORD +75 383 SCONST NO_KEYWORD +== 081 +-- test in atomic context +BEGIN +-- +0 25 SQL_COMMENT NO_KEYWORD +26 31 BEGIN_P UNRESERVED_KEYWORD +== 082 +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 218 SCONST NO_KEYWORD +== 083 +ROLLBACK +-- +0 8 ROLLBACK UNRESERVED_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_control.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_control.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_control.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_control.test b/parser/testdata/scan/plpgsql_regress/plpgsql_control.test new file mode 100644 index 0000000..b2768de --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_control.test @@ -0,0 +1,973 @@ +== 001 +|-- +-- Tests for PL/pgSQL control structures +|-- + +-- integer FOR loop + +do $$ +begin + -- basic case + for i in 1..3 loop + raise notice '1..3: i = %', i; + end loop; + -- with BY, end matches exactly + for i in 1..10 by 3 loop + raise notice '1..10 by 3: i = %', i; + end loop; + -- with BY, end does not match + for i in 1..11 by 3 loop + raise notice '1..11 by 3: i = %', i; + end loop; + -- zero iterations + for i in 1..0 by 3 loop + raise notice '1..0 by 3: i = %', i; + end loop; + -- REVERSE + for i in reverse 10..0 by 3 loop + raise notice 'reverse 10..0 by 3: i = %', i; + end loop; + -- potential overflow + for i in 2147483620..2147483647 by 10 loop + raise notice '2147483620..2147483647 by 10: i = %', i; + end loop; + -- potential overflow, reverse direction + for i in reverse -2147483620..-2147483647 by 10 loop + raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i; + end loop; +end$$ +-- +0 2 SQL_COMMENT NO_KEYWORD +3 43 SQL_COMMENT NO_KEYWORD +44 46 SQL_COMMENT NO_KEYWORD +48 67 SQL_COMMENT NO_KEYWORD +69 71 DO RESERVED_KEYWORD +72 924 SCONST NO_KEYWORD +== 002 +-- BY can't be zero or negative +do $$ +begin + for i in 1..3 by 0 loop + raise notice '1..3 by 0: i = %', i; + end loop; +end$$ +-- +0 31 SQL_COMMENT NO_KEYWORD +32 34 DO RESERVED_KEYWORD +35 127 SCONST NO_KEYWORD +== 003 +do $$ +begin + for i in 1..3 by -1 loop + raise notice '1..3 by -1: i = %', i; + end loop; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 97 SCONST NO_KEYWORD +== 004 +do $$ +begin + for i in reverse 1..3 by -1 loop + raise notice 'reverse 1..3 by -1: i = %', i; + end loop; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 113 SCONST NO_KEYWORD +== 005 +-- CONTINUE statement + +create table conttesttbl(idx serial, v integer) +-- +0 21 SQL_COMMENT NO_KEYWORD +23 29 CREATE RESERVED_KEYWORD +30 35 TABLE RESERVED_KEYWORD +36 47 IDENT NO_KEYWORD +47 48 ASCII_40 NO_KEYWORD +48 51 IDENT NO_KEYWORD +52 58 IDENT NO_KEYWORD +58 59 ASCII_44 NO_KEYWORD +60 61 IDENT NO_KEYWORD +62 69 INTEGER COL_NAME_KEYWORD +69 70 ASCII_41 NO_KEYWORD +== 006 +insert into conttesttbl(v) values(10) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 IDENT NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +27 33 VALUES COL_NAME_KEYWORD +33 34 ASCII_40 NO_KEYWORD +34 36 ICONST NO_KEYWORD +36 37 ASCII_41 NO_KEYWORD +== 007 +insert into conttesttbl(v) values(20) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 IDENT NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +27 33 VALUES COL_NAME_KEYWORD +33 34 ASCII_40 NO_KEYWORD +34 36 ICONST NO_KEYWORD +36 37 ASCII_41 NO_KEYWORD +== 008 +insert into conttesttbl(v) values(30) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 IDENT NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +27 33 VALUES COL_NAME_KEYWORD +33 34 ASCII_40 NO_KEYWORD +34 36 ICONST NO_KEYWORD +36 37 ASCII_41 NO_KEYWORD +== 009 +insert into conttesttbl(v) values(40) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 IDENT NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +27 33 VALUES COL_NAME_KEYWORD +33 34 ASCII_40 NO_KEYWORD +34 36 ICONST NO_KEYWORD +36 37 ASCII_41 NO_KEYWORD +== 010 +create function continue_test1() returns void as $$ +declare _i integer = 0; _r record; +begin + raise notice '---1---'; + loop + _i := _i + 1; + raise notice '%', _i; + continue when _i < 10; + exit; + end loop; + + raise notice '---2---'; + <> + loop + _i := _i - 1; + loop + raise notice '%', _i; + continue lbl when _i > 0; + exit lbl; + end loop; + end loop; + + raise notice '---3---'; + <> + while _i < 10 loop + _i := _i + 1; + continue the_loop when _i % 2 = 0; + raise notice '%', _i; + end loop; + + raise notice '---4---'; + for _i in 1..10 loop + begin + -- applies to outer loop, not the nested begin block + continue when _i < 5; + raise notice '%', _i; + end; + end loop; + + raise notice '---5---'; + for _r in select * from conttesttbl loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---6---'; + for _r in execute 'select * from conttesttbl' loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---7---'; + <> + for _i in 1..3 loop + continue looplabel when _i = 2; + raise notice '%', _i; + end loop; + + raise notice '---8---'; + _i := 1; + while _i <= 3 loop + raise notice '%', _i; + _i := _i + 1; + continue when _i = 3; + end loop; + + raise notice '---9---'; + for _r in select * from conttesttbl order by v limit 1 loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---10---'; + for _r in execute 'select * from conttesttbl order by v limit 1' loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---11---'; + <> + for _i in 1..2 loop + raise notice 'outer %', _i; + <> + for _j in 1..3 loop + continue outerlooplabel when _j = 2; + raise notice 'inner %', _j; + end loop; + end loop; +end; $$ language plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 30 IDENT NO_KEYWORD +30 31 ASCII_40 NO_KEYWORD +31 32 ASCII_41 NO_KEYWORD +33 40 RETURNS UNRESERVED_KEYWORD +41 45 IDENT NO_KEYWORD +46 48 AS RESERVED_KEYWORD +49 1873 SCONST NO_KEYWORD +1874 1882 LANGUAGE UNRESERVED_KEYWORD +1883 1890 IDENT NO_KEYWORD +== 011 +select continue_test1() +-- +0 6 SELECT RESERVED_KEYWORD +7 21 IDENT NO_KEYWORD +21 22 ASCII_40 NO_KEYWORD +22 23 ASCII_41 NO_KEYWORD +== 012 +-- should fail: CONTINUE is only legal inside a loop +create function continue_error1() returns void as $$ +begin + begin + continue; + end; +end; +$$ language plpgsql +-- +0 52 SQL_COMMENT NO_KEYWORD +53 59 CREATE RESERVED_KEYWORD +60 68 FUNCTION UNRESERVED_KEYWORD +69 84 IDENT NO_KEYWORD +84 85 ASCII_40 NO_KEYWORD +85 86 ASCII_41 NO_KEYWORD +87 94 RETURNS UNRESERVED_KEYWORD +95 99 IDENT NO_KEYWORD +100 102 AS RESERVED_KEYWORD +103 156 SCONST NO_KEYWORD +157 165 LANGUAGE UNRESERVED_KEYWORD +166 173 IDENT NO_KEYWORD +== 013 +-- should fail: unlabeled EXIT is only legal inside a loop +create function exit_error1() returns void as $$ +begin + begin + exit; + end; +end; +$$ language plpgsql +-- +0 58 SQL_COMMENT NO_KEYWORD +59 65 CREATE RESERVED_KEYWORD +66 74 FUNCTION UNRESERVED_KEYWORD +75 86 IDENT NO_KEYWORD +86 87 ASCII_40 NO_KEYWORD +87 88 ASCII_41 NO_KEYWORD +89 96 RETURNS UNRESERVED_KEYWORD +97 101 IDENT NO_KEYWORD +102 104 AS RESERVED_KEYWORD +105 154 SCONST NO_KEYWORD +155 163 LANGUAGE UNRESERVED_KEYWORD +164 171 IDENT NO_KEYWORD +== 014 +-- should fail: no such label +create function continue_error2() returns void as $$ +begin + begin + loop + continue no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +0 29 SQL_COMMENT NO_KEYWORD +30 36 CREATE RESERVED_KEYWORD +37 45 FUNCTION UNRESERVED_KEYWORD +46 61 IDENT NO_KEYWORD +61 62 ASCII_40 NO_KEYWORD +62 63 ASCII_41 NO_KEYWORD +64 71 RETURNS UNRESERVED_KEYWORD +72 76 IDENT NO_KEYWORD +77 79 AS RESERVED_KEYWORD +80 182 SCONST NO_KEYWORD +183 191 LANGUAGE UNRESERVED_KEYWORD +192 199 IDENT NO_KEYWORD +== 015 +-- should fail: no such label +create function exit_error2() returns void as $$ +begin + begin + loop + exit no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +0 29 SQL_COMMENT NO_KEYWORD +30 36 CREATE RESERVED_KEYWORD +37 45 FUNCTION UNRESERVED_KEYWORD +46 57 IDENT NO_KEYWORD +57 58 ASCII_40 NO_KEYWORD +58 59 ASCII_41 NO_KEYWORD +60 67 RETURNS UNRESERVED_KEYWORD +68 72 IDENT NO_KEYWORD +73 75 AS RESERVED_KEYWORD +76 174 SCONST NO_KEYWORD +175 183 LANGUAGE UNRESERVED_KEYWORD +184 191 IDENT NO_KEYWORD +== 016 +-- should fail: CONTINUE can't reference the label of a named block +create function continue_error3() returns void as $$ +begin + <> + begin + loop + continue begin_block1; + end loop; + end; +end; +$$ language plpgsql +-- +0 67 SQL_COMMENT NO_KEYWORD +68 74 CREATE RESERVED_KEYWORD +75 83 FUNCTION UNRESERVED_KEYWORD +84 99 IDENT NO_KEYWORD +99 100 ASCII_40 NO_KEYWORD +100 101 ASCII_41 NO_KEYWORD +102 109 RETURNS UNRESERVED_KEYWORD +110 114 IDENT NO_KEYWORD +115 117 AS RESERVED_KEYWORD +118 240 SCONST NO_KEYWORD +241 249 LANGUAGE UNRESERVED_KEYWORD +250 257 IDENT NO_KEYWORD +== 017 +-- On the other hand, EXIT *can* reference the label of a named block +create function exit_block1() returns void as $$ +begin + <> + begin + loop + exit begin_block1; + raise exception 'should not get here'; + end loop; + end; +end; +$$ language plpgsql +-- +0 69 SQL_COMMENT NO_KEYWORD +70 76 CREATE RESERVED_KEYWORD +77 85 FUNCTION UNRESERVED_KEYWORD +86 97 IDENT NO_KEYWORD +97 98 ASCII_40 NO_KEYWORD +98 99 ASCII_41 NO_KEYWORD +100 107 RETURNS UNRESERVED_KEYWORD +108 112 IDENT NO_KEYWORD +113 115 AS RESERVED_KEYWORD +116 285 SCONST NO_KEYWORD +286 294 LANGUAGE UNRESERVED_KEYWORD +295 302 IDENT NO_KEYWORD +== 018 +select exit_block1() +-- +0 6 SELECT RESERVED_KEYWORD +7 18 IDENT NO_KEYWORD +18 19 ASCII_40 NO_KEYWORD +19 20 ASCII_41 NO_KEYWORD +== 019 +-- verbose end block and end loop +create function end_label1() returns void as $$ +<> +begin + <> + for i in 1 .. 10 loop + raise notice 'i = %', i; + exit flbl1; + end loop flbl1; + <> + for j in 1 .. 10 loop + raise notice 'j = %', j; + exit flbl2; + end loop; +end blbl; +$$ language plpgsql +-- +0 33 SQL_COMMENT NO_KEYWORD +34 40 CREATE RESERVED_KEYWORD +41 49 FUNCTION UNRESERVED_KEYWORD +50 60 IDENT NO_KEYWORD +60 61 ASCII_40 NO_KEYWORD +61 62 ASCII_41 NO_KEYWORD +63 70 RETURNS UNRESERVED_KEYWORD +71 75 IDENT NO_KEYWORD +76 78 AS RESERVED_KEYWORD +79 301 SCONST NO_KEYWORD +302 310 LANGUAGE UNRESERVED_KEYWORD +311 318 IDENT NO_KEYWORD +== 020 +select end_label1() +-- +0 6 SELECT RESERVED_KEYWORD +7 17 IDENT NO_KEYWORD +17 18 ASCII_40 NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 021 +-- should fail: undefined end label +create function end_label2() returns void as $$ +begin + for _i in 1 .. 10 loop + exit; + end loop flbl1; +end; +$$ language plpgsql +-- +0 35 SQL_COMMENT NO_KEYWORD +36 42 CREATE RESERVED_KEYWORD +43 51 FUNCTION UNRESERVED_KEYWORD +52 62 IDENT NO_KEYWORD +62 63 ASCII_40 NO_KEYWORD +63 64 ASCII_41 NO_KEYWORD +65 72 RETURNS UNRESERVED_KEYWORD +73 77 IDENT NO_KEYWORD +78 80 AS RESERVED_KEYWORD +81 150 SCONST NO_KEYWORD +151 159 LANGUAGE UNRESERVED_KEYWORD +160 167 IDENT NO_KEYWORD +== 022 +-- should fail: end label does not match start label +create function end_label3() returns void as $$ +<> +begin + <> + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +0 52 SQL_COMMENT NO_KEYWORD +53 59 CREATE RESERVED_KEYWORD +60 68 FUNCTION UNRESERVED_KEYWORD +69 79 IDENT NO_KEYWORD +79 80 ASCII_40 NO_KEYWORD +80 81 ASCII_41 NO_KEYWORD +82 89 RETURNS UNRESERVED_KEYWORD +90 94 IDENT NO_KEYWORD +95 97 AS RESERVED_KEYWORD +98 207 SCONST NO_KEYWORD +208 216 LANGUAGE UNRESERVED_KEYWORD +217 224 IDENT NO_KEYWORD +== 023 +-- should fail: end label on a block without a start label +create function end_label4() returns void as $$ +<> +begin + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +0 58 SQL_COMMENT NO_KEYWORD +59 65 CREATE RESERVED_KEYWORD +66 74 FUNCTION UNRESERVED_KEYWORD +75 85 IDENT NO_KEYWORD +85 86 ASCII_40 NO_KEYWORD +86 87 ASCII_41 NO_KEYWORD +88 95 RETURNS UNRESERVED_KEYWORD +96 100 IDENT NO_KEYWORD +101 103 AS RESERVED_KEYWORD +104 195 SCONST NO_KEYWORD +196 204 LANGUAGE UNRESERVED_KEYWORD +205 212 IDENT NO_KEYWORD +== 024 +-- unlabeled exit matches no blocks +do $$ +begin +for i in 1..10 loop + <> + begin + begin -- unlabeled block + exit; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; +end loop; +raise notice 'should get here'; +end$$ +-- +0 35 SQL_COMMENT NO_KEYWORD +36 38 DO RESERVED_KEYWORD +39 315 SCONST NO_KEYWORD +== 025 +-- check exit out of an unlabeled block to a labeled one +do $$ +<> +begin + <> + begin + <> + begin + begin -- unlabeled block + exit innerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; + end; + raise notice 'should get here'; +end$$ +-- +0 56 SQL_COMMENT NO_KEYWORD +57 59 DO RESERVED_KEYWORD +60 388 SCONST NO_KEYWORD +== 026 +-- check exit out of outermost block +do $$ +<> +begin + <> + begin + exit outerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; +end$$ +-- +0 36 SQL_COMMENT NO_KEYWORD +37 39 DO RESERVED_KEYWORD +40 208 SCONST NO_KEYWORD +== 027 +-- unlabeled exit does match a while loop +do $$ +begin + <> + while 1 > 0 loop + <> + while 1 > 0 loop + <> + while 1 > 0 loop + exit; + raise notice 'should not get here'; + end loop; + raise notice 'should get here'; + exit outermostwhile; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'should get here, too'; +end$$ +-- +0 41 SQL_COMMENT NO_KEYWORD +42 44 DO RESERVED_KEYWORD +45 466 SCONST NO_KEYWORD +== 028 +-- check exit out of an unlabeled while to a labeled one +do $$ +begin + <> + while 1 > 0 loop + while 1 > 0 loop + exit outerwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'should get here'; +end$$ +-- +0 56 SQL_COMMENT NO_KEYWORD +57 59 DO RESERVED_KEYWORD +60 304 SCONST NO_KEYWORD +== 029 +-- continue to an outer while +do $$ +declare i int := 0; +begin + <> + while i < 2 loop + raise notice 'outermostwhile, i = %', i; + i := i + 1; + <> + while 1 > 0 loop + <> + while 1 > 0 loop + continue outermostwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'out of outermostwhile, i = %', i; +end$$ +-- +0 29 SQL_COMMENT NO_KEYWORD +30 32 DO RESERVED_KEYWORD +33 500 SCONST NO_KEYWORD +== 030 +-- return out of a while +create function return_from_while() returns int language plpgsql as $$ +declare i int := 0; +begin + while i < 10 loop + if i > 2 then + return i; + end if; + i := i + 1; + end loop; + return null; +end$$ +-- +0 24 SQL_COMMENT NO_KEYWORD +25 31 CREATE RESERVED_KEYWORD +32 40 FUNCTION UNRESERVED_KEYWORD +41 58 IDENT NO_KEYWORD +58 59 ASCII_40 NO_KEYWORD +59 60 ASCII_41 NO_KEYWORD +61 68 RETURNS UNRESERVED_KEYWORD +69 72 INT_P COL_NAME_KEYWORD +73 81 LANGUAGE UNRESERVED_KEYWORD +82 89 IDENT NO_KEYWORD +90 92 AS RESERVED_KEYWORD +93 236 SCONST NO_KEYWORD +== 031 +select return_from_while() +-- +0 6 SELECT RESERVED_KEYWORD +7 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 032 +-- using list of scalars in fori and fore stmts +create function for_vect() returns void as $proc$ +<>declare a integer; b varchar; c varchar; r record; +begin + -- fori + for i in 1 .. 3 loop + raise notice '%', i; + end loop; + -- fore with record var + for r in select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs loop + raise notice '% % %', r.aa, r.bb, r.cc; + end loop; + -- fore with single scalar + for a in select gs from generate_series(1,4) gs loop + raise notice '%', a; + end loop; + -- fore with multiple scalars + for a,b,c in select gs, 'BB','CC' from generate_series(1,4) gs loop + raise notice '% % %', a, b, c; + end loop; + -- using qualified names in fors, fore is enabled, disabled only for fori + for lbl.a, lbl.b, lbl.c in execute $$select gs, 'bb','cc' from generate_series(1,4) gs$$ loop + raise notice '% % %', a, b, c; + end loop; +end; +$proc$ language plpgsql +-- +0 47 SQL_COMMENT NO_KEYWORD +48 54 CREATE RESERVED_KEYWORD +55 63 FUNCTION UNRESERVED_KEYWORD +64 72 IDENT NO_KEYWORD +72 73 ASCII_40 NO_KEYWORD +73 74 ASCII_41 NO_KEYWORD +75 82 RETURNS UNRESERVED_KEYWORD +83 87 IDENT NO_KEYWORD +88 90 AS RESERVED_KEYWORD +91 899 SCONST NO_KEYWORD +900 908 LANGUAGE UNRESERVED_KEYWORD +909 916 IDENT NO_KEYWORD +== 033 +select for_vect() +-- +0 6 SELECT RESERVED_KEYWORD +7 15 IDENT NO_KEYWORD +15 16 ASCII_40 NO_KEYWORD +16 17 ASCII_41 NO_KEYWORD +== 034 +-- CASE statement + +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; + b int = 1; +begin + case $1 + when 1 then + return 'one'; + when 2 then + return 'two'; + when 3,4,3+5 then + return 'three, four or eight'; + when a then + return 'ten'; + when a+b, a+b+1 then + return 'eleven, twelve'; + end case; +end; +$$ language plpgsql immutable +-- +0 17 SQL_COMMENT NO_KEYWORD +19 25 CREATE RESERVED_KEYWORD +26 28 OR RESERVED_KEYWORD +29 36 REPLACE UNRESERVED_KEYWORD +37 45 FUNCTION UNRESERVED_KEYWORD +46 55 IDENT NO_KEYWORD +55 56 ASCII_40 NO_KEYWORD +56 62 BIGINT COL_NAME_KEYWORD +62 63 ASCII_41 NO_KEYWORD +64 71 RETURNS UNRESERVED_KEYWORD +72 76 TEXT_P UNRESERVED_KEYWORD +77 79 AS RESERVED_KEYWORD +80 380 SCONST NO_KEYWORD +381 389 LANGUAGE UNRESERVED_KEYWORD +390 397 IDENT NO_KEYWORD +398 407 IMMUTABLE UNRESERVED_KEYWORD +== 035 +select case_test(1) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 036 +select case_test(2) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 037 +select case_test(3) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 038 +select case_test(4) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 039 +select case_test(5) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 040 +-- fails +select case_test(8) +-- +0 8 SQL_COMMENT NO_KEYWORD +9 15 SELECT RESERVED_KEYWORD +16 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ICONST NO_KEYWORD +27 28 ASCII_41 NO_KEYWORD +== 041 +select case_test(10) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 19 ICONST NO_KEYWORD +19 20 ASCII_41 NO_KEYWORD +== 042 +select case_test(11) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 19 ICONST NO_KEYWORD +19 20 ASCII_41 NO_KEYWORD +== 043 +select case_test(12) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 19 ICONST NO_KEYWORD +19 20 ASCII_41 NO_KEYWORD +== 044 +select case_test(13) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 19 ICONST NO_KEYWORD +19 20 ASCII_41 NO_KEYWORD +== 045 +-- fails + +create or replace function catch() returns void as $$ +begin + raise notice '%', case_test(6); +exception + when case_not_found then + raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM; +end +$$ language plpgsql +-- +0 8 SQL_COMMENT NO_KEYWORD +10 16 CREATE RESERVED_KEYWORD +17 19 OR RESERVED_KEYWORD +20 27 REPLACE UNRESERVED_KEYWORD +28 36 FUNCTION UNRESERVED_KEYWORD +37 42 IDENT NO_KEYWORD +42 43 ASCII_40 NO_KEYWORD +43 44 ASCII_41 NO_KEYWORD +45 52 RETURNS UNRESERVED_KEYWORD +53 57 IDENT NO_KEYWORD +58 60 AS RESERVED_KEYWORD +61 212 SCONST NO_KEYWORD +213 221 LANGUAGE UNRESERVED_KEYWORD +222 229 IDENT NO_KEYWORD +== 046 +select catch() +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 14 ASCII_41 NO_KEYWORD +== 047 +-- test the searched variant too, as well as ELSE +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; +begin + case + when $1 = 1 then + return 'one'; + when $1 = a + 2 then + return 'twelve'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +0 49 SQL_COMMENT NO_KEYWORD +50 56 CREATE RESERVED_KEYWORD +57 59 OR RESERVED_KEYWORD +60 67 REPLACE UNRESERVED_KEYWORD +68 76 FUNCTION UNRESERVED_KEYWORD +77 86 IDENT NO_KEYWORD +86 87 ASCII_40 NO_KEYWORD +87 93 BIGINT COL_NAME_KEYWORD +93 94 ASCII_41 NO_KEYWORD +95 102 RETURNS UNRESERVED_KEYWORD +103 107 TEXT_P UNRESERVED_KEYWORD +108 110 AS RESERVED_KEYWORD +111 286 SCONST NO_KEYWORD +287 295 LANGUAGE UNRESERVED_KEYWORD +296 303 IDENT NO_KEYWORD +304 313 IMMUTABLE UNRESERVED_KEYWORD +== 048 +select case_test(1) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 049 +select case_test(2) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_41 NO_KEYWORD +== 050 +select case_test(12) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 19 ICONST NO_KEYWORD +19 20 ASCII_41 NO_KEYWORD +== 051 +select case_test(13) +-- +0 6 SELECT RESERVED_KEYWORD +7 16 IDENT NO_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 19 ICONST NO_KEYWORD +19 20 ASCII_41 NO_KEYWORD +== 052 +-- test line comment between WHEN and THEN +create or replace function case_comment(int) returns text as $$ +begin + case $1 + when 1 -- comment before THEN + then return 'one'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +0 42 SQL_COMMENT NO_KEYWORD +43 49 CREATE RESERVED_KEYWORD +50 52 OR RESERVED_KEYWORD +53 60 REPLACE UNRESERVED_KEYWORD +61 69 FUNCTION UNRESERVED_KEYWORD +70 82 IDENT NO_KEYWORD +82 83 ASCII_40 NO_KEYWORD +83 86 INT_P COL_NAME_KEYWORD +86 87 ASCII_41 NO_KEYWORD +88 95 RETURNS UNRESERVED_KEYWORD +96 100 TEXT_P UNRESERVED_KEYWORD +101 103 AS RESERVED_KEYWORD +104 232 SCONST NO_KEYWORD +233 241 LANGUAGE UNRESERVED_KEYWORD +242 249 IDENT NO_KEYWORD +250 259 IMMUTABLE UNRESERVED_KEYWORD +== 053 +select case_comment(1) +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ICONST NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_copy.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_copy.test b/parser/testdata/scan/plpgsql_regress/plpgsql_copy.test new file mode 100644 index 0000000..2788c56 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_copy.test @@ -0,0 +1,21 @@ +== 001 +-- directory paths are passed to us in environment variables + +-- set up file names to use + +CREATE TABLE copy1 (a int, b float); + +-- COPY TO/FROM not authorized from client. +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 TO stdout; +END; +$$; +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 FROM stdin; +-- +ERROR: "unterminated dollar-quoted string at or near \"$$\nBEGIN\n COPY copy1 FROM stdin;\"" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_domain.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_domain.test b/parser/testdata/scan/plpgsql_regress/plpgsql_domain.test new file mode 100644 index 0000000..9dc2e72 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_domain.test @@ -0,0 +1,1389 @@ +== 001 +|-- +-- Tests for PL/pgSQL's behavior with domain types +|-- + +CREATE DOMAIN booltrue AS bool CHECK (VALUE IS TRUE OR VALUE IS NULL) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 53 SQL_COMMENT NO_KEYWORD +54 56 SQL_COMMENT NO_KEYWORD +58 64 CREATE RESERVED_KEYWORD +65 71 DOMAIN_P UNRESERVED_KEYWORD +72 80 IDENT NO_KEYWORD +81 83 AS RESERVED_KEYWORD +84 88 IDENT NO_KEYWORD +89 94 CHECK RESERVED_KEYWORD +95 96 ASCII_40 NO_KEYWORD +96 101 VALUE_P UNRESERVED_KEYWORD +102 104 IS TYPE_FUNC_NAME_KEYWORD +105 109 TRUE_P RESERVED_KEYWORD +110 112 OR RESERVED_KEYWORD +113 118 VALUE_P UNRESERVED_KEYWORD +119 121 IS TYPE_FUNC_NAME_KEYWORD +122 126 NULL_P RESERVED_KEYWORD +126 127 ASCII_41 NO_KEYWORD +== 002 +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 39 IDENT NO_KEYWORD +39 40 ASCII_40 NO_KEYWORD +40 41 IDENT NO_KEYWORD +42 50 IDENT NO_KEYWORD +50 51 ASCII_44 NO_KEYWORD +52 53 IDENT NO_KEYWORD +54 58 IDENT NO_KEYWORD +58 59 ASCII_41 NO_KEYWORD +60 67 RETURNS UNRESERVED_KEYWORD +68 76 IDENT NO_KEYWORD +77 79 AS RESERVED_KEYWORD +80 105 SCONST NO_KEYWORD +106 114 LANGUAGE UNRESERVED_KEYWORD +115 122 IDENT NO_KEYWORD +== 003 +SELECT * FROM test_argresult_booltrue(true, true) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 37 IDENT NO_KEYWORD +37 38 ASCII_40 NO_KEYWORD +38 42 TRUE_P RESERVED_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 48 TRUE_P RESERVED_KEYWORD +48 49 ASCII_41 NO_KEYWORD +== 004 +SELECT * FROM test_argresult_booltrue(false, true) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 37 IDENT NO_KEYWORD +37 38 ASCII_40 NO_KEYWORD +38 43 FALSE_P RESERVED_KEYWORD +43 44 ASCII_44 NO_KEYWORD +45 49 TRUE_P RESERVED_KEYWORD +49 50 ASCII_41 NO_KEYWORD +== 005 +SELECT * FROM test_argresult_booltrue(true, false) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 37 IDENT NO_KEYWORD +37 38 ASCII_40 NO_KEYWORD +38 42 TRUE_P RESERVED_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 49 FALSE_P RESERVED_KEYWORD +49 50 ASCII_41 NO_KEYWORD +== 006 +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $$ +declare v booltrue := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 43 IDENT NO_KEYWORD +43 44 ASCII_44 NO_KEYWORD +45 46 IDENT NO_KEYWORD +47 51 IDENT NO_KEYWORD +51 52 ASCII_41 NO_KEYWORD +53 60 RETURNS UNRESERVED_KEYWORD +61 69 IDENT NO_KEYWORD +70 72 AS RESERVED_KEYWORD +73 131 SCONST NO_KEYWORD +132 140 LANGUAGE UNRESERVED_KEYWORD +141 148 IDENT NO_KEYWORD +== 007 +SELECT * FROM test_assign_booltrue(true, true) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 39 TRUE_P RESERVED_KEYWORD +39 40 ASCII_44 NO_KEYWORD +41 45 TRUE_P RESERVED_KEYWORD +45 46 ASCII_41 NO_KEYWORD +== 008 +SELECT * FROM test_assign_booltrue(false, true) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 40 FALSE_P RESERVED_KEYWORD +40 41 ASCII_44 NO_KEYWORD +42 46 TRUE_P RESERVED_KEYWORD +46 47 ASCII_41 NO_KEYWORD +== 009 +SELECT * FROM test_assign_booltrue(true, false) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 39 TRUE_P RESERVED_KEYWORD +39 40 ASCII_44 NO_KEYWORD +41 46 FALSE_P RESERVED_KEYWORD +46 47 ASCII_41 NO_KEYWORD +== 010 +CREATE DOMAIN uint2 AS int2 CHECK (VALUE >= 0) +-- +0 6 CREATE RESERVED_KEYWORD +7 13 DOMAIN_P UNRESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +20 22 AS RESERVED_KEYWORD +23 27 IDENT NO_KEYWORD +28 33 CHECK RESERVED_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 40 VALUE_P UNRESERVED_KEYWORD +41 43 GREATER_EQUALS NO_KEYWORD +44 45 ICONST NO_KEYWORD +45 46 ASCII_41 NO_KEYWORD +== 011 +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 44 IDENT NO_KEYWORD +44 45 ASCII_44 NO_KEYWORD +46 47 IDENT NO_KEYWORD +48 51 INT_P COL_NAME_KEYWORD +51 52 ASCII_41 NO_KEYWORD +53 60 RETURNS UNRESERVED_KEYWORD +61 66 IDENT NO_KEYWORD +67 69 AS RESERVED_KEYWORD +70 95 SCONST NO_KEYWORD +96 104 LANGUAGE UNRESERVED_KEYWORD +105 112 IDENT NO_KEYWORD +== 012 +SELECT * FROM test_argresult_uint2(100::uint2, 50) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 38 ICONST NO_KEYWORD +38 40 TYPECAST NO_KEYWORD +40 45 IDENT NO_KEYWORD +45 46 ASCII_44 NO_KEYWORD +47 49 ICONST NO_KEYWORD +49 50 ASCII_41 NO_KEYWORD +== 013 +SELECT * FROM test_argresult_uint2(100::uint2, -50) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 38 ICONST NO_KEYWORD +38 40 TYPECAST NO_KEYWORD +40 45 IDENT NO_KEYWORD +45 46 ASCII_44 NO_KEYWORD +47 48 ASCII_45 NO_KEYWORD +48 50 ICONST NO_KEYWORD +50 51 ASCII_41 NO_KEYWORD +== 014 +SELECT * FROM test_argresult_uint2(null, 1) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 39 NULL_P RESERVED_KEYWORD +39 40 ASCII_44 NO_KEYWORD +41 42 ICONST NO_KEYWORD +42 43 ASCII_41 NO_KEYWORD +== 015 +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $$ +declare v uint2 := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 33 IDENT NO_KEYWORD +33 34 ASCII_40 NO_KEYWORD +34 35 IDENT NO_KEYWORD +36 39 INT_P COL_NAME_KEYWORD +39 40 ASCII_44 NO_KEYWORD +41 42 IDENT NO_KEYWORD +43 46 INT_P COL_NAME_KEYWORD +46 47 ASCII_41 NO_KEYWORD +48 55 RETURNS UNRESERVED_KEYWORD +56 61 IDENT NO_KEYWORD +62 64 AS RESERVED_KEYWORD +65 120 SCONST NO_KEYWORD +121 129 LANGUAGE UNRESERVED_KEYWORD +130 137 IDENT NO_KEYWORD +== 016 +SELECT * FROM test_assign_uint2(100, 50) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 35 ICONST NO_KEYWORD +35 36 ASCII_44 NO_KEYWORD +37 39 ICONST NO_KEYWORD +39 40 ASCII_41 NO_KEYWORD +== 017 +SELECT * FROM test_assign_uint2(100, -50) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 35 ICONST NO_KEYWORD +35 36 ASCII_44 NO_KEYWORD +37 38 ASCII_45 NO_KEYWORD +38 40 ICONST NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +== 018 +SELECT * FROM test_assign_uint2(-100, 50) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 33 ASCII_45 NO_KEYWORD +33 36 ICONST NO_KEYWORD +36 37 ASCII_44 NO_KEYWORD +38 40 ICONST NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +== 019 +SELECT * FROM test_assign_uint2(null, 1) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 36 NULL_P RESERVED_KEYWORD +36 37 ASCII_44 NO_KEYWORD +38 39 ICONST NO_KEYWORD +39 40 ASCII_41 NO_KEYWORD +== 020 +CREATE DOMAIN nnint AS int NOT NULL +-- +0 6 CREATE RESERVED_KEYWORD +7 13 DOMAIN_P UNRESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +20 22 AS RESERVED_KEYWORD +23 26 INT_P COL_NAME_KEYWORD +27 30 NOT RESERVED_KEYWORD +31 35 NULL_P RESERVED_KEYWORD +== 021 +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 44 IDENT NO_KEYWORD +44 45 ASCII_44 NO_KEYWORD +46 47 IDENT NO_KEYWORD +48 51 INT_P COL_NAME_KEYWORD +51 52 ASCII_41 NO_KEYWORD +53 60 RETURNS UNRESERVED_KEYWORD +61 66 IDENT NO_KEYWORD +67 69 AS RESERVED_KEYWORD +70 95 SCONST NO_KEYWORD +96 104 LANGUAGE UNRESERVED_KEYWORD +105 112 IDENT NO_KEYWORD +== 022 +SELECT * FROM test_argresult_nnint(10, 20) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 37 ICONST NO_KEYWORD +37 38 ASCII_44 NO_KEYWORD +39 41 ICONST NO_KEYWORD +41 42 ASCII_41 NO_KEYWORD +== 023 +SELECT * FROM test_argresult_nnint(null, 20) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 39 NULL_P RESERVED_KEYWORD +39 40 ASCII_44 NO_KEYWORD +41 43 ICONST NO_KEYWORD +43 44 ASCII_41 NO_KEYWORD +== 024 +SELECT * FROM test_argresult_nnint(10, null) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 37 ICONST NO_KEYWORD +37 38 ASCII_44 NO_KEYWORD +39 43 NULL_P RESERVED_KEYWORD +43 44 ASCII_41 NO_KEYWORD +== 025 +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $$ +declare v nnint := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 33 IDENT NO_KEYWORD +33 34 ASCII_40 NO_KEYWORD +34 35 IDENT NO_KEYWORD +36 39 INT_P COL_NAME_KEYWORD +39 40 ASCII_44 NO_KEYWORD +41 42 IDENT NO_KEYWORD +43 46 INT_P COL_NAME_KEYWORD +46 47 ASCII_41 NO_KEYWORD +48 55 RETURNS UNRESERVED_KEYWORD +56 61 IDENT NO_KEYWORD +62 64 AS RESERVED_KEYWORD +65 120 SCONST NO_KEYWORD +121 129 LANGUAGE UNRESERVED_KEYWORD +130 137 IDENT NO_KEYWORD +== 026 +SELECT * FROM test_assign_nnint(10, 20) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 34 ICONST NO_KEYWORD +34 35 ASCII_44 NO_KEYWORD +36 38 ICONST NO_KEYWORD +38 39 ASCII_41 NO_KEYWORD +== 027 +SELECT * FROM test_assign_nnint(null, 20) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 36 NULL_P RESERVED_KEYWORD +36 37 ASCII_44 NO_KEYWORD +38 40 ICONST NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +== 028 +SELECT * FROM test_assign_nnint(10, null) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 34 ICONST NO_KEYWORD +34 35 ASCII_44 NO_KEYWORD +36 40 NULL_P RESERVED_KEYWORD +40 41 ASCII_41 NO_KEYWORD +== 029 +|-- +-- Domains over arrays +|-- + +CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 25 SQL_COMMENT NO_KEYWORD +26 28 SQL_COMMENT NO_KEYWORD +30 36 CREATE RESERVED_KEYWORD +37 43 DOMAIN_P UNRESERVED_KEYWORD +44 63 IDENT NO_KEYWORD +64 66 AS RESERVED_KEYWORD +67 74 INTEGER COL_NAME_KEYWORD +74 75 ASCII_91 NO_KEYWORD +75 76 ASCII_93 NO_KEYWORD +77 82 CHECK RESERVED_KEYWORD +83 84 ASCII_40 NO_KEYWORD +84 96 IDENT NO_KEYWORD +96 97 ASCII_40 NO_KEYWORD +97 102 VALUE_P UNRESERVED_KEYWORD +102 103 ASCII_44 NO_KEYWORD +103 104 ICONST NO_KEYWORD +104 105 ASCII_41 NO_KEYWORD +105 106 ASCII_61 NO_KEYWORD +106 107 ICONST NO_KEYWORD +108 111 AND RESERVED_KEYWORD +112 117 VALUE_P UNRESERVED_KEYWORD +117 118 ASCII_91 NO_KEYWORD +118 119 ICONST NO_KEYWORD +119 120 ASCII_93 NO_KEYWORD +121 122 ASCII_60 NO_KEYWORD +123 128 VALUE_P UNRESERVED_KEYWORD +128 129 ASCII_91 NO_KEYWORD +129 130 ICONST NO_KEYWORD +130 131 ASCII_93 NO_KEYWORD +131 132 ASCII_41 NO_KEYWORD +== 030 +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) + RETURNS ordered_pair_domain AS $$ +begin +return x; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 43 IDENT NO_KEYWORD +43 44 ASCII_40 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 65 IDENT NO_KEYWORD +65 66 ASCII_41 NO_KEYWORD +69 76 RETURNS UNRESERVED_KEYWORD +77 96 IDENT NO_KEYWORD +97 99 AS RESERVED_KEYWORD +100 125 SCONST NO_KEYWORD +126 134 LANGUAGE UNRESERVED_KEYWORD +135 142 IDENT NO_KEYWORD +== 031 +SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 41 IDENT NO_KEYWORD +41 42 ASCII_40 NO_KEYWORD +42 47 ARRAY RESERVED_KEYWORD +47 48 ASCII_91 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +51 54 ICONST NO_KEYWORD +54 55 ASCII_93 NO_KEYWORD +55 57 TYPECAST NO_KEYWORD +57 76 IDENT NO_KEYWORD +76 77 ASCII_41 NO_KEYWORD +== 032 +SELECT * FROM test_argresult_array_domain(NULL::ordered_pair_domain) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 41 IDENT NO_KEYWORD +41 42 ASCII_40 NO_KEYWORD +42 46 NULL_P RESERVED_KEYWORD +46 48 TYPECAST NO_KEYWORD +48 67 IDENT NO_KEYWORD +67 68 ASCII_41 NO_KEYWORD +== 033 +CREATE FUNCTION test_argresult_array_domain_check_violation() + RETURNS ordered_pair_domain AS $$ +begin +return array[2,1]; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 59 IDENT NO_KEYWORD +59 60 ASCII_40 NO_KEYWORD +60 61 ASCII_41 NO_KEYWORD +64 71 RETURNS UNRESERVED_KEYWORD +72 91 IDENT NO_KEYWORD +92 94 AS RESERVED_KEYWORD +95 129 SCONST NO_KEYWORD +130 138 LANGUAGE UNRESERVED_KEYWORD +139 146 IDENT NO_KEYWORD +== 034 +SELECT * FROM test_argresult_array_domain_check_violation() +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 57 IDENT NO_KEYWORD +57 58 ASCII_40 NO_KEYWORD +58 59 ASCII_41 NO_KEYWORD +== 035 +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $$ +declare v ordered_pair_domain := array[x, y]; +begin +v[2] := z; +return v; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 47 IDENT NO_KEYWORD +47 48 ASCII_40 NO_KEYWORD +48 49 IDENT NO_KEYWORD +50 53 INT_P COL_NAME_KEYWORD +53 54 ASCII_44 NO_KEYWORD +55 56 IDENT NO_KEYWORD +57 60 INT_P COL_NAME_KEYWORD +60 61 ASCII_44 NO_KEYWORD +62 63 IDENT NO_KEYWORD +64 67 INT_P COL_NAME_KEYWORD +67 68 ASCII_41 NO_KEYWORD +69 76 RETURNS UNRESERVED_KEYWORD +77 96 IDENT NO_KEYWORD +97 99 AS RESERVED_KEYWORD +100 182 SCONST NO_KEYWORD +183 191 LANGUAGE UNRESERVED_KEYWORD +192 199 IDENT NO_KEYWORD +== 036 +SELECT * FROM test_assign_ordered_pair_domain(1,2,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 45 IDENT NO_KEYWORD +45 46 ASCII_40 NO_KEYWORD +46 47 ICONST NO_KEYWORD +47 48 ASCII_44 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +50 51 ICONST NO_KEYWORD +51 52 ASCII_41 NO_KEYWORD +== 037 +SELECT * FROM test_assign_ordered_pair_domain(1,2,0) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 45 IDENT NO_KEYWORD +45 46 ASCII_40 NO_KEYWORD +46 47 ICONST NO_KEYWORD +47 48 ASCII_44 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +50 51 ICONST NO_KEYWORD +51 52 ASCII_41 NO_KEYWORD +== 038 +SELECT * FROM test_assign_ordered_pair_domain(2,1,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 45 IDENT NO_KEYWORD +45 46 ASCII_40 NO_KEYWORD +46 47 ICONST NO_KEYWORD +47 48 ASCII_44 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +50 51 ICONST NO_KEYWORD +51 52 ASCII_41 NO_KEYWORD +== 039 +|-- +-- Arrays of domains +|-- + +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +0 2 SQL_COMMENT NO_KEYWORD +3 23 SQL_COMMENT NO_KEYWORD +24 26 SQL_COMMENT NO_KEYWORD +28 34 CREATE RESERVED_KEYWORD +35 43 FUNCTION UNRESERVED_KEYWORD +44 65 IDENT NO_KEYWORD +65 66 ASCII_40 NO_KEYWORD +66 67 IDENT NO_KEYWORD +68 73 IDENT NO_KEYWORD +73 74 ASCII_91 NO_KEYWORD +74 75 ASCII_93 NO_KEYWORD +75 76 ASCII_41 NO_KEYWORD +77 84 RETURNS UNRESERVED_KEYWORD +85 90 IDENT NO_KEYWORD +91 93 AS RESERVED_KEYWORD +94 122 SCONST NO_KEYWORD +123 131 LANGUAGE UNRESERVED_KEYWORD +132 139 IDENT NO_KEYWORD +== 040 +select test_read_uint2_array(array[1::uint2]) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 34 ARRAY RESERVED_KEYWORD +34 35 ASCII_91 NO_KEYWORD +35 36 ICONST NO_KEYWORD +36 38 TYPECAST NO_KEYWORD +38 43 IDENT NO_KEYWORD +43 44 ASCII_93 NO_KEYWORD +44 45 ASCII_41 NO_KEYWORD +== 041 +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $$ +begin +return array[x, x]; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 38 IDENT NO_KEYWORD +38 39 ASCII_40 NO_KEYWORD +39 40 IDENT NO_KEYWORD +41 45 IDENT NO_KEYWORD +45 46 ASCII_41 NO_KEYWORD +47 54 RETURNS UNRESERVED_KEYWORD +55 60 IDENT NO_KEYWORD +60 61 ASCII_91 NO_KEYWORD +61 62 ASCII_93 NO_KEYWORD +63 65 AS RESERVED_KEYWORD +66 101 SCONST NO_KEYWORD +102 110 LANGUAGE UNRESERVED_KEYWORD +111 118 IDENT NO_KEYWORD +== 042 +select test_build_uint2_array(1::int2) +-- +0 6 SELECT RESERVED_KEYWORD +7 29 IDENT NO_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 31 ICONST NO_KEYWORD +31 33 TYPECAST NO_KEYWORD +33 37 IDENT NO_KEYWORD +37 38 ASCII_41 NO_KEYWORD +== 043 +select test_build_uint2_array(-1::int2) +-- +0 6 SELECT RESERVED_KEYWORD +7 29 IDENT NO_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 31 ASCII_45 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 34 TYPECAST NO_KEYWORD +34 38 IDENT NO_KEYWORD +38 39 ASCII_41 NO_KEYWORD +== 044 +-- fail + +CREATE FUNCTION test_argresult_domain_array(x integer[]) + RETURNS ordered_pair_domain[] AS $$ +begin +return array[x::ordered_pair_domain, x::ordered_pair_domain]; +end +$$ LANGUAGE plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 52 IDENT NO_KEYWORD +52 53 ASCII_40 NO_KEYWORD +53 54 IDENT NO_KEYWORD +55 62 INTEGER COL_NAME_KEYWORD +62 63 ASCII_91 NO_KEYWORD +63 64 ASCII_93 NO_KEYWORD +64 65 ASCII_41 NO_KEYWORD +68 75 RETURNS UNRESERVED_KEYWORD +76 95 IDENT NO_KEYWORD +95 96 ASCII_91 NO_KEYWORD +96 97 ASCII_93 NO_KEYWORD +98 100 AS RESERVED_KEYWORD +101 178 SCONST NO_KEYWORD +179 187 LANGUAGE UNRESERVED_KEYWORD +188 195 IDENT NO_KEYWORD +== 045 +select test_argresult_domain_array(array[2,4]) +-- +0 6 SELECT RESERVED_KEYWORD +7 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 40 ARRAY RESERVED_KEYWORD +40 41 ASCII_91 NO_KEYWORD +41 42 ICONST NO_KEYWORD +42 43 ASCII_44 NO_KEYWORD +43 44 ICONST NO_KEYWORD +44 45 ASCII_93 NO_KEYWORD +45 46 ASCII_41 NO_KEYWORD +== 046 +select test_argresult_domain_array(array[4,2]) +-- +0 6 SELECT RESERVED_KEYWORD +7 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 40 ARRAY RESERVED_KEYWORD +40 41 ASCII_91 NO_KEYWORD +41 42 ICONST NO_KEYWORD +42 43 ASCII_44 NO_KEYWORD +43 44 ICONST NO_KEYWORD +44 45 ASCII_93 NO_KEYWORD +45 46 ASCII_41 NO_KEYWORD +== 047 +-- fail + +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) + RETURNS integer AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 53 IDENT NO_KEYWORD +53 54 ASCII_40 NO_KEYWORD +54 55 IDENT NO_KEYWORD +56 75 IDENT NO_KEYWORD +75 76 ASCII_41 NO_KEYWORD +79 86 RETURNS UNRESERVED_KEYWORD +87 94 INTEGER COL_NAME_KEYWORD +95 97 AS RESERVED_KEYWORD +98 126 SCONST NO_KEYWORD +127 135 LANGUAGE UNRESERVED_KEYWORD +136 143 IDENT NO_KEYWORD +== 048 +select test_argresult_domain_array2(array[2,4]) +-- +0 6 SELECT RESERVED_KEYWORD +7 35 IDENT NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 41 ARRAY RESERVED_KEYWORD +41 42 ASCII_91 NO_KEYWORD +42 43 ICONST NO_KEYWORD +43 44 ASCII_44 NO_KEYWORD +44 45 ICONST NO_KEYWORD +45 46 ASCII_93 NO_KEYWORD +46 47 ASCII_41 NO_KEYWORD +== 049 +select test_argresult_domain_array2(array[4,2]) +-- +0 6 SELECT RESERVED_KEYWORD +7 35 IDENT NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 41 ARRAY RESERVED_KEYWORD +41 42 ASCII_91 NO_KEYWORD +42 43 ICONST NO_KEYWORD +43 44 ASCII_44 NO_KEYWORD +44 45 ICONST NO_KEYWORD +45 46 ASCII_93 NO_KEYWORD +46 47 ASCII_41 NO_KEYWORD +== 050 +-- fail + +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) + RETURNS ordered_pair_domain AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 58 IDENT NO_KEYWORD +58 59 ASCII_40 NO_KEYWORD +59 60 IDENT NO_KEYWORD +61 80 IDENT NO_KEYWORD +80 81 ASCII_91 NO_KEYWORD +81 82 ASCII_93 NO_KEYWORD +82 83 ASCII_41 NO_KEYWORD +86 93 RETURNS UNRESERVED_KEYWORD +94 113 IDENT NO_KEYWORD +114 116 AS RESERVED_KEYWORD +117 145 SCONST NO_KEYWORD +146 154 LANGUAGE UNRESERVED_KEYWORD +155 162 IDENT NO_KEYWORD +== 051 +select test_argresult_array_domain_array(array[array[2,4]::ordered_pair_domain]) +-- +0 6 SELECT RESERVED_KEYWORD +7 40 IDENT NO_KEYWORD +40 41 ASCII_40 NO_KEYWORD +41 46 ARRAY RESERVED_KEYWORD +46 47 ASCII_91 NO_KEYWORD +47 52 ARRAY RESERVED_KEYWORD +52 53 ASCII_91 NO_KEYWORD +53 54 ICONST NO_KEYWORD +54 55 ASCII_44 NO_KEYWORD +55 56 ICONST NO_KEYWORD +56 57 ASCII_93 NO_KEYWORD +57 59 TYPECAST NO_KEYWORD +59 78 IDENT NO_KEYWORD +78 79 ASCII_93 NO_KEYWORD +79 80 ASCII_41 NO_KEYWORD +== 052 +|-- +-- Domains within composite +|-- + +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 30 SQL_COMMENT NO_KEYWORD +31 33 SQL_COMMENT NO_KEYWORD +35 41 CREATE RESERVED_KEYWORD +42 46 TYPE_P UNRESERVED_KEYWORD +47 62 IDENT NO_KEYWORD +63 65 AS RESERVED_KEYWORD +66 67 ASCII_40 NO_KEYWORD +67 69 IDENT NO_KEYWORD +70 73 INT_P COL_NAME_KEYWORD +73 74 ASCII_44 NO_KEYWORD +75 77 IDENT NO_KEYWORD +78 83 IDENT NO_KEYWORD +83 84 ASCII_41 NO_KEYWORD +== 053 +CREATE FUNCTION test_result_nnint_container(x int, y int) + RETURNS nnint_container AS $$ +begin +return row(x, y)::nnint_container; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 43 IDENT NO_KEYWORD +43 44 ASCII_40 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_44 NO_KEYWORD +51 52 IDENT NO_KEYWORD +53 56 INT_P COL_NAME_KEYWORD +56 57 ASCII_41 NO_KEYWORD +60 67 RETURNS UNRESERVED_KEYWORD +68 83 IDENT NO_KEYWORD +84 86 AS RESERVED_KEYWORD +87 137 SCONST NO_KEYWORD +138 146 LANGUAGE UNRESERVED_KEYWORD +147 154 IDENT NO_KEYWORD +== 054 +SELECT test_result_nnint_container(null, 3) +-- +0 6 SELECT RESERVED_KEYWORD +7 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 39 NULL_P RESERVED_KEYWORD +39 40 ASCII_44 NO_KEYWORD +41 42 ICONST NO_KEYWORD +42 43 ASCII_41 NO_KEYWORD +== 055 +SELECT test_result_nnint_container(3, null) +-- +0 6 SELECT RESERVED_KEYWORD +7 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 ICONST NO_KEYWORD +36 37 ASCII_44 NO_KEYWORD +38 42 NULL_P RESERVED_KEYWORD +42 43 ASCII_41 NO_KEYWORD +== 056 +-- fail + +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container := row(x, y); +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 52 IDENT NO_KEYWORD +52 53 ASCII_40 NO_KEYWORD +53 54 IDENT NO_KEYWORD +55 58 INT_P COL_NAME_KEYWORD +58 59 ASCII_44 NO_KEYWORD +60 61 IDENT NO_KEYWORD +62 65 INT_P COL_NAME_KEYWORD +65 66 ASCII_44 NO_KEYWORD +67 68 IDENT NO_KEYWORD +69 72 INT_P COL_NAME_KEYWORD +72 73 ASCII_41 NO_KEYWORD +76 83 RETURNS UNRESERVED_KEYWORD +84 99 IDENT NO_KEYWORD +100 102 AS RESERVED_KEYWORD +103 179 SCONST NO_KEYWORD +180 188 LANGUAGE UNRESERVED_KEYWORD +189 196 IDENT NO_KEYWORD +== 057 +SELECT * FROM test_assign_nnint_container(1,2,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 41 IDENT NO_KEYWORD +41 42 ASCII_40 NO_KEYWORD +42 43 ICONST NO_KEYWORD +43 44 ASCII_44 NO_KEYWORD +44 45 ICONST NO_KEYWORD +45 46 ASCII_44 NO_KEYWORD +46 47 ICONST NO_KEYWORD +47 48 ASCII_41 NO_KEYWORD +== 058 +SELECT * FROM test_assign_nnint_container(1,2,null) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 41 IDENT NO_KEYWORD +41 42 ASCII_40 NO_KEYWORD +42 43 ICONST NO_KEYWORD +43 44 ASCII_44 NO_KEYWORD +44 45 ICONST NO_KEYWORD +45 46 ASCII_44 NO_KEYWORD +46 50 NULL_P RESERVED_KEYWORD +50 51 ASCII_41 NO_KEYWORD +== 059 +SELECT * FROM test_assign_nnint_container(1,null,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 41 IDENT NO_KEYWORD +41 42 ASCII_40 NO_KEYWORD +42 43 ICONST NO_KEYWORD +43 44 ASCII_44 NO_KEYWORD +44 48 NULL_P RESERVED_KEYWORD +48 49 ASCII_44 NO_KEYWORD +49 50 ICONST NO_KEYWORD +50 51 ASCII_41 NO_KEYWORD +== 060 +-- Since core system allows this: +SELECT null::nnint_container +-- +0 33 SQL_COMMENT NO_KEYWORD +34 40 SELECT RESERVED_KEYWORD +41 45 NULL_P RESERVED_KEYWORD +45 47 TYPECAST NO_KEYWORD +47 62 IDENT NO_KEYWORD +== 061 +-- so should PL/PgSQL + +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container; +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +0 21 SQL_COMMENT NO_KEYWORD +23 29 CREATE RESERVED_KEYWORD +30 38 FUNCTION UNRESERVED_KEYWORD +39 67 IDENT NO_KEYWORD +67 68 ASCII_40 NO_KEYWORD +68 69 IDENT NO_KEYWORD +70 73 INT_P COL_NAME_KEYWORD +73 74 ASCII_44 NO_KEYWORD +75 76 IDENT NO_KEYWORD +77 80 INT_P COL_NAME_KEYWORD +80 81 ASCII_44 NO_KEYWORD +82 83 IDENT NO_KEYWORD +84 87 INT_P COL_NAME_KEYWORD +87 88 ASCII_41 NO_KEYWORD +91 98 RETURNS UNRESERVED_KEYWORD +99 114 IDENT NO_KEYWORD +115 117 AS RESERVED_KEYWORD +118 181 SCONST NO_KEYWORD +182 190 LANGUAGE UNRESERVED_KEYWORD +191 198 IDENT NO_KEYWORD +== 062 +SELECT * FROM test_assign_nnint_container2(1,2,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 42 IDENT NO_KEYWORD +42 43 ASCII_40 NO_KEYWORD +43 44 ICONST NO_KEYWORD +44 45 ASCII_44 NO_KEYWORD +45 46 ICONST NO_KEYWORD +46 47 ASCII_44 NO_KEYWORD +47 48 ICONST NO_KEYWORD +48 49 ASCII_41 NO_KEYWORD +== 063 +SELECT * FROM test_assign_nnint_container2(1,2,null) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 42 IDENT NO_KEYWORD +42 43 ASCII_40 NO_KEYWORD +43 44 ICONST NO_KEYWORD +44 45 ASCII_44 NO_KEYWORD +45 46 ICONST NO_KEYWORD +46 47 ASCII_44 NO_KEYWORD +47 51 NULL_P RESERVED_KEYWORD +51 52 ASCII_41 NO_KEYWORD +== 064 +|-- +-- Domains of composite +|-- + +CREATE TYPE named_pair AS ( + i integer, + j integer +) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 26 SQL_COMMENT NO_KEYWORD +27 29 SQL_COMMENT NO_KEYWORD +31 37 CREATE RESERVED_KEYWORD +38 42 TYPE_P UNRESERVED_KEYWORD +43 53 IDENT NO_KEYWORD +54 56 AS RESERVED_KEYWORD +57 58 ASCII_40 NO_KEYWORD +63 64 IDENT NO_KEYWORD +65 72 INTEGER COL_NAME_KEYWORD +72 73 ASCII_44 NO_KEYWORD +78 79 IDENT NO_KEYWORD +80 87 INTEGER COL_NAME_KEYWORD +88 89 ASCII_41 NO_KEYWORD +== 065 +CREATE DOMAIN ordered_named_pair AS named_pair CHECK((VALUE).i <= (VALUE).j) +-- +0 6 CREATE RESERVED_KEYWORD +7 13 DOMAIN_P UNRESERVED_KEYWORD +14 32 IDENT NO_KEYWORD +33 35 AS RESERVED_KEYWORD +36 46 IDENT NO_KEYWORD +47 52 CHECK RESERVED_KEYWORD +52 53 ASCII_40 NO_KEYWORD +53 54 ASCII_40 NO_KEYWORD +54 59 VALUE_P UNRESERVED_KEYWORD +59 60 ASCII_41 NO_KEYWORD +60 61 ASCII_46 NO_KEYWORD +61 62 IDENT NO_KEYWORD +63 65 LESS_EQUALS NO_KEYWORD +66 67 ASCII_40 NO_KEYWORD +67 72 VALUE_P UNRESERVED_KEYWORD +72 73 ASCII_41 NO_KEYWORD +73 74 ASCII_46 NO_KEYWORD +74 75 IDENT NO_KEYWORD +75 76 ASCII_41 NO_KEYWORD +== 066 +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS integer AS $$ +begin +return p.i + p.j; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 39 IDENT NO_KEYWORD +39 40 ASCII_40 NO_KEYWORD +40 41 IDENT NO_KEYWORD +42 60 IDENT NO_KEYWORD +60 61 ASCII_41 NO_KEYWORD +62 69 RETURNS UNRESERVED_KEYWORD +70 77 INTEGER COL_NAME_KEYWORD +78 80 AS RESERVED_KEYWORD +81 114 SCONST NO_KEYWORD +115 123 LANGUAGE UNRESERVED_KEYWORD +124 131 IDENT NO_KEYWORD +== 067 +SELECT read_ordered_named_pair(row(1, 2)) +-- +0 6 SELECT RESERVED_KEYWORD +7 30 IDENT NO_KEYWORD +30 31 ASCII_40 NO_KEYWORD +31 34 ROW COL_NAME_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 ICONST NO_KEYWORD +36 37 ASCII_44 NO_KEYWORD +38 39 ICONST NO_KEYWORD +39 40 ASCII_41 NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +== 068 +SELECT read_ordered_named_pair(row(2, 1)) +-- +0 6 SELECT RESERVED_KEYWORD +7 30 IDENT NO_KEYWORD +30 31 ASCII_40 NO_KEYWORD +31 34 ROW COL_NAME_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 ICONST NO_KEYWORD +36 37 ASCII_44 NO_KEYWORD +38 39 ICONST NO_KEYWORD +39 40 ASCII_41 NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +== 069 +-- fail + +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $$ +begin +return row(i, j); +end +$$ LANGUAGE plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 49 IDENT NO_KEYWORD +49 50 ASCII_40 NO_KEYWORD +50 51 IDENT NO_KEYWORD +52 55 INT_P COL_NAME_KEYWORD +55 56 ASCII_44 NO_KEYWORD +57 58 IDENT NO_KEYWORD +59 62 INT_P COL_NAME_KEYWORD +62 63 ASCII_41 NO_KEYWORD +64 71 RETURNS UNRESERVED_KEYWORD +72 90 IDENT NO_KEYWORD +91 93 AS RESERVED_KEYWORD +94 127 SCONST NO_KEYWORD +128 136 LANGUAGE UNRESERVED_KEYWORD +137 144 IDENT NO_KEYWORD +== 070 +SELECT build_ordered_named_pair(1,2) +-- +0 6 SELECT RESERVED_KEYWORD +7 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 33 ICONST NO_KEYWORD +33 34 ASCII_44 NO_KEYWORD +34 35 ICONST NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +== 071 +SELECT build_ordered_named_pair(2,1) +-- +0 6 SELECT RESERVED_KEYWORD +7 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 33 ICONST NO_KEYWORD +33 34 ASCII_44 NO_KEYWORD +34 35 ICONST NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +== 072 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) + RETURNS ordered_named_pair AS $$ +declare v ordered_named_pair := row(x, y); +begin +v.j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 55 IDENT NO_KEYWORD +55 56 ASCII_40 NO_KEYWORD +56 57 IDENT NO_KEYWORD +58 61 INT_P COL_NAME_KEYWORD +61 62 ASCII_44 NO_KEYWORD +63 64 IDENT NO_KEYWORD +65 68 INT_P COL_NAME_KEYWORD +68 69 ASCII_44 NO_KEYWORD +70 71 IDENT NO_KEYWORD +72 75 INT_P COL_NAME_KEYWORD +75 76 ASCII_41 NO_KEYWORD +79 86 RETURNS UNRESERVED_KEYWORD +87 105 IDENT NO_KEYWORD +106 108 AS RESERVED_KEYWORD +109 187 SCONST NO_KEYWORD +188 196 LANGUAGE UNRESERVED_KEYWORD +197 204 IDENT NO_KEYWORD +== 073 +SELECT * FROM test_assign_ordered_named_pair(1,2,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 ICONST NO_KEYWORD +46 47 ASCII_44 NO_KEYWORD +47 48 ICONST NO_KEYWORD +48 49 ASCII_44 NO_KEYWORD +49 50 ICONST NO_KEYWORD +50 51 ASCII_41 NO_KEYWORD +== 074 +SELECT * FROM test_assign_ordered_named_pair(1,2,0) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 ICONST NO_KEYWORD +46 47 ASCII_44 NO_KEYWORD +47 48 ICONST NO_KEYWORD +48 49 ASCII_44 NO_KEYWORD +49 50 ICONST NO_KEYWORD +50 51 ASCII_41 NO_KEYWORD +== 075 +SELECT * FROM test_assign_ordered_named_pair(2,1,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 ICONST NO_KEYWORD +46 47 ASCII_44 NO_KEYWORD +47 48 ICONST NO_KEYWORD +48 49 ASCII_44 NO_KEYWORD +49 50 ICONST NO_KEYWORD +50 51 ASCII_41 NO_KEYWORD +== 076 +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $$ +begin +return array[row(i, j), row(i, j+1)]; +end +$$ LANGUAGE plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 41 IDENT NO_KEYWORD +41 42 ASCII_40 NO_KEYWORD +42 43 IDENT NO_KEYWORD +44 47 INT_P COL_NAME_KEYWORD +47 48 ASCII_44 NO_KEYWORD +49 50 IDENT NO_KEYWORD +51 54 INT_P COL_NAME_KEYWORD +54 55 ASCII_41 NO_KEYWORD +56 63 RETURNS UNRESERVED_KEYWORD +64 82 IDENT NO_KEYWORD +82 83 ASCII_91 NO_KEYWORD +83 84 ASCII_93 NO_KEYWORD +85 87 AS RESERVED_KEYWORD +88 141 SCONST NO_KEYWORD +142 150 LANGUAGE UNRESERVED_KEYWORD +151 158 IDENT NO_KEYWORD +== 077 +SELECT build_ordered_named_pairs(1,2) +-- +0 6 SELECT RESERVED_KEYWORD +7 32 IDENT NO_KEYWORD +32 33 ASCII_40 NO_KEYWORD +33 34 ICONST NO_KEYWORD +34 35 ASCII_44 NO_KEYWORD +35 36 ICONST NO_KEYWORD +36 37 ASCII_41 NO_KEYWORD +== 078 +SELECT build_ordered_named_pairs(2,1) +-- +0 6 SELECT RESERVED_KEYWORD +7 32 IDENT NO_KEYWORD +32 33 ASCII_40 NO_KEYWORD +33 34 ICONST NO_KEYWORD +34 35 ASCII_44 NO_KEYWORD +35 36 ICONST NO_KEYWORD +36 37 ASCII_41 NO_KEYWORD +== 079 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) + RETURNS ordered_named_pair[] AS $$ +declare v ordered_named_pair[] := array[row(x, y)]; +begin +-- ideally this would work, but it doesn't yet: +-- v[1].j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 56 IDENT NO_KEYWORD +56 57 ASCII_40 NO_KEYWORD +57 58 IDENT NO_KEYWORD +59 62 INT_P COL_NAME_KEYWORD +62 63 ASCII_44 NO_KEYWORD +64 65 IDENT NO_KEYWORD +66 69 INT_P COL_NAME_KEYWORD +69 70 ASCII_44 NO_KEYWORD +71 72 IDENT NO_KEYWORD +73 76 INT_P COL_NAME_KEYWORD +76 77 ASCII_41 NO_KEYWORD +80 87 RETURNS UNRESERVED_KEYWORD +88 106 IDENT NO_KEYWORD +106 107 ASCII_91 NO_KEYWORD +107 108 ASCII_93 NO_KEYWORD +109 111 AS RESERVED_KEYWORD +112 253 SCONST NO_KEYWORD +254 262 LANGUAGE UNRESERVED_KEYWORD +263 270 IDENT NO_KEYWORD +== 080 +SELECT * FROM test_assign_ordered_named_pairs(1,2,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 45 IDENT NO_KEYWORD +45 46 ASCII_40 NO_KEYWORD +46 47 ICONST NO_KEYWORD +47 48 ASCII_44 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +50 51 ICONST NO_KEYWORD +51 52 ASCII_41 NO_KEYWORD +== 081 +SELECT * FROM test_assign_ordered_named_pairs(2,1,3) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 45 IDENT NO_KEYWORD +45 46 ASCII_40 NO_KEYWORD +46 47 ICONST NO_KEYWORD +47 48 ASCII_44 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +50 51 ICONST NO_KEYWORD +51 52 ASCII_41 NO_KEYWORD +== 082 +SELECT * FROM test_assign_ordered_named_pairs(1,2,0) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 45 IDENT NO_KEYWORD +45 46 ASCII_40 NO_KEYWORD +46 47 ICONST NO_KEYWORD +47 48 ASCII_44 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +50 51 ICONST NO_KEYWORD +51 52 ASCII_41 NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_misc.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_misc.test b/parser/testdata/scan/plpgsql_regress/plpgsql_misc.test new file mode 100644 index 0000000..95622dd --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_misc.test @@ -0,0 +1,103 @@ +== 001 +|-- +-- Miscellaneous topics +|-- + +-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE +do +$$ + declare procedure int; -- check we still recognize non-keywords as vars + begin + create function test1() returns int + begin atomic + select 2 + 2; + end; + create or replace procedure test2(x int) + begin atomic + select x + 2; + end; + end +$$ +-- +0 2 SQL_COMMENT NO_KEYWORD +3 26 SQL_COMMENT NO_KEYWORD +27 29 SQL_COMMENT NO_KEYWORD +31 94 SQL_COMMENT NO_KEYWORD +95 97 DO RESERVED_KEYWORD +98 365 SCONST NO_KEYWORD +== 002 +-- Test %TYPE and %ROWTYPE error cases +create table misc_table(f1 int) +-- +0 38 SQL_COMMENT NO_KEYWORD +39 45 CREATE RESERVED_KEYWORD +46 51 TABLE RESERVED_KEYWORD +52 62 IDENT NO_KEYWORD +62 63 ASCII_40 NO_KEYWORD +63 65 IDENT NO_KEYWORD +66 69 INT_P COL_NAME_KEYWORD +69 70 ASCII_41 NO_KEYWORD +== 003 +do $$ declare x foo%type; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 38 SCONST NO_KEYWORD +== 004 +do $$ declare x notice%type; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 41 SCONST NO_KEYWORD +== 005 +-- covers unreserved-keyword case +do $$ declare x foo.bar%type; begin end $$ +-- +0 33 SQL_COMMENT NO_KEYWORD +34 36 DO RESERVED_KEYWORD +37 76 SCONST NO_KEYWORD +== 006 +do $$ declare x foo.bar.baz%type; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 46 SCONST NO_KEYWORD +== 007 +do $$ declare x public.foo.bar%type; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 49 SCONST NO_KEYWORD +== 008 +do $$ declare x public.misc_table.zed%type; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 56 SCONST NO_KEYWORD +== 009 +do $$ declare x foo%rowtype; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 41 SCONST NO_KEYWORD +== 010 +do $$ declare x notice%rowtype; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 44 SCONST NO_KEYWORD +== 011 +-- covers unreserved-keyword case +do $$ declare x foo.bar%rowtype; begin end $$ +-- +0 33 SQL_COMMENT NO_KEYWORD +34 36 DO RESERVED_KEYWORD +37 79 SCONST NO_KEYWORD +== 012 +do $$ declare x foo.bar.baz%rowtype; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 49 SCONST NO_KEYWORD +== 013 +do $$ declare x public.foo%rowtype; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 48 SCONST NO_KEYWORD +== 014 +do $$ declare x public.misc_table%rowtype; begin end $$ +-- +0 2 DO RESERVED_KEYWORD +3 55 SCONST NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_record.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_record.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_record.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_record.test b/parser/testdata/scan/plpgsql_regress/plpgsql_record.test new file mode 100644 index 0000000..76c5d2cc --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_record.test @@ -0,0 +1,2259 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of composite (record) variables +|-- + +create type two_int4s as (f1 int4, f2 int4) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 65 SQL_COMMENT NO_KEYWORD +66 68 SQL_COMMENT NO_KEYWORD +70 76 CREATE RESERVED_KEYWORD +77 81 TYPE_P UNRESERVED_KEYWORD +82 91 IDENT NO_KEYWORD +92 94 AS RESERVED_KEYWORD +95 96 ASCII_40 NO_KEYWORD +96 98 IDENT NO_KEYWORD +99 103 IDENT NO_KEYWORD +103 104 ASCII_44 NO_KEYWORD +105 107 IDENT NO_KEYWORD +108 112 IDENT NO_KEYWORD +112 113 ASCII_41 NO_KEYWORD +== 002 +create type more_int4s as (f0 text, f1 int4, f2 int4) +-- +0 6 CREATE RESERVED_KEYWORD +7 11 TYPE_P UNRESERVED_KEYWORD +12 22 IDENT NO_KEYWORD +23 25 AS RESERVED_KEYWORD +26 27 ASCII_40 NO_KEYWORD +27 29 IDENT NO_KEYWORD +30 34 TEXT_P UNRESERVED_KEYWORD +34 35 ASCII_44 NO_KEYWORD +36 38 IDENT NO_KEYWORD +39 43 IDENT NO_KEYWORD +43 44 ASCII_44 NO_KEYWORD +45 47 IDENT NO_KEYWORD +48 52 IDENT NO_KEYWORD +52 53 ASCII_41 NO_KEYWORD +== 003 +create type two_int8s as (q1 int8, q2 int8) +-- +0 6 CREATE RESERVED_KEYWORD +7 11 TYPE_P UNRESERVED_KEYWORD +12 21 IDENT NO_KEYWORD +22 24 AS RESERVED_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 28 IDENT NO_KEYWORD +29 33 IDENT NO_KEYWORD +33 34 ASCII_44 NO_KEYWORD +35 37 IDENT NO_KEYWORD +38 42 IDENT NO_KEYWORD +42 43 ASCII_41 NO_KEYWORD +== 004 +create type nested_int8s as (c1 two_int8s, c2 two_int8s) +-- +0 6 CREATE RESERVED_KEYWORD +7 11 TYPE_P UNRESERVED_KEYWORD +12 24 IDENT NO_KEYWORD +25 27 AS RESERVED_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 31 IDENT NO_KEYWORD +32 41 IDENT NO_KEYWORD +41 42 ASCII_44 NO_KEYWORD +43 45 IDENT NO_KEYWORD +46 55 IDENT NO_KEYWORD +55 56 ASCII_41 NO_KEYWORD +== 005 +-- base-case return of a composite type +create function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1)::two_int8s; end $$ +-- +0 39 SQL_COMMENT NO_KEYWORD +40 46 CREATE RESERVED_KEYWORD +47 55 FUNCTION UNRESERVED_KEYWORD +56 60 IDENT NO_KEYWORD +60 61 ASCII_40 NO_KEYWORD +61 64 INT_P COL_NAME_KEYWORD +64 65 ASCII_41 NO_KEYWORD +66 73 RETURNS UNRESERVED_KEYWORD +74 83 IDENT NO_KEYWORD +84 92 LANGUAGE UNRESERVED_KEYWORD +93 100 IDENT NO_KEYWORD +101 103 AS RESERVED_KEYWORD +104 148 SCONST NO_KEYWORD +== 006 +select retc(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 11 IDENT NO_KEYWORD +11 12 ASCII_40 NO_KEYWORD +12 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 007 +-- ok to return a matching record type +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8); end $$ +-- +0 38 SQL_COMMENT NO_KEYWORD +39 45 CREATE RESERVED_KEYWORD +46 48 OR RESERVED_KEYWORD +49 56 REPLACE UNRESERVED_KEYWORD +57 65 FUNCTION UNRESERVED_KEYWORD +66 70 IDENT NO_KEYWORD +70 71 ASCII_40 NO_KEYWORD +71 74 INT_P COL_NAME_KEYWORD +74 75 ASCII_41 NO_KEYWORD +76 83 RETURNS UNRESERVED_KEYWORD +84 93 IDENT NO_KEYWORD +94 102 LANGUAGE UNRESERVED_KEYWORD +103 110 IDENT NO_KEYWORD +111 113 AS RESERVED_KEYWORD +114 160 SCONST NO_KEYWORD +== 008 +select retc(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 11 IDENT NO_KEYWORD +11 12 ASCII_40 NO_KEYWORD +12 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 009 +-- we don't currently support implicit casting +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1); end $$ +-- +0 46 SQL_COMMENT NO_KEYWORD +47 53 CREATE RESERVED_KEYWORD +54 56 OR RESERVED_KEYWORD +57 64 REPLACE UNRESERVED_KEYWORD +65 73 FUNCTION UNRESERVED_KEYWORD +74 78 IDENT NO_KEYWORD +78 79 ASCII_40 NO_KEYWORD +79 82 INT_P COL_NAME_KEYWORD +82 83 ASCII_41 NO_KEYWORD +84 91 RETURNS UNRESERVED_KEYWORD +92 101 IDENT NO_KEYWORD +102 110 LANGUAGE UNRESERVED_KEYWORD +111 118 IDENT NO_KEYWORD +119 121 AS RESERVED_KEYWORD +122 155 SCONST NO_KEYWORD +== 010 +select retc(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 11 IDENT NO_KEYWORD +11 12 ASCII_40 NO_KEYWORD +12 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 011 +-- nor extra columns +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8, 42); end $$ +-- +0 20 SQL_COMMENT NO_KEYWORD +21 27 CREATE RESERVED_KEYWORD +28 30 OR RESERVED_KEYWORD +31 38 REPLACE UNRESERVED_KEYWORD +39 47 FUNCTION UNRESERVED_KEYWORD +48 52 IDENT NO_KEYWORD +52 53 ASCII_40 NO_KEYWORD +53 56 INT_P COL_NAME_KEYWORD +56 57 ASCII_41 NO_KEYWORD +58 65 RETURNS UNRESERVED_KEYWORD +66 75 IDENT NO_KEYWORD +76 84 LANGUAGE UNRESERVED_KEYWORD +85 92 IDENT NO_KEYWORD +93 95 AS RESERVED_KEYWORD +96 146 SCONST NO_KEYWORD +== 012 +select retc(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 11 IDENT NO_KEYWORD +11 12 ASCII_40 NO_KEYWORD +12 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 013 +-- same cases with an intermediate "record" variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8); return r; end $$ +-- +0 52 SQL_COMMENT NO_KEYWORD +53 59 CREATE RESERVED_KEYWORD +60 62 OR RESERVED_KEYWORD +63 70 REPLACE UNRESERVED_KEYWORD +71 79 FUNCTION UNRESERVED_KEYWORD +80 84 IDENT NO_KEYWORD +84 85 ASCII_40 NO_KEYWORD +85 88 INT_P COL_NAME_KEYWORD +88 89 ASCII_41 NO_KEYWORD +90 97 RETURNS UNRESERVED_KEYWORD +98 107 IDENT NO_KEYWORD +108 116 LANGUAGE UNRESERVED_KEYWORD +117 124 IDENT NO_KEYWORD +125 127 AS RESERVED_KEYWORD +128 200 SCONST NO_KEYWORD +== 014 +select retc(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 11 IDENT NO_KEYWORD +11 12 ASCII_40 NO_KEYWORD +12 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 015 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,1); return r; end $$ +-- +0 6 CREATE RESERVED_KEYWORD +7 9 OR RESERVED_KEYWORD +10 17 REPLACE UNRESERVED_KEYWORD +18 26 FUNCTION UNRESERVED_KEYWORD +27 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 35 INT_P COL_NAME_KEYWORD +35 36 ASCII_41 NO_KEYWORD +37 44 RETURNS UNRESERVED_KEYWORD +45 54 IDENT NO_KEYWORD +55 63 LANGUAGE UNRESERVED_KEYWORD +64 71 IDENT NO_KEYWORD +72 74 AS RESERVED_KEYWORD +75 134 SCONST NO_KEYWORD +== 016 +select retc(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 11 IDENT NO_KEYWORD +11 12 ASCII_40 NO_KEYWORD +12 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 017 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +0 6 CREATE RESERVED_KEYWORD +7 9 OR RESERVED_KEYWORD +10 17 REPLACE UNRESERVED_KEYWORD +18 26 FUNCTION UNRESERVED_KEYWORD +27 31 IDENT NO_KEYWORD +31 32 ASCII_40 NO_KEYWORD +32 35 INT_P COL_NAME_KEYWORD +35 36 ASCII_41 NO_KEYWORD +37 44 RETURNS UNRESERVED_KEYWORD +45 54 IDENT NO_KEYWORD +55 63 LANGUAGE UNRESERVED_KEYWORD +64 71 IDENT NO_KEYWORD +72 74 AS RESERVED_KEYWORD +75 151 SCONST NO_KEYWORD +== 018 +select retc(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 11 IDENT NO_KEYWORD +11 12 ASCII_40 NO_KEYWORD +12 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 019 +-- but, for mostly historical reasons, we do convert when assigning +-- to a named-composite-type variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +0 67 SQL_COMMENT NO_KEYWORD +68 105 SQL_COMMENT NO_KEYWORD +106 112 CREATE RESERVED_KEYWORD +113 115 OR RESERVED_KEYWORD +116 123 REPLACE UNRESERVED_KEYWORD +124 132 FUNCTION UNRESERVED_KEYWORD +133 137 IDENT NO_KEYWORD +137 138 ASCII_40 NO_KEYWORD +138 141 INT_P COL_NAME_KEYWORD +141 142 ASCII_41 NO_KEYWORD +143 150 RETURNS UNRESERVED_KEYWORD +151 160 IDENT NO_KEYWORD +161 169 LANGUAGE UNRESERVED_KEYWORD +170 177 IDENT NO_KEYWORD +178 180 AS RESERVED_KEYWORD +181 260 SCONST NO_KEYWORD +== 020 +select retc(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 11 IDENT NO_KEYWORD +11 12 ASCII_40 NO_KEYWORD +12 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 021 +do $$ declare c two_int8s; +begin c := row(1,2); raise notice 'c = %', c; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 78 SCONST NO_KEYWORD +== 022 +do $$ declare c two_int8s; +begin for c in select 1,2 loop raise notice 'c = %', c; end loop; end$$ +-- +0 2 DO RESERVED_KEYWORD +3 98 SCONST NO_KEYWORD +== 023 +do $$ declare c4 two_int4s; c8 two_int8s; +begin + c8 := row(1,2); + c4 := c8; + c8 := c4; + raise notice 'c4 = %', c4; + raise notice 'c8 = %', c8; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 153 SCONST NO_KEYWORD +== 024 +do $$ declare c two_int8s; d nested_int8s; +begin + c := row(1,2); + d := row(c, row(c.q1, c.q2+1)); + raise notice 'c = %, d = %', c, d; + c.q1 := 10; + d.c1 := row(11,12); + d.c2.q2 := 42; + raise notice 'c = %, d = %', c, d; + raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2; + raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens + raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 431 SCONST NO_KEYWORD +== 025 +-- block-qualified naming +do $$ <> declare c two_int8s; d nested_int8s; +begin + b.c := row(1,2); + b.d := row(b.c, row(b.c.q1, b.c.q2+1)); + raise notice 'b.c = %, b.d = %', b.c, b.d; + b.c.q1 := 10; + b.d.c1 := row(11,12); + b.d.c2.q2 := 42; + raise notice 'b.c = %, b.d = %', b.c, b.d; + raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2; + raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens + raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens +end$$ +-- +0 25 SQL_COMMENT NO_KEYWORD +26 28 DO RESERVED_KEYWORD +29 511 SCONST NO_KEYWORD +== 026 +-- error cases +do $$ declare c two_int8s; begin c.x = 1; end $$ +-- +0 14 SQL_COMMENT NO_KEYWORD +15 17 DO RESERVED_KEYWORD +18 63 SCONST NO_KEYWORD +== 027 +do $$ declare c nested_int8s; begin c.x = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 51 SCONST NO_KEYWORD +== 028 +do $$ declare c nested_int8s; begin c.x.q1 = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 54 SCONST NO_KEYWORD +== 029 +do $$ declare c nested_int8s; begin c.c2.x = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 54 SCONST NO_KEYWORD +== 030 +do $$ declare c nested_int8s; begin d.c2.x = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 54 SCONST NO_KEYWORD +== 031 +do $$ <> declare c two_int8s; begin b.c.x = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 56 SCONST NO_KEYWORD +== 032 +do $$ <> declare c nested_int8s; begin b.c.x = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 59 SCONST NO_KEYWORD +== 033 +do $$ <> declare c nested_int8s; begin b.c.x.q1 = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 62 SCONST NO_KEYWORD +== 034 +do $$ <> declare c nested_int8s; begin b.c.c2.x = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 62 SCONST NO_KEYWORD +== 035 +do $$ <> declare c nested_int8s; begin b.d.c2.x = 1; end $$ +-- +0 2 DO RESERVED_KEYWORD +3 62 SCONST NO_KEYWORD +== 036 +-- check passing composite result to another function +create function getq1(two_int8s) returns int8 language plpgsql as $$ +declare r two_int8s; begin r := $1; return r.q1; end $$ +-- +0 53 SQL_COMMENT NO_KEYWORD +54 60 CREATE RESERVED_KEYWORD +61 69 FUNCTION UNRESERVED_KEYWORD +70 75 IDENT NO_KEYWORD +75 76 ASCII_40 NO_KEYWORD +76 85 IDENT NO_KEYWORD +85 86 ASCII_41 NO_KEYWORD +87 94 RETURNS UNRESERVED_KEYWORD +95 99 IDENT NO_KEYWORD +100 108 LANGUAGE UNRESERVED_KEYWORD +109 116 IDENT NO_KEYWORD +117 119 AS RESERVED_KEYWORD +120 178 SCONST NO_KEYWORD +== 037 +select getq1(retc(344)) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 17 IDENT NO_KEYWORD +17 18 ASCII_40 NO_KEYWORD +18 21 ICONST NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +22 23 ASCII_41 NO_KEYWORD +== 038 +select getq1(row(1,2)) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 16 ROW COL_NAME_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_44 NO_KEYWORD +19 20 ICONST NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 039 +do $$ +declare r1 two_int8s; r2 record; x int8; +begin + r1 := retc(345); + perform getq1(r1); + x := getq1(r1); + raise notice 'x = %', x; + r2 := retc(346); + perform getq1(r2); + x := getq1(r2); + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 228 SCONST NO_KEYWORD +== 040 +-- check assignments of composites +do $$ +declare r1 two_int8s; r2 two_int8s; r3 record; r4 record; +begin + r1 := row(1,2); + raise notice 'r1 = %', r1; + r1 := r1; -- shouldn't do anything + raise notice 'r1 = %', r1; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := null; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := row(7,11)::two_int8s; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r3 := row(1,2); + r4 := r3; + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r1 := r3; + raise notice 'r1 = %', r1; + r4 := r1; + raise notice 'r4 = %', r4; + r4.q2 := r4.q2 + 1; -- r4's field names have changed + raise notice 'r4 = %', r4; +end$$ +-- +0 34 SQL_COMMENT NO_KEYWORD +35 37 DO RESERVED_KEYWORD +38 958 SCONST NO_KEYWORD +== 041 +-- fields of named-type vars read as null if uninitialized +do $$ +declare r1 two_int8s; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; +end$$ +-- +0 58 SQL_COMMENT NO_KEYWORD +59 61 DO RESERVED_KEYWORD +62 226 SCONST NO_KEYWORD +== 042 +do $$ +declare r1 two_int8s; +begin + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 191 SCONST NO_KEYWORD +== 043 +-- records, not so much +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; +end$$ +-- +0 23 SQL_COMMENT NO_KEYWORD +24 26 DO RESERVED_KEYWORD +27 188 SCONST NO_KEYWORD +== 044 +-- but OK if you assign first +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + r1 := row(1,2); + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +0 29 SQL_COMMENT NO_KEYWORD +30 32 DO RESERVED_KEYWORD +33 265 SCONST NO_KEYWORD +== 045 +-- check %type with block-qualified variable names +do $$ +<> +declare + v int; + r two_int8s; + v1 v%type; + v2 blk.v%type; + r1 r%type; + r2 blk.r%type; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(r1); + raise notice '%', pg_typeof(r2); +end$$ +-- +0 50 SQL_COMMENT NO_KEYWORD +51 53 DO RESERVED_KEYWORD +54 308 SCONST NO_KEYWORD +== 046 +-- check that type record can be passed through %type +do $$ +declare r1 record; + r2 r1%type; +begin + r2 := row(1,2); + raise notice 'r2 = %', r2; + r2 := row(3,4,5); + raise notice 'r2 = %', r2; +end$$ +-- +0 53 SQL_COMMENT NO_KEYWORD +54 56 DO RESERVED_KEYWORD +57 206 SCONST NO_KEYWORD +== 047 +-- arrays of record are not supported at the moment +do $$ +declare r1 record[]; +begin +end$$ +-- +0 51 SQL_COMMENT NO_KEYWORD +52 54 DO RESERVED_KEYWORD +55 90 SCONST NO_KEYWORD +== 048 +do $$ +declare r1 record; + r2 r1%type[]; +begin +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 58 SCONST NO_KEYWORD +== 049 +-- check repeated assignments to composite fields +create table some_table (id int, data text) +-- +0 49 SQL_COMMENT NO_KEYWORD +50 56 CREATE RESERVED_KEYWORD +57 62 TABLE RESERVED_KEYWORD +63 73 IDENT NO_KEYWORD +74 75 ASCII_40 NO_KEYWORD +75 77 IDENT NO_KEYWORD +78 81 INT_P COL_NAME_KEYWORD +81 82 ASCII_44 NO_KEYWORD +83 87 DATA_P UNRESERVED_KEYWORD +88 92 TEXT_P UNRESERVED_KEYWORD +92 93 ASCII_41 NO_KEYWORD +== 050 +do $$ +declare r some_table; +begin + r := (23, 'skidoo'); + for i in 1 .. 10 loop + r.id := r.id + i; + r.data := r.data || ' ' || i; + end loop; + raise notice 'r = %', r; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 181 SCONST NO_KEYWORD +== 051 +-- check behavior of function declared to return "record" + +create function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1); end $$ +-- +0 57 SQL_COMMENT NO_KEYWORD +59 65 CREATE RESERVED_KEYWORD +66 74 FUNCTION UNRESERVED_KEYWORD +75 88 IDENT NO_KEYWORD +88 89 ASCII_40 NO_KEYWORD +89 92 INT_P COL_NAME_KEYWORD +92 93 ASCII_41 NO_KEYWORD +94 101 RETURNS UNRESERVED_KEYWORD +102 108 IDENT NO_KEYWORD +109 117 LANGUAGE UNRESERVED_KEYWORD +118 125 IDENT NO_KEYWORD +126 128 AS RESERVED_KEYWORD +129 165 SCONST NO_KEYWORD +== 052 +select returnsrecord(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 20 IDENT NO_KEYWORD +20 21 ASCII_40 NO_KEYWORD +21 23 ICONST NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 053 +select * from returnsrecord(42) as r(x int, y int) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +32 34 AS RESERVED_KEYWORD +35 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_41 NO_KEYWORD +== 054 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +32 34 AS RESERVED_KEYWORD +35 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_44 NO_KEYWORD +51 52 IDENT NO_KEYWORD +53 56 INT_P COL_NAME_KEYWORD +56 57 ASCII_41 NO_KEYWORD +== 055 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +0 7 SQL_COMMENT NO_KEYWORD +8 14 SELECT RESERVED_KEYWORD +15 16 ASCII_42 NO_KEYWORD +17 21 FROM RESERVED_KEYWORD +22 35 IDENT NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 38 ICONST NO_KEYWORD +38 39 ASCII_41 NO_KEYWORD +40 42 AS RESERVED_KEYWORD +43 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 IDENT NO_KEYWORD +47 50 INT_P COL_NAME_KEYWORD +50 51 ASCII_44 NO_KEYWORD +52 53 IDENT NO_KEYWORD +54 60 BIGINT COL_NAME_KEYWORD +60 61 ASCII_41 NO_KEYWORD +== 056 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1); return r; end $$ +-- +0 7 SQL_COMMENT NO_KEYWORD +9 53 SQL_COMMENT NO_KEYWORD +54 60 CREATE RESERVED_KEYWORD +61 63 OR RESERVED_KEYWORD +64 71 REPLACE UNRESERVED_KEYWORD +72 80 FUNCTION UNRESERVED_KEYWORD +81 94 IDENT NO_KEYWORD +94 95 ASCII_40 NO_KEYWORD +95 98 INT_P COL_NAME_KEYWORD +98 99 ASCII_41 NO_KEYWORD +100 107 RETURNS UNRESERVED_KEYWORD +108 114 IDENT NO_KEYWORD +115 123 LANGUAGE UNRESERVED_KEYWORD +124 131 IDENT NO_KEYWORD +132 134 AS RESERVED_KEYWORD +135 197 SCONST NO_KEYWORD +== 057 +select returnsrecord(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 20 IDENT NO_KEYWORD +20 21 ASCII_40 NO_KEYWORD +21 23 ICONST NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 058 +select * from returnsrecord(42) as r(x int, y int) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +32 34 AS RESERVED_KEYWORD +35 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_41 NO_KEYWORD +== 059 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +32 34 AS RESERVED_KEYWORD +35 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_44 NO_KEYWORD +51 52 IDENT NO_KEYWORD +53 56 INT_P COL_NAME_KEYWORD +56 57 ASCII_41 NO_KEYWORD +== 060 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +0 7 SQL_COMMENT NO_KEYWORD +8 14 SELECT RESERVED_KEYWORD +15 16 ASCII_42 NO_KEYWORD +17 21 FROM RESERVED_KEYWORD +22 35 IDENT NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 38 ICONST NO_KEYWORD +38 39 ASCII_41 NO_KEYWORD +40 42 AS RESERVED_KEYWORD +43 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 IDENT NO_KEYWORD +47 50 INT_P COL_NAME_KEYWORD +50 51 ASCII_44 NO_KEYWORD +52 53 IDENT NO_KEYWORD +54 60 BIGINT COL_NAME_KEYWORD +60 61 ASCII_41 NO_KEYWORD +== 061 +-- fail + +-- should work the same with a missing column in the actual result value +create table has_hole(f1 int, f2 int, f3 int) +-- +0 7 SQL_COMMENT NO_KEYWORD +9 81 SQL_COMMENT NO_KEYWORD +82 88 CREATE RESERVED_KEYWORD +89 94 TABLE RESERVED_KEYWORD +95 103 IDENT NO_KEYWORD +103 104 ASCII_40 NO_KEYWORD +104 106 IDENT NO_KEYWORD +107 110 INT_P COL_NAME_KEYWORD +110 111 ASCII_44 NO_KEYWORD +112 114 IDENT NO_KEYWORD +115 118 INT_P COL_NAME_KEYWORD +118 119 ASCII_44 NO_KEYWORD +120 122 IDENT NO_KEYWORD +123 126 INT_P COL_NAME_KEYWORD +126 127 ASCII_41 NO_KEYWORD +== 062 +alter table has_hole drop column f2 +-- +0 5 ALTER UNRESERVED_KEYWORD +6 11 TABLE RESERVED_KEYWORD +12 20 IDENT NO_KEYWORD +21 25 DROP UNRESERVED_KEYWORD +26 32 COLUMN RESERVED_KEYWORD +33 35 IDENT NO_KEYWORD +== 063 +create or replace function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1)::has_hole; end $$ +-- +0 6 CREATE RESERVED_KEYWORD +7 9 OR RESERVED_KEYWORD +10 17 REPLACE UNRESERVED_KEYWORD +18 26 FUNCTION UNRESERVED_KEYWORD +27 40 IDENT NO_KEYWORD +40 41 ASCII_40 NO_KEYWORD +41 44 INT_P COL_NAME_KEYWORD +44 45 ASCII_41 NO_KEYWORD +46 53 RETURNS UNRESERVED_KEYWORD +54 60 IDENT NO_KEYWORD +61 69 LANGUAGE UNRESERVED_KEYWORD +70 77 IDENT NO_KEYWORD +78 80 AS RESERVED_KEYWORD +81 127 SCONST NO_KEYWORD +== 064 +select returnsrecord(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 20 IDENT NO_KEYWORD +20 21 ASCII_40 NO_KEYWORD +21 23 ICONST NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 065 +select * from returnsrecord(42) as r(x int, y int) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +32 34 AS RESERVED_KEYWORD +35 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_41 NO_KEYWORD +== 066 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +32 34 AS RESERVED_KEYWORD +35 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_44 NO_KEYWORD +51 52 IDENT NO_KEYWORD +53 56 INT_P COL_NAME_KEYWORD +56 57 ASCII_41 NO_KEYWORD +== 067 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +0 7 SQL_COMMENT NO_KEYWORD +8 14 SELECT RESERVED_KEYWORD +15 16 ASCII_42 NO_KEYWORD +17 21 FROM RESERVED_KEYWORD +22 35 IDENT NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 38 ICONST NO_KEYWORD +38 39 ASCII_41 NO_KEYWORD +40 42 AS RESERVED_KEYWORD +43 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 IDENT NO_KEYWORD +47 50 INT_P COL_NAME_KEYWORD +50 51 ASCII_44 NO_KEYWORD +52 53 IDENT NO_KEYWORD +54 60 BIGINT COL_NAME_KEYWORD +60 61 ASCII_41 NO_KEYWORD +== 068 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1)::has_hole; return r; end $$ +-- +0 7 SQL_COMMENT NO_KEYWORD +9 53 SQL_COMMENT NO_KEYWORD +54 60 CREATE RESERVED_KEYWORD +61 63 OR RESERVED_KEYWORD +64 71 REPLACE UNRESERVED_KEYWORD +72 80 FUNCTION UNRESERVED_KEYWORD +81 94 IDENT NO_KEYWORD +94 95 ASCII_40 NO_KEYWORD +95 98 INT_P COL_NAME_KEYWORD +98 99 ASCII_41 NO_KEYWORD +100 107 RETURNS UNRESERVED_KEYWORD +108 114 IDENT NO_KEYWORD +115 123 LANGUAGE UNRESERVED_KEYWORD +124 131 IDENT NO_KEYWORD +132 134 AS RESERVED_KEYWORD +135 207 SCONST NO_KEYWORD +== 069 +select returnsrecord(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 20 IDENT NO_KEYWORD +20 21 ASCII_40 NO_KEYWORD +21 23 ICONST NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 070 +select * from returnsrecord(42) as r(x int, y int) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +32 34 AS RESERVED_KEYWORD +35 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_41 NO_KEYWORD +== 071 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +32 34 AS RESERVED_KEYWORD +35 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 IDENT NO_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +42 43 ASCII_44 NO_KEYWORD +44 45 IDENT NO_KEYWORD +46 49 INT_P COL_NAME_KEYWORD +49 50 ASCII_44 NO_KEYWORD +51 52 IDENT NO_KEYWORD +53 56 INT_P COL_NAME_KEYWORD +56 57 ASCII_41 NO_KEYWORD +== 072 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +0 7 SQL_COMMENT NO_KEYWORD +8 14 SELECT RESERVED_KEYWORD +15 16 ASCII_42 NO_KEYWORD +17 21 FROM RESERVED_KEYWORD +22 35 IDENT NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 38 ICONST NO_KEYWORD +38 39 ASCII_41 NO_KEYWORD +40 42 AS RESERVED_KEYWORD +43 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 IDENT NO_KEYWORD +47 50 INT_P COL_NAME_KEYWORD +50 51 ASCII_44 NO_KEYWORD +52 53 IDENT NO_KEYWORD +54 60 BIGINT COL_NAME_KEYWORD +60 61 ASCII_41 NO_KEYWORD +== 073 +-- fail + +-- check access to a field of an argument declared "record" +create function getf1(x record) returns int language plpgsql as +$$ begin return x.f1; end $$ +-- +0 7 SQL_COMMENT NO_KEYWORD +9 68 SQL_COMMENT NO_KEYWORD +69 75 CREATE RESERVED_KEYWORD +76 84 FUNCTION UNRESERVED_KEYWORD +85 90 IDENT NO_KEYWORD +90 91 ASCII_40 NO_KEYWORD +91 92 IDENT NO_KEYWORD +93 99 IDENT NO_KEYWORD +99 100 ASCII_41 NO_KEYWORD +101 108 RETURNS UNRESERVED_KEYWORD +109 112 INT_P COL_NAME_KEYWORD +113 121 LANGUAGE UNRESERVED_KEYWORD +122 129 IDENT NO_KEYWORD +130 132 AS RESERVED_KEYWORD +133 161 SCONST NO_KEYWORD +== 074 +select getf1(1) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 14 ICONST NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +== 075 +select getf1(row(1,2)) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 16 ROW COL_NAME_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_44 NO_KEYWORD +19 20 ICONST NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 076 +select getf1(row(1,2)::two_int4s) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 16 ROW COL_NAME_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_44 NO_KEYWORD +19 20 ICONST NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +21 23 TYPECAST NO_KEYWORD +23 32 IDENT NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 077 +select getf1(row('foo',123,456)::more_int4s) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 16 ROW COL_NAME_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 22 SCONST NO_KEYWORD +22 23 ASCII_44 NO_KEYWORD +23 26 ICONST NO_KEYWORD +26 27 ASCII_44 NO_KEYWORD +27 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +31 33 TYPECAST NO_KEYWORD +33 43 IDENT NO_KEYWORD +43 44 ASCII_41 NO_KEYWORD +== 078 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf1(row(1,2)::two_int8s) +-- +0 59 SQL_COMMENT NO_KEYWORD +60 97 SQL_COMMENT NO_KEYWORD +98 104 SELECT RESERVED_KEYWORD +105 110 IDENT NO_KEYWORD +110 111 ASCII_40 NO_KEYWORD +111 114 ROW COL_NAME_KEYWORD +114 115 ASCII_40 NO_KEYWORD +115 116 ICONST NO_KEYWORD +116 117 ASCII_44 NO_KEYWORD +117 118 ICONST NO_KEYWORD +118 119 ASCII_41 NO_KEYWORD +119 121 TYPECAST NO_KEYWORD +121 130 IDENT NO_KEYWORD +130 131 ASCII_41 NO_KEYWORD +== 079 +select getf1(row(1,2)) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 16 ROW COL_NAME_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_44 NO_KEYWORD +19 20 ICONST NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 080 +-- this seemingly-equivalent case behaves a bit differently, +-- because the core parser's handling of $N symbols is simplistic +create function getf2(record) returns int language plpgsql as +$$ begin return $1.f2; end $$ +-- +0 60 SQL_COMMENT NO_KEYWORD +61 126 SQL_COMMENT NO_KEYWORD +127 133 CREATE RESERVED_KEYWORD +134 142 FUNCTION UNRESERVED_KEYWORD +143 148 IDENT NO_KEYWORD +148 149 ASCII_40 NO_KEYWORD +149 155 IDENT NO_KEYWORD +155 156 ASCII_41 NO_KEYWORD +157 164 RETURNS UNRESERVED_KEYWORD +165 168 INT_P COL_NAME_KEYWORD +169 177 LANGUAGE UNRESERVED_KEYWORD +178 185 IDENT NO_KEYWORD +186 188 AS RESERVED_KEYWORD +189 218 SCONST NO_KEYWORD +== 081 +select getf2(row(1,2)) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 16 ROW COL_NAME_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 18 ICONST NO_KEYWORD +18 19 ASCII_44 NO_KEYWORD +19 20 ICONST NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 082 +-- ideally would work, but does not +select getf2(row(1,2)::two_int4s) +-- +0 35 SQL_COMMENT NO_KEYWORD +36 42 SELECT RESERVED_KEYWORD +43 48 IDENT NO_KEYWORD +48 49 ASCII_40 NO_KEYWORD +49 52 ROW COL_NAME_KEYWORD +52 53 ASCII_40 NO_KEYWORD +53 54 ICONST NO_KEYWORD +54 55 ASCII_44 NO_KEYWORD +55 56 ICONST NO_KEYWORD +56 57 ASCII_41 NO_KEYWORD +57 59 TYPECAST NO_KEYWORD +59 68 IDENT NO_KEYWORD +68 69 ASCII_41 NO_KEYWORD +== 083 +select getf2(row('foo',123,456)::more_int4s) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 16 ROW COL_NAME_KEYWORD +16 17 ASCII_40 NO_KEYWORD +17 22 SCONST NO_KEYWORD +22 23 ASCII_44 NO_KEYWORD +23 26 ICONST NO_KEYWORD +26 27 ASCII_44 NO_KEYWORD +27 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +31 33 TYPECAST NO_KEYWORD +33 43 IDENT NO_KEYWORD +43 44 ASCII_41 NO_KEYWORD +== 084 +-- check behavior when assignment to FOR-loop variable requires coercion +do $$ +declare r two_int8s; +begin + for r in select i, i+1 from generate_series(1,4) i + loop + raise notice 'r = %', r; + end loop; +end$$ +-- +0 72 SQL_COMMENT NO_KEYWORD +73 75 DO RESERVED_KEYWORD +76 212 SCONST NO_KEYWORD +== 085 +-- check behavior when returning setof composite +create function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; + h has_hole; +begin + return next h; + r := (1,2); + h := (3,4); + return next r; + return next h; + return next row(5,6); + return next row(7,8)::has_hole; +end$$ +-- +0 48 SQL_COMMENT NO_KEYWORD +49 55 CREATE RESERVED_KEYWORD +56 64 FUNCTION UNRESERVED_KEYWORD +65 82 IDENT NO_KEYWORD +82 83 ASCII_40 NO_KEYWORD +83 84 ASCII_41 NO_KEYWORD +85 92 RETURNS UNRESERVED_KEYWORD +93 98 SETOF COL_NAME_KEYWORD +99 107 IDENT NO_KEYWORD +108 116 LANGUAGE UNRESERVED_KEYWORD +117 124 IDENT NO_KEYWORD +125 127 AS RESERVED_KEYWORD +128 311 SCONST NO_KEYWORD +== 086 +select returnssetofholes() +-- +0 6 SELECT RESERVED_KEYWORD +7 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 087 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; +begin + return next r; -- fails, not assigned yet +end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 9 OR RESERVED_KEYWORD +10 17 REPLACE UNRESERVED_KEYWORD +18 26 FUNCTION UNRESERVED_KEYWORD +27 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 ASCII_41 NO_KEYWORD +47 54 RETURNS UNRESERVED_KEYWORD +55 60 SETOF COL_NAME_KEYWORD +61 69 IDENT NO_KEYWORD +70 78 LANGUAGE UNRESERVED_KEYWORD +79 86 IDENT NO_KEYWORD +87 89 AS RESERVED_KEYWORD +90 167 SCONST NO_KEYWORD +== 088 +select returnssetofholes() +-- +0 6 SELECT RESERVED_KEYWORD +7 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 089 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +begin + return next row(1,2,3); -- fails +end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 9 OR RESERVED_KEYWORD +10 17 REPLACE UNRESERVED_KEYWORD +18 26 FUNCTION UNRESERVED_KEYWORD +27 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 ASCII_41 NO_KEYWORD +47 54 RETURNS UNRESERVED_KEYWORD +55 60 SETOF COL_NAME_KEYWORD +61 69 IDENT NO_KEYWORD +70 78 LANGUAGE UNRESERVED_KEYWORD +79 86 IDENT NO_KEYWORD +87 89 AS RESERVED_KEYWORD +90 140 SCONST NO_KEYWORD +== 090 +select returnssetofholes() +-- +0 6 SELECT RESERVED_KEYWORD +7 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 091 +-- check behavior with changes of a named rowtype +create table mutable(f1 int, f2 text) +-- +0 49 SQL_COMMENT NO_KEYWORD +50 56 CREATE RESERVED_KEYWORD +57 62 TABLE RESERVED_KEYWORD +63 70 IDENT NO_KEYWORD +70 71 ASCII_40 NO_KEYWORD +71 73 IDENT NO_KEYWORD +74 77 INT_P COL_NAME_KEYWORD +77 78 ASCII_44 NO_KEYWORD +79 81 IDENT NO_KEYWORD +82 86 TEXT_P UNRESERVED_KEYWORD +86 87 ASCII_41 NO_KEYWORD +== 092 +create function sillyaddone(int) returns int language plpgsql as +$$ declare r mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 31 INT_P COL_NAME_KEYWORD +31 32 ASCII_41 NO_KEYWORD +33 40 RETURNS UNRESERVED_KEYWORD +41 44 INT_P COL_NAME_KEYWORD +45 53 LANGUAGE UNRESERVED_KEYWORD +54 61 IDENT NO_KEYWORD +62 64 AS RESERVED_KEYWORD +65 128 SCONST NO_KEYWORD +== 093 +select sillyaddone(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 18 IDENT NO_KEYWORD +18 19 ASCII_40 NO_KEYWORD +19 21 ICONST NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 094 +-- test for change of type of column f1 should be here someday; +-- for now see plpgsql_cache test + +alter table mutable drop column f1 +-- +0 63 SQL_COMMENT NO_KEYWORD +64 97 SQL_COMMENT NO_KEYWORD +99 104 ALTER UNRESERVED_KEYWORD +105 110 TABLE RESERVED_KEYWORD +111 118 IDENT NO_KEYWORD +119 123 DROP UNRESERVED_KEYWORD +124 130 COLUMN RESERVED_KEYWORD +131 133 IDENT NO_KEYWORD +== 095 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddone(42) +-- +0 59 SQL_COMMENT NO_KEYWORD +60 97 SQL_COMMENT NO_KEYWORD +98 104 SELECT RESERVED_KEYWORD +105 116 IDENT NO_KEYWORD +116 117 ASCII_40 NO_KEYWORD +117 119 ICONST NO_KEYWORD +119 120 ASCII_41 NO_KEYWORD +== 096 +-- fail + +create function getf3(x mutable) returns int language plpgsql as +$$ begin return x.f3; end $$ +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 30 IDENT NO_KEYWORD +30 31 ASCII_40 NO_KEYWORD +31 32 IDENT NO_KEYWORD +33 40 IDENT NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +42 49 RETURNS UNRESERVED_KEYWORD +50 53 INT_P COL_NAME_KEYWORD +54 62 LANGUAGE UNRESERVED_KEYWORD +63 70 IDENT NO_KEYWORD +71 73 AS RESERVED_KEYWORD +74 102 SCONST NO_KEYWORD +== 097 +select getf3(null::mutable) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 17 NULL_P RESERVED_KEYWORD +17 19 TYPECAST NO_KEYWORD +19 26 IDENT NO_KEYWORD +26 27 ASCII_41 NO_KEYWORD +== 098 +-- doesn't work yet +alter table mutable add column f3 int +-- +0 19 SQL_COMMENT NO_KEYWORD +20 25 ALTER UNRESERVED_KEYWORD +26 31 TABLE RESERVED_KEYWORD +32 39 IDENT NO_KEYWORD +40 43 ADD_P UNRESERVED_KEYWORD +44 50 COLUMN RESERVED_KEYWORD +51 53 IDENT NO_KEYWORD +54 57 INT_P COL_NAME_KEYWORD +== 099 +select getf3(null::mutable) +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 17 NULL_P RESERVED_KEYWORD +17 19 TYPECAST NO_KEYWORD +19 26 IDENT NO_KEYWORD +26 27 ASCII_41 NO_KEYWORD +== 100 +-- now it works +alter table mutable drop column f3 +-- +0 15 SQL_COMMENT NO_KEYWORD +16 21 ALTER UNRESERVED_KEYWORD +22 27 TABLE RESERVED_KEYWORD +28 35 IDENT NO_KEYWORD +36 40 DROP UNRESERVED_KEYWORD +41 47 COLUMN RESERVED_KEYWORD +48 50 IDENT NO_KEYWORD +== 101 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf3(null::mutable) +-- +0 59 SQL_COMMENT NO_KEYWORD +60 97 SQL_COMMENT NO_KEYWORD +98 104 SELECT RESERVED_KEYWORD +105 110 IDENT NO_KEYWORD +110 111 ASCII_40 NO_KEYWORD +111 115 NULL_P RESERVED_KEYWORD +115 117 TYPECAST NO_KEYWORD +117 124 IDENT NO_KEYWORD +124 125 ASCII_41 NO_KEYWORD +== 102 +-- fails again + +-- check behavior with creating/dropping a named rowtype +set check_function_bodies = off +-- +0 14 SQL_COMMENT NO_KEYWORD +16 72 SQL_COMMENT NO_KEYWORD +73 76 SET UNRESERVED_KEYWORD +77 98 IDENT NO_KEYWORD +99 100 ASCII_61 NO_KEYWORD +101 104 OFF UNRESERVED_KEYWORD +== 103 +-- else reference to nonexistent type fails + +create function sillyaddtwo(int) returns int language plpgsql as +$$ declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end $$ +-- +0 43 SQL_COMMENT NO_KEYWORD +45 51 CREATE RESERVED_KEYWORD +52 60 FUNCTION UNRESERVED_KEYWORD +61 72 IDENT NO_KEYWORD +72 73 ASCII_40 NO_KEYWORD +73 76 INT_P COL_NAME_KEYWORD +76 77 ASCII_41 NO_KEYWORD +78 85 RETURNS UNRESERVED_KEYWORD +86 89 INT_P COL_NAME_KEYWORD +90 98 LANGUAGE UNRESERVED_KEYWORD +99 106 IDENT NO_KEYWORD +107 109 AS RESERVED_KEYWORD +110 174 SCONST NO_KEYWORD +== 104 +reset check_function_bodies +-- +0 5 RESET UNRESERVED_KEYWORD +6 27 IDENT NO_KEYWORD +== 105 +select sillyaddtwo(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 18 IDENT NO_KEYWORD +18 19 ASCII_40 NO_KEYWORD +19 21 ICONST NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 106 +-- fail +create table mutable2(f1 int, f2 text) +-- +0 7 SQL_COMMENT NO_KEYWORD +8 14 CREATE RESERVED_KEYWORD +15 20 TABLE RESERVED_KEYWORD +21 29 IDENT NO_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 32 IDENT NO_KEYWORD +33 36 INT_P COL_NAME_KEYWORD +36 37 ASCII_44 NO_KEYWORD +38 40 IDENT NO_KEYWORD +41 45 TEXT_P UNRESERVED_KEYWORD +45 46 ASCII_41 NO_KEYWORD +== 107 +select sillyaddtwo(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 18 IDENT NO_KEYWORD +18 19 ASCII_40 NO_KEYWORD +19 21 ICONST NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 108 +drop table mutable2 +-- +0 4 DROP UNRESERVED_KEYWORD +5 10 TABLE RESERVED_KEYWORD +11 19 IDENT NO_KEYWORD +== 109 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddtwo(42) +-- +0 59 SQL_COMMENT NO_KEYWORD +60 97 SQL_COMMENT NO_KEYWORD +98 104 SELECT RESERVED_KEYWORD +105 116 IDENT NO_KEYWORD +116 117 ASCII_40 NO_KEYWORD +117 119 ICONST NO_KEYWORD +119 120 ASCII_41 NO_KEYWORD +== 110 +-- fail +create table mutable2(f0 text, f1 int, f2 text) +-- +0 7 SQL_COMMENT NO_KEYWORD +8 14 CREATE RESERVED_KEYWORD +15 20 TABLE RESERVED_KEYWORD +21 29 IDENT NO_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 32 IDENT NO_KEYWORD +33 37 TEXT_P UNRESERVED_KEYWORD +37 38 ASCII_44 NO_KEYWORD +39 41 IDENT NO_KEYWORD +42 45 INT_P COL_NAME_KEYWORD +45 46 ASCII_44 NO_KEYWORD +47 49 IDENT NO_KEYWORD +50 54 TEXT_P UNRESERVED_KEYWORD +54 55 ASCII_41 NO_KEYWORD +== 111 +select sillyaddtwo(42) +-- +0 6 SELECT RESERVED_KEYWORD +7 18 IDENT NO_KEYWORD +18 19 ASCII_40 NO_KEYWORD +19 21 ICONST NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 112 +select sillyaddtwo(43) +-- +0 6 SELECT RESERVED_KEYWORD +7 18 IDENT NO_KEYWORD +18 19 ASCII_40 NO_KEYWORD +19 21 ICONST NO_KEYWORD +21 22 ASCII_41 NO_KEYWORD +== 113 +-- check access to system columns in a record variable + +create function sillytrig() returns trigger language plpgsql as +$$begin + raise notice 'old.ctid = %', old.ctid; + raise notice 'old.tableoid = %', old.tableoid::regclass; + return new; +end$$ +-- +0 54 SQL_COMMENT NO_KEYWORD +56 62 CREATE RESERVED_KEYWORD +63 71 FUNCTION UNRESERVED_KEYWORD +72 81 IDENT NO_KEYWORD +81 82 ASCII_40 NO_KEYWORD +82 83 ASCII_41 NO_KEYWORD +84 91 RETURNS UNRESERVED_KEYWORD +92 99 TRIGGER UNRESERVED_KEYWORD +100 108 LANGUAGE UNRESERVED_KEYWORD +109 116 IDENT NO_KEYWORD +117 119 AS RESERVED_KEYWORD +120 247 SCONST NO_KEYWORD +== 114 +create trigger mutable_trig before update on mutable for each row +execute procedure sillytrig() +-- +0 6 CREATE RESERVED_KEYWORD +7 14 TRIGGER UNRESERVED_KEYWORD +15 27 IDENT NO_KEYWORD +28 34 BEFORE UNRESERVED_KEYWORD +35 41 UPDATE UNRESERVED_KEYWORD +42 44 ON RESERVED_KEYWORD +45 52 IDENT NO_KEYWORD +53 56 FOR RESERVED_KEYWORD +57 61 EACH UNRESERVED_KEYWORD +62 65 ROW COL_NAME_KEYWORD +66 73 EXECUTE UNRESERVED_KEYWORD +74 83 PROCEDURE UNRESERVED_KEYWORD +84 93 IDENT NO_KEYWORD +93 94 ASCII_40 NO_KEYWORD +94 95 ASCII_41 NO_KEYWORD +== 115 +insert into mutable values ('foo'), ('bar') +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 26 VALUES COL_NAME_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 33 SCONST NO_KEYWORD +33 34 ASCII_41 NO_KEYWORD +34 35 ASCII_44 NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 42 SCONST NO_KEYWORD +42 43 ASCII_41 NO_KEYWORD +== 116 +update mutable set f2 = f2 || ' baz' +-- +0 6 UPDATE UNRESERVED_KEYWORD +7 14 IDENT NO_KEYWORD +15 18 SET UNRESERVED_KEYWORD +19 21 IDENT NO_KEYWORD +22 23 ASCII_61 NO_KEYWORD +24 26 IDENT NO_KEYWORD +27 29 Op NO_KEYWORD +30 36 SCONST NO_KEYWORD +== 117 +table mutable +-- +0 5 TABLE RESERVED_KEYWORD +6 13 IDENT NO_KEYWORD +== 118 +-- check returning a composite datum from a trigger + +create or replace function sillytrig() returns trigger language plpgsql as +$$begin + return row(new.*); +end$$ +-- +0 51 SQL_COMMENT NO_KEYWORD +53 59 CREATE RESERVED_KEYWORD +60 62 OR RESERVED_KEYWORD +63 70 REPLACE UNRESERVED_KEYWORD +71 79 FUNCTION UNRESERVED_KEYWORD +80 89 IDENT NO_KEYWORD +89 90 ASCII_40 NO_KEYWORD +90 91 ASCII_41 NO_KEYWORD +92 99 RETURNS UNRESERVED_KEYWORD +100 107 TRIGGER UNRESERVED_KEYWORD +108 116 LANGUAGE UNRESERVED_KEYWORD +117 124 IDENT NO_KEYWORD +125 127 AS RESERVED_KEYWORD +128 162 SCONST NO_KEYWORD +== 119 +update mutable set f2 = f2 || ' baz' +-- +0 6 UPDATE UNRESERVED_KEYWORD +7 14 IDENT NO_KEYWORD +15 18 SET UNRESERVED_KEYWORD +19 21 IDENT NO_KEYWORD +22 23 ASCII_61 NO_KEYWORD +24 26 IDENT NO_KEYWORD +27 29 Op NO_KEYWORD +30 36 SCONST NO_KEYWORD +== 120 +table mutable +-- +0 5 TABLE RESERVED_KEYWORD +6 13 IDENT NO_KEYWORD +== 121 +create or replace function sillytrig() returns trigger language plpgsql as +$$declare r record; +begin + r := row(new.*); + return r; +end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 9 OR RESERVED_KEYWORD +10 17 REPLACE UNRESERVED_KEYWORD +18 26 FUNCTION UNRESERVED_KEYWORD +27 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 ASCII_41 NO_KEYWORD +39 46 RETURNS UNRESERVED_KEYWORD +47 54 TRIGGER UNRESERVED_KEYWORD +55 63 LANGUAGE UNRESERVED_KEYWORD +64 71 IDENT NO_KEYWORD +72 74 AS RESERVED_KEYWORD +75 137 SCONST NO_KEYWORD +== 122 +update mutable set f2 = f2 || ' baz' +-- +0 6 UPDATE UNRESERVED_KEYWORD +7 14 IDENT NO_KEYWORD +15 18 SET UNRESERVED_KEYWORD +19 21 IDENT NO_KEYWORD +22 23 ASCII_61 NO_KEYWORD +24 26 IDENT NO_KEYWORD +27 29 Op NO_KEYWORD +30 36 SCONST NO_KEYWORD +== 123 +table mutable +-- +0 5 TABLE RESERVED_KEYWORD +6 13 IDENT NO_KEYWORD +== 124 +|-- +-- Domains of composite +|-- + +create domain ordered_int8s as two_int8s check((value).q1 <= (value).q2) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 26 SQL_COMMENT NO_KEYWORD +27 29 SQL_COMMENT NO_KEYWORD +31 37 CREATE RESERVED_KEYWORD +38 44 DOMAIN_P UNRESERVED_KEYWORD +45 58 IDENT NO_KEYWORD +59 61 AS RESERVED_KEYWORD +62 71 IDENT NO_KEYWORD +72 77 CHECK RESERVED_KEYWORD +77 78 ASCII_40 NO_KEYWORD +78 79 ASCII_40 NO_KEYWORD +79 84 VALUE_P UNRESERVED_KEYWORD +84 85 ASCII_41 NO_KEYWORD +85 86 ASCII_46 NO_KEYWORD +86 88 IDENT NO_KEYWORD +89 91 LESS_EQUALS NO_KEYWORD +92 93 ASCII_40 NO_KEYWORD +93 98 VALUE_P UNRESERVED_KEYWORD +98 99 ASCII_41 NO_KEYWORD +99 100 ASCII_46 NO_KEYWORD +100 102 IDENT NO_KEYWORD +102 103 ASCII_41 NO_KEYWORD +== 125 +create function read_ordered_int8s(p ordered_int8s) returns int8 as $$ +begin return p.q1 + p.q2; end +$$ language plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 IDENT NO_KEYWORD +37 50 IDENT NO_KEYWORD +50 51 ASCII_41 NO_KEYWORD +52 59 RETURNS UNRESERVED_KEYWORD +60 64 IDENT NO_KEYWORD +65 67 AS RESERVED_KEYWORD +68 103 SCONST NO_KEYWORD +104 112 LANGUAGE UNRESERVED_KEYWORD +113 120 IDENT NO_KEYWORD +== 126 +select read_ordered_int8s(row(1, 2)) +-- +0 6 SELECT RESERVED_KEYWORD +7 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 29 ROW COL_NAME_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 31 ICONST NO_KEYWORD +31 32 ASCII_44 NO_KEYWORD +33 34 ICONST NO_KEYWORD +34 35 ASCII_41 NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +== 127 +select read_ordered_int8s(row(2, 1)) +-- +0 6 SELECT RESERVED_KEYWORD +7 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 29 ROW COL_NAME_KEYWORD +29 30 ASCII_40 NO_KEYWORD +30 31 ICONST NO_KEYWORD +31 32 ASCII_44 NO_KEYWORD +33 34 ICONST NO_KEYWORD +34 35 ASCII_41 NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +== 128 +-- fail + +create function build_ordered_int8s(i int8, j int8) returns ordered_int8s as $$ +begin return row(i,j); end +$$ language plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 IDENT NO_KEYWORD +47 51 IDENT NO_KEYWORD +51 52 ASCII_44 NO_KEYWORD +53 54 IDENT NO_KEYWORD +55 59 IDENT NO_KEYWORD +59 60 ASCII_41 NO_KEYWORD +61 68 RETURNS UNRESERVED_KEYWORD +69 82 IDENT NO_KEYWORD +83 85 AS RESERVED_KEYWORD +86 118 SCONST NO_KEYWORD +119 127 LANGUAGE UNRESERVED_KEYWORD +128 135 IDENT NO_KEYWORD +== 129 +select build_ordered_int8s(1,2) +-- +0 6 SELECT RESERVED_KEYWORD +7 26 IDENT NO_KEYWORD +26 27 ASCII_40 NO_KEYWORD +27 28 ICONST NO_KEYWORD +28 29 ASCII_44 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +== 130 +select build_ordered_int8s(2,1) +-- +0 6 SELECT RESERVED_KEYWORD +7 26 IDENT NO_KEYWORD +26 27 ASCII_40 NO_KEYWORD +27 28 ICONST NO_KEYWORD +28 29 ASCII_44 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +== 131 +-- fail + +create function build_ordered_int8s_2(i int8, j int8) returns ordered_int8s as $$ +declare r record; begin r := row(i,j); return r; end +$$ language plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 46 IDENT NO_KEYWORD +46 47 ASCII_40 NO_KEYWORD +47 48 IDENT NO_KEYWORD +49 53 IDENT NO_KEYWORD +53 54 ASCII_44 NO_KEYWORD +55 56 IDENT NO_KEYWORD +57 61 IDENT NO_KEYWORD +61 62 ASCII_41 NO_KEYWORD +63 70 RETURNS UNRESERVED_KEYWORD +71 84 IDENT NO_KEYWORD +85 87 AS RESERVED_KEYWORD +88 146 SCONST NO_KEYWORD +147 155 LANGUAGE UNRESERVED_KEYWORD +156 163 IDENT NO_KEYWORD +== 132 +select build_ordered_int8s_2(1,2) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_44 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 133 +select build_ordered_int8s_2(2,1) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_44 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 134 +-- fail + +create function build_ordered_int8s_3(i int8, j int8) returns ordered_int8s as $$ +declare r two_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 46 IDENT NO_KEYWORD +46 47 ASCII_40 NO_KEYWORD +47 48 IDENT NO_KEYWORD +49 53 IDENT NO_KEYWORD +53 54 ASCII_44 NO_KEYWORD +55 56 IDENT NO_KEYWORD +57 61 IDENT NO_KEYWORD +61 62 ASCII_41 NO_KEYWORD +63 70 RETURNS UNRESERVED_KEYWORD +71 84 IDENT NO_KEYWORD +85 87 AS RESERVED_KEYWORD +88 149 SCONST NO_KEYWORD +150 158 LANGUAGE UNRESERVED_KEYWORD +159 166 IDENT NO_KEYWORD +== 135 +select build_ordered_int8s_3(1,2) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_44 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 136 +select build_ordered_int8s_3(2,1) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_44 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 137 +-- fail + +create function build_ordered_int8s_4(i int8, j int8) returns ordered_int8s as $$ +declare r ordered_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 46 IDENT NO_KEYWORD +46 47 ASCII_40 NO_KEYWORD +47 48 IDENT NO_KEYWORD +49 53 IDENT NO_KEYWORD +53 54 ASCII_44 NO_KEYWORD +55 56 IDENT NO_KEYWORD +57 61 IDENT NO_KEYWORD +61 62 ASCII_41 NO_KEYWORD +63 70 RETURNS UNRESERVED_KEYWORD +71 84 IDENT NO_KEYWORD +85 87 AS RESERVED_KEYWORD +88 153 SCONST NO_KEYWORD +154 162 LANGUAGE UNRESERVED_KEYWORD +163 170 IDENT NO_KEYWORD +== 138 +select build_ordered_int8s_4(1,2) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_44 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 139 +select build_ordered_int8s_4(2,1) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_44 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 140 +-- fail + +create function build_ordered_int8s_a(i int8, j int8) returns ordered_int8s[] as $$ +begin return array[row(i,j), row(i,j+1)]; end +$$ language plpgsql +-- +0 7 SQL_COMMENT NO_KEYWORD +9 15 CREATE RESERVED_KEYWORD +16 24 FUNCTION UNRESERVED_KEYWORD +25 46 IDENT NO_KEYWORD +46 47 ASCII_40 NO_KEYWORD +47 48 IDENT NO_KEYWORD +49 53 IDENT NO_KEYWORD +53 54 ASCII_44 NO_KEYWORD +55 56 IDENT NO_KEYWORD +57 61 IDENT NO_KEYWORD +61 62 ASCII_41 NO_KEYWORD +63 70 RETURNS UNRESERVED_KEYWORD +71 84 IDENT NO_KEYWORD +84 85 ASCII_91 NO_KEYWORD +85 86 ASCII_93 NO_KEYWORD +87 89 AS RESERVED_KEYWORD +90 141 SCONST NO_KEYWORD +142 150 LANGUAGE UNRESERVED_KEYWORD +151 158 IDENT NO_KEYWORD +== 141 +select build_ordered_int8s_a(1,2) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_44 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 142 +select build_ordered_int8s_a(2,1) +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ICONST NO_KEYWORD +30 31 ASCII_44 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 143 +-- fail + +-- check field assignment +do $$ +declare r ordered_int8s; +begin + r.q1 := null; + r.q2 := 43; + r.q1 := 42; + r.q2 := 41; -- fail +end$$ +-- +0 7 SQL_COMMENT NO_KEYWORD +9 34 SQL_COMMENT NO_KEYWORD +35 37 DO RESERVED_KEYWORD +38 144 SCONST NO_KEYWORD +== 144 +-- check whole-row assignment +do $$ +declare r ordered_int8s; +begin + r := null; + r := row(null,null); + r := row(1,2); + r := row(2,1); -- fail +end$$ +-- +0 29 SQL_COMMENT NO_KEYWORD +30 32 DO RESERVED_KEYWORD +33 151 SCONST NO_KEYWORD +== 145 +-- check assignment in for-loop +do $$ +declare r ordered_int8s; +begin + for r in values (1,2),(3,4),(6,5) loop + raise notice 'r = %', r; + end loop; +end$$ +-- +0 31 SQL_COMMENT NO_KEYWORD +32 34 DO RESERVED_KEYWORD +35 156 SCONST NO_KEYWORD +== 146 +-- check behavior with toastable fields, too + +create type two_texts as (f1 text, f2 text) +-- +0 44 SQL_COMMENT NO_KEYWORD +46 52 CREATE RESERVED_KEYWORD +53 57 TYPE_P UNRESERVED_KEYWORD +58 67 IDENT NO_KEYWORD +68 70 AS RESERVED_KEYWORD +71 72 ASCII_40 NO_KEYWORD +72 74 IDENT NO_KEYWORD +75 79 TEXT_P UNRESERVED_KEYWORD +79 80 ASCII_44 NO_KEYWORD +81 83 IDENT NO_KEYWORD +84 88 TEXT_P UNRESERVED_KEYWORD +88 89 ASCII_41 NO_KEYWORD +== 147 +create domain ordered_texts as two_texts check((value).f1 <= (value).f2) +-- +0 6 CREATE RESERVED_KEYWORD +7 13 DOMAIN_P UNRESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +28 30 AS RESERVED_KEYWORD +31 40 IDENT NO_KEYWORD +41 46 CHECK RESERVED_KEYWORD +46 47 ASCII_40 NO_KEYWORD +47 48 ASCII_40 NO_KEYWORD +48 53 VALUE_P UNRESERVED_KEYWORD +53 54 ASCII_41 NO_KEYWORD +54 55 ASCII_46 NO_KEYWORD +55 57 IDENT NO_KEYWORD +58 60 LESS_EQUALS NO_KEYWORD +61 62 ASCII_40 NO_KEYWORD +62 67 VALUE_P UNRESERVED_KEYWORD +67 68 ASCII_41 NO_KEYWORD +68 69 ASCII_46 NO_KEYWORD +69 71 IDENT NO_KEYWORD +71 72 ASCII_41 NO_KEYWORD +== 148 +create table sometable (id int, a text, b text) +-- +0 6 CREATE RESERVED_KEYWORD +7 12 TABLE RESERVED_KEYWORD +13 22 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 26 IDENT NO_KEYWORD +27 30 INT_P COL_NAME_KEYWORD +30 31 ASCII_44 NO_KEYWORD +32 33 IDENT NO_KEYWORD +34 38 TEXT_P UNRESERVED_KEYWORD +38 39 ASCII_44 NO_KEYWORD +40 41 IDENT NO_KEYWORD +42 46 TEXT_P UNRESERVED_KEYWORD +46 47 ASCII_41 NO_KEYWORD +== 149 +-- b should be compressed, but in-line +insert into sometable values (1, 'a', repeat('ffoob',1000)) +-- +0 38 SQL_COMMENT NO_KEYWORD +39 45 INSERT UNRESERVED_KEYWORD +46 50 INTO RESERVED_KEYWORD +51 60 IDENT NO_KEYWORD +61 67 VALUES COL_NAME_KEYWORD +68 69 ASCII_40 NO_KEYWORD +69 70 ICONST NO_KEYWORD +70 71 ASCII_44 NO_KEYWORD +72 75 SCONST NO_KEYWORD +75 76 ASCII_44 NO_KEYWORD +77 83 IDENT NO_KEYWORD +83 84 ASCII_40 NO_KEYWORD +84 91 SCONST NO_KEYWORD +91 92 ASCII_44 NO_KEYWORD +92 96 ICONST NO_KEYWORD +96 97 ASCII_41 NO_KEYWORD +97 98 ASCII_41 NO_KEYWORD +== 150 +-- this b should be out-of-line +insert into sometable values (2, 'a', repeat('ffoob',100000)) +-- +0 31 SQL_COMMENT NO_KEYWORD +32 38 INSERT UNRESERVED_KEYWORD +39 43 INTO RESERVED_KEYWORD +44 53 IDENT NO_KEYWORD +54 60 VALUES COL_NAME_KEYWORD +61 62 ASCII_40 NO_KEYWORD +62 63 ICONST NO_KEYWORD +63 64 ASCII_44 NO_KEYWORD +65 68 SCONST NO_KEYWORD +68 69 ASCII_44 NO_KEYWORD +70 76 IDENT NO_KEYWORD +76 77 ASCII_40 NO_KEYWORD +77 84 SCONST NO_KEYWORD +84 85 ASCII_44 NO_KEYWORD +85 91 ICONST NO_KEYWORD +91 92 ASCII_41 NO_KEYWORD +92 93 ASCII_41 NO_KEYWORD +== 151 +-- this pair should fail the domain check +insert into sometable values (3, 'z', repeat('ffoob',100000)) +-- +0 41 SQL_COMMENT NO_KEYWORD +42 48 INSERT UNRESERVED_KEYWORD +49 53 INTO RESERVED_KEYWORD +54 63 IDENT NO_KEYWORD +64 70 VALUES COL_NAME_KEYWORD +71 72 ASCII_40 NO_KEYWORD +72 73 ICONST NO_KEYWORD +73 74 ASCII_44 NO_KEYWORD +75 78 SCONST NO_KEYWORD +78 79 ASCII_44 NO_KEYWORD +80 86 IDENT NO_KEYWORD +86 87 ASCII_40 NO_KEYWORD +87 94 SCONST NO_KEYWORD +94 95 ASCII_44 NO_KEYWORD +95 101 ICONST NO_KEYWORD +101 102 ASCII_41 NO_KEYWORD +102 103 ASCII_41 NO_KEYWORD +== 152 +do $$ +declare d ordered_texts; +begin + for d in select a, b from sometable loop + raise notice 'succeeded at "%"', d.f1; + end loop; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 140 SCONST NO_KEYWORD +== 153 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := row(r.a, r.b); + end loop; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 171 SCONST NO_KEYWORD +== 154 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := null; + d.f1 := r.a; + d.f2 := r.b; + end loop; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 196 SCONST NO_KEYWORD +== 155 +-- check coercion of a record result to named-composite function output type +create function compresult(int8) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,$1); return r; end $$ +-- +0 76 SQL_COMMENT NO_KEYWORD +77 83 CREATE RESERVED_KEYWORD +84 92 FUNCTION UNRESERVED_KEYWORD +93 103 IDENT NO_KEYWORD +103 104 ASCII_40 NO_KEYWORD +104 108 IDENT NO_KEYWORD +108 109 ASCII_41 NO_KEYWORD +110 117 RETURNS UNRESERVED_KEYWORD +118 127 IDENT NO_KEYWORD +128 136 LANGUAGE UNRESERVED_KEYWORD +137 144 IDENT NO_KEYWORD +145 147 AS RESERVED_KEYWORD +148 208 SCONST NO_KEYWORD +== 156 +create table two_int8s_tab (f1 two_int8s) +-- +0 6 CREATE RESERVED_KEYWORD +7 12 TABLE RESERVED_KEYWORD +13 26 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 30 IDENT NO_KEYWORD +31 40 IDENT NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +== 157 +insert into two_int8s_tab values (compresult(42)) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 25 IDENT NO_KEYWORD +26 32 VALUES COL_NAME_KEYWORD +33 34 ASCII_40 NO_KEYWORD +34 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 47 ICONST NO_KEYWORD +47 48 ASCII_41 NO_KEYWORD +48 49 ASCII_41 NO_KEYWORD +== 158 +-- reconnect so we lose any local knowledge of anonymous record types +table two_int8s_tab +-- +0 69 SQL_COMMENT NO_KEYWORD +70 75 TABLE RESERVED_KEYWORD +76 89 IDENT NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_simple.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_simple.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_simple.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_simple.test b/parser/testdata/scan/plpgsql_regress/plpgsql_simple.test new file mode 100644 index 0000000..d0d401e --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_simple.test @@ -0,0 +1,337 @@ +== 001 +|-- +-- Tests for plpgsql's handling of "simple" expressions +|-- + +-- Check that changes to an inline-able function are handled correctly +create function simplesql(int) returns int language sql +as 'select $1' +-- +0 2 SQL_COMMENT NO_KEYWORD +3 58 SQL_COMMENT NO_KEYWORD +59 61 SQL_COMMENT NO_KEYWORD +63 133 SQL_COMMENT NO_KEYWORD +134 140 CREATE RESERVED_KEYWORD +141 149 FUNCTION UNRESERVED_KEYWORD +150 159 IDENT NO_KEYWORD +159 160 ASCII_40 NO_KEYWORD +160 163 INT_P COL_NAME_KEYWORD +163 164 ASCII_41 NO_KEYWORD +165 172 RETURNS UNRESERVED_KEYWORD +173 176 INT_P COL_NAME_KEYWORD +177 185 LANGUAGE UNRESERVED_KEYWORD +186 189 SQL_P UNRESERVED_KEYWORD +190 192 AS RESERVED_KEYWORD +193 204 SCONST NO_KEYWORD +== 002 +create function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simplesql(n); + if n = 5 then + create or replace function simplesql(int) returns int language sql + as 'select $1 + 100'; + end if; + end loop; + return sum; +end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ASCII_41 NO_KEYWORD +31 38 RETURNS UNRESERVED_KEYWORD +39 42 INT_P COL_NAME_KEYWORD +43 51 LANGUAGE UNRESERVED_KEYWORD +52 59 IDENT NO_KEYWORD +60 62 AS RESERVED_KEYWORD +63 311 SCONST NO_KEYWORD +== 003 +select simplecaller() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 004 +-- Check that changes in search path are dealt with correctly +create schema simple1 +-- +0 61 SQL_COMMENT NO_KEYWORD +62 68 CREATE RESERVED_KEYWORD +69 75 SCHEMA UNRESERVED_KEYWORD +76 83 IDENT NO_KEYWORD +== 005 +create function simple1.simpletarget(int) returns int language plpgsql +as $$begin return $1; end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 23 IDENT NO_KEYWORD +23 24 ASCII_46 NO_KEYWORD +24 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 40 INT_P COL_NAME_KEYWORD +40 41 ASCII_41 NO_KEYWORD +42 49 RETURNS UNRESERVED_KEYWORD +50 53 INT_P COL_NAME_KEYWORD +54 62 LANGUAGE UNRESERVED_KEYWORD +63 70 IDENT NO_KEYWORD +71 73 AS RESERVED_KEYWORD +74 98 SCONST NO_KEYWORD +== 006 +create function simpletarget(int) returns int language plpgsql +as $$begin return $1 + 100; end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 32 INT_P COL_NAME_KEYWORD +32 33 ASCII_41 NO_KEYWORD +34 41 RETURNS UNRESERVED_KEYWORD +42 45 INT_P COL_NAME_KEYWORD +46 54 LANGUAGE UNRESERVED_KEYWORD +55 62 IDENT NO_KEYWORD +63 65 AS RESERVED_KEYWORD +66 96 SCONST NO_KEYWORD +== 007 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simpletarget(n); + if n = 5 then + set local search_path = 'simple1'; + end if; + end loop; + return sum; +end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 9 OR RESERVED_KEYWORD +10 17 REPLACE UNRESERVED_KEYWORD +18 26 FUNCTION UNRESERVED_KEYWORD +27 39 IDENT NO_KEYWORD +39 40 ASCII_40 NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +42 49 RETURNS UNRESERVED_KEYWORD +50 53 INT_P COL_NAME_KEYWORD +54 62 LANGUAGE UNRESERVED_KEYWORD +63 70 IDENT NO_KEYWORD +71 73 AS RESERVED_KEYWORD +74 265 SCONST NO_KEYWORD +== 008 +select simplecaller() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 009 +-- try it with non-volatile functions, too +alter function simple1.simpletarget(int) immutable +-- +0 42 SQL_COMMENT NO_KEYWORD +43 48 ALTER UNRESERVED_KEYWORD +49 57 FUNCTION UNRESERVED_KEYWORD +58 65 IDENT NO_KEYWORD +65 66 ASCII_46 NO_KEYWORD +66 78 IDENT NO_KEYWORD +78 79 ASCII_40 NO_KEYWORD +79 82 INT_P COL_NAME_KEYWORD +82 83 ASCII_41 NO_KEYWORD +84 93 IMMUTABLE UNRESERVED_KEYWORD +== 010 +alter function simpletarget(int) immutable +-- +0 5 ALTER UNRESERVED_KEYWORD +6 14 FUNCTION UNRESERVED_KEYWORD +15 27 IDENT NO_KEYWORD +27 28 ASCII_40 NO_KEYWORD +28 31 INT_P COL_NAME_KEYWORD +31 32 ASCII_41 NO_KEYWORD +33 42 IMMUTABLE UNRESERVED_KEYWORD +== 011 +select simplecaller() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 012 +-- make sure flushing local caches changes nothing + +select simplecaller() +-- +0 50 SQL_COMMENT NO_KEYWORD +52 58 SELECT RESERVED_KEYWORD +59 71 IDENT NO_KEYWORD +71 72 ASCII_40 NO_KEYWORD +72 73 ASCII_41 NO_KEYWORD +== 013 +-- Check case where first attempt to determine if it's simple fails + +create function simplesql() returns int language sql +as $$select 1 / 0$$ +-- +0 67 SQL_COMMENT NO_KEYWORD +69 75 CREATE RESERVED_KEYWORD +76 84 FUNCTION UNRESERVED_KEYWORD +85 94 IDENT NO_KEYWORD +94 95 ASCII_40 NO_KEYWORD +95 96 ASCII_41 NO_KEYWORD +97 104 RETURNS UNRESERVED_KEYWORD +105 108 INT_P COL_NAME_KEYWORD +109 117 LANGUAGE UNRESERVED_KEYWORD +118 121 SQL_P UNRESERVED_KEYWORD +122 124 AS RESERVED_KEYWORD +125 141 SCONST NO_KEYWORD +== 014 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + select simplesql() into x; + return x; +end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 9 OR RESERVED_KEYWORD +10 17 REPLACE UNRESERVED_KEYWORD +18 26 FUNCTION UNRESERVED_KEYWORD +27 39 IDENT NO_KEYWORD +39 40 ASCII_40 NO_KEYWORD +40 41 ASCII_41 NO_KEYWORD +42 49 RETURNS UNRESERVED_KEYWORD +50 53 INT_P COL_NAME_KEYWORD +54 62 LANGUAGE UNRESERVED_KEYWORD +63 70 IDENT NO_KEYWORD +71 73 AS RESERVED_KEYWORD +74 144 SCONST NO_KEYWORD +== 015 +select simplecaller() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 016 +-- division by zero occurs during simple-expr check + +create or replace function simplesql() returns int language sql +as $$select 2 + 2$$ +-- +0 51 SQL_COMMENT NO_KEYWORD +53 59 CREATE RESERVED_KEYWORD +60 62 OR RESERVED_KEYWORD +63 70 REPLACE UNRESERVED_KEYWORD +71 79 FUNCTION UNRESERVED_KEYWORD +80 89 IDENT NO_KEYWORD +89 90 ASCII_40 NO_KEYWORD +90 91 ASCII_41 NO_KEYWORD +92 99 RETURNS UNRESERVED_KEYWORD +100 103 INT_P COL_NAME_KEYWORD +104 112 LANGUAGE UNRESERVED_KEYWORD +113 116 SQL_P UNRESERVED_KEYWORD +117 119 AS RESERVED_KEYWORD +120 136 SCONST NO_KEYWORD +== 017 +select simplecaller() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 018 +-- Check case where called function changes from non-SRF to SRF (bug #18497) + +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + x := simplesql(); + return x; +end$$ +-- +0 76 SQL_COMMENT NO_KEYWORD +78 84 CREATE RESERVED_KEYWORD +85 87 OR RESERVED_KEYWORD +88 95 REPLACE UNRESERVED_KEYWORD +96 104 FUNCTION UNRESERVED_KEYWORD +105 117 IDENT NO_KEYWORD +117 118 ASCII_40 NO_KEYWORD +118 119 ASCII_41 NO_KEYWORD +120 127 RETURNS UNRESERVED_KEYWORD +128 131 INT_P COL_NAME_KEYWORD +132 140 LANGUAGE UNRESERVED_KEYWORD +141 148 IDENT NO_KEYWORD +149 151 AS RESERVED_KEYWORD +152 213 SCONST NO_KEYWORD +== 019 +select simplecaller() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 020 +drop function simplesql() +-- +0 4 DROP UNRESERVED_KEYWORD +5 13 FUNCTION UNRESERVED_KEYWORD +14 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ASCII_41 NO_KEYWORD +== 021 +create function simplesql() returns setof int language sql +as $$select 22 + 22$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ASCII_41 NO_KEYWORD +28 35 RETURNS UNRESERVED_KEYWORD +36 41 SETOF COL_NAME_KEYWORD +42 45 INT_P COL_NAME_KEYWORD +46 54 LANGUAGE UNRESERVED_KEYWORD +55 58 SQL_P UNRESERVED_KEYWORD +59 61 AS RESERVED_KEYWORD +62 80 SCONST NO_KEYWORD +== 022 +select simplecaller() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 023 +select simplecaller() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 024 +-- Check handling of simple expression in a scrollable cursor (bug #18859) + +do $$ +declare + p_CurData refcursor; + val int; +begin + open p_CurData scroll for select 42; + fetch p_CurData into val; + raise notice 'val = %', val; +end; $$ +-- +0 74 SQL_COMMENT NO_KEYWORD +76 78 DO RESERVED_KEYWORD +79 230 SCONST NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_transaction.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_transaction.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_transaction.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_transaction.test b/parser/testdata/scan/plpgsql_regress/plpgsql_transaction.test new file mode 100644 index 0000000..f61c29b --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_transaction.test @@ -0,0 +1,1403 @@ +== 001 +CREATE TABLE test1 (a int, b text) +-- +0 6 CREATE RESERVED_KEYWORD +7 12 TABLE RESERVED_KEYWORD +13 18 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 IDENT NO_KEYWORD +22 25 INT_P COL_NAME_KEYWORD +25 26 ASCII_44 NO_KEYWORD +27 28 IDENT NO_KEYWORD +29 33 TEXT_P UNRESERVED_KEYWORD +33 34 ASCII_41 NO_KEYWORD +== 002 +CREATE PROCEDURE transaction_test1(x int, y text) +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..x LOOP + INSERT INTO test1 (a, b) VALUES (i, y); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 IDENT NO_KEYWORD +37 40 INT_P COL_NAME_KEYWORD +40 41 ASCII_44 NO_KEYWORD +42 43 IDENT NO_KEYWORD +44 48 TEXT_P UNRESERVED_KEYWORD +48 49 ASCII_41 NO_KEYWORD +50 58 LANGUAGE UNRESERVED_KEYWORD +59 66 IDENT NO_KEYWORD +67 69 AS RESERVED_KEYWORD +70 267 SCONST NO_KEYWORD +== 003 +CALL transaction_test1(9, 'foo') +-- +0 4 CALL UNRESERVED_KEYWORD +5 22 IDENT NO_KEYWORD +22 23 ASCII_40 NO_KEYWORD +23 24 ICONST NO_KEYWORD +24 25 ASCII_44 NO_KEYWORD +26 31 SCONST NO_KEYWORD +31 32 ASCII_41 NO_KEYWORD +== 004 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 005 +TRUNCATE test1 +-- +0 8 TRUNCATE UNRESERVED_KEYWORD +9 14 IDENT NO_KEYWORD +== 006 +DO +LANGUAGE plpgsql +$$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 211 SCONST NO_KEYWORD +== 007 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 008 +-- transaction commands not allowed when called in transaction block +START TRANSACTION +-- +0 68 SQL_COMMENT NO_KEYWORD +69 74 START UNRESERVED_KEYWORD +75 86 TRANSACTION UNRESERVED_KEYWORD +== 009 +CALL transaction_test1(9, 'error') +-- +0 4 CALL UNRESERVED_KEYWORD +5 22 IDENT NO_KEYWORD +22 23 ASCII_40 NO_KEYWORD +23 24 ICONST NO_KEYWORD +24 25 ASCII_44 NO_KEYWORD +26 33 SCONST NO_KEYWORD +33 34 ASCII_41 NO_KEYWORD +== 010 +COMMIT +-- +0 6 COMMIT UNRESERVED_KEYWORD +== 011 +START TRANSACTION +-- +0 5 START UNRESERVED_KEYWORD +6 17 TRANSACTION UNRESERVED_KEYWORD +== 012 +DO LANGUAGE plpgsql $$ BEGIN COMMIT; END $$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 43 SCONST NO_KEYWORD +== 013 +COMMIT +-- +0 6 COMMIT UNRESERVED_KEYWORD +== 014 +TRUNCATE test1 +-- +0 8 TRUNCATE UNRESERVED_KEYWORD +9 14 IDENT NO_KEYWORD +== 015 +-- not allowed in a function +CREATE FUNCTION transaction_test2() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; + RETURN 1; +END +$$ +-- +0 28 SQL_COMMENT NO_KEYWORD +29 35 CREATE RESERVED_KEYWORD +36 44 FUNCTION UNRESERVED_KEYWORD +45 62 IDENT NO_KEYWORD +62 63 ASCII_40 NO_KEYWORD +63 64 ASCII_41 NO_KEYWORD +65 72 RETURNS UNRESERVED_KEYWORD +73 76 INT_P COL_NAME_KEYWORD +77 85 LANGUAGE UNRESERVED_KEYWORD +86 93 IDENT NO_KEYWORD +94 96 AS RESERVED_KEYWORD +97 302 SCONST NO_KEYWORD +== 016 +SELECT transaction_test2() +-- +0 6 SELECT RESERVED_KEYWORD +7 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 017 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 018 +-- also not allowed if procedure is called from a function +CREATE FUNCTION transaction_test3() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, 'error'); + RETURN 1; +END; +$$ +-- +0 58 SQL_COMMENT NO_KEYWORD +59 65 CREATE RESERVED_KEYWORD +66 74 FUNCTION UNRESERVED_KEYWORD +75 92 IDENT NO_KEYWORD +92 93 ASCII_40 NO_KEYWORD +93 94 ASCII_41 NO_KEYWORD +95 102 RETURNS UNRESERVED_KEYWORD +103 106 INT_P COL_NAME_KEYWORD +107 115 LANGUAGE UNRESERVED_KEYWORD +116 123 IDENT NO_KEYWORD +124 126 AS RESERVED_KEYWORD +127 197 SCONST NO_KEYWORD +== 019 +SELECT transaction_test3() +-- +0 6 SELECT RESERVED_KEYWORD +7 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 020 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 021 +-- DO block inside function +CREATE FUNCTION transaction_test4() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'; + RETURN 1; +END; +$$ +-- +0 27 SQL_COMMENT NO_KEYWORD +28 34 CREATE RESERVED_KEYWORD +35 43 FUNCTION UNRESERVED_KEYWORD +44 61 IDENT NO_KEYWORD +61 62 ASCII_40 NO_KEYWORD +62 63 ASCII_41 NO_KEYWORD +64 71 RETURNS UNRESERVED_KEYWORD +72 75 INT_P COL_NAME_KEYWORD +76 84 LANGUAGE UNRESERVED_KEYWORD +85 92 IDENT NO_KEYWORD +93 95 AS RESERVED_KEYWORD +96 187 SCONST NO_KEYWORD +== 022 +SELECT transaction_test4() +-- +0 6 SELECT RESERVED_KEYWORD +7 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 023 +-- proconfig settings currently disallow transaction statements +CREATE PROCEDURE transaction_test5() +LANGUAGE plpgsql +SET work_mem = 555 +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +0 63 SQL_COMMENT NO_KEYWORD +64 70 CREATE RESERVED_KEYWORD +71 80 PROCEDURE UNRESERVED_KEYWORD +81 98 IDENT NO_KEYWORD +98 99 ASCII_40 NO_KEYWORD +99 100 ASCII_41 NO_KEYWORD +101 109 LANGUAGE UNRESERVED_KEYWORD +110 117 IDENT NO_KEYWORD +118 121 SET UNRESERVED_KEYWORD +122 130 IDENT NO_KEYWORD +131 132 ASCII_61 NO_KEYWORD +133 136 ICONST NO_KEYWORD +137 139 AS RESERVED_KEYWORD +140 168 SCONST NO_KEYWORD +== 024 +CALL transaction_test5() +-- +0 4 CALL UNRESERVED_KEYWORD +5 22 IDENT NO_KEYWORD +22 23 ASCII_40 NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 025 +-- SECURITY DEFINER currently disallow transaction statements +CREATE PROCEDURE transaction_test5b() +LANGUAGE plpgsql +SECURITY DEFINER +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +0 61 SQL_COMMENT NO_KEYWORD +62 68 CREATE RESERVED_KEYWORD +69 78 PROCEDURE UNRESERVED_KEYWORD +79 97 IDENT NO_KEYWORD +97 98 ASCII_40 NO_KEYWORD +98 99 ASCII_41 NO_KEYWORD +100 108 LANGUAGE UNRESERVED_KEYWORD +109 116 IDENT NO_KEYWORD +117 125 SECURITY UNRESERVED_KEYWORD +126 133 DEFINER UNRESERVED_KEYWORD +134 136 AS RESERVED_KEYWORD +137 165 SCONST NO_KEYWORD +== 026 +CALL transaction_test5b() +-- +0 4 CALL UNRESERVED_KEYWORD +5 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ASCII_41 NO_KEYWORD +== 027 +TRUNCATE test1 +-- +0 8 TRUNCATE UNRESERVED_KEYWORD +9 14 IDENT NO_KEYWORD +== 028 +-- nested procedure calls +CREATE PROCEDURE transaction_test6(c text) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, c); +END; +$$ +-- +0 25 SQL_COMMENT NO_KEYWORD +26 32 CREATE RESERVED_KEYWORD +33 42 PROCEDURE UNRESERVED_KEYWORD +43 60 IDENT NO_KEYWORD +60 61 ASCII_40 NO_KEYWORD +61 62 IDENT NO_KEYWORD +63 67 TEXT_P UNRESERVED_KEYWORD +67 68 ASCII_41 NO_KEYWORD +69 77 LANGUAGE UNRESERVED_KEYWORD +78 85 IDENT NO_KEYWORD +86 88 AS RESERVED_KEYWORD +89 139 SCONST NO_KEYWORD +== 029 +CALL transaction_test6('bar') +-- +0 4 CALL UNRESERVED_KEYWORD +5 22 IDENT NO_KEYWORD +22 23 ASCII_40 NO_KEYWORD +23 28 SCONST NO_KEYWORD +28 29 ASCII_41 NO_KEYWORD +== 030 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 031 +TRUNCATE test1 +-- +0 8 TRUNCATE UNRESERVED_KEYWORD +9 14 IDENT NO_KEYWORD +== 032 +CREATE PROCEDURE transaction_test7() +LANGUAGE plpgsql +AS $$ +BEGIN + DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'; +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +37 45 LANGUAGE UNRESERVED_KEYWORD +46 53 IDENT NO_KEYWORD +54 56 AS RESERVED_KEYWORD +57 132 SCONST NO_KEYWORD +== 033 +CALL transaction_test7() +-- +0 4 CALL UNRESERVED_KEYWORD +5 22 IDENT NO_KEYWORD +22 23 ASCII_40 NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 034 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 035 +CREATE PROCEDURE transaction_test8() +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'CALL transaction_test1(10, $x$baz$x$)'; +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +37 45 LANGUAGE UNRESERVED_KEYWORD +46 53 IDENT NO_KEYWORD +54 56 AS RESERVED_KEYWORD +57 126 SCONST NO_KEYWORD +== 036 +CALL transaction_test8() +-- +0 4 CALL UNRESERVED_KEYWORD +5 22 IDENT NO_KEYWORD +22 23 ASCII_40 NO_KEYWORD +23 24 ASCII_41 NO_KEYWORD +== 037 +-- commit inside cursor loop +CREATE TABLE test2 (x int) +-- +0 28 SQL_COMMENT NO_KEYWORD +29 35 CREATE RESERVED_KEYWORD +36 41 TABLE RESERVED_KEYWORD +42 47 IDENT NO_KEYWORD +48 49 ASCII_40 NO_KEYWORD +49 50 IDENT NO_KEYWORD +51 54 INT_P COL_NAME_KEYWORD +54 55 ASCII_41 NO_KEYWORD +== 038 +INSERT INTO test2 VALUES (0), (1), (2), (3), (4) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 17 IDENT NO_KEYWORD +18 24 VALUES COL_NAME_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ICONST NO_KEYWORD +27 28 ASCII_41 NO_KEYWORD +28 29 ASCII_44 NO_KEYWORD +30 31 ASCII_40 NO_KEYWORD +31 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +33 34 ASCII_44 NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 37 ICONST NO_KEYWORD +37 38 ASCII_41 NO_KEYWORD +38 39 ASCII_44 NO_KEYWORD +40 41 ASCII_40 NO_KEYWORD +41 42 ICONST NO_KEYWORD +42 43 ASCII_41 NO_KEYWORD +43 44 ASCII_44 NO_KEYWORD +45 46 ASCII_40 NO_KEYWORD +46 47 ICONST NO_KEYWORD +47 48 ASCII_41 NO_KEYWORD +== 039 +TRUNCATE test1 +-- +0 8 TRUNCATE UNRESERVED_KEYWORD +9 14 IDENT NO_KEYWORD +== 040 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + COMMIT; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 181 SCONST NO_KEYWORD +== 041 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 042 +-- check that this doesn't leak a holdable portal +SELECT * FROM pg_cursors +-- +0 49 SQL_COMMENT NO_KEYWORD +50 56 SELECT RESERVED_KEYWORD +57 58 ASCII_42 NO_KEYWORD +59 63 FROM RESERVED_KEYWORD +64 74 IDENT NO_KEYWORD +== 043 +-- error in cursor loop with commit +TRUNCATE test1 +-- +0 35 SQL_COMMENT NO_KEYWORD +36 44 TRUNCATE UNRESERVED_KEYWORD +45 50 IDENT NO_KEYWORD +== 044 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (12/(r.x-2)); + COMMIT; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 188 SCONST NO_KEYWORD +== 045 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 046 +SELECT * FROM pg_cursors +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 24 IDENT NO_KEYWORD +== 047 +-- rollback inside cursor loop +TRUNCATE test1 +-- +0 30 SQL_COMMENT NO_KEYWORD +31 39 TRUNCATE UNRESERVED_KEYWORD +40 45 IDENT NO_KEYWORD +== 048 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 183 SCONST NO_KEYWORD +== 049 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 050 +SELECT * FROM pg_cursors +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 24 IDENT NO_KEYWORD +== 051 +-- first commit then rollback inside cursor loop +TRUNCATE test1 +-- +0 48 SQL_COMMENT NO_KEYWORD +49 57 TRUNCATE UNRESERVED_KEYWORD +58 63 IDENT NO_KEYWORD +== 052 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + IF r.x % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 264 SCONST NO_KEYWORD +== 053 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 054 +SELECT * FROM pg_cursors +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 24 IDENT NO_KEYWORD +== 055 +-- rollback inside cursor loop +TRUNCATE test1 +-- +0 30 SQL_COMMENT NO_KEYWORD +31 39 TRUNCATE UNRESERVED_KEYWORD +40 45 IDENT NO_KEYWORD +== 056 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 191 SCONST NO_KEYWORD +== 057 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 058 +SELECT * FROM test2 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 059 +SELECT * FROM pg_cursors +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 24 IDENT NO_KEYWORD +== 060 +-- interaction of FOR UPDATE cursor with subsequent updates (bug #17050) +TRUNCATE test1 +-- +0 72 SQL_COMMENT NO_KEYWORD +73 81 TRUNCATE UNRESERVED_KEYWORD +82 87 IDENT NO_KEYWORD +== 061 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 17 IDENT NO_KEYWORD +18 24 VALUES COL_NAME_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ICONST NO_KEYWORD +27 28 ASCII_44 NO_KEYWORD +28 33 SCONST NO_KEYWORD +33 34 ASCII_41 NO_KEYWORD +34 35 ASCII_44 NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 ICONST NO_KEYWORD +38 39 ASCII_44 NO_KEYWORD +39 44 SCONST NO_KEYWORD +44 45 ASCII_41 NO_KEYWORD +45 46 ASCII_44 NO_KEYWORD +47 48 ASCII_40 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +50 57 SCONST NO_KEYWORD +57 58 ASCII_41 NO_KEYWORD +== 062 +DO LANGUAGE plpgsql $$ +DECLARE + l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE; +BEGIN + FOR r IN l_cur LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 216 SCONST NO_KEYWORD +== 063 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 064 +SELECT * FROM pg_cursors +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 24 IDENT NO_KEYWORD +== 065 +-- like bug #17050, but with implicit cursor +TRUNCATE test1 +-- +0 44 SQL_COMMENT NO_KEYWORD +45 53 TRUNCATE UNRESERVED_KEYWORD +54 59 IDENT NO_KEYWORD +== 066 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 17 IDENT NO_KEYWORD +18 24 VALUES COL_NAME_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ICONST NO_KEYWORD +27 28 ASCII_44 NO_KEYWORD +28 33 SCONST NO_KEYWORD +33 34 ASCII_41 NO_KEYWORD +34 35 ASCII_44 NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 38 ICONST NO_KEYWORD +38 39 ASCII_44 NO_KEYWORD +39 44 SCONST NO_KEYWORD +44 45 ASCII_41 NO_KEYWORD +45 46 ASCII_44 NO_KEYWORD +47 48 ASCII_40 NO_KEYWORD +48 49 ICONST NO_KEYWORD +49 50 ASCII_44 NO_KEYWORD +50 57 SCONST NO_KEYWORD +57 58 ASCII_41 NO_KEYWORD +== 067 +DO LANGUAGE plpgsql $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT a FROM test1 FOR UPDATE LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 187 SCONST NO_KEYWORD +== 068 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 069 +SELECT * FROM pg_cursors +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 24 IDENT NO_KEYWORD +== 070 +-- commit inside block with exception handler +TRUNCATE test1 +-- +0 45 SQL_COMMENT NO_KEYWORD +46 54 TRUNCATE UNRESERVED_KEYWORD +55 60 IDENT NO_KEYWORD +== 071 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + COMMIT; + INSERT INTO test1 (a) VALUES (1/0); + COMMIT; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 274 SCONST NO_KEYWORD +== 072 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 073 +-- rollback inside block with exception handler +TRUNCATE test1 +-- +0 47 SQL_COMMENT NO_KEYWORD +48 56 TRUNCATE UNRESERVED_KEYWORD +57 62 IDENT NO_KEYWORD +== 074 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + ROLLBACK; + INSERT INTO test1 (a) VALUES (1/0); + ROLLBACK; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 278 SCONST NO_KEYWORD +== 075 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 076 +-- test commit/rollback inside exception handler, too +TRUNCATE test1 +-- +0 53 SQL_COMMENT NO_KEYWORD +54 62 TRUNCATE UNRESERVED_KEYWORD +63 68 IDENT NO_KEYWORD +== 077 +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 1..10 LOOP + BEGIN + INSERT INTO test1 VALUES (i, 'good'); + INSERT INTO test1 VALUES (i/0, 'bad'); + EXCEPTION + WHEN division_by_zero THEN + INSERT INTO test1 VALUES (i, 'exception'); + IF (i % 3) > 0 THEN COMMIT; ELSE ROLLBACK; END IF; + END; + END LOOP; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 359 SCONST NO_KEYWORD +== 078 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 079 +-- detoast result of simple expression after commit +CREATE TEMP TABLE test4(f1 text) +-- +0 51 SQL_COMMENT NO_KEYWORD +52 58 CREATE RESERVED_KEYWORD +59 63 TEMP UNRESERVED_KEYWORD +64 69 TABLE RESERVED_KEYWORD +70 75 IDENT NO_KEYWORD +75 76 ASCII_40 NO_KEYWORD +76 78 IDENT NO_KEYWORD +79 83 TEXT_P UNRESERVED_KEYWORD +83 84 ASCII_41 NO_KEYWORD +== 080 +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE EXTERNAL +-- +0 5 ALTER UNRESERVED_KEYWORD +6 11 TABLE RESERVED_KEYWORD +12 17 IDENT NO_KEYWORD +18 23 ALTER UNRESERVED_KEYWORD +24 30 COLUMN RESERVED_KEYWORD +31 33 IDENT NO_KEYWORD +34 37 SET UNRESERVED_KEYWORD +38 45 STORAGE UNRESERVED_KEYWORD +46 54 EXTERNAL UNRESERVED_KEYWORD +== 081 +-- disable compression +INSERT INTO test4 SELECT repeat('xyzzy', 2000) +-- +0 22 SQL_COMMENT NO_KEYWORD +23 29 INSERT UNRESERVED_KEYWORD +30 34 INTO RESERVED_KEYWORD +35 40 IDENT NO_KEYWORD +41 47 SELECT RESERVED_KEYWORD +48 54 IDENT NO_KEYWORD +54 55 ASCII_40 NO_KEYWORD +55 62 SCONST NO_KEYWORD +62 63 ASCII_44 NO_KEYWORD +64 68 ICONST NO_KEYWORD +68 69 ASCII_41 NO_KEYWORD +== 082 +-- immutable mark is a bit of a lie, but it serves to make call a simple expr +-- that will return a still-toasted value +CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql +AS 'select f1 from test4' IMMUTABLE +-- +0 77 SQL_COMMENT NO_KEYWORD +78 119 SQL_COMMENT NO_KEYWORD +120 126 CREATE RESERVED_KEYWORD +127 135 FUNCTION UNRESERVED_KEYWORD +136 147 IDENT NO_KEYWORD +147 148 ASCII_40 NO_KEYWORD +148 149 IDENT NO_KEYWORD +150 153 INT_P COL_NAME_KEYWORD +153 154 ASCII_41 NO_KEYWORD +155 162 RETURNS UNRESERVED_KEYWORD +163 167 TEXT_P UNRESERVED_KEYWORD +168 176 LANGUAGE UNRESERVED_KEYWORD +177 180 SQL_P UNRESERVED_KEYWORD +181 183 AS RESERVED_KEYWORD +184 206 SCONST NO_KEYWORD +207 216 IMMUTABLE UNRESERVED_KEYWORD +== 083 +DO $$ +declare x text; +begin + for i in 1..3 loop + x := data_source(i); + commit; + end loop; + raise notice 'length(x) = %', length(x); +end $$ +-- +0 2 DO RESERVED_KEYWORD +3 147 SCONST NO_KEYWORD +== 084 +-- operations on composite types vs. internal transactions +DO LANGUAGE plpgsql $$ +declare + c test1 := row(42, 'hello'); + r bool; +begin + for i in 1..3 loop + r := c is not null; + raise notice 'r = %', r; + commit; + end loop; + for i in 1..3 loop + r := c is null; + raise notice 'r = %', r; + rollback; + end loop; +end +$$ +-- +0 58 SQL_COMMENT NO_KEYWORD +59 61 DO RESERVED_KEYWORD +62 70 LANGUAGE UNRESERVED_KEYWORD +71 78 IDENT NO_KEYWORD +79 337 SCONST NO_KEYWORD +== 085 +-- COMMIT failures +DO LANGUAGE plpgsql $$ +BEGIN + CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + INSERT INTO test3 (y) VALUES (2); + COMMIT; + INSERT INTO test3 (y) VALUES (3); -- won't get here +END; +$$ +-- +0 18 SQL_COMMENT NO_KEYWORD +19 21 DO RESERVED_KEYWORD +22 30 LANGUAGE UNRESERVED_KEYWORD +31 38 IDENT NO_KEYWORD +39 331 SCONST NO_KEYWORD +== 086 +SELECT * FROM test3 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 087 +-- failure while trying to persist a cursor across a transaction (bug #15703) +CREATE PROCEDURE cursor_fail_during_commit() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + COMMIT; + END LOOP; + END; +$$ +-- +0 77 SQL_COMMENT NO_KEYWORD +78 84 CREATE RESERVED_KEYWORD +85 94 PROCEDURE UNRESERVED_KEYWORD +95 120 IDENT NO_KEYWORD +120 121 ASCII_40 NO_KEYWORD +121 122 ASCII_41 NO_KEYWORD +124 132 LANGUAGE UNRESERVED_KEYWORD +133 140 IDENT NO_KEYWORD +141 143 AS RESERVED_KEYWORD +144 318 SCONST NO_KEYWORD +== 088 +TRUNCATE test1 +-- +0 8 TRUNCATE UNRESERVED_KEYWORD +9 14 IDENT NO_KEYWORD +== 089 +CALL cursor_fail_during_commit() +-- +0 4 CALL UNRESERVED_KEYWORD +5 30 IDENT NO_KEYWORD +30 31 ASCII_40 NO_KEYWORD +31 32 ASCII_41 NO_KEYWORD +== 090 +-- note that error occurs during first COMMIT, hence nothing is in test1 +SELECT count(*) FROM test1 +-- +0 72 SQL_COMMENT NO_KEYWORD +73 79 SELECT RESERVED_KEYWORD +80 85 IDENT NO_KEYWORD +85 86 ASCII_40 NO_KEYWORD +86 87 ASCII_42 NO_KEYWORD +87 88 ASCII_41 NO_KEYWORD +89 93 FROM RESERVED_KEYWORD +94 99 IDENT NO_KEYWORD +== 091 +CREATE PROCEDURE cursor_fail_during_rollback() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + ROLLBACK; + END LOOP; + END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 44 IDENT NO_KEYWORD +44 45 ASCII_40 NO_KEYWORD +45 46 ASCII_41 NO_KEYWORD +48 56 LANGUAGE UNRESERVED_KEYWORD +57 64 IDENT NO_KEYWORD +65 67 AS RESERVED_KEYWORD +68 244 SCONST NO_KEYWORD +== 092 +TRUNCATE test1 +-- +0 8 TRUNCATE UNRESERVED_KEYWORD +9 14 IDENT NO_KEYWORD +== 093 +CALL cursor_fail_during_rollback() +-- +0 4 CALL UNRESERVED_KEYWORD +5 32 IDENT NO_KEYWORD +32 33 ASCII_40 NO_KEYWORD +33 34 ASCII_41 NO_KEYWORD +== 094 +SELECT count(*) FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 12 IDENT NO_KEYWORD +12 13 ASCII_40 NO_KEYWORD +13 14 ASCII_42 NO_KEYWORD +14 15 ASCII_41 NO_KEYWORD +16 20 FROM RESERVED_KEYWORD +21 26 IDENT NO_KEYWORD +== 095 +-- SET TRANSACTION +DO LANGUAGE plpgsql $$ +BEGIN + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; +END; +$$ +-- +0 18 SQL_COMMENT NO_KEYWORD +19 21 DO RESERVED_KEYWORD +22 30 LANGUAGE UNRESERVED_KEYWORD +31 38 IDENT NO_KEYWORD +39 425 SCONST NO_KEYWORD +== 096 +-- error cases +DO LANGUAGE plpgsql $$ +BEGIN + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +END; +$$ +-- +0 14 SQL_COMMENT NO_KEYWORD +15 17 DO RESERVED_KEYWORD +18 26 LANGUAGE UNRESERVED_KEYWORD +27 34 IDENT NO_KEYWORD +35 104 SCONST NO_KEYWORD +== 097 +DO LANGUAGE plpgsql $$ +BEGIN + SAVEPOINT foo; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 55 SCONST NO_KEYWORD +== 098 +DO LANGUAGE plpgsql $$ +BEGIN + EXECUTE 'COMMIT'; +END; +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 58 SCONST NO_KEYWORD +== 099 +-- snapshot handling test +TRUNCATE test2 +-- +0 25 SQL_COMMENT NO_KEYWORD +26 34 TRUNCATE UNRESERVED_KEYWORD +35 40 IDENT NO_KEYWORD +== 100 +CREATE PROCEDURE transaction_test9() +LANGUAGE SQL +AS $$ +INSERT INTO test2 VALUES (42); +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +37 45 LANGUAGE UNRESERVED_KEYWORD +46 49 SQL_P UNRESERVED_KEYWORD +50 52 AS RESERVED_KEYWORD +53 89 SCONST NO_KEYWORD +== 101 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + CALL transaction_test9(); +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 75 SCONST NO_KEYWORD +== 102 +SELECT * FROM test2 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 103 +-- another snapshot handling case: argument expressions of a CALL need +-- to be evaluated with an up-to-date snapshot +CREATE FUNCTION report_count() RETURNS int +STABLE LANGUAGE sql +AS $$ SELECT COUNT(*) FROM test2 $$ +-- +0 70 SQL_COMMENT NO_KEYWORD +71 117 SQL_COMMENT NO_KEYWORD +118 124 CREATE RESERVED_KEYWORD +125 133 FUNCTION UNRESERVED_KEYWORD +134 146 IDENT NO_KEYWORD +146 147 ASCII_40 NO_KEYWORD +147 148 ASCII_41 NO_KEYWORD +149 156 RETURNS UNRESERVED_KEYWORD +157 160 INT_P COL_NAME_KEYWORD +161 167 STABLE UNRESERVED_KEYWORD +168 176 LANGUAGE UNRESERVED_KEYWORD +177 180 SQL_P UNRESERVED_KEYWORD +181 183 AS RESERVED_KEYWORD +184 216 SCONST NO_KEYWORD +== 104 +CREATE PROCEDURE transaction_test9b(cnt int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'count = %', cnt; +END +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 35 IDENT NO_KEYWORD +35 36 ASCII_40 NO_KEYWORD +36 39 IDENT NO_KEYWORD +40 43 INT_P COL_NAME_KEYWORD +43 44 ASCII_41 NO_KEYWORD +45 53 LANGUAGE UNRESERVED_KEYWORD +54 61 IDENT NO_KEYWORD +62 64 AS RESERVED_KEYWORD +65 113 SCONST NO_KEYWORD +== 105 +DO $$ +BEGIN + CALL transaction_test9b(report_count()); + INSERT INTO test2 VALUES(43); + CALL transaction_test9b(report_count()); +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 142 SCONST NO_KEYWORD +== 106 +-- Test transaction in procedure with output parameters. This uses a +-- different portal strategy and different code paths in pquery.c. +CREATE PROCEDURE transaction_test10a(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x + 1; + COMMIT; +END; +$$ +-- +0 69 SQL_COMMENT NO_KEYWORD +70 136 SQL_COMMENT NO_KEYWORD +137 143 CREATE RESERVED_KEYWORD +144 153 PROCEDURE UNRESERVED_KEYWORD +154 173 IDENT NO_KEYWORD +173 174 ASCII_40 NO_KEYWORD +174 179 INOUT COL_NAME_KEYWORD +180 181 IDENT NO_KEYWORD +182 185 INT_P COL_NAME_KEYWORD +185 186 ASCII_41 NO_KEYWORD +187 195 LANGUAGE UNRESERVED_KEYWORD +196 203 IDENT NO_KEYWORD +204 206 AS RESERVED_KEYWORD +207 247 SCONST NO_KEYWORD +== 107 +CALL transaction_test10a(10) +-- +0 4 CALL UNRESERVED_KEYWORD +5 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 27 ICONST NO_KEYWORD +27 28 ASCII_41 NO_KEYWORD +== 108 +CREATE PROCEDURE transaction_test10b(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x - 1; + ROLLBACK; +END; +$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 16 PROCEDURE UNRESERVED_KEYWORD +17 36 IDENT NO_KEYWORD +36 37 ASCII_40 NO_KEYWORD +37 42 INOUT COL_NAME_KEYWORD +43 44 IDENT NO_KEYWORD +45 48 INT_P COL_NAME_KEYWORD +48 49 ASCII_41 NO_KEYWORD +50 58 LANGUAGE UNRESERVED_KEYWORD +59 66 IDENT NO_KEYWORD +67 69 AS RESERVED_KEYWORD +70 112 SCONST NO_KEYWORD +== 109 +CALL transaction_test10b(10) +-- +0 4 CALL UNRESERVED_KEYWORD +5 24 IDENT NO_KEYWORD +24 25 ASCII_40 NO_KEYWORD +25 27 ICONST NO_KEYWORD +27 28 ASCII_41 NO_KEYWORD +== 110 +-- transaction timestamp vs. statement timestamp +CREATE PROCEDURE transaction_test11() +LANGUAGE plpgsql +AS $$ +DECLARE + s1 timestamp with time zone; + s2 timestamp with time zone; + s3 timestamp with time zone; + t1 timestamp with time zone; + t2 timestamp with time zone; + t3 timestamp with time zone; +BEGIN + s1 := statement_timestamp(); + t1 := transaction_timestamp(); + ASSERT s1 = t1; + PERFORM pg_sleep(0.001); + COMMIT; + s2 := statement_timestamp(); + t2 := transaction_timestamp(); + ASSERT s2 = s1; + ASSERT t2 > t1; + PERFORM pg_sleep(0.001); + ROLLBACK; + s3 := statement_timestamp(); + t3 := transaction_timestamp(); + ASSERT s3 = s1; + ASSERT t3 > t2; +END; +$$ +-- +0 48 SQL_COMMENT NO_KEYWORD +49 55 CREATE RESERVED_KEYWORD +56 65 PROCEDURE UNRESERVED_KEYWORD +66 84 IDENT NO_KEYWORD +84 85 ASCII_40 NO_KEYWORD +85 86 ASCII_41 NO_KEYWORD +87 95 LANGUAGE UNRESERVED_KEYWORD +96 103 IDENT NO_KEYWORD +104 106 AS RESERVED_KEYWORD +107 675 SCONST NO_KEYWORD +== 111 +CALL transaction_test11() +-- +0 4 CALL UNRESERVED_KEYWORD +5 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ASCII_41 NO_KEYWORD +== 112 +-- transaction chain + +TRUNCATE test1 +-- +0 20 SQL_COMMENT NO_KEYWORD +22 30 TRUNCATE UNRESERVED_KEYWORD +31 36 IDENT NO_KEYWORD +== 113 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + FOR i IN 0..3 LOOP + RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT AND CHAIN; + ELSE + ROLLBACK AND CHAIN; + END IF; + END LOOP; +END +$$ +-- +0 2 DO RESERVED_KEYWORD +3 11 LANGUAGE UNRESERVED_KEYWORD +12 19 IDENT NO_KEYWORD +20 388 SCONST NO_KEYWORD +== 114 +SELECT * FROM test1 +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 19 IDENT NO_KEYWORD +== 115 +DROP TABLE test1 +-- +0 4 DROP UNRESERVED_KEYWORD +5 10 TABLE RESERVED_KEYWORD +11 16 IDENT NO_KEYWORD +== 116 +DROP TABLE test2 +-- +0 4 DROP UNRESERVED_KEYWORD +5 10 TABLE RESERVED_KEYWORD +11 16 IDENT NO_KEYWORD +== 117 +DROP TABLE test3 +-- +0 4 DROP UNRESERVED_KEYWORD +5 10 TABLE RESERVED_KEYWORD +11 16 IDENT NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_trap.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_trap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_trap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_trap.test b/parser/testdata/scan/plpgsql_regress/plpgsql_trap.test new file mode 100644 index 0000000..8d0a560 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_trap.test @@ -0,0 +1,531 @@ +== 001 +|-- +-- Test error trapping +|-- + +create function trap_zero_divide(int) returns int as $$ +declare x int; + sx smallint; +begin + begin -- start a subtransaction + raise notice 'should see this'; + x := 100 / $1; + raise notice 'should see this only if % <> 0', $1; + sx := $1; + raise notice 'should see this only if % fits in smallint', $1; + if $1 < 0 then + raise exception '% is less than zero', $1; + end if; + exception + when division_by_zero then + raise notice 'caught division_by_zero'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE then + raise notice 'caught numeric_value_out_of_range'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +0 2 SQL_COMMENT NO_KEYWORD +3 25 SQL_COMMENT NO_KEYWORD +26 28 SQL_COMMENT NO_KEYWORD +30 36 CREATE RESERVED_KEYWORD +37 45 FUNCTION UNRESERVED_KEYWORD +46 62 IDENT NO_KEYWORD +62 63 ASCII_40 NO_KEYWORD +63 66 INT_P COL_NAME_KEYWORD +66 67 ASCII_41 NO_KEYWORD +68 75 RETURNS UNRESERVED_KEYWORD +76 79 INT_P COL_NAME_KEYWORD +80 82 AS RESERVED_KEYWORD +83 629 SCONST NO_KEYWORD +630 638 LANGUAGE UNRESERVED_KEYWORD +639 646 IDENT NO_KEYWORD +== 002 +select trap_zero_divide(50) +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 26 ICONST NO_KEYWORD +26 27 ASCII_41 NO_KEYWORD +== 003 +select trap_zero_divide(0) +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ICONST NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 004 +select trap_zero_divide(100000) +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 30 ICONST NO_KEYWORD +30 31 ASCII_41 NO_KEYWORD +== 005 +select trap_zero_divide(-100) +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ASCII_45 NO_KEYWORD +25 28 ICONST NO_KEYWORD +28 29 ASCII_41 NO_KEYWORD +== 006 +create table match_source as + select x as id, x*10 as data, x/10 as ten from generate_series(1,100) x +-- +0 6 CREATE RESERVED_KEYWORD +7 12 TABLE RESERVED_KEYWORD +13 25 IDENT NO_KEYWORD +26 28 AS RESERVED_KEYWORD +31 37 SELECT RESERVED_KEYWORD +38 39 IDENT NO_KEYWORD +40 42 AS RESERVED_KEYWORD +43 45 IDENT NO_KEYWORD +45 46 ASCII_44 NO_KEYWORD +47 48 IDENT NO_KEYWORD +48 49 ASCII_42 NO_KEYWORD +49 51 ICONST NO_KEYWORD +52 54 AS RESERVED_KEYWORD +55 59 DATA_P UNRESERVED_KEYWORD +59 60 ASCII_44 NO_KEYWORD +61 62 IDENT NO_KEYWORD +62 63 ASCII_47 NO_KEYWORD +63 65 ICONST NO_KEYWORD +66 68 AS RESERVED_KEYWORD +69 72 IDENT NO_KEYWORD +73 77 FROM RESERVED_KEYWORD +78 93 IDENT NO_KEYWORD +93 94 ASCII_40 NO_KEYWORD +94 95 ICONST NO_KEYWORD +95 96 ASCII_44 NO_KEYWORD +96 99 ICONST NO_KEYWORD +99 100 ASCII_41 NO_KEYWORD +101 102 IDENT NO_KEYWORD +== 007 +create function trap_matching_test(int) returns int as $$ +declare x int; + sx smallint; + y int; +begin + begin -- start a subtransaction + x := 100 / $1; + sx := $1; + select into y data from match_source where id = + (select id from match_source b where ten = $1); + exception + when data_exception then -- category match + raise notice 'caught data_exception'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then + raise notice 'caught numeric_value_out_of_range or cardinality_violation'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 38 INT_P COL_NAME_KEYWORD +38 39 ASCII_41 NO_KEYWORD +40 47 RETURNS UNRESERVED_KEYWORD +48 51 INT_P COL_NAME_KEYWORD +52 54 AS RESERVED_KEYWORD +55 550 SCONST NO_KEYWORD +551 559 LANGUAGE UNRESERVED_KEYWORD +560 567 IDENT NO_KEYWORD +== 008 +select trap_matching_test(50) +-- +0 6 SELECT RESERVED_KEYWORD +7 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 28 ICONST NO_KEYWORD +28 29 ASCII_41 NO_KEYWORD +== 009 +select trap_matching_test(0) +-- +0 6 SELECT RESERVED_KEYWORD +7 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ICONST NO_KEYWORD +27 28 ASCII_41 NO_KEYWORD +== 010 +select trap_matching_test(100000) +-- +0 6 SELECT RESERVED_KEYWORD +7 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 32 ICONST NO_KEYWORD +32 33 ASCII_41 NO_KEYWORD +== 011 +select trap_matching_test(1) +-- +0 6 SELECT RESERVED_KEYWORD +7 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ICONST NO_KEYWORD +27 28 ASCII_41 NO_KEYWORD +== 012 +create temp table foo (f1 int) +-- +0 6 CREATE RESERVED_KEYWORD +7 11 TEMP UNRESERVED_KEYWORD +12 17 TABLE RESERVED_KEYWORD +18 21 IDENT NO_KEYWORD +22 23 ASCII_40 NO_KEYWORD +23 25 IDENT NO_KEYWORD +26 29 INT_P COL_NAME_KEYWORD +29 30 ASCII_41 NO_KEYWORD +== 013 +create function subxact_rollback_semantics() returns int as $$ +declare x int; +begin + x := 1; + insert into foo values(x); + begin + x := x + 1; + insert into foo values(x); + raise exception 'inner'; + exception + when others then + x := x * 10; + end; + insert into foo values(x); + return x; +end$$ language plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 42 IDENT NO_KEYWORD +42 43 ASCII_40 NO_KEYWORD +43 44 ASCII_41 NO_KEYWORD +45 52 RETURNS UNRESERVED_KEYWORD +53 56 INT_P COL_NAME_KEYWORD +57 59 AS RESERVED_KEYWORD +60 312 SCONST NO_KEYWORD +313 321 LANGUAGE UNRESERVED_KEYWORD +322 329 IDENT NO_KEYWORD +== 014 +select subxact_rollback_semantics() +-- +0 6 SELECT RESERVED_KEYWORD +7 33 IDENT NO_KEYWORD +33 34 ASCII_40 NO_KEYWORD +34 35 ASCII_41 NO_KEYWORD +== 015 +select * from foo +-- +0 6 SELECT RESERVED_KEYWORD +7 8 ASCII_42 NO_KEYWORD +9 13 FROM RESERVED_KEYWORD +14 17 IDENT NO_KEYWORD +== 016 +drop table foo +-- +0 4 DROP UNRESERVED_KEYWORD +5 10 TABLE RESERVED_KEYWORD +11 14 IDENT NO_KEYWORD +== 017 +create function trap_timeout() returns void as $$ +begin + declare x int; + begin + -- we assume this will take longer than 1 second: + select count(*) into x from generate_series(1, 1_000_000_000_000); + exception + when others then + raise notice 'caught others?'; + when query_canceled then + raise notice 'nyeah nyeah, can''t stop me'; + end; + -- Abort transaction to abandon the statement_timeout setting. Otherwise, + -- the next top-level statement would be vulnerable to the timeout. + raise exception 'end of function'; +end$$ language plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ASCII_41 NO_KEYWORD +31 38 RETURNS UNRESERVED_KEYWORD +39 43 IDENT NO_KEYWORD +44 46 AS RESERVED_KEYWORD +47 551 SCONST NO_KEYWORD +552 560 LANGUAGE UNRESERVED_KEYWORD +561 568 IDENT NO_KEYWORD +== 018 +begin +-- +0 5 BEGIN_P UNRESERVED_KEYWORD +== 019 +set statement_timeout to 1000 +-- +0 3 SET UNRESERVED_KEYWORD +4 21 IDENT NO_KEYWORD +22 24 TO RESERVED_KEYWORD +25 29 ICONST NO_KEYWORD +== 020 +select trap_timeout() +-- +0 6 SELECT RESERVED_KEYWORD +7 19 IDENT NO_KEYWORD +19 20 ASCII_40 NO_KEYWORD +20 21 ASCII_41 NO_KEYWORD +== 021 +rollback +-- +0 8 ROLLBACK UNRESERVED_KEYWORD +== 022 +-- Test for pass-by-ref values being stored in proper context +create function test_variable_storage() returns text as $$ +declare x text; +begin + x := '1234'; + begin + x := x || '5678'; + -- force error inside subtransaction SPI context + perform trap_zero_divide(-100); + exception + when others then + x := x || '9012'; + end; + return x; +end$$ language plpgsql +-- +0 61 SQL_COMMENT NO_KEYWORD +62 68 CREATE RESERVED_KEYWORD +69 77 FUNCTION UNRESERVED_KEYWORD +78 99 IDENT NO_KEYWORD +99 100 ASCII_40 NO_KEYWORD +100 101 ASCII_41 NO_KEYWORD +102 109 RETURNS UNRESERVED_KEYWORD +110 114 TEXT_P UNRESERVED_KEYWORD +115 117 AS RESERVED_KEYWORD +118 358 SCONST NO_KEYWORD +359 367 LANGUAGE UNRESERVED_KEYWORD +368 375 IDENT NO_KEYWORD +== 023 +select test_variable_storage() +-- +0 6 SELECT RESERVED_KEYWORD +7 28 IDENT NO_KEYWORD +28 29 ASCII_40 NO_KEYWORD +29 30 ASCII_41 NO_KEYWORD +== 024 +|-- +-- test foreign key error trapping +|-- + +create temp table root(f1 int primary key) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 37 SQL_COMMENT NO_KEYWORD +38 40 SQL_COMMENT NO_KEYWORD +42 48 CREATE RESERVED_KEYWORD +49 53 TEMP UNRESERVED_KEYWORD +54 59 TABLE RESERVED_KEYWORD +60 64 IDENT NO_KEYWORD +64 65 ASCII_40 NO_KEYWORD +65 67 IDENT NO_KEYWORD +68 71 INT_P COL_NAME_KEYWORD +72 79 PRIMARY RESERVED_KEYWORD +80 83 KEY UNRESERVED_KEYWORD +83 84 ASCII_41 NO_KEYWORD +== 025 +create temp table leaf(f1 int references root deferrable) +-- +0 6 CREATE RESERVED_KEYWORD +7 11 TEMP UNRESERVED_KEYWORD +12 17 TABLE RESERVED_KEYWORD +18 22 IDENT NO_KEYWORD +22 23 ASCII_40 NO_KEYWORD +23 25 IDENT NO_KEYWORD +26 29 INT_P COL_NAME_KEYWORD +30 40 REFERENCES RESERVED_KEYWORD +41 45 IDENT NO_KEYWORD +46 56 DEFERRABLE RESERVED_KEYWORD +56 57 ASCII_41 NO_KEYWORD +== 026 +insert into root values(1) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 16 IDENT NO_KEYWORD +17 23 VALUES COL_NAME_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ICONST NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 027 +insert into leaf values(1) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 16 IDENT NO_KEYWORD +17 23 VALUES COL_NAME_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ICONST NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 028 +insert into leaf values(2) +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 16 IDENT NO_KEYWORD +17 23 VALUES COL_NAME_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ICONST NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 029 +-- fails + +create function trap_foreign_key(int) returns int as $$ +begin + begin -- start a subtransaction + insert into leaf values($1); + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +0 8 SQL_COMMENT NO_KEYWORD +10 16 CREATE RESERVED_KEYWORD +17 25 FUNCTION UNRESERVED_KEYWORD +26 42 IDENT NO_KEYWORD +42 43 ASCII_40 NO_KEYWORD +43 46 INT_P COL_NAME_KEYWORD +46 47 ASCII_41 NO_KEYWORD +48 55 RETURNS UNRESERVED_KEYWORD +56 59 INT_P COL_NAME_KEYWORD +60 62 AS RESERVED_KEYWORD +63 264 SCONST NO_KEYWORD +265 273 LANGUAGE UNRESERVED_KEYWORD +274 281 IDENT NO_KEYWORD +== 030 +create function trap_foreign_key_2() returns int as $$ +begin + begin -- start a subtransaction + set constraints all immediate; + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 34 IDENT NO_KEYWORD +34 35 ASCII_40 NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +37 44 RETURNS UNRESERVED_KEYWORD +45 48 INT_P COL_NAME_KEYWORD +49 51 AS RESERVED_KEYWORD +52 255 SCONST NO_KEYWORD +256 264 LANGUAGE UNRESERVED_KEYWORD +265 272 IDENT NO_KEYWORD +== 031 +select trap_foreign_key(1) +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ICONST NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 032 +select trap_foreign_key(2) +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ICONST NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 033 +-- detects FK violation + +begin +-- +0 23 SQL_COMMENT NO_KEYWORD +25 30 BEGIN_P UNRESERVED_KEYWORD +== 034 +set constraints all deferred +-- +0 3 SET UNRESERVED_KEYWORD +4 15 CONSTRAINTS UNRESERVED_KEYWORD +16 19 ALL RESERVED_KEYWORD +20 28 DEFERRED UNRESERVED_KEYWORD +== 035 +select trap_foreign_key(2) +-- +0 6 SELECT RESERVED_KEYWORD +7 23 IDENT NO_KEYWORD +23 24 ASCII_40 NO_KEYWORD +24 25 ICONST NO_KEYWORD +25 26 ASCII_41 NO_KEYWORD +== 036 +-- should not detect FK violation + savepoint x +-- +0 33 SQL_COMMENT NO_KEYWORD +36 45 SAVEPOINT UNRESERVED_KEYWORD +46 47 IDENT NO_KEYWORD +== 037 +set constraints all immediate +-- +0 3 SET UNRESERVED_KEYWORD +4 15 CONSTRAINTS UNRESERVED_KEYWORD +16 19 ALL RESERVED_KEYWORD +20 29 IMMEDIATE UNRESERVED_KEYWORD +== 038 +-- fails + rollback to x +-- +0 8 SQL_COMMENT NO_KEYWORD +11 19 ROLLBACK UNRESERVED_KEYWORD +20 22 TO RESERVED_KEYWORD +23 24 IDENT NO_KEYWORD +== 039 +select trap_foreign_key_2() +-- +0 6 SELECT RESERVED_KEYWORD +7 25 IDENT NO_KEYWORD +25 26 ASCII_40 NO_KEYWORD +26 27 ASCII_41 NO_KEYWORD +== 040 +-- detects FK violation +commit +-- +0 23 SQL_COMMENT NO_KEYWORD +24 30 COMMIT UNRESERVED_KEYWORD +== 041 +-- still fails + +drop function trap_foreign_key(int) +-- +0 14 SQL_COMMENT NO_KEYWORD +16 20 DROP UNRESERVED_KEYWORD +21 29 FUNCTION UNRESERVED_KEYWORD +30 46 IDENT NO_KEYWORD +46 47 ASCII_40 NO_KEYWORD +47 50 INT_P COL_NAME_KEYWORD +50 51 ASCII_41 NO_KEYWORD +== 042 +drop function trap_foreign_key_2() +-- +0 4 DROP UNRESERVED_KEYWORD +5 13 FUNCTION UNRESERVED_KEYWORD +14 32 IDENT NO_KEYWORD +32 33 ASCII_40 NO_KEYWORD +33 34 ASCII_41 NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_trigger.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_trigger.test b/parser/testdata/scan/plpgsql_regress/plpgsql_trigger.test new file mode 100644 index 0000000..8987a1d --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_trigger.test @@ -0,0 +1,98 @@ +== 001 +-- Simple test to verify accessibility of the OLD and NEW trigger variables + +create table testtr (a int, b text) +-- +0 75 SQL_COMMENT NO_KEYWORD +77 83 CREATE RESERVED_KEYWORD +84 89 TABLE RESERVED_KEYWORD +90 96 IDENT NO_KEYWORD +97 98 ASCII_40 NO_KEYWORD +98 99 IDENT NO_KEYWORD +100 103 INT_P COL_NAME_KEYWORD +103 104 ASCII_44 NO_KEYWORD +105 106 IDENT NO_KEYWORD +107 111 TEXT_P UNRESERVED_KEYWORD +111 112 ASCII_41 NO_KEYWORD +== 002 +create function testtr_trigger() returns trigger language plpgsql as +$$begin + raise notice 'tg_op = %', tg_op; + raise notice 'old(%) = %', old.a, row(old.*); + raise notice 'new(%) = %', new.a, row(new.*); + if (tg_op = 'DELETE') then + return old; + else + return new; + end if; +end$$ +-- +0 6 CREATE RESERVED_KEYWORD +7 15 FUNCTION UNRESERVED_KEYWORD +16 30 IDENT NO_KEYWORD +30 31 ASCII_40 NO_KEYWORD +31 32 ASCII_41 NO_KEYWORD +33 40 RETURNS UNRESERVED_KEYWORD +41 48 TRIGGER UNRESERVED_KEYWORD +49 57 LANGUAGE UNRESERVED_KEYWORD +58 65 IDENT NO_KEYWORD +66 68 AS RESERVED_KEYWORD +69 291 SCONST NO_KEYWORD +== 003 +create trigger testtr_trigger before insert or delete or update on testtr + for each row execute function testtr_trigger() +-- +0 6 CREATE RESERVED_KEYWORD +7 14 TRIGGER UNRESERVED_KEYWORD +15 29 IDENT NO_KEYWORD +30 36 BEFORE UNRESERVED_KEYWORD +37 43 INSERT UNRESERVED_KEYWORD +44 46 OR RESERVED_KEYWORD +47 53 DELETE_P UNRESERVED_KEYWORD +54 56 OR RESERVED_KEYWORD +57 63 UPDATE UNRESERVED_KEYWORD +64 66 ON RESERVED_KEYWORD +67 73 IDENT NO_KEYWORD +76 79 FOR RESERVED_KEYWORD +80 84 EACH UNRESERVED_KEYWORD +85 88 ROW COL_NAME_KEYWORD +89 96 EXECUTE UNRESERVED_KEYWORD +97 105 FUNCTION UNRESERVED_KEYWORD +106 120 IDENT NO_KEYWORD +120 121 ASCII_40 NO_KEYWORD +121 122 ASCII_41 NO_KEYWORD +== 004 +insert into testtr values (1, 'one'), (2, 'two') +-- +0 6 INSERT UNRESERVED_KEYWORD +7 11 INTO RESERVED_KEYWORD +12 18 IDENT NO_KEYWORD +19 25 VALUES COL_NAME_KEYWORD +26 27 ASCII_40 NO_KEYWORD +27 28 ICONST NO_KEYWORD +28 29 ASCII_44 NO_KEYWORD +30 35 SCONST NO_KEYWORD +35 36 ASCII_41 NO_KEYWORD +36 37 ASCII_44 NO_KEYWORD +38 39 ASCII_40 NO_KEYWORD +39 40 ICONST NO_KEYWORD +40 41 ASCII_44 NO_KEYWORD +42 47 SCONST NO_KEYWORD +47 48 ASCII_41 NO_KEYWORD +== 005 +update testtr set a = a + 1 +-- +0 6 UPDATE UNRESERVED_KEYWORD +7 13 IDENT NO_KEYWORD +14 17 SET UNRESERVED_KEYWORD +18 19 IDENT NO_KEYWORD +20 21 ASCII_61 NO_KEYWORD +22 23 IDENT NO_KEYWORD +24 25 ASCII_43 NO_KEYWORD +26 27 ICONST NO_KEYWORD +== 006 +delete from testtr +-- +0 6 DELETE_P UNRESERVED_KEYWORD +7 11 FROM RESERVED_KEYWORD +12 18 IDENT NO_KEYWORD diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_varprops.metadata.json b/parser/testdata/scan/plpgsql_regress/plpgsql_varprops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_varprops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/scan/plpgsql_regress/plpgsql_varprops.test b/parser/testdata/scan/plpgsql_regress/plpgsql_varprops.test new file mode 100644 index 0000000..70f17dd --- /dev/null +++ b/parser/testdata/scan/plpgsql_regress/plpgsql_varprops.test @@ -0,0 +1,403 @@ +== 001 +|-- +-- Tests for PL/pgSQL variable properties: CONSTANT, NOT NULL, initializers +|-- + +create type var_record as (f1 int4, f2 int4) +-- +0 2 SQL_COMMENT NO_KEYWORD +3 78 SQL_COMMENT NO_KEYWORD +79 81 SQL_COMMENT NO_KEYWORD +83 89 CREATE RESERVED_KEYWORD +90 94 TYPE_P UNRESERVED_KEYWORD +95 105 IDENT NO_KEYWORD +106 108 AS RESERVED_KEYWORD +109 110 ASCII_40 NO_KEYWORD +110 112 IDENT NO_KEYWORD +113 117 IDENT NO_KEYWORD +117 118 ASCII_44 NO_KEYWORD +119 121 IDENT NO_KEYWORD +122 126 IDENT NO_KEYWORD +126 127 ASCII_41 NO_KEYWORD +== 002 +create domain int_nn as int not null +-- +0 6 CREATE RESERVED_KEYWORD +7 13 DOMAIN_P UNRESERVED_KEYWORD +14 20 IDENT NO_KEYWORD +21 23 AS RESERVED_KEYWORD +24 27 INT_P COL_NAME_KEYWORD +28 31 NOT RESERVED_KEYWORD +32 36 NULL_P RESERVED_KEYWORD +== 003 +create domain var_record_nn as var_record not null +-- +0 6 CREATE RESERVED_KEYWORD +7 13 DOMAIN_P UNRESERVED_KEYWORD +14 27 IDENT NO_KEYWORD +28 30 AS RESERVED_KEYWORD +31 41 IDENT NO_KEYWORD +42 45 NOT RESERVED_KEYWORD +46 50 NULL_P RESERVED_KEYWORD +== 004 +create domain var_record_colnn as var_record check((value).f2 is not null) +-- +0 6 CREATE RESERVED_KEYWORD +7 13 DOMAIN_P UNRESERVED_KEYWORD +14 30 IDENT NO_KEYWORD +31 33 AS RESERVED_KEYWORD +34 44 IDENT NO_KEYWORD +45 50 CHECK RESERVED_KEYWORD +50 51 ASCII_40 NO_KEYWORD +51 52 ASCII_40 NO_KEYWORD +52 57 VALUE_P UNRESERVED_KEYWORD +57 58 ASCII_41 NO_KEYWORD +58 59 ASCII_46 NO_KEYWORD +59 61 IDENT NO_KEYWORD +62 64 IS TYPE_FUNC_NAME_KEYWORD +65 68 NOT RESERVED_KEYWORD +69 73 NULL_P RESERVED_KEYWORD +73 74 ASCII_41 NO_KEYWORD +== 005 +-- CONSTANT + +do $$ +declare x constant int := 42; +begin + raise notice 'x = %', x; +end$$ +-- +0 11 SQL_COMMENT NO_KEYWORD +13 15 DO RESERVED_KEYWORD +16 87 SCONST NO_KEYWORD +== 006 +do $$ +declare x constant int; +begin + x := 42; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 61 SCONST NO_KEYWORD +== 007 +do $$ +declare x constant int; y int; +begin + for x, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 100 SCONST NO_KEYWORD +== 008 +do $$ +declare x constant int[]; +begin + x[1] := 42; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 66 SCONST NO_KEYWORD +== 009 +do $$ +declare x constant int[]; y int; +begin + for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax) + end loop; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 137 SCONST NO_KEYWORD +== 010 +do $$ +declare x constant var_record; +begin + x.f1 := 42; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 71 SCONST NO_KEYWORD +== 011 +do $$ +declare x constant var_record; y int; +begin + for x.f1, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 110 SCONST NO_KEYWORD +== 012 +-- initializer expressions + +do $$ +declare x int := sin(0); +begin + raise notice 'x = %', x; +end$$ +-- +0 26 SQL_COMMENT NO_KEYWORD +28 30 DO RESERVED_KEYWORD +31 97 SCONST NO_KEYWORD +== 013 +do $$ +declare x int := 1/0; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 75 SCONST NO_KEYWORD +== 014 +do $$ +declare x bigint[] := array[1,3,5]; +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 80 SCONST NO_KEYWORD +== 015 +do $$ +declare x record := row(1,2,3); +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 76 SCONST NO_KEYWORD +== 016 +do $$ +declare x var_record := row(1,2); +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 78 SCONST NO_KEYWORD +== 017 +-- NOT NULL + +do $$ +declare x int not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 11 SQL_COMMENT NO_KEYWORD +13 15 DO RESERVED_KEYWORD +16 90 SCONST NO_KEYWORD +== 018 +do $$ +declare x int not null := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 96 SCONST NO_KEYWORD +== 019 +do $$ +declare x int not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 85 SCONST NO_KEYWORD +== 020 +do $$ +declare x record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 80 SCONST NO_KEYWORD +== 021 +do $$ +declare x record not null := row(42); +begin + raise notice 'x = %', x; + x := row(null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 156 SCONST NO_KEYWORD +== 022 +do $$ +declare x record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 88 SCONST NO_KEYWORD +== 023 +do $$ +declare x var_record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 84 SCONST NO_KEYWORD +== 024 +do $$ +declare x var_record not null := row(41,42); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 168 SCONST NO_KEYWORD +== 025 +do $$ +declare x var_record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 92 SCONST NO_KEYWORD +== 026 +-- Check that variables are reinitialized on block re-entry. + +do $$ +begin + for i in 1..3 loop + declare + x int; + y int := i; + r record; + c var_record; + begin + if i = 1 then + x := 42; + r := row(i, i+1); + c := row(i, i+1); + end if; + raise notice 'x = %', x; + raise notice 'y = %', y; + raise notice 'r = %', r; + raise notice 'c = %', c; + end; + end loop; +end$$ +-- +0 60 SQL_COMMENT NO_KEYWORD +62 64 DO RESERVED_KEYWORD +65 437 SCONST NO_KEYWORD +== 027 +-- Check enforcement of domain constraints during initialization + +do $$ +declare x int_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 64 SQL_COMMENT NO_KEYWORD +66 68 DO RESERVED_KEYWORD +69 137 SCONST NO_KEYWORD +== 028 +do $$ +declare x int_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 79 SCONST NO_KEYWORD +== 029 +do $$ +declare x int_nn := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 90 SCONST NO_KEYWORD +== 030 +do $$ +declare x var_record_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 78 SCONST NO_KEYWORD +== 031 +do $$ +declare x var_record_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 86 SCONST NO_KEYWORD +== 032 +do $$ +declare x var_record_nn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + x := null; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 133 SCONST NO_KEYWORD +== 033 +do $$ +declare x var_record_colnn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 81 SCONST NO_KEYWORD +== 034 +do $$ +declare x var_record_colnn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 89 SCONST NO_KEYWORD +== 035 +do $$ +declare x var_record_colnn := row(1,null); -- fail +begin + raise notice 'x = %', x; +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 96 SCONST NO_KEYWORD +== 036 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 106 SCONST NO_KEYWORD +== 037 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- fail +end$$ +-- +0 2 DO RESERVED_KEYWORD +3 116 SCONST NO_KEYWORD diff --git a/parser/testdata/summary/libpg_query.metadata.json b/parser/testdata/summary/libpg_query.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/libpg_query.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/libpg_query.test b/parser/testdata/summary/libpg_query.test new file mode 100644 index 0000000..b6b7ce8 --- /dev/null +++ b/parser/testdata/summary/libpg_query.test @@ -0,0 +1,911 @@ +== 001 +SELECT * FROM test WHERE a = 1 +-- +TABLE: name="test" schema="" table="test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 002 +SELECT * FROM test AS x WHERE a = 1 +-- +TABLE: name="test" schema="" table="test" ctx=Select +ALIAS: "x"="test" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 003 +SELECT * FROM test WHERE col1 = (SELECT col2 FROM test2 WHERE col3 = 123) +-- +TABLE: name="test" schema="" table="test" ctx=Select +TABLE: name="test2" schema="" table="test2" ctx=Select +FILTER: schema="" table="" column="col1" +FILTER: schema="" table="" column="col3" +STMT: SelectStmt +== 004 +CREATE RANDOM ix_test ON contacts.person; +-- +ERROR: syntax error at or near "RANDOM" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +SELECT 'ERR +-- +ERROR: unterminated quoted string at or near "'ERR" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +SELECT * FROM "t0" +-- +TABLE: name="t0" schema="" table="t0" ctx=Select +STMT: SelectStmt +== 007 +SELECT * FROM "t0" JOIN "t1" ON (1) +-- +TABLE: name="t0" schema="" table="t0" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 008 +SELECT * FROM "t0" + JOIN "t1" ON (1) JOIN "t2" ON (1) JOIN "t3" ON (1) JOIN "t4" ON (1) JOIN "t5" ON (1) + JOIN "t6" ON (1) JOIN "t7" ON (1) JOIN "t8" ON (1) JOIN "t9" ON (1) JOIN "t10" ON (1) + JOIN "t11" ON (1) JOIN "t12" ON (1) JOIN "t13" ON (1) JOIN "t14" ON (1) JOIN "t15" ON (1) + JOIN "t16" ON (1) JOIN "t17" ON (1) JOIN "t18" ON (1) JOIN "t19" ON (1) JOIN "t20" ON (1) + JOIN "t21" ON (1) JOIN "t22" ON (1) JOIN "t23" ON (1) JOIN "t24" ON (1) JOIN "t25" ON (1) + JOIN "t26" ON (1) JOIN "t27" ON (1) JOIN "t28" ON (1) JOIN "t29" ON (1) +-- +TABLE: name="t0" schema="" table="t0" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +TABLE: name="t4" schema="" table="t4" ctx=Select +TABLE: name="t5" schema="" table="t5" ctx=Select +TABLE: name="t6" schema="" table="t6" ctx=Select +TABLE: name="t7" schema="" table="t7" ctx=Select +TABLE: name="t8" schema="" table="t8" ctx=Select +TABLE: name="t9" schema="" table="t9" ctx=Select +TABLE: name="t10" schema="" table="t10" ctx=Select +TABLE: name="t11" schema="" table="t11" ctx=Select +TABLE: name="t12" schema="" table="t12" ctx=Select +TABLE: name="t13" schema="" table="t13" ctx=Select +TABLE: name="t14" schema="" table="t14" ctx=Select +TABLE: name="t15" schema="" table="t15" ctx=Select +TABLE: name="t16" schema="" table="t16" ctx=Select +TABLE: name="t17" schema="" table="t17" ctx=Select +TABLE: name="t18" schema="" table="t18" ctx=Select +TABLE: name="t19" schema="" table="t19" ctx=Select +TABLE: name="t20" schema="" table="t20" ctx=Select +TABLE: name="t21" schema="" table="t21" ctx=Select +TABLE: name="t22" schema="" table="t22" ctx=Select +TABLE: name="t23" schema="" table="t23" ctx=Select +TABLE: name="t24" schema="" table="t24" ctx=Select +TABLE: name="t25" schema="" table="t25" ctx=Select +TABLE: name="t26" schema="" table="t26" ctx=Select +TABLE: name="t27" schema="" table="t27" ctx=Select +TABLE: name="t28" schema="" table="t28" ctx=Select +TABLE: name="t29" schema="" table="t29" ctx=Select +STMT: SelectStmt +== 009 + + SELECT memory_total_bytes, memory_free_bytes, memory_pagecache_bytes, memory_buffers_bytes, memory_applications_bytes, + (memory_swap_total_bytes - memory_swap_free_bytes) AS swap, date_part($0, s.collected_at) AS collected_at + FROM snapshots s JOIN system_snapshots ON (snapshot_id = s.id) + WHERE s.database_id = $0 AND s.collected_at BETWEEN $0 AND $0 + ORDER BY collected_at +-- +TABLE: name="snapshots" schema="" table="snapshots" ctx=Select +TABLE: name="system_snapshots" schema="" table="system_snapshots" ctx=Select +ALIAS: "s"="snapshots" +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FILTER: schema="" table="s" column="database_id" +FILTER: schema="" table="s" column="collected_at" +STMT: SelectStmt +== 010 +-- nothing +-- + +== 011 +SELECT .1 +-- +STMT: SelectStmt +== 012 +SELECT X'EFFF' +-- +STMT: SelectStmt +== 013 +ALTER TABLE test ADD PRIMARY KEY (gid) +-- +TABLE: name="test" schema="" table="test" ctx=DDL +STMT: AlterTableStmt +== 014 +SET statement_timeout=1 +-- +STMT: VariableSetStmt +== 015 +SHOW work_mem +-- +STMT: VariableShowStmt +== 016 +COPY test (id) TO stdout +-- +TABLE: name="test" schema="" table="test" ctx=Select +STMT: CopyStmt +== 017 +drop table abc.test123 cascade +-- +TABLE: name="abc.test123" schema="abc" table="test123" ctx=DDL +STMT: DropStmt +== 018 +drop table abc.test123, test +-- +TABLE: name="abc.test123" schema="abc" table="test123" ctx=DDL +TABLE: name="test" schema="" table="test" ctx=DDL +STMT: DropStmt +== 019 +COMMIT +-- +STMT: TransactionStmt +== 020 +CHECKPOINT +-- +STMT: CheckPointStmt +== 021 +VACUUM my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: VacuumStmt +== 022 +WITH cte AS (SELECT * FROM g.other_table CROSS JOIN p) MERGE INTO my_table USING cte ON (id=oid) WHEN MATCHED THEN UPDATE SET a=b WHEN NOT MATCHED THEN INSERT (id, a) VALUES (oid, b); +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +TABLE: name="g.other_table" schema="g" table="other_table" ctx=Select +TABLE: name="p" schema="" table="p" ctx=Select +CTE: "cte" +STMT: MergeStmt +STMT: SelectStmt +== 023 +EXPLAIN DELETE FROM test +-- +TABLE: name="test" schema="" table="test" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 024 +CREATE TEMP TABLE test AS SELECT 1 +-- +TABLE: name="test" schema="" table="test" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 025 +LOCK TABLE public.schema_migrations IN ACCESS SHARE MODE +-- +TABLE: name="public.schema_migrations" schema="public" table="schema_migrations" ctx=DDL +STMT: LockStmt +== 026 +CREATE TABLE test (a int4) +-- +TABLE: name="test" schema="" table="test" ctx=DDL +STMT: CreateStmt +== 027 +CREATE TABLE foo AS SELECT * FROM bar; +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +TABLE: name="bar" schema="" table="bar" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 028 +CREATE TABLE foo AS SELECT id FROM bar UNION SELECT id from baz; +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +TABLE: name="bar" schema="" table="bar" ctx=Select +TABLE: name="baz" schema="" table="baz" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 029 +CREATE TABLE test (a int4) WITH OIDS +-- +ERROR: syntax error at or near "OIDS" +CURSORPOS: 33 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 030 +CREATE INDEX testidx ON test USING btree (a, (lower(b) || upper(c))) WHERE pow(a, 2) > 25 +-- +TABLE: name="test" schema="" table="test" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="pow" function="pow" schema="" ctx=Call +STMT: IndexStmt +== 031 +CREATE SCHEMA IF NOT EXISTS test AUTHORIZATION joe +-- +STMT: CreateSchemaStmt +== 032 +CREATE VIEW myview AS SELECT * FROM mytab +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +TABLE: name="mytab" schema="" table="mytab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 033 +REFRESH MATERIALIZED VIEW myview +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +STMT: RefreshMatViewStmt +== 034 +CREATE RULE shoe_ins_protect AS ON INSERT TO shoe DO INSTEAD NOTHING +-- +TABLE: name="shoe" schema="" table="shoe" ctx=DDL +STMT: RuleStmt +== 035 +CREATE TRIGGER check_update BEFORE UPDATE ON accounts FOR EACH ROW EXECUTE PROCEDURE check_account_update() +-- +TABLE: name="accounts" schema="" table="accounts" ctx=DDL +STMT: CreateTrigStmt +== 036 +DROP SCHEMA myschema +-- +STMT: DropStmt +== 037 +DROP VIEW myview, myview2 +-- +STMT: DropStmt +== 038 +DROP INDEX CONCURRENTLY myindex +-- +STMT: DropStmt +== 039 +DROP RULE myrule ON mytable CASCADE +-- +TABLE: name="mytable" schema="" table="mytable" ctx=DDL +STMT: DropStmt +== 040 +DROP TRIGGER IF EXISTS mytrigger ON mytable RESTRICT +-- +TABLE: name="mytable" schema="" table="mytable" ctx=DDL +STMT: DropStmt +== 041 +GRANT INSERT, UPDATE ON mytable TO myuser +-- +TABLE: name="mytable" schema="" table="mytable" ctx=DDL +STMT: GrantStmt +== 042 +REVOKE admins FROM joe +-- +STMT: GrantRoleStmt +== 043 +TRUNCATE bigtable, "fattable" RESTART IDENTITY +-- +TABLE: name="bigtable" schema="" table="bigtable" ctx=DDL +TABLE: name="fattable" schema="" table="fattable" ctx=DDL +STMT: TruncateStmt +== 044 +WITH a AS (SELECT * FROM x WHERE x.y = $1 AND x.z = 1) SELECT * FROM a +-- +TABLE: name="x" schema="" table="x" ctx=Select +CTE: "a" +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +== 045 +CREATE OR REPLACE FUNCTION thing(parameter_thing text) + RETURNS bigint AS +$BODY$ +DECLARE + local_thing_id BIGINT := 0; +BEGIN + SELECT thing_id INTO local_thing_id FROM thing_map + WHERE + thing_map_field = parameter_thing + ORDER BY 1 LIMIT 1; + + IF NOT FOUND THEN + local_thing_id = 0; + END IF; + RETURN local_thing_id; +END; +$BODY$ + LANGUAGE plpgsql STABLE +-- +FUNCTION: name="thing" function="thing" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 046 +CREATE FUNCTION getfoo(int) RETURNS TABLE (f1 int) AS 'SELECT * FROM foo WHERE fooid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getfoo" function="getfoo" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 047 +SELECT testfunc(1); +-- +FUNCTION: name="testfunc" function="testfunc" schema="" ctx=Call +STMT: SelectStmt +== 048 +CALL testfunc(1); +-- +FUNCTION: name="testfunc" function="testfunc" schema="" ctx=Call +STMT: CallStmt +== 049 +DROP FUNCTION IF EXISTS testfunc(x integer); +-- +FUNCTION: name="testfunc" function="testfunc" schema="" ctx=DDL +STMT: DropStmt +== 050 +ALTER FUNCTION testfunc(integer) RENAME TO testfunc2; +-- +FUNCTION: name="testfunc" function="testfunc" schema="" ctx=DDL +FUNCTION: name="testfunc2" function="testfunc2" schema="" ctx=DDL +STMT: RenameStmt +== 051 +select u.email, (select count(*) from enrollments e where e.user_id = u.id) as num_enrollments from users u +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="enrollments" schema="" table="enrollments" ctx=Select +ALIAS: "e"="enrollments" +ALIAS: "u"="users" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="e" column="user_id" +FILTER: schema="" table="u" column="id" +STMT: SelectStmt +== 052 +WITH cte_name AS (SELECT 1) SELECT * FROM table_name, cte_name +-- +TABLE: name="table_name" schema="" table="table_name" ctx=Select +CTE: "cte_name" +STMT: SelectStmt +== 053 +SELECT * FROM tbl TABLESAMPLE sample(1) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +STMT: SelectStmt +== 054 +SELECT xmltable.* FROM xmlelements, XMLTABLE('/root' PASSING data COLUMNS element text) +-- +TABLE: name="xmlelements" schema="" table="xmlelements" ctx=Select +STMT: SelectStmt +== 055 +SELECT jt.* FROM my_films, JSON_TABLE (js, '$.favorites[*]' COLUMNS (id FOR ORDINALITY, kind text PATH '$.kind')) AS jt; +-- +TABLE: name="my_films" schema="" table="my_films" ctx=Select +STMT: SelectStmt +== 056 +select u.* from (select * from users) u +-- +TABLE: name="users" schema="" table="users" ctx=Select +STMT: SelectStmt +== 057 +select users.id from users where 1 = (select count(*) from user_roles) +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 058 + + SELECT * + FROM pg_catalog.pg_class c + JOIN ( + SELECT 17650 AS oid + UNION ALL + SELECT 17663 AS oid + ) vals ON c.oid = vals.oid + +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +STMT: SelectStmt +== 059 + + select users.* + from users + where users.id IN (select user_roles.user_id from user_roles) + and (users.created_at between '2016-06-01' and '2016-06-30') + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +== 060 + + select users.* + from users + order by ( + select max(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +== 061 + + select users.* + from users + order by ( + select max(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) asc, ( + select max(user_logins.role_id) + from user_logins + where user_logins.user_id = users.id + ) desc + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +TABLE: name="user_logins" schema="" table="user_logins" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +FILTER: schema="" table="user_logins" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +== 062 + + select users.* + from users + group by ( + select max(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +== 063 + + select users.* + from users + group by ( + select max(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ), ( + select max(user_logins.role_id) + from user_logins + where user_logins.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +TABLE: name="user_logins" schema="" table="user_logins" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +FILTER: schema="" table="user_logins" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +== 064 + + select users.* + from users + group by users.id + having 1 > ( + select count(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +== 065 + + select users.* + from users + group by users.id + having true and 1 > ( + select count(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +== 066 + + select foo.* + from foo + join ( select * from bar ) b + on b.baz = foo.quux + +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +STMT: SelectStmt +== 067 + + SELECT * + FROM foo + INNER JOIN join_a ON foo.id = join_a.id AND join_a.id IN ( + SELECT id + FROM sub_a + INNER JOIN sub_b ON sub_a.id = sub_b.id AND sub_b.id IN ( + SELECT id + FROM sub_c + INNER JOIN sub_d ON sub_c.id IN (SELECT id from sub_e) + ) + ) + INNER JOIN join_b ON foo.id = join_b.id AND join_b.id IN ( + SELECT id FROM sub_f + ) + +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="join_a" schema="" table="join_a" ctx=Select +TABLE: name="join_b" schema="" table="join_b" ctx=Select +TABLE: name="sub_a" schema="" table="sub_a" ctx=Select +TABLE: name="sub_b" schema="" table="sub_b" ctx=Select +TABLE: name="sub_c" schema="" table="sub_c" ctx=Select +TABLE: name="sub_d" schema="" table="sub_d" ctx=Select +TABLE: name="sub_e" schema="" table="sub_e" ctx=Select +TABLE: name="sub_f" schema="" table="sub_f" ctx=Select +STMT: SelectStmt +== 068 + + WITH cte_a AS ( + SELECT * FROM table_a + ), cte_b AS ( + SELECT * FROM table_b + ) + SELECT id FROM table_c + LEFT JOIN cte_b ON table_c.id = cte_b.c_id + UNION + SELECT * FROM cte_a + +-- +TABLE: name="table_a" schema="" table="table_a" ctx=Select +TABLE: name="table_b" schema="" table="table_b" ctx=Select +TABLE: name="table_c" schema="" table="table_c" ctx=Select +CTE: "cte_a" +CTE: "cte_b" +STMT: SelectStmt +== 069 + + WITH cte_a AS ( + SELECT * FROM table_a + ), cte_b AS ( + SELECT * FROM table_b + ) + SELECT id FROM table_c + LEFT JOIN cte_b ON table_c.id = cte_b.c_id + EXCEPT + SELECT * FROM cte_a + +-- +TABLE: name="table_a" schema="" table="table_a" ctx=Select +TABLE: name="table_b" schema="" table="table_b" ctx=Select +TABLE: name="table_c" schema="" table="table_c" ctx=Select +CTE: "cte_a" +CTE: "cte_b" +STMT: SelectStmt +== 070 + + WITH cte_a AS ( + SELECT * FROM table_a + ), cte_b AS ( + SELECT * FROM table_b + ) + SELECT id FROM table_c + LEFT JOIN cte_b ON table_c.id = cte_b.c_id + INTERSECT + SELECT * FROM cte_a + +-- +TABLE: name="table_a" schema="" table="table_a" ctx=Select +TABLE: name="table_b" schema="" table="table_b" ctx=Select +TABLE: name="table_c" schema="" table="table_c" ctx=Select +CTE: "cte_a" +CTE: "cte_b" +STMT: SelectStmt +== 071 + + SELECT GREATEST( + date_trunc($1, $2::timestamptz) + $3::interval, + COALESCE( + ( + SELECT first_aggregate_starts_at + FROM schema_aggregate_infos + WHERE base_table = $4 LIMIT $5 + ), + now() + $6::interval + ) + ) AS first_hourly_start_ts + +-- +TABLE: name="schema_aggregate_infos" schema="" table="schema_aggregate_infos" ctx=Select +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="" column="base_table" +STMT: SelectStmt +== 072 + + SELECT + CASE + WHEN id IN (SELECT foo_id FROM when_a) THEN (SELECT MAX(id) FROM then_a) + WHEN id IN (SELECT foo_id FROM when_b) THEN (SELECT MAX(id) FROM then_b) + ELSE (SELECT MAX(id) FROM elsey) + END + FROM foo + +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="when_a" schema="" table="when_a" ctx=Select +TABLE: name="then_a" schema="" table="then_a" ctx=Select +TABLE: name="when_b" schema="" table="when_b" ctx=Select +TABLE: name="then_b" schema="" table="then_b" ctx=Select +TABLE: name="elsey" schema="" table="elsey" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 073 + + SELECT 1 + FROM foo + WHERE x = any(cast(array(SELECT a FROM bar) as bigint[])) + OR x = any(array(SELECT a FROM baz)::bigint[]) + +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +TABLE: name="baz" schema="" table="baz" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 074 +SELECT * FROM my_custom_func() +-- +FUNCTION: name="my_custom_func" function="my_custom_func" schema="" ctx=Call +STMT: SelectStmt +== 075 + + SELECT * + FROM unnest($1::text[]) AS a(x) + LEFT OUTER JOIN LATERAL ( + SELECT json_build_object($2, z.z) + FROM ( + SELECT * + FROM ( + SELECT row_to_json( + (SELECT * FROM (SELECT public.my_function(b) FROM public.c) d) + ) + ) e + ) f + ) AS g ON (1) + +-- +TABLE: name="public.c" schema="public" table="c" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="public.my_function" function="my_function" schema="public" ctx=Call +STMT: SelectStmt +== 076 +insert into users(pk, name) values (1, 'bob'); +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +insert into users(pk, name) select pk, name from other_users; +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 078 + + with cte as ( + select pk, name from other_users + ) + insert into users(pk, name) select * from cte; + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +CTE: "cte" +STMT: InsertStmt +STMT: SelectStmt +== 079 +update users set name = 'bob'; +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: UpdateStmt +== 080 +update users set name = (select name from other_users limit 1); +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +== 081 + + with cte as ( + select name from other_users limit 1 + ) + update users set name = (select name from cte); + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +CTE: "cte" +STMT: UpdateStmt +STMT: SelectStmt +== 082 + + with cte as ( + select name from other_users limit 1 + ) + update users set name = (select name from cte); + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +CTE: "cte" +STMT: UpdateStmt +STMT: SelectStmt +== 083 +DELETE FROM users; +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: DeleteStmt +== 084 + + DELETE FROM users USING foo + WHERE foo_id = foo.id AND foo.action = 'delete'; + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: DeleteStmt +== 085 + + DELETE FROM users USING foo + WHERE foo_id = foo.id AND foo.action = 'delete'; + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: DeleteStmt +== 086 +DROP TYPE IF EXISTS repack.pk_something +-- +STMT: DropStmt +== 087 +SELECT * FROM x WHERE y = $1 AND z = 1 +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +== 088 +SELECT * FROM x WHERE x.y = $1 AND x.z = 1 +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +== 089 +WITH a AS (SELECT * FROM x WHERE x.y = $1 AND x.z = 1) SELECT * FROM a WHERE b = 5 +-- +TABLE: name="x" schema="" table="x" ctx=Select +CTE: "a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +== 090 +SELECT * FROM x WHERE x.y IS TRUE AND x.z IS NOT FALSE +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +== 091 +SELECT * FROM x WHERE x.y IS NULL AND x.z IS NOT NULL +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +== 092 +SELECT * FROM x WHERE x.y = COALESCE(z.a, z.b) +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z" column="b" +STMT: SelectStmt +== 093 +SELECT * FROM x where y = $1 UNION SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +== 094 +SELECT * FROM x where y = $1 UNION ALL SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +== 095 +SELECT * FROM x where y = $1 EXCEPT SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +== 096 +SELECT * FROM x where y = $1 EXCEPT ALL SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +== 097 +SELECT * FROM x where y = $1 INTERSECT SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +== 098 +SELECT * FROM x where y = $1 INTERSECT ALL SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +== 099 +SELECT a, y, z FROM x WHERE x.y = $1 AND x.z = 1 +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +== 100 +SELECT * FROM x WHERE x.y = $1 AND x.z = 1 ORDER BY a, b +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +== 101 +GRANT SELECT ON ALL TABLES IN SCHEMA public TO myrole +-- +STMT: GrantStmt +== 102 +SELECT * FROM b.c WHERE a.b.c = 1 +-- +TABLE: name="b.c" schema="b" table="c" ctx=Select +FILTER: schema="a" table="b" column="c" +STMT: SelectStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_array.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_array.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_array.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_array.test b/parser/testdata/summary/plpgsql_regress/plpgsql_array.test new file mode 100644 index 0000000..54f09cb --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_array.test @@ -0,0 +1,225 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of array variables +|-- +-- We also check arrays of composites here, so this has some overlap +-- with the plpgsql_record tests. +|-- + +create type complex as (r float8, i float8) +-- +STMT: CompositeTypeStmt +== 002 +create type quadarray as (c1 complex[], c2 complex) +-- +STMT: CompositeTypeStmt +== 003 +do $$ declare a int[]; +begin a := array[1,2]; a[3] := 4; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 004 +do $$ declare a int[]; +begin a[3] := 4; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 005 +do $$ declare a int[]; +begin a[1][4] := 4; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 006 +do $$ declare a int[]; +begin a[1] := 23::text; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 007 +-- lax typing + +do $$ declare a int[]; +begin a := array[1,2]; a[2:3] := array[3,4]; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 008 +do $$ declare a int[]; +begin a := array[1,2]; a[2] := a[2] + 1; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 009 +do $$ declare a int[]; +begin a[1:2] := array[3,4]; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 010 +do $$ declare a int[]; +begin a[1:2] := 4; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 011 +-- error + +do $$ declare a complex[]; +begin a[1] := (1,2); a[1].i := 11; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 012 +do $$ declare a complex[]; +begin a[1].i := 11; raise notice 'a = %, a[1].i = %', a, a[1].i; end$$ +-- +STMT: DoStmt +== 013 +-- perhaps this ought to work, but for now it doesn't: +do $$ declare a complex[]; +begin a[1:2].i := array[11,12]; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 014 +do $$ declare a quadarray; +begin a.c1[1].i := 11; raise notice 'a = %, a.c1[1].i = %', a, a.c1[1].i; end$$ +-- +STMT: DoStmt +== 015 +do $$ declare a int[]; +begin a := array_agg(x) from (values(1),(2),(3)) v(x); raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 016 +create temp table onecol as select array[1,2] as f1 +-- +TABLE: name="onecol" schema="" table="onecol" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 017 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 018 +do $$ declare a int[]; +begin a := * from onecol for update; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 019 +-- error cases: + +do $$ declare a int[]; +begin a := from onecol; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 020 +do $$ declare a int[]; +begin a := f1, f1 from onecol; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 021 +insert into onecol values(array[11]) +-- +TABLE: name="onecol" schema="" table="onecol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +do $$ declare a int[]; +begin a := f1 from onecol; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 023 +do $$ declare a int[]; +begin a := f1 from onecol limit 1; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 024 +do $$ declare a real; +begin a[1] := 2; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 025 +do $$ declare a complex; +begin a.r[1] := 2; raise notice 'a = %', a; end$$ +-- +STMT: DoStmt +== 026 +|-- +-- test of %type[] and %rowtype[] syntax +|-- + +-- check supported syntax +do $$ +declare + v int; + v1 v%type; + v2 v%type[]; + v3 v%type[1]; + v4 v%type[][]; + v5 v%type[1][3]; + v6 v%type array; + v7 v%type array[]; + v8 v%type array[1]; + v9 v%type array[1][1]; + v10 pg_catalog.pg_class%rowtype[]; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(v3); + raise notice '%', pg_typeof(v4); + raise notice '%', pg_typeof(v5); + raise notice '%', pg_typeof(v6); + raise notice '%', pg_typeof(v7); + raise notice '%', pg_typeof(v8); + raise notice '%', pg_typeof(v9); + raise notice '%', pg_typeof(v10); +end; +$$ +-- +STMT: DoStmt +== 027 +-- some types don't support arrays +do $$ +declare + v pg_node_tree; + v1 v%type[]; +begin +end; +$$ +-- +STMT: DoStmt +== 028 +-- check functionality +do $$ +declare + v1 int; + v2 varchar; + a1 v1%type[]; + a2 v2%type[]; +begin + v1 := 10; + v2 := 'Hi'; + a1 := array[v1,v1]; + a2 := array[v2,v2]; + raise notice '% %', a1, a2; +end; +$$ +-- +STMT: DoStmt +== 029 +create table array_test_table(a int, b varchar) +-- +TABLE: name="array_test_table" schema="" table="array_test_table" ctx=DDL +STMT: CreateStmt +== 030 +insert into array_test_table values(1, 'first'), (2, 'second') +-- +TABLE: name="array_test_table" schema="" table="array_test_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +do $$ +declare tg array_test_table%rowtype[]; +begin + tg := array(select array_test_table from array_test_table); + raise notice '%', tg; + tg := array(select row(a,b) from array_test_table); + raise notice '%', tg; +end; +$$ +-- +STMT: DoStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_cache.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_cache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_cache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_cache.test b/parser/testdata/summary/plpgsql_regress/plpgsql_cache.test new file mode 100644 index 0000000..b357d7e --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_cache.test @@ -0,0 +1,93 @@ +== 001 +|-- +-- Cache-behavior-dependent test cases +|-- +-- These tests logically belong in plpgsql_record.sql, and perhaps someday +-- can be merged back into it. For now, however, their results are different +-- depending on debug_discard_caches, so we must have two expected-output +-- files to cover both cases. To minimize the maintenance effort resulting +-- from that, this file should contain only tests that do have different +-- results under debug_discard_caches. +|-- + +-- check behavior with changes of a named rowtype +create table c_mutable(f1 int, f2 text) +-- +TABLE: name="c_mutable" schema="" table="c_mutable" ctx=DDL +STMT: CreateStmt +== 002 +create function c_sillyaddone(int) returns int language plpgsql as +$$ declare r c_mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +FUNCTION: name="c_sillyaddone" function="c_sillyaddone" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +select c_sillyaddone(42) +-- +FUNCTION: name="c_sillyaddone" function="c_sillyaddone" schema="" ctx=Call +STMT: SelectStmt +== 004 +alter table c_mutable drop column f1 +-- +TABLE: name="c_mutable" schema="" table="c_mutable" ctx=DDL +STMT: AlterTableStmt +== 005 +alter table c_mutable add column f1 float8 +-- +TABLE: name="c_mutable" schema="" table="c_mutable" ctx=DDL +STMT: AlterTableStmt +== 006 +-- currently, this fails due to cached plan for "r.f1 + 1" expression +-- (but if debug_discard_caches is on, it will succeed) +select c_sillyaddone(42) +-- +FUNCTION: name="c_sillyaddone" function="c_sillyaddone" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- but it's OK if we force plan rebuilding +discard plans +-- +STMT: DiscardStmt +== 008 +select c_sillyaddone(42) +-- +FUNCTION: name="c_sillyaddone" function="c_sillyaddone" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- check behavior with changes in a record rowtype +create function show_result_type(text) returns text language plpgsql as +$$ + declare + r record; + t text; + begin + execute $1 into r; + select pg_typeof(r.a) into t; + return format('type %s value %s', t, r.a::text); + end; +$$ +-- +FUNCTION: name="show_result_type" function="show_result_type" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 010 +select show_result_type('select 1 as a') +-- +FUNCTION: name="show_result_type" function="show_result_type" schema="" ctx=Call +STMT: SelectStmt +== 011 +-- currently this fails due to cached plan for pg_typeof expression +-- (but if debug_discard_caches is on, it will succeed) +select show_result_type('select 2.0 as a') +-- +FUNCTION: name="show_result_type" function="show_result_type" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- but it's OK if we force plan rebuilding +discard plans +-- +STMT: DiscardStmt +== 013 +select show_result_type('select 2.0 as a') +-- +FUNCTION: name="show_result_type" function="show_result_type" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_call.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_call.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_call.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_call.test b/parser/testdata/summary/plpgsql_regress/plpgsql_call.test new file mode 100644 index 0000000..df9e24f --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_call.test @@ -0,0 +1,807 @@ +== 001 +|-- +-- Tests for procedures / CALL syntax +|-- + +CREATE PROCEDURE test_proc1() +LANGUAGE plpgsql +AS $$ +BEGIN + NULL; +END; +$$ +-- +FUNCTION: name="test_proc1" function="test_proc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +CALL test_proc1() +-- +FUNCTION: name="test_proc1" function="test_proc1" schema="" ctx=Call +STMT: CallStmt +== 003 +-- error: can't return non-NULL +CREATE PROCEDURE test_proc2() +LANGUAGE plpgsql +AS $$ +BEGIN + RETURN 5; +END; +$$ +-- +FUNCTION: name="test_proc2" function="test_proc2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 004 +CREATE TABLE test1 (a int) +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: CreateStmt +== 005 +CREATE PROCEDURE test_proc3(x int) +LANGUAGE plpgsql +AS $$ +BEGIN + INSERT INTO test1 VALUES (x); +END; +$$ +-- +FUNCTION: name="test_proc3" function="test_proc3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +CALL test_proc3(55) +-- +FUNCTION: name="test_proc3" function="test_proc3" schema="" ctx=Call +STMT: CallStmt +== 007 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 008 +-- Check that plan revalidation doesn't prevent setting transaction properties +-- (bug #18059). This test must include the first temp-object creation in +-- this script, or it won't exercise the bug scenario. Hence we put it early. +CREATE PROCEDURE test_proc3a() +LANGUAGE plpgsql +AS $$ +BEGIN + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + RAISE NOTICE 'done'; +END; +$$ +-- +FUNCTION: name="test_proc3a" function="test_proc3a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 009 +CALL test_proc3a() +-- +FUNCTION: name="test_proc3a" function="test_proc3a" schema="" ctx=Call +STMT: CallStmt +== 010 +CREATE TEMP TABLE tt1(f1 int) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: CreateStmt +== 011 +CALL test_proc3a() +-- +FUNCTION: name="test_proc3a" function="test_proc3a" schema="" ctx=Call +STMT: CallStmt +== 012 +-- nested CALL +TRUNCATE TABLE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 013 +CREATE PROCEDURE test_proc4(y int) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL test_proc3(y); + CALL test_proc3($1); +END; +$$ +-- +FUNCTION: name="test_proc4" function="test_proc4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 014 +CALL test_proc4(66) +-- +FUNCTION: name="test_proc4" function="test_proc4" schema="" ctx=Call +STMT: CallStmt +== 015 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 016 +CALL test_proc4(66) +-- +FUNCTION: name="test_proc4" function="test_proc4" schema="" ctx=Call +STMT: CallStmt +== 017 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 018 +-- output arguments + +CREATE PROCEDURE test_proc5(INOUT a text) +LANGUAGE plpgsql +AS $$ +BEGIN + a := a || '+' || a; +END; +$$ +-- +FUNCTION: name="test_proc5" function="test_proc5" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 019 +CALL test_proc5('abc') +-- +FUNCTION: name="test_proc5" function="test_proc5" schema="" ctx=Call +STMT: CallStmt +== 020 +CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + b := b * a; + c := c * a; +END; +$$ +-- +FUNCTION: name="test_proc6" function="test_proc6" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 021 +CALL test_proc6(2, 3, 4) +-- +FUNCTION: name="test_proc6" function="test_proc6" schema="" ctx=Call +STMT: CallStmt +== 022 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); + RAISE INFO 'x = %, y = %', x, y; + CALL test_proc6(2, c => y, b => x); + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +STMT: DoStmt +== 023 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x + 1, y); -- error + RAISE INFO 'x = %, y = %', x, y; +END; +$$ +-- +STMT: DoStmt +== 024 +DO +LANGUAGE plpgsql +$$ +DECLARE + x constant int := 3; + y int := 4; +BEGIN + CALL test_proc6(2, x, y); -- error because x is constant +END; +$$ +-- +STMT: DoStmt +== 025 +DO +LANGUAGE plpgsql +$$ +DECLARE + x int := 3; + y int := 4; +BEGIN + FOR i IN 1..5 LOOP + CALL test_proc6(i, x, y); + RAISE INFO 'x = %, y = %', x, y; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 026 +-- recursive with output arguments + +CREATE PROCEDURE test_proc7(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN +IF x > 1 THEN + a := x / 10; + b := x / 2; + CALL test_proc7(b::int, a, b); +END IF; +END; +$$ +-- +FUNCTION: name="test_proc7" function="test_proc7" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 027 +CALL test_proc7(100, -1, -1) +-- +FUNCTION: name="test_proc7" function="test_proc7" schema="" ctx=Call +STMT: CallStmt +== 028 +-- inner COMMIT with output arguments + +CREATE PROCEDURE test_proc7c(x int, INOUT a int, INOUT b numeric) +LANGUAGE plpgsql +AS $$ +BEGIN + a := x / 10; + b := x / 2; + COMMIT; +END; +$$ +-- +FUNCTION: name="test_proc7c" function="test_proc7c" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +CREATE PROCEDURE test_proc7cc(_x int) +LANGUAGE plpgsql +AS $$ +DECLARE _a int; _b numeric; +BEGIN + CALL test_proc7c(_x, _a, _b); + RAISE NOTICE '_x: %,_a: %, _b: %', _x, _a, _b; +END +$$ +-- +FUNCTION: name="test_proc7cc" function="test_proc7cc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 030 +CALL test_proc7cc(10) +-- +FUNCTION: name="test_proc7cc" function="test_proc7cc" schema="" ctx=Call +STMT: CallStmt +== 031 +-- named parameters and defaults + +CREATE PROCEDURE test_proc8a(INOUT a int, INOUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := a * 10; + b := b + 10; +END; +$$ +-- +FUNCTION: name="test_proc8a" function="test_proc8a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 032 +CALL test_proc8a(10, 20) +-- +FUNCTION: name="test_proc8a" function="test_proc8a" schema="" ctx=Call +STMT: CallStmt +== 033 +CALL test_proc8a(b => 20, a => 10) +-- +FUNCTION: name="test_proc8a" function="test_proc8a" schema="" ctx=Call +STMT: CallStmt +== 034 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc8a(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; + CALL test_proc8a(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +STMT: DoStmt +== 035 +CREATE PROCEDURE test_proc8b(INOUT a int, INOUT b int, INOUT c int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +FUNCTION: name="test_proc8b" function="test_proc8b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 036 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8b(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + CALL test_proc8b(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +STMT: DoStmt +== 037 +CREATE PROCEDURE test_proc8c(INOUT a int, INOUT b int, INOUT c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + a := a * 10; + b := b + 10; + c := c * -10; +END; +$$ +-- +FUNCTION: name="test_proc8c" function="test_proc8c" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 038 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(c => _c, b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +STMT: DoStmt +== 039 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +STMT: DoStmt +== 040 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 50; + CALL test_proc8c(_a, b => _b); -- fail, no output argument for c + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +STMT: DoStmt +== 041 +-- OUT parameters + +CREATE PROCEDURE test_proc9(IN a int, OUT b int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + b := a * 2; +END; +$$ +-- +FUNCTION: name="test_proc9" function="test_proc9" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 042 +DO $$ +DECLARE _a int; _b int; +BEGIN + _a := 10; _b := 30; + CALL test_proc9(_a, _b); + RAISE NOTICE '_a: %, _b: %', _a, _b; +END +$$ +-- +STMT: DoStmt +== 043 +CREATE PROCEDURE test_proc10(IN a int, OUT b int, IN c int DEFAULT 11) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %, c: %', a, b, c; + b := a - c; +END; +$$ +-- +FUNCTION: name="test_proc10" function="test_proc10" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 044 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(a => _a, b => _b, c => _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, c => _c, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(_a, b => _b); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; + + _a := 10; _b := 30; _c := 7; + CALL test_proc10(b => _b, a => _a); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +STMT: DoStmt +== 045 +-- OUT + VARIADIC + +CREATE PROCEDURE test_proc11(a OUT int, VARIADIC b int[]) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %, b: %', a, b; + a := b[1] + b[2]; +END; +$$ +-- +FUNCTION: name="test_proc11" function="test_proc11" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 046 +DO $$ +DECLARE _a int; _b int; _c int; +BEGIN + _a := 10; _b := 30; _c := 7; + CALL test_proc11(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +STMT: DoStmt +== 047 +-- polymorphic OUT arguments + +CREATE PROCEDURE test_proc12(a anyelement, OUT b anyelement, OUT c anyarray) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'a: %', a; + b := a; + c := array[a]; +END; +$$ +-- +FUNCTION: name="test_proc12" function="test_proc12" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 048 +DO $$ +DECLARE _a int; _b int; _c int[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +STMT: DoStmt +== 049 +DO $$ +DECLARE _a int; _b int; _c text[]; +BEGIN + _a := 10; + CALL test_proc12(_a, _b, _c); -- error + RAISE NOTICE '_a: %, _b: %, _c: %', _a, _b, _c; +END +$$ +-- +STMT: DoStmt +== 050 +-- transition variable assignment + +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 051 +CREATE FUNCTION triggerfunc1() RETURNS trigger +LANGUAGE plpgsql +AS $$ +DECLARE + z int := 0; +BEGIN + CALL test_proc6(2, NEW.a, NEW.a); + RETURN NEW; +END; +$$ +-- +FUNCTION: name="triggerfunc1" function="triggerfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 052 +CREATE TRIGGER t1 BEFORE INSERT ON test1 EXECUTE PROCEDURE triggerfunc1() +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: CreateTrigStmt +== 053 +INSERT INTO test1 VALUES (1), (2), (3) +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +UPDATE test1 SET a = 22 WHERE a = 2 +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: UpdateStmt +== 055 +SELECT * FROM test1 ORDER BY a +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 056 +DROP PROCEDURE test_proc1 +-- +STMT: DropStmt +== 057 +DROP PROCEDURE test_proc3 +-- +STMT: DropStmt +== 058 +DROP PROCEDURE test_proc4 +-- +STMT: DropStmt +== 059 +DROP TABLE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: DropStmt +== 060 +-- more checks for named-parameter handling + +CREATE PROCEDURE p1(v_cnt int, v_Text inout text = NULL) +AS $$ +BEGIN + v_Text := 'v_cnt = ' || v_cnt; +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="p1" function="p1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 061 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt); -- error, must supply something for v_Text + RAISE NOTICE '%', v_Text; +END; +$$ +-- +STMT: DoStmt +== 062 +DO $$ +DECLARE + v_Text text; + v_cnt integer := 42; +BEGIN + CALL p1(v_cnt := v_cnt, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +STMT: DoStmt +== 063 +DO $$ +DECLARE + v_Text text; +BEGIN + CALL p1(10, v_Text := v_Text); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +STMT: DoStmt +== 064 +DO $$ +DECLARE + v_Text text; + v_cnt integer; +BEGIN + CALL p1(v_Text := v_Text, v_cnt := v_cnt); + RAISE NOTICE '%', v_Text; +END; +$$ +-- +STMT: DoStmt +== 065 +-- check that we detect change of dependencies in CALL +-- atomic and non-atomic call sites used to do this differently, so check both + +CREATE PROCEDURE inner_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'inner_p(%)', f1; +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="inner_p" function="inner_p" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 066 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 1 $$ LANGUAGE sql +-- +FUNCTION: name="f" function="f" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 067 +CREATE PROCEDURE outer_p (f1 int) +AS $$ +BEGIN + RAISE NOTICE 'outer_p(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="outer_p" function="outer_p" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 068 +CREATE FUNCTION outer_f (f1 int) RETURNS void +AS $$ +BEGIN + RAISE NOTICE 'outer_f(%)', f1; + CALL inner_p(f(f1)); +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="outer_f" function="outer_f" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 069 +CALL outer_p(42) +-- +FUNCTION: name="outer_p" function="outer_p" schema="" ctx=Call +STMT: CallStmt +== 070 +SELECT outer_f(42) +-- +FUNCTION: name="outer_f" function="outer_f" schema="" ctx=Call +STMT: SelectStmt +== 071 +DROP FUNCTION f(int) +-- +FUNCTION: name="f" function="f" schema="" ctx=DDL +STMT: DropStmt +== 072 +CREATE FUNCTION f(int) RETURNS int AS $$ SELECT $1 + 2 $$ LANGUAGE sql +-- +FUNCTION: name="f" function="f" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 073 +CALL outer_p(42) +-- +FUNCTION: name="outer_p" function="outer_p" schema="" ctx=Call +STMT: CallStmt +== 074 +SELECT outer_f(42) +-- +FUNCTION: name="outer_f" function="outer_f" schema="" ctx=Call +STMT: SelectStmt +== 075 +-- Check that stable functions in CALL see the correct snapshot + +CREATE TABLE t_test (x int) +-- +TABLE: name="t_test" schema="" table="t_test" ctx=DDL +STMT: CreateStmt +== 076 +INSERT INTO t_test VALUES (0) +-- +TABLE: name="t_test" schema="" table="t_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +CREATE FUNCTION f_get_x () RETURNS int +AS $$ +DECLARE l_result int; +BEGIN + SELECT x INTO l_result FROM t_test; + RETURN l_result; +END +$$ LANGUAGE plpgsql STABLE +-- +FUNCTION: name="f_get_x" function="f_get_x" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 078 +CREATE PROCEDURE f_print_x (x int) +AS $$ +BEGIN + RAISE NOTICE 'f_print_x(%)', x; +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="f_print_x" function="f_print_x" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 079 +-- test in non-atomic context +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + ROLLBACK; +END +$$ +-- +STMT: DoStmt +== 080 +-- test in non-atomic context, except exception block is locally atomic +DO $$ +BEGIN + BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + EXCEPTION WHEN division_by_zero THEN + RAISE NOTICE '%', SQLERRM; + END; + ROLLBACK; +END +$$ +-- +STMT: DoStmt +== 081 +-- test in atomic context +BEGIN +-- +STMT: TransactionStmt +== 082 +DO $$ +BEGIN + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); + UPDATE t_test SET x = x + 1; + RAISE NOTICE 'f_get_x(%)', f_get_x(); + CALL f_print_x(f_get_x()); +END +$$ +-- +STMT: DoStmt +== 083 +ROLLBACK +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_control.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_control.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_control.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_control.test b/parser/testdata/summary/plpgsql_regress/plpgsql_control.test new file mode 100644 index 0000000..6cc5621 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_control.test @@ -0,0 +1,674 @@ +== 001 +|-- +-- Tests for PL/pgSQL control structures +|-- + +-- integer FOR loop + +do $$ +begin + -- basic case + for i in 1..3 loop + raise notice '1..3: i = %', i; + end loop; + -- with BY, end matches exactly + for i in 1..10 by 3 loop + raise notice '1..10 by 3: i = %', i; + end loop; + -- with BY, end does not match + for i in 1..11 by 3 loop + raise notice '1..11 by 3: i = %', i; + end loop; + -- zero iterations + for i in 1..0 by 3 loop + raise notice '1..0 by 3: i = %', i; + end loop; + -- REVERSE + for i in reverse 10..0 by 3 loop + raise notice 'reverse 10..0 by 3: i = %', i; + end loop; + -- potential overflow + for i in 2147483620..2147483647 by 10 loop + raise notice '2147483620..2147483647 by 10: i = %', i; + end loop; + -- potential overflow, reverse direction + for i in reverse -2147483620..-2147483647 by 10 loop + raise notice 'reverse -2147483620..-2147483647 by 10: i = %', i; + end loop; +end$$ +-- +STMT: DoStmt +== 002 +-- BY can't be zero or negative +do $$ +begin + for i in 1..3 by 0 loop + raise notice '1..3 by 0: i = %', i; + end loop; +end$$ +-- +STMT: DoStmt +== 003 +do $$ +begin + for i in 1..3 by -1 loop + raise notice '1..3 by -1: i = %', i; + end loop; +end$$ +-- +STMT: DoStmt +== 004 +do $$ +begin + for i in reverse 1..3 by -1 loop + raise notice 'reverse 1..3 by -1: i = %', i; + end loop; +end$$ +-- +STMT: DoStmt +== 005 +-- CONTINUE statement + +create table conttesttbl(idx serial, v integer) +-- +TABLE: name="conttesttbl" schema="" table="conttesttbl" ctx=DDL +STMT: CreateStmt +== 006 +insert into conttesttbl(v) values(10) +-- +TABLE: name="conttesttbl" schema="" table="conttesttbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +insert into conttesttbl(v) values(20) +-- +TABLE: name="conttesttbl" schema="" table="conttesttbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +insert into conttesttbl(v) values(30) +-- +TABLE: name="conttesttbl" schema="" table="conttesttbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +insert into conttesttbl(v) values(40) +-- +TABLE: name="conttesttbl" schema="" table="conttesttbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +create function continue_test1() returns void as $$ +declare _i integer = 0; _r record; +begin + raise notice '---1---'; + loop + _i := _i + 1; + raise notice '%', _i; + continue when _i < 10; + exit; + end loop; + + raise notice '---2---'; + <> + loop + _i := _i - 1; + loop + raise notice '%', _i; + continue lbl when _i > 0; + exit lbl; + end loop; + end loop; + + raise notice '---3---'; + <> + while _i < 10 loop + _i := _i + 1; + continue the_loop when _i % 2 = 0; + raise notice '%', _i; + end loop; + + raise notice '---4---'; + for _i in 1..10 loop + begin + -- applies to outer loop, not the nested begin block + continue when _i < 5; + raise notice '%', _i; + end; + end loop; + + raise notice '---5---'; + for _r in select * from conttesttbl loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---6---'; + for _r in execute 'select * from conttesttbl' loop + continue when _r.v <= 20; + raise notice '%', _r.v; + end loop; + + raise notice '---7---'; + <> + for _i in 1..3 loop + continue looplabel when _i = 2; + raise notice '%', _i; + end loop; + + raise notice '---8---'; + _i := 1; + while _i <= 3 loop + raise notice '%', _i; + _i := _i + 1; + continue when _i = 3; + end loop; + + raise notice '---9---'; + for _r in select * from conttesttbl order by v limit 1 loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---10---'; + for _r in execute 'select * from conttesttbl order by v limit 1' loop + raise notice '%', _r.v; + continue; + end loop; + + raise notice '---11---'; + <> + for _i in 1..2 loop + raise notice 'outer %', _i; + <> + for _j in 1..3 loop + continue outerlooplabel when _j = 2; + raise notice 'inner %', _j; + end loop; + end loop; +end; $$ language plpgsql +-- +FUNCTION: name="continue_test1" function="continue_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 011 +select continue_test1() +-- +FUNCTION: name="continue_test1" function="continue_test1" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- should fail: CONTINUE is only legal inside a loop +create function continue_error1() returns void as $$ +begin + begin + continue; + end; +end; +$$ language plpgsql +-- +FUNCTION: name="continue_error1" function="continue_error1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 013 +-- should fail: unlabeled EXIT is only legal inside a loop +create function exit_error1() returns void as $$ +begin + begin + exit; + end; +end; +$$ language plpgsql +-- +FUNCTION: name="exit_error1" function="exit_error1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 014 +-- should fail: no such label +create function continue_error2() returns void as $$ +begin + begin + loop + continue no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +FUNCTION: name="continue_error2" function="continue_error2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 015 +-- should fail: no such label +create function exit_error2() returns void as $$ +begin + begin + loop + exit no_such_label; + end loop; + end; +end; +$$ language plpgsql +-- +FUNCTION: name="exit_error2" function="exit_error2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 016 +-- should fail: CONTINUE can't reference the label of a named block +create function continue_error3() returns void as $$ +begin + <> + begin + loop + continue begin_block1; + end loop; + end; +end; +$$ language plpgsql +-- +FUNCTION: name="continue_error3" function="continue_error3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 017 +-- On the other hand, EXIT *can* reference the label of a named block +create function exit_block1() returns void as $$ +begin + <> + begin + loop + exit begin_block1; + raise exception 'should not get here'; + end loop; + end; +end; +$$ language plpgsql +-- +FUNCTION: name="exit_block1" function="exit_block1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 018 +select exit_block1() +-- +FUNCTION: name="exit_block1" function="exit_block1" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- verbose end block and end loop +create function end_label1() returns void as $$ +<> +begin + <> + for i in 1 .. 10 loop + raise notice 'i = %', i; + exit flbl1; + end loop flbl1; + <> + for j in 1 .. 10 loop + raise notice 'j = %', j; + exit flbl2; + end loop; +end blbl; +$$ language plpgsql +-- +FUNCTION: name="end_label1" function="end_label1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 020 +select end_label1() +-- +FUNCTION: name="end_label1" function="end_label1" schema="" ctx=Call +STMT: SelectStmt +== 021 +-- should fail: undefined end label +create function end_label2() returns void as $$ +begin + for _i in 1 .. 10 loop + exit; + end loop flbl1; +end; +$$ language plpgsql +-- +FUNCTION: name="end_label2" function="end_label2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 022 +-- should fail: end label does not match start label +create function end_label3() returns void as $$ +<> +begin + <> + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +FUNCTION: name="end_label3" function="end_label3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 023 +-- should fail: end label on a block without a start label +create function end_label4() returns void as $$ +<> +begin + for _i in 1 .. 10 loop + exit; + end loop outer_label; +end; +$$ language plpgsql +-- +FUNCTION: name="end_label4" function="end_label4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 024 +-- unlabeled exit matches no blocks +do $$ +begin +for i in 1..10 loop + <> + begin + begin -- unlabeled block + exit; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; +end loop; +raise notice 'should get here'; +end$$ +-- +STMT: DoStmt +== 025 +-- check exit out of an unlabeled block to a labeled one +do $$ +<> +begin + <> + begin + <> + begin + begin -- unlabeled block + exit innerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; + end; + raise notice 'nor here'; + end; + raise notice 'should get here'; +end$$ +-- +STMT: DoStmt +== 026 +-- check exit out of outermost block +do $$ +<> +begin + <> + begin + exit outerblock; + raise notice 'should not get here'; + end; + raise notice 'should not get here, either'; +end$$ +-- +STMT: DoStmt +== 027 +-- unlabeled exit does match a while loop +do $$ +begin + <> + while 1 > 0 loop + <> + while 1 > 0 loop + <> + while 1 > 0 loop + exit; + raise notice 'should not get here'; + end loop; + raise notice 'should get here'; + exit outermostwhile; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'should get here, too'; +end$$ +-- +STMT: DoStmt +== 028 +-- check exit out of an unlabeled while to a labeled one +do $$ +begin + <> + while 1 > 0 loop + while 1 > 0 loop + exit outerwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'should get here'; +end$$ +-- +STMT: DoStmt +== 029 +-- continue to an outer while +do $$ +declare i int := 0; +begin + <> + while i < 2 loop + raise notice 'outermostwhile, i = %', i; + i := i + 1; + <> + while 1 > 0 loop + <> + while 1 > 0 loop + continue outermostwhile; + raise notice 'should not get here'; + end loop; + raise notice 'should not get here, either'; + end loop; + raise notice 'nor here'; + end loop; + raise notice 'out of outermostwhile, i = %', i; +end$$ +-- +STMT: DoStmt +== 030 +-- return out of a while +create function return_from_while() returns int language plpgsql as $$ +declare i int := 0; +begin + while i < 10 loop + if i > 2 then + return i; + end if; + i := i + 1; + end loop; + return null; +end$$ +-- +FUNCTION: name="return_from_while" function="return_from_while" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 031 +select return_from_while() +-- +FUNCTION: name="return_from_while" function="return_from_while" schema="" ctx=Call +STMT: SelectStmt +== 032 +-- using list of scalars in fori and fore stmts +create function for_vect() returns void as $proc$ +<>declare a integer; b varchar; c varchar; r record; +begin + -- fori + for i in 1 .. 3 loop + raise notice '%', i; + end loop; + -- fore with record var + for r in select gs as aa, 'BB' as bb, 'CC' as cc from generate_series(1,4) gs loop + raise notice '% % %', r.aa, r.bb, r.cc; + end loop; + -- fore with single scalar + for a in select gs from generate_series(1,4) gs loop + raise notice '%', a; + end loop; + -- fore with multiple scalars + for a,b,c in select gs, 'BB','CC' from generate_series(1,4) gs loop + raise notice '% % %', a, b, c; + end loop; + -- using qualified names in fors, fore is enabled, disabled only for fori + for lbl.a, lbl.b, lbl.c in execute $$select gs, 'bb','cc' from generate_series(1,4) gs$$ loop + raise notice '% % %', a, b, c; + end loop; +end; +$proc$ language plpgsql +-- +FUNCTION: name="for_vect" function="for_vect" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 033 +select for_vect() +-- +FUNCTION: name="for_vect" function="for_vect" schema="" ctx=Call +STMT: SelectStmt +== 034 +-- CASE statement + +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; + b int = 1; +begin + case $1 + when 1 then + return 'one'; + when 2 then + return 'two'; + when 3,4,3+5 then + return 'three, four or eight'; + when a then + return 'ten'; + when a+b, a+b+1 then + return 'eleven, twelve'; + end case; +end; +$$ language plpgsql immutable +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 035 +select case_test(1) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 036 +select case_test(2) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 037 +select case_test(3) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 038 +select case_test(4) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 039 +select case_test(5) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 040 +-- fails +select case_test(8) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 041 +select case_test(10) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 042 +select case_test(11) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 043 +select case_test(12) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 044 +select case_test(13) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- fails + +create or replace function catch() returns void as $$ +begin + raise notice '%', case_test(6); +exception + when case_not_found then + raise notice 'caught case_not_found % %', SQLSTATE, SQLERRM; +end +$$ language plpgsql +-- +FUNCTION: name="catch" function="catch" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 046 +select catch() +-- +FUNCTION: name="catch" function="catch" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- test the searched variant too, as well as ELSE +create or replace function case_test(bigint) returns text as $$ +declare a int = 10; +begin + case + when $1 = 1 then + return 'one'; + when $1 = a + 2 then + return 'twelve'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 048 +select case_test(1) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 049 +select case_test(2) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 050 +select case_test(12) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 051 +select case_test(13) +-- +FUNCTION: name="case_test" function="case_test" schema="" ctx=Call +STMT: SelectStmt +== 052 +-- test line comment between WHEN and THEN +create or replace function case_comment(int) returns text as $$ +begin + case $1 + when 1 -- comment before THEN + then return 'one'; + else + return 'other'; + end case; +end; +$$ language plpgsql immutable +-- +FUNCTION: name="case_comment" function="case_comment" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 053 +select case_comment(1) +-- +FUNCTION: name="case_comment" function="case_comment" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_copy.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_copy.test b/parser/testdata/summary/plpgsql_regress/plpgsql_copy.test new file mode 100644 index 0000000..2788c56 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_copy.test @@ -0,0 +1,21 @@ +== 001 +-- directory paths are passed to us in environment variables + +-- set up file names to use + +CREATE TABLE copy1 (a int, b float); + +-- COPY TO/FROM not authorized from client. +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 TO stdout; +END; +$$; +DO LANGUAGE plpgsql $$ +BEGIN + COPY copy1 FROM stdin; +-- +ERROR: "unterminated dollar-quoted string at or near \"$$\nBEGIN\n COPY copy1 FROM stdin;\"" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_domain.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_domain.test b/parser/testdata/summary/plpgsql_regress/plpgsql_domain.test new file mode 100644 index 0000000..c8305f6 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_domain.test @@ -0,0 +1,557 @@ +== 001 +|-- +-- Tests for PL/pgSQL's behavior with domain types +|-- + +CREATE DOMAIN booltrue AS bool CHECK (VALUE IS TRUE OR VALUE IS NULL) +-- +STMT: CreateDomainStmt +== 002 +CREATE FUNCTION test_argresult_booltrue(x booltrue, y bool) RETURNS booltrue AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_argresult_booltrue" function="test_argresult_booltrue" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +SELECT * FROM test_argresult_booltrue(true, true) +-- +FUNCTION: name="test_argresult_booltrue" function="test_argresult_booltrue" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT * FROM test_argresult_booltrue(false, true) +-- +FUNCTION: name="test_argresult_booltrue" function="test_argresult_booltrue" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT * FROM test_argresult_booltrue(true, false) +-- +FUNCTION: name="test_argresult_booltrue" function="test_argresult_booltrue" schema="" ctx=Call +STMT: SelectStmt +== 006 +CREATE FUNCTION test_assign_booltrue(x bool, y bool) RETURNS booltrue AS $$ +declare v booltrue := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_assign_booltrue" function="test_assign_booltrue" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 007 +SELECT * FROM test_assign_booltrue(true, true) +-- +FUNCTION: name="test_assign_booltrue" function="test_assign_booltrue" schema="" ctx=Call +STMT: SelectStmt +== 008 +SELECT * FROM test_assign_booltrue(false, true) +-- +FUNCTION: name="test_assign_booltrue" function="test_assign_booltrue" schema="" ctx=Call +STMT: SelectStmt +== 009 +SELECT * FROM test_assign_booltrue(true, false) +-- +FUNCTION: name="test_assign_booltrue" function="test_assign_booltrue" schema="" ctx=Call +STMT: SelectStmt +== 010 +CREATE DOMAIN uint2 AS int2 CHECK (VALUE >= 0) +-- +STMT: CreateDomainStmt +== 011 +CREATE FUNCTION test_argresult_uint2(x uint2, y int) RETURNS uint2 AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_argresult_uint2" function="test_argresult_uint2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 012 +SELECT * FROM test_argresult_uint2(100::uint2, 50) +-- +FUNCTION: name="test_argresult_uint2" function="test_argresult_uint2" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT * FROM test_argresult_uint2(100::uint2, -50) +-- +FUNCTION: name="test_argresult_uint2" function="test_argresult_uint2" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT * FROM test_argresult_uint2(null, 1) +-- +FUNCTION: name="test_argresult_uint2" function="test_argresult_uint2" schema="" ctx=Call +STMT: SelectStmt +== 015 +CREATE FUNCTION test_assign_uint2(x int, y int) RETURNS uint2 AS $$ +declare v uint2 := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_assign_uint2" function="test_assign_uint2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 016 +SELECT * FROM test_assign_uint2(100, 50) +-- +FUNCTION: name="test_assign_uint2" function="test_assign_uint2" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT * FROM test_assign_uint2(100, -50) +-- +FUNCTION: name="test_assign_uint2" function="test_assign_uint2" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT * FROM test_assign_uint2(-100, 50) +-- +FUNCTION: name="test_assign_uint2" function="test_assign_uint2" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT * FROM test_assign_uint2(null, 1) +-- +FUNCTION: name="test_assign_uint2" function="test_assign_uint2" schema="" ctx=Call +STMT: SelectStmt +== 020 +CREATE DOMAIN nnint AS int NOT NULL +-- +STMT: CreateDomainStmt +== 021 +CREATE FUNCTION test_argresult_nnint(x nnint, y int) RETURNS nnint AS $$ +begin +return y; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_argresult_nnint" function="test_argresult_nnint" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 022 +SELECT * FROM test_argresult_nnint(10, 20) +-- +FUNCTION: name="test_argresult_nnint" function="test_argresult_nnint" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT * FROM test_argresult_nnint(null, 20) +-- +FUNCTION: name="test_argresult_nnint" function="test_argresult_nnint" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT * FROM test_argresult_nnint(10, null) +-- +FUNCTION: name="test_argresult_nnint" function="test_argresult_nnint" schema="" ctx=Call +STMT: SelectStmt +== 025 +CREATE FUNCTION test_assign_nnint(x int, y int) RETURNS nnint AS $$ +declare v nnint := x; +begin +v := y; +return v; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_assign_nnint" function="test_assign_nnint" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 026 +SELECT * FROM test_assign_nnint(10, 20) +-- +FUNCTION: name="test_assign_nnint" function="test_assign_nnint" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT * FROM test_assign_nnint(null, 20) +-- +FUNCTION: name="test_assign_nnint" function="test_assign_nnint" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT * FROM test_assign_nnint(10, null) +-- +FUNCTION: name="test_assign_nnint" function="test_assign_nnint" schema="" ctx=Call +STMT: SelectStmt +== 029 +|-- +-- Domains over arrays +|-- + +CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]) +-- +STMT: CreateDomainStmt +== 030 +CREATE FUNCTION test_argresult_array_domain(x ordered_pair_domain) + RETURNS ordered_pair_domain AS $$ +begin +return x; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_argresult_array_domain" function="test_argresult_array_domain" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 031 +SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain) +-- +FUNCTION: name="test_argresult_array_domain" function="test_argresult_array_domain" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT * FROM test_argresult_array_domain(NULL::ordered_pair_domain) +-- +FUNCTION: name="test_argresult_array_domain" function="test_argresult_array_domain" schema="" ctx=Call +STMT: SelectStmt +== 033 +CREATE FUNCTION test_argresult_array_domain_check_violation() + RETURNS ordered_pair_domain AS $$ +begin +return array[2,1]; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_argresult_array_domain_check_violation" function="test_argresult_array_domain_check_violation" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 034 +SELECT * FROM test_argresult_array_domain_check_violation() +-- +FUNCTION: name="test_argresult_array_domain_check_violation" function="test_argresult_array_domain_check_violation" schema="" ctx=Call +STMT: SelectStmt +== 035 +CREATE FUNCTION test_assign_ordered_pair_domain(x int, y int, z int) RETURNS ordered_pair_domain AS $$ +declare v ordered_pair_domain := array[x, y]; +begin +v[2] := z; +return v; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_assign_ordered_pair_domain" function="test_assign_ordered_pair_domain" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 036 +SELECT * FROM test_assign_ordered_pair_domain(1,2,3) +-- +FUNCTION: name="test_assign_ordered_pair_domain" function="test_assign_ordered_pair_domain" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT * FROM test_assign_ordered_pair_domain(1,2,0) +-- +FUNCTION: name="test_assign_ordered_pair_domain" function="test_assign_ordered_pair_domain" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT * FROM test_assign_ordered_pair_domain(2,1,3) +-- +FUNCTION: name="test_assign_ordered_pair_domain" function="test_assign_ordered_pair_domain" schema="" ctx=Call +STMT: SelectStmt +== 039 +|-- +-- Arrays of domains +|-- + +CREATE FUNCTION test_read_uint2_array(x uint2[]) RETURNS uint2 AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_read_uint2_array" function="test_read_uint2_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 040 +select test_read_uint2_array(array[1::uint2]) +-- +FUNCTION: name="test_read_uint2_array" function="test_read_uint2_array" schema="" ctx=Call +STMT: SelectStmt +== 041 +CREATE FUNCTION test_build_uint2_array(x int2) RETURNS uint2[] AS $$ +begin +return array[x, x]; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_build_uint2_array" function="test_build_uint2_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 042 +select test_build_uint2_array(1::int2) +-- +FUNCTION: name="test_build_uint2_array" function="test_build_uint2_array" schema="" ctx=Call +STMT: SelectStmt +== 043 +select test_build_uint2_array(-1::int2) +-- +FUNCTION: name="test_build_uint2_array" function="test_build_uint2_array" schema="" ctx=Call +STMT: SelectStmt +== 044 +-- fail + +CREATE FUNCTION test_argresult_domain_array(x integer[]) + RETURNS ordered_pair_domain[] AS $$ +begin +return array[x::ordered_pair_domain, x::ordered_pair_domain]; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_argresult_domain_array" function="test_argresult_domain_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 045 +select test_argresult_domain_array(array[2,4]) +-- +FUNCTION: name="test_argresult_domain_array" function="test_argresult_domain_array" schema="" ctx=Call +STMT: SelectStmt +== 046 +select test_argresult_domain_array(array[4,2]) +-- +FUNCTION: name="test_argresult_domain_array" function="test_argresult_domain_array" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- fail + +CREATE FUNCTION test_argresult_domain_array2(x ordered_pair_domain) + RETURNS integer AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_argresult_domain_array2" function="test_argresult_domain_array2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 048 +select test_argresult_domain_array2(array[2,4]) +-- +FUNCTION: name="test_argresult_domain_array2" function="test_argresult_domain_array2" schema="" ctx=Call +STMT: SelectStmt +== 049 +select test_argresult_domain_array2(array[4,2]) +-- +FUNCTION: name="test_argresult_domain_array2" function="test_argresult_domain_array2" schema="" ctx=Call +STMT: SelectStmt +== 050 +-- fail + +CREATE FUNCTION test_argresult_array_domain_array(x ordered_pair_domain[]) + RETURNS ordered_pair_domain AS $$ +begin +return x[1]; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_argresult_array_domain_array" function="test_argresult_array_domain_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 051 +select test_argresult_array_domain_array(array[array[2,4]::ordered_pair_domain]) +-- +FUNCTION: name="test_argresult_array_domain_array" function="test_argresult_array_domain_array" schema="" ctx=Call +STMT: SelectStmt +== 052 +|-- +-- Domains within composite +|-- + +CREATE TYPE nnint_container AS (f1 int, f2 nnint) +-- +STMT: CompositeTypeStmt +== 053 +CREATE FUNCTION test_result_nnint_container(x int, y int) + RETURNS nnint_container AS $$ +begin +return row(x, y)::nnint_container; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_result_nnint_container" function="test_result_nnint_container" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 054 +SELECT test_result_nnint_container(null, 3) +-- +FUNCTION: name="test_result_nnint_container" function="test_result_nnint_container" schema="" ctx=Call +STMT: SelectStmt +== 055 +SELECT test_result_nnint_container(3, null) +-- +FUNCTION: name="test_result_nnint_container" function="test_result_nnint_container" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- fail + +CREATE FUNCTION test_assign_nnint_container(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container := row(x, y); +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_assign_nnint_container" function="test_assign_nnint_container" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 057 +SELECT * FROM test_assign_nnint_container(1,2,3) +-- +FUNCTION: name="test_assign_nnint_container" function="test_assign_nnint_container" schema="" ctx=Call +STMT: SelectStmt +== 058 +SELECT * FROM test_assign_nnint_container(1,2,null) +-- +FUNCTION: name="test_assign_nnint_container" function="test_assign_nnint_container" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT * FROM test_assign_nnint_container(1,null,3) +-- +FUNCTION: name="test_assign_nnint_container" function="test_assign_nnint_container" schema="" ctx=Call +STMT: SelectStmt +== 060 +-- Since core system allows this: +SELECT null::nnint_container +-- +STMT: SelectStmt +== 061 +-- so should PL/PgSQL + +CREATE FUNCTION test_assign_nnint_container2(x int, y int, z int) + RETURNS nnint_container AS $$ +declare v nnint_container; +begin +v.f2 := z; +return v; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_assign_nnint_container2" function="test_assign_nnint_container2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 062 +SELECT * FROM test_assign_nnint_container2(1,2,3) +-- +FUNCTION: name="test_assign_nnint_container2" function="test_assign_nnint_container2" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT * FROM test_assign_nnint_container2(1,2,null) +-- +FUNCTION: name="test_assign_nnint_container2" function="test_assign_nnint_container2" schema="" ctx=Call +STMT: SelectStmt +== 064 +|-- +-- Domains of composite +|-- + +CREATE TYPE named_pair AS ( + i integer, + j integer +) +-- +STMT: CompositeTypeStmt +== 065 +CREATE DOMAIN ordered_named_pair AS named_pair CHECK((VALUE).i <= (VALUE).j) +-- +STMT: CreateDomainStmt +== 066 +CREATE FUNCTION read_ordered_named_pair(p ordered_named_pair) RETURNS integer AS $$ +begin +return p.i + p.j; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="read_ordered_named_pair" function="read_ordered_named_pair" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 067 +SELECT read_ordered_named_pair(row(1, 2)) +-- +FUNCTION: name="read_ordered_named_pair" function="read_ordered_named_pair" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT read_ordered_named_pair(row(2, 1)) +-- +FUNCTION: name="read_ordered_named_pair" function="read_ordered_named_pair" schema="" ctx=Call +STMT: SelectStmt +== 069 +-- fail + +CREATE FUNCTION build_ordered_named_pair(i int, j int) RETURNS ordered_named_pair AS $$ +begin +return row(i, j); +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="build_ordered_named_pair" function="build_ordered_named_pair" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 070 +SELECT build_ordered_named_pair(1,2) +-- +FUNCTION: name="build_ordered_named_pair" function="build_ordered_named_pair" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT build_ordered_named_pair(2,1) +-- +FUNCTION: name="build_ordered_named_pair" function="build_ordered_named_pair" schema="" ctx=Call +STMT: SelectStmt +== 072 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pair(x int, y int, z int) + RETURNS ordered_named_pair AS $$ +declare v ordered_named_pair := row(x, y); +begin +v.j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_assign_ordered_named_pair" function="test_assign_ordered_named_pair" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 073 +SELECT * FROM test_assign_ordered_named_pair(1,2,3) +-- +FUNCTION: name="test_assign_ordered_named_pair" function="test_assign_ordered_named_pair" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT * FROM test_assign_ordered_named_pair(1,2,0) +-- +FUNCTION: name="test_assign_ordered_named_pair" function="test_assign_ordered_named_pair" schema="" ctx=Call +STMT: SelectStmt +== 075 +SELECT * FROM test_assign_ordered_named_pair(2,1,3) +-- +FUNCTION: name="test_assign_ordered_named_pair" function="test_assign_ordered_named_pair" schema="" ctx=Call +STMT: SelectStmt +== 076 +CREATE FUNCTION build_ordered_named_pairs(i int, j int) RETURNS ordered_named_pair[] AS $$ +begin +return array[row(i, j), row(i, j+1)]; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="build_ordered_named_pairs" function="build_ordered_named_pairs" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 077 +SELECT build_ordered_named_pairs(1,2) +-- +FUNCTION: name="build_ordered_named_pairs" function="build_ordered_named_pairs" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT build_ordered_named_pairs(2,1) +-- +FUNCTION: name="build_ordered_named_pairs" function="build_ordered_named_pairs" schema="" ctx=Call +STMT: SelectStmt +== 079 +-- fail + +CREATE FUNCTION test_assign_ordered_named_pairs(x int, y int, z int) + RETURNS ordered_named_pair[] AS $$ +declare v ordered_named_pair[] := array[row(x, y)]; +begin +-- ideally this would work, but it doesn't yet: +-- v[1].j := z; +return v; +end +$$ LANGUAGE plpgsql +-- +FUNCTION: name="test_assign_ordered_named_pairs" function="test_assign_ordered_named_pairs" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 080 +SELECT * FROM test_assign_ordered_named_pairs(1,2,3) +-- +FUNCTION: name="test_assign_ordered_named_pairs" function="test_assign_ordered_named_pairs" schema="" ctx=Call +STMT: SelectStmt +== 081 +SELECT * FROM test_assign_ordered_named_pairs(2,1,3) +-- +FUNCTION: name="test_assign_ordered_named_pairs" function="test_assign_ordered_named_pairs" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT * FROM test_assign_ordered_named_pairs(1,2,0) +-- +FUNCTION: name="test_assign_ordered_named_pairs" function="test_assign_ordered_named_pairs" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_misc.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_misc.test b/parser/testdata/summary/plpgsql_regress/plpgsql_misc.test new file mode 100644 index 0000000..2f4c85c --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_misc.test @@ -0,0 +1,78 @@ +== 001 +|-- +-- Miscellaneous topics +|-- + +-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE +do +$$ + declare procedure int; -- check we still recognize non-keywords as vars + begin + create function test1() returns int + begin atomic + select 2 + 2; + end; + create or replace procedure test2(x int) + begin atomic + select x + 2; + end; + end +$$ +-- +STMT: DoStmt +== 002 +-- Test %TYPE and %ROWTYPE error cases +create table misc_table(f1 int) +-- +TABLE: name="misc_table" schema="" table="misc_table" ctx=DDL +STMT: CreateStmt +== 003 +do $$ declare x foo%type; begin end $$ +-- +STMT: DoStmt +== 004 +do $$ declare x notice%type; begin end $$ +-- +STMT: DoStmt +== 005 +-- covers unreserved-keyword case +do $$ declare x foo.bar%type; begin end $$ +-- +STMT: DoStmt +== 006 +do $$ declare x foo.bar.baz%type; begin end $$ +-- +STMT: DoStmt +== 007 +do $$ declare x public.foo.bar%type; begin end $$ +-- +STMT: DoStmt +== 008 +do $$ declare x public.misc_table.zed%type; begin end $$ +-- +STMT: DoStmt +== 009 +do $$ declare x foo%rowtype; begin end $$ +-- +STMT: DoStmt +== 010 +do $$ declare x notice%rowtype; begin end $$ +-- +STMT: DoStmt +== 011 +-- covers unreserved-keyword case +do $$ declare x foo.bar%rowtype; begin end $$ +-- +STMT: DoStmt +== 012 +do $$ declare x foo.bar.baz%rowtype; begin end $$ +-- +STMT: DoStmt +== 013 +do $$ declare x public.foo%rowtype; begin end $$ +-- +STMT: DoStmt +== 014 +do $$ declare x public.misc_table%rowtype; begin end $$ +-- +STMT: DoStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_record.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_record.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_record.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_record.test b/parser/testdata/summary/plpgsql_regress/plpgsql_record.test new file mode 100644 index 0000000..da085c0 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_record.test @@ -0,0 +1,1116 @@ +== 001 +|-- +-- Tests for PL/pgSQL handling of composite (record) variables +|-- + +create type two_int4s as (f1 int4, f2 int4) +-- +STMT: CompositeTypeStmt +== 002 +create type more_int4s as (f0 text, f1 int4, f2 int4) +-- +STMT: CompositeTypeStmt +== 003 +create type two_int8s as (q1 int8, q2 int8) +-- +STMT: CompositeTypeStmt +== 004 +create type nested_int8s as (c1 two_int8s, c2 two_int8s) +-- +STMT: CompositeTypeStmt +== 005 +-- base-case return of a composite type +create function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1)::two_int8s; end $$ +-- +FUNCTION: name="retc" function="retc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +select retc(42) +-- +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- ok to return a matching record type +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8); end $$ +-- +FUNCTION: name="retc" function="retc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 008 +select retc(42) +-- +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- we don't currently support implicit casting +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1,1); end $$ +-- +FUNCTION: name="retc" function="retc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 010 +select retc(42) +-- +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 011 +-- nor extra columns +create or replace function retc(int) returns two_int8s language plpgsql as +$$ begin return row($1::int8, 1::int8, 42); end $$ +-- +FUNCTION: name="retc" function="retc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 012 +select retc(42) +-- +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- same cases with an intermediate "record" variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8); return r; end $$ +-- +FUNCTION: name="retc" function="retc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 014 +select retc(42) +-- +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 015 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,1); return r; end $$ +-- +FUNCTION: name="retc" function="retc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 016 +select retc(42) +-- +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 017 +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +FUNCTION: name="retc" function="retc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 018 +select retc(42) +-- +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- but, for mostly historical reasons, we do convert when assigning +-- to a named-composite-type variable +create or replace function retc(int) returns two_int8s language plpgsql as +$$ declare r two_int8s; begin r := row($1::int8, 1::int8, 42); return r; end $$ +-- +FUNCTION: name="retc" function="retc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 020 +select retc(42) +-- +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 021 +do $$ declare c two_int8s; +begin c := row(1,2); raise notice 'c = %', c; end$$ +-- +STMT: DoStmt +== 022 +do $$ declare c two_int8s; +begin for c in select 1,2 loop raise notice 'c = %', c; end loop; end$$ +-- +STMT: DoStmt +== 023 +do $$ declare c4 two_int4s; c8 two_int8s; +begin + c8 := row(1,2); + c4 := c8; + c8 := c4; + raise notice 'c4 = %', c4; + raise notice 'c8 = %', c8; +end$$ +-- +STMT: DoStmt +== 024 +do $$ declare c two_int8s; d nested_int8s; +begin + c := row(1,2); + d := row(c, row(c.q1, c.q2+1)); + raise notice 'c = %, d = %', c, d; + c.q1 := 10; + d.c1 := row(11,12); + d.c2.q2 := 42; + raise notice 'c = %, d = %', c, d; + raise notice 'c.q1 = %, d.c2 = %', c.q1, d.c2; + raise notice '(d).c2.q2 = %', (d).c2.q2; -- doesn't work without parens + raise notice '(d.c2).q2 = %', (d.c2).q2; -- doesn't work without parens +end$$ +-- +STMT: DoStmt +== 025 +-- block-qualified naming +do $$ <> declare c two_int8s; d nested_int8s; +begin + b.c := row(1,2); + b.d := row(b.c, row(b.c.q1, b.c.q2+1)); + raise notice 'b.c = %, b.d = %', b.c, b.d; + b.c.q1 := 10; + b.d.c1 := row(11,12); + b.d.c2.q2 := 42; + raise notice 'b.c = %, b.d = %', b.c, b.d; + raise notice 'b.c.q1 = %, b.d.c2 = %', b.c.q1, b.d.c2; + raise notice '(b.d).c2.q2 = %', (b.d).c2.q2; -- doesn't work without parens + raise notice '(b.d.c2).q2 = %', (b.d.c2).q2; -- doesn't work without parens +end$$ +-- +STMT: DoStmt +== 026 +-- error cases +do $$ declare c two_int8s; begin c.x = 1; end $$ +-- +STMT: DoStmt +== 027 +do $$ declare c nested_int8s; begin c.x = 1; end $$ +-- +STMT: DoStmt +== 028 +do $$ declare c nested_int8s; begin c.x.q1 = 1; end $$ +-- +STMT: DoStmt +== 029 +do $$ declare c nested_int8s; begin c.c2.x = 1; end $$ +-- +STMT: DoStmt +== 030 +do $$ declare c nested_int8s; begin d.c2.x = 1; end $$ +-- +STMT: DoStmt +== 031 +do $$ <> declare c two_int8s; begin b.c.x = 1; end $$ +-- +STMT: DoStmt +== 032 +do $$ <> declare c nested_int8s; begin b.c.x = 1; end $$ +-- +STMT: DoStmt +== 033 +do $$ <> declare c nested_int8s; begin b.c.x.q1 = 1; end $$ +-- +STMT: DoStmt +== 034 +do $$ <> declare c nested_int8s; begin b.c.c2.x = 1; end $$ +-- +STMT: DoStmt +== 035 +do $$ <> declare c nested_int8s; begin b.d.c2.x = 1; end $$ +-- +STMT: DoStmt +== 036 +-- check passing composite result to another function +create function getq1(two_int8s) returns int8 language plpgsql as $$ +declare r two_int8s; begin r := $1; return r.q1; end $$ +-- +FUNCTION: name="getq1" function="getq1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 037 +select getq1(retc(344)) +-- +FUNCTION: name="getq1" function="getq1" schema="" ctx=Call +FUNCTION: name="retc" function="retc" schema="" ctx=Call +STMT: SelectStmt +== 038 +select getq1(row(1,2)) +-- +FUNCTION: name="getq1" function="getq1" schema="" ctx=Call +STMT: SelectStmt +== 039 +do $$ +declare r1 two_int8s; r2 record; x int8; +begin + r1 := retc(345); + perform getq1(r1); + x := getq1(r1); + raise notice 'x = %', x; + r2 := retc(346); + perform getq1(r2); + x := getq1(r2); + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 040 +-- check assignments of composites +do $$ +declare r1 two_int8s; r2 two_int8s; r3 record; r4 record; +begin + r1 := row(1,2); + raise notice 'r1 = %', r1; + r1 := r1; -- shouldn't do anything + raise notice 'r1 = %', r1; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r2.q2 = r1.q1 + 3; -- check that r2 has distinct storage + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := null; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r1 := row(7,11)::two_int8s; + r2 := r1; + raise notice 'r1 = %', r1; + raise notice 'r2 = %', r2; + r3 := row(1,2); + r4 := r3; + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r4.f1 := r4.f1 + 3; -- check that r4 has distinct storage + raise notice 'r3 = %', r3; + raise notice 'r4 = %', r4; + r1 := r3; + raise notice 'r1 = %', r1; + r4 := r1; + raise notice 'r4 = %', r4; + r4.q2 := r4.q2 + 1; -- r4's field names have changed + raise notice 'r4 = %', r4; +end$$ +-- +STMT: DoStmt +== 041 +-- fields of named-type vars read as null if uninitialized +do $$ +declare r1 two_int8s; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; +end$$ +-- +STMT: DoStmt +== 042 +do $$ +declare r1 two_int8s; +begin + raise notice 'r1.q1 = %', r1.q1; + raise notice 'r1.q2 = %', r1.q2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +STMT: DoStmt +== 043 +-- records, not so much +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; +end$$ +-- +STMT: DoStmt +== 044 +-- but OK if you assign first +do $$ +declare r1 record; +begin + raise notice 'r1 = %', r1; + r1 := row(1,2); + raise notice 'r1.f1 = %', r1.f1; + raise notice 'r1.f2 = %', r1.f2; + raise notice 'r1 = %', r1; + raise notice 'r1.nosuchfield = %', r1.nosuchfield; +end$$ +-- +STMT: DoStmt +== 045 +-- check %type with block-qualified variable names +do $$ +<> +declare + v int; + r two_int8s; + v1 v%type; + v2 blk.v%type; + r1 r%type; + r2 blk.r%type; +begin + raise notice '%', pg_typeof(v1); + raise notice '%', pg_typeof(v2); + raise notice '%', pg_typeof(r1); + raise notice '%', pg_typeof(r2); +end$$ +-- +STMT: DoStmt +== 046 +-- check that type record can be passed through %type +do $$ +declare r1 record; + r2 r1%type; +begin + r2 := row(1,2); + raise notice 'r2 = %', r2; + r2 := row(3,4,5); + raise notice 'r2 = %', r2; +end$$ +-- +STMT: DoStmt +== 047 +-- arrays of record are not supported at the moment +do $$ +declare r1 record[]; +begin +end$$ +-- +STMT: DoStmt +== 048 +do $$ +declare r1 record; + r2 r1%type[]; +begin +end$$ +-- +STMT: DoStmt +== 049 +-- check repeated assignments to composite fields +create table some_table (id int, data text) +-- +TABLE: name="some_table" schema="" table="some_table" ctx=DDL +STMT: CreateStmt +== 050 +do $$ +declare r some_table; +begin + r := (23, 'skidoo'); + for i in 1 .. 10 loop + r.id := r.id + i; + r.data := r.data || ' ' || i; + end loop; + raise notice 'r = %', r; +end$$ +-- +STMT: DoStmt +== 051 +-- check behavior of function declared to return "record" + +create function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1); end $$ +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 052 +select returnsrecord(42) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 053 +select * from returnsrecord(42) as r(x int, y int) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 054 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 055 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1); return r; end $$ +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 057 +select returnsrecord(42) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 058 +select * from returnsrecord(42) as r(x int, y int) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 059 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 060 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 061 +-- fail + +-- should work the same with a missing column in the actual result value +create table has_hole(f1 int, f2 int, f3 int) +-- +TABLE: name="has_hole" schema="" table="has_hole" ctx=DDL +STMT: CreateStmt +== 062 +alter table has_hole drop column f2 +-- +TABLE: name="has_hole" schema="" table="has_hole" ctx=DDL +STMT: AlterTableStmt +== 063 +create or replace function returnsrecord(int) returns record language plpgsql as +$$ begin return row($1,$1+1)::has_hole; end $$ +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 064 +select returnsrecord(42) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 065 +select * from returnsrecord(42) as r(x int, y int) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 066 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 067 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 068 +-- fail + +-- same with an intermediate record variable +create or replace function returnsrecord(int) returns record language plpgsql as +$$ declare r record; begin r := row($1,$1+1)::has_hole; return r; end $$ +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 069 +select returnsrecord(42) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 070 +select * from returnsrecord(42) as r(x int, y int) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 071 +select * from returnsrecord(42) as r(x int, y int, z int) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 072 +-- fail +select * from returnsrecord(42) as r(x int, y bigint) +-- +FUNCTION: name="returnsrecord" function="returnsrecord" schema="" ctx=Call +STMT: SelectStmt +== 073 +-- fail + +-- check access to a field of an argument declared "record" +create function getf1(x record) returns int language plpgsql as +$$ begin return x.f1; end $$ +-- +FUNCTION: name="getf1" function="getf1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 074 +select getf1(1) +-- +FUNCTION: name="getf1" function="getf1" schema="" ctx=Call +STMT: SelectStmt +== 075 +select getf1(row(1,2)) +-- +FUNCTION: name="getf1" function="getf1" schema="" ctx=Call +STMT: SelectStmt +== 076 +select getf1(row(1,2)::two_int4s) +-- +FUNCTION: name="getf1" function="getf1" schema="" ctx=Call +STMT: SelectStmt +== 077 +select getf1(row('foo',123,456)::more_int4s) +-- +FUNCTION: name="getf1" function="getf1" schema="" ctx=Call +STMT: SelectStmt +== 078 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf1(row(1,2)::two_int8s) +-- +FUNCTION: name="getf1" function="getf1" schema="" ctx=Call +STMT: SelectStmt +== 079 +select getf1(row(1,2)) +-- +FUNCTION: name="getf1" function="getf1" schema="" ctx=Call +STMT: SelectStmt +== 080 +-- this seemingly-equivalent case behaves a bit differently, +-- because the core parser's handling of $N symbols is simplistic +create function getf2(record) returns int language plpgsql as +$$ begin return $1.f2; end $$ +-- +FUNCTION: name="getf2" function="getf2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 081 +select getf2(row(1,2)) +-- +FUNCTION: name="getf2" function="getf2" schema="" ctx=Call +STMT: SelectStmt +== 082 +-- ideally would work, but does not +select getf2(row(1,2)::two_int4s) +-- +FUNCTION: name="getf2" function="getf2" schema="" ctx=Call +STMT: SelectStmt +== 083 +select getf2(row('foo',123,456)::more_int4s) +-- +FUNCTION: name="getf2" function="getf2" schema="" ctx=Call +STMT: SelectStmt +== 084 +-- check behavior when assignment to FOR-loop variable requires coercion +do $$ +declare r two_int8s; +begin + for r in select i, i+1 from generate_series(1,4) i + loop + raise notice 'r = %', r; + end loop; +end$$ +-- +STMT: DoStmt +== 085 +-- check behavior when returning setof composite +create function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; + h has_hole; +begin + return next h; + r := (1,2); + h := (3,4); + return next r; + return next h; + return next row(5,6); + return next row(7,8)::has_hole; +end$$ +-- +FUNCTION: name="returnssetofholes" function="returnssetofholes" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 086 +select returnssetofholes() +-- +FUNCTION: name="returnssetofholes" function="returnssetofholes" schema="" ctx=Call +STMT: SelectStmt +== 087 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +declare r record; +begin + return next r; -- fails, not assigned yet +end$$ +-- +FUNCTION: name="returnssetofholes" function="returnssetofholes" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 088 +select returnssetofholes() +-- +FUNCTION: name="returnssetofholes" function="returnssetofholes" schema="" ctx=Call +STMT: SelectStmt +== 089 +create or replace function returnssetofholes() returns setof has_hole language plpgsql as +$$ +begin + return next row(1,2,3); -- fails +end$$ +-- +FUNCTION: name="returnssetofholes" function="returnssetofholes" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 090 +select returnssetofholes() +-- +FUNCTION: name="returnssetofholes" function="returnssetofholes" schema="" ctx=Call +STMT: SelectStmt +== 091 +-- check behavior with changes of a named rowtype +create table mutable(f1 int, f2 text) +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DDL +STMT: CreateStmt +== 092 +create function sillyaddone(int) returns int language plpgsql as +$$ declare r mutable; begin r.f1 := $1; return r.f1 + 1; end $$ +-- +FUNCTION: name="sillyaddone" function="sillyaddone" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 093 +select sillyaddone(42) +-- +FUNCTION: name="sillyaddone" function="sillyaddone" schema="" ctx=Call +STMT: SelectStmt +== 094 +-- test for change of type of column f1 should be here someday; +-- for now see plpgsql_cache test + +alter table mutable drop column f1 +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DDL +STMT: AlterTableStmt +== 095 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddone(42) +-- +FUNCTION: name="sillyaddone" function="sillyaddone" schema="" ctx=Call +STMT: SelectStmt +== 096 +-- fail + +create function getf3(x mutable) returns int language plpgsql as +$$ begin return x.f3; end $$ +-- +FUNCTION: name="getf3" function="getf3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 097 +select getf3(null::mutable) +-- +FUNCTION: name="getf3" function="getf3" schema="" ctx=Call +STMT: SelectStmt +== 098 +-- doesn't work yet +alter table mutable add column f3 int +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DDL +STMT: AlterTableStmt +== 099 +select getf3(null::mutable) +-- +FUNCTION: name="getf3" function="getf3" schema="" ctx=Call +STMT: SelectStmt +== 100 +-- now it works +alter table mutable drop column f3 +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DDL +STMT: AlterTableStmt +== 101 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select getf3(null::mutable) +-- +FUNCTION: name="getf3" function="getf3" schema="" ctx=Call +STMT: SelectStmt +== 102 +-- fails again + +-- check behavior with creating/dropping a named rowtype +set check_function_bodies = off +-- +STMT: VariableSetStmt +== 103 +-- else reference to nonexistent type fails + +create function sillyaddtwo(int) returns int language plpgsql as +$$ declare r mutable2; begin r.f1 := $1; return r.f1 + 2; end $$ +-- +FUNCTION: name="sillyaddtwo" function="sillyaddtwo" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 104 +reset check_function_bodies +-- +STMT: VariableSetStmt +== 105 +select sillyaddtwo(42) +-- +FUNCTION: name="sillyaddtwo" function="sillyaddtwo" schema="" ctx=Call +STMT: SelectStmt +== 106 +-- fail +create table mutable2(f1 int, f2 text) +-- +TABLE: name="mutable2" schema="" table="mutable2" ctx=DDL +STMT: CreateStmt +== 107 +select sillyaddtwo(42) +-- +FUNCTION: name="sillyaddtwo" function="sillyaddtwo" schema="" ctx=Call +STMT: SelectStmt +== 108 +drop table mutable2 +-- +TABLE: name="mutable2" schema="" table="mutable2" ctx=DDL +STMT: DropStmt +== 109 +-- the context stack is different when debug_discard_caches +-- is set, so suppress context output +select sillyaddtwo(42) +-- +FUNCTION: name="sillyaddtwo" function="sillyaddtwo" schema="" ctx=Call +STMT: SelectStmt +== 110 +-- fail +create table mutable2(f0 text, f1 int, f2 text) +-- +TABLE: name="mutable2" schema="" table="mutable2" ctx=DDL +STMT: CreateStmt +== 111 +select sillyaddtwo(42) +-- +FUNCTION: name="sillyaddtwo" function="sillyaddtwo" schema="" ctx=Call +STMT: SelectStmt +== 112 +select sillyaddtwo(43) +-- +FUNCTION: name="sillyaddtwo" function="sillyaddtwo" schema="" ctx=Call +STMT: SelectStmt +== 113 +-- check access to system columns in a record variable + +create function sillytrig() returns trigger language plpgsql as +$$begin + raise notice 'old.ctid = %', old.ctid; + raise notice 'old.tableoid = %', old.tableoid::regclass; + return new; +end$$ +-- +FUNCTION: name="sillytrig" function="sillytrig" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 114 +create trigger mutable_trig before update on mutable for each row +execute procedure sillytrig() +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DDL +STMT: CreateTrigStmt +== 115 +insert into mutable values ('foo'), ('bar') +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +update mutable set f2 = f2 || ' baz' +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DML +STMT: UpdateStmt +== 117 +table mutable +-- +TABLE: name="mutable" schema="" table="mutable" ctx=Select +STMT: SelectStmt +== 118 +-- check returning a composite datum from a trigger + +create or replace function sillytrig() returns trigger language plpgsql as +$$begin + return row(new.*); +end$$ +-- +FUNCTION: name="sillytrig" function="sillytrig" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 119 +update mutable set f2 = f2 || ' baz' +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DML +STMT: UpdateStmt +== 120 +table mutable +-- +TABLE: name="mutable" schema="" table="mutable" ctx=Select +STMT: SelectStmt +== 121 +create or replace function sillytrig() returns trigger language plpgsql as +$$declare r record; +begin + r := row(new.*); + return r; +end$$ +-- +FUNCTION: name="sillytrig" function="sillytrig" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 122 +update mutable set f2 = f2 || ' baz' +-- +TABLE: name="mutable" schema="" table="mutable" ctx=DML +STMT: UpdateStmt +== 123 +table mutable +-- +TABLE: name="mutable" schema="" table="mutable" ctx=Select +STMT: SelectStmt +== 124 +|-- +-- Domains of composite +|-- + +create domain ordered_int8s as two_int8s check((value).q1 <= (value).q2) +-- +STMT: CreateDomainStmt +== 125 +create function read_ordered_int8s(p ordered_int8s) returns int8 as $$ +begin return p.q1 + p.q2; end +$$ language plpgsql +-- +FUNCTION: name="read_ordered_int8s" function="read_ordered_int8s" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 126 +select read_ordered_int8s(row(1, 2)) +-- +FUNCTION: name="read_ordered_int8s" function="read_ordered_int8s" schema="" ctx=Call +STMT: SelectStmt +== 127 +select read_ordered_int8s(row(2, 1)) +-- +FUNCTION: name="read_ordered_int8s" function="read_ordered_int8s" schema="" ctx=Call +STMT: SelectStmt +== 128 +-- fail + +create function build_ordered_int8s(i int8, j int8) returns ordered_int8s as $$ +begin return row(i,j); end +$$ language plpgsql +-- +FUNCTION: name="build_ordered_int8s" function="build_ordered_int8s" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 129 +select build_ordered_int8s(1,2) +-- +FUNCTION: name="build_ordered_int8s" function="build_ordered_int8s" schema="" ctx=Call +STMT: SelectStmt +== 130 +select build_ordered_int8s(2,1) +-- +FUNCTION: name="build_ordered_int8s" function="build_ordered_int8s" schema="" ctx=Call +STMT: SelectStmt +== 131 +-- fail + +create function build_ordered_int8s_2(i int8, j int8) returns ordered_int8s as $$ +declare r record; begin r := row(i,j); return r; end +$$ language plpgsql +-- +FUNCTION: name="build_ordered_int8s_2" function="build_ordered_int8s_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 132 +select build_ordered_int8s_2(1,2) +-- +FUNCTION: name="build_ordered_int8s_2" function="build_ordered_int8s_2" schema="" ctx=Call +STMT: SelectStmt +== 133 +select build_ordered_int8s_2(2,1) +-- +FUNCTION: name="build_ordered_int8s_2" function="build_ordered_int8s_2" schema="" ctx=Call +STMT: SelectStmt +== 134 +-- fail + +create function build_ordered_int8s_3(i int8, j int8) returns ordered_int8s as $$ +declare r two_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +FUNCTION: name="build_ordered_int8s_3" function="build_ordered_int8s_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 135 +select build_ordered_int8s_3(1,2) +-- +FUNCTION: name="build_ordered_int8s_3" function="build_ordered_int8s_3" schema="" ctx=Call +STMT: SelectStmt +== 136 +select build_ordered_int8s_3(2,1) +-- +FUNCTION: name="build_ordered_int8s_3" function="build_ordered_int8s_3" schema="" ctx=Call +STMT: SelectStmt +== 137 +-- fail + +create function build_ordered_int8s_4(i int8, j int8) returns ordered_int8s as $$ +declare r ordered_int8s; begin r := row(i,j); return r; end +$$ language plpgsql +-- +FUNCTION: name="build_ordered_int8s_4" function="build_ordered_int8s_4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 138 +select build_ordered_int8s_4(1,2) +-- +FUNCTION: name="build_ordered_int8s_4" function="build_ordered_int8s_4" schema="" ctx=Call +STMT: SelectStmt +== 139 +select build_ordered_int8s_4(2,1) +-- +FUNCTION: name="build_ordered_int8s_4" function="build_ordered_int8s_4" schema="" ctx=Call +STMT: SelectStmt +== 140 +-- fail + +create function build_ordered_int8s_a(i int8, j int8) returns ordered_int8s[] as $$ +begin return array[row(i,j), row(i,j+1)]; end +$$ language plpgsql +-- +FUNCTION: name="build_ordered_int8s_a" function="build_ordered_int8s_a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 141 +select build_ordered_int8s_a(1,2) +-- +FUNCTION: name="build_ordered_int8s_a" function="build_ordered_int8s_a" schema="" ctx=Call +STMT: SelectStmt +== 142 +select build_ordered_int8s_a(2,1) +-- +FUNCTION: name="build_ordered_int8s_a" function="build_ordered_int8s_a" schema="" ctx=Call +STMT: SelectStmt +== 143 +-- fail + +-- check field assignment +do $$ +declare r ordered_int8s; +begin + r.q1 := null; + r.q2 := 43; + r.q1 := 42; + r.q2 := 41; -- fail +end$$ +-- +STMT: DoStmt +== 144 +-- check whole-row assignment +do $$ +declare r ordered_int8s; +begin + r := null; + r := row(null,null); + r := row(1,2); + r := row(2,1); -- fail +end$$ +-- +STMT: DoStmt +== 145 +-- check assignment in for-loop +do $$ +declare r ordered_int8s; +begin + for r in values (1,2),(3,4),(6,5) loop + raise notice 'r = %', r; + end loop; +end$$ +-- +STMT: DoStmt +== 146 +-- check behavior with toastable fields, too + +create type two_texts as (f1 text, f2 text) +-- +STMT: CompositeTypeStmt +== 147 +create domain ordered_texts as two_texts check((value).f1 <= (value).f2) +-- +STMT: CreateDomainStmt +== 148 +create table sometable (id int, a text, b text) +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DDL +STMT: CreateStmt +== 149 +-- b should be compressed, but in-line +insert into sometable values (1, 'a', repeat('ffoob',1000)) +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 150 +-- this b should be out-of-line +insert into sometable values (2, 'a', repeat('ffoob',100000)) +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 151 +-- this pair should fail the domain check +insert into sometable values (3, 'z', repeat('ffoob',100000)) +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 152 +do $$ +declare d ordered_texts; +begin + for d in select a, b from sometable loop + raise notice 'succeeded at "%"', d.f1; + end loop; +end$$ +-- +STMT: DoStmt +== 153 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := row(r.a, r.b); + end loop; +end$$ +-- +STMT: DoStmt +== 154 +do $$ +declare r record; d ordered_texts; +begin + for r in select * from sometable loop + raise notice 'processing row %', r.id; + d := null; + d.f1 := r.a; + d.f2 := r.b; + end loop; +end$$ +-- +STMT: DoStmt +== 155 +-- check coercion of a record result to named-composite function output type +create function compresult(int8) returns two_int8s language plpgsql as +$$ declare r record; begin r := row($1,$1); return r; end $$ +-- +FUNCTION: name="compresult" function="compresult" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 156 +create table two_int8s_tab (f1 two_int8s) +-- +TABLE: name="two_int8s_tab" schema="" table="two_int8s_tab" ctx=DDL +STMT: CreateStmt +== 157 +insert into two_int8s_tab values (compresult(42)) +-- +TABLE: name="two_int8s_tab" schema="" table="two_int8s_tab" ctx=DML +FUNCTION: name="compresult" function="compresult" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 158 +-- reconnect so we lose any local knowledge of anonymous record types +table two_int8s_tab +-- +TABLE: name="two_int8s_tab" schema="" table="two_int8s_tab" ctx=Select +STMT: SelectStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_simple.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_simple.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_simple.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_simple.test b/parser/testdata/summary/plpgsql_regress/plpgsql_simple.test new file mode 100644 index 0000000..3d2e049 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_simple.test @@ -0,0 +1,184 @@ +== 001 +|-- +-- Tests for plpgsql's handling of "simple" expressions +|-- + +-- Check that changes to an inline-able function are handled correctly +create function simplesql(int) returns int language sql +as 'select $1' +-- +FUNCTION: name="simplesql" function="simplesql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +create function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simplesql(n); + if n = 5 then + create or replace function simplesql(int) returns int language sql + as 'select $1 + 100'; + end if; + end loop; + return sum; +end$$ +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 004 +-- Check that changes in search path are dealt with correctly +create schema simple1 +-- +STMT: CreateSchemaStmt +== 005 +create function simple1.simpletarget(int) returns int language plpgsql +as $$begin return $1; end$$ +-- +FUNCTION: name="simple1.simpletarget" function="simpletarget" schema="simple1" ctx=DDL +STMT: CreateFunctionStmt +== 006 +create function simpletarget(int) returns int language plpgsql +as $$begin return $1 + 100; end$$ +-- +FUNCTION: name="simpletarget" function="simpletarget" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 007 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare + sum int := 0; +begin + for n in 1..10 loop + sum := sum + simpletarget(n); + if n = 5 then + set local search_path = 'simple1'; + end if; + end loop; + return sum; +end$$ +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 008 +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- try it with non-volatile functions, too +alter function simple1.simpletarget(int) immutable +-- +STMT: AlterFunctionStmt +== 010 +alter function simpletarget(int) immutable +-- +STMT: AlterFunctionStmt +== 011 +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- make sure flushing local caches changes nothing + +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- Check case where first attempt to determine if it's simple fails + +create function simplesql() returns int language sql +as $$select 1 / 0$$ +-- +FUNCTION: name="simplesql" function="simplesql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 014 +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + select simplesql() into x; + return x; +end$$ +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 015 +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- division by zero occurs during simple-expr check + +create or replace function simplesql() returns int language sql +as $$select 2 + 2$$ +-- +FUNCTION: name="simplesql" function="simplesql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 017 +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- Check case where called function changes from non-SRF to SRF (bug #18497) + +create or replace function simplecaller() returns int language plpgsql +as $$ +declare x int; +begin + x := simplesql(); + return x; +end$$ +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 019 +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 020 +drop function simplesql() +-- +FUNCTION: name="simplesql" function="simplesql" schema="" ctx=DDL +STMT: DropStmt +== 021 +create function simplesql() returns setof int language sql +as $$select 22 + 22$$ +-- +FUNCTION: name="simplesql" function="simplesql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 022 +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 023 +select simplecaller() +-- +FUNCTION: name="simplecaller" function="simplecaller" schema="" ctx=Call +STMT: SelectStmt +== 024 +-- Check handling of simple expression in a scrollable cursor (bug #18859) + +do $$ +declare + p_CurData refcursor; + val int; +begin + open p_CurData scroll for select 42; + fetch p_CurData into val; + raise notice 'val = %', val; +end; $$ +-- +STMT: DoStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_transaction.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_transaction.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_transaction.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_transaction.test b/parser/testdata/summary/plpgsql_regress/plpgsql_transaction.test new file mode 100644 index 0000000..e711447 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_transaction.test @@ -0,0 +1,951 @@ +== 001 +CREATE TABLE test1 (a int, b text) +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: CreateStmt +== 002 +CREATE PROCEDURE transaction_test1(x int, y text) +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..x LOOP + INSERT INTO test1 (a, b) VALUES (i, y); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +FUNCTION: name="transaction_test1" function="transaction_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +CALL transaction_test1(9, 'foo') +-- +FUNCTION: name="transaction_test1" function="transaction_test1" schema="" ctx=Call +STMT: CallStmt +== 004 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 005 +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 006 +DO +LANGUAGE plpgsql +$$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END +$$ +-- +STMT: DoStmt +== 007 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 008 +-- transaction commands not allowed when called in transaction block +START TRANSACTION +-- +STMT: TransactionStmt +== 009 +CALL transaction_test1(9, 'error') +-- +FUNCTION: name="transaction_test1" function="transaction_test1" schema="" ctx=Call +STMT: CallStmt +== 010 +COMMIT +-- +STMT: TransactionStmt +== 011 +START TRANSACTION +-- +STMT: TransactionStmt +== 012 +DO LANGUAGE plpgsql $$ BEGIN COMMIT; END $$ +-- +STMT: DoStmt +== 013 +COMMIT +-- +STMT: TransactionStmt +== 014 +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 015 +-- not allowed in a function +CREATE FUNCTION transaction_test2() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + FOR i IN 0..9 LOOP + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; + RETURN 1; +END +$$ +-- +FUNCTION: name="transaction_test2" function="transaction_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 016 +SELECT transaction_test2() +-- +FUNCTION: name="transaction_test2" function="transaction_test2" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 018 +-- also not allowed if procedure is called from a function +CREATE FUNCTION transaction_test3() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, 'error'); + RETURN 1; +END; +$$ +-- +FUNCTION: name="transaction_test3" function="transaction_test3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 019 +SELECT transaction_test3() +-- +FUNCTION: name="transaction_test3" function="transaction_test3" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 021 +-- DO block inside function +CREATE FUNCTION transaction_test4() RETURNS int +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'DO LANGUAGE plpgsql $x$ BEGIN COMMIT; END $x$'; + RETURN 1; +END; +$$ +-- +FUNCTION: name="transaction_test4" function="transaction_test4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 022 +SELECT transaction_test4() +-- +FUNCTION: name="transaction_test4" function="transaction_test4" schema="" ctx=Call +STMT: SelectStmt +== 023 +-- proconfig settings currently disallow transaction statements +CREATE PROCEDURE transaction_test5() +LANGUAGE plpgsql +SET work_mem = 555 +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +FUNCTION: name="transaction_test5" function="transaction_test5" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 024 +CALL transaction_test5() +-- +FUNCTION: name="transaction_test5" function="transaction_test5" schema="" ctx=Call +STMT: CallStmt +== 025 +-- SECURITY DEFINER currently disallow transaction statements +CREATE PROCEDURE transaction_test5b() +LANGUAGE plpgsql +SECURITY DEFINER +AS $$ +BEGIN + COMMIT; +END; +$$ +-- +FUNCTION: name="transaction_test5b" function="transaction_test5b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 026 +CALL transaction_test5b() +-- +FUNCTION: name="transaction_test5b" function="transaction_test5b" schema="" ctx=Call +STMT: CallStmt +== 027 +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 028 +-- nested procedure calls +CREATE PROCEDURE transaction_test6(c text) +LANGUAGE plpgsql +AS $$ +BEGIN + CALL transaction_test1(9, c); +END; +$$ +-- +FUNCTION: name="transaction_test6" function="transaction_test6" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +CALL transaction_test6('bar') +-- +FUNCTION: name="transaction_test6" function="transaction_test6" schema="" ctx=Call +STMT: CallStmt +== 030 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 031 +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 032 +CREATE PROCEDURE transaction_test7() +LANGUAGE plpgsql +AS $$ +BEGIN + DO 'BEGIN CALL transaction_test1(9, $x$baz$x$); END;'; +END; +$$ +-- +FUNCTION: name="transaction_test7" function="transaction_test7" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 033 +CALL transaction_test7() +-- +FUNCTION: name="transaction_test7" function="transaction_test7" schema="" ctx=Call +STMT: CallStmt +== 034 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 035 +CREATE PROCEDURE transaction_test8() +LANGUAGE plpgsql +AS $$ +BEGIN + EXECUTE 'CALL transaction_test1(10, $x$baz$x$)'; +END; +$$ +-- +FUNCTION: name="transaction_test8" function="transaction_test8" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 036 +CALL transaction_test8() +-- +FUNCTION: name="transaction_test8" function="transaction_test8" schema="" ctx=Call +STMT: CallStmt +== 037 +-- commit inside cursor loop +CREATE TABLE test2 (x int) +-- +TABLE: name="test2" schema="" table="test2" ctx=DDL +STMT: CreateStmt +== 038 +INSERT INTO test2 VALUES (0), (1), (2), (3), (4) +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 040 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + COMMIT; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 041 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 042 +-- check that this doesn't leak a holdable portal +SELECT * FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 043 +-- error in cursor loop with commit +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 044 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (12/(r.x-2)); + COMMIT; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 045 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 046 +SELECT * FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 047 +-- rollback inside cursor loop +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 048 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 049 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 050 +SELECT * FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 051 +-- first commit then rollback inside cursor loop +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 052 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN SELECT * FROM test2 ORDER BY x LOOP + INSERT INTO test1 (a) VALUES (r.x); + IF r.x % 2 = 0 THEN + COMMIT; + ELSE + ROLLBACK; + END IF; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 053 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 054 +SELECT * FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 055 +-- rollback inside cursor loop +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 056 +DO LANGUAGE plpgsql $$ +DECLARE + r RECORD; +BEGIN + FOR r IN UPDATE test2 SET x = x * 2 RETURNING x LOOP + INSERT INTO test1 (a) VALUES (r.x); + ROLLBACK; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 057 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 058 +SELECT * FROM test2 +-- +TABLE: name="test2" schema="" table="test2" ctx=Select +STMT: SelectStmt +== 059 +SELECT * FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 060 +-- interaction of FOR UPDATE cursor with subsequent updates (bug #17050) +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 061 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +DO LANGUAGE plpgsql $$ +DECLARE + l_cur CURSOR FOR SELECT a FROM test1 ORDER BY 1 FOR UPDATE; +BEGIN + FOR r IN l_cur LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 063 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 064 +SELECT * FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 065 +-- like bug #17050, but with implicit cursor +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 066 +INSERT INTO test1 VALUES (1,'one'), (2,'two'), (3,'three') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +DO LANGUAGE plpgsql $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT a FROM test1 FOR UPDATE LOOP + UPDATE test1 SET b = b || ' ' || b WHERE a = r.a; + COMMIT; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 068 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 069 +SELECT * FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 070 +-- commit inside block with exception handler +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 071 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + COMMIT; + INSERT INTO test1 (a) VALUES (1/0); + COMMIT; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +STMT: DoStmt +== 072 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 073 +-- rollback inside block with exception handler +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 074 +DO LANGUAGE plpgsql $$ +BEGIN + BEGIN + INSERT INTO test1 (a) VALUES (1); + ROLLBACK; + INSERT INTO test1 (a) VALUES (1/0); + ROLLBACK; + EXCEPTION + WHEN division_by_zero THEN + RAISE NOTICE 'caught division_by_zero'; + END; +END; +$$ +-- +STMT: DoStmt +== 075 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 076 +-- test commit/rollback inside exception handler, too +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 077 +DO LANGUAGE plpgsql $$ +BEGIN + FOR i IN 1..10 LOOP + BEGIN + INSERT INTO test1 VALUES (i, 'good'); + INSERT INTO test1 VALUES (i/0, 'bad'); + EXCEPTION + WHEN division_by_zero THEN + INSERT INTO test1 VALUES (i, 'exception'); + IF (i % 3) > 0 THEN COMMIT; ELSE ROLLBACK; END IF; + END; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 078 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 079 +-- detoast result of simple expression after commit +CREATE TEMP TABLE test4(f1 text) +-- +TABLE: name="test4" schema="" table="test4" ctx=DDL +STMT: CreateStmt +== 080 +ALTER TABLE test4 ALTER COLUMN f1 SET STORAGE EXTERNAL +-- +TABLE: name="test4" schema="" table="test4" ctx=DDL +STMT: AlterTableStmt +== 081 +-- disable compression +INSERT INTO test4 SELECT repeat('xyzzy', 2000) +-- +TABLE: name="test4" schema="" table="test4" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 082 +-- immutable mark is a bit of a lie, but it serves to make call a simple expr +-- that will return a still-toasted value +CREATE FUNCTION data_source(i int) RETURNS TEXT LANGUAGE sql +AS 'select f1 from test4' IMMUTABLE +-- +FUNCTION: name="data_source" function="data_source" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 083 +DO $$ +declare x text; +begin + for i in 1..3 loop + x := data_source(i); + commit; + end loop; + raise notice 'length(x) = %', length(x); +end $$ +-- +STMT: DoStmt +== 084 +-- operations on composite types vs. internal transactions +DO LANGUAGE plpgsql $$ +declare + c test1 := row(42, 'hello'); + r bool; +begin + for i in 1..3 loop + r := c is not null; + raise notice 'r = %', r; + commit; + end loop; + for i in 1..3 loop + r := c is null; + raise notice 'r = %', r; + rollback; + end loop; +end +$$ +-- +STMT: DoStmt +== 085 +-- COMMIT failures +DO LANGUAGE plpgsql $$ +BEGIN + CREATE TABLE test3 (y int UNIQUE DEFERRABLE INITIALLY DEFERRED); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + COMMIT; + INSERT INTO test3 (y) VALUES (1); + INSERT INTO test3 (y) VALUES (2); + COMMIT; + INSERT INTO test3 (y) VALUES (3); -- won't get here +END; +$$ +-- +STMT: DoStmt +== 086 +SELECT * FROM test3 +-- +TABLE: name="test3" schema="" table="test3" ctx=Select +STMT: SelectStmt +== 087 +-- failure while trying to persist a cursor across a transaction (bug #15703) +CREATE PROCEDURE cursor_fail_during_commit() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + COMMIT; + END LOOP; + END; +$$ +-- +FUNCTION: name="cursor_fail_during_commit" function="cursor_fail_during_commit" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 088 +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 089 +CALL cursor_fail_during_commit() +-- +FUNCTION: name="cursor_fail_during_commit" function="cursor_fail_during_commit" schema="" ctx=Call +STMT: CallStmt +== 090 +-- note that error occurs during first COMMIT, hence nothing is in test1 +SELECT count(*) FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 091 +CREATE PROCEDURE cursor_fail_during_rollback() + LANGUAGE plpgsql +AS $$ + DECLARE id int; + BEGIN + FOR id IN SELECT 1/(x-1000) FROM generate_series(1,1000) x LOOP + INSERT INTO test1 VALUES(id); + ROLLBACK; + END LOOP; + END; +$$ +-- +FUNCTION: name="cursor_fail_during_rollback" function="cursor_fail_during_rollback" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 092 +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 093 +CALL cursor_fail_during_rollback() +-- +FUNCTION: name="cursor_fail_during_rollback" function="cursor_fail_during_rollback" schema="" ctx=Call +STMT: CallStmt +== 094 +SELECT count(*) FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 095 +-- SET TRANSACTION +DO LANGUAGE plpgsql $$ +BEGIN + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; + SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; + PERFORM 1; + RAISE INFO '%', current_setting('transaction_isolation'); + COMMIT; +END; +$$ +-- +STMT: DoStmt +== 096 +-- error cases +DO LANGUAGE plpgsql $$ +BEGIN + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; +END; +$$ +-- +STMT: DoStmt +== 097 +DO LANGUAGE plpgsql $$ +BEGIN + SAVEPOINT foo; +END; +$$ +-- +STMT: DoStmt +== 098 +DO LANGUAGE plpgsql $$ +BEGIN + EXECUTE 'COMMIT'; +END; +$$ +-- +STMT: DoStmt +== 099 +-- snapshot handling test +TRUNCATE test2 +-- +TABLE: name="test2" schema="" table="test2" ctx=DDL +STMT: TruncateStmt +== 100 +CREATE PROCEDURE transaction_test9() +LANGUAGE SQL +AS $$ +INSERT INTO test2 VALUES (42); +$$ +-- +FUNCTION: name="transaction_test9" function="transaction_test9" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 101 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + CALL transaction_test9(); +END +$$ +-- +STMT: DoStmt +== 102 +SELECT * FROM test2 +-- +TABLE: name="test2" schema="" table="test2" ctx=Select +STMT: SelectStmt +== 103 +-- another snapshot handling case: argument expressions of a CALL need +-- to be evaluated with an up-to-date snapshot +CREATE FUNCTION report_count() RETURNS int +STABLE LANGUAGE sql +AS $$ SELECT COUNT(*) FROM test2 $$ +-- +FUNCTION: name="report_count" function="report_count" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 104 +CREATE PROCEDURE transaction_test9b(cnt int) +LANGUAGE plpgsql +AS $$ +BEGIN + RAISE NOTICE 'count = %', cnt; +END +$$ +-- +FUNCTION: name="transaction_test9b" function="transaction_test9b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 105 +DO $$ +BEGIN + CALL transaction_test9b(report_count()); + INSERT INTO test2 VALUES(43); + CALL transaction_test9b(report_count()); +END +$$ +-- +STMT: DoStmt +== 106 +-- Test transaction in procedure with output parameters. This uses a +-- different portal strategy and different code paths in pquery.c. +CREATE PROCEDURE transaction_test10a(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x + 1; + COMMIT; +END; +$$ +-- +FUNCTION: name="transaction_test10a" function="transaction_test10a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 107 +CALL transaction_test10a(10) +-- +FUNCTION: name="transaction_test10a" function="transaction_test10a" schema="" ctx=Call +STMT: CallStmt +== 108 +CREATE PROCEDURE transaction_test10b(INOUT x int) +LANGUAGE plpgsql +AS $$ +BEGIN + x := x - 1; + ROLLBACK; +END; +$$ +-- +FUNCTION: name="transaction_test10b" function="transaction_test10b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 109 +CALL transaction_test10b(10) +-- +FUNCTION: name="transaction_test10b" function="transaction_test10b" schema="" ctx=Call +STMT: CallStmt +== 110 +-- transaction timestamp vs. statement timestamp +CREATE PROCEDURE transaction_test11() +LANGUAGE plpgsql +AS $$ +DECLARE + s1 timestamp with time zone; + s2 timestamp with time zone; + s3 timestamp with time zone; + t1 timestamp with time zone; + t2 timestamp with time zone; + t3 timestamp with time zone; +BEGIN + s1 := statement_timestamp(); + t1 := transaction_timestamp(); + ASSERT s1 = t1; + PERFORM pg_sleep(0.001); + COMMIT; + s2 := statement_timestamp(); + t2 := transaction_timestamp(); + ASSERT s2 = s1; + ASSERT t2 > t1; + PERFORM pg_sleep(0.001); + ROLLBACK; + s3 := statement_timestamp(); + t3 := transaction_timestamp(); + ASSERT s3 = s1; + ASSERT t3 > t2; +END; +$$ +-- +FUNCTION: name="transaction_test11" function="transaction_test11" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 111 +CALL transaction_test11() +-- +FUNCTION: name="transaction_test11" function="transaction_test11" schema="" ctx=Call +STMT: CallStmt +== 112 +-- transaction chain + +TRUNCATE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: TruncateStmt +== 113 +DO LANGUAGE plpgsql $$ +BEGIN + ROLLBACK; + SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; + FOR i IN 0..3 LOOP + RAISE INFO 'transaction_isolation = %', current_setting('transaction_isolation'); + INSERT INTO test1 (a) VALUES (i); + IF i % 2 = 0 THEN + COMMIT AND CHAIN; + ELSE + ROLLBACK AND CHAIN; + END IF; + END LOOP; +END +$$ +-- +STMT: DoStmt +== 114 +SELECT * FROM test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: SelectStmt +== 115 +DROP TABLE test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: DropStmt +== 116 +DROP TABLE test2 +-- +TABLE: name="test2" schema="" table="test2" ctx=DDL +STMT: DropStmt +== 117 +DROP TABLE test3 +-- +TABLE: name="test3" schema="" table="test3" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_trap.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_trap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_trap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_trap.test b/parser/testdata/summary/plpgsql_regress/plpgsql_trap.test new file mode 100644 index 0000000..91f9b48 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_trap.test @@ -0,0 +1,329 @@ +== 001 +|-- +-- Test error trapping +|-- + +create function trap_zero_divide(int) returns int as $$ +declare x int; + sx smallint; +begin + begin -- start a subtransaction + raise notice 'should see this'; + x := 100 / $1; + raise notice 'should see this only if % <> 0', $1; + sx := $1; + raise notice 'should see this only if % fits in smallint', $1; + if $1 < 0 then + raise exception '% is less than zero', $1; + end if; + exception + when division_by_zero then + raise notice 'caught division_by_zero'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE then + raise notice 'caught numeric_value_out_of_range'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +FUNCTION: name="trap_zero_divide" function="trap_zero_divide" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +select trap_zero_divide(50) +-- +FUNCTION: name="trap_zero_divide" function="trap_zero_divide" schema="" ctx=Call +STMT: SelectStmt +== 003 +select trap_zero_divide(0) +-- +FUNCTION: name="trap_zero_divide" function="trap_zero_divide" schema="" ctx=Call +STMT: SelectStmt +== 004 +select trap_zero_divide(100000) +-- +FUNCTION: name="trap_zero_divide" function="trap_zero_divide" schema="" ctx=Call +STMT: SelectStmt +== 005 +select trap_zero_divide(-100) +-- +FUNCTION: name="trap_zero_divide" function="trap_zero_divide" schema="" ctx=Call +STMT: SelectStmt +== 006 +create table match_source as + select x as id, x*10 as data, x/10 as ten from generate_series(1,100) x +-- +TABLE: name="match_source" schema="" table="match_source" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 007 +create function trap_matching_test(int) returns int as $$ +declare x int; + sx smallint; + y int; +begin + begin -- start a subtransaction + x := 100 / $1; + sx := $1; + select into y data from match_source where id = + (select id from match_source b where ten = $1); + exception + when data_exception then -- category match + raise notice 'caught data_exception'; + x := -1; + when NUMERIC_VALUE_OUT_OF_RANGE OR CARDINALITY_VIOLATION then + raise notice 'caught numeric_value_out_of_range or cardinality_violation'; + x := -2; + end; + return x; +end$$ language plpgsql +-- +FUNCTION: name="trap_matching_test" function="trap_matching_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 008 +select trap_matching_test(50) +-- +FUNCTION: name="trap_matching_test" function="trap_matching_test" schema="" ctx=Call +STMT: SelectStmt +== 009 +select trap_matching_test(0) +-- +FUNCTION: name="trap_matching_test" function="trap_matching_test" schema="" ctx=Call +STMT: SelectStmt +== 010 +select trap_matching_test(100000) +-- +FUNCTION: name="trap_matching_test" function="trap_matching_test" schema="" ctx=Call +STMT: SelectStmt +== 011 +select trap_matching_test(1) +-- +FUNCTION: name="trap_matching_test" function="trap_matching_test" schema="" ctx=Call +STMT: SelectStmt +== 012 +create temp table foo (f1 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 013 +create function subxact_rollback_semantics() returns int as $$ +declare x int; +begin + x := 1; + insert into foo values(x); + begin + x := x + 1; + insert into foo values(x); + raise exception 'inner'; + exception + when others then + x := x * 10; + end; + insert into foo values(x); + return x; +end$$ language plpgsql +-- +FUNCTION: name="subxact_rollback_semantics" function="subxact_rollback_semantics" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 014 +select subxact_rollback_semantics() +-- +FUNCTION: name="subxact_rollback_semantics" function="subxact_rollback_semantics" schema="" ctx=Call +STMT: SelectStmt +== 015 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 016 +drop table foo +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: DropStmt +== 017 +create function trap_timeout() returns void as $$ +begin + declare x int; + begin + -- we assume this will take longer than 1 second: + select count(*) into x from generate_series(1, 1_000_000_000_000); + exception + when others then + raise notice 'caught others?'; + when query_canceled then + raise notice 'nyeah nyeah, can''t stop me'; + end; + -- Abort transaction to abandon the statement_timeout setting. Otherwise, + -- the next top-level statement would be vulnerable to the timeout. + raise exception 'end of function'; +end$$ language plpgsql +-- +FUNCTION: name="trap_timeout" function="trap_timeout" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 018 +begin +-- +STMT: TransactionStmt +== 019 +set statement_timeout to 1000 +-- +STMT: VariableSetStmt +== 020 +select trap_timeout() +-- +FUNCTION: name="trap_timeout" function="trap_timeout" schema="" ctx=Call +STMT: SelectStmt +== 021 +rollback +-- +STMT: TransactionStmt +== 022 +-- Test for pass-by-ref values being stored in proper context +create function test_variable_storage() returns text as $$ +declare x text; +begin + x := '1234'; + begin + x := x || '5678'; + -- force error inside subtransaction SPI context + perform trap_zero_divide(-100); + exception + when others then + x := x || '9012'; + end; + return x; +end$$ language plpgsql +-- +FUNCTION: name="test_variable_storage" function="test_variable_storage" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 023 +select test_variable_storage() +-- +FUNCTION: name="test_variable_storage" function="test_variable_storage" schema="" ctx=Call +STMT: SelectStmt +== 024 +|-- +-- test foreign key error trapping +|-- + +create temp table root(f1 int primary key) +-- +TABLE: name="root" schema="" table="root" ctx=DDL +STMT: CreateStmt +== 025 +create temp table leaf(f1 int references root deferrable) +-- +TABLE: name="leaf" schema="" table="leaf" ctx=DDL +STMT: CreateStmt +== 026 +insert into root values(1) +-- +TABLE: name="root" schema="" table="root" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +insert into leaf values(1) +-- +TABLE: name="leaf" schema="" table="leaf" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +insert into leaf values(2) +-- +TABLE: name="leaf" schema="" table="leaf" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +-- fails + +create function trap_foreign_key(int) returns int as $$ +begin + begin -- start a subtransaction + insert into leaf values($1); + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +FUNCTION: name="trap_foreign_key" function="trap_foreign_key" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 030 +create function trap_foreign_key_2() returns int as $$ +begin + begin -- start a subtransaction + set constraints all immediate; + exception + when foreign_key_violation then + raise notice 'caught foreign_key_violation'; + return 0; + end; + return 1; +end$$ language plpgsql +-- +FUNCTION: name="trap_foreign_key_2" function="trap_foreign_key_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 031 +select trap_foreign_key(1) +-- +FUNCTION: name="trap_foreign_key" function="trap_foreign_key" schema="" ctx=Call +STMT: SelectStmt +== 032 +select trap_foreign_key(2) +-- +FUNCTION: name="trap_foreign_key" function="trap_foreign_key" schema="" ctx=Call +STMT: SelectStmt +== 033 +-- detects FK violation + +begin +-- +STMT: TransactionStmt +== 034 +set constraints all deferred +-- +STMT: ConstraintsSetStmt +== 035 +select trap_foreign_key(2) +-- +FUNCTION: name="trap_foreign_key" function="trap_foreign_key" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- should not detect FK violation + savepoint x +-- +STMT: TransactionStmt +== 037 +set constraints all immediate +-- +STMT: ConstraintsSetStmt +== 038 +-- fails + rollback to x +-- +STMT: TransactionStmt +== 039 +select trap_foreign_key_2() +-- +FUNCTION: name="trap_foreign_key_2" function="trap_foreign_key_2" schema="" ctx=Call +STMT: SelectStmt +== 040 +-- detects FK violation +commit +-- +STMT: TransactionStmt +== 041 +-- still fails + +drop function trap_foreign_key(int) +-- +FUNCTION: name="trap_foreign_key" function="trap_foreign_key" schema="" ctx=DDL +STMT: DropStmt +== 042 +drop function trap_foreign_key_2() +-- +FUNCTION: name="trap_foreign_key_2" function="trap_foreign_key_2" schema="" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_trigger.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_trigger.test b/parser/testdata/summary/plpgsql_regress/plpgsql_trigger.test new file mode 100644 index 0000000..76e946b --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_trigger.test @@ -0,0 +1,44 @@ +== 001 +-- Simple test to verify accessibility of the OLD and NEW trigger variables + +create table testtr (a int, b text) +-- +TABLE: name="testtr" schema="" table="testtr" ctx=DDL +STMT: CreateStmt +== 002 +create function testtr_trigger() returns trigger language plpgsql as +$$begin + raise notice 'tg_op = %', tg_op; + raise notice 'old(%) = %', old.a, row(old.*); + raise notice 'new(%) = %', new.a, row(new.*); + if (tg_op = 'DELETE') then + return old; + else + return new; + end if; +end$$ +-- +FUNCTION: name="testtr_trigger" function="testtr_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +create trigger testtr_trigger before insert or delete or update on testtr + for each row execute function testtr_trigger() +-- +TABLE: name="testtr" schema="" table="testtr" ctx=DDL +STMT: CreateTrigStmt +== 004 +insert into testtr values (1, 'one'), (2, 'two') +-- +TABLE: name="testtr" schema="" table="testtr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +update testtr set a = a + 1 +-- +TABLE: name="testtr" schema="" table="testtr" ctx=DML +STMT: UpdateStmt +== 006 +delete from testtr +-- +TABLE: name="testtr" schema="" table="testtr" ctx=DML +STMT: DeleteStmt diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_varprops.metadata.json b/parser/testdata/summary/plpgsql_regress/plpgsql_varprops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_varprops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/plpgsql_regress/plpgsql_varprops.test b/parser/testdata/summary/plpgsql_regress/plpgsql_varprops.test new file mode 100644 index 0000000..ce18138 --- /dev/null +++ b/parser/testdata/summary/plpgsql_regress/plpgsql_varprops.test @@ -0,0 +1,325 @@ +== 001 +|-- +-- Tests for PL/pgSQL variable properties: CONSTANT, NOT NULL, initializers +|-- + +create type var_record as (f1 int4, f2 int4) +-- +STMT: CompositeTypeStmt +== 002 +create domain int_nn as int not null +-- +STMT: CreateDomainStmt +== 003 +create domain var_record_nn as var_record not null +-- +STMT: CreateDomainStmt +== 004 +create domain var_record_colnn as var_record check((value).f2 is not null) +-- +STMT: CreateDomainStmt +== 005 +-- CONSTANT + +do $$ +declare x constant int := 42; +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 006 +do $$ +declare x constant int; +begin + x := 42; -- fail +end$$ +-- +STMT: DoStmt +== 007 +do $$ +declare x constant int; y int; +begin + for x, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +STMT: DoStmt +== 008 +do $$ +declare x constant int[]; +begin + x[1] := 42; -- fail +end$$ +-- +STMT: DoStmt +== 009 +do $$ +declare x constant int[]; y int; +begin + for x[1], y in select 1, 2 loop -- fail (currently, unsupported syntax) + end loop; +end$$ +-- +STMT: DoStmt +== 010 +do $$ +declare x constant var_record; +begin + x.f1 := 42; -- fail +end$$ +-- +STMT: DoStmt +== 011 +do $$ +declare x constant var_record; y int; +begin + for x.f1, y in select 1, 2 loop -- fail + end loop; +end$$ +-- +STMT: DoStmt +== 012 +-- initializer expressions + +do $$ +declare x int := sin(0); +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 013 +do $$ +declare x int := 1/0; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 014 +do $$ +declare x bigint[] := array[1,3,5]; +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 015 +do $$ +declare x record := row(1,2,3); +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 016 +do $$ +declare x var_record := row(1,2); +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 017 +-- NOT NULL + +do $$ +declare x int not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 018 +do $$ +declare x int not null := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +STMT: DoStmt +== 019 +do $$ +declare x int not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 020 +do $$ +declare x record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 021 +do $$ +declare x record not null := row(42); +begin + raise notice 'x = %', x; + x := row(null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +STMT: DoStmt +== 022 +do $$ +declare x record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 023 +do $$ +declare x var_record not null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 024 +do $$ +declare x var_record not null := row(41,42); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +STMT: DoStmt +== 025 +do $$ +declare x var_record not null := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 026 +-- Check that variables are reinitialized on block re-entry. + +do $$ +begin + for i in 1..3 loop + declare + x int; + y int := i; + r record; + c var_record; + begin + if i = 1 then + x := 42; + r := row(i, i+1); + c := row(i, i+1); + end if; + raise notice 'x = %', x; + raise notice 'y = %', y; + raise notice 'r = %', r; + raise notice 'c = %', c; + end; + end loop; +end$$ +-- +STMT: DoStmt +== 027 +-- Check enforcement of domain constraints during initialization + +do $$ +declare x int_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 028 +do $$ +declare x int_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 029 +do $$ +declare x int_nn := 42; +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +STMT: DoStmt +== 030 +do $$ +declare x var_record_nn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 031 +do $$ +declare x var_record_nn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 032 +do $$ +declare x var_record_nn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- ok + x := null; -- fail +end$$ +-- +STMT: DoStmt +== 033 +do $$ +declare x var_record_colnn; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 034 +do $$ +declare x var_record_colnn := null; -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 035 +do $$ +declare x var_record_colnn := row(1,null); -- fail +begin + raise notice 'x = %', x; +end$$ +-- +STMT: DoStmt +== 036 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := null; -- fail +end$$ +-- +STMT: DoStmt +== 037 +do $$ +declare x var_record_colnn := row(1,2); +begin + raise notice 'x = %', x; + x := row(null,null); -- fail +end$$ +-- +STMT: DoStmt diff --git a/parser/testdata/summary/postgres_regress/advisory_lock.metadata.json b/parser/testdata/summary/postgres_regress/advisory_lock.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/advisory_lock.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/advisory_lock.test b/parser/testdata/summary/postgres_regress/advisory_lock.test new file mode 100644 index 0000000..40a45f9 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/advisory_lock.test @@ -0,0 +1,333 @@ +== 001 +|-- +-- ADVISORY LOCKS +|-- + +SELECT oid AS datoid FROM pg_database WHERE datname = current_database() +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +== 002 +BEGIN +-- +STMT: TransactionStmt +== 003 +SELECT + pg_advisory_xact_lock(1), pg_advisory_xact_lock_shared(2), + pg_advisory_xact_lock(1, 1), pg_advisory_xact_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- pg_advisory_unlock_all() shouldn't release xact locks +SELECT pg_advisory_unlock_all() +-- +FUNCTION: name="pg_advisory_unlock_all" function="pg_advisory_unlock_all" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- can't unlock xact locks +SELECT + pg_advisory_unlock(1), pg_advisory_unlock_shared(2), + pg_advisory_unlock(1, 1), pg_advisory_unlock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- automatically release xact locks at commit +COMMIT +-- +STMT: TransactionStmt +== 009 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 010 +BEGIN +-- +STMT: TransactionStmt +== 011 +-- holding both session and xact locks on the same objects, xact first +SELECT + pg_advisory_xact_lock(1), pg_advisory_xact_lock_shared(2), + pg_advisory_xact_lock(1, 1), pg_advisory_xact_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 013 +SELECT + pg_advisory_lock(1), pg_advisory_lock_shared(2), + pg_advisory_lock(1, 1), pg_advisory_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +STMT: SelectStmt +== 014 +ROLLBACK +-- +STMT: TransactionStmt +== 015 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 016 +-- unlocking session locks +SELECT + pg_advisory_unlock(1), pg_advisory_unlock(1), + pg_advisory_unlock_shared(2), pg_advisory_unlock_shared(2), + pg_advisory_unlock(1, 1), pg_advisory_unlock(1, 1), + pg_advisory_unlock_shared(2, 2), pg_advisory_unlock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 018 +BEGIN +-- +STMT: TransactionStmt +== 019 +-- holding both session and xact locks on the same objects, session first +SELECT + pg_advisory_lock(1), pg_advisory_lock_shared(2), + pg_advisory_lock(1, 1), pg_advisory_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 021 +SELECT + pg_advisory_xact_lock(1), pg_advisory_xact_lock_shared(2), + pg_advisory_xact_lock(1, 1), pg_advisory_xact_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +== 022 +ROLLBACK +-- +STMT: TransactionStmt +== 023 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 024 +-- releasing all session locks +SELECT pg_advisory_unlock_all() +-- +FUNCTION: name="pg_advisory_unlock_all" function="pg_advisory_unlock_all" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 026 +BEGIN +-- +STMT: TransactionStmt +== 027 +-- grabbing txn locks multiple times + +SELECT + pg_advisory_xact_lock(1), pg_advisory_xact_lock(1), + pg_advisory_xact_lock_shared(2), pg_advisory_xact_lock_shared(2), + pg_advisory_xact_lock(1, 1), pg_advisory_xact_lock(1, 1), + pg_advisory_xact_lock_shared(2, 2), pg_advisory_xact_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 029 +COMMIT +-- +STMT: TransactionStmt +== 030 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 031 +-- grabbing session locks multiple times + +SELECT + pg_advisory_lock(1), pg_advisory_lock(1), + pg_advisory_lock_shared(2), pg_advisory_lock_shared(2), + pg_advisory_lock(1, 1), pg_advisory_lock(1, 1), + pg_advisory_lock_shared(2, 2), pg_advisory_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 033 +SELECT + pg_advisory_unlock(1), pg_advisory_unlock(1), + pg_advisory_unlock_shared(2), pg_advisory_unlock_shared(2), + pg_advisory_unlock(1, 1), pg_advisory_unlock(1, 1), + pg_advisory_unlock_shared(2, 2), pg_advisory_unlock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 035 +-- .. and releasing them all at once + +SELECT + pg_advisory_lock(1), pg_advisory_lock(1), + pg_advisory_lock_shared(2), pg_advisory_lock_shared(2), + pg_advisory_lock(1, 1), pg_advisory_lock(1, 1), + pg_advisory_lock_shared(2, 2), pg_advisory_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +STMT: SelectStmt +== 036 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 037 +SELECT pg_advisory_unlock_all() +-- +FUNCTION: name="pg_advisory_unlock_all" function="pg_advisory_unlock_all" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary/postgres_regress/aggregates.metadata.json b/parser/testdata/summary/postgres_regress/aggregates.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/aggregates.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/aggregates.test b/parser/testdata/summary/postgres_regress/aggregates.test new file mode 100644 index 0000000..810e78d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/aggregates.test @@ -0,0 +1,4009 @@ +== 001 +|-- +-- AGGREGATES +|-- + +-- directory paths are passed to us in environment variables + +-- avoid bit-exact output here because operations may not be bit-exact. +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +== 002 +-- prepare some test data +CREATE TABLE aggtest ( + a int2, + b float4 +) +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=DDL +STMT: CreateStmt +== 003 +COPY aggtest FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +ANALYZE aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=DDL +STMT: VacuumStmt +== 005 +SELECT avg(four) AS avg_1 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT avg(a) AS avg_32 FROM aggtest WHERE a < 100 +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 007 +SELECT any_value(v) FROM (VALUES (1), (2), (3)) AS v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +== 008 +SELECT any_value(v) FROM (VALUES (NULL)) AS v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +== 009 +SELECT any_value(v) FROM (VALUES (NULL), (1), (2)) AS v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT any_value(v) FROM (VALUES (array['hello', 'world'])) AS v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +== 011 +-- In 7.1, avg(float4) is computed using float8 arithmetic. +-- Round the result to 3 digits to avoid platform-specific results. + +SELECT avg(b)::numeric(10,3) AS avg_107_943 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT avg(gpa) AS avg_3_4 FROM ONLY student +-- +TABLE: name="student" schema="" table="student" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT sum(four) AS sum_1500 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT sum(a) AS sum_198 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT sum(b) AS avg_431_773 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT sum(gpa) AS avg_6_8 FROM ONLY student +-- +TABLE: name="student" schema="" table="student" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT max(four) AS max_3 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT max(a) AS max_100 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT max(aggtest.b) AS max_324_78 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT max(student.gpa) AS max_3_7 FROM student +-- +TABLE: name="student" schema="" table="student" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT stddev_pop(b) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT stddev_samp(b) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT var_pop(b) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT var_samp(b) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT stddev_pop(b::numeric) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +== 026 +SELECT stddev_samp(b::numeric) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT var_pop(b::numeric) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT var_samp(b::numeric) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 029 +-- population variance is defined for a single tuple, sample variance +-- is not +SELECT var_pop(1.0::float8), var_samp(2.0::float8) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT stddev_pop(3.0::float8), stddev_samp(4.0::float8) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT var_pop('inf'::float8), var_samp('inf'::float8) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT stddev_pop('inf'::float8), stddev_samp('inf'::float8) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT var_pop('nan'::float8), var_samp('nan'::float8) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT stddev_pop('nan'::float8), stddev_samp('nan'::float8) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT var_pop(1.0::float4), var_samp(2.0::float4) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 036 +SELECT stddev_pop(3.0::float4), stddev_samp(4.0::float4) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT var_pop('inf'::float4), var_samp('inf'::float4) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT stddev_pop('inf'::float4), stddev_samp('inf'::float4) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 039 +SELECT var_pop('nan'::float4), var_samp('nan'::float4) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT stddev_pop('nan'::float4), stddev_samp('nan'::float4) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 041 +SELECT var_pop(1.0::numeric), var_samp(2.0::numeric) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 042 +SELECT stddev_pop(3.0::numeric), stddev_samp(4.0::numeric) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT var_pop('inf'::numeric), var_samp('inf'::numeric) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT stddev_pop('inf'::numeric), stddev_samp('inf'::numeric) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 045 +SELECT var_pop('nan'::numeric), var_samp('nan'::numeric) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 046 +SELECT stddev_pop('nan'::numeric), stddev_samp('nan'::numeric) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- verify correct results for null and NaN inputs +select sum(null::int4) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 048 +select sum(null::int8) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 049 +select sum(null::numeric) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 050 +select sum(null::float8) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 051 +select avg(null::int4) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 052 +select avg(null::int8) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 053 +select avg(null::numeric) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 054 +select avg(null::float8) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 055 +select sum('NaN'::numeric) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 056 +select avg('NaN'::numeric) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 057 +-- verify correct results for infinite inputs +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('1'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 058 +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('infinity'), ('1')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('infinity'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('-infinity'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('-infinity'), ('-infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 062 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('1'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('infinity'), ('1')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('infinity'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 065 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('-infinity'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 066 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('-infinity'), ('-infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 067 +-- test accuracy with a large input offset +SELECT avg(x::float8), var_pop(x::float8) +FROM (VALUES (100000003), (100000004), (100000006), (100000007)) v(x) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT avg(x::float8), var_pop(x::float8) +FROM (VALUES (7000000000005), (7000000000007)) v(x) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 069 +-- SQL2003 binary aggregates +SELECT regr_count(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_count" function="regr_count" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT regr_sxx(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT regr_syy(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +STMT: SelectStmt +== 072 +SELECT regr_sxy(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +STMT: SelectStmt +== 073 +SELECT regr_avgx(b, a), regr_avgy(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_avgx" function="regr_avgx" schema="" ctx=Call +FUNCTION: name="regr_avgy" function="regr_avgy" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT regr_r2(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_r2" function="regr_r2" schema="" ctx=Call +STMT: SelectStmt +== 075 +SELECT regr_slope(b, a), regr_intercept(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_slope" function="regr_slope" schema="" ctx=Call +FUNCTION: name="regr_intercept" function="regr_intercept" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT covar_pop(b, a), covar_samp(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="covar_pop" function="covar_pop" schema="" ctx=Call +FUNCTION: name="covar_samp" function="covar_samp" schema="" ctx=Call +STMT: SelectStmt +== 077 +SELECT corr(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="corr" function="corr" schema="" ctx=Call +STMT: SelectStmt +== 078 +-- check single-tuple behavior +SELECT covar_pop(1::float8,2::float8), covar_samp(3::float8,4::float8) +-- +FUNCTION: name="covar_pop" function="covar_pop" schema="" ctx=Call +FUNCTION: name="covar_samp" function="covar_samp" schema="" ctx=Call +STMT: SelectStmt +== 079 +SELECT covar_pop(1::float8,'inf'::float8), covar_samp(3::float8,'inf'::float8) +-- +FUNCTION: name="covar_pop" function="covar_pop" schema="" ctx=Call +FUNCTION: name="covar_samp" function="covar_samp" schema="" ctx=Call +STMT: SelectStmt +== 080 +SELECT covar_pop(1::float8,'nan'::float8), covar_samp(3::float8,'nan'::float8) +-- +FUNCTION: name="covar_pop" function="covar_pop" schema="" ctx=Call +FUNCTION: name="covar_samp" function="covar_samp" schema="" ctx=Call +STMT: SelectStmt +== 081 +-- test accum and combine functions directly +CREATE TABLE regr_test (x float8, y float8) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=DDL +STMT: CreateStmt +== 082 +INSERT INTO regr_test VALUES (10,150),(20,250),(30,350),(80,540),(100,200) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 083 +SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x) +FROM regr_test WHERE x IN (10,20,30,80) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 084 +SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x) +FROM regr_test +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +STMT: SelectStmt +== 085 +SELECT float8_accum('{4,140,2900}'::float8[], 100) +-- +FUNCTION: name="float8_accum" function="float8_accum" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT float8_regr_accum('{4,140,2900,1290,83075,15050}'::float8[], 200, 100) +-- +FUNCTION: name="float8_regr_accum" function="float8_regr_accum" schema="" ctx=Call +STMT: SelectStmt +== 087 +SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x) +FROM regr_test WHERE x IN (10,20,30) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 088 +SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x) +FROM regr_test WHERE x IN (80,100) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 089 +SELECT float8_combine('{3,60,200}'::float8[], '{0,0,0}'::float8[]) +-- +FUNCTION: name="float8_combine" function="float8_combine" schema="" ctx=Call +STMT: SelectStmt +== 090 +SELECT float8_combine('{0,0,0}'::float8[], '{2,180,200}'::float8[]) +-- +FUNCTION: name="float8_combine" function="float8_combine" schema="" ctx=Call +STMT: SelectStmt +== 091 +SELECT float8_combine('{3,60,200}'::float8[], '{2,180,200}'::float8[]) +-- +FUNCTION: name="float8_combine" function="float8_combine" schema="" ctx=Call +STMT: SelectStmt +== 092 +SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[], + '{0,0,0,0,0,0}'::float8[]) +-- +FUNCTION: name="float8_regr_combine" function="float8_regr_combine" schema="" ctx=Call +STMT: SelectStmt +== 093 +SELECT float8_regr_combine('{0,0,0,0,0,0}'::float8[], + '{2,180,200,740,57800,-3400}'::float8[]) +-- +FUNCTION: name="float8_regr_combine" function="float8_regr_combine" schema="" ctx=Call +STMT: SelectStmt +== 094 +SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[], + '{2,180,200,740,57800,-3400}'::float8[]) +-- +FUNCTION: name="float8_regr_combine" function="float8_regr_combine" schema="" ctx=Call +STMT: SelectStmt +== 095 +DROP TABLE regr_test +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=DDL +STMT: DropStmt +== 096 +-- test count, distinct +SELECT count(four) AS cnt_1000 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 097 +SELECT count(DISTINCT four) AS cnt_4 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 098 +select ten, count(*), sum(four) from onek +group by ten order by ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 099 +select ten, count(four), sum(DISTINCT four) from onek +group by ten order by ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 100 +-- user-defined aggregates +SELECT newavg(four) AS avg_1 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="newavg" function="newavg" schema="" ctx=Call +STMT: SelectStmt +== 101 +SELECT newsum(four) AS sum_1500 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="newsum" function="newsum" schema="" ctx=Call +STMT: SelectStmt +== 102 +SELECT newcnt(four) AS cnt_1000 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="newcnt" function="newcnt" schema="" ctx=Call +STMT: SelectStmt +== 103 +SELECT newcnt(*) AS cnt_1000 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="newcnt" function="newcnt" schema="" ctx=Call +STMT: SelectStmt +== 104 +SELECT oldcnt(*) AS cnt_1000 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="oldcnt" function="oldcnt" schema="" ctx=Call +STMT: SelectStmt +== 105 +SELECT sum2(q1,q2) FROM int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="sum2" function="sum2" schema="" ctx=Call +STMT: SelectStmt +== 106 +-- test for outer-level aggregates + +-- this should work +select ten, sum(distinct four) from onek a +group by ten +having exists (select 1 from onek b where sum(distinct a.four) = b.four) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="a" column="four" +FILTER: schema="" table="b" column="four" +STMT: SelectStmt +== 107 +-- this should fail because subquery has an agg of its own in WHERE +select ten, sum(distinct four) from onek a +group by ten +having exists (select 1 from onek b + where sum(distinct a.four + b.four) = b.four) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="a" column="four" +FILTER: schema="" table="b" column="four" +FILTER: schema="" table="b" column="four" +STMT: SelectStmt +== 108 +-- Test handling of sublinks within outer-level aggregates. +-- Per bug report from Daniel Grace. +select + (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1))) +from tenk1 o +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i"="tenk1" +ALIAS: "o"="tenk1" +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="i" column="unique1" +FILTER: schema="" table="o" column="unique1" +STMT: SelectStmt +== 109 +-- Test handling of Params within aggregate arguments in hashed aggregation. +-- Per bug report from Jeevan Chalke. +explain (verbose, costs off) +select s1, s2, sm +from generate_series(1, 3) s1, + lateral (select s2, sum(s1 + s2) sm + from generate_series(1, 3) s2 group by s2) ss +order by 1, 2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 110 +select s1, s2, sm +from generate_series(1, 3) s1, + lateral (select s2, sum(s1 + s2) sm + from generate_series(1, 3) s2 group by s2) ss +order by 1, 2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 111 +explain (verbose, costs off) +select array(select sum(x+y) s + from generate_series(1,3) y group by y order by s) + from generate_series(1,3) x +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 112 +select array(select sum(x+y) s + from generate_series(1,3) y group by y order by s) + from generate_series(1,3) x +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 113 +|-- +-- test for bitwise integer aggregates +|-- +CREATE TEMPORARY TABLE bitwise_test( + i2 INT2, + i4 INT4, + i8 INT8, + i INTEGER, + x INT2, + y BIT(4) +) +-- +TABLE: name="bitwise_test" schema="" table="bitwise_test" ctx=DDL +STMT: CreateStmt +== 114 +-- empty case +SELECT + BIT_AND(i2) AS "?", + BIT_OR(i4) AS "?", + BIT_XOR(i8) AS "?" +FROM bitwise_test +-- +TABLE: name="bitwise_test" schema="" table="bitwise_test" ctx=Select +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +STMT: SelectStmt +== 115 +COPY bitwise_test FROM STDIN NULL 'null' +-- +TABLE: name="bitwise_test" schema="" table="bitwise_test" ctx=Select +STMT: CopyStmt +== 116 +SELECT + BIT_AND(i2) AS "1", + BIT_AND(i4) AS "1", + BIT_AND(i8) AS "1", + BIT_AND(i) AS "?", + BIT_AND(x) AS "0", + BIT_AND(y) AS "0100", + + BIT_OR(i2) AS "7", + BIT_OR(i4) AS "7", + BIT_OR(i8) AS "7", + BIT_OR(i) AS "?", + BIT_OR(x) AS "7", + BIT_OR(y) AS "1101", + + BIT_XOR(i2) AS "5", + BIT_XOR(i4) AS "5", + BIT_XOR(i8) AS "5", + BIT_XOR(i) AS "?", + BIT_XOR(x) AS "7", + BIT_XOR(y) AS "1101" +FROM bitwise_test +-- +TABLE: name="bitwise_test" schema="" table="bitwise_test" ctx=Select +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +STMT: SelectStmt +== 117 +|-- +-- test boolean aggregates +|-- +-- first test all possible transition and final states + +SELECT + -- boolean and transitions + -- null because strict + booland_statefunc(NULL, NULL) IS NULL AS "t", + booland_statefunc(TRUE, NULL) IS NULL AS "t", + booland_statefunc(FALSE, NULL) IS NULL AS "t", + booland_statefunc(NULL, TRUE) IS NULL AS "t", + booland_statefunc(NULL, FALSE) IS NULL AS "t", + -- and actual computations + booland_statefunc(TRUE, TRUE) AS "t", + NOT booland_statefunc(TRUE, FALSE) AS "t", + NOT booland_statefunc(FALSE, TRUE) AS "t", + NOT booland_statefunc(FALSE, FALSE) AS "t" +-- +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +STMT: SelectStmt +== 118 +SELECT + -- boolean or transitions + -- null because strict + boolor_statefunc(NULL, NULL) IS NULL AS "t", + boolor_statefunc(TRUE, NULL) IS NULL AS "t", + boolor_statefunc(FALSE, NULL) IS NULL AS "t", + boolor_statefunc(NULL, TRUE) IS NULL AS "t", + boolor_statefunc(NULL, FALSE) IS NULL AS "t", + -- actual computations + boolor_statefunc(TRUE, TRUE) AS "t", + boolor_statefunc(TRUE, FALSE) AS "t", + boolor_statefunc(FALSE, TRUE) AS "t", + NOT boolor_statefunc(FALSE, FALSE) AS "t" +-- +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +STMT: SelectStmt +== 119 +CREATE TEMPORARY TABLE bool_test( + b1 BOOL, + b2 BOOL, + b3 BOOL, + b4 BOOL) +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=DDL +STMT: CreateStmt +== 120 +-- empty case +SELECT + BOOL_AND(b1) AS "n", + BOOL_OR(b3) AS "n" +FROM bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +== 121 +COPY bool_test FROM STDIN NULL 'null' +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +STMT: CopyStmt +== 122 +SELECT + BOOL_AND(b1) AS "f", + BOOL_AND(b2) AS "t", + BOOL_AND(b3) AS "f", + BOOL_AND(b4) AS "n", + BOOL_AND(NOT b2) AS "f", + BOOL_AND(NOT b3) AS "t" +FROM bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +STMT: SelectStmt +== 123 +SELECT + EVERY(b1) AS "f", + EVERY(b2) AS "t", + EVERY(b3) AS "f", + EVERY(b4) AS "n", + EVERY(NOT b2) AS "f", + EVERY(NOT b3) AS "t" +FROM bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +STMT: SelectStmt +== 124 +SELECT + BOOL_OR(b1) AS "t", + BOOL_OR(b2) AS "t", + BOOL_OR(b3) AS "f", + BOOL_OR(b4) AS "n", + BOOL_OR(NOT b2) AS "f", + BOOL_OR(NOT b3) AS "t" +FROM bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +== 125 +|-- +-- Test cases that should be optimized into indexscans instead of +-- the generic aggregate implementation. +|-- + +-- Basic cases +explain (costs off) + select min(unique1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 126 +select min(unique1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 127 +explain (costs off) + select max(unique1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 128 +select max(unique1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 129 +explain (costs off) + select max(unique1) from tenk1 where unique1 < 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 130 +select max(unique1) from tenk1 where unique1 < 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 131 +explain (costs off) + select max(unique1) from tenk1 where unique1 > 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 132 +select max(unique1) from tenk1 where unique1 > 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 133 +-- the planner may choose a generic aggregate here if parallel query is +-- enabled, since that plan will be parallel safe and the "optimized" +-- plan, which has almost identical cost, will not be. we want to test +-- the optimized plan, so temporarily disable parallel query. +begin +-- +STMT: TransactionStmt +== 134 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 135 +explain (costs off) + select max(unique1) from tenk1 where unique1 > 42000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 136 +select max(unique1) from tenk1 where unique1 > 42000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 137 +rollback +-- +STMT: TransactionStmt +== 138 +-- multi-column index (uses tenk1_thous_tenthous) +explain (costs off) + select max(tenthous) from tenk1 where thousand = 33 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 139 +select max(tenthous) from tenk1 where thousand = 33 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 140 +explain (costs off) + select min(tenthous) from tenk1 where thousand = 33 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 141 +select min(tenthous) from tenk1 where thousand = 33 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 142 +-- check parameter propagation into an indexscan subquery +explain (costs off) + select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt + from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 143 +select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt + from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 144 +-- check some cases that were handled incorrectly in 8.3.0 +explain (costs off) + select distinct max(unique2) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 145 +select distinct max(unique2) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 146 +explain (costs off) + select max(unique2) from tenk1 order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 147 +select max(unique2) from tenk1 order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 148 +explain (costs off) + select max(unique2) from tenk1 order by max(unique2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 149 +select max(unique2) from tenk1 order by max(unique2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 150 +explain (costs off) + select max(unique2) from tenk1 order by max(unique2)+1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 151 +select max(unique2) from tenk1 order by max(unique2)+1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 152 +explain (costs off) + select max(unique2), generate_series(1,3) as g from tenk1 order by g desc +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 153 +select max(unique2), generate_series(1,3) as g from tenk1 order by g desc +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 154 +-- interesting corner case: constant gets optimized into a seqscan +explain (costs off) + select max(100) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 155 +select max(100) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 156 +-- try it on an inheritance tree +create table minmaxtest(f1 int) +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=DDL +STMT: CreateStmt +== 157 +create table minmaxtest1() inherits (minmaxtest) +-- +TABLE: name="minmaxtest1" schema="" table="minmaxtest1" ctx=DDL +STMT: CreateStmt +== 158 +create table minmaxtest2() inherits (minmaxtest) +-- +TABLE: name="minmaxtest2" schema="" table="minmaxtest2" ctx=DDL +STMT: CreateStmt +== 159 +create table minmaxtest3() inherits (minmaxtest) +-- +TABLE: name="minmaxtest3" schema="" table="minmaxtest3" ctx=DDL +STMT: CreateStmt +== 160 +create index minmaxtesti on minmaxtest(f1) +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=DDL +STMT: IndexStmt +== 161 +create index minmaxtest1i on minmaxtest1(f1) +-- +TABLE: name="minmaxtest1" schema="" table="minmaxtest1" ctx=DDL +STMT: IndexStmt +== 162 +create index minmaxtest2i on minmaxtest2(f1 desc) +-- +TABLE: name="minmaxtest2" schema="" table="minmaxtest2" ctx=DDL +STMT: IndexStmt +== 163 +create index minmaxtest3i on minmaxtest3(f1) where f1 is not null +-- +TABLE: name="minmaxtest3" schema="" table="minmaxtest3" ctx=DDL +STMT: IndexStmt +== 164 +insert into minmaxtest values(11), (12) +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 165 +insert into minmaxtest1 values(13), (14) +-- +TABLE: name="minmaxtest1" schema="" table="minmaxtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 166 +insert into minmaxtest2 values(15), (16) +-- +TABLE: name="minmaxtest2" schema="" table="minmaxtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 167 +insert into minmaxtest3 values(17), (18) +-- +TABLE: name="minmaxtest3" schema="" table="minmaxtest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +explain (costs off) + select min(f1), max(f1) from minmaxtest +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 169 +select min(f1), max(f1) from minmaxtest +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 170 +-- DISTINCT doesn't do anything useful here, but it shouldn't fail +explain (costs off) + select distinct min(f1), max(f1) from minmaxtest +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 171 +select distinct min(f1), max(f1) from minmaxtest +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 172 +drop table minmaxtest cascade +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=DDL +STMT: DropStmt +== 173 +-- DISTINCT can also trigger wrong answers with hash aggregation (bug #18465) +begin +-- +STMT: TransactionStmt +== 174 +set local enable_sort = off +-- +STMT: VariableSetStmt +== 175 +explain (costs off) + select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1) + from int4_tbl t0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t0"="int4_tbl" +ALIAS: "t1"="int4_tbl" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="t0" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 176 +select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1) +from int4_tbl t0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t0"="int4_tbl" +ALIAS: "t1"="int4_tbl" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="t0" column="f1" +STMT: SelectStmt +== 177 +rollback +-- +STMT: TransactionStmt +== 178 +-- check for correct detection of nested-aggregate errors +select max(min(unique1)) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 179 +select (select max(min(unique1)) from int8_tbl) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 180 +select avg((select avg(a1.col1 order by (select avg(a2.col2) from tenk1 a3)) + from tenk1 a1(col1))) +from tenk1 a2(col2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a1"="tenk1" +ALIAS: "a2"="tenk1" +ALIAS: "a3"="tenk1" +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 181 +|-- +-- Test removal of redundant GROUP BY columns +|-- + +create temp table t1 (a int, b int, c int, d int, primary key (a, b)) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 182 +create temp table t2 (x int, y int, z int, primary key (x, y)) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 183 +create temp table t3 (a int, b int, c int, primary key(a, b) deferrable) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: CreateStmt +== 184 +-- Non-primary-key columns can be removed from GROUP BY +explain (costs off) select * from t1 group by a,b,c,d +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 185 +-- No removal can happen if the complete PK is not present in GROUP BY +explain (costs off) select a,c from t1 group by a,c,d +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 186 +-- Test removal across multiple relations +explain (costs off) select * +from t1 inner join t2 on t1.a = t2.x and t1.b = t2.y +group by t1.a,t1.b,t1.c,t1.d,t2.x,t2.y,t2.z +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 187 +-- Test case where t1 can be optimized but not t2 +explain (costs off) select t1.*,t2.x,t2.z +from t1 inner join t2 on t1.a = t2.x and t1.b = t2.y +group by t1.a,t1.b,t1.c,t1.d,t2.x,t2.z +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 188 +-- Cannot optimize when PK is deferrable +explain (costs off) select * from t3 group by a,b,c +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 189 +create temp table t1c () inherits (t1) +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DDL +STMT: CreateStmt +== 190 +-- Ensure we don't remove any columns when t1 has a child table +explain (costs off) select * from t1 group by a,b,c,d +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 191 +-- Okay to remove columns if we're only querying the parent. +explain (costs off) select * from only t1 group by a,b,c,d +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 192 +create temp table p_t1 ( + a int, + b int, + c int, + d int, + primary key(a,b) +) partition by list(a) +-- +TABLE: name="p_t1" schema="" table="p_t1" ctx=DDL +STMT: CreateStmt +== 193 +create temp table p_t1_1 partition of p_t1 for values in(1) +-- +TABLE: name="p_t1_1" schema="" table="p_t1_1" ctx=DDL +STMT: CreateStmt +== 194 +create temp table p_t1_2 partition of p_t1 for values in(2) +-- +TABLE: name="p_t1_2" schema="" table="p_t1_2" ctx=DDL +STMT: CreateStmt +== 195 +-- Ensure we can remove non-PK columns for partitioned tables. +explain (costs off) select * from p_t1 group by a,b,c,d +-- +TABLE: name="p_t1" schema="" table="p_t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 196 +drop table t1 cascade +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 197 +drop table t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +== 198 +drop table t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: DropStmt +== 199 +drop table p_t1 +-- +TABLE: name="p_t1" schema="" table="p_t1" ctx=DDL +STMT: DropStmt +== 200 +|-- +-- Test GROUP BY matching of join columns that are type-coerced due to USING +|-- + +create temp table t1(f1 int, f2 int) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 201 +create temp table t2(f1 bigint, f2 oid) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 202 +select f1 from t1 left join t2 using (f1) group by f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +== 203 +select f1 from t1 left join t2 using (f1) group by t1.f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +== 204 +select t1.f1 from t1 left join t2 using (f1) group by t1.f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +== 205 +-- only this one should fail: +select t1.f1 from t1 left join t2 using (f1) group by f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +== 206 +-- check case where we have to inject nullingrels into coerced join alias +select f1, count(*) from +t1 x(x0,x1) left join (t1 left join t2 using(f1)) on (x0 = 0) +group by f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +ALIAS: "x"="t1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 207 +-- same, for a RelabelType coercion +select f2, count(*) from +t1 x(x0,x1) left join (t1 left join t2 using(f2)) on (x0 = 0) +group by f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +ALIAS: "x"="t1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 208 +drop table t1, t2 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +== 209 +|-- +-- Test planner's selection of pathkeys for ORDER BY aggregates +|-- + +-- Ensure we order by four. This suits the most aggregate functions. +explain (costs off) +select sum(two order by two),max(four order by four), min(four order by four) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 210 +-- Ensure we order by two. It's a tie between ordering by two and four but +-- we tiebreak on the aggregate's position. +explain (costs off) +select + sum(two order by two), max(four order by four), + min(four order by four), max(two order by two) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 211 +-- Similar to above, but tiebreak on ordering by four +explain (costs off) +select + max(four order by four), sum(two order by two), + min(four order by four), max(two order by two) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 212 +-- Ensure this one orders by ten since there are 3 aggregates that require ten +-- vs two that suit two and four. +explain (costs off) +select + max(four order by four), sum(two order by two), + min(four order by four), max(two order by two), + sum(ten order by ten), min(ten order by ten), max(ten order by ten) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 213 +-- Try a case involving a GROUP BY clause where the GROUP BY column is also +-- part of an aggregate's ORDER BY clause. We want a sort order that works +-- for the GROUP BY along with the first and the last aggregate. +explain (costs off) +select + sum(unique1 order by ten, two), sum(unique1 order by four), + sum(unique1 order by two, four) +from tenk1 +group by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 214 +-- Ensure that we never choose to provide presorted input to an Aggref with +-- a volatile function in the ORDER BY / DISTINCT clause. We want to ensure +-- these sorts are performed individually rather than at the query level. +explain (costs off) +select + sum(unique1 order by two), sum(unique1 order by four), + sum(unique1 order by four, two), sum(unique1 order by two, random()), + sum(unique1 order by two, random(), random() + 1) +from tenk1 +group by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 215 +-- Ensure consecutive NULLs are properly treated as distinct from each other +select array_agg(distinct val) +from (select null as val from generate_series(1, 2)) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 216 +-- Ensure no ordering is requested when enable_presorted_aggregate is off +set enable_presorted_aggregate to off +-- +STMT: VariableSetStmt +== 217 +explain (costs off) +select sum(two order by two) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 218 +reset enable_presorted_aggregate +-- +STMT: VariableSetStmt +== 219 +|-- +-- Test cases with FILTER clause +|-- + +-- Ensure we presort when the aggregate contains plain Vars +explain (costs off) +select sum(two order by two) filter (where two > 1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 220 +-- Ensure we presort for RelabelType'd Vars +explain (costs off) +select string_agg(distinct f1, ',') filter (where length(f1) > 1) +from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 221 +-- Ensure we don't presort when the aggregate's argument contains an +-- explicit cast. +explain (costs off) +select string_agg(distinct f1::varchar(2), ',') filter (where length(f1) > 1) +from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 222 +|-- +-- Test combinations of DISTINCT and/or ORDER BY +|-- + +select array_agg(a order by b) + from (values (1,4),(2,3),(3,1),(4,2)) v(a,b) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 223 +select array_agg(a order by a) + from (values (1,4),(2,3),(3,1),(4,2)) v(a,b) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 224 +select array_agg(a order by a desc) + from (values (1,4),(2,3),(3,1),(4,2)) v(a,b) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 225 +select array_agg(b order by a desc) + from (values (1,4),(2,3),(3,1),(4,2)) v(a,b) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 226 +select array_agg(distinct a) + from (values (1),(2),(1),(3),(null),(2)) v(a) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 227 +select array_agg(distinct a order by a) + from (values (1),(2),(1),(3),(null),(2)) v(a) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 228 +select array_agg(distinct a order by a desc) + from (values (1),(2),(1),(3),(null),(2)) v(a) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 229 +select array_agg(distinct a order by a desc nulls last) + from (values (1),(2),(1),(3),(null),(2)) v(a) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 230 +-- multi-arg aggs, strict/nonstrict, distinct/order by + +select aggfstr(a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +FUNCTION: name="aggfstr" function="aggfstr" schema="" ctx=Call +STMT: SelectStmt +== 231 +select aggfns(a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: SelectStmt +== 232 +select aggfstr(distinct a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +FUNCTION: name="aggfstr" function="aggfstr" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 233 +select aggfns(distinct a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 234 +select aggfstr(distinct a,b,c order by b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +FUNCTION: name="aggfstr" function="aggfstr" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 235 +select aggfns(distinct a,b,c order by b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 236 +-- test specific code paths + +select aggfns(distinct a,a,c order by c using ~<~,a) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 237 +select aggfns(distinct a,a,c order by c using ~<~) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 238 +select aggfns(distinct a,a,c order by a) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 239 +select aggfns(distinct a,b,c order by a,c using ~<~,b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 240 +-- test a more complex permutation that has previous caused issues +select + string_agg(distinct 'a', ','), + sum(( + select sum(1) + from (values(1)) b(id) + where a.id = b.id +)) from unnest(array[1]) a(id) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="b" column="id" +STMT: SelectStmt +== 241 +-- check node I/O via view creation and usage, also deparsing logic + +create view agg_view1 as + select aggfns(a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 242 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +== 243 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 244 +create or replace view agg_view1 as + select aggfns(distinct a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 245 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +== 246 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 247 +create or replace view agg_view1 as + select aggfns(distinct a,b,c order by b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 248 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +== 249 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 250 +create or replace view agg_view1 as + select aggfns(a,b,c order by b+1) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 251 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +== 252 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 253 +create or replace view agg_view1 as + select aggfns(a,a,c order by b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 254 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +== 255 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 256 +create or replace view agg_view1 as + select aggfns(a,b,c order by c using ~<~) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 257 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +== 258 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 259 +create or replace view agg_view1 as + select aggfns(distinct a,b,c order by a,c using ~<~,b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 260 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +== 261 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 262 +drop view agg_view1 +-- +STMT: DropStmt +== 263 +-- incorrect DISTINCT usage errors + +select aggfns(distinct a,b,c order by i) + from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 264 +select aggfns(distinct a,b,c order by a,b+1) + from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 265 +select aggfns(distinct a,b,c order by a,b,i,c) + from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 266 +select aggfns(distinct a,a,c order by a,b) + from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 267 +-- string_agg tests +select string_agg(a,',') from (values('aaaa'),('bbbb'),('cccc')) g(a) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 268 +select string_agg(a,',') from (values('aaaa'),(null),('bbbb'),('cccc')) g(a) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 269 +select string_agg(a,'AB') from (values(null),(null),('bbbb'),('cccc')) g(a) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 270 +select string_agg(a,',') from (values(null),(null)) g(a) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 271 +-- check some implicit casting cases, as per bug #5564 +select string_agg(distinct f1, ',' order by f1) from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 272 +-- ok +select string_agg(distinct f1::text, ',' order by f1) from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 273 +-- not ok +select string_agg(distinct f1, ',' order by f1::text) from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 274 +-- not ok +select string_agg(distinct f1::text, ',' order by f1::text) from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 275 +-- ok + +-- string_agg bytea tests +create table bytea_test_table(v bytea) +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=DDL +STMT: CreateStmt +== 276 +select string_agg(v, '') from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 277 +insert into bytea_test_table values(decode('ff','hex')) +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=DML +FUNCTION: name="decode" function="decode" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 278 +select string_agg(v, '') from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 279 +insert into bytea_test_table values(decode('aa','hex')) +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=DML +FUNCTION: name="decode" function="decode" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 280 +select string_agg(v, '') from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 281 +select string_agg(v, NULL) from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 282 +select string_agg(v, decode('ee', 'hex')) from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="decode" function="decode" schema="" ctx=Call +STMT: SelectStmt +== 283 +drop table bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=DDL +STMT: DropStmt +== 284 +-- Test parallel string_agg and array_agg +create table pagg_test (x int, y int) with (autovacuum_enabled = off) +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=DDL +STMT: CreateStmt +== 285 +insert into pagg_test +select (case x % 4 when 1 then null else x end), x % 10 +from generate_series(1,5000) x +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 286 +set parallel_setup_cost TO 0 +-- +STMT: VariableSetStmt +== 287 +set parallel_tuple_cost TO 0 +-- +STMT: VariableSetStmt +== 288 +set parallel_leader_participation TO 0 +-- +STMT: VariableSetStmt +== 289 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 290 +set bytea_output = 'escape' +-- +STMT: VariableSetStmt +== 291 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 292 +-- create a view as we otherwise have to repeat this query a few times. +create view v_pagg_test AS +select + y, + min(t) AS tmin,max(t) AS tmax,count(distinct t) AS tndistinct, + min(b) AS bmin,max(b) AS bmax,count(distinct b) AS bndistinct, + min(a) AS amin,max(a) AS amax,count(distinct a) AS andistinct, + min(aa) AS aamin,max(aa) AS aamax,count(distinct aa) AS aandistinct +from ( + select + y, + unnest(regexp_split_to_array(a1.t, ','))::int AS t, + unnest(regexp_split_to_array(a1.b::text, ',')) AS b, + unnest(a1.a) AS a, + unnest(a1.aa) AS aa + from ( + select + y, + string_agg(x::text, ',') AS t, + string_agg(x::text::bytea, ',') AS b, + array_agg(x) AS a, + array_agg(ARRAY[x]) AS aa + from pagg_test + group by y + ) a1 +) a2 +group by y +-- +TABLE: name="v_pagg_test" schema="" table="v_pagg_test" ctx=DDL +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="regexp_split_to_array" function="regexp_split_to_array" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="regexp_split_to_array" function="regexp_split_to_array" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 293 +-- Ensure results are correct. +select * from v_pagg_test order by y +-- +TABLE: name="v_pagg_test" schema="" table="v_pagg_test" ctx=Select +STMT: SelectStmt +== 294 +-- Ensure parallel aggregation is actually being used. +explain (costs off) select * from v_pagg_test order by y +-- +TABLE: name="v_pagg_test" schema="" table="v_pagg_test" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 295 +-- Ensure results are the same without parallel aggregation. +set max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 296 +select * from v_pagg_test order by y +-- +TABLE: name="v_pagg_test" schema="" table="v_pagg_test" ctx=Select +STMT: SelectStmt +== 297 +-- Check that we don't fail on anonymous record types. +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 298 +explain (costs off) +select array_dims(array_agg(s)) from (select * from pagg_test) s +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=Select +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 299 +select array_dims(array_agg(s)) from (select * from pagg_test) s +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=Select +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 300 +-- Clean up +reset max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +== 301 +reset bytea_output +-- +STMT: VariableSetStmt +== 302 +reset min_parallel_table_scan_size +-- +STMT: VariableSetStmt +== 303 +reset parallel_leader_participation +-- +STMT: VariableSetStmt +== 304 +reset parallel_tuple_cost +-- +STMT: VariableSetStmt +== 305 +reset parallel_setup_cost +-- +STMT: VariableSetStmt +== 306 +drop view v_pagg_test +-- +STMT: DropStmt +== 307 +drop table pagg_test +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=DDL +STMT: DropStmt +== 308 +-- FILTER tests + +select min(unique1) filter (where unique1 > 100) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 309 +select sum(1/ten) filter (where ten > 0) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 310 +select ten, sum(distinct four) filter (where four::text ~ '123') from onek a +group by ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 311 +select ten, sum(distinct four) filter (where four > 10) from onek a +group by ten +having exists (select 1 from onek b where sum(distinct a.four) = b.four) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="a" column="four" +FILTER: schema="" table="b" column="four" +STMT: SelectStmt +== 312 +select max(foo COLLATE "C") filter (where (bar collate "POSIX") > '0') +from (values ('a', 'b')) AS v(foo,bar) +-- +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 313 +select any_value(v) filter (where v > 2) from (values (1), (2), (3)) as v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +== 314 +-- outer reference in FILTER (PostgreSQL extension) +select (select count(*) + from (values (1)) t0(inner_c)) +from (values (2),(3)) t1(outer_c) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 315 +-- inner query is aggregation query +select (select count(*) filter (where outer_c <> 0) + from (values (1)) t0(inner_c)) +from (values (2),(3)) t1(outer_c) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 316 +-- outer query is aggregation query +select (select count(inner_c) filter (where outer_c <> 0) + from (values (1)) t0(inner_c)) +from (values (2),(3)) t1(outer_c) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 317 +-- inner query is aggregation query +select + (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1)) + filter (where o.unique1 < 10)) +from tenk1 o +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i"="tenk1" +ALIAS: "o"="tenk1" +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="i" column="unique1" +FILTER: schema="" table="o" column="unique1" +STMT: SelectStmt +== 318 +-- outer query is aggregation query + +-- subquery in FILTER clause (PostgreSQL extension) +select sum(unique1) FILTER (WHERE + unique1 IN (SELECT unique1 FROM onek where unique1 < 100)) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 319 +-- exercise lots of aggregate parts with FILTER +select aggfns(distinct a,b,c order by a,c using ~<~,b) filter (where a > 1) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 320 +-- check handling of bare boolean Var in FILTER +select max(0) filter (where b1) from bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 321 +select (select max(0) filter (where b1)) from bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 322 +-- check for correct detection of nested-aggregate errors in FILTER +select max(unique1) filter (where sum(ten) > 0) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 323 +select (select max(unique1) filter (where sum(ten) > 0) from int8_tbl) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 324 +select max(unique1) filter (where bool_or(ten > 0)) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +== 325 +select (select max(unique1) filter (where bool_or(ten > 0)) from int8_tbl) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +== 326 +-- ordered-set aggregates + +select p, percentile_cont(p) within group (order by x::float8) +from generate_series(1,5) x, + (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p) +group by p order by p +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 327 +select p, percentile_cont(p order by p) within group (order by x) -- error +from generate_series(1,5) x, + (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p) +group by p order by p +-- +ERROR: cannot use multiple ORDER BY clauses with WITHIN GROUP +CURSORPOS: 41 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 328 +select p, sum() within group (order by x::float8) -- error +from generate_series(1,5) x, + (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p) +group by p order by p +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 329 +select p, percentile_cont(p,p) -- error +from generate_series(1,5) x, + (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p) +group by p order by p +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 330 +select percentile_cont(0.5) within group (order by b) from aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +STMT: SelectStmt +== 331 +select percentile_cont(0.5) within group (order by b), sum(b) from aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 332 +select percentile_cont(0.5) within group (order by thousand) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +STMT: SelectStmt +== 333 +select percentile_disc(0.5) within group (order by thousand) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +== 334 +select rank(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4)) v(x) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 335 +select cume_dist(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4)) v(x) +-- +FUNCTION: name="cume_dist" function="cume_dist" schema="" ctx=Call +STMT: SelectStmt +== 336 +select percent_rank(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4),(5)) v(x) +-- +FUNCTION: name="percent_rank" function="percent_rank" schema="" ctx=Call +STMT: SelectStmt +== 337 +select dense_rank(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4)) v(x) +-- +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +STMT: SelectStmt +== 338 +select percentile_disc(array[0,0.1,0.25,0.5,0.75,0.9,1]) within group (order by thousand) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +== 339 +select percentile_cont(array[0,0.25,0.5,0.75,1]) within group (order by thousand) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +STMT: SelectStmt +== 340 +select percentile_disc(array[[null,1,0.5],[0.75,0.25,null]]) within group (order by thousand) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +== 341 +select percentile_cont(array[0,1,0.25,0.75,0.5,1,0.3,0.32,0.35,0.38,0.4]) within group (order by x) +from generate_series(1,6) x +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 342 +select ten, mode() within group (order by string4) from tenk1 group by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="mode" function="mode" schema="" ctx=Call +STMT: SelectStmt +== 343 +select percentile_disc(array[0.25,0.5,0.75]) within group (order by x) +from unnest('{fred,jim,fred,jack,jill,fred,jill,jim,jim,sheila,jim,sheila}'::text[]) u(x) +-- +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 344 +-- check collation propagates up in suitable cases: +select pg_collation_for(percentile_disc(1) within group (order by x collate "POSIX")) + from (values ('fred'),('jim')) v(x) +-- +FUNCTION: name="pg_collation_for" function="pg_collation_for" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +== 345 +-- ordered-set aggs created with CREATE AGGREGATE +select test_rank(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4)) v(x) +-- +FUNCTION: name="test_rank" function="test_rank" schema="" ctx=Call +STMT: SelectStmt +== 346 +select test_percentile_disc(0.5) within group (order by thousand) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="test_percentile_disc" function="test_percentile_disc" schema="" ctx=Call +STMT: SelectStmt +== 347 +-- ordered-set aggs can't use ungrouped vars in direct args: +select rank(x) within group (order by x) from generate_series(1,5) x +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 348 +-- outer-level agg can't use a grouped arg of a lower level, either: +select array(select percentile_disc(a) within group (order by x) + from (values (0.3),(0.7)) v(a) group by a) + from generate_series(1,5) g(x) +-- +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 349 +-- agg in the direct args is a grouping violation, too: +select rank(sum(x)) within group (order by x) from generate_series(1,5) x +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 350 +-- hypothetical-set type unification and argument-count failures: +select rank(3) within group (order by x) from (values ('fred'),('jim')) v(x) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 351 +select rank(3) within group (order by stringu1,stringu2) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 352 +select rank('fred') within group (order by x) from generate_series(1,5) x +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 353 +select rank('adam'::text collate "C") within group (order by x collate "POSIX") + from (values ('fred'),('jim')) v(x) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 354 +-- hypothetical-set type unification successes: +select rank('adam'::varchar) within group (order by x) from (values ('fred'),('jim')) v(x) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 355 +select rank('3') within group (order by x) from generate_series(1,5) x +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 356 +-- divide by zero check +select percent_rank(0) within group (order by x) from generate_series(1,0) x +-- +FUNCTION: name="percent_rank" function="percent_rank" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 357 +-- deparse and multiple features: +create view aggordview1 as +select ten, + percentile_disc(0.5) within group (order by thousand) as p50, + percentile_disc(0.5) within group (order by thousand) filter (where hundred=1) as px, + rank(5,'AZZZZ',50) within group (order by hundred, string4 desc, hundred) + from tenk1 + group by ten order by ten +-- +TABLE: name="aggordview1" schema="" table="aggordview1" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 358 +select pg_get_viewdef('aggordview1') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 359 +select * from aggordview1 order by ten +-- +TABLE: name="aggordview1" schema="" table="aggordview1" ctx=Select +STMT: SelectStmt +== 360 +drop view aggordview1 +-- +STMT: DropStmt +== 361 +-- variadic aggregates +select least_agg(q1,q2) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="least_agg" function="least_agg" schema="" ctx=Call +STMT: SelectStmt +== 362 +select least_agg(variadic array[q1,q2]) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="least_agg" function="least_agg" schema="" ctx=Call +STMT: SelectStmt +== 363 +select cleast_agg(q1,q2) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="cleast_agg" function="cleast_agg" schema="" ctx=Call +STMT: SelectStmt +== 364 +select cleast_agg(4.5,f1) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="cleast_agg" function="cleast_agg" schema="" ctx=Call +STMT: SelectStmt +== 365 +select cleast_agg(variadic array[4.5,f1]) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="cleast_agg" function="cleast_agg" schema="" ctx=Call +STMT: SelectStmt +== 366 +select pg_typeof(cleast_agg(variadic array[4.5,f1])) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="cleast_agg" function="cleast_agg" schema="" ctx=Call +STMT: SelectStmt +== 367 +-- test aggregates with common transition functions share the same states +begin work +-- +STMT: TransactionStmt +== 368 +create type avg_state as (total bigint, count bigint) +-- +STMT: CompositeTypeStmt +== 369 +create or replace function avg_transfn(state avg_state, n int) returns avg_state as +$$ +declare new_state avg_state; +begin + raise notice 'avg_transfn called with %', n; + if state is null then + if n is not null then + new_state.total := n; + new_state.count := 1; + return new_state; + end if; + return null; + elsif n is not null then + state.total := state.total + n; + state.count := state.count + 1; + return state; + end if; + + return null; +end +$$ language plpgsql +-- +FUNCTION: name="avg_transfn" function="avg_transfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 370 +create function avg_finalfn(state avg_state) returns int4 as +$$ +begin + if state is null then + return NULL; + else + return state.total / state.count; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="avg_finalfn" function="avg_finalfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 371 +create function sum_finalfn(state avg_state) returns int4 as +$$ +begin + if state is null then + return NULL; + else + return state.total; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="sum_finalfn" function="sum_finalfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 372 +create aggregate my_avg(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = avg_finalfn +) +-- +STMT: DefineStmt +== 373 +create aggregate my_sum(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = sum_finalfn +) +-- +STMT: DefineStmt +== 374 +-- aggregate state should be shared as aggs are the same. +select my_avg(one),my_avg(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +STMT: SelectStmt +== 375 +-- aggregate state should be shared as transfn is the same for both aggs. +select my_avg(one),my_sum(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +== 376 +-- same as previous one, but with DISTINCT, which requires sorting the input. +select my_avg(distinct one),my_sum(distinct one) from (values(1),(3),(1)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +== 377 +-- shouldn't share states due to the distinctness not matching. +select my_avg(distinct one),my_sum(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +== 378 +-- shouldn't share states due to the filter clause not matching. +select my_avg(one) filter (where one > 1),my_sum(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +== 379 +-- this should not share the state due to different input columns. +select my_avg(one),my_sum(two) from (values(1,2),(3,4)) t(one,two) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +== 380 +-- exercise cases where OSAs share state +select + percentile_cont(0.5) within group (order by a), + percentile_disc(0.5) within group (order by a) +from (values(1::float8),(3),(5),(7)) t(a) +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +== 381 +select + percentile_cont(0.25) within group (order by a), + percentile_disc(0.5) within group (order by a) +from (values(1::float8),(3),(5),(7)) t(a) +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +== 382 +-- these can't share state currently +select + rank(4) within group (order by a), + dense_rank(4) within group (order by a) +from (values(1),(3),(5),(7)) t(a) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +STMT: SelectStmt +== 383 +-- test that aggs with the same sfunc and initcond share the same agg state +create aggregate my_sum_init(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = sum_finalfn, + initcond = '(10,0)' +) +-- +STMT: DefineStmt +== 384 +create aggregate my_avg_init(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = avg_finalfn, + initcond = '(10,0)' +) +-- +STMT: DefineStmt +== 385 +create aggregate my_avg_init2(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = avg_finalfn, + initcond = '(4,0)' +) +-- +STMT: DefineStmt +== 386 +-- state should be shared if INITCONDs are matching +select my_sum_init(one),my_avg_init(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_sum_init" function="my_sum_init" schema="" ctx=Call +FUNCTION: name="my_avg_init" function="my_avg_init" schema="" ctx=Call +STMT: SelectStmt +== 387 +-- Varying INITCONDs should cause the states not to be shared. +select my_sum_init(one),my_avg_init2(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_sum_init" function="my_sum_init" schema="" ctx=Call +FUNCTION: name="my_avg_init2" function="my_avg_init2" schema="" ctx=Call +STMT: SelectStmt +== 388 +rollback +-- +STMT: TransactionStmt +== 389 +-- test aggregate state sharing to ensure it works if one aggregate has a +-- finalfn and the other one has none. +begin work +-- +STMT: TransactionStmt +== 390 +create or replace function sum_transfn(state int4, n int4) returns int4 as +$$ +declare new_state int4; +begin + raise notice 'sum_transfn called with %', n; + if state is null then + if n is not null then + new_state := n; + return new_state; + end if; + return null; + elsif n is not null then + state := state + n; + return state; + end if; + + return null; +end +$$ language plpgsql +-- +FUNCTION: name="sum_transfn" function="sum_transfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 391 +create function halfsum_finalfn(state int4) returns int4 as +$$ +begin + if state is null then + return NULL; + else + return state / 2; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="halfsum_finalfn" function="halfsum_finalfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 392 +create aggregate my_sum(int4) +( + stype = int4, + sfunc = sum_transfn +) +-- +STMT: DefineStmt +== 393 +create aggregate my_half_sum(int4) +( + stype = int4, + sfunc = sum_transfn, + finalfunc = halfsum_finalfn +) +-- +STMT: DefineStmt +== 394 +-- Agg state should be shared even though my_sum has no finalfn +select my_sum(one),my_half_sum(one) from (values(1),(2),(3),(4)) t(one) +-- +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +FUNCTION: name="my_half_sum" function="my_half_sum" schema="" ctx=Call +STMT: SelectStmt +== 395 +rollback +-- +STMT: TransactionStmt +== 396 +-- test that the aggregate transition logic correctly handles +-- transition / combine functions returning NULL + +-- First test the case of a normal transition function returning NULL +BEGIN +-- +STMT: TransactionStmt +== 397 +CREATE FUNCTION balkifnull(int8, int4) +RETURNS int8 +STRICT +LANGUAGE plpgsql AS $$ +BEGIN + IF $1 IS NULL THEN + RAISE 'erroneously called with NULL argument'; + END IF; + RETURN NULL; +END$$ +-- +FUNCTION: name="balkifnull" function="balkifnull" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 398 +CREATE AGGREGATE balk(int4) +( + SFUNC = balkifnull(int8, int4), + STYPE = int8, + PARALLEL = SAFE, + INITCOND = '0' +) +-- +STMT: DefineStmt +== 399 +SELECT balk(hundred) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="balk" function="balk" schema="" ctx=Call +STMT: SelectStmt +== 400 +ROLLBACK +-- +STMT: TransactionStmt +== 401 +-- GROUP BY optimization by reordering GROUP BY clauses +CREATE TABLE btg AS SELECT + i % 10 AS x, + i % 10 AS y, + 'abc' || i % 10 AS z, + i AS w +FROM generate_series(1, 100) AS i +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 402 +CREATE INDEX btg_x_y_idx ON btg(x, y) +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +STMT: IndexStmt +== 403 +ANALYZE btg +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +STMT: VacuumStmt +== 404 +SET enable_hashagg = off +-- +STMT: VariableSetStmt +== 405 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 406 +-- Utilize the ordering of index scan to avoid a Sort operation +EXPLAIN (COSTS OFF) +SELECT count(*) FROM btg GROUP BY y, x +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 407 +-- Engage incremental sort +EXPLAIN (COSTS OFF) +SELECT count(*) FROM btg GROUP BY z, y, w, x +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 408 +-- Utilize the ordering of subquery scan to avoid a Sort operation +EXPLAIN (COSTS OFF) SELECT count(*) +FROM (SELECT * FROM btg ORDER BY x, y, w, z) AS q1 +GROUP BY w, x, z, y +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 409 +-- Utilize the ordering of merge join to avoid a full Sort operation +SET enable_hashjoin = off +-- +STMT: VariableSetStmt +== 410 +SET enable_nestloop = off +-- +STMT: VariableSetStmt +== 411 +EXPLAIN (COSTS OFF) +SELECT count(*) + FROM btg t1 JOIN btg t2 ON t1.z = t2.z AND t1.w = t2.w AND t1.x = t2.x + GROUP BY t1.x, t1.y, t1.z, t1.w +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +TABLE: name="btg" schema="" table="btg" ctx=Select +ALIAS: "t1"="btg" +ALIAS: "t2"="btg" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 412 +RESET enable_nestloop +-- +STMT: VariableSetStmt +== 413 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +== 414 +-- Should work with and without GROUP-BY optimization +EXPLAIN (COSTS OFF) +SELECT count(*) FROM btg GROUP BY w, x, z, y ORDER BY y, x, z, w +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 415 +-- Utilize incremental sort to make the ORDER BY rule a bit cheaper +EXPLAIN (COSTS OFF) +SELECT count(*) FROM btg GROUP BY w, x, y, z ORDER BY x*x, z +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 416 +-- Test the case where the number of incoming subtree path keys is more than +-- the number of grouping keys. +CREATE INDEX btg_y_x_w_idx ON btg(y, x, w) +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +STMT: IndexStmt +== 417 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT y, x, array_agg(distinct w) + FROM btg WHERE y < 0 GROUP BY x, y +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 418 +-- Ensure that we do not select the aggregate pathkeys instead of the grouping +-- pathkeys +CREATE TABLE group_agg_pk AS SELECT + i % 10 AS x, + i % 2 AS y, + i % 2 AS z, + 2 AS w, + i % 10 AS f +FROM generate_series(1,100) AS i +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 419 +ANALYZE group_agg_pk +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=DDL +STMT: VacuumStmt +== 420 +SET enable_nestloop = off +-- +STMT: VariableSetStmt +== 421 +SET enable_hashjoin = off +-- +STMT: VariableSetStmt +== 422 +EXPLAIN (COSTS OFF) +SELECT avg(c1.f ORDER BY c1.x, c1.y) +FROM group_agg_pk c1 JOIN group_agg_pk c2 ON c1.x = c2.x +GROUP BY c1.w, c1.z +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +ALIAS: "c1"="group_agg_pk" +ALIAS: "c2"="group_agg_pk" +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 423 +SELECT avg(c1.f ORDER BY c1.x, c1.y) +FROM group_agg_pk c1 JOIN group_agg_pk c2 ON c1.x = c2.x +GROUP BY c1.w, c1.z +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +ALIAS: "c1"="group_agg_pk" +ALIAS: "c2"="group_agg_pk" +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 424 +-- Pathkeys, built in a subtree, can be used to optimize GROUP-BY clause +-- ordering. Also, here we check that it doesn't depend on the initial clause +-- order in the GROUP-BY list. +EXPLAIN (COSTS OFF) +SELECT c1.y,c1.x FROM group_agg_pk c1 + JOIN group_agg_pk c2 + ON c1.x = c2.x +GROUP BY c1.y,c1.x,c2.x +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +ALIAS: "c1"="group_agg_pk" +ALIAS: "c2"="group_agg_pk" +STMT: ExplainStmt +STMT: SelectStmt +== 425 +EXPLAIN (COSTS OFF) +SELECT c1.y,c1.x FROM group_agg_pk c1 + JOIN group_agg_pk c2 + ON c1.x = c2.x +GROUP BY c1.y,c2.x,c1.x +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +ALIAS: "c1"="group_agg_pk" +ALIAS: "c2"="group_agg_pk" +STMT: ExplainStmt +STMT: SelectStmt +== 426 +RESET enable_nestloop +-- +STMT: VariableSetStmt +== 427 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +== 428 +DROP TABLE group_agg_pk +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=DDL +STMT: DropStmt +== 429 +-- Test the case where the ordering of the scan matches the ordering within the +-- aggregate but cannot be found in the group-by list +CREATE TABLE agg_sort_order (c1 int PRIMARY KEY, c2 int) +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DDL +STMT: CreateStmt +== 430 +CREATE UNIQUE INDEX agg_sort_order_c2_idx ON agg_sort_order(c2) +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DDL +STMT: IndexStmt +== 431 +INSERT INTO agg_sort_order SELECT i, i FROM generate_series(1,100)i +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 432 +ANALYZE agg_sort_order +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DDL +STMT: VacuumStmt +== 433 +EXPLAIN (COSTS OFF) +SELECT array_agg(c1 ORDER BY c2),c2 +FROM agg_sort_order WHERE c2 < 100 GROUP BY c1 ORDER BY 2 +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="c2" +STMT: ExplainStmt +STMT: SelectStmt +== 434 +DROP TABLE agg_sort_order CASCADE +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DDL +STMT: DropStmt +== 435 +DROP TABLE btg +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +STMT: DropStmt +== 436 +RESET enable_hashagg +-- +STMT: VariableSetStmt +== 437 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 438 +-- Secondly test the case of a parallel aggregate combiner function +-- returning NULL. For that use normal transition function, but a +-- combiner function returning NULL. +BEGIN +-- +STMT: TransactionStmt +== 439 +CREATE FUNCTION balkifnull(int8, int8) +RETURNS int8 +PARALLEL SAFE +STRICT +LANGUAGE plpgsql AS $$ +BEGIN + IF $1 IS NULL THEN + RAISE 'erroneously called with NULL argument'; + END IF; + RETURN NULL; +END$$ +-- +FUNCTION: name="balkifnull" function="balkifnull" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 440 +CREATE AGGREGATE balk(int4) +( + SFUNC = int4_sum(int8, int4), + STYPE = int8, + COMBINEFUNC = balkifnull(int8, int8), + PARALLEL = SAFE, + INITCOND = '0' +) +-- +STMT: DefineStmt +== 441 +-- force use of parallelism +ALTER TABLE tenk1 set (parallel_workers = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: AlterTableStmt +== 442 +SET LOCAL parallel_setup_cost=0 +-- +STMT: VariableSetStmt +== 443 +SET LOCAL max_parallel_workers_per_gather=4 +-- +STMT: VariableSetStmt +== 444 +EXPLAIN (COSTS OFF) SELECT balk(hundred) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="balk" function="balk" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 445 +SELECT balk(hundred) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="balk" function="balk" schema="" ctx=Call +STMT: SelectStmt +== 446 +ROLLBACK +-- +STMT: TransactionStmt +== 447 +-- test multiple usage of an aggregate whose finalfn returns a R/W datum +BEGIN +-- +STMT: TransactionStmt +== 448 +CREATE FUNCTION rwagg_sfunc(x anyarray, y anyarray) RETURNS anyarray +LANGUAGE plpgsql IMMUTABLE AS $$ +BEGIN + RETURN array_fill(y[1], ARRAY[4]); +END; +$$ +-- +FUNCTION: name="rwagg_sfunc" function="rwagg_sfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 449 +CREATE FUNCTION rwagg_finalfunc(x anyarray) RETURNS anyarray +LANGUAGE plpgsql STRICT IMMUTABLE AS $$ +DECLARE + res x%TYPE; +BEGIN + -- assignment is essential for this test, it expands the array to R/W + res := array_fill(x[1], ARRAY[4]); + RETURN res; +END; +$$ +-- +FUNCTION: name="rwagg_finalfunc" function="rwagg_finalfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 450 +CREATE AGGREGATE rwagg(anyarray) ( + STYPE = anyarray, + SFUNC = rwagg_sfunc, + FINALFUNC = rwagg_finalfunc +) +-- +STMT: DefineStmt +== 451 +CREATE FUNCTION eatarray(x real[]) RETURNS real[] +LANGUAGE plpgsql STRICT IMMUTABLE AS $$ +BEGIN + x[1] := x[1] + 1; + RETURN x; +END; +$$ +-- +FUNCTION: name="eatarray" function="eatarray" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 452 +SELECT eatarray(rwagg(ARRAY[1.0::real])), eatarray(rwagg(ARRAY[1.0::real])) +-- +FUNCTION: name="eatarray" function="eatarray" schema="" ctx=Call +FUNCTION: name="rwagg" function="rwagg" schema="" ctx=Call +FUNCTION: name="eatarray" function="eatarray" schema="" ctx=Call +FUNCTION: name="rwagg" function="rwagg" schema="" ctx=Call +STMT: SelectStmt +== 453 +ROLLBACK +-- +STMT: TransactionStmt +== 454 +-- test coverage for aggregate combine/serial/deserial functions +BEGIN +-- +STMT: TransactionStmt +== 455 +SET parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 456 +SET parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +== 457 +SET min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 458 +SET max_parallel_workers_per_gather = 4 +-- +STMT: VariableSetStmt +== 459 +SET parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 460 +SET enable_indexonlyscan = off +-- +STMT: VariableSetStmt +== 461 +-- variance(int4) covers numeric_poly_combine +-- sum(int8) covers int8_avg_combine +-- regr_count(float8, float8) covers int8inc_float8_float8 and aggregates with > 1 arg +EXPLAIN (COSTS OFF, VERBOSE) +SELECT variance(unique1::int4), sum(unique1::int8), regr_count(unique1::float8, unique1::float8) +FROM (SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1) u +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_count" function="regr_count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 462 +SELECT variance(unique1::int4), sum(unique1::int8), regr_count(unique1::float8, unique1::float8) +FROM (SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1) u +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_count" function="regr_count" schema="" ctx=Call +STMT: SelectStmt +== 463 +-- variance(int8) covers numeric_combine +-- avg(numeric) covers numeric_avg_combine +EXPLAIN (COSTS OFF, VERBOSE) +SELECT variance(unique1::int8), avg(unique1::numeric) +FROM (SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1) u +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 464 +SELECT variance(unique1::int8), avg(unique1::numeric) +FROM (SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1) u +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 465 +ROLLBACK +-- +STMT: TransactionStmt +== 466 +-- test coverage for dense_rank +SELECT dense_rank(x) WITHIN GROUP (ORDER BY x) FROM (VALUES (1),(1),(2),(2),(3),(3)) v(x) GROUP BY (x) ORDER BY 1 +-- +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +STMT: SelectStmt +== 467 +-- Ensure that the STRICT checks for aggregates does not take NULLness +-- of ORDER BY columns into account. See bug report around +-- 2a505161-2727-2473-7c46-591ed108ac52@email.cz +SELECT min(x ORDER BY y) FROM (VALUES(1, NULL)) AS d(x,y) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 468 +SELECT min(x ORDER BY y) FROM (VALUES(1, 2)) AS d(x,y) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 469 +-- check collation-sensitive matching between grouping expressions +select v||'a', case v||'a' when 'aa' then 1 else 0 end, count(*) + from unnest(array['a','b']) u(v) + group by v||'a' order by 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 470 +select v||'a', case when v||'a' = 'aa' then 1 else 0 end, count(*) + from unnest(array['a','b']) u(v) + group by v||'a' order by 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 471 +-- Make sure that generation of HashAggregate for uniqification purposes +-- does not lead to array overflow due to unexpected duplicate hash keys +-- see CAFeeJoKKu0u+A_A9R9316djW-YW3-+Gtgvy3ju655qRHR3jtdA@mail.gmail.com +set enable_memoize to off +-- +STMT: VariableSetStmt +== 472 +explain (costs off) + select 1 from tenk1 + where (hundred, thousand) in (select twothousand, twothousand from onek) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 473 +reset enable_memoize +-- +STMT: VariableSetStmt +== 474 +|-- +-- Hash Aggregation Spill tests +|-- + +set enable_sort=false +-- +STMT: VariableSetStmt +== 475 +set work_mem='64kB' +-- +STMT: VariableSetStmt +== 476 +select unique1, count(*), sum(twothousand) from tenk1 +group by unique1 +having sum(fivethous) > 4975 +order by sum(twothousand) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 477 +set work_mem to default +-- +STMT: VariableSetStmt +== 478 +set enable_sort to default +-- +STMT: VariableSetStmt +== 479 +|-- +-- Compare results between plans using sorting and plans using hash +-- aggregation. Force spilling in both cases by setting work_mem low. +|-- + +set work_mem='64kB' +-- +STMT: VariableSetStmt +== 480 +create table agg_data_2k as +select g from generate_series(0, 1999) g +-- +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 481 +analyze agg_data_2k +-- +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=DDL +STMT: VacuumStmt +== 482 +create table agg_data_20k as +select g from generate_series(0, 19999) g +-- +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 483 +analyze agg_data_20k +-- +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=DDL +STMT: VacuumStmt +== 484 +-- Produce results with sorting. + +set enable_hashagg = false +-- +STMT: VariableSetStmt +== 485 +set jit_above_cost = 0 +-- +STMT: VariableSetStmt +== 486 +explain (costs off) +select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 + from agg_data_20k group by g%10000 +-- +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 487 +create table agg_group_1 as +select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 + from agg_data_20k group by g%10000 +-- +TABLE: name="agg_group_1" schema="" table="agg_group_1" ctx=DDL +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 488 +create table agg_group_2 as +select * from + (values (100), (300), (500)) as r(a), + lateral ( + select (g/2)::numeric as c1, + array_agg(g::numeric) as c2, + count(*) as c3 + from agg_data_2k + where g < r.a + group by g/2) as s +-- +TABLE: name="agg_group_2" schema="" table="agg_group_2" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="g" +FILTER: schema="" table="r" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 489 +set jit_above_cost to default +-- +STMT: VariableSetStmt +== 490 +create table agg_group_3 as +select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3 + from agg_data_2k group by g/2 +-- +TABLE: name="agg_group_3" schema="" table="agg_group_3" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 491 +create table agg_group_4 as +select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3 + from agg_data_2k group by g/2 +-- +TABLE: name="agg_group_4" schema="" table="agg_group_4" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 492 +-- Produce results with hash aggregation + +set enable_hashagg = true +-- +STMT: VariableSetStmt +== 493 +set enable_sort = false +-- +STMT: VariableSetStmt +== 494 +set jit_above_cost = 0 +-- +STMT: VariableSetStmt +== 495 +explain (costs off) +select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 + from agg_data_20k group by g%10000 +-- +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 496 +create table agg_hash_1 as +select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 + from agg_data_20k group by g%10000 +-- +TABLE: name="agg_hash_1" schema="" table="agg_hash_1" ctx=DDL +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 497 +create table agg_hash_2 as +select * from + (values (100), (300), (500)) as r(a), + lateral ( + select (g/2)::numeric as c1, + array_agg(g::numeric) as c2, + count(*) as c3 + from agg_data_2k + where g < r.a + group by g/2) as s +-- +TABLE: name="agg_hash_2" schema="" table="agg_hash_2" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="g" +FILTER: schema="" table="r" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 498 +set jit_above_cost to default +-- +STMT: VariableSetStmt +== 499 +create table agg_hash_3 as +select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3 + from agg_data_2k group by g/2 +-- +TABLE: name="agg_hash_3" schema="" table="agg_hash_3" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 500 +create table agg_hash_4 as +select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3 + from agg_data_2k group by g/2 +-- +TABLE: name="agg_hash_4" schema="" table="agg_hash_4" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 501 +set enable_sort = true +-- +STMT: VariableSetStmt +== 502 +set work_mem to default +-- +STMT: VariableSetStmt +== 503 +-- Compare group aggregation results to hash aggregation results + +(select * from agg_hash_1 except select * from agg_group_1) + union all +(select * from agg_group_1 except select * from agg_hash_1) +-- +TABLE: name="agg_hash_1" schema="" table="agg_hash_1" ctx=Select +TABLE: name="agg_group_1" schema="" table="agg_group_1" ctx=Select +TABLE: name="agg_group_1" schema="" table="agg_group_1" ctx=Select +TABLE: name="agg_hash_1" schema="" table="agg_hash_1" ctx=Select +STMT: SelectStmt +== 504 +(select * from agg_hash_2 except select * from agg_group_2) + union all +(select * from agg_group_2 except select * from agg_hash_2) +-- +TABLE: name="agg_hash_2" schema="" table="agg_hash_2" ctx=Select +TABLE: name="agg_group_2" schema="" table="agg_group_2" ctx=Select +TABLE: name="agg_group_2" schema="" table="agg_group_2" ctx=Select +TABLE: name="agg_hash_2" schema="" table="agg_hash_2" ctx=Select +STMT: SelectStmt +== 505 +(select * from agg_hash_3 except select * from agg_group_3) + union all +(select * from agg_group_3 except select * from agg_hash_3) +-- +TABLE: name="agg_hash_3" schema="" table="agg_hash_3" ctx=Select +TABLE: name="agg_group_3" schema="" table="agg_group_3" ctx=Select +TABLE: name="agg_group_3" schema="" table="agg_group_3" ctx=Select +TABLE: name="agg_hash_3" schema="" table="agg_hash_3" ctx=Select +STMT: SelectStmt +== 506 +(select * from agg_hash_4 except select * from agg_group_4) + union all +(select * from agg_group_4 except select * from agg_hash_4) +-- +TABLE: name="agg_hash_4" schema="" table="agg_hash_4" ctx=Select +TABLE: name="agg_group_4" schema="" table="agg_group_4" ctx=Select +TABLE: name="agg_group_4" schema="" table="agg_group_4" ctx=Select +TABLE: name="agg_hash_4" schema="" table="agg_hash_4" ctx=Select +STMT: SelectStmt +== 507 +drop table agg_group_1 +-- +TABLE: name="agg_group_1" schema="" table="agg_group_1" ctx=DDL +STMT: DropStmt +== 508 +drop table agg_group_2 +-- +TABLE: name="agg_group_2" schema="" table="agg_group_2" ctx=DDL +STMT: DropStmt +== 509 +drop table agg_group_3 +-- +TABLE: name="agg_group_3" schema="" table="agg_group_3" ctx=DDL +STMT: DropStmt +== 510 +drop table agg_group_4 +-- +TABLE: name="agg_group_4" schema="" table="agg_group_4" ctx=DDL +STMT: DropStmt +== 511 +drop table agg_hash_1 +-- +TABLE: name="agg_hash_1" schema="" table="agg_hash_1" ctx=DDL +STMT: DropStmt +== 512 +drop table agg_hash_2 +-- +TABLE: name="agg_hash_2" schema="" table="agg_hash_2" ctx=DDL +STMT: DropStmt +== 513 +drop table agg_hash_3 +-- +TABLE: name="agg_hash_3" schema="" table="agg_hash_3" ctx=DDL +STMT: DropStmt +== 514 +drop table agg_hash_4 +-- +TABLE: name="agg_hash_4" schema="" table="agg_hash_4" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/alter_generic.metadata.json b/parser/testdata/summary/postgres_regress/alter_generic.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/alter_generic.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/alter_generic.test b/parser/testdata/summary/postgres_regress/alter_generic.test new file mode 100644 index 0000000..c208b9d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/alter_generic.test @@ -0,0 +1,1809 @@ +== 001 +|-- +-- Test for ALTER some_object {RENAME TO, OWNER TO, SET SCHEMA} +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION test_opclass_options_func(internal) + RETURNS void + AS :'regresslib', 'test_opclass_options_func' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 224 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- Clean up in case a prior regression run failed +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +== 003 +DROP ROLE IF EXISTS regress_alter_generic_user1 +-- +STMT: DropRoleStmt +== 004 +DROP ROLE IF EXISTS regress_alter_generic_user2 +-- +STMT: DropRoleStmt +== 005 +DROP ROLE IF EXISTS regress_alter_generic_user3 +-- +STMT: DropRoleStmt +== 006 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 007 +CREATE USER regress_alter_generic_user3 +-- +STMT: CreateRoleStmt +== 008 +CREATE USER regress_alter_generic_user2 +-- +STMT: CreateRoleStmt +== 009 +CREATE USER regress_alter_generic_user1 IN ROLE regress_alter_generic_user3 +-- +STMT: CreateRoleStmt +== 010 +CREATE SCHEMA alt_nsp1 +-- +STMT: CreateSchemaStmt +== 011 +CREATE SCHEMA alt_nsp2 +-- +STMT: CreateSchemaStmt +== 012 +GRANT ALL ON SCHEMA alt_nsp1, alt_nsp2 TO public +-- +STMT: GrantStmt +== 013 +SET search_path = alt_nsp1, public +-- +STMT: VariableSetStmt +== 014 +|-- +-- Function and Aggregate +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +== 015 +CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql + AS 'SELECT $1 + 1' +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 016 +CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql + AS 'SELECT $1 - 1' +-- +FUNCTION: name="alt_func2" function="alt_func2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 017 +CREATE AGGREGATE alt_agg1 ( + sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0 +) +-- +STMT: DefineStmt +== 018 +CREATE AGGREGATE alt_agg2 ( + sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = 0 +) +-- +STMT: DefineStmt +== 019 +ALTER AGGREGATE alt_func1(int) RENAME TO alt_func3 +-- +STMT: RenameStmt +== 020 +-- failed (not aggregate) +ALTER AGGREGATE alt_func1(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 021 +-- failed (not aggregate) +ALTER AGGREGATE alt_func1(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 022 +-- failed (not aggregate) + +ALTER FUNCTION alt_func1(int) RENAME TO alt_func2 +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +FUNCTION: name="alt_func2" function="alt_func2" schema="" ctx=DDL +STMT: RenameStmt +== 023 +-- failed (name conflict) +ALTER FUNCTION alt_func1(int) RENAME TO alt_func3 +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +FUNCTION: name="alt_func3" function="alt_func3" schema="" ctx=DDL +STMT: RenameStmt +== 024 +-- OK +ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 025 +-- failed (no role membership) +ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 026 +-- OK +ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp1 +-- +STMT: AlterObjectSchemaStmt +== 027 +-- OK, already there +ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 028 +-- OK + +ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg2 +-- +STMT: RenameStmt +== 029 +-- failed (name conflict) +ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg3 +-- +STMT: RenameStmt +== 030 +-- OK +ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 031 +-- failed (no role membership) +ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 032 +-- OK +ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 033 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +== 034 +CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql + AS 'SELECT $1 + 2' +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 035 +CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql + AS 'SELECT $1 - 2' +-- +FUNCTION: name="alt_func2" function="alt_func2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 036 +CREATE AGGREGATE alt_agg1 ( + sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100 +) +-- +STMT: DefineStmt +== 037 +CREATE AGGREGATE alt_agg2 ( + sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = -100 +) +-- +STMT: DefineStmt +== 038 +ALTER FUNCTION alt_func3(int) RENAME TO alt_func4 +-- +FUNCTION: name="alt_func3" function="alt_func3" schema="" ctx=DDL +FUNCTION: name="alt_func4" function="alt_func4" schema="" ctx=DDL +STMT: RenameStmt +== 039 +-- failed (not owner) +ALTER FUNCTION alt_func1(int) RENAME TO alt_func4 +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +FUNCTION: name="alt_func4" function="alt_func4" schema="" ctx=DDL +STMT: RenameStmt +== 040 +-- OK +ALTER FUNCTION alt_func3(int) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 041 +-- failed (not owner) +ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 042 +-- failed (no role membership) +ALTER FUNCTION alt_func3(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 043 +-- failed (not owner) +ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 044 +-- failed (name conflicts) + +ALTER AGGREGATE alt_agg3(int) RENAME TO alt_agg4 +-- +STMT: RenameStmt +== 045 +-- failed (not owner) +ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg4 +-- +STMT: RenameStmt +== 046 +-- OK +ALTER AGGREGATE alt_agg3(int) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 047 +-- failed (not owner) +ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 048 +-- failed (no role membership) +ALTER AGGREGATE alt_agg3(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 049 +-- failed (not owner) +ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 050 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 051 +SELECT n.nspname, proname, prorettype::regtype, prokind, a.rolname + FROM pg_proc p, pg_namespace n, pg_authid a + WHERE p.pronamespace = n.oid AND p.proowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="p" column="pronamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="p" column="proowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +== 052 +|-- +-- We would test collations here, but it's not possible because the error +-- messages tend to be nonportable. +|-- + +|-- +-- Conversion +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +== 053 +CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 054 +CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 055 +ALTER CONVERSION alt_conv1 RENAME TO alt_conv2 +-- +STMT: RenameStmt +== 056 +-- failed (name conflict) +ALTER CONVERSION alt_conv1 RENAME TO alt_conv3 +-- +STMT: RenameStmt +== 057 +-- OK +ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 058 +-- failed (no role membership) +ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 059 +-- OK +ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 060 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +== 061 +CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 062 +CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 063 +ALTER CONVERSION alt_conv3 RENAME TO alt_conv4 +-- +STMT: RenameStmt +== 064 +-- failed (not owner) +ALTER CONVERSION alt_conv1 RENAME TO alt_conv4 +-- +STMT: RenameStmt +== 065 +-- OK +ALTER CONVERSION alt_conv3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 066 +-- failed (not owner) +ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 067 +-- failed (no role membership) +ALTER CONVERSION alt_conv3 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 068 +-- failed (not owner) +ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 069 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 070 +SELECT n.nspname, c.conname, a.rolname + FROM pg_conversion c, pg_namespace n, pg_authid a + WHERE c.connamespace = n.oid AND c.conowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, conname +-- +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "c"="pg_conversion" +ALIAS: "n"="pg_namespace" +FILTER: schema="" table="c" column="connamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="c" column="conowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +== 071 +|-- +-- Foreign Data Wrapper and Foreign Server +|-- +CREATE FOREIGN DATA WRAPPER alt_fdw1 +-- +STMT: CreateFdwStmt +== 072 +CREATE FOREIGN DATA WRAPPER alt_fdw2 +-- +STMT: CreateFdwStmt +== 073 +CREATE SERVER alt_fserv1 FOREIGN DATA WRAPPER alt_fdw1 +-- +STMT: CreateForeignServerStmt +== 074 +CREATE SERVER alt_fserv2 FOREIGN DATA WRAPPER alt_fdw2 +-- +STMT: CreateForeignServerStmt +== 075 +ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw2 +-- +STMT: RenameStmt +== 076 +-- failed (name conflict) +ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw3 +-- +STMT: RenameStmt +== 077 +-- OK + +ALTER SERVER alt_fserv1 RENAME TO alt_fserv2 +-- +STMT: RenameStmt +== 078 +-- failed (name conflict) +ALTER SERVER alt_fserv1 RENAME TO alt_fserv3 +-- +STMT: RenameStmt +== 079 +-- OK + +SELECT fdwname FROM pg_foreign_data_wrapper WHERE fdwname like 'alt_fdw%' +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +FILTER: schema="" table="" column="fdwname" +STMT: SelectStmt +== 080 +SELECT srvname FROM pg_foreign_server WHERE srvname like 'alt_fserv%' +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +FILTER: schema="" table="" column="srvname" +STMT: SelectStmt +== 081 +|-- +-- Procedural Language +|-- +CREATE LANGUAGE alt_lang1 HANDLER plpgsql_call_handler +-- +STMT: CreatePLangStmt +== 082 +CREATE LANGUAGE alt_lang2 HANDLER plpgsql_call_handler +-- +STMT: CreatePLangStmt +== 083 +ALTER LANGUAGE alt_lang1 OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +== 084 +-- OK +ALTER LANGUAGE alt_lang2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 085 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +== 086 +ALTER LANGUAGE alt_lang1 RENAME TO alt_lang2 +-- +STMT: RenameStmt +== 087 +-- failed (name conflict) +ALTER LANGUAGE alt_lang2 RENAME TO alt_lang3 +-- +STMT: RenameStmt +== 088 +-- failed (not owner) +ALTER LANGUAGE alt_lang1 RENAME TO alt_lang3 +-- +STMT: RenameStmt +== 089 +-- OK + +ALTER LANGUAGE alt_lang2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 090 +-- failed (not owner) +ALTER LANGUAGE alt_lang3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 091 +-- failed (no role membership) +ALTER LANGUAGE alt_lang3 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 092 +-- OK + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 093 +SELECT lanname, a.rolname + FROM pg_language l, pg_authid a + WHERE l.lanowner = a.oid AND l.lanname like 'alt_lang%' + ORDER BY lanname +-- +TABLE: name="pg_language" schema="" table="pg_language" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "l"="pg_language" +FILTER: schema="" table="l" column="lanowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="l" column="lanname" +STMT: SelectStmt +== 094 +|-- +-- Operator +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +== 095 +CREATE OPERATOR @-@ ( leftarg = int4, rightarg = int4, procedure = int4mi ) +-- +STMT: DefineStmt +== 096 +CREATE OPERATOR @+@ ( leftarg = int4, rightarg = int4, procedure = int4pl ) +-- +STMT: DefineStmt +== 097 +ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 098 +-- failed (no role membership) +ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 099 +-- OK +ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 100 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +== 101 +CREATE OPERATOR @-@ ( leftarg = int4, rightarg = int4, procedure = int4mi ) +-- +STMT: DefineStmt +== 102 +ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 103 +-- failed (not owner) +ALTER OPERATOR @-@(int4, int4) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 104 +-- failed (no role membership) +ALTER OPERATOR @+@(int4, int4) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 105 +-- failed (not owner) +-- can't test this: the error message includes the raw oid of namespace +-- ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2; -- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 106 +SELECT n.nspname, oprname, a.rolname, + oprleft::regtype, oprright::regtype, oprcode::regproc + FROM pg_operator o, pg_namespace n, pg_authid a + WHERE o.oprnamespace = n.oid AND o.oprowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, oprname +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "o"="pg_operator" +FILTER: schema="" table="o" column="oprnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="o" column="oprowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +== 107 +|-- +-- OpFamily and OpClass +|-- +CREATE OPERATOR FAMILY alt_opf1 USING hash +-- +STMT: CreateOpFamilyStmt +== 108 +CREATE OPERATOR FAMILY alt_opf2 USING hash +-- +STMT: CreateOpFamilyStmt +== 109 +ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +== 110 +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +== 111 +CREATE OPERATOR CLASS alt_opc1 FOR TYPE uuid USING hash AS STORAGE uuid +-- +STMT: CreateOpClassStmt +== 112 +CREATE OPERATOR CLASS alt_opc2 FOR TYPE uuid USING hash AS STORAGE uuid +-- +STMT: CreateOpClassStmt +== 113 +ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +== 114 +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +== 115 +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +== 116 +ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf2 +-- +STMT: RenameStmt +== 117 +-- failed (name conflict) +ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf3 +-- +STMT: RenameStmt +== 118 +-- OK +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 119 +-- failed (no role membership) +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 120 +-- OK +ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 121 +-- OK + +ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc2 +-- +STMT: RenameStmt +== 122 +-- failed (name conflict) +ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc3 +-- +STMT: RenameStmt +== 123 +-- OK +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 124 +-- failed (no role membership) +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 125 +-- OK +ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 126 +-- OK + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 127 +CREATE OPERATOR FAMILY alt_opf1 USING hash +-- +STMT: CreateOpFamilyStmt +== 128 +CREATE OPERATOR FAMILY alt_opf2 USING hash +-- +STMT: CreateOpFamilyStmt +== 129 +ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 130 +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 131 +CREATE OPERATOR CLASS alt_opc1 FOR TYPE macaddr USING hash AS STORAGE macaddr +-- +STMT: CreateOpClassStmt +== 132 +CREATE OPERATOR CLASS alt_opc2 FOR TYPE macaddr USING hash AS STORAGE macaddr +-- +STMT: CreateOpClassStmt +== 133 +ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 134 +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 135 +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +== 136 +ALTER OPERATOR FAMILY alt_opf3 USING hash RENAME TO alt_opf4 +-- +STMT: RenameStmt +== 137 +-- failed (not owner) +ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf4 +-- +STMT: RenameStmt +== 138 +-- OK +ALTER OPERATOR FAMILY alt_opf3 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 139 +-- failed (not owner) +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 140 +-- failed (no role membership) +ALTER OPERATOR FAMILY alt_opf3 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 141 +-- failed (not owner) +ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 142 +-- failed (name conflict) + +ALTER OPERATOR CLASS alt_opc3 USING hash RENAME TO alt_opc4 +-- +STMT: RenameStmt +== 143 +-- failed (not owner) +ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc4 +-- +STMT: RenameStmt +== 144 +-- OK +ALTER OPERATOR CLASS alt_opc3 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 145 +-- failed (not owner) +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 146 +-- failed (no role membership) +ALTER OPERATOR CLASS alt_opc3 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 147 +-- failed (not owner) +ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 148 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 149 +SELECT nspname, opfname, amname, rolname + FROM pg_opfamily o, pg_am m, pg_namespace n, pg_authid a + WHERE o.opfmethod = m.oid AND o.opfnamespace = n.oid AND o.opfowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + AND NOT opfname LIKE 'alt_opc%' + ORDER BY nspname, opfname +-- +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "m"="pg_am" +ALIAS: "n"="pg_namespace" +ALIAS: "o"="pg_opfamily" +FILTER: schema="" table="o" column="opfmethod" +FILTER: schema="" table="m" column="oid" +FILTER: schema="" table="o" column="opfnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="o" column="opfowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +FILTER: schema="" table="" column="opfname" +STMT: SelectStmt +== 150 +SELECT nspname, opcname, amname, rolname + FROM pg_opclass o, pg_am m, pg_namespace n, pg_authid a + WHERE o.opcmethod = m.oid AND o.opcnamespace = n.oid AND o.opcowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, opcname +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "m"="pg_am" +ALIAS: "n"="pg_namespace" +ALIAS: "o"="pg_opclass" +FILTER: schema="" table="o" column="opcmethod" +FILTER: schema="" table="m" column="oid" +FILTER: schema="" table="o" column="opcnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="o" column="opcowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +== 151 +-- ALTER OPERATOR FAMILY ... ADD/DROP + +-- Should work. Textbook case of CREATE / ALTER ADD / ALTER DROP / DROP +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 152 +CREATE OPERATOR FAMILY alt_opf4 USING btree +-- +STMT: CreateOpFamilyStmt +== 153 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD + -- int4 vs int2 + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 154 +ALTER OPERATOR FAMILY alt_opf4 USING btree DROP + -- int4 vs int2 + OPERATOR 1 (int4, int2) , + OPERATOR 2 (int4, int2) , + OPERATOR 3 (int4, int2) , + OPERATOR 4 (int4, int2) , + OPERATOR 5 (int4, int2) , + FUNCTION 1 (int4, int2) +-- +STMT: AlterOpFamilyStmt +== 155 +DROP OPERATOR FAMILY alt_opf4 USING btree +-- +STMT: DropStmt +== 156 +ROLLBACK +-- +STMT: TransactionStmt +== 157 +-- Should fail. Invalid values for ALTER OPERATOR FAMILY .. ADD / DROP +CREATE OPERATOR FAMILY alt_opf4 USING btree +-- +STMT: CreateOpFamilyStmt +== 158 +ALTER OPERATOR FAMILY alt_opf4 USING invalid_index_method ADD OPERATOR 1 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +== 159 +-- invalid indexing_method +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 6 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +== 160 +-- operator number should be between 1 and 5 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 0 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +== 161 +-- operator number should be between 1 and 5 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 1 < +-- +STMT: AlterOpFamilyStmt +== 162 +-- operator without argument types +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 0 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 163 +-- invalid options parsing function +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 6 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 164 +-- function number should be between 1 and 5 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD STORAGE invalid_storage +-- +STMT: AlterOpFamilyStmt +== 165 +-- Ensure STORAGE is not a part of ALTER OPERATOR FAMILY +DROP OPERATOR FAMILY alt_opf4 USING btree +-- +STMT: DropStmt +== 166 +-- Should fail. Need to be SUPERUSER to do ALTER OPERATOR FAMILY .. ADD / DROP +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 167 +CREATE ROLE regress_alter_generic_user5 NOSUPERUSER +-- +STMT: CreateRoleStmt +== 168 +CREATE OPERATOR FAMILY alt_opf5 USING btree +-- +STMT: CreateOpFamilyStmt +== 169 +SET ROLE regress_alter_generic_user5 +-- +STMT: VariableSetStmt +== 170 +ALTER OPERATOR FAMILY alt_opf5 USING btree ADD OPERATOR 1 < (int4, int2), FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 171 +RESET ROLE +-- +STMT: VariableSetStmt +== 172 +DROP OPERATOR FAMILY alt_opf5 USING btree +-- +STMT: DropStmt +== 173 +ROLLBACK +-- +STMT: TransactionStmt +== 174 +-- Should fail. Need rights to namespace for ALTER OPERATOR FAMILY .. ADD / DROP +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 175 +CREATE ROLE regress_alter_generic_user6 +-- +STMT: CreateRoleStmt +== 176 +CREATE SCHEMA alt_nsp6 +-- +STMT: CreateSchemaStmt +== 177 +REVOKE ALL ON SCHEMA alt_nsp6 FROM regress_alter_generic_user6 +-- +STMT: GrantStmt +== 178 +CREATE OPERATOR FAMILY alt_nsp6.alt_opf6 USING btree +-- +STMT: CreateOpFamilyStmt +== 179 +SET ROLE regress_alter_generic_user6 +-- +STMT: VariableSetStmt +== 180 +ALTER OPERATOR FAMILY alt_nsp6.alt_opf6 USING btree ADD OPERATOR 1 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +== 181 +ROLLBACK +-- +STMT: TransactionStmt +== 182 +-- Should fail. Only two arguments required for ALTER OPERATOR FAMILY ... DROP OPERATOR +CREATE OPERATOR FAMILY alt_opf7 USING btree +-- +STMT: CreateOpFamilyStmt +== 183 +ALTER OPERATOR FAMILY alt_opf7 USING btree ADD OPERATOR 1 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +== 184 +ALTER OPERATOR FAMILY alt_opf7 USING btree DROP OPERATOR 1 (int4, int2, int8) +-- +STMT: AlterOpFamilyStmt +== 185 +DROP OPERATOR FAMILY alt_opf7 USING btree +-- +STMT: DropStmt +== 186 +-- Should work. During ALTER OPERATOR FAMILY ... DROP OPERATOR +-- when left type is the same as right type, a DROP with only one argument type should work +CREATE OPERATOR FAMILY alt_opf8 USING btree +-- +STMT: CreateOpFamilyStmt +== 187 +ALTER OPERATOR FAMILY alt_opf8 USING btree ADD OPERATOR 1 < (int4, int4) +-- +STMT: AlterOpFamilyStmt +== 188 +DROP OPERATOR FAMILY alt_opf8 USING btree +-- +STMT: DropStmt +== 189 +-- Should work. Textbook case of ALTER OPERATOR FAMILY ... ADD OPERATOR with FOR ORDER BY +CREATE OPERATOR FAMILY alt_opf9 USING gist +-- +STMT: CreateOpFamilyStmt +== 190 +ALTER OPERATOR FAMILY alt_opf9 USING gist ADD OPERATOR 1 < (int4, int4) FOR ORDER BY float_ops +-- +STMT: AlterOpFamilyStmt +== 191 +DROP OPERATOR FAMILY alt_opf9 USING gist +-- +STMT: DropStmt +== 192 +-- Should fail. Ensure correct ordering methods in ALTER OPERATOR FAMILY ... ADD OPERATOR .. FOR ORDER BY +CREATE OPERATOR FAMILY alt_opf10 USING btree +-- +STMT: CreateOpFamilyStmt +== 193 +ALTER OPERATOR FAMILY alt_opf10 USING btree ADD OPERATOR 1 < (int4, int4) FOR ORDER BY float_ops +-- +STMT: AlterOpFamilyStmt +== 194 +DROP OPERATOR FAMILY alt_opf10 USING btree +-- +STMT: DropStmt +== 195 +-- Should work. Textbook case of ALTER OPERATOR FAMILY ... ADD OPERATOR with FOR ORDER BY +CREATE OPERATOR FAMILY alt_opf11 USING gist +-- +STMT: CreateOpFamilyStmt +== 196 +ALTER OPERATOR FAMILY alt_opf11 USING gist ADD OPERATOR 1 < (int4, int4) FOR ORDER BY float_ops +-- +STMT: AlterOpFamilyStmt +== 197 +ALTER OPERATOR FAMILY alt_opf11 USING gist DROP OPERATOR 1 (int4, int4) +-- +STMT: AlterOpFamilyStmt +== 198 +DROP OPERATOR FAMILY alt_opf11 USING gist +-- +STMT: DropStmt +== 199 +-- Should fail. btree comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 200 +CREATE OPERATOR FAMILY alt_opf12 USING btree +-- +STMT: CreateOpFamilyStmt +== 201 +CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL +-- +FUNCTION: name="fn_opf12" function="fn_opf12" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 202 +ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 203 +DROP OPERATOR FAMILY alt_opf12 USING btree +-- +STMT: DropStmt +== 204 +ROLLBACK +-- +STMT: TransactionStmt +== 205 +-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 206 +CREATE OPERATOR FAMILY alt_opf13 USING hash +-- +STMT: CreateOpFamilyStmt +== 207 +CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL +-- +FUNCTION: name="fn_opf13" function="fn_opf13" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 208 +ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4) +-- +STMT: AlterOpFamilyStmt +== 209 +DROP OPERATOR FAMILY alt_opf13 USING hash +-- +STMT: DropStmt +== 210 +ROLLBACK +-- +STMT: TransactionStmt +== 211 +-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 212 +CREATE OPERATOR FAMILY alt_opf14 USING btree +-- +STMT: CreateOpFamilyStmt +== 213 +CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL +-- +FUNCTION: name="fn_opf14" function="fn_opf14" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 214 +ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4) +-- +STMT: AlterOpFamilyStmt +== 215 +DROP OPERATOR FAMILY alt_opf14 USING btree +-- +STMT: DropStmt +== 216 +ROLLBACK +-- +STMT: TransactionStmt +== 217 +-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 218 +CREATE OPERATOR FAMILY alt_opf15 USING hash +-- +STMT: CreateOpFamilyStmt +== 219 +CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL +-- +FUNCTION: name="fn_opf15" function="fn_opf15" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 220 +ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 221 +DROP OPERATOR FAMILY alt_opf15 USING hash +-- +STMT: DropStmt +== 222 +ROLLBACK +-- +STMT: TransactionStmt +== 223 +-- Should fail. In gist throw an error when giving different data types for function argument +-- without defining left / right type in ALTER OPERATOR FAMILY ... ADD FUNCTION +CREATE OPERATOR FAMILY alt_opf16 USING gist +-- +STMT: CreateOpFamilyStmt +== 224 +ALTER OPERATOR FAMILY alt_opf16 USING gist ADD FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 225 +DROP OPERATOR FAMILY alt_opf16 USING gist +-- +STMT: DropStmt +== 226 +-- Should fail. duplicate operator number / function number in ALTER OPERATOR FAMILY ... ADD FUNCTION +CREATE OPERATOR FAMILY alt_opf17 USING btree +-- +STMT: CreateOpFamilyStmt +== 227 +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 < (int4, int4), OPERATOR 1 < (int4, int4) +-- +STMT: AlterOpFamilyStmt +== 228 +-- operator # appears twice in same statement +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 < (int4, int4) +-- +STMT: AlterOpFamilyStmt +== 229 +-- operator 1 requested first-time +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 < (int4, int4) +-- +STMT: AlterOpFamilyStmt +== 230 +-- operator 1 requested again in separate statement +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 231 +-- procedure 1 appears twice in same statement +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 232 +-- procedure 1 appears first time +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 233 +-- procedure 1 requested again in separate statement +DROP OPERATOR FAMILY alt_opf17 USING btree +-- +STMT: DropStmt +== 234 +-- Should fail. Ensure that DROP requests for missing OPERATOR / FUNCTIONS +-- return appropriate message in ALTER OPERATOR FAMILY ... DROP OPERATOR / FUNCTION +CREATE OPERATOR FAMILY alt_opf18 USING btree +-- +STMT: CreateOpFamilyStmt +== 235 +ALTER OPERATOR FAMILY alt_opf18 USING btree DROP OPERATOR 1 (int4, int4) +-- +STMT: AlterOpFamilyStmt +== 236 +ALTER OPERATOR FAMILY alt_opf18 USING btree ADD + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 237 +-- Should fail. Not allowed to have cross-type equalimage function. +ALTER OPERATOR FAMILY alt_opf18 USING btree + ADD FUNCTION 4 (int4, int2) btequalimage(oid) +-- +STMT: AlterOpFamilyStmt +== 238 +ALTER OPERATOR FAMILY alt_opf18 USING btree DROP FUNCTION 2 (int4, int4) +-- +STMT: AlterOpFamilyStmt +== 239 +DROP OPERATOR FAMILY alt_opf18 USING btree +-- +STMT: DropStmt +== 240 +-- Should fail. Invalid opclass options function (#5) specifications. +CREATE OPERATOR FAMILY alt_opf19 USING btree +-- +STMT: CreateOpFamilyStmt +== 241 +ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 test_opclass_options_func(internal, text[], bool) +-- +STMT: AlterOpFamilyStmt +== 242 +ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 243 +ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4, int2) btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +== 244 +ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) test_opclass_options_func(internal) +-- +STMT: AlterOpFamilyStmt +== 245 +-- Ok +ALTER OPERATOR FAMILY alt_opf19 USING btree DROP FUNCTION 5 (int4, int4) +-- +STMT: AlterOpFamilyStmt +== 246 +DROP OPERATOR FAMILY alt_opf19 USING btree +-- +STMT: DropStmt +== 247 +|-- +-- Statistics +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +== 248 +CREATE TABLE alt_regress_1 (a INTEGER, b INTEGER) +-- +TABLE: name="alt_regress_1" schema="" table="alt_regress_1" ctx=DDL +STMT: CreateStmt +== 249 +CREATE STATISTICS alt_stat1 ON a, b FROM alt_regress_1 +-- +STMT: CreateStatsStmt +== 250 +CREATE STATISTICS alt_stat2 ON a, b FROM alt_regress_1 +-- +STMT: CreateStatsStmt +== 251 +ALTER STATISTICS alt_stat1 RENAME TO alt_stat2 +-- +STMT: RenameStmt +== 252 +-- failed (name conflict) +ALTER STATISTICS alt_stat1 RENAME TO alt_stat3 +-- +STMT: RenameStmt +== 253 +-- OK +ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 254 +-- failed (no role membership) +ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 255 +-- OK +ALTER STATISTICS alt_stat2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 256 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +== 257 +CREATE TABLE alt_regress_2 (a INTEGER, b INTEGER) +-- +TABLE: name="alt_regress_2" schema="" table="alt_regress_2" ctx=DDL +STMT: CreateStmt +== 258 +CREATE STATISTICS alt_stat1 ON a, b FROM alt_regress_2 +-- +STMT: CreateStatsStmt +== 259 +CREATE STATISTICS alt_stat2 ON a, b FROM alt_regress_2 +-- +STMT: CreateStatsStmt +== 260 +ALTER STATISTICS alt_stat3 RENAME TO alt_stat4 +-- +STMT: RenameStmt +== 261 +-- failed (not owner) +ALTER STATISTICS alt_stat1 RENAME TO alt_stat4 +-- +STMT: RenameStmt +== 262 +-- OK +ALTER STATISTICS alt_stat3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 263 +-- failed (not owner) +ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 264 +-- failed (no role membership) +ALTER STATISTICS alt_stat3 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 265 +-- failed (not owner) +ALTER STATISTICS alt_stat2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 266 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 267 +SELECT nspname, stxname, rolname + FROM pg_statistic_ext s, pg_namespace n, pg_authid a + WHERE s.stxnamespace = n.oid AND s.stxowner = a.oid + AND n.nspname in ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, stxname +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="s" column="stxowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +== 268 +|-- +-- Text Search Dictionary +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +== 269 +CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple) +-- +STMT: DefineStmt +== 270 +CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template=simple) +-- +STMT: DefineStmt +== 271 +ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict2 +-- +STMT: RenameStmt +== 272 +-- failed (name conflict) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict3 +-- +STMT: RenameStmt +== 273 +-- OK +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 274 +-- failed (no role membership) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 275 +-- OK +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 276 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +== 277 +CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple) +-- +STMT: DefineStmt +== 278 +CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template=simple) +-- +STMT: DefineStmt +== 279 +ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 RENAME TO alt_ts_dict4 +-- +STMT: RenameStmt +== 280 +-- failed (not owner) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict4 +-- +STMT: RenameStmt +== 281 +-- OK +ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 282 +-- failed (not owner) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 283 +-- failed (no role membership) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 284 +-- failed (not owner) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 285 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 286 +SELECT nspname, dictname, rolname + FROM pg_ts_dict t, pg_namespace n, pg_authid a + WHERE t.dictnamespace = n.oid AND t.dictowner = a.oid + AND n.nspname in ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, dictname +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "t"="pg_ts_dict" +FILTER: schema="" table="t" column="dictnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="t" column="dictowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +== 287 +|-- +-- Text Search Configuration +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +== 288 +CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy=english) +-- +STMT: DefineStmt +== 289 +CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy=english) +-- +STMT: DefineStmt +== 290 +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf2 +-- +STMT: RenameStmt +== 291 +-- failed (name conflict) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf3 +-- +STMT: RenameStmt +== 292 +-- OK +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 293 +-- failed (no role membership) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 294 +-- OK +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 295 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +== 296 +CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy=english) +-- +STMT: DefineStmt +== 297 +CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy=english) +-- +STMT: DefineStmt +== 298 +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 RENAME TO alt_ts_conf4 +-- +STMT: RenameStmt +== 299 +-- failed (not owner) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf4 +-- +STMT: RenameStmt +== 300 +-- OK +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +== 301 +-- failed (not owner) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +== 302 +-- failed (no role membership) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 303 +-- failed (not owner) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 304 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 305 +SELECT nspname, cfgname, rolname + FROM pg_ts_config t, pg_namespace n, pg_authid a + WHERE t.cfgnamespace = n.oid AND t.cfgowner = a.oid + AND n.nspname in ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, cfgname +-- +TABLE: name="pg_ts_config" schema="" table="pg_ts_config" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "t"="pg_ts_config" +FILTER: schema="" table="t" column="cfgnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="t" column="cfgowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +== 306 +|-- +-- Text Search Template +|-- +CREATE TEXT SEARCH TEMPLATE alt_ts_temp1 (lexize=dsimple_lexize) +-- +STMT: DefineStmt +== 307 +CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize=dsimple_lexize) +-- +STMT: DefineStmt +== 308 +ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp2 +-- +STMT: RenameStmt +== 309 +-- failed (name conflict) +ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp3 +-- +STMT: RenameStmt +== 310 +-- OK +ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 311 +-- OK + +CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize=dsimple_lexize) +-- +STMT: DefineStmt +== 312 +ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 313 +-- failed (name conflict) + +-- invalid: non-lowercase quoted identifiers +CREATE TEXT SEARCH TEMPLATE tstemp_case ("Init" = init_function) +-- +STMT: DefineStmt +== 314 +SELECT nspname, tmplname + FROM pg_ts_template t, pg_namespace n + WHERE t.tmplnamespace = n.oid AND nspname like 'alt_nsp%' + ORDER BY nspname, tmplname +-- +TABLE: name="pg_ts_template" schema="" table="pg_ts_template" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "n"="pg_namespace" +ALIAS: "t"="pg_ts_template" +FILTER: schema="" table="t" column="tmplnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 315 +|-- +-- Text Search Parser +|-- + +CREATE TEXT SEARCH PARSER alt_ts_prs1 + (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +== 316 +CREATE TEXT SEARCH PARSER alt_ts_prs2 + (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +== 317 +ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs2 +-- +STMT: RenameStmt +== 318 +-- failed (name conflict) +ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs3 +-- +STMT: RenameStmt +== 319 +-- OK +ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 320 +-- OK + +CREATE TEXT SEARCH PARSER alt_ts_prs2 + (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +== 321 +ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +== 322 +-- failed (name conflict) + +-- invalid: non-lowercase quoted identifiers +CREATE TEXT SEARCH PARSER tspars_case ("Start" = start_function) +-- +STMT: DefineStmt +== 323 +SELECT nspname, prsname + FROM pg_ts_parser t, pg_namespace n + WHERE t.prsnamespace = n.oid AND nspname like 'alt_nsp%' + ORDER BY nspname, prsname +-- +TABLE: name="pg_ts_parser" schema="" table="pg_ts_parser" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "n"="pg_namespace" +ALIAS: "t"="pg_ts_parser" +FILTER: schema="" table="t" column="prsnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 324 +--- +--- Cleanup resources +--- +DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE +-- +STMT: DropStmt +== 325 +DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE +-- +STMT: DropStmt +== 326 +DROP LANGUAGE alt_lang2 CASCADE +-- +STMT: DropStmt +== 327 +DROP LANGUAGE alt_lang3 CASCADE +-- +STMT: DropStmt +== 328 +DROP SCHEMA alt_nsp1 CASCADE +-- +STMT: DropStmt +== 329 +DROP SCHEMA alt_nsp2 CASCADE +-- +STMT: DropStmt +== 330 +DROP USER regress_alter_generic_user1 +-- +STMT: DropRoleStmt +== 331 +DROP USER regress_alter_generic_user2 +-- +STMT: DropRoleStmt +== 332 +DROP USER regress_alter_generic_user3 +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/alter_operator.metadata.json b/parser/testdata/summary/postgres_regress/alter_operator.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/alter_operator.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/alter_operator.test b/parser/testdata/summary/postgres_regress/alter_operator.test new file mode 100644 index 0000000..b949dbf --- /dev/null +++ b/parser/testdata/summary/postgres_regress/alter_operator.test @@ -0,0 +1,452 @@ +== 001 +CREATE FUNCTION alter_op_test_fn(boolean, boolean) +RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="alter_op_test_fn" function="alter_op_test_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +CREATE FUNCTION customcontsel(internal, oid, internal, integer) +RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT +-- +FUNCTION: name="customcontsel" function="customcontsel" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +CREATE OPERATOR === ( + LEFTARG = boolean, + RIGHTARG = boolean, + PROCEDURE = alter_op_test_fn, + COMMUTATOR = ===, + NEGATOR = !==, + RESTRICT = customcontsel, + JOIN = contjoinsel, + HASHES, MERGES +) +-- +STMT: DefineStmt +== 004 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 005 +|-- +-- Test resetting and setting restrict and join attributes. +|-- + +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE) +-- +STMT: AlterOperatorStmt +== 006 +ALTER OPERATOR === (boolean, boolean) SET (JOIN = NONE) +-- +STMT: AlterOperatorStmt +== 007 +SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +== 008 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 009 +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = contsel) +-- +STMT: AlterOperatorStmt +== 010 +ALTER OPERATOR === (boolean, boolean) SET (JOIN = contjoinsel) +-- +STMT: AlterOperatorStmt +== 011 +SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +== 012 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 013 +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE, JOIN = NONE) +-- +STMT: AlterOperatorStmt +== 014 +SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +== 015 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 016 +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = customcontsel, JOIN = contjoinsel) +-- +STMT: AlterOperatorStmt +== 017 +SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +== 018 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 019 +|-- +-- Test invalid options. +|-- +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = non_existent_func) +-- +STMT: AlterOperatorStmt +== 020 +ALTER OPERATOR === (boolean, boolean) SET (JOIN = non_existent_func) +-- +STMT: AlterOperatorStmt +== 021 +-- invalid: non-lowercase quoted identifiers +ALTER OPERATOR & (bit, bit) SET ("Restrict" = _int_contsel, "Join" = _int_contjoinsel) +-- +STMT: AlterOperatorStmt +== 022 +|-- +-- Test permission check. Must be owner to ALTER OPERATOR. +|-- +CREATE USER regress_alter_op_user +-- +STMT: CreateRoleStmt +== 023 +SET SESSION AUTHORIZATION regress_alter_op_user +-- +STMT: VariableSetStmt +== 024 +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE) +-- +STMT: AlterOperatorStmt +== 025 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 026 +|-- +-- Test setting commutator, negator, merges, and hashes attributes, +-- which can only be set if not already set +|-- + +CREATE FUNCTION alter_op_test_fn_bool_real(boolean, real) +RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="alter_op_test_fn_bool_real" function="alter_op_test_fn_bool_real" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 027 +CREATE FUNCTION alter_op_test_fn_real_bool(real, boolean) +RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="alter_op_test_fn_real_bool" function="alter_op_test_fn_real_bool" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 028 +-- operator +CREATE OPERATOR === ( + LEFTARG = boolean, + RIGHTARG = real, + PROCEDURE = alter_op_test_fn_bool_real +) +-- +STMT: DefineStmt +== 029 +-- commutator +CREATE OPERATOR ==== ( + LEFTARG = real, + RIGHTARG = boolean, + PROCEDURE = alter_op_test_fn_real_bool +) +-- +STMT: DefineStmt +== 030 +-- negator +CREATE OPERATOR !==== ( + LEFTARG = boolean, + RIGHTARG = real, + PROCEDURE = alter_op_test_fn_bool_real +) +-- +STMT: DefineStmt +== 031 +-- No-op setting already false hashes and merges to false works +ALTER OPERATOR === (boolean, real) SET (MERGES = false) +-- +STMT: AlterOperatorStmt +== 032 +ALTER OPERATOR === (boolean, real) SET (HASHES = false) +-- +STMT: AlterOperatorStmt +== 033 +-- Test setting merges and hashes +ALTER OPERATOR === (boolean, real) SET (MERGES) +-- +STMT: AlterOperatorStmt +== 034 +ALTER OPERATOR === (boolean, real) SET (HASHES) +-- +STMT: AlterOperatorStmt +== 035 +SELECT oprcanmerge, oprcanhash +FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +== 036 +-- Test setting commutator +ALTER OPERATOR === (boolean, real) SET (COMMUTATOR = ====) +-- +STMT: AlterOperatorStmt +== 037 +-- Check that oprcom has been set on both the operator and commutator, +-- that they reference each other, and that the operator used is the existing +-- one we created and not a new shell operator. +SELECT op.oprname AS operator_name, com.oprname AS commutator_name, + com.oprcode AS commutator_func + FROM pg_operator op + INNER JOIN pg_operator com ON (op.oid = com.oprcom AND op.oprcom = com.oid) + WHERE op.oprname = '===' + AND op.oprleft = 'boolean'::regtype AND op.oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "com"="pg_operator" +ALIAS: "op"="pg_operator" +FILTER: schema="" table="op" column="oprname" +FILTER: schema="" table="op" column="oprleft" +FILTER: schema="" table="op" column="oprright" +STMT: SelectStmt +== 038 +-- Cannot set self as negator +ALTER OPERATOR === (boolean, real) SET (NEGATOR = ===) +-- +STMT: AlterOperatorStmt +== 039 +-- Test setting negator +ALTER OPERATOR === (boolean, real) SET (NEGATOR = !====) +-- +STMT: AlterOperatorStmt +== 040 +-- Check that oprnegate has been set on both the operator and negator, +-- that they reference each other, and that the operator used is the existing +-- one we created and not a new shell operator. +SELECT op.oprname AS operator_name, neg.oprname AS negator_name, + neg.oprcode AS negator_func + FROM pg_operator op + INNER JOIN pg_operator neg ON (op.oid = neg.oprnegate AND op.oprnegate = neg.oid) + WHERE op.oprname = '===' + AND op.oprleft = 'boolean'::regtype AND op.oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "neg"="pg_operator" +ALIAS: "op"="pg_operator" +FILTER: schema="" table="op" column="oprname" +FILTER: schema="" table="op" column="oprleft" +FILTER: schema="" table="op" column="oprright" +STMT: SelectStmt +== 041 +-- Test that no-op set succeeds +ALTER OPERATOR === (boolean, real) SET (NEGATOR = !====) +-- +STMT: AlterOperatorStmt +== 042 +ALTER OPERATOR === (boolean, real) SET (COMMUTATOR = ====) +-- +STMT: AlterOperatorStmt +== 043 +ALTER OPERATOR === (boolean, real) SET (MERGES) +-- +STMT: AlterOperatorStmt +== 044 +ALTER OPERATOR === (boolean, real) SET (HASHES) +-- +STMT: AlterOperatorStmt +== 045 +-- Check that the final state of the operator is as we expect +SELECT oprcanmerge, oprcanhash, + pg_describe_object('pg_operator'::regclass, oprcom, 0) AS commutator, + pg_describe_object('pg_operator'::regclass, oprnegate, 0) AS negator + FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +== 046 +-- Cannot change commutator, negator, merges, and hashes when already set + +CREATE OPERATOR @= ( + LEFTARG = real, + RIGHTARG = boolean, + PROCEDURE = alter_op_test_fn_real_bool +) +-- +STMT: DefineStmt +== 047 +CREATE OPERATOR @!= ( + LEFTARG = boolean, + RIGHTARG = real, + PROCEDURE = alter_op_test_fn_bool_real +) +-- +STMT: DefineStmt +== 048 +ALTER OPERATOR === (boolean, real) SET (COMMUTATOR = @=) +-- +STMT: AlterOperatorStmt +== 049 +ALTER OPERATOR === (boolean, real) SET (NEGATOR = @!=) +-- +STMT: AlterOperatorStmt +== 050 +ALTER OPERATOR === (boolean, real) SET (MERGES = false) +-- +STMT: AlterOperatorStmt +== 051 +ALTER OPERATOR === (boolean, real) SET (HASHES = false) +-- +STMT: AlterOperatorStmt +== 052 +-- Cannot set an operator that already has a commutator as the commutator +ALTER OPERATOR @=(real, boolean) SET (COMMUTATOR = ===) +-- +STMT: AlterOperatorStmt +== 053 +-- Cannot set an operator that already has a negator as the negator +ALTER OPERATOR @!=(boolean, real) SET (NEGATOR = ===) +-- +STMT: AlterOperatorStmt +== 054 +-- Check no changes made +SELECT oprcanmerge, oprcanhash, + pg_describe_object('pg_operator'::regclass, oprcom, 0) AS commutator, + pg_describe_object('pg_operator'::regclass, oprnegate, 0) AS negator + FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +== 055 +|-- +-- Clean up +|-- + +DROP USER regress_alter_op_user +-- +STMT: DropRoleStmt +== 056 +DROP OPERATOR === (boolean, boolean) +-- +STMT: DropStmt +== 057 +DROP OPERATOR === (boolean, real) +-- +STMT: DropStmt +== 058 +DROP OPERATOR ==== (real, boolean) +-- +STMT: DropStmt +== 059 +DROP OPERATOR !==== (boolean, real) +-- +STMT: DropStmt +== 060 +DROP OPERATOR @= (real, boolean) +-- +STMT: DropStmt +== 061 +DROP OPERATOR @!= (boolean, real) +-- +STMT: DropStmt +== 062 +DROP FUNCTION customcontsel(internal, oid, internal, integer) +-- +FUNCTION: name="customcontsel" function="customcontsel" schema="" ctx=DDL +STMT: DropStmt +== 063 +DROP FUNCTION alter_op_test_fn(boolean, boolean) +-- +FUNCTION: name="alter_op_test_fn" function="alter_op_test_fn" schema="" ctx=DDL +STMT: DropStmt +== 064 +DROP FUNCTION alter_op_test_fn_bool_real(boolean, real) +-- +FUNCTION: name="alter_op_test_fn_bool_real" function="alter_op_test_fn_bool_real" schema="" ctx=DDL +STMT: DropStmt +== 065 +DROP FUNCTION alter_op_test_fn_real_bool(real, boolean) +-- +FUNCTION: name="alter_op_test_fn_real_bool" function="alter_op_test_fn_real_bool" schema="" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/alter_table.metadata.json b/parser/testdata/summary/postgres_regress/alter_table.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/alter_table.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/alter_table.test b/parser/testdata/summary/postgres_regress/alter_table.test new file mode 100644 index 0000000..5660b98 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/alter_table.test @@ -0,0 +1,9502 @@ +== 001 +|-- +-- ALTER_TABLE +|-- + +-- Clean up in case a prior regression run failed +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +== 002 +DROP ROLE IF EXISTS regress_alter_table_user1 +-- +STMT: DropRoleStmt +== 003 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 004 +CREATE USER regress_alter_table_user1 +-- +STMT: CreateRoleStmt +== 005 +|-- +-- add attribute +|-- + +CREATE TABLE attmp (initial int4) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +== 006 +COMMENT ON TABLE attmp_wrong IS 'table comment' +-- +STMT: CommentStmt +== 007 +COMMENT ON TABLE attmp IS 'table comment' +-- +STMT: CommentStmt +== 008 +COMMENT ON TABLE attmp IS NULL +-- +STMT: CommentStmt +== 009 +ALTER TABLE attmp ADD COLUMN xmin integer +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 010 +-- fails + +ALTER TABLE attmp ADD COLUMN a int4 default 3 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 011 +ALTER TABLE attmp ADD COLUMN b name +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 012 +ALTER TABLE attmp ADD COLUMN c text +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 013 +ALTER TABLE attmp ADD COLUMN d float8 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 014 +ALTER TABLE attmp ADD COLUMN e float4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 015 +ALTER TABLE attmp ADD COLUMN f int2 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 016 +ALTER TABLE attmp ADD COLUMN g polygon +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 017 +ALTER TABLE attmp ADD COLUMN i char +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 018 +ALTER TABLE attmp ADD COLUMN k int4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 019 +ALTER TABLE attmp ADD COLUMN l tid +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 020 +ALTER TABLE attmp ADD COLUMN m xid +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 021 +ALTER TABLE attmp ADD COLUMN n oidvector +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 022 +--ALTER TABLE attmp ADD COLUMN o lock; +ALTER TABLE attmp ADD COLUMN p boolean +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 023 +ALTER TABLE attmp ADD COLUMN q point +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 024 +ALTER TABLE attmp ADD COLUMN r lseg +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 025 +ALTER TABLE attmp ADD COLUMN s path +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 026 +ALTER TABLE attmp ADD COLUMN t box +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 027 +ALTER TABLE attmp ADD COLUMN v timestamp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 028 +ALTER TABLE attmp ADD COLUMN w interval +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 029 +ALTER TABLE attmp ADD COLUMN x float8[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 030 +ALTER TABLE attmp ADD COLUMN y float4[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 031 +ALTER TABLE attmp ADD COLUMN z int2[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 032 +INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t, + v, w, x, y, z) + VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)', + 'c', + 314159, '(1,1)', '512', + '1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)', + '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', + 'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}') +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +SELECT * FROM attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=Select +STMT: SelectStmt +== 034 +DROP TABLE attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: DropStmt +== 035 +-- the wolf bug - schema mods caused inconsistent row descriptors +CREATE TABLE attmp ( + initial int4 +) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +== 036 +ALTER TABLE attmp ADD COLUMN a int4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 037 +ALTER TABLE attmp ADD COLUMN b name +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 038 +ALTER TABLE attmp ADD COLUMN c text +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 039 +ALTER TABLE attmp ADD COLUMN d float8 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 040 +ALTER TABLE attmp ADD COLUMN e float4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 041 +ALTER TABLE attmp ADD COLUMN f int2 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 042 +ALTER TABLE attmp ADD COLUMN g polygon +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 043 +ALTER TABLE attmp ADD COLUMN i char +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 044 +ALTER TABLE attmp ADD COLUMN k int4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 045 +ALTER TABLE attmp ADD COLUMN l tid +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 046 +ALTER TABLE attmp ADD COLUMN m xid +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 047 +ALTER TABLE attmp ADD COLUMN n oidvector +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 048 +--ALTER TABLE attmp ADD COLUMN o lock; +ALTER TABLE attmp ADD COLUMN p boolean +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 049 +ALTER TABLE attmp ADD COLUMN q point +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 050 +ALTER TABLE attmp ADD COLUMN r lseg +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 051 +ALTER TABLE attmp ADD COLUMN s path +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 052 +ALTER TABLE attmp ADD COLUMN t box +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 053 +ALTER TABLE attmp ADD COLUMN v timestamp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 054 +ALTER TABLE attmp ADD COLUMN w interval +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 055 +ALTER TABLE attmp ADD COLUMN x float8[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 056 +ALTER TABLE attmp ADD COLUMN y float4[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 057 +ALTER TABLE attmp ADD COLUMN z int2[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 058 +INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t, + v, w, x, y, z) + VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)', + 'c', + 314159, '(1,1)', '512', + '1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)', + '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', + 'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}') +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +SELECT * FROM attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=Select +STMT: SelectStmt +== 060 +CREATE INDEX attmp_idx ON attmp (a, (d + e), b) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: IndexStmt +== 061 +ALTER INDEX attmp_idx ALTER COLUMN 0 SET STATISTICS 1000 +-- +ERROR: column number must be in range from 1 to 32767 +CURSORPOS: 36 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 062 +ALTER INDEX attmp_idx ALTER COLUMN 1 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +== 063 +ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +== 064 +ALTER INDEX attmp_idx ALTER COLUMN 3 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +== 065 +ALTER INDEX attmp_idx ALTER COLUMN 4 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +== 066 +ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS -1 +-- +STMT: AlterTableStmt +== 067 +DROP TABLE attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: DropStmt +== 068 +|-- +-- rename - check on both non-temp and temp tables +|-- +CREATE TABLE attmp (regtable int) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +== 069 +CREATE TEMP TABLE attmp (attmptable int) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +== 070 +ALTER TABLE attmp RENAME TO attmp_new +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +TABLE: name="attmp_new" schema="" table="attmp_new" ctx=DDL +STMT: RenameStmt +== 071 +SELECT * FROM attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=Select +STMT: SelectStmt +== 072 +SELECT * FROM attmp_new +-- +TABLE: name="attmp_new" schema="" table="attmp_new" ctx=Select +STMT: SelectStmt +== 073 +ALTER TABLE attmp RENAME TO attmp_new2 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +TABLE: name="attmp_new2" schema="" table="attmp_new2" ctx=DDL +STMT: RenameStmt +== 074 +SELECT * FROM attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=Select +STMT: SelectStmt +== 075 +-- should fail +SELECT * FROM attmp_new +-- +TABLE: name="attmp_new" schema="" table="attmp_new" ctx=Select +STMT: SelectStmt +== 076 +SELECT * FROM attmp_new2 +-- +TABLE: name="attmp_new2" schema="" table="attmp_new2" ctx=Select +STMT: SelectStmt +== 077 +DROP TABLE attmp_new +-- +TABLE: name="attmp_new" schema="" table="attmp_new" ctx=DDL +STMT: DropStmt +== 078 +DROP TABLE attmp_new2 +-- +TABLE: name="attmp_new2" schema="" table="attmp_new2" ctx=DDL +STMT: DropStmt +== 079 +-- check rename of partitioned tables and indexes also +CREATE TABLE part_attmp (a int primary key) partition by range (a) +-- +TABLE: name="part_attmp" schema="" table="part_attmp" ctx=DDL +STMT: CreateStmt +== 080 +CREATE TABLE part_attmp1 PARTITION OF part_attmp FOR VALUES FROM (0) TO (100) +-- +TABLE: name="part_attmp1" schema="" table="part_attmp1" ctx=DDL +STMT: CreateStmt +== 081 +ALTER INDEX part_attmp_pkey RENAME TO part_attmp_index +-- +STMT: RenameStmt +== 082 +ALTER INDEX part_attmp1_pkey RENAME TO part_attmp1_index +-- +STMT: RenameStmt +== 083 +ALTER TABLE part_attmp RENAME TO part_at2tmp +-- +TABLE: name="part_attmp" schema="" table="part_attmp" ctx=DDL +TABLE: name="part_at2tmp" schema="" table="part_at2tmp" ctx=DDL +STMT: RenameStmt +== 084 +ALTER TABLE part_attmp1 RENAME TO part_at2tmp1 +-- +TABLE: name="part_attmp1" schema="" table="part_attmp1" ctx=DDL +TABLE: name="part_at2tmp1" schema="" table="part_at2tmp1" ctx=DDL +STMT: RenameStmt +== 085 +SET ROLE regress_alter_table_user1 +-- +STMT: VariableSetStmt +== 086 +ALTER INDEX part_attmp_index RENAME TO fail +-- +STMT: RenameStmt +== 087 +ALTER INDEX part_attmp1_index RENAME TO fail +-- +STMT: RenameStmt +== 088 +ALTER TABLE part_at2tmp RENAME TO fail +-- +TABLE: name="part_at2tmp" schema="" table="part_at2tmp" ctx=DDL +TABLE: name="fail" schema="" table="fail" ctx=DDL +STMT: RenameStmt +== 089 +ALTER TABLE part_at2tmp1 RENAME TO fail +-- +TABLE: name="part_at2tmp1" schema="" table="part_at2tmp1" ctx=DDL +TABLE: name="fail" schema="" table="fail" ctx=DDL +STMT: RenameStmt +== 090 +RESET ROLE +-- +STMT: VariableSetStmt +== 091 +DROP TABLE part_at2tmp +-- +TABLE: name="part_at2tmp" schema="" table="part_at2tmp" ctx=DDL +STMT: DropStmt +== 092 +|-- +-- check renaming to a table's array type's autogenerated name +-- (the array type's name should get out of the way) +|-- +CREATE TABLE attmp_array (id int) +-- +TABLE: name="attmp_array" schema="" table="attmp_array" ctx=DDL +STMT: CreateStmt +== 093 +CREATE TABLE attmp_array2 (id int) +-- +TABLE: name="attmp_array2" schema="" table="attmp_array2" ctx=DDL +STMT: CreateStmt +== 094 +SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 095 +SELECT typname FROM pg_type WHERE oid = 'attmp_array2[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 096 +ALTER TABLE attmp_array2 RENAME TO _attmp_array +-- +TABLE: name="attmp_array2" schema="" table="attmp_array2" ctx=DDL +TABLE: name="_attmp_array" schema="" table="_attmp_array" ctx=DDL +STMT: RenameStmt +== 097 +SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 098 +SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 099 +DROP TABLE _attmp_array +-- +TABLE: name="_attmp_array" schema="" table="_attmp_array" ctx=DDL +STMT: DropStmt +== 100 +DROP TABLE attmp_array +-- +TABLE: name="attmp_array" schema="" table="attmp_array" ctx=DDL +STMT: DropStmt +== 101 +-- renaming to table's own array type's name is an interesting corner case +CREATE TABLE attmp_array (id int) +-- +TABLE: name="attmp_array" schema="" table="attmp_array" ctx=DDL +STMT: CreateStmt +== 102 +SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 103 +ALTER TABLE attmp_array RENAME TO _attmp_array +-- +TABLE: name="attmp_array" schema="" table="attmp_array" ctx=DDL +TABLE: name="_attmp_array" schema="" table="_attmp_array" ctx=DDL +STMT: RenameStmt +== 104 +SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 105 +DROP TABLE _attmp_array +-- +TABLE: name="_attmp_array" schema="" table="_attmp_array" ctx=DDL +STMT: DropStmt +== 106 +-- ALTER TABLE ... RENAME on non-table relations +-- renaming indexes (FIXME: this should probably test the index's functionality) +ALTER INDEX IF EXISTS __onek_unique1 RENAME TO attmp_onek_unique1 +-- +STMT: RenameStmt +== 107 +ALTER INDEX IF EXISTS __attmp_onek_unique1 RENAME TO onek_unique1 +-- +STMT: RenameStmt +== 108 +ALTER INDEX onek_unique1 RENAME TO attmp_onek_unique1 +-- +STMT: RenameStmt +== 109 +ALTER INDEX attmp_onek_unique1 RENAME TO onek_unique1 +-- +STMT: RenameStmt +== 110 +SET ROLE regress_alter_table_user1 +-- +STMT: VariableSetStmt +== 111 +ALTER INDEX onek_unique1 RENAME TO fail +-- +STMT: RenameStmt +== 112 +-- permission denied +RESET ROLE +-- +STMT: VariableSetStmt +== 113 +-- rename statements with mismatching statement and object types +CREATE TABLE alter_idx_rename_test (a INT) +-- +TABLE: name="alter_idx_rename_test" schema="" table="alter_idx_rename_test" ctx=DDL +STMT: CreateStmt +== 114 +CREATE INDEX alter_idx_rename_test_idx ON alter_idx_rename_test (a) +-- +TABLE: name="alter_idx_rename_test" schema="" table="alter_idx_rename_test" ctx=DDL +STMT: IndexStmt +== 115 +CREATE TABLE alter_idx_rename_test_parted (a INT) PARTITION BY LIST (a) +-- +TABLE: name="alter_idx_rename_test_parted" schema="" table="alter_idx_rename_test_parted" ctx=DDL +STMT: CreateStmt +== 116 +CREATE INDEX alter_idx_rename_test_parted_idx ON alter_idx_rename_test_parted (a) +-- +TABLE: name="alter_idx_rename_test_parted" schema="" table="alter_idx_rename_test_parted" ctx=DDL +STMT: IndexStmt +== 117 +BEGIN +-- +STMT: TransactionStmt +== 118 +ALTER INDEX alter_idx_rename_test RENAME TO alter_idx_rename_test_2 +-- +STMT: RenameStmt +== 119 +ALTER INDEX alter_idx_rename_test_parted RENAME TO alter_idx_rename_test_parted_2 +-- +STMT: RenameStmt +== 120 +SELECT relation::regclass, mode FROM pg_locks +WHERE pid = pg_backend_pid() AND locktype = 'relation' + AND relation::regclass::text LIKE 'alter\_idx%' +ORDER BY relation::regclass::text COLLATE "C" +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="pid" +FILTER: schema="" table="" column="locktype" +FILTER: schema="" table="" column="relation" +STMT: SelectStmt +== 121 +COMMIT +-- +STMT: TransactionStmt +== 122 +BEGIN +-- +STMT: TransactionStmt +== 123 +ALTER INDEX alter_idx_rename_test_idx RENAME TO alter_idx_rename_test_idx_2 +-- +STMT: RenameStmt +== 124 +ALTER INDEX alter_idx_rename_test_parted_idx RENAME TO alter_idx_rename_test_parted_idx_2 +-- +STMT: RenameStmt +== 125 +SELECT relation::regclass, mode FROM pg_locks +WHERE pid = pg_backend_pid() AND locktype = 'relation' + AND relation::regclass::text LIKE 'alter\_idx%' +ORDER BY relation::regclass::text COLLATE "C" +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="pid" +FILTER: schema="" table="" column="locktype" +FILTER: schema="" table="" column="relation" +STMT: SelectStmt +== 126 +COMMIT +-- +STMT: TransactionStmt +== 127 +BEGIN +-- +STMT: TransactionStmt +== 128 +ALTER TABLE alter_idx_rename_test_idx_2 RENAME TO alter_idx_rename_test_idx_3 +-- +TABLE: name="alter_idx_rename_test_idx_2" schema="" table="alter_idx_rename_test_idx_2" ctx=DDL +TABLE: name="alter_idx_rename_test_idx_3" schema="" table="alter_idx_rename_test_idx_3" ctx=DDL +STMT: RenameStmt +== 129 +ALTER TABLE alter_idx_rename_test_parted_idx_2 RENAME TO alter_idx_rename_test_parted_idx_3 +-- +TABLE: name="alter_idx_rename_test_parted_idx_2" schema="" table="alter_idx_rename_test_parted_idx_2" ctx=DDL +TABLE: name="alter_idx_rename_test_parted_idx_3" schema="" table="alter_idx_rename_test_parted_idx_3" ctx=DDL +STMT: RenameStmt +== 130 +SELECT relation::regclass, mode FROM pg_locks +WHERE pid = pg_backend_pid() AND locktype = 'relation' + AND relation::regclass::text LIKE 'alter\_idx%' +ORDER BY relation::regclass::text COLLATE "C" +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="pid" +FILTER: schema="" table="" column="locktype" +FILTER: schema="" table="" column="relation" +STMT: SelectStmt +== 131 +COMMIT +-- +STMT: TransactionStmt +== 132 +DROP TABLE alter_idx_rename_test_2 +-- +TABLE: name="alter_idx_rename_test_2" schema="" table="alter_idx_rename_test_2" ctx=DDL +STMT: DropStmt +== 133 +-- renaming views +CREATE VIEW attmp_view (unique1) AS SELECT unique1 FROM tenk1 +-- +TABLE: name="attmp_view" schema="" table="attmp_view" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 134 +ALTER TABLE attmp_view RENAME TO attmp_view_new +-- +TABLE: name="attmp_view" schema="" table="attmp_view" ctx=DDL +TABLE: name="attmp_view_new" schema="" table="attmp_view_new" ctx=DDL +STMT: RenameStmt +== 135 +SET ROLE regress_alter_table_user1 +-- +STMT: VariableSetStmt +== 136 +ALTER VIEW attmp_view_new RENAME TO fail +-- +STMT: RenameStmt +== 137 +-- permission denied +RESET ROLE +-- +STMT: VariableSetStmt +== 138 +-- hack to ensure we get an indexscan here +set enable_seqscan to off +-- +STMT: VariableSetStmt +== 139 +set enable_bitmapscan to off +-- +STMT: VariableSetStmt +== 140 +-- 5 values, sorted +SELECT unique1 FROM tenk1 WHERE unique1 < 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 141 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 142 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 143 +DROP VIEW attmp_view_new +-- +STMT: DropStmt +== 144 +-- toast-like relation name +alter table stud_emp rename to pg_toast_stud_emp +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +TABLE: name="pg_toast_stud_emp" schema="" table="pg_toast_stud_emp" ctx=DDL +STMT: RenameStmt +== 145 +alter table pg_toast_stud_emp rename to stud_emp +-- +TABLE: name="pg_toast_stud_emp" schema="" table="pg_toast_stud_emp" ctx=DDL +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: RenameStmt +== 146 +-- renaming index should rename constraint as well +ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +== 147 +ALTER INDEX onek_unique1_constraint RENAME TO onek_unique1_constraint_foo +-- +STMT: RenameStmt +== 148 +ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +== 149 +-- renaming constraint +ALTER TABLE onek ADD CONSTRAINT onek_check_constraint CHECK (unique1 >= 0) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +== 150 +ALTER TABLE onek RENAME CONSTRAINT onek_check_constraint TO onek_check_constraint_foo +-- +STMT: RenameStmt +== 151 +ALTER TABLE onek DROP CONSTRAINT onek_check_constraint_foo +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +== 152 +-- renaming constraint should rename index as well +ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +== 153 +DROP INDEX onek_unique1_constraint +-- +STMT: DropStmt +== 154 +-- to see whether it's there +ALTER TABLE onek RENAME CONSTRAINT onek_unique1_constraint TO onek_unique1_constraint_foo +-- +STMT: RenameStmt +== 155 +DROP INDEX onek_unique1_constraint_foo +-- +STMT: DropStmt +== 156 +-- to see whether it's there +ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +== 157 +-- renaming constraints vs. inheritance +CREATE TABLE constraint_rename_test (a int CONSTRAINT con1 CHECK (a > 0), b int, c int) +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: CreateStmt +== 158 +CREATE TABLE constraint_rename_test2 (a int CONSTRAINT con1 CHECK (a > 0), d int) INHERITS (constraint_rename_test) +-- +TABLE: name="constraint_rename_test2" schema="" table="constraint_rename_test2" ctx=DDL +STMT: CreateStmt +== 159 +ALTER TABLE constraint_rename_test2 RENAME CONSTRAINT con1 TO con1foo +-- +STMT: RenameStmt +== 160 +-- fail +ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con1 TO con1foo +-- +STMT: RenameStmt +== 161 +-- fail +ALTER TABLE constraint_rename_test RENAME CONSTRAINT con1 TO con1foo +-- +STMT: RenameStmt +== 162 +-- ok +ALTER TABLE constraint_rename_test ADD CONSTRAINT con2 CHECK (b > 0) NO INHERIT +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: AlterTableStmt +== 163 +ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con2 TO con2foo +-- +STMT: RenameStmt +== 164 +-- ok +ALTER TABLE constraint_rename_test RENAME CONSTRAINT con2foo TO con2bar +-- +STMT: RenameStmt +== 165 +-- ok +ALTER TABLE constraint_rename_test ADD CONSTRAINT con3 PRIMARY KEY (a) +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: AlterTableStmt +== 166 +ALTER TABLE constraint_rename_test RENAME CONSTRAINT con3 TO con3foo +-- +STMT: RenameStmt +== 167 +-- ok +DROP TABLE constraint_rename_test2 +-- +TABLE: name="constraint_rename_test2" schema="" table="constraint_rename_test2" ctx=DDL +STMT: DropStmt +== 168 +DROP TABLE constraint_rename_test +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: DropStmt +== 169 +ALTER TABLE IF EXISTS constraint_not_exist RENAME CONSTRAINT con3 TO con3foo +-- +STMT: RenameStmt +== 170 +-- ok +ALTER TABLE IF EXISTS constraint_rename_test ADD CONSTRAINT con4 UNIQUE (a) +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: AlterTableStmt +== 171 +-- renaming constraints with cache reset of target relation +CREATE TABLE constraint_rename_cache (a int, + CONSTRAINT chk_a CHECK (a > 0), + PRIMARY KEY (a)) +-- +TABLE: name="constraint_rename_cache" schema="" table="constraint_rename_cache" ctx=DDL +STMT: CreateStmt +== 172 +ALTER TABLE constraint_rename_cache + RENAME CONSTRAINT chk_a TO chk_a_new +-- +STMT: RenameStmt +== 173 +ALTER TABLE constraint_rename_cache + RENAME CONSTRAINT constraint_rename_cache_pkey TO constraint_rename_pkey_new +-- +STMT: RenameStmt +== 174 +CREATE TABLE like_constraint_rename_cache + (LIKE constraint_rename_cache INCLUDING ALL) +-- +TABLE: name="like_constraint_rename_cache" schema="" table="like_constraint_rename_cache" ctx=DDL +STMT: CreateStmt +== 175 +DROP TABLE constraint_rename_cache +-- +TABLE: name="constraint_rename_cache" schema="" table="constraint_rename_cache" ctx=DDL +STMT: DropStmt +== 176 +DROP TABLE like_constraint_rename_cache +-- +TABLE: name="like_constraint_rename_cache" schema="" table="like_constraint_rename_cache" ctx=DDL +STMT: DropStmt +== 177 +-- FOREIGN KEY CONSTRAINT adding TEST + +CREATE TABLE attmp2 (a int primary key) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DDL +STMT: CreateStmt +== 178 +CREATE TABLE attmp3 (a int, b int) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: CreateStmt +== 179 +CREATE TABLE attmp4 (a int, b int, unique(a,b)) +-- +TABLE: name="attmp4" schema="" table="attmp4" ctx=DDL +STMT: CreateStmt +== 180 +CREATE TABLE attmp5 (a int, b int) +-- +TABLE: name="attmp5" schema="" table="attmp5" ctx=DDL +STMT: CreateStmt +== 181 +-- Insert rows into attmp2 (pktable) +INSERT INTO attmp2 values (1) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 182 +INSERT INTO attmp2 values (2) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 183 +INSERT INTO attmp2 values (3) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 184 +INSERT INTO attmp2 values (4) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 185 +-- Insert rows into attmp3 +INSERT INTO attmp3 values (1,10) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +INSERT INTO attmp3 values (1,20) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +INSERT INTO attmp3 values (5,50) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +-- Try (and fail) to add constraint due to invalid source columns +ALTER TABLE attmp3 add constraint attmpconstr foreign key(c) references attmp2 match full +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 189 +-- Try (and fail) to add constraint due to invalid destination columns explicitly given +ALTER TABLE attmp3 add constraint attmpconstr foreign key(a) references attmp2(b) match full +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 190 +-- Try (and fail) to add constraint due to invalid data +ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 191 +-- Delete failing row +DELETE FROM attmp3 where a=5 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: DeleteStmt +== 192 +-- Try (and succeed) +ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 193 +ALTER TABLE attmp3 drop constraint attmpconstr +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 194 +INSERT INTO attmp3 values (5,50) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 195 +-- Try NOT VALID and then VALIDATE CONSTRAINT, but fails. Delete failure then re-validate +ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full NOT VALID +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 196 +ALTER TABLE attmp3 validate constraint attmpconstr +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 197 +-- Delete failing row +DELETE FROM attmp3 where a=5 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: DeleteStmt +== 198 +-- Try (and succeed) and repeat to show it works on already valid constraint +ALTER TABLE attmp3 validate constraint attmpconstr +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 199 +ALTER TABLE attmp3 validate constraint attmpconstr +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 200 +-- Try a non-verified CHECK constraint +ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 201 +-- fail +ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10) NOT VALID +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 202 +-- succeeds +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 203 +-- fails +DELETE FROM attmp3 WHERE NOT b > 10 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: DeleteStmt +== 204 +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 205 +-- succeeds +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 206 +-- succeeds + +-- Test inherited NOT VALID CHECK constraints +select * from attmp3 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=Select +STMT: SelectStmt +== 207 +CREATE TABLE attmp6 () INHERITS (attmp3) +-- +TABLE: name="attmp6" schema="" table="attmp6" ctx=DDL +STMT: CreateStmt +== 208 +CREATE TABLE attmp7 () INHERITS (attmp3) +-- +TABLE: name="attmp7" schema="" table="attmp7" ctx=DDL +STMT: CreateStmt +== 209 +INSERT INTO attmp6 VALUES (6, 30), (7, 16) +-- +TABLE: name="attmp6" schema="" table="attmp6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 210 +ALTER TABLE attmp3 ADD CONSTRAINT b_le_20 CHECK (b <= 20) NOT VALID +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 211 +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 212 +-- fails +DELETE FROM attmp6 WHERE b > 20 +-- +TABLE: name="attmp6" schema="" table="attmp6" ctx=DML +STMT: DeleteStmt +== 213 +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 214 +-- succeeds + +-- An already validated constraint must not be revalidated +CREATE FUNCTION boo(int) RETURNS int IMMUTABLE STRICT LANGUAGE plpgsql AS $$ BEGIN RAISE NOTICE 'boo: %', $1; RETURN $1; END; $$ +-- +FUNCTION: name="boo" function="boo" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 215 +INSERT INTO attmp7 VALUES (8, 18) +-- +TABLE: name="attmp7" schema="" table="attmp7" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +ALTER TABLE attmp7 ADD CONSTRAINT identity CHECK (b = boo(b)) +-- +TABLE: name="attmp7" schema="" table="attmp7" ctx=DDL +STMT: AlterTableStmt +== 217 +ALTER TABLE attmp3 ADD CONSTRAINT IDENTITY check (b = boo(b)) NOT VALID +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 218 +ALTER TABLE attmp3 VALIDATE CONSTRAINT identity +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +== 219 +-- A NO INHERIT constraint should not be looked for in children during VALIDATE CONSTRAINT +create table parent_noinh_convalid (a int) +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +STMT: CreateStmt +== 220 +create table child_noinh_convalid () inherits (parent_noinh_convalid) +-- +TABLE: name="child_noinh_convalid" schema="" table="child_noinh_convalid" ctx=DDL +STMT: CreateStmt +== 221 +insert into parent_noinh_convalid values (1) +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 222 +insert into child_noinh_convalid values (1) +-- +TABLE: name="child_noinh_convalid" schema="" table="child_noinh_convalid" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 223 +alter table parent_noinh_convalid add constraint check_a_is_2 check (a = 2) no inherit not valid +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +STMT: AlterTableStmt +== 224 +-- fail, because of the row in parent +alter table parent_noinh_convalid validate constraint check_a_is_2 +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +STMT: AlterTableStmt +== 225 +delete from only parent_noinh_convalid +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DML +STMT: DeleteStmt +== 226 +-- ok (parent itself contains no violating rows) +alter table parent_noinh_convalid validate constraint check_a_is_2 +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +STMT: AlterTableStmt +== 227 +select convalidated from pg_constraint where conrelid = 'parent_noinh_convalid'::regclass and conname = 'check_a_is_2' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 228 +-- cleanup +drop table parent_noinh_convalid, child_noinh_convalid +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +TABLE: name="child_noinh_convalid" schema="" table="child_noinh_convalid" ctx=DDL +STMT: DropStmt +== 229 +-- Try (and fail) to create constraint from attmp5(a) to attmp4(a) - unique constraint on +-- attmp4 is a,b + +ALTER TABLE attmp5 add constraint attmpconstr foreign key(a) references attmp4(a) match full +-- +TABLE: name="attmp5" schema="" table="attmp5" ctx=DDL +STMT: AlterTableStmt +== 230 +DROP TABLE attmp7 +-- +TABLE: name="attmp7" schema="" table="attmp7" ctx=DDL +STMT: DropStmt +== 231 +DROP TABLE attmp6 +-- +TABLE: name="attmp6" schema="" table="attmp6" ctx=DDL +STMT: DropStmt +== 232 +DROP TABLE attmp5 +-- +TABLE: name="attmp5" schema="" table="attmp5" ctx=DDL +STMT: DropStmt +== 233 +DROP TABLE attmp4 +-- +TABLE: name="attmp4" schema="" table="attmp4" ctx=DDL +STMT: DropStmt +== 234 +DROP TABLE attmp3 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: DropStmt +== 235 +DROP TABLE attmp2 +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DDL +STMT: DropStmt +== 236 +-- NOT VALID with plan invalidation -- ensure we don't use a constraint for +-- exclusion until validated +set constraint_exclusion TO 'partition' +-- +STMT: VariableSetStmt +== 237 +create table nv_parent (d date, check (false) no inherit not valid) +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=DDL +STMT: CreateStmt +== 238 +-- not valid constraint added at creation time should automatically become valid + +create table nv_child_2010 () inherits (nv_parent) +-- +TABLE: name="nv_child_2010" schema="" table="nv_child_2010" ctx=DDL +STMT: CreateStmt +== 239 +create table nv_child_2011 () inherits (nv_parent) +-- +TABLE: name="nv_child_2011" schema="" table="nv_child_2011" ctx=DDL +STMT: CreateStmt +== 240 +alter table nv_child_2010 add check (d between '2010-01-01'::date and '2010-12-31'::date) not valid +-- +TABLE: name="nv_child_2010" schema="" table="nv_child_2010" ctx=DDL +STMT: AlterTableStmt +== 241 +alter table nv_child_2011 add check (d between '2011-01-01'::date and '2011-12-31'::date) not valid +-- +TABLE: name="nv_child_2011" schema="" table="nv_child_2011" ctx=DDL +STMT: AlterTableStmt +== 242 +explain (costs off) select * from nv_parent where d between '2011-08-01' and '2011-08-31' +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=Select +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +== 243 +create table nv_child_2009 (check (d between '2009-01-01'::date and '2009-12-31'::date)) inherits (nv_parent) +-- +TABLE: name="nv_child_2009" schema="" table="nv_child_2009" ctx=DDL +STMT: CreateStmt +== 244 +explain (costs off) select * from nv_parent where d between '2011-08-01'::date and '2011-08-31'::date +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=Select +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +== 245 +explain (costs off) select * from nv_parent where d between '2009-08-01'::date and '2009-08-31'::date +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=Select +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +== 246 +-- after validation, the constraint should be used +alter table nv_child_2011 VALIDATE CONSTRAINT nv_child_2011_d_check +-- +TABLE: name="nv_child_2011" schema="" table="nv_child_2011" ctx=DDL +STMT: AlterTableStmt +== 247 +explain (costs off) select * from nv_parent where d between '2009-08-01'::date and '2009-08-31'::date +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=Select +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +== 248 +-- add an inherited NOT VALID constraint +alter table nv_parent add check (d between '2001-01-01'::date and '2099-12-31'::date) not valid +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=DDL +STMT: AlterTableStmt +== 249 +-- we leave nv_parent and children around to help test pg_dump logic + +-- Foreign key adding test with mixed types + +-- Note: these tables are TEMP to avoid name conflicts when this test +-- is run in parallel with foreign_key.sql. + +CREATE TEMP TABLE PKTABLE (ptest1 int PRIMARY KEY) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 250 +INSERT INTO PKTABLE VALUES(42) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 251 +CREATE TEMP TABLE FKTABLE (ftest1 inet) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 252 +-- This next should fail, because int=inet does not exist +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 253 +-- This should also fail for the same reason, but here we +-- give the column name +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 254 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 255 +-- This should succeed, even though they are different types, +-- because int=int8 exists and is a member of the integer opfamily +CREATE TEMP TABLE FKTABLE (ftest1 int8) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 256 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 257 +-- Check it actually works +INSERT INTO FKTABLE VALUES(42) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 258 +-- should succeed +INSERT INTO FKTABLE VALUES(43) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 259 +-- should fail +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 260 +-- This should fail, because we'd have to cast numeric to int which is +-- not an implicit coercion (or use numeric=numeric, but that's not part +-- of the integer opfamily) +CREATE TEMP TABLE FKTABLE (ftest1 numeric) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 261 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 262 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 263 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 264 +-- On the other hand, this should work because int implicitly promotes to +-- numeric, and we allow promotion on the FK side +CREATE TEMP TABLE PKTABLE (ptest1 numeric PRIMARY KEY) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 265 +INSERT INTO PKTABLE VALUES(42) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 266 +CREATE TEMP TABLE FKTABLE (ftest1 int) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 267 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 268 +-- Check it actually works +INSERT INTO FKTABLE VALUES(42) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +-- should succeed +INSERT INTO FKTABLE VALUES(43) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 270 +-- should fail +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 271 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 272 +CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet, + PRIMARY KEY(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 273 +-- This should fail, because we just chose really odd types +CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 274 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 275 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 276 +-- Again, so should this... +CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 277 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) + references pktable(ptest1, ptest2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 278 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 279 +-- This fails because we mixed up the column ordering +CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 inet) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 280 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) + references pktable(ptest2, ptest1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 281 +-- As does this... +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest2, ftest1) + references pktable(ptest1, ptest2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 282 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 283 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 284 +-- Test that ALTER CONSTRAINT updates trigger deferrability properly + +CREATE TEMP TABLE PKTABLE (ptest1 int primary key) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 285 +CREATE TEMP TABLE FKTABLE (ftest1 int) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 286 +ALTER TABLE FKTABLE ADD CONSTRAINT fknd FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 287 +ALTER TABLE FKTABLE ADD CONSTRAINT fkdd FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 288 +ALTER TABLE FKTABLE ADD CONSTRAINT fkdi FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY IMMEDIATE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 289 +ALTER TABLE FKTABLE ADD CONSTRAINT fknd2 FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 290 +ALTER TABLE FKTABLE ALTER CONSTRAINT fknd2 NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 291 +ALTER TABLE FKTABLE ADD CONSTRAINT fkdd2 FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 292 +ALTER TABLE FKTABLE ALTER CONSTRAINT fkdd2 DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 293 +ALTER TABLE FKTABLE ADD CONSTRAINT fkdi2 FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 294 +ALTER TABLE FKTABLE ALTER CONSTRAINT fkdi2 DEFERRABLE INITIALLY IMMEDIATE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 295 +SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred +FROM pg_trigger JOIN pg_constraint con ON con.oid = tgconstraint +WHERE tgrelid = 'pktable'::regclass +ORDER BY 1,2,3 +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 296 +SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred +FROM pg_trigger JOIN pg_constraint con ON con.oid = tgconstraint +WHERE tgrelid = 'fktable'::regclass +ORDER BY 1,2,3 +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 297 +-- temp tables should go away by themselves, need not drop them. + +-- test check constraint adding + +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 298 +-- add a check constraint +alter table atacc1 add constraint atacc_test1 check (test>3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 299 +-- should fail +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 300 +-- should succeed +insert into atacc1 (test) values (4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 301 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 302 +-- let's do one where the check fails when added +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 303 +-- insert a soon to be failing row +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 304 +-- add a check constraint (fails) +alter table atacc1 add constraint atacc_test1 check (test>3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 305 +insert into atacc1 (test) values (4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 306 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 307 +-- let's do one where the check fails because the column doesn't exist +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 308 +-- add a check constraint (fails) +alter table atacc1 add constraint atacc_test1 check (test1>3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 309 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 310 +-- something a little more complicated +create table atacc1 ( test int, test2 int, test3 int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 311 +-- add a check constraint (fails) +alter table atacc1 add constraint atacc_test1 check (test+test23), test2 int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 316 +alter table atacc1 add check (test2>test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 317 +-- should fail for $2 +insert into atacc1 (test2, test) values (3, 4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 318 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 319 +-- inheritance related tests +create table atacc1 (test int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 320 +create table atacc2 (test2 int) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +== 321 +create table atacc3 (test3 int) inherits (atacc1, atacc2) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: CreateStmt +== 322 +alter table atacc2 add constraint foo check (test2>0) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +== 323 +-- fail and then succeed on atacc2 +insert into atacc2 (test2) values (-3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 324 +insert into atacc2 (test2) values (3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 325 +-- fail and then succeed on atacc3 +insert into atacc3 (test2) values (-3) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 326 +insert into atacc3 (test2) values (3) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 327 +drop table atacc3 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: DropStmt +== 328 +drop table atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: DropStmt +== 329 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 330 +-- same things with one created with INHERIT +create table atacc1 (test int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 331 +create table atacc2 (test2 int) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +== 332 +create table atacc3 (test3 int) inherits (atacc1, atacc2) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: CreateStmt +== 333 +alter table atacc3 no inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 334 +-- fail +alter table atacc3 no inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 335 +-- make sure it really isn't a child +insert into atacc3 (test2) values (3) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 336 +select test2 from atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=Select +STMT: SelectStmt +== 337 +-- fail due to missing constraint +alter table atacc2 add constraint foo check (test2>0) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +== 338 +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 339 +-- fail due to missing column +alter table atacc3 rename test2 to testx +-- +STMT: RenameStmt +== 340 +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 341 +-- fail due to mismatched data type +alter table atacc3 add test2 bool +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 342 +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 343 +alter table atacc3 drop test2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 344 +-- succeed +alter table atacc3 add test2 int +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 345 +update atacc3 set test2 = 4 where test2 is null +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DML +STMT: UpdateStmt +== 346 +alter table atacc3 add constraint foo check (test2>0) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 347 +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 348 +-- fail due to duplicates and circular inheritance +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +== 349 +alter table atacc2 inherit atacc3 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +== 350 +alter table atacc2 inherit atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +== 351 +-- test that we really are a child now (should see 4 not 3 and cascade should go through) +select test2 from atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=Select +STMT: SelectStmt +== 352 +drop table atacc2 cascade +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: DropStmt +== 353 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 354 +-- adding only to a parent is allowed as of 9.2 + +create table atacc1 (test int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 355 +create table atacc2 (test2 int) inherits (atacc1) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +== 356 +-- ok: +alter table atacc1 add constraint foo check (test>0) no inherit +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 357 +-- check constraint is not there on child +insert into atacc2 (test) values (-3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 358 +-- check constraint is there on parent +insert into atacc1 (test) values (-3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 359 +insert into atacc1 (test) values (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 360 +-- fail, violating row: +alter table atacc2 add constraint foo check (test>0) no inherit +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +== 361 +drop table atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: DropStmt +== 362 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 363 +-- test unique constraint adding + +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 364 +-- add a unique constraint +alter table atacc1 add constraint atacc_test1 unique (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 365 +-- insert first value +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 366 +-- should fail +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 367 +-- should succeed +insert into atacc1 (test) values (4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 368 +-- try to create duplicates via alter table using - should fail +alter table atacc1 alter column test type integer using 0 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 369 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 370 +-- let's do one where the unique constraint fails when added +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 371 +-- insert soon to be failing rows +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 372 +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 373 +-- add a unique constraint (fails) +alter table atacc1 add constraint atacc_test1 unique (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 374 +insert into atacc1 (test) values (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 375 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 376 +-- let's do one where the unique constraint fails +-- because the column doesn't exist +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 377 +-- add a unique constraint (fails) +alter table atacc1 add constraint atacc_test1 unique (test1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 378 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 379 +-- something a little more complicated +create table atacc1 ( test int, test2 int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 380 +-- add a unique constraint +alter table atacc1 add constraint atacc_test1 unique (test, test2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 381 +-- insert initial value +insert into atacc1 (test,test2) values (4,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 382 +-- should fail +insert into atacc1 (test,test2) values (4,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 383 +-- should all succeed +insert into atacc1 (test,test2) values (4,5) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 384 +insert into atacc1 (test,test2) values (5,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 385 +insert into atacc1 (test,test2) values (5,5) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 386 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 387 +-- lets do some naming tests +create table atacc1 (test int, test2 int, unique(test)) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 388 +alter table atacc1 add unique (test2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 389 +-- should fail for @@ second one @@ +insert into atacc1 (test2, test) values (3, 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 390 +insert into atacc1 (test2, test) values (2, 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 391 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 392 +-- test primary key constraint adding + +create table atacc1 ( id serial, test int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 393 +-- add a primary key constraint +alter table atacc1 add constraint atacc_test1 primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 394 +-- insert first value +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 395 +-- should fail +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 396 +-- should succeed +insert into atacc1 (test) values (4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 397 +-- inserting NULL should fail +insert into atacc1 (test) values(NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 398 +-- try adding a second primary key (should fail) +alter table atacc1 add constraint atacc_oid1 primary key(id) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 399 +-- drop first primary key constraint +alter table atacc1 drop constraint atacc_test1 restrict +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 400 +-- try adding a primary key on oid (should succeed) +alter table atacc1 add constraint atacc_oid1 primary key(id) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 401 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 402 +-- let's do one where the primary key constraint fails when added +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 403 +-- insert soon to be failing rows +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 404 +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 405 +-- add a primary key (fails) +alter table atacc1 add constraint atacc_test1 primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 406 +insert into atacc1 (test) values (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 407 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 408 +-- let's do another one where the primary key constraint fails when added +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 409 +-- insert soon to be failing row +insert into atacc1 (test) values (NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 410 +-- add a primary key (fails) +alter table atacc1 add constraint atacc_test1 primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 411 +insert into atacc1 (test) values (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 412 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 413 +-- let's do one where the primary key constraint fails +-- because the column doesn't exist +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 414 +-- add a primary key constraint (fails) +alter table atacc1 add constraint atacc_test1 primary key (test1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 415 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 416 +-- adding a new column as primary key to a non-empty table. +-- should fail unless the column has a non-null default value. +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 417 +insert into atacc1 (test) values (0) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 418 +-- add a primary key column without a default (fails). +alter table atacc1 add column test2 int primary key +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 419 +-- now add a primary key column with a default (succeeds). +alter table atacc1 add column test2 int default 0 primary key +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 420 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 421 +-- this combination used to have order-of-execution problems (bug #15580) +create table atacc1 (a int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 422 +insert into atacc1 values(1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 423 +alter table atacc1 + add column b float8 not null default random(), + add primary key(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 424 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 425 +-- additionally, we've seen issues with foreign key validation not being +-- properly delayed until after a table rewrite. Check that works ok. +create table atacc1 (a int primary key) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 426 +alter table atacc1 add constraint atacc1_fkey foreign key (a) references atacc1 (a) not valid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 427 +alter table atacc1 validate constraint atacc1_fkey, alter a type bigint +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 428 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 429 +-- we've also seen issues with check constraints being validated at the wrong +-- time when there's a pending table rewrite. +create table atacc1 (a bigint, b int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 430 +insert into atacc1 values(1,1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 431 +alter table atacc1 add constraint atacc1_chk check(b = 1) not valid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 432 +alter table atacc1 validate constraint atacc1_chk, alter a type int +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 433 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 434 +-- same as above, but ensure the constraint violation is detected +create table atacc1 (a bigint, b int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 435 +insert into atacc1 values(1,2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 436 +alter table atacc1 add constraint atacc1_chk check(b = 1) not valid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 437 +alter table atacc1 validate constraint atacc1_chk, alter a type int +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 438 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 439 +-- something a little more complicated +create table atacc1 ( test int, test2 int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 440 +-- add a primary key constraint +alter table atacc1 add constraint atacc_test1 primary key (test, test2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 441 +-- try adding a second primary key - should fail +alter table atacc1 add constraint atacc_test2 primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 442 +-- insert initial value +insert into atacc1 (test,test2) values (4,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 443 +-- should fail +insert into atacc1 (test,test2) values (4,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 444 +insert into atacc1 (test,test2) values (NULL,3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 445 +insert into atacc1 (test,test2) values (3, NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 446 +insert into atacc1 (test,test2) values (NULL,NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 447 +-- should all succeed +insert into atacc1 (test,test2) values (4,5) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 448 +insert into atacc1 (test,test2) values (5,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 449 +insert into atacc1 (test,test2) values (5,5) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 450 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 451 +-- lets do some naming tests +create table atacc1 (test int, test2 int, primary key(test)) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 452 +-- only first should succeed +insert into atacc1 (test2, test) values (3, 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 453 +insert into atacc1 (test2, test) values (2, 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 454 +insert into atacc1 (test2, test) values (1, NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 455 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 456 +-- alter table / alter column [set/drop] not null tests +-- try altering system catalogs, should fail +alter table pg_class alter column relname drop not null +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DDL +STMT: AlterTableStmt +== 457 +alter table pg_class alter relname set not null +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DDL +STMT: AlterTableStmt +== 458 +-- try altering non-existent table, should fail +alter table non_existent alter column bar set not null +-- +TABLE: name="non_existent" schema="" table="non_existent" ctx=DDL +STMT: AlterTableStmt +== 459 +alter table non_existent alter column bar drop not null +-- +TABLE: name="non_existent" schema="" table="non_existent" ctx=DDL +STMT: AlterTableStmt +== 460 +-- test setting columns to null and not null and vice versa +-- test checking for null values and primary key +create table atacc1 (test int not null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 461 +alter table atacc1 add constraint "atacc1_pkey" primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 462 +alter table atacc1 alter column test drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 463 +alter table atacc1 drop constraint "atacc1_pkey" +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 464 +alter table atacc1 alter column test drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 465 +insert into atacc1 values (null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 466 +alter table atacc1 alter test set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 467 +delete from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +== 468 +alter table atacc1 alter test set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 469 +-- try altering a non-existent column, should fail +alter table atacc1 alter bar set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 470 +alter table atacc1 alter bar drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 471 +-- try creating a view and altering that, should fail +create view myview as select * from atacc1 +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 472 +alter table myview alter column test drop not null +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +STMT: AlterTableStmt +== 473 +alter table myview alter column test set not null +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +STMT: AlterTableStmt +== 474 +drop view myview +-- +STMT: DropStmt +== 475 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 476 +-- set not null verified by constraints +create table atacc1 (test_a int, test_b int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 477 +insert into atacc1 values (null, 1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 478 +-- constraint not cover all values, should fail +alter table atacc1 add constraint atacc1_constr_or check(test_a is not null or test_b < 10) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 479 +alter table atacc1 alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 480 +alter table atacc1 drop constraint atacc1_constr_or +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 481 +-- not valid constraint, should fail +alter table atacc1 add constraint atacc1_constr_invalid check(test_a is not null) not valid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 482 +alter table atacc1 alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 483 +alter table atacc1 drop constraint atacc1_constr_invalid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 484 +-- with valid constraint +update atacc1 set test_a = 1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +== 485 +alter table atacc1 add constraint atacc1_constr_a_valid check(test_a is not null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 486 +alter table atacc1 alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 487 +delete from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +== 488 +insert into atacc1 values (2, null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 489 +alter table atacc1 alter test_a drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 490 +-- test multiple set not null at same time +-- test_a checked by atacc1_constr_a_valid, test_b should fail by table scan +alter table atacc1 alter test_a set not null, alter test_b set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 491 +-- commands order has no importance +alter table atacc1 alter test_b set not null, alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 492 +-- valid one by table scan, one by check constraints +update atacc1 set test_b = 1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +== 493 +alter table atacc1 alter test_b set not null, alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 494 +alter table atacc1 alter test_a drop not null, alter test_b drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 495 +-- both column has check constraints +alter table atacc1 add constraint atacc1_constr_b_valid check(test_b is not null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 496 +alter table atacc1 alter test_b set not null, alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 497 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 498 +-- test inheritance +create table parent (a int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 499 +create table child (b varchar(255)) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 500 +alter table parent alter a set not null +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 501 +insert into parent values (NULL) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 502 +insert into child (a, b) values (NULL, 'foo') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 503 +alter table parent alter a drop not null +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 504 +insert into parent values (NULL) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 505 +insert into child (a, b) values (NULL, 'foo') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 506 +alter table only parent alter a set not null +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 507 +alter table child alter a set not null +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +== 508 +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +== 509 +alter table only parent alter a set not null +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 510 +insert into parent values (NULL) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 511 +alter table child alter a set not null +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +== 512 +insert into child (a, b) values (NULL, 'foo') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 513 +delete from child +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: DeleteStmt +== 514 +alter table child alter a set not null +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +== 515 +insert into child (a, b) values (NULL, 'foo') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 516 +drop table child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +== 517 +drop table parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +== 518 +-- test setting and removing default values +create table def_test ( + c1 int4 default 5, + c2 text default 'initial_default' +) +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: CreateStmt +== 519 +insert into def_test default values +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DML +STMT: InsertStmt +== 520 +alter table def_test alter column c1 drop default +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +== 521 +insert into def_test default values +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DML +STMT: InsertStmt +== 522 +alter table def_test alter column c2 drop default +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +== 523 +insert into def_test default values +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DML +STMT: InsertStmt +== 524 +alter table def_test alter column c1 set default 10 +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +== 525 +alter table def_test alter column c2 set default 'new_default' +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +== 526 +insert into def_test default values +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DML +STMT: InsertStmt +== 527 +select * from def_test +-- +TABLE: name="def_test" schema="" table="def_test" ctx=Select +STMT: SelectStmt +== 528 +-- set defaults to an incorrect type: this should fail +alter table def_test alter column c1 set default 'wrong_datatype' +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +== 529 +alter table def_test alter column c2 set default 20 +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +== 530 +-- set defaults on a non-existent column: this should fail +alter table def_test alter column c3 set default 30 +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +== 531 +-- set defaults on views: we need to create a view, add a rule +-- to allow insertions into it, and then alter the view to add +-- a default +create view def_view_test as select * from def_test +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +TABLE: name="def_test" schema="" table="def_test" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 532 +create rule def_view_test_ins as + on insert to def_view_test + do instead insert into def_test select new.* +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +STMT: RuleStmt +== 533 +insert into def_view_test default values +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DML +STMT: InsertStmt +== 534 +alter table def_view_test alter column c1 set default 45 +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +STMT: AlterTableStmt +== 535 +insert into def_view_test default values +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DML +STMT: InsertStmt +== 536 +alter table def_view_test alter column c2 set default 'view_default' +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +STMT: AlterTableStmt +== 537 +insert into def_view_test default values +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DML +STMT: InsertStmt +== 538 +select * from def_view_test +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=Select +STMT: SelectStmt +== 539 +drop rule def_view_test_ins on def_view_test +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +STMT: DropStmt +== 540 +drop view def_view_test +-- +STMT: DropStmt +== 541 +drop table def_test +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: DropStmt +== 542 +-- alter table / drop column tests +-- try altering system catalogs, should fail +alter table pg_class drop column relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DDL +STMT: AlterTableStmt +== 543 +-- try altering non-existent table, should fail +alter table nosuchtable drop column bar +-- +TABLE: name="nosuchtable" schema="" table="nosuchtable" ctx=DDL +STMT: AlterTableStmt +== 544 +-- test dropping columns +create table atacc1 (a int4 not null, b int4, c int4 not null, d int4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 545 +insert into atacc1 values (1, 2, 3, 4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 546 +alter table atacc1 drop a +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 547 +alter table atacc1 drop a +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 548 +-- SELECTs +select * from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 549 +select * from atacc1 order by a +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 550 +select * from atacc1 order by "........pg.dropped.1........" +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 551 +select * from atacc1 group by a +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 552 +select * from atacc1 group by "........pg.dropped.1........" +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 553 +select atacc1.* from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 554 +select a from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 555 +select atacc1.a from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 556 +select b,c,d from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 557 +select a,b,c,d from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 558 +select * from atacc1 where a = 1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 559 +select "........pg.dropped.1........" from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 560 +select atacc1."........pg.dropped.1........" from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 561 +select "........pg.dropped.1........",b,c,d from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 562 +select * from atacc1 where "........pg.dropped.1........" = 1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +FILTER: schema="" table="" column="........pg.dropped.1........" +STMT: SelectStmt +== 563 +-- UPDATEs +update atacc1 set a = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +== 564 +update atacc1 set b = 2 where a = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +== 565 +update atacc1 set "........pg.dropped.1........" = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +== 566 +update atacc1 set b = 2 where "........pg.dropped.1........" = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +== 567 +-- INSERTs +insert into atacc1 values (10, 11, 12, 13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 568 +insert into atacc1 values (default, 11, 12, 13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 569 +insert into atacc1 values (11, 12, 13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 570 +insert into atacc1 (a) values (10) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 571 +insert into atacc1 (a) values (default) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 572 +insert into atacc1 (a,b,c,d) values (10,11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 573 +insert into atacc1 (a,b,c,d) values (default,11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 574 +insert into atacc1 (b,c,d) values (11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 575 +insert into atacc1 ("........pg.dropped.1........") values (10) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 576 +insert into atacc1 ("........pg.dropped.1........") values (default) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 577 +insert into atacc1 ("........pg.dropped.1........",b,c,d) values (10,11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 578 +insert into atacc1 ("........pg.dropped.1........",b,c,d) values (default,11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 579 +-- DELETEs +delete from atacc1 where a = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +== 580 +delete from atacc1 where "........pg.dropped.1........" = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +== 581 +delete from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +== 582 +-- try dropping a non-existent column, should fail +alter table atacc1 drop bar +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 583 +-- try removing an oid column, should succeed (as it's nonexistent) +alter table atacc1 SET WITHOUT OIDS +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 584 +-- try adding an oid column, should fail (not supported) +alter table atacc1 SET WITH OIDS +-- +ERROR: syntax error at or near "WITH" +CURSORPOS: 81 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 585 +-- try dropping the xmin column, should fail +alter table atacc1 drop xmin +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 586 +-- try creating a view and altering that, should fail +create view myview as select * from atacc1 +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 587 +select * from myview +-- +TABLE: name="myview" schema="" table="myview" ctx=Select +STMT: SelectStmt +== 588 +alter table myview drop d +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +STMT: AlterTableStmt +== 589 +drop view myview +-- +STMT: DropStmt +== 590 +-- test some commands to make sure they fail on the dropped column +analyze atacc1(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: VacuumStmt +== 591 +analyze atacc1("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: VacuumStmt +== 592 +vacuum analyze atacc1(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: VacuumStmt +== 593 +vacuum analyze atacc1("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: VacuumStmt +== 594 +comment on column atacc1.a is 'testing' +-- +STMT: CommentStmt +== 595 +comment on column atacc1."........pg.dropped.1........" is 'testing' +-- +STMT: CommentStmt +== 596 +alter table atacc1 alter a set storage plain +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 597 +alter table atacc1 alter "........pg.dropped.1........" set storage plain +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 598 +alter table atacc1 alter a set statistics 0 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 599 +alter table atacc1 alter "........pg.dropped.1........" set statistics 0 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 600 +alter table atacc1 alter a set default 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 601 +alter table atacc1 alter "........pg.dropped.1........" set default 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 602 +alter table atacc1 alter a drop default +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 603 +alter table atacc1 alter "........pg.dropped.1........" drop default +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 604 +alter table atacc1 alter a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 605 +alter table atacc1 alter "........pg.dropped.1........" set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 606 +alter table atacc1 alter a drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 607 +alter table atacc1 alter "........pg.dropped.1........" drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 608 +alter table atacc1 rename a to x +-- +STMT: RenameStmt +== 609 +alter table atacc1 rename "........pg.dropped.1........" to x +-- +STMT: RenameStmt +== 610 +alter table atacc1 add primary key(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 611 +alter table atacc1 add primary key("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 612 +alter table atacc1 add unique(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 613 +alter table atacc1 add unique("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 614 +alter table atacc1 add check (a > 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 615 +alter table atacc1 add check ("........pg.dropped.1........" > 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 616 +create table atacc2 (id int4 unique) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +== 617 +alter table atacc1 add foreign key (a) references atacc2(id) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 618 +alter table atacc1 add foreign key ("........pg.dropped.1........") references atacc2(id) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 619 +alter table atacc2 add foreign key (id) references atacc1(a) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +== 620 +alter table atacc2 add foreign key (id) references atacc1("........pg.dropped.1........") +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +== 621 +drop table atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: DropStmt +== 622 +create index "testing_idx" on atacc1(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: IndexStmt +== 623 +create index "testing_idx" on atacc1("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: IndexStmt +== 624 +-- test create as and select into +insert into atacc1 values (21, 22, 23) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 625 +create table attest1 as select * from atacc1 +-- +TABLE: name="attest1" schema="" table="attest1" ctx=DDL +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 626 +select * from attest1 +-- +TABLE: name="attest1" schema="" table="attest1" ctx=Select +STMT: SelectStmt +== 627 +drop table attest1 +-- +TABLE: name="attest1" schema="" table="attest1" ctx=DDL +STMT: DropStmt +== 628 +select * into attest2 from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +TABLE: name="attest2" schema="" table="attest2" ctx=DDL +STMT: SelectStmt +== 629 +select * from attest2 +-- +TABLE: name="attest2" schema="" table="attest2" ctx=Select +STMT: SelectStmt +== 630 +drop table attest2 +-- +TABLE: name="attest2" schema="" table="attest2" ctx=DDL +STMT: DropStmt +== 631 +-- try dropping all columns +alter table atacc1 drop c +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 632 +alter table atacc1 drop d +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 633 +alter table atacc1 drop b +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 634 +select * from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +== 635 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 636 +-- test constraint error reporting in presence of dropped columns +create table atacc1 (id serial primary key, value int check (value < 10)) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 637 +insert into atacc1(value) values (100) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 638 +alter table atacc1 drop column value +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 639 +alter table atacc1 add column value int check (value < 10) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +== 640 +insert into atacc1(value) values (100) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 641 +insert into atacc1(id, value) values (null, 0) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 642 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 643 +-- test inheritance +create table parent (a int, b int, c int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 644 +insert into parent values (1, 2, 3) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 645 +alter table parent drop a +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 646 +create table child (d varchar(255)) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 647 +insert into child values (12, 13, 'testing') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 648 +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 649 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +== 650 +alter table parent drop c +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 651 +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 652 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +== 653 +drop table child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +== 654 +drop table parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +== 655 +-- check error cases for inheritance column merging +create table parent (a float8, b numeric(10,4), c text collate "C") +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 656 +create table child (a float4) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 657 +-- fail +create table child (b decimal(10,7)) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 658 +-- fail +create table child (c text collate "POSIX") inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 659 +-- fail +create table child (a double precision, b decimal(10,4)) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 660 +drop table child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +== 661 +drop table parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +== 662 +-- test copy in/out +create table attest (a int4, b int4, c int4) +-- +TABLE: name="attest" schema="" table="attest" ctx=DDL +STMT: CreateStmt +== 663 +insert into attest values (1,2,3) +-- +TABLE: name="attest" schema="" table="attest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 664 +alter table attest drop a +-- +TABLE: name="attest" schema="" table="attest" ctx=DDL +STMT: AlterTableStmt +== 665 +copy attest to stdout +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +== 666 +copy attest(a) to stdout +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +== 667 +copy attest("........pg.dropped.1........") to stdout +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +== 668 +copy attest from stdin +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +== 669 +select * from attest +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: SelectStmt +== 670 +copy attest from stdin +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +== 671 +select * from attest +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: SelectStmt +== 672 +copy attest(a) from stdin +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +== 673 +select * from attest +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: SelectStmt +== 674 +drop table attest +-- +TABLE: name="attest" schema="" table="attest" ctx=DDL +STMT: DropStmt +== 675 +-- test inheritance + +create table dropColumn (a int, b int, e int) +-- +TABLE: name="dropcolumn" schema="" table="dropcolumn" ctx=DDL +STMT: CreateStmt +== 676 +create table dropColumnChild (c int) inherits (dropColumn) +-- +TABLE: name="dropcolumnchild" schema="" table="dropcolumnchild" ctx=DDL +STMT: CreateStmt +== 677 +create table dropColumnAnother (d int) inherits (dropColumnChild) +-- +TABLE: name="dropcolumnanother" schema="" table="dropcolumnanother" ctx=DDL +STMT: CreateStmt +== 678 +-- these two should fail +alter table dropColumnchild drop column a +-- +TABLE: name="dropcolumnchild" schema="" table="dropcolumnchild" ctx=DDL +STMT: AlterTableStmt +== 679 +alter table only dropColumnChild drop column b +-- +TABLE: name="dropcolumnchild" schema="" table="dropcolumnchild" ctx=DDL +STMT: AlterTableStmt +== 680 +-- these three should work +alter table only dropColumn drop column e +-- +TABLE: name="dropcolumn" schema="" table="dropcolumn" ctx=DDL +STMT: AlterTableStmt +== 681 +alter table dropColumnChild drop column c +-- +TABLE: name="dropcolumnchild" schema="" table="dropcolumnchild" ctx=DDL +STMT: AlterTableStmt +== 682 +alter table dropColumn drop column a +-- +TABLE: name="dropcolumn" schema="" table="dropcolumn" ctx=DDL +STMT: AlterTableStmt +== 683 +create table renameColumn (a int) +-- +TABLE: name="renamecolumn" schema="" table="renamecolumn" ctx=DDL +STMT: CreateStmt +== 684 +create table renameColumnChild (b int) inherits (renameColumn) +-- +TABLE: name="renamecolumnchild" schema="" table="renamecolumnchild" ctx=DDL +STMT: CreateStmt +== 685 +create table renameColumnAnother (c int) inherits (renameColumnChild) +-- +TABLE: name="renamecolumnanother" schema="" table="renamecolumnanother" ctx=DDL +STMT: CreateStmt +== 686 +-- these three should fail +alter table renameColumnChild rename column a to d +-- +STMT: RenameStmt +== 687 +alter table only renameColumnChild rename column a to d +-- +STMT: RenameStmt +== 688 +alter table only renameColumn rename column a to d +-- +STMT: RenameStmt +== 689 +-- these should work +alter table renameColumn rename column a to d +-- +STMT: RenameStmt +== 690 +alter table renameColumnChild rename column b to a +-- +STMT: RenameStmt +== 691 +-- these should work +alter table if exists doesnt_exist_tab rename column a to d +-- +STMT: RenameStmt +== 692 +alter table if exists doesnt_exist_tab rename column b to a +-- +STMT: RenameStmt +== 693 +-- this should work +alter table renameColumn add column w int +-- +TABLE: name="renamecolumn" schema="" table="renamecolumn" ctx=DDL +STMT: AlterTableStmt +== 694 +-- this should fail +alter table only renameColumn add column x int +-- +TABLE: name="renamecolumn" schema="" table="renamecolumn" ctx=DDL +STMT: AlterTableStmt +== 695 +-- Test corner cases in dropping of inherited columns + +create table p1 (f1 int, f2 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 696 +create table c1 (f1 int not null) inherits(p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 697 +-- should be rejected since c1.f1 is inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +== 698 +-- should work +alter table p1 drop column f1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 699 +-- c1.f1 is still there, but no longer inherited +select f1 from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=Select +STMT: SelectStmt +== 700 +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +== 701 +select f1 from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=Select +STMT: SelectStmt +== 702 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 703 +create table p1 (f1 int, f2 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 704 +create table c1 () inherits(p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 705 +-- should be rejected since c1.f1 is inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +== 706 +alter table p1 drop column f1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 707 +-- c1.f1 is dropped now, since there is no local definition for it +select f1 from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=Select +STMT: SelectStmt +== 708 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 709 +create table p1 (f1 int, f2 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 710 +create table c1 () inherits(p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 711 +-- should be rejected since c1.f1 is inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +== 712 +alter table only p1 drop column f1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 713 +-- c1.f1 is NOT dropped, but must now be considered non-inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +== 714 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 715 +create table p1 (f1 int, f2 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 716 +create table c1 (f1 int not null) inherits(p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 717 +-- should be rejected since c1.f1 is inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +== 718 +alter table only p1 drop column f1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 719 +-- c1.f1 is still there, but no longer inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +== 720 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 721 +create table p1(id int, name text) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 722 +create table p2(id2 int, name text, height int) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +== 723 +create table c1(age int) inherits(p1,p2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 724 +create table gc1() inherits (c1) +-- +TABLE: name="gc1" schema="" table="gc1" ctx=DDL +STMT: CreateStmt +== 725 +select relname, attname, attinhcount, attislocal +from pg_class join pg_attribute on (pg_class.oid = pg_attribute.attrelid) +where relname in ('p1','p2','c1','gc1') and attnum > 0 and not attisdropped +order by relname, attnum +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attisdropped" +STMT: SelectStmt +== 726 +-- should work +alter table only p1 drop column name +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 727 +-- should work. Now c1.name is local and inhcount is 0. +alter table p2 drop column name +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +== 728 +-- should be rejected since its inherited +alter table gc1 drop column name +-- +TABLE: name="gc1" schema="" table="gc1" ctx=DDL +STMT: AlterTableStmt +== 729 +-- should work, and drop gc1.name along +alter table c1 drop column name +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +== 730 +-- should fail: column does not exist +alter table gc1 drop column name +-- +TABLE: name="gc1" schema="" table="gc1" ctx=DDL +STMT: AlterTableStmt +== 731 +-- should work and drop the attribute in all tables +alter table p2 drop column height +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +== 732 +-- IF EXISTS test +create table dropColumnExists () +-- +TABLE: name="dropcolumnexists" schema="" table="dropcolumnexists" ctx=DDL +STMT: CreateStmt +== 733 +alter table dropColumnExists drop column non_existing +-- +TABLE: name="dropcolumnexists" schema="" table="dropcolumnexists" ctx=DDL +STMT: AlterTableStmt +== 734 +--fail +alter table dropColumnExists drop column if exists non_existing +-- +TABLE: name="dropcolumnexists" schema="" table="dropcolumnexists" ctx=DDL +STMT: AlterTableStmt +== 735 +--succeed + +select relname, attname, attinhcount, attislocal +from pg_class join pg_attribute on (pg_class.oid = pg_attribute.attrelid) +where relname in ('p1','p2','c1','gc1') and attnum > 0 and not attisdropped +order by relname, attnum +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attisdropped" +STMT: SelectStmt +== 736 +drop table p1, p2 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: DropStmt +== 737 +-- test attinhcount tracking with merged columns + +create table depth0() +-- +TABLE: name="depth0" schema="" table="depth0" ctx=DDL +STMT: CreateStmt +== 738 +create table depth1(c text) inherits (depth0) +-- +TABLE: name="depth1" schema="" table="depth1" ctx=DDL +STMT: CreateStmt +== 739 +create table depth2() inherits (depth1) +-- +TABLE: name="depth2" schema="" table="depth2" ctx=DDL +STMT: CreateStmt +== 740 +alter table depth0 add c text +-- +TABLE: name="depth0" schema="" table="depth0" ctx=DDL +STMT: AlterTableStmt +== 741 +select attrelid::regclass, attname, attinhcount, attislocal +from pg_attribute +where attnum > 0 and attrelid::regclass in ('depth0', 'depth1', 'depth2') +order by attrelid::regclass::text, attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +== 742 +-- test renumbering of child-table columns in inherited operations + +create table p1 (f1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 743 +create table c1 (f2 text, f3 int) inherits (p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 744 +alter table p1 add column a1 int check (a1 > 0) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 745 +alter table p1 add column f2 text +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 746 +insert into p1 values (1,2,'abc') +-- +TABLE: name="p1" schema="" table="p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 747 +insert into c1 values(11,'xyz',33,0) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 748 +-- should fail +insert into c1 values(11,'xyz',33,22) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 749 +select * from p1 +-- +TABLE: name="p1" schema="" table="p1" ctx=Select +STMT: SelectStmt +== 750 +update p1 set a1 = a1 + 1, f2 = upper(f2) +-- +TABLE: name="p1" schema="" table="p1" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: UpdateStmt +== 751 +select * from p1 +-- +TABLE: name="p1" schema="" table="p1" ctx=Select +STMT: SelectStmt +== 752 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 753 +-- test that operations with a dropped column do not try to reference +-- its datatype + +create domain mytype as text +-- +STMT: CreateDomainStmt +== 754 +create temp table foo (f1 text, f2 mytype, f3 text) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 755 +insert into foo values('bb','cc','dd') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 756 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 757 +drop domain mytype cascade +-- +STMT: DropStmt +== 758 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 759 +insert into foo values('qq','rr') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 760 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 761 +update foo set f3 = 'zz' +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: UpdateStmt +== 762 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 763 +select f3,max(f1) from foo group by f3 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 764 +-- Simple tests for alter table column type +alter table foo alter f1 TYPE integer +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: AlterTableStmt +== 765 +-- fails +alter table foo alter f1 TYPE varchar(10) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: AlterTableStmt +== 766 +create table anothertab (atcol1 serial8, atcol2 boolean, + constraint anothertab_chk check (atcol1 <= 3)) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: CreateStmt +== 767 +insert into anothertab (atcol1, atcol2) values (default, true) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 768 +insert into anothertab (atcol1, atcol2) values (default, false) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 769 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +== 770 +alter table anothertab alter column atcol1 type boolean +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 771 +-- fails +alter table anothertab alter column atcol1 type boolean using atcol1::int +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 772 +-- fails +alter table anothertab alter column atcol1 type integer +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 773 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +== 774 +insert into anothertab (atcol1, atcol2) values (45, null) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 775 +-- fails +insert into anothertab (atcol1, atcol2) values (default, null) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 776 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +== 777 +alter table anothertab alter column atcol2 type text + using case when atcol2 is true then 'IT WAS TRUE' + when atcol2 is false then 'IT WAS FALSE' + else 'IT WAS NULL!' end +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 778 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +== 779 +alter table anothertab alter column atcol1 type boolean + using case when atcol1 % 2 = 0 then true else false end +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 780 +-- fails +alter table anothertab alter column atcol1 drop default +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 781 +alter table anothertab alter column atcol1 type boolean + using case when atcol1 % 2 = 0 then true else false end +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 782 +-- fails +alter table anothertab drop constraint anothertab_chk +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 783 +alter table anothertab drop constraint anothertab_chk +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 784 +-- fails +alter table anothertab drop constraint IF EXISTS anothertab_chk +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 785 +-- succeeds + +alter table anothertab alter column atcol1 type boolean + using case when atcol1 % 2 = 0 then true else false end +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 786 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +== 787 +drop table anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: DropStmt +== 788 +-- Test index handling in alter table column type (cf. bugs #15835, #15865) +create table anothertab(f1 int primary key, f2 int unique, + f3 int, f4 int, f5 int) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: CreateStmt +== 789 +alter table anothertab + add exclude using btree (f3 with =) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 790 +alter table anothertab + add exclude using btree (f4 with =) where (f4 is not null) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 791 +alter table anothertab + add exclude using btree (f4 with =) where (f5 > 0) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 792 +alter table anothertab + add unique(f1,f4) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 793 +create index on anothertab(f2,f3) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: IndexStmt +== 794 +create unique index on anothertab(f4) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: IndexStmt +== 795 +alter table anothertab alter column f1 type bigint +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 796 +alter table anothertab + alter column f2 type bigint, + alter column f3 type bigint, + alter column f4 type bigint +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 797 +alter table anothertab alter column f5 type bigint +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +== 798 +drop table anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: DropStmt +== 799 +-- test that USING expressions are parsed before column alter type / drop steps +create table another (f1 int, f2 text, f3 text) +-- +TABLE: name="another" schema="" table="another" ctx=DDL +STMT: CreateStmt +== 800 +insert into another values(1, 'one', 'uno') +-- +TABLE: name="another" schema="" table="another" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 801 +insert into another values(2, 'two', 'due') +-- +TABLE: name="another" schema="" table="another" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 802 +insert into another values(3, 'three', 'tre') +-- +TABLE: name="another" schema="" table="another" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 803 +select * from another +-- +TABLE: name="another" schema="" table="another" ctx=Select +STMT: SelectStmt +== 804 +alter table another + alter f1 type text using f2 || ' and ' || f3 || ' more', + alter f2 type bigint using f1 * 10, + drop column f3 +-- +TABLE: name="another" schema="" table="another" ctx=DDL +STMT: AlterTableStmt +== 805 +select * from another +-- +TABLE: name="another" schema="" table="another" ctx=Select +STMT: SelectStmt +== 806 +drop table another +-- +TABLE: name="another" schema="" table="another" ctx=DDL +STMT: DropStmt +== 807 +-- Create an index that skips WAL, then perform a SET DATA TYPE that skips +-- rewriting the index. +begin +-- +STMT: TransactionStmt +== 808 +create table skip_wal_skip_rewrite_index (c varchar(10) primary key) +-- +TABLE: name="skip_wal_skip_rewrite_index" schema="" table="skip_wal_skip_rewrite_index" ctx=DDL +STMT: CreateStmt +== 809 +alter table skip_wal_skip_rewrite_index alter c type varchar(20) +-- +TABLE: name="skip_wal_skip_rewrite_index" schema="" table="skip_wal_skip_rewrite_index" ctx=DDL +STMT: AlterTableStmt +== 810 +commit +-- +STMT: TransactionStmt +== 811 +-- We disallow changing table's row type if it's used for storage +create table at_tab1 (a int, b text) +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: CreateStmt +== 812 +create table at_tab2 (x int, y at_tab1) +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: CreateStmt +== 813 +alter table at_tab1 alter column b type varchar +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: AlterTableStmt +== 814 +-- fails +drop table at_tab2 +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: DropStmt +== 815 +-- Use of row type in an expression is defended differently +create table at_tab2 (x int, y text, check((x,y)::at_tab1 = (1,'42')::at_tab1)) +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: CreateStmt +== 816 +alter table at_tab1 alter column b type varchar +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: AlterTableStmt +== 817 +-- allowed, but ... +insert into at_tab2 values(1,'42') +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 818 +-- ... this will fail +drop table at_tab1, at_tab2 +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: DropStmt +== 819 +-- Check it for a partitioned table, too +create table at_tab1 (a int, b text) partition by list(a) +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: CreateStmt +== 820 +create table at_tab2 (x int, y at_tab1) +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: CreateStmt +== 821 +alter table at_tab1 alter column b type varchar +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: AlterTableStmt +== 822 +-- fails +drop table at_tab1, at_tab2 +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: DropStmt +== 823 +-- Alter column type that's part of a partitioned index +create table at_partitioned (a int, b text) partition by range (a) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: CreateStmt +== 824 +create table at_part_1 partition of at_partitioned for values from (0) to (1000) +-- +TABLE: name="at_part_1" schema="" table="at_part_1" ctx=DDL +STMT: CreateStmt +== 825 +insert into at_partitioned values (512, '0.123') +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 826 +create table at_part_2 (b text, a int) +-- +TABLE: name="at_part_2" schema="" table="at_part_2" ctx=DDL +STMT: CreateStmt +== 827 +insert into at_part_2 values ('1.234', 1024) +-- +TABLE: name="at_part_2" schema="" table="at_part_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 828 +create index on at_partitioned (b) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: IndexStmt +== 829 +create index on at_partitioned (a) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: IndexStmt +== 830 +alter table at_partitioned attach partition at_part_2 for values from (1000) to (2000) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: AlterTableStmt +== 831 +alter table at_partitioned alter column b type numeric using b::numeric +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: AlterTableStmt +== 832 +drop table at_partitioned +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: DropStmt +== 833 +-- Alter column type when no table rewrite is required +-- Also check that comments are preserved +create table at_partitioned(id int, name varchar(64), unique (id, name)) + partition by hash(id) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: CreateStmt +== 834 +comment on constraint at_partitioned_id_name_key on at_partitioned is 'parent constraint' +-- +STMT: CommentStmt +== 835 +comment on index at_partitioned_id_name_key is 'parent index' +-- +STMT: CommentStmt +== 836 +create table at_partitioned_0 partition of at_partitioned + for values with (modulus 2, remainder 0) +-- +TABLE: name="at_partitioned_0" schema="" table="at_partitioned_0" ctx=DDL +STMT: CreateStmt +== 837 +comment on constraint at_partitioned_0_id_name_key on at_partitioned_0 is 'child 0 constraint' +-- +STMT: CommentStmt +== 838 +comment on index at_partitioned_0_id_name_key is 'child 0 index' +-- +STMT: CommentStmt +== 839 +create table at_partitioned_1 partition of at_partitioned + for values with (modulus 2, remainder 1) +-- +TABLE: name="at_partitioned_1" schema="" table="at_partitioned_1" ctx=DDL +STMT: CreateStmt +== 840 +comment on constraint at_partitioned_1_id_name_key on at_partitioned_1 is 'child 1 constraint' +-- +STMT: CommentStmt +== 841 +comment on index at_partitioned_1_id_name_key is 'child 1 index' +-- +STMT: CommentStmt +== 842 +insert into at_partitioned values(1, 'foo') +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 843 +insert into at_partitioned values(3, 'bar') +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 844 +create temp table old_oids as + select relname, oid as oldoid, relfilenode as oldfilenode + from pg_class where relname like 'at_partitioned%' +-- +TABLE: name="old_oids" schema="" table="old_oids" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 845 +select relname, + c.oid = oldoid as orig_oid, + case relfilenode + when 0 then 'none' + when c.oid then 'own' + when oldfilenode then 'orig' + else 'OTHER' + end as storage, + obj_description(c.oid, 'pg_class') as desc + from pg_class c left join old_oids using (relname) + where relname like 'at_partitioned%' + order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="old_oids" schema="" table="old_oids" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 846 +select conname, obj_description(oid, 'pg_constraint') as desc + from pg_constraint where conname like 'at_partitioned%' + order by conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 847 +alter table at_partitioned alter column name type varchar(127) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: AlterTableStmt +== 848 +select relname, + c.oid = oldoid as orig_oid, + case relfilenode + when 0 then 'none' + when c.oid then 'own' + when oldfilenode then 'orig' + else 'OTHER' + end as storage, + obj_description(c.oid, 'pg_class') as desc + from pg_class c left join old_oids using (relname) + where relname like 'at_partitioned%' + order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="old_oids" schema="" table="old_oids" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 849 +select conname, obj_description(oid, 'pg_constraint') as desc + from pg_constraint where conname like 'at_partitioned%' + order by conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 850 +-- Don't remove this DROP, it exposes bug #15672 +drop table at_partitioned +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: DropStmt +== 851 +-- disallow recursive containment of row types +create temp table recur1 (f1 int) +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: CreateStmt +== 852 +alter table recur1 add column f2 recur1 +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +== 853 +-- fails +alter table recur1 add column f2 recur1[] +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +== 854 +-- fails +create domain array_of_recur1 as recur1[] +-- +STMT: CreateDomainStmt +== 855 +alter table recur1 add column f2 array_of_recur1 +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +== 856 +-- fails +create temp table recur2 (f1 int, f2 recur1) +-- +TABLE: name="recur2" schema="" table="recur2" ctx=DDL +STMT: CreateStmt +== 857 +alter table recur1 add column f2 recur2 +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +== 858 +-- fails +alter table recur1 add column f2 int +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +== 859 +alter table recur1 alter column f2 type recur2 +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +== 860 +-- fails + +-- SET STORAGE may need to add a TOAST table +create table test_storage (a text, c text storage plain) +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: CreateStmt +== 861 +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 862 +alter table test_storage alter a set storage plain +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: AlterTableStmt +== 863 +-- rewrite table to remove its TOAST table; need a non-constant column default +alter table test_storage add b int default random()::int +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: AlterTableStmt +== 864 +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 865 +alter table test_storage alter a set storage default +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: AlterTableStmt +== 866 +-- re-add TOAST table +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 867 +-- check STORAGE correctness +create table test_storage_failed (a text, b int storage extended) +-- +TABLE: name="test_storage_failed" schema="" table="test_storage_failed" ctx=DDL +STMT: CreateStmt +== 868 +-- test that SET STORAGE propagates to index correctly +create index test_storage_idx on test_storage (b, a) +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: IndexStmt +== 869 +alter table test_storage alter column a set storage external +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: AlterTableStmt +== 870 +-- ALTER COLUMN TYPE with a check constraint and a child table (bug #13779) +CREATE TABLE test_inh_check (a float check (a > 10.2), b float) +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: CreateStmt +== 871 +CREATE TABLE test_inh_check_child() INHERITS(test_inh_check) +-- +TABLE: name="test_inh_check_child" schema="" table="test_inh_check_child" ctx=DDL +STMT: CreateStmt +== 872 +select relname, conname, coninhcount, conislocal, connoinherit + from pg_constraint c, pg_class r + where relname like 'test_inh_check%' and c.conrelid = r.oid + order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "r"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="c" column="conrelid" +FILTER: schema="" table="r" column="oid" +STMT: SelectStmt +== 873 +ALTER TABLE test_inh_check ALTER COLUMN a TYPE numeric +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: AlterTableStmt +== 874 +select relname, conname, coninhcount, conislocal, connoinherit + from pg_constraint c, pg_class r + where relname like 'test_inh_check%' and c.conrelid = r.oid + order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "r"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="c" column="conrelid" +FILTER: schema="" table="r" column="oid" +STMT: SelectStmt +== 875 +-- also try noinherit, local, and local+inherited cases +ALTER TABLE test_inh_check ADD CONSTRAINT bnoinherit CHECK (b > 100) NO INHERIT +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: AlterTableStmt +== 876 +ALTER TABLE test_inh_check_child ADD CONSTRAINT blocal CHECK (b < 1000) +-- +TABLE: name="test_inh_check_child" schema="" table="test_inh_check_child" ctx=DDL +STMT: AlterTableStmt +== 877 +ALTER TABLE test_inh_check_child ADD CONSTRAINT bmerged CHECK (b > 1) +-- +TABLE: name="test_inh_check_child" schema="" table="test_inh_check_child" ctx=DDL +STMT: AlterTableStmt +== 878 +ALTER TABLE test_inh_check ADD CONSTRAINT bmerged CHECK (b > 1) +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: AlterTableStmt +== 879 +select relname, conname, coninhcount, conislocal, connoinherit + from pg_constraint c, pg_class r + where relname like 'test_inh_check%' and c.conrelid = r.oid + order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "r"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="c" column="conrelid" +FILTER: schema="" table="r" column="oid" +STMT: SelectStmt +== 880 +ALTER TABLE test_inh_check ALTER COLUMN b TYPE numeric +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: AlterTableStmt +== 881 +select relname, conname, coninhcount, conislocal, connoinherit + from pg_constraint c, pg_class r + where relname like 'test_inh_check%' and c.conrelid = r.oid + order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "r"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="c" column="conrelid" +FILTER: schema="" table="r" column="oid" +STMT: SelectStmt +== 882 +-- ALTER COLUMN TYPE with different schema in children +-- Bug at https://postgr.es/m/20170102225618.GA10071@telsasoft.com +CREATE TABLE test_type_diff (f1 int) +-- +TABLE: name="test_type_diff" schema="" table="test_type_diff" ctx=DDL +STMT: CreateStmt +== 883 +CREATE TABLE test_type_diff_c (extra smallint) INHERITS (test_type_diff) +-- +TABLE: name="test_type_diff_c" schema="" table="test_type_diff_c" ctx=DDL +STMT: CreateStmt +== 884 +ALTER TABLE test_type_diff ADD COLUMN f2 int +-- +TABLE: name="test_type_diff" schema="" table="test_type_diff" ctx=DDL +STMT: AlterTableStmt +== 885 +INSERT INTO test_type_diff_c VALUES (1, 2, 3) +-- +TABLE: name="test_type_diff_c" schema="" table="test_type_diff_c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 886 +ALTER TABLE test_type_diff ALTER COLUMN f2 TYPE bigint USING f2::bigint +-- +TABLE: name="test_type_diff" schema="" table="test_type_diff" ctx=DDL +STMT: AlterTableStmt +== 887 +CREATE TABLE test_type_diff2 (int_two int2, int_four int4, int_eight int8) +-- +TABLE: name="test_type_diff2" schema="" table="test_type_diff2" ctx=DDL +STMT: CreateStmt +== 888 +CREATE TABLE test_type_diff2_c1 (int_four int4, int_eight int8, int_two int2) +-- +TABLE: name="test_type_diff2_c1" schema="" table="test_type_diff2_c1" ctx=DDL +STMT: CreateStmt +== 889 +CREATE TABLE test_type_diff2_c2 (int_eight int8, int_two int2, int_four int4) +-- +TABLE: name="test_type_diff2_c2" schema="" table="test_type_diff2_c2" ctx=DDL +STMT: CreateStmt +== 890 +CREATE TABLE test_type_diff2_c3 (int_two int2, int_four int4, int_eight int8) +-- +TABLE: name="test_type_diff2_c3" schema="" table="test_type_diff2_c3" ctx=DDL +STMT: CreateStmt +== 891 +ALTER TABLE test_type_diff2_c1 INHERIT test_type_diff2 +-- +TABLE: name="test_type_diff2_c1" schema="" table="test_type_diff2_c1" ctx=DDL +STMT: AlterTableStmt +== 892 +ALTER TABLE test_type_diff2_c2 INHERIT test_type_diff2 +-- +TABLE: name="test_type_diff2_c2" schema="" table="test_type_diff2_c2" ctx=DDL +STMT: AlterTableStmt +== 893 +ALTER TABLE test_type_diff2_c3 INHERIT test_type_diff2 +-- +TABLE: name="test_type_diff2_c3" schema="" table="test_type_diff2_c3" ctx=DDL +STMT: AlterTableStmt +== 894 +INSERT INTO test_type_diff2_c1 VALUES (1, 2, 3) +-- +TABLE: name="test_type_diff2_c1" schema="" table="test_type_diff2_c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 895 +INSERT INTO test_type_diff2_c2 VALUES (4, 5, 6) +-- +TABLE: name="test_type_diff2_c2" schema="" table="test_type_diff2_c2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 896 +INSERT INTO test_type_diff2_c3 VALUES (7, 8, 9) +-- +TABLE: name="test_type_diff2_c3" schema="" table="test_type_diff2_c3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 897 +ALTER TABLE test_type_diff2 ALTER COLUMN int_four TYPE int8 USING int_four::int8 +-- +TABLE: name="test_type_diff2" schema="" table="test_type_diff2" ctx=DDL +STMT: AlterTableStmt +== 898 +-- whole-row references are disallowed +ALTER TABLE test_type_diff2 ALTER COLUMN int_four TYPE int4 USING (pg_column_size(test_type_diff2)) +-- +TABLE: name="test_type_diff2" schema="" table="test_type_diff2" ctx=DDL +STMT: AlterTableStmt +== 899 +-- check for rollback of ANALYZE corrupting table property flags (bug #11638) +CREATE TABLE check_fk_presence_1 (id int PRIMARY KEY, t text) +-- +TABLE: name="check_fk_presence_1" schema="" table="check_fk_presence_1" ctx=DDL +STMT: CreateStmt +== 900 +CREATE TABLE check_fk_presence_2 (id int REFERENCES check_fk_presence_1, t text) +-- +TABLE: name="check_fk_presence_2" schema="" table="check_fk_presence_2" ctx=DDL +STMT: CreateStmt +== 901 +BEGIN +-- +STMT: TransactionStmt +== 902 +ALTER TABLE check_fk_presence_2 DROP CONSTRAINT check_fk_presence_2_id_fkey +-- +TABLE: name="check_fk_presence_2" schema="" table="check_fk_presence_2" ctx=DDL +STMT: AlterTableStmt +== 903 +ANALYZE check_fk_presence_2 +-- +TABLE: name="check_fk_presence_2" schema="" table="check_fk_presence_2" ctx=DDL +STMT: VacuumStmt +== 904 +ROLLBACK +-- +STMT: TransactionStmt +== 905 +DROP TABLE check_fk_presence_1, check_fk_presence_2 +-- +TABLE: name="check_fk_presence_1" schema="" table="check_fk_presence_1" ctx=DDL +TABLE: name="check_fk_presence_2" schema="" table="check_fk_presence_2" ctx=DDL +STMT: DropStmt +== 906 +-- check column addition within a view (bug #14876) +create table at_base_table(id int, stuff text) +-- +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=DDL +STMT: CreateStmt +== 907 +insert into at_base_table values (23, 'skidoo') +-- +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 908 +create view at_view_1 as select * from at_base_table bt +-- +TABLE: name="at_view_1" schema="" table="at_view_1" ctx=DDL +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=Select +ALIAS: "bt"="at_base_table" +STMT: ViewStmt +STMT: SelectStmt +== 909 +create view at_view_2 as select *, to_json(v1) as j from at_view_1 v1 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=DDL +TABLE: name="at_view_1" schema="" table="at_view_1" ctx=Select +ALIAS: "v1"="at_view_1" +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 910 +explain (verbose, costs off) select * from at_view_2 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 911 +select * from at_view_2 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=Select +STMT: SelectStmt +== 912 +create or replace view at_view_1 as select *, 2+2 as more from at_base_table bt +-- +TABLE: name="at_view_1" schema="" table="at_view_1" ctx=DDL +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=Select +ALIAS: "bt"="at_base_table" +STMT: ViewStmt +STMT: SelectStmt +== 913 +explain (verbose, costs off) select * from at_view_2 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 914 +select * from at_view_2 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=Select +STMT: SelectStmt +== 915 +drop view at_view_2 +-- +STMT: DropStmt +== 916 +drop view at_view_1 +-- +STMT: DropStmt +== 917 +drop table at_base_table +-- +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=DDL +STMT: DropStmt +== 918 +-- related case (bug #17811) +begin +-- +STMT: TransactionStmt +== 919 +create temp table t1 as select * from int8_tbl +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 920 +create temp view v1 as select 1::int8 as q1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 921 +create temp view v2 as select * from v1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="v1" schema="" table="v1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 922 +create or replace temp view v1 with (security_barrier = true) + as select * from t1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 923 +create temp table log (q1 int8, q2 int8) +-- +TABLE: name="log" schema="" table="log" ctx=DDL +STMT: CreateStmt +== 924 +create rule v1_upd_rule as on update to v1 + do also insert into log values (new.*) +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: RuleStmt +== 925 +update v2 set q1 = q1 + 1 where q1 = 123 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: UpdateStmt +== 926 +select * from t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 927 +select * from log +-- +TABLE: name="log" schema="" table="log" ctx=Select +STMT: SelectStmt +== 928 +rollback +-- +STMT: TransactionStmt +== 929 +-- check adding a column not itself requiring a rewrite, together with +-- a column requiring a default (bug #16038) + +-- ensure that rewrites aren't silently optimized away, removing the +-- value of the test +CREATE FUNCTION check_ddl_rewrite(p_tablename regclass, p_ddl text) +RETURNS boolean +LANGUAGE plpgsql AS $$ +DECLARE + v_relfilenode oid; +BEGIN + v_relfilenode := relfilenode FROM pg_class WHERE oid = p_tablename; + + EXECUTE p_ddl; + + RETURN v_relfilenode <> (SELECT relfilenode FROM pg_class WHERE oid = p_tablename); +END; +$$ +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 930 +CREATE TABLE rewrite_test(col text) +-- +TABLE: name="rewrite_test" schema="" table="rewrite_test" ctx=DDL +STMT: CreateStmt +== 931 +INSERT INTO rewrite_test VALUES ('something') +-- +TABLE: name="rewrite_test" schema="" table="rewrite_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 932 +INSERT INTO rewrite_test VALUES (NULL) +-- +TABLE: name="rewrite_test" schema="" table="rewrite_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 933 +-- empty[12] don't need rewrite, but notempty[12]_rewrite will force one +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN empty1 text, + ADD COLUMN notempty1_rewrite serial; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 934 +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN notempty2_rewrite serial, + ADD COLUMN empty2 text; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 935 +-- also check that fast defaults cause no problem, first without rewrite +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN empty3 text, + ADD COLUMN notempty3_norewrite int default 42; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 936 +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN notempty4_norewrite int default 42, + ADD COLUMN empty4 text; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 937 +-- then with rewrite +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN empty5 text, + ADD COLUMN notempty5_norewrite int default 42, + ADD COLUMN notempty5_rewrite serial; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 938 +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN notempty6_rewrite serial, + ADD COLUMN empty6 text, + ADD COLUMN notempty6_norewrite int default 42; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 939 +-- cleanup +DROP FUNCTION check_ddl_rewrite(regclass, text) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=DDL +STMT: DropStmt +== 940 +DROP TABLE rewrite_test +-- +TABLE: name="rewrite_test" schema="" table="rewrite_test" ctx=DDL +STMT: DropStmt +== 941 +|-- +-- lock levels +|-- +drop type lockmodes +-- +STMT: DropStmt +== 942 +create type lockmodes as enum ( + 'SIReadLock' +,'AccessShareLock' +,'RowShareLock' +,'RowExclusiveLock' +,'ShareUpdateExclusiveLock' +,'ShareLock' +,'ShareRowExclusiveLock' +,'ExclusiveLock' +,'AccessExclusiveLock' +) +-- +STMT: CreateEnumStmt +== 943 +drop view my_locks +-- +STMT: DropStmt +== 944 +create or replace view my_locks as +select case when c.relname like 'pg_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode +from pg_locks l join pg_class c on l.relation = c.oid +where virtualtransaction = ( + select virtualtransaction + from pg_locks + where transactionid = pg_current_xact_id()::xid) +and locktype = 'relation' +and relnamespace != (select oid from pg_namespace where nspname = 'pg_catalog') +and c.relname != 'my_locks' +group by c.relname +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FILTER: schema="" table="" column="virtualtransaction" +FILTER: schema="" table="" column="transactionid" +FILTER: schema="" table="" column="nspname" +STMT: ViewStmt +STMT: SelectStmt +== 945 +create table alterlock (f1 int primary key, f2 text) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: CreateStmt +== 946 +insert into alterlock values (1, 'foo') +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 947 +create table alterlock2 (f3 int primary key, f1 int) +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: CreateStmt +== 948 +insert into alterlock2 values (1, 1) +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 949 +begin +-- +STMT: TransactionStmt +== 950 +alter table alterlock alter column f2 set statistics 150 +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 951 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 952 +rollback +-- +STMT: TransactionStmt +== 953 +begin +-- +STMT: TransactionStmt +== 954 +alter table alterlock cluster on alterlock_pkey +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 955 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 956 +commit +-- +STMT: TransactionStmt +== 957 +begin +-- +STMT: TransactionStmt +== 958 +alter table alterlock set without cluster +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 959 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 960 +commit +-- +STMT: TransactionStmt +== 961 +begin +-- +STMT: TransactionStmt +== 962 +alter table alterlock set (fillfactor = 100) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 963 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 964 +commit +-- +STMT: TransactionStmt +== 965 +begin +-- +STMT: TransactionStmt +== 966 +alter table alterlock reset (fillfactor) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 967 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 968 +commit +-- +STMT: TransactionStmt +== 969 +begin +-- +STMT: TransactionStmt +== 970 +alter table alterlock set (toast.autovacuum_enabled = off) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 971 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 972 +commit +-- +STMT: TransactionStmt +== 973 +begin +-- +STMT: TransactionStmt +== 974 +alter table alterlock set (autovacuum_enabled = off) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 975 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 976 +commit +-- +STMT: TransactionStmt +== 977 +begin +-- +STMT: TransactionStmt +== 978 +alter table alterlock alter column f2 set (n_distinct = 1) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 979 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 980 +rollback +-- +STMT: TransactionStmt +== 981 +-- test that mixing options with different lock levels works as expected +begin +-- +STMT: TransactionStmt +== 982 +alter table alterlock set (autovacuum_enabled = off, fillfactor = 80) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 983 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 984 +commit +-- +STMT: TransactionStmt +== 985 +begin +-- +STMT: TransactionStmt +== 986 +alter table alterlock alter column f2 set storage extended +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 987 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 988 +rollback +-- +STMT: TransactionStmt +== 989 +begin +-- +STMT: TransactionStmt +== 990 +alter table alterlock alter column f2 set default 'x' +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +== 991 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 992 +rollback +-- +STMT: TransactionStmt +== 993 +begin +-- +STMT: TransactionStmt +== 994 +create trigger ttdummy + before delete or update on alterlock + for each row + execute procedure + ttdummy (1, 1) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: CreateTrigStmt +== 995 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 996 +rollback +-- +STMT: TransactionStmt +== 997 +begin +-- +STMT: TransactionStmt +== 998 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 999 +alter table alterlock2 add foreign key (f1) references alterlock (f1) +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: AlterTableStmt +== 1000 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 1001 +rollback +-- +STMT: TransactionStmt +== 1002 +begin +-- +STMT: TransactionStmt +== 1003 +alter table alterlock2 +add constraint alterlock2nv foreign key (f1) references alterlock (f1) NOT VALID +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: AlterTableStmt +== 1004 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 1005 +commit +-- +STMT: TransactionStmt +== 1006 +begin +-- +STMT: TransactionStmt +== 1007 +alter table alterlock2 validate constraint alterlock2nv +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: AlterTableStmt +== 1008 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 1009 +rollback +-- +STMT: TransactionStmt +== 1010 +create or replace view my_locks as +select case when c.relname like 'pg_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode +from pg_locks l join pg_class c on l.relation = c.oid +where virtualtransaction = ( + select virtualtransaction + from pg_locks + where transactionid = pg_current_xact_id()::xid) +and locktype = 'relation' +and relnamespace != (select oid from pg_namespace where nspname = 'pg_catalog') +and c.relname = 'my_locks' +group by c.relname +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FILTER: schema="" table="" column="virtualtransaction" +FILTER: schema="" table="" column="transactionid" +FILTER: schema="" table="" column="nspname" +STMT: ViewStmt +STMT: SelectStmt +== 1011 +-- raise exception +alter table my_locks set (autovacuum_enabled = false) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +== 1012 +alter view my_locks set (autovacuum_enabled = false) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +== 1013 +alter table my_locks reset (autovacuum_enabled) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +== 1014 +alter view my_locks reset (autovacuum_enabled) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +== 1015 +begin +-- +STMT: TransactionStmt +== 1016 +alter view my_locks set (security_barrier=off) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +== 1017 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 1018 +alter view my_locks reset (security_barrier) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +== 1019 +rollback +-- +STMT: TransactionStmt +== 1020 +-- this test intentionally applies the ALTER TABLE command against a view, but +-- uses a view option so we expect this to succeed. This form of SQL is +-- accepted for historical reasons, as shown in the docs for ALTER VIEW +begin +-- +STMT: TransactionStmt +== 1021 +alter table my_locks set (security_barrier=off) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +== 1022 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +== 1023 +alter table my_locks reset (security_barrier) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +== 1024 +rollback +-- +STMT: TransactionStmt +== 1025 +-- cleanup +drop table alterlock2 +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: DropStmt +== 1026 +drop table alterlock +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: DropStmt +== 1027 +drop view my_locks +-- +STMT: DropStmt +== 1028 +drop type lockmodes +-- +STMT: DropStmt +== 1029 +|-- +-- alter function +|-- +create function test_strict(text) returns text as + 'select coalesce($1, ''got passed a null'');' + language sql returns null on null input +-- +FUNCTION: name="test_strict" function="test_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1030 +select test_strict(NULL) +-- +FUNCTION: name="test_strict" function="test_strict" schema="" ctx=Call +STMT: SelectStmt +== 1031 +alter function test_strict(text) called on null input +-- +STMT: AlterFunctionStmt +== 1032 +select test_strict(NULL) +-- +FUNCTION: name="test_strict" function="test_strict" schema="" ctx=Call +STMT: SelectStmt +== 1033 +create function non_strict(text) returns text as + 'select coalesce($1, ''got passed a null'');' + language sql called on null input +-- +FUNCTION: name="non_strict" function="non_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1034 +select non_strict(NULL) +-- +FUNCTION: name="non_strict" function="non_strict" schema="" ctx=Call +STMT: SelectStmt +== 1035 +alter function non_strict(text) returns null on null input +-- +STMT: AlterFunctionStmt +== 1036 +select non_strict(NULL) +-- +FUNCTION: name="non_strict" function="non_strict" schema="" ctx=Call +STMT: SelectStmt +== 1037 +|-- +-- alter object set schema +|-- + +create schema alter1 +-- +STMT: CreateSchemaStmt +== 1038 +create schema alter2 +-- +STMT: CreateSchemaStmt +== 1039 +create table alter1.t1(f1 serial primary key, f2 int check (f2 > 0)) +-- +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=DDL +STMT: CreateStmt +== 1040 +create view alter1.v1 as select * from alter1.t1 +-- +TABLE: name="alter1.v1" schema="alter1" table="v1" ctx=DDL +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 1041 +create function alter1.plus1(int) returns int as 'select $1+1' language sql +-- +FUNCTION: name="alter1.plus1" function="plus1" schema="alter1" ctx=DDL +STMT: CreateFunctionStmt +== 1042 +create domain alter1.posint integer check (value > 0) +-- +STMT: CreateDomainStmt +== 1043 +create type alter1.ctype as (f1 int, f2 text) +-- +STMT: CompositeTypeStmt +== 1044 +create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql +as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2' +-- +FUNCTION: name="alter1.same" function="same" schema="alter1" ctx=DDL +STMT: CreateFunctionStmt +== 1045 +create operator alter1.=(procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype) +-- +STMT: DefineStmt +== 1046 +create operator class alter1.ctype_hash_ops default for type alter1.ctype using hash as + operator 1 alter1.=(alter1.ctype, alter1.ctype) +-- +STMT: CreateOpClassStmt +== 1047 +create conversion alter1.latin1_to_utf8 for 'latin1' to 'utf8' from iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 1048 +create text search parser alter1.prs(start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +== 1049 +create text search configuration alter1.cfg(parser = alter1.prs) +-- +STMT: DefineStmt +== 1050 +create text search template alter1.tmpl(init = dsimple_init, lexize = dsimple_lexize) +-- +STMT: DefineStmt +== 1051 +create text search dictionary alter1.dict(template = alter1.tmpl) +-- +STMT: DefineStmt +== 1052 +insert into alter1.t1(f2) values(11) +-- +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1053 +insert into alter1.t1(f2) values(12) +-- +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1054 +alter table alter1.t1 set schema alter1 +-- +STMT: AlterObjectSchemaStmt +== 1055 +-- no-op, same schema +alter table alter1.t1 set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1056 +alter table alter1.v1 set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1057 +alter function alter1.plus1(int) set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1058 +alter domain alter1.posint set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1059 +alter operator class alter1.ctype_hash_ops using hash set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1060 +alter operator family alter1.ctype_hash_ops using hash set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1061 +alter operator alter1.=(alter1.ctype, alter1.ctype) set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1062 +alter function alter1.same(alter1.ctype, alter1.ctype) set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1063 +alter type alter1.ctype set schema alter1 +-- +STMT: AlterObjectSchemaStmt +== 1064 +-- no-op, same schema +alter type alter1.ctype set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1065 +alter conversion alter1.latin1_to_utf8 set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1066 +alter text search parser alter1.prs set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1067 +alter text search configuration alter1.cfg set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1068 +alter text search template alter1.tmpl set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1069 +alter text search dictionary alter1.dict set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1070 +-- this should succeed because nothing is left in alter1 +drop schema alter1 +-- +STMT: DropStmt +== 1071 +insert into alter2.t1(f2) values(13) +-- +TABLE: name="alter2.t1" schema="alter2" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1072 +insert into alter2.t1(f2) values(14) +-- +TABLE: name="alter2.t1" schema="alter2" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1073 +select * from alter2.t1 +-- +TABLE: name="alter2.t1" schema="alter2" table="t1" ctx=Select +STMT: SelectStmt +== 1074 +select * from alter2.v1 +-- +TABLE: name="alter2.v1" schema="alter2" table="v1" ctx=Select +STMT: SelectStmt +== 1075 +select alter2.plus1(41) +-- +FUNCTION: name="alter2.plus1" function="plus1" schema="alter2" ctx=Call +STMT: SelectStmt +== 1076 +-- clean up +drop schema alter2 cascade +-- +STMT: DropStmt +== 1077 +|-- +-- composite types +|-- + +CREATE TYPE test_type AS (a int) +-- +STMT: CompositeTypeStmt +== 1078 +ALTER TYPE nosuchtype ADD ATTRIBUTE b text +-- +TABLE: name="nosuchtype" schema="" table="nosuchtype" ctx=DDL +STMT: AlterTableStmt +== 1079 +-- fails + +ALTER TYPE test_type ADD ATTRIBUTE b text +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +== 1080 +ALTER TYPE test_type ADD ATTRIBUTE b text +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +== 1081 +-- fails + +ALTER TYPE test_type ALTER ATTRIBUTE b SET DATA TYPE varchar +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +== 1082 +ALTER TYPE test_type ALTER ATTRIBUTE b SET DATA TYPE integer +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +== 1083 +ALTER TYPE test_type DROP ATTRIBUTE b +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +== 1084 +ALTER TYPE test_type DROP ATTRIBUTE c +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +== 1085 +-- fails + +ALTER TYPE test_type DROP ATTRIBUTE IF EXISTS c +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +== 1086 +ALTER TYPE test_type DROP ATTRIBUTE a, ADD ATTRIBUTE d boolean +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +== 1087 +ALTER TYPE test_type RENAME ATTRIBUTE a TO aa +-- +STMT: RenameStmt +== 1088 +ALTER TYPE test_type RENAME ATTRIBUTE d TO dd +-- +STMT: RenameStmt +== 1089 +DROP TYPE test_type +-- +STMT: DropStmt +== 1090 +CREATE TYPE test_type1 AS (a int, b text) +-- +STMT: CompositeTypeStmt +== 1091 +CREATE TABLE test_tbl1 (x int, y test_type1) +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: CreateStmt +== 1092 +ALTER TYPE test_type1 ALTER ATTRIBUTE b TYPE varchar +-- +TABLE: name="test_type1" schema="" table="test_type1" ctx=DDL +STMT: AlterTableStmt +== 1093 +-- fails + +DROP TABLE test_tbl1 +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: DropStmt +== 1094 +CREATE TABLE test_tbl1 (x int, y text) +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: CreateStmt +== 1095 +CREATE INDEX test_tbl1_idx ON test_tbl1((row(x,y)::test_type1)) +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: IndexStmt +== 1096 +ALTER TYPE test_type1 ALTER ATTRIBUTE b TYPE varchar +-- +TABLE: name="test_type1" schema="" table="test_type1" ctx=DDL +STMT: AlterTableStmt +== 1097 +-- fails + +DROP TABLE test_tbl1 +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: DropStmt +== 1098 +DROP TYPE test_type1 +-- +STMT: DropStmt +== 1099 +CREATE TYPE test_type2 AS (a int, b text) +-- +STMT: CompositeTypeStmt +== 1100 +CREATE TABLE test_tbl2 OF test_type2 +-- +TABLE: name="test_tbl2" schema="" table="test_tbl2" ctx=DDL +STMT: CreateStmt +== 1101 +CREATE TABLE test_tbl2_subclass () INHERITS (test_tbl2) +-- +TABLE: name="test_tbl2_subclass" schema="" table="test_tbl2_subclass" ctx=DDL +STMT: CreateStmt +== 1102 +ALTER TYPE test_type2 ADD ATTRIBUTE c text +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +== 1103 +-- fails +ALTER TYPE test_type2 ADD ATTRIBUTE c text CASCADE +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +== 1104 +ALTER TYPE test_type2 ALTER ATTRIBUTE b TYPE varchar +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +== 1105 +-- fails +ALTER TYPE test_type2 ALTER ATTRIBUTE b TYPE varchar CASCADE +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +== 1106 +ALTER TYPE test_type2 DROP ATTRIBUTE b +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +== 1107 +-- fails +ALTER TYPE test_type2 DROP ATTRIBUTE b CASCADE +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +== 1108 +ALTER TYPE test_type2 RENAME ATTRIBUTE a TO aa +-- +STMT: RenameStmt +== 1109 +-- fails +ALTER TYPE test_type2 RENAME ATTRIBUTE a TO aa CASCADE +-- +STMT: RenameStmt +== 1110 +DROP TABLE test_tbl2_subclass, test_tbl2 +-- +TABLE: name="test_tbl2_subclass" schema="" table="test_tbl2_subclass" ctx=DDL +TABLE: name="test_tbl2" schema="" table="test_tbl2" ctx=DDL +STMT: DropStmt +== 1111 +DROP TYPE test_type2 +-- +STMT: DropStmt +== 1112 +CREATE TYPE test_typex AS (a int, b text) +-- +STMT: CompositeTypeStmt +== 1113 +CREATE TABLE test_tblx (x int, y test_typex check ((y).a > 0)) +-- +TABLE: name="test_tblx" schema="" table="test_tblx" ctx=DDL +STMT: CreateStmt +== 1114 +ALTER TYPE test_typex DROP ATTRIBUTE a +-- +TABLE: name="test_typex" schema="" table="test_typex" ctx=DDL +STMT: AlterTableStmt +== 1115 +-- fails +ALTER TYPE test_typex DROP ATTRIBUTE a CASCADE +-- +TABLE: name="test_typex" schema="" table="test_typex" ctx=DDL +STMT: AlterTableStmt +== 1116 +DROP TABLE test_tblx +-- +TABLE: name="test_tblx" schema="" table="test_tblx" ctx=DDL +STMT: DropStmt +== 1117 +DROP TYPE test_typex +-- +STMT: DropStmt +== 1118 +-- This test isn't that interesting on its own, but the purpose is to leave +-- behind a table to test pg_upgrade with. The table has a composite type +-- column in it, and the composite type has a dropped attribute. +CREATE TYPE test_type3 AS (a int) +-- +STMT: CompositeTypeStmt +== 1119 +CREATE TABLE test_tbl3 (c) AS SELECT '(1)'::test_type3 +-- +TABLE: name="test_tbl3" schema="" table="test_tbl3" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 1120 +ALTER TYPE test_type3 DROP ATTRIBUTE a, ADD ATTRIBUTE b int +-- +TABLE: name="test_type3" schema="" table="test_type3" ctx=DDL +STMT: AlterTableStmt +== 1121 +CREATE TYPE test_type_empty AS () +-- +STMT: CompositeTypeStmt +== 1122 +DROP TYPE test_type_empty +-- +STMT: DropStmt +== 1123 +|-- +-- typed tables: OF / NOT OF +|-- + +CREATE TYPE tt_t0 AS (z inet, x int, y numeric(8,2)) +-- +STMT: CompositeTypeStmt +== 1124 +ALTER TYPE tt_t0 DROP ATTRIBUTE z +-- +TABLE: name="tt_t0" schema="" table="tt_t0" ctx=DDL +STMT: AlterTableStmt +== 1125 +CREATE TABLE tt0 (x int NOT NULL, y numeric(8,2)) +-- +TABLE: name="tt0" schema="" table="tt0" ctx=DDL +STMT: CreateStmt +== 1126 +-- OK +CREATE TABLE tt1 (x int, y bigint) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: CreateStmt +== 1127 +-- wrong base type +CREATE TABLE tt2 (x int, y numeric(9,2)) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: CreateStmt +== 1128 +-- wrong typmod +CREATE TABLE tt3 (y numeric(8,2), x int) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: CreateStmt +== 1129 +-- wrong column order +CREATE TABLE tt4 (x int) +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: CreateStmt +== 1130 +-- too few columns +CREATE TABLE tt5 (x int, y numeric(8,2), z int) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: CreateStmt +== 1131 +-- too few columns +CREATE TABLE tt6 () INHERITS (tt0) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DDL +STMT: CreateStmt +== 1132 +-- can't have a parent +CREATE TABLE tt7 (x int, q text, y numeric(8,2)) +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: CreateStmt +== 1133 +ALTER TABLE tt7 DROP q +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +== 1134 +-- OK + +ALTER TABLE tt0 OF tt_t0 +-- +TABLE: name="tt0" schema="" table="tt0" ctx=DDL +STMT: AlterTableStmt +== 1135 +ALTER TABLE tt1 OF tt_t0 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: AlterTableStmt +== 1136 +ALTER TABLE tt2 OF tt_t0 +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: AlterTableStmt +== 1137 +ALTER TABLE tt3 OF tt_t0 +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: AlterTableStmt +== 1138 +ALTER TABLE tt4 OF tt_t0 +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: AlterTableStmt +== 1139 +ALTER TABLE tt5 OF tt_t0 +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: AlterTableStmt +== 1140 +ALTER TABLE tt6 OF tt_t0 +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DDL +STMT: AlterTableStmt +== 1141 +ALTER TABLE tt7 OF tt_t0 +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +== 1142 +CREATE TYPE tt_t1 AS (x int, y numeric(8,2)) +-- +STMT: CompositeTypeStmt +== 1143 +ALTER TABLE tt7 OF tt_t1 +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +== 1144 +-- reassign an already-typed table +ALTER TABLE tt7 NOT OF +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +== 1145 +-- make sure we can drop a constraint on the parent but it remains on the child +CREATE TABLE test_drop_constr_parent (c text CHECK (c IS NOT NULL)) +-- +TABLE: name="test_drop_constr_parent" schema="" table="test_drop_constr_parent" ctx=DDL +STMT: CreateStmt +== 1146 +CREATE TABLE test_drop_constr_child () INHERITS (test_drop_constr_parent) +-- +TABLE: name="test_drop_constr_child" schema="" table="test_drop_constr_child" ctx=DDL +STMT: CreateStmt +== 1147 +ALTER TABLE ONLY test_drop_constr_parent DROP CONSTRAINT "test_drop_constr_parent_c_check" +-- +TABLE: name="test_drop_constr_parent" schema="" table="test_drop_constr_parent" ctx=DDL +STMT: AlterTableStmt +== 1148 +-- should fail +INSERT INTO test_drop_constr_child (c) VALUES (NULL) +-- +TABLE: name="test_drop_constr_child" schema="" table="test_drop_constr_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1149 +DROP TABLE test_drop_constr_parent CASCADE +-- +TABLE: name="test_drop_constr_parent" schema="" table="test_drop_constr_parent" ctx=DDL +STMT: DropStmt +== 1150 +|-- +-- IF EXISTS test +|-- +ALTER TABLE IF EXISTS tt8 ADD COLUMN f int +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 1151 +ALTER TABLE IF EXISTS tt8 ADD CONSTRAINT xxx PRIMARY KEY(f) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 1152 +ALTER TABLE IF EXISTS tt8 ADD CHECK (f BETWEEN 0 AND 10) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 1153 +ALTER TABLE IF EXISTS tt8 ALTER COLUMN f SET DEFAULT 0 +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 1154 +ALTER TABLE IF EXISTS tt8 RENAME COLUMN f TO f1 +-- +STMT: RenameStmt +== 1155 +ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2 +-- +STMT: AlterObjectSchemaStmt +== 1156 +CREATE TABLE tt8(a int) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: CreateStmt +== 1157 +CREATE SCHEMA alter2 +-- +STMT: CreateSchemaStmt +== 1158 +ALTER TABLE IF EXISTS tt8 ADD COLUMN f int +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 1159 +ALTER TABLE IF EXISTS tt8 ADD CONSTRAINT xxx PRIMARY KEY(f) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 1160 +ALTER TABLE IF EXISTS tt8 ADD CHECK (f BETWEEN 0 AND 10) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 1161 +ALTER TABLE IF EXISTS tt8 ALTER COLUMN f SET DEFAULT 0 +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 1162 +ALTER TABLE IF EXISTS tt8 RENAME COLUMN f TO f1 +-- +STMT: RenameStmt +== 1163 +ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2 +-- +STMT: AlterObjectSchemaStmt +== 1164 +DROP TABLE alter2.tt8 +-- +TABLE: name="alter2.tt8" schema="alter2" table="tt8" ctx=DDL +STMT: DropStmt +== 1165 +DROP SCHEMA alter2 +-- +STMT: DropStmt +== 1166 +|-- +-- Check conflicts between index and CHECK constraint names +|-- +CREATE TABLE tt9(c integer) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: CreateStmt +== 1167 +ALTER TABLE tt9 ADD CHECK(c > 1) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1168 +ALTER TABLE tt9 ADD CHECK(c > 2) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1169 +-- picks nonconflicting name +ALTER TABLE tt9 ADD CONSTRAINT foo CHECK(c > 3) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1170 +ALTER TABLE tt9 ADD CONSTRAINT foo CHECK(c > 4) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1171 +-- fail, dup name +ALTER TABLE tt9 ADD UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1172 +ALTER TABLE tt9 ADD UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1173 +-- picks nonconflicting name +ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1174 +-- fail, dup name +ALTER TABLE tt9 ADD CONSTRAINT foo UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1175 +-- fail, dup name +ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key CHECK(c > 5) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1176 +-- fail, dup name +ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key2 CHECK(c > 6) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1177 +ALTER TABLE tt9 ADD UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 1178 +-- picks nonconflicting name +DROP TABLE tt9 +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: DropStmt +== 1179 +-- Check that comments on constraints and indexes are not lost at ALTER TABLE. +CREATE TABLE comment_test ( + id int, + positive_col int CHECK (positive_col > 0), + indexed_col int, + CONSTRAINT comment_test_pk PRIMARY KEY (id)) +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: CreateStmt +== 1180 +CREATE INDEX comment_test_index ON comment_test(indexed_col) +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: IndexStmt +== 1181 +COMMENT ON COLUMN comment_test.id IS 'Column ''id'' on comment_test' +-- +STMT: CommentStmt +== 1182 +COMMENT ON INDEX comment_test_index IS 'Simple index on comment_test' +-- +STMT: CommentStmt +== 1183 +COMMENT ON CONSTRAINT comment_test_positive_col_check ON comment_test IS 'CHECK constraint on comment_test.positive_col' +-- +STMT: CommentStmt +== 1184 +COMMENT ON CONSTRAINT comment_test_pk ON comment_test IS 'PRIMARY KEY constraint of comment_test' +-- +STMT: CommentStmt +== 1185 +COMMENT ON INDEX comment_test_pk IS 'Index backing the PRIMARY KEY of comment_test' +-- +STMT: CommentStmt +== 1186 +SELECT col_description('comment_test'::regclass, 1) as comment +-- +FUNCTION: name="col_description" function="col_description" schema="" ctx=Call +STMT: SelectStmt +== 1187 +SELECT indexrelid::regclass::text as index, obj_description(indexrelid, 'pg_class') as comment FROM pg_index where indrelid = 'comment_test'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 1188 +SELECT conname as constraint, obj_description(oid, 'pg_constraint') as comment FROM pg_constraint where conrelid = 'comment_test'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 1189 +-- Change the datatype of all the columns. ALTER TABLE is optimized to not +-- rebuild an index if the new data type is binary compatible with the old +-- one. Check do a dummy ALTER TABLE that doesn't change the datatype +-- first, to test that no-op codepath, and another one that does. +ALTER TABLE comment_test ALTER COLUMN indexed_col SET DATA TYPE int +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +== 1190 +ALTER TABLE comment_test ALTER COLUMN indexed_col SET DATA TYPE text +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +== 1191 +ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE int +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +== 1192 +ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE text +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +== 1193 +ALTER TABLE comment_test ALTER COLUMN positive_col SET DATA TYPE int +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +== 1194 +ALTER TABLE comment_test ALTER COLUMN positive_col SET DATA TYPE bigint +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +== 1195 +-- Check that the comments are intact. +SELECT col_description('comment_test'::regclass, 1) as comment +-- +FUNCTION: name="col_description" function="col_description" schema="" ctx=Call +STMT: SelectStmt +== 1196 +SELECT indexrelid::regclass::text as index, obj_description(indexrelid, 'pg_class') as comment FROM pg_index where indrelid = 'comment_test'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 1197 +SELECT conname as constraint, obj_description(oid, 'pg_constraint') as comment FROM pg_constraint where conrelid = 'comment_test'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 1198 +-- Check compatibility for foreign keys and comments. This is done +-- separately as rebuilding the column type of the parent leads +-- to an error and would reduce the test scope. +CREATE TABLE comment_test_child ( + id text CONSTRAINT comment_test_child_fk REFERENCES comment_test) +-- +TABLE: name="comment_test_child" schema="" table="comment_test_child" ctx=DDL +STMT: CreateStmt +== 1199 +CREATE INDEX comment_test_child_fk ON comment_test_child(id) +-- +TABLE: name="comment_test_child" schema="" table="comment_test_child" ctx=DDL +STMT: IndexStmt +== 1200 +COMMENT ON COLUMN comment_test_child.id IS 'Column ''id'' on comment_test_child' +-- +STMT: CommentStmt +== 1201 +COMMENT ON INDEX comment_test_child_fk IS 'Index backing the FOREIGN KEY of comment_test_child' +-- +STMT: CommentStmt +== 1202 +COMMENT ON CONSTRAINT comment_test_child_fk ON comment_test_child IS 'FOREIGN KEY constraint of comment_test_child' +-- +STMT: CommentStmt +== 1203 +-- Change column type of parent +ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE text +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +== 1204 +ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE int USING id::integer +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +== 1205 +-- Comments should be intact +SELECT col_description('comment_test_child'::regclass, 1) as comment +-- +FUNCTION: name="col_description" function="col_description" schema="" ctx=Call +STMT: SelectStmt +== 1206 +SELECT indexrelid::regclass::text as index, obj_description(indexrelid, 'pg_class') as comment FROM pg_index where indrelid = 'comment_test_child'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 1207 +SELECT conname as constraint, obj_description(oid, 'pg_constraint') as comment FROM pg_constraint where conrelid = 'comment_test_child'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 1208 +-- Check that we map relation oids to filenodes and back correctly. Only +-- display bad mappings so the test output doesn't change all the time. A +-- filenode function call can return NULL for a relation dropped concurrently +-- with the call's surrounding query, so ignore a NULL mapped_oid for +-- relations that no longer exist after all calls finish. +-- Temporary relations are ignored, as not supported by pg_filenode_relation(). +CREATE TEMP TABLE filenode_mapping AS +SELECT + oid, mapped_oid, reltablespace, relfilenode, relname +FROM pg_class, + pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid +WHERE relkind IN ('r', 'i', 'S', 't', 'm') + AND relpersistence != 't' + AND mapped_oid IS DISTINCT FROM oid +-- +TABLE: name="filenode_mapping" schema="" table="filenode_mapping" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_filenode_relation" function="pg_filenode_relation" schema="" ctx=Call +FUNCTION: name="pg_relation_filenode" function="pg_relation_filenode" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relpersistence" +FILTER: schema="" table="" column="mapped_oid" +FILTER: schema="" table="" column="oid" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 1209 +SELECT m.* FROM filenode_mapping m LEFT JOIN pg_class c ON c.oid = m.oid +WHERE c.oid IS NOT NULL OR m.mapped_oid IS NOT NULL +-- +TABLE: name="filenode_mapping" schema="" table="filenode_mapping" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "m"="filenode_mapping" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="m" column="mapped_oid" +STMT: SelectStmt +== 1210 +-- Checks on creating and manipulation of user defined relations in +-- pg_catalog. + +SHOW allow_system_table_mods +-- +STMT: VariableShowStmt +== 1211 +-- disallowed because of search_path issues with pg_dump +CREATE TABLE pg_catalog.new_system_table() +-- +TABLE: name="pg_catalog.new_system_table" schema="pg_catalog" table="new_system_table" ctx=DDL +STMT: CreateStmt +== 1212 +-- instead create in public first, move to catalog +CREATE TABLE new_system_table(id serial primary key, othercol text) +-- +TABLE: name="new_system_table" schema="" table="new_system_table" ctx=DDL +STMT: CreateStmt +== 1213 +ALTER TABLE new_system_table SET SCHEMA pg_catalog +-- +STMT: AlterObjectSchemaStmt +== 1214 +ALTER TABLE new_system_table SET SCHEMA public +-- +STMT: AlterObjectSchemaStmt +== 1215 +ALTER TABLE new_system_table SET SCHEMA pg_catalog +-- +STMT: AlterObjectSchemaStmt +== 1216 +-- will be ignored -- already there: +ALTER TABLE new_system_table SET SCHEMA pg_catalog +-- +STMT: AlterObjectSchemaStmt +== 1217 +ALTER TABLE new_system_table RENAME TO old_system_table +-- +TABLE: name="new_system_table" schema="" table="new_system_table" ctx=DDL +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: RenameStmt +== 1218 +CREATE INDEX old_system_table__othercol ON old_system_table (othercol) +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: IndexStmt +== 1219 +INSERT INTO old_system_table(othercol) VALUES ('somedata'), ('otherdata') +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1220 +UPDATE old_system_table SET id = -id +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DML +STMT: UpdateStmt +== 1221 +DELETE FROM old_system_table WHERE othercol = 'somedata' +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DML +STMT: DeleteStmt +== 1222 +TRUNCATE old_system_table +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: TruncateStmt +== 1223 +ALTER TABLE old_system_table DROP CONSTRAINT new_system_table_pkey +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: AlterTableStmt +== 1224 +ALTER TABLE old_system_table DROP COLUMN othercol +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: AlterTableStmt +== 1225 +DROP TABLE old_system_table +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: DropStmt +== 1226 +-- set logged +CREATE UNLOGGED TABLE unlogged1(f1 SERIAL PRIMARY KEY, f2 TEXT) +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: CreateStmt +== 1227 +-- has sequence, toast +-- check relpersistence of an unlogged table +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged1' +UNION ALL +SELECT r.relname || ' toast table', t.relkind, t.relpersistence FROM pg_class r JOIN pg_class t ON t.oid = r.reltoastrelid WHERE r.relname ~ '^unlogged1' +UNION ALL +SELECT r.relname || ' toast index', ri.relkind, ri.relpersistence FROM pg_class r join pg_class t ON t.oid = r.reltoastrelid JOIN pg_index i ON i.indrelid = t.oid JOIN pg_class ri ON ri.oid = i.indexrelid WHERE r.relname ~ '^unlogged1' +ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "i"="pg_index" +ALIAS: "r"="pg_class" +ALIAS: "ri"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="r" column="relname" +FILTER: schema="" table="r" column="relname" +STMT: SelectStmt +== 1228 +CREATE UNLOGGED TABLE unlogged2(f1 SERIAL PRIMARY KEY, f2 INTEGER REFERENCES unlogged1) +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: CreateStmt +== 1229 +-- foreign key +CREATE UNLOGGED TABLE unlogged3(f1 SERIAL PRIMARY KEY, f2 INTEGER REFERENCES unlogged3) +-- +TABLE: name="unlogged3" schema="" table="unlogged3" ctx=DDL +STMT: CreateStmt +== 1230 +-- self-referencing foreign key +ALTER TABLE unlogged3 SET LOGGED +-- +TABLE: name="unlogged3" schema="" table="unlogged3" ctx=DDL +STMT: AlterTableStmt +== 1231 +-- skip self-referencing foreign key +ALTER TABLE unlogged2 SET LOGGED +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: AlterTableStmt +== 1232 +-- fails because a foreign key to an unlogged table exists +ALTER TABLE unlogged1 SET LOGGED +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: AlterTableStmt +== 1233 +-- check relpersistence of an unlogged table after changing to permanent +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged1' +UNION ALL +SELECT r.relname || ' toast table', t.relkind, t.relpersistence FROM pg_class r JOIN pg_class t ON t.oid = r.reltoastrelid WHERE r.relname ~ '^unlogged1' +UNION ALL +SELECT r.relname || ' toast index', ri.relkind, ri.relpersistence FROM pg_class r join pg_class t ON t.oid = r.reltoastrelid JOIN pg_index i ON i.indrelid = t.oid JOIN pg_class ri ON ri.oid = i.indexrelid WHERE r.relname ~ '^unlogged1' +ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "i"="pg_index" +ALIAS: "r"="pg_class" +ALIAS: "ri"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="r" column="relname" +FILTER: schema="" table="r" column="relname" +STMT: SelectStmt +== 1234 +ALTER TABLE unlogged1 SET LOGGED +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: AlterTableStmt +== 1235 +-- silently do nothing +DROP TABLE unlogged3 +-- +TABLE: name="unlogged3" schema="" table="unlogged3" ctx=DDL +STMT: DropStmt +== 1236 +DROP TABLE unlogged2 +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: DropStmt +== 1237 +DROP TABLE unlogged1 +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: DropStmt +== 1238 +-- set unlogged +CREATE TABLE logged1(f1 SERIAL PRIMARY KEY, f2 TEXT) +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: CreateStmt +== 1239 +-- has sequence, toast +-- check relpersistence of a permanent table +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^logged1' +UNION ALL +SELECT r.relname || ' toast table', t.relkind, t.relpersistence FROM pg_class r JOIN pg_class t ON t.oid = r.reltoastrelid WHERE r.relname ~ '^logged1' +UNION ALL +SELECT r.relname ||' toast index', ri.relkind, ri.relpersistence FROM pg_class r join pg_class t ON t.oid = r.reltoastrelid JOIN pg_index i ON i.indrelid = t.oid JOIN pg_class ri ON ri.oid = i.indexrelid WHERE r.relname ~ '^logged1' +ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "i"="pg_index" +ALIAS: "r"="pg_class" +ALIAS: "ri"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="r" column="relname" +FILTER: schema="" table="r" column="relname" +STMT: SelectStmt +== 1240 +CREATE TABLE logged2(f1 SERIAL PRIMARY KEY, f2 INTEGER REFERENCES logged1) +-- +TABLE: name="logged2" schema="" table="logged2" ctx=DDL +STMT: CreateStmt +== 1241 +-- foreign key +CREATE TABLE logged3(f1 SERIAL PRIMARY KEY, f2 INTEGER REFERENCES logged3) +-- +TABLE: name="logged3" schema="" table="logged3" ctx=DDL +STMT: CreateStmt +== 1242 +-- self-referencing foreign key +ALTER TABLE logged1 SET UNLOGGED +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: AlterTableStmt +== 1243 +-- fails because a foreign key from a permanent table exists +ALTER TABLE logged3 SET UNLOGGED +-- +TABLE: name="logged3" schema="" table="logged3" ctx=DDL +STMT: AlterTableStmt +== 1244 +-- skip self-referencing foreign key +ALTER TABLE logged2 SET UNLOGGED +-- +TABLE: name="logged2" schema="" table="logged2" ctx=DDL +STMT: AlterTableStmt +== 1245 +ALTER TABLE logged1 SET UNLOGGED +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: AlterTableStmt +== 1246 +-- check relpersistence of a permanent table after changing to unlogged +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^logged1' +UNION ALL +SELECT r.relname || ' toast table', t.relkind, t.relpersistence FROM pg_class r JOIN pg_class t ON t.oid = r.reltoastrelid WHERE r.relname ~ '^logged1' +UNION ALL +SELECT r.relname || ' toast index', ri.relkind, ri.relpersistence FROM pg_class r join pg_class t ON t.oid = r.reltoastrelid JOIN pg_index i ON i.indrelid = t.oid JOIN pg_class ri ON ri.oid = i.indexrelid WHERE r.relname ~ '^logged1' +ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "i"="pg_index" +ALIAS: "r"="pg_class" +ALIAS: "ri"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="r" column="relname" +FILTER: schema="" table="r" column="relname" +STMT: SelectStmt +== 1247 +ALTER TABLE logged1 SET UNLOGGED +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: AlterTableStmt +== 1248 +-- silently do nothing +DROP TABLE logged3 +-- +TABLE: name="logged3" schema="" table="logged3" ctx=DDL +STMT: DropStmt +== 1249 +DROP TABLE logged2 +-- +TABLE: name="logged2" schema="" table="logged2" ctx=DDL +STMT: DropStmt +== 1250 +DROP TABLE logged1 +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: DropStmt +== 1251 +-- test ADD COLUMN IF NOT EXISTS +CREATE TABLE test_add_column(c1 integer) +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: CreateStmt +== 1252 +ALTER TABLE test_add_column + ADD COLUMN c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1253 +ALTER TABLE test_add_column + ADD COLUMN c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1254 +-- fail because c2 already exists +ALTER TABLE ONLY test_add_column + ADD COLUMN c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1255 +-- fail because c2 already exists +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1256 +-- skipping because c2 already exists +ALTER TABLE ONLY test_add_column + ADD COLUMN IF NOT EXISTS c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1257 +-- skipping because c2 already exists +ALTER TABLE test_add_column + ADD COLUMN c2 integer, -- fail because c2 already exists + ADD COLUMN c3 integer primary key +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1258 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists + ADD COLUMN c3 integer primary key +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1259 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists + ADD COLUMN IF NOT EXISTS c3 integer primary key +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1260 +-- skipping because c3 already exists +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists + ADD COLUMN IF NOT EXISTS c3 integer, -- skipping because c3 already exists + ADD COLUMN c4 integer REFERENCES test_add_column +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1261 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c4 integer REFERENCES test_add_column +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1262 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c5 SERIAL CHECK (c5 > 8) +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1263 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c5 SERIAL CHECK (c5 > 10) +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +== 1264 +DROP TABLE test_add_column +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: DropStmt +== 1265 +-- assorted cases with multiple ALTER TABLE steps +CREATE TABLE ataddindex(f1 INT) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: CreateStmt +== 1266 +INSERT INTO ataddindex VALUES (42), (43) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1267 +CREATE UNIQUE INDEX ataddindexi0 ON ataddindex(f1) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: IndexStmt +== 1268 +ALTER TABLE ataddindex + ADD PRIMARY KEY USING INDEX ataddindexi0, + ALTER f1 TYPE BIGINT +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: AlterTableStmt +== 1269 +DROP TABLE ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: DropStmt +== 1270 +CREATE TABLE ataddindex(f1 VARCHAR(10)) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: CreateStmt +== 1271 +INSERT INTO ataddindex(f1) VALUES ('foo'), ('a') +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1272 +ALTER TABLE ataddindex + ALTER f1 SET DATA TYPE TEXT, + ADD EXCLUDE ((f1 LIKE 'a') WITH =) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: AlterTableStmt +== 1273 +DROP TABLE ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: DropStmt +== 1274 +CREATE TABLE ataddindex(id int, ref_id int) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: CreateStmt +== 1275 +ALTER TABLE ataddindex + ADD PRIMARY KEY (id), + ADD FOREIGN KEY (ref_id) REFERENCES ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: AlterTableStmt +== 1276 +DROP TABLE ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: DropStmt +== 1277 +CREATE TABLE ataddindex(id int, ref_id int) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: CreateStmt +== 1278 +ALTER TABLE ataddindex + ADD UNIQUE (id), + ADD FOREIGN KEY (ref_id) REFERENCES ataddindex (id) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: AlterTableStmt +== 1279 +DROP TABLE ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: DropStmt +== 1280 +CREATE TABLE atnotnull1 () +-- +TABLE: name="atnotnull1" schema="" table="atnotnull1" ctx=DDL +STMT: CreateStmt +== 1281 +ALTER TABLE atnotnull1 + ADD COLUMN a INT, + ALTER a SET NOT NULL +-- +TABLE: name="atnotnull1" schema="" table="atnotnull1" ctx=DDL +STMT: AlterTableStmt +== 1282 +ALTER TABLE atnotnull1 + ADD COLUMN c INT, + ADD PRIMARY KEY (c) +-- +TABLE: name="atnotnull1" schema="" table="atnotnull1" ctx=DDL +STMT: AlterTableStmt +== 1283 +-- cannot drop column that is part of the partition key +CREATE TABLE partitioned ( + a int, + b int +) PARTITION BY RANGE (a, (a+b+1)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 1284 +ALTER TABLE partitioned DROP COLUMN a +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 1285 +ALTER TABLE partitioned ALTER COLUMN a TYPE char(5) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 1286 +ALTER TABLE partitioned DROP COLUMN b +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 1287 +ALTER TABLE partitioned ALTER COLUMN b TYPE char(5) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 1288 +-- specifying storage parameters for partitioned tables is not supported +ALTER TABLE partitioned SET (fillfactor=100) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 1289 +-- partitioned table cannot participate in regular inheritance +CREATE TABLE nonpartitioned ( + a int, + b int +) +-- +TABLE: name="nonpartitioned" schema="" table="nonpartitioned" ctx=DDL +STMT: CreateStmt +== 1290 +ALTER TABLE partitioned INHERIT nonpartitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 1291 +ALTER TABLE nonpartitioned INHERIT partitioned +-- +TABLE: name="nonpartitioned" schema="" table="nonpartitioned" ctx=DDL +STMT: AlterTableStmt +== 1292 +-- cannot add NO INHERIT constraint to partitioned tables +ALTER TABLE partitioned ADD CONSTRAINT chk_a CHECK (a > 0) NO INHERIT +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 1293 +DROP TABLE partitioned, nonpartitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +TABLE: name="nonpartitioned" schema="" table="nonpartitioned" ctx=DDL +STMT: DropStmt +== 1294 +|-- +-- ATTACH PARTITION +|-- + +-- check that target table is partitioned +CREATE TABLE unparted ( + a int +) +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +STMT: CreateStmt +== 1295 +CREATE TABLE fail_part (like unparted) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1296 +ALTER TABLE unparted ATTACH PARTITION fail_part FOR VALUES IN ('a') +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +STMT: AlterTableStmt +== 1297 +DROP TABLE unparted, fail_part +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1298 +-- check that partition bound is compatible +CREATE TABLE list_parted ( + a int NOT NULL, + b char(2) COLLATE "C", + CONSTRAINT check_a CHECK (a > 0) +) PARTITION BY LIST (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +== 1299 +CREATE TABLE fail_part (LIKE list_parted) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1300 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES FROM (1) TO (10) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1301 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1302 +-- check that the table being attached exists +ALTER TABLE list_parted ATTACH PARTITION nonexistent FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1303 +-- check ownership of the source table +CREATE ROLE regress_test_me +-- +STMT: CreateRoleStmt +== 1304 +CREATE ROLE regress_test_not_me +-- +STMT: CreateRoleStmt +== 1305 +CREATE TABLE not_owned_by_me (LIKE list_parted) +-- +TABLE: name="not_owned_by_me" schema="" table="not_owned_by_me" ctx=DDL +STMT: CreateStmt +== 1306 +ALTER TABLE not_owned_by_me OWNER TO regress_test_not_me +-- +TABLE: name="not_owned_by_me" schema="" table="not_owned_by_me" ctx=DDL +STMT: AlterTableStmt +== 1307 +SET SESSION AUTHORIZATION regress_test_me +-- +STMT: VariableSetStmt +== 1308 +CREATE TABLE owned_by_me ( + a int +) PARTITION BY LIST (a) +-- +TABLE: name="owned_by_me" schema="" table="owned_by_me" ctx=DDL +STMT: CreateStmt +== 1309 +ALTER TABLE owned_by_me ATTACH PARTITION not_owned_by_me FOR VALUES IN (1) +-- +TABLE: name="owned_by_me" schema="" table="owned_by_me" ctx=DDL +STMT: AlterTableStmt +== 1310 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 1311 +DROP TABLE owned_by_me, not_owned_by_me +-- +TABLE: name="owned_by_me" schema="" table="owned_by_me" ctx=DDL +TABLE: name="not_owned_by_me" schema="" table="not_owned_by_me" ctx=DDL +STMT: DropStmt +== 1312 +DROP ROLE regress_test_not_me +-- +STMT: DropRoleStmt +== 1313 +DROP ROLE regress_test_me +-- +STMT: DropRoleStmt +== 1314 +-- check that the table being attached is not part of regular inheritance +CREATE TABLE parent (LIKE list_parted) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 1315 +CREATE TABLE child () INHERITS (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 1316 +ALTER TABLE list_parted ATTACH PARTITION child FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1317 +ALTER TABLE list_parted ATTACH PARTITION parent FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1318 +DROP TABLE child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +== 1319 +-- now it should work, with a little tweak +ALTER TABLE parent ADD CONSTRAINT check_a CHECK (a > 0) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 1320 +ALTER TABLE list_parted ATTACH PARTITION parent FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1321 +-- test insert/update, per bug #18550 +INSERT INTO parent VALUES (1) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1322 +UPDATE parent SET a = 2 WHERE a = 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: UpdateStmt +== 1323 +DROP TABLE parent CASCADE +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +== 1324 +-- check any TEMP-ness +CREATE TEMP TABLE temp_parted (a int) PARTITION BY LIST (a) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: CreateStmt +== 1325 +CREATE TABLE perm_part (a int) +-- +TABLE: name="perm_part" schema="" table="perm_part" ctx=DDL +STMT: CreateStmt +== 1326 +ALTER TABLE temp_parted ATTACH PARTITION perm_part FOR VALUES IN (1) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: AlterTableStmt +== 1327 +DROP TABLE temp_parted, perm_part +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +TABLE: name="perm_part" schema="" table="perm_part" ctx=DDL +STMT: DropStmt +== 1328 +-- check that the table being attached is not a typed table +CREATE TYPE mytype AS (a int) +-- +STMT: CompositeTypeStmt +== 1329 +CREATE TABLE fail_part OF mytype +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1330 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1331 +DROP TYPE mytype CASCADE +-- +STMT: DropStmt +== 1332 +-- check that the table being attached has only columns present in the parent +CREATE TABLE fail_part (like list_parted, c int) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1333 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1334 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1335 +-- check that the table being attached has every column of the parent +CREATE TABLE fail_part (a int NOT NULL) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1336 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1337 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1338 +-- check that columns match in type, collation and NOT NULL status +CREATE TABLE fail_part ( + b char(3), + a int NOT NULL +) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1339 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1340 +ALTER TABLE fail_part ALTER b TYPE char (2) COLLATE "POSIX" +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: AlterTableStmt +== 1341 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1342 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1343 +-- check that the table being attached has all constraints of the parent +CREATE TABLE fail_part ( + b char(2) COLLATE "C", + a int NOT NULL +) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1344 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1345 +-- check that the constraint matches in definition with parent's constraint +ALTER TABLE fail_part ADD CONSTRAINT check_a CHECK (a >= 0) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: AlterTableStmt +== 1346 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1347 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1348 +-- check the attributes and constraints after partition is attached +CREATE TABLE part_1 ( + a int NOT NULL, + b char(2) COLLATE "C", + CONSTRAINT check_a CHECK (a > 0) +) +-- +TABLE: name="part_1" schema="" table="part_1" ctx=DDL +STMT: CreateStmt +== 1349 +ALTER TABLE list_parted ATTACH PARTITION part_1 FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1350 +-- attislocal and conislocal are always false for merged attributes and constraints respectively. +SELECT attislocal, attinhcount FROM pg_attribute WHERE attrelid = 'part_1'::regclass AND attnum > 0 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +== 1351 +SELECT conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_1'::regclass AND conname = 'check_a' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 1352 +-- check that the new partition won't overlap with an existing partition +CREATE TABLE fail_part (LIKE part_1 INCLUDING CONSTRAINTS) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1353 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1354 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1355 +-- check that an existing table can be attached as a default partition +CREATE TABLE def_part (LIKE list_parted INCLUDING CONSTRAINTS) +-- +TABLE: name="def_part" schema="" table="def_part" ctx=DDL +STMT: CreateStmt +== 1356 +ALTER TABLE list_parted ATTACH PARTITION def_part DEFAULT +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1357 +-- check attaching default partition fails if a default partition already +-- exists +CREATE TABLE fail_def_part (LIKE part_1 INCLUDING CONSTRAINTS) +-- +TABLE: name="fail_def_part" schema="" table="fail_def_part" ctx=DDL +STMT: CreateStmt +== 1358 +ALTER TABLE list_parted ATTACH PARTITION fail_def_part DEFAULT +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1359 +-- check validation when attaching list partitions +CREATE TABLE list_parted2 ( + a int, + b char +) PARTITION BY LIST (a) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: CreateStmt +== 1360 +-- check that violating rows are correctly reported +CREATE TABLE part_2 (LIKE list_parted2) +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: CreateStmt +== 1361 +INSERT INTO part_2 VALUES (3, 'a') +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1362 +ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1363 +-- should be ok after deleting the bad row +DELETE FROM part_2 +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DML +STMT: DeleteStmt +== 1364 +ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1365 +-- check partition cannot be attached if default has some row for its values +CREATE TABLE list_parted2_def PARTITION OF list_parted2 DEFAULT +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DDL +STMT: CreateStmt +== 1366 +INSERT INTO list_parted2_def VALUES (11, 'z') +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1367 +CREATE TABLE part_3 (LIKE list_parted2) +-- +TABLE: name="part_3" schema="" table="part_3" ctx=DDL +STMT: CreateStmt +== 1368 +ALTER TABLE list_parted2 ATTACH PARTITION part_3 FOR VALUES IN (11) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1369 +-- should be ok after deleting the bad row +DELETE FROM list_parted2_def WHERE a = 11 +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DML +STMT: DeleteStmt +== 1370 +ALTER TABLE list_parted2 ATTACH PARTITION part_3 FOR VALUES IN (11) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1371 +-- adding constraints that describe the desired partition constraint +-- (or more restrictive) will help skip the validation scan +CREATE TABLE part_3_4 ( + LIKE list_parted2, + CONSTRAINT check_a CHECK (a IN (3)) +) +-- +TABLE: name="part_3_4" schema="" table="part_3_4" ctx=DDL +STMT: CreateStmt +== 1372 +-- however, if a list partition does not accept nulls, there should be +-- an explicit NOT NULL constraint on the partition key column for the +-- validation scan to be skipped; +ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1373 +-- adding a NOT NULL constraint will cause the scan to be skipped +ALTER TABLE list_parted2 DETACH PARTITION part_3_4 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1374 +ALTER TABLE part_3_4 ALTER a SET NOT NULL +-- +TABLE: name="part_3_4" schema="" table="part_3_4" ctx=DDL +STMT: AlterTableStmt +== 1375 +ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1376 +-- check if default partition scan skipped +ALTER TABLE list_parted2_def ADD CONSTRAINT check_a CHECK (a IN (5, 6)) +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DDL +STMT: AlterTableStmt +== 1377 +CREATE TABLE part_55_66 PARTITION OF list_parted2 FOR VALUES IN (55, 66) +-- +TABLE: name="part_55_66" schema="" table="part_55_66" ctx=DDL +STMT: CreateStmt +== 1378 +-- check validation when attaching range partitions +CREATE TABLE range_parted ( + a int, + b int +) PARTITION BY RANGE (a, b) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +== 1379 +-- check that violating rows are correctly reported +CREATE TABLE part1 ( + a int NOT NULL CHECK (a = 1), + b int NOT NULL CHECK (b >= 1 AND b <= 10) +) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +== 1380 +INSERT INTO part1 VALUES (1, 10) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1381 +-- Remember the TO bound is exclusive +ALTER TABLE range_parted ATTACH PARTITION part1 FOR VALUES FROM (1, 1) TO (1, 10) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 1382 +-- should be ok after deleting the bad row +DELETE FROM part1 +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: DeleteStmt +== 1383 +ALTER TABLE range_parted ATTACH PARTITION part1 FOR VALUES FROM (1, 1) TO (1, 10) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 1384 +-- adding constraints that describe the desired partition constraint +-- (or more restrictive) will help skip the validation scan +CREATE TABLE part2 ( + a int NOT NULL CHECK (a = 1), + b int NOT NULL CHECK (b >= 10 AND b < 18) +) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +== 1385 +ALTER TABLE range_parted ATTACH PARTITION part2 FOR VALUES FROM (1, 10) TO (1, 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 1386 +-- Create default partition +CREATE TABLE partr_def1 PARTITION OF range_parted DEFAULT +-- +TABLE: name="partr_def1" schema="" table="partr_def1" ctx=DDL +STMT: CreateStmt +== 1387 +-- Only one default partition is allowed, hence, following should give error +CREATE TABLE partr_def2 (LIKE part1 INCLUDING CONSTRAINTS) +-- +TABLE: name="partr_def2" schema="" table="partr_def2" ctx=DDL +STMT: CreateStmt +== 1388 +ALTER TABLE range_parted ATTACH PARTITION partr_def2 DEFAULT +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 1389 +-- Overlapping partitions cannot be attached, hence, following should give error +INSERT INTO partr_def1 VALUES (2, 10) +-- +TABLE: name="partr_def1" schema="" table="partr_def1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1390 +CREATE TABLE part3 (LIKE range_parted) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +== 1391 +ALTER TABLE range_parted ATTACH partition part3 FOR VALUES FROM (2, 10) TO (2, 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 1392 +-- Attaching partitions should be successful when there are no overlapping rows +ALTER TABLE range_parted ATTACH partition part3 FOR VALUES FROM (3, 10) TO (3, 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 1393 +-- check that leaf partitions are scanned when attaching a partitioned +-- table +CREATE TABLE part_5 ( + LIKE list_parted2 +) PARTITION BY LIST (b) +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: CreateStmt +== 1394 +-- check that violating rows are correctly reported +CREATE TABLE part_5_a PARTITION OF part_5 FOR VALUES IN ('a') +-- +TABLE: name="part_5_a" schema="" table="part_5_a" ctx=DDL +STMT: CreateStmt +== 1395 +INSERT INTO part_5_a (a, b) VALUES (6, 'a') +-- +TABLE: name="part_5_a" schema="" table="part_5_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1396 +ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1397 +-- delete the faulting row and also add a constraint to skip the scan +DELETE FROM part_5_a WHERE a NOT IN (3) +-- +TABLE: name="part_5_a" schema="" table="part_5_a" ctx=DML +STMT: DeleteStmt +== 1398 +ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 5) +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +== 1399 +ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1400 +ALTER TABLE list_parted2 DETACH PARTITION part_5 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1401 +ALTER TABLE part_5 DROP CONSTRAINT check_a +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +== 1402 +-- scan should again be skipped, even though NOT NULL is now a column property +ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IN (5)), ALTER a SET NOT NULL +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +== 1403 +ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1404 +-- Check the case where attnos of the partitioning columns in the table being +-- attached differs from the parent. It should not affect the constraint- +-- checking logic that allows to skip the scan. +CREATE TABLE part_6 ( + c int, + LIKE list_parted2, + CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 6) +) +-- +TABLE: name="part_6" schema="" table="part_6" ctx=DDL +STMT: CreateStmt +== 1405 +ALTER TABLE part_6 DROP c +-- +TABLE: name="part_6" schema="" table="part_6" ctx=DDL +STMT: AlterTableStmt +== 1406 +ALTER TABLE list_parted2 ATTACH PARTITION part_6 FOR VALUES IN (6) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1407 +-- Similar to above, but the table being attached is a partitioned table +-- whose partition has still different attnos for the root partitioning +-- columns. +CREATE TABLE part_7 ( + LIKE list_parted2, + CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7) +) PARTITION BY LIST (b) +-- +TABLE: name="part_7" schema="" table="part_7" ctx=DDL +STMT: CreateStmt +== 1408 +CREATE TABLE part_7_a_null ( + c int, + d int, + e int, + LIKE list_parted2, -- 'a' will have attnum = 4 + CONSTRAINT check_b CHECK (b IS NULL OR b = 'a'), + CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7) +) +-- +TABLE: name="part_7_a_null" schema="" table="part_7_a_null" ctx=DDL +STMT: CreateStmt +== 1409 +ALTER TABLE part_7_a_null DROP c, DROP d, DROP e +-- +TABLE: name="part_7_a_null" schema="" table="part_7_a_null" ctx=DDL +STMT: AlterTableStmt +== 1410 +ALTER TABLE part_7 ATTACH PARTITION part_7_a_null FOR VALUES IN ('a', null) +-- +TABLE: name="part_7" schema="" table="part_7" ctx=DDL +STMT: AlterTableStmt +== 1411 +ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1412 +-- Same example, but check this time that the constraint correctly detects +-- violating rows +ALTER TABLE list_parted2 DETACH PARTITION part_7 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1413 +ALTER TABLE part_7 DROP CONSTRAINT check_a +-- +TABLE: name="part_7" schema="" table="part_7" ctx=DDL +STMT: AlterTableStmt +== 1414 +-- thusly, scan won't be skipped +INSERT INTO part_7 (a, b) VALUES (8, null), (9, 'a') +-- +TABLE: name="part_7" schema="" table="part_7" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1415 +SELECT tableoid::regclass, a, b FROM part_7 order by a +-- +TABLE: name="part_7" schema="" table="part_7" ctx=Select +STMT: SelectStmt +== 1416 +ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1417 +-- check that leaf partitions of default partition are scanned when +-- attaching a partitioned table. +ALTER TABLE part_5 DROP CONSTRAINT check_a +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +== 1418 +CREATE TABLE part5_def PARTITION OF part_5 DEFAULT PARTITION BY LIST(a) +-- +TABLE: name="part5_def" schema="" table="part5_def" ctx=DDL +STMT: CreateStmt +== 1419 +CREATE TABLE part5_def_p1 PARTITION OF part5_def FOR VALUES IN (5) +-- +TABLE: name="part5_def_p1" schema="" table="part5_def_p1" ctx=DDL +STMT: CreateStmt +== 1420 +INSERT INTO part5_def_p1 VALUES (5, 'y') +-- +TABLE: name="part5_def_p1" schema="" table="part5_def_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1421 +CREATE TABLE part5_p1 (LIKE part_5) +-- +TABLE: name="part5_p1" schema="" table="part5_p1" ctx=DDL +STMT: CreateStmt +== 1422 +ALTER TABLE part_5 ATTACH PARTITION part5_p1 FOR VALUES IN ('y') +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +== 1423 +-- should be ok after deleting the bad row +DELETE FROM part5_def_p1 WHERE b = 'y' +-- +TABLE: name="part5_def_p1" schema="" table="part5_def_p1" ctx=DML +STMT: DeleteStmt +== 1424 +ALTER TABLE part_5 ATTACH PARTITION part5_p1 FOR VALUES IN ('y') +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +== 1425 +-- check that the table being attached is not already a partition +ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1426 +-- check that circular inheritance is not allowed +ALTER TABLE part_5 ATTACH PARTITION list_parted2 FOR VALUES IN ('b') +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +== 1427 +ALTER TABLE list_parted2 ATTACH PARTITION list_parted2 FOR VALUES IN (0) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1428 +-- If a partitioned table being created or an existing table being attached +-- as a partition does not have a constraint that would allow validation scan +-- to be skipped, but an individual partition does, then the partition's +-- validation scan is skipped. +CREATE TABLE quuux (a int, b text) PARTITION BY LIST (a) +-- +TABLE: name="quuux" schema="" table="quuux" ctx=DDL +STMT: CreateStmt +== 1429 +CREATE TABLE quuux_default PARTITION OF quuux DEFAULT PARTITION BY LIST (b) +-- +TABLE: name="quuux_default" schema="" table="quuux_default" ctx=DDL +STMT: CreateStmt +== 1430 +CREATE TABLE quuux_default1 PARTITION OF quuux_default ( + CONSTRAINT check_1 CHECK (a IS NOT NULL AND a = 1) +) FOR VALUES IN ('b') +-- +TABLE: name="quuux_default1" schema="" table="quuux_default1" ctx=DDL +STMT: CreateStmt +== 1431 +CREATE TABLE quuux1 (a int, b text) +-- +TABLE: name="quuux1" schema="" table="quuux1" ctx=DDL +STMT: CreateStmt +== 1432 +ALTER TABLE quuux ATTACH PARTITION quuux1 FOR VALUES IN (1) +-- +TABLE: name="quuux" schema="" table="quuux" ctx=DDL +STMT: AlterTableStmt +== 1433 +-- validate! +CREATE TABLE quuux2 (a int, b text) +-- +TABLE: name="quuux2" schema="" table="quuux2" ctx=DDL +STMT: CreateStmt +== 1434 +ALTER TABLE quuux ATTACH PARTITION quuux2 FOR VALUES IN (2) +-- +TABLE: name="quuux" schema="" table="quuux" ctx=DDL +STMT: AlterTableStmt +== 1435 +-- skip validation +DROP TABLE quuux1, quuux2 +-- +TABLE: name="quuux1" schema="" table="quuux1" ctx=DDL +TABLE: name="quuux2" schema="" table="quuux2" ctx=DDL +STMT: DropStmt +== 1436 +-- should validate for quuux1, but not for quuux2 +CREATE TABLE quuux1 PARTITION OF quuux FOR VALUES IN (1) +-- +TABLE: name="quuux1" schema="" table="quuux1" ctx=DDL +STMT: CreateStmt +== 1437 +CREATE TABLE quuux2 PARTITION OF quuux FOR VALUES IN (2) +-- +TABLE: name="quuux2" schema="" table="quuux2" ctx=DDL +STMT: CreateStmt +== 1438 +DROP TABLE quuux +-- +TABLE: name="quuux" schema="" table="quuux" ctx=DDL +STMT: DropStmt +== 1439 +-- check validation when attaching hash partitions + +-- Use hand-rolled hash functions and operator class to get predictable result +-- on different machines. part_test_int4_ops is defined in test_setup.sql. + +-- check that the new partition won't overlap with an existing partition +CREATE TABLE hash_parted ( + a int, + b int +) PARTITION BY HASH (a part_test_int4_ops) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: CreateStmt +== 1440 +CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 4, REMAINDER 0) +-- +TABLE: name="hpart_1" schema="" table="hpart_1" ctx=DDL +STMT: CreateStmt +== 1441 +CREATE TABLE fail_part (LIKE hpart_1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1442 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 4) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1443 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 0) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1444 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1445 +-- check validation when attaching hash partitions + +-- check that violating rows are correctly reported +CREATE TABLE hpart_2 (LIKE hash_parted) +-- +TABLE: name="hpart_2" schema="" table="hpart_2" ctx=DDL +STMT: CreateStmt +== 1446 +INSERT INTO hpart_2 VALUES (3, 0) +-- +TABLE: name="hpart_2" schema="" table="hpart_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1447 +ALTER TABLE hash_parted ATTACH PARTITION hpart_2 FOR VALUES WITH (MODULUS 4, REMAINDER 1) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1448 +-- should be ok after deleting the bad row +DELETE FROM hpart_2 +-- +TABLE: name="hpart_2" schema="" table="hpart_2" ctx=DML +STMT: DeleteStmt +== 1449 +ALTER TABLE hash_parted ATTACH PARTITION hpart_2 FOR VALUES WITH (MODULUS 4, REMAINDER 1) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1450 +-- check that leaf partitions are scanned when attaching a partitioned +-- table +CREATE TABLE hpart_5 ( + LIKE hash_parted +) PARTITION BY LIST (b) +-- +TABLE: name="hpart_5" schema="" table="hpart_5" ctx=DDL +STMT: CreateStmt +== 1451 +-- check that violating rows are correctly reported +CREATE TABLE hpart_5_a PARTITION OF hpart_5 FOR VALUES IN ('1', '2', '3') +-- +TABLE: name="hpart_5_a" schema="" table="hpart_5_a" ctx=DDL +STMT: CreateStmt +== 1452 +INSERT INTO hpart_5_a (a, b) VALUES (7, 1) +-- +TABLE: name="hpart_5_a" schema="" table="hpart_5_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1453 +ALTER TABLE hash_parted ATTACH PARTITION hpart_5 FOR VALUES WITH (MODULUS 4, REMAINDER 2) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1454 +-- should be ok after deleting the bad row +DELETE FROM hpart_5_a +-- +TABLE: name="hpart_5_a" schema="" table="hpart_5_a" ctx=DML +STMT: DeleteStmt +== 1455 +ALTER TABLE hash_parted ATTACH PARTITION hpart_5 FOR VALUES WITH (MODULUS 4, REMAINDER 2) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1456 +-- check that the table being attach is with valid modulus and remainder value +CREATE TABLE fail_part(LIKE hash_parted) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 1457 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 0, REMAINDER 1) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1458 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 8) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1459 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 3, REMAINDER 2) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1460 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +== 1461 +|-- +-- DETACH PARTITION +|-- + +-- check that the table is partitioned at all +CREATE TABLE regular_table (a int) +-- +TABLE: name="regular_table" schema="" table="regular_table" ctx=DDL +STMT: CreateStmt +== 1462 +ALTER TABLE regular_table DETACH PARTITION any_name +-- +TABLE: name="regular_table" schema="" table="regular_table" ctx=DDL +STMT: AlterTableStmt +== 1463 +DROP TABLE regular_table +-- +TABLE: name="regular_table" schema="" table="regular_table" ctx=DDL +STMT: DropStmt +== 1464 +-- check that the partition being detached exists at all +ALTER TABLE list_parted2 DETACH PARTITION part_4 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1465 +ALTER TABLE hash_parted DETACH PARTITION hpart_4 +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1466 +-- check that the partition being detached is actually a partition of the parent +CREATE TABLE not_a_part (a int) +-- +TABLE: name="not_a_part" schema="" table="not_a_part" ctx=DDL +STMT: CreateStmt +== 1467 +ALTER TABLE list_parted2 DETACH PARTITION not_a_part +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1468 +ALTER TABLE list_parted2 DETACH PARTITION part_1 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1469 +ALTER TABLE hash_parted DETACH PARTITION not_a_part +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +== 1470 +DROP TABLE not_a_part +-- +TABLE: name="not_a_part" schema="" table="not_a_part" ctx=DDL +STMT: DropStmt +== 1471 +-- check that, after being detached, attinhcount/coninhcount is dropped to 0 and +-- attislocal/conislocal is set to true +ALTER TABLE list_parted2 DETACH PARTITION part_3_4 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1472 +SELECT attinhcount, attislocal FROM pg_attribute WHERE attrelid = 'part_3_4'::regclass AND attnum > 0 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +== 1473 +SELECT coninhcount, conislocal FROM pg_constraint WHERE conrelid = 'part_3_4'::regclass AND conname = 'check_a' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 1474 +DROP TABLE part_3_4 +-- +TABLE: name="part_3_4" schema="" table="part_3_4" ctx=DDL +STMT: DropStmt +== 1475 +-- check that a detached partition is not dropped on dropping a partitioned table +CREATE TABLE range_parted2 ( + a int +) PARTITION BY RANGE(a) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: CreateStmt +== 1476 +CREATE TABLE part_rp PARTITION OF range_parted2 FOR VALUES FROM (0) to (100) +-- +TABLE: name="part_rp" schema="" table="part_rp" ctx=DDL +STMT: CreateStmt +== 1477 +ALTER TABLE range_parted2 DETACH PARTITION part_rp +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +== 1478 +DROP TABLE range_parted2 +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: DropStmt +== 1479 +SELECT * from part_rp +-- +TABLE: name="part_rp" schema="" table="part_rp" ctx=Select +STMT: SelectStmt +== 1480 +DROP TABLE part_rp +-- +TABLE: name="part_rp" schema="" table="part_rp" ctx=DDL +STMT: DropStmt +== 1481 +-- concurrent detach +CREATE TABLE range_parted2 ( + a int +) PARTITION BY RANGE(a) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: CreateStmt +== 1482 +CREATE TABLE part_rp PARTITION OF range_parted2 FOR VALUES FROM (0) to (100) +-- +TABLE: name="part_rp" schema="" table="part_rp" ctx=DDL +STMT: CreateStmt +== 1483 +BEGIN +-- +STMT: TransactionStmt +== 1484 +-- doesn't work in a partition block +ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +== 1485 +COMMIT +-- +STMT: TransactionStmt +== 1486 +CREATE TABLE part_rpd PARTITION OF range_parted2 DEFAULT +-- +TABLE: name="part_rpd" schema="" table="part_rpd" ctx=DDL +STMT: CreateStmt +== 1487 +-- doesn't work if there's a default partition +ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +== 1488 +-- doesn't work for the default partition +ALTER TABLE range_parted2 DETACH PARTITION part_rpd CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +== 1489 +DROP TABLE part_rpd +-- +TABLE: name="part_rpd" schema="" table="part_rpd" ctx=DDL +STMT: DropStmt +== 1490 +-- works fine +ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +== 1491 +-- constraint should be created +CREATE TABLE part_rp100 PARTITION OF range_parted2 (CHECK (a>=123 AND a<133 AND a IS NOT NULL)) FOR VALUES FROM (100) to (200) +-- +TABLE: name="part_rp100" schema="" table="part_rp100" ctx=DDL +STMT: CreateStmt +== 1492 +ALTER TABLE range_parted2 DETACH PARTITION part_rp100 CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +== 1493 +-- redundant constraint should not be created +DROP TABLE range_parted2 +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: DropStmt +== 1494 +-- Test that hash partitions continue to work after they're concurrently +-- detached (bugs #18371, #19070) +CREATE TABLE hash_parted2 (a int) PARTITION BY HASH(a) +-- +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: CreateStmt +== 1495 +CREATE TABLE part_hp PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="part_hp" schema="" table="part_hp" ctx=DDL +STMT: CreateStmt +== 1496 +ALTER TABLE hash_parted2 DETACH PARTITION part_hp CONCURRENTLY +-- +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: AlterTableStmt +== 1497 +DROP TABLE hash_parted2 +-- +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: DropStmt +== 1498 +INSERT INTO part_hp VALUES (1) +-- +TABLE: name="part_hp" schema="" table="part_hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1499 +DROP TABLE part_hp +-- +TABLE: name="part_hp" schema="" table="part_hp" ctx=DDL +STMT: DropStmt +== 1500 +-- Check ALTER TABLE commands for partitioned tables and partitions + +-- cannot add/drop column to/from *only* the parent +ALTER TABLE ONLY list_parted2 ADD COLUMN c int +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1501 +ALTER TABLE ONLY list_parted2 DROP COLUMN b +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1502 +-- cannot add a column to partition or drop an inherited one +ALTER TABLE part_2 ADD COLUMN c text +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +== 1503 +ALTER TABLE part_2 DROP COLUMN b +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +== 1504 +-- Nor rename, alter type +ALTER TABLE part_2 RENAME COLUMN b to c +-- +STMT: RenameStmt +== 1505 +ALTER TABLE part_2 ALTER COLUMN b TYPE text +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +== 1506 +-- cannot add/drop NOT NULL or check constraints to *only* the parent, when +-- partitions exist +ALTER TABLE ONLY list_parted2 ALTER b SET NOT NULL +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1507 +ALTER TABLE ONLY list_parted2 ADD CONSTRAINT check_b CHECK (b <> 'zz') +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1508 +ALTER TABLE list_parted2 ALTER b SET NOT NULL +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1509 +ALTER TABLE ONLY list_parted2 ALTER b DROP NOT NULL +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1510 +ALTER TABLE list_parted2 ADD CONSTRAINT check_b CHECK (b <> 'zz') +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1511 +ALTER TABLE ONLY list_parted2 DROP CONSTRAINT check_b +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1512 +-- It's alright though, if no partitions are yet created +CREATE TABLE parted_no_parts (a int) PARTITION BY LIST (a) +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: CreateStmt +== 1513 +ALTER TABLE ONLY parted_no_parts ALTER a SET NOT NULL +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: AlterTableStmt +== 1514 +ALTER TABLE ONLY parted_no_parts ADD CONSTRAINT check_a CHECK (a > 0) +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: AlterTableStmt +== 1515 +ALTER TABLE ONLY parted_no_parts ALTER a DROP NOT NULL +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: AlterTableStmt +== 1516 +ALTER TABLE ONLY parted_no_parts DROP CONSTRAINT check_a +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: AlterTableStmt +== 1517 +DROP TABLE parted_no_parts +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: DropStmt +== 1518 +-- cannot drop inherited NOT NULL or check constraints from partition +ALTER TABLE list_parted2 ALTER b SET NOT NULL, ADD CONSTRAINT check_a2 CHECK (a > 0) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1519 +ALTER TABLE part_2 ALTER b DROP NOT NULL +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +== 1520 +ALTER TABLE part_2 DROP CONSTRAINT check_a2 +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +== 1521 +-- Doesn't make sense to add NO INHERIT constraints on partitioned tables +ALTER TABLE list_parted2 add constraint check_b2 check (b <> 'zz') NO INHERIT +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1522 +-- check that a partition cannot participate in regular inheritance +CREATE TABLE inh_test () INHERITS (part_2) +-- +TABLE: name="inh_test" schema="" table="inh_test" ctx=DDL +STMT: CreateStmt +== 1523 +CREATE TABLE inh_test (LIKE part_2) +-- +TABLE: name="inh_test" schema="" table="inh_test" ctx=DDL +STMT: CreateStmt +== 1524 +ALTER TABLE inh_test INHERIT part_2 +-- +TABLE: name="inh_test" schema="" table="inh_test" ctx=DDL +STMT: AlterTableStmt +== 1525 +ALTER TABLE part_2 INHERIT inh_test +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +== 1526 +-- cannot drop or alter type of partition key columns of lower level +-- partitioned tables; for example, part_5, which is list_parted2's +-- partition, is partitioned on b; +ALTER TABLE list_parted2 DROP COLUMN b +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1527 +ALTER TABLE list_parted2 ALTER COLUMN b TYPE text +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +== 1528 +-- dropping non-partition key columns should be allowed on the parent table. +ALTER TABLE list_parted DROP COLUMN b +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 1529 +SELECT * FROM list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 1530 +-- cleanup +DROP TABLE list_parted, list_parted2, range_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 1531 +DROP TABLE fail_def_part +-- +TABLE: name="fail_def_part" schema="" table="fail_def_part" ctx=DDL +STMT: DropStmt +== 1532 +DROP TABLE hash_parted +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: DropStmt +== 1533 +-- more tests for certain multi-level partitioning scenarios +create table p (a int, b int) partition by range (a, b) +-- +TABLE: name="p" schema="" table="p" ctx=DDL +STMT: CreateStmt +== 1534 +create table p1 (b int, a int not null) partition by range (b) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 1535 +create table p11 (like p1) +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: CreateStmt +== 1536 +alter table p11 drop a +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: AlterTableStmt +== 1537 +alter table p11 add a int +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: AlterTableStmt +== 1538 +alter table p11 drop a +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: AlterTableStmt +== 1539 +alter table p11 add a int not null +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: AlterTableStmt +== 1540 +-- attnum for key attribute 'a' is different in p, p1, and p11 +select attrelid::regclass, attname, attnum +from pg_attribute +where attname = 'a' + and (attrelid = 'p'::regclass + or attrelid = 'p1'::regclass + or attrelid = 'p11'::regclass) +order by attrelid::regclass::text +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attname" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +== 1541 +alter table p1 attach partition p11 for values from (2) to (5) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 1542 +insert into p1 (a, b) values (2, 3) +-- +TABLE: name="p1" schema="" table="p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1543 +-- check that partition validation scan correctly detects violating rows +alter table p attach partition p1 for values from (1, 2) to (1, 10) +-- +TABLE: name="p" schema="" table="p" ctx=DDL +STMT: AlterTableStmt +== 1544 +-- cleanup +drop table p +-- +TABLE: name="p" schema="" table="p" ctx=DDL +STMT: DropStmt +== 1545 +drop table p1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 1546 +-- validate constraint on partitioned tables should only scan leaf partitions +create table parted_validate_test (a int) partition by list (a) +-- +TABLE: name="parted_validate_test" schema="" table="parted_validate_test" ctx=DDL +STMT: CreateStmt +== 1547 +create table parted_validate_test_1 partition of parted_validate_test for values in (0, 1) +-- +TABLE: name="parted_validate_test_1" schema="" table="parted_validate_test_1" ctx=DDL +STMT: CreateStmt +== 1548 +alter table parted_validate_test add constraint parted_validate_test_chka check (a > 0) not valid +-- +TABLE: name="parted_validate_test" schema="" table="parted_validate_test" ctx=DDL +STMT: AlterTableStmt +== 1549 +alter table parted_validate_test validate constraint parted_validate_test_chka +-- +TABLE: name="parted_validate_test" schema="" table="parted_validate_test" ctx=DDL +STMT: AlterTableStmt +== 1550 +drop table parted_validate_test +-- +TABLE: name="parted_validate_test" schema="" table="parted_validate_test" ctx=DDL +STMT: DropStmt +== 1551 +-- test alter column options +CREATE TABLE attmp(i integer) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +== 1552 +INSERT INTO attmp VALUES (1) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1553 +ALTER TABLE attmp ALTER COLUMN i SET (n_distinct = 1, n_distinct_inherited = 2) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 1554 +ALTER TABLE attmp ALTER COLUMN i RESET (n_distinct_inherited) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +== 1555 +ANALYZE attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: VacuumStmt +== 1556 +DROP TABLE attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: DropStmt +== 1557 +DROP USER regress_alter_table_user1 +-- +STMT: DropRoleStmt +== 1558 +-- check that violating rows are correctly reported when attaching as the +-- default partition +create table defpart_attach_test (a int) partition by list (a) +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: CreateStmt +== 1559 +create table defpart_attach_test1 partition of defpart_attach_test for values in (1) +-- +TABLE: name="defpart_attach_test1" schema="" table="defpart_attach_test1" ctx=DDL +STMT: CreateStmt +== 1560 +create table defpart_attach_test_d (b int, a int) +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DDL +STMT: CreateStmt +== 1561 +alter table defpart_attach_test_d drop b +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DDL +STMT: AlterTableStmt +== 1562 +insert into defpart_attach_test_d values (1), (2) +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1563 +-- error because its constraint as the default partition would be violated +-- by the row containing 1 +alter table defpart_attach_test attach partition defpart_attach_test_d default +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: AlterTableStmt +== 1564 +delete from defpart_attach_test_d where a = 1 +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DML +STMT: DeleteStmt +== 1565 +alter table defpart_attach_test_d add check (a > 1) +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DDL +STMT: AlterTableStmt +== 1566 +-- should be attached successfully and without needing to be scanned +alter table defpart_attach_test attach partition defpart_attach_test_d default +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: AlterTableStmt +== 1567 +-- check that attaching a partition correctly reports any rows in the default +-- partition that should not be there for the new partition to be attached +-- successfully +create table defpart_attach_test_2 (like defpart_attach_test_d) +-- +TABLE: name="defpart_attach_test_2" schema="" table="defpart_attach_test_2" ctx=DDL +STMT: CreateStmt +== 1568 +alter table defpart_attach_test attach partition defpart_attach_test_2 for values in (2) +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: AlterTableStmt +== 1569 +drop table defpart_attach_test +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: DropStmt +== 1570 +-- check combinations of temporary and permanent relations when attaching +-- partitions. +create table perm_part_parent (a int) partition by list (a) +-- +TABLE: name="perm_part_parent" schema="" table="perm_part_parent" ctx=DDL +STMT: CreateStmt +== 1571 +create temp table temp_part_parent (a int) partition by list (a) +-- +TABLE: name="temp_part_parent" schema="" table="temp_part_parent" ctx=DDL +STMT: CreateStmt +== 1572 +create table perm_part_child (a int) +-- +TABLE: name="perm_part_child" schema="" table="perm_part_child" ctx=DDL +STMT: CreateStmt +== 1573 +create temp table temp_part_child (a int) +-- +TABLE: name="temp_part_child" schema="" table="temp_part_child" ctx=DDL +STMT: CreateStmt +== 1574 +alter table temp_part_parent attach partition perm_part_child default +-- +TABLE: name="temp_part_parent" schema="" table="temp_part_parent" ctx=DDL +STMT: AlterTableStmt +== 1575 +-- error +alter table perm_part_parent attach partition temp_part_child default +-- +TABLE: name="perm_part_parent" schema="" table="perm_part_parent" ctx=DDL +STMT: AlterTableStmt +== 1576 +-- error +alter table temp_part_parent attach partition temp_part_child default +-- +TABLE: name="temp_part_parent" schema="" table="temp_part_parent" ctx=DDL +STMT: AlterTableStmt +== 1577 +-- ok +drop table perm_part_parent cascade +-- +TABLE: name="perm_part_parent" schema="" table="perm_part_parent" ctx=DDL +STMT: DropStmt +== 1578 +drop table temp_part_parent cascade +-- +TABLE: name="temp_part_parent" schema="" table="temp_part_parent" ctx=DDL +STMT: DropStmt +== 1579 +-- check that attaching partitions to a table while it is being used is +-- prevented +create table tab_part_attach (a int) partition by list (a) +-- +TABLE: name="tab_part_attach" schema="" table="tab_part_attach" ctx=DDL +STMT: CreateStmt +== 1580 +create or replace function func_part_attach() returns trigger + language plpgsql as $$ + begin + execute 'create table tab_part_attach_1 (a int)'; + execute 'alter table tab_part_attach attach partition tab_part_attach_1 for values in (1)'; + return null; + end $$ +-- +FUNCTION: name="func_part_attach" function="func_part_attach" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1581 +create trigger trig_part_attach before insert on tab_part_attach + for each statement execute procedure func_part_attach() +-- +TABLE: name="tab_part_attach" schema="" table="tab_part_attach" ctx=DDL +STMT: CreateTrigStmt +== 1582 +insert into tab_part_attach values (1) +-- +TABLE: name="tab_part_attach" schema="" table="tab_part_attach" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1583 +drop table tab_part_attach +-- +TABLE: name="tab_part_attach" schema="" table="tab_part_attach" ctx=DDL +STMT: DropStmt +== 1584 +drop function func_part_attach() +-- +FUNCTION: name="func_part_attach" function="func_part_attach" schema="" ctx=DDL +STMT: DropStmt +== 1585 +-- test case where the partitioning operator is a SQL function whose +-- evaluation results in the table's relcache being rebuilt partway through +-- the execution of an ATTACH PARTITION command +create function at_test_sql_partop (int4, int4) returns int language sql +as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$ +-- +FUNCTION: name="at_test_sql_partop" function="at_test_sql_partop" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1586 +create operator class at_test_sql_partop for type int4 using btree as + operator 1 < (int4, int4), operator 2 <= (int4, int4), + operator 3 = (int4, int4), operator 4 >= (int4, int4), + operator 5 > (int4, int4), function 1 at_test_sql_partop(int4, int4) +-- +STMT: CreateOpClassStmt +== 1587 +create table at_test_sql_partop (a int) partition by range (a at_test_sql_partop) +-- +TABLE: name="at_test_sql_partop" schema="" table="at_test_sql_partop" ctx=DDL +STMT: CreateStmt +== 1588 +create table at_test_sql_partop_1 (a int) +-- +TABLE: name="at_test_sql_partop_1" schema="" table="at_test_sql_partop_1" ctx=DDL +STMT: CreateStmt +== 1589 +alter table at_test_sql_partop attach partition at_test_sql_partop_1 for values from (0) to (10) +-- +TABLE: name="at_test_sql_partop" schema="" table="at_test_sql_partop" ctx=DDL +STMT: AlterTableStmt +== 1590 +drop table at_test_sql_partop +-- +TABLE: name="at_test_sql_partop" schema="" table="at_test_sql_partop" ctx=DDL +STMT: DropStmt +== 1591 +drop operator class at_test_sql_partop using btree +-- +STMT: DropStmt +== 1592 +drop function at_test_sql_partop +-- +FUNCTION: name="at_test_sql_partop" function="at_test_sql_partop" schema="" ctx=DDL +STMT: DropStmt +== 1593 +/* Test case for bug #16242 */ + +-- We create a parent and child where the child has missing +-- non-null attribute values, and arrange to pass them through +-- tuple conversion from the child to the parent tupdesc +create table bar1 (a integer, b integer not null default 1) + partition by range (a) +-- +TABLE: name="bar1" schema="" table="bar1" ctx=DDL +STMT: CreateStmt +== 1594 +create table bar2 (a integer) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DDL +STMT: CreateStmt +== 1595 +insert into bar2 values (1) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1596 +alter table bar2 add column b integer not null default 1 +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DDL +STMT: AlterTableStmt +== 1597 +-- (at this point bar2 contains tuple with natts=1) +alter table bar1 attach partition bar2 default +-- +TABLE: name="bar1" schema="" table="bar1" ctx=DDL +STMT: AlterTableStmt +== 1598 +-- this works: +select * from bar1 +-- +TABLE: name="bar1" schema="" table="bar1" ctx=Select +STMT: SelectStmt +== 1599 +-- this exercises tuple conversion: +create function xtrig() + returns trigger language plpgsql +as $$ + declare + r record; + begin + for r in select * from old loop + raise info 'a=%, b=%', r.a, r.b; + end loop; + return NULL; + end; +$$ +-- +FUNCTION: name="xtrig" function="xtrig" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1600 +create trigger xtrig + after update on bar1 + referencing old table as old + for each statement execute procedure xtrig() +-- +TABLE: name="bar1" schema="" table="bar1" ctx=DDL +STMT: CreateTrigStmt +== 1601 +update bar1 set a = a + 1 +-- +TABLE: name="bar1" schema="" table="bar1" ctx=DML +STMT: UpdateStmt +== 1602 +/* End test case for bug #16242 */ + +/* Test case for bug #17409 */ + +create table attbl (p1 int constraint pk_attbl primary key) +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: CreateStmt +== 1603 +create table atref (c1 int references attbl(p1)) +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: CreateStmt +== 1604 +cluster attbl using pk_attbl +-- +STMT: ClusterStmt +== 1605 +alter table attbl alter column p1 set data type bigint +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +== 1606 +alter table atref alter column c1 set data type bigint +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: AlterTableStmt +== 1607 +drop table attbl, atref +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: DropStmt +== 1608 +create table attbl (p1 int constraint pk_attbl primary key) +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: CreateStmt +== 1609 +alter table attbl replica identity using index pk_attbl +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +== 1610 +create table atref (c1 int references attbl(p1)) +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: CreateStmt +== 1611 +alter table attbl alter column p1 set data type bigint +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +== 1612 +alter table atref alter column c1 set data type bigint +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: AlterTableStmt +== 1613 +drop table attbl, atref +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: DropStmt +== 1614 +/* End test case for bug #17409 */ + +/* Test case for bug #18970 */ + +create table attbl(a int) +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: CreateStmt +== 1615 +create table atref(b attbl check ((b).a is not null)) +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: CreateStmt +== 1616 +alter table attbl alter column a type numeric +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +== 1617 +-- someday this should work +alter table atref drop constraint atref_b_check +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: AlterTableStmt +== 1618 +create statistics atref_stat on ((b).a is not null) from atref +-- +STMT: CreateStatsStmt +== 1619 +alter table attbl alter column a type numeric +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +== 1620 +-- someday this should work +drop statistics atref_stat +-- +STMT: DropStmt +== 1621 +create index atref_idx on atref (((b).a)) +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: IndexStmt +== 1622 +alter table attbl alter column a type numeric +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +== 1623 +-- someday this should work +drop table attbl, atref +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: DropStmt +== 1624 +/* End test case for bug #18970 */ + +-- Test that ALTER TABLE rewrite preserves a clustered index +-- for normal indexes and indexes on constraints. +create table alttype_cluster (a int) +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: CreateStmt +== 1625 +alter table alttype_cluster add primary key (a) +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +== 1626 +create index alttype_cluster_ind on alttype_cluster (a) +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: IndexStmt +== 1627 +alter table alttype_cluster cluster on alttype_cluster_ind +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +== 1628 +-- Normal index remains clustered. +select indexrelid::regclass, indisclustered from pg_index + where indrelid = 'alttype_cluster'::regclass + order by indexrelid::regclass::text +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 1629 +alter table alttype_cluster alter a type bigint +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +== 1630 +select indexrelid::regclass, indisclustered from pg_index + where indrelid = 'alttype_cluster'::regclass + order by indexrelid::regclass::text +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 1631 +-- Constraint index remains clustered. +alter table alttype_cluster cluster on alttype_cluster_pkey +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +== 1632 +select indexrelid::regclass, indisclustered from pg_index + where indrelid = 'alttype_cluster'::regclass + order by indexrelid::regclass::text +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 1633 +alter table alttype_cluster alter a type int +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +== 1634 +select indexrelid::regclass, indisclustered from pg_index + where indrelid = 'alttype_cluster'::regclass + order by indexrelid::regclass::text +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 1635 +drop table alttype_cluster +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: DropStmt +== 1636 +|-- +-- Check that attaching or detaching a partitioned partition correctly leads +-- to its partitions' constraint being updated to reflect the parent's +-- newly added/removed constraint +create table target_parted (a int, b int) partition by list (a) +-- +TABLE: name="target_parted" schema="" table="target_parted" ctx=DDL +STMT: CreateStmt +== 1637 +create table attach_parted (a int, b int) partition by list (b) +-- +TABLE: name="attach_parted" schema="" table="attach_parted" ctx=DDL +STMT: CreateStmt +== 1638 +create table attach_parted_part1 partition of attach_parted for values in (1) +-- +TABLE: name="attach_parted_part1" schema="" table="attach_parted_part1" ctx=DDL +STMT: CreateStmt +== 1639 +-- insert a row directly into the leaf partition so that its partition +-- constraint is built and stored in the relcache +insert into attach_parted_part1 values (1, 1) +-- +TABLE: name="attach_parted_part1" schema="" table="attach_parted_part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1640 +-- the following better invalidate the partition constraint of the leaf +-- partition too... +alter table target_parted attach partition attach_parted for values in (1) +-- +TABLE: name="target_parted" schema="" table="target_parted" ctx=DDL +STMT: AlterTableStmt +== 1641 +-- ...such that the following insert fails +insert into attach_parted_part1 values (2, 1) +-- +TABLE: name="attach_parted_part1" schema="" table="attach_parted_part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1642 +-- ...and doesn't when the partition is detached along with its own partition +alter table target_parted detach partition attach_parted +-- +TABLE: name="target_parted" schema="" table="target_parted" ctx=DDL +STMT: AlterTableStmt +== 1643 +insert into attach_parted_part1 values (2, 1) +-- +TABLE: name="attach_parted_part1" schema="" table="attach_parted_part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1644 +-- Test altering table having publication +create schema alter1 +-- +STMT: CreateSchemaStmt +== 1645 +create schema alter2 +-- +STMT: CreateSchemaStmt +== 1646 +create table alter1.t1 (a int) +-- +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=DDL +STMT: CreateStmt +== 1647 +set client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 1648 +create publication pub1 for table alter1.t1, tables in schema alter2 +-- +STMT: CreatePublicationStmt +== 1649 +reset client_min_messages +-- +STMT: VariableSetStmt +== 1650 +alter table alter1.t1 set schema alter2 +-- +STMT: AlterObjectSchemaStmt +== 1651 +drop publication pub1 +-- +STMT: DropStmt +== 1652 +drop schema alter1 cascade +-- +STMT: DropStmt +== 1653 +drop schema alter2 cascade +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/amutils.metadata.json b/parser/testdata/summary/postgres_regress/amutils.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/amutils.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/amutils.test b/parser/testdata/summary/postgres_regress/amutils.test new file mode 100644 index 0000000..a8c5b0c --- /dev/null +++ b/parser/testdata/summary/postgres_regress/amutils.test @@ -0,0 +1,161 @@ +== 001 +|-- +-- Test index AM property-reporting functions +|-- + +select prop, + pg_indexam_has_property(a.oid, prop) as "AM", + pg_index_has_property('onek_hundred'::regclass, prop) as "Index", + pg_index_column_has_property('onek_hundred'::regclass, 1, prop) as "Column" + from pg_am a, + unnest(array['asc', 'desc', 'nulls_first', 'nulls_last', + 'orderable', 'distance_orderable', 'returnable', + 'search_array', 'search_nulls', + 'clusterable', 'index_scan', 'bitmap_scan', + 'backward_scan', + 'can_order', 'can_unique', 'can_multi_col', + 'can_exclude', 'can_include', + 'bogus']::text[]) + with ordinality as u(prop,ord) + where a.amname = 'btree' + order by ord +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +FUNCTION: name="pg_indexam_has_property" function="pg_indexam_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="a" column="amname" +STMT: SelectStmt +== 002 +select prop, + pg_indexam_has_property(a.oid, prop) as "AM", + pg_index_has_property('gcircleind'::regclass, prop) as "Index", + pg_index_column_has_property('gcircleind'::regclass, 1, prop) as "Column" + from pg_am a, + unnest(array['asc', 'desc', 'nulls_first', 'nulls_last', + 'orderable', 'distance_orderable', 'returnable', + 'search_array', 'search_nulls', + 'clusterable', 'index_scan', 'bitmap_scan', + 'backward_scan', + 'can_order', 'can_unique', 'can_multi_col', + 'can_exclude', 'can_include', + 'bogus']::text[]) + with ordinality as u(prop,ord) + where a.amname = 'gist' + order by ord +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +FUNCTION: name="pg_indexam_has_property" function="pg_indexam_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="a" column="amname" +STMT: SelectStmt +== 003 +select prop, + pg_index_column_has_property('onek_hundred'::regclass, 1, prop) as btree, + pg_index_column_has_property('hash_i4_index'::regclass, 1, prop) as hash, + pg_index_column_has_property('gcircleind'::regclass, 1, prop) as gist, + pg_index_column_has_property('sp_radix_ind'::regclass, 1, prop) as spgist_radix, + pg_index_column_has_property('sp_quad_ind'::regclass, 1, prop) as spgist_quad, + pg_index_column_has_property('botharrayidx'::regclass, 1, prop) as gin, + pg_index_column_has_property('brinidx'::regclass, 1, prop) as brin + from unnest(array['asc', 'desc', 'nulls_first', 'nulls_last', + 'orderable', 'distance_orderable', 'returnable', + 'search_array', 'search_nulls', + 'bogus']::text[]) + with ordinality as u(prop,ord) + order by ord +-- +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 004 +select prop, + pg_index_has_property('onek_hundred'::regclass, prop) as btree, + pg_index_has_property('hash_i4_index'::regclass, prop) as hash, + pg_index_has_property('gcircleind'::regclass, prop) as gist, + pg_index_has_property('sp_radix_ind'::regclass, prop) as spgist, + pg_index_has_property('botharrayidx'::regclass, prop) as gin, + pg_index_has_property('brinidx'::regclass, prop) as brin + from unnest(array['clusterable', 'index_scan', 'bitmap_scan', + 'backward_scan', + 'bogus']::text[]) + with ordinality as u(prop,ord) + order by ord +-- +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 005 +select amname, prop, pg_indexam_has_property(a.oid, prop) as p + from pg_am a, + unnest(array['can_order', 'can_unique', 'can_multi_col', + 'can_exclude', 'can_include', 'bogus']::text[]) + with ordinality as u(prop,ord) + where amtype = 'i' + order by amname, ord +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +FUNCTION: name="pg_indexam_has_property" function="pg_indexam_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="" column="amtype" +STMT: SelectStmt +== 006 +|-- +-- additional checks for pg_index_column_has_property +|-- +CREATE TEMP TABLE foo (f1 int, f2 int, f3 int, f4 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 007 +CREATE INDEX fooindex ON foo (f1 desc, f2 asc, f3 nulls first, f4 nulls last) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +== 008 +select col, prop, pg_index_column_has_property(o, col, prop) + from (values ('fooindex'::regclass)) v1(o), + (values (1,'orderable'),(2,'asc'),(3,'desc'), + (4,'nulls_first'),(5,'nulls_last'), + (6, 'bogus')) v2(idx,prop), + generate_series(1,4) col + order by col, idx +-- +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 009 +CREATE INDEX foocover ON foo (f1) INCLUDE (f2,f3) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +== 010 +select col, prop, pg_index_column_has_property(o, col, prop) + from (values ('foocover'::regclass)) v1(o), + (values (1,'orderable'),(2,'asc'),(3,'desc'), + (4,'nulls_first'),(5,'nulls_last'), + (6,'distance_orderable'),(7,'returnable'), + (8, 'bogus')) v2(idx,prop), + generate_series(1,3) col + order by col, idx +-- +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/arrays.metadata.json b/parser/testdata/summary/postgres_regress/arrays.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/arrays.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/arrays.test b/parser/testdata/summary/postgres_regress/arrays.test new file mode 100644 index 0000000..2fc9d59 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/arrays.test @@ -0,0 +1,2785 @@ +== 001 +|-- +-- ARRAYS +|-- + +-- directory paths are passed to us in environment variables + +CREATE TABLE arrtest ( + a int2[], + b int4[][][], + c name[], + d text[][], + e float8[], + f char(5)[], + g varchar(5)[] +) +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE array_op_test ( + seqno int4, + i int4[], + t text[] +) +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=DDL +STMT: CreateStmt +== 003 +COPY array_op_test FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +ANALYZE array_op_test +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=DDL +STMT: VacuumStmt +== 005 +|-- +-- only the 'e' array is 0-based, the others are 1-based. +|-- + +INSERT INTO arrtest (a[1:5], b[1:1][1:2][1:2], c, d, f, g) + VALUES ('{1,2,3,4,5}', '{{{0,0},{1,2}}}', '{}', '{}', '{}', '{}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +UPDATE arrtest SET e[0] = '1.1' +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: UpdateStmt +== 007 +UPDATE arrtest SET e[1] = '2.2' +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: UpdateStmt +== 008 +INSERT INTO arrtest (f) + VALUES ('{"too long"}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO arrtest (a, b[1:2][1:2], c, d, e, f, g) + VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}', + '{{"elt1", "elt2"}}', '{"3.4", "6.7"}', + '{"abc","abcde"}', '{"abc","abcde"}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO arrtest (a, b[1:2], c, d[1:2]) + VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO arrtest (b[2]) VALUES(now()) +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 012 +-- error, type mismatch + +INSERT INTO arrtest (b[1:2]) VALUES(now()) +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 013 +-- error, type mismatch + +SELECT * FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 014 +SELECT arrtest.a[1], + arrtest.b[1][1][1], + arrtest.c[1], + arrtest.d[1][1], + arrtest.e[0] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 015 +SELECT a[1], b[1][1][1], c[1], d[1][1], e[0] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 016 +SELECT a[1:3], + b[1:1][1:2][1:2], + c[1:2], + d[1:1][1:2] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 017 +SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FUNCTION: name="array_ndims" function="array_ndims" schema="" ctx=Call +FUNCTION: name="array_ndims" function="array_ndims" schema="" ctx=Call +FUNCTION: name="array_ndims" function="array_ndims" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- returns nothing +SELECT * + FROM arrtest + WHERE a[1] < 5 and + c = '{"foobar"}'::_name +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="c" +STMT: SelectStmt +== 020 +UPDATE arrtest + SET a[1:2] = '{16,25}' + WHERE NOT a = '{}'::_int2 +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: UpdateStmt +== 021 +UPDATE arrtest + SET b[1:1][1:1][1:2] = '{113, 117}', + b[1:1][1:2][2:2] = '{142, 147}' + WHERE array_dims(b) = '[1:1][1:2][1:2]' +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +== 022 +UPDATE arrtest + SET c[2:2] = '{"new_word"}' + WHERE array_dims(c) is not null +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +== 023 +SELECT a,b,c FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 024 +SELECT a[1:3], + b[1:1][1:2][1:2], + c[1:2], + d[1:1][2:2] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 025 +SELECT b[1:1][2][2], + d[1:1][2] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 026 +INSERT INTO arrtest(a) VALUES('{1,null,3}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +SELECT a FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 028 +UPDATE arrtest SET a[4] = NULL WHERE a[2] IS NULL +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: UpdateStmt +== 029 +SELECT a FROM arrtest WHERE a[2] IS NULL +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 030 +DELETE FROM arrtest WHERE a[2] IS NULL AND b IS NULL +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: DeleteStmt +== 031 +SELECT a,b,c FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +== 032 +-- test non-error-throwing API +SELECT pg_input_is_valid('{1,2,3}', 'integer[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT pg_input_is_valid('{1,2', 'integer[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT pg_input_is_valid('{1,zed}', 'integer[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT * FROM pg_input_error_info('{1,zed}', 'integer[]') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- test mixed slice/scalar subscripting +select '{{1,2,3},{4,5,6},{7,8,9}}'::int[] +-- +STMT: SelectStmt +== 037 +select ('{{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2] +-- +STMT: SelectStmt +== 038 +select '[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[] +-- +STMT: SelectStmt +== 039 +select ('[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2] +-- +STMT: SelectStmt +== 040 +|-- +-- check subscription corner cases +|-- +-- More subscripts than MAXDIM (6) +SELECT ('{}'::int[])[1][2][3][4][5][6][7] +-- +STMT: SelectStmt +== 041 +-- NULL index yields NULL when selecting +SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL][1] +-- +STMT: SelectStmt +== 042 +SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL:1][1] +-- +STMT: SelectStmt +== 043 +SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][1:NULL][1] +-- +STMT: SelectStmt +== 044 +-- NULL index in assignment is an error +UPDATE arrtest + SET c[NULL] = '{"can''t assign"}' + WHERE array_dims(c) is not null +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +== 045 +UPDATE arrtest + SET c[NULL:1] = '{"can''t assign"}' + WHERE array_dims(c) is not null +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +== 046 +UPDATE arrtest + SET c[1:NULL] = '{"can''t assign"}' + WHERE array_dims(c) is not null +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +== 047 +-- Un-subscriptable type +SELECT (now())[1] +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 048 +-- test slices with empty lower and/or upper index +CREATE TEMP TABLE arrtest_s ( + a int2[], + b int2[][] +) +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DDL +STMT: CreateStmt +== 049 +INSERT INTO arrtest_s VALUES ('{1,2,3,4,5}', '{{1,2,3}, {4,5,6}, {7,8,9}}') +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO arrtest_s VALUES ('[0:4]={1,2,3,4,5}', '[0:2][0:2]={{1,2,3}, {4,5,6}, {7,8,9}}') +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +SELECT * FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +== 052 +SELECT a[:3], b[:2][:2] FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +== 053 +SELECT a[2:], b[2:][2:] FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +== 054 +SELECT a[:], b[:] FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +== 055 +-- updates +UPDATE arrtest_s SET a[:3] = '{11, 12, 13}', b[:2][:2] = '{{11,12}, {14,15}}' + WHERE array_lower(a,1) = 1 +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +STMT: UpdateStmt +== 056 +SELECT * FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +== 057 +UPDATE arrtest_s SET a[3:] = '{23, 24, 25}', b[2:][2:] = '{{25,26}, {28,29}}' +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: UpdateStmt +== 058 +SELECT * FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +== 059 +UPDATE arrtest_s SET a[:] = '{11, 12, 13, 14, 15}' +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: UpdateStmt +== 060 +SELECT * FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +== 061 +UPDATE arrtest_s SET a[:] = '{23, 24, 25}' +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: UpdateStmt +== 062 +-- fail, too small +INSERT INTO arrtest_s VALUES(NULL, NULL) +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +UPDATE arrtest_s SET a[:] = '{11, 12, 13, 14, 15}' +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: UpdateStmt +== 064 +-- fail, no good with null + +-- we want to work with a point_tbl that includes a null +CREATE TEMP TABLE point_tbl AS SELECT * FROM public.point_tbl +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DDL +TABLE: name="public.point_tbl" schema="public" table="point_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 065 +INSERT INTO POINT_TBL(f1) VALUES (NULL) +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 066 +-- check with fixed-length-array type, such as point +SELECT f1[0:1] FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +== 067 +SELECT f1[0:] FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +== 068 +SELECT f1[:1] FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +== 069 +SELECT f1[:] FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +== 070 +-- subscript assignments to fixed-width result in NULL if previous value is NULL +UPDATE point_tbl SET f1[0] = 10 WHERE f1 IS NULL RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: UpdateStmt +== 071 +INSERT INTO point_tbl(f1[0]) VALUES(0) RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +-- NULL assignments get ignored +UPDATE point_tbl SET f1[0] = NULL WHERE f1::text = '(10,10)'::point::text RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: UpdateStmt +== 073 +-- but non-NULL subscript assignments work +UPDATE point_tbl SET f1[0] = -10, f1[1] = -10 WHERE f1::text = '(10,10)'::point::text RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: UpdateStmt +== 074 +-- but not to expand the range +UPDATE point_tbl SET f1[3] = 10 WHERE f1::text = '(-10,-10)'::point::text RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: UpdateStmt +== 075 +|-- +-- test array extension +|-- +CREATE TEMP TABLE arrtest1 (i int[], t text[]) +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DDL +STMT: CreateStmt +== 076 +insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']) +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 078 +update arrtest1 set i[2] = 22, t[2] = 'twenty-two' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 079 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 080 +update arrtest1 set i[5] = 5, t[5] = 'five' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 081 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 082 +update arrtest1 set i[8] = 8, t[8] = 'eight' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 083 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 084 +update arrtest1 set i[0] = 0, t[0] = 'zero' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 085 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 086 +update arrtest1 set i[-3] = -3, t[-3] = 'minus-three' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 087 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 088 +update arrtest1 set i[0:2] = array[10,11,12], t[0:2] = array['ten','eleven','twelve'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 089 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 090 +update arrtest1 set i[8:10] = array[18,null,20], t[8:10] = array['p18',null,'p20'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 091 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 092 +update arrtest1 set i[11:12] = array[null,22], t[11:12] = array[null,'p22'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 093 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 094 +update arrtest1 set i[15:16] = array[null,26], t[15:16] = array[null,'p26'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 095 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 096 +update arrtest1 set i[-5:-3] = array[-15,-14,-13], t[-5:-3] = array['m15','m14','m13'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 097 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 098 +update arrtest1 set i[-7:-6] = array[-17,null], t[-7:-6] = array['m17',null] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 099 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 100 +update arrtest1 set i[-12:-10] = array[-22,null,-20], t[-12:-10] = array['m22',null,'m20'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 101 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 102 +delete from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: DeleteStmt +== 103 +insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']) +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 105 +update arrtest1 set i[0:5] = array[0,1,2,null,4,5], t[0:5] = array['z','p1','p2',null,'p4','p5'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +== 106 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +== 107 +|-- +-- array expressions and operators +|-- + +-- table creation and INSERTs +CREATE TEMP TABLE arrtest2 (i integer ARRAY[4], f float8[], n numeric[], t text[], d timestamp[]) +-- +TABLE: name="arrtest2" schema="" table="arrtest2" ctx=DDL +STMT: CreateStmt +== 108 +INSERT INTO arrtest2 VALUES( + ARRAY[[[113,142],[1,147]]], + ARRAY[1.1,1.2,1.3]::float8[], + ARRAY[1.1,1.2,1.3], + ARRAY[[['aaa','aab'],['aba','abb'],['aca','acb']],[['baa','bab'],['bba','bbb'],['bca','bcb']]], + ARRAY['19620326','19931223','19970117']::timestamp[] +) +-- +TABLE: name="arrtest2" schema="" table="arrtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +-- some more test data +CREATE TEMP TABLE arrtest_f (f0 int, f1 text, f2 float8) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DDL +STMT: CreateStmt +== 110 +insert into arrtest_f values(1,'cat1',1.21) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +insert into arrtest_f values(2,'cat1',1.24) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 112 +insert into arrtest_f values(3,'cat1',1.18) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 113 +insert into arrtest_f values(4,'cat1',1.26) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 114 +insert into arrtest_f values(5,'cat1',1.15) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +insert into arrtest_f values(6,'cat2',1.15) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +insert into arrtest_f values(7,'cat2',1.26) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +insert into arrtest_f values(8,'cat2',1.32) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 118 +insert into arrtest_f values(9,'cat2',1.30) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 119 +CREATE TEMP TABLE arrtest_i (f0 int, f1 text, f2 int) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DDL +STMT: CreateStmt +== 120 +insert into arrtest_i values(1,'cat1',21) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +insert into arrtest_i values(2,'cat1',24) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +insert into arrtest_i values(3,'cat1',18) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +insert into arrtest_i values(4,'cat1',26) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 124 +insert into arrtest_i values(5,'cat1',15) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 125 +insert into arrtest_i values(6,'cat2',15) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 126 +insert into arrtest_i values(7,'cat2',26) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 127 +insert into arrtest_i values(8,'cat2',32) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 128 +insert into arrtest_i values(9,'cat2',30) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +-- expressions +SELECT t.f[1][3][1] AS "131", t.f[2][2][1] AS "221" FROM ( + SELECT ARRAY[[[111,112],[121,122],[131,132]],[[211,212],[221,122],[231,232]]] AS f +) AS t +-- +STMT: SelectStmt +== 130 +SELECT ARRAY[[[[[['hello'],['world']]]]]] +-- +STMT: SelectStmt +== 131 +SELECT ARRAY[ARRAY['hello'],ARRAY['world']] +-- +STMT: SelectStmt +== 132 +SELECT ARRAY(select f2 from arrtest_f order by f2) AS "ARRAY" +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=Select +STMT: SelectStmt +== 133 +-- with nulls +SELECT '{1,null,3}'::int[] +-- +STMT: SelectStmt +== 134 +SELECT ARRAY[1,NULL,3] +-- +STMT: SelectStmt +== 135 +-- functions +SELECT array_append(array[42], 6) AS "{42,6}" +-- +FUNCTION: name="array_append" function="array_append" schema="" ctx=Call +STMT: SelectStmt +== 136 +SELECT array_prepend(6, array[42]) AS "{6,42}" +-- +FUNCTION: name="array_prepend" function="array_prepend" schema="" ctx=Call +STMT: SelectStmt +== 137 +SELECT array_cat(ARRAY[1,2], ARRAY[3,4]) AS "{1,2,3,4}" +-- +FUNCTION: name="array_cat" function="array_cat" schema="" ctx=Call +STMT: SelectStmt +== 138 +SELECT array_cat(ARRAY[1,2], ARRAY[[3,4],[5,6]]) AS "{{1,2},{3,4},{5,6}}" +-- +FUNCTION: name="array_cat" function="array_cat" schema="" ctx=Call +STMT: SelectStmt +== 139 +SELECT array_cat(ARRAY[[3,4],[5,6]], ARRAY[1,2]) AS "{{3,4},{5,6},{1,2}}" +-- +FUNCTION: name="array_cat" function="array_cat" schema="" ctx=Call +STMT: SelectStmt +== 140 +SELECT array_position(ARRAY[1,2,3,4,5], 4) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 141 +SELECT array_position(ARRAY[5,3,4,2,1], 4) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 142 +SELECT array_position(ARRAY[[1,2],[3,4]], 3) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 143 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'mon') +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 144 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'sat') +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 145 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], NULL) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 146 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], NULL) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 147 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], 'sat') +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 148 +SELECT array_positions(NULL, 10) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +== 149 +SELECT array_positions(NULL, NULL::int) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +== 150 +SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], 4) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +== 151 +SELECT array_positions(ARRAY[[1,2],[3,4]], 4) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +== 152 +SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], NULL) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +== 153 +SELECT array_positions(ARRAY[1,2,3,NULL,5,6,1,2,3,NULL,5,6], NULL) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +== 154 +SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10 + FROM generate_series(1,100) g(i)), + 'AAAAAAAAAAAAAAAAAAAAAAAAA5'), 1) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 155 +DO $$ +DECLARE + o int; + a int[] := ARRAY[1,2,3,2,3,1,2]; +BEGIN + o := array_position(a, 2); + WHILE o IS NOT NULL + LOOP + RAISE NOTICE '%', o; + o := array_position(a, 2, o + 1); + END LOOP; +END +$$ LANGUAGE plpgsql +-- +STMT: DoStmt +== 156 +SELECT array_position('[2:4]={1,2,3}'::int[], 1) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +== 157 +SELECT array_positions('[2:4]={1,2,3}'::int[], 1) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +== 158 +SELECT + array_position(ids, (1, 1)), + array_positions(ids, (1, 1)) + FROM +(VALUES + (ARRAY[(0, 0), (1, 1)]), + (ARRAY[(1, 1)]) +) AS f (ids) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +== 159 +-- operators +SELECT a FROM arrtest WHERE b = ARRAY[[[113,142],[1,147]]] +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 160 +SELECT NOT ARRAY[1.1,1.2,1.3] = ARRAY[1.1,1.2,1.3] AS "FALSE" +-- +STMT: SelectStmt +== 161 +SELECT ARRAY[1,2] || 3 AS "{1,2,3}" +-- +STMT: SelectStmt +== 162 +SELECT 0 || ARRAY[1,2] AS "{0,1,2}" +-- +STMT: SelectStmt +== 163 +SELECT ARRAY[1,2] || ARRAY[3,4] AS "{1,2,3,4}" +-- +STMT: SelectStmt +== 164 +SELECT ARRAY[[['hello','world']]] || ARRAY[[['happy','birthday']]] AS "ARRAY" +-- +STMT: SelectStmt +== 165 +SELECT ARRAY[[1,2],[3,4]] || ARRAY[5,6] AS "{{1,2},{3,4},{5,6}}" +-- +STMT: SelectStmt +== 166 +SELECT ARRAY[0,0] || ARRAY[1,1] || ARRAY[2,2] AS "{0,0,1,1,2,2}" +-- +STMT: SelectStmt +== 167 +SELECT 0 || ARRAY[1,2] || 3 AS "{0,1,2,3}" +-- +STMT: SelectStmt +== 168 +SELECT ARRAY[1.1] || ARRAY[2,3,4] +-- +STMT: SelectStmt +== 169 +SELECT array_agg(x) || array_agg(x) FROM (VALUES (ROW(1,2)), (ROW(3,4))) v(x) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 170 +SELECT ROW(1,2) || array_agg(x) FROM (VALUES (ROW(3,4)), (ROW(5,6))) v(x) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 171 +SELECT * FROM array_op_test WHERE i @> '{32}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 172 +SELECT * FROM array_op_test WHERE i && '{32}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 173 +SELECT * FROM array_op_test WHERE i @> '{17}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 174 +SELECT * FROM array_op_test WHERE i && '{17}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 175 +SELECT * FROM array_op_test WHERE i @> '{32,17}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 176 +SELECT * FROM array_op_test WHERE i && '{32,17}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 177 +SELECT * FROM array_op_test WHERE i <@ '{38,34,32,89}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 178 +SELECT * FROM array_op_test WHERE i = '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 179 +SELECT * FROM array_op_test WHERE i @> '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 180 +SELECT * FROM array_op_test WHERE i && '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 181 +SELECT * FROM array_op_test WHERE i <@ '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 182 +SELECT * FROM array_op_test WHERE i = '{NULL}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 183 +SELECT * FROM array_op_test WHERE i @> '{NULL}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 184 +SELECT * FROM array_op_test WHERE i && '{NULL}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 185 +SELECT * FROM array_op_test WHERE i <@ '{NULL}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 186 +SELECT * FROM array_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 187 +SELECT * FROM array_op_test WHERE t && '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 188 +SELECT * FROM array_op_test WHERE t @> '{AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 189 +SELECT * FROM array_op_test WHERE t && '{AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 190 +SELECT * FROM array_op_test WHERE t @> '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 191 +SELECT * FROM array_op_test WHERE t && '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 192 +SELECT * FROM array_op_test WHERE t <@ '{AAAAAAAA72908,AAAAAAAAAAAAAAAAAAA17075,AA88409,AAAAAAAAAAAAAAAAAA36842,AAAAAAA48038,AAAAAAAAAAAAAA10611}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 193 +SELECT * FROM array_op_test WHERE t = '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 194 +SELECT * FROM array_op_test WHERE t @> '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 195 +SELECT * FROM array_op_test WHERE t && '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 196 +SELECT * FROM array_op_test WHERE t <@ '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 197 +-- array casts +SELECT ARRAY[1,2,3]::text[]::int[]::float8[] AS "{1,2,3}" +-- +STMT: SelectStmt +== 198 +SELECT pg_typeof(ARRAY[1,2,3]::text[]::int[]::float8[]) AS "double precision[]" +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 199 +SELECT ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[] AS "{{a,bc},{def,hijk}}" +-- +STMT: SelectStmt +== 200 +SELECT pg_typeof(ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[]) AS "character varying[]" +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 201 +SELECT CAST(ARRAY[[[[[['a','bb','ccc']]]]]] as text[]) as "{{{{{{a,bb,ccc}}}}}}" +-- +STMT: SelectStmt +== 202 +SELECT NULL::text[]::int[] AS "NULL" +-- +STMT: SelectStmt +== 203 +-- scalar op any/all (array) +select 33 = any ('{1,2,3}') +-- +STMT: SelectStmt +== 204 +select 33 = any ('{1,2,33}') +-- +STMT: SelectStmt +== 205 +select 33 = all ('{1,2,33}') +-- +STMT: SelectStmt +== 206 +select 33 >= all ('{1,2,33}') +-- +STMT: SelectStmt +== 207 +-- boundary cases +select null::int >= all ('{1,2,33}') +-- +STMT: SelectStmt +== 208 +select null::int >= all ('{}') +-- +STMT: SelectStmt +== 209 +select null::int >= any ('{}') +-- +STMT: SelectStmt +== 210 +-- cross-datatype +select 33.4 = any (array[1,2,3]) +-- +STMT: SelectStmt +== 211 +select 33.4 > all (array[1,2,3]) +-- +STMT: SelectStmt +== 212 +-- errors +select 33 * any ('{1,2,3}') +-- +STMT: SelectStmt +== 213 +select 33 * any (44) +-- +STMT: SelectStmt +== 214 +-- nulls +select 33 = any (null::int[]) +-- +STMT: SelectStmt +== 215 +select null::int = any ('{1,2,3}') +-- +STMT: SelectStmt +== 216 +select 33 = any ('{1,null,3}') +-- +STMT: SelectStmt +== 217 +select 33 = any ('{1,null,33}') +-- +STMT: SelectStmt +== 218 +select 33 = all (null::int[]) +-- +STMT: SelectStmt +== 219 +select null::int = all ('{1,2,3}') +-- +STMT: SelectStmt +== 220 +select 33 = all ('{1,null,3}') +-- +STMT: SelectStmt +== 221 +select 33 = all ('{33,null,33}') +-- +STMT: SelectStmt +== 222 +-- nulls later in the bitmap +SELECT -1 != ALL(ARRAY(SELECT NULLIF(g.i, 900) FROM generate_series(1,1000) g(i))) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 223 +-- test indexes on arrays +create temp table arr_tbl (f1 int[] unique) +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DDL +STMT: CreateStmt +== 224 +insert into arr_tbl values ('{1,2,3}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 225 +insert into arr_tbl values ('{1,2}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 226 +-- failure expected: +insert into arr_tbl values ('{1,2,3}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 227 +insert into arr_tbl values ('{2,3,4}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 228 +insert into arr_tbl values ('{1,5,3}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 229 +insert into arr_tbl values ('{1,2,10}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 230 +set enable_seqscan to off +-- +STMT: VariableSetStmt +== 231 +set enable_bitmapscan to off +-- +STMT: VariableSetStmt +== 232 +select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}' +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 233 +select * from arr_tbl where f1 >= '{1,2,3}' and f1 < '{1,5,3}' +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 234 +-- test ON CONFLICT DO UPDATE with arrays +create temp table arr_pk_tbl (pk int4 primary key, f1 int[]) +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DDL +STMT: CreateStmt +== 235 +insert into arr_pk_tbl values (1, '{1,2,3}') +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 236 +insert into arr_pk_tbl values (1, '{3,4,5}') on conflict (pk) + do update set f1[1] = excluded.f1[1], f1[3] = excluded.f1[3] + returning pk, f1 +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 237 +insert into arr_pk_tbl(pk, f1[1:2]) values (1, '{6,7,8}') on conflict (pk) + do update set f1[1] = excluded.f1[1], + f1[2] = excluded.f1[2], + f1[3] = excluded.f1[3] + returning pk, f1 +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 238 +-- note: if above selects don't produce the expected tuple order, +-- then you didn't get an indexscan plan, and something is busted. +reset enable_seqscan +-- +STMT: VariableSetStmt +== 239 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 240 +-- test subscript overflow detection + +-- The normal error message includes a platform-dependent limit, +-- so suppress it to avoid needing multiple expected-files. + +insert into arr_pk_tbl values(10, '[-2147483648:-2147483647]={1,2}') +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 241 +update arr_pk_tbl set f1[2147483647] = 42 where pk = 10 +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: UpdateStmt +== 242 +update arr_pk_tbl set f1[2147483646:2147483647] = array[4,2] where pk = 10 +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: UpdateStmt +== 243 +insert into arr_pk_tbl(pk, f1[0:2147483647]) values (2, '{}') +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +insert into arr_pk_tbl(pk, f1[-2147483648:2147483647]) values (2, '{}') +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +-- also exercise the expanded-array case +do $$ declare a int[]; +begin + a := '[-2147483648:-2147483647]={1,2}'::int[]; + a[2147483647] := 42; +end $$ +-- +STMT: DoStmt +== 246 +-- test [not] (like|ilike) (any|all) (...) +select 'foo' like any (array['%a', '%o']) +-- +STMT: SelectStmt +== 247 +-- t +select 'foo' like any (array['%a', '%b']) +-- +STMT: SelectStmt +== 248 +-- f +select 'foo' like all (array['f%', '%o']) +-- +STMT: SelectStmt +== 249 +-- t +select 'foo' like all (array['f%', '%b']) +-- +STMT: SelectStmt +== 250 +-- f +select 'foo' not like any (array['%a', '%b']) +-- +STMT: SelectStmt +== 251 +-- t +select 'foo' not like all (array['%a', '%o']) +-- +STMT: SelectStmt +== 252 +-- f +select 'foo' ilike any (array['%A', '%O']) +-- +STMT: SelectStmt +== 253 +-- t +select 'foo' ilike all (array['F%', '%O']) +-- +STMT: SelectStmt +== 254 +-- t + +|-- +-- General array parser tests +|-- + +-- none of the following should be accepted +select '{{1,{2}},{2,3}}'::text[] +-- +STMT: SelectStmt +== 255 +select E'{{1,2},\\{2,3}}'::text[] +-- +STMT: SelectStmt +== 256 +select '{"a"b}'::text[] +-- +STMT: SelectStmt +== 257 +select '{a"b"}'::text[] +-- +STMT: SelectStmt +== 258 +select '{"a""b"}'::text[] +-- +STMT: SelectStmt +== 259 +select '{{"1 2" x},{3}}'::text[] +-- +STMT: SelectStmt +== 260 +select '{{"1 2"} x,{3}}'::text[] +-- +STMT: SelectStmt +== 261 +select '{}}'::text[] +-- +STMT: SelectStmt +== 262 +select '{ }}'::text[] +-- +STMT: SelectStmt +== 263 +select '}{'::text[] +-- +STMT: SelectStmt +== 264 +select '{foo{}}'::text[] +-- +STMT: SelectStmt +== 265 +select '{"foo"{}}'::text[] +-- +STMT: SelectStmt +== 266 +select '{foo,,bar}'::text[] +-- +STMT: SelectStmt +== 267 +select '{{1},{{2}}}'::text[] +-- +STMT: SelectStmt +== 268 +select '{{{1}},{2}}'::text[] +-- +STMT: SelectStmt +== 269 +select '{{},{{}}}'::text[] +-- +STMT: SelectStmt +== 270 +select '{{{}},{}}'::text[] +-- +STMT: SelectStmt +== 271 +select '{{1},{}}'::text[] +-- +STMT: SelectStmt +== 272 +select '{{},{1}}'::text[] +-- +STMT: SelectStmt +== 273 +select '[1:0]={}'::int[] +-- +STMT: SelectStmt +== 274 +select '[2147483646:2147483647]={1,2}'::int[] +-- +STMT: SelectStmt +== 275 +select '[1:-1]={}'::int[] +-- +STMT: SelectStmt +== 276 +select '[2]={1}'::int[] +-- +STMT: SelectStmt +== 277 +select '[1:]={1}'::int[] +-- +STMT: SelectStmt +== 278 +select '[:1]={1}'::int[] +-- +STMT: SelectStmt +== 279 +select array[] +-- +STMT: SelectStmt +== 280 +select '{{1,},{1},}'::text[] +-- +STMT: SelectStmt +== 281 +select '{{1,},{1}}'::text[] +-- +STMT: SelectStmt +== 282 +select '{{1,}}'::text[] +-- +STMT: SelectStmt +== 283 +select '{1,}'::text[] +-- +STMT: SelectStmt +== 284 +select '[21474836488:21474836489]={1,2}'::int[] +-- +STMT: SelectStmt +== 285 +select '[-2147483649:-2147483648]={1,2}'::int[] +-- +STMT: SelectStmt +== 286 +-- none of the above should be accepted + +-- all of the following should be accepted +select '{}'::text[] +-- +STMT: SelectStmt +== 287 +select '{{},{}}'::text[] +-- +STMT: SelectStmt +== 288 +select '{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}'::text[] +-- +STMT: SelectStmt +== 289 +select '{null,n\ull,"null"}'::text[] +-- +STMT: SelectStmt +== 290 +select '{ ab\c , "ab\"c" }'::text[] +-- +STMT: SelectStmt +== 291 +select '{0 second ,0 second}'::interval[] +-- +STMT: SelectStmt +== 292 +select '{ { "," } , { 3 } }'::text[] +-- +STMT: SelectStmt +== 293 +select ' { { " 0 second " , 0 second } }'::text[] +-- +STMT: SelectStmt +== 294 +select '{ + 0 second, + @ 1 hour @ 42 minutes @ 20 seconds + }'::interval[] +-- +STMT: SelectStmt +== 295 +select array[]::text[] +-- +STMT: SelectStmt +== 296 +select '[2]={1,7}'::int[] +-- +STMT: SelectStmt +== 297 +select '[0:1]={1.1,2.2}'::float8[] +-- +STMT: SelectStmt +== 298 +select '[2147483646:2147483646]={1}'::int[] +-- +STMT: SelectStmt +== 299 +select '[-2147483648:-2147483647]={1,2}'::int[] +-- +STMT: SelectStmt +== 300 +-- all of the above should be accepted + +-- tests for array aggregates +CREATE TEMP TABLE arraggtest ( f1 INT[], f2 TEXT[][], f3 FLOAT[]) +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DDL +STMT: CreateStmt +== 301 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{1,2,3,4}','{{grey,red},{blue,blue}}','{1.6, 0.0}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 302 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{1,2,3}','{{grey,red},{grey,blue}}','{1.6}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 303 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 304 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{3,3,2,4,5,6}','{{white,yellow},{pink,orange}}','{2.1,3.3,1.8,1.7,1.6}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 305 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 306 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{2}','{{black,red},{green,orange}}','{1.6,2.2,2.6,0.4}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 307 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 308 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{4,2,6,7,8,1}','{{red},{black},{purple},{blue},{blue}}',NULL) +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 309 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 310 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{}','{{pink,white,blue,red,grey,orange}}','{2.1,1.87,1.4,2.2}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 311 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 312 +-- A few simple tests for arrays of composite types + +create type comptype as (f1 int, f2 text) +-- +STMT: CompositeTypeStmt +== 313 +create table comptable (c1 comptype, c2 comptype[]) +-- +TABLE: name="comptable" schema="" table="comptable" ctx=DDL +STMT: CreateStmt +== 314 +-- XXX would like to not have to specify row() construct types here ... +insert into comptable + values (row(1,'foo'), array[row(2,'bar')::comptype, row(3,'baz')::comptype]) +-- +TABLE: name="comptable" schema="" table="comptable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 315 +-- check that implicitly named array type _comptype isn't a problem +create type _comptype as enum('fooey') +-- +STMT: CreateEnumStmt +== 316 +select * from comptable +-- +TABLE: name="comptable" schema="" table="comptable" ctx=Select +STMT: SelectStmt +== 317 +select c2[2].f2 from comptable +-- +TABLE: name="comptable" schema="" table="comptable" ctx=Select +STMT: SelectStmt +== 318 +drop type _comptype +-- +STMT: DropStmt +== 319 +drop table comptable +-- +TABLE: name="comptable" schema="" table="comptable" ctx=DDL +STMT: DropStmt +== 320 +drop type comptype +-- +STMT: DropStmt +== 321 +create or replace function unnest1(anyarray) +returns setof anyelement as $$ +select $1[s] from generate_subscripts($1,1) g(s); +$$ language sql immutable +-- +FUNCTION: name="unnest1" function="unnest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 322 +create or replace function unnest2(anyarray) +returns setof anyelement as $$ +select $1[s1][s2] from generate_subscripts($1,1) g1(s1), + generate_subscripts($1,2) g2(s2); +$$ language sql immutable +-- +FUNCTION: name="unnest2" function="unnest2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 323 +select * from unnest1(array[1,2,3]) +-- +FUNCTION: name="unnest1" function="unnest1" schema="" ctx=Call +STMT: SelectStmt +== 324 +select * from unnest2(array[[1,2,3],[4,5,6]]) +-- +FUNCTION: name="unnest2" function="unnest2" schema="" ctx=Call +STMT: SelectStmt +== 325 +drop function unnest1(anyarray) +-- +FUNCTION: name="unnest1" function="unnest1" schema="" ctx=DDL +STMT: DropStmt +== 326 +drop function unnest2(anyarray) +-- +FUNCTION: name="unnest2" function="unnest2" schema="" ctx=DDL +STMT: DropStmt +== 327 +select array_fill(null::integer, array[3,3],array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 328 +select array_fill(null::integer, array[3,3]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 329 +select array_fill(null::text, array[3,3],array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 330 +select array_fill(null::text, array[3,3]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 331 +select array_fill(7, array[3,3],array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 332 +select array_fill(7, array[3,3]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 333 +select array_fill('juhu'::text, array[3,3],array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 334 +select array_fill('juhu'::text, array[3,3]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 335 +select a, a = '{}' as is_eq, array_dims(a) + from (select array_fill(42, array[0]) as a) ss +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 336 +select a, a = '{}' as is_eq, array_dims(a) + from (select array_fill(42, '{}') as a) ss +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 337 +select a, a = '{}' as is_eq, array_dims(a) + from (select array_fill(42, '{}', '{}') as a) ss +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 338 +-- raise exception +select array_fill(1, null, array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 339 +select array_fill(1, array[2,2], null) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 340 +select array_fill(1, array[2,2], '{}') +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 341 +select array_fill(1, array[3,3], array[1,1,1]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 342 +select array_fill(1, array[1,2,null]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 343 +select array_fill(1, array[[1,2],[3,4]]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +== 344 +select string_to_array('1|2|3', '|') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 345 +select string_to_array('1|2|3|', '|') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 346 +select string_to_array('1||2|3||', '||') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 347 +select string_to_array('1|2|3', '') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 348 +select string_to_array('', '|') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 349 +select string_to_array('1|2|3', NULL) +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 350 +select string_to_array(NULL, '|') IS NULL +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 351 +select string_to_array('abc', '') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 352 +select string_to_array('abc', '', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 353 +select string_to_array('abc', ',') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 354 +select string_to_array('abc', ',', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 355 +select string_to_array('1,2,3,4,,6', ',') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 356 +select string_to_array('1,2,3,4,,6', ',', '') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 357 +select string_to_array('1,2,3,4,*,6', ',', '*') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 358 +select v, v is null as "is null" from string_to_table('1|2|3', '|') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 359 +select v, v is null as "is null" from string_to_table('1|2|3|', '|') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 360 +select v, v is null as "is null" from string_to_table('1||2|3||', '||') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 361 +select v, v is null as "is null" from string_to_table('1|2|3', '') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 362 +select v, v is null as "is null" from string_to_table('', '|') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 363 +select v, v is null as "is null" from string_to_table('1|2|3', NULL) g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 364 +select v, v is null as "is null" from string_to_table(NULL, '|') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 365 +select v, v is null as "is null" from string_to_table('abc', '') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 366 +select v, v is null as "is null" from string_to_table('abc', '', 'abc') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 367 +select v, v is null as "is null" from string_to_table('abc', ',') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 368 +select v, v is null as "is null" from string_to_table('abc', ',', 'abc') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 369 +select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 370 +select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',', '') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 371 +select v, v is null as "is null" from string_to_table('1,2,3,4,*,6', ',', '*') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +== 372 +select array_to_string(NULL::int4[], ',') IS NULL +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +== 373 +select array_to_string('{}'::int4[], ',') +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +== 374 +select array_to_string(array[1,2,3,4,NULL,6], ',') +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +== 375 +select array_to_string(array[1,2,3,4,NULL,6], ',', '*') +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +== 376 +select array_to_string(array[1,2,3,4,NULL,6], NULL) +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +== 377 +select array_to_string(array[1,2,3,4,NULL,6], ',', NULL) +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +== 378 +select array_to_string(string_to_array('1|2|3', '|'), '|') +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 379 +select array_length(array[1,2,3], 1) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +== 380 +select array_length(array[[1,2,3], [4,5,6]], 0) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +== 381 +select array_length(array[[1,2,3], [4,5,6]], 1) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +== 382 +select array_length(array[[1,2,3], [4,5,6]], 2) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +== 383 +select array_length(array[[1,2,3], [4,5,6]], 3) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +== 384 +select cardinality(NULL::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +== 385 +select cardinality('{}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +== 386 +select cardinality(array[1,2,3]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +== 387 +select cardinality('[2:4]={5,6,7}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +== 388 +select cardinality('{{1,2}}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +== 389 +select cardinality('{{1,2},{3,4},{5,6}}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +== 390 +select cardinality('{{{1,9},{5,6}},{{2,3},{3,4}}}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +== 391 +-- array_agg(anynonarray) +select array_agg(unique1) from (select unique1 from tenk1 where unique1 < 15 order by unique1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 392 +select array_agg(ten) from (select ten from tenk1 where unique1 < 15 order by unique1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 393 +select array_agg(nullif(ten, 4)) from (select ten from tenk1 where unique1 < 15 order by unique1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 394 +select array_agg(unique1) from tenk1 where unique1 < -15 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 395 +-- array_agg(anyarray) +select array_agg(ar) + from (values ('{1,2}'::int[]), ('{3,4}'::int[])) v(ar) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 396 +select array_agg(distinct ar order by ar desc) + from (select array[i / 2] from generate_series(1,10) a(i)) b(ar) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 397 +select array_agg(ar) + from (select array_agg(array[i, i+1, i-1]) + from generate_series(1,2) a(i)) b(ar) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 398 +select array_agg(array[i+1.2, i+1.3, i+1.4]) from generate_series(1,3) g(i) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 399 +select array_agg(array['Hello', i::text]) from generate_series(9,11) g(i) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 400 +select array_agg(array[i, nullif(i, 3), i+1]) from generate_series(1,4) g(i) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 401 +-- errors +select array_agg('{}'::int[]) from generate_series(1,2) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 402 +select array_agg(null::int[]) from generate_series(1,2) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 403 +select array_agg(ar) + from (values ('{1,2}'::int[]), ('{3}'::int[])) v(ar) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 404 +select unnest(array[1,2,3]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 405 +select * from unnest(array[1,2,3]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 406 +select unnest(array[1,2,3,4.5]::float8[]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 407 +select unnest(array[1,2,3,4.5]::numeric[]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 408 +select unnest(array[1,2,3,null,4,null,null,5,6]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 409 +select unnest(array[1,2,3,null,4,null,null,5,6]::text[]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 410 +select abs(unnest(array[1,2,null,-3])) +-- +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 411 +select array_remove(array[1,2,2,3], 2) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +== 412 +select array_remove(array[1,2,2,3], 5) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +== 413 +select array_remove(array[1,NULL,NULL,3], NULL) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +== 414 +select array_remove(array['A','CC','D','C','RR'], 'RR') +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +== 415 +select array_remove(array[1.0, 2.1, 3.3], 1) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +== 416 +select array_remove('{{1,2,2},{1,4,3}}', 2) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +== 417 +-- not allowed +select array_remove(array['X','X','X'], 'X') = '{}' +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +== 418 +select array_replace(array[1,2,5,4],5,3) +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +== 419 +select array_replace(array[1,2,5,4],5,NULL) +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +== 420 +select array_replace(array[1,2,NULL,4,NULL],NULL,5) +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +== 421 +select array_replace(array['A','B','DD','B'],'B','CC') +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +== 422 +select array_replace(array[1,NULL,3],NULL,NULL) +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +== 423 +select array_replace(array['AB',NULL,'CDE'],NULL,'12') +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +== 424 +-- array(select array-value ...) +select array(select array[i,i/2] from generate_series(1,5) i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 425 +select array(select array['Hello', i::text] from generate_series(9,11) i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 426 +-- int2vector and oidvector should be treated as scalar types for this purpose +select pg_typeof(array(select '11 22 33'::int2vector from generate_series(1,5))) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 427 +select array(select '11 22 33'::int2vector from generate_series(1,5)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 428 +select unnest(array(select '11 22 33'::int2vector from generate_series(1,5))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 429 +select pg_typeof(array(select '11 22 33'::oidvector from generate_series(1,5))) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 430 +select array(select '11 22 33'::oidvector from generate_series(1,5)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 431 +select unnest(array(select '11 22 33'::oidvector from generate_series(1,5))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 432 +-- array[] should do the same +select pg_typeof(array['11 22 33'::int2vector]) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 433 +select array['11 22 33'::int2vector] +-- +STMT: SelectStmt +== 434 +select pg_typeof(unnest(array['11 22 33'::int2vector])) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 435 +select unnest(array['11 22 33'::int2vector]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 436 +select pg_typeof(unnest('11 22 33'::int2vector)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 437 +select unnest('11 22 33'::int2vector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 438 +select pg_typeof(array['11 22 33'::oidvector]) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 439 +select array['11 22 33'::oidvector] +-- +STMT: SelectStmt +== 440 +select pg_typeof(unnest(array['11 22 33'::oidvector])) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 441 +select unnest(array['11 22 33'::oidvector]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 442 +select pg_typeof(unnest('11 22 33'::oidvector)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 443 +select unnest('11 22 33'::oidvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 444 +-- Insert/update on a column that is array of composite + +create temp table t1 (f1 int8_tbl[]) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 445 +insert into t1 (f1[5].q1) values(42) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 446 +select * from t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 447 +update t1 set f1[5].q2 = 43 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: UpdateStmt +== 448 +select * from t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 449 +-- Check that arrays of composites are safely detoasted when needed + +create temp table src (f1 text) +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: CreateStmt +== 450 +insert into src + select string_agg(random()::text,'') from generate_series(1,10000) +-- +TABLE: name="src" schema="" table="src" ctx=DML +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 451 +create type textandtext as (c1 text, c2 text) +-- +STMT: CompositeTypeStmt +== 452 +create temp table dest (f1 textandtext[]) +-- +TABLE: name="dest" schema="" table="dest" ctx=DDL +STMT: CreateStmt +== 453 +insert into dest select array[row(f1,f1)::textandtext] from src +-- +TABLE: name="dest" schema="" table="dest" ctx=DML +TABLE: name="src" schema="" table="src" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 454 +select length(fipshash((f1[1]).c2)) from dest +-- +TABLE: name="dest" schema="" table="dest" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +STMT: SelectStmt +== 455 +delete from src +-- +TABLE: name="src" schema="" table="src" ctx=DML +STMT: DeleteStmt +== 456 +select length(fipshash((f1[1]).c2)) from dest +-- +TABLE: name="dest" schema="" table="dest" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +STMT: SelectStmt +== 457 +truncate table src +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: TruncateStmt +== 458 +drop table src +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: DropStmt +== 459 +select length(fipshash((f1[1]).c2)) from dest +-- +TABLE: name="dest" schema="" table="dest" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +STMT: SelectStmt +== 460 +drop table dest +-- +TABLE: name="dest" schema="" table="dest" ctx=DDL +STMT: DropStmt +== 461 +drop type textandtext +-- +STMT: DropStmt +== 462 +-- Tests for polymorphic-array form of width_bucket() + +-- this exercises the varwidth and float8 code paths +SELECT + op, + width_bucket(op::numeric, ARRAY[1, 3, 5, 10.0]::numeric[]) AS wb_n1, + width_bucket(op::numeric, ARRAY[0, 5.5, 9.99]::numeric[]) AS wb_n2, + width_bucket(op::numeric, ARRAY[-6, -5, 2.0]::numeric[]) AS wb_n3, + width_bucket(op::float8, ARRAY[1, 3, 5, 10.0]::float8[]) AS wb_f1, + width_bucket(op::float8, ARRAY[0, 5.5, 9.99]::float8[]) AS wb_f2, + width_bucket(op::float8, ARRAY[-6, -5, 2.0]::float8[]) AS wb_f3 +FROM (VALUES + (-5.2), + (-0.0000000001), + (0.000000000001), + (1), + (1.99999999999999), + (2), + (2.00000000000001), + (3), + (4), + (4.5), + (5), + (5.5), + (6), + (7), + (8), + (9), + (9.99999999999999), + (10), + (10.0000000000001) +) v(op) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 463 +-- ensure float8 path handles NaN properly +SELECT + op, + width_bucket(op, ARRAY[1, 3, 9, 'NaN', 'NaN']::float8[]) AS wb +FROM (VALUES + (-5.2::float8), + (4::float8), + (77::float8), + ('NaN'::float8) +) v(op) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 464 +-- these exercise the generic fixed-width code path +SELECT + op, + width_bucket(op, ARRAY[1, 3, 5, 10]) AS wb_1 +FROM generate_series(0,11) as op +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 465 +SELECT width_bucket(now(), + array['yesterday', 'today', 'tomorrow']::timestamptz[]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 466 +-- corner cases +SELECT width_bucket(5, ARRAY[3]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 467 +SELECT width_bucket(5, '{}') +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 468 +-- error cases +SELECT width_bucket('5'::text, ARRAY[3, 4]::integer[]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 469 +SELECT width_bucket(5, ARRAY[3, 4, NULL]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 470 +SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 471 +-- trim_array + +SELECT arr, trim_array(arr, 2) +FROM +(VALUES ('{1,2,3,4,5,6}'::bigint[]), + ('{1,2}'), + ('[10:16]={1,2,3,4,5,6,7}'), + ('[-15:-10]={1,2,3,4,5,6}'), + ('{{1,10},{2,20},{3,30},{4,40}}')) v(arr) +-- +FUNCTION: name="trim_array" function="trim_array" schema="" ctx=Call +STMT: SelectStmt +== 472 +SELECT trim_array(ARRAY[1, 2, 3], -1) +-- +FUNCTION: name="trim_array" function="trim_array" schema="" ctx=Call +STMT: SelectStmt +== 473 +-- fail +SELECT trim_array(ARRAY[1, 2, 3], 10) +-- +FUNCTION: name="trim_array" function="trim_array" schema="" ctx=Call +STMT: SelectStmt +== 474 +-- fail +SELECT trim_array(ARRAY[]::int[], 1) +-- +FUNCTION: name="trim_array" function="trim_array" schema="" ctx=Call +STMT: SelectStmt +== 475 +-- fail + +-- array_shuffle +SELECT array_shuffle('{1,2,3,4,5,6}'::int[]) <@ '{1,2,3,4,5,6}' +-- +FUNCTION: name="array_shuffle" function="array_shuffle" schema="" ctx=Call +STMT: SelectStmt +== 476 +SELECT array_shuffle('{1,2,3,4,5,6}'::int[]) @> '{1,2,3,4,5,6}' +-- +FUNCTION: name="array_shuffle" function="array_shuffle" schema="" ctx=Call +STMT: SelectStmt +== 477 +SELECT array_dims(array_shuffle('[-1:2][2:3]={{1,2},{3,NULL},{5,6},{7,8}}'::int[])) +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_shuffle" function="array_shuffle" schema="" ctx=Call +STMT: SelectStmt +== 478 +SELECT array_dims(array_shuffle('{{{1,2},{3,NULL}},{{5,6},{7,8}},{{9,10},{11,12}}}'::int[])) +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_shuffle" function="array_shuffle" schema="" ctx=Call +STMT: SelectStmt +== 479 +-- array_sample +SELECT array_sample('{1,2,3,4,5,6}'::int[], 3) <@ '{1,2,3,4,5,6}' +-- +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +== 480 +SELECT array_length(array_sample('{1,2,3,4,5,6}'::int[], 3), 1) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +== 481 +SELECT array_dims(array_sample('[-1:2][2:3]={{1,2},{3,NULL},{5,6},{7,8}}'::int[], 3)) +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +== 482 +SELECT array_dims(array_sample('{{{1,2},{3,NULL}},{{5,6},{7,8}},{{9,10},{11,12}}}'::int[], 2)) +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +== 483 +SELECT array_sample('{1,2,3,4,5,6}'::int[], -1) +-- +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +== 484 +-- fail +SELECT array_sample('{1,2,3,4,5,6}'::int[], 7) +-- +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/async.metadata.json b/parser/testdata/summary/postgres_regress/async.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/async.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/async.test b/parser/testdata/summary/postgres_regress/async.test new file mode 100644 index 0000000..b7cb31d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/async.test @@ -0,0 +1,60 @@ +== 001 +|-- +-- ASYNC +|-- + +--Should work. Send a valid message via a valid channel name +SELECT pg_notify('notify_async1','sample message1') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +== 002 +SELECT pg_notify('notify_async1','') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +== 003 +SELECT pg_notify('notify_async1',NULL) +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +== 004 +-- Should fail. Send a valid message via an invalid channel name +SELECT pg_notify('','sample message1') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT pg_notify(NULL,'sample message1') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT pg_notify('notify_async_channel_name_too_long______________________________','sample_message1') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +== 007 +--Should work. Valid NOTIFY/LISTEN/UNLISTEN commands +NOTIFY notify_async2 +-- +STMT: NotifyStmt +== 008 +LISTEN notify_async2 +-- +STMT: ListenStmt +== 009 +UNLISTEN notify_async2 +-- +STMT: UnlistenStmt +== 010 +UNLISTEN * +-- +STMT: UnlistenStmt +== 011 +-- Should return zero while there are no pending notifications. +-- src/test/isolation/specs/async-notify.spec tests for actual usage. +SELECT pg_notification_queue_usage() +-- +FUNCTION: name="pg_notification_queue_usage" function="pg_notification_queue_usage" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/bit.metadata.json b/parser/testdata/summary/postgres_regress/bit.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/bit.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/bit.test b/parser/testdata/summary/postgres_regress/bit.test new file mode 100644 index 0000000..b14f4da --- /dev/null +++ b/parser/testdata/summary/postgres_regress/bit.test @@ -0,0 +1,813 @@ +== 001 +|-- +-- BIT types +|-- + +|-- +-- Build tables for testing +|-- + +CREATE TABLE BIT_TABLE(b BIT(11)) +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO BIT_TABLE VALUES (B'10') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +-- too short +INSERT INTO BIT_TABLE VALUES (B'00000000000') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO BIT_TABLE VALUES (B'11011000000') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO BIT_TABLE VALUES (B'01010101010') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO BIT_TABLE VALUES (B'101011111010') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- too long +--INSERT INTO BIT_TABLE VALUES ('X554'); +--INSERT INTO BIT_TABLE VALUES ('X555'); + +SELECT * FROM BIT_TABLE +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: SelectStmt +== 008 +CREATE TABLE VARBIT_TABLE(v BIT VARYING(11)) +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DDL +STMT: CreateStmt +== 009 +INSERT INTO VARBIT_TABLE VALUES (B'') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO VARBIT_TABLE VALUES (B'0') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO VARBIT_TABLE VALUES (B'010101') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO VARBIT_TABLE VALUES (B'01010101010') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO VARBIT_TABLE VALUES (B'101011111010') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +-- too long +--INSERT INTO VARBIT_TABLE VALUES ('X554'); +--INSERT INTO VARBIT_TABLE VALUES ('X555'); +SELECT * FROM VARBIT_TABLE +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +== 015 +-- Literals with syntax errors +SELECT b' 0' +-- +STMT: SelectStmt +== 016 +SELECT b'0 ' +-- +STMT: SelectStmt +== 017 +SELECT x' 0' +-- +STMT: SelectStmt +== 018 +SELECT x'0 ' +-- +STMT: SelectStmt +== 019 +-- Concatenation +SELECT v, b, (v || b) AS concat + FROM BIT_TABLE, VARBIT_TABLE + ORDER BY 3 +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +== 020 +-- Length +SELECT b, length(b) AS lb + FROM BIT_TABLE +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT v, length(v) AS lv + FROM VARBIT_TABLE +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- Substring +SELECT b, + SUBSTRING(b FROM 2 FOR 4) AS sub_2_4, + SUBSTRING(b FROM 7 FOR 13) AS sub_7_13, + SUBSTRING(b FROM 6) AS sub_6 + FROM BIT_TABLE +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 023 +SELECT v, + SUBSTRING(v FROM 2 FOR 4) AS sub_2_4, + SUBSTRING(v FROM 7 FOR 13) AS sub_7_13, + SUBSTRING(v FROM 6) AS sub_6 + FROM VARBIT_TABLE +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 024 +-- test overflow cases +SELECT SUBSTRING('01010101'::bit(8) FROM 2 FOR 2147483646) AS "1010101" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 025 +SELECT SUBSTRING('01010101'::bit(8) FROM -10 FOR 2147483646) AS "01010101" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 026 +SELECT SUBSTRING('01010101'::bit(8) FROM -10 FOR -2147483646) AS "error" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 027 +SELECT SUBSTRING('01010101'::varbit FROM 2 FOR 2147483646) AS "1010101" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 028 +SELECT SUBSTRING('01010101'::varbit FROM -10 FOR 2147483646) AS "01010101" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 029 +SELECT SUBSTRING('01010101'::varbit FROM -10 FOR -2147483646) AS "error" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 030 +--- Bit operations +DROP TABLE varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DDL +STMT: DropStmt +== 031 +CREATE TABLE varbit_table (a BIT VARYING(16), b BIT VARYING(16)) +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DDL +STMT: CreateStmt +== 032 +COPY varbit_table FROM stdin +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: CopyStmt +== 033 +SELECT a, b, ~a AS "~ a", a & b AS "a & b", + a | b AS "a | b", a # b AS "a # b" FROM varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +== 034 +SELECT a,b,a=b AS "a>=b",a>b AS "a>b",a<>b AS "a<>b" FROM varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +== 035 +SELECT a,a<<4 AS "a<<4",b,b>>2 AS "b>>2" FROM varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +== 036 +DROP TABLE varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DDL +STMT: DropStmt +== 037 +--- Bit operations +DROP TABLE bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DDL +STMT: DropStmt +== 038 +CREATE TABLE bit_table (a BIT(16), b BIT(16)) +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DDL +STMT: CreateStmt +== 039 +COPY bit_table FROM stdin +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: CopyStmt +== 040 +SELECT a,b,~a AS "~ a",a & b AS "a & b", + a|b AS "a | b", a # b AS "a # b" FROM bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: SelectStmt +== 041 +SELECT a,b,a=b AS "a>=b",a>b AS "a>b",a<>b AS "a<>b" FROM bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: SelectStmt +== 042 +SELECT a,a<<4 AS "a<<4",b,b>>2 AS "b>>2" FROM bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: SelectStmt +== 043 +DROP TABLE bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DDL +STMT: DropStmt +== 044 +-- The following should fail +select B'001' & B'10' +-- +STMT: SelectStmt +== 045 +select B'0111' | B'011' +-- +STMT: SelectStmt +== 046 +select B'0010' # B'011101' +-- +STMT: SelectStmt +== 047 +-- More position tests, checking all the boundary cases +SELECT POSITION(B'1010' IN B'0000101') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 048 +-- 0 +SELECT POSITION(B'1010' IN B'00001010') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 049 +-- 5 +SELECT POSITION(B'1010' IN B'00000101') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 050 +-- 0 +SELECT POSITION(B'1010' IN B'000001010') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 051 +-- 6 + +SELECT POSITION(B'' IN B'00001010') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 052 +-- 1 +SELECT POSITION(B'0' IN B'') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 053 +-- 0 +SELECT POSITION(B'' IN B'') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 054 +-- 0 +SELECT POSITION(B'101101' IN B'001011011011011000') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 055 +-- 3 +SELECT POSITION(B'10110110' IN B'001011011011010') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 056 +-- 3 +SELECT POSITION(B'1011011011011' IN B'001011011011011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 057 +-- 3 +SELECT POSITION(B'1011011011011' IN B'00001011011011011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 058 +-- 5 + +SELECT POSITION(B'11101011' IN B'11101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 059 +-- 1 +SELECT POSITION(B'11101011' IN B'011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 060 +-- 2 +SELECT POSITION(B'11101011' IN B'00011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 061 +-- 4 +SELECT POSITION(B'11101011' IN B'0000011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 062 +-- 6 + +SELECT POSITION(B'111010110' IN B'111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 063 +-- 1 +SELECT POSITION(B'111010110' IN B'0111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 064 +-- 2 +SELECT POSITION(B'111010110' IN B'000111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 065 +-- 4 +SELECT POSITION(B'111010110' IN B'00000111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 066 +-- 6 + +SELECT POSITION(B'111010110' IN B'11101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 067 +-- 0 +SELECT POSITION(B'111010110' IN B'011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 068 +-- 0 +SELECT POSITION(B'111010110' IN B'00011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 069 +-- 0 +SELECT POSITION(B'111010110' IN B'0000011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 070 +-- 0 + +SELECT POSITION(B'111010110' IN B'111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 071 +-- 1 +SELECT POSITION(B'111010110' IN B'0111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 072 +-- 2 +SELECT POSITION(B'111010110' IN B'000111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 073 +-- 4 +SELECT POSITION(B'111010110' IN B'00000111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 074 +-- 6 + +SELECT POSITION(B'111010110' IN B'000001110101111101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 075 +-- 0 +SELECT POSITION(B'111010110' IN B'0000001110101111101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 076 +-- 0 +SELECT POSITION(B'111010110' IN B'000000001110101111101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 077 +-- 0 +SELECT POSITION(B'111010110' IN B'00000000001110101111101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 078 +-- 0 + +SELECT POSITION(B'111010110' IN B'0000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 079 +-- 14 +SELECT POSITION(B'111010110' IN B'00000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 080 +-- 15 +SELECT POSITION(B'111010110' IN B'0000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 081 +-- 17 +SELECT POSITION(B'111010110' IN B'000000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 082 +-- 19 + +SELECT POSITION(B'000000000011101011111010110' IN B'000000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 083 +-- 1 +SELECT POSITION(B'00000000011101011111010110' IN B'000000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 084 +-- 2 +SELECT POSITION(B'0000000000011101011111010110' IN B'000000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 085 +-- 0 + + +-- Shifting + +CREATE TABLE BIT_SHIFT_TABLE(b BIT(16)) +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DDL +STMT: CreateStmt +== 086 +INSERT INTO BIT_SHIFT_TABLE VALUES (B'1101100000000000') +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +INSERT INTO BIT_SHIFT_TABLE SELECT b>>1 FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 088 +INSERT INTO BIT_SHIFT_TABLE SELECT b>>2 FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 089 +INSERT INTO BIT_SHIFT_TABLE SELECT b>>4 FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 090 +INSERT INTO BIT_SHIFT_TABLE SELECT b>>8 FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 091 +SELECT POSITION(B'1101' IN b), + POSITION(B'11011' IN b), + b + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 092 +SELECT b, b >> 1 AS bsr, b << 1 AS bsl + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: SelectStmt +== 093 +SELECT b, b >> 8 AS bsr8, b << 8 AS bsl8 + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: SelectStmt +== 094 +SELECT b::bit(15), b::bit(15) >> 1 AS bsr, b::bit(15) << 1 AS bsl + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: SelectStmt +== 095 +SELECT b::bit(15), b::bit(15) >> 8 AS bsr8, b::bit(15) << 8 AS bsl8 + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: SelectStmt +== 096 +CREATE TABLE VARBIT_SHIFT_TABLE(v BIT VARYING(20)) +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DDL +STMT: CreateStmt +== 097 +INSERT INTO VARBIT_SHIFT_TABLE VALUES (B'11011') +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +INSERT INTO VARBIT_SHIFT_TABLE SELECT CAST(v || B'0' AS BIT VARYING(6)) >>1 FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 099 +INSERT INTO VARBIT_SHIFT_TABLE SELECT CAST(v || B'00' AS BIT VARYING(8)) >>2 FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 100 +INSERT INTO VARBIT_SHIFT_TABLE SELECT CAST(v || B'0000' AS BIT VARYING(12)) >>4 FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 101 +INSERT INTO VARBIT_SHIFT_TABLE SELECT CAST(v || B'00000000' AS BIT VARYING(20)) >>8 FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 102 +SELECT POSITION(B'1101' IN v), + POSITION(B'11011' IN v), + v + FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 103 +SELECT v, v >> 1 AS vsr, v << 1 AS vsl + FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: SelectStmt +== 104 +SELECT v, v >> 8 AS vsr8, v << 8 AS vsl8 + FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: SelectStmt +== 105 +DROP TABLE BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DDL +STMT: DropStmt +== 106 +DROP TABLE VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DDL +STMT: DropStmt +== 107 +-- Get/Set bit +SELECT get_bit(B'0101011000100', 10) +-- +FUNCTION: name="get_bit" function="get_bit" schema="" ctx=Call +STMT: SelectStmt +== 108 +SELECT set_bit(B'0101011000100100', 15, 1) +-- +FUNCTION: name="set_bit" function="set_bit" schema="" ctx=Call +STMT: SelectStmt +== 109 +SELECT set_bit(B'0101011000100100', 16, 1) +-- +FUNCTION: name="set_bit" function="set_bit" schema="" ctx=Call +STMT: SelectStmt +== 110 +-- fail + +-- Overlay +SELECT overlay(B'0101011100' placing '001' from 2 for 3) +-- +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 111 +SELECT overlay(B'0101011100' placing '101' from 6) +-- +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 112 +SELECT overlay(B'0101011100' placing '001' from 11) +-- +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 113 +SELECT overlay(B'0101011100' placing '001' from 20) +-- +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 114 +-- bit_count +SELECT bit_count(B'0101011100'::bit(10)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +STMT: SelectStmt +== 115 +SELECT bit_count(B'1111111111'::bit(10)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +STMT: SelectStmt +== 116 +SELECT bit_count(repeat('0', 100)::bit(100)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 117 +SELECT bit_count(repeat('1', 100)::bit(100)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 118 +SELECT bit_count(repeat('01', 500)::bit(1000)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 119 +SELECT bit_count(repeat('10101', 200)::bit(1000)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 120 +-- This table is intentionally left around to exercise pg_dump/pg_upgrade +CREATE TABLE bit_defaults( + b1 bit(4) DEFAULT '1001', + b2 bit(4) DEFAULT B'0101', + b3 bit varying(5) DEFAULT '1001', + b4 bit varying(5) DEFAULT B'0101' +) +-- +TABLE: name="bit_defaults" schema="" table="bit_defaults" ctx=DDL +STMT: CreateStmt +== 121 +INSERT INTO bit_defaults DEFAULT VALUES +-- +TABLE: name="bit_defaults" schema="" table="bit_defaults" ctx=DML +STMT: InsertStmt +== 122 +TABLE bit_defaults +-- +TABLE: name="bit_defaults" schema="" table="bit_defaults" ctx=Select +STMT: SelectStmt +== 123 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('01010001', 'bit(10)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 124 +SELECT * FROM pg_input_error_info('01010001', 'bit(10)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 125 +SELECT pg_input_is_valid('01010Z01', 'bit(8)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 126 +SELECT * FROM pg_input_error_info('01010Z01', 'bit(8)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 127 +SELECT pg_input_is_valid('x01010Z01', 'bit(32)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 128 +SELECT * FROM pg_input_error_info('x01010Z01', 'bit(32)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 129 +SELECT pg_input_is_valid('01010Z01', 'varbit') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 130 +SELECT * FROM pg_input_error_info('01010Z01', 'varbit') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 131 +SELECT pg_input_is_valid('x01010Z01', 'varbit') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 132 +SELECT * FROM pg_input_error_info('x01010Z01', 'varbit') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/bitmapops.metadata.json b/parser/testdata/summary/postgres_regress/bitmapops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/bitmapops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/bitmapops.test b/parser/testdata/summary/postgres_regress/bitmapops.test new file mode 100644 index 0000000..45dc777 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/bitmapops.test @@ -0,0 +1,77 @@ +== 001 +-- Test bitmap AND and OR + + +-- Generate enough data that we can test the lossy bitmaps. + +-- There's 55 tuples per page in the table. 53 is just +-- below 55, so that an index scan with qual a = constant +-- will return at least one hit per page. 59 is just above +-- 55, so that an index scan with qual b = constant will return +-- hits on most but not all pages. 53 and 59 are prime, so that +-- there's a maximum number of a,b combinations in the table. +-- That allows us to test all the different combinations of +-- lossy and non-lossy pages with the minimum amount of data + +CREATE TABLE bmscantest (a int, b int, t text) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO bmscantest + SELECT (r%53), (r%59), 'foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + FROM generate_series(1,70000) r +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +CREATE INDEX i_bmtest_a ON bmscantest(a) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: IndexStmt +== 004 +CREATE INDEX i_bmtest_b ON bmscantest(b) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: IndexStmt +== 005 +-- We want to use bitmapscans. With default settings, the planner currently +-- chooses a bitmap scan for the queries below anyway, but let's make sure. +set enable_indexscan=false +-- +STMT: VariableSetStmt +== 006 +set enable_seqscan=false +-- +STMT: VariableSetStmt +== 007 +-- Lower work_mem to trigger use of lossy bitmaps +set work_mem = 64 +-- +STMT: VariableSetStmt +== 008 +-- Test bitmap-and. +SELECT count(*) FROM bmscantest WHERE a = 1 AND b = 1 +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 009 +-- Test bitmap-or. +SELECT count(*) FROM bmscantest WHERE a = 1 OR b = 1 +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 010 +-- clean up +DROP TABLE bmscantest +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/boolean.metadata.json b/parser/testdata/summary/postgres_regress/boolean.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/boolean.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/boolean.test b/parser/testdata/summary/postgres_regress/boolean.test new file mode 100644 index 0000000..75cf072 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/boolean.test @@ -0,0 +1,579 @@ +== 001 +|-- +-- BOOLEAN +|-- + +|-- +-- sanity check - if this fails go insane! +|-- +SELECT 1 AS one +-- +STMT: SelectStmt +== 002 +-- ******************testing built-in type bool******************** + +-- check bool input syntax + +SELECT true AS true +-- +STMT: SelectStmt +== 003 +SELECT false AS false +-- +STMT: SelectStmt +== 004 +SELECT bool 't' AS true +-- +STMT: SelectStmt +== 005 +SELECT bool ' f ' AS false +-- +STMT: SelectStmt +== 006 +SELECT bool 'true' AS true +-- +STMT: SelectStmt +== 007 +SELECT bool 'test' AS error +-- +STMT: SelectStmt +== 008 +SELECT bool 'false' AS false +-- +STMT: SelectStmt +== 009 +SELECT bool 'foo' AS error +-- +STMT: SelectStmt +== 010 +SELECT bool 'y' AS true +-- +STMT: SelectStmt +== 011 +SELECT bool 'yes' AS true +-- +STMT: SelectStmt +== 012 +SELECT bool 'yeah' AS error +-- +STMT: SelectStmt +== 013 +SELECT bool 'n' AS false +-- +STMT: SelectStmt +== 014 +SELECT bool 'no' AS false +-- +STMT: SelectStmt +== 015 +SELECT bool 'nay' AS error +-- +STMT: SelectStmt +== 016 +SELECT bool 'on' AS true +-- +STMT: SelectStmt +== 017 +SELECT bool 'off' AS false +-- +STMT: SelectStmt +== 018 +SELECT bool 'of' AS false +-- +STMT: SelectStmt +== 019 +SELECT bool 'o' AS error +-- +STMT: SelectStmt +== 020 +SELECT bool 'on_' AS error +-- +STMT: SelectStmt +== 021 +SELECT bool 'off_' AS error +-- +STMT: SelectStmt +== 022 +SELECT bool '1' AS true +-- +STMT: SelectStmt +== 023 +SELECT bool '11' AS error +-- +STMT: SelectStmt +== 024 +SELECT bool '0' AS false +-- +STMT: SelectStmt +== 025 +SELECT bool '000' AS error +-- +STMT: SelectStmt +== 026 +SELECT bool '' AS error +-- +STMT: SelectStmt +== 027 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('true', 'bool') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT pg_input_is_valid('asdf', 'bool') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT * FROM pg_input_error_info('junk', 'bool') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 030 +-- and, or, not in qualifications + +SELECT bool 't' or bool 'f' AS true +-- +STMT: SelectStmt +== 031 +SELECT bool 't' and bool 'f' AS false +-- +STMT: SelectStmt +== 032 +SELECT not bool 'f' AS true +-- +STMT: SelectStmt +== 033 +SELECT bool 't' = bool 'f' AS false +-- +STMT: SelectStmt +== 034 +SELECT bool 't' <> bool 'f' AS true +-- +STMT: SelectStmt +== 035 +SELECT bool 't' > bool 'f' AS true +-- +STMT: SelectStmt +== 036 +SELECT bool 't' >= bool 'f' AS true +-- +STMT: SelectStmt +== 037 +SELECT bool 'f' < bool 't' AS true +-- +STMT: SelectStmt +== 038 +SELECT bool 'f' <= bool 't' AS true +-- +STMT: SelectStmt +== 039 +-- explicit casts to/from text +SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false +-- +STMT: SelectStmt +== 040 +SELECT ' true '::text::boolean AS true, + ' FALSE'::text::boolean AS false +-- +STMT: SelectStmt +== 041 +SELECT true::boolean::text AS true, false::boolean::text AS false +-- +STMT: SelectStmt +== 042 +SELECT ' tru e '::text::boolean AS invalid +-- +STMT: SelectStmt +== 043 +-- error +SELECT ''::text::boolean AS invalid +-- +STMT: SelectStmt +== 044 +-- error + +CREATE TABLE BOOLTBL1 (f1 bool) +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DDL +STMT: CreateStmt +== 045 +INSERT INTO BOOLTBL1 (f1) VALUES (bool 't') +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO BOOLTBL1 (f1) VALUES (bool 'True') +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO BOOLTBL1 (f1) VALUES (bool 'true') +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +-- BOOLTBL1 should be full of true's at this point +SELECT BOOLTBL1.* FROM BOOLTBL1 +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +STMT: SelectStmt +== 049 +SELECT BOOLTBL1.* + FROM BOOLTBL1 + WHERE f1 = bool 'true' +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 050 +SELECT BOOLTBL1.* + FROM BOOLTBL1 + WHERE f1 <> bool 'false' +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 051 +SELECT BOOLTBL1.* + FROM BOOLTBL1 + WHERE booleq(bool 'false', f1) +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FUNCTION: name="booleq" function="booleq" schema="" ctx=Call +FUNCTION: name="booleq" function="booleq" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 052 +INSERT INTO BOOLTBL1 (f1) VALUES (bool 'f') +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +SELECT BOOLTBL1.* + FROM BOOLTBL1 + WHERE f1 = bool 'false' +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 054 +CREATE TABLE BOOLTBL2 (f1 bool) +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DDL +STMT: CreateStmt +== 055 +INSERT INTO BOOLTBL2 (f1) VALUES (bool 'f') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +INSERT INTO BOOLTBL2 (f1) VALUES (bool 'false') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +INSERT INTO BOOLTBL2 (f1) VALUES (bool 'False') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +INSERT INTO BOOLTBL2 (f1) VALUES (bool 'FALSE') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +-- This is now an invalid expression +-- For pre-v6.3 this evaluated to false - thomas 1997-10-23 +INSERT INTO BOOLTBL2 (f1) + VALUES (bool 'XXX') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +-- BOOLTBL2 should be full of false's at this point +SELECT BOOLTBL2.* FROM BOOLTBL2 +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +STMT: SelectStmt +== 061 +SELECT BOOLTBL1.*, BOOLTBL2.* + FROM BOOLTBL1, BOOLTBL2 + WHERE BOOLTBL2.f1 <> BOOLTBL1.f1 +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="booltbl2" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +STMT: SelectStmt +== 062 +SELECT BOOLTBL1.*, BOOLTBL2.* + FROM BOOLTBL1, BOOLTBL2 + WHERE boolne(BOOLTBL2.f1,BOOLTBL1.f1) +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FUNCTION: name="boolne" function="boolne" schema="" ctx=Call +FUNCTION: name="boolne" function="boolne" schema="" ctx=Call +FILTER: schema="" table="booltbl2" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +STMT: SelectStmt +== 063 +SELECT BOOLTBL1.*, BOOLTBL2.* + FROM BOOLTBL1, BOOLTBL2 + WHERE BOOLTBL2.f1 = BOOLTBL1.f1 and BOOLTBL1.f1 = bool 'false' +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="booltbl2" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +STMT: SelectStmt +== 064 +SELECT BOOLTBL1.*, BOOLTBL2.* + FROM BOOLTBL1, BOOLTBL2 + WHERE BOOLTBL2.f1 = BOOLTBL1.f1 or BOOLTBL1.f1 = bool 'true' + ORDER BY BOOLTBL1.f1, BOOLTBL2.f1 +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="booltbl2" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +STMT: SelectStmt +== 065 +|-- +-- SQL syntax +-- Try all combinations to ensure that we get nothing when we expect nothing +-- - thomas 2000-01-04 +|-- + +SELECT f1 + FROM BOOLTBL1 + WHERE f1 IS TRUE +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 066 +SELECT f1 + FROM BOOLTBL1 + WHERE f1 IS NOT FALSE +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 067 +SELECT f1 + FROM BOOLTBL1 + WHERE f1 IS FALSE +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 068 +SELECT f1 + FROM BOOLTBL1 + WHERE f1 IS NOT TRUE +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 069 +SELECT f1 + FROM BOOLTBL2 + WHERE f1 IS TRUE +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 070 +SELECT f1 + FROM BOOLTBL2 + WHERE f1 IS NOT FALSE +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 071 +SELECT f1 + FROM BOOLTBL2 + WHERE f1 IS FALSE +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 072 +SELECT f1 + FROM BOOLTBL2 + WHERE f1 IS NOT TRUE +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 073 +|-- +-- Tests for BooleanTest +|-- +CREATE TABLE BOOLTBL3 (d text, b bool, o int) +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DDL +STMT: CreateStmt +== 074 +INSERT INTO BOOLTBL3 (d, b, o) VALUES ('true', true, 1) +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +INSERT INTO BOOLTBL3 (d, b, o) VALUES ('false', false, 2) +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 076 +INSERT INTO BOOLTBL3 (d, b, o) VALUES ('null', null, 3) +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +SELECT + d, + b IS TRUE AS istrue, + b IS NOT TRUE AS isnottrue, + b IS FALSE AS isfalse, + b IS NOT FALSE AS isnotfalse, + b IS UNKNOWN AS isunknown, + b IS NOT UNKNOWN AS isnotunknown +FROM booltbl3 ORDER BY o +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=Select +STMT: SelectStmt +== 078 +-- Test to make sure short-circuiting and NULL handling is +-- correct. Use a table as source to prevent constant simplification +-- from interfering. +CREATE TABLE booltbl4(isfalse bool, istrue bool, isnul bool) +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=DDL +STMT: CreateStmt +== 079 +INSERT INTO booltbl4 VALUES (false, true, null) +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +-- AND expression need to return null if there's any nulls and not all +-- of the value are true +SELECT istrue AND isnul AND istrue FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 081 +SELECT istrue AND istrue AND isnul FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 082 +SELECT isnul AND istrue AND istrue FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 083 +SELECT isfalse AND isnul AND istrue FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 084 +SELECT istrue AND isfalse AND isnul FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 085 +SELECT isnul AND istrue AND isfalse FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 086 +-- OR expression need to return null if there's any nulls and none +-- of the value is true +SELECT isfalse OR isnul OR isfalse FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 087 +SELECT isfalse OR isfalse OR isnul FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 088 +SELECT isnul OR isfalse OR isfalse FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 089 +SELECT isfalse OR isnul OR istrue FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 090 +SELECT istrue OR isfalse OR isnul FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 091 +SELECT isnul OR istrue OR isfalse FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +== 092 +-- Casts +SELECT 0::boolean +-- +STMT: SelectStmt +== 093 +SELECT 1::boolean +-- +STMT: SelectStmt +== 094 +SELECT 2::boolean +-- +STMT: SelectStmt +== 095 +|-- +-- Clean up +-- Many tables are retained by the regression test, but these do not seem +-- particularly useful so just get rid of them for now. +-- - thomas 1997-11-30 +|-- + +DROP TABLE BOOLTBL1 +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DDL +STMT: DropStmt +== 096 +DROP TABLE BOOLTBL2 +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DDL +STMT: DropStmt +== 097 +DROP TABLE BOOLTBL3 +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DDL +STMT: DropStmt +== 098 +DROP TABLE BOOLTBL4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/box.metadata.json b/parser/testdata/summary/postgres_regress/box.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/box.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/box.test b/parser/testdata/summary/postgres_regress/box.test new file mode 100644 index 0000000..b35f833 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/box.test @@ -0,0 +1,764 @@ +== 001 +|-- +-- BOX +|-- + +|-- +-- box logic +-- o +-- 3 o--|X +-- | o| +-- 2 +-+-+ | +-- | | | | +-- 1 | o-+-o +-- | | +-- 0 +---+ +|-- +-- 0 1 2 3 +|-- + +-- boxes are specified by two points, given by four floats x1,y1,x2,y2 + + +CREATE TABLE BOX_TBL (f1 box) +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO BOX_TBL (f1) VALUES ('((-8, 2), (-2, -10))') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +-- degenerate cases where the box is a line or a point +-- note that lines and points boxes all have zero area +INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- badly formatted box inputs +INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO BOX_TBL (f1) VALUES ('[1, 2, 3, 4)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO BOX_TBL (f1) VALUES ('(1, 2, 3, 4]') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO BOX_TBL (f1) VALUES ('(1, 2, 3, 4) x') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +SELECT * FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +STMT: SelectStmt +== 013 +SELECT b.*, area(b.f1) as barea + FROM BOX_TBL b +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FUNCTION: name="area" function="area" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- overlap +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 && box '(2.5,2.5,1.0,1.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 015 +-- left-or-overlap (x only) +SELECT b1.* + FROM BOX_TBL b1 + WHERE b1.f1 &< box '(2.0,2.0,2.5,2.5)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +FILTER: schema="" table="b1" column="f1" +STMT: SelectStmt +== 016 +-- right-or-overlap (x only) +SELECT b1.* + FROM BOX_TBL b1 + WHERE b1.f1 &> box '(2.0,2.0,2.5,2.5)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +FILTER: schema="" table="b1" column="f1" +STMT: SelectStmt +== 017 +-- left of +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 << box '(3.0,3.0,5.0,5.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 018 +-- area <= +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 <= box '(3.0,3.0,5.0,5.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 019 +-- area < +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 < box '(3.0,3.0,5.0,5.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 020 +-- area = +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 = box '(3.0,3.0,5.0,5.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 021 +-- area > +SELECT b.f1 + FROM BOX_TBL b -- zero area + WHERE b.f1 > box '(3.5,3.0,4.5,3.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 022 +-- area >= +SELECT b.f1 + FROM BOX_TBL b -- zero area + WHERE b.f1 >= box '(3.5,3.0,4.5,3.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 023 +-- right of +SELECT b.f1 + FROM BOX_TBL b + WHERE box '(3.0,3.0,5.0,5.0)' >> b.f1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 024 +-- contained in +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 <@ box '(0,0,3,3)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 025 +-- contains +SELECT b.f1 + FROM BOX_TBL b + WHERE box '(0,0,3,3)' @> b.f1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 026 +-- box equality +SELECT b.f1 + FROM BOX_TBL b + WHERE box '(1,1,3,3)' ~= b.f1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 027 +-- center of box, left unary operator +SELECT @@(b1.f1) AS p + FROM BOX_TBL b1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +STMT: SelectStmt +== 028 +-- wholly-contained +SELECT b1.*, b2.* + FROM BOX_TBL b1, BOX_TBL b2 + WHERE b1.f1 @> b2.f1 and not b1.f1 ~= b2.f1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +FILTER: schema="" table="b1" column="f1" +FILTER: schema="" table="b2" column="f1" +FILTER: schema="" table="b1" column="f1" +FILTER: schema="" table="b2" column="f1" +STMT: SelectStmt +== 029 +SELECT height(f1), width(f1) FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="height" function="height" schema="" ctx=Call +FUNCTION: name="width" function="width" schema="" ctx=Call +STMT: SelectStmt +== 030 +|-- +-- Test the SP-GiST index +|-- + +CREATE TEMPORARY TABLE box_temp (f1 box) +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=DDL +STMT: CreateStmt +== 031 +INSERT INTO box_temp + SELECT box(point(i, i), point(i * 2, i * 2)) + FROM generate_series(1, 50) AS i +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 032 +CREATE INDEX box_spgist ON box_temp USING spgist (f1) +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=DDL +STMT: IndexStmt +== 033 +INSERT INTO box_temp + VALUES (NULL), + ('(0,0)(0,100)'), + ('(-3,4.3333333333)(40,1)'), + ('(0,100)(0,infinity)'), + ('(-infinity,0)(0,infinity)'), + ('(-infinity,-infinity)(infinity,infinity)') +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +SET enable_seqscan = false +-- +STMT: VariableSetStmt +== 035 +SELECT * FROM box_temp WHERE f1 << '(10,20),(30,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 036 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 << '(10,20),(30,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 037 +SELECT * FROM box_temp WHERE f1 &< '(10,4.333334),(5,100)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 038 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &< '(10,4.333334),(5,100)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 039 +SELECT * FROM box_temp WHERE f1 && '(15,20),(25,30)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 040 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 && '(15,20),(25,30)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 041 +SELECT * FROM box_temp WHERE f1 &> '(40,30),(45,50)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 042 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &> '(40,30),(45,50)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 043 +SELECT * FROM box_temp WHERE f1 >> '(30,40),(40,30)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 044 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 >> '(30,40),(40,30)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 045 +SELECT * FROM box_temp WHERE f1 <<| '(10,4.33334),(5,100)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 046 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 <<| '(10,4.33334),(5,100)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 047 +SELECT * FROM box_temp WHERE f1 &<| '(10,4.3333334),(5,1)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 048 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &<| '(10,4.3333334),(5,1)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 049 +SELECT * FROM box_temp WHERE f1 |&> '(49.99,49.99),(49.99,49.99)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 050 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 |&> '(49.99,49.99),(49.99,49.99)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 051 +SELECT * FROM box_temp WHERE f1 |>> '(37,38),(39,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 052 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 |>> '(37,38),(39,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 053 +SELECT * FROM box_temp WHERE f1 @> '(10,11),(15,16)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 054 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 @> '(10,11),(15,15)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 055 +SELECT * FROM box_temp WHERE f1 <@ '(10,15),(30,35)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 056 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 <@ '(10,15),(30,35)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 057 +SELECT * FROM box_temp WHERE f1 ~= '(20,20),(40,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 058 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 ~= '(20,20),(40,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 059 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 060 +DROP INDEX box_spgist +-- +STMT: DropStmt +== 061 +|-- +-- Test the SP-GiST index on the larger volume of data +|-- +CREATE TABLE quad_box_tbl (id int, b box) +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DDL +STMT: CreateStmt +== 062 +INSERT INTO quad_box_tbl + SELECT (x - 1) * 100 + y, box(point(x * 10, y * 10), point(x * 10 + 5, y * 10 + 5)) + FROM generate_series(1, 100) x, + generate_series(1, 100) y +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 063 +-- insert repeating data to test allTheSame +INSERT INTO quad_box_tbl + SELECT i, '((200, 300),(210, 310))' + FROM generate_series(10001, 11000) AS i +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 064 +INSERT INTO quad_box_tbl +VALUES + (11001, NULL), + (11002, NULL), + (11003, '((-infinity,-infinity),(infinity,infinity))'), + (11004, '((-infinity,100),(-infinity,500))'), + (11005, '((-infinity,-infinity),(700,infinity))') +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +CREATE INDEX quad_box_tbl_idx ON quad_box_tbl USING spgist(b) +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DDL +STMT: IndexStmt +== 066 +-- get reference results for ORDER BY distance from seq scan +SET enable_seqscan = ON +-- +STMT: VariableSetStmt +== 067 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +== 068 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 069 +CREATE TABLE quad_box_tbl_ord_seq1 AS +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl +-- +TABLE: name="quad_box_tbl_ord_seq1" schema="" table="quad_box_tbl_ord_seq1" ctx=DDL +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 070 +CREATE TABLE quad_box_tbl_ord_seq2 AS +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl WHERE b <@ box '((200,300),(500,600))' +-- +TABLE: name="quad_box_tbl_ord_seq2" schema="" table="quad_box_tbl_ord_seq2" ctx=DDL +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 071 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 072 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +== 073 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +== 074 +SELECT count(*) FROM quad_box_tbl WHERE b << box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 075 +SELECT count(*) FROM quad_box_tbl WHERE b &< box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 076 +SELECT count(*) FROM quad_box_tbl WHERE b && box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 077 +SELECT count(*) FROM quad_box_tbl WHERE b &> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 078 +SELECT count(*) FROM quad_box_tbl WHERE b >> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 079 +SELECT count(*) FROM quad_box_tbl WHERE b >> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 080 +SELECT count(*) FROM quad_box_tbl WHERE b <<| box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 081 +SELECT count(*) FROM quad_box_tbl WHERE b &<| box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 082 +SELECT count(*) FROM quad_box_tbl WHERE b |&> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 083 +SELECT count(*) FROM quad_box_tbl WHERE b |>> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 084 +SELECT count(*) FROM quad_box_tbl WHERE b @> box '((201,301),(202,303))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 085 +SELECT count(*) FROM quad_box_tbl WHERE b <@ box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 086 +SELECT count(*) FROM quad_box_tbl WHERE b ~= box '((200,300),(205,305))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 087 +-- test ORDER BY distance +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +== 088 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 089 +EXPLAIN (COSTS OFF) +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 090 +CREATE TEMP TABLE quad_box_tbl_ord_idx1 AS +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl +-- +TABLE: name="quad_box_tbl_ord_idx1" schema="" table="quad_box_tbl_ord_idx1" ctx=DDL +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 091 +SELECT * +FROM quad_box_tbl_ord_seq1 seq FULL JOIN quad_box_tbl_ord_idx1 idx + ON seq.n = idx.n AND seq.id = idx.id AND + (seq.dist = idx.dist OR seq.dist IS NULL AND idx.dist IS NULL) +WHERE seq.id IS NULL OR idx.id IS NULL +-- +TABLE: name="quad_box_tbl_ord_seq1" schema="" table="quad_box_tbl_ord_seq1" ctx=Select +TABLE: name="quad_box_tbl_ord_idx1" schema="" table="quad_box_tbl_ord_idx1" ctx=Select +ALIAS: "idx"="quad_box_tbl_ord_idx1" +ALIAS: "seq"="quad_box_tbl_ord_seq1" +FILTER: schema="" table="seq" column="id" +FILTER: schema="" table="idx" column="id" +STMT: SelectStmt +== 092 +EXPLAIN (COSTS OFF) +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl WHERE b <@ box '((200,300),(500,600))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 093 +CREATE TEMP TABLE quad_box_tbl_ord_idx2 AS +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl WHERE b <@ box '((200,300),(500,600))' +-- +TABLE: name="quad_box_tbl_ord_idx2" schema="" table="quad_box_tbl_ord_idx2" ctx=DDL +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 094 +SELECT * +FROM quad_box_tbl_ord_seq2 seq FULL JOIN quad_box_tbl_ord_idx2 idx + ON seq.n = idx.n AND seq.id = idx.id AND + (seq.dist = idx.dist OR seq.dist IS NULL AND idx.dist IS NULL) +WHERE seq.id IS NULL OR idx.id IS NULL +-- +TABLE: name="quad_box_tbl_ord_seq2" schema="" table="quad_box_tbl_ord_seq2" ctx=Select +TABLE: name="quad_box_tbl_ord_idx2" schema="" table="quad_box_tbl_ord_idx2" ctx=Select +ALIAS: "idx"="quad_box_tbl_ord_idx2" +ALIAS: "seq"="quad_box_tbl_ord_seq2" +FILTER: schema="" table="seq" column="id" +FILTER: schema="" table="idx" column="id" +STMT: SelectStmt +== 095 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 096 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 097 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 098 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('200', 'box') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 099 +SELECT * FROM pg_input_error_info('200', 'box') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 100 +SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 101 +SELECT * FROM pg_input_error_info('((200,300),(500, xyz))', 'box') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/brin.metadata.json b/parser/testdata/summary/postgres_regress/brin.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/brin.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/brin.test b/parser/testdata/summary/postgres_regress/brin.test new file mode 100644 index 0000000..e2fab7b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/brin.test @@ -0,0 +1,849 @@ +== 001 +CREATE TABLE brintest (byteacol bytea, + charcol "char", + namecol name, + int8col bigint, + int2col smallint, + int4col integer, + textcol text, + oidcol oid, + tidcol tid, + float4col real, + float8col double precision, + macaddrcol macaddr, + inetcol inet, + cidrcol cidr, + bpcharcol character, + datecol date, + timecol time without time zone, + timestampcol timestamp without time zone, + timestamptzcol timestamp with time zone, + intervalcol interval, + timetzcol time with time zone, + bitcol bit(10), + varbitcol bit varying(16), + numericcol numeric, + uuidcol uuid, + int4rangecol int4range, + lsncol pg_lsn, + boxcol box +) WITH (fillfactor=10, autovacuum_enabled=off) +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO brintest SELECT + repeat(stringu1, 8)::bytea, + substr(stringu1, 1, 1)::"char", + stringu1::name, 142857 * tenthous, + thousand, + twothousand, + repeat(stringu1, 8), + unique1::oid, + format('(%s,%s)', tenthous, twenty)::tid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + inet '10.2.3.4/24' + tenthous, + cidr '10.2.3/24' + tenthous, + substr(stringu1, 1, 1)::bpchar, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20+02' + hundred * interval '15 seconds', + thousand::bit(10), + tenthous::bit(16)::varbit, + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + int4range(thousand, twothousand), + format('%s/%s%s', odd, even, tenthous)::pg_lsn, + box(point(odd, even), point(thousand, twothousand)) +FROM tenk1 ORDER BY unique2 LIMIT 100 +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +-- throw in some NULL's and different values +INSERT INTO brintest (inetcol, cidrcol, int4rangecol) SELECT + inet 'fe80::6e40:8ff:fea9:8c46' + tenthous, + cidr 'fe80::6e40:8ff:fea9:8c46' + tenthous, + 'empty'::int4range +FROM tenk1 ORDER BY thousand, tenthous LIMIT 25 +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 004 +CREATE INDEX brinidx ON brintest USING brin ( + byteacol, + charcol, + namecol, + int8col, + int2col, + int4col, + textcol, + oidcol, + tidcol, + float4col, + float8col, + macaddrcol, + inetcol inet_inclusion_ops, + inetcol inet_minmax_ops, + cidrcol inet_inclusion_ops, + cidrcol inet_minmax_ops, + bpcharcol, + datecol, + timecol, + timestampcol, + timestamptzcol, + intervalcol, + timetzcol, + bitcol, + varbitcol, + numericcol, + uuidcol, + int4rangecol, + lsncol, + boxcol +) with (pages_per_range = 1) +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DDL +STMT: IndexStmt +== 005 +CREATE TABLE brinopers (colname name, typ text, + op text[], value text[], matches int[], + check (cardinality(op) = cardinality(value)), + check (cardinality(op) = cardinality(matches))) +-- +TABLE: name="brinopers" schema="" table="brinopers" ctx=DDL +STMT: CreateStmt +== 006 +INSERT INTO brinopers VALUES + ('byteacol', 'bytea', + '{>, >=, =, <=, <}', + '{AAAAAA, AAAAAA, BNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAA, ZZZZZZ, ZZZZZZ}', + '{100, 100, 1, 100, 100}'), + ('charcol', '"char"', + '{>, >=, =, <=, <}', + '{A, A, M, Z, Z}', + '{97, 100, 6, 100, 98}'), + ('namecol', 'name', + '{>, >=, =, <=, <}', + '{AAAAAA, AAAAAA, MAAAAA, ZZAAAA, ZZAAAA}', + '{100, 100, 2, 100, 100}'), + ('int2col', 'int2', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 999}', + '{100, 100, 1, 100, 100}'), + ('int2col', 'int4', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int2col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int2', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int4', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('int8col', 'int2', + '{>, >=}', + '{0, 0}', + '{100, 100}'), + ('int8col', 'int4', + '{>, >=}', + '{0, 0}', + '{100, 100}'), + ('int8col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 1257141600, 1428427143, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('textcol', 'text', + '{>, >=, =, <=, <}', + '{ABABAB, ABABAB, BNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAA, ZZAAAA, ZZAAAA}', + '{100, 100, 1, 100, 100}'), + ('oidcol', 'oid', + '{>, >=, =, <=, <}', + '{0, 0, 8800, 9999, 9999}', + '{100, 100, 1, 100, 100}'), + ('tidcol', 'tid', + '{>, >=, =, <=, <}', + '{"(0,0)", "(0,0)", "(8800,0)", "(9999,19)", "(9999,19)"}', + '{100, 100, 1, 100, 100}'), + ('float4col', 'float4', + '{>, >=, =, <=, <}', + '{0.0103093, 0.0103093, 1, 1, 1}', + '{100, 100, 4, 100, 96}'), + ('float4col', 'float8', + '{>, >=, =, <=, <}', + '{0.0103093, 0.0103093, 1, 1, 1}', + '{100, 100, 4, 100, 96}'), + ('float8col', 'float4', + '{>, >=, =, <=, <}', + '{0, 0, 0, 1.98, 1.98}', + '{99, 100, 1, 100, 100}'), + ('float8col', 'float8', + '{>, >=, =, <=, <}', + '{0, 0, 0, 1.98, 1.98}', + '{99, 100, 1, 100, 100}'), + ('macaddrcol', 'macaddr', + '{>, >=, =, <=, <}', + '{00:00:01:00:00:00, 00:00:01:00:00:00, 2c:00:2d:00:16:00, ff:fe:00:00:00:00, ff:fe:00:00:00:00}', + '{99, 100, 2, 100, 100}'), + ('inetcol', 'inet', + '{&&, =, <, <=, >, >=, >>=, >>, <<=, <<}', + '{10/8, 10.2.14.231/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0, 10.2.14.231/24, 10.2.14.231/25, 10.2.14.231/8, 0/0}', + '{100, 1, 100, 100, 125, 125, 2, 2, 100, 100}'), + ('inetcol', 'inet', + '{&&, >>=, <<=, =}', + '{fe80::6e40:8ff:fea9:a673/32, fe80::6e40:8ff:fea9:8c46, fe80::6e40:8ff:fea9:a673/32, fe80::6e40:8ff:fea9:8c46}', + '{25, 1, 25, 1}'), + ('inetcol', 'cidr', + '{&&, <, <=, >, >=, >>=, >>, <<=, <<}', + '{10/8, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0, 10.2.14/24, 10.2.14/25, 10/8, 0/0}', + '{100, 100, 100, 125, 125, 2, 2, 100, 100}'), + ('inetcol', 'cidr', + '{&&, >>=, <<=, =}', + '{fe80::/32, fe80::6e40:8ff:fea9:8c46, fe80::/32, fe80::6e40:8ff:fea9:8c46}', + '{25, 1, 25, 1}'), + ('cidrcol', 'inet', + '{&&, =, <, <=, >, >=, >>=, >>, <<=, <<}', + '{10/8, 10.2.14/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0, 10.2.14.231/24, 10.2.14.231/25, 10.2.14.231/8, 0/0}', + '{100, 2, 100, 100, 125, 125, 2, 2, 100, 100}'), + ('cidrcol', 'inet', + '{&&, >>=, <<=, =}', + '{fe80::6e40:8ff:fea9:a673/32, fe80::6e40:8ff:fea9:8c46, fe80::6e40:8ff:fea9:a673/32, fe80::6e40:8ff:fea9:8c46}', + '{25, 1, 25, 1}'), + ('cidrcol', 'cidr', + '{&&, =, <, <=, >, >=, >>=, >>, <<=, <<}', + '{10/8, 10.2.14/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0, 10.2.14/24, 10.2.14/25, 10/8, 0/0}', + '{100, 2, 100, 100, 125, 125, 2, 2, 100, 100}'), + ('cidrcol', 'cidr', + '{&&, >>=, <<=, =}', + '{fe80::/32, fe80::6e40:8ff:fea9:8c46, fe80::/32, fe80::6e40:8ff:fea9:8c46}', + '{25, 1, 25, 1}'), + ('bpcharcol', 'bpchar', + '{>, >=, =, <=, <}', + '{A, A, W, Z, Z}', + '{97, 100, 6, 100, 98}'), + ('datecol', 'date', + '{>, >=, =, <=, <}', + '{1995-08-15, 1995-08-15, 2009-12-01, 2022-12-30, 2022-12-30}', + '{100, 100, 1, 100, 100}'), + ('timecol', 'time', + '{>, >=, =, <=, <}', + '{01:20:30, 01:20:30, 02:28:57, 06:28:31.5, 06:28:31.5}', + '{100, 100, 1, 100, 100}'), + ('timestampcol', 'timestamp', + '{>, >=, =, <=, <}', + '{1942-07-23 03:05:09, 1942-07-23 03:05:09, 1964-03-24 19:26:45, 1984-01-20 22:42:21, 1984-01-20 22:42:21}', + '{100, 100, 1, 100, 100}'), + ('timestampcol', 'timestamptz', + '{>, >=, =, <=, <}', + '{1942-07-23 03:05:09, 1942-07-23 03:05:09, 1964-03-24 19:26:45, 1984-01-20 22:42:21, 1984-01-20 22:42:21}', + '{100, 100, 1, 100, 100}'), + ('timestamptzcol', 'timestamptz', + '{>, >=, =, <=, <}', + '{1972-10-10 03:00:00-04, 1972-10-10 03:00:00-04, 1972-10-19 09:00:00-07, 1972-11-20 19:00:00-03, 1972-11-20 19:00:00-03}', + '{100, 100, 1, 100, 100}'), + ('intervalcol', 'interval', + '{>, >=, =, <=, <}', + '{00:00:00, 00:00:00, 1 mons 13 days 12:24, 2 mons 23 days 07:48:00, 1 year}', + '{100, 100, 1, 100, 100}'), + ('timetzcol', 'timetz', + '{>, >=, =, <=, <}', + '{01:30:20+02, 01:30:20+02, 01:35:50+02, 23:55:05+02, 23:55:05+02}', + '{99, 100, 2, 100, 100}'), + ('bitcol', 'bit(10)', + '{>, >=, =, <=, <}', + '{0000000010, 0000000010, 0011011110, 1111111000, 1111111000}', + '{100, 100, 1, 100, 100}'), + ('varbitcol', 'varbit(16)', + '{>, >=, =, <=, <}', + '{0000000000000100, 0000000000000100, 0001010001100110, 1111111111111000, 1111111111111000}', + '{100, 100, 1, 100, 100}'), + ('numericcol', 'numeric', + '{>, >=, =, <=, <}', + '{0.00, 0.01, 2268164.347826086956521739130434782609, 99470151.9, 99470151.9}', + '{100, 100, 1, 100, 100}'), + ('uuidcol', 'uuid', + '{>, >=, =, <=, <}', + '{00040004-0004-0004-0004-000400040004, 00040004-0004-0004-0004-000400040004, 52225222-5222-5222-5222-522252225222, 99989998-9998-9998-9998-999899989998, 99989998-9998-9998-9998-999899989998}', + '{100, 100, 1, 100, 100}'), + ('int4rangecol', 'int4range', + '{<<, &<, &&, &>, >>, @>, <@, =, <, <=, >, >=}', + '{"[10000,)","[10000,)","(,]","[3,4)","[36,44)","(1500,1501]","[3,4)","[222,1222)","[36,44)","[43,1043)","[367,4466)","[519,)"}', + '{53, 53, 53, 53, 50, 22, 72, 1, 74, 75, 34, 21}'), + ('int4rangecol', 'int4range', + '{@>, <@, =, <=, >, >=}', + '{empty, empty, empty, empty, empty, empty}', + '{125, 72, 72, 72, 53, 125}'), + ('int4rangecol', 'int4', + '{@>}', + '{1500}', + '{22}'), + ('lsncol', 'pg_lsn', + '{>, >=, =, <=, <, IS, IS NOT}', + '{0/1200, 0/1200, 44/455222, 198/1999799, 198/1999799, NULL, NULL}', + '{100, 100, 1, 100, 100, 25, 100}'), + ('boxcol', 'point', + '{@>}', + '{"(500,43)"}', + '{11}'), + ('boxcol', 'box', + '{<<, &<, &&, &>, >>, <<|, &<|, |&>, |>>, @>, <@, ~=}', + '{"((1000,2000),(3000,4000))","((1,2),(3000,4000))","((1,2),(3000,4000))","((1,2),(3000,4000))","((1,2),(3,4))","((1000,2000),(3000,4000))","((1,2000),(3,4000))","((1000,2),(3000,4))","((1,2),(3,4))","((1,2),(300,400))","((1,2),(3000,4000))","((222,1222),(44,45))"}', + '{100, 100, 100, 99, 96, 100, 100, 99, 96, 1, 99, 1}') +-- +TABLE: name="brinopers" schema="" table="brinopers" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +DO $x$ +DECLARE + r record; + r2 record; + cond text; + idx_ctids tid[]; + ss_ctids tid[]; + count int; + plan_ok bool; + plan_line text; +BEGIN + FOR r IN SELECT colname, oper, typ, value[ordinality], matches[ordinality] FROM brinopers, unnest(op) WITH ORDINALITY AS oper LOOP + + -- prepare the condition + IF r.value IS NULL THEN + cond := format('%I %s %L', r.colname, r.oper, r.value); + ELSE + cond := format('%I %s %L::%s', r.colname, r.oper, r.value, r.typ); + END IF; + + -- run the query using the brin index + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Bitmap Heap Scan on brintest%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get bitmap indexscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest WHERE %s $y$, cond) + INTO idx_ctids; + + -- run the query using a seqscan + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Seq Scan on brintest%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get seqscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest WHERE %s $y$, cond) + INTO ss_ctids; + + -- make sure both return the same results + count := array_length(idx_ctids, 1); + + IF NOT (count = array_length(ss_ctids, 1) AND + idx_ctids @> ss_ctids AND + idx_ctids <@ ss_ctids) THEN + -- report the results of each scan to make the differences obvious + RAISE WARNING 'something not right in %: count %', r, count; + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest WHERE ' || cond LOOP + RAISE NOTICE 'seqscan: %', r2; + END LOOP; + + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest WHERE ' || cond LOOP + RAISE NOTICE 'bitmapscan: %', r2; + END LOOP; + END IF; + + -- make sure we found expected number of matches + IF count != r.matches THEN RAISE WARNING 'unexpected number of results % for %', count, r; END IF; + END LOOP; +END; +$x$ +-- +STMT: DoStmt +== 008 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 009 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 010 +INSERT INTO brintest SELECT + repeat(stringu1, 42)::bytea, + substr(stringu1, 1, 1)::"char", + stringu1::name, 142857 * tenthous, + thousand, + twothousand, + repeat(stringu1, 42), + unique1::oid, + format('(%s,%s)', tenthous, twenty)::tid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + inet '10.2.3.4' + tenthous, + cidr '10.2.3/24' + tenthous, + substr(stringu1, 1, 1)::bpchar, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20' + hundred * interval '15 seconds', + thousand::bit(10), + tenthous::bit(16)::varbit, + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + int4range(thousand, twothousand), + format('%s/%s%s', odd, even, tenthous)::pg_lsn, + box(point(odd, even), point(thousand, twothousand)) +FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5 +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 011 +SELECT brin_desummarize_range('brinidx', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 012 +VACUUM brintest +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DDL +STMT: VacuumStmt +== 013 +-- force a summarization cycle in brinidx + +UPDATE brintest SET int8col = int8col * int4col +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +STMT: UpdateStmt +== 014 +UPDATE brintest SET textcol = '' WHERE textcol IS NOT NULL +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +STMT: UpdateStmt +== 015 +-- Tests for brin_summarize_new_values +SELECT brin_summarize_new_values('brintest') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- error, not an index +SELECT brin_summarize_new_values('tenk1_unique1') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- error, not a BRIN index +SELECT brin_summarize_new_values('brinidx') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- ok, no change expected + +-- Tests for brin_desummarize_range +SELECT brin_desummarize_range('brinidx', -1) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- error, invalid range +SELECT brin_desummarize_range('brinidx', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT brin_desummarize_range('brinidx', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT brin_desummarize_range('brinidx', 100000000) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- Test brin_summarize_range +CREATE TABLE brin_summarize ( + value int +) WITH (fillfactor=10, autovacuum_enabled=false) +-- +TABLE: name="brin_summarize" schema="" table="brin_summarize" ctx=DDL +STMT: CreateStmt +== 023 +CREATE INDEX brin_summarize_idx ON brin_summarize USING brin (value) WITH (pages_per_range=2) +-- +TABLE: name="brin_summarize" schema="" table="brin_summarize" ctx=DDL +STMT: IndexStmt +== 024 +-- Fill a few pages +DO $$ +DECLARE curtid tid; +BEGIN + LOOP + INSERT INTO brin_summarize VALUES (1) RETURNING ctid INTO curtid; + EXIT WHEN curtid > tid '(2, 0)'; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 025 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_idx', 0) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 026 +-- nothing: already summarized +SELECT brin_summarize_range('brin_summarize_idx', 1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 027 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_idx', 2) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 028 +-- nothing: page doesn't exist in table +SELECT brin_summarize_range('brin_summarize_idx', 4294967295) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 029 +-- invalid block number values +SELECT brin_summarize_range('brin_summarize_idx', -1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT brin_summarize_range('brin_summarize_idx', 4294967296) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- test value merging in add_value +CREATE TABLE brintest_2 (n numrange) +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DDL +STMT: CreateStmt +== 032 +CREATE INDEX brinidx_2 ON brintest_2 USING brin (n) +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DDL +STMT: IndexStmt +== 033 +INSERT INTO brintest_2 VALUES ('empty') +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO brintest_2 VALUES (numrange(0, 2^1000::numeric)) +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO brintest_2 VALUES ('(-1, 0)') +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +SELECT brin_desummarize_range('brinidx', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT brin_summarize_range('brinidx', 0) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 038 +DROP TABLE brintest_2 +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DDL +STMT: DropStmt +== 039 +-- test brin cost estimates behave sanely based on correlation of values +CREATE TABLE brin_test (a INT, b INT) +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DDL +STMT: CreateStmt +== 040 +INSERT INTO brin_test SELECT x/100,x%100 FROM generate_series(1,10000) x(x) +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 041 +CREATE INDEX brin_test_a_idx ON brin_test USING brin (a) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DDL +STMT: IndexStmt +== 042 +CREATE INDEX brin_test_b_idx ON brin_test USING brin (b) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DDL +STMT: IndexStmt +== 043 +VACUUM ANALYZE brin_test +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DDL +STMT: VacuumStmt +== 044 +-- Ensure brin index is used when columns are perfectly correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test WHERE a = 1 +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 045 +-- Ensure brin index is not used when values are not correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test WHERE b = 1 +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 046 +-- make sure data are properly de-toasted in BRIN index +CREATE TABLE brintest_3 (a text, b text, c text, d text) +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: CreateStmt +== 047 +-- long random strings (~2000 chars each, so ~6kB for min/max on two +-- columns) to trigger toasting +WITH rand_value AS (SELECT string_agg(fipshash(i::text),'') AS val FROM generate_series(1,60) s(i)) +INSERT INTO brintest_3 +SELECT val, val, val, val FROM rand_value +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DML +CTE: "rand_value" +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 048 +CREATE INDEX brin_test_toast_idx ON brintest_3 USING brin (b, c) +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: IndexStmt +== 049 +DELETE FROM brintest_3 +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DML +STMT: DeleteStmt +== 050 +-- We need to wait a bit for all transactions to complete, so that the +-- vacuum actually removes the TOAST rows. Creating an index concurrently +-- is a one way to achieve that, because it does exactly such wait. +CREATE INDEX CONCURRENTLY brin_test_temp_idx ON brintest_3(a) +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: IndexStmt +== 051 +DROP INDEX brin_test_temp_idx +-- +STMT: DropStmt +== 052 +-- vacuum the table, to discard TOAST data +VACUUM brintest_3 +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: VacuumStmt +== 053 +-- retry insert with a different random-looking (but deterministic) value +-- the value is different, and so should replace either min or max in the +-- brin summary +WITH rand_value AS (SELECT string_agg(fipshash((-i)::text),'') AS val FROM generate_series(1,60) s(i)) +INSERT INTO brintest_3 +SELECT val, val, val, val FROM rand_value +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DML +CTE: "rand_value" +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 054 +-- now try some queries, accessing the brin index +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 055 +EXPLAIN (COSTS OFF) +SELECT * FROM brintest_3 WHERE b < '0' +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 056 +SELECT * FROM brintest_3 WHERE b < '0' +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 057 +DROP TABLE brintest_3 +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: DropStmt +== 058 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 059 +-- test an unlogged table, mostly to get coverage of brinbuildempty +CREATE UNLOGGED TABLE brintest_unlogged (n numrange) +-- +TABLE: name="brintest_unlogged" schema="" table="brintest_unlogged" ctx=DDL +STMT: CreateStmt +== 060 +CREATE INDEX brinidx_unlogged ON brintest_unlogged USING brin (n) +-- +TABLE: name="brintest_unlogged" schema="" table="brintest_unlogged" ctx=DDL +STMT: IndexStmt +== 061 +INSERT INTO brintest_unlogged VALUES (numrange(0, 2^1000::numeric)) +-- +TABLE: name="brintest_unlogged" schema="" table="brintest_unlogged" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 062 +DROP TABLE brintest_unlogged +-- +TABLE: name="brintest_unlogged" schema="" table="brintest_unlogged" ctx=DDL +STMT: DropStmt +== 063 +-- test that the insert optimization works if no rows end up inserted +CREATE TABLE brin_insert_optimization (a int) +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DDL +STMT: CreateStmt +== 064 +INSERT INTO brin_insert_optimization VALUES (1) +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +CREATE INDEX brin_insert_optimization_idx ON brin_insert_optimization USING brin (a) +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DDL +STMT: IndexStmt +== 066 +UPDATE brin_insert_optimization SET a = a +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DML +STMT: UpdateStmt +== 067 +REINDEX INDEX CONCURRENTLY brin_insert_optimization_idx +-- +STMT: ReindexStmt +== 068 +DROP TABLE brin_insert_optimization +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/brin_bloom.metadata.json b/parser/testdata/summary/postgres_regress/brin_bloom.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/brin_bloom.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/brin_bloom.test b/parser/testdata/summary/postgres_regress/brin_bloom.test new file mode 100644 index 0000000..6774d89 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/brin_bloom.test @@ -0,0 +1,574 @@ +== 001 +CREATE TABLE brintest_bloom (byteacol bytea, + charcol "char", + namecol name, + int8col bigint, + int2col smallint, + int4col integer, + textcol text, + oidcol oid, + float4col real, + float8col double precision, + macaddrcol macaddr, + inetcol inet, + cidrcol cidr, + bpcharcol character, + datecol date, + timecol time without time zone, + timestampcol timestamp without time zone, + timestamptzcol timestamp with time zone, + intervalcol interval, + timetzcol time with time zone, + numericcol numeric, + uuidcol uuid, + lsncol pg_lsn +) WITH (fillfactor=10) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO brintest_bloom SELECT + repeat(stringu1, 8)::bytea, + substr(stringu1, 1, 1)::"char", + stringu1::name, 142857 * tenthous, + thousand, + twothousand, + repeat(stringu1, 8), + unique1::oid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + inet '10.2.3.4/24' + tenthous, + cidr '10.2.3/24' + tenthous, + substr(stringu1, 1, 1)::bpchar, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20+02' + hundred * interval '15 seconds', + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + format('%s/%s%s', odd, even, tenthous)::pg_lsn +FROM tenk1 ORDER BY unique2 LIMIT 100 +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +-- throw in some NULL's and different values +INSERT INTO brintest_bloom (inetcol, cidrcol) SELECT + inet 'fe80::6e40:8ff:fea9:8c46' + tenthous, + cidr 'fe80::6e40:8ff:fea9:8c46' + tenthous +FROM tenk1 ORDER BY thousand, tenthous LIMIT 25 +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 004 +-- test bloom specific index options +-- ndistinct must be >= -1.0 +CREATE INDEX brinidx_bloom ON brintest_bloom USING brin ( + byteacol bytea_bloom_ops(n_distinct_per_range = -1.1) +) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: IndexStmt +== 005 +-- false_positive_rate must be between 0.0001 and 0.25 +CREATE INDEX brinidx_bloom ON brintest_bloom USING brin ( + byteacol bytea_bloom_ops(false_positive_rate = 0.00009) +) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: IndexStmt +== 006 +CREATE INDEX brinidx_bloom ON brintest_bloom USING brin ( + byteacol bytea_bloom_ops(false_positive_rate = 0.26) +) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: IndexStmt +== 007 +CREATE INDEX brinidx_bloom ON brintest_bloom USING brin ( + byteacol bytea_bloom_ops, + charcol char_bloom_ops, + namecol name_bloom_ops, + int8col int8_bloom_ops, + int2col int2_bloom_ops, + int4col int4_bloom_ops, + textcol text_bloom_ops, + oidcol oid_bloom_ops, + float4col float4_bloom_ops, + float8col float8_bloom_ops, + macaddrcol macaddr_bloom_ops, + inetcol inet_bloom_ops, + cidrcol inet_bloom_ops, + bpcharcol bpchar_bloom_ops, + datecol date_bloom_ops, + timecol time_bloom_ops, + timestampcol timestamp_bloom_ops, + timestamptzcol timestamptz_bloom_ops, + intervalcol interval_bloom_ops, + timetzcol timetz_bloom_ops, + numericcol numeric_bloom_ops, + uuidcol uuid_bloom_ops, + lsncol pg_lsn_bloom_ops +) with (pages_per_range = 1) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: IndexStmt +== 008 +CREATE TABLE brinopers_bloom (colname name, typ text, + op text[], value text[], matches int[], + check (cardinality(op) = cardinality(value)), + check (cardinality(op) = cardinality(matches))) +-- +TABLE: name="brinopers_bloom" schema="" table="brinopers_bloom" ctx=DDL +STMT: CreateStmt +== 009 +INSERT INTO brinopers_bloom VALUES + ('byteacol', 'bytea', + '{=}', + '{BNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAA}', + '{1}'), + ('charcol', '"char"', + '{=}', + '{M}', + '{6}'), + ('namecol', 'name', + '{=}', + '{MAAAAA}', + '{2}'), + ('int2col', 'int2', + '{=}', + '{800}', + '{1}'), + ('int4col', 'int4', + '{=}', + '{800}', + '{1}'), + ('int8col', 'int8', + '{=}', + '{1257141600}', + '{1}'), + ('textcol', 'text', + '{=}', + '{BNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAA}', + '{1}'), + ('oidcol', 'oid', + '{=}', + '{8800}', + '{1}'), + ('float4col', 'float4', + '{=}', + '{1}', + '{4}'), + ('float8col', 'float8', + '{=}', + '{0}', + '{1}'), + ('macaddrcol', 'macaddr', + '{=}', + '{2c:00:2d:00:16:00}', + '{2}'), + ('inetcol', 'inet', + '{=}', + '{10.2.14.231/24}', + '{1}'), + ('inetcol', 'cidr', + '{=}', + '{fe80::6e40:8ff:fea9:8c46}', + '{1}'), + ('cidrcol', 'inet', + '{=}', + '{10.2.14/24}', + '{2}'), + ('cidrcol', 'inet', + '{=}', + '{fe80::6e40:8ff:fea9:8c46}', + '{1}'), + ('cidrcol', 'cidr', + '{=}', + '{10.2.14/24}', + '{2}'), + ('cidrcol', 'cidr', + '{=}', + '{fe80::6e40:8ff:fea9:8c46}', + '{1}'), + ('bpcharcol', 'bpchar', + '{=}', + '{W}', + '{6}'), + ('datecol', 'date', + '{=}', + '{2009-12-01}', + '{1}'), + ('timecol', 'time', + '{=}', + '{02:28:57}', + '{1}'), + ('timestampcol', 'timestamp', + '{=}', + '{1964-03-24 19:26:45}', + '{1}'), + ('timestamptzcol', 'timestamptz', + '{=}', + '{1972-10-19 09:00:00-07}', + '{1}'), + ('intervalcol', 'interval', + '{=}', + '{1 mons 13 days 12:24}', + '{1}'), + ('timetzcol', 'timetz', + '{=}', + '{01:35:50+02}', + '{2}'), + ('numericcol', 'numeric', + '{=}', + '{2268164.347826086956521739130434782609}', + '{1}'), + ('uuidcol', 'uuid', + '{=}', + '{52225222-5222-5222-5222-522252225222}', + '{1}'), + ('lsncol', 'pg_lsn', + '{=, IS, IS NOT}', + '{44/455222, NULL, NULL}', + '{1, 25, 100}') +-- +TABLE: name="brinopers_bloom" schema="" table="brinopers_bloom" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +DO $x$ +DECLARE + r record; + r2 record; + cond text; + idx_ctids tid[]; + ss_ctids tid[]; + count int; + plan_ok bool; + plan_line text; +BEGIN + FOR r IN SELECT colname, oper, typ, value[ordinality], matches[ordinality] FROM brinopers_bloom, unnest(op) WITH ORDINALITY AS oper LOOP + + -- prepare the condition + IF r.value IS NULL THEN + cond := format('%I %s %L', r.colname, r.oper, r.value); + ELSE + cond := format('%I %s %L::%s', r.colname, r.oper, r.value, r.typ); + END IF; + + -- run the query using the brin index + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest_bloom WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Bitmap Heap Scan on brintest_bloom%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get bitmap indexscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest_bloom WHERE %s $y$, cond) + INTO idx_ctids; + + -- run the query using a seqscan + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest_bloom WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Seq Scan on brintest_bloom%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get seqscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest_bloom WHERE %s $y$, cond) + INTO ss_ctids; + + -- make sure both return the same results + count := array_length(idx_ctids, 1); + + IF NOT (count = array_length(ss_ctids, 1) AND + idx_ctids @> ss_ctids AND + idx_ctids <@ ss_ctids) THEN + -- report the results of each scan to make the differences obvious + RAISE WARNING 'something not right in %: count %', r, count; + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest_bloom WHERE ' || cond LOOP + RAISE NOTICE 'seqscan: %', r2; + END LOOP; + + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest_bloom WHERE ' || cond LOOP + RAISE NOTICE 'bitmapscan: %', r2; + END LOOP; + END IF; + + -- make sure we found expected number of matches + IF count != r.matches THEN RAISE WARNING 'unexpected number of results % for %', count, r; END IF; + END LOOP; +END; +$x$ +-- +STMT: DoStmt +== 011 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 012 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 013 +INSERT INTO brintest_bloom SELECT + repeat(stringu1, 42)::bytea, + substr(stringu1, 1, 1)::"char", + stringu1::name, 142857 * tenthous, + thousand, + twothousand, + repeat(stringu1, 42), + unique1::oid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + inet '10.2.3.4' + tenthous, + cidr '10.2.3/24' + tenthous, + substr(stringu1, 1, 1)::bpchar, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20' + hundred * interval '15 seconds', + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + format('%s/%s%s', odd, even, tenthous)::pg_lsn +FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5 +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 014 +SELECT brin_desummarize_range('brinidx_bloom', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 015 +VACUUM brintest_bloom +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: VacuumStmt +== 016 +-- force a summarization cycle in brinidx + +UPDATE brintest_bloom SET int8col = int8col * int4col +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +STMT: UpdateStmt +== 017 +UPDATE brintest_bloom SET textcol = '' WHERE textcol IS NOT NULL +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +STMT: UpdateStmt +== 018 +-- Tests for brin_summarize_new_values +SELECT brin_summarize_new_values('brintest_bloom') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- error, not an index +SELECT brin_summarize_new_values('tenk1_unique1') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 020 +-- error, not a BRIN index +SELECT brin_summarize_new_values('brinidx_bloom') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 021 +-- ok, no change expected + +-- Tests for brin_desummarize_range +SELECT brin_desummarize_range('brinidx_bloom', -1) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- error, invalid range +SELECT brin_desummarize_range('brinidx_bloom', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT brin_desummarize_range('brinidx_bloom', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT brin_desummarize_range('brinidx_bloom', 100000000) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 025 +-- Test brin_summarize_range +CREATE TABLE brin_summarize_bloom ( + value int +) WITH (fillfactor=10, autovacuum_enabled=false) +-- +TABLE: name="brin_summarize_bloom" schema="" table="brin_summarize_bloom" ctx=DDL +STMT: CreateStmt +== 026 +CREATE INDEX brin_summarize_bloom_idx ON brin_summarize_bloom USING brin (value) WITH (pages_per_range=2) +-- +TABLE: name="brin_summarize_bloom" schema="" table="brin_summarize_bloom" ctx=DDL +STMT: IndexStmt +== 027 +-- Fill a few pages +DO $$ +DECLARE curtid tid; +BEGIN + LOOP + INSERT INTO brin_summarize_bloom VALUES (1) RETURNING ctid INTO curtid; + EXIT WHEN curtid > tid '(2, 0)'; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 028 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_bloom_idx', 0) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 029 +-- nothing: already summarized +SELECT brin_summarize_range('brin_summarize_bloom_idx', 1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 030 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_bloom_idx', 2) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- nothing: page doesn't exist in table +SELECT brin_summarize_range('brin_summarize_bloom_idx', 4294967295) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 032 +-- invalid block number values +SELECT brin_summarize_range('brin_summarize_bloom_idx', -1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT brin_summarize_range('brin_summarize_bloom_idx', 4294967296) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 034 +-- test brin cost estimates behave sanely based on correlation of values +CREATE TABLE brin_test_bloom (a INT, b INT) +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DDL +STMT: CreateStmt +== 035 +INSERT INTO brin_test_bloom SELECT x/100,x%100 FROM generate_series(1,10000) x(x) +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 036 +CREATE INDEX brin_test_bloom_a_idx ON brin_test_bloom USING brin (a) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DDL +STMT: IndexStmt +== 037 +CREATE INDEX brin_test_bloom_b_idx ON brin_test_bloom USING brin (b) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DDL +STMT: IndexStmt +== 038 +VACUUM ANALYZE brin_test_bloom +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DDL +STMT: VacuumStmt +== 039 +-- Ensure brin index is used when columns are perfectly correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test_bloom WHERE a = 1 +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 040 +-- Ensure brin index is not used when values are not correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test_bloom WHERE b = 1 +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/brin_multi.metadata.json b/parser/testdata/summary/postgres_regress/brin_multi.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/brin_multi.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/brin_multi.test b/parser/testdata/summary/postgres_regress/brin_multi.test new file mode 100644 index 0000000..eeb0457 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/brin_multi.test @@ -0,0 +1,1466 @@ +== 001 +CREATE TABLE brintest_multi ( + int8col bigint, + int2col smallint, + int4col integer, + oidcol oid, + tidcol tid, + float4col real, + float8col double precision, + macaddrcol macaddr, + macaddr8col macaddr8, + inetcol inet, + cidrcol cidr, + datecol date, + timecol time without time zone, + timestampcol timestamp without time zone, + timestamptzcol timestamp with time zone, + intervalcol interval, + timetzcol time with time zone, + numericcol numeric, + uuidcol uuid, + lsncol pg_lsn +) WITH (fillfactor=10) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO brintest_multi SELECT + 142857 * tenthous, + thousand, + twothousand, + unique1::oid, + format('(%s,%s)', tenthous, twenty)::tid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + substr(fipshash(unique1::text), 1, 16)::macaddr8, + inet '10.2.3.4/24' + tenthous, + cidr '10.2.3/24' + tenthous, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20+02' + hundred * interval '15 seconds', + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + format('%s/%s%s', odd, even, tenthous)::pg_lsn +FROM tenk1 ORDER BY unique2 LIMIT 100 +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +-- throw in some NULL's and different values +INSERT INTO brintest_multi (inetcol, cidrcol) SELECT + inet 'fe80::6e40:8ff:fea9:8c46' + tenthous, + cidr 'fe80::6e40:8ff:fea9:8c46' + tenthous +FROM tenk1 ORDER BY thousand, tenthous LIMIT 25 +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 004 +-- test minmax-multi specific index options +-- number of values must be >= 16 +CREATE INDEX brinidx_multi ON brintest_multi USING brin ( + int8col int8_minmax_multi_ops(values_per_range = 7) +) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: IndexStmt +== 005 +-- number of values must be <= 256 +CREATE INDEX brinidx_multi ON brintest_multi USING brin ( + int8col int8_minmax_multi_ops(values_per_range = 257) +) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: IndexStmt +== 006 +-- first create an index with a single page range, to force compaction +-- due to exceeding the number of values per summary +CREATE INDEX brinidx_multi ON brintest_multi USING brin ( + int8col int8_minmax_multi_ops, + int2col int2_minmax_multi_ops, + int4col int4_minmax_multi_ops, + oidcol oid_minmax_multi_ops, + tidcol tid_minmax_multi_ops, + float4col float4_minmax_multi_ops, + float8col float8_minmax_multi_ops, + macaddrcol macaddr_minmax_multi_ops, + macaddr8col macaddr8_minmax_multi_ops, + inetcol inet_minmax_multi_ops, + cidrcol inet_minmax_multi_ops, + datecol date_minmax_multi_ops, + timecol time_minmax_multi_ops, + timestampcol timestamp_minmax_multi_ops, + timestamptzcol timestamptz_minmax_multi_ops, + intervalcol interval_minmax_multi_ops, + timetzcol timetz_minmax_multi_ops, + numericcol numeric_minmax_multi_ops, + uuidcol uuid_minmax_multi_ops, + lsncol pg_lsn_minmax_multi_ops +) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: IndexStmt +== 007 +DROP INDEX brinidx_multi +-- +STMT: DropStmt +== 008 +CREATE INDEX brinidx_multi ON brintest_multi USING brin ( + int8col int8_minmax_multi_ops, + int2col int2_minmax_multi_ops, + int4col int4_minmax_multi_ops, + oidcol oid_minmax_multi_ops, + tidcol tid_minmax_multi_ops, + float4col float4_minmax_multi_ops, + float8col float8_minmax_multi_ops, + macaddrcol macaddr_minmax_multi_ops, + macaddr8col macaddr8_minmax_multi_ops, + inetcol inet_minmax_multi_ops, + cidrcol inet_minmax_multi_ops, + datecol date_minmax_multi_ops, + timecol time_minmax_multi_ops, + timestampcol timestamp_minmax_multi_ops, + timestamptzcol timestamptz_minmax_multi_ops, + intervalcol interval_minmax_multi_ops, + timetzcol timetz_minmax_multi_ops, + numericcol numeric_minmax_multi_ops, + uuidcol uuid_minmax_multi_ops, + lsncol pg_lsn_minmax_multi_ops +) with (pages_per_range = 1) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: IndexStmt +== 009 +CREATE TABLE brinopers_multi (colname name, typ text, + op text[], value text[], matches int[], + check (cardinality(op) = cardinality(value)), + check (cardinality(op) = cardinality(matches))) +-- +TABLE: name="brinopers_multi" schema="" table="brinopers_multi" ctx=DDL +STMT: CreateStmt +== 010 +INSERT INTO brinopers_multi VALUES + ('int2col', 'int2', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 999}', + '{100, 100, 1, 100, 100}'), + ('int2col', 'int4', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int2col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int2', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int4', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('int8col', 'int2', + '{>, >=}', + '{0, 0}', + '{100, 100}'), + ('int8col', 'int4', + '{>, >=}', + '{0, 0}', + '{100, 100}'), + ('int8col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 1257141600, 1428427143, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('oidcol', 'oid', + '{>, >=, =, <=, <}', + '{0, 0, 8800, 9999, 9999}', + '{100, 100, 1, 100, 100}'), + ('tidcol', 'tid', + '{>, >=, =, <=, <}', + '{"(0,0)", "(0,0)", "(8800,0)", "(9999,19)", "(9999,19)"}', + '{100, 100, 1, 100, 100}'), + ('float4col', 'float4', + '{>, >=, =, <=, <}', + '{0.0103093, 0.0103093, 1, 1, 1}', + '{100, 100, 4, 100, 96}'), + ('float4col', 'float8', + '{>, >=, =, <=, <}', + '{0.0103093, 0.0103093, 1, 1, 1}', + '{100, 100, 4, 100, 96}'), + ('float8col', 'float4', + '{>, >=, =, <=, <}', + '{0, 0, 0, 1.98, 1.98}', + '{99, 100, 1, 100, 100}'), + ('float8col', 'float8', + '{>, >=, =, <=, <}', + '{0, 0, 0, 1.98, 1.98}', + '{99, 100, 1, 100, 100}'), + ('macaddrcol', 'macaddr', + '{>, >=, =, <=, <}', + '{00:00:01:00:00:00, 00:00:01:00:00:00, 2c:00:2d:00:16:00, ff:fe:00:00:00:00, ff:fe:00:00:00:00}', + '{99, 100, 2, 100, 100}'), + ('macaddr8col', 'macaddr8', + '{>, >=, =, <=, <}', + '{b1:d1:0e:7b:af:a4:42:12, d9:35:91:bd:f7:86:0e:1e, 72:8f:20:6c:2a:01:bf:57, 23:e8:46:63:86:07:ad:cb, 13:16:8e:6a:2e:6c:84:b4}', + '{31, 17, 1, 11, 4}'), + ('inetcol', 'inet', + '{=, <, <=, >, >=}', + '{10.2.14.231/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}', + '{1, 100, 100, 125, 125}'), + ('inetcol', 'cidr', + '{<, <=, >, >=}', + '{255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}', + '{100, 100, 125, 125}'), + ('cidrcol', 'inet', + '{=, <, <=, >, >=}', + '{10.2.14/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}', + '{2, 100, 100, 125, 125}'), + ('cidrcol', 'cidr', + '{=, <, <=, >, >=}', + '{10.2.14/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}', + '{2, 100, 100, 125, 125}'), + ('datecol', 'date', + '{>, >=, =, <=, <}', + '{1995-08-15, 1995-08-15, 2009-12-01, 2022-12-30, 2022-12-30}', + '{100, 100, 1, 100, 100}'), + ('timecol', 'time', + '{>, >=, =, <=, <}', + '{01:20:30, 01:20:30, 02:28:57, 06:28:31.5, 06:28:31.5}', + '{100, 100, 1, 100, 100}'), + ('timestampcol', 'timestamp', + '{>, >=, =, <=, <}', + '{1942-07-23 03:05:09, 1942-07-23 03:05:09, 1964-03-24 19:26:45, 1984-01-20 22:42:21, 1984-01-20 22:42:21}', + '{100, 100, 1, 100, 100}'), + ('timestampcol', 'timestamptz', + '{>, >=, =, <=, <}', + '{1942-07-23 03:05:09, 1942-07-23 03:05:09, 1964-03-24 19:26:45, 1984-01-20 22:42:21, 1984-01-20 22:42:21}', + '{100, 100, 1, 100, 100}'), + ('timestamptzcol', 'timestamptz', + '{>, >=, =, <=, <}', + '{1972-10-10 03:00:00-04, 1972-10-10 03:00:00-04, 1972-10-19 09:00:00-07, 1972-11-20 19:00:00-03, 1972-11-20 19:00:00-03}', + '{100, 100, 1, 100, 100}'), + ('intervalcol', 'interval', + '{>, >=, =, <=, <}', + '{00:00:00, 00:00:00, 1 mons 13 days 12:24, 2 mons 23 days 07:48:00, 1 year}', + '{100, 100, 1, 100, 100}'), + ('timetzcol', 'timetz', + '{>, >=, =, <=, <}', + '{01:30:20+02, 01:30:20+02, 01:35:50+02, 23:55:05+02, 23:55:05+02}', + '{99, 100, 2, 100, 100}'), + ('numericcol', 'numeric', + '{>, >=, =, <=, <}', + '{0.00, 0.01, 2268164.347826086956521739130434782609, 99470151.9, 99470151.9}', + '{100, 100, 1, 100, 100}'), + ('uuidcol', 'uuid', + '{>, >=, =, <=, <}', + '{00040004-0004-0004-0004-000400040004, 00040004-0004-0004-0004-000400040004, 52225222-5222-5222-5222-522252225222, 99989998-9998-9998-9998-999899989998, 99989998-9998-9998-9998-999899989998}', + '{100, 100, 1, 100, 100}'), + ('lsncol', 'pg_lsn', + '{>, >=, =, <=, <, IS, IS NOT}', + '{0/1200, 0/1200, 44/455222, 198/1999799, 198/1999799, NULL, NULL}', + '{100, 100, 1, 100, 100, 25, 100}') +-- +TABLE: name="brinopers_multi" schema="" table="brinopers_multi" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +DO $x$ +DECLARE + r record; + r2 record; + cond text; + idx_ctids tid[]; + ss_ctids tid[]; + count int; + plan_ok bool; + plan_line text; +BEGIN + FOR r IN SELECT colname, oper, typ, value[ordinality], matches[ordinality] FROM brinopers_multi, unnest(op) WITH ORDINALITY AS oper LOOP + + -- prepare the condition + IF r.value IS NULL THEN + cond := format('%I %s %L', r.colname, r.oper, r.value); + ELSE + cond := format('%I %s %L::%s', r.colname, r.oper, r.value, r.typ); + END IF; + + -- run the query using the brin index + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest_multi WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Bitmap Heap Scan on brintest_multi%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get bitmap indexscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest_multi WHERE %s $y$, cond) + INTO idx_ctids; + + -- run the query using a seqscan + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest_multi WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Seq Scan on brintest_multi%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get seqscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest_multi WHERE %s $y$, cond) + INTO ss_ctids; + + -- make sure both return the same results + count := array_length(idx_ctids, 1); + + IF NOT (count = array_length(ss_ctids, 1) AND + idx_ctids @> ss_ctids AND + idx_ctids <@ ss_ctids) THEN + -- report the results of each scan to make the differences obvious + RAISE WARNING 'something not right in %: count %', r, count; + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest_multi WHERE ' || cond LOOP + RAISE NOTICE 'seqscan: %', r2; + END LOOP; + + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest_multi WHERE ' || cond LOOP + RAISE NOTICE 'bitmapscan: %', r2; + END LOOP; + END IF; + + -- make sure we found expected number of matches + IF count != r.matches THEN RAISE WARNING 'unexpected number of results % for %', count, r; END IF; + END LOOP; +END; +$x$ +-- +STMT: DoStmt +== 012 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 013 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 014 +INSERT INTO brintest_multi SELECT + 142857 * tenthous, + thousand, + twothousand, + unique1::oid, + format('(%s,%s)', tenthous, twenty)::tid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + substr(fipshash(unique1::text), 1, 16)::macaddr8, + inet '10.2.3.4' + tenthous, + cidr '10.2.3/24' + tenthous, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20' + hundred * interval '15 seconds', + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + format('%s/%s%s', odd, even, tenthous)::pg_lsn +FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5 +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 015 +SELECT brin_desummarize_range('brinidx_multi', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 016 +VACUUM brintest_multi +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: VacuumStmt +== 017 +-- force a summarization cycle in brinidx + +-- Try inserting a values with NaN, to test distance calculation. +insert into public.brintest_multi (float4col) values (real 'nan') +-- +TABLE: name="public.brintest_multi" schema="public" table="brintest_multi" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +insert into public.brintest_multi (float8col) values (real 'nan') +-- +TABLE: name="public.brintest_multi" schema="public" table="brintest_multi" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +UPDATE brintest_multi SET int8col = int8col * int4col +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DML +STMT: UpdateStmt +== 020 +-- Test handling of inet netmasks with inet_minmax_multi_ops +CREATE TABLE brin_test_inet (a inet) +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DDL +STMT: CreateStmt +== 021 +CREATE INDEX ON brin_test_inet USING brin (a inet_minmax_multi_ops) +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DDL +STMT: IndexStmt +== 022 +INSERT INTO brin_test_inet VALUES ('127.0.0.1/0') +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO brin_test_inet VALUES ('0.0.0.0/12') +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +DROP TABLE brin_test_inet +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DDL +STMT: DropStmt +== 025 +-- Tests for brin_summarize_new_values +SELECT brin_summarize_new_values('brintest_multi') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 026 +-- error, not an index +SELECT brin_summarize_new_values('tenk1_unique1') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 027 +-- error, not a BRIN index +SELECT brin_summarize_new_values('brinidx_multi') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +== 028 +-- ok, no change expected + +-- Tests for brin_desummarize_range +SELECT brin_desummarize_range('brinidx_multi', -1) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 029 +-- error, invalid range +SELECT brin_desummarize_range('brinidx_multi', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT brin_desummarize_range('brinidx_multi', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT brin_desummarize_range('brinidx_multi', 100000000) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +== 032 +-- test building an index with many values, to force compaction of the buffer +CREATE TABLE brin_large_range (a int4) +-- +TABLE: name="brin_large_range" schema="" table="brin_large_range" ctx=DDL +STMT: CreateStmt +== 033 +INSERT INTO brin_large_range SELECT i FROM generate_series(1,10000) s(i) +-- +TABLE: name="brin_large_range" schema="" table="brin_large_range" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 034 +CREATE INDEX brin_large_range_idx ON brin_large_range USING brin (a int4_minmax_multi_ops) +-- +TABLE: name="brin_large_range" schema="" table="brin_large_range" ctx=DDL +STMT: IndexStmt +== 035 +DROP TABLE brin_large_range +-- +TABLE: name="brin_large_range" schema="" table="brin_large_range" ctx=DDL +STMT: DropStmt +== 036 +-- Test brin_summarize_range +CREATE TABLE brin_summarize_multi ( + value int +) WITH (fillfactor=10, autovacuum_enabled=false) +-- +TABLE: name="brin_summarize_multi" schema="" table="brin_summarize_multi" ctx=DDL +STMT: CreateStmt +== 037 +CREATE INDEX brin_summarize_multi_idx ON brin_summarize_multi USING brin (value) WITH (pages_per_range=2) +-- +TABLE: name="brin_summarize_multi" schema="" table="brin_summarize_multi" ctx=DDL +STMT: IndexStmt +== 038 +-- Fill a few pages +DO $$ +DECLARE curtid tid; +BEGIN + LOOP + INSERT INTO brin_summarize_multi VALUES (1) RETURNING ctid INTO curtid; + EXIT WHEN curtid > tid '(2, 0)'; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 039 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_multi_idx', 0) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 040 +-- nothing: already summarized +SELECT brin_summarize_range('brin_summarize_multi_idx', 1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_multi_idx', 2) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 042 +-- nothing: page doesn't exist in table +SELECT brin_summarize_range('brin_summarize_multi_idx', 4294967295) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 043 +-- invalid block number values +SELECT brin_summarize_range('brin_summarize_multi_idx', -1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT brin_summarize_range('brin_summarize_multi_idx', 4294967296) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- test brin cost estimates behave sanely based on correlation of values +CREATE TABLE brin_test_multi (a INT, b INT) +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DDL +STMT: CreateStmt +== 046 +INSERT INTO brin_test_multi SELECT x/100,x%100 FROM generate_series(1,10000) x(x) +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 047 +CREATE INDEX brin_test_multi_a_idx ON brin_test_multi USING brin (a) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DDL +STMT: IndexStmt +== 048 +CREATE INDEX brin_test_multi_b_idx ON brin_test_multi USING brin (b) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DDL +STMT: IndexStmt +== 049 +VACUUM ANALYZE brin_test_multi +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DDL +STMT: VacuumStmt +== 050 +-- Ensure brin index is used when columns are perfectly correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test_multi WHERE a = 1 +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 051 +-- Ensure brin index is not used when values are not correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test_multi WHERE b = 1 +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 052 +-- do some inequality tests +CREATE TABLE brin_test_multi_1 (a INT, b BIGINT) WITH (fillfactor=10) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: CreateStmt +== 053 +INSERT INTO brin_test_multi_1 +SELECT i/5 + mod(911 * i + 483, 25), + i/10 + mod(751 * i + 221, 41) + FROM generate_series(1,1000) s(i) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 054 +CREATE INDEX brin_test_multi_1_idx_1 ON brin_test_multi_1 USING brin (a int4_minmax_multi_ops) WITH (pages_per_range=5) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: IndexStmt +== 055 +CREATE INDEX brin_test_multi_1_idx_2 ON brin_test_multi_1 USING brin (b int8_minmax_multi_ops) WITH (pages_per_range=5) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: IndexStmt +== 056 +SET enable_seqscan=off +-- +STMT: VariableSetStmt +== 057 +-- int: less than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a < 37 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 058 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a < 113 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 059 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a <= 177 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 060 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a <= 25 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 061 +-- int: greater than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a > 120 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 062 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a >= 180 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 063 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a > 71 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 064 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a >= 63 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 065 +-- int: equals +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a = 207 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 066 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a = 177 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 067 +-- bigint: less than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b < 73 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 068 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b <= 47 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 069 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b < 199 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 070 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b <= 150 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 071 +-- bigint: greater than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 93 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 072 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 37 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 073 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b >= 215 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 074 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 201 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 075 +-- bigint: equals +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b = 88 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 076 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b = 103 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 077 +-- now do the same, but insert the rows with the indexes already created +-- so that we don't use the "build callback" and instead use the regular +-- approach of adding rows into existing ranges +TRUNCATE brin_test_multi_1 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: TruncateStmt +== 078 +INSERT INTO brin_test_multi_1 +SELECT i/5 + mod(911 * i + 483, 25), + i/10 + mod(751 * i + 221, 41) + FROM generate_series(1,1000) s(i) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 079 +-- int: less than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a < 37 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 080 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a < 113 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 081 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a <= 177 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 082 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a <= 25 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 083 +-- int: greater than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a > 120 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 084 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a >= 180 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 085 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a > 71 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 086 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a >= 63 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 087 +-- int: equals +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a = 207 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 088 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a = 177 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 089 +-- bigint: less than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b < 73 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 090 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b <= 47 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 091 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b < 199 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 092 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b <= 150 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 093 +-- bigint: greater than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 93 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 094 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 37 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 095 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b >= 215 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 096 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 201 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 097 +-- bigint: equals +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b = 88 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 098 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b = 103 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 099 +DROP TABLE brin_test_multi_1 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: DropStmt +== 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 101 +-- do some inequality tests for varlena data types +CREATE TABLE brin_test_multi_2 (a UUID) WITH (fillfactor=10) +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DDL +STMT: CreateStmt +== 102 +INSERT INTO brin_test_multi_2 +SELECT v::uuid FROM (SELECT row_number() OVER (ORDER BY v) c, v FROM (SELECT fipshash((i/13)::text) AS v FROM generate_series(1,1000) s(i)) foo) bar ORDER BY c + 25 * random() +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DML +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 103 +CREATE INDEX brin_test_multi_2_idx ON brin_test_multi_2 USING brin (a uuid_minmax_multi_ops) WITH (pages_per_range=5) +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DDL +STMT: IndexStmt +== 104 +SET enable_seqscan=off +-- +STMT: VariableSetStmt +== 105 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a < '3d914f93-48c9-cc0f-f8a7-9716700b9fcd' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 106 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a > '3d914f93-48c9-cc0f-f8a7-9716700b9fcd' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 107 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a <= 'f369cb89-fc62-7e66-8987-007d121ed1ea' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 108 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a >= 'aea92132-c4cb-eb26-3e6a-c2bf6c183b5d' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 109 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a = '5feceb66-ffc8-6f38-d952-786c6d696c79' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 110 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a = '86e50149-6586-6131-2a9e-0b35558d84f6' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 111 +-- now do the same, but insert the rows with the indexes already created +-- so that we don't use the "build callback" and instead use the regular +-- approach of adding rows into existing ranges + +TRUNCATE brin_test_multi_2 +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DDL +STMT: TruncateStmt +== 112 +INSERT INTO brin_test_multi_2 +SELECT v::uuid FROM (SELECT row_number() OVER (ORDER BY v) c, v FROM (SELECT fipshash((i/13)::text) AS v FROM generate_series(1,1000) s(i)) foo) bar ORDER BY c + 25 * random() +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DML +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 113 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a < '3d914f93-48c9-cc0f-f8a7-9716700b9fcd' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 114 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a > '3d914f93-48c9-cc0f-f8a7-9716700b9fcd' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 115 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a <= 'f369cb89-fc62-7e66-8987-007d121ed1ea' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 116 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a >= 'aea92132-c4cb-eb26-3e6a-c2bf6c183b5d' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 117 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a = '5feceb66-ffc8-6f38-d952-786c6d696c79' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 118 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a = '86e50149-6586-6131-2a9e-0b35558d84f6' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 119 +DROP TABLE brin_test_multi_2 +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DDL +STMT: DropStmt +== 120 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 121 +-- test overflows during CREATE INDEX with extreme timestamp values +CREATE TABLE brin_timestamp_test(a TIMESTAMPTZ) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: CreateStmt +== 122 +SET datestyle TO iso +-- +STMT: VariableSetStmt +== 123 +-- values close to timestamp minimum +INSERT INTO brin_timestamp_test +SELECT '4713-01-01 00:00:01 BC'::timestamptz + (i || ' seconds')::interval + FROM generate_series(1,30) s(i) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 124 +-- values close to timestamp maximum +INSERT INTO brin_timestamp_test +SELECT '294276-12-01 00:00:01'::timestamptz + (i || ' seconds')::interval + FROM generate_series(1,30) s(i) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 125 +CREATE INDEX ON brin_timestamp_test USING brin (a timestamptz_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: IndexStmt +== 126 +DROP TABLE brin_timestamp_test +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: DropStmt +== 127 +-- test overflows during CREATE INDEX with extreme date values +CREATE TABLE brin_date_test(a DATE) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: CreateStmt +== 128 +-- insert values close to date minimum +INSERT INTO brin_date_test SELECT '4713-01-01 BC'::date + i FROM generate_series(1, 30) s(i) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 129 +-- insert values close to date minimum +INSERT INTO brin_date_test SELECT '5874897-12-01'::date + i FROM generate_series(1, 30) s(i) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 130 +CREATE INDEX ON brin_date_test USING brin (a date_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: IndexStmt +== 131 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 132 +-- make sure the ranges were built correctly and 2023-01-01 eliminates all +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_date_test WHERE a = '2023-01-01'::date +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 133 +DROP TABLE brin_date_test +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: DropStmt +== 134 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 135 +-- test handling of infinite timestamp values +CREATE TABLE brin_timestamp_test(a TIMESTAMP) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: CreateStmt +== 136 +INSERT INTO brin_timestamp_test VALUES ('-infinity'), ('infinity') +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +INSERT INTO brin_timestamp_test +SELECT i FROM generate_series('2000-01-01'::timestamp, '2000-02-09'::timestamp, '1 day'::interval) s(i) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 138 +CREATE INDEX ON brin_timestamp_test USING brin (a timestamp_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: IndexStmt +== 139 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 140 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_timestamp_test WHERE a = '2023-01-01'::timestamp +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 141 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_timestamp_test WHERE a = '1900-01-01'::timestamp +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 142 +DROP TABLE brin_timestamp_test +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: DropStmt +== 143 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 144 +-- test handling of infinite date values +CREATE TABLE brin_date_test(a DATE) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: CreateStmt +== 145 +INSERT INTO brin_date_test VALUES ('-infinity'), ('infinity') +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +INSERT INTO brin_date_test SELECT '2000-01-01'::date + i FROM generate_series(1, 40) s(i) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 147 +CREATE INDEX ON brin_date_test USING brin (a date_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: IndexStmt +== 148 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 149 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_date_test WHERE a = '2023-01-01'::date +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 150 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_date_test WHERE a = '1900-01-01'::date +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 151 +DROP TABLE brin_date_test +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: DropStmt +== 152 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 153 +RESET datestyle +-- +STMT: VariableSetStmt +== 154 +-- test handling of overflow for interval values +CREATE TABLE brin_interval_test(a INTERVAL) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: CreateStmt +== 155 +INSERT INTO brin_interval_test SELECT (i || ' years')::interval FROM generate_series(-178000000, -177999980) s(i) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 156 +INSERT INTO brin_interval_test SELECT (i || ' years')::interval FROM generate_series( 177999980, 178000000) s(i) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 157 +CREATE INDEX ON brin_interval_test USING brin (a interval_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: IndexStmt +== 158 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 159 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_interval_test WHERE a = '-30 years'::interval +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 160 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_interval_test WHERE a = '30 years'::interval +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 161 +DROP TABLE brin_interval_test +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: DropStmt +== 162 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 163 +-- test handling of infinite interval values +CREATE TABLE brin_interval_test(a INTERVAL) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: CreateStmt +== 164 +INSERT INTO brin_interval_test VALUES ('-infinity'), ('infinity') +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 165 +INSERT INTO brin_interval_test SELECT (i || ' days')::interval FROM generate_series(100, 140) s(i) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 166 +CREATE INDEX ON brin_interval_test USING brin (a interval_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: IndexStmt +== 167 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 168 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_interval_test WHERE a = '-30 years'::interval +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 169 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_interval_test WHERE a = '30 years'::interval +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 170 +DROP TABLE brin_interval_test +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: DropStmt +== 171 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 172 +RESET datestyle +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/btree_index.metadata.json b/parser/testdata/summary/postgres_regress/btree_index.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/btree_index.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/btree_index.test b/parser/testdata/summary/postgres_regress/btree_index.test new file mode 100644 index 0000000..18d65c7 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/btree_index.test @@ -0,0 +1,695 @@ +== 001 +|-- +-- BTREE_INDEX +|-- + +-- directory paths are passed to us in environment variables + +CREATE TABLE bt_i4_heap ( + seqno int4, + random int4 +) +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE bt_name_heap ( + seqno name, + random int4 +) +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE bt_txt_heap ( + seqno text, + random int4 +) +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE bt_f8_heap ( + seqno float8, + random int4 +) +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=DDL +STMT: CreateStmt +== 005 +COPY bt_i4_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +COPY bt_name_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +COPY bt_txt_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +COPY bt_f8_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +ANALYZE bt_i4_heap +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=DDL +STMT: VacuumStmt +== 010 +ANALYZE bt_name_heap +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=DDL +STMT: VacuumStmt +== 011 +ANALYZE bt_txt_heap +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=DDL +STMT: VacuumStmt +== 012 +ANALYZE bt_f8_heap +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=DDL +STMT: VacuumStmt +== 013 +|-- +-- BTREE ascending/descending cases +|-- +-- we load int4/text from pure descending data (each key is a new +-- low key) and name/f8 from pure ascending data (each key is a new +-- high key). we had a bug where new low keys would sometimes be +-- "lost". +|-- +CREATE INDEX bt_i4_index ON bt_i4_heap USING btree (seqno int4_ops) +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=DDL +STMT: IndexStmt +== 014 +CREATE INDEX bt_name_index ON bt_name_heap USING btree (seqno name_ops) +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=DDL +STMT: IndexStmt +== 015 +CREATE INDEX bt_txt_index ON bt_txt_heap USING btree (seqno text_ops) +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=DDL +STMT: IndexStmt +== 016 +CREATE INDEX bt_f8_index ON bt_f8_heap USING btree (seqno float8_ops) +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=DDL +STMT: IndexStmt +== 017 +|-- +-- test retrieval of min/max keys for each index +|-- + +SELECT b.* + FROM bt_i4_heap b + WHERE b.seqno < 1 +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=Select +ALIAS: "b"="bt_i4_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 018 +SELECT b.* + FROM bt_i4_heap b + WHERE b.seqno >= 9999 +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=Select +ALIAS: "b"="bt_i4_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 019 +SELECT b.* + FROM bt_i4_heap b + WHERE b.seqno = 4500 +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=Select +ALIAS: "b"="bt_i4_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 020 +SELECT b.* + FROM bt_name_heap b + WHERE b.seqno < '1'::name +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=Select +ALIAS: "b"="bt_name_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 021 +SELECT b.* + FROM bt_name_heap b + WHERE b.seqno >= '9999'::name +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=Select +ALIAS: "b"="bt_name_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 022 +SELECT b.* + FROM bt_name_heap b + WHERE b.seqno = '4500'::name +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=Select +ALIAS: "b"="bt_name_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 023 +SELECT b.* + FROM bt_txt_heap b + WHERE b.seqno < '1'::text +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=Select +ALIAS: "b"="bt_txt_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 024 +SELECT b.* + FROM bt_txt_heap b + WHERE b.seqno >= '9999'::text +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=Select +ALIAS: "b"="bt_txt_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 025 +SELECT b.* + FROM bt_txt_heap b + WHERE b.seqno = '4500'::text +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=Select +ALIAS: "b"="bt_txt_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 026 +SELECT b.* + FROM bt_f8_heap b + WHERE b.seqno < '1'::float8 +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=Select +ALIAS: "b"="bt_f8_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 027 +SELECT b.* + FROM bt_f8_heap b + WHERE b.seqno >= '9999'::float8 +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=Select +ALIAS: "b"="bt_f8_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 028 +SELECT b.* + FROM bt_f8_heap b + WHERE b.seqno = '4500'::float8 +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=Select +ALIAS: "b"="bt_f8_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +== 029 +|-- +-- Add coverage for optimization of backwards scan index descents +|-- +-- Here we expect _bt_search to descend straight to a leaf page containing a +-- non-pivot tuple with the value '47', which comes last (after 11 similar +-- non-pivot tuples). Query execution should only need to visit a single +-- leaf page here. +|-- +-- Test case relies on tenk1_hundred index having a leaf page whose high key +-- is '(48, -inf)'. We use a low cardinality index to make our test case less +-- sensitive to implementation details that may change in the future. +set enable_seqscan to false +-- +STMT: VariableSetStmt +== 030 +set enable_indexscan to true +-- +STMT: VariableSetStmt +== 031 +set enable_bitmapscan to false +-- +STMT: VariableSetStmt +== 032 +explain (costs off) +select hundred, twenty from tenk1 where hundred < 48 order by hundred desc limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 033 +select hundred, twenty from tenk1 where hundred < 48 order by hundred desc limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 034 +-- This variant of the query need only return a single tuple located to the immediate +-- right of the '(48, -inf)' high key. It also only needs to scan one single +-- leaf page (the right sibling of the page scanned by the last test case): +explain (costs off) +select hundred, twenty from tenk1 where hundred <= 48 order by hundred desc limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 035 +select hundred, twenty from tenk1 where hundred <= 48 order by hundred desc limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 036 +|-- +-- Add coverage for ScalarArrayOp btree quals with pivot tuple constants +|-- +explain (costs off) +select distinct hundred from tenk1 where hundred in (47, 48, 72, 82) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 037 +select distinct hundred from tenk1 where hundred in (47, 48, 72, 82) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 038 +explain (costs off) +select distinct hundred from tenk1 where hundred in (47, 48, 72, 82) order by hundred desc +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 039 +select distinct hundred from tenk1 where hundred in (47, 48, 72, 82) order by hundred desc +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 040 +explain (costs off) +select thousand from tenk1 where thousand in (364, 366,380) and tenthous = 200000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 041 +select thousand from tenk1 where thousand in (364, 366,380) and tenthous = 200000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 042 +|-- +-- Check correct optimization of LIKE (special index operator support) +-- for both indexscan and bitmapscan cases +|-- + +set enable_seqscan to false +-- +STMT: VariableSetStmt +== 043 +set enable_indexscan to true +-- +STMT: VariableSetStmt +== 044 +set enable_bitmapscan to false +-- +STMT: VariableSetStmt +== 045 +explain (costs off) +select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +== 046 +select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +== 047 +explain (costs off) +select proname from pg_proc where proname ilike '00%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +== 048 +select proname from pg_proc where proname ilike '00%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +== 049 +explain (costs off) +select proname from pg_proc where proname ilike 'ri%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +== 050 +set enable_indexscan to false +-- +STMT: VariableSetStmt +== 051 +set enable_bitmapscan to true +-- +STMT: VariableSetStmt +== 052 +explain (costs off) +select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +== 053 +select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +== 054 +explain (costs off) +select proname from pg_proc where proname ilike '00%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +== 055 +select proname from pg_proc where proname ilike '00%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +== 056 +explain (costs off) +select proname from pg_proc where proname ilike 'ri%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +== 057 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 058 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 059 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 060 +-- Also check LIKE optimization with binary-compatible cases + +create temp table btree_bpchar (f1 text collate "C") +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=DDL +STMT: CreateStmt +== 061 +create index on btree_bpchar(f1 bpchar_ops) WITH (deduplicate_items=on) +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=DDL +STMT: IndexStmt +== 062 +insert into btree_bpchar values ('foo'), ('fool'), ('bar'), ('quux') +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +-- doesn't match index: +explain (costs off) +select * from btree_bpchar where f1 like 'foo' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 064 +select * from btree_bpchar where f1 like 'foo' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 065 +explain (costs off) +select * from btree_bpchar where f1 like 'foo%' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 066 +select * from btree_bpchar where f1 like 'foo%' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 067 +-- these do match the index: +explain (costs off) +select * from btree_bpchar where f1::bpchar like 'foo' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 068 +select * from btree_bpchar where f1::bpchar like 'foo' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 069 +explain (costs off) +select * from btree_bpchar where f1::bpchar like 'foo%' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 070 +select * from btree_bpchar where f1::bpchar like 'foo%' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 071 +-- get test coverage for "single value" deduplication strategy: +insert into btree_bpchar select 'foo' from generate_series(1,1500) +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 072 +|-- +-- Perform unique checking, with and without the use of deduplication +|-- +CREATE TABLE dedup_unique_test_table (a int) WITH (autovacuum_enabled=false) +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DDL +STMT: CreateStmt +== 073 +CREATE UNIQUE INDEX dedup_unique ON dedup_unique_test_table (a) WITH (deduplicate_items=on) +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DDL +STMT: IndexStmt +== 074 +CREATE UNIQUE INDEX plain_unique ON dedup_unique_test_table (a) WITH (deduplicate_items=off) +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DDL +STMT: IndexStmt +== 075 +-- Generate enough garbage tuples in index to ensure that even the unique index +-- with deduplication enabled has to check multiple leaf pages during unique +-- checking (at least with a BLCKSZ of 8192 or less) +DO $$ +BEGIN + FOR r IN 1..1350 LOOP + DELETE FROM dedup_unique_test_table; + INSERT INTO dedup_unique_test_table SELECT 1; + END LOOP; +END$$ +-- +STMT: DoStmt +== 076 +-- Exercise the LP_DEAD-bit-set tuple deletion code with a posting list tuple. +-- The implementation prefers deleting existing items to merging any duplicate +-- tuples into a posting list, so we need an explicit test to make sure we get +-- coverage (note that this test also assumes BLCKSZ is 8192 or less): +DROP INDEX plain_unique +-- +STMT: DropStmt +== 077 +DELETE FROM dedup_unique_test_table WHERE a = 1 +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DML +STMT: DeleteStmt +== 078 +INSERT INTO dedup_unique_test_table SELECT i FROM generate_series(0,450) i +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 079 +|-- +-- Test B-tree fast path (cache rightmost leaf page) optimization. +|-- + +-- First create a tree that's at least three levels deep (i.e. has one level +-- between the root and leaf levels). The text inserted is long. It won't be +-- TOAST compressed because we use plain storage in the table. Only a few +-- index tuples fit on each internal page, allowing us to get a tall tree with +-- few pages. (A tall tree is required to trigger caching.) +|-- +-- The text column must be the leading column in the index, since suffix +-- truncation would otherwise truncate tuples on internal pages, leaving us +-- with a short tree. +create table btree_tall_tbl(id int4, t text) +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: CreateStmt +== 080 +alter table btree_tall_tbl alter COLUMN t set storage plain +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: AlterTableStmt +== 081 +create index btree_tall_idx on btree_tall_tbl (t, id) with (fillfactor = 10) +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: IndexStmt +== 082 +insert into btree_tall_tbl select g, repeat('x', 250) +from generate_series(1, 130) g +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 083 +|-- +-- Test for multilevel page deletion +|-- +CREATE TABLE delete_test_table (a bigint, b bigint, c bigint, d bigint) +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DDL +STMT: CreateStmt +== 084 +INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1,80000) i +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 085 +ALTER TABLE delete_test_table ADD PRIMARY KEY (a,b,c,d) +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DDL +STMT: AlterTableStmt +== 086 +-- Delete most entries, and vacuum, deleting internal pages and creating "fast +-- root" +DELETE FROM delete_test_table WHERE a < 79990 +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DML +STMT: DeleteStmt +== 087 +VACUUM delete_test_table +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DDL +STMT: VacuumStmt +== 088 +|-- +-- Test B-tree insertion with a metapage update (XLOG_BTREE_INSERT_META +-- WAL record type). This happens when a "fast root" page is split. This +-- also creates coverage for nbtree FSM page recycling. +|-- +-- The vacuum above should've turned the leaf page into a fast root. We just +-- need to insert some rows to cause the fast root page to split. +INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1,1000) i +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 089 +-- Test unsupported btree opclass parameters +create index on btree_tall_tbl (id int4_ops(foo=1)) +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: IndexStmt +== 090 +-- Test case of ALTER INDEX with abuse of column names for indexes. +-- This grammar is not officially supported, but the parser allows it. +CREATE INDEX btree_tall_idx2 ON btree_tall_tbl (id) +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: IndexStmt +== 091 +ALTER INDEX btree_tall_idx2 ALTER COLUMN id SET (n_distinct=100) +-- +STMT: AlterTableStmt +== 092 +DROP INDEX btree_tall_idx2 +-- +STMT: DropStmt +== 093 +-- Partitioned index +CREATE TABLE btree_part (id int4) PARTITION BY RANGE (id) +-- +TABLE: name="btree_part" schema="" table="btree_part" ctx=DDL +STMT: CreateStmt +== 094 +CREATE INDEX btree_part_idx ON btree_part(id) +-- +TABLE: name="btree_part" schema="" table="btree_part" ctx=DDL +STMT: IndexStmt +== 095 +ALTER INDEX btree_part_idx ALTER COLUMN id SET (n_distinct=100) +-- +STMT: AlterTableStmt +== 096 +DROP TABLE btree_part +-- +TABLE: name="btree_part" schema="" table="btree_part" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/case.metadata.json b/parser/testdata/summary/postgres_regress/case.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/case.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/case.test b/parser/testdata/summary/postgres_regress/case.test new file mode 100644 index 0000000..4402a85 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/case.test @@ -0,0 +1,490 @@ +== 001 +|-- +-- CASE +-- Test the case statement +|-- + +CREATE TABLE CASE_TBL ( + i integer, + f double precision +) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE CASE2_TBL ( + i integer, + j integer +) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO CASE_TBL VALUES (1, 10.1) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO CASE_TBL VALUES (2, 20.2) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO CASE_TBL VALUES (3, -30.3) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO CASE_TBL VALUES (4, NULL) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO CASE2_TBL VALUES (1, -1) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO CASE2_TBL VALUES (2, -2) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO CASE2_TBL VALUES (3, -3) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO CASE2_TBL VALUES (2, -4) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO CASE2_TBL VALUES (1, NULL) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO CASE2_TBL VALUES (NULL, -6) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +|-- +-- Simplest examples without tables +|-- + +SELECT '3' AS "One", + CASE + WHEN 1 < 2 THEN 3 + END AS "Simple WHEN" +-- +STMT: SelectStmt +== 014 +SELECT '' AS "One", + CASE + WHEN 1 > 2 THEN 3 + END AS "Simple default" +-- +STMT: SelectStmt +== 015 +SELECT '3' AS "One", + CASE + WHEN 1 < 2 THEN 3 + ELSE 4 + END AS "Simple ELSE" +-- +STMT: SelectStmt +== 016 +SELECT '4' AS "One", + CASE + WHEN 1 > 2 THEN 3 + ELSE 4 + END AS "ELSE default" +-- +STMT: SelectStmt +== 017 +SELECT '6' AS "One", + CASE + WHEN 1 > 2 THEN 3 + WHEN 4 < 5 THEN 6 + ELSE 7 + END AS "Two WHEN with default" +-- +STMT: SelectStmt +== 018 +SELECT '7' AS "None", + CASE WHEN random() < 0 THEN 1 + END AS "NULL on no matches" +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- Constant-expression folding shouldn't evaluate unreachable subexpressions +SELECT CASE WHEN 1=0 THEN 1/0 WHEN 1=1 THEN 1 ELSE 2/0 END +-- +STMT: SelectStmt +== 020 +SELECT CASE 1 WHEN 0 THEN 1/0 WHEN 1 THEN 1 ELSE 2/0 END +-- +STMT: SelectStmt +== 021 +-- However we do not currently suppress folding of potentially +-- reachable subexpressions +SELECT CASE WHEN i > 100 THEN 1/0 ELSE 0 END FROM case_tbl +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +== 022 +-- Test for cases involving untyped literals in test expression +SELECT CASE 'a' WHEN 'a' THEN 1 ELSE 2 END +-- +STMT: SelectStmt +== 023 +|-- +-- Examples of targets involving tables +|-- + +SELECT + CASE + WHEN i >= 3 THEN i + END AS ">= 3 or Null" + FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +== 024 +SELECT + CASE WHEN i >= 3 THEN (i + i) + ELSE i + END AS "Simplest Math" + FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +== 025 +SELECT i AS "Value", + CASE WHEN (i < 0) THEN 'small' + WHEN (i = 0) THEN 'zero' + WHEN (i = 1) THEN 'one' + WHEN (i = 2) THEN 'two' + ELSE 'big' + END AS "Category" + FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +== 026 +SELECT + CASE WHEN ((i < 0) or (i < 0)) THEN 'small' + WHEN ((i = 0) or (i = 0)) THEN 'zero' + WHEN ((i = 1) or (i = 1)) THEN 'one' + WHEN ((i = 2) or (i = 2)) THEN 'two' + ELSE 'big' + END AS "Category" + FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +== 027 +|-- +-- Examples of qualifications involving tables +|-- + +|-- +-- NULLIF() and COALESCE() +-- Shorthand forms for typical CASE constructs +-- defined in the SQL standard. +|-- + +SELECT * FROM CASE_TBL WHERE COALESCE(f,i) = 4 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +FILTER: schema="" table="" column="f" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 028 +SELECT * FROM CASE_TBL WHERE NULLIF(f,i) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +FILTER: schema="" table="" column="f" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 029 +SELECT COALESCE(a.f, b.i, b.j) + FROM CASE_TBL a, CASE2_TBL b +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "a"="case_tbl" +ALIAS: "b"="case2_tbl" +STMT: SelectStmt +== 030 +SELECT * + FROM CASE_TBL a, CASE2_TBL b + WHERE COALESCE(a.f, b.i, b.j) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "a"="case_tbl" +ALIAS: "b"="case2_tbl" +FILTER: schema="" table="a" column="f" +FILTER: schema="" table="b" column="i" +FILTER: schema="" table="b" column="j" +STMT: SelectStmt +== 031 +SELECT NULLIF(a.i,b.i) AS "NULLIF(a.i,b.i)", + NULLIF(b.i, 4) AS "NULLIF(b.i,4)" + FROM CASE_TBL a, CASE2_TBL b +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "a"="case_tbl" +ALIAS: "b"="case2_tbl" +STMT: SelectStmt +== 032 +SELECT * + FROM CASE_TBL a, CASE2_TBL b + WHERE COALESCE(f,b.i) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "a"="case_tbl" +ALIAS: "b"="case2_tbl" +FILTER: schema="" table="" column="f" +FILTER: schema="" table="b" column="i" +STMT: SelectStmt +== 033 +-- Tests for constant subexpression simplification + +explain (costs off) +SELECT * FROM CASE_TBL WHERE NULLIF(1, 2) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 034 +explain (costs off) +SELECT * FROM CASE_TBL WHERE NULLIF(1, 1) IS NOT NULL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 035 +explain (costs off) +SELECT * FROM CASE_TBL WHERE NULLIF(1, null) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 036 +|-- +-- Examples of updates involving tables +|-- + +UPDATE CASE_TBL + SET i = CASE WHEN i >= 3 THEN (- i) + ELSE (2 * i) END +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: UpdateStmt +== 037 +SELECT * FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +== 038 +UPDATE CASE_TBL + SET i = CASE WHEN i >= 2 THEN (2 * i) + ELSE (3 * i) END +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: UpdateStmt +== 039 +SELECT * FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +== 040 +UPDATE CASE_TBL + SET i = CASE WHEN b.i >= 2 THEN (2 * j) + ELSE (3 * j) END + FROM CASE2_TBL b + WHERE j = -CASE_TBL.i +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "b"="case2_tbl" +STMT: UpdateStmt +== 041 +SELECT * FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +== 042 +|-- +-- Nested CASE expressions +|-- + +-- This test exercises a bug caused by aliasing econtext->caseValue_isNull +-- with the isNull argument of the inner CASE's CaseExpr evaluation. After +-- evaluating the vol(null) expression in the inner CASE's second WHEN-clause, +-- the isNull flag for the case test value incorrectly became true, causing +-- the third WHEN-clause not to match. The volatile function calls are needed +-- to prevent constant-folding in the planner, which would hide the bug. + +-- Wrap this in a single transaction so the transient '=' operator doesn't +-- cause problems in concurrent sessions +BEGIN +-- +STMT: TransactionStmt +== 043 +CREATE FUNCTION vol(text) returns text as + 'begin return $1; end' language plpgsql volatile +-- +FUNCTION: name="vol" function="vol" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 044 +SELECT CASE + (CASE vol('bar') + WHEN 'foo' THEN 'it was foo!' + WHEN vol(null) THEN 'null input' + WHEN 'bar' THEN 'it was bar!' END + ) + WHEN 'it was foo!' THEN 'foo recognized' + WHEN 'it was bar!' THEN 'bar recognized' + ELSE 'unrecognized' END +-- +FUNCTION: name="vol" function="vol" schema="" ctx=Call +FUNCTION: name="vol" function="vol" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- In this case, we can't inline the SQL function without confusing things. +CREATE DOMAIN foodomain AS text +-- +STMT: CreateDomainStmt +== 046 +CREATE FUNCTION volfoo(text) returns foodomain as + 'begin return $1::foodomain; end' language plpgsql volatile +-- +FUNCTION: name="volfoo" function="volfoo" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 047 +CREATE FUNCTION inline_eq(foodomain, foodomain) returns boolean as + 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' language sql +-- +FUNCTION: name="inline_eq" function="inline_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 048 +CREATE OPERATOR = (procedure = inline_eq, + leftarg = foodomain, rightarg = foodomain) +-- +STMT: DefineStmt +== 049 +SELECT CASE volfoo('bar') WHEN 'foo'::foodomain THEN 'is foo' ELSE 'is not foo' END +-- +FUNCTION: name="volfoo" function="volfoo" schema="" ctx=Call +STMT: SelectStmt +== 050 +ROLLBACK +-- +STMT: TransactionStmt +== 051 +-- Test multiple evaluation of a CASE arg that is a read/write object (#14472) +-- Wrap this in a single transaction so the transient '=' operator doesn't +-- cause problems in concurrent sessions +BEGIN +-- +STMT: TransactionStmt +== 052 +CREATE DOMAIN arrdomain AS int[] +-- +STMT: CreateDomainStmt +== 053 +CREATE FUNCTION make_ad(int,int) returns arrdomain as + 'declare x arrdomain; + begin + x := array[$1,$2]; + return x; + end' language plpgsql volatile +-- +FUNCTION: name="make_ad" function="make_ad" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 054 +CREATE FUNCTION ad_eq(arrdomain, arrdomain) returns boolean as + 'begin return array_eq($1, $2); end' language plpgsql +-- +FUNCTION: name="ad_eq" function="ad_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 055 +CREATE OPERATOR = (procedure = ad_eq, + leftarg = arrdomain, rightarg = arrdomain) +-- +STMT: DefineStmt +== 056 +SELECT CASE make_ad(1,2) + WHEN array[2,4]::arrdomain THEN 'wrong' + WHEN array[2,5]::arrdomain THEN 'still wrong' + WHEN array[1,2]::arrdomain THEN 'right' + END +-- +FUNCTION: name="make_ad" function="make_ad" schema="" ctx=Call +STMT: SelectStmt +== 057 +-- While we're here, also test handling of a NULLIF arg that is a read/write +-- object (bug #18722) + +SELECT NULLIF(make_ad(1,2), array[2,3]::arrdomain) +-- +FUNCTION: name="make_ad" function="make_ad" schema="" ctx=Call +STMT: SelectStmt +== 058 +ROLLBACK +-- +STMT: TransactionStmt +== 059 +-- Test interaction of CASE with ArrayCoerceExpr (bug #15471) +BEGIN +-- +STMT: TransactionStmt +== 060 +CREATE TYPE casetestenum AS ENUM ('e', 'f', 'g') +-- +STMT: CreateEnumStmt +== 061 +SELECT + CASE 'foo'::text + WHEN 'foo' THEN ARRAY['a', 'b', 'c', 'd'] || enum_range(NULL::casetestenum)::text[] + ELSE ARRAY['x', 'y'] + END +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 062 +ROLLBACK +-- +STMT: TransactionStmt +== 063 +|-- +-- Clean up +|-- + +DROP TABLE CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DDL +STMT: DropStmt +== 064 +DROP TABLE CASE2_TBL +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/char.metadata.json b/parser/testdata/summary/postgres_regress/char.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/char.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/char.test b/parser/testdata/summary/postgres_regress/char.test new file mode 100644 index 0000000..b743663 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/char.test @@ -0,0 +1,212 @@ +== 001 +|-- +-- CHAR +|-- + +-- Per SQL standard, CHAR means character(1), that is a varlena type +-- with a constraint restricting it to one character (not byte) + +SELECT char 'c' = char 'c' AS true +-- +STMT: SelectStmt +== 002 +|-- +-- Build a table for testing +-- (This temporarily hides the table created in test_setup.sql) +|-- + +CREATE TEMP TABLE CHAR_TBL(f1 char) +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO CHAR_TBL (f1) VALUES ('a') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO CHAR_TBL (f1) VALUES ('A') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +-- any of the following three input formats are acceptable +INSERT INTO CHAR_TBL (f1) VALUES ('1') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO CHAR_TBL (f1) VALUES (2) +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO CHAR_TBL (f1) VALUES ('3') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +-- zero-length char +INSERT INTO CHAR_TBL (f1) VALUES ('') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +-- try char's of greater than 1 length +INSERT INTO CHAR_TBL (f1) VALUES ('cd') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO CHAR_TBL (f1) VALUES ('c ') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +SELECT * FROM CHAR_TBL +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +== 012 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 <> 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 013 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 = 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 014 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 < 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 015 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 <= 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 016 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 > 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 017 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 >= 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 018 +DROP TABLE CHAR_TBL +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DDL +STMT: DropStmt +== 019 +|-- +-- Now test longer arrays of char +|-- +-- This char_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. +|-- + +INSERT INTO CHAR_TBL (f1) VALUES ('abcde') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +SELECT * FROM CHAR_TBL +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +== 021 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('abcd ', 'char(4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT pg_input_is_valid('abcde', 'char(4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT * FROM pg_input_error_info('abcde', 'char(4)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 024 +|-- +-- Also test "char", which is an ad-hoc one-byte type. It can only +-- really store ASCII characters, but we allow high-bit-set characters +-- to be accessed via bytea-like escapes. +|-- + +SELECT 'a'::"char" +-- +STMT: SelectStmt +== 025 +SELECT '\101'::"char" +-- +STMT: SelectStmt +== 026 +SELECT '\377'::"char" +-- +STMT: SelectStmt +== 027 +SELECT 'a'::"char"::text +-- +STMT: SelectStmt +== 028 +SELECT '\377'::"char"::text +-- +STMT: SelectStmt +== 029 +SELECT '\000'::"char"::text +-- +STMT: SelectStmt +== 030 +SELECT 'a'::text::"char" +-- +STMT: SelectStmt +== 031 +SELECT '\377'::text::"char" +-- +STMT: SelectStmt +== 032 +SELECT ''::text::"char" +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/circle.metadata.json b/parser/testdata/summary/postgres_regress/circle.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/circle.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/circle.test b/parser/testdata/summary/postgres_regress/circle.test new file mode 100644 index 0000000..a408bee --- /dev/null +++ b/parser/testdata/summary/postgres_regress/circle.test @@ -0,0 +1,158 @@ +== 001 +|-- +-- CIRCLE +|-- + +-- Back off displayed precision a little bit to reduce platform-to-platform +-- variation in results. +SET extra_float_digits = -1 +-- +STMT: VariableSetStmt +== 002 +CREATE TABLE CIRCLE_TBL (f1 circle) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO CIRCLE_TBL VALUES ('((1,2),100)') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO CIRCLE_TBL VALUES (' 1 , 3 , 5 ') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO CIRCLE_TBL VALUES (' ( ( 1 , 2 ) , 3 ) ') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO CIRCLE_TBL VALUES (' ( 100 , 200 ) , 10 ') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO CIRCLE_TBL VALUES (' < ( 100 , 1 ) , 115 > ') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO CIRCLE_TBL VALUES ('<(3,5),0>') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +-- Zero radius + +INSERT INTO CIRCLE_TBL VALUES ('<(3,5),NaN>') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +-- NaN radius + +-- bad values + +INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10> x') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO CIRCLE_TBL VALUES ('(3,(1,2),3)') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +SELECT * FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +STMT: SelectStmt +== 017 +SELECT center(f1) AS center + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="center" function="center" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT radius(f1) AS radius + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="radius" function="radius" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT diameter(f1) AS diameter + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="diameter" function="diameter" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT f1 FROM CIRCLE_TBL WHERE radius(f1) < 5 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="radius" function="radius" schema="" ctx=Call +FUNCTION: name="radius" function="radius" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 021 +SELECT f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="diameter" function="diameter" schema="" ctx=Call +FUNCTION: name="diameter" function="diameter" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 022 +SELECT c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance + FROM CIRCLE_TBL c1, CIRCLE_TBL c2 + WHERE (c1.f1 < c2.f1) AND ((c1.f1 <-> c2.f1) > 0) + ORDER BY distance, area(c1.f1), area(c2.f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FUNCTION: name="area" function="area" schema="" ctx=Call +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/cluster.metadata.json b/parser/testdata/summary/postgres_regress/cluster.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/cluster.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/cluster.test b/parser/testdata/summary/postgres_regress/cluster.test new file mode 100644 index 0000000..3c8d187 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/cluster.test @@ -0,0 +1,1236 @@ +== 001 +|-- +-- CLUSTER +|-- + +CREATE TABLE clstr_tst_s (rf_a SERIAL PRIMARY KEY, + b INT) +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE clstr_tst (a SERIAL PRIMARY KEY, + b INT, + c TEXT, + d TEXT, + CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: CreateStmt +== 003 +CREATE INDEX clstr_tst_b ON clstr_tst (b) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: IndexStmt +== 004 +CREATE INDEX clstr_tst_c ON clstr_tst (c) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: IndexStmt +== 005 +CREATE INDEX clstr_tst_c_b ON clstr_tst (c,b) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: IndexStmt +== 006 +CREATE INDEX clstr_tst_b_c ON clstr_tst (b,c) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: IndexStmt +== 007 +INSERT INTO clstr_tst_s (b) VALUES (0) +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 013 +CREATE TABLE clstr_tst_inh () INHERITS (clstr_tst) +-- +TABLE: name="clstr_tst_inh" schema="" table="clstr_tst_inh" ctx=DDL +STMT: CreateStmt +== 014 +INSERT INTO clstr_tst (b, c) VALUES (11, 'once') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO clstr_tst (b, c) VALUES (10, 'diez') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO clstr_tst (b, c) VALUES (3, 'tres') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO clstr_tst (b, c) VALUES (2, 'dos') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO clstr_tst (b, c) VALUES (13, 'trece') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO clstr_tst (b, c) VALUES (1, 'uno') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +INSERT INTO clstr_tst (b, c) VALUES (12, 'doce') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO clstr_tst (b, c) VALUES (15, 'quince') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO clstr_tst (b, c) VALUES (7, 'siete') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +-- This entry is needed to test that TOASTED values are copied correctly. +INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('xyzzy', 100000)) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 046 +CLUSTER clstr_tst_c ON clstr_tst +-- +STMT: ClusterStmt +== 047 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 049 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY b +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 050 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY c +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 051 +-- Verify that inheritance link still works +INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table') +-- +TABLE: name="clstr_tst_inh" schema="" table="clstr_tst_inh" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 053 +-- Verify that foreign key link still works +INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +SELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst'::regclass +ORDER BY 1 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 055 +SELECT relname, relkind, + EXISTS(SELECT 1 FROM pg_class WHERE oid = c.reltoastrelid) AS hastoast +FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="c" column="reltoastrelid" +STMT: SelectStmt +== 056 +-- Verify that indisclustered is correctly set +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pg_class_2"="pg_class" +FILTER: schema="" table="pg_class" column="oid" +FILTER: schema="" table="" column="indexrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="pg_class_2" column="oid" +FILTER: schema="" table="pg_class_2" column="relname" +FILTER: schema="" table="" column="indisclustered" +STMT: SelectStmt +== 057 +-- Try changing indisclustered +ALTER TABLE clstr_tst CLUSTER ON clstr_tst_b_c +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: AlterTableStmt +== 058 +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pg_class_2"="pg_class" +FILTER: schema="" table="pg_class" column="oid" +FILTER: schema="" table="" column="indexrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="pg_class_2" column="oid" +FILTER: schema="" table="pg_class_2" column="relname" +FILTER: schema="" table="" column="indisclustered" +STMT: SelectStmt +== 059 +-- Try turning off all clustering +ALTER TABLE clstr_tst SET WITHOUT CLUSTER +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: AlterTableStmt +== 060 +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pg_class_2"="pg_class" +FILTER: schema="" table="pg_class" column="oid" +FILTER: schema="" table="" column="indexrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="pg_class_2" column="oid" +FILTER: schema="" table="pg_class_2" column="relname" +FILTER: schema="" table="" column="indisclustered" +STMT: SelectStmt +== 061 +-- Verify that toast tables are clusterable +CLUSTER pg_toast.pg_toast_826 USING pg_toast_826_index +-- +STMT: ClusterStmt +== 062 +-- Verify that clustering all tables does in fact cluster the right ones +CREATE USER regress_clstr_user +-- +STMT: CreateRoleStmt +== 063 +CREATE TABLE clstr_1 (a INT PRIMARY KEY) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DDL +STMT: CreateStmt +== 064 +CREATE TABLE clstr_2 (a INT PRIMARY KEY) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DDL +STMT: CreateStmt +== 065 +CREATE TABLE clstr_3 (a INT PRIMARY KEY) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DDL +STMT: CreateStmt +== 066 +ALTER TABLE clstr_1 OWNER TO regress_clstr_user +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DDL +STMT: AlterTableStmt +== 067 +ALTER TABLE clstr_3 OWNER TO regress_clstr_user +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DDL +STMT: AlterTableStmt +== 068 +GRANT SELECT ON clstr_2 TO regress_clstr_user +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DDL +STMT: GrantStmt +== 069 +INSERT INTO clstr_1 VALUES (2) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +INSERT INTO clstr_1 VALUES (1) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +INSERT INTO clstr_2 VALUES (2) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +INSERT INTO clstr_2 VALUES (1) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +INSERT INTO clstr_3 VALUES (2) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 074 +INSERT INTO clstr_3 VALUES (1) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +-- "CLUSTER " on a table that hasn't been clustered +CLUSTER clstr_2 +-- +STMT: ClusterStmt +== 076 +CLUSTER clstr_1_pkey ON clstr_1 +-- +STMT: ClusterStmt +== 077 +CLUSTER clstr_2 USING clstr_2_pkey +-- +STMT: ClusterStmt +== 078 +SELECT * FROM clstr_1 UNION ALL + SELECT * FROM clstr_2 UNION ALL + SELECT * FROM clstr_3 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=Select +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=Select +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=Select +STMT: SelectStmt +== 079 +-- revert to the original state +DELETE FROM clstr_1 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: DeleteStmt +== 080 +DELETE FROM clstr_2 +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: DeleteStmt +== 081 +DELETE FROM clstr_3 +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: DeleteStmt +== 082 +INSERT INTO clstr_1 VALUES (2) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 083 +INSERT INTO clstr_1 VALUES (1) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 084 +INSERT INTO clstr_2 VALUES (2) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 085 +INSERT INTO clstr_2 VALUES (1) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 086 +INSERT INTO clstr_3 VALUES (2) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +INSERT INTO clstr_3 VALUES (1) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +-- this user can only cluster clstr_1 and clstr_3, but the latter +-- has not been clustered +SET SESSION AUTHORIZATION regress_clstr_user +-- +STMT: VariableSetStmt +== 089 +SET client_min_messages = ERROR +-- +STMT: VariableSetStmt +== 090 +-- order of "skipping" warnings may vary +CLUSTER +-- +STMT: ClusterStmt +== 091 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 092 +SELECT * FROM clstr_1 UNION ALL + SELECT * FROM clstr_2 UNION ALL + SELECT * FROM clstr_3 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=Select +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=Select +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=Select +STMT: SelectStmt +== 093 +-- cluster a single table using the indisclustered bit previously set +DELETE FROM clstr_1 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: DeleteStmt +== 094 +INSERT INTO clstr_1 VALUES (2) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +INSERT INTO clstr_1 VALUES (1) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +CLUSTER clstr_1 +-- +STMT: ClusterStmt +== 097 +SELECT * FROM clstr_1 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=Select +STMT: SelectStmt +== 098 +-- Test MVCC-safety of cluster. There isn't much we can do to verify the +-- results with a single backend... + +CREATE TABLE clustertest (key int PRIMARY KEY) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DDL +STMT: CreateStmt +== 099 +INSERT INTO clustertest VALUES (10) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 100 +INSERT INTO clustertest VALUES (20) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +INSERT INTO clustertest VALUES (30) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 102 +INSERT INTO clustertest VALUES (40) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +INSERT INTO clustertest VALUES (50) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +-- Use a transaction so that updates are not committed when CLUSTER sees 'em +BEGIN +-- +STMT: TransactionStmt +== 105 +-- Test update where the old row version is found first in the scan +UPDATE clustertest SET key = 100 WHERE key = 10 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +== 106 +-- Test update where the new row version is found first in the scan +UPDATE clustertest SET key = 35 WHERE key = 40 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +== 107 +-- Test longer update chain +UPDATE clustertest SET key = 60 WHERE key = 50 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +== 108 +UPDATE clustertest SET key = 70 WHERE key = 60 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +== 109 +UPDATE clustertest SET key = 80 WHERE key = 70 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +== 110 +SELECT * FROM clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=Select +STMT: SelectStmt +== 111 +CLUSTER clustertest_pkey ON clustertest +-- +STMT: ClusterStmt +== 112 +SELECT * FROM clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=Select +STMT: SelectStmt +== 113 +COMMIT +-- +STMT: TransactionStmt +== 114 +SELECT * FROM clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=Select +STMT: SelectStmt +== 115 +-- check that temp tables can be clustered +create temp table clstr_temp (col1 int primary key, col2 text) +-- +TABLE: name="clstr_temp" schema="" table="clstr_temp" ctx=DDL +STMT: CreateStmt +== 116 +insert into clstr_temp values (2, 'two'), (1, 'one') +-- +TABLE: name="clstr_temp" schema="" table="clstr_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +cluster clstr_temp using clstr_temp_pkey +-- +STMT: ClusterStmt +== 118 +select * from clstr_temp +-- +TABLE: name="clstr_temp" schema="" table="clstr_temp" ctx=Select +STMT: SelectStmt +== 119 +drop table clstr_temp +-- +TABLE: name="clstr_temp" schema="" table="clstr_temp" ctx=DDL +STMT: DropStmt +== 120 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 121 +-- check clustering an empty table +DROP TABLE clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DDL +STMT: DropStmt +== 122 +CREATE TABLE clustertest (f1 int PRIMARY KEY) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DDL +STMT: CreateStmt +== 123 +CLUSTER clustertest USING clustertest_pkey +-- +STMT: ClusterStmt +== 124 +CLUSTER clustertest +-- +STMT: ClusterStmt +== 125 +-- Check that partitioned tables can be clustered +CREATE TABLE clstrpart (a int) PARTITION BY RANGE (a) +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: CreateStmt +== 126 +CREATE TABLE clstrpart1 PARTITION OF clstrpart FOR VALUES FROM (1) TO (10) PARTITION BY RANGE (a) +-- +TABLE: name="clstrpart1" schema="" table="clstrpart1" ctx=DDL +STMT: CreateStmt +== 127 +CREATE TABLE clstrpart11 PARTITION OF clstrpart1 FOR VALUES FROM (1) TO (5) +-- +TABLE: name="clstrpart11" schema="" table="clstrpart11" ctx=DDL +STMT: CreateStmt +== 128 +CREATE TABLE clstrpart12 PARTITION OF clstrpart1 FOR VALUES FROM (5) TO (10) PARTITION BY RANGE (a) +-- +TABLE: name="clstrpart12" schema="" table="clstrpart12" ctx=DDL +STMT: CreateStmt +== 129 +CREATE TABLE clstrpart2 PARTITION OF clstrpart FOR VALUES FROM (10) TO (20) +-- +TABLE: name="clstrpart2" schema="" table="clstrpart2" ctx=DDL +STMT: CreateStmt +== 130 +CREATE TABLE clstrpart3 PARTITION OF clstrpart DEFAULT PARTITION BY RANGE (a) +-- +TABLE: name="clstrpart3" schema="" table="clstrpart3" ctx=DDL +STMT: CreateStmt +== 131 +CREATE TABLE clstrpart33 PARTITION OF clstrpart3 DEFAULT +-- +TABLE: name="clstrpart33" schema="" table="clstrpart33" ctx=DDL +STMT: CreateStmt +== 132 +CREATE INDEX clstrpart_only_idx ON ONLY clstrpart (a) +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: IndexStmt +== 133 +CLUSTER clstrpart USING clstrpart_only_idx +-- +STMT: ClusterStmt +== 134 +-- fails +DROP INDEX clstrpart_only_idx +-- +STMT: DropStmt +== 135 +CREATE INDEX clstrpart_idx ON clstrpart (a) +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: IndexStmt +== 136 +-- Check that clustering sets new relfilenodes: +CREATE TEMP TABLE old_cluster_info AS SELECT relname, level, relfilenode, relkind FROM pg_partition_tree('clstrpart'::regclass) AS tree JOIN pg_class c ON c.oid=tree.relid +-- +TABLE: name="old_cluster_info" schema="" table="old_cluster_info" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 137 +CLUSTER clstrpart USING clstrpart_idx +-- +STMT: ClusterStmt +== 138 +CREATE TEMP TABLE new_cluster_info AS SELECT relname, level, relfilenode, relkind FROM pg_partition_tree('clstrpart'::regclass) AS tree JOIN pg_class c ON c.oid=tree.relid +-- +TABLE: name="new_cluster_info" schema="" table="new_cluster_info" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 139 +SELECT relname, old.level, old.relkind, old.relfilenode = new.relfilenode FROM old_cluster_info AS old JOIN new_cluster_info AS new USING (relname) ORDER BY relname COLLATE "C" +-- +TABLE: name="old_cluster_info" schema="" table="old_cluster_info" ctx=Select +TABLE: name="new_cluster_info" schema="" table="new_cluster_info" ctx=Select +ALIAS: "new"="new_cluster_info" +ALIAS: "old"="old_cluster_info" +STMT: SelectStmt +== 140 +-- Partitioned indexes aren't and can't be marked un/clustered: +CLUSTER clstrpart +-- +STMT: ClusterStmt +== 141 +ALTER TABLE clstrpart SET WITHOUT CLUSTER +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: AlterTableStmt +== 142 +ALTER TABLE clstrpart CLUSTER ON clstrpart_idx +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: AlterTableStmt +== 143 +DROP TABLE clstrpart +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: DropStmt +== 144 +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique) PARTITION BY LIST (i) +-- +TABLE: name="ptnowner" schema="" table="ptnowner" ctx=DDL +STMT: CreateStmt +== 145 +CREATE INDEX ptnowner_i_idx ON ptnowner(i) +-- +TABLE: name="ptnowner" schema="" table="ptnowner" ctx=DDL +STMT: IndexStmt +== 146 +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1) +-- +TABLE: name="ptnowner1" schema="" table="ptnowner1" ctx=DDL +STMT: CreateStmt +== 147 +CREATE ROLE regress_ptnowner +-- +STMT: CreateRoleStmt +== 148 +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2) +-- +TABLE: name="ptnowner2" schema="" table="ptnowner2" ctx=DDL +STMT: CreateStmt +== 149 +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner +-- +TABLE: name="ptnowner1" schema="" table="ptnowner1" ctx=DDL +STMT: AlterTableStmt +== 150 +SET SESSION AUTHORIZATION regress_ptnowner +-- +STMT: VariableSetStmt +== 151 +CLUSTER ptnowner USING ptnowner_i_idx +-- +STMT: ClusterStmt +== 152 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 153 +ALTER TABLE ptnowner OWNER TO regress_ptnowner +-- +TABLE: name="ptnowner" schema="" table="ptnowner" ctx=DDL +STMT: AlterTableStmt +== 154 +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid +-- +TABLE: name="ptnowner_oldnodes" schema="" table="ptnowner_oldnodes" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 155 +SET SESSION AUTHORIZATION regress_ptnowner +-- +STMT: VariableSetStmt +== 156 +CLUSTER ptnowner USING ptnowner_i_idx +-- +STMT: ClusterStmt +== 157 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 158 +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C" +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="ptnowner_oldnodes" schema="" table="ptnowner_oldnodes" ctx=Select +ALIAS: "a"="pg_class" +ALIAS: "b"="ptnowner_oldnodes" +STMT: SelectStmt +== 159 +DROP TABLE ptnowner +-- +TABLE: name="ptnowner" schema="" table="ptnowner" ctx=DDL +STMT: DropStmt +== 160 +DROP ROLE regress_ptnowner +-- +STMT: DropRoleStmt +== 161 +-- Test CLUSTER with external tuplesorting + +create table clstr_4 as select * from tenk1 +-- +TABLE: name="clstr_4" schema="" table="clstr_4" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 162 +create index cluster_sort on clstr_4 (hundred, thousand, tenthous) +-- +TABLE: name="clstr_4" schema="" table="clstr_4" ctx=DDL +STMT: IndexStmt +== 163 +-- ensure we don't use the index in CLUSTER nor the checking SELECTs +set enable_indexscan = off +-- +STMT: VariableSetStmt +== 164 +-- Use external sort: +set maintenance_work_mem = '1MB' +-- +STMT: VariableSetStmt +== 165 +cluster clstr_4 using cluster_sort +-- +STMT: ClusterStmt +== 166 +select * from +(select hundred, lag(hundred) over () as lhundred, + thousand, lag(thousand) over () as lthousand, + tenthous, lag(tenthous) over () as ltenthous from clstr_4) ss +where row(hundred, thousand, tenthous) <= row(lhundred, lthousand, ltenthous) +-- +TABLE: name="clstr_4" schema="" table="clstr_4" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="lhundred" +FILTER: schema="" table="" column="lthousand" +FILTER: schema="" table="" column="ltenthous" +STMT: SelectStmt +== 167 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 168 +reset maintenance_work_mem +-- +STMT: VariableSetStmt +== 169 +-- test CLUSTER on expression index +CREATE TABLE clstr_expression(id serial primary key, a int, b text COLLATE "C") +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DDL +STMT: CreateStmt +== 170 +INSERT INTO clstr_expression(a, b) SELECT g.i % 42, 'prefix'||g.i FROM generate_series(1, 133) g(i) +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 171 +CREATE INDEX clstr_expression_minus_a ON clstr_expression ((-a), b) +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DDL +STMT: IndexStmt +== 172 +CREATE INDEX clstr_expression_upper_b ON clstr_expression ((upper(b))) +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DDL +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: IndexStmt +== 173 +-- verify indexes work before cluster +BEGIN +-- +STMT: TransactionStmt +== 174 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +== 175 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 176 +SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 177 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 178 +SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 179 +COMMIT +-- +STMT: TransactionStmt +== 180 +-- and after clustering on clstr_expression_minus_a +CLUSTER clstr_expression USING clstr_expression_minus_a +-- +STMT: ClusterStmt +== 181 +WITH rows AS + (SELECT ctid, lag(a) OVER (ORDER BY ctid) AS la, a FROM clstr_expression) +SELECT * FROM rows WHERE la < a +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +CTE: "rows" +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="la" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 182 +BEGIN +-- +STMT: TransactionStmt +== 183 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +== 184 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 185 +SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 186 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 187 +SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 188 +COMMIT +-- +STMT: TransactionStmt +== 189 +-- and after clustering on clstr_expression_upper_b +CLUSTER clstr_expression USING clstr_expression_upper_b +-- +STMT: ClusterStmt +== 190 +WITH rows AS + (SELECT ctid, lag(b) OVER (ORDER BY ctid) AS lb, b FROM clstr_expression) +SELECT * FROM rows WHERE upper(lb) > upper(b) +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +CTE: "rows" +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="lb" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 191 +BEGIN +-- +STMT: TransactionStmt +== 192 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +== 193 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 194 +SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 195 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 196 +SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 197 +COMMIT +-- +STMT: TransactionStmt +== 198 +-- clean up +DROP TABLE clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DDL +STMT: DropStmt +== 199 +DROP TABLE clstr_1 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DDL +STMT: DropStmt +== 200 +DROP TABLE clstr_2 +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DDL +STMT: DropStmt +== 201 +DROP TABLE clstr_3 +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DDL +STMT: DropStmt +== 202 +DROP TABLE clstr_4 +-- +TABLE: name="clstr_4" schema="" table="clstr_4" ctx=DDL +STMT: DropStmt +== 203 +DROP TABLE clstr_expression +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DDL +STMT: DropStmt +== 204 +DROP USER regress_clstr_user +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/collate.icu.utf8.metadata.json b/parser/testdata/summary/postgres_regress/collate.icu.utf8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.icu.utf8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/collate.icu.utf8.test b/parser/testdata/summary/postgres_regress/collate.icu.utf8.test new file mode 100644 index 0000000..0525cf2 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.icu.utf8.test @@ -0,0 +1,2980 @@ +== 001 +/* + * This test is for ICU collations. + */ + +/* skip test if not UTF8 server encoding or no ICU collations installed */ +SELECT getdatabaseencoding() <> 'UTF8' OR + (SELECT count(*) FROM pg_collation WHERE collprovider = 'i' AND collname <> 'unicode') = 0 + AS skip_test +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="collprovider" +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 002 +SET client_encoding TO UTF8 +-- +STMT: VariableSetStmt +== 003 +CREATE SCHEMA collate_tests +-- +STMT: CreateSchemaStmt +== 004 +SET search_path = collate_tests +-- +STMT: VariableSetStmt +== 005 +CREATE TABLE collate_test1 ( + a int, + b text COLLATE "en-x-icu" NOT NULL +) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: CreateStmt +== 006 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "ja_JP.eucjp-x-icu" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 007 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "foo-x-icu" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE collate_test_fail ( + a int COLLATE "en-x-icu", + b text +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 009 +CREATE TABLE collate_test_like ( + LIKE collate_test1 +) +-- +TABLE: name="collate_test_like" schema="" table="collate_test_like" ctx=DDL +STMT: CreateStmt +== 010 +CREATE TABLE collate_test2 ( + a int, + b text COLLATE "sv-x-icu" +) +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DDL +STMT: CreateStmt +== 011 +CREATE TABLE collate_test3 ( + a int, + b text COLLATE "C" +) +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DDL +STMT: CreateStmt +== 012 +INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'äbc'), (3, 'bbc'), (4, 'ABC') +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO collate_test2 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO collate_test3 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 015 +SELECT * FROM collate_test1 WHERE b >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 016 +SELECT * FROM collate_test2 WHERE b >= 'bbc' +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 017 +SELECT * FROM collate_test3 WHERE b >= 'bbc' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 018 +SELECT * FROM collate_test3 WHERE b >= 'BBC' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 019 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 020 +SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 021 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 022 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "en-x-icu" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 023 +CREATE DOMAIN testdomain_sv AS text COLLATE "sv-x-icu" +-- +STMT: CreateDomainStmt +== 024 +CREATE DOMAIN testdomain_i AS int COLLATE "sv-x-icu" +-- +STMT: CreateDomainStmt +== 025 +-- fails +CREATE TABLE collate_test4 ( + a int, + b testdomain_sv +) +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DDL +STMT: CreateStmt +== 026 +INSERT INTO collate_test4 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 027 +SELECT a, b FROM collate_test4 ORDER BY b +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=Select +STMT: SelectStmt +== 028 +CREATE TABLE collate_test5 ( + a int, + b testdomain_sv COLLATE "en-x-icu" +) +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DDL +STMT: CreateStmt +== 029 +INSERT INTO collate_test5 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 030 +SELECT a, b FROM collate_test5 ORDER BY b +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=Select +STMT: SelectStmt +== 031 +SELECT a, b FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 032 +SELECT a, b FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 033 +SELECT a, b FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 034 +SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 035 +-- star expansion +SELECT * FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 036 +SELECT * FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 037 +SELECT * FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 038 +-- constant expression folding +SELECT 'bbc' COLLATE "en-x-icu" > 'äbc' COLLATE "en-x-icu" AS "true" +-- +STMT: SelectStmt +== 039 +SELECT 'bbc' COLLATE "sv-x-icu" > 'äbc' COLLATE "sv-x-icu" AS "false" +-- +STMT: SelectStmt +== 040 +-- upper/lower + +CREATE TABLE collate_test10 ( + a int, + x text COLLATE "en-x-icu", + y text COLLATE "tr-x-icu" +) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DDL +STMT: CreateStmt +== 041 +INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ') +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT a, lower(x COLLATE "C"), lower(y COLLATE "C") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- LIKE/ILIKE + +SELECT * FROM collate_test1 WHERE b LIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 046 +SELECT * FROM collate_test1 WHERE b LIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 047 +SELECT * FROM collate_test1 WHERE b LIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 048 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 049 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 050 +SELECT * FROM collate_test1 WHERE b ILIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 051 +SELECT 'Türkiye' COLLATE "en-x-icu" ILIKE '%KI%' AS "true" +-- +STMT: SelectStmt +== 052 +SELECT 'Türkiye' COLLATE "tr-x-icu" ILIKE '%KI%' AS "false" +-- +STMT: SelectStmt +== 053 +SELECT 'bıt' ILIKE 'BIT' COLLATE "en-x-icu" AS "false" +-- +STMT: SelectStmt +== 054 +SELECT 'bıt' ILIKE 'BIT' COLLATE "tr-x-icu" AS "true" +-- +STMT: SelectStmt +== 055 +-- The following actually exercises the selectivity estimation for ILIKE. +SELECT relname FROM pg_class WHERE relname ILIKE 'abc%' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 056 +-- regular expressions + +SELECT * FROM collate_test1 WHERE b ~ '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 057 +SELECT * FROM collate_test1 WHERE b ~ '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 058 +SELECT * FROM collate_test1 WHERE b ~ 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 059 +SELECT * FROM collate_test1 WHERE b ~* '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 060 +SELECT * FROM collate_test1 WHERE b ~* '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 061 +SELECT * FROM collate_test1 WHERE b ~* 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 062 +CREATE TABLE collate_test6 ( + a int, + b text COLLATE "en-x-icu" +) +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DDL +STMT: CreateStmt +== 063 +INSERT INTO collate_test6 VALUES (1, 'abc'), (2, 'ABC'), (3, '123'), (4, 'ab1'), + (5, 'a1!'), (6, 'a c'), (7, '!.;'), (8, ' '), + (9, 'äbç'), (10, 'ÄBÇ') +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +SELECT b, + b ~ '^[[:alpha:]]+$' AS is_alpha, + b ~ '^[[:upper:]]+$' AS is_upper, + b ~ '^[[:lower:]]+$' AS is_lower, + b ~ '^[[:digit:]]+$' AS is_digit, + b ~ '^[[:alnum:]]+$' AS is_alnum, + b ~ '^[[:graph:]]+$' AS is_graph, + b ~ '^[[:print:]]+$' AS is_print, + b ~ '^[[:punct:]]+$' AS is_punct, + b ~ '^[[:space:]]+$' AS is_space +FROM collate_test6 +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=Select +STMT: SelectStmt +== 065 +SELECT 'Türkiye' COLLATE "en-x-icu" ~* 'KI' AS "true" +-- +STMT: SelectStmt +== 066 +SELECT 'Türkiye' COLLATE "tr-x-icu" ~* 'KI' AS "true" +-- +STMT: SelectStmt +== 067 +-- true with ICU + +SELECT 'bıt' ~* 'BIT' COLLATE "en-x-icu" AS "false" +-- +STMT: SelectStmt +== 068 +SELECT 'bıt' ~* 'BIT' COLLATE "tr-x-icu" AS "false" +-- +STMT: SelectStmt +== 069 +-- false with ICU + +-- The following actually exercises the selectivity estimation for ~*. +SELECT relname FROM pg_class WHERE relname ~* '^abc' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 070 +/* not run by default because it requires tr_TR system locale +-- to_char + +SET lc_time TO 'tr_TR'; +SELECT to_char(date '2010-04-01', 'DD TMMON YYYY'); +SELECT to_char(date '2010-04-01', 'DD TMMON YYYY' COLLATE "tr-x-icu"); +*/ + + +-- backwards parsing + +CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collview1" schema="" table="collview1" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 071 +CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collview2" schema="" table="collview2" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 072 +CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10 +-- +TABLE: name="collview3" schema="" table="collview3" ctx=DDL +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 073 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'collview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 074 +-- collation propagation in various expression types + +SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 075 +SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 076 +SELECT a, coalesce(b, 'foo') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 077 +SELECT a, lower(coalesce(x, 'foo')), lower(coalesce(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 079 +SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 080 +SELECT a, b, greatest(b, 'CCC') FROM collate_test3 ORDER BY 3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 081 +SELECT a, x, y, lower(greatest(x, 'foo')), lower(greatest(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 083 +SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 084 +SELECT a, nullif(b, 'abc') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 085 +SELECT a, lower(nullif(x, 'foo')), lower(nullif(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 087 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 088 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 089 +CREATE DOMAIN testdomain AS text +-- +STMT: CreateDomainStmt +== 090 +SELECT a, b::testdomain FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 091 +SELECT a, b::testdomain FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 092 +SELECT a, b::testdomain FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 093 +SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 094 +SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 095 +SELECT min(b), max(b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 096 +SELECT min(b), max(b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 097 +SELECT min(b), max(b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 098 +SELECT array_agg(b ORDER BY b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 099 +SELECT array_agg(b ORDER BY b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 100 +SELECT array_agg(b ORDER BY b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 101 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 102 +SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 103 +SELECT a, b FROM collate_test3 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test3 WHERE a > 1 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 104 +SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 105 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 106 +-- fail +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 107 +-- ok +SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 108 +-- fail +SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 109 +-- ok +SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 110 +-- fail +SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 111 +-- fail + +CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="test_u" schema="" table="test_u" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 112 +-- fail + +-- ideally this would be a parse-time error, but for now it must be run-time: +select x < y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 113 +-- fail +select x || y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 114 +-- ok, because || is not collation aware +select x, y from collate_test10 order by x || y +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 115 +-- not so ok + +-- collation mismatch between recursive and non-recursive term +WITH RECURSIVE foo(x) AS + (SELECT x FROM (VALUES('a' COLLATE "en-x-icu"),('b')) t(x) + UNION ALL + SELECT (x || 'c') COLLATE "de-x-icu" FROM foo WHERE length(x) < 10) +SELECT * FROM foo +-- +CTE: "foo" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 116 +-- casting + +SELECT CAST('42' AS text COLLATE "C") +-- +ERROR: syntax error at or near "COLLATE" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 117 +SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 118 +SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 119 +SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 120 +-- propagation of collation in SQL functions (inlined and non-inlined cases) +-- and plpgsql functions too + +CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 $$ +-- +FUNCTION: name="mylt" function="mylt" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 121 +CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 limit 1 $$ +-- +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 122 +CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql + AS $$ begin return $1 < $2; end $$ +-- +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 123 +SELECT a.b AS a, b.b AS b, a.b < b.b AS lt, + mylt(a.b, b.b), mylt_noninline(a.b, b.b), mylt_plpgsql(a.b, b.b) +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +== 124 +SELECT a.b AS a, b.b AS b, a.b < b.b COLLATE "C" AS lt, + mylt(a.b, b.b COLLATE "C"), mylt_noninline(a.b, b.b COLLATE "C"), + mylt_plpgsql(a.b, b.b COLLATE "C") +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +== 125 +-- collation override in plpgsql + +CREATE FUNCTION mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 126 +SELECT mylt2('a', 'B' collate "en-x-icu") as t, mylt2('a', 'B' collate "C") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 127 +CREATE OR REPLACE FUNCTION + mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text COLLATE "POSIX" := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 128 +SELECT mylt2('a', 'B') as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 129 +SELECT mylt2('a', 'B' collate "C") as fail +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 130 +-- conflicting collations +SELECT mylt2('a', 'B' collate "POSIX") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 131 +-- polymorphism + +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 132 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 133 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 134 +CREATE FUNCTION dup (anyelement) RETURNS anyelement + AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 135 +SELECT a, dup(b) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 136 +SELECT a, dup(b) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 137 +SELECT a, dup(b) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 138 +-- indexes + +CREATE INDEX collate_test1_idx1 ON collate_test1 (b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 139 +CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 140 +CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 141 +-- this is different grammatically +CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 142 +CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 143 +-- fail +CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 144 +-- fail + +SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 145 +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 146 +explain (costs off) +select * from collate_test1 where b ilike 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 147 +select * from collate_test1 where b ilike 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 148 +explain (costs off) +select * from collate_test1 where b ilike 'ABC' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 149 +select * from collate_test1 where b ilike 'ABC' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 150 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 151 +-- schema manipulation commands + +CREATE ROLE regress_test_role +-- +STMT: CreateRoleStmt +== 152 +CREATE SCHEMA test_schema +-- +STMT: CreateSchemaStmt +== 153 +-- We need to do this this way to cope with varying names for encodings: +SET client_min_messages TO WARNING +-- +STMT: VariableSetStmt +== 154 +SET icu_validation_level = disabled +-- +STMT: VariableSetStmt +== 155 +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' || + quote_literal((SELECT CASE WHEN datlocprovider='i' THEN datlocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +== 156 +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +== 157 +-- fail, duplicate name +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' || + quote_literal((SELECT CASE WHEN datlocprovider='i' THEN datlocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +== 158 +RESET icu_validation_level +-- +STMT: VariableSetStmt +== 159 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 160 +CREATE COLLATION test3 (provider = icu, lc_collate = 'en_US.utf8') +-- +STMT: DefineStmt +== 161 +-- fail, needs "locale" +SET icu_validation_level = ERROR +-- +STMT: VariableSetStmt +== 162 +CREATE COLLATION testx (provider = icu, locale = 'nonsense-nowhere') +-- +STMT: DefineStmt +== 163 +-- fails +CREATE COLLATION testx (provider = icu, locale = '@colStrength=primary;nonsense=yes') +-- +STMT: DefineStmt +== 164 +-- fails +RESET icu_validation_level +-- +STMT: VariableSetStmt +== 165 +CREATE COLLATION testx (provider = icu, locale = '@colStrength=primary;nonsense=yes') +-- +STMT: DefineStmt +== 166 +DROP COLLATION testx +-- +STMT: DropStmt +== 167 +CREATE COLLATION testx (provider = icu, locale = 'nonsense-nowhere') +-- +STMT: DefineStmt +== 168 +DROP COLLATION testx +-- +STMT: DropStmt +== 169 +CREATE COLLATION test4 FROM nonsense +-- +STMT: DefineStmt +== 170 +CREATE COLLATION test5 FROM test0 +-- +STMT: DefineStmt +== 171 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 172 +ALTER COLLATION test1 RENAME TO test11 +-- +STMT: RenameStmt +== 173 +ALTER COLLATION test0 RENAME TO test11 +-- +STMT: RenameStmt +== 174 +-- fail +ALTER COLLATION test1 RENAME TO test22 +-- +STMT: RenameStmt +== 175 +-- fail + +ALTER COLLATION test11 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +== 176 +ALTER COLLATION test11 OWNER TO nonsense +-- +STMT: AlterOwnerStmt +== 177 +ALTER COLLATION test11 SET SCHEMA test_schema +-- +STMT: AlterObjectSchemaStmt +== 178 +COMMENT ON COLLATION test0 IS 'US English' +-- +STMT: CommentStmt +== 179 +SELECT collname, nspname, obj_description(pg_collation.oid, 'pg_collation') + FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid) + WHERE collname LIKE 'test%' + ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 180 +DROP COLLATION test0, test_schema.test11, test5 +-- +STMT: DropStmt +== 181 +DROP COLLATION test0 +-- +STMT: DropStmt +== 182 +-- fail +DROP COLLATION IF EXISTS test0 +-- +STMT: DropStmt +== 183 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 184 +DROP SCHEMA test_schema +-- +STMT: DropStmt +== 185 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +== 186 +-- ALTER + +ALTER COLLATION "en-x-icu" REFRESH VERSION +-- +STMT: AlterCollationStmt +== 187 +-- also test for database while we are here +SELECT current_database() AS datname +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +== 188 +ALTER DATABASE :"datname" REFRESH COLLATION VERSION +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 189 +-- dependencies + +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +== 190 +CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0) +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +STMT: CreateStmt +== 191 +CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0 +-- +STMT: CreateDomainStmt +== 192 +CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0) +-- +STMT: CompositeTypeStmt +== 193 +CREATE VIEW collate_dep_test3 AS SELECT text 'foo' COLLATE test0 AS foo +-- +TABLE: name="collate_dep_test3" schema="" table="collate_dep_test3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 194 +CREATE TABLE collate_dep_test4t (a int, b text) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: CreateStmt +== 195 +CREATE INDEX collate_dep_test4i ON collate_dep_test4t (b COLLATE test0) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: IndexStmt +== 196 +DROP COLLATION test0 RESTRICT +-- +STMT: DropStmt +== 197 +-- fail +DROP COLLATION test0 CASCADE +-- +STMT: DropStmt +== 198 +DROP TABLE collate_dep_test1, collate_dep_test4t +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: DropStmt +== 199 +DROP TYPE collate_dep_test2 +-- +STMT: DropStmt +== 200 +-- test range types and collations + +create type textrange_c as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +== 201 +create type textrange_en_us as range(subtype=text, collation="en-x-icu") +-- +STMT: CreateRangeStmt +== 202 +select textrange_c('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_c" function="textrange_c" schema="" ctx=Call +STMT: SelectStmt +== 203 +select textrange_en_us('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_en_us" function="textrange_en_us" schema="" ctx=Call +STMT: SelectStmt +== 204 +drop type textrange_c +-- +STMT: DropStmt +== 205 +drop type textrange_en_us +-- +STMT: DropStmt +== 206 +-- standard collations + +SELECT * FROM collate_test2 ORDER BY b COLLATE UCS_BASIC +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 207 +SELECT * FROM collate_test2 ORDER BY b COLLATE UNICODE +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 208 +-- test ICU collation customization + +-- test the attributes handled by icu_set_collation_attributes() + +SET client_min_messages=WARNING +-- +STMT: VariableSetStmt +== 209 +CREATE COLLATION testcoll_ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes') +-- +STMT: DefineStmt +== 210 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 211 +SELECT 'aaá' > 'AAA' COLLATE "und-x-icu", 'aaá' < 'AAA' COLLATE testcoll_ignore_accents +-- +STMT: SelectStmt +== 212 +SET client_min_messages=WARNING +-- +STMT: VariableSetStmt +== 213 +CREATE COLLATION testcoll_backwards (provider = icu, locale = '@colBackwards=yes') +-- +STMT: DefineStmt +== 214 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 215 +SELECT 'coté' < 'côte' COLLATE "und-x-icu", 'coté' > 'côte' COLLATE testcoll_backwards +-- +STMT: SelectStmt +== 216 +CREATE COLLATION testcoll_lower_first (provider = icu, locale = '@colCaseFirst=lower') +-- +STMT: DefineStmt +== 217 +CREATE COLLATION testcoll_upper_first (provider = icu, locale = '@colCaseFirst=upper') +-- +STMT: DefineStmt +== 218 +SELECT 'aaa' < 'AAA' COLLATE testcoll_lower_first, 'aaa' > 'AAA' COLLATE testcoll_upper_first +-- +STMT: SelectStmt +== 219 +CREATE COLLATION testcoll_shifted (provider = icu, locale = '@colAlternate=shifted') +-- +STMT: DefineStmt +== 220 +SELECT 'de-luge' < 'deanza' COLLATE "und-x-icu", 'de-luge' > 'deanza' COLLATE testcoll_shifted +-- +STMT: SelectStmt +== 221 +SET client_min_messages=WARNING +-- +STMT: VariableSetStmt +== 222 +CREATE COLLATION testcoll_numeric (provider = icu, locale = '@colNumeric=yes') +-- +STMT: DefineStmt +== 223 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 224 +SELECT 'A-21' > 'A-123' COLLATE "und-x-icu", 'A-21' < 'A-123' COLLATE testcoll_numeric +-- +STMT: SelectStmt +== 225 +CREATE COLLATION testcoll_error1 (provider = icu, locale = '@colNumeric=lower') +-- +STMT: DefineStmt +== 226 +-- test that attributes not handled by icu_set_collation_attributes() +-- (handled by ucol_open() directly) also work +CREATE COLLATION testcoll_de_phonebook (provider = icu, locale = 'de@collation=phonebook') +-- +STMT: DefineStmt +== 227 +SELECT 'Goldmann' < 'Götz' COLLATE "de-x-icu", 'Goldmann' > 'Götz' COLLATE testcoll_de_phonebook +-- +STMT: SelectStmt +== 228 +-- rules + +CREATE COLLATION testcoll_rules1 (provider = icu, locale = '', rules = '&a < g') +-- +STMT: DefineStmt +== 229 +CREATE TABLE test7 (a text) +-- +TABLE: name="test7" schema="" table="test7" ctx=DDL +STMT: CreateStmt +== 230 +-- example from https://unicode-org.github.io/icu/userguide/collation/customization/#syntax +INSERT INTO test7 VALUES ('Abernathy'), ('apple'), ('bird'), ('Boston'), ('Graham'), ('green') +-- +TABLE: name="test7" schema="" table="test7" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 231 +SELECT * FROM test7 ORDER BY a COLLATE "en-x-icu" +-- +TABLE: name="test7" schema="" table="test7" ctx=Select +STMT: SelectStmt +== 232 +SELECT * FROM test7 ORDER BY a COLLATE testcoll_rules1 +-- +TABLE: name="test7" schema="" table="test7" ctx=Select +STMT: SelectStmt +== 233 +DROP TABLE test7 +-- +TABLE: name="test7" schema="" table="test7" ctx=DDL +STMT: DropStmt +== 234 +CREATE COLLATION testcoll_rulesx (provider = icu, locale = '', rules = '!!wrong!!') +-- +STMT: DefineStmt +== 235 +-- nondeterministic collations + +CREATE COLLATION ctest_det (provider = icu, locale = '', deterministic = true) +-- +STMT: DefineStmt +== 236 +CREATE COLLATION ctest_nondet (provider = icu, locale = '', deterministic = false) +-- +STMT: DefineStmt +== 237 +CREATE TABLE test6 (a int, b text) +-- +TABLE: name="test6" schema="" table="test6" ctx=DDL +STMT: CreateStmt +== 238 +-- same string in different normal forms +INSERT INTO test6 VALUES (1, U&'\00E4bc') +-- +TABLE: name="test6" schema="" table="test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 239 +INSERT INTO test6 VALUES (2, U&'\0061\0308bc') +-- +TABLE: name="test6" schema="" table="test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 240 +SELECT * FROM test6 +-- +TABLE: name="test6" schema="" table="test6" ctx=Select +STMT: SelectStmt +== 241 +SELECT * FROM test6 WHERE b = 'äbc' COLLATE ctest_det +-- +TABLE: name="test6" schema="" table="test6" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 242 +SELECT * FROM test6 WHERE b = 'äbc' COLLATE ctest_nondet +-- +TABLE: name="test6" schema="" table="test6" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 243 +-- same with arrays +CREATE TABLE test6a (a int, b text[]) +-- +TABLE: name="test6a" schema="" table="test6a" ctx=DDL +STMT: CreateStmt +== 244 +INSERT INTO test6a VALUES (1, ARRAY[U&'\00E4bc']) +-- +TABLE: name="test6a" schema="" table="test6a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +INSERT INTO test6a VALUES (2, ARRAY[U&'\0061\0308bc']) +-- +TABLE: name="test6a" schema="" table="test6a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 246 +SELECT * FROM test6a +-- +TABLE: name="test6a" schema="" table="test6a" ctx=Select +STMT: SelectStmt +== 247 +SELECT * FROM test6a WHERE b = ARRAY['äbc'] COLLATE ctest_det +-- +TABLE: name="test6a" schema="" table="test6a" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 248 +SELECT * FROM test6a WHERE b = ARRAY['äbc'] COLLATE ctest_nondet +-- +TABLE: name="test6a" schema="" table="test6a" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 249 +CREATE COLLATION case_sensitive (provider = icu, locale = '') +-- +STMT: DefineStmt +== 250 +CREATE COLLATION case_insensitive (provider = icu, locale = '@colStrength=secondary', deterministic = false) +-- +STMT: DefineStmt +== 251 +SELECT 'abc' <= 'ABC' COLLATE case_sensitive, 'abc' >= 'ABC' COLLATE case_sensitive +-- +STMT: SelectStmt +== 252 +SELECT 'abc' <= 'ABC' COLLATE case_insensitive, 'abc' >= 'ABC' COLLATE case_insensitive +-- +STMT: SelectStmt +== 253 +-- test language tags +CREATE COLLATION lt_insensitive (provider = icu, locale = 'en-u-ks-level1', deterministic = false) +-- +STMT: DefineStmt +== 254 +SELECT 'aBcD' COLLATE lt_insensitive = 'AbCd' COLLATE lt_insensitive +-- +STMT: SelectStmt +== 255 +CREATE COLLATION lt_upperfirst (provider = icu, locale = 'und-u-kf-upper') +-- +STMT: DefineStmt +== 256 +SELECT 'Z' COLLATE lt_upperfirst < 'z' COLLATE lt_upperfirst +-- +STMT: SelectStmt +== 257 +CREATE TABLE test1cs (x text COLLATE case_sensitive) +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=DDL +STMT: CreateStmt +== 258 +CREATE TABLE test2cs (x text COLLATE case_sensitive) +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=DDL +STMT: CreateStmt +== 259 +CREATE TABLE test3cs (x text COLLATE case_sensitive) +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=DDL +STMT: CreateStmt +== 260 +INSERT INTO test1cs VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 261 +INSERT INTO test2cs VALUES ('ABC'), ('ghi') +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 262 +INSERT INTO test3cs VALUES ('abc'), ('ABC'), ('def'), ('ghi') +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 263 +SELECT x FROM test3cs WHERE x = 'abc' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 264 +SELECT x FROM test3cs WHERE x <> 'abc' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 265 +SELECT x FROM test3cs WHERE x LIKE 'a%' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 266 +SELECT x FROM test3cs WHERE x ILIKE 'a%' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 267 +SELECT x FROM test3cs WHERE x SIMILAR TO 'a%' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 268 +SELECT x FROM test3cs WHERE x ~ 'a' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 269 +SET enable_hashagg TO off +-- +STMT: VariableSetStmt +== 270 +SELECT x FROM test1cs UNION SELECT x FROM test2cs ORDER BY x +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +STMT: SelectStmt +== 271 +SELECT x FROM test2cs UNION SELECT x FROM test1cs ORDER BY x +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +STMT: SelectStmt +== 272 +SELECT x FROM test1cs INTERSECT SELECT x FROM test2cs +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +STMT: SelectStmt +== 273 +SELECT x FROM test2cs INTERSECT SELECT x FROM test1cs +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +STMT: SelectStmt +== 274 +SELECT x FROM test1cs EXCEPT SELECT x FROM test2cs +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +STMT: SelectStmt +== 275 +SELECT x FROM test2cs EXCEPT SELECT x FROM test1cs +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +STMT: SelectStmt +== 276 +SELECT DISTINCT x FROM test3cs ORDER BY x +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +STMT: SelectStmt +== 277 +RESET enable_hashagg +-- +STMT: VariableSetStmt +== 278 +SELECT count(DISTINCT x) FROM test3cs +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 279 +SELECT x, count(*) FROM test3cs GROUP BY x ORDER BY x +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 280 +SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3cs ORDER BY x +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 281 +CREATE UNIQUE INDEX ON test1cs (x) +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=DDL +STMT: IndexStmt +== 282 +-- ok +INSERT INTO test1cs VALUES ('ABC') +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 283 +-- ok +CREATE UNIQUE INDEX ON test3cs (x) +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=DDL +STMT: IndexStmt +== 284 +-- ok +SELECT string_to_array('ABC,DEF,GHI' COLLATE case_sensitive, ',', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 285 +SELECT string_to_array('ABCDEFGHI' COLLATE case_sensitive, NULL, 'b') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 286 +CREATE TABLE test1ci (x text COLLATE case_insensitive) +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=DDL +STMT: CreateStmt +== 287 +CREATE TABLE test2ci (x text COLLATE case_insensitive) +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=DDL +STMT: CreateStmt +== 288 +CREATE TABLE test3ci (x text COLLATE case_insensitive) +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=DDL +STMT: CreateStmt +== 289 +CREATE INDEX ON test3ci (x text_pattern_ops) +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=DDL +STMT: IndexStmt +== 290 +-- error +INSERT INTO test1ci VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 291 +INSERT INTO test2ci VALUES ('ABC'), ('ghi') +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 292 +INSERT INTO test3ci VALUES ('abc'), ('ABC'), ('def'), ('ghi') +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +SELECT x FROM test3ci WHERE x = 'abc' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 294 +SELECT x FROM test3ci WHERE x <> 'abc' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 295 +SELECT x FROM test3ci WHERE x LIKE 'a%' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 296 +SELECT x FROM test3ci WHERE x ILIKE 'a%' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 297 +SELECT x FROM test3ci WHERE x SIMILAR TO 'a%' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 298 +SELECT x FROM test3ci WHERE x ~ 'a' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 299 +SELECT x FROM test1ci UNION SELECT x FROM test2ci ORDER BY x +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +STMT: SelectStmt +== 300 +SELECT x FROM test2ci UNION SELECT x FROM test1ci ORDER BY x +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +STMT: SelectStmt +== 301 +SELECT x FROM test1ci INTERSECT SELECT x FROM test2ci ORDER BY x +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +STMT: SelectStmt +== 302 +SELECT x FROM test2ci INTERSECT SELECT x FROM test1ci ORDER BY x +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +STMT: SelectStmt +== 303 +SELECT x FROM test1ci EXCEPT SELECT x FROM test2ci +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +STMT: SelectStmt +== 304 +SELECT x FROM test2ci EXCEPT SELECT x FROM test1ci +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +STMT: SelectStmt +== 305 +SELECT DISTINCT x FROM test3ci ORDER BY x +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +STMT: SelectStmt +== 306 +SELECT count(DISTINCT x) FROM test3ci +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 307 +SELECT x, count(*) FROM test3ci GROUP BY x ORDER BY x +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 308 +SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3ci ORDER BY x +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 309 +CREATE UNIQUE INDEX ON test1ci (x) +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=DDL +STMT: IndexStmt +== 310 +-- ok +INSERT INTO test1ci VALUES ('ABC') +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 311 +-- error +CREATE UNIQUE INDEX ON test3ci (x) +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=DDL +STMT: IndexStmt +== 312 +-- error +SELECT string_to_array('ABC,DEF,GHI' COLLATE case_insensitive, ',', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 313 +SELECT string_to_array('ABCDEFGHI' COLLATE case_insensitive, NULL, 'b') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 314 +-- bpchar +CREATE TABLE test1bpci (x char(3) COLLATE case_insensitive) +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=DDL +STMT: CreateStmt +== 315 +CREATE TABLE test2bpci (x char(3) COLLATE case_insensitive) +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=DDL +STMT: CreateStmt +== 316 +CREATE TABLE test3bpci (x char(3) COLLATE case_insensitive) +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=DDL +STMT: CreateStmt +== 317 +CREATE INDEX ON test3bpci (x bpchar_pattern_ops) +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=DDL +STMT: IndexStmt +== 318 +-- error +INSERT INTO test1bpci VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 319 +INSERT INTO test2bpci VALUES ('ABC'), ('ghi') +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 320 +INSERT INTO test3bpci VALUES ('abc'), ('ABC'), ('def'), ('ghi') +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 321 +SELECT x FROM test3bpci WHERE x = 'abc' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 322 +SELECT x FROM test3bpci WHERE x <> 'abc' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 323 +SELECT x FROM test3bpci WHERE x LIKE 'a%' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 324 +SELECT x FROM test3bpci WHERE x ILIKE 'a%' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 325 +SELECT x FROM test3bpci WHERE x SIMILAR TO 'a%' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 326 +SELECT x FROM test3bpci WHERE x ~ 'a' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 327 +SELECT x FROM test1bpci UNION SELECT x FROM test2bpci ORDER BY x +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +STMT: SelectStmt +== 328 +SELECT x FROM test2bpci UNION SELECT x FROM test1bpci ORDER BY x +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +STMT: SelectStmt +== 329 +SELECT x FROM test1bpci INTERSECT SELECT x FROM test2bpci ORDER BY x +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +STMT: SelectStmt +== 330 +SELECT x FROM test2bpci INTERSECT SELECT x FROM test1bpci ORDER BY x +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +STMT: SelectStmt +== 331 +SELECT x FROM test1bpci EXCEPT SELECT x FROM test2bpci +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +STMT: SelectStmt +== 332 +SELECT x FROM test2bpci EXCEPT SELECT x FROM test1bpci +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +STMT: SelectStmt +== 333 +SELECT DISTINCT x FROM test3bpci ORDER BY x +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +STMT: SelectStmt +== 334 +SELECT count(DISTINCT x) FROM test3bpci +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 335 +SELECT x, count(*) FROM test3bpci GROUP BY x ORDER BY x +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 336 +SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3bpci ORDER BY x +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 337 +CREATE UNIQUE INDEX ON test1bpci (x) +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=DDL +STMT: IndexStmt +== 338 +-- ok +INSERT INTO test1bpci VALUES ('ABC') +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 339 +-- error +CREATE UNIQUE INDEX ON test3bpci (x) +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=DDL +STMT: IndexStmt +== 340 +-- error +SELECT string_to_array('ABC,DEF,GHI'::char(11) COLLATE case_insensitive, ',', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 341 +SELECT string_to_array('ABCDEFGHI'::char(9) COLLATE case_insensitive, NULL, 'b') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +== 342 +-- This tests the issue described in match_pattern_prefix(). In the +-- absence of that check, the case_insensitive tests below would +-- return no rows where they should logically return one. +CREATE TABLE test4c (x text COLLATE "C") +-- +TABLE: name="test4c" schema="" table="test4c" ctx=DDL +STMT: CreateStmt +== 343 +INSERT INTO test4c VALUES ('abc') +-- +TABLE: name="test4c" schema="" table="test4c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 344 +CREATE INDEX ON test4c (x) +-- +TABLE: name="test4c" schema="" table="test4c" ctx=DDL +STMT: IndexStmt +== 345 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 346 +SELECT x FROM test4c WHERE x LIKE 'ABC' COLLATE case_sensitive +-- +TABLE: name="test4c" schema="" table="test4c" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 347 +-- ok, no rows +SELECT x FROM test4c WHERE x LIKE 'ABC%' COLLATE case_sensitive +-- +TABLE: name="test4c" schema="" table="test4c" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 348 +-- ok, no rows +SELECT x FROM test4c WHERE x LIKE 'ABC' COLLATE case_insensitive +-- +TABLE: name="test4c" schema="" table="test4c" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 349 +-- error +SELECT x FROM test4c WHERE x LIKE 'ABC%' COLLATE case_insensitive +-- +TABLE: name="test4c" schema="" table="test4c" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 350 +-- error +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 351 +-- Unicode special case: different variants of Greek lower case sigma. +-- A naive implementation like citext that just does lower(x) = +-- lower(y) will do the wrong thing here, because lower('Σ') is 'σ' +-- but upper('ς') is 'Σ'. +SELECT 'ὀδυσσεύς' = 'ὈΔΥΣΣΕΎΣ' COLLATE case_sensitive +-- +STMT: SelectStmt +== 352 +SELECT 'ὀδυσσεύς' = 'ὈΔΥΣΣΕΎΣ' COLLATE case_insensitive +-- +STMT: SelectStmt +== 353 +-- name vs. text comparison operators +SELECT relname FROM pg_class WHERE relname = 'PG_CLASS'::text COLLATE case_insensitive +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 354 +SELECT relname FROM pg_class WHERE 'PG_CLASS'::text = relname COLLATE case_insensitive +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 355 +SELECT typname FROM pg_type WHERE typname LIKE 'int_' AND typname <> 'INT2'::text + COLLATE case_insensitive ORDER BY typname +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 356 +SELECT typname FROM pg_type WHERE typname LIKE 'int_' AND 'INT2'::text <> typname + COLLATE case_insensitive ORDER BY typname +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 357 +-- test case adapted from subselect.sql +CREATE TEMP TABLE outer_text (f1 text COLLATE case_insensitive, f2 text) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DDL +STMT: CreateStmt +== 358 +INSERT INTO outer_text VALUES ('a', 'a') +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 359 +INSERT INTO outer_text VALUES ('b', 'a') +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 360 +INSERT INTO outer_text VALUES ('A', NULL) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 361 +INSERT INTO outer_text VALUES ('B', NULL) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 362 +CREATE TEMP TABLE inner_text (c1 text COLLATE case_insensitive, c2 text) +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DDL +STMT: CreateStmt +== 363 +INSERT INTO inner_text VALUES ('a', NULL) +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 364 +SELECT * FROM outer_text WHERE (f1, f2) NOT IN (SELECT * FROM inner_text) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 365 +-- accents +SET client_min_messages=WARNING +-- +STMT: VariableSetStmt +== 366 +CREATE COLLATION ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes', deterministic = false) +-- +STMT: DefineStmt +== 367 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 368 +CREATE TABLE test4 (a int, b text) +-- +TABLE: name="test4" schema="" table="test4" ctx=DDL +STMT: CreateStmt +== 369 +INSERT INTO test4 VALUES (1, 'cote'), (2, 'côte'), (3, 'coté'), (4, 'côté') +-- +TABLE: name="test4" schema="" table="test4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 370 +SELECT * FROM test4 WHERE b = 'cote' +-- +TABLE: name="test4" schema="" table="test4" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 371 +SELECT * FROM test4 WHERE b = 'cote' COLLATE ignore_accents +-- +TABLE: name="test4" schema="" table="test4" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 372 +SELECT * FROM test4 WHERE b = 'Cote' COLLATE ignore_accents +-- +TABLE: name="test4" schema="" table="test4" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 373 +-- still case-sensitive +SELECT * FROM test4 WHERE b = 'Cote' COLLATE case_insensitive +-- +TABLE: name="test4" schema="" table="test4" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 374 +-- foreign keys (should use collation of primary key) + +-- PK is case-sensitive, FK is case-insensitive +CREATE TABLE test10pk (x text COLLATE case_sensitive PRIMARY KEY) +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=DDL +STMT: CreateStmt +== 375 +INSERT INTO test10pk VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 376 +CREATE TABLE test10fk (x text COLLATE case_insensitive REFERENCES test10pk (x) ON UPDATE CASCADE ON DELETE CASCADE) +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DDL +STMT: CreateStmt +== 377 +INSERT INTO test10fk VALUES ('abc') +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 378 +-- ok +INSERT INTO test10fk VALUES ('ABC') +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 379 +-- error +INSERT INTO test10fk VALUES ('xyz') +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 380 +-- error +SELECT * FROM test10pk +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=Select +STMT: SelectStmt +== 381 +SELECT * FROM test10fk +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=Select +STMT: SelectStmt +== 382 +-- restrict update even though the values are "equal" in the FK table +UPDATE test10fk SET x = 'ABC' WHERE x = 'abc' +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DML +STMT: UpdateStmt +== 383 +-- error +SELECT * FROM test10fk +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=Select +STMT: SelectStmt +== 384 +DELETE FROM test10pk WHERE x = 'abc' +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=DML +STMT: DeleteStmt +== 385 +SELECT * FROM test10pk +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=Select +STMT: SelectStmt +== 386 +SELECT * FROM test10fk +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=Select +STMT: SelectStmt +== 387 +-- PK is case-insensitive, FK is case-sensitive +CREATE TABLE test11pk (x text COLLATE case_insensitive PRIMARY KEY) +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=DDL +STMT: CreateStmt +== 388 +INSERT INTO test11pk VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 389 +CREATE TABLE test11fk (x text COLLATE case_sensitive REFERENCES test11pk (x) ON UPDATE CASCADE ON DELETE CASCADE) +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=DDL +STMT: CreateStmt +== 390 +INSERT INTO test11fk VALUES ('abc') +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 391 +-- ok +INSERT INTO test11fk VALUES ('ABC') +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 392 +-- ok +INSERT INTO test11fk VALUES ('xyz') +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 393 +-- error +SELECT * FROM test11pk +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=Select +STMT: SelectStmt +== 394 +SELECT * FROM test11fk +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=Select +STMT: SelectStmt +== 395 +-- cascade update even though the values are "equal" in the PK table +UPDATE test11pk SET x = 'ABC' WHERE x = 'abc' +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=DML +STMT: UpdateStmt +== 396 +SELECT * FROM test11fk +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=Select +STMT: SelectStmt +== 397 +DELETE FROM test11pk WHERE x = 'abc' +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=DML +STMT: DeleteStmt +== 398 +SELECT * FROM test11pk +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=Select +STMT: SelectStmt +== 399 +SELECT * FROM test11fk +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=Select +STMT: SelectStmt +== 400 +-- partitioning +CREATE TABLE test20 (a int, b text COLLATE case_insensitive) PARTITION BY LIST (b) +-- +TABLE: name="test20" schema="" table="test20" ctx=DDL +STMT: CreateStmt +== 401 +CREATE TABLE test20_1 PARTITION OF test20 FOR VALUES IN ('abc') +-- +TABLE: name="test20_1" schema="" table="test20_1" ctx=DDL +STMT: CreateStmt +== 402 +INSERT INTO test20 VALUES (1, 'abc') +-- +TABLE: name="test20" schema="" table="test20" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 403 +INSERT INTO test20 VALUES (2, 'ABC') +-- +TABLE: name="test20" schema="" table="test20" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 404 +SELECT * FROM test20_1 +-- +TABLE: name="test20_1" schema="" table="test20_1" ctx=Select +STMT: SelectStmt +== 405 +CREATE TABLE test21 (a int, b text COLLATE case_insensitive) PARTITION BY RANGE (b) +-- +TABLE: name="test21" schema="" table="test21" ctx=DDL +STMT: CreateStmt +== 406 +CREATE TABLE test21_1 PARTITION OF test21 FOR VALUES FROM ('ABC') TO ('DEF') +-- +TABLE: name="test21_1" schema="" table="test21_1" ctx=DDL +STMT: CreateStmt +== 407 +INSERT INTO test21 VALUES (1, 'abc') +-- +TABLE: name="test21" schema="" table="test21" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 408 +INSERT INTO test21 VALUES (2, 'ABC') +-- +TABLE: name="test21" schema="" table="test21" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 409 +SELECT * FROM test21_1 +-- +TABLE: name="test21_1" schema="" table="test21_1" ctx=Select +STMT: SelectStmt +== 410 +CREATE TABLE test22 (a int, b text COLLATE case_sensitive) PARTITION BY HASH (b) +-- +TABLE: name="test22" schema="" table="test22" ctx=DDL +STMT: CreateStmt +== 411 +CREATE TABLE test22_0 PARTITION OF test22 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test22_0" schema="" table="test22_0" ctx=DDL +STMT: CreateStmt +== 412 +CREATE TABLE test22_1 PARTITION OF test22 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test22_1" schema="" table="test22_1" ctx=DDL +STMT: CreateStmt +== 413 +INSERT INTO test22 VALUES (1, 'def') +-- +TABLE: name="test22" schema="" table="test22" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 414 +INSERT INTO test22 VALUES (2, 'DEF') +-- +TABLE: name="test22" schema="" table="test22" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 415 +-- they end up in different partitions +SELECT (SELECT count(*) FROM test22_0) = (SELECT count(*) FROM test22_1) +-- +TABLE: name="test22_0" schema="" table="test22_0" ctx=Select +TABLE: name="test22_1" schema="" table="test22_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 416 +-- same with arrays +CREATE TABLE test22a (a int, b text[] COLLATE case_sensitive) PARTITION BY HASH (b) +-- +TABLE: name="test22a" schema="" table="test22a" ctx=DDL +STMT: CreateStmt +== 417 +CREATE TABLE test22a_0 PARTITION OF test22a FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test22a_0" schema="" table="test22a_0" ctx=DDL +STMT: CreateStmt +== 418 +CREATE TABLE test22a_1 PARTITION OF test22a FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test22a_1" schema="" table="test22a_1" ctx=DDL +STMT: CreateStmt +== 419 +INSERT INTO test22a VALUES (1, ARRAY['def']) +-- +TABLE: name="test22a" schema="" table="test22a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 420 +INSERT INTO test22a VALUES (2, ARRAY['DEF']) +-- +TABLE: name="test22a" schema="" table="test22a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 421 +-- they end up in different partitions +SELECT (SELECT count(*) FROM test22a_0) = (SELECT count(*) FROM test22a_1) +-- +TABLE: name="test22a_0" schema="" table="test22a_0" ctx=Select +TABLE: name="test22a_1" schema="" table="test22a_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 422 +CREATE TABLE test23 (a int, b text COLLATE case_insensitive) PARTITION BY HASH (b) +-- +TABLE: name="test23" schema="" table="test23" ctx=DDL +STMT: CreateStmt +== 423 +CREATE TABLE test23_0 PARTITION OF test23 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test23_0" schema="" table="test23_0" ctx=DDL +STMT: CreateStmt +== 424 +CREATE TABLE test23_1 PARTITION OF test23 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test23_1" schema="" table="test23_1" ctx=DDL +STMT: CreateStmt +== 425 +INSERT INTO test23 VALUES (1, 'def') +-- +TABLE: name="test23" schema="" table="test23" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 426 +INSERT INTO test23 VALUES (2, 'DEF') +-- +TABLE: name="test23" schema="" table="test23" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 427 +-- they end up in the same partition (but it's platform-dependent which one) +SELECT (SELECT count(*) FROM test23_0) <> (SELECT count(*) FROM test23_1) +-- +TABLE: name="test23_0" schema="" table="test23_0" ctx=Select +TABLE: name="test23_1" schema="" table="test23_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 428 +-- same with arrays +CREATE TABLE test23a (a int, b text[] COLLATE case_insensitive) PARTITION BY HASH (b) +-- +TABLE: name="test23a" schema="" table="test23a" ctx=DDL +STMT: CreateStmt +== 429 +CREATE TABLE test23a_0 PARTITION OF test23a FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test23a_0" schema="" table="test23a_0" ctx=DDL +STMT: CreateStmt +== 430 +CREATE TABLE test23a_1 PARTITION OF test23a FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test23a_1" schema="" table="test23a_1" ctx=DDL +STMT: CreateStmt +== 431 +INSERT INTO test23a VALUES (1, ARRAY['def']) +-- +TABLE: name="test23a" schema="" table="test23a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 432 +INSERT INTO test23a VALUES (2, ARRAY['DEF']) +-- +TABLE: name="test23a" schema="" table="test23a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 433 +-- they end up in the same partition (but it's platform-dependent which one) +SELECT (SELECT count(*) FROM test23a_0) <> (SELECT count(*) FROM test23a_1) +-- +TABLE: name="test23a_0" schema="" table="test23a_0" ctx=Select +TABLE: name="test23a_1" schema="" table="test23a_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 434 +CREATE TABLE test30 (a int, b char(3) COLLATE case_insensitive) PARTITION BY LIST (b) +-- +TABLE: name="test30" schema="" table="test30" ctx=DDL +STMT: CreateStmt +== 435 +CREATE TABLE test30_1 PARTITION OF test30 FOR VALUES IN ('abc') +-- +TABLE: name="test30_1" schema="" table="test30_1" ctx=DDL +STMT: CreateStmt +== 436 +INSERT INTO test30 VALUES (1, 'abc') +-- +TABLE: name="test30" schema="" table="test30" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 437 +INSERT INTO test30 VALUES (2, 'ABC') +-- +TABLE: name="test30" schema="" table="test30" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 438 +SELECT * FROM test30_1 +-- +TABLE: name="test30_1" schema="" table="test30_1" ctx=Select +STMT: SelectStmt +== 439 +CREATE TABLE test31 (a int, b char(3) COLLATE case_insensitive) PARTITION BY RANGE (b) +-- +TABLE: name="test31" schema="" table="test31" ctx=DDL +STMT: CreateStmt +== 440 +CREATE TABLE test31_1 PARTITION OF test31 FOR VALUES FROM ('ABC') TO ('DEF') +-- +TABLE: name="test31_1" schema="" table="test31_1" ctx=DDL +STMT: CreateStmt +== 441 +INSERT INTO test31 VALUES (1, 'abc') +-- +TABLE: name="test31" schema="" table="test31" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 442 +INSERT INTO test31 VALUES (2, 'ABC') +-- +TABLE: name="test31" schema="" table="test31" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 443 +SELECT * FROM test31_1 +-- +TABLE: name="test31_1" schema="" table="test31_1" ctx=Select +STMT: SelectStmt +== 444 +CREATE TABLE test32 (a int, b char(3) COLLATE case_sensitive) PARTITION BY HASH (b) +-- +TABLE: name="test32" schema="" table="test32" ctx=DDL +STMT: CreateStmt +== 445 +CREATE TABLE test32_0 PARTITION OF test32 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test32_0" schema="" table="test32_0" ctx=DDL +STMT: CreateStmt +== 446 +CREATE TABLE test32_1 PARTITION OF test32 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test32_1" schema="" table="test32_1" ctx=DDL +STMT: CreateStmt +== 447 +INSERT INTO test32 VALUES (1, 'def') +-- +TABLE: name="test32" schema="" table="test32" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 448 +INSERT INTO test32 VALUES (2, 'DEF') +-- +TABLE: name="test32" schema="" table="test32" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 449 +-- they end up in different partitions +SELECT (SELECT count(*) FROM test32_0) = (SELECT count(*) FROM test32_1) +-- +TABLE: name="test32_0" schema="" table="test32_0" ctx=Select +TABLE: name="test32_1" schema="" table="test32_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 450 +CREATE TABLE test33 (a int, b char(3) COLLATE case_insensitive) PARTITION BY HASH (b) +-- +TABLE: name="test33" schema="" table="test33" ctx=DDL +STMT: CreateStmt +== 451 +CREATE TABLE test33_0 PARTITION OF test33 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test33_0" schema="" table="test33_0" ctx=DDL +STMT: CreateStmt +== 452 +CREATE TABLE test33_1 PARTITION OF test33 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test33_1" schema="" table="test33_1" ctx=DDL +STMT: CreateStmt +== 453 +INSERT INTO test33 VALUES (1, 'def') +-- +TABLE: name="test33" schema="" table="test33" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 454 +INSERT INTO test33 VALUES (2, 'DEF') +-- +TABLE: name="test33" schema="" table="test33" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 455 +-- they end up in the same partition (but it's platform-dependent which one) +SELECT (SELECT count(*) FROM test33_0) <> (SELECT count(*) FROM test33_1) +-- +TABLE: name="test33_0" schema="" table="test33_0" ctx=Select +TABLE: name="test33_1" schema="" table="test33_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 456 +|-- +-- Bug #18568 +|-- +-- Partitionwise aggregate (full or partial) should not be used when a +-- partition key's collation doesn't match that of the GROUP BY column it is +-- matched with. +SET max_parallel_workers_per_gather TO 0 +-- +STMT: VariableSetStmt +== 457 +SET enable_incremental_sort TO off +-- +STMT: VariableSetStmt +== 458 +CREATE TABLE pagg_tab3 (a text, c text collate case_insensitive) PARTITION BY LIST(c collate "C") +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=DDL +STMT: CreateStmt +== 459 +CREATE TABLE pagg_tab3_p1 PARTITION OF pagg_tab3 FOR VALUES IN ('a', 'b') +-- +TABLE: name="pagg_tab3_p1" schema="" table="pagg_tab3_p1" ctx=DDL +STMT: CreateStmt +== 460 +CREATE TABLE pagg_tab3_p2 PARTITION OF pagg_tab3 FOR VALUES IN ('B', 'A') +-- +TABLE: name="pagg_tab3_p2" schema="" table="pagg_tab3_p2" ctx=DDL +STMT: CreateStmt +== 461 +INSERT INTO pagg_tab3 SELECT i % 4 + 1, substr('abAB', (i % 4) + 1 , 1) FROM generate_series(0, 19) i +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=DML +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 462 +ANALYZE pagg_tab3 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=DDL +STMT: VacuumStmt +== 463 +SET enable_partitionwise_aggregate TO false +-- +STMT: VariableSetStmt +== 464 +EXPLAIN (COSTS OFF) +SELECT upper(c collate case_insensitive), count(c) FROM pagg_tab3 GROUP BY c collate case_insensitive ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 465 +SELECT upper(c collate case_insensitive), count(c) FROM pagg_tab3 GROUP BY c collate case_insensitive ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 466 +-- No "full" partitionwise aggregation allowed, though "partial" is allowed. +SET enable_partitionwise_aggregate TO true +-- +STMT: VariableSetStmt +== 467 +EXPLAIN (COSTS OFF) +SELECT upper(c collate case_insensitive), count(c) FROM pagg_tab3 GROUP BY c collate case_insensitive ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 468 +SELECT upper(c collate case_insensitive), count(c) FROM pagg_tab3 GROUP BY c collate case_insensitive ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 469 +-- OK to use full partitionwise aggregate after changing the GROUP BY column's +-- collation to be the same as that of the partition key. +EXPLAIN (COSTS OFF) +SELECT c collate "C", count(c) FROM pagg_tab3 GROUP BY c collate "C" ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 470 +SELECT c collate "C", count(c) FROM pagg_tab3 GROUP BY c collate "C" ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 471 +-- Partitionwise join should not be allowed too when the collation used by the +-- join keys doesn't match the partition key collation. +SET enable_partitionwise_join TO false +-- +STMT: VariableSetStmt +== 472 +EXPLAIN (COSTS OFF) +SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 473 +SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 474 +SET enable_partitionwise_join TO true +-- +STMT: VariableSetStmt +== 475 +EXPLAIN (COSTS OFF) +SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 476 +SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 477 +-- OK when the join clause uses the same collation as the partition key. +EXPLAIN (COSTS OFF) +SELECT t1.c COLLATE "C", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE "C" GROUP BY t1.c COLLATE "C" ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 478 +SELECT t1.c COLLATE "C", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE "C" GROUP BY t1.c COLLATE "C" ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 479 +SET enable_partitionwise_join TO false +-- +STMT: VariableSetStmt +== 480 +EXPLAIN (COSTS OFF) +SELECT t1.c COLLATE "C", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE "C" GROUP BY t1.c COLLATE "C" ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 481 +SELECT t1.c COLLATE "C", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE "C" GROUP BY t1.c COLLATE "C" ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 482 +DROP TABLE pagg_tab3 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=DDL +STMT: DropStmt +== 483 +RESET enable_partitionwise_aggregate +-- +STMT: VariableSetStmt +== 484 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +== 485 +RESET enable_incremental_sort +-- +STMT: VariableSetStmt +== 486 +-- Check that DEFAULT expressions in SQL/JSON functions use the same collation +-- as the RETURNING type. Mismatched collations should raise an error. +CREATE DOMAIN d1 AS text COLLATE case_insensitive +-- +STMT: CreateDomainStmt +== 487 +CREATE DOMAIN d2 AS text COLLATE "C" +-- +STMT: CreateDomainStmt +== 488 +SELECT JSON_VALUE('{"a": "A"}', '$.a' RETURNING d1 DEFAULT ('C' COLLATE "C") COLLATE case_insensitive ON EMPTY) = 'a' +-- +STMT: SelectStmt +== 489 +-- true +SELECT JSON_VALUE('{"a": "A"}', '$.a' RETURNING d1 DEFAULT 'C' ON EMPTY) = 'a' +-- +STMT: SelectStmt +== 490 +-- true +SELECT JSON_VALUE('{"a": "A"}', '$.a' RETURNING d1 DEFAULT 'C'::d2 ON EMPTY) = 'a' +-- +STMT: SelectStmt +== 491 +-- error +SELECT JSON_VALUE('{"a": "A"}', '$.a' RETURNING d1 DEFAULT 'C' COLLATE "C" ON EMPTY) = 'a' +-- +STMT: SelectStmt +== 492 +-- error +SELECT JSON_VALUE('{"a": "A"}', '$.c' RETURNING d1 DEFAULT 'A' ON EMPTY) = 'a' +-- +STMT: SelectStmt +== 493 +-- true +SELECT JSON_VALUE('{"a": "A"}', '$.c' RETURNING d1 DEFAULT 'A' COLLATE case_insensitive ON EMPTY) = 'a' +-- +STMT: SelectStmt +== 494 +-- true +SELECT JSON_VALUE('{"a": "A"}', '$.c' RETURNING d1 DEFAULT 'A'::d2 ON EMPTY) = 'a' +-- +STMT: SelectStmt +== 495 +-- error +SELECT JSON_VALUE('{"a": "A"}', '$.c' RETURNING d1 DEFAULT 'A' COLLATE "C" ON EMPTY) = 'a' +-- +STMT: SelectStmt +== 496 +-- error +DROP DOMAIN d1, d2 +-- +STMT: DropStmt +== 497 +-- cleanup +RESET search_path +-- +STMT: VariableSetStmt +== 498 +SET client_min_messages TO warning +-- +STMT: VariableSetStmt +== 499 +DROP SCHEMA collate_tests CASCADE +-- +STMT: DropStmt +== 500 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 501 +-- leave a collation for pg_upgrade test +CREATE COLLATION coll_icu_upgrade FROM "und-x-icu" +-- +STMT: DefineStmt diff --git a/parser/testdata/summary/postgres_regress/collate.linux.utf8.metadata.json b/parser/testdata/summary/postgres_regress/collate.linux.utf8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.linux.utf8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/collate.linux.utf8.test b/parser/testdata/summary/postgres_regress/collate.linux.utf8.test new file mode 100644 index 0000000..239c3ed --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.linux.utf8.test @@ -0,0 +1,1269 @@ +== 001 +/* + * This test is for Linux/glibc systems and assumes that a full set of + * locales is installed. It must be run in a database with UTF-8 encoding, + * because other encodings don't support all the characters used. + */ + +SELECT getdatabaseencoding() <> 'UTF8' OR + (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE', 'tr_TR') AND collencoding = pg_char_to_encoding('UTF8')) <> 4 OR + version() !~ 'linux-gnu' + AS skip_test +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +FUNCTION: name="pg_char_to_encoding" function="pg_char_to_encoding" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_char_to_encoding" function="pg_char_to_encoding" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +FILTER: schema="" table="" column="collencoding" +STMT: SelectStmt +== 002 +SET client_encoding TO UTF8 +-- +STMT: VariableSetStmt +== 003 +CREATE SCHEMA collate_tests +-- +STMT: CreateSchemaStmt +== 004 +SET search_path = collate_tests +-- +STMT: VariableSetStmt +== 005 +CREATE TABLE collate_test1 ( + a int, + b text COLLATE "en_US" NOT NULL +) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: CreateStmt +== 006 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "ja_JP.eucjp" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 007 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "foo" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE collate_test_fail ( + a int COLLATE "en_US", + b text +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 009 +CREATE TABLE collate_test_like ( + LIKE collate_test1 +) +-- +TABLE: name="collate_test_like" schema="" table="collate_test_like" ctx=DDL +STMT: CreateStmt +== 010 +CREATE TABLE collate_test2 ( + a int, + b text COLLATE "sv_SE" +) +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DDL +STMT: CreateStmt +== 011 +CREATE TABLE collate_test3 ( + a int, + b text COLLATE "C" +) +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DDL +STMT: CreateStmt +== 012 +INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'äbc'), (3, 'bbc'), (4, 'ABC') +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO collate_test2 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO collate_test3 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 015 +SELECT * FROM collate_test1 WHERE b >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 016 +SELECT * FROM collate_test2 WHERE b >= 'bbc' +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 017 +SELECT * FROM collate_test3 WHERE b >= 'bbc' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 018 +SELECT * FROM collate_test3 WHERE b >= 'BBC' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 019 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 020 +SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 021 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 022 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "en_US" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 023 +CREATE DOMAIN testdomain_sv AS text COLLATE "sv_SE" +-- +STMT: CreateDomainStmt +== 024 +CREATE DOMAIN testdomain_i AS int COLLATE "sv_SE" +-- +STMT: CreateDomainStmt +== 025 +-- fails +CREATE TABLE collate_test4 ( + a int, + b testdomain_sv +) +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DDL +STMT: CreateStmt +== 026 +INSERT INTO collate_test4 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 027 +SELECT a, b FROM collate_test4 ORDER BY b +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=Select +STMT: SelectStmt +== 028 +CREATE TABLE collate_test5 ( + a int, + b testdomain_sv COLLATE "en_US" +) +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DDL +STMT: CreateStmt +== 029 +INSERT INTO collate_test5 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 030 +SELECT a, b FROM collate_test5 ORDER BY b +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=Select +STMT: SelectStmt +== 031 +SELECT a, b FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 032 +SELECT a, b FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 033 +SELECT a, b FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 034 +SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 035 +-- star expansion +SELECT * FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 036 +SELECT * FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 037 +SELECT * FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 038 +-- constant expression folding +SELECT 'bbc' COLLATE "en_US" > 'äbc' COLLATE "en_US" AS "true" +-- +STMT: SelectStmt +== 039 +SELECT 'bbc' COLLATE "sv_SE" > 'äbc' COLLATE "sv_SE" AS "false" +-- +STMT: SelectStmt +== 040 +-- upper/lower + +CREATE TABLE collate_test10 ( + a int, + x text COLLATE "en_US", + y text COLLATE "tr_TR" +) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DDL +STMT: CreateStmt +== 041 +INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ') +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT a, lower(x COLLATE "C"), lower(y COLLATE "C") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- LIKE/ILIKE + +SELECT * FROM collate_test1 WHERE b LIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 046 +SELECT * FROM collate_test1 WHERE b LIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 047 +SELECT * FROM collate_test1 WHERE b LIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 048 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 049 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 050 +SELECT * FROM collate_test1 WHERE b ILIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 051 +SELECT 'Türkiye' COLLATE "en_US" ILIKE '%KI%' AS "true" +-- +STMT: SelectStmt +== 052 +SELECT 'Türkiye' COLLATE "tr_TR" ILIKE '%KI%' AS "false" +-- +STMT: SelectStmt +== 053 +SELECT 'bıt' ILIKE 'BIT' COLLATE "en_US" AS "false" +-- +STMT: SelectStmt +== 054 +SELECT 'bıt' ILIKE 'BIT' COLLATE "tr_TR" AS "true" +-- +STMT: SelectStmt +== 055 +-- The following actually exercises the selectivity estimation for ILIKE. +SELECT relname FROM pg_class WHERE relname ILIKE 'abc%' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 056 +-- regular expressions + +SELECT * FROM collate_test1 WHERE b ~ '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 057 +SELECT * FROM collate_test1 WHERE b ~ '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 058 +SELECT * FROM collate_test1 WHERE b ~ 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 059 +SELECT * FROM collate_test1 WHERE b ~* '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 060 +SELECT * FROM collate_test1 WHERE b ~* '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 061 +SELECT * FROM collate_test1 WHERE b ~* 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 062 +CREATE TABLE collate_test6 ( + a int, + b text COLLATE "en_US" +) +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DDL +STMT: CreateStmt +== 063 +INSERT INTO collate_test6 VALUES (1, 'abc'), (2, 'ABC'), (3, '123'), (4, 'ab1'), + (5, 'a1!'), (6, 'a c'), (7, '!.;'), (8, ' '), + (9, 'äbç'), (10, 'ÄBÇ') +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +SELECT b, + b ~ '^[[:alpha:]]+$' AS is_alpha, + b ~ '^[[:upper:]]+$' AS is_upper, + b ~ '^[[:lower:]]+$' AS is_lower, + b ~ '^[[:digit:]]+$' AS is_digit, + b ~ '^[[:alnum:]]+$' AS is_alnum, + b ~ '^[[:graph:]]+$' AS is_graph, + b ~ '^[[:print:]]+$' AS is_print, + b ~ '^[[:punct:]]+$' AS is_punct, + b ~ '^[[:space:]]+$' AS is_space +FROM collate_test6 +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=Select +STMT: SelectStmt +== 065 +SELECT 'Türkiye' COLLATE "en_US" ~* 'KI' AS "true" +-- +STMT: SelectStmt +== 066 +SELECT 'Türkiye' COLLATE "tr_TR" ~* 'KI' AS "false" +-- +STMT: SelectStmt +== 067 +SELECT 'bıt' ~* 'BIT' COLLATE "en_US" AS "false" +-- +STMT: SelectStmt +== 068 +SELECT 'bıt' ~* 'BIT' COLLATE "tr_TR" AS "true" +-- +STMT: SelectStmt +== 069 +-- The following actually exercises the selectivity estimation for ~*. +SELECT relname FROM pg_class WHERE relname ~* '^abc' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 070 +-- to_char + +SET lc_time TO 'tr_TR' +-- +STMT: VariableSetStmt +== 071 +SELECT to_char(date '2010-02-01', 'DD TMMON YYYY') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 072 +SELECT to_char(date '2010-02-01', 'DD TMMON YYYY' COLLATE "tr_TR") +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 073 +SELECT to_char(date '2010-04-01', 'DD TMMON YYYY') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT to_char(date '2010-04-01', 'DD TMMON YYYY' COLLATE "tr_TR") +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 075 +-- to_date + +SELECT to_date('01 ŞUB 2010', 'DD TMMON YYYY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT to_date('01 Şub 2010', 'DD TMMON YYYY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 077 +SELECT to_date('1234567890ab 2010', 'TMMONTH YYYY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 078 +-- fail + + +-- backwards parsing + +CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collview1" schema="" table="collview1" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 079 +CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collview2" schema="" table="collview2" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 080 +CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10 +-- +TABLE: name="collview3" schema="" table="collview3" ctx=DDL +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 081 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'collview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 082 +-- collation propagation in various expression types + +SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 083 +SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 084 +SELECT a, coalesce(b, 'foo') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 085 +SELECT a, lower(coalesce(x, 'foo')), lower(coalesce(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 087 +SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 088 +SELECT a, b, greatest(b, 'CCC') FROM collate_test3 ORDER BY 3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 089 +SELECT a, x, y, lower(greatest(x, 'foo')), lower(greatest(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 090 +SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 091 +SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 092 +SELECT a, nullif(b, 'abc') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 093 +SELECT a, lower(nullif(x, 'foo')), lower(nullif(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 094 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 095 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 096 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 097 +CREATE DOMAIN testdomain AS text +-- +STMT: CreateDomainStmt +== 098 +SELECT a, b::testdomain FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 099 +SELECT a, b::testdomain FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 100 +SELECT a, b::testdomain FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 101 +SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 102 +SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 103 +SELECT min(b), max(b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 104 +SELECT min(b), max(b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 105 +SELECT min(b), max(b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 106 +SELECT array_agg(b ORDER BY b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 107 +SELECT array_agg(b ORDER BY b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 108 +SELECT array_agg(b ORDER BY b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 109 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 110 +SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 111 +SELECT a, b FROM collate_test3 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test3 WHERE a > 1 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 112 +SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 113 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 114 +-- fail +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 115 +-- ok +SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 116 +-- fail +SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 117 +-- ok +SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 118 +-- fail +SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 119 +-- fail + +CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="test_u" schema="" table="test_u" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 120 +-- fail + +-- ideally this would be a parse-time error, but for now it must be run-time: +select x < y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 121 +-- fail +select x || y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 122 +-- ok, because || is not collation aware +select x, y from collate_test10 order by x || y +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 123 +-- not so ok + +-- collation mismatch between recursive and non-recursive term +WITH RECURSIVE foo(x) AS + (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x) + UNION ALL + SELECT (x || 'c') COLLATE "de_DE" FROM foo WHERE length(x) < 10) +SELECT * FROM foo +-- +CTE: "foo" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 124 +-- casting + +SELECT CAST('42' AS text COLLATE "C") +-- +ERROR: syntax error at or near "COLLATE" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 125 +SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 126 +SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 127 +SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 128 +-- propagation of collation in SQL functions (inlined and non-inlined cases) +-- and plpgsql functions too + +CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 $$ +-- +FUNCTION: name="mylt" function="mylt" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 129 +CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 limit 1 $$ +-- +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 130 +CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql + AS $$ begin return $1 < $2; end $$ +-- +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 131 +SELECT a.b AS a, b.b AS b, a.b < b.b AS lt, + mylt(a.b, b.b), mylt_noninline(a.b, b.b), mylt_plpgsql(a.b, b.b) +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +== 132 +SELECT a.b AS a, b.b AS b, a.b < b.b COLLATE "C" AS lt, + mylt(a.b, b.b COLLATE "C"), mylt_noninline(a.b, b.b COLLATE "C"), + mylt_plpgsql(a.b, b.b COLLATE "C") +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +== 133 +-- collation override in plpgsql + +CREATE FUNCTION mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 134 +SELECT mylt2('a', 'B' collate "en_US") as t, mylt2('a', 'B' collate "C") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 135 +CREATE OR REPLACE FUNCTION + mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text COLLATE "POSIX" := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 136 +SELECT mylt2('a', 'B') as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 137 +SELECT mylt2('a', 'B' collate "C") as fail +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 138 +-- conflicting collations +SELECT mylt2('a', 'B' collate "POSIX") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 139 +-- polymorphism + +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 140 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 141 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 142 +CREATE FUNCTION dup (anyelement) RETURNS anyelement + AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 143 +SELECT a, dup(b) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 144 +SELECT a, dup(b) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 145 +SELECT a, dup(b) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 146 +-- indexes + +CREATE INDEX collate_test1_idx1 ON collate_test1 (b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 147 +CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 148 +CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 149 +-- this is different grammatically +CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 150 +CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 151 +-- fail +CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 152 +-- fail + +SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 153 +-- schema manipulation commands + +CREATE ROLE regress_test_role +-- +STMT: CreateRoleStmt +== 154 +CREATE SCHEMA test_schema +-- +STMT: CreateSchemaStmt +== 155 +-- We need to do this this way to cope with varying names for encodings: +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test0 (locale = ' || + quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +== 156 +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +== 157 +-- fail, duplicate name +CREATE COLLATION IF NOT EXISTS test0 FROM "C" +-- +STMT: DefineStmt +== 158 +-- ok, skipped +CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo') +-- +STMT: DefineStmt +== 159 +-- ok, skipped +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test1 (lc_collate = ' || + quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || + ', lc_ctype = ' || + quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +== 160 +CREATE COLLATION test3 (lc_collate = 'en_US.utf8') +-- +STMT: DefineStmt +== 161 +-- fail, need lc_ctype +CREATE COLLATION testx (locale = 'nonsense') +-- +STMT: DefineStmt +== 162 +-- fail + +CREATE COLLATION test4 FROM nonsense +-- +STMT: DefineStmt +== 163 +CREATE COLLATION test5 FROM test0 +-- +STMT: DefineStmt +== 164 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 165 +ALTER COLLATION test1 RENAME TO test11 +-- +STMT: RenameStmt +== 166 +ALTER COLLATION test0 RENAME TO test11 +-- +STMT: RenameStmt +== 167 +-- fail +ALTER COLLATION test1 RENAME TO test22 +-- +STMT: RenameStmt +== 168 +-- fail + +ALTER COLLATION test11 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +== 169 +ALTER COLLATION test11 OWNER TO nonsense +-- +STMT: AlterOwnerStmt +== 170 +ALTER COLLATION test11 SET SCHEMA test_schema +-- +STMT: AlterObjectSchemaStmt +== 171 +COMMENT ON COLLATION test0 IS 'US English' +-- +STMT: CommentStmt +== 172 +SELECT collname, nspname, obj_description(pg_collation.oid, 'pg_collation') + FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid) + WHERE collname LIKE 'test%' + ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 173 +DROP COLLATION test0, test_schema.test11, test5 +-- +STMT: DropStmt +== 174 +DROP COLLATION test0 +-- +STMT: DropStmt +== 175 +-- fail +DROP COLLATION IF EXISTS test0 +-- +STMT: DropStmt +== 176 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 177 +DROP SCHEMA test_schema +-- +STMT: DropStmt +== 178 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +== 179 +-- ALTER + +ALTER COLLATION "en_US" REFRESH VERSION +-- +STMT: AlterCollationStmt +== 180 +-- also test for database while we are here +SELECT current_database() AS datname +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +== 181 +ALTER DATABASE :"datname" REFRESH COLLATION VERSION +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 182 +-- dependencies + +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +== 183 +CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0) +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +STMT: CreateStmt +== 184 +CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0 +-- +STMT: CreateDomainStmt +== 185 +CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0) +-- +STMT: CompositeTypeStmt +== 186 +CREATE VIEW collate_dep_test3 AS SELECT text 'foo' COLLATE test0 AS foo +-- +TABLE: name="collate_dep_test3" schema="" table="collate_dep_test3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 187 +CREATE TABLE collate_dep_test4t (a int, b text) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: CreateStmt +== 188 +CREATE INDEX collate_dep_test4i ON collate_dep_test4t (b COLLATE test0) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: IndexStmt +== 189 +DROP COLLATION test0 RESTRICT +-- +STMT: DropStmt +== 190 +-- fail +DROP COLLATION test0 CASCADE +-- +STMT: DropStmt +== 191 +DROP TABLE collate_dep_test1, collate_dep_test4t +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: DropStmt +== 192 +DROP TYPE collate_dep_test2 +-- +STMT: DropStmt +== 193 +-- test range types and collations + +create type textrange_c as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +== 194 +create type textrange_en_us as range(subtype=text, collation="en_US") +-- +STMT: CreateRangeStmt +== 195 +select textrange_c('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_c" function="textrange_c" schema="" ctx=Call +STMT: SelectStmt +== 196 +select textrange_en_us('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_en_us" function="textrange_en_us" schema="" ctx=Call +STMT: SelectStmt +== 197 +drop type textrange_c +-- +STMT: DropStmt +== 198 +drop type textrange_en_us +-- +STMT: DropStmt +== 199 +-- standard collations + +SELECT * FROM collate_test2 ORDER BY b COLLATE UCS_BASIC +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 200 +-- nondeterministic collations +-- (not supported with libc provider) + +CREATE COLLATION ctest_det (locale = 'en_US.utf8', deterministic = true) +-- +STMT: DefineStmt +== 201 +CREATE COLLATION ctest_nondet (locale = 'en_US.utf8', deterministic = false) +-- +STMT: DefineStmt +== 202 +-- cleanup +SET client_min_messages TO warning +-- +STMT: VariableSetStmt +== 203 +DROP SCHEMA collate_tests CASCADE +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/collate.metadata.json b/parser/testdata/summary/postgres_regress/collate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/collate.test b/parser/testdata/summary/postgres_regress/collate.test new file mode 100644 index 0000000..3f21c91 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.test @@ -0,0 +1,911 @@ +== 001 +/* + * This test is intended to pass on all platforms supported by Postgres. + * We can therefore only assume that the default, C, and POSIX collations + * are available --- and since the regression tests are often run in a + * C-locale database, these may well all have the same behavior. But + * fortunately, the system doesn't know that and will treat them as + * incompatible collations. It is therefore at least possible to test + * parser behaviors such as collation conflict resolution. This test will, + * however, be more revealing when run in a database with non-C locale, + * since any departure from C sorting behavior will show as a failure. + */ + +CREATE SCHEMA collate_tests +-- +STMT: CreateSchemaStmt +== 002 +SET search_path = collate_tests +-- +STMT: VariableSetStmt +== 003 +CREATE TABLE collate_test1 ( + a int, + b text COLLATE "C" NOT NULL +) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE collate_test_fail ( + a int COLLATE "C", + b text +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 005 +CREATE TABLE collate_test_like ( + LIKE collate_test1 +) +-- +TABLE: name="collate_test_like" schema="" table="collate_test_like" ctx=DDL +STMT: CreateStmt +== 006 +CREATE TABLE collate_test2 ( + a int, + b text COLLATE "POSIX" +) +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DDL +STMT: CreateStmt +== 007 +INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'Abc'), (3, 'bbc'), (4, 'ABD') +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO collate_test2 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 009 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 010 +SELECT * FROM collate_test1 WHERE b >= 'abc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 011 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'abc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 012 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "POSIX" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 013 +-- fail + +CREATE DOMAIN testdomain_p AS text COLLATE "POSIX" +-- +STMT: CreateDomainStmt +== 014 +CREATE DOMAIN testdomain_i AS int COLLATE "POSIX" +-- +STMT: CreateDomainStmt +== 015 +-- fail +CREATE TABLE collate_test4 ( + a int, + b testdomain_p +) +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DDL +STMT: CreateStmt +== 016 +INSERT INTO collate_test4 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 017 +SELECT a, b FROM collate_test4 ORDER BY b +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=Select +STMT: SelectStmt +== 018 +CREATE TABLE collate_test5 ( + a int, + b testdomain_p COLLATE "C" +) +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DDL +STMT: CreateStmt +== 019 +INSERT INTO collate_test5 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 020 +SELECT a, b FROM collate_test5 ORDER BY b +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=Select +STMT: SelectStmt +== 021 +SELECT a, b FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 022 +SELECT a, b FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 023 +SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 024 +-- star expansion +SELECT * FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 025 +SELECT * FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 026 +-- constant expression folding +SELECT 'bbc' COLLATE "C" > 'Abc' COLLATE "C" AS "true" +-- +STMT: SelectStmt +== 027 +SELECT 'bbc' COLLATE "POSIX" < 'Abc' COLLATE "POSIX" AS "false" +-- +STMT: SelectStmt +== 028 +-- upper/lower + +CREATE TABLE collate_test10 ( + a int, + x text COLLATE "C", + y text COLLATE "POSIX" +) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DDL +STMT: CreateStmt +== 029 +INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ') +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT a, lower(x COLLATE "C"), lower(y COLLATE "C") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 033 +-- backwards parsing + +CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collview1" schema="" table="collview1" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 034 +CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collview2" schema="" table="collview2" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 035 +CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "POSIX") FROM collate_test10 +-- +TABLE: name="collview3" schema="" table="collview3" ctx=DDL +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 036 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'collview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 037 +-- collation propagation in various expression types + +SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 038 +SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 039 +SELECT a, lower(coalesce(x, 'foo')), lower(coalesce(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 041 +SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 042 +SELECT a, x, y, lower(greatest(x, 'foo')), lower(greatest(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 044 +SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 045 +SELECT a, lower(nullif(x, 'foo')), lower(nullif(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 046 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 047 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 048 +CREATE DOMAIN testdomain AS text +-- +STMT: CreateDomainStmt +== 049 +SELECT a, b::testdomain FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 050 +SELECT a, b::testdomain FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 051 +SELECT a, b::testdomain_p FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 052 +SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 053 +SELECT min(b), max(b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 054 +SELECT min(b), max(b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 055 +SELECT array_agg(b ORDER BY b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 056 +SELECT array_agg(b ORDER BY b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 057 +-- In aggregates, ORDER BY expressions don't affect aggregate's collation +SELECT string_agg(x COLLATE "C", y COLLATE "POSIX") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +== 058 +-- fail +SELECT array_agg(x COLLATE "C" ORDER BY y COLLATE "POSIX") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT array_agg(a ORDER BY x COLLATE "C", y COLLATE "POSIX") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT array_agg(a ORDER BY x||y) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 061 +-- fail + +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 062 +SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 063 +SELECT a, b FROM collate_test2 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test2 WHERE a > 1 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 064 +SELECT a, b FROM collate_test2 EXCEPT SELECT a, b FROM collate_test2 WHERE a < 2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 065 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 066 +-- fail +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 067 +-- ok +SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 068 +-- fail +SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 069 +-- ok +SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 070 +-- fail +SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 071 +-- fail + +CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2 +-- +TABLE: name="test_u" schema="" table="test_u" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 072 +-- fail + +-- ideally this would be a parse-time error, but for now it must be run-time: +select x < y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 073 +-- fail +select x || y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 074 +-- ok, because || is not collation aware +select x, y from collate_test10 order by x || y +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +== 075 +-- not so ok + +-- collation mismatch between recursive and non-recursive term +WITH RECURSIVE foo(x) AS + (SELECT x FROM (VALUES('a' COLLATE "C"),('b')) t(x) + UNION ALL + SELECT (x || 'c') COLLATE "POSIX" FROM foo WHERE length(x) < 10) +SELECT * FROM foo +-- +CTE: "foo" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 076 +SELECT a, b, a < b as lt FROM + (VALUES ('a', 'B'), ('A', 'b' COLLATE "C")) v(a,b) +-- +STMT: SelectStmt +== 077 +-- collation mismatch in subselects +SELECT * FROM collate_test10 WHERE (x, y) NOT IN (SELECT y, x FROM collate_test10) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +== 078 +-- now it works with overrides +SELECT * FROM collate_test10 WHERE (x COLLATE "POSIX", y COLLATE "C") NOT IN (SELECT y, x FROM collate_test10) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +== 079 +SELECT * FROM collate_test10 WHERE (x, y) NOT IN (SELECT y COLLATE "C", x COLLATE "POSIX" FROM collate_test10) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +== 080 +-- casting + +SELECT CAST('42' AS text COLLATE "C") +-- +ERROR: syntax error at or near "COLLATE" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 081 +SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 082 +SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 083 +-- result of a SQL function + +CREATE FUNCTION vc (text) RETURNS text LANGUAGE sql + AS 'select $1::varchar' +-- +FUNCTION: name="vc" function="vc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 084 +SELECT a, b FROM collate_test1 ORDER BY a, vc(b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="vc" function="vc" schema="" ctx=Call +STMT: SelectStmt +== 085 +-- polymorphism + +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 087 +CREATE FUNCTION dup (anyelement) RETURNS anyelement + AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 088 +SELECT a, dup(b) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 089 +SELECT a, dup(b) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 090 +-- indexes + +CREATE INDEX collate_test1_idx1 ON collate_test1 (b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 091 +CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "POSIX") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 092 +CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 093 +-- this is different grammatically +CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 094 +CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "POSIX") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 095 +-- fail +CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 096 +-- fail + +SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 097 +-- foreign keys + +-- force indexes and mergejoins to be used for FK checking queries, +-- else they might not exercise collation-dependent operators +SET enable_seqscan TO 0 +-- +STMT: VariableSetStmt +== 098 +SET enable_hashjoin TO 0 +-- +STMT: VariableSetStmt +== 099 +SET enable_nestloop TO 0 +-- +STMT: VariableSetStmt +== 100 +CREATE TABLE collate_test20 (f1 text COLLATE "C" PRIMARY KEY) +-- +TABLE: name="collate_test20" schema="" table="collate_test20" ctx=DDL +STMT: CreateStmt +== 101 +INSERT INTO collate_test20 VALUES ('foo'), ('bar') +-- +TABLE: name="collate_test20" schema="" table="collate_test20" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 102 +CREATE TABLE collate_test21 (f2 text COLLATE "POSIX" REFERENCES collate_test20) +-- +TABLE: name="collate_test21" schema="" table="collate_test21" ctx=DDL +STMT: CreateStmt +== 103 +INSERT INTO collate_test21 VALUES ('foo'), ('bar') +-- +TABLE: name="collate_test21" schema="" table="collate_test21" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +INSERT INTO collate_test21 VALUES ('baz') +-- +TABLE: name="collate_test21" schema="" table="collate_test21" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +-- fail +CREATE TABLE collate_test22 (f2 text COLLATE "POSIX") +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DDL +STMT: CreateStmt +== 106 +INSERT INTO collate_test22 VALUES ('foo'), ('bar'), ('baz') +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +ALTER TABLE collate_test22 ADD FOREIGN KEY (f2) REFERENCES collate_test20 +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DDL +STMT: AlterTableStmt +== 108 +-- fail +DELETE FROM collate_test22 WHERE f2 = 'baz' +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DML +STMT: DeleteStmt +== 109 +ALTER TABLE collate_test22 ADD FOREIGN KEY (f2) REFERENCES collate_test20 +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DDL +STMT: AlterTableStmt +== 110 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 111 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +== 112 +RESET enable_nestloop +-- +STMT: VariableSetStmt +== 113 +-- EXPLAIN + +EXPLAIN (COSTS OFF) + SELECT * FROM collate_test10 ORDER BY x, y +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 114 +EXPLAIN (COSTS OFF) + SELECT * FROM collate_test10 ORDER BY x DESC, y COLLATE "C" ASC NULLS FIRST +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 115 +-- CREATE/DROP COLLATION + +CREATE COLLATION builtin_c ( PROVIDER = builtin, LOCALE = "C" ) +-- +STMT: DefineStmt +== 116 +SELECT b FROM collate_test1 ORDER BY b COLLATE builtin_c +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 117 +CREATE COLLATION builtin2 ( PROVIDER = builtin ) +-- +STMT: DefineStmt +== 118 +-- fails +CREATE COLLATION builtin2 ( PROVIDER = builtin, LOCALE = "en_US" ) +-- +STMT: DefineStmt +== 119 +-- fails +CREATE COLLATION builtin2 ( PROVIDER = builtin, LC_CTYPE = "C", LC_COLLATE = "C" ) +-- +STMT: DefineStmt +== 120 +-- fails + +CREATE COLLATION mycoll1 FROM "C" +-- +STMT: DefineStmt +== 121 +CREATE COLLATION mycoll2 ( LC_COLLATE = "POSIX", LC_CTYPE = "POSIX" ) +-- +STMT: DefineStmt +== 122 +CREATE COLLATION mycoll3 FROM "default" +-- +STMT: DefineStmt +== 123 +-- intentionally unsupported + +DROP COLLATION mycoll1 +-- +STMT: DropStmt +== 124 +CREATE TABLE collate_test23 (f1 text collate mycoll2) +-- +TABLE: name="collate_test23" schema="" table="collate_test23" ctx=DDL +STMT: CreateStmt +== 125 +DROP COLLATION mycoll2 +-- +STMT: DropStmt +== 126 +-- fail + +-- invalid: non-lowercase quoted identifiers +CREATE COLLATION case_coll ("Lc_Collate" = "POSIX", "Lc_Ctype" = "POSIX") +-- +STMT: DefineStmt +== 127 +-- 9.1 bug with useless COLLATE in an expression subject to length coercion + +CREATE TEMP TABLE vctable (f1 varchar(25)) +-- +TABLE: name="vctable" schema="" table="vctable" ctx=DDL +STMT: CreateStmt +== 128 +INSERT INTO vctable VALUES ('foo' COLLATE "C") +-- +TABLE: name="vctable" schema="" table="vctable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +SELECT collation for ('foo') +-- +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 130 +-- unknown type - null +SELECT collation for ('foo'::text) +-- +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 131 +SELECT collation for ((SELECT a FROM collate_test1 LIMIT 1)) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 132 +-- non-collatable type - error +SELECT collation for ((SELECT b FROM collate_test1 LIMIT 1)) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 133 +-- old bug with not dropping COLLATE when coercing to non-collatable type +CREATE VIEW collate_on_int AS +SELECT c1+1 AS c1p FROM + (SELECT ('4' COLLATE "C")::INT AS c1) ss +-- +TABLE: name="collate_on_int" schema="" table="collate_on_int" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 134 +-- Check conflicting or redundant options in CREATE COLLATION +-- LC_COLLATE +CREATE COLLATION coll_dup_chk (LC_COLLATE = "POSIX", LC_COLLATE = "NONSENSE", LC_CTYPE = "POSIX") +-- +STMT: DefineStmt +== 135 +-- LC_CTYPE +CREATE COLLATION coll_dup_chk (LC_CTYPE = "POSIX", LC_CTYPE = "NONSENSE", LC_COLLATE = "POSIX") +-- +STMT: DefineStmt +== 136 +-- PROVIDER +CREATE COLLATION coll_dup_chk (PROVIDER = icu, PROVIDER = NONSENSE, LC_COLLATE = "POSIX", LC_CTYPE = "POSIX") +-- +STMT: DefineStmt +== 137 +-- LOCALE +CREATE COLLATION case_sensitive (LOCALE = '', LOCALE = "NONSENSE") +-- +STMT: DefineStmt +== 138 +-- DETERMINISTIC +CREATE COLLATION coll_dup_chk (DETERMINISTIC = TRUE, DETERMINISTIC = NONSENSE, LOCALE = '') +-- +STMT: DefineStmt +== 139 +-- VERSION +CREATE COLLATION coll_dup_chk (VERSION = '1', VERSION = "NONSENSE", LOCALE = '') +-- +STMT: DefineStmt +== 140 +-- LOCALE conflicts with LC_COLLATE and LC_CTYPE +CREATE COLLATION coll_dup_chk (LC_COLLATE = "POSIX", LC_CTYPE = "POSIX", LOCALE = '') +-- +STMT: DefineStmt +== 141 +-- LOCALE conflicts with LC_COLLATE +CREATE COLLATION coll_dup_chk (LC_COLLATE = "POSIX", LOCALE = '') +-- +STMT: DefineStmt +== 142 +-- LOCALE conflicts with LC_CTYPE +CREATE COLLATION coll_dup_chk (LC_CTYPE = "POSIX", LOCALE = '') +-- +STMT: DefineStmt +== 143 +-- FROM conflicts with any other option +CREATE COLLATION coll_dup_chk (FROM = "C", VERSION = "1") +-- +STMT: DefineStmt +== 144 +|-- +-- Clean up. Many of these table names will be re-used if the user is +-- trying to run any platform-specific collation tests later, so we +-- must get rid of them. +|-- +DROP SCHEMA collate_tests CASCADE +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/collate.utf8.metadata.json b/parser/testdata/summary/postgres_regress/collate.utf8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.utf8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/collate.utf8.test b/parser/testdata/summary/postgres_regress/collate.utf8.test new file mode 100644 index 0000000..00e00c2 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.utf8.test @@ -0,0 +1,155 @@ +== 001 +/* + * This test is for collations and character operations when using the + * builtin provider with the C.UTF-8 locale. + */ + +/* skip test if not UTF8 server encoding */ +SELECT getdatabaseencoding() <> 'UTF8' AS skip_test +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +== 002 +SET client_encoding TO UTF8 +-- +STMT: VariableSetStmt +== 003 +|-- +-- Test PG_C_UTF8 +|-- + +CREATE COLLATION regress_pg_c_utf8 ( + provider = builtin, locale = 'C_UTF8') +-- +STMT: DefineStmt +== 004 +-- fails +CREATE COLLATION regress_pg_c_utf8 ( + provider = builtin, locale = 'C.UTF8') +-- +STMT: DefineStmt +== 005 +DROP COLLATION regress_pg_c_utf8 +-- +STMT: DropStmt +== 006 +CREATE COLLATION regress_pg_c_utf8 ( + provider = builtin, locale = 'C.UTF-8') +-- +STMT: DefineStmt +== 007 +CREATE TABLE test_pg_c_utf8 ( + t TEXT COLLATE PG_C_UTF8 +) +-- +TABLE: name="test_pg_c_utf8" schema="" table="test_pg_c_utf8" ctx=DDL +STMT: CreateStmt +== 008 +INSERT INTO test_pg_c_utf8 VALUES + ('abc DEF 123abc'), + ('ábc sßs ßss DÉF'), + ('DŽxxDŽ džxxDž Džxxdž'), + ('ȺȺȺ'), + ('ⱥⱥⱥ'), + ('ⱥȺ') +-- +TABLE: name="test_pg_c_utf8" schema="" table="test_pg_c_utf8" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +SELECT + t, lower(t), initcap(t), upper(t), + length(convert_to(t, 'UTF8')) AS t_bytes, + length(convert_to(lower(t), 'UTF8')) AS lower_t_bytes, + length(convert_to(initcap(t), 'UTF8')) AS initcap_t_bytes, + length(convert_to(upper(t), 'UTF8')) AS upper_t_bytes + FROM test_pg_c_utf8 +-- +TABLE: name="test_pg_c_utf8" schema="" table="test_pg_c_utf8" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="convert_to" function="convert_to" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="convert_to" function="convert_to" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="convert_to" function="convert_to" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="convert_to" function="convert_to" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +== 010 +DROP TABLE test_pg_c_utf8 +-- +TABLE: name="test_pg_c_utf8" schema="" table="test_pg_c_utf8" ctx=DDL +STMT: DropStmt +== 011 +-- negative test: Final_Sigma not used for builtin locale C.UTF-8 +SELECT lower('ΑΣ' COLLATE PG_C_UTF8) +-- +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT lower('ΑͺΣͺ' COLLATE PG_C_UTF8) +-- +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT lower('Α΄Σ΄' COLLATE PG_C_UTF8) +-- +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- properties + +SELECT 'xyz' ~ '[[:alnum:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 015 +SELECT 'xyz' !~ '[[:upper:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 016 +SELECT '@' !~ '[[:alnum:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 017 +SELECT '=' ~ '[[:punct:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 018 +-- symbols are punctuation in posix +SELECT 'a8a' ~ '[[:digit:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 019 +SELECT '൧' !~ '\d' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 020 +-- only 0-9 considered digits in posix + +-- case mapping + +SELECT 'xYz' ~* 'XyZ' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 021 +SELECT 'xAb' ~* '[W-Y]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 022 +SELECT 'xAb' !~* '[c-d]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 023 +SELECT 'Δ' ~* '[γ-λ]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +== 024 +SELECT 'δ' ~* '[Γ-Λ]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/collate.windows.win1252.metadata.json b/parser/testdata/summary/postgres_regress/collate.windows.win1252.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.windows.win1252.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/collate.windows.win1252.test b/parser/testdata/summary/postgres_regress/collate.windows.win1252.test new file mode 100644 index 0000000..085c590 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/collate.windows.win1252.test @@ -0,0 +1,1095 @@ +== 001 +/* + * This test is meant to run on Windows systems that has successfully + * run pg_import_system_collations(). Also, the database must have + * WIN1252 encoding, because of the locales' own encodings. Because + * of this, some test are lost from UTF-8 version, such as Turkish + * dotted and undotted 'i'. + */ +SELECT getdatabaseencoding() <> 'WIN1252' OR + (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE') AND collencoding = pg_char_to_encoding('WIN1252')) <> 3 OR + (version() !~ 'Visual C\+\+' AND version() !~ 'mingw32' AND version() !~ 'windows') + AS skip_test +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +FUNCTION: name="pg_char_to_encoding" function="pg_char_to_encoding" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_char_to_encoding" function="pg_char_to_encoding" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +FILTER: schema="" table="" column="collencoding" +STMT: SelectStmt +== 002 +SET client_encoding TO WIN1252 +-- +STMT: VariableSetStmt +== 003 +CREATE SCHEMA collate_tests +-- +STMT: CreateSchemaStmt +== 004 +SET search_path = collate_tests +-- +STMT: VariableSetStmt +== 005 +CREATE TABLE collate_test1 ( + a int, + b text COLLATE "en_US" NOT NULL +) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: CreateStmt +== 006 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "ja_JP.eucjp" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 007 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "foo" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE collate_test_fail ( + a int COLLATE "en_US", + b text +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +== 009 +CREATE TABLE collate_test_like ( + LIKE collate_test1 +) +-- +TABLE: name="collate_test_like" schema="" table="collate_test_like" ctx=DDL +STMT: CreateStmt +== 010 +CREATE TABLE collate_test2 ( + a int, + b text COLLATE "sv_SE" +) +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DDL +STMT: CreateStmt +== 011 +CREATE TABLE collate_test3 ( + a int, + b text COLLATE "C" +) +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DDL +STMT: CreateStmt +== 012 +INSERT INTO collate_test1 VALUES (1, 'abc'), (2, '�bc'), (3, 'bbc'), (4, 'ABC') +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO collate_test2 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO collate_test3 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 015 +SELECT * FROM collate_test1 WHERE b >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 016 +SELECT * FROM collate_test2 WHERE b >= 'bbc' +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 017 +SELECT * FROM collate_test3 WHERE b >= 'bbc' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 018 +SELECT * FROM collate_test3 WHERE b >= 'BBC' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 019 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 020 +SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 021 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 022 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "en_US" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 023 +CREATE DOMAIN testdomain_sv AS text COLLATE "sv_SE" +-- +STMT: CreateDomainStmt +== 024 +CREATE DOMAIN testdomain_i AS int COLLATE "sv_SE" +-- +STMT: CreateDomainStmt +== 025 +-- fails +CREATE TABLE collate_test4 ( + a int, + b testdomain_sv +) +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DDL +STMT: CreateStmt +== 026 +INSERT INTO collate_test4 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 027 +SELECT a, b FROM collate_test4 ORDER BY b +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=Select +STMT: SelectStmt +== 028 +CREATE TABLE collate_test5 ( + a int, + b testdomain_sv COLLATE "en_US" +) +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DDL +STMT: CreateStmt +== 029 +INSERT INTO collate_test5 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 030 +SELECT a, b FROM collate_test5 ORDER BY b +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=Select +STMT: SelectStmt +== 031 +SELECT a, b FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 032 +SELECT a, b FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 033 +SELECT a, b FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 034 +SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 035 +-- star expansion +SELECT * FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 036 +SELECT * FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 037 +SELECT * FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 038 +-- constant expression folding +SELECT 'bbc' COLLATE "en_US" > '�bc' COLLATE "en_US" AS "true" +-- +STMT: SelectStmt +== 039 +SELECT 'bbc' COLLATE "sv_SE" > '�bc' COLLATE "sv_SE" AS "false" +-- +STMT: SelectStmt +== 040 +-- LIKE/ILIKE + +SELECT * FROM collate_test1 WHERE b LIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 041 +SELECT * FROM collate_test1 WHERE b LIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 042 +SELECT * FROM collate_test1 WHERE b LIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 043 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 044 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 045 +SELECT * FROM collate_test1 WHERE b ILIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 046 +-- The following actually exercises the selectivity estimation for ILIKE. +SELECT relname FROM pg_class WHERE relname ILIKE 'abc%' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 047 +-- regular expressions + +SELECT * FROM collate_test1 WHERE b ~ '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 048 +SELECT * FROM collate_test1 WHERE b ~ '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 049 +SELECT * FROM collate_test1 WHERE b ~ 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 050 +SELECT * FROM collate_test1 WHERE b ~* '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 051 +SELECT * FROM collate_test1 WHERE b ~* '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 052 +SELECT * FROM collate_test1 WHERE b ~* 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 053 +CREATE TABLE collate_test6 ( + a int, + b text COLLATE "en_US" +) +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DDL +STMT: CreateStmt +== 054 +INSERT INTO collate_test6 VALUES (1, 'abc'), (2, 'ABC'), (3, '123'), (4, 'ab1'), + (5, 'a1!'), (6, 'a c'), (7, '!.;'), (8, ' '), + (9, '�b�'), (10, '�B�') +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +SELECT b, + b ~ '^[[:alpha:]]+$' AS is_alpha, + b ~ '^[[:upper:]]+$' AS is_upper, + b ~ '^[[:lower:]]+$' AS is_lower, + b ~ '^[[:digit:]]+$' AS is_digit, + b ~ '^[[:alnum:]]+$' AS is_alnum, + b ~ '^[[:graph:]]+$' AS is_graph, + b ~ '^[[:print:]]+$' AS is_print, + b ~ '^[[:punct:]]+$' AS is_punct, + b ~ '^[[:space:]]+$' AS is_space +FROM collate_test6 +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=Select +STMT: SelectStmt +== 056 +-- The following actually exercises the selectivity estimation for ~*. +SELECT relname FROM pg_class WHERE relname ~* '^abc' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 057 +-- backwards parsing + +CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collview1" schema="" table="collview1" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 058 +CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collview2" schema="" table="collview2" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 059 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'collview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 060 +-- collation propagation in various expression types + +SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 061 +SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 062 +SELECT a, coalesce(b, 'foo') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 063 +SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 064 +SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 065 +SELECT a, b, greatest(b, 'CCC') FROM collate_test3 ORDER BY 3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 066 +SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 067 +SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 068 +SELECT a, nullif(b, 'abc') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 069 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 070 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 071 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 072 +CREATE DOMAIN testdomain AS text +-- +STMT: CreateDomainStmt +== 073 +SELECT a, b::testdomain FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 074 +SELECT a, b::testdomain FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 075 +SELECT a, b::testdomain FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 076 +SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 077 +SELECT min(b), max(b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT min(b), max(b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 079 +SELECT min(b), max(b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 080 +SELECT array_agg(b ORDER BY b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 081 +SELECT array_agg(b ORDER BY b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT array_agg(b ORDER BY b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 084 +SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 085 +SELECT a, b FROM collate_test3 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test3 WHERE a > 1 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 086 +SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 087 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 088 +-- fail +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 089 +-- ok +SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 090 +-- fail +SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 091 +-- ok +SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 092 +-- fail +SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 093 +-- fail + +CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="test_u" schema="" table="test_u" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 094 +-- fail + +-- collation mismatch between recursive and non-recursive term +WITH RECURSIVE foo(x) AS + (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x) + UNION ALL + SELECT (x || 'c') COLLATE "de_DE" FROM foo WHERE length(x) < 10) +SELECT * FROM foo +-- +CTE: "foo" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 095 +-- casting + +SELECT CAST('42' AS text COLLATE "C") +-- +ERROR: syntax error at or near "COLLATE" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 096 +SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +== 097 +SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +== 098 +SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +== 099 +-- propagation of collation in SQL functions (inlined and non-inlined cases) +-- and plpgsql functions too + +CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 $$ +-- +FUNCTION: name="mylt" function="mylt" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 100 +CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 limit 1 $$ +-- +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 101 +CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql + AS $$ begin return $1 < $2; end $$ +-- +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 102 +SELECT a.b AS a, b.b AS b, a.b < b.b AS lt, + mylt(a.b, b.b), mylt_noninline(a.b, b.b), mylt_plpgsql(a.b, b.b) +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +== 103 +SELECT a.b AS a, b.b AS b, a.b < b.b COLLATE "C" AS lt, + mylt(a.b, b.b COLLATE "C"), mylt_noninline(a.b, b.b COLLATE "C"), + mylt_plpgsql(a.b, b.b COLLATE "C") +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +== 104 +-- collation override in plpgsql + +CREATE FUNCTION mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 105 +SELECT mylt2('a', 'B' collate "en_US") as t, mylt2('a', 'B' collate "C") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 106 +CREATE OR REPLACE FUNCTION + mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text COLLATE "POSIX" := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 107 +SELECT mylt2('a', 'B') as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 108 +SELECT mylt2('a', 'B' collate "C") as fail +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 109 +-- conflicting collations +SELECT mylt2('a', 'B' collate "POSIX") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +== 110 +-- polymorphism + +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 111 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 112 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 113 +CREATE FUNCTION dup (anyelement) RETURNS anyelement + AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 114 +SELECT a, dup(b) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 115 +SELECT a, dup(b) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 116 +SELECT a, dup(b) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 117 +-- indexes + +CREATE INDEX collate_test1_idx1 ON collate_test1 (b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 118 +CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 119 +CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 120 +-- this is different grammatically +CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 121 +CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 122 +-- fail +CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +== 123 +-- fail + +SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 124 +-- schema manipulation commands + +CREATE ROLE regress_test_role +-- +STMT: CreateRoleStmt +== 125 +CREATE SCHEMA test_schema +-- +STMT: CreateSchemaStmt +== 126 +-- We need to do this this way to cope with varying names for encodings: +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test0 (locale = ' || + quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +== 127 +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +== 128 +-- fail, duplicate name +CREATE COLLATION IF NOT EXISTS test0 FROM "C" +-- +STMT: DefineStmt +== 129 +-- ok, skipped +CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo') +-- +STMT: DefineStmt +== 130 +-- ok, skipped +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test1 (lc_collate = ' || + quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || + ', lc_ctype = ' || + quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +== 131 +CREATE COLLATION test3 (lc_collate = 'en_US.utf8') +-- +STMT: DefineStmt +== 132 +-- fail, need lc_ctype +CREATE COLLATION testx (locale = 'nonsense') +-- +STMT: DefineStmt +== 133 +-- fail + +CREATE COLLATION test4 FROM nonsense +-- +STMT: DefineStmt +== 134 +CREATE COLLATION test5 FROM test0 +-- +STMT: DefineStmt +== 135 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 136 +ALTER COLLATION test1 RENAME TO test11 +-- +STMT: RenameStmt +== 137 +ALTER COLLATION test0 RENAME TO test11 +-- +STMT: RenameStmt +== 138 +-- fail +ALTER COLLATION test1 RENAME TO test22 +-- +STMT: RenameStmt +== 139 +-- fail + +ALTER COLLATION test11 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +== 140 +ALTER COLLATION test11 OWNER TO nonsense +-- +STMT: AlterOwnerStmt +== 141 +ALTER COLLATION test11 SET SCHEMA test_schema +-- +STMT: AlterObjectSchemaStmt +== 142 +COMMENT ON COLLATION test0 IS 'US English' +-- +STMT: CommentStmt +== 143 +SELECT collname, nspname, obj_description(pg_collation.oid, 'pg_collation') + FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid) + WHERE collname LIKE 'test%' + ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 144 +DROP COLLATION test0, test_schema.test11, test5 +-- +STMT: DropStmt +== 145 +DROP COLLATION test0 +-- +STMT: DropStmt +== 146 +-- fail +DROP COLLATION IF EXISTS test0 +-- +STMT: DropStmt +== 147 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 148 +DROP SCHEMA test_schema +-- +STMT: DropStmt +== 149 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +== 150 +-- ALTER + +ALTER COLLATION "en_US" REFRESH VERSION +-- +STMT: AlterCollationStmt +== 151 +-- also test for database while we are here +SELECT current_database() AS datname +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +== 152 +ALTER DATABASE :"datname" REFRESH COLLATION VERSION +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 153 +-- dependencies + +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +== 154 +CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0) +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +STMT: CreateStmt +== 155 +CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0 +-- +STMT: CreateDomainStmt +== 156 +CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0) +-- +STMT: CompositeTypeStmt +== 157 +CREATE VIEW collate_dep_test3 AS SELECT text 'foo' COLLATE test0 AS foo +-- +TABLE: name="collate_dep_test3" schema="" table="collate_dep_test3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 158 +CREATE TABLE collate_dep_test4t (a int, b text) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: CreateStmt +== 159 +CREATE INDEX collate_dep_test4i ON collate_dep_test4t (b COLLATE test0) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: IndexStmt +== 160 +DROP COLLATION test0 RESTRICT +-- +STMT: DropStmt +== 161 +-- fail +DROP COLLATION test0 CASCADE +-- +STMT: DropStmt +== 162 +DROP TABLE collate_dep_test1, collate_dep_test4t +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: DropStmt +== 163 +DROP TYPE collate_dep_test2 +-- +STMT: DropStmt +== 164 +-- test range types and collations + +create type textrange_c as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +== 165 +create type textrange_en_us as range(subtype=text, collation="en_US") +-- +STMT: CreateRangeStmt +== 166 +select textrange_c('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_c" function="textrange_c" schema="" ctx=Call +STMT: SelectStmt +== 167 +select textrange_en_us('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_en_us" function="textrange_en_us" schema="" ctx=Call +STMT: SelectStmt +== 168 +drop type textrange_c +-- +STMT: DropStmt +== 169 +drop type textrange_en_us +-- +STMT: DropStmt +== 170 +-- nondeterministic collations +-- (not supported with libc provider) +do $$ +BEGIN + EXECUTE 'CREATE COLLATION ctest_det (locale = ' || + quote_literal((SELECT collcollate FROM pg_collation WHERE + collname = 'en_US')) || ', deterministic = true);'; + END +$$ +-- +STMT: DoStmt +== 171 +CREATE COLLATION ctest_nondet (locale = 'en_US', deterministic = false) +-- +STMT: DefineStmt +== 172 +-- cleanup +SET client_min_messages TO warning +-- +STMT: VariableSetStmt +== 173 +DROP SCHEMA collate_tests CASCADE +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/combocid.metadata.json b/parser/testdata/summary/postgres_regress/combocid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/combocid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/combocid.test b/parser/testdata/summary/postgres_regress/combocid.test new file mode 100644 index 0000000..0f857c3 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/combocid.test @@ -0,0 +1,339 @@ +== 001 +|-- +-- Tests for some likely failure cases with combo cmin/cmax mechanism +|-- +CREATE TEMP TABLE combocidtest (foobar int) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DDL +STMT: CreateStmt +== 002 +BEGIN +-- +STMT: TransactionStmt +== 003 +-- a few dummy ops to push up the CommandId counter +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO combocidtest VALUES (1) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO combocidtest VALUES (2) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 016 +SAVEPOINT s1 +-- +STMT: TransactionStmt +== 017 +UPDATE combocidtest SET foobar = foobar + 10 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: UpdateStmt +== 018 +-- here we should see only updated tuples +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 019 +ROLLBACK TO s1 +-- +STMT: TransactionStmt +== 020 +-- now we should see old tuples, but with combo CIDs starting at 0 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 021 +COMMIT +-- +STMT: TransactionStmt +== 022 +-- combo data is not there anymore, but should still see tuples +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 023 +-- Test combo CIDs with portals +BEGIN +-- +STMT: TransactionStmt +== 024 +INSERT INTO combocidtest VALUES (333) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +DECLARE c CURSOR FOR SELECT ctid,cmin,* FROM combocidtest +-- +STMT: DeclareCursorStmt +== 026 +DELETE FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: DeleteStmt +== 027 +FETCH ALL FROM c +-- +STMT: FetchStmt +== 028 +ROLLBACK +-- +STMT: TransactionStmt +== 029 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 030 +-- check behavior with locked tuples +BEGIN +-- +STMT: TransactionStmt +== 031 +-- a few dummy ops to push up the CommandId counter +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO combocidtest VALUES (444) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 043 +SAVEPOINT s1 +-- +STMT: TransactionStmt +== 044 +-- this doesn't affect cmin +SELECT ctid,cmin,* FROM combocidtest FOR UPDATE +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 045 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 046 +-- but this does +UPDATE combocidtest SET foobar = foobar + 10 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: UpdateStmt +== 047 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 048 +ROLLBACK TO s1 +-- +STMT: TransactionStmt +== 049 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 050 +COMMIT +-- +STMT: TransactionStmt +== 051 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +== 052 +-- test for bug reported in +-- CABRT9RC81YUf1=jsmWopcKJEro=VoeG2ou6sPwyOUTx_qteRsg@mail.gmail.com +CREATE TABLE IF NOT EXISTS testcase( + id int PRIMARY KEY, + balance numeric +) +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DDL +STMT: CreateStmt +== 053 +INSERT INTO testcase VALUES (1, 0) +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +BEGIN +-- +STMT: TransactionStmt +== 055 +SELECT * FROM testcase WHERE testcase.id = 1 FOR UPDATE +-- +TABLE: name="testcase" schema="" table="testcase" ctx=Select +FILTER: schema="" table="testcase" column="id" +STMT: SelectStmt +== 056 +UPDATE testcase SET balance = balance + 400 WHERE id=1 +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DML +STMT: UpdateStmt +== 057 +SAVEPOINT subxact +-- +STMT: TransactionStmt +== 058 +UPDATE testcase SET balance = balance - 100 WHERE id=1 +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DML +STMT: UpdateStmt +== 059 +ROLLBACK TO SAVEPOINT subxact +-- +STMT: TransactionStmt +== 060 +-- should return one tuple +SELECT * FROM testcase WHERE id = 1 FOR UPDATE +-- +TABLE: name="testcase" schema="" table="testcase" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 061 +ROLLBACK +-- +STMT: TransactionStmt +== 062 +DROP TABLE testcase +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/comments.metadata.json b/parser/testdata/summary/postgres_regress/comments.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/comments.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/comments.test b/parser/testdata/summary/postgres_regress/comments.test new file mode 100644 index 0000000..c544ef6 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/comments.test @@ -0,0 +1,59 @@ +== 001 +|-- +-- COMMENTS +|-- + +SELECT 'trailing' AS first +-- +STMT: SelectStmt +== 002 +-- trailing single line +SELECT /* embedded single line */ 'embedded' AS second +-- +STMT: SelectStmt +== 003 +SELECT /* both embedded and trailing single line */ 'both' AS third +-- +STMT: SelectStmt +== 004 +-- trailing single line + +SELECT 'before multi-line' AS fourth +-- +STMT: SelectStmt +== 005 +/* This is an example of SQL which should not execute: + * select 'multi-line'; + */ +SELECT 'after multi-line' AS fifth +-- +STMT: SelectStmt +== 006 +|-- +-- Nested comments +|-- + +/* +SELECT 'trailing' as x1; -- inside block comment +*/ + +/* This block comment surrounds a query which itself has a block comment... +SELECT /* embedded single line */ 'embedded' AS x2; +*/ + +SELECT -- continued after the following block comments... +/* Deeply nested comment. + This includes a single apostrophe to make sure we aren't decoding this part as a string. +SELECT 'deep nest' AS n1; +/* Second level of nesting... +SELECT 'deeper nest' as n2; +/* Third level of nesting... +SELECT 'deepest nest' as n3; +*/ +Hoo boy. Still two deep... +*/ +Now just one deep... +*/ +'deeply nested example' AS sixth +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/compression.metadata.json b/parser/testdata/summary/postgres_regress/compression.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/compression.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/compression.test b/parser/testdata/summary/postgres_regress/compression.test new file mode 100644 index 0000000..931506a --- /dev/null +++ b/parser/testdata/summary/postgres_regress/compression.test @@ -0,0 +1,524 @@ +== 001 +-- ensure we get stable results regardless of installation's default +SET default_toast_compression = 'pglz' +-- +STMT: VariableSetStmt +== 002 +-- test creating table with compression method +CREATE TABLE cmdata(f1 text COMPRESSION pglz) +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DDL +STMT: CreateStmt +== 003 +CREATE INDEX idx ON cmdata(f1) +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DDL +STMT: IndexStmt +== 004 +INSERT INTO cmdata VALUES(repeat('1234567890', 1000)) +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 005 +CREATE TABLE cmdata1(f1 TEXT COMPRESSION lz4) +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=DDL +STMT: CreateStmt +== 006 +INSERT INTO cmdata1 VALUES(repeat('1234567890', 1004)) +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- verify stored compression method in the data +SELECT pg_column_compression(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 008 +SELECT pg_column_compression(f1) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- decompress data slice +SELECT SUBSTR(f1, 200, 5) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT SUBSTR(f1, 2000, 50) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +STMT: SelectStmt +== 011 +-- copy with table creation +SELECT * INTO cmmove1 FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +TABLE: name="cmmove1" schema="" table="cmmove1" ctx=DDL +STMT: SelectStmt +== 012 +SELECT pg_column_compression(f1) FROM cmmove1 +-- +TABLE: name="cmmove1" schema="" table="cmmove1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- copy to existing table +CREATE TABLE cmmove3(f1 text COMPRESSION pglz) +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=DDL +STMT: CreateStmt +== 014 +INSERT INTO cmmove3 SELECT * FROM cmdata +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=DML +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO cmmove3 SELECT * FROM cmdata1 +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=DML +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 016 +SELECT pg_column_compression(f1) FROM cmmove3 +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- test LIKE INCLUDING COMPRESSION +CREATE TABLE cmdata2 (LIKE cmdata1 INCLUDING COMPRESSION) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +== 018 +DROP TABLE cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: DropStmt +== 019 +-- try setting compression for incompressible data type +CREATE TABLE cmdata2 (f1 int COMPRESSION pglz) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +== 020 +-- update using datum from different table +CREATE TABLE cmmove2(f1 text COMPRESSION pglz) +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=DDL +STMT: CreateStmt +== 021 +INSERT INTO cmmove2 VALUES (repeat('1234567890', 1004)) +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 022 +SELECT pg_column_compression(f1) FROM cmmove2 +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 023 +UPDATE cmmove2 SET f1 = cmdata1.f1 FROM cmdata1 +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=DML +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +STMT: UpdateStmt +== 024 +SELECT pg_column_compression(f1) FROM cmmove2 +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 025 +-- test externally stored compressed data +CREATE OR REPLACE FUNCTION large_val() RETURNS TEXT LANGUAGE SQL AS +'select array_agg(fipshash(g::text))::text from generate_series(1, 256) g' +-- +FUNCTION: name="large_val" function="large_val" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 026 +CREATE TABLE cmdata2 (f1 text COMPRESSION pglz) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +== 027 +INSERT INTO cmdata2 SELECT large_val() || repeat('a', 4000) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DML +FUNCTION: name="large_val" function="large_val" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 028 +SELECT pg_column_compression(f1) FROM cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 029 +INSERT INTO cmdata1 SELECT large_val() || repeat('a', 4000) +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=DML +FUNCTION: name="large_val" function="large_val" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 030 +SELECT pg_column_compression(f1) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT SUBSTR(f1, 200, 5) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT SUBSTR(f1, 200, 5) FROM cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +STMT: SelectStmt +== 033 +DROP TABLE cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: DropStmt +== 034 +--test column type update varlena/non-varlena +CREATE TABLE cmdata2 (f1 int) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +== 035 +ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +== 036 +ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::integer +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +== 037 +--changing column storage should not impact the compression method +--but the data should not be compressed +ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +== 038 +ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION pglz +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +== 039 +ALTER TABLE cmdata2 ALTER COLUMN f1 SET STORAGE plain +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +== 040 +INSERT INTO cmdata2 VALUES (repeat('123456789', 800)) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 041 +SELECT pg_column_compression(f1) FROM cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 042 +-- test compression with materialized view +CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1 +-- +TABLE: name="compressmv" schema="" table="compressmv" ctx=DDL +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 043 +SELECT pg_column_compression(f1) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT pg_column_compression(x) FROM compressmv +-- +TABLE: name="compressmv" schema="" table="compressmv" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- test compression with partition +CREATE TABLE cmpart(f1 text COMPRESSION lz4) PARTITION BY HASH(f1) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DDL +STMT: CreateStmt +== 046 +CREATE TABLE cmpart1 PARTITION OF cmpart FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="cmpart1" schema="" table="cmpart1" ctx=DDL +STMT: CreateStmt +== 047 +CREATE TABLE cmpart2(f1 text COMPRESSION pglz) +-- +TABLE: name="cmpart2" schema="" table="cmpart2" ctx=DDL +STMT: CreateStmt +== 048 +ALTER TABLE cmpart ATTACH PARTITION cmpart2 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DDL +STMT: AlterTableStmt +== 049 +INSERT INTO cmpart VALUES (repeat('123456789', 1004)) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO cmpart VALUES (repeat('123456789', 4004)) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 051 +SELECT pg_column_compression(f1) FROM cmpart1 +-- +TABLE: name="cmpart1" schema="" table="cmpart1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 052 +SELECT pg_column_compression(f1) FROM cmpart2 +-- +TABLE: name="cmpart2" schema="" table="cmpart2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 053 +-- test compression with inheritance +CREATE TABLE cminh() INHERITS(cmdata, cmdata1) +-- +TABLE: name="cminh" schema="" table="cminh" ctx=DDL +STMT: CreateStmt +== 054 +-- error +CREATE TABLE cminh(f1 TEXT COMPRESSION lz4) INHERITS(cmdata) +-- +TABLE: name="cminh" schema="" table="cminh" ctx=DDL +STMT: CreateStmt +== 055 +-- error +CREATE TABLE cmdata3(f1 text) +-- +TABLE: name="cmdata3" schema="" table="cmdata3" ctx=DDL +STMT: CreateStmt +== 056 +CREATE TABLE cminh() INHERITS (cmdata, cmdata3) +-- +TABLE: name="cminh" schema="" table="cminh" ctx=DDL +STMT: CreateStmt +== 057 +-- test default_toast_compression GUC +SET default_toast_compression = '' +-- +STMT: VariableSetStmt +== 058 +SET default_toast_compression = 'I do not exist compression' +-- +STMT: VariableSetStmt +== 059 +SET default_toast_compression = 'lz4' +-- +STMT: VariableSetStmt +== 060 +SET default_toast_compression = 'pglz' +-- +STMT: VariableSetStmt +== 061 +-- test alter compression method +ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION lz4 +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DDL +STMT: AlterTableStmt +== 062 +INSERT INTO cmdata VALUES (repeat('123456789', 4004)) +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 063 +SELECT pg_column_compression(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 064 +ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION default +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +== 065 +-- test alter compression method for materialized views +ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4 +-- +TABLE: name="compressmv" schema="" table="compressmv" ctx=DDL +STMT: AlterTableStmt +== 066 +-- test alter compression method for partitioned tables +ALTER TABLE cmpart1 ALTER COLUMN f1 SET COMPRESSION pglz +-- +TABLE: name="cmpart1" schema="" table="cmpart1" ctx=DDL +STMT: AlterTableStmt +== 067 +ALTER TABLE cmpart2 ALTER COLUMN f1 SET COMPRESSION lz4 +-- +TABLE: name="cmpart2" schema="" table="cmpart2" ctx=DDL +STMT: AlterTableStmt +== 068 +-- new data should be compressed with the current compression method +INSERT INTO cmpart VALUES (repeat('123456789', 1004)) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 069 +INSERT INTO cmpart VALUES (repeat('123456789', 4004)) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 070 +SELECT pg_column_compression(f1) FROM cmpart1 +-- +TABLE: name="cmpart1" schema="" table="cmpart1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT pg_column_compression(f1) FROM cmpart2 +-- +TABLE: name="cmpart2" schema="" table="cmpart2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 072 +-- VACUUM FULL does not recompress +SELECT pg_column_compression(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 073 +VACUUM FULL cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DDL +STMT: VacuumStmt +== 074 +SELECT pg_column_compression(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +== 075 +-- test expression index +DROP TABLE cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: DropStmt +== 076 +CREATE TABLE cmdata2 (f1 TEXT COMPRESSION pglz, f2 TEXT COMPRESSION lz4) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +== 077 +CREATE UNIQUE INDEX idx1 ON cmdata2 ((f1 || f2)) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: IndexStmt +== 078 +INSERT INTO cmdata2 VALUES((SELECT array_agg(fipshash(g::TEXT))::TEXT FROM +generate_series(1, 50) g), VERSION()) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DML +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 079 +-- check data is ok +SELECT length(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 080 +SELECT length(f1) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 081 +SELECT length(f1) FROM cmmove1 +-- +TABLE: name="cmmove1" schema="" table="cmmove1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT length(f1) FROM cmmove2 +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT length(f1) FROM cmmove3 +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 084 +CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression) +-- +TABLE: name="badcompresstbl" schema="" table="badcompresstbl" ctx=DDL +STMT: CreateStmt +== 085 +-- fails +CREATE TABLE badcompresstbl (a text) +-- +TABLE: name="badcompresstbl" schema="" table="badcompresstbl" ctx=DDL +STMT: CreateStmt +== 086 +ALTER TABLE badcompresstbl ALTER a SET COMPRESSION I_Do_Not_Exist_Compression +-- +TABLE: name="badcompresstbl" schema="" table="badcompresstbl" ctx=DDL +STMT: AlterTableStmt +== 087 +-- fails +DROP TABLE badcompresstbl +-- +TABLE: name="badcompresstbl" schema="" table="badcompresstbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/constraints.metadata.json b/parser/testdata/summary/postgres_regress/constraints.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/constraints.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/constraints.test b/parser/testdata/summary/postgres_regress/constraints.test new file mode 100644 index 0000000..f82197b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/constraints.test @@ -0,0 +1,1887 @@ +== 001 +|-- +-- CONSTRAINTS +-- Constraints can be specified with: +-- - DEFAULT clause +-- - CHECK clauses +-- - PRIMARY KEY clauses +-- - UNIQUE clauses +-- - EXCLUDE clauses +|-- + +-- directory paths are passed to us in environment variables + +|-- +-- DEFAULT syntax +|-- + +CREATE TABLE DEFAULT_TBL (i int DEFAULT 100, + x text DEFAULT 'vadim', f float8 DEFAULT 123.456) +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO DEFAULT_TBL VALUES (1, 'thomas', 57.0613) +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO DEFAULT_TBL VALUES (1, 'bruce') +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO DEFAULT_TBL (i, f) VALUES (2, 987.654) +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO DEFAULT_TBL (x) VALUES ('marc') +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO DEFAULT_TBL VALUES (3, null, 1.0) +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +SELECT * FROM DEFAULT_TBL +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=Select +STMT: SelectStmt +== 008 +CREATE SEQUENCE DEFAULT_SEQ +-- +STMT: CreateSeqStmt +== 009 +CREATE TABLE DEFAULTEXPR_TBL (i1 int DEFAULT 100 + (200-199) * 2, + i2 int DEFAULT nextval('default_seq')) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DDL +STMT: CreateStmt +== 010 +INSERT INTO DEFAULTEXPR_TBL VALUES (-1, -2) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO DEFAULTEXPR_TBL (i1) VALUES (-3) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO DEFAULTEXPR_TBL (i2) VALUES (-4) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO DEFAULTEXPR_TBL (i2) VALUES (NULL) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +SELECT * FROM DEFAULTEXPR_TBL +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=Select +STMT: SelectStmt +== 015 +-- syntax errors +-- test for extraneous comma +CREATE TABLE error_tbl (i int DEFAULT (100, )) +-- +ERROR: syntax error at or near ")" +CURSORPOS: 92 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 016 +-- this will fail because gram.y uses b_expr not a_expr for defaults, +-- to avoid a shift/reduce conflict that arises from NOT NULL being +-- part of the column definition syntax: +CREATE TABLE error_tbl (b1 bool DEFAULT 1 IN (1, 2)) +-- +ERROR: syntax error at or near "IN" +CURSORPOS: 225 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 017 +-- this should work, however: +CREATE TABLE error_tbl (b1 bool DEFAULT (1 IN (1, 2))) +-- +TABLE: name="error_tbl" schema="" table="error_tbl" ctx=DDL +STMT: CreateStmt +== 018 +DROP TABLE error_tbl +-- +TABLE: name="error_tbl" schema="" table="error_tbl" ctx=DDL +STMT: DropStmt +== 019 +|-- +-- CHECK syntax +|-- + +CREATE TABLE CHECK_TBL (x int, + CONSTRAINT CHECK_CON CHECK (x > 3)) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DDL +STMT: CreateStmt +== 020 +INSERT INTO CHECK_TBL VALUES (5) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO CHECK_TBL VALUES (4) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO CHECK_TBL VALUES (3) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO CHECK_TBL VALUES (2) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO CHECK_TBL VALUES (6) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO CHECK_TBL VALUES (1) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +SELECT * FROM CHECK_TBL +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=Select +STMT: SelectStmt +== 027 +CREATE SEQUENCE CHECK_SEQ +-- +STMT: CreateSeqStmt +== 028 +CREATE TABLE CHECK2_TBL (x int, y text, z int, + CONSTRAINT SEQUENCE_CON + CHECK (x > 3 and y <> 'check failed' and z < 8)) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DDL +STMT: CreateStmt +== 029 +INSERT INTO CHECK2_TBL VALUES (4, 'check ok', -2) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO CHECK2_TBL VALUES (1, 'x check failed', -2) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO CHECK2_TBL VALUES (5, 'z check failed', 10) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO CHECK2_TBL VALUES (0, 'check failed', -2) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO CHECK2_TBL VALUES (6, 'check failed', 11) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO CHECK2_TBL VALUES (7, 'check ok', 7) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +SELECT * from CHECK2_TBL +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=Select +STMT: SelectStmt +== 036 +|-- +-- Check constraints on INSERT +|-- + +CREATE SEQUENCE INSERT_SEQ +-- +STMT: CreateSeqStmt +== 037 +CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'), + y TEXT DEFAULT '-NULL-', + z INT DEFAULT -1 * currval('insert_seq'), + CONSTRAINT INSERT_TBL_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8), + CHECK (x + z = 0)) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DDL +STMT: CreateStmt +== 038 +INSERT INTO INSERT_TBL(x,z) VALUES (2, -2) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +== 040 +SELECT 'one' AS one, nextval('insert_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 041 +INSERT INTO INSERT_TBL(y) VALUES ('Y') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO INSERT_TBL(y) VALUES ('Y') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO INSERT_TBL(x,z) VALUES (1, -2) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO INSERT_TBL(z,x) VALUES (-7, 7) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO INSERT_TBL VALUES (5, 'check failed', -5) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO INSERT_TBL VALUES (7, '!check failed', -7) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +== 049 +INSERT INTO INSERT_TBL(y,z) VALUES ('check failed', 4) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO INSERT_TBL(x,y) VALUES (5, 'check failed') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +INSERT INTO INSERT_TBL(x,y) VALUES (5, '!check failed') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +== 054 +SELECT 'seven' AS one, nextval('insert_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 055 +INSERT INTO INSERT_TBL(y) VALUES ('Y') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +SELECT 'eight' AS one, currval('insert_seq') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 057 +-- According to SQL, it is OK to insert a record that gives rise to NULL +-- constraint-condition results. Postgres used to reject this, but it +-- was wrong: +INSERT INTO INSERT_TBL VALUES (null, null, null) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +== 059 +|-- +-- Check constraints on system columns +|-- + +CREATE TABLE SYS_COL_CHECK_TBL (city text, state text, is_capital bool, + altitude int, + CHECK (NOT (is_capital AND tableoid::regclass::text = 'sys_col_check_tbl'))) +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DDL +STMT: CreateStmt +== 060 +INSERT INTO SYS_COL_CHECK_TBL VALUES ('Seattle', 'Washington', false, 100) +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +INSERT INTO SYS_COL_CHECK_TBL VALUES ('Olympia', 'Washington', true, 100) +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +SELECT *, tableoid::regclass::text FROM SYS_COL_CHECK_TBL +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=Select +STMT: SelectStmt +== 063 +DROP TABLE SYS_COL_CHECK_TBL +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DDL +STMT: DropStmt +== 064 +|-- +-- Check constraints on system columns other then TableOid should return error +|-- +CREATE TABLE SYS_COL_CHECK_TBL (city text, state text, is_capital bool, + altitude int, + CHECK (NOT (is_capital AND ctid::text = 'sys_col_check_tbl'))) +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DDL +STMT: CreateStmt +== 065 +|-- +-- Check inheritance of defaults and constraints +|-- + +CREATE TABLE INSERT_CHILD (cx INT default 42, + cy INT CHECK (cy > x)) + INHERITS (INSERT_TBL) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DDL +STMT: CreateStmt +== 066 +INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,11) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,6) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 068 +INSERT INTO INSERT_CHILD(x,z,cy) VALUES (6,-7,7) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 069 +INSERT INTO INSERT_CHILD(x,y,z,cy) VALUES (6,'check failed',-6,7) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +SELECT * FROM INSERT_CHILD +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=Select +STMT: SelectStmt +== 071 +DROP TABLE INSERT_CHILD +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DDL +STMT: DropStmt +== 072 +|-- +-- Check NO INHERIT type of constraints and inheritance +|-- + +CREATE TABLE ATACC1 (TEST INT + CHECK (TEST > 0) NO INHERIT) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 073 +CREATE TABLE ATACC2 (TEST2 INT) INHERITS (ATACC1) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +== 074 +-- check constraint is not there on child +INSERT INTO ATACC2 (TEST) VALUES (-3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +-- check constraint is there on parent +INSERT INTO ATACC1 (TEST) VALUES (-3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 076 +DROP TABLE ATACC1 CASCADE +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 077 +CREATE TABLE ATACC1 (TEST INT, TEST2 INT + CHECK (TEST > 0), CHECK (TEST2 > 10) NO INHERIT) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +== 078 +CREATE TABLE ATACC2 () INHERITS (ATACC1) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +== 079 +-- check constraint is there on child +INSERT INTO ATACC2 (TEST) VALUES (-3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +-- check constraint is there on parent +INSERT INTO ATACC1 (TEST) VALUES (-3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +-- check constraint is not there on child +INSERT INTO ATACC2 (TEST2) VALUES (3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 082 +-- check constraint is there on parent +INSERT INTO ATACC1 (TEST2) VALUES (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 083 +DROP TABLE ATACC1 CASCADE +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +== 084 +|-- +-- Check constraints on INSERT INTO +|-- + +DELETE FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: DeleteStmt +== 085 +ALTER SEQUENCE INSERT_SEQ RESTART WITH 4 +-- +STMT: AlterSeqStmt +== 086 +CREATE TEMP TABLE tmp (xd INT, yd TEXT, zd INT) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: CreateStmt +== 087 +INSERT INTO tmp VALUES (null, 'Y', null) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +INSERT INTO tmp VALUES (5, '!check failed', null) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +INSERT INTO tmp VALUES (null, 'try again', null) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 090 +INSERT INTO INSERT_TBL(y) select yd from tmp +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +TABLE: name="tmp" schema="" table="tmp" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 091 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +== 092 +INSERT INTO INSERT_TBL SELECT * FROM tmp WHERE yd = 'try again' +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +TABLE: name="tmp" schema="" table="tmp" ctx=Select +FILTER: schema="" table="" column="yd" +STMT: InsertStmt +STMT: SelectStmt +== 093 +INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM tmp WHERE yd = 'try again' +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +TABLE: name="tmp" schema="" table="tmp" ctx=Select +FILTER: schema="" table="" column="yd" +STMT: InsertStmt +STMT: SelectStmt +== 094 +INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM tmp WHERE yd = 'try again' +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +TABLE: name="tmp" schema="" table="tmp" ctx=Select +FILTER: schema="" table="" column="yd" +STMT: InsertStmt +STMT: SelectStmt +== 095 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +== 096 +DROP TABLE tmp +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: DropStmt +== 097 +|-- +-- Check constraints on UPDATE +|-- + +UPDATE INSERT_TBL SET x = NULL WHERE x = 5 +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: UpdateStmt +== 098 +UPDATE INSERT_TBL SET x = 6 WHERE x = 6 +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: UpdateStmt +== 099 +UPDATE INSERT_TBL SET x = -z, z = -x +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: UpdateStmt +== 100 +UPDATE INSERT_TBL SET x = z, z = x +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: UpdateStmt +== 101 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +== 102 +-- DROP TABLE INSERT_TBL; + +|-- +-- Check constraints on COPY FROM +|-- + +CREATE TABLE COPY_TBL (x INT, y TEXT, z INT, + CONSTRAINT COPY_CON + CHECK (x > 3 AND y <> 'check failed' AND x < 7 )) +-- +TABLE: name="copy_tbl" schema="" table="copy_tbl" ctx=DDL +STMT: CreateStmt +== 103 +COPY COPY_TBL FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 104 +SELECT * FROM COPY_TBL +-- +TABLE: name="copy_tbl" schema="" table="copy_tbl" ctx=Select +STMT: SelectStmt +== 105 +COPY COPY_TBL FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 106 +SELECT * FROM COPY_TBL +-- +TABLE: name="copy_tbl" schema="" table="copy_tbl" ctx=Select +STMT: SelectStmt +== 107 +|-- +-- Primary keys +|-- + +CREATE TABLE PRIMARY_TBL (i int PRIMARY KEY, t text) +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DDL +STMT: CreateStmt +== 108 +INSERT INTO PRIMARY_TBL VALUES (1, 'one') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +INSERT INTO PRIMARY_TBL VALUES (2, 'two') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +INSERT INTO PRIMARY_TBL VALUES (1, 'three') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +INSERT INTO PRIMARY_TBL VALUES (4, 'three') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 112 +INSERT INTO PRIMARY_TBL VALUES (5, 'one') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 113 +INSERT INTO PRIMARY_TBL (t) VALUES ('six') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 114 +SELECT * FROM PRIMARY_TBL +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=Select +STMT: SelectStmt +== 115 +DROP TABLE PRIMARY_TBL +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DDL +STMT: DropStmt +== 116 +CREATE TABLE PRIMARY_TBL (i int, t text, + PRIMARY KEY(i,t)) +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DDL +STMT: CreateStmt +== 117 +INSERT INTO PRIMARY_TBL VALUES (1, 'one') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 118 +INSERT INTO PRIMARY_TBL VALUES (2, 'two') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 119 +INSERT INTO PRIMARY_TBL VALUES (1, 'three') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 120 +INSERT INTO PRIMARY_TBL VALUES (4, 'three') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +INSERT INTO PRIMARY_TBL VALUES (5, 'one') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +INSERT INTO PRIMARY_TBL (t) VALUES ('six') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +SELECT * FROM PRIMARY_TBL +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=Select +STMT: SelectStmt +== 124 +DROP TABLE PRIMARY_TBL +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DDL +STMT: DropStmt +== 125 +|-- +-- Unique keys +|-- + +CREATE TABLE UNIQUE_TBL (i int UNIQUE, t text) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +== 126 +INSERT INTO UNIQUE_TBL VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 127 +INSERT INTO UNIQUE_TBL VALUES (2, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 128 +INSERT INTO UNIQUE_TBL VALUES (1, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +INSERT INTO UNIQUE_TBL VALUES (4, 'four') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 130 +INSERT INTO UNIQUE_TBL VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 131 +INSERT INTO UNIQUE_TBL (t) VALUES ('six') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 132 +INSERT INTO UNIQUE_TBL (t) VALUES ('seven') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 133 +INSERT INTO UNIQUE_TBL VALUES (5, 'five-upsert-insert') ON CONFLICT (i) DO UPDATE SET t = 'five-upsert-update' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 134 +INSERT INTO UNIQUE_TBL VALUES (6, 'six-upsert-insert') ON CONFLICT (i) DO UPDATE SET t = 'six-upsert-update' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 135 +-- should fail +INSERT INTO UNIQUE_TBL VALUES (1, 'a'), (2, 'b'), (2, 'b') ON CONFLICT (i) DO UPDATE SET t = 'fails' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +SELECT * FROM UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 137 +DROP TABLE UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +== 138 +CREATE TABLE UNIQUE_TBL (i int UNIQUE NULLS NOT DISTINCT, t text) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +== 139 +INSERT INTO UNIQUE_TBL VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 140 +INSERT INTO UNIQUE_TBL VALUES (2, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 141 +INSERT INTO UNIQUE_TBL VALUES (1, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +-- fail +INSERT INTO UNIQUE_TBL VALUES (4, 'four') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +INSERT INTO UNIQUE_TBL VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +INSERT INTO UNIQUE_TBL (t) VALUES ('six') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 145 +INSERT INTO UNIQUE_TBL (t) VALUES ('seven') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +-- fail +INSERT INTO UNIQUE_TBL (t) VALUES ('eight') ON CONFLICT DO NOTHING +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +-- no-op + +SELECT * FROM UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 148 +DROP TABLE UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +== 149 +CREATE TABLE UNIQUE_TBL (i int, t text, + UNIQUE(i,t)) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +== 150 +INSERT INTO UNIQUE_TBL VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 151 +INSERT INTO UNIQUE_TBL VALUES (2, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +INSERT INTO UNIQUE_TBL VALUES (1, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 153 +INSERT INTO UNIQUE_TBL VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 154 +INSERT INTO UNIQUE_TBL VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +INSERT INTO UNIQUE_TBL (t) VALUES ('six') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 156 +SELECT * FROM UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 157 +DROP TABLE UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +== 158 +|-- +-- Deferrable unique constraints +|-- + +CREATE TABLE unique_tbl (i int UNIQUE DEFERRABLE, t text) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +== 159 +INSERT INTO unique_tbl VALUES (0, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 160 +INSERT INTO unique_tbl VALUES (1, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 161 +INSERT INTO unique_tbl VALUES (2, 'tree') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 162 +INSERT INTO unique_tbl VALUES (3, 'four') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 163 +INSERT INTO unique_tbl VALUES (4, 'five') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +BEGIN +-- +STMT: TransactionStmt +== 165 +-- default is immediate so this should fail right away +UPDATE unique_tbl SET i = 1 WHERE i = 0 +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +== 166 +ROLLBACK +-- +STMT: TransactionStmt +== 167 +-- check is done at end of statement, so this should succeed +UPDATE unique_tbl SET i = i+1 +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +== 168 +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 169 +-- explicitly defer the constraint +BEGIN +-- +STMT: TransactionStmt +== 170 +SET CONSTRAINTS unique_tbl_i_key DEFERRED +-- +STMT: ConstraintsSetStmt +== 171 +INSERT INTO unique_tbl VALUES (3, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 172 +DELETE FROM unique_tbl WHERE t = 'tree' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +== 173 +-- makes constraint valid again + +COMMIT +-- +STMT: TransactionStmt +== 174 +-- should succeed + +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 175 +-- try adding an initially deferred constraint +ALTER TABLE unique_tbl DROP CONSTRAINT unique_tbl_i_key +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: AlterTableStmt +== 176 +ALTER TABLE unique_tbl ADD CONSTRAINT unique_tbl_i_key + UNIQUE (i) DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: AlterTableStmt +== 177 +BEGIN +-- +STMT: TransactionStmt +== 178 +INSERT INTO unique_tbl VALUES (1, 'five') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 179 +INSERT INTO unique_tbl VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 180 +UPDATE unique_tbl SET i = 4 WHERE i = 2 +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +== 181 +UPDATE unique_tbl SET i = 2 WHERE i = 4 AND t = 'four' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +== 182 +DELETE FROM unique_tbl WHERE i = 1 AND t = 'one' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +== 183 +DELETE FROM unique_tbl WHERE i = 5 AND t = 'five' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +== 184 +COMMIT +-- +STMT: TransactionStmt +== 185 +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 186 +-- should fail at commit-time +BEGIN +-- +STMT: TransactionStmt +== 187 +INSERT INTO unique_tbl VALUES (3, 'Three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +-- should succeed for now +COMMIT +-- +STMT: TransactionStmt +== 189 +-- should fail + +-- make constraint check immediate +BEGIN +-- +STMT: TransactionStmt +== 190 +SET CONSTRAINTS ALL IMMEDIATE +-- +STMT: ConstraintsSetStmt +== 191 +INSERT INTO unique_tbl VALUES (3, 'Three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 192 +-- should fail + +COMMIT +-- +STMT: TransactionStmt +== 193 +-- forced check when SET CONSTRAINTS is called +BEGIN +-- +STMT: TransactionStmt +== 194 +SET CONSTRAINTS ALL DEFERRED +-- +STMT: ConstraintsSetStmt +== 195 +INSERT INTO unique_tbl VALUES (3, 'Three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +-- should succeed for now + +SET CONSTRAINTS ALL IMMEDIATE +-- +STMT: ConstraintsSetStmt +== 197 +-- should fail + +COMMIT +-- +STMT: TransactionStmt +== 198 +-- test deferrable UNIQUE with a partitioned table +CREATE TABLE parted_uniq_tbl (i int UNIQUE DEFERRABLE) partition by range (i) +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DDL +STMT: CreateStmt +== 199 +CREATE TABLE parted_uniq_tbl_1 PARTITION OF parted_uniq_tbl FOR VALUES FROM (0) TO (10) +-- +TABLE: name="parted_uniq_tbl_1" schema="" table="parted_uniq_tbl_1" ctx=DDL +STMT: CreateStmt +== 200 +CREATE TABLE parted_uniq_tbl_2 PARTITION OF parted_uniq_tbl FOR VALUES FROM (20) TO (30) +-- +TABLE: name="parted_uniq_tbl_2" schema="" table="parted_uniq_tbl_2" ctx=DDL +STMT: CreateStmt +== 201 +SELECT conname, conrelid::regclass FROM pg_constraint + WHERE conname LIKE 'parted_uniq%' ORDER BY conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 202 +BEGIN +-- +STMT: TransactionStmt +== 203 +INSERT INTO parted_uniq_tbl VALUES (1) +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 204 +SAVEPOINT f +-- +STMT: TransactionStmt +== 205 +INSERT INTO parted_uniq_tbl VALUES (1) +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 206 +-- unique violation +ROLLBACK TO f +-- +STMT: TransactionStmt +== 207 +SET CONSTRAINTS parted_uniq_tbl_i_key DEFERRED +-- +STMT: ConstraintsSetStmt +== 208 +INSERT INTO parted_uniq_tbl VALUES (1) +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 209 +-- OK now, fail at commit +COMMIT +-- +STMT: TransactionStmt +== 210 +DROP TABLE parted_uniq_tbl +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DDL +STMT: DropStmt +== 211 +-- test naming a constraint in a partition when a conflict exists +CREATE TABLE parted_fk_naming ( + id bigint NOT NULL default 1, + id_abc bigint, + CONSTRAINT dummy_constr FOREIGN KEY (id_abc) + REFERENCES parted_fk_naming (id), + PRIMARY KEY (id) +) +PARTITION BY LIST (id) +-- +TABLE: name="parted_fk_naming" schema="" table="parted_fk_naming" ctx=DDL +STMT: CreateStmt +== 212 +CREATE TABLE parted_fk_naming_1 ( + id bigint NOT NULL default 1, + id_abc bigint, + PRIMARY KEY (id), + CONSTRAINT dummy_constr CHECK (true) +) +-- +TABLE: name="parted_fk_naming_1" schema="" table="parted_fk_naming_1" ctx=DDL +STMT: CreateStmt +== 213 +ALTER TABLE parted_fk_naming ATTACH PARTITION parted_fk_naming_1 FOR VALUES IN ('1') +-- +TABLE: name="parted_fk_naming" schema="" table="parted_fk_naming" ctx=DDL +STMT: AlterTableStmt +== 214 +SELECT conname FROM pg_constraint WHERE conrelid = 'parted_fk_naming_1'::regclass AND contype = 'f' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +FILTER: schema="" table="" column="contype" +STMT: SelectStmt +== 215 +DROP TABLE parted_fk_naming +-- +TABLE: name="parted_fk_naming" schema="" table="parted_fk_naming" ctx=DDL +STMT: DropStmt +== 216 +|-- +-- Test various ways to create primary keys on partitions, linked to unique +-- indexes (without constraints) on the partitioned table. Ideally these should +-- fail, but we don't dare change released behavior, so instead cope with it at +-- DETACH time. +CREATE TEMP TABLE t (a integer, b integer) PARTITION BY HASH (a, b) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 217 +CREATE TEMP TABLE tp (a integer, b integer, PRIMARY KEY (a, b), UNIQUE (b, a)) +-- +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: CreateStmt +== 218 +ALTER TABLE t ATTACH PARTITION tp FOR VALUES WITH (MODULUS 1, REMAINDER 0) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 219 +CREATE UNIQUE INDEX t_a_idx ON t (a, b) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +== 220 +CREATE UNIQUE INDEX t_b_idx ON t (b, a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +== 221 +ALTER INDEX t_a_idx ATTACH PARTITION tp_pkey +-- +STMT: AlterTableStmt +== 222 +ALTER INDEX t_b_idx ATTACH PARTITION tp_b_a_key +-- +STMT: AlterTableStmt +== 223 +SELECT conname, conparentid, conislocal, coninhcount + FROM pg_constraint WHERE conname IN ('tp_pkey', 'tp_b_a_key') + ORDER BY conname DESC +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 224 +ALTER TABLE t DETACH PARTITION tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 225 +DROP TABLE t, tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: DropStmt +== 226 +CREATE TEMP TABLE t (a integer) PARTITION BY LIST (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 227 +CREATE TEMP TABLE tp (a integer PRIMARY KEY) +-- +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: CreateStmt +== 228 +CREATE UNIQUE INDEX t_a_idx ON t (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +== 229 +ALTER TABLE t ATTACH PARTITION tp FOR VALUES IN (1) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 230 +ALTER TABLE t DETACH PARTITION tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 231 +DROP TABLE t, tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: DropStmt +== 232 +CREATE TEMP TABLE t (a integer) PARTITION BY LIST (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 233 +CREATE TEMP TABLE tp (a integer PRIMARY KEY) +-- +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: CreateStmt +== 234 +CREATE UNIQUE INDEX t_a_idx ON ONLY t (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +== 235 +ALTER TABLE t ATTACH PARTITION tp FOR VALUES IN (1) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 236 +ALTER TABLE t DETACH PARTITION tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 237 +DROP TABLE t, tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: DropStmt +== 238 +CREATE TABLE regress_constr_partitioned (a integer) PARTITION BY LIST (a) +-- +TABLE: name="regress_constr_partitioned" schema="" table="regress_constr_partitioned" ctx=DDL +STMT: CreateStmt +== 239 +CREATE TABLE regress_constr_partition1 PARTITION OF regress_constr_partitioned FOR VALUES IN (1) +-- +TABLE: name="regress_constr_partition1" schema="" table="regress_constr_partition1" ctx=DDL +STMT: CreateStmt +== 240 +ALTER TABLE regress_constr_partition1 ADD PRIMARY KEY (a) +-- +TABLE: name="regress_constr_partition1" schema="" table="regress_constr_partition1" ctx=DDL +STMT: AlterTableStmt +== 241 +CREATE UNIQUE INDEX ON regress_constr_partitioned (a) +-- +TABLE: name="regress_constr_partitioned" schema="" table="regress_constr_partitioned" ctx=DDL +STMT: IndexStmt +== 242 +BEGIN +-- +STMT: TransactionStmt +== 243 +ALTER TABLE regress_constr_partitioned DETACH PARTITION regress_constr_partition1 +-- +TABLE: name="regress_constr_partitioned" schema="" table="regress_constr_partitioned" ctx=DDL +STMT: AlterTableStmt +== 244 +ROLLBACK +-- +STMT: TransactionStmt +== 245 +-- Leave this one in funny state for pg_upgrade testing + +-- test a HOT update that invalidates the conflicting tuple. +-- the trigger should still fire and catch the violation + +BEGIN +-- +STMT: TransactionStmt +== 246 +INSERT INTO unique_tbl VALUES (3, 'Three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 247 +-- should succeed for now +UPDATE unique_tbl SET t = 'THREE' WHERE i = 3 AND t = 'Three' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +== 248 +COMMIT +-- +STMT: TransactionStmt +== 249 +-- should fail + +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 250 +-- test a HOT update that modifies the newly inserted tuple, +-- but should succeed because we then remove the other conflicting tuple. + +BEGIN +-- +STMT: TransactionStmt +== 251 +INSERT INTO unique_tbl VALUES(3, 'tree') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 252 +-- should succeed for now +UPDATE unique_tbl SET t = 'threex' WHERE t = 'tree' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +== 253 +DELETE FROM unique_tbl WHERE t = 'three' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +== 254 +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 255 +COMMIT +-- +STMT: TransactionStmt +== 256 +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +== 257 +DROP TABLE unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +== 258 +|-- +-- EXCLUDE constraints +|-- + +CREATE TABLE circles ( + c1 CIRCLE, + c2 TEXT, + EXCLUDE USING gist + (c1 WITH &&, (c2::circle) WITH &&) + WHERE (circle_center(c1) <> '(0,0)') +) +-- +TABLE: name="circles" schema="" table="circles" ctx=DDL +STMT: CreateStmt +== 259 +-- these should succeed because they don't match the index predicate +INSERT INTO circles VALUES('<(0,0), 5>', '<(0,0), 5>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 260 +INSERT INTO circles VALUES('<(0,0), 5>', '<(0,0), 4>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 261 +-- succeed +INSERT INTO circles VALUES('<(10,10), 10>', '<(0,0), 5>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 262 +-- fail, overlaps +INSERT INTO circles VALUES('<(20,20), 10>', '<(0,0), 4>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 263 +-- succeed, because violation is ignored +INSERT INTO circles VALUES('<(20,20), 10>', '<(0,0), 4>') + ON CONFLICT ON CONSTRAINT circles_c1_c2_excl DO NOTHING +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 264 +-- fail, because DO UPDATE variant requires unique index +INSERT INTO circles VALUES('<(20,20), 10>', '<(0,0), 4>') + ON CONFLICT ON CONSTRAINT circles_c1_c2_excl DO UPDATE SET c2 = EXCLUDED.c2 +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 265 +-- succeed because c1 doesn't overlap +INSERT INTO circles VALUES('<(20,20), 1>', '<(0,0), 5>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 266 +-- succeed because c2 doesn't overlap +INSERT INTO circles VALUES('<(20,20), 10>', '<(10,10), 5>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 267 +-- should fail on existing data without the WHERE clause +ALTER TABLE circles ADD EXCLUDE USING gist + (c1 WITH &&, (c2::circle) WITH &&) +-- +TABLE: name="circles" schema="" table="circles" ctx=DDL +STMT: AlterTableStmt +== 268 +-- try reindexing an existing constraint +REINDEX INDEX circles_c1_c2_excl +-- +STMT: ReindexStmt +== 269 +DROP TABLE circles +-- +TABLE: name="circles" schema="" table="circles" ctx=DDL +STMT: DropStmt +== 270 +-- Check deferred exclusion constraint + +CREATE TABLE deferred_excl ( + f1 int, + f2 int, + CONSTRAINT deferred_excl_con EXCLUDE (f1 WITH =) INITIALLY DEFERRED +) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DDL +STMT: CreateStmt +== 271 +INSERT INTO deferred_excl VALUES(1) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 272 +INSERT INTO deferred_excl VALUES(2) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 273 +INSERT INTO deferred_excl VALUES(1) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 274 +-- fail +INSERT INTO deferred_excl VALUES(1) ON CONFLICT ON CONSTRAINT deferred_excl_con DO NOTHING +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 275 +-- fail +BEGIN +-- +STMT: TransactionStmt +== 276 +INSERT INTO deferred_excl VALUES(2) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 277 +-- no fail here +COMMIT +-- +STMT: TransactionStmt +== 278 +-- should fail here +BEGIN +-- +STMT: TransactionStmt +== 279 +INSERT INTO deferred_excl VALUES(3) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 280 +INSERT INTO deferred_excl VALUES(3) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 281 +-- no fail here +COMMIT +-- +STMT: TransactionStmt +== 282 +-- should fail here + +-- bug #13148: deferred constraint versus HOT update +BEGIN +-- +STMT: TransactionStmt +== 283 +INSERT INTO deferred_excl VALUES(2, 1) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 284 +-- no fail here +DELETE FROM deferred_excl WHERE f1 = 2 AND f2 IS NULL +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: DeleteStmt +== 285 +-- remove old row +UPDATE deferred_excl SET f2 = 2 WHERE f1 = 2 +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: UpdateStmt +== 286 +COMMIT +-- +STMT: TransactionStmt +== 287 +-- should not fail + +SELECT * FROM deferred_excl +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=Select +STMT: SelectStmt +== 288 +ALTER TABLE deferred_excl DROP CONSTRAINT deferred_excl_con +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DDL +STMT: AlterTableStmt +== 289 +-- This should fail, but worth testing because of HOT updates +UPDATE deferred_excl SET f1 = 3 +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: UpdateStmt +== 290 +ALTER TABLE deferred_excl ADD EXCLUDE (f1 WITH =) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DDL +STMT: AlterTableStmt +== 291 +DROP TABLE deferred_excl +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DDL +STMT: DropStmt +== 292 +-- Comments +-- Setup a low-level role to enforce non-superuser checks. +CREATE ROLE regress_constraint_comments +-- +STMT: CreateRoleStmt +== 293 +SET SESSION AUTHORIZATION regress_constraint_comments +-- +STMT: VariableSetStmt +== 294 +CREATE TABLE constraint_comments_tbl (a int CONSTRAINT the_constraint CHECK (a > 0)) +-- +TABLE: name="constraint_comments_tbl" schema="" table="constraint_comments_tbl" ctx=DDL +STMT: CreateStmt +== 295 +CREATE DOMAIN constraint_comments_dom AS int CONSTRAINT the_constraint CHECK (value > 0) +-- +STMT: CreateDomainStmt +== 296 +COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS 'yes, the comment' +-- +STMT: CommentStmt +== 297 +COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS 'yes, another comment' +-- +STMT: CommentStmt +== 298 +-- no such constraint +COMMENT ON CONSTRAINT no_constraint ON constraint_comments_tbl IS 'yes, the comment' +-- +STMT: CommentStmt +== 299 +COMMENT ON CONSTRAINT no_constraint ON DOMAIN constraint_comments_dom IS 'yes, another comment' +-- +STMT: CommentStmt +== 300 +-- no such table/domain +COMMENT ON CONSTRAINT the_constraint ON no_comments_tbl IS 'bad comment' +-- +STMT: CommentStmt +== 301 +COMMENT ON CONSTRAINT the_constraint ON DOMAIN no_comments_dom IS 'another bad comment' +-- +STMT: CommentStmt +== 302 +COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS NULL +-- +STMT: CommentStmt +== 303 +COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS NULL +-- +STMT: CommentStmt +== 304 +-- unauthorized user +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 305 +CREATE ROLE regress_constraint_comments_noaccess +-- +STMT: CreateRoleStmt +== 306 +SET SESSION AUTHORIZATION regress_constraint_comments_noaccess +-- +STMT: VariableSetStmt +== 307 +COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS 'no, the comment' +-- +STMT: CommentStmt +== 308 +COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS 'no, another comment' +-- +STMT: CommentStmt +== 309 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 310 +DROP TABLE constraint_comments_tbl +-- +TABLE: name="constraint_comments_tbl" schema="" table="constraint_comments_tbl" ctx=DDL +STMT: DropStmt +== 311 +DROP DOMAIN constraint_comments_dom +-- +STMT: DropStmt +== 312 +DROP ROLE regress_constraint_comments +-- +STMT: DropRoleStmt +== 313 +DROP ROLE regress_constraint_comments_noaccess +-- +STMT: DropRoleStmt +== 314 +-- Leave some constraints for the pg_upgrade test to pick up +CREATE DOMAIN constraint_comments_dom AS int +-- +STMT: CreateDomainStmt +== 315 +ALTER DOMAIN constraint_comments_dom ADD CONSTRAINT inv_ck CHECK (value > 0) NOT VALID +-- +STMT: AlterDomainStmt +== 316 +COMMENT ON CONSTRAINT inv_ck ON DOMAIN constraint_comments_dom IS 'comment on invalid constraint' +-- +STMT: CommentStmt +== 317 +-- Create a table that exercises pg_upgrade +CREATE TABLE regress_notnull1 (a integer) +-- +TABLE: name="regress_notnull1" schema="" table="regress_notnull1" ctx=DDL +STMT: CreateStmt +== 318 +CREATE TABLE regress_notnull2 () INHERITS (regress_notnull1) +-- +TABLE: name="regress_notnull2" schema="" table="regress_notnull2" ctx=DDL +STMT: CreateStmt +== 319 +ALTER TABLE ONLY regress_notnull2 ALTER COLUMN a SET NOT NULL +-- +TABLE: name="regress_notnull2" schema="" table="regress_notnull2" ctx=DDL +STMT: AlterTableStmt diff --git a/parser/testdata/summary/postgres_regress/conversion.metadata.json b/parser/testdata/summary/postgres_regress/conversion.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/conversion.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/conversion.test b/parser/testdata/summary/postgres_regress/conversion.test new file mode 100644 index 0000000..6e44b8f --- /dev/null +++ b/parser/testdata/summary/postgres_regress/conversion.test @@ -0,0 +1,677 @@ +== 001 +|-- +-- create user defined conversion +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION test_enc_setup() RETURNS void + AS :'regresslib', 'test_enc_setup' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 171 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +SELECT FROM test_enc_setup() +-- +FUNCTION: name="test_enc_setup" function="test_enc_setup" schema="" ctx=Call +STMT: SelectStmt +== 003 +CREATE FUNCTION test_enc_conversion(bytea, name, name, bool, validlen OUT int, result OUT bytea) + AS :'regresslib', 'test_enc_conversion' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 105 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +CREATE USER regress_conversion_user WITH NOCREATEDB NOCREATEROLE +-- +STMT: CreateRoleStmt +== 005 +SET SESSION AUTHORIZATION regress_conversion_user +-- +STMT: VariableSetStmt +== 006 +CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 007 +|-- +-- cannot make same name conversion in same schema +|-- +CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 008 +|-- +-- create default conversion with qualified name +|-- +CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 009 +|-- +-- cannot make default conversion with same schema/for_encoding/to_encoding +|-- +CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 010 +-- test comments +COMMENT ON CONVERSION myconv_bad IS 'foo' +-- +STMT: CommentStmt +== 011 +COMMENT ON CONVERSION myconv IS 'bar' +-- +STMT: CommentStmt +== 012 +COMMENT ON CONVERSION myconv IS NULL +-- +STMT: CommentStmt +== 013 +|-- +-- drop user defined conversion +|-- +DROP CONVERSION myconv +-- +STMT: DropStmt +== 014 +DROP CONVERSION mydef +-- +STMT: DropStmt +== 015 +|-- +-- Note: the built-in conversions are exercised in opr_sanity.sql, +-- so there's no need to do that here. +|-- +|-- +-- return to the superuser +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 016 +DROP USER regress_conversion_user +-- +STMT: DropRoleStmt +== 017 +|-- +-- Test built-in conversion functions. +|-- + +-- Helper function to test a conversion. Uses the test_enc_conversion function +-- that was created in the create_function_0 test. +create or replace function test_conv( + input IN bytea, + src_encoding IN text, + dst_encoding IN text, + + result OUT bytea, + errorat OUT bytea, + error OUT text) +language plpgsql as +$$ +declare + validlen int; +begin + -- First try to perform the conversion with noError = false. If that errors out, + -- capture the error message, and try again with noError = true. The second call + -- should succeed and return the position of the error, return that too. + begin + select * into validlen, result from test_enc_conversion(input, src_encoding, dst_encoding, false); + errorat = NULL; + error := NULL; + exception when others then + error := sqlerrm; + select * into validlen, result from test_enc_conversion(input, src_encoding, dst_encoding, true); + errorat = substr(input, validlen + 1); + end; + return; +end; +$$ +-- +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 018 +|-- +-- UTF-8 +|-- +-- The description column must be unique. +CREATE TABLE utf8_verification_inputs (inbytes bytea, description text PRIMARY KEY) +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=DDL +STMT: CreateStmt +== 019 +insert into utf8_verification_inputs values + ('\x66006f', 'NUL byte'), + ('\xaf', 'bare continuation'), + ('\xc5', 'missing second byte in 2-byte char'), + ('\xc080', 'smallest 2-byte overlong'), + ('\xc1bf', 'largest 2-byte overlong'), + ('\xc280', 'next 2-byte after overlongs'), + ('\xdfbf', 'largest 2-byte'), + ('\xe9af', 'missing third byte in 3-byte char'), + ('\xe08080', 'smallest 3-byte overlong'), + ('\xe09fbf', 'largest 3-byte overlong'), + ('\xe0a080', 'next 3-byte after overlong'), + ('\xed9fbf', 'last before surrogates'), + ('\xeda080', 'smallest surrogate'), + ('\xedbfbf', 'largest surrogate'), + ('\xee8080', 'next after surrogates'), + ('\xefbfbf', 'largest 3-byte'), + ('\xf1afbf', 'missing fourth byte in 4-byte char'), + ('\xf0808080', 'smallest 4-byte overlong'), + ('\xf08fbfbf', 'largest 4-byte overlong'), + ('\xf0908080', 'next 4-byte after overlong'), + ('\xf48fbfbf', 'largest 4-byte'), + ('\xf4908080', 'smallest too large'), + ('\xfa9a9a8a8a', '5-byte') +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +-- Test UTF-8 verification slow path +select description, (test_conv(inbytes, 'utf8', 'utf8')).* from utf8_verification_inputs +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 021 +-- Test UTF-8 verification with ASCII padding appended to provide +-- coverage for algorithms that work on multiple bytes at a time. +-- The error message for a sequence starting with a 4-byte lead +-- will contain all 4 bytes if they are present, so various +-- expressions below add 3 ASCII bytes to the end to ensure +-- consistent error messages. +-- The number 64 below needs to be at least the value of STRIDE_LENGTH in wchar.c. + +-- Test multibyte verification in fast path +with test_bytes as ( + select + inbytes, + description, + (test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from utf8_verification_inputs +), test_padded as ( + select + description, + (test_conv(inbytes || repeat('.', 64)::bytea, 'utf8', 'utf8')).error + from test_bytes +) +select + description, + b.error as orig_error, + p.error as error_after_padding +from test_padded p +join test_bytes b +using (description) +where p.error is distinct from b.error +order by description +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +ALIAS: "b"="test_bytes" +ALIAS: "p"="test_padded" +CTE: "test_bytes" +CTE: "test_padded" +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="p" column="error" +FILTER: schema="" table="b" column="error" +STMT: SelectStmt +== 022 +-- Test ASCII verification in fast path where incomplete +-- UTF-8 sequences fall at the end of the preceding chunk. +with test_bytes as ( + select + inbytes, + description, + (test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from utf8_verification_inputs +), test_padded as ( + select + description, + (test_conv(repeat('.', 64 - length(inbytes))::bytea || inbytes || repeat('.', 64)::bytea, 'utf8', 'utf8')).error + from test_bytes +) +select + description, + b.error as orig_error, + p.error as error_after_padding +from test_padded p +join test_bytes b +using (description) +where p.error is distinct from b.error +order by description +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +ALIAS: "b"="test_bytes" +ALIAS: "p"="test_padded" +CTE: "test_bytes" +CTE: "test_padded" +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="p" column="error" +FILTER: schema="" table="b" column="error" +STMT: SelectStmt +== 023 +-- Test cases where UTF-8 sequences within short text +-- come after the fast path returns. +with test_bytes as ( + select + inbytes, + description, + (test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from utf8_verification_inputs +), test_padded as ( + select + description, + (test_conv(repeat('.', 64)::bytea || inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from test_bytes +) +select + description, + b.error as orig_error, + p.error as error_after_padding +from test_padded p +join test_bytes b +using (description) +where p.error is distinct from b.error +order by description +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +ALIAS: "b"="test_bytes" +ALIAS: "p"="test_padded" +CTE: "test_bytes" +CTE: "test_padded" +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="p" column="error" +FILTER: schema="" table="b" column="error" +STMT: SelectStmt +== 024 +-- Test cases where incomplete UTF-8 sequences fall at the +-- end of the part checked by the fast path. +with test_bytes as ( + select + inbytes, + description, + (test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from utf8_verification_inputs +), test_padded as ( + select + description, + (test_conv(repeat('.', 64 - length(inbytes))::bytea || inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from test_bytes +) +select + description, + b.error as orig_error, + p.error as error_after_padding +from test_padded p +join test_bytes b +using (description) +where p.error is distinct from b.error +order by description +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +ALIAS: "b"="test_bytes" +ALIAS: "p"="test_padded" +CTE: "test_bytes" +CTE: "test_padded" +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="p" column="error" +FILTER: schema="" table="b" column="error" +STMT: SelectStmt +== 025 +CREATE TABLE utf8_inputs (inbytes bytea, description text) +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=DDL +STMT: CreateStmt +== 026 +insert into utf8_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\xc3a4c3b6', 'valid, extra latin chars'), + ('\xd184d0bed0be', 'valid, cyrillic'), + ('\x666f6fe8b1a1', 'valid, kanji/Chinese'), + ('\xe382abe3829a', 'valid, two chars that combine to one in EUC_JIS_2004'), + ('\xe382ab', 'only first half of combined char in EUC_JIS_2004'), + ('\xe382abe382', 'incomplete combination when converted EUC_JIS_2004'), + ('\xecbd94eb81bceba6ac', 'valid, Hangul, Korean'), + ('\x666f6fefa8aa', 'valid, needs mapping function to convert to GB18030'), + ('\x66e8b1ff6f6f', 'invalid byte sequence'), + ('\x66006f', 'invalid, NUL byte'), + ('\x666f6fe8b100', 'invalid, NUL byte'), + ('\x666f6fe8b1', 'incomplete character at end') +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +-- Test UTF-8 verification +select description, (test_conv(inbytes, 'utf8', 'utf8')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 028 +-- Test conversions from UTF-8 +select description, inbytes, (test_conv(inbytes, 'utf8', 'euc_jis_2004')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 029 +select description, inbytes, (test_conv(inbytes, 'utf8', 'latin1')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 030 +select description, inbytes, (test_conv(inbytes, 'utf8', 'latin2')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 031 +select description, inbytes, (test_conv(inbytes, 'utf8', 'latin5')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 032 +select description, inbytes, (test_conv(inbytes, 'utf8', 'koi8r')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 033 +select description, inbytes, (test_conv(inbytes, 'utf8', 'gb18030')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 034 +|-- +-- EUC_JIS_2004 +|-- +CREATE TABLE euc_jis_2004_inputs (inbytes bytea, description text) +-- +TABLE: name="euc_jis_2004_inputs" schema="" table="euc_jis_2004_inputs" ctx=DDL +STMT: CreateStmt +== 035 +insert into euc_jis_2004_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x666f6fbedd', 'valid'), + ('\xa5f7', 'valid, translates to two UTF-8 chars '), + ('\xbeddbe', 'incomplete char '), + ('\x666f6f00bedd', 'invalid, NUL byte'), + ('\x666f6fbe00dd', 'invalid, NUL byte'), + ('\x666f6fbedd00', 'invalid, NUL byte'), + ('\xbe04', 'invalid byte sequence') +-- +TABLE: name="euc_jis_2004_inputs" schema="" table="euc_jis_2004_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +-- Test EUC_JIS_2004 verification +select description, inbytes, (test_conv(inbytes, 'euc_jis_2004', 'euc_jis_2004')).* from euc_jis_2004_inputs +-- +TABLE: name="euc_jis_2004_inputs" schema="" table="euc_jis_2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- Test conversions from EUC_JIS_2004 +select description, inbytes, (test_conv(inbytes, 'euc_jis_2004', 'utf8')).* from euc_jis_2004_inputs +-- +TABLE: name="euc_jis_2004_inputs" schema="" table="euc_jis_2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 038 +|-- +-- SHIFT-JIS-2004 +|-- +CREATE TABLE shiftjis2004_inputs (inbytes bytea, description text) +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=DDL +STMT: CreateStmt +== 039 +insert into shiftjis2004_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x666f6f8fdb', 'valid'), + ('\x666f6f81c0', 'valid, no translation to UTF-8'), + ('\x666f6f82f5', 'valid, translates to two UTF-8 chars '), + ('\x666f6f8fdb8f', 'incomplete char '), + ('\x666f6f820a', 'incomplete char, followed by newline '), + ('\x666f6f008fdb', 'invalid, NUL byte'), + ('\x666f6f8f00db', 'invalid, NUL byte'), + ('\x666f6f8fdb00', 'invalid, NUL byte') +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +-- Test SHIFT-JIS-2004 verification +select description, inbytes, (test_conv(inbytes, 'shiftjis2004', 'shiftjis2004')).* from shiftjis2004_inputs +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- Test conversions from SHIFT-JIS-2004 +select description, inbytes, (test_conv(inbytes, 'shiftjis2004', 'utf8')).* from shiftjis2004_inputs +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 042 +select description, inbytes, (test_conv(inbytes, 'shiftjis2004', 'euc_jis_2004')).* from shiftjis2004_inputs +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 043 +|-- +-- GB18030 +|-- +CREATE TABLE gb18030_inputs (inbytes bytea, description text) +-- +TABLE: name="gb18030_inputs" schema="" table="gb18030_inputs" ctx=DDL +STMT: CreateStmt +== 044 +insert into gb18030_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x666f6fcff3', 'valid'), + ('\x666f6f8431a530', 'valid, no translation to UTF-8'), + ('\x666f6f84309c38', 'valid, translates to UTF-8 by mapping function'), + ('\x666f6f84309c', 'incomplete char '), + ('\x666f6f84309c0a', 'incomplete char, followed by newline '), + ('\x666f6f84', 'incomplete char at end'), + ('\x666f6f84309c3800', 'invalid, NUL byte'), + ('\x666f6f84309c0038', 'invalid, NUL byte') +-- +TABLE: name="gb18030_inputs" schema="" table="gb18030_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +-- Test GB18030 verification. Round-trip through text so the backing of the +-- bytea values is palloc, not shared_buffers. This lets Valgrind detect +-- reads past the end. +select description, inbytes, (test_conv(inbytes::text::bytea, 'gb18030', 'gb18030')).* from gb18030_inputs +-- +TABLE: name="gb18030_inputs" schema="" table="gb18030_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 046 +-- Test conversions from GB18030 +select description, inbytes, (test_conv(inbytes, 'gb18030', 'utf8')).* from gb18030_inputs +-- +TABLE: name="gb18030_inputs" schema="" table="gb18030_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 047 +|-- +-- ISO-8859-5 +|-- +CREATE TABLE iso8859_5_inputs (inbytes bytea, description text) +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=DDL +STMT: CreateStmt +== 048 +insert into iso8859_5_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\xe4dede', 'valid'), + ('\x00', 'invalid, NUL byte'), + ('\xe400dede', 'invalid, NUL byte'), + ('\xe4dede00', 'invalid, NUL byte') +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +-- Test ISO-8859-5 verification +select description, inbytes, (test_conv(inbytes, 'iso8859-5', 'iso8859-5')).* from iso8859_5_inputs +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 050 +-- Test conversions from ISO-8859-5 +select description, inbytes, (test_conv(inbytes, 'iso8859-5', 'utf8')).* from iso8859_5_inputs +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 051 +select description, inbytes, (test_conv(inbytes, 'iso8859-5', 'koi8r')).* from iso8859_5_inputs +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 052 +select description, inbytes, (test_conv(inbytes, 'iso8859_5', 'mule_internal')).* from iso8859_5_inputs +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 053 +|-- +-- Big5 +|-- +CREATE TABLE big5_inputs (inbytes bytea, description text) +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=DDL +STMT: CreateStmt +== 054 +insert into big5_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x666f6fb648', 'valid'), + ('\x666f6fa27f', 'valid, no translation to UTF-8'), + ('\x666f6fb60048', 'invalid, NUL byte'), + ('\x666f6fb64800', 'invalid, NUL byte') +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +-- Test Big5 verification +select description, inbytes, (test_conv(inbytes, 'big5', 'big5')).* from big5_inputs +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- Test conversions from Big5 +select description, inbytes, (test_conv(inbytes, 'big5', 'utf8')).* from big5_inputs +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 057 +select description, inbytes, (test_conv(inbytes, 'big5', 'mule_internal')).* from big5_inputs +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 058 +|-- +-- MULE_INTERNAL +|-- +CREATE TABLE mic_inputs (inbytes bytea, description text) +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=DDL +STMT: CreateStmt +== 059 +insert into mic_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x8bc68bcf8bcf', 'valid (in KOI8R)'), + ('\x8bc68bcf8b', 'invalid,incomplete char'), + ('\x92bedd', 'valid (in SHIFT_JIS)'), + ('\x92be', 'invalid, incomplete char)'), + ('\x666f6f95a3c1', 'valid (in Big5)'), + ('\x666f6f95a3', 'invalid, incomplete char'), + ('\x9200bedd', 'invalid, NUL byte'), + ('\x92bedd00', 'invalid, NUL byte'), + ('\x8b00c68bcf8bcf', 'invalid, NUL byte') +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +-- Test MULE_INTERNAL verification +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'mule_internal')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 061 +-- Test conversions from MULE_INTERNAL +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'koi8r')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 062 +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'iso8859-5')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 063 +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'sjis')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 064 +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'big5')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +== 065 +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'euc_jp')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/copy.metadata.json b/parser/testdata/summary/postgres_regress/copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/copy.test b/parser/testdata/summary/postgres_regress/copy.test new file mode 100644 index 0000000..49d4dd6 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/copy.test @@ -0,0 +1,595 @@ +== 001 +|-- +-- COPY +|-- + +-- directory paths are passed to us in environment variables + +--- test copying in CSV mode with various styles +--- of embedded line ending characters + +create temp table copytest ( + style text, + test text, + filler int) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DDL +STMT: CreateStmt +== 002 +insert into copytest values('DOS',E'abc\r\ndef',1) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +insert into copytest values('Unix',E'abc\ndef',2) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +insert into copytest values('Mac',E'abc\rdef',3) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +insert into copytest values(E'esc\\ape',E'a\\r\\\r\\\n\\nb',4) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +copy copytest to :'filename' csv +-- +ERROR: syntax error at or near ":" +CURSORPOS: 18 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +create temp table copytest2 (like copytest) +-- +TABLE: name="copytest2" schema="" table="copytest2" ctx=DDL +STMT: CreateStmt +== 008 +copy copytest2 from :'filename' csv +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +select * from copytest except select * from copytest2 +-- +TABLE: name="copytest" schema="" table="copytest" ctx=Select +TABLE: name="copytest2" schema="" table="copytest2" ctx=Select +STMT: SelectStmt +== 010 +truncate copytest2 +-- +TABLE: name="copytest2" schema="" table="copytest2" ctx=DDL +STMT: TruncateStmt +== 011 +--- same test but with an escape char different from quote char + +copy copytest to :'filename' csv quote '''' escape E'\\' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 83 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +copy copytest2 from :'filename' csv quote '''' escape E'\\' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 013 +select * from copytest except select * from copytest2 +-- +TABLE: name="copytest" schema="" table="copytest" ctx=Select +TABLE: name="copytest2" schema="" table="copytest2" ctx=Select +STMT: SelectStmt +== 014 +-- test header line feature + +create temp table copytest3 ( + c1 int, + "col with , comma" text, + "col with "" quote" int) +-- +TABLE: name="copytest3" schema="" table="copytest3" ctx=DDL +STMT: CreateStmt +== 015 +copy copytest3 from stdin csv header +-- +TABLE: name="copytest3" schema="" table="copytest3" ctx=Select +STMT: CopyStmt +== 016 +copy copytest3 to stdout csv header +-- +TABLE: name="copytest3" schema="" table="copytest3" ctx=Select +STMT: CopyStmt +== 017 +create temp table copytest4 ( + c1 int, + "colname with tab: " text) +-- +TABLE: name="copytest4" schema="" table="copytest4" ctx=DDL +STMT: CreateStmt +== 018 +copy copytest4 from stdin (header) +-- +TABLE: name="copytest4" schema="" table="copytest4" ctx=Select +STMT: CopyStmt +== 019 +copy copytest4 to stdout (header) +-- +TABLE: name="copytest4" schema="" table="copytest4" ctx=Select +STMT: CopyStmt +== 020 +-- test copy from with a partitioned table +create table parted_copytest ( + a int, + b int, + c text +) partition by list (b) +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: CreateStmt +== 021 +create table parted_copytest_a1 (c text, b int, a int) +-- +TABLE: name="parted_copytest_a1" schema="" table="parted_copytest_a1" ctx=DDL +STMT: CreateStmt +== 022 +create table parted_copytest_a2 (a int, c text, b int) +-- +TABLE: name="parted_copytest_a2" schema="" table="parted_copytest_a2" ctx=DDL +STMT: CreateStmt +== 023 +alter table parted_copytest attach partition parted_copytest_a1 for values in(1) +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: AlterTableStmt +== 024 +alter table parted_copytest attach partition parted_copytest_a2 for values in(2) +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: AlterTableStmt +== 025 +-- We must insert enough rows to trigger multi-inserts. These are only +-- enabled adaptively when there are few enough partition changes. +insert into parted_copytest select x,1,'One' from generate_series(1,1000) x +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 026 +insert into parted_copytest select x,2,'Two' from generate_series(1001,1010) x +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 027 +insert into parted_copytest select x,1,'One' from generate_series(1011,1020) x +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 028 +copy (select * from parted_copytest order by a) to :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 52 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 029 +truncate parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: TruncateStmt +== 030 +copy parted_copytest from :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 27 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 031 +-- Ensure COPY FREEZE errors for partitioned tables. +begin +-- +STMT: TransactionStmt +== 032 +truncate parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: TruncateStmt +== 033 +copy parted_copytest from :'filename' (freeze) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 27 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 034 +rollback +-- +STMT: TransactionStmt +== 035 +select tableoid::regclass,count(*),sum(a) from parted_copytest +group by tableoid order by tableoid::regclass::name +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 036 +truncate parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: TruncateStmt +== 037 +-- create before insert row trigger on parted_copytest_a2 +create function part_ins_func() returns trigger language plpgsql as $$ +begin + return new; +end; +$$ +-- +FUNCTION: name="part_ins_func" function="part_ins_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 038 +create trigger part_ins_trig + before insert on parted_copytest_a2 + for each row + execute procedure part_ins_func() +-- +TABLE: name="parted_copytest_a2" schema="" table="parted_copytest_a2" ctx=DDL +STMT: CreateTrigStmt +== 039 +copy parted_copytest from :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 27 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 040 +select tableoid::regclass,count(*),sum(a) from parted_copytest +group by tableoid order by tableoid::regclass::name +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 041 +truncate table parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: TruncateStmt +== 042 +create index on parted_copytest (b) +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: IndexStmt +== 043 +drop trigger part_ins_trig on parted_copytest_a2 +-- +TABLE: name="parted_copytest_a2" schema="" table="parted_copytest_a2" ctx=DDL +STMT: DropStmt +== 044 +copy parted_copytest from stdin +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +STMT: CopyStmt +== 045 +-- Ensure index entries were properly added during the copy. +select * from parted_copytest where b = 1 +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 046 +select * from parted_copytest where b = 2 +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 047 +drop table parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: DropStmt +== 048 +|-- +-- Progress reporting for COPY +|-- +create table tab_progress_reporting ( + name text, + age int4, + location point, + salary int4, + manager name +) +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: CreateStmt +== 049 +-- Add a trigger to catch and print the contents of the catalog view +-- pg_stat_progress_copy during data insertion. This allows to test +-- the validation of some progress reports for COPY FROM where the trigger +-- would fire. +create function notice_after_tab_progress_reporting() returns trigger AS +$$ +declare report record; +begin + -- The fields ignored here are the ones that may not remain + -- consistent across multiple runs. The sizes reported may differ + -- across platforms, so just check if these are strictly positive. + with progress_data as ( + select + relid::regclass::text as relname, + command, + type, + bytes_processed > 0 as has_bytes_processed, + bytes_total > 0 as has_bytes_total, + tuples_processed, + tuples_excluded + from pg_stat_progress_copy + where pid = pg_backend_pid()) + select into report (to_jsonb(r)) as value + from progress_data r; + + raise info 'progress: %', report.value::text; + return new; +end; +$$ language plpgsql +-- +FUNCTION: name="notice_after_tab_progress_reporting" function="notice_after_tab_progress_reporting" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 050 +create trigger check_after_tab_progress_reporting + after insert on tab_progress_reporting + for each statement + execute function notice_after_tab_progress_reporting() +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: CreateTrigStmt +== 051 +-- Generate COPY FROM report with PIPE. +copy tab_progress_reporting from stdin +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=Select +STMT: CopyStmt +== 052 +-- Generate COPY FROM report with FILE, with some excluded tuples. +truncate tab_progress_reporting +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: TruncateStmt +== 053 +copy tab_progress_reporting from :'filename' + where (salary < 2000) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 054 +drop trigger check_after_tab_progress_reporting on tab_progress_reporting +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: DropStmt +== 055 +drop function notice_after_tab_progress_reporting() +-- +FUNCTION: name="notice_after_tab_progress_reporting" function="notice_after_tab_progress_reporting" schema="" ctx=DDL +STMT: DropStmt +== 056 +drop table tab_progress_reporting +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: DropStmt +== 057 +-- Test header matching feature +create table header_copytest ( + a int, + b int, + c text +) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: CreateStmt +== 058 +-- Make sure it works with dropped columns +alter table header_copytest drop column c +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: AlterTableStmt +== 059 +alter table header_copytest add column c text +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: AlterTableStmt +== 060 +copy header_copytest to stdout with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 061 +copy header_copytest from stdin with (header wrong_choice) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 062 +copy header_copytest (c, a, b) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 063 +copy header_copytest from stdin with (header match, format csv) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 064 +-- errors +copy header_copytest (c, b, a) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 065 +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 066 +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 067 +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 068 +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 069 +SELECT * FROM header_copytest ORDER BY a +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: SelectStmt +== 070 +-- Drop an extra column, in the middle of the existing set. +alter table header_copytest drop column b +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: AlterTableStmt +== 071 +-- works +copy header_copytest (c, a) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 072 +copy header_copytest (a, c) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 073 +-- errors +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 074 +copy header_copytest (a, c) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +== 075 +SELECT * FROM header_copytest ORDER BY a +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: SelectStmt +== 076 +drop table header_copytest +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: DropStmt +== 077 +-- test COPY with overlong column defaults +create temp table oversized_column_default ( + col1 varchar(5) DEFAULT 'more than 5 chars', + col2 varchar(5)) +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=DDL +STMT: CreateStmt +== 078 +-- normal COPY should work +copy oversized_column_default from stdin +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=Select +STMT: CopyStmt +== 079 +-- error if the column is excluded +copy oversized_column_default (col2) from stdin +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=Select +STMT: CopyStmt +== 080 +-- error if the DEFAULT option is given +copy oversized_column_default from stdin (default '') +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=Select +STMT: CopyStmt +== 081 +drop table oversized_column_default +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=DDL +STMT: DropStmt +== 082 +|-- +-- Create partitioned table that does not allow bulk insertions, to test bugs +-- related to the reuse of BulkInsertState across partitions (only done when +-- not using bulk insert). Switching between partitions often makes it more +-- likely to encounter these bugs, so we just switch on roughly every insert +-- by having an even/odd number partition and inserting evenly distributed +-- data. +|-- +CREATE TABLE parted_si ( + id int not null, + data text not null, + -- prevent use of bulk insert by having a volatile function + rand float8 not null default random() +) +PARTITION BY LIST((id % 2)) +-- +TABLE: name="parted_si" schema="" table="parted_si" ctx=DDL +STMT: CreateStmt +== 083 +CREATE TABLE parted_si_p_even PARTITION OF parted_si FOR VALUES IN (0) +-- +TABLE: name="parted_si_p_even" schema="" table="parted_si_p_even" ctx=DDL +STMT: CreateStmt +== 084 +CREATE TABLE parted_si_p_odd PARTITION OF parted_si FOR VALUES IN (1) +-- +TABLE: name="parted_si_p_odd" schema="" table="parted_si_p_odd" ctx=DDL +STMT: CreateStmt +== 085 +-- Test that bulk relation extension handles reusing a single BulkInsertState +-- across partitions. Without the fix applied, this reliably reproduces +-- #18130 unless shared_buffers is extremely small (preventing any use of bulk +-- relation extension). See +-- https://postgr.es/m/18130-7a86a7356a75209d%40postgresql.org +-- https://postgr.es/m/257696.1695670946%40sss.pgh.pa.us +COPY parted_si(id, data) FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 409 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 086 +-- An earlier bug (see commit b1ecb9b3fcf) could end up using a buffer from +-- the wrong partition. This test is *not* guaranteed to trigger that bug, but +-- does so when shared_buffers is small enough. To test if we encountered the +-- bug, check that the partition condition isn't violated. +SELECT tableoid::regclass, id % 2 = 0 is_even, count(*) from parted_si GROUP BY 1, 2 ORDER BY 1 +-- +TABLE: name="parted_si" schema="" table="parted_si" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 087 +DROP TABLE parted_si +-- +TABLE: name="parted_si" schema="" table="parted_si" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/copy2.metadata.json b/parser/testdata/summary/postgres_regress/copy2.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/copy2.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/copy2.test b/parser/testdata/summary/postgres_regress/copy2.test new file mode 100644 index 0000000..fd127c4 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/copy2.test @@ -0,0 +1,373 @@ +== 001 +CREATE TEMP TABLE x ( + a serial, + b int, + c text not null default 'stuff', + d text, + e text +) ; + +CREATE FUNCTION fn_x_before () RETURNS TRIGGER AS ' + BEGIN + NEW.e := ''before trigger fired''::text; + return NEW; + END; +' LANGUAGE plpgsql; + +CREATE FUNCTION fn_x_after () RETURNS TRIGGER AS ' + BEGIN + UPDATE x set e=''after trigger fired'' where c=''stuff''; + return NULL; + END; +' LANGUAGE plpgsql; + +CREATE TRIGGER trg_x_after AFTER INSERT ON x +FOR EACH ROW EXECUTE PROCEDURE fn_x_after(); + +CREATE TRIGGER trg_x_before BEFORE INSERT ON x +FOR EACH ROW EXECUTE PROCEDURE fn_x_before(); + +COPY x (a, b, c, d, e) from stdin; + +COPY x (b, d) from stdin; + +COPY x (b, d) from stdin; + +COPY x (a, b, c, d, e) from stdin; + +-- non-existent column in column list: should fail +COPY x (xyz) from stdin; +COPY x from stdin; +COPY x from stdin; + +-- extra data: should fail +COPY x from stdin; + +-- various COPY options: delimiters, oids, NULL string, encoding +COPY x (b, c, d, e) from stdin delimiter ',' null 'x'; + +COPY x from stdin WITH DELIMITER AS ';' NULL AS ''; + +COPY x from stdin WITH DELIMITER AS ':' NULL AS E'\\X' ENCODING 'sql_ascii'; + +COPY x TO stdout WHERE a = 1; +COPY x from stdin WHERE a = 50004; + +COPY x from stdin WHERE a > 60003; + +COPY x from stdin WHERE f > 60003; + +-- test end of copy marker +CREATE TEMP TABLE testeoc (a text); + +COPY testeoc FROM stdin CSV; + +COPY testeoc TO stdout CSV; + +-- test handling of nonstandard null marker that violates escaping rules + +CREATE TEMP TABLE testnull(a int, b text); +INSERT INTO testnull VALUES (1, E'\\0'), (NULL, NULL); + +COPY testnull TO stdout WITH NULL AS E'\\0'; + +COPY testnull FROM stdin WITH NULL AS E'\\0'; + +SELECT * FROM testnull; + +BEGIN; +CREATE TABLE vistest (LIKE testeoc); +COPY vistest FROM stdin CSV; +COMMIT; +SELECT * FROM vistest; +BEGIN; +TRUNCATE vistest; +COPY vistest FROM stdin CSV; +SELECT * FROM vistest; +SAVEPOINT s1; +TRUNCATE vistest; +COPY vistest FROM stdin CSV; +SELECT * FROM vistest; +COMMIT; +SELECT * FROM vistest; + +BEGIN; +TRUNCATE vistest; +COPY vistest FROM stdin CSV FREEZE; +SELECT * FROM vistest; +SAVEPOINT s1; +TRUNCATE vistest; +COPY vistest FROM stdin CSV FREEZE; +SELECT * FROM vistest; +COMMIT; +SELECT * FROM vistest; + +BEGIN; +TRUNCATE vistest; +COPY vistest FROM stdin CSV FREEZE; +SELECT * FROM vistest; +COMMIT; +TRUNCATE vistest; +COPY vistest FROM stdin CSV FREEZE; +BEGIN; +TRUNCATE vistest; +SAVEPOINT s1; +COPY vistest FROM stdin CSV FREEZE; +COMMIT; +BEGIN; +INSERT INTO vistest VALUES ('z'); +SAVEPOINT s1; +TRUNCATE vistest; +ROLLBACK TO SAVEPOINT s1; +COPY vistest FROM stdin CSV FREEZE; +COMMIT; +CREATE FUNCTION truncate_in_subxact() RETURNS VOID AS +$$ +BEGIN + TRUNCATE vistest; +EXCEPTION + WHEN OTHERS THEN + INSERT INTO vistest VALUES ('subxact failure'); +END; +$$ language plpgsql; +BEGIN; +INSERT INTO vistest VALUES ('z'); +SELECT truncate_in_subxact(); +COPY vistest FROM stdin CSV FREEZE; +SELECT * FROM vistest; +COMMIT; +SELECT * FROM vistest; +-- Test FORCE_NOT_NULL and FORCE_NULL options +CREATE TEMP TABLE forcetest ( + a INT NOT NULL, + b TEXT NOT NULL, + c TEXT, + d TEXT, + e TEXT +); +-- should succeed with no effect ("b" remains an empty string, "c" remains NULL) +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL(b), FORCE_NULL(c)); +COMMIT; +SELECT b, c FROM forcetest WHERE a = 1; +-- should succeed, FORCE_NULL and FORCE_NOT_NULL can be both specified +BEGIN; +COPY forcetest (a, b, c, d) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL(c,d), FORCE_NULL(c,d)); +COMMIT; +SELECT c, d FROM forcetest WHERE a = 2; +-- should fail with not-null constraint violation +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NULL(b), FORCE_NOT_NULL(c)); +ROLLBACK; +-- should fail with "not referenced by COPY" error +BEGIN; +COPY forcetest (d, e) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL(b)); +COMMIT; +SELECT b, c FROM forcetest WHERE a = 4; +-- should succeed with effect ("b" remains an empty string) +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL *); +COMMIT; +SELECT b, c FROM forcetest WHERE a = 5; +-- should succeed with effect ("c" remains NULL) +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NULL *); +COMMIT; +SELECT b, c FROM forcetest WHERE a = 6; +-- should fail with "conflicting or redundant options" error +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL *, FORCE_NOT_NULL(b)); +copy check_con_tbl from stdin; +select * from check_con_tbl; + +-- test with RLS enabled. +CREATE ROLE regress_rls_copy_user; +CREATE ROLE regress_rls_copy_user_colperms; +CREATE TABLE rls_t1 (a int, b int, c int); + +COPY rls_t1 (a, b, c) from stdin; + +CREATE POLICY p1 ON rls_t1 FOR SELECT USING (a % 2 = 0); +ALTER TABLE rls_t1 ENABLE ROW LEVEL SECURITY; +ALTER TABLE rls_t1 FORCE ROW LEVEL SECURITY; + +GRANT SELECT ON TABLE rls_t1 TO regress_rls_copy_user; +GRANT SELECT (a, b) ON TABLE rls_t1 TO regress_rls_copy_user_colperms; + +-- all columns +COPY rls_t1 TO stdout; +COPY rls_t1 (a, b, c) TO stdout; + +-- subset of columns +COPY rls_t1 (a) TO stdout; +COPY rls_t1 (a, b) TO stdout; + +-- column reordering +COPY rls_t1 (b, a) TO stdout; + +SET SESSION AUTHORIZATION regress_rls_copy_user; + +-- all columns +COPY rls_t1 TO stdout; +COPY rls_t1 (a, b, c) TO stdout; + +-- subset of columns +COPY rls_t1 (a) TO stdout; +COPY rls_t1 (a, b) TO stdout; + +-- column reordering +COPY rls_t1 (b, a) TO stdout; + +RESET SESSION AUTHORIZATION; + +SET SESSION AUTHORIZATION regress_rls_copy_user_colperms; + +-- attempt all columns (should fail) +COPY rls_t1 TO stdout; +COPY rls_t1 (a, b, c) TO stdout; + +-- try to copy column with no privileges (should fail) +COPY rls_t1 (c) TO stdout; + +-- subset of columns (should succeed) +COPY rls_t1 (a) TO stdout; +COPY rls_t1 (a, b) TO stdout; + +RESET SESSION AUTHORIZATION; + +-- test with INSTEAD OF INSERT trigger on a view +CREATE TABLE instead_of_insert_tbl(id serial, name text); +CREATE VIEW instead_of_insert_tbl_view AS SELECT ''::text AS str; + +COPY instead_of_insert_tbl_view FROM stdin; -- fail +test1 + +CREATE FUNCTION fun_instead_of_insert_tbl() RETURNS trigger AS $$ +BEGIN + INSERT INTO instead_of_insert_tbl (name) VALUES (NEW.str); + +SELECT * FROM instead_of_insert_tbl; + +-- Test of COPY optimization with view using INSTEAD OF INSERT +-- trigger when relation is created in the same transaction as +-- when COPY is executed. +BEGIN; +CREATE VIEW instead_of_insert_tbl_view_2 as select ''::text as str; +CREATE TRIGGER trig_instead_of_insert_tbl_view_2 + INSTEAD OF INSERT ON instead_of_insert_tbl_view_2 + FOR EACH ROW EXECUTE PROCEDURE fun_instead_of_insert_tbl(); + +COPY instead_of_insert_tbl_view_2 FROM stdin; + +SELECT * FROM instead_of_insert_tbl; +COMMIT; + +-- tests for on_error option +CREATE TABLE check_ign_err (n int, m int[], k int); +COPY check_ign_err FROM STDIN WITH (on_error stop); + +-- want context for notices + +COPY check_ign_err FROM STDIN WITH (on_error ignore, log_verbosity verbose); + +-- tests for on_error option with log_verbosity and null constraint via domain +CREATE DOMAIN dcheck_ign_err2 varchar(15) NOT NULL; +CREATE TABLE check_ign_err2 (n int, m int[], k int, l dcheck_ign_err2); +COPY check_ign_err2 FROM STDIN WITH (on_error ignore, log_verbosity verbose); + +-- reset context choice + +SELECT * FROM check_ign_err; + +SELECT * FROM check_ign_err2; + +-- test datatype error that can't be handled as soft: should fail +CREATE TABLE hard_err(foo widget); +COPY hard_err FROM STDIN WITH (on_error ignore); + +-- test missing data: should fail +COPY check_ign_err FROM STDIN WITH (on_error ignore); + +-- test extra data: should fail +COPY check_ign_err FROM STDIN WITH (on_error ignore); + +-- clean up +DROP TABLE forcetest; +DROP TABLE vistest; +DROP FUNCTION truncate_in_subxact(); +DROP TABLE x, y; +DROP TABLE rls_t1 CASCADE; +DROP ROLE regress_rls_copy_user; +DROP ROLE regress_rls_copy_user_colperms; +DROP FUNCTION fn_x_before(); +DROP FUNCTION fn_x_after(); +DROP TABLE instead_of_insert_tbl; +DROP VIEW instead_of_insert_tbl_view; +DROP VIEW instead_of_insert_tbl_view_2; +DROP FUNCTION fun_instead_of_insert_tbl(); +DROP TABLE check_ign_err; +DROP TABLE check_ign_err2; +DROP DOMAIN dcheck_ign_err2; +DROP TABLE hard_err; + +|-- +-- COPY FROM ... DEFAULT +|-- + +create temp table copy_default ( + id integer primary key, + text_value text not null default 'test', + ts_value timestamp without time zone not null default '2022-07-05' +); + +-- if DEFAULT is not specified, then the marker will be regular data +copy copy_default from stdin; + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +copy copy_default from stdin with (format csv); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +-- DEFAULT cannot be used in binary mode +copy copy_default from stdin with (format binary, default '\D'); + +copy copy_default from stdin with (format csv, default '\D'); + +-- The DEFAULT marker must be unquoted and unescaped or it's not recognized +copy copy_default from stdin with (default '\D'); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +copy copy_default from stdin with (format csv, default '\D'); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +-- successful usage of DEFAULT option in COPY +copy copy_default from stdin with (default '\D'); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +copy copy_default from stdin with (format csv, default '\D'); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +-- DEFAULT cannot be used in COPY TO +copy (select 1 as test) TO stdout with (default '\D'); +-- +ERROR: WHERE clause not allowed with COPY TO +CURSORPOS: 1145 +FILENAME: gram.y +FUNCNAME: base_yyparse diff --git a/parser/testdata/summary/postgres_regress/copydml.metadata.json b/parser/testdata/summary/postgres_regress/copydml.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/copydml.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/copydml.test b/parser/testdata/summary/postgres_regress/copydml.test new file mode 100644 index 0000000..156d8f5 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/copydml.test @@ -0,0 +1,324 @@ +== 001 +|-- +-- Test cases for COPY (INSERT/UPDATE/DELETE) TO +|-- +create table copydml_test (id serial, t text) +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: CreateStmt +== 002 +insert into copydml_test (t) values ('a') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +insert into copydml_test (t) values ('b') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +insert into copydml_test (t) values ('c') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +insert into copydml_test (t) values ('d') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +insert into copydml_test (t) values ('e') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +|-- +-- Test COPY (insert/update/delete ...) +|-- +copy (insert into copydml_test (t) values ('f') returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 008 +copy (update copydml_test set t = 'g' where t = 'f' returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 009 +copy (delete from copydml_test where t = 'g' returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 010 +|-- +-- Test \copy (insert/update/delete ...) +|-- + +-- Error cases +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 011 +copy (update copydml_test set t = 'g') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 012 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 013 +create rule qqq as on insert to copydml_test do instead nothing +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 014 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 015 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 016 +create rule qqq as on insert to copydml_test do also delete from copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 017 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 018 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 019 +create rule qqq as on insert to copydml_test do instead (delete from copydml_test; delete from copydml_test) +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 020 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 021 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 022 +create rule qqq as on insert to copydml_test where new.t <> 'f' do instead delete from copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 023 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 024 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 025 +create rule qqq as on update to copydml_test do instead nothing +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 026 +copy (update copydml_test set t = 'f') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 027 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 028 +create rule qqq as on update to copydml_test do also delete from copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 029 +copy (update copydml_test set t = 'f') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 030 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 031 +create rule qqq as on update to copydml_test do instead (delete from copydml_test; delete from copydml_test) +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 032 +copy (update copydml_test set t = 'f') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 033 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 034 +create rule qqq as on update to copydml_test where new.t <> 'f' do instead delete from copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 035 +copy (update copydml_test set t = 'f') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 036 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 037 +create rule qqq as on delete to copydml_test do instead nothing +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 038 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 039 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 040 +create rule qqq as on delete to copydml_test do also insert into copydml_test default values +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 041 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 042 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 043 +create rule qqq as on delete to copydml_test do instead (insert into copydml_test default values; insert into copydml_test default values) +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 044 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 045 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 046 +create rule qqq as on delete to copydml_test where old.t <> 'f' do instead insert into copydml_test default values +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 047 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 048 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 049 +create rule qqq as on insert to copydml_test do instead notify copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +== 050 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 051 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 052 +-- triggers +create function qqq_trig() returns trigger as $$ +begin +if tg_op in ('INSERT', 'UPDATE') then + raise notice '% % %', tg_when, tg_op, new.id; + return new; +else + raise notice '% % %', tg_when, tg_op, old.id; + return old; +end if; +end +$$ language plpgsql +-- +FUNCTION: name="qqq_trig" function="qqq_trig" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 053 +create trigger qqqbef before insert or update or delete on copydml_test + for each row execute procedure qqq_trig() +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: CreateTrigStmt +== 054 +create trigger qqqaf after insert or update or delete on copydml_test + for each row execute procedure qqq_trig() +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: CreateTrigStmt +== 055 +copy (insert into copydml_test (t) values ('f') returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 056 +copy (update copydml_test set t = 'g' where t = 'f' returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 057 +copy (delete from copydml_test where t = 'g' returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +== 058 +drop table copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +== 059 +drop function qqq_trig() +-- +FUNCTION: name="qqq_trig" function="qqq_trig" schema="" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/copyselect.metadata.json b/parser/testdata/summary/postgres_regress/copyselect.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/copyselect.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/copyselect.test b/parser/testdata/summary/postgres_regress/copyselect.test new file mode 100644 index 0000000..eb112ca --- /dev/null +++ b/parser/testdata/summary/postgres_regress/copyselect.test @@ -0,0 +1,148 @@ +== 001 +|-- +-- Test cases for COPY (select) TO +|-- +create table test1 (id serial, t text) +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: CreateStmt +== 002 +insert into test1 (t) values ('a') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +insert into test1 (t) values ('b') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +insert into test1 (t) values ('c') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +insert into test1 (t) values ('d') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +insert into test1 (t) values ('e') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +create table test2 (id serial, t text) +-- +TABLE: name="test2" schema="" table="test2" ctx=DDL +STMT: CreateStmt +== 008 +insert into test2 (t) values ('A') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +insert into test2 (t) values ('B') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +insert into test2 (t) values ('C') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +insert into test2 (t) values ('D') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +insert into test2 (t) values ('E') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +create view v_test1 +as select 'v_'||t from test1 +-- +TABLE: name="v_test1" schema="" table="v_test1" ctx=DDL +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 014 +|-- +-- Test COPY table TO +|-- +copy test1 to stdout +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: CopyStmt +== 015 +|-- +-- This should fail +|-- +copy v_test1 to stdout +-- +TABLE: name="v_test1" schema="" table="v_test1" ctx=Select +STMT: CopyStmt +== 016 +|-- +-- Test COPY (select) TO +|-- +copy (select t from test1 where id=1) to stdout +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +FILTER: schema="" table="" column="id" +STMT: CopyStmt +== 017 +|-- +-- Test COPY (select for update) TO +|-- +copy (select t from test1 where id=3 for update) to stdout +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +FILTER: schema="" table="" column="id" +STMT: CopyStmt +== 018 +|-- +-- This should fail +|-- +copy (select t into temp test3 from test1 where id=3) to stdout +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +TABLE: name="test3" schema="" table="test3" ctx=DDL +FILTER: schema="" table="" column="id" +STMT: CopyStmt +== 019 +|-- +-- This should fail +|-- +copy (select * from test1) from stdin +-- +ERROR: syntax error at or near "from" +CURSORPOS: 54 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 020 +2 +select * from test3 +-- +ERROR: syntax error at or near "2" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 021 +drop table test3 +-- +TABLE: name="test3" schema="" table="test3" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/create_aggregate.metadata.json b/parser/testdata/summary/postgres_regress/create_aggregate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_aggregate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_aggregate.test b/parser/testdata/summary/postgres_regress/create_aggregate.test new file mode 100644 index 0000000..3665eeb --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_aggregate.test @@ -0,0 +1,476 @@ +== 001 +|-- +-- CREATE_AGGREGATE +|-- + +-- all functions CREATEd +CREATE AGGREGATE newavg ( + sfunc = int4_avg_accum, basetype = int4, stype = _int8, + finalfunc = int8_avg, + initcond1 = '{0,0}' +) +-- +STMT: DefineStmt +== 002 +-- test comments +COMMENT ON AGGREGATE newavg_wrong (int4) IS 'an agg comment' +-- +STMT: CommentStmt +== 003 +COMMENT ON AGGREGATE newavg (int4) IS 'an agg comment' +-- +STMT: CommentStmt +== 004 +COMMENT ON AGGREGATE newavg (int4) IS NULL +-- +STMT: CommentStmt +== 005 +-- without finalfunc; test obsolete spellings 'sfunc1' etc +CREATE AGGREGATE newsum ( + sfunc1 = int4pl, basetype = int4, stype1 = int4, + initcond1 = '0' +) +-- +STMT: DefineStmt +== 006 +-- zero-argument aggregate +CREATE AGGREGATE newcnt (*) ( + sfunc = int8inc, stype = int8, + initcond = '0', parallel = safe +) +-- +STMT: DefineStmt +== 007 +-- old-style spelling of same (except without parallel-safe; that's too new) +CREATE AGGREGATE oldcnt ( + sfunc = int8inc, basetype = 'ANY', stype = int8, + initcond = '0' +) +-- +STMT: DefineStmt +== 008 +-- aggregate that only cares about null/nonnull input +CREATE AGGREGATE newcnt ("any") ( + sfunc = int8inc_any, stype = int8, + initcond = '0' +) +-- +STMT: DefineStmt +== 009 +COMMENT ON AGGREGATE nosuchagg (*) IS 'should fail' +-- +STMT: CommentStmt +== 010 +COMMENT ON AGGREGATE newcnt (*) IS 'an agg(*) comment' +-- +STMT: CommentStmt +== 011 +COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment' +-- +STMT: CommentStmt +== 012 +-- multi-argument aggregate +create function sum3(int8,int8,int8) returns int8 as +'select $1 + $2 + $3' language sql strict immutable +-- +FUNCTION: name="sum3" function="sum3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 013 +create aggregate sum2(int8,int8) ( + sfunc = sum3, stype = int8, + initcond = '0' +) +-- +STMT: DefineStmt +== 014 +-- multi-argument aggregates sensitive to distinct/order, strict/nonstrict +create type aggtype as (a integer, b integer, c text) +-- +STMT: CompositeTypeStmt +== 015 +create function aggf_trans(aggtype[],integer,integer,text) returns aggtype[] +as 'select array_append($1,ROW($2,$3,$4)::aggtype)' +language sql strict immutable +-- +FUNCTION: name="aggf_trans" function="aggf_trans" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 016 +create function aggfns_trans(aggtype[],integer,integer,text) returns aggtype[] +as 'select array_append($1,ROW($2,$3,$4)::aggtype)' +language sql immutable +-- +FUNCTION: name="aggfns_trans" function="aggfns_trans" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 017 +create aggregate aggfstr(integer,integer,text) ( + sfunc = aggf_trans, stype = aggtype[], + initcond = '{}' +) +-- +STMT: DefineStmt +== 018 +create aggregate aggfns(integer,integer,text) ( + sfunc = aggfns_trans, stype = aggtype[], sspace = 10000, + initcond = '{}' +) +-- +STMT: DefineStmt +== 019 +-- check error cases that would require run-time type coercion +create function least_accum(int8, int8) returns int8 language sql as + 'select least($1, $2)' +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 020 +create aggregate least_agg(int4) ( + stype = int8, sfunc = least_accum +) +-- +STMT: DefineStmt +== 021 +-- fails + +drop function least_accum(int8, int8) +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: DropStmt +== 022 +create function least_accum(anycompatible, anycompatible) +returns anycompatible language sql as + 'select least($1, $2)' +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 023 +create aggregate least_agg(int4) ( + stype = int8, sfunc = least_accum +) +-- +STMT: DefineStmt +== 024 +-- fails + +create aggregate least_agg(int8) ( + stype = int8, sfunc = least_accum +) +-- +STMT: DefineStmt +== 025 +drop function least_accum(anycompatible, anycompatible) cascade +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: DropStmt +== 026 +-- variadic aggregates +create function least_accum(anyelement, variadic anyarray) +returns anyelement language sql as + 'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)' +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 027 +create aggregate least_agg(variadic items anyarray) ( + stype = anyelement, sfunc = least_accum +) +-- +STMT: DefineStmt +== 028 +create function cleast_accum(anycompatible, variadic anycompatiblearray) +returns anycompatible language sql as + 'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)' +-- +FUNCTION: name="cleast_accum" function="cleast_accum" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +create aggregate cleast_agg(variadic items anycompatiblearray) ( + stype = anycompatible, sfunc = cleast_accum +) +-- +STMT: DefineStmt +== 030 +-- test ordered-set aggs using built-in support functions +create aggregate my_percentile_disc(float8 ORDER BY anyelement) ( + stype = internal, + sfunc = ordered_set_transition, + finalfunc = percentile_disc_final, + finalfunc_extra = true, + finalfunc_modify = read_write +) +-- +STMT: DefineStmt +== 031 +create aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") ( + stype = internal, + sfunc = ordered_set_transition_multi, + finalfunc = rank_final, + finalfunc_extra = true, + hypothetical +) +-- +STMT: DefineStmt +== 032 +alter aggregate my_percentile_disc(float8 ORDER BY anyelement) + rename to test_percentile_disc +-- +STMT: RenameStmt +== 033 +alter aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") + rename to test_rank +-- +STMT: RenameStmt +== 034 +-- moving-aggregate options + +CREATE AGGREGATE sumdouble (float8) +( + stype = float8, + sfunc = float8pl, + mstype = float8, + msfunc = float8pl, + minvfunc = float8mi +) +-- +STMT: DefineStmt +== 035 +-- aggregate combine and serialization functions + +-- can't specify just one of serialfunc and deserialfunc +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + serialfunc = numeric_avg_serialize +) +-- +STMT: DefineStmt +== 036 +-- serialfunc must have correct parameters +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + serialfunc = numeric_avg_deserialize, + deserialfunc = numeric_avg_deserialize +) +-- +STMT: DefineStmt +== 037 +-- deserialfunc must have correct parameters +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + serialfunc = numeric_avg_serialize, + deserialfunc = numeric_avg_serialize +) +-- +STMT: DefineStmt +== 038 +-- ensure combine function parameters are checked +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + serialfunc = numeric_avg_serialize, + deserialfunc = numeric_avg_deserialize, + combinefunc = int4larger +) +-- +STMT: DefineStmt +== 039 +-- ensure create aggregate works. +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + finalfunc = numeric_avg, + serialfunc = numeric_avg_serialize, + deserialfunc = numeric_avg_deserialize, + combinefunc = numeric_avg_combine, + finalfunc_modify = shareable -- just to test a non-default setting +) +-- +STMT: DefineStmt +== 040 +-- Ensure all these functions made it into the catalog +SELECT aggfnoid, aggtransfn, aggcombinefn, aggtranstype::regtype, + aggserialfn, aggdeserialfn, aggfinalmodify +FROM pg_aggregate +WHERE aggfnoid = 'myavg'::REGPROC +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +FILTER: schema="" table="" column="aggfnoid" +STMT: SelectStmt +== 041 +DROP AGGREGATE myavg (numeric) +-- +STMT: DropStmt +== 042 +-- create or replace aggregate +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + finalfunc = numeric_avg +) +-- +STMT: DefineStmt +== 043 +CREATE OR REPLACE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + finalfunc = numeric_avg, + serialfunc = numeric_avg_serialize, + deserialfunc = numeric_avg_deserialize, + combinefunc = numeric_avg_combine, + finalfunc_modify = shareable -- just to test a non-default setting +) +-- +STMT: DefineStmt +== 044 +-- Ensure all these functions made it into the catalog again +SELECT aggfnoid, aggtransfn, aggcombinefn, aggtranstype::regtype, + aggserialfn, aggdeserialfn, aggfinalmodify +FROM pg_aggregate +WHERE aggfnoid = 'myavg'::REGPROC +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +FILTER: schema="" table="" column="aggfnoid" +STMT: SelectStmt +== 045 +-- can change stype: +CREATE OR REPLACE AGGREGATE myavg (numeric) +( + stype = numeric, + sfunc = numeric_add +) +-- +STMT: DefineStmt +== 046 +SELECT aggfnoid, aggtransfn, aggcombinefn, aggtranstype::regtype, + aggserialfn, aggdeserialfn, aggfinalmodify +FROM pg_aggregate +WHERE aggfnoid = 'myavg'::REGPROC +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +FILTER: schema="" table="" column="aggfnoid" +STMT: SelectStmt +== 047 +-- can't change return type: +CREATE OR REPLACE AGGREGATE myavg (numeric) +( + stype = numeric, + sfunc = numeric_add, + finalfunc = numeric_out +) +-- +STMT: DefineStmt +== 048 +-- can't change to a different kind: +CREATE OR REPLACE AGGREGATE myavg (order by numeric) +( + stype = numeric, + sfunc = numeric_add +) +-- +STMT: DefineStmt +== 049 +-- can't change plain function to aggregate: +create function sum4(int8,int8,int8,int8) returns int8 as +'select $1 + $2 + $3 + $4' language sql strict immutable +-- +FUNCTION: name="sum4" function="sum4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 050 +CREATE OR REPLACE AGGREGATE sum3 (int8,int8,int8) +( + stype = int8, + sfunc = sum4 +) +-- +STMT: DefineStmt +== 051 +drop function sum4(int8,int8,int8,int8) +-- +FUNCTION: name="sum4" function="sum4" schema="" ctx=DDL +STMT: DropStmt +== 052 +DROP AGGREGATE myavg (numeric) +-- +STMT: DropStmt +== 053 +-- invalid: bad parallel-safety marking +CREATE AGGREGATE mysum (int) +( + stype = int, + sfunc = int4pl, + parallel = pear +) +-- +STMT: DefineStmt +== 054 +-- invalid: nonstrict inverse with strict forward function + +CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS +$$ SELECT $1 - $2; $$ +LANGUAGE SQL +-- +FUNCTION: name="float8mi_n" function="float8mi_n" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 055 +CREATE AGGREGATE invalidsumdouble (float8) +( + stype = float8, + sfunc = float8pl, + mstype = float8, + msfunc = float8pl, + minvfunc = float8mi_n +) +-- +STMT: DefineStmt +== 056 +-- invalid: non-matching result types + +CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS +$$ SELECT CAST($1 - $2 AS INT); $$ +LANGUAGE SQL +-- +FUNCTION: name="float8mi_int" function="float8mi_int" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 057 +CREATE AGGREGATE wrongreturntype (float8) +( + stype = float8, + sfunc = float8pl, + mstype = float8, + msfunc = float8pl, + minvfunc = float8mi_int +) +-- +STMT: DefineStmt +== 058 +-- invalid: non-lowercase quoted identifiers + +CREATE AGGREGATE case_agg ( -- old syntax + "Sfunc1" = int4pl, + "Basetype" = int4, + "Stype1" = int4, + "Initcond1" = '0', + "Parallel" = safe +) +-- +STMT: DefineStmt +== 059 +CREATE AGGREGATE case_agg(float8) +( + "Stype" = internal, + "Sfunc" = ordered_set_transition, + "Finalfunc" = percentile_disc_final, + "Finalfunc_extra" = true, + "Finalfunc_modify" = read_write, + "Parallel" = safe +) +-- +STMT: DefineStmt diff --git a/parser/testdata/summary/postgres_regress/create_am.metadata.json b/parser/testdata/summary/postgres_regress/create_am.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_am.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_am.test b/parser/testdata/summary/postgres_regress/create_am.test new file mode 100644 index 0000000..4bbe8d3 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_am.test @@ -0,0 +1,1019 @@ +== 001 +|-- +-- Create access method tests +|-- + +-- Make gist2 over gisthandler. In fact, it would be a synonym to gist. +CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler +-- +STMT: CreateAmStmt +== 002 +-- Verify return type checks for handlers +CREATE ACCESS METHOD bogus TYPE INDEX HANDLER int4in +-- +STMT: CreateAmStmt +== 003 +CREATE ACCESS METHOD bogus TYPE INDEX HANDLER heap_tableam_handler +-- +STMT: CreateAmStmt +== 004 +-- Try to create gist2 index on fast_emp4000: fail because opclass doesn't exist +CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base) +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: IndexStmt +== 005 +-- Make operator class for boxes using gist2 +CREATE OPERATOR CLASS box_ops DEFAULT + FOR TYPE box USING gist2 AS + OPERATOR 1 <<, + OPERATOR 2 &<, + OPERATOR 3 &&, + OPERATOR 4 &>, + OPERATOR 5 >>, + OPERATOR 6 ~=, + OPERATOR 7 @>, + OPERATOR 8 <@, + OPERATOR 9 &<|, + OPERATOR 10 <<|, + OPERATOR 11 |>>, + OPERATOR 12 |&>, + FUNCTION 1 gist_box_consistent(internal, box, smallint, oid, internal), + FUNCTION 2 gist_box_union(internal, internal), + -- don't need compress, decompress, or fetch functions + FUNCTION 5 gist_box_penalty(internal, internal, internal), + FUNCTION 6 gist_box_picksplit(internal, internal), + FUNCTION 7 gist_box_same(box, box, internal) +-- +STMT: CreateOpClassStmt +== 006 +-- Create gist2 index on fast_emp4000 +CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base) +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: IndexStmt +== 007 +-- Now check the results from plain indexscan; temporarily drop existing +-- index grect2ind to ensure it doesn't capture the plan +BEGIN +-- +STMT: TransactionStmt +== 008 +DROP INDEX grect2ind +-- +STMT: DropStmt +== 009 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 010 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +== 011 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 012 +EXPLAIN (COSTS OFF) +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +== 013 +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 014 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +== 015 +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 016 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +== 017 +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 018 +ROLLBACK +-- +STMT: TransactionStmt +== 019 +-- Try to drop access method: fail because of dependent objects +DROP ACCESS METHOD gist2 +-- +STMT: DropStmt +== 020 +-- Drop access method cascade +-- To prevent a (rare) deadlock against autovacuum, +-- we must lock the table that owns the index that will be dropped +BEGIN +-- +STMT: TransactionStmt +== 021 +LOCK TABLE fast_emp4000 +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: LockStmt +== 022 +DROP ACCESS METHOD gist2 CASCADE +-- +STMT: DropStmt +== 023 +COMMIT +-- +STMT: TransactionStmt +== 024 +|-- +-- Test table access methods +|-- + +-- prevent empty values +SET default_table_access_method = '' +-- +STMT: VariableSetStmt +== 025 +-- prevent nonexistent values +SET default_table_access_method = 'I do not exist AM' +-- +STMT: VariableSetStmt +== 026 +-- prevent setting it to an index AM +SET default_table_access_method = 'btree' +-- +STMT: VariableSetStmt +== 027 +-- Create a heap2 table am handler with heapam handler +CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler +-- +STMT: CreateAmStmt +== 028 +-- Verify return type checks for handlers +CREATE ACCESS METHOD bogus TYPE TABLE HANDLER int4in +-- +STMT: CreateAmStmt +== 029 +CREATE ACCESS METHOD bogus TYPE TABLE HANDLER bthandler +-- +STMT: CreateAmStmt +== 030 +SELECT amname, amhandler, amtype FROM pg_am where amtype = 't' ORDER BY 1, 2 +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FILTER: schema="" table="" column="amtype" +STMT: SelectStmt +== 031 +-- First create tables employing the new AM using USING + +-- plain CREATE TABLE +CREATE TABLE tableam_tbl_heap2(f1 int) USING heap2 +-- +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=DDL +STMT: CreateStmt +== 032 +INSERT INTO tableam_tbl_heap2 VALUES(1) +-- +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +SELECT f1 FROM tableam_tbl_heap2 ORDER BY f1 +-- +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=Select +STMT: SelectStmt +== 034 +-- CREATE TABLE AS +CREATE TABLE tableam_tblas_heap2 USING heap2 AS SELECT * FROM tableam_tbl_heap2 +-- +TABLE: name="tableam_tblas_heap2" schema="" table="tableam_tblas_heap2" ctx=DDL +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 035 +SELECT f1 FROM tableam_tbl_heap2 ORDER BY f1 +-- +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=Select +STMT: SelectStmt +== 036 +-- SELECT INTO doesn't support USING +SELECT INTO tableam_tblselectinto_heap2 USING heap2 FROM tableam_tbl_heap2 +-- +ERROR: syntax error at or near "USING" +CURSORPOS: 78 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 037 +-- CREATE VIEW doesn't support USING +CREATE VIEW tableam_view_heap2 USING heap2 AS SELECT * FROM tableam_tbl_heap2 +-- +ERROR: syntax error at or near "USING" +CURSORPOS: 69 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 038 +-- CREATE SEQUENCE doesn't support USING +CREATE SEQUENCE tableam_seq_heap2 USING heap2 +-- +ERROR: syntax error at or near "USING" +CURSORPOS: 76 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 039 +-- CREATE MATERIALIZED VIEW does support USING +CREATE MATERIALIZED VIEW tableam_tblmv_heap2 USING heap2 AS SELECT * FROM tableam_tbl_heap2 +-- +TABLE: name="tableam_tblmv_heap2" schema="" table="tableam_tblmv_heap2" ctx=DDL +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 040 +SELECT f1 FROM tableam_tblmv_heap2 ORDER BY f1 +-- +TABLE: name="tableam_tblmv_heap2" schema="" table="tableam_tblmv_heap2" ctx=Select +STMT: SelectStmt +== 041 +-- CREATE TABLE .. PARTITION BY supports USING. +CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) USING heap2 +-- +TABLE: name="tableam_parted_heap2" schema="" table="tableam_parted_heap2" ctx=DDL +STMT: CreateStmt +== 042 +SELECT a.amname FROM pg_class c, pg_am a + WHERE c.relname = 'tableam_parted_heap2' AND a.oid = c.relam +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relam" +STMT: SelectStmt +== 043 +DROP TABLE tableam_parted_heap2 +-- +TABLE: name="tableam_parted_heap2" schema="" table="tableam_parted_heap2" ctx=DDL +STMT: DropStmt +== 044 +CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) +-- +TABLE: name="tableam_parted_heap2" schema="" table="tableam_parted_heap2" ctx=DDL +STMT: CreateStmt +== 045 +-- new partitions will inherit from the current default, rather the partition root +SET default_table_access_method = 'heap' +-- +STMT: VariableSetStmt +== 046 +CREATE TABLE tableam_parted_a_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('a') +-- +TABLE: name="tableam_parted_a_heap2" schema="" table="tableam_parted_a_heap2" ctx=DDL +STMT: CreateStmt +== 047 +SET default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +== 048 +CREATE TABLE tableam_parted_b_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('b') +-- +TABLE: name="tableam_parted_b_heap2" schema="" table="tableam_parted_b_heap2" ctx=DDL +STMT: CreateStmt +== 049 +RESET default_table_access_method +-- +STMT: VariableSetStmt +== 050 +-- but the method can be explicitly specified +CREATE TABLE tableam_parted_c_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('c') USING heap +-- +TABLE: name="tableam_parted_c_heap2" schema="" table="tableam_parted_c_heap2" ctx=DDL +STMT: CreateStmt +== 051 +CREATE TABLE tableam_parted_d_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('d') USING heap2 +-- +TABLE: name="tableam_parted_d_heap2" schema="" table="tableam_parted_d_heap2" ctx=DDL +STMT: CreateStmt +== 052 +-- List all objects in AM +SELECT + pc.relkind, + pa.amname, + CASE WHEN relkind = 't' THEN + (SELECT 'toast for ' || relname::regclass FROM pg_class pcm WHERE pcm.reltoastrelid = pc.oid) + ELSE + relname::regclass::text + END COLLATE "C" AS relname +FROM pg_class AS pc, + pg_am AS pa +WHERE pa.oid = pc.relam + AND pa.amname = 'heap2' +ORDER BY 3, 1, 2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pa"="pg_am" +ALIAS: "pc"="pg_class" +ALIAS: "pcm"="pg_class" +FILTER: schema="" table="pa" column="oid" +FILTER: schema="" table="pc" column="relam" +FILTER: schema="" table="pa" column="amname" +FILTER: schema="" table="pcm" column="reltoastrelid" +FILTER: schema="" table="pc" column="oid" +STMT: SelectStmt +== 053 +-- Show dependencies onto AM - there shouldn't be any for toast +SELECT pg_describe_object(classid,objid,objsubid) AS obj +FROM pg_depend, pg_am +WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_am.amname = 'heap2' +ORDER BY classid, objid, objsubid +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_am" column="amname" +STMT: SelectStmt +== 054 +-- ALTER TABLE SET ACCESS METHOD +CREATE TABLE heaptable USING heap AS + SELECT a, repeat(a::text, 100) FROM generate_series(1,9) AS a +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 055 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +== 056 +-- Switching to heap2 adds new dependency entry to the AM. +ALTER TABLE heaptable SET ACCESS METHOD heap2 +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +== 057 +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as objref, + deptype + FROM pg_depend + WHERE classid = 'pg_class'::regclass AND + objid = 'heaptable'::regclass + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 058 +-- Switching to heap should not have a dependency entry to the AM. +ALTER TABLE heaptable SET ACCESS METHOD heap +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +== 059 +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as objref, + deptype + FROM pg_depend + WHERE classid = 'pg_class'::regclass AND + objid = 'heaptable'::regclass + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 060 +ALTER TABLE heaptable SET ACCESS METHOD heap2 +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +== 061 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +== 062 +SELECT COUNT(a), COUNT(1) FILTER(WHERE a=1) FROM heaptable +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 063 +-- DEFAULT access method +BEGIN +-- +STMT: TransactionStmt +== 064 +SET LOCAL default_table_access_method TO heap2 +-- +STMT: VariableSetStmt +== 065 +ALTER TABLE heaptable SET ACCESS METHOD DEFAULT +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +== 066 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +== 067 +SET LOCAL default_table_access_method TO heap +-- +STMT: VariableSetStmt +== 068 +ALTER TABLE heaptable SET ACCESS METHOD DEFAULT +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +== 069 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +== 070 +ROLLBACK +-- +STMT: TransactionStmt +== 071 +-- ALTER MATERIALIZED VIEW SET ACCESS METHOD +CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT * FROM heaptable +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +TABLE: name="heaptable" schema="" table="heaptable" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 072 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +== 073 +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2 +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +STMT: AlterTableStmt +== 074 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +== 075 +SELECT COUNT(a), COUNT(1) FILTER(WHERE a=1) FROM heapmv +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 076 +-- No support for multiple subcommands +ALTER TABLE heaptable SET ACCESS METHOD heap, SET ACCESS METHOD heap2 +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +== 077 +ALTER TABLE heaptable SET ACCESS METHOD DEFAULT, SET ACCESS METHOD heap2 +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +== 078 +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap, SET ACCESS METHOD heap2 +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +STMT: AlterTableStmt +== 079 +DROP MATERIALIZED VIEW heapmv +-- +STMT: DropStmt +== 080 +DROP TABLE heaptable +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: DropStmt +== 081 +-- Partitioned table with USING +CREATE TABLE am_partitioned(x INT, y INT) PARTITION BY hash (x) USING heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: CreateStmt +== 082 +SELECT pg_describe_object(classid, objid, objsubid) AS obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as refobj + FROM pg_depend, pg_am + WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_depend.objid = 'am_partitioned'::regclass +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_depend" column="objid" +STMT: SelectStmt +== 083 +DROP TABLE am_partitioned +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: DropStmt +== 084 +-- Partition hierarchies with access methods +BEGIN +-- +STMT: TransactionStmt +== 085 +SET LOCAL default_table_access_method = 'heap' +-- +STMT: VariableSetStmt +== 086 +CREATE TABLE am_partitioned(x INT, y INT) PARTITION BY hash (x) +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: CreateStmt +== 087 +-- pg_class.relam is 0, no dependency recorded between the AM and the +-- partitioned table. +SELECT relam FROM pg_class WHERE relname = 'am_partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 088 +SELECT pg_describe_object(classid, objid, objsubid) AS obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as refobj + FROM pg_depend, pg_am + WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_depend.objid = 'am_partitioned'::regclass +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_depend" column="objid" +STMT: SelectStmt +== 089 +-- New default is set, with dependency added. +ALTER TABLE am_partitioned SET ACCESS METHOD heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +== 090 +SELECT a.amname FROM pg_class c, pg_am a + WHERE c.relname = 'am_partitioned' AND a.oid = c.relam +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relam" +STMT: SelectStmt +== 091 +SELECT pg_describe_object(classid, objid, objsubid) AS obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as refobj + FROM pg_depend, pg_am + WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_depend.objid = 'am_partitioned'::regclass +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_depend" column="objid" +STMT: SelectStmt +== 092 +-- Default is set, with dependency updated. +SET LOCAL default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +== 093 +ALTER TABLE am_partitioned SET ACCESS METHOD heap +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +== 094 +SELECT a.amname FROM pg_class c, pg_am a + WHERE c.relname = 'am_partitioned' AND a.oid = c.relam +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relam" +STMT: SelectStmt +== 095 +-- Dependency pinned, hence removed. +SELECT pg_describe_object(classid, objid, objsubid) AS obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as refobj + FROM pg_depend, pg_am + WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_depend.objid = 'am_partitioned'::regclass +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_depend" column="objid" +STMT: SelectStmt +== 096 +-- Default and AM set in the clause are the same, relam should be set. +SET LOCAL default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +== 097 +ALTER TABLE am_partitioned SET ACCESS METHOD heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +== 098 +SELECT a.amname FROM pg_class c, pg_am a + WHERE c.relname = 'am_partitioned' AND a.oid = c.relam +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relam" +STMT: SelectStmt +== 099 +-- Reset to default +ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +== 100 +SELECT relam FROM pg_class WHERE relname = 'am_partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 101 +-- Upon ALTER TABLE SET ACCESS METHOD on a partitioned table, new partitions +-- will inherit the AM set. Existing partitioned are unchanged. +SELECT relam FROM pg_class WHERE relname = 'am_partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 102 +SET LOCAL default_table_access_method = 'heap' +-- +STMT: VariableSetStmt +== 103 +CREATE TABLE am_partitioned_0 PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 0) +-- +TABLE: name="am_partitioned_0" schema="" table="am_partitioned_0" ctx=DDL +STMT: CreateStmt +== 104 +SET LOCAL default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +== 105 +CREATE TABLE am_partitioned_1 PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="am_partitioned_1" schema="" table="am_partitioned_1" ctx=DDL +STMT: CreateStmt +== 106 +SET LOCAL default_table_access_method = 'heap' +-- +STMT: VariableSetStmt +== 107 +ALTER TABLE am_partitioned SET ACCESS METHOD heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +== 108 +CREATE TABLE am_partitioned_2 PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 2) +-- +TABLE: name="am_partitioned_2" schema="" table="am_partitioned_2" ctx=DDL +STMT: CreateStmt +== 109 +ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +== 110 +SELECT relam FROM pg_class WHERE relname = 'am_partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 111 +CREATE TABLE am_partitioned_3 PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 3) +-- +TABLE: name="am_partitioned_3" schema="" table="am_partitioned_3" ctx=DDL +STMT: CreateStmt +== 112 +-- Partitioned table with relam at 0 +ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +== 113 +CREATE TABLE am_partitioned_5p PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 5) PARTITION BY hash(y) +-- +TABLE: name="am_partitioned_5p" schema="" table="am_partitioned_5p" ctx=DDL +STMT: CreateStmt +== 114 +-- Partitions of this partitioned table inherit default AM at creation +-- time. +CREATE TABLE am_partitioned_5p1 PARTITION OF am_partitioned_5p + FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="am_partitioned_5p1" schema="" table="am_partitioned_5p1" ctx=DDL +STMT: CreateStmt +== 115 +-- Partitioned table with relam set. +ALTER TABLE am_partitioned SET ACCESS METHOD heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +== 116 +CREATE TABLE am_partitioned_6p PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 6) PARTITION BY hash(y) +-- +TABLE: name="am_partitioned_6p" schema="" table="am_partitioned_6p" ctx=DDL +STMT: CreateStmt +== 117 +-- Partitions of this partitioned table inherit its AM. +CREATE TABLE am_partitioned_6p1 PARTITION OF am_partitioned_6p + FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="am_partitioned_6p1" schema="" table="am_partitioned_6p1" ctx=DDL +STMT: CreateStmt +== 118 +SELECT c.relname, a.amname FROM pg_class c, pg_am a + WHERE c.relam = a.oid AND + c.relname LIKE 'am_partitioned%' +UNION ALL +SELECT c.relname, 'default' FROM pg_class c + WHERE c.relam = 0 + AND c.relname LIKE 'am_partitioned%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +== 119 +DROP TABLE am_partitioned +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: DropStmt +== 120 +COMMIT +-- +STMT: TransactionStmt +== 121 +-- Second, create objects in the new AM by changing the default AM +BEGIN +-- +STMT: TransactionStmt +== 122 +SET LOCAL default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +== 123 +-- following tests should all respect the default AM +CREATE TABLE tableam_tbl_heapx(f1 int) +-- +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=DDL +STMT: CreateStmt +== 124 +CREATE TABLE tableam_tblas_heapx AS SELECT * FROM tableam_tbl_heapx +-- +TABLE: name="tableam_tblas_heapx" schema="" table="tableam_tblas_heapx" ctx=DDL +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 125 +SELECT INTO tableam_tblselectinto_heapx FROM tableam_tbl_heapx +-- +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=Select +TABLE: name="tableam_tblselectinto_heapx" schema="" table="tableam_tblselectinto_heapx" ctx=DDL +STMT: SelectStmt +== 126 +CREATE MATERIALIZED VIEW tableam_tblmv_heapx USING heap2 AS SELECT * FROM tableam_tbl_heapx +-- +TABLE: name="tableam_tblmv_heapx" schema="" table="tableam_tblmv_heapx" ctx=DDL +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 127 +CREATE TABLE tableam_parted_heapx (a text, b int) PARTITION BY list (a) +-- +TABLE: name="tableam_parted_heapx" schema="" table="tableam_parted_heapx" ctx=DDL +STMT: CreateStmt +== 128 +CREATE TABLE tableam_parted_1_heapx PARTITION OF tableam_parted_heapx FOR VALUES IN ('a', 'b') +-- +TABLE: name="tableam_parted_1_heapx" schema="" table="tableam_parted_1_heapx" ctx=DDL +STMT: CreateStmt +== 129 +-- but an explicitly set AM overrides it +CREATE TABLE tableam_parted_2_heapx PARTITION OF tableam_parted_heapx FOR VALUES IN ('c', 'd') USING heap +-- +TABLE: name="tableam_parted_2_heapx" schema="" table="tableam_parted_2_heapx" ctx=DDL +STMT: CreateStmt +== 130 +-- sequences, views and foreign servers shouldn't have an AM +CREATE VIEW tableam_view_heapx AS SELECT * FROM tableam_tbl_heapx +-- +TABLE: name="tableam_view_heapx" schema="" table="tableam_view_heapx" ctx=DDL +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 131 +CREATE SEQUENCE tableam_seq_heapx +-- +STMT: CreateSeqStmt +== 132 +CREATE FOREIGN DATA WRAPPER fdw_heap2 VALIDATOR postgresql_fdw_validator +-- +STMT: CreateFdwStmt +== 133 +CREATE SERVER fs_heap2 FOREIGN DATA WRAPPER fdw_heap2 +-- +STMT: CreateForeignServerStmt +== 134 +CREATE FOREIGN table tableam_fdw_heapx () SERVER fs_heap2 +-- +STMT: CreateForeignTableStmt +== 135 +-- Verify that new AM was used for tables, matviews, but not for sequences, views and fdws +SELECT + pc.relkind, + pa.amname, + CASE WHEN relkind = 't' THEN + (SELECT 'toast for ' || relname::regclass FROM pg_class pcm WHERE pcm.reltoastrelid = pc.oid) + ELSE + relname::regclass::text + END COLLATE "C" AS relname +FROM pg_class AS pc + LEFT JOIN pg_am AS pa ON (pa.oid = pc.relam) +WHERE pc.relname LIKE 'tableam_%_heapx' +ORDER BY 3, 1, 2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pa"="pg_am" +ALIAS: "pc"="pg_class" +ALIAS: "pcm"="pg_class" +FILTER: schema="" table="pc" column="relname" +FILTER: schema="" table="pcm" column="reltoastrelid" +FILTER: schema="" table="pc" column="oid" +STMT: SelectStmt +== 136 +-- don't want to keep those tables, nor the default +ROLLBACK +-- +STMT: TransactionStmt +== 137 +-- Third, check that we can neither create a table using a nonexistent +-- AM, nor using an index AM +CREATE TABLE i_am_a_failure() USING "notempty" +-- +TABLE: name="i_am_a_failure" schema="" table="i_am_a_failure" ctx=DDL +STMT: CreateStmt +== 138 +CREATE TABLE i_am_a_failure() USING i_do_not_exist_am +-- +TABLE: name="i_am_a_failure" schema="" table="i_am_a_failure" ctx=DDL +STMT: CreateStmt +== 139 +CREATE TABLE i_am_a_failure() USING "I do not exist AM" +-- +TABLE: name="i_am_a_failure" schema="" table="i_am_a_failure" ctx=DDL +STMT: CreateStmt +== 140 +CREATE TABLE i_am_a_failure() USING "btree" +-- +TABLE: name="i_am_a_failure" schema="" table="i_am_a_failure" ctx=DDL +STMT: CreateStmt +== 141 +-- Other weird invalid cases that cause problems +CREATE FOREIGN TABLE fp PARTITION OF tableam_parted_a_heap2 DEFAULT SERVER x +-- +STMT: CreateForeignTableStmt +== 142 +-- Drop table access method, which fails as objects depends on it +DROP ACCESS METHOD heap2 +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/create_cast.metadata.json b/parser/testdata/summary/postgres_regress/create_cast.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_cast.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_cast.test b/parser/testdata/summary/postgres_regress/create_cast.test new file mode 100644 index 0000000..65bc7cc --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_cast.test @@ -0,0 +1,166 @@ +== 001 +|-- +-- CREATE_CAST +|-- + +-- Create some types to test with +CREATE TYPE casttesttype +-- +STMT: DefineStmt +== 002 +CREATE FUNCTION casttesttype_in(cstring) + RETURNS casttesttype + AS 'textin' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="casttesttype_in" function="casttesttype_in" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +CREATE FUNCTION casttesttype_out(casttesttype) + RETURNS cstring + AS 'textout' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="casttesttype_out" function="casttesttype_out" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 004 +CREATE TYPE casttesttype ( + internallength = variable, + input = casttesttype_in, + output = casttesttype_out, + alignment = int4 +) +-- +STMT: DefineStmt +== 005 +-- a dummy function to test with +CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQL AS +$$ SELECT 1; $$ +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +SELECT casttestfunc('foo'::text) +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- fails, as there's no cast + +-- Try binary coercion cast +CREATE CAST (text AS casttesttype) WITHOUT FUNCTION +-- +STMT: CreateCastStmt +== 008 +SELECT casttestfunc('foo'::text) +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- doesn't work, as the cast is explicit +SELECT casttestfunc('foo'::text::casttesttype) +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=Call +STMT: SelectStmt +== 010 +-- should work +DROP CAST (text AS casttesttype) +-- +STMT: DropStmt +== 011 +-- cleanup + +-- Try IMPLICIT binary coercion cast +CREATE CAST (text AS casttesttype) WITHOUT FUNCTION AS IMPLICIT +-- +STMT: CreateCastStmt +== 012 +SELECT casttestfunc('foo'::text) +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- Should work now + +-- Try I/O conversion cast. +SELECT 1234::int4::casttesttype +-- +STMT: SelectStmt +== 014 +-- No cast yet, should fail + +CREATE CAST (int4 AS casttesttype) WITH INOUT +-- +STMT: CreateCastStmt +== 015 +SELECT 1234::int4::casttesttype +-- +STMT: SelectStmt +== 016 +-- Should work now + +DROP CAST (int4 AS casttesttype) +-- +STMT: DropStmt +== 017 +-- Try cast with a function + +CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQL AS +$$ SELECT ('foo'::text || $1::text)::casttesttype; $$ +-- +FUNCTION: name="int4_casttesttype" function="int4_casttesttype" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 018 +CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT +-- +STMT: CreateCastStmt +== 019 +SELECT 1234::int4::casttesttype +-- +STMT: SelectStmt +== 020 +-- Should work now + +DROP FUNCTION int4_casttesttype(int4) CASCADE +-- +FUNCTION: name="int4_casttesttype" function="int4_casttesttype" schema="" ctx=DDL +STMT: DropStmt +== 021 +-- Try it with a function that requires an implicit cast + +CREATE FUNCTION bar_int4_text(int4) RETURNS text LANGUAGE SQL AS +$$ SELECT ('bar'::text || $1::text); $$ +-- +FUNCTION: name="bar_int4_text" function="bar_int4_text" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 022 +CREATE CAST (int4 AS casttesttype) WITH FUNCTION bar_int4_text(int4) AS IMPLICIT +-- +STMT: CreateCastStmt +== 023 +SELECT 1234::int4::casttesttype +-- +STMT: SelectStmt +== 024 +-- Should work now + +-- check dependencies generated for that +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_cast'::regclass AND + objid = (SELECT oid FROM pg_cast + WHERE castsource = 'int4'::regtype + AND casttarget = 'casttesttype'::regtype) +ORDER BY refclassid +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +FILTER: schema="" table="" column="castsource" +FILTER: schema="" table="" column="casttarget" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/create_function_c.metadata.json b/parser/testdata/summary/postgres_regress/create_function_c.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_function_c.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_function_c.test b/parser/testdata/summary/postgres_regress/create_function_c.test new file mode 100644 index 0000000..8826f11 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_function_c.test @@ -0,0 +1,53 @@ +== 001 +|-- +-- CREATE_FUNCTION_C +|-- +-- This script used to create C functions for other scripts to use. +-- But to get rid of the ordering dependencies that caused, such +-- functions are now made either in test_setup.sql or in the specific +-- test script that needs them. All that remains here is error cases. + +-- directory path and dlsuffix are passed to us in environment variables + + +|-- +-- Check LOAD command. (The alternative of implicitly loading the library +-- is checked in many other test scripts.) +|-- +LOAD :'regresslib' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 507 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- Things that shouldn't work: + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C + AS 'nosuchfile' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +-- To produce stable regression test output, we have to filter the name +-- of the regresslib file out of the error message in this test. +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C + AS :'regresslib', 'nosuchsymbol' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 196 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +SELECT regexp_replace(:'LAST_ERROR_MESSAGE', 'file ".*"', 'file "..."') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal + AS 'nosuch' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt diff --git a/parser/testdata/summary/postgres_regress/create_function_sql.metadata.json b/parser/testdata/summary/postgres_regress/create_function_sql.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_function_sql.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_function_sql.test b/parser/testdata/summary/postgres_regress/create_function_sql.test new file mode 100644 index 0000000..daeb174 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_function_sql.test @@ -0,0 +1,985 @@ +== 001 +|-- +-- CREATE_FUNCTION_SQL +|-- +-- Assorted tests using SQL-language functions +|-- + +-- All objects made in this test are in temp_func_test schema + +CREATE USER regress_unpriv_user +-- +STMT: CreateRoleStmt +== 002 +CREATE SCHEMA temp_func_test +-- +STMT: CreateSchemaStmt +== 003 +GRANT ALL ON SCHEMA temp_func_test TO public +-- +STMT: GrantStmt +== 004 +SET search_path TO temp_func_test, public +-- +STMT: VariableSetStmt +== 005 +|-- +-- Make sanity checks on the pg_proc entries created by CREATE FUNCTION +|-- + +|-- +-- ARGUMENT and RETURN TYPES +|-- +CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''' +-- +FUNCTION: name="functest_a_1" function="functest_a_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql' + AS 'SELECT $1[1]::int' +-- +FUNCTION: name="functest_a_2" function="functest_a_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 007 +CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql' + AS 'SELECT false' +-- +FUNCTION: name="functest_a_3" function="functest_a_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 008 +SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc + WHERE oid in ('functest_A_1'::regproc, + 'functest_A_2'::regproc, + 'functest_A_3'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 009 +SELECT functest_A_1('abcd', '2020-01-01') +-- +FUNCTION: name="functest_a_1" function="functest_a_1" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT functest_A_2(ARRAY['1', '2', '3']) +-- +FUNCTION: name="functest_a_2" function="functest_a_2" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT functest_A_3() +-- +FUNCTION: name="functest_a_3" function="functest_a_3" schema="" ctx=Call +STMT: SelectStmt +== 012 +|-- +-- IMMUTABLE | STABLE | VOLATILE +|-- +CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 > 0' +-- +FUNCTION: name="functest_b_1" function="functest_b_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 013 +CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sql' + IMMUTABLE AS 'SELECT $1 > 0' +-- +FUNCTION: name="functest_b_2" function="functest_b_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 014 +CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sql' + STABLE AS 'SELECT $1 = 0' +-- +FUNCTION: name="functest_b_3" function="functest_b_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 015 +CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sql' + VOLATILE AS 'SELECT $1 < 0' +-- +FUNCTION: name="functest_b_4" function="functest_b_4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 016 +SELECT proname, provolatile FROM pg_proc + WHERE oid in ('functest_B_1'::regproc, + 'functest_B_2'::regproc, + 'functest_B_3'::regproc, + 'functest_B_4'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 017 +ALTER FUNCTION functest_B_2(int) VOLATILE +-- +STMT: AlterFunctionStmt +== 018 +ALTER FUNCTION functest_B_3(int) COST 100 +-- +STMT: AlterFunctionStmt +== 019 +-- unrelated change, no effect +SELECT proname, provolatile FROM pg_proc + WHERE oid in ('functest_B_1'::regproc, + 'functest_B_2'::regproc, + 'functest_B_3'::regproc, + 'functest_B_4'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 020 +|-- +-- SECURITY DEFINER | INVOKER +|-- +CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 > 0' +-- +FUNCTION: name="functest_c_1" function="functest_c_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 021 +CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql' + SECURITY DEFINER AS 'SELECT $1 = 0' +-- +FUNCTION: name="functest_c_2" function="functest_c_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 022 +CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql' + SECURITY INVOKER AS 'SELECT $1 < 0' +-- +FUNCTION: name="functest_c_3" function="functest_c_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 023 +SELECT proname, prosecdef FROM pg_proc + WHERE oid in ('functest_C_1'::regproc, + 'functest_C_2'::regproc, + 'functest_C_3'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 024 +ALTER FUNCTION functest_C_1(int) IMMUTABLE +-- +STMT: AlterFunctionStmt +== 025 +-- unrelated change, no effect +ALTER FUNCTION functest_C_2(int) SECURITY INVOKER +-- +STMT: AlterFunctionStmt +== 026 +ALTER FUNCTION functest_C_3(int) SECURITY DEFINER +-- +STMT: AlterFunctionStmt +== 027 +SELECT proname, prosecdef FROM pg_proc + WHERE oid in ('functest_C_1'::regproc, + 'functest_C_2'::regproc, + 'functest_C_3'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 028 +|-- +-- LEAKPROOF +|-- +CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 > 100' +-- +FUNCTION: name="functest_e_1" function="functest_e_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql' + LEAKPROOF AS 'SELECT $1 > 100' +-- +FUNCTION: name="functest_e_2" function="functest_e_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 030 +SELECT proname, proleakproof FROM pg_proc + WHERE oid in ('functest_E_1'::regproc, + 'functest_E_2'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 031 +ALTER FUNCTION functest_E_1(int) LEAKPROOF +-- +STMT: AlterFunctionStmt +== 032 +ALTER FUNCTION functest_E_2(int) STABLE +-- +STMT: AlterFunctionStmt +== 033 +-- unrelated change, no effect +SELECT proname, proleakproof FROM pg_proc + WHERE oid in ('functest_E_1'::regproc, + 'functest_E_2'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 034 +ALTER FUNCTION functest_E_2(int) NOT LEAKPROOF +-- +STMT: AlterFunctionStmt +== 035 +-- remove leakproof attribute +SELECT proname, proleakproof FROM pg_proc + WHERE oid in ('functest_E_1'::regproc, + 'functest_E_2'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 036 +-- it takes superuser privilege to turn on leakproof, but not to turn off +ALTER FUNCTION functest_E_1(int) OWNER TO regress_unpriv_user +-- +STMT: AlterOwnerStmt +== 037 +ALTER FUNCTION functest_E_2(int) OWNER TO regress_unpriv_user +-- +STMT: AlterOwnerStmt +== 038 +SET SESSION AUTHORIZATION regress_unpriv_user +-- +STMT: VariableSetStmt +== 039 +SET search_path TO temp_func_test, public +-- +STMT: VariableSetStmt +== 040 +ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF +-- +STMT: AlterFunctionStmt +== 041 +ALTER FUNCTION functest_E_2(int) LEAKPROOF +-- +STMT: AlterFunctionStmt +== 042 +CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql' + LEAKPROOF AS 'SELECT $1 < 200' +-- +FUNCTION: name="functest_e_3" function="functest_e_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 043 +-- fail + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 044 +|-- +-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT +|-- +CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 > 50' +-- +FUNCTION: name="functest_f_1" function="functest_f_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 045 +CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql' + CALLED ON NULL INPUT AS 'SELECT $1 = 50' +-- +FUNCTION: name="functest_f_2" function="functest_f_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 046 +CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql' + RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50' +-- +FUNCTION: name="functest_f_3" function="functest_f_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 047 +CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql' + STRICT AS 'SELECT $1 = 50' +-- +FUNCTION: name="functest_f_4" function="functest_f_4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 048 +SELECT proname, proisstrict FROM pg_proc + WHERE oid in ('functest_F_1'::regproc, + 'functest_F_2'::regproc, + 'functest_F_3'::regproc, + 'functest_F_4'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 049 +ALTER FUNCTION functest_F_1(int) IMMUTABLE +-- +STMT: AlterFunctionStmt +== 050 +-- unrelated change, no effect +ALTER FUNCTION functest_F_2(int) STRICT +-- +STMT: AlterFunctionStmt +== 051 +ALTER FUNCTION functest_F_3(int) CALLED ON NULL INPUT +-- +STMT: AlterFunctionStmt +== 052 +SELECT proname, proisstrict FROM pg_proc + WHERE oid in ('functest_F_1'::regproc, + 'functest_F_2'::regproc, + 'functest_F_3'::regproc, + 'functest_F_4'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 053 +-- pg_get_functiondef tests + +SELECT pg_get_functiondef('functest_A_1'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 054 +SELECT pg_get_functiondef('functest_B_3'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 055 +SELECT pg_get_functiondef('functest_C_3'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 056 +SELECT pg_get_functiondef('functest_F_2'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 057 +|-- +-- SQL-standard body +|-- +CREATE FUNCTION functest_S_1(a text, b date) RETURNS boolean + LANGUAGE SQL + RETURN a = 'abcd' AND b > '2001-01-01' +-- +FUNCTION: name="functest_s_1" function="functest_s_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 058 +CREATE FUNCTION functest_S_2(a text[]) RETURNS int + RETURN a[1]::int +-- +FUNCTION: name="functest_s_2" function="functest_s_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 059 +CREATE FUNCTION functest_S_3() RETURNS boolean + RETURN false +-- +FUNCTION: name="functest_s_3" function="functest_s_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 060 +CREATE FUNCTION functest_S_3a() RETURNS boolean + BEGIN ATOMIC +-- +ERROR: syntax error at end of input +CURSORPOS: 65 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 061 +RETURN false +-- +ERROR: syntax error at or near "RETURN" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 062 +END +-- +STMT: TransactionStmt +== 063 +CREATE FUNCTION functest_S_10(a text, b date) RETURNS boolean + LANGUAGE SQL + BEGIN ATOMIC + SELECT a = 'abcd' AND b > '2001-01-01' +-- +ERROR: syntax error at end of input +CURSORPOS: 143 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 064 +END +-- +STMT: TransactionStmt +== 065 +CREATE FUNCTION functest_S_13() RETURNS boolean + BEGIN ATOMIC + SELECT 1 +-- +ERROR: syntax error at end of input +CURSORPOS: 82 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 066 +SELECT false +-- +STMT: SelectStmt +== 067 +END +-- +STMT: TransactionStmt +== 068 +-- check display of function arguments in sub-SELECT +CREATE TABLE functest1 (i int) +-- +TABLE: name="functest1" schema="" table="functest1" ctx=DDL +STMT: CreateStmt +== 069 +CREATE FUNCTION functest_S_16(a int, b int) RETURNS void + LANGUAGE SQL + BEGIN ATOMIC + INSERT INTO functest1 SELECT a + $2 +-- +ERROR: syntax error at end of input +CURSORPOS: 135 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 070 +END +-- +STMT: TransactionStmt +== 071 +-- error: duplicate function body +CREATE FUNCTION functest_S_xxx(x int) RETURNS int + LANGUAGE SQL + AS $$ SELECT x * 2 $$ + RETURN x * 3 +-- +FUNCTION: name="functest_s_xxx" function="functest_s_xxx" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 072 +-- polymorphic arguments not allowed in this form +CREATE FUNCTION functest_S_xx(x anyarray) RETURNS anyelement + LANGUAGE SQL + RETURN x[1] +-- +FUNCTION: name="functest_s_xx" function="functest_s_xx" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 073 +-- check reporting of parse-analysis errors +CREATE FUNCTION functest_S_xx(x date) RETURNS boolean + LANGUAGE SQL + RETURN x > 1 +-- +FUNCTION: name="functest_s_xx" function="functest_s_xx" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 074 +-- tricky parsing +CREATE FUNCTION functest_S_15(x int) RETURNS boolean +LANGUAGE SQL +BEGIN ATOMIC + select case when x % 2 = 0 then true else false end +-- +ERROR: syntax error at end of input +CURSORPOS: 153 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 075 +END +-- +STMT: TransactionStmt +== 076 +SELECT functest_S_1('abcd', '2020-01-01') +-- +FUNCTION: name="functest_s_1" function="functest_s_1" schema="" ctx=Call +STMT: SelectStmt +== 077 +SELECT functest_S_2(ARRAY['1', '2', '3']) +-- +FUNCTION: name="functest_s_2" function="functest_s_2" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT functest_S_3() +-- +FUNCTION: name="functest_s_3" function="functest_s_3" schema="" ctx=Call +STMT: SelectStmt +== 079 +SELECT functest_S_10('abcd', '2020-01-01') +-- +FUNCTION: name="functest_s_10" function="functest_s_10" schema="" ctx=Call +STMT: SelectStmt +== 080 +SELECT functest_S_13() +-- +FUNCTION: name="functest_s_13" function="functest_s_13" schema="" ctx=Call +STMT: SelectStmt +== 081 +SELECT pg_get_functiondef('functest_S_1'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT pg_get_functiondef('functest_S_2'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT pg_get_functiondef('functest_S_3'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 084 +SELECT pg_get_functiondef('functest_S_3a'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 085 +SELECT pg_get_functiondef('functest_S_10'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT pg_get_functiondef('functest_S_13'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 087 +SELECT pg_get_functiondef('functest_S_15'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 088 +SELECT pg_get_functiondef('functest_S_16'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 089 +DROP TABLE functest1 CASCADE +-- +TABLE: name="functest1" schema="" table="functest1" ctx=DDL +STMT: DropStmt +== 090 +-- test with views +CREATE TABLE functest3 (a int) +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DDL +STMT: CreateStmt +== 091 +INSERT INTO functest3 VALUES (1), (2) +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +CREATE VIEW functestv3 AS SELECT * FROM functest3 +-- +TABLE: name="functestv3" schema="" table="functestv3" ctx=DDL +TABLE: name="functest3" schema="" table="functest3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 093 +CREATE FUNCTION functest_S_14() RETURNS bigint + RETURN (SELECT count(*) FROM functestv3) +-- +FUNCTION: name="functest_s_14" function="functest_s_14" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 094 +SELECT functest_S_14() +-- +FUNCTION: name="functest_s_14" function="functest_s_14" schema="" ctx=Call +STMT: SelectStmt +== 095 +DROP TABLE functest3 CASCADE +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DDL +STMT: DropStmt +== 096 +-- information_schema tests + +CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo') + RETURNS int + LANGUAGE SQL + AS 'SELECT $1 + $2' +-- +FUNCTION: name="functest_is_1" function="functest_is_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 097 +CREATE FUNCTION functest_IS_2(out a int, b int default 1) + RETURNS int + LANGUAGE SQL + AS 'SELECT $1' +-- +FUNCTION: name="functest_is_2" function="functest_is_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 098 +CREATE FUNCTION functest_IS_3(a int default 1, out b int) + RETURNS int + LANGUAGE SQL + AS 'SELECT $1' +-- +FUNCTION: name="functest_is_3" function="functest_is_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 099 +SELECT routine_name, ordinal_position, parameter_name, parameter_default + FROM information_schema.parameters JOIN information_schema.routines USING (specific_schema, specific_name) + WHERE routine_schema = 'temp_func_test' AND routine_name ~ '^functest_is_' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.parameters" schema="information_schema" table="parameters" ctx=Select +TABLE: name="information_schema.routines" schema="information_schema" table="routines" ctx=Select +FILTER: schema="" table="" column="routine_schema" +FILTER: schema="" table="" column="routine_name" +STMT: SelectStmt +== 100 +DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int) +-- +FUNCTION: name="functest_is_1" function="functest_is_1" schema="" ctx=DDL +STMT: DropStmt +== 101 +-- routine usage views + +CREATE FUNCTION functest_IS_4a() RETURNS int LANGUAGE SQL AS 'SELECT 1' +-- +FUNCTION: name="functest_is_4a" function="functest_is_4a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 102 +CREATE FUNCTION functest_IS_4b(x int DEFAULT functest_IS_4a()) RETURNS int LANGUAGE SQL AS 'SELECT x' +-- +FUNCTION: name="functest_is_4b" function="functest_is_4b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 103 +CREATE SEQUENCE functest1 +-- +STMT: CreateSeqStmt +== 104 +CREATE FUNCTION functest_IS_5(x int DEFAULT nextval('functest1')) + RETURNS int + LANGUAGE SQL + AS 'SELECT x' +-- +FUNCTION: name="functest_is_5" function="functest_is_5" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 105 +CREATE FUNCTION functest_IS_6() + RETURNS int + LANGUAGE SQL + RETURN nextval('functest1') +-- +FUNCTION: name="functest_is_6" function="functest_is_6" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 106 +CREATE TABLE functest2 (a int, b int) +-- +TABLE: name="functest2" schema="" table="functest2" ctx=DDL +STMT: CreateStmt +== 107 +CREATE FUNCTION functest_IS_7() + RETURNS int + LANGUAGE SQL + RETURN (SELECT count(a) FROM functest2) +-- +FUNCTION: name="functest_is_7" function="functest_is_7" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 108 +SELECT r0.routine_name, r1.routine_name + FROM information_schema.routine_routine_usage rru + JOIN information_schema.routines r0 ON r0.specific_name = rru.specific_name + JOIN information_schema.routines r1 ON r1.specific_name = rru.routine_name + WHERE r0.routine_schema = 'temp_func_test' AND + r1.routine_schema = 'temp_func_test' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.routine_routine_usage" schema="information_schema" table="routine_routine_usage" ctx=Select +TABLE: name="information_schema.routines" schema="information_schema" table="routines" ctx=Select +TABLE: name="information_schema.routines" schema="information_schema" table="routines" ctx=Select +ALIAS: "r0"="information_schema.routines" +ALIAS: "r1"="information_schema.routines" +ALIAS: "rru"="information_schema.routine_routine_usage" +FILTER: schema="" table="r0" column="routine_schema" +FILTER: schema="" table="r1" column="routine_schema" +STMT: SelectStmt +== 109 +SELECT routine_name, sequence_name FROM information_schema.routine_sequence_usage + WHERE routine_schema = 'temp_func_test' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.routine_sequence_usage" schema="information_schema" table="routine_sequence_usage" ctx=Select +FILTER: schema="" table="" column="routine_schema" +STMT: SelectStmt +== 110 +SELECT routine_name, table_name, column_name FROM information_schema.routine_column_usage + WHERE routine_schema = 'temp_func_test' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.routine_column_usage" schema="information_schema" table="routine_column_usage" ctx=Select +FILTER: schema="" table="" column="routine_schema" +STMT: SelectStmt +== 111 +SELECT routine_name, table_name FROM information_schema.routine_table_usage + WHERE routine_schema = 'temp_func_test' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.routine_table_usage" schema="information_schema" table="routine_table_usage" ctx=Select +FILTER: schema="" table="" column="routine_schema" +STMT: SelectStmt +== 112 +DROP FUNCTION functest_IS_4a CASCADE +-- +FUNCTION: name="functest_is_4a" function="functest_is_4a" schema="" ctx=DDL +STMT: DropStmt +== 113 +DROP SEQUENCE functest1 CASCADE +-- +STMT: DropStmt +== 114 +DROP TABLE functest2 CASCADE +-- +TABLE: name="functest2" schema="" table="functest2" ctx=DDL +STMT: DropStmt +== 115 +-- overload +CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sql' + IMMUTABLE AS 'SELECT $1 > 0' +-- +FUNCTION: name="functest_b_2" function="functest_b_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 116 +DROP FUNCTION functest_b_1 +-- +FUNCTION: name="functest_b_1" function="functest_b_1" schema="" ctx=DDL +STMT: DropStmt +== 117 +DROP FUNCTION functest_b_1 +-- +FUNCTION: name="functest_b_1" function="functest_b_1" schema="" ctx=DDL +STMT: DropStmt +== 118 +-- error, not found +DROP FUNCTION functest_b_2 +-- +FUNCTION: name="functest_b_2" function="functest_b_2" schema="" ctx=DDL +STMT: DropStmt +== 119 +-- error, ambiguous + + +-- CREATE OR REPLACE tests + +CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL AS 'SELECT $1' +-- +FUNCTION: name="functest1" function="functest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 120 +CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL WINDOW AS 'SELECT $1' +-- +FUNCTION: name="functest1" function="functest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 121 +CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQL AS 'SELECT $1' +-- +FUNCTION: name="functest1" function="functest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 122 +DROP FUNCTION functest1(a int) +-- +FUNCTION: name="functest1" function="functest1" schema="" ctx=DDL +STMT: DropStmt +== 123 +-- inlining of set-returning functions + +CREATE TABLE functest3 (a int) +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DDL +STMT: CreateStmt +== 124 +INSERT INTO functest3 VALUES (1), (2), (3) +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 125 +CREATE FUNCTION functest_sri1() RETURNS SETOF int +LANGUAGE SQL +STABLE +AS ' + SELECT * FROM functest3; +' +-- +FUNCTION: name="functest_sri1" function="functest_sri1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 126 +SELECT * FROM functest_sri1() +-- +FUNCTION: name="functest_sri1" function="functest_sri1" schema="" ctx=Call +STMT: SelectStmt +== 127 +EXPLAIN (verbose, costs off) SELECT * FROM functest_sri1() +-- +FUNCTION: name="functest_sri1" function="functest_sri1" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 128 +CREATE FUNCTION functest_sri2() RETURNS SETOF int +LANGUAGE SQL +STABLE +BEGIN ATOMIC + SELECT * FROM functest3 +-- +ERROR: syntax error at end of input +CURSORPOS: 111 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 129 +END +-- +STMT: TransactionStmt +== 130 +SELECT * FROM functest_sri2() +-- +FUNCTION: name="functest_sri2" function="functest_sri2" schema="" ctx=Call +STMT: SelectStmt +== 131 +EXPLAIN (verbose, costs off) SELECT * FROM functest_sri2() +-- +FUNCTION: name="functest_sri2" function="functest_sri2" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 132 +DROP TABLE functest3 CASCADE +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DDL +STMT: DropStmt +== 133 +-- Check behavior of VOID-returning SQL functions + +CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQL AS +$$ SELECT a + 1 $$ +-- +FUNCTION: name="voidtest1" function="voidtest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 134 +SELECT voidtest1(42) +-- +FUNCTION: name="voidtest1" function="voidtest1" schema="" ctx=Call +STMT: SelectStmt +== 135 +CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQL AS +$$ SELECT voidtest1(a + b) $$ +-- +FUNCTION: name="voidtest2" function="voidtest2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 136 +SELECT voidtest2(11,22) +-- +FUNCTION: name="voidtest2" function="voidtest2" schema="" ctx=Call +STMT: SelectStmt +== 137 +-- currently, we can inline voidtest2 but not voidtest1 +EXPLAIN (verbose, costs off) SELECT voidtest2(11,22) +-- +FUNCTION: name="voidtest2" function="voidtest2" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 138 +CREATE TEMP TABLE sometable(f1 int) +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DDL +STMT: CreateStmt +== 139 +CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQL AS +$$ INSERT INTO sometable VALUES(a + 1) $$ +-- +FUNCTION: name="voidtest3" function="voidtest3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 140 +SELECT voidtest3(17) +-- +FUNCTION: name="voidtest3" function="voidtest3" schema="" ctx=Call +STMT: SelectStmt +== 141 +CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQL AS +$$ INSERT INTO sometable VALUES(a - 1) RETURNING f1 $$ +-- +FUNCTION: name="voidtest4" function="voidtest4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 142 +SELECT voidtest4(39) +-- +FUNCTION: name="voidtest4" function="voidtest4" schema="" ctx=Call +STMT: SelectStmt +== 143 +TABLE sometable +-- +TABLE: name="sometable" schema="" table="sometable" ctx=Select +STMT: SelectStmt +== 144 +CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQL AS +$$ SELECT generate_series(1, a) $$ STABLE +-- +FUNCTION: name="voidtest5" function="voidtest5" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 145 +SELECT * FROM voidtest5(3) +-- +FUNCTION: name="voidtest5" function="voidtest5" schema="" ctx=Call +STMT: SelectStmt +== 146 +-- Regression tests for bugs: + +-- Check that arguments that are R/W expanded datums aren't corrupted by +-- multiple uses. This test knows that array_append() returns a R/W datum +-- and will modify a R/W array input in-place. We use SETOF to prevent +-- inlining of the SQL function. +CREATE FUNCTION double_append(anyarray, anyelement) RETURNS SETOF anyarray +LANGUAGE SQL IMMUTABLE AS +$$ SELECT array_append($1, $2) || array_append($1, $2) $$ +-- +FUNCTION: name="double_append" function="double_append" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 147 +SELECT double_append(array_append(ARRAY[q1], q2), q3) + FROM (VALUES(1,2,3), (4,5,6)) v(q1,q2,q3) +-- +FUNCTION: name="double_append" function="double_append" schema="" ctx=Call +FUNCTION: name="array_append" function="array_append" schema="" ctx=Call +STMT: SelectStmt +== 148 +-- Things that shouldn't work: + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT ''not an integer'';' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 149 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'not even SQL' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 150 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT 1, 2, 3;' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 151 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT $2;' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 152 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'a', 'b' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 153 +-- Cleanup +DROP SCHEMA temp_func_test CASCADE +-- +STMT: DropStmt +== 154 +DROP USER regress_unpriv_user +-- +STMT: DropRoleStmt +== 155 +RESET search_path +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/create_index.metadata.json b/parser/testdata/summary/postgres_regress/create_index.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_index.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_index.test b/parser/testdata/summary/postgres_regress/create_index.test new file mode 100644 index 0000000..995fef5 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_index.test @@ -0,0 +1,3911 @@ +== 001 +|-- +-- CREATE_INDEX +-- Create ancillary data structures (i.e. indices) +|-- + +-- directory paths are passed to us in environment variables + +|-- +-- BTREE +|-- +CREATE INDEX onek_unique1 ON onek USING btree(unique1 int4_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +== 002 +CREATE INDEX IF NOT EXISTS onek_unique1 ON onek USING btree(unique1 int4_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +== 003 +CREATE INDEX IF NOT EXISTS ON onek USING btree(unique1 int4_ops) +-- +ERROR: syntax error at or near "ON" +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +CREATE INDEX onek_unique2 ON onek USING btree(unique2 int4_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +== 005 +CREATE INDEX onek_hundred ON onek USING btree(hundred int4_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +== 006 +CREATE INDEX onek_stringu1 ON onek USING btree(stringu1 name_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +== 007 +CREATE INDEX tenk1_unique1 ON tenk1 USING btree(unique1 int4_ops) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +== 008 +CREATE INDEX tenk1_unique2 ON tenk1 USING btree(unique2 int4_ops) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +== 009 +CREATE INDEX tenk1_hundred ON tenk1 USING btree(hundred int4_ops) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +== 010 +CREATE INDEX tenk1_thous_tenthous ON tenk1 (thousand, tenthous) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +== 011 +CREATE INDEX tenk2_unique1 ON tenk2 USING btree(unique1 int4_ops) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: IndexStmt +== 012 +CREATE INDEX tenk2_unique2 ON tenk2 USING btree(unique2 int4_ops) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: IndexStmt +== 013 +CREATE INDEX tenk2_hundred ON tenk2 USING btree(hundred int4_ops) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: IndexStmt +== 014 +CREATE INDEX rix ON road USING btree (name text_ops) +-- +TABLE: name="road" schema="" table="road" ctx=DDL +STMT: IndexStmt +== 015 +CREATE INDEX iix ON ihighway USING btree (name text_ops) +-- +TABLE: name="ihighway" schema="" table="ihighway" ctx=DDL +STMT: IndexStmt +== 016 +CREATE INDEX six ON shighway USING btree (name text_ops) +-- +TABLE: name="shighway" schema="" table="shighway" ctx=DDL +STMT: IndexStmt +== 017 +-- test comments +COMMENT ON INDEX six_wrong IS 'bad index' +-- +STMT: CommentStmt +== 018 +COMMENT ON INDEX six IS 'good index' +-- +STMT: CommentStmt +== 019 +COMMENT ON INDEX six IS NULL +-- +STMT: CommentStmt +== 020 +|-- +-- BTREE partial indices +|-- +CREATE INDEX onek2_u1_prtl ON onek2 USING btree(unique1 int4_ops) + where unique1 < 20 or unique1 > 980 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: IndexStmt +== 021 +CREATE INDEX onek2_u2_prtl ON onek2 USING btree(unique2 int4_ops) + where stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: IndexStmt +== 022 +CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops) + where onek2.stringu1 >= 'J' and onek2.stringu1 < 'K' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: IndexStmt +== 023 +|-- +-- GiST (rtree-equivalent opclasses only) +|-- + +CREATE TABLE slow_emp4000 ( + home_base box +) +-- +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=DDL +STMT: CreateStmt +== 024 +CREATE TABLE fast_emp4000 ( + home_base box +) +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: CreateStmt +== 025 +COPY slow_emp4000 FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 026 +INSERT INTO fast_emp4000 SELECT * FROM slow_emp4000 +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DML +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 027 +ANALYZE slow_emp4000 +-- +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=DDL +STMT: VacuumStmt +== 028 +ANALYZE fast_emp4000 +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: VacuumStmt +== 029 +CREATE INDEX grect2ind ON fast_emp4000 USING gist (home_base) +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: IndexStmt +== 030 +-- we want to work with a point_tbl that includes a null +CREATE TEMP TABLE point_tbl AS SELECT * FROM public.point_tbl +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DDL +TABLE: name="public.point_tbl" schema="public" table="point_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 031 +INSERT INTO POINT_TBL(f1) VALUES (NULL) +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +CREATE INDEX gpointind ON point_tbl USING gist (f1) +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DDL +STMT: IndexStmt +== 033 +CREATE TEMP TABLE gpolygon_tbl AS + SELECT polygon(home_base) AS f1 FROM slow_emp4000 +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=DDL +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 034 +INSERT INTO gpolygon_tbl VALUES ( '(1000,0,0,1000)' ) +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO gpolygon_tbl VALUES ( '(0,1000,1000,1000)' ) +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +CREATE TEMP TABLE gcircle_tbl AS + SELECT circle(home_base) AS f1 FROM slow_emp4000 +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=DDL +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 037 +CREATE INDEX ggpolygonind ON gpolygon_tbl USING gist (f1) +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=DDL +STMT: IndexStmt +== 038 +CREATE INDEX ggcircleind ON gcircle_tbl USING gist (f1) +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=DDL +STMT: IndexStmt +== 039 +|-- +-- Test GiST indexes +|-- + +-- get non-indexed results for comparison purposes + +SET enable_seqscan = ON +-- +STMT: VariableSetStmt +== 040 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +== 041 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 042 +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 043 +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 044 +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 045 +SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 046 +SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 047 +SELECT count(*) FROM point_tbl WHERE f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 048 +SELECT count(*) FROM point_tbl WHERE box '(0,0,100,100)' @> f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 049 +SELECT count(*) FROM point_tbl WHERE f1 <@ polygon '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 050 +SELECT count(*) FROM point_tbl WHERE f1 <@ circle '<(50,50),50>' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 051 +SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 052 +SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 053 +SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 054 +SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 055 +SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 056 +SELECT * FROM point_tbl ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +== 057 +SELECT * FROM point_tbl WHERE f1 IS NULL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 058 +SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 059 +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 060 +SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10 +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +STMT: SelectStmt +== 061 +SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10 +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="circle_center" function="circle_center" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="radius" function="radius" schema="" ctx=Call +STMT: SelectStmt +== 062 +-- Now check the results from plain indexscan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 063 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +== 064 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 065 +EXPLAIN (COSTS OFF) +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +== 066 +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 067 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +== 068 +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 069 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +== 070 +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +== 071 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 072 +SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 073 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 074 +SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 075 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl WHERE f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 076 +SELECT count(*) FROM point_tbl WHERE f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 077 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl WHERE box '(0,0,100,100)' @> f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 078 +SELECT count(*) FROM point_tbl WHERE box '(0,0,100,100)' @> f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 079 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl WHERE f1 <@ polygon '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 080 +SELECT count(*) FROM point_tbl WHERE f1 <@ polygon '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 081 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl WHERE f1 <@ circle '<(50,50),50>' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 082 +SELECT count(*) FROM point_tbl WHERE f1 <@ circle '<(50,50),50>' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 083 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 084 +SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 085 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 086 +SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 087 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 088 +SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 089 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 090 +SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 091 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 092 +SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 093 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 094 +SELECT * FROM point_tbl ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +== 095 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl WHERE f1 IS NULL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 096 +SELECT * FROM point_tbl WHERE f1 IS NULL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 097 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 098 +SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 099 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 100 +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 101 +EXPLAIN (COSTS OFF) +SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10 +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 102 +SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10 +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +STMT: SelectStmt +== 103 +EXPLAIN (COSTS OFF) +SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10 +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="circle_center" function="circle_center" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="radius" function="radius" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 104 +SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10 +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="circle_center" function="circle_center" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="radius" function="radius" schema="" ctx=Call +STMT: SelectStmt +== 105 +EXPLAIN (COSTS OFF) +SELECT point(x,x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x,x) LIMIT 1) as c FROM generate_series(0,10,1) x +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 106 +SELECT point(x,x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x,x) LIMIT 1) as c FROM generate_series(0,10,1) x +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 107 +-- Now check the results from bitmap indexscan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 108 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +== 109 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +== 110 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 111 +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 112 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 113 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 114 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 115 +|-- +-- GIN over int[] and text[] +|-- +-- Note: GIN currently supports only bitmap scans, not plain indexscans +|-- + +CREATE TABLE array_index_op_test ( + seqno int4, + i int4[], + t text[] +) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: CreateStmt +== 116 +COPY array_index_op_test FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 31 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 117 +ANALYZE array_index_op_test +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: VacuumStmt +== 118 +SELECT * FROM array_index_op_test WHERE i = '{NULL}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 119 +SELECT * FROM array_index_op_test WHERE i @> '{NULL}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 120 +SELECT * FROM array_index_op_test WHERE i && '{NULL}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 121 +SELECT * FROM array_index_op_test WHERE i <@ '{NULL}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 122 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 123 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +== 124 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +== 125 +CREATE INDEX intarrayidx ON array_index_op_test USING gin (i) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: IndexStmt +== 126 +explain (costs off) +SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 127 +SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 128 +SELECT * FROM array_index_op_test WHERE i && '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 129 +SELECT * FROM array_index_op_test WHERE i @> '{17}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 130 +SELECT * FROM array_index_op_test WHERE i && '{17}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 131 +SELECT * FROM array_index_op_test WHERE i @> '{32,17}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 132 +SELECT * FROM array_index_op_test WHERE i && '{32,17}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 133 +SELECT * FROM array_index_op_test WHERE i <@ '{38,34,32,89}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 134 +SELECT * FROM array_index_op_test WHERE i = '{47,77}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 135 +SELECT * FROM array_index_op_test WHERE i = '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 136 +SELECT * FROM array_index_op_test WHERE i @> '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 137 +SELECT * FROM array_index_op_test WHERE i && '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 138 +SELECT * FROM array_index_op_test WHERE i <@ '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 139 +CREATE INDEX textarrayidx ON array_index_op_test USING gin (t) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: IndexStmt +== 140 +explain (costs off) +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 141 +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 142 +SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 143 +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 144 +SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 145 +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 146 +SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 147 +SELECT * FROM array_index_op_test WHERE t <@ '{AAAAAAAA72908,AAAAAAAAAAAAAAAAAAA17075,AA88409,AAAAAAAAAAAAAAAAAA36842,AAAAAAA48038,AAAAAAAAAAAAAA10611}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 148 +SELECT * FROM array_index_op_test WHERE t = '{AAAAAAAAAA646,A87088}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 149 +SELECT * FROM array_index_op_test WHERE t = '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 150 +SELECT * FROM array_index_op_test WHERE t @> '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 151 +SELECT * FROM array_index_op_test WHERE t && '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 152 +SELECT * FROM array_index_op_test WHERE t <@ '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 153 +-- And try it with a multicolumn GIN index + +DROP INDEX intarrayidx, textarrayidx +-- +STMT: DropStmt +== 154 +CREATE INDEX botharrayidx ON array_index_op_test USING gin (i, t) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: IndexStmt +== 155 +SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 156 +SELECT * FROM array_index_op_test WHERE i && '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 157 +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAA80240}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 158 +SELECT * FROM array_index_op_test WHERE t && '{AAAAAAA80240}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 159 +SELECT * FROM array_index_op_test WHERE i @> '{32}' AND t && '{AAAAAAA80240}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 160 +SELECT * FROM array_index_op_test WHERE i && '{32}' AND t @> '{AAAAAAA80240}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 161 +SELECT * FROM array_index_op_test WHERE t = '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 162 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 163 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 164 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 165 +|-- +-- Try a GIN index with a lot of items with same key. (GIN creates a posting +-- tree when there are enough duplicates) +|-- +CREATE TABLE array_gin_test (a int[]) +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=DDL +STMT: CreateStmt +== 166 +INSERT INTO array_gin_test SELECT ARRAY[1, g%5, g] FROM generate_series(1, 10000) g +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 167 +CREATE INDEX array_gin_test_idx ON array_gin_test USING gin (a) +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=DDL +STMT: IndexStmt +== 168 +SELECT COUNT(*) FROM array_gin_test WHERE a @> '{2}' +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 169 +DROP TABLE array_gin_test +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=DDL +STMT: DropStmt +== 170 +|-- +-- Test GIN index's reloptions +|-- +CREATE INDEX gin_relopts_test ON array_index_op_test USING gin (i) + WITH (FASTUPDATE=on, GIN_PENDING_LIST_LIMIT=128) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: IndexStmt +== 171 +|-- +-- HASH +|-- +CREATE UNLOGGED TABLE unlogged_hash_table (id int4) +-- +TABLE: name="unlogged_hash_table" schema="" table="unlogged_hash_table" ctx=DDL +STMT: CreateStmt +== 172 +CREATE INDEX unlogged_hash_index ON unlogged_hash_table USING hash (id int4_ops) +-- +TABLE: name="unlogged_hash_table" schema="" table="unlogged_hash_table" ctx=DDL +STMT: IndexStmt +== 173 +DROP TABLE unlogged_hash_table +-- +TABLE: name="unlogged_hash_table" schema="" table="unlogged_hash_table" ctx=DDL +STMT: DropStmt +== 174 +-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops); + +-- Test hash index build tuplesorting. Force hash tuplesort using low +-- maintenance_work_mem setting and fillfactor: +SET maintenance_work_mem = '1MB' +-- +STMT: VariableSetStmt +== 175 +CREATE INDEX hash_tuplesort_idx ON tenk1 USING hash (stringu1 name_ops) WITH (fillfactor = 10) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +== 176 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 177 +SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 178 +DROP INDEX hash_tuplesort_idx +-- +STMT: DropStmt +== 179 +RESET maintenance_work_mem +-- +STMT: VariableSetStmt +== 180 +|-- +-- Test unique null behavior +|-- +CREATE TABLE unique_tbl (i int, t text) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +== 181 +CREATE UNIQUE INDEX unique_idx1 ON unique_tbl (i) NULLS DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +== 182 +CREATE UNIQUE INDEX unique_idx2 ON unique_tbl (i) NULLS NOT DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +== 183 +INSERT INTO unique_tbl VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 184 +INSERT INTO unique_tbl VALUES (2, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 185 +INSERT INTO unique_tbl VALUES (3, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +INSERT INTO unique_tbl VALUES (4, 'four') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +INSERT INTO unique_tbl VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +INSERT INTO unique_tbl (t) VALUES ('six') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +INSERT INTO unique_tbl (t) VALUES ('seven') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +-- error from unique_idx2 + +DROP INDEX unique_idx1, unique_idx2 +-- +STMT: DropStmt +== 191 +INSERT INTO unique_tbl (t) VALUES ('seven') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 192 +-- build indexes on filled table +CREATE UNIQUE INDEX unique_idx3 ON unique_tbl (i) NULLS DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +== 193 +-- ok +CREATE UNIQUE INDEX unique_idx4 ON unique_tbl (i) NULLS NOT DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +== 194 +-- error + +DELETE FROM unique_tbl WHERE t = 'seven' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +== 195 +CREATE UNIQUE INDEX unique_idx4 ON unique_tbl (i) NULLS NOT DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +== 196 +-- ok now + +SELECT pg_get_indexdef('unique_idx3'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 197 +SELECT pg_get_indexdef('unique_idx4'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 198 +DROP TABLE unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +== 199 +|-- +-- Test functional index +|-- +CREATE TABLE func_index_heap (f1 text, f2 text) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: CreateStmt +== 200 +CREATE UNIQUE INDEX func_index_index on func_index_heap (textcat(f1,f2)) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +FUNCTION: name="textcat" function="textcat" schema="" ctx=Call +STMT: IndexStmt +== 201 +INSERT INTO func_index_heap VALUES('ABC','DEF') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +INSERT INTO func_index_heap VALUES('AB','CDEFG') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 203 +INSERT INTO func_index_heap VALUES('QWE','RTY') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 204 +-- this should fail because of unique index: +INSERT INTO func_index_heap VALUES('ABCD', 'EF') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 205 +-- but this shouldn't: +INSERT INTO func_index_heap VALUES('QWERTY') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 206 +-- while we're here, see that the metadata looks sane + + +|-- +-- Same test, expressional index +|-- +DROP TABLE func_index_heap +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: DropStmt +== 207 +CREATE TABLE func_index_heap (f1 text, f2 text) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: CreateStmt +== 208 +CREATE UNIQUE INDEX func_index_index on func_index_heap ((f1 || f2) text_ops) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: IndexStmt +== 209 +INSERT INTO func_index_heap VALUES('ABC','DEF') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 210 +INSERT INTO func_index_heap VALUES('AB','CDEFG') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 211 +INSERT INTO func_index_heap VALUES('QWE','RTY') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 212 +-- this should fail because of unique index: +INSERT INTO func_index_heap VALUES('ABCD', 'EF') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 213 +-- but this shouldn't: +INSERT INTO func_index_heap VALUES('QWERTY') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 214 +-- while we're here, see that the metadata looks sane + +-- this should fail because of unsafe column type (anonymous record) +create index on func_index_heap ((f1 || f2), (row(f1, f2))) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: IndexStmt +== 215 +|-- +-- Test unique index with included columns +|-- +CREATE TABLE covering_index_heap (f1 int, f2 int, f3 text) +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: CreateStmt +== 216 +CREATE UNIQUE INDEX covering_index_index on covering_index_heap (f1,f2) INCLUDE(f3) +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: IndexStmt +== 217 +INSERT INTO covering_index_heap VALUES(1,1,'AAA') +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 218 +INSERT INTO covering_index_heap VALUES(1,2,'AAA') +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 219 +-- this should fail because of unique index on f1,f2: +INSERT INTO covering_index_heap VALUES(1,2,'BBB') +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 220 +-- and this shouldn't: +INSERT INTO covering_index_heap VALUES(1,4,'AAA') +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 221 +-- Try to build index on table that already contains data +CREATE UNIQUE INDEX covering_pkey on covering_index_heap (f1,f2) INCLUDE(f3) +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: IndexStmt +== 222 +-- Try to use existing covering index as primary key +ALTER TABLE covering_index_heap ADD CONSTRAINT covering_pkey PRIMARY KEY USING INDEX +covering_pkey +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: AlterTableStmt +== 223 +DROP TABLE covering_index_heap +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: DropStmt +== 224 +|-- +-- Try some concurrent index builds +|-- +-- Unfortunately this only tests about half the code paths because there are +-- no concurrent updates happening to the table at the same time. + +CREATE TABLE concur_heap (f1 text, f2 text) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: CreateStmt +== 225 +-- empty table +CREATE INDEX CONCURRENTLY concur_index1 ON concur_heap(f2,f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 226 +CREATE INDEX CONCURRENTLY IF NOT EXISTS concur_index1 ON concur_heap(f2,f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 227 +INSERT INTO concur_heap VALUES ('a','b') +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 228 +INSERT INTO concur_heap VALUES ('b','b') +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 229 +-- unique index +CREATE UNIQUE INDEX CONCURRENTLY concur_index2 ON concur_heap(f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 230 +CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS concur_index2 ON concur_heap(f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 231 +-- check if constraint is set up properly to be enforced +INSERT INTO concur_heap VALUES ('b','x') +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 232 +-- check if constraint is enforced properly at build time +CREATE UNIQUE INDEX CONCURRENTLY concur_index3 ON concur_heap(f2) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 233 +-- test that expression indexes and partial indexes work concurrently +CREATE INDEX CONCURRENTLY concur_index4 on concur_heap(f2) WHERE f1='a' +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 234 +CREATE INDEX CONCURRENTLY concur_index5 on concur_heap(f2) WHERE f1='x' +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 235 +-- here we also check that you can default the index name +CREATE INDEX CONCURRENTLY on concur_heap((f2||f1)) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 236 +-- You can't do a concurrent index build in a transaction +BEGIN +-- +STMT: TransactionStmt +== 237 +CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 238 +COMMIT +-- +STMT: TransactionStmt +== 239 +-- test where predicate is able to do a transactional update during +-- a concurrent build before switching pg_index state flags. +CREATE FUNCTION predicate_stable() RETURNS bool IMMUTABLE +LANGUAGE plpgsql AS $$ +BEGIN + EXECUTE 'SELECT txid_current()'; + RETURN true; +END; $$ +-- +FUNCTION: name="predicate_stable" function="predicate_stable" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 240 +CREATE INDEX CONCURRENTLY concur_index8 ON concur_heap (f1) + WHERE predicate_stable() +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +FUNCTION: name="predicate_stable" function="predicate_stable" schema="" ctx=Call +STMT: IndexStmt +== 241 +DROP INDEX concur_index8 +-- +STMT: DropStmt +== 242 +DROP FUNCTION predicate_stable() +-- +FUNCTION: name="predicate_stable" function="predicate_stable" schema="" ctx=DDL +STMT: DropStmt +== 243 +-- But you can do a regular index build in a transaction +BEGIN +-- +STMT: TransactionStmt +== 244 +CREATE INDEX std_index on concur_heap(f2) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +== 245 +COMMIT +-- +STMT: TransactionStmt +== 246 +-- Failed builds are left invalid by VACUUM FULL, fixed by REINDEX +VACUUM FULL concur_heap +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: VacuumStmt +== 247 +REINDEX TABLE concur_heap +-- +STMT: ReindexStmt +== 248 +DELETE FROM concur_heap WHERE f1 = 'b' +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DML +STMT: DeleteStmt +== 249 +VACUUM FULL concur_heap +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: VacuumStmt +== 250 +REINDEX TABLE concur_heap +-- +STMT: ReindexStmt +== 251 +-- Temporary tables with concurrent builds and on-commit actions +-- CONCURRENTLY used with CREATE INDEX and DROP INDEX is ignored. +-- PRESERVE ROWS, the default. +CREATE TEMP TABLE concur_temp (f1 int, f2 text) + ON COMMIT PRESERVE ROWS +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: CreateStmt +== 252 +INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp(f1) +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: IndexStmt +== 254 +DROP INDEX CONCURRENTLY concur_temp_ind +-- +STMT: DropStmt +== 255 +DROP TABLE concur_temp +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: DropStmt +== 256 +-- ON COMMIT DROP +BEGIN +-- +STMT: TransactionStmt +== 257 +CREATE TEMP TABLE concur_temp (f1 int, f2 text) + ON COMMIT DROP +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: CreateStmt +== 258 +INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 259 +-- Fails when running in a transaction. +CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp(f1) +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: IndexStmt +== 260 +COMMIT +-- +STMT: TransactionStmt +== 261 +-- ON COMMIT DELETE ROWS +CREATE TEMP TABLE concur_temp (f1 int, f2 text) + ON COMMIT DELETE ROWS +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: CreateStmt +== 262 +INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 263 +CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp(f1) +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: IndexStmt +== 264 +DROP INDEX CONCURRENTLY concur_temp_ind +-- +STMT: DropStmt +== 265 +DROP TABLE concur_temp +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: DropStmt +== 266 +|-- +-- Try some concurrent index drops +|-- +DROP INDEX CONCURRENTLY "concur_index2" +-- +STMT: DropStmt +== 267 +-- works +DROP INDEX CONCURRENTLY IF EXISTS "concur_index2" +-- +STMT: DropStmt +== 268 +-- notice + +-- failures +DROP INDEX CONCURRENTLY "concur_index2", "concur_index3" +-- +STMT: DropStmt +== 269 +BEGIN +-- +STMT: TransactionStmt +== 270 +DROP INDEX CONCURRENTLY "concur_index5" +-- +STMT: DropStmt +== 271 +ROLLBACK +-- +STMT: TransactionStmt +== 272 +-- successes +DROP INDEX CONCURRENTLY IF EXISTS "concur_index3" +-- +STMT: DropStmt +== 273 +DROP INDEX CONCURRENTLY "concur_index4" +-- +STMT: DropStmt +== 274 +DROP INDEX CONCURRENTLY "concur_index5" +-- +STMT: DropStmt +== 275 +DROP INDEX CONCURRENTLY "concur_index1" +-- +STMT: DropStmt +== 276 +DROP INDEX CONCURRENTLY "concur_heap_expr_idx" +-- +STMT: DropStmt +== 277 +DROP TABLE concur_heap +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: DropStmt +== 278 +|-- +-- Test ADD CONSTRAINT USING INDEX +|-- + +CREATE TABLE cwi_test( a int , b varchar(10), c char) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: CreateStmt +== 279 +-- add some data so that all tests have something to work with. + +INSERT INTO cwi_test VALUES(1, 2), (3, 4), (5, 6) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 280 +CREATE UNIQUE INDEX cwi_uniq_idx ON cwi_test(a , b) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +== 281 +ALTER TABLE cwi_test ADD primary key USING INDEX cwi_uniq_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +== 282 +CREATE UNIQUE INDEX cwi_uniq2_idx ON cwi_test(b , a) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +== 283 +ALTER TABLE cwi_test DROP CONSTRAINT cwi_uniq_idx, + ADD CONSTRAINT cwi_replaced_pkey PRIMARY KEY + USING INDEX cwi_uniq2_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +== 284 +DROP INDEX cwi_replaced_pkey +-- +STMT: DropStmt +== 285 +-- Should fail; a constraint depends on it + +-- Check that non-default index options are rejected +CREATE UNIQUE INDEX cwi_uniq3_idx ON cwi_test(a desc) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +== 286 +ALTER TABLE cwi_test ADD UNIQUE USING INDEX cwi_uniq3_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +== 287 +-- fail +CREATE UNIQUE INDEX cwi_uniq4_idx ON cwi_test(b collate "POSIX") +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +== 288 +ALTER TABLE cwi_test ADD UNIQUE USING INDEX cwi_uniq4_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +== 289 +-- fail + +DROP TABLE cwi_test +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: DropStmt +== 290 +-- ADD CONSTRAINT USING INDEX is forbidden on partitioned tables +CREATE TABLE cwi_test(a int) PARTITION BY hash (a) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: CreateStmt +== 291 +create unique index on cwi_test (a) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +== 292 +alter table cwi_test add primary key using index cwi_test_a_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +== 293 +DROP TABLE cwi_test +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: DropStmt +== 294 +-- PRIMARY KEY constraint cannot be backed by a NULLS NOT DISTINCT index +CREATE TABLE cwi_test(a int, b int) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: CreateStmt +== 295 +CREATE UNIQUE INDEX cwi_a_nnd ON cwi_test (a) NULLS NOT DISTINCT +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +== 296 +ALTER TABLE cwi_test ADD PRIMARY KEY USING INDEX cwi_a_nnd +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +== 297 +DROP TABLE cwi_test +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: DropStmt +== 298 +|-- +-- Check handling of indexes on system columns +|-- +CREATE TABLE syscol_table (a INT) +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: CreateStmt +== 299 +-- System columns cannot be indexed +CREATE INDEX ON syscol_table (ctid) +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: IndexStmt +== 300 +-- nor used in expressions +CREATE INDEX ON syscol_table ((ctid >= '(1000,0)')) +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: IndexStmt +== 301 +-- nor used in predicates +CREATE INDEX ON syscol_table (a) WHERE ctid >= '(1000,0)' +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: IndexStmt +== 302 +DROP TABLE syscol_table +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: DropStmt +== 303 +|-- +-- Tests for IS NULL/IS NOT NULL with b-tree indexes +|-- + +CREATE TABLE onek_with_null AS SELECT unique1, unique2 FROM onek +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 304 +INSERT INTO onek_with_null (unique1,unique2) VALUES (NULL, -1), (NULL, NULL) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 305 +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2,unique1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +== 306 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 307 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +== 308 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +== 309 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 310 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 311 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 312 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 313 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 314 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 315 +DROP INDEX onek_nulltest +-- +STMT: DropStmt +== 316 +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2 desc,unique1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +== 317 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 318 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 319 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 320 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 321 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 322 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 323 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IN (-1, 0, 1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 324 +DROP INDEX onek_nulltest +-- +STMT: DropStmt +== 325 +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2 desc nulls last,unique1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +== 326 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 327 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 328 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 329 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 330 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 331 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 332 +DROP INDEX onek_nulltest +-- +STMT: DropStmt +== 333 +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2 nulls first,unique1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +== 334 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 335 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 336 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 337 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 338 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 339 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 340 +DROP INDEX onek_nulltest +-- +STMT: DropStmt +== 341 +-- Check initial-positioning logic too + +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +== 342 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 343 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +== 344 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 345 +SELECT unique1, unique2 FROM onek_with_null + ORDER BY unique2 LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +STMT: SelectStmt +== 346 +SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= -1 + ORDER BY unique2 LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 347 +SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= 0 + ORDER BY unique2 LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 348 +SELECT unique1, unique2 FROM onek_with_null + ORDER BY unique2 DESC LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +STMT: SelectStmt +== 349 +SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= -1 + ORDER BY unique2 DESC LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 350 +SELECT unique1, unique2 FROM onek_with_null WHERE unique2 < 999 + ORDER BY unique2 DESC LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 351 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 352 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 353 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 354 +DROP TABLE onek_with_null +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: DropStmt +== 355 +|-- +-- Check bitmap index path planning +|-- + +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 + WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 356 +SELECT * FROM tenk1 + WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 357 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 + WHERE hundred = 42 AND (thousand = 42 OR thousand = 99) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 358 +SELECT count(*) FROM tenk1 + WHERE hundred = 42 AND (thousand = 42 OR thousand = 99) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 359 +|-- +-- Check behavior with duplicate index column contents +|-- + +CREATE TABLE dupindexcols AS + SELECT unique1 as id, stringu2::text as f1 FROM tenk1 +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 360 +CREATE INDEX dupindexcols_i ON dupindexcols (f1, id, f1 text_pattern_ops) +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=DDL +STMT: IndexStmt +== 361 +ANALYZE dupindexcols +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=DDL +STMT: VacuumStmt +== 362 +EXPLAIN (COSTS OFF) + SELECT count(*) FROM dupindexcols + WHERE f1 BETWEEN 'WA' AND 'ZZZ' and id < 1000 and f1 ~<~ 'YX' +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 363 +SELECT count(*) FROM dupindexcols + WHERE f1 BETWEEN 'WA' AND 'ZZZ' and id < 1000 and f1 ~<~ 'YX' +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 364 +|-- +-- Check that index scans with =ANY indexquals return rows in index order +|-- + +explain (costs off) +SELECT unique1 FROM tenk1 +WHERE unique1 IN (1,42,7) +ORDER BY unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 365 +SELECT unique1 FROM tenk1 +WHERE unique1 IN (1,42,7) +ORDER BY unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 366 +-- Non-required array scan key on "tenthous": +explain (costs off) +SELECT thousand, tenthous FROM tenk1 +WHERE thousand < 2 AND tenthous IN (1001,3000) +ORDER BY thousand +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 367 +SELECT thousand, tenthous FROM tenk1 +WHERE thousand < 2 AND tenthous IN (1001,3000) +ORDER BY thousand +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 368 +-- Non-required array scan key on "tenthous", backward scan: +explain (costs off) +SELECT thousand, tenthous FROM tenk1 +WHERE thousand < 2 AND tenthous IN (1001,3000) +ORDER BY thousand DESC, tenthous DESC +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 369 +SELECT thousand, tenthous FROM tenk1 +WHERE thousand < 2 AND tenthous IN (1001,3000) +ORDER BY thousand DESC, tenthous DESC +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 370 +|-- +-- Check elimination of redundant and contradictory index quals +|-- +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = ANY('{7, 8, 9}') +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 371 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = ANY('{7, 8, 9}') +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 372 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 = ANY('{7, 14, 22}') and unique1 = ANY('{33, 44}'::bigint[]) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 373 +SELECT unique1 FROM tenk1 WHERE unique1 = ANY('{7, 14, 22}') and unique1 = ANY('{33, 44}'::bigint[]) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 374 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 375 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 376 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = 12345 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 377 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = 12345 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 378 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 >= 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 379 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 >= 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 380 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 > 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 381 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 > 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 382 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 > 9996 and unique1 >= 9999 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 383 +SELECT unique1 FROM tenk1 WHERE unique1 > 9996 and unique1 >= 9999 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 384 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 < 3 and unique1 <= 3 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 385 +SELECT unique1 FROM tenk1 WHERE unique1 < 3 and unique1 <= 3 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 386 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 < 3 and unique1 < (-1)::bigint +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 387 +SELECT unique1 FROM tenk1 WHERE unique1 < 3 and unique1 < (-1)::bigint +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 388 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 < (-1)::bigint +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 389 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 < (-1)::bigint +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 390 +|-- +-- Check elimination of constant-NULL subexpressions +|-- + +explain (costs off) + select * from tenk1 where (thousand, tenthous) in ((1,1001), (null,null)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 391 +|-- +-- Check matching of boolean index columns to WHERE conditions and sort keys +|-- + +create temp table boolindex (b bool, i int, unique(b, i), junk float) +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=DDL +STMT: CreateStmt +== 392 +explain (costs off) + select * from boolindex order by b, i limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 393 +explain (costs off) + select * from boolindex where b order by i limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 394 +explain (costs off) + select * from boolindex where b = true order by i desc limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 395 +explain (costs off) + select * from boolindex where not b order by i limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 396 +explain (costs off) + select * from boolindex where b is true order by i desc limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 397 +explain (costs off) + select * from boolindex where b is false order by i desc limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 398 +|-- +-- REINDEX (VERBOSE) +|-- +CREATE TABLE reindex_verbose(id integer primary key) +-- +TABLE: name="reindex_verbose" schema="" table="reindex_verbose" ctx=DDL +STMT: CreateStmt +== 399 +REINDEX (VERBOSE) TABLE reindex_verbose +-- +STMT: ReindexStmt +== 400 +DROP TABLE reindex_verbose +-- +TABLE: name="reindex_verbose" schema="" table="reindex_verbose" ctx=DDL +STMT: DropStmt +== 401 +|-- +-- REINDEX CONCURRENTLY +|-- +CREATE TABLE concur_reindex_tab (c1 int) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: CreateStmt +== 402 +-- REINDEX +REINDEX TABLE concur_reindex_tab +-- +STMT: ReindexStmt +== 403 +-- notice +REINDEX (CONCURRENTLY) TABLE concur_reindex_tab +-- +STMT: ReindexStmt +== 404 +-- notice +ALTER TABLE concur_reindex_tab ADD COLUMN c2 text +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: AlterTableStmt +== 405 +-- add toast index +-- Normal index with integer column +CREATE UNIQUE INDEX concur_reindex_ind1 ON concur_reindex_tab(c1) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: IndexStmt +== 406 +-- Normal index with text column +CREATE INDEX concur_reindex_ind2 ON concur_reindex_tab(c2) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: IndexStmt +== 407 +-- UNIQUE index with expression +CREATE UNIQUE INDEX concur_reindex_ind3 ON concur_reindex_tab(abs(c1)) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 408 +-- Duplicate column names +CREATE INDEX concur_reindex_ind4 ON concur_reindex_tab(c1, c1, c2) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: IndexStmt +== 409 +-- Create table for check on foreign key dependence switch with indexes swapped +ALTER TABLE concur_reindex_tab ADD PRIMARY KEY USING INDEX concur_reindex_ind1 +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: AlterTableStmt +== 410 +CREATE TABLE concur_reindex_tab2 (c1 int REFERENCES concur_reindex_tab) +-- +TABLE: name="concur_reindex_tab2" schema="" table="concur_reindex_tab2" ctx=DDL +STMT: CreateStmt +== 411 +INSERT INTO concur_reindex_tab VALUES (1, 'a') +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 412 +INSERT INTO concur_reindex_tab VALUES (2, 'a') +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 413 +-- Reindex concurrently of exclusion constraint currently not supported +CREATE TABLE concur_reindex_tab3 (c1 int, c2 int4range, EXCLUDE USING gist (c2 WITH &&)) +-- +TABLE: name="concur_reindex_tab3" schema="" table="concur_reindex_tab3" ctx=DDL +STMT: CreateStmt +== 414 +INSERT INTO concur_reindex_tab3 VALUES (3, '[1,2]') +-- +TABLE: name="concur_reindex_tab3" schema="" table="concur_reindex_tab3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 415 +REINDEX INDEX CONCURRENTLY concur_reindex_tab3_c2_excl +-- +STMT: ReindexStmt +== 416 +-- error +REINDEX TABLE CONCURRENTLY concur_reindex_tab3 +-- +STMT: ReindexStmt +== 417 +-- succeeds with warning +INSERT INTO concur_reindex_tab3 VALUES (4, '[2,4]') +-- +TABLE: name="concur_reindex_tab3" schema="" table="concur_reindex_tab3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 418 +-- Check materialized views +CREATE MATERIALIZED VIEW concur_reindex_matview AS SELECT * FROM concur_reindex_tab +-- +TABLE: name="concur_reindex_matview" schema="" table="concur_reindex_matview" ctx=DDL +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 419 +-- Dependency lookup before and after the follow-up REINDEX commands. +-- These should remain consistent. +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid,refobjid,refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_class'::regclass AND + objid in ('concur_reindex_tab'::regclass, + 'concur_reindex_ind1'::regclass, + 'concur_reindex_ind2'::regclass, + 'concur_reindex_ind3'::regclass, + 'concur_reindex_ind4'::regclass, + 'concur_reindex_matview'::regclass) + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 420 +REINDEX INDEX CONCURRENTLY concur_reindex_ind1 +-- +STMT: ReindexStmt +== 421 +REINDEX TABLE CONCURRENTLY concur_reindex_tab +-- +STMT: ReindexStmt +== 422 +REINDEX TABLE CONCURRENTLY concur_reindex_matview +-- +STMT: ReindexStmt +== 423 +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid,refobjid,refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_class'::regclass AND + objid in ('concur_reindex_tab'::regclass, + 'concur_reindex_ind1'::regclass, + 'concur_reindex_ind2'::regclass, + 'concur_reindex_ind3'::regclass, + 'concur_reindex_ind4'::regclass, + 'concur_reindex_matview'::regclass) + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 424 +-- Check that comments are preserved +CREATE TABLE testcomment (i int) +-- +TABLE: name="testcomment" schema="" table="testcomment" ctx=DDL +STMT: CreateStmt +== 425 +CREATE INDEX testcomment_idx1 ON testcomment (i) +-- +TABLE: name="testcomment" schema="" table="testcomment" ctx=DDL +STMT: IndexStmt +== 426 +COMMENT ON INDEX testcomment_idx1 IS 'test comment' +-- +STMT: CommentStmt +== 427 +SELECT obj_description('testcomment_idx1'::regclass, 'pg_class') +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +== 428 +REINDEX TABLE testcomment +-- +STMT: ReindexStmt +== 429 +SELECT obj_description('testcomment_idx1'::regclass, 'pg_class') +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +== 430 +REINDEX TABLE CONCURRENTLY testcomment +-- +STMT: ReindexStmt +== 431 +SELECT obj_description('testcomment_idx1'::regclass, 'pg_class') +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +== 432 +DROP TABLE testcomment +-- +TABLE: name="testcomment" schema="" table="testcomment" ctx=DDL +STMT: DropStmt +== 433 +-- Check that indisclustered updates are preserved +CREATE TABLE concur_clustered(i int) +-- +TABLE: name="concur_clustered" schema="" table="concur_clustered" ctx=DDL +STMT: CreateStmt +== 434 +CREATE INDEX concur_clustered_i_idx ON concur_clustered(i) +-- +TABLE: name="concur_clustered" schema="" table="concur_clustered" ctx=DDL +STMT: IndexStmt +== 435 +ALTER TABLE concur_clustered CLUSTER ON concur_clustered_i_idx +-- +TABLE: name="concur_clustered" schema="" table="concur_clustered" ctx=DDL +STMT: AlterTableStmt +== 436 +REINDEX TABLE CONCURRENTLY concur_clustered +-- +STMT: ReindexStmt +== 437 +SELECT indexrelid::regclass, indisclustered FROM pg_index + WHERE indrelid = 'concur_clustered'::regclass +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 438 +DROP TABLE concur_clustered +-- +TABLE: name="concur_clustered" schema="" table="concur_clustered" ctx=DDL +STMT: DropStmt +== 439 +-- Check that indisreplident updates are preserved. +CREATE TABLE concur_replident(i int NOT NULL) +-- +TABLE: name="concur_replident" schema="" table="concur_replident" ctx=DDL +STMT: CreateStmt +== 440 +CREATE UNIQUE INDEX concur_replident_i_idx ON concur_replident(i) +-- +TABLE: name="concur_replident" schema="" table="concur_replident" ctx=DDL +STMT: IndexStmt +== 441 +ALTER TABLE concur_replident REPLICA IDENTITY + USING INDEX concur_replident_i_idx +-- +TABLE: name="concur_replident" schema="" table="concur_replident" ctx=DDL +STMT: AlterTableStmt +== 442 +SELECT indexrelid::regclass, indisreplident FROM pg_index + WHERE indrelid = 'concur_replident'::regclass +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 443 +REINDEX TABLE CONCURRENTLY concur_replident +-- +STMT: ReindexStmt +== 444 +SELECT indexrelid::regclass, indisreplident FROM pg_index + WHERE indrelid = 'concur_replident'::regclass +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 445 +DROP TABLE concur_replident +-- +TABLE: name="concur_replident" schema="" table="concur_replident" ctx=DDL +STMT: DropStmt +== 446 +-- Check that opclass parameters are preserved +CREATE TABLE concur_appclass_tab(i tsvector, j tsvector, k tsvector) +-- +TABLE: name="concur_appclass_tab" schema="" table="concur_appclass_tab" ctx=DDL +STMT: CreateStmt +== 447 +CREATE INDEX concur_appclass_ind on concur_appclass_tab + USING gist (i tsvector_ops (siglen='1000'), j tsvector_ops (siglen='500')) +-- +TABLE: name="concur_appclass_tab" schema="" table="concur_appclass_tab" ctx=DDL +STMT: IndexStmt +== 448 +CREATE INDEX concur_appclass_ind_2 on concur_appclass_tab + USING gist (k tsvector_ops (siglen='300'), j tsvector_ops) +-- +TABLE: name="concur_appclass_tab" schema="" table="concur_appclass_tab" ctx=DDL +STMT: IndexStmt +== 449 +REINDEX TABLE CONCURRENTLY concur_appclass_tab +-- +STMT: ReindexStmt +== 450 +DROP TABLE concur_appclass_tab +-- +TABLE: name="concur_appclass_tab" schema="" table="concur_appclass_tab" ctx=DDL +STMT: DropStmt +== 451 +-- Partitions +-- Create some partitioned tables +CREATE TABLE concur_reindex_part (c1 int, c2 int) PARTITION BY RANGE (c1) +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: CreateStmt +== 452 +CREATE TABLE concur_reindex_part_0 PARTITION OF concur_reindex_part + FOR VALUES FROM (0) TO (10) PARTITION BY list (c2) +-- +TABLE: name="concur_reindex_part_0" schema="" table="concur_reindex_part_0" ctx=DDL +STMT: CreateStmt +== 453 +CREATE TABLE concur_reindex_part_0_1 PARTITION OF concur_reindex_part_0 + FOR VALUES IN (1) +-- +TABLE: name="concur_reindex_part_0_1" schema="" table="concur_reindex_part_0_1" ctx=DDL +STMT: CreateStmt +== 454 +CREATE TABLE concur_reindex_part_0_2 PARTITION OF concur_reindex_part_0 + FOR VALUES IN (2) +-- +TABLE: name="concur_reindex_part_0_2" schema="" table="concur_reindex_part_0_2" ctx=DDL +STMT: CreateStmt +== 455 +-- This partitioned table will have no partitions. +CREATE TABLE concur_reindex_part_10 PARTITION OF concur_reindex_part + FOR VALUES FROM (10) TO (20) PARTITION BY list (c2) +-- +TABLE: name="concur_reindex_part_10" schema="" table="concur_reindex_part_10" ctx=DDL +STMT: CreateStmt +== 456 +-- Create some partitioned indexes +CREATE INDEX concur_reindex_part_index ON ONLY concur_reindex_part (c1) +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: IndexStmt +== 457 +CREATE INDEX concur_reindex_part_index_0 ON ONLY concur_reindex_part_0 (c1) +-- +TABLE: name="concur_reindex_part_0" schema="" table="concur_reindex_part_0" ctx=DDL +STMT: IndexStmt +== 458 +ALTER INDEX concur_reindex_part_index ATTACH PARTITION concur_reindex_part_index_0 +-- +STMT: AlterTableStmt +== 459 +-- This partitioned index will have no partitions. +CREATE INDEX concur_reindex_part_index_10 ON ONLY concur_reindex_part_10 (c1) +-- +TABLE: name="concur_reindex_part_10" schema="" table="concur_reindex_part_10" ctx=DDL +STMT: IndexStmt +== 460 +ALTER INDEX concur_reindex_part_index ATTACH PARTITION concur_reindex_part_index_10 +-- +STMT: AlterTableStmt +== 461 +CREATE INDEX concur_reindex_part_index_0_1 ON ONLY concur_reindex_part_0_1 (c1) +-- +TABLE: name="concur_reindex_part_0_1" schema="" table="concur_reindex_part_0_1" ctx=DDL +STMT: IndexStmt +== 462 +ALTER INDEX concur_reindex_part_index_0 ATTACH PARTITION concur_reindex_part_index_0_1 +-- +STMT: AlterTableStmt +== 463 +CREATE INDEX concur_reindex_part_index_0_2 ON ONLY concur_reindex_part_0_2 (c1) +-- +TABLE: name="concur_reindex_part_0_2" schema="" table="concur_reindex_part_0_2" ctx=DDL +STMT: IndexStmt +== 464 +ALTER INDEX concur_reindex_part_index_0 ATTACH PARTITION concur_reindex_part_index_0_2 +-- +STMT: AlterTableStmt +== 465 +SELECT relid, parentrelid, level FROM pg_partition_tree('concur_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 466 +SELECT relid, parentrelid, level FROM pg_partition_tree('concur_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 467 +-- REINDEX should preserve dependencies of partition tree. +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid,refobjid,refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_class'::regclass AND + objid in ('concur_reindex_part'::regclass, + 'concur_reindex_part_0'::regclass, + 'concur_reindex_part_0_1'::regclass, + 'concur_reindex_part_0_2'::regclass, + 'concur_reindex_part_index'::regclass, + 'concur_reindex_part_index_0'::regclass, + 'concur_reindex_part_index_0_1'::regclass, + 'concur_reindex_part_index_0_2'::regclass) + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 468 +REINDEX INDEX CONCURRENTLY concur_reindex_part_index_0_1 +-- +STMT: ReindexStmt +== 469 +REINDEX INDEX CONCURRENTLY concur_reindex_part_index_0_2 +-- +STMT: ReindexStmt +== 470 +SELECT relid, parentrelid, level FROM pg_partition_tree('concur_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 471 +REINDEX TABLE CONCURRENTLY concur_reindex_part_0_1 +-- +STMT: ReindexStmt +== 472 +REINDEX TABLE CONCURRENTLY concur_reindex_part_0_2 +-- +STMT: ReindexStmt +== 473 +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid,refobjid,refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_class'::regclass AND + objid in ('concur_reindex_part'::regclass, + 'concur_reindex_part_0'::regclass, + 'concur_reindex_part_0_1'::regclass, + 'concur_reindex_part_0_2'::regclass, + 'concur_reindex_part_index'::regclass, + 'concur_reindex_part_index_0'::regclass, + 'concur_reindex_part_index_0_1'::regclass, + 'concur_reindex_part_index_0_2'::regclass) + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +== 474 +SELECT relid, parentrelid, level FROM pg_partition_tree('concur_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 475 +-- REINDEX for partitioned indexes +-- REINDEX TABLE fails for partitioned indexes +-- Top-most parent index +REINDEX TABLE concur_reindex_part_index +-- +STMT: ReindexStmt +== 476 +-- error +REINDEX TABLE CONCURRENTLY concur_reindex_part_index +-- +STMT: ReindexStmt +== 477 +-- error +-- Partitioned index with no leaves +REINDEX TABLE concur_reindex_part_index_10 +-- +STMT: ReindexStmt +== 478 +-- error +REINDEX TABLE CONCURRENTLY concur_reindex_part_index_10 +-- +STMT: ReindexStmt +== 479 +-- error +-- Cannot run in a transaction block +BEGIN +-- +STMT: TransactionStmt +== 480 +REINDEX INDEX concur_reindex_part_index +-- +STMT: ReindexStmt +== 481 +ROLLBACK +-- +STMT: TransactionStmt +== 482 +-- Helper functions to track changes of relfilenodes in a partition tree. +-- Create a table tracking the relfilenode state. +CREATE OR REPLACE FUNCTION create_relfilenode_part(relname text, indname text) + RETURNS VOID AS + $func$ + BEGIN + EXECUTE format(' + CREATE TABLE %I AS + SELECT oid, relname, relfilenode, relkind, reltoastrelid + FROM pg_class + WHERE oid IN + (SELECT relid FROM pg_partition_tree(''%I''));', + relname, indname); + END + $func$ LANGUAGE plpgsql +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 483 +CREATE OR REPLACE FUNCTION compare_relfilenode_part(tabname text) + RETURNS TABLE (relname name, relkind "char", state text) AS + $func$ + BEGIN + RETURN QUERY EXECUTE + format( + 'SELECT b.relname, + b.relkind, + CASE WHEN a.relfilenode = b.relfilenode THEN ''relfilenode is unchanged'' + ELSE ''relfilenode has changed'' END + -- Do not join with OID here as CONCURRENTLY changes it. + FROM %I b JOIN pg_class a ON b.relname = a.relname + ORDER BY 1;', tabname); + END + $func$ LANGUAGE plpgsql +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 484 +-- Check that expected relfilenodes are changed, non-concurrent case. +SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index') +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +== 485 +REINDEX INDEX concur_reindex_part_index +-- +STMT: ReindexStmt +== 486 +SELECT * FROM compare_relfilenode_part('reindex_index_status') +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +== 487 +DROP TABLE reindex_index_status +-- +TABLE: name="reindex_index_status" schema="" table="reindex_index_status" ctx=DDL +STMT: DropStmt +== 488 +-- concurrent case. +SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index') +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +== 489 +REINDEX INDEX CONCURRENTLY concur_reindex_part_index +-- +STMT: ReindexStmt +== 490 +SELECT * FROM compare_relfilenode_part('reindex_index_status') +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +== 491 +DROP TABLE reindex_index_status +-- +TABLE: name="reindex_index_status" schema="" table="reindex_index_status" ctx=DDL +STMT: DropStmt +== 492 +-- REINDEX for partitioned tables +-- REINDEX INDEX fails for partitioned tables +-- Top-most parent +REINDEX INDEX concur_reindex_part +-- +STMT: ReindexStmt +== 493 +-- error +REINDEX INDEX CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +== 494 +-- error +-- Partitioned with no leaves +REINDEX INDEX concur_reindex_part_10 +-- +STMT: ReindexStmt +== 495 +-- error +REINDEX INDEX CONCURRENTLY concur_reindex_part_10 +-- +STMT: ReindexStmt +== 496 +-- error +-- Cannot run in a transaction block +BEGIN +-- +STMT: TransactionStmt +== 497 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +== 498 +ROLLBACK +-- +STMT: TransactionStmt +== 499 +-- Check that expected relfilenodes are changed, non-concurrent case. +-- Note that the partition tree changes of the *indexes* need to be checked. +SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index') +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +== 500 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +== 501 +SELECT * FROM compare_relfilenode_part('reindex_index_status') +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +== 502 +DROP TABLE reindex_index_status +-- +TABLE: name="reindex_index_status" schema="" table="reindex_index_status" ctx=DDL +STMT: DropStmt +== 503 +-- concurrent case. +SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index') +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +== 504 +REINDEX TABLE CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +== 505 +SELECT * FROM compare_relfilenode_part('reindex_index_status') +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +== 506 +DROP TABLE reindex_index_status +-- +TABLE: name="reindex_index_status" schema="" table="reindex_index_status" ctx=DDL +STMT: DropStmt +== 507 +DROP FUNCTION create_relfilenode_part +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=DDL +STMT: DropStmt +== 508 +DROP FUNCTION compare_relfilenode_part +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=DDL +STMT: DropStmt +== 509 +-- Cleanup of partition tree used for REINDEX test. +DROP TABLE concur_reindex_part +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: DropStmt +== 510 +-- Check errors +-- Cannot run inside a transaction block +BEGIN +-- +STMT: TransactionStmt +== 511 +REINDEX TABLE CONCURRENTLY concur_reindex_tab +-- +STMT: ReindexStmt +== 512 +COMMIT +-- +STMT: TransactionStmt +== 513 +REINDEX TABLE CONCURRENTLY pg_class +-- +STMT: ReindexStmt +== 514 +-- no catalog relation +REINDEX INDEX CONCURRENTLY pg_class_oid_index +-- +STMT: ReindexStmt +== 515 +-- no catalog index +-- These are the toast table and index of pg_authid. +REINDEX TABLE CONCURRENTLY pg_toast.pg_toast_1260 +-- +STMT: ReindexStmt +== 516 +-- no catalog toast table +REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_1260_index +-- +STMT: ReindexStmt +== 517 +-- no catalog toast index +REINDEX SYSTEM CONCURRENTLY postgres +-- +STMT: ReindexStmt +== 518 +-- not allowed for SYSTEM +REINDEX (CONCURRENTLY) SYSTEM postgres +-- +STMT: ReindexStmt +== 519 +-- ditto +REINDEX (CONCURRENTLY) SYSTEM +-- +STMT: ReindexStmt +== 520 +-- ditto +-- Warns about catalog relations +REINDEX SCHEMA CONCURRENTLY pg_catalog +-- +STMT: ReindexStmt +== 521 +-- Not the current database +REINDEX DATABASE not_current_database +-- +STMT: ReindexStmt +== 522 +-- Check the relation status, there should not be invalid indexes +DROP MATERIALIZED VIEW concur_reindex_matview +-- +STMT: DropStmt +== 523 +DROP TABLE concur_reindex_tab, concur_reindex_tab2, concur_reindex_tab3 +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +TABLE: name="concur_reindex_tab2" schema="" table="concur_reindex_tab2" ctx=DDL +TABLE: name="concur_reindex_tab3" schema="" table="concur_reindex_tab3" ctx=DDL +STMT: DropStmt +== 524 +-- Check handling of invalid indexes +CREATE TABLE concur_reindex_tab4 (c1 int) +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DDL +STMT: CreateStmt +== 525 +INSERT INTO concur_reindex_tab4 VALUES (1), (1), (2) +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 526 +-- This trick creates an invalid index. +CREATE UNIQUE INDEX CONCURRENTLY concur_reindex_ind5 ON concur_reindex_tab4 (c1) +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DDL +STMT: IndexStmt +== 527 +-- Reindexing concurrently this index fails with the same failure. +-- The extra index created is itself invalid, and can be dropped. +REINDEX INDEX CONCURRENTLY concur_reindex_ind5 +-- +STMT: ReindexStmt +== 528 +DROP INDEX concur_reindex_ind5_ccnew +-- +STMT: DropStmt +== 529 +-- This makes the previous failure go away, so the index can become valid. +DELETE FROM concur_reindex_tab4 WHERE c1 = 1 +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DML +STMT: DeleteStmt +== 530 +-- The invalid index is not processed when running REINDEX TABLE. +REINDEX TABLE CONCURRENTLY concur_reindex_tab4 +-- +STMT: ReindexStmt +== 531 +-- But it is fixed with REINDEX INDEX. +REINDEX INDEX CONCURRENTLY concur_reindex_ind5 +-- +STMT: ReindexStmt +== 532 +DROP TABLE concur_reindex_tab4 +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DDL +STMT: DropStmt +== 533 +-- Check handling of indexes with expressions and predicates. The +-- definitions of the rebuilt indexes should match the original +-- definitions. +CREATE TABLE concur_exprs_tab (c1 int , c2 boolean) +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: CreateStmt +== 534 +INSERT INTO concur_exprs_tab (c1, c2) VALUES (1369652450, FALSE), + (414515746, TRUE), + (897778963, FALSE) +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 535 +CREATE UNIQUE INDEX concur_exprs_index_expr + ON concur_exprs_tab ((c1::text COLLATE "C")) +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: IndexStmt +== 536 +CREATE UNIQUE INDEX concur_exprs_index_pred ON concur_exprs_tab (c1) + WHERE (c1::text > 500000000::text COLLATE "C") +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: IndexStmt +== 537 +CREATE UNIQUE INDEX concur_exprs_index_pred_2 + ON concur_exprs_tab ((1 / c1)) + WHERE ('-H') >= (c2::TEXT) COLLATE "C" +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: IndexStmt +== 538 +ALTER INDEX concur_exprs_index_expr ALTER COLUMN 1 SET STATISTICS 100 +-- +STMT: AlterTableStmt +== 539 +ANALYZE concur_exprs_tab +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: VacuumStmt +== 540 +SELECT starelid::regclass, count(*) FROM pg_statistic WHERE starelid IN ( + 'concur_exprs_index_expr'::regclass, + 'concur_exprs_index_pred'::regclass, + 'concur_exprs_index_pred_2'::regclass) + GROUP BY starelid ORDER BY starelid::regclass::text +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="starelid" +STMT: SelectStmt +== 541 +SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 542 +SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 543 +SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 544 +REINDEX TABLE CONCURRENTLY concur_exprs_tab +-- +STMT: ReindexStmt +== 545 +SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 546 +SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 547 +SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 548 +-- ALTER TABLE recreates the indexes, which should keep their collations. +ALTER TABLE concur_exprs_tab ALTER c2 TYPE TEXT +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: AlterTableStmt +== 549 +SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 550 +SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 551 +SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 552 +-- Statistics should remain intact. +SELECT starelid::regclass, count(*) FROM pg_statistic WHERE starelid IN ( + 'concur_exprs_index_expr'::regclass, + 'concur_exprs_index_pred'::regclass, + 'concur_exprs_index_pred_2'::regclass) + GROUP BY starelid ORDER BY starelid::regclass::text +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="starelid" +STMT: SelectStmt +== 553 +-- attstattarget should remain intact +SELECT attrelid::regclass, attnum, attstattarget + FROM pg_attribute WHERE attrelid IN ( + 'concur_exprs_index_expr'::regclass, + 'concur_exprs_index_pred'::regclass, + 'concur_exprs_index_pred_2'::regclass) + ORDER BY attrelid::regclass::text, attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +== 554 +DROP TABLE concur_exprs_tab +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: DropStmt +== 555 +-- Temporary tables and on-commit actions, where CONCURRENTLY is ignored. +-- ON COMMIT PRESERVE ROWS, the default. +CREATE TEMP TABLE concur_temp_tab_1 (c1 int, c2 text) + ON COMMIT PRESERVE ROWS +-- +TABLE: name="concur_temp_tab_1" schema="" table="concur_temp_tab_1" ctx=DDL +STMT: CreateStmt +== 556 +INSERT INTO concur_temp_tab_1 VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp_tab_1" schema="" table="concur_temp_tab_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 557 +CREATE INDEX concur_temp_ind_1 ON concur_temp_tab_1(c2) +-- +TABLE: name="concur_temp_tab_1" schema="" table="concur_temp_tab_1" ctx=DDL +STMT: IndexStmt +== 558 +REINDEX TABLE CONCURRENTLY concur_temp_tab_1 +-- +STMT: ReindexStmt +== 559 +REINDEX INDEX CONCURRENTLY concur_temp_ind_1 +-- +STMT: ReindexStmt +== 560 +-- Still fails in transaction blocks +BEGIN +-- +STMT: TransactionStmt +== 561 +REINDEX INDEX CONCURRENTLY concur_temp_ind_1 +-- +STMT: ReindexStmt +== 562 +COMMIT +-- +STMT: TransactionStmt +== 563 +-- ON COMMIT DELETE ROWS +CREATE TEMP TABLE concur_temp_tab_2 (c1 int, c2 text) + ON COMMIT DELETE ROWS +-- +TABLE: name="concur_temp_tab_2" schema="" table="concur_temp_tab_2" ctx=DDL +STMT: CreateStmt +== 564 +CREATE INDEX concur_temp_ind_2 ON concur_temp_tab_2(c2) +-- +TABLE: name="concur_temp_tab_2" schema="" table="concur_temp_tab_2" ctx=DDL +STMT: IndexStmt +== 565 +REINDEX TABLE CONCURRENTLY concur_temp_tab_2 +-- +STMT: ReindexStmt +== 566 +REINDEX INDEX CONCURRENTLY concur_temp_ind_2 +-- +STMT: ReindexStmt +== 567 +-- ON COMMIT DROP +BEGIN +-- +STMT: TransactionStmt +== 568 +CREATE TEMP TABLE concur_temp_tab_3 (c1 int, c2 text) + ON COMMIT PRESERVE ROWS +-- +TABLE: name="concur_temp_tab_3" schema="" table="concur_temp_tab_3" ctx=DDL +STMT: CreateStmt +== 569 +INSERT INTO concur_temp_tab_3 VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp_tab_3" schema="" table="concur_temp_tab_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 570 +CREATE INDEX concur_temp_ind_3 ON concur_temp_tab_3(c2) +-- +TABLE: name="concur_temp_tab_3" schema="" table="concur_temp_tab_3" ctx=DDL +STMT: IndexStmt +== 571 +-- Fails when running in a transaction +REINDEX INDEX CONCURRENTLY concur_temp_ind_3 +-- +STMT: ReindexStmt +== 572 +COMMIT +-- +STMT: TransactionStmt +== 573 +-- REINDEX SCHEMA processes all temporary relations +CREATE TABLE reindex_temp_before AS +SELECT oid, relname, relfilenode, relkind, reltoastrelid + FROM pg_class + WHERE relname IN ('concur_temp_ind_1', 'concur_temp_ind_2') +-- +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 574 +SELECT pg_my_temp_schema()::regnamespace as temp_schema_name +-- +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +STMT: SelectStmt +== 575 +REINDEX SCHEMA CONCURRENTLY :temp_schema_name +-- +ERROR: syntax error at or near ":" +CURSORPOS: 29 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 576 +SELECT b.relname, + b.relkind, + CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged' + ELSE 'relfilenode has changed' END + FROM reindex_temp_before b JOIN pg_class a ON b.oid = a.oid + ORDER BY 1 +-- +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_class" +ALIAS: "b"="reindex_temp_before" +STMT: SelectStmt +== 577 +DROP TABLE concur_temp_tab_1, concur_temp_tab_2, reindex_temp_before +-- +TABLE: name="concur_temp_tab_1" schema="" table="concur_temp_tab_1" ctx=DDL +TABLE: name="concur_temp_tab_2" schema="" table="concur_temp_tab_2" ctx=DDL +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=DDL +STMT: DropStmt +== 578 +|-- +-- REINDEX SCHEMA +|-- +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +== 579 +-- failure, schema does not exist +CREATE SCHEMA schema_to_reindex +-- +STMT: CreateSchemaStmt +== 580 +SET search_path = 'schema_to_reindex' +-- +STMT: VariableSetStmt +== 581 +CREATE TABLE table1(col1 SERIAL PRIMARY KEY) +-- +TABLE: name="table1" schema="" table="table1" ctx=DDL +STMT: CreateStmt +== 582 +INSERT INTO table1 SELECT generate_series(1,400) +-- +TABLE: name="table1" schema="" table="table1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 583 +CREATE TABLE table2(col1 SERIAL PRIMARY KEY, col2 TEXT NOT NULL) +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: CreateStmt +== 584 +INSERT INTO table2 SELECT generate_series(1,400), 'abc' +-- +TABLE: name="table2" schema="" table="table2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 585 +CREATE INDEX ON table2(col2) +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: IndexStmt +== 586 +CREATE MATERIALIZED VIEW matview AS SELECT col1 FROM table2 +-- +TABLE: name="matview" schema="" table="matview" ctx=DDL +TABLE: name="table2" schema="" table="table2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 587 +CREATE INDEX ON matview(col1) +-- +TABLE: name="matview" schema="" table="matview" ctx=DDL +STMT: IndexStmt +== 588 +CREATE VIEW view AS SELECT col2 FROM table2 +-- +TABLE: name="view" schema="" table="view" ctx=DDL +TABLE: name="table2" schema="" table="table2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 589 +CREATE TABLE reindex_before AS +SELECT oid, relname, relfilenode, relkind, reltoastrelid + FROM pg_class + where relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'schema_to_reindex') +-- +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 590 +INSERT INTO reindex_before +SELECT oid, 'pg_toast_TABLE', relfilenode, relkind, reltoastrelid +FROM pg_class WHERE oid IN + (SELECT reltoastrelid FROM reindex_before WHERE reltoastrelid > 0) +-- +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=DML +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=Select +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="reltoastrelid" +STMT: InsertStmt +STMT: SelectStmt +== 591 +INSERT INTO reindex_before +SELECT oid, 'pg_toast_TABLE_index', relfilenode, relkind, reltoastrelid +FROM pg_class where oid in + (select indexrelid from pg_index where indrelid in + (select reltoastrelid from reindex_before where reltoastrelid > 0)) +-- +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=DML +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=Select +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="reltoastrelid" +STMT: InsertStmt +STMT: SelectStmt +== 592 +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +== 593 +CREATE TABLE reindex_after AS SELECT oid, relname, relfilenode, relkind + FROM pg_class + where relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'schema_to_reindex') +-- +TABLE: name="reindex_after" schema="" table="reindex_after" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 594 +SELECT b.relname, + b.relkind, + CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged' + ELSE 'relfilenode has changed' END + FROM reindex_before b JOIN pg_class a ON b.oid = a.oid + ORDER BY 1 +-- +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_class" +ALIAS: "b"="reindex_before" +STMT: SelectStmt +== 595 +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +== 596 +BEGIN +-- +STMT: TransactionStmt +== 597 +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +== 598 +-- failure, cannot run in a transaction +END +-- +STMT: TransactionStmt +== 599 +-- concurrently +REINDEX SCHEMA CONCURRENTLY schema_to_reindex +-- +STMT: ReindexStmt +== 600 +-- Failure for unauthorized user +CREATE ROLE regress_reindexuser NOLOGIN +-- +STMT: CreateRoleStmt +== 601 +SET SESSION ROLE regress_reindexuser +-- +STMT: VariableSetStmt +== 602 +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +== 603 +-- Permission failures with toast tables and indexes (pg_authid here) +RESET ROLE +-- +STMT: VariableSetStmt +== 604 +GRANT USAGE ON SCHEMA pg_toast TO regress_reindexuser +-- +STMT: GrantStmt +== 605 +SET SESSION ROLE regress_reindexuser +-- +STMT: VariableSetStmt +== 606 +REINDEX TABLE pg_toast.pg_toast_1260 +-- +STMT: ReindexStmt +== 607 +REINDEX INDEX pg_toast.pg_toast_1260_index +-- +STMT: ReindexStmt +== 608 +-- Clean up +RESET ROLE +-- +STMT: VariableSetStmt +== 609 +REVOKE USAGE ON SCHEMA pg_toast FROM regress_reindexuser +-- +STMT: GrantStmt +== 610 +DROP ROLE regress_reindexuser +-- +STMT: DropRoleStmt +== 611 +DROP SCHEMA schema_to_reindex CASCADE +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/create_index_spgist.metadata.json b/parser/testdata/summary/postgres_regress/create_index_spgist.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_index_spgist.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_index_spgist.test b/parser/testdata/summary/postgres_regress/create_index_spgist.test new file mode 100644 index 0000000..5640897 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_index_spgist.test @@ -0,0 +1,1585 @@ +== 001 +|-- +-- SP-GiST index tests +|-- + +CREATE TABLE quad_point_tbl AS + SELECT point(unique1,unique2) AS p FROM tenk1 +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 002 +INSERT INTO quad_point_tbl + SELECT '(333.0,400.0)'::point FROM generate_series(1,1000) +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO quad_point_tbl VALUES (NULL), (NULL), (NULL) +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +CREATE INDEX sp_quad_ind ON quad_point_tbl USING spgist (p) +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=DDL +STMT: IndexStmt +== 005 +CREATE TABLE kd_point_tbl AS SELECT * FROM quad_point_tbl +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 006 +CREATE INDEX sp_kd_ind ON kd_point_tbl USING spgist (p kd_point_ops) +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=DDL +STMT: IndexStmt +== 007 +CREATE TABLE radix_text_tbl AS + SELECT name AS t FROM road WHERE name !~ '^[0-9]' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DDL +TABLE: name="road" schema="" table="road" ctx=Select +FILTER: schema="" table="" column="name" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 008 +INSERT INTO radix_text_tbl + SELECT 'P0123456789abcdef' FROM generate_series(1,1000) +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO radix_text_tbl VALUES ('P0123456789abcde') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO radix_text_tbl VALUES ('P0123456789abcdefF') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +CREATE INDEX sp_radix_ind ON radix_text_tbl USING spgist (t) +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DDL +STMT: IndexStmt +== 012 +-- get non-indexed results for comparison purposes + +SET enable_seqscan = ON +-- +STMT: VariableSetStmt +== 013 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +== 014 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 015 +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 016 +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 017 +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 019 +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 020 +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 021 +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 022 +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 023 +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 024 +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 025 +CREATE TEMP TABLE quad_point_tbl_ord_seq1 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 026 +CREATE TEMP TABLE quad_point_tbl_ord_seq2 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl_ord_seq2" schema="" table="quad_point_tbl_ord_seq2" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 027 +CREATE TEMP TABLE quad_point_tbl_ord_seq3 AS +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl_ord_seq3" schema="" table="quad_point_tbl_ord_seq3" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 028 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 029 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 030 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 031 +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 032 +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 033 +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 034 +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 035 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 036 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 037 +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 038 +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 039 +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 040 +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 041 +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 042 +-- Now check the results from plain indexscan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 043 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +== 044 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 045 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 046 +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 047 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 048 +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 049 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 050 +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 051 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 052 +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 053 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 054 +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 055 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 056 +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 057 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 058 +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 059 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 060 +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 061 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 062 +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 063 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 064 +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 065 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 066 +CREATE TEMP TABLE quad_point_tbl_ord_idx1 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl_ord_idx1" schema="" table="quad_point_tbl_ord_idx1" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 067 +SELECT * FROM quad_point_tbl_ord_seq1 seq FULL JOIN quad_point_tbl_ord_idx1 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=Select +TABLE: name="quad_point_tbl_ord_idx1" schema="" table="quad_point_tbl_ord_idx1" ctx=Select +ALIAS: "idx"="quad_point_tbl_ord_idx1" +ALIAS: "seq"="quad_point_tbl_ord_seq1" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +== 068 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 069 +CREATE TEMP TABLE quad_point_tbl_ord_idx2 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl_ord_idx2" schema="" table="quad_point_tbl_ord_idx2" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 070 +SELECT * FROM quad_point_tbl_ord_seq2 seq FULL JOIN quad_point_tbl_ord_idx2 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq2" schema="" table="quad_point_tbl_ord_seq2" ctx=Select +TABLE: name="quad_point_tbl_ord_idx2" schema="" table="quad_point_tbl_ord_idx2" ctx=Select +ALIAS: "idx"="quad_point_tbl_ord_idx2" +ALIAS: "seq"="quad_point_tbl_ord_seq2" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +== 071 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 072 +CREATE TEMP TABLE quad_point_tbl_ord_idx3 AS +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl_ord_idx3" schema="" table="quad_point_tbl_ord_idx3" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 073 +SELECT * FROM quad_point_tbl_ord_seq3 seq FULL JOIN quad_point_tbl_ord_idx3 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq3" schema="" table="quad_point_tbl_ord_seq3" ctx=Select +TABLE: name="quad_point_tbl_ord_idx3" schema="" table="quad_point_tbl_ord_idx3" ctx=Select +ALIAS: "idx"="quad_point_tbl_ord_idx3" +ALIAS: "seq"="quad_point_tbl_ord_seq3" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +== 074 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 075 +SELECT count(*) FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 076 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 077 +SELECT count(*) FROM kd_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 078 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 079 +SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 080 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 081 +SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 082 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 083 +SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 084 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 085 +SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 086 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 087 +SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 088 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM kd_point_tbl +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 089 +CREATE TEMP TABLE kd_point_tbl_ord_idx1 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM kd_point_tbl +-- +TABLE: name="kd_point_tbl_ord_idx1" schema="" table="kd_point_tbl_ord_idx1" ctx=DDL +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 090 +SELECT * FROM quad_point_tbl_ord_seq1 seq FULL JOIN kd_point_tbl_ord_idx1 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=Select +TABLE: name="kd_point_tbl_ord_idx1" schema="" table="kd_point_tbl_ord_idx1" ctx=Select +ALIAS: "idx"="kd_point_tbl_ord_idx1" +ALIAS: "seq"="quad_point_tbl_ord_seq1" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +== 091 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 092 +CREATE TEMP TABLE kd_point_tbl_ord_idx2 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl_ord_idx2" schema="" table="kd_point_tbl_ord_idx2" ctx=DDL +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 093 +SELECT * FROM quad_point_tbl_ord_seq2 seq FULL JOIN kd_point_tbl_ord_idx2 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq2" schema="" table="quad_point_tbl_ord_seq2" ctx=Select +TABLE: name="kd_point_tbl_ord_idx2" schema="" table="kd_point_tbl_ord_idx2" ctx=Select +ALIAS: "idx"="kd_point_tbl_ord_idx2" +ALIAS: "seq"="quad_point_tbl_ord_seq2" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +== 094 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM kd_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 095 +CREATE TEMP TABLE kd_point_tbl_ord_idx3 AS +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM kd_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="kd_point_tbl_ord_idx3" schema="" table="kd_point_tbl_ord_idx3" ctx=DDL +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 096 +SELECT * FROM quad_point_tbl_ord_seq3 seq FULL JOIN kd_point_tbl_ord_idx3 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq3" schema="" table="quad_point_tbl_ord_seq3" ctx=Select +TABLE: name="kd_point_tbl_ord_idx3" schema="" table="kd_point_tbl_ord_idx3" ctx=Select +ALIAS: "idx"="kd_point_tbl_ord_idx3" +ALIAS: "seq"="quad_point_tbl_ord_seq3" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +== 097 +-- test KNN scan with included columns +-- the distance numbers are not exactly the same across platforms +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +== 098 +CREATE INDEX ON quad_point_tbl_ord_seq1 USING spgist(p) INCLUDE(dist) +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=DDL +STMT: IndexStmt +== 099 +EXPLAIN (COSTS OFF) +SELECT p, dist FROM quad_point_tbl_ord_seq1 ORDER BY p <-> '0,0' LIMIT 10 +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 100 +SELECT p, dist FROM quad_point_tbl_ord_seq1 ORDER BY p <-> '0,0' LIMIT 10 +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=Select +STMT: SelectStmt +== 101 +RESET extra_float_digits +-- +STMT: VariableSetStmt +== 102 +-- check ORDER BY distance to NULL +SELECT (SELECT p FROM kd_point_tbl ORDER BY p <-> pt, p <-> '0,0' LIMIT 1) +FROM (VALUES (point '1,2'), (NULL), ('1234,5678')) pts(pt) +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +STMT: SelectStmt +== 103 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 104 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 105 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 106 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 107 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 108 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 109 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 110 +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 111 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 112 +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 113 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 114 +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 115 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 116 +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 117 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 118 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 119 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 120 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 121 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 122 +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 123 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 124 +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 125 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 126 +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 127 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 128 +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 129 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 130 +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 131 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 132 +SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 133 +-- Now check the results from bitmap indexscan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 134 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +== 135 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +== 136 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 137 +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 138 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 139 +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 140 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 141 +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 142 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 143 +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 144 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 145 +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 146 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 147 +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 148 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 149 +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 150 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 151 +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 152 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 153 +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 154 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 155 +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 156 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 157 +SELECT count(*) FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 158 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 159 +SELECT count(*) FROM kd_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 160 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 161 +SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 162 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 163 +SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 164 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 165 +SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 166 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 167 +SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 168 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 169 +SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 170 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 171 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 172 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 173 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 174 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 175 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 176 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 177 +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 178 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 179 +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 180 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 181 +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 182 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 183 +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 184 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 185 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 186 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 187 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 188 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 189 +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 190 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 191 +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 192 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 193 +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 194 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 195 +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 196 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 197 +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 198 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 199 +SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 200 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 201 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 202 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/create_misc.metadata.json b/parser/testdata/summary/postgres_regress/create_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_misc.test b/parser/testdata/summary/postgres_regress/create_misc.test new file mode 100644 index 0000000..1d02053 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_misc.test @@ -0,0 +1,588 @@ +== 001 +|-- +-- CREATE_MISC +|-- + +|-- +-- a is the type root +-- b and c inherit from a (one-level single inheritance) +-- d inherits from b and c (two-level multiple inheritance) +-- e inherits from c (two-level single inheritance) +-- f inherits from e (three-level single inheritance) +|-- +CREATE TABLE a_star ( + class char, + a int4 +) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE b_star ( + b text +) INHERITS (a_star) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE c_star ( + c name +) INHERITS (a_star) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE d_star ( + d float8 +) INHERITS (b_star, c_star) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DDL +STMT: CreateStmt +== 005 +CREATE TABLE e_star ( + e int2 +) INHERITS (c_star) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: CreateStmt +== 006 +CREATE TABLE f_star ( + f polygon +) INHERITS (e_star) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: CreateStmt +== 007 +INSERT INTO a_star (class, a) VALUES ('a', 1) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO a_star (class, a) VALUES ('a', 2) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO a_star (class) VALUES ('a') +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO b_star (class, a, b) VALUES ('b', 3, 'mumble'::text) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO b_star (class, a) VALUES ('b', 4) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO b_star (class, b) VALUES ('b', 'bumble'::text) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO b_star (class) VALUES ('b') +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO c_star (class, a, c) VALUES ('c', 5, 'hi mom'::name) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO c_star (class, a) VALUES ('c', 6) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO c_star (class, c) VALUES ('c', 'hi paul'::name) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO c_star (class) VALUES ('c') +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO d_star (class, a, b, c, d) + VALUES ('d', 7, 'grumble'::text, 'hi sunita'::name, '0.0'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO d_star (class, a, b, c) + VALUES ('d', 8, 'stumble'::text, 'hi koko'::name) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO d_star (class, a, b, d) + VALUES ('d', 9, 'rumble'::text, '1.1'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO d_star (class, a, c, d) + VALUES ('d', 10, 'hi kristin'::name, '10.01'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO d_star (class, b, c, d) + VALUES ('d', 'crumble'::text, 'hi boris'::name, '100.001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO d_star (class, a, b) + VALUES ('d', 11, 'fumble'::text) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO d_star (class, a, c) + VALUES ('d', 12, 'hi avi'::name) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO d_star (class, a, d) + VALUES ('d', 13, '1000.0001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO d_star (class, b, c) + VALUES ('d', 'tumble'::text, 'hi andrew'::name) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO d_star (class, b, d) + VALUES ('d', 'humble'::text, '10000.00001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO d_star (class, c, d) + VALUES ('d', 'hi ginger'::name, '100000.000001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +INSERT INTO d_star (class, a) VALUES ('d', 14) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO d_star (class, b) VALUES ('d', 'jumble'::text) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO d_star (class, c) VALUES ('d', 'hi jolly'::name) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO d_star (class, d) VALUES ('d', '1000000.0000001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO d_star (class) VALUES ('d') +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO e_star (class, a, c, e) + VALUES ('e', 15, 'hi carol'::name, '-1'::int2) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO e_star (class, a, c) + VALUES ('e', 16, 'hi bob'::name) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +INSERT INTO e_star (class, a, e) + VALUES ('e', 17, '-2'::int2) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO e_star (class, c, e) + VALUES ('e', 'hi michelle'::name, '-3'::int2) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO e_star (class, a) + VALUES ('e', 18) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO e_star (class, c) + VALUES ('e', 'hi elisa'::name) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO e_star (class, e) + VALUES ('e', '-4'::int2) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO f_star (class, a, c, e, f) + VALUES ('f', 19, 'hi claire'::name, '-5'::int2, '(1,3),(2,4)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO f_star (class, a, c, e) + VALUES ('f', 20, 'hi mike'::name, '-6'::int2) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO f_star (class, a, c, f) + VALUES ('f', 21, 'hi marcel'::name, '(11,44),(22,55),(33,66)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO f_star (class, a, e, f) + VALUES ('f', 22, '-7'::int2, '(111,555),(222,666),(333,777),(444,888)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO f_star (class, c, e, f) + VALUES ('f', 'hi keith'::name, '-8'::int2, + '(1111,3333),(2222,4444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO f_star (class, a, c) + VALUES ('f', 24, 'hi marc'::name) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO f_star (class, a, e) + VALUES ('f', 25, '-9'::int2) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO f_star (class, a, f) + VALUES ('f', 26, '(11111,33333),(22222,44444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +INSERT INTO f_star (class, c, e) + VALUES ('f', 'hi allison'::name, '-10'::int2) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO f_star (class, c, f) + VALUES ('f', 'hi jeff'::name, + '(111111,333333),(222222,444444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +INSERT INTO f_star (class, e, f) + VALUES ('f', '-11'::int2, '(1111111,3333333),(2222222,4444444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO f_star (class, a) VALUES ('f', 27) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +INSERT INTO f_star (class, c) VALUES ('f', 'hi carl'::name) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +INSERT INTO f_star (class, e) VALUES ('f', '-12'::int2) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +INSERT INTO f_star (class, f) + VALUES ('f', '(11111111,33333333),(22222222,44444444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +INSERT INTO f_star (class) VALUES ('f') +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +-- Analyze the X_star tables for better plan stability in later tests +ANALYZE a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: VacuumStmt +== 058 +ANALYZE b_star +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DDL +STMT: VacuumStmt +== 059 +ANALYZE c_star +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DDL +STMT: VacuumStmt +== 060 +ANALYZE d_star +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DDL +STMT: VacuumStmt +== 061 +ANALYZE e_star +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: VacuumStmt +== 062 +ANALYZE f_star +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: VacuumStmt +== 063 +|-- +-- inheritance stress test +|-- +SELECT * FROM a_star* +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +STMT: SelectStmt +== 064 +SELECT * + FROM b_star* x + WHERE x.b = text 'bumble' or x.a < 3 +-- +TABLE: name="b_star" schema="" table="b_star" ctx=Select +ALIAS: "x"="b_star" +FILTER: schema="" table="x" column="b" +FILTER: schema="" table="x" column="a" +STMT: SelectStmt +== 065 +SELECT class, a + FROM c_star* x + WHERE x.c ~ text 'hi' +-- +TABLE: name="c_star" schema="" table="c_star" ctx=Select +ALIAS: "x"="c_star" +FILTER: schema="" table="x" column="c" +STMT: SelectStmt +== 066 +SELECT class, b, c + FROM d_star* x + WHERE x.a < 100 +-- +TABLE: name="d_star" schema="" table="d_star" ctx=Select +ALIAS: "x"="d_star" +FILTER: schema="" table="x" column="a" +STMT: SelectStmt +== 067 +SELECT class, c FROM e_star* x WHERE x.c NOTNULL +-- +TABLE: name="e_star" schema="" table="e_star" ctx=Select +ALIAS: "x"="e_star" +FILTER: schema="" table="x" column="c" +STMT: SelectStmt +== 068 +SELECT * FROM f_star* x WHERE x.c ISNULL +-- +TABLE: name="f_star" schema="" table="f_star" ctx=Select +ALIAS: "x"="f_star" +FILTER: schema="" table="x" column="c" +STMT: SelectStmt +== 069 +-- grouping and aggregation on inherited sets have been busted in the past... + +SELECT sum(a) FROM a_star* +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT class, sum(a) FROM a_star* GROUP BY class ORDER BY class +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 071 +ALTER TABLE f_star RENAME COLUMN f TO ff +-- +STMT: RenameStmt +== 072 +ALTER TABLE e_star* RENAME COLUMN e TO ee +-- +STMT: RenameStmt +== 073 +ALTER TABLE d_star* RENAME COLUMN d TO dd +-- +STMT: RenameStmt +== 074 +ALTER TABLE c_star* RENAME COLUMN c TO cc +-- +STMT: RenameStmt +== 075 +ALTER TABLE b_star* RENAME COLUMN b TO bb +-- +STMT: RenameStmt +== 076 +ALTER TABLE a_star* RENAME COLUMN a TO aa +-- +STMT: RenameStmt +== 077 +SELECT class, aa + FROM a_star* x + WHERE aa ISNULL +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "x"="a_star" +FILTER: schema="" table="" column="aa" +STMT: SelectStmt +== 078 +-- As of Postgres 7.1, ALTER implicitly recurses, +-- so this should be same as ALTER a_star* + +ALTER TABLE a_star RENAME COLUMN aa TO foo +-- +STMT: RenameStmt +== 079 +SELECT class, foo + FROM a_star* x + WHERE x.foo >= 2 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "x"="a_star" +FILTER: schema="" table="x" column="foo" +STMT: SelectStmt +== 080 +ALTER TABLE a_star RENAME COLUMN foo TO aa +-- +STMT: RenameStmt +== 081 +SELECT * + from a_star* + WHERE aa < 1000 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FILTER: schema="" table="" column="aa" +STMT: SelectStmt +== 082 +ALTER TABLE f_star ADD COLUMN f int4 +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: AlterTableStmt +== 083 +UPDATE f_star SET f = 10 +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: UpdateStmt +== 084 +ALTER TABLE e_star* ADD COLUMN e int4 +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: AlterTableStmt +== 085 +--UPDATE e_star* SET e = 42; + +SELECT * FROM e_star* +-- +TABLE: name="e_star" schema="" table="e_star" ctx=Select +STMT: SelectStmt +== 086 +ALTER TABLE a_star* ADD COLUMN a text +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: AlterTableStmt +== 087 +-- That ALTER TABLE should have added TOAST tables. +SELECT relname, reltoastrelid <> 0 AS has_toast_table + FROM pg_class + WHERE oid::regclass IN ('a_star', 'c_star') + ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 088 +--UPDATE b_star* +-- SET a = text 'gazpacho' +-- WHERE aa > 4; + +SELECT class, aa, a FROM a_star* +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/create_operator.metadata.json b/parser/testdata/summary/postgres_regress/create_operator.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_operator.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_operator.test b/parser/testdata/summary/postgres_regress/create_operator.test new file mode 100644 index 0000000..0969ac1 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_operator.test @@ -0,0 +1,530 @@ +== 001 +|-- +-- CREATE_OPERATOR +|-- + +CREATE OPERATOR ## ( + leftarg = path, + rightarg = path, + function = path_inter, + commutator = ## +) +-- +STMT: DefineStmt +== 002 +CREATE OPERATOR @#@ ( + rightarg = int8, -- prefix + procedure = factorial +) +-- +STMT: DefineStmt +== 003 +CREATE OPERATOR #%# ( + leftarg = int8, -- fail, postfix is no longer supported + procedure = factorial +) +-- +STMT: DefineStmt +== 004 +-- Test operator created above +SELECT @#@ 24 +-- +STMT: SelectStmt +== 005 +-- Test comments +COMMENT ON OPERATOR ###### (NONE, int4) IS 'bad prefix' +-- +STMT: CommentStmt +== 006 +COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad postfix' +-- +STMT: CommentStmt +== 007 +COMMENT ON OPERATOR ###### (int4, int8) IS 'bad infix' +-- +STMT: CommentStmt +== 008 +-- Check that DROP on a nonexistent op behaves sanely, too +DROP OPERATOR ###### (NONE, int4) +-- +STMT: DropStmt +== 009 +DROP OPERATOR ###### (int4, NONE) +-- +STMT: DropStmt +== 010 +DROP OPERATOR ###### (int4, int8) +-- +STMT: DropStmt +== 011 +-- => is disallowed as an operator name now +CREATE OPERATOR => ( + rightarg = int8, + procedure = factorial +) +-- +ERROR: syntax error at or near "=>" +CURSORPOS: 61 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +-- lexing of <=, >=, <>, != has a number of edge cases +-- (=> is tested elsewhere) + +-- this is legal because ! is not allowed in sql ops +CREATE OPERATOR !=- ( + rightarg = int8, + procedure = factorial +) +-- +STMT: DefineStmt +== 013 +SELECT !=- 10 +-- +STMT: SelectStmt +== 014 +-- postfix operators don't work anymore +SELECT 10 !=- +-- +ERROR: syntax error at end of input +CURSORPOS: 54 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 015 +-- make sure lexer returns != as <> even in edge cases +SELECT 2 !=/**/ 1, 2 !=/**/ 2 +-- +STMT: SelectStmt +== 016 +SELECT 2 !=-- comment to be removed by psql + 1 +-- +STMT: SelectStmt +== 017 +DO $$ -- use DO to protect -- from psql + declare r boolean; + begin + execute $e$ select 2 !=-- comment + 1 $e$ into r; + raise info 'r = %', r; + end; +$$ +-- +STMT: DoStmt +== 018 +-- check that <= etc. followed by more operator characters are returned +-- as the correct token with correct precedence +SELECT true<>-1 BETWEEN 1 AND 1 +-- +STMT: SelectStmt +== 019 +-- BETWEEN has prec. above <> but below Op +SELECT false<>/**/1 BETWEEN 1 AND 1 +-- +STMT: SelectStmt +== 020 +SELECT false<=-1 BETWEEN 1 AND 1 +-- +STMT: SelectStmt +== 021 +SELECT false>=-1 BETWEEN 1 AND 1 +-- +STMT: SelectStmt +== 022 +SELECT 2<=/**/3, 3>=/**/2, 2<>/**/3 +-- +STMT: SelectStmt +== 023 +SELECT 3<=/**/2, 2>=/**/3, 2<>/**/2 +-- +STMT: SelectStmt +== 024 +-- Should fail. CREATE OPERATOR requires USAGE on SCHEMA +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 025 +CREATE ROLE regress_rol_op1 +-- +STMT: CreateRoleStmt +== 026 +CREATE SCHEMA schema_op1 +-- +STMT: CreateSchemaStmt +== 027 +GRANT USAGE ON SCHEMA schema_op1 TO PUBLIC +-- +STMT: GrantStmt +== 028 +REVOKE USAGE ON SCHEMA schema_op1 FROM regress_rol_op1 +-- +STMT: GrantStmt +== 029 +SET ROLE regress_rol_op1 +-- +STMT: VariableSetStmt +== 030 +CREATE OPERATOR schema_op1.#*# ( + rightarg = int8, + procedure = factorial +) +-- +STMT: DefineStmt +== 031 +ROLLBACK +-- +STMT: TransactionStmt +== 032 +-- Should fail. SETOF type functions not allowed as argument (testing leftarg) +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 033 +CREATE OPERATOR #*# ( + leftarg = SETOF int8, + procedure = factorial +) +-- +STMT: DefineStmt +== 034 +ROLLBACK +-- +STMT: TransactionStmt +== 035 +-- Should fail. SETOF type functions not allowed as argument (testing rightarg) +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 036 +CREATE OPERATOR #*# ( + rightarg = SETOF int8, + procedure = factorial +) +-- +STMT: DefineStmt +== 037 +ROLLBACK +-- +STMT: TransactionStmt +== 038 +-- Should work. Sample text-book case +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 039 +CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean) +RETURNS boolean AS $$ + SELECT NULL::BOOLEAN; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op2" function="fn_op2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 040 +CREATE OPERATOR === ( + LEFTARG = boolean, + RIGHTARG = boolean, + PROCEDURE = fn_op2, + COMMUTATOR = ===, + NEGATOR = !==, + RESTRICT = contsel, + JOIN = contjoinsel, + SORT1, SORT2, LTCMP, GTCMP, HASHES, MERGES +) +-- +STMT: DefineStmt +== 041 +ROLLBACK +-- +STMT: TransactionStmt +== 042 +-- Should fail. Invalid attribute +CREATE OPERATOR #@%# ( + rightarg = int8, + procedure = factorial, + invalid_att = int8 +) +-- +STMT: DefineStmt +== 043 +-- Should fail. At least rightarg should be mandatorily specified +CREATE OPERATOR #@%# ( + procedure = factorial +) +-- +STMT: DefineStmt +== 044 +-- Should fail. Procedure should be mandatorily specified +CREATE OPERATOR #@%# ( + rightarg = int8 +) +-- +STMT: DefineStmt +== 045 +-- Should fail. CREATE OPERATOR requires USAGE on TYPE +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 046 +CREATE ROLE regress_rol_op3 +-- +STMT: CreateRoleStmt +== 047 +CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +== 048 +CREATE FUNCTION fn_op3(type_op3, int8) +RETURNS int8 AS $$ + SELECT NULL::int8; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op3" function="fn_op3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 049 +REVOKE USAGE ON TYPE type_op3 FROM regress_rol_op3 +-- +STMT: GrantStmt +== 050 +REVOKE USAGE ON TYPE type_op3 FROM PUBLIC +-- +STMT: GrantStmt +== 051 +-- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC +SET ROLE regress_rol_op3 +-- +STMT: VariableSetStmt +== 052 +CREATE OPERATOR #*# ( + leftarg = type_op3, + rightarg = int8, + procedure = fn_op3 +) +-- +STMT: DefineStmt +== 053 +ROLLBACK +-- +STMT: TransactionStmt +== 054 +-- Should fail. CREATE OPERATOR requires USAGE on TYPE (need to check separately for rightarg) +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 055 +CREATE ROLE regress_rol_op4 +-- +STMT: CreateRoleStmt +== 056 +CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +== 057 +CREATE FUNCTION fn_op4(int8, type_op4) +RETURNS int8 AS $$ + SELECT NULL::int8; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op4" function="fn_op4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 058 +REVOKE USAGE ON TYPE type_op4 FROM regress_rol_op4 +-- +STMT: GrantStmt +== 059 +REVOKE USAGE ON TYPE type_op4 FROM PUBLIC +-- +STMT: GrantStmt +== 060 +-- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC +SET ROLE regress_rol_op4 +-- +STMT: VariableSetStmt +== 061 +CREATE OPERATOR #*# ( + leftarg = int8, + rightarg = type_op4, + procedure = fn_op4 +) +-- +STMT: DefineStmt +== 062 +ROLLBACK +-- +STMT: TransactionStmt +== 063 +-- Should fail. CREATE OPERATOR requires EXECUTE on function +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 064 +CREATE ROLE regress_rol_op5 +-- +STMT: CreateRoleStmt +== 065 +CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +== 066 +CREATE FUNCTION fn_op5(int8, int8) +RETURNS int8 AS $$ + SELECT NULL::int8; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op5" function="fn_op5" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 067 +REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5 +-- +FUNCTION: name="fn_op5" function="fn_op5" schema="" ctx=DDL +STMT: GrantStmt +== 068 +REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC +-- +FUNCTION: name="fn_op5" function="fn_op5" schema="" ctx=DDL +STMT: GrantStmt +== 069 +-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC +SET ROLE regress_rol_op5 +-- +STMT: VariableSetStmt +== 070 +CREATE OPERATOR #*# ( + leftarg = int8, + rightarg = int8, + procedure = fn_op5 +) +-- +STMT: DefineStmt +== 071 +ROLLBACK +-- +STMT: TransactionStmt +== 072 +-- Should fail. CREATE OPERATOR requires USAGE on return TYPE +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 073 +CREATE ROLE regress_rol_op6 +-- +STMT: CreateRoleStmt +== 074 +CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +== 075 +CREATE FUNCTION fn_op6(int8, int8) +RETURNS type_op6 AS $$ + SELECT NULL::type_op6; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op6" function="fn_op6" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 076 +REVOKE USAGE ON TYPE type_op6 FROM regress_rol_op6 +-- +STMT: GrantStmt +== 077 +REVOKE USAGE ON TYPE type_op6 FROM PUBLIC +-- +STMT: GrantStmt +== 078 +-- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC +SET ROLE regress_rol_op6 +-- +STMT: VariableSetStmt +== 079 +CREATE OPERATOR #*# ( + leftarg = int8, + rightarg = int8, + procedure = fn_op6 +) +-- +STMT: DefineStmt +== 080 +ROLLBACK +-- +STMT: TransactionStmt +== 081 +-- Should fail. An operator cannot be its own negator. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 082 +CREATE OPERATOR === ( + leftarg = integer, + rightarg = integer, + procedure = int4eq, + negator = === +) +-- +STMT: DefineStmt +== 083 +ROLLBACK +-- +STMT: TransactionStmt +== 084 +-- Should fail. An operator cannot be its own negator. Here we check that +-- this error is detected when replacing a shell operator. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 085 +-- create a shell operator for ===!!! by referencing it as a commutator +CREATE OPERATOR === ( + leftarg = integer, + rightarg = integer, + procedure = int4eq, + commutator = ===!!! +) +-- +STMT: DefineStmt +== 086 +CREATE OPERATOR ===!!! ( + leftarg = integer, + rightarg = integer, + procedure = int4ne, + negator = ===!!! +) +-- +STMT: DefineStmt +== 087 +ROLLBACK +-- +STMT: TransactionStmt +== 088 +-- test that we can't use part of an existing commutator or negator pair +-- as a commutator or negator +CREATE OPERATOR === ( + leftarg = integer, + rightarg = integer, + procedure = int4eq, + commutator = = +) +-- +STMT: DefineStmt +== 089 +CREATE OPERATOR === ( + leftarg = integer, + rightarg = integer, + procedure = int4eq, + negator = <> +) +-- +STMT: DefineStmt +== 090 +-- invalid: non-lowercase quoted identifiers +CREATE OPERATOR === +( + "Leftarg" = box, + "Rightarg" = box, + "Procedure" = area_equal_function, + "Commutator" = ===, + "Negator" = !==, + "Restrict" = area_restriction_function, + "Join" = area_join_function, + "Hashes", + "Merges" +) +-- +STMT: DefineStmt diff --git a/parser/testdata/summary/postgres_regress/create_procedure.metadata.json b/parser/testdata/summary/postgres_regress/create_procedure.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_procedure.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_procedure.test b/parser/testdata/summary/postgres_regress/create_procedure.test new file mode 100644 index 0000000..b74f207 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_procedure.test @@ -0,0 +1,654 @@ +== 001 +CALL nonexistent() +-- +FUNCTION: name="nonexistent" function="nonexistent" schema="" ctx=Call +STMT: CallStmt +== 002 +-- error +CALL random() +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: CallStmt +== 003 +-- error + +CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQL AS $$ SELECT a $$ +-- +FUNCTION: name="cp_testfunc1" function="cp_testfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 004 +CREATE TABLE cp_test (a int, b text) +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: CreateStmt +== 005 +CREATE PROCEDURE ptest1(x text) +LANGUAGE SQL +AS $$ +INSERT INTO cp_test VALUES (1, x); +$$ +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +SELECT pg_get_functiondef('ptest1'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- show only normal functions + +-- show only procedures + +SELECT ptest1('x') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- error +CALL ptest1('a') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: CallStmt +== 009 +-- ok +CALL ptest1('xy' || 'zzy') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: CallStmt +== 010 +-- ok, constant-folded arg +CALL ptest1(substring(random()::numeric(20,15)::text, 1, 1)) +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +FUNCTION: name="substring" function="substring" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: CallStmt +== 011 +-- ok, volatile arg + +SELECT * FROM cp_test ORDER BY b COLLATE "C" +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=Select +STMT: SelectStmt +== 012 +-- SQL-standard body +CREATE PROCEDURE ptest1s(x text) +LANGUAGE SQL +BEGIN ATOMIC + INSERT INTO cp_test VALUES (1, x) +-- +ERROR: syntax error at end of input +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 013 +END +-- +STMT: TransactionStmt +== 014 +SELECT pg_get_functiondef('ptest1s'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 015 +CALL ptest1s('b') +-- +FUNCTION: name="ptest1s" function="ptest1s" schema="" ctx=Call +STMT: CallStmt +== 016 +SELECT * FROM cp_test ORDER BY b COLLATE "C" +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=Select +STMT: SelectStmt +== 017 +-- utility functions currently not supported here +CREATE PROCEDURE ptestx() +LANGUAGE SQL +BEGIN ATOMIC + CREATE TABLE x (a int) +-- +ERROR: syntax error at end of input +CURSORPOS: 127 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 018 +END +-- +STMT: TransactionStmt +== 019 +CREATE PROCEDURE ptest2() +LANGUAGE SQL +AS $$ +SELECT 5; +$$ +-- +FUNCTION: name="ptest2" function="ptest2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 020 +CALL ptest2() +-- +FUNCTION: name="ptest2" function="ptest2" schema="" ctx=Call +STMT: CallStmt +== 021 +-- nested CALL +TRUNCATE cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: TruncateStmt +== 022 +CREATE PROCEDURE ptest3(y text) +LANGUAGE SQL +AS $$ +CALL ptest1(y); +CALL ptest1($1); +$$ +-- +FUNCTION: name="ptest3" function="ptest3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 023 +CALL ptest3('b') +-- +FUNCTION: name="ptest3" function="ptest3" schema="" ctx=Call +STMT: CallStmt +== 024 +SELECT * FROM cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=Select +STMT: SelectStmt +== 025 +-- output arguments + +CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int) +LANGUAGE SQL +AS $$ +SELECT 1, 2; +$$ +-- +FUNCTION: name="ptest4a" function="ptest4a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 026 +CALL ptest4a(NULL, NULL) +-- +FUNCTION: name="ptest4a" function="ptest4a" schema="" ctx=Call +STMT: CallStmt +== 027 +CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int) +LANGUAGE SQL +AS $$ +CALL ptest4a(a, b); -- error, not supported +$$ +-- +FUNCTION: name="ptest4b" function="ptest4b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 028 +-- we used to get confused by a single output argument that is composite +CREATE PROCEDURE ptest4c(INOUT comp int8_tbl) +LANGUAGE SQL +AS $$ +SELECT ROW(1, 2); +$$ +-- +FUNCTION: name="ptest4c" function="ptest4c" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +CALL ptest4c(NULL) +-- +FUNCTION: name="ptest4c" function="ptest4c" schema="" ctx=Call +STMT: CallStmt +== 030 +DROP PROCEDURE ptest4a, ptest4c +-- +STMT: DropStmt +== 031 +-- named and default parameters + +CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int default 100) +LANGUAGE SQL +AS $$ +INSERT INTO cp_test VALUES(a, b); +INSERT INTO cp_test VALUES(c, b); +$$ +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 032 +TRUNCATE cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: TruncateStmt +== 033 +CALL ptest5(10, 'Hello', 20) +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=Call +STMT: CallStmt +== 034 +CALL ptest5(10, 'Hello') +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=Call +STMT: CallStmt +== 035 +CALL ptest5(10, b => 'Hello') +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=Call +STMT: CallStmt +== 036 +CALL ptest5(b => 'Hello', a => 10) +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=Call +STMT: CallStmt +== 037 +SELECT * FROM cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=Select +STMT: SelectStmt +== 038 +-- polymorphic types + +CREATE PROCEDURE ptest6(a int, b anyelement) +LANGUAGE SQL +AS $$ +SELECT NULL::int; +$$ +-- +FUNCTION: name="ptest6" function="ptest6" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 039 +CALL ptest6(1, 2) +-- +FUNCTION: name="ptest6" function="ptest6" schema="" ctx=Call +STMT: CallStmt +== 040 +CREATE PROCEDURE ptest6a(inout a anyelement, out b anyelement) +LANGUAGE SQL +AS $$ +SELECT $1, $1; +$$ +-- +FUNCTION: name="ptest6a" function="ptest6a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 041 +CALL ptest6a(1, null) +-- +FUNCTION: name="ptest6a" function="ptest6a" schema="" ctx=Call +STMT: CallStmt +== 042 +CALL ptest6a(1.1, null) +-- +FUNCTION: name="ptest6a" function="ptest6a" schema="" ctx=Call +STMT: CallStmt +== 043 +CREATE PROCEDURE ptest6b(a anyelement, out b anyelement, out c anyarray) +LANGUAGE SQL +AS $$ +SELECT $1, array[$1]; +$$ +-- +FUNCTION: name="ptest6b" function="ptest6b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 044 +CALL ptest6b(1, null, null) +-- +FUNCTION: name="ptest6b" function="ptest6b" schema="" ctx=Call +STMT: CallStmt +== 045 +CALL ptest6b(1.1, null, null) +-- +FUNCTION: name="ptest6b" function="ptest6b" schema="" ctx=Call +STMT: CallStmt +== 046 +CREATE PROCEDURE ptest6c(inout a anyelement, inout b anyelement) +LANGUAGE SQL +AS $$ +SELECT $1, 1; +$$ +-- +FUNCTION: name="ptest6c" function="ptest6c" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 047 +CALL ptest6c(1, null) +-- +FUNCTION: name="ptest6c" function="ptest6c" schema="" ctx=Call +STMT: CallStmt +== 048 +CALL ptest6c(1.1, null) +-- +FUNCTION: name="ptest6c" function="ptest6c" schema="" ctx=Call +STMT: CallStmt +== 049 +-- fails before v13 + + +-- collation assignment + +CREATE PROCEDURE ptest7(a text, b text) +LANGUAGE SQL +AS $$ +SELECT a = b; +$$ +-- +FUNCTION: name="ptest7" function="ptest7" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 050 +CALL ptest7(least('a', 'b'), 'a') +-- +FUNCTION: name="ptest7" function="ptest7" schema="" ctx=Call +STMT: CallStmt +== 051 +-- empty body +CREATE PROCEDURE ptest8(x text) +BEGIN ATOMIC +END +-- +FUNCTION: name="ptest8" function="ptest8" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 052 +SELECT pg_get_functiondef('ptest8'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 053 +CALL ptest8('') +-- +FUNCTION: name="ptest8" function="ptest8" schema="" ctx=Call +STMT: CallStmt +== 054 +-- OUT parameters + +CREATE PROCEDURE ptest9(OUT a int) +LANGUAGE SQL +AS $$ +INSERT INTO cp_test VALUES (1, 'a'); +SELECT 1; +$$ +-- +FUNCTION: name="ptest9" function="ptest9" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 055 +-- standard way to do a call: +CALL ptest9(NULL) +-- +FUNCTION: name="ptest9" function="ptest9" schema="" ctx=Call +STMT: CallStmt +== 056 +-- you can write an expression, but it's not evaluated +CALL ptest9(1/0) +-- +FUNCTION: name="ptest9" function="ptest9" schema="" ctx=Call +STMT: CallStmt +== 057 +-- no error +-- ... and it had better match the type of the parameter +CALL ptest9(1./0.) +-- +FUNCTION: name="ptest9" function="ptest9" schema="" ctx=Call +STMT: CallStmt +== 058 +-- error + +-- check named-parameter matching +CREATE PROCEDURE ptest10(OUT a int, IN b int, IN c int) +LANGUAGE SQL AS $$ SELECT b - c $$ +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 059 +CALL ptest10(null, 7, 4) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +== 060 +CALL ptest10(a => null, b => 8, c => 2) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +== 061 +CALL ptest10(null, 7, c => 2) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +== 062 +CALL ptest10(null, c => 4, b => 11) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +== 063 +CALL ptest10(b => 8, c => 2, a => 0) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +== 064 +CREATE PROCEDURE ptest11(a OUT int, VARIADIC b int[]) LANGUAGE SQL + AS $$ SELECT b[1] + b[2] $$ +-- +FUNCTION: name="ptest11" function="ptest11" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 065 +CALL ptest11(null, 11, 12, 13) +-- +FUNCTION: name="ptest11" function="ptest11" schema="" ctx=Call +STMT: CallStmt +== 066 +-- check resolution of ambiguous DROP commands + +CREATE PROCEDURE ptest10(IN a int, IN b int, IN c int) +LANGUAGE SQL AS $$ SELECT a + b - c $$ +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 067 +drop procedure ptest10 +-- +STMT: DropStmt +== 068 +-- fail +drop procedure ptest10(int, int, int) +-- +STMT: DropStmt +== 069 +-- fail +begin +-- +STMT: TransactionStmt +== 070 +drop procedure ptest10(out int, int, int) +-- +STMT: DropStmt +== 071 +drop procedure ptest10(int, int, int) +-- +STMT: DropStmt +== 072 +-- now this would work +rollback +-- +STMT: TransactionStmt +== 073 +begin +-- +STMT: TransactionStmt +== 074 +drop procedure ptest10(in int, int, int) +-- +STMT: DropStmt +== 075 +drop procedure ptest10(int, int, int) +-- +STMT: DropStmt +== 076 +-- now this would work +rollback +-- +STMT: TransactionStmt +== 077 +-- various error cases + +CALL version() +-- +FUNCTION: name="version" function="version" schema="" ctx=Call +STMT: CallStmt +== 078 +-- error: not a procedure +CALL sum(1) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: CallStmt +== 079 +-- error: not a procedure + +CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$ +-- +FUNCTION: name="ptestx" function="ptestx" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 080 +CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$ +-- +FUNCTION: name="ptestx" function="ptestx" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 081 +CREATE PROCEDURE ptestx(a VARIADIC int[], b OUT int) LANGUAGE SQL + AS $$ SELECT a[1] $$ +-- +FUNCTION: name="ptestx" function="ptestx" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 082 +CREATE PROCEDURE ptestx(a int DEFAULT 42, b OUT int) LANGUAGE SQL + AS $$ SELECT a $$ +-- +FUNCTION: name="ptestx" function="ptestx" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 083 +ALTER PROCEDURE ptest1(text) STRICT +-- +STMT: AlterFunctionStmt +== 084 +ALTER FUNCTION ptest1(text) VOLATILE +-- +STMT: AlterFunctionStmt +== 085 +-- error: not a function +ALTER PROCEDURE cp_testfunc1(int) VOLATILE +-- +STMT: AlterFunctionStmt +== 086 +-- error: not a procedure +ALTER PROCEDURE nonexistent() VOLATILE +-- +STMT: AlterFunctionStmt +== 087 +DROP FUNCTION ptest1(text) +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: DropStmt +== 088 +-- error: not a function +DROP PROCEDURE cp_testfunc1(int) +-- +STMT: DropStmt +== 089 +-- error: not a procedure +DROP PROCEDURE nonexistent() +-- +STMT: DropStmt +== 090 +-- privileges + +CREATE USER regress_cp_user1 +-- +STMT: CreateRoleStmt +== 091 +GRANT INSERT ON cp_test TO regress_cp_user1 +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: GrantStmt +== 092 +REVOKE EXECUTE ON PROCEDURE ptest1(text) FROM PUBLIC +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: GrantStmt +== 093 +SET ROLE regress_cp_user1 +-- +STMT: VariableSetStmt +== 094 +CALL ptest1('a') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: CallStmt +== 095 +-- error +RESET ROLE +-- +STMT: VariableSetStmt +== 096 +GRANT EXECUTE ON PROCEDURE ptest1(text) TO regress_cp_user1 +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: GrantStmt +== 097 +SET ROLE regress_cp_user1 +-- +STMT: VariableSetStmt +== 098 +CALL ptest1('a') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: CallStmt +== 099 +-- ok +RESET ROLE +-- +STMT: VariableSetStmt +== 100 +-- ROUTINE syntax + +ALTER ROUTINE cp_testfunc1(int) RENAME TO cp_testfunc1a +-- +FUNCTION: name="cp_testfunc1" function="cp_testfunc1" schema="" ctx=DDL +FUNCTION: name="cp_testfunc1a" function="cp_testfunc1a" schema="" ctx=DDL +STMT: RenameStmt +== 101 +ALTER ROUTINE cp_testfunc1a RENAME TO cp_testfunc1 +-- +FUNCTION: name="cp_testfunc1a" function="cp_testfunc1a" schema="" ctx=DDL +FUNCTION: name="cp_testfunc1" function="cp_testfunc1" schema="" ctx=DDL +STMT: RenameStmt +== 102 +ALTER ROUTINE ptest1(text) RENAME TO ptest1a +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +FUNCTION: name="ptest1a" function="ptest1a" schema="" ctx=DDL +STMT: RenameStmt +== 103 +ALTER ROUTINE ptest1a RENAME TO ptest1 +-- +FUNCTION: name="ptest1a" function="ptest1a" schema="" ctx=DDL +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: RenameStmt +== 104 +DROP ROUTINE cp_testfunc1(int) +-- +STMT: DropStmt +== 105 +-- cleanup + +DROP PROCEDURE ptest1 +-- +STMT: DropStmt +== 106 +DROP PROCEDURE ptest1s +-- +STMT: DropStmt +== 107 +DROP PROCEDURE ptest2 +-- +STMT: DropStmt +== 108 +DROP TABLE cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: DropStmt +== 109 +DROP USER regress_cp_user1 +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/create_role.metadata.json b/parser/testdata/summary/postgres_regress/create_role.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_role.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_role.test b/parser/testdata/summary/postgres_regress/create_role.test new file mode 100644 index 0000000..5438158 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_role.test @@ -0,0 +1,609 @@ +== 001 +-- ok, superuser can create users with any set of privileges +CREATE ROLE regress_role_super SUPERUSER +-- +STMT: CreateRoleStmt +== 002 +CREATE ROLE regress_role_admin CREATEDB CREATEROLE REPLICATION BYPASSRLS +-- +STMT: CreateRoleStmt +== 003 +GRANT CREATE ON DATABASE regression TO regress_role_admin WITH GRANT OPTION +-- +STMT: GrantStmt +== 004 +CREATE ROLE regress_role_limited_admin CREATEROLE +-- +STMT: CreateRoleStmt +== 005 +CREATE ROLE regress_role_normal +-- +STMT: CreateRoleStmt +== 006 +-- fail, CREATEROLE user can't give away role attributes without having them +SET SESSION AUTHORIZATION regress_role_limited_admin +-- +STMT: VariableSetStmt +== 007 +CREATE ROLE regress_nosuch_superuser SUPERUSER +-- +STMT: CreateRoleStmt +== 008 +CREATE ROLE regress_nosuch_replication_bypassrls REPLICATION BYPASSRLS +-- +STMT: CreateRoleStmt +== 009 +CREATE ROLE regress_nosuch_replication REPLICATION +-- +STMT: CreateRoleStmt +== 010 +CREATE ROLE regress_nosuch_bypassrls BYPASSRLS +-- +STMT: CreateRoleStmt +== 011 +CREATE ROLE regress_nosuch_createdb CREATEDB +-- +STMT: CreateRoleStmt +== 012 +-- ok, can create a role without any special attributes +CREATE ROLE regress_role_limited +-- +STMT: CreateRoleStmt +== 013 +-- fail, can't give it in any of the restricted attributes +ALTER ROLE regress_role_limited SUPERUSER +-- +STMT: AlterRoleStmt +== 014 +ALTER ROLE regress_role_limited REPLICATION +-- +STMT: AlterRoleStmt +== 015 +ALTER ROLE regress_role_limited CREATEDB +-- +STMT: AlterRoleStmt +== 016 +ALTER ROLE regress_role_limited BYPASSRLS +-- +STMT: AlterRoleStmt +== 017 +DROP ROLE regress_role_limited +-- +STMT: DropRoleStmt +== 018 +-- ok, can give away these role attributes if you have them +SET SESSION AUTHORIZATION regress_role_admin +-- +STMT: VariableSetStmt +== 019 +CREATE ROLE regress_replication_bypassrls REPLICATION BYPASSRLS +-- +STMT: CreateRoleStmt +== 020 +CREATE ROLE regress_replication REPLICATION +-- +STMT: CreateRoleStmt +== 021 +CREATE ROLE regress_bypassrls BYPASSRLS +-- +STMT: CreateRoleStmt +== 022 +CREATE ROLE regress_createdb CREATEDB +-- +STMT: CreateRoleStmt +== 023 +-- ok, can toggle these role attributes off and on if you have them +ALTER ROLE regress_replication NOREPLICATION +-- +STMT: AlterRoleStmt +== 024 +ALTER ROLE regress_replication REPLICATION +-- +STMT: AlterRoleStmt +== 025 +ALTER ROLE regress_bypassrls NOBYPASSRLS +-- +STMT: AlterRoleStmt +== 026 +ALTER ROLE regress_bypassrls BYPASSRLS +-- +STMT: AlterRoleStmt +== 027 +ALTER ROLE regress_createdb NOCREATEDB +-- +STMT: AlterRoleStmt +== 028 +ALTER ROLE regress_createdb CREATEDB +-- +STMT: AlterRoleStmt +== 029 +-- fail, can't toggle SUPERUSER +ALTER ROLE regress_createdb SUPERUSER +-- +STMT: AlterRoleStmt +== 030 +ALTER ROLE regress_createdb NOSUPERUSER +-- +STMT: AlterRoleStmt +== 031 +-- ok, having CREATEROLE is enough to create users with these privileges +CREATE ROLE regress_createrole CREATEROLE NOINHERIT +-- +STMT: CreateRoleStmt +== 032 +GRANT CREATE ON DATABASE regression TO regress_createrole WITH GRANT OPTION +-- +STMT: GrantStmt +== 033 +CREATE ROLE regress_login LOGIN +-- +STMT: CreateRoleStmt +== 034 +CREATE ROLE regress_inherit INHERIT +-- +STMT: CreateRoleStmt +== 035 +CREATE ROLE regress_connection_limit CONNECTION LIMIT 5 +-- +STMT: CreateRoleStmt +== 036 +CREATE ROLE regress_encrypted_password ENCRYPTED PASSWORD 'foo' +-- +STMT: CreateRoleStmt +== 037 +CREATE ROLE regress_password_null PASSWORD NULL +-- +STMT: CreateRoleStmt +== 038 +-- ok, backwards compatible noise words should be ignored +CREATE ROLE regress_noiseword SYSID 12345 +-- +STMT: CreateRoleStmt +== 039 +-- fail, cannot grant membership in superuser role +CREATE ROLE regress_nosuch_super IN ROLE regress_role_super +-- +STMT: CreateRoleStmt +== 040 +-- fail, database owner cannot have members +CREATE ROLE regress_nosuch_dbowner IN ROLE pg_database_owner +-- +STMT: CreateRoleStmt +== 041 +-- ok, can grant other users into a role +CREATE ROLE regress_inroles ROLE + regress_role_super, regress_createdb, regress_createrole, regress_login, + regress_inherit, regress_connection_limit, regress_encrypted_password, regress_password_null +-- +STMT: CreateRoleStmt +== 042 +-- fail, cannot grant a role into itself +CREATE ROLE regress_nosuch_recursive ROLE regress_nosuch_recursive +-- +STMT: CreateRoleStmt +== 043 +-- ok, can grant other users into a role with admin option +CREATE ROLE regress_adminroles ADMIN + regress_role_super, regress_createdb, regress_createrole, regress_login, + regress_inherit, regress_connection_limit, regress_encrypted_password, regress_password_null +-- +STMT: CreateRoleStmt +== 044 +-- fail, cannot grant a role into itself with admin option +CREATE ROLE regress_nosuch_admin_recursive ADMIN regress_nosuch_admin_recursive +-- +STMT: CreateRoleStmt +== 045 +-- fail, regress_createrole does not have CREATEDB privilege +SET SESSION AUTHORIZATION regress_createrole +-- +STMT: VariableSetStmt +== 046 +CREATE DATABASE regress_nosuch_db +-- +STMT: CreatedbStmt +== 047 +-- ok, regress_createrole can create new roles +CREATE ROLE regress_plainrole +-- +STMT: CreateRoleStmt +== 048 +-- ok, roles with CREATEROLE can create new roles with it +CREATE ROLE regress_rolecreator CREATEROLE +-- +STMT: CreateRoleStmt +== 049 +-- ok, roles with CREATEROLE can create new roles with different role +-- attributes, including CREATEROLE +CREATE ROLE regress_hasprivs CREATEROLE LOGIN INHERIT CONNECTION LIMIT 5 +-- +STMT: CreateRoleStmt +== 050 +-- ok, we should be able to modify a role we created +COMMENT ON ROLE regress_hasprivs IS 'some comment' +-- +STMT: CommentStmt +== 051 +ALTER ROLE regress_hasprivs RENAME TO regress_tenant +-- +STMT: RenameStmt +== 052 +ALTER ROLE regress_tenant NOINHERIT NOLOGIN CONNECTION LIMIT 7 +-- +STMT: AlterRoleStmt +== 053 +-- fail, we should be unable to modify a role we did not create +COMMENT ON ROLE regress_role_normal IS 'some comment' +-- +STMT: CommentStmt +== 054 +ALTER ROLE regress_role_normal RENAME TO regress_role_abnormal +-- +STMT: RenameStmt +== 055 +ALTER ROLE regress_role_normal NOINHERIT NOLOGIN CONNECTION LIMIT 7 +-- +STMT: AlterRoleStmt +== 056 +-- ok, regress_tenant can create objects within the database +SET SESSION AUTHORIZATION regress_tenant +-- +STMT: VariableSetStmt +== 057 +CREATE TABLE tenant_table (i integer) +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: CreateStmt +== 058 +CREATE INDEX tenant_idx ON tenant_table(i) +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: IndexStmt +== 059 +CREATE VIEW tenant_view AS SELECT * FROM pg_catalog.pg_class +-- +TABLE: name="tenant_view" schema="" table="tenant_view" ctx=DDL +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 060 +REVOKE ALL PRIVILEGES ON tenant_table FROM PUBLIC +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: GrantStmt +== 061 +-- fail, these objects belonging to regress_tenant +SET SESSION AUTHORIZATION regress_createrole +-- +STMT: VariableSetStmt +== 062 +DROP INDEX tenant_idx +-- +STMT: DropStmt +== 063 +ALTER TABLE tenant_table ADD COLUMN t text +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: AlterTableStmt +== 064 +DROP TABLE tenant_table +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: DropStmt +== 065 +ALTER VIEW tenant_view OWNER TO regress_role_admin +-- +TABLE: name="tenant_view" schema="" table="tenant_view" ctx=DDL +STMT: AlterTableStmt +== 066 +DROP VIEW tenant_view +-- +STMT: DropStmt +== 067 +-- fail, can't create objects owned as regress_tenant +CREATE SCHEMA regress_tenant_schema AUTHORIZATION regress_tenant +-- +STMT: CreateSchemaStmt +== 068 +-- fail, we don't inherit permissions from regress_tenant +REASSIGN OWNED BY regress_tenant TO regress_createrole +-- +STMT: ReassignOwnedStmt +== 069 +-- ok, create a role with a value for createrole_self_grant +SET createrole_self_grant = 'set, inherit' +-- +STMT: VariableSetStmt +== 070 +CREATE ROLE regress_tenant2 +-- +STMT: CreateRoleStmt +== 071 +GRANT CREATE ON DATABASE regression TO regress_tenant2 +-- +STMT: GrantStmt +== 072 +-- ok, regress_tenant2 can create objects within the database +SET SESSION AUTHORIZATION regress_tenant2 +-- +STMT: VariableSetStmt +== 073 +CREATE TABLE tenant2_table (i integer) +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: CreateStmt +== 074 +REVOKE ALL PRIVILEGES ON tenant2_table FROM PUBLIC +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: GrantStmt +== 075 +-- ok, because we have SET and INHERIT on regress_tenant2 +SET SESSION AUTHORIZATION regress_createrole +-- +STMT: VariableSetStmt +== 076 +CREATE SCHEMA regress_tenant2_schema AUTHORIZATION regress_tenant2 +-- +STMT: CreateSchemaStmt +== 077 +ALTER SCHEMA regress_tenant2_schema OWNER TO regress_createrole +-- +STMT: AlterOwnerStmt +== 078 +ALTER TABLE tenant2_table OWNER TO regress_createrole +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +== 079 +ALTER TABLE tenant2_table OWNER TO regress_tenant2 +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +== 080 +-- with SET but not INHERIT, we can give away objects but not take them +REVOKE INHERIT OPTION FOR regress_tenant2 FROM regress_createrole +-- +STMT: GrantRoleStmt +== 081 +ALTER SCHEMA regress_tenant2_schema OWNER TO regress_tenant2 +-- +STMT: AlterOwnerStmt +== 082 +ALTER TABLE tenant2_table OWNER TO regress_createrole +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +== 083 +-- with INHERIT but not SET, we can take objects but not give them away +GRANT regress_tenant2 TO regress_createrole WITH INHERIT TRUE, SET FALSE +-- +STMT: GrantRoleStmt +== 084 +ALTER TABLE tenant2_table OWNER TO regress_createrole +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +== 085 +ALTER TABLE tenant2_table OWNER TO regress_tenant2 +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +== 086 +DROP TABLE tenant2_table +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: DropStmt +== 087 +-- fail, CREATEROLE is not enough to create roles in privileged roles +CREATE ROLE regress_read_all_data IN ROLE pg_read_all_data +-- +STMT: CreateRoleStmt +== 088 +CREATE ROLE regress_write_all_data IN ROLE pg_write_all_data +-- +STMT: CreateRoleStmt +== 089 +CREATE ROLE regress_monitor IN ROLE pg_monitor +-- +STMT: CreateRoleStmt +== 090 +CREATE ROLE regress_read_all_settings IN ROLE pg_read_all_settings +-- +STMT: CreateRoleStmt +== 091 +CREATE ROLE regress_read_all_stats IN ROLE pg_read_all_stats +-- +STMT: CreateRoleStmt +== 092 +CREATE ROLE regress_stat_scan_tables IN ROLE pg_stat_scan_tables +-- +STMT: CreateRoleStmt +== 093 +CREATE ROLE regress_read_server_files IN ROLE pg_read_server_files +-- +STMT: CreateRoleStmt +== 094 +CREATE ROLE regress_write_server_files IN ROLE pg_write_server_files +-- +STMT: CreateRoleStmt +== 095 +CREATE ROLE regress_execute_server_program IN ROLE pg_execute_server_program +-- +STMT: CreateRoleStmt +== 096 +CREATE ROLE regress_signal_backend IN ROLE pg_signal_backend +-- +STMT: CreateRoleStmt +== 097 +-- fail, role still owns database objects +DROP ROLE regress_tenant +-- +STMT: DropRoleStmt +== 098 +-- fail, creation of these roles failed above so they do not now exist +SET SESSION AUTHORIZATION regress_role_admin +-- +STMT: VariableSetStmt +== 099 +DROP ROLE regress_nosuch_superuser +-- +STMT: DropRoleStmt +== 100 +DROP ROLE regress_nosuch_replication_bypassrls +-- +STMT: DropRoleStmt +== 101 +DROP ROLE regress_nosuch_replication +-- +STMT: DropRoleStmt +== 102 +DROP ROLE regress_nosuch_bypassrls +-- +STMT: DropRoleStmt +== 103 +DROP ROLE regress_nosuch_super +-- +STMT: DropRoleStmt +== 104 +DROP ROLE regress_nosuch_dbowner +-- +STMT: DropRoleStmt +== 105 +DROP ROLE regress_nosuch_recursive +-- +STMT: DropRoleStmt +== 106 +DROP ROLE regress_nosuch_admin_recursive +-- +STMT: DropRoleStmt +== 107 +DROP ROLE regress_plainrole +-- +STMT: DropRoleStmt +== 108 +-- must revoke privileges before dropping role +REVOKE CREATE ON DATABASE regression FROM regress_createrole CASCADE +-- +STMT: GrantStmt +== 109 +-- ok, should be able to drop non-superuser roles we created +DROP ROLE regress_replication_bypassrls +-- +STMT: DropRoleStmt +== 110 +DROP ROLE regress_replication +-- +STMT: DropRoleStmt +== 111 +DROP ROLE regress_bypassrls +-- +STMT: DropRoleStmt +== 112 +DROP ROLE regress_createdb +-- +STMT: DropRoleStmt +== 113 +DROP ROLE regress_createrole +-- +STMT: DropRoleStmt +== 114 +DROP ROLE regress_login +-- +STMT: DropRoleStmt +== 115 +DROP ROLE regress_inherit +-- +STMT: DropRoleStmt +== 116 +DROP ROLE regress_connection_limit +-- +STMT: DropRoleStmt +== 117 +DROP ROLE regress_encrypted_password +-- +STMT: DropRoleStmt +== 118 +DROP ROLE regress_password_null +-- +STMT: DropRoleStmt +== 119 +DROP ROLE regress_noiseword +-- +STMT: DropRoleStmt +== 120 +DROP ROLE regress_inroles +-- +STMT: DropRoleStmt +== 121 +DROP ROLE regress_adminroles +-- +STMT: DropRoleStmt +== 122 +-- fail, cannot drop ourself, nor superusers or roles we lack ADMIN for +DROP ROLE regress_role_super +-- +STMT: DropRoleStmt +== 123 +DROP ROLE regress_role_admin +-- +STMT: DropRoleStmt +== 124 +DROP ROLE regress_rolecreator +-- +STMT: DropRoleStmt +== 125 +-- ok +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 126 +REVOKE CREATE ON DATABASE regression FROM regress_role_admin CASCADE +-- +STMT: GrantStmt +== 127 +DROP INDEX tenant_idx +-- +STMT: DropStmt +== 128 +DROP TABLE tenant_table +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: DropStmt +== 129 +DROP VIEW tenant_view +-- +STMT: DropStmt +== 130 +DROP SCHEMA regress_tenant2_schema +-- +STMT: DropStmt +== 131 +-- check for duplicated drop +DROP ROLE regress_tenant, regress_tenant +-- +STMT: DropRoleStmt +== 132 +DROP ROLE regress_tenant2 +-- +STMT: DropRoleStmt +== 133 +DROP ROLE regress_rolecreator +-- +STMT: DropRoleStmt +== 134 +DROP ROLE regress_role_admin +-- +STMT: DropRoleStmt +== 135 +DROP ROLE regress_role_limited_admin +-- +STMT: DropRoleStmt +== 136 +DROP ROLE regress_role_super +-- +STMT: DropRoleStmt +== 137 +DROP ROLE regress_role_normal +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/create_schema.metadata.json b/parser/testdata/summary/postgres_regress/create_schema.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_schema.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_schema.test b/parser/testdata/summary/postgres_regress/create_schema.test new file mode 100644 index 0000000..334bdba --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_schema.test @@ -0,0 +1,145 @@ +== 001 +|-- +-- CREATE_SCHEMA +|-- + +-- Schema creation with elements. + +CREATE ROLE regress_create_schema_role SUPERUSER +-- +STMT: CreateRoleStmt +== 002 +-- Cases where schema creation fails as objects are qualified with a schema +-- that does not match with what's expected. +-- This checks all the object types that include schema qualifications. +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE SEQUENCE schema_not_existing.seq +-- +STMT: CreateSchemaStmt +== 003 +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE TABLE schema_not_existing.tab (id int) +-- +STMT: CreateSchemaStmt +== 004 +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE VIEW schema_not_existing.view AS SELECT 1 +-- +STMT: CreateSchemaStmt +== 005 +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE INDEX ON schema_not_existing.tab (id) +-- +STMT: CreateSchemaStmt +== 006 +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab + EXECUTE FUNCTION schema_trig.no_func() +-- +STMT: CreateSchemaStmt +== 007 +-- Again, with a role specification and no schema names. +SET ROLE regress_create_schema_role +-- +STMT: VariableSetStmt +== 008 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE SEQUENCE schema_not_existing.seq +-- +STMT: CreateSchemaStmt +== 009 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE TABLE schema_not_existing.tab (id int) +-- +STMT: CreateSchemaStmt +== 010 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE VIEW schema_not_existing.view AS SELECT 1 +-- +STMT: CreateSchemaStmt +== 011 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE INDEX ON schema_not_existing.tab (id) +-- +STMT: CreateSchemaStmt +== 012 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab + EXECUTE FUNCTION schema_trig.no_func() +-- +STMT: CreateSchemaStmt +== 013 +-- Again, with a schema name and a role specification. +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE SEQUENCE schema_not_existing.seq +-- +STMT: CreateSchemaStmt +== 014 +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE TABLE schema_not_existing.tab (id int) +-- +STMT: CreateSchemaStmt +== 015 +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE VIEW schema_not_existing.view AS SELECT 1 +-- +STMT: CreateSchemaStmt +== 016 +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE INDEX ON schema_not_existing.tab (id) +-- +STMT: CreateSchemaStmt +== 017 +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab + EXECUTE FUNCTION schema_trig.no_func() +-- +STMT: CreateSchemaStmt +== 018 +RESET ROLE +-- +STMT: VariableSetStmt +== 019 +-- Cases where the schema creation succeeds. +-- The schema created matches the role name. +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE TABLE regress_create_schema_role.tab (id int) +-- +STMT: CreateSchemaStmt +== 020 +DROP SCHEMA regress_create_schema_role CASCADE +-- +STMT: DropStmt +== 021 +-- Again, with a different role specification and no schema names. +SET ROLE regress_create_schema_role +-- +STMT: VariableSetStmt +== 022 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE TABLE regress_create_schema_role.tab (id int) +-- +STMT: CreateSchemaStmt +== 023 +DROP SCHEMA regress_create_schema_role CASCADE +-- +STMT: DropStmt +== 024 +-- Again, with a schema name and a role specification. +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE TABLE regress_schema_1.tab (id int) +-- +STMT: CreateSchemaStmt +== 025 +DROP SCHEMA regress_schema_1 CASCADE +-- +STMT: DropStmt +== 026 +RESET ROLE +-- +STMT: VariableSetStmt +== 027 +-- Clean up +DROP ROLE regress_create_schema_role +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/create_table.metadata.json b/parser/testdata/summary/postgres_regress/create_table.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_table.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_table.test b/parser/testdata/summary/postgres_regress/create_table.test new file mode 100644 index 0000000..f93e160 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_table.test @@ -0,0 +1,1980 @@ +== 001 +|-- +-- CREATE_TABLE +|-- + +-- Error cases +CREATE TABLE unknowntab ( + u unknown -- fail +) +-- +TABLE: name="unknowntab" schema="" table="unknowntab" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TYPE unknown_comptype AS ( + u unknown -- fail +) +-- +STMT: CompositeTypeStmt +== 003 +-- invalid: non-lowercase quoted reloptions identifiers +CREATE TABLE tas_case WITH ("Fillfactor" = 10) AS SELECT 1 a +-- +TABLE: name="tas_case" schema="" table="tas_case" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 004 +CREATE UNLOGGED TABLE unlogged1 (a int primary key) +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: CreateStmt +== 005 +-- OK +CREATE TEMPORARY TABLE unlogged2 (a int primary key) +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: CreateStmt +== 006 +-- OK +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 007 +REINDEX INDEX unlogged1_pkey +-- +STMT: ReindexStmt +== 008 +REINDEX INDEX unlogged2_pkey +-- +STMT: ReindexStmt +== 009 +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 010 +DROP TABLE unlogged2 +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: DropStmt +== 011 +INSERT INTO unlogged1 VALUES (42) +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +CREATE UNLOGGED TABLE public.unlogged2 (a int primary key) +-- +TABLE: name="public.unlogged2" schema="public" table="unlogged2" ctx=DDL +STMT: CreateStmt +== 013 +-- also OK +CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key) +-- +TABLE: name="pg_temp.unlogged3" schema="pg_temp" table="unlogged3" ctx=DDL +STMT: CreateStmt +== 014 +-- not OK +CREATE TABLE pg_temp.implicitly_temp (a int primary key) +-- +TABLE: name="pg_temp.implicitly_temp" schema="pg_temp" table="implicitly_temp" ctx=DDL +STMT: CreateStmt +== 015 +-- OK +CREATE TEMP TABLE explicitly_temp (a int primary key) +-- +TABLE: name="explicitly_temp" schema="" table="explicitly_temp" ctx=DDL +STMT: CreateStmt +== 016 +-- also OK +CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key) +-- +TABLE: name="pg_temp.doubly_temp" schema="pg_temp" table="doubly_temp" ctx=DDL +STMT: CreateStmt +== 017 +-- also OK +CREATE TEMP TABLE public.temp_to_perm (a int primary key) +-- +TABLE: name="public.temp_to_perm" schema="public" table="temp_to_perm" ctx=DDL +STMT: CreateStmt +== 018 +-- not OK +DROP TABLE unlogged1, public.unlogged2 +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +TABLE: name="public.unlogged2" schema="public" table="unlogged2" ctx=DDL +STMT: DropStmt +== 019 +CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r' +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relkind" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 020 +CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r' +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relkind" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 021 +CREATE TABLE IF NOT EXISTS as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r' +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relkind" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 022 +DROP TABLE as_select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: DropStmt +== 023 +PREPARE select1 AS SELECT 1 as a +-- +STMT: PrepareStmt +STMT: SelectStmt +== 024 +CREATE TABLE as_select1 AS EXECUTE select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 025 +CREATE TABLE as_select1 AS EXECUTE select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 026 +SELECT * FROM as_select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=Select +STMT: SelectStmt +== 027 +CREATE TABLE IF NOT EXISTS as_select1 AS EXECUTE select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 028 +DROP TABLE as_select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: DropStmt +== 029 +DEALLOCATE select1 +-- +STMT: DeallocateStmt +== 030 +-- create an extra wide table to test for issues related to that +-- (temporarily hide query, to avoid the long CREATE TABLE stmt) +SELECT 'CREATE TABLE extra_wide_table(firstc text, '|| array_to_string(array_agg('c'||i||' bool'),',')||', lastc text);' +FROM generate_series(1, 1100) g(i) +INSERT INTO extra_wide_table(firstc, lastc) VALUES('first col', 'last col') +-- +ERROR: syntax error at or near "INSERT" +CURSORPOS: 287 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 031 +SELECT firstc, lastc FROM extra_wide_table +-- +TABLE: name="extra_wide_table" schema="" table="extra_wide_table" ctx=Select +STMT: SelectStmt +== 032 +-- check that tables with oids cannot be created anymore +CREATE TABLE withoid() WITH OIDS +-- +ERROR: syntax error at or near "OIDS" +CURSORPOS: 86 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 033 +CREATE TABLE withoid() WITH (oids) +-- +TABLE: name="withoid" schema="" table="withoid" ctx=DDL +STMT: CreateStmt +== 034 +CREATE TABLE withoid() WITH (oids = true) +-- +TABLE: name="withoid" schema="" table="withoid" ctx=DDL +STMT: CreateStmt +== 035 +-- but explicitly not adding oids is still supported +CREATE TEMP TABLE withoutoid() WITHOUT OIDS +-- +TABLE: name="withoutoid" schema="" table="withoutoid" ctx=DDL +STMT: CreateStmt +== 036 +DROP TABLE withoutoid +-- +TABLE: name="withoutoid" schema="" table="withoutoid" ctx=DDL +STMT: DropStmt +== 037 +CREATE TEMP TABLE withoutoid() WITH (oids = false) +-- +TABLE: name="withoutoid" schema="" table="withoutoid" ctx=DDL +STMT: CreateStmt +== 038 +DROP TABLE withoutoid +-- +TABLE: name="withoutoid" schema="" table="withoutoid" ctx=DDL +STMT: DropStmt +== 039 +-- temporary tables are ignored by pg_filenode_relation(). +CREATE TEMP TABLE relation_filenode_check(c1 int) +-- +TABLE: name="relation_filenode_check" schema="" table="relation_filenode_check" ctx=DDL +STMT: CreateStmt +== 040 +SELECT relpersistence, + pg_filenode_relation (reltablespace, pg_relation_filenode(oid)) + FROM pg_class + WHERE relname = 'relation_filenode_check' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_filenode_relation" function="pg_filenode_relation" schema="" ctx=Call +FUNCTION: name="pg_relation_filenode" function="pg_relation_filenode" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 041 +DROP TABLE relation_filenode_check +-- +TABLE: name="relation_filenode_check" schema="" table="relation_filenode_check" ctx=DDL +STMT: DropStmt +== 042 +-- check restriction with default expressions +-- invalid use of column reference in default expressions +CREATE TABLE default_expr_column (id int DEFAULT (id)) +-- +TABLE: name="default_expr_column" schema="" table="default_expr_column" ctx=DDL +STMT: CreateStmt +== 043 +CREATE TABLE default_expr_column (id int DEFAULT (bar.id)) +-- +TABLE: name="default_expr_column" schema="" table="default_expr_column" ctx=DDL +STMT: CreateStmt +== 044 +CREATE TABLE default_expr_agg_column (id int DEFAULT (avg(id))) +-- +TABLE: name="default_expr_agg_column" schema="" table="default_expr_agg_column" ctx=DDL +STMT: CreateStmt +== 045 +-- invalid column definition +CREATE TABLE default_expr_non_column (a int DEFAULT (avg(non_existent))) +-- +TABLE: name="default_expr_non_column" schema="" table="default_expr_non_column" ctx=DDL +STMT: CreateStmt +== 046 +-- invalid use of aggregate +CREATE TABLE default_expr_agg (a int DEFAULT (avg(1))) +-- +TABLE: name="default_expr_agg" schema="" table="default_expr_agg" ctx=DDL +STMT: CreateStmt +== 047 +-- invalid use of subquery +CREATE TABLE default_expr_agg (a int DEFAULT (select 1)) +-- +TABLE: name="default_expr_agg" schema="" table="default_expr_agg" ctx=DDL +STMT: CreateStmt +== 048 +-- invalid use of set-returning function +CREATE TABLE default_expr_agg (a int DEFAULT (generate_series(1,3))) +-- +TABLE: name="default_expr_agg" schema="" table="default_expr_agg" ctx=DDL +STMT: CreateStmt +== 049 +-- Verify that subtransaction rollback restores rd_createSubid. +BEGIN +-- +STMT: TransactionStmt +== 050 +CREATE TABLE remember_create_subid (c int) +-- +TABLE: name="remember_create_subid" schema="" table="remember_create_subid" ctx=DDL +STMT: CreateStmt +== 051 +SAVEPOINT q +-- +STMT: TransactionStmt +== 052 +DROP TABLE remember_create_subid +-- +TABLE: name="remember_create_subid" schema="" table="remember_create_subid" ctx=DDL +STMT: DropStmt +== 053 +ROLLBACK TO q +-- +STMT: TransactionStmt +== 054 +COMMIT +-- +STMT: TransactionStmt +== 055 +DROP TABLE remember_create_subid +-- +TABLE: name="remember_create_subid" schema="" table="remember_create_subid" ctx=DDL +STMT: DropStmt +== 056 +-- Verify that subtransaction rollback restores rd_firstRelfilenodeSubid. +CREATE TABLE remember_node_subid (c int) +-- +TABLE: name="remember_node_subid" schema="" table="remember_node_subid" ctx=DDL +STMT: CreateStmt +== 057 +BEGIN +-- +STMT: TransactionStmt +== 058 +ALTER TABLE remember_node_subid ALTER c TYPE bigint +-- +TABLE: name="remember_node_subid" schema="" table="remember_node_subid" ctx=DDL +STMT: AlterTableStmt +== 059 +SAVEPOINT q +-- +STMT: TransactionStmt +== 060 +DROP TABLE remember_node_subid +-- +TABLE: name="remember_node_subid" schema="" table="remember_node_subid" ctx=DDL +STMT: DropStmt +== 061 +ROLLBACK TO q +-- +STMT: TransactionStmt +== 062 +COMMIT +-- +STMT: TransactionStmt +== 063 +DROP TABLE remember_node_subid +-- +TABLE: name="remember_node_subid" schema="" table="remember_node_subid" ctx=DDL +STMT: DropStmt +== 064 +|-- +-- Partitioned tables +|-- + +-- cannot combine INHERITS and PARTITION BY (although grammar allows) +CREATE TABLE partitioned ( + a int +) INHERITS (some_table) PARTITION BY LIST (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 065 +-- cannot use more than 1 column as partition key for list partitioned table +CREATE TABLE partitioned ( + a1 int, + a2 int +) PARTITION BY LIST (a1, a2) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 066 +-- fail + +-- prevent using prohibited expressions in the key +CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="retset" function="retset" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 067 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (retset(a)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 068 +DROP FUNCTION retset(int) +-- +FUNCTION: name="retset" function="retset" schema="" ctx=DDL +STMT: DropStmt +== 069 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE ((avg(a))) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 070 +CREATE TABLE partitioned ( + a int, + b int +) PARTITION BY RANGE ((avg(a) OVER (PARTITION BY b))) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 071 +CREATE TABLE partitioned ( + a int +) PARTITION BY LIST ((a LIKE (SELECT 1))) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 072 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE ((42)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 073 +CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="const_func" function="const_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 074 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (const_func()) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 075 +DROP FUNCTION const_func() +-- +FUNCTION: name="const_func" function="const_func" schema="" ctx=DDL +STMT: DropStmt +== 076 +-- only accept valid partitioning strategy +CREATE TABLE partitioned ( + a int +) PARTITION BY MAGIC (a) +-- +ERROR: unrecognized partitioning strategy "magic" +FILENAME: gram.y +FUNCNAME: parsePartitionStrategy +== 077 +-- specified column must be present in the table +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (b) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 078 +-- cannot use system columns in partition key +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (xmin) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 079 +-- cannot use pseudotypes +CREATE TABLE partitioned ( + a int, + b int +) PARTITION BY RANGE (((a, b))) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 080 +CREATE TABLE partitioned ( + a int, + b int +) PARTITION BY RANGE (a, ('unknown')) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 081 +-- functions in key must be immutable +CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL +-- +FUNCTION: name="immut_func" function="immut_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 082 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (immut_func(a)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 083 +DROP FUNCTION immut_func(int) +-- +FUNCTION: name="immut_func" function="immut_func" schema="" ctx=DDL +STMT: DropStmt +== 084 +-- prevent using columns of unsupported types in key (type must have a btree operator class) +CREATE TABLE partitioned ( + a point +) PARTITION BY LIST (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 085 +CREATE TABLE partitioned ( + a point +) PARTITION BY LIST (a point_ops) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 086 +CREATE TABLE partitioned ( + a point +) PARTITION BY RANGE (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 087 +CREATE TABLE partitioned ( + a point +) PARTITION BY RANGE (a point_ops) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 088 +-- cannot add NO INHERIT constraints to partitioned tables +CREATE TABLE partitioned ( + a int, + CONSTRAINT check_a CHECK (a > 0) NO INHERIT +) PARTITION BY RANGE (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 089 +-- some checks after successful creation of a partitioned table +CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL +-- +FUNCTION: name="plusone" function="plusone" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 090 +CREATE TABLE partitioned ( + a int, + b int, + c text, + d text +) PARTITION BY RANGE (a oid_ops, plusone(b), c collate "default", d collate "C") +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 091 +-- check relkind +SELECT relkind FROM pg_class WHERE relname = 'partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 092 +-- prevent a function referenced in partition key from being dropped +DROP FUNCTION plusone(int) +-- +FUNCTION: name="plusone" function="plusone" schema="" ctx=DDL +STMT: DropStmt +== 093 +-- partitioned table cannot participate in regular inheritance +CREATE TABLE partitioned2 ( + a int, + b text +) PARTITION BY RANGE ((a+1), substr(b, 1, 5)) +-- +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DDL +STMT: CreateStmt +== 094 +CREATE TABLE fail () INHERITS (partitioned2) +-- +TABLE: name="fail" schema="" table="fail" ctx=DDL +STMT: CreateStmt +== 095 +-- Partition key in describe output + +INSERT INTO partitioned2 VALUES (1, 'hello') +-- +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +CREATE TABLE part2_1 PARTITION OF partitioned2 FOR VALUES FROM (-1, 'aaaaa') TO (100, 'ccccc') +-- +TABLE: name="part2_1" schema="" table="part2_1" ctx=DDL +STMT: CreateStmt +== 097 +DROP TABLE partitioned, partitioned2 +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DDL +STMT: DropStmt +== 098 +-- check reference to partitioned table's rowtype in partition descriptor +create table partitioned (a int, b int) + partition by list ((row(a, b)::partitioned)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 099 +create table partitioned1 + partition of partitioned for values in ('(1,2)'::partitioned) +-- +TABLE: name="partitioned1" schema="" table="partitioned1" ctx=DDL +STMT: CreateStmt +== 100 +create table partitioned2 + partition of partitioned for values in ('(2,4)'::partitioned) +-- +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DDL +STMT: CreateStmt +== 101 +explain (costs off) +select * from partitioned where row(a,b)::partitioned = '(1,2)'::partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 102 +drop table partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: DropStmt +== 103 +-- whole-row Var in partition key works too +create table partitioned (a int, b int) + partition by list ((partitioned)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 104 +create table partitioned1 + partition of partitioned for values in ('(1,2)') +-- +TABLE: name="partitioned1" schema="" table="partitioned1" ctx=DDL +STMT: CreateStmt +== 105 +create table partitioned2 + partition of partitioned for values in ('(2,4)') +-- +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DDL +STMT: CreateStmt +== 106 +explain (costs off) +select * from partitioned where partitioned = '(1,2)'::partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=Select +FILTER: schema="" table="" column="partitioned" +STMT: ExplainStmt +STMT: SelectStmt +== 107 +drop table partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: DropStmt +== 108 +-- check that dependencies of partition columns are handled correctly +create domain intdom1 as int +-- +STMT: CreateDomainStmt +== 109 +create table partitioned ( + a intdom1, + b text +) partition by range (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 110 +alter table partitioned drop column a +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 111 +-- fail + +drop domain intdom1 +-- +STMT: DropStmt +== 112 +-- fail, requires cascade + +drop domain intdom1 cascade +-- +STMT: DropStmt +== 113 +table partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=Select +STMT: SelectStmt +== 114 +-- gone + +-- likewise for columns used in partition expressions +create domain intdom1 as int +-- +STMT: CreateDomainStmt +== 115 +create table partitioned ( + a intdom1, + b text +) partition by range (plusone(a)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +== 116 +alter table partitioned drop column a +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +== 117 +-- fail + +drop domain intdom1 +-- +STMT: DropStmt +== 118 +-- fail, requires cascade + +drop domain intdom1 cascade +-- +STMT: DropStmt +== 119 +table partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=Select +STMT: SelectStmt +== 120 +-- gone + + +|-- +-- Partitions +|-- + +-- check partition bound syntax + +CREATE TABLE list_parted ( + a int +) PARTITION BY LIST (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +== 121 +CREATE TABLE part_p1 PARTITION OF list_parted FOR VALUES IN ('1') +-- +TABLE: name="part_p1" schema="" table="part_p1" ctx=DDL +STMT: CreateStmt +== 122 +CREATE TABLE part_p2 PARTITION OF list_parted FOR VALUES IN (2) +-- +TABLE: name="part_p2" schema="" table="part_p2" ctx=DDL +STMT: CreateStmt +== 123 +CREATE TABLE part_p3 PARTITION OF list_parted FOR VALUES IN ((2+1)) +-- +TABLE: name="part_p3" schema="" table="part_p3" ctx=DDL +STMT: CreateStmt +== 124 +CREATE TABLE part_null PARTITION OF list_parted FOR VALUES IN (null) +-- +TABLE: name="part_null" schema="" table="part_null" ctx=DDL +STMT: CreateStmt +== 125 +-- forbidden expressions for partition bound with list partitioned table +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 126 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename.somename) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 127 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (a) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 128 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(a)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 129 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(somename)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 130 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(1)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 131 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((select 1)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 132 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (generate_series(4, 6)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 133 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((1+1) collate "POSIX") +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 134 +-- syntax does not allow empty list of values for list partitions +CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN () +-- +ERROR: syntax error at or near ")" +CURSORPOS: 130 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 135 +-- trying to specify range for list partitioned table +CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES FROM (1) TO (2) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 136 +-- trying to specify modulus and remainder for list partitioned table +CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 137 +-- check default partition cannot be created more than once +CREATE TABLE part_default PARTITION OF list_parted DEFAULT +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: CreateStmt +== 138 +CREATE TABLE fail_default_part PARTITION OF list_parted DEFAULT +-- +TABLE: name="fail_default_part" schema="" table="fail_default_part" ctx=DDL +STMT: CreateStmt +== 139 +-- specified literal can't be cast to the partition column data type +CREATE TABLE bools ( + a bool +) PARTITION BY LIST (a) +-- +TABLE: name="bools" schema="" table="bools" ctx=DDL +STMT: CreateStmt +== 140 +CREATE TABLE bools_true PARTITION OF bools FOR VALUES IN (1) +-- +TABLE: name="bools_true" schema="" table="bools_true" ctx=DDL +STMT: CreateStmt +== 141 +DROP TABLE bools +-- +TABLE: name="bools" schema="" table="bools" ctx=DDL +STMT: DropStmt +== 142 +-- specified literal can be cast, and the cast might not be immutable +CREATE TABLE moneyp ( + a money +) PARTITION BY LIST (a) +-- +TABLE: name="moneyp" schema="" table="moneyp" ctx=DDL +STMT: CreateStmt +== 143 +CREATE TABLE moneyp_10 PARTITION OF moneyp FOR VALUES IN (10) +-- +TABLE: name="moneyp_10" schema="" table="moneyp_10" ctx=DDL +STMT: CreateStmt +== 144 +CREATE TABLE moneyp_11 PARTITION OF moneyp FOR VALUES IN ('11') +-- +TABLE: name="moneyp_11" schema="" table="moneyp_11" ctx=DDL +STMT: CreateStmt +== 145 +CREATE TABLE moneyp_12 PARTITION OF moneyp FOR VALUES IN (to_char(12, '99')::int) +-- +TABLE: name="moneyp_12" schema="" table="moneyp_12" ctx=DDL +STMT: CreateStmt +== 146 +DROP TABLE moneyp +-- +TABLE: name="moneyp" schema="" table="moneyp" ctx=DDL +STMT: DropStmt +== 147 +-- cast is immutable +CREATE TABLE bigintp ( + a bigint +) PARTITION BY LIST (a) +-- +TABLE: name="bigintp" schema="" table="bigintp" ctx=DDL +STMT: CreateStmt +== 148 +CREATE TABLE bigintp_10 PARTITION OF bigintp FOR VALUES IN (10) +-- +TABLE: name="bigintp_10" schema="" table="bigintp_10" ctx=DDL +STMT: CreateStmt +== 149 +-- fails due to overlap: +CREATE TABLE bigintp_10_2 PARTITION OF bigintp FOR VALUES IN ('10') +-- +TABLE: name="bigintp_10_2" schema="" table="bigintp_10_2" ctx=DDL +STMT: CreateStmt +== 150 +DROP TABLE bigintp +-- +TABLE: name="bigintp" schema="" table="bigintp" ctx=DDL +STMT: DropStmt +== 151 +CREATE TABLE range_parted ( + a date +) PARTITION BY RANGE (a) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +== 152 +-- forbidden expressions for partition bounds with range partitioned table +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (somename) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 153 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (somename.somename) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 154 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (a) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 155 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (max(a)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 156 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (max(somename)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 157 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (max('2019-02-01'::date)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 158 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM ((select 1)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 159 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (generate_series(1, 3)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +== 160 +-- trying to specify list for range partitioned table +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES IN ('a') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 161 +-- trying to specify modulus and remainder for range partitioned table +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 162 +-- each of start and end bounds must have same number of values as the +-- length of the partition key +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('z') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 163 +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a') TO ('z', 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 164 +-- cannot specify null values in range bounds +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM (null) TO (maxvalue) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 165 +-- trying to specify modulus and remainder for range partitioned table +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 166 +-- check partition bound syntax for the hash partition +CREATE TABLE hash_parted ( + a int +) PARTITION BY HASH (a) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: CreateStmt +== 167 +CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 0) +-- +TABLE: name="hpart_1" schema="" table="hpart_1" ctx=DDL +STMT: CreateStmt +== 168 +CREATE TABLE hpart_2 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 50, REMAINDER 1) +-- +TABLE: name="hpart_2" schema="" table="hpart_2" ctx=DDL +STMT: CreateStmt +== 169 +CREATE TABLE hpart_3 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 200, REMAINDER 2) +-- +TABLE: name="hpart_3" schema="" table="hpart_3" ctx=DDL +STMT: CreateStmt +== 170 +CREATE TABLE hpart_4 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 3) +-- +TABLE: name="hpart_4" schema="" table="hpart_4" ctx=DDL +STMT: CreateStmt +== 171 +-- modulus 25 is factor of modulus of 50 but 10 is not a factor of 25. +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 25, REMAINDER 3) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 172 +-- previous modulus 50 is factor of 150 but this modulus is not a factor of next modulus 200. +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 150, REMAINDER 3) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 173 +-- overlapping remainders +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 100, REMAINDER 3) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 174 +-- trying to specify range for the hash partitioned table +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES FROM ('a', 1) TO ('z') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 175 +-- trying to specify list value for the hash partitioned table +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES IN (1000) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 176 +-- trying to create default partition for the hash partitioned table +CREATE TABLE fail_default_part PARTITION OF hash_parted DEFAULT +-- +TABLE: name="fail_default_part" schema="" table="fail_default_part" ctx=DDL +STMT: CreateStmt +== 177 +-- check if compatible with the specified parent + +-- cannot create as partition of a non-partitioned table +CREATE TABLE unparted ( + a int +) +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +STMT: CreateStmt +== 178 +CREATE TABLE fail_part PARTITION OF unparted FOR VALUES IN ('a') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 179 +CREATE TABLE fail_part PARTITION OF unparted FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 180 +DROP TABLE unparted +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +STMT: DropStmt +== 181 +-- cannot create a permanent rel as partition of a temp rel +CREATE TEMP TABLE temp_parted ( + a int +) PARTITION BY LIST (a) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: CreateStmt +== 182 +CREATE TABLE fail_part PARTITION OF temp_parted FOR VALUES IN ('a') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 183 +DROP TABLE temp_parted +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: DropStmt +== 184 +-- check for partition bound overlap and other invalid specifications + +CREATE TABLE list_parted2 ( + a varchar +) PARTITION BY LIST (a) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: CreateStmt +== 185 +CREATE TABLE part_null_z PARTITION OF list_parted2 FOR VALUES IN (null, 'z') +-- +TABLE: name="part_null_z" schema="" table="part_null_z" ctx=DDL +STMT: CreateStmt +== 186 +CREATE TABLE part_ab PARTITION OF list_parted2 FOR VALUES IN ('a', 'b') +-- +TABLE: name="part_ab" schema="" table="part_ab" ctx=DDL +STMT: CreateStmt +== 187 +CREATE TABLE list_parted2_def PARTITION OF list_parted2 DEFAULT +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DDL +STMT: CreateStmt +== 188 +CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN (null) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 189 +CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('b', 'c') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 190 +-- check default partition overlap +INSERT INTO list_parted2 VALUES('X') +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('W', 'X', 'Y') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 192 +CREATE TABLE range_parted2 ( + a int +) PARTITION BY RANGE (a) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: CreateStmt +== 193 +-- trying to create range partition with empty range +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (0) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 194 +-- note that the range '[1, 1)' has no elements +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 195 +CREATE TABLE part0 PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (1) +-- +TABLE: name="part0" schema="" table="part0" ctx=DDL +STMT: CreateStmt +== 196 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (2) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 197 +CREATE TABLE part1 PARTITION OF range_parted2 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +== 198 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (-1) TO (1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 199 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (9) TO (maxvalue) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 200 +CREATE TABLE part2 PARTITION OF range_parted2 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +== 201 +CREATE TABLE part3 PARTITION OF range_parted2 FOR VALUES FROM (30) TO (40) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +== 202 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (30) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 203 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (50) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 204 +-- Create a default partition for range partitioned table +CREATE TABLE range2_default PARTITION OF range_parted2 DEFAULT +-- +TABLE: name="range2_default" schema="" table="range2_default" ctx=DDL +STMT: CreateStmt +== 205 +-- More than one default partition is not allowed, so this should give error +CREATE TABLE fail_default_part PARTITION OF range_parted2 DEFAULT +-- +TABLE: name="fail_default_part" schema="" table="fail_default_part" ctx=DDL +STMT: CreateStmt +== 206 +-- Check if the range for default partitions overlap +INSERT INTO range_parted2 VALUES (85) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 207 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (80) TO (90) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 208 +CREATE TABLE part4 PARTITION OF range_parted2 FOR VALUES FROM (90) TO (100) +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: CreateStmt +== 209 +-- now check for multi-column range partition key +CREATE TABLE range_parted3 ( + a int, + b int +) PARTITION BY RANGE (a, (b+1)) +-- +TABLE: name="range_parted3" schema="" table="range_parted3" ctx=DDL +STMT: CreateStmt +== 210 +CREATE TABLE part00 PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, maxvalue) +-- +TABLE: name="part00" schema="" table="part00" ctx=DDL +STMT: CreateStmt +== 211 +CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 212 +CREATE TABLE part10 PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, 1) +-- +TABLE: name="part10" schema="" table="part10" ctx=DDL +STMT: CreateStmt +== 213 +CREATE TABLE part11 PARTITION OF range_parted3 FOR VALUES FROM (1, 1) TO (1, 10) +-- +TABLE: name="part11" schema="" table="part11" ctx=DDL +STMT: CreateStmt +== 214 +CREATE TABLE part12 PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, maxvalue) +-- +TABLE: name="part12" schema="" table="part12" ctx=DDL +STMT: CreateStmt +== 215 +CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, 20) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 216 +CREATE TABLE range3_default PARTITION OF range_parted3 DEFAULT +-- +TABLE: name="range3_default" schema="" table="range3_default" ctx=DDL +STMT: CreateStmt +== 217 +-- cannot create a partition that says column b is allowed to range +-- from -infinity to +infinity, while there exist partitions that have +-- more specific ranges +CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, maxvalue) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 218 +-- check for partition bound overlap and other invalid specifications for the hash partition +CREATE TABLE hash_parted2 ( + a varchar +) PARTITION BY HASH (a) +-- +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: CreateStmt +== 219 +CREATE TABLE h2part_1 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 4, REMAINDER 2) +-- +TABLE: name="h2part_1" schema="" table="h2part_1" ctx=DDL +STMT: CreateStmt +== 220 +CREATE TABLE h2part_2 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 0) +-- +TABLE: name="h2part_2" schema="" table="h2part_2" ctx=DDL +STMT: CreateStmt +== 221 +CREATE TABLE h2part_3 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 4) +-- +TABLE: name="h2part_3" schema="" table="h2part_3" ctx=DDL +STMT: CreateStmt +== 222 +CREATE TABLE h2part_4 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 5) +-- +TABLE: name="h2part_4" schema="" table="h2part_4" ctx=DDL +STMT: CreateStmt +== 223 +-- overlap with part_4 +CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 224 +-- modulus must be greater than zero +CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 0, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 225 +-- remainder must be greater than or equal to zero and less than modulus +CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 8) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +== 226 +-- check schema propagation from parent + +CREATE TABLE parted ( + a text, + b int NOT NULL DEFAULT 0, + CONSTRAINT check_a CHECK (length(a) > 0) +) PARTITION BY LIST (a) +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateStmt +== 227 +CREATE TABLE part_a PARTITION OF parted FOR VALUES IN ('a') +-- +TABLE: name="part_a" schema="" table="part_a" ctx=DDL +STMT: CreateStmt +== 228 +-- only inherited attributes (never local ones) +SELECT attname, attislocal, attinhcount FROM pg_attribute + WHERE attrelid = 'part_a'::regclass and attnum > 0 + ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +== 229 +-- able to specify column default, column constraint, and table constraint + +-- first check the "column specified more than once" error +CREATE TABLE part_b PARTITION OF parted ( + b NOT NULL, + b DEFAULT 1, + b CHECK (b >= 0), + CONSTRAINT check_a CHECK (length(a) > 0) +) FOR VALUES IN ('b') +-- +TABLE: name="part_b" schema="" table="part_b" ctx=DDL +STMT: CreateStmt +== 230 +CREATE TABLE part_b PARTITION OF parted ( + b NOT NULL DEFAULT 1, + CONSTRAINT check_a CHECK (length(a) > 0), + CONSTRAINT check_b CHECK (b >= 0) +) FOR VALUES IN ('b') +-- +TABLE: name="part_b" schema="" table="part_b" ctx=DDL +STMT: CreateStmt +== 231 +-- conislocal should be false for any merged constraints, true otherwise +SELECT conname, conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 232 +-- Once check_b is added to the parent, it should be made non-local for part_b +ALTER TABLE parted ADD CONSTRAINT check_b CHECK (b >= 0) +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: AlterTableStmt +== 233 +SELECT conname, conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 234 +-- Neither check_a nor check_b are droppable from part_b +ALTER TABLE part_b DROP CONSTRAINT check_a +-- +TABLE: name="part_b" schema="" table="part_b" ctx=DDL +STMT: AlterTableStmt +== 235 +ALTER TABLE part_b DROP CONSTRAINT check_b +-- +TABLE: name="part_b" schema="" table="part_b" ctx=DDL +STMT: AlterTableStmt +== 236 +-- And dropping it from parted should leave no trace of them on part_b, unlike +-- traditional inheritance where they will be left behind, because they would +-- be local constraints. +ALTER TABLE parted DROP CONSTRAINT check_a, DROP CONSTRAINT check_b +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: AlterTableStmt +== 237 +SELECT conname, conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 238 +-- specify PARTITION BY for a partition +CREATE TABLE fail_part_col_not_found PARTITION OF parted FOR VALUES IN ('c') PARTITION BY RANGE (c) +-- +TABLE: name="fail_part_col_not_found" schema="" table="fail_part_col_not_found" ctx=DDL +STMT: CreateStmt +== 239 +CREATE TABLE part_c PARTITION OF parted (b WITH OPTIONS NOT NULL DEFAULT 0) FOR VALUES IN ('c') PARTITION BY RANGE ((b)) +-- +TABLE: name="part_c" schema="" table="part_c" ctx=DDL +STMT: CreateStmt +== 240 +-- create a level-2 partition +CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10) +-- +TABLE: name="part_c_1_10" schema="" table="part_c_1_10" ctx=DDL +STMT: CreateStmt +== 241 +-- check that NOT NULL and default value are inherited correctly +create table parted_notnull_inh_test (a int default 1, b int not null default 0) partition by list (a) +-- +TABLE: name="parted_notnull_inh_test" schema="" table="parted_notnull_inh_test" ctx=DDL +STMT: CreateStmt +== 242 +create table parted_notnull_inh_test1 partition of parted_notnull_inh_test (a not null, b default 1) for values in (1) +-- +TABLE: name="parted_notnull_inh_test1" schema="" table="parted_notnull_inh_test1" ctx=DDL +STMT: CreateStmt +== 243 +insert into parted_notnull_inh_test (b) values (null) +-- +TABLE: name="parted_notnull_inh_test" schema="" table="parted_notnull_inh_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +-- note that while b's default is overridden, a's default is preserved +drop table parted_notnull_inh_test +-- +TABLE: name="parted_notnull_inh_test" schema="" table="parted_notnull_inh_test" ctx=DDL +STMT: DropStmt +== 245 +-- check that collations are assigned in partition bound expressions +create table parted_boolean_col (a bool, b text) partition by list(a) +-- +TABLE: name="parted_boolean_col" schema="" table="parted_boolean_col" ctx=DDL +STMT: CreateStmt +== 246 +create table parted_boolean_less partition of parted_boolean_col + for values in ('foo' < 'bar') +-- +TABLE: name="parted_boolean_less" schema="" table="parted_boolean_less" ctx=DDL +STMT: CreateStmt +== 247 +create table parted_boolean_greater partition of parted_boolean_col + for values in ('foo' > 'bar') +-- +TABLE: name="parted_boolean_greater" schema="" table="parted_boolean_greater" ctx=DDL +STMT: CreateStmt +== 248 +drop table parted_boolean_col +-- +TABLE: name="parted_boolean_col" schema="" table="parted_boolean_col" ctx=DDL +STMT: DropStmt +== 249 +-- check for a conflicting COLLATE clause +create table parted_collate_must_match (a text collate "C", b text collate "C") + partition by range (a) +-- +TABLE: name="parted_collate_must_match" schema="" table="parted_collate_must_match" ctx=DDL +STMT: CreateStmt +== 250 +-- on the partition key +create table parted_collate_must_match1 partition of parted_collate_must_match + (a collate "POSIX") for values from ('a') to ('m') +-- +TABLE: name="parted_collate_must_match1" schema="" table="parted_collate_must_match1" ctx=DDL +STMT: CreateStmt +== 251 +-- on another column +create table parted_collate_must_match2 partition of parted_collate_must_match + (b collate "POSIX") for values from ('m') to ('z') +-- +TABLE: name="parted_collate_must_match2" schema="" table="parted_collate_must_match2" ctx=DDL +STMT: CreateStmt +== 252 +drop table parted_collate_must_match +-- +TABLE: name="parted_collate_must_match" schema="" table="parted_collate_must_match" ctx=DDL +STMT: DropStmt +== 253 +-- check that non-matching collations for partition bound +-- expressions are coerced to the right collation + +create table test_part_coll_posix (a text) partition by range (a collate "POSIX") +-- +TABLE: name="test_part_coll_posix" schema="" table="test_part_coll_posix" ctx=DDL +STMT: CreateStmt +== 254 +-- ok, collation is implicitly coerced +create table test_part_coll partition of test_part_coll_posix for values from ('a' collate "C") to ('g') +-- +TABLE: name="test_part_coll" schema="" table="test_part_coll" ctx=DDL +STMT: CreateStmt +== 255 +-- ok +create table test_part_coll2 partition of test_part_coll_posix for values from ('g') to ('m') +-- +TABLE: name="test_part_coll2" schema="" table="test_part_coll2" ctx=DDL +STMT: CreateStmt +== 256 +-- ok, collation is implicitly coerced +create table test_part_coll_cast partition of test_part_coll_posix for values from (name 'm' collate "C") to ('s') +-- +TABLE: name="test_part_coll_cast" schema="" table="test_part_coll_cast" ctx=DDL +STMT: CreateStmt +== 257 +-- ok; partition collation silently overrides the default collation of type 'name' +create table test_part_coll_cast2 partition of test_part_coll_posix for values from (name 's') to ('z') +-- +TABLE: name="test_part_coll_cast2" schema="" table="test_part_coll_cast2" ctx=DDL +STMT: CreateStmt +== 258 +drop table test_part_coll_posix +-- +TABLE: name="test_part_coll_posix" schema="" table="test_part_coll_posix" ctx=DDL +STMT: DropStmt +== 259 +-- Partition bound in describe output + +-- Both partition bound and partition key in describe output + +-- a level-2 partition's constraint will include the parent's expressions + +-- Show partition count in the parent's describe output +-- Tempted to include \d+ output listing partitions with bound info but +-- output could vary depending on the order in which partition oids are +-- returned. + +-- check that we get the expected partition constraints +CREATE TABLE range_parted4 (a int, b int, c int) PARTITION BY RANGE (abs(a), abs(b), c) +-- +TABLE: name="range_parted4" schema="" table="range_parted4" ctx=DDL +STMT: CreateStmt +== 260 +CREATE TABLE unbounded_range_part PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE) +-- +TABLE: name="unbounded_range_part" schema="" table="unbounded_range_part" ctx=DDL +STMT: CreateStmt +== 261 +DROP TABLE unbounded_range_part +-- +TABLE: name="unbounded_range_part" schema="" table="unbounded_range_part" ctx=DDL +STMT: DropStmt +== 262 +CREATE TABLE range_parted4_1 PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE) +-- +TABLE: name="range_parted4_1" schema="" table="range_parted4_1" ctx=DDL +STMT: CreateStmt +== 263 +CREATE TABLE range_parted4_2 PARTITION OF range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE) +-- +TABLE: name="range_parted4_2" schema="" table="range_parted4_2" ctx=DDL +STMT: CreateStmt +== 264 +CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE) +-- +TABLE: name="range_parted4_3" schema="" table="range_parted4_3" ctx=DDL +STMT: CreateStmt +== 265 +DROP TABLE range_parted4 +-- +TABLE: name="range_parted4" schema="" table="range_parted4" ctx=DDL +STMT: DropStmt +== 266 +-- user-defined operator class in partition key +CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql + AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$ +-- +FUNCTION: name="my_int4_sort" function="my_int4_sort" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 267 +CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS + OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4), + OPERATOR 3 = (int4,int4), OPERATOR 4 >= (int4,int4), + OPERATOR 5 > (int4,int4), FUNCTION 1 my_int4_sort(int4,int4) +-- +STMT: CreateOpClassStmt +== 268 +CREATE TABLE partkey_t (a int4) PARTITION BY RANGE (a test_int4_ops) +-- +TABLE: name="partkey_t" schema="" table="partkey_t" ctx=DDL +STMT: CreateStmt +== 269 +CREATE TABLE partkey_t_1 PARTITION OF partkey_t FOR VALUES FROM (0) TO (1000) +-- +TABLE: name="partkey_t_1" schema="" table="partkey_t_1" ctx=DDL +STMT: CreateStmt +== 270 +INSERT INTO partkey_t VALUES (100) +-- +TABLE: name="partkey_t" schema="" table="partkey_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 271 +INSERT INTO partkey_t VALUES (200) +-- +TABLE: name="partkey_t" schema="" table="partkey_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 272 +-- cleanup +DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3 +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +TABLE: name="range_parted3" schema="" table="range_parted3" ctx=DDL +STMT: DropStmt +== 273 +DROP TABLE partkey_t, hash_parted, hash_parted2 +-- +TABLE: name="partkey_t" schema="" table="partkey_t" ctx=DDL +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: DropStmt +== 274 +DROP OPERATOR CLASS test_int4_ops USING btree +-- +STMT: DropStmt +== 275 +DROP FUNCTION my_int4_sort(int4,int4) +-- +FUNCTION: name="my_int4_sort" function="my_int4_sort" schema="" ctx=DDL +STMT: DropStmt +== 276 +-- comments on partitioned tables columns +CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a) +-- +TABLE: name="parted_col_comment" schema="" table="parted_col_comment" ctx=DDL +STMT: CreateStmt +== 277 +COMMENT ON TABLE parted_col_comment IS 'Am partitioned table' +-- +STMT: CommentStmt +== 278 +COMMENT ON COLUMN parted_col_comment.a IS 'Partition key' +-- +STMT: CommentStmt +== 279 +SELECT obj_description('parted_col_comment'::regclass) +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +== 280 +DROP TABLE parted_col_comment +-- +TABLE: name="parted_col_comment" schema="" table="parted_col_comment" ctx=DDL +STMT: DropStmt +== 281 +-- specifying storage parameters for partitioned tables is not supported +CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a) WITH (fillfactor=100) +-- +TABLE: name="parted_col_comment" schema="" table="parted_col_comment" ctx=DDL +STMT: CreateStmt +== 282 +-- list partitioning on array type column +CREATE TABLE arrlp (a int[]) PARTITION BY LIST (a) +-- +TABLE: name="arrlp" schema="" table="arrlp" ctx=DDL +STMT: CreateStmt +== 283 +CREATE TABLE arrlp12 PARTITION OF arrlp FOR VALUES IN ('{1}', '{2}') +-- +TABLE: name="arrlp12" schema="" table="arrlp12" ctx=DDL +STMT: CreateStmt +== 284 +DROP TABLE arrlp +-- +TABLE: name="arrlp" schema="" table="arrlp" ctx=DDL +STMT: DropStmt +== 285 +-- partition on boolean column +create table boolspart (a bool) partition by list (a) +-- +TABLE: name="boolspart" schema="" table="boolspart" ctx=DDL +STMT: CreateStmt +== 286 +create table boolspart_t partition of boolspart for values in (true) +-- +TABLE: name="boolspart_t" schema="" table="boolspart_t" ctx=DDL +STMT: CreateStmt +== 287 +create table boolspart_f partition of boolspart for values in (false) +-- +TABLE: name="boolspart_f" schema="" table="boolspart_f" ctx=DDL +STMT: CreateStmt +== 288 +drop table boolspart +-- +TABLE: name="boolspart" schema="" table="boolspart" ctx=DDL +STMT: DropStmt +== 289 +-- partitions mixing temporary and permanent relations +create table perm_parted (a int) partition by list (a) +-- +TABLE: name="perm_parted" schema="" table="perm_parted" ctx=DDL +STMT: CreateStmt +== 290 +create temporary table temp_parted (a int) partition by list (a) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: CreateStmt +== 291 +create table perm_part partition of temp_parted default +-- +TABLE: name="perm_part" schema="" table="perm_part" ctx=DDL +STMT: CreateStmt +== 292 +-- error +create temp table temp_part partition of perm_parted default +-- +TABLE: name="temp_part" schema="" table="temp_part" ctx=DDL +STMT: CreateStmt +== 293 +-- error +create temp table temp_part partition of temp_parted default +-- +TABLE: name="temp_part" schema="" table="temp_part" ctx=DDL +STMT: CreateStmt +== 294 +-- ok +drop table perm_parted cascade +-- +TABLE: name="perm_parted" schema="" table="perm_parted" ctx=DDL +STMT: DropStmt +== 295 +drop table temp_parted cascade +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: DropStmt +== 296 +-- check that adding partitions to a table while it is being used is prevented +create table tab_part_create (a int) partition by list (a) +-- +TABLE: name="tab_part_create" schema="" table="tab_part_create" ctx=DDL +STMT: CreateStmt +== 297 +create or replace function func_part_create() returns trigger + language plpgsql as $$ + begin + execute 'create table tab_part_create_1 partition of tab_part_create for values in (1)'; + return null; + end $$ +-- +FUNCTION: name="func_part_create" function="func_part_create" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 298 +create trigger trig_part_create before insert on tab_part_create + for each statement execute procedure func_part_create() +-- +TABLE: name="tab_part_create" schema="" table="tab_part_create" ctx=DDL +STMT: CreateTrigStmt +== 299 +insert into tab_part_create values (1) +-- +TABLE: name="tab_part_create" schema="" table="tab_part_create" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 300 +drop table tab_part_create +-- +TABLE: name="tab_part_create" schema="" table="tab_part_create" ctx=DDL +STMT: DropStmt +== 301 +drop function func_part_create() +-- +FUNCTION: name="func_part_create" function="func_part_create" schema="" ctx=DDL +STMT: DropStmt +== 302 +-- test using a volatile expression as partition bound +create table volatile_partbound_test (partkey timestamp) partition by range (partkey) +-- +TABLE: name="volatile_partbound_test" schema="" table="volatile_partbound_test" ctx=DDL +STMT: CreateStmt +== 303 +create table volatile_partbound_test1 partition of volatile_partbound_test for values from (minvalue) to (current_timestamp) +-- +TABLE: name="volatile_partbound_test1" schema="" table="volatile_partbound_test1" ctx=DDL +STMT: CreateStmt +== 304 +create table volatile_partbound_test2 partition of volatile_partbound_test for values from (current_timestamp) to (maxvalue) +-- +TABLE: name="volatile_partbound_test2" schema="" table="volatile_partbound_test2" ctx=DDL +STMT: CreateStmt +== 305 +-- this should go into the partition volatile_partbound_test2 +insert into volatile_partbound_test values (current_timestamp) +-- +TABLE: name="volatile_partbound_test" schema="" table="volatile_partbound_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 306 +select tableoid::regclass from volatile_partbound_test +-- +TABLE: name="volatile_partbound_test" schema="" table="volatile_partbound_test" ctx=Select +STMT: SelectStmt +== 307 +drop table volatile_partbound_test +-- +TABLE: name="volatile_partbound_test" schema="" table="volatile_partbound_test" ctx=DDL +STMT: DropStmt +== 308 +-- test the case where a check constraint on default partition allows +-- to avoid scanning it when adding a new partition +create table defcheck (a int, b int) partition by list (b) +-- +TABLE: name="defcheck" schema="" table="defcheck" ctx=DDL +STMT: CreateStmt +== 309 +create table defcheck_def (a int, c int, b int) +-- +TABLE: name="defcheck_def" schema="" table="defcheck_def" ctx=DDL +STMT: CreateStmt +== 310 +alter table defcheck_def drop c +-- +TABLE: name="defcheck_def" schema="" table="defcheck_def" ctx=DDL +STMT: AlterTableStmt +== 311 +alter table defcheck attach partition defcheck_def default +-- +TABLE: name="defcheck" schema="" table="defcheck" ctx=DDL +STMT: AlterTableStmt +== 312 +alter table defcheck_def add check (b <= 0 and b is not null) +-- +TABLE: name="defcheck_def" schema="" table="defcheck_def" ctx=DDL +STMT: AlterTableStmt +== 313 +create table defcheck_1 partition of defcheck for values in (1, null) +-- +TABLE: name="defcheck_1" schema="" table="defcheck_1" ctx=DDL +STMT: CreateStmt +== 314 +-- test that complex default partition constraints are enforced correctly +insert into defcheck_def values (0, 0) +-- +TABLE: name="defcheck_def" schema="" table="defcheck_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 315 +create table defcheck_0 partition of defcheck for values in (0) +-- +TABLE: name="defcheck_0" schema="" table="defcheck_0" ctx=DDL +STMT: CreateStmt +== 316 +drop table defcheck +-- +TABLE: name="defcheck" schema="" table="defcheck" ctx=DDL +STMT: DropStmt +== 317 +-- tests of column drop with partition tables and indexes using +-- predicates and expressions. +create table part_column_drop ( + useless_1 int, + id int, + useless_2 int, + d int, + b int, + useless_3 int +) partition by range (id) +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: CreateStmt +== 318 +alter table part_column_drop drop column useless_1 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: AlterTableStmt +== 319 +alter table part_column_drop drop column useless_2 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: AlterTableStmt +== 320 +alter table part_column_drop drop column useless_3 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: AlterTableStmt +== 321 +create index part_column_drop_b_pred on part_column_drop(b) where b = 1 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: IndexStmt +== 322 +create index part_column_drop_b_expr on part_column_drop((b = 1)) +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: IndexStmt +== 323 +create index part_column_drop_d_pred on part_column_drop(d) where d = 2 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: IndexStmt +== 324 +create index part_column_drop_d_expr on part_column_drop((d = 2)) +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: IndexStmt +== 325 +create table part_column_drop_1_10 partition of + part_column_drop for values from (1) to (10) +-- +TABLE: name="part_column_drop_1_10" schema="" table="part_column_drop_1_10" ctx=DDL +STMT: CreateStmt +== 326 +drop table part_column_drop +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/create_table_like.metadata.json b/parser/testdata/summary/postgres_regress/create_table_like.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_table_like.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_table_like.test b/parser/testdata/summary/postgres_regress/create_table_like.test new file mode 100644 index 0000000..e38a6b9 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_table_like.test @@ -0,0 +1,822 @@ +== 001 +/* Test inheritance of structure (LIKE) */ +CREATE TABLE inhx (xx text DEFAULT 'text') +-- +TABLE: name="inhx" schema="" table="inhx" ctx=DDL +STMT: CreateStmt +== 002 +/* + * Test double inheritance + * + * Ensure that defaults are NOT included unless + * INCLUDING DEFAULTS is specified + */ +CREATE TABLE ctla (aa TEXT) +-- +TABLE: name="ctla" schema="" table="ctla" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE ctlb (bb TEXT) INHERITS (ctla) +-- +TABLE: name="ctlb" schema="" table="ctlb" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE foo (LIKE nonexistent) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 005 +CREATE TABLE inhe (ee text, LIKE inhx) inherits (ctlb) +-- +TABLE: name="inhe" schema="" table="inhe" ctx=DDL +STMT: CreateStmt +== 006 +INSERT INTO inhe VALUES ('ee-col1', 'ee-col2', DEFAULT, 'ee-col4') +-- +TABLE: name="inhe" schema="" table="inhe" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +SELECT * FROM inhe +-- +TABLE: name="inhe" schema="" table="inhe" ctx=Select +STMT: SelectStmt +== 008 +/* Columns aa, bb, xx value NULL, ee */ +SELECT * FROM inhx +-- +TABLE: name="inhx" schema="" table="inhx" ctx=Select +STMT: SelectStmt +== 009 +/* Empty set since LIKE inherits structure only */ +SELECT * FROM ctlb +-- +TABLE: name="ctlb" schema="" table="ctlb" ctx=Select +STMT: SelectStmt +== 010 +/* Has ee entry */ +SELECT * FROM ctla +-- +TABLE: name="ctla" schema="" table="ctla" ctx=Select +STMT: SelectStmt +== 011 +/* Has ee entry */ + +CREATE TABLE inhf (LIKE inhx, LIKE inhx) +-- +TABLE: name="inhf" schema="" table="inhf" ctx=DDL +STMT: CreateStmt +== 012 +/* Throw error */ + +CREATE TABLE inhf (LIKE inhx INCLUDING DEFAULTS INCLUDING CONSTRAINTS) +-- +TABLE: name="inhf" schema="" table="inhf" ctx=DDL +STMT: CreateStmt +== 013 +INSERT INTO inhf DEFAULT VALUES +-- +TABLE: name="inhf" schema="" table="inhf" ctx=DML +STMT: InsertStmt +== 014 +SELECT * FROM inhf +-- +TABLE: name="inhf" schema="" table="inhf" ctx=Select +STMT: SelectStmt +== 015 +/* Single entry with value 'text' */ + +ALTER TABLE inhx add constraint foo CHECK (xx = 'text') +-- +TABLE: name="inhx" schema="" table="inhx" ctx=DDL +STMT: AlterTableStmt +== 016 +ALTER TABLE inhx ADD PRIMARY KEY (xx) +-- +TABLE: name="inhx" schema="" table="inhx" ctx=DDL +STMT: AlterTableStmt +== 017 +CREATE TABLE inhg (LIKE inhx) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +== 018 +/* Doesn't copy constraint */ +INSERT INTO inhg VALUES ('foo') +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +DROP TABLE inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: DropStmt +== 020 +CREATE TABLE inhg (x text, LIKE inhx INCLUDING CONSTRAINTS, y text) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +== 021 +/* Copies constraints */ +INSERT INTO inhg VALUES ('x', 'text', 'y') +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +/* Succeeds */ +INSERT INTO inhg VALUES ('x', 'text', 'y') +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +/* Succeeds -- Unique constraints not copied */ +INSERT INTO inhg VALUES ('x', 'foo', 'y') +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +/* fails due to constraint */ +SELECT * FROM inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=Select +STMT: SelectStmt +== 025 +/* Two records with three columns in order x=x, xx=text, y=y */ +DROP TABLE inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: DropStmt +== 026 +CREATE TABLE test_like_id_1 (a bigint GENERATED ALWAYS AS IDENTITY, b text) +-- +TABLE: name="test_like_id_1" schema="" table="test_like_id_1" ctx=DDL +STMT: CreateStmt +== 027 +INSERT INTO test_like_id_1 (b) VALUES ('b1') +-- +TABLE: name="test_like_id_1" schema="" table="test_like_id_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +SELECT * FROM test_like_id_1 +-- +TABLE: name="test_like_id_1" schema="" table="test_like_id_1" ctx=Select +STMT: SelectStmt +== 029 +CREATE TABLE test_like_id_2 (LIKE test_like_id_1) +-- +TABLE: name="test_like_id_2" schema="" table="test_like_id_2" ctx=DDL +STMT: CreateStmt +== 030 +INSERT INTO test_like_id_2 (b) VALUES ('b2') +-- +TABLE: name="test_like_id_2" schema="" table="test_like_id_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +SELECT * FROM test_like_id_2 +-- +TABLE: name="test_like_id_2" schema="" table="test_like_id_2" ctx=Select +STMT: SelectStmt +== 032 +-- identity was not copied +CREATE TABLE test_like_id_3 (LIKE test_like_id_1 INCLUDING IDENTITY) +-- +TABLE: name="test_like_id_3" schema="" table="test_like_id_3" ctx=DDL +STMT: CreateStmt +== 033 +INSERT INTO test_like_id_3 (b) VALUES ('b3') +-- +TABLE: name="test_like_id_3" schema="" table="test_like_id_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +SELECT * FROM test_like_id_3 +-- +TABLE: name="test_like_id_3" schema="" table="test_like_id_3" ctx=Select +STMT: SelectStmt +== 035 +-- identity was copied and applied +DROP TABLE test_like_id_1, test_like_id_2, test_like_id_3 +-- +TABLE: name="test_like_id_1" schema="" table="test_like_id_1" ctx=DDL +TABLE: name="test_like_id_2" schema="" table="test_like_id_2" ctx=DDL +TABLE: name="test_like_id_3" schema="" table="test_like_id_3" ctx=DDL +STMT: DropStmt +== 036 +CREATE TABLE test_like_gen_1 (a int, b int GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="test_like_gen_1" schema="" table="test_like_gen_1" ctx=DDL +STMT: CreateStmt +== 037 +INSERT INTO test_like_gen_1 (a) VALUES (1) +-- +TABLE: name="test_like_gen_1" schema="" table="test_like_gen_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +SELECT * FROM test_like_gen_1 +-- +TABLE: name="test_like_gen_1" schema="" table="test_like_gen_1" ctx=Select +STMT: SelectStmt +== 039 +CREATE TABLE test_like_gen_2 (LIKE test_like_gen_1) +-- +TABLE: name="test_like_gen_2" schema="" table="test_like_gen_2" ctx=DDL +STMT: CreateStmt +== 040 +INSERT INTO test_like_gen_2 (a) VALUES (1) +-- +TABLE: name="test_like_gen_2" schema="" table="test_like_gen_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +SELECT * FROM test_like_gen_2 +-- +TABLE: name="test_like_gen_2" schema="" table="test_like_gen_2" ctx=Select +STMT: SelectStmt +== 042 +CREATE TABLE test_like_gen_3 (LIKE test_like_gen_1 INCLUDING GENERATED) +-- +TABLE: name="test_like_gen_3" schema="" table="test_like_gen_3" ctx=DDL +STMT: CreateStmt +== 043 +INSERT INTO test_like_gen_3 (a) VALUES (1) +-- +TABLE: name="test_like_gen_3" schema="" table="test_like_gen_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +SELECT * FROM test_like_gen_3 +-- +TABLE: name="test_like_gen_3" schema="" table="test_like_gen_3" ctx=Select +STMT: SelectStmt +== 045 +DROP TABLE test_like_gen_1, test_like_gen_2, test_like_gen_3 +-- +TABLE: name="test_like_gen_1" schema="" table="test_like_gen_1" ctx=DDL +TABLE: name="test_like_gen_2" schema="" table="test_like_gen_2" ctx=DDL +TABLE: name="test_like_gen_3" schema="" table="test_like_gen_3" ctx=DDL +STMT: DropStmt +== 046 +-- also test generated column with a "forward" reference (bug #16342) +CREATE TABLE test_like_4 (b int DEFAULT 42, + c int GENERATED ALWAYS AS (a * 2) STORED, + a int CHECK (a > 0)) +-- +TABLE: name="test_like_4" schema="" table="test_like_4" ctx=DDL +STMT: CreateStmt +== 047 +CREATE TABLE test_like_4a (LIKE test_like_4) +-- +TABLE: name="test_like_4a" schema="" table="test_like_4a" ctx=DDL +STMT: CreateStmt +== 048 +CREATE TABLE test_like_4b (LIKE test_like_4 INCLUDING DEFAULTS) +-- +TABLE: name="test_like_4b" schema="" table="test_like_4b" ctx=DDL +STMT: CreateStmt +== 049 +CREATE TABLE test_like_4c (LIKE test_like_4 INCLUDING GENERATED) +-- +TABLE: name="test_like_4c" schema="" table="test_like_4c" ctx=DDL +STMT: CreateStmt +== 050 +CREATE TABLE test_like_4d (LIKE test_like_4 INCLUDING DEFAULTS INCLUDING GENERATED) +-- +TABLE: name="test_like_4d" schema="" table="test_like_4d" ctx=DDL +STMT: CreateStmt +== 051 +INSERT INTO test_like_4a (a) VALUES(11) +-- +TABLE: name="test_like_4a" schema="" table="test_like_4a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +SELECT a, b, c FROM test_like_4a +-- +TABLE: name="test_like_4a" schema="" table="test_like_4a" ctx=Select +STMT: SelectStmt +== 053 +INSERT INTO test_like_4b (a) VALUES(11) +-- +TABLE: name="test_like_4b" schema="" table="test_like_4b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +SELECT a, b, c FROM test_like_4b +-- +TABLE: name="test_like_4b" schema="" table="test_like_4b" ctx=Select +STMT: SelectStmt +== 055 +INSERT INTO test_like_4c (a) VALUES(11) +-- +TABLE: name="test_like_4c" schema="" table="test_like_4c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +SELECT a, b, c FROM test_like_4c +-- +TABLE: name="test_like_4c" schema="" table="test_like_4c" ctx=Select +STMT: SelectStmt +== 057 +INSERT INTO test_like_4d (a) VALUES(11) +-- +TABLE: name="test_like_4d" schema="" table="test_like_4d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +SELECT a, b, c FROM test_like_4d +-- +TABLE: name="test_like_4d" schema="" table="test_like_4d" ctx=Select +STMT: SelectStmt +== 059 +-- Test renumbering of Vars when combining LIKE with inheritance +CREATE TABLE test_like_5 (x point, y point, z point) +-- +TABLE: name="test_like_5" schema="" table="test_like_5" ctx=DDL +STMT: CreateStmt +== 060 +CREATE TABLE test_like_5x (p int CHECK (p > 0), + q int GENERATED ALWAYS AS (p * 2) STORED) +-- +TABLE: name="test_like_5x" schema="" table="test_like_5x" ctx=DDL +STMT: CreateStmt +== 061 +CREATE TABLE test_like_5c (LIKE test_like_4 INCLUDING ALL) + INHERITS (test_like_5, test_like_5x) +-- +TABLE: name="test_like_5c" schema="" table="test_like_5c" ctx=DDL +STMT: CreateStmt +== 062 +-- Test updating of column numbers in statistics expressions (bug #18468) +CREATE TABLE test_like_6 (a int, c text, b text) +-- +TABLE: name="test_like_6" schema="" table="test_like_6" ctx=DDL +STMT: CreateStmt +== 063 +CREATE STATISTICS ext_stat ON (a || b) FROM test_like_6 +-- +STMT: CreateStatsStmt +== 064 +ALTER TABLE test_like_6 DROP COLUMN c +-- +TABLE: name="test_like_6" schema="" table="test_like_6" ctx=DDL +STMT: AlterTableStmt +== 065 +CREATE TABLE test_like_6c (LIKE test_like_6 INCLUDING ALL) +-- +TABLE: name="test_like_6c" schema="" table="test_like_6c" ctx=DDL +STMT: CreateStmt +== 066 +DROP TABLE test_like_4, test_like_4a, test_like_4b, test_like_4c, test_like_4d +-- +TABLE: name="test_like_4" schema="" table="test_like_4" ctx=DDL +TABLE: name="test_like_4a" schema="" table="test_like_4a" ctx=DDL +TABLE: name="test_like_4b" schema="" table="test_like_4b" ctx=DDL +TABLE: name="test_like_4c" schema="" table="test_like_4c" ctx=DDL +TABLE: name="test_like_4d" schema="" table="test_like_4d" ctx=DDL +STMT: DropStmt +== 067 +DROP TABLE test_like_5, test_like_5x, test_like_5c +-- +TABLE: name="test_like_5" schema="" table="test_like_5" ctx=DDL +TABLE: name="test_like_5x" schema="" table="test_like_5x" ctx=DDL +TABLE: name="test_like_5c" schema="" table="test_like_5c" ctx=DDL +STMT: DropStmt +== 068 +DROP TABLE test_like_6, test_like_6c +-- +TABLE: name="test_like_6" schema="" table="test_like_6" ctx=DDL +TABLE: name="test_like_6c" schema="" table="test_like_6c" ctx=DDL +STMT: DropStmt +== 069 +CREATE TABLE inhg (x text, LIKE inhx INCLUDING INDEXES, y text) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +== 070 +/* copies indexes */ +INSERT INTO inhg VALUES (5, 10) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +INSERT INTO inhg VALUES (20, 10) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +-- should fail +DROP TABLE inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: DropStmt +== 073 +/* Multiple primary keys creation should fail */ +CREATE TABLE inhg (x text, LIKE inhx INCLUDING INDEXES, PRIMARY KEY(x)) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +== 074 +/* fails */ +CREATE TABLE inhz (xx text DEFAULT 'text', yy int UNIQUE) +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: CreateStmt +== 075 +CREATE UNIQUE INDEX inhz_xx_idx on inhz (xx) WHERE xx <> 'test' +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: IndexStmt +== 076 +/* Ok to create multiple unique indexes */ +CREATE TABLE inhg (x text UNIQUE, LIKE inhz INCLUDING INDEXES) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +== 077 +INSERT INTO inhg (xx, yy, x) VALUES ('test', 5, 10) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +INSERT INTO inhg (xx, yy, x) VALUES ('test', 10, 15) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 079 +INSERT INTO inhg (xx, yy, x) VALUES ('foo', 10, 15) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +-- should fail +DROP TABLE inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: DropStmt +== 081 +DROP TABLE inhz +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: DropStmt +== 082 +/* Use primary key imported by LIKE for self-referential FK constraint */ +CREATE TABLE inhz (x text REFERENCES inhz, LIKE inhx INCLUDING INDEXES) +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: CreateStmt +== 083 +DROP TABLE inhz +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: DropStmt +== 084 +-- including storage and comments +CREATE TABLE ctlt1 (a text CHECK (length(a) > 2) PRIMARY KEY, b text) +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: CreateStmt +== 085 +CREATE INDEX ctlt1_b_key ON ctlt1 (b) +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: IndexStmt +== 086 +CREATE INDEX ctlt1_fnidx ON ctlt1 ((a || b)) +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: IndexStmt +== 087 +CREATE STATISTICS ctlt1_a_b_stat ON a,b FROM ctlt1 +-- +STMT: CreateStatsStmt +== 088 +CREATE STATISTICS ctlt1_expr_stat ON (a || b) FROM ctlt1 +-- +STMT: CreateStatsStmt +== 089 +COMMENT ON STATISTICS ctlt1_a_b_stat IS 'ab stats' +-- +STMT: CommentStmt +== 090 +COMMENT ON STATISTICS ctlt1_expr_stat IS 'ab expr stats' +-- +STMT: CommentStmt +== 091 +COMMENT ON COLUMN ctlt1.a IS 'A' +-- +STMT: CommentStmt +== 092 +COMMENT ON COLUMN ctlt1.b IS 'B' +-- +STMT: CommentStmt +== 093 +COMMENT ON CONSTRAINT ctlt1_a_check ON ctlt1 IS 't1_a_check' +-- +STMT: CommentStmt +== 094 +COMMENT ON INDEX ctlt1_pkey IS 'index pkey' +-- +STMT: CommentStmt +== 095 +COMMENT ON INDEX ctlt1_b_key IS 'index b_key' +-- +STMT: CommentStmt +== 096 +ALTER TABLE ctlt1 ALTER COLUMN a SET STORAGE MAIN +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: AlterTableStmt +== 097 +CREATE TABLE ctlt2 (c text) +-- +TABLE: name="ctlt2" schema="" table="ctlt2" ctx=DDL +STMT: CreateStmt +== 098 +ALTER TABLE ctlt2 ALTER COLUMN c SET STORAGE EXTERNAL +-- +TABLE: name="ctlt2" schema="" table="ctlt2" ctx=DDL +STMT: AlterTableStmt +== 099 +COMMENT ON COLUMN ctlt2.c IS 'C' +-- +STMT: CommentStmt +== 100 +CREATE TABLE ctlt3 (a text CHECK (length(a) < 5), c text CHECK (length(c) < 7)) +-- +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +STMT: CreateStmt +== 101 +ALTER TABLE ctlt3 ALTER COLUMN c SET STORAGE EXTERNAL +-- +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +STMT: AlterTableStmt +== 102 +ALTER TABLE ctlt3 ALTER COLUMN a SET STORAGE MAIN +-- +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +STMT: AlterTableStmt +== 103 +CREATE INDEX ctlt3_fnidx ON ctlt3 ((a || c)) +-- +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +STMT: IndexStmt +== 104 +COMMENT ON COLUMN ctlt3.a IS 'A3' +-- +STMT: CommentStmt +== 105 +COMMENT ON COLUMN ctlt3.c IS 'C' +-- +STMT: CommentStmt +== 106 +COMMENT ON CONSTRAINT ctlt3_a_check ON ctlt3 IS 't3_a_check' +-- +STMT: CommentStmt +== 107 +CREATE TABLE ctlt4 (a text, c text) +-- +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +STMT: CreateStmt +== 108 +ALTER TABLE ctlt4 ALTER COLUMN c SET STORAGE EXTERNAL +-- +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +STMT: AlterTableStmt +== 109 +CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING STORAGE) +-- +TABLE: name="ctlt12_storage" schema="" table="ctlt12_storage" ctx=DDL +STMT: CreateStmt +== 110 +CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS) +-- +TABLE: name="ctlt12_comments" schema="" table="ctlt12_comments" ctx=DDL +STMT: CreateStmt +== 111 +CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING COMMENTS) INHERITS (ctlt1) +-- +TABLE: name="ctlt1_inh" schema="" table="ctlt1_inh" ctx=DDL +STMT: CreateStmt +== 112 +SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt1_inh'::regclass +-- +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "c"="pg_constraint" +FILTER: schema="" table="" column="classoid" +FILTER: schema="" table="" column="objoid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="c" column="conrelid" +STMT: SelectStmt +== 113 +CREATE TABLE ctlt13_inh () INHERITS (ctlt1, ctlt3) +-- +TABLE: name="ctlt13_inh" schema="" table="ctlt13_inh" ctx=DDL +STMT: CreateStmt +== 114 +CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING INDEXES INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1) +-- +TABLE: name="ctlt13_like" schema="" table="ctlt13_like" ctx=DDL +STMT: CreateStmt +== 115 +SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt13_like'::regclass +-- +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "c"="pg_constraint" +FILTER: schema="" table="" column="classoid" +FILTER: schema="" table="" column="objoid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="c" column="conrelid" +STMT: SelectStmt +== 116 +CREATE TABLE ctlt_all (LIKE ctlt1 INCLUDING ALL) +-- +TABLE: name="ctlt_all" schema="" table="ctlt_all" ctx=DDL +STMT: CreateStmt +== 117 +SELECT c.relname, objsubid, description FROM pg_description, pg_index i, pg_class c WHERE classoid = 'pg_class'::regclass AND objoid = i.indexrelid AND c.oid = i.indexrelid AND i.indrelid = 'ctlt_all'::regclass ORDER BY c.relname, objsubid +-- +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FILTER: schema="" table="" column="classoid" +FILTER: schema="" table="" column="objoid" +FILTER: schema="" table="i" column="indexrelid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="i" column="indexrelid" +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +== 118 +SELECT s.stxname, objsubid, description FROM pg_description, pg_statistic_ext s WHERE classoid = 'pg_statistic_ext'::regclass AND objoid = s.oid AND s.stxrelid = 'ctlt_all'::regclass ORDER BY s.stxname, objsubid +-- +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="" column="classoid" +FILTER: schema="" table="" column="objoid" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="stxrelid" +STMT: SelectStmt +== 119 +CREATE TABLE inh_error1 () INHERITS (ctlt1, ctlt4) +-- +TABLE: name="inh_error1" schema="" table="inh_error1" ctx=DDL +STMT: CreateStmt +== 120 +CREATE TABLE inh_error2 (LIKE ctlt4 INCLUDING STORAGE) INHERITS (ctlt1) +-- +TABLE: name="inh_error2" schema="" table="inh_error2" ctx=DDL +STMT: CreateStmt +== 121 +-- Check that LIKE isn't confused by a system catalog of the same name +CREATE TABLE pg_attrdef (LIKE ctlt1 INCLUDING ALL) +-- +TABLE: name="pg_attrdef" schema="" table="pg_attrdef" ctx=DDL +STMT: CreateStmt +== 122 +DROP TABLE public.pg_attrdef +-- +TABLE: name="public.pg_attrdef" schema="public" table="pg_attrdef" ctx=DDL +STMT: DropStmt +== 123 +-- Check that LIKE isn't confused when new table masks the old, either +BEGIN +-- +STMT: TransactionStmt +== 124 +CREATE SCHEMA ctl_schema +-- +STMT: CreateSchemaStmt +== 125 +SET LOCAL search_path = ctl_schema, public +-- +STMT: VariableSetStmt +== 126 +CREATE TABLE ctlt1 (LIKE ctlt1 INCLUDING ALL) +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: CreateStmt +== 127 +ROLLBACK +-- +STMT: TransactionStmt +== 128 +DROP TABLE ctlt1, ctlt2, ctlt3, ctlt4, ctlt12_storage, ctlt12_comments, ctlt1_inh, ctlt13_inh, ctlt13_like, ctlt_all, ctla, ctlb CASCADE +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +TABLE: name="ctlt2" schema="" table="ctlt2" ctx=DDL +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +TABLE: name="ctlt12_storage" schema="" table="ctlt12_storage" ctx=DDL +TABLE: name="ctlt12_comments" schema="" table="ctlt12_comments" ctx=DDL +TABLE: name="ctlt1_inh" schema="" table="ctlt1_inh" ctx=DDL +TABLE: name="ctlt13_inh" schema="" table="ctlt13_inh" ctx=DDL +TABLE: name="ctlt13_like" schema="" table="ctlt13_like" ctx=DDL +TABLE: name="ctlt_all" schema="" table="ctlt_all" ctx=DDL +TABLE: name="ctla" schema="" table="ctla" ctx=DDL +TABLE: name="ctlb" schema="" table="ctlb" ctx=DDL +STMT: DropStmt +== 129 +-- LIKE must respect NO INHERIT property of constraints +CREATE TABLE noinh_con_copy (a int CHECK (a > 0) NO INHERIT) +-- +TABLE: name="noinh_con_copy" schema="" table="noinh_con_copy" ctx=DDL +STMT: CreateStmt +== 130 +CREATE TABLE noinh_con_copy1 (LIKE noinh_con_copy INCLUDING CONSTRAINTS) +-- +TABLE: name="noinh_con_copy1" schema="" table="noinh_con_copy1" ctx=DDL +STMT: CreateStmt +== 131 +-- fail, as partitioned tables don't allow NO INHERIT constraints +CREATE TABLE noinh_con_copy1_parted (LIKE noinh_con_copy INCLUDING ALL) + PARTITION BY LIST (a) +-- +TABLE: name="noinh_con_copy1_parted" schema="" table="noinh_con_copy1_parted" ctx=DDL +STMT: CreateStmt +== 132 +DROP TABLE noinh_con_copy, noinh_con_copy1 +-- +TABLE: name="noinh_con_copy" schema="" table="noinh_con_copy" ctx=DDL +TABLE: name="noinh_con_copy1" schema="" table="noinh_con_copy1" ctx=DDL +STMT: DropStmt +== 133 +/* LIKE with other relation kinds */ + +CREATE TABLE ctlt4 (a int, b text) +-- +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +STMT: CreateStmt +== 134 +CREATE SEQUENCE ctlseq1 +-- +STMT: CreateSeqStmt +== 135 +CREATE TABLE ctlt10 (LIKE ctlseq1) +-- +TABLE: name="ctlt10" schema="" table="ctlt10" ctx=DDL +STMT: CreateStmt +== 136 +-- fail + +CREATE VIEW ctlv1 AS SELECT * FROM ctlt4 +-- +TABLE: name="ctlv1" schema="" table="ctlv1" ctx=DDL +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 137 +CREATE TABLE ctlt11 (LIKE ctlv1) +-- +TABLE: name="ctlt11" schema="" table="ctlt11" ctx=DDL +STMT: CreateStmt +== 138 +CREATE TABLE ctlt11a (LIKE ctlv1 INCLUDING ALL) +-- +TABLE: name="ctlt11a" schema="" table="ctlt11a" ctx=DDL +STMT: CreateStmt +== 139 +CREATE TYPE ctlty1 AS (a int, b text) +-- +STMT: CompositeTypeStmt +== 140 +CREATE TABLE ctlt12 (LIKE ctlty1) +-- +TABLE: name="ctlt12" schema="" table="ctlt12" ctx=DDL +STMT: CreateStmt +== 141 +DROP SEQUENCE ctlseq1 +-- +STMT: DropStmt +== 142 +DROP TYPE ctlty1 +-- +STMT: DropStmt +== 143 +DROP VIEW ctlv1 +-- +STMT: DropStmt +== 144 +DROP TABLE IF EXISTS ctlt4, ctlt10, ctlt11, ctlt11a, ctlt12 +-- +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +TABLE: name="ctlt10" schema="" table="ctlt10" ctx=DDL +TABLE: name="ctlt11" schema="" table="ctlt11" ctx=DDL +TABLE: name="ctlt11a" schema="" table="ctlt11a" ctx=DDL +TABLE: name="ctlt12" schema="" table="ctlt12" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/create_type.metadata.json b/parser/testdata/summary/postgres_regress/create_type.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_type.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_type.test b/parser/testdata/summary/postgres_regress/create_type.test new file mode 100644 index 0000000..01de685 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_type.test @@ -0,0 +1,578 @@ +== 001 +|-- +-- CREATE_TYPE +|-- + +-- directory path and dlsuffix are passed to us in environment variables + + +|-- +-- Test the "old style" approach of making the I/O functions first, +-- with no explicit shell type creation. +|-- +CREATE FUNCTION widget_in(cstring) + RETURNS widget + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 272 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +CREATE FUNCTION widget_out(widget) + RETURNS cstring + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 61 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +CREATE FUNCTION int44in(cstring) + RETURNS city_budget + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +CREATE FUNCTION int44out(city_budget) + RETURNS cstring + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 64 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +CREATE TYPE widget ( + internallength = 24, + input = widget_in, + output = widget_out, + typmod_in = numerictypmodin, + typmod_out = numerictypmodout, + alignment = double +) +-- +STMT: DefineStmt +== 006 +CREATE TYPE city_budget ( + internallength = 16, + input = int44in, + output = int44out, + element = int4, + category = 'x', -- just to verify the system will take it + preferred = true -- ditto +) +-- +STMT: DefineStmt +== 007 +-- Test creation and destruction of shell types +CREATE TYPE shell +-- +STMT: DefineStmt +== 008 +CREATE TYPE shell +-- +STMT: DefineStmt +== 009 +-- fail, type already present +DROP TYPE shell +-- +STMT: DropStmt +== 010 +DROP TYPE shell +-- +STMT: DropStmt +== 011 +-- fail, type not exist + +-- also, let's leave one around for purposes of pg_dump testing +CREATE TYPE myshell +-- +STMT: DefineStmt +== 012 +|-- +-- Test type-related default values (broken in releases before PG 7.2) +|-- +-- This part of the test also exercises the "new style" approach of making +-- a shell type and then filling it in. +|-- +CREATE TYPE int42 +-- +STMT: DefineStmt +== 013 +CREATE TYPE text_w_default +-- +STMT: DefineStmt +== 014 +-- Make dummy I/O routines using the existing internal support for int4, text +CREATE FUNCTION int42_in(cstring) + RETURNS int42 + AS 'int4in' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="int42_in" function="int42_in" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 015 +CREATE FUNCTION int42_out(int42) + RETURNS cstring + AS 'int4out' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="int42_out" function="int42_out" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 016 +CREATE FUNCTION text_w_default_in(cstring) + RETURNS text_w_default + AS 'textin' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="text_w_default_in" function="text_w_default_in" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 017 +CREATE FUNCTION text_w_default_out(text_w_default) + RETURNS cstring + AS 'textout' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="text_w_default_out" function="text_w_default_out" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 018 +CREATE TYPE int42 ( + internallength = 4, + input = int42_in, + output = int42_out, + alignment = int4, + default = 42, + passedbyvalue +) +-- +STMT: DefineStmt +== 019 +CREATE TYPE text_w_default ( + internallength = variable, + input = text_w_default_in, + output = text_w_default_out, + alignment = int4, + default = 'zippo' +) +-- +STMT: DefineStmt +== 020 +CREATE TABLE default_test (f1 text_w_default, f2 int42) +-- +TABLE: name="default_test" schema="" table="default_test" ctx=DDL +STMT: CreateStmt +== 021 +INSERT INTO default_test DEFAULT VALUES +-- +TABLE: name="default_test" schema="" table="default_test" ctx=DML +STMT: InsertStmt +== 022 +SELECT * FROM default_test +-- +TABLE: name="default_test" schema="" table="default_test" ctx=Select +STMT: SelectStmt +== 023 +-- We need a shell type to test some CREATE TYPE failure cases with +CREATE TYPE bogus_type +-- +STMT: DefineStmt +== 024 +-- invalid: non-lowercase quoted identifiers +CREATE TYPE bogus_type ( + "Internallength" = 4, + "Input" = int42_in, + "Output" = int42_out, + "Alignment" = int4, + "Default" = 42, + "Passedbyvalue" +) +-- +STMT: DefineStmt +== 025 +-- invalid: input/output function incompatibility +CREATE TYPE bogus_type (INPUT = array_in, + OUTPUT = array_out, + ELEMENT = int, + INTERNALLENGTH = 32) +-- +STMT: DefineStmt +== 026 +DROP TYPE bogus_type +-- +STMT: DropStmt +== 027 +-- It no longer is possible to issue CREATE TYPE without making a shell first +CREATE TYPE bogus_type (INPUT = array_in, + OUTPUT = array_out, + ELEMENT = int, + INTERNALLENGTH = 32) +-- +STMT: DefineStmt +== 028 +-- Test stand-alone composite type + +CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42) +-- +STMT: CompositeTypeStmt +== 029 +CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS ' + SELECT * FROM default_test; +' LANGUAGE SQL +-- +FUNCTION: name="get_default_test" function="get_default_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 030 +SELECT * FROM get_default_test() +-- +FUNCTION: name="get_default_test" function="get_default_test" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- Test comments +COMMENT ON TYPE bad IS 'bad comment' +-- +STMT: CommentStmt +== 032 +COMMENT ON TYPE default_test_row IS 'good comment' +-- +STMT: CommentStmt +== 033 +COMMENT ON TYPE default_test_row IS NULL +-- +STMT: CommentStmt +== 034 +COMMENT ON COLUMN default_test_row.nope IS 'bad comment' +-- +STMT: CommentStmt +== 035 +COMMENT ON COLUMN default_test_row.f1 IS 'good comment' +-- +STMT: CommentStmt +== 036 +COMMENT ON COLUMN default_test_row.f1 IS NULL +-- +STMT: CommentStmt +== 037 +-- Check shell type create for existing types +CREATE TYPE text_w_default +-- +STMT: DefineStmt +== 038 +-- should fail + +DROP TYPE default_test_row CASCADE +-- +STMT: DropStmt +== 039 +DROP TABLE default_test +-- +TABLE: name="default_test" schema="" table="default_test" ctx=DDL +STMT: DropStmt +== 040 +-- Check dependencies are established when creating a new type +CREATE TYPE base_type +-- +STMT: DefineStmt +== 041 +CREATE FUNCTION base_fn_in(cstring) RETURNS base_type AS 'boolin' + LANGUAGE internal IMMUTABLE STRICT +-- +FUNCTION: name="base_fn_in" function="base_fn_in" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 042 +CREATE FUNCTION base_fn_out(base_type) RETURNS cstring AS 'boolout' + LANGUAGE internal IMMUTABLE STRICT +-- +FUNCTION: name="base_fn_out" function="base_fn_out" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 043 +CREATE TYPE base_type(INPUT = base_fn_in, OUTPUT = base_fn_out) +-- +STMT: DefineStmt +== 044 +DROP FUNCTION base_fn_in(cstring) +-- +FUNCTION: name="base_fn_in" function="base_fn_in" schema="" ctx=DDL +STMT: DropStmt +== 045 +-- error +DROP FUNCTION base_fn_out(base_type) +-- +FUNCTION: name="base_fn_out" function="base_fn_out" schema="" ctx=DDL +STMT: DropStmt +== 046 +-- error +DROP TYPE base_type +-- +STMT: DropStmt +== 047 +-- error +DROP TYPE base_type CASCADE +-- +STMT: DropStmt +== 048 +-- Check usage of typmod with a user-defined type +-- (we have borrowed numeric's typmod functions) + +CREATE TEMP TABLE mytab (foo widget(42,13,7)) +-- +TABLE: name="mytab" schema="" table="mytab" ctx=DDL +STMT: CreateStmt +== 049 +-- should fail +CREATE TEMP TABLE mytab (foo widget(42,13)) +-- +TABLE: name="mytab" schema="" table="mytab" ctx=DDL +STMT: CreateStmt +== 050 +SELECT format_type(atttypid,atttypmod) FROM pg_attribute +WHERE attrelid = 'mytab'::regclass AND attnum > 0 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FUNCTION: name="format_type" function="format_type" schema="" ctx=Call +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +== 051 +-- might as well exercise the widget type while we're here +INSERT INTO mytab VALUES ('(1,2,3)'), ('(-44,5.5,12)') +-- +TABLE: name="mytab" schema="" table="mytab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +TABLE mytab +-- +TABLE: name="mytab" schema="" table="mytab" ctx=Select +STMT: SelectStmt +== 053 +-- and test format_type() a bit more, too +select format_type('varchar'::regtype, 42) +-- +FUNCTION: name="format_type" function="format_type" schema="" ctx=Call +STMT: SelectStmt +== 054 +select format_type('bpchar'::regtype, null) +-- +FUNCTION: name="format_type" function="format_type" schema="" ctx=Call +STMT: SelectStmt +== 055 +-- this behavior difference is intentional +select format_type('bpchar'::regtype, -1) +-- +FUNCTION: name="format_type" function="format_type" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- Test non-error-throwing APIs using widget, which still throws errors +SELECT pg_input_is_valid('(1,2,3)', 'widget') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 057 +SELECT pg_input_is_valid('(1,2)', 'widget') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 058 +-- hard error expected +SELECT pg_input_is_valid('{"(1,2,3)"}', 'widget[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT pg_input_is_valid('{"(1,2)"}', 'widget[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 060 +-- hard error expected +SELECT pg_input_is_valid('("(1,2,3)")', 'mytab') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT pg_input_is_valid('("(1,2)")', 'mytab') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 062 +-- hard error expected + +-- Test creation of an operator over a user-defined type + +CREATE FUNCTION pt_in_widget(point, widget) + RETURNS bool + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 149 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 063 +CREATE OPERATOR <% ( + leftarg = point, + rightarg = widget, + procedure = pt_in_widget, + commutator = >% , + negator = >=% +) +-- +STMT: DefineStmt +== 064 +SELECT point '(1,2)' <% widget '(0,0,3)' AS t, + point '(1,2)' <% widget '(0,0,1)' AS f +-- +STMT: SelectStmt +== 065 +-- exercise city_budget type +CREATE TABLE city ( + name name, + location box, + budget city_budget +) +-- +TABLE: name="city" schema="" table="city" ctx=DDL +STMT: CreateStmt +== 066 +INSERT INTO city VALUES +('Podunk', '(1,2),(3,4)', '100,127,1000'), +('Gotham', '(1000,34),(1100,334)', '123456,127,-1000,6789') +-- +TABLE: name="city" schema="" table="city" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +TABLE city +-- +TABLE: name="city" schema="" table="city" ctx=Select +STMT: SelectStmt +== 068 +|-- +-- Test CREATE/ALTER TYPE using a type that's compatible with varchar, +-- so we can re-use those support functions +|-- +CREATE TYPE myvarchar +-- +STMT: DefineStmt +== 069 +CREATE FUNCTION myvarcharin(cstring, oid, integer) RETURNS myvarchar +LANGUAGE internal IMMUTABLE PARALLEL SAFE STRICT AS 'varcharin' +-- +FUNCTION: name="myvarcharin" function="myvarcharin" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 070 +CREATE FUNCTION myvarcharout(myvarchar) RETURNS cstring +LANGUAGE internal IMMUTABLE PARALLEL SAFE STRICT AS 'varcharout' +-- +FUNCTION: name="myvarcharout" function="myvarcharout" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 071 +CREATE FUNCTION myvarcharsend(myvarchar) RETURNS bytea +LANGUAGE internal STABLE PARALLEL SAFE STRICT AS 'varcharsend' +-- +FUNCTION: name="myvarcharsend" function="myvarcharsend" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 072 +CREATE FUNCTION myvarcharrecv(internal, oid, integer) RETURNS myvarchar +LANGUAGE internal STABLE PARALLEL SAFE STRICT AS 'varcharrecv' +-- +FUNCTION: name="myvarcharrecv" function="myvarcharrecv" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 073 +-- fail, it's still a shell: +ALTER TYPE myvarchar SET (storage = extended) +-- +STMT: AlterTypeStmt +== 074 +CREATE TYPE myvarchar ( + input = myvarcharin, + output = myvarcharout, + alignment = integer, + storage = main +) +-- +STMT: DefineStmt +== 075 +-- want to check updating of a domain over the target type, too +CREATE DOMAIN myvarchardom AS myvarchar +-- +STMT: CreateDomainStmt +== 076 +ALTER TYPE myvarchar SET (storage = plain) +-- +STMT: AlterTypeStmt +== 077 +-- not allowed + +ALTER TYPE myvarchar SET (storage = extended) +-- +STMT: AlterTypeStmt +== 078 +ALTER TYPE myvarchar SET ( + send = myvarcharsend, + receive = myvarcharrecv, + typmod_in = varchartypmodin, + typmod_out = varchartypmodout, + -- these are bogus, but it's safe as long as we don't use the type: + analyze = ts_typanalyze, + subscript = raw_array_subscript_handler +) +-- +STMT: AlterTypeStmt +== 079 +SELECT typinput, typoutput, typreceive, typsend, typmodin, typmodout, + typanalyze, typsubscript, typstorage +FROM pg_type WHERE typname = 'myvarchar' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 080 +SELECT typinput, typoutput, typreceive, typsend, typmodin, typmodout, + typanalyze, typsubscript, typstorage +FROM pg_type WHERE typname = '_myvarchar' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 081 +SELECT typinput, typoutput, typreceive, typsend, typmodin, typmodout, + typanalyze, typsubscript, typstorage +FROM pg_type WHERE typname = 'myvarchardom' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 082 +SELECT typinput, typoutput, typreceive, typsend, typmodin, typmodout, + typanalyze, typsubscript, typstorage +FROM pg_type WHERE typname = '_myvarchardom' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 083 +-- ensure dependencies are straight +DROP FUNCTION myvarcharsend(myvarchar) +-- +FUNCTION: name="myvarcharsend" function="myvarcharsend" schema="" ctx=DDL +STMT: DropStmt +== 084 +-- fail +DROP TYPE myvarchar +-- +STMT: DropStmt +== 085 +-- fail + +DROP TYPE myvarchar CASCADE +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/create_view.metadata.json b/parser/testdata/summary/postgres_regress/create_view.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_view.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/create_view.test b/parser/testdata/summary/postgres_regress/create_view.test new file mode 100644 index 0000000..2824838 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/create_view.test @@ -0,0 +1,2312 @@ +== 001 +|-- +-- CREATE_VIEW +-- Virtual class definitions +-- (this also tests the query rewrite system) +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION interpt_pp(path, path) + RETURNS point + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 238 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +CREATE TABLE real_city ( + pop int4, + cname text, + outline path +) +-- +TABLE: name="real_city" schema="" table="real_city" ctx=DDL +STMT: CreateStmt +== 003 +COPY real_city FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +ANALYZE real_city +-- +TABLE: name="real_city" schema="" table="real_city" ctx=DDL +STMT: VacuumStmt +== 005 +SELECT * + INTO TABLE ramp + FROM ONLY road + WHERE name ~ '.*Ramp' +-- +TABLE: name="road" schema="" table="road" ctx=Select +TABLE: name="ramp" schema="" table="ramp" ctx=DDL +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 006 +CREATE VIEW street AS + SELECT r.name, r.thepath, c.cname AS cname + FROM ONLY road r, real_city c + WHERE c.outline ?# r.thepath +-- +TABLE: name="street" schema="" table="street" ctx=DDL +TABLE: name="road" schema="" table="road" ctx=Select +TABLE: name="real_city" schema="" table="real_city" ctx=Select +ALIAS: "c"="real_city" +ALIAS: "r"="road" +FILTER: schema="" table="c" column="outline" +FILTER: schema="" table="r" column="thepath" +STMT: ViewStmt +STMT: SelectStmt +== 007 +CREATE VIEW iexit AS + SELECT ih.name, ih.thepath, + interpt_pp(ih.thepath, r.thepath) AS exit + FROM ihighway ih, ramp r + WHERE ih.thepath ?# r.thepath +-- +TABLE: name="iexit" schema="" table="iexit" ctx=DDL +TABLE: name="ihighway" schema="" table="ihighway" ctx=Select +TABLE: name="ramp" schema="" table="ramp" ctx=Select +ALIAS: "ih"="ihighway" +ALIAS: "r"="ramp" +FUNCTION: name="interpt_pp" function="interpt_pp" schema="" ctx=Call +FILTER: schema="" table="ih" column="thepath" +FILTER: schema="" table="r" column="thepath" +STMT: ViewStmt +STMT: SelectStmt +== 008 +CREATE VIEW toyemp AS + SELECT name, age, location, 12*salary AS annualsal + FROM emp +-- +TABLE: name="toyemp" schema="" table="toyemp" ctx=DDL +TABLE: name="emp" schema="" table="emp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 009 +-- Test comments +COMMENT ON VIEW noview IS 'no view' +-- +STMT: CommentStmt +== 010 +COMMENT ON VIEW toyemp IS 'is a view' +-- +STMT: CommentStmt +== 011 +COMMENT ON VIEW toyemp IS NULL +-- +STMT: CommentStmt +== 012 +-- These views are left around mainly to exercise special cases in pg_dump. + +CREATE TABLE view_base_table (key int PRIMARY KEY, data varchar(20)) +-- +TABLE: name="view_base_table" schema="" table="view_base_table" ctx=DDL +STMT: CreateStmt +== 013 +CREATE VIEW key_dependent_view AS + SELECT * FROM view_base_table GROUP BY key +-- +TABLE: name="key_dependent_view" schema="" table="key_dependent_view" ctx=DDL +TABLE: name="view_base_table" schema="" table="view_base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 014 +ALTER TABLE view_base_table DROP CONSTRAINT view_base_table_pkey +-- +TABLE: name="view_base_table" schema="" table="view_base_table" ctx=DDL +STMT: AlterTableStmt +== 015 +-- fails + +CREATE VIEW key_dependent_view_no_cols AS + SELECT FROM view_base_table GROUP BY key HAVING length(data) > 0 +-- +TABLE: name="key_dependent_view_no_cols" schema="" table="key_dependent_view_no_cols" ctx=DDL +TABLE: name="view_base_table" schema="" table="view_base_table" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 016 +|-- +-- CREATE OR REPLACE VIEW +|-- + +CREATE TABLE viewtest_tbl (a int, b int, c numeric(10,1), d text COLLATE "C") +-- +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=DDL +STMT: CreateStmt +== 017 +COPY viewtest_tbl FROM stdin +-- +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: CopyStmt +== 018 +CREATE OR REPLACE VIEW viewtest AS + SELECT * FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 019 +CREATE OR REPLACE VIEW viewtest AS + SELECT * FROM viewtest_tbl WHERE a > 10 +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 020 +SELECT * FROM viewtest +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=Select +STMT: SelectStmt +== 021 +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b, c, d FROM viewtest_tbl WHERE a > 5 ORDER BY b DESC +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 022 +SELECT * FROM viewtest +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=Select +STMT: SelectStmt +== 023 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT a FROM viewtest_tbl WHERE a <> 20 +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 024 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT 1, * FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 025 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b::numeric, c, d FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 026 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b, c::numeric(10,2), d FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 027 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b, c, d COLLATE "POSIX" FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 028 +-- should work +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b, c, d, 0 AS e FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 029 +DROP VIEW viewtest +-- +STMT: DropStmt +== 030 +DROP TABLE viewtest_tbl +-- +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=DDL +STMT: DropStmt +== 031 +-- tests for temporary views + +CREATE SCHEMA temp_view_test + CREATE TABLE base_table (a int, id int) + CREATE TABLE base_table2 (a int, id int) +-- +STMT: CreateSchemaStmt +== 032 +SET search_path TO temp_view_test, public +-- +STMT: VariableSetStmt +== 033 +CREATE TEMPORARY TABLE temp_table (a int, id int) +-- +TABLE: name="temp_table" schema="" table="temp_table" ctx=DDL +STMT: CreateStmt +== 034 +-- should be created in temp_view_test schema +CREATE VIEW v1 AS SELECT * FROM base_table +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 035 +-- should be created in temp object schema +CREATE VIEW v1_temp AS SELECT * FROM temp_table +-- +TABLE: name="v1_temp" schema="" table="v1_temp" ctx=DDL +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 036 +-- should be created in temp object schema +CREATE TEMP VIEW v2_temp AS SELECT * FROM base_table +-- +TABLE: name="v2_temp" schema="" table="v2_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 037 +-- should be created in temp_views schema +CREATE VIEW temp_view_test.v2 AS SELECT * FROM base_table +-- +TABLE: name="temp_view_test.v2" schema="temp_view_test" table="v2" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 038 +-- should fail +CREATE VIEW temp_view_test.v3_temp AS SELECT * FROM temp_table +-- +TABLE: name="temp_view_test.v3_temp" schema="temp_view_test" table="v3_temp" ctx=DDL +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 039 +-- should fail +CREATE SCHEMA test_view_schema + CREATE TEMP VIEW testview AS SELECT 1 +-- +STMT: CreateSchemaStmt +== 040 +-- joins: if any of the join relations are temporary, the view +-- should also be temporary + +-- should be non-temp +CREATE VIEW v3 AS + SELECT t1.a AS t1_a, t2.a AS t2_a + FROM base_table t1, base_table2 t2 + WHERE t1.id = t2.id +-- +TABLE: name="v3" schema="" table="v3" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +ALIAS: "t1"="base_table" +ALIAS: "t2"="base_table2" +FILTER: schema="" table="t1" column="id" +FILTER: schema="" table="t2" column="id" +STMT: ViewStmt +STMT: SelectStmt +== 041 +-- should be temp (one join rel is temp) +CREATE VIEW v4_temp AS + SELECT t1.a AS t1_a, t2.a AS t2_a + FROM base_table t1, temp_table t2 + WHERE t1.id = t2.id +-- +TABLE: name="v4_temp" schema="" table="v4_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +ALIAS: "t1"="base_table" +ALIAS: "t2"="temp_table" +FILTER: schema="" table="t1" column="id" +FILTER: schema="" table="t2" column="id" +STMT: ViewStmt +STMT: SelectStmt +== 042 +-- should be temp +CREATE VIEW v5_temp AS + SELECT t1.a AS t1_a, t2.a AS t2_a, t3.a AS t3_a + FROM base_table t1, base_table2 t2, temp_table t3 + WHERE t1.id = t2.id and t2.id = t3.id +-- +TABLE: name="v5_temp" schema="" table="v5_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +ALIAS: "t1"="base_table" +ALIAS: "t2"="base_table2" +ALIAS: "t3"="temp_table" +FILTER: schema="" table="t1" column="id" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t3" column="id" +STMT: ViewStmt +STMT: SelectStmt +== 043 +-- subqueries +CREATE VIEW v4 AS SELECT * FROM base_table WHERE id IN (SELECT id FROM base_table2) +-- +TABLE: name="v4" schema="" table="v4" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +FILTER: schema="" table="" column="id" +STMT: ViewStmt +STMT: SelectStmt +== 044 +CREATE VIEW v5 AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM base_table2) t2 +-- +TABLE: name="v5" schema="" table="v5" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +ALIAS: "t1"="base_table" +STMT: ViewStmt +STMT: SelectStmt +== 045 +CREATE VIEW v6 AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM base_table2) +-- +TABLE: name="v6" schema="" table="v6" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 046 +CREATE VIEW v7 AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM base_table2) +-- +TABLE: name="v7" schema="" table="v7" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 047 +CREATE VIEW v8 AS SELECT * FROM base_table WHERE EXISTS (SELECT 1) +-- +TABLE: name="v8" schema="" table="v8" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 048 +CREATE VIEW v6_temp AS SELECT * FROM base_table WHERE id IN (SELECT id FROM temp_table) +-- +TABLE: name="v6_temp" schema="" table="v6_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +FILTER: schema="" table="" column="id" +STMT: ViewStmt +STMT: SelectStmt +== 049 +CREATE VIEW v7_temp AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM temp_table) t2 +-- +TABLE: name="v7_temp" schema="" table="v7_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +ALIAS: "t1"="base_table" +STMT: ViewStmt +STMT: SelectStmt +== 050 +CREATE VIEW v8_temp AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM temp_table) +-- +TABLE: name="v8_temp" schema="" table="v8_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 051 +CREATE VIEW v9_temp AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM temp_table) +-- +TABLE: name="v9_temp" schema="" table="v9_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 052 +-- a view should also be temporary if it references a temporary view +CREATE VIEW v10_temp AS SELECT * FROM v7_temp +-- +TABLE: name="v10_temp" schema="" table="v10_temp" ctx=DDL +TABLE: name="v7_temp" schema="" table="v7_temp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 053 +CREATE VIEW v11_temp AS SELECT t1.id, t2.a FROM base_table t1, v10_temp t2 +-- +TABLE: name="v11_temp" schema="" table="v11_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="v10_temp" schema="" table="v10_temp" ctx=Select +ALIAS: "t1"="base_table" +ALIAS: "t2"="v10_temp" +STMT: ViewStmt +STMT: SelectStmt +== 054 +CREATE VIEW v12_temp AS SELECT true FROM v11_temp +-- +TABLE: name="v12_temp" schema="" table="v12_temp" ctx=DDL +TABLE: name="v11_temp" schema="" table="v11_temp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 055 +-- a view should also be temporary if it references a temporary sequence +CREATE SEQUENCE seq1 +-- +STMT: CreateSeqStmt +== 056 +CREATE TEMPORARY SEQUENCE seq1_temp +-- +STMT: CreateSeqStmt +== 057 +CREATE VIEW v9 AS SELECT seq1.is_called FROM seq1 +-- +TABLE: name="v9" schema="" table="v9" ctx=DDL +TABLE: name="seq1" schema="" table="seq1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 058 +CREATE VIEW v13_temp AS SELECT seq1_temp.is_called FROM seq1_temp +-- +TABLE: name="v13_temp" schema="" table="v13_temp" ctx=DDL +TABLE: name="seq1_temp" schema="" table="seq1_temp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 059 +SELECT relname FROM pg_class + WHERE relname LIKE 'v_' + AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'temp_view_test') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 060 +SELECT relname FROM pg_class + WHERE relname LIKE 'v%' + AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 061 +CREATE SCHEMA testviewschm2 +-- +STMT: CreateSchemaStmt +== 062 +SET search_path TO testviewschm2, public +-- +STMT: VariableSetStmt +== 063 +CREATE TABLE t1 (num int, name text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 064 +CREATE TABLE t2 (num2 int, value text) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 065 +CREATE TEMP TABLE tt (num2 int, value text) +-- +TABLE: name="tt" schema="" table="tt" ctx=DDL +STMT: CreateStmt +== 066 +CREATE VIEW nontemp1 AS SELECT * FROM t1 CROSS JOIN t2 +-- +TABLE: name="nontemp1" schema="" table="nontemp1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 067 +CREATE VIEW temporal1 AS SELECT * FROM t1 CROSS JOIN tt +-- +TABLE: name="temporal1" schema="" table="temporal1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 068 +CREATE VIEW nontemp2 AS SELECT * FROM t1 INNER JOIN t2 ON t1.num = t2.num2 +-- +TABLE: name="nontemp2" schema="" table="nontemp2" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 069 +CREATE VIEW temporal2 AS SELECT * FROM t1 INNER JOIN tt ON t1.num = tt.num2 +-- +TABLE: name="temporal2" schema="" table="temporal2" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 070 +CREATE VIEW nontemp3 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2 +-- +TABLE: name="nontemp3" schema="" table="nontemp3" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 071 +CREATE VIEW temporal3 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2 +-- +TABLE: name="temporal3" schema="" table="temporal3" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 072 +CREATE VIEW nontemp4 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2 AND t2.value = 'xxx' +-- +TABLE: name="nontemp4" schema="" table="nontemp4" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 073 +CREATE VIEW temporal4 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2 AND tt.value = 'xxx' +-- +TABLE: name="temporal4" schema="" table="temporal4" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 074 +SELECT relname FROM pg_class + WHERE relname LIKE 'nontemp%' + AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'testviewschm2') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 075 +SELECT relname FROM pg_class + WHERE relname LIKE 'temporal%' + AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 076 +CREATE TABLE tbl1 ( a int, b int) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DDL +STMT: CreateStmt +== 077 +CREATE TABLE tbl2 (c int, d int) +-- +TABLE: name="tbl2" schema="" table="tbl2" ctx=DDL +STMT: CreateStmt +== 078 +CREATE TABLE tbl3 (e int, f int) +-- +TABLE: name="tbl3" schema="" table="tbl3" ctx=DDL +STMT: CreateStmt +== 079 +CREATE TABLE tbl4 (g int, h int) +-- +TABLE: name="tbl4" schema="" table="tbl4" ctx=DDL +STMT: CreateStmt +== 080 +CREATE TEMP TABLE tmptbl (i int, j int) +-- +TABLE: name="tmptbl" schema="" table="tmptbl" ctx=DDL +STMT: CreateStmt +== 081 +--Should be in testviewschm2 +CREATE VIEW pubview AS SELECT * FROM tbl1 WHERE tbl1.a +BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2) +AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f) +-- +TABLE: name="pubview" schema="" table="pubview" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl2" schema="" table="tbl2" ctx=Select +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +TABLE: name="tbl4" schema="" table="tbl4" ctx=Select +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +FILTER: schema="" table="tbl1" column="a" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="f" +STMT: ViewStmt +STMT: SelectStmt +== 082 +SELECT count(*) FROM pg_class where relname = 'pubview' +AND relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname = 'testviewschm2') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 083 +--Should be in temp object schema +CREATE VIEW mytempview AS SELECT * FROM tbl1 WHERE tbl1.a +BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2) +AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f) +AND NOT EXISTS (SELECT g FROM tbl4 LEFT JOIN tmptbl ON tbl4.h = tmptbl.j) +-- +TABLE: name="mytempview" schema="" table="mytempview" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl2" schema="" table="tbl2" ctx=Select +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +TABLE: name="tbl4" schema="" table="tbl4" ctx=Select +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +TABLE: name="tbl4" schema="" table="tbl4" ctx=Select +TABLE: name="tmptbl" schema="" table="tmptbl" ctx=Select +FILTER: schema="" table="tbl1" column="a" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="f" +STMT: ViewStmt +STMT: SelectStmt +== 084 +SELECT count(*) FROM pg_class where relname LIKE 'mytempview' +And relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname LIKE 'pg_temp%') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 085 +|-- +-- CREATE VIEW and WITH(...) clause +|-- +CREATE VIEW mysecview1 + AS SELECT * FROM tbl1 WHERE a = 0 +-- +TABLE: name="mysecview1" schema="" table="mysecview1" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 086 +CREATE VIEW mysecview2 WITH (security_barrier=true) + AS SELECT * FROM tbl1 WHERE a > 0 +-- +TABLE: name="mysecview2" schema="" table="mysecview2" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 087 +CREATE VIEW mysecview3 WITH (security_barrier=false) + AS SELECT * FROM tbl1 WHERE a < 0 +-- +TABLE: name="mysecview3" schema="" table="mysecview3" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 088 +CREATE VIEW mysecview4 WITH (security_barrier) + AS SELECT * FROM tbl1 WHERE a <> 0 +-- +TABLE: name="mysecview4" schema="" table="mysecview4" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 089 +CREATE VIEW mysecview5 WITH (security_barrier=100) -- Error + AS SELECT * FROM tbl1 WHERE a > 100 +-- +TABLE: name="mysecview5" schema="" table="mysecview5" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 090 +CREATE VIEW mysecview6 WITH (invalid_option) -- Error + AS SELECT * FROM tbl1 WHERE a < 100 +-- +TABLE: name="mysecview6" schema="" table="mysecview6" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 091 +CREATE VIEW mysecview7 WITH (security_invoker=true) + AS SELECT * FROM tbl1 WHERE a = 100 +-- +TABLE: name="mysecview7" schema="" table="mysecview7" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 092 +CREATE VIEW mysecview8 WITH (security_invoker=false, security_barrier=true) + AS SELECT * FROM tbl1 WHERE a > 100 +-- +TABLE: name="mysecview8" schema="" table="mysecview8" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 093 +CREATE VIEW mysecview9 WITH (security_invoker) + AS SELECT * FROM tbl1 WHERE a < 100 +-- +TABLE: name="mysecview9" schema="" table="mysecview9" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 094 +CREATE VIEW mysecview10 WITH (security_invoker=100) -- Error + AS SELECT * FROM tbl1 WHERE a <> 100 +-- +TABLE: name="mysecview10" schema="" table="mysecview10" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 095 +SELECT relname, relkind, reloptions FROM pg_class + WHERE oid in ('mysecview1'::regclass, 'mysecview2'::regclass, + 'mysecview3'::regclass, 'mysecview4'::regclass, + 'mysecview7'::regclass, 'mysecview8'::regclass, + 'mysecview9'::regclass) + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 096 +CREATE OR REPLACE VIEW mysecview1 + AS SELECT * FROM tbl1 WHERE a = 256 +-- +TABLE: name="mysecview1" schema="" table="mysecview1" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 097 +CREATE OR REPLACE VIEW mysecview2 + AS SELECT * FROM tbl1 WHERE a > 256 +-- +TABLE: name="mysecview2" schema="" table="mysecview2" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 098 +CREATE OR REPLACE VIEW mysecview3 WITH (security_barrier=true) + AS SELECT * FROM tbl1 WHERE a < 256 +-- +TABLE: name="mysecview3" schema="" table="mysecview3" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 099 +CREATE OR REPLACE VIEW mysecview4 WITH (security_barrier=false) + AS SELECT * FROM tbl1 WHERE a <> 256 +-- +TABLE: name="mysecview4" schema="" table="mysecview4" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 100 +CREATE OR REPLACE VIEW mysecview7 + AS SELECT * FROM tbl1 WHERE a > 256 +-- +TABLE: name="mysecview7" schema="" table="mysecview7" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 101 +CREATE OR REPLACE VIEW mysecview8 WITH (security_invoker=true) + AS SELECT * FROM tbl1 WHERE a < 256 +-- +TABLE: name="mysecview8" schema="" table="mysecview8" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 102 +CREATE OR REPLACE VIEW mysecview9 WITH (security_invoker=false, security_barrier=true) + AS SELECT * FROM tbl1 WHERE a <> 256 +-- +TABLE: name="mysecview9" schema="" table="mysecview9" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 103 +SELECT relname, relkind, reloptions FROM pg_class + WHERE oid in ('mysecview1'::regclass, 'mysecview2'::regclass, + 'mysecview3'::regclass, 'mysecview4'::regclass, + 'mysecview7'::regclass, 'mysecview8'::regclass, + 'mysecview9'::regclass) + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 104 +-- Check that unknown literals are converted to "text" in CREATE VIEW, +-- so that we don't end up with unknown-type columns. + +CREATE VIEW unspecified_types AS + SELECT 42 as i, 42.5 as num, 'foo' as u, 'foo'::unknown as u2, null as n +-- +TABLE: name="unspecified_types" schema="" table="unspecified_types" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 105 +SELECT * FROM unspecified_types +-- +TABLE: name="unspecified_types" schema="" table="unspecified_types" ctx=Select +STMT: SelectStmt +== 106 +-- This test checks that proper typmods are assigned in a multi-row VALUES + +CREATE VIEW tt1 AS + SELECT * FROM ( + VALUES + ('abc'::varchar(3), '0123456789', 42, 'abcd'::varchar(4)), + ('0123456789', 'abc'::varchar(3), 42.12, 'abc'::varchar(4)) + ) vv(a,b,c,d) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 107 +SELECT * FROM tt1 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=Select +STMT: SelectStmt +== 108 +SELECT a::varchar(3) FROM tt1 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=Select +STMT: SelectStmt +== 109 +DROP VIEW tt1 +-- +STMT: DropStmt +== 110 +-- Test view decompilation in the face of relation renaming conflicts + +CREATE TABLE tt1 (f1 int, f2 int, f3 text) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: CreateStmt +== 111 +CREATE TABLE tx1 (x1 int, x2 int, x3 text) +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: CreateStmt +== 112 +CREATE TABLE temp_view_test.tt1 (y1 int, f2 int, f3 text) +-- +TABLE: name="temp_view_test.tt1" schema="temp_view_test" table="tt1" ctx=DDL +STMT: CreateStmt +== 113 +CREATE VIEW aliased_view_1 AS + select * from tt1 + where exists (select 1 from tx1 where tt1.f1 = tx1.x1) +-- +TABLE: name="aliased_view_1" schema="" table="aliased_view_1" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=Select +TABLE: name="tx1" schema="" table="tx1" ctx=Select +FILTER: schema="" table="tt1" column="f1" +FILTER: schema="" table="tx1" column="x1" +STMT: ViewStmt +STMT: SelectStmt +== 114 +CREATE VIEW aliased_view_2 AS + select * from tt1 a1 + where exists (select 1 from tx1 where a1.f1 = tx1.x1) +-- +TABLE: name="aliased_view_2" schema="" table="aliased_view_2" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=Select +TABLE: name="tx1" schema="" table="tx1" ctx=Select +ALIAS: "a1"="tt1" +FILTER: schema="" table="a1" column="f1" +FILTER: schema="" table="tx1" column="x1" +STMT: ViewStmt +STMT: SelectStmt +== 115 +CREATE VIEW aliased_view_3 AS + select * from tt1 + where exists (select 1 from tx1 a2 where tt1.f1 = a2.x1) +-- +TABLE: name="aliased_view_3" schema="" table="aliased_view_3" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=Select +TABLE: name="tx1" schema="" table="tx1" ctx=Select +ALIAS: "a2"="tx1" +FILTER: schema="" table="tt1" column="f1" +FILTER: schema="" table="a2" column="x1" +STMT: ViewStmt +STMT: SelectStmt +== 116 +CREATE VIEW aliased_view_4 AS + select * from temp_view_test.tt1 + where exists (select 1 from tt1 where temp_view_test.tt1.y1 = tt1.f1) +-- +TABLE: name="aliased_view_4" schema="" table="aliased_view_4" ctx=DDL +TABLE: name="temp_view_test.tt1" schema="temp_view_test" table="tt1" ctx=Select +TABLE: name="tt1" schema="" table="tt1" ctx=Select +FILTER: schema="temp_view_test" table="tt1" column="y1" +FILTER: schema="" table="tt1" column="f1" +STMT: ViewStmt +STMT: SelectStmt +== 117 +ALTER TABLE tx1 RENAME TO a1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +TABLE: name="a1" schema="" table="a1" ctx=DDL +STMT: RenameStmt +== 118 +ALTER TABLE tt1 RENAME TO a2 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +TABLE: name="a2" schema="" table="a2" ctx=DDL +STMT: RenameStmt +== 119 +ALTER TABLE a1 RENAME TO tt1 +-- +TABLE: name="a1" schema="" table="a1" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: RenameStmt +== 120 +ALTER TABLE a2 RENAME TO tx1 +-- +TABLE: name="a2" schema="" table="a2" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: RenameStmt +== 121 +ALTER TABLE tx1 SET SCHEMA temp_view_test +-- +STMT: AlterObjectSchemaStmt +== 122 +ALTER TABLE temp_view_test.tt1 RENAME TO tmp1 +-- +TABLE: name="temp_view_test.tt1" schema="temp_view_test" table="tt1" ctx=DDL +TABLE: name="temp_view_test.tmp1" schema="temp_view_test" table="tmp1" ctx=DDL +STMT: RenameStmt +== 123 +ALTER TABLE temp_view_test.tmp1 SET SCHEMA testviewschm2 +-- +STMT: AlterObjectSchemaStmt +== 124 +ALTER TABLE tmp1 RENAME TO tx1 +-- +TABLE: name="tmp1" schema="" table="tmp1" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: RenameStmt +== 125 +-- Test correct deparsing of ORDER BY when there is an output name conflict + +create view aliased_order_by as +select x1 as x2, x2 as x1, x3 from tt1 + order by x2 +-- +TABLE: name="aliased_order_by" schema="" table="aliased_order_by" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 126 +-- this is interpreted per SQL92, so really ordering by x1 + + +alter view aliased_order_by rename column x1 to x0 +-- +STMT: RenameStmt +== 127 +alter view aliased_order_by rename column x3 to x1 +-- +STMT: RenameStmt +== 128 +-- Test aliasing of joins + +create view view_of_joins as +select * from + (select * from (tbl1 cross join tbl2) same) ss, + (tbl3 cross join tbl4) same +-- +TABLE: name="view_of_joins" schema="" table="view_of_joins" ctx=DDL +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +TABLE: name="tbl4" schema="" table="tbl4" ctx=Select +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl2" schema="" table="tbl2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 129 +create table tbl1a (a int, c int) +-- +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=DDL +STMT: CreateStmt +== 130 +create view view_of_joins_2a as select * from tbl1 join tbl1a using (a) +-- +TABLE: name="view_of_joins_2a" schema="" table="view_of_joins_2a" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 131 +create view view_of_joins_2b as select * from tbl1 join tbl1a using (a) as x +-- +TABLE: name="view_of_joins_2b" schema="" table="view_of_joins_2b" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 132 +create view view_of_joins_2c as select * from (tbl1 join tbl1a using (a)) as y +-- +TABLE: name="view_of_joins_2c" schema="" table="view_of_joins_2c" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 133 +create view view_of_joins_2d as select * from (tbl1 join tbl1a using (a) as x) as y +-- +TABLE: name="view_of_joins_2d" schema="" table="view_of_joins_2d" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 134 +select pg_get_viewdef('view_of_joins_2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 135 +select pg_get_viewdef('view_of_joins_2b', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 136 +select pg_get_viewdef('view_of_joins_2c', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 137 +select pg_get_viewdef('view_of_joins_2d', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 138 +-- Test view decompilation in the face of column addition/deletion/renaming + +create table tt2 (a int, b int, c int) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: CreateStmt +== 139 +create table tt3 (ax int8, b int2, c numeric) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: CreateStmt +== 140 +create table tt4 (ay int, b int, q int) +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: CreateStmt +== 141 +create view v1 as select * from tt2 natural join tt3 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 142 +create view v1a as select * from (tt2 natural join tt3) j +-- +TABLE: name="v1a" schema="" table="v1a" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 143 +create view v2 as select * from tt2 join tt3 using (b,c) join tt4 using (b) +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt4" schema="" table="tt4" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 144 +create view v2a as select * from (tt2 join tt3 using (b,c) join tt4 using (b)) j +-- +TABLE: name="v2a" schema="" table="v2a" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt4" schema="" table="tt4" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 145 +create view v3 as select * from tt2 join tt3 using (b,c) full join tt4 using (b) +-- +TABLE: name="v3" schema="" table="v3" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt4" schema="" table="tt4" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 146 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 147 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 148 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 149 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 150 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 151 +alter table tt2 add column d int +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: AlterTableStmt +== 152 +alter table tt2 add column e int +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: AlterTableStmt +== 153 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 154 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 155 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 156 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 157 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 158 +alter table tt3 rename c to d +-- +STMT: RenameStmt +== 159 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 160 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 161 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 162 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 163 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 164 +alter table tt3 add column c int +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: AlterTableStmt +== 165 +alter table tt3 add column e int +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: AlterTableStmt +== 166 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 167 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 168 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 169 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 170 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 171 +alter table tt2 drop column d +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: AlterTableStmt +== 172 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 173 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 174 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 175 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 176 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 177 +create table tt5 (a int, b int) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: CreateStmt +== 178 +create table tt6 (c int, d int) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DDL +STMT: CreateStmt +== 179 +create view vv1 as select * from (tt5 cross join tt6) j(aa,bb,cc,dd) +-- +TABLE: name="vv1" schema="" table="vv1" ctx=DDL +TABLE: name="tt5" schema="" table="tt5" ctx=Select +TABLE: name="tt6" schema="" table="tt6" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 180 +select pg_get_viewdef('vv1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 181 +alter table tt5 add column c int +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: AlterTableStmt +== 182 +select pg_get_viewdef('vv1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 183 +alter table tt5 add column cc int +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: AlterTableStmt +== 184 +select pg_get_viewdef('vv1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 185 +alter table tt5 drop column c +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: AlterTableStmt +== 186 +select pg_get_viewdef('vv1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 187 +create view v4 as select * from v1 +-- +TABLE: name="v4" schema="" table="v4" ctx=DDL +TABLE: name="v1" schema="" table="v1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 188 +alter view v1 rename column a to x +-- +STMT: RenameStmt +== 189 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 190 +select pg_get_viewdef('v4', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 191 +-- Unnamed FULL JOIN USING is lots of fun too + +create table tt7 (x int, xx int, y int) +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: CreateStmt +== 192 +alter table tt7 drop column xx +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +== 193 +create table tt8 (x int, z int) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: CreateStmt +== 194 +create view vv2 as +select * from (values(1,2,3,4,5)) v(a,b,c,d,e) +union all +select * from tt7 full join tt8 using (x), tt8 tt8x +-- +TABLE: name="vv2" schema="" table="vv2" ctx=DDL +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +ALIAS: "tt8x"="tt8" +STMT: ViewStmt +STMT: SelectStmt +== 195 +select pg_get_viewdef('vv2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 196 +create view vv3 as +select * from (values(1,2,3,4,5,6)) v(a,b,c,x,e,f) +union all +select * from + tt7 full join tt8 using (x), + tt7 tt7x full join tt8 tt8x using (x) +-- +TABLE: name="vv3" schema="" table="vv3" ctx=DDL +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +ALIAS: "tt7x"="tt7" +ALIAS: "tt8x"="tt8" +STMT: ViewStmt +STMT: SelectStmt +== 197 +select pg_get_viewdef('vv3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 198 +create view vv4 as +select * from (values(1,2,3,4,5,6,7)) v(a,b,c,x,e,f,g) +union all +select * from + tt7 full join tt8 using (x), + tt7 tt7x full join tt8 tt8x using (x) full join tt8 tt8y using (x) +-- +TABLE: name="vv4" schema="" table="vv4" ctx=DDL +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +ALIAS: "tt7x"="tt7" +ALIAS: "tt8x"="tt8" +ALIAS: "tt8y"="tt8" +STMT: ViewStmt +STMT: SelectStmt +== 199 +select pg_get_viewdef('vv4', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 200 +alter table tt7 add column zz int +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +== 201 +alter table tt7 add column z int +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +== 202 +alter table tt7 drop column zz +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +== 203 +alter table tt8 add column z2 int +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +== 204 +select pg_get_viewdef('vv2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 205 +select pg_get_viewdef('vv3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 206 +select pg_get_viewdef('vv4', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 207 +-- Implicit coercions in a JOIN USING create issues similar to FULL JOIN + +create table tt7a (x date, xx int, y int) +-- +TABLE: name="tt7a" schema="" table="tt7a" ctx=DDL +STMT: CreateStmt +== 208 +alter table tt7a drop column xx +-- +TABLE: name="tt7a" schema="" table="tt7a" ctx=DDL +STMT: AlterTableStmt +== 209 +create table tt8a (x timestamptz, z int) +-- +TABLE: name="tt8a" schema="" table="tt8a" ctx=DDL +STMT: CreateStmt +== 210 +create view vv2a as +select * from (values(now(),2,3,now(),5)) v(a,b,c,d,e) +union all +select * from tt7a left join tt8a using (x), tt8a tt8ax +-- +TABLE: name="vv2a" schema="" table="vv2a" ctx=DDL +TABLE: name="tt7a" schema="" table="tt7a" ctx=Select +TABLE: name="tt8a" schema="" table="tt8a" ctx=Select +TABLE: name="tt8a" schema="" table="tt8a" ctx=Select +ALIAS: "tt8ax"="tt8a" +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 211 +select pg_get_viewdef('vv2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 212 +|-- +-- Also check dropping a column that existed when the view was made +|-- + +create table tt9 (x int, xx int, y int) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: CreateStmt +== 213 +create table tt10 (x int, z int) +-- +TABLE: name="tt10" schema="" table="tt10" ctx=DDL +STMT: CreateStmt +== 214 +create view vv5 as select x,y,z from tt9 join tt10 using(x) +-- +TABLE: name="vv5" schema="" table="vv5" ctx=DDL +TABLE: name="tt9" schema="" table="tt9" ctx=Select +TABLE: name="tt10" schema="" table="tt10" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 215 +select pg_get_viewdef('vv5', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 216 +alter table tt9 drop column xx +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +== 217 +select pg_get_viewdef('vv5', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 218 +|-- +-- Another corner case is that we might add a column to a table below a +-- JOIN USING, and thereby make the USING column name ambiguous +|-- + +create table tt11 (x int, y int) +-- +TABLE: name="tt11" schema="" table="tt11" ctx=DDL +STMT: CreateStmt +== 219 +create table tt12 (x int, z int) +-- +TABLE: name="tt12" schema="" table="tt12" ctx=DDL +STMT: CreateStmt +== 220 +create table tt13 (z int, q int) +-- +TABLE: name="tt13" schema="" table="tt13" ctx=DDL +STMT: CreateStmt +== 221 +create view vv6 as select x,y,z,q from + (tt11 join tt12 using(x)) join tt13 using(z) +-- +TABLE: name="vv6" schema="" table="vv6" ctx=DDL +TABLE: name="tt11" schema="" table="tt11" ctx=Select +TABLE: name="tt12" schema="" table="tt12" ctx=Select +TABLE: name="tt13" schema="" table="tt13" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 222 +select pg_get_viewdef('vv6', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 223 +alter table tt11 add column z int +-- +TABLE: name="tt11" schema="" table="tt11" ctx=DDL +STMT: AlterTableStmt +== 224 +select pg_get_viewdef('vv6', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 225 +|-- +-- Check cases involving dropped/altered columns in a function's rowtype result +|-- + +create table tt14t (f1 text, f2 text, f3 text, f4 text) +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: CreateStmt +== 226 +insert into tt14t values('foo', 'bar', 'baz', '42') +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 227 +alter table tt14t drop column f2 +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +== 228 +create function tt14f() returns setof tt14t as +$$ +declare + rec1 record; +begin + for rec1 in select * from tt14t + loop + return next rec1; + end loop; +end; +$$ +language plpgsql +-- +FUNCTION: name="tt14f" function="tt14f" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 229 +create view tt14v as select t.* from tt14f() t +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=DDL +FUNCTION: name="tt14f" function="tt14f" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 230 +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 231 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +== 232 +alter table tt14t drop column f3 +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +== 233 +-- fail, view has explicit reference to f3 + +-- We used to have a bug that would allow the above to succeed, posing +-- hazards for later execution of the view. Check that the internal +-- defenses for those hazards haven't bit-rotted, in case some other +-- bug with similar symptoms emerges. +begin +-- +STMT: TransactionStmt +== 234 +-- destroy the dependency entry that prevents the DROP: +delete from pg_depend where + objid = (select oid from pg_rewrite + where ev_class = 'tt14v'::regclass and rulename = '_RETURN') + and refobjsubid = 3 +returning pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as ref, + deptype +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=DML +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="rulename" +STMT: DeleteStmt +STMT: SelectStmt +== 235 +-- this will now succeed: +alter table tt14t drop column f3 +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +== 236 +-- column f3 is still in the view, sort of ... +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 237 +-- ... and you can even EXPLAIN it ... +explain (verbose, costs off) select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 238 +-- but it will fail at execution +select f1, f4 from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +== 239 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +== 240 +rollback +-- +STMT: TransactionStmt +== 241 +-- likewise, altering a referenced column's type is prohibited ... +alter table tt14t alter column f4 type integer using f4::integer +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +== 242 +-- fail + +-- ... but some bug might let it happen, so check defenses +begin +-- +STMT: TransactionStmt +== 243 +-- destroy the dependency entry that prevents the ALTER: +delete from pg_depend where + objid = (select oid from pg_rewrite + where ev_class = 'tt14v'::regclass and rulename = '_RETURN') + and refobjsubid = 4 +returning pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as ref, + deptype +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=DML +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="rulename" +STMT: DeleteStmt +STMT: SelectStmt +== 244 +-- this will now succeed: +alter table tt14t alter column f4 type integer using f4::integer +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +== 245 +-- f4 is still in the view ... +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 246 +-- but will fail at execution +select f1, f3 from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +== 247 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +== 248 +rollback +-- +STMT: TransactionStmt +== 249 +drop view tt14v +-- +STMT: DropStmt +== 250 +create view tt14v as select t.f1, t.f4 from tt14f() t +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=DDL +FUNCTION: name="tt14f" function="tt14f" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 251 +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 252 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +== 253 +alter table tt14t drop column f3 +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +== 254 +-- ok + +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 255 +explain (verbose, costs off) select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 256 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +== 257 +-- check display of whole-row variables in some corner cases + +create type nestedcomposite as (x int8_tbl) +-- +STMT: CompositeTypeStmt +== 258 +create view tt15v as select row(i)::nestedcomposite from int8_tbl i +-- +TABLE: name="tt15v" schema="" table="tt15v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: ViewStmt +STMT: SelectStmt +== 259 +select * from tt15v +-- +TABLE: name="tt15v" schema="" table="tt15v" ctx=Select +STMT: SelectStmt +== 260 +select pg_get_viewdef('tt15v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 261 +select row(i.*::int8_tbl)::nestedcomposite from int8_tbl i +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: SelectStmt +== 262 +create view tt16v as select * from int8_tbl i, lateral(values(i)) ss +-- +TABLE: name="tt16v" schema="" table="tt16v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: ViewStmt +STMT: SelectStmt +== 263 +select * from tt16v +-- +TABLE: name="tt16v" schema="" table="tt16v" ctx=Select +STMT: SelectStmt +== 264 +select pg_get_viewdef('tt16v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 265 +select * from int8_tbl i, lateral(values(i.*::int8_tbl)) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: SelectStmt +== 266 +create view tt17v as select * from int8_tbl i where i in (values(i)) +-- +TABLE: name="tt17v" schema="" table="tt17v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +FILTER: schema="" table="" column="i" +STMT: ViewStmt +STMT: SelectStmt +== 267 +select * from tt17v +-- +TABLE: name="tt17v" schema="" table="tt17v" ctx=Select +STMT: SelectStmt +== 268 +select pg_get_viewdef('tt17v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 269 +select * from int8_tbl i where i.* in (values(i.*::int8_tbl)) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: SelectStmt +== 270 +create table tt15v_log(o tt15v, n tt15v, incr bool) +-- +TABLE: name="tt15v_log" schema="" table="tt15v_log" ctx=DDL +STMT: CreateStmt +== 271 +create rule updlog as on update to tt15v do also + insert into tt15v_log values(old, new, row(old,old) < row(new,new)) +-- +TABLE: name="tt15v" schema="" table="tt15v" ctx=DDL +STMT: RuleStmt +== 272 +-- check unique-ification of overlength names + +create view tt18v as + select * from int8_tbl xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy + union all + select * from int8_tbl xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz +-- +TABLE: name="tt18v" schema="" table="tt18v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"="int8_tbl" +STMT: ViewStmt +STMT: SelectStmt +== 273 +select pg_get_viewdef('tt18v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 274 +explain (costs off) select * from tt18v +-- +TABLE: name="tt18v" schema="" table="tt18v" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 275 +-- check display of ScalarArrayOp with a sub-select + +select 'foo'::text = any(array['abc','def','foo']::text[]) +-- +STMT: SelectStmt +== 276 +select 'foo'::text = any((select array['abc','def','foo']::text[])) +-- +STMT: SelectStmt +== 277 +-- fail +select 'foo'::text = any((select array['abc','def','foo']::text[])::text[]) +-- +STMT: SelectStmt +== 278 +create view tt19v as +select 'foo'::text = any(array['abc','def','foo']::text[]) c1, + 'foo'::text = any((select array['abc','def','foo']::text[])::text[]) c2 +-- +TABLE: name="tt19v" schema="" table="tt19v" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 279 +select pg_get_viewdef('tt19v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 280 +-- check display of assorted RTE_FUNCTION expressions + +create view tt20v as +select * from + coalesce(1,2) as c, + collation for ('x'::text) col, + current_date as d, + localtimestamp(3) as t, + cast(1+2 as int4) as i4, + cast(1+2 as int8) as i8 +-- +TABLE: name="tt20v" schema="" table="tt20v" ctx=DDL +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 281 +select pg_get_viewdef('tt20v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 282 +-- reverse-listing of various special function syntaxes required by SQL + +create view tt201v as +select + ('2022-12-01'::date + '1 day'::interval) at time zone 'UTC' as atz, + extract(day from now()) as extr, + (now(), '1 day'::interval) overlaps + (current_timestamp(2), '1 day'::interval) as o, + 'foo' is normalized isn, + 'foo' is nfkc normalized isnn, + normalize('foo') as n, + normalize('foo', nfkd) as nfkd, + overlay('foo' placing 'bar' from 2) as ovl, + overlay('foo' placing 'bar' from 2 for 3) as ovl2, + position('foo' in 'foobar') as p, + substring('foo' from 2 for 3) as s, + substring('foo' similar 'f' escape '#') as ss, + substring('foo' from 'oo') as ssf, -- historically-permitted abuse + trim(' ' from ' foo ') as bt, + trim(leading ' ' from ' foo ') as lt, + trim(trailing ' foo ') as rt, + trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea) as btb, + trim(leading E'\\000'::bytea from E'\\000Tom\\000'::bytea) as ltb, + trim(trailing E'\\000'::bytea from E'\\000Tom\\000'::bytea) as rtb, + CURRENT_DATE as cd, + (select * from CURRENT_DATE) as cd2, + CURRENT_TIME as ct, + (select * from CURRENT_TIME) as ct2, + CURRENT_TIME (1) as ct3, + (select * from CURRENT_TIME (1)) as ct4, + CURRENT_TIMESTAMP as ct5, + (select * from CURRENT_TIMESTAMP) as ct6, + CURRENT_TIMESTAMP (1) as ct7, + (select * from CURRENT_TIMESTAMP (1)) as ct8, + LOCALTIME as lt1, + (select * from LOCALTIME) as lt2, + LOCALTIME (1) as lt3, + (select * from LOCALTIME (1)) as lt4, + LOCALTIMESTAMP as lt5, + (select * from LOCALTIMESTAMP) as lt6, + LOCALTIMESTAMP (1) as lt7, + (select * from LOCALTIMESTAMP (1)) as lt8, + CURRENT_CATALOG as ca, + (select * from CURRENT_CATALOG) as ca2, + CURRENT_ROLE as cr, + (select * from CURRENT_ROLE) as cr2, + CURRENT_SCHEMA as cs, + (select * from CURRENT_SCHEMA) as cs2, + CURRENT_USER as cu, + (select * from CURRENT_USER) as cu2, + USER as us, + (select * from USER) as us2, + SESSION_USER seu, + (select * from SESSION_USER) as seu2, + SYSTEM_USER as su, + (select * from SYSTEM_USER) as su2 +-- +TABLE: name="tt201v" schema="" table="tt201v" ctx=DDL +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.btrim" function="btrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.ltrim" function="ltrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.rtrim" function="rtrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.btrim" function="btrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.ltrim" function="ltrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.rtrim" function="rtrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.system_user" function="system_user" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.system_user" function="system_user" schema="pg_catalog" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 283 +select pg_get_viewdef('tt201v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 284 +-- corner cases with empty join conditions + +create view tt21v as +select * from tt5 natural inner join tt6 +-- +TABLE: name="tt21v" schema="" table="tt21v" ctx=DDL +TABLE: name="tt5" schema="" table="tt5" ctx=Select +TABLE: name="tt6" schema="" table="tt6" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 285 +select pg_get_viewdef('tt21v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 286 +create view tt22v as +select * from tt5 natural left join tt6 +-- +TABLE: name="tt22v" schema="" table="tt22v" ctx=DDL +TABLE: name="tt5" schema="" table="tt5" ctx=Select +TABLE: name="tt6" schema="" table="tt6" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 287 +select pg_get_viewdef('tt22v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 288 +-- check handling of views with immediately-renamed columns + +create view tt23v (col_a, col_b) as +select q1 as other_name1, q2 as other_name2 from int8_tbl +union +select 42, 43 +-- +TABLE: name="tt23v" schema="" table="tt23v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 289 +select pg_get_viewdef('tt23v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 290 +select pg_get_ruledef(oid, true) from pg_rewrite + where ev_class = 'tt23v'::regclass and ev_type = '1' +-- +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_get_ruledef" function="pg_get_ruledef" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="ev_type" +STMT: SelectStmt +== 291 +-- test extraction of FieldSelect field names (get_name_for_var_field) + +create view tt24v as +with cte as materialized (select r from (values(1,2),(3,4)) r) +select (r).column2 as col_a, (rr).column2 as col_b from + cte join (select rr from (values(1,7),(3,8)) rr limit 2) ss + on (r).column1 = (rr).column1 +-- +TABLE: name="tt24v" schema="" table="tt24v" ctx=DDL +CTE: "cte" +STMT: ViewStmt +STMT: SelectStmt +== 292 +select pg_get_viewdef('tt24v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 293 +create view tt25v as +with cte as materialized (select pg_get_keywords() k) +select (k).word from cte +-- +TABLE: name="tt25v" schema="" table="tt25v" ctx=DDL +CTE: "cte" +FUNCTION: name="pg_get_keywords" function="pg_get_keywords" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 294 +select pg_get_viewdef('tt25v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 295 +-- also check cases seen only in EXPLAIN +explain (verbose, costs off) +select * from tt24v +-- +TABLE: name="tt24v" schema="" table="tt24v" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 296 +explain (verbose, costs off) +select (r).column2 from (select r from (values(1,2),(3,4)) r limit 1) ss +-- +STMT: ExplainStmt +STMT: SelectStmt +== 297 +-- test pretty-print parenthesization rules, and SubLink deparsing + +create view tt26v as +select x + y + z as c1, + (x * y) + z as c2, + x + (y * z) as c3, + (x + y) * z as c4, + x * (y + z) as c5, + x + (y + z) as c6, + x + (y # z) as c7, + (x > y) AND (y > z OR x > z) as c8, + (x > y) OR (y > z AND NOT (x > z)) as c9, + (x,y) <> ALL (values(1,2),(3,4)) as c10, + (x,y) <= ANY (values(1,2),(3,4)) as c11 +from (values(1,2,3)) v(x,y,z) +-- +TABLE: name="tt26v" schema="" table="tt26v" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 298 +select pg_get_viewdef('tt26v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 299 +-- test restriction on non-system view expansion. +create table tt27v_tbl (a int) +-- +TABLE: name="tt27v_tbl" schema="" table="tt27v_tbl" ctx=DDL +STMT: CreateStmt +== 300 +create view tt27v as select a from tt27v_tbl +-- +TABLE: name="tt27v" schema="" table="tt27v" ctx=DDL +TABLE: name="tt27v_tbl" schema="" table="tt27v_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 301 +set restrict_nonsystem_relation_kind to 'view' +-- +STMT: VariableSetStmt +== 302 +select a from tt27v where a > 0 +-- +TABLE: name="tt27v" schema="" table="tt27v" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 303 +-- Error +insert into tt27v values (1) +-- +TABLE: name="tt27v" schema="" table="tt27v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 304 +-- Error +select viewname from pg_views where viewname = 'tt27v' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +== 305 +-- Ok to access a system view. +reset restrict_nonsystem_relation_kind +-- +STMT: VariableSetStmt +== 306 +-- clean up all the random objects we made above +DROP SCHEMA temp_view_test CASCADE +-- +STMT: DropStmt +== 307 +DROP SCHEMA testviewschm2 CASCADE +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/database.metadata.json b/parser/testdata/summary/postgres_regress/database.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/database.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/database.test b/parser/testdata/summary/postgres_regress/database.test new file mode 100644 index 0000000..8049198 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/database.test @@ -0,0 +1,72 @@ +== 001 +CREATE DATABASE regression_tbd + ENCODING utf8 LC_COLLATE "C" LC_CTYPE "C" TEMPLATE template0 +-- +STMT: CreatedbStmt +== 002 +ALTER DATABASE regression_tbd RENAME TO regression_utf8 +-- +STMT: RenameStmt +== 003 +ALTER DATABASE regression_utf8 SET TABLESPACE regress_tblspace +-- +STMT: AlterDatabaseStmt +== 004 +ALTER DATABASE regression_utf8 RESET TABLESPACE +-- +STMT: AlterDatabaseSetStmt +== 005 +ALTER DATABASE regression_utf8 CONNECTION_LIMIT 123 +-- +STMT: AlterDatabaseStmt +== 006 +-- Test PgDatabaseToastTable. Doing this with GRANT would be slow. +BEGIN +-- +STMT: TransactionStmt +== 007 +UPDATE pg_database +SET datacl = array_fill(makeaclitem(10, 10, 'USAGE', false), ARRAY[5e5::int]) +WHERE datname = 'regression_utf8' +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=DML +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +FUNCTION: name="makeaclitem" function="makeaclitem" schema="" ctx=Call +STMT: UpdateStmt +== 008 +-- load catcache entry, if nothing else does +ALTER DATABASE regression_utf8 RESET TABLESPACE +-- +STMT: AlterDatabaseSetStmt +== 009 +ROLLBACK +-- +STMT: TransactionStmt +== 010 +CREATE ROLE regress_datdba_before +-- +STMT: CreateRoleStmt +== 011 +CREATE ROLE regress_datdba_after +-- +STMT: CreateRoleStmt +== 012 +ALTER DATABASE regression_utf8 OWNER TO regress_datdba_before +-- +STMT: AlterOwnerStmt +== 013 +REASSIGN OWNED BY regress_datdba_before TO regress_datdba_after +-- +STMT: ReassignOwnedStmt +== 014 +DROP DATABASE regression_utf8 +-- +STMT: DropdbStmt +== 015 +DROP ROLE regress_datdba_before +-- +STMT: DropRoleStmt +== 016 +DROP ROLE regress_datdba_after +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/date.metadata.json b/parser/testdata/summary/postgres_regress/date.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/date.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/date.test b/parser/testdata/summary/postgres_regress/date.test new file mode 100644 index 0000000..6829170 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/date.test @@ -0,0 +1,1362 @@ +== 001 +|-- +-- DATE +|-- + +CREATE TABLE DATE_TBL (f1 date) +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO DATE_TBL VALUES ('1957-04-09') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO DATE_TBL VALUES ('1957-06-13') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO DATE_TBL VALUES ('1996-02-28') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO DATE_TBL VALUES ('1996-02-29') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO DATE_TBL VALUES ('1996-03-01') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO DATE_TBL VALUES ('1996-03-02') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO DATE_TBL VALUES ('1997-02-28') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO DATE_TBL VALUES ('1997-02-29') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO DATE_TBL VALUES ('1997-03-01') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO DATE_TBL VALUES ('1997-03-02') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO DATE_TBL VALUES ('2000-04-01') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO DATE_TBL VALUES ('2000-04-02') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO DATE_TBL VALUES ('2000-04-03') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO DATE_TBL VALUES ('2038-04-08') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO DATE_TBL VALUES ('2039-04-09') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO DATE_TBL VALUES ('2040-04-10') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO DATE_TBL VALUES ('2040-04-10 BC') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +SELECT f1 FROM DATE_TBL +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +STMT: SelectStmt +== 020 +SELECT f1 FROM DATE_TBL WHERE f1 < '2000-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 021 +SELECT f1 FROM DATE_TBL + WHERE f1 BETWEEN '2000-01-01' AND '2001-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 022 +|-- +-- Check all the documented input formats +|-- +SET datestyle TO iso +-- +STMT: VariableSetStmt +== 023 +-- display results in ISO + +SET datestyle TO ymd +-- +STMT: VariableSetStmt +== 024 +SELECT date 'January 8, 1999' +-- +STMT: SelectStmt +== 025 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +== 026 +SELECT date '1999-01-18' +-- +STMT: SelectStmt +== 027 +SELECT date '1/8/1999' +-- +STMT: SelectStmt +== 028 +SELECT date '1/18/1999' +-- +STMT: SelectStmt +== 029 +SELECT date '18/1/1999' +-- +STMT: SelectStmt +== 030 +SELECT date '01/02/03' +-- +STMT: SelectStmt +== 031 +SELECT date '19990108' +-- +STMT: SelectStmt +== 032 +SELECT date '990108' +-- +STMT: SelectStmt +== 033 +SELECT date '1999.008' +-- +STMT: SelectStmt +== 034 +SELECT date 'J2451187' +-- +STMT: SelectStmt +== 035 +SELECT date 'January 8, 99 BC' +-- +STMT: SelectStmt +== 036 +SELECT date '99-Jan-08' +-- +STMT: SelectStmt +== 037 +SELECT date '1999-Jan-08' +-- +STMT: SelectStmt +== 038 +SELECT date '08-Jan-99' +-- +STMT: SelectStmt +== 039 +SELECT date '08-Jan-1999' +-- +STMT: SelectStmt +== 040 +SELECT date 'Jan-08-99' +-- +STMT: SelectStmt +== 041 +SELECT date 'Jan-08-1999' +-- +STMT: SelectStmt +== 042 +SELECT date '99-08-Jan' +-- +STMT: SelectStmt +== 043 +SELECT date '1999-08-Jan' +-- +STMT: SelectStmt +== 044 +SELECT date '99 Jan 08' +-- +STMT: SelectStmt +== 045 +SELECT date '1999 Jan 08' +-- +STMT: SelectStmt +== 046 +SELECT date '08 Jan 99' +-- +STMT: SelectStmt +== 047 +SELECT date '08 Jan 1999' +-- +STMT: SelectStmt +== 048 +SELECT date 'Jan 08 99' +-- +STMT: SelectStmt +== 049 +SELECT date 'Jan 08 1999' +-- +STMT: SelectStmt +== 050 +SELECT date '99 08 Jan' +-- +STMT: SelectStmt +== 051 +SELECT date '1999 08 Jan' +-- +STMT: SelectStmt +== 052 +SELECT date '99-01-08' +-- +STMT: SelectStmt +== 053 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +== 054 +SELECT date '08-01-99' +-- +STMT: SelectStmt +== 055 +SELECT date '08-01-1999' +-- +STMT: SelectStmt +== 056 +SELECT date '01-08-99' +-- +STMT: SelectStmt +== 057 +SELECT date '01-08-1999' +-- +STMT: SelectStmt +== 058 +SELECT date '99-08-01' +-- +STMT: SelectStmt +== 059 +SELECT date '1999-08-01' +-- +STMT: SelectStmt +== 060 +SELECT date '99 01 08' +-- +STMT: SelectStmt +== 061 +SELECT date '1999 01 08' +-- +STMT: SelectStmt +== 062 +SELECT date '08 01 99' +-- +STMT: SelectStmt +== 063 +SELECT date '08 01 1999' +-- +STMT: SelectStmt +== 064 +SELECT date '01 08 99' +-- +STMT: SelectStmt +== 065 +SELECT date '01 08 1999' +-- +STMT: SelectStmt +== 066 +SELECT date '99 08 01' +-- +STMT: SelectStmt +== 067 +SELECT date '1999 08 01' +-- +STMT: SelectStmt +== 068 +SET datestyle TO dmy +-- +STMT: VariableSetStmt +== 069 +SELECT date 'January 8, 1999' +-- +STMT: SelectStmt +== 070 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +== 071 +SELECT date '1999-01-18' +-- +STMT: SelectStmt +== 072 +SELECT date '1/8/1999' +-- +STMT: SelectStmt +== 073 +SELECT date '1/18/1999' +-- +STMT: SelectStmt +== 074 +SELECT date '18/1/1999' +-- +STMT: SelectStmt +== 075 +SELECT date '01/02/03' +-- +STMT: SelectStmt +== 076 +SELECT date '19990108' +-- +STMT: SelectStmt +== 077 +SELECT date '990108' +-- +STMT: SelectStmt +== 078 +SELECT date '1999.008' +-- +STMT: SelectStmt +== 079 +SELECT date 'J2451187' +-- +STMT: SelectStmt +== 080 +SELECT date 'January 8, 99 BC' +-- +STMT: SelectStmt +== 081 +SELECT date '99-Jan-08' +-- +STMT: SelectStmt +== 082 +SELECT date '1999-Jan-08' +-- +STMT: SelectStmt +== 083 +SELECT date '08-Jan-99' +-- +STMT: SelectStmt +== 084 +SELECT date '08-Jan-1999' +-- +STMT: SelectStmt +== 085 +SELECT date 'Jan-08-99' +-- +STMT: SelectStmt +== 086 +SELECT date 'Jan-08-1999' +-- +STMT: SelectStmt +== 087 +SELECT date '99-08-Jan' +-- +STMT: SelectStmt +== 088 +SELECT date '1999-08-Jan' +-- +STMT: SelectStmt +== 089 +SELECT date '99 Jan 08' +-- +STMT: SelectStmt +== 090 +SELECT date '1999 Jan 08' +-- +STMT: SelectStmt +== 091 +SELECT date '08 Jan 99' +-- +STMT: SelectStmt +== 092 +SELECT date '08 Jan 1999' +-- +STMT: SelectStmt +== 093 +SELECT date 'Jan 08 99' +-- +STMT: SelectStmt +== 094 +SELECT date 'Jan 08 1999' +-- +STMT: SelectStmt +== 095 +SELECT date '99 08 Jan' +-- +STMT: SelectStmt +== 096 +SELECT date '1999 08 Jan' +-- +STMT: SelectStmt +== 097 +SELECT date '99-01-08' +-- +STMT: SelectStmt +== 098 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +== 099 +SELECT date '08-01-99' +-- +STMT: SelectStmt +== 100 +SELECT date '08-01-1999' +-- +STMT: SelectStmt +== 101 +SELECT date '01-08-99' +-- +STMT: SelectStmt +== 102 +SELECT date '01-08-1999' +-- +STMT: SelectStmt +== 103 +SELECT date '99-08-01' +-- +STMT: SelectStmt +== 104 +SELECT date '1999-08-01' +-- +STMT: SelectStmt +== 105 +SELECT date '99 01 08' +-- +STMT: SelectStmt +== 106 +SELECT date '1999 01 08' +-- +STMT: SelectStmt +== 107 +SELECT date '08 01 99' +-- +STMT: SelectStmt +== 108 +SELECT date '08 01 1999' +-- +STMT: SelectStmt +== 109 +SELECT date '01 08 99' +-- +STMT: SelectStmt +== 110 +SELECT date '01 08 1999' +-- +STMT: SelectStmt +== 111 +SELECT date '99 08 01' +-- +STMT: SelectStmt +== 112 +SELECT date '1999 08 01' +-- +STMT: SelectStmt +== 113 +SET datestyle TO mdy +-- +STMT: VariableSetStmt +== 114 +SELECT date 'January 8, 1999' +-- +STMT: SelectStmt +== 115 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +== 116 +SELECT date '1999-01-18' +-- +STMT: SelectStmt +== 117 +SELECT date '1/8/1999' +-- +STMT: SelectStmt +== 118 +SELECT date '1/18/1999' +-- +STMT: SelectStmt +== 119 +SELECT date '18/1/1999' +-- +STMT: SelectStmt +== 120 +SELECT date '01/02/03' +-- +STMT: SelectStmt +== 121 +SELECT date '19990108' +-- +STMT: SelectStmt +== 122 +SELECT date '990108' +-- +STMT: SelectStmt +== 123 +SELECT date '1999.008' +-- +STMT: SelectStmt +== 124 +SELECT date 'J2451187' +-- +STMT: SelectStmt +== 125 +SELECT date 'January 8, 99 BC' +-- +STMT: SelectStmt +== 126 +SELECT date '99-Jan-08' +-- +STMT: SelectStmt +== 127 +SELECT date '1999-Jan-08' +-- +STMT: SelectStmt +== 128 +SELECT date '08-Jan-99' +-- +STMT: SelectStmt +== 129 +SELECT date '08-Jan-1999' +-- +STMT: SelectStmt +== 130 +SELECT date 'Jan-08-99' +-- +STMT: SelectStmt +== 131 +SELECT date 'Jan-08-1999' +-- +STMT: SelectStmt +== 132 +SELECT date '99-08-Jan' +-- +STMT: SelectStmt +== 133 +SELECT date '1999-08-Jan' +-- +STMT: SelectStmt +== 134 +SELECT date '99 Jan 08' +-- +STMT: SelectStmt +== 135 +SELECT date '1999 Jan 08' +-- +STMT: SelectStmt +== 136 +SELECT date '08 Jan 99' +-- +STMT: SelectStmt +== 137 +SELECT date '08 Jan 1999' +-- +STMT: SelectStmt +== 138 +SELECT date 'Jan 08 99' +-- +STMT: SelectStmt +== 139 +SELECT date 'Jan 08 1999' +-- +STMT: SelectStmt +== 140 +SELECT date '99 08 Jan' +-- +STMT: SelectStmt +== 141 +SELECT date '1999 08 Jan' +-- +STMT: SelectStmt +== 142 +SELECT date '99-01-08' +-- +STMT: SelectStmt +== 143 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +== 144 +SELECT date '08-01-99' +-- +STMT: SelectStmt +== 145 +SELECT date '08-01-1999' +-- +STMT: SelectStmt +== 146 +SELECT date '01-08-99' +-- +STMT: SelectStmt +== 147 +SELECT date '01-08-1999' +-- +STMT: SelectStmt +== 148 +SELECT date '99-08-01' +-- +STMT: SelectStmt +== 149 +SELECT date '1999-08-01' +-- +STMT: SelectStmt +== 150 +SELECT date '99 01 08' +-- +STMT: SelectStmt +== 151 +SELECT date '1999 01 08' +-- +STMT: SelectStmt +== 152 +SELECT date '08 01 99' +-- +STMT: SelectStmt +== 153 +SELECT date '08 01 1999' +-- +STMT: SelectStmt +== 154 +SELECT date '01 08 99' +-- +STMT: SelectStmt +== 155 +SELECT date '01 08 1999' +-- +STMT: SelectStmt +== 156 +SELECT date '99 08 01' +-- +STMT: SelectStmt +== 157 +SELECT date '1999 08 01' +-- +STMT: SelectStmt +== 158 +-- Check upper and lower limits of date range +SELECT date '4714-11-24 BC' +-- +STMT: SelectStmt +== 159 +SELECT date '4714-11-23 BC' +-- +STMT: SelectStmt +== 160 +-- out of range +SELECT date '5874897-12-31' +-- +STMT: SelectStmt +== 161 +SELECT date '5874898-01-01' +-- +STMT: SelectStmt +== 162 +-- out of range + +-- Test non-error-throwing API +SELECT pg_input_is_valid('now', 'date') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 163 +SELECT pg_input_is_valid('garbage', 'date') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 164 +SELECT pg_input_is_valid('6874898-01-01', 'date') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 165 +SELECT * FROM pg_input_error_info('garbage', 'date') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 166 +SELECT * FROM pg_input_error_info('6874898-01-01', 'date') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 167 +RESET datestyle +-- +STMT: VariableSetStmt +== 168 +|-- +-- Simple math +-- Leave most of it for the horology tests +|-- + +SELECT f1 - date '2000-01-01' AS "Days From 2K" FROM DATE_TBL +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +STMT: SelectStmt +== 169 +SELECT f1 - date 'epoch' AS "Days From Epoch" FROM DATE_TBL +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +STMT: SelectStmt +== 170 +SELECT date 'yesterday' - date 'today' AS "One day" +-- +STMT: SelectStmt +== 171 +SELECT date 'today' - date 'tomorrow' AS "One day" +-- +STMT: SelectStmt +== 172 +SELECT date 'yesterday' - date 'tomorrow' AS "Two days" +-- +STMT: SelectStmt +== 173 +SELECT date 'tomorrow' - date 'today' AS "One day" +-- +STMT: SelectStmt +== 174 +SELECT date 'today' - date 'yesterday' AS "One day" +-- +STMT: SelectStmt +== 175 +SELECT date 'tomorrow' - date 'yesterday' AS "Two days" +-- +STMT: SelectStmt +== 176 +|-- +-- test extract! +|-- +SELECT f1 as "date", + date_part('year', f1) AS year, + date_part('month', f1) AS month, + date_part('day', f1) AS day, + date_part('quarter', f1) AS quarter, + date_part('decade', f1) AS decade, + date_part('century', f1) AS century, + date_part('millennium', f1) AS millennium, + date_part('isoyear', f1) AS isoyear, + date_part('week', f1) AS week, + date_part('dow', f1) AS dow, + date_part('isodow', f1) AS isodow, + date_part('doy', f1) AS doy, + date_part('julian', f1) AS julian, + date_part('epoch', f1) AS epoch + FROM date_tbl +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 177 +|-- +-- epoch +|-- +SELECT EXTRACT(EPOCH FROM DATE '1970-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 178 +-- 0 +|-- +-- century +|-- +SELECT EXTRACT(CENTURY FROM DATE '0101-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 179 +-- -2 +SELECT EXTRACT(CENTURY FROM DATE '0100-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 180 +-- -1 +SELECT EXTRACT(CENTURY FROM DATE '0001-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 181 +-- -1 +SELECT EXTRACT(CENTURY FROM DATE '0001-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 182 +-- 1 +SELECT EXTRACT(CENTURY FROM DATE '0001-01-01 AD') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 183 +-- 1 +SELECT EXTRACT(CENTURY FROM DATE '1900-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 184 +-- 19 +SELECT EXTRACT(CENTURY FROM DATE '1901-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 185 +-- 20 +SELECT EXTRACT(CENTURY FROM DATE '2000-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 186 +-- 20 +SELECT EXTRACT(CENTURY FROM DATE '2001-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 187 +-- 21 +SELECT EXTRACT(CENTURY FROM CURRENT_DATE)>=21 AS True +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 188 +-- true +|-- +-- millennium +|-- +SELECT EXTRACT(MILLENNIUM FROM DATE '0001-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 189 +-- -1 +SELECT EXTRACT(MILLENNIUM FROM DATE '0001-01-01 AD') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 190 +-- 1 +SELECT EXTRACT(MILLENNIUM FROM DATE '1000-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 191 +-- 1 +SELECT EXTRACT(MILLENNIUM FROM DATE '1001-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 192 +-- 2 +SELECT EXTRACT(MILLENNIUM FROM DATE '2000-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 193 +-- 2 +SELECT EXTRACT(MILLENNIUM FROM DATE '2001-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 194 +-- 3 +-- next test to be fixed on the turn of the next millennium;-) +SELECT EXTRACT(MILLENNIUM FROM CURRENT_DATE) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 195 +-- 3 +|-- +-- decade +|-- +SELECT EXTRACT(DECADE FROM DATE '1994-12-25') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 196 +-- 199 +SELECT EXTRACT(DECADE FROM DATE '0010-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 197 +-- 1 +SELECT EXTRACT(DECADE FROM DATE '0009-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 198 +-- 0 +SELECT EXTRACT(DECADE FROM DATE '0001-01-01 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 199 +-- 0 +SELECT EXTRACT(DECADE FROM DATE '0002-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 200 +-- -1 +SELECT EXTRACT(DECADE FROM DATE '0011-01-01 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 201 +-- -1 +SELECT EXTRACT(DECADE FROM DATE '0012-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 202 +-- -2 +|-- +-- all possible fields +|-- +SELECT EXTRACT(MICROSECONDS FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 203 +SELECT EXTRACT(MILLISECONDS FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 204 +SELECT EXTRACT(SECOND FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 205 +SELECT EXTRACT(MINUTE FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 206 +SELECT EXTRACT(HOUR FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 207 +SELECT EXTRACT(DAY FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 208 +SELECT EXTRACT(MONTH FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 209 +SELECT EXTRACT(YEAR FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 210 +SELECT EXTRACT(YEAR FROM DATE '2020-08-11 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 211 +SELECT EXTRACT(DECADE FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 212 +SELECT EXTRACT(CENTURY FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 213 +SELECT EXTRACT(MILLENNIUM FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 214 +SELECT EXTRACT(ISOYEAR FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 215 +SELECT EXTRACT(ISOYEAR FROM DATE '2020-08-11 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 216 +SELECT EXTRACT(QUARTER FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 217 +SELECT EXTRACT(WEEK FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 218 +SELECT EXTRACT(DOW FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 219 +SELECT EXTRACT(DOW FROM DATE '2020-08-16') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 220 +SELECT EXTRACT(ISODOW FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 221 +SELECT EXTRACT(ISODOW FROM DATE '2020-08-16') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 222 +SELECT EXTRACT(DOY FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 223 +SELECT EXTRACT(TIMEZONE FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 224 +SELECT EXTRACT(TIMEZONE_M FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 225 +SELECT EXTRACT(TIMEZONE_H FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 226 +SELECT EXTRACT(EPOCH FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 227 +SELECT EXTRACT(JULIAN FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 228 +|-- +-- test trunc function! +|-- +SELECT DATE_TRUNC('MILLENNIUM', TIMESTAMP '1970-03-20 04:30:00.00000') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 229 +-- 1001 +SELECT DATE_TRUNC('MILLENNIUM', DATE '1970-03-20') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 230 +-- 1001-01-01 +SELECT DATE_TRUNC('CENTURY', TIMESTAMP '1970-03-20 04:30:00.00000') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 231 +-- 1901 +SELECT DATE_TRUNC('CENTURY', DATE '1970-03-20') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 232 +-- 1901 +SELECT DATE_TRUNC('CENTURY', DATE '2004-08-10') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 233 +-- 2001-01-01 +SELECT DATE_TRUNC('CENTURY', DATE '0002-02-04') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 234 +-- 0001-01-01 +SELECT DATE_TRUNC('CENTURY', DATE '0055-08-10 BC') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 235 +-- 0100-01-01 BC +SELECT DATE_TRUNC('DECADE', DATE '1993-12-25') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 236 +-- 1990-01-01 +SELECT DATE_TRUNC('DECADE', DATE '0004-12-25') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 237 +-- 0001-01-01 BC +SELECT DATE_TRUNC('DECADE', DATE '0002-12-31 BC') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 238 +-- 0011-01-01 BC +|-- +-- test infinity +|-- +select 'infinity'::date, '-infinity'::date +-- +STMT: SelectStmt +== 239 +select 'infinity'::date > 'today'::date as t +-- +STMT: SelectStmt +== 240 +select '-infinity'::date < 'today'::date as t +-- +STMT: SelectStmt +== 241 +select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'::date) +-- +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +STMT: SelectStmt +== 242 +select 'infinity'::date = '+infinity'::date as t +-- +STMT: SelectStmt +== 243 +|-- +-- oscillating fields from non-finite date: +|-- +SELECT EXTRACT(DAY FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 244 +-- NULL +SELECT EXTRACT(DAY FROM DATE '-infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 245 +-- NULL +-- all supported fields +SELECT EXTRACT(DAY FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 246 +-- NULL +SELECT EXTRACT(MONTH FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 247 +-- NULL +SELECT EXTRACT(QUARTER FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 248 +-- NULL +SELECT EXTRACT(WEEK FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 249 +-- NULL +SELECT EXTRACT(DOW FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 250 +-- NULL +SELECT EXTRACT(ISODOW FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 251 +-- NULL +SELECT EXTRACT(DOY FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 252 +-- NULL +|-- +-- monotonic fields from non-finite date: +|-- +SELECT EXTRACT(EPOCH FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 253 +-- Infinity +SELECT EXTRACT(EPOCH FROM DATE '-infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 254 +-- -Infinity +-- all supported fields +SELECT EXTRACT(YEAR FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 255 +-- Infinity +SELECT EXTRACT(DECADE FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 256 +-- Infinity +SELECT EXTRACT(CENTURY FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 257 +-- Infinity +SELECT EXTRACT(MILLENNIUM FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 258 +-- Infinity +SELECT EXTRACT(JULIAN FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 259 +-- Infinity +SELECT EXTRACT(ISOYEAR FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 260 +-- Infinity +SELECT EXTRACT(EPOCH FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 261 +-- Infinity +|-- +-- wrong fields from non-finite date: +|-- +SELECT EXTRACT(MICROSEC FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 262 +-- error + +-- test constructors +select make_date(2013, 7, 15) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +== 263 +select make_date(-44, 3, 15) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +== 264 +select make_time(8, 20, 0.0) +-- +FUNCTION: name="make_time" function="make_time" schema="" ctx=Call +STMT: SelectStmt +== 265 +-- should fail +select make_date(0, 7, 15) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +== 266 +select make_date(2013, 2, 30) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +== 267 +select make_date(2013, 13, 1) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +== 268 +select make_date(2013, 11, -1) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +== 269 +select make_time(10, 55, 100.1) +-- +FUNCTION: name="make_time" function="make_time" schema="" ctx=Call +STMT: SelectStmt +== 270 +select make_time(24, 0, 2.1) +-- +FUNCTION: name="make_time" function="make_time" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/dbsize.metadata.json b/parser/testdata/summary/postgres_regress/dbsize.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/dbsize.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/dbsize.test b/parser/testdata/summary/postgres_regress/dbsize.test new file mode 100644 index 0000000..9dfd064 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/dbsize.test @@ -0,0 +1,167 @@ +== 001 +SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM + (VALUES (10::bigint), (1000::bigint), (1000000::bigint), + (1000000000::bigint), (1000000000000::bigint), + (1000000000000000::bigint)) x(size) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +== 002 +SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM + (VALUES (10::numeric), (1000::numeric), (1000000::numeric), + (1000000000::numeric), (1000000000000::numeric), + (1000000000000000::numeric), + (10.5::numeric), (1000.5::numeric), (1000000.5::numeric), + (1000000000.5::numeric), (1000000000000.5::numeric), + (1000000000000000.5::numeric)) x(size) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +== 003 +-- test where units change up +SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM + (VALUES (10239::bigint), (10240::bigint), + (10485247::bigint), (10485248::bigint), + (10736893951::bigint), (10736893952::bigint), + (10994579406847::bigint), (10994579406848::bigint), + (11258449312612351::bigint), (11258449312612352::bigint)) x(size) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM + (VALUES (10239::numeric), (10240::numeric), + (10485247::numeric), (10485248::numeric), + (10736893951::numeric), (10736893952::numeric), + (10994579406847::numeric), (10994579406848::numeric), + (11258449312612351::numeric), (11258449312612352::numeric), + (11528652096115048447::numeric), (11528652096115048448::numeric)) x(size) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +== 005 +-- Ensure we get the expected results when passing the extremities of bigint +SELECT pg_size_pretty('-9223372036854775808'::bigint), + pg_size_pretty('9223372036854775807'::bigint) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +== 006 +-- pg_size_bytes() tests +SELECT size, pg_size_bytes(size) FROM + (VALUES ('1'), ('123bytes'), ('256 B'), ('1kB'), ('1MB'), (' 1 GB'), ('1.5 GB '), + ('1TB'), ('3000 TB'), ('1e6 MB'), ('99 PB')) x(size) +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- case-insensitive units are supported +SELECT size, pg_size_bytes(size) FROM + (VALUES ('1'), ('123bYteS'), ('1kb'), ('1mb'), (' 1 Gb'), ('1.5 gB '), + ('1tb'), ('3000 tb'), ('1e6 mb'), ('99 pb')) x(size) +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- negative numbers are supported +SELECT size, pg_size_bytes(size) FROM + (VALUES ('-1'), ('-123bytes'), ('-1kb'), ('-1mb'), (' -1 Gb'), ('-1.5 gB '), + ('-1tb'), ('-3000 TB'), ('-10e-1 MB'), ('-99 PB')) x(size) +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- different cases with allowed points +SELECT size, pg_size_bytes(size) FROM + (VALUES ('-1.'), ('-1.kb'), ('-1. kb'), ('-0. gb'), + ('-.1'), ('-.1kb'), ('-.1 kb'), ('-.0 gb')) x(size) +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 010 +-- invalid inputs +SELECT pg_size_bytes('1 AB') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT pg_size_bytes('1 AB A') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT pg_size_bytes('1 AB A ') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT pg_size_bytes('9223372036854775807.9') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT pg_size_bytes('1e100') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT pg_size_bytes('1e1000000000000000000') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT pg_size_bytes('1 byte') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- the singular "byte" is not supported +SELECT pg_size_bytes('') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT pg_size_bytes('kb') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT pg_size_bytes('..') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT pg_size_bytes('-.') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT pg_size_bytes('-.kb') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT pg_size_bytes('-. kb') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT pg_size_bytes('.+912') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT pg_size_bytes('+912+ kB') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT pg_size_bytes('++123 kB') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/delete.metadata.json b/parser/testdata/summary/postgres_regress/delete.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/delete.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/delete.test b/parser/testdata/summary/postgres_regress/delete.test new file mode 100644 index 0000000..922c437 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/delete.test @@ -0,0 +1,66 @@ +== 001 +CREATE TABLE delete_test ( + id SERIAL PRIMARY KEY, + a INT, + b text +) +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO delete_test (a) VALUES (10) +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO delete_test (a, b) VALUES (50, repeat('x', 10000)) +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO delete_test (a) VALUES (100) +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +-- allow an alias to be specified for DELETE's target table +DELETE FROM delete_test AS dt WHERE dt.a > 75 +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +ALIAS: "dt"="delete_test" +STMT: DeleteStmt +== 006 +-- if an alias is specified, don't allow the original table name +-- to be referenced +DELETE FROM delete_test dt WHERE delete_test.a > 25 +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +ALIAS: "dt"="delete_test" +STMT: DeleteStmt +== 007 +SELECT id, a, char_length(b) FROM delete_test +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- delete a row with a TOASTed value +DELETE FROM delete_test WHERE a > 25 +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +STMT: DeleteStmt +== 009 +SELECT id, a, char_length(b) FROM delete_test +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +== 010 +DROP TABLE delete_test +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/dependency.metadata.json b/parser/testdata/summary/postgres_regress/dependency.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/dependency.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/dependency.test b/parser/testdata/summary/postgres_regress/dependency.test new file mode 100644 index 0000000..a99ed80 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/dependency.test @@ -0,0 +1,302 @@ +== 001 +|-- +-- DEPENDENCIES +|-- + +CREATE USER regress_dep_user +-- +STMT: CreateRoleStmt +== 002 +CREATE USER regress_dep_user2 +-- +STMT: CreateRoleStmt +== 003 +CREATE USER regress_dep_user3 +-- +STMT: CreateRoleStmt +== 004 +CREATE GROUP regress_dep_group +-- +STMT: CreateRoleStmt +== 005 +CREATE TABLE deptest (f1 serial primary key, f2 text) +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: CreateStmt +== 006 +GRANT SELECT ON TABLE deptest TO GROUP regress_dep_group +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +== 007 +GRANT ALL ON TABLE deptest TO regress_dep_user, regress_dep_user2 +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +== 008 +-- can't drop neither because they have privileges somewhere +DROP USER regress_dep_user +-- +STMT: DropRoleStmt +== 009 +DROP GROUP regress_dep_group +-- +STMT: DropRoleStmt +== 010 +-- if we revoke the privileges we can drop the group +REVOKE SELECT ON deptest FROM GROUP regress_dep_group +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +== 011 +DROP GROUP regress_dep_group +-- +STMT: DropRoleStmt +== 012 +-- can't drop the user if we revoke the privileges partially +REVOKE SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, MAINTAIN ON deptest FROM regress_dep_user +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +== 013 +DROP USER regress_dep_user +-- +STMT: DropRoleStmt +== 014 +-- now we are OK to drop him +REVOKE TRIGGER ON deptest FROM regress_dep_user +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +== 015 +DROP USER regress_dep_user +-- +STMT: DropRoleStmt +== 016 +-- we are OK too if we drop the privileges all at once +REVOKE ALL ON deptest FROM regress_dep_user2 +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +== 017 +DROP USER regress_dep_user2 +-- +STMT: DropRoleStmt +== 018 +-- can't drop the owner of an object +-- the error message detail here would include a pg_toast_nnn name that +-- is not constant, so suppress it +ALTER TABLE deptest OWNER TO regress_dep_user3 +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: AlterTableStmt +== 019 +DROP USER regress_dep_user3 +-- +STMT: DropRoleStmt +== 020 +-- if we drop the object, we can drop the user too +DROP TABLE deptest +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: DropStmt +== 021 +DROP USER regress_dep_user3 +-- +STMT: DropRoleStmt +== 022 +-- Test DROP OWNED +CREATE USER regress_dep_user0 +-- +STMT: CreateRoleStmt +== 023 +CREATE USER regress_dep_user1 +-- +STMT: CreateRoleStmt +== 024 +CREATE USER regress_dep_user2 +-- +STMT: CreateRoleStmt +== 025 +SET SESSION AUTHORIZATION regress_dep_user0 +-- +STMT: VariableSetStmt +== 026 +-- permission denied +DROP OWNED BY regress_dep_user1 +-- +STMT: DropOwnedStmt +== 027 +DROP OWNED BY regress_dep_user0, regress_dep_user2 +-- +STMT: DropOwnedStmt +== 028 +REASSIGN OWNED BY regress_dep_user0 TO regress_dep_user1 +-- +STMT: ReassignOwnedStmt +== 029 +REASSIGN OWNED BY regress_dep_user1 TO regress_dep_user0 +-- +STMT: ReassignOwnedStmt +== 030 +-- this one is allowed +DROP OWNED BY regress_dep_user0 +-- +STMT: DropOwnedStmt +== 031 +CREATE TABLE deptest1 (f1 int unique) +-- +TABLE: name="deptest1" schema="" table="deptest1" ctx=DDL +STMT: CreateStmt +== 032 +GRANT ALL ON deptest1 TO regress_dep_user1 WITH GRANT OPTION +-- +TABLE: name="deptest1" schema="" table="deptest1" ctx=DDL +STMT: GrantStmt +== 033 +SET SESSION AUTHORIZATION regress_dep_user1 +-- +STMT: VariableSetStmt +== 034 +CREATE TABLE deptest (a serial primary key, b text) +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: CreateStmt +== 035 +GRANT ALL ON deptest1 TO regress_dep_user2 +-- +TABLE: name="deptest1" schema="" table="deptest1" ctx=DDL +STMT: GrantStmt +== 036 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 037 +DROP OWNED BY regress_dep_user1 +-- +STMT: DropOwnedStmt +== 038 +-- all grants revoked +-- table was dropped + +-- Test REASSIGN OWNED +GRANT ALL ON deptest1 TO regress_dep_user1 +-- +TABLE: name="deptest1" schema="" table="deptest1" ctx=DDL +STMT: GrantStmt +== 039 +GRANT CREATE ON DATABASE regression TO regress_dep_user1 +-- +STMT: GrantStmt +== 040 +SET SESSION AUTHORIZATION regress_dep_user1 +-- +STMT: VariableSetStmt +== 041 +CREATE SCHEMA deptest +-- +STMT: CreateSchemaStmt +== 042 +CREATE TABLE deptest (a serial primary key, b text) +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: CreateStmt +== 043 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_dep_user1 IN SCHEMA deptest + GRANT ALL ON TABLES TO regress_dep_user2 +-- +STMT: AlterDefaultPrivilegesStmt +== 044 +CREATE FUNCTION deptest_func() RETURNS void LANGUAGE plpgsql + AS $$ BEGIN END; $$ +-- +FUNCTION: name="deptest_func" function="deptest_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 045 +CREATE TYPE deptest_enum AS ENUM ('red') +-- +STMT: CreateEnumStmt +== 046 +CREATE TYPE deptest_range AS RANGE (SUBTYPE = int4) +-- +STMT: CreateRangeStmt +== 047 +CREATE TABLE deptest2 (f1 int) +-- +TABLE: name="deptest2" schema="" table="deptest2" ctx=DDL +STMT: CreateStmt +== 048 +-- make a serial column the hard way +CREATE SEQUENCE ss1 +-- +STMT: CreateSeqStmt +== 049 +ALTER TABLE deptest2 ALTER f1 SET DEFAULT nextval('ss1') +-- +TABLE: name="deptest2" schema="" table="deptest2" ctx=DDL +STMT: AlterTableStmt +== 050 +ALTER SEQUENCE ss1 OWNED BY deptest2.f1 +-- +STMT: AlterSeqStmt +== 051 +-- When reassigning ownership of a composite type, its pg_class entry +-- should match +CREATE TYPE deptest_t AS (a int) +-- +STMT: CompositeTypeStmt +== 052 +SELECT typowner = relowner +FROM pg_type JOIN pg_class c ON typrelid = c.oid WHERE typname = 'deptest_t' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 053 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 054 +REASSIGN OWNED BY regress_dep_user1 TO regress_dep_user2 +-- +STMT: ReassignOwnedStmt +== 055 +SELECT typowner = relowner +FROM pg_type JOIN pg_class c ON typrelid = c.oid WHERE typname = 'deptest_t' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 056 +-- doesn't work: grant still exists +DROP USER regress_dep_user1 +-- +STMT: DropRoleStmt +== 057 +DROP OWNED BY regress_dep_user1 +-- +STMT: DropOwnedStmt +== 058 +DROP USER regress_dep_user1 +-- +STMT: DropRoleStmt +== 059 +DROP USER regress_dep_user2 +-- +STMT: DropRoleStmt +== 060 +DROP OWNED BY regress_dep_user2, regress_dep_user0 +-- +STMT: DropOwnedStmt +== 061 +DROP USER regress_dep_user2 +-- +STMT: DropRoleStmt +== 062 +DROP USER regress_dep_user0 +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/domain.metadata.json b/parser/testdata/summary/postgres_regress/domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/domain.test b/parser/testdata/summary/postgres_regress/domain.test new file mode 100644 index 0000000..88c24c5 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/domain.test @@ -0,0 +1,1789 @@ +== 001 +|-- +-- Test domains. +|-- + +-- Test Comment / Drop +create domain domaindroptest int4 +-- +STMT: CreateDomainStmt +== 002 +comment on domain domaindroptest is 'About to drop this..' +-- +STMT: CommentStmt +== 003 +create domain dependenttypetest domaindroptest +-- +STMT: CreateDomainStmt +== 004 +-- fail because of dependent type +drop domain domaindroptest +-- +STMT: DropStmt +== 005 +drop domain domaindroptest cascade +-- +STMT: DropStmt +== 006 +-- this should fail because already gone +drop domain domaindroptest cascade +-- +STMT: DropStmt +== 007 +-- Test domain input. + +-- Note: the point of checking both INSERT and COPY FROM is that INSERT +-- exercises CoerceToDomain while COPY exercises domain_in. + +create domain domainvarchar varchar(5) +-- +STMT: CreateDomainStmt +== 008 +create domain domainnumeric numeric(8,2) +-- +STMT: CreateDomainStmt +== 009 +create domain domainint4 int4 +-- +STMT: CreateDomainStmt +== 010 +create domain domaintext text +-- +STMT: CreateDomainStmt +== 011 +-- Test explicit coercions --- these should succeed (and truncate) +SELECT cast('123456' as domainvarchar) +-- +STMT: SelectStmt +== 012 +SELECT cast('12345' as domainvarchar) +-- +STMT: SelectStmt +== 013 +-- Test tables using domains +create table basictest + ( testint4 domainint4 + , testtext domaintext + , testvarchar domainvarchar + , testnumeric domainnumeric + ) +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DDL +STMT: CreateStmt +== 014 +INSERT INTO basictest values ('88', 'haha', 'short', '123.12') +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +-- Good +INSERT INTO basictest values ('88', 'haha', 'short text', '123.12') +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +-- Bad varchar +INSERT INTO basictest values ('88', 'haha', 'short', '123.1212') +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +-- Truncate numeric + +-- Test copy +COPY basictest (testvarchar) FROM stdin +-- +TABLE: name="basictest" schema="" table="basictest" ctx=Select +STMT: CopyStmt +== 018 +-- fail +notsoshorttext + +COPY basictest (testvarchar) FROM stdin +-- +ERROR: syntax error at or near "notsoshorttext" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 019 +select * from basictest +-- +TABLE: name="basictest" schema="" table="basictest" ctx=Select +STMT: SelectStmt +== 020 +-- check that domains inherit operations from base types +select testtext || testvarchar as concat, testnumeric + 42 as sum +from basictest +-- +TABLE: name="basictest" schema="" table="basictest" ctx=Select +STMT: SelectStmt +== 021 +-- check that union/case/coalesce type resolution handles domains properly +select pg_typeof(coalesce(4::domainint4, 7)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 022 +select pg_typeof(coalesce(4::domainint4, 7::domainint4)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 023 +drop table basictest +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DDL +STMT: DropStmt +== 024 +drop domain domainvarchar restrict +-- +STMT: DropStmt +== 025 +drop domain domainnumeric restrict +-- +STMT: DropStmt +== 026 +drop domain domainint4 restrict +-- +STMT: DropStmt +== 027 +drop domain domaintext +-- +STMT: DropStmt +== 028 +-- Test non-error-throwing input + +create domain positiveint int4 check(value > 0) +-- +STMT: CreateDomainStmt +== 029 +create domain weirdfloat float8 check((1 / value) < 10) +-- +STMT: CreateDomainStmt +== 030 +select pg_input_is_valid('1', 'positiveint') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 031 +select pg_input_is_valid('junk', 'positiveint') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 032 +select pg_input_is_valid('-1', 'positiveint') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 033 +select * from pg_input_error_info('junk', 'positiveint') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 034 +select * from pg_input_error_info('-1', 'positiveint') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 035 +select * from pg_input_error_info('junk', 'weirdfloat') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 036 +select * from pg_input_error_info('0.01', 'weirdfloat') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- We currently can't trap errors raised in the CHECK expression itself +select * from pg_input_error_info('0', 'weirdfloat') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 038 +drop domain positiveint +-- +STMT: DropStmt +== 039 +drop domain weirdfloat +-- +STMT: DropStmt +== 040 +-- Test domains over array types + +create domain domainint4arr int4[1] +-- +STMT: CreateDomainStmt +== 041 +create domain domainchar4arr varchar(4)[2][3] +-- +STMT: CreateDomainStmt +== 042 +create table domarrtest + ( testint4arr domainint4arr + , testchar4arr domainchar4arr + ) +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DDL +STMT: CreateStmt +== 043 +INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO domarrtest values ('{{2,2},{2,2}}', '{{"a","b"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"},{"e","f"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO domarrtest values ('{2,2}', '{{"a"},{"c"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO domarrtest values (NULL, '{{"a","b","c"},{"d","e","f"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO domarrtest values (NULL, '{{"toolong","b","c"},{"d","e","f"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +INSERT INTO domarrtest (testint4arr[1], testint4arr[3]) values (11,22) +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +select * from domarrtest +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +STMT: SelectStmt +== 051 +select testint4arr[1], testchar4arr[2:2] from domarrtest +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +STMT: SelectStmt +== 052 +select array_dims(testint4arr), array_dims(testchar4arr) from domarrtest +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: SelectStmt +== 053 +COPY domarrtest FROM stdin +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +STMT: CopyStmt +== 054 +COPY domarrtest FROM stdin +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +STMT: CopyStmt +== 055 +-- fail +{3,4} {qwerty,w,e} + +select * from domarrtest +-- +ERROR: syntax error at or near "{" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 056 +COPY nulltest FROM stdin +-- +TABLE: name="nulltest" schema="" table="nulltest" ctx=Select +STMT: CopyStmt +== 057 +--fail +a b c d \N + +-- Last row is bad +COPY nulltest FROM stdin +-- +ERROR: syntax error at or near "a" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 058 +select * from nulltest +-- +TABLE: name="nulltest" schema="" table="nulltest" ctx=Select +STMT: SelectStmt +== 059 +-- Test out coerced (casted) constraints +SELECT cast('1' as dnotnull) +-- +STMT: SelectStmt +== 060 +SELECT cast(NULL as dnotnull) +-- +STMT: SelectStmt +== 061 +-- fail +SELECT cast(cast(NULL as dnull) as dnotnull) +-- +STMT: SelectStmt +== 062 +-- fail +SELECT cast(col4 as dnotnull) from nulltest +-- +TABLE: name="nulltest" schema="" table="nulltest" ctx=Select +STMT: SelectStmt +== 063 +-- fail + +-- cleanup +drop table nulltest +-- +TABLE: name="nulltest" schema="" table="nulltest" ctx=DDL +STMT: DropStmt +== 064 +drop domain dnotnull restrict +-- +STMT: DropStmt +== 065 +drop domain dnull restrict +-- +STMT: DropStmt +== 066 +drop domain dcheck restrict +-- +STMT: DropStmt +== 067 +create domain ddef1 int4 DEFAULT 3 +-- +STMT: CreateDomainStmt +== 068 +create domain ddef2 oid DEFAULT '12' +-- +STMT: CreateDomainStmt +== 069 +-- Type mixing, function returns int8 +create domain ddef3 text DEFAULT 5 +-- +STMT: CreateDomainStmt +== 070 +create sequence ddef4_seq +-- +STMT: CreateSeqStmt +== 071 +create domain ddef4 int4 DEFAULT nextval('ddef4_seq') +-- +STMT: CreateDomainStmt +== 072 +create domain ddef5 numeric(8,2) NOT NULL DEFAULT '12.12' +-- +STMT: CreateDomainStmt +== 073 +create table defaulttest + ( col1 ddef1 + , col2 ddef2 + , col3 ddef3 + , col4 ddef4 PRIMARY KEY + , col5 ddef1 NOT NULL DEFAULT NULL + , col6 ddef2 DEFAULT '88' + , col7 ddef4 DEFAULT 8000 + , col8 ddef5 + ) +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: CreateStmt +== 074 +insert into defaulttest(col4) values(0) +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +-- fails, col5 defaults to null +alter table defaulttest alter column col5 drop default +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: AlterTableStmt +== 076 +insert into defaulttest default values +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +== 077 +-- succeeds, inserts domain default +-- We used to treat SET DEFAULT NULL as equivalent to DROP DEFAULT; wrong +alter table defaulttest alter column col5 set default null +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: AlterTableStmt +== 078 +insert into defaulttest(col4) values(0) +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 079 +-- fails +alter table defaulttest alter column col5 drop default +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: AlterTableStmt +== 080 +insert into defaulttest default values +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +== 081 +insert into defaulttest default values +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +== 082 +-- Test defaults with copy +COPY defaulttest(col5) FROM stdin +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=Select +STMT: CopyStmt +== 083 +select * from defaulttest +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=Select +STMT: SelectStmt +== 084 +drop table defaulttest cascade +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: DropStmt +== 085 +-- Test ALTER DOMAIN .. NOT NULL +create domain dnotnulltest integer +-- +STMT: CreateDomainStmt +== 086 +create table domnotnull +( col1 dnotnulltest +, col2 dnotnulltest +) +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DDL +STMT: CreateStmt +== 087 +insert into domnotnull default values +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: InsertStmt +== 088 +alter domain dnotnulltest set not null +-- +STMT: AlterDomainStmt +== 089 +-- fails + +update domnotnull set col1 = 5 +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +== 090 +alter domain dnotnulltest set not null +-- +STMT: AlterDomainStmt +== 091 +-- fails + +update domnotnull set col2 = 6 +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +== 092 +alter domain dnotnulltest set not null +-- +STMT: AlterDomainStmt +== 093 +update domnotnull set col1 = null +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +== 094 +-- fails + +alter domain dnotnulltest drop not null +-- +STMT: AlterDomainStmt +== 095 +update domnotnull set col1 = null +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +== 096 +update domnotnull set col1 = 5 +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +== 097 +-- these constraints can also be added and removed by name +alter domain dnotnulltest add constraint dnotnulltest_notnull not null +-- +STMT: AlterDomainStmt +== 098 +update domnotnull set col1 = null +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +== 099 +-- fails +select conname, pg_get_constraintdef(oid) from pg_constraint + where contypid = 'dnotnulltest'::regtype +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="contypid" +STMT: SelectStmt +== 100 +alter domain dnotnulltest drop constraint dnotnulltest_notnull +-- +STMT: AlterDomainStmt +== 101 +update domnotnull set col1 = null +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +== 102 +drop domain dnotnulltest cascade +-- +STMT: DropStmt +== 103 +-- Test ALTER DOMAIN .. DEFAULT .. +create table domdeftest (col1 ddef1) +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DDL +STMT: CreateStmt +== 104 +insert into domdeftest default values +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DML +STMT: InsertStmt +== 105 +select * from domdeftest +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=Select +STMT: SelectStmt +== 106 +alter domain ddef1 set default '42' +-- +STMT: AlterDomainStmt +== 107 +insert into domdeftest default values +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DML +STMT: InsertStmt +== 108 +select * from domdeftest +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=Select +STMT: SelectStmt +== 109 +alter domain ddef1 drop default +-- +STMT: AlterDomainStmt +== 110 +insert into domdeftest default values +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DML +STMT: InsertStmt +== 111 +select * from domdeftest +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=Select +STMT: SelectStmt +== 112 +drop table domdeftest +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DDL +STMT: DropStmt +== 113 +-- Test ALTER DOMAIN .. CONSTRAINT .. +create domain con as integer +-- +STMT: CreateDomainStmt +== 114 +create table domcontest (col1 con) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DDL +STMT: CreateStmt +== 115 +insert into domcontest values (1) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +insert into domcontest values (2) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +alter domain con add constraint t check (VALUE < 1) +-- +STMT: AlterDomainStmt +== 118 +-- fails + +alter domain con add constraint t check (VALUE < 34) +-- +STMT: AlterDomainStmt +== 119 +alter domain con add check (VALUE > 0) +-- +STMT: AlterDomainStmt +== 120 +insert into domcontest values (-5) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +-- fails +insert into domcontest values (42) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +-- fails +insert into domcontest values (5) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +alter domain con drop constraint t +-- +STMT: AlterDomainStmt +== 124 +insert into domcontest values (-5) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 125 +--fails +insert into domcontest values (42) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 126 +alter domain con drop constraint nonexistent +-- +STMT: AlterDomainStmt +== 127 +alter domain con drop constraint if exists nonexistent +-- +STMT: AlterDomainStmt +== 128 +-- not-null constraints +create domain connotnull integer +-- +STMT: CreateDomainStmt +== 129 +create table domconnotnulltest +( col1 connotnull +, col2 connotnull +) +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DDL +STMT: CreateStmt +== 130 +insert into domconnotnulltest default values +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: InsertStmt +== 131 +alter domain connotnull add not null +-- +STMT: AlterDomainStmt +== 132 +-- fails + +update domconnotnulltest set col1 = 5 +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: UpdateStmt +== 133 +alter domain connotnull add not null +-- +STMT: AlterDomainStmt +== 134 +-- fails + +update domconnotnulltest set col2 = 6 +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: UpdateStmt +== 135 +alter domain connotnull add constraint constr1 not null +-- +STMT: AlterDomainStmt +== 136 +select count(*) from pg_constraint where contypid = 'connotnull'::regtype and contype = 'n' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="contypid" +FILTER: schema="" table="" column="contype" +STMT: SelectStmt +== 137 +alter domain connotnull add constraint constr1bis not null +-- +STMT: AlterDomainStmt +== 138 +-- redundant +select count(*) from pg_constraint where contypid = 'connotnull'::regtype and contype = 'n' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="contypid" +FILTER: schema="" table="" column="contype" +STMT: SelectStmt +== 139 +update domconnotnulltest set col1 = null +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: UpdateStmt +== 140 +-- fails + +alter domain connotnull drop constraint constr1 +-- +STMT: AlterDomainStmt +== 141 +update domconnotnulltest set col1 = null +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: UpdateStmt +== 142 +drop domain connotnull cascade +-- +STMT: DropStmt +== 143 +drop table domconnotnulltest +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DDL +STMT: DropStmt +== 144 +-- Test ALTER DOMAIN .. CONSTRAINT .. NOT VALID +create domain things AS INT +-- +STMT: CreateDomainStmt +== 145 +CREATE TABLE thethings (stuff things) +-- +TABLE: name="thethings" schema="" table="thethings" ctx=DDL +STMT: CreateStmt +== 146 +INSERT INTO thethings (stuff) VALUES (55) +-- +TABLE: name="thethings" schema="" table="thethings" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +ALTER DOMAIN things ADD CONSTRAINT meow CHECK (VALUE < 11) +-- +STMT: AlterDomainStmt +== 148 +ALTER DOMAIN things ADD CONSTRAINT meow CHECK (VALUE < 11) NOT VALID +-- +STMT: AlterDomainStmt +== 149 +ALTER DOMAIN things VALIDATE CONSTRAINT meow +-- +STMT: AlterDomainStmt +== 150 +UPDATE thethings SET stuff = 10 +-- +TABLE: name="thethings" schema="" table="thethings" ctx=DML +STMT: UpdateStmt +== 151 +ALTER DOMAIN things VALIDATE CONSTRAINT meow +-- +STMT: AlterDomainStmt +== 152 +-- Confirm ALTER DOMAIN with RULES. +create table domtab (col1 integer) +-- +TABLE: name="domtab" schema="" table="domtab" ctx=DDL +STMT: CreateStmt +== 153 +create domain dom as integer +-- +STMT: CreateDomainStmt +== 154 +create view domview as select cast(col1 as dom) from domtab +-- +TABLE: name="domview" schema="" table="domview" ctx=DDL +TABLE: name="domtab" schema="" table="domtab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 155 +insert into domtab (col1) values (null) +-- +TABLE: name="domtab" schema="" table="domtab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 156 +insert into domtab (col1) values (5) +-- +TABLE: name="domtab" schema="" table="domtab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 157 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +== 158 +alter domain dom set not null +-- +STMT: AlterDomainStmt +== 159 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +== 160 +-- fail + +alter domain dom drop not null +-- +STMT: AlterDomainStmt +== 161 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +== 162 +alter domain dom add constraint domchkgt6 check(value > 6) +-- +STMT: AlterDomainStmt +== 163 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +== 164 +--fail + +alter domain dom drop constraint domchkgt6 restrict +-- +STMT: AlterDomainStmt +== 165 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +== 166 +-- cleanup +drop domain ddef1 restrict +-- +STMT: DropStmt +== 167 +drop domain ddef2 restrict +-- +STMT: DropStmt +== 168 +drop domain ddef3 restrict +-- +STMT: DropStmt +== 169 +drop domain ddef4 restrict +-- +STMT: DropStmt +== 170 +drop domain ddef5 restrict +-- +STMT: DropStmt +== 171 +drop sequence ddef4_seq +-- +STMT: DropStmt +== 172 +-- Test domains over domains +create domain vchar4 varchar(4) +-- +STMT: CreateDomainStmt +== 173 +create domain dinter vchar4 check (substring(VALUE, 1, 1) = 'x') +-- +STMT: CreateDomainStmt +== 174 +create domain dtop dinter check (substring(VALUE, 2, 1) = '1') +-- +STMT: CreateDomainStmt +== 175 +select 'x123'::dtop +-- +STMT: SelectStmt +== 176 +select 'x1234'::dtop +-- +STMT: SelectStmt +== 177 +-- explicit coercion should truncate +select 'y1234'::dtop +-- +STMT: SelectStmt +== 178 +-- fail +select 'y123'::dtop +-- +STMT: SelectStmt +== 179 +-- fail +select 'yz23'::dtop +-- +STMT: SelectStmt +== 180 +-- fail +select 'xz23'::dtop +-- +STMT: SelectStmt +== 181 +-- fail + +create temp table dtest(f1 dtop) +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DDL +STMT: CreateStmt +== 182 +insert into dtest values('x123') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 183 +insert into dtest values('x1234') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 184 +-- fail, implicit coercion +insert into dtest values('y1234') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 185 +-- fail, implicit coercion +insert into dtest values('y123') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +-- fail +insert into dtest values('yz23') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +-- fail +insert into dtest values('xz23') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +-- fail + +drop table dtest +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DDL +STMT: DropStmt +== 189 +drop domain vchar4 cascade +-- +STMT: DropStmt +== 190 +-- Make sure that constraints of newly-added domain columns are +-- enforced correctly, even if there's no default value for the new +-- column. Per bug #1433 +create domain str_domain as text not null +-- +STMT: CreateDomainStmt +== 191 +create table domain_test (a int, b int) +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DDL +STMT: CreateStmt +== 192 +insert into domain_test values (1, 2) +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 193 +insert into domain_test values (1, 2) +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 194 +-- should fail +alter table domain_test add column c str_domain +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DDL +STMT: AlterTableStmt +== 195 +create domain str_domain2 as text check (value <> 'foo') default 'foo' +-- +STMT: CreateDomainStmt +== 196 +-- should fail +alter table domain_test add column d str_domain2 +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DDL +STMT: AlterTableStmt +== 197 +-- Check that domain constraints on prepared statement parameters of +-- unknown type are enforced correctly. +create domain pos_int as int4 check (value > 0) not null +-- +STMT: CreateDomainStmt +== 198 +prepare s1 as select $1::pos_int = 10 as "is_ten" +-- +STMT: PrepareStmt +STMT: SelectStmt +== 199 +execute s1(10) +-- +STMT: ExecuteStmt +== 200 +execute s1(0) +-- +STMT: ExecuteStmt +== 201 +-- should fail +execute s1(NULL) +-- +STMT: ExecuteStmt +== 202 +-- should fail + +-- Check that domain constraints on plpgsql function parameters, results, +-- and local variables are enforced correctly. + +create function doubledecrement(p1 pos_int) returns pos_int as $$ +declare v pos_int; +begin + return p1; +end$$ language plpgsql +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 203 +select doubledecrement(3) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +== 204 +-- fail because of implicit null assignment + +create or replace function doubledecrement(p1 pos_int) returns pos_int as $$ +declare v pos_int := 0; +begin + return p1; +end$$ language plpgsql +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 205 +select doubledecrement(3) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +== 206 +-- fail at initialization assignment + +create or replace function doubledecrement(p1 pos_int) returns pos_int as $$ +declare v pos_int := 1; +begin + v := p1 - 1; + return v - 1; +end$$ language plpgsql +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 207 +select doubledecrement(null) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +== 208 +-- fail before call +select doubledecrement(0) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +== 209 +-- fail before call +select doubledecrement(1) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +== 210 +-- fail at assignment to v +select doubledecrement(2) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +== 211 +-- fail at return +select doubledecrement(3) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +== 212 +-- good + +-- Check that ALTER DOMAIN tests columns of derived types + +create domain posint as int4 +-- +STMT: CreateDomainStmt +== 213 +-- Currently, this doesn't work for composite types, but verify it complains +create type ddtest1 as (f1 posint) +-- +STMT: CompositeTypeStmt +== 214 +create table ddtest2(f1 ddtest1) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +== 215 +insert into ddtest2 values(row(-1)) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +== 217 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +== 218 +-- Likewise for domains within arrays of composite +create table ddtest2(f1 ddtest1[]) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +== 219 +insert into ddtest2 values('{(-1)}') +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 220 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +== 221 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +== 222 +-- Likewise for domains within domains over composite +create domain ddtest1d as ddtest1 +-- +STMT: CreateDomainStmt +== 223 +create table ddtest2(f1 ddtest1d) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +== 224 +insert into ddtest2 values('(-1)') +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 225 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +== 226 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +== 227 +drop domain ddtest1d +-- +STMT: DropStmt +== 228 +-- Likewise for domains within domains over array of composite +create domain ddtest1d as ddtest1[] +-- +STMT: CreateDomainStmt +== 229 +create table ddtest2(f1 ddtest1d) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +== 230 +insert into ddtest2 values('{(-1)}') +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 231 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +== 232 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +== 233 +drop domain ddtest1d +-- +STMT: DropStmt +== 234 +-- Doesn't work for ranges, either +create type rposint as range (subtype = posint) +-- +STMT: CreateRangeStmt +== 235 +create table ddtest2(f1 rposint) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +== 236 +insert into ddtest2 values('(-1,3]') +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 237 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +== 238 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +== 239 +drop type rposint +-- +STMT: DropStmt +== 240 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +== 241 +create domain posint2 as posint check (value % 2 = 0) +-- +STMT: CreateDomainStmt +== 242 +create table ddtest2(f1 posint2) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +== 243 +insert into ddtest2 values(11) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +-- fail +insert into ddtest2 values(-2) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +-- fail +insert into ddtest2 values(2) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 246 +alter domain posint add constraint c2 check(value >= 10) +-- +STMT: AlterDomainStmt +== 247 +-- fail +alter domain posint add constraint c2 check(value > 0) +-- +STMT: AlterDomainStmt +== 248 +-- OK + +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +== 249 +drop type ddtest1 +-- +STMT: DropStmt +== 250 +drop domain posint cascade +-- +STMT: DropStmt +== 251 +|-- +-- Check enforcement of domain-related typmod in plpgsql (bug #5717) +|-- + +create or replace function array_elem_check(numeric) returns numeric as $$ +declare + x numeric(4,2)[1]; +begin + x[1] := $1; + return x[1]; +end$$ language plpgsql +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 252 +select array_elem_check(121.00) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +== 253 +select array_elem_check(1.23456) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +== 254 +create domain mynums as numeric(4,2)[1] +-- +STMT: CreateDomainStmt +== 255 +create or replace function array_elem_check(numeric) returns numeric as $$ +declare + x mynums; +begin + x[1] := $1; + return x[1]; +end$$ language plpgsql +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 256 +select array_elem_check(121.00) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +== 257 +select array_elem_check(1.23456) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +== 258 +create domain mynums2 as mynums +-- +STMT: CreateDomainStmt +== 259 +create or replace function array_elem_check(numeric) returns numeric as $$ +declare + x mynums2; +begin + x[1] := $1; + return x[1]; +end$$ language plpgsql +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 260 +select array_elem_check(121.00) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +== 261 +select array_elem_check(1.23456) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +== 262 +drop function array_elem_check(numeric) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: DropStmt +== 263 +|-- +-- Check enforcement of array-level domain constraints +|-- + +create domain orderedpair as int[2] check (value[1] < value[2]) +-- +STMT: CreateDomainStmt +== 264 +select array[1,2]::orderedpair +-- +STMT: SelectStmt +== 265 +select array[2,1]::orderedpair +-- +STMT: SelectStmt +== 266 +-- fail + +create temp table op (f1 orderedpair) +-- +TABLE: name="op" schema="" table="op" ctx=DDL +STMT: CreateStmt +== 267 +insert into op values (array[1,2]) +-- +TABLE: name="op" schema="" table="op" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 268 +insert into op values (array[2,1]) +-- +TABLE: name="op" schema="" table="op" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +-- fail + +update op set f1[2] = 3 +-- +TABLE: name="op" schema="" table="op" ctx=DML +STMT: UpdateStmt +== 270 +update op set f1[2] = 0 +-- +TABLE: name="op" schema="" table="op" ctx=DML +STMT: UpdateStmt +== 271 +-- fail +select * from op +-- +TABLE: name="op" schema="" table="op" ctx=Select +STMT: SelectStmt +== 272 +create or replace function array_elem_check(int) returns int as $$ +declare + x orderedpair := '{1,2}'; +begin + x[2] := $1; + return x[2]; +end$$ language plpgsql +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 273 +select array_elem_check(3) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +== 274 +select array_elem_check(-1) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +== 275 +drop function array_elem_check(int) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: DropStmt +== 276 +|-- +-- Check enforcement of changing constraints in plpgsql +|-- + +create domain di as int +-- +STMT: CreateDomainStmt +== 277 +create function dom_check(int) returns di as $$ +declare d di; +begin + d := $1::di; + return d; +end +$$ language plpgsql immutable +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 278 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +== 279 +alter domain di add constraint pos check (value > 0) +-- +STMT: AlterDomainStmt +== 280 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +== 281 +-- fail + +alter domain di drop constraint pos +-- +STMT: AlterDomainStmt +== 282 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +== 283 +-- implicit cast during assignment is a separate code path, test that too + +create or replace function dom_check(int) returns di as $$ +declare d di; +begin + d := $1; + return d; +end +$$ language plpgsql immutable +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 284 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +== 285 +alter domain di add constraint pos check (value > 0) +-- +STMT: AlterDomainStmt +== 286 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +== 287 +-- fail + +alter domain di drop constraint pos +-- +STMT: AlterDomainStmt +== 288 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +== 289 +drop function dom_check(int) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=DDL +STMT: DropStmt +== 290 +drop domain di +-- +STMT: DropStmt +== 291 +|-- +-- Check use of a (non-inline-able) SQL function in a domain constraint; +-- this has caused issues in the past +|-- + +create function sql_is_distinct_from(anyelement, anyelement) +returns boolean language sql +as 'select $1 is distinct from $2 limit 1' +-- +FUNCTION: name="sql_is_distinct_from" function="sql_is_distinct_from" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 292 +create domain inotnull int + check (sql_is_distinct_from(value, null)) +-- +STMT: CreateDomainStmt +== 293 +select 1::inotnull +-- +STMT: SelectStmt +== 294 +select null::inotnull +-- +STMT: SelectStmt +== 295 +create table dom_table (x inotnull) +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DDL +STMT: CreateStmt +== 296 +insert into dom_table values ('1') +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 297 +insert into dom_table values (1) +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 298 +insert into dom_table values (null) +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 299 +drop table dom_table +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DDL +STMT: DropStmt +== 300 +drop domain inotnull +-- +STMT: DropStmt +== 301 +drop function sql_is_distinct_from(anyelement, anyelement) +-- +FUNCTION: name="sql_is_distinct_from" function="sql_is_distinct_from" schema="" ctx=DDL +STMT: DropStmt +== 302 +|-- +-- Renaming +|-- + +create domain testdomain1 as int +-- +STMT: CreateDomainStmt +== 303 +alter domain testdomain1 rename to testdomain2 +-- +STMT: RenameStmt +== 304 +alter type testdomain2 rename to testdomain3 +-- +STMT: RenameStmt +== 305 +-- alter type also works +drop domain testdomain3 +-- +STMT: DropStmt +== 306 +|-- +-- Renaming domain constraints +|-- + +create domain testdomain1 as int constraint unsigned check (value > 0) +-- +STMT: CreateDomainStmt +== 307 +alter domain testdomain1 rename constraint unsigned to unsigned_foo +-- +STMT: RenameStmt +== 308 +alter domain testdomain1 drop constraint unsigned_foo +-- +STMT: AlterDomainStmt +== 309 +drop domain testdomain1 +-- +STMT: DropStmt +== 310 +|-- +-- Get the base type of a domain +|-- +create domain mytext as text +-- +STMT: CreateDomainStmt +== 311 +create domain mytext_child_1 as mytext +-- +STMT: CreateDomainStmt +== 312 +select pg_basetype('mytext'::regtype) +-- +FUNCTION: name="pg_basetype" function="pg_basetype" schema="" ctx=Call +STMT: SelectStmt +== 313 +select pg_basetype('mytext_child_1'::regtype) +-- +FUNCTION: name="pg_basetype" function="pg_basetype" schema="" ctx=Call +STMT: SelectStmt +== 314 +select pg_basetype(1) +-- +FUNCTION: name="pg_basetype" function="pg_basetype" schema="" ctx=Call +STMT: SelectStmt +== 315 +-- expect NULL not error + +drop domain mytext cascade +-- +STMT: DropStmt +== 316 +|-- +-- Information schema +|-- + +SELECT * FROM information_schema.column_domain_usage + WHERE domain_name IN ('con', 'dom', 'pos_int', 'things') + ORDER BY domain_name +-- +TABLE: name="information_schema.column_domain_usage" schema="information_schema" table="column_domain_usage" ctx=Select +FILTER: schema="" table="" column="domain_name" +STMT: SelectStmt +== 317 +SELECT * FROM information_schema.domain_constraints + WHERE domain_name IN ('con', 'dom', 'pos_int', 'things') + ORDER BY constraint_name +-- +TABLE: name="information_schema.domain_constraints" schema="information_schema" table="domain_constraints" ctx=Select +FILTER: schema="" table="" column="domain_name" +STMT: SelectStmt +== 318 +SELECT * FROM information_schema.domains + WHERE domain_name IN ('con', 'dom', 'pos_int', 'things') + ORDER BY domain_name +-- +TABLE: name="information_schema.domains" schema="information_schema" table="domains" ctx=Select +FILTER: schema="" table="" column="domain_name" +STMT: SelectStmt +== 319 +SELECT * FROM information_schema.check_constraints + WHERE (constraint_schema, constraint_name) + IN (SELECT constraint_schema, constraint_name + FROM information_schema.domain_constraints + WHERE domain_name IN ('con', 'dom', 'pos_int', 'things')) + ORDER BY constraint_name +-- +TABLE: name="information_schema.check_constraints" schema="information_schema" table="check_constraints" ctx=Select +TABLE: name="information_schema.domain_constraints" schema="information_schema" table="domain_constraints" ctx=Select +FILTER: schema="" table="" column="constraint_schema" +FILTER: schema="" table="" column="constraint_name" +FILTER: schema="" table="" column="domain_name" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/drop_if_exists.metadata.json b/parser/testdata/summary/postgres_regress/drop_if_exists.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/drop_if_exists.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/drop_if_exists.test b/parser/testdata/summary/postgres_regress/drop_if_exists.test new file mode 100644 index 0000000..30104d6 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/drop_if_exists.test @@ -0,0 +1,750 @@ +== 001 +|-- +-- IF EXISTS tests +|-- + +-- table (will be really dropped at the end) + +DROP TABLE test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 002 +DROP TABLE IF EXISTS test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 003 +CREATE TABLE test_exists (a int, b text) +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: CreateStmt +== 004 +-- view + +DROP VIEW test_view_exists +-- +STMT: DropStmt +== 005 +DROP VIEW IF EXISTS test_view_exists +-- +STMT: DropStmt +== 006 +CREATE VIEW test_view_exists AS select * from test_exists +-- +TABLE: name="test_view_exists" schema="" table="test_view_exists" ctx=DDL +TABLE: name="test_exists" schema="" table="test_exists" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 007 +DROP VIEW IF EXISTS test_view_exists +-- +STMT: DropStmt +== 008 +DROP VIEW test_view_exists +-- +STMT: DropStmt +== 009 +-- index + +DROP INDEX test_index_exists +-- +STMT: DropStmt +== 010 +DROP INDEX IF EXISTS test_index_exists +-- +STMT: DropStmt +== 011 +CREATE INDEX test_index_exists on test_exists(a) +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: IndexStmt +== 012 +DROP INDEX IF EXISTS test_index_exists +-- +STMT: DropStmt +== 013 +DROP INDEX test_index_exists +-- +STMT: DropStmt +== 014 +-- sequence + +DROP SEQUENCE test_sequence_exists +-- +STMT: DropStmt +== 015 +DROP SEQUENCE IF EXISTS test_sequence_exists +-- +STMT: DropStmt +== 016 +CREATE SEQUENCE test_sequence_exists +-- +STMT: CreateSeqStmt +== 017 +DROP SEQUENCE IF EXISTS test_sequence_exists +-- +STMT: DropStmt +== 018 +DROP SEQUENCE test_sequence_exists +-- +STMT: DropStmt +== 019 +-- schema + +DROP SCHEMA test_schema_exists +-- +STMT: DropStmt +== 020 +DROP SCHEMA IF EXISTS test_schema_exists +-- +STMT: DropStmt +== 021 +CREATE SCHEMA test_schema_exists +-- +STMT: CreateSchemaStmt +== 022 +DROP SCHEMA IF EXISTS test_schema_exists +-- +STMT: DropStmt +== 023 +DROP SCHEMA test_schema_exists +-- +STMT: DropStmt +== 024 +-- type + +DROP TYPE test_type_exists +-- +STMT: DropStmt +== 025 +DROP TYPE IF EXISTS test_type_exists +-- +STMT: DropStmt +== 026 +CREATE type test_type_exists as (a int, b text) +-- +STMT: CompositeTypeStmt +== 027 +DROP TYPE IF EXISTS test_type_exists +-- +STMT: DropStmt +== 028 +DROP TYPE test_type_exists +-- +STMT: DropStmt +== 029 +-- domain + +DROP DOMAIN test_domain_exists +-- +STMT: DropStmt +== 030 +DROP DOMAIN IF EXISTS test_domain_exists +-- +STMT: DropStmt +== 031 +CREATE domain test_domain_exists as int not null check (value > 0) +-- +STMT: CreateDomainStmt +== 032 +DROP DOMAIN IF EXISTS test_domain_exists +-- +STMT: DropStmt +== 033 +DROP DOMAIN test_domain_exists +-- +STMT: DropStmt +== 034 +--- +--- role/user/group +--- + +CREATE USER regress_test_u1 +-- +STMT: CreateRoleStmt +== 035 +CREATE ROLE regress_test_r1 +-- +STMT: CreateRoleStmt +== 036 +CREATE GROUP regress_test_g1 +-- +STMT: CreateRoleStmt +== 037 +DROP USER regress_test_u2 +-- +STMT: DropRoleStmt +== 038 +DROP USER IF EXISTS regress_test_u1, regress_test_u2 +-- +STMT: DropRoleStmt +== 039 +DROP USER regress_test_u1 +-- +STMT: DropRoleStmt +== 040 +DROP ROLE regress_test_r2 +-- +STMT: DropRoleStmt +== 041 +DROP ROLE IF EXISTS regress_test_r1, regress_test_r2 +-- +STMT: DropRoleStmt +== 042 +DROP ROLE regress_test_r1 +-- +STMT: DropRoleStmt +== 043 +DROP GROUP regress_test_g2 +-- +STMT: DropRoleStmt +== 044 +DROP GROUP IF EXISTS regress_test_g1, regress_test_g2 +-- +STMT: DropRoleStmt +== 045 +DROP GROUP regress_test_g1 +-- +STMT: DropRoleStmt +== 046 +-- collation +DROP COLLATION IF EXISTS test_collation_exists +-- +STMT: DropStmt +== 047 +-- conversion +DROP CONVERSION test_conversion_exists +-- +STMT: DropStmt +== 048 +DROP CONVERSION IF EXISTS test_conversion_exists +-- +STMT: DropStmt +== 049 +CREATE CONVERSION test_conversion_exists + FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +== 050 +DROP CONVERSION test_conversion_exists +-- +STMT: DropStmt +== 051 +-- text search parser +DROP TEXT SEARCH PARSER test_tsparser_exists +-- +STMT: DropStmt +== 052 +DROP TEXT SEARCH PARSER IF EXISTS test_tsparser_exists +-- +STMT: DropStmt +== 053 +-- text search dictionary +DROP TEXT SEARCH DICTIONARY test_tsdict_exists +-- +STMT: DropStmt +== 054 +DROP TEXT SEARCH DICTIONARY IF EXISTS test_tsdict_exists +-- +STMT: DropStmt +== 055 +CREATE TEXT SEARCH DICTIONARY test_tsdict_exists ( + Template=ispell, + DictFile=ispell_sample, + AffFile=ispell_sample +) +-- +STMT: DefineStmt +== 056 +DROP TEXT SEARCH DICTIONARY test_tsdict_exists +-- +STMT: DropStmt +== 057 +-- test search template +DROP TEXT SEARCH TEMPLATE test_tstemplate_exists +-- +STMT: DropStmt +== 058 +DROP TEXT SEARCH TEMPLATE IF EXISTS test_tstemplate_exists +-- +STMT: DropStmt +== 059 +-- text search configuration +DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists +-- +STMT: DropStmt +== 060 +DROP TEXT SEARCH CONFIGURATION IF EXISTS test_tsconfig_exists +-- +STMT: DropStmt +== 061 +CREATE TEXT SEARCH CONFIGURATION test_tsconfig_exists (COPY=english) +-- +STMT: DefineStmt +== 062 +DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists +-- +STMT: DropStmt +== 063 +-- extension +DROP EXTENSION test_extension_exists +-- +STMT: DropStmt +== 064 +DROP EXTENSION IF EXISTS test_extension_exists +-- +STMT: DropStmt +== 065 +-- functions +DROP FUNCTION test_function_exists() +-- +FUNCTION: name="test_function_exists" function="test_function_exists" schema="" ctx=DDL +STMT: DropStmt +== 066 +DROP FUNCTION IF EXISTS test_function_exists() +-- +FUNCTION: name="test_function_exists" function="test_function_exists" schema="" ctx=DDL +STMT: DropStmt +== 067 +DROP FUNCTION test_function_exists(int, text, int[]) +-- +FUNCTION: name="test_function_exists" function="test_function_exists" schema="" ctx=DDL +STMT: DropStmt +== 068 +DROP FUNCTION IF EXISTS test_function_exists(int, text, int[]) +-- +FUNCTION: name="test_function_exists" function="test_function_exists" schema="" ctx=DDL +STMT: DropStmt +== 069 +-- aggregate +DROP AGGREGATE test_aggregate_exists(*) +-- +STMT: DropStmt +== 070 +DROP AGGREGATE IF EXISTS test_aggregate_exists(*) +-- +STMT: DropStmt +== 071 +DROP AGGREGATE test_aggregate_exists(int) +-- +STMT: DropStmt +== 072 +DROP AGGREGATE IF EXISTS test_aggregate_exists(int) +-- +STMT: DropStmt +== 073 +-- operator +DROP OPERATOR @#@ (int, int) +-- +STMT: DropStmt +== 074 +DROP OPERATOR IF EXISTS @#@ (int, int) +-- +STMT: DropStmt +== 075 +CREATE OPERATOR @#@ + (leftarg = int8, rightarg = int8, procedure = int8xor) +-- +STMT: DefineStmt +== 076 +DROP OPERATOR @#@ (int8, int8) +-- +STMT: DropStmt +== 077 +-- language +DROP LANGUAGE test_language_exists +-- +STMT: DropStmt +== 078 +DROP LANGUAGE IF EXISTS test_language_exists +-- +STMT: DropStmt +== 079 +-- cast +DROP CAST (text AS text) +-- +STMT: DropStmt +== 080 +DROP CAST IF EXISTS (text AS text) +-- +STMT: DropStmt +== 081 +-- trigger +DROP TRIGGER test_trigger_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 082 +DROP TRIGGER IF EXISTS test_trigger_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 083 +DROP TRIGGER test_trigger_exists ON no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=DDL +STMT: DropStmt +== 084 +DROP TRIGGER IF EXISTS test_trigger_exists ON no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=DDL +STMT: DropStmt +== 085 +DROP TRIGGER test_trigger_exists ON no_such_schema.no_such_table +-- +TABLE: name="no_such_schema.no_such_table" schema="no_such_schema" table="no_such_table" ctx=DDL +STMT: DropStmt +== 086 +DROP TRIGGER IF EXISTS test_trigger_exists ON no_such_schema.no_such_table +-- +TABLE: name="no_such_schema.no_such_table" schema="no_such_schema" table="no_such_table" ctx=DDL +STMT: DropStmt +== 087 +CREATE TRIGGER test_trigger_exists + BEFORE UPDATE ON test_exists + FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger() +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: CreateTrigStmt +== 088 +DROP TRIGGER test_trigger_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 089 +-- rule +DROP RULE test_rule_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 090 +DROP RULE IF EXISTS test_rule_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 091 +DROP RULE test_rule_exists ON no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=DDL +STMT: DropStmt +== 092 +DROP RULE IF EXISTS test_rule_exists ON no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=DDL +STMT: DropStmt +== 093 +DROP RULE test_rule_exists ON no_such_schema.no_such_table +-- +TABLE: name="no_such_schema.no_such_table" schema="no_such_schema" table="no_such_table" ctx=DDL +STMT: DropStmt +== 094 +DROP RULE IF EXISTS test_rule_exists ON no_such_schema.no_such_table +-- +TABLE: name="no_such_schema.no_such_table" schema="no_such_schema" table="no_such_table" ctx=DDL +STMT: DropStmt +== 095 +CREATE RULE test_rule_exists AS ON INSERT TO test_exists + DO INSTEAD + INSERT INTO test_exists VALUES (NEW.a, NEW.b || NEW.a::text) +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: RuleStmt +== 096 +DROP RULE test_rule_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 097 +-- foreign data wrapper +DROP FOREIGN DATA WRAPPER test_fdw_exists +-- +STMT: DropStmt +== 098 +DROP FOREIGN DATA WRAPPER IF EXISTS test_fdw_exists +-- +STMT: DropStmt +== 099 +-- foreign server +DROP SERVER test_server_exists +-- +STMT: DropStmt +== 100 +DROP SERVER IF EXISTS test_server_exists +-- +STMT: DropStmt +== 101 +-- operator class +DROP OPERATOR CLASS test_operator_class USING btree +-- +STMT: DropStmt +== 102 +DROP OPERATOR CLASS IF EXISTS test_operator_class USING btree +-- +STMT: DropStmt +== 103 +DROP OPERATOR CLASS test_operator_class USING no_such_am +-- +STMT: DropStmt +== 104 +DROP OPERATOR CLASS IF EXISTS test_operator_class USING no_such_am +-- +STMT: DropStmt +== 105 +-- operator family +DROP OPERATOR FAMILY test_operator_family USING btree +-- +STMT: DropStmt +== 106 +DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree +-- +STMT: DropStmt +== 107 +DROP OPERATOR FAMILY test_operator_family USING no_such_am +-- +STMT: DropStmt +== 108 +DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am +-- +STMT: DropStmt +== 109 +-- access method +DROP ACCESS METHOD no_such_am +-- +STMT: DropStmt +== 110 +DROP ACCESS METHOD IF EXISTS no_such_am +-- +STMT: DropStmt +== 111 +-- drop the table + +DROP TABLE IF EXISTS test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 112 +DROP TABLE test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +== 113 +-- be tolerant with missing schemas, types, etc + +DROP AGGREGATE IF EXISTS no_such_schema.foo(int) +-- +STMT: DropStmt +== 114 +DROP AGGREGATE IF EXISTS foo(no_such_type) +-- +STMT: DropStmt +== 115 +DROP AGGREGATE IF EXISTS foo(no_such_schema.no_such_type) +-- +STMT: DropStmt +== 116 +DROP CAST IF EXISTS (INTEGER AS no_such_type2) +-- +STMT: DropStmt +== 117 +DROP CAST IF EXISTS (no_such_type1 AS INTEGER) +-- +STMT: DropStmt +== 118 +DROP CAST IF EXISTS (INTEGER AS no_such_schema.bar) +-- +STMT: DropStmt +== 119 +DROP CAST IF EXISTS (no_such_schema.foo AS INTEGER) +-- +STMT: DropStmt +== 120 +DROP COLLATION IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 121 +DROP CONVERSION IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 122 +DROP DOMAIN IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 123 +DROP FOREIGN TABLE IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 124 +DROP FUNCTION IF EXISTS no_such_schema.foo() +-- +FUNCTION: name="no_such_schema.foo" function="foo" schema="no_such_schema" ctx=DDL +STMT: DropStmt +== 125 +DROP FUNCTION IF EXISTS foo(no_such_type) +-- +FUNCTION: name="foo" function="foo" schema="" ctx=DDL +STMT: DropStmt +== 126 +DROP FUNCTION IF EXISTS foo(no_such_schema.no_such_type) +-- +FUNCTION: name="foo" function="foo" schema="" ctx=DDL +STMT: DropStmt +== 127 +DROP INDEX IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 128 +DROP MATERIALIZED VIEW IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 129 +DROP OPERATOR IF EXISTS no_such_schema.+ (int, int) +-- +STMT: DropStmt +== 130 +DROP OPERATOR IF EXISTS + (no_such_type, no_such_type) +-- +STMT: DropStmt +== 131 +DROP OPERATOR IF EXISTS + (no_such_schema.no_such_type, no_such_schema.no_such_type) +-- +STMT: DropStmt +== 132 +DROP OPERATOR IF EXISTS # (NONE, no_such_schema.no_such_type) +-- +STMT: DropStmt +== 133 +DROP OPERATOR CLASS IF EXISTS no_such_schema.widget_ops USING btree +-- +STMT: DropStmt +== 134 +DROP OPERATOR FAMILY IF EXISTS no_such_schema.float_ops USING btree +-- +STMT: DropStmt +== 135 +DROP RULE IF EXISTS foo ON no_such_schema.bar +-- +TABLE: name="no_such_schema.bar" schema="no_such_schema" table="bar" ctx=DDL +STMT: DropStmt +== 136 +DROP SEQUENCE IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 137 +DROP TABLE IF EXISTS no_such_schema.foo +-- +TABLE: name="no_such_schema.foo" schema="no_such_schema" table="foo" ctx=DDL +STMT: DropStmt +== 138 +DROP TEXT SEARCH CONFIGURATION IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 139 +DROP TEXT SEARCH DICTIONARY IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 140 +DROP TEXT SEARCH PARSER IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 141 +DROP TEXT SEARCH TEMPLATE IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 142 +DROP TRIGGER IF EXISTS foo ON no_such_schema.bar +-- +TABLE: name="no_such_schema.bar" schema="no_such_schema" table="bar" ctx=DDL +STMT: DropStmt +== 143 +DROP TYPE IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 144 +DROP VIEW IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +== 145 +-- Check we receive an ambiguous function error when there are +-- multiple matching functions. +CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ language sql +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 146 +CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ language sql +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 147 +DROP FUNCTION test_ambiguous_funcname +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: DropStmt +== 148 +DROP FUNCTION IF EXISTS test_ambiguous_funcname +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: DropStmt +== 149 +-- cleanup +DROP FUNCTION test_ambiguous_funcname(int) +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: DropStmt +== 150 +DROP FUNCTION test_ambiguous_funcname(text) +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: DropStmt +== 151 +-- Likewise for procedures. +CREATE PROCEDURE test_ambiguous_procname(int) as $$ begin end; $$ language plpgsql +-- +FUNCTION: name="test_ambiguous_procname" function="test_ambiguous_procname" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 152 +CREATE PROCEDURE test_ambiguous_procname(text) as $$ begin end; $$ language plpgsql +-- +FUNCTION: name="test_ambiguous_procname" function="test_ambiguous_procname" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 153 +DROP PROCEDURE test_ambiguous_procname +-- +STMT: DropStmt +== 154 +DROP PROCEDURE IF EXISTS test_ambiguous_procname +-- +STMT: DropStmt +== 155 +-- Check we get a similar error if we use ROUTINE instead of PROCEDURE. +DROP ROUTINE IF EXISTS test_ambiguous_procname +-- +STMT: DropStmt +== 156 +-- cleanup +DROP PROCEDURE test_ambiguous_procname(int) +-- +STMT: DropStmt +== 157 +DROP PROCEDURE test_ambiguous_procname(text) +-- +STMT: DropStmt +== 158 +-- This test checks both the functionality of 'if exists' and the syntax +-- of the drop database command. +drop database test_database_exists (force) +-- +STMT: DropdbStmt +== 159 +drop database test_database_exists with (force) +-- +STMT: DropdbStmt +== 160 +drop database if exists test_database_exists (force) +-- +STMT: DropdbStmt +== 161 +drop database if exists test_database_exists with (force) +-- +STMT: DropdbStmt diff --git a/parser/testdata/summary/postgres_regress/drop_operator.metadata.json b/parser/testdata/summary/postgres_regress/drop_operator.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/drop_operator.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/drop_operator.test b/parser/testdata/summary/postgres_regress/drop_operator.test new file mode 100644 index 0000000..48629ea --- /dev/null +++ b/parser/testdata/summary/postgres_regress/drop_operator.test @@ -0,0 +1,109 @@ +== 001 +CREATE OPERATOR === ( + PROCEDURE = int8eq, + LEFTARG = bigint, + RIGHTARG = bigint, + COMMUTATOR = === +) +-- +STMT: DefineStmt +== 002 +CREATE OPERATOR !== ( + PROCEDURE = int8ne, + LEFTARG = bigint, + RIGHTARG = bigint, + NEGATOR = ===, + COMMUTATOR = !== +) +-- +STMT: DefineStmt +== 003 +DROP OPERATOR !==(bigint, bigint) +-- +STMT: DropStmt +== 004 +SELECT ctid, oprcom +FROM pg_catalog.pg_operator fk +WHERE oprcom != 0 AND + NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprcom) +-- +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +ALIAS: "fk"="pg_catalog.pg_operator" +ALIAS: "pk"="pg_catalog.pg_operator" +FILTER: schema="" table="" column="oprcom" +FILTER: schema="" table="pk" column="oid" +FILTER: schema="" table="fk" column="oprcom" +STMT: SelectStmt +== 005 +SELECT ctid, oprnegate +FROM pg_catalog.pg_operator fk +WHERE oprnegate != 0 AND + NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprnegate) +-- +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +ALIAS: "fk"="pg_catalog.pg_operator" +ALIAS: "pk"="pg_catalog.pg_operator" +FILTER: schema="" table="" column="oprnegate" +FILTER: schema="" table="pk" column="oid" +FILTER: schema="" table="fk" column="oprnegate" +STMT: SelectStmt +== 006 +DROP OPERATOR ===(bigint, bigint) +-- +STMT: DropStmt +== 007 +CREATE OPERATOR <| ( + PROCEDURE = int8lt, + LEFTARG = bigint, + RIGHTARG = bigint +) +-- +STMT: DefineStmt +== 008 +CREATE OPERATOR |> ( + PROCEDURE = int8gt, + LEFTARG = bigint, + RIGHTARG = bigint, + NEGATOR = <|, + COMMUTATOR = <| +) +-- +STMT: DefineStmt +== 009 +DROP OPERATOR |>(bigint, bigint) +-- +STMT: DropStmt +== 010 +SELECT ctid, oprcom +FROM pg_catalog.pg_operator fk +WHERE oprcom != 0 AND + NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprcom) +-- +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +ALIAS: "fk"="pg_catalog.pg_operator" +ALIAS: "pk"="pg_catalog.pg_operator" +FILTER: schema="" table="" column="oprcom" +FILTER: schema="" table="pk" column="oid" +FILTER: schema="" table="fk" column="oprcom" +STMT: SelectStmt +== 011 +SELECT ctid, oprnegate +FROM pg_catalog.pg_operator fk +WHERE oprnegate != 0 AND + NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprnegate) +-- +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +ALIAS: "fk"="pg_catalog.pg_operator" +ALIAS: "pk"="pg_catalog.pg_operator" +FILTER: schema="" table="" column="oprnegate" +FILTER: schema="" table="pk" column="oid" +FILTER: schema="" table="fk" column="oprnegate" +STMT: SelectStmt +== 012 +DROP OPERATOR <|(bigint, bigint) +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/enum.metadata.json b/parser/testdata/summary/postgres_regress/enum.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/enum.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/enum.test b/parser/testdata/summary/postgres_regress/enum.test new file mode 100644 index 0000000..ba153dc --- /dev/null +++ b/parser/testdata/summary/postgres_regress/enum.test @@ -0,0 +1,927 @@ +== 001 +|-- +-- Enum tests +|-- + +CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple') +-- +STMT: CreateEnumStmt +== 002 +|-- +-- Did it create the right number of rows? +|-- +SELECT COUNT(*) FROM pg_enum WHERE enumtypid = 'rainbow'::regtype +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +== 003 +|-- +-- I/O functions +|-- +SELECT 'red'::rainbow +-- +STMT: SelectStmt +== 004 +SELECT 'mauve'::rainbow +-- +STMT: SelectStmt +== 005 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('red', 'rainbow') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT pg_input_is_valid('mauve', 'rainbow') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT * FROM pg_input_error_info('mauve', 'rainbow') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 008 +SELECT * FROM pg_input_error_info(repeat('too_long', 32), 'rainbow') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 009 +|-- +-- adding new values +|-- + +CREATE TYPE planets AS ENUM ( 'venus', 'earth', 'mars' ) +-- +STMT: CreateEnumStmt +== 010 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'planets'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +== 011 +ALTER TYPE planets ADD VALUE 'uranus' +-- +STMT: AlterEnumStmt +== 012 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'planets'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +== 013 +ALTER TYPE planets ADD VALUE 'mercury' BEFORE 'venus' +-- +STMT: AlterEnumStmt +== 014 +ALTER TYPE planets ADD VALUE 'saturn' BEFORE 'uranus' +-- +STMT: AlterEnumStmt +== 015 +ALTER TYPE planets ADD VALUE 'jupiter' AFTER 'mars' +-- +STMT: AlterEnumStmt +== 016 +ALTER TYPE planets ADD VALUE 'neptune' AFTER 'uranus' +-- +STMT: AlterEnumStmt +== 017 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'planets'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +== 018 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'planets'::regtype +ORDER BY enumlabel::planets +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +== 019 +-- errors for adding labels +ALTER TYPE planets ADD VALUE + 'plutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutopluto' +-- +STMT: AlterEnumStmt +== 020 +ALTER TYPE planets ADD VALUE 'pluto' AFTER 'zeus' +-- +STMT: AlterEnumStmt +== 021 +-- if not exists tests + +-- existing value gives error +ALTER TYPE planets ADD VALUE 'mercury' +-- +STMT: AlterEnumStmt +== 022 +-- unless IF NOT EXISTS is specified +ALTER TYPE planets ADD VALUE IF NOT EXISTS 'mercury' +-- +STMT: AlterEnumStmt +== 023 +-- should be neptune, not mercury +SELECT enum_last(NULL::planets) +-- +FUNCTION: name="enum_last" function="enum_last" schema="" ctx=Call +STMT: SelectStmt +== 024 +ALTER TYPE planets ADD VALUE IF NOT EXISTS 'pluto' +-- +STMT: AlterEnumStmt +== 025 +-- should be pluto, i.e. the new value +SELECT enum_last(NULL::planets) +-- +FUNCTION: name="enum_last" function="enum_last" schema="" ctx=Call +STMT: SelectStmt +== 026 +|-- +-- Test inserting so many values that we have to renumber +|-- + +create type insenum as enum ('L1', 'L2') +-- +STMT: CreateEnumStmt +== 027 +alter type insenum add value 'i1' before 'L2' +-- +STMT: AlterEnumStmt +== 028 +alter type insenum add value 'i2' before 'L2' +-- +STMT: AlterEnumStmt +== 029 +alter type insenum add value 'i3' before 'L2' +-- +STMT: AlterEnumStmt +== 030 +alter type insenum add value 'i4' before 'L2' +-- +STMT: AlterEnumStmt +== 031 +alter type insenum add value 'i5' before 'L2' +-- +STMT: AlterEnumStmt +== 032 +alter type insenum add value 'i6' before 'L2' +-- +STMT: AlterEnumStmt +== 033 +alter type insenum add value 'i7' before 'L2' +-- +STMT: AlterEnumStmt +== 034 +alter type insenum add value 'i8' before 'L2' +-- +STMT: AlterEnumStmt +== 035 +alter type insenum add value 'i9' before 'L2' +-- +STMT: AlterEnumStmt +== 036 +alter type insenum add value 'i10' before 'L2' +-- +STMT: AlterEnumStmt +== 037 +alter type insenum add value 'i11' before 'L2' +-- +STMT: AlterEnumStmt +== 038 +alter type insenum add value 'i12' before 'L2' +-- +STMT: AlterEnumStmt +== 039 +alter type insenum add value 'i13' before 'L2' +-- +STMT: AlterEnumStmt +== 040 +alter type insenum add value 'i14' before 'L2' +-- +STMT: AlterEnumStmt +== 041 +alter type insenum add value 'i15' before 'L2' +-- +STMT: AlterEnumStmt +== 042 +alter type insenum add value 'i16' before 'L2' +-- +STMT: AlterEnumStmt +== 043 +alter type insenum add value 'i17' before 'L2' +-- +STMT: AlterEnumStmt +== 044 +alter type insenum add value 'i18' before 'L2' +-- +STMT: AlterEnumStmt +== 045 +alter type insenum add value 'i19' before 'L2' +-- +STMT: AlterEnumStmt +== 046 +alter type insenum add value 'i20' before 'L2' +-- +STMT: AlterEnumStmt +== 047 +alter type insenum add value 'i21' before 'L2' +-- +STMT: AlterEnumStmt +== 048 +alter type insenum add value 'i22' before 'L2' +-- +STMT: AlterEnumStmt +== 049 +alter type insenum add value 'i23' before 'L2' +-- +STMT: AlterEnumStmt +== 050 +alter type insenum add value 'i24' before 'L2' +-- +STMT: AlterEnumStmt +== 051 +alter type insenum add value 'i25' before 'L2' +-- +STMT: AlterEnumStmt +== 052 +alter type insenum add value 'i26' before 'L2' +-- +STMT: AlterEnumStmt +== 053 +alter type insenum add value 'i27' before 'L2' +-- +STMT: AlterEnumStmt +== 054 +alter type insenum add value 'i28' before 'L2' +-- +STMT: AlterEnumStmt +== 055 +alter type insenum add value 'i29' before 'L2' +-- +STMT: AlterEnumStmt +== 056 +alter type insenum add value 'i30' before 'L2' +-- +STMT: AlterEnumStmt +== 057 +-- The exact values of enumsortorder will now depend on the local properties +-- of float4, but in any reasonable implementation we should get at least +-- 20 splits before having to renumber; so only hide values > 20. + +SELECT enumlabel, + case when enumsortorder > 20 then null else enumsortorder end as so +FROM pg_enum +WHERE enumtypid = 'insenum'::regtype +ORDER BY enumsortorder +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +== 058 +|-- +-- Basic table creation, row selection +|-- +CREATE TABLE enumtest (col rainbow) +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DDL +STMT: CreateStmt +== 059 +INSERT INTO enumtest values ('red'), ('orange'), ('yellow'), ('green') +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +COPY enumtest FROM stdin +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +STMT: CopyStmt +== 061 +SELECT * FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +STMT: SelectStmt +== 062 +|-- +-- Operators, no index +|-- +SELECT * FROM enumtest WHERE col = 'orange' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 063 +SELECT * FROM enumtest WHERE col <> 'orange' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 064 +SELECT * FROM enumtest WHERE col > 'yellow' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 065 +SELECT * FROM enumtest WHERE col >= 'yellow' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 066 +SELECT * FROM enumtest WHERE col < 'green' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 067 +SELECT * FROM enumtest WHERE col <= 'green' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 068 +|-- +-- Cast to/from text +|-- +SELECT 'red'::rainbow::text || 'hithere' +-- +STMT: SelectStmt +== 069 +SELECT 'red'::text::rainbow = 'red'::rainbow +-- +STMT: SelectStmt +== 070 +|-- +-- Aggregates +|-- +SELECT min(col) FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT max(col) FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 072 +SELECT max(col) FROM enumtest WHERE col < 'green' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 073 +|-- +-- Index tests, force use of index +|-- +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 074 +SET enable_bitmapscan = off +-- +STMT: VariableSetStmt +== 075 +|-- +-- Btree index / opclass with the various operators +|-- +CREATE UNIQUE INDEX enumtest_btree ON enumtest USING btree (col) +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DDL +STMT: IndexStmt +== 076 +SELECT * FROM enumtest WHERE col = 'orange' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 077 +SELECT * FROM enumtest WHERE col <> 'orange' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 078 +SELECT * FROM enumtest WHERE col > 'yellow' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 079 +SELECT * FROM enumtest WHERE col >= 'yellow' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 080 +SELECT * FROM enumtest WHERE col < 'green' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 081 +SELECT * FROM enumtest WHERE col <= 'green' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 082 +SELECT min(col) FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT max(col) FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 084 +SELECT max(col) FROM enumtest WHERE col < 'green' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 085 +DROP INDEX enumtest_btree +-- +STMT: DropStmt +== 086 +|-- +-- Hash index / opclass with the = operator +|-- +CREATE INDEX enumtest_hash ON enumtest USING hash (col) +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DDL +STMT: IndexStmt +== 087 +SELECT * FROM enumtest WHERE col = 'orange' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +== 088 +DROP INDEX enumtest_hash +-- +STMT: DropStmt +== 089 +|-- +-- End index tests +|-- +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 090 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 091 +|-- +-- Domains over enums +|-- +CREATE DOMAIN rgb AS rainbow CHECK (VALUE IN ('red', 'green', 'blue')) +-- +STMT: CreateDomainStmt +== 092 +SELECT 'red'::rgb +-- +STMT: SelectStmt +== 093 +SELECT 'purple'::rgb +-- +STMT: SelectStmt +== 094 +SELECT 'purple'::rainbow::rgb +-- +STMT: SelectStmt +== 095 +DROP DOMAIN rgb +-- +STMT: DropStmt +== 096 +|-- +-- Arrays +|-- +SELECT '{red,green,blue}'::rainbow[] +-- +STMT: SelectStmt +== 097 +SELECT ('{red,green,blue}'::rainbow[])[2] +-- +STMT: SelectStmt +== 098 +SELECT 'red' = ANY ('{red,green,blue}'::rainbow[]) +-- +STMT: SelectStmt +== 099 +SELECT 'yellow' = ANY ('{red,green,blue}'::rainbow[]) +-- +STMT: SelectStmt +== 100 +SELECT 'red' = ALL ('{red,green,blue}'::rainbow[]) +-- +STMT: SelectStmt +== 101 +SELECT 'red' = ALL ('{red,red}'::rainbow[]) +-- +STMT: SelectStmt +== 102 +|-- +-- Support functions +|-- +SELECT enum_first(NULL::rainbow) +-- +FUNCTION: name="enum_first" function="enum_first" schema="" ctx=Call +STMT: SelectStmt +== 103 +SELECT enum_last('green'::rainbow) +-- +FUNCTION: name="enum_last" function="enum_last" schema="" ctx=Call +STMT: SelectStmt +== 104 +SELECT enum_range(NULL::rainbow) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 105 +SELECT enum_range('orange'::rainbow, 'green'::rainbow) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 106 +SELECT enum_range(NULL, 'green'::rainbow) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 107 +SELECT enum_range('orange'::rainbow, NULL) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 108 +SELECT enum_range(NULL::rainbow, NULL) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 109 +|-- +-- User functions, can't test perl/python etc here since may not be compiled. +|-- +CREATE FUNCTION echo_me(anyenum) RETURNS text AS $$ +BEGIN +RETURN $1::text || 'omg'; +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 110 +SELECT echo_me('red'::rainbow) +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=Call +STMT: SelectStmt +== 111 +|-- +-- Concrete function should override generic one +|-- +CREATE FUNCTION echo_me(rainbow) RETURNS text AS $$ +BEGIN +RETURN $1::text || 'wtf'; +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 112 +SELECT echo_me('red'::rainbow) +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=Call +STMT: SelectStmt +== 113 +|-- +-- If we drop the original generic one, we don't have to qualify the type +-- anymore, since there's only one match +|-- +DROP FUNCTION echo_me(anyenum) +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=DDL +STMT: DropStmt +== 114 +SELECT echo_me('red') +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=Call +STMT: SelectStmt +== 115 +DROP FUNCTION echo_me(rainbow) +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=DDL +STMT: DropStmt +== 116 +|-- +-- RI triggers on enum types +|-- +CREATE TABLE enumtest_parent (id rainbow PRIMARY KEY) +-- +TABLE: name="enumtest_parent" schema="" table="enumtest_parent" ctx=DDL +STMT: CreateStmt +== 117 +CREATE TABLE enumtest_child (parent rainbow REFERENCES enumtest_parent) +-- +TABLE: name="enumtest_child" schema="" table="enumtest_child" ctx=DDL +STMT: CreateStmt +== 118 +INSERT INTO enumtest_parent VALUES ('red') +-- +TABLE: name="enumtest_parent" schema="" table="enumtest_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 119 +INSERT INTO enumtest_child VALUES ('red') +-- +TABLE: name="enumtest_child" schema="" table="enumtest_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 120 +INSERT INTO enumtest_child VALUES ('blue') +-- +TABLE: name="enumtest_child" schema="" table="enumtest_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +-- fail +DELETE FROM enumtest_parent +-- +TABLE: name="enumtest_parent" schema="" table="enumtest_parent" ctx=DML +STMT: DeleteStmt +== 122 +-- fail +|-- +-- cross-type RI should fail +|-- +CREATE TYPE bogus AS ENUM('good', 'bad', 'ugly') +-- +STMT: CreateEnumStmt +== 123 +CREATE TABLE enumtest_bogus_child(parent bogus REFERENCES enumtest_parent) +-- +TABLE: name="enumtest_bogus_child" schema="" table="enumtest_bogus_child" ctx=DDL +STMT: CreateStmt +== 124 +DROP TYPE bogus +-- +STMT: DropStmt +== 125 +-- check renaming a value +ALTER TYPE rainbow RENAME VALUE 'red' TO 'crimson' +-- +STMT: AlterEnumStmt +== 126 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'rainbow'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +== 127 +-- check that renaming a non-existent value fails +ALTER TYPE rainbow RENAME VALUE 'red' TO 'crimson' +-- +STMT: AlterEnumStmt +== 128 +-- check that renaming to an existent value fails +ALTER TYPE rainbow RENAME VALUE 'blue' TO 'green' +-- +STMT: AlterEnumStmt +== 129 +|-- +-- check transactional behaviour of ALTER TYPE ... ADD VALUE +|-- +CREATE TYPE bogus AS ENUM('good') +-- +STMT: CreateEnumStmt +== 130 +-- check that we can add new values to existing enums in a transaction +-- but we can't use them +BEGIN +-- +STMT: TransactionStmt +== 131 +ALTER TYPE bogus ADD VALUE 'new' +-- +STMT: AlterEnumStmt +== 132 +SAVEPOINT x +-- +STMT: TransactionStmt +== 133 +SELECT 'new'::bogus +-- +STMT: SelectStmt +== 134 +-- unsafe +ROLLBACK TO x +-- +STMT: TransactionStmt +== 135 +SELECT enum_first(null::bogus) +-- +FUNCTION: name="enum_first" function="enum_first" schema="" ctx=Call +STMT: SelectStmt +== 136 +-- safe +SELECT enum_last(null::bogus) +-- +FUNCTION: name="enum_last" function="enum_last" schema="" ctx=Call +STMT: SelectStmt +== 137 +-- unsafe +ROLLBACK TO x +-- +STMT: TransactionStmt +== 138 +SELECT enum_range(null::bogus) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 139 +-- unsafe +ROLLBACK TO x +-- +STMT: TransactionStmt +== 140 +COMMIT +-- +STMT: TransactionStmt +== 141 +SELECT 'new'::bogus +-- +STMT: SelectStmt +== 142 +-- now safe +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'bogus'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +== 143 +-- check that we recognize the case where the enum already existed but was +-- modified in the current txn; this should not be considered safe +BEGIN +-- +STMT: TransactionStmt +== 144 +ALTER TYPE bogus RENAME TO bogon +-- +STMT: RenameStmt +== 145 +ALTER TYPE bogon ADD VALUE 'bad' +-- +STMT: AlterEnumStmt +== 146 +SELECT 'bad'::bogon +-- +STMT: SelectStmt +== 147 +ROLLBACK +-- +STMT: TransactionStmt +== 148 +-- but a renamed value is safe to use later in same transaction +BEGIN +-- +STMT: TransactionStmt +== 149 +ALTER TYPE bogus RENAME VALUE 'good' to 'bad' +-- +STMT: AlterEnumStmt +== 150 +SELECT 'bad'::bogus +-- +STMT: SelectStmt +== 151 +ROLLBACK +-- +STMT: TransactionStmt +== 152 +DROP TYPE bogus +-- +STMT: DropStmt +== 153 +-- check that values created during CREATE TYPE can be used in any case +BEGIN +-- +STMT: TransactionStmt +== 154 +CREATE TYPE bogus AS ENUM('good','bad','ugly') +-- +STMT: CreateEnumStmt +== 155 +ALTER TYPE bogus RENAME TO bogon +-- +STMT: RenameStmt +== 156 +select enum_range(null::bogon) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 157 +ROLLBACK +-- +STMT: TransactionStmt +== 158 +-- we must allow this usage to support pg_dump in binary upgrade mode +BEGIN +-- +STMT: TransactionStmt +== 159 +CREATE TYPE bogus AS ENUM('good') +-- +STMT: CreateEnumStmt +== 160 +ALTER TYPE bogus RENAME TO bogon +-- +STMT: RenameStmt +== 161 +ALTER TYPE bogon ADD VALUE 'bad' +-- +STMT: AlterEnumStmt +== 162 +ALTER TYPE bogon ADD VALUE 'ugly' +-- +STMT: AlterEnumStmt +== 163 +select enum_range(null::bogon) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +== 164 +ROLLBACK +-- +STMT: TransactionStmt +== 165 +|-- +-- Cleanup +|-- +DROP TABLE enumtest_child +-- +TABLE: name="enumtest_child" schema="" table="enumtest_child" ctx=DDL +STMT: DropStmt +== 166 +DROP TABLE enumtest_parent +-- +TABLE: name="enumtest_parent" schema="" table="enumtest_parent" ctx=DDL +STMT: DropStmt +== 167 +DROP TABLE enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DDL +STMT: DropStmt +== 168 +DROP TYPE rainbow +-- +STMT: DropStmt +== 169 +|-- +-- Verify properly cleaned up +|-- +SELECT COUNT(*) FROM pg_type WHERE typname = 'rainbow' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +== 170 +SELECT * FROM pg_enum WHERE NOT EXISTS + (SELECT 1 FROM pg_type WHERE pg_type.oid = enumtypid) +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="pg_type" column="oid" +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/equivclass.metadata.json b/parser/testdata/summary/postgres_regress/equivclass.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/equivclass.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/equivclass.test b/parser/testdata/summary/postgres_regress/equivclass.test new file mode 100644 index 0000000..f1e0b15 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/equivclass.test @@ -0,0 +1,640 @@ +== 001 +|-- +-- Tests for the planner's "equivalence class" mechanism +|-- + +-- One thing that's not tested well during normal querying is the logic +-- for handling "broken" ECs. This is because an EC can only become broken +-- if its underlying btree operator family doesn't include a complete set +-- of cross-type equality operators. There are not (and should not be) +-- any such families built into Postgres; so we have to hack things up +-- to create one. We do this by making two alias types that are really +-- int8 (so we need no new C code) and adding only some operators for them +-- into the standard integer_ops opfamily. + +create type int8alias1 +-- +STMT: DefineStmt +== 002 +create function int8alias1in(cstring) returns int8alias1 + strict immutable language internal as 'int8in' +-- +FUNCTION: name="int8alias1in" function="int8alias1in" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +create function int8alias1out(int8alias1) returns cstring + strict immutable language internal as 'int8out' +-- +FUNCTION: name="int8alias1out" function="int8alias1out" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 004 +create type int8alias1 ( + input = int8alias1in, + output = int8alias1out, + like = int8 +) +-- +STMT: DefineStmt +== 005 +create type int8alias2 +-- +STMT: DefineStmt +== 006 +create function int8alias2in(cstring) returns int8alias2 + strict immutable language internal as 'int8in' +-- +FUNCTION: name="int8alias2in" function="int8alias2in" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 007 +create function int8alias2out(int8alias2) returns cstring + strict immutable language internal as 'int8out' +-- +FUNCTION: name="int8alias2out" function="int8alias2out" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 008 +create type int8alias2 ( + input = int8alias2in, + output = int8alias2out, + like = int8 +) +-- +STMT: DefineStmt +== 009 +create cast (int8 as int8alias1) without function +-- +STMT: CreateCastStmt +== 010 +create cast (int8 as int8alias2) without function +-- +STMT: CreateCastStmt +== 011 +create cast (int8alias1 as int8) without function +-- +STMT: CreateCastStmt +== 012 +create cast (int8alias2 as int8) without function +-- +STMT: CreateCastStmt +== 013 +create function int8alias1eq(int8alias1, int8alias1) returns bool + strict immutable language internal as 'int8eq' +-- +FUNCTION: name="int8alias1eq" function="int8alias1eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 014 +create operator = ( + procedure = int8alias1eq, + leftarg = int8alias1, rightarg = int8alias1, + commutator = =, + restrict = eqsel, join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +== 015 +alter operator family integer_ops using btree add + operator 3 = (int8alias1, int8alias1) +-- +STMT: AlterOpFamilyStmt +== 016 +create function int8alias2eq(int8alias2, int8alias2) returns bool + strict immutable language internal as 'int8eq' +-- +FUNCTION: name="int8alias2eq" function="int8alias2eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 017 +create operator = ( + procedure = int8alias2eq, + leftarg = int8alias2, rightarg = int8alias2, + commutator = =, + restrict = eqsel, join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +== 018 +alter operator family integer_ops using btree add + operator 3 = (int8alias2, int8alias2) +-- +STMT: AlterOpFamilyStmt +== 019 +create function int8alias1eq(int8, int8alias1) returns bool + strict immutable language internal as 'int8eq' +-- +FUNCTION: name="int8alias1eq" function="int8alias1eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 020 +create operator = ( + procedure = int8alias1eq, + leftarg = int8, rightarg = int8alias1, + restrict = eqsel, join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +== 021 +alter operator family integer_ops using btree add + operator 3 = (int8, int8alias1) +-- +STMT: AlterOpFamilyStmt +== 022 +create function int8alias1eq(int8alias1, int8alias2) returns bool + strict immutable language internal as 'int8eq' +-- +FUNCTION: name="int8alias1eq" function="int8alias1eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 023 +create operator = ( + procedure = int8alias1eq, + leftarg = int8alias1, rightarg = int8alias2, + restrict = eqsel, join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +== 024 +alter operator family integer_ops using btree add + operator 3 = (int8alias1, int8alias2) +-- +STMT: AlterOpFamilyStmt +== 025 +create function int8alias1lt(int8alias1, int8alias1) returns bool + strict immutable language internal as 'int8lt' +-- +FUNCTION: name="int8alias1lt" function="int8alias1lt" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 026 +create operator < ( + procedure = int8alias1lt, + leftarg = int8alias1, rightarg = int8alias1 +) +-- +STMT: DefineStmt +== 027 +alter operator family integer_ops using btree add + operator 1 < (int8alias1, int8alias1) +-- +STMT: AlterOpFamilyStmt +== 028 +create function int8alias1cmp(int8, int8alias1) returns int + strict immutable language internal as 'btint8cmp' +-- +FUNCTION: name="int8alias1cmp" function="int8alias1cmp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +alter operator family integer_ops using btree add + function 1 int8alias1cmp (int8, int8alias1) +-- +STMT: AlterOpFamilyStmt +== 030 +create table ec0 (ff int8 primary key, f1 int8, f2 int8) +-- +TABLE: name="ec0" schema="" table="ec0" ctx=DDL +STMT: CreateStmt +== 031 +create table ec1 (ff int8 primary key, f1 int8alias1, f2 int8alias2) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: CreateStmt +== 032 +create table ec2 (xf int8 primary key, x1 int8alias1, x2 int8alias2) +-- +TABLE: name="ec2" schema="" table="ec2" ctx=DDL +STMT: CreateStmt +== 033 +-- for the moment we only want to look at nestloop plans +set enable_hashjoin = off +-- +STMT: VariableSetStmt +== 034 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +== 035 +|-- +-- Note that for cases where there's a missing operator, we don't care so +-- much whether the plan is ideal as that we don't fail or generate an +-- outright incorrect plan. +|-- + +explain (costs off) + select * from ec0 where ff = f1 and f1 = '42'::int8 +-- +TABLE: name="ec0" schema="" table="ec0" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 036 +explain (costs off) + select * from ec0 where ff = f1 and f1 = '42'::int8alias1 +-- +TABLE: name="ec0" schema="" table="ec0" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 037 +explain (costs off) + select * from ec1 where ff = f1 and f1 = '42'::int8alias1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 038 +explain (costs off) + select * from ec1 where ff = f1 and f1 = '42'::int8alias2 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 039 +explain (costs off) + select * from ec1, ec2 where ff = x1 and ff = '42'::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 040 +explain (costs off) + select * from ec1, ec2 where ff = x1 and ff = '42'::int8alias1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 041 +explain (costs off) + select * from ec1, ec2 where ff = x1 and '42'::int8 = x1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="x1" +STMT: ExplainStmt +STMT: SelectStmt +== 042 +explain (costs off) + select * from ec1, ec2 where ff = x1 and x1 = '42'::int8alias1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="x1" +STMT: ExplainStmt +STMT: SelectStmt +== 043 +explain (costs off) + select * from ec1, ec2 where ff = x1 and x1 = '42'::int8alias2 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="x1" +STMT: ExplainStmt +STMT: SelectStmt +== 044 +create unique index ec1_expr1 on ec1((ff + 1)) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: IndexStmt +== 045 +create unique index ec1_expr2 on ec1((ff + 2 + 1)) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: IndexStmt +== 046 +create unique index ec1_expr3 on ec1((ff + 3 + 1)) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: IndexStmt +== 047 +create unique index ec1_expr4 on ec1((ff + 4)) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: IndexStmt +== 048 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1 + where ss1.x = ec1.f1 and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 049 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1 + where ss1.x = ec1.f1 and ec1.ff = 42::int8 and ec1.ff = ec1.f1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ec1" column="ff" +FILTER: schema="" table="ec1" column="ff" +FILTER: schema="" table="ec1" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 050 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss2 + where ss1.x = ec1.f1 and ss1.x = ss2.x and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ss2" column="x" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 051 +-- let's try that as a mergejoin +set enable_mergejoin = on +-- +STMT: VariableSetStmt +== 052 +set enable_nestloop = off +-- +STMT: VariableSetStmt +== 053 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss2 + where ss1.x = ec1.f1 and ss1.x = ss2.x and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ss2" column="x" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 054 +-- check partially indexed scan +set enable_nestloop = on +-- +STMT: VariableSetStmt +== 055 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +== 056 +drop index ec1_expr3 +-- +STMT: DropStmt +== 057 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1 + where ss1.x = ec1.f1 and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 058 +-- let's try that as a mergejoin +set enable_mergejoin = on +-- +STMT: VariableSetStmt +== 059 +set enable_nestloop = off +-- +STMT: VariableSetStmt +== 060 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1 + where ss1.x = ec1.f1 and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 061 +-- check effects of row-level security +set enable_nestloop = on +-- +STMT: VariableSetStmt +== 062 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +== 063 +alter table ec1 enable row level security +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: AlterTableStmt +== 064 +create policy p1 on ec1 using (f1 < '5'::int8alias1) +-- +STMT: CreatePolicyStmt +== 065 +create user regress_user_ectest +-- +STMT: CreateRoleStmt +== 066 +grant select on ec0 to regress_user_ectest +-- +TABLE: name="ec0" schema="" table="ec0" ctx=DDL +STMT: GrantStmt +== 067 +grant select on ec1 to regress_user_ectest +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: GrantStmt +== 068 +-- without any RLS, we'll treat {a.ff, b.ff, 43} as an EquivalenceClass +explain (costs off) + select * from ec0 a, ec1 b + where a.ff = b.ff and a.ff = 43::bigint::int8alias1 +-- +TABLE: name="ec0" schema="" table="ec0" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +ALIAS: "a"="ec0" +ALIAS: "b"="ec1" +FILTER: schema="" table="a" column="ff" +FILTER: schema="" table="b" column="ff" +FILTER: schema="" table="a" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 069 +set session authorization regress_user_ectest +-- +STMT: VariableSetStmt +== 070 +-- with RLS active, the non-leakproof a.ff = 43 clause is not treated +-- as a suitable source for an EquivalenceClass; currently, this is true +-- even though the RLS clause has nothing to do directly with the EC +explain (costs off) + select * from ec0 a, ec1 b + where a.ff = b.ff and a.ff = 43::bigint::int8alias1 +-- +TABLE: name="ec0" schema="" table="ec0" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +ALIAS: "a"="ec0" +ALIAS: "b"="ec1" +FILTER: schema="" table="a" column="ff" +FILTER: schema="" table="b" column="ff" +FILTER: schema="" table="a" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +== 071 +reset session authorization +-- +STMT: VariableSetStmt +== 072 +revoke select on ec0 from regress_user_ectest +-- +TABLE: name="ec0" schema="" table="ec0" ctx=DDL +STMT: GrantStmt +== 073 +revoke select on ec1 from regress_user_ectest +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: GrantStmt +== 074 +drop user regress_user_ectest +-- +STMT: DropRoleStmt +== 075 +-- check that X=X is converted to X IS NOT NULL when appropriate +explain (costs off) + select * from tenk1 where unique1 = unique1 and unique2 = unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 076 +-- this could be converted, but isn't at present +explain (costs off) + select * from tenk1 where unique1 = unique1 or unique2 = unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 077 +-- check that we recognize equivalence with dummy domains in the way +create temp table undername (f1 name, f2 int) +-- +TABLE: name="undername" schema="" table="undername" ctx=DDL +STMT: CreateStmt +== 078 +create temp view overview as + select f1::information_schema.sql_identifier as sqli, f2 from undername +-- +TABLE: name="overview" schema="" table="overview" ctx=DDL +TABLE: name="undername" schema="" table="undername" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 079 +explain (costs off) -- this should not require a sort + select * from overview where sqli = 'foo' order by sqli +-- +TABLE: name="overview" schema="" table="overview" ctx=Select +FILTER: schema="" table="" column="sqli" +STMT: ExplainStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/errors.metadata.json b/parser/testdata/summary/postgres_regress/errors.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/errors.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/errors.test b/parser/testdata/summary/postgres_regress/errors.test new file mode 100644 index 0000000..5cdae13 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/errors.test @@ -0,0 +1,666 @@ +== 001 +|-- +-- ERRORS +|-- + +-- bad in postquel, but ok in PostgreSQL +select 1 +-- +STMT: SelectStmt +== 002 +|-- +-- UNSUPPORTED STUFF + +-- doesn't work +-- notify pg_class +|-- + +|-- +-- SELECT + +-- this used to be a syntax error, but now we allow an empty target list +select +-- +STMT: SelectStmt +== 003 +-- no such relation +select * from nonesuch +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=Select +STMT: SelectStmt +== 004 +-- bad name in target list +select nonesuch from pg_database +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +STMT: SelectStmt +== 005 +-- empty distinct list isn't OK +select distinct from pg_database +-- +ERROR: syntax error at or near "from" +CURSORPOS: 49 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +-- bad attribute name on lhs of operator +select * from pg_database where nonesuch = pg_database.datname +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FILTER: schema="" table="" column="nonesuch" +FILTER: schema="" table="pg_database" column="datname" +STMT: SelectStmt +== 007 +-- bad attribute name on rhs of operator +select * from pg_database where pg_database.datname = nonesuch +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FILTER: schema="" table="pg_database" column="datname" +FILTER: schema="" table="" column="nonesuch" +STMT: SelectStmt +== 008 +-- bad attribute name in select distinct on +select distinct on (foobar) * from pg_database +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +STMT: SelectStmt +== 009 +-- grouping with FOR UPDATE +select null from pg_database group by datname for update +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +STMT: SelectStmt +== 010 +select null from pg_database group by grouping sets (()) for update +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +STMT: SelectStmt +== 011 +|-- +-- DELETE + +-- missing relation name (this had better not wildcard!) +delete from +-- +ERROR: syntax error at end of input +CURSORPOS: 83 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +-- no such relation +delete from nonesuch +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=DML +STMT: DeleteStmt +== 013 +|-- +-- DROP + +-- missing relation name (this had better not wildcard!) +drop table +-- +ERROR: syntax error at end of input +CURSORPOS: 80 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 014 +-- no such relation +drop table nonesuch +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=DDL +STMT: DropStmt +== 015 +|-- +-- ALTER TABLE + +-- relation renaming + +-- missing relation name +alter table rename +-- +ERROR: syntax error at end of input +CURSORPOS: 85 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 016 +-- no such relation +alter table nonesuch rename to newnonesuch +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=DDL +TABLE: name="newnonesuch" schema="" table="newnonesuch" ctx=DDL +STMT: RenameStmt +== 017 +-- no such relation +alter table nonesuch rename to stud_emp +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=DDL +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: RenameStmt +== 018 +-- conflict +alter table stud_emp rename to student +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +TABLE: name="student" schema="" table="student" ctx=DDL +STMT: RenameStmt +== 019 +-- self-conflict +alter table stud_emp rename to stud_emp +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: RenameStmt +== 020 +-- attribute renaming + +-- no such relation +alter table nonesuchrel rename column nonesuchatt to newnonesuchatt +-- +STMT: RenameStmt +== 021 +-- no such attribute +alter table emp rename column nonesuchatt to newnonesuchatt +-- +STMT: RenameStmt +== 022 +-- conflict +alter table emp rename column salary to manager +-- +STMT: RenameStmt +== 023 +-- conflict +alter table emp rename column salary to ctid +-- +STMT: RenameStmt +== 024 +|-- +-- TRANSACTION STUFF + +-- not in a xact +abort +-- +STMT: TransactionStmt +== 025 +-- not in a xact +end +-- +STMT: TransactionStmt +== 026 +|-- +-- CREATE AGGREGATE + +-- sfunc/finalfunc type disagreement +create aggregate newavg2 (sfunc = int4pl, + basetype = int4, + stype = int4, + finalfunc = int2um, + initcond = '0') +-- +STMT: DefineStmt +== 027 +-- left out basetype +create aggregate newcnt1 (sfunc = int4inc, + stype = int4, + initcond = '0') +-- +STMT: DefineStmt +== 028 +|-- +-- DROP INDEX + +-- missing index name +drop index +-- +ERROR: syntax error at end of input +CURSORPOS: 51 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 029 +-- bad index name +drop index 314159 +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 030 +-- no such index +drop index nonesuch +-- +STMT: DropStmt +== 031 +|-- +-- DROP AGGREGATE + +-- missing aggregate name +drop aggregate +-- +ERROR: syntax error at end of input +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 032 +-- missing aggregate type +drop aggregate newcnt1 +-- +ERROR: syntax error at end of input +CURSORPOS: 49 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 033 +-- bad aggregate name +drop aggregate 314159 (int) +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 034 +-- bad aggregate type +drop aggregate newcnt (nonesuch) +-- +STMT: DropStmt +== 035 +-- no such aggregate +drop aggregate nonesuch (int4) +-- +STMT: DropStmt +== 036 +-- no such aggregate for type +drop aggregate newcnt (float4) +-- +STMT: DropStmt +== 037 +|-- +-- DROP FUNCTION + +-- missing function name +drop function () +-- +ERROR: syntax error at or near "(" +CURSORPOS: 61 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 038 +-- bad function name +drop function 314159() +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 039 +-- no such function +drop function nonesuch() +-- +FUNCTION: name="nonesuch" function="nonesuch" schema="" ctx=DDL +STMT: DropStmt +== 040 +|-- +-- DROP TYPE + +-- missing type name +drop type +-- +ERROR: syntax error at end of input +CURSORPOS: 48 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 041 +-- bad type name +drop type 314159 +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 042 +-- no such type +drop type nonesuch +-- +STMT: DropStmt +== 043 +|-- +-- DROP OPERATOR + +-- missing everything +drop operator +-- +ERROR: syntax error at end of input +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 044 +-- bad operator name +drop operator equals +-- +ERROR: syntax error at end of input +CURSORPOS: 42 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 045 +-- missing type list +drop operator === +-- +ERROR: syntax error at end of input +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 046 +-- missing parentheses +drop operator int4, int4 +-- +ERROR: syntax error at or near "," +CURSORPOS: 42 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 047 +-- missing operator name +drop operator (int4, int4) +-- +ERROR: syntax error at or near "(" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 048 +-- missing type list contents +drop operator === () +-- +ERROR: syntax error at or near ")" +CURSORPOS: 50 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 049 +-- no such operator +drop operator === (int4) +-- +ERROR: missing argument +CURSORPOS: 44 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 050 +-- no such operator by that name +drop operator === (int4, int4) +-- +STMT: DropStmt +== 051 +-- no such type1 +drop operator = (nonesuch) +-- +ERROR: missing argument +CURSORPOS: 43 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 052 +-- no such type1 +drop operator = ( , int4) +-- +ERROR: syntax error at or near "," +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 053 +-- no such type1 +drop operator = (nonesuch, int4) +-- +STMT: DropStmt +== 054 +-- no such type2 +drop operator = (int4, nonesuch) +-- +STMT: DropStmt +== 055 +-- no such type2 +drop operator = (int4, ) +-- +ERROR: syntax error at or near ")" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 056 +|-- +-- DROP RULE + +-- missing rule name +drop rule +-- +ERROR: syntax error at end of input +CURSORPOS: 48 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 057 +-- bad rule name +drop rule 314159 +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 058 +-- no such rule +drop rule nonesuch on noplace +-- +TABLE: name="noplace" schema="" table="noplace" ctx=DDL +STMT: DropStmt +== 059 +-- these postquel variants are no longer supported +drop tuple rule nonesuch +-- +ERROR: syntax error at or near "tuple" +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 060 +drop instance rule nonesuch on noplace +-- +ERROR: syntax error at or near "instance" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 061 +drop rewrite rule nonesuch +-- +ERROR: syntax error at or near "rewrite" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 062 +|-- +-- Check that division-by-zero is properly caught. +|-- + +select 1/0 +-- +STMT: SelectStmt +== 063 +select 1::int8/0 +-- +STMT: SelectStmt +== 064 +select 1/0::int8 +-- +STMT: SelectStmt +== 065 +select 1::int2/0 +-- +STMT: SelectStmt +== 066 +select 1/0::int2 +-- +STMT: SelectStmt +== 067 +select 1::numeric/0 +-- +STMT: SelectStmt +== 068 +select 1/0::numeric +-- +STMT: SelectStmt +== 069 +select 1::float8/0 +-- +STMT: SelectStmt +== 070 +select 1/0::float8 +-- +STMT: SelectStmt +== 071 +select 1::float4/0 +-- +STMT: SelectStmt +== 072 +select 1/0::float4 +-- +STMT: SelectStmt +== 073 +CREATE foo +-- +ERROR: syntax error at or near "foo" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 074 +CREATE TABLE +-- +ERROR: syntax error at end of input +CURSORPOS: 13 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 075 +CREATE TABLE + +INSERT INTO foo VALUES(123) foo +-- +ERROR: syntax error at or near "INTO" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 076 +INSERT INTO 123 +VALUES(123) +-- +ERROR: syntax error at or near "123" +CURSORPOS: 13 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 077 +INSERT INTO foo +VALUES(123) 123 +-- +ERROR: syntax error at or near "123" +CURSORPOS: 29 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 078 +-- with a tab +CREATE TABLE foo + (id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, + id3 INTEGER NOT NUL, + id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 108 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 079 +-- long line to be truncated on the left +CREATE TABLE foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, +id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 131 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 080 +-- long line to be truncated on the right +CREATE TABLE foo( +id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 77 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 081 +-- long line to be truncated both ways +CREATE TABLE foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 129 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 082 +-- long line to be truncated on the left, many lines +CREATE +TEMPORARY +TABLE +foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, +id4 INT4 +UNIQUE +NOT +NULL, +id5 TEXT +UNIQUE +NOT +NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 153 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 083 +-- long line to be truncated on the right, many lines +CREATE +TEMPORARY +TABLE +foo( +id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 99 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 084 +-- long line to be truncated both ways, many lines +CREATE +TEMPORARY +TABLE +foo +(id +INT4 +UNIQUE NOT NULL, idx INT4 UNIQUE NOT NULL, idy INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, +idz INT4 UNIQUE NOT NULL, +idv INT4 UNIQUE NOT NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 204 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 085 +-- more than 10 lines... +CREATE +TEMPORARY +TABLE +foo +(id +INT4 +UNIQUE +NOT +NULL +, +idm +INT4 +UNIQUE +NOT +NULL, +idx INT4 UNIQUE NOT NULL, idy INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, +idz INT4 UNIQUE NOT NULL, +idv +INT4 +UNIQUE +NOT +NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 205 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary/postgres_regress/event_trigger.metadata.json b/parser/testdata/summary/postgres_regress/event_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/event_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/event_trigger.test b/parser/testdata/summary/postgres_regress/event_trigger.test new file mode 100644 index 0000000..74d9f8f --- /dev/null +++ b/parser/testdata/summary/postgres_regress/event_trigger.test @@ -0,0 +1,1367 @@ +== 001 +-- should fail, return type mismatch +create event trigger regress_event_trigger + on ddl_command_start + execute procedure pg_backend_pid() +-- +STMT: CreateEventTrigStmt +== 002 +-- OK +create function test_event_trigger() returns event_trigger as $$ +BEGIN + RAISE NOTICE 'test_event_trigger: % %', tg_event, tg_tag; +END +$$ language plpgsql +-- +FUNCTION: name="test_event_trigger" function="test_event_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +-- should fail, can't call it as a plain function +SELECT test_event_trigger() +-- +FUNCTION: name="test_event_trigger" function="test_event_trigger" schema="" ctx=Call +STMT: SelectStmt +== 004 +-- should fail, event triggers cannot have declared arguments +create function test_event_trigger_arg(name text) +returns event_trigger as $$ BEGIN RETURN 1; END $$ language plpgsql +-- +FUNCTION: name="test_event_trigger_arg" function="test_event_trigger_arg" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 005 +-- should fail, SQL functions cannot be event triggers +create function test_event_trigger_sql() returns event_trigger as $$ +SELECT 1 $$ language sql +-- +FUNCTION: name="test_event_trigger_sql" function="test_event_trigger_sql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +-- should fail, no elephant_bootstrap entry point +create event trigger regress_event_trigger on elephant_bootstrap + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 007 +-- OK +create event trigger regress_event_trigger on ddl_command_start + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 008 +-- OK +create event trigger regress_event_trigger_end on ddl_command_end + execute function test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 009 +-- should fail, food is not a valid filter variable +create event trigger regress_event_trigger2 on ddl_command_start + when food in ('sandwich') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 010 +-- should fail, sandwich is not a valid command tag +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('sandwich') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 011 +-- should fail, create skunkcabbage is not a valid command tag +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('create table', 'create skunkcabbage') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 012 +-- should fail, can't have event triggers on event triggers +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('DROP EVENT TRIGGER') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 013 +-- should fail, can't have event triggers on global objects +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('CREATE ROLE') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 014 +-- should fail, can't have event triggers on global objects +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('CREATE DATABASE') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 015 +-- should fail, can't have event triggers on global objects +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('CREATE TABLESPACE') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 016 +-- should fail, can't have same filter variable twice +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('create table') and tag in ('CREATE FUNCTION') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 017 +-- should fail, can't have arguments +create event trigger regress_event_trigger2 on ddl_command_start + execute procedure test_event_trigger('argument not allowed') +-- +ERROR: syntax error at or near "'argument not allowed'" +CURSORPOS: 143 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 018 +-- OK +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('create table', 'CREATE FUNCTION') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 019 +-- OK +comment on event trigger regress_event_trigger is 'test comment' +-- +STMT: CommentStmt +== 020 +-- drop as non-superuser should fail +create role regress_evt_user +-- +STMT: CreateRoleStmt +== 021 +set role regress_evt_user +-- +STMT: VariableSetStmt +== 022 +create event trigger regress_event_trigger_noperms on ddl_command_start + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +== 023 +reset role +-- +STMT: VariableSetStmt +== 024 +-- test enabling and disabling +alter event trigger regress_event_trigger disable +-- +STMT: AlterEventTrigStmt +== 025 +-- fires _trigger2 and _trigger_end should fire, but not _trigger +create table event_trigger_fire1 (a int) +-- +TABLE: name="event_trigger_fire1" schema="" table="event_trigger_fire1" ctx=DDL +STMT: CreateStmt +== 026 +alter event trigger regress_event_trigger enable +-- +STMT: AlterEventTrigStmt +== 027 +set session_replication_role = replica +-- +STMT: VariableSetStmt +== 028 +-- fires nothing +create table event_trigger_fire2 (a int) +-- +TABLE: name="event_trigger_fire2" schema="" table="event_trigger_fire2" ctx=DDL +STMT: CreateStmt +== 029 +alter event trigger regress_event_trigger enable replica +-- +STMT: AlterEventTrigStmt +== 030 +-- fires only _trigger +create table event_trigger_fire3 (a int) +-- +TABLE: name="event_trigger_fire3" schema="" table="event_trigger_fire3" ctx=DDL +STMT: CreateStmt +== 031 +alter event trigger regress_event_trigger enable always +-- +STMT: AlterEventTrigStmt +== 032 +-- fires only _trigger +create table event_trigger_fire4 (a int) +-- +TABLE: name="event_trigger_fire4" schema="" table="event_trigger_fire4" ctx=DDL +STMT: CreateStmt +== 033 +reset session_replication_role +-- +STMT: VariableSetStmt +== 034 +-- fires all three +create table event_trigger_fire5 (a int) +-- +TABLE: name="event_trigger_fire5" schema="" table="event_trigger_fire5" ctx=DDL +STMT: CreateStmt +== 035 +-- non-top-level command +create function f1() returns int +language plpgsql +as $$ +begin + create table event_trigger_fire6 (a int); + return 0; +end $$ +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 036 +select f1() +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- non-top-level command +create procedure p1() +language plpgsql +as $$ +begin + create table event_trigger_fire7 (a int); +end $$ +-- +FUNCTION: name="p1" function="p1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 038 +call p1() +-- +FUNCTION: name="p1" function="p1" schema="" ctx=Call +STMT: CallStmt +== 039 +-- clean up +alter event trigger regress_event_trigger disable +-- +STMT: AlterEventTrigStmt +== 040 +drop table event_trigger_fire2, event_trigger_fire3, event_trigger_fire4, event_trigger_fire5, event_trigger_fire6, event_trigger_fire7 +-- +TABLE: name="event_trigger_fire2" schema="" table="event_trigger_fire2" ctx=DDL +TABLE: name="event_trigger_fire3" schema="" table="event_trigger_fire3" ctx=DDL +TABLE: name="event_trigger_fire4" schema="" table="event_trigger_fire4" ctx=DDL +TABLE: name="event_trigger_fire5" schema="" table="event_trigger_fire5" ctx=DDL +TABLE: name="event_trigger_fire6" schema="" table="event_trigger_fire6" ctx=DDL +TABLE: name="event_trigger_fire7" schema="" table="event_trigger_fire7" ctx=DDL +STMT: DropStmt +== 041 +drop routine f1(), p1() +-- +STMT: DropStmt +== 042 +-- regress_event_trigger_end should fire on these commands +grant all on table event_trigger_fire1 to public +-- +TABLE: name="event_trigger_fire1" schema="" table="event_trigger_fire1" ctx=DDL +STMT: GrantStmt +== 043 +comment on table event_trigger_fire1 is 'here is a comment' +-- +STMT: CommentStmt +== 044 +revoke all on table event_trigger_fire1 from public +-- +TABLE: name="event_trigger_fire1" schema="" table="event_trigger_fire1" ctx=DDL +STMT: GrantStmt +== 045 +drop table event_trigger_fire1 +-- +TABLE: name="event_trigger_fire1" schema="" table="event_trigger_fire1" ctx=DDL +STMT: DropStmt +== 046 +create foreign data wrapper useless +-- +STMT: CreateFdwStmt +== 047 +create server useless_server foreign data wrapper useless +-- +STMT: CreateForeignServerStmt +== 048 +create user mapping for regress_evt_user server useless_server +-- +STMT: CreateUserMappingStmt +== 049 +alter default privileges for role regress_evt_user + revoke delete on tables from regress_evt_user +-- +STMT: AlterDefaultPrivilegesStmt +== 050 +-- alter owner to non-superuser should fail +alter event trigger regress_event_trigger owner to regress_evt_user +-- +STMT: AlterOwnerStmt +== 051 +-- alter owner to superuser should work +alter role regress_evt_user superuser +-- +STMT: AlterRoleStmt +== 052 +alter event trigger regress_event_trigger owner to regress_evt_user +-- +STMT: AlterOwnerStmt +== 053 +-- should fail, name collision +alter event trigger regress_event_trigger rename to regress_event_trigger2 +-- +STMT: RenameStmt +== 054 +-- OK +alter event trigger regress_event_trigger rename to regress_event_trigger3 +-- +STMT: RenameStmt +== 055 +-- should fail, doesn't exist any more +drop event trigger regress_event_trigger +-- +STMT: DropStmt +== 056 +-- should fail, regress_evt_user owns some objects +drop role regress_evt_user +-- +STMT: DropRoleStmt +== 057 +-- cleanup before next test +-- these are all OK; the second one should emit a NOTICE +drop event trigger if exists regress_event_trigger2 +-- +STMT: DropStmt +== 058 +drop event trigger if exists regress_event_trigger2 +-- +STMT: DropStmt +== 059 +drop event trigger regress_event_trigger3 +-- +STMT: DropStmt +== 060 +drop event trigger regress_event_trigger_end +-- +STMT: DropStmt +== 061 +-- test support for dropped objects +CREATE SCHEMA schema_one authorization regress_evt_user +-- +STMT: CreateSchemaStmt +== 062 +CREATE SCHEMA schema_two authorization regress_evt_user +-- +STMT: CreateSchemaStmt +== 063 +CREATE SCHEMA audit_tbls authorization regress_evt_user +-- +STMT: CreateSchemaStmt +== 064 +CREATE TEMP TABLE a_temp_tbl () +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: CreateStmt +== 065 +SET SESSION AUTHORIZATION regress_evt_user +-- +STMT: VariableSetStmt +== 066 +CREATE TABLE schema_one.table_one(a int) +-- +TABLE: name="schema_one.table_one" schema="schema_one" table="table_one" ctx=DDL +STMT: CreateStmt +== 067 +CREATE TABLE schema_one."table two"(a int) +-- +TABLE: name="schema_one.\"table two\"" schema="schema_one" table="table two" ctx=DDL +STMT: CreateStmt +== 068 +CREATE TABLE schema_one.table_three(a int) +-- +TABLE: name="schema_one.table_three" schema="schema_one" table="table_three" ctx=DDL +STMT: CreateStmt +== 069 +CREATE TABLE audit_tbls.schema_one_table_two(the_value text) +-- +TABLE: name="audit_tbls.schema_one_table_two" schema="audit_tbls" table="schema_one_table_two" ctx=DDL +STMT: CreateStmt +== 070 +CREATE TABLE schema_two.table_two(a int) +-- +TABLE: name="schema_two.table_two" schema="schema_two" table="table_two" ctx=DDL +STMT: CreateStmt +== 071 +CREATE TABLE schema_two.table_three(a int, b text) +-- +TABLE: name="schema_two.table_three" schema="schema_two" table="table_three" ctx=DDL +STMT: CreateStmt +== 072 +CREATE TABLE audit_tbls.schema_two_table_three(the_value text) +-- +TABLE: name="audit_tbls.schema_two_table_three" schema="audit_tbls" table="schema_two_table_three" ctx=DDL +STMT: CreateStmt +== 073 +CREATE OR REPLACE FUNCTION schema_two.add(int, int) RETURNS int LANGUAGE plpgsql + CALLED ON NULL INPUT + AS $$ BEGIN RETURN coalesce($1,0) + coalesce($2,0); END; $$ +-- +FUNCTION: name="schema_two.add" function="add" schema="schema_two" ctx=DDL +STMT: CreateFunctionStmt +== 074 +CREATE AGGREGATE schema_two.newton + (BASETYPE = int, SFUNC = schema_two.add, STYPE = int) +-- +STMT: DefineStmt +== 075 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 076 +CREATE TABLE undroppable_objs ( + object_type text, + object_identity text +) +-- +TABLE: name="undroppable_objs" schema="" table="undroppable_objs" ctx=DDL +STMT: CreateStmt +== 077 +INSERT INTO undroppable_objs VALUES +('table', 'schema_one.table_three'), +('table', 'audit_tbls.schema_two_table_three') +-- +TABLE: name="undroppable_objs" schema="" table="undroppable_objs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +CREATE TABLE dropped_objects ( + object_type text, + schema_name text, + object_name text, + object_identity text, + address_names text[], + address_args text[], + is_temporary bool, + original bool, + normal bool +) +-- +TABLE: name="dropped_objects" schema="" table="dropped_objects" ctx=DDL +STMT: CreateStmt +== 079 +-- This tests errors raised within event triggers; the one in audit_tbls +-- uses 2nd-level recursive invocation via test_evtrig_dropped_objects(). +CREATE OR REPLACE FUNCTION undroppable() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +DECLARE + obj record; +BEGIN + PERFORM 1 FROM pg_tables WHERE tablename = 'undroppable_objs'; + IF NOT FOUND THEN + RAISE NOTICE 'table undroppable_objs not found, skipping'; + RETURN; + END IF; + FOR obj IN + SELECT * FROM pg_event_trigger_dropped_objects() JOIN + undroppable_objs USING (object_type, object_identity) + LOOP + RAISE EXCEPTION 'object % of type % cannot be dropped', + obj.object_identity, obj.object_type; + END LOOP; +END; +$$ +-- +FUNCTION: name="undroppable" function="undroppable" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 080 +CREATE EVENT TRIGGER undroppable ON sql_drop + EXECUTE PROCEDURE undroppable() +-- +STMT: CreateEventTrigStmt +== 081 +CREATE OR REPLACE FUNCTION test_evtrig_dropped_objects() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +DECLARE + obj record; +BEGIN + FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects() + LOOP + IF obj.object_type = 'table' THEN + EXECUTE format('DROP TABLE IF EXISTS audit_tbls.%I', + format('%s_%s', obj.schema_name, obj.object_name)); + END IF; + + INSERT INTO dropped_objects + (object_type, schema_name, object_name, + object_identity, address_names, address_args, + is_temporary, original, normal) VALUES + (obj.object_type, obj.schema_name, obj.object_name, + obj.object_identity, obj.address_names, obj.address_args, + obj.is_temporary, obj.original, obj.normal); + END LOOP; +END +$$ +-- +FUNCTION: name="test_evtrig_dropped_objects" function="test_evtrig_dropped_objects" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 082 +CREATE EVENT TRIGGER regress_event_trigger_drop_objects ON sql_drop + WHEN TAG IN ('drop table', 'drop function', 'drop view', + 'drop owned', 'drop schema', 'alter table') + EXECUTE PROCEDURE test_evtrig_dropped_objects() +-- +STMT: CreateEventTrigStmt +== 083 +ALTER TABLE schema_one.table_one DROP COLUMN a +-- +TABLE: name="schema_one.table_one" schema="schema_one" table="table_one" ctx=DDL +STMT: AlterTableStmt +== 084 +DROP SCHEMA schema_one, schema_two CASCADE +-- +STMT: DropStmt +== 085 +DELETE FROM undroppable_objs WHERE object_identity = 'audit_tbls.schema_two_table_three' +-- +TABLE: name="undroppable_objs" schema="" table="undroppable_objs" ctx=DML +STMT: DeleteStmt +== 086 +DROP SCHEMA schema_one, schema_two CASCADE +-- +STMT: DropStmt +== 087 +DELETE FROM undroppable_objs WHERE object_identity = 'schema_one.table_three' +-- +TABLE: name="undroppable_objs" schema="" table="undroppable_objs" ctx=DML +STMT: DeleteStmt +== 088 +DROP SCHEMA schema_one, schema_two CASCADE +-- +STMT: DropStmt +== 089 +-- exclude TOAST objects because they have unstable names +SELECT * FROM dropped_objects + WHERE schema_name IS NULL OR schema_name <> 'pg_toast' +-- +TABLE: name="dropped_objects" schema="" table="dropped_objects" ctx=Select +FILTER: schema="" table="" column="schema_name" +FILTER: schema="" table="" column="schema_name" +STMT: SelectStmt +== 090 +DROP OWNED BY regress_evt_user +-- +STMT: DropOwnedStmt +== 091 +SELECT * FROM dropped_objects WHERE object_type = 'schema' +-- +TABLE: name="dropped_objects" schema="" table="dropped_objects" ctx=Select +FILTER: schema="" table="" column="object_type" +STMT: SelectStmt +== 092 +DROP ROLE regress_evt_user +-- +STMT: DropRoleStmt +== 093 +DROP EVENT TRIGGER regress_event_trigger_drop_objects +-- +STMT: DropStmt +== 094 +DROP EVENT TRIGGER undroppable +-- +STMT: DropStmt +== 095 +-- Event triggers on relations. +CREATE OR REPLACE FUNCTION event_trigger_report_dropped() + RETURNS event_trigger + LANGUAGE plpgsql +AS $$ +DECLARE r record; +BEGIN + FOR r IN SELECT * from pg_event_trigger_dropped_objects() + LOOP + IF NOT r.normal AND NOT r.original THEN + CONTINUE; + END IF; + RAISE NOTICE 'NORMAL: orig=% normal=% istemp=% type=% identity=% schema=% name=% addr=% args=%', + r.original, r.normal, r.is_temporary, r.object_type, + r.object_identity, r.schema_name, r.object_name, + r.address_names, r.address_args; + END LOOP; +END; $$ +-- +FUNCTION: name="event_trigger_report_dropped" function="event_trigger_report_dropped" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 096 +CREATE EVENT TRIGGER regress_event_trigger_report_dropped ON sql_drop + EXECUTE PROCEDURE event_trigger_report_dropped() +-- +STMT: CreateEventTrigStmt +== 097 +CREATE OR REPLACE FUNCTION event_trigger_report_end() + RETURNS event_trigger + LANGUAGE plpgsql +AS $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT * FROM pg_event_trigger_ddl_commands() + LOOP + RAISE NOTICE 'END: command_tag=% type=% identity=%', + r.command_tag, r.object_type, r.object_identity; + END LOOP; +END; $$ +-- +FUNCTION: name="event_trigger_report_end" function="event_trigger_report_end" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 098 +CREATE EVENT TRIGGER regress_event_trigger_report_end ON ddl_command_end + EXECUTE PROCEDURE event_trigger_report_end() +-- +STMT: CreateEventTrigStmt +== 099 +CREATE SCHEMA evttrig + CREATE TABLE one (col_a SERIAL PRIMARY KEY, col_b text DEFAULT 'forty two', col_c SERIAL) + CREATE INDEX one_idx ON one (col_b) + CREATE TABLE two (col_c INTEGER CHECK (col_c > 0) REFERENCES one DEFAULT 42) + CREATE TABLE id (col_d int NOT NULL GENERATED ALWAYS AS IDENTITY) +-- +STMT: CreateSchemaStmt +== 100 +-- Partitioned tables with a partitioned index +CREATE TABLE evttrig.parted ( + id int PRIMARY KEY) + PARTITION BY RANGE (id) +-- +TABLE: name="evttrig.parted" schema="evttrig" table="parted" ctx=DDL +STMT: CreateStmt +== 101 +CREATE TABLE evttrig.part_1_10 PARTITION OF evttrig.parted (id) + FOR VALUES FROM (1) TO (10) +-- +TABLE: name="evttrig.part_1_10" schema="evttrig" table="part_1_10" ctx=DDL +STMT: CreateStmt +== 102 +CREATE TABLE evttrig.part_10_20 PARTITION OF evttrig.parted (id) + FOR VALUES FROM (10) TO (20) PARTITION BY RANGE (id) +-- +TABLE: name="evttrig.part_10_20" schema="evttrig" table="part_10_20" ctx=DDL +STMT: CreateStmt +== 103 +CREATE TABLE evttrig.part_10_15 PARTITION OF evttrig.part_10_20 (id) + FOR VALUES FROM (10) TO (15) +-- +TABLE: name="evttrig.part_10_15" schema="evttrig" table="part_10_15" ctx=DDL +STMT: CreateStmt +== 104 +CREATE TABLE evttrig.part_15_20 PARTITION OF evttrig.part_10_20 (id) + FOR VALUES FROM (15) TO (20) +-- +TABLE: name="evttrig.part_15_20" schema="evttrig" table="part_15_20" ctx=DDL +STMT: CreateStmt +== 105 +ALTER TABLE evttrig.two DROP COLUMN col_c +-- +TABLE: name="evttrig.two" schema="evttrig" table="two" ctx=DDL +STMT: AlterTableStmt +== 106 +ALTER TABLE evttrig.one ALTER COLUMN col_b DROP DEFAULT +-- +TABLE: name="evttrig.one" schema="evttrig" table="one" ctx=DDL +STMT: AlterTableStmt +== 107 +ALTER TABLE evttrig.one DROP CONSTRAINT one_pkey +-- +TABLE: name="evttrig.one" schema="evttrig" table="one" ctx=DDL +STMT: AlterTableStmt +== 108 +ALTER TABLE evttrig.one DROP COLUMN col_c +-- +TABLE: name="evttrig.one" schema="evttrig" table="one" ctx=DDL +STMT: AlterTableStmt +== 109 +ALTER TABLE evttrig.id ALTER COLUMN col_d SET DATA TYPE bigint +-- +TABLE: name="evttrig.id" schema="evttrig" table="id" ctx=DDL +STMT: AlterTableStmt +== 110 +ALTER TABLE evttrig.id ALTER COLUMN col_d DROP IDENTITY, + ALTER COLUMN col_d SET DATA TYPE int +-- +TABLE: name="evttrig.id" schema="evttrig" table="id" ctx=DDL +STMT: AlterTableStmt +== 111 +DROP INDEX evttrig.one_idx +-- +STMT: DropStmt +== 112 +DROP SCHEMA evttrig CASCADE +-- +STMT: DropStmt +== 113 +DROP TABLE a_temp_tbl +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: DropStmt +== 114 +-- check unfiltered results, too +CREATE OR REPLACE FUNCTION event_trigger_report_dropped() + RETURNS event_trigger + LANGUAGE plpgsql +AS $$ +DECLARE r record; +BEGIN + FOR r IN SELECT * from pg_event_trigger_dropped_objects() + LOOP + RAISE NOTICE 'DROP: orig=% normal=% istemp=% type=% identity=% schema=% name=% addr=% args=%', + r.original, r.normal, r.is_temporary, r.object_type, + r.object_identity, r.schema_name, r.object_name, + r.address_names, r.address_args; + END LOOP; +END; $$ +-- +FUNCTION: name="event_trigger_report_dropped" function="event_trigger_report_dropped" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 115 +CREATE FUNCTION event_trigger_dummy_trigger() + RETURNS trigger + LANGUAGE plpgsql +AS $$ +BEGIN + RETURN new; +END; $$ +-- +FUNCTION: name="event_trigger_dummy_trigger" function="event_trigger_dummy_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 116 +CREATE TABLE evtrg_nontemp_table (f1 int primary key, f2 int default 42) +-- +TABLE: name="evtrg_nontemp_table" schema="" table="evtrg_nontemp_table" ctx=DDL +STMT: CreateStmt +== 117 +CREATE TRIGGER evtrg_nontemp_trig + BEFORE INSERT ON evtrg_nontemp_table + EXECUTE FUNCTION event_trigger_dummy_trigger() +-- +TABLE: name="evtrg_nontemp_table" schema="" table="evtrg_nontemp_table" ctx=DDL +STMT: CreateTrigStmt +== 118 +CREATE POLICY evtrg_nontemp_pol ON evtrg_nontemp_table USING (f2 > 0) +-- +STMT: CreatePolicyStmt +== 119 +DROP TABLE evtrg_nontemp_table +-- +TABLE: name="evtrg_nontemp_table" schema="" table="evtrg_nontemp_table" ctx=DDL +STMT: DropStmt +== 120 +CREATE TEMP TABLE a_temp_tbl (f1 int primary key, f2 int default 42) +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: CreateStmt +== 121 +CREATE TRIGGER a_temp_trig + BEFORE INSERT ON a_temp_tbl + EXECUTE FUNCTION event_trigger_dummy_trigger() +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: CreateTrigStmt +== 122 +CREATE POLICY a_temp_pol ON a_temp_tbl USING (f2 > 0) +-- +STMT: CreatePolicyStmt +== 123 +DROP TABLE a_temp_tbl +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: DropStmt +== 124 +DROP FUNCTION event_trigger_dummy_trigger() +-- +FUNCTION: name="event_trigger_dummy_trigger" function="event_trigger_dummy_trigger" schema="" ctx=DDL +STMT: DropStmt +== 125 +-- CREATE OPERATOR CLASS without FAMILY clause should report +-- both CREATE OPERATOR FAMILY and CREATE OPERATOR CLASS +CREATE OPERATOR CLASS evttrigopclass FOR TYPE int USING btree AS STORAGE int +-- +STMT: CreateOpClassStmt +== 126 +DROP EVENT TRIGGER regress_event_trigger_report_dropped +-- +STMT: DropStmt +== 127 +DROP EVENT TRIGGER regress_event_trigger_report_end +-- +STMT: DropStmt +== 128 +-- only allowed from within an event trigger function, should fail +select pg_event_trigger_table_rewrite_oid() +-- +FUNCTION: name="pg_event_trigger_table_rewrite_oid" function="pg_event_trigger_table_rewrite_oid" schema="" ctx=Call +STMT: SelectStmt +== 129 +-- test Table Rewrite Event Trigger +CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE EXCEPTION 'rewrites not allowed'; +END; +$$ +-- +FUNCTION: name="test_evtrig_no_rewrite" function="test_evtrig_no_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 130 +create event trigger no_rewrite_allowed on table_rewrite + execute procedure test_evtrig_no_rewrite() +-- +STMT: CreateEventTrigStmt +== 131 +create table rewriteme (id serial primary key, foo float, bar timestamptz) +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: CreateStmt +== 132 +insert into rewriteme + select x * 1.001 from generate_series(1, 500) as t(x) +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 133 +alter table rewriteme alter column foo type numeric +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +== 134 +alter table rewriteme add column baz int default 0 +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +== 135 +-- test with more than one reason to rewrite a single table +CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'Table ''%'' is being rewritten (reason = %)', + pg_event_trigger_table_rewrite_oid()::regclass, + pg_event_trigger_table_rewrite_reason(); +END; +$$ +-- +FUNCTION: name="test_evtrig_no_rewrite" function="test_evtrig_no_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 136 +alter table rewriteme + add column onemore int default 0, + add column another int default -1, + alter column foo type numeric(10,4) +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +== 137 +-- matview rewrite when changing access method +CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT 1 AS a +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 138 +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2 +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +STMT: AlterTableStmt +== 139 +DROP MATERIALIZED VIEW heapmv +-- +STMT: DropStmt +== 140 +-- shouldn't trigger a table_rewrite event +alter table rewriteme alter column foo type numeric(12,4) +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +== 141 +begin +-- +STMT: TransactionStmt +== 142 +set timezone to 'UTC' +-- +STMT: VariableSetStmt +== 143 +alter table rewriteme alter column bar type timestamp +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +== 144 +set timezone to '0' +-- +STMT: VariableSetStmt +== 145 +alter table rewriteme alter column bar type timestamptz +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +== 146 +set timezone to 'Europe/London' +-- +STMT: VariableSetStmt +== 147 +alter table rewriteme alter column bar type timestamp +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +== 148 +-- does rewrite +rollback +-- +STMT: TransactionStmt +== 149 +-- typed tables are rewritten when their type changes. Don't emit table +-- name, because firing order is not stable. +CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'Table is being rewritten (reason = %)', + pg_event_trigger_table_rewrite_reason(); +END; +$$ +-- +FUNCTION: name="test_evtrig_no_rewrite" function="test_evtrig_no_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 150 +create type rewritetype as (a int) +-- +STMT: CompositeTypeStmt +== 151 +create table rewritemetoo1 of rewritetype +-- +TABLE: name="rewritemetoo1" schema="" table="rewritemetoo1" ctx=DDL +STMT: CreateStmt +== 152 +create table rewritemetoo2 of rewritetype +-- +TABLE: name="rewritemetoo2" schema="" table="rewritemetoo2" ctx=DDL +STMT: CreateStmt +== 153 +alter type rewritetype alter attribute a type text cascade +-- +TABLE: name="rewritetype" schema="" table="rewritetype" ctx=DDL +STMT: AlterTableStmt +== 154 +-- but this doesn't work +create table rewritemetoo3 (a rewritetype) +-- +TABLE: name="rewritemetoo3" schema="" table="rewritemetoo3" ctx=DDL +STMT: CreateStmt +== 155 +alter type rewritetype alter attribute a type varchar cascade +-- +TABLE: name="rewritetype" schema="" table="rewritetype" ctx=DDL +STMT: AlterTableStmt +== 156 +drop table rewriteme +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: DropStmt +== 157 +drop event trigger no_rewrite_allowed +-- +STMT: DropStmt +== 158 +drop function test_evtrig_no_rewrite() +-- +FUNCTION: name="test_evtrig_no_rewrite" function="test_evtrig_no_rewrite" schema="" ctx=DDL +STMT: DropStmt +== 159 +-- Tests for REINDEX +CREATE OR REPLACE FUNCTION reindex_start_command() +RETURNS event_trigger AS $$ +BEGIN + RAISE NOTICE 'REINDEX START: % %', tg_event, tg_tag; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="reindex_start_command" function="reindex_start_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 160 +CREATE EVENT TRIGGER regress_reindex_start ON ddl_command_start + WHEN TAG IN ('REINDEX') + EXECUTE PROCEDURE reindex_start_command() +-- +STMT: CreateEventTrigStmt +== 161 +CREATE FUNCTION reindex_end_command() +RETURNS event_trigger AS $$ +DECLARE + obj record; +BEGIN + FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() + LOOP + RAISE NOTICE 'REINDEX END: command_tag=% type=% identity=%', + obj.command_tag, obj.object_type, obj.object_identity; + END LOOP; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="reindex_end_command" function="reindex_end_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 162 +CREATE EVENT TRIGGER regress_reindex_end ON ddl_command_end + WHEN TAG IN ('REINDEX') + EXECUTE PROCEDURE reindex_end_command() +-- +STMT: CreateEventTrigStmt +== 163 +-- Extra event to force the use of a snapshot. +CREATE FUNCTION reindex_end_command_snap() RETURNS EVENT_TRIGGER + AS $$ BEGIN PERFORM 1; END $$ LANGUAGE plpgsql +-- +FUNCTION: name="reindex_end_command_snap" function="reindex_end_command_snap" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 164 +CREATE EVENT TRIGGER regress_reindex_end_snap ON ddl_command_end + EXECUTE FUNCTION reindex_end_command_snap() +-- +STMT: CreateEventTrigStmt +== 165 +-- With simple relation +CREATE TABLE concur_reindex_tab (c1 int) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: CreateStmt +== 166 +CREATE INDEX concur_reindex_ind ON concur_reindex_tab (c1) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: IndexStmt +== 167 +-- Both start and end triggers enabled. +REINDEX INDEX concur_reindex_ind +-- +STMT: ReindexStmt +== 168 +REINDEX TABLE concur_reindex_tab +-- +STMT: ReindexStmt +== 169 +REINDEX INDEX CONCURRENTLY concur_reindex_ind +-- +STMT: ReindexStmt +== 170 +REINDEX TABLE CONCURRENTLY concur_reindex_tab +-- +STMT: ReindexStmt +== 171 +-- with start trigger disabled. +ALTER EVENT TRIGGER regress_reindex_start DISABLE +-- +STMT: AlterEventTrigStmt +== 172 +REINDEX INDEX concur_reindex_ind +-- +STMT: ReindexStmt +== 173 +REINDEX INDEX CONCURRENTLY concur_reindex_ind +-- +STMT: ReindexStmt +== 174 +-- without an index +DROP INDEX concur_reindex_ind +-- +STMT: DropStmt +== 175 +REINDEX TABLE concur_reindex_tab +-- +STMT: ReindexStmt +== 176 +REINDEX TABLE CONCURRENTLY concur_reindex_tab +-- +STMT: ReindexStmt +== 177 +-- With a Schema +CREATE SCHEMA concur_reindex_schema +-- +STMT: CreateSchemaStmt +== 178 +-- No indexes +REINDEX SCHEMA concur_reindex_schema +-- +STMT: ReindexStmt +== 179 +REINDEX SCHEMA CONCURRENTLY concur_reindex_schema +-- +STMT: ReindexStmt +== 180 +CREATE TABLE concur_reindex_schema.tab (a int) +-- +TABLE: name="concur_reindex_schema.tab" schema="concur_reindex_schema" table="tab" ctx=DDL +STMT: CreateStmt +== 181 +CREATE INDEX ind ON concur_reindex_schema.tab (a) +-- +TABLE: name="concur_reindex_schema.tab" schema="concur_reindex_schema" table="tab" ctx=DDL +STMT: IndexStmt +== 182 +-- One index reported +REINDEX SCHEMA concur_reindex_schema +-- +STMT: ReindexStmt +== 183 +REINDEX SCHEMA CONCURRENTLY concur_reindex_schema +-- +STMT: ReindexStmt +== 184 +-- One table on schema but no indexes +DROP INDEX concur_reindex_schema.ind +-- +STMT: DropStmt +== 185 +REINDEX SCHEMA concur_reindex_schema +-- +STMT: ReindexStmt +== 186 +REINDEX SCHEMA CONCURRENTLY concur_reindex_schema +-- +STMT: ReindexStmt +== 187 +DROP SCHEMA concur_reindex_schema CASCADE +-- +STMT: DropStmt +== 188 +-- With a partitioned table, and nothing else. +CREATE TABLE concur_reindex_part (id int) PARTITION BY RANGE (id) +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: CreateStmt +== 189 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +== 190 +REINDEX TABLE CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +== 191 +-- Partition that would be reindexed, still nothing. +CREATE TABLE concur_reindex_child PARTITION OF concur_reindex_part + FOR VALUES FROM (0) TO (10) +-- +TABLE: name="concur_reindex_child" schema="" table="concur_reindex_child" ctx=DDL +STMT: CreateStmt +== 192 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +== 193 +REINDEX TABLE CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +== 194 +-- Now add some indexes. +CREATE INDEX concur_reindex_partidx ON concur_reindex_part (id) +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: IndexStmt +== 195 +REINDEX INDEX concur_reindex_partidx +-- +STMT: ReindexStmt +== 196 +REINDEX INDEX CONCURRENTLY concur_reindex_partidx +-- +STMT: ReindexStmt +== 197 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +== 198 +REINDEX TABLE CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +== 199 +DROP TABLE concur_reindex_part +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: DropStmt +== 200 +-- Clean up +DROP EVENT TRIGGER regress_reindex_start +-- +STMT: DropStmt +== 201 +DROP EVENT TRIGGER regress_reindex_end +-- +STMT: DropStmt +== 202 +DROP EVENT TRIGGER regress_reindex_end_snap +-- +STMT: DropStmt +== 203 +DROP FUNCTION reindex_end_command() +-- +FUNCTION: name="reindex_end_command" function="reindex_end_command" schema="" ctx=DDL +STMT: DropStmt +== 204 +DROP FUNCTION reindex_end_command_snap() +-- +FUNCTION: name="reindex_end_command_snap" function="reindex_end_command_snap" schema="" ctx=DDL +STMT: DropStmt +== 205 +DROP FUNCTION reindex_start_command() +-- +FUNCTION: name="reindex_start_command" function="reindex_start_command" schema="" ctx=DDL +STMT: DropStmt +== 206 +DROP TABLE concur_reindex_tab +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: DropStmt +== 207 +-- test Row Security Event Trigger +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 208 +CREATE TABLE event_trigger_test (a integer, b text) +-- +TABLE: name="event_trigger_test" schema="" table="event_trigger_test" ctx=DDL +STMT: CreateStmt +== 209 +CREATE OR REPLACE FUNCTION start_command() +RETURNS event_trigger AS $$ +BEGIN +RAISE NOTICE '% - ddl_command_start', tg_tag; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="start_command" function="start_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 210 +CREATE OR REPLACE FUNCTION end_command() +RETURNS event_trigger AS $$ +BEGIN +RAISE NOTICE '% - ddl_command_end', tg_tag; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="end_command" function="end_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 211 +CREATE OR REPLACE FUNCTION drop_sql_command() +RETURNS event_trigger AS $$ +BEGIN +RAISE NOTICE '% - sql_drop', tg_tag; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="drop_sql_command" function="drop_sql_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 212 +CREATE EVENT TRIGGER start_rls_command ON ddl_command_start + WHEN TAG IN ('CREATE POLICY', 'ALTER POLICY', 'DROP POLICY') EXECUTE PROCEDURE start_command() +-- +STMT: CreateEventTrigStmt +== 213 +CREATE EVENT TRIGGER end_rls_command ON ddl_command_end + WHEN TAG IN ('CREATE POLICY', 'ALTER POLICY', 'DROP POLICY') EXECUTE PROCEDURE end_command() +-- +STMT: CreateEventTrigStmt +== 214 +CREATE EVENT TRIGGER sql_drop_command ON sql_drop + WHEN TAG IN ('DROP POLICY') EXECUTE PROCEDURE drop_sql_command() +-- +STMT: CreateEventTrigStmt +== 215 +CREATE POLICY p1 ON event_trigger_test USING (FALSE) +-- +STMT: CreatePolicyStmt +== 216 +ALTER POLICY p1 ON event_trigger_test USING (TRUE) +-- +STMT: AlterPolicyStmt +== 217 +ALTER POLICY p1 ON event_trigger_test RENAME TO p2 +-- +STMT: RenameStmt +== 218 +DROP POLICY p2 ON event_trigger_test +-- +STMT: DropStmt +== 219 +-- Check the object addresses of all the event triggers. +SELECT + e.evtname, + pg_describe_object('pg_event_trigger'::regclass, e.oid, 0) as descr, + b.type, b.object_names, b.object_args, + pg_identify_object(a.classid, a.objid, a.objsubid) as ident + FROM pg_event_trigger as e, + LATERAL pg_identify_object_as_address('pg_event_trigger'::regclass, e.oid, 0) as b, + LATERAL pg_get_object_address(b.type, b.object_names, b.object_args) as a + ORDER BY e.evtname +-- +TABLE: name="pg_event_trigger" schema="" table="pg_event_trigger" ctx=Select +ALIAS: "e"="pg_event_trigger" +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object_as_address" function="pg_identify_object_as_address" schema="" ctx=Call +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 220 +DROP EVENT TRIGGER start_rls_command +-- +STMT: DropStmt +== 221 +DROP EVENT TRIGGER end_rls_command +-- +STMT: DropStmt +== 222 +DROP EVENT TRIGGER sql_drop_command +-- +STMT: DropStmt +== 223 +-- Check the GUC for disabling event triggers +CREATE FUNCTION test_event_trigger_guc() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +DECLARE + obj record; +BEGIN + FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects() + LOOP + RAISE NOTICE '% dropped %', tg_tag, obj.object_type; + END LOOP; +END; +$$ +-- +FUNCTION: name="test_event_trigger_guc" function="test_event_trigger_guc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 224 +CREATE EVENT TRIGGER test_event_trigger_guc + ON sql_drop + WHEN TAG IN ('DROP POLICY') EXECUTE FUNCTION test_event_trigger_guc() +-- +STMT: CreateEventTrigStmt +== 225 +SET event_triggers = 'on' +-- +STMT: VariableSetStmt +== 226 +CREATE POLICY pguc ON event_trigger_test USING (FALSE) +-- +STMT: CreatePolicyStmt +== 227 +DROP POLICY pguc ON event_trigger_test +-- +STMT: DropStmt +== 228 +CREATE POLICY pguc ON event_trigger_test USING (FALSE) +-- +STMT: CreatePolicyStmt +== 229 +SET event_triggers = 'off' +-- +STMT: VariableSetStmt +== 230 +DROP POLICY pguc ON event_trigger_test +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/event_trigger_login.metadata.json b/parser/testdata/summary/postgres_regress/event_trigger_login.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/event_trigger_login.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/event_trigger_login.test b/parser/testdata/summary/postgres_regress/event_trigger_login.test new file mode 100644 index 0000000..dafce96 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/event_trigger_login.test @@ -0,0 +1,64 @@ +== 001 +-- Login event triggers +CREATE TABLE user_logins(id serial, who text) +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=DDL +STMT: CreateStmt +== 002 +GRANT SELECT ON user_logins TO public +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=DDL +STMT: GrantStmt +== 003 +CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$ +BEGIN + INSERT INTO user_logins (who) VALUES (SESSION_USER); + RAISE NOTICE 'You are welcome!'; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="on_login_proc" function="on_login_proc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 004 +CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc() +-- +STMT: CreateEventTrigStmt +== 005 +ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS +-- +STMT: AlterEventTrigStmt +== 006 +SELECT COUNT(*) FROM user_logins +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT COUNT(*) FROM user_logins +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- Check dathasloginevt in system catalog +SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 97 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- Cleanup +DROP TABLE user_logins +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=DDL +STMT: DropStmt +== 010 +DROP EVENT TRIGGER on_login_trigger +-- +STMT: DropStmt +== 011 +DROP FUNCTION on_login_proc() +-- +FUNCTION: name="on_login_proc" function="on_login_proc" schema="" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/explain.metadata.json b/parser/testdata/summary/postgres_regress/explain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/explain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/explain.test b/parser/testdata/summary/postgres_regress/explain.test new file mode 100644 index 0000000..67e4d53 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/explain.test @@ -0,0 +1,348 @@ +== 001 +|-- +-- EXPLAIN +|-- +-- There are many test cases elsewhere that use EXPLAIN as a vehicle for +-- checking something else (usually planner behavior). This file is +-- concerned with testing EXPLAIN in its own right. +|-- + +-- To produce stable regression test output, it's usually necessary to +-- ignore details such as exact costs or row counts. These filter +-- functions replace changeable output details with fixed strings. + +create function explain_filter(text) returns setof text +language plpgsql as +$$ +declare + ln text; +begin + for ln in execute $1 + loop + -- Replace any numeric word with just 'N' + ln := regexp_replace(ln, '-?\m\d+\M', 'N', 'g'); + -- In sort output, the above won't match units-suffixed numbers + ln := regexp_replace(ln, '\m\d+kB', 'NkB', 'g'); + -- Ignore text-mode buffers output because it varies depending + -- on the system state + CONTINUE WHEN (ln ~ ' +Buffers: .*'); + -- Ignore text-mode "Planning:" line because whether it's output + -- varies depending on the system state + CONTINUE WHEN (ln = 'Planning:'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +-- To produce valid JSON output, replace numbers with "0" or "0.0" not "N" +create function explain_filter_to_json(text) returns jsonb +language plpgsql as +$$ +declare + data text := ''; + ln text; +begin + for ln in execute $1 + loop + -- Replace any numeric word with just '0' + ln := regexp_replace(ln, '\m\d+\M', '0', 'g'); + data := data || ln; + end loop; + return data::jsonb; +end; +$$ +-- +FUNCTION: name="explain_filter_to_json" function="explain_filter_to_json" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 003 +-- Disable JIT, or we'll get different output on machines where that's been +-- forced on +set jit = off +-- +STMT: VariableSetStmt +== 004 +-- Similarly, disable track_io_timing, to avoid output differences when +-- enabled. +set track_io_timing = off +-- +STMT: VariableSetStmt +== 005 +-- Simple cases + +select explain_filter('explain select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 006 +select explain_filter('explain (analyze) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 007 +select explain_filter('explain (analyze, verbose) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 008 +select explain_filter('explain (analyze, buffers, format text) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 009 +select explain_filter('explain (analyze, buffers, format xml) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 010 +select explain_filter('explain (analyze, serialize, buffers, format yaml) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 011 +select explain_filter('explain (buffers, format text) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 012 +select explain_filter('explain (buffers, format json) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- Check output including I/O timings. These fields are conditional +-- but always set in JSON format, so check them only in this case. +set track_io_timing = on +-- +STMT: VariableSetStmt +== 014 +select explain_filter('explain (analyze, buffers, format json) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 015 +set track_io_timing = off +-- +STMT: VariableSetStmt +== 016 +-- SETTINGS option +-- We have to ignore other settings that might be imposed by the environment, +-- so printing the whole Settings field unfortunately won't do. + +begin +-- +STMT: TransactionStmt +== 017 +set local plan_cache_mode = force_generic_plan +-- +STMT: VariableSetStmt +== 018 +select true as "OK" + from explain_filter('explain (settings) select * from int8_tbl i8') ln + where ln ~ '^ *Settings: .*plan_cache_mode = ''force_generic_plan''' +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +FILTER: schema="" table="" column="ln" +STMT: SelectStmt +== 019 +select explain_filter_to_json('explain (settings, format json) select * from int8_tbl i8') #> '{0,Settings,plan_cache_mode}' +-- +FUNCTION: name="explain_filter_to_json" function="explain_filter_to_json" schema="" ctx=Call +STMT: SelectStmt +== 020 +rollback +-- +STMT: TransactionStmt +== 021 +-- GENERIC_PLAN option + +select explain_filter('explain (generic_plan) select unique1 from tenk1 where thousand = $1') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- should fail +select explain_filter('explain (analyze, generic_plan) select unique1 from tenk1 where thousand = $1') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 023 +-- MEMORY option +select explain_filter('explain (memory) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 024 +select explain_filter('explain (memory, analyze) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 025 +select explain_filter('explain (memory, summary, format yaml) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 026 +select explain_filter('explain (memory, analyze, format json) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 027 +prepare int8_query as select * from int8_tbl i8 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +STMT: PrepareStmt +STMT: SelectStmt +== 028 +select explain_filter('explain (memory) execute int8_query') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 029 +-- Test EXPLAIN (GENERIC_PLAN) with partition pruning +-- partitions should be pruned at plan time, based on constants, +-- but there should be no pruning based on parameter placeholders +create table gen_part ( + key1 integer not null, + key2 integer not null +) partition by list (key1) +-- +TABLE: name="gen_part" schema="" table="gen_part" ctx=DDL +STMT: CreateStmt +== 030 +create table gen_part_1 + partition of gen_part for values in (1) + partition by range (key2) +-- +TABLE: name="gen_part_1" schema="" table="gen_part_1" ctx=DDL +STMT: CreateStmt +== 031 +create table gen_part_1_1 + partition of gen_part_1 for values from (1) to (2) +-- +TABLE: name="gen_part_1_1" schema="" table="gen_part_1_1" ctx=DDL +STMT: CreateStmt +== 032 +create table gen_part_1_2 + partition of gen_part_1 for values from (2) to (3) +-- +TABLE: name="gen_part_1_2" schema="" table="gen_part_1_2" ctx=DDL +STMT: CreateStmt +== 033 +create table gen_part_2 + partition of gen_part for values in (2) +-- +TABLE: name="gen_part_2" schema="" table="gen_part_2" ctx=DDL +STMT: CreateStmt +== 034 +-- should scan gen_part_1_1 and gen_part_1_2, but not gen_part_2 +select explain_filter('explain (generic_plan) select key1, key2 from gen_part where key1 = 1 and key2 = $1') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 035 +drop table gen_part +-- +TABLE: name="gen_part" schema="" table="gen_part" ctx=DDL +STMT: DropStmt +== 036 +|-- +-- Test production of per-worker data +|-- +-- Unfortunately, because we don't know how many worker processes we'll +-- actually get (maybe none at all), we can't examine the "Workers" output +-- in any detail. We can check that it parses correctly as JSON, and then +-- remove it from the displayed results. + +begin +-- +STMT: TransactionStmt +== 037 +-- encourage use of parallel plans +set parallel_setup_cost=0 +-- +STMT: VariableSetStmt +== 038 +set parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +== 039 +set min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +== 040 +set max_parallel_workers_per_gather=4 +-- +STMT: VariableSetStmt +== 041 +select jsonb_pretty( + explain_filter_to_json('explain (analyze, verbose, buffers, format json) + select * from tenk1 order by tenthous') + -- remove "Workers" node of the Seq Scan plan node + #- '{0,Plan,Plans,0,Plans,0,Workers}' + -- remove "Workers" node of the Sort plan node + #- '{0,Plan,Plans,0,Workers}' + -- Also remove its sort-type fields, as those aren't 100% stable + #- '{0,Plan,Plans,0,Sort Method}' + #- '{0,Plan,Plans,0,Sort Space Type}' +) +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +FUNCTION: name="explain_filter_to_json" function="explain_filter_to_json" schema="" ctx=Call +STMT: SelectStmt +== 042 +rollback +-- +STMT: TransactionStmt +== 043 +-- Test display of temporary objects +create temp table t1(f1 float8) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 044 +create function pg_temp.mysin(float8) returns float8 language plpgsql +as 'begin return sin($1); end' +-- +FUNCTION: name="pg_temp.mysin" function="mysin" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +== 045 +select explain_filter('explain (verbose) select * from t1 where pg_temp.mysin(f1) < 0.5') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 046 +-- Test compute_query_id +set compute_query_id = on +-- +STMT: VariableSetStmt +== 047 +select explain_filter('explain (verbose) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 048 +-- Test SERIALIZE option +select explain_filter('explain (analyze,serialize) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 049 +select explain_filter('explain (analyze,serialize text,buffers,timing off) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 050 +select explain_filter('explain (analyze,serialize binary,buffers,timing) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +== 051 +-- this tests an edge case where we have no data to return +select explain_filter('explain (analyze,serialize) create temp table explain_temp as select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/expressions.metadata.json b/parser/testdata/summary/postgres_regress/expressions.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/expressions.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/expressions.test b/parser/testdata/summary/postgres_regress/expressions.test new file mode 100644 index 0000000..fb4afa8 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/expressions.test @@ -0,0 +1,452 @@ +== 001 +|-- +-- expression evaluation tests that don't fit into a more specific file +|-- + +|-- +-- Tests for SQLValueFunction +|-- + + +-- current_date (always matches because of transactional behaviour) +SELECT date(now())::text = current_date::text +-- +FUNCTION: name="date" function="date" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 002 +-- current_time / localtime +SELECT now()::timetz::text = current_time::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 003 +SELECT now()::timetz(4)::text = current_time(4)::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT now()::time::text = localtime::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT now()::time(3)::text = localtime(3)::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 006 +-- current_time[stamp]/ localtime[stamp] (always matches because of transactional behaviour) +SELECT current_timestamp = NOW() +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- precision +SELECT length(current_timestamp::text) >= length(current_timestamp(0)::text) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- localtimestamp +SELECT now()::timestamp::text = localtimestamp::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- precision overflow +SELECT current_time = current_time(7) +-- +STMT: SelectStmt +== 010 +SELECT current_timestamp = current_timestamp(7) +-- +STMT: SelectStmt +== 011 +SELECT localtime = localtime(7) +-- +STMT: SelectStmt +== 012 +SELECT localtimestamp = localtimestamp(7) +-- +STMT: SelectStmt +== 013 +-- current_role/user/user is tested in rolenames.sql + +-- current database / catalog +SELECT current_catalog = current_database() +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- current_schema +SELECT current_schema +-- +STMT: SelectStmt +== 015 +SET search_path = 'notme' +-- +STMT: VariableSetStmt +== 016 +SELECT current_schema +-- +STMT: SelectStmt +== 017 +SET search_path = 'pg_catalog' +-- +STMT: VariableSetStmt +== 018 +SELECT current_schema +-- +STMT: SelectStmt +== 019 +RESET search_path +-- +STMT: VariableSetStmt +== 020 +|-- +-- Test parsing of a no-op cast to a type with unspecified typmod +|-- +begin +-- +STMT: TransactionStmt +== 021 +create table numeric_tbl (f1 numeric(18,3), f2 numeric) +-- +TABLE: name="numeric_tbl" schema="" table="numeric_tbl" ctx=DDL +STMT: CreateStmt +== 022 +create view numeric_view as + select + f1, f1::numeric(16,4) as f1164, f1::numeric as f1n, + f2, f2::numeric(16,4) as f2164, f2::numeric as f2n + from numeric_tbl +-- +TABLE: name="numeric_view" schema="" table="numeric_view" ctx=DDL +TABLE: name="numeric_tbl" schema="" table="numeric_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 023 +explain (verbose, costs off) select * from numeric_view +-- +TABLE: name="numeric_view" schema="" table="numeric_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 024 +-- bpchar, lacking planner support for its length coercion function, +-- could behave differently + +create table bpchar_tbl (f1 character(16) unique, f2 bpchar) +-- +TABLE: name="bpchar_tbl" schema="" table="bpchar_tbl" ctx=DDL +STMT: CreateStmt +== 025 +create view bpchar_view as + select + f1, f1::character(14) as f114, f1::bpchar as f1n, + f2, f2::character(14) as f214, f2::bpchar as f2n + from bpchar_tbl +-- +TABLE: name="bpchar_view" schema="" table="bpchar_view" ctx=DDL +TABLE: name="bpchar_tbl" schema="" table="bpchar_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 026 +explain (verbose, costs off) select * from bpchar_view + where f1::bpchar = 'foo' +-- +TABLE: name="bpchar_view" schema="" table="bpchar_view" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 027 +rollback +-- +STMT: TransactionStmt +== 028 +|-- +-- Ordinarily, IN/NOT IN can be converted to a ScalarArrayOpExpr +-- with a suitably-chosen array type. +|-- +explain (verbose, costs off) +select random() IN (1, 4, 8.0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 029 +explain (verbose, costs off) +select random()::int IN (1, 4, 8.0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 030 +-- However, if there's not a common supertype for the IN elements, +-- we should instead try to produce "x = v1 OR x = v2 OR ...". +-- In most cases that'll fail for lack of all the requisite = operators, +-- but it can succeed sometimes. So this should complain about lack of +-- an = operator, not about cast failure. +select '(0,0)'::point in ('(0,0,0,0)'::box, point(0,0)) +-- +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 031 +|-- +-- Tests for ScalarArrayOpExpr with a hashfn +|-- + +-- create a stable function so that the tests below are not +-- evaluated using the planner's constant folding. +begin +-- +STMT: TransactionStmt +== 032 +create function return_int_input(int) returns int as $$ +begin + return $1; +end; +$$ language plpgsql stable +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 033 +create function return_text_input(text) returns text as $$ +begin + return $1; +end; +$$ language plpgsql stable +-- +FUNCTION: name="return_text_input" function="return_text_input" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 034 +select return_int_input(1) in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 035 +select return_int_input(1) in (10, 9, 2, 8, 3, 7, 4, 6, 5, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 036 +select return_int_input(1) in (null, null, null, null, null, null, null, null, null, null, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 037 +select return_int_input(1) in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 038 +select return_int_input(null::int) in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 039 +select return_int_input(null::int) in (10, 9, 2, 8, 3, 7, 4, 6, 5, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 040 +select return_text_input('a') in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j') +-- +FUNCTION: name="return_text_input" function="return_text_input" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- NOT IN +select return_int_input(1) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 042 +select return_int_input(1) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 0) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 043 +select return_int_input(1) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 2, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 044 +select return_int_input(1) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 045 +select return_int_input(1) not in (null, null, null, null, null, null, null, null, null, null, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 046 +select return_int_input(null::int) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 047 +select return_int_input(null::int) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +== 048 +select return_text_input('a') not in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j') +-- +FUNCTION: name="return_text_input" function="return_text_input" schema="" ctx=Call +STMT: SelectStmt +== 049 +rollback +-- +STMT: TransactionStmt +== 050 +-- Test with non-strict equality function. +-- We need to create our own type for this. + +begin +-- +STMT: TransactionStmt +== 051 +create type myint +-- +STMT: DefineStmt +== 052 +create function myintin(cstring) returns myint strict immutable language + internal as 'int4in' +-- +FUNCTION: name="myintin" function="myintin" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 053 +create function myintout(myint) returns cstring strict immutable language + internal as 'int4out' +-- +FUNCTION: name="myintout" function="myintout" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 054 +create function myinthash(myint) returns integer strict immutable language + internal as 'hashint4' +-- +FUNCTION: name="myinthash" function="myinthash" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 055 +create type myint (input = myintin, output = myintout, like = int4) +-- +STMT: DefineStmt +== 056 +create cast (int4 as myint) without function +-- +STMT: CreateCastStmt +== 057 +create cast (myint as int4) without function +-- +STMT: CreateCastStmt +== 058 +create function myinteq(myint, myint) returns bool as $$ +begin + if $1 is null and $2 is null then + return true; + else + return $1::int = $2::int; + end if; +end; +$$ language plpgsql immutable +-- +FUNCTION: name="myinteq" function="myinteq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 059 +create function myintne(myint, myint) returns bool as $$ +begin + return not myinteq($1, $2); +end; +$$ language plpgsql immutable +-- +FUNCTION: name="myintne" function="myintne" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 060 +create operator = ( + leftarg = myint, + rightarg = myint, + commutator = =, + negator = <>, + procedure = myinteq, + restrict = eqsel, + join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +== 061 +create operator <> ( + leftarg = myint, + rightarg = myint, + commutator = <>, + negator = =, + procedure = myintne, + restrict = eqsel, + join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +== 062 +create operator class myint_ops +default for type myint using hash as + operator 1 = (myint, myint), + function 1 myinthash(myint) +-- +STMT: CreateOpClassStmt +== 063 +create table inttest (a myint) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=DDL +STMT: CreateStmt +== 064 +insert into inttest values(1::myint),(null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +-- try an array with enough elements to cause hashing +select * from inttest where a in (1::myint,2::myint,3::myint,4::myint,5::myint,6::myint,7::myint,8::myint,9::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 066 +select * from inttest where a not in (1::myint,2::myint,3::myint,4::myint,5::myint,6::myint,7::myint,8::myint,9::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 067 +select * from inttest where a not in (0::myint,2::myint,3::myint,4::myint,5::myint,6::myint,7::myint,8::myint,9::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 068 +-- ensure the result matched with the non-hashed version. We simply remove +-- some array elements so that we don't reach the hashing threshold. +select * from inttest where a in (1::myint,2::myint,3::myint,4::myint,5::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 069 +select * from inttest where a not in (1::myint,2::myint,3::myint,4::myint,5::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 070 +select * from inttest where a not in (0::myint,2::myint,3::myint,4::myint,5::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 071 +rollback +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/fast_default.metadata.json b/parser/testdata/summary/postgres_regress/fast_default.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/fast_default.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/fast_default.test b/parser/testdata/summary/postgres_regress/fast_default.test new file mode 100644 index 0000000..3489d36 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/fast_default.test @@ -0,0 +1,1617 @@ +== 001 +|-- +-- ALTER TABLE ADD COLUMN DEFAULT test +|-- + +SET search_path = fast_default +-- +STMT: VariableSetStmt +== 002 +CREATE SCHEMA fast_default +-- +STMT: CreateSchemaStmt +== 003 +CREATE TABLE m(id OID) +-- +TABLE: name="m" schema="" table="m" ctx=DDL +STMT: CreateStmt +== 004 +INSERT INTO m VALUES (NULL::OID) +-- +TABLE: name="m" schema="" table="m" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +CREATE FUNCTION set(tabname name) RETURNS VOID +AS $$ +BEGIN + UPDATE m + SET id = (SELECT c.relfilenode + FROM pg_class AS c, pg_namespace AS s + WHERE c.relname = tabname + AND c.relnamespace = s.oid + AND s.nspname = 'fast_default'); +END; +$$ LANGUAGE 'plpgsql' +-- +FUNCTION: name="set" function="set" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +CREATE FUNCTION comp() RETURNS TEXT +AS $$ +BEGIN + RETURN (SELECT CASE + WHEN m.id = c.relfilenode THEN 'Unchanged' + ELSE 'Rewritten' + END + FROM m, pg_class AS c, pg_namespace AS s + WHERE c.relname = 't' + AND c.relnamespace = s.oid + AND s.nspname = 'fast_default'); +END; +$$ LANGUAGE 'plpgsql' +-- +FUNCTION: name="comp" function="comp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 007 +CREATE FUNCTION log_rewrite() RETURNS event_trigger +LANGUAGE plpgsql as +$func$ + +declare + this_schema text; +begin + select into this_schema relnamespace::regnamespace::text + from pg_class + where oid = pg_event_trigger_table_rewrite_oid(); + if this_schema = 'fast_default' + then + RAISE NOTICE 'rewriting table % for reason %', + pg_event_trigger_table_rewrite_oid()::regclass, + pg_event_trigger_table_rewrite_reason(); + end if; +end; +$func$ +-- +FUNCTION: name="log_rewrite" function="log_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 008 +CREATE TABLE has_volatile AS +SELECT * FROM generate_series(1,10) id +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 009 +CREATE EVENT TRIGGER has_volatile_rewrite + ON table_rewrite + EXECUTE PROCEDURE log_rewrite() +-- +STMT: CreateEventTrigStmt +== 010 +-- only the last of these should trigger a rewrite +ALTER TABLE has_volatile ADD col1 int +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: AlterTableStmt +== 011 +ALTER TABLE has_volatile ADD col2 int DEFAULT 1 +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: AlterTableStmt +== 012 +ALTER TABLE has_volatile ADD col3 timestamptz DEFAULT current_timestamp +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: AlterTableStmt +== 013 +ALTER TABLE has_volatile ADD col4 int DEFAULT (random() * 10000)::int +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: AlterTableStmt +== 014 +-- Test a large sample of different datatypes +CREATE TABLE T(pk INT NOT NULL PRIMARY KEY, c_int INT DEFAULT 1) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 015 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +== 016 +INSERT INTO T VALUES (1), (2) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +ALTER TABLE T ADD COLUMN c_bpchar BPCHAR(5) DEFAULT 'hello', + ALTER COLUMN c_int SET DEFAULT 2 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 018 +INSERT INTO T VALUES (3), (4) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT 'world', + ALTER COLUMN c_bpchar SET DEFAULT 'dog' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 020 +INSERT INTO T VALUES (5), (6) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +ALTER TABLE T ADD COLUMN c_date DATE DEFAULT '2016-06-02', + ALTER COLUMN c_text SET DEFAULT 'cat' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 022 +INSERT INTO T VALUES (7), (8) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +ALTER TABLE T ADD COLUMN c_timestamp TIMESTAMP DEFAULT '2016-09-01 12:00:00', + ADD COLUMN c_timestamp_null TIMESTAMP, + ALTER COLUMN c_date SET DEFAULT '2010-01-01' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 024 +INSERT INTO T VALUES (9), (10) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +ALTER TABLE T ADD COLUMN c_array TEXT[] + DEFAULT '{"This", "is", "the", "real", "world"}', + ALTER COLUMN c_timestamp SET DEFAULT '1970-12-31 11:12:13', + ALTER COLUMN c_timestamp_null SET DEFAULT '2016-09-29 12:00:00' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 026 +INSERT INTO T VALUES (11), (12) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +ALTER TABLE T ADD COLUMN c_small SMALLINT DEFAULT -5, + ADD COLUMN c_small_null SMALLINT, + ALTER COLUMN c_array + SET DEFAULT '{"This", "is", "no", "fantasy"}' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 028 +INSERT INTO T VALUES (13), (14) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +ALTER TABLE T ADD COLUMN c_big BIGINT DEFAULT 180000000000018, + ALTER COLUMN c_small SET DEFAULT 9, + ALTER COLUMN c_small_null SET DEFAULT 13 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 030 +INSERT INTO T VALUES (15), (16) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +ALTER TABLE T ADD COLUMN c_num NUMERIC DEFAULT 1.00000000001, + ALTER COLUMN c_big SET DEFAULT -9999999999999999 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 032 +INSERT INTO T VALUES (17), (18) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +ALTER TABLE T ADD COLUMN c_time TIME DEFAULT '12:00:00', + ALTER COLUMN c_num SET DEFAULT 2.000000000000002 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 034 +INSERT INTO T VALUES (19), (20) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +ALTER TABLE T ADD COLUMN c_interval INTERVAL DEFAULT '1 day', + ALTER COLUMN c_time SET DEFAULT '23:59:59' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 036 +INSERT INTO T VALUES (21), (22) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +ALTER TABLE T ADD COLUMN c_hugetext TEXT DEFAULT repeat('abcdefg',1000), + ALTER COLUMN c_interval SET DEFAULT '3 hours' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 038 +INSERT INTO T VALUES (23), (24) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +ALTER TABLE T ALTER COLUMN c_interval DROP DEFAULT, + ALTER COLUMN c_hugetext SET DEFAULT repeat('poiuyt', 1000) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 040 +INSERT INTO T VALUES (25), (26) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +ALTER TABLE T ALTER COLUMN c_bpchar DROP DEFAULT, + ALTER COLUMN c_date DROP DEFAULT, + ALTER COLUMN c_text DROP DEFAULT, + ALTER COLUMN c_timestamp DROP DEFAULT, + ALTER COLUMN c_array DROP DEFAULT, + ALTER COLUMN c_small DROP DEFAULT, + ALTER COLUMN c_big DROP DEFAULT, + ALTER COLUMN c_num DROP DEFAULT, + ALTER COLUMN c_time DROP DEFAULT, + ALTER COLUMN c_hugetext DROP DEFAULT +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 042 +INSERT INTO T VALUES (27), (28) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +SELECT pk, c_int, c_bpchar, c_text, c_date, c_timestamp, + c_timestamp_null, c_array, c_small, c_small_null, + c_big, c_num, c_time, c_interval, + c_hugetext = repeat('abcdefg',1000) as c_hugetext_origdef, + c_hugetext = repeat('poiuyt', 1000) as c_hugetext_newdef +FROM T ORDER BY pk +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +== 045 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 046 +-- Test expressions in the defaults +CREATE OR REPLACE FUNCTION foo(a INT) RETURNS TEXT AS $$ +DECLARE res TEXT := ''; + i INT; +BEGIN + i := 0; + WHILE (i < a) LOOP + res := res || chr(ascii('a') + i); + i := i + 1; + END LOOP; + RETURN res; +END; $$ LANGUAGE PLPGSQL STABLE +-- +FUNCTION: name="foo" function="foo" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 047 +CREATE TABLE T(pk INT NOT NULL PRIMARY KEY, c_int INT DEFAULT LENGTH(foo(6))) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 048 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +== 049 +INSERT INTO T VALUES (1), (2) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +ALTER TABLE T ADD COLUMN c_bpchar BPCHAR(5) DEFAULT foo(4), + ALTER COLUMN c_int SET DEFAULT LENGTH(foo(8)) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 051 +INSERT INTO T VALUES (3), (4) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT foo(6), + ALTER COLUMN c_bpchar SET DEFAULT foo(3) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 053 +INSERT INTO T VALUES (5), (6) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +ALTER TABLE T ADD COLUMN c_date DATE + DEFAULT '2016-06-02'::DATE + LENGTH(foo(10)), + ALTER COLUMN c_text SET DEFAULT foo(12) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 055 +INSERT INTO T VALUES (7), (8) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +ALTER TABLE T ADD COLUMN c_timestamp TIMESTAMP + DEFAULT '2016-09-01'::DATE + LENGTH(foo(10)), + ALTER COLUMN c_date + SET DEFAULT '2010-01-01'::DATE - LENGTH(foo(4)) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 057 +INSERT INTO T VALUES (9), (10) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +ALTER TABLE T ADD COLUMN c_array TEXT[] + DEFAULT ('{"This", "is", "' || foo(4) || + '","the", "real", "world"}')::TEXT[], + ALTER COLUMN c_timestamp + SET DEFAULT '1970-12-31'::DATE + LENGTH(foo(30)) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 059 +INSERT INTO T VALUES (11), (12) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +ALTER TABLE T ALTER COLUMN c_int DROP DEFAULT, + ALTER COLUMN c_array + SET DEFAULT ('{"This", "is", "' || foo(1) || + '", "fantasy"}')::text[] +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 061 +INSERT INTO T VALUES (13), (14) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +ALTER TABLE T ALTER COLUMN c_bpchar DROP DEFAULT, + ALTER COLUMN c_date DROP DEFAULT, + ALTER COLUMN c_text DROP DEFAULT, + ALTER COLUMN c_timestamp DROP DEFAULT, + ALTER COLUMN c_array DROP DEFAULT +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 063 +INSERT INTO T VALUES (15), (16) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +SELECT * FROM T +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 065 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +== 066 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 067 +-- Test domains with default value for table rewrite. +CREATE DOMAIN domain1 AS int DEFAULT 11 +-- +STMT: CreateDomainStmt +== 068 +-- constant +CREATE DOMAIN domain2 AS int DEFAULT random(min=>10, max=>100) +-- +STMT: CreateDomainStmt +== 069 +-- volatile +CREATE DOMAIN domain3 AS text DEFAULT foo(4) +-- +STMT: CreateDomainStmt +== 070 +-- stable +CREATE DOMAIN domain4 AS text[] + DEFAULT ('{"This", "is", "' || foo(4) || '","the", "real", "world"}')::TEXT[] +-- +STMT: CreateDomainStmt +== 071 +CREATE TABLE t2 (a domain1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 072 +INSERT INTO t2 VALUES (1),(2) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +-- no table rewrite +ALTER TABLE t2 ADD COLUMN b domain1 default 3 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +== 074 +SELECT attnum, attname, atthasmissing, atthasdef, attmissingval +FROM pg_attribute +WHERE attnum > 0 AND attrelid = 't2'::regclass +ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +== 075 +-- table rewrite should happen +ALTER TABLE t2 ADD COLUMN c domain3 default left(random()::text,3) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +== 076 +-- no table rewrite +ALTER TABLE t2 ADD COLUMN d domain4 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +== 077 +SELECT attnum, attname, atthasmissing, atthasdef, attmissingval +FROM pg_attribute +WHERE attnum > 0 AND attrelid = 't2'::regclass +ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +== 078 +-- table rewrite should happen +ALTER TABLE t2 ADD COLUMN e domain2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +== 079 +SELECT attnum, attname, atthasmissing, atthasdef, attmissingval +FROM pg_attribute +WHERE attnum > 0 AND attrelid = 't2'::regclass +ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +== 080 +SELECT a, b, length(c) = 3 as c_ok, d, e >= 10 as e_ok FROM t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 081 +DROP TABLE t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +== 082 +DROP DOMAIN domain1 +-- +STMT: DropStmt +== 083 +DROP DOMAIN domain2 +-- +STMT: DropStmt +== 084 +DROP DOMAIN domain3 +-- +STMT: DropStmt +== 085 +DROP DOMAIN domain4 +-- +STMT: DropStmt +== 086 +DROP FUNCTION foo(INT) +-- +FUNCTION: name="foo" function="foo" schema="" ctx=DDL +STMT: DropStmt +== 087 +-- Fall back to full rewrite for volatile expressions +CREATE TABLE T(pk INT NOT NULL PRIMARY KEY) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 088 +INSERT INTO T VALUES (1) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +== 090 +-- now() is stable, because it returns the transaction timestamp +ALTER TABLE T ADD COLUMN c1 TIMESTAMP DEFAULT now() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 091 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +== 092 +-- clock_timestamp() is volatile +ALTER TABLE T ADD COLUMN c2 TIMESTAMP DEFAULT clock_timestamp() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 093 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +== 094 +-- check that we notice insertion of a volatile default argument +CREATE FUNCTION foolme(timestamptz DEFAULT clock_timestamp()) + RETURNS timestamptz + IMMUTABLE AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="foolme" function="foolme" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 095 +ALTER TABLE T ADD COLUMN c3 timestamptz DEFAULT foolme() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 096 +SELECT attname, atthasmissing, attmissingval FROM pg_attribute + WHERE attrelid = 't'::regclass AND attnum > 0 + ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +== 097 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 098 +DROP FUNCTION foolme(timestamptz) +-- +FUNCTION: name="foolme" function="foolme" schema="" ctx=DDL +STMT: DropStmt +== 099 +-- Simple querie +CREATE TABLE T (pk INT NOT NULL PRIMARY KEY) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 100 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +== 101 +INSERT INTO T SELECT * FROM generate_series(1, 10) a +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 102 +ALTER TABLE T ADD COLUMN c_bigint BIGINT NOT NULL DEFAULT -1 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 103 +INSERT INTO T SELECT b, b - 10 FROM generate_series(11, 20) a(b) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 104 +ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT 'hello' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 105 +INSERT INTO T SELECT b, b - 10, (b + 10)::text FROM generate_series(21, 30) a(b) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 106 +-- WHERE clause +SELECT c_bigint, c_text FROM T WHERE c_bigint = -1 LIMIT 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_bigint" +STMT: SelectStmt +== 107 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) +SELECT c_bigint, c_text FROM T WHERE c_bigint = -1 LIMIT 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_bigint" +STMT: ExplainStmt +STMT: SelectStmt +== 108 +SELECT c_bigint, c_text FROM T WHERE c_text = 'hello' LIMIT 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_text" +STMT: SelectStmt +== 109 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) SELECT c_bigint, c_text FROM T WHERE c_text = 'hello' LIMIT 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_text" +STMT: ExplainStmt +STMT: SelectStmt +== 110 +-- COALESCE +SELECT COALESCE(c_bigint, pk), COALESCE(c_text, pk::text) +FROM T +ORDER BY pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 111 +-- Aggregate function +SELECT SUM(c_bigint), MAX(c_text COLLATE "C" ), MIN(c_text COLLATE "C") FROM T +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 112 +-- ORDER BY +SELECT * FROM T ORDER BY c_bigint, c_text, pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 113 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) +SELECT * FROM T ORDER BY c_bigint, c_text, pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 114 +-- LIMIT +SELECT * FROM T WHERE c_bigint > -1 ORDER BY c_bigint, c_text, pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_bigint" +STMT: SelectStmt +== 115 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) +SELECT * FROM T WHERE c_bigint > -1 ORDER BY c_bigint, c_text, pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_bigint" +STMT: ExplainStmt +STMT: SelectStmt +== 116 +-- DELETE with RETURNING +DELETE FROM T WHERE pk BETWEEN 10 AND 20 RETURNING * +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +== 117 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) +DELETE FROM T WHERE pk BETWEEN 10 AND 20 RETURNING * +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 118 +-- UPDATE +UPDATE T SET c_text = '"' || c_text || '"' WHERE pk < 10 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 119 +SELECT * FROM T WHERE c_text LIKE '"%"' ORDER BY PK +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_text" +STMT: SelectStmt +== 120 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +== 121 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 122 +-- Combine with other DDL +CREATE TABLE T(pk INT NOT NULL PRIMARY KEY) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 123 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +== 124 +INSERT INTO T VALUES (1), (2) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 125 +ALTER TABLE T ADD COLUMN c_int INT NOT NULL DEFAULT -1 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 126 +INSERT INTO T VALUES (3), (4) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 127 +ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT 'Hello' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 128 +INSERT INTO T VALUES (5), (6) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +ALTER TABLE T ALTER COLUMN c_text SET DEFAULT 'world', + ALTER COLUMN c_int SET DEFAULT 1 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 130 +INSERT INTO T VALUES (7), (8) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 131 +SELECT * FROM T ORDER BY pk +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 132 +-- Add an index +CREATE INDEX i ON T(c_int, c_text) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +== 133 +SELECT c_text FROM T WHERE c_int = -1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_int" +STMT: SelectStmt +== 134 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +== 135 +-- query to exercise expand_tuple function +CREATE TABLE t1 AS +SELECT 1::int AS a , 2::int AS b +FROM generate_series(1,20) q +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 136 +ALTER TABLE t1 ADD COLUMN c text +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +== 137 +SELECT a, + stddev(cast((SELECT sum(1) FROM generate_series(1,20) x) AS float4)) + OVER (PARTITION BY a,b,c ORDER BY b) + AS z +FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 138 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 139 +-- test that we account for missing columns without defaults correctly +-- in expand_tuple, and that rows are correctly expanded for triggers + +CREATE FUNCTION test_trigger() +RETURNS trigger +LANGUAGE plpgsql +AS $$ + +begin + raise notice 'old tuple: %', to_json(OLD)::text; + if TG_OP = 'DELETE' + then + return OLD; + else + return NEW; + end if; +end; + +$$ +-- +FUNCTION: name="test_trigger" function="test_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 140 +-- 2 new columns, both have defaults +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 141 +INSERT INTO t (a,b,c) VALUES (1,2,3) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 143 +ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 144 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +== 145 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 146 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 147 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 148 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 149 +-- 2 new columns, first has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 150 +INSERT INTO t (a,b,c) VALUES (1,2,3) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 151 +ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 152 +ALTER TABLE t ADD COLUMN y int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 153 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +== 154 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 155 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 156 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 157 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 158 +-- 2 new columns, second has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 159 +INSERT INTO t (a,b,c) VALUES (1,2,3) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 160 +ALTER TABLE t ADD COLUMN x int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 161 +ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 162 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +== 163 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 164 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 165 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 166 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 167 +-- 2 new columns, neither has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 168 +INSERT INTO t (a,b,c) VALUES (1,2,3) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 169 +ALTER TABLE t ADD COLUMN x int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 170 +ALTER TABLE t ADD COLUMN y int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 171 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +== 172 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 173 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 174 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 175 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 176 +-- same as last 4 tests but here the last original column has a NULL value +-- 2 new columns, both have defaults +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 177 +INSERT INTO t (a,b,c) VALUES (1,2,NULL) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 178 +ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 179 +ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 180 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +== 181 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 182 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 183 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 184 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 185 +-- 2 new columns, first has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 186 +INSERT INTO t (a,b,c) VALUES (1,2,NULL) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 188 +ALTER TABLE t ADD COLUMN y int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 189 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +== 190 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 191 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 192 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 193 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 194 +-- 2 new columns, second has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 195 +INSERT INTO t (a,b,c) VALUES (1,2,NULL) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +ALTER TABLE t ADD COLUMN x int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 197 +ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 198 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +== 199 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 200 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 201 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 202 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 203 +-- 2 new columns, neither has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 204 +INSERT INTO t (a,b,c) VALUES (1,2,NULL) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 205 +ALTER TABLE t ADD COLUMN x int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 206 +ALTER TABLE t ADD COLUMN y int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 207 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +== 208 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 209 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 210 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 211 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 212 +-- make sure expanded tuple has correct self pointer +-- it will be required by the RI trigger doing the cascading delete + +CREATE TABLE leader (a int PRIMARY KEY, b int) +-- +TABLE: name="leader" schema="" table="leader" ctx=DDL +STMT: CreateStmt +== 213 +CREATE TABLE follower (a int REFERENCES leader ON DELETE CASCADE, b int) +-- +TABLE: name="follower" schema="" table="follower" ctx=DDL +STMT: CreateStmt +== 214 +INSERT INTO leader VALUES (1, 1), (2, 2) +-- +TABLE: name="leader" schema="" table="leader" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 215 +ALTER TABLE leader ADD c int +-- +TABLE: name="leader" schema="" table="leader" ctx=DDL +STMT: AlterTableStmt +== 216 +ALTER TABLE leader DROP c +-- +TABLE: name="leader" schema="" table="leader" ctx=DDL +STMT: AlterTableStmt +== 217 +DELETE FROM leader +-- +TABLE: name="leader" schema="" table="leader" ctx=DML +STMT: DeleteStmt +== 218 +-- check that ALTER TABLE ... ALTER TYPE does the right thing + +CREATE TABLE vtype( a integer) +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: CreateStmt +== 219 +INSERT INTO vtype VALUES (1) +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 220 +ALTER TABLE vtype ADD COLUMN b DOUBLE PRECISION DEFAULT 0.2 +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: AlterTableStmt +== 221 +ALTER TABLE vtype ADD COLUMN c BOOLEAN DEFAULT true +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: AlterTableStmt +== 222 +SELECT * FROM vtype +-- +TABLE: name="vtype" schema="" table="vtype" ctx=Select +STMT: SelectStmt +== 223 +ALTER TABLE vtype + ALTER b TYPE text USING b::text, + ALTER c TYPE text USING c::text +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: AlterTableStmt +== 224 +SELECT * FROM vtype +-- +TABLE: name="vtype" schema="" table="vtype" ctx=Select +STMT: SelectStmt +== 225 +-- also check the case that doesn't rewrite the table + +CREATE TABLE vtype2 (a int) +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: CreateStmt +== 226 +INSERT INTO vtype2 VALUES (1) +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 227 +ALTER TABLE vtype2 ADD COLUMN b varchar(10) DEFAULT 'xxx' +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: AlterTableStmt +== 228 +ALTER TABLE vtype2 ALTER COLUMN b SET DEFAULT 'yyy' +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: AlterTableStmt +== 229 +INSERT INTO vtype2 VALUES (2) +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 230 +ALTER TABLE vtype2 ALTER COLUMN b TYPE varchar(20) USING b::varchar(20) +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: AlterTableStmt +== 231 +SELECT * FROM vtype2 +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=Select +STMT: SelectStmt +== 232 +-- Ensure that defaults are checked when evaluating whether HOT update +-- is possible, this was broken for a while: +-- https://postgr.es/m/20190202133521.ylauh3ckqa7colzj%40alap3.anarazel.de +BEGIN +-- +STMT: TransactionStmt +== 233 +CREATE TABLE t() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 234 +INSERT INTO t DEFAULT VALUES +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +== 235 +ALTER TABLE t ADD COLUMN a int DEFAULT 1 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +== 236 +CREATE INDEX ON t(a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +== 237 +-- set column with a default 1 to NULL, due to a bug that wasn't +-- noticed has heap_getattr buggily returned NULL for default columns +UPDATE t SET a = NULL +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +== 238 +-- verify that index and non-index scans show the same result +SET LOCAL enable_seqscan = true +-- +STMT: VariableSetStmt +== 239 +SELECT * FROM t WHERE a IS NULL +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 240 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +== 241 +SELECT * FROM t WHERE a IS NULL +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 242 +ROLLBACK +-- +STMT: TransactionStmt +== 243 +-- verify that a default set on a non-plain table doesn't set a missing +-- value on the attribute +CREATE FOREIGN DATA WRAPPER dummy +-- +STMT: CreateFdwStmt +== 244 +CREATE SERVER s0 FOREIGN DATA WRAPPER dummy +-- +STMT: CreateForeignServerStmt +== 245 +CREATE FOREIGN TABLE ft1 (c1 integer NOT NULL) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 246 +ALTER FOREIGN TABLE ft1 ADD COLUMN c8 integer DEFAULT 0 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 247 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 248 +SELECT count(*) + FROM pg_attribute + WHERE attrelid = 'ft1'::regclass AND + (attmissingval IS NOT NULL OR atthasmissing) +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attmissingval" +FILTER: schema="" table="" column="atthasmissing" +STMT: SelectStmt +== 249 +-- cleanup +DROP FOREIGN TABLE ft1 +-- +STMT: DropStmt +== 250 +DROP SERVER s0 +-- +STMT: DropStmt +== 251 +DROP FOREIGN DATA WRAPPER dummy +-- +STMT: DropStmt +== 252 +DROP TABLE vtype +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: DropStmt +== 253 +DROP TABLE vtype2 +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: DropStmt +== 254 +DROP TABLE follower +-- +TABLE: name="follower" schema="" table="follower" ctx=DDL +STMT: DropStmt +== 255 +DROP TABLE leader +-- +TABLE: name="leader" schema="" table="leader" ctx=DDL +STMT: DropStmt +== 256 +DROP FUNCTION test_trigger() +-- +FUNCTION: name="test_trigger" function="test_trigger" schema="" ctx=DDL +STMT: DropStmt +== 257 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 258 +DROP FUNCTION set(name) +-- +FUNCTION: name="set" function="set" schema="" ctx=DDL +STMT: DropStmt +== 259 +DROP FUNCTION comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=DDL +STMT: DropStmt +== 260 +DROP TABLE m +-- +TABLE: name="m" schema="" table="m" ctx=DDL +STMT: DropStmt +== 261 +DROP TABLE has_volatile +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: DropStmt +== 262 +DROP EVENT TRIGGER has_volatile_rewrite +-- +STMT: DropStmt +== 263 +DROP FUNCTION log_rewrite +-- +FUNCTION: name="log_rewrite" function="log_rewrite" schema="" ctx=DDL +STMT: DropStmt +== 264 +DROP SCHEMA fast_default +-- +STMT: DropStmt +== 265 +-- Leave a table with an active fast default in place, for pg_upgrade testing +set search_path = public +-- +STMT: VariableSetStmt +== 266 +create table has_fast_default(f1 int) +-- +TABLE: name="has_fast_default" schema="" table="has_fast_default" ctx=DDL +STMT: CreateStmt +== 267 +insert into has_fast_default values(1) +-- +TABLE: name="has_fast_default" schema="" table="has_fast_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 268 +alter table has_fast_default add column f2 int default 42 +-- +TABLE: name="has_fast_default" schema="" table="has_fast_default" ctx=DDL +STMT: AlterTableStmt +== 269 +table has_fast_default +-- +TABLE: name="has_fast_default" schema="" table="has_fast_default" ctx=Select +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/float4.metadata.json b/parser/testdata/summary/postgres_regress/float4.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/float4.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/float4.test b/parser/testdata/summary/postgres_regress/float4.test new file mode 100644 index 0000000..9ed277a --- /dev/null +++ b/parser/testdata/summary/postgres_regress/float4.test @@ -0,0 +1,747 @@ +== 001 +|-- +-- FLOAT4 +|-- + +CREATE TABLE FLOAT4_TBL (f1 float4) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO FLOAT4_TBL(f1) VALUES (' 0.0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO FLOAT4_TBL(f1) VALUES ('1004.30 ') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO FLOAT4_TBL(f1) VALUES (' -34.84 ') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e+20') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e-20') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- test for over and under flow +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'::float8) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'::float8) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'::float8) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'::float8) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e400') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-400') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-400') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +-- bad input +INSERT INTO FLOAT4_TBL(f1) VALUES ('') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO FLOAT4_TBL(f1) VALUES (' ') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO FLOAT4_TBL(f1) VALUES ('xyz') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO FLOAT4_TBL(f1) VALUES ('5.0.0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO FLOAT4_TBL(f1) VALUES ('5 . 0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO FLOAT4_TBL(f1) VALUES ('5. 0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO FLOAT4_TBL(f1) VALUES (' - 3.0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO FLOAT4_TBL(f1) VALUES ('123 5') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34.5', 'float4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT pg_input_is_valid('xyz', 'float4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT pg_input_is_valid('1e400', 'float4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT * FROM pg_input_error_info('1e400', 'float4') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- special inputs +SELECT 'NaN'::float4 +-- +STMT: SelectStmt +== 032 +SELECT 'nan'::float4 +-- +STMT: SelectStmt +== 033 +SELECT ' NAN '::float4 +-- +STMT: SelectStmt +== 034 +SELECT 'infinity'::float4 +-- +STMT: SelectStmt +== 035 +SELECT ' -INFINiTY '::float4 +-- +STMT: SelectStmt +== 036 +-- bad special inputs +SELECT 'N A N'::float4 +-- +STMT: SelectStmt +== 037 +SELECT 'NaN x'::float4 +-- +STMT: SelectStmt +== 038 +SELECT ' INFINITY x'::float4 +-- +STMT: SelectStmt +== 039 +SELECT 'Infinity'::float4 + 100.0 +-- +STMT: SelectStmt +== 040 +SELECT 'Infinity'::float4 / 'Infinity'::float4 +-- +STMT: SelectStmt +== 041 +SELECT '42'::float4 / 'Infinity'::float4 +-- +STMT: SelectStmt +== 042 +SELECT 'nan'::float4 / 'nan'::float4 +-- +STMT: SelectStmt +== 043 +SELECT 'nan'::float4 / '0'::float4 +-- +STMT: SelectStmt +== 044 +SELECT 'nan'::numeric::float4 +-- +STMT: SelectStmt +== 045 +SELECT * FROM FLOAT4_TBL +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +STMT: SelectStmt +== 046 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 047 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 048 +SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1 +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 049 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 050 +SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1 +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 051 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 052 +SELECT f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 053 +SELECT f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 054 +SELECT f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 055 +SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 056 +-- test divide by zero +SELECT f.f1 / '0.0' from FLOAT4_TBL f +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +STMT: SelectStmt +== 057 +SELECT * FROM FLOAT4_TBL +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +STMT: SelectStmt +== 058 +-- test the unary float4abs operator +SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +STMT: SelectStmt +== 059 +UPDATE FLOAT4_TBL + SET f1 = FLOAT4_TBL.f1 * '-1' + WHERE FLOAT4_TBL.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: UpdateStmt +== 060 +SELECT * FROM FLOAT4_TBL +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +STMT: SelectStmt +== 061 +-- test edge-case coercions to integer +SELECT '32767.4'::float4::int2 +-- +STMT: SelectStmt +== 062 +SELECT '32767.6'::float4::int2 +-- +STMT: SelectStmt +== 063 +SELECT '-32768.4'::float4::int2 +-- +STMT: SelectStmt +== 064 +SELECT '-32768.6'::float4::int2 +-- +STMT: SelectStmt +== 065 +SELECT '2147483520'::float4::int4 +-- +STMT: SelectStmt +== 066 +SELECT '2147483647'::float4::int4 +-- +STMT: SelectStmt +== 067 +SELECT '-2147483648.5'::float4::int4 +-- +STMT: SelectStmt +== 068 +SELECT '-2147483900'::float4::int4 +-- +STMT: SelectStmt +== 069 +SELECT '9223369837831520256'::float4::int8 +-- +STMT: SelectStmt +== 070 +SELECT '9223372036854775807'::float4::int8 +-- +STMT: SelectStmt +== 071 +SELECT '-9223372036854775808.5'::float4::int8 +-- +STMT: SelectStmt +== 072 +SELECT '-9223380000000000000'::float4::int8 +-- +STMT: SelectStmt +== 073 +-- Test for correct input rounding in edge cases. +-- These lists are from Paxson 1991, excluding subnormals and +-- inputs of over 9 sig. digits. + +SELECT float4send('5e-20'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT float4send('67e14'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 075 +SELECT float4send('985e15'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT float4send('55895e-16'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 077 +SELECT float4send('7038531e-32'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT float4send('702990899e-20'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 079 +SELECT float4send('3e-23'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 080 +SELECT float4send('57e18'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 081 +SELECT float4send('789e-35'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT float4send('2539e-18'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT float4send('76173e28'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 084 +SELECT float4send('887745e-11'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 085 +SELECT float4send('5382571e-37'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT float4send('82381273e-35'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 087 +SELECT float4send('750486563e-38'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 088 +-- Test that the smallest possible normalized input value inputs +-- correctly, either in 9-significant-digit or shortest-decimal +-- format. +|-- +-- exact val is 1.1754943508... +-- shortest val is 1.1754944000 +-- midpoint to next val is 1.1754944208... + +SELECT float4send('1.17549435e-38'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 089 +SELECT float4send('1.1754944e-38'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 090 +-- test output (and round-trip safety) of various values. +-- To ensure we're testing what we think we're testing, start with +-- float values specified by bit patterns (as a useful side effect, +-- this means we'll fail on non-IEEE platforms). + +create type xfloat4 +-- +STMT: DefineStmt +== 091 +create function xfloat4in(cstring) returns xfloat4 immutable strict + language internal as 'int4in' +-- +FUNCTION: name="xfloat4in" function="xfloat4in" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 092 +create function xfloat4out(xfloat4) returns cstring immutable strict + language internal as 'int4out' +-- +FUNCTION: name="xfloat4out" function="xfloat4out" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 093 +create type xfloat4 (input = xfloat4in, output = xfloat4out, like = float4) +-- +STMT: DefineStmt +== 094 +create cast (xfloat4 as float4) without function +-- +STMT: CreateCastStmt +== 095 +create cast (float4 as xfloat4) without function +-- +STMT: CreateCastStmt +== 096 +create cast (xfloat4 as integer) without function +-- +STMT: CreateCastStmt +== 097 +create cast (integer as xfloat4) without function +-- +STMT: CreateCastStmt +== 098 +-- float4: seeeeeee emmmmmmm mmmmmmmm mmmmmmmm + +-- we don't care to assume the platform's strtod() handles subnormals +-- correctly; those are "use at your own risk". However we do test +-- subnormal outputs, since those are under our control. + +with testdata(bits) as (values + -- small subnormals + (x'00000001'), + (x'00000002'), (x'00000003'), + (x'00000010'), (x'00000011'), (x'00000100'), (x'00000101'), + (x'00004000'), (x'00004001'), (x'00080000'), (x'00080001'), + -- stress values + (x'0053c4f4'), -- 7693e-42 + (x'006c85c4'), -- 996622e-44 + (x'0041ca76'), -- 60419369e-46 + (x'004b7678'), -- 6930161142e-48 + -- taken from upstream testsuite + (x'00000007'), + (x'00424fe2'), + -- borderline between subnormal and normal + (x'007ffff0'), (x'007ffff1'), (x'007ffffe'), (x'007fffff')) +select float4send(flt) as ibits, + flt + from (select bits::integer::xfloat4::float4 as flt + from testdata + offset 0) s +-- +CTE: "testdata" +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 099 +with testdata(bits) as (values + (x'00000000'), + -- smallest normal values + (x'00800000'), (x'00800001'), (x'00800004'), (x'00800005'), + (x'00800006'), + -- small normal values chosen for short vs. long output + (x'008002f1'), (x'008002f2'), (x'008002f3'), + (x'00800e17'), (x'00800e18'), (x'00800e19'), + -- assorted values (random mantissae) + (x'01000001'), (x'01102843'), (x'01a52c98'), + (x'0219c229'), (x'02e4464d'), (x'037343c1'), (x'03a91b36'), + (x'047ada65'), (x'0496fe87'), (x'0550844f'), (x'05999da3'), + (x'060ea5e2'), (x'06e63c45'), (x'07f1e548'), (x'0fc5282b'), + (x'1f850283'), (x'2874a9d6'), + -- values around 5e-08 + (x'3356bf94'), (x'3356bf95'), (x'3356bf96'), + -- around 1e-07 + (x'33d6bf94'), (x'33d6bf95'), (x'33d6bf96'), + -- around 3e-07 .. 1e-04 + (x'34a10faf'), (x'34a10fb0'), (x'34a10fb1'), + (x'350637bc'), (x'350637bd'), (x'350637be'), + (x'35719786'), (x'35719787'), (x'35719788'), + (x'358637bc'), (x'358637bd'), (x'358637be'), + (x'36a7c5ab'), (x'36a7c5ac'), (x'36a7c5ad'), + (x'3727c5ab'), (x'3727c5ac'), (x'3727c5ad'), + -- format crossover at 1e-04 + (x'38d1b714'), (x'38d1b715'), (x'38d1b716'), + (x'38d1b717'), (x'38d1b718'), (x'38d1b719'), + (x'38d1b71a'), (x'38d1b71b'), (x'38d1b71c'), + (x'38d1b71d'), + -- + (x'38dffffe'), (x'38dfffff'), (x'38e00000'), + (x'38efffff'), (x'38f00000'), (x'38f00001'), + (x'3a83126e'), (x'3a83126f'), (x'3a831270'), + (x'3c23d709'), (x'3c23d70a'), (x'3c23d70b'), + (x'3dcccccc'), (x'3dcccccd'), (x'3dccccce'), + -- chosen to need 9 digits for 3dcccd70 + (x'3dcccd6f'), (x'3dcccd70'), (x'3dcccd71'), + -- + (x'3effffff'), (x'3f000000'), (x'3f000001'), + (x'3f333332'), (x'3f333333'), (x'3f333334'), + -- approach 1.0 with increasing numbers of 9s + (x'3f666665'), (x'3f666666'), (x'3f666667'), + (x'3f7d70a3'), (x'3f7d70a4'), (x'3f7d70a5'), + (x'3f7fbe76'), (x'3f7fbe77'), (x'3f7fbe78'), + (x'3f7ff971'), (x'3f7ff972'), (x'3f7ff973'), + (x'3f7fff57'), (x'3f7fff58'), (x'3f7fff59'), + (x'3f7fffee'), (x'3f7fffef'), + -- values very close to 1 + (x'3f7ffff0'), (x'3f7ffff1'), (x'3f7ffff2'), + (x'3f7ffff3'), (x'3f7ffff4'), (x'3f7ffff5'), + (x'3f7ffff6'), (x'3f7ffff7'), (x'3f7ffff8'), + (x'3f7ffff9'), (x'3f7ffffa'), (x'3f7ffffb'), + (x'3f7ffffc'), (x'3f7ffffd'), (x'3f7ffffe'), + (x'3f7fffff'), + (x'3f800000'), + (x'3f800001'), (x'3f800002'), (x'3f800003'), + (x'3f800004'), (x'3f800005'), (x'3f800006'), + (x'3f800007'), (x'3f800008'), (x'3f800009'), + -- values 1 to 1.1 + (x'3f80000f'), (x'3f800010'), (x'3f800011'), + (x'3f800012'), (x'3f800013'), (x'3f800014'), + (x'3f800017'), (x'3f800018'), (x'3f800019'), + (x'3f80001a'), (x'3f80001b'), (x'3f80001c'), + (x'3f800029'), (x'3f80002a'), (x'3f80002b'), + (x'3f800053'), (x'3f800054'), (x'3f800055'), + (x'3f800346'), (x'3f800347'), (x'3f800348'), + (x'3f8020c4'), (x'3f8020c5'), (x'3f8020c6'), + (x'3f8147ad'), (x'3f8147ae'), (x'3f8147af'), + (x'3f8ccccc'), (x'3f8ccccd'), (x'3f8cccce'), + -- + (x'3fc90fdb'), -- pi/2 + (x'402df854'), -- e + (x'40490fdb'), -- pi + -- + (x'409fffff'), (x'40a00000'), (x'40a00001'), + (x'40afffff'), (x'40b00000'), (x'40b00001'), + (x'411fffff'), (x'41200000'), (x'41200001'), + (x'42c7ffff'), (x'42c80000'), (x'42c80001'), + (x'4479ffff'), (x'447a0000'), (x'447a0001'), + (x'461c3fff'), (x'461c4000'), (x'461c4001'), + (x'47c34fff'), (x'47c35000'), (x'47c35001'), + (x'497423ff'), (x'49742400'), (x'49742401'), + (x'4b18967f'), (x'4b189680'), (x'4b189681'), + (x'4cbebc1f'), (x'4cbebc20'), (x'4cbebc21'), + (x'4e6e6b27'), (x'4e6e6b28'), (x'4e6e6b29'), + (x'501502f8'), (x'501502f9'), (x'501502fa'), + (x'51ba43b6'), (x'51ba43b7'), (x'51ba43b8'), + -- stress values + (x'1f6c1e4a'), -- 5e-20 + (x'59be6cea'), -- 67e14 + (x'5d5ab6c4'), -- 985e15 + (x'2cc4a9bd'), -- 55895e-16 + (x'15ae43fd'), -- 7038531e-32 + (x'2cf757ca'), -- 702990899e-20 + (x'665ba998'), -- 25933168707e13 + (x'743c3324'), -- 596428896559e20 + -- exercise fixed-point memmoves + (x'47f1205a'), + (x'4640e6ae'), + (x'449a5225'), + (x'42f6e9d5'), + (x'414587dd'), + (x'3f9e064b'), + -- these cases come from the upstream's testsuite + -- BoundaryRoundEven + (x'4c000004'), + (x'50061c46'), + (x'510006a8'), + -- ExactValueRoundEven + (x'48951f84'), + (x'45fd1840'), + -- LotsOfTrailingZeros + (x'39800000'), + (x'3b200000'), + (x'3b900000'), + (x'3bd00000'), + -- Regression + (x'63800000'), + (x'4b000000'), + (x'4b800000'), + (x'4c000001'), + (x'4c800b0d'), + (x'00d24584'), + (x'00d90b88'), + (x'45803f34'), + (x'4f9f24f7'), + (x'3a8722c3'), + (x'5c800041'), + (x'15ae43fd'), + (x'5d4cccfb'), + (x'4c800001'), + (x'57800ed8'), + (x'5f000000'), + (x'700000f0'), + (x'5f23e9ac'), + (x'5e9502f9'), + (x'5e8012b1'), + (x'3c000028'), + (x'60cde861'), + (x'03aa2a50'), + (x'43480000'), + (x'4c000000'), + -- LooksLikePow5 + (x'5D1502F9'), + (x'5D9502F9'), + (x'5E1502F9'), + -- OutputLength + (x'3f99999a'), + (x'3f9d70a4'), + (x'3f9df3b6'), + (x'3f9e0419'), + (x'3f9e0610'), + (x'3f9e064b'), + (x'3f9e0651'), + (x'03d20cfe') +) +select float4send(flt) as ibits, + flt, + flt::text::float4 as r_flt, + float4send(flt::text::float4) as obits, + float4send(flt::text::float4) = float4send(flt) as correct + from (select bits::integer::xfloat4::float4 as flt + from testdata + offset 0) s +-- +CTE: "testdata" +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +== 100 +-- clean up, lest opr_sanity complain +drop type xfloat4 cascade +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/float8.metadata.json b/parser/testdata/summary/postgres_regress/float8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/float8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/float8.test b/parser/testdata/summary/postgres_regress/float8.test new file mode 100644 index 0000000..5d8f908 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/float8.test @@ -0,0 +1,1173 @@ +== 001 +|-- +-- FLOAT8 +|-- + +|-- +-- Build a table for testing +-- (This temporarily hides the table created in test_setup.sql) +|-- + +CREATE TEMP TABLE FLOAT8_TBL(f1 float8) +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 ') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30 ') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO FLOAT8_TBL(f1) VALUES (' -34.84') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- test for underflow and overflow handling +SELECT '10e400'::float8 +-- +STMT: SelectStmt +== 008 +SELECT '-10e400'::float8 +-- +STMT: SelectStmt +== 009 +SELECT '10e-400'::float8 +-- +STMT: SelectStmt +== 010 +SELECT '-10e-400'::float8 +-- +STMT: SelectStmt +== 011 +-- test smallest normalized input +SELECT float8send('2.2250738585072014E-308'::float8) +-- +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- bad input +INSERT INTO FLOAT8_TBL(f1) VALUES ('') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO FLOAT8_TBL(f1) VALUES (' ') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34.5', 'float8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT pg_input_is_valid('xyz', 'float8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT pg_input_is_valid('1e4000', 'float8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT * FROM pg_input_error_info('1e4000', 'float8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 024 +-- special inputs +SELECT 'NaN'::float8 +-- +STMT: SelectStmt +== 025 +SELECT 'nan'::float8 +-- +STMT: SelectStmt +== 026 +SELECT ' NAN '::float8 +-- +STMT: SelectStmt +== 027 +SELECT 'infinity'::float8 +-- +STMT: SelectStmt +== 028 +SELECT ' -INFINiTY '::float8 +-- +STMT: SelectStmt +== 029 +-- bad special inputs +SELECT 'N A N'::float8 +-- +STMT: SelectStmt +== 030 +SELECT 'NaN x'::float8 +-- +STMT: SelectStmt +== 031 +SELECT ' INFINITY x'::float8 +-- +STMT: SelectStmt +== 032 +SELECT 'Infinity'::float8 + 100.0 +-- +STMT: SelectStmt +== 033 +SELECT 'Infinity'::float8 / 'Infinity'::float8 +-- +STMT: SelectStmt +== 034 +SELECT '42'::float8 / 'Infinity'::float8 +-- +STMT: SelectStmt +== 035 +SELECT 'nan'::float8 / 'nan'::float8 +-- +STMT: SelectStmt +== 036 +SELECT 'nan'::float8 / '0'::float8 +-- +STMT: SelectStmt +== 037 +SELECT 'nan'::numeric::float8 +-- +STMT: SelectStmt +== 038 +SELECT * FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +== 039 +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 040 +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 041 +SELECT f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 042 +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 043 +SELECT f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 044 +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 045 +SELECT f.f1, f.f1 * '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 046 +SELECT f.f1, f.f1 + '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 047 +SELECT f.f1, f.f1 / '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 048 +SELECT f.f1, f.f1 - '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 049 +SELECT f.f1 ^ '2.0' AS square_f1 + FROM FLOAT8_TBL f where f.f1 = '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 050 +-- absolute value +SELECT f.f1, @f.f1 AS abs_f1 + FROM FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +== 051 +-- truncate +SELECT f.f1, trunc(f.f1) AS trunc_f1 + FROM FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 052 +-- round +SELECT f.f1, round(f.f1) AS round_f1 + FROM FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 053 +-- ceil / ceiling +select ceil(f1) as ceil_f1 from float8_tbl f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="ceil" function="ceil" schema="" ctx=Call +STMT: SelectStmt +== 054 +select ceiling(f1) as ceiling_f1 from float8_tbl f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="ceiling" function="ceiling" schema="" ctx=Call +STMT: SelectStmt +== 055 +-- floor +select floor(f1) as floor_f1 from float8_tbl f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="floor" function="floor" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- sign +select sign(f1) as sign_f1 from float8_tbl f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="sign" function="sign" schema="" ctx=Call +STMT: SelectStmt +== 057 +-- avoid bit-exact output here because operations may not be bit-exact. +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +== 058 +-- square root +SELECT sqrt(float8 '64') AS eight +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT |/ float8 '64' AS eight +-- +STMT: SelectStmt +== 060 +SELECT f.f1, |/f.f1 AS sqrt_f1 + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 061 +-- power +SELECT power(float8 '144', float8 '0.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 062 +SELECT power(float8 'NaN', float8 '0.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT power(float8 '144', float8 'NaN') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT power(float8 'NaN', float8 'NaN') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 065 +SELECT power(float8 '-1', float8 'NaN') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 066 +SELECT power(float8 '1', float8 'NaN') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT power(float8 'NaN', float8 '0') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT power(float8 'inf', float8 '0') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT power(float8 '-inf', float8 '0') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT power(float8 '0', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT power(float8 '0', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 072 +SELECT power(float8 '1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 073 +SELECT power(float8 '1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT power(float8 '-1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 075 +SELECT power(float8 '-1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT power(float8 '0.1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 077 +SELECT power(float8 '-0.1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT power(float8 '1.1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 079 +SELECT power(float8 '-1.1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 080 +SELECT power(float8 '0.1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 081 +SELECT power(float8 '-0.1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT power(float8 '1.1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT power(float8 '-1.1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 084 +SELECT power(float8 'inf', float8 '-2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 085 +SELECT power(float8 'inf', float8 '2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT power(float8 'inf', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 087 +SELECT power(float8 'inf', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 088 +-- Intel's icc misoptimizes the code that controls the sign of this result, +-- even with -mp1. Pending a fix for that, only test for "is it zero". +SELECT power(float8 '-inf', float8 '-2') = '0' +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 089 +SELECT power(float8 '-inf', float8 '-3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 090 +SELECT power(float8 '-inf', float8 '2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 091 +SELECT power(float8 '-inf', float8 '3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 092 +SELECT power(float8 '-inf', float8 '3.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 093 +SELECT power(float8 '-inf', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 094 +SELECT power(float8 '-inf', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 095 +-- take exp of ln(f.f1) +SELECT f.f1, exp(ln(f.f1)) AS exp_ln_f1 + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="exp" function="exp" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 096 +-- check edge cases for exp +SELECT exp('inf'::float8), exp('-inf'::float8), exp('nan'::float8) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +FUNCTION: name="exp" function="exp" schema="" ctx=Call +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 097 +-- cube root +SELECT ||/ float8 '27' AS three +-- +STMT: SelectStmt +== 098 +SELECT f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +== 099 +SELECT * FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +== 100 +UPDATE FLOAT8_TBL + SET f1 = FLOAT8_TBL.f1 * '-1' + WHERE FLOAT8_TBL.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: UpdateStmt +== 101 +SELECT f.f1 * '1e200' from FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +== 102 +SELECT f.f1 ^ '1e200' from FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +== 103 +SELECT 0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5 +-- +STMT: SelectStmt +== 104 +SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 105 +SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +== 106 +SELECT exp(f.f1) from FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 107 +SELECT f.f1 / '0.0' from FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +== 108 +SELECT * FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +== 109 +-- hyperbolic functions +-- we run these with extra_float_digits = 0 too, since different platforms +-- tend to produce results that vary in the last place. +SELECT sinh(float8 '1') +-- +FUNCTION: name="sinh" function="sinh" schema="" ctx=Call +STMT: SelectStmt +== 110 +SELECT cosh(float8 '1') +-- +FUNCTION: name="cosh" function="cosh" schema="" ctx=Call +STMT: SelectStmt +== 111 +SELECT tanh(float8 '1') +-- +FUNCTION: name="tanh" function="tanh" schema="" ctx=Call +STMT: SelectStmt +== 112 +SELECT asinh(float8 '1') +-- +FUNCTION: name="asinh" function="asinh" schema="" ctx=Call +STMT: SelectStmt +== 113 +SELECT acosh(float8 '2') +-- +FUNCTION: name="acosh" function="acosh" schema="" ctx=Call +STMT: SelectStmt +== 114 +SELECT atanh(float8 '0.5') +-- +FUNCTION: name="atanh" function="atanh" schema="" ctx=Call +STMT: SelectStmt +== 115 +-- test Inf/NaN cases for hyperbolic functions +SELECT sinh(float8 'infinity') +-- +FUNCTION: name="sinh" function="sinh" schema="" ctx=Call +STMT: SelectStmt +== 116 +SELECT sinh(float8 '-infinity') +-- +FUNCTION: name="sinh" function="sinh" schema="" ctx=Call +STMT: SelectStmt +== 117 +SELECT sinh(float8 'nan') +-- +FUNCTION: name="sinh" function="sinh" schema="" ctx=Call +STMT: SelectStmt +== 118 +SELECT cosh(float8 'infinity') +-- +FUNCTION: name="cosh" function="cosh" schema="" ctx=Call +STMT: SelectStmt +== 119 +SELECT cosh(float8 '-infinity') +-- +FUNCTION: name="cosh" function="cosh" schema="" ctx=Call +STMT: SelectStmt +== 120 +SELECT cosh(float8 'nan') +-- +FUNCTION: name="cosh" function="cosh" schema="" ctx=Call +STMT: SelectStmt +== 121 +SELECT tanh(float8 'infinity') +-- +FUNCTION: name="tanh" function="tanh" schema="" ctx=Call +STMT: SelectStmt +== 122 +SELECT tanh(float8 '-infinity') +-- +FUNCTION: name="tanh" function="tanh" schema="" ctx=Call +STMT: SelectStmt +== 123 +SELECT tanh(float8 'nan') +-- +FUNCTION: name="tanh" function="tanh" schema="" ctx=Call +STMT: SelectStmt +== 124 +SELECT asinh(float8 'infinity') +-- +FUNCTION: name="asinh" function="asinh" schema="" ctx=Call +STMT: SelectStmt +== 125 +SELECT asinh(float8 '-infinity') +-- +FUNCTION: name="asinh" function="asinh" schema="" ctx=Call +STMT: SelectStmt +== 126 +SELECT asinh(float8 'nan') +-- +FUNCTION: name="asinh" function="asinh" schema="" ctx=Call +STMT: SelectStmt +== 127 +-- acosh(Inf) should be Inf, but some mingw versions produce NaN, so skip test +-- SELECT acosh(float8 'infinity'); +SELECT acosh(float8 '-infinity') +-- +FUNCTION: name="acosh" function="acosh" schema="" ctx=Call +STMT: SelectStmt +== 128 +SELECT acosh(float8 'nan') +-- +FUNCTION: name="acosh" function="acosh" schema="" ctx=Call +STMT: SelectStmt +== 129 +SELECT atanh(float8 'infinity') +-- +FUNCTION: name="atanh" function="atanh" schema="" ctx=Call +STMT: SelectStmt +== 130 +SELECT atanh(float8 '-infinity') +-- +FUNCTION: name="atanh" function="atanh" schema="" ctx=Call +STMT: SelectStmt +== 131 +SELECT atanh(float8 'nan') +-- +FUNCTION: name="atanh" function="atanh" schema="" ctx=Call +STMT: SelectStmt +== 132 +-- error functions +-- we run these with extra_float_digits = -1, to get consistently rounded +-- results on all platforms. +SET extra_float_digits = -1 +-- +STMT: VariableSetStmt +== 133 +SELECT x, + erf(x), + erfc(x) +FROM (VALUES (float8 '-infinity'), + (-28), (-6), (-3.4), (-2.1), (-1.1), (-0.45), + (-1.2e-9), (-2.3e-13), (-1.2e-17), (0), + (1.2e-17), (2.3e-13), (1.2e-9), + (0.45), (1.1), (2.1), (3.4), (6), (28), + (float8 'infinity'), (float8 'nan')) AS t(x) +-- +FUNCTION: name="erf" function="erf" schema="" ctx=Call +FUNCTION: name="erfc" function="erfc" schema="" ctx=Call +STMT: SelectStmt +== 134 +RESET extra_float_digits +-- +STMT: VariableSetStmt +== 135 +-- test for over- and underflow +INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +DROP TABLE FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DDL +STMT: DropStmt +== 140 +-- Check the float8 values exported for use by other tests + +SELECT * FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +== 141 +-- test edge-case coercions to integer +SELECT '32767.4'::float8::int2 +-- +STMT: SelectStmt +== 142 +SELECT '32767.6'::float8::int2 +-- +STMT: SelectStmt +== 143 +SELECT '-32768.4'::float8::int2 +-- +STMT: SelectStmt +== 144 +SELECT '-32768.6'::float8::int2 +-- +STMT: SelectStmt +== 145 +SELECT '2147483647.4'::float8::int4 +-- +STMT: SelectStmt +== 146 +SELECT '2147483647.6'::float8::int4 +-- +STMT: SelectStmt +== 147 +SELECT '-2147483648.4'::float8::int4 +-- +STMT: SelectStmt +== 148 +SELECT '-2147483648.6'::float8::int4 +-- +STMT: SelectStmt +== 149 +SELECT '9223372036854773760'::float8::int8 +-- +STMT: SelectStmt +== 150 +SELECT '9223372036854775807'::float8::int8 +-- +STMT: SelectStmt +== 151 +SELECT '-9223372036854775808.5'::float8::int8 +-- +STMT: SelectStmt +== 152 +SELECT '-9223372036854780000'::float8::int8 +-- +STMT: SelectStmt +== 153 +-- test exact cases for trigonometric functions in degrees + +SELECT x, + sind(x), + sind(x) IN (-1,-0.5,0,0.5,1) AS sind_exact +FROM (VALUES (0), (30), (90), (150), (180), + (210), (270), (330), (360)) AS t(x) +-- +FUNCTION: name="sind" function="sind" schema="" ctx=Call +FUNCTION: name="sind" function="sind" schema="" ctx=Call +STMT: SelectStmt +== 154 +SELECT x, + cosd(x), + cosd(x) IN (-1,-0.5,0,0.5,1) AS cosd_exact +FROM (VALUES (0), (60), (90), (120), (180), + (240), (270), (300), (360)) AS t(x) +-- +FUNCTION: name="cosd" function="cosd" schema="" ctx=Call +FUNCTION: name="cosd" function="cosd" schema="" ctx=Call +STMT: SelectStmt +== 155 +SELECT x, + tand(x), + tand(x) IN ('-Infinity'::float8,-1,0, + 1,'Infinity'::float8) AS tand_exact, + cotd(x), + cotd(x) IN ('-Infinity'::float8,-1,0, + 1,'Infinity'::float8) AS cotd_exact +FROM (VALUES (0), (45), (90), (135), (180), + (225), (270), (315), (360)) AS t(x) +-- +FUNCTION: name="tand" function="tand" schema="" ctx=Call +FUNCTION: name="tand" function="tand" schema="" ctx=Call +FUNCTION: name="cotd" function="cotd" schema="" ctx=Call +FUNCTION: name="cotd" function="cotd" schema="" ctx=Call +STMT: SelectStmt +== 156 +SELECT x, + asind(x), + asind(x) IN (-90,-30,0,30,90) AS asind_exact, + acosd(x), + acosd(x) IN (0,60,90,120,180) AS acosd_exact +FROM (VALUES (-1), (-0.5), (0), (0.5), (1)) AS t(x) +-- +FUNCTION: name="asind" function="asind" schema="" ctx=Call +FUNCTION: name="asind" function="asind" schema="" ctx=Call +FUNCTION: name="acosd" function="acosd" schema="" ctx=Call +FUNCTION: name="acosd" function="acosd" schema="" ctx=Call +STMT: SelectStmt +== 157 +SELECT x, + atand(x), + atand(x) IN (-90,-45,0,45,90) AS atand_exact +FROM (VALUES ('-Infinity'::float8), (-1), (0), (1), + ('Infinity'::float8)) AS t(x) +-- +FUNCTION: name="atand" function="atand" schema="" ctx=Call +FUNCTION: name="atand" function="atand" schema="" ctx=Call +STMT: SelectStmt +== 158 +SELECT x, y, + atan2d(y, x), + atan2d(y, x) IN (-90,0,90,180) AS atan2d_exact +FROM (SELECT 10*cosd(a), 10*sind(a) + FROM generate_series(0, 360, 90) AS t(a)) AS t(x,y) +-- +FUNCTION: name="atan2d" function="atan2d" schema="" ctx=Call +FUNCTION: name="atan2d" function="atan2d" schema="" ctx=Call +FUNCTION: name="cosd" function="cosd" schema="" ctx=Call +FUNCTION: name="sind" function="sind" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 159 +|-- +-- test output (and round-trip safety) of various values. +-- To ensure we're testing what we think we're testing, start with +-- float values specified by bit patterns (as a useful side effect, +-- this means we'll fail on non-IEEE platforms). + +create type xfloat8 +-- +STMT: DefineStmt +== 160 +create function xfloat8in(cstring) returns xfloat8 immutable strict + language internal as 'int8in' +-- +FUNCTION: name="xfloat8in" function="xfloat8in" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 161 +create function xfloat8out(xfloat8) returns cstring immutable strict + language internal as 'int8out' +-- +FUNCTION: name="xfloat8out" function="xfloat8out" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 162 +create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8) +-- +STMT: DefineStmt +== 163 +create cast (xfloat8 as float8) without function +-- +STMT: CreateCastStmt +== 164 +create cast (float8 as xfloat8) without function +-- +STMT: CreateCastStmt +== 165 +create cast (xfloat8 as bigint) without function +-- +STMT: CreateCastStmt +== 166 +create cast (bigint as xfloat8) without function +-- +STMT: CreateCastStmt +== 167 +-- float8: seeeeeee eeeeeeee eeeeeeee mmmmmmmm mmmmmmmm(x4) + +-- we don't care to assume the platform's strtod() handles subnormals +-- correctly; those are "use at your own risk". However we do test +-- subnormal outputs, since those are under our control. + +with testdata(bits) as (values + -- small subnormals + (x'0000000000000001'), + (x'0000000000000002'), (x'0000000000000003'), + (x'0000000000001000'), (x'0000000100000000'), + (x'0000010000000000'), (x'0000010100000000'), + (x'0000400000000000'), (x'0000400100000000'), + (x'0000800000000000'), (x'0000800000000001'), + -- these values taken from upstream testsuite + (x'00000000000f4240'), + (x'00000000016e3600'), + (x'0000008cdcdea440'), + -- borderline between subnormal and normal + (x'000ffffffffffff0'), (x'000ffffffffffff1'), + (x'000ffffffffffffe'), (x'000fffffffffffff')) +select float8send(flt) as ibits, + flt + from (select bits::bigint::xfloat8::float8 as flt + from testdata + offset 0) s +-- +CTE: "testdata" +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +STMT: SelectStmt +== 168 +-- round-trip tests + +with testdata(bits) as (values + (x'0000000000000000'), + -- smallest normal values + (x'0010000000000000'), (x'0010000000000001'), + (x'0010000000000002'), (x'0018000000000000'), + -- + (x'3ddb7cdfd9d7bdba'), (x'3ddb7cdfd9d7bdbb'), (x'3ddb7cdfd9d7bdbc'), + (x'3e112e0be826d694'), (x'3e112e0be826d695'), (x'3e112e0be826d696'), + (x'3e45798ee2308c39'), (x'3e45798ee2308c3a'), (x'3e45798ee2308c3b'), + (x'3e7ad7f29abcaf47'), (x'3e7ad7f29abcaf48'), (x'3e7ad7f29abcaf49'), + (x'3eb0c6f7a0b5ed8c'), (x'3eb0c6f7a0b5ed8d'), (x'3eb0c6f7a0b5ed8e'), + (x'3ee4f8b588e368ef'), (x'3ee4f8b588e368f0'), (x'3ee4f8b588e368f1'), + (x'3f1a36e2eb1c432c'), (x'3f1a36e2eb1c432d'), (x'3f1a36e2eb1c432e'), + (x'3f50624dd2f1a9fb'), (x'3f50624dd2f1a9fc'), (x'3f50624dd2f1a9fd'), + (x'3f847ae147ae147a'), (x'3f847ae147ae147b'), (x'3f847ae147ae147c'), + (x'3fb9999999999999'), (x'3fb999999999999a'), (x'3fb999999999999b'), + -- values very close to 1 + (x'3feffffffffffff0'), (x'3feffffffffffff1'), (x'3feffffffffffff2'), + (x'3feffffffffffff3'), (x'3feffffffffffff4'), (x'3feffffffffffff5'), + (x'3feffffffffffff6'), (x'3feffffffffffff7'), (x'3feffffffffffff8'), + (x'3feffffffffffff9'), (x'3feffffffffffffa'), (x'3feffffffffffffb'), + (x'3feffffffffffffc'), (x'3feffffffffffffd'), (x'3feffffffffffffe'), + (x'3fefffffffffffff'), + (x'3ff0000000000000'), + (x'3ff0000000000001'), (x'3ff0000000000002'), (x'3ff0000000000003'), + (x'3ff0000000000004'), (x'3ff0000000000005'), (x'3ff0000000000006'), + (x'3ff0000000000007'), (x'3ff0000000000008'), (x'3ff0000000000009'), + -- + (x'3ff921fb54442d18'), + (x'4005bf0a8b14576a'), + (x'400921fb54442d18'), + -- + (x'4023ffffffffffff'), (x'4024000000000000'), (x'4024000000000001'), + (x'4058ffffffffffff'), (x'4059000000000000'), (x'4059000000000001'), + (x'408f3fffffffffff'), (x'408f400000000000'), (x'408f400000000001'), + (x'40c387ffffffffff'), (x'40c3880000000000'), (x'40c3880000000001'), + (x'40f869ffffffffff'), (x'40f86a0000000000'), (x'40f86a0000000001'), + (x'412e847fffffffff'), (x'412e848000000000'), (x'412e848000000001'), + (x'416312cfffffffff'), (x'416312d000000000'), (x'416312d000000001'), + (x'4197d783ffffffff'), (x'4197d78400000000'), (x'4197d78400000001'), + (x'41cdcd64ffffffff'), (x'41cdcd6500000000'), (x'41cdcd6500000001'), + (x'4202a05f1fffffff'), (x'4202a05f20000000'), (x'4202a05f20000001'), + (x'42374876e7ffffff'), (x'42374876e8000000'), (x'42374876e8000001'), + (x'426d1a94a1ffffff'), (x'426d1a94a2000000'), (x'426d1a94a2000001'), + (x'42a2309ce53fffff'), (x'42a2309ce5400000'), (x'42a2309ce5400001'), + (x'42d6bcc41e8fffff'), (x'42d6bcc41e900000'), (x'42d6bcc41e900001'), + (x'430c6bf52633ffff'), (x'430c6bf526340000'), (x'430c6bf526340001'), + (x'4341c37937e07fff'), (x'4341c37937e08000'), (x'4341c37937e08001'), + (x'4376345785d89fff'), (x'4376345785d8a000'), (x'4376345785d8a001'), + (x'43abc16d674ec7ff'), (x'43abc16d674ec800'), (x'43abc16d674ec801'), + (x'43e158e460913cff'), (x'43e158e460913d00'), (x'43e158e460913d01'), + (x'4415af1d78b58c3f'), (x'4415af1d78b58c40'), (x'4415af1d78b58c41'), + (x'444b1ae4d6e2ef4f'), (x'444b1ae4d6e2ef50'), (x'444b1ae4d6e2ef51'), + (x'4480f0cf064dd591'), (x'4480f0cf064dd592'), (x'4480f0cf064dd593'), + (x'44b52d02c7e14af5'), (x'44b52d02c7e14af6'), (x'44b52d02c7e14af7'), + (x'44ea784379d99db3'), (x'44ea784379d99db4'), (x'44ea784379d99db5'), + (x'45208b2a2c280290'), (x'45208b2a2c280291'), (x'45208b2a2c280292'), + -- + (x'7feffffffffffffe'), (x'7fefffffffffffff'), + -- round to even tests (+ve) + (x'4350000000000002'), + (x'4350000000002e06'), + (x'4352000000000003'), + (x'4352000000000004'), + (x'4358000000000003'), + (x'4358000000000004'), + (x'435f000000000020'), + -- round to even tests (-ve) + (x'c350000000000002'), + (x'c350000000002e06'), + (x'c352000000000003'), + (x'c352000000000004'), + (x'c358000000000003'), + (x'c358000000000004'), + (x'c35f000000000020'), + -- exercise fixed-point memmoves + (x'42dc12218377de66'), + (x'42a674e79c5fe51f'), + (x'4271f71fb04cb74c'), + (x'423cbe991a145879'), + (x'4206fee0e1a9e061'), + (x'41d26580b487e6b4'), + (x'419d6f34540ca453'), + (x'41678c29dcd6e9dc'), + (x'4132d687e3df217d'), + (x'40fe240c9fcb68c8'), + (x'40c81cd6e63c53d3'), + (x'40934a4584fd0fdc'), + (x'405edd3c07fb4c93'), + (x'4028b0fcd32f7076'), + (x'3ff3c0ca428c59f8'), + -- these cases come from the upstream's testsuite + -- LotsOfTrailingZeros) + (x'3e60000000000000'), + -- Regression + (x'c352bd2668e077c4'), + (x'434018601510c000'), + (x'43d055dc36f24000'), + (x'43e052961c6f8000'), + (x'3ff3c0ca2a5b1d5d'), + -- LooksLikePow5 + (x'4830f0cf064dd592'), + (x'4840f0cf064dd592'), + (x'4850f0cf064dd592'), + -- OutputLength + (x'3ff3333333333333'), + (x'3ff3ae147ae147ae'), + (x'3ff3be76c8b43958'), + (x'3ff3c083126e978d'), + (x'3ff3c0c1fc8f3238'), + (x'3ff3c0c9539b8887'), + (x'3ff3c0ca2a5b1d5d'), + (x'3ff3c0ca4283de1b'), + (x'3ff3c0ca43db770a'), + (x'3ff3c0ca428abd53'), + (x'3ff3c0ca428c1d2b'), + (x'3ff3c0ca428c51f2'), + (x'3ff3c0ca428c58fc'), + (x'3ff3c0ca428c59dd'), + (x'3ff3c0ca428c59f8'), + (x'3ff3c0ca428c59fb'), + -- 32-bit chunking + (x'40112e0be8047a7d'), + (x'40112e0be815a889'), + (x'40112e0be826d695'), + (x'40112e0be83804a1'), + (x'40112e0be84932ad'), + -- MinMaxShift + (x'0040000000000000'), + (x'007fffffffffffff'), + (x'0290000000000000'), + (x'029fffffffffffff'), + (x'4350000000000000'), + (x'435fffffffffffff'), + (x'1330000000000000'), + (x'133fffffffffffff'), + (x'3a6fa7161a4d6e0c') +) +select float8send(flt) as ibits, + flt, + flt::text::float8 as r_flt, + float8send(flt::text::float8) as obits, + float8send(flt::text::float8) = float8send(flt) as correct + from (select bits::bigint::xfloat8::float8 as flt + from testdata + offset 0) s +-- +CTE: "testdata" +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +STMT: SelectStmt +== 169 +-- clean up, lest opr_sanity complain +drop type xfloat8 cascade +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/foreign_data.metadata.json b/parser/testdata/summary/postgres_regress/foreign_data.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/foreign_data.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/foreign_data.test b/parser/testdata/summary/postgres_regress/foreign_data.test new file mode 100644 index 0000000..39f95aa --- /dev/null +++ b/parser/testdata/summary/postgres_regress/foreign_data.test @@ -0,0 +1,2652 @@ +== 001 +|-- +-- Test foreign-data wrapper and server management. +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION test_fdw_handler() + RETURNS fdw_handler + AS :'regresslib', 'test_fdw_handler' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 202 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- Clean up in case a prior regression run failed + +-- Suppress NOTICE messages when roles don't exist +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +== 003 +DROP ROLE IF EXISTS regress_foreign_data_user, regress_test_role, regress_test_role2, regress_test_role_super, regress_test_indirect, regress_unprivileged_role +-- +STMT: DropRoleStmt +== 004 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 005 +CREATE ROLE regress_foreign_data_user LOGIN SUPERUSER +-- +STMT: CreateRoleStmt +== 006 +SET SESSION AUTHORIZATION 'regress_foreign_data_user' +-- +STMT: VariableSetStmt +== 007 +CREATE ROLE regress_test_role +-- +STMT: CreateRoleStmt +== 008 +CREATE ROLE regress_test_role2 +-- +STMT: CreateRoleStmt +== 009 +CREATE ROLE regress_test_role_super SUPERUSER +-- +STMT: CreateRoleStmt +== 010 +CREATE ROLE regress_test_indirect +-- +STMT: CreateRoleStmt +== 011 +CREATE ROLE regress_unprivileged_role +-- +STMT: CreateRoleStmt +== 012 +CREATE FOREIGN DATA WRAPPER dummy +-- +STMT: CreateFdwStmt +== 013 +COMMENT ON FOREIGN DATA WRAPPER dummy IS 'useless' +-- +STMT: CommentStmt +== 014 +CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator +-- +STMT: CreateFdwStmt +== 015 +-- At this point we should have 2 built-in wrappers and no servers. +SELECT fdwname, fdwhandler::regproc, fdwvalidator::regproc, fdwoptions FROM pg_foreign_data_wrapper ORDER BY 1, 2, 3 +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +STMT: SelectStmt +== 016 +SELECT srvname, srvoptions FROM pg_foreign_server +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +STMT: SelectStmt +== 017 +SELECT * FROM pg_user_mapping +-- +TABLE: name="pg_user_mapping" schema="" table="pg_user_mapping" ctx=Select +STMT: SelectStmt +== 018 +-- CREATE FOREIGN DATA WRAPPER +CREATE FOREIGN DATA WRAPPER foo VALIDATOR bar +-- +STMT: CreateFdwStmt +== 019 +-- ERROR +CREATE FOREIGN DATA WRAPPER foo +-- +STMT: CreateFdwStmt +== 020 +CREATE FOREIGN DATA WRAPPER foo +-- +STMT: CreateFdwStmt +== 021 +-- duplicate +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +== 022 +CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1') +-- +STMT: CreateFdwStmt +== 023 +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +== 024 +CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1', testing '2') +-- +STMT: CreateFdwStmt +== 025 +-- ERROR +CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1', another '2') +-- +STMT: CreateFdwStmt +== 026 +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +== 027 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 028 +CREATE FOREIGN DATA WRAPPER foo +-- +STMT: CreateFdwStmt +== 029 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 030 +CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator +-- +STMT: CreateFdwStmt +== 031 +-- HANDLER related checks +CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;' +-- +FUNCTION: name="invalid_fdw_handler" function="invalid_fdw_handler" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 032 +CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler +-- +STMT: CreateFdwStmt +== 033 +-- ERROR +CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler +-- +STMT: CreateFdwStmt +== 034 +-- ERROR +CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler +-- +STMT: CreateFdwStmt +== 035 +DROP FOREIGN DATA WRAPPER test_fdw +-- +STMT: DropStmt +== 036 +-- ALTER FOREIGN DATA WRAPPER +ALTER FOREIGN DATA WRAPPER foo OPTIONS (nonexistent 'fdw') +-- +STMT: AlterFdwStmt +== 037 +-- ERROR + +ALTER FOREIGN DATA WRAPPER foo +-- +ERROR: syntax error at end of input +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 038 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo VALIDATOR bar +-- +STMT: AlterFdwStmt +== 039 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo NO VALIDATOR +-- +STMT: AlterFdwStmt +== 040 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (a '1', b '2') +-- +STMT: AlterFdwStmt +== 041 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (SET c '4') +-- +STMT: AlterFdwStmt +== 042 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OPTIONS (DROP c) +-- +STMT: AlterFdwStmt +== 043 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD x '1', DROP x) +-- +STMT: AlterFdwStmt +== 044 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (DROP a, SET b '3', ADD c '4') +-- +STMT: AlterFdwStmt +== 045 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (a '2') +-- +STMT: AlterFdwStmt +== 046 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (b '4') +-- +STMT: AlterFdwStmt +== 047 +-- ERROR + +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 048 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD d '5') +-- +STMT: AlterFdwStmt +== 049 +-- ERROR +SET ROLE regress_test_role_super +-- +STMT: VariableSetStmt +== 050 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD d '5') +-- +STMT: AlterFdwStmt +== 051 +ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +== 052 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_test_role_super +-- +STMT: AlterOwnerStmt +== 053 +ALTER ROLE regress_test_role_super NOSUPERUSER +-- +STMT: AlterRoleStmt +== 054 +SET ROLE regress_test_role_super +-- +STMT: VariableSetStmt +== 055 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD e '6') +-- +STMT: AlterFdwStmt +== 056 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 057 +ALTER FOREIGN DATA WRAPPER foo RENAME TO foo1 +-- +STMT: RenameStmt +== 058 +ALTER FOREIGN DATA WRAPPER foo1 RENAME TO foo +-- +STMT: RenameStmt +== 059 +-- HANDLER related checks +ALTER FOREIGN DATA WRAPPER foo HANDLER invalid_fdw_handler +-- +STMT: AlterFdwStmt +== 060 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler HANDLER anything +-- +STMT: AlterFdwStmt +== 061 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler +-- +STMT: AlterFdwStmt +== 062 +DROP FUNCTION invalid_fdw_handler() +-- +FUNCTION: name="invalid_fdw_handler" function="invalid_fdw_handler" schema="" ctx=DDL +STMT: DropStmt +== 063 +-- DROP FOREIGN DATA WRAPPER +DROP FOREIGN DATA WRAPPER nonexistent +-- +STMT: DropStmt +== 064 +-- ERROR +DROP FOREIGN DATA WRAPPER IF EXISTS nonexistent +-- +STMT: DropStmt +== 065 +DROP ROLE regress_test_role_super +-- +STMT: DropRoleStmt +== 066 +-- ERROR +SET ROLE regress_test_role_super +-- +STMT: VariableSetStmt +== 067 +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +== 068 +RESET ROLE +-- +STMT: VariableSetStmt +== 069 +DROP ROLE regress_test_role_super +-- +STMT: DropRoleStmt +== 070 +CREATE FOREIGN DATA WRAPPER foo +-- +STMT: CreateFdwStmt +== 071 +CREATE SERVER s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 072 +COMMENT ON SERVER s1 IS 'foreign server' +-- +STMT: CommentStmt +== 073 +CREATE USER MAPPING FOR current_user SERVER s1 +-- +STMT: CreateUserMappingStmt +== 074 +CREATE USER MAPPING FOR current_user SERVER s1 +-- +STMT: CreateUserMappingStmt +== 075 +-- ERROR +CREATE USER MAPPING IF NOT EXISTS FOR current_user SERVER s1 +-- +STMT: CreateUserMappingStmt +== 076 +-- NOTICE +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +== 077 +-- ERROR +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 078 +DROP FOREIGN DATA WRAPPER foo CASCADE +-- +STMT: DropStmt +== 079 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 080 +DROP FOREIGN DATA WRAPPER foo CASCADE +-- +STMT: DropStmt +== 081 +-- exercise CREATE SERVER +CREATE SERVER s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 082 +-- ERROR +CREATE FOREIGN DATA WRAPPER foo OPTIONS ("test wrapper" 'true') +-- +STMT: CreateFdwStmt +== 083 +CREATE SERVER s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 084 +CREATE SERVER s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 085 +-- ERROR +CREATE SERVER IF NOT EXISTS s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 086 +-- No ERROR, just NOTICE +CREATE SERVER s2 FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b') +-- +STMT: CreateForeignServerStmt +== 087 +CREATE SERVER s3 TYPE 'oracle' FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 088 +CREATE SERVER s4 TYPE 'oracle' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b') +-- +STMT: CreateForeignServerStmt +== 089 +CREATE SERVER s5 VERSION '15.0' FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 090 +CREATE SERVER s6 VERSION '16.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b') +-- +STMT: CreateForeignServerStmt +== 091 +CREATE SERVER s7 TYPE 'oracle' VERSION '17.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b') +-- +STMT: CreateForeignServerStmt +== 092 +CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (foo '1') +-- +STMT: CreateForeignServerStmt +== 093 +-- ERROR +CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (host 'localhost', dbname 's8db') +-- +STMT: CreateForeignServerStmt +== 094 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 095 +CREATE SERVER t1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 096 +-- ERROR: no usage on FDW +RESET ROLE +-- +STMT: VariableSetStmt +== 097 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +== 098 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 099 +CREATE SERVER t1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 100 +RESET ROLE +-- +STMT: VariableSetStmt +== 101 +REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM regress_test_role +-- +STMT: GrantStmt +== 102 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_indirect +-- +STMT: GrantStmt +== 103 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 104 +CREATE SERVER t2 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 105 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 106 +GRANT regress_test_indirect TO regress_test_role +-- +STMT: GrantRoleStmt +== 107 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 108 +CREATE SERVER t2 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 109 +RESET ROLE +-- +STMT: VariableSetStmt +== 110 +REVOKE regress_test_indirect FROM regress_test_role +-- +STMT: GrantRoleStmt +== 111 +-- ALTER SERVER +ALTER SERVER s0 +-- +ERROR: syntax error at end of input +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 112 +-- ERROR +ALTER SERVER s0 OPTIONS (a '1') +-- +STMT: AlterForeignServerStmt +== 113 +-- ERROR +ALTER SERVER s1 VERSION '1.0' OPTIONS (servername 's1') +-- +STMT: AlterForeignServerStmt +== 114 +ALTER SERVER s2 VERSION '1.1' +-- +STMT: AlterForeignServerStmt +== 115 +ALTER SERVER s3 OPTIONS ("tns name" 'orcl', port '1521') +-- +STMT: AlterForeignServerStmt +== 116 +GRANT USAGE ON FOREIGN SERVER s1 TO regress_test_role +-- +STMT: GrantStmt +== 117 +GRANT USAGE ON FOREIGN SERVER s6 TO regress_test_role2 WITH GRANT OPTION +-- +STMT: GrantStmt +== 118 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 119 +ALTER SERVER s1 VERSION '1.1' +-- +STMT: AlterForeignServerStmt +== 120 +-- ERROR +ALTER SERVER s1 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +== 121 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 122 +ALTER SERVER s1 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +== 123 +GRANT regress_test_role2 TO regress_test_role +-- +STMT: GrantRoleStmt +== 124 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 125 +ALTER SERVER s1 VERSION '1.1' +-- +STMT: AlterForeignServerStmt +== 126 +ALTER SERVER s1 OWNER TO regress_test_role2 +-- +STMT: AlterOwnerStmt +== 127 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 128 +ALTER SERVER s8 OPTIONS (foo '1') +-- +STMT: AlterForeignServerStmt +== 129 +-- ERROR option validation +ALTER SERVER s8 OPTIONS (connect_timeout '30', SET dbname 'db1', DROP host) +-- +STMT: AlterForeignServerStmt +== 130 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 131 +ALTER SERVER s1 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +== 132 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 133 +GRANT regress_test_indirect TO regress_test_role +-- +STMT: GrantRoleStmt +== 134 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 135 +ALTER SERVER s1 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +== 136 +RESET ROLE +-- +STMT: VariableSetStmt +== 137 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_indirect +-- +STMT: GrantStmt +== 138 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 139 +ALTER SERVER s1 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +== 140 +RESET ROLE +-- +STMT: VariableSetStmt +== 141 +DROP ROLE regress_test_indirect +-- +STMT: DropRoleStmt +== 142 +-- ERROR + +ALTER SERVER s8 RENAME to s8new +-- +STMT: RenameStmt +== 143 +ALTER SERVER s8new RENAME to s8 +-- +STMT: RenameStmt +== 144 +-- DROP SERVER +DROP SERVER nonexistent +-- +STMT: DropStmt +== 145 +-- ERROR +DROP SERVER IF EXISTS nonexistent +-- +STMT: DropStmt +== 146 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 147 +DROP SERVER s2 +-- +STMT: DropStmt +== 148 +-- ERROR +DROP SERVER s1 +-- +STMT: DropStmt +== 149 +RESET ROLE +-- +STMT: VariableSetStmt +== 150 +ALTER SERVER s2 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +== 151 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 152 +DROP SERVER s2 +-- +STMT: DropStmt +== 153 +RESET ROLE +-- +STMT: VariableSetStmt +== 154 +CREATE USER MAPPING FOR current_user SERVER s3 +-- +STMT: CreateUserMappingStmt +== 155 +DROP SERVER s3 +-- +STMT: DropStmt +== 156 +-- ERROR +DROP SERVER s3 CASCADE +-- +STMT: DropStmt +== 157 +-- CREATE USER MAPPING +CREATE USER MAPPING FOR regress_test_missing_role SERVER s1 +-- +STMT: CreateUserMappingStmt +== 158 +-- ERROR +CREATE USER MAPPING FOR current_user SERVER s1 +-- +STMT: CreateUserMappingStmt +== 159 +-- ERROR +CREATE USER MAPPING FOR current_user SERVER s4 +-- +STMT: CreateUserMappingStmt +== 160 +CREATE USER MAPPING FOR user SERVER s4 +-- +STMT: CreateUserMappingStmt +== 161 +-- ERROR duplicate +CREATE USER MAPPING FOR public SERVER s4 OPTIONS ("this mapping" 'is public') +-- +STMT: CreateUserMappingStmt +== 162 +CREATE USER MAPPING FOR user SERVER s8 OPTIONS (username 'test', password 'secret') +-- +STMT: CreateUserMappingStmt +== 163 +-- ERROR +CREATE USER MAPPING FOR user SERVER s8 OPTIONS (user 'test', password 'secret') +-- +STMT: CreateUserMappingStmt +== 164 +ALTER SERVER s5 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +== 165 +ALTER SERVER s6 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +== 166 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 167 +CREATE USER MAPPING FOR current_user SERVER s5 +-- +STMT: CreateUserMappingStmt +== 168 +CREATE USER MAPPING FOR current_user SERVER s6 OPTIONS (username 'test') +-- +STMT: CreateUserMappingStmt +== 169 +CREATE USER MAPPING FOR current_user SERVER s7 +-- +STMT: CreateUserMappingStmt +== 170 +-- ERROR +CREATE USER MAPPING FOR public SERVER s8 +-- +STMT: CreateUserMappingStmt +== 171 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 172 +ALTER SERVER t1 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +== 173 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 174 +CREATE USER MAPPING FOR current_user SERVER t1 OPTIONS (username 'bob', password 'boo') +-- +STMT: CreateUserMappingStmt +== 175 +CREATE USER MAPPING FOR public SERVER t1 +-- +STMT: CreateUserMappingStmt +== 176 +RESET ROLE +-- +STMT: VariableSetStmt +== 177 +-- ALTER USER MAPPING +ALTER USER MAPPING FOR regress_test_missing_role SERVER s4 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +== 178 +-- ERROR +ALTER USER MAPPING FOR user SERVER ss4 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +== 179 +-- ERROR +ALTER USER MAPPING FOR public SERVER s5 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +== 180 +-- ERROR +ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (username 'test') +-- +STMT: AlterUserMappingStmt +== 181 +-- ERROR +ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (DROP user, SET password 'public') +-- +STMT: AlterUserMappingStmt +== 182 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 183 +ALTER USER MAPPING FOR current_user SERVER s5 OPTIONS (ADD modified '1') +-- +STMT: AlterUserMappingStmt +== 184 +ALTER USER MAPPING FOR public SERVER s4 OPTIONS (ADD modified '1') +-- +STMT: AlterUserMappingStmt +== 185 +-- ERROR +ALTER USER MAPPING FOR public SERVER t1 OPTIONS (ADD modified '1') +-- +STMT: AlterUserMappingStmt +== 186 +RESET ROLE +-- +STMT: VariableSetStmt +== 187 +-- DROP USER MAPPING +DROP USER MAPPING FOR regress_test_missing_role SERVER s4 +-- +STMT: DropUserMappingStmt +== 188 +-- ERROR +DROP USER MAPPING FOR user SERVER ss4 +-- +STMT: DropUserMappingStmt +== 189 +DROP USER MAPPING FOR public SERVER s7 +-- +STMT: DropUserMappingStmt +== 190 +-- ERROR +DROP USER MAPPING IF EXISTS FOR regress_test_missing_role SERVER s4 +-- +STMT: DropUserMappingStmt +== 191 +DROP USER MAPPING IF EXISTS FOR user SERVER ss4 +-- +STMT: DropUserMappingStmt +== 192 +DROP USER MAPPING IF EXISTS FOR public SERVER s7 +-- +STMT: DropUserMappingStmt +== 193 +CREATE USER MAPPING FOR public SERVER s8 +-- +STMT: CreateUserMappingStmt +== 194 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 195 +DROP USER MAPPING FOR public SERVER s8 +-- +STMT: DropUserMappingStmt +== 196 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 197 +DROP SERVER s7 +-- +STMT: DropStmt +== 198 +-- CREATE FOREIGN TABLE +CREATE SCHEMA foreign_schema +-- +STMT: CreateSchemaStmt +== 199 +CREATE SERVER s0 FOREIGN DATA WRAPPER dummy +-- +STMT: CreateForeignServerStmt +== 200 +CREATE FOREIGN TABLE ft1 () +-- +ERROR: syntax error at end of input +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 201 +-- ERROR +CREATE FOREIGN TABLE ft1 () SERVER no_server +-- +STMT: CreateForeignTableStmt +== 202 +-- ERROR +CREATE FOREIGN TABLE ft1 ( + c1 integer OPTIONS ("param 1" 'val1') PRIMARY KEY, + c2 text OPTIONS (param2 'val2', param3 'val3'), + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 203 +-- ERROR +CREATE TABLE ref_table (id integer PRIMARY KEY) +-- +TABLE: name="ref_table" schema="" table="ref_table" ctx=DDL +STMT: CreateStmt +== 204 +CREATE FOREIGN TABLE ft1 ( + c1 integer OPTIONS ("param 1" 'val1') REFERENCES ref_table (id), + c2 text OPTIONS (param2 'val2', param3 'val3'), + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 205 +-- ERROR +DROP TABLE ref_table +-- +TABLE: name="ref_table" schema="" table="ref_table" ctx=DDL +STMT: DropStmt +== 206 +CREATE FOREIGN TABLE ft1 ( + c1 integer OPTIONS ("param 1" 'val1') NOT NULL, + c2 text OPTIONS (param2 'val2', param3 'val3'), + c3 date, + UNIQUE (c3) +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 207 +-- ERROR +CREATE FOREIGN TABLE ft1 ( + c1 integer OPTIONS ("param 1" 'val1') NOT NULL, + c2 text OPTIONS (param2 'val2', param3 'val3') CHECK (c2 <> ''), + c3 date, + CHECK (c3 BETWEEN '1994-01-01'::date AND '1994-01-31'::date) +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 208 +COMMENT ON FOREIGN TABLE ft1 IS 'ft1' +-- +STMT: CommentStmt +== 209 +COMMENT ON COLUMN ft1.c1 IS 'ft1.c1' +-- +STMT: CommentStmt +== 210 +CREATE INDEX id_ft1_c2 ON ft1 (c2) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: IndexStmt +== 211 +-- ERROR +SELECT * FROM ft1 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=Select +STMT: SelectStmt +== 212 +-- ERROR +EXPLAIN SELECT * FROM ft1 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 213 +-- ERROR + +CREATE TABLE lt1 (a INT) PARTITION BY RANGE (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: CreateStmt +== 214 +CREATE FOREIGN TABLE ft_part1 + PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 215 +CREATE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +== 216 +-- skips partition +CREATE UNIQUE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +== 217 +-- ERROR +ALTER TABLE lt1 ADD PRIMARY KEY (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +== 218 +-- ERROR +DROP TABLE lt1 +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: DropStmt +== 219 +CREATE TABLE lt1 (a INT) PARTITION BY RANGE (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: CreateStmt +== 220 +CREATE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +== 221 +CREATE FOREIGN TABLE ft_part1 + PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 222 +CREATE FOREIGN TABLE ft_part2 (a INT) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 223 +ALTER TABLE lt1 ATTACH PARTITION ft_part2 FOR VALUES FROM (1000) TO (2000) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +== 224 +DROP FOREIGN TABLE ft_part1, ft_part2 +-- +STMT: DropStmt +== 225 +CREATE UNIQUE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +== 226 +ALTER TABLE lt1 ADD PRIMARY KEY (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +== 227 +CREATE FOREIGN TABLE ft_part1 + PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 228 +-- ERROR +CREATE FOREIGN TABLE ft_part2 (a INT NOT NULL) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 229 +ALTER TABLE lt1 ATTACH PARTITION ft_part2 + FOR VALUES FROM (1000) TO (2000) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +== 230 +-- ERROR +DROP TABLE lt1 +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: DropStmt +== 231 +DROP FOREIGN TABLE ft_part2 +-- +STMT: DropStmt +== 232 +CREATE TABLE lt1 (a INT) PARTITION BY RANGE (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: CreateStmt +== 233 +CREATE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +== 234 +CREATE TABLE lt1_part1 + PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) + PARTITION BY RANGE (a) +-- +TABLE: name="lt1_part1" schema="" table="lt1_part1" ctx=DDL +STMT: CreateStmt +== 235 +CREATE FOREIGN TABLE ft_part_1_1 + PARTITION OF lt1_part1 FOR VALUES FROM (0) TO (100) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 236 +CREATE FOREIGN TABLE ft_part_1_2 (a INT) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 237 +ALTER TABLE lt1_part1 ATTACH PARTITION ft_part_1_2 FOR VALUES FROM (100) TO (200) +-- +TABLE: name="lt1_part1" schema="" table="lt1_part1" ctx=DDL +STMT: AlterTableStmt +== 238 +CREATE UNIQUE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +== 239 +ALTER TABLE lt1 ADD PRIMARY KEY (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +== 240 +DROP FOREIGN TABLE ft_part_1_1, ft_part_1_2 +-- +STMT: DropStmt +== 241 +CREATE UNIQUE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +== 242 +ALTER TABLE lt1 ADD PRIMARY KEY (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +== 243 +CREATE FOREIGN TABLE ft_part_1_1 + PARTITION OF lt1_part1 FOR VALUES FROM (0) TO (100) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 244 +CREATE FOREIGN TABLE ft_part_1_2 (a INT NOT NULL) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 245 +ALTER TABLE lt1_part1 ATTACH PARTITION ft_part_1_2 FOR VALUES FROM (100) TO (200) +-- +TABLE: name="lt1_part1" schema="" table="lt1_part1" ctx=DDL +STMT: AlterTableStmt +== 246 +DROP TABLE lt1 +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: DropStmt +== 247 +DROP FOREIGN TABLE ft_part_1_2 +-- +STMT: DropStmt +== 248 +-- ALTER FOREIGN TABLE +COMMENT ON FOREIGN TABLE ft1 IS 'foreign table' +-- +STMT: CommentStmt +== 249 +COMMENT ON FOREIGN TABLE ft1 IS NULL +-- +STMT: CommentStmt +== 250 +COMMENT ON COLUMN ft1.c1 IS 'foreign column' +-- +STMT: CommentStmt +== 251 +COMMENT ON COLUMN ft1.c1 IS NULL +-- +STMT: CommentStmt +== 252 +ALTER FOREIGN TABLE ft1 ADD COLUMN c4 integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 253 +ALTER FOREIGN TABLE ft1 ADD COLUMN c5 integer DEFAULT 0 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 254 +ALTER FOREIGN TABLE ft1 ADD COLUMN c6 integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 255 +ALTER FOREIGN TABLE ft1 ADD COLUMN c7 integer NOT NULL +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 256 +ALTER FOREIGN TABLE ft1 ADD COLUMN c8 integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 257 +ALTER FOREIGN TABLE ft1 ADD COLUMN c9 integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 258 +ALTER FOREIGN TABLE ft1 ADD COLUMN c10 integer OPTIONS (p1 'v1') +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 259 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c4 SET DEFAULT 0 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 260 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c5 DROP DEFAULT +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 261 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c6 SET NOT NULL +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 262 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 DROP NOT NULL +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 263 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) USING '0' +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 264 +-- ERROR +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 265 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET DATA TYPE text +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 266 +ALTER FOREIGN TABLE ft1 ALTER COLUMN xmin OPTIONS (ADD p1 'v1') +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 267 +-- ERROR +ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2'), + ALTER COLUMN c8 OPTIONS (ADD p1 'v1', ADD p2 'v2') +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 268 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 269 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET STATISTICS 10000 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 270 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET (n_distinct = 100) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 271 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STATISTICS -1 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 272 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STORAGE PLAIN +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 273 +-- can't change the column type if it's used elsewhere +CREATE TABLE use_ft1_column_type (x ft1) +-- +TABLE: name="use_ft1_column_type" schema="" table="use_ft1_column_type" ctx=DDL +STMT: CreateStmt +== 274 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET DATA TYPE integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 275 +-- ERROR +DROP TABLE use_ft1_column_type +-- +TABLE: name="use_ft1_column_type" schema="" table="use_ft1_column_type" ctx=DDL +STMT: DropStmt +== 276 +ALTER FOREIGN TABLE ft1 ADD PRIMARY KEY (c7) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 277 +-- ERROR +ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c9_check CHECK (c9 < 0) NOT VALID +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 278 +ALTER FOREIGN TABLE ft1 ALTER CONSTRAINT ft1_c9_check DEFERRABLE +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 279 +-- ERROR +ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c9_check +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 280 +ALTER FOREIGN TABLE ft1 DROP CONSTRAINT no_const +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 281 +-- ERROR +ALTER FOREIGN TABLE ft1 DROP CONSTRAINT IF EXISTS no_const +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 282 +ALTER FOREIGN TABLE ft1 OWNER TO regress_test_role +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 283 +ALTER FOREIGN TABLE ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@') +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 284 +ALTER FOREIGN TABLE ft1 DROP COLUMN no_column +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 285 +-- ERROR +ALTER FOREIGN TABLE ft1 DROP COLUMN IF EXISTS no_column +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 286 +ALTER FOREIGN TABLE ft1 DROP COLUMN c9 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 287 +ALTER FOREIGN TABLE ft1 ADD COLUMN c11 serial +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 288 +ALTER FOREIGN TABLE ft1 SET SCHEMA foreign_schema +-- +STMT: AlterObjectSchemaStmt +== 289 +ALTER FOREIGN TABLE ft1 SET TABLESPACE ts +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +== 290 +-- ERROR +ALTER SEQUENCE foreign_schema.ft1_c11_seq SET SCHEMA public +-- +STMT: AlterObjectSchemaStmt +== 291 +-- ERROR +ALTER FOREIGN TABLE foreign_schema.ft1 RENAME c1 TO foreign_column_1 +-- +STMT: RenameStmt +== 292 +ALTER FOREIGN TABLE foreign_schema.ft1 RENAME TO foreign_table_1 +-- +STMT: RenameStmt +== 293 +-- alter noexisting table +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c4 integer +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 294 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c6 integer +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 295 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c7 integer NOT NULL +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 296 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c8 integer +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 297 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c9 integer +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 298 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c10 integer OPTIONS (p1 'v1') +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 299 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c6 SET NOT NULL +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 300 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c7 DROP NOT NULL +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 301 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 TYPE char(10) +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 302 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 SET DATA TYPE text +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 303 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2'), + ALTER COLUMN c8 OPTIONS (ADD p1 'v1', ADD p2 'v2') +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 304 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1) +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 305 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP CONSTRAINT IF EXISTS no_const +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 306 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP CONSTRAINT ft1_c1_check +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 307 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 OWNER TO regress_test_role +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 308 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@') +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 309 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP COLUMN IF EXISTS no_column +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 310 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP COLUMN c9 +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +== 311 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 SET SCHEMA foreign_schema +-- +STMT: AlterObjectSchemaStmt +== 312 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 RENAME c1 TO foreign_column_1 +-- +STMT: RenameStmt +== 313 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 RENAME TO foreign_table_1 +-- +STMT: RenameStmt +== 314 +-- Information schema + +SELECT * FROM information_schema.foreign_data_wrappers ORDER BY 1, 2 +-- +TABLE: name="information_schema.foreign_data_wrappers" schema="information_schema" table="foreign_data_wrappers" ctx=Select +STMT: SelectStmt +== 315 +SELECT * FROM information_schema.foreign_data_wrapper_options ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.foreign_data_wrapper_options" schema="information_schema" table="foreign_data_wrapper_options" ctx=Select +STMT: SelectStmt +== 316 +SELECT * FROM information_schema.foreign_servers ORDER BY 1, 2 +-- +TABLE: name="information_schema.foreign_servers" schema="information_schema" table="foreign_servers" ctx=Select +STMT: SelectStmt +== 317 +SELECT * FROM information_schema.foreign_server_options ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.foreign_server_options" schema="information_schema" table="foreign_server_options" ctx=Select +STMT: SelectStmt +== 318 +SELECT * FROM information_schema.user_mappings ORDER BY lower(authorization_identifier), 2, 3 +-- +TABLE: name="information_schema.user_mappings" schema="information_schema" table="user_mappings" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 319 +SELECT * FROM information_schema.user_mapping_options ORDER BY lower(authorization_identifier), 2, 3, 4 +-- +TABLE: name="information_schema.user_mapping_options" schema="information_schema" table="user_mapping_options" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 320 +SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5 +-- +TABLE: name="information_schema.usage_privileges" schema="information_schema" table="usage_privileges" ctx=Select +FILTER: schema="" table="" column="object_type" +FILTER: schema="" table="" column="object_name" +STMT: SelectStmt +== 321 +SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5 +-- +TABLE: name="information_schema.role_usage_grants" schema="information_schema" table="role_usage_grants" ctx=Select +FILTER: schema="" table="" column="object_type" +FILTER: schema="" table="" column="object_name" +STMT: SelectStmt +== 322 +SELECT * FROM information_schema.foreign_tables ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.foreign_tables" schema="information_schema" table="foreign_tables" ctx=Select +STMT: SelectStmt +== 323 +SELECT * FROM information_schema.foreign_table_options ORDER BY 1, 2, 3, 4 +-- +TABLE: name="information_schema.foreign_table_options" schema="information_schema" table="foreign_table_options" ctx=Select +STMT: SelectStmt +== 324 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 325 +SELECT * FROM information_schema.user_mapping_options ORDER BY 1, 2, 3, 4 +-- +TABLE: name="information_schema.user_mapping_options" schema="information_schema" table="user_mapping_options" ctx=Select +STMT: SelectStmt +== 326 +SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5 +-- +TABLE: name="information_schema.usage_privileges" schema="information_schema" table="usage_privileges" ctx=Select +FILTER: schema="" table="" column="object_type" +FILTER: schema="" table="" column="object_name" +STMT: SelectStmt +== 327 +SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5 +-- +TABLE: name="information_schema.role_usage_grants" schema="information_schema" table="role_usage_grants" ctx=Select +FILTER: schema="" table="" column="object_type" +FILTER: schema="" table="" column="object_name" +STMT: SelectStmt +== 328 +DROP USER MAPPING FOR current_user SERVER t1 +-- +STMT: DropUserMappingStmt +== 329 +SET ROLE regress_test_role2 +-- +STMT: VariableSetStmt +== 330 +SELECT * FROM information_schema.user_mapping_options ORDER BY 1, 2, 3, 4 +-- +TABLE: name="information_schema.user_mapping_options" schema="information_schema" table="user_mapping_options" ctx=Select +STMT: SelectStmt +== 331 +RESET ROLE +-- +STMT: VariableSetStmt +== 332 +-- has_foreign_data_wrapper_privilege +SELECT has_foreign_data_wrapper_privilege('regress_test_role', + (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE') +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="fdwname" +STMT: SelectStmt +== 333 +SELECT has_foreign_data_wrapper_privilege('regress_test_role', 'foo', 'USAGE') +-- +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +STMT: SelectStmt +== 334 +SELECT has_foreign_data_wrapper_privilege( + (SELECT oid FROM pg_roles WHERE rolname='regress_test_role'), + (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE') +-- +TABLE: name="pg_roles" schema="" table="pg_roles" ctx=Select +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +FILTER: schema="" table="" column="fdwname" +STMT: SelectStmt +== 335 +SELECT has_foreign_data_wrapper_privilege( + (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE') +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="fdwname" +STMT: SelectStmt +== 336 +SELECT has_foreign_data_wrapper_privilege( + (SELECT oid FROM pg_roles WHERE rolname='regress_test_role'), 'foo', 'USAGE') +-- +TABLE: name="pg_roles" schema="" table="pg_roles" ctx=Select +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 337 +SELECT has_foreign_data_wrapper_privilege('foo', 'USAGE') +-- +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +STMT: SelectStmt +== 338 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +== 339 +SELECT has_foreign_data_wrapper_privilege('regress_test_role', 'foo', 'USAGE') +-- +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +STMT: SelectStmt +== 340 +-- has_server_privilege +SELECT has_server_privilege('regress_test_role', + (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE') +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="srvname" +STMT: SelectStmt +== 341 +SELECT has_server_privilege('regress_test_role', 's8', 'USAGE') +-- +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +STMT: SelectStmt +== 342 +SELECT has_server_privilege( + (SELECT oid FROM pg_roles WHERE rolname='regress_test_role'), + (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE') +-- +TABLE: name="pg_roles" schema="" table="pg_roles" ctx=Select +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +FILTER: schema="" table="" column="srvname" +STMT: SelectStmt +== 343 +SELECT has_server_privilege( + (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE') +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="srvname" +STMT: SelectStmt +== 344 +SELECT has_server_privilege( + (SELECT oid FROM pg_roles WHERE rolname='regress_test_role'), 's8', 'USAGE') +-- +TABLE: name="pg_roles" schema="" table="pg_roles" ctx=Select +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 345 +SELECT has_server_privilege('s8', 'USAGE') +-- +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +STMT: SelectStmt +== 346 +GRANT USAGE ON FOREIGN SERVER s8 TO regress_test_role +-- +STMT: GrantStmt +== 347 +SELECT has_server_privilege('regress_test_role', 's8', 'USAGE') +-- +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +STMT: SelectStmt +== 348 +REVOKE USAGE ON FOREIGN SERVER s8 FROM regress_test_role +-- +STMT: GrantStmt +== 349 +GRANT USAGE ON FOREIGN SERVER s4 TO regress_test_role +-- +STMT: GrantStmt +== 350 +DROP USER MAPPING FOR public SERVER s4 +-- +STMT: DropUserMappingStmt +== 351 +ALTER SERVER s6 OPTIONS (DROP host, DROP dbname) +-- +STMT: AlterForeignServerStmt +== 352 +ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (DROP username) +-- +STMT: AlterUserMappingStmt +== 353 +ALTER FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator +-- +STMT: AlterFdwStmt +== 354 +-- Privileges +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +== 355 +CREATE FOREIGN DATA WRAPPER foobar +-- +STMT: CreateFdwStmt +== 356 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OPTIONS (gotcha 'true') +-- +STMT: AlterFdwStmt +== 357 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_unprivileged_role +-- +STMT: AlterOwnerStmt +== 358 +-- ERROR +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +== 359 +-- ERROR +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +== 360 +-- ERROR +CREATE SERVER s9 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 361 +-- ERROR +ALTER SERVER s4 VERSION '0.5' +-- +STMT: AlterForeignServerStmt +== 362 +-- ERROR +ALTER SERVER s4 OWNER TO regress_unprivileged_role +-- +STMT: AlterOwnerStmt +== 363 +-- ERROR +DROP SERVER s4 +-- +STMT: DropStmt +== 364 +-- ERROR +GRANT USAGE ON FOREIGN SERVER s4 TO regress_test_role +-- +STMT: GrantStmt +== 365 +-- ERROR +CREATE USER MAPPING FOR public SERVER s4 +-- +STMT: CreateUserMappingStmt +== 366 +-- ERROR +ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +== 367 +-- ERROR +DROP USER MAPPING FOR regress_test_role SERVER s6 +-- +STMT: DropUserMappingStmt +== 368 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 369 +GRANT USAGE ON FOREIGN DATA WRAPPER postgresql TO regress_unprivileged_role +-- +STMT: GrantStmt +== 370 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_unprivileged_role WITH GRANT OPTION +-- +STMT: GrantStmt +== 371 +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +== 372 +CREATE FOREIGN DATA WRAPPER foobar +-- +STMT: CreateFdwStmt +== 373 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OPTIONS (gotcha 'true') +-- +STMT: AlterFdwStmt +== 374 +-- ERROR +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +== 375 +-- ERROR +GRANT USAGE ON FOREIGN DATA WRAPPER postgresql TO regress_test_role +-- +STMT: GrantStmt +== 376 +-- WARNING +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +== 377 +CREATE SERVER s9 FOREIGN DATA WRAPPER postgresql +-- +STMT: CreateForeignServerStmt +== 378 +ALTER SERVER s6 VERSION '0.5' +-- +STMT: AlterForeignServerStmt +== 379 +-- ERROR +DROP SERVER s6 +-- +STMT: DropStmt +== 380 +-- ERROR +GRANT USAGE ON FOREIGN SERVER s6 TO regress_test_role +-- +STMT: GrantStmt +== 381 +-- ERROR +GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role +-- +STMT: GrantStmt +== 382 +CREATE USER MAPPING FOR public SERVER s6 +-- +STMT: CreateUserMappingStmt +== 383 +-- ERROR +CREATE USER MAPPING FOR public SERVER s9 +-- +STMT: CreateUserMappingStmt +== 384 +ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +== 385 +-- ERROR +DROP USER MAPPING FOR regress_test_role SERVER s6 +-- +STMT: DropUserMappingStmt +== 386 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +== 387 +REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM regress_unprivileged_role +-- +STMT: GrantStmt +== 388 +-- ERROR +REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM regress_unprivileged_role CASCADE +-- +STMT: GrantStmt +== 389 +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +== 390 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +== 391 +-- ERROR +CREATE SERVER s10 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 392 +-- ERROR +ALTER SERVER s9 VERSION '1.1' +-- +STMT: AlterForeignServerStmt +== 393 +GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role +-- +STMT: GrantStmt +== 394 +CREATE USER MAPPING FOR current_user SERVER s9 +-- +STMT: CreateUserMappingStmt +== 395 +DROP SERVER s9 CASCADE +-- +STMT: DropStmt +== 396 +RESET ROLE +-- +STMT: VariableSetStmt +== 397 +CREATE SERVER s9 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 398 +GRANT USAGE ON FOREIGN SERVER s9 TO regress_unprivileged_role +-- +STMT: GrantStmt +== 399 +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +== 400 +ALTER SERVER s9 VERSION '1.2' +-- +STMT: AlterForeignServerStmt +== 401 +-- ERROR +GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role +-- +STMT: GrantStmt +== 402 +-- WARNING +CREATE USER MAPPING FOR current_user SERVER s9 +-- +STMT: CreateUserMappingStmt +== 403 +DROP SERVER s9 CASCADE +-- +STMT: DropStmt +== 404 +-- ERROR + +-- Check visibility of user mapping data +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +== 405 +CREATE SERVER s10 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +== 406 +CREATE USER MAPPING FOR public SERVER s10 OPTIONS (user 'secret') +-- +STMT: CreateUserMappingStmt +== 407 +CREATE USER MAPPING FOR regress_unprivileged_role SERVER s10 OPTIONS (user 'secret') +-- +STMT: CreateUserMappingStmt +== 408 +-- owner of server can see some option fields +RESET ROLE +-- +STMT: VariableSetStmt +== 409 +-- superuser can see all option fields +-- unprivileged user cannot see any option field +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +== 410 +RESET ROLE +-- +STMT: VariableSetStmt +== 411 +DROP SERVER s10 CASCADE +-- +STMT: DropStmt +== 412 +-- Triggers +CREATE FUNCTION dummy_trigger() RETURNS TRIGGER AS $$ + BEGIN + RETURN NULL; + END +$$ language plpgsql +-- +FUNCTION: name="dummy_trigger" function="dummy_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 413 +CREATE TRIGGER trigtest_before_stmt BEFORE INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH STATEMENT +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +== 414 +CREATE TRIGGER trigtest_after_stmt AFTER INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH STATEMENT +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +== 415 +CREATE TRIGGER trigtest_after_stmt_tt AFTER INSERT OR UPDATE OR DELETE -- ERROR +ON foreign_schema.foreign_table_1 +REFERENCING NEW TABLE AS new_table +FOR EACH STATEMENT +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +== 416 +CREATE TRIGGER trigtest_before_row BEFORE INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH ROW +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +== 417 +CREATE TRIGGER trigtest_after_row AFTER INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH ROW +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +== 418 +CREATE CONSTRAINT TRIGGER trigtest_constraint AFTER INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH ROW +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +== 419 +ALTER FOREIGN TABLE foreign_schema.foreign_table_1 + DISABLE TRIGGER trigtest_before_stmt +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: AlterTableStmt +== 420 +ALTER FOREIGN TABLE foreign_schema.foreign_table_1 + ENABLE TRIGGER trigtest_before_stmt +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: AlterTableStmt +== 421 +DROP TRIGGER trigtest_before_stmt ON foreign_schema.foreign_table_1 +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: DropStmt +== 422 +DROP TRIGGER trigtest_before_row ON foreign_schema.foreign_table_1 +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: DropStmt +== 423 +DROP TRIGGER trigtest_after_stmt ON foreign_schema.foreign_table_1 +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: DropStmt +== 424 +DROP TRIGGER trigtest_after_row ON foreign_schema.foreign_table_1 +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: DropStmt +== 425 +DROP FUNCTION dummy_trigger() +-- +FUNCTION: name="dummy_trigger" function="dummy_trigger" schema="" ctx=DDL +STMT: DropStmt +== 426 +-- Table inheritance +CREATE TABLE fd_pt1 ( + c1 integer NOT NULL, + c2 text, + c3 date +) +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: CreateStmt +== 427 +CREATE FOREIGN TABLE ft2 () INHERITS (fd_pt1) + SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 428 +DROP FOREIGN TABLE ft2 +-- +STMT: DropStmt +== 429 +CREATE FOREIGN TABLE ft2 ( + c1 integer NOT NULL, + c2 text, + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 430 +ALTER FOREIGN TABLE ft2 INHERIT fd_pt1 +-- +TABLE: name="ft2" schema="" table="ft2" ctx=DDL +STMT: AlterTableStmt +== 431 +CREATE TABLE ct3() INHERITS(ft2) +-- +TABLE: name="ct3" schema="" table="ct3" ctx=DDL +STMT: CreateStmt +== 432 +CREATE FOREIGN TABLE ft3 ( + c1 integer NOT NULL, + c2 text, + c3 date +) INHERITS(ft2) + SERVER s0 +-- +STMT: CreateForeignTableStmt +== 433 +-- add attributes recursively +ALTER TABLE fd_pt1 ADD COLUMN c4 integer +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 434 +ALTER TABLE fd_pt1 ADD COLUMN c5 integer DEFAULT 0 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 435 +ALTER TABLE fd_pt1 ADD COLUMN c6 integer +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 436 +ALTER TABLE fd_pt1 ADD COLUMN c7 integer NOT NULL +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 437 +ALTER TABLE fd_pt1 ADD COLUMN c8 integer +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 438 +-- alter attributes recursively +ALTER TABLE fd_pt1 ALTER COLUMN c4 SET DEFAULT 0 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 439 +ALTER TABLE fd_pt1 ALTER COLUMN c5 DROP DEFAULT +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 440 +ALTER TABLE fd_pt1 ALTER COLUMN c6 SET NOT NULL +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 441 +ALTER TABLE fd_pt1 ALTER COLUMN c7 DROP NOT NULL +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 442 +ALTER TABLE fd_pt1 ALTER COLUMN c8 TYPE char(10) USING '0' +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 443 +-- ERROR +ALTER TABLE fd_pt1 ALTER COLUMN c8 TYPE char(10) +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 444 +ALTER TABLE fd_pt1 ALTER COLUMN c8 SET DATA TYPE text +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 445 +ALTER TABLE fd_pt1 ALTER COLUMN c1 SET STATISTICS 10000 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 446 +ALTER TABLE fd_pt1 ALTER COLUMN c1 SET (n_distinct = 100) +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 447 +ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STATISTICS -1 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 448 +ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STORAGE EXTERNAL +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 449 +-- drop attributes recursively +ALTER TABLE fd_pt1 DROP COLUMN c4 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 450 +ALTER TABLE fd_pt1 DROP COLUMN c5 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 451 +ALTER TABLE fd_pt1 DROP COLUMN c6 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 452 +ALTER TABLE fd_pt1 DROP COLUMN c7 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 453 +ALTER TABLE fd_pt1 DROP COLUMN c8 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 454 +-- add constraints recursively +ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk1 CHECK (c1 > 0) NO INHERIT +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 455 +ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk2 CHECK (c2 <> '') +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 456 +-- connoinherit should be true for NO INHERIT constraint +SELECT relname, conname, contype, conislocal, coninhcount, connoinherit + FROM pg_class AS pc JOIN pg_constraint AS pgc ON (conrelid = pc.oid) + WHERE pc.relname = 'fd_pt1' + ORDER BY 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 457 +-- child does not inherit NO INHERIT constraints +DROP FOREIGN TABLE ft2 +-- +STMT: DropStmt +== 458 +-- ERROR +DROP FOREIGN TABLE ft2 CASCADE +-- +STMT: DropStmt +== 459 +CREATE FOREIGN TABLE ft2 ( + c1 integer NOT NULL, + c2 text, + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 460 +-- child must have parent's INHERIT constraints +ALTER FOREIGN TABLE ft2 INHERIT fd_pt1 +-- +TABLE: name="ft2" schema="" table="ft2" ctx=DDL +STMT: AlterTableStmt +== 461 +-- ERROR +ALTER FOREIGN TABLE ft2 ADD CONSTRAINT fd_pt1chk2 CHECK (c2 <> '') +-- +TABLE: name="ft2" schema="" table="ft2" ctx=DDL +STMT: AlterTableStmt +== 462 +ALTER FOREIGN TABLE ft2 INHERIT fd_pt1 +-- +TABLE: name="ft2" schema="" table="ft2" ctx=DDL +STMT: AlterTableStmt +== 463 +-- child does not inherit NO INHERIT constraints + +-- drop constraints recursively +ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk1 CASCADE +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 464 +ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk2 CASCADE +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 465 +-- NOT VALID case +INSERT INTO fd_pt1 VALUES (1, 'fd_pt1'::text, '1994-01-01'::date) +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 466 +ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk3 CHECK (c2 <> '') NOT VALID +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 467 +-- VALIDATE CONSTRAINT need do nothing on foreign tables +ALTER TABLE fd_pt1 VALIDATE CONSTRAINT fd_pt1chk3 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +== 468 +-- changes name of an attribute recursively +ALTER TABLE fd_pt1 RENAME COLUMN c1 TO f1 +-- +STMT: RenameStmt +== 469 +ALTER TABLE fd_pt1 RENAME COLUMN c2 TO f2 +-- +STMT: RenameStmt +== 470 +ALTER TABLE fd_pt1 RENAME COLUMN c3 TO f3 +-- +STMT: RenameStmt +== 471 +-- changes name of a constraint recursively +ALTER TABLE fd_pt1 RENAME CONSTRAINT fd_pt1chk3 TO f2_check +-- +STMT: RenameStmt +== 472 +DROP TABLE fd_pt1 CASCADE +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: DropStmt +== 473 +-- IMPORT FOREIGN SCHEMA +IMPORT FOREIGN SCHEMA s1 FROM SERVER s9 INTO public +-- +STMT: ImportForeignSchemaStmt +== 474 +-- ERROR +IMPORT FOREIGN SCHEMA s1 LIMIT TO (t1) FROM SERVER s9 INTO public +-- +STMT: ImportForeignSchemaStmt +== 475 +--ERROR +IMPORT FOREIGN SCHEMA s1 EXCEPT (t1) FROM SERVER s9 INTO public +-- +STMT: ImportForeignSchemaStmt +== 476 +-- ERROR +IMPORT FOREIGN SCHEMA s1 EXCEPT (t1, t2) FROM SERVER s9 INTO public +OPTIONS (option1 'value1', option2 'value2') +-- +STMT: ImportForeignSchemaStmt +== 477 +-- ERROR + +-- DROP FOREIGN TABLE +DROP FOREIGN TABLE no_table +-- +STMT: DropStmt +== 478 +-- ERROR +DROP FOREIGN TABLE IF EXISTS no_table +-- +STMT: DropStmt +== 479 +DROP FOREIGN TABLE foreign_schema.foreign_table_1 +-- +STMT: DropStmt +== 480 +-- REASSIGN OWNED/DROP OWNED of foreign objects +REASSIGN OWNED BY regress_test_role TO regress_test_role2 +-- +STMT: ReassignOwnedStmt +== 481 +DROP OWNED BY regress_test_role2 +-- +STMT: DropOwnedStmt +== 482 +DROP OWNED BY regress_test_role2 CASCADE +-- +STMT: DropOwnedStmt +== 483 +-- Foreign partition DDL stuff +CREATE TABLE fd_pt2 ( + c1 integer NOT NULL, + c2 text, + c3 date +) PARTITION BY LIST (c1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: CreateStmt +== 484 +CREATE FOREIGN TABLE fd_pt2_1 PARTITION OF fd_pt2 FOR VALUES IN (1) + SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 485 +-- partition cannot have additional columns +DROP FOREIGN TABLE fd_pt2_1 +-- +STMT: DropStmt +== 486 +CREATE FOREIGN TABLE fd_pt2_1 ( + c1 integer NOT NULL, + c2 text, + c3 date, + c4 char +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 487 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 488 +-- ERROR + +DROP FOREIGN TABLE fd_pt2_1 +-- +STMT: DropStmt +== 489 +CREATE FOREIGN TABLE fd_pt2_1 ( + c1 integer NOT NULL, + c2 text, + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +== 490 +-- no attach partition validation occurs for foreign tables +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 491 +-- cannot add column to a partition +ALTER TABLE fd_pt2_1 ADD c4 char +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +== 492 +-- ok to have a partition's own constraints though +ALTER TABLE fd_pt2_1 ALTER c3 SET NOT NULL +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +== 493 +ALTER TABLE fd_pt2_1 ADD CONSTRAINT p21chk CHECK (c2 <> '') +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +== 494 +-- cannot drop inherited NOT NULL constraint from a partition +ALTER TABLE fd_pt2_1 ALTER c1 DROP NOT NULL +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +== 495 +-- partition must have parent's constraints +ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1 +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 496 +ALTER TABLE fd_pt2 ALTER c2 SET NOT NULL +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 497 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 498 +-- ERROR +ALTER FOREIGN TABLE fd_pt2_1 ALTER c2 SET NOT NULL +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +== 499 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 500 +ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1 +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 501 +ALTER TABLE fd_pt2 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 502 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 503 +-- ERROR +ALTER FOREIGN TABLE fd_pt2_1 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0) +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +== 504 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +== 505 +DROP FOREIGN TABLE fd_pt2_1 +-- +STMT: DropStmt +== 506 +DROP TABLE fd_pt2 +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: DropStmt +== 507 +-- foreign table cannot be part of partition tree made of temporary +-- relations. +CREATE TEMP TABLE temp_parted (a int) PARTITION BY LIST (a) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: CreateStmt +== 508 +CREATE FOREIGN TABLE foreign_part PARTITION OF temp_parted DEFAULT + SERVER s0 +-- +STMT: CreateForeignTableStmt +== 509 +-- ERROR +CREATE FOREIGN TABLE foreign_part (a int) SERVER s0 +-- +STMT: CreateForeignTableStmt +== 510 +ALTER TABLE temp_parted ATTACH PARTITION foreign_part DEFAULT +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: AlterTableStmt +== 511 +-- ERROR +DROP FOREIGN TABLE foreign_part +-- +STMT: DropStmt +== 512 +DROP TABLE temp_parted +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: DropStmt +== 513 +-- Cleanup +DROP SCHEMA foreign_schema CASCADE +-- +STMT: DropStmt +== 514 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +== 515 +-- ERROR +DROP SERVER t1 CASCADE +-- +STMT: DropStmt +== 516 +DROP USER MAPPING FOR regress_test_role SERVER s6 +-- +STMT: DropUserMappingStmt +== 517 +DROP FOREIGN DATA WRAPPER foo CASCADE +-- +STMT: DropStmt +== 518 +DROP SERVER s8 CASCADE +-- +STMT: DropStmt +== 519 +DROP ROLE regress_test_indirect +-- +STMT: DropRoleStmt +== 520 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +== 521 +DROP ROLE regress_unprivileged_role +-- +STMT: DropRoleStmt +== 522 +-- ERROR +REVOKE ALL ON FOREIGN DATA WRAPPER postgresql FROM regress_unprivileged_role +-- +STMT: GrantStmt +== 523 +DROP ROLE regress_unprivileged_role +-- +STMT: DropRoleStmt +== 524 +DROP ROLE regress_test_role2 +-- +STMT: DropRoleStmt +== 525 +DROP FOREIGN DATA WRAPPER postgresql CASCADE +-- +STMT: DropStmt +== 526 +DROP FOREIGN DATA WRAPPER dummy CASCADE +-- +STMT: DropStmt +== 527 +DROP ROLE regress_foreign_data_user +-- +STMT: DropRoleStmt +== 528 +-- At this point we should have no wrappers, no servers, and no mappings. +SELECT fdwname, fdwhandler, fdwvalidator, fdwoptions FROM pg_foreign_data_wrapper +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +STMT: SelectStmt +== 529 +SELECT srvname, srvoptions FROM pg_foreign_server +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +STMT: SelectStmt +== 530 +SELECT * FROM pg_user_mapping +-- +TABLE: name="pg_user_mapping" schema="" table="pg_user_mapping" ctx=Select +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/foreign_key.metadata.json b/parser/testdata/summary/postgres_regress/foreign_key.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/foreign_key.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/foreign_key.test b/parser/testdata/summary/postgres_regress/foreign_key.test new file mode 100644 index 0000000..412f612 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/foreign_key.test @@ -0,0 +1,6735 @@ +== 001 +|-- +-- FOREIGN KEY +|-- + +-- MATCH FULL +|-- +-- First test, check and cascade +|-- +CREATE TABLE PKTABLE ( ptest1 int PRIMARY KEY, ptest2 text ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE FKTABLE ( ftest1 int REFERENCES PKTABLE MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE, ftest2 int ) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 003 +-- Insert test data into PKTABLE +INSERT INTO PKTABLE VALUES (1, 'Test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO PKTABLE VALUES (2, 'Test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO PKTABLE VALUES (3, 'Test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO PKTABLE VALUES (4, 'Test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO PKTABLE VALUES (5, 'Test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +-- Insert successful rows into FK TABLE +INSERT INTO FKTABLE VALUES (1, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO FKTABLE VALUES (2, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO FKTABLE VALUES (3, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO FKTABLE VALUES (NULL, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +-- Insert a failed row into FK TABLE +INSERT INTO FKTABLE VALUES (100, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +-- Check FKTABLE +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 014 +-- Delete a row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 015 +-- Check FKTABLE for removal of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 016 +-- Update a row from PK TABLE +UPDATE PKTABLE SET ptest1=1 WHERE ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 017 +-- Check FKTABLE for update of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 018 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 019 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 020 +|-- +-- check set NULL and table constraint on multiple columns +|-- +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY(ptest1, ptest2) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 021 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, CONSTRAINT constrname FOREIGN KEY(ftest1, ftest2) + REFERENCES PKTABLE MATCH FULL ON DELETE SET NULL ON UPDATE SET NULL) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 022 +-- Test comments +COMMENT ON CONSTRAINT constrname_wrong ON FKTABLE IS 'fk constraint comment' +-- +STMT: CommentStmt +== 023 +COMMENT ON CONSTRAINT constrname ON FKTABLE IS 'fk constraint comment' +-- +STMT: CommentStmt +== 024 +COMMENT ON CONSTRAINT constrname ON FKTABLE IS NULL +-- +STMT: CommentStmt +== 025 +-- Insert test data into PKTABLE +INSERT INTO PKTABLE VALUES (1, 2, 'Test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO PKTABLE VALUES (1, 3, 'Test1-2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO PKTABLE VALUES (2, 4, 'Test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO PKTABLE VALUES (3, 6, 'Test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +INSERT INTO PKTABLE VALUES (4, 8, 'Test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO PKTABLE VALUES (5, 10, 'Test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +-- Insert successful rows into FK TABLE +INSERT INTO FKTABLE VALUES (1, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO FKTABLE VALUES (1, 3, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO FKTABLE VALUES (2, 4, 8) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO FKTABLE VALUES (3, 6, 12) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO FKTABLE VALUES (NULL, NULL, 0) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +-- Insert failed rows into FK TABLE +INSERT INTO FKTABLE VALUES (100, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO FKTABLE VALUES (2, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO FKTABLE VALUES (NULL, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO FKTABLE VALUES (1, NULL, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +-- Check FKTABLE +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 041 +-- Delete a row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=1 and ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 042 +-- Check FKTABLE for removal of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 043 +-- Delete another row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=5 and ptest2=10 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 044 +-- Check FKTABLE (should be no change) +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 045 +-- Update a row from PK TABLE +UPDATE PKTABLE SET ptest1=1 WHERE ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 046 +-- Check FKTABLE for update of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 047 +-- Check update with part of key null +UPDATE FKTABLE SET ftest1 = NULL WHERE ftest1 = 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 048 +-- Check update with old and new key values equal +UPDATE FKTABLE SET ftest1 = 1 WHERE ftest1 = 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 049 +-- Try altering the column type where foreign keys are involved +ALTER TABLE PKTABLE ALTER COLUMN ptest1 TYPE bigint +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: AlterTableStmt +== 050 +ALTER TABLE FKTABLE ALTER COLUMN ftest1 TYPE bigint +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 051 +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 052 +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 053 +DROP TABLE PKTABLE CASCADE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 054 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 055 +|-- +-- check set default and table constraint on multiple columns +|-- +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY(ptest1, ptest2) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 056 +CREATE TABLE FKTABLE ( ftest1 int DEFAULT -1, ftest2 int DEFAULT -2, ftest3 int, CONSTRAINT constrname2 FOREIGN KEY(ftest1, ftest2) + REFERENCES PKTABLE MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 057 +-- Insert a value in PKTABLE for default +INSERT INTO PKTABLE VALUES (-1, -2, 'The Default!') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +-- Insert test data into PKTABLE +INSERT INTO PKTABLE VALUES (1, 2, 'Test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +INSERT INTO PKTABLE VALUES (1, 3, 'Test1-2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +INSERT INTO PKTABLE VALUES (2, 4, 'Test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +INSERT INTO PKTABLE VALUES (3, 6, 'Test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +INSERT INTO PKTABLE VALUES (4, 8, 'Test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +INSERT INTO PKTABLE VALUES (5, 10, 'Test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +-- Insert successful rows into FK TABLE +INSERT INTO FKTABLE VALUES (1, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +INSERT INTO FKTABLE VALUES (1, 3, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 066 +INSERT INTO FKTABLE VALUES (2, 4, 8) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +INSERT INTO FKTABLE VALUES (3, 6, 12) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 068 +INSERT INTO FKTABLE VALUES (NULL, NULL, 0) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 069 +-- Insert failed rows into FK TABLE +INSERT INTO FKTABLE VALUES (100, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +INSERT INTO FKTABLE VALUES (2, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +INSERT INTO FKTABLE VALUES (NULL, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +INSERT INTO FKTABLE VALUES (1, NULL, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +-- Check FKTABLE +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 074 +-- Delete a row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=1 and ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 075 +-- Check FKTABLE to check for removal +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 076 +-- Delete another row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=5 and ptest2=10 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 077 +-- Check FKTABLE (should be no change) +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 078 +-- Update a row from PK TABLE +UPDATE PKTABLE SET ptest1=1 WHERE ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 079 +-- Check FKTABLE for update of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 080 +-- this should fail for lack of CASCADE +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 081 +DROP TABLE PKTABLE CASCADE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 082 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 083 +|-- +-- First test, check with no on delete or on update +|-- +CREATE TABLE PKTABLE ( ptest1 int PRIMARY KEY, ptest2 text ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 084 +CREATE TABLE FKTABLE ( ftest1 int REFERENCES PKTABLE MATCH FULL, ftest2 int ) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 085 +-- Insert test data into PKTABLE +INSERT INTO PKTABLE VALUES (1, 'Test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 086 +INSERT INTO PKTABLE VALUES (2, 'Test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +INSERT INTO PKTABLE VALUES (3, 'Test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +INSERT INTO PKTABLE VALUES (4, 'Test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +INSERT INTO PKTABLE VALUES (5, 'Test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 090 +-- Insert successful rows into FK TABLE +INSERT INTO FKTABLE VALUES (1, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 091 +INSERT INTO FKTABLE VALUES (2, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +INSERT INTO FKTABLE VALUES (3, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +INSERT INTO FKTABLE VALUES (NULL, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 094 +-- Insert a failed row into FK TABLE +INSERT INTO FKTABLE VALUES (100, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +-- Check FKTABLE +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 096 +-- Check PKTABLE +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 097 +-- Delete a row from PK TABLE (should fail) +DELETE FROM PKTABLE WHERE ptest1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 098 +-- Delete a row from PK TABLE (should succeed) +DELETE FROM PKTABLE WHERE ptest1=5 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 099 +-- Check PKTABLE for deletes +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 100 +-- Update a row from PK TABLE (should fail) +UPDATE PKTABLE SET ptest1=0 WHERE ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 101 +-- Update a row from PK TABLE (should succeed) +UPDATE PKTABLE SET ptest1=0 WHERE ptest1=4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 102 +-- Check PKTABLE for updates +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 103 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 104 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 105 +|-- +-- Check initial check upon ALTER TABLE +|-- +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, PRIMARY KEY(ptest1, ptest2) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 106 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int ) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 107 +INSERT INTO PKTABLE VALUES (1, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +INSERT INTO FKTABLE VALUES (1, NULL) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) REFERENCES PKTABLE MATCH FULL +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 110 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 111 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 112 +-- MATCH SIMPLE + +-- Base test restricting update/delete +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 113 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 114 +-- Insert Primary Key values +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +INSERT INTO PKTABLE VALUES (1, 3, 3, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +INSERT INTO PKTABLE VALUES (2, 3, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +INSERT INTO PKTABLE VALUES (2, 4, 5, 'test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 118 +-- Insert Foreign Key values +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 119 +INSERT INTO FKTABLE VALUES (NULL, 2, 3, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 120 +INSERT INTO FKTABLE VALUES (2, NULL, 3, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +INSERT INTO FKTABLE VALUES (NULL, 2, 7, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +INSERT INTO FKTABLE VALUES (NULL, 3, 4, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +-- Insert a failed values +INSERT INTO FKTABLE VALUES (1, 2, 7, 6) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 124 +-- Show FKTABLE +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 125 +-- Try to update something that should fail +UPDATE PKTABLE set ptest2=5 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 126 +-- Try to update something that should succeed +UPDATE PKTABLE set ptest1=1 WHERE ptest2=3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 127 +-- Try to delete something that should fail +DELETE FROM PKTABLE where ptest1=1 and ptest2=2 and ptest3=3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 128 +-- Try to delete something that should work +DELETE FROM PKTABLE where ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 129 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 130 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 131 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 132 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 133 +-- restrict with null values +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, UNIQUE(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 134 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE (ptest1, ptest2, ptest3)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 135 +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +INSERT INTO PKTABLE VALUES (1, 3, NULL, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +INSERT INTO PKTABLE VALUES (2, NULL, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +DELETE FROM PKTABLE WHERE ptest1 = 2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 140 +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 141 +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 142 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 143 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 144 +-- cascade update/delete +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 145 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE + ON DELETE CASCADE ON UPDATE CASCADE) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 146 +-- Insert Primary Key values +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +INSERT INTO PKTABLE VALUES (1, 3, 3, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 148 +INSERT INTO PKTABLE VALUES (2, 3, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 149 +INSERT INTO PKTABLE VALUES (2, 4, 5, 'test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +-- Insert Foreign Key values +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 151 +INSERT INTO FKTABLE VALUES (NULL, 2, 3, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +INSERT INTO FKTABLE VALUES (2, NULL, 3, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 153 +INSERT INTO FKTABLE VALUES (NULL, 2, 7, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 154 +INSERT INTO FKTABLE VALUES (NULL, 3, 4, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +-- Insert a failed values +INSERT INTO FKTABLE VALUES (1, 2, 7, 6) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 156 +-- Show FKTABLE +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 157 +-- Try to update something that will cascade +UPDATE PKTABLE set ptest2=5 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 158 +-- Try to update something that should not cascade +UPDATE PKTABLE set ptest1=1 WHERE ptest2=3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 159 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 160 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 161 +-- Try to delete something that should cascade +DELETE FROM PKTABLE where ptest1=1 and ptest2=5 and ptest3=3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 162 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 163 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 164 +-- Try to delete something that should not have a cascade +DELETE FROM PKTABLE where ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 165 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 166 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 167 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 168 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 169 +-- set null update / set default delete +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 170 +CREATE TABLE FKTABLE ( ftest1 int DEFAULT 0, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE + ON DELETE SET DEFAULT ON UPDATE SET NULL) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 171 +-- Insert Primary Key values +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 172 +INSERT INTO PKTABLE VALUES (1, 3, 3, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +INSERT INTO PKTABLE VALUES (2, 3, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 174 +INSERT INTO PKTABLE VALUES (2, 4, 5, 'test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 175 +-- Insert Foreign Key values +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 176 +INSERT INTO FKTABLE VALUES (2, 3, 4, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 177 +INSERT INTO FKTABLE VALUES (NULL, 2, 3, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 178 +INSERT INTO FKTABLE VALUES (2, NULL, 3, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 179 +INSERT INTO FKTABLE VALUES (NULL, 2, 7, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 180 +INSERT INTO FKTABLE VALUES (NULL, 3, 4, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 181 +-- Insert a failed values +INSERT INTO FKTABLE VALUES (1, 2, 7, 6) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 182 +-- Show FKTABLE +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 183 +-- Try to update something that will set null +UPDATE PKTABLE set ptest2=5 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 184 +-- Try to update something that should not set null +UPDATE PKTABLE set ptest2=2 WHERE ptest2=3 and ptest1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 185 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 186 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 187 +-- Try to delete something that should set default +DELETE FROM PKTABLE where ptest1=2 and ptest2=3 and ptest3=4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 188 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 189 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 190 +-- Try to delete something that should not set default +DELETE FROM PKTABLE where ptest2=5 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 191 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 192 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 193 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 194 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 195 +-- set default update / set null delete +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 196 +CREATE TABLE FKTABLE ( ftest1 int DEFAULT 0, ftest2 int DEFAULT -1, ftest3 int DEFAULT -2, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE + ON DELETE SET NULL ON UPDATE SET DEFAULT) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 197 +-- Insert Primary Key values +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 198 +INSERT INTO PKTABLE VALUES (1, 3, 3, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 199 +INSERT INTO PKTABLE VALUES (2, 3, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 200 +INSERT INTO PKTABLE VALUES (2, 4, 5, 'test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 201 +INSERT INTO PKTABLE VALUES (2, -1, 5, 'test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +-- Insert Foreign Key values +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 203 +INSERT INTO FKTABLE VALUES (2, 3, 4, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 204 +INSERT INTO FKTABLE VALUES (2, 4, 5, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 205 +INSERT INTO FKTABLE VALUES (NULL, 2, 3, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 206 +INSERT INTO FKTABLE VALUES (2, NULL, 3, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 207 +INSERT INTO FKTABLE VALUES (NULL, 2, 7, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 208 +INSERT INTO FKTABLE VALUES (NULL, 3, 4, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 209 +-- Insert a failed values +INSERT INTO FKTABLE VALUES (1, 2, 7, 6) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 210 +-- Show FKTABLE +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 211 +-- Try to update something that will fail +UPDATE PKTABLE set ptest2=5 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 212 +-- Try to update something that will set default +UPDATE PKTABLE set ptest1=0, ptest2=-1, ptest3=-2 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 213 +UPDATE PKTABLE set ptest2=10 where ptest2=4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 214 +-- Try to update something that should not set default +UPDATE PKTABLE set ptest2=2 WHERE ptest2=3 and ptest1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 215 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 216 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 217 +-- Try to delete something that should set null +DELETE FROM PKTABLE where ptest1=2 and ptest2=3 and ptest3=4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 218 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 219 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 220 +-- Try to delete something that should not set null +DELETE FROM PKTABLE where ptest2=-1 and ptest3=5 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 221 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +== 222 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 223 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 224 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 225 +-- Test for ON DELETE SET NULL/DEFAULT (column_list); +CREATE TABLE PKTABLE (tid int, id int, PRIMARY KEY (tid, id)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 226 +CREATE TABLE FKTABLE (tid int, id int, foo int, FOREIGN KEY (tid, id) REFERENCES PKTABLE ON DELETE SET NULL (bar)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 227 +CREATE TABLE FKTABLE (tid int, id int, foo int, FOREIGN KEY (tid, id) REFERENCES PKTABLE ON DELETE SET NULL (foo)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 228 +CREATE TABLE FKTABLE (tid int, id int, foo int, FOREIGN KEY (tid, foo) REFERENCES PKTABLE ON UPDATE SET NULL (foo)) +-- +ERROR: a column list with SET NULL is only supported for ON DELETE actions +CURSORPOS: 91 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 229 +CREATE TABLE FKTABLE ( + tid int, id int, + fk_id_del_set_null int, + fk_id_del_set_default int DEFAULT 0, + FOREIGN KEY (tid, fk_id_del_set_null) REFERENCES PKTABLE ON DELETE SET NULL (fk_id_del_set_null), + -- this tests handling of duplicate entries in SET DEFAULT column list + FOREIGN KEY (tid, fk_id_del_set_default) REFERENCES PKTABLE ON DELETE SET DEFAULT (fk_id_del_set_default, fk_id_del_set_default) +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 230 +SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE conrelid = 'fktable'::regclass::oid ORDER BY oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 231 +INSERT INTO PKTABLE VALUES (1, 0), (1, 1), (1, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 232 +INSERT INTO FKTABLE VALUES + (1, 1, 1, NULL), + (1, 2, NULL, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 233 +DELETE FROM PKTABLE WHERE id = 1 OR id = 2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 234 +SELECT * FROM FKTABLE ORDER BY id +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +== 235 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 236 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 237 +-- Test some invalid FK definitions +CREATE TABLE PKTABLE (ptest1 int PRIMARY KEY, someoid oid) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 238 +CREATE TABLE FKTABLE_FAIL1 ( ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (ftest2) REFERENCES PKTABLE) +-- +TABLE: name="fktable_fail1" schema="" table="fktable_fail1" ctx=DDL +STMT: CreateStmt +== 239 +CREATE TABLE FKTABLE_FAIL2 ( ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (ftest1) REFERENCES PKTABLE(ptest2)) +-- +TABLE: name="fktable_fail2" schema="" table="fktable_fail2" ctx=DDL +STMT: CreateStmt +== 240 +CREATE TABLE FKTABLE_FAIL3 ( ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (tableoid) REFERENCES PKTABLE(someoid)) +-- +TABLE: name="fktable_fail3" schema="" table="fktable_fail3" ctx=DDL +STMT: CreateStmt +== 241 +CREATE TABLE FKTABLE_FAIL4 ( ftest1 oid, CONSTRAINT fkfail1 FOREIGN KEY (ftest1) REFERENCES PKTABLE(tableoid)) +-- +TABLE: name="fktable_fail4" schema="" table="fktable_fail4" ctx=DDL +STMT: CreateStmt +== 242 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 243 +-- Test for referencing column number smaller than referenced constraint +CREATE TABLE PKTABLE (ptest1 int, ptest2 int, UNIQUE(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 244 +CREATE TABLE FKTABLE_FAIL1 (ftest1 int REFERENCES pktable(ptest1)) +-- +TABLE: name="fktable_fail1" schema="" table="fktable_fail1" ctx=DDL +STMT: CreateStmt +== 245 +DROP TABLE FKTABLE_FAIL1 +-- +TABLE: name="fktable_fail1" schema="" table="fktable_fail1" ctx=DDL +STMT: DropStmt +== 246 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 247 +|-- +-- Tests for mismatched types +|-- +-- Basic one column, two table setup +CREATE TABLE PKTABLE (ptest1 int PRIMARY KEY) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 248 +INSERT INTO PKTABLE VALUES(42) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 249 +-- This next should fail, because int=inet does not exist +CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 250 +-- This should also fail for the same reason, but here we +-- give the column name +CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable(ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 251 +-- This should succeed, even though they are different types, +-- because int=int8 exists and is a member of the integer opfamily +CREATE TABLE FKTABLE (ftest1 int8 REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 252 +-- Check it actually works +INSERT INTO FKTABLE VALUES(42) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +-- should succeed +INSERT INTO FKTABLE VALUES(43) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 254 +-- should fail +UPDATE FKTABLE SET ftest1 = ftest1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 255 +-- should succeed +UPDATE FKTABLE SET ftest1 = ftest1 + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 256 +-- should fail +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 257 +-- This should fail, because we'd have to cast numeric to int which is +-- not an implicit coercion (or use numeric=numeric, but that's not part +-- of the integer opfamily) +CREATE TABLE FKTABLE (ftest1 numeric REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 258 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 259 +-- On the other hand, this should work because int implicitly promotes to +-- numeric, and we allow promotion on the FK side +CREATE TABLE PKTABLE (ptest1 numeric PRIMARY KEY) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 260 +INSERT INTO PKTABLE VALUES(42) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 261 +CREATE TABLE FKTABLE (ftest1 int REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 262 +-- Check it actually works +INSERT INTO FKTABLE VALUES(42) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 263 +-- should succeed +INSERT INTO FKTABLE VALUES(43) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 264 +-- should fail +UPDATE FKTABLE SET ftest1 = ftest1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 265 +-- should succeed +UPDATE FKTABLE SET ftest1 = ftest1 + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 266 +-- should fail +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 267 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 268 +-- Two columns, two tables +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, PRIMARY KEY(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 269 +-- This should fail, because we just chose really odd types +CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 270 +-- Again, so should this... +CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 271 +-- This fails because we mixed up the column ordering +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 272 +-- As does this... +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 273 +-- And again.. +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest2, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 274 +-- This works... +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest2, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 275 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 276 +-- As does this +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 277 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 278 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 279 +-- Two columns, same table +-- Make sure this still works... +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3, +ptest4) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 280 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 281 +-- And this, +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3, +ptest4) REFERENCES pktable) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 282 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 283 +-- This shouldn't (mixed up columns) +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3, +ptest4) REFERENCES pktable(ptest2, ptest1)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 284 +-- Nor should this... (same reason, we have 4,3 referencing 1,2 which mismatches types +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4, +ptest3) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 285 +-- Not this one either... Same as the last one except we didn't defined the columns being referenced. +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4, +ptest3) REFERENCES pktable) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 286 +|-- +-- Now some cases with inheritance +-- Basic 2 table case: 1 column of matching types. +create table pktable_base (base1 int not null) +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: CreateStmt +== 287 +create table pktable (ptest1 int, primary key(base1), unique(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 288 +create table fktable (ftest1 int references pktable(base1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 289 +-- now some ins, upd, del +insert into pktable(base1) values (1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 290 +insert into pktable(base1) values (2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 291 +-- let's insert a non-existent fktable value +insert into fktable(ftest1) values (3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 292 +-- let's make a valid row for that +insert into pktable(base1) values (3) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +insert into fktable(ftest1) values (3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 294 +-- let's try removing a row that should fail from pktable +delete from pktable where base1>2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 295 +-- okay, let's try updating all of the base1 values to *4 +-- which should fail. +update pktable set base1=base1*4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 296 +-- okay, let's try an update that should work. +update pktable set base1=base1*4 where base1<3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 297 +-- and a delete that should work +delete from pktable where base1>3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 298 +-- cleanup +drop table fktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 299 +delete from pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 300 +-- Now 2 columns 2 tables, matching types +create table fktable (ftest1 int, ftest2 int, foreign key(ftest1, ftest2) references pktable(base1, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 301 +-- now some ins, upd, del +insert into pktable(base1, ptest1) values (1, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 302 +insert into pktable(base1, ptest1) values (2, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 303 +-- let's insert a non-existent fktable value +insert into fktable(ftest1, ftest2) values (3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 304 +-- let's make a valid row for that +insert into pktable(base1,ptest1) values (3, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 305 +insert into fktable(ftest1, ftest2) values (3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 306 +-- let's try removing a row that should fail from pktable +delete from pktable where base1>2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 307 +-- okay, let's try updating all of the base1 values to *4 +-- which should fail. +update pktable set base1=base1*4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 308 +-- okay, let's try an update that should work. +update pktable set base1=base1*4 where base1<3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 309 +-- and a delete that should work +delete from pktable where base1>3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 310 +-- cleanup +drop table fktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 311 +drop table pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 312 +drop table pktable_base +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: DropStmt +== 313 +-- Now we'll do one all in 1 table with 2 columns of matching types +create table pktable_base(base1 int not null, base2 int) +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: CreateStmt +== 314 +create table pktable(ptest1 int, ptest2 int, primary key(base1, ptest1), foreign key(base2, ptest2) references + pktable(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 315 +insert into pktable (base1, ptest1, base2, ptest2) values (1, 1, 1, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 316 +insert into pktable (base1, ptest1, base2, ptest2) values (2, 1, 1, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 317 +insert into pktable (base1, ptest1, base2, ptest2) values (2, 2, 2, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 318 +insert into pktable (base1, ptest1, base2, ptest2) values (1, 3, 2, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 319 +-- fails (3,2) isn't in base1, ptest1 +insert into pktable (base1, ptest1, base2, ptest2) values (2, 3, 3, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 320 +-- fails (2,2) is being referenced +delete from pktable where base1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 321 +-- fails (1,1) is being referenced (twice) +update pktable set base1=3 where base1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 322 +-- this sequence of two deletes will work, since after the first there will be no (2,*) references +delete from pktable where base2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 323 +delete from pktable where base1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +== 324 +drop table pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 325 +drop table pktable_base +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: DropStmt +== 326 +-- 2 columns (2 tables), mismatched types +create table pktable_base(base1 int not null) +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: CreateStmt +== 327 +create table pktable(ptest1 inet, primary key(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 328 +-- just generally bad types (with and without column references on the referenced table) +create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 329 +create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable(base1, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 330 +-- let's mix up which columns reference which +create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 331 +create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable(base1, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 332 +create table fktable(ftest1 int, ftest2 inet, foreign key(ftest1, ftest2) references pktable(ptest1, base1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 333 +drop table pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 334 +drop table pktable_base +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: DropStmt +== 335 +-- 2 columns (1 table), mismatched types +create table pktable_base(base1 int not null, base2 int) +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: CreateStmt +== 336 +create table pktable(ptest1 inet, ptest2 inet[], primary key(base1, ptest1), foreign key(base2, ptest2) references + pktable(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 337 +create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(base2, ptest2) references + pktable(ptest1, base1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 338 +create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references + pktable(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 339 +create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references + pktable(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 340 +drop table pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 341 +drop table pktable_base +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: DropStmt +== 342 +|-- +-- Deferrable constraints +|-- + +-- deferrable, explicitly deferred +CREATE TABLE pktable ( + id INT4 PRIMARY KEY, + other INT4 +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 343 +CREATE TABLE fktable ( + id INT4 PRIMARY KEY, + fk INT4 REFERENCES pktable DEFERRABLE +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 344 +-- default to immediate: should fail +INSERT INTO fktable VALUES (5, 10) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 345 +-- explicitly defer the constraint +BEGIN +-- +STMT: TransactionStmt +== 346 +SET CONSTRAINTS ALL DEFERRED +-- +STMT: ConstraintsSetStmt +== 347 +INSERT INTO fktable VALUES (10, 15) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 348 +INSERT INTO pktable VALUES (15, 0) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 349 +-- make the FK insert valid + +COMMIT +-- +STMT: TransactionStmt +== 350 +DROP TABLE fktable, pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 351 +-- deferrable, initially deferred +CREATE TABLE pktable ( + id INT4 PRIMARY KEY, + other INT4 +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 352 +CREATE TABLE fktable ( + id INT4 PRIMARY KEY, + fk INT4 REFERENCES pktable DEFERRABLE INITIALLY DEFERRED +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 353 +-- default to deferred, should succeed +BEGIN +-- +STMT: TransactionStmt +== 354 +INSERT INTO fktable VALUES (100, 200) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 355 +INSERT INTO pktable VALUES (200, 500) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 356 +-- make the FK insert valid + +COMMIT +-- +STMT: TransactionStmt +== 357 +-- default to deferred, explicitly make immediate +BEGIN +-- +STMT: TransactionStmt +== 358 +SET CONSTRAINTS ALL IMMEDIATE +-- +STMT: ConstraintsSetStmt +== 359 +-- should fail +INSERT INTO fktable VALUES (500, 1000) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 360 +COMMIT +-- +STMT: TransactionStmt +== 361 +DROP TABLE fktable, pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 362 +-- tricky behavior: according to SQL99, if a deferred constraint is set +-- to 'immediate' mode, it should be checked for validity *immediately*, +-- not when the current transaction commits (i.e. the mode change applies +-- retroactively) +CREATE TABLE pktable ( + id INT4 PRIMARY KEY, + other INT4 +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 363 +CREATE TABLE fktable ( + id INT4 PRIMARY KEY, + fk INT4 REFERENCES pktable DEFERRABLE +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 364 +BEGIN +-- +STMT: TransactionStmt +== 365 +SET CONSTRAINTS ALL DEFERRED +-- +STMT: ConstraintsSetStmt +== 366 +-- should succeed, for now +INSERT INTO fktable VALUES (1000, 2000) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 367 +-- should cause transaction abort, due to preceding error +SET CONSTRAINTS ALL IMMEDIATE +-- +STMT: ConstraintsSetStmt +== 368 +INSERT INTO pktable VALUES (2000, 3) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 369 +-- too late + +COMMIT +-- +STMT: TransactionStmt +== 370 +DROP TABLE fktable, pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +== 371 +-- deferrable, initially deferred +CREATE TABLE pktable ( + id INT4 PRIMARY KEY, + other INT4 +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 372 +CREATE TABLE fktable ( + id INT4 PRIMARY KEY, + fk INT4 REFERENCES pktable DEFERRABLE INITIALLY DEFERRED +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 373 +BEGIN +-- +STMT: TransactionStmt +== 374 +-- no error here +INSERT INTO fktable VALUES (100, 200) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 375 +-- error here on commit +COMMIT +-- +STMT: TransactionStmt +== 376 +DROP TABLE pktable, fktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 377 +-- test notice about expensive referential integrity checks, +-- where the index cannot be used because of type incompatibilities. + +CREATE TEMP TABLE pktable ( + id1 INT4 PRIMARY KEY, + id2 VARCHAR(4) UNIQUE, + id3 REAL UNIQUE, + UNIQUE(id1, id2, id3) +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 378 +CREATE TEMP TABLE fktable ( + x1 INT4 REFERENCES pktable(id1), + x2 VARCHAR(4) REFERENCES pktable(id2), + x3 REAL REFERENCES pktable(id3), + x4 TEXT, + x5 INT2 +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 379 +-- check individual constraints with alter table. + +-- should fail + +-- varchar does not promote to real +ALTER TABLE fktable ADD CONSTRAINT fk_2_3 +FOREIGN KEY (x2) REFERENCES pktable(id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 380 +-- nor to int4 +ALTER TABLE fktable ADD CONSTRAINT fk_2_1 +FOREIGN KEY (x2) REFERENCES pktable(id1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 381 +-- real does not promote to int4 +ALTER TABLE fktable ADD CONSTRAINT fk_3_1 +FOREIGN KEY (x3) REFERENCES pktable(id1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 382 +-- int4 does not promote to text +ALTER TABLE fktable ADD CONSTRAINT fk_1_2 +FOREIGN KEY (x1) REFERENCES pktable(id2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 383 +-- should succeed + +-- int4 promotes to real +ALTER TABLE fktable ADD CONSTRAINT fk_1_3 +FOREIGN KEY (x1) REFERENCES pktable(id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 384 +-- text is compatible with varchar +ALTER TABLE fktable ADD CONSTRAINT fk_4_2 +FOREIGN KEY (x4) REFERENCES pktable(id2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 385 +-- int2 is part of integer opfamily as of 8.0 +ALTER TABLE fktable ADD CONSTRAINT fk_5_1 +FOREIGN KEY (x5) REFERENCES pktable(id1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 386 +-- check multikey cases, especially out-of-order column lists + +-- these should work + +ALTER TABLE fktable ADD CONSTRAINT fk_123_123 +FOREIGN KEY (x1,x2,x3) REFERENCES pktable(id1,id2,id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 387 +ALTER TABLE fktable ADD CONSTRAINT fk_213_213 +FOREIGN KEY (x2,x1,x3) REFERENCES pktable(id2,id1,id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 388 +ALTER TABLE fktable ADD CONSTRAINT fk_253_213 +FOREIGN KEY (x2,x5,x3) REFERENCES pktable(id2,id1,id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 389 +-- these should fail + +ALTER TABLE fktable ADD CONSTRAINT fk_123_231 +FOREIGN KEY (x1,x2,x3) REFERENCES pktable(id2,id3,id1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 390 +ALTER TABLE fktable ADD CONSTRAINT fk_241_132 +FOREIGN KEY (x2,x4,x1) REFERENCES pktable(id1,id3,id2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 391 +DROP TABLE pktable, fktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +== 392 +-- test a tricky case: we can elide firing the FK check trigger during +-- an UPDATE if the UPDATE did not change the foreign key +-- field. However, we can't do this if our transaction was the one that +-- created the updated row and the trigger is deferred, since our UPDATE +-- will have invalidated the original newly-inserted tuple, and therefore +-- cause the on-INSERT RI trigger not to be fired. + +CREATE TEMP TABLE pktable ( + id int primary key, + other int +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +== 393 +CREATE TEMP TABLE fktable ( + id int primary key, + fk int references pktable deferrable initially deferred +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +== 394 +INSERT INTO pktable VALUES (5, 10) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 395 +BEGIN +-- +STMT: TransactionStmt +== 396 +-- doesn't match PK, but no error yet +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 397 +-- don't change FK +UPDATE fktable SET id = id + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 398 +-- should catch error from initial INSERT +COMMIT +-- +STMT: TransactionStmt +== 399 +-- check same case when insert is in a different subtransaction than update + +BEGIN +-- +STMT: TransactionStmt +== 400 +-- doesn't match PK, but no error yet +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 401 +-- UPDATE will be in a subxact +SAVEPOINT savept1 +-- +STMT: TransactionStmt +== 402 +-- don't change FK +UPDATE fktable SET id = id + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 403 +-- should catch error from initial INSERT +COMMIT +-- +STMT: TransactionStmt +== 404 +BEGIN +-- +STMT: TransactionStmt +== 405 +-- INSERT will be in a subxact +SAVEPOINT savept1 +-- +STMT: TransactionStmt +== 406 +-- doesn't match PK, but no error yet +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 407 +RELEASE SAVEPOINT savept1 +-- +STMT: TransactionStmt +== 408 +-- don't change FK +UPDATE fktable SET id = id + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 409 +-- should catch error from initial INSERT +COMMIT +-- +STMT: TransactionStmt +== 410 +BEGIN +-- +STMT: TransactionStmt +== 411 +-- doesn't match PK, but no error yet +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 412 +-- UPDATE will be in a subxact +SAVEPOINT savept1 +-- +STMT: TransactionStmt +== 413 +-- don't change FK +UPDATE fktable SET id = id + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +== 414 +-- Roll back the UPDATE +ROLLBACK TO savept1 +-- +STMT: TransactionStmt +== 415 +-- should catch error from initial INSERT +COMMIT +-- +STMT: TransactionStmt +== 416 +|-- +-- check ALTER CONSTRAINT +|-- + +INSERT INTO fktable VALUES (1, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 417 +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey DEFERRABLE INITIALLY IMMEDIATE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 418 +BEGIN +-- +STMT: TransactionStmt +== 419 +-- doesn't match FK, should throw error now +UPDATE pktable SET id = 10 WHERE id = 5 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +== 420 +COMMIT +-- +STMT: TransactionStmt +== 421 +BEGIN +-- +STMT: TransactionStmt +== 422 +-- doesn't match PK, should throw error now +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 423 +COMMIT +-- +STMT: TransactionStmt +== 424 +-- try additional syntax +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +== 425 +-- illegal options +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE INITIALLY DEFERRED +-- +ERROR: constraint declared INITIALLY DEFERRED must be DEFERRABLE +CURSORPOS: 88 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 426 +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NO INHERIT +-- +ERROR: FOREIGN KEY constraints cannot be marked NO INHERIT +FILENAME: gram.y +FUNCNAME: processCASbits +== 427 +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT VALID +-- +ERROR: FOREIGN KEY constraints cannot be marked NOT VALID +FILENAME: gram.y +FUNCNAME: processCASbits +== 428 +-- test order of firing of FK triggers when several RI-induced changes need to +-- be made to the same row. This was broken by subtransaction-related +-- changes in 8.0. + +CREATE TEMP TABLE users ( + id INT PRIMARY KEY, + name VARCHAR NOT NULL +) +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: CreateStmt +== 429 +INSERT INTO users VALUES (1, 'Jozko') +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 430 +INSERT INTO users VALUES (2, 'Ferko') +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 431 +INSERT INTO users VALUES (3, 'Samko') +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 432 +CREATE TEMP TABLE tasks ( + id INT PRIMARY KEY, + owner INT REFERENCES users ON UPDATE CASCADE ON DELETE SET NULL, + worker INT REFERENCES users ON UPDATE CASCADE ON DELETE SET NULL, + checked_by INT REFERENCES users ON UPDATE CASCADE ON DELETE SET NULL +) +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DDL +STMT: CreateStmt +== 433 +INSERT INTO tasks VALUES (1,1,NULL,NULL) +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 434 +INSERT INTO tasks VALUES (2,2,2,NULL) +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 435 +INSERT INTO tasks VALUES (3,3,3,3) +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 436 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +== 437 +UPDATE users SET id = 4 WHERE id = 3 +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: UpdateStmt +== 438 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +== 439 +DELETE FROM users WHERE id = 4 +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: DeleteStmt +== 440 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +== 441 +-- could fail with only 2 changes to make, if row was already updated +BEGIN +-- +STMT: TransactionStmt +== 442 +UPDATE tasks set id=id WHERE id=2 +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DML +STMT: UpdateStmt +== 443 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +== 444 +DELETE FROM users WHERE id = 2 +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: DeleteStmt +== 445 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +== 446 +COMMIT +-- +STMT: TransactionStmt +== 447 +|-- +-- Test self-referential FK with CASCADE (bug #6268) +|-- +create temp table selfref ( + a int primary key, + b int, + foreign key (b) references selfref (a) + on update cascade on delete cascade +) +-- +TABLE: name="selfref" schema="" table="selfref" ctx=DDL +STMT: CreateStmt +== 448 +insert into selfref (a, b) +values + (0, 0), + (1, 1) +-- +TABLE: name="selfref" schema="" table="selfref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 449 +begin +-- +STMT: TransactionStmt +== 450 +update selfref set a = 123 where a = 0 +-- +TABLE: name="selfref" schema="" table="selfref" ctx=DML +STMT: UpdateStmt +== 451 +select a, b from selfref +-- +TABLE: name="selfref" schema="" table="selfref" ctx=Select +STMT: SelectStmt +== 452 +update selfref set a = 456 where a = 123 +-- +TABLE: name="selfref" schema="" table="selfref" ctx=DML +STMT: UpdateStmt +== 453 +select a, b from selfref +-- +TABLE: name="selfref" schema="" table="selfref" ctx=Select +STMT: SelectStmt +== 454 +commit +-- +STMT: TransactionStmt +== 455 +|-- +-- Test that SET DEFAULT actions recognize updates to default values +|-- +create temp table defp (f1 int primary key) +-- +TABLE: name="defp" schema="" table="defp" ctx=DDL +STMT: CreateStmt +== 456 +create temp table defc (f1 int default 0 + references defp on delete set default) +-- +TABLE: name="defc" schema="" table="defc" ctx=DDL +STMT: CreateStmt +== 457 +insert into defp values (0), (1), (2) +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 458 +insert into defc values (2) +-- +TABLE: name="defc" schema="" table="defc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 459 +select * from defc +-- +TABLE: name="defc" schema="" table="defc" ctx=Select +STMT: SelectStmt +== 460 +delete from defp where f1 = 2 +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: DeleteStmt +== 461 +select * from defc +-- +TABLE: name="defc" schema="" table="defc" ctx=Select +STMT: SelectStmt +== 462 +delete from defp where f1 = 0 +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: DeleteStmt +== 463 +-- fail +alter table defc alter column f1 set default 1 +-- +TABLE: name="defc" schema="" table="defc" ctx=DDL +STMT: AlterTableStmt +== 464 +delete from defp where f1 = 0 +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: DeleteStmt +== 465 +select * from defc +-- +TABLE: name="defc" schema="" table="defc" ctx=Select +STMT: SelectStmt +== 466 +delete from defp where f1 = 1 +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: DeleteStmt +== 467 +-- fail + +|-- +-- Test the difference between NO ACTION and RESTRICT +|-- +create temp table pp (f1 int primary key) +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +STMT: CreateStmt +== 468 +create temp table cc (f1 int references pp on update no action on delete no action) +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: CreateStmt +== 469 +insert into pp values(12) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 470 +insert into pp values(11) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 471 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +== 472 +insert into cc values(13) +-- +TABLE: name="cc" schema="" table="cc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 473 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +== 474 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +== 475 +-- fail +delete from pp where f1 = 13 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: DeleteStmt +== 476 +-- fail +drop table pp, cc +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: DropStmt +== 477 +create temp table pp (f1 int primary key) +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +STMT: CreateStmt +== 478 +create temp table cc (f1 int references pp on update restrict on delete restrict) +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: CreateStmt +== 479 +insert into pp values(12) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 480 +insert into pp values(11) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 481 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +== 482 +insert into cc values(13) +-- +TABLE: name="cc" schema="" table="cc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 483 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +== 484 +-- fail +delete from pp where f1 = 13 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: DeleteStmt +== 485 +-- fail +drop table pp, cc +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: DropStmt +== 486 +|-- +-- Test interaction of foreign-key optimization with rules (bug #14219) +|-- +create temp table t1 (a integer primary key, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 487 +create temp table t2 (a integer primary key, b integer references t1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 488 +create rule r1 as on delete to t1 do delete from t2 where t2.b = old.a +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +== 489 +explain (costs off) delete from t1 where a = 1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 490 +delete from t1 where a = 1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: DeleteStmt +== 491 +-- Test a primary key with attributes located in later attnum positions +-- compared to the fk attributes. +create table pktable2 (a int, b int, c int, d int, e int, primary key (d, e)) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +STMT: CreateStmt +== 492 +create table fktable2 (d int, e int, foreign key (d, e) references pktable2) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: CreateStmt +== 493 +insert into pktable2 values (1, 2, 3, 4, 5) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 494 +insert into fktable2 values (4, 5) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 495 +delete from pktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: DeleteStmt +== 496 +update pktable2 set d = 5 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: UpdateStmt +== 497 +drop table pktable2, fktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: DropStmt +== 498 +-- Test truncation of long foreign key names +create table pktable1 (a int primary key) +-- +TABLE: name="pktable1" schema="" table="pktable1" ctx=DDL +STMT: CreateStmt +== 499 +create table pktable2 (a int, b int, primary key (a, b)) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +STMT: CreateStmt +== 500 +create table fktable2 ( + a int, + b int, + very_very_long_column_name_to_exceed_63_characters int, + foreign key (very_very_long_column_name_to_exceed_63_characters) references pktable1, + foreign key (a, very_very_long_column_name_to_exceed_63_characters) references pktable2, + foreign key (a, very_very_long_column_name_to_exceed_63_characters) references pktable2 +) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: CreateStmt +== 501 +select conname from pg_constraint where conrelid = 'fktable2'::regclass order by conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 502 +drop table pktable1, pktable2, fktable2 +-- +TABLE: name="pktable1" schema="" table="pktable1" ctx=DDL +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: DropStmt +== 503 +|-- +-- Test deferred FK check on a tuple deleted by a rolled-back subtransaction +|-- +create table pktable2(f1 int primary key) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +STMT: CreateStmt +== 504 +create table fktable2(f1 int references pktable2 deferrable initially deferred) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: CreateStmt +== 505 +insert into pktable2 values(1) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 506 +begin +-- +STMT: TransactionStmt +== 507 +insert into fktable2 values(1) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 508 +savepoint x +-- +STMT: TransactionStmt +== 509 +delete from fktable2 +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: DeleteStmt +== 510 +rollback to x +-- +STMT: TransactionStmt +== 511 +commit +-- +STMT: TransactionStmt +== 512 +begin +-- +STMT: TransactionStmt +== 513 +insert into fktable2 values(2) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 514 +savepoint x +-- +STMT: TransactionStmt +== 515 +delete from fktable2 +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: DeleteStmt +== 516 +rollback to x +-- +STMT: TransactionStmt +== 517 +commit +-- +STMT: TransactionStmt +== 518 +-- fail + +|-- +-- Test that we prevent dropping FK constraint with pending trigger events +|-- +begin +-- +STMT: TransactionStmt +== 519 +insert into fktable2 values(2) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 520 +alter table fktable2 drop constraint fktable2_f1_fkey +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: AlterTableStmt +== 521 +commit +-- +STMT: TransactionStmt +== 522 +begin +-- +STMT: TransactionStmt +== 523 +delete from pktable2 where f1 = 1 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: DeleteStmt +== 524 +alter table fktable2 drop constraint fktable2_f1_fkey +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: AlterTableStmt +== 525 +commit +-- +STMT: TransactionStmt +== 526 +drop table pktable2, fktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: DropStmt +== 527 +|-- +-- Test keys that "look" different but compare as equal +|-- +create table pktable2 (a float8, b float8, primary key (a, b)) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +STMT: CreateStmt +== 528 +create table fktable2 (x float8, y float8, foreign key (x, y) references pktable2 (a, b) on update cascade) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: CreateStmt +== 529 +insert into pktable2 values ('-0', '-0') +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 530 +insert into fktable2 values ('-0', '-0') +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 531 +select * from pktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=Select +STMT: SelectStmt +== 532 +select * from fktable2 +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=Select +STMT: SelectStmt +== 533 +update pktable2 set a = '0' where a = '-0' +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: UpdateStmt +== 534 +select * from pktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=Select +STMT: SelectStmt +== 535 +-- should have updated fktable2.x +select * from fktable2 +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=Select +STMT: SelectStmt +== 536 +drop table pktable2, fktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: DropStmt +== 537 +|-- +-- Foreign keys and partitioned tables +|-- + +-- Creation of a partitioned hierarchy with irregular definitions +CREATE TABLE fk_notpartitioned_pk (fdrop1 int, a int, fdrop2 int, b int, + PRIMARY KEY (a, b)) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: CreateStmt +== 538 +ALTER TABLE fk_notpartitioned_pk DROP COLUMN fdrop1, DROP COLUMN fdrop2 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: AlterTableStmt +== 539 +CREATE TABLE fk_partitioned_fk (b int, fdrop1 int, a int) PARTITION BY RANGE (a, b) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: CreateStmt +== 540 +ALTER TABLE fk_partitioned_fk DROP COLUMN fdrop1 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 541 +CREATE TABLE fk_partitioned_fk_1 (fdrop1 int, fdrop2 int, a int, fdrop3 int, b int) +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DDL +STMT: CreateStmt +== 542 +ALTER TABLE fk_partitioned_fk_1 DROP COLUMN fdrop1, DROP COLUMN fdrop2, DROP COLUMN fdrop3 +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DDL +STMT: AlterTableStmt +== 543 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_1 FOR VALUES FROM (0,0) TO (1000,1000) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 544 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 545 +CREATE TABLE fk_partitioned_fk_2 (b int, fdrop1 int, fdrop2 int, a int) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +== 546 +ALTER TABLE fk_partitioned_fk_2 DROP COLUMN fdrop1, DROP COLUMN fdrop2 +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: AlterTableStmt +== 547 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES FROM (1000,1000) TO (2000,2000) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 548 +CREATE TABLE fk_partitioned_fk_3 (fdrop1 int, fdrop2 int, fdrop3 int, fdrop4 int, b int, a int) + PARTITION BY HASH (a) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DDL +STMT: CreateStmt +== 549 +ALTER TABLE fk_partitioned_fk_3 DROP COLUMN fdrop1, DROP COLUMN fdrop2, + DROP COLUMN fdrop3, DROP COLUMN fdrop4 +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DDL +STMT: AlterTableStmt +== 550 +CREATE TABLE fk_partitioned_fk_3_0 PARTITION OF fk_partitioned_fk_3 FOR VALUES WITH (MODULUS 5, REMAINDER 0) +-- +TABLE: name="fk_partitioned_fk_3_0" schema="" table="fk_partitioned_fk_3_0" ctx=DDL +STMT: CreateStmt +== 551 +CREATE TABLE fk_partitioned_fk_3_1 PARTITION OF fk_partitioned_fk_3 FOR VALUES WITH (MODULUS 5, REMAINDER 1) +-- +TABLE: name="fk_partitioned_fk_3_1" schema="" table="fk_partitioned_fk_3_1" ctx=DDL +STMT: CreateStmt +== 552 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_3 + FOR VALUES FROM (2000,2000) TO (3000,3000) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 553 +-- Creating a foreign key with ONLY on a partitioned table referencing +-- a non-partitioned table fails. +ALTER TABLE ONLY fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 554 +-- Adding a NOT VALID foreign key on a partitioned table referencing +-- a non-partitioned table fails. +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk NOT VALID +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 555 +-- these inserts, targeting both the partition directly as well as the +-- partitioned table, should all fail +INSERT INTO fk_partitioned_fk (a,b) VALUES (500, 501) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 556 +INSERT INTO fk_partitioned_fk_1 (a,b) VALUES (500, 501) +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 557 +INSERT INTO fk_partitioned_fk (a,b) VALUES (1500, 1501) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 558 +INSERT INTO fk_partitioned_fk_2 (a,b) VALUES (1500, 1501) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 559 +INSERT INTO fk_partitioned_fk (a,b) VALUES (2500, 2502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 560 +INSERT INTO fk_partitioned_fk_3 (a,b) VALUES (2500, 2502) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 561 +INSERT INTO fk_partitioned_fk (a,b) VALUES (2501, 2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 562 +INSERT INTO fk_partitioned_fk_3 (a,b) VALUES (2501, 2503) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 563 +-- but if we insert the values that make them valid, then they work +INSERT INTO fk_notpartitioned_pk VALUES (500, 501), (1500, 1501), + (2500, 2502), (2501, 2503) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 564 +INSERT INTO fk_partitioned_fk (a,b) VALUES (500, 501) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 565 +INSERT INTO fk_partitioned_fk (a,b) VALUES (1500, 1501) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 566 +INSERT INTO fk_partitioned_fk (a,b) VALUES (2500, 2502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 567 +INSERT INTO fk_partitioned_fk (a,b) VALUES (2501, 2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 568 +-- this update fails because there is no referenced row +UPDATE fk_partitioned_fk SET a = a + 1 WHERE a = 2501 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: UpdateStmt +== 569 +-- but we can fix it thusly: +INSERT INTO fk_notpartitioned_pk (a,b) VALUES (2502, 2503) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 570 +UPDATE fk_partitioned_fk SET a = a + 1 WHERE a = 2501 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: UpdateStmt +== 571 +-- these updates would leave lingering rows in the referencing table; disallow +UPDATE fk_notpartitioned_pk SET b = 502 WHERE a = 500 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +== 572 +UPDATE fk_notpartitioned_pk SET b = 1502 WHERE a = 1500 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +== 573 +UPDATE fk_notpartitioned_pk SET b = 2504 WHERE a = 2500 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +== 574 +-- check psql behavior +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 575 +-- done. +DROP TABLE fk_notpartitioned_pk, fk_partitioned_fk +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: DropStmt +== 576 +-- Altering a type referenced by a foreign key needs to drop/recreate the FK. +-- Ensure that works. +CREATE TABLE fk_notpartitioned_pk (a INT, PRIMARY KEY(a), CHECK (a > 0)) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: CreateStmt +== 577 +CREATE TABLE fk_partitioned_fk (a INT REFERENCES fk_notpartitioned_pk(a) PRIMARY KEY) PARTITION BY RANGE(a) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: CreateStmt +== 578 +CREATE TABLE fk_partitioned_fk_1 PARTITION OF fk_partitioned_fk FOR VALUES FROM (MINVALUE) TO (MAXVALUE) +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DDL +STMT: CreateStmt +== 579 +INSERT INTO fk_notpartitioned_pk VALUES (1) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 580 +INSERT INTO fk_partitioned_fk VALUES (1) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 581 +ALTER TABLE fk_notpartitioned_pk ALTER COLUMN a TYPE bigint +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: AlterTableStmt +== 582 +DELETE FROM fk_notpartitioned_pk WHERE a = 1 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +== 583 +DROP TABLE fk_notpartitioned_pk, fk_partitioned_fk +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: DropStmt +== 584 +-- Test some other exotic foreign key features: MATCH SIMPLE, ON UPDATE/DELETE +-- actions +CREATE TABLE fk_notpartitioned_pk (a int, b int, primary key (a, b)) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: CreateStmt +== 585 +CREATE TABLE fk_partitioned_fk (a int default 2501, b int default 142857) PARTITION BY LIST (a) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: CreateStmt +== 586 +CREATE TABLE fk_partitioned_fk_1 PARTITION OF fk_partitioned_fk FOR VALUES IN (NULL,500,501,502) +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DDL +STMT: CreateStmt +== 587 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk MATCH SIMPLE + ON DELETE SET NULL ON UPDATE SET NULL +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 588 +CREATE TABLE fk_partitioned_fk_2 PARTITION OF fk_partitioned_fk FOR VALUES IN (1500,1502) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +== 589 +CREATE TABLE fk_partitioned_fk_3 (a int, b int) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DDL +STMT: CreateStmt +== 590 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_3 FOR VALUES IN (2500,2501,2502,2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 591 +-- this insert fails +INSERT INTO fk_partitioned_fk (a, b) VALUES (2502, 2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 592 +INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 593 +-- but since the FK is MATCH SIMPLE, this one doesn't +INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, NULL) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 594 +-- now create the referenced row ... +INSERT INTO fk_notpartitioned_pk VALUES (2502, 2503) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 595 +--- and now the same insert work +INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 596 +-- this always works +INSERT INTO fk_partitioned_fk (a,b) VALUES (NULL, NULL) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 597 +-- MATCH FULL +INSERT INTO fk_notpartitioned_pk VALUES (1, 2) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 598 +CREATE TABLE fk_partitioned_fk_full (x int, y int) PARTITION BY RANGE (x) +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: CreateStmt +== 599 +CREATE TABLE fk_partitioned_fk_full_1 PARTITION OF fk_partitioned_fk_full DEFAULT +-- +TABLE: name="fk_partitioned_fk_full_1" schema="" table="fk_partitioned_fk_full_1" ctx=DDL +STMT: CreateStmt +== 600 +INSERT INTO fk_partitioned_fk_full VALUES (1, NULL) +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 601 +ALTER TABLE fk_partitioned_fk_full ADD FOREIGN KEY (x, y) REFERENCES fk_notpartitioned_pk MATCH FULL +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: AlterTableStmt +== 602 +-- fails +TRUNCATE fk_partitioned_fk_full +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: TruncateStmt +== 603 +ALTER TABLE fk_partitioned_fk_full ADD FOREIGN KEY (x, y) REFERENCES fk_notpartitioned_pk MATCH FULL +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: AlterTableStmt +== 604 +INSERT INTO fk_partitioned_fk_full VALUES (1, NULL) +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 605 +-- fails +DROP TABLE fk_partitioned_fk_full +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: DropStmt +== 606 +-- ON UPDATE SET NULL +SELECT tableoid::regclass, a, b FROM fk_partitioned_fk WHERE b IS NULL ORDER BY a +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 607 +UPDATE fk_notpartitioned_pk SET a = a + 1 WHERE a = 2502 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +== 608 +SELECT tableoid::regclass, a, b FROM fk_partitioned_fk WHERE b IS NULL ORDER BY a +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 609 +-- ON DELETE SET NULL +INSERT INTO fk_partitioned_fk VALUES (2503, 2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 610 +SELECT count(*) FROM fk_partitioned_fk WHERE a IS NULL +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 611 +DELETE FROM fk_notpartitioned_pk +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +== 612 +SELECT count(*) FROM fk_partitioned_fk WHERE a IS NULL +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 613 +-- ON UPDATE/DELETE SET DEFAULT +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 614 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk + ON DELETE SET DEFAULT ON UPDATE SET DEFAULT +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 615 +INSERT INTO fk_notpartitioned_pk VALUES (2502, 2503) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 616 +INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 617 +-- this fails, because the defaults for the referencing table are not present +-- in the referenced table: +UPDATE fk_notpartitioned_pk SET a = 1500 WHERE a = 2502 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +== 618 +-- but inserting the row we can make it work: +INSERT INTO fk_notpartitioned_pk VALUES (2501, 142857) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 619 +UPDATE fk_notpartitioned_pk SET a = 1500 WHERE a = 2502 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +== 620 +SELECT * FROM fk_partitioned_fk WHERE b = 142857 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 621 +-- ON DELETE SET NULL column_list +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 622 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk + ON DELETE SET NULL (a) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 623 +BEGIN +-- +STMT: TransactionStmt +== 624 +DELETE FROM fk_notpartitioned_pk WHERE b = 142857 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +== 625 +SELECT * FROM fk_partitioned_fk WHERE a IS NOT NULL OR b IS NOT NULL ORDER BY a NULLS LAST +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 626 +ROLLBACK +-- +STMT: TransactionStmt +== 627 +-- ON DELETE SET DEFAULT column_list +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 628 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk + ON DELETE SET DEFAULT (a) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 629 +BEGIN +-- +STMT: TransactionStmt +== 630 +DELETE FROM fk_partitioned_fk +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: DeleteStmt +== 631 +DELETE FROM fk_notpartitioned_pk +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +== 632 +INSERT INTO fk_notpartitioned_pk VALUES (500, 100000), (2501, 100000) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 633 +INSERT INTO fk_partitioned_fk VALUES (500, 100000) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 634 +DELETE FROM fk_notpartitioned_pk WHERE a = 500 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +== 635 +SELECT * FROM fk_partitioned_fk ORDER BY a +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +STMT: SelectStmt +== 636 +ROLLBACK +-- +STMT: TransactionStmt +== 637 +-- ON UPDATE/DELETE CASCADE +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 638 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk + ON DELETE CASCADE ON UPDATE CASCADE +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 639 +UPDATE fk_notpartitioned_pk SET a = 2502 WHERE a = 2501 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +== 640 +SELECT * FROM fk_partitioned_fk WHERE b = 142857 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 641 +-- Now you see it ... +SELECT * FROM fk_partitioned_fk WHERE b = 142857 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 642 +DELETE FROM fk_notpartitioned_pk WHERE b = 142857 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +== 643 +-- now you don't. +SELECT * FROM fk_partitioned_fk WHERE a = 142857 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 644 +-- verify that DROP works +DROP TABLE fk_partitioned_fk_2 +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: DropStmt +== 645 +-- Test behavior of the constraint together with attaching and detaching +-- partitions. +CREATE TABLE fk_partitioned_fk_2 PARTITION OF fk_partitioned_fk FOR VALUES IN (1500,1502) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +== 646 +ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_2 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 647 +BEGIN +-- +STMT: TransactionStmt +== 648 +DROP TABLE fk_partitioned_fk +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: DropStmt +== 649 +-- constraint should still be there +ROLLBACK +-- +STMT: TransactionStmt +== 650 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES IN (1500,1502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 651 +DROP TABLE fk_partitioned_fk_2 +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: DropStmt +== 652 +CREATE TABLE fk_partitioned_fk_2 (b int, c text, a int, + FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk ON UPDATE CASCADE ON DELETE CASCADE) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +== 653 +ALTER TABLE fk_partitioned_fk_2 DROP COLUMN c +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: AlterTableStmt +== 654 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES IN (1500,1502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 655 +-- should have only one constraint +DROP TABLE fk_partitioned_fk_2 +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: DropStmt +== 656 +CREATE TABLE fk_partitioned_fk_4 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk(a, b) ON UPDATE CASCADE ON DELETE CASCADE) PARTITION BY RANGE (b, a) +-- +TABLE: name="fk_partitioned_fk_4" schema="" table="fk_partitioned_fk_4" ctx=DDL +STMT: CreateStmt +== 657 +CREATE TABLE fk_partitioned_fk_4_1 PARTITION OF fk_partitioned_fk_4 FOR VALUES FROM (1,1) TO (100,100) +-- +TABLE: name="fk_partitioned_fk_4_1" schema="" table="fk_partitioned_fk_4_1" ctx=DDL +STMT: CreateStmt +== 658 +CREATE TABLE fk_partitioned_fk_4_2 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk(a, b) ON UPDATE SET NULL) +-- +TABLE: name="fk_partitioned_fk_4_2" schema="" table="fk_partitioned_fk_4_2" ctx=DDL +STMT: CreateStmt +== 659 +ALTER TABLE fk_partitioned_fk_4 ATTACH PARTITION fk_partitioned_fk_4_2 FOR VALUES FROM (100,100) TO (1000,1000) +-- +TABLE: name="fk_partitioned_fk_4" schema="" table="fk_partitioned_fk_4" ctx=DDL +STMT: AlterTableStmt +== 660 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_4 FOR VALUES IN (3500,3502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 661 +ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_4 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 662 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_4 FOR VALUES IN (3500,3502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 663 +-- should only have one constraint +-- this one has an FK with mismatched properties + +CREATE TABLE fk_partitioned_fk_5 (a int, b int, + FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk(a, b) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE, + FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk(a, b) MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE) + PARTITION BY RANGE (a) +-- +TABLE: name="fk_partitioned_fk_5" schema="" table="fk_partitioned_fk_5" ctx=DDL +STMT: CreateStmt +== 664 +CREATE TABLE fk_partitioned_fk_5_1 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk) +-- +TABLE: name="fk_partitioned_fk_5_1" schema="" table="fk_partitioned_fk_5_1" ctx=DDL +STMT: CreateStmt +== 665 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_5 FOR VALUES IN (4500) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 666 +ALTER TABLE fk_partitioned_fk_5 ATTACH PARTITION fk_partitioned_fk_5_1 FOR VALUES FROM (0) TO (10) +-- +TABLE: name="fk_partitioned_fk_5" schema="" table="fk_partitioned_fk_5" ctx=DDL +STMT: AlterTableStmt +== 667 +ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_5 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 668 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_5 FOR VALUES IN (4500) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 669 +-- this one has two constraints, similar but not quite the one in the parent, +-- so it gets a new one +-- verify that it works to reattaching a child with multiple candidate +-- constraints +ALTER TABLE fk_partitioned_fk_5 DETACH PARTITION fk_partitioned_fk_5_1 +-- +TABLE: name="fk_partitioned_fk_5" schema="" table="fk_partitioned_fk_5" ctx=DDL +STMT: AlterTableStmt +== 670 +ALTER TABLE fk_partitioned_fk_5 ATTACH PARTITION fk_partitioned_fk_5_1 FOR VALUES FROM (0) TO (10) +-- +TABLE: name="fk_partitioned_fk_5" schema="" table="fk_partitioned_fk_5" ctx=DDL +STMT: AlterTableStmt +== 671 +-- verify that attaching a table checks that the existing data satisfies the +-- constraint +CREATE TABLE fk_partitioned_fk_2 (a int, b int) PARTITION BY RANGE (b) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +== 672 +CREATE TABLE fk_partitioned_fk_2_1 PARTITION OF fk_partitioned_fk_2 FOR VALUES FROM (0) TO (1000) +-- +TABLE: name="fk_partitioned_fk_2_1" schema="" table="fk_partitioned_fk_2_1" ctx=DDL +STMT: CreateStmt +== 673 +CREATE TABLE fk_partitioned_fk_2_2 PARTITION OF fk_partitioned_fk_2 FOR VALUES FROM (1000) TO (2000) +-- +TABLE: name="fk_partitioned_fk_2_2" schema="" table="fk_partitioned_fk_2_2" ctx=DDL +STMT: CreateStmt +== 674 +INSERT INTO fk_partitioned_fk_2 VALUES (1600, 601), (1600, 1601) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 675 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 + FOR VALUES IN (1600) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 676 +INSERT INTO fk_notpartitioned_pk VALUES (1600, 601), (1600, 1601) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 677 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 + FOR VALUES IN (1600) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 678 +-- leave these tables around intentionally + +-- Verify that attaching a table that's referenced by an existing FK +-- in the parent throws an error +CREATE TABLE fk_partitioned_pk_6 (a int PRIMARY KEY) +-- +TABLE: name="fk_partitioned_pk_6" schema="" table="fk_partitioned_pk_6" ctx=DDL +STMT: CreateStmt +== 679 +CREATE TABLE fk_partitioned_fk_6 (a int REFERENCES fk_partitioned_pk_6) PARTITION BY LIST (a) +-- +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: CreateStmt +== 680 +ALTER TABLE fk_partitioned_fk_6 ATTACH PARTITION fk_partitioned_pk_6 FOR VALUES IN (1) +-- +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: AlterTableStmt +== 681 +DROP TABLE fk_partitioned_pk_6, fk_partitioned_fk_6 +-- +TABLE: name="fk_partitioned_pk_6" schema="" table="fk_partitioned_pk_6" ctx=DDL +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: DropStmt +== 682 +-- This case is similar to above, but the referenced relation is one level +-- lower in the hierarchy. This one fails in a different way as the above, +-- because we don't bother to protect against this case explicitly. If the +-- current error stops happening, we'll need to add a better protection. +CREATE TABLE fk_partitioned_pk_6 (a int PRIMARY KEY) PARTITION BY list (a) +-- +TABLE: name="fk_partitioned_pk_6" schema="" table="fk_partitioned_pk_6" ctx=DDL +STMT: CreateStmt +== 683 +CREATE TABLE fk_partitioned_pk_61 PARTITION OF fk_partitioned_pk_6 FOR VALUES IN (1) +-- +TABLE: name="fk_partitioned_pk_61" schema="" table="fk_partitioned_pk_61" ctx=DDL +STMT: CreateStmt +== 684 +CREATE TABLE fk_partitioned_fk_6 (a int REFERENCES fk_partitioned_pk_61) PARTITION BY LIST (a) +-- +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: CreateStmt +== 685 +ALTER TABLE fk_partitioned_fk_6 ATTACH PARTITION fk_partitioned_pk_6 FOR VALUES IN (1) +-- +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: AlterTableStmt +== 686 +DROP TABLE fk_partitioned_pk_6, fk_partitioned_fk_6 +-- +TABLE: name="fk_partitioned_pk_6" schema="" table="fk_partitioned_pk_6" ctx=DDL +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: DropStmt +== 687 +-- test the case when the referenced table is owned by a different user +create role regress_other_partitioned_fk_owner +-- +STMT: CreateRoleStmt +== 688 +grant references on fk_notpartitioned_pk to regress_other_partitioned_fk_owner +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: GrantStmt +== 689 +set role regress_other_partitioned_fk_owner +-- +STMT: VariableSetStmt +== 690 +create table other_partitioned_fk(a int, b int) partition by list (a) +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DDL +STMT: CreateStmt +== 691 +create table other_partitioned_fk_1 partition of other_partitioned_fk + for values in (2048) +-- +TABLE: name="other_partitioned_fk_1" schema="" table="other_partitioned_fk_1" ctx=DDL +STMT: CreateStmt +== 692 +insert into other_partitioned_fk + select 2048, x from generate_series(1,10) x +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 693 +-- this should fail +alter table other_partitioned_fk add foreign key (a, b) + references fk_notpartitioned_pk(a, b) +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 694 +-- add the missing keys and retry +reset role +-- +STMT: VariableSetStmt +== 695 +insert into fk_notpartitioned_pk (a, b) + select 2048, x from generate_series(1,10) x +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 696 +set role regress_other_partitioned_fk_owner +-- +STMT: VariableSetStmt +== 697 +alter table other_partitioned_fk add foreign key (a, b) + references fk_notpartitioned_pk(a, b) +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +== 698 +-- clean up +drop table other_partitioned_fk +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DDL +STMT: DropStmt +== 699 +reset role +-- +STMT: VariableSetStmt +== 700 +revoke all on fk_notpartitioned_pk from regress_other_partitioned_fk_owner +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: GrantStmt +== 701 +drop role regress_other_partitioned_fk_owner +-- +STMT: DropRoleStmt +== 702 +|-- +-- Test self-referencing foreign key with partition. +-- This should create only one fk constraint per partition +|-- +CREATE TABLE parted_self_fk ( + id bigint NOT NULL PRIMARY KEY, + id_abc bigint, + FOREIGN KEY (id_abc) REFERENCES parted_self_fk(id) +) +PARTITION BY RANGE (id) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: CreateStmt +== 703 +CREATE TABLE part1_self_fk ( + id bigint NOT NULL PRIMARY KEY, + id_abc bigint +) +-- +TABLE: name="part1_self_fk" schema="" table="part1_self_fk" ctx=DDL +STMT: CreateStmt +== 704 +ALTER TABLE parted_self_fk ATTACH PARTITION part1_self_fk FOR VALUES FROM (0) TO (10) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +== 705 +CREATE TABLE part2_self_fk PARTITION OF parted_self_fk FOR VALUES FROM (10) TO (20) +-- +TABLE: name="part2_self_fk" schema="" table="part2_self_fk" ctx=DDL +STMT: CreateStmt +== 706 +CREATE TABLE part3_self_fk ( -- a partitioned partition + id bigint NOT NULL PRIMARY KEY, + id_abc bigint +) PARTITION BY RANGE (id) +-- +TABLE: name="part3_self_fk" schema="" table="part3_self_fk" ctx=DDL +STMT: CreateStmt +== 707 +CREATE TABLE part32_self_fk PARTITION OF part3_self_fk FOR VALUES FROM (20) TO (30) +-- +TABLE: name="part32_self_fk" schema="" table="part32_self_fk" ctx=DDL +STMT: CreateStmt +== 708 +ALTER TABLE parted_self_fk ATTACH PARTITION part3_self_fk FOR VALUES FROM (20) TO (40) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +== 709 +CREATE TABLE part33_self_fk ( + id bigint NOT NULL PRIMARY KEY, + id_abc bigint +) +-- +TABLE: name="part33_self_fk" schema="" table="part33_self_fk" ctx=DDL +STMT: CreateStmt +== 710 +ALTER TABLE part3_self_fk ATTACH PARTITION part33_self_fk FOR VALUES FROM (30) TO (40) +-- +TABLE: name="part3_self_fk" schema="" table="part3_self_fk" ctx=DDL +STMT: AlterTableStmt +== 711 +-- verify that this constraint works +INSERT INTO parted_self_fk VALUES (1, NULL), (2, NULL), (3, NULL) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 712 +INSERT INTO parted_self_fk VALUES (10, 1), (11, 2), (12, 3) RETURNING tableoid::regclass +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 713 +INSERT INTO parted_self_fk VALUES (4, 5) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 714 +-- error: referenced doesn't exist +DELETE FROM parted_self_fk WHERE id = 1 RETURNING * +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: DeleteStmt +== 715 +-- error: reference remains + +SELECT cr.relname, co.conname, co.convalidated, + p.conname AS conparent, p.convalidated, cf.relname AS foreignrel +FROM pg_constraint co +JOIN pg_class cr ON cr.oid = co.conrelid +LEFT JOIN pg_class cf ON cf.oid = co.confrelid +LEFT JOIN pg_constraint p ON p.oid = co.conparentid +WHERE co.contype = 'f' AND + cr.oid IN (SELECT relid FROM pg_partition_tree('parted_self_fk')) +ORDER BY cr.relname, co.conname, p.conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "cf"="pg_class" +ALIAS: "co"="pg_constraint" +ALIAS: "cr"="pg_class" +ALIAS: "p"="pg_constraint" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="co" column="contype" +FILTER: schema="" table="cr" column="oid" +STMT: SelectStmt +== 716 +-- detach and re-attach multiple times just to ensure everything is kosher +ALTER TABLE parted_self_fk DETACH PARTITION part2_self_fk +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +== 717 +INSERT INTO part2_self_fk VALUES (16, 9) +-- +TABLE: name="part2_self_fk" schema="" table="part2_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 718 +-- error: referenced doesn't exist +DELETE FROM parted_self_fk WHERE id = 2 RETURNING * +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: DeleteStmt +== 719 +-- error: reference remains + +ALTER TABLE parted_self_fk ATTACH PARTITION part2_self_fk FOR VALUES FROM (10) TO (20) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +== 720 +INSERT INTO parted_self_fk VALUES (16, 9) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 721 +-- error: referenced doesn't exist +DELETE FROM parted_self_fk WHERE id = 3 RETURNING * +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: DeleteStmt +== 722 +-- error: reference remains + +ALTER TABLE parted_self_fk DETACH PARTITION part2_self_fk +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +== 723 +ALTER TABLE parted_self_fk ATTACH PARTITION part2_self_fk FOR VALUES FROM (10) TO (20) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +== 724 +ALTER TABLE parted_self_fk DETACH PARTITION part3_self_fk +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +== 725 +ALTER TABLE parted_self_fk ATTACH PARTITION part3_self_fk FOR VALUES FROM (30) TO (40) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +== 726 +ALTER TABLE part3_self_fk DETACH PARTITION part33_self_fk +-- +TABLE: name="part3_self_fk" schema="" table="part3_self_fk" ctx=DDL +STMT: AlterTableStmt +== 727 +ALTER TABLE part3_self_fk ATTACH PARTITION part33_self_fk FOR VALUES FROM (30) TO (40) +-- +TABLE: name="part3_self_fk" schema="" table="part3_self_fk" ctx=DDL +STMT: AlterTableStmt +== 728 +SELECT cr.relname, co.conname, co.convalidated, + p.conname AS conparent, p.convalidated, cf.relname AS foreignrel +FROM pg_constraint co +JOIN pg_class cr ON cr.oid = co.conrelid +LEFT JOIN pg_class cf ON cf.oid = co.confrelid +LEFT JOIN pg_constraint p ON p.oid = co.conparentid +WHERE co.contype = 'f' AND + cr.oid IN (SELECT relid FROM pg_partition_tree('parted_self_fk')) +ORDER BY cr.relname, co.conname, p.conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "cf"="pg_class" +ALIAS: "co"="pg_constraint" +ALIAS: "cr"="pg_class" +ALIAS: "p"="pg_constraint" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="co" column="contype" +FILTER: schema="" table="cr" column="oid" +STMT: SelectStmt +== 729 +-- Leave this table around, for pg_upgrade/pg_dump tests + + +-- Test creating a constraint at the parent that already exists in partitions. +-- There should be no duplicated constraints, and attempts to drop the +-- constraint in partitions should raise appropriate errors. +create schema fkpart0 + create table pkey (a int primary key) + create table fk_part (a int) partition by list (a) + create table fk_part_1 partition of fk_part + (foreign key (a) references fkpart0.pkey) for values in (1) + create table fk_part_23 partition of fk_part + (foreign key (a) references fkpart0.pkey) for values in (2, 3) + partition by list (a) + create table fk_part_23_2 partition of fk_part_23 for values in (2) +-- +STMT: CreateSchemaStmt +== 730 +alter table fkpart0.fk_part add foreign key (a) references fkpart0.pkey +-- +TABLE: name="fkpart0.fk_part" schema="fkpart0" table="fk_part" ctx=DDL +STMT: AlterTableStmt +== 731 +alter table fkpart0.fk_part_1 drop constraint fk_part_1_a_fkey +-- +TABLE: name="fkpart0.fk_part_1" schema="fkpart0" table="fk_part_1" ctx=DDL +STMT: AlterTableStmt +== 732 +alter table fkpart0.fk_part_23 drop constraint fk_part_23_a_fkey +-- +TABLE: name="fkpart0.fk_part_23" schema="fkpart0" table="fk_part_23" ctx=DDL +STMT: AlterTableStmt +== 733 +alter table fkpart0.fk_part_23_2 drop constraint fk_part_23_a_fkey +-- +TABLE: name="fkpart0.fk_part_23_2" schema="fkpart0" table="fk_part_23_2" ctx=DDL +STMT: AlterTableStmt +== 734 +create table fkpart0.fk_part_4 partition of fkpart0.fk_part for values in (4) +-- +TABLE: name="fkpart0.fk_part_4" schema="fkpart0" table="fk_part_4" ctx=DDL +STMT: CreateStmt +== 735 +alter table fkpart0.fk_part_4 drop constraint fk_part_a_fkey +-- +TABLE: name="fkpart0.fk_part_4" schema="fkpart0" table="fk_part_4" ctx=DDL +STMT: AlterTableStmt +== 736 +create table fkpart0.fk_part_56 partition of fkpart0.fk_part + for values in (5,6) partition by list (a) +-- +TABLE: name="fkpart0.fk_part_56" schema="fkpart0" table="fk_part_56" ctx=DDL +STMT: CreateStmt +== 737 +create table fkpart0.fk_part_56_5 partition of fkpart0.fk_part_56 + for values in (5) +-- +TABLE: name="fkpart0.fk_part_56_5" schema="fkpart0" table="fk_part_56_5" ctx=DDL +STMT: CreateStmt +== 738 +alter table fkpart0.fk_part_56 drop constraint fk_part_a_fkey +-- +TABLE: name="fkpart0.fk_part_56" schema="fkpart0" table="fk_part_56" ctx=DDL +STMT: AlterTableStmt +== 739 +alter table fkpart0.fk_part_56_5 drop constraint fk_part_a_fkey +-- +TABLE: name="fkpart0.fk_part_56_5" schema="fkpart0" table="fk_part_56_5" ctx=DDL +STMT: AlterTableStmt +== 740 +-- verify that attaching and detaching partitions maintains the right set of +-- triggers +create schema fkpart1 + create table pkey (a int primary key) + create table fk_part (a int) partition by list (a) + create table fk_part_1 partition of fk_part for values in (1) partition by list (a) + create table fk_part_1_1 partition of fk_part_1 for values in (1) +-- +STMT: CreateSchemaStmt +== 741 +alter table fkpart1.fk_part add foreign key (a) references fkpart1.pkey +-- +TABLE: name="fkpart1.fk_part" schema="fkpart1" table="fk_part" ctx=DDL +STMT: AlterTableStmt +== 742 +insert into fkpart1.fk_part values (1) +-- +TABLE: name="fkpart1.fk_part" schema="fkpart1" table="fk_part" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 743 +-- should fail +insert into fkpart1.pkey values (1) +-- +TABLE: name="fkpart1.pkey" schema="fkpart1" table="pkey" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 744 +insert into fkpart1.fk_part values (1) +-- +TABLE: name="fkpart1.fk_part" schema="fkpart1" table="fk_part" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 745 +delete from fkpart1.pkey where a = 1 +-- +TABLE: name="fkpart1.pkey" schema="fkpart1" table="pkey" ctx=DML +STMT: DeleteStmt +== 746 +-- should fail +alter table fkpart1.fk_part detach partition fkpart1.fk_part_1 +-- +TABLE: name="fkpart1.fk_part" schema="fkpart1" table="fk_part" ctx=DDL +STMT: AlterTableStmt +== 747 +create table fkpart1.fk_part_1_2 partition of fkpart1.fk_part_1 for values in (2) +-- +TABLE: name="fkpart1.fk_part_1_2" schema="fkpart1" table="fk_part_1_2" ctx=DDL +STMT: CreateStmt +== 748 +insert into fkpart1.fk_part_1 values (2) +-- +TABLE: name="fkpart1.fk_part_1" schema="fkpart1" table="fk_part_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 749 +-- should fail +delete from fkpart1.pkey where a = 1 +-- +TABLE: name="fkpart1.pkey" schema="fkpart1" table="pkey" ctx=DML +STMT: DeleteStmt +== 750 +-- verify that attaching and detaching partitions manipulates the inheritance +-- properties of their FK constraints correctly +create schema fkpart2 + create table pkey (a int primary key) + create table fk_part (a int, constraint fkey foreign key (a) references fkpart2.pkey) partition by list (a) + create table fk_part_1 partition of fkpart2.fk_part for values in (1) partition by list (a) + create table fk_part_1_1 (a int, constraint my_fkey foreign key (a) references fkpart2.pkey) +-- +STMT: CreateSchemaStmt +== 751 +alter table fkpart2.fk_part_1 attach partition fkpart2.fk_part_1_1 for values in (1) +-- +TABLE: name="fkpart2.fk_part_1" schema="fkpart2" table="fk_part_1" ctx=DDL +STMT: AlterTableStmt +== 752 +alter table fkpart2.fk_part_1 drop constraint fkey +-- +TABLE: name="fkpart2.fk_part_1" schema="fkpart2" table="fk_part_1" ctx=DDL +STMT: AlterTableStmt +== 753 +-- should fail +alter table fkpart2.fk_part_1_1 drop constraint my_fkey +-- +TABLE: name="fkpart2.fk_part_1_1" schema="fkpart2" table="fk_part_1_1" ctx=DDL +STMT: AlterTableStmt +== 754 +-- should fail +alter table fkpart2.fk_part detach partition fkpart2.fk_part_1 +-- +TABLE: name="fkpart2.fk_part" schema="fkpart2" table="fk_part" ctx=DDL +STMT: AlterTableStmt +== 755 +alter table fkpart2.fk_part_1 drop constraint fkey +-- +TABLE: name="fkpart2.fk_part_1" schema="fkpart2" table="fk_part_1" ctx=DDL +STMT: AlterTableStmt +== 756 +-- ok +alter table fkpart2.fk_part_1_1 drop constraint my_fkey +-- +TABLE: name="fkpart2.fk_part_1_1" schema="fkpart2" table="fk_part_1_1" ctx=DDL +STMT: AlterTableStmt +== 757 +-- doesn't exist + +-- verify constraint deferrability +create schema fkpart3 + create table pkey (a int primary key) + create table fk_part (a int, constraint fkey foreign key (a) references fkpart3.pkey deferrable initially immediate) partition by list (a) + create table fk_part_1 partition of fkpart3.fk_part for values in (1) partition by list (a) + create table fk_part_1_1 partition of fkpart3.fk_part_1 for values in (1) + create table fk_part_2 partition of fkpart3.fk_part for values in (2) +-- +STMT: CreateSchemaStmt +== 758 +begin +-- +STMT: TransactionStmt +== 759 +set constraints fkpart3.fkey deferred +-- +STMT: ConstraintsSetStmt +== 760 +insert into fkpart3.fk_part values (1) +-- +TABLE: name="fkpart3.fk_part" schema="fkpart3" table="fk_part" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 761 +insert into fkpart3.pkey values (1) +-- +TABLE: name="fkpart3.pkey" schema="fkpart3" table="pkey" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 762 +commit +-- +STMT: TransactionStmt +== 763 +begin +-- +STMT: TransactionStmt +== 764 +set constraints fkpart3.fkey deferred +-- +STMT: ConstraintsSetStmt +== 765 +delete from fkpart3.pkey +-- +TABLE: name="fkpart3.pkey" schema="fkpart3" table="pkey" ctx=DML +STMT: DeleteStmt +== 766 +delete from fkpart3.fk_part +-- +TABLE: name="fkpart3.fk_part" schema="fkpart3" table="fk_part" ctx=DML +STMT: DeleteStmt +== 767 +commit +-- +STMT: TransactionStmt +== 768 +drop schema fkpart0, fkpart1, fkpart2, fkpart3 cascade +-- +STMT: DropStmt +== 769 +-- Test a partitioned table as referenced table. + +-- Verify basic functionality with a regular partition creation and a partition +-- with a different column layout, as well as partitions added (created and +-- attached) after creating the foreign key. +CREATE SCHEMA fkpart3 +-- +STMT: CreateSchemaStmt +== 770 +SET search_path TO fkpart3 +-- +STMT: VariableSetStmt +== 771 +CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY RANGE (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +== 772 +CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (0) TO (1000) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +== 773 +CREATE TABLE pk2 (b int, a int) +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: CreateStmt +== 774 +ALTER TABLE pk2 DROP COLUMN b +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: AlterTableStmt +== 775 +ALTER TABLE pk2 ALTER a SET NOT NULL +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: AlterTableStmt +== 776 +ALTER TABLE pk ATTACH PARTITION pk2 FOR VALUES FROM (1000) TO (2000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +== 777 +CREATE TABLE fk (a int) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +== 778 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (0) TO (750) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +== 779 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 780 +CREATE TABLE fk2 (b int, a int) +-- +TABLE: name="fk2" schema="" table="fk2" ctx=DDL +STMT: CreateStmt +== 781 +ALTER TABLE fk2 DROP COLUMN b +-- +TABLE: name="fk2" schema="" table="fk2" ctx=DDL +STMT: AlterTableStmt +== 782 +ALTER TABLE fk ATTACH PARTITION fk2 FOR VALUES FROM (750) TO (3500) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 783 +CREATE TABLE pk3 PARTITION OF pk FOR VALUES FROM (2000) TO (3000) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: CreateStmt +== 784 +CREATE TABLE pk4 (LIKE pk) +-- +TABLE: name="pk4" schema="" table="pk4" ctx=DDL +STMT: CreateStmt +== 785 +ALTER TABLE pk ATTACH PARTITION pk4 FOR VALUES FROM (3000) TO (4000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +== 786 +CREATE TABLE pk5 (c int, b int, a int NOT NULL) PARTITION BY RANGE (a) +-- +TABLE: name="pk5" schema="" table="pk5" ctx=DDL +STMT: CreateStmt +== 787 +ALTER TABLE pk5 DROP COLUMN b, DROP COLUMN c +-- +TABLE: name="pk5" schema="" table="pk5" ctx=DDL +STMT: AlterTableStmt +== 788 +CREATE TABLE pk51 PARTITION OF pk5 FOR VALUES FROM (4000) TO (4500) +-- +TABLE: name="pk51" schema="" table="pk51" ctx=DDL +STMT: CreateStmt +== 789 +CREATE TABLE pk52 PARTITION OF pk5 FOR VALUES FROM (4500) TO (5000) +-- +TABLE: name="pk52" schema="" table="pk52" ctx=DDL +STMT: CreateStmt +== 790 +ALTER TABLE pk ATTACH PARTITION pk5 FOR VALUES FROM (4000) TO (5000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +== 791 +CREATE TABLE fk3 PARTITION OF fk FOR VALUES FROM (3500) TO (5000) +-- +TABLE: name="fk3" schema="" table="fk3" ctx=DDL +STMT: CreateStmt +== 792 +-- these should fail: referenced value not present +INSERT into fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 793 +INSERT into fk VALUES (1000) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 794 +INSERT into fk VALUES (2000) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 795 +INSERT into fk VALUES (3000) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 796 +INSERT into fk VALUES (4000) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 797 +INSERT into fk VALUES (4500) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 798 +-- insert into the referenced table, now they should work +INSERT into pk VALUES (1), (1000), (2000), (3000), (4000), (4500) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 799 +INSERT into fk VALUES (1), (1000), (2000), (3000), (4000), (4500) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 800 +-- should fail: referencing value present +DELETE FROM pk WHERE a = 1 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 801 +DELETE FROM pk WHERE a = 1000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 802 +DELETE FROM pk WHERE a = 2000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 803 +DELETE FROM pk WHERE a = 3000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 804 +DELETE FROM pk WHERE a = 4000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 805 +DELETE FROM pk WHERE a = 4500 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 806 +UPDATE pk SET a = 2 WHERE a = 1 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 807 +UPDATE pk SET a = 1002 WHERE a = 1000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 808 +UPDATE pk SET a = 2002 WHERE a = 2000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 809 +UPDATE pk SET a = 3002 WHERE a = 3000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 810 +UPDATE pk SET a = 4002 WHERE a = 4000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 811 +UPDATE pk SET a = 4502 WHERE a = 4500 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 812 +-- now they should work +DELETE FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: DeleteStmt +== 813 +UPDATE pk SET a = 2 WHERE a = 1 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 814 +DELETE FROM pk WHERE a = 2 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 815 +UPDATE pk SET a = 1002 WHERE a = 1000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 816 +DELETE FROM pk WHERE a = 1002 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 817 +UPDATE pk SET a = 2002 WHERE a = 2000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 818 +DELETE FROM pk WHERE a = 2002 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 819 +UPDATE pk SET a = 3002 WHERE a = 3000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 820 +DELETE FROM pk WHERE a = 3002 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 821 +UPDATE pk SET a = 4002 WHERE a = 4000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 822 +DELETE FROM pk WHERE a = 4002 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 823 +UPDATE pk SET a = 4502 WHERE a = 4500 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 824 +DELETE FROM pk WHERE a = 4502 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 825 +-- Also, detaching a partition that has the FK itself should work +-- https://postgr.es/m/CAAJ_b97GuPh6wQPbxQS-Zpy16Oh+0aMv-w64QcGrLhCOZZ6p+g@mail.gmail.com +CREATE TABLE ffk (a int, b int REFERENCES pk) PARTITION BY list (a) +-- +TABLE: name="ffk" schema="" table="ffk" ctx=DDL +STMT: CreateStmt +== 826 +CREATE TABLE ffk1 PARTITION OF ffk FOR VALUES IN (1) +-- +TABLE: name="ffk1" schema="" table="ffk1" ctx=DDL +STMT: CreateStmt +== 827 +ALTER TABLE ffk1 ADD FOREIGN KEY (a) REFERENCES pk +-- +TABLE: name="ffk1" schema="" table="ffk1" ctx=DDL +STMT: AlterTableStmt +== 828 +ALTER TABLE ffk DETACH PARTITION ffk1 +-- +TABLE: name="ffk" schema="" table="ffk" ctx=DDL +STMT: AlterTableStmt +== 829 +DROP TABLE ffk, ffk1 +-- +TABLE: name="ffk" schema="" table="ffk" ctx=DDL +TABLE: name="ffk1" schema="" table="ffk1" ctx=DDL +STMT: DropStmt +== 830 +CREATE SCHEMA fkpart4 +-- +STMT: CreateSchemaStmt +== 831 +SET search_path TO fkpart4 +-- +STMT: VariableSetStmt +== 832 +-- dropping/detaching PARTITIONs is prevented if that would break +-- a foreign key's existing data +CREATE TABLE droppk (a int PRIMARY KEY) PARTITION BY RANGE (a) +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DDL +STMT: CreateStmt +== 833 +CREATE TABLE droppk1 PARTITION OF droppk FOR VALUES FROM (0) TO (1000) +-- +TABLE: name="droppk1" schema="" table="droppk1" ctx=DDL +STMT: CreateStmt +== 834 +CREATE TABLE droppk_d PARTITION OF droppk DEFAULT +-- +TABLE: name="droppk_d" schema="" table="droppk_d" ctx=DDL +STMT: CreateStmt +== 835 +CREATE TABLE droppk2 PARTITION OF droppk FOR VALUES FROM (1000) TO (2000) + PARTITION BY RANGE (a) +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: CreateStmt +== 836 +CREATE TABLE droppk21 PARTITION OF droppk2 FOR VALUES FROM (1000) TO (1400) +-- +TABLE: name="droppk21" schema="" table="droppk21" ctx=DDL +STMT: CreateStmt +== 837 +CREATE TABLE droppk2_d PARTITION OF droppk2 DEFAULT +-- +TABLE: name="droppk2_d" schema="" table="droppk2_d" ctx=DDL +STMT: CreateStmt +== 838 +INSERT into droppk VALUES (1), (1000), (1500), (2000) +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 839 +CREATE TABLE dropfk (a int REFERENCES droppk) +-- +TABLE: name="dropfk" schema="" table="dropfk" ctx=DDL +STMT: CreateStmt +== 840 +INSERT into dropfk VALUES (1), (1000), (1500), (2000) +-- +TABLE: name="dropfk" schema="" table="dropfk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 841 +-- these should all fail +ALTER TABLE droppk DETACH PARTITION droppk_d +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DDL +STMT: AlterTableStmt +== 842 +ALTER TABLE droppk2 DETACH PARTITION droppk2_d +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: AlterTableStmt +== 843 +ALTER TABLE droppk DETACH PARTITION droppk1 +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DDL +STMT: AlterTableStmt +== 844 +ALTER TABLE droppk DETACH PARTITION droppk2 +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DDL +STMT: AlterTableStmt +== 845 +ALTER TABLE droppk2 DETACH PARTITION droppk21 +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: AlterTableStmt +== 846 +-- dropping partitions is disallowed +DROP TABLE droppk_d +-- +TABLE: name="droppk_d" schema="" table="droppk_d" ctx=DDL +STMT: DropStmt +== 847 +DROP TABLE droppk2_d +-- +TABLE: name="droppk2_d" schema="" table="droppk2_d" ctx=DDL +STMT: DropStmt +== 848 +DROP TABLE droppk1 +-- +TABLE: name="droppk1" schema="" table="droppk1" ctx=DDL +STMT: DropStmt +== 849 +DROP TABLE droppk2 +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: DropStmt +== 850 +DROP TABLE droppk21 +-- +TABLE: name="droppk21" schema="" table="droppk21" ctx=DDL +STMT: DropStmt +== 851 +DELETE FROM dropfk +-- +TABLE: name="dropfk" schema="" table="dropfk" ctx=DML +STMT: DeleteStmt +== 852 +-- dropping partitions is disallowed, even when no referencing values +DROP TABLE droppk_d +-- +TABLE: name="droppk_d" schema="" table="droppk_d" ctx=DDL +STMT: DropStmt +== 853 +DROP TABLE droppk2_d +-- +TABLE: name="droppk2_d" schema="" table="droppk2_d" ctx=DDL +STMT: DropStmt +== 854 +DROP TABLE droppk1 +-- +TABLE: name="droppk1" schema="" table="droppk1" ctx=DDL +STMT: DropStmt +== 855 +-- but DETACH is allowed, and DROP afterwards works +ALTER TABLE droppk2 DETACH PARTITION droppk21 +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: AlterTableStmt +== 856 +DROP TABLE droppk2 +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: DropStmt +== 857 +-- Verify that initial constraint creation and cloning behave correctly +CREATE SCHEMA fkpart5 +-- +STMT: CreateSchemaStmt +== 858 +SET search_path TO fkpart5 +-- +STMT: VariableSetStmt +== 859 +CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY LIST (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +== 860 +CREATE TABLE pk1 PARTITION OF pk FOR VALUES IN (1) PARTITION BY LIST (a) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +== 861 +CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES IN (1) +-- +TABLE: name="pk11" schema="" table="pk11" ctx=DDL +STMT: CreateStmt +== 862 +CREATE TABLE fk (a int) PARTITION BY LIST (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +== 863 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES IN (1) PARTITION BY LIST (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +== 864 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES IN (1) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +== 865 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 866 +CREATE TABLE pk2 PARTITION OF pk FOR VALUES IN (2) +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: CreateStmt +== 867 +CREATE TABLE pk3 (a int NOT NULL) PARTITION BY LIST (a) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: CreateStmt +== 868 +CREATE TABLE pk31 PARTITION OF pk3 FOR VALUES IN (31) +-- +TABLE: name="pk31" schema="" table="pk31" ctx=DDL +STMT: CreateStmt +== 869 +CREATE TABLE pk32 (b int, a int NOT NULL) +-- +TABLE: name="pk32" schema="" table="pk32" ctx=DDL +STMT: CreateStmt +== 870 +ALTER TABLE pk32 DROP COLUMN b +-- +TABLE: name="pk32" schema="" table="pk32" ctx=DDL +STMT: AlterTableStmt +== 871 +ALTER TABLE pk3 ATTACH PARTITION pk32 FOR VALUES IN (32) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: AlterTableStmt +== 872 +ALTER TABLE pk ATTACH PARTITION pk3 FOR VALUES IN (31, 32) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +== 873 +CREATE TABLE fk2 PARTITION OF fk FOR VALUES IN (2) +-- +TABLE: name="fk2" schema="" table="fk2" ctx=DDL +STMT: CreateStmt +== 874 +CREATE TABLE fk3 (b int, a int) +-- +TABLE: name="fk3" schema="" table="fk3" ctx=DDL +STMT: CreateStmt +== 875 +ALTER TABLE fk3 DROP COLUMN b +-- +TABLE: name="fk3" schema="" table="fk3" ctx=DDL +STMT: AlterTableStmt +== 876 +ALTER TABLE fk ATTACH PARTITION fk3 FOR VALUES IN (3) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 877 +SELECT pg_describe_object('pg_constraint'::regclass, oid, 0), confrelid::regclass, + CASE WHEN conparentid <> 0 THEN pg_describe_object('pg_constraint'::regclass, conparentid, 0) ELSE 'TOP' END +FROM pg_catalog.pg_constraint +WHERE conrelid IN (SELECT relid FROM pg_partition_tree('fk')) +ORDER BY conrelid::regclass::text, conname +-- +TABLE: name="pg_catalog.pg_constraint" schema="pg_catalog" table="pg_constraint" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 878 +CREATE TABLE fk4 (LIKE fk) +-- +TABLE: name="fk4" schema="" table="fk4" ctx=DDL +STMT: CreateStmt +== 879 +INSERT INTO fk4 VALUES (50) +-- +TABLE: name="fk4" schema="" table="fk4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 880 +ALTER TABLE fk ATTACH PARTITION fk4 FOR VALUES IN (50) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 881 +-- Verify constraint deferrability +CREATE SCHEMA fkpart9 +-- +STMT: CreateSchemaStmt +== 882 +SET search_path TO fkpart9 +-- +STMT: VariableSetStmt +== 883 +CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY LIST (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +== 884 +CREATE TABLE pk1 PARTITION OF pk FOR VALUES IN (1, 2) PARTITION BY LIST (a) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +== 885 +CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES IN (1) +-- +TABLE: name="pk11" schema="" table="pk11" ctx=DDL +STMT: CreateStmt +== 886 +CREATE TABLE pk3 PARTITION OF pk FOR VALUES IN (3) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: CreateStmt +== 887 +CREATE TABLE fk (a int REFERENCES pk DEFERRABLE INITIALLY IMMEDIATE) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +== 888 +INSERT INTO fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 889 +-- should fail +BEGIN +-- +STMT: TransactionStmt +== 890 +SET CONSTRAINTS fk_a_fkey DEFERRED +-- +STMT: ConstraintsSetStmt +== 891 +INSERT INTO fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 892 +COMMIT +-- +STMT: TransactionStmt +== 893 +-- should fail +BEGIN +-- +STMT: TransactionStmt +== 894 +SET CONSTRAINTS fk_a_fkey DEFERRED +-- +STMT: ConstraintsSetStmt +== 895 +INSERT INTO fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 896 +INSERT INTO pk VALUES (1) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 897 +COMMIT +-- +STMT: TransactionStmt +== 898 +-- OK +BEGIN +-- +STMT: TransactionStmt +== 899 +SET CONSTRAINTS fk_a_fkey DEFERRED +-- +STMT: ConstraintsSetStmt +== 900 +DELETE FROM pk WHERE a = 1 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 901 +DELETE FROM fk WHERE a = 1 +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: DeleteStmt +== 902 +COMMIT +-- +STMT: TransactionStmt +== 903 +-- OK + +-- Verify constraint deferrability when changed by ALTER +-- Partitioned table at referencing end +CREATE TABLE pt(f1 int, f2 int, f3 int, PRIMARY KEY(f1,f2)) +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +STMT: CreateStmt +== 904 +CREATE TABLE ref(f1 int, f2 int, f3 int) + PARTITION BY list(f1) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +== 905 +CREATE TABLE ref1 PARTITION OF ref FOR VALUES IN (1) +-- +TABLE: name="ref1" schema="" table="ref1" ctx=DDL +STMT: CreateStmt +== 906 +CREATE TABLE ref2 PARTITION OF ref FOR VALUES in (2) +-- +TABLE: name="ref2" schema="" table="ref2" ctx=DDL +STMT: CreateStmt +== 907 +ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 908 +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 909 +INSERT INTO pt VALUES(1,2,3) +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 910 +INSERT INTO ref VALUES(1,2,3) +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 911 +BEGIN +-- +STMT: TransactionStmt +== 912 +DELETE FROM pt +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: DeleteStmt +== 913 +DELETE FROM ref +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: DeleteStmt +== 914 +ABORT +-- +STMT: TransactionStmt +== 915 +DROP TABLE pt, ref +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +== 916 +-- Multi-level partitioning at referencing end +CREATE TABLE pt(f1 int, f2 int, f3 int, PRIMARY KEY(f1,f2)) +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +STMT: CreateStmt +== 917 +CREATE TABLE ref(f1 int, f2 int, f3 int) + PARTITION BY list(f1) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +== 918 +CREATE TABLE ref1_2 PARTITION OF ref FOR VALUES IN (1, 2) PARTITION BY list (f2) +-- +TABLE: name="ref1_2" schema="" table="ref1_2" ctx=DDL +STMT: CreateStmt +== 919 +CREATE TABLE ref1 PARTITION OF ref1_2 FOR VALUES IN (1) +-- +TABLE: name="ref1" schema="" table="ref1" ctx=DDL +STMT: CreateStmt +== 920 +CREATE TABLE ref2 PARTITION OF ref1_2 FOR VALUES IN (2) PARTITION BY list (f2) +-- +TABLE: name="ref2" schema="" table="ref2" ctx=DDL +STMT: CreateStmt +== 921 +CREATE TABLE ref22 PARTITION OF ref2 FOR VALUES IN (2) +-- +TABLE: name="ref22" schema="" table="ref22" ctx=DDL +STMT: CreateStmt +== 922 +ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 923 +INSERT INTO pt VALUES(1,2,3) +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 924 +INSERT INTO ref VALUES(1,2,3) +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 925 +ALTER TABLE ref22 ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY IMMEDIATE +-- +TABLE: name="ref22" schema="" table="ref22" ctx=DDL +STMT: AlterTableStmt +== 926 +-- fails +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 927 +BEGIN +-- +STMT: TransactionStmt +== 928 +DELETE FROM pt +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: DeleteStmt +== 929 +DELETE FROM ref +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: DeleteStmt +== 930 +ABORT +-- +STMT: TransactionStmt +== 931 +DROP TABLE pt, ref +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +== 932 +-- Partitioned table at referenced end +CREATE TABLE pt(f1 int, f2 int, f3 int, PRIMARY KEY(f1,f2)) + PARTITION BY LIST(f1) +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +STMT: CreateStmt +== 933 +CREATE TABLE pt1 PARTITION OF pt FOR VALUES IN (1) +-- +TABLE: name="pt1" schema="" table="pt1" ctx=DDL +STMT: CreateStmt +== 934 +CREATE TABLE pt2 PARTITION OF pt FOR VALUES IN (2) +-- +TABLE: name="pt2" schema="" table="pt2" ctx=DDL +STMT: CreateStmt +== 935 +CREATE TABLE ref(f1 int, f2 int, f3 int) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +== 936 +ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 937 +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 938 +INSERT INTO pt VALUES(1,2,3) +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 939 +INSERT INTO ref VALUES(1,2,3) +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 940 +BEGIN +-- +STMT: TransactionStmt +== 941 +DELETE FROM pt +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: DeleteStmt +== 942 +DELETE FROM ref +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: DeleteStmt +== 943 +ABORT +-- +STMT: TransactionStmt +== 944 +DROP TABLE pt, ref +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +== 945 +-- Multi-level partitioning at referenced end +CREATE TABLE pt(f1 int, f2 int, f3 int, PRIMARY KEY(f1,f2)) + PARTITION BY LIST(f1) +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +STMT: CreateStmt +== 946 +CREATE TABLE pt1_2 PARTITION OF pt FOR VALUES IN (1, 2) PARTITION BY LIST (f1) +-- +TABLE: name="pt1_2" schema="" table="pt1_2" ctx=DDL +STMT: CreateStmt +== 947 +CREATE TABLE pt1 PARTITION OF pt1_2 FOR VALUES IN (1) +-- +TABLE: name="pt1" schema="" table="pt1" ctx=DDL +STMT: CreateStmt +== 948 +CREATE TABLE pt2 PARTITION OF pt1_2 FOR VALUES IN (2) +-- +TABLE: name="pt2" schema="" table="pt2" ctx=DDL +STMT: CreateStmt +== 949 +CREATE TABLE ref(f1 int, f2 int, f3 int) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +== 950 +ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 951 +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey1 + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 952 +-- fails +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +== 953 +INSERT INTO pt VALUES(1,2,3) +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 954 +INSERT INTO ref VALUES(1,2,3) +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 955 +BEGIN +-- +STMT: TransactionStmt +== 956 +DELETE FROM pt +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: DeleteStmt +== 957 +DELETE FROM ref +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: DeleteStmt +== 958 +ABORT +-- +STMT: TransactionStmt +== 959 +DROP TABLE pt, ref +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +== 960 +DROP SCHEMA fkpart9 CASCADE +-- +STMT: DropStmt +== 961 +-- Verify ON UPDATE/DELETE behavior +CREATE SCHEMA fkpart6 +-- +STMT: CreateSchemaStmt +== 962 +SET search_path TO fkpart6 +-- +STMT: VariableSetStmt +== 963 +CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY RANGE (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +== 964 +CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +== 965 +CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES FROM (1) TO (50) +-- +TABLE: name="pk11" schema="" table="pk11" ctx=DDL +STMT: CreateStmt +== 966 +CREATE TABLE pk12 PARTITION OF pk1 FOR VALUES FROM (50) TO (100) +-- +TABLE: name="pk12" schema="" table="pk12" ctx=DDL +STMT: CreateStmt +== 967 +CREATE TABLE fk (a int) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +== 968 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +== 969 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +== 970 +CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100) +-- +TABLE: name="fk12" schema="" table="fk12" ctx=DDL +STMT: CreateStmt +== 971 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE CASCADE ON DELETE CASCADE +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 972 +CREATE TABLE fk_d PARTITION OF fk DEFAULT +-- +TABLE: name="fk_d" schema="" table="fk_d" ctx=DDL +STMT: CreateStmt +== 973 +INSERT INTO pk VALUES (1) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 974 +INSERT INTO fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 975 +UPDATE pk SET a = 20 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 976 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +== 977 +DELETE FROM pk WHERE a = 20 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 978 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +== 979 +DROP TABLE fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: DropStmt +== 980 +TRUNCATE TABLE pk +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: TruncateStmt +== 981 +INSERT INTO pk VALUES (20), (50) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 982 +CREATE TABLE fk (a int) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +== 983 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +== 984 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +== 985 +CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100) +-- +TABLE: name="fk12" schema="" table="fk12" ctx=DDL +STMT: CreateStmt +== 986 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE SET NULL ON DELETE SET NULL +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 987 +CREATE TABLE fk_d PARTITION OF fk DEFAULT +-- +TABLE: name="fk_d" schema="" table="fk_d" ctx=DDL +STMT: CreateStmt +== 988 +INSERT INTO fk VALUES (20), (50) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 989 +UPDATE pk SET a = 21 WHERE a = 20 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 990 +DELETE FROM pk WHERE a = 50 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 991 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +== 992 +DROP TABLE fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: DropStmt +== 993 +TRUNCATE TABLE pk +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: TruncateStmt +== 994 +INSERT INTO pk VALUES (20), (30), (50) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 995 +CREATE TABLE fk (id int, a int DEFAULT 50) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +== 996 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +== 997 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +== 998 +CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100) +-- +TABLE: name="fk12" schema="" table="fk12" ctx=DDL +STMT: CreateStmt +== 999 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE SET DEFAULT ON DELETE SET DEFAULT +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 1000 +CREATE TABLE fk_d PARTITION OF fk DEFAULT +-- +TABLE: name="fk_d" schema="" table="fk_d" ctx=DDL +STMT: CreateStmt +== 1001 +INSERT INTO fk VALUES (1, 20), (2, 30) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1002 +DELETE FROM pk WHERE a = 20 RETURNING * +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 1003 +UPDATE pk SET a = 90 WHERE a = 30 RETURNING * +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 1004 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +== 1005 +DROP TABLE fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: DropStmt +== 1006 +TRUNCATE TABLE pk +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: TruncateStmt +== 1007 +INSERT INTO pk VALUES (20), (30) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1008 +CREATE TABLE fk (a int DEFAULT 50) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +== 1009 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +== 1010 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +== 1011 +CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100) +-- +TABLE: name="fk12" schema="" table="fk12" ctx=DDL +STMT: CreateStmt +== 1012 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE RESTRICT ON DELETE RESTRICT +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +== 1013 +CREATE TABLE fk_d PARTITION OF fk DEFAULT +-- +TABLE: name="fk_d" schema="" table="fk_d" ctx=DDL +STMT: CreateStmt +== 1014 +INSERT INTO fk VALUES (20), (30) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1015 +DELETE FROM pk WHERE a = 20 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +== 1016 +UPDATE pk SET a = 90 WHERE a = 30 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +== 1017 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +== 1018 +DROP TABLE fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: DropStmt +== 1019 +-- test for reported bug: relispartition not set +-- https://postgr.es/m/CA+HiwqHMsRtRYRWYTWavKJ8x14AFsv7bmAV46mYwnfD3vy8goQ@mail.gmail.com +CREATE SCHEMA fkpart7 + CREATE TABLE pkpart (a int) PARTITION BY LIST (a) + CREATE TABLE pkpart1 PARTITION OF pkpart FOR VALUES IN (1) +-- +STMT: CreateSchemaStmt +== 1020 +ALTER TABLE fkpart7.pkpart1 ADD PRIMARY KEY (a) +-- +TABLE: name="fkpart7.pkpart1" schema="fkpart7" table="pkpart1" ctx=DDL +STMT: AlterTableStmt +== 1021 +ALTER TABLE fkpart7.pkpart ADD PRIMARY KEY (a) +-- +TABLE: name="fkpart7.pkpart" schema="fkpart7" table="pkpart" ctx=DDL +STMT: AlterTableStmt +== 1022 +CREATE TABLE fkpart7.fk (a int REFERENCES fkpart7.pkpart) +-- +TABLE: name="fkpart7.fk" schema="fkpart7" table="fk" ctx=DDL +STMT: CreateStmt +== 1023 +DROP SCHEMA fkpart7 CASCADE +-- +STMT: DropStmt +== 1024 +-- ensure we check partitions are "not used" when dropping constraints +CREATE SCHEMA fkpart8 + CREATE TABLE tbl1(f1 int PRIMARY KEY) + CREATE TABLE tbl2(f1 int REFERENCES tbl1 DEFERRABLE INITIALLY DEFERRED) PARTITION BY RANGE(f1) + CREATE TABLE tbl2_p1 PARTITION OF tbl2 FOR VALUES FROM (minvalue) TO (maxvalue) +-- +STMT: CreateSchemaStmt +== 1025 +INSERT INTO fkpart8.tbl1 VALUES(1) +-- +TABLE: name="fkpart8.tbl1" schema="fkpart8" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1026 +BEGIN +-- +STMT: TransactionStmt +== 1027 +INSERT INTO fkpart8.tbl2 VALUES(1) +-- +TABLE: name="fkpart8.tbl2" schema="fkpart8" table="tbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1028 +ALTER TABLE fkpart8.tbl2 DROP CONSTRAINT tbl2_f1_fkey +-- +TABLE: name="fkpart8.tbl2" schema="fkpart8" table="tbl2" ctx=DDL +STMT: AlterTableStmt +== 1029 +COMMIT +-- +STMT: TransactionStmt +== 1030 +DROP SCHEMA fkpart8 CASCADE +-- +STMT: DropStmt +== 1031 +-- ensure FK referencing a multi-level partitioned table are +-- enforce reference to sub-children. +CREATE SCHEMA fkpart9 + CREATE TABLE pk (a INT PRIMARY KEY) PARTITION BY RANGE (a) + CREATE TABLE fk ( + fk_a INT REFERENCES pk(a) ON DELETE CASCADE + ) + CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (30) TO (50) PARTITION BY RANGE (a) + CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES FROM (30) TO (40) +-- +STMT: CreateSchemaStmt +== 1032 +INSERT INTO fkpart9.pk VALUES (35) +-- +TABLE: name="fkpart9.pk" schema="fkpart9" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1033 +INSERT INTO fkpart9.fk VALUES (35) +-- +TABLE: name="fkpart9.fk" schema="fkpart9" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1034 +DELETE FROM fkpart9.pk WHERE a=35 +-- +TABLE: name="fkpart9.pk" schema="fkpart9" table="pk" ctx=DML +STMT: DeleteStmt +== 1035 +SELECT * FROM fkpart9.pk +-- +TABLE: name="fkpart9.pk" schema="fkpart9" table="pk" ctx=Select +STMT: SelectStmt +== 1036 +SELECT * FROM fkpart9.fk +-- +TABLE: name="fkpart9.fk" schema="fkpart9" table="fk" ctx=Select +STMT: SelectStmt +== 1037 +DROP SCHEMA fkpart9 CASCADE +-- +STMT: DropStmt +== 1038 +-- test that ri_Check_Pk_Match() scans the correct partition for a deferred +-- ON DELETE/UPDATE NO ACTION constraint +CREATE SCHEMA fkpart10 + CREATE TABLE tbl1(f1 int PRIMARY KEY) PARTITION BY RANGE(f1) + CREATE TABLE tbl1_p1 PARTITION OF tbl1 FOR VALUES FROM (minvalue) TO (1) + CREATE TABLE tbl1_p2 PARTITION OF tbl1 FOR VALUES FROM (1) TO (maxvalue) + CREATE TABLE tbl2(f1 int REFERENCES tbl1 DEFERRABLE INITIALLY DEFERRED) + CREATE TABLE tbl3(f1 int PRIMARY KEY) PARTITION BY RANGE(f1) + CREATE TABLE tbl3_p1 PARTITION OF tbl3 FOR VALUES FROM (minvalue) TO (1) + CREATE TABLE tbl3_p2 PARTITION OF tbl3 FOR VALUES FROM (1) TO (maxvalue) + CREATE TABLE tbl4(f1 int REFERENCES tbl3 DEFERRABLE INITIALLY DEFERRED) +-- +STMT: CreateSchemaStmt +== 1039 +INSERT INTO fkpart10.tbl1 VALUES (0), (1) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1040 +INSERT INTO fkpart10.tbl2 VALUES (0), (1) +-- +TABLE: name="fkpart10.tbl2" schema="fkpart10" table="tbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1041 +INSERT INTO fkpart10.tbl3 VALUES (-2), (-1), (0) +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1042 +INSERT INTO fkpart10.tbl4 VALUES (-2), (-1) +-- +TABLE: name="fkpart10.tbl4" schema="fkpart10" table="tbl4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1043 +BEGIN +-- +STMT: TransactionStmt +== 1044 +DELETE FROM fkpart10.tbl1 WHERE f1 = 0 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: DeleteStmt +== 1045 +UPDATE fkpart10.tbl1 SET f1 = 2 WHERE f1 = 1 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: UpdateStmt +== 1046 +INSERT INTO fkpart10.tbl1 VALUES (0), (1) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1047 +COMMIT +-- +STMT: TransactionStmt +== 1048 +-- test that cross-partition updates correctly enforces the foreign key +-- restriction (specifically testing INITIALLY DEFERRED) +BEGIN +-- +STMT: TransactionStmt +== 1049 +UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: UpdateStmt +== 1050 +UPDATE fkpart10.tbl3 SET f1 = f1 * -1 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +== 1051 +INSERT INTO fkpart10.tbl1 VALUES (4) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1052 +COMMIT +-- +STMT: TransactionStmt +== 1053 +BEGIN +-- +STMT: TransactionStmt +== 1054 +UPDATE fkpart10.tbl3 SET f1 = f1 * -1 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +== 1055 +UPDATE fkpart10.tbl3 SET f1 = f1 + 3 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +== 1056 +UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: UpdateStmt +== 1057 +INSERT INTO fkpart10.tbl1 VALUES (0) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1058 +COMMIT +-- +STMT: TransactionStmt +== 1059 +BEGIN +-- +STMT: TransactionStmt +== 1060 +UPDATE fkpart10.tbl3 SET f1 = f1 * -1 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +== 1061 +UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: UpdateStmt +== 1062 +INSERT INTO fkpart10.tbl1 VALUES (0) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1063 +INSERT INTO fkpart10.tbl3 VALUES (-2), (-1) +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1064 +COMMIT +-- +STMT: TransactionStmt +== 1065 +-- test where the updated table now has both an IMMEDIATE and a DEFERRED +-- constraint pointing into it +CREATE TABLE fkpart10.tbl5(f1 int REFERENCES fkpart10.tbl3) +-- +TABLE: name="fkpart10.tbl5" schema="fkpart10" table="tbl5" ctx=DDL +STMT: CreateStmt +== 1066 +INSERT INTO fkpart10.tbl5 VALUES (-2), (-1) +-- +TABLE: name="fkpart10.tbl5" schema="fkpart10" table="tbl5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1067 +BEGIN +-- +STMT: TransactionStmt +== 1068 +UPDATE fkpart10.tbl3 SET f1 = f1 * -3 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +== 1069 +COMMIT +-- +STMT: TransactionStmt +== 1070 +-- Now test where the row referenced from the table with an IMMEDIATE +-- constraint stays in place, while those referenced from the table with a +-- DEFERRED constraint don't. +DELETE FROM fkpart10.tbl5 +-- +TABLE: name="fkpart10.tbl5" schema="fkpart10" table="tbl5" ctx=DML +STMT: DeleteStmt +== 1071 +INSERT INTO fkpart10.tbl5 VALUES (0) +-- +TABLE: name="fkpart10.tbl5" schema="fkpart10" table="tbl5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1072 +BEGIN +-- +STMT: TransactionStmt +== 1073 +UPDATE fkpart10.tbl3 SET f1 = f1 * -3 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +== 1074 +COMMIT +-- +STMT: TransactionStmt +== 1075 +DROP SCHEMA fkpart10 CASCADE +-- +STMT: DropStmt +== 1076 +-- verify foreign keys are enforced during cross-partition updates, +-- especially on the PK side +CREATE SCHEMA fkpart11 + CREATE TABLE pk (a INT PRIMARY KEY, b text) PARTITION BY LIST (a) + CREATE TABLE fk ( + a INT, + CONSTRAINT fkey FOREIGN KEY (a) REFERENCES pk(a) ON UPDATE CASCADE ON DELETE CASCADE + ) + CREATE TABLE fk_parted ( + a INT PRIMARY KEY, + CONSTRAINT fkey FOREIGN KEY (a) REFERENCES pk(a) ON UPDATE CASCADE ON DELETE CASCADE + ) PARTITION BY LIST (a) + CREATE TABLE fk_another ( + a INT, + CONSTRAINT fkey FOREIGN KEY (a) REFERENCES fk_parted (a) ON UPDATE CASCADE ON DELETE CASCADE + ) + CREATE TABLE pk1 PARTITION OF pk FOR VALUES IN (1, 2) PARTITION BY LIST (a) + CREATE TABLE pk2 PARTITION OF pk FOR VALUES IN (3) + CREATE TABLE pk3 PARTITION OF pk FOR VALUES IN (4) + CREATE TABLE fk1 PARTITION OF fk_parted FOR VALUES IN (1, 2) + CREATE TABLE fk2 PARTITION OF fk_parted FOR VALUES IN (3) + CREATE TABLE fk3 PARTITION OF fk_parted FOR VALUES IN (4) +-- +STMT: CreateSchemaStmt +== 1077 +CREATE TABLE fkpart11.pk11 (b text, a int NOT NULL) +-- +TABLE: name="fkpart11.pk11" schema="fkpart11" table="pk11" ctx=DDL +STMT: CreateStmt +== 1078 +ALTER TABLE fkpart11.pk1 ATTACH PARTITION fkpart11.pk11 FOR VALUES IN (1) +-- +TABLE: name="fkpart11.pk1" schema="fkpart11" table="pk1" ctx=DDL +STMT: AlterTableStmt +== 1079 +CREATE TABLE fkpart11.pk12 (b text, c int, a int NOT NULL) +-- +TABLE: name="fkpart11.pk12" schema="fkpart11" table="pk12" ctx=DDL +STMT: CreateStmt +== 1080 +ALTER TABLE fkpart11.pk12 DROP c +-- +TABLE: name="fkpart11.pk12" schema="fkpart11" table="pk12" ctx=DDL +STMT: AlterTableStmt +== 1081 +ALTER TABLE fkpart11.pk1 ATTACH PARTITION fkpart11.pk12 FOR VALUES IN (2) +-- +TABLE: name="fkpart11.pk1" schema="fkpart11" table="pk1" ctx=DDL +STMT: AlterTableStmt +== 1082 +INSERT INTO fkpart11.pk VALUES (1, 'xxx'), (3, 'yyy') +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1083 +INSERT INTO fkpart11.fk VALUES (1), (3) +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1084 +INSERT INTO fkpart11.fk_parted VALUES (1), (3) +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1085 +INSERT INTO fkpart11.fk_another VALUES (1), (3) +-- +TABLE: name="fkpart11.fk_another" schema="fkpart11" table="fk_another" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1086 +-- moves 2 rows from one leaf partition to another, with both updates being +-- cascaded to fk and fk_parted. Updates of fk_parted, of which one is +-- cross-partition (3 -> 4), are further cascaded to fk_another. +UPDATE fkpart11.pk SET a = a + 1 RETURNING tableoid::pg_catalog.regclass, * +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +== 1087 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=Select +STMT: SelectStmt +== 1088 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_parted +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=Select +STMT: SelectStmt +== 1089 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_another +-- +TABLE: name="fkpart11.fk_another" schema="fkpart11" table="fk_another" ctx=Select +STMT: SelectStmt +== 1090 +-- let's try with the foreign key pointing at tables in the partition tree +-- that are not the same as the query's target table + +-- 1. foreign key pointing into a non-root ancestor +|-- +-- A cross-partition update on the root table will fail, because we currently +-- can't enforce the foreign keys pointing into a non-leaf partition +ALTER TABLE fkpart11.fk DROP CONSTRAINT fkey +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: AlterTableStmt +== 1091 +DELETE FROM fkpart11.fk WHERE a = 4 +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DML +STMT: DeleteStmt +== 1092 +ALTER TABLE fkpart11.fk ADD CONSTRAINT fkey FOREIGN KEY (a) REFERENCES fkpart11.pk1 (a) ON UPDATE CASCADE ON DELETE CASCADE +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: AlterTableStmt +== 1093 +UPDATE fkpart11.pk SET a = a - 1 +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +== 1094 +-- it's okay though if the non-leaf partition is updated directly +UPDATE fkpart11.pk1 SET a = a - 1 +-- +TABLE: name="fkpart11.pk1" schema="fkpart11" table="pk1" ctx=DML +STMT: UpdateStmt +== 1095 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.pk +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=Select +STMT: SelectStmt +== 1096 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=Select +STMT: SelectStmt +== 1097 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_parted +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=Select +STMT: SelectStmt +== 1098 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_another +-- +TABLE: name="fkpart11.fk_another" schema="fkpart11" table="fk_another" ctx=Select +STMT: SelectStmt +== 1099 +-- 2. foreign key pointing into a single leaf partition +|-- +-- A cross-partition update that deletes from the pointed-to leaf partition +-- is allowed to succeed +ALTER TABLE fkpart11.fk DROP CONSTRAINT fkey +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: AlterTableStmt +== 1100 +ALTER TABLE fkpart11.fk ADD CONSTRAINT fkey FOREIGN KEY (a) REFERENCES fkpart11.pk11 (a) ON UPDATE CASCADE ON DELETE CASCADE +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: AlterTableStmt +== 1101 +-- will delete (1) from p11 which is cascaded to fk +UPDATE fkpart11.pk SET a = a + 1 WHERE a = 1 +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +== 1102 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=Select +STMT: SelectStmt +== 1103 +DROP TABLE fkpart11.fk +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: DropStmt +== 1104 +-- check that regular and deferrable AR triggers on the PK tables +-- still work as expected +CREATE FUNCTION fkpart11.print_row () RETURNS TRIGGER LANGUAGE plpgsql AS $$ + BEGIN + RAISE NOTICE 'TABLE: %, OP: %, OLD: %, NEW: %', TG_RELNAME, TG_OP, OLD, NEW; + RETURN NULL; + END; +$$ +-- +FUNCTION: name="fkpart11.print_row" function="print_row" schema="fkpart11" ctx=DDL +STMT: CreateFunctionStmt +== 1105 +CREATE TRIGGER trig_upd_pk AFTER UPDATE ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DDL +STMT: CreateTrigStmt +== 1106 +CREATE TRIGGER trig_del_pk AFTER DELETE ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DDL +STMT: CreateTrigStmt +== 1107 +CREATE TRIGGER trig_ins_pk AFTER INSERT ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DDL +STMT: CreateTrigStmt +== 1108 +CREATE CONSTRAINT TRIGGER trig_upd_fk_parted AFTER UPDATE ON fkpart11.fk_parted INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=DDL +STMT: CreateTrigStmt +== 1109 +CREATE CONSTRAINT TRIGGER trig_del_fk_parted AFTER DELETE ON fkpart11.fk_parted INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=DDL +STMT: CreateTrigStmt +== 1110 +CREATE CONSTRAINT TRIGGER trig_ins_fk_parted AFTER INSERT ON fkpart11.fk_parted INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=DDL +STMT: CreateTrigStmt +== 1111 +UPDATE fkpart11.pk SET a = 3 WHERE a = 4 +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +== 1112 +UPDATE fkpart11.pk SET a = 1 WHERE a = 2 +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +== 1113 +DROP SCHEMA fkpart11 CASCADE +-- +STMT: DropStmt +== 1114 +-- When a table is attached as partition to a partitioned table that has +-- a foreign key to another partitioned table, it acquires a clone of the +-- FK. Upon detach, this clone is not removed, but instead becomes an +-- independent FK. If it then attaches to the partitioned table again, +-- the FK from the parent "takes over" ownership of the independent FK rather +-- than creating a separate one. +CREATE SCHEMA fkpart12 + CREATE TABLE fk_p ( id int, jd int, PRIMARY KEY(id, jd)) PARTITION BY list (id) + CREATE TABLE fk_p_1 PARTITION OF fk_p FOR VALUES IN (1) PARTITION BY list (jd) + CREATE TABLE fk_p_1_1 PARTITION OF fk_p_1 FOR VALUES IN (1) + CREATE TABLE fk_p_1_2 (x int, y int, jd int NOT NULL, id int NOT NULL) + CREATE TABLE fk_p_2 PARTITION OF fk_p FOR VALUES IN (2) PARTITION BY list (jd) + CREATE TABLE fk_p_2_1 PARTITION OF fk_p_2 FOR VALUES IN (1) + CREATE TABLE fk_p_2_2 PARTITION OF fk_p_2 FOR VALUES IN (2) + CREATE TABLE fk_r_1 ( p_jd int NOT NULL, x int, id int PRIMARY KEY, p_id int NOT NULL) + CREATE TABLE fk_r_2 ( id int PRIMARY KEY, p_id int NOT NULL, p_jd int NOT NULL) PARTITION BY list (id) + CREATE TABLE fk_r_2_1 PARTITION OF fk_r_2 FOR VALUES IN (2, 1) + CREATE TABLE fk_r ( id int PRIMARY KEY, p_id int NOT NULL, p_jd int NOT NULL, + FOREIGN KEY (p_id, p_jd) REFERENCES fk_p (id, jd) + ) PARTITION BY list (id) +-- +STMT: CreateSchemaStmt +== 1115 +SET search_path TO fkpart12 +-- +STMT: VariableSetStmt +== 1116 +ALTER TABLE fk_p_1_2 DROP COLUMN x, DROP COLUMN y +-- +TABLE: name="fk_p_1_2" schema="" table="fk_p_1_2" ctx=DDL +STMT: AlterTableStmt +== 1117 +ALTER TABLE fk_p_1 ATTACH PARTITION fk_p_1_2 FOR VALUES IN (2) +-- +TABLE: name="fk_p_1" schema="" table="fk_p_1" ctx=DDL +STMT: AlterTableStmt +== 1118 +ALTER TABLE fk_r_1 DROP COLUMN x +-- +TABLE: name="fk_r_1" schema="" table="fk_r_1" ctx=DDL +STMT: AlterTableStmt +== 1119 +INSERT INTO fk_p VALUES (1, 1) +-- +TABLE: name="fk_p" schema="" table="fk_p" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1120 +ALTER TABLE fk_r ATTACH PARTITION fk_r_1 FOR VALUES IN (1) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +== 1121 +ALTER TABLE fk_r ATTACH PARTITION fk_r_2 FOR VALUES IN (2) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +== 1122 +INSERT INTO fk_r VALUES (1, 1, 1) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1123 +INSERT INTO fk_r VALUES (2, 2, 1) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1124 +ALTER TABLE fk_r DETACH PARTITION fk_r_1 +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +== 1125 +ALTER TABLE fk_r DETACH PARTITION fk_r_2 +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +== 1126 +INSERT INTO fk_r_1 (id, p_id, p_jd) VALUES (2, 1, 2) +-- +TABLE: name="fk_r_1" schema="" table="fk_r_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1127 +-- should fail +DELETE FROM fk_p +-- +TABLE: name="fk_p" schema="" table="fk_p" ctx=DML +STMT: DeleteStmt +== 1128 +-- should fail + +ALTER TABLE fk_r ATTACH PARTITION fk_r_1 FOR VALUES IN (1) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +== 1129 +ALTER TABLE fk_r ATTACH PARTITION fk_r_2 FOR VALUES IN (2) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +== 1130 +DELETE FROM fk_p +-- +TABLE: name="fk_p" schema="" table="fk_p" ctx=DML +STMT: DeleteStmt +== 1131 +-- should fail + +-- these should all fail +ALTER TABLE fk_r_1 DROP CONSTRAINT fk_r_p_id_p_jd_fkey +-- +TABLE: name="fk_r_1" schema="" table="fk_r_1" ctx=DDL +STMT: AlterTableStmt +== 1132 +ALTER TABLE fk_r DROP CONSTRAINT fk_r_p_id_p_jd_fkey1 +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +== 1133 +ALTER TABLE fk_r_2 DROP CONSTRAINT fk_r_p_id_p_jd_fkey +-- +TABLE: name="fk_r_2" schema="" table="fk_r_2" ctx=DDL +STMT: AlterTableStmt +== 1134 +SET client_min_messages TO warning +-- +STMT: VariableSetStmt +== 1135 +DROP SCHEMA fkpart12 CASCADE +-- +STMT: DropStmt +== 1136 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 1137 +RESET search_path +-- +STMT: VariableSetStmt +== 1138 +-- Exercise the column mapping code with foreign keys. In this test we'll +-- create a partitioned table which has a partition with a dropped column and +-- check to ensure that an UPDATE cascades the changes correctly to the +-- partitioned table. +CREATE SCHEMA fkpart13 +-- +STMT: CreateSchemaStmt +== 1139 +SET search_path TO fkpart13 +-- +STMT: VariableSetStmt +== 1140 +CREATE TABLE fkpart13_t1 (a int PRIMARY KEY) +-- +TABLE: name="fkpart13_t1" schema="" table="fkpart13_t1" ctx=DDL +STMT: CreateStmt +== 1141 +CREATE TABLE fkpart13_t2 ( + part_id int PRIMARY KEY, + column_to_drop int, + FOREIGN KEY (part_id) REFERENCES fkpart13_t1 ON UPDATE CASCADE ON DELETE CASCADE +) PARTITION BY LIST (part_id) +-- +TABLE: name="fkpart13_t2" schema="" table="fkpart13_t2" ctx=DDL +STMT: CreateStmt +== 1142 +CREATE TABLE fkpart13_t2_p1 PARTITION OF fkpart13_t2 FOR VALUES IN (1) +-- +TABLE: name="fkpart13_t2_p1" schema="" table="fkpart13_t2_p1" ctx=DDL +STMT: CreateStmt +== 1143 +-- drop the column +ALTER TABLE fkpart13_t2 DROP COLUMN column_to_drop +-- +TABLE: name="fkpart13_t2" schema="" table="fkpart13_t2" ctx=DDL +STMT: AlterTableStmt +== 1144 +-- create a new partition without the dropped column +CREATE TABLE fkpart13_t2_p2 PARTITION OF fkpart13_t2 FOR VALUES IN (2) +-- +TABLE: name="fkpart13_t2_p2" schema="" table="fkpart13_t2_p2" ctx=DDL +STMT: CreateStmt +== 1145 +CREATE TABLE fkpart13_t3 ( + a int NOT NULL, + FOREIGN KEY (a) + REFERENCES fkpart13_t2 + ON UPDATE CASCADE ON DELETE CASCADE +) +-- +TABLE: name="fkpart13_t3" schema="" table="fkpart13_t3" ctx=DDL +STMT: CreateStmt +== 1146 +INSERT INTO fkpart13_t1 (a) VALUES (1) +-- +TABLE: name="fkpart13_t1" schema="" table="fkpart13_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1147 +INSERT INTO fkpart13_t2 (part_id) VALUES (1) +-- +TABLE: name="fkpart13_t2" schema="" table="fkpart13_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1148 +INSERT INTO fkpart13_t3 (a) VALUES (1) +-- +TABLE: name="fkpart13_t3" schema="" table="fkpart13_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1149 +-- Test a cascading update works correctly with with the dropped column +UPDATE fkpart13_t1 SET a = 2 WHERE a = 1 +-- +TABLE: name="fkpart13_t1" schema="" table="fkpart13_t1" ctx=DML +STMT: UpdateStmt +== 1150 +SELECT tableoid::regclass,* FROM fkpart13_t2 +-- +TABLE: name="fkpart13_t2" schema="" table="fkpart13_t2" ctx=Select +STMT: SelectStmt +== 1151 +SELECT tableoid::regclass,* FROM fkpart13_t3 +-- +TABLE: name="fkpart13_t3" schema="" table="fkpart13_t3" ctx=Select +STMT: SelectStmt +== 1152 +-- Exercise code in ExecGetTriggerResultRel() as there's been previous issues +-- with ResultRelInfos being returned with the incorrect ri_RootResultRelInfo +WITH cte AS ( + UPDATE fkpart13_t2_p1 SET part_id = part_id +) UPDATE fkpart13_t1 SET a = 2 WHERE a = 1 +-- +TABLE: name="fkpart13_t1" schema="" table="fkpart13_t1" ctx=DML +TABLE: name="fkpart13_t2_p1" schema="" table="fkpart13_t2_p1" ctx=DML +CTE: "cte" +STMT: UpdateStmt +== 1153 +DROP SCHEMA fkpart13 CASCADE +-- +STMT: DropStmt +== 1154 +RESET search_path +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/functional_deps.metadata.json b/parser/testdata/summary/postgres_regress/functional_deps.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/functional_deps.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/functional_deps.test b/parser/testdata/summary/postgres_regress/functional_deps.test new file mode 100644 index 0000000..0fc9705 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/functional_deps.test @@ -0,0 +1,395 @@ +== 001 +-- from http://www.depesz.com/index.php/2010/04/19/getting-unique-elements/ + +CREATE TEMP TABLE articles ( + id int CONSTRAINT articles_pkey PRIMARY KEY, + keywords text, + title text UNIQUE NOT NULL, + body text UNIQUE, + created date +) +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TEMP TABLE articles_in_category ( + article_id int, + category_id int, + changed date, + PRIMARY KEY (article_id, category_id) +) +-- +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=DDL +STMT: CreateStmt +== 003 +-- test functional dependencies based on primary keys/unique constraints + +-- base tables + +-- group by primary key (OK) +SELECT id, keywords, title, body, created +FROM articles +GROUP BY id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: SelectStmt +== 004 +-- group by unique not null (fail/todo) +SELECT id, keywords, title, body, created +FROM articles +GROUP BY title +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: SelectStmt +== 005 +-- group by unique nullable (fail) +SELECT id, keywords, title, body, created +FROM articles +GROUP BY body +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: SelectStmt +== 006 +-- group by something else (fail) +SELECT id, keywords, title, body, created +FROM articles +GROUP BY keywords +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: SelectStmt +== 007 +-- multiple tables + +-- group by primary key (OK) +SELECT a.id, a.keywords, a.title, a.body, a.created +FROM articles AS a, articles_in_category AS aic +WHERE a.id = aic.article_id AND aic.category_id in (14,62,70,53,138) +GROUP BY a.id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="aic" column="article_id" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +== 008 +-- group by something else (fail) +SELECT a.id, a.keywords, a.title, a.body, a.created +FROM articles AS a, articles_in_category AS aic +WHERE a.id = aic.article_id AND aic.category_id in (14,62,70,53,138) +GROUP BY aic.article_id, aic.category_id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="aic" column="article_id" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +== 009 +-- JOIN syntax + +-- group by left table's primary key (OK) +SELECT a.id, a.keywords, a.title, a.body, a.created +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY a.id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +== 010 +-- group by something else (fail) +SELECT a.id, a.keywords, a.title, a.body, a.created +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY aic.article_id, aic.category_id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +== 011 +-- group by right table's (composite) primary key (OK) +SELECT aic.changed +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY aic.category_id, aic.article_id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +== 012 +-- group by right table's partial primary key (fail) +SELECT aic.changed +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY aic.article_id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +== 013 +-- example from documentation + +CREATE TEMP TABLE products (product_id int, name text, price numeric) +-- +TABLE: name="products" schema="" table="products" ctx=DDL +STMT: CreateStmt +== 014 +CREATE TEMP TABLE sales (product_id int, units int) +-- +TABLE: name="sales" schema="" table="sales" ctx=DDL +STMT: CreateStmt +== 015 +-- OK +SELECT product_id, p.name, (sum(s.units) * p.price) AS sales + FROM products p LEFT JOIN sales s USING (product_id) + GROUP BY product_id, p.name, p.price +-- +TABLE: name="products" schema="" table="products" ctx=Select +TABLE: name="sales" schema="" table="sales" ctx=Select +ALIAS: "p"="products" +ALIAS: "s"="sales" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- fail +SELECT product_id, p.name, (sum(s.units) * p.price) AS sales + FROM products p LEFT JOIN sales s USING (product_id) + GROUP BY product_id +-- +TABLE: name="products" schema="" table="products" ctx=Select +TABLE: name="sales" schema="" table="sales" ctx=Select +ALIAS: "p"="products" +ALIAS: "s"="sales" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 017 +ALTER TABLE products ADD PRIMARY KEY (product_id) +-- +TABLE: name="products" schema="" table="products" ctx=DDL +STMT: AlterTableStmt +== 018 +-- OK now +SELECT product_id, p.name, (sum(s.units) * p.price) AS sales + FROM products p LEFT JOIN sales s USING (product_id) + GROUP BY product_id +-- +TABLE: name="products" schema="" table="products" ctx=Select +TABLE: name="sales" schema="" table="sales" ctx=Select +ALIAS: "p"="products" +ALIAS: "s"="sales" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- Drupal example, http://drupal.org/node/555530 + +CREATE TEMP TABLE node ( + nid SERIAL, + vid integer NOT NULL default '0', + type varchar(32) NOT NULL default '', + title varchar(128) NOT NULL default '', + uid integer NOT NULL default '0', + status integer NOT NULL default '1', + created integer NOT NULL default '0', + -- snip + PRIMARY KEY (nid, vid) +) +-- +TABLE: name="node" schema="" table="node" ctx=DDL +STMT: CreateStmt +== 020 +CREATE TEMP TABLE users ( + uid integer NOT NULL default '0', + name varchar(60) NOT NULL default '', + pass varchar(32) NOT NULL default '', + -- snip + PRIMARY KEY (uid), + UNIQUE (name) +) +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: CreateStmt +== 021 +-- OK +SELECT u.uid, u.name FROM node n +INNER JOIN users u ON u.uid = n.uid +WHERE n.type = 'blog' AND n.status = 1 +GROUP BY u.uid, u.name +-- +TABLE: name="node" schema="" table="node" ctx=Select +TABLE: name="users" schema="" table="users" ctx=Select +ALIAS: "n"="node" +ALIAS: "u"="users" +FILTER: schema="" table="n" column="type" +FILTER: schema="" table="n" column="status" +STMT: SelectStmt +== 022 +-- OK +SELECT u.uid, u.name FROM node n +INNER JOIN users u ON u.uid = n.uid +WHERE n.type = 'blog' AND n.status = 1 +GROUP BY u.uid +-- +TABLE: name="node" schema="" table="node" ctx=Select +TABLE: name="users" schema="" table="users" ctx=Select +ALIAS: "n"="node" +ALIAS: "u"="users" +FILTER: schema="" table="n" column="type" +FILTER: schema="" table="n" column="status" +STMT: SelectStmt +== 023 +-- Check views and dependencies + +-- fail +CREATE TEMP VIEW fdv1 AS +SELECT id, keywords, title, body, created +FROM articles +GROUP BY body +-- +TABLE: name="fdv1" schema="" table="fdv1" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 024 +-- OK +CREATE TEMP VIEW fdv1 AS +SELECT id, keywords, title, body, created +FROM articles +GROUP BY id +-- +TABLE: name="fdv1" schema="" table="fdv1" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 025 +-- fail +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +== 026 +DROP VIEW fdv1 +-- +STMT: DropStmt +== 027 +-- multiple dependencies +CREATE TEMP VIEW fdv2 AS +SELECT a.id, a.keywords, a.title, aic.category_id, aic.changed +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY a.id, aic.category_id, aic.article_id +-- +TABLE: name="fdv2" schema="" table="fdv2" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: ViewStmt +STMT: SelectStmt +== 028 +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +== 029 +-- fail +ALTER TABLE articles_in_category DROP CONSTRAINT articles_in_category_pkey RESTRICT +-- +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=DDL +STMT: AlterTableStmt +== 030 +--fail + +DROP VIEW fdv2 +-- +STMT: DropStmt +== 031 +-- nested queries + +CREATE TEMP VIEW fdv3 AS +SELECT id, keywords, title, body, created +FROM articles +GROUP BY id +UNION +SELECT id, keywords, title, body, created +FROM articles +GROUP BY id +-- +TABLE: name="fdv3" schema="" table="fdv3" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 032 +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +== 033 +-- fail + +DROP VIEW fdv3 +-- +STMT: DropStmt +== 034 +CREATE TEMP VIEW fdv4 AS +SELECT * FROM articles WHERE title IN (SELECT title FROM articles GROUP BY id) +-- +TABLE: name="fdv4" schema="" table="fdv4" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles" schema="" table="articles" ctx=Select +FILTER: schema="" table="" column="title" +STMT: ViewStmt +STMT: SelectStmt +== 035 +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +== 036 +-- fail + +DROP VIEW fdv4 +-- +STMT: DropStmt +== 037 +-- prepared query plans: this results in failure on reuse + +PREPARE foo AS + SELECT id, keywords, title, body, created + FROM articles + GROUP BY id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +== 038 +EXECUTE foo +-- +STMT: ExecuteStmt +== 039 +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +== 040 +EXECUTE foo +-- +STMT: ExecuteStmt diff --git a/parser/testdata/summary/postgres_regress/generated.metadata.json b/parser/testdata/summary/postgres_regress/generated.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/generated.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/generated.test b/parser/testdata/summary/postgres_regress/generated.test new file mode 100644 index 0000000..dc40d55 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/generated.test @@ -0,0 +1,699 @@ +== 001 +-- sanity check of system catalog +SELECT attrelid, attname, attgenerated FROM pg_attribute WHERE attgenerated NOT IN ('', 's') +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attgenerated" +STMT: SelectStmt +== 002 +CREATE TABLE gtest0 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (55) STORED) +-- +TABLE: name="gtest0" schema="" table="gtest0" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE gtest1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DDL +STMT: CreateStmt +== 004 +SELECT table_name, column_name, column_default, is_nullable, is_generated, generation_expression FROM information_schema.columns WHERE table_name LIKE 'gtest_' ORDER BY 1, 2 +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 005 +SELECT table_name, column_name, dependent_column FROM information_schema.column_column_usage ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.column_column_usage" schema="information_schema" table="column_column_usage" ctx=Select +STMT: SelectStmt +== 006 +-- duplicate generated +CREATE TABLE gtest_err_1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED GENERATED ALWAYS AS (a * 3) STORED) +-- +TABLE: name="gtest_err_1" schema="" table="gtest_err_1" ctx=DDL +STMT: CreateStmt +== 007 +-- references to other generated columns, including self-references +CREATE TABLE gtest_err_2a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (b * 2) STORED) +-- +TABLE: name="gtest_err_2a" schema="" table="gtest_err_2a" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE gtest_err_2b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED, c int GENERATED ALWAYS AS (b * 3) STORED) +-- +TABLE: name="gtest_err_2b" schema="" table="gtest_err_2b" ctx=DDL +STMT: CreateStmt +== 009 +-- a whole-row var is a self-reference on steroids, so disallow that too +CREATE TABLE gtest_err_2c (a int PRIMARY KEY, + b int GENERATED ALWAYS AS (num_nulls(gtest_err_2c)) STORED) +-- +TABLE: name="gtest_err_2c" schema="" table="gtest_err_2c" ctx=DDL +STMT: CreateStmt +== 010 +-- invalid reference +CREATE TABLE gtest_err_3 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (c * 2) STORED) +-- +TABLE: name="gtest_err_3" schema="" table="gtest_err_3" ctx=DDL +STMT: CreateStmt +== 011 +-- generation expression must be immutable +CREATE TABLE gtest_err_4 (a int PRIMARY KEY, b double precision GENERATED ALWAYS AS (random()) STORED) +-- +TABLE: name="gtest_err_4" schema="" table="gtest_err_4" ctx=DDL +STMT: CreateStmt +== 012 +-- ... but be sure that the immutability test is accurate +CREATE TABLE gtest2 (a int, b text GENERATED ALWAYS AS (a || ' sec') STORED) +-- +TABLE: name="gtest2" schema="" table="gtest2" ctx=DDL +STMT: CreateStmt +== 013 +DROP TABLE gtest2 +-- +TABLE: name="gtest2" schema="" table="gtest2" ctx=DDL +STMT: DropStmt +== 014 +-- cannot have default/identity and generated +CREATE TABLE gtest_err_5a (a int PRIMARY KEY, b int DEFAULT 5 GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtest_err_5a" schema="" table="gtest_err_5a" ctx=DDL +STMT: CreateStmt +== 015 +CREATE TABLE gtest_err_5b (a int PRIMARY KEY, b int GENERATED ALWAYS AS identity GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtest_err_5b" schema="" table="gtest_err_5b" ctx=DDL +STMT: CreateStmt +== 016 +-- reference to system column not allowed in generated column +-- (except tableoid, which we test below) +CREATE TABLE gtest_err_6a (a int PRIMARY KEY, b bool GENERATED ALWAYS AS (xmin <> 37) STORED) +-- +TABLE: name="gtest_err_6a" schema="" table="gtest_err_6a" ctx=DDL +STMT: CreateStmt +== 017 +-- various prohibited constructs +CREATE TABLE gtest_err_7a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (avg(a)) STORED) +-- +TABLE: name="gtest_err_7a" schema="" table="gtest_err_7a" ctx=DDL +STMT: CreateStmt +== 018 +CREATE TABLE gtest_err_7b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (row_number() OVER (ORDER BY a)) STORED) +-- +TABLE: name="gtest_err_7b" schema="" table="gtest_err_7b" ctx=DDL +STMT: CreateStmt +== 019 +CREATE TABLE gtest_err_7c (a int PRIMARY KEY, b int GENERATED ALWAYS AS ((SELECT a)) STORED) +-- +TABLE: name="gtest_err_7c" schema="" table="gtest_err_7c" ctx=DDL +STMT: CreateStmt +== 020 +CREATE TABLE gtest_err_7d (a int PRIMARY KEY, b int GENERATED ALWAYS AS (generate_series(1, a)) STORED) +-- +TABLE: name="gtest_err_7d" schema="" table="gtest_err_7d" ctx=DDL +STMT: CreateStmt +== 021 +-- GENERATED BY DEFAULT not allowed +CREATE TABLE gtest_err_8 (a int PRIMARY KEY, b int GENERATED BY DEFAULT AS (a * 2) STORED) +-- +ERROR: for a generated column, GENERATED ALWAYS must be specified +CURSORPOS: 98 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 022 +INSERT INTO gtest1 VALUES (1) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO gtest1 VALUES (2, DEFAULT) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +-- ok +INSERT INTO gtest1 VALUES (3, 33) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +-- error +INSERT INTO gtest1 VALUES (3, 33), (4, 44) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +-- error +INSERT INTO gtest1 VALUES (3, DEFAULT), (4, 44) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +-- error +INSERT INTO gtest1 VALUES (3, 33), (4, DEFAULT) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +-- error +INSERT INTO gtest1 VALUES (3, DEFAULT), (4, DEFAULT) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +-- ok + +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +== 030 +DELETE FROM gtest1 WHERE a >= 3 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: DeleteStmt +== 031 +UPDATE gtest1 SET b = DEFAULT WHERE a = 1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: UpdateStmt +== 032 +UPDATE gtest1 SET b = 11 WHERE a = 1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: UpdateStmt +== 033 +-- error + +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +== 034 +SELECT a, b, b * 2 AS b2 FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +== 035 +SELECT a, b FROM gtest1 WHERE b = 4 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 036 +-- test that overflow error happens on write +INSERT INTO gtest1 VALUES (2000000000) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +SELECT * FROM gtest1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +== 038 +DELETE FROM gtest1 WHERE a = 2000000000 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: DeleteStmt +== 039 +-- test with joins +CREATE TABLE gtestx (x int, y int) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: CreateStmt +== 040 +INSERT INTO gtestx VALUES (11, 1), (22, 2), (33, 3) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +SELECT * FROM gtestx, gtest1 WHERE gtestx.y = gtest1.a +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=Select +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +FILTER: schema="" table="gtestx" column="y" +FILTER: schema="" table="gtest1" column="a" +STMT: SelectStmt +== 042 +DROP TABLE gtestx +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: DropStmt +== 043 +-- test UPDATE/DELETE quals +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +== 044 +UPDATE gtest1 SET a = 3 WHERE b = 4 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: UpdateStmt +== 045 +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +== 046 +DELETE FROM gtest1 WHERE b = 2 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: DeleteStmt +== 047 +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +== 048 +-- test MERGE +CREATE TABLE gtestm ( + id int PRIMARY KEY, + f1 int, + f2 int, + f3 int GENERATED ALWAYS AS (f1 * 2) STORED, + f4 int GENERATED ALWAYS AS (f2 * 2) STORED +) +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=DDL +STMT: CreateStmt +== 049 +INSERT INTO gtestm VALUES (1, 5, 100) +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +MERGE INTO gtestm t USING (VALUES (1, 10), (2, 20)) v(id, f1) ON t.id = v.id + WHEN MATCHED THEN UPDATE SET f1 = v.f1 + WHEN NOT MATCHED THEN INSERT VALUES (v.id, v.f1, 200) +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=DML +ALIAS: "t"="gtestm" +STMT: MergeStmt +STMT: SelectStmt +== 051 +SELECT * FROM gtestm ORDER BY id +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=Select +STMT: SelectStmt +== 052 +DROP TABLE gtestm +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=DDL +STMT: DropStmt +== 053 +-- views +CREATE VIEW gtest1v AS SELECT * FROM gtest1 +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DDL +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 054 +SELECT * FROM gtest1v +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=Select +STMT: SelectStmt +== 055 +INSERT INTO gtest1v VALUES (4, 8) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +-- error +INSERT INTO gtest1v VALUES (5, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +-- ok +INSERT INTO gtest1v VALUES (6, 66), (7, 77) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +-- error +INSERT INTO gtest1v VALUES (6, DEFAULT), (7, 77) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +-- error +INSERT INTO gtest1v VALUES (6, 66), (7, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +-- error +INSERT INTO gtest1v VALUES (6, DEFAULT), (7, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +-- ok + +ALTER VIEW gtest1v ALTER COLUMN b SET DEFAULT 100 +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DDL +STMT: AlterTableStmt +== 062 +INSERT INTO gtest1v VALUES (8, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +-- error +INSERT INTO gtest1v VALUES (8, DEFAULT), (9, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +-- error + +SELECT * FROM gtest1v +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=Select +STMT: SelectStmt +== 065 +DELETE FROM gtest1v WHERE a >= 5 +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: DeleteStmt +== 066 +DROP VIEW gtest1v +-- +STMT: DropStmt +== 067 +-- CTEs +WITH foo AS (SELECT * FROM gtest1) SELECT * FROM foo +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +CTE: "foo" +STMT: SelectStmt +== 068 +-- inheritance +CREATE TABLE gtest1_1 () INHERITS (gtest1) +-- +TABLE: name="gtest1_1" schema="" table="gtest1_1" ctx=DDL +STMT: CreateStmt +== 069 +SELECT * FROM gtest1_1 +-- +TABLE: name="gtest1_1" schema="" table="gtest1_1" ctx=Select +STMT: SelectStmt +== 070 +INSERT INTO gtest1_1 VALUES (4) +-- +TABLE: name="gtest1_1" schema="" table="gtest1_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +SELECT * FROM gtest1_1 +-- +TABLE: name="gtest1_1" schema="" table="gtest1_1" ctx=Select +STMT: SelectStmt +== 072 +SELECT * FROM gtest1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +== 073 +-- can't have generated column that is a child of normal column +CREATE TABLE gtest_normal (a int, b int) +-- +TABLE: name="gtest_normal" schema="" table="gtest_normal" ctx=DDL +STMT: CreateStmt +== 074 +CREATE TABLE gtest_normal_child (a int, b int GENERATED ALWAYS AS (a * 2) STORED) INHERITS (gtest_normal) +-- +TABLE: name="gtest_normal_child" schema="" table="gtest_normal_child" ctx=DDL +STMT: CreateStmt +== 075 +-- error +CREATE TABLE gtest_normal_child (a int, b int GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtest_normal_child" schema="" table="gtest_normal_child" ctx=DDL +STMT: CreateStmt +== 076 +ALTER TABLE gtest_normal_child INHERIT gtest_normal +-- +TABLE: name="gtest_normal_child" schema="" table="gtest_normal_child" ctx=DDL +STMT: AlterTableStmt +== 077 +-- error +DROP TABLE gtest_normal, gtest_normal_child +-- +TABLE: name="gtest_normal" schema="" table="gtest_normal" ctx=DDL +TABLE: name="gtest_normal_child" schema="" table="gtest_normal_child" ctx=DDL +STMT: DropStmt +== 078 +-- test inheritance mismatches between parent and child +CREATE TABLE gtestx (x int, b int DEFAULT 10) INHERITS (gtest1) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: CreateStmt +== 079 +-- error +CREATE TABLE gtestx (x int, b int GENERATED ALWAYS AS IDENTITY) INHERITS (gtest1) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: CreateStmt +== 080 +-- error +CREATE TABLE gtestx (x int, b int GENERATED ALWAYS AS (a * 22) STORED) INHERITS (gtest1) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: CreateStmt +== 081 +-- ok, overrides parent + +CREATE TABLE gtestxx_1 (a int NOT NULL, b int) +-- +TABLE: name="gtestxx_1" schema="" table="gtestxx_1" ctx=DDL +STMT: CreateStmt +== 082 +ALTER TABLE gtestxx_1 INHERIT gtest1 +-- +TABLE: name="gtestxx_1" schema="" table="gtestxx_1" ctx=DDL +STMT: AlterTableStmt +== 083 +-- error +CREATE TABLE gtestxx_3 (a int NOT NULL, b int GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtestxx_3" schema="" table="gtestxx_3" ctx=DDL +STMT: CreateStmt +== 084 +ALTER TABLE gtestxx_3 INHERIT gtest1 +-- +TABLE: name="gtestxx_3" schema="" table="gtestxx_3" ctx=DDL +STMT: AlterTableStmt +== 085 +-- ok +CREATE TABLE gtestxx_4 (b int GENERATED ALWAYS AS (a * 2) STORED, a int NOT NULL) +-- +TABLE: name="gtestxx_4" schema="" table="gtestxx_4" ctx=DDL +STMT: CreateStmt +== 086 +ALTER TABLE gtestxx_4 INHERIT gtest1 +-- +TABLE: name="gtestxx_4" schema="" table="gtestxx_4" ctx=DDL +STMT: AlterTableStmt +== 087 +-- ok + +-- test multiple inheritance mismatches +CREATE TABLE gtesty (x int, b int DEFAULT 55) +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: CreateStmt +== 088 +CREATE TABLE gtest1_y () INHERITS (gtest0, gtesty) +-- +TABLE: name="gtest1_y" schema="" table="gtest1_y" ctx=DDL +STMT: CreateStmt +== 089 +-- error +DROP TABLE gtesty +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: DropStmt +== 090 +CREATE TABLE gtesty (x int, b int) +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: CreateStmt +== 091 +CREATE TABLE gtest1_y () INHERITS (gtest1, gtesty) +-- +TABLE: name="gtest1_y" schema="" table="gtest1_y" ctx=DDL +STMT: CreateStmt +== 092 +-- error +DROP TABLE gtesty +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: DropStmt +== 093 +CREATE TABLE gtesty (x int, b int GENERATED ALWAYS AS (x * 22) STORED) +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: CreateStmt +== 094 +CREATE TABLE gtest1_y () INHERITS (gtest1, gtesty) +-- +TABLE: name="gtest1_y" schema="" table="gtest1_y" ctx=DDL +STMT: CreateStmt +== 095 +-- error +CREATE TABLE gtest1_y (b int GENERATED ALWAYS AS (x + 1) STORED) INHERITS (gtest1, gtesty) +-- +TABLE: name="gtest1_y" schema="" table="gtest1_y" ctx=DDL +STMT: CreateStmt +== 096 +-- ok + +-- test correct handling of GENERATED column that's only in child +CREATE TABLE gtestp (f1 int) +-- +TABLE: name="gtestp" schema="" table="gtestp" ctx=DDL +STMT: CreateStmt +== 097 +CREATE TABLE gtestc (f2 int GENERATED ALWAYS AS (f1+1) STORED) INHERITS(gtestp) +-- +TABLE: name="gtestc" schema="" table="gtestc" ctx=DDL +STMT: CreateStmt +== 098 +INSERT INTO gtestc values(42) +-- +TABLE: name="gtestc" schema="" table="gtestc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 099 +TABLE gtestc +-- +TABLE: name="gtestc" schema="" table="gtestc" ctx=Select +STMT: SelectStmt +== 100 +UPDATE gtestp SET f1 = f1 * 10 +-- +TABLE: name="gtestp" schema="" table="gtestp" ctx=DML +STMT: UpdateStmt +== 101 +TABLE gtestc +-- +TABLE: name="gtestc" schema="" table="gtestc" ctx=Select +STMT: SelectStmt +== 102 +DROP TABLE gtestp CASCADE +-- +TABLE: name="gtestp" schema="" table="gtestp" ctx=DDL +STMT: DropStmt +== 103 +-- test stored update +CREATE TABLE gtest3 (a int, b int GENERATED ALWAYS AS (a * 3) STORED) +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=DDL +STMT: CreateStmt +== 104 +INSERT INTO gtest3 (a) VALUES (1), (2), (3), (NULL) +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +SELECT * FROM gtest3 ORDER BY a +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=Select +STMT: SelectStmt +== 106 +UPDATE gtest3 SET a = 22 WHERE a = 2 +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=DML +STMT: UpdateStmt +== 107 +SELECT * FROM gtest3 ORDER BY a +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=Select +STMT: SelectStmt +== 108 +CREATE TABLE gtest3a (a text, b text GENERATED ALWAYS AS (a || '+' || a) STORED) +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=DDL +STMT: CreateStmt +== 109 +INSERT INTO gtest3a (a) VALUES ('a'), ('b'), ('c'), (NULL) +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +SELECT * FROM gtest3a ORDER BY a +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=Select +STMT: SelectStmt +== 111 +UPDATE gtest3a SET a = 'bb' WHERE a = 'b' +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=DML +STMT: UpdateStmt +== 112 +SELECT * FROM gtest3a ORDER BY a +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=Select +STMT: SelectStmt +== 113 +-- COPY +TRUNCATE gtest1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DDL +STMT: TruncateStmt +== 114 +INSERT INTO gtest1 (a) VALUES (1), (2) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +COPY gtest1 TO stdout +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: CopyStmt +== 116 +COPY gtest1 (a, b) TO stdout +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: CopyStmt +== 117 +COPY gtest1 FROM stdin +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: CopyStmt +== 118 +COPY gtest1 (a, b) FROM stdin +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: CopyStmt +== 119 +COPY gtest3 (a, b) FROM stdin +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=Select +STMT: CopyStmt diff --git a/parser/testdata/summary/postgres_regress/geometry.metadata.json b/parser/testdata/summary/postgres_regress/geometry.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/geometry.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/geometry.test b/parser/testdata/summary/postgres_regress/geometry.test new file mode 100644 index 0000000..0535464 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/geometry.test @@ -0,0 +1,1570 @@ +== 001 +|-- +-- GEOMETRY +|-- + +-- Back off displayed precision a little bit to reduce platform-to-platform +-- variation in results. +SET extra_float_digits TO -3 +-- +STMT: VariableSetStmt +== 002 +|-- +-- Points +|-- + +SELECT center(f1) AS center + FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="center" function="center" schema="" ctx=Call +STMT: SelectStmt +== 003 +SELECT (@@ f1) AS center + FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +STMT: SelectStmt +== 004 +SELECT point(f1) AS center + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT (@@ f1) AS center + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +STMT: SelectStmt +== 006 +SELECT (@@ f1) AS center + FROM POLYGON_TBL + WHERE (# f1) > 2 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 007 +-- "is horizontal" function +SELECT p1.f1 + FROM POINT_TBL p1 + WHERE ishorizontal(p1.f1, point '(0,0)') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +FUNCTION: name="ishorizontal" function="ishorizontal" schema="" ctx=Call +FUNCTION: name="ishorizontal" function="ishorizontal" schema="" ctx=Call +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 008 +-- "is horizontal" operator +SELECT p1.f1 + FROM POINT_TBL p1 + WHERE p1.f1 ?- point '(0,0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 009 +-- "is vertical" function +SELECT p1.f1 + FROM POINT_TBL p1 + WHERE isvertical(p1.f1, point '(5.1,34.5)') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +FUNCTION: name="isvertical" function="isvertical" schema="" ctx=Call +FUNCTION: name="isvertical" function="isvertical" schema="" ctx=Call +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 010 +-- "is vertical" operator +SELECT p1.f1 + FROM POINT_TBL p1 + WHERE p1.f1 ?| point '(5.1,34.5)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 011 +-- Slope +SELECT p1.f1, p2.f1, slope(p1.f1, p2.f1) FROM POINT_TBL p1, POINT_TBL p2 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FUNCTION: name="slope" function="slope" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- Add point +SELECT p1.f1, p2.f1, p1.f1 + p2.f1 FROM POINT_TBL p1, POINT_TBL p2 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +STMT: SelectStmt +== 013 +-- Subtract point +SELECT p1.f1, p2.f1, p1.f1 - p2.f1 FROM POINT_TBL p1, POINT_TBL p2 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +STMT: SelectStmt +== 014 +-- Multiply with point +SELECT p1.f1, p2.f1, p1.f1 * p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p1.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 015 +-- Underflow error +SELECT p1.f1, p2.f1, p1.f1 * p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p1.f1[0] < 1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 016 +-- Divide by point +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 017 +-- Overflow error +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1[0] > 1000 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 018 +-- Division by 0 error +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1 ~= '(0,0)'::point +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 019 +-- Distance to line +SELECT p.f1, l.s, p.f1 <-> l.s AS dist_pl, l.s <-> p.f1 AS dist_lp FROM POINT_TBL p, LINE_TBL l +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="line_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 020 +-- Distance to line segment +SELECT p.f1, l.s, p.f1 <-> l.s AS dist_ps, l.s <-> p.f1 AS dist_sp FROM POINT_TBL p, LSEG_TBL l +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 021 +-- Distance to box +SELECT p.f1, b.f1, p.f1 <-> b.f1 AS dist_pb, b.f1 <-> p.f1 AS dist_bp FROM POINT_TBL p, BOX_TBL b +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 022 +-- Distance to path +SELECT p.f1, p1.f1, p.f1 <-> p1.f1 AS dist_ppath, p1.f1 <-> p.f1 AS dist_pathp FROM POINT_TBL p, PATH_TBL p1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "p1"="path_tbl" +STMT: SelectStmt +== 023 +-- Distance to polygon +SELECT p.f1, p1.f1, p.f1 <-> p1.f1 AS dist_ppoly, p1.f1 <-> p.f1 AS dist_polyp FROM POINT_TBL p, POLYGON_TBL p1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "p1"="polygon_tbl" +STMT: SelectStmt +== 024 +-- Construct line through two points +SELECT p1.f1, p2.f1, line(p1.f1, p2.f1) + FROM POINT_TBL p1, POINT_TBL p2 WHERE p1.f1 <> p2.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FUNCTION: name="line" function="line" schema="" ctx=Call +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 025 +-- Closest point to line +SELECT p.f1, l.s, p.f1 ## l.s FROM POINT_TBL p, LINE_TBL l +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="line_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 026 +-- Closest point to line segment +SELECT p.f1, l.s, p.f1 ## l.s FROM POINT_TBL p, LSEG_TBL l +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 027 +-- Closest point to box +SELECT p.f1, b.f1, p.f1 ## b.f1 FROM POINT_TBL p, BOX_TBL b +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 028 +-- On line +SELECT p.f1, l.s FROM POINT_TBL p, LINE_TBL l WHERE p.f1 <@ l.s +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="line_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +FILTER: schema="" table="l" column="s" +STMT: SelectStmt +== 029 +-- On line segment +SELECT p.f1, l.s FROM POINT_TBL p, LSEG_TBL l WHERE p.f1 <@ l.s +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +FILTER: schema="" table="l" column="s" +STMT: SelectStmt +== 030 +-- On path +SELECT p.f1, p1.f1 FROM POINT_TBL p, PATH_TBL p1 WHERE p.f1 <@ p1.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "p1"="path_tbl" +FILTER: schema="" table="p" column="f1" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 031 +|-- +-- Lines +|-- + +-- Vertical +SELECT s FROM LINE_TBL WHERE ?| s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +FILTER: schema="" table="" column="s" +STMT: SelectStmt +== 032 +-- Horizontal +SELECT s FROM LINE_TBL WHERE ?- s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +FILTER: schema="" table="" column="s" +STMT: SelectStmt +== 033 +-- Same as line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s = l2.s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 034 +-- Parallel to line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?|| l2.s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 035 +-- Perpendicular to line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?-| l2.s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 036 +-- Distance to line +SELECT l1.s, l2.s, l1.s <-> l2.s FROM LINE_TBL l1, LINE_TBL l2 +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +STMT: SelectStmt +== 037 +-- Intersect with line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?# l2.s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 038 +-- Intersect with box +SELECT l.s, b.f1 FROM LINE_TBL l, BOX_TBL b WHERE l.s ?# b.f1 +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="line_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 039 +-- Intersection point with line +SELECT l1.s, l2.s, l1.s # l2.s FROM LINE_TBL l1, LINE_TBL l2 +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +STMT: SelectStmt +== 040 +-- Closest point to line segment +SELECT l.s, l1.s, l.s ## l1.s FROM LINE_TBL l, LSEG_TBL l1 +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l"="line_tbl" +ALIAS: "l1"="lseg_tbl" +STMT: SelectStmt +== 041 +|-- +-- Line segments +|-- + +-- intersection +SELECT p.f1, l.s, l.s # p.f1 AS intersection + FROM LSEG_TBL l, POINT_TBL p +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 042 +-- Length +SELECT s, @-@ s FROM LSEG_TBL +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +STMT: SelectStmt +== 043 +-- Vertical +SELECT s FROM LSEG_TBL WHERE ?| s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +FILTER: schema="" table="" column="s" +STMT: SelectStmt +== 044 +-- Horizontal +SELECT s FROM LSEG_TBL WHERE ?- s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +FILTER: schema="" table="" column="s" +STMT: SelectStmt +== 045 +-- Center +SELECT s, @@ s FROM LSEG_TBL +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +STMT: SelectStmt +== 046 +-- To point +SELECT s, s::point FROM LSEG_TBL +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +STMT: SelectStmt +== 047 +-- Has points less than line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s < l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 048 +-- Has points less than or equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s <= l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 049 +-- Has points equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s = l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 050 +-- Has points greater than or equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s >= l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 051 +-- Has points greater than line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s > l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 052 +-- Has points not equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s != l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 053 +-- Parallel with line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s ?|| l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 054 +-- Perpendicular with line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s ?-| l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +== 055 +-- Distance to line +SELECT l.s, l1.s, l.s <-> l1.s AS dist_sl, l1.s <-> l.s AS dist_ls FROM LSEG_TBL l, LINE_TBL l1 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "l1"="line_tbl" +STMT: SelectStmt +== 056 +-- Distance to line segment +SELECT l1.s, l2.s, l1.s <-> l2.s FROM LSEG_TBL l1, LSEG_TBL l2 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +STMT: SelectStmt +== 057 +-- Distance to box +SELECT l.s, b.f1, l.s <-> b.f1 AS dist_sb, b.f1 <-> l.s AS dist_bs FROM LSEG_TBL l, BOX_TBL b +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="lseg_tbl" +STMT: SelectStmt +== 058 +-- Intersect with line segment +SELECT l.s, l1.s FROM LSEG_TBL l, LINE_TBL l1 WHERE l.s ?# l1.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "l1"="line_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="l1" column="s" +STMT: SelectStmt +== 059 +-- Intersect with box +SELECT l.s, b.f1 FROM LSEG_TBL l, BOX_TBL b WHERE l.s ?# b.f1 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="lseg_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 060 +-- Intersection point with line segment +SELECT l1.s, l2.s, l1.s # l2.s FROM LSEG_TBL l1, LSEG_TBL l2 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +STMT: SelectStmt +== 061 +-- Closest point to line segment +SELECT l1.s, l2.s, l1.s ## l2.s FROM LSEG_TBL l1, LSEG_TBL l2 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +STMT: SelectStmt +== 062 +-- Closest point to box +SELECT l.s, b.f1, l.s ## b.f1 FROM LSEG_TBL l, BOX_TBL b +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="lseg_tbl" +STMT: SelectStmt +== 063 +-- On line +SELECT l.s, l1.s FROM LSEG_TBL l, LINE_TBL l1 WHERE l.s <@ l1.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "l1"="line_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="l1" column="s" +STMT: SelectStmt +== 064 +-- On box +SELECT l.s, b.f1 FROM LSEG_TBL l, BOX_TBL b WHERE l.s <@ b.f1 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="lseg_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +== 065 +|-- +-- Boxes +|-- + +SELECT box(f1) AS box FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +STMT: SelectStmt +== 066 +-- translation +SELECT b.f1 + p.f1 AS translation + FROM BOX_TBL b, POINT_TBL p +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 067 +SELECT b.f1 - p.f1 AS translation + FROM BOX_TBL b, POINT_TBL p +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 068 +-- Multiply with point +SELECT b.f1, p.f1, b.f1 * p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 069 +-- Overflow error +SELECT b.f1, p.f1, b.f1 * p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] > 1000 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 070 +-- Divide by point +SELECT b.f1, p.f1, b.f1 / p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 071 +-- To box +SELECT f1::box + FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +== 072 +SELECT bound_box(a.f1, b.f1) + FROM BOX_TBL a, BOX_TBL b +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "a"="box_tbl" +ALIAS: "b"="box_tbl" +FUNCTION: name="bound_box" function="bound_box" schema="" ctx=Call +STMT: SelectStmt +== 073 +-- Below box +SELECT b1.f1, b2.f1, b1.f1 <^ b2.f1 FROM BOX_TBL b1, BOX_TBL b2 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +STMT: SelectStmt +== 074 +-- Above box +SELECT b1.f1, b2.f1, b1.f1 >^ b2.f1 FROM BOX_TBL b1, BOX_TBL b2 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +STMT: SelectStmt +== 075 +-- Intersection point with box +SELECT b1.f1, b2.f1, b1.f1 # b2.f1 FROM BOX_TBL b1, BOX_TBL b2 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +STMT: SelectStmt +== 076 +-- Diagonal +SELECT f1, diagonal(f1) FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="diagonal" function="diagonal" schema="" ctx=Call +STMT: SelectStmt +== 077 +-- Distance to box +SELECT b1.f1, b2.f1, b1.f1 <-> b2.f1 FROM BOX_TBL b1, BOX_TBL b2 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +STMT: SelectStmt +== 078 +|-- +-- Paths +|-- + +-- Points +SELECT f1, npoints(f1) FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="npoints" function="npoints" schema="" ctx=Call +STMT: SelectStmt +== 079 +-- Area +SELECT f1, area(f1) FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="area" function="area" schema="" ctx=Call +STMT: SelectStmt +== 080 +-- Length +SELECT f1, @-@ f1 FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +STMT: SelectStmt +== 081 +-- To polygon +SELECT f1, f1::polygon FROM PATH_TBL WHERE isclosed(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 082 +-- Open path cannot be converted to polygon error +SELECT f1, f1::polygon FROM PATH_TBL WHERE isopen(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 083 +-- Has points less than path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 < p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 084 +-- Has points less than or equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 <= p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 085 +-- Has points equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 = p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 086 +-- Has points greater than or equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 >= p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 087 +-- Has points greater than path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 > p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 088 +-- Add path +SELECT p1.f1, p2.f1, p1.f1 + p2.f1 FROM PATH_TBL p1, PATH_TBL p2 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +STMT: SelectStmt +== 089 +-- Add point +SELECT p.f1, p1.f1, p.f1 + p1.f1 FROM PATH_TBL p, POINT_TBL p1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +STMT: SelectStmt +== 090 +-- Subtract point +SELECT p.f1, p1.f1, p.f1 - p1.f1 FROM PATH_TBL p, POINT_TBL p1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +STMT: SelectStmt +== 091 +-- Multiply with point +SELECT p.f1, p1.f1, p.f1 * p1.f1 FROM PATH_TBL p, POINT_TBL p1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +STMT: SelectStmt +== 092 +-- Divide by point +SELECT p.f1, p1.f1, p.f1 / p1.f1 FROM PATH_TBL p, POINT_TBL p1 WHERE p1.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 093 +-- Division by 0 error +SELECT p.f1, p1.f1, p.f1 / p1.f1 FROM PATH_TBL p, POINT_TBL p1 WHERE p1.f1 ~= '(0,0)'::point +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +== 094 +-- Distance to path +SELECT p1.f1, p2.f1, p1.f1 <-> p2.f1 FROM PATH_TBL p1, PATH_TBL p2 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +STMT: SelectStmt +== 095 +|-- +-- Polygons +|-- + +-- containment +SELECT p.f1, poly.f1, poly.f1 @> p.f1 AS contains + FROM POLYGON_TBL poly, POINT_TBL p +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "poly"="polygon_tbl" +STMT: SelectStmt +== 096 +SELECT p.f1, poly.f1, p.f1 <@ poly.f1 AS contained + FROM POLYGON_TBL poly, POINT_TBL p +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "poly"="polygon_tbl" +STMT: SelectStmt +== 097 +SELECT npoints(f1) AS npoints, f1 AS polygon + FROM POLYGON_TBL +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="npoints" function="npoints" schema="" ctx=Call +STMT: SelectStmt +== 098 +SELECT polygon(f1) + FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +STMT: SelectStmt +== 099 +SELECT polygon(f1) + FROM PATH_TBL WHERE isclosed(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 100 +SELECT f1 AS open_path, polygon( pclose(f1)) AS polygon + FROM PATH_TBL + WHERE isopen(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FUNCTION: name="pclose" function="pclose" schema="" ctx=Call +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 101 +-- To box +SELECT f1, f1::box FROM POLYGON_TBL +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +STMT: SelectStmt +== 102 +-- To path +SELECT f1, f1::path FROM POLYGON_TBL +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +STMT: SelectStmt +== 103 +-- Same as polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 ~= p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 104 +-- Contained by polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 <@ p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 105 +-- Contains polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 @> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 106 +-- Overlap with polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 && p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 107 +-- Left of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 << p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 108 +-- Overlap of left of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &< p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 109 +-- Right of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 >> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 110 +-- Overlap of right of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 111 +-- Below polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 <<| p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 112 +-- Overlap or below polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &<| p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 113 +-- Above polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 |>> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 114 +-- Overlap or above polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 |&> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 115 +-- Distance to polygon +SELECT p1.f1, p2.f1, p1.f1 <-> p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +STMT: SelectStmt +== 116 +|-- +-- Circles +|-- + +SELECT circle(f1, 50.0) + FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +STMT: SelectStmt +== 117 +SELECT circle(f1) + FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +STMT: SelectStmt +== 118 +SELECT circle(f1) + FROM POLYGON_TBL + WHERE (# f1) >= 3 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 119 +SELECT c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS distance + FROM CIRCLE_TBL c1, POINT_TBL p1 + WHERE (p1.f1 <-> c1.f1) > 0 + ORDER BY distance, area(c1.f1), p1.f1[0] +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "p1"="point_tbl" +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="c1" column="f1" +STMT: SelectStmt +== 120 +-- To polygon +SELECT f1, f1::polygon FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>' +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 121 +-- To polygon with less points +SELECT f1, polygon(8, f1) FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>' +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 122 +-- Error for insufficient number of points +SELECT f1, polygon(1, f1) FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>' +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 123 +-- Zero radius error +SELECT f1, polygon(10, f1) FROM CIRCLE_TBL WHERE f1 < '<(0,0),1>' +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 124 +-- Same as circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 ~= c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 125 +-- Overlap with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 && c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 126 +-- Overlap or left of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &< c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 127 +-- Left of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 << c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 128 +-- Right of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 >> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 129 +-- Overlap or right of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 130 +-- Contained by circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <@ c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 131 +-- Contain by circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 @> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 132 +-- Below circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <<| c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 133 +-- Above circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 |>> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 134 +-- Overlap or below circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &<| c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 135 +-- Overlap or above circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 |&> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 136 +-- Area equal with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 = c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 137 +-- Area not equal with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 != c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 138 +-- Area less than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 139 +-- Area greater than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 > c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 140 +-- Area less than or equal circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <= c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 141 +-- Area greater than or equal circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 >= c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 142 +-- Area less than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 143 +-- Area greater than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +== 144 +-- Add point +SELECT c.f1, p.f1, c.f1 + p.f1 FROM CIRCLE_TBL c, POINT_TBL p +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 145 +-- Subtract point +SELECT c.f1, p.f1, c.f1 - p.f1 FROM CIRCLE_TBL c, POINT_TBL p +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 146 +-- Multiply with point +SELECT c.f1, p.f1, c.f1 * p.f1 FROM CIRCLE_TBL c, POINT_TBL p +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 147 +-- Divide by point +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 148 +-- Overflow error +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1[0] > 1000 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 149 +-- Division by 0 error +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1 ~= '(0,0)'::point +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 150 +-- Distance to polygon +SELECT c.f1, p.f1, c.f1 <-> p.f1 FROM CIRCLE_TBL c, POLYGON_TBL p +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="polygon_tbl" +STMT: SelectStmt +== 151 +-- Check index behavior for circles + +CREATE INDEX gcircleind ON circle_tbl USING gist (f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DDL +STMT: IndexStmt +== 152 +SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) + ORDER BY area(f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 153 +EXPLAIN (COSTS OFF) +SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) + ORDER BY area(f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 154 +SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) + ORDER BY area(f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 155 +-- Check index behavior for polygons + +CREATE INDEX gpolygonind ON polygon_tbl USING gist (f1) +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DDL +STMT: IndexStmt +== 156 +SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon + ORDER BY (poly_center(f1))[0] +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="poly_center" function="poly_center" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 157 +EXPLAIN (COSTS OFF) +SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon + ORDER BY (poly_center(f1))[0] +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="poly_center" function="poly_center" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 158 +SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon + ORDER BY (poly_center(f1))[0] +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="poly_center" function="poly_center" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 159 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('(1', 'circle') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 160 +SELECT * FROM pg_input_error_info('1,', 'circle') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 161 +SELECT pg_input_is_valid('(1,2),-1', 'circle') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 162 +SELECT * FROM pg_input_error_info('(1,2),-1', 'circle') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/gin.metadata.json b/parser/testdata/summary/postgres_regress/gin.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/gin.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/gin.test b/parser/testdata/summary/postgres_regress/gin.test new file mode 100644 index 0000000..f2ecfca --- /dev/null +++ b/parser/testdata/summary/postgres_regress/gin.test @@ -0,0 +1,438 @@ +== 001 +|-- +-- Test GIN indexes. +|-- +-- There are other tests to test different GIN opclasses. This is for testing +-- GIN itself. + +-- Create and populate a test table with a GIN index. +create table gin_test_tbl(i int4[]) with (autovacuum_enabled = off) +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: CreateStmt +== 002 +create index gin_test_idx on gin_test_tbl using gin (i) + with (fastupdate = on, gin_pending_list_limit = 4096) +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: IndexStmt +== 003 +insert into gin_test_tbl select array[1, 2, g] from generate_series(1, 20000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 004 +insert into gin_test_tbl select array[1, 3, g] from generate_series(1, 1000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 005 +select gin_clean_pending_list('gin_test_idx')>10 as many +-- +FUNCTION: name="gin_clean_pending_list" function="gin_clean_pending_list" schema="" ctx=Call +STMT: SelectStmt +== 006 +-- flush the fastupdate buffers + +insert into gin_test_tbl select array[3, 1, g] from generate_series(1, 1000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 007 +vacuum gin_test_tbl +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: VacuumStmt +== 008 +-- flush the fastupdate buffers + +select gin_clean_pending_list('gin_test_idx') +-- +FUNCTION: name="gin_clean_pending_list" function="gin_clean_pending_list" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- nothing to flush + +-- Test vacuuming +delete from gin_test_tbl where i @> array[2] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +STMT: DeleteStmt +== 010 +vacuum gin_test_tbl +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: VacuumStmt +== 011 +-- Disable fastupdate, and do more insertions. With fastupdate enabled, most +-- insertions (by flushing the list pages) cause page splits. Without +-- fastupdate, we get more churn in the GIN data leaf pages, and exercise the +-- recompression codepaths. +alter index gin_test_idx set (fastupdate = off) +-- +STMT: AlterTableStmt +== 012 +insert into gin_test_tbl select array[1, 2, g] from generate_series(1, 1000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 013 +insert into gin_test_tbl select array[1, 3, g] from generate_series(1, 1000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 014 +delete from gin_test_tbl where i @> array[2] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +STMT: DeleteStmt +== 015 +vacuum gin_test_tbl +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: VacuumStmt +== 016 +-- Test for "rare && frequent" searches +explain (costs off) +select count(*) from gin_test_tbl where i @> array[1, 999] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 017 +select count(*) from gin_test_tbl where i @> array[1, 999] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 018 +-- Very weak test for gin_fuzzy_search_limit +set gin_fuzzy_search_limit = 1000 +-- +STMT: VariableSetStmt +== 019 +explain (costs off) +select count(*) > 0 as ok from gin_test_tbl where i @> array[1] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 020 +select count(*) > 0 as ok from gin_test_tbl where i @> array[1] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 021 +reset gin_fuzzy_search_limit +-- +STMT: VariableSetStmt +== 022 +-- Test optimization of empty queries +create temp table t_gin_test_tbl(i int4[], j int4[]) +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: CreateStmt +== 023 +create index on t_gin_test_tbl using gin (i, j) +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: IndexStmt +== 024 +insert into t_gin_test_tbl +values + (null, null), + ('{}', null), + ('{1}', null), + ('{1,2}', null), + (null, '{}'), + (null, '{10}'), + ('{1,2}', '{10}'), + ('{2}', '{10}'), + ('{1,3}', '{}'), + ('{1,1}', '{10}') +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 026 +explain (costs off) +select * from t_gin_test_tbl where array[0] <@ i +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 027 +select * from t_gin_test_tbl where array[0] <@ i +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 028 +select * from t_gin_test_tbl where array[0] <@ i and '{}'::int4[] <@ j +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 029 +explain (costs off) +select * from t_gin_test_tbl where i @> '{}' +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 030 +select * from t_gin_test_tbl where i @> '{}' +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 031 +create function explain_query_json(query_sql text) +returns table (explain_line json) +language plpgsql as +$$ +begin + set enable_seqscan = off; + set enable_bitmapscan = on; + return query execute 'EXPLAIN (ANALYZE, FORMAT json) ' || query_sql; +end; +$$ +-- +FUNCTION: name="explain_query_json" function="explain_query_json" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 032 +create function execute_text_query_index(query_sql text) +returns setof text +language plpgsql +as +$$ +begin + set enable_seqscan = off; + set enable_bitmapscan = on; + return query execute query_sql; +end; +$$ +-- +FUNCTION: name="execute_text_query_index" function="execute_text_query_index" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 033 +create function execute_text_query_heap(query_sql text) +returns setof text +language plpgsql +as +$$ +begin + set enable_seqscan = on; + set enable_bitmapscan = off; + return query execute query_sql; +end; +$$ +-- +FUNCTION: name="execute_text_query_heap" function="execute_text_query_heap" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 034 +-- check number of rows returned by index and removed by recheck +select + query, + js->0->'Plan'->'Plans'->0->'Actual Rows' as "return by index", + js->0->'Plan'->'Rows Removed by Index Recheck' as "removed by recheck", + (res_index = res_heap) as "match" +from + (values + ($$ i @> '{}' $$), + ($$ j @> '{}' $$), + ($$ i @> '{}' and j @> '{}' $$), + ($$ i @> '{1}' $$), + ($$ i @> '{1}' and j @> '{}' $$), + ($$ i @> '{1}' and i @> '{}' and j @> '{}' $$), + ($$ j @> '{10}' $$), + ($$ j @> '{10}' and i @> '{}' $$), + ($$ j @> '{10}' and j @> '{}' and i @> '{}' $$), + ($$ i @> '{1}' and j @> '{10}' $$) + ) q(query), + lateral explain_query_json($$select * from t_gin_test_tbl where $$ || query) js, + lateral execute_text_query_index($$select string_agg((i, j)::text, ' ') from t_gin_test_tbl where $$ || query) res_index, + lateral execute_text_query_heap($$select string_agg((i, j)::text, ' ') from t_gin_test_tbl where $$ || query) res_heap +-- +FUNCTION: name="explain_query_json" function="explain_query_json" schema="" ctx=Call +FUNCTION: name="execute_text_query_index" function="execute_text_query_index" schema="" ctx=Call +FUNCTION: name="execute_text_query_heap" function="execute_text_query_heap" schema="" ctx=Call +STMT: SelectStmt +== 035 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 036 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 037 +-- re-purpose t_gin_test_tbl to test scans involving posting trees +insert into t_gin_test_tbl select array[1, g, g/10], array[2, g, g/10] + from generate_series(1, 20000) g +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 038 +select gin_clean_pending_list('t_gin_test_tbl_i_j_idx') is not null +-- +FUNCTION: name="gin_clean_pending_list" function="gin_clean_pending_list" schema="" ctx=Call +STMT: SelectStmt +== 039 +analyze t_gin_test_tbl +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: VacuumStmt +== 040 +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 041 +set enable_bitmapscan = on +-- +STMT: VariableSetStmt +== 042 +explain (costs off) +select count(*) from t_gin_test_tbl where j @> array[50] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +== 043 +select count(*) from t_gin_test_tbl where j @> array[50] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 044 +explain (costs off) +select count(*) from t_gin_test_tbl where j @> array[2] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +== 045 +select count(*) from t_gin_test_tbl where j @> array[2] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 046 +explain (costs off) +select count(*) from t_gin_test_tbl where j @> '{}'::int[] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +== 047 +select count(*) from t_gin_test_tbl where j @> '{}'::int[] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 048 +-- test vacuuming of posting trees +delete from t_gin_test_tbl where j @> array[2] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DML +STMT: DeleteStmt +== 049 +vacuum t_gin_test_tbl +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: VacuumStmt +== 050 +select count(*) from t_gin_test_tbl where j @> array[50] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 051 +select count(*) from t_gin_test_tbl where j @> array[2] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 052 +select count(*) from t_gin_test_tbl where j @> '{}'::int[] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 053 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 054 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 055 +drop table t_gin_test_tbl +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: DropStmt +== 056 +-- test an unlogged table, mostly to get coverage of ginbuildempty +create unlogged table t_gin_test_tbl(i int4[], j int4[]) +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: CreateStmt +== 057 +create index on t_gin_test_tbl using gin (i, j) +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: IndexStmt +== 058 +insert into t_gin_test_tbl +values + (null, null), + ('{}', null), + ('{1}', '{2,3}') +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +drop table t_gin_test_tbl +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/gist.metadata.json b/parser/testdata/summary/postgres_regress/gist.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/gist.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/gist.test b/parser/testdata/summary/postgres_regress/gist.test new file mode 100644 index 0000000..6d1c097 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/gist.test @@ -0,0 +1,584 @@ +== 001 +|-- +-- Test GiST indexes. +|-- +-- There are other tests to test different GiST opclasses. This is for +-- testing GiST code itself. Vacuuming in particular. + +create table gist_point_tbl(id int4, p point) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: CreateStmt +== 002 +create index gist_pointidx on gist_point_tbl using gist(p) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +== 003 +-- Verify the fillfactor and buffering options +create index gist_pointidx2 on gist_point_tbl using gist(p) with (buffering = on, fillfactor=50) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +== 004 +create index gist_pointidx3 on gist_point_tbl using gist(p) with (buffering = off) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +== 005 +create index gist_pointidx4 on gist_point_tbl using gist(p) with (buffering = auto) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +== 006 +drop index gist_pointidx2, gist_pointidx3, gist_pointidx4 +-- +STMT: DropStmt +== 007 +-- Make sure bad values are refused +create index gist_pointidx5 on gist_point_tbl using gist(p) with (buffering = invalid_value) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +== 008 +create index gist_pointidx5 on gist_point_tbl using gist(p) with (fillfactor=9) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +== 009 +create index gist_pointidx5 on gist_point_tbl using gist(p) with (fillfactor=101) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +== 010 +-- Insert enough data to create a tree that's a couple of levels deep. +insert into gist_point_tbl (id, p) +select g, point(g*10, g*10) from generate_series(1, 10000) g +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 011 +insert into gist_point_tbl (id, p) +select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 012 +-- To test vacuum, delete some entries from all over the index. +delete from gist_point_tbl where id % 2 = 1 +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DML +STMT: DeleteStmt +== 013 +-- And also delete some concentration of values. +delete from gist_point_tbl where id > 5000 +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DML +STMT: DeleteStmt +== 014 +vacuum analyze gist_point_tbl +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: VacuumStmt +== 015 +-- rebuild the index with a different fillfactor +alter index gist_pointidx SET (fillfactor = 40) +-- +STMT: AlterTableStmt +== 016 +reindex index gist_pointidx +-- +STMT: ReindexStmt +== 017 +|-- +-- Test Index-only plans on GiST indexes +|-- + +create table gist_tbl (b box, p point, c circle) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: CreateStmt +== 018 +insert into gist_tbl +select box(point(0.05*i, 0.05*i), point(0.05*i, 0.05*i)), + point(0.05*i, 0.05*i), + circle(point(0.05*i, 0.05*i), 1.0) +from generate_series(0,10000) as i +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 019 +vacuum analyze gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: VacuumStmt +== 020 +set enable_seqscan=off +-- +STMT: VariableSetStmt +== 021 +set enable_bitmapscan=off +-- +STMT: VariableSetStmt +== 022 +set enable_indexonlyscan=on +-- +STMT: VariableSetStmt +== 023 +-- Test index-only scan with point opclass +create index gist_tbl_point_index on gist_tbl using gist (p) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +== 024 +-- check that the planner chooses an index-only scan +explain (costs off) +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 025 +-- execute the same +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 026 +-- Also test an index-only knn-search +explain (costs off) +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +order by p <-> point(0.201, 0.201) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 027 +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +order by p <-> point(0.201, 0.201) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 028 +-- Check commuted case as well +explain (costs off) +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +order by point(0.101, 0.101) <-> p +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 029 +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +order by point(0.101, 0.101) <-> p +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 030 +-- Check case with multiple rescans (bug #14641) +explain (costs off) +select p from + (values (box(point(0,0), point(0.5,0.5))), + (box(point(0.5,0.5), point(0.75,0.75))), + (box(point(0.8,0.8), point(1.0,1.0)))) as v(bb) +cross join lateral + (select p from gist_tbl where p <@ bb order by p <-> bb[0] limit 2) ss +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +FILTER: schema="" table="" column="bb" +STMT: ExplainStmt +STMT: SelectStmt +== 031 +select p from + (values (box(point(0,0), point(0.5,0.5))), + (box(point(0.5,0.5), point(0.75,0.75))), + (box(point(0.8,0.8), point(1.0,1.0)))) as v(bb) +cross join lateral + (select p from gist_tbl where p <@ bb order by p <-> bb[0] limit 2) ss +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +FILTER: schema="" table="" column="bb" +STMT: SelectStmt +== 032 +drop index gist_tbl_point_index +-- +STMT: DropStmt +== 033 +-- Test index-only scan with box opclass +create index gist_tbl_box_index on gist_tbl using gist (b) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +== 034 +-- check that the planner chooses an index-only scan +explain (costs off) +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 035 +-- execute the same +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 036 +-- Also test an index-only knn-search +explain (costs off) +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +order by b <-> point(5.2, 5.91) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 037 +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +order by b <-> point(5.2, 5.91) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 038 +-- Check commuted case as well +explain (costs off) +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +order by point(5.2, 5.91) <-> b +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 039 +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +order by point(5.2, 5.91) <-> b +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 040 +drop index gist_tbl_box_index +-- +STMT: DropStmt +== 041 +-- Test that an index-only scan is not chosen, when the query involves the +-- circle column (the circle opclass does not support index-only scans). +create index gist_tbl_multi_index on gist_tbl using gist (p, c) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +== 042 +explain (costs off) +select p, c from gist_tbl +where p <@ box(point(5,5), point(6, 6)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 043 +-- execute the same +select b, p from gist_tbl +where b <@ box(point(4.5, 4.5), point(5.5, 5.5)) +and p <@ box(point(5,5), point(6, 6)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 044 +drop index gist_tbl_multi_index +-- +STMT: DropStmt +== 045 +-- Test that we don't try to return the value of a non-returnable +-- column in an index-only scan. (This isn't GIST-specific, but +-- it only applies to index AMs that can return some columns and not +-- others, so GIST with appropriate opclasses is a convenient test case.) +create index gist_tbl_multi_index on gist_tbl using gist (circle(p,1), p) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +FUNCTION: name="circle" function="circle" schema="" ctx=Call +STMT: IndexStmt +== 046 +explain (verbose, costs off) +select circle(p,1) from gist_tbl +where p <@ box(point(5, 5), point(5.3, 5.3)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 047 +select circle(p,1) from gist_tbl +where p <@ box(point(5, 5), point(5.3, 5.3)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 048 +-- Similarly, test that index rechecks involving a non-returnable column +-- are done correctly. +explain (verbose, costs off) +select p from gist_tbl where circle(p,1) @> circle(point(0,0),0.95) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 049 +select p from gist_tbl where circle(p,1) @> circle(point(0,0),0.95) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 050 +-- Also check that use_physical_tlist doesn't trigger in such cases. +explain (verbose, costs off) +select count(*) from gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 051 +select count(*) from gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 052 +-- This case isn't supported, but it should at least EXPLAIN correctly. +explain (verbose, costs off) +select p from gist_tbl order by circle(p,1) <-> point(0,0) limit 1 +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 053 +select p from gist_tbl order by circle(p,1) <-> point(0,0) limit 1 +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 054 +-- Force an index build using buffering. +create index gist_tbl_box_index_forcing_buffering on gist_tbl using gist (p) + with (buffering=on, fillfactor=50) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +== 055 +-- Clean up +reset enable_seqscan +-- +STMT: VariableSetStmt +== 056 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 057 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +== 058 +drop table gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: DropStmt +== 059 +-- test an unlogged table, mostly to get coverage of gistbuildempty +create unlogged table gist_tbl (b box) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: CreateStmt +== 060 +create index gist_tbl_box_index on gist_tbl using gist (b) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +== 061 +insert into gist_tbl + select box(point(0.05*i, 0.05*i)) from generate_series(0,10) as i +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 062 +drop table gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/groupingsets.metadata.json b/parser/testdata/summary/postgres_regress/groupingsets.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/groupingsets.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/groupingsets.test b/parser/testdata/summary/postgres_regress/groupingsets.test new file mode 100644 index 0000000..95a6d2a --- /dev/null +++ b/parser/testdata/summary/postgres_regress/groupingsets.test @@ -0,0 +1,1405 @@ +== 001 +|-- +-- grouping sets +|-- + +-- test data sources + +create temp view gstest1(a,b,v) + as values (1,1,10),(1,1,11),(1,2,12),(1,2,13),(1,3,14), + (2,3,15), + (3,3,16),(3,4,17), + (4,1,18),(4,1,19) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 002 +create temp table gstest2 (a integer, b integer, c integer, d integer, + e integer, f integer, g integer, h integer) +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=DDL +STMT: CreateStmt +== 003 +copy gstest2 from stdin +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +STMT: CopyStmt +== 004 +create temp table gstest3 (a integer, b integer, c integer, d integer) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=DDL +STMT: CreateStmt +== 005 +copy gstest3 from stdin +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +STMT: CopyStmt +== 006 +alter table gstest3 add primary key (a) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=DDL +STMT: AlterTableStmt +== 007 +create temp table gstest4(id integer, v integer, + unhashable_col bit(4), unsortable_col xid) +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=DDL +STMT: CreateStmt +== 008 +insert into gstest4 +values (1,1,b'0000','1'), (2,2,b'0001','1'), + (3,4,b'0010','2'), (4,8,b'0011','2'), + (5,16,b'0000','2'), (6,32,b'0001','2'), + (7,64,b'0010','1'), (8,128,b'0011','1') +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +create temp table gstest_empty (a integer, b integer, v integer) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=DDL +STMT: CreateStmt +== 010 +create function gstest_data(v integer, out a integer, out b integer) + returns setof record + as $f$ + begin + return query select v, i from generate_series(1,3) i; + end; + $f$ language plpgsql +-- +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 011 +-- basic functionality + +set enable_hashagg = false +-- +STMT: VariableSetStmt +== 012 +-- test hashing explicitly later + +-- simple rollup with multiple plain aggregates, with and without ordering +-- (and with ordering differing from grouping) + +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by rollup (a,b) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 013 +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by rollup (a,b) order by a,b +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 014 +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by rollup (a,b) order by b desc, a +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 015 +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by rollup (a,b) order by coalesce(a,0)+coalesce(b,0) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- various types of ordered aggs +select a, b, grouping(a,b), + array_agg(v order by v), + string_agg(v::text, ':' order by v desc), + percentile_disc(0.5) within group (order by v), + rank(1,2,12) within group (order by a,b,v) + from gstest1 group by rollup (a,b) order by a,b +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- test usage of grouped columns in direct args of aggs +select grouping(a), a, array_agg(b), + rank(a) within group (order by b nulls first), + rank(a) within group (order by b nulls last) + from (values (1,1),(1,4),(1,5),(3,1),(3,2)) v(a,b) + group by rollup (a) order by a +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- nesting with window functions +select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum + from gstest2 group by rollup (a,b) order by rsum, a, b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- nesting with grouping sets +select sum(c) from gstest2 + group by grouping sets((), grouping sets((), grouping sets(()))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 020 +select sum(c) from gstest2 + group by grouping sets((), grouping sets((), grouping sets(((a, b))))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 021 +select sum(c) from gstest2 + group by grouping sets(grouping sets(rollup(c), grouping sets(cube(c)))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 022 +select sum(c) from gstest2 + group by grouping sets(a, grouping sets(a, cube(b))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 023 +select sum(c) from gstest2 + group by grouping sets(grouping sets((a, (b)))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 024 +select sum(c) from gstest2 + group by grouping sets(grouping sets((a, b))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 025 +select sum(c) from gstest2 + group by grouping sets(grouping sets(a, grouping sets(a), a)) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 026 +select sum(c) from gstest2 + group by grouping sets(grouping sets(a, grouping sets(a, grouping sets(a), ((a)), a, grouping sets(a), (a)), a)) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 027 +select sum(c) from gstest2 + group by grouping sets((a,(a,b)), grouping sets((a,(a,b)),a)) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 028 +-- empty input: first is 0 rows, second 1, third 3 etc. +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),a) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 029 +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 030 +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),(),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 031 +select sum(v), count(*) from gstest_empty group by grouping sets ((),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 032 +-- empty input with joins tests some important code paths +select t1.a, t2.b, sum(t1.v), count(*) from gstest_empty t1, gstest_empty t2 + group by grouping sets ((t1.a,t2.b),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +ALIAS: "t1"="gstest_empty" +ALIAS: "t2"="gstest_empty" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 033 +-- simple joins, var resolution, GROUPING on join vars +select t1.a, t2.b, grouping(t1.a, t2.b), sum(t1.v), max(t2.a) + from gstest1 t1, gstest2 t2 + group by grouping sets ((t1.a, t2.b), ()) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +ALIAS: "t1"="gstest1" +ALIAS: "t2"="gstest2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 034 +select t1.a, t2.b, grouping(t1.a, t2.b), sum(t1.v), max(t2.a) + from gstest1 t1 join gstest2 t2 on (t1.a=t2.a) + group by grouping sets ((t1.a, t2.b), ()) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +ALIAS: "t1"="gstest1" +ALIAS: "t2"="gstest2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 035 +select a, b, grouping(a, b), sum(t1.v), max(t2.c) + from gstest1 t1 join gstest2 t2 using (a,b) + group by grouping sets ((a, b), ()) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +ALIAS: "t1"="gstest1" +ALIAS: "t2"="gstest2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- check that functionally dependent cols are not nulled +select a, d, grouping(a,b,c) + from gstest3 + group by grouping sets ((a,b), (a,c)) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +STMT: SelectStmt +== 037 +-- check that distinct grouping columns are kept separate +-- even if they are equal() +explain (costs off) +select g as alias1, g as alias2 + from generate_series(1,3) g + group by alias1, rollup(alias2) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 038 +select g as alias1, g as alias2 + from generate_series(1,3) g + group by alias1, rollup(alias2) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 039 +-- check that pulled-up subquery outputs still go to null when appropriate +select four, x + from (select four, ten, 'foo'::text as x from tenk1) as t + group by grouping sets (four, x) + having x = 'foo' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +== 040 +select four, x || 'x' + from (select four, ten, 'foo'::text as x from tenk1) as t + group by grouping sets (four, x) + order by four +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +== 041 +select (x+y)*1, sum(z) + from (select 1 as x, 2 as y, 3 as z) s + group by grouping sets (x+y, x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 042 +select x, not x as not_x, q2 from + (select *, q1 = 1 as x from int8_tbl i1) as t + group by grouping sets(x, q2) + order by x, q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: SelectStmt +== 043 +-- check qual push-down rules for a subquery with grouping sets +explain (verbose, costs off) +select * from ( + select 1 as x, q1, sum(q2) + from int8_tbl i1 + group by grouping sets(1, 2) +) ss +where x = 1 and q1 = 123 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 044 +select * from ( + select 1 as x, q1, sum(q2) + from int8_tbl i1 + group by grouping sets(1, 2) +) ss +where x = 1 and q1 = 123 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 045 +-- check handling of pulled-up SubPlan in GROUPING() argument (bug #17479) +explain (verbose, costs off) +select grouping(ss.x) +from int8_tbl i1 +cross join lateral (select (select i1.q1) as x) ss +group by ss.x +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 046 +select grouping(ss.x) +from int8_tbl i1 +cross join lateral (select (select i1.q1) as x) ss +group by ss.x +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: SelectStmt +== 047 +explain (verbose, costs off) +select (select grouping(ss.x)) +from int8_tbl i1 +cross join lateral (select (select i1.q1) as x) ss +group by ss.x +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 048 +select (select grouping(ss.x)) +from int8_tbl i1 +cross join lateral (select (select i1.q1) as x) ss +group by ss.x +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: SelectStmt +== 049 +-- simple rescan tests + +select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by rollup (a,b) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +== 050 +select * + from (values (1),(2)) v(x), + lateral (select a, b, sum(v.x) from gstest_data(v.x) group by rollup (a,b)) s +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +== 051 +-- min max optimization should still work with GROUP BY () +explain (costs off) + select min(unique1) from tenk1 GROUP BY () +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 052 +-- Views with GROUPING SET queries +CREATE VIEW gstest_view AS select a, b, grouping(a,b), sum(c), count(*), max(c) + from gstest2 group by rollup ((a,b,c),(c,d)) +-- +TABLE: name="gstest_view" schema="" table="gstest_view" ctx=DDL +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 053 +select pg_get_viewdef('gstest_view'::regclass, true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 054 +-- Nested queries with 3 or more levels of nesting +select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f) +-- +STMT: SelectStmt +== 055 +select(select (select grouping(e,f) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f) +-- +STMT: SelectStmt +== 056 +select(select (select grouping(c) from (values (1)) v2(c) GROUP BY c) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f) +-- +STMT: SelectStmt +== 057 +-- Combinations of operations +select a, b, c, d from gstest2 group by rollup(a,b),grouping sets(c,d) +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +STMT: SelectStmt +== 058 +select a, b from (values (1,2),(2,3)) v(a,b) group by a,b, grouping sets(a) +-- +STMT: SelectStmt +== 059 +-- Tests for chained aggregates +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a,b),(a+1,b+1),(a+2,b+2)) order by 3,6 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 060 +select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP((e+1),(f+1)) +-- +STMT: SelectStmt +== 061 +select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY CUBE((e+1),(f+1)) ORDER BY (e+1),(f+1) +-- +STMT: SelectStmt +== 062 +select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum + from gstest2 group by cube (a,b) order by rsum, a, b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 063 +select a, b, sum(c) from (values (1,1,10),(1,1,11),(1,2,12),(1,2,13),(1,3,14),(2,3,15),(3,3,16),(3,4,17),(4,1,18),(4,1,19)) v(a,b,c) group by rollup (a,b) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 064 +select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by cube (a,b) order by a,b +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +== 065 +-- Test reordering of grouping sets +explain (costs off) +select * from gstest1 group by grouping sets((a,b,v),(v)) order by v,b,a +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 066 +-- Agg level check. This query should error out. +select (select grouping(a,b) from gstest2) from gstest2 group by a,b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +STMT: SelectStmt +== 067 +--Nested queries +select a, b, sum(c), count(*) from gstest2 group by grouping sets (rollup(a,b),a) +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 068 +-- HAVING queries +select ten, sum(distinct four) from onek a +group by grouping sets((ten,four),(ten)) +having exists (select 1 from onek b where sum(distinct a.four) = b.four) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="a" column="four" +FILTER: schema="" table="b" column="four" +STMT: SelectStmt +== 069 +-- Tests around pushdown of HAVING clauses, partially testing against previous bugs +select a,count(*) from gstest2 group by rollup(a) order by a +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 070 +select a,count(*) from gstest2 group by rollup(a) having a is distinct from 1 order by a +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 071 +explain (costs off) + select a,count(*) from gstest2 group by rollup(a) having a is distinct from 1 order by a +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 072 +select v.c, (select count(*) from gstest2 group by () having v.c) + from (values (false),(true)) v(c) order by v.c +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 073 +explain (costs off) + select v.c, (select count(*) from gstest2 group by () having v.c) + from (values (false),(true)) v(c) order by v.c +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 074 +-- HAVING with GROUPING queries +select ten, grouping(ten) from onek +group by grouping sets(ten) having grouping(ten) >= 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 075 +select ten, grouping(ten) from onek +group by grouping sets(ten, four) having grouping(ten) > 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 076 +select ten, grouping(ten) from onek +group by rollup(ten) having grouping(ten) > 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 077 +select ten, grouping(ten) from onek +group by cube(ten) having grouping(ten) > 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 078 +select ten, grouping(ten) from onek +group by (ten) having grouping(ten) >= 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 079 +-- FILTER queries +select ten, sum(distinct four) filter (where four::text ~ '123') from onek a +group by rollup(ten) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 080 +-- More rescan tests +select * from (values (1),(2)) v(a) left join lateral (select v.a, four, ten, count(*) from onek group by cube(four,ten)) s on true order by v.a,four,ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 081 +select array(select row(v.a,s1.*) from (select two,four, count(*) from onek group by cube(two,four) order by two,four) s1) from (values (1),(2)) v(a) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 082 +-- Grouping on text columns +select sum(ten) from onek group by two, rollup(four::text) order by 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 083 +select sum(ten) from onek group by rollup(four::text), two order by 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 084 +-- hashing support + +set enable_hashagg = true +-- +STMT: VariableSetStmt +== 085 +-- failure cases + +select count(*) from gstest4 group by rollup(unhashable_col,unsortable_col) +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 086 +select array_agg(v order by v) from gstest4 group by grouping sets ((id,unsortable_col),(id)) +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 087 +-- simple cases + +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a),(b)) order by 3,1,2 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 088 +explain (costs off) select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a),(b)) order by 3,1,2 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 089 +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by cube(a,b) order by 3,1,2 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 090 +explain (costs off) select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by cube(a,b) order by 3,1,2 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 091 +-- shouldn't try and hash +explain (costs off) + select a, b, grouping(a,b), array_agg(v order by v) + from gstest1 group by cube(a,b) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 092 +-- unsortable cases +select unsortable_col, count(*) + from gstest4 group by grouping sets ((unsortable_col),(unsortable_col)) + order by unsortable_col::text +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 093 +-- mixed hashable/sortable cases +select unhashable_col, unsortable_col, + grouping(unhashable_col, unsortable_col), + count(*), sum(v) + from gstest4 group by grouping sets ((unhashable_col),(unsortable_col)) + order by 3, 5 +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 094 +explain (costs off) + select unhashable_col, unsortable_col, + grouping(unhashable_col, unsortable_col), + count(*), sum(v) + from gstest4 group by grouping sets ((unhashable_col),(unsortable_col)) + order by 3,5 +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 095 +select unhashable_col, unsortable_col, + grouping(unhashable_col, unsortable_col), + count(*), sum(v) + from gstest4 group by grouping sets ((v,unhashable_col),(v,unsortable_col)) + order by 3,5 +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 096 +explain (costs off) + select unhashable_col, unsortable_col, + grouping(unhashable_col, unsortable_col), + count(*), sum(v) + from gstest4 group by grouping sets ((v,unhashable_col),(v,unsortable_col)) + order by 3,5 +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 097 +-- empty input: first is 0 rows, second 1, third 3 etc. +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),a) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 098 +explain (costs off) + select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),a) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 099 +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 100 +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),(),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 101 +explain (costs off) + select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),(),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 102 +select sum(v), count(*) from gstest_empty group by grouping sets ((),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 103 +explain (costs off) + select sum(v), count(*) from gstest_empty group by grouping sets ((),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 104 +-- check that functionally dependent cols are not nulled +select a, d, grouping(a,b,c) + from gstest3 + group by grouping sets ((a,b), (a,c)) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +STMT: SelectStmt +== 105 +explain (costs off) + select a, d, grouping(a,b,c) + from gstest3 + group by grouping sets ((a,b), (a,c)) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 106 +-- simple rescan tests + +select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by grouping sets (a,b) + order by 1, 2, 3 +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +== 107 +explain (costs off) + select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by grouping sets (a,b) + order by 3, 1, 2 +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 108 +select * + from (values (1),(2)) v(x), + lateral (select a, b, sum(v.x) from gstest_data(v.x) group by grouping sets (a,b)) s +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +== 109 +explain (costs off) + select * + from (values (1),(2)) v(x), + lateral (select a, b, sum(v.x) from gstest_data(v.x) group by grouping sets (a,b)) s +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 110 +-- Tests for chained aggregates +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a,b),(a+1,b+1),(a+2,b+2)) order by 3,6 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 111 +explain (costs off) + select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a,b),(a+1,b+1),(a+2,b+2)) order by 3,6 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 112 +select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum + from gstest2 group by cube (a,b) order by rsum, a, b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 113 +explain (costs off) + select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum + from gstest2 group by cube (a,b) order by rsum, a, b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 114 +select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by cube (a,b) order by a,b +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +== 115 +explain (costs off) + select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by cube (a,b) order by a,b +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 116 +-- Verify that we correctly handle the child node returning a +-- non-minimal slot, which happens if the input is pre-sorted, +-- e.g. due to an index scan. +BEGIN +-- +STMT: TransactionStmt +== 117 +SET LOCAL enable_hashagg = false +-- +STMT: VariableSetStmt +== 118 +EXPLAIN (COSTS OFF) SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 119 +SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 120 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +== 121 +EXPLAIN (COSTS OFF) SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 122 +SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 123 +COMMIT +-- +STMT: TransactionStmt +== 124 +-- More rescan tests +select * from (values (1),(2)) v(a) left join lateral (select v.a, four, ten, count(*) from onek group by cube(four,ten)) s on true order by v.a,four,ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 125 +select array(select row(v.a,s1.*) from (select two,four, count(*) from onek group by cube(two,four) order by two,four) s1) from (values (1),(2)) v(a) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 126 +-- Rescan logic changes when there are no empty grouping sets, so test +-- that too: +select * from (values (1),(2)) v(a) left join lateral (select v.a, four, ten, count(*) from onek group by grouping sets(four,ten)) s on true order by v.a,four,ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 127 +select array(select row(v.a,s1.*) from (select two,four, count(*) from onek group by grouping sets(two,four) order by two,four) s1) from (values (1),(2)) v(a) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 128 +-- test the knapsack + +set enable_indexscan = false +-- +STMT: VariableSetStmt +== 129 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 130 +set work_mem = '64kB' +-- +STMT: VariableSetStmt +== 131 +explain (costs off) + select unique1, + count(two), count(four), count(ten), + count(hundred), count(thousand), count(twothousand), + count(*) + from tenk1 group by grouping sets (unique1,twothousand,thousand,hundred,ten,four,two) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 132 +explain (costs off) + select unique1, + count(two), count(four), count(ten), + count(hundred), count(thousand), count(twothousand), + count(*) + from tenk1 group by grouping sets (unique1,hundred,ten,four,two) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 133 +set work_mem = '384kB' +-- +STMT: VariableSetStmt +== 134 +explain (costs off) + select unique1, + count(two), count(four), count(ten), + count(hundred), count(thousand), count(twothousand), + count(*) + from tenk1 group by grouping sets (unique1,twothousand,thousand,hundred,ten,four,two) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 135 +-- check collation-sensitive matching between grouping expressions +-- (similar to a check for aggregates, but there are additional code +-- paths for GROUPING, so check again here) + +select v||'a', case grouping(v||'a') when 1 then 1 else 0 end, count(*) + from unnest(array[1,1], array['a','b']) u(i,v) + group by rollup(i, v||'a') order by 1,3 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 136 +select v||'a', case when grouping(v||'a') = 1 then 1 else 0 end, count(*) + from unnest(array[1,1], array['a','b']) u(i,v) + group by rollup(i, v||'a') order by 1,3 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 137 +-- Bug #16784 +create table bug_16784(i int, j int) +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=DDL +STMT: CreateStmt +== 138 +analyze bug_16784 +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=DDL +STMT: VacuumStmt +== 139 +alter table bug_16784 set (autovacuum_enabled = 'false') +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=DDL +STMT: AlterTableStmt +== 140 +update pg_class set reltuples = 10 where relname='bug_16784' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +STMT: UpdateStmt +== 141 +insert into bug_16784 select g/10, g from generate_series(1,40) g +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 142 +set work_mem='64kB' +-- +STMT: VariableSetStmt +== 143 +set enable_sort = false +-- +STMT: VariableSetStmt +== 144 +select * from + (values (1),(2)) v(a), + lateral (select a, i, j, count(*) from + bug_16784 group by cube(i,j)) s + order by v.a, i, j +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 145 +|-- +-- Compare results between plans using sorting and plans using hash +-- aggregation. Force spilling in both cases by setting work_mem low +-- and altering the statistics. +|-- + +create table gs_data_1 as +select g%1000 as g1000, g%100 as g100, g%10 as g10, g + from generate_series(0,1999) g +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 146 +analyze gs_data_1 +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=DDL +STMT: VacuumStmt +== 147 +alter table gs_data_1 set (autovacuum_enabled = 'false') +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=DDL +STMT: AlterTableStmt +== 148 +update pg_class set reltuples = 10 where relname='gs_data_1' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +STMT: UpdateStmt +== 149 +set work_mem='64kB' +-- +STMT: VariableSetStmt +== 150 +-- Produce results with sorting. + +set enable_sort = true +-- +STMT: VariableSetStmt +== 151 +set enable_hashagg = false +-- +STMT: VariableSetStmt +== 152 +set jit_above_cost = 0 +-- +STMT: VariableSetStmt +== 153 +explain (costs off) +select g100, g10, sum(g::numeric), count(*), max(g::text) +from gs_data_1 group by cube (g1000, g100,g10) +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 154 +create table gs_group_1 as +select g100, g10, sum(g::numeric), count(*), max(g::text) +from gs_data_1 group by cube (g1000, g100,g10) +-- +TABLE: name="gs_group_1" schema="" table="gs_group_1" ctx=DDL +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 155 +-- Produce results with hash aggregation. + +set enable_hashagg = true +-- +STMT: VariableSetStmt +== 156 +set enable_sort = false +-- +STMT: VariableSetStmt +== 157 +explain (costs off) +select g100, g10, sum(g::numeric), count(*), max(g::text) +from gs_data_1 group by cube (g1000, g100,g10) +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 158 +create table gs_hash_1 as +select g100, g10, sum(g::numeric), count(*), max(g::text) +from gs_data_1 group by cube (g1000, g100,g10) +-- +TABLE: name="gs_hash_1" schema="" table="gs_hash_1" ctx=DDL +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 159 +set enable_sort = true +-- +STMT: VariableSetStmt +== 160 +set work_mem to default +-- +STMT: VariableSetStmt +== 161 +set hash_mem_multiplier to default +-- +STMT: VariableSetStmt +== 162 +-- Compare results + +(select * from gs_hash_1 except select * from gs_group_1) + union all +(select * from gs_group_1 except select * from gs_hash_1) +-- +TABLE: name="gs_hash_1" schema="" table="gs_hash_1" ctx=Select +TABLE: name="gs_group_1" schema="" table="gs_group_1" ctx=Select +TABLE: name="gs_group_1" schema="" table="gs_group_1" ctx=Select +TABLE: name="gs_hash_1" schema="" table="gs_hash_1" ctx=Select +STMT: SelectStmt +== 163 +drop table gs_group_1 +-- +TABLE: name="gs_group_1" schema="" table="gs_group_1" ctx=DDL +STMT: DropStmt +== 164 +drop table gs_hash_1 +-- +TABLE: name="gs_hash_1" schema="" table="gs_hash_1" ctx=DDL +STMT: DropStmt +== 165 +-- GROUP BY DISTINCT + +-- "normal" behavior... +select a, b, c +from (values (1, 2, 3), (4, null, 6), (7, 8, 9)) as t (a, b, c) +group by all rollup(a, b), rollup(a, c) +order by a, b, c +-- +STMT: SelectStmt +== 166 +-- ...which is also the default +select a, b, c +from (values (1, 2, 3), (4, null, 6), (7, 8, 9)) as t (a, b, c) +group by rollup(a, b), rollup(a, c) +order by a, b, c +-- +STMT: SelectStmt +== 167 +-- "group by distinct" behavior... +select a, b, c +from (values (1, 2, 3), (4, null, 6), (7, 8, 9)) as t (a, b, c) +group by distinct rollup(a, b), rollup(a, c) +order by a, b, c +-- +STMT: SelectStmt +== 168 +-- ...which is not the same as "select distinct" +select distinct a, b, c +from (values (1, 2, 3), (4, null, 6), (7, 8, 9)) as t (a, b, c) +group by rollup(a, b), rollup(a, c) +order by a, b, c +-- +STMT: SelectStmt +== 169 +-- test handling of outer GroupingFunc within subqueries +explain (costs off) +select (select grouping(v1)) from (values ((select 1))) v(v1) group by cube(v1) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 170 +select (select grouping(v1)) from (values ((select 1))) v(v1) group by cube(v1) +-- +STMT: SelectStmt +== 171 +explain (costs off) +select (select grouping(v1)) from (values ((select 1))) v(v1) group by v1 +-- +STMT: ExplainStmt +STMT: SelectStmt +== 172 +select (select grouping(v1)) from (values ((select 1))) v(v1) group by v1 +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/guc.metadata.json b/parser/testdata/summary/postgres_regress/guc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/guc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/guc.test b/parser/testdata/summary/postgres_regress/guc.test new file mode 100644 index 0000000..12ffa58 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/guc.test @@ -0,0 +1,1034 @@ +== 001 +-- pg_regress should ensure that this default value applies; however +-- we can't rely on any specific default value of vacuum_cost_delay +SHOW datestyle +-- +STMT: VariableShowStmt +== 002 +-- SET to some nondefault value +SET vacuum_cost_delay TO 40 +-- +STMT: VariableSetStmt +== 003 +SET datestyle = 'ISO, YMD' +-- +STMT: VariableSetStmt +== 004 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 005 +SHOW datestyle +-- +STMT: VariableShowStmt +== 006 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 007 +-- SET LOCAL has no effect outside of a transaction +SET LOCAL vacuum_cost_delay TO 50 +-- +STMT: VariableSetStmt +== 008 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 009 +SET LOCAL datestyle = 'SQL' +-- +STMT: VariableSetStmt +== 010 +SHOW datestyle +-- +STMT: VariableShowStmt +== 011 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 012 +-- SET LOCAL within a transaction that commits +BEGIN +-- +STMT: TransactionStmt +== 013 +SET LOCAL vacuum_cost_delay TO 50 +-- +STMT: VariableSetStmt +== 014 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 015 +SET LOCAL datestyle = 'SQL' +-- +STMT: VariableSetStmt +== 016 +SHOW datestyle +-- +STMT: VariableShowStmt +== 017 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 018 +COMMIT +-- +STMT: TransactionStmt +== 019 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 020 +SHOW datestyle +-- +STMT: VariableShowStmt +== 021 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 022 +-- SET should be reverted after ROLLBACK +BEGIN +-- +STMT: TransactionStmt +== 023 +SET vacuum_cost_delay TO 60 +-- +STMT: VariableSetStmt +== 024 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 025 +SET datestyle = 'German' +-- +STMT: VariableSetStmt +== 026 +SHOW datestyle +-- +STMT: VariableShowStmt +== 027 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 028 +ROLLBACK +-- +STMT: TransactionStmt +== 029 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 030 +SHOW datestyle +-- +STMT: VariableShowStmt +== 031 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 032 +-- Some tests with subtransactions +BEGIN +-- +STMT: TransactionStmt +== 033 +SET vacuum_cost_delay TO 70 +-- +STMT: VariableSetStmt +== 034 +SET datestyle = 'MDY' +-- +STMT: VariableSetStmt +== 035 +SHOW datestyle +-- +STMT: VariableShowStmt +== 036 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 037 +SAVEPOINT first_sp +-- +STMT: TransactionStmt +== 038 +SET vacuum_cost_delay TO 80.1 +-- +STMT: VariableSetStmt +== 039 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 040 +SET datestyle = 'German, DMY' +-- +STMT: VariableSetStmt +== 041 +SHOW datestyle +-- +STMT: VariableShowStmt +== 042 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 043 +ROLLBACK TO first_sp +-- +STMT: TransactionStmt +== 044 +SHOW datestyle +-- +STMT: VariableShowStmt +== 045 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 046 +SAVEPOINT second_sp +-- +STMT: TransactionStmt +== 047 +SET vacuum_cost_delay TO '900us' +-- +STMT: VariableSetStmt +== 048 +SET datestyle = 'SQL, YMD' +-- +STMT: VariableSetStmt +== 049 +SHOW datestyle +-- +STMT: VariableShowStmt +== 050 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 051 +SAVEPOINT third_sp +-- +STMT: TransactionStmt +== 052 +SET vacuum_cost_delay TO 100 +-- +STMT: VariableSetStmt +== 053 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 054 +SET datestyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +== 055 +SHOW datestyle +-- +STMT: VariableShowStmt +== 056 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 057 +ROLLBACK TO third_sp +-- +STMT: TransactionStmt +== 058 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 059 +SHOW datestyle +-- +STMT: VariableShowStmt +== 060 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 061 +ROLLBACK TO second_sp +-- +STMT: TransactionStmt +== 062 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 063 +SHOW datestyle +-- +STMT: VariableShowStmt +== 064 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 065 +ROLLBACK +-- +STMT: TransactionStmt +== 066 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 067 +SHOW datestyle +-- +STMT: VariableShowStmt +== 068 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 069 +-- SET LOCAL with Savepoints +BEGIN +-- +STMT: TransactionStmt +== 070 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 071 +SHOW datestyle +-- +STMT: VariableShowStmt +== 072 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 073 +SAVEPOINT sp +-- +STMT: TransactionStmt +== 074 +SET LOCAL vacuum_cost_delay TO 30 +-- +STMT: VariableSetStmt +== 075 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 076 +SET LOCAL datestyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +== 077 +SHOW datestyle +-- +STMT: VariableShowStmt +== 078 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 079 +ROLLBACK TO sp +-- +STMT: TransactionStmt +== 080 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 081 +SHOW datestyle +-- +STMT: VariableShowStmt +== 082 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 083 +ROLLBACK +-- +STMT: TransactionStmt +== 084 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 085 +SHOW datestyle +-- +STMT: VariableShowStmt +== 086 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 087 +-- SET LOCAL persists through RELEASE (which was not true in 8.0-8.2) +BEGIN +-- +STMT: TransactionStmt +== 088 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 089 +SHOW datestyle +-- +STMT: VariableShowStmt +== 090 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 091 +SAVEPOINT sp +-- +STMT: TransactionStmt +== 092 +SET LOCAL vacuum_cost_delay TO 30 +-- +STMT: VariableSetStmt +== 093 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 094 +SET LOCAL datestyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +== 095 +SHOW datestyle +-- +STMT: VariableShowStmt +== 096 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 097 +RELEASE SAVEPOINT sp +-- +STMT: TransactionStmt +== 098 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 099 +SHOW datestyle +-- +STMT: VariableShowStmt +== 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 101 +ROLLBACK +-- +STMT: TransactionStmt +== 102 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 103 +SHOW datestyle +-- +STMT: VariableShowStmt +== 104 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 105 +-- SET followed by SET LOCAL +BEGIN +-- +STMT: TransactionStmt +== 106 +SET vacuum_cost_delay TO 40 +-- +STMT: VariableSetStmt +== 107 +SET LOCAL vacuum_cost_delay TO 50 +-- +STMT: VariableSetStmt +== 108 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 109 +SET datestyle = 'ISO, DMY' +-- +STMT: VariableSetStmt +== 110 +SET LOCAL datestyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +== 111 +SHOW datestyle +-- +STMT: VariableShowStmt +== 112 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 113 +COMMIT +-- +STMT: TransactionStmt +== 114 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 115 +SHOW datestyle +-- +STMT: VariableShowStmt +== 116 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 117 +|-- +-- Test RESET. We use datestyle because the reset value is forced by +-- pg_regress, so it doesn't depend on the installation's configuration. +|-- +SET datestyle = iso, ymd +-- +STMT: VariableSetStmt +== 118 +SHOW datestyle +-- +STMT: VariableShowStmt +== 119 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 120 +RESET datestyle +-- +STMT: VariableSetStmt +== 121 +SHOW datestyle +-- +STMT: VariableShowStmt +== 122 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +== 123 +-- Test some simple error cases +SET seq_page_cost TO 'NaN' +-- +STMT: VariableSetStmt +== 124 +SET vacuum_cost_delay TO '10s' +-- +STMT: VariableSetStmt +== 125 +SET no_such_variable TO 42 +-- +STMT: VariableSetStmt +== 126 +-- Test "custom" GUCs created on the fly (which aren't really an +-- intended feature, but many people use them). +SHOW custom.my_guc +-- +STMT: VariableShowStmt +== 127 +-- error, not known yet +SET custom.my_guc = 42 +-- +STMT: VariableSetStmt +== 128 +SHOW custom.my_guc +-- +STMT: VariableShowStmt +== 129 +RESET custom.my_guc +-- +STMT: VariableSetStmt +== 130 +-- this makes it go to empty, not become unknown again +SHOW custom.my_guc +-- +STMT: VariableShowStmt +== 131 +SET custom.my.qualified.guc = 'foo' +-- +STMT: VariableSetStmt +== 132 +SHOW custom.my.qualified.guc +-- +STMT: VariableShowStmt +== 133 +SET custom."bad-guc" = 42 +-- +STMT: VariableSetStmt +== 134 +-- disallowed because -c cannot set this name +SHOW custom."bad-guc" +-- +STMT: VariableShowStmt +== 135 +SET special."weird name" = 'foo' +-- +STMT: VariableSetStmt +== 136 +-- could be allowed, but we choose not to +SHOW special."weird name" +-- +STMT: VariableShowStmt +== 137 +-- Check what happens when you try to set a "custom" GUC within the +-- namespace of an extension. +SET plpgsql.extra_foo_warnings = true +-- +STMT: VariableSetStmt +== 138 +-- allowed if plpgsql is not loaded yet +LOAD 'plpgsql' +-- +STMT: LoadStmt +== 139 +-- this will throw a warning and delete the variable +SET plpgsql.extra_foo_warnings = true +-- +STMT: VariableSetStmt +== 140 +-- now, it's an error +SHOW plpgsql.extra_foo_warnings +-- +STMT: VariableShowStmt +== 141 +|-- +-- Test DISCARD TEMP +|-- +CREATE TEMP TABLE reset_test ( data text ) ON COMMIT DELETE ROWS +-- +TABLE: name="reset_test" schema="" table="reset_test" ctx=DDL +STMT: CreateStmt +== 142 +SELECT relname FROM pg_class WHERE relname = 'reset_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 143 +DISCARD TEMP +-- +STMT: DiscardStmt +== 144 +SELECT relname FROM pg_class WHERE relname = 'reset_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 145 +|-- +-- Test DISCARD ALL +|-- + +-- do changes +DECLARE foo CURSOR WITH HOLD FOR SELECT 1 +-- +STMT: DeclareCursorStmt +== 146 +PREPARE foo AS SELECT 1 +-- +STMT: PrepareStmt +STMT: SelectStmt +== 147 +LISTEN foo_event +-- +STMT: ListenStmt +== 148 +SET vacuum_cost_delay = 13 +-- +STMT: VariableSetStmt +== 149 +CREATE TEMP TABLE tmp_foo (data text) ON COMMIT DELETE ROWS +-- +TABLE: name="tmp_foo" schema="" table="tmp_foo" ctx=DDL +STMT: CreateStmt +== 150 +CREATE ROLE regress_guc_user +-- +STMT: CreateRoleStmt +== 151 +SET SESSION AUTHORIZATION regress_guc_user +-- +STMT: VariableSetStmt +== 152 +-- look changes +SELECT pg_listening_channels() +-- +FUNCTION: name="pg_listening_channels" function="pg_listening_channels" schema="" ctx=Call +STMT: SelectStmt +== 153 +SELECT name FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +== 154 +SELECT name FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 155 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 156 +SELECT relname from pg_class where relname = 'tmp_foo' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 157 +SELECT current_user = 'regress_guc_user' +-- +STMT: SelectStmt +== 158 +-- discard everything +DISCARD ALL +-- +STMT: DiscardStmt +== 159 +-- look again +SELECT pg_listening_channels() +-- +FUNCTION: name="pg_listening_channels" function="pg_listening_channels" schema="" ctx=Call +STMT: SelectStmt +== 160 +SELECT name FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +== 161 +SELECT name FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +== 162 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +== 163 +SELECT relname from pg_class where relname = 'tmp_foo' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 164 +SELECT current_user = 'regress_guc_user' +-- +STMT: SelectStmt +== 165 +DROP ROLE regress_guc_user +-- +STMT: DropRoleStmt +== 166 +|-- +-- search_path should react to changes in pg_namespace +|-- + +set search_path = foo, public, not_there_initially +-- +STMT: VariableSetStmt +== 167 +select current_schemas(false) +-- +FUNCTION: name="current_schemas" function="current_schemas" schema="" ctx=Call +STMT: SelectStmt +== 168 +create schema not_there_initially +-- +STMT: CreateSchemaStmt +== 169 +select current_schemas(false) +-- +FUNCTION: name="current_schemas" function="current_schemas" schema="" ctx=Call +STMT: SelectStmt +== 170 +drop schema not_there_initially +-- +STMT: DropStmt +== 171 +select current_schemas(false) +-- +FUNCTION: name="current_schemas" function="current_schemas" schema="" ctx=Call +STMT: SelectStmt +== 172 +reset search_path +-- +STMT: VariableSetStmt +== 173 +|-- +-- Tests for function-local GUC settings +|-- + +set work_mem = '3MB' +-- +STMT: VariableSetStmt +== 174 +create function report_guc(text) returns text as +$$ select current_setting($1) $$ language sql +set work_mem = '1MB' +-- +FUNCTION: name="report_guc" function="report_guc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 175 +select report_guc('work_mem'), current_setting('work_mem') +-- +FUNCTION: name="report_guc" function="report_guc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 176 +alter function report_guc(text) set work_mem = '2MB' +-- +STMT: AlterFunctionStmt +== 177 +select report_guc('work_mem'), current_setting('work_mem') +-- +FUNCTION: name="report_guc" function="report_guc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 178 +alter function report_guc(text) reset all +-- +STMT: AlterFunctionStmt +== 179 +select report_guc('work_mem'), current_setting('work_mem') +-- +FUNCTION: name="report_guc" function="report_guc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 180 +-- SET LOCAL is restricted by a function SET option +create or replace function myfunc(int) returns text as $$ +begin + set local work_mem = '2MB'; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB' +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 181 +select myfunc(0), current_setting('work_mem') +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 182 +alter function myfunc(int) reset all +-- +STMT: AlterFunctionStmt +== 183 +select myfunc(0), current_setting('work_mem') +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 184 +set work_mem = '3MB' +-- +STMT: VariableSetStmt +== 185 +-- but SET isn't +create or replace function myfunc(int) returns text as $$ +begin + set work_mem = '2MB'; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB' +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 186 +select myfunc(0), current_setting('work_mem') +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 187 +set work_mem = '3MB' +-- +STMT: VariableSetStmt +== 188 +-- it should roll back on error, though +create or replace function myfunc(int) returns text as $$ +begin + set work_mem = '2MB'; + perform 1/$1; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB' +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 189 +select myfunc(0) +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +STMT: SelectStmt +== 190 +select current_setting('work_mem') +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 191 +select myfunc(1), current_setting('work_mem') +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 192 +-- check current_setting()'s behavior with invalid setting name + +select current_setting('nosuch.setting') +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 193 +-- FAIL +select current_setting('nosuch.setting', false) +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 194 +-- FAIL +select current_setting('nosuch.setting', true) is null +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 195 +-- after this, all three cases should yield 'nada' +set nosuch.setting = 'nada' +-- +STMT: VariableSetStmt +== 196 +select current_setting('nosuch.setting') +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 197 +select current_setting('nosuch.setting', false) +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 198 +select current_setting('nosuch.setting', true) +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 199 +-- Normally, CREATE FUNCTION should complain about invalid values in +-- function SET options; but not if check_function_bodies is off, +-- because that creates ordering hazards for pg_dump + +create function func_with_bad_set() returns int as $$ select 1 $$ +language sql +set default_text_search_config = no_such_config +-- +FUNCTION: name="func_with_bad_set" function="func_with_bad_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 200 +set check_function_bodies = off +-- +STMT: VariableSetStmt +== 201 +create function func_with_bad_set() returns int as $$ select 1 $$ +language sql +set default_text_search_config = no_such_config +-- +FUNCTION: name="func_with_bad_set" function="func_with_bad_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 202 +select func_with_bad_set() +-- +FUNCTION: name="func_with_bad_set" function="func_with_bad_set" schema="" ctx=Call +STMT: SelectStmt +== 203 +reset check_function_bodies +-- +STMT: VariableSetStmt +== 204 +set default_with_oids to f +-- +STMT: VariableSetStmt +== 205 +-- Should not allow to set it to true. +set default_with_oids to t +-- +STMT: VariableSetStmt +== 206 +-- Test GUC categories and flag patterns +SELECT pg_settings_get_flags(NULL) +-- +FUNCTION: name="pg_settings_get_flags" function="pg_settings_get_flags" schema="" ctx=Call +STMT: SelectStmt +== 207 +SELECT pg_settings_get_flags('does_not_exist') +-- +FUNCTION: name="pg_settings_get_flags" function="pg_settings_get_flags" schema="" ctx=Call +STMT: SelectStmt +== 208 +CREATE TABLE tab_settings_flags AS SELECT name, category, + 'EXPLAIN' = ANY(flags) AS explain, + 'NO_RESET' = ANY(flags) AS no_reset, + 'NO_RESET_ALL' = ANY(flags) AS no_reset_all, + 'NOT_IN_SAMPLE' = ANY(flags) AS not_in_sample, + 'RUNTIME_COMPUTED' = ANY(flags) AS runtime_computed + FROM pg_show_all_settings() AS psas, + pg_settings_get_flags(psas.name) AS flags +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=DDL +FUNCTION: name="pg_show_all_settings" function="pg_show_all_settings" schema="" ctx=Call +FUNCTION: name="pg_settings_get_flags" function="pg_settings_get_flags" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 209 +-- Developer GUCs should be flagged with GUC_NOT_IN_SAMPLE: +SELECT name FROM tab_settings_flags + WHERE category = 'Developer Options' AND NOT not_in_sample + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="category" +FILTER: schema="" table="" column="not_in_sample" +STMT: SelectStmt +== 210 +-- Most query-tuning GUCs are flagged as valid for EXPLAIN. +-- default_statistics_target is an exception. +SELECT name FROM tab_settings_flags + WHERE category ~ '^Query Tuning' AND NOT explain + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="category" +FILTER: schema="" table="" column="explain" +STMT: SelectStmt +== 211 +-- Runtime-computed GUCs should be part of the preset category. +SELECT name FROM tab_settings_flags + WHERE NOT category = 'Preset Options' AND runtime_computed + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="category" +FILTER: schema="" table="" column="runtime_computed" +STMT: SelectStmt +== 212 +-- Preset GUCs are flagged as NOT_IN_SAMPLE. +SELECT name FROM tab_settings_flags + WHERE category = 'Preset Options' AND NOT not_in_sample + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="category" +FILTER: schema="" table="" column="not_in_sample" +STMT: SelectStmt +== 213 +-- NO_RESET implies NO_RESET_ALL. +SELECT name FROM tab_settings_flags + WHERE no_reset AND NOT no_reset_all + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="no_reset" +FILTER: schema="" table="" column="no_reset_all" +STMT: SelectStmt +== 214 +DROP TABLE tab_settings_flags +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/hash_func.metadata.json b/parser/testdata/summary/postgres_regress/hash_func.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/hash_func.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/hash_func.test b/parser/testdata/summary/postgres_regress/hash_func.test new file mode 100644 index 0000000..0fdc843 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/hash_func.test @@ -0,0 +1,803 @@ +== 001 +|-- +-- Test hash functions +|-- +-- When the salt is 0, the extended hash function should produce a result +-- whose low 32 bits match the standard hash function. When the salt is +-- not 0, we should get a different result. +|-- + +SELECT v as value, hashint2(v)::bit(32) as standard, + hashint2extended(v, 0)::bit(32) as extended0, + hashint2extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0::int2), (1::int2), (17::int2), (42::int2)) x(v) +WHERE hashint2(v)::bit(32) != hashint2extended(v, 0)::bit(32) + OR hashint2(v)::bit(32) = hashint2extended(v, 1)::bit(32) +-- +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 002 +SELECT v as value, hashint4(v)::bit(32) as standard, + hashint4extended(v, 0)::bit(32) as extended0, + hashint4extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashint4(v)::bit(32) != hashint4extended(v, 0)::bit(32) + OR hashint4(v)::bit(32) = hashint4extended(v, 1)::bit(32) +-- +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 003 +SELECT v as value, hashint8(v)::bit(32) as standard, + hashint8extended(v, 0)::bit(32) as extended0, + hashint8extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashint8(v)::bit(32) != hashint8extended(v, 0)::bit(32) + OR hashint8(v)::bit(32) = hashint8extended(v, 1)::bit(32) +-- +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 004 +SELECT v as value, hashfloat4(v)::bit(32) as standard, + hashfloat4extended(v, 0)::bit(32) as extended0, + hashfloat4extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashfloat4(v)::bit(32) != hashfloat4extended(v, 0)::bit(32) + OR hashfloat4(v)::bit(32) = hashfloat4extended(v, 1)::bit(32) +-- +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 005 +SELECT v as value, hashfloat8(v)::bit(32) as standard, + hashfloat8extended(v, 0)::bit(32) as extended0, + hashfloat8extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashfloat8(v)::bit(32) != hashfloat8extended(v, 0)::bit(32) + OR hashfloat8(v)::bit(32) = hashfloat8extended(v, 1)::bit(32) +-- +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 006 +SELECT v as value, hashoid(v)::bit(32) as standard, + hashoidextended(v, 0)::bit(32) as extended0, + hashoidextended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashoid(v)::bit(32) != hashoidextended(v, 0)::bit(32) + OR hashoid(v)::bit(32) = hashoidextended(v, 1)::bit(32) +-- +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 007 +SELECT v as value, hashchar(v)::bit(32) as standard, + hashcharextended(v, 0)::bit(32) as extended0, + hashcharextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::"char"), ('1'), ('x'), ('X'), ('p'), ('N')) x(v) +WHERE hashchar(v)::bit(32) != hashcharextended(v, 0)::bit(32) + OR hashchar(v)::bit(32) = hashcharextended(v, 1)::bit(32) +-- +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 008 +SELECT v as value, hashname(v)::bit(32) as standard, + hashnameextended(v, 0)::bit(32) as extended0, + hashnameextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL), ('PostgreSQL'), ('eIpUEtqmY89'), ('AXKEJBTK'), + ('muop28x03'), ('yi3nm0d73')) x(v) +WHERE hashname(v)::bit(32) != hashnameextended(v, 0)::bit(32) + OR hashname(v)::bit(32) = hashnameextended(v, 1)::bit(32) +-- +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 009 +SELECT v as value, hashtext(v)::bit(32) as standard, + hashtextextended(v, 0)::bit(32) as extended0, + hashtextextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL), ('PostgreSQL'), ('eIpUEtqmY89'), ('AXKEJBTK'), + ('muop28x03'), ('yi3nm0d73')) x(v) +WHERE hashtext(v)::bit(32) != hashtextextended(v, 0)::bit(32) + OR hashtext(v)::bit(32) = hashtextextended(v, 1)::bit(32) +-- +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 010 +SELECT v as value, hashoidvector(v)::bit(32) as standard, + hashoidvectorextended(v, 0)::bit(32) as extended0, + hashoidvectorextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::oidvector), ('0 1 2 3 4'), ('17 18 19 20'), + ('42 43 42 45'), ('550273 550273 570274'), + ('207112489 207112499 21512 2155 372325 1363252')) x(v) +WHERE hashoidvector(v)::bit(32) != hashoidvectorextended(v, 0)::bit(32) + OR hashoidvector(v)::bit(32) = hashoidvectorextended(v, 1)::bit(32) +-- +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 011 +SELECT v as value, hash_aclitem(v)::bit(32) as standard, + hash_aclitem_extended(v, 0)::bit(32) as extended0, + hash_aclitem_extended(v, 1)::bit(32) as extended1 +FROM (SELECT DISTINCT(relacl[1]) FROM pg_class LIMIT 10) x(v) +WHERE hash_aclitem(v)::bit(32) != hash_aclitem_extended(v, 0)::bit(32) + OR hash_aclitem(v)::bit(32) = hash_aclitem_extended(v, 1)::bit(32) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 012 +SELECT v as value, hashmacaddr(v)::bit(32) as standard, + hashmacaddrextended(v, 0)::bit(32) as extended0, + hashmacaddrextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::macaddr), ('08:00:2b:01:02:04'), ('08:00:2b:01:02:04'), + ('e2:7f:51:3e:70:49'), ('d6:a9:4a:78:1c:d5'), + ('ea:29:b1:5e:1f:a5')) x(v) +WHERE hashmacaddr(v)::bit(32) != hashmacaddrextended(v, 0)::bit(32) + OR hashmacaddr(v)::bit(32) = hashmacaddrextended(v, 1)::bit(32) +-- +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 013 +SELECT v as value, hashinet(v)::bit(32) as standard, + hashinetextended(v, 0)::bit(32) as extended0, + hashinetextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::inet), ('192.168.100.128/25'), ('192.168.100.0/8'), + ('172.168.10.126/16'), ('172.18.103.126/24'), ('192.188.13.16/32')) x(v) +WHERE hashinet(v)::bit(32) != hashinetextended(v, 0)::bit(32) + OR hashinet(v)::bit(32) = hashinetextended(v, 1)::bit(32) +-- +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 014 +SELECT v as value, hash_numeric(v)::bit(32) as standard, + hash_numeric_extended(v, 0)::bit(32) as extended0, + hash_numeric_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1.149484958), (17.149484958), (42.149484958), + (149484958.550273), (2071124898672)) x(v) +WHERE hash_numeric(v)::bit(32) != hash_numeric_extended(v, 0)::bit(32) + OR hash_numeric(v)::bit(32) = hash_numeric_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 015 +SELECT v as value, hashmacaddr8(v)::bit(32) as standard, + hashmacaddr8extended(v, 0)::bit(32) as extended0, + hashmacaddr8extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::macaddr8), ('08:00:2b:01:02:04:36:49'), + ('08:00:2b:01:02:04:f0:e8'), ('e2:7f:51:3e:70:49:16:29'), + ('d6:a9:4a:78:1c:d5:47:32'), ('ea:29:b1:5e:1f:a5')) x(v) +WHERE hashmacaddr8(v)::bit(32) != hashmacaddr8extended(v, 0)::bit(32) + OR hashmacaddr8(v)::bit(32) = hashmacaddr8extended(v, 1)::bit(32) +-- +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 016 +SELECT v as value, hash_array(v)::bit(32) as standard, + hash_array_extended(v, 0)::bit(32) as extended0, + hash_array_extended(v, 1)::bit(32) as extended1 +FROM (VALUES ('{0}'::int4[]), ('{0,1,2,3,4}'), ('{17,18,19,20}'), + ('{42,34,65,98}'), ('{550273,590027, 870273}'), + ('{207112489, 807112489}')) x(v) +WHERE hash_array(v)::bit(32) != hash_array_extended(v, 0)::bit(32) + OR hash_array(v)::bit(32) = hash_array_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 017 +-- array hashing with non-hashable element type +SELECT v as value, hash_array(v)::bit(32) as standard +FROM (VALUES ('{101}'::varbit[])) x(v) +-- +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT v as value, hash_array_extended(v, 0)::bit(32) as extended0 +FROM (VALUES ('{101}'::varbit[])) x(v) +-- +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT v as value, hashbpchar(v)::bit(32) as standard, + hashbpcharextended(v, 0)::bit(32) as extended0, + hashbpcharextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL), ('PostgreSQL'), ('eIpUEtqmY89'), ('AXKEJBTK'), + ('muop28x03'), ('yi3nm0d73')) x(v) +WHERE hashbpchar(v)::bit(32) != hashbpcharextended(v, 0)::bit(32) + OR hashbpchar(v)::bit(32) = hashbpcharextended(v, 1)::bit(32) +-- +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 020 +SELECT v as value, time_hash(v)::bit(32) as standard, + time_hash_extended(v, 0)::bit(32) as extended0, + time_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::time), ('11:09:59'), ('1:09:59'), ('11:59:59'), + ('7:9:59'), ('5:15:59')) x(v) +WHERE time_hash(v)::bit(32) != time_hash_extended(v, 0)::bit(32) + OR time_hash(v)::bit(32) = time_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 021 +SELECT v as value, timetz_hash(v)::bit(32) as standard, + timetz_hash_extended(v, 0)::bit(32) as extended0, + timetz_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::timetz), ('00:11:52.518762-07'), ('00:11:52.51762-08'), + ('00:11:52.62-01'), ('00:11:52.62+01'), ('11:59:59+04')) x(v) +WHERE timetz_hash(v)::bit(32) != timetz_hash_extended(v, 0)::bit(32) + OR timetz_hash(v)::bit(32) = timetz_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 022 +SELECT v as value, interval_hash(v)::bit(32) as standard, + interval_hash_extended(v, 0)::bit(32) as extended0, + interval_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::interval), + ('5 month 7 day 46 minutes'), ('1 year 7 day 46 minutes'), + ('1 year 7 month 20 day 46 minutes'), ('5 month'), + ('17 year 11 month 7 day 9 hours 46 minutes 5 seconds')) x(v) +WHERE interval_hash(v)::bit(32) != interval_hash_extended(v, 0)::bit(32) + OR interval_hash(v)::bit(32) = interval_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 023 +SELECT v as value, timestamp_hash(v)::bit(32) as standard, + timestamp_hash_extended(v, 0)::bit(32) as extended0, + timestamp_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::timestamp), ('2017-08-22 00:09:59.518762'), + ('2015-08-20 00:11:52.51762-08'), + ('2017-05-22 00:11:52.62-01'), + ('2013-08-22 00:11:52.62+01'), ('2013-08-22 11:59:59+04')) x(v) +WHERE timestamp_hash(v)::bit(32) != timestamp_hash_extended(v, 0)::bit(32) + OR timestamp_hash(v)::bit(32) = timestamp_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 024 +SELECT v as value, uuid_hash(v)::bit(32) as standard, + uuid_hash_extended(v, 0)::bit(32) as extended0, + uuid_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::uuid), ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'), + ('5a9ba4ac-8d6f-11e7-bb31-be2e44b06b34'), + ('99c6705c-d939-461c-a3c9-1690ad64ed7b'), + ('7deed3ca-8d6f-11e7-bb31-be2e44b06b34'), + ('9ad46d4f-6f2a-4edd-aadb-745993928e1e')) x(v) +WHERE uuid_hash(v)::bit(32) != uuid_hash_extended(v, 0)::bit(32) + OR uuid_hash(v)::bit(32) = uuid_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 025 +SELECT v as value, pg_lsn_hash(v)::bit(32) as standard, + pg_lsn_hash_extended(v, 0)::bit(32) as extended0, + pg_lsn_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::pg_lsn), ('16/B374D84'), ('30/B374D84'), + ('255/B374D84'), ('25/B379D90'), ('900/F37FD90')) x(v) +WHERE pg_lsn_hash(v)::bit(32) != pg_lsn_hash_extended(v, 0)::bit(32) + OR pg_lsn_hash(v)::bit(32) = pg_lsn_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 026 +CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy') +-- +STMT: CreateEnumStmt +== 027 +SELECT v as value, hashenum(v)::bit(32) as standard, + hashenumextended(v, 0)::bit(32) as extended0, + hashenumextended(v, 1)::bit(32) as extended1 +FROM (VALUES ('sad'::mood), ('ok'), ('happy')) x(v) +WHERE hashenum(v)::bit(32) != hashenumextended(v, 0)::bit(32) + OR hashenum(v)::bit(32) = hashenumextended(v, 1)::bit(32) +-- +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 028 +DROP TYPE mood +-- +STMT: DropStmt +== 029 +SELECT v as value, jsonb_hash(v)::bit(32) as standard, + jsonb_hash_extended(v, 0)::bit(32) as extended0, + jsonb_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::jsonb), + ('{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'), + ('{"foo": [true, "bar"], "tags": {"e": 1, "f": null}}'), + ('{"g": {"h": "value"}}')) x(v) +WHERE jsonb_hash(v)::bit(32) != jsonb_hash_extended(v, 0)::bit(32) + OR jsonb_hash(v)::bit(32) = jsonb_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 030 +SELECT v as value, hash_range(v)::bit(32) as standard, + hash_range_extended(v, 0)::bit(32) as extended0, + hash_range_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (int4range(10, 20)), (int4range(23, 43)), + (int4range(5675, 550273)), + (int4range(550274, 1550274)), (int4range(1550275, 208112489))) x(v) +WHERE hash_range(v)::bit(32) != hash_range_extended(v, 0)::bit(32) + OR hash_range(v)::bit(32) = hash_range_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 031 +SELECT v as value, hash_multirange(v)::bit(32) as standard, + hash_multirange_extended(v, 0)::bit(32) as extended0, + hash_multirange_extended(v, 1)::bit(32) as extended1 +FROM (VALUES ('{[10,20)}'::int4multirange), ('{[23, 43]}'::int4multirange), + ('{[5675, 550273)}'::int4multirange), + ('{[550274, 1550274)}'::int4multirange), + ('{[1550275, 208112489)}'::int4multirange)) x(v) +WHERE hash_multirange(v)::bit(32) != hash_multirange_extended(v, 0)::bit(32) + OR hash_multirange(v)::bit(32) = hash_multirange_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 032 +CREATE TYPE hash_test_t1 AS (a int, b text) +-- +STMT: CompositeTypeStmt +== 033 +SELECT v as value, hash_record(v)::bit(32) as standard, + hash_record_extended(v, 0)::bit(32) as extended0, + hash_record_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (row(1, 'aaa')::hash_test_t1, row(2, 'bbb'), row(-1, 'ccc'))) x(v) +WHERE hash_record(v)::bit(32) != hash_record_extended(v, 0)::bit(32) + OR hash_record(v)::bit(32) = hash_record_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +== 034 +DROP TYPE hash_test_t1 +-- +STMT: DropStmt +== 035 +-- record hashing with non-hashable field type +CREATE TYPE hash_test_t2 AS (a varbit, b text) +-- +STMT: CompositeTypeStmt +== 036 +SELECT v as value, hash_record(v)::bit(32) as standard +FROM (VALUES (row('10'::varbit, 'aaa')::hash_test_t2)) x(v) +-- +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT v as value, hash_record_extended(v, 0)::bit(32) as extended0 +FROM (VALUES (row('11'::varbit, 'aaa')::hash_test_t2)) x(v) +-- +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +STMT: SelectStmt +== 038 +DROP TYPE hash_test_t2 +-- +STMT: DropStmt +== 039 +|-- +-- Check special cases for specific data types +|-- +SELECT hashfloat4('0'::float4) = hashfloat4('-0'::float4) AS t +-- +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT hashfloat4('NaN'::float4) = hashfloat4(-'NaN'::float4) AS t +-- +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +STMT: SelectStmt +== 041 +SELECT hashfloat8('0'::float8) = hashfloat8('-0'::float8) AS t +-- +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +STMT: SelectStmt +== 042 +SELECT hashfloat8('NaN'::float8) = hashfloat8(-'NaN'::float8) AS t +-- +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT hashfloat4('NaN'::float4) = hashfloat8('NaN'::float8) AS t +-- +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/hash_index.metadata.json b/parser/testdata/summary/postgres_regress/hash_index.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/hash_index.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/hash_index.test b/parser/testdata/summary/postgres_regress/hash_index.test new file mode 100644 index 0000000..fbb61bc --- /dev/null +++ b/parser/testdata/summary/postgres_regress/hash_index.test @@ -0,0 +1,688 @@ +== 001 +|-- +-- HASH_INDEX +|-- + +-- directory paths are passed to us in environment variables + +CREATE TABLE hash_i4_heap ( + seqno int4, + random int4 +) +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE hash_name_heap ( + seqno int4, + random name +) +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE hash_txt_heap ( + seqno int4, + random text +) +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE hash_f8_heap ( + seqno int4, + random float8 +) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: CreateStmt +== 005 +COPY hash_i4_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +COPY hash_name_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 26 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +COPY hash_txt_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +COPY hash_f8_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- the data in this file has a lot of duplicates in the index key +-- fields, leading to long bucket chains and lots of table expansion. +-- this is therefore a stress test of the bucket overflow code (unlike +-- the data in hash.data, which has unique index keys). +|-- +-- \set filename :abs_srcdir '/data/hashovfl.data' +-- COPY hash_ovfl_heap FROM :'filename'; + +ANALYZE hash_i4_heap +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DDL +STMT: VacuumStmt +== 010 +ANALYZE hash_name_heap +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DDL +STMT: VacuumStmt +== 011 +ANALYZE hash_txt_heap +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DDL +STMT: VacuumStmt +== 012 +ANALYZE hash_f8_heap +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: VacuumStmt +== 013 +CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops) +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DDL +STMT: IndexStmt +== 014 +CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops) +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DDL +STMT: IndexStmt +== 015 +CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops) +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DDL +STMT: IndexStmt +== 016 +CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops) + WITH (fillfactor=60) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +== 017 +|-- +-- Also try building functional, expressional, and partial indexes on +-- tables that already contain data. +|-- +create unique index hash_f8_index_1 on hash_f8_heap(abs(random)) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 018 +create unique index hash_f8_index_2 on hash_f8_heap((seqno + 1), random) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +== 019 +create unique index hash_f8_index_3 on hash_f8_heap(random) where seqno > 1000 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +== 020 +|-- +-- hash index +-- grep 843938989 hash.data +|-- +SELECT * FROM hash_i4_heap + WHERE hash_i4_heap.random = 843938989 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=Select +FILTER: schema="" table="hash_i4_heap" column="random" +STMT: SelectStmt +== 021 +|-- +-- hash index +-- grep 66766766 hash.data +|-- +SELECT * FROM hash_i4_heap + WHERE hash_i4_heap.random = 66766766 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=Select +FILTER: schema="" table="hash_i4_heap" column="random" +STMT: SelectStmt +== 022 +|-- +-- hash index +-- grep 1505703298 hash.data +|-- +SELECT * FROM hash_name_heap + WHERE hash_name_heap.random = '1505703298'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=Select +FILTER: schema="" table="hash_name_heap" column="random" +STMT: SelectStmt +== 023 +|-- +-- hash index +-- grep 7777777 hash.data +|-- +SELECT * FROM hash_name_heap + WHERE hash_name_heap.random = '7777777'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=Select +FILTER: schema="" table="hash_name_heap" column="random" +STMT: SelectStmt +== 024 +|-- +-- hash index +-- grep 1351610853 hash.data +|-- +SELECT * FROM hash_txt_heap + WHERE hash_txt_heap.random = '1351610853'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=Select +FILTER: schema="" table="hash_txt_heap" column="random" +STMT: SelectStmt +== 025 +|-- +-- hash index +-- grep 111111112222222233333333 hash.data +|-- +SELECT * FROM hash_txt_heap + WHERE hash_txt_heap.random = '111111112222222233333333'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=Select +FILTER: schema="" table="hash_txt_heap" column="random" +STMT: SelectStmt +== 026 +|-- +-- hash index +-- grep 444705537 hash.data +|-- +SELECT * FROM hash_f8_heap + WHERE hash_f8_heap.random = '444705537'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=Select +FILTER: schema="" table="hash_f8_heap" column="random" +STMT: SelectStmt +== 027 +|-- +-- hash index +-- grep 88888888 hash.data +|-- +SELECT * FROM hash_f8_heap + WHERE hash_f8_heap.random = '88888888'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=Select +FILTER: schema="" table="hash_f8_heap" column="random" +STMT: SelectStmt +== 028 +|-- +-- hash index +-- grep '^90[^0-9]' hashovfl.data +|-- +-- SELECT count(*) AS i988 FROM hash_ovfl_heap +-- WHERE x = 90; + +|-- +-- hash index +-- grep '^1000[^0-9]' hashovfl.data +|-- +-- SELECT count(*) AS i0 FROM hash_ovfl_heap +-- WHERE x = 1000; + +|-- +-- HASH +|-- +UPDATE hash_i4_heap + SET random = 1 + WHERE hash_i4_heap.seqno = 1492 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DML +STMT: UpdateStmt +== 029 +SELECT h.seqno AS i1492, h.random AS i1 + FROM hash_i4_heap h + WHERE h.random = 1 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=Select +ALIAS: "h"="hash_i4_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +== 030 +UPDATE hash_i4_heap + SET seqno = 20000 + WHERE hash_i4_heap.random = 1492795354 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DML +STMT: UpdateStmt +== 031 +SELECT h.seqno AS i20000 + FROM hash_i4_heap h + WHERE h.random = 1492795354 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=Select +ALIAS: "h"="hash_i4_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +== 032 +UPDATE hash_name_heap + SET random = '0123456789abcdef'::name + WHERE hash_name_heap.seqno = 6543 +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DML +STMT: UpdateStmt +== 033 +SELECT h.seqno AS i6543, h.random AS c0_to_f + FROM hash_name_heap h + WHERE h.random = '0123456789abcdef'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=Select +ALIAS: "h"="hash_name_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +== 034 +UPDATE hash_name_heap + SET seqno = 20000 + WHERE hash_name_heap.random = '76652222'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DML +STMT: UpdateStmt +== 035 +|-- +-- this is the row we just replaced; index scan should return zero rows +|-- +SELECT h.seqno AS emptyset + FROM hash_name_heap h + WHERE h.random = '76652222'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=Select +ALIAS: "h"="hash_name_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +== 036 +UPDATE hash_txt_heap + SET random = '0123456789abcdefghijklmnop'::text + WHERE hash_txt_heap.seqno = 4002 +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DML +STMT: UpdateStmt +== 037 +SELECT h.seqno AS i4002, h.random AS c0_to_p + FROM hash_txt_heap h + WHERE h.random = '0123456789abcdefghijklmnop'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=Select +ALIAS: "h"="hash_txt_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +== 038 +UPDATE hash_txt_heap + SET seqno = 20000 + WHERE hash_txt_heap.random = '959363399'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DML +STMT: UpdateStmt +== 039 +SELECT h.seqno AS t20000 + FROM hash_txt_heap h + WHERE h.random = '959363399'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=Select +ALIAS: "h"="hash_txt_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +== 040 +UPDATE hash_f8_heap + SET random = '-1234.1234'::float8 + WHERE hash_f8_heap.seqno = 8906 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DML +STMT: UpdateStmt +== 041 +SELECT h.seqno AS i8096, h.random AS f1234_1234 + FROM hash_f8_heap h + WHERE h.random = '-1234.1234'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=Select +ALIAS: "h"="hash_f8_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +== 042 +UPDATE hash_f8_heap + SET seqno = 20000 + WHERE hash_f8_heap.random = '488912369'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DML +STMT: UpdateStmt +== 043 +SELECT h.seqno AS f20000 + FROM hash_f8_heap h + WHERE h.random = '488912369'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=Select +ALIAS: "h"="hash_f8_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +== 044 +-- UPDATE hash_ovfl_heap +-- SET x = 1000 +-- WHERE x = 90; + +-- this vacuums the index as well +-- VACUUM hash_ovfl_heap; + +-- SELECT count(*) AS i0 FROM hash_ovfl_heap +-- WHERE x = 90; + +-- SELECT count(*) AS i988 FROM hash_ovfl_heap +-- WHERE x = 1000; + +|-- +-- Cause some overflow insert and splits. +|-- +CREATE TABLE hash_split_heap (keycol INT) +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DDL +STMT: CreateStmt +== 045 +INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 500) a +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 046 +CREATE INDEX hash_split_index on hash_split_heap USING HASH (keycol) +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DDL +STMT: IndexStmt +== 047 +INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 5000) a +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 048 +-- Let's do a backward scan. +BEGIN +-- +STMT: TransactionStmt +== 049 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 050 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 051 +DECLARE c CURSOR FOR SELECT * from hash_split_heap WHERE keycol = 1 +-- +STMT: DeclareCursorStmt +== 052 +MOVE FORWARD ALL FROM c +-- +STMT: FetchStmt +== 053 +MOVE BACKWARD 10000 FROM c +-- +STMT: FetchStmt +== 054 +MOVE BACKWARD ALL FROM c +-- +STMT: FetchStmt +== 055 +CLOSE c +-- +STMT: ClosePortalStmt +== 056 +END +-- +STMT: TransactionStmt +== 057 +-- DELETE, INSERT, VACUUM. +DELETE FROM hash_split_heap WHERE keycol = 1 +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DML +STMT: DeleteStmt +== 058 +INSERT INTO hash_split_heap SELECT a/2 FROM generate_series(1, 25000) a +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 059 +VACUUM hash_split_heap +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DDL +STMT: VacuumStmt +== 060 +-- Rebuild the index using a different fillfactor +ALTER INDEX hash_split_index SET (fillfactor = 10) +-- +STMT: AlterTableStmt +== 061 +REINDEX INDEX hash_split_index +-- +STMT: ReindexStmt +== 062 +-- Clean up. +DROP TABLE hash_split_heap +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DDL +STMT: DropStmt +== 063 +-- Testcases for removing overflow pages. +CREATE TABLE hash_cleanup_heap(keycol INT) +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: CreateStmt +== 064 +CREATE INDEX hash_cleanup_index on hash_cleanup_heap USING HASH (keycol) +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: IndexStmt +== 065 +-- Insert tuples to both the primary bucket page and overflow pages. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 066 +-- Fill overflow pages by "dead" tuples. +BEGIN +-- +STMT: TransactionStmt +== 067 +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1000) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 068 +ROLLBACK +-- +STMT: TransactionStmt +== 069 +-- Checkpoint will ensure that all hash buffers are cleaned before we try +-- to remove overflow pages. +CHECKPOINT +-- +STMT: CheckPointStmt +== 070 +-- This will squeeze the bucket and remove overflow pages. +VACUUM hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: VacuumStmt +== 071 +TRUNCATE hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: TruncateStmt +== 072 +-- Insert a few tuples so that the primary bucket page doesn't get full and +-- tuples can be moved to it. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 50) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 073 +-- Fill overflow pages by "dead" tuples. +BEGIN +-- +STMT: TransactionStmt +== 074 +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 075 +ROLLBACK +-- +STMT: TransactionStmt +== 076 +-- And insert some tuples again. During squeeze operation, these will be moved +-- to the primary bucket allowing to test freeing intermediate overflow pages. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 077 +CHECKPOINT +-- +STMT: CheckPointStmt +== 078 +VACUUM hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: VacuumStmt +== 079 +TRUNCATE hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: TruncateStmt +== 080 +-- Insert tuples to both the primary bucket page and overflow pages. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 081 +-- Fill overflow pages by "dead" tuples. +BEGIN +-- +STMT: TransactionStmt +== 082 +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 083 +ROLLBACK +-- +STMT: TransactionStmt +== 084 +-- And insert some tuples again. During squeeze operation, these will be moved +-- to other overflow pages and also allow overflow pages filled by dead tuples +-- to be freed. Note the main purpose of this test is to test the case where +-- we don't need to move any tuple from the overflow page being freed. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 50) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 085 +CHECKPOINT +-- +STMT: CheckPointStmt +== 086 +VACUUM hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: VacuumStmt +== 087 +-- Clean up. +DROP TABLE hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: DropStmt +== 088 +-- Index on temp table. +CREATE TEMP TABLE hash_temp_heap (x int, y int) +-- +TABLE: name="hash_temp_heap" schema="" table="hash_temp_heap" ctx=DDL +STMT: CreateStmt +== 089 +INSERT INTO hash_temp_heap VALUES (1,1) +-- +TABLE: name="hash_temp_heap" schema="" table="hash_temp_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 090 +CREATE INDEX hash_idx ON hash_temp_heap USING hash (x) +-- +TABLE: name="hash_temp_heap" schema="" table="hash_temp_heap" ctx=DDL +STMT: IndexStmt +== 091 +DROP TABLE hash_temp_heap CASCADE +-- +TABLE: name="hash_temp_heap" schema="" table="hash_temp_heap" ctx=DDL +STMT: DropStmt +== 092 +-- Float4 type. +CREATE TABLE hash_heap_float4 (x float4, y int) +-- +TABLE: name="hash_heap_float4" schema="" table="hash_heap_float4" ctx=DDL +STMT: CreateStmt +== 093 +INSERT INTO hash_heap_float4 VALUES (1.1,1) +-- +TABLE: name="hash_heap_float4" schema="" table="hash_heap_float4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 094 +CREATE INDEX hash_idx ON hash_heap_float4 USING hash (x) +-- +TABLE: name="hash_heap_float4" schema="" table="hash_heap_float4" ctx=DDL +STMT: IndexStmt +== 095 +DROP TABLE hash_heap_float4 CASCADE +-- +TABLE: name="hash_heap_float4" schema="" table="hash_heap_float4" ctx=DDL +STMT: DropStmt +== 096 +-- Test out-of-range fillfactor values +CREATE INDEX hash_f8_index2 ON hash_f8_heap USING hash (random float8_ops) + WITH (fillfactor=9) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +== 097 +CREATE INDEX hash_f8_index2 ON hash_f8_heap USING hash (random float8_ops) + WITH (fillfactor=101) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt diff --git a/parser/testdata/summary/postgres_regress/hash_part.metadata.json b/parser/testdata/summary/postgres_regress/hash_part.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/hash_part.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/hash_part.test b/parser/testdata/summary/postgres_regress/hash_part.test new file mode 100644 index 0000000..f82e3f4 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/hash_part.test @@ -0,0 +1,184 @@ +== 001 +|-- +-- Hash partitioning. +|-- + +-- Use hand-rolled hash functions and operator classes to get predictable +-- result on different machines. See the definitions of +-- part_test_int4_ops and part_test_text_ops in test_setup.sql. + +CREATE TABLE mchash (a int, b text, c jsonb) + PARTITION BY HASH (a part_test_int4_ops, b part_test_text_ops) +-- +TABLE: name="mchash" schema="" table="mchash" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE mchash1 + PARTITION OF mchash FOR VALUES WITH (MODULUS 4, REMAINDER 0) +-- +TABLE: name="mchash1" schema="" table="mchash1" ctx=DDL +STMT: CreateStmt +== 003 +-- invalid OID, no such table +SELECT satisfies_hash_partition(0, 4, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 004 +-- not partitioned +SELECT satisfies_hash_partition('tenk1'::regclass, 4, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 005 +-- partition rather than the parent +SELECT satisfies_hash_partition('mchash1'::regclass, 4, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 006 +-- invalid modulus +SELECT satisfies_hash_partition('mchash'::regclass, 0, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- remainder too small +SELECT satisfies_hash_partition('mchash'::regclass, 1, -1, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- remainder too large +SELECT satisfies_hash_partition('mchash'::regclass, 1, 1, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- modulus is null +SELECT satisfies_hash_partition('mchash'::regclass, NULL, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 010 +-- remainder is null +SELECT satisfies_hash_partition('mchash'::regclass, 4, NULL, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 011 +-- too many arguments +SELECT satisfies_hash_partition('mchash'::regclass, 4, 0, NULL::int, NULL::text, NULL::json) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- too few arguments +SELECT satisfies_hash_partition('mchash'::regclass, 3, 1, NULL::int) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- wrong argument type +SELECT satisfies_hash_partition('mchash'::regclass, 2, 1, NULL::int, NULL::int) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- ok, should be false +SELECT satisfies_hash_partition('mchash'::regclass, 4, 0, 0, ''::text) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 015 +-- ok, should be true +SELECT satisfies_hash_partition('mchash'::regclass, 4, 0, 2, ''::text) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- argument via variadic syntax, should fail because not all partitioning +-- columns are of the correct type +SELECT satisfies_hash_partition('mchash'::regclass, 2, 1, + variadic array[1,2]::int[]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- multiple partitioning columns of the same type +CREATE TABLE mcinthash (a int, b int, c jsonb) + PARTITION BY HASH (a part_test_int4_ops, b part_test_int4_ops) +-- +TABLE: name="mcinthash" schema="" table="mcinthash" ctx=DDL +STMT: CreateStmt +== 018 +-- now variadic should work, should be false +SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, + variadic array[0, 0]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- should be true +SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, + variadic array[0, 1]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 020 +-- wrong length +SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, + variadic array[]::int[]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 021 +-- wrong type +SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, + variadic array[now(), now()]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- check satisfies_hash_partition passes correct collation +create table text_hashp (a text) partition by hash (a) +-- +TABLE: name="text_hashp" schema="" table="text_hashp" ctx=DDL +STMT: CreateStmt +== 023 +create table text_hashp0 partition of text_hashp for values with (modulus 2, remainder 0) +-- +TABLE: name="text_hashp0" schema="" table="text_hashp0" ctx=DDL +STMT: CreateStmt +== 024 +create table text_hashp1 partition of text_hashp for values with (modulus 2, remainder 1) +-- +TABLE: name="text_hashp1" schema="" table="text_hashp1" ctx=DDL +STMT: CreateStmt +== 025 +-- The result here should always be true, because 'xxx' must belong to +-- one of the two defined partitions +select satisfies_hash_partition('text_hashp'::regclass, 2, 0, 'xxx'::text) OR + satisfies_hash_partition('text_hashp'::regclass, 2, 1, 'xxx'::text) AS satisfies +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +== 026 +-- cleanup +DROP TABLE mchash +-- +TABLE: name="mchash" schema="" table="mchash" ctx=DDL +STMT: DropStmt +== 027 +DROP TABLE mcinthash +-- +TABLE: name="mcinthash" schema="" table="mcinthash" ctx=DDL +STMT: DropStmt +== 028 +DROP TABLE text_hashp +-- +TABLE: name="text_hashp" schema="" table="text_hashp" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/horology.metadata.json b/parser/testdata/summary/postgres_regress/horology.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/horology.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/horology.test b/parser/testdata/summary/postgres_regress/horology.test new file mode 100644 index 0000000..ec11b1b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/horology.test @@ -0,0 +1,1995 @@ +== 001 +|-- +-- HOROLOGY +|-- + +SHOW TimeZone +-- +STMT: VariableShowStmt +== 002 +-- Many of these tests depend on the prevailing settings +SHOW DateStyle +-- +STMT: VariableShowStmt +== 003 +|-- +-- Test various input formats +|-- +SELECT timestamp with time zone '20011227 040506+08' +-- +STMT: SelectStmt +== 004 +SELECT timestamp with time zone '20011227 040506-08' +-- +STMT: SelectStmt +== 005 +SELECT timestamp with time zone '20011227 040506.789+08' +-- +STMT: SelectStmt +== 006 +SELECT timestamp with time zone '20011227 040506.789-08' +-- +STMT: SelectStmt +== 007 +SELECT timestamp with time zone '20011227T040506+08' +-- +STMT: SelectStmt +== 008 +SELECT timestamp with time zone '20011227T040506-08' +-- +STMT: SelectStmt +== 009 +SELECT timestamp with time zone '20011227T040506.789+08' +-- +STMT: SelectStmt +== 010 +SELECT timestamp with time zone '20011227T040506.789-08' +-- +STMT: SelectStmt +== 011 +SELECT timestamp with time zone '2001-12-27 04:05:06.789-08' +-- +STMT: SelectStmt +== 012 +SELECT timestamp with time zone '2001.12.27 04:05:06.789-08' +-- +STMT: SelectStmt +== 013 +SELECT timestamp with time zone '2001/12/27 04:05:06.789-08' +-- +STMT: SelectStmt +== 014 +SELECT timestamp with time zone '12/27/2001 04:05:06.789-08' +-- +STMT: SelectStmt +== 015 +SELECT timestamp with time zone '2001-12-27 04:05:06.789 MET DST' +-- +STMT: SelectStmt +== 016 +SELECT timestamp with time zone '2001-12-27 allballs' +-- +STMT: SelectStmt +== 017 +-- should fail in mdy mode: +SELECT timestamp with time zone '27/12/2001 04:05:06.789-08' +-- +STMT: SelectStmt +== 018 +set datestyle to dmy +-- +STMT: VariableSetStmt +== 019 +SELECT timestamp with time zone '27/12/2001 04:05:06.789-08' +-- +STMT: SelectStmt +== 020 +reset datestyle +-- +STMT: VariableSetStmt +== 021 +SELECT timestamp with time zone 'J2452271+08' +-- +STMT: SelectStmt +== 022 +SELECT timestamp with time zone 'J2452271-08' +-- +STMT: SelectStmt +== 023 +SELECT timestamp with time zone 'J2452271.5+08' +-- +STMT: SelectStmt +== 024 +SELECT timestamp with time zone 'J2452271.5-08' +-- +STMT: SelectStmt +== 025 +SELECT timestamp with time zone 'J2452271 04:05:06+08' +-- +STMT: SelectStmt +== 026 +SELECT timestamp with time zone 'J2452271 04:05:06-08' +-- +STMT: SelectStmt +== 027 +SELECT timestamp with time zone 'J2452271T040506+08' +-- +STMT: SelectStmt +== 028 +SELECT timestamp with time zone 'J2452271T040506-08' +-- +STMT: SelectStmt +== 029 +SELECT timestamp with time zone 'J2452271T040506.789+08' +-- +STMT: SelectStmt +== 030 +SELECT timestamp with time zone 'J2452271T040506.789-08' +-- +STMT: SelectStmt +== 031 +-- German/European-style dates with periods as delimiters +SELECT timestamp with time zone '12.27.2001 04:05:06.789+08' +-- +STMT: SelectStmt +== 032 +SELECT timestamp with time zone '12.27.2001 04:05:06.789-08' +-- +STMT: SelectStmt +== 033 +SET DateStyle = 'German' +-- +STMT: VariableSetStmt +== 034 +SELECT timestamp with time zone '27.12.2001 04:05:06.789+08' +-- +STMT: SelectStmt +== 035 +SELECT timestamp with time zone '27.12.2001 04:05:06.789-08' +-- +STMT: SelectStmt +== 036 +SET DateStyle = 'ISO' +-- +STMT: VariableSetStmt +== 037 +-- As of 7.4, allow time without time zone having a time zone specified +SELECT time without time zone '040506.789+08' +-- +STMT: SelectStmt +== 038 +SELECT time without time zone '040506.789-08' +-- +STMT: SelectStmt +== 039 +SELECT time without time zone 'T040506.789+08' +-- +STMT: SelectStmt +== 040 +SELECT time without time zone 'T040506.789-08' +-- +STMT: SelectStmt +== 041 +SELECT time with time zone '040506.789+08' +-- +STMT: SelectStmt +== 042 +SELECT time with time zone '040506.789-08' +-- +STMT: SelectStmt +== 043 +SELECT time with time zone 'T040506.789+08' +-- +STMT: SelectStmt +== 044 +SELECT time with time zone 'T040506.789-08' +-- +STMT: SelectStmt +== 045 +SELECT time with time zone 'T040506.789 +08' +-- +STMT: SelectStmt +== 046 +SELECT time with time zone 'T040506.789 -08' +-- +STMT: SelectStmt +== 047 +-- time with time zone should accept a date for DST resolution purposes +SELECT time with time zone 'T040506.789 America/Los_Angeles' +-- +STMT: SelectStmt +== 048 +SELECT time with time zone '2001-12-27 T040506.789 America/Los_Angeles' +-- +STMT: SelectStmt +== 049 +SELECT time with time zone 'J2452271 T040506.789 America/Los_Angeles' +-- +STMT: SelectStmt +== 050 +-- Check time formats required by ISO 8601 +SELECT time without time zone '040506.07' +-- +STMT: SelectStmt +== 051 +SELECT time without time zone '04:05:06.07' +-- +STMT: SelectStmt +== 052 +SELECT time without time zone '040506' +-- +STMT: SelectStmt +== 053 +SELECT time without time zone '04:05:06' +-- +STMT: SelectStmt +== 054 +SELECT time without time zone '0405' +-- +STMT: SelectStmt +== 055 +SELECT time without time zone '04:05' +-- +STMT: SelectStmt +== 056 +SELECT time without time zone 'T040506.07' +-- +STMT: SelectStmt +== 057 +SELECT time without time zone 'T04:05:06.07' +-- +STMT: SelectStmt +== 058 +SELECT time without time zone 'T040506' +-- +STMT: SelectStmt +== 059 +SELECT time without time zone 'T04:05:06' +-- +STMT: SelectStmt +== 060 +SELECT time without time zone 'T0405' +-- +STMT: SelectStmt +== 061 +SELECT time without time zone 'T04:05' +-- +STMT: SelectStmt +== 062 +-- 8601 says "Thh" is allowed, but we intentionally reject it as too vague +SELECT time without time zone 'T04' +-- +STMT: SelectStmt +== 063 +SELECT time with time zone '040506.07+08' +-- +STMT: SelectStmt +== 064 +SELECT time with time zone '04:05:06.07+08' +-- +STMT: SelectStmt +== 065 +SELECT time with time zone '040506+08' +-- +STMT: SelectStmt +== 066 +SELECT time with time zone '04:05:06+08' +-- +STMT: SelectStmt +== 067 +SELECT time with time zone '0405+08' +-- +STMT: SelectStmt +== 068 +SELECT time with time zone '04:05+08' +-- +STMT: SelectStmt +== 069 +SELECT time with time zone 'T040506.07+08' +-- +STMT: SelectStmt +== 070 +SELECT time with time zone 'T04:05:06.07+08' +-- +STMT: SelectStmt +== 071 +SELECT time with time zone 'T040506+08' +-- +STMT: SelectStmt +== 072 +SELECT time with time zone 'T04:05:06+08' +-- +STMT: SelectStmt +== 073 +SELECT time with time zone 'T0405+08' +-- +STMT: SelectStmt +== 074 +SELECT time with time zone 'T04:05+08' +-- +STMT: SelectStmt +== 075 +-- 8601 says "Thh" is allowed, but we intentionally reject it as too vague +SELECT time with time zone 'T04+08' +-- +STMT: SelectStmt +== 076 +SET DateStyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +== 077 +-- Check Julian dates BC +SELECT date 'J1520447' AS "Confucius' Birthday" +-- +STMT: SelectStmt +== 078 +SELECT date 'J0' AS "Julian Epoch" +-- +STMT: SelectStmt +== 079 +-- test error on dangling Julian units +SELECT date '1995-08-06 J J J' +-- +STMT: SelectStmt +== 080 +SELECT date 'J J 1520447' +-- +STMT: SelectStmt +== 081 +-- We used to accept this input style, but it was based on a misreading +-- of ISO8601, and it was never documented anyway +SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789+08' +-- +STMT: SelectStmt +== 082 +SELECT timestamp with time zone 'Y2001M12D27H04MM05S06.789-08' +-- +STMT: SelectStmt +== 083 +-- conflicting fields should throw errors +SELECT date '1995-08-06 epoch' +-- +STMT: SelectStmt +== 084 +SELECT date '1995-08-06 infinity' +-- +STMT: SelectStmt +== 085 +SELECT date '1995-08-06 -infinity' +-- +STMT: SelectStmt +== 086 +SELECT date 'today infinity' +-- +STMT: SelectStmt +== 087 +SELECT date '-infinity infinity' +-- +STMT: SelectStmt +== 088 +SELECT timestamp '1995-08-06 epoch' +-- +STMT: SelectStmt +== 089 +SELECT timestamp '1995-08-06 infinity' +-- +STMT: SelectStmt +== 090 +SELECT timestamp '1995-08-06 -infinity' +-- +STMT: SelectStmt +== 091 +SELECT timestamp 'epoch 01:01:01' +-- +STMT: SelectStmt +== 092 +SELECT timestamp 'infinity 01:01:01' +-- +STMT: SelectStmt +== 093 +SELECT timestamp '-infinity 01:01:01' +-- +STMT: SelectStmt +== 094 +SELECT timestamp 'now epoch' +-- +STMT: SelectStmt +== 095 +SELECT timestamp '-infinity infinity' +-- +STMT: SelectStmt +== 096 +SELECT timestamptz '1995-08-06 epoch' +-- +STMT: SelectStmt +== 097 +SELECT timestamptz '1995-08-06 infinity' +-- +STMT: SelectStmt +== 098 +SELECT timestamptz '1995-08-06 -infinity' +-- +STMT: SelectStmt +== 099 +SELECT timestamptz 'epoch 01:01:01' +-- +STMT: SelectStmt +== 100 +SELECT timestamptz 'infinity 01:01:01' +-- +STMT: SelectStmt +== 101 +SELECT timestamptz '-infinity 01:01:01' +-- +STMT: SelectStmt +== 102 +SELECT timestamptz 'now epoch' +-- +STMT: SelectStmt +== 103 +SELECT timestamptz '-infinity infinity' +-- +STMT: SelectStmt +== 104 +|-- +-- date, time arithmetic +|-- + +SELECT date '1981-02-03' + time '04:05:06' AS "Date + Time" +-- +STMT: SelectStmt +== 105 +SELECT date '1991-02-03' + time with time zone '04:05:06 PST' AS "Date + Time PST" +-- +STMT: SelectStmt +== 106 +SELECT date '2001-02-03' + time with time zone '04:05:06 UTC' AS "Date + Time UTC" +-- +STMT: SelectStmt +== 107 +SELECT date '1991-02-03' + interval '2 years' AS "Add Two Years" +-- +STMT: SelectStmt +== 108 +SELECT date '2001-12-13' - interval '2 years' AS "Subtract Two Years" +-- +STMT: SelectStmt +== 109 +-- subtract time from date should not make sense; use interval instead +SELECT date '1991-02-03' - time '04:05:06' AS "Subtract Time" +-- +STMT: SelectStmt +== 110 +SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time UTC" +-- +STMT: SelectStmt +== 111 +|-- +-- timestamp, interval arithmetic +|-- + +SELECT timestamp without time zone '1996-03-01' - interval '1 second' AS "Feb 29" +-- +STMT: SelectStmt +== 112 +SELECT timestamp without time zone '1999-03-01' - interval '1 second' AS "Feb 28" +-- +STMT: SelectStmt +== 113 +SELECT timestamp without time zone '2000-03-01' - interval '1 second' AS "Feb 29" +-- +STMT: SelectStmt +== 114 +SELECT timestamp without time zone '1999-12-01' + interval '1 month - 1 second' AS "Dec 31" +-- +STMT: SelectStmt +== 115 +SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '106000000 days' AS "Feb 23, 285506" +-- +STMT: SelectStmt +== 116 +SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '107000000 days' AS "Jan 20, 288244" +-- +STMT: SelectStmt +== 117 +SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '109203489 days' AS "Dec 31, 294276" +-- +STMT: SelectStmt +== 118 +SELECT timestamp without time zone '2000-01-01' - interval '2483590 days' AS "out of range" +-- +STMT: SelectStmt +== 119 +SELECT timestamp without time zone '294276-12-31 23:59:59' + interval '9223372036854775807 microseconds' AS "out of range" +-- +STMT: SelectStmt +== 120 +SELECT timestamp without time zone '12/31/294276' - timestamp without time zone '12/23/1999' AS "106751991 Days" +-- +STMT: SelectStmt +== 121 +-- Shorthand values +-- Not directly usable for regression testing since these are not constants. +-- So, just try to test parser and hope for the best - thomas 97/04/26 +SELECT (timestamp without time zone 'today' = (timestamp without time zone 'yesterday' + interval '1 day')) as "True" +-- +STMT: SelectStmt +== 122 +SELECT (timestamp without time zone 'today' = (timestamp without time zone 'tomorrow' - interval '1 day')) as "True" +-- +STMT: SelectStmt +== 123 +SELECT (timestamp without time zone 'today 10:30' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True" +-- +STMT: SelectStmt +== 124 +SELECT (timestamp without time zone '10:30 today' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True" +-- +STMT: SelectStmt +== 125 +SELECT (timestamp without time zone 'tomorrow' = (timestamp without time zone 'yesterday' + interval '2 days')) as "True" +-- +STMT: SelectStmt +== 126 +SELECT (timestamp without time zone 'tomorrow 16:00:00' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True" +-- +STMT: SelectStmt +== 127 +SELECT (timestamp without time zone '16:00:00 tomorrow' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True" +-- +STMT: SelectStmt +== 128 +SELECT (timestamp without time zone 'yesterday 12:34:56' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True" +-- +STMT: SelectStmt +== 129 +SELECT (timestamp without time zone '12:34:56 yesterday' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True" +-- +STMT: SelectStmt +== 130 +SELECT (timestamp without time zone 'tomorrow' > 'now') as "True" +-- +STMT: SelectStmt +== 131 +-- Convert from date and time to timestamp +-- This test used to be timestamp(date,time) but no longer allowed by grammar +-- to enable support for SQL99 timestamp type syntax. +SELECT date '1994-01-01' + time '11:00' AS "Jan_01_1994_11am" +-- +STMT: SelectStmt +== 132 +SELECT date '1994-01-01' + time '10:00' AS "Jan_01_1994_10am" +-- +STMT: SelectStmt +== 133 +SELECT date '1994-01-01' + timetz '11:00-5' AS "Jan_01_1994_8am" +-- +STMT: SelectStmt +== 134 +SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 135 +SELECT d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 136 +SELECT d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 137 +SELECT timestamp with time zone '1996-03-01' - interval '1 second' AS "Feb 29" +-- +STMT: SelectStmt +== 138 +SELECT timestamp with time zone '1999-03-01' - interval '1 second' AS "Feb 28" +-- +STMT: SelectStmt +== 139 +SELECT timestamp with time zone '2000-03-01' - interval '1 second' AS "Feb 29" +-- +STMT: SelectStmt +== 140 +SELECT timestamp with time zone '1999-12-01' + interval '1 month - 1 second' AS "Dec 31" +-- +STMT: SelectStmt +== 141 +SELECT timestamp with time zone '2000-01-01' - interval '2483590 days' AS "out of range" +-- +STMT: SelectStmt +== 142 +SELECT timestamp with time zone '294276-12-31 23:59:59 UTC' + interval '9223372036854775807 microseconds' AS "out of range" +-- +STMT: SelectStmt +== 143 +SELECT (timestamp with time zone 'today' = (timestamp with time zone 'yesterday' + interval '1 day')) as "True" +-- +STMT: SelectStmt +== 144 +SELECT (timestamp with time zone 'today' = (timestamp with time zone 'tomorrow' - interval '1 day')) as "True" +-- +STMT: SelectStmt +== 145 +SELECT (timestamp with time zone 'tomorrow' = (timestamp with time zone 'yesterday' + interval '2 days')) as "True" +-- +STMT: SelectStmt +== 146 +SELECT (timestamp with time zone 'tomorrow' > 'now') as "True" +-- +STMT: SelectStmt +== 147 +-- timestamp with time zone, interval arithmetic around DST change +-- (just for fun, let's use an intentionally nonstandard POSIX zone spec) +SET TIME ZONE 'CST7CDT,M4.1.0,M10.5.0' +-- +STMT: VariableSetStmt +== 148 +SELECT timestamp with time zone '2005-04-02 12:00-07' + interval '1 day' as "Apr 3, 12:00" +-- +STMT: SelectStmt +== 149 +SELECT timestamp with time zone '2005-04-02 12:00-07' + interval '24 hours' as "Apr 3, 13:00" +-- +STMT: SelectStmt +== 150 +SELECT timestamp with time zone '2005-04-03 12:00-06' - interval '1 day' as "Apr 2, 12:00" +-- +STMT: SelectStmt +== 151 +SELECT timestamp with time zone '2005-04-03 12:00-06' - interval '24 hours' as "Apr 2, 11:00" +-- +STMT: SelectStmt +== 152 +RESET TIME ZONE +-- +STMT: VariableSetStmt +== 153 +SELECT timestamptz(date '1994-01-01', time '11:00') AS "Jan_01_1994_10am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 154 +SELECT timestamptz(date '1994-01-01', time '10:00') AS "Jan_01_1994_9am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 155 +SELECT timestamptz(date '1994-01-01', time with time zone '11:00-8') AS "Jan_01_1994_11am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 156 +SELECT timestamptz(date '1994-01-01', time with time zone '10:00-8') AS "Jan_01_1994_10am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 157 +SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 158 +SELECT d1 + interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +STMT: SelectStmt +== 159 +SELECT d1 - interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +STMT: SelectStmt +== 160 +|-- +-- time, interval arithmetic +|-- + +SELECT CAST(time '01:02' AS interval) AS "+01:02" +-- +STMT: SelectStmt +== 161 +SELECT CAST(interval '02:03' AS time) AS "02:03:00" +-- +STMT: SelectStmt +== 162 +SELECT CAST(interval '-02:03' AS time) AS "21:57:00" +-- +STMT: SelectStmt +== 163 +SELECT CAST(interval '-9223372022400000000 us' AS time) AS "00:00:00" +-- +STMT: SelectStmt +== 164 +SELECT time '01:30' + interval '02:01' AS "03:31:00" +-- +STMT: SelectStmt +== 165 +SELECT time '01:30' - interval '02:01' AS "23:29:00" +-- +STMT: SelectStmt +== 166 +SELECT time '02:30' + interval '36:01' AS "14:31:00" +-- +STMT: SelectStmt +== 167 +SELECT time '03:30' + interval '1 month 04:01' AS "07:31:00" +-- +STMT: SelectStmt +== 168 +SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01" +-- +STMT: SelectStmt +== 169 +SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08" +-- +STMT: SelectStmt +== 170 +SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08" +-- +STMT: SelectStmt +== 171 +SELECT time with time zone '02:30-08' + interval '36:01' AS "14:31:00-08" +-- +STMT: SelectStmt +== 172 +-- These two tests cannot be used because they default to current timezone, +-- which may be either -08 or -07 depending on the time of year. +-- SELECT time with time zone '01:30' + interval '02:01' AS "03:31:00-08"; +-- SELECT time with time zone '03:30' + interval '1 month 04:01' AS "07:31:00-08"; +-- Try the following two tests instead, as a poor substitute + +SELECT CAST(CAST(date 'today' + time with time zone '05:30' + + interval '02:01' AS time with time zone) AS time) AS "07:31:00" +-- +STMT: SelectStmt +== 173 +SELECT CAST(cast(date 'today' + time with time zone '03:30' + + interval '1 month 04:01' as timestamp without time zone) AS time) AS "07:31:00" +-- +STMT: SelectStmt +== 174 +SELECT t.d1 AS t, i.f1 AS i, t.d1 + i.f1 AS "add", t.d1 - i.f1 AS "subtract" + FROM TIMESTAMP_TBL t, INTERVAL_TBL i + WHERE t.d1 BETWEEN '1990-01-01' AND '2001-01-01' + AND i.f1 BETWEEN '00:00' AND '23:00' + ORDER BY 1,2 +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "i"="interval_tbl" +ALIAS: "t"="timestamp_tbl" +FILTER: schema="" table="t" column="d1" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 175 +SELECT t.f1 AS t, i.f1 AS i, t.f1 + i.f1 AS "add", t.f1 - i.f1 AS "subtract" + FROM TIME_TBL t, INTERVAL_TBL i + WHERE isfinite(i.f1) + ORDER BY 1,2 +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "i"="interval_tbl" +ALIAS: "t"="time_tbl" +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 176 +SELECT t.f1 AS t, i.f1 AS i, t.f1 + i.f1 AS "add", t.f1 - i.f1 AS "subtract" + FROM TIMETZ_TBL t, INTERVAL_TBL i + WHERE isfinite(i.f1) + ORDER BY 1,2 +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "i"="interval_tbl" +ALIAS: "t"="timetz_tbl" +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 177 +-- SQL9x OVERLAPS operator +-- test with time zone +SELECT (timestamp with time zone '2000-11-27', timestamp with time zone '2000-11-28') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 178 +SELECT (timestamp with time zone '2000-11-26', timestamp with time zone '2000-11-27') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 179 +SELECT (timestamp with time zone '2000-11-27', timestamp with time zone '2000-11-28') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', interval '1 day') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 180 +SELECT (timestamp with time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 181 +SELECT (timestamp with time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp with time zone '2000-11-27', interval '12 hours') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 182 +SELECT (timestamp with time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', interval '12 hours') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 183 +-- test without time zone +SELECT (timestamp without time zone '2000-11-27', timestamp without time zone '2000-11-28') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 184 +SELECT (timestamp without time zone '2000-11-26', timestamp without time zone '2000-11-27') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 185 +SELECT (timestamp without time zone '2000-11-27', timestamp without time zone '2000-11-28') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', interval '1 day') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 186 +SELECT (timestamp without time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 187 +SELECT (timestamp without time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp without time zone '2000-11-27', interval '12 hours') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 188 +SELECT (timestamp without time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', interval '12 hours') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 189 +-- test time and interval +SELECT (time '00:00', time '01:00') + OVERLAPS (time '00:30', time '01:30') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 190 +SELECT (time '00:00', interval '1 hour') + OVERLAPS (time '00:30', interval '1 hour') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 191 +SELECT (time '00:00', interval '1 hour') + OVERLAPS (time '01:30', interval '1 hour') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 192 +-- SQL99 seems to want this to be false (and we conform to the spec). +-- istm that this *should* return true, on the theory that time +-- intervals can wrap around the day boundary - thomas 2001-09-25 +SELECT (time '00:00', interval '1 hour') + OVERLAPS (time '01:30', interval '1 day') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 193 +CREATE TABLE TEMP_TIMESTAMP (f1 timestamp with time zone) +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=DDL +STMT: CreateStmt +== 194 +-- get some candidate input values + +INSERT INTO TEMP_TIMESTAMP (f1) + SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 BETWEEN '13-jun-1957' AND '1-jan-1997' + OR d1 BETWEEN '1-jan-1999' AND '1-jan-2010' +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=DML +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +FILTER: schema="" table="" column="d1" +STMT: InsertStmt +STMT: SelectStmt +== 195 +SELECT f1 AS "timestamp" + FROM TEMP_TIMESTAMP + ORDER BY "timestamp" +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +STMT: SelectStmt +== 196 +SELECT d.f1 AS "timestamp", t.f1 AS "interval", d.f1 + t.f1 AS plus + FROM TEMP_TIMESTAMP d, INTERVAL_TBL t + ORDER BY plus, "timestamp", "interval" +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "d"="temp_timestamp" +ALIAS: "t"="interval_tbl" +STMT: SelectStmt +== 197 +SELECT d.f1 AS "timestamp", t.f1 AS "interval", d.f1 - t.f1 AS minus + FROM TEMP_TIMESTAMP d, INTERVAL_TBL t + ORDER BY minus, "timestamp", "interval" +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "d"="temp_timestamp" +ALIAS: "t"="interval_tbl" +STMT: SelectStmt +== 198 +SELECT d.f1 AS "timestamp", + timestamp with time zone '1980-01-06 00:00 GMT' AS gpstime_zero, + d.f1 - timestamp with time zone '1980-01-06 00:00 GMT' AS difference + FROM TEMP_TIMESTAMP d + ORDER BY difference +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +ALIAS: "d"="temp_timestamp" +STMT: SelectStmt +== 199 +SELECT d1.f1 AS timestamp1, d2.f1 AS timestamp2, d1.f1 - d2.f1 AS difference + FROM TEMP_TIMESTAMP d1, TEMP_TIMESTAMP d2 + ORDER BY timestamp1, timestamp2, difference +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +ALIAS: "d1"="temp_timestamp" +ALIAS: "d2"="temp_timestamp" +STMT: SelectStmt +== 200 +|-- +-- Conversions +|-- + +SELECT f1 AS "timestamp", date(f1) AS date + FROM TEMP_TIMESTAMP + WHERE f1 <> timestamp 'now' + ORDER BY date, "timestamp" +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +FUNCTION: name="date" function="date" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 201 +DROP TABLE TEMP_TIMESTAMP +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=DDL +STMT: DropStmt +== 202 +|-- +-- Comparisons between datetime types, especially overflow cases +--- + +SELECT '2202020-10-05'::date::timestamp +-- +STMT: SelectStmt +== 203 +-- fail +SELECT '2202020-10-05'::date > '2020-10-05'::timestamp as t +-- +STMT: SelectStmt +== 204 +SELECT '2020-10-05'::timestamp > '2202020-10-05'::date as f +-- +STMT: SelectStmt +== 205 +SELECT '2202020-10-05'::date::timestamptz +-- +STMT: SelectStmt +== 206 +-- fail +SELECT '2202020-10-05'::date > '2020-10-05'::timestamptz as t +-- +STMT: SelectStmt +== 207 +SELECT '2020-10-05'::timestamptz > '2202020-10-05'::date as f +-- +STMT: SelectStmt +== 208 +-- This conversion may work depending on timezone +SELECT '4714-11-24 BC'::date::timestamptz +-- +STMT: SelectStmt +== 209 +SET TimeZone = 'UTC-2' +-- +STMT: VariableSetStmt +== 210 +SELECT '4714-11-24 BC'::date::timestamptz +-- +STMT: SelectStmt +== 211 +-- fail + +SELECT '4714-11-24 BC'::date < '2020-10-05'::timestamptz as t +-- +STMT: SelectStmt +== 212 +SELECT '2020-10-05'::timestamptz >= '4714-11-24 BC'::date as t +-- +STMT: SelectStmt +== 213 +SELECT '4714-11-24 BC'::timestamp < '2020-10-05'::timestamptz as t +-- +STMT: SelectStmt +== 214 +SELECT '2020-10-05'::timestamptz >= '4714-11-24 BC'::timestamp as t +-- +STMT: SelectStmt +== 215 +RESET TimeZone +-- +STMT: VariableSetStmt +== 216 +|-- +-- Tests for BETWEEN +|-- + +explain (costs off) +select count(*) from date_tbl + where f1 between '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 217 +select count(*) from date_tbl + where f1 between '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 218 +explain (costs off) +select count(*) from date_tbl + where f1 not between '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 219 +select count(*) from date_tbl + where f1 not between '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 220 +explain (costs off) +select count(*) from date_tbl + where f1 between symmetric '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 221 +select count(*) from date_tbl + where f1 between symmetric '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 222 +explain (costs off) +select count(*) from date_tbl + where f1 not between symmetric '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 223 +select count(*) from date_tbl + where f1 not between symmetric '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 224 +|-- +-- Formats +|-- + +SET DateStyle TO 'US,Postgres' +-- +STMT: VariableSetStmt +== 225 +SHOW DateStyle +-- +STMT: VariableShowStmt +== 226 +SELECT d1 AS us_postgres FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 227 +SET DateStyle TO 'US,ISO' +-- +STMT: VariableSetStmt +== 228 +SELECT d1 AS us_iso FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 229 +SET DateStyle TO 'US,SQL' +-- +STMT: VariableSetStmt +== 230 +SHOW DateStyle +-- +STMT: VariableShowStmt +== 231 +SELECT d1 AS us_sql FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 232 +SET DateStyle TO 'European,Postgres' +-- +STMT: VariableSetStmt +== 233 +SHOW DateStyle +-- +STMT: VariableShowStmt +== 234 +INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 235 +SELECT count(*) as one FROM TIMESTAMP_TBL WHERE d1 = 'Jun 13 1957' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 236 +SELECT d1 AS european_postgres FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 237 +SET DateStyle TO 'European,ISO' +-- +STMT: VariableSetStmt +== 238 +SHOW DateStyle +-- +STMT: VariableShowStmt +== 239 +SELECT d1 AS european_iso FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 240 +SET DateStyle TO 'European,SQL' +-- +STMT: VariableSetStmt +== 241 +SHOW DateStyle +-- +STMT: VariableShowStmt +== 242 +SELECT d1 AS european_sql FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 243 +RESET DateStyle +-- +STMT: VariableSetStmt +== 244 +|-- +-- to_timestamp() +|-- + +SELECT to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 245 +SELECT to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 246 +SELECT to_timestamp('2011$03!18 23_38_15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 247 +SELECT to_timestamp('1985 January 12', 'YYYY FMMonth DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 248 +SELECT to_timestamp('1985 FMMonth 12', 'YYYY "FMMonth" DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 249 +SELECT to_timestamp('1985 \ 12', 'YYYY \\ DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 250 +SELECT to_timestamp('My birthday-> Year: 1976, Month: May, Day: 16', + '"My birthday-> Year:" YYYY, "Month:" FMMonth, "Day:" DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 251 +SELECT to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 252 +SELECT to_timestamp('15 "text between quote marks" 98 54 45', + E'HH24 "\\"text between quote marks\\"" YY MI SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 253 +SELECT to_timestamp('05121445482000', 'MMDDHH24MISSYYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 254 +SELECT to_timestamp('2000January09Sunday', 'YYYYFMMonthDDFMDay') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 255 +SELECT to_timestamp('97/Feb/16', 'YYMonDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 256 +SELECT to_timestamp('97/Feb/16', 'YY:Mon:DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 257 +SELECT to_timestamp('97/Feb/16', 'FXYY:Mon:DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 258 +SELECT to_timestamp('97/Feb/16', 'FXYY/Mon/DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 259 +SELECT to_timestamp('19971116', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 260 +SELECT to_timestamp('20000-1116', 'YYYY-MMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 261 +SELECT to_timestamp('1997 AD 11 16', 'YYYY BC MM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 262 +SELECT to_timestamp('1997 BC 11 16', 'YYYY BC MM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 263 +SELECT to_timestamp('1997 A.D. 11 16', 'YYYY B.C. MM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 264 +SELECT to_timestamp('1997 B.C. 11 16', 'YYYY B.C. MM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 265 +SELECT to_timestamp('9-1116', 'Y-MMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 266 +SELECT to_timestamp('95-1116', 'YY-MMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 267 +SELECT to_timestamp('995-1116', 'YYY-MMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 268 +SELECT to_timestamp('2005426', 'YYYYWWD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 269 +SELECT to_timestamp('2005300', 'YYYYDDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 270 +SELECT to_timestamp('2005527', 'IYYYIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 271 +SELECT to_timestamp('005527', 'IYYIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 272 +SELECT to_timestamp('05527', 'IYIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 273 +SELECT to_timestamp('5527', 'IIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 274 +SELECT to_timestamp('2005364', 'IYYYIDDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 275 +SELECT to_timestamp('20050302', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 276 +SELECT to_timestamp('2005 03 02', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 277 +SELECT to_timestamp(' 2005 03 02', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 278 +SELECT to_timestamp(' 20050302', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 279 +SELECT to_timestamp('2011-12-18 11:38 AM', 'YYYY-MM-DD HH12:MI PM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 280 +SELECT to_timestamp('2011-12-18 11:38 PM', 'YYYY-MM-DD HH12:MI PM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 281 +SELECT to_timestamp('2011-12-18 11:38 A.M.', 'YYYY-MM-DD HH12:MI P.M.') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 282 +SELECT to_timestamp('2011-12-18 11:38 P.M.', 'YYYY-MM-DD HH12:MI P.M.') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 283 +SELECT to_timestamp('2011-12-18 11:38 +05', 'YYYY-MM-DD HH12:MI TZH') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 284 +SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI TZH') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 285 +SELECT to_timestamp('2011-12-18 11:38 +05:20', 'YYYY-MM-DD HH12:MI TZH:TZM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 286 +SELECT to_timestamp('2011-12-18 11:38 -05:20', 'YYYY-MM-DD HH12:MI TZH:TZM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 287 +SELECT to_timestamp('2011-12-18 11:38 20', 'YYYY-MM-DD HH12:MI TZM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 288 +SELECT to_timestamp('2011-12-18 11:38 EST', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 289 +SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 290 +SELECT to_timestamp('2011-12-18 11:38 +01:30', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 291 +SELECT to_timestamp('2011-12-18 11:38 MSK', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 292 +-- dyntz +SELECT to_timestamp('2011-12-18 11:38ESTFOO24', 'YYYY-MM-DD HH12:MITZFOOSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 293 +SELECT to_timestamp('2011-12-18 11:38-05FOO24', 'YYYY-MM-DD HH12:MITZFOOSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 294 +SELECT to_timestamp('2011-12-18 11:38 JUNK', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 295 +-- error +SELECT to_timestamp('2011-12-18 11:38 ...', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 296 +-- error + +SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI OF') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 297 +SELECT to_timestamp('2011-12-18 11:38 +01:30', 'YYYY-MM-DD HH12:MI OF') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 298 +SELECT to_timestamp('2011-12-18 11:38 +xyz', 'YYYY-MM-DD HH12:MI OF') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 299 +-- error +SELECT to_timestamp('2011-12-18 11:38 +01:xyz', 'YYYY-MM-DD HH12:MI OF') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 300 +-- error + +SELECT to_timestamp('2018-11-02 12:34:56.025', 'YYYY-MM-DD HH24:MI:SS.MS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 301 +SELECT i, to_timestamp('2018-11-02 12:34:56', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 302 +SELECT i, to_timestamp('2018-11-02 12:34:56.1', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 303 +SELECT i, to_timestamp('2018-11-02 12:34:56.12', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 304 +SELECT i, to_timestamp('2018-11-02 12:34:56.123', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 305 +SELECT i, to_timestamp('2018-11-02 12:34:56.1234', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 306 +SELECT i, to_timestamp('2018-11-02 12:34:56.12345', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 307 +SELECT i, to_timestamp('2018-11-02 12:34:56.123456', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 308 +SELECT i, to_timestamp('2018-11-02 12:34:56.123456789', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 309 +SELECT i, to_timestamp('20181102123456123456', 'YYYYMMDDHH24MISSFF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 310 +SELECT to_date('1 4 1902', 'Q MM YYYY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 311 +-- Q is ignored +SELECT to_date('3 4 21 01', 'W MM CC YY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 312 +SELECT to_date('2458872', 'J') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 313 +|-- +-- Check handling of BC dates +|-- + +SELECT to_date('44-02-01 BC','YYYY-MM-DD BC') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 314 +SELECT to_date('-44-02-01','YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 315 +SELECT to_date('-44-02-01 BC','YYYY-MM-DD BC') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 316 +SELECT to_timestamp('44-02-01 11:12:13 BC','YYYY-MM-DD HH24:MI:SS BC') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 317 +SELECT to_timestamp('-44-02-01 11:12:13','YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 318 +SELECT to_timestamp('-44-02-01 11:12:13 BC','YYYY-MM-DD HH24:MI:SS BC') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 319 +|-- +-- Check handling of multiple spaces in format and/or input +|-- + +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 320 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 321 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 322 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 323 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 324 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 325 +SELECT to_timestamp('2000+ JUN', 'YYYY/MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 326 +SELECT to_timestamp(' 2000 +JUN', 'YYYY/MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 327 +SELECT to_timestamp(' 2000 +JUN', 'YYYY//MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 328 +SELECT to_timestamp('2000 +JUN', 'YYYY//MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 329 +SELECT to_timestamp('2000 + JUN', 'YYYY MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 330 +SELECT to_timestamp('2000 ++ JUN', 'YYYY MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 331 +SELECT to_timestamp('2000 + + JUN', 'YYYY MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 332 +SELECT to_timestamp('2000 + + JUN', 'YYYY MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 333 +SELECT to_timestamp('2000 -10', 'YYYY TZH') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 334 +SELECT to_timestamp('2000 -10', 'YYYY TZH') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 335 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 336 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 337 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 338 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 339 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 340 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 341 +SELECT to_date('2011 12 18', 'YYYYxMMxDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 342 +SELECT to_date('2011x 12x 18', 'YYYYxMMxDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 343 +SELECT to_date('2011 x12 x18', 'YYYYxMMxDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 344 +|-- +-- Check errors for some incorrect usages of to_timestamp() and to_date() +|-- + +-- Mixture of date conventions (ISO week and Gregorian): +SELECT to_timestamp('2005527', 'YYYYIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 345 +-- Insufficient characters in the source string: +SELECT to_timestamp('19971', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 346 +-- Insufficient digit characters for a single node: +SELECT to_timestamp('19971)24', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 347 +-- We don't accept full-length day or month names if short form is specified: +SELECT to_timestamp('Friday 1-January-1999', 'DY DD MON YYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 348 +SELECT to_timestamp('Fri 1-January-1999', 'DY DD MON YYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 349 +SELECT to_timestamp('Fri 1-Jan-1999', 'DY DD MON YYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 350 +-- ok + +-- Value clobbering: +SELECT to_timestamp('1997-11-Jan-16', 'YYYY-MM-Mon-DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 351 +-- Non-numeric input: +SELECT to_timestamp('199711xy', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 352 +-- Input that doesn't fit in an int: +SELECT to_timestamp('10000000000', 'FMYYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 353 +-- Out-of-range and not-quite-out-of-range fields: +SELECT to_timestamp('2016-06-13 25:00:00', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 354 +SELECT to_timestamp('2016-06-13 15:60:00', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 355 +SELECT to_timestamp('2016-06-13 15:50:60', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 356 +SELECT to_timestamp('2016-06-13 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 357 +-- ok +SELECT to_timestamp('2016-06-13 15:50:55', 'YYYY-MM-DD HH:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 358 +SELECT to_timestamp('2016-13-01 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 359 +SELECT to_timestamp('2016-02-30 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 360 +SELECT to_timestamp('2016-02-29 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 361 +-- ok +SELECT to_timestamp('2015-02-29 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 362 +SELECT to_timestamp('2015-02-11 86000', 'YYYY-MM-DD SSSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 363 +-- ok +SELECT to_timestamp('2015-02-11 86400', 'YYYY-MM-DD SSSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 364 +SELECT to_timestamp('2015-02-11 86000', 'YYYY-MM-DD SSSSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 365 +-- ok +SELECT to_timestamp('2015-02-11 86400', 'YYYY-MM-DD SSSSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 366 +SELECT to_date('2016-13-10', 'YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 367 +SELECT to_date('2016-02-30', 'YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 368 +SELECT to_date('2016-02-29', 'YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 369 +-- ok +SELECT to_date('2015-02-29', 'YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 370 +SELECT to_date('2015 365', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 371 +-- ok +SELECT to_date('2015 366', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 372 +SELECT to_date('2016 365', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 373 +-- ok +SELECT to_date('2016 366', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 374 +-- ok +SELECT to_date('2016 367', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 375 +SELECT to_date('0000-02-01','YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 376 +-- allowed, though it shouldn't be + +-- to_char's TZ format code produces zone abbrev if known +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 377 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS tz') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 378 +|-- +-- Check behavior with SQL-style fixed-GMT-offset time zone (cf bug #8572) +|-- + +SET TIME ZONE 'America/New_York' +-- +STMT: VariableSetStmt +== 379 +SET TIME ZONE '-1.5' +-- +STMT: VariableSetStmt +== 380 +SHOW TIME ZONE +-- +STMT: VariableShowStmt +== 381 +SELECT '2012-12-12 12:00'::timestamptz +-- +STMT: SelectStmt +== 382 +SELECT '2012-12-12 12:00 America/New_York'::timestamptz +-- +STMT: SelectStmt +== 383 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 384 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD SSSS') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 385 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD SSSSS') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 386 +SET TIME ZONE '+2' +-- +STMT: VariableSetStmt +== 387 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 388 +RESET TIME ZONE +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/identity.metadata.json b/parser/testdata/summary/postgres_regress/identity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/identity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/identity.test b/parser/testdata/summary/postgres_regress/identity.test new file mode 100644 index 0000000..57a15d4 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/identity.test @@ -0,0 +1,1600 @@ +== 001 +-- sanity check of system catalog +SELECT attrelid, attname, attidentity FROM pg_attribute WHERE attidentity NOT IN ('', 'a', 'd') +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attidentity" +STMT: SelectStmt +== 002 +CREATE TABLE itest1 (a int generated by default as identity, b text) +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE itest2 (a bigint generated always as identity, b text) +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE itest3 (a smallint generated by default as identity (start with 7 increment by 5), b text) +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: CreateStmt +== 005 +ALTER TABLE itest3 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: AlterTableStmt +== 006 +-- error + +SELECT table_name, column_name, column_default, is_nullable, is_identity, identity_generation, identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle FROM information_schema.columns WHERE table_name LIKE 'itest_' ORDER BY 1, 2 +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 007 +-- internal sequences should not be shown here +SELECT sequence_name FROM information_schema.sequences WHERE sequence_name LIKE 'itest%' +-- +TABLE: name="information_schema.sequences" schema="information_schema" table="sequences" ctx=Select +FILTER: schema="" table="" column="sequence_name" +STMT: SelectStmt +== 008 +SELECT pg_get_serial_sequence('itest1', 'a') +-- +FUNCTION: name="pg_get_serial_sequence" function="pg_get_serial_sequence" schema="" ctx=Call +STMT: SelectStmt +== 009 +CREATE TABLE itest4 (a int, b text) +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: CreateStmt +== 010 +ALTER TABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 011 +-- error, requires NOT NULL +ALTER TABLE itest4 ALTER COLUMN a SET NOT NULL +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 012 +ALTER TABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 013 +-- ok +ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 014 +-- error, disallowed +ALTER TABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 015 +-- error, already set +ALTER TABLE itest4 ALTER COLUMN b ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 016 +-- error, wrong data type + +-- for later +ALTER TABLE itest4 ALTER COLUMN b SET DEFAULT '' +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 017 +-- invalid column type +CREATE TABLE itest_err_1 (a text generated by default as identity) +-- +TABLE: name="itest_err_1" schema="" table="itest_err_1" ctx=DDL +STMT: CreateStmt +== 018 +-- duplicate identity +CREATE TABLE itest_err_2 (a int generated always as identity generated by default as identity) +-- +TABLE: name="itest_err_2" schema="" table="itest_err_2" ctx=DDL +STMT: CreateStmt +== 019 +-- cannot have default and identity +CREATE TABLE itest_err_3 (a int default 5 generated by default as identity) +-- +TABLE: name="itest_err_3" schema="" table="itest_err_3" ctx=DDL +STMT: CreateStmt +== 020 +-- cannot combine serial and identity +CREATE TABLE itest_err_4 (a serial generated by default as identity) +-- +TABLE: name="itest_err_4" schema="" table="itest_err_4" ctx=DDL +STMT: CreateStmt +== 021 +INSERT INTO itest1 DEFAULT VALUES +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +== 022 +INSERT INTO itest1 DEFAULT VALUES +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +== 023 +INSERT INTO itest2 DEFAULT VALUES +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +== 024 +INSERT INTO itest2 DEFAULT VALUES +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +== 025 +INSERT INTO itest3 DEFAULT VALUES +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DML +STMT: InsertStmt +== 026 +INSERT INTO itest3 DEFAULT VALUES +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DML +STMT: InsertStmt +== 027 +INSERT INTO itest4 DEFAULT VALUES +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DML +STMT: InsertStmt +== 028 +INSERT INTO itest4 DEFAULT VALUES +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DML +STMT: InsertStmt +== 029 +SELECT * FROM itest1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=Select +STMT: SelectStmt +== 030 +SELECT * FROM itest2 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=Select +STMT: SelectStmt +== 031 +SELECT * FROM itest3 +-- +TABLE: name="itest3" schema="" table="itest3" ctx=Select +STMT: SelectStmt +== 032 +SELECT * FROM itest4 +-- +TABLE: name="itest4" schema="" table="itest4" ctx=Select +STMT: SelectStmt +== 033 +-- VALUES RTEs + +CREATE TABLE itest5 (a int generated always as identity, b text) +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DDL +STMT: CreateStmt +== 034 +INSERT INTO itest5 VALUES (1, 'a') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +-- error +INSERT INTO itest5 VALUES (DEFAULT, 'a') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +-- ok +INSERT INTO itest5 VALUES (2, 'b'), (3, 'c') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +-- error +INSERT INTO itest5 VALUES (DEFAULT, 'b'), (3, 'c') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +-- error +INSERT INTO itest5 VALUES (2, 'b'), (DEFAULT, 'c') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +-- error +INSERT INTO itest5 VALUES (DEFAULT, 'b'), (DEFAULT, 'c') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +-- ok + +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-1, 'aa') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-2, 'bb'), (-3, 'cc') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (DEFAULT, 'dd'), (-4, 'ee') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-5, 'ff'), (DEFAULT, 'gg') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (DEFAULT, 'hh'), (DEFAULT, 'ii') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-1, 'aaa') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-2, 'bbb'), (-3, 'ccc') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (DEFAULT, 'ddd'), (-4, 'eee') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-5, 'fff'), (DEFAULT, 'ggg') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (DEFAULT, 'hhh'), (DEFAULT, 'iii') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +SELECT * FROM itest5 +-- +TABLE: name="itest5" schema="" table="itest5" ctx=Select +STMT: SelectStmt +== 051 +DROP TABLE itest5 +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DDL +STMT: DropStmt +== 052 +INSERT INTO itest3 VALUES (DEFAULT, 'a') +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +INSERT INTO itest3 VALUES (DEFAULT, 'b'), (DEFAULT, 'c') +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +SELECT * FROM itest3 +-- +TABLE: name="itest3" schema="" table="itest3" ctx=Select +STMT: SelectStmt +== 055 +-- OVERRIDING tests + +-- GENERATED BY DEFAULT + +-- This inserts the row as presented: +INSERT INTO itest1 VALUES (10, 'xyz') +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +-- With GENERATED BY DEFAULT, OVERRIDING SYSTEM VALUE is not allowed +-- by the standard, but we allow it as a no-op, since it is of use if +-- there are multiple identity columns in a table, which is also an +-- extension. +INSERT INTO itest1 OVERRIDING SYSTEM VALUE VALUES (20, 'xyz') +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +-- This ignores the 30 and uses the sequence value instead: +INSERT INTO itest1 OVERRIDING USER VALUE VALUES (30, 'xyz') +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +SELECT * FROM itest1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=Select +STMT: SelectStmt +== 059 +-- GENERATED ALWAYS + +-- This is an error: +INSERT INTO itest2 VALUES (10, 'xyz') +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +-- This inserts the row as presented: +INSERT INTO itest2 OVERRIDING SYSTEM VALUE VALUES (20, 'xyz') +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +-- This ignores the 30 and uses the sequence value instead: +INSERT INTO itest2 OVERRIDING USER VALUE VALUES (30, 'xyz') +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +SELECT * FROM itest2 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=Select +STMT: SelectStmt +== 063 +-- UPDATE tests + +-- GENERATED BY DEFAULT is not restricted. +UPDATE itest1 SET a = 101 WHERE a = 1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: UpdateStmt +== 064 +UPDATE itest1 SET a = DEFAULT WHERE a = 2 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: UpdateStmt +== 065 +SELECT * FROM itest1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=Select +STMT: SelectStmt +== 066 +-- GENERATED ALWAYS allows only DEFAULT. +UPDATE itest2 SET a = 101 WHERE a = 1 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: UpdateStmt +== 067 +-- error +UPDATE itest2 SET a = DEFAULT WHERE a = 2 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: UpdateStmt +== 068 +-- ok +SELECT * FROM itest2 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=Select +STMT: SelectStmt +== 069 +-- COPY tests + +CREATE TABLE itest9 (a int GENERATED ALWAYS AS IDENTITY, b text, c bigint) +-- +TABLE: name="itest9" schema="" table="itest9" ctx=DDL +STMT: CreateStmt +== 070 +COPY itest9 FROM stdin +-- +TABLE: name="itest9" schema="" table="itest9" ctx=Select +STMT: CopyStmt +== 071 +COPY itest9 (b, c) FROM stdin +-- +TABLE: name="itest9" schema="" table="itest9" ctx=Select +STMT: CopyStmt +== 072 +SELECT * FROM itest9 ORDER BY c +-- +TABLE: name="itest9" schema="" table="itest9" ctx=Select +STMT: SelectStmt +== 073 +-- DROP IDENTITY tests + +ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 074 +ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 075 +-- error +ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY IF EXISTS +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 076 +-- noop + +INSERT INTO itest4 DEFAULT VALUES +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DML +STMT: InsertStmt +== 077 +-- fails because NOT NULL is not dropped +ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +== 078 +INSERT INTO itest4 DEFAULT VALUES +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DML +STMT: InsertStmt +== 079 +SELECT * FROM itest4 +-- +TABLE: name="itest4" schema="" table="itest4" ctx=Select +STMT: SelectStmt +== 080 +-- check that sequence is removed +SELECT sequence_name FROM itest4_a_seq +-- +TABLE: name="itest4_a_seq" schema="" table="itest4_a_seq" ctx=Select +STMT: SelectStmt +== 081 +-- test views + +CREATE TABLE itest10 (a int generated by default as identity, b text) +-- +TABLE: name="itest10" schema="" table="itest10" ctx=DDL +STMT: CreateStmt +== 082 +CREATE TABLE itest11 (a int generated always as identity, b text) +-- +TABLE: name="itest11" schema="" table="itest11" ctx=DDL +STMT: CreateStmt +== 083 +CREATE VIEW itestv10 AS SELECT * FROM itest10 +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DDL +TABLE: name="itest10" schema="" table="itest10" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 084 +CREATE VIEW itestv11 AS SELECT * FROM itest11 +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DDL +TABLE: name="itest11" schema="" table="itest11" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 085 +INSERT INTO itestv10 DEFAULT VALUES +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DML +STMT: InsertStmt +== 086 +INSERT INTO itestv10 DEFAULT VALUES +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DML +STMT: InsertStmt +== 087 +INSERT INTO itestv11 DEFAULT VALUES +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DML +STMT: InsertStmt +== 088 +INSERT INTO itestv11 DEFAULT VALUES +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DML +STMT: InsertStmt +== 089 +SELECT * FROM itestv10 +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=Select +STMT: SelectStmt +== 090 +SELECT * FROM itestv11 +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=Select +STMT: SelectStmt +== 091 +INSERT INTO itestv10 VALUES (10, 'xyz') +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +INSERT INTO itestv10 OVERRIDING USER VALUE VALUES (11, 'xyz') +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +SELECT * FROM itestv10 +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=Select +STMT: SelectStmt +== 094 +INSERT INTO itestv11 VALUES (10, 'xyz') +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +INSERT INTO itestv11 OVERRIDING SYSTEM VALUE VALUES (11, 'xyz') +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +SELECT * FROM itestv11 +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=Select +STMT: SelectStmt +== 097 +DROP VIEW itestv10, itestv11 +-- +STMT: DropStmt +== 098 +-- ADD COLUMN + +CREATE TABLE itest13 (a int) +-- +TABLE: name="itest13" schema="" table="itest13" ctx=DDL +STMT: CreateStmt +== 099 +-- add column to empty table +ALTER TABLE itest13 ADD COLUMN b int GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="itest13" schema="" table="itest13" ctx=DDL +STMT: AlterTableStmt +== 100 +INSERT INTO itest13 VALUES (1), (2), (3) +-- +TABLE: name="itest13" schema="" table="itest13" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +-- add column to populated table +ALTER TABLE itest13 ADD COLUMN c int GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="itest13" schema="" table="itest13" ctx=DDL +STMT: AlterTableStmt +== 102 +SELECT * FROM itest13 +-- +TABLE: name="itest13" schema="" table="itest13" ctx=Select +STMT: SelectStmt +== 103 +-- various ALTER COLUMN tests + +-- fail, not allowed for identity columns +ALTER TABLE itest1 ALTER COLUMN a SET DEFAULT 1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DDL +STMT: AlterTableStmt +== 104 +-- fail, not allowed, already has a default +CREATE TABLE itest5 (a serial, b text) +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DDL +STMT: CreateStmt +== 105 +ALTER TABLE itest5 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DDL +STMT: AlterTableStmt +== 106 +ALTER TABLE itest3 ALTER COLUMN a TYPE int +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: AlterTableStmt +== 107 +SELECT seqtypid::regtype FROM pg_sequence WHERE seqrelid = 'itest3_a_seq'::regclass +-- +TABLE: name="pg_sequence" schema="" table="pg_sequence" ctx=Select +FILTER: schema="" table="" column="seqrelid" +STMT: SelectStmt +== 108 +ALTER TABLE itest3 ALTER COLUMN a TYPE text +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: AlterTableStmt +== 109 +-- error + +-- check that unlogged propagates to sequence +CREATE UNLOGGED TABLE itest17 (a int NOT NULL, b text) +-- +TABLE: name="itest17" schema="" table="itest17" ctx=DDL +STMT: CreateStmt +== 110 +ALTER TABLE itest17 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest17" schema="" table="itest17" ctx=DDL +STMT: AlterTableStmt +== 111 +ALTER TABLE itest17 ADD COLUMN c int GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest17" schema="" table="itest17" ctx=DDL +STMT: AlterTableStmt +== 112 +CREATE TABLE itest18 (a int NOT NULL, b text) +-- +TABLE: name="itest18" schema="" table="itest18" ctx=DDL +STMT: CreateStmt +== 113 +ALTER TABLE itest18 SET UNLOGGED, ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest18" schema="" table="itest18" ctx=DDL +STMT: AlterTableStmt +== 114 +ALTER TABLE itest18 SET LOGGED +-- +TABLE: name="itest18" schema="" table="itest18" ctx=DDL +STMT: AlterTableStmt +== 115 +ALTER TABLE itest18 SET UNLOGGED +-- +TABLE: name="itest18" schema="" table="itest18" ctx=DDL +STMT: AlterTableStmt +== 116 +-- kinda silly to change property in the same command, but it should work +ALTER TABLE itest3 + ADD COLUMN c int GENERATED BY DEFAULT AS IDENTITY, + ALTER COLUMN c SET GENERATED ALWAYS +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: AlterTableStmt +== 117 +-- ALTER COLUMN ... SET + +CREATE TABLE itest6 (a int GENERATED ALWAYS AS IDENTITY, b text) +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DDL +STMT: CreateStmt +== 118 +INSERT INTO itest6 DEFAULT VALUES +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DML +STMT: InsertStmt +== 119 +ALTER TABLE itest6 ALTER COLUMN a SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 100 RESTART +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DDL +STMT: AlterTableStmt +== 120 +INSERT INTO itest6 DEFAULT VALUES +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DML +STMT: InsertStmt +== 121 +INSERT INTO itest6 DEFAULT VALUES +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DML +STMT: InsertStmt +== 122 +SELECT * FROM itest6 +-- +TABLE: name="itest6" schema="" table="itest6" ctx=Select +STMT: SelectStmt +== 123 +SELECT table_name, column_name, is_identity, identity_generation FROM information_schema.columns WHERE table_name = 'itest6' ORDER BY 1, 2 +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 124 +ALTER TABLE itest6 ALTER COLUMN b SET INCREMENT BY 2 +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DDL +STMT: AlterTableStmt +== 125 +-- fail, not identity + + +-- prohibited direct modification of sequence + +ALTER SEQUENCE itest6_a_seq OWNED BY NONE +-- +STMT: AlterSeqStmt +== 126 +-- inheritance + +CREATE TABLE itest7 (a int GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DDL +STMT: CreateStmt +== 127 +INSERT INTO itest7 DEFAULT VALUES +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DML +STMT: InsertStmt +== 128 +SELECT * FROM itest7 +-- +TABLE: name="itest7" schema="" table="itest7" ctx=Select +STMT: SelectStmt +== 129 +-- identity property is not inherited +CREATE TABLE itest7a (b text) INHERITS (itest7) +-- +TABLE: name="itest7a" schema="" table="itest7a" ctx=DDL +STMT: CreateStmt +== 130 +-- make column identity in child table +CREATE TABLE itest7b (a int) +-- +TABLE: name="itest7b" schema="" table="itest7b" ctx=DDL +STMT: CreateStmt +== 131 +CREATE TABLE itest7c (a int GENERATED ALWAYS AS IDENTITY) INHERITS (itest7b) +-- +TABLE: name="itest7c" schema="" table="itest7c" ctx=DDL +STMT: CreateStmt +== 132 +INSERT INTO itest7c DEFAULT VALUES +-- +TABLE: name="itest7c" schema="" table="itest7c" ctx=DML +STMT: InsertStmt +== 133 +SELECT * FROM itest7c +-- +TABLE: name="itest7c" schema="" table="itest7c" ctx=Select +STMT: SelectStmt +== 134 +CREATE TABLE itest7d (a int not null) +-- +TABLE: name="itest7d" schema="" table="itest7d" ctx=DDL +STMT: CreateStmt +== 135 +CREATE TABLE itest7e () INHERITS (itest7d) +-- +TABLE: name="itest7e" schema="" table="itest7e" ctx=DDL +STMT: CreateStmt +== 136 +ALTER TABLE itest7d ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest7d" schema="" table="itest7d" ctx=DDL +STMT: AlterTableStmt +== 137 +ALTER TABLE itest7d ADD COLUMN b int GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest7d" schema="" table="itest7d" ctx=DDL +STMT: AlterTableStmt +== 138 +-- error + +SELECT table_name, column_name, is_nullable, is_identity, identity_generation FROM information_schema.columns WHERE table_name LIKE 'itest7%' ORDER BY 1, 2 +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 139 +-- These ALTER TABLE variants will not recurse. +ALTER TABLE itest7 ALTER COLUMN a SET GENERATED BY DEFAULT +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DDL +STMT: AlterTableStmt +== 140 +ALTER TABLE itest7 ALTER COLUMN a RESTART +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DDL +STMT: AlterTableStmt +== 141 +ALTER TABLE itest7 ALTER COLUMN a DROP IDENTITY +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DDL +STMT: AlterTableStmt +== 142 +-- privileges +CREATE USER regress_identity_user1 +-- +STMT: CreateRoleStmt +== 143 +CREATE TABLE itest8 (a int GENERATED ALWAYS AS IDENTITY, b text) +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: CreateStmt +== 144 +GRANT SELECT, INSERT ON itest8 TO regress_identity_user1 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: GrantStmt +== 145 +SET ROLE regress_identity_user1 +-- +STMT: VariableSetStmt +== 146 +INSERT INTO itest8 DEFAULT VALUES +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DML +STMT: InsertStmt +== 147 +SELECT * FROM itest8 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=Select +STMT: SelectStmt +== 148 +RESET ROLE +-- +STMT: VariableSetStmt +== 149 +DROP TABLE itest8 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: DropStmt +== 150 +DROP USER regress_identity_user1 +-- +STMT: DropRoleStmt +== 151 +-- multiple steps in ALTER TABLE +CREATE TABLE itest8 (f1 int) +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: CreateStmt +== 152 +ALTER TABLE itest8 + ADD COLUMN f2 int NOT NULL, + ALTER COLUMN f2 ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +== 153 +ALTER TABLE itest8 + ADD COLUMN f3 int NOT NULL, + ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY, + ALTER COLUMN f3 SET GENERATED BY DEFAULT SET INCREMENT 10 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +== 154 +ALTER TABLE itest8 + ADD COLUMN f4 int +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +== 155 +ALTER TABLE itest8 + ALTER COLUMN f4 SET NOT NULL, + ALTER COLUMN f4 ADD GENERATED ALWAYS AS IDENTITY, + ALTER COLUMN f4 SET DATA TYPE bigint +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +== 156 +ALTER TABLE itest8 + ADD COLUMN f5 int GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +== 157 +ALTER TABLE itest8 + ALTER COLUMN f5 DROP IDENTITY, + ALTER COLUMN f5 DROP NOT NULL, + ALTER COLUMN f5 SET DATA TYPE bigint +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +== 158 +INSERT INTO itest8 VALUES(0), (1) +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 159 +-- This does not work when the table isn't empty. That's intentional, +-- since ADD GENERATED should only affect later insertions: +ALTER TABLE itest8 + ADD COLUMN f22 int NOT NULL, + ALTER COLUMN f22 ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +== 160 +TABLE itest8 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=Select +STMT: SelectStmt +== 161 +DROP TABLE itest8 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: DropStmt +== 162 +-- typed tables (currently not supported) + +CREATE TYPE itest_type AS (f1 integer, f2 text, f3 bigint) +-- +STMT: CompositeTypeStmt +== 163 +CREATE TABLE itest12 OF itest_type (f1 WITH OPTIONS GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="itest12" schema="" table="itest12" ctx=DDL +STMT: CreateStmt +== 164 +-- error +DROP TYPE itest_type CASCADE +-- +STMT: DropStmt +== 165 +-- table partitions + +-- partitions inherit identity column and share sequence +CREATE TABLE pitest1 (f1 date NOT NULL, f2 text, f3 bigint generated always as identity) PARTITION BY RANGE (f1) +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: CreateStmt +== 166 +-- new partition +CREATE TABLE pitest1_p1 PARTITION OF pitest1 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01') +-- +TABLE: name="pitest1_p1" schema="" table="pitest1_p1" ctx=DDL +STMT: CreateStmt +== 167 +INSERT into pitest1(f1, f2) VALUES ('2016-07-2', 'from pitest1') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +INSERT into pitest1_p1 (f1, f2) VALUES ('2016-07-3', 'from pitest1_p1') +-- +TABLE: name="pitest1_p1" schema="" table="pitest1_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 169 +-- attached partition +CREATE TABLE pitest1_p2 (f3 bigint, f2 text, f1 date NOT NULL) +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DDL +STMT: CreateStmt +== 170 +INSERT INTO pitest1_p2 (f1, f2, f3) VALUES ('2016-08-2', 'before attaching', 100) +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 171 +ALTER TABLE pitest1 ATTACH PARTITION pitest1_p2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +== 172 +-- requires NOT NULL constraint +ALTER TABLE pitest1_p2 ALTER COLUMN f3 SET NOT NULL +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DDL +STMT: AlterTableStmt +== 173 +ALTER TABLE pitest1 ATTACH PARTITION pitest1_p2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +== 174 +INSERT INTO pitest1_p2 (f1, f2) VALUES ('2016-08-3', 'from pitest1_p2') +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 175 +INSERT INTO pitest1 (f1, f2) VALUES ('2016-08-4', 'from pitest1') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 176 +-- LIKE INCLUDING on partition +CREATE TABLE pitest1_p1_like (LIKE pitest1_p1 INCLUDING IDENTITY) +-- +TABLE: name="pitest1_p1_like" schema="" table="pitest1_p1_like" ctx=DDL +STMT: CreateStmt +== 177 +INSERT into pitest1_p1_like(f1, f2) VALUES ('2016-07-2', 'from pitest1_p1_like') +-- +TABLE: name="pitest1_p1_like" schema="" table="pitest1_p1_like" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 178 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest1 +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=Select +STMT: SelectStmt +== 179 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest1_p1_like +-- +TABLE: name="pitest1_p1_like" schema="" table="pitest1_p1_like" ctx=Select +STMT: SelectStmt +== 180 +ALTER TABLE pitest1 ALTER COLUMN f3 SET DATA TYPE bigint +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +== 181 +SELECT tableoid::regclass, f1, f2, f3, pg_typeof(f3) FROM pitest1 +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=Select +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 182 +SELECT tableoid::regclass, f1, f2, f3, pg_typeof(f3) FROM pitest1_p2 +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=Select +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 183 +-- add identity column +CREATE TABLE pitest2 (f1 date NOT NULL, f2 text) PARTITION BY RANGE (f1) +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: CreateStmt +== 184 +CREATE TABLE pitest2_p1 PARTITION OF pitest2 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01') +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DDL +STMT: CreateStmt +== 185 +CREATE TABLE pitest2_p2 PARTITION OF pitest2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01') +-- +TABLE: name="pitest2_p2" schema="" table="pitest2_p2" ctx=DDL +STMT: CreateStmt +== 186 +INSERT into pitest2(f1, f2) VALUES ('2016-07-2', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +INSERT INTO pitest2 (f1, f2) VALUES ('2016-08-2', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +ALTER TABLE pitest2 ADD COLUMN f3 int GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: AlterTableStmt +== 189 +INSERT into pitest2_p1 (f1, f2) VALUES ('2016-07-3', 'from pitest2_p1') +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +INSERT INTO pitest2_p2 (f1, f2) VALUES ('2016-08-3', 'from pitest2_p2') +-- +TABLE: name="pitest2_p2" schema="" table="pitest2_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +INSERT into pitest2(f1, f2) VALUES ('2016-07-4', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 192 +INSERT INTO pitest2 (f1, f2) VALUES ('2016-08-4', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 193 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest2 +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=Select +STMT: SelectStmt +== 194 +-- SET identity column +ALTER TABLE pitest2_p1 ALTER COLUMN f3 SET GENERATED BY DEFAULT +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DDL +STMT: AlterTableStmt +== 195 +-- fails +ALTER TABLE pitest2_p1 ALTER COLUMN f3 SET INCREMENT BY 2 +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DDL +STMT: AlterTableStmt +== 196 +-- fails +ALTER TABLE ONLY pitest2 ALTER COLUMN f3 SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 1000 RESTART +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: AlterTableStmt +== 197 +-- fails +ALTER TABLE pitest2 ALTER COLUMN f3 SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 1000 RESTART +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: AlterTableStmt +== 198 +INSERT into pitest2(f1, f2, f3) VALUES ('2016-07-5', 'from pitest2', 200) +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 199 +INSERT INTO pitest2(f1, f2) VALUES ('2016-08-5', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 200 +INSERT into pitest2_p1 (f1, f2) VALUES ('2016-07-6', 'from pitest2_p1') +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 201 +INSERT INTO pitest2_p2 (f1, f2, f3) VALUES ('2016-08-6', 'from pitest2_p2', 300) +-- +TABLE: name="pitest2_p2" schema="" table="pitest2_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest2 +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=Select +STMT: SelectStmt +== 203 +-- detaching a partition removes identity property +ALTER TABLE pitest2 DETACH PARTITION pitest2_p1 +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: AlterTableStmt +== 204 +INSERT into pitest2(f1, f2) VALUES ('2016-08-7', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 205 +INSERT into pitest2_p1 (f1, f2) VALUES ('2016-07-7', 'from pitest2_p1') +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 206 +-- error +INSERT into pitest2_p1 (f1, f2, f3) VALUES ('2016-07-7', 'from pitest2_p1', 2000) +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 207 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest2 +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=Select +STMT: SelectStmt +== 208 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest2_p1 +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=Select +STMT: SelectStmt +== 209 +DROP TABLE pitest2_p1 +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DDL +STMT: DropStmt +== 210 +-- changing a regular column to identity column in a partitioned table +CREATE TABLE pitest3 (f1 date NOT NULL, f2 text, f3 int) PARTITION BY RANGE (f1) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: CreateStmt +== 211 +CREATE TABLE pitest3_p1 PARTITION OF pitest3 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01') +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DDL +STMT: CreateStmt +== 212 +INSERT into pitest3 VALUES ('2016-07-2', 'from pitest3', 1) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 213 +INSERT into pitest3_p1 VALUES ('2016-07-3', 'from pitest3_p1', 2) +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 214 +-- fails, changing only a partition not allowed +ALTER TABLE pitest3_p1 + ALTER COLUMN f3 SET NOT NULL, + ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3) +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DDL +STMT: AlterTableStmt +== 215 +-- fails, changing only the partitioned table not allowed +BEGIN +-- +STMT: TransactionStmt +== 216 +ALTER TABLE pitest3_p1 ALTER COLUMN f3 SET NOT NULL +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DDL +STMT: AlterTableStmt +== 217 +ALTER TABLE ONLY pitest3 + ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +== 218 +ROLLBACK +-- +STMT: TransactionStmt +== 219 +ALTER TABLE pitest3 + ALTER COLUMN f3 SET NOT NULL, + ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +== 220 +INSERT into pitest3(f1, f2) VALUES ('2016-07-4', 'from pitest3') +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 221 +INSERT into pitest3_p1 (f1, f2) VALUES ('2016-07-5', 'from pitest3_p1') +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 222 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest3 +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=Select +STMT: SelectStmt +== 223 +-- changing an identity column to a non-identity column in a partitioned table +ALTER TABLE pitest3_p1 ALTER COLUMN f3 DROP IDENTITY +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DDL +STMT: AlterTableStmt +== 224 +-- fails +ALTER TABLE ONLY pitest3 ALTER COLUMN f3 DROP IDENTITY +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +== 225 +-- fails +ALTER TABLE pitest3 ALTER COLUMN f3 DROP IDENTITY +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +== 226 +INSERT into pitest3(f1, f2) VALUES ('2016-07-4', 'from pitest3') +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 227 +-- fails +INSERT into pitest3_p1 (f1, f2) VALUES ('2016-07-5', 'from pitest3_p1') +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 228 +-- fails +INSERT into pitest3(f1, f2, f3) VALUES ('2016-07-6', 'from pitest3', 5) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 229 +INSERT into pitest3_p1 (f1, f2, f3) VALUES ('2016-07-7', 'from pitest3_p1', 6) +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 230 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest3 +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=Select +STMT: SelectStmt +== 231 +-- Changing NOT NULL constraint of identity columns is not allowed +ALTER TABLE pitest1_p1 ALTER COLUMN f3 DROP NOT NULL +-- +TABLE: name="pitest1_p1" schema="" table="pitest1_p1" ctx=DDL +STMT: AlterTableStmt +== 232 +ALTER TABLE pitest1 ALTER COLUMN f3 DROP NOT NULL +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +== 233 +-- Identity columns have their own default +ALTER TABLE pitest1_p2 ALTER COLUMN f3 SET DEFAULT 10000 +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DDL +STMT: AlterTableStmt +== 234 +ALTER TABLE pitest1 ALTER COLUMN f3 SET DEFAULT 10000 +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +== 235 +-- Adding identity to an identity column is not allowed +ALTER TABLE pitest1_p2 ALTER COLUMN f3 ADD GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DDL +STMT: AlterTableStmt +== 236 +ALTER TABLE pitest1 ALTER COLUMN f3 ADD GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +== 237 +-- partitions with their own identity columns are not allowed, even if the +-- partitioned table does not have an identity column. +CREATE TABLE pitest1_pfail PARTITION OF pitest1 ( + f3 WITH OPTIONS GENERATED ALWAYS AS IDENTITY +) FOR VALUES FROM ('2016-11-01') TO ('2016-12-01') +-- +TABLE: name="pitest1_pfail" schema="" table="pitest1_pfail" ctx=DDL +STMT: CreateStmt +== 238 +CREATE TABLE pitest_pfail PARTITION OF pitest3 ( + f3 WITH OPTIONS GENERATED ALWAYS AS IDENTITY +) FOR VALUES FROM ('2016-07-01') TO ('2016-08-01') +-- +TABLE: name="pitest_pfail" schema="" table="pitest_pfail" ctx=DDL +STMT: CreateStmt +== 239 +CREATE TABLE pitest1_pfail (f1 date NOT NULL, f2 text, f3 bigint GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="pitest1_pfail" schema="" table="pitest1_pfail" ctx=DDL +STMT: CreateStmt +== 240 +ALTER TABLE pitest1 ATTACH PARTITION pitest1_pfail FOR VALUES FROM ('2016-11-01') TO ('2016-12-01') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +== 241 +ALTER TABLE pitest3 ATTACH PARTITION pitest1_pfail FOR VALUES FROM ('2016-11-01') TO ('2016-12-01') +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +== 242 +DROP TABLE pitest1_pfail +-- +TABLE: name="pitest1_pfail" schema="" table="pitest1_pfail" ctx=DDL +STMT: DropStmt +== 243 +DROP TABLE pitest3 +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: DropStmt +== 244 +-- test that sequence of half-dropped serial column is properly ignored + +CREATE TABLE itest14 (id serial) +-- +TABLE: name="itest14" schema="" table="itest14" ctx=DDL +STMT: CreateStmt +== 245 +ALTER TABLE itest14 ALTER id DROP DEFAULT +-- +TABLE: name="itest14" schema="" table="itest14" ctx=DDL +STMT: AlterTableStmt +== 246 +ALTER TABLE itest14 ALTER id ADD GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="itest14" schema="" table="itest14" ctx=DDL +STMT: AlterTableStmt +== 247 +INSERT INTO itest14 (id) VALUES (DEFAULT) +-- +TABLE: name="itest14" schema="" table="itest14" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 248 +-- Identity columns must be NOT NULL (cf bug #16913) + +CREATE TABLE itest15 (id integer GENERATED ALWAYS AS IDENTITY NULL) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +== 249 +-- fail +CREATE TABLE itest15 (id integer NULL GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +== 250 +-- fail +CREATE TABLE itest15 (id integer GENERATED ALWAYS AS IDENTITY NOT NULL) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +== 251 +DROP TABLE itest15 +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: DropStmt +== 252 +CREATE TABLE itest15 (id integer NOT NULL GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +== 253 +DROP TABLE itest15 +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: DropStmt +== 254 +-- MERGE tests +CREATE TABLE itest15 (a int GENERATED ALWAYS AS IDENTITY, b text) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +== 255 +CREATE TABLE itest16 (a int GENERATED BY DEFAULT AS IDENTITY, b text) +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DDL +STMT: CreateStmt +== 256 +MERGE INTO itest15 t +USING (SELECT 10 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DML +ALIAS: "t"="itest15" +STMT: MergeStmt +STMT: SelectStmt +== 257 +-- Used to fail, but now it works and ignores the user supplied value +MERGE INTO itest15 t +USING (SELECT 20 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) OVERRIDING USER VALUE VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DML +ALIAS: "t"="itest15" +STMT: MergeStmt +STMT: SelectStmt +== 258 +MERGE INTO itest15 t +USING (SELECT 30 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) OVERRIDING SYSTEM VALUE VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DML +ALIAS: "t"="itest15" +STMT: MergeStmt +STMT: SelectStmt +== 259 +MERGE INTO itest16 t +USING (SELECT 10 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DML +ALIAS: "t"="itest16" +STMT: MergeStmt +STMT: SelectStmt +== 260 +MERGE INTO itest16 t +USING (SELECT 20 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) OVERRIDING USER VALUE VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DML +ALIAS: "t"="itest16" +STMT: MergeStmt +STMT: SelectStmt +== 261 +MERGE INTO itest16 t +USING (SELECT 30 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) OVERRIDING SYSTEM VALUE VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DML +ALIAS: "t"="itest16" +STMT: MergeStmt +STMT: SelectStmt +== 262 +SELECT * FROM itest15 +-- +TABLE: name="itest15" schema="" table="itest15" ctx=Select +STMT: SelectStmt +== 263 +SELECT * FROM itest16 +-- +TABLE: name="itest16" schema="" table="itest16" ctx=Select +STMT: SelectStmt +== 264 +DROP TABLE itest15 +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: DropStmt +== 265 +DROP TABLE itest16 +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DDL +STMT: DropStmt +== 266 +-- For testing of pg_dump and pg_upgrade, leave behind some identity +-- sequences whose logged-ness doesn't match their owning table's. +CREATE TABLE identity_dump_logged (a INT GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="identity_dump_logged" schema="" table="identity_dump_logged" ctx=DDL +STMT: CreateStmt +== 267 +ALTER SEQUENCE identity_dump_logged_a_seq SET UNLOGGED +-- +TABLE: name="identity_dump_logged_a_seq" schema="" table="identity_dump_logged_a_seq" ctx=DDL +STMT: AlterTableStmt +== 268 +CREATE UNLOGGED TABLE identity_dump_unlogged (a INT GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="identity_dump_unlogged" schema="" table="identity_dump_unlogged" ctx=DDL +STMT: CreateStmt +== 269 +ALTER SEQUENCE identity_dump_unlogged_a_seq SET LOGGED +-- +TABLE: name="identity_dump_unlogged_a_seq" schema="" table="identity_dump_unlogged_a_seq" ctx=DDL +STMT: AlterTableStmt +== 270 +SELECT relname, relpersistence FROM pg_class + WHERE relname ~ '^identity_dump_' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/incremental_sort.metadata.json b/parser/testdata/summary/postgres_regress/incremental_sort.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/incremental_sort.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/incremental_sort.test b/parser/testdata/summary/postgres_regress/incremental_sort.test new file mode 100644 index 0000000..72f355c --- /dev/null +++ b/parser/testdata/summary/postgres_regress/incremental_sort.test @@ -0,0 +1,803 @@ +== 001 +-- When there is a LIMIT clause, incremental sort is beneficial because +-- it only has to sort some of the groups, and not the entire table. +explain (costs off) +select * from (select * from tenk1 order by four) t order by four, ten +limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 002 +-- When work_mem is not enough to sort the entire table, incremental sort +-- may be faster if individual groups still fit into work_mem. +set work_mem to '2MB' +-- +STMT: VariableSetStmt +== 003 +explain (costs off) +select * from (select * from tenk1 order by four) t order by four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 004 +reset work_mem +-- +STMT: VariableSetStmt +== 005 +create table t(a integer, b integer) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 006 +create or replace function explain_analyze_without_memory(query text) +returns table (out_line text) language plpgsql +as +$$ +declare + line text; +begin + for line in + execute 'explain (analyze, costs off, summary off, timing off) ' || query + loop + out_line := regexp_replace(line, '\d+kB', 'NNkB', 'g'); + return next; + end loop; +end; +$$ +-- +FUNCTION: name="explain_analyze_without_memory" function="explain_analyze_without_memory" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 007 +create or replace function explain_analyze_inc_sort_nodes(query text) +returns jsonb language plpgsql +as +$$ +declare + elements jsonb; + element jsonb; + matching_nodes jsonb := '[]'::jsonb; +begin + execute 'explain (analyze, costs off, summary off, timing off, format ''json'') ' || query into strict elements; + while jsonb_array_length(elements) > 0 loop + element := elements->0; + elements := elements - 0; + case jsonb_typeof(element) + when 'array' then + if jsonb_array_length(element) > 0 then + elements := elements || element; + end if; + when 'object' then + if element ? 'Plan' then + elements := elements || jsonb_build_array(element->'Plan'); + element := element - 'Plan'; + else + if element ? 'Plans' then + elements := elements || jsonb_build_array(element->'Plans'); + element := element - 'Plans'; + end if; + if (element->>'Node Type')::text = 'Incremental Sort' then + matching_nodes := matching_nodes || element; + end if; + end if; + end case; + end loop; + return matching_nodes; +end; +$$ +-- +FUNCTION: name="explain_analyze_inc_sort_nodes" function="explain_analyze_inc_sort_nodes" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 008 +create or replace function explain_analyze_inc_sort_nodes_without_memory(query text) +returns jsonb language plpgsql +as +$$ +declare + nodes jsonb := '[]'::jsonb; + node jsonb; + group_key text; + space_key text; +begin + for node in select * from jsonb_array_elements(explain_analyze_inc_sort_nodes(query)) t loop + for group_key in select unnest(array['Full-sort Groups', 'Pre-sorted Groups']::text[]) t loop + for space_key in select unnest(array['Sort Space Memory', 'Sort Space Disk']::text[]) t loop + node := jsonb_set(node, array[group_key, space_key, 'Average Sort Space Used'], '"NN"', false); + node := jsonb_set(node, array[group_key, space_key, 'Peak Sort Space Used'], '"NN"', false); + end loop; + end loop; + nodes := nodes || node; + end loop; + return nodes; +end; +$$ +-- +FUNCTION: name="explain_analyze_inc_sort_nodes_without_memory" function="explain_analyze_inc_sort_nodes_without_memory" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 009 +create or replace function explain_analyze_inc_sort_nodes_verify_invariants(query text) +returns bool language plpgsql +as +$$ +declare + node jsonb; + group_stats jsonb; + group_key text; + space_key text; +begin + for node in select * from jsonb_array_elements(explain_analyze_inc_sort_nodes(query)) t loop + for group_key in select unnest(array['Full-sort Groups', 'Pre-sorted Groups']::text[]) t loop + group_stats := node->group_key; + for space_key in select unnest(array['Sort Space Memory', 'Sort Space Disk']::text[]) t loop + if (group_stats->space_key->'Peak Sort Space Used')::bigint < (group_stats->space_key->'Peak Sort Space Used')::bigint then + raise exception '% has invalid max space < average space', group_key; + end if; + end loop; + end loop; + end loop; + return true; +end; +$$ +-- +FUNCTION: name="explain_analyze_inc_sort_nodes_verify_invariants" function="explain_analyze_inc_sort_nodes_verify_invariants" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 010 +-- A single large group tested around each mode transition point. +insert into t(a, b) select i/100 + 1, i + 1 from generate_series(0, 999) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 011 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +== 012 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 013 +select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 014 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 015 +select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 016 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 017 +select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 018 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 019 +select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 020 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 021 +select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 022 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +== 023 +-- An initial large group followed by a small group. +insert into t(a, b) select i/50 + 1, i + 1 from generate_series(0, 999) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 024 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +== 025 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 55 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 026 +select * from (select * from t order by a) s order by a, b limit 55 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 027 +-- Test EXPLAIN ANALYZE with only a fullsort group. +select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 55') +-- +FUNCTION: name="explain_analyze_without_memory" function="explain_analyze_without_memory" schema="" ctx=Call +STMT: SelectStmt +== 028 +select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 55')) +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +FUNCTION: name="explain_analyze_inc_sort_nodes_without_memory" function="explain_analyze_inc_sort_nodes_without_memory" schema="" ctx=Call +STMT: SelectStmt +== 029 +select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 55') +-- +FUNCTION: name="explain_analyze_inc_sort_nodes_verify_invariants" function="explain_analyze_inc_sort_nodes_verify_invariants" schema="" ctx=Call +STMT: SelectStmt +== 030 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +== 031 +-- An initial small group followed by a large group. +insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_series(1, 1000) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 032 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +== 033 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 70 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 034 +select * from (select * from t order by a) s order by a, b limit 70 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 035 +-- Checks case where we hit a group boundary at the last tuple of a batch. +-- Because the full sort state is bounded, we scan 64 tuples (the mode +-- transition point) but only retain 5. Thus when we transition modes, all +-- tuples in the full sort state have different prefix keys. +explain (costs off) select * from (select * from t order by a) s order by a, b limit 5 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 036 +select * from (select * from t order by a) s order by a, b limit 5 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 037 +-- Test rescan. +begin +-- +STMT: TransactionStmt +== 038 +-- We force the planner to choose a plan with incremental sort on the right side +-- of a nested loop join node. That way we trigger the rescan code path. +set local enable_hashjoin = off +-- +STMT: VariableSetStmt +== 039 +set local enable_mergejoin = off +-- +STMT: VariableSetStmt +== 040 +set local enable_material = off +-- +STMT: VariableSetStmt +== 041 +set local enable_sort = off +-- +STMT: VariableSetStmt +== 042 +explain (costs off) select * from t left join (select * from (select * from t order by a) v order by a, b) s on s.a = t.a where t.a in (1, 2) +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="t" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 043 +select * from t left join (select * from (select * from t order by a) v order by a, b) s on s.a = t.a where t.a in (1, 2) +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="t" column="a" +STMT: SelectStmt +== 044 +rollback +-- +STMT: TransactionStmt +== 045 +-- Test EXPLAIN ANALYZE with both fullsort and presorted groups. +select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 70') +-- +FUNCTION: name="explain_analyze_without_memory" function="explain_analyze_without_memory" schema="" ctx=Call +STMT: SelectStmt +== 046 +select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 70')) +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +FUNCTION: name="explain_analyze_inc_sort_nodes_without_memory" function="explain_analyze_inc_sort_nodes_without_memory" schema="" ctx=Call +STMT: SelectStmt +== 047 +select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 70') +-- +FUNCTION: name="explain_analyze_inc_sort_nodes_verify_invariants" function="explain_analyze_inc_sort_nodes_verify_invariants" schema="" ctx=Call +STMT: SelectStmt +== 048 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +== 049 +-- Small groups of 10 tuples each tested around each mode transition point. +insert into t(a, b) select i / 10, i from generate_series(1, 1000) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 050 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +== 051 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 052 +select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 053 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 054 +select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 055 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 056 +select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 057 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 058 +select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 059 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 060 +select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 061 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +== 062 +-- Small groups of only 1 tuple each tested around each mode transition point. +insert into t(a, b) select i, i from generate_series(1, 1000) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 063 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +== 064 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 065 +select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 066 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 067 +select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 068 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 069 +select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 070 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 071 +select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 072 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 073 +select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +== 074 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +== 075 +drop table t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 076 +-- Incremental sort vs. parallel queries +set min_parallel_table_scan_size = '1kB' +-- +STMT: VariableSetStmt +== 077 +set min_parallel_index_scan_size = '1kB' +-- +STMT: VariableSetStmt +== 078 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 079 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +== 080 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 081 +create table t (a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 082 +insert into t select mod(i,10),mod(i,10),i from generate_series(1,10000) s(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 083 +create index on t (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +== 084 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +== 085 +set enable_incremental_sort = off +-- +STMT: VariableSetStmt +== 086 +explain (costs off) select a,b,sum(c) from t group by 1,2 order by 1,2,3 limit 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 087 +set enable_incremental_sort = on +-- +STMT: VariableSetStmt +== 088 +explain (costs off) select a,b,sum(c) from t group by 1,2 order by 1,2,3 limit 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 089 +-- Incremental sort vs. set operations with varno 0 +set enable_hashagg to off +-- +STMT: VariableSetStmt +== 090 +explain (costs off) select * from t union select * from t order by 1,3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 091 +-- Full sort, not just incremental sort can be pushed below a gather merge path +-- by generate_useful_gather_paths. +explain (costs off) select distinct a,b from t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 092 +drop table t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +== 093 +-- Sort pushdown can't go below where expressions are part of the rel target. +-- In particular this is interesting for volatile expressions which have to +-- go above joins since otherwise we'll incorrectly use expression evaluations +-- across multiple rows. +set enable_hashagg=off +-- +STMT: VariableSetStmt +== 094 +set enable_seqscan=off +-- +STMT: VariableSetStmt +== 095 +set enable_incremental_sort = off +-- +STMT: VariableSetStmt +== 096 +set parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +== 097 +set parallel_setup_cost=0 +-- +STMT: VariableSetStmt +== 098 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 099 +set min_parallel_index_scan_size = 0 +-- +STMT: VariableSetStmt +== 100 +-- Parallel sort below join. +explain (costs off) select distinct sub.unique1, stringu1 +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 101 +explain (costs off) select sub.unique1, stringu1 +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +order by 1, 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 102 +-- Parallel sort but with expression that can be safely generated at the base rel. +explain (costs off) select distinct sub.unique1, md5(stringu1) +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="md5" function="md5" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 103 +explain (costs off) select sub.unique1, md5(stringu1) +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +order by 1, 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="md5" function="md5" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 104 +-- Parallel sort with an aggregate that can be safely generated in parallel, +-- but we can't sort by partial aggregate values. +explain (costs off) select count(*) +from tenk1 t1 +join tenk1 t2 on t1.unique1 = t2.unique2 +join tenk1 t3 on t2.unique1 = t3.unique1 +order by count(*) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 105 +-- Parallel sort but with expression (correlated subquery) that +-- is prohibited in parallel plans. +explain (costs off) select distinct + unique1, + (select t.unique1 from tenk1 where tenk1.unique1 = t.unique1) +from tenk1 t, generate_series(1, 1000) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t"="tenk1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +FILTER: schema="" table="t" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 106 +explain (costs off) select + unique1, + (select t.unique1 from tenk1 where tenk1.unique1 = t.unique1) +from tenk1 t, generate_series(1, 1000) +order by 1, 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t"="tenk1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +FILTER: schema="" table="t" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 107 +-- Parallel sort but with expression not available until the upper rel. +explain (costs off) select distinct sub.unique1, stringu1 || random()::text +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 108 +explain (costs off) select sub.unique1, stringu1 || random()::text +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +order by 1, 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 109 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 110 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 111 +reset enable_incremental_sort +-- +STMT: VariableSetStmt +== 112 +reset parallel_tuple_cost +-- +STMT: VariableSetStmt +== 113 +reset parallel_setup_cost +-- +STMT: VariableSetStmt +== 114 +reset min_parallel_table_scan_size +-- +STMT: VariableSetStmt +== 115 +reset min_parallel_index_scan_size +-- +STMT: VariableSetStmt +== 116 +-- Ensure incremental sorts work for amcanorderbyop type indexes +create table point_table (a point, b int) +-- +TABLE: name="point_table" schema="" table="point_table" ctx=DDL +STMT: CreateStmt +== 117 +create index point_table_a_idx on point_table using gist(a) +-- +TABLE: name="point_table" schema="" table="point_table" ctx=DDL +STMT: IndexStmt +== 118 +-- Ensure we get an incremental sort plan for both of the following queries +explain (costs off) select a, b, a <-> point(5, 5) dist from point_table order by dist, b limit 1 +-- +TABLE: name="point_table" schema="" table="point_table" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 119 +explain (costs off) select a, b, a <-> point(5, 5) dist from point_table order by dist, b desc limit 1 +-- +TABLE: name="point_table" schema="" table="point_table" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/index_including.metadata.json b/parser/testdata/summary/postgres_regress/index_including.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/index_including.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/index_including.test b/parser/testdata/summary/postgres_regress/index_including.test new file mode 100644 index 0000000..4cb4bc0 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/index_including.test @@ -0,0 +1,862 @@ +== 001 +/* + * 1.test CREATE INDEX + * + * Deliberately avoid dropping objects in this section, to get some pg_dump + * coverage. + */ + +-- Regular index with included columns +CREATE TABLE tbl_include_reg (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_reg" schema="" table="tbl_include_reg" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO tbl_include_reg SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_reg" schema="" table="tbl_include_reg" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +CREATE INDEX tbl_include_reg_idx ON tbl_include_reg (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_reg" schema="" table="tbl_include_reg" ctx=DDL +STMT: IndexStmt +== 004 +-- duplicate column is pretty pointless, but we allow it anyway +CREATE INDEX ON tbl_include_reg (c1, c2) INCLUDE (c1, c3) +-- +TABLE: name="tbl_include_reg" schema="" table="tbl_include_reg" ctx=DDL +STMT: IndexStmt +== 005 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_include_reg'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +== 006 +-- Unique index and unique constraint +CREATE TABLE tbl_include_unique1 (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DDL +STMT: CreateStmt +== 007 +INSERT INTO tbl_include_unique1 SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 008 +CREATE UNIQUE INDEX tbl_include_unique1_idx_unique ON tbl_include_unique1 using btree (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DDL +STMT: IndexStmt +== 009 +ALTER TABLE tbl_include_unique1 add UNIQUE USING INDEX tbl_include_unique1_idx_unique +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DDL +STMT: AlterTableStmt +== 010 +ALTER TABLE tbl_include_unique1 add UNIQUE (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DDL +STMT: AlterTableStmt +== 011 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_include_unique1'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +== 012 +-- Unique index and unique constraint. Both must fail. +CREATE TABLE tbl_include_unique2 (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_unique2" schema="" table="tbl_include_unique2" ctx=DDL +STMT: CreateStmt +== 013 +INSERT INTO tbl_include_unique2 SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_unique2" schema="" table="tbl_include_unique2" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 014 +CREATE UNIQUE INDEX tbl_include_unique2_idx_unique ON tbl_include_unique2 using btree (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_unique2" schema="" table="tbl_include_unique2" ctx=DDL +STMT: IndexStmt +== 015 +ALTER TABLE tbl_include_unique2 add UNIQUE (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_unique2" schema="" table="tbl_include_unique2" ctx=DDL +STMT: AlterTableStmt +== 016 +-- PK constraint +CREATE TABLE tbl_include_pk (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_pk" schema="" table="tbl_include_pk" ctx=DDL +STMT: CreateStmt +== 017 +INSERT INTO tbl_include_pk SELECT 1, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_pk" schema="" table="tbl_include_pk" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 018 +ALTER TABLE tbl_include_pk add PRIMARY KEY (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_pk" schema="" table="tbl_include_pk" ctx=DDL +STMT: AlterTableStmt +== 019 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_include_pk'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +== 020 +CREATE TABLE tbl_include_box (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_box" schema="" table="tbl_include_box" ctx=DDL +STMT: CreateStmt +== 021 +INSERT INTO tbl_include_box SELECT 1, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_box" schema="" table="tbl_include_box" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 022 +CREATE UNIQUE INDEX tbl_include_box_idx_unique ON tbl_include_box using btree (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_box" schema="" table="tbl_include_box" ctx=DDL +STMT: IndexStmt +== 023 +ALTER TABLE tbl_include_box add PRIMARY KEY USING INDEX tbl_include_box_idx_unique +-- +TABLE: name="tbl_include_box" schema="" table="tbl_include_box" ctx=DDL +STMT: AlterTableStmt +== 024 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_include_box'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +== 025 +-- PK constraint. Must fail. +CREATE TABLE tbl_include_box_pk (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_box_pk" schema="" table="tbl_include_box_pk" ctx=DDL +STMT: CreateStmt +== 026 +INSERT INTO tbl_include_box_pk SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_box_pk" schema="" table="tbl_include_box_pk" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 027 +ALTER TABLE tbl_include_box_pk add PRIMARY KEY (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_box_pk" schema="" table="tbl_include_box_pk" ctx=DDL +STMT: AlterTableStmt +== 028 +/* + * 2. Test CREATE TABLE with constraint + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + CONSTRAINT covering UNIQUE(c1,c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 029 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 030 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 031 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 032 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 033 +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + CONSTRAINT covering PRIMARY KEY(c1,c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 034 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 035 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 036 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO tbl SELECT 1, NULL, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,300) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 039 +explain (costs off) +select * from tbl where (c1,c2,c3) < (2,5,1) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c3" +STMT: ExplainStmt +STMT: SelectStmt +== 040 +select * from tbl where (c1,c2,c3) < (2,5,1) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c3" +STMT: SelectStmt +== 041 +-- row comparison that compares high key at page boundary +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 042 +explain (costs off) +select * from tbl where (c1,c2,c3) < (262,1,1) limit 1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c3" +STMT: ExplainStmt +STMT: SelectStmt +== 043 +select * from tbl where (c1,c2,c3) < (262,1,1) limit 1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c3" +STMT: SelectStmt +== 044 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 045 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 046 +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + UNIQUE(c1,c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 047 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 048 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 049 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 050 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 051 +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + PRIMARY KEY(c1,c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 052 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 053 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 054 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 055 +INSERT INTO tbl SELECT 1, NULL, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 056 +INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 057 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 058 +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + EXCLUDE USING btree (c1 WITH =) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 059 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 060 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 061 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 062 +INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 063 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 064 +/* + * 3.0 Test ALTER TABLE DROP COLUMN. + * Any column deletion leads to index deletion. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 int) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 065 +CREATE UNIQUE INDEX tbl_idx ON tbl using btree(c1, c2, c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 066 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 067 +ALTER TABLE tbl DROP COLUMN c3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 068 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 069 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 070 +/* + * 3.1 Test ALTER TABLE DROP COLUMN. + * Included column deletion leads to the index deletion, + * AS well AS key columns deletion. It's explained in documentation. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 071 +CREATE UNIQUE INDEX tbl_idx ON tbl using btree(c1, c2) INCLUDE(c3,c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 072 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 073 +ALTER TABLE tbl DROP COLUMN c3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 074 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 075 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 076 +/* + * 3.2 Test ALTER TABLE DROP COLUMN. + * Included column deletion leads to the index deletion. + * AS well AS key columns deletion. It's explained in documentation. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, UNIQUE(c1, c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 077 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 078 +ALTER TABLE tbl DROP COLUMN c3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 079 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 080 +ALTER TABLE tbl DROP COLUMN c1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 081 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 082 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 083 +/* + * 3.3 Test ALTER TABLE SET STATISTICS + */ +CREATE TABLE tbl (c1 int, c2 int) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 084 +CREATE INDEX tbl_idx ON tbl (c1, (c1+0)) INCLUDE (c2) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 085 +ALTER INDEX tbl_idx ALTER COLUMN 1 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +== 086 +ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +== 087 +ALTER INDEX tbl_idx ALTER COLUMN 3 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +== 088 +ALTER INDEX tbl_idx ALTER COLUMN 4 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +== 089 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 090 +/* + * 4. CREATE INDEX CONCURRENTLY + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, UNIQUE(c1, c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 091 +INSERT INTO tbl SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,1000) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 092 +CREATE UNIQUE INDEX CONCURRENTLY on tbl (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 093 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 094 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 095 +/* + * 5. REINDEX + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, UNIQUE(c1, c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 096 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 097 +ALTER TABLE tbl DROP COLUMN c3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 098 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 099 +REINDEX INDEX tbl_c1_c2_c3_c4_key +-- +STMT: ReindexStmt +== 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 101 +ALTER TABLE tbl DROP COLUMN c1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 102 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 103 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 104 +/* + * 7. Check various AMs. All but btree, gist and spgist must fail. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 box, c4 box) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 105 +CREATE INDEX on tbl USING brin(c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 106 +CREATE INDEX on tbl USING gist(c3) INCLUDE (c1, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 107 +CREATE INDEX on tbl USING spgist(c3) INCLUDE (c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 108 +CREATE INDEX on tbl USING gin(c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 109 +CREATE INDEX on tbl USING hash(c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 110 +CREATE INDEX on tbl USING rtree(c3) INCLUDE (c1, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 111 +CREATE INDEX on tbl USING btree(c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 112 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 113 +/* + * 8. Update, delete values in indexed table. + */ +CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 114 +INSERT INTO tbl SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 115 +CREATE UNIQUE INDEX tbl_idx_unique ON tbl using btree(c1, c2) INCLUDE (c3,c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +== 116 +UPDATE tbl SET c1 = 100 WHERE c1 = 2 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: UpdateStmt +== 117 +UPDATE tbl SET c1 = 1 WHERE c1 = 3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: UpdateStmt +== 118 +-- should fail +UPDATE tbl SET c2 = 2 WHERE c1 = 1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: UpdateStmt +== 119 +UPDATE tbl SET c3 = 1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: UpdateStmt +== 120 +DELETE FROM tbl WHERE c1 = 5 OR c3 = 12 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: DeleteStmt +== 121 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 122 +/* + * 9. Alter column type. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, UNIQUE(c1, c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +== 123 +INSERT INTO tbl SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 124 +ALTER TABLE tbl ALTER c1 TYPE bigint +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 125 +ALTER TABLE tbl ALTER c3 TYPE bigint +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 126 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +== 127 +/* + * 10. Test coverage for names stored as cstrings in indexes + */ +CREATE TABLE nametbl (c1 int, c2 name, c3 float) +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DDL +STMT: CreateStmt +== 128 +CREATE INDEX nametbl_c1_c2_idx ON nametbl (c2, c1) INCLUDE (c3) +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DDL +STMT: IndexStmt +== 129 +INSERT INTO nametbl VALUES(1, 'two', 3.0) +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 130 +VACUUM nametbl +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DDL +STMT: VacuumStmt +== 131 +SET enable_seqscan = 0 +-- +STMT: VariableSetStmt +== 132 +-- Ensure we get an index only scan plan +EXPLAIN (COSTS OFF) SELECT c2, c1, c3 FROM nametbl WHERE c2 = 'two' AND c1 = 1 +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=Select +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c1" +STMT: ExplainStmt +STMT: SelectStmt +== 133 +-- Validate the results look sane +SELECT c2, c1, c3 FROM nametbl WHERE c2 = 'two' AND c1 = 1 +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=Select +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c1" +STMT: SelectStmt +== 134 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 135 +DROP TABLE nametbl +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/index_including_gist.metadata.json b/parser/testdata/summary/postgres_regress/index_including_gist.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/index_including_gist.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/index_including_gist.test b/parser/testdata/summary/postgres_regress/index_including_gist.test new file mode 100644 index 0000000..5c4536b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/index_including_gist.test @@ -0,0 +1,368 @@ +== 001 +/* + * 1.1. test CREATE INDEX with buffered build + */ + +-- Regular index with included columns +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +== 002 +-- size is chosen to exceed page size and trigger actual truncation +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,8000) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c2,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +== 004 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_gist'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +== 005 +SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: SelectStmt +== 006 +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +== 007 +EXPLAIN (costs off) SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: ExplainStmt +STMT: SelectStmt +== 008 +SET enable_bitmapscan TO default +-- +STMT: VariableSetStmt +== 009 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +== 010 +/* + * 1.2. test CREATE INDEX with inserts + */ + +-- Regular index with included columns +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +== 011 +-- size is chosen to exceed page size and trigger actual truncation +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c2,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +== 012 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,8000) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 013 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_gist'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +== 014 +SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: SelectStmt +== 015 +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +== 016 +EXPLAIN (costs off) SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: ExplainStmt +STMT: SelectStmt +== 017 +SET enable_bitmapscan TO default +-- +STMT: VariableSetStmt +== 018 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +== 019 +/* + * 2. CREATE INDEX CONCURRENTLY + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +== 020 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 021 +CREATE INDEX CONCURRENTLY tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c2,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +== 022 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 023 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +== 024 +/* + * 3. REINDEX + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +== 025 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 026 +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +== 027 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 028 +REINDEX INDEX tbl_gist_idx +-- +STMT: ReindexStmt +== 029 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 030 +ALTER TABLE tbl_gist DROP COLUMN c1 +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: AlterTableStmt +== 031 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 032 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +== 033 +/* + * 4. Update, delete values in indexed table. + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +== 034 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 035 +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +== 036 +UPDATE tbl_gist SET c1 = 100 WHERE c1 = 2 +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +STMT: UpdateStmt +== 037 +UPDATE tbl_gist SET c1 = 1 WHERE c1 = 3 +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +STMT: UpdateStmt +== 038 +DELETE FROM tbl_gist WHERE c1 = 5 OR c3 = 12 +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +STMT: DeleteStmt +== 039 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +== 040 +/* + * 5. Alter column type. + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +== 041 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 042 +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +== 043 +ALTER TABLE tbl_gist ALTER c1 TYPE bigint +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: AlterTableStmt +== 044 +ALTER TABLE tbl_gist ALTER c3 TYPE bigint +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: AlterTableStmt +== 045 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +== 046 +/* + * 6. EXCLUDE constraint. + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box, EXCLUDE USING gist (c4 WITH &&) INCLUDE (c1, c2, c3)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +== 047 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(3*x,2*x),point(3*x+1,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 049 +EXPLAIN (costs off) SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: ExplainStmt +STMT: SelectStmt +== 050 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/indexing.metadata.json b/parser/testdata/summary/postgres_regress/indexing.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/indexing.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/indexing.test b/parser/testdata/summary/postgres_regress/indexing.test new file mode 100644 index 0000000..a92df17 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/indexing.test @@ -0,0 +1,3228 @@ +== 001 +-- Creating an index on a partitioned table makes the partitions +-- automatically get the index +create table idxpart (a int, b int, c text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 002 +-- relhassubclass of a partitioned index is false before creating any partition. +-- It will be set after the first partition is created. +create index idxpart_idx on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 003 +select relhassubclass from pg_class where relname = 'idxpart_idx' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 004 +-- Check that partitioned indexes are present in pg_indexes. +select indexdef from pg_indexes where indexname like 'idxpart_idx%' +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="indexname" +STMT: SelectStmt +== 005 +drop index idxpart_idx +-- +STMT: DropStmt +== 006 +create table idxpart1 partition of idxpart for values from (0) to (10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 007 +create table idxpart2 partition of idxpart for values from (10) to (100) + partition by range (b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 008 +create table idxpart21 partition of idxpart2 for values from (0) to (100) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +== 009 +-- Even with partitions, relhassubclass should not be set if a partitioned +-- index is created only on the parent. +create index idxpart_idx on only idxpart(a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 010 +select relhassubclass from pg_class where relname = 'idxpart_idx' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 011 +drop index idxpart_idx +-- +STMT: DropStmt +== 012 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 013 +select relname, relkind, relhassubclass, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 014 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 015 +-- Some unsupported features +create table idxpart (a int, b int, c text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 016 +create table idxpart1 partition of idxpart for values from (0) to (10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 017 +create index concurrently on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 018 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 019 +-- Verify bugfix with query on indexed partitioned table with no partitions +-- https://postgr.es/m/20180124162006.pmapfiznhgngwtjf@alvherre.pgsql +CREATE TABLE idxpart (col1 INT) PARTITION BY RANGE (col1) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 020 +CREATE INDEX ON idxpart (col1) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 021 +CREATE TABLE idxpart_two (col2 INT) +-- +TABLE: name="idxpart_two" schema="" table="idxpart_two" ctx=DDL +STMT: CreateStmt +== 022 +SELECT col2 FROM idxpart_two fk LEFT OUTER JOIN idxpart pk ON (col1 = col2) +-- +TABLE: name="idxpart_two" schema="" table="idxpart_two" ctx=Select +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +ALIAS: "fk"="idxpart_two" +ALIAS: "pk"="idxpart" +STMT: SelectStmt +== 023 +DROP table idxpart, idxpart_two +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart_two" schema="" table="idxpart_two" ctx=DDL +STMT: DropStmt +== 024 +-- Verify bugfix with index rewrite on ALTER TABLE / SET DATA TYPE +-- https://postgr.es/m/CAKcux6mxNCGsgATwf5CGMF8g4WSupCXicCVMeKUTuWbyxHOMsQ@mail.gmail.com +CREATE TABLE idxpart (a INT, b TEXT, c INT) PARTITION BY RANGE(a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 025 +CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (MINVALUE) TO (MAXVALUE) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 026 +CREATE INDEX partidx_abc_idx ON idxpart (a, b, c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 027 +INSERT INTO idxpart (a, b, c) SELECT i, i, i FROM generate_series(1, 50) i +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 028 +ALTER TABLE idxpart ALTER COLUMN c TYPE numeric +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 029 +DROP TABLE idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 030 +-- If a table without index is attached as partition to a table with +-- an index, the index is automatically created +create table idxpart (a int, b int, c text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 031 +create index idxparti on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 032 +create index idxparti2 on idxpart (b, c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 033 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 034 +alter table idxpart attach partition idxpart1 for values from (0) to (10) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 035 +-- Forbid ALTER TABLE when attaching or detaching an index to a partition. +create index idxpart_c on only idxpart (c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 036 +create index idxpart1_c on idxpart1 (c) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 037 +alter table idxpart_c attach partition idxpart1_c for values from (10) to (20) +-- +TABLE: name="idxpart_c" schema="" table="idxpart_c" ctx=DDL +STMT: AlterTableStmt +== 038 +alter index idxpart_c attach partition idxpart1_c +-- +STMT: AlterTableStmt +== 039 +select relname, relpartbound from pg_class + where relname in ('idxpart_c', 'idxpart1_c') + order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 040 +alter table idxpart_c detach partition idxpart1_c +-- +TABLE: name="idxpart_c" schema="" table="idxpart_c" ctx=DDL +STMT: AlterTableStmt +== 041 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 042 +-- If a partition already has an index, don't create a duplicative one +create table idxpart (a int, b int) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 043 +create table idxpart1 partition of idxpart for values from (0, 0) to (10, 10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 044 +create index on idxpart1 (a, b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 045 +create index on idxpart (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 046 +select relname, relkind, relhassubclass, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 047 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 048 +-- DROP behavior for partitioned indexes +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 049 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 050 +create table idxpart1 partition of idxpart for values from (0) to (10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 051 +drop index idxpart1_a_idx +-- +STMT: DropStmt +== 052 +-- no way +drop index concurrently idxpart_a_idx +-- +STMT: DropStmt +== 053 +-- unsupported +drop index idxpart_a_idx +-- +STMT: DropStmt +== 054 +-- both indexes go away +select relname, relkind from pg_class + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 055 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 056 +drop table idxpart1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: DropStmt +== 057 +-- the index on partition goes away too +select relname, relkind from pg_class + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 058 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 059 +-- DROP behavior with temporary partitioned indexes +create temp table idxpart_temp (a int) partition by range (a) +-- +TABLE: name="idxpart_temp" schema="" table="idxpart_temp" ctx=DDL +STMT: CreateStmt +== 060 +create index on idxpart_temp(a) +-- +TABLE: name="idxpart_temp" schema="" table="idxpart_temp" ctx=DDL +STMT: IndexStmt +== 061 +create temp table idxpart1_temp partition of idxpart_temp + for values from (0) to (10) +-- +TABLE: name="idxpart1_temp" schema="" table="idxpart1_temp" ctx=DDL +STMT: CreateStmt +== 062 +drop index idxpart1_temp_a_idx +-- +STMT: DropStmt +== 063 +-- error +-- non-concurrent drop is enforced here, so it is a valid case. +drop index concurrently idxpart_temp_a_idx +-- +STMT: DropStmt +== 064 +select relname, relkind from pg_class + where relname like 'idxpart_temp%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 065 +drop table idxpart_temp +-- +TABLE: name="idxpart_temp" schema="" table="idxpart_temp" ctx=DDL +STMT: DropStmt +== 066 +-- ALTER INDEX .. ATTACH, error cases +create table idxpart (a int, b int) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 067 +create table idxpart1 partition of idxpart for values from (0, 0) to (10, 10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 068 +create index idxpart_a_b_idx on only idxpart (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 069 +create index idxpart1_a_b_idx on idxpart1 (a, b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 070 +create index idxpart1_tst1 on idxpart1 (b, a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 071 +create index idxpart1_tst2 on idxpart1 using hash (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 072 +create index idxpart1_tst3 on idxpart1 (a, b) where a > 10 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 073 +alter index idxpart attach partition idxpart1 +-- +STMT: AlterTableStmt +== 074 +alter index idxpart_a_b_idx attach partition idxpart1 +-- +STMT: AlterTableStmt +== 075 +alter index idxpart_a_b_idx attach partition idxpart_a_b_idx +-- +STMT: AlterTableStmt +== 076 +alter index idxpart_a_b_idx attach partition idxpart1_b_idx +-- +STMT: AlterTableStmt +== 077 +alter index idxpart_a_b_idx attach partition idxpart1_tst1 +-- +STMT: AlterTableStmt +== 078 +alter index idxpart_a_b_idx attach partition idxpart1_tst2 +-- +STMT: AlterTableStmt +== 079 +alter index idxpart_a_b_idx attach partition idxpart1_tst3 +-- +STMT: AlterTableStmt +== 080 +-- OK +alter index idxpart_a_b_idx attach partition idxpart1_a_b_idx +-- +STMT: AlterTableStmt +== 081 +alter index idxpart_a_b_idx attach partition idxpart1_a_b_idx +-- +STMT: AlterTableStmt +== 082 +-- quiet + +-- reject dupe +create index idxpart1_2_a_b on idxpart1 (a, b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 083 +alter index idxpart_a_b_idx attach partition idxpart1_2_a_b +-- +STMT: AlterTableStmt +== 084 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 085 +-- make sure everything's gone +select indexrelid::regclass, indrelid::regclass + from pg_index where indexrelid::regclass::text like 'idxpart%' +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +== 086 +-- Don't auto-attach incompatible indexes +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 087 +create table idxpart1 (a int, b int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 088 +create index on idxpart1 using hash (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 089 +create index on idxpart1 (a) where b > 1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 090 +create index on idxpart1 ((a + 0)) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 091 +create index on idxpart1 (a, a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 092 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 093 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 094 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 095 +-- If CREATE INDEX ONLY, don't create indexes on partitions; and existing +-- indexes on partitions don't change parent. ALTER INDEX ATTACH can change +-- the parent after the fact. +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 096 +create table idxpart1 partition of idxpart for values from (0) to (100) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 097 +create table idxpart2 partition of idxpart for values from (100) to (1000) + partition by range (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 098 +create table idxpart21 partition of idxpart2 for values from (100) to (200) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +== 099 +create table idxpart22 partition of idxpart2 for values from (200) to (300) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: CreateStmt +== 100 +create index on idxpart22 (a) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: IndexStmt +== 101 +create index on only idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 102 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 103 +-- Here we expect that idxpart1 and idxpart2 have a new index, but idxpart21 +-- does not; also, idxpart22 is not attached. +select indexrelid::regclass, indrelid::regclass, inhparent::regclass + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) +where indexrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +== 104 +alter index idxpart2_a_idx attach partition idxpart22_a_idx +-- +STMT: AlterTableStmt +== 105 +select indexrelid::regclass, indrelid::regclass, inhparent::regclass + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) +where indexrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +== 106 +-- attaching idxpart22 is not enough to set idxpart22_a_idx valid ... +alter index idxpart2_a_idx attach partition idxpart22_a_idx +-- +STMT: AlterTableStmt +== 107 +-- ... but this one is. +create index on idxpart21 (a) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: IndexStmt +== 108 +alter index idxpart2_a_idx attach partition idxpart21_a_idx +-- +STMT: AlterTableStmt +== 109 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 110 +-- When a table is attached a partition and it already has an index, a +-- duplicate index should not get created, but rather the index becomes +-- attached to the parent's index. +create table idxpart (a int, b int, c text, d bool) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 111 +create index idxparti on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 112 +create index idxparti2 on idxpart (b, c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 113 +create table idxpart1 (like idxpart including indexes) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 114 +select relname, relkind, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 115 +alter table idxpart attach partition idxpart1 for values from (0) to (10) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 116 +select relname, relkind, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 117 +-- While here, also check matching when creating an index after the fact. +create index on idxpart1 ((a+b)) where d = true +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 118 +select relname, relkind, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 119 +create index idxparti3 on idxpart ((a+b)) where d = true +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 120 +select relname, relkind, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 121 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 122 +-- Verify that attaching an invalid index does not mark the parent index valid. +-- On the other hand, attaching a valid index marks not only its direct +-- ancestor valid, but also any indirect ancestor that was only missing the one +-- that was just made valid +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 123 +create table idxpart1 partition of idxpart for values from (1) to (1000) partition by range (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 124 +create table idxpart11 partition of idxpart1 for values from (1) to (100) +-- +TABLE: name="idxpart11" schema="" table="idxpart11" ctx=DDL +STMT: CreateStmt +== 125 +create index on only idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 126 +create index on only idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 127 +-- this results in two invalid indexes: +select relname, indisvalid from pg_class join pg_index on indexrelid = oid + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 128 +-- idxpart1_a_idx is not valid, so idxpart_a_idx should not become valid: +alter index idxpart_a_idx attach partition idxpart1_a_idx +-- +STMT: AlterTableStmt +== 129 +select relname, indisvalid from pg_class join pg_index on indexrelid = oid + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 130 +-- after creating and attaching this, both idxpart1_a_idx and idxpart_a_idx +-- should become valid +create index on idxpart11 (a) +-- +TABLE: name="idxpart11" schema="" table="idxpart11" ctx=DDL +STMT: IndexStmt +== 131 +alter index idxpart1_a_idx attach partition idxpart11_a_idx +-- +STMT: AlterTableStmt +== 132 +select relname, indisvalid from pg_class join pg_index on indexrelid = oid + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 133 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 134 +-- verify dependency handling during ALTER TABLE DETACH PARTITION +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 135 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 136 +create index on idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 137 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 138 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 139 +alter table idxpart attach partition idxpart1 for values from (0000) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 140 +alter table idxpart attach partition idxpart2 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 141 +create table idxpart3 partition of idxpart for values from (2000) to (3000) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +== 142 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 143 +-- a) after detaching partitions, the indexes can be dropped independently +alter table idxpart detach partition idxpart1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 144 +alter table idxpart detach partition idxpart2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 145 +alter table idxpart detach partition idxpart3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 146 +drop index idxpart1_a_idx +-- +STMT: DropStmt +== 147 +drop index idxpart2_a_idx +-- +STMT: DropStmt +== 148 +drop index idxpart3_a_idx +-- +STMT: DropStmt +== 149 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 150 +drop table idxpart, idxpart1, idxpart2, idxpart3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: DropStmt +== 151 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 152 +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 153 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 154 +create index on idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 155 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 156 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 157 +alter table idxpart attach partition idxpart1 for values from (0000) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 158 +alter table idxpart attach partition idxpart2 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 159 +create table idxpart3 partition of idxpart for values from (2000) to (3000) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +== 160 +-- b) after detaching, dropping the index on parent does not remove the others +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 161 +alter table idxpart detach partition idxpart1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 162 +alter table idxpart detach partition idxpart2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 163 +alter table idxpart detach partition idxpart3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 164 +drop index idxpart_a_idx +-- +STMT: DropStmt +== 165 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 166 +drop table idxpart, idxpart1, idxpart2, idxpart3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: DropStmt +== 167 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 168 +create table idxpart (a int, b int, c int) partition by range(a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 169 +create index on idxpart(c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 170 +create table idxpart1 partition of idxpart for values from (0) to (250) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 171 +create table idxpart2 partition of idxpart for values from (250) to (500) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 172 +alter table idxpart detach partition idxpart2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 173 +alter table idxpart2 drop column c +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: AlterTableStmt +== 174 +drop table idxpart, idxpart2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: DropStmt +== 175 +-- Verify that expression indexes inherit correctly +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 176 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 177 +create index on idxpart1 ((a + b)) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 178 +create index on idxpart ((a + b)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 179 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 180 +alter table idxpart attach partition idxpart1 for values from (0000) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 181 +alter table idxpart attach partition idxpart2 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 182 +create table idxpart3 partition of idxpart for values from (2000) to (3000) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +== 183 +select relname as child, inhparent::regclass as parent, pg_get_indexdef as childdef + from pg_class join pg_inherits on inhrelid = oid, + lateral pg_get_indexdef(pg_class.oid) + where relkind in ('i', 'I') and relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 184 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 185 +-- Verify behavior for collation (mis)matches +create table idxpart (a text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 186 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 187 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 188 +create index on idxpart2 (a collate "POSIX") +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 189 +create index on idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 190 +create index on idxpart2 (a collate "C") +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 191 +alter table idxpart attach partition idxpart1 for values from ('aaa') to ('bbb') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 192 +alter table idxpart attach partition idxpart2 for values from ('bbb') to ('ccc') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 193 +create table idxpart3 partition of idxpart for values from ('ccc') to ('ddd') +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +== 194 +create index on idxpart (a collate "C") +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 195 +create table idxpart4 partition of idxpart for values from ('ddd') to ('eee') +-- +TABLE: name="idxpart4" schema="" table="idxpart4" ctx=DDL +STMT: CreateStmt +== 196 +select relname as child, inhparent::regclass as parent, pg_get_indexdef as childdef + from pg_class left join pg_inherits on inhrelid = oid, + lateral pg_get_indexdef(pg_class.oid) + where relkind in ('i', 'I') and relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 197 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 198 +-- Verify behavior for opclass (mis)matches +create table idxpart (a text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 199 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 200 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 201 +create index on idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 202 +alter table idxpart attach partition idxpart1 for values from ('aaa') to ('bbb') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 203 +alter table idxpart attach partition idxpart2 for values from ('bbb') to ('ccc') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 204 +create table idxpart3 partition of idxpart for values from ('ccc') to ('ddd') +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +== 205 +create index on idxpart (a text_pattern_ops) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 206 +create table idxpart4 partition of idxpart for values from ('ddd') to ('eee') +-- +TABLE: name="idxpart4" schema="" table="idxpart4" ctx=DDL +STMT: CreateStmt +== 207 +-- must *not* have attached the index we created on idxpart2 +select relname as child, inhparent::regclass as parent, pg_get_indexdef as childdef + from pg_class left join pg_inherits on inhrelid = oid, + lateral pg_get_indexdef(pg_class.oid) + where relkind in ('i', 'I') and relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 208 +drop index idxpart_a_idx +-- +STMT: DropStmt +== 209 +create index on only idxpart (a text_pattern_ops) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 210 +-- must reject +alter index idxpart_a_idx attach partition idxpart2_a_idx +-- +STMT: AlterTableStmt +== 211 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 212 +-- Verify that attaching indexes maps attribute numbers correctly +create table idxpart (col1 int, a int, col2 int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 213 +create table idxpart1 (b int, col1 int, col2 int, col3 int, a int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 214 +alter table idxpart drop column col1, drop column col2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 215 +alter table idxpart1 drop column col1, drop column col2, drop column col3 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 216 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 217 +create index idxpart_1_idx on only idxpart (b, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 218 +create index idxpart1_1_idx on idxpart1 (b, a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 219 +create index idxpart1_1b_idx on idxpart1 (b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 220 +-- test expressions and partial-index predicate, too +create index idxpart_2_idx on only idxpart ((b + a)) where a > 1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 221 +create index idxpart1_2_idx on idxpart1 ((b + a)) where a > 1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 222 +create index idxpart1_2b_idx on idxpart1 ((a + b)) where a > 1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 223 +create index idxpart1_2c_idx on idxpart1 ((b + a)) where b > 1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 224 +alter index idxpart_1_idx attach partition idxpart1_1b_idx +-- +STMT: AlterTableStmt +== 225 +-- fail +alter index idxpart_1_idx attach partition idxpart1_1_idx +-- +STMT: AlterTableStmt +== 226 +alter index idxpart_2_idx attach partition idxpart1_2b_idx +-- +STMT: AlterTableStmt +== 227 +-- fail +alter index idxpart_2_idx attach partition idxpart1_2c_idx +-- +STMT: AlterTableStmt +== 228 +-- fail +alter index idxpart_2_idx attach partition idxpart1_2_idx +-- +STMT: AlterTableStmt +== 229 +-- ok +select relname as child, inhparent::regclass as parent, pg_get_indexdef as childdef + from pg_class left join pg_inherits on inhrelid = oid, + lateral pg_get_indexdef(pg_class.oid) + where relkind in ('i', 'I') and relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 230 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 231 +-- Make sure the partition columns are mapped correctly +create table idxpart (a int, b int, c text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 232 +create index idxparti on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 233 +create index idxparti2 on idxpart (c, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 234 +create table idxpart1 (c text, a int, b int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 235 +alter table idxpart attach partition idxpart1 for values from (0) to (10) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 236 +create table idxpart2 (c text, a int, b int) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 237 +create index on idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 238 +create index on idxpart2 (c, b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 239 +alter table idxpart attach partition idxpart2 for values from (10) to (20) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 240 +select c.relname, pg_get_indexdef(indexrelid) + from pg_class c join pg_index i on c.oid = i.indexrelid + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 241 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 242 +-- Verify that columns are mapped correctly in expression indexes +create table idxpart (col1 int, col2 int, a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 243 +create table idxpart1 (col2 int, b int, col1 int, a int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 244 +create table idxpart2 (col1 int, col2 int, b int, a int) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 245 +alter table idxpart drop column col1, drop column col2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 246 +alter table idxpart1 drop column col1, drop column col2 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 247 +alter table idxpart2 drop column col1, drop column col2 +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: AlterTableStmt +== 248 +create index on idxpart2 (abs(b)) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 249 +alter table idxpart attach partition idxpart2 for values from (0) to (1) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 250 +create index on idxpart (abs(b)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 251 +create index on idxpart ((b + 1)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 252 +alter table idxpart attach partition idxpart1 for values from (1) to (2) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 253 +select c.relname, pg_get_indexdef(indexrelid) + from pg_class c join pg_index i on c.oid = i.indexrelid + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 254 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 255 +-- Verify that columns are mapped correctly for WHERE in a partial index +create table idxpart (col1 int, a int, col3 int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 256 +alter table idxpart drop column col1, drop column col3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 257 +create table idxpart1 (col1 int, col2 int, col3 int, col4 int, b int, a int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 258 +alter table idxpart1 drop column col1, drop column col2, drop column col3, drop column col4 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 259 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 260 +create table idxpart2 (col1 int, col2 int, b int, a int) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 261 +create index on idxpart2 (a) where b > 1000 +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 262 +alter table idxpart2 drop column col1, drop column col2 +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: AlterTableStmt +== 263 +alter table idxpart attach partition idxpart2 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 264 +create index on idxpart (a) where b > 1000 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 265 +select c.relname, pg_get_indexdef(indexrelid) + from pg_class c join pg_index i on c.oid = i.indexrelid + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 266 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 267 +-- Column number mapping: dropped columns in the partition +create table idxpart1 (drop_1 int, drop_2 int, col_keep int, drop_3 int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 268 +alter table idxpart1 drop column drop_1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 269 +alter table idxpart1 drop column drop_2 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 270 +alter table idxpart1 drop column drop_3 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 271 +create index on idxpart1 (col_keep) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 272 +create table idxpart (col_keep int) partition by range (col_keep) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 273 +create index on idxpart (col_keep) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 274 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 275 +select attrelid::regclass, attname, attnum from pg_attribute + where attrelid::regclass::text like 'idxpart%' and attnum > 0 + order by attrelid::regclass, attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +== 276 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 277 +-- Column number mapping: dropped columns in the parent table +create table idxpart(drop_1 int, drop_2 int, col_keep int, drop_3 int) partition by range (col_keep) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 278 +alter table idxpart drop column drop_1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 279 +alter table idxpart drop column drop_2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 280 +alter table idxpart drop column drop_3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 281 +create table idxpart1 (col_keep int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 282 +create index on idxpart1 (col_keep) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 283 +create index on idxpart (col_keep) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 284 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 285 +select attrelid::regclass, attname, attnum from pg_attribute + where attrelid::regclass::text like 'idxpart%' and attnum > 0 + order by attrelid::regclass, attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +== 286 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 287 +|-- +-- Constraint-related indexes +|-- + +-- Verify that it works to add primary key / unique to partitioned tables +create table idxpart (a int primary key, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 288 +-- multiple primary key on child should fail +create table failpart partition of idxpart (b primary key) for values from (0) to (100) +-- +TABLE: name="failpart" schema="" table="failpart" ctx=DDL +STMT: CreateStmt +== 289 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 290 +-- primary key on child is okay if there's no PK in the parent, though +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 291 +create table idxpart1pk partition of idxpart (a primary key) for values from (0) to (100) +-- +TABLE: name="idxpart1pk" schema="" table="idxpart1pk" ctx=DDL +STMT: CreateStmt +== 292 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 293 +-- Failing to use the full partition key is not allowed +create table idxpart (a int unique, b int) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 294 +create table idxpart (a int, b int unique) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 295 +create table idxpart (a int primary key, b int) partition by range (b, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 296 +create table idxpart (a int, b int primary key) partition by range (b, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 297 +-- OK if you use them in some other order +create table idxpart (a int, b int, c text, primary key (a, b, c)) partition by range (b, c, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 298 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 299 +-- OK to add an exclusion constraint if partitioning by its equal column +create table idxpart (a int4range, exclude USING GIST (a with = )) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 300 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 301 +-- OK more than one equal column +create table idxpart (a int4range, b int4range, exclude USING GIST (a with =, b with =)) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 302 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 303 +-- OK with more than one equal column: constraint is a proper superset of partition key +create table idxpart (a int4range, b int4range, exclude USING GIST (a with =, b with =)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 304 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 305 +-- Not OK more than one equal column: partition keys are a proper superset of constraint +create table idxpart (a int4range, b int4range, exclude USING GIST (a with = )) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 306 +-- Not OK with just -|- +create table idxpart (a int4range, exclude USING GIST (a with -|- )) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 307 +-- OK with equals and &&, and equals is the partition key +create table idxpart (a int4range, b int4range, exclude USING GIST (a with =, b with &&)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 308 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 309 +-- Not OK with equals and &&, and equals is not the partition key +create table idxpart (a int4range, b int4range, c int4range, exclude USING GIST (b with =, c with &&)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 310 +-- OK more than one equal column and a && column +create table idxpart (a int4range, b int4range, c int4range, exclude USING GIST (a with =, b with =, c with &&)) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 311 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 312 +-- no expressions in partition key for PK/UNIQUE +create table idxpart (a int primary key, b int) partition by range ((b + a)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 313 +create table idxpart (a int unique, b int) partition by range ((b + a)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 314 +-- use ALTER TABLE to add a primary key +create table idxpart (a int, b int, c text) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 315 +alter table idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 316 +-- not an incomplete one though +alter table idxpart add primary key (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 317 +-- this works +create table idxpart1 partition of idxpart for values from (0, 0) to (1000, 1000) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 318 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 319 +-- use ALTER TABLE to add a unique constraint +create table idxpart (a int, b int) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 320 +alter table idxpart add unique (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 321 +-- not an incomplete one though +alter table idxpart add unique (b, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 322 +-- this works +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 323 +-- Exclusion constraints can be added if partitioning by their equal column +create table idxpart (a int4range, b int4range) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 324 +alter table idxpart add exclude USING GIST (a with =) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 325 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 326 +-- OK more than one equal column +create table idxpart (a int4range, b int4range) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 327 +alter table idxpart add exclude USING GIST (a with =, b with =) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 328 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 329 +-- OK with more than one equal column: constraint is a proper superset of partition key +create table idxpart (a int4range, b int4range) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 330 +alter table idxpart add exclude USING GIST (a with =, b with =) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 331 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 332 +-- Not OK more than one equal column: partition keys are a proper superset of constraint +create table idxpart (a int4range, b int4range) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 333 +alter table idxpart add exclude USING GIST (a with =) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 334 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 335 +-- Not OK with just -|- +create table idxpart (a int4range, b int4range) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 336 +alter table idxpart add exclude USING GIST (a with -|-) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 337 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 338 +-- OK with equals and &&, and equals is the partition key +create table idxpart (a int4range, b int4range) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 339 +alter table idxpart add exclude USING GIST (a with =, b with &&) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 340 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 341 +-- Not OK with equals and &&, and equals is not the partition key +create table idxpart (a int4range, b int4range, c int4range) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 342 +alter table idxpart add exclude USING GIST (b with =, c with &&) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 343 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 344 +-- OK more than one equal column and a && column +create table idxpart (a int4range, b int4range, c int4range) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 345 +alter table idxpart add exclude USING GIST (a with =, b with =, c with &&) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 346 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 347 +-- When (sub)partitions are created, they also contain the constraint +create table idxpart (a int, b int, primary key (a, b)) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 348 +create table idxpart1 partition of idxpart for values from (1, 1) to (10, 10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 349 +create table idxpart2 partition of idxpart for values from (10, 10) to (20, 20) + partition by range (b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 350 +create table idxpart21 partition of idxpart2 for values from (10) to (15) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +== 351 +create table idxpart22 partition of idxpart2 for values from (15) to (20) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: CreateStmt +== 352 +create table idxpart3 (b int not null, a int not null) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +== 353 +alter table idxpart attach partition idxpart3 for values from (20, 20) to (30, 30) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 354 +select conname, contype, conrelid::regclass, conindid::regclass, conkey + from pg_constraint where conrelid::regclass::text like 'idxpart%' + order by conrelid::regclass::text, conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 355 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 356 +-- Verify that multi-layer partitioning honors the requirement that all +-- columns in the partition key must appear in primary/unique key +create table idxpart (a int, b int, primary key (a)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 357 +create table idxpart2 partition of idxpart +for values from (0) to (1000) partition by range (b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 358 +-- fail +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 359 +-- Ditto for the ATTACH PARTITION case +create table idxpart (a int unique, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 360 +create table idxpart1 (a int not null, b int, unique (a, b)) + partition by range (a, b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 361 +alter table idxpart attach partition idxpart1 for values from (1) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 362 +DROP TABLE idxpart, idxpart1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: DropStmt +== 363 +-- Multi-layer partitioning works correctly in this case: +create table idxpart (a int, b int, primary key (a, b)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 364 +create table idxpart2 partition of idxpart for values from (0) to (1000) partition by range (b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 365 +create table idxpart21 partition of idxpart2 for values from (0) to (1000) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +== 366 +select conname, contype, conrelid::regclass, conindid::regclass, conkey + from pg_constraint where conrelid::regclass::text like 'idxpart%' + order by conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +== 367 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 368 +-- If a partitioned table has a unique/PK constraint, then it's not possible +-- to drop the corresponding constraint in the children; nor it's possible +-- to drop the indexes individually. Dropping the constraint in the parent +-- gets rid of the lot. +create table idxpart (i int) partition by hash (i) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 369 +create table idxpart0 partition of idxpart (i) for values with (modulus 2, remainder 0) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: CreateStmt +== 370 +create table idxpart1 partition of idxpart (i) for values with (modulus 2, remainder 1) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 371 +alter table idxpart0 add primary key(i) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +== 372 +alter table idxpart add primary key(i) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 373 +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 374 +drop index idxpart0_pkey +-- +STMT: DropStmt +== 375 +-- fail +drop index idxpart1_pkey +-- +STMT: DropStmt +== 376 +-- fail +alter table idxpart0 drop constraint idxpart0_pkey +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +== 377 +-- fail +alter table idxpart1 drop constraint idxpart1_pkey +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 378 +-- fail +alter table idxpart drop constraint idxpart_pkey +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 379 +-- ok +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 380 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 381 +-- If the partition to be attached already has a primary key, fail if +-- it doesn't match the parent's PK. +CREATE TABLE idxpart (c1 INT PRIMARY KEY, c2 INT, c3 VARCHAR(10)) PARTITION BY RANGE(c1) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 382 +CREATE TABLE idxpart1 (LIKE idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 383 +ALTER TABLE idxpart1 ADD PRIMARY KEY (c1, c2) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 384 +ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (100) TO (200) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 385 +DROP TABLE idxpart, idxpart1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: DropStmt +== 386 +-- Ditto if there is some distance between the PKs (subpartitioning) +create table idxpart (a int, b int, primary key (a)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 387 +create table idxpart1 (a int not null, b int) partition by range (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 388 +create table idxpart11 (a int not null, b int primary key) +-- +TABLE: name="idxpart11" schema="" table="idxpart11" ctx=DDL +STMT: CreateStmt +== 389 +alter table idxpart1 attach partition idxpart11 for values from (0) to (1000) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +== 390 +alter table idxpart attach partition idxpart1 for values from (0) to (10000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 391 +drop table idxpart, idxpart1, idxpart11 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +TABLE: name="idxpart11" schema="" table="idxpart11" ctx=DDL +STMT: DropStmt +== 392 +-- If a partitioned table has a constraint whose index is not valid, +-- attaching a missing partition makes it valid. +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 393 +create table idxpart0 (like idxpart) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: CreateStmt +== 394 +alter table idxpart0 add primary key (a) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +== 395 +alter table idxpart attach partition idxpart0 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 396 +alter table only idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 397 +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 398 +alter index idxpart_pkey attach partition idxpart0_pkey +-- +STMT: AlterTableStmt +== 399 +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 400 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 401 +-- Related to the above scenario: ADD PRIMARY KEY on the parent mustn't +-- automatically propagate NOT NULL to child columns. +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 402 +create table idxpart0 (like idxpart) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: CreateStmt +== 403 +alter table idxpart0 add unique (a) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +== 404 +alter table idxpart attach partition idxpart0 default +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 405 +alter table only idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 406 +-- fail, no not-null constraint +alter table idxpart0 alter column a set not null +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +== 407 +alter table only idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 408 +-- now it works +alter index idxpart_pkey attach partition idxpart0_a_key +-- +STMT: AlterTableStmt +== 409 +alter table idxpart0 alter column a drop not null +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +== 410 +-- fail, pkey needs it +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 411 +-- if a partition has a unique index without a constraint, does not attach +-- automatically; creates a new index instead. +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 412 +create table idxpart1 (a int not null, b int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 413 +create unique index on idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 414 +alter table idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 415 +alter table idxpart attach partition idxpart1 for values from (1) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 416 +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 417 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 418 +-- Can't attach an index without a corresponding constraint +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 419 +create table idxpart1 (a int not null, b int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 420 +create unique index on idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +== 421 +alter table idxpart attach partition idxpart1 for values from (1) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 422 +alter table only idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 423 +alter index idxpart_pkey attach partition idxpart1_a_idx +-- +STMT: AlterTableStmt +== 424 +-- fail +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 425 +-- Test that unique constraints are working +create table idxpart (a int, b text, primary key (a, b)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 426 +create table idxpart1 partition of idxpart for values from (0) to (100000) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 427 +create table idxpart2 (c int, like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 428 +insert into idxpart2 (c, a, b) values (42, 572814, 'inserted first') +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 429 +alter table idxpart2 drop column c +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: AlterTableStmt +== 430 +create unique index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 431 +alter table idxpart attach partition idxpart2 for values from (100000) to (1000000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 432 +insert into idxpart values (0, 'zero'), (42, 'life'), (2^16, 'sixteen') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 433 +insert into idxpart select 2^g, format('two to power of %s', g) from generate_series(15, 17) g +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 434 +insert into idxpart values (16, 'sixteen') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 435 +insert into idxpart (b, a) values ('one', 142857), ('two', 285714) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 436 +insert into idxpart select a * 2, b || b from idxpart where a between 2^16 and 2^19 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 437 +insert into idxpart values (572814, 'five') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 438 +insert into idxpart values (857142, 'six') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 439 +select tableoid::regclass, * from idxpart order by a +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +STMT: SelectStmt +== 440 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 441 +-- Test some other non-btree index types +create table idxpart (a int, b text, c int[]) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 442 +create table idxpart1 partition of idxpart for values from (0) to (100000) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 443 +set enable_seqscan to off +-- +STMT: VariableSetStmt +== 444 +create index idxpart_brin on idxpart using brin(b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 445 +explain (costs off) select * from idxpart where b = 'abcd' +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 446 +drop index idxpart_brin +-- +STMT: DropStmt +== 447 +create index idxpart_spgist on idxpart using spgist(b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 448 +explain (costs off) select * from idxpart where b = 'abcd' +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 449 +drop index idxpart_spgist +-- +STMT: DropStmt +== 450 +create index idxpart_gin on idxpart using gin(c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 451 +explain (costs off) select * from idxpart where c @> array[42] +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 452 +drop index idxpart_gin +-- +STMT: DropStmt +== 453 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 454 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +== 455 +-- intentionally leave some objects around +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +== 456 +create table idxpart1 partition of idxpart for values from (0) to (100) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +== 457 +create table idxpart2 partition of idxpart for values from (100) to (1000) + partition by range (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +== 458 +create table idxpart21 partition of idxpart2 for values from (100) to (200) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +== 459 +create table idxpart22 partition of idxpart2 for values from (200) to (300) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: CreateStmt +== 460 +create index on idxpart22 (a) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: IndexStmt +== 461 +create index on only idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +== 462 +alter index idxpart2_a_idx attach partition idxpart22_a_idx +-- +STMT: AlterTableStmt +== 463 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +== 464 +create table idxpart_another (a int, b int, primary key (a, b)) partition by range (a) +-- +TABLE: name="idxpart_another" schema="" table="idxpart_another" ctx=DDL +STMT: CreateStmt +== 465 +create table idxpart_another_1 partition of idxpart_another for values from (0) to (100) +-- +TABLE: name="idxpart_another_1" schema="" table="idxpart_another_1" ctx=DDL +STMT: CreateStmt +== 466 +create table idxpart3 (c int, b int, a int) partition by range (a) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +== 467 +alter table idxpart3 drop column b, drop column c +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: AlterTableStmt +== 468 +create table idxpart31 partition of idxpart3 for values from (1000) to (1200) +-- +TABLE: name="idxpart31" schema="" table="idxpart31" ctx=DDL +STMT: CreateStmt +== 469 +create table idxpart32 partition of idxpart3 for values from (1200) to (1400) +-- +TABLE: name="idxpart32" schema="" table="idxpart32" ctx=DDL +STMT: CreateStmt +== 470 +alter table idxpart attach partition idxpart3 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +== 471 +-- More objects intentionally left behind, to verify some pg_dump/pg_upgrade +-- behavior; see https://postgr.es/m/20190321204928.GA17535@alvherre.pgsql +create schema regress_indexing +-- +STMT: CreateSchemaStmt +== 472 +set search_path to regress_indexing +-- +STMT: VariableSetStmt +== 473 +create table pk (a int primary key) partition by range (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +== 474 +create table pk1 partition of pk for values from (0) to (1000) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +== 475 +create table pk2 (b int, a int) +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: CreateStmt +== 476 +alter table pk2 drop column b +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: AlterTableStmt +== 477 +alter table pk2 alter a set not null +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: AlterTableStmt +== 478 +alter table pk attach partition pk2 for values from (1000) to (2000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +== 479 +create table pk3 partition of pk for values from (2000) to (3000) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: CreateStmt +== 480 +create table pk4 (like pk) +-- +TABLE: name="pk4" schema="" table="pk4" ctx=DDL +STMT: CreateStmt +== 481 +alter table pk attach partition pk4 for values from (3000) to (4000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +== 482 +create table pk5 (like pk) partition by range (a) +-- +TABLE: name="pk5" schema="" table="pk5" ctx=DDL +STMT: CreateStmt +== 483 +create table pk51 partition of pk5 for values from (4000) to (4500) +-- +TABLE: name="pk51" schema="" table="pk51" ctx=DDL +STMT: CreateStmt +== 484 +create table pk52 partition of pk5 for values from (4500) to (5000) +-- +TABLE: name="pk52" schema="" table="pk52" ctx=DDL +STMT: CreateStmt +== 485 +alter table pk attach partition pk5 for values from (4000) to (5000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +== 486 +reset search_path +-- +STMT: VariableSetStmt +== 487 +-- Test that covering partitioned indexes work in various cases +create table covidxpart (a int, b int) partition by list (a) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: CreateStmt +== 488 +create unique index on covidxpart (a) include (b) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: IndexStmt +== 489 +create table covidxpart1 partition of covidxpart for values in (1) +-- +TABLE: name="covidxpart1" schema="" table="covidxpart1" ctx=DDL +STMT: CreateStmt +== 490 +create table covidxpart2 partition of covidxpart for values in (2) +-- +TABLE: name="covidxpart2" schema="" table="covidxpart2" ctx=DDL +STMT: CreateStmt +== 491 +insert into covidxpart values (1, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 492 +insert into covidxpart values (1, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 493 +create table covidxpart3 (b int, c int, a int) +-- +TABLE: name="covidxpart3" schema="" table="covidxpart3" ctx=DDL +STMT: CreateStmt +== 494 +alter table covidxpart3 drop c +-- +TABLE: name="covidxpart3" schema="" table="covidxpart3" ctx=DDL +STMT: AlterTableStmt +== 495 +alter table covidxpart attach partition covidxpart3 for values in (3) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: AlterTableStmt +== 496 +insert into covidxpart values (3, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 497 +insert into covidxpart values (3, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 498 +create table covidxpart4 (b int, a int) +-- +TABLE: name="covidxpart4" schema="" table="covidxpart4" ctx=DDL +STMT: CreateStmt +== 499 +create unique index on covidxpart4 (a) include (b) +-- +TABLE: name="covidxpart4" schema="" table="covidxpart4" ctx=DDL +STMT: IndexStmt +== 500 +create unique index on covidxpart4 (a) +-- +TABLE: name="covidxpart4" schema="" table="covidxpart4" ctx=DDL +STMT: IndexStmt +== 501 +alter table covidxpart attach partition covidxpart4 for values in (4) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: AlterTableStmt +== 502 +insert into covidxpart values (4, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 503 +insert into covidxpart values (4, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 504 +create unique index on covidxpart (b) include (a) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: IndexStmt +== 505 +-- should fail + +-- check that detaching a partition also detaches the primary key constraint +create table parted_pk_detach_test (a int primary key) partition by list (a) +-- +TABLE: name="parted_pk_detach_test" schema="" table="parted_pk_detach_test" ctx=DDL +STMT: CreateStmt +== 506 +create table parted_pk_detach_test1 partition of parted_pk_detach_test for values in (1) +-- +TABLE: name="parted_pk_detach_test1" schema="" table="parted_pk_detach_test1" ctx=DDL +STMT: CreateStmt +== 507 +alter table parted_pk_detach_test1 drop constraint parted_pk_detach_test1_pkey +-- +TABLE: name="parted_pk_detach_test1" schema="" table="parted_pk_detach_test1" ctx=DDL +STMT: AlterTableStmt +== 508 +-- should fail +alter table parted_pk_detach_test detach partition parted_pk_detach_test1 +-- +TABLE: name="parted_pk_detach_test" schema="" table="parted_pk_detach_test" ctx=DDL +STMT: AlterTableStmt +== 509 +alter table parted_pk_detach_test1 drop constraint parted_pk_detach_test1_pkey +-- +TABLE: name="parted_pk_detach_test1" schema="" table="parted_pk_detach_test1" ctx=DDL +STMT: AlterTableStmt +== 510 +drop table parted_pk_detach_test, parted_pk_detach_test1 +-- +TABLE: name="parted_pk_detach_test" schema="" table="parted_pk_detach_test" ctx=DDL +TABLE: name="parted_pk_detach_test1" schema="" table="parted_pk_detach_test1" ctx=DDL +STMT: DropStmt +== 511 +create table parted_uniq_detach_test (a int unique) partition by list (a) +-- +TABLE: name="parted_uniq_detach_test" schema="" table="parted_uniq_detach_test" ctx=DDL +STMT: CreateStmt +== 512 +create table parted_uniq_detach_test1 partition of parted_uniq_detach_test for values in (1) +-- +TABLE: name="parted_uniq_detach_test1" schema="" table="parted_uniq_detach_test1" ctx=DDL +STMT: CreateStmt +== 513 +alter table parted_uniq_detach_test1 drop constraint parted_uniq_detach_test1_a_key +-- +TABLE: name="parted_uniq_detach_test1" schema="" table="parted_uniq_detach_test1" ctx=DDL +STMT: AlterTableStmt +== 514 +-- should fail +alter table parted_uniq_detach_test detach partition parted_uniq_detach_test1 +-- +TABLE: name="parted_uniq_detach_test" schema="" table="parted_uniq_detach_test" ctx=DDL +STMT: AlterTableStmt +== 515 +alter table parted_uniq_detach_test1 drop constraint parted_uniq_detach_test1_a_key +-- +TABLE: name="parted_uniq_detach_test1" schema="" table="parted_uniq_detach_test1" ctx=DDL +STMT: AlterTableStmt +== 516 +drop table parted_uniq_detach_test, parted_uniq_detach_test1 +-- +TABLE: name="parted_uniq_detach_test" schema="" table="parted_uniq_detach_test" ctx=DDL +TABLE: name="parted_uniq_detach_test1" schema="" table="parted_uniq_detach_test1" ctx=DDL +STMT: DropStmt +== 517 +-- check that dropping a column takes with it any partitioned indexes +-- depending on it. +create table parted_index_col_drop(a int, b int, c int) + partition by list (a) +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: CreateStmt +== 518 +create table parted_index_col_drop1 partition of parted_index_col_drop + for values in (1) partition by list (a) +-- +TABLE: name="parted_index_col_drop1" schema="" table="parted_index_col_drop1" ctx=DDL +STMT: CreateStmt +== 519 +-- leave this partition without children. +create table parted_index_col_drop2 partition of parted_index_col_drop + for values in (2) partition by list (a) +-- +TABLE: name="parted_index_col_drop2" schema="" table="parted_index_col_drop2" ctx=DDL +STMT: CreateStmt +== 520 +create table parted_index_col_drop11 partition of parted_index_col_drop1 + for values in (1) +-- +TABLE: name="parted_index_col_drop11" schema="" table="parted_index_col_drop11" ctx=DDL +STMT: CreateStmt +== 521 +create index on parted_index_col_drop (b) +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: IndexStmt +== 522 +create index on parted_index_col_drop (c) +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: IndexStmt +== 523 +create index on parted_index_col_drop (b, c) +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: IndexStmt +== 524 +alter table parted_index_col_drop drop column c +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: AlterTableStmt +== 525 +drop table parted_index_col_drop +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: DropStmt +== 526 +-- Check that invalid indexes are not selected when attaching a partition. +create table parted_inval_tab (a int) partition by range (a) +-- +TABLE: name="parted_inval_tab" schema="" table="parted_inval_tab" ctx=DDL +STMT: CreateStmt +== 527 +create index parted_inval_idx on parted_inval_tab (a) +-- +TABLE: name="parted_inval_tab" schema="" table="parted_inval_tab" ctx=DDL +STMT: IndexStmt +== 528 +create table parted_inval_tab_1 (a int) partition by range (a) +-- +TABLE: name="parted_inval_tab_1" schema="" table="parted_inval_tab_1" ctx=DDL +STMT: CreateStmt +== 529 +create table parted_inval_tab_1_1 partition of parted_inval_tab_1 + for values from (0) to (10) +-- +TABLE: name="parted_inval_tab_1_1" schema="" table="parted_inval_tab_1_1" ctx=DDL +STMT: CreateStmt +== 530 +create table parted_inval_tab_1_2 partition of parted_inval_tab_1 + for values from (10) to (20) +-- +TABLE: name="parted_inval_tab_1_2" schema="" table="parted_inval_tab_1_2" ctx=DDL +STMT: CreateStmt +== 531 +-- this creates an invalid index. +create index parted_inval_ixd_1 on only parted_inval_tab_1 (a) +-- +TABLE: name="parted_inval_tab_1" schema="" table="parted_inval_tab_1" ctx=DDL +STMT: IndexStmt +== 532 +-- this creates new indexes for all the partitions of parted_inval_tab_1, +-- discarding the invalid index created previously as what is chosen. +alter table parted_inval_tab attach partition parted_inval_tab_1 + for values from (1) to (100) +-- +TABLE: name="parted_inval_tab" schema="" table="parted_inval_tab" ctx=DDL +STMT: AlterTableStmt +== 533 +select indexrelid::regclass, indisvalid, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_inval%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +== 534 +drop table parted_inval_tab +-- +TABLE: name="parted_inval_tab" schema="" table="parted_inval_tab" ctx=DDL +STMT: DropStmt +== 535 +-- Check setup of indisvalid across a complex partition tree on index +-- creation. If one index in a partition index is invalid, so should its +-- partitioned index. +create table parted_isvalid_tab (a int, b int) partition by range (a) +-- +TABLE: name="parted_isvalid_tab" schema="" table="parted_isvalid_tab" ctx=DDL +STMT: CreateStmt +== 536 +create table parted_isvalid_tab_1 partition of parted_isvalid_tab + for values from (1) to (10) partition by range (a) +-- +TABLE: name="parted_isvalid_tab_1" schema="" table="parted_isvalid_tab_1" ctx=DDL +STMT: CreateStmt +== 537 +create table parted_isvalid_tab_2 partition of parted_isvalid_tab + for values from (10) to (20) partition by range (a) +-- +TABLE: name="parted_isvalid_tab_2" schema="" table="parted_isvalid_tab_2" ctx=DDL +STMT: CreateStmt +== 538 +create table parted_isvalid_tab_11 partition of parted_isvalid_tab_1 + for values from (1) to (5) +-- +TABLE: name="parted_isvalid_tab_11" schema="" table="parted_isvalid_tab_11" ctx=DDL +STMT: CreateStmt +== 539 +create table parted_isvalid_tab_12 partition of parted_isvalid_tab_1 + for values from (5) to (10) +-- +TABLE: name="parted_isvalid_tab_12" schema="" table="parted_isvalid_tab_12" ctx=DDL +STMT: CreateStmt +== 540 +-- create an invalid index on one of the partitions. +insert into parted_isvalid_tab_11 values (1, 0) +-- +TABLE: name="parted_isvalid_tab_11" schema="" table="parted_isvalid_tab_11" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 541 +create index concurrently parted_isvalid_idx_11 on parted_isvalid_tab_11 ((a/b)) +-- +TABLE: name="parted_isvalid_tab_11" schema="" table="parted_isvalid_tab_11" ctx=DDL +STMT: IndexStmt +== 542 +-- The previous invalid index is selected, invalidating all the indexes up to +-- the top-most parent. +create index parted_isvalid_idx on parted_isvalid_tab ((a/b)) +-- +TABLE: name="parted_isvalid_tab" schema="" table="parted_isvalid_tab" ctx=DDL +STMT: IndexStmt +== 543 +select indexrelid::regclass, indisvalid, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_isvalid%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +== 544 +drop table parted_isvalid_tab +-- +TABLE: name="parted_isvalid_tab" schema="" table="parted_isvalid_tab" ctx=DDL +STMT: DropStmt +== 545 +-- Check state of replica indexes when attaching a partition. +begin +-- +STMT: TransactionStmt +== 546 +create table parted_replica_tab (id int not null) partition by range (id) +-- +TABLE: name="parted_replica_tab" schema="" table="parted_replica_tab" ctx=DDL +STMT: CreateStmt +== 547 +create table parted_replica_tab_1 partition of parted_replica_tab + for values from (1) to (10) partition by range (id) +-- +TABLE: name="parted_replica_tab_1" schema="" table="parted_replica_tab_1" ctx=DDL +STMT: CreateStmt +== 548 +create table parted_replica_tab_11 partition of parted_replica_tab_1 + for values from (1) to (5) +-- +TABLE: name="parted_replica_tab_11" schema="" table="parted_replica_tab_11" ctx=DDL +STMT: CreateStmt +== 549 +create unique index parted_replica_idx + on only parted_replica_tab using btree (id) +-- +TABLE: name="parted_replica_tab" schema="" table="parted_replica_tab" ctx=DDL +STMT: IndexStmt +== 550 +create unique index parted_replica_idx_1 + on only parted_replica_tab_1 using btree (id) +-- +TABLE: name="parted_replica_tab_1" schema="" table="parted_replica_tab_1" ctx=DDL +STMT: IndexStmt +== 551 +-- This triggers an update of pg_index.indisreplident for parted_replica_idx. +alter table only parted_replica_tab_1 replica identity + using index parted_replica_idx_1 +-- +TABLE: name="parted_replica_tab_1" schema="" table="parted_replica_tab_1" ctx=DDL +STMT: AlterTableStmt +== 552 +create unique index parted_replica_idx_11 on parted_replica_tab_11 USING btree (id) +-- +TABLE: name="parted_replica_tab_11" schema="" table="parted_replica_tab_11" ctx=DDL +STMT: IndexStmt +== 553 +select indexrelid::regclass, indisvalid, indisreplident, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_replica%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +== 554 +-- parted_replica_idx is not valid yet here, because parted_replica_idx_1 +-- is not valid. +alter index parted_replica_idx ATTACH PARTITION parted_replica_idx_1 +-- +STMT: AlterTableStmt +== 555 +select indexrelid::regclass, indisvalid, indisreplident, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_replica%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +== 556 +-- parted_replica_idx becomes valid here. +alter index parted_replica_idx_1 ATTACH PARTITION parted_replica_idx_11 +-- +STMT: AlterTableStmt +== 557 +alter table only parted_replica_tab_1 replica identity + using index parted_replica_idx_1 +-- +TABLE: name="parted_replica_tab_1" schema="" table="parted_replica_tab_1" ctx=DDL +STMT: AlterTableStmt +== 558 +commit +-- +STMT: TransactionStmt +== 559 +select indexrelid::regclass, indisvalid, indisreplident, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_replica%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +== 560 +drop table parted_replica_tab +-- +TABLE: name="parted_replica_tab" schema="" table="parted_replica_tab" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/indirect_toast.metadata.json b/parser/testdata/summary/postgres_regress/indirect_toast.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/indirect_toast.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/indirect_toast.test b/parser/testdata/summary/postgres_regress/indirect_toast.test new file mode 100644 index 0000000..de2edd3 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/indirect_toast.test @@ -0,0 +1,198 @@ +== 001 +|-- +-- Tests for external toast datums +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION make_tuple_indirect (record) + RETURNS record + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 198 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- Other compression algorithms may cause the compressed data to be stored +-- inline. pglz guarantees that the data is externalized, so stick to it. +SET default_toast_compression = 'pglz' +-- +STMT: VariableSetStmt +== 003 +CREATE TABLE indtoasttest(descr text, cnt int DEFAULT 0, f1 text, f2 text) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: CreateStmt +== 004 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('two-compressed', repeat('1234567890',1000), repeat('1234567890',1000)) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('two-toasted', repeat('1234567890',30000), repeat('1234567890',50000)) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-compressed,one-null', NULL, repeat('1234567890',1000)) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-toasted,one-null', NULL, repeat('1234567890',50000)) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 008 +-- check whether indirect tuples works on the most basic level +SELECT descr, substring(make_tuple_indirect(indtoasttest)::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +FUNCTION: name="make_tuple_indirect" function="make_tuple_indirect" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- modification without changing varlenas +UPDATE indtoasttest SET cnt = cnt +1 RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +== 010 +-- modification without modifying assigned value +UPDATE indtoasttest SET cnt = cnt +1, f1 = f1 RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +== 011 +-- modification modifying, but effectively not changing +UPDATE indtoasttest SET cnt = cnt +1, f1 = f1||'' RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +== 012 +UPDATE indtoasttest SET cnt = cnt +1, f1 = '-'||f1||'-' RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +== 013 +SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- check we didn't screw with main/toast tuple visibility +VACUUM FREEZE indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: VacuumStmt +== 015 +SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- now create a trigger that forces all Datums to be indirect ones +CREATE FUNCTION update_using_indirect() + RETURNS trigger + LANGUAGE plpgsql AS $$ +BEGIN + NEW := make_tuple_indirect(NEW); + RETURN NEW; +END$$ +-- +FUNCTION: name="update_using_indirect" function="update_using_indirect" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 017 +CREATE TRIGGER indtoasttest_update_indirect + BEFORE INSERT OR UPDATE + ON indtoasttest + FOR EACH ROW + EXECUTE PROCEDURE update_using_indirect() +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: CreateTrigStmt +== 018 +-- modification without changing varlenas +UPDATE indtoasttest SET cnt = cnt +1 RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +== 019 +-- modification without modifying assigned value +UPDATE indtoasttest SET cnt = cnt +1, f1 = f1 RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +== 020 +-- modification modifying, but effectively not changing +UPDATE indtoasttest SET cnt = cnt +1, f1 = f1||'' RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +== 021 +UPDATE indtoasttest SET cnt = cnt +1, f1 = '-'||f1||'-' RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +== 022 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-toasted,one-null, via indirect', repeat('1234567890',30000), NULL) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 023 +SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +== 024 +-- check we didn't screw with main/toast tuple visibility +VACUUM FREEZE indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: VacuumStmt +== 025 +SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +== 026 +DROP TABLE indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: DropStmt +== 027 +DROP FUNCTION update_using_indirect() +-- +FUNCTION: name="update_using_indirect" function="update_using_indirect" schema="" ctx=DDL +STMT: DropStmt +== 028 +RESET default_toast_compression +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/inet.metadata.json b/parser/testdata/summary/postgres_regress/inet.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/inet.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/inet.test b/parser/testdata/summary/postgres_regress/inet.test new file mode 100644 index 0000000..748bbb1 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/inet.test @@ -0,0 +1,759 @@ +== 001 +|-- +-- INET +|-- + +-- prepare the table... + +DROP TABLE INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: DropStmt +== 002 +CREATE TABLE INET_TBL (c cidr, i inet) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.226/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/26', '192.168.1.226') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/25') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.255/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.255/25') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO INET_TBL (c, i) VALUES ('10', '10.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO INET_TBL (c, i) VALUES ('10.0.0.0', '10.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO INET_TBL (c, i) VALUES ('10.1.2.3', '10.1.2.3/32') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO INET_TBL (c, i) VALUES ('10.1.2', '10.1.2.3/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO INET_TBL (c, i) VALUES ('10.1', '10.1.2.3/16') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO INET_TBL (c, i) VALUES ('10', '10.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO INET_TBL (c, i) VALUES ('10', '11.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO INET_TBL (c, i) VALUES ('10', '9.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO INET_TBL (c, i) VALUES ('10:23::f1', '10:23::f1/64') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO INET_TBL (c, i) VALUES ('10:23::8000/113', '10:23::ffff') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO INET_TBL (c, i) VALUES ('::ffff:1.2.3.4', '::4.3.2.1/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +-- check that CIDR rejects invalid input: +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/30', '192.168.1.226') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1.2.3.4') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +-- check that CIDR rejects invalid input when converting from text: +INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/30'), '192.168.1.226') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +FUNCTION: name="cidr" function="cidr" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +FUNCTION: name="cidr" function="cidr" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 024 +SELECT c AS cidr, i AS inet FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +== 025 +-- now test some support functions + +SELECT i AS inet, host(i), text(i), family(i) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="host" function="host" schema="" ctx=Call +FUNCTION: name="text" function="text" schema="" ctx=Call +FUNCTION: name="family" function="family" schema="" ctx=Call +STMT: SelectStmt +== 026 +SELECT c AS cidr, abbrev(c) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="abbrev" function="abbrev" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT c AS cidr, broadcast(c), + i AS inet, broadcast(i) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="broadcast" function="broadcast" schema="" ctx=Call +FUNCTION: name="broadcast" function="broadcast" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT c AS cidr, network(c) AS "network(cidr)", + i AS inet, network(i) AS "network(inet)" FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="network" function="network" schema="" ctx=Call +FUNCTION: name="network" function="network" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT c AS cidr, masklen(c) AS "masklen(cidr)", + i AS inet, masklen(i) AS "masklen(inet)" FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT c AS cidr, masklen(c) AS "masklen(cidr)", + i AS inet, masklen(i) AS "masklen(inet)" FROM INET_TBL + WHERE masklen(c) <= 8 +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +== 031 +SELECT c AS cidr, i AS inet FROM INET_TBL + WHERE c = i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 032 +SELECT i, c, + i < c AS lt, i <= c AS le, i = c AS eq, + i >= c AS ge, i > c AS gt, i <> c AS ne, + i << c AS sb, i <<= c AS sbe, + i >> c AS sup, i >>= c AS spe, + i && c AS ovr + FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +== 033 +SELECT max(i) AS max, min(i) AS min FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT max(c) AS max, min(c) AS min FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 035 +-- check the conversion to/from text and set_netmask +SELECT set_masklen(inet(text(i)), 24) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="set_masklen" function="set_masklen" schema="" ctx=Call +FUNCTION: name="inet" function="inet" schema="" ctx=Call +FUNCTION: name="text" function="text" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- check that btree index works correctly +CREATE INDEX inet_idx1 ON inet_tbl(i) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: IndexStmt +== 037 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +== 038 +EXPLAIN (COSTS OFF) +SELECT * FROM inet_tbl WHERE i<<'192.168.1.0/24'::cidr +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 039 +SELECT * FROM inet_tbl WHERE i<<'192.168.1.0/24'::cidr +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 040 +EXPLAIN (COSTS OFF) +SELECT * FROM inet_tbl WHERE i<<='192.168.1.0/24'::cidr +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 041 +SELECT * FROM inet_tbl WHERE i<<='192.168.1.0/24'::cidr +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 042 +EXPLAIN (COSTS OFF) +SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >>= i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 043 +SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >>= i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 044 +EXPLAIN (COSTS OFF) +SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >> i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 045 +SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >> i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 046 +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +== 047 +DROP INDEX inet_idx1 +-- +STMT: DropStmt +== 048 +-- check that gist index works correctly +CREATE INDEX inet_idx2 ON inet_tbl using gist (i inet_ops) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: IndexStmt +== 049 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +== 050 +SELECT * FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 051 +SELECT * FROM inet_tbl WHERE i <<= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 052 +SELECT * FROM inet_tbl WHERE i && '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 053 +SELECT * FROM inet_tbl WHERE i >>= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 054 +SELECT * FROM inet_tbl WHERE i >> '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 055 +SELECT * FROM inet_tbl WHERE i < '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 056 +SELECT * FROM inet_tbl WHERE i <= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 057 +SELECT * FROM inet_tbl WHERE i = '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 058 +SELECT * FROM inet_tbl WHERE i >= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 059 +SELECT * FROM inet_tbl WHERE i > '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 060 +SELECT * FROM inet_tbl WHERE i <> '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 061 +-- test index-only scans +EXPLAIN (COSTS OFF) +SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 062 +SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 063 +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +== 064 +DROP INDEX inet_idx2 +-- +STMT: DropStmt +== 065 +-- check that spgist index works correctly +CREATE INDEX inet_idx3 ON inet_tbl using spgist (i) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: IndexStmt +== 066 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +== 067 +SELECT * FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 068 +SELECT * FROM inet_tbl WHERE i <<= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 069 +SELECT * FROM inet_tbl WHERE i && '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 070 +SELECT * FROM inet_tbl WHERE i >>= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 071 +SELECT * FROM inet_tbl WHERE i >> '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 072 +SELECT * FROM inet_tbl WHERE i < '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 073 +SELECT * FROM inet_tbl WHERE i <= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 074 +SELECT * FROM inet_tbl WHERE i = '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 075 +SELECT * FROM inet_tbl WHERE i >= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 076 +SELECT * FROM inet_tbl WHERE i > '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 077 +SELECT * FROM inet_tbl WHERE i <> '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 078 +-- test index-only scans +EXPLAIN (COSTS OFF) +SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 079 +SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 080 +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +== 081 +DROP INDEX inet_idx3 +-- +STMT: DropStmt +== 082 +-- simple tests of inet boolean and arithmetic operators +SELECT i, ~i AS "~i" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +== 083 +SELECT i, c, i & c AS "and" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +== 084 +SELECT i, c, i | c AS "or" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +== 085 +SELECT i, i + 500 AS "i+500" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +== 086 +SELECT i, i - 500 AS "i-500" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +== 087 +SELECT i, c, i - c AS "minus" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +== 088 +SELECT '127.0.0.1'::inet + 257 +-- +STMT: SelectStmt +== 089 +SELECT ('127.0.0.1'::inet + 257) - 257 +-- +STMT: SelectStmt +== 090 +SELECT '127::1'::inet + 257 +-- +STMT: SelectStmt +== 091 +SELECT ('127::1'::inet + 257) - 257 +-- +STMT: SelectStmt +== 092 +SELECT '127.0.0.2'::inet - ('127.0.0.2'::inet + 500) +-- +STMT: SelectStmt +== 093 +SELECT '127.0.0.2'::inet - ('127.0.0.2'::inet - 500) +-- +STMT: SelectStmt +== 094 +SELECT '127::2'::inet - ('127::2'::inet + 500) +-- +STMT: SelectStmt +== 095 +SELECT '127::2'::inet - ('127::2'::inet - 500) +-- +STMT: SelectStmt +== 096 +-- these should give overflow errors: +SELECT '127.0.0.1'::inet + 10000000000 +-- +STMT: SelectStmt +== 097 +SELECT '127.0.0.1'::inet - 10000000000 +-- +STMT: SelectStmt +== 098 +SELECT '126::1'::inet - '127::2'::inet +-- +STMT: SelectStmt +== 099 +SELECT '127::1'::inet - '126::2'::inet +-- +STMT: SelectStmt +== 100 +-- but not these +SELECT '127::1'::inet + 10000000000 +-- +STMT: SelectStmt +== 101 +SELECT '127::1'::inet - '127::2'::inet +-- +STMT: SelectStmt +== 102 +-- insert one more row with addressed from different families +INSERT INTO INET_TBL (c, i) VALUES ('10', '10::/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +-- now, this one should fail +SELECT inet_merge(c, i) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="inet_merge" function="inet_merge" schema="" ctx=Call +STMT: SelectStmt +== 104 +-- fix it by inet_same_family() condition +SELECT inet_merge(c, i) FROM INET_TBL WHERE inet_same_family(c, i) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="inet_same_family" function="inet_same_family" schema="" ctx=Call +FUNCTION: name="inet_merge" function="inet_merge" schema="" ctx=Call +FUNCTION: name="inet_same_family" function="inet_same_family" schema="" ctx=Call +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 105 +-- Test inet sortsupport with a variety of boundary inputs: +SELECT a FROM (VALUES + ('0.0.0.0/0'::inet), + ('0.0.0.0/1'::inet), + ('0.0.0.0/32'::inet), + ('0.0.0.1/0'::inet), + ('0.0.0.1/1'::inet), + ('127.126.127.127/0'::inet), + ('127.127.127.127/0'::inet), + ('127.128.127.127/0'::inet), + ('192.168.1.0/24'::inet), + ('192.168.1.0/25'::inet), + ('192.168.1.1/23'::inet), + ('192.168.1.1/5'::inet), + ('192.168.1.1/6'::inet), + ('192.168.1.1/25'::inet), + ('192.168.1.2/25'::inet), + ('192.168.1.1/26'::inet), + ('192.168.1.2/26'::inet), + ('192.168.1.2/23'::inet), + ('192.168.1.255/5'::inet), + ('192.168.1.255/6'::inet), + ('192.168.1.3/1'::inet), + ('192.168.1.3/23'::inet), + ('192.168.1.4/0'::inet), + ('192.168.1.5/0'::inet), + ('255.0.0.0/0'::inet), + ('255.1.0.0/0'::inet), + ('255.2.0.0/0'::inet), + ('255.255.000.000/0'::inet), + ('255.255.000.000/0'::inet), + ('255.255.000.000/15'::inet), + ('255.255.000.000/16'::inet), + ('255.255.255.254/32'::inet), + ('255.255.255.000/32'::inet), + ('255.255.255.001/31'::inet), + ('255.255.255.002/31'::inet), + ('255.255.255.003/31'::inet), + ('255.255.255.003/32'::inet), + ('255.255.255.001/32'::inet), + ('255.255.255.255/0'::inet), + ('255.255.255.255/0'::inet), + ('255.255.255.255/0'::inet), + ('255.255.255.255/1'::inet), + ('255.255.255.255/16'::inet), + ('255.255.255.255/16'::inet), + ('255.255.255.255/31'::inet), + ('255.255.255.255/32'::inet), + ('255.255.255.253/32'::inet), + ('255.255.255.252/32'::inet), + ('255.3.0.0/0'::inet), + ('0000:0000:0000:0000:0000:0000:0000:0000/0'::inet), + ('0000:0000:0000:0000:0000:0000:0000:0000/128'::inet), + ('0000:0000:0000:0000:0000:0000:0000:0001/128'::inet), + ('10:23::f1/64'::inet), + ('10:23::f1/65'::inet), + ('10:23::ffff'::inet), + ('127::1'::inet), + ('127::2'::inet), + ('8000:0000:0000:0000:0000:0000:0000:0000/1'::inet), + ('::1:ffff:ffff:ffff:ffff/128'::inet), + ('::2:ffff:ffff:ffff:ffff/128'::inet), + ('::4:3:2:0/24'::inet), + ('::4:3:2:1/24'::inet), + ('::4:3:2:2/24'::inet), + ('ffff:83e7:f118:57dc:6093:6d92:689d:58cf/70'::inet), + ('ffff:84b0:4775:536e:c3ed:7116:a6d6:34f0/44'::inet), + ('ffff:8566:f84:5867:47f1:7867:d2ba:8a1a/69'::inet), + ('ffff:8883:f028:7d2:4d68:d510:7d6b:ac43/73'::inet), + ('ffff:8ae8:7c14:65b3:196:8e4a:89ae:fb30/89'::inet), + ('ffff:8dd0:646:694c:7c16:7e35:6a26:171/104'::inet), + ('ffff:8eef:cbf:700:eda3:ae32:f4b4:318b/121'::inet), + ('ffff:90e7:e744:664:a93:8efe:1f25:7663/122'::inet), + ('ffff:9597:c69c:8b24:57a:8639:ec78:6026/111'::inet), + ('ffff:9e86:79ea:f16e:df31:8e4d:7783:532e/88'::inet), + ('ffff:a0c7:82d3:24de:f762:6e1f:316d:3fb2/23'::inet), + ('ffff:fffa:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:fffb:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:fffc:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:fffd:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:fffe:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffa:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffb:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffc:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffd::/128'::inet), + ('ffff:ffff:ffff:fffd:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffe::/128'::inet), + ('ffff:ffff:ffff:fffe:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:ffff:4:3:2:0/24'::inet), + ('ffff:ffff:ffff:ffff:4:3:2:1/24'::inet), + ('ffff:ffff:ffff:ffff:4:3:2:2/24'::inet), + ('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128'::inet) +) AS i(a) ORDER BY a +-- +STMT: SelectStmt +== 106 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('1234', 'cidr') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 107 +SELECT * FROM pg_input_error_info('1234', 'cidr') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 108 +SELECT pg_input_is_valid('192.168.198.200/24', 'cidr') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 109 +SELECT * FROM pg_input_error_info('192.168.198.200/24', 'cidr') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 110 +SELECT pg_input_is_valid('1234', 'inet') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 111 +SELECT * FROM pg_input_error_info('1234', 'inet') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/infinite_recurse.metadata.json b/parser/testdata/summary/postgres_regress/infinite_recurse.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/infinite_recurse.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/infinite_recurse.test b/parser/testdata/summary/postgres_regress/infinite_recurse.test new file mode 100644 index 0000000..4a951eb --- /dev/null +++ b/parser/testdata/summary/postgres_regress/infinite_recurse.test @@ -0,0 +1,33 @@ +== 001 +-- Check that stack depth detection mechanism works and +-- max_stack_depth is not set too high. + +create function infinite_recurse() returns int as +'select infinite_recurse()' language sql +-- +FUNCTION: name="infinite_recurse" function="infinite_recurse" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64 +-- signal handling that would cause this test to crash if it happened +-- to receive an sinval catchup interrupt while the stack is deep: +-- https://bugzilla.kernel.org/show_bug.cgi?id=205183 +-- It is likely to be many years before that bug disappears from all +-- production kernels, so disable this test on such platforms. +-- (We still create the function, so as not to have a cross-platform +-- difference in the end state of the regression database.) + +SELECT version() ~ 'powerpc64[^,]*-linux-gnu' + AS skip_test +-- +FUNCTION: name="version" function="version" schema="" ctx=Call +STMT: SelectStmt +== 003 +-- The full error report is not very stable, so we show only SQLSTATE +-- and primary error message. + + +select infinite_recurse() +-- +FUNCTION: name="infinite_recurse" function="infinite_recurse" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/inherit.metadata.json b/parser/testdata/summary/postgres_regress/inherit.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/inherit.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/inherit.test b/parser/testdata/summary/postgres_regress/inherit.test new file mode 100644 index 0000000..1093161 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/inherit.test @@ -0,0 +1,4183 @@ +== 001 +|-- +-- Test inheritance features +|-- +CREATE TABLE a (aa TEXT) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE b (bb TEXT) INHERITS (a) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE c (cc TEXT) INHERITS (a) +-- +TABLE: name="c" schema="" table="c" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE d (dd TEXT) INHERITS (b,c,a) +-- +TABLE: name="d" schema="" table="d" ctx=DDL +STMT: CreateStmt +== 005 +INSERT INTO a(aa) VALUES('aaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO a(aa) VALUES('aaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO a(aa) VALUES('aaaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO a(aa) VALUES('aaaaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO a(aa) VALUES('aaaaaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO a(aa) VALUES('aaaaaaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO b(aa) VALUES('bbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO b(aa) VALUES('bbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO b(aa) VALUES('bbbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO b(aa) VALUES('bbbbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO b(aa) VALUES('bbbbbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO b(aa) VALUES('bbbbbbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO c(aa) VALUES('ccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO c(aa) VALUES('cccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO c(aa) VALUES('ccccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO c(aa) VALUES('cccccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO c(aa) VALUES('ccccccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO c(aa) VALUES('cccccccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO d(aa) VALUES('ddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO d(aa) VALUES('dddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO d(aa) VALUES('ddddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO d(aa) VALUES('dddddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO d(aa) VALUES('ddddddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO d(aa) VALUES('dddddddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 030 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 031 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 032 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 033 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 034 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 035 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 036 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 037 +UPDATE a SET aa='zzzz' WHERE aa='aaaa' +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: UpdateStmt +== 038 +UPDATE ONLY a SET aa='zzzzz' WHERE aa='aaaaa' +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: UpdateStmt +== 039 +UPDATE b SET aa='zzz' WHERE aa='aaa' +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: UpdateStmt +== 040 +UPDATE ONLY b SET aa='zzz' WHERE aa='aaa' +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: UpdateStmt +== 041 +UPDATE a SET aa='zzzzzz' WHERE aa LIKE 'aaa%' +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: UpdateStmt +== 042 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 043 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 044 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 045 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 046 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 047 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 048 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 049 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 050 +UPDATE b SET aa='new' +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: UpdateStmt +== 051 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 052 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 053 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 054 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 055 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 056 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 057 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 058 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 059 +UPDATE a SET aa='new' +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: UpdateStmt +== 060 +DELETE FROM ONLY c WHERE aa='new' +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: DeleteStmt +== 061 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 062 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 063 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 064 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 065 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 066 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 067 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 068 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 069 +DELETE FROM a +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: DeleteStmt +== 070 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 071 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 072 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 073 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 074 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 075 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 076 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 077 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +== 078 +-- Confirm PRIMARY KEY adds NOT NULL constraint to child table +CREATE TEMP TABLE z (b TEXT, PRIMARY KEY(aa, b)) inherits (a) +-- +TABLE: name="z" schema="" table="z" ctx=DDL +STMT: CreateStmt +== 079 +INSERT INTO z VALUES (NULL, 'text') +-- +TABLE: name="z" schema="" table="z" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +-- should fail + +-- Check inherited UPDATE with first child excluded +create table some_tab (f1 int, f2 int, f3 int, check (f1 < 10) no inherit) +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: CreateStmt +== 081 +create table some_tab_child () inherits(some_tab) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DDL +STMT: CreateStmt +== 082 +insert into some_tab_child select i, i+1, 0 from generate_series(1,1000) i +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 083 +create index on some_tab_child(f1, f2) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DDL +STMT: IndexStmt +== 084 +-- while at it, also check that statement-level triggers fire +create function some_tab_stmt_trig_func() returns trigger as +$$begin raise notice 'updating some_tab'; return NULL; end;$$ +language plpgsql +-- +FUNCTION: name="some_tab_stmt_trig_func" function="some_tab_stmt_trig_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 085 +create trigger some_tab_stmt_trig + before update on some_tab execute function some_tab_stmt_trig_func() +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: CreateTrigStmt +== 086 +explain (costs off) +update some_tab set f3 = 11 where f1 = 12 and f2 = 13 +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 087 +update some_tab set f3 = 11 where f1 = 12 and f2 = 13 +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: UpdateStmt +== 088 +drop table some_tab cascade +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: DropStmt +== 089 +drop function some_tab_stmt_trig_func() +-- +FUNCTION: name="some_tab_stmt_trig_func" function="some_tab_stmt_trig_func" schema="" ctx=DDL +STMT: DropStmt +== 090 +-- Check inherited UPDATE with all children excluded +create table some_tab (a int, b int) +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: CreateStmt +== 091 +create table some_tab_child () inherits (some_tab) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DDL +STMT: CreateStmt +== 092 +insert into some_tab_child values(1,2) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +explain (verbose, costs off) +update some_tab set a = a + 1 where false +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 094 +update some_tab set a = a + 1 where false +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: UpdateStmt +== 095 +explain (verbose, costs off) +update some_tab set a = a + 1 where false returning b, a +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 096 +update some_tab set a = a + 1 where false returning b, a +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: UpdateStmt +== 097 +table some_tab +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +STMT: SelectStmt +== 098 +drop table some_tab cascade +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: DropStmt +== 099 +-- Check UPDATE with inherited target and an inherited source table +create temp table foo(f1 int, f2 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 100 +create temp table foo2(f3 int) inherits (foo) +-- +TABLE: name="foo2" schema="" table="foo2" ctx=DDL +STMT: CreateStmt +== 101 +create temp table bar(f1 int, f2 int) +-- +TABLE: name="bar" schema="" table="bar" ctx=DDL +STMT: CreateStmt +== 102 +create temp table bar2(f3 int) inherits (bar) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DDL +STMT: CreateStmt +== 103 +insert into foo values(1,1) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +insert into foo values(3,3) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +insert into foo2 values(2,2,2) +-- +TABLE: name="foo2" schema="" table="foo2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 106 +insert into foo2 values(3,3,3) +-- +TABLE: name="foo2" schema="" table="foo2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +insert into bar values(1,1) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +insert into bar values(2,2) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +insert into bar values(3,3) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +insert into bar values(4,4) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +insert into bar2 values(1,1,1) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 112 +insert into bar2 values(2,2,2) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 113 +insert into bar2 values(3,3,3) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 114 +insert into bar2 values(4,4,4) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +update bar set f2 = f2 + 100 where f1 in (select f1 from foo) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +== 116 +select tableoid::regclass::text as relname, bar.* from bar order by 1,2 +-- +TABLE: name="bar" schema="" table="bar" ctx=Select +STMT: SelectStmt +== 117 +-- Check UPDATE with inherited target and an appendrel subquery +update bar set f2 = f2 + 100 +from + ( select f1 from foo union all select f1+3 from foo ) ss +where bar.f1 = ss.f1 +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +== 118 +select tableoid::regclass::text as relname, bar.* from bar order by 1,2 +-- +TABLE: name="bar" schema="" table="bar" ctx=Select +STMT: SelectStmt +== 119 +-- Check UPDATE with *partitioned* inherited target and an appendrel subquery +create table some_tab (a int) +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: CreateStmt +== 120 +insert into some_tab values (0) +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +create table some_tab_child () inherits (some_tab) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DDL +STMT: CreateStmt +== 122 +insert into some_tab_child values (1) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +create table parted_tab (a int, b char) partition by list (a) +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DDL +STMT: CreateStmt +== 124 +create table parted_tab_part1 partition of parted_tab for values in (1) +-- +TABLE: name="parted_tab_part1" schema="" table="parted_tab_part1" ctx=DDL +STMT: CreateStmt +== 125 +create table parted_tab_part2 partition of parted_tab for values in (2) +-- +TABLE: name="parted_tab_part2" schema="" table="parted_tab_part2" ctx=DDL +STMT: CreateStmt +== 126 +create table parted_tab_part3 partition of parted_tab for values in (3) +-- +TABLE: name="parted_tab_part3" schema="" table="parted_tab_part3" ctx=DDL +STMT: CreateStmt +== 127 +insert into parted_tab values (1, 'a'), (2, 'a'), (3, 'a') +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 128 +update parted_tab set b = 'b' +from + (select a from some_tab union all select a+1 from some_tab) ss (a) +where parted_tab.a = ss.a +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +== 129 +select tableoid::regclass::text as relname, parted_tab.* from parted_tab order by 1,2 +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=Select +STMT: SelectStmt +== 130 +truncate parted_tab +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DDL +STMT: TruncateStmt +== 131 +insert into parted_tab values (1, 'a'), (2, 'a'), (3, 'a') +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 132 +update parted_tab set b = 'b' +from + (select 0 from parted_tab union all select 1 from parted_tab) ss (a) +where parted_tab.a = ss.a +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=Select +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +== 133 +select tableoid::regclass::text as relname, parted_tab.* from parted_tab order by 1,2 +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=Select +STMT: SelectStmt +== 134 +-- modifies partition key, but no rows will actually be updated +explain update parted_tab set a = 2 where false +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 135 +drop table parted_tab +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DDL +STMT: DropStmt +== 136 +-- Check UPDATE with multi-level partitioned inherited target +create table mlparted_tab (a int, b char, c text) partition by list (a) +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=DDL +STMT: CreateStmt +== 137 +create table mlparted_tab_part1 partition of mlparted_tab for values in (1) +-- +TABLE: name="mlparted_tab_part1" schema="" table="mlparted_tab_part1" ctx=DDL +STMT: CreateStmt +== 138 +create table mlparted_tab_part2 partition of mlparted_tab for values in (2) partition by list (b) +-- +TABLE: name="mlparted_tab_part2" schema="" table="mlparted_tab_part2" ctx=DDL +STMT: CreateStmt +== 139 +create table mlparted_tab_part3 partition of mlparted_tab for values in (3) +-- +TABLE: name="mlparted_tab_part3" schema="" table="mlparted_tab_part3" ctx=DDL +STMT: CreateStmt +== 140 +create table mlparted_tab_part2a partition of mlparted_tab_part2 for values in ('a') +-- +TABLE: name="mlparted_tab_part2a" schema="" table="mlparted_tab_part2a" ctx=DDL +STMT: CreateStmt +== 141 +create table mlparted_tab_part2b partition of mlparted_tab_part2 for values in ('b') +-- +TABLE: name="mlparted_tab_part2b" schema="" table="mlparted_tab_part2b" ctx=DDL +STMT: CreateStmt +== 142 +insert into mlparted_tab values (1, 'a'), (2, 'a'), (2, 'b'), (3, 'a') +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +update mlparted_tab mlp set c = 'xxx' +from + (select a from some_tab union all select a+1 from some_tab) ss (a) +where (mlp.a = ss.a and mlp.b = 'b') or mlp.a = 3 +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=DML +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +ALIAS: "mlp"="mlparted_tab" +STMT: UpdateStmt +STMT: SelectStmt +== 144 +select tableoid::regclass::text as relname, mlparted_tab.* from mlparted_tab order by 1,2 +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=Select +STMT: SelectStmt +== 145 +drop table mlparted_tab +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=DDL +STMT: DropStmt +== 146 +drop table some_tab cascade +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: DropStmt +== 147 +/* Test multiple inheritance of column defaults */ + +CREATE TABLE firstparent (tomorrow date default now()::date + 1) +-- +TABLE: name="firstparent" schema="" table="firstparent" ctx=DDL +STMT: CreateStmt +== 148 +CREATE TABLE secondparent (tomorrow date default now() :: date + 1) +-- +TABLE: name="secondparent" schema="" table="secondparent" ctx=DDL +STMT: CreateStmt +== 149 +CREATE TABLE jointchild () INHERITS (firstparent, secondparent) +-- +TABLE: name="jointchild" schema="" table="jointchild" ctx=DDL +STMT: CreateStmt +== 150 +-- ok +CREATE TABLE thirdparent (tomorrow date default now()::date - 1) +-- +TABLE: name="thirdparent" schema="" table="thirdparent" ctx=DDL +STMT: CreateStmt +== 151 +CREATE TABLE otherchild () INHERITS (firstparent, thirdparent) +-- +TABLE: name="otherchild" schema="" table="otherchild" ctx=DDL +STMT: CreateStmt +== 152 +-- not ok +CREATE TABLE otherchild (tomorrow date default now()) + INHERITS (firstparent, thirdparent) +-- +TABLE: name="otherchild" schema="" table="otherchild" ctx=DDL +STMT: CreateStmt +== 153 +-- ok, child resolves ambiguous default + +DROP TABLE firstparent, secondparent, jointchild, thirdparent, otherchild +-- +TABLE: name="firstparent" schema="" table="firstparent" ctx=DDL +TABLE: name="secondparent" schema="" table="secondparent" ctx=DDL +TABLE: name="jointchild" schema="" table="jointchild" ctx=DDL +TABLE: name="thirdparent" schema="" table="thirdparent" ctx=DDL +TABLE: name="otherchild" schema="" table="otherchild" ctx=DDL +STMT: DropStmt +== 154 +-- Test changing the type of inherited columns +insert into d values('test','one','two','three') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +alter table a alter column aa type integer using bit_length(aa) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: AlterTableStmt +== 156 +select * from d +-- +TABLE: name="d" schema="" table="d" ctx=Select +STMT: SelectStmt +== 157 +-- The above verified that we can change the type of a multiply-inherited +-- column; but we should reject that if any definition was inherited from +-- an unrelated parent. +create temp table parent1(f1 int, f2 int) +-- +TABLE: name="parent1" schema="" table="parent1" ctx=DDL +STMT: CreateStmt +== 158 +create temp table parent2(f1 int, f3 bigint) +-- +TABLE: name="parent2" schema="" table="parent2" ctx=DDL +STMT: CreateStmt +== 159 +create temp table childtab(f4 int) inherits(parent1, parent2) +-- +TABLE: name="childtab" schema="" table="childtab" ctx=DDL +STMT: CreateStmt +== 160 +alter table parent1 alter column f1 type bigint +-- +TABLE: name="parent1" schema="" table="parent1" ctx=DDL +STMT: AlterTableStmt +== 161 +-- fail, conflict w/parent2 +alter table parent1 alter column f2 type bigint +-- +TABLE: name="parent1" schema="" table="parent1" ctx=DDL +STMT: AlterTableStmt +== 162 +-- ok + +-- Test non-inheritable parent constraints +create table p1(ff1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 163 +alter table p1 add constraint p1chk check (ff1 > 0) no inherit +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 164 +alter table p1 add constraint p2chk check (ff1 > 10) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 165 +-- connoinherit should be true for NO INHERIT constraint +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.connoinherit from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname = 'p1' order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 166 +-- Test that child does not inherit NO INHERIT constraints +create table c1 () inherits (p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 167 +-- Test that child does not override inheritable constraints of the parent +create table c2 (constraint p2chk check (ff1 > 10) no inherit) inherits (p1) +-- +TABLE: name="c2" schema="" table="c2" ctx=DDL +STMT: CreateStmt +== 168 +--fails + +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 169 +-- Tests for casting between the rowtypes of parent and child +-- tables. See the pgsql-hackers thread beginning Dec. 4/04 +create table base (i integer) +-- +TABLE: name="base" schema="" table="base" ctx=DDL +STMT: CreateStmt +== 170 +create table derived () inherits (base) +-- +TABLE: name="derived" schema="" table="derived" ctx=DDL +STMT: CreateStmt +== 171 +create table more_derived (like derived, b int) inherits (derived) +-- +TABLE: name="more_derived" schema="" table="more_derived" ctx=DDL +STMT: CreateStmt +== 172 +insert into derived (i) values (0) +-- +TABLE: name="derived" schema="" table="derived" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +select derived::base from derived +-- +TABLE: name="derived" schema="" table="derived" ctx=Select +STMT: SelectStmt +== 174 +select NULL::derived::base +-- +STMT: SelectStmt +== 175 +-- remove redundant conversions. +explain (verbose on, costs off) select row(i, b)::more_derived::derived::base from more_derived +-- +TABLE: name="more_derived" schema="" table="more_derived" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 176 +explain (verbose on, costs off) select (1, 2)::more_derived::derived::base +-- +STMT: ExplainStmt +STMT: SelectStmt +== 177 +drop table more_derived +-- +TABLE: name="more_derived" schema="" table="more_derived" ctx=DDL +STMT: DropStmt +== 178 +drop table derived +-- +TABLE: name="derived" schema="" table="derived" ctx=DDL +STMT: DropStmt +== 179 +drop table base +-- +TABLE: name="base" schema="" table="base" ctx=DDL +STMT: DropStmt +== 180 +create table p1(ff1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 181 +create table p2(f1 text) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +== 182 +create function p2text(p2) returns text as 'select $1.f1' language sql +-- +FUNCTION: name="p2text" function="p2text" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 183 +create table c1(f3 int) inherits(p1,p2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 184 +insert into c1 values(123456789, 'hi', 42) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 185 +select p2text(c1.*) from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=Select +FUNCTION: name="p2text" function="p2text" schema="" ctx=Call +STMT: SelectStmt +== 186 +drop function p2text(p2) +-- +FUNCTION: name="p2text" function="p2text" schema="" ctx=DDL +STMT: DropStmt +== 187 +drop table c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: DropStmt +== 188 +drop table p2 +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: DropStmt +== 189 +drop table p1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 190 +CREATE TABLE ac (aa TEXT) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: CreateStmt +== 191 +alter table ac add constraint ac_check check (aa is not null) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +== 192 +CREATE TABLE bc (bb TEXT) INHERITS (ac) +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: CreateStmt +== 193 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 194 +insert into ac (aa) values (NULL) +-- +TABLE: name="ac" schema="" table="ac" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 195 +insert into bc (aa) values (NULL) +-- +TABLE: name="bc" schema="" table="bc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +alter table bc drop constraint ac_check +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: AlterTableStmt +== 197 +-- fail, disallowed +alter table ac drop constraint ac_check +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +== 198 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 199 +-- try the unnamed-constraint case +alter table ac add check (aa is not null) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +== 200 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 201 +insert into ac (aa) values (NULL) +-- +TABLE: name="ac" schema="" table="ac" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +insert into bc (aa) values (NULL) +-- +TABLE: name="bc" schema="" table="bc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 203 +alter table bc drop constraint ac_aa_check +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: AlterTableStmt +== 204 +-- fail, disallowed +alter table ac drop constraint ac_aa_check +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +== 205 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 206 +alter table ac add constraint ac_check check (aa is not null) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +== 207 +alter table bc no inherit ac +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: AlterTableStmt +== 208 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 209 +alter table bc drop constraint ac_check +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: AlterTableStmt +== 210 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 211 +alter table ac drop constraint ac_check +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +== 212 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 213 +drop table bc +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: DropStmt +== 214 +drop table ac +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: DropStmt +== 215 +create table ac (a int constraint check_a check (a <> 0)) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: CreateStmt +== 216 +create table bc (a int constraint check_a check (a <> 0), b int constraint check_b check (b <> 0)) inherits (ac) +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: CreateStmt +== 217 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 218 +drop table bc +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: DropStmt +== 219 +drop table ac +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: DropStmt +== 220 +create table ac (a int constraint check_a check (a <> 0)) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: CreateStmt +== 221 +create table bc (b int constraint check_b check (b <> 0)) +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: CreateStmt +== 222 +create table cc (c int constraint check_c check (c <> 0)) inherits (ac, bc) +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: CreateStmt +== 223 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 224 +alter table cc no inherit bc +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: AlterTableStmt +== 225 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +== 226 +drop table cc +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: DropStmt +== 227 +drop table bc +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: DropStmt +== 228 +drop table ac +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: DropStmt +== 229 +create table p1(f1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 230 +create table p2(f2 int) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +== 231 +create table c1(f3 int) inherits(p1,p2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +== 232 +insert into c1 values(1,-1,2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 233 +alter table p2 add constraint cc check (f2>0) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +== 234 +-- fail +alter table p2 add check (f2>0) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +== 235 +-- check it without a name, too +delete from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: DeleteStmt +== 236 +insert into c1 values(1,1,2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 237 +alter table p2 add check (f2>0) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +== 238 +insert into c1 values(1,-1,2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 239 +-- fail +create table c2(f3 int) inherits(p1,p2) +-- +TABLE: name="c2" schema="" table="c2" ctx=DDL +STMT: CreateStmt +== 240 +create table c3 (f4 int) inherits(c1,c2) +-- +TABLE: name="c3" schema="" table="c3" ctx=DDL +STMT: CreateStmt +== 241 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 242 +drop table p2 cascade +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: DropStmt +== 243 +create table pp1 (f1 int) +-- +TABLE: name="pp1" schema="" table="pp1" ctx=DDL +STMT: CreateStmt +== 244 +create table cc1 (f2 text, f3 int) inherits (pp1) +-- +TABLE: name="cc1" schema="" table="cc1" ctx=DDL +STMT: CreateStmt +== 245 +alter table pp1 add column a1 int check (a1 > 0) +-- +TABLE: name="pp1" schema="" table="pp1" ctx=DDL +STMT: AlterTableStmt +== 246 +create table cc2(f4 float) inherits(pp1,cc1) +-- +TABLE: name="cc2" schema="" table="cc2" ctx=DDL +STMT: CreateStmt +== 247 +alter table pp1 add column a2 int check (a2 > 0) +-- +TABLE: name="pp1" schema="" table="pp1" ctx=DDL +STMT: AlterTableStmt +== 248 +drop table pp1 cascade +-- +TABLE: name="pp1" schema="" table="pp1" ctx=DDL +STMT: DropStmt +== 249 +-- Test for renaming in simple multiple inheritance +CREATE TABLE inht1 (a int, b int) +-- +TABLE: name="inht1" schema="" table="inht1" ctx=DDL +STMT: CreateStmt +== 250 +CREATE TABLE inhs1 (b int, c int) +-- +TABLE: name="inhs1" schema="" table="inhs1" ctx=DDL +STMT: CreateStmt +== 251 +CREATE TABLE inhts (d int) INHERITS (inht1, inhs1) +-- +TABLE: name="inhts" schema="" table="inhts" ctx=DDL +STMT: CreateStmt +== 252 +ALTER TABLE inht1 RENAME a TO aa +-- +STMT: RenameStmt +== 253 +ALTER TABLE inht1 RENAME b TO bb +-- +STMT: RenameStmt +== 254 +-- to be failed +ALTER TABLE inhts RENAME aa TO aaa +-- +STMT: RenameStmt +== 255 +-- to be failed +ALTER TABLE inhts RENAME d TO dd +-- +STMT: RenameStmt +== 256 +DROP TABLE inhts +-- +TABLE: name="inhts" schema="" table="inhts" ctx=DDL +STMT: DropStmt +== 257 +-- Test for adding a column to a parent table with complex inheritance +CREATE TABLE inhta () +-- +TABLE: name="inhta" schema="" table="inhta" ctx=DDL +STMT: CreateStmt +== 258 +CREATE TABLE inhtb () INHERITS (inhta) +-- +TABLE: name="inhtb" schema="" table="inhtb" ctx=DDL +STMT: CreateStmt +== 259 +CREATE TABLE inhtc () INHERITS (inhtb) +-- +TABLE: name="inhtc" schema="" table="inhtc" ctx=DDL +STMT: CreateStmt +== 260 +CREATE TABLE inhtd () INHERITS (inhta, inhtb, inhtc) +-- +TABLE: name="inhtd" schema="" table="inhtd" ctx=DDL +STMT: CreateStmt +== 261 +ALTER TABLE inhta ADD COLUMN i int, ADD COLUMN j bigint DEFAULT 1 +-- +TABLE: name="inhta" schema="" table="inhta" ctx=DDL +STMT: AlterTableStmt +== 262 +DROP TABLE inhta, inhtb, inhtc, inhtd +-- +TABLE: name="inhta" schema="" table="inhta" ctx=DDL +TABLE: name="inhtb" schema="" table="inhtb" ctx=DDL +TABLE: name="inhtc" schema="" table="inhtc" ctx=DDL +TABLE: name="inhtd" schema="" table="inhtd" ctx=DDL +STMT: DropStmt +== 263 +-- Test for renaming in diamond inheritance +CREATE TABLE inht2 (x int) INHERITS (inht1) +-- +TABLE: name="inht2" schema="" table="inht2" ctx=DDL +STMT: CreateStmt +== 264 +CREATE TABLE inht3 (y int) INHERITS (inht1) +-- +TABLE: name="inht3" schema="" table="inht3" ctx=DDL +STMT: CreateStmt +== 265 +CREATE TABLE inht4 (z int) INHERITS (inht2, inht3) +-- +TABLE: name="inht4" schema="" table="inht4" ctx=DDL +STMT: CreateStmt +== 266 +ALTER TABLE inht1 RENAME aa TO aaa +-- +STMT: RenameStmt +== 267 +CREATE TABLE inhts (d int) INHERITS (inht2, inhs1) +-- +TABLE: name="inhts" schema="" table="inhts" ctx=DDL +STMT: CreateStmt +== 268 +ALTER TABLE inht1 RENAME aaa TO aaaa +-- +STMT: RenameStmt +== 269 +ALTER TABLE inht1 RENAME b TO bb +-- +STMT: RenameStmt +== 270 +-- to be failed + +WITH RECURSIVE r AS ( + SELECT 'inht1'::regclass AS inhrelid +UNION ALL + SELECT c.inhrelid FROM pg_inherits c, r WHERE r.inhrelid = c.inhparent +) +SELECT a.attrelid::regclass, a.attname, a.attinhcount, e.expected + FROM (SELECT inhrelid, count(*) AS expected FROM pg_inherits + WHERE inhparent IN (SELECT inhrelid FROM r) GROUP BY inhrelid) e + JOIN pg_attribute a ON e.inhrelid = a.attrelid WHERE NOT attislocal + ORDER BY a.attrelid::regclass::name, a.attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_inherits" +CTE: "r" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="attislocal" +FILTER: schema="" table="" column="inhparent" +FILTER: schema="" table="r" column="inhrelid" +FILTER: schema="" table="c" column="inhparent" +STMT: SelectStmt +== 271 +DROP TABLE inht1, inhs1 CASCADE +-- +TABLE: name="inht1" schema="" table="inht1" ctx=DDL +TABLE: name="inhs1" schema="" table="inhs1" ctx=DDL +STMT: DropStmt +== 272 +-- Test non-inheritable indices [UNIQUE, EXCLUDE] constraints +CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2)) +-- +TABLE: name="test_constraints" schema="" table="test_constraints" ctx=DDL +STMT: CreateStmt +== 273 +CREATE TABLE test_constraints_inh () INHERITS (test_constraints) +-- +TABLE: name="test_constraints_inh" schema="" table="test_constraints_inh" ctx=DDL +STMT: CreateStmt +== 274 +ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key +-- +TABLE: name="test_constraints" schema="" table="test_constraints" ctx=DDL +STMT: AlterTableStmt +== 275 +DROP TABLE test_constraints_inh +-- +TABLE: name="test_constraints_inh" schema="" table="test_constraints_inh" ctx=DDL +STMT: DropStmt +== 276 +DROP TABLE test_constraints +-- +TABLE: name="test_constraints" schema="" table="test_constraints" ctx=DDL +STMT: DropStmt +== 277 +CREATE TABLE test_ex_constraints ( + c circle, + EXCLUDE USING gist (c WITH &&) +) +-- +TABLE: name="test_ex_constraints" schema="" table="test_ex_constraints" ctx=DDL +STMT: CreateStmt +== 278 +CREATE TABLE test_ex_constraints_inh () INHERITS (test_ex_constraints) +-- +TABLE: name="test_ex_constraints_inh" schema="" table="test_ex_constraints_inh" ctx=DDL +STMT: CreateStmt +== 279 +ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl +-- +TABLE: name="test_ex_constraints" schema="" table="test_ex_constraints" ctx=DDL +STMT: AlterTableStmt +== 280 +DROP TABLE test_ex_constraints_inh +-- +TABLE: name="test_ex_constraints_inh" schema="" table="test_ex_constraints_inh" ctx=DDL +STMT: DropStmt +== 281 +DROP TABLE test_ex_constraints +-- +TABLE: name="test_ex_constraints" schema="" table="test_ex_constraints" ctx=DDL +STMT: DropStmt +== 282 +-- Test non-inheritable foreign key constraints +CREATE TABLE test_primary_constraints(id int PRIMARY KEY) +-- +TABLE: name="test_primary_constraints" schema="" table="test_primary_constraints" ctx=DDL +STMT: CreateStmt +== 283 +CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id)) +-- +TABLE: name="test_foreign_constraints" schema="" table="test_foreign_constraints" ctx=DDL +STMT: CreateStmt +== 284 +CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints) +-- +TABLE: name="test_foreign_constraints_inh" schema="" table="test_foreign_constraints_inh" ctx=DDL +STMT: CreateStmt +== 285 +ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey +-- +TABLE: name="test_foreign_constraints" schema="" table="test_foreign_constraints" ctx=DDL +STMT: AlterTableStmt +== 286 +DROP TABLE test_foreign_constraints_inh +-- +TABLE: name="test_foreign_constraints_inh" schema="" table="test_foreign_constraints_inh" ctx=DDL +STMT: DropStmt +== 287 +DROP TABLE test_foreign_constraints +-- +TABLE: name="test_foreign_constraints" schema="" table="test_foreign_constraints" ctx=DDL +STMT: DropStmt +== 288 +DROP TABLE test_primary_constraints +-- +TABLE: name="test_primary_constraints" schema="" table="test_primary_constraints" ctx=DDL +STMT: DropStmt +== 289 +-- Test foreign key behavior +create table inh_fk_1 (a int primary key) +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=DDL +STMT: CreateStmt +== 290 +insert into inh_fk_1 values (1), (2), (3) +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 291 +create table inh_fk_2 (x int primary key, y int references inh_fk_1 on delete cascade) +-- +TABLE: name="inh_fk_2" schema="" table="inh_fk_2" ctx=DDL +STMT: CreateStmt +== 292 +insert into inh_fk_2 values (11, 1), (22, 2), (33, 3) +-- +TABLE: name="inh_fk_2" schema="" table="inh_fk_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +create table inh_fk_2_child () inherits (inh_fk_2) +-- +TABLE: name="inh_fk_2_child" schema="" table="inh_fk_2_child" ctx=DDL +STMT: CreateStmt +== 294 +insert into inh_fk_2_child values (111, 1), (222, 2) +-- +TABLE: name="inh_fk_2_child" schema="" table="inh_fk_2_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 295 +delete from inh_fk_1 where a = 1 +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=DML +STMT: DeleteStmt +== 296 +select * from inh_fk_1 order by 1 +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=Select +STMT: SelectStmt +== 297 +select * from inh_fk_2 order by 1, 2 +-- +TABLE: name="inh_fk_2" schema="" table="inh_fk_2" ctx=Select +STMT: SelectStmt +== 298 +drop table inh_fk_1, inh_fk_2, inh_fk_2_child +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=DDL +TABLE: name="inh_fk_2" schema="" table="inh_fk_2" ctx=DDL +TABLE: name="inh_fk_2_child" schema="" table="inh_fk_2_child" ctx=DDL +STMT: DropStmt +== 299 +-- Test that parent and child CHECK constraints can be created in either order +create table p1(f1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 300 +create table p1_c1() inherits(p1) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: CreateStmt +== 301 +alter table p1 add constraint inh_check_constraint1 check (f1 > 0) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 302 +alter table p1_c1 add constraint inh_check_constraint1 check (f1 > 0) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: AlterTableStmt +== 303 +alter table p1_c1 add constraint inh_check_constraint2 check (f1 < 10) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: AlterTableStmt +== 304 +alter table p1 add constraint inh_check_constraint2 check (f1 < 10) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 305 +select conrelid::regclass::text as relname, conname, conislocal, coninhcount +from pg_constraint where conname like 'inh\_check\_constraint%' +order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 306 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 307 +|-- +-- Test DROP behavior of multiply-defined CHECK constraints +|-- +create table p1(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 308 +create table p1_c1 (f1 int constraint f1_pos CHECK (f1 > 0)) inherits (p1) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: CreateStmt +== 309 +alter table p1_c1 drop constraint f1_pos +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: AlterTableStmt +== 310 +alter table p1 drop constraint f1_pos +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 311 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 312 +create table p1(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 313 +create table p2(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +== 314 +create table p1p2_c1 (f1 int) inherits (p1, p2) +-- +TABLE: name="p1p2_c1" schema="" table="p1p2_c1" ctx=DDL +STMT: CreateStmt +== 315 +create table p1p2_c2 (f1 int constraint f1_pos CHECK (f1 > 0)) inherits (p1, p2) +-- +TABLE: name="p1p2_c2" schema="" table="p1p2_c2" ctx=DDL +STMT: CreateStmt +== 316 +alter table p2 drop constraint f1_pos +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +== 317 +alter table p1 drop constraint f1_pos +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 318 +drop table p1, p2 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: DropStmt +== 319 +create table p1(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 320 +create table p1_c1() inherits (p1) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: CreateStmt +== 321 +create table p1_c2() inherits (p1) +-- +TABLE: name="p1_c2" schema="" table="p1_c2" ctx=DDL +STMT: CreateStmt +== 322 +create table p1_c1c2() inherits (p1_c1, p1_c2) +-- +TABLE: name="p1_c1c2" schema="" table="p1_c1c2" ctx=DDL +STMT: CreateStmt +== 323 +alter table p1 drop constraint f1_pos +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 324 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 325 +create table p1(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 326 +create table p1_c1() inherits (p1) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: CreateStmt +== 327 +create table p1_c2(constraint f1_pos CHECK (f1 > 0)) inherits (p1) +-- +TABLE: name="p1_c2" schema="" table="p1_c2" ctx=DDL +STMT: CreateStmt +== 328 +create table p1_c1c2() inherits (p1_c1, p1_c2, p1) +-- +TABLE: name="p1_c1c2" schema="" table="p1_c1c2" ctx=DDL +STMT: CreateStmt +== 329 +alter table p1_c2 drop constraint f1_pos +-- +TABLE: name="p1_c2" schema="" table="p1_c2" ctx=DDL +STMT: AlterTableStmt +== 330 +alter table p1 drop constraint f1_pos +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +== 331 +alter table p1_c1c2 drop constraint f1_pos +-- +TABLE: name="p1_c1c2" schema="" table="p1_c1c2" ctx=DDL +STMT: AlterTableStmt +== 332 +alter table p1_c2 drop constraint f1_pos +-- +TABLE: name="p1_c2" schema="" table="p1_c2" ctx=DDL +STMT: AlterTableStmt +== 333 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +== 334 +-- Test that a valid child can have not-valid parent, but not vice versa +create table invalid_check_con(f1 int) +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DDL +STMT: CreateStmt +== 335 +create table invalid_check_con_child() inherits(invalid_check_con) +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DDL +STMT: CreateStmt +== 336 +alter table invalid_check_con_child add constraint inh_check_constraint check(f1 > 0) not valid +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DDL +STMT: AlterTableStmt +== 337 +alter table invalid_check_con add constraint inh_check_constraint check(f1 > 0) +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DDL +STMT: AlterTableStmt +== 338 +-- fail +alter table invalid_check_con_child drop constraint inh_check_constraint +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DDL +STMT: AlterTableStmt +== 339 +insert into invalid_check_con values(0) +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 340 +alter table invalid_check_con_child add constraint inh_check_constraint check(f1 > 0) +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DDL +STMT: AlterTableStmt +== 341 +alter table invalid_check_con add constraint inh_check_constraint check(f1 > 0) not valid +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DDL +STMT: AlterTableStmt +== 342 +insert into invalid_check_con values(0) +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 343 +-- fail +insert into invalid_check_con_child values(0) +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 344 +-- fail + +select conrelid::regclass::text as relname, conname, + convalidated, conislocal, coninhcount, connoinherit +from pg_constraint where conname like 'inh\_check\_constraint%' +order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +== 345 +-- We don't drop the invalid_check_con* tables, to test dump/reload with + +|-- +-- Test parameterized append plans for inheritance trees +|-- + +create temp table patest0 (id, x) as + select x, x from generate_series(0,1000) x +-- +TABLE: name="patest0" schema="" table="patest0" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 346 +create temp table patest1() inherits (patest0) +-- +TABLE: name="patest1" schema="" table="patest1" ctx=DDL +STMT: CreateStmt +== 347 +insert into patest1 + select x, x from generate_series(0,1000) x +-- +TABLE: name="patest1" schema="" table="patest1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 348 +create temp table patest2() inherits (patest0) +-- +TABLE: name="patest2" schema="" table="patest2" ctx=DDL +STMT: CreateStmt +== 349 +insert into patest2 + select x, x from generate_series(0,1000) x +-- +TABLE: name="patest2" schema="" table="patest2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 350 +create index patest0i on patest0(id) +-- +TABLE: name="patest0" schema="" table="patest0" ctx=DDL +STMT: IndexStmt +== 351 +create index patest1i on patest1(id) +-- +TABLE: name="patest1" schema="" table="patest1" ctx=DDL +STMT: IndexStmt +== 352 +create index patest2i on patest2(id) +-- +TABLE: name="patest2" schema="" table="patest2" ctx=DDL +STMT: IndexStmt +== 353 +analyze patest0 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=DDL +STMT: VacuumStmt +== 354 +analyze patest1 +-- +TABLE: name="patest1" schema="" table="patest1" ctx=DDL +STMT: VacuumStmt +== 355 +analyze patest2 +-- +TABLE: name="patest2" schema="" table="patest2" ctx=DDL +STMT: VacuumStmt +== 356 +explain (costs off) +select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 357 +select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +== 358 +drop index patest2i +-- +STMT: DropStmt +== 359 +explain (costs off) +select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 360 +select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +== 361 +drop table patest0 cascade +-- +TABLE: name="patest0" schema="" table="patest0" ctx=DDL +STMT: DropStmt +== 362 +|-- +-- Test merge-append plans for inheritance trees +|-- + +create table matest0 (id serial primary key, name text) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: CreateStmt +== 363 +create table matest1 (id integer primary key) inherits (matest0) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: CreateStmt +== 364 +create table matest2 (id integer primary key) inherits (matest0) +-- +TABLE: name="matest2" schema="" table="matest2" ctx=DDL +STMT: CreateStmt +== 365 +create table matest3 (id integer primary key) inherits (matest0) +-- +TABLE: name="matest3" schema="" table="matest3" ctx=DDL +STMT: CreateStmt +== 366 +create index matest0i on matest0 ((1-id)) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: IndexStmt +== 367 +create index matest1i on matest1 ((1-id)) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: IndexStmt +== 368 +-- create index matest2i on matest2 ((1-id)); -- intentionally missing +create index matest3i on matest3 ((1-id)) +-- +TABLE: name="matest3" schema="" table="matest3" ctx=DDL +STMT: IndexStmt +== 369 +insert into matest1 (name) values ('Test 1') +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 370 +insert into matest1 (name) values ('Test 2') +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 371 +insert into matest2 (name) values ('Test 3') +-- +TABLE: name="matest2" schema="" table="matest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 372 +insert into matest2 (name) values ('Test 4') +-- +TABLE: name="matest2" schema="" table="matest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 373 +insert into matest3 (name) values ('Test 5') +-- +TABLE: name="matest3" schema="" table="matest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 374 +insert into matest3 (name) values ('Test 6') +-- +TABLE: name="matest3" schema="" table="matest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 375 +set enable_indexscan = off +-- +STMT: VariableSetStmt +== 376 +-- force use of seqscan/sort, so no merge +explain (verbose, costs off) select * from matest0 order by 1-id +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 377 +select * from matest0 order by 1-id +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +STMT: SelectStmt +== 378 +explain (verbose, costs off) select min(1-id) from matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 379 +select min(1-id) from matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 380 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 381 +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 382 +-- plan with fewest seqscans should be merge +set enable_parallel_append = off +-- +STMT: VariableSetStmt +== 383 +-- Don't let parallel-append interfere +explain (verbose, costs off) select * from matest0 order by 1-id +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 384 +select * from matest0 order by 1-id +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +STMT: SelectStmt +== 385 +explain (verbose, costs off) select min(1-id) from matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 386 +select min(1-id) from matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 387 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 388 +reset enable_parallel_append +-- +STMT: VariableSetStmt +== 389 +explain (verbose, costs off) -- bug #18652 +select 1 - id as c from +(select id from matest3 t1 union all select id * 2 from matest3 t2) ss +order by c +-- +TABLE: name="matest3" schema="" table="matest3" ctx=Select +TABLE: name="matest3" schema="" table="matest3" ctx=Select +ALIAS: "t1"="matest3" +ALIAS: "t2"="matest3" +STMT: ExplainStmt +STMT: SelectStmt +== 390 +select 1 - id as c from +(select id from matest3 t1 union all select id * 2 from matest3 t2) ss +order by c +-- +TABLE: name="matest3" schema="" table="matest3" ctx=Select +TABLE: name="matest3" schema="" table="matest3" ctx=Select +ALIAS: "t1"="matest3" +ALIAS: "t2"="matest3" +STMT: SelectStmt +== 391 +drop table matest0 cascade +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: DropStmt +== 392 +|-- +-- Check that use of an index with an extraneous column doesn't produce +-- a plan with extraneous sorting +|-- + +create table matest0 (a int, b int, c int, d int) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: CreateStmt +== 393 +create table matest1 () inherits(matest0) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: CreateStmt +== 394 +create index matest0i on matest0 (b, c) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: IndexStmt +== 395 +create index matest1i on matest1 (b, c) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: IndexStmt +== 396 +set enable_nestloop = off +-- +STMT: VariableSetStmt +== 397 +-- we want a plan with two MergeAppends + +explain (costs off) +select t1.* from matest0 t1, matest0 t2 +where t1.b = t2.b and t2.c = t2.d +order by t1.b limit 10 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +TABLE: name="matest0" schema="" table="matest0" ctx=Select +ALIAS: "t1"="matest0" +ALIAS: "t2"="matest0" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t2" column="d" +STMT: ExplainStmt +STMT: SelectStmt +== 398 +reset enable_nestloop +-- +STMT: VariableSetStmt +== 399 +drop table matest0 cascade +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: DropStmt +== 400 +-- Test a MergeAppend plan where one child requires a sort +create table matest0(a int primary key) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: CreateStmt +== 401 +create table matest1() inherits (matest0) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: CreateStmt +== 402 +insert into matest0 select generate_series(1, 400) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 403 +insert into matest1 select generate_series(1, 200) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 404 +analyze matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: VacuumStmt +== 405 +analyze matest1 +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: VacuumStmt +== 406 +explain (costs off) +select * from matest0 where a < 100 order by a +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 407 +drop table matest0 cascade +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: DropStmt +== 408 +|-- +-- Test merge-append for UNION ALL append relations +|-- + +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 409 +set enable_indexscan = on +-- +STMT: VariableSetStmt +== 410 +set enable_bitmapscan = off +-- +STMT: VariableSetStmt +== 411 +-- Check handling of duplicated, constant, or volatile targetlist items +explain (costs off) +SELECT thousand, tenthous FROM tenk1 +UNION ALL +SELECT thousand, thousand FROM tenk1 +ORDER BY thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 412 +explain (costs off) +SELECT thousand, tenthous, thousand+tenthous AS x FROM tenk1 +UNION ALL +SELECT 42, 42, hundred FROM tenk1 +ORDER BY thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 413 +explain (costs off) +SELECT thousand, tenthous FROM tenk1 +UNION ALL +SELECT thousand, random()::integer FROM tenk1 +ORDER BY thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 414 +-- Check min/max aggregate optimization +explain (costs off) +SELECT min(x) FROM + (SELECT unique1 AS x FROM tenk1 a + UNION ALL + SELECT unique2 AS x FROM tenk1 b) s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 415 +explain (costs off) +SELECT min(y) FROM + (SELECT unique1 AS x, unique1 AS y FROM tenk1 a + UNION ALL + SELECT unique2 AS x, unique2 AS y FROM tenk1 b) s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 416 +-- XXX planner doesn't recognize that index on unique2 is sufficiently sorted +explain (costs off) +SELECT x, y FROM + (SELECT thousand AS x, tenthous AS y FROM tenk1 a + UNION ALL + SELECT unique2 AS x, unique2 AS y FROM tenk1 b) s +ORDER BY x, y +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +== 417 +-- exercise rescan code path via a repeatedly-evaluated subquery +explain (costs off) +SELECT + ARRAY(SELECT f.i FROM ( + (SELECT d + g.i FROM generate_series(4, 30, 3) d ORDER BY 1) + UNION ALL + (SELECT d + g.i FROM generate_series(0, 30, 5) d ORDER BY 1) + ) f(i) + ORDER BY f.i LIMIT 10) +FROM generate_series(1, 3) g(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 418 +SELECT + ARRAY(SELECT f.i FROM ( + (SELECT d + g.i FROM generate_series(4, 30, 3) d ORDER BY 1) + UNION ALL + (SELECT d + g.i FROM generate_series(0, 30, 5) d ORDER BY 1) + ) f(i) + ORDER BY f.i LIMIT 10) +FROM generate_series(1, 3) g(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 419 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 420 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 421 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 422 +|-- +-- Check handling of MULTIEXPR SubPlans in inherited updates +|-- +create table inhpar(f1 int, f2 name) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: CreateStmt +== 423 +create table inhcld(f2 name, f1 int) +-- +TABLE: name="inhcld" schema="" table="inhcld" ctx=DDL +STMT: CreateStmt +== 424 +alter table inhcld inherit inhpar +-- +TABLE: name="inhcld" schema="" table="inhcld" ctx=DDL +STMT: AlterTableStmt +== 425 +insert into inhpar select x, x::text from generate_series(1,5) x +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 426 +insert into inhcld select x::text, x from generate_series(6,10) x +-- +TABLE: name="inhcld" schema="" table="inhcld" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 427 +explain (verbose, costs off) +update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit 1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="inhpar" +STMT: ExplainStmt +STMT: UpdateStmt +STMT: SelectStmt +== 428 +update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit 1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="inhpar" +STMT: UpdateStmt +STMT: SelectStmt +== 429 +select * from inhpar +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=Select +STMT: SelectStmt +== 430 +drop table inhpar cascade +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: DropStmt +== 431 +|-- +-- And the same for partitioned cases +|-- +create table inhpar(f1 int primary key, f2 name) partition by range (f1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: CreateStmt +== 432 +create table inhcld1(f2 name, f1 int primary key) +-- +TABLE: name="inhcld1" schema="" table="inhcld1" ctx=DDL +STMT: CreateStmt +== 433 +create table inhcld2(f1 int primary key, f2 name) +-- +TABLE: name="inhcld2" schema="" table="inhcld2" ctx=DDL +STMT: CreateStmt +== 434 +alter table inhpar attach partition inhcld1 for values from (1) to (5) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: AlterTableStmt +== 435 +alter table inhpar attach partition inhcld2 for values from (5) to (100) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: AlterTableStmt +== 436 +insert into inhpar select x, x::text from generate_series(1,10) x +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 437 +explain (verbose, costs off) +update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit 1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="inhpar" +STMT: ExplainStmt +STMT: UpdateStmt +STMT: SelectStmt +== 438 +update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit 1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="inhpar" +STMT: UpdateStmt +STMT: SelectStmt +== 439 +select * from inhpar +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=Select +STMT: SelectStmt +== 440 +-- Also check ON CONFLICT +insert into inhpar as i values (3), (7) on conflict (f1) + do update set (f1, f2) = (select i.f1, i.f2 || '+') +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +ALIAS: "i"="inhpar" +STMT: InsertStmt +STMT: SelectStmt +== 441 +select * from inhpar order by f1 +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=Select +STMT: SelectStmt +== 442 +-- tuple order might be unstable here + +drop table inhpar cascade +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: DropStmt +== 443 +|-- +-- Check handling of a constant-null CHECK constraint +|-- +create table cnullparent (f1 int) +-- +TABLE: name="cnullparent" schema="" table="cnullparent" ctx=DDL +STMT: CreateStmt +== 444 +create table cnullchild (check (f1 = 1 or f1 = null)) inherits(cnullparent) +-- +TABLE: name="cnullchild" schema="" table="cnullchild" ctx=DDL +STMT: CreateStmt +== 445 +insert into cnullchild values(1) +-- +TABLE: name="cnullchild" schema="" table="cnullchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 446 +insert into cnullchild values(2) +-- +TABLE: name="cnullchild" schema="" table="cnullchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 447 +insert into cnullchild values(null) +-- +TABLE: name="cnullchild" schema="" table="cnullchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 448 +select * from cnullparent +-- +TABLE: name="cnullparent" schema="" table="cnullparent" ctx=Select +STMT: SelectStmt +== 449 +select * from cnullparent where f1 = 2 +-- +TABLE: name="cnullparent" schema="" table="cnullparent" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 450 +drop table cnullparent cascade +-- +TABLE: name="cnullparent" schema="" table="cnullparent" ctx=DDL +STMT: DropStmt +== 451 +|-- +-- Mixed ownership inheritance tree +|-- +create role regress_alice +-- +STMT: CreateRoleStmt +== 452 +create role regress_bob +-- +STMT: CreateRoleStmt +== 453 +grant all on schema public to regress_alice, regress_bob +-- +STMT: GrantStmt +== 454 +grant regress_alice to regress_bob +-- +STMT: GrantRoleStmt +== 455 +set session authorization regress_alice +-- +STMT: VariableSetStmt +== 456 +create table inh_parent (a int not null) +-- +TABLE: name="inh_parent" schema="" table="inh_parent" ctx=DDL +STMT: CreateStmt +== 457 +set session authorization regress_bob +-- +STMT: VariableSetStmt +== 458 +create table inh_child () inherits (inh_parent) +-- +TABLE: name="inh_child" schema="" table="inh_child" ctx=DDL +STMT: CreateStmt +== 459 +set session authorization regress_alice +-- +STMT: VariableSetStmt +== 460 +-- alice can't do this: she doesn't own inh_child +alter table inh_parent alter a drop not null +-- +TABLE: name="inh_parent" schema="" table="inh_parent" ctx=DDL +STMT: AlterTableStmt +== 461 +set session authorization regress_bob +-- +STMT: VariableSetStmt +== 462 +alter table inh_parent alter a drop not null +-- +TABLE: name="inh_parent" schema="" table="inh_parent" ctx=DDL +STMT: AlterTableStmt +== 463 +reset session authorization +-- +STMT: VariableSetStmt +== 464 +drop table inh_parent, inh_child +-- +TABLE: name="inh_parent" schema="" table="inh_parent" ctx=DDL +TABLE: name="inh_child" schema="" table="inh_child" ctx=DDL +STMT: DropStmt +== 465 +revoke all on schema public from regress_alice, regress_bob +-- +STMT: GrantStmt +== 466 +drop role regress_alice, regress_bob +-- +STMT: DropRoleStmt +== 467 +|-- +-- Check use of temporary tables with inheritance trees +|-- +create table inh_perm_parent (a1 int) +-- +TABLE: name="inh_perm_parent" schema="" table="inh_perm_parent" ctx=DDL +STMT: CreateStmt +== 468 +create temp table inh_temp_parent (a1 int) +-- +TABLE: name="inh_temp_parent" schema="" table="inh_temp_parent" ctx=DDL +STMT: CreateStmt +== 469 +create temp table inh_temp_child () inherits (inh_perm_parent) +-- +TABLE: name="inh_temp_child" schema="" table="inh_temp_child" ctx=DDL +STMT: CreateStmt +== 470 +-- ok +create table inh_perm_child () inherits (inh_temp_parent) +-- +TABLE: name="inh_perm_child" schema="" table="inh_perm_child" ctx=DDL +STMT: CreateStmt +== 471 +-- error +create temp table inh_temp_child_2 () inherits (inh_temp_parent) +-- +TABLE: name="inh_temp_child_2" schema="" table="inh_temp_child_2" ctx=DDL +STMT: CreateStmt +== 472 +-- ok +insert into inh_perm_parent values (1) +-- +TABLE: name="inh_perm_parent" schema="" table="inh_perm_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 473 +insert into inh_temp_parent values (2) +-- +TABLE: name="inh_temp_parent" schema="" table="inh_temp_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 474 +insert into inh_temp_child values (3) +-- +TABLE: name="inh_temp_child" schema="" table="inh_temp_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 475 +insert into inh_temp_child_2 values (4) +-- +TABLE: name="inh_temp_child_2" schema="" table="inh_temp_child_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 476 +select tableoid::regclass, a1 from inh_perm_parent +-- +TABLE: name="inh_perm_parent" schema="" table="inh_perm_parent" ctx=Select +STMT: SelectStmt +== 477 +select tableoid::regclass, a1 from inh_temp_parent +-- +TABLE: name="inh_temp_parent" schema="" table="inh_temp_parent" ctx=Select +STMT: SelectStmt +== 478 +drop table inh_perm_parent cascade +-- +TABLE: name="inh_perm_parent" schema="" table="inh_perm_parent" ctx=DDL +STMT: DropStmt +== 479 +drop table inh_temp_parent cascade +-- +TABLE: name="inh_temp_parent" schema="" table="inh_temp_parent" ctx=DDL +STMT: DropStmt +== 480 +|-- +-- Check that constraint exclusion works correctly with partitions using +-- implicit constraints generated from the partition bound information. +|-- +create table list_parted ( + a varchar +) partition by list (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +== 481 +create table part_ab_cd partition of list_parted for values in ('ab', 'cd') +-- +TABLE: name="part_ab_cd" schema="" table="part_ab_cd" ctx=DDL +STMT: CreateStmt +== 482 +create table part_ef_gh partition of list_parted for values in ('ef', 'gh') +-- +TABLE: name="part_ef_gh" schema="" table="part_ef_gh" ctx=DDL +STMT: CreateStmt +== 483 +create table part_null_xy partition of list_parted for values in (null, 'xy') +-- +TABLE: name="part_null_xy" schema="" table="part_null_xy" ctx=DDL +STMT: CreateStmt +== 484 +explain (costs off) select * from list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 485 +explain (costs off) select * from list_parted where a is null +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 486 +explain (costs off) select * from list_parted where a is not null +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 487 +explain (costs off) select * from list_parted where a in ('ab', 'cd', 'ef') +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 488 +explain (costs off) select * from list_parted where a = 'ab' or a in (null, 'cd') +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 489 +explain (costs off) select * from list_parted where a = 'ab' +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 490 +create table range_list_parted ( + a int, + b char(2) +) partition by range (a) +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=DDL +STMT: CreateStmt +== 491 +create table part_1_10 partition of range_list_parted for values from (1) to (10) partition by list (b) +-- +TABLE: name="part_1_10" schema="" table="part_1_10" ctx=DDL +STMT: CreateStmt +== 492 +create table part_1_10_ab partition of part_1_10 for values in ('ab') +-- +TABLE: name="part_1_10_ab" schema="" table="part_1_10_ab" ctx=DDL +STMT: CreateStmt +== 493 +create table part_1_10_cd partition of part_1_10 for values in ('cd') +-- +TABLE: name="part_1_10_cd" schema="" table="part_1_10_cd" ctx=DDL +STMT: CreateStmt +== 494 +create table part_10_20 partition of range_list_parted for values from (10) to (20) partition by list (b) +-- +TABLE: name="part_10_20" schema="" table="part_10_20" ctx=DDL +STMT: CreateStmt +== 495 +create table part_10_20_ab partition of part_10_20 for values in ('ab') +-- +TABLE: name="part_10_20_ab" schema="" table="part_10_20_ab" ctx=DDL +STMT: CreateStmt +== 496 +create table part_10_20_cd partition of part_10_20 for values in ('cd') +-- +TABLE: name="part_10_20_cd" schema="" table="part_10_20_cd" ctx=DDL +STMT: CreateStmt +== 497 +create table part_21_30 partition of range_list_parted for values from (21) to (30) partition by list (b) +-- +TABLE: name="part_21_30" schema="" table="part_21_30" ctx=DDL +STMT: CreateStmt +== 498 +create table part_21_30_ab partition of part_21_30 for values in ('ab') +-- +TABLE: name="part_21_30_ab" schema="" table="part_21_30_ab" ctx=DDL +STMT: CreateStmt +== 499 +create table part_21_30_cd partition of part_21_30 for values in ('cd') +-- +TABLE: name="part_21_30_cd" schema="" table="part_21_30_cd" ctx=DDL +STMT: CreateStmt +== 500 +create table part_40_inf partition of range_list_parted for values from (40) to (maxvalue) partition by list (b) +-- +TABLE: name="part_40_inf" schema="" table="part_40_inf" ctx=DDL +STMT: CreateStmt +== 501 +create table part_40_inf_ab partition of part_40_inf for values in ('ab') +-- +TABLE: name="part_40_inf_ab" schema="" table="part_40_inf_ab" ctx=DDL +STMT: CreateStmt +== 502 +create table part_40_inf_cd partition of part_40_inf for values in ('cd') +-- +TABLE: name="part_40_inf_cd" schema="" table="part_40_inf_cd" ctx=DDL +STMT: CreateStmt +== 503 +create table part_40_inf_null partition of part_40_inf for values in (null) +-- +TABLE: name="part_40_inf_null" schema="" table="part_40_inf_null" ctx=DDL +STMT: CreateStmt +== 504 +explain (costs off) select * from range_list_parted +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 505 +explain (costs off) select * from range_list_parted where a = 5 +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 506 +explain (costs off) select * from range_list_parted where b = 'ab' +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 507 +explain (costs off) select * from range_list_parted where a between 3 and 23 and b in ('ab') +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 508 +/* Should select no rows because range partition key cannot be null */ +explain (costs off) select * from range_list_parted where a is null +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 509 +/* Should only select rows from the null-accepting partition */ +explain (costs off) select * from range_list_parted where b is null +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 510 +explain (costs off) select * from range_list_parted where a is not null and a < 67 +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 511 +explain (costs off) select * from range_list_parted where a >= 30 +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 512 +drop table list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +== 513 +drop table range_list_parted +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=DDL +STMT: DropStmt +== 514 +-- check that constraint exclusion is able to cope with the partition +-- constraint emitted for multi-column range partitioned tables +create table mcrparted (a int, b int, c int) partition by range (a, abs(b), c) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: CreateStmt +== 515 +create table mcrparted_def partition of mcrparted default +-- +TABLE: name="mcrparted_def" schema="" table="mcrparted_def" ctx=DDL +STMT: CreateStmt +== 516 +create table mcrparted0 partition of mcrparted for values from (minvalue, minvalue, minvalue) to (1, 1, 1) +-- +TABLE: name="mcrparted0" schema="" table="mcrparted0" ctx=DDL +STMT: CreateStmt +== 517 +create table mcrparted1 partition of mcrparted for values from (1, 1, 1) to (10, 5, 10) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DDL +STMT: CreateStmt +== 518 +create table mcrparted2 partition of mcrparted for values from (10, 5, 10) to (10, 10, 10) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DDL +STMT: CreateStmt +== 519 +create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20, 10, 10) +-- +TABLE: name="mcrparted3" schema="" table="mcrparted3" ctx=DDL +STMT: CreateStmt +== 520 +create table mcrparted4 partition of mcrparted for values from (20, 10, 10) to (20, 20, 20) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DDL +STMT: CreateStmt +== 521 +create table mcrparted5 partition of mcrparted for values from (20, 20, 20) to (maxvalue, maxvalue, maxvalue) +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DDL +STMT: CreateStmt +== 522 +explain (costs off) select * from mcrparted where a = 0 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 523 +-- scans mcrparted0, mcrparted_def +explain (costs off) select * from mcrparted where a = 10 and abs(b) < 5 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 524 +-- scans mcrparted1, mcrparted_def +explain (costs off) select * from mcrparted where a = 10 and abs(b) = 5 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 525 +-- scans mcrparted1, mcrparted2, mcrparted_def +explain (costs off) select * from mcrparted where abs(b) = 5 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 526 +-- scans all partitions +explain (costs off) select * from mcrparted where a > -1 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 527 +-- scans all partitions +explain (costs off) select * from mcrparted where a = 20 and abs(b) = 10 and c > 10 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 528 +-- scans mcrparted4 +explain (costs off) select * from mcrparted where a = 20 and c > 20 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 529 +-- scans mcrparted3, mcrparte4, mcrparte5, mcrparted_def + +-- check that partitioned table Appends cope with being referenced in +-- subplans +create table parted_minmax (a int, b varchar(16)) partition by range (a) +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=DDL +STMT: CreateStmt +== 530 +create table parted_minmax1 partition of parted_minmax for values from (1) to (10) +-- +TABLE: name="parted_minmax1" schema="" table="parted_minmax1" ctx=DDL +STMT: CreateStmt +== 531 +create index parted_minmax1i on parted_minmax1 (a, b) +-- +TABLE: name="parted_minmax1" schema="" table="parted_minmax1" ctx=DDL +STMT: IndexStmt +== 532 +insert into parted_minmax values (1,'12345') +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 533 +explain (costs off) select min(a), max(a) from parted_minmax where b = '12345' +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 534 +select min(a), max(a) from parted_minmax where b = '12345' +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 535 +drop table parted_minmax +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=DDL +STMT: DropStmt +== 536 +-- Test code that uses Append nodes in place of MergeAppend when the +-- partition ordering matches the desired ordering. + +create index mcrparted_a_abs_c_idx on mcrparted (a, abs(b), c) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 537 +-- MergeAppend must be used when a default partition exists +explain (costs off) select * from mcrparted order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 538 +drop table mcrparted_def +-- +TABLE: name="mcrparted_def" schema="" table="mcrparted_def" ctx=DDL +STMT: DropStmt +== 539 +-- Append is used for a RANGE partitioned table with no default +-- and no subpartitions +explain (costs off) select * from mcrparted order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 540 +-- Append is used with subpaths in reverse order with backwards index scans +explain (costs off) select * from mcrparted order by a desc, abs(b) desc, c desc +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 541 +-- check that Append plan is used containing a MergeAppend for sub-partitions +-- that are unordered. +drop table mcrparted5 +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DDL +STMT: DropStmt +== 542 +create table mcrparted5 partition of mcrparted for values from (20, 20, 20) to (maxvalue, maxvalue, maxvalue) partition by list (a) +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DDL +STMT: CreateStmt +== 543 +create table mcrparted5a partition of mcrparted5 for values in(20) +-- +TABLE: name="mcrparted5a" schema="" table="mcrparted5a" ctx=DDL +STMT: CreateStmt +== 544 +create table mcrparted5_def partition of mcrparted5 default +-- +TABLE: name="mcrparted5_def" schema="" table="mcrparted5_def" ctx=DDL +STMT: CreateStmt +== 545 +explain (costs off) select * from mcrparted order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 546 +drop table mcrparted5_def +-- +TABLE: name="mcrparted5_def" schema="" table="mcrparted5_def" ctx=DDL +STMT: DropStmt +== 547 +-- check that an Append plan is used and the sub-partitions are flattened +-- into the main Append when the sub-partition is unordered but contains +-- just a single sub-partition. +explain (costs off) select a, abs(b) from mcrparted order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 548 +-- check that Append is used when the sub-partitioned tables are pruned +-- during planning. +explain (costs off) select * from mcrparted where a < 20 order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 549 +set enable_bitmapscan to off +-- +STMT: VariableSetStmt +== 550 +set enable_sort to off +-- +STMT: VariableSetStmt +== 551 +create table mclparted (a int) partition by list(a) +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=DDL +STMT: CreateStmt +== 552 +create table mclparted1 partition of mclparted for values in(1) +-- +TABLE: name="mclparted1" schema="" table="mclparted1" ctx=DDL +STMT: CreateStmt +== 553 +create table mclparted2 partition of mclparted for values in(2) +-- +TABLE: name="mclparted2" schema="" table="mclparted2" ctx=DDL +STMT: CreateStmt +== 554 +create index on mclparted (a) +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=DDL +STMT: IndexStmt +== 555 +-- Ensure an Append is used for a list partition with an order by. +explain (costs off) select * from mclparted order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 556 +-- Ensure a MergeAppend is used when a partition exists with interleaved +-- datums in the partition bound. +create table mclparted3_5 partition of mclparted for values in(3,5) +-- +TABLE: name="mclparted3_5" schema="" table="mclparted3_5" ctx=DDL +STMT: CreateStmt +== 557 +create table mclparted4 partition of mclparted for values in(4) +-- +TABLE: name="mclparted4" schema="" table="mclparted4" ctx=DDL +STMT: CreateStmt +== 558 +explain (costs off) select * from mclparted order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 559 +explain (costs off) select * from mclparted where a in(3,4,5) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 560 +-- Introduce a NULL and DEFAULT partition so we can test more complex cases +create table mclparted_null partition of mclparted for values in(null) +-- +TABLE: name="mclparted_null" schema="" table="mclparted_null" ctx=DDL +STMT: CreateStmt +== 561 +create table mclparted_def partition of mclparted default +-- +TABLE: name="mclparted_def" schema="" table="mclparted_def" ctx=DDL +STMT: CreateStmt +== 562 +-- Append can be used providing we don't scan the interleaved partition +explain (costs off) select * from mclparted where a in(1,2,4) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 563 +explain (costs off) select * from mclparted where a in(1,2,4) or a is null order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 564 +-- Test a more complex case where the NULL partition allows some other value +drop table mclparted_null +-- +TABLE: name="mclparted_null" schema="" table="mclparted_null" ctx=DDL +STMT: DropStmt +== 565 +create table mclparted_0_null partition of mclparted for values in(0,null) +-- +TABLE: name="mclparted_0_null" schema="" table="mclparted_0_null" ctx=DDL +STMT: CreateStmt +== 566 +-- Ensure MergeAppend is used since 0 and NULLs are in the same partition. +explain (costs off) select * from mclparted where a in(1,2,4) or a is null order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 567 +explain (costs off) select * from mclparted where a in(0,1,2,4) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 568 +-- Ensure Append is used when the null partition is pruned +explain (costs off) select * from mclparted where a in(1,2,4) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 569 +-- Ensure MergeAppend is used when the default partition is not pruned +explain (costs off) select * from mclparted where a in(1,2,4,100) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 570 +drop table mclparted +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=DDL +STMT: DropStmt +== 571 +reset enable_sort +-- +STMT: VariableSetStmt +== 572 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 573 +-- Ensure subplans which don't have a path with the correct pathkeys get +-- sorted correctly. +drop index mcrparted_a_abs_c_idx +-- +STMT: DropStmt +== 574 +create index on mcrparted1 (a, abs(b), c) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 575 +create index on mcrparted2 (a, abs(b), c) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 576 +create index on mcrparted3 (a, abs(b), c) +-- +TABLE: name="mcrparted3" schema="" table="mcrparted3" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 577 +create index on mcrparted4 (a, abs(b), c) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 578 +explain (costs off) select * from mcrparted where a < 20 order by a, abs(b), c limit 1 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 579 +set enable_bitmapscan = 0 +-- +STMT: VariableSetStmt +== 580 +-- Ensure Append node can be used when the partition is ordered by some +-- pathkeys which were deemed redundant. +explain (costs off) select * from mcrparted where a = 10 order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 581 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 582 +drop table mcrparted +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: DropStmt +== 583 +-- Ensure LIST partitions allow an Append to be used instead of a MergeAppend +create table bool_lp (b bool) partition by list(b) +-- +TABLE: name="bool_lp" schema="" table="bool_lp" ctx=DDL +STMT: CreateStmt +== 584 +create table bool_lp_true partition of bool_lp for values in(true) +-- +TABLE: name="bool_lp_true" schema="" table="bool_lp_true" ctx=DDL +STMT: CreateStmt +== 585 +create table bool_lp_false partition of bool_lp for values in(false) +-- +TABLE: name="bool_lp_false" schema="" table="bool_lp_false" ctx=DDL +STMT: CreateStmt +== 586 +create index on bool_lp (b) +-- +TABLE: name="bool_lp" schema="" table="bool_lp" ctx=DDL +STMT: IndexStmt +== 587 +explain (costs off) select * from bool_lp order by b +-- +TABLE: name="bool_lp" schema="" table="bool_lp" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 588 +drop table bool_lp +-- +TABLE: name="bool_lp" schema="" table="bool_lp" ctx=DDL +STMT: DropStmt +== 589 +-- Ensure const bool quals can be properly detected as redundant +create table bool_rp (b bool, a int) partition by range(b,a) +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=DDL +STMT: CreateStmt +== 590 +create table bool_rp_false_1k partition of bool_rp for values from (false,0) to (false,1000) +-- +TABLE: name="bool_rp_false_1k" schema="" table="bool_rp_false_1k" ctx=DDL +STMT: CreateStmt +== 591 +create table bool_rp_true_1k partition of bool_rp for values from (true,0) to (true,1000) +-- +TABLE: name="bool_rp_true_1k" schema="" table="bool_rp_true_1k" ctx=DDL +STMT: CreateStmt +== 592 +create table bool_rp_false_2k partition of bool_rp for values from (false,1000) to (false,2000) +-- +TABLE: name="bool_rp_false_2k" schema="" table="bool_rp_false_2k" ctx=DDL +STMT: CreateStmt +== 593 +create table bool_rp_true_2k partition of bool_rp for values from (true,1000) to (true,2000) +-- +TABLE: name="bool_rp_true_2k" schema="" table="bool_rp_true_2k" ctx=DDL +STMT: CreateStmt +== 594 +create index on bool_rp (b,a) +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=DDL +STMT: IndexStmt +== 595 +explain (costs off) select * from bool_rp where b = true order by b,a +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 596 +explain (costs off) select * from bool_rp where b = false order by b,a +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 597 +explain (costs off) select * from bool_rp where b = true order by a +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 598 +explain (costs off) select * from bool_rp where b = false order by a +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 599 +drop table bool_rp +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=DDL +STMT: DropStmt +== 600 +-- Ensure an Append scan is chosen when the partition order is a subset of +-- the required order. +create table range_parted (a int, b int, c int) partition by range(a, b) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +== 601 +create table range_parted1 partition of range_parted for values from (0,0) to (10,10) +-- +TABLE: name="range_parted1" schema="" table="range_parted1" ctx=DDL +STMT: CreateStmt +== 602 +create table range_parted2 partition of range_parted for values from (10,10) to (20,20) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: CreateStmt +== 603 +create index on range_parted (a,b,c) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: IndexStmt +== 604 +explain (costs off) select * from range_parted order by a,b,c +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 605 +explain (costs off) select * from range_parted order by a desc,b desc,c desc +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 606 +drop table range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 607 +-- Check that we allow access to a child table's statistics when the user +-- has permissions only for the parent table. +create table permtest_parent (a int, b text, c text) partition by list (a) +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: CreateStmt +== 608 +create table permtest_child (b text, c text, a int) partition by list (b) +-- +TABLE: name="permtest_child" schema="" table="permtest_child" ctx=DDL +STMT: CreateStmt +== 609 +create table permtest_grandchild (c text, b text, a int) +-- +TABLE: name="permtest_grandchild" schema="" table="permtest_grandchild" ctx=DDL +STMT: CreateStmt +== 610 +alter table permtest_child attach partition permtest_grandchild for values in ('a') +-- +TABLE: name="permtest_child" schema="" table="permtest_child" ctx=DDL +STMT: AlterTableStmt +== 611 +alter table permtest_parent attach partition permtest_child for values in (1) +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: AlterTableStmt +== 612 +create index on permtest_parent (left(c, 3)) +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +FUNCTION: name="left" function="left" schema="" ctx=Call +STMT: IndexStmt +== 613 +insert into permtest_parent + select 1, 'a', left(fipshash(i::text), 5) from generate_series(0, 100) i +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DML +FUNCTION: name="left" function="left" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 614 +analyze permtest_parent +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: VacuumStmt +== 615 +create role regress_no_child_access +-- +STMT: CreateRoleStmt +== 616 +revoke all on permtest_grandchild from regress_no_child_access +-- +TABLE: name="permtest_grandchild" schema="" table="permtest_grandchild" ctx=DDL +STMT: GrantStmt +== 617 +grant select on permtest_parent to regress_no_child_access +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: GrantStmt +== 618 +set session authorization regress_no_child_access +-- +STMT: VariableSetStmt +== 619 +-- without stats access, these queries would produce hash join plans: +explain (costs off) + select * from permtest_parent p1 inner join permtest_parent p2 + on p1.a = p2.a and p1.c ~ 'a1$' +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +ALIAS: "p1"="permtest_parent" +ALIAS: "p2"="permtest_parent" +STMT: ExplainStmt +STMT: SelectStmt +== 620 +explain (costs off) + select * from permtest_parent p1 inner join permtest_parent p2 + on p1.a = p2.a and left(p1.c, 3) ~ 'a1$' +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +ALIAS: "p1"="permtest_parent" +ALIAS: "p2"="permtest_parent" +FUNCTION: name="left" function="left" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 621 +reset session authorization +-- +STMT: VariableSetStmt +== 622 +revoke all on permtest_parent from regress_no_child_access +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: GrantStmt +== 623 +grant select(a,c) on permtest_parent to regress_no_child_access +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: GrantStmt +== 624 +set session authorization regress_no_child_access +-- +STMT: VariableSetStmt +== 625 +explain (costs off) + select p2.a, p1.c from permtest_parent p1 inner join permtest_parent p2 + on p1.a = p2.a and p1.c ~ 'a1$' +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +ALIAS: "p1"="permtest_parent" +ALIAS: "p2"="permtest_parent" +STMT: ExplainStmt +STMT: SelectStmt +== 626 +-- we will not have access to the expression index's stats here: +explain (costs off) + select p2.a, p1.c from permtest_parent p1 inner join permtest_parent p2 + on p1.a = p2.a and left(p1.c, 3) ~ 'a1$' +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +ALIAS: "p1"="permtest_parent" +ALIAS: "p2"="permtest_parent" +FUNCTION: name="left" function="left" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 627 +reset session authorization +-- +STMT: VariableSetStmt +== 628 +revoke all on permtest_parent from regress_no_child_access +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: GrantStmt +== 629 +drop role regress_no_child_access +-- +STMT: DropRoleStmt +== 630 +drop table permtest_parent +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: DropStmt +== 631 +-- Verify that constraint errors across partition root / child are +-- handled correctly (Bug #16293) +CREATE TABLE errtst_parent ( + partid int not null, + shdata int not null, + data int NOT NULL DEFAULT 0, + CONSTRAINT shdata_small CHECK(shdata < 3) +) PARTITION BY RANGE (partid) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: CreateStmt +== 632 +-- fast defaults lead to attribute mapping being used in one +-- direction, but not the other +CREATE TABLE errtst_child_fastdef ( + partid int not null, + shdata int not null, + CONSTRAINT shdata_small CHECK(shdata < 3) +) +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DDL +STMT: CreateStmt +== 633 +-- no remapping in either direction necessary +CREATE TABLE errtst_child_plaindef ( + partid int not null, + shdata int not null, + data int NOT NULL DEFAULT 0, + CONSTRAINT shdata_small CHECK(shdata < 3), + CHECK(data < 10) +) +-- +TABLE: name="errtst_child_plaindef" schema="" table="errtst_child_plaindef" ctx=DDL +STMT: CreateStmt +== 634 +-- remapping in both direction +CREATE TABLE errtst_child_reorder ( + data int NOT NULL DEFAULT 0, + shdata int not null, + partid int not null, + CONSTRAINT shdata_small CHECK(shdata < 3), + CHECK(data < 10) +) +-- +TABLE: name="errtst_child_reorder" schema="" table="errtst_child_reorder" ctx=DDL +STMT: CreateStmt +== 635 +ALTER TABLE errtst_child_fastdef ADD COLUMN data int NOT NULL DEFAULT 0 +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DDL +STMT: AlterTableStmt +== 636 +ALTER TABLE errtst_child_fastdef ADD CONSTRAINT errtest_child_fastdef_data_check CHECK (data < 10) +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DDL +STMT: AlterTableStmt +== 637 +ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_fastdef FOR VALUES FROM (0) TO (10) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: AlterTableStmt +== 638 +ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_plaindef FOR VALUES FROM (10) TO (20) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: AlterTableStmt +== 639 +ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_reorder FOR VALUES FROM (20) TO (30) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: AlterTableStmt +== 640 +-- insert without child check constraint error +INSERT INTO errtst_parent(partid, shdata, data) VALUES ( '0', '1', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 641 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('10', '1', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 642 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('20', '1', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 643 +-- insert with child check constraint error +INSERT INTO errtst_parent(partid, shdata, data) VALUES ( '0', '1', '10') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 644 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('10', '1', '10') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 645 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('20', '1', '10') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 646 +-- insert with child not null constraint error +INSERT INTO errtst_parent(partid, shdata, data) VALUES ( '0', '1', NULL) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 647 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('10', '1', NULL) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 648 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('20', '1', NULL) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 649 +-- insert with shared check constraint error +INSERT INTO errtst_parent(partid, shdata, data) VALUES ( '0', '5', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 650 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('10', '5', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 651 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('20', '5', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 652 +-- within partition update without child check constraint violation +BEGIN +-- +STMT: TransactionStmt +== 653 +UPDATE errtst_parent SET data = data + 1 WHERE partid = 0 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 654 +UPDATE errtst_parent SET data = data + 1 WHERE partid = 10 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 655 +UPDATE errtst_parent SET data = data + 1 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 656 +ROLLBACK +-- +STMT: TransactionStmt +== 657 +-- within partition update with child check constraint violation +UPDATE errtst_parent SET data = data + 10 WHERE partid = 0 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 658 +UPDATE errtst_parent SET data = data + 10 WHERE partid = 10 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 659 +UPDATE errtst_parent SET data = data + 10 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 660 +-- direct leaf partition update, without partition id violation +BEGIN +-- +STMT: TransactionStmt +== 661 +UPDATE errtst_child_fastdef SET partid = 1 WHERE partid = 0 +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DML +STMT: UpdateStmt +== 662 +UPDATE errtst_child_plaindef SET partid = 11 WHERE partid = 10 +-- +TABLE: name="errtst_child_plaindef" schema="" table="errtst_child_plaindef" ctx=DML +STMT: UpdateStmt +== 663 +UPDATE errtst_child_reorder SET partid = 21 WHERE partid = 20 +-- +TABLE: name="errtst_child_reorder" schema="" table="errtst_child_reorder" ctx=DML +STMT: UpdateStmt +== 664 +ROLLBACK +-- +STMT: TransactionStmt +== 665 +-- direct leaf partition update, with partition id violation +UPDATE errtst_child_fastdef SET partid = partid + 10 WHERE partid = 0 +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DML +STMT: UpdateStmt +== 666 +UPDATE errtst_child_plaindef SET partid = partid + 10 WHERE partid = 10 +-- +TABLE: name="errtst_child_plaindef" schema="" table="errtst_child_plaindef" ctx=DML +STMT: UpdateStmt +== 667 +UPDATE errtst_child_reorder SET partid = partid + 10 WHERE partid = 20 +-- +TABLE: name="errtst_child_reorder" schema="" table="errtst_child_reorder" ctx=DML +STMT: UpdateStmt +== 668 +-- partition move, without child check constraint violation +BEGIN +-- +STMT: TransactionStmt +== 669 +UPDATE errtst_parent SET partid = 10, data = data + 1 WHERE partid = 0 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 670 +UPDATE errtst_parent SET partid = 20, data = data + 1 WHERE partid = 10 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 671 +UPDATE errtst_parent SET partid = 0, data = data + 1 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 672 +ROLLBACK +-- +STMT: TransactionStmt +== 673 +-- partition move, with child check constraint violation +UPDATE errtst_parent SET partid = 10, data = data + 10 WHERE partid = 0 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 674 +UPDATE errtst_parent SET partid = 20, data = data + 10 WHERE partid = 10 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 675 +UPDATE errtst_parent SET partid = 0, data = data + 10 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 676 +-- partition move, without target partition +UPDATE errtst_parent SET partid = 30, data = data + 10 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +== 677 +DROP TABLE errtst_parent +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/init_privs.metadata.json b/parser/testdata/summary/postgres_regress/init_privs.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/init_privs.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/init_privs.test b/parser/testdata/summary/postgres_regress/init_privs.test new file mode 100644 index 0000000..8710663 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/init_privs.test @@ -0,0 +1,25 @@ +== 001 +-- Test initial privileges + +-- There should always be some initial privileges, set up by initdb +SELECT count(*) > 0 FROM pg_init_privs +-- +TABLE: name="pg_init_privs" schema="" table="pg_init_privs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 002 +-- Intentionally include some non-initial privs for pg_dump to dump out +GRANT SELECT ON pg_proc TO CURRENT_USER +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=DDL +STMT: GrantStmt +== 003 +GRANT SELECT (prosrc) ON pg_proc TO CURRENT_USER +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=DDL +STMT: GrantStmt +== 004 +GRANT SELECT (rolname, rolsuper) ON pg_authid TO CURRENT_USER +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=DDL +STMT: GrantStmt diff --git a/parser/testdata/summary/postgres_regress/insert.metadata.json b/parser/testdata/summary/postgres_regress/insert.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/insert.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/insert.test b/parser/testdata/summary/postgres_regress/insert.test new file mode 100644 index 0000000..a27379a --- /dev/null +++ b/parser/testdata/summary/postgres_regress/insert.test @@ -0,0 +1,2298 @@ +== 001 +|-- +-- insert with DEFAULT in the target_list +|-- +create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DDL +STMT: CreateStmt +== 002 +insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +insert into inserttest (col2, col3) values (3, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +insert into inserttest values (DEFAULT, 5, 'test') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +insert into inserttest values (DEFAULT, 7) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +select * from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +STMT: SelectStmt +== 008 +|-- +-- insert with similar expression / target_list values (all fail) +|-- +insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +insert into inserttest (col1, col2, col3) values (1, 2) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +insert into inserttest (col1) values (1, 2) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +insert into inserttest (col1) values (DEFAULT, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +select * from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +STMT: SelectStmt +== 013 +|-- +-- VALUES test +|-- +insert into inserttest values(10, 20, '40'), (-1, 2, DEFAULT), + ((select 2), (select i from (values(3)) as foo (i)), 'values are fun!') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +select * from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +STMT: SelectStmt +== 015 +|-- +-- TOASTed value test +|-- +insert into inserttest values(30, 50, repeat('x', 10000)) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 016 +select col1, col2, char_length(col3) from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +== 017 +drop table inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DDL +STMT: DropStmt +== 018 +|-- +-- tuple larger than fillfactor +|-- +CREATE TABLE large_tuple_test (a int, b text) WITH (fillfactor = 10) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DDL +STMT: CreateStmt +== 019 +ALTER TABLE large_tuple_test ALTER COLUMN b SET STORAGE plain +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DDL +STMT: AlterTableStmt +== 020 +-- create page w/ free space in range [nearlyEmptyFreeSpace, MaxHeapTupleSize) +INSERT INTO large_tuple_test (select 1, NULL) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +-- should still fit on the page +INSERT INTO large_tuple_test (select 2, repeat('a', 1000)) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 022 +SELECT pg_size_pretty(pg_relation_size('large_tuple_test'::regclass, 'main')) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +== 023 +-- add small record to the second page +INSERT INTO large_tuple_test (select 3, NULL) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +-- now this tuple won't fit on the second page, but the insert should +-- still succeed by extending the relation +INSERT INTO large_tuple_test (select 4, repeat('a', 8126)) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 025 +DROP TABLE large_tuple_test +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DDL +STMT: DropStmt +== 026 +|-- +-- check indirection (field/array assignment), cf bug #14265 +|-- +-- these tests are aware that transformInsertStmt has 3 separate code paths +|-- + +create type insert_test_type as (if1 int, if2 text[]) +-- +STMT: CompositeTypeStmt +== 027 +create table inserttest (f1 int, f2 int[], + f3 insert_test_type, f4 insert_test_type[]) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DDL +STMT: CreateStmt +== 028 +insert into inserttest (f2[1], f2[2]) values (1,2) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +insert into inserttest (f2[1], f2[2]) values (3,4), (5,6) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +insert into inserttest (f2[1], f2[2]) select 7,8 +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +insert into inserttest (f2[1], f2[2]) values (1,default) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +-- not supported + +insert into inserttest (f3.if1, f3.if2) values (1,array['foo']) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +insert into inserttest (f3.if1, f3.if2) values (1,'{foo}'), (2,'{bar}') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +insert into inserttest (f3.if1, f3.if2) select 3, '{baz,quux}' +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +insert into inserttest (f3.if1, f3.if2) values (1,default) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +-- not supported + +insert into inserttest (f3.if2[1], f3.if2[2]) values ('foo', 'bar') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +insert into inserttest (f3.if2[1], f3.if2[2]) values ('foo', 'bar'), ('baz', 'quux') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +insert into inserttest (f3.if2[1], f3.if2[2]) select 'bear', 'beer' +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +insert into inserttest (f4[1].if2[1], f4[1].if2[2]) values ('foo', 'bar') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +insert into inserttest (f4[1].if2[1], f4[1].if2[2]) values ('foo', 'bar'), ('baz', 'quux') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +insert into inserttest (f4[1].if2[1], f4[1].if2[2]) select 'bear', 'beer' +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +select * from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +STMT: SelectStmt +== 043 +-- also check reverse-listing +create table inserttest2 (f1 bigint, f2 text) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: CreateStmt +== 044 +create rule irule1 as on insert to inserttest2 do also + insert into inserttest (f3.if2[1], f3.if2[2]) + values (new.f1,new.f2) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +== 045 +create rule irule2 as on insert to inserttest2 do also + insert into inserttest (f4[1].if1, f4[1].if2[2]) + values (1,'fool'),(new.f1,new.f2) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +== 046 +create rule irule3 as on insert to inserttest2 do also + insert into inserttest (f4[1].if1, f4[1].if2[2]) + select new.f1, new.f2 +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +== 047 +drop table inserttest2 +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: DropStmt +== 048 +drop table inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DDL +STMT: DropStmt +== 049 +-- Make the same tests with domains over the array and composite fields + +create domain insert_pos_ints as int[] check (value[1] > 0) +-- +STMT: CreateDomainStmt +== 050 +create domain insert_test_domain as insert_test_type + check ((value).if2[1] is not null) +-- +STMT: CreateDomainStmt +== 051 +create table inserttesta (f1 int, f2 insert_pos_ints) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DDL +STMT: CreateStmt +== 052 +create table inserttestb (f3 insert_test_domain, f4 insert_test_domain[]) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DDL +STMT: CreateStmt +== 053 +insert into inserttesta (f2[1], f2[2]) values (1,2) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +insert into inserttesta (f2[1], f2[2]) values (3,4), (5,6) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +insert into inserttesta (f2[1], f2[2]) select 7,8 +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +insert into inserttesta (f2[1], f2[2]) values (1,default) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +-- not supported +insert into inserttesta (f2[1], f2[2]) values (0,2) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +insert into inserttesta (f2[1], f2[2]) values (3,4), (0,6) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +insert into inserttesta (f2[1], f2[2]) select 0,8 +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +insert into inserttestb (f3.if1, f3.if2) values (1,array['foo']) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +insert into inserttestb (f3.if1, f3.if2) values (1,'{foo}'), (2,'{bar}') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +insert into inserttestb (f3.if1, f3.if2) select 3, '{baz,quux}' +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +insert into inserttestb (f3.if1, f3.if2) values (1,default) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +-- not supported +insert into inserttestb (f3.if1, f3.if2) values (1,array[null]) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +insert into inserttestb (f3.if1, f3.if2) values (1,'{null}'), (2,'{bar}') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 066 +insert into inserttestb (f3.if1, f3.if2) select 3, '{null,quux}' +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +insert into inserttestb (f3.if2[1], f3.if2[2]) values ('foo', 'bar') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 068 +insert into inserttestb (f3.if2[1], f3.if2[2]) values ('foo', 'bar'), ('baz', 'quux') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 069 +insert into inserttestb (f3.if2[1], f3.if2[2]) select 'bear', 'beer' +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +insert into inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) values (row(1,'{x}'), 'foo', 'bar') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +insert into inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) values (row(1,'{x}'), 'foo', 'bar'), (row(2,'{y}'), 'baz', 'quux') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +insert into inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) select row(1,'{x}')::insert_test_domain, 'bear', 'beer' +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +select * from inserttesta +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=Select +STMT: SelectStmt +== 074 +select * from inserttestb +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=Select +STMT: SelectStmt +== 075 +-- also check reverse-listing +create table inserttest2 (f1 bigint, f2 text) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: CreateStmt +== 076 +create rule irule1 as on insert to inserttest2 do also + insert into inserttestb (f3.if2[1], f3.if2[2]) + values (new.f1,new.f2) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +== 077 +create rule irule2 as on insert to inserttest2 do also + insert into inserttestb (f4[1].if1, f4[1].if2[2]) + values (1,'fool'),(new.f1,new.f2) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +== 078 +create rule irule3 as on insert to inserttest2 do also + insert into inserttestb (f4[1].if1, f4[1].if2[2]) + select new.f1, new.f2 +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +== 079 +drop table inserttest2 +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: DropStmt +== 080 +drop table inserttesta +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DDL +STMT: DropStmt +== 081 +drop table inserttestb +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DDL +STMT: DropStmt +== 082 +drop domain insert_pos_ints +-- +STMT: DropStmt +== 083 +drop domain insert_test_domain +-- +STMT: DropStmt +== 084 +-- Verify that multiple inserts to subfields of a domain-over-container +-- check the domain constraints only on the finished value + +create domain insert_nnarray as int[] + check (value[1] is not null and value[2] is not null) +-- +STMT: CreateDomainStmt +== 085 +create domain insert_test_domain as insert_test_type + check ((value).if1 is not null and (value).if2 is not null) +-- +STMT: CreateDomainStmt +== 086 +create table inserttesta (f1 insert_nnarray) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DDL +STMT: CreateStmt +== 087 +insert into inserttesta (f1[1]) values (1) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +-- fail +insert into inserttesta (f1[1], f1[2]) values (1, 2) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +create table inserttestb (f1 insert_test_domain) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DDL +STMT: CreateStmt +== 090 +insert into inserttestb (f1.if1) values (1) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 091 +-- fail +insert into inserttestb (f1.if1, f1.if2) values (1, '{foo}') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +drop table inserttesta +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DDL +STMT: DropStmt +== 093 +drop table inserttestb +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DDL +STMT: DropStmt +== 094 +drop domain insert_nnarray +-- +STMT: DropStmt +== 095 +drop type insert_test_type cascade +-- +STMT: DropStmt +== 096 +-- direct partition inserts should check partition bound constraint +create table range_parted ( + a text, + b int +) partition by range (a, (b+0)) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +== 097 +-- no partitions, so fail +insert into range_parted values ('a', 11) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +create table part1 partition of range_parted for values from ('a', 1) to ('a', 10) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +== 099 +create table part2 partition of range_parted for values from ('a', 10) to ('a', 20) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +== 100 +create table part3 partition of range_parted for values from ('b', 1) to ('b', 10) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +== 101 +create table part4 partition of range_parted for values from ('b', 10) to ('b', 20) +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: CreateStmt +== 102 +-- fail +insert into part1 values ('a', 11) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +insert into part1 values ('b', 1) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +-- ok +insert into part1 values ('a', 1) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +-- fail +insert into part4 values ('b', 21) +-- +TABLE: name="part4" schema="" table="part4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 106 +insert into part4 values ('a', 10) +-- +TABLE: name="part4" schema="" table="part4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +-- ok +insert into part4 values ('b', 10) +-- +TABLE: name="part4" schema="" table="part4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +-- fail (partition key a has a NOT NULL constraint) +insert into part1 values (null) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +-- fail (expression key (b+0) cannot be null either) +insert into part1 values (1) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +create table list_parted ( + a text, + b int +) partition by list (lower(a)) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +== 111 +create table part_aa_bb partition of list_parted FOR VALUES IN ('aa', 'bb') +-- +TABLE: name="part_aa_bb" schema="" table="part_aa_bb" ctx=DDL +STMT: CreateStmt +== 112 +create table part_cc_dd partition of list_parted FOR VALUES IN ('cc', 'dd') +-- +TABLE: name="part_cc_dd" schema="" table="part_cc_dd" ctx=DDL +STMT: CreateStmt +== 113 +create table part_null partition of list_parted FOR VALUES IN (null) +-- +TABLE: name="part_null" schema="" table="part_null" ctx=DDL +STMT: CreateStmt +== 114 +-- fail +insert into part_aa_bb values ('cc', 1) +-- +TABLE: name="part_aa_bb" schema="" table="part_aa_bb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +insert into part_aa_bb values ('AAa', 1) +-- +TABLE: name="part_aa_bb" schema="" table="part_aa_bb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +insert into part_aa_bb values (null) +-- +TABLE: name="part_aa_bb" schema="" table="part_aa_bb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +-- ok +insert into part_cc_dd values ('cC', 1) +-- +TABLE: name="part_cc_dd" schema="" table="part_cc_dd" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 118 +insert into part_null values (null, 0) +-- +TABLE: name="part_null" schema="" table="part_null" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 119 +-- check in case of multi-level partitioned table +create table part_ee_ff partition of list_parted for values in ('ee', 'ff') partition by range (b) +-- +TABLE: name="part_ee_ff" schema="" table="part_ee_ff" ctx=DDL +STMT: CreateStmt +== 120 +create table part_ee_ff1 partition of part_ee_ff for values from (1) to (10) +-- +TABLE: name="part_ee_ff1" schema="" table="part_ee_ff1" ctx=DDL +STMT: CreateStmt +== 121 +create table part_ee_ff2 partition of part_ee_ff for values from (10) to (20) +-- +TABLE: name="part_ee_ff2" schema="" table="part_ee_ff2" ctx=DDL +STMT: CreateStmt +== 122 +-- test default partition +create table part_default partition of list_parted default +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: CreateStmt +== 123 +-- Negative test: a row, which would fit in other partition, does not fit +-- default partition, even when inserted directly +insert into part_default values ('aa', 2) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 124 +insert into part_default values (null, 2) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 125 +-- ok +insert into part_default values ('Zz', 2) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 126 +-- test if default partition works as expected for multi-level partitioned +-- table as well as when default partition itself is further partitioned +drop table part_default +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: DropStmt +== 127 +create table part_xx_yy partition of list_parted for values in ('xx', 'yy') partition by list (a) +-- +TABLE: name="part_xx_yy" schema="" table="part_xx_yy" ctx=DDL +STMT: CreateStmt +== 128 +create table part_xx_yy_p1 partition of part_xx_yy for values in ('xx') +-- +TABLE: name="part_xx_yy_p1" schema="" table="part_xx_yy_p1" ctx=DDL +STMT: CreateStmt +== 129 +create table part_xx_yy_defpart partition of part_xx_yy default +-- +TABLE: name="part_xx_yy_defpart" schema="" table="part_xx_yy_defpart" ctx=DDL +STMT: CreateStmt +== 130 +create table part_default partition of list_parted default partition by range(b) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: CreateStmt +== 131 +create table part_default_p1 partition of part_default for values from (20) to (30) +-- +TABLE: name="part_default_p1" schema="" table="part_default_p1" ctx=DDL +STMT: CreateStmt +== 132 +create table part_default_p2 partition of part_default for values from (30) to (40) +-- +TABLE: name="part_default_p2" schema="" table="part_default_p2" ctx=DDL +STMT: CreateStmt +== 133 +-- fail +insert into part_ee_ff1 values ('EE', 11) +-- +TABLE: name="part_ee_ff1" schema="" table="part_ee_ff1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 134 +insert into part_default_p2 values ('gg', 43) +-- +TABLE: name="part_default_p2" schema="" table="part_default_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 135 +-- fail (even the parent's, ie, part_ee_ff's partition constraint applies) +insert into part_ee_ff1 values ('cc', 1) +-- +TABLE: name="part_ee_ff1" schema="" table="part_ee_ff1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +insert into part_default values ('gg', 43) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +-- ok +insert into part_ee_ff1 values ('ff', 1) +-- +TABLE: name="part_ee_ff1" schema="" table="part_ee_ff1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +insert into part_ee_ff2 values ('ff', 11) +-- +TABLE: name="part_ee_ff2" schema="" table="part_ee_ff2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +insert into part_default_p1 values ('cd', 25) +-- +TABLE: name="part_default_p1" schema="" table="part_default_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 140 +insert into part_default_p2 values ('de', 35) +-- +TABLE: name="part_default_p2" schema="" table="part_default_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 141 +insert into list_parted values ('ab', 21) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +insert into list_parted values ('xx', 1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +insert into list_parted values ('yy', 2) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +select tableoid::regclass, * from list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 145 +-- Check tuple routing for partitioned tables + +-- fail +insert into range_parted values ('a', 0) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +-- ok +insert into range_parted values ('a', 1) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +insert into range_parted values ('a', 10) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 148 +-- fail +insert into range_parted values ('a', 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 149 +-- ok +insert into range_parted values ('b', 1) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +insert into range_parted values ('b', 10) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 151 +-- fail (partition key (b+0) is null) +insert into range_parted values ('a') +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +-- Check default partition +create table part_def partition of range_parted default +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DDL +STMT: CreateStmt +== 153 +-- fail +insert into part_def values ('b', 10) +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 154 +-- ok +insert into part_def values ('c', 10) +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +insert into range_parted values (null, null) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 156 +insert into range_parted values ('a', null) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 157 +insert into range_parted values (null, 19) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 158 +insert into range_parted values ('b', 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 159 +select tableoid::regclass, * from range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=Select +STMT: SelectStmt +== 160 +-- ok +insert into list_parted values (null, 1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 161 +insert into list_parted (a) values ('aA') +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 162 +-- fail (partition of part_ee_ff not found in both cases) +insert into list_parted values ('EE', 0) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 163 +insert into part_ee_ff values ('EE', 0) +-- +TABLE: name="part_ee_ff" schema="" table="part_ee_ff" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +-- ok +insert into list_parted values ('EE', 1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 165 +insert into part_ee_ff values ('EE', 10) +-- +TABLE: name="part_ee_ff" schema="" table="part_ee_ff" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 166 +select tableoid::regclass, * from list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 167 +-- some more tests to exercise tuple-routing with multi-level partitioning +create table part_gg partition of list_parted for values in ('gg') partition by range (b) +-- +TABLE: name="part_gg" schema="" table="part_gg" ctx=DDL +STMT: CreateStmt +== 168 +create table part_gg1 partition of part_gg for values from (minvalue) to (1) +-- +TABLE: name="part_gg1" schema="" table="part_gg1" ctx=DDL +STMT: CreateStmt +== 169 +create table part_gg2 partition of part_gg for values from (1) to (10) partition by range (b) +-- +TABLE: name="part_gg2" schema="" table="part_gg2" ctx=DDL +STMT: CreateStmt +== 170 +create table part_gg2_1 partition of part_gg2 for values from (1) to (5) +-- +TABLE: name="part_gg2_1" schema="" table="part_gg2_1" ctx=DDL +STMT: CreateStmt +== 171 +create table part_gg2_2 partition of part_gg2 for values from (5) to (10) +-- +TABLE: name="part_gg2_2" schema="" table="part_gg2_2" ctx=DDL +STMT: CreateStmt +== 172 +create table part_ee_ff3 partition of part_ee_ff for values from (20) to (30) partition by range (b) +-- +TABLE: name="part_ee_ff3" schema="" table="part_ee_ff3" ctx=DDL +STMT: CreateStmt +== 173 +create table part_ee_ff3_1 partition of part_ee_ff3 for values from (20) to (25) +-- +TABLE: name="part_ee_ff3_1" schema="" table="part_ee_ff3_1" ctx=DDL +STMT: CreateStmt +== 174 +create table part_ee_ff3_2 partition of part_ee_ff3 for values from (25) to (30) +-- +TABLE: name="part_ee_ff3_2" schema="" table="part_ee_ff3_2" ctx=DDL +STMT: CreateStmt +== 175 +truncate list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: TruncateStmt +== 176 +insert into list_parted values ('aa'), ('cc') +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 177 +insert into list_parted select 'Ff', s.a from generate_series(1, 29) s(a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 178 +insert into list_parted select 'gg', s.a from generate_series(1, 9) s(a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 179 +insert into list_parted (b) values (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 180 +select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_parted group by 1, 2 order by 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 181 +-- direct partition inserts should check hash partition bound constraint + +create table hash_parted ( + a int +) partition by hash (a part_test_int4_ops) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: CreateStmt +== 182 +create table hpart0 partition of hash_parted for values with (modulus 4, remainder 0) +-- +TABLE: name="hpart0" schema="" table="hpart0" ctx=DDL +STMT: CreateStmt +== 183 +create table hpart1 partition of hash_parted for values with (modulus 4, remainder 1) +-- +TABLE: name="hpart1" schema="" table="hpart1" ctx=DDL +STMT: CreateStmt +== 184 +create table hpart2 partition of hash_parted for values with (modulus 4, remainder 2) +-- +TABLE: name="hpart2" schema="" table="hpart2" ctx=DDL +STMT: CreateStmt +== 185 +create table hpart3 partition of hash_parted for values with (modulus 4, remainder 3) +-- +TABLE: name="hpart3" schema="" table="hpart3" ctx=DDL +STMT: CreateStmt +== 186 +insert into hash_parted values(generate_series(1,10)) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 187 +-- direct insert of values divisible by 4 - ok; +insert into hpart0 values(12),(16) +-- +TABLE: name="hpart0" schema="" table="hpart0" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +-- fail; +insert into hpart0 values(11) +-- +TABLE: name="hpart0" schema="" table="hpart0" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +-- 11 % 4 -> 3 remainder i.e. valid data for hpart3 partition +insert into hpart3 values(11) +-- +TABLE: name="hpart3" schema="" table="hpart3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +-- view data +select tableoid::regclass as part, a, a%4 as "remainder = a % 4" +from hash_parted order by part +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=Select +STMT: SelectStmt +== 191 +-- test \d+ output on a table which has both partitioned and unpartitioned +-- partitions + +-- cleanup +drop table range_parted, list_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +== 192 +drop table hash_parted +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: DropStmt +== 193 +-- test that a default partition added as the first partition accepts any value +-- including null +create table list_parted (a int) partition by list (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +== 194 +create table part_default partition of list_parted default +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: CreateStmt +== 195 +insert into part_default values (null) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +insert into part_default values (1) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 197 +insert into part_default values (-1) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 198 +select tableoid::regclass, a from list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 199 +-- cleanup +drop table list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +== 200 +-- more tests for certain multi-level partitioning scenarios +create table mlparted (a int, b int) partition by range (a, b) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: CreateStmt +== 201 +create table mlparted1 (b int not null, a int not null) partition by range ((b+0)) +-- +TABLE: name="mlparted1" schema="" table="mlparted1" ctx=DDL +STMT: CreateStmt +== 202 +create table mlparted11 (like mlparted1) +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: CreateStmt +== 203 +alter table mlparted11 drop a +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: AlterTableStmt +== 204 +alter table mlparted11 add a int +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: AlterTableStmt +== 205 +alter table mlparted11 drop a +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: AlterTableStmt +== 206 +alter table mlparted11 add a int not null +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: AlterTableStmt +== 207 +-- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11 +select attrelid::regclass, attname, attnum +from pg_attribute +where attname = 'a' + and (attrelid = 'mlparted'::regclass + or attrelid = 'mlparted1'::regclass + or attrelid = 'mlparted11'::regclass) +order by attrelid::regclass::text +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attname" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +== 208 +alter table mlparted1 attach partition mlparted11 for values from (2) to (5) +-- +TABLE: name="mlparted1" schema="" table="mlparted1" ctx=DDL +STMT: AlterTableStmt +== 209 +alter table mlparted attach partition mlparted1 for values from (1, 2) to (1, 10) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 210 +-- check that "(1, 2)" is correctly routed to mlparted11. +insert into mlparted values (1, 2) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 211 +select tableoid::regclass, * from mlparted +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=Select +STMT: SelectStmt +== 212 +-- check that proper message is shown after failure to route through mlparted1 +insert into mlparted (a, b) values (1, 5) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 213 +truncate mlparted +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: TruncateStmt +== 214 +alter table mlparted add constraint check_b check (b = 3) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 215 +-- have a BR trigger modify the row such that the check_b is violated +create function mlparted11_trig_fn() +returns trigger AS +$$ +begin + NEW.b := 4; + return NEW; +end; +$$ +language plpgsql +-- +FUNCTION: name="mlparted11_trig_fn" function="mlparted11_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 216 +create trigger mlparted11_trig before insert ON mlparted11 + for each row execute procedure mlparted11_trig_fn() +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: CreateTrigStmt +== 217 +-- check that the correct row is shown when constraint check_b fails after +-- "(1, 2)" is routed to mlparted11 (actually "(1, 4)" would be shown due +-- to the BR trigger mlparted11_trig_fn) +insert into mlparted values (1, 2) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 218 +drop trigger mlparted11_trig on mlparted11 +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: DropStmt +== 219 +drop function mlparted11_trig_fn() +-- +FUNCTION: name="mlparted11_trig_fn" function="mlparted11_trig_fn" schema="" ctx=DDL +STMT: DropStmt +== 220 +-- check that inserting into an internal partition successfully results in +-- checking its partition constraint before inserting into the leaf partition +-- selected by tuple-routing +insert into mlparted1 (a, b) values (2, 3) +-- +TABLE: name="mlparted1" schema="" table="mlparted1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 221 +-- check routing error through a list partitioned table when the key is null +create table lparted_nonullpart (a int, b char) partition by list (b) +-- +TABLE: name="lparted_nonullpart" schema="" table="lparted_nonullpart" ctx=DDL +STMT: CreateStmt +== 222 +create table lparted_nonullpart_a partition of lparted_nonullpart for values in ('a') +-- +TABLE: name="lparted_nonullpart_a" schema="" table="lparted_nonullpart_a" ctx=DDL +STMT: CreateStmt +== 223 +insert into lparted_nonullpart values (1) +-- +TABLE: name="lparted_nonullpart" schema="" table="lparted_nonullpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 224 +drop table lparted_nonullpart +-- +TABLE: name="lparted_nonullpart" schema="" table="lparted_nonullpart" ctx=DDL +STMT: DropStmt +== 225 +-- check that RETURNING works correctly with tuple-routing +alter table mlparted drop constraint check_b +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 226 +create table mlparted12 partition of mlparted1 for values from (5) to (10) +-- +TABLE: name="mlparted12" schema="" table="mlparted12" ctx=DDL +STMT: CreateStmt +== 227 +create table mlparted2 (b int not null, a int not null) +-- +TABLE: name="mlparted2" schema="" table="mlparted2" ctx=DDL +STMT: CreateStmt +== 228 +alter table mlparted attach partition mlparted2 for values from (1, 10) to (1, 20) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 229 +create table mlparted3 partition of mlparted for values from (1, 20) to (1, 30) +-- +TABLE: name="mlparted3" schema="" table="mlparted3" ctx=DDL +STMT: CreateStmt +== 230 +create table mlparted4 (like mlparted) +-- +TABLE: name="mlparted4" schema="" table="mlparted4" ctx=DDL +STMT: CreateStmt +== 231 +alter table mlparted4 drop a +-- +TABLE: name="mlparted4" schema="" table="mlparted4" ctx=DDL +STMT: AlterTableStmt +== 232 +alter table mlparted4 add a int not null +-- +TABLE: name="mlparted4" schema="" table="mlparted4" ctx=DDL +STMT: AlterTableStmt +== 233 +alter table mlparted attach partition mlparted4 for values from (1, 30) to (1, 40) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 234 +with ins (a, b, c) as + (insert into mlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *) + select a, b, min(c), max(c) from ins group by a, b order by 1 +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +CTE: "ins" +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +STMT: InsertStmt +== 235 +alter table mlparted add c text +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 236 +create table mlparted5 (c text, a int not null, b int not null) partition by list (c) +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: CreateStmt +== 237 +create table mlparted5a (a int not null, c text, b int not null) +-- +TABLE: name="mlparted5a" schema="" table="mlparted5a" ctx=DDL +STMT: CreateStmt +== 238 +alter table mlparted5 attach partition mlparted5a for values in ('a') +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: AlterTableStmt +== 239 +alter table mlparted attach partition mlparted5 for values from (1, 40) to (1, 50) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 240 +alter table mlparted add constraint check_b check (a = 1 and b < 45) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 241 +insert into mlparted values (1, 45, 'a') +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 242 +create function mlparted5abrtrig_func() returns trigger as $$ begin new.c = 'b'; return new; end; $$ language plpgsql +-- +FUNCTION: name="mlparted5abrtrig_func" function="mlparted5abrtrig_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 243 +create trigger mlparted5abrtrig before insert on mlparted5a for each row execute procedure mlparted5abrtrig_func() +-- +TABLE: name="mlparted5a" schema="" table="mlparted5a" ctx=DDL +STMT: CreateTrigStmt +== 244 +insert into mlparted5 (a, b, c) values (1, 40, 'a') +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +drop table mlparted5 +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: DropStmt +== 246 +alter table mlparted drop constraint check_b +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 247 +-- Check multi-level default partition +create table mlparted_def partition of mlparted default partition by range(a) +-- +TABLE: name="mlparted_def" schema="" table="mlparted_def" ctx=DDL +STMT: CreateStmt +== 248 +create table mlparted_def1 partition of mlparted_def for values from (40) to (50) +-- +TABLE: name="mlparted_def1" schema="" table="mlparted_def1" ctx=DDL +STMT: CreateStmt +== 249 +create table mlparted_def2 partition of mlparted_def for values from (50) to (60) +-- +TABLE: name="mlparted_def2" schema="" table="mlparted_def2" ctx=DDL +STMT: CreateStmt +== 250 +insert into mlparted values (40, 100) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 251 +insert into mlparted_def1 values (42, 100) +-- +TABLE: name="mlparted_def1" schema="" table="mlparted_def1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 252 +insert into mlparted_def2 values (54, 50) +-- +TABLE: name="mlparted_def2" schema="" table="mlparted_def2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +-- fail +insert into mlparted values (70, 100) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 254 +insert into mlparted_def1 values (52, 50) +-- +TABLE: name="mlparted_def1" schema="" table="mlparted_def1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 255 +insert into mlparted_def2 values (34, 50) +-- +TABLE: name="mlparted_def2" schema="" table="mlparted_def2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 256 +-- ok +create table mlparted_defd partition of mlparted_def default +-- +TABLE: name="mlparted_defd" schema="" table="mlparted_defd" ctx=DDL +STMT: CreateStmt +== 257 +insert into mlparted values (70, 100) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 258 +select tableoid::regclass, * from mlparted_def +-- +TABLE: name="mlparted_def" schema="" table="mlparted_def" ctx=Select +STMT: SelectStmt +== 259 +-- Check multi-level tuple routing with attributes dropped from the +-- top-most parent. First remove the last attribute. +alter table mlparted add d int, add e int +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 260 +alter table mlparted drop e +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 261 +create table mlparted5 partition of mlparted + for values from (1, 40) to (1, 50) partition by range (c) +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: CreateStmt +== 262 +create table mlparted5_ab partition of mlparted5 + for values from ('a') to ('c') partition by list (c) +-- +TABLE: name="mlparted5_ab" schema="" table="mlparted5_ab" ctx=DDL +STMT: CreateStmt +== 263 +-- This partitioned table should remain with no partitions. +create table mlparted5_cd partition of mlparted5 + for values from ('c') to ('e') partition by list (c) +-- +TABLE: name="mlparted5_cd" schema="" table="mlparted5_cd" ctx=DDL +STMT: CreateStmt +== 264 +create table mlparted5_a partition of mlparted5_ab for values in ('a') +-- +TABLE: name="mlparted5_a" schema="" table="mlparted5_a" ctx=DDL +STMT: CreateStmt +== 265 +create table mlparted5_b (d int, b int, c text, a int) +-- +TABLE: name="mlparted5_b" schema="" table="mlparted5_b" ctx=DDL +STMT: CreateStmt +== 266 +alter table mlparted5_ab attach partition mlparted5_b for values in ('b') +-- +TABLE: name="mlparted5_ab" schema="" table="mlparted5_ab" ctx=DDL +STMT: AlterTableStmt +== 267 +truncate mlparted +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: TruncateStmt +== 268 +insert into mlparted values (1, 2, 'a', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +insert into mlparted values (1, 40, 'a', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 270 +-- goes to mlparted5_a +insert into mlparted values (1, 45, 'b', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 271 +-- goes to mlparted5_b +insert into mlparted values (1, 45, 'c', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 272 +-- goes to mlparted5_cd, fails +insert into mlparted values (1, 45, 'f', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 273 +-- goes to mlparted5, fails +select tableoid::regclass, * from mlparted order by a, b, c, d +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=Select +STMT: SelectStmt +== 274 +alter table mlparted drop d +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 275 +truncate mlparted +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: TruncateStmt +== 276 +-- Remove the before last attribute. +alter table mlparted add e int, add d int +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 277 +alter table mlparted drop e +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 278 +insert into mlparted values (1, 2, 'a', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 279 +insert into mlparted values (1, 40, 'a', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 280 +-- goes to mlparted5_a +insert into mlparted values (1, 45, 'b', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 281 +-- goes to mlparted5_b +insert into mlparted values (1, 45, 'c', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 282 +-- goes to mlparted5_cd, fails +insert into mlparted values (1, 45, 'f', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 283 +-- goes to mlparted5, fails +select tableoid::regclass, * from mlparted order by a, b, c, d +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=Select +STMT: SelectStmt +== 284 +alter table mlparted drop d +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +== 285 +drop table mlparted5 +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: DropStmt +== 286 +-- check that message shown after failure to find a partition shows the +-- appropriate key description (or none) in various situations +create table key_desc (a int, b int) partition by list ((a+0)) +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DDL +STMT: CreateStmt +== 287 +create table key_desc_1 partition of key_desc for values in (1) partition by range (b) +-- +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: CreateStmt +== 288 +create user regress_insert_other_user +-- +STMT: CreateRoleStmt +== 289 +grant select (a) on key_desc_1 to regress_insert_other_user +-- +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: GrantStmt +== 290 +grant insert on key_desc to regress_insert_other_user +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DDL +STMT: GrantStmt +== 291 +set role regress_insert_other_user +-- +STMT: VariableSetStmt +== 292 +-- no key description is shown +insert into key_desc values (1, 1) +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +reset role +-- +STMT: VariableSetStmt +== 294 +grant select (b) on key_desc_1 to regress_insert_other_user +-- +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: GrantStmt +== 295 +set role regress_insert_other_user +-- +STMT: VariableSetStmt +== 296 +-- key description (b)=(1) is now shown +insert into key_desc values (1, 1) +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 297 +-- key description is not shown if key contains expression +insert into key_desc values (2, 1) +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 298 +reset role +-- +STMT: VariableSetStmt +== 299 +revoke all on key_desc from regress_insert_other_user +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DDL +STMT: GrantStmt +== 300 +revoke all on key_desc_1 from regress_insert_other_user +-- +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: GrantStmt +== 301 +drop role regress_insert_other_user +-- +STMT: DropRoleStmt +== 302 +drop table key_desc, key_desc_1 +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DDL +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: DropStmt +== 303 +-- test minvalue/maxvalue restrictions +create table mcrparted (a int, b int, c int) partition by range (a, abs(b), c) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: CreateStmt +== 304 +create table mcrparted0 partition of mcrparted for values from (minvalue, 0, 0) to (1, maxvalue, maxvalue) +-- +TABLE: name="mcrparted0" schema="" table="mcrparted0" ctx=DDL +STMT: CreateStmt +== 305 +create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue) to (10, maxvalue, minvalue) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DDL +STMT: CreateStmt +== 306 +create table mcrparted4 partition of mcrparted for values from (21, minvalue, 0) to (30, 20, minvalue) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DDL +STMT: CreateStmt +== 307 +-- check multi-column range partitioning expression enforces the same +-- constraint as what tuple-routing would determine it to be +create table mcrparted0 partition of mcrparted for values from (minvalue, minvalue, minvalue) to (1, maxvalue, maxvalue) +-- +TABLE: name="mcrparted0" schema="" table="mcrparted0" ctx=DDL +STMT: CreateStmt +== 308 +create table mcrparted1 partition of mcrparted for values from (2, 1, minvalue) to (10, 5, 10) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DDL +STMT: CreateStmt +== 309 +create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue) to (10, maxvalue, maxvalue) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DDL +STMT: CreateStmt +== 310 +create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20, 10, 10) +-- +TABLE: name="mcrparted3" schema="" table="mcrparted3" ctx=DDL +STMT: CreateStmt +== 311 +create table mcrparted4 partition of mcrparted for values from (21, minvalue, minvalue) to (30, 20, maxvalue) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DDL +STMT: CreateStmt +== 312 +create table mcrparted5 partition of mcrparted for values from (30, 21, 20) to (maxvalue, maxvalue, maxvalue) +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DDL +STMT: CreateStmt +== 313 +-- null not allowed in range partition +insert into mcrparted values (null, null, null) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 314 +-- routed to mcrparted0 +insert into mcrparted values (0, 1, 1) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 315 +insert into mcrparted0 values (0, 1, 1) +-- +TABLE: name="mcrparted0" schema="" table="mcrparted0" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 316 +-- routed to mcparted1 +insert into mcrparted values (9, 1000, 1) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 317 +insert into mcrparted1 values (9, 1000, 1) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 318 +insert into mcrparted values (10, 5, -1) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 319 +insert into mcrparted1 values (10, 5, -1) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 320 +insert into mcrparted values (2, 1, 0) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 321 +insert into mcrparted1 values (2, 1, 0) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 322 +-- routed to mcparted2 +insert into mcrparted values (10, 6, 1000) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 323 +insert into mcrparted2 values (10, 6, 1000) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 324 +insert into mcrparted values (10, 1000, 1000) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 325 +insert into mcrparted2 values (10, 1000, 1000) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 326 +-- no partition exists, nor does mcrparted3 accept it +insert into mcrparted values (11, 1, -1) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 327 +insert into mcrparted3 values (11, 1, -1) +-- +TABLE: name="mcrparted3" schema="" table="mcrparted3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 328 +-- routed to mcrparted5 +insert into mcrparted values (30, 21, 20) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 329 +insert into mcrparted5 values (30, 21, 20) +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 330 +insert into mcrparted4 values (30, 21, 20) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 331 +-- error + +-- check rows +select tableoid::regclass::text, * from mcrparted order by 1 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +STMT: SelectStmt +== 332 +-- cleanup +drop table mcrparted +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: DropStmt +== 333 +-- check that a BR constraint can't make partition contain violating rows +create table brtrigpartcon (a int, b text) partition by list (a) +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: CreateStmt +== 334 +create table brtrigpartcon1 partition of brtrigpartcon for values in (1) +-- +TABLE: name="brtrigpartcon1" schema="" table="brtrigpartcon1" ctx=DDL +STMT: CreateStmt +== 335 +create or replace function brtrigpartcon1trigf() returns trigger as $$begin new.a := 2; return new; end$$ language plpgsql +-- +FUNCTION: name="brtrigpartcon1trigf" function="brtrigpartcon1trigf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 336 +create trigger brtrigpartcon1trig before insert on brtrigpartcon1 for each row execute procedure brtrigpartcon1trigf() +-- +TABLE: name="brtrigpartcon1" schema="" table="brtrigpartcon1" ctx=DDL +STMT: CreateTrigStmt +== 337 +insert into brtrigpartcon values (1, 'hi there') +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 338 +insert into brtrigpartcon1 values (1, 'hi there') +-- +TABLE: name="brtrigpartcon1" schema="" table="brtrigpartcon1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 339 +-- check that the message shows the appropriate column description in a +-- situation where the partitioned table is not the primary ModifyTable node +create table inserttest3 (f1 text default 'foo', f2 text default 'bar', f3 int) +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DDL +STMT: CreateStmt +== 340 +create role regress_coldesc_role +-- +STMT: CreateRoleStmt +== 341 +grant insert on inserttest3 to regress_coldesc_role +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DDL +STMT: GrantStmt +== 342 +grant insert on brtrigpartcon to regress_coldesc_role +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: GrantStmt +== 343 +revoke select on brtrigpartcon from regress_coldesc_role +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: GrantStmt +== 344 +set role regress_coldesc_role +-- +STMT: VariableSetStmt +== 345 +with result as (insert into brtrigpartcon values (1, 'hi there') returning 1) + insert into inserttest3 (f3) select * from result +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DML +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DML +CTE: "result" +STMT: InsertStmt +STMT: SelectStmt +== 346 +reset role +-- +STMT: VariableSetStmt +== 347 +-- cleanup +revoke all on inserttest3 from regress_coldesc_role +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DDL +STMT: GrantStmt +== 348 +revoke all on brtrigpartcon from regress_coldesc_role +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: GrantStmt +== 349 +drop role regress_coldesc_role +-- +STMT: DropRoleStmt +== 350 +drop table inserttest3 +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DDL +STMT: DropStmt +== 351 +drop table brtrigpartcon +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: DropStmt +== 352 +drop function brtrigpartcon1trigf() +-- +FUNCTION: name="brtrigpartcon1trigf" function="brtrigpartcon1trigf" schema="" ctx=DDL +STMT: DropStmt +== 353 +-- check that "do nothing" BR triggers work with tuple-routing +create table donothingbrtrig_test (a int, b text) partition by list (a) +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DDL +STMT: CreateStmt +== 354 +create table donothingbrtrig_test1 (b text, a int) +-- +TABLE: name="donothingbrtrig_test1" schema="" table="donothingbrtrig_test1" ctx=DDL +STMT: CreateStmt +== 355 +create table donothingbrtrig_test2 (c text, b text, a int) +-- +TABLE: name="donothingbrtrig_test2" schema="" table="donothingbrtrig_test2" ctx=DDL +STMT: CreateStmt +== 356 +alter table donothingbrtrig_test2 drop column c +-- +TABLE: name="donothingbrtrig_test2" schema="" table="donothingbrtrig_test2" ctx=DDL +STMT: AlterTableStmt +== 357 +create or replace function donothingbrtrig_func() returns trigger as $$begin raise notice 'b: %', new.b; return NULL; end$$ language plpgsql +-- +FUNCTION: name="donothingbrtrig_func" function="donothingbrtrig_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 358 +create trigger donothingbrtrig1 before insert on donothingbrtrig_test1 for each row execute procedure donothingbrtrig_func() +-- +TABLE: name="donothingbrtrig_test1" schema="" table="donothingbrtrig_test1" ctx=DDL +STMT: CreateTrigStmt +== 359 +create trigger donothingbrtrig2 before insert on donothingbrtrig_test2 for each row execute procedure donothingbrtrig_func() +-- +TABLE: name="donothingbrtrig_test2" schema="" table="donothingbrtrig_test2" ctx=DDL +STMT: CreateTrigStmt +== 360 +alter table donothingbrtrig_test attach partition donothingbrtrig_test1 for values in (1) +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DDL +STMT: AlterTableStmt +== 361 +alter table donothingbrtrig_test attach partition donothingbrtrig_test2 for values in (2) +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DDL +STMT: AlterTableStmt +== 362 +insert into donothingbrtrig_test values (1, 'foo'), (2, 'bar') +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 363 +copy donothingbrtrig_test from stdout +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=Select +STMT: CopyStmt +== 364 +1 baz +2 qux +select tableoid::regclass, * from donothingbrtrig_test +-- +ERROR: syntax error at or near "1" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 365 +-- cleanup +drop table donothingbrtrig_test +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DDL +STMT: DropStmt +== 366 +drop function donothingbrtrig_func() +-- +FUNCTION: name="donothingbrtrig_func" function="donothingbrtrig_func" schema="" ctx=DDL +STMT: DropStmt +== 367 +-- check multi-column range partitioning with minvalue/maxvalue constraints +create table mcrparted (a text, b int) partition by range(a, b) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: CreateStmt +== 368 +create table mcrparted1_lt_b partition of mcrparted for values from (minvalue, minvalue) to ('b', minvalue) +-- +TABLE: name="mcrparted1_lt_b" schema="" table="mcrparted1_lt_b" ctx=DDL +STMT: CreateStmt +== 369 +create table mcrparted2_b partition of mcrparted for values from ('b', minvalue) to ('c', minvalue) +-- +TABLE: name="mcrparted2_b" schema="" table="mcrparted2_b" ctx=DDL +STMT: CreateStmt +== 370 +create table mcrparted3_c_to_common partition of mcrparted for values from ('c', minvalue) to ('common', minvalue) +-- +TABLE: name="mcrparted3_c_to_common" schema="" table="mcrparted3_c_to_common" ctx=DDL +STMT: CreateStmt +== 371 +create table mcrparted4_common_lt_0 partition of mcrparted for values from ('common', minvalue) to ('common', 0) +-- +TABLE: name="mcrparted4_common_lt_0" schema="" table="mcrparted4_common_lt_0" ctx=DDL +STMT: CreateStmt +== 372 +create table mcrparted5_common_0_to_10 partition of mcrparted for values from ('common', 0) to ('common', 10) +-- +TABLE: name="mcrparted5_common_0_to_10" schema="" table="mcrparted5_common_0_to_10" ctx=DDL +STMT: CreateStmt +== 373 +create table mcrparted6_common_ge_10 partition of mcrparted for values from ('common', 10) to ('common', maxvalue) +-- +TABLE: name="mcrparted6_common_ge_10" schema="" table="mcrparted6_common_ge_10" ctx=DDL +STMT: CreateStmt +== 374 +create table mcrparted7_gt_common_lt_d partition of mcrparted for values from ('common', maxvalue) to ('d', minvalue) +-- +TABLE: name="mcrparted7_gt_common_lt_d" schema="" table="mcrparted7_gt_common_lt_d" ctx=DDL +STMT: CreateStmt +== 375 +create table mcrparted8_ge_d partition of mcrparted for values from ('d', minvalue) to (maxvalue, maxvalue) +-- +TABLE: name="mcrparted8_ge_d" schema="" table="mcrparted8_ge_d" ctx=DDL +STMT: CreateStmt +== 376 +insert into mcrparted values ('aaa', 0), ('b', 0), ('bz', 10), ('c', -10), + ('comm', -10), ('common', -10), ('common', 0), ('common', 10), + ('commons', 0), ('d', -10), ('e', 0) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 377 +select tableoid::regclass, * from mcrparted order by a, b +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +STMT: SelectStmt +== 378 +drop table mcrparted +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: DropStmt +== 379 +-- check that wholerow vars in the RETURNING list work with partitioned tables +create table returningwrtest (a int) partition by list (a) +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DDL +STMT: CreateStmt +== 380 +create table returningwrtest1 partition of returningwrtest for values in (1) +-- +TABLE: name="returningwrtest1" schema="" table="returningwrtest1" ctx=DDL +STMT: CreateStmt +== 381 +insert into returningwrtest values (1) returning returningwrtest +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 382 +-- check also that the wholerow vars in RETURNING list are converted as needed +alter table returningwrtest add b text +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DDL +STMT: AlterTableStmt +== 383 +create table returningwrtest2 (b text, c int, a int) +-- +TABLE: name="returningwrtest2" schema="" table="returningwrtest2" ctx=DDL +STMT: CreateStmt +== 384 +alter table returningwrtest2 drop c +-- +TABLE: name="returningwrtest2" schema="" table="returningwrtest2" ctx=DDL +STMT: AlterTableStmt +== 385 +alter table returningwrtest attach partition returningwrtest2 for values in (2) +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DDL +STMT: AlterTableStmt +== 386 +insert into returningwrtest values (2, 'foo') returning returningwrtest +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 387 +drop table returningwrtest +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/insert_conflict.metadata.json b/parser/testdata/summary/postgres_regress/insert_conflict.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/insert_conflict.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/insert_conflict.test b/parser/testdata/summary/postgres_regress/insert_conflict.test new file mode 100644 index 0000000..0486ff3 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/insert_conflict.test @@ -0,0 +1,1691 @@ +== 001 +|-- +-- insert...on conflict do unique index inference +|-- +create table insertconflicttest(key int4, fruit text) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: CreateStmt +== 002 +-- These things should work through a view, as well +create view insertconflictview as select * from insertconflicttest +-- +TABLE: name="insertconflictview" schema="" table="insertconflictview" ctx=DDL +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 003 +|-- +-- Test unique index inference with operator class specifications and +-- named collations +|-- +create unique index op_index_key on insertconflicttest(key, fruit text_pattern_ops) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 004 +create unique index collation_index_key on insertconflicttest(key, fruit collate "C") +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 005 +create unique index both_index_key on insertconflicttest(key, fruit collate "C" text_pattern_ops) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 006 +create unique index both_index_expr_key on insertconflicttest(key, lower(fruit) collate "C" text_pattern_ops) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: IndexStmt +== 007 +-- fails +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 008 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (fruit) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 009 +-- succeeds +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 010 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (fruit, key, fruit, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 011 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit), key, lower(fruit), key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 012 +explain (costs off) insert into insertconflictview values(0, 'Crowberry') on conflict (lower(fruit), key, lower(fruit), key) do nothing +-- +TABLE: name="insertconflictview" schema="" table="insertconflictview" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 013 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit) do update set fruit = excluded.fruit + where exists (select 1 from insertconflicttest ii where ii.key = excluded.key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=Select +ALIAS: "ii"="insertconflicttest" +FILTER: schema="" table="ii" column="key" +FILTER: schema="" table="excluded" column="key" +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 014 +-- Neither collation nor operator class specifications are required -- +-- supplying them merely *limits* matches to indexes with matching opclasses +-- used for relevant indexes +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit text_pattern_ops) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 015 +-- Okay, arbitrates using both index where text_pattern_ops opclass does and +-- does not appear. +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit collate "C") do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 016 +-- Okay, but only accepts the single index where both opclass and collation are +-- specified +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (fruit collate "C" text_pattern_ops, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 017 +-- Okay, but only accepts the single index where both opclass and collation are +-- specified (plus expression variant) +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit) collate "C", key, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 018 +-- Attribute appears twice, while not all attributes/expressions on attributes +-- appearing within index definition match in terms of both opclass and +-- collation. +|-- +-- Works because every attribute in inference specification needs to be +-- satisfied once or more by cataloged index attribute, and as always when an +-- attribute in the cataloged definition has a non-default opclass/collation, +-- it still satisfied some inference attribute lacking any particular +-- opclass/collation specification. +|-- +-- The implementation is liberal in accepting inference specifications on the +-- assumption that multiple inferred unique indexes will prevent problematic +-- cases. It rolls with unique indexes where attributes redundantly appear +-- multiple times, too (which is not tested here). +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (fruit, key, fruit text_pattern_ops, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 019 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit) collate "C" text_pattern_ops, key, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 020 +drop index op_index_key +-- +STMT: DropStmt +== 021 +drop index collation_index_key +-- +STMT: DropStmt +== 022 +drop index both_index_key +-- +STMT: DropStmt +== 023 +drop index both_index_expr_key +-- +STMT: DropStmt +== 024 +|-- +-- Make sure that cross matching of attribute opclass/collation does not occur +|-- +create unique index cross_match on insertconflicttest(lower(fruit) collate "C", upper(fruit) text_pattern_ops) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: IndexStmt +== 025 +-- fails: +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit) text_pattern_ops, upper(fruit) collate "C") do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 026 +-- works: +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit) collate "C", upper(fruit) text_pattern_ops) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 027 +drop index cross_match +-- +STMT: DropStmt +== 028 +|-- +-- Single key tests +|-- +create unique index key_index on insertconflicttest(key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 029 +|-- +-- Explain tests +|-- +explain (costs off) insert into insertconflicttest values (0, 'Bilberry') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 030 +-- Should display qual actually attributable to internal sequential scan: +explain (costs off) insert into insertconflicttest values (0, 'Bilberry') on conflict (key) do update set fruit = excluded.fruit where insertconflicttest.fruit != 'Cawesh' +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 031 +-- With EXCLUDED.* expression in scan node: +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key) do update set fruit = excluded.fruit where excluded.fruit != 'Elderberry' +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 032 +-- Does the same, but JSON format shows "Conflict Arbiter Index" as JSON array: +explain (costs off, format json) insert into insertconflicttest values (0, 'Bilberry') on conflict (key) do update set fruit = excluded.fruit where insertconflicttest.fruit != 'Lime' returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 033 +-- Fails (no unique index inference specification, required for do update variant): +insert into insertconflicttest values (1, 'Apple') on conflict do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +-- inference succeeds: +insert into insertconflicttest values (1, 'Apple') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +insert into insertconflicttest values (2, 'Orange') on conflict (key, key, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +-- Succeed, since multi-assignment does not involve subquery: +insert into insertconflicttest +values (1, 'Apple'), (2, 'Orange') +on conflict (key) do update set (fruit, key) = (excluded.fruit, excluded.key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +-- Give good diagnostic message when EXCLUDED.* spuriously referenced from +-- RETURNING: +insert into insertconflicttest values (1, 'Apple') on conflict (key) do update set fruit = excluded.fruit RETURNING excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +-- Only suggest .* column when inference element misspelled: +insert into insertconflicttest values (1, 'Apple') on conflict (keyy) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +-- Have useful HINT for EXCLUDED.* RTE within UPDATE: +insert into insertconflicttest values (1, 'Apple') on conflict (key) do update set fruit = excluded.fruitt +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +-- inference fails: +insert into insertconflicttest values (3, 'Kiwi') on conflict (key, fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +insert into insertconflicttest values (4, 'Mango') on conflict (fruit, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +insert into insertconflicttest values (5, 'Lemon') on conflict (fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +insert into insertconflicttest values (6, 'Passionfruit') on conflict (lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 044 +-- Check the target relation can be aliased +insert into insertconflicttest AS ict values (6, 'Passionfruit') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "ict"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +== 045 +-- ok, no reference to target table +insert into insertconflicttest AS ict values (6, 'Passionfruit') on conflict (key) do update set fruit = ict.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "ict"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +== 046 +-- ok, alias +insert into insertconflicttest AS ict values (6, 'Passionfruit') on conflict (key) do update set fruit = insertconflicttest.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "ict"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +== 047 +-- error, references aliased away name + +-- Check helpful hint when qualifying set column with target table +insert into insertconflicttest values (3, 'Kiwi') on conflict (key, fruit) do update set insertconflicttest.fruit = 'Mango' +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +drop index key_index +-- +STMT: DropStmt +== 049 +|-- +-- Composite key tests +|-- +create unique index comp_key_index on insertconflicttest(key, fruit) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 050 +-- inference succeeds: +insert into insertconflicttest values (7, 'Raspberry') on conflict (key, fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +insert into insertconflicttest values (8, 'Lime') on conflict (fruit, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +-- inference fails: +insert into insertconflicttest values (9, 'Banana') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +insert into insertconflicttest values (10, 'Blueberry') on conflict (key, key, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +insert into insertconflicttest values (11, 'Cherry') on conflict (key, lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 055 +insert into insertconflicttest values (12, 'Date') on conflict (lower(fruit), key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 056 +drop index comp_key_index +-- +STMT: DropStmt +== 057 +|-- +-- Partial index tests, no inference predicate specified +|-- +create unique index part_comp_key_index on insertconflicttest(key, fruit) where key < 5 +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 058 +create unique index expr_part_comp_key_index on insertconflicttest(key, lower(fruit)) where key < 5 +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: IndexStmt +== 059 +-- inference fails: +insert into insertconflicttest values (13, 'Grape') on conflict (key, fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +insert into insertconflicttest values (14, 'Raisin') on conflict (fruit, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +insert into insertconflicttest values (15, 'Cranberry') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +insert into insertconflicttest values (16, 'Melon') on conflict (key, key, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +insert into insertconflicttest values (17, 'Mulberry') on conflict (key, lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 064 +insert into insertconflicttest values (18, 'Pineapple') on conflict (lower(fruit), key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 065 +drop index part_comp_key_index +-- +STMT: DropStmt +== 066 +drop index expr_part_comp_key_index +-- +STMT: DropStmt +== 067 +|-- +-- Expression index tests +|-- +create unique index expr_key_index on insertconflicttest(lower(fruit)) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: IndexStmt +== 068 +-- inference succeeds: +insert into insertconflicttest values (20, 'Quince') on conflict (lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 069 +insert into insertconflicttest values (21, 'Pomegranate') on conflict (lower(fruit), lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 070 +-- inference fails: +insert into insertconflicttest values (22, 'Apricot') on conflict (upper(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 071 +insert into insertconflicttest values (23, 'Blackberry') on conflict (fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +drop index expr_key_index +-- +STMT: DropStmt +== 073 +|-- +-- Expression index tests (with regular column) +|-- +create unique index expr_comp_key_index on insertconflicttest(key, lower(fruit)) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: IndexStmt +== 074 +create unique index tricky_expr_comp_key_index on insertconflicttest(key, lower(fruit), upper(fruit)) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: IndexStmt +== 075 +-- inference succeeds: +insert into insertconflicttest values (24, 'Plum') on conflict (key, lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 076 +insert into insertconflicttest values (25, 'Peach') on conflict (lower(fruit), key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 077 +-- Should not infer "tricky_expr_comp_key_index" index: +explain (costs off) insert into insertconflicttest values (26, 'Fig') on conflict (lower(fruit), key, lower(fruit), key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 078 +-- inference fails: +insert into insertconflicttest values (27, 'Prune') on conflict (key, upper(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 079 +insert into insertconflicttest values (28, 'Redcurrant') on conflict (fruit, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +insert into insertconflicttest values (29, 'Nectarine') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +drop index expr_comp_key_index +-- +STMT: DropStmt +== 082 +drop index tricky_expr_comp_key_index +-- +STMT: DropStmt +== 083 +|-- +-- Non-spurious duplicate violation tests +|-- +create unique index key_index on insertconflicttest(key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 084 +create unique index fruit_index on insertconflicttest(fruit) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 085 +-- succeeds, since UPDATE happens to update "fruit" to existing value: +insert into insertconflicttest values (26, 'Fig') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 086 +-- fails, since UPDATE is to row with key value 26, and we're updating "fruit" +-- to a value that happens to exist in another row ('peach'): +insert into insertconflicttest values (26, 'Peach') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +-- succeeds, since "key" isn't repeated/referenced in UPDATE, and "fruit" +-- arbitrates that statement updates existing "Fig" row: +insert into insertconflicttest values (25, 'Fig') on conflict (fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +drop index key_index +-- +STMT: DropStmt +== 089 +drop index fruit_index +-- +STMT: DropStmt +== 090 +|-- +-- Test partial unique index inference +|-- +create unique index partial_key_index on insertconflicttest(key) where fruit like '%berry' +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 091 +-- Succeeds +insert into insertconflicttest values (23, 'Blackberry') on conflict (key) where fruit like '%berry' do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +insert into insertconflicttest as t values (23, 'Blackberry') on conflict (key) where fruit like '%berry' and t.fruit = 'inconsequential' do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "t"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +== 093 +insert into insertconflictview as t values (23, 'Blackberry') on conflict (key) where fruit like '%berry' and t.fruit = 'inconsequential' do nothing +-- +TABLE: name="insertconflictview" schema="" table="insertconflictview" ctx=DML +ALIAS: "t"="insertconflictview" +STMT: InsertStmt +STMT: SelectStmt +== 094 +-- fails +insert into insertconflicttest values (23, 'Blackberry') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +insert into insertconflicttest values (23, 'Blackberry') on conflict (key) where fruit like '%berry' or fruit = 'consequential' do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +insert into insertconflicttest values (23, 'Blackberry') on conflict (fruit) where fruit like '%berry' do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +drop index partial_key_index +-- +STMT: DropStmt +== 098 +|-- +-- Test that wholerow references to ON CONFLICT's EXCLUDED work +|-- +create unique index plain on insertconflicttest(key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +== 099 +-- Succeeds, updates existing row: +insert into insertconflicttest as i values (23, 'Jackfruit') on conflict (key) do update set fruit = excluded.fruit + where i.* != excluded.* returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +== 100 +-- No update this time, though: +insert into insertconflicttest as i values (23, 'Jackfruit') on conflict (key) do update set fruit = excluded.fruit + where i.* != excluded.* returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +== 101 +-- Predicate changed to require match rather than non-match, so updates once more: +insert into insertconflicttest as i values (23, 'Jackfruit') on conflict (key) do update set fruit = excluded.fruit + where i.* = excluded.* returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +== 102 +-- Assign: +insert into insertconflicttest as i values (23, 'Avocado') on conflict (key) do update set fruit = excluded.*::text + returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +== 103 +-- deparse whole row var in WHERE and SET clauses: +explain (costs off) insert into insertconflicttest as i values (23, 'Avocado') on conflict (key) do update set fruit = excluded.fruit where excluded.* is null +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 104 +explain (costs off) insert into insertconflicttest as i values (23, 'Avocado') on conflict (key) do update set fruit = excluded.*::text +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 105 +drop index plain +-- +STMT: DropStmt +== 106 +-- Cleanup +drop view insertconflictview +-- +STMT: DropStmt +== 107 +drop table insertconflicttest +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: DropStmt +== 108 +|-- +-- Verify that EXCLUDED does not allow system column references. These +-- do not make sense because EXCLUDED isn't an already stored tuple +-- (and thus doesn't have a ctid etc). +|-- +create table syscolconflicttest(key int4, data text) +-- +TABLE: name="syscolconflicttest" schema="" table="syscolconflicttest" ctx=DDL +STMT: CreateStmt +== 109 +insert into syscolconflicttest values (1) +-- +TABLE: name="syscolconflicttest" schema="" table="syscolconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +insert into syscolconflicttest values (1) on conflict (key) do update set data = excluded.ctid::text +-- +TABLE: name="syscolconflicttest" schema="" table="syscolconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +drop table syscolconflicttest +-- +TABLE: name="syscolconflicttest" schema="" table="syscolconflicttest" ctx=DDL +STMT: DropStmt +== 112 +|-- +-- Previous tests all managed to not test any expressions requiring +-- planner preprocessing ... +|-- +create table insertconflict (a bigint, b bigint) +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: CreateStmt +== 113 +create unique index insertconflicti1 on insertconflict(coalesce(a, 0)) +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: IndexStmt +== 114 +create unique index insertconflicti2 on insertconflict(b) + where coalesce(a, 1) > 0 +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: IndexStmt +== 115 +insert into insertconflict values (1, 2) +on conflict (coalesce(a, 0)) do nothing +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +insert into insertconflict values (1, 2) +on conflict (b) where coalesce(a, 1) > 0 do nothing +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +insert into insertconflict values (1, 2) +on conflict (b) where coalesce(a, 1) > 1 do nothing +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 118 +drop table insertconflict +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: DropStmt +== 119 +|-- +-- test insertion through view +|-- + +create table insertconflict (f1 int primary key, f2 text) +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: CreateStmt +== 120 +create view insertconflictv as + select * from insertconflict with cascaded check option +-- +TABLE: name="insertconflictv" schema="" table="insertconflictv" ctx=DDL +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 121 +insert into insertconflictv values (1,'foo') + on conflict (f1) do update set f2 = excluded.f2 +-- +TABLE: name="insertconflictv" schema="" table="insertconflictv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +select * from insertconflict +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=Select +STMT: SelectStmt +== 123 +insert into insertconflictv values (1,'bar') + on conflict (f1) do update set f2 = excluded.f2 +-- +TABLE: name="insertconflictv" schema="" table="insertconflictv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 124 +select * from insertconflict +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=Select +STMT: SelectStmt +== 125 +drop view insertconflictv +-- +STMT: DropStmt +== 126 +drop table insertconflict +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: DropStmt +== 127 +-- ****************************************************************** +-- * * +-- * Test inheritance (example taken from tutorial) * +-- * * +-- ****************************************************************** +create table cities ( + name text, + population float8, + altitude int -- (in ft) +) +-- +TABLE: name="cities" schema="" table="cities" ctx=DDL +STMT: CreateStmt +== 128 +create table capitals ( + state char(2) +) inherits (cities) +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DDL +STMT: CreateStmt +== 129 +-- Create unique indexes. Due to a general limitation of inheritance, +-- uniqueness is only enforced per-relation. Unique index inference +-- specification will do the right thing, though. +create unique index cities_names_unique on cities (name) +-- +TABLE: name="cities" schema="" table="cities" ctx=DDL +STMT: IndexStmt +== 130 +create unique index capitals_names_unique on capitals (name) +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DDL +STMT: IndexStmt +== 131 +-- prepopulate the tables. +insert into cities values ('San Francisco', 7.24E+5, 63) +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 132 +insert into cities values ('Las Vegas', 2.583E+5, 2174) +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 133 +insert into cities values ('Mariposa', 1200, 1953) +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 134 +insert into capitals values ('Sacramento', 3.694E+5, 30, 'CA') +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 135 +insert into capitals values ('Madison', 1.913E+5, 845, 'WI') +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +-- Tests proper for inheritance: +select * from capitals +-- +TABLE: name="capitals" schema="" table="capitals" ctx=Select +STMT: SelectStmt +== 137 +-- Succeeds: +insert into cities values ('Las Vegas', 2.583E+5, 2174) on conflict do nothing +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +insert into capitals values ('Sacramento', 4664.E+5, 30, 'CA') on conflict (name) do update set population = excluded.population +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +-- Wrong "Sacramento", so do nothing: +insert into capitals values ('Sacramento', 50, 2267, 'NE') on conflict (name) do nothing +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 140 +select * from capitals +-- +TABLE: name="capitals" schema="" table="capitals" ctx=Select +STMT: SelectStmt +== 141 +insert into cities values ('Las Vegas', 5.83E+5, 2001) on conflict (name) do update set population = excluded.population, altitude = excluded.altitude +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +select tableoid::regclass, * from cities +-- +TABLE: name="cities" schema="" table="cities" ctx=Select +STMT: SelectStmt +== 143 +insert into capitals values ('Las Vegas', 5.83E+5, 2222, 'NV') on conflict (name) do update set population = excluded.population +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +-- Capitals will contain new capital, Las Vegas: +select * from capitals +-- +TABLE: name="capitals" schema="" table="capitals" ctx=Select +STMT: SelectStmt +== 145 +-- Cities contains two instances of "Las Vegas", since unique constraints don't +-- work across inheritance: +select tableoid::regclass, * from cities +-- +TABLE: name="cities" schema="" table="cities" ctx=Select +STMT: SelectStmt +== 146 +-- This only affects "cities" version of "Las Vegas": +insert into cities values ('Las Vegas', 5.86E+5, 2223) on conflict (name) do update set population = excluded.population, altitude = excluded.altitude +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +select tableoid::regclass, * from cities +-- +TABLE: name="cities" schema="" table="cities" ctx=Select +STMT: SelectStmt +== 148 +-- clean up +drop table capitals +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DDL +STMT: DropStmt +== 149 +drop table cities +-- +TABLE: name="cities" schema="" table="cities" ctx=DDL +STMT: DropStmt +== 150 +-- Make sure a table named excluded is handled properly +create table excluded(key int primary key, data text) +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DDL +STMT: CreateStmt +== 151 +insert into excluded values(1, '1') +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +-- error, ambiguous +insert into excluded values(1, '2') on conflict (key) do update set data = excluded.data RETURNING * +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 153 +-- ok, aliased +insert into excluded AS target values(1, '2') on conflict (key) do update set data = excluded.data RETURNING * +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +ALIAS: "target"="excluded" +STMT: InsertStmt +STMT: SelectStmt +== 154 +-- ok, aliased +insert into excluded AS target values(1, '2') on conflict (key) do update set data = target.data RETURNING * +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +ALIAS: "target"="excluded" +STMT: InsertStmt +STMT: SelectStmt +== 155 +-- make sure excluded isn't a problem in returning clause +insert into excluded values(1, '2') on conflict (key) do update set data = 3 RETURNING excluded.* +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 156 +-- clean up +drop table excluded +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DDL +STMT: DropStmt +== 157 +-- check that references to columns after dropped columns are handled correctly +create table dropcol(key int primary key, drop1 int, keep1 text, drop2 numeric, keep2 float) +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DDL +STMT: CreateStmt +== 158 +insert into dropcol(key, drop1, keep1, drop2, keep2) values(1, 1, '1', '1', 1) +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 159 +-- set using excluded +insert into dropcol(key, drop1, keep1, drop2, keep2) values(1, 2, '2', '2', 2) on conflict(key) + do update set drop1 = excluded.drop1, keep1 = excluded.keep1, drop2 = excluded.drop2, keep2 = excluded.keep2 + where excluded.drop1 is not null and excluded.keep1 is not null and excluded.drop2 is not null and excluded.keep2 is not null + and dropcol.drop1 is not null and dropcol.keep1 is not null and dropcol.drop2 is not null and dropcol.keep2 is not null + returning * +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 160 +-- set using existing table +insert into dropcol(key, drop1, keep1, drop2, keep2) values(1, 3, '3', '3', 3) on conflict(key) + do update set drop1 = dropcol.drop1, keep1 = dropcol.keep1, drop2 = dropcol.drop2, keep2 = dropcol.keep2 + returning * +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 161 +alter table dropcol drop column drop1, drop column drop2 +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DDL +STMT: AlterTableStmt +== 162 +-- set using excluded +insert into dropcol(key, keep1, keep2) values(1, '4', 4) on conflict(key) + do update set keep1 = excluded.keep1, keep2 = excluded.keep2 + where excluded.keep1 is not null and excluded.keep2 is not null + and dropcol.keep1 is not null and dropcol.keep2 is not null + returning * +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 163 +-- set using existing table +insert into dropcol(key, keep1, keep2) values(1, '5', 5) on conflict(key) + do update set keep1 = dropcol.keep1, keep2 = dropcol.keep2 + returning * +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +DROP TABLE dropcol +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DDL +STMT: DropStmt +== 165 +-- check handling of regular btree constraint along with gist constraint + +create table twoconstraints (f1 int unique, f2 box, + exclude using gist(f2 with &&)) +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DDL +STMT: CreateStmt +== 166 +insert into twoconstraints values(1, '((0,0),(1,1))') +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 167 +insert into twoconstraints values(1, '((2,2),(3,3))') +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +-- fail on f1 +insert into twoconstraints values(2, '((0,0),(1,2))') +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 169 +-- fail on f2 +insert into twoconstraints values(2, '((0,0),(1,2))') + on conflict on constraint twoconstraints_f1_key do nothing +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 170 +-- fail on f2 +insert into twoconstraints values(2, '((0,0),(1,2))') + on conflict on constraint twoconstraints_f2_excl do nothing +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 171 +-- do nothing +select * from twoconstraints +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=Select +STMT: SelectStmt +== 172 +drop table twoconstraints +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DDL +STMT: DropStmt +== 173 +-- check handling of self-conflicts at various isolation levels + +create table selfconflict (f1 int primary key, f2 int) +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DDL +STMT: CreateStmt +== 174 +begin transaction isolation level read committed +-- +STMT: TransactionStmt +== 175 +insert into selfconflict values (1,1), (1,2) on conflict do nothing +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 176 +commit +-- +STMT: TransactionStmt +== 177 +begin transaction isolation level repeatable read +-- +STMT: TransactionStmt +== 178 +insert into selfconflict values (2,1), (2,2) on conflict do nothing +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 179 +commit +-- +STMT: TransactionStmt +== 180 +begin transaction isolation level serializable +-- +STMT: TransactionStmt +== 181 +insert into selfconflict values (3,1), (3,2) on conflict do nothing +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 182 +commit +-- +STMT: TransactionStmt +== 183 +begin transaction isolation level read committed +-- +STMT: TransactionStmt +== 184 +insert into selfconflict values (4,1), (4,2) on conflict(f1) do update set f2 = 0 +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 185 +commit +-- +STMT: TransactionStmt +== 186 +begin transaction isolation level repeatable read +-- +STMT: TransactionStmt +== 187 +insert into selfconflict values (5,1), (5,2) on conflict(f1) do update set f2 = 0 +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +commit +-- +STMT: TransactionStmt +== 189 +begin transaction isolation level serializable +-- +STMT: TransactionStmt +== 190 +insert into selfconflict values (6,1), (6,2) on conflict(f1) do update set f2 = 0 +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +commit +-- +STMT: TransactionStmt +== 192 +select * from selfconflict +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=Select +STMT: SelectStmt +== 193 +drop table selfconflict +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DDL +STMT: DropStmt +== 194 +-- check ON CONFLICT handling with partitioned tables +create table parted_conflict_test (a int unique, b char) partition by list (a) +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: CreateStmt +== 195 +create table parted_conflict_test_1 partition of parted_conflict_test (b unique) for values in (1, 2) +-- +TABLE: name="parted_conflict_test_1" schema="" table="parted_conflict_test_1" ctx=DDL +STMT: CreateStmt +== 196 +-- no indexes required here +insert into parted_conflict_test values (1, 'a') on conflict do nothing +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 197 +-- index on a required, which does exist in parent +insert into parted_conflict_test values (1, 'a') on conflict (a) do nothing +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 198 +insert into parted_conflict_test values (1, 'a') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 199 +-- targeting partition directly will work +insert into parted_conflict_test_1 values (1, 'a') on conflict (a) do nothing +-- +TABLE: name="parted_conflict_test_1" schema="" table="parted_conflict_test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 200 +insert into parted_conflict_test_1 values (1, 'b') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test_1" schema="" table="parted_conflict_test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 201 +-- index on b required, which doesn't exist in parent +insert into parted_conflict_test values (2, 'b') on conflict (b) do update set a = excluded.a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +-- targeting partition directly will work +insert into parted_conflict_test_1 values (2, 'b') on conflict (b) do update set a = excluded.a +-- +TABLE: name="parted_conflict_test_1" schema="" table="parted_conflict_test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 203 +-- should see (2, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +== 204 +-- now check that DO UPDATE works correctly for target partition with +-- different attribute numbers +create table parted_conflict_test_2 (b char, a int unique) +-- +TABLE: name="parted_conflict_test_2" schema="" table="parted_conflict_test_2" ctx=DDL +STMT: CreateStmt +== 205 +alter table parted_conflict_test attach partition parted_conflict_test_2 for values in (3) +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: AlterTableStmt +== 206 +truncate parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: TruncateStmt +== 207 +insert into parted_conflict_test values (3, 'a') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 208 +insert into parted_conflict_test values (3, 'b') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 209 +-- should see (3, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +== 210 +-- case where parent will have a dropped column, but the partition won't +alter table parted_conflict_test drop b, add b char +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: AlterTableStmt +== 211 +create table parted_conflict_test_3 partition of parted_conflict_test for values in (4) +-- +TABLE: name="parted_conflict_test_3" schema="" table="parted_conflict_test_3" ctx=DDL +STMT: CreateStmt +== 212 +truncate parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: TruncateStmt +== 213 +insert into parted_conflict_test (a, b) values (4, 'a') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 214 +insert into parted_conflict_test (a, b) values (4, 'b') on conflict (a) do update set b = excluded.b where parted_conflict_test.b = 'a' +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 215 +-- should see (4, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +== 216 +-- case with multi-level partitioning +create table parted_conflict_test_4 partition of parted_conflict_test for values in (5) partition by list (a) +-- +TABLE: name="parted_conflict_test_4" schema="" table="parted_conflict_test_4" ctx=DDL +STMT: CreateStmt +== 217 +create table parted_conflict_test_4_1 partition of parted_conflict_test_4 for values in (5) +-- +TABLE: name="parted_conflict_test_4_1" schema="" table="parted_conflict_test_4_1" ctx=DDL +STMT: CreateStmt +== 218 +truncate parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: TruncateStmt +== 219 +insert into parted_conflict_test (a, b) values (5, 'a') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 220 +insert into parted_conflict_test (a, b) values (5, 'b') on conflict (a) do update set b = excluded.b where parted_conflict_test.b = 'a' +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 221 +-- should see (5, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +== 222 +-- test with multiple rows +truncate parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: TruncateStmt +== 223 +insert into parted_conflict_test (a, b) values (1, 'a'), (2, 'a'), (4, 'a') on conflict (a) do update set b = excluded.b where excluded.b = 'b' +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 224 +insert into parted_conflict_test (a, b) values (1, 'b'), (2, 'c'), (4, 'b') on conflict (a) do update set b = excluded.b where excluded.b = 'b' +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 225 +-- should see (1, 'b'), (2, 'a'), (4, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +== 226 +drop table parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: DropStmt +== 227 +-- test behavior of inserting a conflicting tuple into an intermediate +-- partitioning level +create table parted_conflict (a int primary key, b text) partition by range (a) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: CreateStmt +== 228 +create table parted_conflict_1 partition of parted_conflict for values from (0) to (1000) partition by range (a) +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: CreateStmt +== 229 +create table parted_conflict_1_1 partition of parted_conflict_1 for values from (0) to (500) +-- +TABLE: name="parted_conflict_1_1" schema="" table="parted_conflict_1_1" ctx=DDL +STMT: CreateStmt +== 230 +insert into parted_conflict values (40, 'forty') +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 231 +insert into parted_conflict_1 values (40, 'cuarenta') + on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 232 +drop table parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: DropStmt +== 233 +-- same thing, but this time try to use an index that's created not in the +-- partition +create table parted_conflict (a int, b text) partition by range (a) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: CreateStmt +== 234 +create table parted_conflict_1 partition of parted_conflict for values from (0) to (1000) partition by range (a) +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: CreateStmt +== 235 +create table parted_conflict_1_1 partition of parted_conflict_1 for values from (0) to (500) +-- +TABLE: name="parted_conflict_1_1" schema="" table="parted_conflict_1_1" ctx=DDL +STMT: CreateStmt +== 236 +create unique index on only parted_conflict_1 (a) +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: IndexStmt +== 237 +create unique index on only parted_conflict (a) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: IndexStmt +== 238 +alter index parted_conflict_a_idx attach partition parted_conflict_1_a_idx +-- +STMT: AlterTableStmt +== 239 +insert into parted_conflict values (40, 'forty') +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 240 +insert into parted_conflict_1 values (40, 'cuarenta') + on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 241 +drop table parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: DropStmt +== 242 +-- test whole-row Vars in ON CONFLICT expressions +create table parted_conflict (a int, b text, c int) partition by range (a) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: CreateStmt +== 243 +create table parted_conflict_1 (drp text, c int, a int, b text) +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: CreateStmt +== 244 +alter table parted_conflict_1 drop column drp +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: AlterTableStmt +== 245 +create unique index on parted_conflict (a, b) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: IndexStmt +== 246 +alter table parted_conflict attach partition parted_conflict_1 for values from (0) to (1000) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: AlterTableStmt +== 247 +truncate parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: TruncateStmt +== 248 +insert into parted_conflict values (50, 'cincuenta', 1) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 249 +insert into parted_conflict values (50, 'cincuenta', 2) + on conflict (a, b) do update set (a, b, c) = row(excluded.*) + where parted_conflict = (50, text 'cincuenta', 1) and + excluded = (50, text 'cincuenta', 2) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 250 +-- should see (50, 'cincuenta', 2) +select * from parted_conflict order by a +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=Select +STMT: SelectStmt +== 251 +-- test with statement level triggers +create or replace function parted_conflict_update_func() returns trigger as $$ +declare + r record; +begin + for r in select * from inserted loop + raise notice 'a = %, b = %, c = %', r.a, r.b, r.c; + end loop; + return new; +end; +$$ language plpgsql +-- +FUNCTION: name="parted_conflict_update_func" function="parted_conflict_update_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 252 +create trigger parted_conflict_update + after update on parted_conflict + referencing new table as inserted + for each statement + execute procedure parted_conflict_update_func() +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: CreateTrigStmt +== 253 +truncate parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: TruncateStmt +== 254 +insert into parted_conflict values (0, 'cero', 1) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 255 +insert into parted_conflict values(0, 'cero', 1) + on conflict (a,b) do update set c = parted_conflict.c + 1 +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 256 +drop table parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: DropStmt +== 257 +drop function parted_conflict_update_func() +-- +FUNCTION: name="parted_conflict_update_func" function="parted_conflict_update_func" schema="" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/int2.metadata.json b/parser/testdata/summary/postgres_regress/int2.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/int2.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/int2.test b/parser/testdata/summary/postgres_regress/int2.test new file mode 100644 index 0000000..8cab4b8 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/int2.test @@ -0,0 +1,438 @@ +== 001 +|-- +-- INT2 +|-- + +-- int2_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. + +INSERT INTO INT2_TBL(f1) VALUES ('34.5') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 002 +INSERT INTO INT2_TBL(f1) VALUES ('100000') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO INT2_TBL(f1) VALUES ('asdf') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO INT2_TBL(f1) VALUES (' ') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO INT2_TBL(f1) VALUES ('- 1234') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO INT2_TBL(f1) VALUES ('4 444') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO INT2_TBL(f1) VALUES ('123 dt') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO INT2_TBL(f1) VALUES ('') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +SELECT * FROM INT2_TBL +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +STMT: SelectStmt +== 010 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34', 'int2') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT pg_input_is_valid('asdf', 'int2') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT pg_input_is_valid('50000', 'int2') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT * FROM pg_input_error_info('50000', 'int2') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- While we're here, check int2vector as well +SELECT pg_input_is_valid(' 1 3 5 ', 'int2vector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT * FROM pg_input_error_info('1 asdf', 'int2vector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT * FROM pg_input_error_info('50000', 'int2vector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT * FROM INT2_TBL AS f(a, b) +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "f"="int2_tbl" +STMT: SelectStmt +== 018 +SELECT * FROM (TABLE int2_tbl) AS s (a, b) +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +STMT: SelectStmt +== 019 +SELECT i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 020 +SELECT i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 021 +SELECT i.* FROM INT2_TBL i WHERE i.f1 = int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 022 +SELECT i.* FROM INT2_TBL i WHERE i.f1 = int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 023 +SELECT i.* FROM INT2_TBL i WHERE i.f1 < int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 024 +SELECT i.* FROM INT2_TBL i WHERE i.f1 < int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 025 +SELECT i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 026 +SELECT i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 027 +SELECT i.* FROM INT2_TBL i WHERE i.f1 > int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 028 +SELECT i.* FROM INT2_TBL i WHERE i.f1 > int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 029 +SELECT i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 030 +SELECT i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 031 +-- positive odds +SELECT i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 032 +-- any evens +SELECT i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 033 +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +== 034 +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i +WHERE abs(f1) < 16384 +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 035 +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +== 036 +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +== 037 +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i +WHERE f1 < 32766 +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 038 +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +== 039 +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +== 040 +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i +WHERE f1 > -32767 +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 041 +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +== 042 +SELECT i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +== 043 +SELECT i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +== 044 +-- corner cases +SELECT (-1::int2<<15)::text +-- +STMT: SelectStmt +== 045 +SELECT ((-1::int2<<15)+1::int2)::text +-- +STMT: SelectStmt +== 046 +-- check sane handling of INT16_MIN overflow cases +SELECT (-32768)::int2 * (-1)::int2 +-- +STMT: SelectStmt +== 047 +SELECT (-32768)::int2 / (-1)::int2 +-- +STMT: SelectStmt +== 048 +SELECT (-32768)::int2 % (-1)::int2 +-- +STMT: SelectStmt +== 049 +-- check rounding when casting from float +SELECT x, x::int2 AS int2_value +FROM (VALUES (-2.5::float8), + (-1.5::float8), + (-0.5::float8), + (0.0::float8), + (0.5::float8), + (1.5::float8), + (2.5::float8)) t(x) +-- +STMT: SelectStmt +== 050 +-- check rounding when casting from numeric +SELECT x, x::int2 AS int2_value +FROM (VALUES (-2.5::numeric), + (-1.5::numeric), + (-0.5::numeric), + (0.0::numeric), + (0.5::numeric), + (1.5::numeric), + (2.5::numeric)) t(x) +-- +STMT: SelectStmt +== 051 +-- non-decimal literals + +SELECT int2 '0b100101' +-- +STMT: SelectStmt +== 052 +SELECT int2 '0o273' +-- +STMT: SelectStmt +== 053 +SELECT int2 '0x42F' +-- +STMT: SelectStmt +== 054 +SELECT int2 '0b' +-- +STMT: SelectStmt +== 055 +SELECT int2 '0o' +-- +STMT: SelectStmt +== 056 +SELECT int2 '0x' +-- +STMT: SelectStmt +== 057 +-- cases near overflow +SELECT int2 '0b111111111111111' +-- +STMT: SelectStmt +== 058 +SELECT int2 '0b1000000000000000' +-- +STMT: SelectStmt +== 059 +SELECT int2 '0o77777' +-- +STMT: SelectStmt +== 060 +SELECT int2 '0o100000' +-- +STMT: SelectStmt +== 061 +SELECT int2 '0x7FFF' +-- +STMT: SelectStmt +== 062 +SELECT int2 '0x8000' +-- +STMT: SelectStmt +== 063 +SELECT int2 '-0b1000000000000000' +-- +STMT: SelectStmt +== 064 +SELECT int2 '-0b1000000000000001' +-- +STMT: SelectStmt +== 065 +SELECT int2 '-0o100000' +-- +STMT: SelectStmt +== 066 +SELECT int2 '-0o100001' +-- +STMT: SelectStmt +== 067 +SELECT int2 '-0x8000' +-- +STMT: SelectStmt +== 068 +SELECT int2 '-0x8001' +-- +STMT: SelectStmt +== 069 +-- underscores + +SELECT int2 '1_000' +-- +STMT: SelectStmt +== 070 +SELECT int2 '1_2_3' +-- +STMT: SelectStmt +== 071 +SELECT int2 '0xE_FF' +-- +STMT: SelectStmt +== 072 +SELECT int2 '0o2_73' +-- +STMT: SelectStmt +== 073 +SELECT int2 '0b_10_0101' +-- +STMT: SelectStmt +== 074 +-- error cases +SELECT int2 '_100' +-- +STMT: SelectStmt +== 075 +SELECT int2 '100_' +-- +STMT: SelectStmt +== 076 +SELECT int2 '10__000' +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/int4.metadata.json b/parser/testdata/summary/postgres_regress/int4.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/int4.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/int4.test b/parser/testdata/summary/postgres_regress/int4.test new file mode 100644 index 0000000..e1f39ce --- /dev/null +++ b/parser/testdata/summary/postgres_regress/int4.test @@ -0,0 +1,556 @@ +== 001 +|-- +-- INT4 +|-- + +-- int4_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. + +INSERT INTO INT4_TBL(f1) VALUES ('34.5') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 002 +INSERT INTO INT4_TBL(f1) VALUES ('1000000000000') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO INT4_TBL(f1) VALUES ('asdf') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO INT4_TBL(f1) VALUES (' ') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO INT4_TBL(f1) VALUES (' asdf ') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO INT4_TBL(f1) VALUES ('- 1234') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO INT4_TBL(f1) VALUES ('123 5') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO INT4_TBL(f1) VALUES ('') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +SELECT * FROM INT4_TBL +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +== 010 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34', 'int4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT pg_input_is_valid('asdf', 'int4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT pg_input_is_valid('1000000000000', 'int4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT * FROM pg_input_error_info('1000000000000', 'int4') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 015 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 016 +SELECT i.* FROM INT4_TBL i WHERE i.f1 = int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 017 +SELECT i.* FROM INT4_TBL i WHERE i.f1 = int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 018 +SELECT i.* FROM INT4_TBL i WHERE i.f1 < int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 019 +SELECT i.* FROM INT4_TBL i WHERE i.f1 < int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 020 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 021 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 022 +SELECT i.* FROM INT4_TBL i WHERE i.f1 > int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 023 +SELECT i.* FROM INT4_TBL i WHERE i.f1 > int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 024 +SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 025 +SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 026 +-- positive odds +SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 027 +-- any evens +SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +== 028 +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +== 029 +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i +WHERE abs(f1) < 1073741824 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 030 +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +== 031 +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i +WHERE abs(f1) < 1073741824 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 032 +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +== 033 +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i +WHERE f1 < 2147483646 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 034 +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +== 035 +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i +WHERE f1 < 2147483646 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 036 +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +== 037 +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i +WHERE f1 > -2147483647 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 038 +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +== 039 +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i +WHERE f1 > -2147483647 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 040 +SELECT i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +== 041 +SELECT i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +== 042 +|-- +-- more complex expressions +|-- + +-- variations on unary minus parsing +SELECT -2+3 AS one +-- +STMT: SelectStmt +== 043 +SELECT 4-2 AS two +-- +STMT: SelectStmt +== 044 +SELECT 2- -1 AS three +-- +STMT: SelectStmt +== 045 +SELECT 2 - -2 AS four +-- +STMT: SelectStmt +== 046 +SELECT int2 '2' * int2 '2' = int2 '16' / int2 '4' AS true +-- +STMT: SelectStmt +== 047 +SELECT int4 '2' * int2 '2' = int2 '16' / int4 '4' AS true +-- +STMT: SelectStmt +== 048 +SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true +-- +STMT: SelectStmt +== 049 +SELECT int4 '1000' < int4 '999' AS false +-- +STMT: SelectStmt +== 050 +SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten +-- +STMT: SelectStmt +== 051 +SELECT 2 + 2 / 2 AS three +-- +STMT: SelectStmt +== 052 +SELECT (2 + 2) / 2 AS two +-- +STMT: SelectStmt +== 053 +-- corner case +SELECT (-1::int4<<31)::text +-- +STMT: SelectStmt +== 054 +SELECT ((-1::int4<<31)+1)::text +-- +STMT: SelectStmt +== 055 +-- check sane handling of INT_MIN overflow cases +SELECT (-2147483648)::int4 * (-1)::int4 +-- +STMT: SelectStmt +== 056 +SELECT (-2147483648)::int4 / (-1)::int4 +-- +STMT: SelectStmt +== 057 +SELECT (-2147483648)::int4 % (-1)::int4 +-- +STMT: SelectStmt +== 058 +SELECT (-2147483648)::int4 * (-1)::int2 +-- +STMT: SelectStmt +== 059 +SELECT (-2147483648)::int4 / (-1)::int2 +-- +STMT: SelectStmt +== 060 +SELECT (-2147483648)::int4 % (-1)::int2 +-- +STMT: SelectStmt +== 061 +-- check rounding when casting from float +SELECT x, x::int4 AS int4_value +FROM (VALUES (-2.5::float8), + (-1.5::float8), + (-0.5::float8), + (0.0::float8), + (0.5::float8), + (1.5::float8), + (2.5::float8)) t(x) +-- +STMT: SelectStmt +== 062 +-- check rounding when casting from numeric +SELECT x, x::int4 AS int4_value +FROM (VALUES (-2.5::numeric), + (-1.5::numeric), + (-0.5::numeric), + (0.0::numeric), + (0.5::numeric), + (1.5::numeric), + (2.5::numeric)) t(x) +-- +STMT: SelectStmt +== 063 +-- test gcd() +SELECT a, b, gcd(a, b), gcd(a, -b), gcd(b, a), gcd(-b, a) +FROM (VALUES (0::int4, 0::int4), + (0::int4, 6410818::int4), + (61866666::int4, 6410818::int4), + (-61866666::int4, 6410818::int4), + ((-2147483648)::int4, 1::int4), + ((-2147483648)::int4, 2147483647::int4), + ((-2147483648)::int4, 1073741824::int4)) AS v(a, b) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT gcd((-2147483648)::int4, 0::int4) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +== 065 +-- overflow +SELECT gcd((-2147483648)::int4, (-2147483648)::int4) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +== 066 +-- overflow + +-- test lcm() +SELECT a, b, lcm(a, b), lcm(a, -b), lcm(b, a), lcm(-b, a) +FROM (VALUES (0::int4, 0::int4), + (0::int4, 42::int4), + (42::int4, 42::int4), + (330::int4, 462::int4), + (-330::int4, 462::int4), + ((-2147483648)::int4, 0::int4)) AS v(a, b) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT lcm((-2147483648)::int4, 1::int4) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +== 068 +-- overflow +SELECT lcm(2147483647::int4, 2147483646::int4) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +== 069 +-- overflow + + +-- non-decimal literals + +SELECT int4 '0b100101' +-- +STMT: SelectStmt +== 070 +SELECT int4 '0o273' +-- +STMT: SelectStmt +== 071 +SELECT int4 '0x42F' +-- +STMT: SelectStmt +== 072 +SELECT int4 '0b' +-- +STMT: SelectStmt +== 073 +SELECT int4 '0o' +-- +STMT: SelectStmt +== 074 +SELECT int4 '0x' +-- +STMT: SelectStmt +== 075 +-- cases near overflow +SELECT int4 '0b1111111111111111111111111111111' +-- +STMT: SelectStmt +== 076 +SELECT int4 '0b10000000000000000000000000000000' +-- +STMT: SelectStmt +== 077 +SELECT int4 '0o17777777777' +-- +STMT: SelectStmt +== 078 +SELECT int4 '0o20000000000' +-- +STMT: SelectStmt +== 079 +SELECT int4 '0x7FFFFFFF' +-- +STMT: SelectStmt +== 080 +SELECT int4 '0x80000000' +-- +STMT: SelectStmt +== 081 +SELECT int4 '-0b10000000000000000000000000000000' +-- +STMT: SelectStmt +== 082 +SELECT int4 '-0b10000000000000000000000000000001' +-- +STMT: SelectStmt +== 083 +SELECT int4 '-0o20000000000' +-- +STMT: SelectStmt +== 084 +SELECT int4 '-0o20000000001' +-- +STMT: SelectStmt +== 085 +SELECT int4 '-0x80000000' +-- +STMT: SelectStmt +== 086 +SELECT int4 '-0x80000001' +-- +STMT: SelectStmt +== 087 +-- underscores + +SELECT int4 '1_000_000' +-- +STMT: SelectStmt +== 088 +SELECT int4 '1_2_3' +-- +STMT: SelectStmt +== 089 +SELECT int4 '0x1EEE_FFFF' +-- +STMT: SelectStmt +== 090 +SELECT int4 '0o2_73' +-- +STMT: SelectStmt +== 091 +SELECT int4 '0b_10_0101' +-- +STMT: SelectStmt +== 092 +-- error cases +SELECT int4 '_100' +-- +STMT: SelectStmt +== 093 +SELECT int4 '100_' +-- +STMT: SelectStmt +== 094 +SELECT int4 '100__000' +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/int8.metadata.json b/parser/testdata/summary/postgres_regress/int8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/int8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/int8.test b/parser/testdata/summary/postgres_regress/int8.test new file mode 100644 index 0000000..e2c8a3d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/int8.test @@ -0,0 +1,921 @@ +== 001 +|-- +-- INT8 +-- Test int8 64-bit integers. +|-- + +-- int8_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. + +INSERT INTO INT8_TBL(q1) VALUES (' ') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 002 +INSERT INTO INT8_TBL(q1) VALUES ('xxx') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO INT8_TBL(q1) VALUES ('3908203590239580293850293850329485') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340329840934') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO INT8_TBL(q1) VALUES ('- 123') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO INT8_TBL(q1) VALUES (' 345 5') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO INT8_TBL(q1) VALUES ('') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +SELECT * FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 009 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34', 'int8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT pg_input_is_valid('asdf', 'int8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT pg_input_is_valid('10000000000000000000', 'int8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT * FROM pg_input_error_info('10000000000000000000', 'int8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- int8/int8 cmp +SELECT * FROM INT8_TBL WHERE q2 = 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 014 +SELECT * FROM INT8_TBL WHERE q2 <> 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 015 +SELECT * FROM INT8_TBL WHERE q2 < 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 016 +SELECT * FROM INT8_TBL WHERE q2 > 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 017 +SELECT * FROM INT8_TBL WHERE q2 <= 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 018 +SELECT * FROM INT8_TBL WHERE q2 >= 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 019 +-- int8/int4 cmp +SELECT * FROM INT8_TBL WHERE q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 020 +SELECT * FROM INT8_TBL WHERE q2 <> 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 021 +SELECT * FROM INT8_TBL WHERE q2 < 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 022 +SELECT * FROM INT8_TBL WHERE q2 > 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 023 +SELECT * FROM INT8_TBL WHERE q2 <= 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 024 +SELECT * FROM INT8_TBL WHERE q2 >= 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 025 +-- int4/int8 cmp +SELECT * FROM INT8_TBL WHERE 123 = q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 026 +SELECT * FROM INT8_TBL WHERE 123 <> q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 027 +SELECT * FROM INT8_TBL WHERE 123 < q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 028 +SELECT * FROM INT8_TBL WHERE 123 > q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 029 +SELECT * FROM INT8_TBL WHERE 123 <= q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 030 +SELECT * FROM INT8_TBL WHERE 123 >= q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 031 +-- int8/int2 cmp +SELECT * FROM INT8_TBL WHERE q2 = '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 032 +SELECT * FROM INT8_TBL WHERE q2 <> '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 033 +SELECT * FROM INT8_TBL WHERE q2 < '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 034 +SELECT * FROM INT8_TBL WHERE q2 > '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 035 +SELECT * FROM INT8_TBL WHERE q2 <= '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 036 +SELECT * FROM INT8_TBL WHERE q2 >= '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 037 +-- int2/int8 cmp +SELECT * FROM INT8_TBL WHERE '123'::int2 = q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 038 +SELECT * FROM INT8_TBL WHERE '123'::int2 <> q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 039 +SELECT * FROM INT8_TBL WHERE '123'::int2 < q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 040 +SELECT * FROM INT8_TBL WHERE '123'::int2 > q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 041 +SELECT * FROM INT8_TBL WHERE '123'::int2 <= q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 042 +SELECT * FROM INT8_TBL WHERE '123'::int2 >= q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 043 +SELECT q1 AS plus, -q1 AS minus FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 044 +SELECT q1, q2, q1 + q2 AS plus FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 045 +SELECT q1, q2, q1 - q2 AS minus FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 046 +SELECT q1, q2, q1 * q2 AS multiply FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 047 +SELECT q1, q2, q1 * q2 AS multiply FROM INT8_TBL + WHERE q1 < 1000 or (q2 > 0 and q2 < 1000) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 048 +SELECT q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 049 +SELECT q1, float8(q1) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="float8" function="float8" schema="" ctx=Call +STMT: SelectStmt +== 050 +SELECT q2, float8(q2) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="float8" function="float8" schema="" ctx=Call +STMT: SelectStmt +== 051 +SELECT 37 + q1 AS plus4 FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 052 +SELECT 37 - q1 AS minus4 FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 053 +SELECT 2 * q1 AS "twice int4" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 054 +SELECT q1 * 2 AS "twice int4" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 055 +-- int8 op int4 +SELECT q1 + 42::int4 AS "8plus4", q1 - 42::int4 AS "8minus4", q1 * 42::int4 AS "8mul4", q1 / 42::int4 AS "8div4" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 056 +-- int4 op int8 +SELECT 246::int4 + q1 AS "4plus8", 246::int4 - q1 AS "4minus8", 246::int4 * q1 AS "4mul8", 246::int4 / q1 AS "4div8" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 057 +-- int8 op int2 +SELECT q1 + 42::int2 AS "8plus2", q1 - 42::int2 AS "8minus2", q1 * 42::int2 AS "8mul2", q1 / 42::int2 AS "8div2" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 058 +-- int2 op int8 +SELECT 246::int2 + q1 AS "2plus8", 246::int2 - q1 AS "2minus8", 246::int2 * q1 AS "2mul8", 246::int2 / q1 AS "2div8" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 059 +SELECT q2, abs(q2) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT min(q1), min(q2) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT max(q1), max(q2) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 062 +-- TO_CHAR() +|-- +SELECT to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') + FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT to_char(q1, '9G999G999G999G999G999D999G999'), to_char(q2, '9,999,999,999,999,999.999,999') + FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT to_char( (q1 * -1), '9999999999999999PR'), to_char( (q2 * -1), '9999999999999999.999PR') + FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 065 +SELECT to_char( (q1 * -1), '9999999999999999S'), to_char( (q2 * -1), 'S9999999999999999') + FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 066 +SELECT to_char(q2, 'MI9999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT to_char(q2, 'FMS9999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT to_char(q2, 'FM9999999999999999THPR') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT to_char(q2, 'SG9999999999999999th') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT to_char(q2, '0999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT to_char(q2, 'S0999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 072 +SELECT to_char(q2, 'FM0999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 073 +SELECT to_char(q2, 'FM9999999999999999.000') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT to_char(q2, 'L9999999999999999.000') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 075 +SELECT to_char(q2, 'FM9999999999999999.999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT to_char(q2, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 077 +SELECT to_char(q2, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT to_char(q2, '999999SG9999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 079 +-- check min/max values and overflow behavior + +select '-9223372036854775808'::int8 +-- +STMT: SelectStmt +== 080 +select '-9223372036854775809'::int8 +-- +STMT: SelectStmt +== 081 +select '9223372036854775807'::int8 +-- +STMT: SelectStmt +== 082 +select '9223372036854775808'::int8 +-- +STMT: SelectStmt +== 083 +select -('-9223372036854775807'::int8) +-- +STMT: SelectStmt +== 084 +select -('-9223372036854775808'::int8) +-- +STMT: SelectStmt +== 085 +select 0::int8 - '-9223372036854775808'::int8 +-- +STMT: SelectStmt +== 086 +select '9223372036854775800'::int8 + '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 087 +select '-9223372036854775800'::int8 + '-9223372036854775800'::int8 +-- +STMT: SelectStmt +== 088 +select '9223372036854775800'::int8 - '-9223372036854775800'::int8 +-- +STMT: SelectStmt +== 089 +select '-9223372036854775800'::int8 - '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 090 +select '9223372036854775800'::int8 * '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 091 +select '9223372036854775800'::int8 / '0'::int8 +-- +STMT: SelectStmt +== 092 +select '9223372036854775800'::int8 % '0'::int8 +-- +STMT: SelectStmt +== 093 +select abs('-9223372036854775808'::int8) +-- +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: SelectStmt +== 094 +select '9223372036854775800'::int8 + '100'::int4 +-- +STMT: SelectStmt +== 095 +select '-9223372036854775800'::int8 - '100'::int4 +-- +STMT: SelectStmt +== 096 +select '9223372036854775800'::int8 * '100'::int4 +-- +STMT: SelectStmt +== 097 +select '100'::int4 + '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 098 +select '-100'::int4 - '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 099 +select '100'::int4 * '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 100 +select '9223372036854775800'::int8 + '100'::int2 +-- +STMT: SelectStmt +== 101 +select '-9223372036854775800'::int8 - '100'::int2 +-- +STMT: SelectStmt +== 102 +select '9223372036854775800'::int8 * '100'::int2 +-- +STMT: SelectStmt +== 103 +select '-9223372036854775808'::int8 / '0'::int2 +-- +STMT: SelectStmt +== 104 +select '100'::int2 + '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 105 +select '-100'::int2 - '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 106 +select '100'::int2 * '9223372036854775800'::int8 +-- +STMT: SelectStmt +== 107 +select '100'::int2 / '0'::int8 +-- +STMT: SelectStmt +== 108 +SELECT CAST(q1 AS int4) FROM int8_tbl WHERE q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 109 +SELECT CAST(q1 AS int4) FROM int8_tbl WHERE q2 <> 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 110 +SELECT CAST(q1 AS int2) FROM int8_tbl WHERE q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 111 +SELECT CAST(q1 AS int2) FROM int8_tbl WHERE q2 <> 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 112 +SELECT CAST('42'::int2 AS int8), CAST('-37'::int2 AS int8) +-- +STMT: SelectStmt +== 113 +SELECT CAST(q1 AS float4), CAST(q2 AS float8) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 114 +SELECT CAST('36854775807.0'::float4 AS int8) +-- +STMT: SelectStmt +== 115 +SELECT CAST('922337203685477580700.0'::float8 AS int8) +-- +STMT: SelectStmt +== 116 +SELECT CAST(q1 AS oid) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 117 +SELECT oid::int8 FROM pg_class WHERE relname = 'pg_class' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 118 +-- bit operations + +SELECT q1, q2, q1 & q2 AS "and", q1 | q2 AS "or", q1 # q2 AS "xor", ~q1 AS "not" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 119 +SELECT q1, q1 << 2 AS "shl", q1 >> 3 AS "shr" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 120 +-- generate_series + +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 121 +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 0) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 122 +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 2) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 123 +-- corner case +SELECT (-1::int8<<63)::text +-- +STMT: SelectStmt +== 124 +SELECT ((-1::int8<<63)+1)::text +-- +STMT: SelectStmt +== 125 +-- check sane handling of INT64_MIN overflow cases +SELECT (-9223372036854775808)::int8 * (-1)::int8 +-- +STMT: SelectStmt +== 126 +SELECT (-9223372036854775808)::int8 / (-1)::int8 +-- +STMT: SelectStmt +== 127 +SELECT (-9223372036854775808)::int8 % (-1)::int8 +-- +STMT: SelectStmt +== 128 +SELECT (-9223372036854775808)::int8 * (-1)::int4 +-- +STMT: SelectStmt +== 129 +SELECT (-9223372036854775808)::int8 / (-1)::int4 +-- +STMT: SelectStmt +== 130 +SELECT (-9223372036854775808)::int8 % (-1)::int4 +-- +STMT: SelectStmt +== 131 +SELECT (-9223372036854775808)::int8 * (-1)::int2 +-- +STMT: SelectStmt +== 132 +SELECT (-9223372036854775808)::int8 / (-1)::int2 +-- +STMT: SelectStmt +== 133 +SELECT (-9223372036854775808)::int8 % (-1)::int2 +-- +STMT: SelectStmt +== 134 +-- check rounding when casting from float +SELECT x, x::int8 AS int8_value +FROM (VALUES (-2.5::float8), + (-1.5::float8), + (-0.5::float8), + (0.0::float8), + (0.5::float8), + (1.5::float8), + (2.5::float8)) t(x) +-- +STMT: SelectStmt +== 135 +-- check rounding when casting from numeric +SELECT x, x::int8 AS int8_value +FROM (VALUES (-2.5::numeric), + (-1.5::numeric), + (-0.5::numeric), + (0.0::numeric), + (0.5::numeric), + (1.5::numeric), + (2.5::numeric)) t(x) +-- +STMT: SelectStmt +== 136 +-- test gcd() +SELECT a, b, gcd(a, b), gcd(a, -b), gcd(b, a), gcd(-b, a) +FROM (VALUES (0::int8, 0::int8), + (0::int8, 29893644334::int8), + (288484263558::int8, 29893644334::int8), + (-288484263558::int8, 29893644334::int8), + ((-9223372036854775808)::int8, 1::int8), + ((-9223372036854775808)::int8, 9223372036854775807::int8), + ((-9223372036854775808)::int8, 4611686018427387904::int8)) AS v(a, b) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +== 137 +SELECT gcd((-9223372036854775808)::int8, 0::int8) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +== 138 +-- overflow +SELECT gcd((-9223372036854775808)::int8, (-9223372036854775808)::int8) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +== 139 +-- overflow + +-- test lcm() +SELECT a, b, lcm(a, b), lcm(a, -b), lcm(b, a), lcm(-b, a) +FROM (VALUES (0::int8, 0::int8), + (0::int8, 29893644334::int8), + (29893644334::int8, 29893644334::int8), + (288484263558::int8, 29893644334::int8), + (-288484263558::int8, 29893644334::int8), + ((-9223372036854775808)::int8, 0::int8)) AS v(a, b) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +== 140 +SELECT lcm((-9223372036854775808)::int8, 1::int8) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +== 141 +-- overflow +SELECT lcm(9223372036854775807::int8, 9223372036854775806::int8) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +== 142 +-- overflow + + +-- non-decimal literals + +SELECT int8 '0b100101' +-- +STMT: SelectStmt +== 143 +SELECT int8 '0o273' +-- +STMT: SelectStmt +== 144 +SELECT int8 '0x42F' +-- +STMT: SelectStmt +== 145 +SELECT int8 '0b' +-- +STMT: SelectStmt +== 146 +SELECT int8 '0o' +-- +STMT: SelectStmt +== 147 +SELECT int8 '0x' +-- +STMT: SelectStmt +== 148 +-- cases near overflow +SELECT int8 '0b111111111111111111111111111111111111111111111111111111111111111' +-- +STMT: SelectStmt +== 149 +SELECT int8 '0b1000000000000000000000000000000000000000000000000000000000000000' +-- +STMT: SelectStmt +== 150 +SELECT int8 '0o777777777777777777777' +-- +STMT: SelectStmt +== 151 +SELECT int8 '0o1000000000000000000000' +-- +STMT: SelectStmt +== 152 +SELECT int8 '0x7FFFFFFFFFFFFFFF' +-- +STMT: SelectStmt +== 153 +SELECT int8 '0x8000000000000000' +-- +STMT: SelectStmt +== 154 +SELECT int8 '-0b1000000000000000000000000000000000000000000000000000000000000000' +-- +STMT: SelectStmt +== 155 +SELECT int8 '-0b1000000000000000000000000000000000000000000000000000000000000001' +-- +STMT: SelectStmt +== 156 +SELECT int8 '-0o1000000000000000000000' +-- +STMT: SelectStmt +== 157 +SELECT int8 '-0o1000000000000000000001' +-- +STMT: SelectStmt +== 158 +SELECT int8 '-0x8000000000000000' +-- +STMT: SelectStmt +== 159 +SELECT int8 '-0x8000000000000001' +-- +STMT: SelectStmt +== 160 +-- underscores + +SELECT int8 '1_000_000' +-- +STMT: SelectStmt +== 161 +SELECT int8 '1_2_3' +-- +STMT: SelectStmt +== 162 +SELECT int8 '0x1EEE_FFFF' +-- +STMT: SelectStmt +== 163 +SELECT int8 '0o2_73' +-- +STMT: SelectStmt +== 164 +SELECT int8 '0b_10_0101' +-- +STMT: SelectStmt +== 165 +-- error cases +SELECT int8 '_100' +-- +STMT: SelectStmt +== 166 +SELECT int8 '100_' +-- +STMT: SelectStmt +== 167 +SELECT int8 '100__000' +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/interval.metadata.json b/parser/testdata/summary/postgres_regress/interval.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/interval.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/interval.test b/parser/testdata/summary/postgres_regress/interval.test new file mode 100644 index 0000000..d0d0cfa --- /dev/null +++ b/parser/testdata/summary/postgres_regress/interval.test @@ -0,0 +1,2252 @@ +== 001 +|-- +-- INTERVAL +|-- + +SET DATESTYLE = 'ISO' +-- +STMT: VariableSetStmt +== 002 +SET IntervalStyle to postgres +-- +STMT: VariableSetStmt +== 003 +-- check acceptance of "time zone style" +SELECT INTERVAL '01:00' AS "One hour" +-- +STMT: SelectStmt +== 004 +SELECT INTERVAL '+02:00' AS "Two hours" +-- +STMT: SelectStmt +== 005 +SELECT INTERVAL '-08:00' AS "Eight hours" +-- +STMT: SelectStmt +== 006 +SELECT INTERVAL '-1 +02:03' AS "22 hours ago..." +-- +STMT: SelectStmt +== 007 +SELECT INTERVAL '-1 days +02:03' AS "22 hours ago..." +-- +STMT: SelectStmt +== 008 +SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours" +-- +STMT: SelectStmt +== 009 +SELECT INTERVAL '1.5 months' AS "One month 15 days" +-- +STMT: SelectStmt +== 010 +SELECT INTERVAL '10 years -11 month -12 days +13:14' AS "9 years..." +-- +STMT: SelectStmt +== 011 +SELECT INTERVAL 'infinity' AS "eternity" +-- +STMT: SelectStmt +== 012 +SELECT INTERVAL '-infinity' AS "beginning of time" +-- +STMT: SelectStmt +== 013 +CREATE TABLE INTERVAL_TBL (f1 interval) +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DDL +STMT: CreateStmt +== 014 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 1 minute') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 5 hour') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 10 day') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 34 year') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 3 months') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 14 seconds ago') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO INTERVAL_TBL (f1) VALUES ('1 day 2 hours 3 minutes 4 seconds') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO INTERVAL_TBL (f1) VALUES ('6 years') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months 12 hours') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO INTERVAL_TBL (f1) VALUES ('infinity') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO INTERVAL_TBL (f1) VALUES ('-infinity') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +-- badly formatted interval +INSERT INTO INTERVAL_TBL (f1) VALUES ('badly formatted interval') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 30 eons ago') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +-- Test non-error-throwing API +SELECT pg_input_is_valid('1.5 weeks', 'interval') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT pg_input_is_valid('garbage', 'interval') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT pg_input_is_valid('@ 30 eons ago', 'interval') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT * FROM pg_input_error_info('garbage', 'interval') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT * FROM pg_input_error_info('@ 30 eons ago', 'interval') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 033 +-- test interval operators + +SELECT * FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +STMT: SelectStmt +== 034 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 <> interval '@ 10 days' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +== 035 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 <= interval '@ 5 hours' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +== 036 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 < interval '@ 1 day' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +== 037 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 = interval '@ 34 years' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +== 038 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 >= interval '@ 1 month' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +== 039 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 > interval '@ 3 seconds ago' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +== 040 +SELECT r1.*, r2.* + FROM INTERVAL_TBL r1, INTERVAL_TBL r2 + WHERE r1.f1 > r2.f1 + ORDER BY r1.f1, r2.f1 +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "r1"="interval_tbl" +ALIAS: "r2"="interval_tbl" +FILTER: schema="" table="r1" column="f1" +FILTER: schema="" table="r2" column="f1" +STMT: SelectStmt +== 041 +-- test unary minus + +SELECT f1, -f1 FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +STMT: SelectStmt +== 042 +SELECT -('-2147483648 months'::interval) +-- +STMT: SelectStmt +== 043 +-- should fail +SELECT -('-2147483647 months'::interval) +-- +STMT: SelectStmt +== 044 +-- ok +SELECT -('-2147483648 days'::interval) +-- +STMT: SelectStmt +== 045 +-- should fail +SELECT -('-2147483647 days'::interval) +-- +STMT: SelectStmt +== 046 +-- ok +SELECT -('-9223372036854775808 us'::interval) +-- +STMT: SelectStmt +== 047 +-- should fail +SELECT -('-9223372036854775807 us'::interval) +-- +STMT: SelectStmt +== 048 +-- ok +SELECT -('-2147483647 months -2147483647 days -9223372036854775807 us'::interval) +-- +STMT: SelectStmt +== 049 +-- should fail + +-- Test intervals that are large enough to overflow 64 bits in comparisons +CREATE TEMP TABLE INTERVAL_TBL_OF (f1 interval) +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DDL +STMT: CreateStmt +== 050 +INSERT INTO INTERVAL_TBL_OF (f1) VALUES + ('2147483647 days 2147483647 months'), + ('2147483647 days -2147483648 months'), + ('1 year'), + ('-2147483648 days 2147483647 months'), + ('-2147483648 days -2147483648 months') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +-- these should fail as out-of-range +INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('2147483648 days') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('-2147483649 days') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('2147483647 years') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('-2147483648 years') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +-- Test edge-case overflow detection in interval multiplication +select extract(epoch from '256 microseconds'::interval * (2^55)::float8) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 056 +SELECT r1.*, r2.* + FROM INTERVAL_TBL_OF r1, INTERVAL_TBL_OF r2 + WHERE r1.f1 > r2.f1 + ORDER BY r1.f1, r2.f1 +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +ALIAS: "r1"="interval_tbl_of" +ALIAS: "r2"="interval_tbl_of" +FILTER: schema="" table="r1" column="f1" +FILTER: schema="" table="r2" column="f1" +STMT: SelectStmt +== 057 +CREATE INDEX ON INTERVAL_TBL_OF USING btree (f1) +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DDL +STMT: IndexStmt +== 058 +SET enable_seqscan TO false +-- +STMT: VariableSetStmt +== 059 +EXPLAIN (COSTS OFF) +SELECT f1 FROM INTERVAL_TBL_OF r1 ORDER BY f1 +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +ALIAS: "r1"="interval_tbl_of" +STMT: ExplainStmt +STMT: SelectStmt +== 060 +SELECT f1 FROM INTERVAL_TBL_OF r1 ORDER BY f1 +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +ALIAS: "r1"="interval_tbl_of" +STMT: SelectStmt +== 061 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 062 +-- subtracting about-to-overflow values should result in 0 +SELECT f1 - f1 FROM INTERVAL_TBL_OF +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +STMT: SelectStmt +== 063 +DROP TABLE INTERVAL_TBL_OF +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DDL +STMT: DropStmt +== 064 +-- Test multiplication and division with intervals. +-- Floating point arithmetic rounding errors can lead to unexpected results, +-- though the code attempts to do the right thing and round up to days and +-- minutes to avoid results such as '3 days 24:00 hours' or '14:20:60'. +-- Note that it is expected for some day components to be greater than 29 and +-- some time components be greater than 23:59:59 due to how intervals are +-- stored internally. + +CREATE TABLE INTERVAL_MULDIV_TBL (span interval) +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=DDL +STMT: CreateStmt +== 065 +COPY INTERVAL_MULDIV_TBL FROM STDIN +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: CopyStmt +== 066 +SELECT span * 0.3 AS product +FROM INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: SelectStmt +== 067 +SELECT span * 8.2 AS product +FROM INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: SelectStmt +== 068 +SELECT span / 10 AS quotient +FROM INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: SelectStmt +== 069 +SELECT span / 100 AS quotient +FROM INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: SelectStmt +== 070 +DROP TABLE INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=DDL +STMT: DropStmt +== 071 +SET DATESTYLE = 'postgres' +-- +STMT: VariableSetStmt +== 072 +SET IntervalStyle to postgres_verbose +-- +STMT: VariableSetStmt +== 073 +SELECT * FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +STMT: SelectStmt +== 074 +-- multiplication and division overflow test cases +SELECT '3000000 months'::interval * 1000 +-- +STMT: SelectStmt +== 075 +SELECT '3000000 months'::interval / 0.001 +-- +STMT: SelectStmt +== 076 +SELECT '3000000 days'::interval * 1000 +-- +STMT: SelectStmt +== 077 +SELECT '3000000 days'::interval / 0.001 +-- +STMT: SelectStmt +== 078 +SELECT '1 month 2146410 days'::interval * 1000.5002 +-- +STMT: SelectStmt +== 079 +SELECT '4611686018427387904 usec'::interval / 0.1 +-- +STMT: SelectStmt +== 080 +-- test avg(interval), which is somewhat fragile since people have been +-- known to change the allowed input syntax for type interval without +-- updating pg_aggregate.agginitval + +select avg(f1) from interval_tbl where isfinite(f1) +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 081 +-- test long interval input +select '4 millenniums 5 centuries 4 decades 1 year 4 months 4 days 17 minutes 31 seconds'::interval +-- +STMT: SelectStmt +== 082 +-- test long interval output +-- Note: the actual maximum length of the interval output is longer, +-- but we need the test to work for both integer and floating-point +-- timestamps. +select '100000000y 10mon -1000000000d -100000h -10min -10.000001s ago'::interval +-- +STMT: SelectStmt +== 083 +-- test justify_hours() and justify_days() + +SELECT justify_hours(interval '6 months 3 days 52 hours 3 minutes 2 seconds') as "6 mons 5 days 4 hours 3 mins 2 seconds" +-- +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +STMT: SelectStmt +== 084 +SELECT justify_days(interval '6 months 36 days 5 hours 4 minutes 3 seconds') as "7 mons 6 days 5 hours 4 mins 3 seconds" +-- +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +STMT: SelectStmt +== 085 +SELECT justify_hours(interval '2147483647 days 24 hrs') +-- +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT justify_days(interval '2147483647 months 30 days') +-- +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +STMT: SelectStmt +== 087 +-- test justify_interval() + +SELECT justify_interval(interval '1 month -1 hour') as "1 month -1 hour" +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 088 +SELECT justify_interval(interval '2147483647 days 24 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 089 +SELECT justify_interval(interval '-2147483648 days -24 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 090 +SELECT justify_interval(interval '2147483647 months 30 days') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 091 +SELECT justify_interval(interval '-2147483648 months -30 days') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 092 +SELECT justify_interval(interval '2147483647 months 30 days -24 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 093 +SELECT justify_interval(interval '-2147483648 months -30 days 24 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 094 +SELECT justify_interval(interval '2147483647 months -30 days 1440 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 095 +SELECT justify_interval(interval '-2147483648 months 30 days -1440 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +== 096 +-- test fractional second input, and detection of duplicate units +SET DATESTYLE = 'ISO' +-- +STMT: VariableSetStmt +== 097 +SET IntervalStyle TO postgres +-- +STMT: VariableSetStmt +== 098 +SELECT '1 millisecond'::interval, '1 microsecond'::interval, + '500 seconds 99 milliseconds 51 microseconds'::interval +-- +STMT: SelectStmt +== 099 +SELECT '3 days 5 milliseconds'::interval +-- +STMT: SelectStmt +== 100 +SELECT '1 second 2 seconds'::interval +-- +STMT: SelectStmt +== 101 +-- error +SELECT '10 milliseconds 20 milliseconds'::interval +-- +STMT: SelectStmt +== 102 +-- error +SELECT '5.5 seconds 3 milliseconds'::interval +-- +STMT: SelectStmt +== 103 +-- error +SELECT '1:20:05 5 microseconds'::interval +-- +STMT: SelectStmt +== 104 +-- error +SELECT '1 day 1 day'::interval +-- +STMT: SelectStmt +== 105 +-- error +SELECT interval '1-2' +-- +STMT: SelectStmt +== 106 +-- SQL year-month literal +SELECT interval '999' second +-- +STMT: SelectStmt +== 107 +-- oversize leading field is ok +SELECT interval '999' minute +-- +STMT: SelectStmt +== 108 +SELECT interval '999' hour +-- +STMT: SelectStmt +== 109 +SELECT interval '999' day +-- +STMT: SelectStmt +== 110 +SELECT interval '999' month +-- +STMT: SelectStmt +== 111 +-- test SQL-spec syntaxes for restricted field sets +SELECT interval '1' year +-- +STMT: SelectStmt +== 112 +SELECT interval '2' month +-- +STMT: SelectStmt +== 113 +SELECT interval '3' day +-- +STMT: SelectStmt +== 114 +SELECT interval '4' hour +-- +STMT: SelectStmt +== 115 +SELECT interval '5' minute +-- +STMT: SelectStmt +== 116 +SELECT interval '6' second +-- +STMT: SelectStmt +== 117 +SELECT interval '1' year to month +-- +STMT: SelectStmt +== 118 +SELECT interval '1-2' year to month +-- +STMT: SelectStmt +== 119 +SELECT interval '1 2' day to hour +-- +STMT: SelectStmt +== 120 +SELECT interval '1 2:03' day to hour +-- +STMT: SelectStmt +== 121 +SELECT interval '1 2:03:04' day to hour +-- +STMT: SelectStmt +== 122 +SELECT interval '1 2' day to minute +-- +STMT: SelectStmt +== 123 +SELECT interval '1 2:03' day to minute +-- +STMT: SelectStmt +== 124 +SELECT interval '1 2:03:04' day to minute +-- +STMT: SelectStmt +== 125 +SELECT interval '1 2' day to second +-- +STMT: SelectStmt +== 126 +SELECT interval '1 2:03' day to second +-- +STMT: SelectStmt +== 127 +SELECT interval '1 2:03:04' day to second +-- +STMT: SelectStmt +== 128 +SELECT interval '1 2' hour to minute +-- +STMT: SelectStmt +== 129 +SELECT interval '1 2:03' hour to minute +-- +STMT: SelectStmt +== 130 +SELECT interval '1 2:03:04' hour to minute +-- +STMT: SelectStmt +== 131 +SELECT interval '1 2' hour to second +-- +STMT: SelectStmt +== 132 +SELECT interval '1 2:03' hour to second +-- +STMT: SelectStmt +== 133 +SELECT interval '1 2:03:04' hour to second +-- +STMT: SelectStmt +== 134 +SELECT interval '1 2' minute to second +-- +STMT: SelectStmt +== 135 +SELECT interval '1 2:03' minute to second +-- +STMT: SelectStmt +== 136 +SELECT interval '1 2:03:04' minute to second +-- +STMT: SelectStmt +== 137 +SELECT interval '1 +2:03' minute to second +-- +STMT: SelectStmt +== 138 +SELECT interval '1 +2:03:04' minute to second +-- +STMT: SelectStmt +== 139 +SELECT interval '1 -2:03' minute to second +-- +STMT: SelectStmt +== 140 +SELECT interval '1 -2:03:04' minute to second +-- +STMT: SelectStmt +== 141 +SELECT interval '123 11' day to hour +-- +STMT: SelectStmt +== 142 +-- ok +SELECT interval '123 11' day +-- +STMT: SelectStmt +== 143 +-- not ok +SELECT interval '123 11' +-- +STMT: SelectStmt +== 144 +-- not ok, too ambiguous +SELECT interval '123 2:03 -2:04' +-- +STMT: SelectStmt +== 145 +-- not ok, redundant hh:mm fields + +-- test syntaxes for restricted precision +SELECT interval(0) '1 day 01:23:45.6789' +-- +STMT: SelectStmt +== 146 +SELECT interval(2) '1 day 01:23:45.6789' +-- +STMT: SelectStmt +== 147 +SELECT interval '12:34.5678' minute to second(2) +-- +STMT: SelectStmt +== 148 +-- per SQL spec +SELECT interval '1.234' second +-- +STMT: SelectStmt +== 149 +SELECT interval '1.234' second(2) +-- +STMT: SelectStmt +== 150 +SELECT interval '1 2.345' day to second(2) +-- +STMT: SelectStmt +== 151 +SELECT interval '1 2:03' day to second(2) +-- +STMT: SelectStmt +== 152 +SELECT interval '1 2:03.4567' day to second(2) +-- +STMT: SelectStmt +== 153 +SELECT interval '1 2:03:04.5678' day to second(2) +-- +STMT: SelectStmt +== 154 +SELECT interval '1 2.345' hour to second(2) +-- +STMT: SelectStmt +== 155 +SELECT interval '1 2:03.45678' hour to second(2) +-- +STMT: SelectStmt +== 156 +SELECT interval '1 2:03:04.5678' hour to second(2) +-- +STMT: SelectStmt +== 157 +SELECT interval '1 2.3456' minute to second(2) +-- +STMT: SelectStmt +== 158 +SELECT interval '1 2:03.5678' minute to second(2) +-- +STMT: SelectStmt +== 159 +SELECT interval '1 2:03:04.5678' minute to second(2) +-- +STMT: SelectStmt +== 160 +SELECT interval '2562047788:00:54.775807' second(2) +-- +STMT: SelectStmt +== 161 +-- out of range +SELECT interval '-2562047788:00:54.775807' second(2) +-- +STMT: SelectStmt +== 162 +-- out of range + +-- test casting to restricted precision (bug #14479) +SELECT f1, f1::INTERVAL DAY TO MINUTE AS "minutes", + (f1 + INTERVAL '1 month')::INTERVAL MONTH::INTERVAL YEAR AS "years" + FROM interval_tbl +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +STMT: SelectStmt +== 163 +-- test inputting and outputting SQL standard interval literals +SET IntervalStyle TO sql_standard +-- +STMT: VariableSetStmt +== 164 +SELECT interval '0' AS "zero", + interval '1-2' year to month AS "year-month", + interval '1 2:03:04' day to second AS "day-time", + - interval '1-2' AS "negative year-month", + - interval '1 2:03:04' AS "negative day-time" +-- +STMT: SelectStmt +== 165 +-- test input of some not-quite-standard interval values in the sql style +SET IntervalStyle TO postgres +-- +STMT: VariableSetStmt +== 166 +SELECT interval '+1 -1:00:00', + interval '-1 +1:00:00', + interval '+1-2 -3 +4:05:06.789', + interval '-1-2 +3 -4:05:06.789' +-- +STMT: SelectStmt +== 167 +-- cases that trigger sign-matching rules in the sql style +SELECT interval '-23 hours 45 min 12.34 sec', + interval '-1 day 23 hours 45 min 12.34 sec', + interval '-1 year 2 months 1 day 23 hours 45 min 12.34 sec', + interval '-1 year 2 months 1 day 23 hours 45 min +12.34 sec' +-- +STMT: SelectStmt +== 168 +-- test output of couple non-standard interval values in the sql style +SET IntervalStyle TO sql_standard +-- +STMT: VariableSetStmt +== 169 +SELECT interval '1 day -1 hours', + interval '-1 days +1 hours', + interval '1 years 2 months -3 days 4 hours 5 minutes 6.789 seconds', + - interval '1 years 2 months -3 days 4 hours 5 minutes 6.789 seconds' +-- +STMT: SelectStmt +== 170 +-- cases that trigger sign-matching rules in the sql style +SELECT interval '-23 hours 45 min 12.34 sec', + interval '-1 day 23 hours 45 min 12.34 sec', + interval '-1 year 2 months 1 day 23 hours 45 min 12.34 sec', + interval '-1 year 2 months 1 day 23 hours 45 min +12.34 sec' +-- +STMT: SelectStmt +== 171 +-- edge case for sign-matching rules +SELECT interval '' +-- +STMT: SelectStmt +== 172 +-- error + +-- test outputting iso8601 intervals +SET IntervalStyle to iso_8601 +-- +STMT: VariableSetStmt +== 173 +select interval '0' AS "zero", + interval '1-2' AS "a year 2 months", + interval '1 2:03:04' AS "a bit over a day", + interval '2:03:04.45679' AS "a bit over 2 hours", + (interval '1-2' + interval '3 4:05:06.7') AS "all fields", + (interval '1-2' - interval '3 4:05:06.7') AS "mixed sign", + (- interval '1-2' + interval '3 4:05:06.7') AS "negative" +-- +STMT: SelectStmt +== 174 +-- test inputting ISO 8601 4.4.2.1 "Format With Time Unit Designators" +SET IntervalStyle to sql_standard +-- +STMT: VariableSetStmt +== 175 +select interval 'P0Y' AS "zero", + interval 'P1Y2M' AS "a year 2 months", + interval 'P1W' AS "a week", + interval 'P1DT2H3M4S' AS "a bit over a day", + interval 'P1Y2M3DT4H5M6.7S' AS "all fields", + interval 'P-1Y-2M-3DT-4H-5M-6.7S' AS "negative", + interval 'PT-0.1S' AS "fractional second" +-- +STMT: SelectStmt +== 176 +-- test inputting ISO 8601 4.4.2.2 "Alternative Format" +SET IntervalStyle to postgres +-- +STMT: VariableSetStmt +== 177 +select interval 'P00021015T103020' AS "ISO8601 Basic Format", + interval 'P0002-10-15T10:30:20' AS "ISO8601 Extended Format" +-- +STMT: SelectStmt +== 178 +-- Make sure optional ISO8601 alternative format fields are optional. +select interval 'P0002' AS "year only", + interval 'P0002-10' AS "year month", + interval 'P0002-10-15' AS "year month day", + interval 'P0002T1S' AS "year only plus time", + interval 'P0002-10T1S' AS "year month plus time", + interval 'P0002-10-15T1S' AS "year month day plus time", + interval 'PT10' AS "hour only", + interval 'PT10:30' AS "hour minute" +-- +STMT: SelectStmt +== 179 +-- Check handling of fractional fields in ISO8601 format. +select interval 'P1Y0M3DT4H5M6S' +-- +STMT: SelectStmt +== 180 +select interval 'P1.0Y0M3DT4H5M6S' +-- +STMT: SelectStmt +== 181 +select interval 'P1.1Y0M3DT4H5M6S' +-- +STMT: SelectStmt +== 182 +select interval 'P1.Y0M3DT4H5M6S' +-- +STMT: SelectStmt +== 183 +select interval 'P.1Y0M3DT4H5M6S' +-- +STMT: SelectStmt +== 184 +select interval 'P10.5e4Y' +-- +STMT: SelectStmt +== 185 +-- not per spec, but we've historically taken it +select interval 'P.Y0M3DT4H5M6S' +-- +STMT: SelectStmt +== 186 +-- error + +-- test a couple rounding cases that changed since 8.3 w/ HAVE_INT64_TIMESTAMP. +SET IntervalStyle to postgres_verbose +-- +STMT: VariableSetStmt +== 187 +select interval '-10 mons -3 days +03:55:06.70' +-- +STMT: SelectStmt +== 188 +select interval '1 year 2 mons 3 days 04:05:06.699999' +-- +STMT: SelectStmt +== 189 +select interval '0:0:0.7', interval '@ 0.70 secs', interval '0.7 seconds' +-- +STMT: SelectStmt +== 190 +-- test time fields using entire 64 bit microseconds range +select interval '2562047788.01521550194 hours' +-- +STMT: SelectStmt +== 191 +select interval '-2562047788.01521550222 hours' +-- +STMT: SelectStmt +== 192 +select interval '153722867280.912930117 minutes' +-- +STMT: SelectStmt +== 193 +select interval '-153722867280.912930133 minutes' +-- +STMT: SelectStmt +== 194 +select interval '9223372036854.775807 seconds' +-- +STMT: SelectStmt +== 195 +select interval '-9223372036854.775808 seconds' +-- +STMT: SelectStmt +== 196 +select interval '9223372036854775.807 milliseconds' +-- +STMT: SelectStmt +== 197 +select interval '-9223372036854775.808 milliseconds' +-- +STMT: SelectStmt +== 198 +select interval '9223372036854775807 microseconds' +-- +STMT: SelectStmt +== 199 +select interval '-9223372036854775808 microseconds' +-- +STMT: SelectStmt +== 200 +select interval 'PT2562047788H54.775807S' +-- +STMT: SelectStmt +== 201 +select interval 'PT-2562047788H-54.775808S' +-- +STMT: SelectStmt +== 202 +select interval 'PT2562047788:00:54.775807' +-- +STMT: SelectStmt +== 203 +select interval 'PT2562047788.0152155019444' +-- +STMT: SelectStmt +== 204 +select interval 'PT-2562047788.0152155022222' +-- +STMT: SelectStmt +== 205 +-- overflow each date/time field +select interval '2147483648 years' +-- +STMT: SelectStmt +== 206 +select interval '-2147483649 years' +-- +STMT: SelectStmt +== 207 +select interval '2147483648 months' +-- +STMT: SelectStmt +== 208 +select interval '-2147483649 months' +-- +STMT: SelectStmt +== 209 +select interval '2147483648 days' +-- +STMT: SelectStmt +== 210 +select interval '-2147483649 days' +-- +STMT: SelectStmt +== 211 +select interval '2562047789 hours' +-- +STMT: SelectStmt +== 212 +select interval '-2562047789 hours' +-- +STMT: SelectStmt +== 213 +select interval '153722867281 minutes' +-- +STMT: SelectStmt +== 214 +select interval '-153722867281 minutes' +-- +STMT: SelectStmt +== 215 +select interval '9223372036855 seconds' +-- +STMT: SelectStmt +== 216 +select interval '-9223372036855 seconds' +-- +STMT: SelectStmt +== 217 +select interval '9223372036854777 millisecond' +-- +STMT: SelectStmt +== 218 +select interval '-9223372036854777 millisecond' +-- +STMT: SelectStmt +== 219 +select interval '9223372036854775808 microsecond' +-- +STMT: SelectStmt +== 220 +select interval '-9223372036854775809 microsecond' +-- +STMT: SelectStmt +== 221 +select interval 'P2147483648' +-- +STMT: SelectStmt +== 222 +select interval 'P-2147483649' +-- +STMT: SelectStmt +== 223 +select interval 'P1-2147483647-2147483647' +-- +STMT: SelectStmt +== 224 +select interval 'PT2562047789' +-- +STMT: SelectStmt +== 225 +select interval 'PT-2562047789' +-- +STMT: SelectStmt +== 226 +-- overflow with date/time unit aliases +select interval '2147483647 weeks' +-- +STMT: SelectStmt +== 227 +select interval '-2147483648 weeks' +-- +STMT: SelectStmt +== 228 +select interval '2147483647 decades' +-- +STMT: SelectStmt +== 229 +select interval '-2147483648 decades' +-- +STMT: SelectStmt +== 230 +select interval '2147483647 centuries' +-- +STMT: SelectStmt +== 231 +select interval '-2147483648 centuries' +-- +STMT: SelectStmt +== 232 +select interval '2147483647 millennium' +-- +STMT: SelectStmt +== 233 +select interval '-2147483648 millennium' +-- +STMT: SelectStmt +== 234 +select interval '1 week 2147483647 days' +-- +STMT: SelectStmt +== 235 +select interval '-1 week -2147483648 days' +-- +STMT: SelectStmt +== 236 +select interval '2147483647 days 1 week' +-- +STMT: SelectStmt +== 237 +select interval '-2147483648 days -1 week' +-- +STMT: SelectStmt +== 238 +select interval 'P1W2147483647D' +-- +STMT: SelectStmt +== 239 +select interval 'P-1W-2147483648D' +-- +STMT: SelectStmt +== 240 +select interval 'P2147483647D1W' +-- +STMT: SelectStmt +== 241 +select interval 'P-2147483648D-1W' +-- +STMT: SelectStmt +== 242 +select interval '1 decade 2147483647 years' +-- +STMT: SelectStmt +== 243 +select interval '1 century 2147483647 years' +-- +STMT: SelectStmt +== 244 +select interval '1 millennium 2147483647 years' +-- +STMT: SelectStmt +== 245 +select interval '-1 decade -2147483648 years' +-- +STMT: SelectStmt +== 246 +select interval '-1 century -2147483648 years' +-- +STMT: SelectStmt +== 247 +select interval '-1 millennium -2147483648 years' +-- +STMT: SelectStmt +== 248 +select interval '2147483647 years 1 decade' +-- +STMT: SelectStmt +== 249 +select interval '2147483647 years 1 century' +-- +STMT: SelectStmt +== 250 +select interval '2147483647 years 1 millennium' +-- +STMT: SelectStmt +== 251 +select interval '-2147483648 years -1 decade' +-- +STMT: SelectStmt +== 252 +select interval '-2147483648 years -1 century' +-- +STMT: SelectStmt +== 253 +select interval '-2147483648 years -1 millennium' +-- +STMT: SelectStmt +== 254 +-- overflowing with fractional fields - postgres format +select interval '0.1 millennium 2147483647 months' +-- +STMT: SelectStmt +== 255 +select interval '0.1 centuries 2147483647 months' +-- +STMT: SelectStmt +== 256 +select interval '0.1 decades 2147483647 months' +-- +STMT: SelectStmt +== 257 +select interval '0.1 yrs 2147483647 months' +-- +STMT: SelectStmt +== 258 +select interval '-0.1 millennium -2147483648 months' +-- +STMT: SelectStmt +== 259 +select interval '-0.1 centuries -2147483648 months' +-- +STMT: SelectStmt +== 260 +select interval '-0.1 decades -2147483648 months' +-- +STMT: SelectStmt +== 261 +select interval '-0.1 yrs -2147483648 months' +-- +STMT: SelectStmt +== 262 +select interval '2147483647 months 0.1 millennium' +-- +STMT: SelectStmt +== 263 +select interval '2147483647 months 0.1 centuries' +-- +STMT: SelectStmt +== 264 +select interval '2147483647 months 0.1 decades' +-- +STMT: SelectStmt +== 265 +select interval '2147483647 months 0.1 yrs' +-- +STMT: SelectStmt +== 266 +select interval '-2147483648 months -0.1 millennium' +-- +STMT: SelectStmt +== 267 +select interval '-2147483648 months -0.1 centuries' +-- +STMT: SelectStmt +== 268 +select interval '-2147483648 months -0.1 decades' +-- +STMT: SelectStmt +== 269 +select interval '-2147483648 months -0.1 yrs' +-- +STMT: SelectStmt +== 270 +select interval '0.1 months 2147483647 days' +-- +STMT: SelectStmt +== 271 +select interval '-0.1 months -2147483648 days' +-- +STMT: SelectStmt +== 272 +select interval '2147483647 days 0.1 months' +-- +STMT: SelectStmt +== 273 +select interval '-2147483648 days -0.1 months' +-- +STMT: SelectStmt +== 274 +select interval '0.5 weeks 2147483647 days' +-- +STMT: SelectStmt +== 275 +select interval '-0.5 weeks -2147483648 days' +-- +STMT: SelectStmt +== 276 +select interval '2147483647 days 0.5 weeks' +-- +STMT: SelectStmt +== 277 +select interval '-2147483648 days -0.5 weeks' +-- +STMT: SelectStmt +== 278 +select interval '0.01 months 9223372036854775807 microseconds' +-- +STMT: SelectStmt +== 279 +select interval '-0.01 months -9223372036854775808 microseconds' +-- +STMT: SelectStmt +== 280 +select interval '9223372036854775807 microseconds 0.01 months' +-- +STMT: SelectStmt +== 281 +select interval '-9223372036854775808 microseconds -0.01 months' +-- +STMT: SelectStmt +== 282 +select interval '0.1 weeks 9223372036854775807 microseconds' +-- +STMT: SelectStmt +== 283 +select interval '-0.1 weeks -9223372036854775808 microseconds' +-- +STMT: SelectStmt +== 284 +select interval '9223372036854775807 microseconds 0.1 weeks' +-- +STMT: SelectStmt +== 285 +select interval '-9223372036854775808 microseconds -0.1 weeks' +-- +STMT: SelectStmt +== 286 +select interval '0.1 days 9223372036854775807 microseconds' +-- +STMT: SelectStmt +== 287 +select interval '-0.1 days -9223372036854775808 microseconds' +-- +STMT: SelectStmt +== 288 +select interval '9223372036854775807 microseconds 0.1 days' +-- +STMT: SelectStmt +== 289 +select interval '-9223372036854775808 microseconds -0.1 days' +-- +STMT: SelectStmt +== 290 +-- overflowing with fractional fields - ISO8601 format +select interval 'P0.1Y2147483647M' +-- +STMT: SelectStmt +== 291 +select interval 'P-0.1Y-2147483648M' +-- +STMT: SelectStmt +== 292 +select interval 'P2147483647M0.1Y' +-- +STMT: SelectStmt +== 293 +select interval 'P-2147483648M-0.1Y' +-- +STMT: SelectStmt +== 294 +select interval 'P0.1M2147483647D' +-- +STMT: SelectStmt +== 295 +select interval 'P-0.1M-2147483648D' +-- +STMT: SelectStmt +== 296 +select interval 'P2147483647D0.1M' +-- +STMT: SelectStmt +== 297 +select interval 'P-2147483648D-0.1M' +-- +STMT: SelectStmt +== 298 +select interval 'P0.5W2147483647D' +-- +STMT: SelectStmt +== 299 +select interval 'P-0.5W-2147483648D' +-- +STMT: SelectStmt +== 300 +select interval 'P2147483647D0.5W' +-- +STMT: SelectStmt +== 301 +select interval 'P-2147483648D-0.5W' +-- +STMT: SelectStmt +== 302 +select interval 'P0.01MT2562047788H54.775807S' +-- +STMT: SelectStmt +== 303 +select interval 'P-0.01MT-2562047788H-54.775808S' +-- +STMT: SelectStmt +== 304 +select interval 'P0.1DT2562047788H54.775807S' +-- +STMT: SelectStmt +== 305 +select interval 'P-0.1DT-2562047788H-54.775808S' +-- +STMT: SelectStmt +== 306 +select interval 'PT2562047788.1H54.775807S' +-- +STMT: SelectStmt +== 307 +select interval 'PT-2562047788.1H-54.775808S' +-- +STMT: SelectStmt +== 308 +select interval 'PT2562047788H0.1M54.775807S' +-- +STMT: SelectStmt +== 309 +select interval 'PT-2562047788H-0.1M-54.775808S' +-- +STMT: SelectStmt +== 310 +-- overflowing with fractional fields - ISO8601 alternative format +select interval 'P0.1-2147483647-00' +-- +STMT: SelectStmt +== 311 +select interval 'P00-0.1-2147483647' +-- +STMT: SelectStmt +== 312 +select interval 'P00-0.01-00T2562047788:00:54.775807' +-- +STMT: SelectStmt +== 313 +select interval 'P00-00-0.1T2562047788:00:54.775807' +-- +STMT: SelectStmt +== 314 +select interval 'PT2562047788.1:00:54.775807' +-- +STMT: SelectStmt +== 315 +select interval 'PT2562047788:01.:54.775807' +-- +STMT: SelectStmt +== 316 +-- overflowing with fractional fields - SQL standard format +select interval '0.1 2562047788:0:54.775807' +-- +STMT: SelectStmt +== 317 +select interval '0.1 2562047788:0:54.775808 ago' +-- +STMT: SelectStmt +== 318 +select interval '2562047788.1:0:54.775807' +-- +STMT: SelectStmt +== 319 +select interval '2562047788.1:0:54.775808 ago' +-- +STMT: SelectStmt +== 320 +select interval '2562047788:0.1:54.775807' +-- +STMT: SelectStmt +== 321 +select interval '2562047788:0.1:54.775808 ago' +-- +STMT: SelectStmt +== 322 +-- overflowing using AGO with INT_MIN +select interval '-2147483648 months ago' +-- +STMT: SelectStmt +== 323 +select interval '-2147483648 days ago' +-- +STMT: SelectStmt +== 324 +select interval '-9223372036854775808 microseconds ago' +-- +STMT: SelectStmt +== 325 +select interval '-2147483648 months -2147483648 days -9223372036854775808 microseconds ago' +-- +STMT: SelectStmt +== 326 +-- overflowing using make_interval +select make_interval(years := 178956971) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 327 +select make_interval(years := -178956971) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 328 +select make_interval(years := 1, months := 2147483647) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 329 +select make_interval(years := -1, months := -2147483648) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 330 +select make_interval(weeks := 306783379) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 331 +select make_interval(weeks := -306783379) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 332 +select make_interval(weeks := 1, days := 2147483647) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 333 +select make_interval(weeks := -1, days := -2147483648) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 334 +select make_interval(secs := 1e308) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 335 +select make_interval(secs := 1e18) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 336 +select make_interval(secs := -1e18) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 337 +select make_interval(mins := 1, secs := 9223372036800.0) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 338 +select make_interval(mins := -1, secs := -9223372036800.0) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 339 +-- test that INT_MIN number is formatted properly +SET IntervalStyle to postgres +-- +STMT: VariableSetStmt +== 340 +select interval '-2147483647 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +== 341 +SET IntervalStyle to sql_standard +-- +STMT: VariableSetStmt +== 342 +select interval '-2147483647 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +== 343 +SET IntervalStyle to iso_8601 +-- +STMT: VariableSetStmt +== 344 +select interval '-2147483647 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +== 345 +SET IntervalStyle to postgres_verbose +-- +STMT: VariableSetStmt +== 346 +select interval '-2147483647 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +== 347 +-- check that '30 days' equals '1 month' according to the hash function +select '30 days'::interval = '1 month'::interval as t +-- +STMT: SelectStmt +== 348 +select interval_hash('30 days'::interval) = interval_hash('1 month'::interval) as t +-- +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +STMT: SelectStmt +== 349 +-- numeric constructor +select make_interval(years := 2) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 350 +select make_interval(years := 1, months := 6) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 351 +select make_interval(years := 1, months := -1, weeks := 5, days := -7, hours := 25, mins := -180) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 352 +select make_interval() = make_interval(years := 0, months := 0, weeks := 0, days := 0, mins := 0, secs := 0.0) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 353 +select make_interval(hours := -2, mins := -10, secs := -25.3) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 354 +select make_interval(years := 'inf'::float::int) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 355 +select make_interval(months := 'NaN'::float::int) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 356 +select make_interval(secs := 'inf') +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 357 +select make_interval(secs := 'NaN') +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 358 +select make_interval(secs := 7e12) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +== 359 +|-- +-- test EXTRACT +|-- +SELECT f1, + EXTRACT(MICROSECOND FROM f1) AS MICROSECOND, + EXTRACT(MILLISECOND FROM f1) AS MILLISECOND, + EXTRACT(SECOND FROM f1) AS SECOND, + EXTRACT(MINUTE FROM f1) AS MINUTE, + EXTRACT(HOUR FROM f1) AS HOUR, + EXTRACT(DAY FROM f1) AS DAY, + EXTRACT(MONTH FROM f1) AS MONTH, + EXTRACT(QUARTER FROM f1) AS QUARTER, + EXTRACT(YEAR FROM f1) AS YEAR, + EXTRACT(DECADE FROM f1) AS DECADE, + EXTRACT(CENTURY FROM f1) AS CENTURY, + EXTRACT(MILLENNIUM FROM f1) AS MILLENNIUM, + EXTRACT(EPOCH FROM f1) AS EPOCH + FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 360 +SELECT EXTRACT(FORTNIGHT FROM INTERVAL '2 days') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 361 +-- error +SELECT EXTRACT(TIMEZONE FROM INTERVAL '2 days') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 362 +-- error + +SELECT EXTRACT(DECADE FROM INTERVAL '100 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 363 +SELECT EXTRACT(DECADE FROM INTERVAL '99 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 364 +SELECT EXTRACT(DECADE FROM INTERVAL '-99 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 365 +SELECT EXTRACT(DECADE FROM INTERVAL '-100 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 366 +SELECT EXTRACT(CENTURY FROM INTERVAL '100 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 367 +SELECT EXTRACT(CENTURY FROM INTERVAL '99 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 368 +SELECT EXTRACT(CENTURY FROM INTERVAL '-99 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 369 +SELECT EXTRACT(CENTURY FROM INTERVAL '-100 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 370 +-- date_part implementation is mostly the same as extract, so only +-- test a few cases for additional coverage. +SELECT f1, + date_part('microsecond', f1) AS microsecond, + date_part('millisecond', f1) AS millisecond, + date_part('second', f1) AS second, + date_part('epoch', f1) AS epoch + FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 371 +-- internal overflow test case +SELECT extract(epoch from interval '1000000000 days') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 372 +|-- +-- test infinite intervals +|-- + +-- largest finite intervals +SELECT interval '-2147483648 months -2147483648 days -9223372036854775807 us' +-- +STMT: SelectStmt +== 373 +SELECT interval '2147483647 months 2147483647 days 9223372036854775806 us' +-- +STMT: SelectStmt +== 374 +-- infinite intervals +SELECT interval '-2147483648 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +== 375 +SELECT interval '2147483647 months 2147483647 days 9223372036854775807 us' +-- +STMT: SelectStmt +== 376 +CREATE TABLE INFINITE_INTERVAL_TBL (i interval) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=DDL +STMT: CreateStmt +== 377 +INSERT INTO INFINITE_INTERVAL_TBL VALUES ('infinity'), ('-infinity'), ('1 year 2 days 3 hours') +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 378 +SELECT i, isfinite(i) FROM INFINITE_INTERVAL_TBL +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +STMT: SelectStmt +== 379 +-- test basic arithmetic +CREATE FUNCTION eval(expr text) +RETURNS text AS +$$ +DECLARE + result text; +BEGIN + EXECUTE 'select '||expr INTO result; + RETURN result; +EXCEPTION WHEN OTHERS THEN + RETURN SQLERRM; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="eval" function="eval" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 380 +SELECT d AS date, i AS interval, + eval(format('date %L + interval %L', d, i)) AS plus, + eval(format('date %L - interval %L', d, i)) AS minus +FROM (VALUES (date '-infinity'), + (date '1995-08-06'), + (date 'infinity')) AS t1(d), + (VALUES (interval '-infinity'), + (interval 'infinity')) AS t2(i) +-- +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 381 +SELECT i1 AS interval1, i2 AS interval2, + eval(format('interval %L + interval %L', i1, i2)) AS plus, + eval(format('interval %L - interval %L', i1, i2)) AS minus +FROM (VALUES (interval '-infinity'), + (interval '2 months'), + (interval 'infinity')) AS t1(i1), + (VALUES (interval '-infinity'), + (interval '10 days'), + (interval 'infinity')) AS t2(i2) +-- +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 382 +SELECT interval '2147483646 months 2147483646 days 9223372036854775806 us' + interval '1 month 1 day 1 us' +-- +STMT: SelectStmt +== 383 +SELECT interval '-2147483647 months -2147483647 days -9223372036854775807 us' + interval '-1 month -1 day -1 us' +-- +STMT: SelectStmt +== 384 +SELECT interval '2147483646 months 2147483646 days 9223372036854775806 us' - interval '-1 month -1 day -1 us' +-- +STMT: SelectStmt +== 385 +SELECT interval '-2147483647 months -2147483647 days -9223372036854775807 us' - interval '1 month 1 day 1 us' +-- +STMT: SelectStmt +== 386 +SELECT t AS timestamp, i AS interval, + eval(format('timestamp %L + interval %L', t, i)) AS plus, + eval(format('timestamp %L - interval %L', t, i)) AS minus +FROM (VALUES (timestamp '-infinity'), + (timestamp '1995-08-06 12:30:15'), + (timestamp 'infinity')) AS t1(t), + (VALUES (interval '-infinity'), + (interval 'infinity')) AS t2(i) +-- +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 387 +SELECT t AT TIME ZONE 'GMT' AS timestamptz, i AS interval, + eval(format('timestamptz %L + interval %L', t, i)) AS plus, + eval(format('timestamptz %L - interval %L', t, i)) AS minus +FROM (VALUES (timestamptz '-infinity'), + (timestamptz '1995-08-06 12:30:15 GMT'), + (timestamptz 'infinity')) AS t1(t), + (VALUES (interval '-infinity'), + (interval 'infinity')) AS t2(i) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 388 +-- time +/- infinite interval not supported +SELECT time '11:27:42' + interval 'infinity' +-- +STMT: SelectStmt +== 389 +SELECT time '11:27:42' + interval '-infinity' +-- +STMT: SelectStmt +== 390 +SELECT time '11:27:42' - interval 'infinity' +-- +STMT: SelectStmt +== 391 +SELECT time '11:27:42' - interval '-infinity' +-- +STMT: SelectStmt +== 392 +SELECT timetz '11:27:42' + interval 'infinity' +-- +STMT: SelectStmt +== 393 +SELECT timetz '11:27:42' + interval '-infinity' +-- +STMT: SelectStmt +== 394 +SELECT timetz '11:27:42' - interval 'infinity' +-- +STMT: SelectStmt +== 395 +SELECT timetz '11:27:42' - interval '-infinity' +-- +STMT: SelectStmt +== 396 +SELECT lhst.i lhs, + rhst.i rhs, + lhst.i < rhst.i AS lt, + lhst.i <= rhst.i AS le, + lhst.i = rhst.i AS eq, + lhst.i > rhst.i AS gt, + lhst.i >= rhst.i AS ge, + lhst.i <> rhst.i AS ne + FROM INFINITE_INTERVAL_TBL lhst CROSS JOIN INFINITE_INTERVAL_TBL rhst + WHERE NOT isfinite(lhst.i) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +ALIAS: "lhst"="infinite_interval_tbl" +ALIAS: "rhst"="infinite_interval_tbl" +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="lhst" column="i" +STMT: SelectStmt +== 397 +SELECT i AS interval, + -i AS um, + i * 2.0 AS mul, + i * -2.0 AS mul_neg, + i * 'infinity' AS mul_inf, + i * '-infinity' AS mul_inf_neg, + i / 3.0 AS div, + i / -3.0 AS div_neg + FROM INFINITE_INTERVAL_TBL + WHERE NOT isfinite(i) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 398 +SELECT -interval '-2147483647 months -2147483647 days -9223372036854775807 us' +-- +STMT: SelectStmt +== 399 +SELECT interval 'infinity' * 'nan' +-- +STMT: SelectStmt +== 400 +SELECT interval '-infinity' * 'nan' +-- +STMT: SelectStmt +== 401 +SELECT interval '-1073741824 months -1073741824 days -4611686018427387904 us' * 2 +-- +STMT: SelectStmt +== 402 +SELECT interval 'infinity' * 0 +-- +STMT: SelectStmt +== 403 +SELECT interval '-infinity' * 0 +-- +STMT: SelectStmt +== 404 +SELECT interval '0 days' * 'infinity'::float +-- +STMT: SelectStmt +== 405 +SELECT interval '0 days' * '-infinity'::float +-- +STMT: SelectStmt +== 406 +SELECT interval '5 days' * 'infinity'::float +-- +STMT: SelectStmt +== 407 +SELECT interval '5 days' * '-infinity'::float +-- +STMT: SelectStmt +== 408 +SELECT interval 'infinity' / 'infinity' +-- +STMT: SelectStmt +== 409 +SELECT interval 'infinity' / '-infinity' +-- +STMT: SelectStmt +== 410 +SELECT interval 'infinity' / 'nan' +-- +STMT: SelectStmt +== 411 +SELECT interval '-infinity' / 'infinity' +-- +STMT: SelectStmt +== 412 +SELECT interval '-infinity' / '-infinity' +-- +STMT: SelectStmt +== 413 +SELECT interval '-infinity' / 'nan' +-- +STMT: SelectStmt +== 414 +SELECT interval '-1073741824 months -1073741824 days -4611686018427387904 us' / 0.5 +-- +STMT: SelectStmt +== 415 +SELECT date_bin('infinity', timestamp '2001-02-16 20:38:40', timestamp '2001-02-16 20:05:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 416 +SELECT date_bin('-infinity', timestamp '2001-02-16 20:38:40', timestamp '2001-02-16 20:05:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 417 +SELECT i AS interval, date_trunc('hour', i) + FROM INFINITE_INTERVAL_TBL + WHERE NOT isfinite(i) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 418 +SELECT i AS interval, justify_days(i), justify_hours(i), justify_interval(i) + FROM INFINITE_INTERVAL_TBL + WHERE NOT isfinite(i) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 419 +SELECT timezone('infinity'::interval, '1995-08-06 12:12:12'::timestamp) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +== 420 +SELECT timezone('-infinity'::interval, '1995-08-06 12:12:12'::timestamp) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +== 421 +SELECT timezone('infinity'::interval, '1995-08-06 12:12:12'::timestamptz) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +== 422 +SELECT timezone('-infinity'::interval, '1995-08-06 12:12:12'::timestamptz) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +== 423 +SELECT timezone('infinity'::interval, '12:12:12'::time) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +== 424 +SELECT timezone('-infinity'::interval, '12:12:12'::time) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +== 425 +SELECT timezone('infinity'::interval, '12:12:12'::timetz) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +== 426 +SELECT timezone('-infinity'::interval, '12:12:12'::timetz) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +== 427 +SELECT 'infinity'::interval::time +-- +STMT: SelectStmt +== 428 +SELECT '-infinity'::interval::time +-- +STMT: SelectStmt +== 429 +SELECT to_char('infinity'::interval, 'YYYY') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 430 +SELECT to_char('-infinity'::interval, 'YYYY') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 431 +-- "ago" can only appear once at the end of an interval. +SELECT INTERVAL '42 days 2 seconds ago ago' +-- +STMT: SelectStmt +== 432 +SELECT INTERVAL '2 minutes ago 5 days' +-- +STMT: SelectStmt +== 433 +-- consecutive and dangling units are not allowed. +SELECT INTERVAL 'hour 5 months' +-- +STMT: SelectStmt +== 434 +SELECT INTERVAL '1 year months days 5 hours' +-- +STMT: SelectStmt +== 435 +-- unacceptable reserved words in interval. Only "infinity", "+infinity" and +-- "-infinity" are allowed. +SELECT INTERVAL 'now' +-- +STMT: SelectStmt +== 436 +SELECT INTERVAL 'today' +-- +STMT: SelectStmt +== 437 +SELECT INTERVAL 'tomorrow' +-- +STMT: SelectStmt +== 438 +SELECT INTERVAL 'allballs' +-- +STMT: SelectStmt +== 439 +SELECT INTERVAL 'epoch' +-- +STMT: SelectStmt +== 440 +SELECT INTERVAL 'yesterday' +-- +STMT: SelectStmt +== 441 +-- infinity specification should be the only thing +SELECT INTERVAL 'infinity years' +-- +STMT: SelectStmt +== 442 +SELECT INTERVAL 'infinity ago' +-- +STMT: SelectStmt +== 443 +SELECT INTERVAL '+infinity -infinity' +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/join.metadata.json b/parser/testdata/summary/postgres_regress/join.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/join.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/join.test b/parser/testdata/summary/postgres_regress/join.test new file mode 100644 index 0000000..d4ea86a --- /dev/null +++ b/parser/testdata/summary/postgres_regress/join.test @@ -0,0 +1,7366 @@ +== 001 +|-- +-- JOIN +-- Test JOIN clauses +|-- + +CREATE TABLE J1_TBL ( + i integer, + j integer, + t text +) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE J2_TBL ( + i integer, + k integer +) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO J1_TBL VALUES (1, 4, 'one') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO J1_TBL VALUES (2, 3, 'two') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO J1_TBL VALUES (3, 2, 'three') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO J1_TBL VALUES (4, 1, 'four') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO J1_TBL VALUES (5, 0, 'five') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO J1_TBL VALUES (6, 6, 'six') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO J1_TBL VALUES (7, 7, 'seven') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO J1_TBL VALUES (8, 8, 'eight') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO J1_TBL VALUES (0, NULL, 'zero') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO J1_TBL VALUES (NULL, NULL, 'null') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO J1_TBL VALUES (NULL, 0, 'zero') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO J2_TBL VALUES (1, -1) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO J2_TBL VALUES (2, 2) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO J2_TBL VALUES (3, -3) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO J2_TBL VALUES (2, 4) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO J2_TBL VALUES (5, -5) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO J2_TBL VALUES (5, -5) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO J2_TBL VALUES (0, NULL) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO J2_TBL VALUES (NULL, NULL) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO J2_TBL VALUES (NULL, 0) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +-- useful in some tests below +create temp table onerow() +-- +TABLE: name="onerow" schema="" table="onerow" ctx=DDL +STMT: CreateStmt +== 024 +insert into onerow default values +-- +TABLE: name="onerow" schema="" table="onerow" ctx=DML +STMT: InsertStmt +== 025 +analyze onerow +-- +TABLE: name="onerow" schema="" table="onerow" ctx=DDL +STMT: VacuumStmt +== 026 +|-- +-- CORRELATION NAMES +-- Make sure that table/column aliases are supported +-- before diving into more complex join syntax. +|-- + +SELECT * + FROM J1_TBL AS tx +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +ALIAS: "tx"="j1_tbl" +STMT: SelectStmt +== 027 +SELECT * + FROM J1_TBL tx +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +ALIAS: "tx"="j1_tbl" +STMT: SelectStmt +== 028 +SELECT * + FROM J1_TBL AS t1 (a, b, c) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +STMT: SelectStmt +== 029 +SELECT * + FROM J1_TBL t1 (a, b, c) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +STMT: SelectStmt +== 030 +SELECT * + FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +== 031 +SELECT t1.a, t2.e + FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e) + WHERE t1.a = t2.d +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="d" +STMT: SelectStmt +== 032 +|-- +-- CROSS JOIN +-- Qualifications are not allowed on cross joins, +-- which degenerate into a standard unqualified inner join. +|-- + +SELECT * + FROM J1_TBL CROSS JOIN J2_TBL +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 033 +-- ambiguous column +SELECT i, k, t + FROM J1_TBL CROSS JOIN J2_TBL +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 034 +-- resolve previous ambiguity by specifying the table name +SELECT t1.i, k, t + FROM J1_TBL t1 CROSS JOIN J2_TBL t2 +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +== 035 +SELECT ii, tt, kk + FROM (J1_TBL CROSS JOIN J2_TBL) + AS tx (ii, jj, tt, ii2, kk) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 036 +SELECT tx.ii, tx.jj, tx.kk + FROM (J1_TBL t1 (a, b, c) CROSS JOIN J2_TBL t2 (d, e)) + AS tx (ii, jj, tt, ii2, kk) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +== 037 +SELECT * + FROM J1_TBL CROSS JOIN J2_TBL a CROSS JOIN J2_TBL b +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "a"="j2_tbl" +ALIAS: "b"="j2_tbl" +STMT: SelectStmt +== 038 +|-- +|-- +-- Inner joins (equi-joins) +|-- +|-- + +|-- +-- Inner joins (equi-joins) with USING clause +-- The USING syntax changes the shape of the resulting table +-- by including a column in the USING clause only once in the result. +|-- + +-- Inner equi-join on specified column +SELECT * + FROM J1_TBL INNER JOIN J2_TBL USING (i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 039 +-- Same as above, slightly different syntax +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 040 +SELECT * + FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, d) USING (a) + ORDER BY a, d +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +== 041 +SELECT * + FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, b) USING (b) + ORDER BY b, t1.a +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +== 042 +-- test join using aliases +SELECT * FROM J1_TBL JOIN J2_TBL USING (i) WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +== 043 +-- ok +SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +== 044 +-- ok +SELECT * FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +== 045 +-- error +SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i = 1 +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="x" column="i" +STMT: SelectStmt +== 046 +-- ok +SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="x" column="t" +STMT: SelectStmt +== 047 +-- error +SELECT * FROM (J1_TBL JOIN J2_TBL USING (i) AS x) AS xx WHERE x.i = 1 +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="x" column="i" +STMT: SelectStmt +== 048 +-- error (XXX could use better hint) +SELECT * FROM J1_TBL a1 JOIN J2_TBL a2 USING (i) AS a1 +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "a1"="j1_tbl" +ALIAS: "a2"="j2_tbl" +STMT: SelectStmt +== 049 +-- error +SELECT x.* FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +== 050 +SELECT ROW(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +== 051 +SELECT row_to_json(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +== 052 +|-- +-- NATURAL JOIN +-- Inner equi-join on all columns with the same name +|-- + +SELECT * + FROM J1_TBL NATURAL JOIN J2_TBL +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 053 +SELECT * + FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (a, d) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +== 054 +SELECT * + FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (d, a) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +== 055 +-- mismatch number of columns +-- currently, Postgres will fill in with underlying names +SELECT * + FROM J1_TBL t1 (a, b) NATURAL JOIN J2_TBL t2 (a) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +== 056 +|-- +-- Inner joins (equi-joins) +|-- + +SELECT * + FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 057 +SELECT * + FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.k) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 058 +|-- +-- Non-equi-joins +|-- + +SELECT * + FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i <= J2_TBL.k) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 059 +|-- +-- Outer joins +-- Note that OUTER is a noise word +|-- + +SELECT * + FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i) + ORDER BY i, k, t +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 060 +SELECT * + FROM J1_TBL LEFT JOIN J2_TBL USING (i) + ORDER BY i, k, t +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 061 +SELECT * + FROM J1_TBL RIGHT OUTER JOIN J2_TBL USING (i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 062 +SELECT * + FROM J1_TBL RIGHT JOIN J2_TBL USING (i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 063 +SELECT * + FROM J1_TBL FULL OUTER JOIN J2_TBL USING (i) + ORDER BY i, k, t +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 064 +SELECT * + FROM J1_TBL FULL JOIN J2_TBL USING (i) + ORDER BY i, k, t +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 065 +SELECT * + FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (k = 1) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="" column="k" +STMT: SelectStmt +== 066 +SELECT * + FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (i = 1) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 067 +|-- +-- semijoin selectivity for <> +|-- +explain (costs off) +select * from int4_tbl i4, tenk1 a +where exists(select * from tenk1 b + where a.twothousand = b.twothousand and a.fivethous <> b.fivethous) + and i4.f1 = a.tenthous +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "i4"="int4_tbl" +FILTER: schema="" table="a" column="twothousand" +FILTER: schema="" table="b" column="twothousand" +FILTER: schema="" table="a" column="fivethous" +FILTER: schema="" table="b" column="fivethous" +STMT: ExplainStmt +STMT: SelectStmt +== 068 +|-- +-- More complicated constructs +|-- + +|-- +-- Multiway full join +|-- + +CREATE TABLE t1 (name TEXT, n INTEGER) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 069 +CREATE TABLE t2 (name TEXT, n INTEGER) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 070 +CREATE TABLE t3 (name TEXT, n INTEGER) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: CreateStmt +== 071 +INSERT INTO t1 VALUES ( 'bb', 11 ) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +INSERT INTO t2 VALUES ( 'bb', 12 ) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +INSERT INTO t2 VALUES ( 'cc', 22 ) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 074 +INSERT INTO t2 VALUES ( 'ee', 42 ) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +INSERT INTO t3 VALUES ( 'bb', 13 ) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 076 +INSERT INTO t3 VALUES ( 'cc', 23 ) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +INSERT INTO t3 VALUES ( 'dd', 33 ) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 079 +|-- +-- Test interactions of join syntax and subqueries +|-- + +-- Basic cases (we expect planner to pull up the subquery here) +SELECT * FROM +(SELECT * FROM t2) as s2 +INNER JOIN +(SELECT * FROM t3) s3 +USING (name) +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 080 +SELECT * FROM +(SELECT * FROM t2) as s2 +LEFT JOIN +(SELECT * FROM t3) s3 +USING (name) +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 081 +SELECT * FROM +(SELECT * FROM t2) as s2 +FULL JOIN +(SELECT * FROM t3) s3 +USING (name) +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 082 +-- Cases with non-nullable expressions in subquery results; +-- make sure these go to null as expected +SELECT * FROM +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL INNER JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 083 +SELECT * FROM +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL LEFT JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 084 +SELECT * FROM +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL FULL JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 085 +SELECT * FROM +(SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1 +NATURAL INNER JOIN +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL INNER JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 086 +SELECT * FROM +(SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1 +NATURAL FULL JOIN +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL FULL JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 087 +SELECT * FROM +(SELECT name, n as s1_n FROM t1) as s1 +NATURAL FULL JOIN + (SELECT * FROM + (SELECT name, n as s2_n FROM t2) as s2 + NATURAL FULL JOIN + (SELECT name, n as s3_n FROM t3) as s3 + ) ss2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 088 +SELECT * FROM +(SELECT name, n as s1_n FROM t1) as s1 +NATURAL FULL JOIN + (SELECT * FROM + (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 + NATURAL FULL JOIN + (SELECT name, n as s3_n FROM t3) as s3 + ) ss2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 089 +-- Constants as join keys can also be problematic +SELECT * FROM + (SELECT name, n as s1_n FROM t1) as s1 +FULL JOIN + (SELECT name, 2 as s2_n FROM t2) as s2 +ON (s1_n = s2_n) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +== 090 +-- Test for propagation of nullability constraints into sub-joins + +create temp table x (x1 int, x2 int) +-- +TABLE: name="x" schema="" table="x" ctx=DDL +STMT: CreateStmt +== 091 +insert into x values (1,11) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +insert into x values (2,22) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +insert into x values (3,null) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 094 +insert into x values (4,44) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +insert into x values (5,null) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +create temp table y (y1 int, y2 int) +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateStmt +== 097 +insert into y values (1,111) +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +insert into y values (2,222) +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 099 +insert into y values (3,333) +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 100 +insert into y values (4,null) +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +select * from x +-- +TABLE: name="x" schema="" table="x" ctx=Select +STMT: SelectStmt +== 102 +select * from y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 103 +select * from x left join y on (x1 = y1 and x2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 104 +select * from x left join y on (x1 = y1 and y2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 105 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +STMT: SelectStmt +== 106 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1 and x2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +STMT: SelectStmt +== 107 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1 and y2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +STMT: SelectStmt +== 108 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1 and xx2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +STMT: SelectStmt +== 109 +-- these should NOT give the same answers as above +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1) where (x2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +FILTER: schema="" table="" column="x2" +STMT: SelectStmt +== 110 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1) where (y2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +FILTER: schema="" table="" column="y2" +STMT: SelectStmt +== 111 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1) where (xx2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +FILTER: schema="" table="" column="xx2" +STMT: SelectStmt +== 112 +|-- +-- regression test: check for bug with propagation of implied equality +-- to outside an IN +|-- +select count(*) from tenk1 a where unique1 in + (select unique1 from tenk1 b join tenk1 c using (unique1) + where b.unique2 = 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: SelectStmt +== 113 +|-- +-- regression test: check for failure to generate a plan with multiple +-- degenerate IN clauses +|-- +select count(*) from tenk1 x where + x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and + x.unique1 = 0 and + x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "aa"="int4_tbl" +ALIAS: "b"="float8_tbl" +ALIAS: "bb"="float8_tbl" +ALIAS: "x"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="unique1" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="aa" column="f1" +FILTER: schema="" table="bb" column="f1" +STMT: SelectStmt +== 114 +-- try that with GEQO too +begin +-- +STMT: TransactionStmt +== 115 +set geqo = on +-- +STMT: VariableSetStmt +== 116 +set geqo_threshold = 2 +-- +STMT: VariableSetStmt +== 117 +select count(*) from tenk1 x where + x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and + x.unique1 = 0 and + x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "aa"="int4_tbl" +ALIAS: "b"="float8_tbl" +ALIAS: "bb"="float8_tbl" +ALIAS: "x"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="unique1" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="aa" column="f1" +FILTER: schema="" table="bb" column="f1" +STMT: SelectStmt +== 118 +rollback +-- +STMT: TransactionStmt +== 119 +|-- +-- regression test: be sure we cope with proven-dummy append rels +|-- +explain (costs off) +select aa, bb, unique1, unique1 + from tenk1 right join b_star on aa = unique1 + where bb < bb and bb is null +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="b_star" schema="" table="b_star" ctx=Select +FILTER: schema="" table="" column="bb" +FILTER: schema="" table="" column="bb" +FILTER: schema="" table="" column="bb" +STMT: ExplainStmt +STMT: SelectStmt +== 120 +select aa, bb, unique1, unique1 + from tenk1 right join b_star on aa = unique1 + where bb < bb and bb is null +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="b_star" schema="" table="b_star" ctx=Select +FILTER: schema="" table="" column="bb" +FILTER: schema="" table="" column="bb" +FILTER: schema="" table="" column="bb" +STMT: SelectStmt +== 121 +|-- +-- regression test: check handling of empty-FROM subquery underneath outer join +|-- +explain (costs off) +select * from int8_tbl i1 left join (int8_tbl i2 join + (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2 +order by 1, 2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +ALIAS: "i2"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 122 +select * from int8_tbl i1 left join (int8_tbl i2 join + (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2 +order by 1, 2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +ALIAS: "i2"="int8_tbl" +STMT: SelectStmt +== 123 +|-- +-- regression test: check a case where join_clause_is_movable_into() +-- used to give an imprecise result, causing an assertion failure +|-- +select count(*) +from + (select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2 + from tenk1 t1 + left join tenk1 t2 on t1.unique1 = t2.unique1 + join tenk1 t3 on t1.unique2 = t3.unique2) ss, + tenk1 t4, + tenk1 t5 +where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +ALIAS: "t4"="tenk1" +ALIAS: "t5"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t4" column="thousand" +FILTER: schema="" table="t5" column="unique1" +FILTER: schema="" table="ss" column="x1" +FILTER: schema="" table="t4" column="tenthous" +FILTER: schema="" table="ss" column="x2" +FILTER: schema="" table="t5" column="stringu1" +STMT: SelectStmt +== 124 +|-- +-- regression test: check a case where we formerly missed including an EC +-- enforcement clause because it was expected to be handled at scan level +|-- +explain (costs off) +select a.f1, b.f1, t.thousand, t.tenthous from + tenk1 t, + (select sum(f1)+1 as f1 from int4_tbl i4a) a, + (select sum(f1) as f1 from int4_tbl i4b) b +where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4a"="int4_tbl" +ALIAS: "i4b"="int4_tbl" +ALIAS: "t"="tenk1" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="t" column="thousand" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="t" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 125 +select a.f1, b.f1, t.thousand, t.tenthous from + tenk1 t, + (select sum(f1)+1 as f1 from int4_tbl i4a) a, + (select sum(f1) as f1 from int4_tbl i4b) b +where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4a"="int4_tbl" +ALIAS: "i4b"="int4_tbl" +ALIAS: "t"="tenk1" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="t" column="thousand" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="t" column="tenthous" +STMT: SelectStmt +== 126 +|-- +-- checks for correct handling of quals in multiway outer joins +|-- +explain (costs off) +select t1.f1 +from int4_tbl t1, int4_tbl t2 + left join int4_tbl t3 on t3.f1 > 0 + left join int4_tbl t4 on t3.f1 > 1 +where t4.f1 is null +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +FILTER: schema="" table="t4" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 127 +select t1.f1 +from int4_tbl t1, int4_tbl t2 + left join int4_tbl t3 on t3.f1 > 0 + left join int4_tbl t4 on t3.f1 > 1 +where t4.f1 is null +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +FILTER: schema="" table="t4" column="f1" +STMT: SelectStmt +== 128 +explain (costs off) +select * +from int4_tbl t1 left join int4_tbl t2 on true + left join int4_tbl t3 on t2.f1 > 0 + left join int4_tbl t4 on t3.f1 > 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 129 +explain (costs off) +select * from onek t1 + left join onek t2 on t1.unique1 = t2.unique1 + left join onek t3 on t2.unique1 != t3.unique1 + left join onek t4 on t3.unique1 = t4.unique1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="onek" +ALIAS: "t3"="onek" +ALIAS: "t4"="onek" +STMT: ExplainStmt +STMT: SelectStmt +== 130 +explain (costs off) +select * from int4_tbl t1 + left join (select now() from int4_tbl t2 + left join int4_tbl t3 on t2.f1 = t3.f1 + left join int4_tbl t4 on t3.f1 = t4.f1) s on true + inner join int4_tbl t5 on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +ALIAS: "t5"="int4_tbl" +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 131 +explain (costs off) +select * from int4_tbl t1 + left join int4_tbl t2 on true + left join int4_tbl t3 on true + left join int4_tbl t4 on t2.f1 = t3.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 132 +explain (costs off) +select * from int4_tbl t1 + left join int4_tbl t2 on true + left join int4_tbl t3 on t2.f1 = t3.f1 + left join int4_tbl t4 on t3.f1 != t4.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 133 +explain (costs off) +select * from int4_tbl t1 + left join (int4_tbl t2 left join int4_tbl t3 on t2.f1 > 0) on t2.f1 > 1 + left join int4_tbl t4 on t2.f1 > 2 and t3.f1 > 3 +where t1.f1 = coalesce(t2.f1, 1) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="t2" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 134 +explain (costs off) +select * from int4_tbl t1 + left join ((select t2.f1 from int4_tbl t2 + left join int4_tbl t3 on t2.f1 > 0 + where t3.f1 is null) s + left join tenk1 t4 on s.f1 > 1) + on s.f1 = t1.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="tenk1" +FILTER: schema="" table="t3" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 135 +explain (costs off) +select * from int4_tbl t1 + left join ((select t2.f1 from int4_tbl t2 + left join int4_tbl t3 on t2.f1 > 0 + where t2.f1 <> coalesce(t3.f1, -1)) s + left join tenk1 t4 on s.f1 > 1) + on s.f1 = t1.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="tenk1" +FILTER: schema="" table="t2" column="f1" +FILTER: schema="" table="t3" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 136 +explain (costs off) +select * from onek t1 + left join onek t2 on t1.unique1 = t2.unique1 + left join onek t3 on t2.unique1 = t3.unique1 + left join onek t4 on t3.unique1 = t4.unique1 and t2.unique2 = t4.unique2 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="onek" +ALIAS: "t3"="onek" +ALIAS: "t4"="onek" +STMT: ExplainStmt +STMT: SelectStmt +== 137 +explain (costs off) +select * from int8_tbl t1 left join + (int8_tbl t2 left join int8_tbl t3 full join int8_tbl t4 on false on false) + left join int8_tbl t5 on t2.q1 = t5.q1 +on t2.q2 = 123 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +ALIAS: "t4"="int8_tbl" +ALIAS: "t5"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 138 +explain (costs off) +select * from int8_tbl t1 + left join int8_tbl t2 on true + left join lateral + (select * from int8_tbl t3 where t3.q1 = t2.q1 offset 0) s + on t2.q1 = 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="t3" column="q1" +FILTER: schema="" table="t2" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 139 +explain (costs off) +select * from int8_tbl t1 + left join int8_tbl t2 on true + left join lateral + (select * from generate_series(t2.q1, 100)) s + on t2.q1 = 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 140 +explain (costs off) +select * from int8_tbl t1 + left join int8_tbl t2 on true + left join lateral + (select t2.q1 from int8_tbl t3) s + on t2.q1 = 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 141 +explain (costs off) +select * from onek t1 + left join onek t2 on true + left join lateral + (select * from onek t3 where t3.two = t2.two offset 0) s + on t2.unique1 = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="onek" +ALIAS: "t3"="onek" +FILTER: schema="" table="t3" column="two" +FILTER: schema="" table="t2" column="two" +STMT: ExplainStmt +STMT: SelectStmt +== 142 +|-- +-- check a case where we formerly got confused by conflicting sort orders +-- in redundant merge join path keys +|-- +explain (costs off) +select * from + j1_tbl full join + (select * from j2_tbl order by j2_tbl.i desc, j2_tbl.k asc) j2_tbl + on j1_tbl.i = j2_tbl.i and j1_tbl.i = j2_tbl.k +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 143 +select * from + j1_tbl full join + (select * from j2_tbl order by j2_tbl.i desc, j2_tbl.k asc) j2_tbl + on j1_tbl.i = j2_tbl.i and j1_tbl.i = j2_tbl.k +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +== 144 +|-- +-- a different check for handling of redundant sort keys in merge joins +|-- +explain (costs off) +select count(*) from + (select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x + left join + (select * from tenk1 y order by y.unique2) y + on x.thousand = y.unique2 and x.twothousand = y.hundred and x.fivethous = y.unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="tenk1" +ALIAS: "y"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 145 +select count(*) from + (select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x + left join + (select * from tenk1 y order by y.unique2) y + on x.thousand = y.unique2 and x.twothousand = y.hundred and x.fivethous = y.unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="tenk1" +ALIAS: "y"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 146 +set enable_hashjoin = 0 +-- +STMT: VariableSetStmt +== 147 +set enable_nestloop = 0 +-- +STMT: VariableSetStmt +== 148 +set enable_hashagg = 0 +-- +STMT: VariableSetStmt +== 149 +|-- +-- Check that we use the pathkeys from a prefix of the group by / order by +-- clause for the join pathkeys when that prefix covers all join quals. We +-- expect this to lead to an incremental sort for the group by / order by. +|-- +explain (costs off) +select x.thousand, x.twothousand, count(*) +from tenk1 x inner join tenk1 y on x.thousand = y.thousand +group by x.thousand, x.twothousand +order by x.thousand desc, x.twothousand +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="tenk1" +ALIAS: "y"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 150 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 151 +reset enable_nestloop +-- +STMT: VariableSetStmt +== 152 +reset enable_hashjoin +-- +STMT: VariableSetStmt +== 153 +|-- +-- Clean up +|-- + +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 154 +DROP TABLE t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +== 155 +DROP TABLE t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: DropStmt +== 156 +DROP TABLE J1_TBL +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DDL +STMT: DropStmt +== 157 +DROP TABLE J2_TBL +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DDL +STMT: DropStmt +== 158 +-- Both DELETE and UPDATE allow the specification of additional tables +-- to "join" against to determine which rows should be modified. + +CREATE TEMP TABLE t1 (a int, b int) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 159 +CREATE TEMP TABLE t2 (a int, b int) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 160 +CREATE TEMP TABLE t3 (x int, y int) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: CreateStmt +== 161 +INSERT INTO t1 VALUES (5, 10) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 162 +INSERT INTO t1 VALUES (15, 20) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 163 +INSERT INTO t1 VALUES (100, 100) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +INSERT INTO t1 VALUES (200, 1000) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 165 +INSERT INTO t2 VALUES (200, 2000) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 166 +INSERT INTO t3 VALUES (5, 20) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 167 +INSERT INTO t3 VALUES (6, 7) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +INSERT INTO t3 VALUES (7, 8) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 169 +INSERT INTO t3 VALUES (500, 100) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 170 +DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +ALIAS: "table1"="t1" +STMT: DeleteStmt +== 171 +SELECT * FROM t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 172 +DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: DeleteStmt +== 173 +SELECT * FROM t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 174 +DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "t3_other"="t3" +STMT: DeleteStmt +== 175 +SELECT * FROM t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 176 +-- Test join against inheritance tree + +create temp table t2a () inherits (t2) +-- +TABLE: name="t2a" schema="" table="t2a" ctx=DDL +STMT: CreateStmt +== 177 +insert into t2a values (200, 2001) +-- +TABLE: name="t2a" schema="" table="t2a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 178 +select * from t1 left join t2 on (t1.a = t2.a) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +== 179 +-- Test matching of column name with wrong alias + +select t1.x from t1 join t3 on (t1.a = t3.x) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 180 +-- Test matching of locking clause with wrong alias + +select t1.*, t2.*, unnamed_join.* from + t1 join t2 on (t1.a = t2.a), t3 as unnamed_join + for update of unnamed_join +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +== 181 +select foo.*, unnamed_join.* from + t1 join t2 using (a) as foo, t3 as unnamed_join + for update of unnamed_join +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +== 182 +select foo.*, unnamed_join.* from + t1 join t2 using (a) as foo, t3 as unnamed_join + for update of foo +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +== 183 +select bar.*, unnamed_join.* from + (t1 join t2 using (a) as foo) as bar, t3 as unnamed_join + for update of foo +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +== 184 +select bar.*, unnamed_join.* from + (t1 join t2 using (a) as foo) as bar, t3 as unnamed_join + for update of bar +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +== 185 +|-- +-- regression test for 8.1 merge right join bug +|-- + +CREATE TEMP TABLE tt1 ( tt1_id int4, joincol int4 ) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: CreateStmt +== 186 +INSERT INTO tt1 VALUES (1, 11) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +INSERT INTO tt1 VALUES (2, NULL) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +CREATE TEMP TABLE tt2 ( tt2_id int4, joincol int4 ) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: CreateStmt +== 189 +INSERT INTO tt2 VALUES (21, 11) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +INSERT INTO tt2 VALUES (22, 11) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +set enable_hashjoin to off +-- +STMT: VariableSetStmt +== 192 +set enable_nestloop to off +-- +STMT: VariableSetStmt +== 193 +-- these should give the same results + +select tt1.*, tt2.* from tt1 left join tt2 on tt1.joincol = tt2.joincol +-- +TABLE: name="tt1" schema="" table="tt1" ctx=Select +TABLE: name="tt2" schema="" table="tt2" ctx=Select +STMT: SelectStmt +== 194 +select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol +-- +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt1" schema="" table="tt1" ctx=Select +STMT: SelectStmt +== 195 +reset enable_hashjoin +-- +STMT: VariableSetStmt +== 196 +reset enable_nestloop +-- +STMT: VariableSetStmt +== 197 +|-- +-- regression test for bug #18522 (merge-right-anti-join in inner_unique cases) +|-- + +create temp table tbl_ra(a int unique, b int) +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=DDL +STMT: CreateStmt +== 198 +insert into tbl_ra select i, i%100 from generate_series(1,1000)i +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 199 +create index on tbl_ra (b) +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=DDL +STMT: IndexStmt +== 200 +analyze tbl_ra +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=DDL +STMT: VacuumStmt +== 201 +set enable_hashjoin to off +-- +STMT: VariableSetStmt +== 202 +set enable_nestloop to off +-- +STMT: VariableSetStmt +== 203 +-- ensure we get a merge right anti join +explain (costs off) +select * from tbl_ra t1 +where not exists (select 1 from tbl_ra t2 where t2.b = t1.a) and t1.b < 2 +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=Select +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=Select +ALIAS: "t1"="tbl_ra" +ALIAS: "t2"="tbl_ra" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 204 +-- and check we get the expected results +select * from tbl_ra t1 +where not exists (select 1 from tbl_ra t2 where t2.b = t1.a) and t1.b < 2 +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=Select +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=Select +ALIAS: "t1"="tbl_ra" +ALIAS: "t2"="tbl_ra" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +STMT: SelectStmt +== 205 +reset enable_hashjoin +-- +STMT: VariableSetStmt +== 206 +reset enable_nestloop +-- +STMT: VariableSetStmt +== 207 +|-- +-- regression test for bug #13908 (hash join with skew tuples & nbatch increase) +|-- + +set work_mem to '64kB' +-- +STMT: VariableSetStmt +== 208 +set enable_mergejoin to off +-- +STMT: VariableSetStmt +== 209 +set enable_memoize to off +-- +STMT: VariableSetStmt +== 210 +explain (costs off) +select count(*) from tenk1 a, tenk1 b + where a.hundred = b.thousand and (b.fivethous % 10) < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="hundred" +FILTER: schema="" table="b" column="thousand" +FILTER: schema="" table="b" column="fivethous" +STMT: ExplainStmt +STMT: SelectStmt +== 211 +select count(*) from tenk1 a, tenk1 b + where a.hundred = b.thousand and (b.fivethous % 10) < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="hundred" +FILTER: schema="" table="b" column="thousand" +FILTER: schema="" table="b" column="fivethous" +STMT: SelectStmt +== 212 +reset work_mem +-- +STMT: VariableSetStmt +== 213 +reset enable_mergejoin +-- +STMT: VariableSetStmt +== 214 +reset enable_memoize +-- +STMT: VariableSetStmt +== 215 +|-- +-- regression test for 8.2 bug with improper re-ordering of left joins +|-- + +create temp table tt3(f1 int, f2 text) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: CreateStmt +== 216 +insert into tt3 select x, repeat('xyzzy', 100) from generate_series(1,10000) x +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 217 +analyze tt3 +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: VacuumStmt +== 218 +create temp table tt4(f1 int) +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: CreateStmt +== 219 +insert into tt4 values (0),(1),(9999) +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 220 +analyze tt4 +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: VacuumStmt +== 221 +set enable_nestloop to off +-- +STMT: VariableSetStmt +== 222 +EXPLAIN (COSTS OFF) +SELECT a.f1 +FROM tt4 a +LEFT JOIN ( + SELECT b.f1 + FROM tt3 b LEFT JOIN tt3 c ON (b.f1 = c.f1) + WHERE COALESCE(c.f1, 0) = 0 +) AS d ON (a.f1 = d.f1) +WHERE COALESCE(d.f1, 0) = 0 +ORDER BY 1 +-- +TABLE: name="tt4" schema="" table="tt4" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +ALIAS: "a"="tt4" +ALIAS: "b"="tt3" +ALIAS: "c"="tt3" +FILTER: schema="" table="d" column="f1" +FILTER: schema="" table="c" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 223 +SELECT a.f1 +FROM tt4 a +LEFT JOIN ( + SELECT b.f1 + FROM tt3 b LEFT JOIN tt3 c ON (b.f1 = c.f1) + WHERE COALESCE(c.f1, 0) = 0 +) AS d ON (a.f1 = d.f1) +WHERE COALESCE(d.f1, 0) = 0 +ORDER BY 1 +-- +TABLE: name="tt4" schema="" table="tt4" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +ALIAS: "a"="tt4" +ALIAS: "b"="tt3" +ALIAS: "c"="tt3" +FILTER: schema="" table="d" column="f1" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 224 +reset enable_nestloop +-- +STMT: VariableSetStmt +== 225 +|-- +-- basic semijoin and antijoin recognition tests +|-- + +explain (costs off) +select a.* from tenk1 a +where unique1 in (select unique2 from tenk1 b) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 226 +-- sadly, this is not an antijoin +explain (costs off) +select a.* from tenk1 a +where unique1 not in (select unique2 from tenk1 b) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 227 +explain (costs off) +select a.* from tenk1 a +where exists (select 1 from tenk1 b where a.unique1 = b.unique2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 228 +explain (costs off) +select a.* from tenk1 a +where not exists (select 1 from tenk1 b where a.unique1 = b.unique2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 229 +explain (costs off) +select a.* from tenk1 a left join tenk1 b on a.unique1 = b.unique2 +where b.unique2 is null +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 230 +|-- +-- regression test for proper handling of outer joins within antijoins +|-- + +create temp table tt4x(c1 int, c2 int, c3 int) +-- +TABLE: name="tt4x" schema="" table="tt4x" ctx=DDL +STMT: CreateStmt +== 231 +explain (costs off) +select * from tt4x t1 +where not exists ( + select 1 from tt4x t2 + left join tt4x t3 on t2.c3 = t3.c1 + left join ( select t5.c1 as c1 + from tt4x t4 left join tt4x t5 on t4.c2 = t5.c1 + ) a1 on t3.c2 = a1.c1 + where t1.c1 = t2.c2 +) +-- +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +ALIAS: "t1"="tt4x" +ALIAS: "t2"="tt4x" +ALIAS: "t3"="tt4x" +ALIAS: "t4"="tt4x" +ALIAS: "t5"="tt4x" +FILTER: schema="" table="t1" column="c1" +FILTER: schema="" table="t2" column="c2" +STMT: ExplainStmt +STMT: SelectStmt +== 232 +|-- +-- regression test for problems of the sort depicted in bug #3494 +|-- + +create temp table tt5(f1 int, f2 int) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: CreateStmt +== 233 +create temp table tt6(f1 int, f2 int) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DDL +STMT: CreateStmt +== 234 +insert into tt5 values(1, 10) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 235 +insert into tt5 values(1, 11) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 236 +insert into tt6 values(1, 9) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 237 +insert into tt6 values(1, 2) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 238 +insert into tt6 values(2, 9) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 239 +select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2 +-- +TABLE: name="tt5" schema="" table="tt5" ctx=Select +TABLE: name="tt6" schema="" table="tt6" ctx=Select +FILTER: schema="" table="tt5" column="f1" +FILTER: schema="" table="tt6" column="f1" +FILTER: schema="" table="tt5" column="f1" +FILTER: schema="" table="tt5" column="f2" +FILTER: schema="" table="tt6" column="f2" +STMT: SelectStmt +== 240 +|-- +-- regression test for problems of the sort depicted in bug #3588 +|-- + +create temp table xx (pkxx int) +-- +TABLE: name="xx" schema="" table="xx" ctx=DDL +STMT: CreateStmt +== 241 +create temp table yy (pkyy int, pkxx int) +-- +TABLE: name="yy" schema="" table="yy" ctx=DDL +STMT: CreateStmt +== 242 +insert into xx values (1) +-- +TABLE: name="xx" schema="" table="xx" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 243 +insert into xx values (2) +-- +TABLE: name="xx" schema="" table="xx" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +insert into xx values (3) +-- +TABLE: name="xx" schema="" table="xx" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +insert into yy values (101, 1) +-- +TABLE: name="yy" schema="" table="yy" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 246 +insert into yy values (201, 2) +-- +TABLE: name="yy" schema="" table="yy" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 247 +insert into yy values (301, NULL) +-- +TABLE: name="yy" schema="" table="yy" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 248 +select yy.pkyy as yy_pkyy, yy.pkxx as yy_pkxx, yya.pkyy as yya_pkyy, + xxa.pkxx as xxa_pkxx, xxb.pkxx as xxb_pkxx +from yy + left join (SELECT * FROM yy where pkyy = 101) as yya ON yy.pkyy = yya.pkyy + left join xx xxa on yya.pkxx = xxa.pkxx + left join xx xxb on coalesce (xxa.pkxx, 1) = xxb.pkxx +-- +TABLE: name="yy" schema="" table="yy" ctx=Select +TABLE: name="xx" schema="" table="xx" ctx=Select +TABLE: name="xx" schema="" table="xx" ctx=Select +TABLE: name="yy" schema="" table="yy" ctx=Select +ALIAS: "xxa"="xx" +ALIAS: "xxb"="xx" +FILTER: schema="" table="" column="pkyy" +STMT: SelectStmt +== 249 +|-- +-- regression test for improper pushing of constants across outer-join clauses +-- (as seen in early 8.2.x releases) +|-- + +create temp table zt1 (f1 int primary key) +-- +TABLE: name="zt1" schema="" table="zt1" ctx=DDL +STMT: CreateStmt +== 250 +create temp table zt2 (f2 int primary key) +-- +TABLE: name="zt2" schema="" table="zt2" ctx=DDL +STMT: CreateStmt +== 251 +create temp table zt3 (f3 int primary key) +-- +TABLE: name="zt3" schema="" table="zt3" ctx=DDL +STMT: CreateStmt +== 252 +insert into zt1 values(53) +-- +TABLE: name="zt1" schema="" table="zt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +insert into zt2 values(53) +-- +TABLE: name="zt2" schema="" table="zt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 254 +select * from + zt2 left join zt3 on (f2 = f3) + left join zt1 on (f3 = f1) +where f2 = 53 +-- +TABLE: name="zt2" schema="" table="zt2" ctx=Select +TABLE: name="zt3" schema="" table="zt3" ctx=Select +TABLE: name="zt1" schema="" table="zt1" ctx=Select +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 255 +create temp view zv1 as select *,'dummy'::text AS junk from zt1 +-- +TABLE: name="zv1" schema="" table="zv1" ctx=DDL +TABLE: name="zt1" schema="" table="zt1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 256 +select * from + zt2 left join zt3 on (f2 = f3) + left join zv1 on (f3 = f1) +where f2 = 53 +-- +TABLE: name="zt2" schema="" table="zt2" ctx=Select +TABLE: name="zt3" schema="" table="zt3" ctx=Select +TABLE: name="zv1" schema="" table="zv1" ctx=Select +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 257 +|-- +-- regression test for improper extraction of OR indexqual conditions +-- (as seen in early 8.3.x releases) +|-- + +select a.unique2, a.ten, b.tenthous, b.unique2, b.hundred +from tenk1 a left join tenk1 b on a.unique2 = b.tenthous +where a.unique1 = 42 and + ((b.unique2 is null and a.ten = 2) or b.hundred = 3) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +FILTER: schema="" table="a" column="ten" +FILTER: schema="" table="b" column="hundred" +STMT: SelectStmt +== 258 +|-- +-- test proper positioning of one-time quals in EXISTS (8.4devel bug) +|-- +prepare foo(bool) as + select count(*) from tenk1 a left join tenk1 b + on (a.unique2 = b.unique1 and exists + (select 1 from tenk1 c where c.thousand = b.unique2 and $1)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="c" column="thousand" +FILTER: schema="" table="b" column="unique2" +STMT: PrepareStmt +STMT: SelectStmt +== 259 +execute foo(true) +-- +STMT: ExecuteStmt +== 260 +execute foo(false) +-- +STMT: ExecuteStmt +== 261 +|-- +-- test for sane behavior with noncanonical merge clauses, per bug #4926 +|-- + +begin +-- +STMT: TransactionStmt +== 262 +set enable_mergejoin = 1 +-- +STMT: VariableSetStmt +== 263 +set enable_hashjoin = 0 +-- +STMT: VariableSetStmt +== 264 +set enable_nestloop = 0 +-- +STMT: VariableSetStmt +== 265 +create temp table a (i integer) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +== 266 +create temp table b (x integer, y integer) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +== 267 +select * from a left join b on i = x and i = y and x = i +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: SelectStmt +== 268 +rollback +-- +STMT: TransactionStmt +== 269 +|-- +-- test handling of merge clauses using record_ops +|-- +begin +-- +STMT: TransactionStmt +== 270 +create type mycomptype as (id int, v bigint) +-- +STMT: CompositeTypeStmt +== 271 +create temp table tidv (idv mycomptype) +-- +TABLE: name="tidv" schema="" table="tidv" ctx=DDL +STMT: CreateStmt +== 272 +create index on tidv (idv) +-- +TABLE: name="tidv" schema="" table="tidv" ctx=DDL +STMT: IndexStmt +== 273 +explain (costs off) +select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv +-- +TABLE: name="tidv" schema="" table="tidv" ctx=Select +TABLE: name="tidv" schema="" table="tidv" ctx=Select +ALIAS: "a"="tidv" +ALIAS: "b"="tidv" +FILTER: schema="" table="a" column="idv" +FILTER: schema="" table="b" column="idv" +STMT: ExplainStmt +STMT: SelectStmt +== 274 +set enable_mergejoin = 0 +-- +STMT: VariableSetStmt +== 275 +set enable_hashjoin = 0 +-- +STMT: VariableSetStmt +== 276 +explain (costs off) +select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv +-- +TABLE: name="tidv" schema="" table="tidv" ctx=Select +TABLE: name="tidv" schema="" table="tidv" ctx=Select +ALIAS: "a"="tidv" +ALIAS: "b"="tidv" +FILTER: schema="" table="a" column="idv" +FILTER: schema="" table="b" column="idv" +STMT: ExplainStmt +STMT: SelectStmt +== 277 +rollback +-- +STMT: TransactionStmt +== 278 +|-- +-- test NULL behavior of whole-row Vars, per bug #5025 +|-- +select t1.q2, count(t2.*) +from int8_tbl t1 left join int8_tbl t2 on (t1.q2 = t2.q1) +group by t1.q2 order by 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 279 +select t1.q2, count(t2.*) +from int8_tbl t1 left join (select * from int8_tbl) t2 on (t1.q2 = t2.q1) +group by t1.q2 order by 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 280 +select t1.q2, count(t2.*) +from int8_tbl t1 left join (select * from int8_tbl offset 0) t2 on (t1.q2 = t2.q1) +group by t1.q2 order by 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 281 +select t1.q2, count(t2.*) +from int8_tbl t1 left join + (select q1, case when q2=1 then 1 else q2 end as q2 from int8_tbl) t2 + on (t1.q2 = t2.q1) +group by t1.q2 order by 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 282 +|-- +-- test incorrect failure to NULL pulled-up subexpressions +|-- +begin +-- +STMT: TransactionStmt +== 283 +create temp table a ( + code char not null, + constraint a_pk primary key (code) +) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +== 284 +create temp table b ( + a char not null, + num integer not null, + constraint b_pk primary key (a, num) +) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +== 285 +create temp table c ( + name char not null, + a char, + constraint c_pk primary key (name) +) +-- +TABLE: name="c" schema="" table="c" ctx=DDL +STMT: CreateStmt +== 286 +insert into a (code) values ('p') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 287 +insert into a (code) values ('q') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 288 +insert into b (a, num) values ('p', 1) +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 289 +insert into b (a, num) values ('p', 2) +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 290 +insert into c (name, a) values ('A', 'p') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 291 +insert into c (name, a) values ('B', 'q') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 292 +insert into c (name, a) values ('C', null) +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +select c.name, ss.code, ss.b_cnt, ss.const +from c left join + (select a.code, coalesce(b_grp.cnt, 0) as b_cnt, -1 as const + from a left join + (select count(1) as cnt, b.a from b group by b.a) as b_grp + on a.code = b_grp.a + ) as ss + on (c.a = ss.code) +order by c.name +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 294 +rollback +-- +STMT: TransactionStmt +== 295 +|-- +-- test incorrect handling of placeholders that only appear in targetlists, +-- per bug #6154 +|-- +SELECT * FROM +( SELECT 1 as key1 ) sub1 +LEFT JOIN +( SELECT sub3.key3, sub4.value2, COALESCE(sub4.value2, 66) as value3 FROM + ( SELECT 1 as key3 ) sub3 + LEFT JOIN + ( SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2 FROM + ( SELECT 1 as key5 ) sub5 + LEFT JOIN + ( SELECT 2 as key6, 42 as value1 ) sub6 + ON sub5.key5 = sub6.key6 + ) sub4 + ON sub4.key5 = sub3.key3 +) sub2 +ON sub1.key1 = sub2.key3 +-- +STMT: SelectStmt +== 296 +-- test the path using join aliases, too +SELECT * FROM +( SELECT 1 as key1 ) sub1 +LEFT JOIN +( SELECT sub3.key3, value2, COALESCE(value2, 66) as value3 FROM + ( SELECT 1 as key3 ) sub3 + LEFT JOIN + ( SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2 FROM + ( SELECT 1 as key5 ) sub5 + LEFT JOIN + ( SELECT 2 as key6, 42 as value1 ) sub6 + ON sub5.key5 = sub6.key6 + ) sub4 + ON sub4.key5 = sub3.key3 +) sub2 +ON sub1.key1 = sub2.key3 +-- +STMT: SelectStmt +== 297 +|-- +-- test case where a PlaceHolderVar is used as a nestloop parameter +|-- + +EXPLAIN (COSTS OFF) +SELECT qq, unique1 + FROM + ( SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a ) AS ss1 + FULL OUTER JOIN + ( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2 + USING (qq) + INNER JOIN tenk1 c ON qq = unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +== 298 +SELECT qq, unique1 + FROM + ( SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a ) AS ss1 + FULL OUTER JOIN + ( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2 + USING (qq) + INNER JOIN tenk1 c ON qq = unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="tenk1" +STMT: SelectStmt +== 299 +|-- +-- nested nestloops can require nested PlaceHolderVars +|-- + +create temp table nt1 ( + id int primary key, + a1 boolean, + a2 boolean +) +-- +TABLE: name="nt1" schema="" table="nt1" ctx=DDL +STMT: CreateStmt +== 300 +create temp table nt2 ( + id int primary key, + nt1_id int, + b1 boolean, + b2 boolean, + foreign key (nt1_id) references nt1(id) +) +-- +TABLE: name="nt2" schema="" table="nt2" ctx=DDL +STMT: CreateStmt +== 301 +create temp table nt3 ( + id int primary key, + nt2_id int, + c1 boolean, + foreign key (nt2_id) references nt2(id) +) +-- +TABLE: name="nt3" schema="" table="nt3" ctx=DDL +STMT: CreateStmt +== 302 +insert into nt1 values (1,true,true) +-- +TABLE: name="nt1" schema="" table="nt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 303 +insert into nt1 values (2,true,false) +-- +TABLE: name="nt1" schema="" table="nt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 304 +insert into nt1 values (3,false,false) +-- +TABLE: name="nt1" schema="" table="nt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 305 +insert into nt2 values (1,1,true,true) +-- +TABLE: name="nt2" schema="" table="nt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 306 +insert into nt2 values (2,2,true,false) +-- +TABLE: name="nt2" schema="" table="nt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 307 +insert into nt2 values (3,3,false,false) +-- +TABLE: name="nt2" schema="" table="nt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 308 +insert into nt3 values (1,1,true) +-- +TABLE: name="nt3" schema="" table="nt3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 309 +insert into nt3 values (2,2,false) +-- +TABLE: name="nt3" schema="" table="nt3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 310 +insert into nt3 values (3,3,true) +-- +TABLE: name="nt3" schema="" table="nt3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 311 +explain (costs off) +select nt3.id +from nt3 as nt3 + left join + (select nt2.*, (nt2.b1 and ss1.a3) AS b3 + from nt2 as nt2 + left join + (select nt1.*, (nt1.id is not null) as a3 from nt1) as ss1 + on ss1.id = nt2.nt1_id + ) as ss2 + on ss2.id = nt3.nt2_id +where nt3.id = 1 and ss2.b3 +-- +TABLE: name="nt3" schema="" table="nt3" ctx=Select +TABLE: name="nt2" schema="" table="nt2" ctx=Select +TABLE: name="nt1" schema="" table="nt1" ctx=Select +ALIAS: "nt2"="nt2" +ALIAS: "nt3"="nt3" +FILTER: schema="" table="nt3" column="id" +FILTER: schema="" table="ss2" column="b3" +STMT: ExplainStmt +STMT: SelectStmt +== 312 +select nt3.id +from nt3 as nt3 + left join + (select nt2.*, (nt2.b1 and ss1.a3) AS b3 + from nt2 as nt2 + left join + (select nt1.*, (nt1.id is not null) as a3 from nt1) as ss1 + on ss1.id = nt2.nt1_id + ) as ss2 + on ss2.id = nt3.nt2_id +where nt3.id = 1 and ss2.b3 +-- +TABLE: name="nt3" schema="" table="nt3" ctx=Select +TABLE: name="nt2" schema="" table="nt2" ctx=Select +TABLE: name="nt1" schema="" table="nt1" ctx=Select +ALIAS: "nt2"="nt2" +ALIAS: "nt3"="nt3" +FILTER: schema="" table="nt3" column="id" +FILTER: schema="" table="ss2" column="b3" +STMT: SelectStmt +== 313 +|-- +-- test case where a PlaceHolderVar is propagated into a subquery +|-- + +explain (costs off) +select * from + int8_tbl t1 left join + (select q1 as x, 42 as y from int8_tbl t2) ss + on t1.q2 = ss.x +where + 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1) +order by 1,2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="ss" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 314 +select * from + int8_tbl t1 left join + (select q1 as x, 42 as y from int8_tbl t2) ss + on t1.q2 = ss.x +where + 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1) +order by 1,2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="ss" column="y" +STMT: SelectStmt +== 315 +|-- +-- variant where a PlaceHolderVar is needed at a join, but not above the join +|-- + +explain (costs off) +select * from + int4_tbl as i41, + lateral + (select 1 as x from + (select i41.f1 as lat, + i42.f1 as loc from + int8_tbl as i81, int4_tbl as i42) as ss1 + right join int4_tbl as i43 on (i43.f1 > 1) + where ss1.loc = ss1.lat) as ss2 +where i41.f1 > 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i41"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i43"="int4_tbl" +ALIAS: "i81"="int8_tbl" +FILTER: schema="" table="i41" column="f1" +FILTER: schema="" table="ss1" column="loc" +FILTER: schema="" table="ss1" column="lat" +STMT: ExplainStmt +STMT: SelectStmt +== 316 +select * from + int4_tbl as i41, + lateral + (select 1 as x from + (select i41.f1 as lat, + i42.f1 as loc from + int8_tbl as i81, int4_tbl as i42) as ss1 + right join int4_tbl as i43 on (i43.f1 > 1) + where ss1.loc = ss1.lat) as ss2 +where i41.f1 > 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i41"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i43"="int4_tbl" +ALIAS: "i81"="int8_tbl" +FILTER: schema="" table="i41" column="f1" +FILTER: schema="" table="ss1" column="loc" +FILTER: schema="" table="ss1" column="lat" +STMT: SelectStmt +== 317 +|-- +-- test the corner cases FULL JOIN ON TRUE and FULL JOIN ON FALSE +|-- +select * from int4_tbl a full join int4_tbl b on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +STMT: SelectStmt +== 318 +select * from int4_tbl a full join int4_tbl b on false +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +STMT: SelectStmt +== 319 +|-- +-- test for ability to use a cartesian join when necessary +|-- + +create temp table q1 as select 1 as q1 +-- +TABLE: name="q1" schema="" table="q1" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 320 +create temp table q2 as select 0 as q2 +-- +TABLE: name="q2" schema="" table="q2" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 321 +analyze q1 +-- +TABLE: name="q1" schema="" table="q1" ctx=DDL +STMT: VacuumStmt +== 322 +analyze q2 +-- +TABLE: name="q2" schema="" table="q2" ctx=DDL +STMT: VacuumStmt +== 323 +explain (costs off) +select * from + tenk1 join int4_tbl on f1 = twothousand, + q1, q2 +where q1 = thousand or q2 = thousand +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +TABLE: name="q2" schema="" table="q2" ctx=Select +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 324 +explain (costs off) +select * from + tenk1 join int4_tbl on f1 = twothousand, + q1, q2 +where thousand = (q1 + q2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +TABLE: name="q2" schema="" table="q2" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 325 +|-- +-- test ability to generate a suitable plan for a star-schema query +|-- + +explain (costs off) +select * from + tenk1, int8_tbl a, int8_tbl b +where thousand = a.q1 and tenthous = b.q1 and a.q2 = 1 and b.q2 = 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="a" column="q1" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="b" column="q1" +FILTER: schema="" table="a" column="q2" +FILTER: schema="" table="b" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 326 +|-- +-- test a corner case in which we shouldn't apply the star-schema optimization +|-- + +explain (costs off) +select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from + tenk1 t1 + inner join int4_tbl i1 + left join (select v1.x2, v2.y1, 11 AS d1 + from (select 1,0 from onerow) v1(x1,x2) + left join (select 3,1 from onerow) v2(y1,y2) + on v1.x1 = v2.y2) subq1 + on (i1.f1 = subq1.x2) + on (t1.unique2 = subq1.d1) + left join tenk1 t2 + on (subq1.y1 = t2.unique1) +where t1.unique2 < 42 and t1.stringu1 > t2.stringu2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="t1" column="unique2" +FILTER: schema="" table="t1" column="stringu1" +FILTER: schema="" table="t2" column="stringu2" +STMT: ExplainStmt +STMT: SelectStmt +== 327 +select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from + tenk1 t1 + inner join int4_tbl i1 + left join (select v1.x2, v2.y1, 11 AS d1 + from (select 1,0 from onerow) v1(x1,x2) + left join (select 3,1 from onerow) v2(y1,y2) + on v1.x1 = v2.y2) subq1 + on (i1.f1 = subq1.x2) + on (t1.unique2 = subq1.d1) + left join tenk1 t2 + on (subq1.y1 = t2.unique1) +where t1.unique2 < 42 and t1.stringu1 > t2.stringu2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="t1" column="unique2" +FILTER: schema="" table="t1" column="stringu1" +FILTER: schema="" table="t2" column="stringu2" +STMT: SelectStmt +== 328 +-- variant that isn't quite a star-schema case + +select ss1.d1 from + tenk1 as t1 + inner join tenk1 as t2 + on t1.tenthous = t2.ten + inner join + int8_tbl as i8 + left join int4_tbl as i4 + inner join (select 64::information_schema.cardinal_number as d1 + from tenk1 t3, + lateral (select abs(t3.unique1) + random()) ss0(x) + where t3.fivethous < 0) as ss1 + on i4.f1 = ss1.d1 + on i8.q1 = i4.f1 + on t1.tenthous = ss1.d1 +where t1.unique1 < i4.f1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="i4" column="f1" +FILTER: schema="" table="t3" column="fivethous" +STMT: SelectStmt +== 329 +-- this variant is foldable by the remove-useless-RESULT-RTEs code + +explain (costs off) +select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from + tenk1 t1 + inner join int4_tbl i1 + left join (select v1.x2, v2.y1, 11 AS d1 + from (values(1,0)) v1(x1,x2) + left join (values(3,1)) v2(y1,y2) + on v1.x1 = v2.y2) subq1 + on (i1.f1 = subq1.x2) + on (t1.unique2 = subq1.d1) + left join tenk1 t2 + on (subq1.y1 = t2.unique1) +where t1.unique2 < 42 and t1.stringu1 > t2.stringu2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="t1" column="unique2" +FILTER: schema="" table="t1" column="stringu1" +FILTER: schema="" table="t2" column="stringu2" +STMT: ExplainStmt +STMT: SelectStmt +== 330 +select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from + tenk1 t1 + inner join int4_tbl i1 + left join (select v1.x2, v2.y1, 11 AS d1 + from (values(1,0)) v1(x1,x2) + left join (values(3,1)) v2(y1,y2) + on v1.x1 = v2.y2) subq1 + on (i1.f1 = subq1.x2) + on (t1.unique2 = subq1.d1) + left join tenk1 t2 + on (subq1.y1 = t2.unique1) +where t1.unique2 < 42 and t1.stringu1 > t2.stringu2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="t1" column="unique2" +FILTER: schema="" table="t1" column="stringu1" +FILTER: schema="" table="t2" column="stringu2" +STMT: SelectStmt +== 331 +-- Here's a variant that we can't fold too aggressively, though, +-- or we end up with noplace to evaluate the lateral PHV +explain (verbose, costs off) +select * from + (select 1 as x) ss1 left join (select 2 as y) ss2 on (true), + lateral (select ss2.y as z limit 1) ss3 +-- +STMT: ExplainStmt +STMT: SelectStmt +== 332 +select * from + (select 1 as x) ss1 left join (select 2 as y) ss2 on (true), + lateral (select ss2.y as z limit 1) ss3 +-- +STMT: SelectStmt +== 333 +-- Test proper handling of appendrel PHVs during useless-RTE removal +explain (costs off) +select * from + (select 0 as z) as t1 + left join + (select true as a) as t2 + on true, + lateral (select true as b + union all + select a as b) as t3 +where b +-- +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 334 +select * from + (select 0 as z) as t1 + left join + (select true as a) as t2 + on true, + lateral (select true as b + union all + select a as b) as t3 +where b +-- +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 335 +-- Test PHV in a semijoin qual, which confused useless-RTE removal (bug #17700) +explain (verbose, costs off) +with ctetable as not materialized ( select 1 as f1 ) +select * from ctetable c1 +where f1 in ( select c3.f1 from ctetable c2 full join ctetable c3 on true ) +-- +ALIAS: "c1"="ctetable" +ALIAS: "c2"="ctetable" +ALIAS: "c3"="ctetable" +CTE: "ctetable" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 336 +with ctetable as not materialized ( select 1 as f1 ) +select * from ctetable c1 +where f1 in ( select c3.f1 from ctetable c2 full join ctetable c3 on true ) +-- +ALIAS: "c1"="ctetable" +ALIAS: "c2"="ctetable" +ALIAS: "c3"="ctetable" +CTE: "ctetable" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 337 +-- Test PHV that winds up in a Result node, despite having nonempty nullingrels +explain (verbose, costs off) +select table_catalog, table_name +from int4_tbl t1 + inner join (int8_tbl t2 + left join information_schema.column_udt_usage on null) + on null +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="information_schema.column_udt_usage" schema="information_schema" table="column_udt_usage" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 338 +-- Test handling of qual pushdown to appendrel members with non-Var outputs +explain (verbose, costs off) +select * from int4_tbl left join ( + select text 'foo' union all select text 'bar' +) ss(x) on true +where ss.x is null +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="ss" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 339 +|-- +-- test inlining of immutable functions +|-- +create function f_immutable_int4(i integer) returns integer as +$$ begin return i; end; $$ language plpgsql immutable +-- +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 340 +-- check optimization of function scan with join +explain (costs off) +select unique1 from tenk1, (select * from f_immutable_int4(1) x) x +where x = unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 341 +explain (verbose, costs off) +select unique1, x.* +from tenk1, (select *, random() from f_immutable_int4(1) x) x +where x = unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 342 +explain (costs off) +select unique1 from tenk1, f_immutable_int4(1) x where x = unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 343 +explain (costs off) +select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 344 +explain (costs off) +select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 345 +explain (costs off) +select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 346 +explain (costs off) +select unique1, x from tenk1 left join f_immutable_int4(1) x on unique1 = x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 347 +explain (costs off) +select unique1, x from tenk1 right join f_immutable_int4(1) x on unique1 = x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 348 +explain (costs off) +select unique1, x from tenk1 full join f_immutable_int4(1) x on unique1 = x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 349 +-- check that pullup of a const function allows further const-folding +explain (costs off) +select unique1 from tenk1, f_immutable_int4(1) x where x = 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 350 +-- test inlining of immutable functions with PlaceHolderVars +explain (costs off) +select nt3.id +from nt3 as nt3 + left join + (select nt2.*, (nt2.b1 or i4 = 42) AS b3 + from nt2 as nt2 + left join + f_immutable_int4(0) i4 + on i4 = nt2.nt1_id + ) as ss2 + on ss2.id = nt3.nt2_id +where nt3.id = 1 and ss2.b3 +-- +TABLE: name="nt3" schema="" table="nt3" ctx=Select +TABLE: name="nt2" schema="" table="nt2" ctx=Select +ALIAS: "nt2"="nt2" +ALIAS: "nt3"="nt3" +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="nt3" column="id" +FILTER: schema="" table="ss2" column="b3" +STMT: ExplainStmt +STMT: SelectStmt +== 351 +drop function f_immutable_int4(int) +-- +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=DDL +STMT: DropStmt +== 352 +-- test inlining when function returns composite + +create function mki8(bigint, bigint) returns int8_tbl as +$$select row($1,$2)::int8_tbl$$ language sql +-- +FUNCTION: name="mki8" function="mki8" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 353 +create function mki4(int) returns int4_tbl as +$$select row($1)::int4_tbl$$ language sql +-- +FUNCTION: name="mki4" function="mki4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 354 +explain (verbose, costs off) +select * from mki8(1,2) +-- +FUNCTION: name="mki8" function="mki8" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 355 +select * from mki8(1,2) +-- +FUNCTION: name="mki8" function="mki8" schema="" ctx=Call +STMT: SelectStmt +== 356 +explain (verbose, costs off) +select * from mki4(42) +-- +FUNCTION: name="mki4" function="mki4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 357 +select * from mki4(42) +-- +FUNCTION: name="mki4" function="mki4" schema="" ctx=Call +STMT: SelectStmt +== 358 +drop function mki8(bigint, bigint) +-- +FUNCTION: name="mki8" function="mki8" schema="" ctx=DDL +STMT: DropStmt +== 359 +drop function mki4(int) +-- +FUNCTION: name="mki4" function="mki4" schema="" ctx=DDL +STMT: DropStmt +== 360 +-- test const-folding of a whole-row Var into a per-field Var +-- (need to inline a function to reach this case, else parser does it) +create function f_field_select(t onek) returns int4 as +$$ select t.unique2; $$ language sql immutable +-- +FUNCTION: name="f_field_select" function="f_field_select" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 361 +explain (verbose, costs off) +select (t2.*).unique1, f_field_select(t2) from tenk1 t1 + left join onek t2 on t1.unique1 = t2.unique1 + left join int8_tbl t3 on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="onek" +ALIAS: "t3"="int8_tbl" +FUNCTION: name="f_field_select" function="f_field_select" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 362 +drop function f_field_select(t onek) +-- +FUNCTION: name="f_field_select" function="f_field_select" schema="" ctx=DDL +STMT: DropStmt +== 363 +|-- +-- test extraction of restriction OR clauses from join OR clause +-- (we used to only do this for indexable clauses) +|-- + +explain (costs off) +select * from tenk1 a join tenk1 b on + (a.unique1 = 1 and b.unique1 = 2) or (a.unique2 = 3 and b.hundred = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +== 364 +explain (costs off) +select * from tenk1 a join tenk1 b on + (a.unique1 = 1 and b.unique1 = 2) or (a.unique2 = 3 and b.ten = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +== 365 +explain (costs off) +select * from tenk1 a join tenk1 b on + (a.unique1 = 1 and b.unique1 = 2) or + ((a.unique2 = 3 or a.unique2 = 7) and b.hundred = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +== 366 +|-- +-- test placement of movable quals in a parameterized join tree +|-- + +explain (costs off) +select * from tenk1 t1 left join + (tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2) + on t1.hundred = t2.hundred and t1.ten = t3.ten +where t1.unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FILTER: schema="" table="t1" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 367 +explain (costs off) +select * from tenk1 t1 left join + (tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2) + on t1.hundred = t2.hundred and t1.ten + t2.ten = t3.ten +where t1.unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FILTER: schema="" table="t1" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 368 +explain (costs off) +select count(*) from + tenk1 a join tenk1 b on a.unique1 = b.unique2 + left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand + join int4_tbl on b.thousand = f1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 369 +select count(*) from + tenk1 a join tenk1 b on a.unique1 = b.unique2 + left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand + join int4_tbl on b.thousand = f1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 370 +explain (costs off) +select b.unique1 from + tenk1 a join tenk1 b on a.unique1 = b.unique2 + left join tenk1 c on b.unique1 = 42 and c.thousand = a.thousand + join int4_tbl i1 on b.thousand = f1 + right join int4_tbl i2 on i2.f1 = b.tenthous + order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 371 +select b.unique1 from + tenk1 a join tenk1 b on a.unique1 = b.unique2 + left join tenk1 c on b.unique1 = 42 and c.thousand = a.thousand + join int4_tbl i1 on b.thousand = f1 + right join int4_tbl i2 on i2.f1 = b.tenthous + order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int4_tbl" +STMT: SelectStmt +== 372 +explain (costs off) +select * from +( + select unique1, q1, coalesce(unique1, -1) + q1 as fault + from int8_tbl left join tenk1 on (q2 = unique2) +) ss +where fault = 122 +order by fault +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="fault" +STMT: ExplainStmt +STMT: SelectStmt +== 373 +select * from +( + select unique1, q1, coalesce(unique1, -1) + q1 as fault + from int8_tbl left join tenk1 on (q2 = unique2) +) ss +where fault = 122 +order by fault +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="fault" +STMT: SelectStmt +== 374 +explain (costs off) +select * from +(values (1, array[10,20]), (2, array[20,30])) as v1(v1x,v1ys) +left join (values (1, 10), (2, 20)) as v2(v2x,v2y) on v2x = v1x +left join unnest(v1ys) as u1(u1y) on u1y = v2y +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 375 +select * from +(values (1, array[10,20]), (2, array[20,30])) as v1(v1x,v1ys) +left join (values (1, 10), (2, 20)) as v2(v2x,v2y) on v2x = v1x +left join unnest(v1ys) as u1(u1y) on u1y = v2y +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 376 +|-- +-- test handling of potential equivalence clauses above outer joins +|-- + +explain (costs off) +select q1, unique2, thousand, hundred + from int8_tbl a left join tenk1 b on q1 = unique2 + where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 377 +select q1, unique2, thousand, hundred + from int8_tbl a left join tenk1 b on q1 = unique2 + where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 378 +explain (costs off) +select f1, unique2, case when unique2 is null then f1 else 0 end + from int4_tbl a left join tenk1 b on f1 = unique2 + where (case when unique2 is null then f1 else 0 end) = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 379 +select f1, unique2, case when unique2 is null then f1 else 0 end + from int4_tbl a left join tenk1 b on f1 = unique2 + where (case when unique2 is null then f1 else 0 end) = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 380 +|-- +-- another case with equivalence clauses above outer joins (bug #8591) +|-- + +explain (costs off) +select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand) + from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand) + where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FILTER: schema="" table="a" column="unique2" +FILTER: schema="" table="b" column="twothousand" +FILTER: schema="" table="a" column="twothousand" +STMT: ExplainStmt +STMT: SelectStmt +== 381 +select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand) + from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand) + where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FILTER: schema="" table="a" column="unique2" +FILTER: schema="" table="b" column="twothousand" +FILTER: schema="" table="a" column="twothousand" +STMT: SelectStmt +== 382 +-- related case + +explain (costs off) +select * from int8_tbl t1 left join int8_tbl t2 on t1.q2 = t2.q1, + lateral (select * from int8_tbl t3 where t2.q1 = t2.q2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="t2" column="q1" +FILTER: schema="" table="t2" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 383 +select * from int8_tbl t1 left join int8_tbl t2 on t1.q2 = t2.q1, + lateral (select * from int8_tbl t3 where t2.q1 = t2.q2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="t2" column="q1" +FILTER: schema="" table="t2" column="q2" +STMT: SelectStmt +== 384 +|-- +-- check handling of join aliases when flattening multiple levels of subquery +|-- + +explain (verbose, costs off) +select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from + (values (0),(1)) foo1(join_key) +left join + (select join_key, bug_field from + (select ss1.join_key, ss1.bug_field from + (select f1 as join_key, 666 as bug_field from int4_tbl i1) ss1 + ) foo2 + left join + (select unique2 as join_key from tenk1 i2) ss2 + using (join_key) + ) foo3 +using (join_key) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +== 385 +select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from + (values (0),(1)) foo1(join_key) +left join + (select join_key, bug_field from + (select ss1.join_key, ss1.bug_field from + (select f1 as join_key, 666 as bug_field from int4_tbl i1) ss1 + ) foo2 + left join + (select unique2 as join_key from tenk1 i2) ss2 + using (join_key) + ) foo3 +using (join_key) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="tenk1" +STMT: SelectStmt +== 386 +|-- +-- check handling of a variable-free join alias +|-- +explain (verbose, costs off) +select * from +int4_tbl i0 left join +( (select *, 123 as x from int4_tbl i1) ss1 + left join + (select *, q2 as x from int8_tbl i2) ss2 + using (x) +) ss0 +on (i0.f1 = ss0.f1) +order by i0.f1, x +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i0"="int4_tbl" +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 387 +select * from +int4_tbl i0 left join +( (select *, 123 as x from int4_tbl i1) ss1 + left join + (select *, q2 as x from int8_tbl i2) ss2 + using (x) +) ss0 +on (i0.f1 = ss0.f1) +order by i0.f1, x +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i0"="int4_tbl" +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int8_tbl" +STMT: SelectStmt +== 388 +|-- +-- test successful handling of nested outer joins with degenerate join quals +|-- + +explain (verbose, costs off) +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 389 +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +STMT: SelectStmt +== 390 +explain (verbose, costs off) +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i4b2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 391 +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i4b2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +STMT: SelectStmt +== 392 +explain (verbose, costs off) +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2 + where q1 = f1) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i4b2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 393 +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2 + where q1 = f1) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i4b2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 394 +explain (verbose, costs off) +select * from + text_tbl t1 + inner join int8_tbl i8 + on i8.q2 = 456 + right join text_tbl t2 + on t1.f1 = 'doh!' + left join int4_tbl i4 + on i8.q1 = i4.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 395 +select * from + text_tbl t1 + inner join int8_tbl i8 + on i8.q2 = 456 + right join text_tbl t2 + on t1.f1 = 'doh!' + left join int4_tbl i4 + on i8.q1 = i4.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +STMT: SelectStmt +== 396 +-- check handling of a variable-free qual for a non-commutable outer join +explain (costs off) +select nspname +from (select 1 as x) ss1 +left join +( select n.nspname, c.relname + from pg_class c left join pg_namespace n on n.oid = c.relnamespace + where c.relkind = 'r' +) ss2 on false +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "n"="pg_namespace" +FILTER: schema="" table="c" column="relkind" +STMT: ExplainStmt +STMT: SelectStmt +== 397 +-- check handling of apparently-commutable outer joins with non-commutable +-- joins between them +explain (costs off) +select 1 from + int4_tbl i4 + left join int8_tbl i8 on i4.f1 is not null + left join (select 1 as a) ss1 on null + join int4_tbl i42 on ss1.a is null or i8.q1 <> i8.q2 + right join (select 2 as b) ss2 + on ss2.b < i4.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 398 +|-- +-- test for appropriate join order in the presence of lateral references +|-- + +explain (verbose, costs off) +select * from + text_tbl t1 + left join int8_tbl i8 + on i8.q2 = 123, + lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss +where t1.f1 = ss.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="ss" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 399 +select * from + text_tbl t1 + left join int8_tbl i8 + on i8.q2 = 123, + lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss +where t1.f1 = ss.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="ss" column="f1" +STMT: SelectStmt +== 400 +explain (verbose, costs off) +select * from + text_tbl t1 + left join int8_tbl i8 + on i8.q2 = 123, + lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss1, + lateral (select ss1.* from text_tbl t3 limit 1) as ss2 +where t1.f1 = ss2.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +ALIAS: "t3"="text_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="ss2" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 401 +select * from + text_tbl t1 + left join int8_tbl i8 + on i8.q2 = 123, + lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss1, + lateral (select ss1.* from text_tbl t3 limit 1) as ss2 +where t1.f1 = ss2.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +ALIAS: "t3"="text_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="ss2" column="f1" +STMT: SelectStmt +== 402 +explain (verbose, costs off) +select 1 from + text_tbl as tt1 + inner join text_tbl as tt2 on (tt1.f1 = 'foo') + left join text_tbl as tt3 on (tt3.f1 = 'foo') + left join text_tbl as tt4 on (tt3.f1 = tt4.f1), + lateral (select tt4.f1 as c0 from text_tbl as tt5 limit 1) as ss1 +where tt1.f1 = ss1.c0 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "tt1"="text_tbl" +ALIAS: "tt2"="text_tbl" +ALIAS: "tt3"="text_tbl" +ALIAS: "tt4"="text_tbl" +ALIAS: "tt5"="text_tbl" +FILTER: schema="" table="tt1" column="f1" +FILTER: schema="" table="ss1" column="c0" +STMT: ExplainStmt +STMT: SelectStmt +== 403 +select 1 from + text_tbl as tt1 + inner join text_tbl as tt2 on (tt1.f1 = 'foo') + left join text_tbl as tt3 on (tt3.f1 = 'foo') + left join text_tbl as tt4 on (tt3.f1 = tt4.f1), + lateral (select tt4.f1 as c0 from text_tbl as tt5 limit 1) as ss1 +where tt1.f1 = ss1.c0 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "tt1"="text_tbl" +ALIAS: "tt2"="text_tbl" +ALIAS: "tt3"="text_tbl" +ALIAS: "tt4"="text_tbl" +ALIAS: "tt5"="text_tbl" +FILTER: schema="" table="tt1" column="f1" +FILTER: schema="" table="ss1" column="c0" +STMT: SelectStmt +== 404 +explain (verbose, costs off) +select 1 from + int4_tbl as i4 + inner join + ((select 42 as n from int4_tbl x1 left join int8_tbl x2 on f1 = q1) as ss1 + right join (select 1 as z) as ss2 on true) + on false, + lateral (select i4.f1, ss1.n from int8_tbl as i8 limit 1) as ss3 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "x1"="int4_tbl" +ALIAS: "x2"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 405 +select 1 from + int4_tbl as i4 + inner join + ((select 42 as n from int4_tbl x1 left join int8_tbl x2 on f1 = q1) as ss1 + right join (select 1 as z) as ss2 on true) + on false, + lateral (select i4.f1, ss1.n from int8_tbl as i8 limit 1) as ss3 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "x1"="int4_tbl" +ALIAS: "x2"="int8_tbl" +STMT: SelectStmt +== 406 +|-- +-- check a case where we formerly generated invalid parameterized paths +|-- + +begin +-- +STMT: TransactionStmt +== 407 +create temp table t (a int unique) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 408 +explain (costs off) +select 1 from t t1 + join lateral (select t1.a from (select 1) foo offset 0) as s1 on true + join + (select 1 from t t2 + inner join (t t3 + left join (t t4 left join t t5 on t4.a = 1) + on t3.a = t4.a) + on false + where t3.a = coalesce(t5.a,1)) as s2 + on true +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +ALIAS: "t4"="t" +ALIAS: "t5"="t" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t5" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 409 +rollback +-- +STMT: TransactionStmt +== 410 +|-- +-- check a case in which a PlaceHolderVar forces join order +|-- + +explain (verbose, costs off) +select ss2.* from + int4_tbl i41 + left join int8_tbl i8 + join (select i42.f1 as c1, i43.f1 as c2, 42 as c3 + from int4_tbl i42, int4_tbl i43) ss1 + on i8.q1 = ss1.c2 + on i41.f1 = ss1.c1, + lateral (select i41.*, i8.*, ss1.* from text_tbl limit 1) ss2 +where ss1.c2 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i41"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i43"="int4_tbl" +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="ss1" column="c2" +STMT: ExplainStmt +STMT: SelectStmt +== 411 +select ss2.* from + int4_tbl i41 + left join int8_tbl i8 + join (select i42.f1 as c1, i43.f1 as c2, 42 as c3 + from int4_tbl i42, int4_tbl i43) ss1 + on i8.q1 = ss1.c2 + on i41.f1 = ss1.c1, + lateral (select i41.*, i8.*, ss1.* from text_tbl limit 1) ss2 +where ss1.c2 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i41"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i43"="int4_tbl" +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="ss1" column="c2" +STMT: SelectStmt +== 412 +|-- +-- test successful handling of full join underneath left join (bug #14105) +|-- + +explain (costs off) +select * from + (select 1 as id) as xx + left join + (tenk1 as a1 full join (select 1 as id) as yy on (a1.unique1 = yy.id)) + on (xx.id = coalesce(yy.id)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a1"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +== 413 +select * from + (select 1 as id) as xx + left join + (tenk1 as a1 full join (select 1 as id) as yy on (a1.unique1 = yy.id)) + on (xx.id = coalesce(yy.id)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a1"="tenk1" +STMT: SelectStmt +== 414 +|-- +-- test ability to push constants through outer join clauses +|-- + +explain (costs off) + select * from int4_tbl a left join tenk1 b on f1 = unique2 where f1 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 415 +explain (costs off) + select * from tenk1 a full join tenk1 b using(unique2) where unique2 = 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 416 +|-- +-- test that quals attached to an outer join have correct semantics, +-- specifically that they don't re-use expressions computed below the join; +-- we force a mergejoin so that coalesce(b.q1, 1) appears as a join input +|-- + +set enable_hashjoin to off +-- +STMT: VariableSetStmt +== 417 +set enable_nestloop to off +-- +STMT: VariableSetStmt +== 418 +explain (verbose, costs off) + select a.q2, b.q1 + from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1) + where coalesce(b.q1, 1) > 0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="b" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 419 +select a.q2, b.q1 + from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1) + where coalesce(b.q1, 1) > 0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="b" column="q1" +STMT: SelectStmt +== 420 +reset enable_hashjoin +-- +STMT: VariableSetStmt +== 421 +reset enable_nestloop +-- +STMT: VariableSetStmt +== 422 +|-- +-- test join strength reduction with a SubPlan providing the proof +|-- + +explain (costs off) +select a.unique1, b.unique2 + from onek a left join onek b on a.unique1 = b.unique2 + where (b.unique2, random() > 0) = any (select q1, random() > 0 from int8_tbl c where c.q1 < b.unique1) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +ALIAS: "c"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="b" column="unique2" +FILTER: schema="" table="c" column="q1" +FILTER: schema="" table="b" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 423 +select a.unique1, b.unique2 + from onek a left join onek b on a.unique1 = b.unique2 + where (b.unique2, random() > 0) = any (select q1, random() > 0 from int8_tbl c where c.q1 < b.unique1) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +ALIAS: "c"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="b" column="unique2" +FILTER: schema="" table="c" column="q1" +FILTER: schema="" table="b" column="unique1" +STMT: SelectStmt +== 424 +|-- +-- test full-join strength reduction +|-- + +explain (costs off) +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where a.unique1 = 42 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="a" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 425 +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where a.unique1 = 42 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="a" column="unique1" +STMT: SelectStmt +== 426 +explain (costs off) +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where b.unique2 = 43 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 427 +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where b.unique2 = 43 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="b" column="unique2" +STMT: SelectStmt +== 428 +explain (costs off) +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where a.unique1 = 42 and b.unique2 = 42 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 429 +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where a.unique1 = 42 and b.unique2 = 42 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: SelectStmt +== 430 +|-- +-- test result-RTE removal underneath a full join +|-- + +explain (costs off) +select * from + (select * from int8_tbl i81 join (values(123,2)) v(v1,v2) on q2=v1) ss1 +full join + (select * from (values(456,2)) w(v1,v2) join int8_tbl i82 on q2=v1) ss2 +on true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 431 +select * from + (select * from int8_tbl i81 join (values(123,2)) v(v1,v2) on q2=v1) ss1 +full join + (select * from (values(456,2)) w(v1,v2) join int8_tbl i82 on q2=v1) ss2 +on true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +STMT: SelectStmt +== 432 +|-- +-- test join removal +|-- + +begin +-- +STMT: TransactionStmt +== 433 +CREATE TEMP TABLE a (id int PRIMARY KEY, b_id int) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +== 434 +CREATE TEMP TABLE b (id int PRIMARY KEY, c_id int) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +== 435 +CREATE TEMP TABLE c (id int PRIMARY KEY) +-- +TABLE: name="c" schema="" table="c" ctx=DDL +STMT: CreateStmt +== 436 +CREATE TEMP TABLE d (a int, b int) +-- +TABLE: name="d" schema="" table="d" ctx=DDL +STMT: CreateStmt +== 437 +INSERT INTO a VALUES (0, 0), (1, NULL) +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 438 +INSERT INTO b VALUES (0, 0), (1, NULL) +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 439 +INSERT INTO c VALUES (0), (1) +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 440 +INSERT INTO d VALUES (1,3), (2,2), (3,1) +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 441 +-- all three cases should be optimizable into a simple seqscan +explain (costs off) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 442 +explain (costs off) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="c" schema="" table="c" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 443 +explain (costs off) + SELECT a.* FROM a LEFT JOIN (b left join c on b.c_id = c.id) + ON (a.b_id = b.id) +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="c" schema="" table="c" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 444 +-- check optimization of outer join within another special join +explain (costs off) +select id from a where id in ( + select b.id from b left join c on b.id = c.id +) +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="c" schema="" table="c" ctx=Select +FILTER: schema="" table="" column="id" +STMT: ExplainStmt +STMT: SelectStmt +== 445 +-- check optimization with oddly-nested outer joins +explain (costs off) +select a1.id from + (a a1 left join a a2 on true) + left join + (a a3 left join a a4 on a3.id = a4.id) + on a2.id = a3.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "a1"="a" +ALIAS: "a2"="a" +ALIAS: "a3"="a" +ALIAS: "a4"="a" +STMT: ExplainStmt +STMT: SelectStmt +== 446 +explain (costs off) +select a1.id from + (a a1 left join a a2 on a1.id = a2.id) + left join + (a a3 left join a a4 on a3.id = a4.id) + on a2.id = a3.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "a1"="a" +ALIAS: "a2"="a" +ALIAS: "a3"="a" +ALIAS: "a4"="a" +STMT: ExplainStmt +STMT: SelectStmt +== 447 +explain (costs off) +select 1 from a t1 + left join a t2 on true + inner join a t3 on true + left join a t4 on t2.id = t4.id and t2.id = t3.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "t1"="a" +ALIAS: "t2"="a" +ALIAS: "t3"="a" +ALIAS: "t4"="a" +STMT: ExplainStmt +STMT: SelectStmt +== 448 +-- another example (bug #17781) +explain (costs off) +select ss1.f1 +from int4_tbl as t1 + left join (int4_tbl as t2 + right join int4_tbl as t3 on null + left join (int4_tbl as t4 + right join int8_tbl as t5 on null) + on t2.f1 = t4.f1 + left join ((select null as f1 from int4_tbl as t6) as ss1 + inner join int8_tbl as t7 on null) + on t5.q1 = t7.q2) + on false +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +ALIAS: "t5"="int8_tbl" +ALIAS: "t6"="int4_tbl" +ALIAS: "t7"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 449 +-- variant with Var rather than PHV coming from t6 +explain (costs off) +select ss1.f1 +from int4_tbl as t1 + left join (int4_tbl as t2 + right join int4_tbl as t3 on null + left join (int4_tbl as t4 + right join int8_tbl as t5 on null) + on t2.f1 = t4.f1 + left join ((select f1 from int4_tbl as t6) as ss1 + inner join int8_tbl as t7 on null) + on t5.q1 = t7.q2) + on false +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +ALIAS: "t5"="int8_tbl" +ALIAS: "t6"="int4_tbl" +ALIAS: "t7"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 450 +-- per further discussion of bug #17781 +explain (costs off) +select ss1.x +from (select f1/2 as x from int4_tbl i4 left join a on a.id = i4.f1) ss1 + right join int8_tbl i8 on true +where current_user is not null +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 451 +-- this is to add a Result node + +-- and further discussion of bug #17781 +explain (costs off) +select * +from int8_tbl t1 + left join (int8_tbl t2 left join onek t3 on t2.q1 > t3.unique1) + on t1.q2 = t2.q2 + left join onek t4 + on t2.q2 < t3.unique2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="onek" +ALIAS: "t4"="onek" +STMT: ExplainStmt +STMT: SelectStmt +== 452 +-- More tests of correct placement of pseudoconstant quals + +-- simple constant-false condition +explain (costs off) +select * from int8_tbl t1 left join + (int8_tbl t2 inner join int8_tbl t3 on false + left join int8_tbl t4 on t2.q2 = t4.q2) +on t1.q1 = t2.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +ALIAS: "t4"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 453 +-- deduce constant-false from an EquivalenceClass +explain (costs off) +select * from int8_tbl t1 left join + (int8_tbl t2 inner join int8_tbl t3 on (t2.q1-t3.q2) = 0 and (t2.q1-t3.q2) = 1 + left join int8_tbl t4 on t2.q2 = t4.q2) +on t1.q1 = t2.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +ALIAS: "t4"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 454 +-- pseudoconstant based on an outer-level Param +explain (costs off) +select exists( + select * from int8_tbl t1 left join + (int8_tbl t2 inner join int8_tbl t3 on x0.f1 = 1 + left join int8_tbl t4 on t2.q2 = t4.q2) + on t1.q1 = t2.q1 +) from int4_tbl x0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +ALIAS: "t4"="int8_tbl" +ALIAS: "x0"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 455 +-- check that join removal works for a left join when joining a subquery +-- that is guaranteed to be unique by its GROUP BY clause +explain (costs off) +select d.* from d left join (select * from b group by b.id, b.c_id) s + on d.a = s.id and d.b = s.c_id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 456 +-- similarly, but keying off a DISTINCT clause +explain (costs off) +select d.* from d left join (select distinct * from b) s + on d.a = s.id and d.b = s.c_id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 457 +-- join removal is not possible when the GROUP BY contains a column that is +-- not in the join condition. (Note: as of 9.6, we notice that b.id is a +-- primary key and so drop b.c_id from the GROUP BY of the resulting plan; +-- but this happens too late for join removal in the outer plan level.) +explain (costs off) +select d.* from d left join (select * from b group by b.id, b.c_id) s + on d.a = s.id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 458 +-- similarly, but keying off a DISTINCT clause +explain (costs off) +select d.* from d left join (select distinct * from b) s + on d.a = s.id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 459 +-- join removal is not possible here +explain (costs off) +select 1 from a t1 + left join (a t2 left join a t3 on t2.id = 1) on t2.id = 1 +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "t1"="a" +ALIAS: "t2"="a" +ALIAS: "t3"="a" +STMT: ExplainStmt +STMT: SelectStmt +== 460 +-- check join removal works when uniqueness of the join condition is enforced +-- by a UNION +explain (costs off) +select d.* from d left join (select id from a union select id from b) s + on d.a = s.id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 461 +-- check join removal with a cross-type comparison operator +explain (costs off) +select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4 + on i8.q1 = i4.f1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 462 +-- check join removal with lateral references +explain (costs off) +select 1 from (select a.id FROM a left join b on a.b_id = b.id) q, + lateral generate_series(1, q.id) gs(i) where q.id = gs.i +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="q" column="id" +FILTER: schema="" table="gs" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 463 +-- check join removal within RHS of an outer join +explain (costs off) +select c.id, ss.a from c + left join (select d.a from onerow, d left join b on d.a = b.id) ss + on c.id = ss.a +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 464 +CREATE TEMP TABLE parted_b (id int PRIMARY KEY) partition by range(id) +-- +TABLE: name="parted_b" schema="" table="parted_b" ctx=DDL +STMT: CreateStmt +== 465 +CREATE TEMP TABLE parted_b1 partition of parted_b for values from (0) to (10) +-- +TABLE: name="parted_b1" schema="" table="parted_b1" ctx=DDL +STMT: CreateStmt +== 466 +-- test join removals on a partitioned table +explain (costs off) +select a.* from a left join parted_b pb on a.b_id = pb.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="parted_b" schema="" table="parted_b" ctx=Select +ALIAS: "pb"="parted_b" +STMT: ExplainStmt +STMT: SelectStmt +== 467 +rollback +-- +STMT: TransactionStmt +== 468 +create temp table parent (k int primary key, pd int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 469 +create temp table child (k int unique, cd int) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 470 +insert into parent values (1, 10), (2, 20), (3, 30) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 471 +insert into child values (1, 100), (4, 400) +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 472 +-- this case is optimizable +select p.* from parent p left join child c on (p.k = c.k) +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +STMT: SelectStmt +== 473 +explain (costs off) + select p.* from parent p left join child c on (p.k = c.k) +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +STMT: ExplainStmt +STMT: SelectStmt +== 474 +-- this case is not +select p.*, linked from parent p + left join (select c.*, true as linked from child c) as ss + on (p.k = ss.k) +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +STMT: SelectStmt +== 475 +explain (costs off) + select p.*, linked from parent p + left join (select c.*, true as linked from child c) as ss + on (p.k = ss.k) +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +STMT: ExplainStmt +STMT: SelectStmt +== 476 +-- check for a 9.0rc1 bug: join removal breaks pseudoconstant qual handling +select p.* from + parent p left join child c on (p.k = c.k) + where p.k = 1 and p.k = 2 +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +FILTER: schema="" table="p" column="k" +FILTER: schema="" table="p" column="k" +STMT: SelectStmt +== 477 +explain (costs off) +select p.* from + parent p left join child c on (p.k = c.k) + where p.k = 1 and p.k = 2 +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +FILTER: schema="" table="p" column="k" +FILTER: schema="" table="p" column="k" +STMT: ExplainStmt +STMT: SelectStmt +== 478 +select p.* from + (parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k + where p.k = 1 and p.k = 2 +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +TABLE: name="parent" schema="" table="parent" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +ALIAS: "x"="parent" +FILTER: schema="" table="p" column="k" +FILTER: schema="" table="p" column="k" +STMT: SelectStmt +== 479 +explain (costs off) +select p.* from + (parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k + where p.k = 1 and p.k = 2 +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +TABLE: name="parent" schema="" table="parent" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +ALIAS: "x"="parent" +FILTER: schema="" table="p" column="k" +FILTER: schema="" table="p" column="k" +STMT: ExplainStmt +STMT: SelectStmt +== 480 +-- bug 5255: this is not optimizable by join removal +begin +-- +STMT: TransactionStmt +== 481 +CREATE TEMP TABLE a (id int PRIMARY KEY) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +== 482 +CREATE TEMP TABLE b (id int PRIMARY KEY, a_id int) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +== 483 +INSERT INTO a VALUES (0), (1) +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 484 +INSERT INTO b VALUES (0, 0), (1, NULL) +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 485 +SELECT * FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0) +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="a" column="id" +STMT: SelectStmt +== 486 +SELECT b.* FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0) +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="a" column="id" +STMT: SelectStmt +== 487 +rollback +-- +STMT: TransactionStmt +== 488 +-- another join removal bug: this is not optimizable, either +begin +-- +STMT: TransactionStmt +== 489 +create temp table innertab (id int8 primary key, dat1 int8) +-- +TABLE: name="innertab" schema="" table="innertab" ctx=DDL +STMT: CreateStmt +== 490 +insert into innertab values(123, 42) +-- +TABLE: name="innertab" schema="" table="innertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 491 +SELECT * FROM + (SELECT 1 AS x) ss1 + LEFT JOIN + (SELECT q1, q2, COALESCE(dat1, q1) AS y + FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss2 + ON true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="innertab" schema="" table="innertab" ctx=Select +STMT: SelectStmt +== 492 +-- join removal bug #17769: can't remove if there's a pushed-down reference +EXPLAIN (COSTS OFF) +SELECT q2 FROM + (SELECT * + FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss + WHERE COALESCE(dat1, 0) = q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="innertab" schema="" table="innertab" ctx=Select +FILTER: schema="" table="" column="dat1" +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 493 +-- join removal bug #17773: otherwise-removable PHV appears in a qual condition +EXPLAIN (VERBOSE, COSTS OFF) +SELECT q2 FROM + (SELECT q2, 'constant'::text AS x + FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss + RIGHT JOIN int4_tbl ON NULL + WHERE x >= x +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="innertab" schema="" table="innertab" ctx=Select +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 494 +-- join removal bug #17786: check that OR conditions are cleaned up +EXPLAIN (COSTS OFF) +SELECT f1, x +FROM int4_tbl + JOIN ((SELECT 42 AS x FROM int8_tbl LEFT JOIN innertab ON q1 = id) AS ss1 + RIGHT JOIN tenk1 ON NULL) + ON tenk1.unique1 = ss1.x OR tenk1.unique2 = ss1.x +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="innertab" schema="" table="innertab" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 495 +rollback +-- +STMT: TransactionStmt +== 496 +-- another join removal bug: we must clean up correctly when removing a PHV +begin +-- +STMT: TransactionStmt +== 497 +create temp table uniquetbl (f1 text unique) +-- +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=DDL +STMT: CreateStmt +== 498 +explain (costs off) +select t1.* from + uniquetbl as t1 + left join (select *, '***'::text as d1 from uniquetbl) t2 + on t1.f1 = t2.f1 + left join uniquetbl t3 + on t2.d1 = t3.f1 +-- +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +ALIAS: "t1"="uniquetbl" +ALIAS: "t3"="uniquetbl" +STMT: ExplainStmt +STMT: SelectStmt +== 499 +explain (costs off) +select t0.* +from + text_tbl t0 + left join + (select case t1.ten when 0 then 'doh!'::text else null::text end as case1, + t1.stringu2 + from tenk1 t1 + join int4_tbl i4 ON i4.f1 = t1.unique2 + left join uniquetbl u1 ON u1.f1 = t1.string4) ss + on t0.f1 = ss.case1 +where ss.stringu2 !~* ss.case1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "t0"="text_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "u1"="uniquetbl" +FILTER: schema="" table="ss" column="stringu2" +FILTER: schema="" table="ss" column="case1" +STMT: ExplainStmt +STMT: SelectStmt +== 500 +select t0.* +from + text_tbl t0 + left join + (select case t1.ten when 0 then 'doh!'::text else null::text end as case1, + t1.stringu2 + from tenk1 t1 + join int4_tbl i4 ON i4.f1 = t1.unique2 + left join uniquetbl u1 ON u1.f1 = t1.string4) ss + on t0.f1 = ss.case1 +where ss.stringu2 !~* ss.case1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "t0"="text_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "u1"="uniquetbl" +FILTER: schema="" table="ss" column="stringu2" +FILTER: schema="" table="ss" column="case1" +STMT: SelectStmt +== 501 +rollback +-- +STMT: TransactionStmt +== 502 +-- another join removal bug: we must clean up EquivalenceClasses too +begin +-- +STMT: TransactionStmt +== 503 +create temp table t (a int unique) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 504 +insert into t values (1) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 505 +explain (costs off) +select 1 +from t t1 + left join (select 2 as c + from t t2 left join t t3 on t2.a = t3.a) s + on true +where t1.a = s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 506 +select 1 +from t t1 + left join (select 2 as c + from t t2 left join t t3 on t2.a = t3.a) s + on true +where t1.a = s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="s" column="c" +STMT: SelectStmt +== 507 +rollback +-- +STMT: TransactionStmt +== 508 +-- test cases where we can remove a join, but not a PHV computed at it +begin +-- +STMT: TransactionStmt +== 509 +create temp table t (a int unique, b int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 510 +insert into t values (1,1), (2,2) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 511 +explain (costs off) +select 1 +from t t1 + left join (select t2.a, 1 as c + from t t2 left join t t3 on t2.a = t3.a) s + on true + left join t t4 on true +where s.a < s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +ALIAS: "t4"="t" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 512 +explain (costs off) +select t1.a, s.* +from t t1 + left join lateral (select t2.a, coalesce(t1.a, 1) as c + from t t2 left join t t3 on t2.a = t3.a) s + on true + left join t t4 on true +where s.a < s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +ALIAS: "t4"="t" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 513 +select t1.a, s.* +from t t1 + left join lateral (select t2.a, coalesce(t1.a, 1) as c + from t t2 left join t t3 on t2.a = t3.a) s + on true + left join t t4 on true +where s.a < s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +ALIAS: "t4"="t" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="c" +STMT: SelectStmt +== 514 +rollback +-- +STMT: TransactionStmt +== 515 +-- test case to expose miscomputation of required relid set for a PHV +explain (verbose, costs off) +select i8.*, ss.v, t.unique2 + from int8_tbl i8 + left join int4_tbl i4 on i4.f1 = 1 + left join lateral (select i4.f1 + 1 as v) as ss on true + left join tenk1 t on t.unique2 = ss.v +where q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="tenk1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 516 +select i8.*, ss.v, t.unique2 + from int8_tbl i8 + left join int4_tbl i4 on i4.f1 = 1 + left join lateral (select i4.f1 + 1 as v) as ss on true + left join tenk1 t on t.unique2 = ss.v +where q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="tenk1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 517 +-- and check a related issue where we miscompute required relids for +-- a PHV that's been translated to a child rel +create temp table parttbl (a integer primary key) partition by range (a) +-- +TABLE: name="parttbl" schema="" table="parttbl" ctx=DDL +STMT: CreateStmt +== 518 +create temp table parttbl1 partition of parttbl for values from (1) to (100) +-- +TABLE: name="parttbl1" schema="" table="parttbl1" ctx=DDL +STMT: CreateStmt +== 519 +insert into parttbl values (11), (12) +-- +TABLE: name="parttbl" schema="" table="parttbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 520 +explain (costs off) +select * from + (select *, 12 as phv from parttbl) as ss + right join int4_tbl on true +where ss.a = ss.phv and f1 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="parttbl" schema="" table="parttbl" ctx=Select +FILTER: schema="" table="ss" column="a" +FILTER: schema="" table="ss" column="phv" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 521 +select * from + (select *, 12 as phv from parttbl) as ss + right join int4_tbl on true +where ss.a = ss.phv and f1 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="parttbl" schema="" table="parttbl" ctx=Select +FILTER: schema="" table="ss" column="a" +FILTER: schema="" table="ss" column="phv" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 522 +-- bug #8444: we've historically allowed duplicate aliases within aliased JOINs + +select * from + int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = f1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "x"="int4_tbl" +ALIAS: "y"="int4_tbl" +STMT: SelectStmt +== 523 +-- error +select * from + int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = y.f1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "x"="int4_tbl" +ALIAS: "y"="int4_tbl" +STMT: SelectStmt +== 524 +-- error +select * from + int8_tbl x join (int4_tbl x cross join int4_tbl y(ff)) j on q1 = f1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "x"="int4_tbl" +ALIAS: "y"="int4_tbl" +STMT: SelectStmt +== 525 +-- ok + +|-- +-- Test hints given on incorrect column references are useful +|-- + +select t1.uunique1 from + tenk1 t1 join tenk2 t2 on t1.two = t2.two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: SelectStmt +== 526 +-- error, prefer "t1" suggestion +select t2.uunique1 from + tenk1 t1 join tenk2 t2 on t1.two = t2.two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: SelectStmt +== 527 +-- error, prefer "t2" suggestion +select uunique1 from + tenk1 t1 join tenk2 t2 on t1.two = t2.two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: SelectStmt +== 528 +-- error, suggest both at once +select ctid from + tenk1 t1 join tenk2 t2 on t1.two = t2.two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: SelectStmt +== 529 +-- error, need qualification + +|-- +-- Take care to reference the correct RTE +|-- + +select atts.relid::regclass, s.* from pg_stats s join + pg_attribute a on s.attname = a.attname and s.tablename = + a.attrelid::regclass::text join (select unnest(indkey) attnum, + indexrelid from pg_index i) atts on atts.attnum = a.attnum where + schemaname != 'pg_catalog' +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "i"="pg_index" +ALIAS: "s"="pg_stats" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +== 530 +-- Test bug in rangetable flattening +explain (verbose, costs off) +select 1 from + (select * from int8_tbl where q1 <> (select 42) offset 0) ss +where false +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 531 +|-- +-- Test LATERAL +|-- + +select unique2, x.* +from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="a" column="unique1" +STMT: SelectStmt +== 532 +explain (costs off) + select unique2, x.* + from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="a" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 533 +select unique2, x.* +from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 534 +explain (costs off) + select unique2, x.* + from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 535 +explain (costs off) + select unique2, x.* + from int4_tbl x cross join lateral (select unique2 from tenk1 where f1 = unique1) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 536 +select unique2, x.* +from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 537 +explain (costs off) + select unique2, x.* + from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 538 +-- check scoping of lateral versus parent references +-- the first of these should return int8_tbl.q2, the second int8_tbl.q1 +select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 539 +select *, (select r from (select q1 as q2) x, lateral (select q2 as r) y) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 540 +-- lateral with function in FROM +select count(*) from tenk1 a, lateral generate_series(1,two) g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 541 +explain (costs off) + select count(*) from tenk1 a, lateral generate_series(1,two) g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 542 +explain (costs off) + select count(*) from tenk1 a cross join lateral generate_series(1,two) g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 543 +-- don't need the explicit LATERAL keyword for functions +explain (costs off) + select count(*) from tenk1 a, generate_series(1,two) g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 544 +-- lateral with UNION ALL subselect +explain (costs off) + select * from generate_series(100,200) g, + lateral (select * from int8_tbl a where g = q1 union all + select * from int8_tbl b where g = q2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="g" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="g" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 545 +select * from generate_series(100,200) g, + lateral (select * from int8_tbl a where g = q1 union all + select * from int8_tbl b where g = q2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="g" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="g" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 546 +-- lateral with VALUES +explain (costs off) + select count(*) from tenk1 a, + tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 547 +select count(*) from tenk1 a, + tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 548 +-- lateral with VALUES, no flattening possible +explain (costs off) + select count(*) from tenk1 a, + tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 549 +select count(*) from tenk1 a, + tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 550 +-- lateral injecting a strange outer join condition +explain (costs off) + select * from int8_tbl a, + int8_tbl x left join lateral (select a.q1 from int4_tbl y) ss(z) + on x.q2 = ss.z + order by a.q1, a.q2, x.q1, x.q2, ss.z +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "x"="int8_tbl" +ALIAS: "y"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 551 +select * from int8_tbl a, + int8_tbl x left join lateral (select a.q1 from int4_tbl y) ss(z) + on x.q2 = ss.z + order by a.q1, a.q2, x.q1, x.q2, ss.z +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "x"="int8_tbl" +ALIAS: "y"="int4_tbl" +STMT: SelectStmt +== 552 +-- lateral reference to a join alias variable +select * from (select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1, + lateral (select x) ss2(y) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +STMT: SelectStmt +== 553 +select * from (select f1 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1, + lateral (values(x)) ss2(y) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +STMT: SelectStmt +== 554 +select * from ((select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1) j, + lateral (select x) ss2(y) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +STMT: SelectStmt +== 555 +-- lateral references requiring pullup +select * from (values(1)) x(lb), + lateral generate_series(lb,4) x4 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 556 +select * from (select f1/1000000000 from int4_tbl) x(lb), + lateral generate_series(lb,4) x4 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 557 +select * from (values(1)) x(lb), + lateral (values(lb)) y(lbcopy) +-- +STMT: SelectStmt +== 558 +select * from (values(1)) x(lb), + lateral (select lb from int4_tbl) y(lbcopy) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +== 559 +select * from + int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1, + lateral (values(x.q1,y.q1,y.q2)) v(xq1,yq1,yq2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +STMT: SelectStmt +== 560 +select * from + int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1, + lateral (select x.q1,y.q1,y.q2) v(xq1,yq1,yq2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +STMT: SelectStmt +== 561 +select x.* from + int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1, + lateral (select x.q1,y.q1,y.q2) v(xq1,yq1,yq2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +STMT: SelectStmt +== 562 +select v.* from + (int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1) + left join int4_tbl z on z.f1 = x.q2, + lateral (select x.q1,y.q1 union all select x.q2,y.q2) v(vx,vy) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +ALIAS: "z"="int4_tbl" +STMT: SelectStmt +== 563 +select v.* from + (int8_tbl x left join (select q1,(select coalesce(q2,0)) q2 from int8_tbl) y on x.q2 = y.q1) + left join int4_tbl z on z.f1 = x.q2, + lateral (select x.q1,y.q1 union all select x.q2,y.q2) v(vx,vy) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +ALIAS: "z"="int4_tbl" +STMT: SelectStmt +== 564 +select v.* from + (int8_tbl x left join (select q1,(select coalesce(q2,0)) q2 from int8_tbl) y on x.q2 = y.q1) + left join int4_tbl z on z.f1 = x.q2, + lateral (select x.q1,y.q1 from onerow union all select x.q2,y.q2 from onerow) v(vx,vy) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +ALIAS: "x"="int8_tbl" +ALIAS: "z"="int4_tbl" +STMT: SelectStmt +== 565 +explain (verbose, costs off) +select * from + int8_tbl a left join + lateral (select *, a.q2 as x from int8_tbl b) ss on a.q2 = ss.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 566 +select * from + int8_tbl a left join + lateral (select *, a.q2 as x from int8_tbl b) ss on a.q2 = ss.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: SelectStmt +== 567 +explain (verbose, costs off) +select * from + int8_tbl a left join + lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 568 +select * from + int8_tbl a left join + lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: SelectStmt +== 569 +-- lateral can result in join conditions appearing below their +-- real semantic level +explain (verbose, costs off) +select * from int4_tbl i left join + lateral (select * from int2_tbl j where i.f1 = j.f1) k on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "j"="int2_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="j" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 570 +select * from int4_tbl i left join + lateral (select * from int2_tbl j where i.f1 = j.f1) k on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "j"="int2_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="j" column="f1" +STMT: SelectStmt +== 571 +explain (verbose, costs off) +select * from int4_tbl i left join + lateral (select coalesce(i) from int2_tbl j where i.f1 = j.f1) k on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "j"="int2_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="j" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 572 +select * from int4_tbl i left join + lateral (select coalesce(i) from int2_tbl j where i.f1 = j.f1) k on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "j"="int2_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="j" column="f1" +STMT: SelectStmt +== 573 +explain (verbose, costs off) +select * from int4_tbl a, + lateral ( + select * from int4_tbl b left join int8_tbl c on (b.f1 = q1 and a.f1 = q2) + ) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +ALIAS: "c"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 574 +select * from int4_tbl a, + lateral ( + select * from int4_tbl b left join int8_tbl c on (b.f1 = q1 and a.f1 = q2) + ) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +ALIAS: "c"="int8_tbl" +STMT: SelectStmt +== 575 +-- lateral reference in a PlaceHolderVar evaluated at join level +explain (verbose, costs off) +select * from + int8_tbl a left join lateral + (select b.q1 as bq1, c.q1 as cq1, least(a.q1,b.q1,c.q1) from + int8_tbl b cross join int8_tbl c) ss + on a.q2 = ss.bq1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 576 +select * from + int8_tbl a left join lateral + (select b.q1 as bq1, c.q1 as cq1, least(a.q1,b.q1,c.q1) from + int8_tbl b cross join int8_tbl c) ss + on a.q2 = ss.bq1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="int8_tbl" +STMT: SelectStmt +== 577 +-- case requiring nested PlaceHolderVars +explain (verbose, costs off) +select * from + int8_tbl c left join ( + int8_tbl a left join (select q1, coalesce(q2,42) as x from int8_tbl b) ss1 + on a.q2 = ss1.q1 + cross join + lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2 + ) on c.q2 = ss2.q1, + lateral (select ss2.y offset 0) ss3 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="int8_tbl" +ALIAS: "d"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 578 +-- another case requiring nested PlaceHolderVars +explain (verbose, costs off) +select * from + (select 0 as val0) as ss0 + left join (select 1 as val) as ss1 on true + left join lateral (select ss1.val as val_filtered where false) as ss2 on true +-- +STMT: ExplainStmt +STMT: SelectStmt +== 579 +select * from + (select 0 as val0) as ss0 + left join (select 1 as val) as ss1 on true + left join lateral (select ss1.val as val_filtered where false) as ss2 on true +-- +STMT: SelectStmt +== 580 +-- case that breaks the old ph_may_need optimization +explain (verbose, costs off) +select c.*,a.*,ss1.q1,ss2.q1,ss3.* from + int8_tbl c left join ( + int8_tbl a left join + (select q1, coalesce(q2,f1) as x from int8_tbl b, int4_tbl b2 + where q1 < f1) ss1 + on a.q2 = ss1.q1 + cross join + lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2 + ) on c.q2 = ss2.q1, + lateral (select * from int4_tbl i where ss2.y > f1) ss3 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "b2"="int4_tbl" +ALIAS: "c"="int8_tbl" +ALIAS: "d"="int8_tbl" +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="ss2" column="y" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 581 +-- check processing of postponed quals (bug #9041) +explain (verbose, costs off) +select * from + (select 1 as x offset 0) x cross join (select 2 as y offset 0) y + left join lateral ( + select * from (select 3 as z offset 0) z where z.z = x.x + ) zz on zz.z = y.y +-- +FILTER: schema="" table="z" column="z" +FILTER: schema="" table="x" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 582 +-- a new postponed-quals issue (bug #17768) +explain (costs off) +select * from int4_tbl t1, + lateral (select * from int4_tbl t2 inner join int4_tbl t3 on t1.f1 = 1 + inner join (int4_tbl t4 left join int4_tbl t5 on true) on true) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +ALIAS: "t5"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 583 +-- check dummy rels with lateral references (bug #15694) +explain (verbose, costs off) +select * from int8_tbl i8 left join lateral + (select *, i8.q2 from int4_tbl where false) ss on true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 584 +explain (verbose, costs off) +select * from int8_tbl i8 left join lateral + (select *, i8.q2 from int4_tbl i1, int4_tbl i2 where false) ss on true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 585 +-- check handling of nested appendrels inside LATERAL +select * from + ((select 2 as v) union all (select 3 as v)) as q1 + cross join lateral + ((select * from + ((select 4 as v) union all (select 5 as v)) as q3) + union all + (select q1.v) + ) as q2 +-- +STMT: SelectStmt +== 586 +-- check the number of columns specified +SELECT * FROM (int8_tbl i cross join int4_tbl j) ss(a,b,c,d) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +ALIAS: "j"="int4_tbl" +STMT: SelectStmt +== 587 +-- check we don't try to do a unique-ified semijoin with LATERAL +explain (verbose, costs off) +select * from + (values (0,9998), (1,1000)) v(id,x), + lateral (select f1 from int4_tbl + where f1 = any (select unique1 from tenk1 + where unique2 = v.x offset 0)) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="v" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 588 +select * from + (values (0,9998), (1,1000)) v(id,x), + lateral (select f1 from int4_tbl + where f1 = any (select unique1 from tenk1 + where unique2 = v.x offset 0)) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="v" column="x" +STMT: SelectStmt +== 589 +-- check proper extParam/allParam handling (this isn't exactly a LATERAL issue, +-- but we can make the test case much more compact with LATERAL) +explain (verbose, costs off) +select * from (values (0), (1)) v(id), +lateral (select * from int8_tbl t1, + lateral (select * from + (select * from int8_tbl t2 + where (q1, random() > 0) = any (select q2, random() > 0 from int8_tbl t3 + where q2 = (select greatest(t1.q1,t2.q2)) + and (select v.id=0)) offset 0) ss2) ss + where t1.q1 = ss.q2) ss0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="t1" column="q1" +FILTER: schema="" table="ss" column="q2" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 590 +select * from (values (0), (1)) v(id), +lateral (select * from int8_tbl t1, + lateral (select * from + (select * from int8_tbl t2 + where (q1, random() > 0) = any (select q2, random() > 0 from int8_tbl t3 + where q2 = (select greatest(t1.q1,t2.q2)) + and (select v.id=0)) offset 0) ss2) ss + where t1.q1 = ss.q2) ss0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="t1" column="q1" +FILTER: schema="" table="ss" column="q2" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 591 +-- test some error cases where LATERAL should have been used but wasn't +select f1,g from int4_tbl a, (select f1 as g) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +STMT: SelectStmt +== 592 +select f1,g from int4_tbl a, (select a.f1 as g) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +STMT: SelectStmt +== 593 +select f1,g from int4_tbl a cross join (select f1 as g) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +STMT: SelectStmt +== 594 +select f1,g from int4_tbl a cross join (select a.f1 as g) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +STMT: SelectStmt +== 595 +-- SQL:2008 says the left table is in scope but illegal to access here +select f1,g from int4_tbl a right join lateral generate_series(0, a.f1) g on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 596 +select f1,g from int4_tbl a full join lateral generate_series(0, a.f1) g on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 597 +-- check we complain about ambiguous table references +select * from + int8_tbl x cross join (int4_tbl x cross join lateral (select x.f1) ss) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "x"="int4_tbl" +STMT: SelectStmt +== 598 +-- LATERAL can be used to put an aggregate into the FROM clause of its query +select 1 from tenk1 a, lateral (select max(a.unique1) from int4_tbl b) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="int4_tbl" +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 599 +-- check behavior of LATERAL in UPDATE/DELETE + +create temp table xx1 as select f1 as x1, -f1 as x2 from int4_tbl +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DDL +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 600 +-- error, can't do this: +update xx1 set x2 = f1 from (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: UpdateStmt +STMT: SelectStmt +== 601 +update xx1 set x2 = f1 from (select * from int4_tbl where f1 = xx1.x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="xx1" column="x1" +STMT: UpdateStmt +STMT: SelectStmt +== 602 +-- can't do it even with LATERAL: +update xx1 set x2 = f1 from lateral (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: UpdateStmt +STMT: SelectStmt +== 603 +-- we might in future allow something like this, but for now it's an error: +update xx1 set x2 = f1 from xx1, lateral (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="xx1" schema="" table="xx1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: UpdateStmt +STMT: SelectStmt +== 604 +-- also errors: +delete from xx1 using (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: DeleteStmt +STMT: SelectStmt +== 605 +delete from xx1 using (select * from int4_tbl where f1 = xx1.x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="xx1" column="x1" +STMT: DeleteStmt +STMT: SelectStmt +== 606 +delete from xx1 using lateral (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: DeleteStmt +STMT: SelectStmt +== 607 +|-- +-- test LATERAL reference propagation down a multi-level inheritance hierarchy +-- produced for a multi-level partitioned table hierarchy. +|-- +create table join_pt1 (a int, b int, c varchar) partition by range(a) +-- +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=DDL +STMT: CreateStmt +== 608 +create table join_pt1p1 partition of join_pt1 for values from (0) to (100) partition by range(b) +-- +TABLE: name="join_pt1p1" schema="" table="join_pt1p1" ctx=DDL +STMT: CreateStmt +== 609 +create table join_pt1p2 partition of join_pt1 for values from (100) to (200) +-- +TABLE: name="join_pt1p2" schema="" table="join_pt1p2" ctx=DDL +STMT: CreateStmt +== 610 +create table join_pt1p1p1 partition of join_pt1p1 for values from (0) to (100) +-- +TABLE: name="join_pt1p1p1" schema="" table="join_pt1p1p1" ctx=DDL +STMT: CreateStmt +== 611 +insert into join_pt1 values (1, 1, 'x'), (101, 101, 'y') +-- +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 612 +create table join_ut1 (a int, b int, c varchar) +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=DDL +STMT: CreateStmt +== 613 +insert into join_ut1 values (101, 101, 'y'), (2, 2, 'z') +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 614 +explain (verbose, costs off) +select t1.b, ss.phv from join_ut1 t1 left join lateral + (select t2.a as t2a, t3.a t3a, least(t1.a, t2.a, t3.a) phv + from join_pt1 t2 join join_ut1 t3 on t2.a = t3.b) ss + on t1.a = ss.t2a order by t1.a +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=Select +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=Select +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=Select +ALIAS: "t1"="join_ut1" +ALIAS: "t2"="join_pt1" +ALIAS: "t3"="join_ut1" +STMT: ExplainStmt +STMT: SelectStmt +== 615 +select t1.b, ss.phv from join_ut1 t1 left join lateral + (select t2.a as t2a, t3.a t3a, least(t1.a, t2.a, t3.a) phv + from join_pt1 t2 join join_ut1 t3 on t2.a = t3.b) ss + on t1.a = ss.t2a order by t1.a +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=Select +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=Select +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=Select +ALIAS: "t1"="join_ut1" +ALIAS: "t2"="join_pt1" +ALIAS: "t3"="join_ut1" +STMT: SelectStmt +== 616 +drop table join_pt1 +-- +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=DDL +STMT: DropStmt +== 617 +drop table join_ut1 +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=DDL +STMT: DropStmt +== 618 +|-- +-- test estimation behavior with multi-column foreign key and constant qual +|-- + +begin +-- +STMT: TransactionStmt +== 619 +create table fkest (x integer, x10 integer, x10b integer, x100 integer) +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: CreateStmt +== 620 +insert into fkest select x, x/10, x/10, x/100 from generate_series(1,1000) x +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 621 +create unique index on fkest(x, x10, x100) +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: IndexStmt +== 622 +analyze fkest +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: VacuumStmt +== 623 +explain (costs off) +select * from fkest f1 + join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100) + join fkest f3 on f1.x = f3.x + where f1.x100 = 2 +-- +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest" schema="" table="fkest" ctx=Select +ALIAS: "f1"="fkest" +ALIAS: "f2"="fkest" +ALIAS: "f3"="fkest" +FILTER: schema="" table="f1" column="x100" +STMT: ExplainStmt +STMT: SelectStmt +== 624 +alter table fkest add constraint fk + foreign key (x, x10b, x100) references fkest (x, x10, x100) +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: AlterTableStmt +== 625 +explain (costs off) +select * from fkest f1 + join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100) + join fkest f3 on f1.x = f3.x + where f1.x100 = 2 +-- +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest" schema="" table="fkest" ctx=Select +ALIAS: "f1"="fkest" +ALIAS: "f2"="fkest" +ALIAS: "f3"="fkest" +FILTER: schema="" table="f1" column="x100" +STMT: ExplainStmt +STMT: SelectStmt +== 626 +rollback +-- +STMT: TransactionStmt +== 627 +|-- +-- test that foreign key join estimation performs sanely for outer joins +|-- + +begin +-- +STMT: TransactionStmt +== 628 +create table fkest (a int, b int, c int unique, primary key(a,b)) +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: CreateStmt +== 629 +create table fkest1 (a int, b int, primary key(a,b)) +-- +TABLE: name="fkest1" schema="" table="fkest1" ctx=DDL +STMT: CreateStmt +== 630 +insert into fkest select x/10, x%10, x from generate_series(1,1000) x +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 631 +insert into fkest1 select x/10, x%10 from generate_series(1,1000) x +-- +TABLE: name="fkest1" schema="" table="fkest1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 632 +alter table fkest1 + add constraint fkest1_a_b_fkey foreign key (a,b) references fkest +-- +TABLE: name="fkest1" schema="" table="fkest1" ctx=DDL +STMT: AlterTableStmt +== 633 +analyze fkest +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: VacuumStmt +== 634 +analyze fkest1 +-- +TABLE: name="fkest1" schema="" table="fkest1" ctx=DDL +STMT: VacuumStmt +== 635 +explain (costs off) +select * +from fkest f + left join fkest1 f1 on f.a = f1.a and f.b = f1.b + left join fkest1 f2 on f.a = f2.a and f.b = f2.b + left join fkest1 f3 on f.a = f3.a and f.b = f3.b +where f.c = 1 +-- +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest1" schema="" table="fkest1" ctx=Select +TABLE: name="fkest1" schema="" table="fkest1" ctx=Select +TABLE: name="fkest1" schema="" table="fkest1" ctx=Select +ALIAS: "f"="fkest" +ALIAS: "f1"="fkest1" +ALIAS: "f2"="fkest1" +ALIAS: "f3"="fkest1" +FILTER: schema="" table="f" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 636 +rollback +-- +STMT: TransactionStmt +== 637 +|-- +-- test planner's ability to mark joins as unique +|-- + +create table j1 (id int primary key) +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: CreateStmt +== 638 +create table j2 (id int primary key) +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: CreateStmt +== 639 +create table j3 (id int) +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: CreateStmt +== 640 +insert into j1 values(1),(2),(3) +-- +TABLE: name="j1" schema="" table="j1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 641 +insert into j2 values(1),(2),(3) +-- +TABLE: name="j2" schema="" table="j2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 642 +insert into j3 values(1),(1) +-- +TABLE: name="j3" schema="" table="j3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 643 +analyze j1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: VacuumStmt +== 644 +analyze j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: VacuumStmt +== 645 +analyze j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: VacuumStmt +== 646 +-- ensure join is properly marked as unique +explain (verbose, costs off) +select * from j1 inner join j2 on j1.id = j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 647 +-- ensure join is not unique when not an equi-join +explain (verbose, costs off) +select * from j1 inner join j2 on j1.id > j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 648 +-- ensure non-unique rel is not chosen as inner +explain (verbose, costs off) +select * from j1 inner join j3 on j1.id = j3.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j3" schema="" table="j3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 649 +-- ensure left join is marked as unique +explain (verbose, costs off) +select * from j1 left join j2 on j1.id = j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 650 +-- ensure right join is marked as unique +explain (verbose, costs off) +select * from j1 right join j2 on j1.id = j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 651 +-- ensure full join is marked as unique +explain (verbose, costs off) +select * from j1 full join j2 on j1.id = j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 652 +-- a clauseless (cross) join can't be unique +explain (verbose, costs off) +select * from j1 cross join j2 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 653 +-- ensure a natural join is marked as unique +explain (verbose, costs off) +select * from j1 natural join j2 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 654 +-- ensure a distinct clause allows the inner to become unique +explain (verbose, costs off) +select * from j1 +inner join (select distinct id from j3) j3 on j1.id = j3.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j3" schema="" table="j3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 655 +-- ensure group by clause allows the inner to become unique +explain (verbose, costs off) +select * from j1 +inner join (select id from j3 group by id) j3 on j1.id = j3.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j3" schema="" table="j3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 656 +drop table j1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: DropStmt +== 657 +drop table j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: DropStmt +== 658 +drop table j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: DropStmt +== 659 +-- test more complex permutations of unique joins + +create table j1 (id1 int, id2 int, primary key(id1,id2)) +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: CreateStmt +== 660 +create table j2 (id1 int, id2 int, primary key(id1,id2)) +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: CreateStmt +== 661 +create table j3 (id1 int, id2 int, primary key(id1,id2)) +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: CreateStmt +== 662 +insert into j1 values(1,1),(1,2) +-- +TABLE: name="j1" schema="" table="j1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 663 +insert into j2 values(1,1) +-- +TABLE: name="j2" schema="" table="j2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 664 +insert into j3 values(1,1) +-- +TABLE: name="j3" schema="" table="j3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 665 +analyze j1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: VacuumStmt +== 666 +analyze j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: VacuumStmt +== 667 +analyze j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: VacuumStmt +== 668 +-- ensure there's no unique join when not all columns which are part of the +-- unique index are seen in the join clause +explain (verbose, costs off) +select * from j1 +inner join j2 on j1.id1 = j2.id1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 669 +-- ensure proper unique detection with multiple join quals +explain (verbose, costs off) +select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 670 +-- ensure we don't detect the join to be unique when quals are not part of the +-- join condition +explain (verbose, costs off) +select * from j1 +inner join j2 on j1.id1 = j2.id1 where j1.id2 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id2" +STMT: ExplainStmt +STMT: SelectStmt +== 671 +-- as above, but for left joins. +explain (verbose, costs off) +select * from j1 +left join j2 on j1.id1 = j2.id1 where j1.id2 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id2" +STMT: ExplainStmt +STMT: SelectStmt +== 672 +create unique index j1_id2_idx on j1(id2) where id2 is not null +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: IndexStmt +== 673 +-- ensure we don't use a partial unique index as unique proofs +explain (verbose, costs off) +select * from j1 +inner join j2 on j1.id2 = j2.id2 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 674 +drop index j1_id2_idx +-- +STMT: DropStmt +== 675 +-- validate logic in merge joins which skips mark and restore. +-- it should only do this if all quals which were used to detect the unique +-- are present as join quals, and not plain quals. +set enable_nestloop to 0 +-- +STMT: VariableSetStmt +== 676 +set enable_hashjoin to 0 +-- +STMT: VariableSetStmt +== 677 +set enable_sort to 0 +-- +STMT: VariableSetStmt +== 678 +-- create indexes that will be preferred over the PKs to perform the join +create index j1_id1_idx on j1 (id1) where id1 % 1000 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: IndexStmt +== 679 +create index j2_id1_idx on j2 (id1) where id1 % 1000 = 1 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: IndexStmt +== 680 +-- need an additional row in j2, if we want j2_id1_idx to be preferred +insert into j2 values(1,2) +-- +TABLE: name="j2" schema="" table="j2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 681 +analyze j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: VacuumStmt +== 682 +explain (costs off) select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: ExplainStmt +STMT: SelectStmt +== 683 +select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: SelectStmt +== 684 +-- Exercise array keys mark/restore B-Tree code +explain (costs off) select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]) +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: ExplainStmt +STMT: SelectStmt +== 685 +select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]) +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: SelectStmt +== 686 +-- Exercise array keys "find extreme element" B-Tree code +explain (costs off) select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]) +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: ExplainStmt +STMT: SelectStmt +== 687 +select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]) +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: SelectStmt +== 688 +reset enable_nestloop +-- +STMT: VariableSetStmt +== 689 +reset enable_hashjoin +-- +STMT: VariableSetStmt +== 690 +reset enable_sort +-- +STMT: VariableSetStmt +== 691 +drop table j1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: DropStmt +== 692 +drop table j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: DropStmt +== 693 +drop table j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: DropStmt +== 694 +-- check that semijoin inner is not seen as unique for a portion of the outerrel +explain (verbose, costs off) +select t1.unique1, t2.hundred +from onek t1, tenk1 t2 +where exists (select 1 from tenk1 t3 + where t3.thousand = t1.unique1 and t3.tenthous = t2.hundred) + and t1.unique1 < 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FILTER: schema="" table="t3" column="thousand" +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t3" column="tenthous" +FILTER: schema="" table="t2" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 695 +-- ... unless it actually is unique +create table j3 as select unique1, tenthous from onek +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 696 +vacuum analyze j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: VacuumStmt +== 697 +create unique index on j3(unique1, tenthous) +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: IndexStmt +== 698 +explain (verbose, costs off) +select t1.unique1, t2.hundred +from onek t1, tenk1 t2 +where exists (select 1 from j3 + where j3.unique1 = t1.unique1 and j3.tenthous = t2.hundred) + and t1.unique1 < 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="j3" schema="" table="j3" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="j3" column="unique1" +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="j3" column="tenthous" +FILTER: schema="" table="t2" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 699 +drop table j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: DropStmt +== 700 +-- Exercise the "skip fetch" Bitmap Heap Scan optimization when candidate +-- tuples are discarded. This may occur when: +-- 1. A join doesn't require all inner tuples to be scanned for each outer +-- tuple, and +-- 2. The inner side is scanned using a bitmap heap scan, and +-- 3. The bitmap heap scan is eligible for the "skip fetch" optimization. +-- This optimization is usable when no data from the underlying table is +-- needed. Use a temp table so it is only visible to this backend and +-- vacuum may reliably mark all blocks in the table all visible in the +-- visibility map. +CREATE TEMP TABLE skip_fetch (a INT, b INT) WITH (fillfactor=10) +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=DDL +STMT: CreateStmt +== 701 +INSERT INTO skip_fetch SELECT i % 3, i FROM generate_series(0,30) i +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 702 +CREATE INDEX ON skip_fetch(a) +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=DDL +STMT: IndexStmt +== 703 +VACUUM (ANALYZE) skip_fetch +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=DDL +STMT: VacuumStmt +== 704 +SET enable_indexonlyscan = off +-- +STMT: VariableSetStmt +== 705 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 706 +EXPLAIN (COSTS OFF) +SELECT t1.a FROM skip_fetch t1 LEFT JOIN skip_fetch t2 ON t2.a = 1 WHERE t2.a IS NULL +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=Select +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=Select +ALIAS: "t1"="skip_fetch" +ALIAS: "t2"="skip_fetch" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 707 +SELECT t1.a FROM skip_fetch t1 LEFT JOIN skip_fetch t2 ON t2.a = 1 WHERE t2.a IS NULL +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=Select +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=Select +ALIAS: "t1"="skip_fetch" +ALIAS: "t2"="skip_fetch" +FILTER: schema="" table="t2" column="a" +STMT: SelectStmt +== 708 +RESET enable_indexonlyscan +-- +STMT: VariableSetStmt +== 709 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 710 +-- Test that we do not account for nullingrels when looking up statistics +CREATE TABLE group_tbl (a INT, b INT) +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=DDL +STMT: CreateStmt +== 711 +INSERT INTO group_tbl SELECT 1, 1 +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 712 +CREATE STATISTICS group_tbl_stat (ndistinct) ON a, b FROM group_tbl +-- +STMT: CreateStatsStmt +== 713 +ANALYZE group_tbl +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=DDL +STMT: VacuumStmt +== 714 +EXPLAIN (COSTS OFF) +SELECT 1 FROM group_tbl t1 + LEFT JOIN (SELECT a c1, COALESCE(a) c2 FROM group_tbl t2) s ON TRUE +GROUP BY s.c1, s.c2 +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=Select +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=Select +ALIAS: "t1"="group_tbl" +ALIAS: "t2"="group_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 715 +DROP TABLE group_tbl +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/join_hash.metadata.json b/parser/testdata/summary/postgres_regress/join_hash.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/join_hash.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/join_hash.test b/parser/testdata/summary/postgres_regress/join_hash.test new file mode 100644 index 0000000..6bab601 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/join_hash.test @@ -0,0 +1,1812 @@ +== 001 +|-- +-- exercises for the hash join code +|-- + +begin +-- +STMT: TransactionStmt +== 002 +set local min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 003 +set local parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 004 +set local enable_hashjoin = on +-- +STMT: VariableSetStmt +== 005 +-- Extract bucket and batch counts from an explain analyze plan. In +-- general we can't make assertions about how many batches (or +-- buckets) will be required because it can vary, but we can in some +-- special cases and we can check for growth. +create or replace function find_hash(node json) +returns json language plpgsql +as +$$ +declare + x json; + child json; +begin + if node->>'Node Type' = 'Hash' then + return node; + else + for child in select json_array_elements(node->'Plans') + loop + x := find_hash(child); + if x is not null then + return x; + end if; + end loop; + return null; + end if; +end; +$$ +-- +FUNCTION: name="find_hash" function="find_hash" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +create or replace function hash_join_batches(query text) +returns table (original int, final int) language plpgsql +as +$$ +declare + whole_plan json; + hash_node json; +begin + for whole_plan in + execute 'explain (analyze, format ''json'') ' || query + loop + hash_node := find_hash(json_extract_path(whole_plan, '0', 'Plan')); + original := hash_node->>'Original Hash Batches'; + final := hash_node->>'Hash Batches'; + return next; + end loop; +end; +$$ +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 007 +-- Make a simple relation with well distributed keys and correctly +-- estimated size. +create table simple as + select generate_series(1, 20000) AS id, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +-- +TABLE: name="simple" schema="" table="simple" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 008 +alter table simple set (parallel_workers = 2) +-- +TABLE: name="simple" schema="" table="simple" ctx=DDL +STMT: AlterTableStmt +== 009 +analyze simple +-- +TABLE: name="simple" schema="" table="simple" ctx=DDL +STMT: VacuumStmt +== 010 +-- Make a relation whose size we will under-estimate. We want stats +-- to say 1000 rows, but actually there are 20,000 rows. +create table bigger_than_it_looks as + select generate_series(1, 20000) as id, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +-- +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 011 +alter table bigger_than_it_looks set (autovacuum_enabled = 'false') +-- +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=DDL +STMT: AlterTableStmt +== 012 +alter table bigger_than_it_looks set (parallel_workers = 2) +-- +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=DDL +STMT: AlterTableStmt +== 013 +analyze bigger_than_it_looks +-- +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=DDL +STMT: VacuumStmt +== 014 +update pg_class set reltuples = 1000 where relname = 'bigger_than_it_looks' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +STMT: UpdateStmt +== 015 +-- Make a relation whose size we underestimate and that also has a +-- kind of skew that breaks our batching scheme. We want stats to say +-- 2 rows, but actually there are 20,000 rows with the same key. +create table extremely_skewed (id int, t text) +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DDL +STMT: CreateStmt +== 016 +alter table extremely_skewed set (autovacuum_enabled = 'false') +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DDL +STMT: AlterTableStmt +== 017 +alter table extremely_skewed set (parallel_workers = 2) +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DDL +STMT: AlterTableStmt +== 018 +analyze extremely_skewed +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DDL +STMT: VacuumStmt +== 019 +insert into extremely_skewed + select 42 as id, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + from generate_series(1, 20000) +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 020 +update pg_class + set reltuples = 2, relpages = pg_relation_size('extremely_skewed') / 8192 + where relname = 'extremely_skewed' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: UpdateStmt +== 021 +-- Make a relation with a couple of enormous tuples. +create table wide as select generate_series(1, 2) as id, rpad('', 320000, 'x') as t +-- +TABLE: name="wide" schema="" table="wide" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="rpad" function="rpad" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 022 +alter table wide set (parallel_workers = 2) +-- +TABLE: name="wide" schema="" table="wide" ctx=DDL +STMT: AlterTableStmt +== 023 +-- The "optimal" case: the hash table fits in memory; we plan for 1 +-- batch, we stick to that number, and peak memory usage stays within +-- our work_mem budget + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +== 024 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 025 +set local work_mem = '4MB' +-- +STMT: VariableSetStmt +== 026 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 027 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 028 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 029 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 030 +rollback to settings +-- +STMT: TransactionStmt +== 031 +-- parallel with parallel-oblivious hash join +savepoint settings +-- +STMT: TransactionStmt +== 032 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 033 +set local work_mem = '4MB' +-- +STMT: VariableSetStmt +== 034 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 035 +set local enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 036 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 037 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 038 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 039 +rollback to settings +-- +STMT: TransactionStmt +== 040 +-- parallel with parallel-aware hash join +savepoint settings +-- +STMT: TransactionStmt +== 041 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 042 +set local work_mem = '4MB' +-- +STMT: VariableSetStmt +== 043 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 044 +set local enable_parallel_hash = on +-- +STMT: VariableSetStmt +== 045 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 046 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 047 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 048 +rollback to settings +-- +STMT: TransactionStmt +== 049 +-- The "good" case: batches required, but we plan the right number; we +-- plan for some number of batches, and we stick to that number, and +-- peak memory usage says within our work_mem budget + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +== 050 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 051 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +== 052 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 053 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 054 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 055 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 056 +rollback to settings +-- +STMT: TransactionStmt +== 057 +-- parallel with parallel-oblivious hash join +savepoint settings +-- +STMT: TransactionStmt +== 058 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 059 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +== 060 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 061 +set local enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 062 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 063 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 064 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 065 +rollback to settings +-- +STMT: TransactionStmt +== 066 +-- parallel with parallel-aware hash join +savepoint settings +-- +STMT: TransactionStmt +== 067 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 068 +set local work_mem = '192kB' +-- +STMT: VariableSetStmt +== 069 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 070 +set local enable_parallel_hash = on +-- +STMT: VariableSetStmt +== 071 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 072 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 073 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 074 +-- parallel full multi-batch hash join +select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 075 +rollback to settings +-- +STMT: TransactionStmt +== 076 +-- The "bad" case: during execution we need to increase number of +-- batches; in this case we plan for 1 batch, and increase at least a +-- couple of times, and peak memory usage stays within our work_mem +-- budget + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +== 077 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 078 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +== 079 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 080 +explain (costs off) + select count(*) FROM simple r JOIN bigger_than_it_looks s USING (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 081 +select count(*) FROM simple r JOIN bigger_than_it_looks s USING (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 082 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) FROM simple r JOIN bigger_than_it_looks s USING (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 083 +rollback to settings +-- +STMT: TransactionStmt +== 084 +-- parallel with parallel-oblivious hash join +savepoint settings +-- +STMT: TransactionStmt +== 085 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 086 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +== 087 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 088 +set local enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 089 +explain (costs off) + select count(*) from simple r join bigger_than_it_looks s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 090 +select count(*) from simple r join bigger_than_it_looks s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 091 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join bigger_than_it_looks s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 092 +rollback to settings +-- +STMT: TransactionStmt +== 093 +-- parallel with parallel-aware hash join +savepoint settings +-- +STMT: TransactionStmt +== 094 +set local max_parallel_workers_per_gather = 1 +-- +STMT: VariableSetStmt +== 095 +set local work_mem = '192kB' +-- +STMT: VariableSetStmt +== 096 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 097 +set local enable_parallel_hash = on +-- +STMT: VariableSetStmt +== 098 +explain (costs off) + select count(*) from simple r join bigger_than_it_looks s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 099 +select count(*) from simple r join bigger_than_it_looks s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join bigger_than_it_looks s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 101 +rollback to settings +-- +STMT: TransactionStmt +== 102 +-- The "ugly" case: increasing the number of batches during execution +-- doesn't help, so stop trying to fit in work_mem and hope for the +-- best; in this case we plan for 1 batch, increases just once and +-- then stop increasing because that didn't help at all, so we blow +-- right through the work_mem budget and hope for the best... + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +== 103 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 104 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +== 105 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 106 +explain (costs off) + select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 107 +select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 108 +select * from hash_join_batches( +$$ + select count(*) from simple r join extremely_skewed s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 109 +rollback to settings +-- +STMT: TransactionStmt +== 110 +-- parallel with parallel-oblivious hash join +savepoint settings +-- +STMT: TransactionStmt +== 111 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 112 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +== 113 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 114 +set local enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 115 +explain (costs off) + select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 116 +select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 117 +select * from hash_join_batches( +$$ + select count(*) from simple r join extremely_skewed s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 118 +rollback to settings +-- +STMT: TransactionStmt +== 119 +-- parallel with parallel-aware hash join +savepoint settings +-- +STMT: TransactionStmt +== 120 +set local max_parallel_workers_per_gather = 1 +-- +STMT: VariableSetStmt +== 121 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +== 122 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 123 +set local enable_parallel_hash = on +-- +STMT: VariableSetStmt +== 124 +explain (costs off) + select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 125 +select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 126 +select * from hash_join_batches( +$$ + select count(*) from simple r join extremely_skewed s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 127 +rollback to settings +-- +STMT: TransactionStmt +== 128 +-- A couple of other hash join tests unrelated to work_mem management. + +-- Check that EXPLAIN ANALYZE has data even if the leader doesn't participate +savepoint settings +-- +STMT: TransactionStmt +== 129 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 130 +set local work_mem = '4MB' +-- +STMT: VariableSetStmt +== 131 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 132 +set local parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 133 +select * from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 134 +rollback to settings +-- +STMT: TransactionStmt +== 135 +-- Exercise rescans. We'll turn off parallel_leader_participation so +-- that we can check that instrumentation comes back correctly. + +create table join_foo as select generate_series(1, 3) as id, 'xxxxx'::text as t +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 136 +alter table join_foo set (parallel_workers = 0) +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=DDL +STMT: AlterTableStmt +== 137 +create table join_bar as select generate_series(1, 10000) as id, 'xxxxx'::text as t +-- +TABLE: name="join_bar" schema="" table="join_bar" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 138 +alter table join_bar set (parallel_workers = 2) +-- +TABLE: name="join_bar" schema="" table="join_bar" ctx=DDL +STMT: AlterTableStmt +== 139 +-- multi-batch with rescan, parallel-oblivious +savepoint settings +-- +STMT: TransactionStmt +== 140 +set enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 141 +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 142 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 143 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 144 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +== 145 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 146 +set enable_material = off +-- +STMT: VariableSetStmt +== 147 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +== 148 +set work_mem = '64kB' +-- +STMT: VariableSetStmt +== 149 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 150 +explain (costs off) + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 151 +select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 152 +select final > 1 as multibatch + from hash_join_batches( +$$ + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 153 +rollback to settings +-- +STMT: TransactionStmt +== 154 +-- single-batch with rescan, parallel-oblivious +savepoint settings +-- +STMT: TransactionStmt +== 155 +set enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 156 +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 157 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 158 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 159 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +== 160 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 161 +set enable_material = off +-- +STMT: VariableSetStmt +== 162 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +== 163 +set work_mem = '4MB' +-- +STMT: VariableSetStmt +== 164 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 165 +explain (costs off) + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 166 +select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 167 +select final > 1 as multibatch + from hash_join_batches( +$$ + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 168 +rollback to settings +-- +STMT: TransactionStmt +== 169 +-- multi-batch with rescan, parallel-aware +savepoint settings +-- +STMT: TransactionStmt +== 170 +set enable_parallel_hash = on +-- +STMT: VariableSetStmt +== 171 +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 172 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 173 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 174 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +== 175 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 176 +set enable_material = off +-- +STMT: VariableSetStmt +== 177 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +== 178 +set work_mem = '64kB' +-- +STMT: VariableSetStmt +== 179 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 180 +explain (costs off) + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 181 +select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 182 +select final > 1 as multibatch + from hash_join_batches( +$$ + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 183 +rollback to settings +-- +STMT: TransactionStmt +== 184 +-- single-batch with rescan, parallel-aware +savepoint settings +-- +STMT: TransactionStmt +== 185 +set enable_parallel_hash = on +-- +STMT: VariableSetStmt +== 186 +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 187 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 188 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 189 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +== 190 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 191 +set enable_material = off +-- +STMT: VariableSetStmt +== 192 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +== 193 +set work_mem = '4MB' +-- +STMT: VariableSetStmt +== 194 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 195 +explain (costs off) + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 196 +select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 197 +select final > 1 as multibatch + from hash_join_batches( +$$ + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 198 +rollback to settings +-- +STMT: TransactionStmt +== 199 +-- A full outer join where every record is matched. + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +== 200 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 201 +explain (costs off) + select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 202 +select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 203 +rollback to settings +-- +STMT: TransactionStmt +== 204 +-- parallelism not possible with parallel-oblivious full hash join +savepoint settings +-- +STMT: TransactionStmt +== 205 +set enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 206 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 207 +explain (costs off) + select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 208 +select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 209 +rollback to settings +-- +STMT: TransactionStmt +== 210 +-- parallelism is possible with parallel-aware full hash join +savepoint settings +-- +STMT: TransactionStmt +== 211 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 212 +explain (costs off) + select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 213 +select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 214 +rollback to settings +-- +STMT: TransactionStmt +== 215 +-- A full outer join where every record is not matched. + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +== 216 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 217 +explain (costs off) + select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 218 +select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 219 +rollback to settings +-- +STMT: TransactionStmt +== 220 +-- parallelism not possible with parallel-oblivious full hash join +savepoint settings +-- +STMT: TransactionStmt +== 221 +set enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 222 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 223 +explain (costs off) + select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 224 +select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 225 +rollback to settings +-- +STMT: TransactionStmt +== 226 +-- parallelism is possible with parallel-aware full hash join +savepoint settings +-- +STMT: TransactionStmt +== 227 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 228 +explain (costs off) + select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 229 +select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 230 +rollback to settings +-- +STMT: TransactionStmt +== 231 +-- exercise special code paths for huge tuples (note use of non-strict +-- expression and left join required to get the detoasted tuple into +-- the hash table) + +-- parallel with parallel-aware hash join (hits ExecParallelHashLoadTuple and +-- sts_puttuple oversized tuple cases because it's multi-batch) +savepoint settings +-- +STMT: TransactionStmt +== 232 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 233 +set enable_parallel_hash = on +-- +STMT: VariableSetStmt +== 234 +set work_mem = '128kB' +-- +STMT: VariableSetStmt +== 235 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +== 236 +explain (costs off) + select length(max(s.t)) + from wide left join (select id, coalesce(t, '') || '' as t from wide) s using (id) +-- +TABLE: name="wide" schema="" table="wide" ctx=Select +TABLE: name="wide" schema="" table="wide" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 237 +select length(max(s.t)) +from wide left join (select id, coalesce(t, '') || '' as t from wide) s using (id) +-- +TABLE: name="wide" schema="" table="wide" ctx=Select +TABLE: name="wide" schema="" table="wide" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 238 +select final > 1 as multibatch + from hash_join_batches( +$$ + select length(max(s.t)) + from wide left join (select id, coalesce(t, '') || '' as t from wide) s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +== 239 +rollback to settings +-- +STMT: TransactionStmt +== 240 +-- Hash join reuses the HOT status bit to indicate match status. This can only +-- be guaranteed to produce correct results if all the hash join tuple match +-- bits are reset before reuse. This is done upon loading them into the +-- hashtable. +SAVEPOINT settings +-- +STMT: TransactionStmt +== 241 +SET enable_parallel_hash = on +-- +STMT: VariableSetStmt +== 242 +SET min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 243 +SET parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 244 +SET parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +== 245 +CREATE TABLE hjtest_matchbits_t1(id int) +-- +TABLE: name="hjtest_matchbits_t1" schema="" table="hjtest_matchbits_t1" ctx=DDL +STMT: CreateStmt +== 246 +CREATE TABLE hjtest_matchbits_t2(id int) +-- +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=DDL +STMT: CreateStmt +== 247 +INSERT INTO hjtest_matchbits_t1 VALUES (1) +-- +TABLE: name="hjtest_matchbits_t1" schema="" table="hjtest_matchbits_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 248 +INSERT INTO hjtest_matchbits_t2 VALUES (2) +-- +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 249 +-- Update should create a HOT tuple. If this status bit isn't cleared, we won't +-- correctly emit the NULL-extended unmatching tuple in full hash join. +UPDATE hjtest_matchbits_t2 set id = 2 +-- +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=DML +STMT: UpdateStmt +== 250 +SELECT * FROM hjtest_matchbits_t1 t1 FULL JOIN hjtest_matchbits_t2 t2 ON t1.id = t2.id + ORDER BY t1.id +-- +TABLE: name="hjtest_matchbits_t1" schema="" table="hjtest_matchbits_t1" ctx=Select +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=Select +ALIAS: "t1"="hjtest_matchbits_t1" +ALIAS: "t2"="hjtest_matchbits_t2" +STMT: SelectStmt +== 251 +-- Test serial full hash join. +-- Resetting parallel_setup_cost should force a serial plan. +-- Just to be safe, however, set enable_parallel_hash to off, as parallel full +-- hash joins are only supported with shared hashtables. +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +== 252 +SET enable_parallel_hash = off +-- +STMT: VariableSetStmt +== 253 +SELECT * FROM hjtest_matchbits_t1 t1 FULL JOIN hjtest_matchbits_t2 t2 ON t1.id = t2.id +-- +TABLE: name="hjtest_matchbits_t1" schema="" table="hjtest_matchbits_t1" ctx=Select +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=Select +ALIAS: "t1"="hjtest_matchbits_t1" +ALIAS: "t2"="hjtest_matchbits_t2" +STMT: SelectStmt +== 254 +ROLLBACK TO settings +-- +STMT: TransactionStmt +== 255 +rollback +-- +STMT: TransactionStmt +== 256 +-- Verify that hash key expressions reference the correct +-- nodes. Hashjoin's hashkeys need to reference its outer plan, Hash's +-- need to reference Hash's outer plan (which is below HashJoin's +-- inner plan). It's not trivial to verify that the references are +-- correct (we don't display the hashkeys themselves), but if the +-- hashkeys contain subplan references, those will be displayed. Force +-- subplans to appear just about everywhere. +|-- +-- Bug report: +-- https://www.postgresql.org/message-id/CAPpHfdvGVegF_TKKRiBrSmatJL2dR9uwFCuR%2BteQ_8tEXU8mxg%40mail.gmail.com +|-- +BEGIN +-- +STMT: TransactionStmt +== 257 +SET LOCAL enable_sort = OFF +-- +STMT: VariableSetStmt +== 258 +-- avoid mergejoins +SET LOCAL from_collapse_limit = 1 +-- +STMT: VariableSetStmt +== 259 +-- allows easy changing of join order + +CREATE TABLE hjtest_1 (a text, b int, id int, c bool) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DDL +STMT: CreateStmt +== 260 +CREATE TABLE hjtest_2 (a bool, id int, b text, c int) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DDL +STMT: CreateStmt +== 261 +INSERT INTO hjtest_1(a, b, id, c) VALUES ('text', 2, 1, false) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 262 +-- matches +INSERT INTO hjtest_1(a, b, id, c) VALUES ('text', 1, 2, false) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 263 +-- fails id join condition +INSERT INTO hjtest_1(a, b, id, c) VALUES ('text', 20, 1, false) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 264 +-- fails < 50 +INSERT INTO hjtest_1(a, b, id, c) VALUES ('text', 1, 1, false) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 265 +-- fails (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 1, 'another', 2) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 266 +-- matches +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 3, 'another', 7) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 267 +-- fails id join condition +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 1, 'another', 90) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 268 +-- fails < 55 +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 1, 'another', 3) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +-- fails (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 1, 'text', 1) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 270 +-- fails hjtest_1.a <> hjtest_2.b; + +EXPLAIN (COSTS OFF, VERBOSE) +SELECT hjtest_1.a a1, hjtest_2.a a2,hjtest_1.tableoid::regclass t1, hjtest_2.tableoid::regclass t2 +FROM hjtest_1, hjtest_2 +WHERE + hjtest_1.id = (SELECT 1 WHERE hjtest_2.id = 1) + AND (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + AND (SELECT hjtest_1.b * 5) < 50 + AND (SELECT hjtest_2.c * 5) < 55 + AND hjtest_1.a <> hjtest_2.b +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=Select +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=Select +FILTER: schema="" table="hjtest_1" column="id" +FILTER: schema="" table="hjtest_2" column="id" +STMT: ExplainStmt +STMT: SelectStmt +== 271 +SELECT hjtest_1.a a1, hjtest_2.a a2,hjtest_1.tableoid::regclass t1, hjtest_2.tableoid::regclass t2 +FROM hjtest_1, hjtest_2 +WHERE + hjtest_1.id = (SELECT 1 WHERE hjtest_2.id = 1) + AND (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + AND (SELECT hjtest_1.b * 5) < 50 + AND (SELECT hjtest_2.c * 5) < 55 + AND hjtest_1.a <> hjtest_2.b +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=Select +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=Select +FILTER: schema="" table="hjtest_1" column="id" +FILTER: schema="" table="hjtest_2" column="id" +STMT: SelectStmt +== 272 +EXPLAIN (COSTS OFF, VERBOSE) +SELECT hjtest_1.a a1, hjtest_2.a a2,hjtest_1.tableoid::regclass t1, hjtest_2.tableoid::regclass t2 +FROM hjtest_2, hjtest_1 +WHERE + hjtest_1.id = (SELECT 1 WHERE hjtest_2.id = 1) + AND (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + AND (SELECT hjtest_1.b * 5) < 50 + AND (SELECT hjtest_2.c * 5) < 55 + AND hjtest_1.a <> hjtest_2.b +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=Select +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=Select +FILTER: schema="" table="hjtest_1" column="id" +FILTER: schema="" table="hjtest_2" column="id" +STMT: ExplainStmt +STMT: SelectStmt +== 273 +SELECT hjtest_1.a a1, hjtest_2.a a2,hjtest_1.tableoid::regclass t1, hjtest_2.tableoid::regclass t2 +FROM hjtest_2, hjtest_1 +WHERE + hjtest_1.id = (SELECT 1 WHERE hjtest_2.id = 1) + AND (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + AND (SELECT hjtest_1.b * 5) < 50 + AND (SELECT hjtest_2.c * 5) < 55 + AND hjtest_1.a <> hjtest_2.b +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=Select +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=Select +FILTER: schema="" table="hjtest_1" column="id" +FILTER: schema="" table="hjtest_2" column="id" +STMT: SelectStmt +== 274 +ROLLBACK +-- +STMT: TransactionStmt +== 275 +-- Verify that we behave sanely when the inner hash keys contain parameters +-- (that is, outer or lateral references). This situation has to defeat +-- re-use of the inner hash table across rescans. +begin +-- +STMT: TransactionStmt +== 276 +set local enable_hashjoin = on +-- +STMT: VariableSetStmt +== 277 +explain (costs off) +select i8.q2, ss.* from +int8_tbl i8, +lateral (select t1.fivethous, i4.f1 from tenk1 t1 join int4_tbl i4 + on t1.fivethous = i4.f1+i8.q2 order by 1,2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +== 278 +select i8.q2, ss.* from +int8_tbl i8, +lateral (select t1.fivethous, i4.f1 from tenk1 t1 join int4_tbl i4 + on t1.fivethous = i4.f1+i8.q2 order by 1,2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="tenk1" +STMT: SelectStmt +== 279 +rollback +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/json.metadata.json b/parser/testdata/summary/postgres_regress/json.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/json.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/json.test b/parser/testdata/summary/postgres_regress/json.test new file mode 100644 index 0000000..7951a7c --- /dev/null +++ b/parser/testdata/summary/postgres_regress/json.test @@ -0,0 +1,2566 @@ +== 001 +-- Strings. +SELECT '""'::json +-- +STMT: SelectStmt +== 002 +-- OK. +SELECT $$''$$::json +-- +STMT: SelectStmt +== 003 +-- ERROR, single quotes are not allowed +SELECT '"abc"'::json +-- +STMT: SelectStmt +== 004 +-- OK +SELECT '"abc'::json +-- +STMT: SelectStmt +== 005 +-- ERROR, quotes not closed +SELECT '"abc +def"'::json +-- +STMT: SelectStmt +== 006 +-- ERROR, unescaped newline in string constant +SELECT '"\n\"\\"'::json +-- +STMT: SelectStmt +== 007 +-- OK, legal escapes +SELECT '"\v"'::json +-- +STMT: SelectStmt +== 008 +-- ERROR, not a valid JSON escape + +-- Check fast path for longer strings (at least 16 bytes long) +SELECT ('"'||repeat('.', 12)||'abc"')::json +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- OK +SELECT ('"'||repeat('.', 12)||'abc\n"')::json +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 010 +-- OK, legal escapes + +-- see json_encoding test for input with unicode escapes + +-- Numbers. +SELECT '1'::json +-- +STMT: SelectStmt +== 011 +-- OK +SELECT '0'::json +-- +STMT: SelectStmt +== 012 +-- OK +SELECT '01'::json +-- +STMT: SelectStmt +== 013 +-- ERROR, not valid according to JSON spec +SELECT '0.1'::json +-- +STMT: SelectStmt +== 014 +-- OK +SELECT '9223372036854775808'::json +-- +STMT: SelectStmt +== 015 +-- OK, even though it's too large for int8 +SELECT '1e100'::json +-- +STMT: SelectStmt +== 016 +-- OK +SELECT '1.3e100'::json +-- +STMT: SelectStmt +== 017 +-- OK +SELECT '1f2'::json +-- +STMT: SelectStmt +== 018 +-- ERROR +SELECT '0.x1'::json +-- +STMT: SelectStmt +== 019 +-- ERROR +SELECT '1.3ex100'::json +-- +STMT: SelectStmt +== 020 +-- ERROR + +-- Arrays. +SELECT '[]'::json +-- +STMT: SelectStmt +== 021 +-- OK +SELECT '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'::json +-- +STMT: SelectStmt +== 022 +-- OK +SELECT '[1,2]'::json +-- +STMT: SelectStmt +== 023 +-- OK +SELECT '[1,2,]'::json +-- +STMT: SelectStmt +== 024 +-- ERROR, trailing comma +SELECT '[1,2'::json +-- +STMT: SelectStmt +== 025 +-- ERROR, no closing bracket +SELECT '[1,[2]'::json +-- +STMT: SelectStmt +== 026 +-- ERROR, no closing bracket + +-- Objects. +SELECT '{}'::json +-- +STMT: SelectStmt +== 027 +-- OK +SELECT '{"abc"}'::json +-- +STMT: SelectStmt +== 028 +-- ERROR, no value +SELECT '{"abc":1}'::json +-- +STMT: SelectStmt +== 029 +-- OK +SELECT '{1:"abc"}'::json +-- +STMT: SelectStmt +== 030 +-- ERROR, keys must be strings +SELECT '{"abc",1}'::json +-- +STMT: SelectStmt +== 031 +-- ERROR, wrong separator +SELECT '{"abc"=1}'::json +-- +STMT: SelectStmt +== 032 +-- ERROR, totally wrong separator +SELECT '{"abc"::1}'::json +-- +STMT: SelectStmt +== 033 +-- ERROR, another wrong separator +SELECT '{"abc":1,"def":2,"ghi":[3,4],"hij":{"klm":5,"nop":[6]}}'::json +-- +STMT: SelectStmt +== 034 +-- OK +SELECT '{"abc":1:2}'::json +-- +STMT: SelectStmt +== 035 +-- ERROR, colon in wrong spot +SELECT '{"abc":1,3}'::json +-- +STMT: SelectStmt +== 036 +-- ERROR, no value + +-- Recursion. +SET max_stack_depth = '100kB' +-- +STMT: VariableSetStmt +== 037 +SELECT repeat('[', 10000)::json +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT repeat('{"a":', 10000)::json +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 039 +RESET max_stack_depth +-- +STMT: VariableSetStmt +== 040 +-- Miscellaneous stuff. +SELECT 'true'::json +-- +STMT: SelectStmt +== 041 +-- OK +SELECT 'false'::json +-- +STMT: SelectStmt +== 042 +-- OK +SELECT 'null'::json +-- +STMT: SelectStmt +== 043 +-- OK +SELECT ' true '::json +-- +STMT: SelectStmt +== 044 +-- OK, even with extra whitespace +SELECT 'true false'::json +-- +STMT: SelectStmt +== 045 +-- ERROR, too many values +SELECT 'true, false'::json +-- +STMT: SelectStmt +== 046 +-- ERROR, too many values +SELECT 'truf'::json +-- +STMT: SelectStmt +== 047 +-- ERROR, not a keyword +SELECT 'trues'::json +-- +STMT: SelectStmt +== 048 +-- ERROR, not a keyword +SELECT ''::json +-- +STMT: SelectStmt +== 049 +-- ERROR, no value +SELECT ' '::json +-- +STMT: SelectStmt +== 050 +-- ERROR, no value + +-- Multi-line JSON input to check ERROR reporting +SELECT '{ + "one": 1, + "two":"two", + "three": + true}'::json +-- +STMT: SelectStmt +== 051 +-- OK +SELECT '{ + "one": 1, + "two":,"two", -- ERROR extraneous comma before field "two" + "three": + true}'::json +-- +STMT: SelectStmt +== 052 +SELECT '{ + "one": 1, + "two":"two", + "averyveryveryveryveryveryveryveryveryverylongfieldname":}'::json +-- +STMT: SelectStmt +== 053 +-- ERROR missing value for last field + +-- test non-error-throwing input +select pg_input_is_valid('{"a":true}', 'json') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 054 +select pg_input_is_valid('{"a":true', 'json') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 055 +select * from pg_input_error_info('{"a":true', 'json') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 056 +--constructors +-- array_to_json + +SELECT array_to_json(array(select 1 as a)) +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +STMT: SelectStmt +== 057 +SELECT array_to_json(array_agg(q),false) from (select x as b, x * 2 as c from generate_series(1,3) x) q +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 058 +SELECT array_to_json(array_agg(q),true) from (select x as b, x * 2 as c from generate_series(1,3) x) q +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT array_to_json(array_agg(q),false) + FROM ( SELECT $$a$$ || x AS b, y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT array_to_json(array_agg(x),false) from generate_series(5,10) x +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT array_to_json('{{1,5},{99,100}}'::int[]) +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +STMT: SelectStmt +== 062 +-- row_to_json +SELECT row_to_json(row(1,'foo')) +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT row_to_json(q) +FROM (SELECT $$a$$ || x AS b, + y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT row_to_json(q,true) +FROM (SELECT $$a$$ || x AS b, + y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 065 +CREATE TEMP TABLE rows AS +SELECT x, 'txt' || x as y +FROM generate_series(1,3) AS x +-- +TABLE: name="rows" schema="" table="rows" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 066 +SELECT row_to_json(q,true) +FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),false) +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 068 +-- anyarray column + +analyze rows +-- +TABLE: name="rows" schema="" table="rows" ctx=DDL +STMT: VacuumStmt +== 069 +select attname, to_json(histogram_bounds) histogram_bounds +from pg_stats +where tablename = 'rows' and + schemaname = pg_my_temp_schema()::regnamespace::text +order by 1 +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +FILTER: schema="" table="" column="tablename" +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +== 070 +-- to_json, timestamps + +select to_json(timestamp '2014-05-28 12:22:35.614298') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 071 +BEGIN +-- +STMT: TransactionStmt +== 072 +SET LOCAL TIME ZONE 10.5 +-- +STMT: VariableSetStmt +== 073 +select to_json(timestamptz '2014-05-28 12:22:35.614298-04') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 074 +SET LOCAL TIME ZONE -8 +-- +STMT: VariableSetStmt +== 075 +select to_json(timestamptz '2014-05-28 12:22:35.614298-04') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 076 +COMMIT +-- +STMT: TransactionStmt +== 077 +select to_json(date '2014-05-28') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 078 +select to_json(date 'Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 079 +select to_json(date '-Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 080 +select to_json(timestamp 'Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 081 +select to_json(timestamp '-Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 082 +select to_json(timestamptz 'Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 083 +select to_json(timestamptz '-Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 084 +--json_agg + +SELECT json_agg(q) + FROM ( SELECT $$a$$ || x AS b, y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="json_agg" function="json_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 085 +SELECT json_agg(q ORDER BY x, y) + FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="json_agg" function="json_agg" schema="" ctx=Call +STMT: SelectStmt +== 086 +UPDATE rows SET x = NULL WHERE x = 1 +-- +TABLE: name="rows" schema="" table="rows" ctx=DML +STMT: UpdateStmt +== 087 +SELECT json_agg(q ORDER BY x NULLS FIRST, y) + FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="json_agg" function="json_agg" schema="" ctx=Call +STMT: SelectStmt +== 088 +-- non-numeric output +SELECT row_to_json(q) +FROM (SELECT 'NaN'::float8 AS "float8field") q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 089 +SELECT row_to_json(q) +FROM (SELECT 'Infinity'::float8 AS "float8field") q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 090 +SELECT row_to_json(q) +FROM (SELECT '-Infinity'::float8 AS "float8field") q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 091 +-- json input +SELECT row_to_json(q) +FROM (SELECT '{"a":1,"b": [2,3,4,"d","e","f"],"c":{"p":1,"q":2}}'::json AS "jsonfield") q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 092 +-- json extraction functions + +CREATE TEMP TABLE test_json ( + json_type text, + test_json json +) +-- +TABLE: name="test_json" schema="" table="test_json" ctx=DDL +STMT: CreateStmt +== 093 +INSERT INTO test_json VALUES +('scalar','"a scalar"'), +('array','["zero", "one","two",null,"four","five", [1,2,3],{"f1":9}]'), +('object','{"field1":"val1","field2":"val2","field3":null, "field4": 4, "field5": [1,2,3], "field6": {"f1":9}}') +-- +TABLE: name="test_json" schema="" table="test_json" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 094 +SELECT test_json -> 'x' +FROM test_json +WHERE json_type = 'scalar' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 095 +SELECT test_json -> 'x' +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 096 +SELECT test_json -> 'x' +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 097 +SELECT test_json->'field2' +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 098 +SELECT test_json->>'field2' +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 099 +SELECT test_json -> 2 +FROM test_json +WHERE json_type = 'scalar' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 100 +SELECT test_json -> 2 +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 101 +SELECT test_json -> -1 +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 102 +SELECT test_json -> 2 +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 103 +SELECT test_json->>2 +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 104 +SELECT test_json ->> 6 FROM test_json WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 105 +SELECT test_json ->> 7 FROM test_json WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 106 +SELECT test_json ->> 'field4' FROM test_json WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 107 +SELECT test_json ->> 'field5' FROM test_json WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 108 +SELECT test_json ->> 'field6' FROM test_json WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 109 +SELECT json_object_keys(test_json) +FROM test_json +WHERE json_type = 'scalar' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FUNCTION: name="json_object_keys" function="json_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 110 +SELECT json_object_keys(test_json) +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FUNCTION: name="json_object_keys" function="json_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 111 +SELECT json_object_keys(test_json) +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FUNCTION: name="json_object_keys" function="json_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 112 +-- test extending object_keys resultset - initial resultset size is 256 + +select count(*) from + (select json_object_keys(json_object(array_agg(g))) + from (select unnest(array['f'||n,n::text])as g + from generate_series(1,300) as n) x ) y +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="json_object_keys" function="json_object_keys" schema="" ctx=Call +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 113 +-- nulls + +select (test_json->'field3') is null as expect_false +from test_json +where json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 114 +select (test_json->>'field3') is null as expect_true +from test_json +where json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 115 +select (test_json->3) is null as expect_false +from test_json +where json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 116 +select (test_json->>3) is null as expect_true +from test_json +where json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 117 +-- corner cases + +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> null::text +-- +STMT: SelectStmt +== 118 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> null::int +-- +STMT: SelectStmt +== 119 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> 1 +-- +STMT: SelectStmt +== 120 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> -1 +-- +STMT: SelectStmt +== 121 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> 'z' +-- +STMT: SelectStmt +== 122 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> '' +-- +STMT: SelectStmt +== 123 +select '[{"b": "c"}, {"b": "cc"}]'::json -> 1 +-- +STMT: SelectStmt +== 124 +select '[{"b": "c"}, {"b": "cc"}]'::json -> 3 +-- +STMT: SelectStmt +== 125 +select '[{"b": "c"}, {"b": "cc"}]'::json -> 'z' +-- +STMT: SelectStmt +== 126 +select '{"a": "c", "b": null}'::json -> 'b' +-- +STMT: SelectStmt +== 127 +select '"foo"'::json -> 1 +-- +STMT: SelectStmt +== 128 +select '"foo"'::json -> 'z' +-- +STMT: SelectStmt +== 129 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> null::text +-- +STMT: SelectStmt +== 130 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> null::int +-- +STMT: SelectStmt +== 131 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> 1 +-- +STMT: SelectStmt +== 132 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> 'z' +-- +STMT: SelectStmt +== 133 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> '' +-- +STMT: SelectStmt +== 134 +select '[{"b": "c"}, {"b": "cc"}]'::json ->> 1 +-- +STMT: SelectStmt +== 135 +select '[{"b": "c"}, {"b": "cc"}]'::json ->> 3 +-- +STMT: SelectStmt +== 136 +select '[{"b": "c"}, {"b": "cc"}]'::json ->> 'z' +-- +STMT: SelectStmt +== 137 +select '{"a": "c", "b": null}'::json ->> 'b' +-- +STMT: SelectStmt +== 138 +select '"foo"'::json ->> 1 +-- +STMT: SelectStmt +== 139 +select '"foo"'::json ->> 'z' +-- +STMT: SelectStmt +== 140 +-- array length + +SELECT json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]') +-- +FUNCTION: name="json_array_length" function="json_array_length" schema="" ctx=Call +STMT: SelectStmt +== 141 +SELECT json_array_length('[]') +-- +FUNCTION: name="json_array_length" function="json_array_length" schema="" ctx=Call +STMT: SelectStmt +== 142 +SELECT json_array_length('{"f1":1,"f2":[5,6]}') +-- +FUNCTION: name="json_array_length" function="json_array_length" schema="" ctx=Call +STMT: SelectStmt +== 143 +SELECT json_array_length('4') +-- +FUNCTION: name="json_array_length" function="json_array_length" schema="" ctx=Call +STMT: SelectStmt +== 144 +-- each + +select json_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null}') +-- +FUNCTION: name="json_each" function="json_each" schema="" ctx=Call +STMT: SelectStmt +== 145 +select * from json_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q +-- +FUNCTION: name="json_each" function="json_each" schema="" ctx=Call +STMT: SelectStmt +== 146 +select json_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":"null"}') +-- +FUNCTION: name="json_each_text" function="json_each_text" schema="" ctx=Call +STMT: SelectStmt +== 147 +select * from json_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q +-- +FUNCTION: name="json_each_text" function="json_each_text" schema="" ctx=Call +STMT: SelectStmt +== 148 +-- extract_path, extract_path_as_text + +select json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6') +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 149 +select json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2') +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 150 +select json_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text) +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 151 +select json_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text) +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 152 +select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6') +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 153 +select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2') +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 154 +select json_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text) +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 155 +select json_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text) +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 156 +-- extract_path nulls + +select json_extract_path('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') is null as expect_false +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 157 +select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') is null as expect_true +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 158 +select json_extract_path('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') is null as expect_false +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 159 +select json_extract_path_text('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') is null as expect_true +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 160 +-- extract_path operators + +select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f4','f6'] +-- +STMT: SelectStmt +== 161 +select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2'] +-- +STMT: SelectStmt +== 162 +select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','0'] +-- +STMT: SelectStmt +== 163 +select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','1'] +-- +STMT: SelectStmt +== 164 +select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f4','f6'] +-- +STMT: SelectStmt +== 165 +select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2'] +-- +STMT: SelectStmt +== 166 +select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','0'] +-- +STMT: SelectStmt +== 167 +select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','1'] +-- +STMT: SelectStmt +== 168 +-- corner cases for same +select '{"a": {"b":{"c": "foo"}}}'::json #> '{}' +-- +STMT: SelectStmt +== 169 +select '[1,2,3]'::json #> '{}' +-- +STMT: SelectStmt +== 170 +select '"foo"'::json #> '{}' +-- +STMT: SelectStmt +== 171 +select '42'::json #> '{}' +-- +STMT: SelectStmt +== 172 +select 'null'::json #> '{}' +-- +STMT: SelectStmt +== 173 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a'] +-- +STMT: SelectStmt +== 174 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', null] +-- +STMT: SelectStmt +== 175 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', ''] +-- +STMT: SelectStmt +== 176 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b'] +-- +STMT: SelectStmt +== 177 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b','c'] +-- +STMT: SelectStmt +== 178 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b','c','d'] +-- +STMT: SelectStmt +== 179 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','z','c'] +-- +STMT: SelectStmt +== 180 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json #> array['a','1','b'] +-- +STMT: SelectStmt +== 181 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json #> array['a','z','b'] +-- +STMT: SelectStmt +== 182 +select '[{"b": "c"}, {"b": "cc"}]'::json #> array['1','b'] +-- +STMT: SelectStmt +== 183 +select '[{"b": "c"}, {"b": "cc"}]'::json #> array['z','b'] +-- +STMT: SelectStmt +== 184 +select '[{"b": "c"}, {"b": null}]'::json #> array['1','b'] +-- +STMT: SelectStmt +== 185 +select '"foo"'::json #> array['z'] +-- +STMT: SelectStmt +== 186 +select '42'::json #> array['f2'] +-- +STMT: SelectStmt +== 187 +select '42'::json #> array['0'] +-- +STMT: SelectStmt +== 188 +select '{"a": {"b":{"c": "foo"}}}'::json #>> '{}' +-- +STMT: SelectStmt +== 189 +select '[1,2,3]'::json #>> '{}' +-- +STMT: SelectStmt +== 190 +select '"foo"'::json #>> '{}' +-- +STMT: SelectStmt +== 191 +select '42'::json #>> '{}' +-- +STMT: SelectStmt +== 192 +select 'null'::json #>> '{}' +-- +STMT: SelectStmt +== 193 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a'] +-- +STMT: SelectStmt +== 194 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a', null] +-- +STMT: SelectStmt +== 195 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a', ''] +-- +STMT: SelectStmt +== 196 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a','b'] +-- +STMT: SelectStmt +== 197 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a','b','c'] +-- +STMT: SelectStmt +== 198 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a','b','c','d'] +-- +STMT: SelectStmt +== 199 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a','z','c'] +-- +STMT: SelectStmt +== 200 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json #>> array['a','1','b'] +-- +STMT: SelectStmt +== 201 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json #>> array['a','z','b'] +-- +STMT: SelectStmt +== 202 +select '[{"b": "c"}, {"b": "cc"}]'::json #>> array['1','b'] +-- +STMT: SelectStmt +== 203 +select '[{"b": "c"}, {"b": "cc"}]'::json #>> array['z','b'] +-- +STMT: SelectStmt +== 204 +select '[{"b": "c"}, {"b": null}]'::json #>> array['1','b'] +-- +STMT: SelectStmt +== 205 +select '"foo"'::json #>> array['z'] +-- +STMT: SelectStmt +== 206 +select '42'::json #>> array['f2'] +-- +STMT: SelectStmt +== 207 +select '42'::json #>> array['0'] +-- +STMT: SelectStmt +== 208 +-- array_elements + +select json_array_elements('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') +-- +FUNCTION: name="json_array_elements" function="json_array_elements" schema="" ctx=Call +STMT: SelectStmt +== 209 +select * from json_array_elements('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') q +-- +FUNCTION: name="json_array_elements" function="json_array_elements" schema="" ctx=Call +STMT: SelectStmt +== 210 +select json_array_elements_text('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') +-- +FUNCTION: name="json_array_elements_text" function="json_array_elements_text" schema="" ctx=Call +STMT: SelectStmt +== 211 +select * from json_array_elements_text('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') q +-- +FUNCTION: name="json_array_elements_text" function="json_array_elements_text" schema="" ctx=Call +STMT: SelectStmt +== 212 +-- populate_record +create type jpop as (a text, b int, c timestamp) +-- +STMT: CompositeTypeStmt +== 213 +CREATE DOMAIN js_int_not_null AS int NOT NULL +-- +STMT: CreateDomainStmt +== 214 +CREATE DOMAIN js_int_array_1d AS int[] CHECK(array_length(VALUE, 1) = 3) +-- +STMT: CreateDomainStmt +== 215 +CREATE DOMAIN js_int_array_2d AS int[][] CHECK(array_length(VALUE, 2) = 3) +-- +STMT: CreateDomainStmt +== 216 +create type j_unordered_pair as (x int, y int) +-- +STMT: CompositeTypeStmt +== 217 +create domain j_ordered_pair as j_unordered_pair check((value).x <= (value).y) +-- +STMT: CreateDomainStmt +== 218 +CREATE TYPE jsrec AS ( + i int, + ia _int4, + ia1 int[], + ia2 int[][], + ia3 int[][][], + ia1d js_int_array_1d, + ia2d js_int_array_2d, + t text, + ta text[], + c char(10), + ca char(10)[], + ts timestamp, + js json, + jsb jsonb, + jsa json[], + rec jpop, + reca jpop[] +) +-- +STMT: CompositeTypeStmt +== 219 +CREATE TYPE jsrec_i_not_null AS ( + i js_int_not_null +) +-- +STMT: CompositeTypeStmt +== 220 +select * from json_populate_record(null::jpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 221 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 222 +select * from json_populate_record(null::jpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 223 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 224 +select * from json_populate_record(null::jpop,'{"a":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 225 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{"a":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 226 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{"c":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 227 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 228 +SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{"x": 43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 229 +SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{"i": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 230 +SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{"i": 12345}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 231 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 232 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 233 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 234 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": [[1, 2], [3, 4]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 235 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": [[1], 2]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 236 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": [[1], [2, 3]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 237 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": "{1,2,3}"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 238 +SELECT ia1 FROM json_populate_record(NULL::jsrec, '{"ia1": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 239 +SELECT ia1 FROM json_populate_record(NULL::jsrec, '{"ia1": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 240 +SELECT ia1 FROM json_populate_record(NULL::jsrec, '{"ia1": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 241 +SELECT ia1 FROM json_populate_record(NULL::jsrec, '{"ia1": [[1, 2, 3]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 242 +SELECT ia1d FROM json_populate_record(NULL::jsrec, '{"ia1d": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 243 +SELECT ia1d FROM json_populate_record(NULL::jsrec, '{"ia1d": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 244 +SELECT ia1d FROM json_populate_record(NULL::jsrec, '{"ia1d": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 245 +SELECT ia1d FROM json_populate_record(NULL::jsrec, '{"ia1d": [1, "2", null]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 246 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 247 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [[1, 2], [null, 4]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 248 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [[], []]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 249 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [[1, 2], [3]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 250 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [[1, 2], 3, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 251 +SELECT ia2d FROM json_populate_record(NULL::jsrec, '{"ia2d": [[1, "2"], [null, 4]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 252 +SELECT ia2d FROM json_populate_record(NULL::jsrec, '{"ia2d": [[1, "2", 3], [null, 5, 6]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 253 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 254 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [[1, 2], [null, 4]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 255 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [ [[], []], [[], []], [[], []] ]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 256 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [ [[1, 2]], [[3, 4]] ]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 257 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 258 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [ [[1, 2], [3, 4]], [[5, 6], [7, 8], [9, 10]] ]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 259 +SELECT ta FROM json_populate_record(NULL::jsrec, '{"ta": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 260 +SELECT ta FROM json_populate_record(NULL::jsrec, '{"ta": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 261 +SELECT ta FROM json_populate_record(NULL::jsrec, '{"ta": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 262 +SELECT ta FROM json_populate_record(NULL::jsrec, '{"ta": [[1, 2, 3], {"k": "v"}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 263 +SELECT c FROM json_populate_record(NULL::jsrec, '{"c": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 264 +SELECT c FROM json_populate_record(NULL::jsrec, '{"c": "aaa"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 265 +SELECT c FROM json_populate_record(NULL::jsrec, '{"c": "aaaaaaaaaa"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 266 +SELECT c FROM json_populate_record(NULL::jsrec, '{"c": "aaaaaaaaaaaaa"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 267 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 268 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 269 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 270 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": ["aaaaaaaaaaaaaaaa"]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 271 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": [[1, 2, 3], {"k": "v"}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 272 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 273 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": true}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 274 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": 123.45}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 275 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": "123.45"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 276 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": "abc"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 277 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": [123, "123", null, {"key": "value"}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 278 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": {"a": "bbb", "b": null, "c": 123.45}}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 279 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 280 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": true}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 281 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": 123.45}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 282 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": "123.45"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 283 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": "abc"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 284 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": [123, "123", null, {"key": "value"}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 285 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": {"a": "bbb", "b": null, "c": 123.45}}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 286 +SELECT jsa FROM json_populate_record(NULL::jsrec, '{"jsa": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 287 +SELECT jsa FROM json_populate_record(NULL::jsrec, '{"jsa": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 288 +SELECT jsa FROM json_populate_record(NULL::jsrec, '{"jsa": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 289 +SELECT jsa FROM json_populate_record(NULL::jsrec, '{"jsa": ["aaa", null, [1, 2, "3", {}], { "k" : "v" }]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 290 +SELECT rec FROM json_populate_record(NULL::jsrec, '{"rec": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 291 +SELECT rec FROM json_populate_record(NULL::jsrec, '{"rec": [1, 2]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 292 +SELECT rec FROM json_populate_record(NULL::jsrec, '{"rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 293 +SELECT rec FROM json_populate_record(NULL::jsrec, '{"rec": "(abc,42,01.02.2003)"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 294 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 295 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": [1, 2]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 296 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": [{"a": "abc", "b": 456}, null, {"c": "01.02.2003", "x": 43.2}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 297 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": ["(abc,42,01.02.2003)"]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 298 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": "{\"(abc,42,01.02.2003)\"}"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 299 +SELECT rec FROM json_populate_record( + row(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, + row('x',3,'2012-12-31 15:30:56')::jpop,NULL)::jsrec, + '{"rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}}' +) q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 300 +-- anonymous record type +SELECT json_populate_record(null::record, '{"x": 0, "y": 1}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 301 +SELECT json_populate_record(row(1,2), '{"f1": 0, "f2": 1}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 302 +SELECT * FROM + json_populate_record(null::record, '{"x": 776}') AS (x int, y int) +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 303 +-- composite domain +SELECT json_populate_record(null::j_ordered_pair, '{"x": 0, "y": 1}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 304 +SELECT json_populate_record(row(1,2)::j_ordered_pair, '{"x": 0}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 305 +SELECT json_populate_record(row(1,2)::j_ordered_pair, '{"x": 1, "y": 0}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 306 +-- populate_recordset + +select * from json_populate_recordset(null::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 307 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 308 +select * from json_populate_recordset(null::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 309 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 310 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 311 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"c":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 312 +create type jpop2 as (a int, b json, c int, d int) +-- +STMT: CompositeTypeStmt +== 313 +select * from json_populate_recordset(null::jpop2, '[{"a":2,"c":3,"b":{"z":4},"d":6}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 314 +select * from json_populate_recordset(null::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 315 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 316 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 317 +-- anonymous record type +SELECT json_populate_recordset(null::record, '[{"x": 0, "y": 1}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 318 +SELECT json_populate_recordset(row(1,2), '[{"f1": 0, "f2": 1}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 319 +SELECT i, json_populate_recordset(row(i,50), '[{"f1":"42"},{"f2":"43"}]') +FROM (VALUES (1),(2)) v(i) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 320 +SELECT * FROM + json_populate_recordset(null::record, '[{"x": 776}]') AS (x int, y int) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 321 +-- empty array is a corner case +SELECT json_populate_recordset(null::record, '[]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 322 +SELECT json_populate_recordset(row(1,2), '[]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 323 +SELECT * FROM json_populate_recordset(NULL::jpop,'[]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 324 +SELECT * FROM + json_populate_recordset(null::record, '[]') AS (x int, y int) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 325 +-- composite domain +SELECT json_populate_recordset(null::j_ordered_pair, '[{"x": 0, "y": 1}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 326 +SELECT json_populate_recordset(row(1,2)::j_ordered_pair, '[{"x": 0}, {"y": 3}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 327 +SELECT json_populate_recordset(row(1,2)::j_ordered_pair, '[{"x": 1, "y": 0}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 328 +-- negative cases where the wrong record type is supplied +select * from json_populate_recordset(row(0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 329 +select * from json_populate_recordset(row(0::int,0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 330 +select * from json_populate_recordset(row(0::int,0::int,0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 331 +select * from json_populate_recordset(row(1000000000::int,50::int),'[{"b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 332 +-- test type info caching in json_populate_record() +CREATE TEMP TABLE jspoptest (js json) +-- +TABLE: name="jspoptest" schema="" table="jspoptest" ctx=DDL +STMT: CreateStmt +== 333 +INSERT INTO jspoptest +SELECT '{ + "jsa": [1, "2", null, 4], + "rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}, + "reca": [{"a": "abc", "b": 456}, null, {"c": "01.02.2003", "x": 43.2}] +}'::json +FROM generate_series(1, 3) +-- +TABLE: name="jspoptest" schema="" table="jspoptest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 334 +SELECT (json_populate_record(NULL::jsrec, js)).* FROM jspoptest +-- +TABLE: name="jspoptest" schema="" table="jspoptest" ctx=Select +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 335 +DROP TYPE jsrec +-- +STMT: DropStmt +== 336 +DROP TYPE jsrec_i_not_null +-- +STMT: DropStmt +== 337 +DROP DOMAIN js_int_not_null +-- +STMT: DropStmt +== 338 +DROP DOMAIN js_int_array_1d +-- +STMT: DropStmt +== 339 +DROP DOMAIN js_int_array_2d +-- +STMT: DropStmt +== 340 +DROP DOMAIN j_ordered_pair +-- +STMT: DropStmt +== 341 +DROP TYPE j_unordered_pair +-- +STMT: DropStmt +== 342 +--json_typeof() function +select value, json_typeof(value) + from (values (json '123.4'), + (json '-1'), + (json '"foo"'), + (json 'true'), + (json 'false'), + (json 'null'), + (json '[1, 2, 3]'), + (json '[]'), + (json '{"x":"foo", "y":123}'), + (json '{}'), + (NULL::json)) + as data(value) +-- +FUNCTION: name="json_typeof" function="json_typeof" schema="" ctx=Call +STMT: SelectStmt +== 343 +-- json_build_array, json_build_object, json_object_agg + +SELECT json_build_array('a',1,'b',1.2,'c',true,'d',null,'e',json '{"x": 3, "y": [1,2,3]}') +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 344 +SELECT json_build_array('a', NULL) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 345 +-- ok +SELECT json_build_array(VARIADIC NULL::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 346 +-- ok +SELECT json_build_array(VARIADIC '{}'::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 347 +-- ok +SELECT json_build_array(VARIADIC '{a,b,c}'::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 348 +-- ok +SELECT json_build_array(VARIADIC ARRAY['a', NULL]::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 349 +-- ok +SELECT json_build_array(VARIADIC '{1,2,3,4}'::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 350 +-- ok +SELECT json_build_array(VARIADIC '{1,2,3,4}'::int[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 351 +-- ok +SELECT json_build_array(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 352 +-- ok + +SELECT json_build_object('a',1,'b',1.2,'c',true,'d',null,'e',json '{"x": 3, "y": [1,2,3]}') +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 353 +SELECT json_build_object( + 'a', json_build_object('b',false,'c',99), + 'd', json_build_object('e',array[9,8,7]::int[], + 'f', (select row_to_json(r) from ( select relkind, oid::regclass as name from pg_class where relname = 'pg_class') r))) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 354 +SELECT json_build_object('{a,b,c}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 355 +-- error +SELECT json_build_object('{a,b,c}'::text[], '{d,e,f}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 356 +-- error, key cannot be array +SELECT json_build_object('a', 'b', 'c') +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 357 +-- error +SELECT json_build_object(NULL, 'a') +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 358 +-- error, key cannot be NULL +SELECT json_build_object('a', NULL) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 359 +-- ok +SELECT json_build_object(VARIADIC NULL::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 360 +-- ok +SELECT json_build_object(VARIADIC '{}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 361 +-- ok +SELECT json_build_object(VARIADIC '{a,b,c}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 362 +-- error +SELECT json_build_object(VARIADIC ARRAY['a', NULL]::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 363 +-- ok +SELECT json_build_object(VARIADIC ARRAY[NULL, 'a']::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 364 +-- error, key cannot be NULL +SELECT json_build_object(VARIADIC '{1,2,3,4}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 365 +-- ok +SELECT json_build_object(VARIADIC '{1,2,3,4}'::int[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 366 +-- ok +SELECT json_build_object(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 367 +-- ok + +-- empty objects/arrays +SELECT json_build_array() +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +== 368 +SELECT json_build_object() +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 369 +-- make sure keys are quoted +SELECT json_build_object(1,2) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 370 +-- keys must be scalar and not null +SELECT json_build_object(null,2) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 371 +SELECT json_build_object(r,2) FROM (SELECT 1 AS a, 2 AS b) r +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 372 +SELECT json_build_object(json '{"a":1,"b":2}', 3) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 373 +SELECT json_build_object('{1,2,3}'::int[], 3) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 374 +CREATE TEMP TABLE foo (serial_num int, name text, type text) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 375 +INSERT INTO foo VALUES (847001,'t15','GE1043') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 376 +INSERT INTO foo VALUES (847002,'t16','GE1043') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 377 +INSERT INTO foo VALUES (847003,'sub-alpha','GESS90') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 378 +SELECT json_build_object('turbines',json_object_agg(serial_num,json_build_object('name',name,'type',type))) +FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="json_object_agg" function="json_object_agg" schema="" ctx=Call +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +== 379 +SELECT json_object_agg(name, type) FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="json_object_agg" function="json_object_agg" schema="" ctx=Call +STMT: SelectStmt +== 380 +INSERT INTO foo VALUES (999999, NULL, 'bar') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 381 +SELECT json_object_agg(name, type) FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="json_object_agg" function="json_object_agg" schema="" ctx=Call +STMT: SelectStmt +== 382 +-- json_object + +-- empty object, one dimension +SELECT json_object('{}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 383 +-- empty object, two dimensions +SELECT json_object('{}', '{}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 384 +-- one dimension +SELECT json_object('{a,1,b,2,3,NULL,"d e f","a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 385 +-- same but with two dimensions +SELECT json_object('{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 386 +-- odd number error +SELECT json_object('{a,b,c}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 387 +-- one column error +SELECT json_object('{{a},{b}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 388 +-- too many columns error +SELECT json_object('{{a,b,c},{b,c,d}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 389 +-- too many dimensions error +SELECT json_object('{{{a,b},{c,d}},{{b,c},{d,e}}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 390 +--two argument form of json_object + +select json_object('{a,b,c,"d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 391 +-- too many dimensions +SELECT json_object('{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}', '{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 392 +-- mismatched dimensions + +select json_object('{a,b,c,"d e f",g}','{1,2,3,"a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 393 +select json_object('{a,b,c,"d e f"}','{1,2,3,"a b c",g}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 394 +-- null key error + +select json_object('{a,b,NULL,"d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 395 +-- empty key is allowed + +select json_object('{a,b,"","d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 396 +-- json_object_agg_unique requires unique keys +select json_object_agg_unique(mod(i,100), i) from generate_series(0, 199) i +-- +FUNCTION: name="json_object_agg_unique" function="json_object_agg_unique" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 397 +-- json_to_record and json_to_recordset + +select * from json_to_record('{"a":1,"b":"foo","c":"bar"}') + as x(a int, b text, d text) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 398 +select * from json_to_recordset('[{"a":1,"b":"foo","d":false},{"a":2,"b":"bar","c":true}]') + as x(a int, b text, c boolean) +-- +FUNCTION: name="json_to_recordset" function="json_to_recordset" schema="" ctx=Call +STMT: SelectStmt +== 399 +select * from json_to_recordset('[{"a":1,"b":{"d":"foo"},"c":true},{"a":2,"c":false,"b":{"d":"bar"}}]') + as x(a int, b json, c boolean) +-- +FUNCTION: name="json_to_recordset" function="json_to_recordset" schema="" ctx=Call +STMT: SelectStmt +== 400 +select *, c is null as c_is_null +from json_to_record('{"a":1, "b":{"c":16, "d":2}, "x":8, "ca": ["1 2", 3], "ia": [[1,2],[3,4]], "r": {"a": "aaa", "b": 123}}'::json) + as t(a int, b json, c text, x int, ca char(5)[], ia int[][], r jpop) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 401 +select *, c is null as c_is_null +from json_to_recordset('[{"a":1, "b":{"c":16, "d":2}, "x":8}]'::json) + as t(a int, b json, c text, x int) +-- +FUNCTION: name="json_to_recordset" function="json_to_recordset" schema="" ctx=Call +STMT: SelectStmt +== 402 +select * from json_to_record('{"ia": null}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 403 +select * from json_to_record('{"ia": 123}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 404 +select * from json_to_record('{"ia": [1, "2", null, 4]}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 405 +select * from json_to_record('{"ia": [[1, 2], [3, 4]]}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 406 +select * from json_to_record('{"ia": [[1], 2]}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 407 +select * from json_to_record('{"ia": [[1], [2, 3]]}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 408 +select * from json_to_record('{"ia2": [1, 2, 3]}') as x(ia2 int[][]) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 409 +select * from json_to_record('{"ia2": [[1, 2], [3, 4]]}') as x(ia2 int4[][]) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 410 +select * from json_to_record('{"ia2": [[[1], [2], [3]]]}') as x(ia2 int4[][]) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 411 +select * from json_to_record('{"out": {"key": 1}}') as x(out json) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 412 +select * from json_to_record('{"out": [{"key": 1}]}') as x(out json) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 413 +select * from json_to_record('{"out": "{\"key\": 1}"}') as x(out json) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 414 +select * from json_to_record('{"out": {"key": 1}}') as x(out jsonb) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 415 +select * from json_to_record('{"out": [{"key": 1}]}') as x(out jsonb) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 416 +select * from json_to_record('{"out": "{\"key\": 1}"}') as x(out jsonb) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +== 417 +-- json_strip_nulls + +select json_strip_nulls(null) +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 418 +select json_strip_nulls('1') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 419 +select json_strip_nulls('"a string"') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 420 +select json_strip_nulls('null') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 421 +select json_strip_nulls('[1,2,null,3,4]') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 422 +select json_strip_nulls('{"a":1,"b":null,"c":[2,null,3],"d":{"e":4,"f":null}}') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 423 +select json_strip_nulls('[1,{"a":1,"b":null,"c":2},3]') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 424 +-- an empty object is not null and should not be stripped +select json_strip_nulls('{"a": {"b": null, "c": null}, "d": {} }') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 425 +-- json to tsvector +select to_tsvector('{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 426 +-- json to tsvector with config +select to_tsvector('simple', '{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 427 +-- json to tsvector with stop words +select to_tsvector('english', '{"a": "aaa in bbb ddd ccc", "b": ["the eee fff ggg"], "c": {"d": "hhh. iii"}}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 428 +-- json to tsvector with numeric values +select to_tsvector('english', '{"a": "aaa in bbb ddd ccc", "b": 123, "c": 456}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 429 +-- json_to_tsvector +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 430 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"key"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 431 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"string"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 432 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"numeric"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 433 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"boolean"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 434 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '["string", "numeric"]') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 435 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 436 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"key"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 437 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"string"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 438 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"numeric"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 439 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"boolean"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 440 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '["string", "numeric"]') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 441 +-- to_tsvector corner cases +select to_tsvector('""'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 442 +select to_tsvector('{}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 443 +select to_tsvector('[]'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 444 +select to_tsvector('null'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 445 +-- json_to_tsvector corner cases +select json_to_tsvector('""'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 446 +select json_to_tsvector('{}'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 447 +select json_to_tsvector('[]'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 448 +select json_to_tsvector('null'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 449 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '""') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 450 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '{}') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 451 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '[]') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 452 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, 'null') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 453 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '["all", null]') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 454 +-- ts_headline for json +select ts_headline('{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::json, tsquery('bbb & ddd & hhh')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 455 +select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc ddd fff"}, "d": ["ggg hhh", "iii jjj"]}'::json, tsquery('bbb & ddd & hhh')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 456 +select ts_headline('{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::json, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 457 +select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::json, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 458 +-- corner cases for ts_headline with json +select ts_headline('null'::json, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 459 +select ts_headline('{}'::json, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 460 +select ts_headline('[]'::json, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/json_encoding.metadata.json b/parser/testdata/summary/postgres_regress/json_encoding.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/json_encoding.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/json_encoding.test b/parser/testdata/summary/postgres_regress/json_encoding.test new file mode 100644 index 0000000..9618e7b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/json_encoding.test @@ -0,0 +1,231 @@ +== 001 +|-- +-- encoding-sensitive tests for json and jsonb +|-- + +-- We provide expected-results files for UTF8 (json_encoding.out) +-- and for SQL_ASCII (json_encoding_1.out). Skip otherwise. +SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') + AS skip_test +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +== 002 +SELECT getdatabaseencoding() +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +== 003 +-- just to label the results files + +-- first json + +-- basic unicode input +SELECT '"\u"'::json +-- +STMT: SelectStmt +== 004 +-- ERROR, incomplete escape +SELECT '"\u00"'::json +-- +STMT: SelectStmt +== 005 +-- ERROR, incomplete escape +SELECT '"\u000g"'::json +-- +STMT: SelectStmt +== 006 +-- ERROR, g is not a hex digit +SELECT '"\u0000"'::json +-- +STMT: SelectStmt +== 007 +-- OK, legal escape +SELECT '"\uaBcD"'::json +-- +STMT: SelectStmt +== 008 +-- OK, uppercase and lower case both OK + +-- handling of unicode surrogate pairs + +select json '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8 +-- +STMT: SelectStmt +== 009 +select json '{ "a": "\ud83d\ud83d" }' -> 'a' +-- +STMT: SelectStmt +== 010 +-- 2 high surrogates in a row +select json '{ "a": "\ude04\ud83d" }' -> 'a' +-- +STMT: SelectStmt +== 011 +-- surrogates in wrong order +select json '{ "a": "\ud83dX" }' -> 'a' +-- +STMT: SelectStmt +== 012 +-- orphan high surrogate +select json '{ "a": "\ude04X" }' -> 'a' +-- +STMT: SelectStmt +== 013 +-- orphan low surrogate + +--handling of simple unicode escapes + +select json '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8 +-- +STMT: SelectStmt +== 014 +select json '{ "a": "dollar \u0024 character" }' as correct_everywhere +-- +STMT: SelectStmt +== 015 +select json '{ "a": "dollar \\u0024 character" }' as not_an_escape +-- +STMT: SelectStmt +== 016 +select json '{ "a": "null \u0000 escape" }' as not_unescaped +-- +STMT: SelectStmt +== 017 +select json '{ "a": "null \\u0000 escape" }' as not_an_escape +-- +STMT: SelectStmt +== 018 +select json '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8 +-- +STMT: SelectStmt +== 019 +select json '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere +-- +STMT: SelectStmt +== 020 +select json '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape +-- +STMT: SelectStmt +== 021 +select json '{ "a": "null \u0000 escape" }' ->> 'a' as fails +-- +STMT: SelectStmt +== 022 +select json '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape +-- +STMT: SelectStmt +== 023 +-- then jsonb + +-- basic unicode input +SELECT '"\u"'::jsonb +-- +STMT: SelectStmt +== 024 +-- ERROR, incomplete escape +SELECT '"\u00"'::jsonb +-- +STMT: SelectStmt +== 025 +-- ERROR, incomplete escape +SELECT '"\u000g"'::jsonb +-- +STMT: SelectStmt +== 026 +-- ERROR, g is not a hex digit +SELECT '"\u0045"'::jsonb +-- +STMT: SelectStmt +== 027 +-- OK, legal escape +SELECT '"\u0000"'::jsonb +-- +STMT: SelectStmt +== 028 +-- ERROR, we don't support U+0000 +-- use octet_length here so we don't get an odd unicode char in the +-- output +SELECT octet_length('"\uaBcD"'::jsonb::text) +-- +FUNCTION: name="octet_length" function="octet_length" schema="" ctx=Call +STMT: SelectStmt +== 029 +-- OK, uppercase and lower case both OK + +-- handling of unicode surrogate pairs + +SELECT octet_length((jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a')::text) AS correct_in_utf8 +-- +FUNCTION: name="octet_length" function="octet_length" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT jsonb '{ "a": "\ud83d\ud83d" }' -> 'a' +-- +STMT: SelectStmt +== 031 +-- 2 high surrogates in a row +SELECT jsonb '{ "a": "\ude04\ud83d" }' -> 'a' +-- +STMT: SelectStmt +== 032 +-- surrogates in wrong order +SELECT jsonb '{ "a": "\ud83dX" }' -> 'a' +-- +STMT: SelectStmt +== 033 +-- orphan high surrogate +SELECT jsonb '{ "a": "\ude04X" }' -> 'a' +-- +STMT: SelectStmt +== 034 +-- orphan low surrogate + +-- handling of simple unicode escapes + +SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8 +-- +STMT: SelectStmt +== 035 +SELECT jsonb '{ "a": "dollar \u0024 character" }' as correct_everywhere +-- +STMT: SelectStmt +== 036 +SELECT jsonb '{ "a": "dollar \\u0024 character" }' as not_an_escape +-- +STMT: SelectStmt +== 037 +SELECT jsonb '{ "a": "null \u0000 escape" }' as fails +-- +STMT: SelectStmt +== 038 +SELECT jsonb '{ "a": "null \\u0000 escape" }' as not_an_escape +-- +STMT: SelectStmt +== 039 +SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8 +-- +STMT: SelectStmt +== 040 +SELECT jsonb '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere +-- +STMT: SelectStmt +== 041 +SELECT jsonb '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape +-- +STMT: SelectStmt +== 042 +SELECT jsonb '{ "a": "null \u0000 escape" }' ->> 'a' as fails +-- +STMT: SelectStmt +== 043 +SELECT jsonb '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape +-- +STMT: SelectStmt +== 044 +-- soft error for input-time failure + +select * from pg_input_error_info('{ "a": "\ud83d\ude04\ud83d\udc36" }', 'jsonb') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/jsonb.metadata.json b/parser/testdata/summary/postgres_regress/jsonb.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/jsonb.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/jsonb.test b/parser/testdata/summary/postgres_regress/jsonb.test new file mode 100644 index 0000000..3bef236 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/jsonb.test @@ -0,0 +1,5586 @@ +== 001 +-- directory paths are passed to us in environment variables + +CREATE TABLE testjsonb ( + j jsonb +) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: CreateStmt +== 002 +COPY testjsonb FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +-- Strings. +SELECT '""'::jsonb +-- +STMT: SelectStmt +== 004 +-- OK. +SELECT $$''$$::jsonb +-- +STMT: SelectStmt +== 005 +-- ERROR, single quotes are not allowed +SELECT '"abc"'::jsonb +-- +STMT: SelectStmt +== 006 +-- OK +SELECT '"abc'::jsonb +-- +STMT: SelectStmt +== 007 +-- ERROR, quotes not closed +SELECT '"abc +def"'::jsonb +-- +STMT: SelectStmt +== 008 +-- ERROR, unescaped newline in string constant +SELECT '"\n\"\\"'::jsonb +-- +STMT: SelectStmt +== 009 +-- OK, legal escapes +SELECT '"\v"'::jsonb +-- +STMT: SelectStmt +== 010 +-- ERROR, not a valid JSON escape +-- see json_encoding test for input with unicode escapes + +-- Numbers. +SELECT '1'::jsonb +-- +STMT: SelectStmt +== 011 +-- OK +SELECT '0'::jsonb +-- +STMT: SelectStmt +== 012 +-- OK +SELECT '01'::jsonb +-- +STMT: SelectStmt +== 013 +-- ERROR, not valid according to JSON spec +SELECT '0.1'::jsonb +-- +STMT: SelectStmt +== 014 +-- OK +SELECT '9223372036854775808'::jsonb +-- +STMT: SelectStmt +== 015 +-- OK, even though it's too large for int8 +SELECT '1e100'::jsonb +-- +STMT: SelectStmt +== 016 +-- OK +SELECT '1.3e100'::jsonb +-- +STMT: SelectStmt +== 017 +-- OK +SELECT '1f2'::jsonb +-- +STMT: SelectStmt +== 018 +-- ERROR +SELECT '0.x1'::jsonb +-- +STMT: SelectStmt +== 019 +-- ERROR +SELECT '1.3ex100'::jsonb +-- +STMT: SelectStmt +== 020 +-- ERROR + +-- Arrays. +SELECT '[]'::jsonb +-- +STMT: SelectStmt +== 021 +-- OK +SELECT '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'::jsonb +-- +STMT: SelectStmt +== 022 +-- OK +SELECT '[1,2]'::jsonb +-- +STMT: SelectStmt +== 023 +-- OK +SELECT '[1,2,]'::jsonb +-- +STMT: SelectStmt +== 024 +-- ERROR, trailing comma +SELECT '[1,2'::jsonb +-- +STMT: SelectStmt +== 025 +-- ERROR, no closing bracket +SELECT '[1,[2]'::jsonb +-- +STMT: SelectStmt +== 026 +-- ERROR, no closing bracket + +-- Objects. +SELECT '{}'::jsonb +-- +STMT: SelectStmt +== 027 +-- OK +SELECT '{"abc"}'::jsonb +-- +STMT: SelectStmt +== 028 +-- ERROR, no value +SELECT '{"abc":1}'::jsonb +-- +STMT: SelectStmt +== 029 +-- OK +SELECT '{1:"abc"}'::jsonb +-- +STMT: SelectStmt +== 030 +-- ERROR, keys must be strings +SELECT '{"abc",1}'::jsonb +-- +STMT: SelectStmt +== 031 +-- ERROR, wrong separator +SELECT '{"abc"=1}'::jsonb +-- +STMT: SelectStmt +== 032 +-- ERROR, totally wrong separator +SELECT '{"abc"::1}'::jsonb +-- +STMT: SelectStmt +== 033 +-- ERROR, another wrong separator +SELECT '{"abc":1,"def":2,"ghi":[3,4],"hij":{"klm":5,"nop":[6]}}'::jsonb +-- +STMT: SelectStmt +== 034 +-- OK +SELECT '{"abc":1:2}'::jsonb +-- +STMT: SelectStmt +== 035 +-- ERROR, colon in wrong spot +SELECT '{"abc":1,3}'::jsonb +-- +STMT: SelectStmt +== 036 +-- ERROR, no value + +-- Recursion. +SET max_stack_depth = '100kB' +-- +STMT: VariableSetStmt +== 037 +SELECT repeat('[', 10000)::jsonb +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT repeat('{"a":', 10000)::jsonb +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 039 +RESET max_stack_depth +-- +STMT: VariableSetStmt +== 040 +-- Miscellaneous stuff. +SELECT 'true'::jsonb +-- +STMT: SelectStmt +== 041 +-- OK +SELECT 'false'::jsonb +-- +STMT: SelectStmt +== 042 +-- OK +SELECT 'null'::jsonb +-- +STMT: SelectStmt +== 043 +-- OK +SELECT ' true '::jsonb +-- +STMT: SelectStmt +== 044 +-- OK, even with extra whitespace +SELECT 'true false'::jsonb +-- +STMT: SelectStmt +== 045 +-- ERROR, too many values +SELECT 'true, false'::jsonb +-- +STMT: SelectStmt +== 046 +-- ERROR, too many values +SELECT 'truf'::jsonb +-- +STMT: SelectStmt +== 047 +-- ERROR, not a keyword +SELECT 'trues'::jsonb +-- +STMT: SelectStmt +== 048 +-- ERROR, not a keyword +SELECT ''::jsonb +-- +STMT: SelectStmt +== 049 +-- ERROR, no value +SELECT ' '::jsonb +-- +STMT: SelectStmt +== 050 +-- ERROR, no value + +-- Multi-line JSON input to check ERROR reporting +SELECT '{ + "one": 1, + "two":"two", + "three": + true}'::jsonb +-- +STMT: SelectStmt +== 051 +-- OK +SELECT '{ + "one": 1, + "two":,"two", -- ERROR extraneous comma before field "two" + "three": + true}'::jsonb +-- +STMT: SelectStmt +== 052 +SELECT '{ + "one": 1, + "two":"two", + "averyveryveryveryveryveryveryveryveryverylongfieldname":}'::jsonb +-- +STMT: SelectStmt +== 053 +-- ERROR missing value for last field + +-- test non-error-throwing input +select pg_input_is_valid('{"a":true}', 'jsonb') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 054 +select pg_input_is_valid('{"a":true', 'jsonb') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 055 +select * from pg_input_error_info('{"a":true', 'jsonb') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 056 +select * from pg_input_error_info('{"a":1e1000000}', 'jsonb') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 057 +-- make sure jsonb is passed through json generators without being escaped +SELECT array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']) +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +STMT: SelectStmt +== 058 +-- anyarray column + +CREATE TEMP TABLE rows AS +SELECT x, 'txt' || x as y +FROM generate_series(1,3) AS x +-- +TABLE: name="rows" schema="" table="rows" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 059 +analyze rows +-- +TABLE: name="rows" schema="" table="rows" ctx=DDL +STMT: VacuumStmt +== 060 +select attname, to_jsonb(histogram_bounds) histogram_bounds +from pg_stats +where tablename = 'rows' and + schemaname = pg_my_temp_schema()::regnamespace::text +order by 1 +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +FILTER: schema="" table="" column="tablename" +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +== 061 +-- to_jsonb, timestamps + +select to_jsonb(timestamp '2014-05-28 12:22:35.614298') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 062 +BEGIN +-- +STMT: TransactionStmt +== 063 +SET LOCAL TIME ZONE 10.5 +-- +STMT: VariableSetStmt +== 064 +select to_jsonb(timestamptz '2014-05-28 12:22:35.614298-04') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 065 +SET LOCAL TIME ZONE -8 +-- +STMT: VariableSetStmt +== 066 +select to_jsonb(timestamptz '2014-05-28 12:22:35.614298-04') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 067 +COMMIT +-- +STMT: TransactionStmt +== 068 +select to_jsonb(date '2014-05-28') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 069 +select to_jsonb(date 'Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 070 +select to_jsonb(date '-Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 071 +select to_jsonb(timestamp 'Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 072 +select to_jsonb(timestamp '-Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 073 +select to_jsonb(timestamptz 'Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 074 +select to_jsonb(timestamptz '-Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +== 075 +--jsonb_agg + +SELECT jsonb_agg(q) + FROM ( SELECT $$a$$ || x AS b, y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="jsonb_agg" function="jsonb_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT jsonb_agg(q ORDER BY x, y) + FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="jsonb_agg" function="jsonb_agg" schema="" ctx=Call +STMT: SelectStmt +== 077 +UPDATE rows SET x = NULL WHERE x = 1 +-- +TABLE: name="rows" schema="" table="rows" ctx=DML +STMT: UpdateStmt +== 078 +SELECT jsonb_agg(q ORDER BY x NULLS FIRST, y) + FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="jsonb_agg" function="jsonb_agg" schema="" ctx=Call +STMT: SelectStmt +== 079 +-- jsonb extraction functions +CREATE TEMP TABLE test_jsonb ( + json_type text, + test_json jsonb +) +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=DDL +STMT: CreateStmt +== 080 +INSERT INTO test_jsonb VALUES +('scalar','"a scalar"'), +('array','["zero", "one","two",null,"four","five", [1,2,3],{"f1":9}]'), +('object','{"field1":"val1","field2":"val2","field3":null, "field4": 4, "field5": [1,2,3], "field6": {"f1":9}}') +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 082 +SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 083 +SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 084 +SELECT test_json -> 'field2' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 085 +SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 086 +SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 087 +SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 088 +SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 089 +SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 090 +SELECT test_json -> 9 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 091 +SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 092 +SELECT test_json ->> 6 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 093 +SELECT test_json ->> 7 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 094 +SELECT test_json ->> 'field4' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 095 +SELECT test_json ->> 'field5' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 096 +SELECT test_json ->> 'field6' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 097 +SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 098 +SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 099 +SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 100 +SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FUNCTION: name="jsonb_object_keys" function="jsonb_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 101 +SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FUNCTION: name="jsonb_object_keys" function="jsonb_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 102 +SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FUNCTION: name="jsonb_object_keys" function="jsonb_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 103 +-- nulls +SELECT (test_json->'field3') IS NULL AS expect_false FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 104 +SELECT (test_json->>'field3') IS NULL AS expect_true FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 105 +SELECT (test_json->3) IS NULL AS expect_false FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 106 +SELECT (test_json->>3) IS NULL AS expect_true FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +== 107 +-- corner cases +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> null::text +-- +STMT: SelectStmt +== 108 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> null::int +-- +STMT: SelectStmt +== 109 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> 1 +-- +STMT: SelectStmt +== 110 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> 'z' +-- +STMT: SelectStmt +== 111 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> '' +-- +STMT: SelectStmt +== 112 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb -> 1 +-- +STMT: SelectStmt +== 113 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb -> 3 +-- +STMT: SelectStmt +== 114 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb -> 'z' +-- +STMT: SelectStmt +== 115 +select '{"a": "c", "b": null}'::jsonb -> 'b' +-- +STMT: SelectStmt +== 116 +select '"foo"'::jsonb -> 1 +-- +STMT: SelectStmt +== 117 +select '"foo"'::jsonb -> 'z' +-- +STMT: SelectStmt +== 118 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> null::text +-- +STMT: SelectStmt +== 119 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> null::int +-- +STMT: SelectStmt +== 120 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> 1 +-- +STMT: SelectStmt +== 121 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> 'z' +-- +STMT: SelectStmt +== 122 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> '' +-- +STMT: SelectStmt +== 123 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb ->> 1 +-- +STMT: SelectStmt +== 124 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb ->> 3 +-- +STMT: SelectStmt +== 125 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb ->> 'z' +-- +STMT: SelectStmt +== 126 +select '{"a": "c", "b": null}'::jsonb ->> 'b' +-- +STMT: SelectStmt +== 127 +select '"foo"'::jsonb ->> 1 +-- +STMT: SelectStmt +== 128 +select '"foo"'::jsonb ->> 'z' +-- +STMT: SelectStmt +== 129 +-- equality and inequality +SELECT '{"x":"y"}'::jsonb = '{"x":"y"}'::jsonb +-- +STMT: SelectStmt +== 130 +SELECT '{"x":"y"}'::jsonb = '{"x":"z"}'::jsonb +-- +STMT: SelectStmt +== 131 +SELECT '{"x":"y"}'::jsonb <> '{"x":"y"}'::jsonb +-- +STMT: SelectStmt +== 132 +SELECT '{"x":"y"}'::jsonb <> '{"x":"z"}'::jsonb +-- +STMT: SelectStmt +== 133 +-- containment +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b"}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +== 134 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b", "c":null}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +== 135 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b", "g":null}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +== 136 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"g":null}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +== 137 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"c"}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +== 138 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b"}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +== 139 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b", "c":"q"}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +== 140 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}' +-- +STMT: SelectStmt +== 141 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":null}' +-- +STMT: SelectStmt +== 142 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "g":null}' +-- +STMT: SelectStmt +== 143 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"g":null}' +-- +STMT: SelectStmt +== 144 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"c"}' +-- +STMT: SelectStmt +== 145 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}' +-- +STMT: SelectStmt +== 146 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":"q"}' +-- +STMT: SelectStmt +== 147 +SELECT '[1,2]'::jsonb @> '[1,2,2]'::jsonb +-- +STMT: SelectStmt +== 148 +SELECT '[1,1,2]'::jsonb @> '[1,2,2]'::jsonb +-- +STMT: SelectStmt +== 149 +SELECT '[[1,2]]'::jsonb @> '[[1,2,2]]'::jsonb +-- +STMT: SelectStmt +== 150 +SELECT '[1,2,2]'::jsonb <@ '[1,2]'::jsonb +-- +STMT: SelectStmt +== 151 +SELECT '[1,2,2]'::jsonb <@ '[1,1,2]'::jsonb +-- +STMT: SelectStmt +== 152 +SELECT '[[1,2,2]]'::jsonb <@ '[[1,2]]'::jsonb +-- +STMT: SelectStmt +== 153 +SELECT jsonb_contained('{"a":"b"}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +== 154 +SELECT jsonb_contained('{"a":"b", "c":null}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +== 155 +SELECT jsonb_contained('{"a":"b", "g":null}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +== 156 +SELECT jsonb_contained('{"g":null}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +== 157 +SELECT jsonb_contained('{"a":"c"}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +== 158 +SELECT jsonb_contained('{"a":"b"}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +== 159 +SELECT jsonb_contained('{"a":"b", "c":"q"}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +== 160 +SELECT '{"a":"b"}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +== 161 +SELECT '{"a":"b", "c":null}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +== 162 +SELECT '{"a":"b", "g":null}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +== 163 +SELECT '{"g":null}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +== 164 +SELECT '{"a":"c"}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +== 165 +SELECT '{"a":"b"}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +== 166 +SELECT '{"a":"b", "c":"q"}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +== 167 +-- Raw scalar may contain another raw scalar, array may contain a raw scalar +SELECT '[5]'::jsonb @> '[5]' +-- +STMT: SelectStmt +== 168 +SELECT '5'::jsonb @> '5' +-- +STMT: SelectStmt +== 169 +SELECT '[5]'::jsonb @> '5' +-- +STMT: SelectStmt +== 170 +-- But a raw scalar cannot contain an array +SELECT '5'::jsonb @> '[5]' +-- +STMT: SelectStmt +== 171 +-- In general, one thing should always contain itself. Test array containment: +SELECT '["9", ["7", "3"], 1]'::jsonb @> '["9", ["7", "3"], 1]'::jsonb +-- +STMT: SelectStmt +== 172 +SELECT '["9", ["7", "3"], ["1"]]'::jsonb @> '["9", ["7", "3"], ["1"]]'::jsonb +-- +STMT: SelectStmt +== 173 +-- array containment string matching confusion bug +SELECT '{ "name": "Bob", "tags": [ "enim", "qui"]}'::jsonb @> '{"tags":["qu"]}' +-- +STMT: SelectStmt +== 174 +-- array length +SELECT jsonb_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]') +-- +FUNCTION: name="jsonb_array_length" function="jsonb_array_length" schema="" ctx=Call +STMT: SelectStmt +== 175 +SELECT jsonb_array_length('[]') +-- +FUNCTION: name="jsonb_array_length" function="jsonb_array_length" schema="" ctx=Call +STMT: SelectStmt +== 176 +SELECT jsonb_array_length('{"f1":1,"f2":[5,6]}') +-- +FUNCTION: name="jsonb_array_length" function="jsonb_array_length" schema="" ctx=Call +STMT: SelectStmt +== 177 +SELECT jsonb_array_length('4') +-- +FUNCTION: name="jsonb_array_length" function="jsonb_array_length" schema="" ctx=Call +STMT: SelectStmt +== 178 +-- each +SELECT jsonb_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null}') +-- +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +== 179 +SELECT jsonb_each('{"a":{"b":"c","c":"b","1":"first"},"b":[1,2],"c":"cc","1":"first","n":null}'::jsonb) AS q +-- +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +== 180 +SELECT * FROM jsonb_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q +-- +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +== 181 +SELECT * FROM jsonb_each('{"a":{"b":"c","c":"b","1":"first"},"b":[1,2],"c":"cc","1":"first","n":null}'::jsonb) AS q +-- +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +== 182 +SELECT jsonb_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":"null"}') +-- +FUNCTION: name="jsonb_each_text" function="jsonb_each_text" schema="" ctx=Call +STMT: SelectStmt +== 183 +SELECT jsonb_each_text('{"a":{"b":"c","c":"b","1":"first"},"b":[1,2],"c":"cc","1":"first","n":null}'::jsonb) AS q +-- +FUNCTION: name="jsonb_each_text" function="jsonb_each_text" schema="" ctx=Call +STMT: SelectStmt +== 184 +SELECT * FROM jsonb_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q +-- +FUNCTION: name="jsonb_each_text" function="jsonb_each_text" schema="" ctx=Call +STMT: SelectStmt +== 185 +SELECT * FROM jsonb_each_text('{"a":{"b":"c","c":"b","1":"first"},"b":[1,2],"c":"cc","1":"first","n":null}'::jsonb) AS q +-- +FUNCTION: name="jsonb_each_text" function="jsonb_each_text" schema="" ctx=Call +STMT: SelectStmt +== 186 +-- exists +SELECT jsonb_exists('{"a":null, "b":"qq"}', 'a') +-- +FUNCTION: name="jsonb_exists" function="jsonb_exists" schema="" ctx=Call +STMT: SelectStmt +== 187 +SELECT jsonb_exists('{"a":null, "b":"qq"}', 'b') +-- +FUNCTION: name="jsonb_exists" function="jsonb_exists" schema="" ctx=Call +STMT: SelectStmt +== 188 +SELECT jsonb_exists('{"a":null, "b":"qq"}', 'c') +-- +FUNCTION: name="jsonb_exists" function="jsonb_exists" schema="" ctx=Call +STMT: SelectStmt +== 189 +SELECT jsonb_exists('{"a":"null", "b":"qq"}', 'a') +-- +FUNCTION: name="jsonb_exists" function="jsonb_exists" schema="" ctx=Call +STMT: SelectStmt +== 190 +SELECT jsonb '{"a":null, "b":"qq"}' ? 'a' +-- +STMT: SelectStmt +== 191 +SELECT jsonb '{"a":null, "b":"qq"}' ? 'b' +-- +STMT: SelectStmt +== 192 +SELECT jsonb '{"a":null, "b":"qq"}' ? 'c' +-- +STMT: SelectStmt +== 193 +SELECT jsonb '{"a":"null", "b":"qq"}' ? 'a' +-- +STMT: SelectStmt +== 194 +-- array exists - array elements should behave as keys +SELECT count(*) from testjsonb WHERE j->'array' ? 'bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 195 +-- type sensitive array exists - should return no rows (since "exists" only +-- matches strings that are either object keys or array elements) +SELECT count(*) from testjsonb WHERE j->'array' ? '5'::text +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 196 +-- However, a raw scalar is *contained* within the array +SELECT count(*) from testjsonb WHERE j->'array' @> '5'::jsonb +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 197 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['a','b']) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +== 198 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['b','a']) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +== 199 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['c','a']) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +== 200 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['c','d']) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +== 201 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', '{}'::text[]) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +== 202 +SELECT jsonb '{"a":null, "b":"qq"}' ?| ARRAY['a','b'] +-- +STMT: SelectStmt +== 203 +SELECT jsonb '{"a":null, "b":"qq"}' ?| ARRAY['b','a'] +-- +STMT: SelectStmt +== 204 +SELECT jsonb '{"a":null, "b":"qq"}' ?| ARRAY['c','a'] +-- +STMT: SelectStmt +== 205 +SELECT jsonb '{"a":null, "b":"qq"}' ?| ARRAY['c','d'] +-- +STMT: SelectStmt +== 206 +SELECT jsonb '{"a":null, "b":"qq"}' ?| '{}'::text[] +-- +STMT: SelectStmt +== 207 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', ARRAY['a','b']) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +== 208 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', ARRAY['b','a']) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +== 209 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', ARRAY['c','a']) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +== 210 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', ARRAY['c','d']) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +== 211 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', '{}'::text[]) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +== 212 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['a','b'] +-- +STMT: SelectStmt +== 213 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['b','a'] +-- +STMT: SelectStmt +== 214 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['c','a'] +-- +STMT: SelectStmt +== 215 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['c','d'] +-- +STMT: SelectStmt +== 216 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['a','a', 'b', 'b', 'b'] +-- +STMT: SelectStmt +== 217 +SELECT jsonb '{"a":null, "b":"qq"}' ?& '{}'::text[] +-- +STMT: SelectStmt +== 218 +-- typeof +SELECT jsonb_typeof('{}') AS object +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 219 +SELECT jsonb_typeof('{"c":3,"p":"o"}') AS object +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 220 +SELECT jsonb_typeof('[]') AS array +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 221 +SELECT jsonb_typeof('["a", 1]') AS array +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 222 +SELECT jsonb_typeof('null') AS "null" +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 223 +SELECT jsonb_typeof('1') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 224 +SELECT jsonb_typeof('-1') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 225 +SELECT jsonb_typeof('1.0') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 226 +SELECT jsonb_typeof('1e2') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 227 +SELECT jsonb_typeof('-1.0') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 228 +SELECT jsonb_typeof('true') AS boolean +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 229 +SELECT jsonb_typeof('false') AS boolean +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 230 +SELECT jsonb_typeof('"hello"') AS string +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 231 +SELECT jsonb_typeof('"true"') AS string +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 232 +SELECT jsonb_typeof('"1.0"') AS string +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +== 233 +-- jsonb_build_array, jsonb_build_object, jsonb_object_agg + +SELECT jsonb_build_array('a',1,'b',1.2,'c',true,'d',null,'e',json '{"x": 3, "y": [1,2,3]}') +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 234 +SELECT jsonb_build_array('a', NULL) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 235 +-- ok +SELECT jsonb_build_array(VARIADIC NULL::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 236 +-- ok +SELECT jsonb_build_array(VARIADIC '{}'::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 237 +-- ok +SELECT jsonb_build_array(VARIADIC '{a,b,c}'::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 238 +-- ok +SELECT jsonb_build_array(VARIADIC ARRAY['a', NULL]::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 239 +-- ok +SELECT jsonb_build_array(VARIADIC '{1,2,3,4}'::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 240 +-- ok +SELECT jsonb_build_array(VARIADIC '{1,2,3,4}'::int[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 241 +-- ok +SELECT jsonb_build_array(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 242 +-- ok + +SELECT jsonb_build_object('a',1,'b',1.2,'c',true,'d',null,'e',json '{"x": 3, "y": [1,2,3]}') +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 243 +SELECT jsonb_build_object( + 'a', jsonb_build_object('b',false,'c',99), + 'd', jsonb_build_object('e',array[9,8,7]::int[], + 'f', (select row_to_json(r) from ( select relkind, oid::regclass as name from pg_class where relname = 'pg_class') r))) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 244 +SELECT jsonb_build_object('{a,b,c}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 245 +-- error +SELECT jsonb_build_object('{a,b,c}'::text[], '{d,e,f}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 246 +-- error, key cannot be array +SELECT jsonb_build_object('a', 'b', 'c') +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 247 +-- error +SELECT jsonb_build_object(NULL, 'a') +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 248 +-- error, key cannot be NULL +SELECT jsonb_build_object('a', NULL) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 249 +-- ok +SELECT jsonb_build_object(VARIADIC NULL::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 250 +-- ok +SELECT jsonb_build_object(VARIADIC '{}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 251 +-- ok +SELECT jsonb_build_object(VARIADIC '{a,b,c}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 252 +-- error +SELECT jsonb_build_object(VARIADIC ARRAY['a', NULL]::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 253 +-- ok +SELECT jsonb_build_object(VARIADIC ARRAY[NULL, 'a']::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 254 +-- error, key cannot be NULL +SELECT jsonb_build_object(VARIADIC '{1,2,3,4}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 255 +-- ok +SELECT jsonb_build_object(VARIADIC '{1,2,3,4}'::int[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 256 +-- ok +SELECT jsonb_build_object(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 257 +-- ok + +-- empty objects/arrays +SELECT jsonb_build_array() +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +== 258 +SELECT jsonb_build_object() +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 259 +-- make sure keys are quoted +SELECT jsonb_build_object(1,2) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 260 +-- keys must be scalar and not null +SELECT jsonb_build_object(null,2) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 261 +SELECT jsonb_build_object(r,2) FROM (SELECT 1 AS a, 2 AS b) r +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 262 +SELECT jsonb_build_object(json '{"a":1,"b":2}', 3) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 263 +SELECT jsonb_build_object('{1,2,3}'::int[], 3) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 264 +-- handling of NULL values +SELECT jsonb_object_agg(1, NULL::jsonb) +-- +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +== 265 +SELECT jsonb_object_agg(NULL, '{"a":1}') +-- +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +== 266 +CREATE TEMP TABLE foo (serial_num int, name text, type text) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 267 +INSERT INTO foo VALUES (847001,'t15','GE1043') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 268 +INSERT INTO foo VALUES (847002,'t16','GE1043') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +INSERT INTO foo VALUES (847003,'sub-alpha','GESS90') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 270 +SELECT jsonb_build_object('turbines',jsonb_object_agg(serial_num,jsonb_build_object('name',name,'type',type))) +FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 271 +SELECT jsonb_object_agg(name, type) FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +== 272 +INSERT INTO foo VALUES (999999, NULL, 'bar') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 273 +SELECT jsonb_object_agg(name, type) FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +== 274 +-- edge case for parser +SELECT jsonb_object_agg(DISTINCT 'a', 'abc') +-- +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +== 275 +-- jsonb_object + +-- empty object, one dimension +SELECT jsonb_object('{}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 276 +-- empty object, two dimensions +SELECT jsonb_object('{}', '{}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 277 +-- one dimension +SELECT jsonb_object('{a,1,b,2,3,NULL,"d e f","a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 278 +-- same but with two dimensions +SELECT jsonb_object('{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 279 +-- odd number error +SELECT jsonb_object('{a,b,c}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 280 +-- one column error +SELECT jsonb_object('{{a},{b}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 281 +-- too many columns error +SELECT jsonb_object('{{a,b,c},{b,c,d}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 282 +-- too many dimensions error +SELECT jsonb_object('{{{a,b},{c,d}},{{b,c},{d,e}}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 283 +--two argument form of jsonb_object + +select jsonb_object('{a,b,c,"d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 284 +-- too many dimensions +SELECT jsonb_object('{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}', '{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 285 +-- mismatched dimensions + +select jsonb_object('{a,b,c,"d e f",g}','{1,2,3,"a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 286 +select jsonb_object('{a,b,c,"d e f"}','{1,2,3,"a b c",g}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 287 +-- null key error + +select jsonb_object('{a,b,NULL,"d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 288 +-- empty key is allowed + +select jsonb_object('{a,b,"","d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +== 289 +-- extract_path, extract_path_as_text +SELECT jsonb_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6') +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 290 +SELECT jsonb_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2') +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 291 +SELECT jsonb_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text) +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 292 +SELECT jsonb_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text) +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 293 +SELECT jsonb_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6') +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 294 +SELECT jsonb_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2') +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 295 +SELECT jsonb_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text) +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 296 +SELECT jsonb_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text) +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 297 +-- extract_path nulls +SELECT jsonb_extract_path('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') IS NULL AS expect_false +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 298 +SELECT jsonb_extract_path_text('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') IS NULL AS expect_true +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 299 +SELECT jsonb_extract_path('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') IS NULL AS expect_false +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +== 300 +SELECT jsonb_extract_path_text('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') IS NULL AS expect_true +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +== 301 +-- extract_path operators +SELECT '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>array['f4','f6'] +-- +STMT: SelectStmt +== 302 +SELECT '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>array['f2'] +-- +STMT: SelectStmt +== 303 +SELECT '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>array['f2','0'] +-- +STMT: SelectStmt +== 304 +SELECT '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>array['f2','1'] +-- +STMT: SelectStmt +== 305 +SELECT '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>>array['f4','f6'] +-- +STMT: SelectStmt +== 306 +SELECT '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>>array['f2'] +-- +STMT: SelectStmt +== 307 +SELECT '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>>array['f2','0'] +-- +STMT: SelectStmt +== 308 +SELECT '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>>array['f2','1'] +-- +STMT: SelectStmt +== 309 +-- corner cases for same +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> '{}' +-- +STMT: SelectStmt +== 310 +select '[1,2,3]'::jsonb #> '{}' +-- +STMT: SelectStmt +== 311 +select '"foo"'::jsonb #> '{}' +-- +STMT: SelectStmt +== 312 +select '42'::jsonb #> '{}' +-- +STMT: SelectStmt +== 313 +select 'null'::jsonb #> '{}' +-- +STMT: SelectStmt +== 314 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a'] +-- +STMT: SelectStmt +== 315 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a', null] +-- +STMT: SelectStmt +== 316 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a', ''] +-- +STMT: SelectStmt +== 317 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a','b'] +-- +STMT: SelectStmt +== 318 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a','b','c'] +-- +STMT: SelectStmt +== 319 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a','b','c','d'] +-- +STMT: SelectStmt +== 320 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a','z','c'] +-- +STMT: SelectStmt +== 321 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb #> array['a','1','b'] +-- +STMT: SelectStmt +== 322 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb #> array['a','z','b'] +-- +STMT: SelectStmt +== 323 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb #> array['1','b'] +-- +STMT: SelectStmt +== 324 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb #> array['z','b'] +-- +STMT: SelectStmt +== 325 +select '[{"b": "c"}, {"b": null}]'::jsonb #> array['1','b'] +-- +STMT: SelectStmt +== 326 +select '"foo"'::jsonb #> array['z'] +-- +STMT: SelectStmt +== 327 +select '42'::jsonb #> array['f2'] +-- +STMT: SelectStmt +== 328 +select '42'::jsonb #> array['0'] +-- +STMT: SelectStmt +== 329 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> '{}' +-- +STMT: SelectStmt +== 330 +select '[1,2,3]'::jsonb #>> '{}' +-- +STMT: SelectStmt +== 331 +select '"foo"'::jsonb #>> '{}' +-- +STMT: SelectStmt +== 332 +select '42'::jsonb #>> '{}' +-- +STMT: SelectStmt +== 333 +select 'null'::jsonb #>> '{}' +-- +STMT: SelectStmt +== 334 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a'] +-- +STMT: SelectStmt +== 335 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a', null] +-- +STMT: SelectStmt +== 336 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a', ''] +-- +STMT: SelectStmt +== 337 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a','b'] +-- +STMT: SelectStmt +== 338 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a','b','c'] +-- +STMT: SelectStmt +== 339 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a','b','c','d'] +-- +STMT: SelectStmt +== 340 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a','z','c'] +-- +STMT: SelectStmt +== 341 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb #>> array['a','1','b'] +-- +STMT: SelectStmt +== 342 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb #>> array['a','z','b'] +-- +STMT: SelectStmt +== 343 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb #>> array['1','b'] +-- +STMT: SelectStmt +== 344 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb #>> array['z','b'] +-- +STMT: SelectStmt +== 345 +select '[{"b": "c"}, {"b": null}]'::jsonb #>> array['1','b'] +-- +STMT: SelectStmt +== 346 +select '"foo"'::jsonb #>> array['z'] +-- +STMT: SelectStmt +== 347 +select '42'::jsonb #>> array['f2'] +-- +STMT: SelectStmt +== 348 +select '42'::jsonb #>> array['0'] +-- +STMT: SelectStmt +== 349 +-- array_elements +SELECT jsonb_array_elements('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false]') +-- +FUNCTION: name="jsonb_array_elements" function="jsonb_array_elements" schema="" ctx=Call +STMT: SelectStmt +== 350 +SELECT * FROM jsonb_array_elements('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false]') q +-- +FUNCTION: name="jsonb_array_elements" function="jsonb_array_elements" schema="" ctx=Call +STMT: SelectStmt +== 351 +SELECT jsonb_array_elements_text('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') +-- +FUNCTION: name="jsonb_array_elements_text" function="jsonb_array_elements_text" schema="" ctx=Call +STMT: SelectStmt +== 352 +SELECT * FROM jsonb_array_elements_text('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') q +-- +FUNCTION: name="jsonb_array_elements_text" function="jsonb_array_elements_text" schema="" ctx=Call +STMT: SelectStmt +== 353 +-- populate_record +CREATE TYPE jbpop AS (a text, b int, c timestamp) +-- +STMT: CompositeTypeStmt +== 354 +CREATE DOMAIN jsb_int_not_null AS int NOT NULL +-- +STMT: CreateDomainStmt +== 355 +CREATE DOMAIN jsb_int_array_1d AS int[] CHECK(array_length(VALUE, 1) = 3) +-- +STMT: CreateDomainStmt +== 356 +CREATE DOMAIN jsb_int_array_2d AS int[][] CHECK(array_length(VALUE, 2) = 3) +-- +STMT: CreateDomainStmt +== 357 +create type jb_unordered_pair as (x int, y int) +-- +STMT: CompositeTypeStmt +== 358 +create domain jb_ordered_pair as jb_unordered_pair check((value).x <= (value).y) +-- +STMT: CreateDomainStmt +== 359 +CREATE TYPE jsbrec AS ( + i int, + ia _int4, + ia1 int[], + ia2 int[][], + ia3 int[][][], + ia1d jsb_int_array_1d, + ia2d jsb_int_array_2d, + t text, + ta text[], + c char(10), + ca char(10)[], + ts timestamp, + js json, + jsb jsonb, + jsa json[], + rec jbpop, + reca jbpop[] +) +-- +STMT: CompositeTypeStmt +== 360 +CREATE TYPE jsbrec_i_not_null AS ( + i jsb_int_not_null +) +-- +STMT: CompositeTypeStmt +== 361 +SELECT * FROM jsonb_populate_record(NULL::jbpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 362 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 363 +SELECT * FROM jsonb_populate_record(NULL::jbpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 364 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 365 +SELECT * FROM jsonb_populate_record(NULL::jbpop,'{"a":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 366 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop,'{"a":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 367 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop,'{"c":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 368 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop, '{}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 369 +SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{"x": 43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 370 +SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{"i": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 371 +SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{"i": 12345}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 372 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 373 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 374 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 375 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": [[1, 2], [3, 4]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 376 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": [[1], 2]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 377 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": [[1], [2, 3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 378 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": "{1,2,3}"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 379 +SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{"ia1": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 380 +SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{"ia1": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 381 +SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{"ia1": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 382 +SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{"ia1": [[1, 2, 3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 383 +SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{"ia1d": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 384 +SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{"ia1d": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 385 +SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{"ia1d": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 386 +SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{"ia1d": [1, "2", null]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 387 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 388 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [[1, 2], [null, 4]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 389 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [[], []]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 390 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [[1, 2], [3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 391 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [[1, 2], 3, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 392 +SELECT ia2d FROM jsonb_populate_record(NULL::jsbrec, '{"ia2d": [[1, "2"], [null, 4]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 393 +SELECT ia2d FROM jsonb_populate_record(NULL::jsbrec, '{"ia2d": [[1, "2", 3], [null, 5, 6]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 394 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 395 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [[1, 2], [null, 4]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 396 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [ [[], []], [[], []], [[], []] ]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 397 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [ [[1, 2]], [[3, 4]] ]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 398 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 399 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [ [[1, 2], [3, 4]], [[5, 6], [7, 8], [9, 10]] ]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 400 +SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{"ta": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 401 +SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{"ta": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 402 +SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{"ta": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 403 +SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{"ta": [[1, 2, 3], {"k": "v"}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 404 +SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{"c": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 405 +SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{"c": "aaa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 406 +SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{"c": "aaaaaaaaaa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 407 +SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{"c": "aaaaaaaaaaaaa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 408 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 409 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 410 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 411 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": ["aaaaaaaaaaaaaaaa"]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 412 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": [[1, 2, 3], {"k": "v"}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 413 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 414 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": true}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 415 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": 123.45}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 416 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": "123.45"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 417 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": "abc"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 418 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": [123, "123", null, {"key": "value"}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 419 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": {"a": "bbb", "b": null, "c": 123.45}}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 420 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 421 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": true}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 422 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": 123.45}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 423 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": "123.45"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 424 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": "abc"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 425 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": [123, "123", null, {"key": "value"}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 426 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": {"a": "bbb", "b": null, "c": 123.45}}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 427 +SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{"jsa": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 428 +SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{"jsa": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 429 +SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{"jsa": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 430 +SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{"jsa": ["aaa", null, [1, 2, "3", {}], { "k" : "v" }]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 431 +SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{"rec": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 432 +SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{"rec": [1, 2]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 433 +SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{"rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 434 +SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{"rec": "(abc,42,01.02.2003)"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 435 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 436 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": [1, 2]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 437 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": [{"a": "abc", "b": 456}, null, {"c": "01.02.2003", "x": 43.2}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 438 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": ["(abc,42,01.02.2003)"]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 439 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": "{\"(abc,42,01.02.2003)\"}"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 440 +SELECT rec FROM jsonb_populate_record( + row(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, + row('x',3,'2012-12-31 15:30:56')::jbpop,NULL)::jsbrec, + '{"rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}}' +) q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 441 +-- Tests to check soft-error support for populate_record_field() + +-- populate_scalar() +create type jsb_char2 as (a char(2)) +-- +STMT: CompositeTypeStmt +== 442 +select jsonb_populate_record_valid(NULL::jsb_char2, '{"a": "aaa"}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 443 +select * from jsonb_populate_record(NULL::jsb_char2, '{"a": "aaa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 444 +select jsonb_populate_record_valid(NULL::jsb_char2, '{"a": "aa"}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 445 +select * from jsonb_populate_record(NULL::jsb_char2, '{"a": "aa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 446 +-- populate_array() +create type jsb_ia as (a int[]) +-- +STMT: CompositeTypeStmt +== 447 +create type jsb_ia2 as (a int[][]) +-- +STMT: CompositeTypeStmt +== 448 +select jsonb_populate_record_valid(NULL::jsb_ia, '{"a": 43.2}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 449 +select * from jsonb_populate_record(NULL::jsb_ia, '{"a": 43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 450 +select jsonb_populate_record_valid(NULL::jsb_ia, '{"a": [1, 2]}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 451 +select * from jsonb_populate_record(NULL::jsb_ia, '{"a": [1, 2]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 452 +select jsonb_populate_record_valid(NULL::jsb_ia2, '{"a": [[1], [2, 3]]}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 453 +select * from jsonb_populate_record(NULL::jsb_ia2, '{"a": [[1], [2, 3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 454 +select jsonb_populate_record_valid(NULL::jsb_ia2, '{"a": [[1, 0], [2, 3]]}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 455 +select * from jsonb_populate_record(NULL::jsb_ia2, '{"a": [[1, 0], [2, 3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 456 +-- populate_domain() +create domain jsb_i_not_null as int not null +-- +STMT: CreateDomainStmt +== 457 +create domain jsb_i_gt_1 as int check (value > 1) +-- +STMT: CreateDomainStmt +== 458 +create type jsb_i_not_null_rec as (a jsb_i_not_null) +-- +STMT: CompositeTypeStmt +== 459 +create type jsb_i_gt_1_rec as (a jsb_i_gt_1) +-- +STMT: CompositeTypeStmt +== 460 +select jsonb_populate_record_valid(NULL::jsb_i_not_null_rec, '{"a": null}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 461 +select * from jsonb_populate_record(NULL::jsb_i_not_null_rec, '{"a": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 462 +select jsonb_populate_record_valid(NULL::jsb_i_not_null_rec, '{"a": 1}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 463 +select * from jsonb_populate_record(NULL::jsb_i_not_null_rec, '{"a": 1}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 464 +select jsonb_populate_record_valid(NULL::jsb_i_gt_1_rec, '{"a": 1}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 465 +select * from jsonb_populate_record(NULL::jsb_i_gt_1_rec, '{"a": 1}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 466 +select jsonb_populate_record_valid(NULL::jsb_i_gt_1_rec, '{"a": 2}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +== 467 +select * from jsonb_populate_record(NULL::jsb_i_gt_1_rec, '{"a": 2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 468 +drop type jsb_ia, jsb_ia2, jsb_char2, jsb_i_not_null_rec, jsb_i_gt_1_rec +-- +STMT: DropStmt +== 469 +drop domain jsb_i_not_null, jsb_i_gt_1 +-- +STMT: DropStmt +== 470 +-- anonymous record type +SELECT jsonb_populate_record(null::record, '{"x": 0, "y": 1}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 471 +SELECT jsonb_populate_record(row(1,2), '{"f1": 0, "f2": 1}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 472 +SELECT * FROM + jsonb_populate_record(null::record, '{"x": 776}') AS (x int, y int) +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 473 +-- composite domain +SELECT jsonb_populate_record(null::jb_ordered_pair, '{"x": 0, "y": 1}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 474 +SELECT jsonb_populate_record(row(1,2)::jb_ordered_pair, '{"x": 0}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 475 +SELECT jsonb_populate_record(row(1,2)::jb_ordered_pair, '{"x": 1, "y": 0}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 476 +-- populate_recordset +SELECT * FROM jsonb_populate_recordset(NULL::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 477 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 478 +SELECT * FROM jsonb_populate_recordset(NULL::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 479 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 480 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 481 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"c":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 482 +SELECT * FROM jsonb_populate_recordset(NULL::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 483 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 484 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 485 +-- anonymous record type +SELECT jsonb_populate_recordset(null::record, '[{"x": 0, "y": 1}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 486 +SELECT jsonb_populate_recordset(row(1,2), '[{"f1": 0, "f2": 1}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 487 +SELECT i, jsonb_populate_recordset(row(i,50), '[{"f1":"42"},{"f2":"43"}]') +FROM (VALUES (1),(2)) v(i) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 488 +SELECT * FROM + jsonb_populate_recordset(null::record, '[{"x": 776}]') AS (x int, y int) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 489 +-- empty array is a corner case +SELECT jsonb_populate_recordset(null::record, '[]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 490 +SELECT jsonb_populate_recordset(row(1,2), '[]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 491 +SELECT * FROM jsonb_populate_recordset(NULL::jbpop,'[]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 492 +SELECT * FROM + jsonb_populate_recordset(null::record, '[]') AS (x int, y int) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 493 +-- composite domain +SELECT jsonb_populate_recordset(null::jb_ordered_pair, '[{"x": 0, "y": 1}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 494 +SELECT jsonb_populate_recordset(row(1,2)::jb_ordered_pair, '[{"x": 0}, {"y": 3}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 495 +SELECT jsonb_populate_recordset(row(1,2)::jb_ordered_pair, '[{"x": 1, "y": 0}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 496 +-- negative cases where the wrong record type is supplied +select * from jsonb_populate_recordset(row(0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 497 +select * from jsonb_populate_recordset(row(0::int,0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 498 +select * from jsonb_populate_recordset(row(0::int,0::int,0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 499 +select * from jsonb_populate_recordset(row(1000000000::int,50::int),'[{"b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +== 500 +-- jsonb_to_record and jsonb_to_recordset + +select * from jsonb_to_record('{"a":1,"b":"foo","c":"bar"}') + as x(a int, b text, d text) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 501 +select * from jsonb_to_recordset('[{"a":1,"b":"foo","d":false},{"a":2,"b":"bar","c":true}]') + as x(a int, b text, c boolean) +-- +FUNCTION: name="jsonb_to_recordset" function="jsonb_to_recordset" schema="" ctx=Call +STMT: SelectStmt +== 502 +select *, c is null as c_is_null +from jsonb_to_record('{"a":1, "b":{"c":16, "d":2}, "x":8, "ca": ["1 2", 3], "ia": [[1,2],[3,4]], "r": {"a": "aaa", "b": 123}}'::jsonb) + as t(a int, b jsonb, c text, x int, ca char(5)[], ia int[][], r jbpop) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 503 +select *, c is null as c_is_null +from jsonb_to_recordset('[{"a":1, "b":{"c":16, "d":2}, "x":8}]'::jsonb) + as t(a int, b jsonb, c text, x int) +-- +FUNCTION: name="jsonb_to_recordset" function="jsonb_to_recordset" schema="" ctx=Call +STMT: SelectStmt +== 504 +select * from jsonb_to_record('{"ia": null}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 505 +select * from jsonb_to_record('{"ia": 123}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 506 +select * from jsonb_to_record('{"ia": [1, "2", null, 4]}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 507 +select * from jsonb_to_record('{"ia": [[1, 2], [3, 4]]}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 508 +select * from jsonb_to_record('{"ia": [[1], 2]}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 509 +select * from jsonb_to_record('{"ia": [[1], [2, 3]]}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 510 +select * from jsonb_to_record('{"ia2": [1, 2, 3]}') as x(ia2 int[][]) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 511 +select * from jsonb_to_record('{"ia2": [[1, 2], [3, 4]]}') as x(ia2 int4[][]) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 512 +select * from jsonb_to_record('{"ia2": [[[1], [2], [3]]]}') as x(ia2 int4[][]) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 513 +select * from jsonb_to_record('{"out": {"key": 1}}') as x(out json) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 514 +select * from jsonb_to_record('{"out": [{"key": 1}]}') as x(out json) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 515 +select * from jsonb_to_record('{"out": "{\"key\": 1}"}') as x(out json) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 516 +select * from jsonb_to_record('{"out": {"key": 1}}') as x(out jsonb) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 517 +select * from jsonb_to_record('{"out": [{"key": 1}]}') as x(out jsonb) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 518 +select * from jsonb_to_record('{"out": "{\"key\": 1}"}') as x(out jsonb) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +== 519 +-- test type info caching in jsonb_populate_record() +CREATE TEMP TABLE jsbpoptest (js jsonb) +-- +TABLE: name="jsbpoptest" schema="" table="jsbpoptest" ctx=DDL +STMT: CreateStmt +== 520 +INSERT INTO jsbpoptest +SELECT '{ + "jsa": [1, "2", null, 4], + "rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}, + "reca": [{"a": "abc", "b": 456}, null, {"c": "01.02.2003", "x": 43.2}] +}'::jsonb +FROM generate_series(1, 3) +-- +TABLE: name="jsbpoptest" schema="" table="jsbpoptest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 521 +SELECT (jsonb_populate_record(NULL::jsbrec, js)).* FROM jsbpoptest +-- +TABLE: name="jsbpoptest" schema="" table="jsbpoptest" ctx=Select +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +== 522 +DROP TYPE jsbrec +-- +STMT: DropStmt +== 523 +DROP TYPE jsbrec_i_not_null +-- +STMT: DropStmt +== 524 +DROP DOMAIN jsb_int_not_null +-- +STMT: DropStmt +== 525 +DROP DOMAIN jsb_int_array_1d +-- +STMT: DropStmt +== 526 +DROP DOMAIN jsb_int_array_2d +-- +STMT: DropStmt +== 527 +DROP DOMAIN jb_ordered_pair +-- +STMT: DropStmt +== 528 +DROP TYPE jb_unordered_pair +-- +STMT: DropStmt +== 529 +-- indexing +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":null}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 530 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC"}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 531 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC", "public":true}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 532 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 533 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25.0}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 534 +SELECT count(*) FROM testjsonb WHERE j ? 'public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 535 +SELECT count(*) FROM testjsonb WHERE j ? 'bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 536 +SELECT count(*) FROM testjsonb WHERE j ?| ARRAY['public','disabled'] +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 537 +SELECT count(*) FROM testjsonb WHERE j ?& ARRAY['public','disabled'] +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 538 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 539 +SELECT count(*) FROM testjsonb WHERE j @@ '"CC" == $.wait' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 540 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == "CC" && true == $.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 541 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 542 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 543 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 544 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 545 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.bar)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 546 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) || exists($.disabled)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 547 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) && exists($.disabled)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 548 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 549 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? ("CC" == @)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 550 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == "CC" && true == @.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 551 +SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 552 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 553 +SELECT count(*) FROM testjsonb WHERE j @? '$' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 554 +SELECT count(*) FROM testjsonb WHERE j @? '$.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 555 +SELECT count(*) FROM testjsonb WHERE j @? '$.bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 556 +CREATE INDEX jidx ON testjsonb USING gin (j) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: IndexStmt +== 557 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 558 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":null}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 559 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC"}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 560 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC", "public":true}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 561 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 562 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25.0}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 563 +SELECT count(*) FROM testjsonb WHERE j @> '{"array":["foo"]}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 564 +SELECT count(*) FROM testjsonb WHERE j @> '{"array":["bar"]}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 565 +-- exercise GIN_SEARCH_MODE_ALL +SELECT count(*) FROM testjsonb WHERE j @> '{}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 566 +SELECT count(*) FROM testjsonb WHERE j ? 'public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 567 +SELECT count(*) FROM testjsonb WHERE j ? 'bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 568 +SELECT count(*) FROM testjsonb WHERE j ?| ARRAY['public','disabled'] +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 569 +SELECT count(*) FROM testjsonb WHERE j ?& ARRAY['public','disabled'] +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 570 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +== 571 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 572 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.wait == null))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 573 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.wait ? (@ == null))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 574 +SELECT count(*) FROM testjsonb WHERE j @@ '"CC" == $.wait' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 575 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == "CC" && true == $.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 576 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 577 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 578 +SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == "foo"' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 579 +SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == "bar"' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 580 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.array[*] == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 581 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array ? (@[*] == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 582 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array[*] ? (@ == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 583 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 584 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 585 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.bar)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 586 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) || exists($.disabled)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 587 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) && exists($.disabled)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 588 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +== 589 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 590 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? ("CC" == @)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 591 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == "CC" && true == @.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 592 +SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 593 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 594 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.array[*] == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 595 +SELECT count(*) FROM testjsonb WHERE j @? '$.array ? (@[*] == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 596 +SELECT count(*) FROM testjsonb WHERE j @? '$.array[*] ? (@ == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 597 +SELECT count(*) FROM testjsonb WHERE j @? '$' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 598 +SELECT count(*) FROM testjsonb WHERE j @? '$.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 599 +SELECT count(*) FROM testjsonb WHERE j @? '$.bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 600 +-- array exists - array elements should behave as keys (for GIN index scans too) +CREATE INDEX jidx_array ON testjsonb USING gin((j->'array')) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: IndexStmt +== 601 +SELECT count(*) from testjsonb WHERE j->'array' ? 'bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 602 +-- type sensitive array exists - should return no rows (since "exists" only +-- matches strings that are either object keys or array elements) +SELECT count(*) from testjsonb WHERE j->'array' ? '5'::text +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 603 +-- However, a raw scalar is *contained* within the array +SELECT count(*) from testjsonb WHERE j->'array' @> '5'::jsonb +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 604 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 605 +SELECT count(*) FROM (SELECT (jsonb_each(j)).key FROM testjsonb) AS wow +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +== 606 +SELECT key, count(*) FROM (SELECT (jsonb_each(j)).key FROM testjsonb) AS wow GROUP BY key ORDER BY count DESC, key +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +== 607 +-- sort/hash +SELECT count(distinct j) FROM testjsonb +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 608 +SET enable_hashagg = off +-- +STMT: VariableSetStmt +== 609 +SELECT count(*) FROM (SELECT j FROM (SELECT * FROM testjsonb UNION ALL SELECT * FROM testjsonb) js GROUP BY j) js2 +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 610 +SET enable_hashagg = on +-- +STMT: VariableSetStmt +== 611 +SET enable_sort = off +-- +STMT: VariableSetStmt +== 612 +SELECT count(*) FROM (SELECT j FROM (SELECT * FROM testjsonb UNION ALL SELECT * FROM testjsonb) js GROUP BY j) js2 +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 613 +SELECT distinct * FROM (values (jsonb '{}' || ''::text),('{}')) v(j) +-- +STMT: SelectStmt +== 614 +SET enable_sort = on +-- +STMT: VariableSetStmt +== 615 +RESET enable_hashagg +-- +STMT: VariableSetStmt +== 616 +RESET enable_sort +-- +STMT: VariableSetStmt +== 617 +DROP INDEX jidx +-- +STMT: DropStmt +== 618 +DROP INDEX jidx_array +-- +STMT: DropStmt +== 619 +-- btree +CREATE INDEX jidx ON testjsonb USING btree (j) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: IndexStmt +== 620 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 621 +SELECT count(*) FROM testjsonb WHERE j > '{"p":1}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 622 +SELECT count(*) FROM testjsonb WHERE j = '{"pos":98, "line":371, "node":"CBA", "indexed":true}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 623 +--gin path opclass +DROP INDEX jidx +-- +STMT: DropStmt +== 624 +CREATE INDEX jidx ON testjsonb USING gin (j jsonb_path_ops) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: IndexStmt +== 625 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 626 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":null}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 627 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC"}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 628 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC", "public":true}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 629 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 630 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25.0}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 631 +-- exercise GIN_SEARCH_MODE_ALL +SELECT count(*) FROM testjsonb WHERE j @> '{}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 632 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 633 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.wait == null))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 634 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.wait ? (@ == null))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 635 +SELECT count(*) FROM testjsonb WHERE j @@ '"CC" == $.wait' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 636 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == "CC" && true == $.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 637 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 638 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 639 +SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == "foo"' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 640 +SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == "bar"' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 641 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.array[*] == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 642 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array ? (@[*] == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 643 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array[*] ? (@ == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 644 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 645 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +== 646 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 647 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? ("CC" == @)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 648 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == "CC" && true == @.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 649 +SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 650 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 651 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.array[*] == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 652 +SELECT count(*) FROM testjsonb WHERE j @? '$.array ? (@[*] == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 653 +SELECT count(*) FROM testjsonb WHERE j @? '$.array[*] ? (@ == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 654 +SELECT count(*) FROM testjsonb WHERE j @? '$' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 655 +SELECT count(*) FROM testjsonb WHERE j @? '$.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 656 +SELECT count(*) FROM testjsonb WHERE j @? '$.bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 657 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 658 +DROP INDEX jidx +-- +STMT: DropStmt +== 659 +-- nested tests +SELECT '{"ff":{"a":12,"b":16}}'::jsonb +-- +STMT: SelectStmt +== 660 +SELECT '{"ff":{"a":12,"b":16},"qq":123}'::jsonb +-- +STMT: SelectStmt +== 661 +SELECT '{"aa":["a","aaa"],"qq":{"a":12,"b":16,"c":["c1","c2"],"d":{"d1":"d1","d2":"d2","d1":"d3"}}}'::jsonb +-- +STMT: SelectStmt +== 662 +SELECT '{"aa":["a","aaa"],"qq":{"a":"12","b":"16","c":["c1","c2"],"d":{"d1":"d1","d2":"d2"}}}'::jsonb +-- +STMT: SelectStmt +== 663 +SELECT '{"aa":["a","aaa"],"qq":{"a":"12","b":"16","c":["c1","c2",["c3"],{"c4":4}],"d":{"d1":"d1","d2":"d2"}}}'::jsonb +-- +STMT: SelectStmt +== 664 +SELECT '{"ff":["a","aaa"]}'::jsonb +-- +STMT: SelectStmt +== 665 +SELECT + '{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb -> 'ff', + '{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb -> 'qq', + ('{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb -> 'Y') IS NULL AS f, + ('{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb ->> 'Y') IS NULL AS t, + '{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb -> 'x' +-- +STMT: SelectStmt +== 666 +-- nested containment +SELECT '{"a":[1,2],"c":"b"}'::jsonb @> '{"a":[1,2]}' +-- +STMT: SelectStmt +== 667 +SELECT '{"a":[2,1],"c":"b"}'::jsonb @> '{"a":[1,2]}' +-- +STMT: SelectStmt +== 668 +SELECT '{"a":{"1":2},"c":"b"}'::jsonb @> '{"a":[1,2]}' +-- +STMT: SelectStmt +== 669 +SELECT '{"a":{"2":1},"c":"b"}'::jsonb @> '{"a":[1,2]}' +-- +STMT: SelectStmt +== 670 +SELECT '{"a":{"1":2},"c":"b"}'::jsonb @> '{"a":{"1":2}}' +-- +STMT: SelectStmt +== 671 +SELECT '{"a":{"2":1},"c":"b"}'::jsonb @> '{"a":{"1":2}}' +-- +STMT: SelectStmt +== 672 +SELECT '["a","b"]'::jsonb @> '["a","b","c","b"]' +-- +STMT: SelectStmt +== 673 +SELECT '["a","b","c","b"]'::jsonb @> '["a","b"]' +-- +STMT: SelectStmt +== 674 +SELECT '["a","b","c",[1,2]]'::jsonb @> '["a",[1,2]]' +-- +STMT: SelectStmt +== 675 +SELECT '["a","b","c",[1,2]]'::jsonb @> '["b",[1,2]]' +-- +STMT: SelectStmt +== 676 +SELECT '{"a":[1,2],"c":"b"}'::jsonb @> '{"a":[1]}' +-- +STMT: SelectStmt +== 677 +SELECT '{"a":[1,2],"c":"b"}'::jsonb @> '{"a":[2]}' +-- +STMT: SelectStmt +== 678 +SELECT '{"a":[1,2],"c":"b"}'::jsonb @> '{"a":[3]}' +-- +STMT: SelectStmt +== 679 +SELECT '{"a":[1,2,{"c":3,"x":4}],"c":"b"}'::jsonb @> '{"a":[{"c":3}]}' +-- +STMT: SelectStmt +== 680 +SELECT '{"a":[1,2,{"c":3,"x":4}],"c":"b"}'::jsonb @> '{"a":[{"x":4}]}' +-- +STMT: SelectStmt +== 681 +SELECT '{"a":[1,2,{"c":3,"x":4}],"c":"b"}'::jsonb @> '{"a":[{"x":4},3]}' +-- +STMT: SelectStmt +== 682 +SELECT '{"a":[1,2,{"c":3,"x":4}],"c":"b"}'::jsonb @> '{"a":[{"x":4},1]}' +-- +STMT: SelectStmt +== 683 +-- check some corner cases for indexed nested containment (bug #13756) +create temp table nestjsonb (j jsonb) +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DDL +STMT: CreateStmt +== 684 +insert into nestjsonb (j) values ('{"a":[["b",{"x":1}],["b",{"x":2}]],"c":3}') +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 685 +insert into nestjsonb (j) values ('[[14,2,3]]') +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 686 +insert into nestjsonb (j) values ('[1,[14,2,3]]') +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 687 +create index on nestjsonb using gin(j jsonb_path_ops) +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DDL +STMT: IndexStmt +== 688 +set enable_seqscan = on +-- +STMT: VariableSetStmt +== 689 +set enable_bitmapscan = off +-- +STMT: VariableSetStmt +== 690 +select * from nestjsonb where j @> '{"a":[[{"x":2}]]}'::jsonb +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 691 +select * from nestjsonb where j @> '{"c":3}' +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 692 +select * from nestjsonb where j @> '[[14]]' +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 693 +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 694 +set enable_bitmapscan = on +-- +STMT: VariableSetStmt +== 695 +select * from nestjsonb where j @> '{"a":[[{"x":2}]]}'::jsonb +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 696 +select * from nestjsonb where j @> '{"c":3}' +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 697 +select * from nestjsonb where j @> '[[14]]' +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 698 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 699 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 700 +-- nested object field / array index lookup +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'n' +-- +STMT: SelectStmt +== 701 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'a' +-- +STMT: SelectStmt +== 702 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'b' +-- +STMT: SelectStmt +== 703 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'c' +-- +STMT: SelectStmt +== 704 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'd' +-- +STMT: SelectStmt +== 705 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'd' -> '1' +-- +STMT: SelectStmt +== 706 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'e' +-- +STMT: SelectStmt +== 707 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 0 +-- +STMT: SelectStmt +== 708 +--expecting error + +SELECT '["a","b","c",[1,2],null]'::jsonb -> 0 +-- +STMT: SelectStmt +== 709 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 1 +-- +STMT: SelectStmt +== 710 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 2 +-- +STMT: SelectStmt +== 711 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 3 +-- +STMT: SelectStmt +== 712 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 3 -> 1 +-- +STMT: SelectStmt +== 713 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 4 +-- +STMT: SelectStmt +== 714 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 5 +-- +STMT: SelectStmt +== 715 +SELECT '["a","b","c",[1,2],null]'::jsonb -> -1 +-- +STMT: SelectStmt +== 716 +SELECT '["a","b","c",[1,2],null]'::jsonb -> -5 +-- +STMT: SelectStmt +== 717 +SELECT '["a","b","c",[1,2],null]'::jsonb -> -6 +-- +STMT: SelectStmt +== 718 +--nested path extraction +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{0}' +-- +STMT: SelectStmt +== 719 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{a}' +-- +STMT: SelectStmt +== 720 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c}' +-- +STMT: SelectStmt +== 721 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,0}' +-- +STMT: SelectStmt +== 722 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,1}' +-- +STMT: SelectStmt +== 723 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,2}' +-- +STMT: SelectStmt +== 724 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,3}' +-- +STMT: SelectStmt +== 725 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,-1}' +-- +STMT: SelectStmt +== 726 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,-3}' +-- +STMT: SelectStmt +== 727 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,-4}' +-- +STMT: SelectStmt +== 728 +SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{0}' +-- +STMT: SelectStmt +== 729 +SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{3}' +-- +STMT: SelectStmt +== 730 +SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{4}' +-- +STMT: SelectStmt +== 731 +SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{4,5}' +-- +STMT: SelectStmt +== 732 +--nested exists +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'n' +-- +STMT: SelectStmt +== 733 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'a' +-- +STMT: SelectStmt +== 734 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'b' +-- +STMT: SelectStmt +== 735 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'c' +-- +STMT: SelectStmt +== 736 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'd' +-- +STMT: SelectStmt +== 737 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'e' +-- +STMT: SelectStmt +== 738 +-- jsonb_strip_nulls + +select jsonb_strip_nulls(null) +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 739 +select jsonb_strip_nulls('1') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 740 +select jsonb_strip_nulls('"a string"') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 741 +select jsonb_strip_nulls('null') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 742 +select jsonb_strip_nulls('[1,2,null,3,4]') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 743 +select jsonb_strip_nulls('{"a":1,"b":null,"c":[2,null,3],"d":{"e":4,"f":null}}') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 744 +select jsonb_strip_nulls('[1,{"a":1,"b":null,"c":2},3]') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 745 +-- an empty object is not null and should not be stripped +select jsonb_strip_nulls('{"a": {"b": null, "c": null}, "d": {} }') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +== 746 +select jsonb_pretty('{"a": "test", "b": [1, 2, 3], "c": "test3", "d":{"dd": "test4", "dd2":{"ddd": "test5"}}}') +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +STMT: SelectStmt +== 747 +select jsonb_pretty('[{"f1":1,"f2":null},2,null,[[{"x":true},6,7],8],3]') +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +STMT: SelectStmt +== 748 +select jsonb_pretty('{"a":["b", "c"], "d": {"e":"f"}}') +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +STMT: SelectStmt +== 749 +select jsonb_concat('{"d": "test", "a": [1, 2]}', '{"g": "test2", "c": {"c1":1, "c2":2}}') +-- +FUNCTION: name="jsonb_concat" function="jsonb_concat" schema="" ctx=Call +STMT: SelectStmt +== 750 +select '{"aa":1 , "b":2, "cq":3}'::jsonb || '{"cq":"l", "b":"g", "fg":false}' +-- +STMT: SelectStmt +== 751 +select '{"aa":1 , "b":2, "cq":3}'::jsonb || '{"aq":"l"}' +-- +STMT: SelectStmt +== 752 +select '{"aa":1 , "b":2, "cq":3}'::jsonb || '{"aa":"l"}' +-- +STMT: SelectStmt +== 753 +select '{"aa":1 , "b":2, "cq":3}'::jsonb || '{}' +-- +STMT: SelectStmt +== 754 +select '["a", "b"]'::jsonb || '["c"]' +-- +STMT: SelectStmt +== 755 +select '["a", "b"]'::jsonb || '["c", "d"]' +-- +STMT: SelectStmt +== 756 +select '["c"]' || '["a", "b"]'::jsonb +-- +STMT: SelectStmt +== 757 +select '["a", "b"]'::jsonb || '"c"' +-- +STMT: SelectStmt +== 758 +select '"c"' || '["a", "b"]'::jsonb +-- +STMT: SelectStmt +== 759 +select '[]'::jsonb || '["a"]'::jsonb +-- +STMT: SelectStmt +== 760 +select '[]'::jsonb || '"a"'::jsonb +-- +STMT: SelectStmt +== 761 +select '"b"'::jsonb || '"a"'::jsonb +-- +STMT: SelectStmt +== 762 +select '{}'::jsonb || '{"a":"b"}'::jsonb +-- +STMT: SelectStmt +== 763 +select '[]'::jsonb || '{"a":"b"}'::jsonb +-- +STMT: SelectStmt +== 764 +select '{"a":"b"}'::jsonb || '[]'::jsonb +-- +STMT: SelectStmt +== 765 +select '"a"'::jsonb || '{"a":1}' +-- +STMT: SelectStmt +== 766 +select '{"a":1}' || '"a"'::jsonb +-- +STMT: SelectStmt +== 767 +select '[3]'::jsonb || '{}'::jsonb +-- +STMT: SelectStmt +== 768 +select '3'::jsonb || '[]'::jsonb +-- +STMT: SelectStmt +== 769 +select '3'::jsonb || '4'::jsonb +-- +STMT: SelectStmt +== 770 +select '3'::jsonb || '{}'::jsonb +-- +STMT: SelectStmt +== 771 +select '["a", "b"]'::jsonb || '{"c":1}' +-- +STMT: SelectStmt +== 772 +select '{"c": 1}'::jsonb || '["a", "b"]' +-- +STMT: SelectStmt +== 773 +select '{}'::jsonb || '{"cq":"l", "b":"g", "fg":false}' +-- +STMT: SelectStmt +== 774 +select pg_column_size('{}'::jsonb || '{}'::jsonb) = pg_column_size('{}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +== 775 +select pg_column_size('{"aa":1}'::jsonb || '{"b":2}'::jsonb) = pg_column_size('{"aa":1, "b":2}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +== 776 +select pg_column_size('{"aa":1, "b":2}'::jsonb || '{}'::jsonb) = pg_column_size('{"aa":1, "b":2}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +== 777 +select pg_column_size('{}'::jsonb || '{"aa":1, "b":2}'::jsonb) = pg_column_size('{"aa":1, "b":2}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +== 778 +select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'a') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +== 779 +select jsonb_delete('{"a":null , "b":2, "c":3}'::jsonb, 'a') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +== 780 +select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'b') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +== 781 +select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'c') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +== 782 +select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'd') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +== 783 +select '{"a":1 , "b":2, "c":3}'::jsonb - 'a' +-- +STMT: SelectStmt +== 784 +select '{"a":null , "b":2, "c":3}'::jsonb - 'a' +-- +STMT: SelectStmt +== 785 +select '{"a":1 , "b":2, "c":3}'::jsonb - 'b' +-- +STMT: SelectStmt +== 786 +select '{"a":1 , "b":2, "c":3}'::jsonb - 'c' +-- +STMT: SelectStmt +== 787 +select '{"a":1 , "b":2, "c":3}'::jsonb - 'd' +-- +STMT: SelectStmt +== 788 +select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b') = pg_column_size('{"a":1, "b":2}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +== 789 +select '["a","b","c"]'::jsonb - 3 +-- +STMT: SelectStmt +== 790 +select '["a","b","c"]'::jsonb - 2 +-- +STMT: SelectStmt +== 791 +select '["a","b","c"]'::jsonb - 1 +-- +STMT: SelectStmt +== 792 +select '["a","b","c"]'::jsonb - 0 +-- +STMT: SelectStmt +== 793 +select '["a","b","c"]'::jsonb - -1 +-- +STMT: SelectStmt +== 794 +select '["a","b","c"]'::jsonb - -2 +-- +STMT: SelectStmt +== 795 +select '["a","b","c"]'::jsonb - -3 +-- +STMT: SelectStmt +== 796 +select '["a","b","c"]'::jsonb - -4 +-- +STMT: SelectStmt +== 797 +select '{"a":1 , "b":2, "c":3}'::jsonb - '{b}'::text[] +-- +STMT: SelectStmt +== 798 +select '{"a":1 , "b":2, "c":3}'::jsonb - '{c,b}'::text[] +-- +STMT: SelectStmt +== 799 +select '{"a":1 , "b":2, "c":3}'::jsonb - '{}'::text[] +-- +STMT: SelectStmt +== 800 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{n}', '[1,2,3]') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 801 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '[1,2,3]') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 802 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{d,1,0}', '[1,2,3]') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 803 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{d,NULL,0}', '[1,2,3]') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 804 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{n}', '{"1": 2}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 805 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '{"1": 2}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 806 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{d,1,0}', '{"1": 2}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 807 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{d,NULL,0}', '{"1": 2}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 808 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '"test"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 809 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '{"f": "test"}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 810 +select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}') +-- +FUNCTION: name="jsonb_delete_path" function="jsonb_delete_path" schema="" ctx=Call +STMT: SelectStmt +== 811 +select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}') +-- +FUNCTION: name="jsonb_delete_path" function="jsonb_delete_path" schema="" ctx=Call +STMT: SelectStmt +== 812 +select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}') +-- +FUNCTION: name="jsonb_delete_path" function="jsonb_delete_path" schema="" ctx=Call +STMT: SelectStmt +== 813 +select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{n}' +-- +STMT: SelectStmt +== 814 +select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1}' +-- +STMT: SelectStmt +== 815 +select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1e}' +-- +STMT: SelectStmt +== 816 +-- invalid array subscript +select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{d,1,0}' +-- +STMT: SelectStmt +== 817 +-- empty structure and error conditions for delete and replace + +select '"a"'::jsonb - 'a' +-- +STMT: SelectStmt +== 818 +-- error +select '{}'::jsonb - 'a' +-- +STMT: SelectStmt +== 819 +select '[]'::jsonb - 'a' +-- +STMT: SelectStmt +== 820 +select '"a"'::jsonb - 1 +-- +STMT: SelectStmt +== 821 +-- error +select '{}'::jsonb - 1 +-- +STMT: SelectStmt +== 822 +-- error +select '[]'::jsonb - 1 +-- +STMT: SelectStmt +== 823 +select '"a"'::jsonb #- '{a}' +-- +STMT: SelectStmt +== 824 +-- error +select '{}'::jsonb #- '{a}' +-- +STMT: SelectStmt +== 825 +select '[]'::jsonb #- '{a}' +-- +STMT: SelectStmt +== 826 +select jsonb_set('"a"','{a}','"b"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 827 +--error +select jsonb_set('{}','{a}','"b"', false) +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 828 +select jsonb_set('[]','{1}','"b"', false) +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 829 +select jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0}','[2,3,4]', false) +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 830 +-- jsonb_set adding instead of replacing + +-- prepend to array +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,-33}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 831 +-- append to array +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,33}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 832 +-- check nesting levels addition +select jsonb_set('{"a":1,"b":[4,5,[0,1,2],6,7],"c":{"d":4}}','{b,2,33}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 833 +-- add new key +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{c,e}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 834 +-- adding doesn't do anything if elements before last aren't present +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{x,-33}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 835 +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{x,y}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 836 +-- add to empty object +select jsonb_set('{}','{x}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 837 +--add to empty array +select jsonb_set('[]','{0}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 838 +select jsonb_set('[]','{99}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 839 +select jsonb_set('[]','{-99}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 840 +select jsonb_set('{"a": [1, 2, 3]}', '{a, non_integer}', '"new_value"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 841 +select jsonb_set('{"a": {"b": [1, 2, 3]}}', '{a, b, non_integer}', '"new_value"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 842 +select jsonb_set('{"a": {"b": [1, 2, 3]}}', '{a, b, NULL}', '"new_value"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +== 843 +-- jsonb_set_lax + + +-- pass though non nulls to jsonb_set +select jsonb_set_lax('{"a":1,"b":2}','{b}','5') +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 844 +select jsonb_set_lax('{"a":1,"b":2}','{d}','6', true) +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 845 +-- using the default treatment +select jsonb_set_lax('{"a":1,"b":2}','{b}',null) +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 846 +select jsonb_set_lax('{"a":1,"b":2}','{d}',null,true) +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 847 +-- errors +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, true, null) +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 848 +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, true, 'no_such_treatment') +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 849 +-- explicit treatments +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, null_value_treatment => 'raise_exception') as raise_exception +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 850 +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, null_value_treatment => 'return_target') as return_target +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 851 +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, null_value_treatment => 'delete_key') as delete_key +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 852 +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, null_value_treatment => 'use_json_null') as use_json_null +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +== 853 +-- jsonb_insert +select jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 854 +select jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 855 +select jsonb_insert('{"a": {"b": {"c": [0, 1, "test1", "test2"]}}}', '{a, b, c, 2}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 856 +select jsonb_insert('{"a": {"b": {"c": [0, 1, "test1", "test2"]}}}', '{a, b, c, 2}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 857 +select jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '{"b": "value"}') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 858 +select jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '["value1", "value2"]') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 859 +-- edge cases +select jsonb_insert('{"a": [0,1,2]}', '{a, 0}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 860 +select jsonb_insert('{"a": [0,1,2]}', '{a, 0}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 861 +select jsonb_insert('{"a": [0,1,2]}', '{a, 2}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 862 +select jsonb_insert('{"a": [0,1,2]}', '{a, 2}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 863 +select jsonb_insert('{"a": [0,1,2]}', '{a, -1}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 864 +select jsonb_insert('{"a": [0,1,2]}', '{a, -1}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 865 +select jsonb_insert('[]', '{1}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 866 +select jsonb_insert('[]', '{1}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 867 +select jsonb_insert('{"a": []}', '{a, 1}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 868 +select jsonb_insert('{"a": []}', '{a, 1}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 869 +select jsonb_insert('{"a": [0,1,2]}', '{a, 10}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 870 +select jsonb_insert('{"a": [0,1,2]}', '{a, -10}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 871 +-- jsonb_insert should be able to insert new value for objects, but not to replace +select jsonb_insert('{"a": {"b": "value"}}', '{a, c}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 872 +select jsonb_insert('{"a": {"b": "value"}}', '{a, c}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 873 +select jsonb_insert('{"a": {"b": "value"}}', '{a, b}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 874 +select jsonb_insert('{"a": {"b": "value"}}', '{a, b}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +== 875 +-- jsonb subscript +select ('123'::jsonb)['a'] +-- +STMT: SelectStmt +== 876 +select ('123'::jsonb)[0] +-- +STMT: SelectStmt +== 877 +select ('123'::jsonb)[NULL] +-- +STMT: SelectStmt +== 878 +select ('{"a": 1}'::jsonb)['a'] +-- +STMT: SelectStmt +== 879 +select ('{"a": 1}'::jsonb)[0] +-- +STMT: SelectStmt +== 880 +select ('{"a": 1}'::jsonb)['not_exist'] +-- +STMT: SelectStmt +== 881 +select ('{"a": 1}'::jsonb)[NULL] +-- +STMT: SelectStmt +== 882 +select ('[1, "2", null]'::jsonb)['a'] +-- +STMT: SelectStmt +== 883 +select ('[1, "2", null]'::jsonb)[0] +-- +STMT: SelectStmt +== 884 +select ('[1, "2", null]'::jsonb)['1'] +-- +STMT: SelectStmt +== 885 +select ('[1, "2", null]'::jsonb)[1.0] +-- +STMT: SelectStmt +== 886 +select ('[1, "2", null]'::jsonb)[2] +-- +STMT: SelectStmt +== 887 +select ('[1, "2", null]'::jsonb)[3] +-- +STMT: SelectStmt +== 888 +select ('[1, "2", null]'::jsonb)[-2] +-- +STMT: SelectStmt +== 889 +select ('[1, "2", null]'::jsonb)[1]['a'] +-- +STMT: SelectStmt +== 890 +select ('[1, "2", null]'::jsonb)[1][0] +-- +STMT: SelectStmt +== 891 +select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb)['b'] +-- +STMT: SelectStmt +== 892 +select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb)['d'] +-- +STMT: SelectStmt +== 893 +select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb)['d'][1] +-- +STMT: SelectStmt +== 894 +select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb)['d']['a'] +-- +STMT: SelectStmt +== 895 +select ('{"a": {"a1": {"a2": "aaa"}}, "b": "bbb", "c": "ccc"}'::jsonb)['a']['a1'] +-- +STMT: SelectStmt +== 896 +select ('{"a": {"a1": {"a2": "aaa"}}, "b": "bbb", "c": "ccc"}'::jsonb)['a']['a1']['a2'] +-- +STMT: SelectStmt +== 897 +select ('{"a": {"a1": {"a2": "aaa"}}, "b": "bbb", "c": "ccc"}'::jsonb)['a']['a1']['a2']['a3'] +-- +STMT: SelectStmt +== 898 +select ('{"a": ["a1", {"b1": ["aaa", "bbb", "ccc"]}], "b": "bb"}'::jsonb)['a'][1]['b1'] +-- +STMT: SelectStmt +== 899 +select ('{"a": ["a1", {"b1": ["aaa", "bbb", "ccc"]}], "b": "bb"}'::jsonb)['a'][1]['b1'][2] +-- +STMT: SelectStmt +== 900 +-- slices are not supported +select ('{"a": 1}'::jsonb)['a':'b'] +-- +STMT: SelectStmt +== 901 +select ('[1, "2", null]'::jsonb)[1:2] +-- +STMT: SelectStmt +== 902 +select ('[1, "2", null]'::jsonb)[:2] +-- +STMT: SelectStmt +== 903 +select ('[1, "2", null]'::jsonb)[1:] +-- +STMT: SelectStmt +== 904 +select ('[1, "2", null]'::jsonb)[:] +-- +STMT: SelectStmt +== 905 +create TEMP TABLE test_jsonb_subscript ( + id int, + test_json jsonb +) +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DDL +STMT: CreateStmt +== 906 +insert into test_jsonb_subscript values +(1, '{}'), -- empty jsonb +(2, '{"key": "value"}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 907 +-- jsonb with data + +-- update empty jsonb +update test_jsonb_subscript set test_json['a'] = '1' where id = 1 +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 908 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 909 +-- update jsonb with some data +update test_jsonb_subscript set test_json['a'] = '1' where id = 2 +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 910 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 911 +-- replace jsonb +update test_jsonb_subscript set test_json['a'] = '"test"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 912 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 913 +-- replace by object +update test_jsonb_subscript set test_json['a'] = '{"b": 1}'::jsonb +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 914 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 915 +-- replace by array +update test_jsonb_subscript set test_json['a'] = '[1, 2, 3]'::jsonb +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 916 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 917 +-- use jsonb subscription in where clause +select * from test_jsonb_subscript where test_json['key'] = '"value"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FILTER: schema="" table="" column="test_json" +STMT: SelectStmt +== 918 +select * from test_jsonb_subscript where test_json['key_doesnt_exists'] = '"value"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FILTER: schema="" table="" column="test_json" +STMT: SelectStmt +== 919 +select * from test_jsonb_subscript where test_json['key'] = '"wrong_value"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FILTER: schema="" table="" column="test_json" +STMT: SelectStmt +== 920 +-- NULL +update test_jsonb_subscript set test_json[NULL] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 921 +update test_jsonb_subscript set test_json['another_key'] = NULL +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 922 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 923 +-- NULL as jsonb source +insert into test_jsonb_subscript values (3, NULL) +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 924 +update test_jsonb_subscript set test_json['a'] = '1' where id = 3 +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 925 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 926 +update test_jsonb_subscript set test_json = NULL where id = 3 +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 927 +update test_jsonb_subscript set test_json[0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 928 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 929 +-- Fill the gaps logic +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 930 +insert into test_jsonb_subscript values (1, '[0]') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 931 +update test_jsonb_subscript set test_json[5] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 932 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 933 +update test_jsonb_subscript set test_json[-4] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 934 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 935 +update test_jsonb_subscript set test_json[-8] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 936 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 937 +-- keep consistent values position +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 938 +insert into test_jsonb_subscript values (1, '[]') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 939 +update test_jsonb_subscript set test_json[5] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 940 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 941 +-- create the whole path +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 942 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 943 +update test_jsonb_subscript set test_json['a'][0]['b'][0]['c'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 944 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 945 +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 946 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 947 +update test_jsonb_subscript set test_json['a'][2]['b'][2]['c'][2] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 948 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 949 +-- create the whole path with already existing keys +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 950 +insert into test_jsonb_subscript values (1, '{"b": 1}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 951 +update test_jsonb_subscript set test_json['a'][0] = '2' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 952 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 953 +-- the start jsonb is an object, first subscript is treated as a key +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 954 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 955 +update test_jsonb_subscript set test_json[0]['a'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 956 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 957 +-- the start jsonb is an array +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 958 +insert into test_jsonb_subscript values (1, '[]') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 959 +update test_jsonb_subscript set test_json[0]['a'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 960 +update test_jsonb_subscript set test_json[2]['b'] = '2' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 961 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 962 +-- overwriting an existing path +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 963 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 964 +update test_jsonb_subscript set test_json['a']['b'][1] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 965 +update test_jsonb_subscript set test_json['a']['b'][10] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 966 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 967 +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 968 +insert into test_jsonb_subscript values (1, '[]') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 969 +update test_jsonb_subscript set test_json[0][0][0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 970 +update test_jsonb_subscript set test_json[0][0][1] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 971 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 972 +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 973 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 974 +update test_jsonb_subscript set test_json['a']['b'][10] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 975 +update test_jsonb_subscript set test_json['a'][10][10] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 976 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 977 +-- an empty sub element + +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 978 +insert into test_jsonb_subscript values (1, '{"a": {}}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 979 +update test_jsonb_subscript set test_json['a']['b']['c'][2] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 980 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 981 +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 982 +insert into test_jsonb_subscript values (1, '{"a": []}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 983 +update test_jsonb_subscript set test_json['a'][1]['c'][2] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 984 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 985 +-- trying replace assuming a composite object, but it's an element or a value + +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 986 +insert into test_jsonb_subscript values (1, '{"a": 1}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 987 +update test_jsonb_subscript set test_json['a']['b'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 988 +update test_jsonb_subscript set test_json['a']['b']['c'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 989 +update test_jsonb_subscript set test_json['a'][0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 990 +update test_jsonb_subscript set test_json['a'][0]['c'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 991 +update test_jsonb_subscript set test_json['a'][0][0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 992 +-- trying replace assuming a composite object, but it's a raw scalar + +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +== 993 +insert into test_jsonb_subscript values (1, 'null') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 994 +update test_jsonb_subscript set test_json[0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 995 +update test_jsonb_subscript set test_json[0][0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 996 +-- try some things with short-header and toasted subscript values + +drop table test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DDL +STMT: DropStmt +== 997 +create temp table test_jsonb_subscript ( + id text, + test_json jsonb +) +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DDL +STMT: CreateStmt +== 998 +insert into test_jsonb_subscript values('foo', '{"foo": "bar"}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 999 +insert into test_jsonb_subscript + select s, ('{"' || s || '": "bar"}')::jsonb from repeat('xyzzy', 500) s +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 1000 +select length(id), test_json[id] from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 1001 +update test_jsonb_subscript set test_json[id] = '"baz"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +== 1002 +select length(id), test_json[id] from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 1003 +table test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +== 1004 +-- jsonb to tsvector +select to_tsvector('{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1005 +-- jsonb to tsvector with config +select to_tsvector('simple', '{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1006 +-- jsonb to tsvector with stop words +select to_tsvector('english', '{"a": "aaa in bbb ddd ccc", "b": ["the eee fff ggg"], "c": {"d": "hhh. iii"}}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1007 +-- jsonb to tsvector with numeric values +select to_tsvector('english', '{"a": "aaa in bbb ddd ccc", "b": 123, "c": 456}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1008 +-- jsonb_to_tsvector +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1009 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"key"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1010 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"string"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1011 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"numeric"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1012 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"boolean"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1013 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '["string", "numeric"]') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1014 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1015 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"key"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1016 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"string"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1017 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"numeric"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1018 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"boolean"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1019 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '["string", "numeric"]') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1020 +-- to_tsvector corner cases +select to_tsvector('""'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1021 +select to_tsvector('{}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1022 +select to_tsvector('[]'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1023 +select to_tsvector('null'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1024 +-- jsonb_to_tsvector corner cases +select jsonb_to_tsvector('""'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1025 +select jsonb_to_tsvector('{}'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1026 +select jsonb_to_tsvector('[]'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1027 +select jsonb_to_tsvector('null'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1028 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '""') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1029 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '{}') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1030 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '[]') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1031 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, 'null') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1032 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '["all", null]') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 1033 +-- ts_headline for jsonb +select ts_headline('{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::jsonb, tsquery('bbb & ddd & hhh')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 1034 +select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc ddd fff"}, "d": ["ggg hhh", "iii jjj"]}'::jsonb, tsquery('bbb & ddd & hhh')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 1035 +select ts_headline('{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::jsonb, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 1036 +select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::jsonb, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 1037 +-- corner cases for ts_headline with jsonb +select ts_headline('null'::jsonb, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 1038 +select ts_headline('{}'::jsonb, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 1039 +select ts_headline('[]'::jsonb, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +== 1040 +-- casts +select 'true'::jsonb::bool +-- +STMT: SelectStmt +== 1041 +select '[]'::jsonb::bool +-- +STMT: SelectStmt +== 1042 +select '1.0'::jsonb::float +-- +STMT: SelectStmt +== 1043 +select '[1.0]'::jsonb::float +-- +STMT: SelectStmt +== 1044 +select '12345'::jsonb::int4 +-- +STMT: SelectStmt +== 1045 +select '"hello"'::jsonb::int4 +-- +STMT: SelectStmt +== 1046 +select '12345'::jsonb::numeric +-- +STMT: SelectStmt +== 1047 +select '{}'::jsonb::numeric +-- +STMT: SelectStmt +== 1048 +select '12345.05'::jsonb::numeric +-- +STMT: SelectStmt +== 1049 +select '12345.05'::jsonb::float4 +-- +STMT: SelectStmt +== 1050 +select '12345.05'::jsonb::float8 +-- +STMT: SelectStmt +== 1051 +select '12345.05'::jsonb::int2 +-- +STMT: SelectStmt +== 1052 +select '12345.05'::jsonb::int4 +-- +STMT: SelectStmt +== 1053 +select '12345.05'::jsonb::int8 +-- +STMT: SelectStmt +== 1054 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::numeric +-- +STMT: SelectStmt +== 1055 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::float4 +-- +STMT: SelectStmt +== 1056 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::float8 +-- +STMT: SelectStmt +== 1057 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::int2 +-- +STMT: SelectStmt +== 1058 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::int4 +-- +STMT: SelectStmt +== 1059 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::int8 +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/jsonb_jsonpath.metadata.json b/parser/testdata/summary/postgres_regress/jsonb_jsonpath.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/jsonb_jsonpath.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/jsonb_jsonpath.test b/parser/testdata/summary/postgres_regress/jsonb_jsonpath.test new file mode 100644 index 0000000..52d6fb1 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/jsonb_jsonpath.test @@ -0,0 +1,4255 @@ +== 001 +select jsonb '{"a": 12}' @? '$' +-- +STMT: SelectStmt +== 002 +select jsonb '{"a": 12}' @? '1' +-- +STMT: SelectStmt +== 003 +select jsonb '{"a": 12}' @? '$.a.b' +-- +STMT: SelectStmt +== 004 +select jsonb '{"a": 12}' @? '$.b' +-- +STMT: SelectStmt +== 005 +select jsonb '{"a": 12}' @? '$.a + 2' +-- +STMT: SelectStmt +== 006 +select jsonb '{"a": 12}' @? '$.b + 2' +-- +STMT: SelectStmt +== 007 +select jsonb '{"a": {"a": 12}}' @? '$.a.a' +-- +STMT: SelectStmt +== 008 +select jsonb '{"a": {"a": 12}}' @? '$.*.a' +-- +STMT: SelectStmt +== 009 +select jsonb '{"b": {"a": 12}}' @? '$.*.a' +-- +STMT: SelectStmt +== 010 +select jsonb '{"b": {"a": 12}}' @? '$.*.b' +-- +STMT: SelectStmt +== 011 +select jsonb '{"b": {"a": 12}}' @? 'strict $.*.b' +-- +STMT: SelectStmt +== 012 +select jsonb '{}' @? '$.*' +-- +STMT: SelectStmt +== 013 +select jsonb '{"a": 1}' @? '$.*' +-- +STMT: SelectStmt +== 014 +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{1}' +-- +STMT: SelectStmt +== 015 +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{2}' +-- +STMT: SelectStmt +== 016 +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{3}' +-- +STMT: SelectStmt +== 017 +select jsonb '[]' @? '$[*]' +-- +STMT: SelectStmt +== 018 +select jsonb '[1]' @? '$[*]' +-- +STMT: SelectStmt +== 019 +select jsonb '[1]' @? '$[1]' +-- +STMT: SelectStmt +== 020 +select jsonb '[1]' @? 'strict $[1]' +-- +STMT: SelectStmt +== 021 +select jsonb_path_query('[1]', 'strict $[1]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 022 +select jsonb_path_query('[1]', 'strict $[1]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 023 +select jsonb '[1]' @? 'lax $[10000000000000000]' +-- +STMT: SelectStmt +== 024 +select jsonb '[1]' @? 'strict $[10000000000000000]' +-- +STMT: SelectStmt +== 025 +select jsonb_path_query('[1]', 'lax $[10000000000000000]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 026 +select jsonb_path_query('[1]', 'strict $[10000000000000000]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 027 +select jsonb '[1]' @? '$[0]' +-- +STMT: SelectStmt +== 028 +select jsonb '[1]' @? '$[0.3]' +-- +STMT: SelectStmt +== 029 +select jsonb '[1]' @? '$[0.5]' +-- +STMT: SelectStmt +== 030 +select jsonb '[1]' @? '$[0.9]' +-- +STMT: SelectStmt +== 031 +select jsonb '[1]' @? '$[1.2]' +-- +STMT: SelectStmt +== 032 +select jsonb '[1]' @? 'strict $[1.2]' +-- +STMT: SelectStmt +== 033 +select jsonb '{"a": [1,2,3], "b": [3,4,5]}' @? '$ ? (@.a[*] > @.b[*])' +-- +STMT: SelectStmt +== 034 +select jsonb '{"a": [1,2,3], "b": [3,4,5]}' @? '$ ? (@.a[*] >= @.b[*])' +-- +STMT: SelectStmt +== 035 +select jsonb '{"a": [1,2,3], "b": [3,4,"5"]}' @? '$ ? (@.a[*] >= @.b[*])' +-- +STMT: SelectStmt +== 036 +select jsonb '{"a": [1,2,3], "b": [3,4,"5"]}' @? 'strict $ ? (@.a[*] >= @.b[*])' +-- +STMT: SelectStmt +== 037 +select jsonb '{"a": [1,2,3], "b": [3,4,null]}' @? '$ ? (@.a[*] >= @.b[*])' +-- +STMT: SelectStmt +== 038 +select jsonb '1' @? '$ ? ((@ == "1") is unknown)' +-- +STMT: SelectStmt +== 039 +select jsonb '1' @? '$ ? ((@ == 1) is unknown)' +-- +STMT: SelectStmt +== 040 +select jsonb '[{"a": 1}, {"a": 2}]' @? '$[0 to 1] ? (@.a > 1)' +-- +STMT: SelectStmt +== 041 +select jsonb_path_exists('[{"a": 1}, {"a": 2}, 3]', 'lax $[*].a', silent => false) +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 042 +select jsonb_path_exists('[{"a": 1}, {"a": 2}, 3]', 'lax $[*].a', silent => true) +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 043 +select jsonb_path_exists('[{"a": 1}, {"a": 2}, 3]', 'strict $[*].a', silent => false) +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 044 +select jsonb_path_exists('[{"a": 1}, {"a": 2}, 3]', 'strict $[*].a', silent => true) +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 045 +select jsonb_path_query('1', 'lax $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 046 +select jsonb_path_query('1', 'strict $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 047 +select jsonb_path_query('1', 'strict $.*') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 048 +select jsonb_path_query('1', 'strict $.a', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 049 +select jsonb_path_query('1', 'strict $.*', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 050 +select jsonb_path_query('[]', 'lax $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 051 +select jsonb_path_query('[]', 'strict $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 052 +select jsonb_path_query('[]', 'strict $.a', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 053 +select jsonb_path_query('{}', 'lax $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 054 +select jsonb_path_query('{}', 'strict $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 055 +select jsonb_path_query('{}', 'strict $.a', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 056 +select jsonb_path_query('1', 'strict $[1]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 057 +select jsonb_path_query('1', 'strict $[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 058 +select jsonb_path_query('[]', 'strict $[1]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 059 +select jsonb_path_query('[]', 'strict $["a"]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 060 +select jsonb_path_query('1', 'strict $[1]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 061 +select jsonb_path_query('1', 'strict $[*]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 062 +select jsonb_path_query('[]', 'strict $[1]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 063 +select jsonb_path_query('[]', 'strict $["a"]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 064 +select jsonb_path_query('{"a": 12, "b": {"a": 13}}', '$.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 065 +select jsonb_path_query('{"a": 12, "b": {"a": 13}}', '$.b') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 066 +select jsonb_path_query('{"a": 12, "b": {"a": 13}}', '$.*') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 067 +select jsonb_path_query('{"a": 12, "b": {"a": 13}}', 'lax $.*.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 068 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[*].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 069 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[*].*') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 070 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[0].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 071 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[1].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 072 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[2].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 073 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[0,1].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 074 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[0 to 10].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 075 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[0 to 10 / 0].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 076 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}, "ccc", true]', '$[2.5 - 1 to $.size() - 2]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 077 +select jsonb_path_query('1', 'lax $[0]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 078 +select jsonb_path_query('1', 'lax $[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 079 +select jsonb_path_query('[1]', 'lax $[0]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 080 +select jsonb_path_query('[1]', 'lax $[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 081 +select jsonb_path_query('[1,2,3]', 'lax $[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 082 +select jsonb_path_query('[1,2,3]', 'strict $[*].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 083 +select jsonb_path_query('[1,2,3]', 'strict $[*].a', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 084 +select jsonb_path_query('[]', '$[last]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 085 +select jsonb_path_query('[]', '$[last ? (exists(last))]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 086 +select jsonb_path_query('[]', 'strict $[last]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 087 +select jsonb_path_query('[]', 'strict $[last]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 088 +select jsonb_path_query('[1]', '$[last]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 089 +select jsonb_path_query('[1,2,3]', '$[last]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 090 +select jsonb_path_query('[1,2,3]', '$[last - 1]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 091 +select jsonb_path_query('[1,2,3]', '$[last ? (@.type() == "number")]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 092 +select jsonb_path_query('[1,2,3]', '$[last ? (@.type() == "string")]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 093 +select jsonb_path_query('[1,2,3]', '$[last ? (@.type() == "string")]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 094 +select * from jsonb_path_query('{"a": 10}', '$') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 095 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 096 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)', '1') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 097 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)', '[{"value" : 13}]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 098 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)', '{"value" : 13}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 099 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)', '{"value" : 8}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 100 +select * from jsonb_path_query('{"a": 10}', '$.a ? (@ < $value)', '{"value" : 13}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 101 +select * from jsonb_path_query('[10,11,12,13,14,15]', '$[*] ? (@ < $value)', '{"value" : 13}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 102 +select * from jsonb_path_query('[10,11,12,13,14,15]', '$[0,1] ? (@ < $x.value)', '{"x": {"value" : 13}}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 103 +select * from jsonb_path_query('[10,11,12,13,14,15]', '$[0 to 2] ? (@ < $value)', '{"value" : 15}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 104 +select * from jsonb_path_query('[1,"1",2,"2",null]', '$[*] ? (@ == "1")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 105 +select * from jsonb_path_query('[1,"1",2,"2",null]', '$[*] ? (@ == $value)', '{"value" : "1"}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 106 +select * from jsonb_path_query('[1,"1",2,"2",null]', '$[*] ? (@ == $value)', '{"value" : null}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 107 +select * from jsonb_path_query('[1, "2", null]', '$[*] ? (@ != null)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 108 +select * from jsonb_path_query('[1, "2", null]', '$[*] ? (@ == null)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 109 +select * from jsonb_path_query('{}', '$ ? (@ == @)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 110 +select * from jsonb_path_query('[]', 'strict $ ? (@ == @)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 111 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 112 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{0}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 113 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{0 to last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 114 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 115 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1 to last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 116 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{2}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 117 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{2 to last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 118 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{3 to last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 119 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 120 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 121 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{0}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 122 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 123 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{0 to last}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 124 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1 to last}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 125 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1 to 2}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 126 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 127 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{0}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 128 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{1}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 129 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{0 to last}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 130 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{1 to last}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 131 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{1 to 2}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 132 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{2 to 3}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 133 +select jsonb '{"a": {"b": 1}}' @? '$.**.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 134 +select jsonb '{"a": {"b": 1}}' @? '$.**{0}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 135 +select jsonb '{"a": {"b": 1}}' @? '$.**{1}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 136 +select jsonb '{"a": {"b": 1}}' @? '$.**{0 to last}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 137 +select jsonb '{"a": {"b": 1}}' @? '$.**{1 to last}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 138 +select jsonb '{"a": {"b": 1}}' @? '$.**{1 to 2}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 139 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 140 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{0}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 141 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 142 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{0 to last}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 143 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1 to last}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 144 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1 to 2}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 145 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{2 to 3}.b ? ( @ > 0)' +-- +STMT: SelectStmt +== 146 +select jsonb_path_query('{"g": {"x": 2}}', '$.g ? (exists (@.x))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 147 +select jsonb_path_query('{"g": {"x": 2}}', '$.g ? (exists (@.y))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 148 +select jsonb_path_query('{"g": {"x": 2}}', '$.g ? (exists (@.x ? (@ >= 2) ))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 149 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'lax $.g ? (exists (@.x))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 150 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'lax $.g ? (exists (@.x + "3"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 151 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'lax $.g ? ((exists (@.x + "3")) is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 152 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'strict $.g[*] ? (exists (@.x))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 153 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'strict $.g[*] ? ((exists (@.x)) is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 154 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'strict $.g ? (exists (@[*].x))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 155 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'strict $.g ? ((exists (@[*].x)) is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 156 +--test ternary logic +select + x, y, + jsonb_path_query( + '[true, false, null]', + '$[*] ? (@ == true && ($x == true && $y == true) || + @ == false && !($x == true && $y == true) || + @ == null && ($x == true && $y == true) is unknown)', + jsonb_build_object('x', x, 'y', y) + ) as "x && y" +from + (values (jsonb 'true'), ('false'), ('"null"')) x(x), + (values (jsonb 'true'), ('false'), ('"null"')) y(y) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 157 +select + x, y, + jsonb_path_query( + '[true, false, null]', + '$[*] ? (@ == true && ($x == true || $y == true) || + @ == false && !($x == true || $y == true) || + @ == null && ($x == true || $y == true) is unknown)', + jsonb_build_object('x', x, 'y', y) + ) as "x || y" +from + (values (jsonb 'true'), ('false'), ('"null"')) x(x), + (values (jsonb 'true'), ('false'), ('"null"')) y(y) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +== 158 +select jsonb '{"a": 1, "b":1}' @? '$ ? (@.a == @.b)' +-- +STMT: SelectStmt +== 159 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$ ? (@.a == @.b)' +-- +STMT: SelectStmt +== 160 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.c ? (@.a == @.b)' +-- +STMT: SelectStmt +== 161 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.c ? ($.c.a == @.b)' +-- +STMT: SelectStmt +== 162 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.* ? (@.a == @.b)' +-- +STMT: SelectStmt +== 163 +select jsonb '{"a": 1, "b":1}' @? '$.** ? (@.a == @.b)' +-- +STMT: SelectStmt +== 164 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.** ? (@.a == @.b)' +-- +STMT: SelectStmt +== 165 +select jsonb_path_query('{"c": {"a": 2, "b":1}}', '$.** ? (@.a == 1 + 1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 166 +select jsonb_path_query('{"c": {"a": 2, "b":1}}', '$.** ? (@.a == (1 + 1))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 167 +select jsonb_path_query('{"c": {"a": 2, "b":1}}', '$.** ? (@.a == @.b + 1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 168 +select jsonb_path_query('{"c": {"a": 2, "b":1}}', '$.** ? (@.a == (@.b + 1))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 169 +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == - 1)' +-- +STMT: SelectStmt +== 170 +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == -1)' +-- +STMT: SelectStmt +== 171 +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == -@.b)' +-- +STMT: SelectStmt +== 172 +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == - @.b)' +-- +STMT: SelectStmt +== 173 +select jsonb '{"c": {"a": 0, "b":1}}' @? '$.** ? (@.a == 1 - @.b)' +-- +STMT: SelectStmt +== 174 +select jsonb '{"c": {"a": 2, "b":1}}' @? '$.** ? (@.a == 1 - - @.b)' +-- +STMT: SelectStmt +== 175 +select jsonb '{"c": {"a": 0, "b":1}}' @? '$.** ? (@.a == 1 - +@.b)' +-- +STMT: SelectStmt +== 176 +select jsonb '[1,2,3]' @? '$ ? (+@[*] > +2)' +-- +STMT: SelectStmt +== 177 +select jsonb '[1,2,3]' @? '$ ? (+@[*] > +3)' +-- +STMT: SelectStmt +== 178 +select jsonb '[1,2,3]' @? '$ ? (-@[*] < -2)' +-- +STMT: SelectStmt +== 179 +select jsonb '[1,2,3]' @? '$ ? (-@[*] < -3)' +-- +STMT: SelectStmt +== 180 +select jsonb '1' @? '$ ? ($ > 0)' +-- +STMT: SelectStmt +== 181 +-- arithmetic errors +select jsonb_path_query('[1,2,0,3]', '$[*] ? (2 / @ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 182 +select jsonb_path_query('[1,2,0,3]', '$[*] ? ((2 / @ > 0) is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 183 +select jsonb_path_query('0', '1 / $') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 184 +select jsonb_path_query('0', '1 / $ + 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 185 +select jsonb_path_query('0', '-(3 + 1 % $)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 186 +select jsonb_path_query('1', '$ + "2"') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 187 +select jsonb_path_query('[1, 2]', '3 * $') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 188 +select jsonb_path_query('"a"', '-$') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 189 +select jsonb_path_query('[1,"2",3]', '+$') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 190 +select jsonb_path_query('1', '$ + "2"', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 191 +select jsonb_path_query('[1, 2]', '3 * $', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 192 +select jsonb_path_query('"a"', '-$', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 193 +select jsonb_path_query('[1,"2",3]', '+$', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 194 +select jsonb '["1",2,0,3]' @? '-$[*]' +-- +STMT: SelectStmt +== 195 +select jsonb '[1,"2",0,3]' @? '-$[*]' +-- +STMT: SelectStmt +== 196 +select jsonb '["1",2,0,3]' @? 'strict -$[*]' +-- +STMT: SelectStmt +== 197 +select jsonb '[1,"2",0,3]' @? 'strict -$[*]' +-- +STMT: SelectStmt +== 198 +-- unwrapping of operator arguments in lax mode +select jsonb_path_query('{"a": [2]}', 'lax $.a * 3') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 199 +select jsonb_path_query('{"a": [2]}', 'lax $.a + 3') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 200 +select jsonb_path_query('{"a": [2, 3, 4]}', 'lax -$.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 201 +-- should fail +select jsonb_path_query('{"a": [1, 2]}', 'lax $.a * 3') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 202 +select jsonb_path_query('{"a": [1, 2]}', 'lax $.a * 3', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 203 +-- extension: boolean expressions +select jsonb_path_query('2', '$ > 1') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 204 +select jsonb_path_query('2', '$ <= 1') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 205 +select jsonb_path_query('2', '$ == "2"') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 206 +select jsonb '2' @? '$ == "2"' +-- +STMT: SelectStmt +== 207 +select jsonb '2' @@ '$ > 1' +-- +STMT: SelectStmt +== 208 +select jsonb '2' @@ '$ <= 1' +-- +STMT: SelectStmt +== 209 +select jsonb '2' @@ '$ == "2"' +-- +STMT: SelectStmt +== 210 +select jsonb '2' @@ '1' +-- +STMT: SelectStmt +== 211 +select jsonb '{}' @@ '$' +-- +STMT: SelectStmt +== 212 +select jsonb '[]' @@ '$' +-- +STMT: SelectStmt +== 213 +select jsonb '[1,2,3]' @@ '$[*]' +-- +STMT: SelectStmt +== 214 +select jsonb '[]' @@ '$[*]' +-- +STMT: SelectStmt +== 215 +select jsonb_path_match('[[1, true], [2, false]]', 'strict $[*] ? (@[0] > $x) [1]', '{"x": 1}') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 216 +select jsonb_path_match('[[1, true], [2, false]]', 'strict $[*] ? (@[0] < $x) [1]', '{"x": 2}') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 217 +select jsonb_path_match('[{"a": 1}, {"a": 2}, 3]', 'lax exists($[*].a)', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 218 +select jsonb_path_match('[{"a": 1}, {"a": 2}, 3]', 'lax exists($[*].a)', silent => true) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 219 +select jsonb_path_match('[{"a": 1}, {"a": 2}, 3]', 'strict exists($[*].a)', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 220 +select jsonb_path_match('[{"a": 1}, {"a": 2}, 3]', 'strict exists($[*].a)', silent => true) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 221 +select jsonb_path_query('[null,1,true,"a",[],{}]', '$.type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 222 +select jsonb_path_query('[null,1,true,"a",[],{}]', 'lax $.type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 223 +select jsonb_path_query('[null,1,true,"a",[],{}]', '$[*].type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 224 +select jsonb_path_query('null', 'null.type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 225 +select jsonb_path_query('null', 'true.type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 226 +select jsonb_path_query('null', '(123).type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 227 +select jsonb_path_query('null', '"123".type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 228 +select jsonb_path_query('{"a": 2}', '($.a - 5).abs() + 10') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 229 +select jsonb_path_query('{"a": 2.5}', '-($.a * $.a).floor() % 4.3') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 230 +select jsonb_path_query('[1, 2, 3]', '($[*] > 2) ? (@ == true)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 231 +select jsonb_path_query('[1, 2, 3]', '($[*] > 3).type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 232 +select jsonb_path_query('[1, 2, 3]', '($[*].a > 3).type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 233 +select jsonb_path_query('[1, 2, 3]', 'strict ($[*].a > 3).type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 234 +select jsonb_path_query('[1,null,true,"11",[],[1],[1,2,3],{},{"a":1,"b":2}]', 'strict $[*].size()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 235 +select jsonb_path_query('[1,null,true,"11",[],[1],[1,2,3],{},{"a":1,"b":2}]', 'strict $[*].size()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 236 +select jsonb_path_query('[1,null,true,"11",[],[1],[1,2,3],{},{"a":1,"b":2}]', 'lax $[*].size()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 237 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].abs()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 238 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].floor()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 239 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 240 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling().abs()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 241 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling().abs().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 242 +select jsonb_path_query('[{},1]', '$[*].keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 243 +select jsonb_path_query('[{},1]', '$[*].keyvalue()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 244 +select jsonb_path_query('{}', '$.keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 245 +select jsonb_path_query('{"a": 1, "b": [1, 2], "c": {"a": "bbb"}}', '$.keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 246 +select jsonb_path_query('[{"a": 1, "b": [1, 2]}, {"c": {"a": "bbb"}}]', '$[*].keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 247 +select jsonb_path_query('[{"a": 1, "b": [1, 2]}, {"c": {"a": "bbb"}}]', 'strict $.keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 248 +select jsonb_path_query('[{"a": 1, "b": [1, 2]}, {"c": {"a": "bbb"}}]', 'lax $.keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 249 +select jsonb_path_query('[{"a": 1, "b": [1, 2]}, {"c": {"a": "bbb"}}]', 'strict $.keyvalue().a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 250 +select jsonb '{"a": 1, "b": [1, 2]}' @? 'lax $.keyvalue()' +-- +STMT: SelectStmt +== 251 +select jsonb '{"a": 1, "b": [1, 2]}' @? 'lax $.keyvalue().key' +-- +STMT: SelectStmt +== 252 +select jsonb_path_query('null', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 253 +select jsonb_path_query('true', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 254 +select jsonb_path_query('null', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 255 +select jsonb_path_query('true', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 256 +select jsonb_path_query('[]', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 257 +select jsonb_path_query('[]', 'strict $.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 258 +select jsonb_path_query('{}', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 259 +select jsonb_path_query('[]', 'strict $.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 260 +select jsonb_path_query('{}', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 261 +select jsonb_path_query('1.23', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 262 +select jsonb_path_query('"1.23"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 263 +select jsonb_path_query('"1.23aaa"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 264 +select jsonb_path_query('1e1000', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 265 +select jsonb_path_query('"nan"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 266 +select jsonb_path_query('"NaN"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 267 +select jsonb_path_query('"inf"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 268 +select jsonb_path_query('"-inf"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 269 +select jsonb_path_query('"inf"', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 270 +select jsonb_path_query('"-inf"', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 271 +select jsonb_path_query('{}', '$.abs()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 272 +select jsonb_path_query('true', '$.floor()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 273 +select jsonb_path_query('"1.2"', '$.ceiling()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 274 +select jsonb_path_query('{}', '$.abs()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 275 +select jsonb_path_query('true', '$.floor()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 276 +select jsonb_path_query('"1.2"', '$.ceiling()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 277 +select jsonb_path_query('["", "a", "abc", "abcabc"]', '$[*] ? (@ starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 278 +select jsonb_path_query('["", "a", "abc", "abcabc"]', 'strict $ ? (@[*] starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 279 +select jsonb_path_query('["", "a", "abd", "abdabc"]', 'strict $ ? (@[*] starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 280 +select jsonb_path_query('["abc", "abcabc", null, 1]', 'strict $ ? (@[*] starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 281 +select jsonb_path_query('["abc", "abcabc", null, 1]', 'strict $ ? ((@[*] starts with "abc") is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 282 +select jsonb_path_query('[[null, 1, "abc", "abcabc"]]', 'lax $ ? (@[*] starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 283 +select jsonb_path_query('[[null, 1, "abd", "abdabc"]]', 'lax $ ? ((@[*] starts with "abc") is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 284 +select jsonb_path_query('[null, 1, "abd", "abdabc"]', 'lax $[*] ? ((@ starts with "abc") is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 285 +select jsonb_path_query('[null, 1, "abc", "abd", "aBdC", "abdacb", "babc", "adc\nabc", "ab\nadc"]', 'lax $[*] ? (@ like_regex "^ab.*c")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 286 +select jsonb_path_query('[null, 1, "abc", "abd", "aBdC", "abdacb", "babc", "adc\nabc", "ab\nadc"]', 'lax $[*] ? (@ like_regex "^ab.*c" flag "i")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 287 +select jsonb_path_query('[null, 1, "abc", "abd", "aBdC", "abdacb", "babc", "adc\nabc", "ab\nadc"]', 'lax $[*] ? (@ like_regex "^ab.*c" flag "m")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 288 +select jsonb_path_query('[null, 1, "abc", "abd", "aBdC", "abdacb", "babc", "adc\nabc", "ab\nadc"]', 'lax $[*] ? (@ like_regex "^ab.*c" flag "s")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 289 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "a\\b" flag "q")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 290 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "a\\b" flag "")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 291 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "^a\\b$" flag "q")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 292 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "^a\\B$" flag "q")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 293 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "^a\\B$" flag "iq")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 294 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "^a\\b$" flag "")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 295 +select jsonb_path_query('null', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 296 +select jsonb_path_query('true', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 297 +select jsonb_path_query('1', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 298 +select jsonb_path_query('[]', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 299 +select jsonb_path_query('[]', 'strict $.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 300 +select jsonb_path_query('{}', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 301 +select jsonb_path_query('"bogus"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 302 +select jsonb_path_query('"12:34"', '$.datetime("aaa")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 303 +select jsonb_path_query('"aaaa"', '$.datetime("HH24")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 304 +select jsonb '"10-03-2017"' @? '$.datetime("dd-mm-yyyy")' +-- +STMT: SelectStmt +== 305 +select jsonb_path_query('"10-03-2017"', '$.datetime("dd-mm-yyyy")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 306 +select jsonb_path_query('"10-03-2017"', '$.datetime("dd-mm-yyyy").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 307 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 308 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 309 +select jsonb_path_query('"10-03-2017 12:34"', ' $.datetime("dd-mm-yyyy HH24:MI").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 310 +select jsonb_path_query('"10-03-2017 12:34 +05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 311 +select jsonb_path_query('"12:34:56"', '$.datetime("HH24:MI:SS").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 312 +select jsonb_path_query('"12:34:56 +05:20"', '$.datetime("HH24:MI:SS TZH:TZM").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 313 +select jsonb_path_query('"10-03-2017T12:34:56"', '$.datetime("dd-mm-yyyy\"T\"HH24:MI:SS")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 314 +select jsonb_path_query('"10-03-2017t12:34:56"', '$.datetime("dd-mm-yyyy\"T\"HH24:MI:SS")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 315 +select jsonb_path_query('"10-03-2017 12:34:56"', '$.datetime("dd-mm-yyyy\"T\"HH24:MI:SS")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 316 +-- Test .bigint() +select jsonb_path_query('null', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 317 +select jsonb_path_query('true', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 318 +select jsonb_path_query('null', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 319 +select jsonb_path_query('true', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 320 +select jsonb_path_query('[]', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 321 +select jsonb_path_query('[]', 'strict $.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 322 +select jsonb_path_query('{}', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 323 +select jsonb_path_query('[]', 'strict $.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 324 +select jsonb_path_query('{}', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 325 +select jsonb_path_query('"1.23"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 326 +select jsonb_path_query('"1.23aaa"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 327 +select jsonb_path_query('1e1000', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 328 +select jsonb_path_query('"nan"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 329 +select jsonb_path_query('"NaN"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 330 +select jsonb_path_query('"inf"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 331 +select jsonb_path_query('"-inf"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 332 +select jsonb_path_query('"inf"', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 333 +select jsonb_path_query('"-inf"', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 334 +select jsonb_path_query('123', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 335 +select jsonb_path_query('"123"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 336 +select jsonb_path_query('1.23', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 337 +select jsonb_path_query('1.83', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 338 +select jsonb_path_query('1234567890123', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 339 +select jsonb_path_query('"1234567890123"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 340 +select jsonb_path_query('12345678901234567890', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 341 +select jsonb_path_query('"12345678901234567890"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 342 +select jsonb_path_query('"+123"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 343 +select jsonb_path_query('-123', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 344 +select jsonb_path_query('"-123"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 345 +select jsonb_path_query('123', '$.bigint() * 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 346 +-- Test .boolean() +select jsonb_path_query('null', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 347 +select jsonb_path_query('null', '$.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 348 +select jsonb_path_query('[]', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 349 +select jsonb_path_query('[]', 'strict $.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 350 +select jsonb_path_query('{}', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 351 +select jsonb_path_query('[]', 'strict $.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 352 +select jsonb_path_query('{}', '$.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 353 +select jsonb_path_query('1.23', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 354 +select jsonb_path_query('"1.23"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 355 +select jsonb_path_query('"1.23aaa"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 356 +select jsonb_path_query('1e1000', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 357 +select jsonb_path_query('"nan"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 358 +select jsonb_path_query('"NaN"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 359 +select jsonb_path_query('"inf"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 360 +select jsonb_path_query('"-inf"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 361 +select jsonb_path_query('"inf"', '$.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 362 +select jsonb_path_query('"-inf"', '$.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 363 +select jsonb_path_query('"100"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 364 +select jsonb_path_query('true', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 365 +select jsonb_path_query('false', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 366 +select jsonb_path_query('1', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 367 +select jsonb_path_query('0', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 368 +select jsonb_path_query('-1', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 369 +select jsonb_path_query('100', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 370 +select jsonb_path_query('"1"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 371 +select jsonb_path_query('"0"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 372 +select jsonb_path_query('"true"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 373 +select jsonb_path_query('"false"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 374 +select jsonb_path_query('"TRUE"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 375 +select jsonb_path_query('"FALSE"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 376 +select jsonb_path_query('"yes"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 377 +select jsonb_path_query('"NO"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 378 +select jsonb_path_query('"T"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 379 +select jsonb_path_query('"f"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 380 +select jsonb_path_query('"y"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 381 +select jsonb_path_query('"N"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 382 +select jsonb_path_query('true', '$.boolean().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 383 +select jsonb_path_query('123', '$.boolean().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 384 +select jsonb_path_query('"Yes"', '$.boolean().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 385 +select jsonb_path_query_array('[1, "yes", false]', '$[*].boolean()') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 386 +-- Test .date() +select jsonb_path_query('null', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 387 +select jsonb_path_query('true', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 388 +select jsonb_path_query('1', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 389 +select jsonb_path_query('[]', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 390 +select jsonb_path_query('[]', 'strict $.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 391 +select jsonb_path_query('{}', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 392 +select jsonb_path_query('"bogus"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 393 +select jsonb '"2023-08-15"' @? '$.date()' +-- +STMT: SelectStmt +== 394 +select jsonb_path_query('"2023-08-15"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 395 +select jsonb_path_query('"2023-08-15"', '$.date().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 396 +select jsonb_path_query('"12:34:56"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 397 +select jsonb_path_query('"12:34:56 +05:30"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 398 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 399 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 400 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.date()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 401 +-- should work + +select jsonb_path_query('"2023-08-15"', '$.date(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 402 +-- Test .decimal() +select jsonb_path_query('null', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 403 +select jsonb_path_query('true', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 404 +select jsonb_path_query('null', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 405 +select jsonb_path_query('true', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 406 +select jsonb_path_query('[]', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 407 +select jsonb_path_query('[]', 'strict $.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 408 +select jsonb_path_query('{}', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 409 +select jsonb_path_query('[]', 'strict $.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 410 +select jsonb_path_query('{}', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 411 +select jsonb_path_query('1.23', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 412 +select jsonb_path_query('"1.23"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 413 +select jsonb_path_query('"1.23aaa"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 414 +select jsonb_path_query('1e1000', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 415 +select jsonb_path_query('"nan"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 416 +select jsonb_path_query('"NaN"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 417 +select jsonb_path_query('"inf"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 418 +select jsonb_path_query('"-inf"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 419 +select jsonb_path_query('"inf"', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 420 +select jsonb_path_query('"-inf"', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 421 +select jsonb_path_query('123', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 422 +select jsonb_path_query('"123"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 423 +select jsonb_path_query('12345678901234567890', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 424 +select jsonb_path_query('"12345678901234567890"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 425 +select jsonb_path_query('"+12.3"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 426 +select jsonb_path_query('-12.3', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 427 +select jsonb_path_query('"-12.3"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 428 +select jsonb_path_query('12.3', '$.decimal() * 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 429 +select jsonb_path_query('12345.678', '$.decimal(6, 1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 430 +select jsonb_path_query('12345.678', '$.decimal(6, 2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 431 +select jsonb_path_query('1234.5678', '$.decimal(6, 2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 432 +select jsonb_path_query('12345.678', '$.decimal(4, 6)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 433 +select jsonb_path_query('12345.678', '$.decimal(0, 6)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 434 +select jsonb_path_query('12345.678', '$.decimal(1001, 6)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 435 +select jsonb_path_query('1234.5678', '$.decimal(+6, +2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 436 +select jsonb_path_query('1234.5678', '$.decimal(+6, -2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 437 +select jsonb_path_query('1234.5678', '$.decimal(-6, +2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 438 +select jsonb_path_query('1234.5678', '$.decimal(6, -1001)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 439 +select jsonb_path_query('1234.5678', '$.decimal(6, 1001)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 440 +select jsonb_path_query('-1234.5678', '$.decimal(+6, -2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 441 +select jsonb_path_query('0.0123456', '$.decimal(1,2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 442 +select jsonb_path_query('0.0012345', '$.decimal(2,4)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 443 +select jsonb_path_query('-0.00123456', '$.decimal(2,-4)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 444 +select jsonb_path_query('12.3', '$.decimal(12345678901,1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 445 +select jsonb_path_query('12.3', '$.decimal(1,12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 446 +-- Test .integer() +select jsonb_path_query('null', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 447 +select jsonb_path_query('true', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 448 +select jsonb_path_query('null', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 449 +select jsonb_path_query('true', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 450 +select jsonb_path_query('[]', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 451 +select jsonb_path_query('[]', 'strict $.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 452 +select jsonb_path_query('{}', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 453 +select jsonb_path_query('[]', 'strict $.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 454 +select jsonb_path_query('{}', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 455 +select jsonb_path_query('"1.23"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 456 +select jsonb_path_query('"1.23aaa"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 457 +select jsonb_path_query('1e1000', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 458 +select jsonb_path_query('"nan"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 459 +select jsonb_path_query('"NaN"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 460 +select jsonb_path_query('"inf"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 461 +select jsonb_path_query('"-inf"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 462 +select jsonb_path_query('"inf"', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 463 +select jsonb_path_query('"-inf"', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 464 +select jsonb_path_query('123', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 465 +select jsonb_path_query('"123"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 466 +select jsonb_path_query('1.23', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 467 +select jsonb_path_query('1.83', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 468 +select jsonb_path_query('12345678901', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 469 +select jsonb_path_query('"12345678901"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 470 +select jsonb_path_query('"+123"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 471 +select jsonb_path_query('-123', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 472 +select jsonb_path_query('"-123"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 473 +select jsonb_path_query('123', '$.integer() * 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 474 +-- Test .number() +select jsonb_path_query('null', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 475 +select jsonb_path_query('true', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 476 +select jsonb_path_query('null', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 477 +select jsonb_path_query('true', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 478 +select jsonb_path_query('[]', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 479 +select jsonb_path_query('[]', 'strict $.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 480 +select jsonb_path_query('{}', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 481 +select jsonb_path_query('[]', 'strict $.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 482 +select jsonb_path_query('{}', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 483 +select jsonb_path_query('1.23', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 484 +select jsonb_path_query('"1.23"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 485 +select jsonb_path_query('"1.23aaa"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 486 +select jsonb_path_query('1e1000', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 487 +select jsonb_path_query('"nan"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 488 +select jsonb_path_query('"NaN"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 489 +select jsonb_path_query('"inf"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 490 +select jsonb_path_query('"-inf"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 491 +select jsonb_path_query('"inf"', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 492 +select jsonb_path_query('"-inf"', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 493 +select jsonb_path_query('123', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 494 +select jsonb_path_query('"123"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 495 +select jsonb_path_query('12345678901234567890', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 496 +select jsonb_path_query('"12345678901234567890"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 497 +select jsonb_path_query('"+12.3"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 498 +select jsonb_path_query('-12.3', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 499 +select jsonb_path_query('"-12.3"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 500 +select jsonb_path_query('12.3', '$.number() * 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 501 +-- Test .string() +select jsonb_path_query('null', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 502 +select jsonb_path_query('null', '$.string()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 503 +select jsonb_path_query('[]', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 504 +select jsonb_path_query('[]', 'strict $.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 505 +select jsonb_path_query('{}', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 506 +select jsonb_path_query('[]', 'strict $.string()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 507 +select jsonb_path_query('{}', '$.string()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 508 +select jsonb_path_query('1.23', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 509 +select jsonb_path_query('"1.23"', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 510 +select jsonb_path_query('"1.23aaa"', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 511 +select jsonb_path_query('1234', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 512 +select jsonb_path_query('true', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 513 +select jsonb_path_query('1234', '$.string().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 514 +select jsonb_path_query('[2, true]', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 515 +select jsonb_path_query_array('[1.23, "yes", false]', '$[*].string()') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 516 +select jsonb_path_query_array('[1.23, "yes", false]', '$[*].string().type()') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 517 +select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 518 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 519 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp_tz().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 520 +select jsonb_path_query_tz('"2023-08-15 12:34:56"', '$.timestamp_tz().string()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 521 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp_tz().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 522 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 523 +select jsonb_path_query('"12:34:56 +5:30"', '$.time_tz().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 524 +-- this timetz usage will absorb the UTC offset of the current timezone setting +begin +-- +STMT: TransactionStmt +== 525 +set local timezone = 'UTC-10' +-- +STMT: VariableSetStmt +== 526 +select jsonb_path_query_tz('"12:34:56"', '$.time_tz().string()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 527 +rollback +-- +STMT: TransactionStmt +== 528 +select jsonb_path_query('"12:34:56"', '$.time().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 529 +select jsonb_path_query('"2023-08-15"', '$.date().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 530 +-- .string() does not react to timezone or datestyle +begin +-- +STMT: TransactionStmt +== 531 +set local timezone = 'UTC' +-- +STMT: VariableSetStmt +== 532 +set local datestyle = 'German' +-- +STMT: VariableSetStmt +== 533 +select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp_tz().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 534 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 535 +rollback +-- +STMT: TransactionStmt +== 536 +-- Test .time() +select jsonb_path_query('null', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 537 +select jsonb_path_query('true', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 538 +select jsonb_path_query('1', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 539 +select jsonb_path_query('[]', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 540 +select jsonb_path_query('[]', 'strict $.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 541 +select jsonb_path_query('{}', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 542 +select jsonb_path_query('"bogus"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 543 +select jsonb '"12:34:56"' @? '$.time()' +-- +STMT: SelectStmt +== 544 +select jsonb_path_query('"12:34:56"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 545 +select jsonb_path_query('"12:34:56"', '$.time().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 546 +select jsonb_path_query('"2023-08-15"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 547 +select jsonb_path_query('"12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 548 +select jsonb_path_query_tz('"12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 549 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 550 +select jsonb_path_query('"12:34:56.789"', '$.time(-1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 551 +select jsonb_path_query('"12:34:56.789"', '$.time(2.0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 552 +select jsonb_path_query('"12:34:56.789"', '$.time(12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 553 +select jsonb_path_query('"12:34:56.789"', '$.time(0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 554 +select jsonb_path_query('"12:34:56.789"', '$.time(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 555 +select jsonb_path_query('"12:34:56.789"', '$.time(5)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 556 +select jsonb_path_query('"12:34:56.789"', '$.time(10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 557 +select jsonb_path_query('"12:34:56.789012"', '$.time(8)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 558 +-- Test .time_tz() +select jsonb_path_query('null', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 559 +select jsonb_path_query('true', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 560 +select jsonb_path_query('1', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 561 +select jsonb_path_query('[]', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 562 +select jsonb_path_query('[]', 'strict $.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 563 +select jsonb_path_query('{}', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 564 +select jsonb_path_query('"bogus"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 565 +select jsonb '"12:34:56 +05:30"' @? '$.time_tz()' +-- +STMT: SelectStmt +== 566 +select jsonb_path_query('"12:34:56 +05:30"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 567 +select jsonb_path_query('"12:34:56 +05:30"', '$.time_tz().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 568 +select jsonb_path_query('"2023-08-15"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 569 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 570 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(-1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 571 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(2.0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 572 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 573 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 574 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 575 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(5)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 576 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 577 +select jsonb_path_query('"12:34:56.789012 +05:30"', '$.time_tz(8)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 578 +-- Test .timestamp() +select jsonb_path_query('null', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 579 +select jsonb_path_query('true', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 580 +select jsonb_path_query('1', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 581 +select jsonb_path_query('[]', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 582 +select jsonb_path_query('[]', 'strict $.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 583 +select jsonb_path_query('{}', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 584 +select jsonb_path_query('"bogus"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 585 +select jsonb '"2023-08-15 12:34:56"' @? '$.timestamp()' +-- +STMT: SelectStmt +== 586 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 587 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 588 +select jsonb_path_query('"2023-08-15"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 589 +select jsonb_path_query('"12:34:56"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 590 +select jsonb_path_query('"12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 591 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(-1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 592 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(2.0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 593 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 594 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 595 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 596 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(5)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 597 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 598 +select jsonb_path_query('"2023-08-15 12:34:56.789012"', '$.timestamp(8)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 599 +-- Test .timestamp_tz() +select jsonb_path_query('null', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 600 +select jsonb_path_query('true', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 601 +select jsonb_path_query('1', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 602 +select jsonb_path_query('[]', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 603 +select jsonb_path_query('[]', 'strict $.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 604 +select jsonb_path_query('{}', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 605 +select jsonb_path_query('"bogus"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 606 +select jsonb '"2023-08-15 12:34:56 +05:30"' @? '$.timestamp_tz()' +-- +STMT: SelectStmt +== 607 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 608 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp_tz().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 609 +select jsonb_path_query('"2023-08-15"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 610 +select jsonb_path_query_tz('"2023-08-15"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 611 +-- should work +select jsonb_path_query('"12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 612 +select jsonb_path_query('"12:34:56 +05:30"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 613 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(-1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 614 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(2.0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 615 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 616 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 617 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 618 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(5)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 619 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 620 +select jsonb_path_query('"2023-08-15 12:34:56.789012 +05:30"', '$.timestamp_tz(8)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 621 +set time zone '+00' +-- +STMT: VariableSetStmt +== 622 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 623 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 624 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 625 +select jsonb_path_query('"12:34:56"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 626 +select jsonb_path_query_tz('"12:34:56"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 627 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 628 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 629 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 630 +select jsonb_path_query_tz('"2023-08-15 12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 631 +-- should work + +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy HH24:MI")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 632 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 633 +select jsonb_path_query('"10-03-2017 12:34 +05"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 634 +select jsonb_path_query('"10-03-2017 12:34 -05"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 635 +select jsonb_path_query('"10-03-2017 12:34 +05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 636 +select jsonb_path_query('"10-03-2017 12:34 -05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 637 +select jsonb_path_query('"12:34"', '$.datetime("HH24:MI")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 638 +select jsonb_path_query('"12:34"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 639 +select jsonb_path_query('"12:34 +05"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 640 +select jsonb_path_query('"12:34 -05"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 641 +select jsonb_path_query('"12:34 +05:20"', '$.datetime("HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 642 +select jsonb_path_query('"12:34 -05:20"', '$.datetime("HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 643 +set time zone '+10' +-- +STMT: VariableSetStmt +== 644 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 645 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 646 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 647 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 648 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 649 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 650 +select jsonb_path_query_tz('"2023-08-15 12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 651 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 652 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy HH24:MI")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 653 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 654 +select jsonb_path_query('"10-03-2017 12:34 +05"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 655 +select jsonb_path_query('"10-03-2017 12:34 -05"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 656 +select jsonb_path_query('"10-03-2017 12:34 +05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 657 +select jsonb_path_query('"10-03-2017 12:34 -05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 658 +select jsonb_path_query('"12:34"', '$.datetime("HH24:MI")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 659 +select jsonb_path_query('"12:34"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 660 +select jsonb_path_query('"12:34 +05"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 661 +select jsonb_path_query('"12:34 -05"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 662 +select jsonb_path_query('"12:34 +05:20"', '$.datetime("HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 663 +select jsonb_path_query('"12:34 -05:20"', '$.datetime("HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 664 +set time zone default +-- +STMT: VariableSetStmt +== 665 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 666 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 667 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 668 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 669 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 670 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 671 +select jsonb_path_query('"2017-03-10"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 672 +select jsonb_path_query('"2017-03-10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 673 +select jsonb_path_query('"2017-03-10 12:34:56"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 674 +select jsonb_path_query('"2017-03-10 12:34:56"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 675 +select jsonb_path_query('"2017-03-10 12:34:56+3"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 676 +select jsonb_path_query('"2017-03-10 12:34:56+3"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 677 +select jsonb_path_query('"2017-03-10 12:34:56+3:10"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 678 +select jsonb_path_query('"2017-03-10 12:34:56+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 679 +select jsonb_path_query('"2017-03-10T12:34:56+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 680 +select jsonb_path_query('"2017-03-10t12:34:56+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 681 +select jsonb_path_query('"2017-03-10 12:34:56.789+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 682 +select jsonb_path_query('"2017-03-10T12:34:56.789+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 683 +select jsonb_path_query('"2017-03-10t12:34:56.789+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 684 +select jsonb_path_query('"2017-03-10T12:34:56.789EST"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 685 +select jsonb_path_query('"2017-03-10T12:34:56.789Z"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 686 +select jsonb_path_query('"12:34:56"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 687 +select jsonb_path_query('"12:34:56"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 688 +select jsonb_path_query('"12:34:56+3"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 689 +select jsonb_path_query('"12:34:56+3"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 690 +select jsonb_path_query('"12:34:56+3:10"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 691 +select jsonb_path_query('"12:34:56+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 692 +set time zone '+00' +-- +STMT: VariableSetStmt +== 693 +-- date comparison +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ == "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 694 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ >= "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 695 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ < "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 696 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ == "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 697 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ >= "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 698 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ < "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 699 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ == "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 700 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ >= "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 701 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ < "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 702 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ == "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 703 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ >= "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 704 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ < "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 705 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ == "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 706 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ >= "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 707 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ < "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 708 +-- time comparison +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ == "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 709 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ >= "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 710 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ < "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 711 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ == "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 712 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ >= "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 713 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ < "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 714 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ == "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 715 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ >= "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 716 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ < "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 717 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ == "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 718 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ >= "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 719 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ < "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 720 +select jsonb_path_query( + '["12:34:00.123", "12:35:00.123", "12:36:00.1123", "12:35:00.1123+00", "12:35:00.123+01", "13:35:00.123+01", "2017-03-10 12:35:00.1", "2017-03-10 12:35:00.123+01"]', + '$[*].time(2) ? (@ >= "12:35:00.123".time(2))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 721 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ == "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 722 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ >= "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 723 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ < "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 724 +select jsonb_path_query_tz( + '["12:34:00.123", "12:35:00.123", "12:36:00.1123", "12:35:00.1123+00", "12:35:00.123+01", "13:35:00.123+01", "2017-03-10 12:35:00.1", "2017-03-10 12:35:00.123+01"]', + '$[*].time(2) ? (@ >= "12:35:00.123".time(2))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 725 +-- timetz comparison +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ == "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 726 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ >= "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 727 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ < "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 728 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ == "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 729 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ >= "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 730 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ < "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 731 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ == "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 732 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ >= "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 733 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ < "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 734 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ == "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 735 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ >= "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 736 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ < "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 737 +select jsonb_path_query( + '["12:34:00.123+01", "12:35:00.123+01", "12:36:00.1123+01", "12:35:00.1123+02", "12:35:00.123-02", "10:35:00.123", "11:35:00.1", "12:35:00.123", "2017-03-10 12:35:00.123 +1"]', + '$[*].time_tz(2) ? (@ >= "12:35:00.123 +1".time_tz(2))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 738 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ == "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 739 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ >= "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 740 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ < "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 741 +select jsonb_path_query_tz( + '["12:34:00.123+01", "12:35:00.123+01", "12:36:00.1123+01", "12:35:00.1123+02", "12:35:00.123-02", "10:35:00.123", "11:35:00.1", "12:35:00.123", "2017-03-10 12:35:00.123 +1"]', + '$[*].time_tz(2) ? (@ >= "12:35:00.123 +1".time_tz(2))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 742 +-- timestamp comparison +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ == "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 743 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ >= "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 744 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ < "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 745 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ == "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 746 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ >= "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 747 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ < "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 748 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ == "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 749 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ >= "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 750 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ < "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 751 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ == "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 752 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ >= "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 753 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ < "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 754 +select jsonb_path_query( + '["2017-03-10 12:34:00.123", "2017-03-10 12:35:00.123", "2017-03-10 12:36:00.1123", "2017-03-10 12:35:00.1123+01", "2017-03-10 13:35:00.123+01", "2017-03-10 12:35:00.1-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp(2) ? (@ >= "2017-03-10 12:35:00.123".timestamp(2))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 755 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ == "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 756 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ >= "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 757 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ < "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 758 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00.123", "2017-03-10 12:35:00.123", "2017-03-10 12:36:00.1123", "2017-03-10 12:35:00.1123+01", "2017-03-10 13:35:00.123+01", "2017-03-10 12:35:00.1-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp(2) ? (@ >= "2017-03-10 12:35:00.123".timestamp(2))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 759 +-- timestamptz comparison +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ == "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 760 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ >= "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 761 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ < "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 762 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ == "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 763 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ >= "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 764 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ < "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 765 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ == "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 766 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ >= "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 767 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ < "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 768 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ == "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 769 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ >= "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 770 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ < "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 771 +select jsonb_path_query( + '["2017-03-10 12:34:00.123+01", "2017-03-10 12:35:00.123+01", "2017-03-10 12:36:00.1123+01", "2017-03-10 12:35:00.1123+02", "2017-03-10 12:35:00.123-02", "2017-03-10 10:35:00.123", "2017-03-10 11:35:00.1", "2017-03-10 12:35:00.123", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz(2) ? (@ >= "2017-03-10 12:35:00.123 +1".timestamp_tz(2))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 772 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ == "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 773 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ >= "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 774 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ < "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 775 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00.123+01", "2017-03-10 12:35:00.123+01", "2017-03-10 12:36:00.1123+01", "2017-03-10 12:35:00.1123+02", "2017-03-10 12:35:00.123-02", "2017-03-10 10:35:00.123", "2017-03-10 11:35:00.1", "2017-03-10 12:35:00.123", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz(2) ? (@ >= "2017-03-10 12:35:00.123 +1".timestamp_tz(2))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +== 776 +-- overflow during comparison +select jsonb_path_query('"1000000-01-01"', '$.datetime() > "2020-01-01 12:00:00".datetime()'::jsonpath) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 777 +set time zone default +-- +STMT: VariableSetStmt +== 778 +-- jsonpath operators + +SELECT jsonb_path_query('[{"a": 1}, {"a": 2}]', '$[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 779 +SELECT jsonb_path_query('[{"a": 1}, {"a": 2}]', '$[*] ? (@.a > 10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 780 +SELECT jsonb_path_query('[{"a": 1}]', '$undefined_var') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 781 +SELECT jsonb_path_query('[{"a": 1}]', 'false') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +== 782 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}, {}]', 'strict $[*].a') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 783 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}]', '$[*].a') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 784 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ == 1)') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 785 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ > 10)') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 786 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].a ? (@ > $min && @ < $max)', vars => '{"min": 1, "max": 4}') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 787 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].a ? (@ > $min && @ < $max)', vars => '{"min": 3, "max": 4}') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +== 788 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {}]', 'strict $[*].a') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 789 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {}]', 'strict $[*].a', silent => true) +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 790 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}]', '$[*].a') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 791 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ == 1)') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 792 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ > 10)') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 793 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].a ? (@ > $min && @ < $max)', vars => '{"min": 1, "max": 4}') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 794 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].a ? (@ > $min && @ < $max)', vars => '{"min": 3, "max": 4}') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 795 +SELECT jsonb_path_query_first('[{"a": 1}]', '$undefined_var') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 796 +SELECT jsonb_path_query_first('[{"a": 1}]', 'false') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +== 797 +SELECT jsonb '[{"a": 1}, {"a": 2}]' @? '$[*].a ? (@ > 1)' +-- +STMT: SelectStmt +== 798 +SELECT jsonb '[{"a": 1}, {"a": 2}]' @? '$[*] ? (@.a > 2)' +-- +STMT: SelectStmt +== 799 +SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ > 1)') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 800 +SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*] ? (@.a > $min && @.a < $max)', vars => '{"min": 1, "max": 4}') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 801 +SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*] ? (@.a > $min && @.a < $max)', vars => '{"min": 3, "max": 4}') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 802 +SELECT jsonb_path_exists('[{"a": 1}]', '$undefined_var') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 803 +SELECT jsonb_path_exists('[{"a": 1}]', 'false') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +== 804 +SELECT jsonb_path_match('true', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 805 +SELECT jsonb_path_match('false', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 806 +SELECT jsonb_path_match('null', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 807 +SELECT jsonb_path_match('1', '$', silent => true) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 808 +SELECT jsonb_path_match('1', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 809 +SELECT jsonb_path_match('"a"', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 810 +SELECT jsonb_path_match('{}', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 811 +SELECT jsonb_path_match('[true]', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 812 +SELECT jsonb_path_match('{}', 'lax $.a', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 813 +SELECT jsonb_path_match('{}', 'strict $.a', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 814 +SELECT jsonb_path_match('{}', 'strict $.a', silent => true) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 815 +SELECT jsonb_path_match('[true, true]', '$[*]', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 816 +SELECT jsonb '[{"a": 1}, {"a": 2}]' @@ '$[*].a > 1' +-- +STMT: SelectStmt +== 817 +SELECT jsonb '[{"a": 1}, {"a": 2}]' @@ '$[*].a > 2' +-- +STMT: SelectStmt +== 818 +SELECT jsonb_path_match('[{"a": 1}, {"a": 2}]', '$[*].a > 1') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 819 +SELECT jsonb_path_match('[{"a": 1}]', '$undefined_var') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 820 +SELECT jsonb_path_match('[{"a": 1}]', 'false') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +== 821 +-- test string comparison (Unicode codepoint collation) +WITH str(j, num) AS +( + SELECT jsonb_build_object('s', s), num + FROM unnest('{"", "a", "ab", "abc", "abcd", "b", "A", "AB", "ABC", "ABc", "ABcD", "B"}'::text[]) WITH ORDINALITY AS a(s, num) +) +SELECT + s1.j, s2.j, + jsonb_path_query_first(s1.j, '$.s < $s', vars => s2.j) lt, + jsonb_path_query_first(s1.j, '$.s <= $s', vars => s2.j) le, + jsonb_path_query_first(s1.j, '$.s == $s', vars => s2.j) eq, + jsonb_path_query_first(s1.j, '$.s >= $s', vars => s2.j) ge, + jsonb_path_query_first(s1.j, '$.s > $s', vars => s2.j) gt +FROM str s1, str s2 +ORDER BY s1.num, s2.num +-- +ALIAS: "s1"="str" +ALIAS: "s2"="str" +CTE: "str" +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/jsonpath.metadata.json b/parser/testdata/summary/postgres_regress/jsonpath.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/jsonpath.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/jsonpath.test b/parser/testdata/summary/postgres_regress/jsonpath.test new file mode 100644 index 0000000..a67af69 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/jsonpath.test @@ -0,0 +1,923 @@ +== 001 +--jsonpath io + +select ''::jsonpath +-- +STMT: SelectStmt +== 002 +select '$'::jsonpath +-- +STMT: SelectStmt +== 003 +select 'strict $'::jsonpath +-- +STMT: SelectStmt +== 004 +select 'lax $'::jsonpath +-- +STMT: SelectStmt +== 005 +select '$.a'::jsonpath +-- +STMT: SelectStmt +== 006 +select '$.a.v'::jsonpath +-- +STMT: SelectStmt +== 007 +select '$.a.*'::jsonpath +-- +STMT: SelectStmt +== 008 +select '$.*[*]'::jsonpath +-- +STMT: SelectStmt +== 009 +select '$.a[*]'::jsonpath +-- +STMT: SelectStmt +== 010 +select '$.a[*][*]'::jsonpath +-- +STMT: SelectStmt +== 011 +select '$[*]'::jsonpath +-- +STMT: SelectStmt +== 012 +select '$[0]'::jsonpath +-- +STMT: SelectStmt +== 013 +select '$[*][0]'::jsonpath +-- +STMT: SelectStmt +== 014 +select '$[*].a'::jsonpath +-- +STMT: SelectStmt +== 015 +select '$[*][0].a.b'::jsonpath +-- +STMT: SelectStmt +== 016 +select '$.a.**.b'::jsonpath +-- +STMT: SelectStmt +== 017 +select '$.a.**{2}.b'::jsonpath +-- +STMT: SelectStmt +== 018 +select '$.a.**{2 to 2}.b'::jsonpath +-- +STMT: SelectStmt +== 019 +select '$.a.**{2 to 5}.b'::jsonpath +-- +STMT: SelectStmt +== 020 +select '$.a.**{0 to 5}.b'::jsonpath +-- +STMT: SelectStmt +== 021 +select '$.a.**{5 to last}.b'::jsonpath +-- +STMT: SelectStmt +== 022 +select '$.a.**{last}.b'::jsonpath +-- +STMT: SelectStmt +== 023 +select '$.a.**{last to 5}.b'::jsonpath +-- +STMT: SelectStmt +== 024 +select '$+1'::jsonpath +-- +STMT: SelectStmt +== 025 +select '$-1'::jsonpath +-- +STMT: SelectStmt +== 026 +select '$--+1'::jsonpath +-- +STMT: SelectStmt +== 027 +select '$.a/+-1'::jsonpath +-- +STMT: SelectStmt +== 028 +select '1 * 2 + 4 % -3 != false'::jsonpath +-- +STMT: SelectStmt +== 029 +select '"\b\f\r\n\t\v\"\''\\"'::jsonpath +-- +STMT: SelectStmt +== 030 +select '"\x50\u0067\u{53}\u{051}\u{00004C}"'::jsonpath +-- +STMT: SelectStmt +== 031 +select '$.foo\x50\u0067\u{53}\u{051}\u{00004C}\t\"bar'::jsonpath +-- +STMT: SelectStmt +== 032 +select '"\z"'::jsonpath +-- +STMT: SelectStmt +== 033 +-- unrecognized escape is just the literal char + +select '$.g ? ($.a == 1)'::jsonpath +-- +STMT: SelectStmt +== 034 +select '$.g ? (@ == 1)'::jsonpath +-- +STMT: SelectStmt +== 035 +select '$.g ? (@.a == 1)'::jsonpath +-- +STMT: SelectStmt +== 036 +select '$.g ? (@.a == 1 || @.a == 4)'::jsonpath +-- +STMT: SelectStmt +== 037 +select '$.g ? (@.a == 1 && @.a == 4)'::jsonpath +-- +STMT: SelectStmt +== 038 +select '$.g ? (@.a == 1 || @.a == 4 && @.b == 7)'::jsonpath +-- +STMT: SelectStmt +== 039 +select '$.g ? (@.a == 1 || !(@.a == 4) && @.b == 7)'::jsonpath +-- +STMT: SelectStmt +== 040 +select '$.g ? (@.a == 1 || !(@.x >= 123 || @.a == 4) && @.b == 7)'::jsonpath +-- +STMT: SelectStmt +== 041 +select '$.g ? (@.x >= @[*]?(@.a > "abc"))'::jsonpath +-- +STMT: SelectStmt +== 042 +select '$.g ? ((@.x >= 123 || @.a == 4) is unknown)'::jsonpath +-- +STMT: SelectStmt +== 043 +select '$.g ? (exists (@.x))'::jsonpath +-- +STMT: SelectStmt +== 044 +select '$.g ? (exists (@.x ? (@ == 14)))'::jsonpath +-- +STMT: SelectStmt +== 045 +select '$.g ? ((@.x >= 123 || @.a == 4) && exists (@.x ? (@ == 14)))'::jsonpath +-- +STMT: SelectStmt +== 046 +select '$.g ? (+@.x >= +-(+@.a + 2))'::jsonpath +-- +STMT: SelectStmt +== 047 +select '$a'::jsonpath +-- +STMT: SelectStmt +== 048 +select '$a.b'::jsonpath +-- +STMT: SelectStmt +== 049 +select '$a[*]'::jsonpath +-- +STMT: SelectStmt +== 050 +select '$.g ? (@.zip == $zip)'::jsonpath +-- +STMT: SelectStmt +== 051 +select '$.a[1,2, 3 to 16]'::jsonpath +-- +STMT: SelectStmt +== 052 +select '$.a[$a + 1, ($b[*]) to -($[0] * 2)]'::jsonpath +-- +STMT: SelectStmt +== 053 +select '$.a[$.a.size() - 3]'::jsonpath +-- +STMT: SelectStmt +== 054 +select 'last'::jsonpath +-- +STMT: SelectStmt +== 055 +select '"last"'::jsonpath +-- +STMT: SelectStmt +== 056 +select '$.last'::jsonpath +-- +STMT: SelectStmt +== 057 +select '$ ? (last > 0)'::jsonpath +-- +STMT: SelectStmt +== 058 +select '$[last]'::jsonpath +-- +STMT: SelectStmt +== 059 +select '$[$[0] ? (last > 0)]'::jsonpath +-- +STMT: SelectStmt +== 060 +select 'null.type()'::jsonpath +-- +STMT: SelectStmt +== 061 +select '1.type()'::jsonpath +-- +STMT: SelectStmt +== 062 +select '(1).type()'::jsonpath +-- +STMT: SelectStmt +== 063 +select '1.2.type()'::jsonpath +-- +STMT: SelectStmt +== 064 +select '"aaa".type()'::jsonpath +-- +STMT: SelectStmt +== 065 +select 'true.type()'::jsonpath +-- +STMT: SelectStmt +== 066 +select '$.double().floor().ceiling().abs()'::jsonpath +-- +STMT: SelectStmt +== 067 +select '$.keyvalue().key'::jsonpath +-- +STMT: SelectStmt +== 068 +select '$.datetime()'::jsonpath +-- +STMT: SelectStmt +== 069 +select '$.datetime("datetime template")'::jsonpath +-- +STMT: SelectStmt +== 070 +select '$.bigint().integer().number().decimal()'::jsonpath +-- +STMT: SelectStmt +== 071 +select '$.boolean()'::jsonpath +-- +STMT: SelectStmt +== 072 +select '$.date()'::jsonpath +-- +STMT: SelectStmt +== 073 +select '$.decimal(4,2)'::jsonpath +-- +STMT: SelectStmt +== 074 +select '$.string()'::jsonpath +-- +STMT: SelectStmt +== 075 +select '$.time()'::jsonpath +-- +STMT: SelectStmt +== 076 +select '$.time(6)'::jsonpath +-- +STMT: SelectStmt +== 077 +select '$.time_tz()'::jsonpath +-- +STMT: SelectStmt +== 078 +select '$.time_tz(4)'::jsonpath +-- +STMT: SelectStmt +== 079 +select '$.timestamp()'::jsonpath +-- +STMT: SelectStmt +== 080 +select '$.timestamp(2)'::jsonpath +-- +STMT: SelectStmt +== 081 +select '$.timestamp_tz()'::jsonpath +-- +STMT: SelectStmt +== 082 +select '$.timestamp_tz(0)'::jsonpath +-- +STMT: SelectStmt +== 083 +select '$ ? (@ starts with "abc")'::jsonpath +-- +STMT: SelectStmt +== 084 +select '$ ? (@ starts with $var)'::jsonpath +-- +STMT: SelectStmt +== 085 +select '$ ? (@ like_regex "(invalid pattern")'::jsonpath +-- +STMT: SelectStmt +== 086 +select '$ ? (@ like_regex "pattern")'::jsonpath +-- +STMT: SelectStmt +== 087 +select '$ ? (@ like_regex "pattern" flag "")'::jsonpath +-- +STMT: SelectStmt +== 088 +select '$ ? (@ like_regex "pattern" flag "i")'::jsonpath +-- +STMT: SelectStmt +== 089 +select '$ ? (@ like_regex "pattern" flag "is")'::jsonpath +-- +STMT: SelectStmt +== 090 +select '$ ? (@ like_regex "pattern" flag "isim")'::jsonpath +-- +STMT: SelectStmt +== 091 +select '$ ? (@ like_regex "pattern" flag "xsms")'::jsonpath +-- +STMT: SelectStmt +== 092 +select '$ ? (@ like_regex "pattern" flag "q")'::jsonpath +-- +STMT: SelectStmt +== 093 +select '$ ? (@ like_regex "pattern" flag "iq")'::jsonpath +-- +STMT: SelectStmt +== 094 +select '$ ? (@ like_regex "pattern" flag "smixq")'::jsonpath +-- +STMT: SelectStmt +== 095 +select '$ ? (@ like_regex "pattern" flag "a")'::jsonpath +-- +STMT: SelectStmt +== 096 +select '$ < 1'::jsonpath +-- +STMT: SelectStmt +== 097 +select '($ < 1) || $.a.b <= $x'::jsonpath +-- +STMT: SelectStmt +== 098 +select '@ + 1'::jsonpath +-- +STMT: SelectStmt +== 099 +select '($).a.b'::jsonpath +-- +STMT: SelectStmt +== 100 +select '($.a.b).c.d'::jsonpath +-- +STMT: SelectStmt +== 101 +select '($.a.b + -$.x.y).c.d'::jsonpath +-- +STMT: SelectStmt +== 102 +select '(-+$.a.b).c.d'::jsonpath +-- +STMT: SelectStmt +== 103 +select '1 + ($.a.b + 2).c.d'::jsonpath +-- +STMT: SelectStmt +== 104 +select '1 + ($.a.b > 2).c.d'::jsonpath +-- +STMT: SelectStmt +== 105 +select '($)'::jsonpath +-- +STMT: SelectStmt +== 106 +select '(($))'::jsonpath +-- +STMT: SelectStmt +== 107 +select '((($ + 1)).a + ((2)).b ? ((((@ > 1)) || (exists(@.c)))))'::jsonpath +-- +STMT: SelectStmt +== 108 +select '$ ? (@.a < 1)'::jsonpath +-- +STMT: SelectStmt +== 109 +select '$ ? (@.a < -1)'::jsonpath +-- +STMT: SelectStmt +== 110 +select '$ ? (@.a < +1)'::jsonpath +-- +STMT: SelectStmt +== 111 +select '$ ? (@.a < .1)'::jsonpath +-- +STMT: SelectStmt +== 112 +select '$ ? (@.a < -.1)'::jsonpath +-- +STMT: SelectStmt +== 113 +select '$ ? (@.a < +.1)'::jsonpath +-- +STMT: SelectStmt +== 114 +select '$ ? (@.a < 0.1)'::jsonpath +-- +STMT: SelectStmt +== 115 +select '$ ? (@.a < -0.1)'::jsonpath +-- +STMT: SelectStmt +== 116 +select '$ ? (@.a < +0.1)'::jsonpath +-- +STMT: SelectStmt +== 117 +select '$ ? (@.a < 10.1)'::jsonpath +-- +STMT: SelectStmt +== 118 +select '$ ? (@.a < -10.1)'::jsonpath +-- +STMT: SelectStmt +== 119 +select '$ ? (@.a < +10.1)'::jsonpath +-- +STMT: SelectStmt +== 120 +select '$ ? (@.a < 1e1)'::jsonpath +-- +STMT: SelectStmt +== 121 +select '$ ? (@.a < -1e1)'::jsonpath +-- +STMT: SelectStmt +== 122 +select '$ ? (@.a < +1e1)'::jsonpath +-- +STMT: SelectStmt +== 123 +select '$ ? (@.a < .1e1)'::jsonpath +-- +STMT: SelectStmt +== 124 +select '$ ? (@.a < -.1e1)'::jsonpath +-- +STMT: SelectStmt +== 125 +select '$ ? (@.a < +.1e1)'::jsonpath +-- +STMT: SelectStmt +== 126 +select '$ ? (@.a < 0.1e1)'::jsonpath +-- +STMT: SelectStmt +== 127 +select '$ ? (@.a < -0.1e1)'::jsonpath +-- +STMT: SelectStmt +== 128 +select '$ ? (@.a < +0.1e1)'::jsonpath +-- +STMT: SelectStmt +== 129 +select '$ ? (@.a < 10.1e1)'::jsonpath +-- +STMT: SelectStmt +== 130 +select '$ ? (@.a < -10.1e1)'::jsonpath +-- +STMT: SelectStmt +== 131 +select '$ ? (@.a < +10.1e1)'::jsonpath +-- +STMT: SelectStmt +== 132 +select '$ ? (@.a < 1e-1)'::jsonpath +-- +STMT: SelectStmt +== 133 +select '$ ? (@.a < -1e-1)'::jsonpath +-- +STMT: SelectStmt +== 134 +select '$ ? (@.a < +1e-1)'::jsonpath +-- +STMT: SelectStmt +== 135 +select '$ ? (@.a < .1e-1)'::jsonpath +-- +STMT: SelectStmt +== 136 +select '$ ? (@.a < -.1e-1)'::jsonpath +-- +STMT: SelectStmt +== 137 +select '$ ? (@.a < +.1e-1)'::jsonpath +-- +STMT: SelectStmt +== 138 +select '$ ? (@.a < 0.1e-1)'::jsonpath +-- +STMT: SelectStmt +== 139 +select '$ ? (@.a < -0.1e-1)'::jsonpath +-- +STMT: SelectStmt +== 140 +select '$ ? (@.a < +0.1e-1)'::jsonpath +-- +STMT: SelectStmt +== 141 +select '$ ? (@.a < 10.1e-1)'::jsonpath +-- +STMT: SelectStmt +== 142 +select '$ ? (@.a < -10.1e-1)'::jsonpath +-- +STMT: SelectStmt +== 143 +select '$ ? (@.a < +10.1e-1)'::jsonpath +-- +STMT: SelectStmt +== 144 +select '$ ? (@.a < 1e+1)'::jsonpath +-- +STMT: SelectStmt +== 145 +select '$ ? (@.a < -1e+1)'::jsonpath +-- +STMT: SelectStmt +== 146 +select '$ ? (@.a < +1e+1)'::jsonpath +-- +STMT: SelectStmt +== 147 +select '$ ? (@.a < .1e+1)'::jsonpath +-- +STMT: SelectStmt +== 148 +select '$ ? (@.a < -.1e+1)'::jsonpath +-- +STMT: SelectStmt +== 149 +select '$ ? (@.a < +.1e+1)'::jsonpath +-- +STMT: SelectStmt +== 150 +select '$ ? (@.a < 0.1e+1)'::jsonpath +-- +STMT: SelectStmt +== 151 +select '$ ? (@.a < -0.1e+1)'::jsonpath +-- +STMT: SelectStmt +== 152 +select '$ ? (@.a < +0.1e+1)'::jsonpath +-- +STMT: SelectStmt +== 153 +select '$ ? (@.a < 10.1e+1)'::jsonpath +-- +STMT: SelectStmt +== 154 +select '$ ? (@.a < -10.1e+1)'::jsonpath +-- +STMT: SelectStmt +== 155 +select '$ ? (@.a < +10.1e+1)'::jsonpath +-- +STMT: SelectStmt +== 156 +-- numeric literals + +select '0'::jsonpath +-- +STMT: SelectStmt +== 157 +select '00'::jsonpath +-- +STMT: SelectStmt +== 158 +select '0755'::jsonpath +-- +STMT: SelectStmt +== 159 +select '0.0'::jsonpath +-- +STMT: SelectStmt +== 160 +select '0.000'::jsonpath +-- +STMT: SelectStmt +== 161 +select '0.000e1'::jsonpath +-- +STMT: SelectStmt +== 162 +select '0.000e2'::jsonpath +-- +STMT: SelectStmt +== 163 +select '0.000e3'::jsonpath +-- +STMT: SelectStmt +== 164 +select '0.0010'::jsonpath +-- +STMT: SelectStmt +== 165 +select '0.0010e-1'::jsonpath +-- +STMT: SelectStmt +== 166 +select '0.0010e+1'::jsonpath +-- +STMT: SelectStmt +== 167 +select '0.0010e+2'::jsonpath +-- +STMT: SelectStmt +== 168 +select '.001'::jsonpath +-- +STMT: SelectStmt +== 169 +select '.001e1'::jsonpath +-- +STMT: SelectStmt +== 170 +select '1.'::jsonpath +-- +STMT: SelectStmt +== 171 +select '1.e1'::jsonpath +-- +STMT: SelectStmt +== 172 +select '1a'::jsonpath +-- +STMT: SelectStmt +== 173 +select '1e'::jsonpath +-- +STMT: SelectStmt +== 174 +select '1.e'::jsonpath +-- +STMT: SelectStmt +== 175 +select '1.2a'::jsonpath +-- +STMT: SelectStmt +== 176 +select '1.2e'::jsonpath +-- +STMT: SelectStmt +== 177 +select '1.2.e'::jsonpath +-- +STMT: SelectStmt +== 178 +select '(1.2).e'::jsonpath +-- +STMT: SelectStmt +== 179 +select '1e3'::jsonpath +-- +STMT: SelectStmt +== 180 +select '1.e3'::jsonpath +-- +STMT: SelectStmt +== 181 +select '1.e3.e'::jsonpath +-- +STMT: SelectStmt +== 182 +select '1.e3.e4'::jsonpath +-- +STMT: SelectStmt +== 183 +select '1.2e3'::jsonpath +-- +STMT: SelectStmt +== 184 +select '1.2e3a'::jsonpath +-- +STMT: SelectStmt +== 185 +select '1.2.e3'::jsonpath +-- +STMT: SelectStmt +== 186 +select '(1.2).e3'::jsonpath +-- +STMT: SelectStmt +== 187 +select '1..e'::jsonpath +-- +STMT: SelectStmt +== 188 +select '1..e3'::jsonpath +-- +STMT: SelectStmt +== 189 +select '(1.).e'::jsonpath +-- +STMT: SelectStmt +== 190 +select '(1.).e3'::jsonpath +-- +STMT: SelectStmt +== 191 +select '1?(2>3)'::jsonpath +-- +STMT: SelectStmt +== 192 +-- nondecimal +select '0b100101'::jsonpath +-- +STMT: SelectStmt +== 193 +select '0o273'::jsonpath +-- +STMT: SelectStmt +== 194 +select '0x42F'::jsonpath +-- +STMT: SelectStmt +== 195 +-- error cases +select '0b'::jsonpath +-- +STMT: SelectStmt +== 196 +select '1b'::jsonpath +-- +STMT: SelectStmt +== 197 +select '0b0x'::jsonpath +-- +STMT: SelectStmt +== 198 +select '0o'::jsonpath +-- +STMT: SelectStmt +== 199 +select '1o'::jsonpath +-- +STMT: SelectStmt +== 200 +select '0o0x'::jsonpath +-- +STMT: SelectStmt +== 201 +select '0x'::jsonpath +-- +STMT: SelectStmt +== 202 +select '1x'::jsonpath +-- +STMT: SelectStmt +== 203 +select '0x0y'::jsonpath +-- +STMT: SelectStmt +== 204 +-- underscores +select '1_000_000'::jsonpath +-- +STMT: SelectStmt +== 205 +select '1_2_3'::jsonpath +-- +STMT: SelectStmt +== 206 +select '0x1EEE_FFFF'::jsonpath +-- +STMT: SelectStmt +== 207 +select '0o2_73'::jsonpath +-- +STMT: SelectStmt +== 208 +select '0b10_0101'::jsonpath +-- +STMT: SelectStmt +== 209 +select '1_000.000_005'::jsonpath +-- +STMT: SelectStmt +== 210 +select '1_000.'::jsonpath +-- +STMT: SelectStmt +== 211 +select '.000_005'::jsonpath +-- +STMT: SelectStmt +== 212 +select '1_000.5e0_1'::jsonpath +-- +STMT: SelectStmt +== 213 +-- error cases +select '_100'::jsonpath +-- +STMT: SelectStmt +== 214 +select '100_'::jsonpath +-- +STMT: SelectStmt +== 215 +select '100__000'::jsonpath +-- +STMT: SelectStmt +== 216 +select '_1_000.5'::jsonpath +-- +STMT: SelectStmt +== 217 +select '1_000_.5'::jsonpath +-- +STMT: SelectStmt +== 218 +select '1_000._5'::jsonpath +-- +STMT: SelectStmt +== 219 +select '1_000.5_'::jsonpath +-- +STMT: SelectStmt +== 220 +select '1_000.5e_1'::jsonpath +-- +STMT: SelectStmt +== 221 +-- underscore after prefix not allowed in JavaScript (but allowed in SQL) +select '0b_10_0101'::jsonpath +-- +STMT: SelectStmt +== 222 +select '0o_273'::jsonpath +-- +STMT: SelectStmt +== 223 +select '0x_42F'::jsonpath +-- +STMT: SelectStmt +== 224 +-- test non-error-throwing API + +SELECT str as jsonpath, + pg_input_is_valid(str,'jsonpath') as ok, + errinfo.sql_error_code, + errinfo.message, + errinfo.detail, + errinfo.hint +FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text, + '$ ? (@ like_regex "pattern" flag "a")', + '@ + 1', + '00', + '1a']) str, + LATERAL pg_input_error_info(str, 'jsonpath') as errinfo +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/jsonpath_encoding.metadata.json b/parser/testdata/summary/postgres_regress/jsonpath_encoding.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/jsonpath_encoding.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/jsonpath_encoding.test b/parser/testdata/summary/postgres_regress/jsonpath_encoding.test new file mode 100644 index 0000000..40034d2 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/jsonpath_encoding.test @@ -0,0 +1,171 @@ +== 001 +|-- +-- encoding-sensitive tests for jsonpath +|-- + +-- We provide expected-results files for UTF8 (jsonpath_encoding.out) +-- and for SQL_ASCII (jsonpath_encoding_1.out). Skip otherwise. +SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') + AS skip_test +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +== 002 +SELECT getdatabaseencoding() +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +== 003 +-- just to label the results files + +-- checks for double-quoted values + +-- basic unicode input +SELECT '"\u"'::jsonpath +-- +STMT: SelectStmt +== 004 +-- ERROR, incomplete escape +SELECT '"\u00"'::jsonpath +-- +STMT: SelectStmt +== 005 +-- ERROR, incomplete escape +SELECT '"\u000g"'::jsonpath +-- +STMT: SelectStmt +== 006 +-- ERROR, g is not a hex digit +SELECT '"\u0000"'::jsonpath +-- +STMT: SelectStmt +== 007 +-- OK, legal escape +SELECT '"\uaBcD"'::jsonpath +-- +STMT: SelectStmt +== 008 +-- OK, uppercase and lower case both OK + +-- handling of unicode surrogate pairs +select '"\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8 +-- +STMT: SelectStmt +== 009 +select '"\ud83d\ud83d"'::jsonpath +-- +STMT: SelectStmt +== 010 +-- 2 high surrogates in a row +select '"\ude04\ud83d"'::jsonpath +-- +STMT: SelectStmt +== 011 +-- surrogates in wrong order +select '"\ud83dX"'::jsonpath +-- +STMT: SelectStmt +== 012 +-- orphan high surrogate +select '"\ude04X"'::jsonpath +-- +STMT: SelectStmt +== 013 +-- orphan low surrogate + +--handling of simple unicode escapes +select '"the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8 +-- +STMT: SelectStmt +== 014 +select '"dollar \u0024 character"'::jsonpath as correct_everywhere +-- +STMT: SelectStmt +== 015 +select '"dollar \\u0024 character"'::jsonpath as not_an_escape +-- +STMT: SelectStmt +== 016 +select '"null \u0000 escape"'::jsonpath as not_unescaped +-- +STMT: SelectStmt +== 017 +select '"null \\u0000 escape"'::jsonpath as not_an_escape +-- +STMT: SelectStmt +== 018 +-- checks for quoted key names + +-- basic unicode input +SELECT '$."\u"'::jsonpath +-- +STMT: SelectStmt +== 019 +-- ERROR, incomplete escape +SELECT '$."\u00"'::jsonpath +-- +STMT: SelectStmt +== 020 +-- ERROR, incomplete escape +SELECT '$."\u000g"'::jsonpath +-- +STMT: SelectStmt +== 021 +-- ERROR, g is not a hex digit +SELECT '$."\u0000"'::jsonpath +-- +STMT: SelectStmt +== 022 +-- OK, legal escape +SELECT '$."\uaBcD"'::jsonpath +-- +STMT: SelectStmt +== 023 +-- OK, uppercase and lower case both OK + +-- handling of unicode surrogate pairs +select '$."\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8 +-- +STMT: SelectStmt +== 024 +select '$."\ud83d\ud83d"'::jsonpath +-- +STMT: SelectStmt +== 025 +-- 2 high surrogates in a row +select '$."\ude04\ud83d"'::jsonpath +-- +STMT: SelectStmt +== 026 +-- surrogates in wrong order +select '$."\ud83dX"'::jsonpath +-- +STMT: SelectStmt +== 027 +-- orphan high surrogate +select '$."\ude04X"'::jsonpath +-- +STMT: SelectStmt +== 028 +-- orphan low surrogate + +--handling of simple unicode escapes +select '$."the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8 +-- +STMT: SelectStmt +== 029 +select '$."dollar \u0024 character"'::jsonpath as correct_everywhere +-- +STMT: SelectStmt +== 030 +select '$."dollar \\u0024 character"'::jsonpath as not_an_escape +-- +STMT: SelectStmt +== 031 +select '$."null \u0000 escape"'::jsonpath as not_unescaped +-- +STMT: SelectStmt +== 032 +select '$."null \\u0000 escape"'::jsonpath as not_an_escape +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/largeobject.metadata.json b/parser/testdata/summary/postgres_regress/largeobject.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/largeobject.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/largeobject.test b/parser/testdata/summary/postgres_regress/largeobject.test new file mode 100644 index 0000000..5e4aa24 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/largeobject.test @@ -0,0 +1,764 @@ +== 001 +|-- +-- Test large object support +|-- + +-- directory paths are passed to us in environment variables + +-- ensure consistent test output regardless of the default bytea format +SET bytea_output TO escape +-- +STMT: VariableSetStmt +== 002 +-- Test ALTER LARGE OBJECT OWNER +CREATE ROLE regress_lo_user +-- +STMT: CreateRoleStmt +== 003 +SELECT lo_create(42) +-- +FUNCTION: name="lo_create" function="lo_create" schema="" ctx=Call +STMT: SelectStmt +== 004 +ALTER LARGE OBJECT 42 OWNER TO regress_lo_user +-- +STMT: AlterOwnerStmt +== 005 +-- Test GRANT, COMMENT as non-superuser +SET SESSION AUTHORIZATION regress_lo_user +-- +STMT: VariableSetStmt +== 006 +GRANT SELECT ON LARGE OBJECT 42 TO public +-- +STMT: GrantStmt +== 007 +COMMENT ON LARGE OBJECT 42 IS 'the ultimate answer' +-- +STMT: CommentStmt +== 008 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 009 +-- Test psql's \lo_list et al (we assume no other LOs exist yet) + +-- Load a file +CREATE TABLE lotest_stash_values (loid oid, fd integer) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DDL +STMT: CreateStmt +== 010 +-- lo_creat(mode integer) returns oid +-- The mode arg to lo_creat is unused, some vestigal holdover from ancient times +-- returns the large object id +INSERT INTO lotest_stash_values (loid) SELECT lo_creat(42) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_creat" function="lo_creat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 011 +-- NOTE: large objects require transactions +BEGIN +-- +STMT: TransactionStmt +== 012 +-- lo_open(lobjId oid, mode integer) returns integer +-- The mode parameter to lo_open uses two constants: +-- INV_WRITE = 0x20000 +-- INV_READ = 0x40000 +-- The return value is a file descriptor-like value which remains valid for the +-- transaction. +UPDATE lotest_stash_values SET fd = lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +== 013 +-- loread/lowrite names are wonky, different from other functions which are lo_* +-- lowrite(fd integer, data bytea) returns integer +-- the integer is the number of bytes written +SELECT lowrite(fd, ' +I wandered lonely as a cloud +That floats on high o''er vales and hills, +When all at once I saw a crowd, +A host, of golden daffodils; +Beside the lake, beneath the trees, +Fluttering and dancing in the breeze. + +Continuous as the stars that shine +And twinkle on the milky way, +They stretched in never-ending line +Along the margin of a bay: +Ten thousand saw I at a glance, +Tossing their heads in sprightly dance. + +The waves beside them danced; but they +Out-did the sparkling waves in glee: +A poet could not but be gay, +In such a jocund company: +I gazed--and gazed--but little thought +What wealth the show to me had brought: + +For oft, when on my couch I lie +In vacant or in pensive mood, +They flash upon that inward eye +Which is the bliss of solitude; +And then my heart with pleasure fills, +And dances with the daffodils. + + -- William Wordsworth +') FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- lo_close(fd integer) returns integer +-- return value is 0 for success, or <0 for error (actually only -1, but...) +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +== 015 +END +-- +STMT: TransactionStmt +== 016 +-- Copy to another large object. +-- Note: we intentionally don't remove the object created here; +-- it's left behind to help test pg_dump. + +SELECT lo_from_bytea(0, lo_get(loid)) AS newloid FROM lotest_stash_values + +-- Add a comment to it, as well, for pg_dump/pg_upgrade testing. +COMMENT ON LARGE OBJECT :newloid IS 'I Wandered Lonely as a Cloud' +-- +ERROR: syntax error at or near "ON" +CURSORPOS: 289 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 017 +-- Read out a portion +BEGIN +-- +STMT: TransactionStmt +== 018 +UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +== 019 +-- lo_lseek(fd integer, offset integer, whence integer) returns integer +-- offset is in bytes, whence is one of three values: +-- SEEK_SET (= 0) meaning relative to beginning +-- SEEK_CUR (= 1) meaning relative to current position +-- SEEK_END (= 2) meaning relative to end (offset better be negative) +-- returns current position in file +SELECT lo_lseek(fd, 104, 0) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 020 +-- loread/lowrite names are wonky, different from other functions which are lo_* +-- loread(fd integer, len integer) returns bytea +SELECT loread(fd, 28) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT lo_lseek(fd, -19, 1) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT lowrite(fd, 'n') FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT lo_tell(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell" function="lo_tell" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT lo_lseek(fd, -744, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT loread(fd, 28) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +== 026 +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +== 027 +END +-- +STMT: TransactionStmt +== 028 +-- Test resource management +BEGIN +-- +STMT: TransactionStmt +== 029 +SELECT lo_open(loid, x'40000'::int) from lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: SelectStmt +== 030 +ABORT +-- +STMT: TransactionStmt +== 031 +DO :'dobody' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 4 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 032 +-- Test truncation. +BEGIN +-- +STMT: TransactionStmt +== 033 +UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +== 034 +SELECT lo_truncate(fd, 11) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate" function="lo_truncate" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT loread(fd, 15) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +== 036 +SELECT lo_truncate(fd, 10000) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate" function="lo_truncate" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT loread(fd, 10) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 039 +SELECT lo_tell(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell" function="lo_tell" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT lo_truncate(fd, 5000) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate" function="lo_truncate" schema="" ctx=Call +STMT: SelectStmt +== 041 +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 042 +SELECT lo_tell(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell" function="lo_tell" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +== 044 +END +-- +STMT: TransactionStmt +== 045 +-- Test 64-bit large object functions. +BEGIN +-- +STMT: TransactionStmt +== 046 +UPDATE lotest_stash_values SET fd = lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +== 047 +SELECT lo_lseek64(fd, 4294967296, 0) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek64" function="lo_lseek64" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT lowrite(fd, 'offset:4GB') FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +== 049 +SELECT lo_tell64(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell64" function="lo_tell64" schema="" ctx=Call +STMT: SelectStmt +== 050 +SELECT lo_lseek64(fd, -10, 1) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek64" function="lo_lseek64" schema="" ctx=Call +STMT: SelectStmt +== 051 +SELECT lo_tell64(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell64" function="lo_tell64" schema="" ctx=Call +STMT: SelectStmt +== 052 +SELECT loread(fd, 10) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +== 053 +SELECT lo_truncate64(fd, 5000000000) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate64" function="lo_truncate64" schema="" ctx=Call +STMT: SelectStmt +== 054 +SELECT lo_lseek64(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek64" function="lo_lseek64" schema="" ctx=Call +STMT: SelectStmt +== 055 +SELECT lo_tell64(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell64" function="lo_tell64" schema="" ctx=Call +STMT: SelectStmt +== 056 +SELECT lo_truncate64(fd, 3000000000) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate64" function="lo_truncate64" schema="" ctx=Call +STMT: SelectStmt +== 057 +SELECT lo_lseek64(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek64" function="lo_lseek64" schema="" ctx=Call +STMT: SelectStmt +== 058 +SELECT lo_tell64(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell64" function="lo_tell64" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +== 060 +END +-- +STMT: TransactionStmt +== 061 +-- lo_unlink(lobjId oid) returns integer +-- return value appears to always be 1 +SELECT lo_unlink(loid) from lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_unlink" function="lo_unlink" schema="" ctx=Call +STMT: SelectStmt +== 062 +TRUNCATE lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DDL +STMT: TruncateStmt +== 063 +INSERT INTO lotest_stash_values (loid) SELECT lo_import(:'filename') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 064 +BEGIN +-- +STMT: TransactionStmt +== 065 +UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +== 066 +-- verify length of large object +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 067 +-- with the default BLCKSZ, LOBLKSIZE = 2048, so this positions us for a block +-- edge case +SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 068 +-- this should get half of the value from page 0 and half from page 1 of the +-- large object +SELECT loread(fd, 36) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT lo_tell(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell" function="lo_tell" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT lo_lseek(fd, -26, 1) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT lowrite(fd, 'abcdefghijklmnop') FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +== 072 +SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +== 073 +SELECT loread(fd, 36) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +== 075 +END +-- +STMT: TransactionStmt +== 076 +SELECT lo_export(loid, :'filename') FROM lotest_stash_values +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 077 +-- just make sure \lo_export does not barf + +-- This is a hack to test that export/import are reversible +-- This uses knowledge about the inner workings of large object mechanism +-- which should not be used outside it. This makes it a HACK +SELECT pageno, data FROM pg_largeobject WHERE loid = (SELECT loid from lotest_stash_values) +EXCEPT +SELECT pageno, data FROM pg_largeobject WHERE loid = :newloid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 393 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 078 +SELECT lo_unlink(loid) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_unlink" function="lo_unlink" schema="" ctx=Call +STMT: SelectStmt +== 079 +TRUNCATE lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DDL +STMT: TruncateStmt +== 080 +SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2 + +SELECT fipshash(lo_get(:newloid_1)) = fipshash(lo_get(:newloid_2)) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 081 +SELECT lo_get(:newloid_1, 0, 20) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 082 +SELECT lo_get(:newloid_1, 10, 20) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 083 +SELECT lo_put(:newloid_1, 5, decode('afafafaf', 'hex')) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 084 +SELECT lo_get(:newloid_1, 0, 20) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 085 +SELECT lo_put(:newloid_1, 4294967310, 'foo') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 086 +SELECT lo_get(:newloid_1) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 087 +SELECT lo_get(:newloid_1, 4294967294, 100) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 088 +-- This object is left in the database for pg_dump test purposes +SELECT lo_from_bytea(0, E'\\xdeadbeef') AS newloid + +SET bytea_output TO hex +-- +ERROR: syntax error at or near "SET" +CURSORPOS: 118 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 089 +SELECT lo_get(:newloid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 090 +-- Create one more object that we leave behind for testing pg_dump/pg_upgrade; +-- this one intentionally has an OID in the system range +SELECT lo_create(2121) +-- +FUNCTION: name="lo_create" function="lo_create" schema="" ctx=Call +STMT: SelectStmt +== 091 +COMMENT ON LARGE OBJECT 2121 IS 'testing comments' +-- +STMT: CommentStmt +== 092 +-- Test writes on large objects in read-only transactions +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 093 +-- INV_READ ... ok +SELECT lo_open(2121, x'40000'::int) +-- +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: SelectStmt +== 094 +-- INV_WRITE ... error +SELECT lo_open(2121, x'20000'::int) +-- +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: SelectStmt +== 095 +ROLLBACK +-- +STMT: TransactionStmt +== 096 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 097 +SELECT lo_create(42) +-- +FUNCTION: name="lo_create" function="lo_create" schema="" ctx=Call +STMT: SelectStmt +== 098 +ROLLBACK +-- +STMT: TransactionStmt +== 099 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 100 +SELECT lo_creat(42) +-- +FUNCTION: name="lo_creat" function="lo_creat" schema="" ctx=Call +STMT: SelectStmt +== 101 +ROLLBACK +-- +STMT: TransactionStmt +== 102 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 103 +SELECT lo_unlink(42) +-- +FUNCTION: name="lo_unlink" function="lo_unlink" schema="" ctx=Call +STMT: SelectStmt +== 104 +ROLLBACK +-- +STMT: TransactionStmt +== 105 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 106 +SELECT lowrite(42, 'x') +-- +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +== 107 +ROLLBACK +-- +STMT: TransactionStmt +== 108 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 109 +SELECT lo_import(:'filename') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 18 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 110 +ROLLBACK +-- +STMT: TransactionStmt +== 111 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 112 +SELECT lo_truncate(42, 0) +-- +FUNCTION: name="lo_truncate" function="lo_truncate" schema="" ctx=Call +STMT: SelectStmt +== 113 +ROLLBACK +-- +STMT: TransactionStmt +== 114 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 115 +SELECT lo_truncate64(42, 0) +-- +FUNCTION: name="lo_truncate64" function="lo_truncate64" schema="" ctx=Call +STMT: SelectStmt +== 116 +ROLLBACK +-- +STMT: TransactionStmt +== 117 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 118 +SELECT lo_from_bytea(0, 'x') +-- +FUNCTION: name="lo_from_bytea" function="lo_from_bytea" schema="" ctx=Call +STMT: SelectStmt +== 119 +ROLLBACK +-- +STMT: TransactionStmt +== 120 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 121 +SELECT lo_put(42, 0, 'x') +-- +FUNCTION: name="lo_put" function="lo_put" schema="" ctx=Call +STMT: SelectStmt +== 122 +ROLLBACK +-- +STMT: TransactionStmt +== 123 +-- Clean up +DROP TABLE lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DDL +STMT: DropStmt +== 124 +DROP ROLE regress_lo_user +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/limit.metadata.json b/parser/testdata/summary/postgres_regress/limit.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/limit.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/limit.test b/parser/testdata/summary/postgres_regress/limit.test new file mode 100644 index 0000000..00b1b34 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/limit.test @@ -0,0 +1,509 @@ +== 001 +|-- +-- LIMIT +-- Check the LIMIT/OFFSET feature of SELECT +|-- + +SELECT ''::text AS two, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 50 + ORDER BY unique1 LIMIT 2 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 002 +SELECT ''::text AS five, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 60 + ORDER BY unique1 LIMIT 5 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 003 +SELECT ''::text AS two, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 60 AND unique1 < 63 + ORDER BY unique1 LIMIT 5 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 004 +SELECT ''::text AS three, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 100 + ORDER BY unique1 LIMIT 3 OFFSET 20 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 005 +SELECT ''::text AS zero, unique1, unique2, stringu1 + FROM onek WHERE unique1 < 50 + ORDER BY unique1 DESC LIMIT 8 OFFSET 99 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 006 +SELECT ''::text AS eleven, unique1, unique2, stringu1 + FROM onek WHERE unique1 < 50 + ORDER BY unique1 DESC LIMIT 20 OFFSET 39 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 007 +SELECT ''::text AS ten, unique1, unique2, stringu1 + FROM onek + ORDER BY unique1 OFFSET 990 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 008 +SELECT ''::text AS five, unique1, unique2, stringu1 + FROM onek + ORDER BY unique1 OFFSET 990 LIMIT 5 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 009 +SELECT ''::text AS five, unique1, unique2, stringu1 + FROM onek + ORDER BY unique1 LIMIT 5 OFFSET 900 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 010 +-- Test null limit and offset. The planner would discard a simple null +-- constant, so to ensure executor is exercised, do this: +select * from int8_tbl limit (case when random() < 0.5 then null::bigint end) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 011 +select * from int8_tbl offset (case when random() < 0.5 then null::bigint end) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- Test assorted cases involving backwards fetch from a LIMIT plan node +begin +-- +STMT: TransactionStmt +== 013 +declare c1 cursor for select * from int8_tbl limit 10 +-- +STMT: DeclareCursorStmt +== 014 +fetch all in c1 +-- +STMT: FetchStmt +== 015 +fetch 1 in c1 +-- +STMT: FetchStmt +== 016 +fetch backward 1 in c1 +-- +STMT: FetchStmt +== 017 +fetch backward all in c1 +-- +STMT: FetchStmt +== 018 +fetch backward 1 in c1 +-- +STMT: FetchStmt +== 019 +fetch all in c1 +-- +STMT: FetchStmt +== 020 +declare c2 cursor for select * from int8_tbl limit 3 +-- +STMT: DeclareCursorStmt +== 021 +fetch all in c2 +-- +STMT: FetchStmt +== 022 +fetch 1 in c2 +-- +STMT: FetchStmt +== 023 +fetch backward 1 in c2 +-- +STMT: FetchStmt +== 024 +fetch backward all in c2 +-- +STMT: FetchStmt +== 025 +fetch backward 1 in c2 +-- +STMT: FetchStmt +== 026 +fetch all in c2 +-- +STMT: FetchStmt +== 027 +declare c3 cursor for select * from int8_tbl offset 3 +-- +STMT: DeclareCursorStmt +== 028 +fetch all in c3 +-- +STMT: FetchStmt +== 029 +fetch 1 in c3 +-- +STMT: FetchStmt +== 030 +fetch backward 1 in c3 +-- +STMT: FetchStmt +== 031 +fetch backward all in c3 +-- +STMT: FetchStmt +== 032 +fetch backward 1 in c3 +-- +STMT: FetchStmt +== 033 +fetch all in c3 +-- +STMT: FetchStmt +== 034 +declare c4 cursor for select * from int8_tbl offset 10 +-- +STMT: DeclareCursorStmt +== 035 +fetch all in c4 +-- +STMT: FetchStmt +== 036 +fetch 1 in c4 +-- +STMT: FetchStmt +== 037 +fetch backward 1 in c4 +-- +STMT: FetchStmt +== 038 +fetch backward all in c4 +-- +STMT: FetchStmt +== 039 +fetch backward 1 in c4 +-- +STMT: FetchStmt +== 040 +fetch all in c4 +-- +STMT: FetchStmt +== 041 +declare c5 cursor for select * from int8_tbl order by q1 fetch first 2 rows with ties +-- +STMT: DeclareCursorStmt +== 042 +fetch all in c5 +-- +STMT: FetchStmt +== 043 +fetch 1 in c5 +-- +STMT: FetchStmt +== 044 +fetch backward 1 in c5 +-- +STMT: FetchStmt +== 045 +fetch backward 1 in c5 +-- +STMT: FetchStmt +== 046 +fetch all in c5 +-- +STMT: FetchStmt +== 047 +fetch backward all in c5 +-- +STMT: FetchStmt +== 048 +fetch all in c5 +-- +STMT: FetchStmt +== 049 +fetch backward all in c5 +-- +STMT: FetchStmt +== 050 +rollback +-- +STMT: TransactionStmt +== 051 +-- Stress test for variable LIMIT in conjunction with bounded-heap sorting + +SELECT + (SELECT n + FROM (VALUES (1)) AS x, + (SELECT n FROM generate_series(1,10) AS n + ORDER BY n LIMIT 1 OFFSET s-1) AS y) AS z + FROM generate_series(1,10) AS s +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 052 +|-- +-- Test behavior of volatile and set-returning functions in conjunction +-- with ORDER BY and LIMIT. +|-- + +create temp sequence testseq +-- +STMT: CreateSeqStmt +== 053 +explain (verbose, costs off) +select unique1, unique2, nextval('testseq') + from tenk1 order by unique2 limit 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 054 +select unique1, unique2, nextval('testseq') + from tenk1 order by unique2 limit 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 055 +select currval('testseq') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 056 +explain (verbose, costs off) +select unique1, unique2, nextval('testseq') + from tenk1 order by tenthous limit 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 057 +select unique1, unique2, nextval('testseq') + from tenk1 order by tenthous limit 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 058 +select currval('testseq') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 059 +explain (verbose, costs off) +select unique1, unique2, generate_series(1,10) + from tenk1 order by unique2 limit 7 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 060 +select unique1, unique2, generate_series(1,10) + from tenk1 order by unique2 limit 7 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 061 +explain (verbose, costs off) +select unique1, unique2, generate_series(1,10) + from tenk1 order by tenthous limit 7 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 062 +select unique1, unique2, generate_series(1,10) + from tenk1 order by tenthous limit 7 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 063 +-- use of random() is to keep planner from folding the expressions together +explain (verbose, costs off) +select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 064 +select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 065 +explain (verbose, costs off) +select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 +order by s2 desc +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 066 +select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 +order by s2 desc +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 067 +-- test for failure to set all aggregates' aggtranstype +explain (verbose, costs off) +select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 + from tenk1 group by thousand order by thousand limit 3 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 068 +select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 + from tenk1 group by thousand order by thousand limit 3 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 069 +|-- +-- FETCH FIRST +-- Check the WITH TIES clause +|-- + +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 2 ROW WITH TIES +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 070 +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST ROWS WITH TIES +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 071 +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 1 ROW WITH TIES +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 072 +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 2 ROW ONLY +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 073 +-- SKIP LOCKED and WITH TIES are incompatible +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 1 ROW WITH TIES FOR UPDATE SKIP LOCKED +-- +ERROR: SKIP LOCKED and WITH TIES options cannot be used together +FILENAME: gram.y +FUNCNAME: insertSelectOptions +== 074 +-- should fail +SELECT ''::text AS two, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 50 + FETCH FIRST 2 ROW WITH TIES +-- +ERROR: WITH TIES cannot be specified without ORDER BY clause +FILENAME: gram.y +FUNCNAME: insertSelectOptions +== 075 +-- test ruleutils +CREATE VIEW limit_thousand_v_1 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST 5 ROWS WITH TIES OFFSET 10 +-- +TABLE: name="limit_thousand_v_1" schema="" table="limit_thousand_v_1" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +== 076 +CREATE VIEW limit_thousand_v_2 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand OFFSET 10 FETCH FIRST 5 ROWS ONLY +-- +TABLE: name="limit_thousand_v_2" schema="" table="limit_thousand_v_2" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +== 077 +CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST NULL ROWS WITH TIES +-- +TABLE: name="limit_thousand_v_3" schema="" table="limit_thousand_v_3" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +== 078 +-- fails +CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST (NULL+1) ROWS WITH TIES +-- +TABLE: name="limit_thousand_v_3" schema="" table="limit_thousand_v_3" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +== 079 +CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST (5::bigint) ROWS WITH TIES +-- +TABLE: name="limit_thousand_v_4" schema="" table="limit_thousand_v_4" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +== 080 +CREATE VIEW limit_thousand_v_5 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST NULL ROWS ONLY +-- +TABLE: name="limit_thousand_v_5" schema="" table="limit_thousand_v_5" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/line.metadata.json b/parser/testdata/summary/postgres_regress/line.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/line.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/line.test b/parser/testdata/summary/postgres_regress/line.test new file mode 100644 index 0000000..00f1f3d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/line.test @@ -0,0 +1,212 @@ +== 001 +|-- +-- LINE +-- Infinite lines +|-- + +--DROP TABLE LINE_TBL; +CREATE TABLE LINE_TBL (s line) +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO LINE_TBL VALUES ('{0,-1,5}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +-- A == 0 +INSERT INTO LINE_TBL VALUES ('{1,0,5}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +-- B == 0 +INSERT INTO LINE_TBL VALUES ('{0,3,0}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +-- A == C == 0 +INSERT INTO LINE_TBL VALUES (' (0,0), (6,6)') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO LINE_TBL VALUES ('10,-10 ,-5,-4') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO LINE_TBL VALUES ('[-1e6,2e2,3e5, -4e1]') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO LINE_TBL VALUES ('{3,NaN,5}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO LINE_TBL VALUES ('{NaN,NaN,NaN}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +-- horizontal +INSERT INTO LINE_TBL VALUES ('[(1,3),(2,3)]') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +-- vertical +INSERT INTO LINE_TBL VALUES (line(point '(3,1)', point '(3,2)')) +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +FUNCTION: name="line" function="line" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 012 +-- bad values for parser testing +INSERT INTO LINE_TBL VALUES ('{}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO LINE_TBL VALUES ('{0') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO LINE_TBL VALUES ('{0,0}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO LINE_TBL VALUES ('{0,0,1') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO LINE_TBL VALUES ('{0,0,1}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO LINE_TBL VALUES ('{0,0,1} x') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO LINE_TBL VALUES ('(3asdf,2 ,3,4r2)') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO LINE_TBL VALUES ('[1,2,3, 4') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO LINE_TBL VALUES ('[(,2),(3,4)]') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO LINE_TBL VALUES ('[(1,2),(3,4)') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO LINE_TBL VALUES ('[(1,2),(1,2)]') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO LINE_TBL VALUES (line(point '(1,0)', point '(1,0)')) +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +FUNCTION: name="line" function="line" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 024 +select * from LINE_TBL +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +STMT: SelectStmt +== 025 +select '{nan, 1, nan}'::line = '{nan, 1, nan}'::line as true, + '{nan, 1, nan}'::line = '{nan, 2, nan}'::line as false +-- +STMT: SelectStmt +== 026 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('{1, 1}', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT * FROM pg_input_error_info('{1, 1}', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT pg_input_is_valid('{0, 0, 0}', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT * FROM pg_input_error_info('{0, 0, 0}', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT pg_input_is_valid('{1, 1, a}', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT * FROM pg_input_error_info('{1, 1, a}', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT pg_input_is_valid('{1, 1, 1e400}', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT * FROM pg_input_error_info('{1, 1, 1e400}', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT * FROM pg_input_error_info('(1, 1), (1, 1e400)', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/lock.metadata.json b/parser/testdata/summary/postgres_regress/lock.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/lock.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/lock.test b/parser/testdata/summary/postgres_regress/lock.test new file mode 100644 index 0000000..db41453 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/lock.test @@ -0,0 +1,725 @@ +== 001 +|-- +-- Test the LOCK statement +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +-- Setup +CREATE SCHEMA lock_schema1 +-- +STMT: CreateSchemaStmt +== 002 +SET search_path = lock_schema1 +-- +STMT: VariableSetStmt +== 003 +CREATE TABLE lock_tbl1 (a BIGINT) +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE lock_tbl1a (a BIGINT) +-- +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=DDL +STMT: CreateStmt +== 005 +CREATE VIEW lock_view1 AS SELECT * FROM lock_tbl1 +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 006 +CREATE VIEW lock_view2(a,b) AS SELECT * FROM lock_tbl1, lock_tbl1a +-- +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 007 +CREATE VIEW lock_view3 AS SELECT * from lock_view2 +-- +TABLE: name="lock_view3" schema="" table="lock_view3" ctx=DDL +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 008 +CREATE VIEW lock_view4 AS SELECT (select a from lock_tbl1a limit 1) from lock_tbl1 +-- +TABLE: name="lock_view4" schema="" table="lock_view4" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 009 +CREATE VIEW lock_view5 AS SELECT * from lock_tbl1 where a in (select * from lock_tbl1a) +-- +TABLE: name="lock_view5" schema="" table="lock_view5" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 010 +CREATE VIEW lock_view6 AS SELECT * from (select * from lock_tbl1) sub +-- +TABLE: name="lock_view6" schema="" table="lock_view6" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 011 +CREATE ROLE regress_rol_lock1 +-- +STMT: CreateRoleStmt +== 012 +ALTER ROLE regress_rol_lock1 SET search_path = lock_schema1 +-- +STMT: AlterRoleSetStmt +== 013 +GRANT USAGE ON SCHEMA lock_schema1 TO regress_rol_lock1 +-- +STMT: GrantStmt +== 014 +-- Try all valid lock options; also try omitting the optional TABLE keyword. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 015 +LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 016 +LOCK lock_tbl1 IN ROW SHARE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 017 +LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 018 +LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 019 +LOCK TABLE lock_tbl1 IN SHARE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 020 +LOCK lock_tbl1 IN SHARE ROW EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 021 +LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 022 +LOCK TABLE lock_tbl1 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 023 +ROLLBACK +-- +STMT: TransactionStmt +== 024 +-- Try using NOWAIT along with valid options. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 025 +LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 026 +LOCK TABLE lock_tbl1 IN ROW SHARE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 027 +LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 028 +LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 029 +LOCK TABLE lock_tbl1 IN SHARE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 030 +LOCK TABLE lock_tbl1 IN SHARE ROW EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 031 +LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 032 +LOCK TABLE lock_tbl1 IN ACCESS EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 033 +ROLLBACK +-- +STMT: TransactionStmt +== 034 +-- Verify that we can lock views. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 035 +LOCK TABLE lock_view1 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: LockStmt +== 036 +-- lock_view1 and lock_tbl1 are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 037 +ROLLBACK +-- +STMT: TransactionStmt +== 038 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 039 +LOCK TABLE lock_view2 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=DDL +STMT: LockStmt +== 040 +-- lock_view1, lock_tbl1, and lock_tbl1a are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 041 +ROLLBACK +-- +STMT: TransactionStmt +== 042 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 043 +LOCK TABLE lock_view3 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view3" schema="" table="lock_view3" ctx=DDL +STMT: LockStmt +== 044 +-- lock_view3, lock_view2, lock_tbl1, and lock_tbl1a are locked recursively. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 045 +ROLLBACK +-- +STMT: TransactionStmt +== 046 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 047 +LOCK TABLE lock_view4 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view4" schema="" table="lock_view4" ctx=DDL +STMT: LockStmt +== 048 +-- lock_view4, lock_tbl1, and lock_tbl1a are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 049 +ROLLBACK +-- +STMT: TransactionStmt +== 050 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 051 +LOCK TABLE lock_view5 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view5" schema="" table="lock_view5" ctx=DDL +STMT: LockStmt +== 052 +-- lock_view5, lock_tbl1, and lock_tbl1a are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 053 +ROLLBACK +-- +STMT: TransactionStmt +== 054 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 055 +LOCK TABLE lock_view6 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view6" schema="" table="lock_view6" ctx=DDL +STMT: LockStmt +== 056 +-- lock_view6 an lock_tbl1 are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 057 +ROLLBACK +-- +STMT: TransactionStmt +== 058 +-- Verify that we cope with infinite recursion in view definitions. +CREATE OR REPLACE VIEW lock_view2 AS SELECT * from lock_view3 +-- +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=DDL +TABLE: name="lock_view3" schema="" table="lock_view3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 059 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 060 +LOCK TABLE lock_view2 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=DDL +STMT: LockStmt +== 061 +ROLLBACK +-- +STMT: TransactionStmt +== 062 +CREATE VIEW lock_view7 AS SELECT * from lock_view2 +-- +TABLE: name="lock_view7" schema="" table="lock_view7" ctx=DDL +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 063 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 064 +LOCK TABLE lock_view7 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view7" schema="" table="lock_view7" ctx=DDL +STMT: LockStmt +== 065 +ROLLBACK +-- +STMT: TransactionStmt +== 066 +-- Verify that we can lock a table with inheritance children. +CREATE TABLE lock_tbl2 (b BIGINT) INHERITS (lock_tbl1) +-- +TABLE: name="lock_tbl2" schema="" table="lock_tbl2" ctx=DDL +STMT: CreateStmt +== 067 +CREATE TABLE lock_tbl3 () INHERITS (lock_tbl2) +-- +TABLE: name="lock_tbl3" schema="" table="lock_tbl3" ctx=DDL +STMT: CreateStmt +== 068 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 069 +LOCK TABLE lock_tbl1 * IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 070 +ROLLBACK +-- +STMT: TransactionStmt +== 071 +-- Child tables are locked without granting explicit permission to do so as +-- long as we have permission to lock the parent. +GRANT UPDATE ON TABLE lock_tbl1 TO regress_rol_lock1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: GrantStmt +== 072 +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +== 073 +-- fail when child locked directly +BEGIN +-- +STMT: TransactionStmt +== 074 +LOCK TABLE lock_tbl2 +-- +TABLE: name="lock_tbl2" schema="" table="lock_tbl2" ctx=DDL +STMT: LockStmt +== 075 +ROLLBACK +-- +STMT: TransactionStmt +== 076 +BEGIN +-- +STMT: TransactionStmt +== 077 +LOCK TABLE lock_tbl1 * IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 078 +ROLLBACK +-- +STMT: TransactionStmt +== 079 +BEGIN +-- +STMT: TransactionStmt +== 080 +LOCK TABLE ONLY lock_tbl1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +== 081 +ROLLBACK +-- +STMT: TransactionStmt +== 082 +RESET ROLE +-- +STMT: VariableSetStmt +== 083 +REVOKE UPDATE ON TABLE lock_tbl1 FROM regress_rol_lock1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: GrantStmt +== 084 +-- Tables referred to by views are locked without explicit permission to do so +-- as long as we have permission to lock the view itself. +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +== 085 +-- fail without permissions on the view +BEGIN +-- +STMT: TransactionStmt +== 086 +LOCK TABLE lock_view1 +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: LockStmt +== 087 +ROLLBACK +-- +STMT: TransactionStmt +== 088 +RESET ROLE +-- +STMT: VariableSetStmt +== 089 +GRANT UPDATE ON TABLE lock_view1 TO regress_rol_lock1 +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: GrantStmt +== 090 +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +== 091 +BEGIN +-- +STMT: TransactionStmt +== 092 +LOCK TABLE lock_view1 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: LockStmt +== 093 +-- lock_view1 and lock_tbl1 (plus children lock_tbl2 and lock_tbl3) are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'AccessExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 094 +ROLLBACK +-- +STMT: TransactionStmt +== 095 +RESET ROLE +-- +STMT: VariableSetStmt +== 096 +REVOKE UPDATE ON TABLE lock_view1 FROM regress_rol_lock1 +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: GrantStmt +== 097 +-- Tables referred to by security invoker views require explicit permission to +-- be locked. +CREATE VIEW lock_view8 WITH (security_invoker) AS SELECT * FROM lock_tbl1 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 098 +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +== 099 +-- fail without permissions on the view +BEGIN +-- +STMT: TransactionStmt +== 100 +LOCK TABLE lock_view8 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: LockStmt +== 101 +ROLLBACK +-- +STMT: TransactionStmt +== 102 +RESET ROLE +-- +STMT: VariableSetStmt +== 103 +GRANT UPDATE ON TABLE lock_view8 TO regress_rol_lock1 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: GrantStmt +== 104 +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +== 105 +-- fail without permissions on the table referenced by the view +BEGIN +-- +STMT: TransactionStmt +== 106 +LOCK TABLE lock_view8 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: LockStmt +== 107 +ROLLBACK +-- +STMT: TransactionStmt +== 108 +RESET ROLE +-- +STMT: VariableSetStmt +== 109 +GRANT UPDATE ON TABLE lock_tbl1 TO regress_rol_lock1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: GrantStmt +== 110 +BEGIN +-- +STMT: TransactionStmt +== 111 +LOCK TABLE lock_view8 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: LockStmt +== 112 +-- lock_view8 and lock_tbl1 (plus children lock_tbl2 and lock_tbl3) are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'AccessExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 113 +ROLLBACK +-- +STMT: TransactionStmt +== 114 +RESET ROLE +-- +STMT: VariableSetStmt +== 115 +REVOKE UPDATE ON TABLE lock_view8 FROM regress_rol_lock1 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: GrantStmt +== 116 +|-- +-- Clean up +|-- +DROP VIEW lock_view8 +-- +STMT: DropStmt +== 117 +DROP VIEW lock_view7 +-- +STMT: DropStmt +== 118 +DROP VIEW lock_view6 +-- +STMT: DropStmt +== 119 +DROP VIEW lock_view5 +-- +STMT: DropStmt +== 120 +DROP VIEW lock_view4 +-- +STMT: DropStmt +== 121 +DROP VIEW lock_view3 CASCADE +-- +STMT: DropStmt +== 122 +DROP VIEW lock_view1 +-- +STMT: DropStmt +== 123 +DROP TABLE lock_tbl3 +-- +TABLE: name="lock_tbl3" schema="" table="lock_tbl3" ctx=DDL +STMT: DropStmt +== 124 +DROP TABLE lock_tbl2 +-- +TABLE: name="lock_tbl2" schema="" table="lock_tbl2" ctx=DDL +STMT: DropStmt +== 125 +DROP TABLE lock_tbl1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: DropStmt +== 126 +DROP TABLE lock_tbl1a +-- +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=DDL +STMT: DropStmt +== 127 +DROP SCHEMA lock_schema1 CASCADE +-- +STMT: DropStmt +== 128 +DROP ROLE regress_rol_lock1 +-- +STMT: DropRoleStmt +== 129 +-- atomic ops tests +RESET search_path +-- +STMT: VariableSetStmt +== 130 +CREATE FUNCTION test_atomic_ops() + RETURNS bool + AS :'regresslib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 59 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 131 +SELECT test_atomic_ops() +-- +FUNCTION: name="test_atomic_ops" function="test_atomic_ops" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/lseg.metadata.json b/parser/testdata/summary/postgres_regress/lseg.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/lseg.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/lseg.test b/parser/testdata/summary/postgres_regress/lseg.test new file mode 100644 index 0000000..125ee1f --- /dev/null +++ b/parser/testdata/summary/postgres_regress/lseg.test @@ -0,0 +1,107 @@ +== 001 +|-- +-- LSEG +-- Line segments +|-- + +--DROP TABLE LSEG_TBL; +CREATE TABLE LSEG_TBL (s lseg) +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO LSEG_TBL VALUES ('(0,0),(6,6)') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO LSEG_TBL VALUES ('10,-10 ,-3,-4') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO LSEG_TBL VALUES ('[-1e6,2e2,3e5, -4e1]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO LSEG_TBL VALUES (lseg(point(11, 22), point(33,44))) +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +FUNCTION: name="lseg" function="lseg" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO LSEG_TBL VALUES ('[(-10,2),(-10,3)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +-- vertical +INSERT INTO LSEG_TBL VALUES ('[(0,-20),(30,-20)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +-- horizontal +INSERT INTO LSEG_TBL VALUES ('[(NaN,1),(NaN,90)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +-- NaN + +-- bad values for parser testing +INSERT INTO LSEG_TBL VALUES ('(3asdf,2 ,3,4r2)') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO LSEG_TBL VALUES ('[1,2,3, 4') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +select * from LSEG_TBL +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +STMT: SelectStmt +== 015 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('[(1,2),(3)]', 'lseg') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'lseg') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/macaddr.metadata.json b/parser/testdata/summary/postgres_regress/macaddr.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/macaddr.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/macaddr.test b/parser/testdata/summary/postgres_regress/macaddr.test new file mode 100644 index 0000000..0f9c01f --- /dev/null +++ b/parser/testdata/summary/postgres_regress/macaddr.test @@ -0,0 +1,215 @@ +== 001 +|-- +-- macaddr +|-- + +CREATE TABLE macaddr_data (a int, b macaddr) +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO macaddr_data VALUES (1, '08:00:2b:01:02:03') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO macaddr_data VALUES (2, '08-00-2b-01-02-03') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO macaddr_data VALUES (3, '08002b:010203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO macaddr_data VALUES (4, '08002b-010203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO macaddr_data VALUES (5, '0800.2b01.0203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO macaddr_data VALUES (6, '0800-2b01-0203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO macaddr_data VALUES (7, '08002b010203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO macaddr_data VALUES (8, '0800:2b01:0203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +-- invalid +INSERT INTO macaddr_data VALUES (9, 'not even close') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +-- invalid + +INSERT INTO macaddr_data VALUES (10, '08:00:2b:01:02:04') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO macaddr_data VALUES (11, '08:00:2b:01:02:02') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO macaddr_data VALUES (12, '08:00:2a:01:02:03') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO macaddr_data VALUES (13, '08:00:2c:01:02:03') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO macaddr_data VALUES (14, '08:00:2a:01:02:04') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +SELECT * FROM macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +STMT: SelectStmt +== 017 +CREATE INDEX macaddr_data_btree ON macaddr_data USING btree (b) +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DDL +STMT: IndexStmt +== 018 +CREATE INDEX macaddr_data_hash ON macaddr_data USING hash (b) +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DDL +STMT: IndexStmt +== 019 +SELECT a, b, trunc(b) FROM macaddr_data ORDER BY 2, 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT b < '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 021 +-- true +SELECT b > '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 022 +-- false +SELECT b > '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 023 +-- false +SELECT b <= '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 024 +-- true +SELECT b >= '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 025 +-- false +SELECT b = '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 026 +-- true +SELECT b <> '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 027 +-- true +SELECT b <> '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 028 +-- false + +SELECT ~b FROM macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +STMT: SelectStmt +== 029 +SELECT b & '00:00:00:ff:ff:ff' FROM macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +STMT: SelectStmt +== 030 +SELECT b | '01:02:03:04:05:06' FROM macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +STMT: SelectStmt +== 031 +DROP TABLE macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DDL +STMT: DropStmt +== 032 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('08:00:2b:01:02:ZZ', 'macaddr') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT * FROM pg_input_error_info('08:00:2b:01:02:ZZ', 'macaddr') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT pg_input_is_valid('08:00:2b:01:02:', 'macaddr') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT * FROM pg_input_error_info('08:00:2b:01:02:', 'macaddr') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/macaddr8.metadata.json b/parser/testdata/summary/postgres_regress/macaddr8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/macaddr8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/macaddr8.test b/parser/testdata/summary/postgres_regress/macaddr8.test new file mode 100644 index 0000000..b934bdc --- /dev/null +++ b/parser/testdata/summary/postgres_regress/macaddr8.test @@ -0,0 +1,418 @@ +== 001 +|-- +-- macaddr8 +|-- + +-- test various cases of valid and invalid input +-- valid +SELECT '08:00:2b:01:02:03 '::macaddr8 +-- +STMT: SelectStmt +== 002 +SELECT ' 08:00:2b:01:02:03 '::macaddr8 +-- +STMT: SelectStmt +== 003 +SELECT ' 08:00:2b:01:02:03'::macaddr8 +-- +STMT: SelectStmt +== 004 +SELECT '08:00:2b:01:02:03:04:05 '::macaddr8 +-- +STMT: SelectStmt +== 005 +SELECT ' 08:00:2b:01:02:03:04:05 '::macaddr8 +-- +STMT: SelectStmt +== 006 +SELECT ' 08:00:2b:01:02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +== 007 +SELECT '123 08:00:2b:01:02:03'::macaddr8 +-- +STMT: SelectStmt +== 008 +-- invalid +SELECT '08:00:2b:01:02:03 123'::macaddr8 +-- +STMT: SelectStmt +== 009 +-- invalid +SELECT '123 08:00:2b:01:02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +== 010 +-- invalid +SELECT '08:00:2b:01:02:03:04:05 123'::macaddr8 +-- +STMT: SelectStmt +== 011 +-- invalid +SELECT '08:00:2b:01:02:03:04:05:06:07'::macaddr8 +-- +STMT: SelectStmt +== 012 +-- invalid +SELECT '08-00-2b-01-02-03-04-05-06-07'::macaddr8 +-- +STMT: SelectStmt +== 013 +-- invalid +SELECT '08002b:01020304050607'::macaddr8 +-- +STMT: SelectStmt +== 014 +-- invalid +SELECT '08002b01020304050607'::macaddr8 +-- +STMT: SelectStmt +== 015 +-- invalid +SELECT '0z002b0102030405'::macaddr8 +-- +STMT: SelectStmt +== 016 +-- invalid +SELECT '08002b010203xyza'::macaddr8 +-- +STMT: SelectStmt +== 017 +-- invalid + +SELECT '08:00-2b:01:02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +== 018 +-- invalid +SELECT '08:00-2b:01:02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +== 019 +-- invalid +SELECT '08:00:2b:01.02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +== 020 +-- invalid +SELECT '08:00:2b:01.02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +== 021 +-- invalid + +-- test converting a MAC address to modified EUI-64 for inclusion +-- in an ipv6 address +SELECT macaddr8_set7bit('00:08:2b:01:02:03'::macaddr8) +-- +FUNCTION: name="macaddr8_set7bit" function="macaddr8_set7bit" schema="" ctx=Call +STMT: SelectStmt +== 022 +CREATE TABLE macaddr8_data (a int, b macaddr8) +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DDL +STMT: CreateStmt +== 023 +INSERT INTO macaddr8_data VALUES (1, '08:00:2b:01:02:03') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO macaddr8_data VALUES (2, '08-00-2b-01-02-03') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO macaddr8_data VALUES (3, '08002b:010203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO macaddr8_data VALUES (4, '08002b-010203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO macaddr8_data VALUES (5, '0800.2b01.0203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO macaddr8_data VALUES (6, '0800-2b01-0203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +INSERT INTO macaddr8_data VALUES (7, '08002b010203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO macaddr8_data VALUES (8, '0800:2b01:0203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO macaddr8_data VALUES (9, 'not even close') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +-- invalid + +INSERT INTO macaddr8_data VALUES (10, '08:00:2b:01:02:04') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO macaddr8_data VALUES (11, '08:00:2b:01:02:02') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO macaddr8_data VALUES (12, '08:00:2a:01:02:03') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO macaddr8_data VALUES (13, '08:00:2c:01:02:03') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +INSERT INTO macaddr8_data VALUES (14, '08:00:2a:01:02:04') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO macaddr8_data VALUES (15, '08:00:2b:01:02:03:04:05') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO macaddr8_data VALUES (16, '08-00-2b-01-02-03-04-05') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO macaddr8_data VALUES (17, '08002b:0102030405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO macaddr8_data VALUES (18, '08002b-0102030405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO macaddr8_data VALUES (19, '0800.2b01.0203.0405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO macaddr8_data VALUES (20, '08002b01:02030405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO macaddr8_data VALUES (21, '08002b0102030405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +SELECT * FROM macaddr8_data ORDER BY 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +STMT: SelectStmt +== 045 +CREATE INDEX macaddr8_data_btree ON macaddr8_data USING btree (b) +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DDL +STMT: IndexStmt +== 046 +CREATE INDEX macaddr8_data_hash ON macaddr8_data USING hash (b) +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DDL +STMT: IndexStmt +== 047 +SELECT a, b, trunc(b) FROM macaddr8_data ORDER BY 2, 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT b < '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 049 +-- true +SELECT b > '08:00:2b:ff:fe:01:02:04' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 050 +-- false +SELECT b > '08:00:2b:ff:fe:01:02:03' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 051 +-- false +SELECT b::macaddr <= '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 052 +-- true +SELECT b::macaddr >= '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 053 +-- false +SELECT b = '08:00:2b:ff:fe:01:02:03' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 054 +-- true +SELECT b::macaddr <> '08:00:2b:01:02:04'::macaddr FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 055 +-- true +SELECT b::macaddr <> '08:00:2b:01:02:03'::macaddr FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 056 +-- false + +SELECT b < '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 057 +-- true +SELECT b > '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 058 +-- false +SELECT b > '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 059 +-- false +SELECT b <= '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 060 +-- true +SELECT b >= '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 061 +-- false +SELECT b = '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 062 +-- true +SELECT b <> '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 063 +-- true +SELECT b <> '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 064 +-- false + +SELECT ~b FROM macaddr8_data +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +STMT: SelectStmt +== 065 +SELECT b & '00:00:00:ff:ff:ff' FROM macaddr8_data +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +STMT: SelectStmt +== 066 +SELECT b | '01:02:03:04:05:06' FROM macaddr8_data +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +STMT: SelectStmt +== 067 +DROP TABLE macaddr8_data +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DDL +STMT: DropStmt +== 068 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('08:00:2b:01:02:03:04:ZZ', 'macaddr8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:ZZ', 'macaddr8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT pg_input_is_valid('08:00:2b:01:02:03:04:', 'macaddr8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:', 'macaddr8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/maintain_every.metadata.json b/parser/testdata/summary/postgres_regress/maintain_every.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/maintain_every.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/maintain_every.test b/parser/testdata/summary/postgres_regress/maintain_every.test new file mode 100644 index 0000000..cfadc3e --- /dev/null +++ b/parser/testdata/summary/postgres_regress/maintain_every.test @@ -0,0 +1,86 @@ +== 001 +-- Test maintenance commands that visit every eligible relation. Run as a +-- non-superuser, to skip other users' tables. + +CREATE ROLE regress_maintain +-- +STMT: CreateRoleStmt +== 002 +SET ROLE regress_maintain +-- +STMT: VariableSetStmt +== 003 +-- Test database-wide ANALYZE ("use_own_xacts" mode) setting relhassubclass=f +-- for non-partitioning inheritance, w/ ON COMMIT DELETE ROWS building an +-- empty index. +CREATE TEMP TABLE past_inh_db_other () +-- +TABLE: name="past_inh_db_other" schema="" table="past_inh_db_other" ctx=DDL +STMT: CreateStmt +== 004 +-- need 2 tables for "use_own_xacts" +CREATE TEMP TABLE past_inh_db_parent () ON COMMIT DELETE ROWS +-- +TABLE: name="past_inh_db_parent" schema="" table="past_inh_db_parent" ctx=DDL +STMT: CreateStmt +== 005 +CREATE TEMP TABLE past_inh_db_child () INHERITS (past_inh_db_parent) +-- +TABLE: name="past_inh_db_child" schema="" table="past_inh_db_child" ctx=DDL +STMT: CreateStmt +== 006 +CREATE INDEX ON past_inh_db_parent ((1)) +-- +TABLE: name="past_inh_db_parent" schema="" table="past_inh_db_parent" ctx=DDL +STMT: IndexStmt +== 007 +ANALYZE past_inh_db_parent +-- +TABLE: name="past_inh_db_parent" schema="" table="past_inh_db_parent" ctx=DDL +STMT: VacuumStmt +== 008 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_inh_db_parent'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 009 +DROP TABLE past_inh_db_child +-- +TABLE: name="past_inh_db_child" schema="" table="past_inh_db_child" ctx=DDL +STMT: DropStmt +== 010 +SET client_min_messages = error +-- +STMT: VariableSetStmt +== 011 +-- hide WARNINGs for other users' tables +ANALYZE +-- +STMT: VacuumStmt +== 012 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 013 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_inh_db_parent'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 014 +DROP TABLE past_inh_db_parent, past_inh_db_other +-- +TABLE: name="past_inh_db_parent" schema="" table="past_inh_db_parent" ctx=DDL +TABLE: name="past_inh_db_other" schema="" table="past_inh_db_other" ctx=DDL +STMT: DropStmt +== 015 +RESET ROLE +-- +STMT: VariableSetStmt +== 016 +DROP ROLE regress_maintain +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/matview.metadata.json b/parser/testdata/summary/postgres_regress/matview.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/matview.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/matview.test b/parser/testdata/summary/postgres_regress/matview.test new file mode 100644 index 0000000..ca20cee --- /dev/null +++ b/parser/testdata/summary/postgres_regress/matview.test @@ -0,0 +1,1116 @@ +== 001 +-- create a table to use as a basis for views and materialized views in various combinations +CREATE TABLE mvtest_t (id int NOT NULL PRIMARY KEY, type text NOT NULL, amt numeric NOT NULL) +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO mvtest_t VALUES + (1, 'x', 2), + (2, 'x', 3), + (3, 'y', 5), + (4, 'y', 7), + (5, 'z', 11) +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +-- we want a view based on the table, too, since views present additional challenges +CREATE VIEW mvtest_tv AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type +-- +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=DDL +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 004 +SELECT * FROM mvtest_tv ORDER BY type +-- +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +STMT: SelectStmt +== 005 +-- create a materialized view with no data, and confirm correct behavior +EXPLAIN (costs off) + CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type WITH NO DATA +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 006 +CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type WITH NO DATA +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 007 +SELECT relispopulated FROM pg_class WHERE oid = 'mvtest_tm'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 008 +SELECT * FROM mvtest_tm ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +STMT: SelectStmt +== 009 +REFRESH MATERIALIZED VIEW mvtest_tm +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +STMT: RefreshMatViewStmt +== 010 +SELECT relispopulated FROM pg_class WHERE oid = 'mvtest_tm'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 011 +CREATE UNIQUE INDEX mvtest_tm_type ON mvtest_tm (type) +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +STMT: IndexStmt +== 012 +SELECT * FROM mvtest_tm ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +STMT: SelectStmt +== 013 +-- create various views +EXPLAIN (costs off) + CREATE MATERIALIZED VIEW mvtest_tvm AS SELECT * FROM mvtest_tv ORDER BY type +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=DDL +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 014 +CREATE MATERIALIZED VIEW mvtest_tvm AS SELECT * FROM mvtest_tv ORDER BY type +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=DDL +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 015 +SELECT * FROM mvtest_tvm +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=Select +STMT: SelectStmt +== 016 +CREATE MATERIALIZED VIEW mvtest_tmm AS SELECT sum(totamt) AS grandtot FROM mvtest_tm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=DDL +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 017 +CREATE MATERIALIZED VIEW mvtest_tvmm AS SELECT sum(totamt) AS grandtot FROM mvtest_tvm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 018 +CREATE UNIQUE INDEX mvtest_tvmm_expr ON mvtest_tvmm ((grandtot > 0)) +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: IndexStmt +== 019 +CREATE UNIQUE INDEX mvtest_tvmm_pred ON mvtest_tvmm (grandtot) WHERE grandtot < 0 +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: IndexStmt +== 020 +CREATE VIEW mvtest_tvv AS SELECT sum(totamt) AS grandtot FROM mvtest_tv +-- +TABLE: name="mvtest_tvv" schema="" table="mvtest_tvv" ctx=DDL +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 021 +EXPLAIN (costs off) + CREATE MATERIALIZED VIEW mvtest_tvvm AS SELECT * FROM mvtest_tvv +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=DDL +TABLE: name="mvtest_tvv" schema="" table="mvtest_tvv" ctx=Select +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 022 +CREATE MATERIALIZED VIEW mvtest_tvvm AS SELECT * FROM mvtest_tvv +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=DDL +TABLE: name="mvtest_tvv" schema="" table="mvtest_tvv" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 023 +CREATE VIEW mvtest_tvvmv AS SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvmv" schema="" table="mvtest_tvvmv" ctx=DDL +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 024 +CREATE MATERIALIZED VIEW mvtest_bb AS SELECT * FROM mvtest_tvvmv +-- +TABLE: name="mvtest_bb" schema="" table="mvtest_bb" ctx=DDL +TABLE: name="mvtest_tvvmv" schema="" table="mvtest_tvvmv" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 025 +CREATE INDEX mvtest_aa ON mvtest_bb (grandtot) +-- +TABLE: name="mvtest_bb" schema="" table="mvtest_bb" ctx=DDL +STMT: IndexStmt +== 026 +-- check that plans seem reasonable + +-- test schema behavior +CREATE SCHEMA mvtest_mvschema +-- +STMT: CreateSchemaStmt +== 027 +ALTER MATERIALIZED VIEW mvtest_tvm SET SCHEMA mvtest_mvschema +-- +STMT: AlterObjectSchemaStmt +== 028 +SET search_path = mvtest_mvschema, public +-- +STMT: VariableSetStmt +== 029 +-- modify the underlying table data +INSERT INTO mvtest_t VALUES (6, 'z', 13) +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +-- confirm pre- and post-refresh contents of fairly simple materialized views +SELECT * FROM mvtest_tm ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +STMT: SelectStmt +== 031 +SELECT * FROM mvtest_tvm ORDER BY type +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=Select +STMT: SelectStmt +== 032 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tm +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +STMT: RefreshMatViewStmt +== 033 +REFRESH MATERIALIZED VIEW mvtest_tvm +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=DDL +STMT: RefreshMatViewStmt +== 034 +SELECT * FROM mvtest_tm ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +STMT: SelectStmt +== 035 +SELECT * FROM mvtest_tvm ORDER BY type +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=Select +STMT: SelectStmt +== 036 +RESET search_path +-- +STMT: VariableSetStmt +== 037 +-- confirm pre- and post-refresh contents of nested materialized views +EXPLAIN (costs off) + SELECT * FROM mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 038 +EXPLAIN (costs off) + SELECT * FROM mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 039 +EXPLAIN (costs off) + SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 040 +SELECT * FROM mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=Select +STMT: SelectStmt +== 041 +SELECT * FROM mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=Select +STMT: SelectStmt +== 042 +SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: SelectStmt +== 043 +REFRESH MATERIALIZED VIEW mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=DDL +STMT: RefreshMatViewStmt +== 044 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: RefreshMatViewStmt +== 045 +REFRESH MATERIALIZED VIEW mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: RefreshMatViewStmt +== 046 +REFRESH MATERIALIZED VIEW mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=DDL +STMT: RefreshMatViewStmt +== 047 +EXPLAIN (costs off) + SELECT * FROM mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 048 +EXPLAIN (costs off) + SELECT * FROM mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 049 +EXPLAIN (costs off) + SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 050 +SELECT * FROM mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=Select +STMT: SelectStmt +== 051 +SELECT * FROM mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=Select +STMT: SelectStmt +== 052 +SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: SelectStmt +== 053 +-- test diemv when the mv does not exist +DROP MATERIALIZED VIEW IF EXISTS no_such_mv +-- +STMT: DropStmt +== 054 +-- make sure invalid combination of options is prohibited +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tvmm WITH NO DATA +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: RefreshMatViewStmt +== 055 +-- no tuple locks on materialized views +SELECT * FROM mvtest_tvvm FOR SHARE +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: SelectStmt +== 056 +-- test join of mv and view +SELECT type, m.totamt AS mtot, v.totamt AS vtot FROM mvtest_tm m LEFT JOIN mvtest_tv v USING (type) ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +ALIAS: "m"="mvtest_tm" +ALIAS: "v"="mvtest_tv" +STMT: SelectStmt +== 057 +-- make sure that dependencies are reported properly when they block the drop +DROP TABLE mvtest_t +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DDL +STMT: DropStmt +== 058 +-- make sure dependencies are dropped and reported +-- and make sure that transactional behavior is correct on rollback +-- incidentally leaving some interesting materialized views for pg_dump testing +BEGIN +-- +STMT: TransactionStmt +== 059 +DROP TABLE mvtest_t CASCADE +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DDL +STMT: DropStmt +== 060 +ROLLBACK +-- +STMT: TransactionStmt +== 061 +-- some additional tests not using base tables +CREATE VIEW mvtest_vt1 AS SELECT 1 moo +-- +TABLE: name="mvtest_vt1" schema="" table="mvtest_vt1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 062 +CREATE VIEW mvtest_vt2 AS SELECT moo, 2*moo FROM mvtest_vt1 UNION ALL SELECT moo, 3*moo FROM mvtest_vt1 +-- +TABLE: name="mvtest_vt2" schema="" table="mvtest_vt2" ctx=DDL +TABLE: name="mvtest_vt1" schema="" table="mvtest_vt1" ctx=Select +TABLE: name="mvtest_vt1" schema="" table="mvtest_vt1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 063 +CREATE MATERIALIZED VIEW mv_test2 AS SELECT moo, 2*moo FROM mvtest_vt2 UNION ALL SELECT moo, 3*moo FROM mvtest_vt2 +-- +TABLE: name="mv_test2" schema="" table="mv_test2" ctx=DDL +TABLE: name="mvtest_vt2" schema="" table="mvtest_vt2" ctx=Select +TABLE: name="mvtest_vt2" schema="" table="mvtest_vt2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 064 +CREATE MATERIALIZED VIEW mv_test3 AS SELECT * FROM mv_test2 WHERE moo = 12345 +-- +TABLE: name="mv_test3" schema="" table="mv_test3" ctx=DDL +TABLE: name="mv_test2" schema="" table="mv_test2" ctx=Select +FILTER: schema="" table="" column="moo" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 065 +SELECT relispopulated FROM pg_class WHERE oid = 'mv_test3'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 066 +DROP VIEW mvtest_vt1 CASCADE +-- +STMT: DropStmt +== 067 +-- test that duplicate values on unique index prevent refresh +CREATE TABLE mvtest_foo(a, b) AS VALUES(1, 10) +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 068 +CREATE MATERIALIZED VIEW mvtest_mv AS SELECT * FROM mvtest_foo +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 069 +CREATE UNIQUE INDEX ON mvtest_mv(a) +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: IndexStmt +== 070 +INSERT INTO mvtest_foo SELECT * FROM mvtest_foo +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DML +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 071 +REFRESH MATERIALIZED VIEW mvtest_mv +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: RefreshMatViewStmt +== 072 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: RefreshMatViewStmt +== 073 +DROP TABLE mvtest_foo CASCADE +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DDL +STMT: DropStmt +== 074 +-- make sure that all columns covered by unique indexes works +CREATE TABLE mvtest_foo(a, b, c) AS VALUES(1, 2, 3) +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 075 +CREATE MATERIALIZED VIEW mvtest_mv AS SELECT * FROM mvtest_foo +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 076 +CREATE UNIQUE INDEX ON mvtest_mv (a) +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: IndexStmt +== 077 +CREATE UNIQUE INDEX ON mvtest_mv (b) +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: IndexStmt +== 078 +CREATE UNIQUE INDEX on mvtest_mv (c) +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: IndexStmt +== 079 +INSERT INTO mvtest_foo VALUES(2, 3, 4) +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +INSERT INTO mvtest_foo VALUES(3, 4, 5) +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +REFRESH MATERIALIZED VIEW mvtest_mv +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: RefreshMatViewStmt +== 082 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: RefreshMatViewStmt +== 083 +DROP TABLE mvtest_foo CASCADE +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DDL +STMT: DropStmt +== 084 +-- allow subquery to reference unpopulated matview if WITH NO DATA is specified +CREATE MATERIALIZED VIEW mvtest_mv1 AS SELECT 1 AS col1 WITH NO DATA +-- +TABLE: name="mvtest_mv1" schema="" table="mvtest_mv1" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 085 +CREATE MATERIALIZED VIEW mvtest_mv2 AS SELECT * FROM mvtest_mv1 + WHERE col1 = (SELECT LEAST(col1) FROM mvtest_mv1) WITH NO DATA +-- +TABLE: name="mvtest_mv2" schema="" table="mvtest_mv2" ctx=DDL +TABLE: name="mvtest_mv1" schema="" table="mvtest_mv1" ctx=Select +TABLE: name="mvtest_mv1" schema="" table="mvtest_mv1" ctx=Select +FILTER: schema="" table="" column="col1" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 086 +DROP MATERIALIZED VIEW mvtest_mv1 CASCADE +-- +STMT: DropStmt +== 087 +-- make sure that types with unusual equality tests work +CREATE TABLE mvtest_boxes (id serial primary key, b box) +-- +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=DDL +STMT: CreateStmt +== 088 +INSERT INTO mvtest_boxes (b) VALUES + ('(32,32),(31,31)'), + ('(2.0000004,2.0000004),(1,1)'), + ('(1.9999996,1.9999996),(1,1)') +-- +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +CREATE MATERIALIZED VIEW mvtest_boxmv AS SELECT * FROM mvtest_boxes +-- +TABLE: name="mvtest_boxmv" schema="" table="mvtest_boxmv" ctx=DDL +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 090 +CREATE UNIQUE INDEX mvtest_boxmv_id ON mvtest_boxmv (id) +-- +TABLE: name="mvtest_boxmv" schema="" table="mvtest_boxmv" ctx=DDL +STMT: IndexStmt +== 091 +UPDATE mvtest_boxes SET b = '(2,2),(1,1)' WHERE id = 2 +-- +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=DML +STMT: UpdateStmt +== 092 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_boxmv +-- +TABLE: name="mvtest_boxmv" schema="" table="mvtest_boxmv" ctx=DDL +STMT: RefreshMatViewStmt +== 093 +SELECT * FROM mvtest_boxmv ORDER BY id +-- +TABLE: name="mvtest_boxmv" schema="" table="mvtest_boxmv" ctx=Select +STMT: SelectStmt +== 094 +DROP TABLE mvtest_boxes CASCADE +-- +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=DDL +STMT: DropStmt +== 095 +-- make sure that column names are handled correctly +CREATE TABLE mvtest_v (i int, j int) +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DDL +STMT: CreateStmt +== 096 +CREATE MATERIALIZED VIEW mvtest_mv_v (ii, jj, kk) AS SELECT i, j FROM mvtest_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 097 +-- error +CREATE MATERIALIZED VIEW mvtest_mv_v (ii, jj) AS SELECT i, j FROM mvtest_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 098 +-- ok +CREATE MATERIALIZED VIEW mvtest_mv_v_2 (ii) AS SELECT i, j FROM mvtest_v +-- +TABLE: name="mvtest_mv_v_2" schema="" table="mvtest_mv_v_2" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 099 +-- ok +CREATE MATERIALIZED VIEW mvtest_mv_v_3 (ii, jj, kk) AS SELECT i, j FROM mvtest_v WITH NO DATA +-- +TABLE: name="mvtest_mv_v_3" schema="" table="mvtest_mv_v_3" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 100 +-- error +CREATE MATERIALIZED VIEW mvtest_mv_v_3 (ii, jj) AS SELECT i, j FROM mvtest_v WITH NO DATA +-- +TABLE: name="mvtest_mv_v_3" schema="" table="mvtest_mv_v_3" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 101 +-- ok +CREATE MATERIALIZED VIEW mvtest_mv_v_4 (ii) AS SELECT i, j FROM mvtest_v WITH NO DATA +-- +TABLE: name="mvtest_mv_v_4" schema="" table="mvtest_mv_v_4" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 102 +-- ok +ALTER TABLE mvtest_v RENAME COLUMN i TO x +-- +STMT: RenameStmt +== 103 +INSERT INTO mvtest_v values (1, 2) +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +CREATE UNIQUE INDEX mvtest_mv_v_ii ON mvtest_mv_v (ii) +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +STMT: IndexStmt +== 105 +REFRESH MATERIALIZED VIEW mvtest_mv_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +STMT: RefreshMatViewStmt +== 106 +UPDATE mvtest_v SET j = 3 WHERE x = 1 +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DML +STMT: UpdateStmt +== 107 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +STMT: RefreshMatViewStmt +== 108 +REFRESH MATERIALIZED VIEW mvtest_mv_v_2 +-- +TABLE: name="mvtest_mv_v_2" schema="" table="mvtest_mv_v_2" ctx=DDL +STMT: RefreshMatViewStmt +== 109 +REFRESH MATERIALIZED VIEW mvtest_mv_v_3 +-- +TABLE: name="mvtest_mv_v_3" schema="" table="mvtest_mv_v_3" ctx=DDL +STMT: RefreshMatViewStmt +== 110 +REFRESH MATERIALIZED VIEW mvtest_mv_v_4 +-- +TABLE: name="mvtest_mv_v_4" schema="" table="mvtest_mv_v_4" ctx=DDL +STMT: RefreshMatViewStmt +== 111 +SELECT * FROM mvtest_v +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: SelectStmt +== 112 +SELECT * FROM mvtest_mv_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=Select +STMT: SelectStmt +== 113 +SELECT * FROM mvtest_mv_v_2 +-- +TABLE: name="mvtest_mv_v_2" schema="" table="mvtest_mv_v_2" ctx=Select +STMT: SelectStmt +== 114 +SELECT * FROM mvtest_mv_v_3 +-- +TABLE: name="mvtest_mv_v_3" schema="" table="mvtest_mv_v_3" ctx=Select +STMT: SelectStmt +== 115 +SELECT * FROM mvtest_mv_v_4 +-- +TABLE: name="mvtest_mv_v_4" schema="" table="mvtest_mv_v_4" ctx=Select +STMT: SelectStmt +== 116 +DROP TABLE mvtest_v CASCADE +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DDL +STMT: DropStmt +== 117 +-- Check that unknown literals are converted to "text" in CREATE MATVIEW, +-- so that we don't end up with unknown-type columns. +CREATE MATERIALIZED VIEW mv_unspecified_types AS + SELECT 42 as i, 42.5 as num, 'foo' as u, 'foo'::unknown as u2, null as n +-- +TABLE: name="mv_unspecified_types" schema="" table="mv_unspecified_types" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 118 +SELECT * FROM mv_unspecified_types +-- +TABLE: name="mv_unspecified_types" schema="" table="mv_unspecified_types" ctx=Select +STMT: SelectStmt +== 119 +DROP MATERIALIZED VIEW mv_unspecified_types +-- +STMT: DropStmt +== 120 +-- make sure that create WITH NO DATA does not plan the query (bug #13907) +create materialized view mvtest_error as select 1/0 as x +-- +TABLE: name="mvtest_error" schema="" table="mvtest_error" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 121 +-- fail +create materialized view mvtest_error as select 1/0 as x with no data +-- +TABLE: name="mvtest_error" schema="" table="mvtest_error" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 122 +refresh materialized view mvtest_error +-- +TABLE: name="mvtest_error" schema="" table="mvtest_error" ctx=DDL +STMT: RefreshMatViewStmt +== 123 +-- fail here +drop materialized view mvtest_error +-- +STMT: DropStmt +== 124 +-- make sure that matview rows can be referenced as source rows (bug #9398) +CREATE TABLE mvtest_v AS SELECT generate_series(1,10) AS a +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 125 +CREATE MATERIALIZED VIEW mvtest_mv_v AS SELECT a FROM mvtest_v WHERE a <= 5 +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +FILTER: schema="" table="" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 126 +DELETE FROM mvtest_v WHERE EXISTS ( SELECT * FROM mvtest_mv_v WHERE mvtest_mv_v.a = mvtest_v.a ) +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DML +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=Select +FILTER: schema="" table="mvtest_mv_v" column="a" +FILTER: schema="" table="mvtest_v" column="a" +STMT: DeleteStmt +STMT: SelectStmt +== 127 +SELECT * FROM mvtest_v +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: SelectStmt +== 128 +SELECT * FROM mvtest_mv_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=Select +STMT: SelectStmt +== 129 +DROP TABLE mvtest_v CASCADE +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DDL +STMT: DropStmt +== 130 +-- make sure running as superuser works when MV owned by another role (bug #11208) +CREATE ROLE regress_user_mvtest +-- +STMT: CreateRoleStmt +== 131 +SET ROLE regress_user_mvtest +-- +STMT: VariableSetStmt +== 132 +-- this test case also checks for ambiguity in the queries issued by +-- refresh_by_match_merge(), by choosing column names that intentionally +-- duplicate all the aliases used in those queries +CREATE TABLE mvtest_foo_data AS SELECT i, + i+1 AS tid, + fipshash(random()::text) AS mv, + fipshash(random()::text) AS newdata, + fipshash(random()::text) AS newdata2, + fipshash(random()::text) AS diff + FROM generate_series(1, 10) i +-- +TABLE: name="mvtest_foo_data" schema="" table="mvtest_foo_data" ctx=DDL +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 133 +CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +TABLE: name="mvtest_foo_data" schema="" table="mvtest_foo_data" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 134 +CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +TABLE: name="mvtest_foo_data" schema="" table="mvtest_foo_data" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 135 +CREATE MATERIALIZED VIEW IF NOT EXISTS mvtest_mv_foo AS SELECT * FROM mvtest_foo_data +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +TABLE: name="mvtest_foo_data" schema="" table="mvtest_foo_data" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 136 +CREATE UNIQUE INDEX ON mvtest_mv_foo (i) +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +STMT: IndexStmt +== 137 +RESET ROLE +-- +STMT: VariableSetStmt +== 138 +REFRESH MATERIALIZED VIEW mvtest_mv_foo +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +STMT: RefreshMatViewStmt +== 139 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv_foo +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +STMT: RefreshMatViewStmt +== 140 +DROP OWNED BY regress_user_mvtest CASCADE +-- +STMT: DropOwnedStmt +== 141 +DROP ROLE regress_user_mvtest +-- +STMT: DropRoleStmt +== 142 +-- Concurrent refresh requires a unique index on the materialized +-- view. Test what happens if it's dropped during the refresh. +SET search_path = mvtest_mvschema, public +-- +STMT: VariableSetStmt +== 143 +CREATE OR REPLACE FUNCTION mvtest_drop_the_index() + RETURNS bool AS $$ +BEGIN + EXECUTE 'DROP INDEX IF EXISTS mvtest_mvschema.mvtest_drop_idx'; + RETURN true; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="mvtest_drop_the_index" function="mvtest_drop_the_index" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 144 +CREATE MATERIALIZED VIEW drop_idx_matview AS + SELECT 1 as i WHERE mvtest_drop_the_index() +-- +TABLE: name="drop_idx_matview" schema="" table="drop_idx_matview" ctx=DDL +FUNCTION: name="mvtest_drop_the_index" function="mvtest_drop_the_index" schema="" ctx=Call +FUNCTION: name="mvtest_drop_the_index" function="mvtest_drop_the_index" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 145 +CREATE UNIQUE INDEX mvtest_drop_idx ON drop_idx_matview (i) +-- +TABLE: name="drop_idx_matview" schema="" table="drop_idx_matview" ctx=DDL +STMT: IndexStmt +== 146 +REFRESH MATERIALIZED VIEW CONCURRENTLY drop_idx_matview +-- +TABLE: name="drop_idx_matview" schema="" table="drop_idx_matview" ctx=DDL +STMT: RefreshMatViewStmt +== 147 +DROP MATERIALIZED VIEW drop_idx_matview +-- +STMT: DropStmt +== 148 +-- clean up +RESET search_path +-- +STMT: VariableSetStmt +== 149 +-- make sure that create WITH NO DATA works via SPI +BEGIN +-- +STMT: TransactionStmt +== 150 +CREATE FUNCTION mvtest_func() + RETURNS void AS $$ +BEGIN + CREATE MATERIALIZED VIEW mvtest1 AS SELECT 1 AS x; + CREATE MATERIALIZED VIEW mvtest2 AS SELECT 1 AS x WITH NO DATA; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="mvtest_func" function="mvtest_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 151 +SELECT mvtest_func() +-- +FUNCTION: name="mvtest_func" function="mvtest_func" schema="" ctx=Call +STMT: SelectStmt +== 152 +SELECT * FROM mvtest1 +-- +TABLE: name="mvtest1" schema="" table="mvtest1" ctx=Select +STMT: SelectStmt +== 153 +SELECT * FROM mvtest2 +-- +TABLE: name="mvtest2" schema="" table="mvtest2" ctx=Select +STMT: SelectStmt +== 154 +ROLLBACK +-- +STMT: TransactionStmt +== 155 +-- INSERT privileges if relation owner is not allowed to insert. +CREATE SCHEMA matview_schema +-- +STMT: CreateSchemaStmt +== 156 +CREATE USER regress_matview_user +-- +STMT: CreateRoleStmt +== 157 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_matview_user + REVOKE INSERT ON TABLES FROM regress_matview_user +-- +STMT: AlterDefaultPrivilegesStmt +== 158 +GRANT ALL ON SCHEMA matview_schema TO public +-- +STMT: GrantStmt +== 159 +SET SESSION AUTHORIZATION regress_matview_user +-- +STMT: VariableSetStmt +== 160 +CREATE MATERIALIZED VIEW matview_schema.mv_withdata1 (a) AS + SELECT generate_series(1, 10) WITH DATA +-- +TABLE: name="matview_schema.mv_withdata1" schema="matview_schema" table="mv_withdata1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 161 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW matview_schema.mv_withdata2 (a) AS + SELECT generate_series(1, 10) WITH DATA +-- +TABLE: name="matview_schema.mv_withdata2" schema="matview_schema" table="mv_withdata2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 162 +REFRESH MATERIALIZED VIEW matview_schema.mv_withdata2 +-- +TABLE: name="matview_schema.mv_withdata2" schema="matview_schema" table="mv_withdata2" ctx=DDL +STMT: RefreshMatViewStmt +== 163 +CREATE MATERIALIZED VIEW matview_schema.mv_nodata1 (a) AS + SELECT generate_series(1, 10) WITH NO DATA +-- +TABLE: name="matview_schema.mv_nodata1" schema="matview_schema" table="mv_nodata1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 164 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW matview_schema.mv_nodata2 (a) AS + SELECT generate_series(1, 10) WITH NO DATA +-- +TABLE: name="matview_schema.mv_nodata2" schema="matview_schema" table="mv_nodata2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 165 +REFRESH MATERIALIZED VIEW matview_schema.mv_nodata2 +-- +TABLE: name="matview_schema.mv_nodata2" schema="matview_schema" table="mv_nodata2" ctx=DDL +STMT: RefreshMatViewStmt +== 166 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 167 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_matview_user + GRANT INSERT ON TABLES TO regress_matview_user +-- +STMT: AlterDefaultPrivilegesStmt +== 168 +DROP SCHEMA matview_schema CASCADE +-- +STMT: DropStmt +== 169 +DROP USER regress_matview_user +-- +STMT: DropRoleStmt +== 170 +-- CREATE MATERIALIZED VIEW ... IF NOT EXISTS +CREATE MATERIALIZED VIEW matview_ine_tab AS SELECT 1 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 171 +CREATE MATERIALIZED VIEW matview_ine_tab AS SELECT 1 / 0 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 172 +-- error +CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS + SELECT 1 / 0 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 173 +-- ok +CREATE MATERIALIZED VIEW matview_ine_tab AS + SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 174 +-- error +CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS + SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 175 +-- ok +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW matview_ine_tab AS + SELECT 1 / 0 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 176 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS + SELECT 1 / 0 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 177 +-- ok +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW matview_ine_tab AS + SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 178 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS + SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 179 +-- ok +DROP MATERIALIZED VIEW matview_ine_tab +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/md5.metadata.json b/parser/testdata/summary/postgres_regress/md5.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/md5.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/md5.test b/parser/testdata/summary/postgres_regress/md5.test new file mode 100644 index 0000000..b2adffc --- /dev/null +++ b/parser/testdata/summary/postgres_regress/md5.test @@ -0,0 +1,79 @@ +== 001 +|-- +-- MD5 test suite - from IETF RFC 1321 +-- (see: https://www.rfc-editor.org/rfc/rfc1321) +|-- + +-- (The md5() function will error in OpenSSL FIPS mode. By keeping +-- this test in a separate file, it is easier to manage variant +-- results.) + +select md5('') = 'd41d8cd98f00b204e9800998ecf8427e' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 002 +select md5('a') = '0cc175b9c0f1b6a831c399e269772661' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 003 +select md5('abc') = '900150983cd24fb0d6963f7d28e17f72' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 004 +select md5('message digest') = 'f96b697d7cb7938d525a2f31aaf161d0' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 005 +select md5('abcdefghijklmnopqrstuvwxyz') = 'c3fcd3d76192e4007dfb496cca67e13b' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 006 +select md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') = 'd174ab98d277d9f5a5611c2c9f419d9f' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 007 +select md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890') = '57edf4a22be3c955ac49da2e2107b67a' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 008 +select md5(''::bytea) = 'd41d8cd98f00b204e9800998ecf8427e' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 009 +select md5('a'::bytea) = '0cc175b9c0f1b6a831c399e269772661' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 010 +select md5('abc'::bytea) = '900150983cd24fb0d6963f7d28e17f72' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 011 +select md5('message digest'::bytea) = 'f96b697d7cb7938d525a2f31aaf161d0' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 012 +select md5('abcdefghijklmnopqrstuvwxyz'::bytea) = 'c3fcd3d76192e4007dfb496cca67e13b' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 013 +select md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'::bytea) = 'd174ab98d277d9f5a5611c2c9f419d9f' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +== 014 +select md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890'::bytea) = '57edf4a22be3c955ac49da2e2107b67a' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/memoize.metadata.json b/parser/testdata/summary/postgres_regress/memoize.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/memoize.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/memoize.test b/parser/testdata/summary/postgres_regress/memoize.test new file mode 100644 index 0000000..b1fa272 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/memoize.test @@ -0,0 +1,510 @@ +== 001 +-- Perform tests on the Memoize node. + +-- The cache hits/misses/evictions from the Memoize node can vary between +-- machines. Let's just replace the number with an 'N'. In order to allow us +-- to perform validation when the measure was zero, we replace a zero value +-- with "Zero". All other numbers are replaced with 'N'. +create function explain_memoize(query text, hide_hitmiss bool) returns setof text +language plpgsql as +$$ +declare + ln text; +begin + for ln in + execute format('explain (analyze, costs off, summary off, timing off) %s', + query) + loop + if hide_hitmiss = true then + ln := regexp_replace(ln, 'Hits: 0', 'Hits: Zero'); + ln := regexp_replace(ln, 'Hits: \d+', 'Hits: N'); + ln := regexp_replace(ln, 'Misses: 0', 'Misses: Zero'); + ln := regexp_replace(ln, 'Misses: \d+', 'Misses: N'); + end if; + ln := regexp_replace(ln, 'Evictions: 0', 'Evictions: Zero'); + ln := regexp_replace(ln, 'Evictions: \d+', 'Evictions: N'); + ln := regexp_replace(ln, 'Memory Usage: \d+', 'Memory Usage: N'); + ln := regexp_replace(ln, 'Heap Fetches: \d+', 'Heap Fetches: N'); + ln := regexp_replace(ln, 'loops=\d+', 'loops=N'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +-- Ensure we get a memoize node on the inner side of the nested loop +SET enable_hashjoin TO off +-- +STMT: VariableSetStmt +== 003 +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +== 004 +SELECT explain_memoize(' +SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1 +INNER JOIN tenk1 t2 ON t1.unique1 = t2.twenty +WHERE t2.unique1 < 1000;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 005 +-- And check we get the expected results. +SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1 +INNER JOIN tenk1 t2 ON t1.unique1 = t2.twenty +WHERE t2.unique1 < 1000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t2" column="unique1" +STMT: SelectStmt +== 006 +-- Try with LATERAL joins +SELECT explain_memoize(' +SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1, +LATERAL (SELECT t2.unique1 FROM tenk1 t2 + WHERE t1.twenty = t2.unique1 OFFSET 0) t2 +WHERE t1.unique1 < 1000;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- And check we get the expected results. +SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1, +LATERAL (SELECT t2.unique1 FROM tenk1 t2 + WHERE t1.twenty = t2.unique1 OFFSET 0) t2 +WHERE t1.unique1 < 1000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t2" column="unique1" +STMT: SelectStmt +== 008 +-- Try with LATERAL joins +SELECT explain_memoize(' +SELECT COUNT(*),AVG(t2.t1two) FROM tenk1 t1 LEFT JOIN +LATERAL ( + SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 4 OFFSET 0 +) t2 +ON t1.two = t2.two +WHERE t1.unique1 < 10;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- And check we get the expected results. +SELECT COUNT(*),AVG(t2.t1two) FROM tenk1 t1 LEFT JOIN +LATERAL ( + SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 4 OFFSET 0 +) t2 +ON t1.two = t2.two +WHERE t1.unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t2" column="unique1" +STMT: SelectStmt +== 010 +SET enable_mergejoin TO off +-- +STMT: VariableSetStmt +== 011 +-- Test for varlena datatype with expr evaluation +CREATE TABLE expr_key (x numeric, t text) +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DDL +STMT: CreateStmt +== 012 +INSERT INTO expr_key (x, t) +SELECT d1::numeric, d1::text FROM ( + SELECT round((d / pi())::numeric, 7) AS d1 FROM generate_series(1, 20) AS d +) t +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DML +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="pi" function="pi" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 013 +-- duplicate rows so we get some cache hits +INSERT INTO expr_key SELECT * FROM expr_key +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DML +TABLE: name="expr_key" schema="" table="expr_key" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 014 +CREATE INDEX expr_key_idx_x_t ON expr_key (x, t) +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DDL +STMT: IndexStmt +== 015 +VACUUM ANALYZE expr_key +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DDL +STMT: VacuumStmt +== 016 +-- Ensure we get we get a cache miss and hit for each of the 20 distinct values +SELECT explain_memoize(' +SELECT * FROM expr_key t1 INNER JOIN expr_key t2 +ON t1.x = t2.t::numeric AND t1.t::numeric = t2.x;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 017 +DROP TABLE expr_key +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DDL +STMT: DropStmt +== 018 +-- Reduce work_mem and hash_mem_multiplier so that we see some cache evictions +SET work_mem TO '64kB' +-- +STMT: VariableSetStmt +== 019 +SET hash_mem_multiplier TO 1.0 +-- +STMT: VariableSetStmt +== 020 +-- Ensure we get some evictions. We're unable to validate the hits and misses +-- here as the number of entries that fit in the cache at once will vary +-- between different machines. +SELECT explain_memoize(' +SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1 +INNER JOIN tenk1 t2 ON t1.unique1 = t2.thousand +WHERE t2.unique1 < 1200;', true) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 021 +CREATE TABLE flt (f float) +-- +TABLE: name="flt" schema="" table="flt" ctx=DDL +STMT: CreateStmt +== 022 +CREATE INDEX flt_f_idx ON flt (f) +-- +TABLE: name="flt" schema="" table="flt" ctx=DDL +STMT: IndexStmt +== 023 +INSERT INTO flt VALUES('-0.0'::float),('+0.0'::float) +-- +TABLE: name="flt" schema="" table="flt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +ANALYZE flt +-- +TABLE: name="flt" schema="" table="flt" ctx=DDL +STMT: VacuumStmt +== 025 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +== 026 +-- Ensure memoize operates in logical mode +SELECT explain_memoize(' +SELECT * FROM flt f1 INNER JOIN flt f2 ON f1.f = f2.f;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 027 +-- Ensure memoize operates in binary mode +SELECT explain_memoize(' +SELECT * FROM flt f1 INNER JOIN flt f2 ON f1.f >= f2.f;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 028 +DROP TABLE flt +-- +TABLE: name="flt" schema="" table="flt" ctx=DDL +STMT: DropStmt +== 029 +-- Exercise Memoize in binary mode with a large fixed width type and a +-- varlena type. +CREATE TABLE strtest (n name, t text) +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: CreateStmt +== 030 +CREATE INDEX strtest_n_idx ON strtest (n) +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: IndexStmt +== 031 +CREATE INDEX strtest_t_idx ON strtest (t) +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: IndexStmt +== 032 +INSERT INTO strtest VALUES('one','one'),('two','two'),('three',repeat(fipshash('three'),100)) +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 033 +-- duplicate rows so we get some cache hits +INSERT INTO strtest SELECT * FROM strtest +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DML +TABLE: name="strtest" schema="" table="strtest" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 034 +ANALYZE strtest +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: VacuumStmt +== 035 +-- Ensure we get 3 hits and 3 misses +SELECT explain_memoize(' +SELECT * FROM strtest s1 INNER JOIN strtest s2 ON s1.n >= s2.n;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- Ensure we get 3 hits and 3 misses +SELECT explain_memoize(' +SELECT * FROM strtest s1 INNER JOIN strtest s2 ON s1.t >= s2.t;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 037 +DROP TABLE strtest +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: DropStmt +== 038 +-- Ensure memoize works with partitionwise join +SET enable_partitionwise_join TO on +-- +STMT: VariableSetStmt +== 039 +CREATE TABLE prt (a int) PARTITION BY RANGE(a) +-- +TABLE: name="prt" schema="" table="prt" ctx=DDL +STMT: CreateStmt +== 040 +CREATE TABLE prt_p1 PARTITION OF prt FOR VALUES FROM (0) TO (10) +-- +TABLE: name="prt_p1" schema="" table="prt_p1" ctx=DDL +STMT: CreateStmt +== 041 +CREATE TABLE prt_p2 PARTITION OF prt FOR VALUES FROM (10) TO (20) +-- +TABLE: name="prt_p2" schema="" table="prt_p2" ctx=DDL +STMT: CreateStmt +== 042 +INSERT INTO prt VALUES (0), (0), (0), (0) +-- +TABLE: name="prt" schema="" table="prt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO prt VALUES (10), (10), (10), (10) +-- +TABLE: name="prt" schema="" table="prt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +CREATE INDEX iprt_p1_a ON prt_p1 (a) +-- +TABLE: name="prt_p1" schema="" table="prt_p1" ctx=DDL +STMT: IndexStmt +== 045 +CREATE INDEX iprt_p2_a ON prt_p2 (a) +-- +TABLE: name="prt_p2" schema="" table="prt_p2" ctx=DDL +STMT: IndexStmt +== 046 +ANALYZE prt +-- +TABLE: name="prt" schema="" table="prt" ctx=DDL +STMT: VacuumStmt +== 047 +SELECT explain_memoize(' +SELECT * FROM prt t1 INNER JOIN prt t2 ON t1.a = t2.a;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 048 +-- Ensure memoize works with parameterized union-all Append path +SET enable_partitionwise_join TO off +-- +STMT: VariableSetStmt +== 049 +SELECT explain_memoize(' +SELECT * FROM prt_p1 t1 INNER JOIN +(SELECT * FROM prt_p1 UNION ALL SELECT * FROM prt_p2) t2 +ON t1.a = t2.a;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +== 050 +DROP TABLE prt +-- +TABLE: name="prt" schema="" table="prt" ctx=DDL +STMT: DropStmt +== 051 +RESET enable_partitionwise_join +-- +STMT: VariableSetStmt +== 052 +-- Exercise Memoize code that flushes the cache when a parameter changes which +-- is not part of the cache key. + +-- Ensure we get a Memoize plan +EXPLAIN (COSTS OFF) +SELECT unique1 FROM tenk1 t0 +WHERE unique1 < 3 + AND EXISTS ( + SELECT 1 FROM tenk1 t1 + INNER JOIN tenk1 t2 ON t1.unique1 = t2.hundred + WHERE t0.ten = t1.twenty AND t0.two <> t2.four OFFSET 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t0"="tenk1" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="t0" column="ten" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t0" column="two" +FILTER: schema="" table="t2" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 053 +-- Ensure the above query returns the correct result +SELECT unique1 FROM tenk1 t0 +WHERE unique1 < 3 + AND EXISTS ( + SELECT 1 FROM tenk1 t1 + INNER JOIN tenk1 t2 ON t1.unique1 = t2.hundred + WHERE t0.ten = t1.twenty AND t0.two <> t2.four OFFSET 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t0"="tenk1" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="t0" column="ten" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t0" column="two" +FILTER: schema="" table="t2" column="four" +STMT: SelectStmt +== 054 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 055 +RESET enable_mergejoin +-- +STMT: VariableSetStmt +== 056 +RESET work_mem +-- +STMT: VariableSetStmt +== 057 +RESET hash_mem_multiplier +-- +STMT: VariableSetStmt +== 058 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 059 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +== 060 +-- Test parallel plans with Memoize +SET min_parallel_table_scan_size TO 0 +-- +STMT: VariableSetStmt +== 061 +SET parallel_setup_cost TO 0 +-- +STMT: VariableSetStmt +== 062 +SET parallel_tuple_cost TO 0 +-- +STMT: VariableSetStmt +== 063 +SET max_parallel_workers_per_gather TO 2 +-- +STMT: VariableSetStmt +== 064 +-- Ensure we get a parallel plan. +EXPLAIN (COSTS OFF) +SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1, +LATERAL (SELECT t2.unique1 FROM tenk1 t2 WHERE t1.twenty = t2.unique1) t2 +WHERE t1.unique1 < 1000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t2" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 065 +-- And ensure the parallel plan gives us the correct results. +SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1, +LATERAL (SELECT t2.unique1 FROM tenk1 t2 WHERE t1.twenty = t2.unique1) t2 +WHERE t1.unique1 < 1000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t2" column="unique1" +STMT: SelectStmt +== 066 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +== 067 +RESET parallel_tuple_cost +-- +STMT: VariableSetStmt +== 068 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +== 069 +RESET min_parallel_table_scan_size +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/merge.metadata.json b/parser/testdata/summary/postgres_regress/merge.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/merge.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/merge.test b/parser/testdata/summary/postgres_regress/merge.test new file mode 100644 index 0000000..15bb434 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/merge.test @@ -0,0 +1,4075 @@ +== 001 +|-- +-- MERGE +|-- + +CREATE USER regress_merge_privs +-- +STMT: CreateRoleStmt +== 002 +CREATE USER regress_merge_no_privs +-- +STMT: CreateRoleStmt +== 003 +CREATE USER regress_merge_none +-- +STMT: CreateRoleStmt +== 004 +DROP TABLE IF EXISTS target +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: DropStmt +== 005 +DROP TABLE IF EXISTS source +-- +TABLE: name="source" schema="" table="source" ctx=DDL +STMT: DropStmt +== 006 +CREATE TABLE target (tid integer, balance integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateStmt +== 007 +CREATE TABLE source (sid integer, delta integer) -- no index + WITH (autovacuum_enabled=off) +-- +TABLE: name="source" schema="" table="source" ctx=DDL +STMT: CreateStmt +== 008 +INSERT INTO target VALUES (1, 10) +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO target VALUES (2, 20) +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO target VALUES (3, 30) +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +SELECT t.ctid is not null as matched, t.*, s.* FROM source s FULL OUTER JOIN target t ON s.sid = t.tid ORDER BY t.tid, s.sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +TABLE: name="target" schema="" table="target" ctx=Select +ALIAS: "s"="source" +ALIAS: "t"="target" +STMT: SelectStmt +== 012 +ALTER TABLE target OWNER TO regress_merge_privs +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: AlterTableStmt +== 013 +ALTER TABLE source OWNER TO regress_merge_privs +-- +TABLE: name="source" schema="" table="source" ctx=DDL +STMT: AlterTableStmt +== 014 +CREATE TABLE target2 (tid integer, balance integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="target2" schema="" table="target2" ctx=DDL +STMT: CreateStmt +== 015 +CREATE TABLE source2 (sid integer, delta integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="source2" schema="" table="source2" ctx=DDL +STMT: CreateStmt +== 016 +ALTER TABLE target2 OWNER TO regress_merge_no_privs +-- +TABLE: name="target2" schema="" table="target2" ctx=DDL +STMT: AlterTableStmt +== 017 +ALTER TABLE source2 OWNER TO regress_merge_no_privs +-- +TABLE: name="source2" schema="" table="source2" ctx=DDL +STMT: AlterTableStmt +== 018 +GRANT INSERT ON target TO regress_merge_no_privs +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: GrantStmt +== 019 +SET SESSION AUTHORIZATION regress_merge_privs +-- +STMT: VariableSetStmt +== 020 +EXPLAIN (COSTS OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: ExplainStmt +STMT: MergeStmt +== 021 +|-- +-- Errors +|-- +MERGE INTO target t RANDOMWORD +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +ERROR: syntax error at or near "RANDOMWORD" +CURSORPOS: 37 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 022 +-- MATCHED/INSERT error +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + INSERT DEFAULT VALUES +-- +ERROR: syntax error at or near "INSERT" +CURSORPOS: 99 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 023 +-- NOT MATCHED BY SOURCE/INSERT error +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED BY SOURCE THEN + INSERT DEFAULT VALUES +-- +ERROR: syntax error at or near "INSERT" +CURSORPOS: 127 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 024 +-- incorrectly specifying INTO target +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT INTO target DEFAULT VALUES +-- +ERROR: syntax error at or near "INTO" +CURSORPOS: 124 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 025 +-- Multiple VALUES clause +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (1,1), (2,2) +-- +ERROR: syntax error at or near "," +CURSORPOS: 124 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 026 +-- SELECT query for INSERT +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT SELECT (1, 1) +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 113 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 027 +-- NOT MATCHED/UPDATE +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + UPDATE SET balance = 0 +-- +ERROR: syntax error at or near "UPDATE" +CURSORPOS: 101 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 028 +-- NOT MATCHED BY TARGET/UPDATE +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED BY TARGET THEN + UPDATE SET balance = 0 +-- +ERROR: syntax error at or near "UPDATE" +CURSORPOS: 121 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 029 +-- UPDATE tablename +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE target SET balance = 0 +-- +ERROR: syntax error at or near "target" +CURSORPOS: 102 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 030 +-- source and target names the same +MERGE INTO target +USING target +ON tid = tid +WHEN MATCHED THEN DO NOTHING +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +== 031 +-- used in a CTE without RETURNING +WITH foo AS ( + MERGE INTO target USING source ON (true) + WHEN MATCHED THEN DELETE +) SELECT * FROM foo +-- +TABLE: name="target" schema="" table="target" ctx=DML +CTE: "foo" +STMT: SelectStmt +STMT: MergeStmt +== 032 +-- used in COPY without RETURNING +COPY ( + MERGE INTO target USING source ON (true) + WHEN MATCHED THEN DELETE +) TO stdout +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: CopyStmt +== 033 +-- unsupported relation types +-- materialized view +CREATE MATERIALIZED VIEW mv AS SELECT * FROM target +-- +TABLE: name="mv" schema="" table="mv" ctx=DDL +TABLE: name="target" schema="" table="target" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 034 +MERGE INTO mv t +USING source s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="mv" schema="" table="mv" ctx=DML +ALIAS: "t"="mv" +STMT: MergeStmt +== 035 +DROP MATERIALIZED VIEW mv +-- +STMT: DropStmt +== 036 +-- permissions + +SET SESSION AUTHORIZATION regress_merge_none +-- +STMT: VariableSetStmt +== 037 +MERGE INTO target +USING (SELECT 1) +ON true +WHEN MATCHED THEN + DO NOTHING +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +STMT: SelectStmt +== 038 +SET SESSION AUTHORIZATION regress_merge_privs +-- +STMT: VariableSetStmt +== 039 +MERGE INTO target +USING source2 +ON target.tid = source2.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +== 040 +GRANT INSERT ON target TO regress_merge_no_privs +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: GrantStmt +== 041 +SET SESSION AUTHORIZATION regress_merge_no_privs +-- +STMT: VariableSetStmt +== 042 +MERGE INTO target +USING source2 +ON target.tid = source2.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +== 043 +GRANT UPDATE ON target2 TO regress_merge_privs +-- +TABLE: name="target2" schema="" table="target2" ctx=DDL +STMT: GrantStmt +== 044 +SET SESSION AUTHORIZATION regress_merge_privs +-- +STMT: VariableSetStmt +== 045 +MERGE INTO target2 +USING source +ON target2.tid = source.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target2" schema="" table="target2" ctx=DML +STMT: MergeStmt +== 046 +MERGE INTO target2 +USING source +ON target2.tid = source.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="target2" schema="" table="target2" ctx=DML +STMT: MergeStmt +== 047 +-- check if the target can be accessed from source relation subquery; we should +-- not be able to do so +MERGE INTO target t +USING (SELECT * FROM source WHERE t.tid > sid) s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="source" schema="" table="source" ctx=Select +ALIAS: "t"="target" +FILTER: schema="" table="t" column="tid" +FILTER: schema="" table="" column="sid" +STMT: MergeStmt +STMT: SelectStmt +== 048 +|-- +-- initial tests +|-- +-- zero rows in source has no effect +MERGE INTO target +USING source +ON target.tid = source.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +== 049 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 050 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 051 +BEGIN +-- +STMT: TransactionStmt +== 052 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 053 +ROLLBACK +-- +STMT: TransactionStmt +== 054 +-- insert some non-matching source rows to work from +INSERT INTO source VALUES (4, 40) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +== 056 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 057 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + DO NOTHING +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 058 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 059 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 060 +BEGIN +-- +STMT: TransactionStmt +== 061 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 062 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 063 +ROLLBACK +-- +STMT: TransactionStmt +== 064 +-- DELETE/INSERT not matched by source/target +BEGIN +-- +STMT: TransactionStmt +== 065 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED BY SOURCE THEN + DELETE +WHEN NOT MATCHED BY TARGET THEN + INSERT VALUES (s.sid, s.delta) +RETURNING merge_action(), t.* +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 066 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 067 +ROLLBACK +-- +STMT: TransactionStmt +== 068 +-- index plans +INSERT INTO target SELECT generate_series(1000,2500), 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 069 +ALTER TABLE target ADD PRIMARY KEY (tid) +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: AlterTableStmt +== 070 +ANALYZE target +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: VacuumStmt +== 071 +EXPLAIN (COSTS OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: ExplainStmt +STMT: MergeStmt +== 072 +EXPLAIN (COSTS OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: ExplainStmt +STMT: MergeStmt +== 073 +EXPLAIN (COSTS OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (4, NULL) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: ExplainStmt +STMT: MergeStmt +== 074 +DELETE FROM target WHERE tid > 100 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: DeleteStmt +== 075 +ANALYZE target +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: VacuumStmt +== 076 +-- insert some matching source rows to work from +INSERT INTO source VALUES (2, 5) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +INSERT INTO source VALUES (3, 20) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +== 079 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 080 +-- equivalent of an UPDATE join +BEGIN +-- +STMT: TransactionStmt +== 081 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 082 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 083 +ROLLBACK +-- +STMT: TransactionStmt +== 084 +-- equivalent of a DELETE join +BEGIN +-- +STMT: TransactionStmt +== 085 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 086 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 087 +ROLLBACK +-- +STMT: TransactionStmt +== 088 +BEGIN +-- +STMT: TransactionStmt +== 089 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DO NOTHING +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 090 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 091 +ROLLBACK +-- +STMT: TransactionStmt +== 092 +BEGIN +-- +STMT: TransactionStmt +== 093 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (4, NULL) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 094 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 095 +ROLLBACK +-- +STMT: TransactionStmt +== 096 +-- duplicate source row causes multiple target row update ERROR +INSERT INTO source VALUES (2, 5) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +== 098 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 099 +BEGIN +-- +STMT: TransactionStmt +== 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 101 +ROLLBACK +-- +STMT: TransactionStmt +== 102 +BEGIN +-- +STMT: TransactionStmt +== 103 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 104 +ROLLBACK +-- +STMT: TransactionStmt +== 105 +-- remove duplicate MATCHED data from source data +DELETE FROM source WHERE sid = 2 +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: DeleteStmt +== 106 +INSERT INTO source VALUES (2, 5) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +== 108 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 109 +-- duplicate source row on INSERT should fail because of target_pkey +INSERT INTO source VALUES (4, 40) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +BEGIN +-- +STMT: TransactionStmt +== 111 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (4, NULL) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 112 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 113 +ROLLBACK +-- +STMT: TransactionStmt +== 114 +-- remove duplicate NOT MATCHED data from source data +DELETE FROM source WHERE sid = 4 +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: DeleteStmt +== 115 +INSERT INTO source VALUES (4, 40) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +== 117 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 118 +-- remove constraints +alter table target drop CONSTRAINT target_pkey +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: AlterTableStmt +== 119 +alter table target alter column tid drop not null +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: AlterTableStmt +== 120 +-- multiple actions +BEGIN +-- +STMT: TransactionStmt +== 121 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (4, 4) +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 122 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 123 +ROLLBACK +-- +STMT: TransactionStmt +== 124 +-- should be equivalent +BEGIN +-- +STMT: TransactionStmt +== 125 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +WHEN NOT MATCHED THEN + INSERT VALUES (4, 4) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 126 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 127 +ROLLBACK +-- +STMT: TransactionStmt +== 128 +-- column references +-- do a simple equivalent of an UPDATE join +BEGIN +-- +STMT: TransactionStmt +== 129 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = t.balance + s.delta +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 130 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 131 +ROLLBACK +-- +STMT: TransactionStmt +== 132 +-- do a simple equivalent of an INSERT SELECT +BEGIN +-- +STMT: TransactionStmt +== 133 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 134 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 135 +ROLLBACK +-- +STMT: TransactionStmt +== 136 +-- and again with duplicate source rows +INSERT INTO source VALUES (5, 50) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +INSERT INTO source VALUES (5, 50) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +-- do a simple equivalent of an INSERT SELECT +BEGIN +-- +STMT: TransactionStmt +== 139 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 140 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 141 +ROLLBACK +-- +STMT: TransactionStmt +== 142 +-- removing duplicate source rows +DELETE FROM source WHERE sid = 5 +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: DeleteStmt +== 143 +-- and again with explicitly identified column list +BEGIN +-- +STMT: TransactionStmt +== 144 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 145 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 146 +ROLLBACK +-- +STMT: TransactionStmt +== 147 +-- and again with a subtle error: referring to non-existent target row for NOT MATCHED +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (t.tid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 148 +-- and again with a constant ON clause +BEGIN +-- +STMT: TransactionStmt +== 149 +MERGE INTO target t +USING source AS s +ON (SELECT true) +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (t.tid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +STMT: SelectStmt +== 150 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 151 +ROLLBACK +-- +STMT: TransactionStmt +== 152 +-- now the classic UPSERT +BEGIN +-- +STMT: TransactionStmt +== 153 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = t.balance + s.delta +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 154 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 155 +ROLLBACK +-- +STMT: TransactionStmt +== 156 +-- unreachable WHEN clause should ERROR +BEGIN +-- +STMT: TransactionStmt +== 157 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN /* Terminal WHEN clause for MATCHED */ + DELETE +WHEN MATCHED THEN + UPDATE SET balance = t.balance - s.delta +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 158 +ROLLBACK +-- +STMT: TransactionStmt +== 159 +-- conditional WHEN clause +CREATE TABLE wq_target (tid integer not null, balance integer DEFAULT -1) + WITH (autovacuum_enabled=off) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DDL +STMT: CreateStmt +== 160 +CREATE TABLE wq_source (balance integer, sid integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="wq_source" schema="" table="wq_source" ctx=DDL +STMT: CreateStmt +== 161 +INSERT INTO wq_source (sid, balance) VALUES (1, 100) +-- +TABLE: name="wq_source" schema="" table="wq_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 162 +BEGIN +-- +STMT: TransactionStmt +== 163 +-- try a simple INSERT with default values first +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 164 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 165 +ROLLBACK +-- +STMT: TransactionStmt +== 166 +-- this time with a FALSE condition +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND FALSE THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 167 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 168 +-- this time with an actual condition which returns false +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND s.balance <> 100 THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 169 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 170 +BEGIN +-- +STMT: TransactionStmt +== 171 +-- and now with a condition which returns true +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND s.balance = 100 THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 172 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 173 +ROLLBACK +-- +STMT: TransactionStmt +== 174 +-- conditions in the NOT MATCHED clause can only refer to source columns +BEGIN +-- +STMT: TransactionStmt +== 175 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND t.balance = 100 THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 176 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 177 +ROLLBACK +-- +STMT: TransactionStmt +== 178 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND s.balance = 100 THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 179 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 180 +-- conditions in NOT MATCHED BY SOURCE clause can only refer to target columns +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED BY SOURCE AND s.balance = 100 THEN + DELETE +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 181 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED BY SOURCE AND t.balance = 100 THEN + DELETE +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 182 +-- conditions in MATCHED clause can refer to both source and target +SELECT * FROM wq_source +-- +TABLE: name="wq_source" schema="" table="wq_source" ctx=Select +STMT: SelectStmt +== 183 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND s.balance = 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 184 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 185 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 186 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 187 +-- check if AND works +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 99 AND s.balance > 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 188 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 189 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 99 AND s.balance = 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 190 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 191 +-- check if OR works +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 99 OR s.balance > 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 192 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 193 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 199 OR s.balance > 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 194 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 195 +-- check source-side whole-row references +BEGIN +-- +STMT: TransactionStmt +== 196 +MERGE INTO wq_target t +USING wq_source s ON (t.tid = s.sid) +WHEN matched and t = s or t.tid = s.sid THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 197 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 198 +ROLLBACK +-- +STMT: TransactionStmt +== 199 +-- check if subqueries work in the conditions? +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance > (SELECT max(balance) FROM target) THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +TABLE: name="target" schema="" table="target" ctx=Select +ALIAS: "t"="wq_target" +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 200 +-- check if we can access system columns in the conditions +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.xmin = t.xmax THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 201 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.tableoid >= 0 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +== 202 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +== 203 +DROP TABLE wq_target, wq_source +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DDL +TABLE: name="wq_source" schema="" table="wq_source" ctx=DDL +STMT: DropStmt +== 204 +-- test triggers +create or replace function merge_trigfunc () returns trigger +language plpgsql as +$$ +DECLARE + line text; +BEGIN + SELECT INTO line format('%s %s %s trigger%s', + TG_WHEN, TG_OP, TG_LEVEL, CASE + WHEN TG_OP = 'INSERT' AND TG_LEVEL = 'ROW' + THEN format(' row: %s', NEW) + WHEN TG_OP = 'UPDATE' AND TG_LEVEL = 'ROW' + THEN format(' row: %s -> %s', OLD, NEW) + WHEN TG_OP = 'DELETE' AND TG_LEVEL = 'ROW' + THEN format(' row: %s', OLD) + END); + + RAISE NOTICE '%', line; + IF (TG_WHEN = 'BEFORE' AND TG_LEVEL = 'ROW') THEN + IF (TG_OP = 'DELETE') THEN + RETURN OLD; + ELSE + RETURN NEW; + END IF; + ELSE + RETURN NULL; + END IF; +END; +$$ +-- +FUNCTION: name="merge_trigfunc" function="merge_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 205 +CREATE TRIGGER merge_bsi BEFORE INSERT ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 206 +CREATE TRIGGER merge_bsu BEFORE UPDATE ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 207 +CREATE TRIGGER merge_bsd BEFORE DELETE ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 208 +CREATE TRIGGER merge_asi AFTER INSERT ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 209 +CREATE TRIGGER merge_asu AFTER UPDATE ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 210 +CREATE TRIGGER merge_asd AFTER DELETE ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 211 +CREATE TRIGGER merge_bri BEFORE INSERT ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 212 +CREATE TRIGGER merge_bru BEFORE UPDATE ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 213 +CREATE TRIGGER merge_brd BEFORE DELETE ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 214 +CREATE TRIGGER merge_ari AFTER INSERT ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 215 +CREATE TRIGGER merge_aru AFTER UPDATE ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 216 +CREATE TRIGGER merge_ard AFTER DELETE ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 217 +-- now the classic UPSERT, with a DELETE +BEGIN +-- +STMT: TransactionStmt +== 218 +UPDATE target SET balance = 0 WHERE tid = 3 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: UpdateStmt +== 219 +--EXPLAIN (ANALYZE ON, COSTS OFF, SUMMARY OFF, TIMING OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED AND t.balance > s.delta THEN + UPDATE SET balance = t.balance - s.delta +WHEN MATCHED THEN + DELETE +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 220 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 221 +ROLLBACK +-- +STMT: TransactionStmt +== 222 +-- UPSERT with UPDATE/DELETE when not matched by source +BEGIN +-- +STMT: TransactionStmt +== 223 +DELETE FROM SOURCE WHERE sid = 2 +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: DeleteStmt +== 224 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED AND t.balance > s.delta THEN + UPDATE SET balance = t.balance - s.delta +WHEN MATCHED THEN + UPDATE SET balance = 0 +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +WHEN NOT MATCHED BY SOURCE AND tid = 1 THEN + UPDATE SET balance = 0 +WHEN NOT MATCHED BY SOURCE THEN + DELETE +RETURNING merge_action(), t.* +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +== 225 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 226 +ROLLBACK +-- +STMT: TransactionStmt +== 227 +-- Test behavior of triggers that turn UPDATE/DELETE into no-ops +create or replace function skip_merge_op() returns trigger +language plpgsql as +$$ +BEGIN + RETURN NULL; +END; +$$ +-- +FUNCTION: name="skip_merge_op" function="skip_merge_op" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 228 +SELECT * FROM target full outer join source on (sid = tid) +-- +TABLE: name="target" schema="" table="target" ctx=Select +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +== 229 +create trigger merge_skip BEFORE INSERT OR UPDATE or DELETE + ON target FOR EACH ROW EXECUTE FUNCTION skip_merge_op() +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +== 230 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED AND s.sid = 3 THEN UPDATE SET balance = t.balance + s.delta +WHEN MATCHED THEN DELETE +WHEN NOT MATCHED THEN INSERT VALUES (sid, delta); +IF FOUND THEN + RAISE NOTICE 'Found'; +ELSE + RAISE NOTICE 'Not found'; +END IF; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +== 231 +SELECT * FROM target FULL OUTER JOIN source ON (sid = tid) +-- +TABLE: name="target" schema="" table="target" ctx=Select +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +== 232 +DROP TRIGGER merge_skip ON target +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: DropStmt +== 233 +DROP FUNCTION skip_merge_op() +-- +FUNCTION: name="skip_merge_op" function="skip_merge_op" schema="" ctx=DDL +STMT: DropStmt +== 234 +-- test from PL/pgSQL +-- make sure MERGE INTO isn't interpreted to mean returning variables like SELECT INTO +BEGIN +-- +STMT: TransactionStmt +== 235 +DO LANGUAGE plpgsql $$ +BEGIN +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED AND t.balance > s.delta THEN + UPDATE SET balance = t.balance - s.delta; +END; +$$ +-- +STMT: DoStmt +== 236 +ROLLBACK +-- +STMT: TransactionStmt +== 237 +--source constants +BEGIN +-- +STMT: TransactionStmt +== 238 +MERGE INTO target t +USING (SELECT 9 AS sid, 57 AS delta) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +STMT: SelectStmt +== 239 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 240 +ROLLBACK +-- +STMT: TransactionStmt +== 241 +--source query +BEGIN +-- +STMT: TransactionStmt +== 242 +MERGE INTO target t +USING (SELECT sid, delta FROM source WHERE delta > 0) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="source" schema="" table="source" ctx=Select +ALIAS: "t"="target" +FILTER: schema="" table="" column="delta" +STMT: MergeStmt +STMT: SelectStmt +== 243 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 244 +ROLLBACK +-- +STMT: TransactionStmt +== 245 +BEGIN +-- +STMT: TransactionStmt +== 246 +MERGE INTO target t +USING (SELECT sid, delta as newname FROM source WHERE delta > 0) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.newname) +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="source" schema="" table="source" ctx=Select +ALIAS: "t"="target" +FILTER: schema="" table="" column="delta" +STMT: MergeStmt +STMT: SelectStmt +== 247 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 248 +ROLLBACK +-- +STMT: TransactionStmt +== 249 +--self-merge +BEGIN +-- +STMT: TransactionStmt +== 250 +MERGE INTO target t1 +USING target t2 +ON t1.tid = t2.tid +WHEN MATCHED THEN + UPDATE SET balance = t1.balance + t2.balance +WHEN NOT MATCHED THEN + INSERT VALUES (t2.tid, t2.balance) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t1"="target" +STMT: MergeStmt +== 251 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 252 +ROLLBACK +-- +STMT: TransactionStmt +== 253 +BEGIN +-- +STMT: TransactionStmt +== 254 +MERGE INTO target t +USING (SELECT tid as sid, balance as delta FROM target WHERE balance > 0) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="target" schema="" table="target" ctx=Select +ALIAS: "t"="target" +FILTER: schema="" table="" column="balance" +STMT: MergeStmt +STMT: SelectStmt +== 255 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 256 +ROLLBACK +-- +STMT: TransactionStmt +== 257 +BEGIN +-- +STMT: TransactionStmt +== 258 +MERGE INTO target t +USING +(SELECT sid, max(delta) AS delta + FROM source + GROUP BY sid + HAVING count(*) = 1 + ORDER BY sid ASC) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="source" schema="" table="source" ctx=Select +ALIAS: "t"="target" +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 259 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 260 +ROLLBACK +-- +STMT: TransactionStmt +== 261 +-- plpgsql parameters and results +BEGIN +-- +STMT: TransactionStmt +== 262 +CREATE FUNCTION merge_func (p_id integer, p_bal integer) +RETURNS INTEGER +LANGUAGE plpgsql +AS $$ +DECLARE + result integer; +BEGIN +MERGE INTO target t +USING (SELECT p_id AS sid) AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = t.balance - p_bal; +IF FOUND THEN + GET DIAGNOSTICS result := ROW_COUNT; +END IF; +RETURN result; +END; +$$ +-- +FUNCTION: name="merge_func" function="merge_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 263 +SELECT merge_func(3, 4) +-- +FUNCTION: name="merge_func" function="merge_func" schema="" ctx=Call +STMT: SelectStmt +== 264 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 265 +ROLLBACK +-- +STMT: TransactionStmt +== 266 +-- PREPARE +BEGIN +-- +STMT: TransactionStmt +== 267 +prepare foom as merge into target t using (select 1 as sid) s on (t.tid = s.sid) when matched then update set balance = 1 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: PrepareStmt +STMT: MergeStmt +STMT: SelectStmt +== 268 +execute foom +-- +STMT: ExecuteStmt +== 269 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 270 +ROLLBACK +-- +STMT: TransactionStmt +== 271 +BEGIN +-- +STMT: TransactionStmt +== 272 +PREPARE foom2 (integer, integer) AS +MERGE INTO target t +USING (SELECT 1) s +ON t.tid = $1 +WHEN MATCHED THEN +UPDATE SET balance = $2 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: PrepareStmt +STMT: MergeStmt +STMT: SelectStmt +== 273 +--EXPLAIN (ANALYZE ON, COSTS OFF, SUMMARY OFF, TIMING OFF) +execute foom2 (1, 1) +-- +STMT: ExecuteStmt +== 274 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +== 275 +ROLLBACK +-- +STMT: TransactionStmt +== 276 +-- subqueries in source relation + +CREATE TABLE sq_target (tid integer NOT NULL, balance integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DDL +STMT: CreateStmt +== 277 +CREATE TABLE sq_source (delta integer, sid integer, balance integer DEFAULT 0) + WITH (autovacuum_enabled=off) +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=DDL +STMT: CreateStmt +== 278 +INSERT INTO sq_target(tid, balance) VALUES (1,100), (2,200), (3,300) +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 279 +INSERT INTO sq_source(sid, delta) VALUES (1,10), (2,20), (4,40) +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 280 +BEGIN +-- +STMT: TransactionStmt +== 281 +MERGE INTO sq_target t +USING (SELECT * FROM sq_source) s +ON tid = sid +WHEN MATCHED AND t.balance > delta THEN + UPDATE SET balance = t.balance + delta +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_source" schema="" table="sq_source" ctx=Select +ALIAS: "t"="sq_target" +STMT: MergeStmt +STMT: SelectStmt +== 282 +SELECT * FROM sq_target +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +== 283 +ROLLBACK +-- +STMT: TransactionStmt +== 284 +-- try a view +CREATE VIEW v AS SELECT * FROM sq_source WHERE sid < 2 +-- +TABLE: name="v" schema="" table="v" ctx=DDL +TABLE: name="sq_source" schema="" table="sq_source" ctx=Select +FILTER: schema="" table="" column="sid" +STMT: ViewStmt +STMT: SelectStmt +== 285 +BEGIN +-- +STMT: TransactionStmt +== 286 +MERGE INTO sq_target +USING v +ON tid = sid +WHEN MATCHED THEN + UPDATE SET balance = v.balance + delta +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +STMT: MergeStmt +== 287 +SELECT * FROM sq_target +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +== 288 +ROLLBACK +-- +STMT: TransactionStmt +== 289 +-- ambiguous reference to a column +BEGIN +-- +STMT: TransactionStmt +== 290 +MERGE INTO sq_target +USING v +ON tid = sid +WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = balance + delta +WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) +WHEN MATCHED AND tid < 2 THEN + DELETE +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +STMT: MergeStmt +== 291 +ROLLBACK +-- +STMT: TransactionStmt +== 292 +BEGIN +-- +STMT: TransactionStmt +== 293 +INSERT INTO sq_source (sid, balance, delta) VALUES (-1, -1, -10) +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 294 +MERGE INTO sq_target t +USING v +ON tid = sid +WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta +WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) +WHEN MATCHED AND tid < 2 THEN + DELETE +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +ALIAS: "t"="sq_target" +STMT: MergeStmt +== 295 +SELECT * FROM sq_target +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +== 296 +ROLLBACK +-- +STMT: TransactionStmt +== 297 +-- CTEs +BEGIN +-- +STMT: TransactionStmt +== 298 +INSERT INTO sq_source (sid, balance, delta) VALUES (-1, -1, -10) +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 299 +WITH targq AS ( + SELECT * FROM v +) +MERGE INTO sq_target t +USING v +ON tid = sid +WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta +WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) +WHEN MATCHED AND tid < 2 THEN + DELETE +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="v" schema="" table="v" ctx=Select +ALIAS: "t"="sq_target" +CTE: "targq" +STMT: MergeStmt +STMT: SelectStmt +== 300 +ROLLBACK +-- +STMT: TransactionStmt +== 301 +-- RETURNING +SELECT * FROM sq_source ORDER BY sid +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=Select +STMT: SelectStmt +== 302 +SELECT * FROM sq_target ORDER BY tid +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +== 303 +BEGIN +-- +STMT: TransactionStmt +== 304 +CREATE TABLE merge_actions(action text, abbrev text) +-- +TABLE: name="merge_actions" schema="" table="merge_actions" ctx=DDL +STMT: CreateStmt +== 305 +INSERT INTO merge_actions VALUES ('INSERT', 'ins'), ('UPDATE', 'upd'), ('DELETE', 'del') +-- +TABLE: name="merge_actions" schema="" table="merge_actions" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 306 +MERGE INTO sq_target t +USING sq_source s +ON tid = sid +WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta +WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) +WHEN MATCHED AND tid < 2 THEN + DELETE +RETURNING (SELECT abbrev FROM merge_actions + WHERE action = merge_action()) AS action, + t.*, + CASE merge_action() + WHEN 'INSERT' THEN 'Inserted '||t + WHEN 'UPDATE' THEN 'Added '||delta||' to balance' + WHEN 'DELETE' THEN 'Removed '||t + END AS description +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="merge_actions" schema="" table="merge_actions" ctx=Select +ALIAS: "t"="sq_target" +FILTER: schema="" table="" column="action" +STMT: MergeStmt +STMT: SelectStmt +== 307 +ROLLBACK +-- +STMT: TransactionStmt +== 308 +-- error when using merge_action() outside MERGE +SELECT merge_action() FROM sq_target +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +== 309 +UPDATE sq_target SET balance = balance + 1 RETURNING merge_action() +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +STMT: UpdateStmt +== 310 +-- RETURNING in CTEs +CREATE TABLE sq_target_merge_log (tid integer NOT NULL, last_change text) +-- +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=DDL +STMT: CreateStmt +== 311 +INSERT INTO sq_target_merge_log VALUES (1, 'Original value') +-- +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 312 +BEGIN +-- +STMT: TransactionStmt +== 313 +WITH m AS ( + MERGE INTO sq_target t + USING sq_source s + ON tid = sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action() AS action, t.*, + CASE merge_action() + WHEN 'INSERT' THEN 'Inserted '||t + WHEN 'UPDATE' THEN 'Added '||delta||' to balance' + WHEN 'DELETE' THEN 'Removed '||t + END AS description +), m2 AS ( + MERGE INTO sq_target_merge_log l + USING m + ON l.tid = m.tid + WHEN MATCHED THEN + UPDATE SET last_change = description + WHEN NOT MATCHED THEN + INSERT VALUES (m.tid, description) + RETURNING action, merge_action() AS log_action, l.* +) +SELECT * FROM m2 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=DML +ALIAS: "l"="sq_target_merge_log" +ALIAS: "t"="sq_target" +CTE: "m" +CTE: "m2" +STMT: SelectStmt +STMT: MergeStmt +== 314 +SELECT * FROM sq_target_merge_log ORDER BY tid +-- +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=Select +STMT: SelectStmt +== 315 +ROLLBACK +-- +STMT: TransactionStmt +== 316 +-- COPY (MERGE ... RETURNING) TO ... +BEGIN +-- +STMT: TransactionStmt +== 317 +COPY ( + MERGE INTO sq_target t + USING sq_source s + ON tid = sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action(), t.* +) TO stdout +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +ALIAS: "t"="sq_target" +STMT: CopyStmt +== 318 +ROLLBACK +-- +STMT: TransactionStmt +== 319 +-- SQL function with MERGE ... RETURNING +BEGIN +-- +STMT: TransactionStmt +== 320 +CREATE FUNCTION merge_into_sq_target(sid int, balance int, delta int, + OUT action text, OUT tid int, OUT new_balance int) +LANGUAGE sql AS +$$ + MERGE INTO sq_target t + USING (VALUES ($1, $2, $3)) AS v(sid, balance, delta) + ON tid = v.sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + v.delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (v.balance + v.delta, v.sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action(), t.*; +$$ +-- +FUNCTION: name="merge_into_sq_target" function="merge_into_sq_target" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 321 +SELECT m.* +FROM (VALUES (1, 0, 0), (3, 0, 20), (4, 100, 10)) AS v(sid, balance, delta), +LATERAL (SELECT action, tid, new_balance FROM merge_into_sq_target(sid, balance, delta)) m +-- +FUNCTION: name="merge_into_sq_target" function="merge_into_sq_target" schema="" ctx=Call +STMT: SelectStmt +== 322 +ROLLBACK +-- +STMT: TransactionStmt +== 323 +-- SQL SRF with MERGE ... RETURNING +BEGIN +-- +STMT: TransactionStmt +== 324 +CREATE FUNCTION merge_sq_source_into_sq_target() +RETURNS TABLE (action text, tid int, balance int) +LANGUAGE sql AS +$$ + MERGE INTO sq_target t + USING sq_source s + ON tid = sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action(), t.*; +$$ +-- +FUNCTION: name="merge_sq_source_into_sq_target" function="merge_sq_source_into_sq_target" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 325 +SELECT * FROM merge_sq_source_into_sq_target() +-- +FUNCTION: name="merge_sq_source_into_sq_target" function="merge_sq_source_into_sq_target" schema="" ctx=Call +STMT: SelectStmt +== 326 +ROLLBACK +-- +STMT: TransactionStmt +== 327 +-- PL/pgSQL function with MERGE ... RETURNING ... INTO +BEGIN +-- +STMT: TransactionStmt +== 328 +CREATE FUNCTION merge_into_sq_target(sid int, balance int, delta int, + OUT r_action text, OUT r_tid int, OUT r_balance int) +LANGUAGE plpgsql AS +$$ +BEGIN + MERGE INTO sq_target t + USING (VALUES ($1, $2, $3)) AS v(sid, balance, delta) + ON tid = v.sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + v.delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (v.balance + v.delta, v.sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action(), t.* INTO r_action, r_tid, r_balance; +END; +$$ +-- +FUNCTION: name="merge_into_sq_target" function="merge_into_sq_target" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 329 +SELECT m.* +FROM (VALUES (1, 0, 0), (3, 0, 20), (4, 100, 10)) AS v(sid, balance, delta), +LATERAL (SELECT r_action, r_tid, r_balance FROM merge_into_sq_target(sid, balance, delta)) m +-- +FUNCTION: name="merge_into_sq_target" function="merge_into_sq_target" schema="" ctx=Call +STMT: SelectStmt +== 330 +ROLLBACK +-- +STMT: TransactionStmt +== 331 +-- EXPLAIN +CREATE TABLE ex_mtarget (a int, b int) + WITH (autovacuum_enabled=off) +-- +TABLE: name="ex_mtarget" schema="" table="ex_mtarget" ctx=DDL +STMT: CreateStmt +== 332 +CREATE TABLE ex_msource (a int, b int) + WITH (autovacuum_enabled=off) +-- +TABLE: name="ex_msource" schema="" table="ex_msource" ctx=DDL +STMT: CreateStmt +== 333 +INSERT INTO ex_mtarget SELECT i, i*10 FROM generate_series(1,100,2) i +-- +TABLE: name="ex_mtarget" schema="" table="ex_mtarget" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 334 +INSERT INTO ex_msource SELECT i, i*10 FROM generate_series(1,100,1) i +-- +TABLE: name="ex_msource" schema="" table="ex_msource" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 335 +CREATE FUNCTION explain_merge(query text) RETURNS SETOF text +LANGUAGE plpgsql AS +$$ +DECLARE ln text; +BEGIN + FOR ln IN + EXECUTE 'explain (analyze, timing off, summary off, costs off) ' || + query + LOOP + ln := regexp_replace(ln, '(Memory( Usage)?|Buckets|Batches): \S*', '\1: xxx', 'g'); + RETURN NEXT ln; + END LOOP; +END; +$$ +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 336 +-- only updates +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN MATCHED THEN + UPDATE SET b = t.b + 1') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +== 337 +-- only updates to selected tuples +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN MATCHED AND t.a < 10 THEN + UPDATE SET b = t.b + 1') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +== 338 +-- updates + deletes +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN MATCHED AND t.a < 10 THEN + UPDATE SET b = t.b + 1 +WHEN MATCHED AND t.a >= 10 AND t.a <= 20 THEN + DELETE') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +== 339 +-- only inserts +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN NOT MATCHED AND s.a < 10 THEN + INSERT VALUES (a, b)') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +== 340 +-- all three +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN MATCHED AND t.a < 10 THEN + UPDATE SET b = t.b + 1 +WHEN MATCHED AND t.a >= 30 AND t.a <= 40 THEN + DELETE +WHEN NOT MATCHED AND s.a < 20 THEN + INSERT VALUES (a, b)') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +== 341 +-- not matched by source +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN NOT MATCHED BY SOURCE and t.a < 10 THEN + DELETE') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +== 342 +-- not matched by source and target +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN NOT MATCHED BY SOURCE AND t.a < 10 THEN + DELETE +WHEN NOT MATCHED BY TARGET AND s.a < 20 THEN + INSERT VALUES (a, b)') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +== 343 +-- nothing +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a AND t.a < -1000 +WHEN MATCHED AND t.a < 10 THEN + DO NOTHING') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +== 344 +DROP TABLE ex_msource, ex_mtarget +-- +TABLE: name="ex_msource" schema="" table="ex_msource" ctx=DDL +TABLE: name="ex_mtarget" schema="" table="ex_mtarget" ctx=DDL +STMT: DropStmt +== 345 +DROP FUNCTION explain_merge(text) +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=DDL +STMT: DropStmt +== 346 +-- EXPLAIN SubPlans and InitPlans +CREATE TABLE src (a int, b int, c int, d int) +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: CreateStmt +== 347 +CREATE TABLE tgt (a int, b int, c int, d int) +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DDL +STMT: CreateStmt +== 348 +CREATE TABLE ref (ab int, cd int) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +== 349 +EXPLAIN (verbose, costs off) +MERGE INTO tgt t +USING (SELECT *, (SELECT count(*) FROM ref r + WHERE r.ab = s.a + s.b + AND r.cd = s.c - s.d) cnt + FROM src s) s +ON t.a = s.a AND t.b < s.cnt +WHEN MATCHED AND t.c > s.cnt THEN + UPDATE SET (b, c) = (SELECT s.b, s.cnt) +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DML +TABLE: name="src" schema="" table="src" ctx=Select +TABLE: name="ref" schema="" table="ref" ctx=Select +ALIAS: "r"="ref" +ALIAS: "s"="src" +ALIAS: "t"="tgt" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="r" column="ab" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="b" +FILTER: schema="" table="r" column="cd" +FILTER: schema="" table="s" column="c" +FILTER: schema="" table="s" column="d" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 350 +DROP TABLE src, tgt, ref +-- +TABLE: name="src" schema="" table="src" ctx=DDL +TABLE: name="tgt" schema="" table="tgt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +== 351 +-- Subqueries +BEGIN +-- +STMT: TransactionStmt +== 352 +MERGE INTO sq_target t +USING v +ON tid = sid +WHEN MATCHED THEN + UPDATE SET balance = (SELECT count(*) FROM sq_target) +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +ALIAS: "t"="sq_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 353 +SELECT * FROM sq_target WHERE tid = 1 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +FILTER: schema="" table="" column="tid" +STMT: SelectStmt +== 354 +ROLLBACK +-- +STMT: TransactionStmt +== 355 +BEGIN +-- +STMT: TransactionStmt +== 356 +MERGE INTO sq_target t +USING v +ON tid = sid +WHEN MATCHED AND (SELECT count(*) > 0 FROM sq_target) THEN + UPDATE SET balance = 42 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +ALIAS: "t"="sq_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 357 +SELECT * FROM sq_target WHERE tid = 1 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +FILTER: schema="" table="" column="tid" +STMT: SelectStmt +== 358 +ROLLBACK +-- +STMT: TransactionStmt +== 359 +BEGIN +-- +STMT: TransactionStmt +== 360 +MERGE INTO sq_target t +USING v +ON tid = sid AND (SELECT count(*) > 0 FROM sq_target) +WHEN MATCHED THEN + UPDATE SET balance = 42 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +ALIAS: "t"="sq_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 361 +SELECT * FROM sq_target WHERE tid = 1 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +FILTER: schema="" table="" column="tid" +STMT: SelectStmt +== 362 +ROLLBACK +-- +STMT: TransactionStmt +== 363 +DROP TABLE sq_target, sq_target_merge_log, sq_source CASCADE +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DDL +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=DDL +TABLE: name="sq_source" schema="" table="sq_source" ctx=DDL +STMT: DropStmt +== 364 +CREATE TABLE pa_target (tid integer, balance float, val text) + PARTITION BY LIST (tid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateStmt +== 365 +CREATE TABLE part1 PARTITION OF pa_target FOR VALUES IN (1,4) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +== 366 +CREATE TABLE part2 PARTITION OF pa_target FOR VALUES IN (2,5,6) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +== 367 +CREATE TABLE part3 PARTITION OF pa_target FOR VALUES IN (3,8,9) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +== 368 +CREATE TABLE part4 PARTITION OF pa_target DEFAULT + WITH (autovacuum_enabled=off) +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: CreateStmt +== 369 +CREATE TABLE pa_source (sid integer, delta float) +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: CreateStmt +== 370 +-- insert many rows to the source table +INSERT INTO pa_source SELECT id, id * 10 FROM generate_series(1,14) AS id +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 371 +-- insert a few rows in the target table (odd numbered tid) +INSERT INTO pa_target SELECT id, id * 100, 'initial' FROM generate_series(1,15,2) AS id +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 372 +-- try simple MERGE +BEGIN +-- +STMT: TransactionStmt +== 373 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source' +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +== 374 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 375 +ROLLBACK +-- +STMT: TransactionStmt +== 376 +-- same with a constant qual +BEGIN +-- +STMT: TransactionStmt +== 377 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid AND tid = 1 + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source' +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +== 378 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 379 +ROLLBACK +-- +STMT: TransactionStmt +== 380 +-- try updating the partition key column +BEGIN +-- +STMT: TransactionStmt +== 381 +CREATE FUNCTION merge_func() RETURNS integer LANGUAGE plpgsql AS $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET tid = 1, val = val || ' not matched by source'; +IF FOUND THEN + GET DIAGNOSTICS result := ROW_COUNT; +END IF; +RETURN result; +END; +$$ +-- +FUNCTION: name="merge_func" function="merge_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 382 +SELECT merge_func() +-- +FUNCTION: name="merge_func" function="merge_func" schema="" ctx=Call +STMT: SelectStmt +== 383 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 384 +ROLLBACK +-- +STMT: TransactionStmt +== 385 +-- update partition key to partition not initially scanned +BEGIN +-- +STMT: TransactionStmt +== 386 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid AND t.tid = 1 + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + RETURNING merge_action(), t.* +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +== 387 +SELECT * FROM pa_target ORDER BY tid +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 388 +ROLLBACK +-- +STMT: TransactionStmt +== 389 +-- bug #18871: ExecInitPartitionInfo()'s handling of DO NOTHING actions +BEGIN +-- +STMT: TransactionStmt +== 390 +TRUNCATE pa_target +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: TruncateStmt +== 391 +MERGE INTO pa_target t + USING (VALUES (10, 100)) AS s(sid, delta) + ON t.tid = s.sid + WHEN NOT MATCHED THEN + INSERT VALUES (1, 10, 'inserted by merge') + WHEN MATCHED THEN + DO NOTHING +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +STMT: SelectStmt +== 392 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 393 +ROLLBACK +-- +STMT: TransactionStmt +== 394 +DROP TABLE pa_target CASCADE +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: DropStmt +== 395 +-- The target table is partitioned in the same way, but this time by attaching +-- partitions which have columns in different order, dropped columns etc. +CREATE TABLE pa_target (tid integer, balance float, val text) + PARTITION BY LIST (tid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateStmt +== 396 +CREATE TABLE part1 (tid integer, balance float, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +== 397 +CREATE TABLE part2 (balance float, tid integer, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +== 398 +CREATE TABLE part3 (tid integer, balance float, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +== 399 +CREATE TABLE part4 (extraid text, tid integer, balance float, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: CreateStmt +== 400 +ALTER TABLE part4 DROP COLUMN extraid +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: AlterTableStmt +== 401 +ALTER TABLE pa_target ATTACH PARTITION part1 FOR VALUES IN (1,4) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +== 402 +ALTER TABLE pa_target ATTACH PARTITION part2 FOR VALUES IN (2,5,6) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +== 403 +ALTER TABLE pa_target ATTACH PARTITION part3 FOR VALUES IN (3,8,9) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +== 404 +ALTER TABLE pa_target ATTACH PARTITION part4 DEFAULT +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +== 405 +-- insert a few rows in the target table (odd numbered tid) +INSERT INTO pa_target SELECT id, id * 100, 'initial' FROM generate_series(1,15,2) AS id +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 406 +-- try simple MERGE +BEGIN +-- +STMT: TransactionStmt +== 407 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source'; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +== 408 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 409 +ROLLBACK +-- +STMT: TransactionStmt +== 410 +-- same with a constant qual +BEGIN +-- +STMT: TransactionStmt +== 411 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid AND tid IN (1, 5) + WHEN MATCHED AND tid % 5 = 0 THEN DELETE + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source' +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +== 412 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 413 +ROLLBACK +-- +STMT: TransactionStmt +== 414 +-- try updating the partition key column +BEGIN +-- +STMT: TransactionStmt +== 415 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET tid = 1, val = val || ' not matched by source'; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +== 416 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 417 +ROLLBACK +-- +STMT: TransactionStmt +== 418 +-- as above, but blocked by BEFORE DELETE ROW trigger +BEGIN +-- +STMT: TransactionStmt +== 419 +CREATE FUNCTION trig_fn() RETURNS trigger LANGUAGE plpgsql AS + $$ BEGIN RETURN NULL; END; $$ +-- +FUNCTION: name="trig_fn" function="trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 420 +CREATE TRIGGER del_trig BEFORE DELETE ON pa_target + FOR EACH ROW EXECUTE PROCEDURE trig_fn() +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateTrigStmt +== 421 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source'; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +== 422 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 423 +ROLLBACK +-- +STMT: TransactionStmt +== 424 +-- as above, but blocked by BEFORE INSERT ROW trigger +BEGIN +-- +STMT: TransactionStmt +== 425 +CREATE FUNCTION trig_fn() RETURNS trigger LANGUAGE plpgsql AS + $$ BEGIN RETURN NULL; END; $$ +-- +FUNCTION: name="trig_fn" function="trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 426 +CREATE TRIGGER ins_trig BEFORE INSERT ON pa_target + FOR EACH ROW EXECUTE PROCEDURE trig_fn() +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateTrigStmt +== 427 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source'; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +== 428 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 429 +ROLLBACK +-- +STMT: TransactionStmt +== 430 +-- test RLS enforcement +BEGIN +-- +STMT: TransactionStmt +== 431 +ALTER TABLE pa_target ENABLE ROW LEVEL SECURITY +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +== 432 +ALTER TABLE pa_target FORCE ROW LEVEL SECURITY +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +== 433 +CREATE POLICY pa_target_pol ON pa_target USING (tid != 0) +-- +STMT: CreatePolicyStmt +== 434 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid AND t.tid IN (1,2,3,4) + WHEN MATCHED THEN + UPDATE SET tid = tid - 1 +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +== 435 +ROLLBACK +-- +STMT: TransactionStmt +== 436 +DROP TABLE pa_source +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: DropStmt +== 437 +DROP TABLE pa_target CASCADE +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: DropStmt +== 438 +-- Sub-partitioning +CREATE TABLE pa_target (logts timestamp, tid integer, balance float, val text) + PARTITION BY RANGE (logts) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateStmt +== 439 +CREATE TABLE part_m01 PARTITION OF pa_target + FOR VALUES FROM ('2017-01-01') TO ('2017-02-01') + PARTITION BY LIST (tid) +-- +TABLE: name="part_m01" schema="" table="part_m01" ctx=DDL +STMT: CreateStmt +== 440 +CREATE TABLE part_m01_odd PARTITION OF part_m01 + FOR VALUES IN (1,3,5,7,9) WITH (autovacuum_enabled=off) +-- +TABLE: name="part_m01_odd" schema="" table="part_m01_odd" ctx=DDL +STMT: CreateStmt +== 441 +CREATE TABLE part_m01_even PARTITION OF part_m01 + FOR VALUES IN (2,4,6,8) WITH (autovacuum_enabled=off) +-- +TABLE: name="part_m01_even" schema="" table="part_m01_even" ctx=DDL +STMT: CreateStmt +== 442 +CREATE TABLE part_m02 PARTITION OF pa_target + FOR VALUES FROM ('2017-02-01') TO ('2017-03-01') + PARTITION BY LIST (tid) +-- +TABLE: name="part_m02" schema="" table="part_m02" ctx=DDL +STMT: CreateStmt +== 443 +CREATE TABLE part_m02_odd PARTITION OF part_m02 + FOR VALUES IN (1,3,5,7,9) WITH (autovacuum_enabled=off) +-- +TABLE: name="part_m02_odd" schema="" table="part_m02_odd" ctx=DDL +STMT: CreateStmt +== 444 +CREATE TABLE part_m02_even PARTITION OF part_m02 + FOR VALUES IN (2,4,6,8) WITH (autovacuum_enabled=off) +-- +TABLE: name="part_m02_even" schema="" table="part_m02_even" ctx=DDL +STMT: CreateStmt +== 445 +CREATE TABLE pa_source (sid integer, delta float) + WITH (autovacuum_enabled=off) +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: CreateStmt +== 446 +-- insert many rows to the source table +INSERT INTO pa_source SELECT id, id * 10 FROM generate_series(1,14) AS id +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 447 +-- insert a few rows in the target table (odd numbered tid) +INSERT INTO pa_target SELECT '2017-01-31', id, id * 100, 'initial' FROM generate_series(1,9,3) AS id +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 448 +INSERT INTO pa_target SELECT '2017-02-28', id, id * 100, 'initial' FROM generate_series(2,9,3) AS id +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 449 +-- try simple MERGE +BEGIN +-- +STMT: TransactionStmt +== 450 +MERGE INTO pa_target t + USING (SELECT '2017-01-15' AS slogts, * FROM pa_source WHERE sid < 10) s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (slogts::timestamp, sid, delta, 'inserted by merge') + RETURNING merge_action(), t.* +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +TABLE: name="pa_source" schema="" table="pa_source" ctx=Select +ALIAS: "t"="pa_target" +FILTER: schema="" table="" column="sid" +STMT: MergeStmt +STMT: SelectStmt +== 451 +SELECT * FROM pa_target ORDER BY tid +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 452 +ROLLBACK +-- +STMT: TransactionStmt +== 453 +DROP TABLE pa_source +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: DropStmt +== 454 +DROP TABLE pa_target CASCADE +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: DropStmt +== 455 +-- Partitioned table with primary key + +CREATE TABLE pa_target (tid integer PRIMARY KEY) PARTITION BY LIST (tid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateStmt +== 456 +CREATE TABLE pa_targetp PARTITION OF pa_target DEFAULT +-- +TABLE: name="pa_targetp" schema="" table="pa_targetp" ctx=DDL +STMT: CreateStmt +== 457 +CREATE TABLE pa_source (sid integer) +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: CreateStmt +== 458 +INSERT INTO pa_source VALUES (1), (2) +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 459 +EXPLAIN (VERBOSE, COSTS OFF) +MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid + WHEN NOT MATCHED THEN INSERT VALUES (s.sid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: ExplainStmt +STMT: MergeStmt +== 460 +MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid + WHEN NOT MATCHED THEN INSERT VALUES (s.sid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +== 461 +TABLE pa_target +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +== 462 +-- Partition-less partitioned table +-- (the bug we are checking for appeared only if table had partitions before) + +DROP TABLE pa_targetp +-- +TABLE: name="pa_targetp" schema="" table="pa_targetp" ctx=DDL +STMT: DropStmt +== 463 +EXPLAIN (VERBOSE, COSTS OFF) +MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid + WHEN NOT MATCHED THEN INSERT VALUES (s.sid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: ExplainStmt +STMT: MergeStmt +== 464 +MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid + WHEN NOT MATCHED THEN INSERT VALUES (s.sid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +== 465 +DROP TABLE pa_source +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: DropStmt +== 466 +DROP TABLE pa_target CASCADE +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: DropStmt +== 467 +-- some complex joins on the source side + +CREATE TABLE cj_target (tid integer, balance float, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DDL +STMT: CreateStmt +== 468 +CREATE TABLE cj_source1 (sid1 integer, scat integer, delta integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DDL +STMT: CreateStmt +== 469 +CREATE TABLE cj_source2 (sid2 integer, sval text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DDL +STMT: CreateStmt +== 470 +INSERT INTO cj_source1 VALUES (1, 10, 100) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 471 +INSERT INTO cj_source1 VALUES (1, 20, 200) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 472 +INSERT INTO cj_source1 VALUES (2, 20, 300) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 473 +INSERT INTO cj_source1 VALUES (3, 10, 400) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 474 +INSERT INTO cj_source2 VALUES (1, 'initial source2') +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 475 +INSERT INTO cj_source2 VALUES (2, 'initial source2') +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 476 +INSERT INTO cj_source2 VALUES (3, 'initial source2') +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 477 +-- source relation is an unaliased join +MERGE INTO cj_target t +USING cj_source1 s1 + INNER JOIN cj_source2 s2 ON sid1 = sid2 +ON t.tid = sid1 +WHEN NOT MATCHED THEN + INSERT VALUES (sid1, delta, sval) +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +== 478 +-- try accessing columns from either side of the source join +MERGE INTO cj_target t +USING cj_source2 s2 + INNER JOIN cj_source1 s1 ON sid1 = sid2 AND scat = 20 +ON t.tid = sid1 +WHEN NOT MATCHED THEN + INSERT VALUES (sid2, delta, sval) +WHEN MATCHED THEN + DELETE +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +== 479 +-- some simple expressions in INSERT targetlist +MERGE INTO cj_target t +USING cj_source2 s2 + INNER JOIN cj_source1 s1 ON sid1 = sid2 +ON t.tid = sid1 +WHEN NOT MATCHED THEN + INSERT VALUES (sid2, delta + scat, sval) +WHEN MATCHED THEN + UPDATE SET val = val || ' updated by merge' +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +== 480 +MERGE INTO cj_target t +USING cj_source2 s2 + INNER JOIN cj_source1 s1 ON sid1 = sid2 AND scat = 20 +ON t.tid = sid1 +WHEN MATCHED THEN + UPDATE SET val = val || ' ' || delta::text +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +== 481 +SELECT * FROM cj_target +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=Select +STMT: SelectStmt +== 482 +-- try it with an outer join and PlaceHolderVar +MERGE INTO cj_target t +USING (SELECT *, 'join input'::text AS phv FROM cj_source1) fj + FULL JOIN cj_source2 fj2 ON fj.scat = fj2.sid2 * 10 +ON t.tid = fj.scat +WHEN NOT MATCHED THEN + INSERT (tid, balance, val) VALUES (fj.scat, fj.delta, fj.phv) +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=Select +ALIAS: "t"="cj_target" +STMT: MergeStmt +STMT: SelectStmt +== 483 +SELECT * FROM cj_target +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=Select +STMT: SelectStmt +== 484 +ALTER TABLE cj_source1 RENAME COLUMN sid1 TO sid +-- +STMT: RenameStmt +== 485 +ALTER TABLE cj_source2 RENAME COLUMN sid2 TO sid +-- +STMT: RenameStmt +== 486 +TRUNCATE cj_target +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DDL +STMT: TruncateStmt +== 487 +MERGE INTO cj_target t +USING cj_source1 s1 + INNER JOIN cj_source2 s2 ON s1.sid = s2.sid +ON t.tid = s1.sid +WHEN NOT MATCHED THEN + INSERT VALUES (s2.sid, delta, sval) +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +== 488 +DROP TABLE cj_source2, cj_source1, cj_target +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DDL +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DDL +TABLE: name="cj_target" schema="" table="cj_target" ctx=DDL +STMT: DropStmt +== 489 +-- Function scans +CREATE TABLE fs_target (a int, b int, c text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=DDL +STMT: CreateStmt +== 490 +MERGE INTO fs_target t +USING generate_series(1,100,1) AS id +ON t.a = id +WHEN MATCHED THEN + UPDATE SET b = b + id +WHEN NOT MATCHED THEN + INSERT VALUES (id, -1) +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=DML +ALIAS: "t"="fs_target" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +== 491 +MERGE INTO fs_target t +USING generate_series(1,100,2) AS id +ON t.a = id +WHEN MATCHED THEN + UPDATE SET b = b + id, c = 'updated '|| id.*::text +WHEN NOT MATCHED THEN + INSERT VALUES (id, -1, 'inserted ' || id.*::text) +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=DML +ALIAS: "t"="fs_target" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +== 492 +SELECT count(*) FROM fs_target +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 493 +DROP TABLE fs_target +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=DDL +STMT: DropStmt +== 494 +-- SERIALIZABLE test +-- handled in isolation tests + +-- Inheritance-based partitioning +CREATE TABLE measurement ( + city_id int not null, + logdate date not null, + peaktemp int, + unitsales int +) WITH (autovacuum_enabled=off) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: CreateStmt +== 495 +CREATE TABLE measurement_y2006m02 ( + CHECK ( logdate >= DATE '2006-02-01' AND logdate < DATE '2006-03-01' ) +) INHERITS (measurement) WITH (autovacuum_enabled=off) +-- +TABLE: name="measurement_y2006m02" schema="" table="measurement_y2006m02" ctx=DDL +STMT: CreateStmt +== 496 +CREATE TABLE measurement_y2006m03 ( + CHECK ( logdate >= DATE '2006-03-01' AND logdate < DATE '2006-04-01' ) +) INHERITS (measurement) WITH (autovacuum_enabled=off) +-- +TABLE: name="measurement_y2006m03" schema="" table="measurement_y2006m03" ctx=DDL +STMT: CreateStmt +== 497 +CREATE TABLE measurement_y2007m01 ( + filler text, + peaktemp int, + logdate date not null, + city_id int not null, + unitsales int + CHECK ( logdate >= DATE '2007-01-01' AND logdate < DATE '2007-02-01') +) WITH (autovacuum_enabled=off) +-- +TABLE: name="measurement_y2007m01" schema="" table="measurement_y2007m01" ctx=DDL +STMT: CreateStmt +== 498 +ALTER TABLE measurement_y2007m01 DROP COLUMN filler +-- +TABLE: name="measurement_y2007m01" schema="" table="measurement_y2007m01" ctx=DDL +STMT: AlterTableStmt +== 499 +ALTER TABLE measurement_y2007m01 INHERIT measurement +-- +TABLE: name="measurement_y2007m01" schema="" table="measurement_y2007m01" ctx=DDL +STMT: AlterTableStmt +== 500 +INSERT INTO measurement VALUES (0, '2005-07-21', 5, 15) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 501 +CREATE OR REPLACE FUNCTION measurement_insert_trigger() +RETURNS TRIGGER AS $$ +BEGIN + IF ( NEW.logdate >= DATE '2006-02-01' AND + NEW.logdate < DATE '2006-03-01' ) THEN + INSERT INTO measurement_y2006m02 VALUES (NEW.*); + ELSIF ( NEW.logdate >= DATE '2006-03-01' AND + NEW.logdate < DATE '2006-04-01' ) THEN + INSERT INTO measurement_y2006m03 VALUES (NEW.*); + ELSIF ( NEW.logdate >= DATE '2007-01-01' AND + NEW.logdate < DATE '2007-02-01' ) THEN + INSERT INTO measurement_y2007m01 (city_id, logdate, peaktemp, unitsales) + VALUES (NEW.*); + ELSE + RAISE EXCEPTION 'Date out of range. Fix the measurement_insert_trigger() function!'; + END IF; + RETURN NULL; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="measurement_insert_trigger" function="measurement_insert_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 502 +CREATE TRIGGER insert_measurement_trigger + BEFORE INSERT ON measurement + FOR EACH ROW EXECUTE PROCEDURE measurement_insert_trigger() +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: CreateTrigStmt +== 503 +INSERT INTO measurement VALUES (1, '2006-02-10', 35, 10) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 504 +INSERT INTO measurement VALUES (1, '2006-02-16', 45, 20) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 505 +INSERT INTO measurement VALUES (1, '2006-03-17', 25, 10) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 506 +INSERT INTO measurement VALUES (1, '2006-03-27', 15, 40) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 507 +INSERT INTO measurement VALUES (1, '2007-01-15', 10, 10) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 508 +INSERT INTO measurement VALUES (1, '2007-01-17', 10, 10) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 509 +SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +== 510 +CREATE TABLE new_measurement (LIKE measurement) WITH (autovacuum_enabled=off) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DDL +STMT: CreateStmt +== 511 +INSERT INTO new_measurement VALUES (0, '2005-07-21', 25, 20) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 512 +INSERT INTO new_measurement VALUES (1, '2006-03-01', 20, 10) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 513 +INSERT INTO new_measurement VALUES (1, '2006-02-16', 50, 10) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 514 +INSERT INTO new_measurement VALUES (2, '2006-02-10', 20, 20) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 515 +INSERT INTO new_measurement VALUES (1, '2006-03-27', NULL, NULL) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 516 +INSERT INTO new_measurement VALUES (1, '2007-01-17', NULL, NULL) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 517 +INSERT INTO new_measurement VALUES (1, '2007-01-15', 5, NULL) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 518 +INSERT INTO new_measurement VALUES (1, '2007-01-16', 10, 10) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 519 +BEGIN +-- +STMT: TransactionStmt +== 520 +MERGE INTO ONLY measurement m + USING new_measurement nm ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN MATCHED AND nm.peaktemp IS NULL THEN DELETE +WHEN MATCHED THEN UPDATE + SET peaktemp = greatest(m.peaktemp, nm.peaktemp), + unitsales = m.unitsales + coalesce(nm.unitsales, 0) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id, logdate, peaktemp, unitsales) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +== 521 +SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate, peaktemp +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +== 522 +ROLLBACK +-- +STMT: TransactionStmt +== 523 +MERGE into measurement m + USING new_measurement nm ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN MATCHED AND nm.peaktemp IS NULL THEN DELETE +WHEN MATCHED THEN UPDATE + SET peaktemp = greatest(m.peaktemp, nm.peaktemp), + unitsales = m.unitsales + coalesce(nm.unitsales, 0) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id, logdate, peaktemp, unitsales) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +== 524 +SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +== 525 +BEGIN +-- +STMT: TransactionStmt +== 526 +MERGE INTO new_measurement nm + USING ONLY measurement m ON + (nm.city_id = m.city_id and nm.logdate=m.logdate) +WHEN MATCHED THEN DELETE +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +ALIAS: "nm"="new_measurement" +STMT: MergeStmt +== 527 +SELECT * FROM new_measurement ORDER BY city_id, logdate +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=Select +STMT: SelectStmt +== 528 +ROLLBACK +-- +STMT: TransactionStmt +== 529 +MERGE INTO new_measurement nm + USING measurement m ON + (nm.city_id = m.city_id and nm.logdate=m.logdate) +WHEN MATCHED THEN DELETE +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +ALIAS: "nm"="new_measurement" +STMT: MergeStmt +== 530 +SELECT * FROM new_measurement ORDER BY city_id, logdate +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=Select +STMT: SelectStmt +== 531 +-- MERGE into inheritance root table +DROP TRIGGER insert_measurement_trigger ON measurement +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: DropStmt +== 532 +ALTER TABLE measurement ADD CONSTRAINT mcheck CHECK (city_id = 0) NO INHERIT +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: AlterTableStmt +== 533 +EXPLAIN (COSTS OFF) +MERGE INTO measurement m + USING (VALUES (1, '01-17-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, 25, 100) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 534 +BEGIN +-- +STMT: TransactionStmt +== 535 +MERGE INTO measurement m + USING (VALUES (1, '01-17-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, 25, 100) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +STMT: SelectStmt +== 536 +SELECT * FROM ONLY measurement ORDER BY city_id, logdate +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +== 537 +ROLLBACK +-- +STMT: TransactionStmt +== 538 +ALTER TABLE measurement ENABLE ROW LEVEL SECURITY +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: AlterTableStmt +== 539 +ALTER TABLE measurement FORCE ROW LEVEL SECURITY +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: AlterTableStmt +== 540 +CREATE POLICY measurement_p ON measurement USING (peaktemp IS NOT NULL) +-- +STMT: CreatePolicyStmt +== 541 +MERGE INTO measurement m + USING (VALUES (1, '01-17-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, NULL, 100) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +STMT: SelectStmt +== 542 +-- should fail + +MERGE INTO measurement m + USING (VALUES (1, '01-17-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, 25, 100) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +STMT: SelectStmt +== 543 +-- ok +SELECT * FROM ONLY measurement ORDER BY city_id, logdate +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +== 544 +MERGE INTO measurement m + USING (VALUES (1, '01-18-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, 25, 200) +RETURNING merge_action(), m.* +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +STMT: SelectStmt +== 545 +DROP TABLE measurement, new_measurement CASCADE +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DDL +STMT: DropStmt +== 546 +DROP FUNCTION measurement_insert_trigger() +-- +FUNCTION: name="measurement_insert_trigger" function="measurement_insert_trigger" schema="" ctx=DDL +STMT: DropStmt +== 547 +|-- +-- test non-strict join clause +|-- +CREATE TABLE src (a int, b text) +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: CreateStmt +== 548 +INSERT INTO src VALUES (1, 'src row') +-- +TABLE: name="src" schema="" table="src" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 549 +CREATE TABLE tgt (a int, b text) +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DDL +STMT: CreateStmt +== 550 +INSERT INTO tgt VALUES (NULL, 'tgt row') +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 551 +MERGE INTO tgt USING src ON tgt.a IS NOT DISTINCT FROM src.a + WHEN MATCHED THEN UPDATE SET a = src.a, b = src.b + WHEN NOT MATCHED BY SOURCE THEN DELETE + RETURNING merge_action(), src.*, tgt.* +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DML +STMT: MergeStmt +== 552 +SELECT * FROM tgt +-- +TABLE: name="tgt" schema="" table="tgt" ctx=Select +STMT: SelectStmt +== 553 +DROP TABLE src, tgt +-- +TABLE: name="src" schema="" table="src" ctx=DDL +TABLE: name="tgt" schema="" table="tgt" ctx=DDL +STMT: DropStmt +== 554 +|-- +-- test for bug #18634 (wrong varnullingrels error) +|-- +CREATE TABLE bug18634t (a int, b int, c text) +-- +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=DDL +STMT: CreateStmt +== 555 +INSERT INTO bug18634t VALUES(1, 10, 'tgt1'), (2, 20, 'tgt2') +-- +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 556 +CREATE VIEW bug18634v AS + SELECT * FROM bug18634t WHERE EXISTS (SELECT 1 FROM bug18634t) +-- +TABLE: name="bug18634v" schema="" table="bug18634v" ctx=DDL +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=Select +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 557 +CREATE TABLE bug18634s (a int, b int, c text) +-- +TABLE: name="bug18634s" schema="" table="bug18634s" ctx=DDL +STMT: CreateStmt +== 558 +INSERT INTO bug18634s VALUES (1, 2, 'src1') +-- +TABLE: name="bug18634s" schema="" table="bug18634s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 559 +MERGE INTO bug18634v t USING bug18634s s ON s.a = t.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED BY SOURCE THEN DELETE + RETURNING merge_action(), s.c, t.* +-- +TABLE: name="bug18634v" schema="" table="bug18634v" ctx=DML +ALIAS: "t"="bug18634v" +STMT: MergeStmt +== 560 +SELECT * FROM bug18634t +-- +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=Select +STMT: SelectStmt +== 561 +DROP TABLE bug18634t CASCADE +-- +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=DDL +STMT: DropStmt +== 562 +DROP TABLE bug18634s +-- +TABLE: name="bug18634s" schema="" table="bug18634s" ctx=DDL +STMT: DropStmt +== 563 +-- prepare + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 564 +-- try a system catalog +MERGE INTO pg_class c +USING (SELECT 'pg_depend'::regclass AS oid) AS j +ON j.oid = c.oid +WHEN MATCHED THEN + UPDATE SET reltuples = reltuples + 1 +RETURNING j.oid +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +ALIAS: "c"="pg_class" +STMT: MergeStmt +STMT: SelectStmt +== 565 +CREATE VIEW classv AS SELECT * FROM pg_class +-- +TABLE: name="classv" schema="" table="classv" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 566 +MERGE INTO classv c +USING pg_namespace n +ON n.oid = c.relnamespace +WHEN MATCHED AND c.oid = 'pg_depend'::regclass THEN + UPDATE SET reltuples = reltuples - 1 +RETURNING c.oid +-- +TABLE: name="classv" schema="" table="classv" ctx=DML +ALIAS: "c"="classv" +STMT: MergeStmt +== 567 +DROP TABLE target, target2 +-- +TABLE: name="target" schema="" table="target" ctx=DDL +TABLE: name="target2" schema="" table="target2" ctx=DDL +STMT: DropStmt +== 568 +DROP TABLE source, source2 +-- +TABLE: name="source" schema="" table="source" ctx=DDL +TABLE: name="source2" schema="" table="source2" ctx=DDL +STMT: DropStmt +== 569 +DROP FUNCTION merge_trigfunc() +-- +FUNCTION: name="merge_trigfunc" function="merge_trigfunc" schema="" ctx=DDL +STMT: DropStmt +== 570 +DROP USER regress_merge_privs +-- +STMT: DropRoleStmt +== 571 +DROP USER regress_merge_no_privs +-- +STMT: DropRoleStmt +== 572 +DROP USER regress_merge_none +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/misc.metadata.json b/parser/testdata/summary/postgres_regress/misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/misc.test b/parser/testdata/summary/postgres_regress/misc.test new file mode 100644 index 0000000..c562203 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/misc.test @@ -0,0 +1,520 @@ +== 001 +|-- +-- MISC +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION overpaid(emp) + RETURNS bool + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 144 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +CREATE FUNCTION reverse_name(name) + RETURNS name + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 58 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +|-- +-- BTREE +|-- +UPDATE onek + SET unique1 = onek.unique1 + 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=DML +STMT: UpdateStmt +== 004 +UPDATE onek + SET unique1 = onek.unique1 - 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=DML +STMT: UpdateStmt +== 005 +|-- +-- BTREE partial +|-- +-- UPDATE onek2 +-- SET unique1 = onek2.unique1 + 1; + +--UPDATE onek2 +-- SET unique1 = onek2.unique1 - 1; + +|-- +-- BTREE shutting out non-functional updates +|-- +-- the following two tests seem to take a long time on some +-- systems. This non-func update stuff needs to be examined +-- more closely. - jolly (2/22/96) +|-- +SELECT two, stringu1, ten, string4 + INTO TABLE tmp + FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: SelectStmt +== 006 +UPDATE tmp + SET stringu1 = reverse_name(onek.stringu1) + FROM onek + WHERE onek.stringu1 = 'JBAAAA' and + onek.stringu1 = tmp.stringu1 +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="reverse_name" function="reverse_name" schema="" ctx=Call +STMT: UpdateStmt +== 007 +UPDATE tmp + SET stringu1 = reverse_name(onek2.stringu1) + FROM onek2 + WHERE onek2.stringu1 = 'JCAAAA' and + onek2.stringu1 = tmp.stringu1 +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FUNCTION: name="reverse_name" function="reverse_name" schema="" ctx=Call +STMT: UpdateStmt +== 008 +DROP TABLE tmp +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: DropStmt +== 009 +--UPDATE person* +-- SET age = age + 1; + +--UPDATE person* +-- SET age = age + 3 +-- WHERE name = 'linda'; + +|-- +-- copy +|-- +COPY onek TO :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 138 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 010 +CREATE TEMP TABLE onek_copy (LIKE onek) +-- +TABLE: name="onek_copy" schema="" table="onek_copy" ctx=DDL +STMT: CreateStmt +== 011 +COPY onek_copy FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +SELECT * FROM onek EXCEPT ALL SELECT * FROM onek_copy +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek_copy" schema="" table="onek_copy" ctx=Select +STMT: SelectStmt +== 013 +SELECT * FROM onek_copy EXCEPT ALL SELECT * FROM onek +-- +TABLE: name="onek_copy" schema="" table="onek_copy" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 014 +COPY BINARY stud_emp TO :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 015 +CREATE TEMP TABLE stud_emp_copy (LIKE stud_emp) +-- +TABLE: name="stud_emp_copy" schema="" table="stud_emp_copy" ctx=DDL +STMT: CreateStmt +== 016 +COPY BINARY stud_emp_copy FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 017 +SELECT * FROM stud_emp_copy +-- +TABLE: name="stud_emp_copy" schema="" table="stud_emp_copy" ctx=Select +STMT: SelectStmt +== 018 +|-- +-- test data for postquel functions +|-- + +CREATE TABLE hobbies_r ( + name text, + person text +) +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=DDL +STMT: CreateStmt +== 019 +CREATE TABLE equipment_r ( + name text, + hobby text +) +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DDL +STMT: CreateStmt +== 020 +INSERT INTO hobbies_r (name, person) + SELECT 'posthacking', p.name + FROM person* p + WHERE p.name = 'mike' or p.name = 'jeff' +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=DML +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FILTER: schema="" table="p" column="name" +FILTER: schema="" table="p" column="name" +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO hobbies_r (name, person) + SELECT 'basketball', p.name + FROM person p + WHERE p.name = 'joe' or p.name = 'sally' +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=DML +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FILTER: schema="" table="p" column="name" +FILTER: schema="" table="p" column="name" +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO hobbies_r (name) VALUES ('skywalking') +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO equipment_r (name, hobby) VALUES ('advil', 'posthacking') +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO equipment_r (name, hobby) VALUES ('peet''s coffee', 'posthacking') +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO equipment_r (name, hobby) VALUES ('hightops', 'basketball') +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO equipment_r (name, hobby) VALUES ('guts', 'skywalking') +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +|-- +-- postquel functions +|-- + +CREATE FUNCTION hobbies(person) + RETURNS setof hobbies_r + AS 'select * from hobbies_r where person = $1.name' + LANGUAGE SQL +-- +FUNCTION: name="hobbies" function="hobbies" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 028 +CREATE FUNCTION hobby_construct(text, text) + RETURNS hobbies_r + AS 'select $1 as name, $2 as hobby' + LANGUAGE SQL +-- +FUNCTION: name="hobby_construct" function="hobby_construct" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +CREATE FUNCTION hobby_construct_named(name text, hobby text) + RETURNS hobbies_r + AS 'select name, hobby' + LANGUAGE SQL +-- +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 030 +CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE) + RETURNS hobbies_r.person%TYPE + AS 'select person from hobbies_r where name = $1' + LANGUAGE SQL +-- +FUNCTION: name="hobbies_by_name" function="hobbies_by_name" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 031 +CREATE FUNCTION equipment(hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where hobby = $1.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment" function="equipment" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 032 +CREATE FUNCTION equipment_named(hobby hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where equipment_r.hobby = equipment_named.hobby.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named" function="equipment_named" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 033 +CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where hobby = equipment_named_ambiguous_1a.hobby.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_1a" function="equipment_named_ambiguous_1a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 034 +CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where equipment_r.hobby = hobby.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_1b" function="equipment_named_ambiguous_1b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 035 +CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where hobby = hobby.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_1c" function="equipment_named_ambiguous_1c" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 036 +CREATE FUNCTION equipment_named_ambiguous_2a(hobby text) + RETURNS setof equipment_r + AS 'select * from equipment_r where hobby = equipment_named_ambiguous_2a.hobby' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_2a" function="equipment_named_ambiguous_2a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 037 +CREATE FUNCTION equipment_named_ambiguous_2b(hobby text) + RETURNS setof equipment_r + AS 'select * from equipment_r where equipment_r.hobby = hobby' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_2b" function="equipment_named_ambiguous_2b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 038 +|-- +-- mike does post_hacking, +-- joe and sally play basketball, and +-- everyone else does nothing. +|-- +SELECT p.name, name(p.hobbies) FROM ONLY person p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +== 039 +|-- +-- as above, but jeff also does post_hacking. +|-- +SELECT p.name, name(p.hobbies) FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +== 040 +|-- +-- the next two queries demonstrate how functions generate bogus duplicates. +-- this is a "feature" .. +|-- +SELECT DISTINCT hobbies_r.name, name(hobbies_r.equipment) FROM hobbies_r + ORDER BY 1,2 +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=Select +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +== 041 +SELECT hobbies_r.name, (hobbies_r.equipment).name FROM hobbies_r +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=Select +STMT: SelectStmt +== 042 +|-- +-- mike needs advil and peet's coffee, +-- joe and sally need hightops, and +-- everyone else is fine. +|-- +SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM ONLY person p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +== 043 +|-- +-- as above, but jeff needs advil and peet's coffee as well. +|-- +SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +== 044 +|-- +-- just like the last two, but make sure that the target list fixup and +-- unflattening is being done correctly. +|-- +SELECT name(equipment(p.hobbies)), p.name, name(p.hobbies) FROM ONLY person p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +== 045 +SELECT (p.hobbies).equipment.name, p.name, name(p.hobbies) FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +== 046 +SELECT (p.hobbies).equipment.name, name(p.hobbies), p.name FROM ONLY person p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +== 047 +SELECT name(equipment(p.hobbies)), name(p.hobbies), p.name FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +FUNCTION: name="hobby_construct" function="hobby_construct" schema="" ctx=Call +STMT: SelectStmt +== 049 +SELECT name(equipment(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +== 050 +SELECT name(equipment_named(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named" function="equipment_named" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +== 051 +SELECT name(equipment_named_ambiguous_1a(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_1a" function="equipment_named_ambiguous_1a" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +== 052 +SELECT name(equipment_named_ambiguous_1b(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_1b" function="equipment_named_ambiguous_1b" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +== 053 +SELECT name(equipment_named_ambiguous_1c(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_1c" function="equipment_named_ambiguous_1c" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +== 054 +SELECT name(equipment_named_ambiguous_2a(text 'skywalking')) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_2a" function="equipment_named_ambiguous_2a" schema="" ctx=Call +STMT: SelectStmt +== 055 +SELECT name(equipment_named_ambiguous_2b(text 'skywalking')) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_2b" function="equipment_named_ambiguous_2b" schema="" ctx=Call +STMT: SelectStmt +== 056 +SELECT hobbies_by_name('basketball') +-- +FUNCTION: name="hobbies_by_name" function="hobbies_by_name" schema="" ctx=Call +STMT: SelectStmt +== 057 +SELECT name, overpaid(emp.*) FROM emp +-- +TABLE: name="emp" schema="" table="emp" ctx=Select +FUNCTION: name="overpaid" function="overpaid" schema="" ctx=Call +STMT: SelectStmt +== 058 +|-- +-- Try a few cases with SQL-spec row constructor expressions +|-- +SELECT * FROM equipment(ROW('skywalking', 'mer')) +-- +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT name(equipment(ROW('skywalking', 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT *, name(equipment(h.*)) FROM hobbies_r h +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=Select +ALIAS: "h"="hobbies_r" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=Select +ALIAS: "h"="hobbies_r" +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/misc_functions.metadata.json b/parser/testdata/summary/postgres_regress/misc_functions.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/misc_functions.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/misc_functions.test b/parser/testdata/summary/postgres_regress/misc_functions.test new file mode 100644 index 0000000..0b20686 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/misc_functions.test @@ -0,0 +1,781 @@ +== 001 +-- directory paths and dlsuffix are passed to us in environment variables + + +|-- +-- num_nulls() +|-- + +SELECT num_nonnulls(NULL) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 002 +SELECT num_nonnulls('1') +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 003 +SELECT num_nonnulls(NULL::text) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT num_nonnulls(NULL::text, NULL::int) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT num_nonnulls(1, 2, NULL::text, NULL::point, '', int8 '9', 1.0 / NULL) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT num_nonnulls(VARIADIC '{1,2,NULL,3}'::int[]) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT num_nonnulls(VARIADIC '{"1","2","3","4"}'::text[]) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 008 +SELECT num_nonnulls(VARIADIC ARRAY(SELECT CASE WHEN i <> 40 THEN i END FROM generate_series(1, 100) i)) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 009 +SELECT num_nulls(NULL) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT num_nulls('1') +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT num_nulls(NULL::text) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT num_nulls(NULL::text, NULL::int) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT num_nulls(1, 2, NULL::text, NULL::point, '', int8 '9', 1.0 / NULL) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT num_nulls(VARIADIC '{1,2,NULL,3}'::int[]) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT num_nulls(VARIADIC '{"1","2","3","4"}'::text[]) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT num_nulls(VARIADIC ARRAY(SELECT CASE WHEN i <> 40 THEN i END FROM generate_series(1, 100) i)) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- special cases +SELECT num_nonnulls(VARIADIC NULL::text[]) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT num_nonnulls(VARIADIC '{}'::int[]) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT num_nulls(VARIADIC NULL::text[]) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT num_nulls(VARIADIC '{}'::int[]) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 021 +-- should fail, one or more arguments is required +SELECT num_nonnulls() +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT num_nulls() +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +== 023 +|-- +-- canonicalize_path() +|-- + +CREATE FUNCTION test_canonicalize_path(text) + RETURNS text + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 98 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 024 +SELECT test_canonicalize_path('/') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT test_canonicalize_path('/./abc/def/') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 026 +SELECT test_canonicalize_path('/./../abc/def') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT test_canonicalize_path('/./../../abc/def/') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT test_canonicalize_path('/abc/.././def/ghi') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT test_canonicalize_path('/abc/./../def/ghi//') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT test_canonicalize_path('/abc/def/../..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT test_canonicalize_path('/abc/def/../../..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT test_canonicalize_path('/abc/def/../../../../ghi/jkl') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT test_canonicalize_path('.') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT test_canonicalize_path('./') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT test_canonicalize_path('./abc/..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 036 +SELECT test_canonicalize_path('abc/../') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT test_canonicalize_path('abc/../def') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT test_canonicalize_path('..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 039 +SELECT test_canonicalize_path('../abc/def') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT test_canonicalize_path('../abc/..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 041 +SELECT test_canonicalize_path('../abc/../def') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 042 +SELECT test_canonicalize_path('../abc/../../def/ghi') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT test_canonicalize_path('./abc/./def/.') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT test_canonicalize_path('./abc/././def/.') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 045 +SELECT test_canonicalize_path('./abc/./def/.././ghi/../../../jkl/mno') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +== 046 +|-- +-- pg_log_backend_memory_contexts() +|-- +-- Memory contexts are logged and they are not returned to the function. +-- Furthermore, their contents can vary depending on the timing. However, +-- we can at least verify that the code doesn't fail, and that the +-- permissions are set properly. +|-- + +SELECT pg_log_backend_memory_contexts(pg_backend_pid()) +-- +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +STMT: SelectStmt +== 047 +SELECT pg_log_backend_memory_contexts(pid) FROM pg_stat_activity + WHERE backend_type = 'checkpointer' +-- +TABLE: name="pg_stat_activity" schema="" table="pg_stat_activity" ctx=Select +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=Call +FILTER: schema="" table="" column="backend_type" +STMT: SelectStmt +== 048 +CREATE ROLE regress_log_memory +-- +STMT: CreateRoleStmt +== 049 +SELECT has_function_privilege('regress_log_memory', + 'pg_log_backend_memory_contexts(integer)', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 050 +-- no + +GRANT EXECUTE ON FUNCTION pg_log_backend_memory_contexts(integer) + TO regress_log_memory +-- +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=DDL +STMT: GrantStmt +== 051 +SELECT has_function_privilege('regress_log_memory', + 'pg_log_backend_memory_contexts(integer)', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 052 +-- yes + +SET ROLE regress_log_memory +-- +STMT: VariableSetStmt +== 053 +SELECT pg_log_backend_memory_contexts(pg_backend_pid()) +-- +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +STMT: SelectStmt +== 054 +RESET ROLE +-- +STMT: VariableSetStmt +== 055 +REVOKE EXECUTE ON FUNCTION pg_log_backend_memory_contexts(integer) + FROM regress_log_memory +-- +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=DDL +STMT: GrantStmt +== 056 +DROP ROLE regress_log_memory +-- +STMT: DropRoleStmt +== 057 +|-- +-- Test some built-in SRFs +|-- +-- The outputs of these are variable, so we can't just print their results +-- directly, but we can at least verify that the code doesn't fail. +|-- +select setting as segsize +from pg_settings where name = 'wal_segment_size' + +select count(*) > 0 as ok from pg_ls_waldir() +-- +ERROR: syntax error at or near "select" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 058 +-- Test ProjectSet as well as FunctionScan +select count(*) > 0 as ok from (select pg_ls_waldir()) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_waldir" function="pg_ls_waldir" schema="" ctx=Call +STMT: SelectStmt +== 059 +-- Test not-run-to-completion cases. +select * from pg_ls_waldir() limit 0 +-- +FUNCTION: name="pg_ls_waldir" function="pg_ls_waldir" schema="" ctx=Call +STMT: SelectStmt +== 060 +select count(*) > 0 as ok from (select * from pg_ls_waldir() limit 1) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_waldir" function="pg_ls_waldir" schema="" ctx=Call +STMT: SelectStmt +== 061 +select (w).size = :segsize as ok +from (select pg_ls_waldir() w) ss where length((w).name) = 24 limit 1 +-- +ERROR: syntax error at or near ":" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 062 +select count(*) >= 0 as ok from pg_ls_archive_statusdir() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_archive_statusdir" function="pg_ls_archive_statusdir" schema="" ctx=Call +STMT: SelectStmt +== 063 +-- pg_read_file() +select length(pg_read_file('postmaster.pid')) > 20 +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +== 064 +select length(pg_read_file('postmaster.pid', 1, 20)) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +== 065 +-- Test missing_ok +select pg_read_file('does not exist') +-- +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +== 066 +-- error +select pg_read_file('does not exist', true) IS NULL +-- +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +== 067 +-- ok +-- Test invalid argument +select pg_read_file('does not exist', 0, -1) +-- +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +== 068 +-- error +select pg_read_file('does not exist', 0, -1, true) +-- +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +== 069 +-- error + +-- pg_read_binary_file() +select length(pg_read_binary_file('postmaster.pid')) > 20 +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +== 070 +select length(pg_read_binary_file('postmaster.pid', 1, 20)) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +== 071 +-- Test missing_ok +select pg_read_binary_file('does not exist') +-- +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +== 072 +-- error +select pg_read_binary_file('does not exist', true) IS NULL +-- +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +== 073 +-- ok +-- Test invalid argument +select pg_read_binary_file('does not exist', 0, -1) +-- +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +== 074 +-- error +select pg_read_binary_file('does not exist', 0, -1, true) +-- +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +== 075 +-- error + +-- pg_stat_file() +select size > 20, isdir from pg_stat_file('postmaster.pid') +-- +FUNCTION: name="pg_stat_file" function="pg_stat_file" schema="" ctx=Call +STMT: SelectStmt +== 076 +-- pg_ls_dir() +select * from (select pg_ls_dir('.') a) a where a = 'base' limit 1 +-- +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 077 +-- Test missing_ok (second argument) +select pg_ls_dir('does not exist', false, false) +-- +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +STMT: SelectStmt +== 078 +-- error +select pg_ls_dir('does not exist', true, false) +-- +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +STMT: SelectStmt +== 079 +-- ok +-- Test include_dot_dirs (third argument) +select count(*) = 1 as dot_found + from pg_ls_dir('.', false, true) as ls where ls = '.' +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +FILTER: schema="" table="" column="ls" +STMT: SelectStmt +== 080 +select count(*) = 1 as dot_found + from pg_ls_dir('.', false, false) as ls where ls = '.' +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +FILTER: schema="" table="" column="ls" +STMT: SelectStmt +== 081 +-- pg_timezone_names() +select * from (select (pg_timezone_names()).name) ptn where name='UTC' limit 1 +-- +FUNCTION: name="pg_timezone_names" function="pg_timezone_names" schema="" ctx=Call +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 082 +-- pg_tablespace_databases() +select count(*) > 0 from + (select pg_tablespace_databases(oid) as pts from pg_tablespace + where spcname = 'pg_default') pts + join pg_database db on pts.pts = db.oid +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "db"="pg_database" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_tablespace_databases" function="pg_tablespace_databases" schema="" ctx=Call +FILTER: schema="" table="" column="spcname" +STMT: SelectStmt +== 083 +|-- +-- Test replication slot directory functions +|-- +CREATE ROLE regress_slot_dir_funcs +-- +STMT: CreateRoleStmt +== 084 +-- Not available by default. +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_logicalsnapdir()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 085 +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_logicalmapdir()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 086 +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_replslotdir(text)', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 087 +GRANT pg_monitor TO regress_slot_dir_funcs +-- +STMT: GrantRoleStmt +== 088 +-- Role is now part of pg_monitor, so these are available. +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_logicalsnapdir()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 089 +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_logicalmapdir()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 090 +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_replslotdir(text)', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 091 +DROP ROLE regress_slot_dir_funcs +-- +STMT: DropRoleStmt +== 092 +|-- +-- Test adding a support function to a subject function +|-- + +CREATE FUNCTION my_int_eq(int, int) RETURNS bool + LANGUAGE internal STRICT IMMUTABLE PARALLEL SAFE + AS $$int4eq$$ +-- +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 093 +-- By default, planner does not think that's selective +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique1 +WHERE my_int_eq(a.unique2, 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=Call +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=Call +FILTER: schema="" table="a" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 094 +-- With support function that knows it's int4eq, we get a different plan +CREATE FUNCTION test_support_func(internal) + RETURNS internal + AS :'regresslib', 'test_support_func' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 146 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 095 +ALTER FUNCTION my_int_eq(int, int) SUPPORT test_support_func +-- +STMT: AlterFunctionStmt +== 096 +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique1 +WHERE my_int_eq(a.unique2, 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=Call +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=Call +FILTER: schema="" table="a" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 097 +-- Also test non-default rowcount estimate +CREATE FUNCTION my_gen_series(int, int) RETURNS SETOF integer + LANGUAGE internal STRICT IMMUTABLE PARALLEL SAFE + AS $$generate_series_int4$$ + SUPPORT test_support_func +-- +FUNCTION: name="my_gen_series" function="my_gen_series" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 098 +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 a JOIN my_gen_series(1,1000) g ON a.unique1 = g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="my_gen_series" function="my_gen_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 099 +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 a JOIN my_gen_series(1,10) g ON a.unique1 = g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="my_gen_series" function="my_gen_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 100 +-- Test functions for control data +SELECT count(*) > 0 AS ok FROM pg_control_checkpoint() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_control_checkpoint" function="pg_control_checkpoint" schema="" ctx=Call +STMT: SelectStmt +== 101 +SELECT count(*) > 0 AS ok FROM pg_control_init() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_control_init" function="pg_control_init" schema="" ctx=Call +STMT: SelectStmt +== 102 +SELECT count(*) > 0 AS ok FROM pg_control_recovery() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_control_recovery" function="pg_control_recovery" schema="" ctx=Call +STMT: SelectStmt +== 103 +SELECT count(*) > 0 AS ok FROM pg_control_system() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_control_system" function="pg_control_system" schema="" ctx=Call +STMT: SelectStmt +== 104 +-- pg_split_walfile_name, pg_walfile_name & pg_walfile_name_offset +SELECT * FROM pg_split_walfile_name(NULL) +-- +FUNCTION: name="pg_split_walfile_name" function="pg_split_walfile_name" schema="" ctx=Call +STMT: SelectStmt +== 105 +SELECT * FROM pg_split_walfile_name('invalid') +-- +FUNCTION: name="pg_split_walfile_name" function="pg_split_walfile_name" schema="" ctx=Call +STMT: SelectStmt +== 106 +SELECT segment_number > 0 AS ok_segment_number, timeline_id + FROM pg_split_walfile_name('000000010000000100000000') +-- +FUNCTION: name="pg_split_walfile_name" function="pg_split_walfile_name" schema="" ctx=Call +STMT: SelectStmt +== 107 +SELECT segment_number > 0 AS ok_segment_number, timeline_id + FROM pg_split_walfile_name('ffffffFF00000001000000af') +-- +FUNCTION: name="pg_split_walfile_name" function="pg_split_walfile_name" schema="" ctx=Call +STMT: SelectStmt +== 108 +SELECT setting::int8 AS segment_size +FROM pg_settings +WHERE name = 'wal_segment_size' +SELECT segment_number, file_offset +FROM pg_walfile_name_offset('0/0'::pg_lsn + :segment_size), + pg_split_walfile_name(file_name) +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 87 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 109 +SELECT segment_number, file_offset +FROM pg_walfile_name_offset('0/0'::pg_lsn + :segment_size + 1), + pg_split_walfile_name(file_name) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 80 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 110 +SELECT segment_number, file_offset = :segment_size - 1 +FROM pg_walfile_name_offset('0/0'::pg_lsn + :segment_size - 1), + pg_split_walfile_name(file_name) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 111 +-- pg_current_logfile +CREATE ROLE regress_current_logfile +-- +STMT: CreateRoleStmt +== 112 +-- not available by default +SELECT has_function_privilege('regress_current_logfile', + 'pg_current_logfile()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 113 +GRANT pg_monitor TO regress_current_logfile +-- +STMT: GrantRoleStmt +== 114 +-- role has privileges of pg_monitor and can execute the function +SELECT has_function_privilege('regress_current_logfile', + 'pg_current_logfile()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +== 115 +DROP ROLE regress_current_logfile +-- +STMT: DropRoleStmt +== 116 +-- pg_column_toast_chunk_id +CREATE TABLE test_chunk_id (a TEXT, b TEXT STORAGE EXTERNAL) +-- +TABLE: name="test_chunk_id" schema="" table="test_chunk_id" ctx=DDL +STMT: CreateStmt +== 117 +INSERT INTO test_chunk_id VALUES ('x', repeat('x', 8192)) +-- +TABLE: name="test_chunk_id" schema="" table="test_chunk_id" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 118 +SELECT t.relname AS toastrel FROM pg_class c + LEFT JOIN pg_class t ON c.reltoastrelid = t.oid + WHERE c.relname = 'test_chunk_id' +SELECT pg_column_toast_chunk_id(a) IS NULL, + pg_column_toast_chunk_id(b) IN (SELECT chunk_id FROM pg_toast.:toastrel) + FROM test_chunk_id +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 132 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 119 +DROP TABLE test_chunk_id +-- +TABLE: name="test_chunk_id" schema="" table="test_chunk_id" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/misc_sanity.metadata.json b/parser/testdata/summary/postgres_regress/misc_sanity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/misc_sanity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/misc_sanity.test b/parser/testdata/summary/postgres_regress/misc_sanity.test new file mode 100644 index 0000000..15ef1c6 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/misc_sanity.test @@ -0,0 +1,118 @@ +== 001 +|-- +-- MISC_SANITY +-- Sanity checks for common errors in making system tables that don't fit +-- comfortably into either opr_sanity or type_sanity. +|-- +-- Every test failure in this file should be closely inspected. +-- The description of the failing test should be read carefully before +-- adjusting the expected output. In most cases, the queries should +-- not find *any* matching entries. +|-- +-- NB: run this test early, because some later tests create bogus entries. + + +-- **************** pg_depend **************** + +-- Look for illegal values in pg_depend fields. + +SELECT * +FROM pg_depend as d1 +WHERE refclassid = 0 OR refobjid = 0 OR + classid = 0 OR objid = 0 OR + deptype NOT IN ('a', 'e', 'i', 'n', 'x', 'P', 'S') +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +ALIAS: "d1"="pg_depend" +FILTER: schema="" table="" column="refclassid" +FILTER: schema="" table="" column="refobjid" +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +FILTER: schema="" table="" column="deptype" +STMT: SelectStmt +== 002 +-- **************** pg_shdepend **************** + +-- Look for illegal values in pg_shdepend fields. + +SELECT * +FROM pg_shdepend as d1 +WHERE refclassid = 0 OR refobjid = 0 OR + classid = 0 OR objid = 0 OR + deptype NOT IN ('a', 'i', 'o', 'r', 't') +-- +TABLE: name="pg_shdepend" schema="" table="pg_shdepend" ctx=Select +ALIAS: "d1"="pg_shdepend" +FILTER: schema="" table="" column="refclassid" +FILTER: schema="" table="" column="refobjid" +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +FILTER: schema="" table="" column="deptype" +STMT: SelectStmt +== 003 +-- **************** pg_class **************** + +-- Look for system tables with varlena columns but no toast table. All +-- system tables with toastable columns should have toast tables, with +-- the following exceptions: +-- 1. pg_class, pg_attribute, and pg_index, due to fear of recursive +-- dependencies as toast tables depend on them. +-- 2. pg_largeobject and pg_largeobject_metadata. Large object catalogs +-- and toast tables are mutually exclusive and large object data is handled +-- as user data by pg_upgrade, which would cause failures. + +SELECT relname, attname, atttypid::regtype +FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid +WHERE c.oid < 16384 AND + reltoastrelid = 0 AND + relkind = 'r' AND + attstorage != 'p' +ORDER BY 1, 2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="reltoastrelid" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="attstorage" +STMT: SelectStmt +== 004 +-- system catalogs without primary keys +|-- +-- Current exceptions: +-- * pg_depend, pg_shdepend don't have a unique key +SELECT relname +FROM pg_class +WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'r' + AND pg_class.oid NOT IN (SELECT indrelid FROM pg_index WHERE indisprimary) +ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="pg_class" column="oid" +FILTER: schema="" table="" column="indisprimary" +STMT: SelectStmt +== 005 +-- system catalog unique indexes not wrapped in a constraint +-- (There should be none.) +SELECT relname +FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid +WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'i' + AND i.indisunique + AND c.oid NOT IN (SELECT conindid FROM pg_constraint) +ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="i" column="indisunique" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/money.metadata.json b/parser/testdata/summary/postgres_regress/money.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/money.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/money.test b/parser/testdata/summary/postgres_regress/money.test new file mode 100644 index 0000000..bf8b4fa --- /dev/null +++ b/parser/testdata/summary/postgres_regress/money.test @@ -0,0 +1,525 @@ +== 001 +|-- +-- MONEY +|-- +-- Note that we assume lc_monetary has been set to C. +|-- + +CREATE TABLE money_data (m money) +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO money_data VALUES ('123') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 004 +SELECT m + '123' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 005 +SELECT m + '123.45' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 006 +SELECT m - '123.45' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 007 +SELECT m / '2'::money FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 008 +SELECT m * 2 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 009 +SELECT 2 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 010 +SELECT m / 2 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 011 +SELECT m * 2::int2 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 012 +SELECT 2::int2 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 013 +SELECT m / 2::int2 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 014 +SELECT m * 2::int8 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 015 +SELECT 2::int8 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 016 +SELECT m / 2::int8 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 017 +SELECT m * 2::float8 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 018 +SELECT 2::float8 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 019 +SELECT m / 2::float8 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 020 +SELECT m * 2::float4 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 021 +SELECT 2::float4 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 022 +SELECT m / 2::float4 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 023 +-- All true +SELECT m = '$123.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 024 +SELECT m != '$124.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 025 +SELECT m <= '$123.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 026 +SELECT m >= '$123.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 027 +SELECT m < '$124.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 028 +SELECT m > '$122.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 029 +-- All false +SELECT m = '$123.01' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 030 +SELECT m != '$123.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 031 +SELECT m <= '$122.99' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 032 +SELECT m >= '$123.01' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 033 +SELECT m > '$124.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 034 +SELECT m < '$122.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 035 +SELECT cashlarger(m, '$124.00') FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +FUNCTION: name="cashlarger" function="cashlarger" schema="" ctx=Call +STMT: SelectStmt +== 036 +SELECT cashsmaller(m, '$124.00') FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +FUNCTION: name="cashsmaller" function="cashsmaller" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT cash_words(m) FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +FUNCTION: name="cash_words" function="cash_words" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT cash_words(m + '1.23') FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +FUNCTION: name="cash_words" function="cash_words" schema="" ctx=Call +STMT: SelectStmt +== 039 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +== 040 +INSERT INTO money_data VALUES ('$123.45') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 042 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +== 043 +INSERT INTO money_data VALUES ('$123.451') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 045 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +== 046 +INSERT INTO money_data VALUES ('$123.454') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 048 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +== 049 +INSERT INTO money_data VALUES ('$123.455') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 051 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +== 052 +INSERT INTO money_data VALUES ('$123.456') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 054 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +== 055 +INSERT INTO money_data VALUES ('$123.459') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +== 057 +-- input checks +SELECT '1234567890'::money +-- +STMT: SelectStmt +== 058 +SELECT '12345678901234567'::money +-- +STMT: SelectStmt +== 059 +SELECT '123456789012345678'::money +-- +STMT: SelectStmt +== 060 +SELECT '9223372036854775807'::money +-- +STMT: SelectStmt +== 061 +SELECT '-12345'::money +-- +STMT: SelectStmt +== 062 +SELECT '-1234567890'::money +-- +STMT: SelectStmt +== 063 +SELECT '-12345678901234567'::money +-- +STMT: SelectStmt +== 064 +SELECT '-123456789012345678'::money +-- +STMT: SelectStmt +== 065 +SELECT '-9223372036854775808'::money +-- +STMT: SelectStmt +== 066 +-- special characters +SELECT '(1)'::money +-- +STMT: SelectStmt +== 067 +SELECT '($123,456.78)'::money +-- +STMT: SelectStmt +== 068 +-- test non-error-throwing API +SELECT pg_input_is_valid('\x0001', 'money') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT * FROM pg_input_error_info('\x0001', 'money') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT pg_input_is_valid('192233720368547758.07', 'money') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT * FROM pg_input_error_info('192233720368547758.07', 'money') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 072 +-- documented minimums and maximums +SELECT '-92233720368547758.08'::money +-- +STMT: SelectStmt +== 073 +SELECT '92233720368547758.07'::money +-- +STMT: SelectStmt +== 074 +SELECT '-92233720368547758.09'::money +-- +STMT: SelectStmt +== 075 +SELECT '92233720368547758.08'::money +-- +STMT: SelectStmt +== 076 +-- rounding +SELECT '-92233720368547758.085'::money +-- +STMT: SelectStmt +== 077 +SELECT '92233720368547758.075'::money +-- +STMT: SelectStmt +== 078 +-- rounding vs. truncation in division +SELECT '878.08'::money / 11::float8 +-- +STMT: SelectStmt +== 079 +SELECT '878.08'::money / 11::float4 +-- +STMT: SelectStmt +== 080 +SELECT '878.08'::money / 11::bigint +-- +STMT: SelectStmt +== 081 +SELECT '878.08'::money / 11::int +-- +STMT: SelectStmt +== 082 +SELECT '878.08'::money / 11::smallint +-- +STMT: SelectStmt +== 083 +-- check for precision loss in division +SELECT '90000000000000099.00'::money / 10::bigint +-- +STMT: SelectStmt +== 084 +SELECT '90000000000000099.00'::money / 10::int +-- +STMT: SelectStmt +== 085 +SELECT '90000000000000099.00'::money / 10::smallint +-- +STMT: SelectStmt +== 086 +-- Cast int4/int8/numeric to money +SELECT 1234567890::money +-- +STMT: SelectStmt +== 087 +SELECT 12345678901234567::money +-- +STMT: SelectStmt +== 088 +SELECT (-12345)::money +-- +STMT: SelectStmt +== 089 +SELECT (-1234567890)::money +-- +STMT: SelectStmt +== 090 +SELECT (-12345678901234567)::money +-- +STMT: SelectStmt +== 091 +SELECT 1234567890::int4::money +-- +STMT: SelectStmt +== 092 +SELECT 12345678901234567::int8::money +-- +STMT: SelectStmt +== 093 +SELECT 12345678901234567::numeric::money +-- +STMT: SelectStmt +== 094 +SELECT (-1234567890)::int4::money +-- +STMT: SelectStmt +== 095 +SELECT (-12345678901234567)::int8::money +-- +STMT: SelectStmt +== 096 +SELECT (-12345678901234567)::numeric::money +-- +STMT: SelectStmt +== 097 +-- Cast from money to numeric +SELECT '12345678901234567'::money::numeric +-- +STMT: SelectStmt +== 098 +SELECT '-12345678901234567'::money::numeric +-- +STMT: SelectStmt +== 099 +SELECT '92233720368547758.07'::money::numeric +-- +STMT: SelectStmt +== 100 +SELECT '-92233720368547758.08'::money::numeric +-- +STMT: SelectStmt +== 101 +-- overflow checks +SELECT '92233720368547758.07'::money + '0.01'::money +-- +STMT: SelectStmt +== 102 +SELECT '-92233720368547758.08'::money - '0.01'::money +-- +STMT: SelectStmt +== 103 +SELECT '92233720368547758.07'::money * 2::float8 +-- +STMT: SelectStmt +== 104 +SELECT '-1'::money / 1.175494e-38::float4 +-- +STMT: SelectStmt +== 105 +SELECT '92233720368547758.07'::money * 2::int4 +-- +STMT: SelectStmt +== 106 +SELECT '1'::money / 0::int2 +-- +STMT: SelectStmt +== 107 +SELECT '42'::money * 'inf'::float8 +-- +STMT: SelectStmt +== 108 +SELECT '42'::money * '-inf'::float8 +-- +STMT: SelectStmt +== 109 +SELECT '42'::money * 'nan'::float4 +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/multirangetypes.metadata.json b/parser/testdata/summary/postgres_regress/multirangetypes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/multirangetypes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/multirangetypes.test b/parser/testdata/summary/postgres_regress/multirangetypes.test new file mode 100644 index 0000000..75b19b6 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/multirangetypes.test @@ -0,0 +1,4086 @@ +== 001 +-- Tests for multirange data types. + +|-- +-- test input parser +|-- + +-- negative tests; should fail +select ''::textmultirange +-- +STMT: SelectStmt +== 002 +select '{,}'::textmultirange +-- +STMT: SelectStmt +== 003 +select '{(,)}.'::textmultirange +-- +STMT: SelectStmt +== 004 +select '{[a,c),}'::textmultirange +-- +STMT: SelectStmt +== 005 +select '{,[a,c)}'::textmultirange +-- +STMT: SelectStmt +== 006 +select '{-[a,z)}'::textmultirange +-- +STMT: SelectStmt +== 007 +select '{[a,z) - }'::textmultirange +-- +STMT: SelectStmt +== 008 +select '{(",a)}'::textmultirange +-- +STMT: SelectStmt +== 009 +select '{(,,a)}'::textmultirange +-- +STMT: SelectStmt +== 010 +select '{(),a)}'::textmultirange +-- +STMT: SelectStmt +== 011 +select '{(a,))}'::textmultirange +-- +STMT: SelectStmt +== 012 +select '{(],a)}'::textmultirange +-- +STMT: SelectStmt +== 013 +select '{(a,])}'::textmultirange +-- +STMT: SelectStmt +== 014 +select '{[z,a]}'::textmultirange +-- +STMT: SelectStmt +== 015 +-- should succeed +select '{}'::textmultirange +-- +STMT: SelectStmt +== 016 +select ' {} '::textmultirange +-- +STMT: SelectStmt +== 017 +select ' { empty, empty } '::textmultirange +-- +STMT: SelectStmt +== 018 +select ' {( " a " " a ", " z " " z " ) }'::textmultirange +-- +STMT: SelectStmt +== 019 +select textrange('\\\\', repeat('a', 200))::textmultirange +-- +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 020 +select '{(,z)}'::textmultirange +-- +STMT: SelectStmt +== 021 +select '{(a,)}'::textmultirange +-- +STMT: SelectStmt +== 022 +select '{[,z]}'::textmultirange +-- +STMT: SelectStmt +== 023 +select '{[a,]}'::textmultirange +-- +STMT: SelectStmt +== 024 +select '{(,)}'::textmultirange +-- +STMT: SelectStmt +== 025 +select '{[ , ]}'::textmultirange +-- +STMT: SelectStmt +== 026 +select '{["",""]}'::textmultirange +-- +STMT: SelectStmt +== 027 +select '{[",",","]}'::textmultirange +-- +STMT: SelectStmt +== 028 +select '{["\\","\\"]}'::textmultirange +-- +STMT: SelectStmt +== 029 +select '{["""","\""]}'::textmultirange +-- +STMT: SelectStmt +== 030 +select '{(\\,a)}'::textmultirange +-- +STMT: SelectStmt +== 031 +select '{((,z)}'::textmultirange +-- +STMT: SelectStmt +== 032 +select '{([,z)}'::textmultirange +-- +STMT: SelectStmt +== 033 +select '{(!,()}'::textmultirange +-- +STMT: SelectStmt +== 034 +select '{(!,[)}'::textmultirange +-- +STMT: SelectStmt +== 035 +select '{[a,a]}'::textmultirange +-- +STMT: SelectStmt +== 036 +select '{[a,a],[a,b]}'::textmultirange +-- +STMT: SelectStmt +== 037 +select '{[a,b), [b,e]}'::textmultirange +-- +STMT: SelectStmt +== 038 +select '{[a,d), [b,f]}'::textmultirange +-- +STMT: SelectStmt +== 039 +select '{[a,a],[b,b]}'::textmultirange +-- +STMT: SelectStmt +== 040 +-- without canonicalization, we can't join these: +select '{[a,a], [b,b]}'::textmultirange +-- +STMT: SelectStmt +== 041 +-- with canonicalization, we can join these: +select '{[1,2], [3,4]}'::int4multirange +-- +STMT: SelectStmt +== 042 +select '{[a,a], [b,b], [c,c]}'::textmultirange +-- +STMT: SelectStmt +== 043 +select '{[a,d], [b,e]}'::textmultirange +-- +STMT: SelectStmt +== 044 +select '{[a,d), [d,e)}'::textmultirange +-- +STMT: SelectStmt +== 045 +-- these are allowed but normalize to empty: +select '{[a,a)}'::textmultirange +-- +STMT: SelectStmt +== 046 +select '{(a,a]}'::textmultirange +-- +STMT: SelectStmt +== 047 +select '{(a,a)}'::textmultirange +-- +STMT: SelectStmt +== 048 +-- Also try it with non-error-throwing API +select pg_input_is_valid('{[1,2], [4,5]}', 'int4multirange') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 049 +select pg_input_is_valid('{[1,2], [4,5]', 'int4multirange') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 050 +select * from pg_input_error_info('{[1,2], [4,5]', 'int4multirange') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 051 +select pg_input_is_valid('{[1,2], [4,zed]}', 'int4multirange') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 052 +select * from pg_input_error_info('{[1,2], [4,zed]}', 'int4multirange') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 053 +|-- +-- test the constructor +--- +select textmultirange() +-- +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +STMT: SelectStmt +== 054 +select textmultirange(textrange('a', 'c')) +-- +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 055 +select textmultirange(textrange('a', 'c'), textrange('f', 'g')) +-- +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 056 +select textmultirange(textrange('\\\\', repeat('a', 200)), textrange('c', 'd')) +-- +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 057 +|-- +-- test casts, both a built-in range type and a user-defined one: +|-- +select 'empty'::int4range::int4multirange +-- +STMT: SelectStmt +== 058 +select int4range(1, 3)::int4multirange +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 059 +select int4range(1, null)::int4multirange +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 060 +select int4range(null, null)::int4multirange +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 061 +select 'empty'::textrange::textmultirange +-- +STMT: SelectStmt +== 062 +select textrange('a', 'c')::textmultirange +-- +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 063 +select textrange('a', null)::textmultirange +-- +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 064 +select textrange(null, null)::textmultirange +-- +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 065 +|-- +-- test unnest(multirange) function +|-- +select unnest(int4multirange(int4range('5', '6'), int4range('1', '2'))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 066 +select unnest(textmultirange(textrange('a', 'b'), textrange('d', 'e'))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 067 +select unnest(textmultirange(textrange('\\\\', repeat('a', 200)), textrange('c', 'd'))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 068 +|-- +-- create some test data and test the operators +|-- + +CREATE TABLE nummultirange_test (nmr NUMMULTIRANGE) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DDL +STMT: CreateStmt +== 069 +CREATE INDEX nummultirange_test_btree ON nummultirange_test(nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DDL +STMT: IndexStmt +== 070 +INSERT INTO nummultirange_test VALUES('{}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +INSERT INTO nummultirange_test VALUES('{[,)}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +INSERT INTO nummultirange_test VALUES('{[3,]}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +INSERT INTO nummultirange_test VALUES('{[,), [3,]}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 074 +INSERT INTO nummultirange_test VALUES('{[, 5)}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +INSERT INTO nummultirange_test VALUES(nummultirange()) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 076 +INSERT INTO nummultirange_test VALUES(nummultirange(variadic '{}'::numrange[])) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 077 +INSERT INTO nummultirange_test VALUES(nummultirange(numrange(1.1, 2.2))) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 078 +INSERT INTO nummultirange_test VALUES('{empty}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 079 +INSERT INTO nummultirange_test VALUES(nummultirange(numrange(1.7, 1.7, '[]'), numrange(1.7, 1.9))) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 080 +INSERT INTO nummultirange_test VALUES(nummultirange(numrange(1.7, 1.7, '[]'), numrange(1.9, 2.1))) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 081 +SELECT nmr, isempty(nmr), lower(nmr), upper(nmr) FROM nummultirange_test ORDER BY nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="isempty" function="isempty" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT nmr, lower_inc(nmr), lower_inf(nmr), upper_inc(nmr), upper_inf(nmr) FROM nummultirange_test ORDER BY nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="lower_inc" function="lower_inc" schema="" ctx=Call +FUNCTION: name="lower_inf" function="lower_inf" schema="" ctx=Call +FUNCTION: name="upper_inc" function="upper_inc" schema="" ctx=Call +FUNCTION: name="upper_inf" function="upper_inf" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT * FROM nummultirange_test WHERE nmr = '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 084 +SELECT * FROM nummultirange_test WHERE nmr = '{(,5)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 085 +SELECT * FROM nummultirange_test WHERE nmr = '{[3,)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 086 +SELECT * FROM nummultirange_test WHERE nmr = '{[1.7,1.7]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 087 +SELECT * FROM nummultirange_test WHERE nmr = '{[1.7,1.7],[1.9,2.1)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 088 +SELECT * FROM nummultirange_test WHERE nmr < '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 089 +SELECT * FROM nummultirange_test WHERE nmr < '{[-1000.0, -1000.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 090 +SELECT * FROM nummultirange_test WHERE nmr < '{[0.0, 1.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 091 +SELECT * FROM nummultirange_test WHERE nmr < '{[1000.0, 1001.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 092 +SELECT * FROM nummultirange_test WHERE nmr <= '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 093 +SELECT * FROM nummultirange_test WHERE nmr <= '{[3,)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 094 +SELECT * FROM nummultirange_test WHERE nmr >= '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 095 +SELECT * FROM nummultirange_test WHERE nmr >= '{[3,)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 096 +SELECT * FROM nummultirange_test WHERE nmr > '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 097 +SELECT * FROM nummultirange_test WHERE nmr > '{[-1000.0, -1000.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 098 +SELECT * FROM nummultirange_test WHERE nmr > '{[0.0, 1.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 099 +SELECT * FROM nummultirange_test WHERE nmr > '{[1000.0, 1001.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 100 +SELECT * FROM nummultirange_test WHERE nmr <> '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 101 +SELECT * FROM nummultirange_test WHERE nmr <> '{(,5)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 102 +select nummultirange(numrange(2.0, 1.0)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 103 +select nummultirange(numrange(5.0, 6.0), numrange(1.0, 2.0)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 104 +analyze nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DDL +STMT: VacuumStmt +== 105 +-- overlaps +SELECT * FROM nummultirange_test WHERE range_overlaps_multirange(numrange(4.0, 4.2), nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_overlaps_multirange" function="range_overlaps_multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="range_overlaps_multirange" function="range_overlaps_multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 106 +SELECT * FROM nummultirange_test WHERE numrange(4.0, 4.2) && nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 107 +SELECT * FROM nummultirange_test WHERE multirange_overlaps_range(nmr, numrange(4.0, 4.2)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_overlaps_range" function="multirange_overlaps_range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="multirange_overlaps_range" function="multirange_overlaps_range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 108 +SELECT * FROM nummultirange_test WHERE nmr && numrange(4.0, 4.2) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 109 +SELECT * FROM nummultirange_test WHERE multirange_overlaps_multirange(nmr, nummultirange(numrange(4.0, 4.2), numrange(6.0, 7.0))) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_overlaps_multirange" function="multirange_overlaps_multirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="multirange_overlaps_multirange" function="multirange_overlaps_multirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 110 +SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(4.0, 4.2), numrange(6.0, 7.0)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 111 +SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(6.0, 7.0)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 112 +SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(6.0, 7.0), numrange(8.0, 9.0)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 113 +-- mr contains x +SELECT * FROM nummultirange_test WHERE multirange_contains_elem(nmr, 4.0) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_contains_elem" function="multirange_contains_elem" schema="" ctx=Call +FUNCTION: name="multirange_contains_elem" function="multirange_contains_elem" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 114 +SELECT * FROM nummultirange_test WHERE nmr @> 4.0 +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 115 +SELECT * FROM nummultirange_test WHERE multirange_contains_range(nmr, numrange(4.0, 4.2)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_contains_range" function="multirange_contains_range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="multirange_contains_range" function="multirange_contains_range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 116 +SELECT * FROM nummultirange_test WHERE nmr @> numrange(4.0, 4.2) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 117 +SELECT * FROM nummultirange_test WHERE multirange_contains_multirange(nmr, '{[4.0,4.2), [6.0, 8.0)}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_contains_multirange" function="multirange_contains_multirange" schema="" ctx=Call +FUNCTION: name="multirange_contains_multirange" function="multirange_contains_multirange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 118 +SELECT * FROM nummultirange_test WHERE nmr @> '{[4.0,4.2), [6.0, 8.0)}'::nummultirange +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 119 +-- x is contained by mr +SELECT * FROM nummultirange_test WHERE elem_contained_by_multirange(4.0, nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="elem_contained_by_multirange" function="elem_contained_by_multirange" schema="" ctx=Call +FUNCTION: name="elem_contained_by_multirange" function="elem_contained_by_multirange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 120 +SELECT * FROM nummultirange_test WHERE 4.0 <@ nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 121 +SELECT * FROM nummultirange_test WHERE range_contained_by_multirange(numrange(4.0, 4.2), nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_contained_by_multirange" function="range_contained_by_multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="range_contained_by_multirange" function="range_contained_by_multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 122 +SELECT * FROM nummultirange_test WHERE numrange(4.0, 4.2) <@ nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 123 +SELECT * FROM nummultirange_test WHERE multirange_contained_by_multirange('{[4.0,4.2), [6.0, 8.0)}', nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_contained_by_multirange" function="multirange_contained_by_multirange" schema="" ctx=Call +FUNCTION: name="multirange_contained_by_multirange" function="multirange_contained_by_multirange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 124 +SELECT * FROM nummultirange_test WHERE '{[4.0,4.2), [6.0, 8.0)}'::nummultirange <@ nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 125 +-- overlaps +SELECT 'empty'::numrange && nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 126 +SELECT 'empty'::numrange && nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 127 +SELECT nummultirange() && 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 128 +SELECT nummultirange(numrange(1,2)) && 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 129 +SELECT nummultirange() && nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 130 +SELECT nummultirange() && nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 131 +SELECT nummultirange(numrange(1,2)) && nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 132 +SELECT nummultirange(numrange(3,4)) && nummultirange(numrange(1,2), numrange(7,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 133 +SELECT nummultirange(numrange(1,2), numrange(7,8)) && nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 134 +SELECT nummultirange(numrange(3,4)) && nummultirange(numrange(1,2), numrange(3.5,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 135 +SELECT nummultirange(numrange(1,2), numrange(3.5,8)) && numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 136 +SELECT nummultirange(numrange(1,2), numrange(3.5,8)) && nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 137 +select '{(10,20),(30,40),(50,60)}'::nummultirange && '(42,92)'::numrange +-- +STMT: SelectStmt +== 138 +-- contains +SELECT nummultirange() @> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 139 +SELECT nummultirange() @> 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 140 +SELECT nummultirange(numrange(null,null)) @> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 141 +SELECT nummultirange(numrange(null,null)) @> numrange(null,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 142 +SELECT nummultirange(numrange(null,null)) @> numrange(2,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 143 +SELECT nummultirange(numrange(null,5)) @> numrange(null,3) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 144 +SELECT nummultirange(numrange(null,5)) @> numrange(null,8) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 145 +SELECT nummultirange(numrange(5,null)) @> numrange(8,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 146 +SELECT nummultirange(numrange(5,null)) @> numrange(3,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 147 +SELECT nummultirange(numrange(1,5)) @> numrange(8,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 148 +SELECT nummultirange(numrange(1,5)) @> numrange(3,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 149 +SELECT nummultirange(numrange(1,5)) @> numrange(1,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 150 +SELECT nummultirange(numrange(1,5)) @> numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 151 +SELECT nummultirange(numrange(-4,-2), numrange(1,5)) @> numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 152 +SELECT nummultirange(numrange(1,5), numrange(8,9)) @> numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 153 +SELECT nummultirange(numrange(1,5), numrange(8,9)) @> numrange(6,7) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 154 +SELECT nummultirange(numrange(1,5), numrange(6,9)) @> numrange(6,7) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 155 +SELECT '{[1,5)}'::nummultirange @> '{[1,5)}' +-- +STMT: SelectStmt +== 156 +SELECT '{[-4,-2), [1,5)}'::nummultirange @> '{[1,5)}' +-- +STMT: SelectStmt +== 157 +SELECT '{[1,5), [8,9)}'::nummultirange @> '{[1,5)}' +-- +STMT: SelectStmt +== 158 +SELECT '{[1,5), [8,9)}'::nummultirange @> '{[6,7)}' +-- +STMT: SelectStmt +== 159 +SELECT '{[1,5), [6,9)}'::nummultirange @> '{[6,7)}' +-- +STMT: SelectStmt +== 160 +select '{(10,20),(30,40),(50,60)}'::nummultirange @> '(52,56)'::numrange +-- +STMT: SelectStmt +== 161 +SELECT numrange(null,null) @> nummultirange(numrange(1,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 162 +SELECT numrange(null,null) @> nummultirange(numrange(null,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 163 +SELECT numrange(null,null) @> nummultirange(numrange(2,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 164 +SELECT numrange(null,5) @> nummultirange(numrange(null,3)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 165 +SELECT numrange(null,5) @> nummultirange(numrange(null,8)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 166 +SELECT numrange(5,null) @> nummultirange(numrange(8,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 167 +SELECT numrange(5,null) @> nummultirange(numrange(3,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 168 +SELECT numrange(1,5) @> nummultirange(numrange(8,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 169 +SELECT numrange(1,5) @> nummultirange(numrange(3,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 170 +SELECT numrange(1,5) @> nummultirange(numrange(1,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 171 +SELECT numrange(1,5) @> nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 172 +SELECT numrange(1,9) @> nummultirange(numrange(-4,-2), numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 173 +SELECT numrange(1,9) @> nummultirange(numrange(1,5), numrange(8,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 174 +SELECT numrange(1,9) @> nummultirange(numrange(1,5), numrange(6,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 175 +SELECT numrange(1,9) @> nummultirange(numrange(1,5), numrange(6,10)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 176 +SELECT '{[1,9)}' @> '{[1,5)}'::nummultirange +-- +STMT: SelectStmt +== 177 +SELECT '{[1,9)}' @> '{[-4,-2), [1,5)}'::nummultirange +-- +STMT: SelectStmt +== 178 +SELECT '{[1,9)}' @> '{[1,5), [8,9)}'::nummultirange +-- +STMT: SelectStmt +== 179 +SELECT '{[1,9)}' @> '{[1,5), [6,9)}'::nummultirange +-- +STMT: SelectStmt +== 180 +SELECT '{[1,9)}' @> '{[1,5), [6,10)}'::nummultirange +-- +STMT: SelectStmt +== 181 +-- is contained by +SELECT nummultirange() <@ nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 182 +SELECT 'empty'::numrange <@ nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 183 +SELECT numrange(1,2) <@ nummultirange(numrange(null,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 184 +SELECT numrange(null,2) <@ nummultirange(numrange(null,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 185 +SELECT numrange(2,null) <@ nummultirange(numrange(null,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 186 +SELECT numrange(null,3) <@ nummultirange(numrange(null,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 187 +SELECT numrange(null,8) <@ nummultirange(numrange(null,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 188 +SELECT numrange(8,null) <@ nummultirange(numrange(5,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 189 +SELECT numrange(3,null) <@ nummultirange(numrange(5,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 190 +SELECT numrange(8,9) <@ nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 191 +SELECT numrange(3,9) <@ nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 192 +SELECT numrange(1,4) <@ nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 193 +SELECT numrange(1,5) <@ nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 194 +SELECT numrange(1,5) <@ nummultirange(numrange(-4,-2), numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 195 +SELECT numrange(1,5) <@ nummultirange(numrange(1,5), numrange(8,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 196 +SELECT numrange(6,7) <@ nummultirange(numrange(1,5), numrange(8,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 197 +SELECT numrange(6,7) <@ nummultirange(numrange(1,5), numrange(6,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 198 +SELECT '{[1,5)}' <@ '{[1,5)}'::nummultirange +-- +STMT: SelectStmt +== 199 +SELECT '{[1,5)}' <@ '{[-4,-2), [1,5)}'::nummultirange +-- +STMT: SelectStmt +== 200 +SELECT '{[1,5)}' <@ '{[1,5), [8,9)}'::nummultirange +-- +STMT: SelectStmt +== 201 +SELECT '{[6,7)}' <@ '{[1,5), [8,9)}'::nummultirange +-- +STMT: SelectStmt +== 202 +SELECT '{[6,7)}' <@ '{[1,5), [6,9)}'::nummultirange +-- +STMT: SelectStmt +== 203 +SELECT nummultirange(numrange(1,2)) <@ numrange(null,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 204 +SELECT nummultirange(numrange(null,2)) <@ numrange(null,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 205 +SELECT nummultirange(numrange(2,null)) <@ numrange(null,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 206 +SELECT nummultirange(numrange(null,3)) <@ numrange(null,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 207 +SELECT nummultirange(numrange(null,8)) <@ numrange(null,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 208 +SELECT nummultirange(numrange(8,null)) <@ numrange(5,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 209 +SELECT nummultirange(numrange(3,null)) <@ numrange(5,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 210 +SELECT nummultirange(numrange(8,9)) <@ numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 211 +SELECT nummultirange(numrange(3,9)) <@ numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 212 +SELECT nummultirange(numrange(1,4)) <@ numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 213 +SELECT nummultirange(numrange(1,5)) <@ numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 214 +SELECT nummultirange(numrange(-4,-2), numrange(1,5)) <@ numrange(1,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 215 +SELECT nummultirange(numrange(1,5), numrange(8,9)) <@ numrange(1,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 216 +SELECT nummultirange(numrange(1,5), numrange(6,9)) <@ numrange(1,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 217 +SELECT nummultirange(numrange(1,5), numrange(6,10)) <@ numrange(1,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 218 +SELECT '{[1,5)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +== 219 +SELECT '{[-4,-2), [1,5)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +== 220 +SELECT '{[1,5), [8,9)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +== 221 +SELECT '{[1,5), [6,9)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +== 222 +SELECT '{[1,5), [6,10)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +== 223 +-- overleft +SELECT 'empty'::numrange &< nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 224 +SELECT 'empty'::numrange &< nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 225 +SELECT nummultirange() &< 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 226 +SELECT nummultirange(numrange(1,2)) &< 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 227 +SELECT nummultirange() &< nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 228 +SELECT nummultirange(numrange(1,2)) &< nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 229 +SELECT nummultirange() &< nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 230 +SELECT numrange(6,7) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 231 +SELECT numrange(1,2) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 232 +SELECT numrange(1,4) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 233 +SELECT numrange(1,6) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 234 +SELECT numrange(3.5,6) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 235 +SELECT nummultirange(numrange(6,7)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 236 +SELECT nummultirange(numrange(1,2)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 237 +SELECT nummultirange(numrange(1,4)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 238 +SELECT nummultirange(numrange(1,6)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 239 +SELECT nummultirange(numrange(3.5,6)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 240 +SELECT nummultirange(numrange(6,7)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 241 +SELECT nummultirange(numrange(1,2)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 242 +SELECT nummultirange(numrange(1,4)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 243 +SELECT nummultirange(numrange(1,6)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 244 +SELECT nummultirange(numrange(3.5,6)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 245 +-- overright +SELECT nummultirange() &> 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 246 +SELECT nummultirange(numrange(1,2)) &> 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 247 +SELECT 'empty'::numrange &> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 248 +SELECT 'empty'::numrange &> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 249 +SELECT nummultirange() &> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 250 +SELECT nummultirange() &> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 251 +SELECT nummultirange(numrange(1,2)) &> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 252 +SELECT nummultirange(numrange(3,4)) &> numrange(6,7) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 253 +SELECT nummultirange(numrange(3,4)) &> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 254 +SELECT nummultirange(numrange(3,4)) &> numrange(1,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 255 +SELECT nummultirange(numrange(3,4)) &> numrange(1,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 256 +SELECT nummultirange(numrange(3,4)) &> numrange(3.5,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 257 +SELECT numrange(3,4) &> nummultirange(numrange(6,7)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 258 +SELECT numrange(3,4) &> nummultirange(numrange(1,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 259 +SELECT numrange(3,4) &> nummultirange(numrange(1,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 260 +SELECT numrange(3,4) &> nummultirange(numrange(1,6)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 261 +SELECT numrange(3,4) &> nummultirange(numrange(3.5,6)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 262 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(6,7)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 263 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 264 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(1,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 265 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(1,6)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 266 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(3.5,6)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 267 +-- meets +SELECT 'empty'::numrange -|- nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 268 +SELECT 'empty'::numrange -|- nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 269 +SELECT nummultirange() -|- 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 270 +SELECT nummultirange(numrange(1,2)) -|- 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 271 +SELECT nummultirange() -|- nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 272 +SELECT nummultirange(numrange(1,2)) -|- nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 273 +SELECT nummultirange() -|- nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 274 +SELECT numrange(1,2) -|- nummultirange(numrange(2,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 275 +SELECT numrange(1,2) -|- nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 276 +SELECT nummultirange(numrange(1,2)) -|- numrange(2,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 277 +SELECT nummultirange(numrange(1,2)) -|- numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 278 +SELECT nummultirange(numrange(1,2)) -|- nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 279 +SELECT nummultirange(numrange(1,2)) -|- nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 280 +SELECT nummultirange(numrange(1,2), numrange(5,6)) -|- nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 281 +SELECT nummultirange(numrange(1,2), numrange(5,6)) -|- nummultirange(numrange(6,7)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 282 +SELECT nummultirange(numrange(1,2), numrange(5,6)) -|- nummultirange(numrange(8,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 283 +SELECT nummultirange(numrange(1,2)) -|- nummultirange(numrange(2,4), numrange(6,7)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 284 +-- strictly left +select 'empty'::numrange << nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 285 +select numrange(1,2) << nummultirange() +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 286 +select numrange(1,2) << nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 287 +select numrange(1,2) << nummultirange(numrange(0,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 288 +select numrange(1,2) << nummultirange(numrange(0,4), numrange(7,8)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 289 +select nummultirange() << 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 290 +select nummultirange() << numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 291 +select nummultirange(numrange(3,4)) << numrange(3,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 292 +select nummultirange(numrange(0,2)) << numrange(3,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 293 +select nummultirange(numrange(0,2), numrange(7,8)) << numrange(3,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 294 +select nummultirange(numrange(-4,-2), numrange(0,2)) << numrange(3,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 295 +select nummultirange() << nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 296 +select nummultirange() << nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 297 +select nummultirange(numrange(1,2)) << nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 298 +select nummultirange(numrange(1,2)) << nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 299 +select nummultirange(numrange(1,2)) << nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 300 +select nummultirange(numrange(1,2)) << nummultirange(numrange(3,4), numrange(7,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 301 +select nummultirange(numrange(1,2), numrange(4,5)) << nummultirange(numrange(3,4), numrange(7,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 302 +-- strictly right +select nummultirange() >> 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 303 +select nummultirange() >> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 304 +select nummultirange(numrange(3,4)) >> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 305 +select nummultirange(numrange(0,4)) >> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 306 +select nummultirange(numrange(0,4), numrange(7,8)) >> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 307 +select 'empty'::numrange >> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 308 +select numrange(1,2) >> nummultirange() +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 309 +select numrange(3,6) >> nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 310 +select numrange(3,6) >> nummultirange(numrange(0,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 311 +select numrange(3,6) >> nummultirange(numrange(0,2), numrange(7,8)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 312 +select numrange(3,6) >> nummultirange(numrange(-4,-2), numrange(0,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 313 +select nummultirange() >> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 314 +select nummultirange(numrange(1,2)) >> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 315 +select nummultirange() >> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 316 +select nummultirange(numrange(1,2)) >> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 317 +select nummultirange(numrange(3,4)) >> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 318 +select nummultirange(numrange(3,4), numrange(7,8)) >> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 319 +select nummultirange(numrange(3,4), numrange(7,8)) >> nummultirange(numrange(1,2), numrange(4,5)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 320 +-- union +SELECT nummultirange() + nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 321 +SELECT nummultirange() + nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 322 +SELECT nummultirange(numrange(1,2)) + nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 323 +SELECT nummultirange(numrange(1,2)) + nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 324 +SELECT nummultirange(numrange(1,2)) + nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 325 +SELECT nummultirange(numrange(1,2)) + nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 326 +SELECT nummultirange(numrange(1,2), numrange(4,5)) + nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 327 +SELECT nummultirange(numrange(1,2), numrange(4,5)) + nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 328 +SELECT nummultirange(numrange(1,2), numrange(4,5)) + nummultirange(numrange(0,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 329 +-- merge +SELECT range_merge(nummultirange()) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 330 +SELECT range_merge(nummultirange(numrange(1,2))) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 331 +SELECT range_merge(nummultirange(numrange(1,2), numrange(7,8))) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 332 +-- minus +SELECT nummultirange() - nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 333 +SELECT nummultirange() - nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 334 +SELECT nummultirange(numrange(1,2)) - nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 335 +SELECT nummultirange(numrange(1,2), numrange(3,4)) - nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 336 +SELECT nummultirange(numrange(1,2)) - nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 337 +SELECT nummultirange(numrange(1,2)) - nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 338 +SELECT nummultirange(numrange(1,2)) - nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 339 +SELECT nummultirange(numrange(1,4)) - nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 340 +SELECT nummultirange(numrange(1,4)) - nummultirange(numrange(2,3)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 341 +SELECT nummultirange(numrange(1,4)) - nummultirange(numrange(0,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 342 +SELECT nummultirange(numrange(1,4)) - nummultirange(numrange(0,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 343 +SELECT nummultirange(numrange(1,8)) - nummultirange(numrange(0,2), numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 344 +SELECT nummultirange(numrange(1,8)) - nummultirange(numrange(2,3), numrange(5,null)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 345 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(-2,0)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 346 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 347 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(3,5)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 348 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(0,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 349 +SELECT nummultirange(numrange(1,3), numrange(4,5)) - nummultirange(numrange(2,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 350 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(8,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 351 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(-2,0), numrange(8,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 352 +-- intersection +SELECT nummultirange() * nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 353 +SELECT nummultirange() * nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 354 +SELECT nummultirange(numrange(1,2)) * nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +== 355 +SELECT '{[1,3)}'::nummultirange * '{[1,5)}'::nummultirange +-- +STMT: SelectStmt +== 356 +SELECT '{[1,3)}'::nummultirange * '{[0,5)}'::nummultirange +-- +STMT: SelectStmt +== 357 +SELECT '{[1,3)}'::nummultirange * '{[0,2)}'::nummultirange +-- +STMT: SelectStmt +== 358 +SELECT '{[1,3)}'::nummultirange * '{[2,5)}'::nummultirange +-- +STMT: SelectStmt +== 359 +SELECT '{[1,4)}'::nummultirange * '{[2,3)}'::nummultirange +-- +STMT: SelectStmt +== 360 +SELECT '{[1,4)}'::nummultirange * '{[0,2), [3,5)}'::nummultirange +-- +STMT: SelectStmt +== 361 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,8), [9,12)}'::nummultirange +-- +STMT: SelectStmt +== 362 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[9,12)}'::nummultirange +-- +STMT: SelectStmt +== 363 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[-5,-4), [5,6), [9,12)}'::nummultirange +-- +STMT: SelectStmt +== 364 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,2), [3,8), [9,12)}'::nummultirange +-- +STMT: SelectStmt +== 365 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,2), [3,8), [9,12)}'::nummultirange +-- +STMT: SelectStmt +== 366 +-- test GiST index +create table test_multirange_gist(mr int4multirange) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DDL +STMT: CreateStmt +== 367 +insert into test_multirange_gist select int4multirange(int4range(g, g+10),int4range(g+20, g+30),int4range(g+40, g+50)) from generate_series(1,2000) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 368 +insert into test_multirange_gist select '{}'::int4multirange from generate_series(1,500) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 369 +insert into test_multirange_gist select int4multirange(int4range(g, g+10000)) from generate_series(1,1000) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 370 +insert into test_multirange_gist select int4multirange(int4range(NULL, g*10, '(]'), int4range(g*10, g*20, '(]')) from generate_series(1,100) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 371 +insert into test_multirange_gist select int4multirange(int4range(g*10, g*20, '(]'), int4range(g*20, NULL, '(]')) from generate_series(1,100) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 372 +create index test_mulrirange_gist_idx on test_multirange_gist using gist (mr) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DDL +STMT: IndexStmt +== 373 +-- test statistics and selectivity estimation as well +|-- +-- We don't check the accuracy of selectivity estimation, but at least check +-- it doesn't fall. +analyze test_multirange_gist +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DDL +STMT: VacuumStmt +== 374 +-- first, verify non-indexed results +SET enable_seqscan = t +-- +STMT: VariableSetStmt +== 375 +SET enable_indexscan = f +-- +STMT: VariableSetStmt +== 376 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +== 377 +select count(*) from test_multirange_gist where mr = '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 378 +select count(*) from test_multirange_gist where mr @> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 379 +select count(*) from test_multirange_gist where mr && 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 380 +select count(*) from test_multirange_gist where mr <@ 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 381 +select count(*) from test_multirange_gist where mr << 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 382 +select count(*) from test_multirange_gist where mr >> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 383 +select count(*) from test_multirange_gist where mr &< 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 384 +select count(*) from test_multirange_gist where mr &> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 385 +select count(*) from test_multirange_gist where mr -|- 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 386 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 387 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 388 +select count(*) from test_multirange_gist where mr && '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 389 +select count(*) from test_multirange_gist where mr <@ '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 390 +select count(*) from test_multirange_gist where mr << '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 391 +select count(*) from test_multirange_gist where mr >> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 392 +select count(*) from test_multirange_gist where mr &< '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 393 +select count(*) from test_multirange_gist where mr &> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 394 +select count(*) from test_multirange_gist where mr -|- '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 395 +select count(*) from test_multirange_gist where mr = int4multirange(int4range(10,20), int4range(30,40), int4range(50,60)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 396 +select count(*) from test_multirange_gist where mr @> 10 +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 397 +select count(*) from test_multirange_gist where mr @> int4range(10,20) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 398 +select count(*) from test_multirange_gist where mr && int4range(10,20) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 399 +select count(*) from test_multirange_gist where mr <@ int4range(10,50) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 400 +select count(*) from test_multirange_gist where mr << int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 401 +select count(*) from test_multirange_gist where mr >> int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 402 +select count(*) from test_multirange_gist where mr &< int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 403 +select count(*) from test_multirange_gist where mr &> int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 404 +select count(*) from test_multirange_gist where mr -|- int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 405 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 406 +select count(*) from test_multirange_gist where mr @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 407 +select count(*) from test_multirange_gist where mr && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 408 +select count(*) from test_multirange_gist where mr <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 409 +select count(*) from test_multirange_gist where mr << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 410 +select count(*) from test_multirange_gist where mr >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 411 +select count(*) from test_multirange_gist where mr &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 412 +select count(*) from test_multirange_gist where mr &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 413 +select count(*) from test_multirange_gist where mr -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 414 +-- now check same queries using index +SET enable_seqscan = f +-- +STMT: VariableSetStmt +== 415 +SET enable_indexscan = t +-- +STMT: VariableSetStmt +== 416 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +== 417 +select count(*) from test_multirange_gist where mr = '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 418 +select count(*) from test_multirange_gist where mr @> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 419 +select count(*) from test_multirange_gist where mr && 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 420 +select count(*) from test_multirange_gist where mr <@ 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 421 +select count(*) from test_multirange_gist where mr << 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 422 +select count(*) from test_multirange_gist where mr >> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 423 +select count(*) from test_multirange_gist where mr &< 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 424 +select count(*) from test_multirange_gist where mr &> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 425 +select count(*) from test_multirange_gist where mr -|- 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 426 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 427 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 428 +select count(*) from test_multirange_gist where mr && '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 429 +select count(*) from test_multirange_gist where mr <@ '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 430 +select count(*) from test_multirange_gist where mr << '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 431 +select count(*) from test_multirange_gist where mr >> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 432 +select count(*) from test_multirange_gist where mr &< '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 433 +select count(*) from test_multirange_gist where mr &> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 434 +select count(*) from test_multirange_gist where mr -|- '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 435 +select count(*) from test_multirange_gist where mr @> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 436 +select count(*) from test_multirange_gist where mr = int4multirange(int4range(10,20), int4range(30,40), int4range(50,60)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 437 +select count(*) from test_multirange_gist where mr @> 10 +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 438 +select count(*) from test_multirange_gist where mr @> int4range(10,20) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 439 +select count(*) from test_multirange_gist where mr && int4range(10,20) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 440 +select count(*) from test_multirange_gist where mr <@ int4range(10,50) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 441 +select count(*) from test_multirange_gist where mr << int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 442 +select count(*) from test_multirange_gist where mr >> int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 443 +select count(*) from test_multirange_gist where mr &< int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 444 +select count(*) from test_multirange_gist where mr &> int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 445 +select count(*) from test_multirange_gist where mr -|- int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 446 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 447 +select count(*) from test_multirange_gist where mr @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 448 +select count(*) from test_multirange_gist where mr && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 449 +select count(*) from test_multirange_gist where mr <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 450 +select count(*) from test_multirange_gist where mr << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 451 +select count(*) from test_multirange_gist where mr >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 452 +select count(*) from test_multirange_gist where mr &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 453 +select count(*) from test_multirange_gist where mr &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 454 +select count(*) from test_multirange_gist where mr -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +== 455 +drop table test_multirange_gist +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DDL +STMT: DropStmt +== 456 +|-- +-- range_agg function +|-- +create table reservations ( room_id integer not null, booked_during daterange ) +-- +TABLE: name="reservations" schema="" table="reservations" ctx=DDL +STMT: CreateStmt +== 457 +insert into reservations values +-- 1: has a meets and a gap +(1, daterange('2018-07-01', '2018-07-07')), +(1, daterange('2018-07-07', '2018-07-14')), +(1, daterange('2018-07-20', '2018-07-22')), +-- 2: just a single row +(2, daterange('2018-07-01', '2018-07-03')), +-- 3: one null range +(3, NULL), +-- 4: two null ranges +(4, NULL), +(4, NULL), +-- 5: a null range and a non-null range +(5, NULL), +(5, daterange('2018-07-01', '2018-07-03')), +-- 6: has overlap +(6, daterange('2018-07-01', '2018-07-07')), +(6, daterange('2018-07-05', '2018-07-10')), +-- 7: two ranges that meet: no gap or overlap +(7, daterange('2018-07-01', '2018-07-07')), +(7, daterange('2018-07-07', '2018-07-14')), +-- 8: an empty range +(8, 'empty'::daterange) +-- +TABLE: name="reservations" schema="" table="reservations" ctx=DML +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 458 +SELECT room_id, range_agg(booked_during) +FROM reservations +GROUP BY room_id +ORDER BY room_id +-- +TABLE: name="reservations" schema="" table="reservations" ctx=Select +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 459 +-- range_agg on a custom range type too +SELECT range_agg(r) +FROM (VALUES + ('[a,c]'::textrange), + ('[b,b]'::textrange), + ('[c,f]'::textrange), + ('[g,h)'::textrange), + ('[h,j)'::textrange) + ) t(r) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 460 +-- range_agg with multirange inputs +select range_agg(nmr) from nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 461 +select range_agg(nmr) from nummultirange_test where false +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 462 +select range_agg(null::nummultirange) from nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 463 +select range_agg(nmr) from (values ('{}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 464 +select range_agg(nmr) from (values ('{}'::nummultirange), ('{}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 465 +select range_agg(nmr) from (values ('{[1,2]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 466 +select range_agg(nmr) from (values ('{[1,2], [5,6]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 467 +select range_agg(nmr) from (values ('{[1,2], [2,3]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 468 +select range_agg(nmr) from (values ('{[1,2]}'::nummultirange), ('{[5,6]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 469 +select range_agg(nmr) from (values ('{[1,2]}'::nummultirange), ('{[2,3]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +== 470 +|-- +-- range_intersect_agg function +|-- +select range_intersect_agg(nmr) from nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 471 +select range_intersect_agg(nmr) from nummultirange_test where false +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 472 +select range_intersect_agg(null::nummultirange) from nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 473 +select range_intersect_agg(nmr) from (values ('{[1,3]}'::nummultirange), ('{[6,12]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 474 +select range_intersect_agg(nmr) from (values ('{[1,6]}'::nummultirange), ('{[3,12]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 475 +select range_intersect_agg(nmr) from (values ('{[1,6], [10,12]}'::nummultirange), ('{[4,14]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 476 +-- test with just one input: +select range_intersect_agg(nmr) from (values ('{}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 477 +select range_intersect_agg(nmr) from (values ('{[1,2]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 478 +select range_intersect_agg(nmr) from (values ('{[1,6], [10,12]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 479 +select range_intersect_agg(nmr) from nummultirange_test where nmr @> 4.0 +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 480 +create table nummultirange_test2(nmr nummultirange) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DDL +STMT: CreateStmt +== 481 +create index nummultirange_test2_hash_idx on nummultirange_test2 using hash (nmr) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DDL +STMT: IndexStmt +== 482 +INSERT INTO nummultirange_test2 VALUES('{[, 5)}') +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 483 +INSERT INTO nummultirange_test2 VALUES(nummultirange(numrange(1.1, 2.2))) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 484 +INSERT INTO nummultirange_test2 VALUES(nummultirange(numrange(1.1, 2.2))) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 485 +INSERT INTO nummultirange_test2 VALUES(nummultirange(numrange(1.1, 2.2,'()'))) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 486 +INSERT INTO nummultirange_test2 VALUES('{}') +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 487 +select * from nummultirange_test2 where nmr = '{}' +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 488 +select * from nummultirange_test2 where nmr = nummultirange(numrange(1.1, 2.2)) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 489 +select * from nummultirange_test2 where nmr = nummultirange(numrange(1.1, 2.3)) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +== 490 +set enable_nestloop=t +-- +STMT: VariableSetStmt +== 491 +set enable_hashjoin=f +-- +STMT: VariableSetStmt +== 492 +set enable_mergejoin=f +-- +STMT: VariableSetStmt +== 493 +select * from nummultirange_test natural join nummultirange_test2 order by nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +STMT: SelectStmt +== 494 +set enable_nestloop=f +-- +STMT: VariableSetStmt +== 495 +set enable_hashjoin=t +-- +STMT: VariableSetStmt +== 496 +set enable_mergejoin=f +-- +STMT: VariableSetStmt +== 497 +select * from nummultirange_test natural join nummultirange_test2 order by nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +STMT: SelectStmt +== 498 +set enable_nestloop=f +-- +STMT: VariableSetStmt +== 499 +set enable_hashjoin=f +-- +STMT: VariableSetStmt +== 500 +set enable_mergejoin=t +-- +STMT: VariableSetStmt +== 501 +select * from nummultirange_test natural join nummultirange_test2 order by nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +STMT: SelectStmt +== 502 +set enable_nestloop to default +-- +STMT: VariableSetStmt +== 503 +set enable_hashjoin to default +-- +STMT: VariableSetStmt +== 504 +set enable_mergejoin to default +-- +STMT: VariableSetStmt +== 505 +DROP TABLE nummultirange_test2 +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DDL +STMT: DropStmt +== 506 +|-- +-- Test user-defined multirange of floats +|-- + +select '{[123.001, 5.e9)}'::float8multirange @> 888.882::float8 +-- +STMT: SelectStmt +== 507 +create table float8multirange_test(f8mr float8multirange, i int) +-- +TABLE: name="float8multirange_test" schema="" table="float8multirange_test" ctx=DDL +STMT: CreateStmt +== 508 +insert into float8multirange_test values(float8multirange(float8range(-100.00007, '1.111113e9')), 42) +-- +TABLE: name="float8multirange_test" schema="" table="float8multirange_test" ctx=DML +FUNCTION: name="float8multirange" function="float8multirange" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 509 +select * from float8multirange_test +-- +TABLE: name="float8multirange_test" schema="" table="float8multirange_test" ctx=Select +STMT: SelectStmt +== 510 +drop table float8multirange_test +-- +TABLE: name="float8multirange_test" schema="" table="float8multirange_test" ctx=DDL +STMT: DropStmt +== 511 +|-- +-- Test multirange types over domains +|-- + +create domain mydomain as int4 +-- +STMT: CreateDomainStmt +== 512 +create type mydomainrange as range(subtype=mydomain) +-- +STMT: CreateRangeStmt +== 513 +select '{[4,50)}'::mydomainmultirange @> 7::mydomain +-- +STMT: SelectStmt +== 514 +drop domain mydomain cascade +-- +STMT: DropStmt +== 515 +|-- +-- Test domains over multirange types +|-- + +create domain restrictedmultirange as int4multirange check (upper(value) < 10) +-- +STMT: CreateDomainStmt +== 516 +select '{[4,5)}'::restrictedmultirange @> 7 +-- +STMT: SelectStmt +== 517 +select '{[4,50)}'::restrictedmultirange @> 7 +-- +STMT: SelectStmt +== 518 +-- should fail +drop domain restrictedmultirange +-- +STMT: DropStmt +== 519 +--- +-- Check automatic naming of multiranges +--- + +create type intr as range(subtype=int) +-- +STMT: CreateRangeStmt +== 520 +select intr_multirange(intr(1,10)) +-- +FUNCTION: name="intr_multirange" function="intr_multirange" schema="" ctx=Call +FUNCTION: name="intr" function="intr" schema="" ctx=Call +STMT: SelectStmt +== 521 +drop type intr +-- +STMT: DropStmt +== 522 +create type intmultirange as (x int, y int) +-- +STMT: CompositeTypeStmt +== 523 +create type intrange as range(subtype=int) +-- +STMT: CreateRangeStmt +== 524 +-- should fail +drop type intmultirange +-- +STMT: DropStmt +== 525 +create type intr_multirange as (x int, y int) +-- +STMT: CompositeTypeStmt +== 526 +create type intr as range(subtype=int) +-- +STMT: CreateRangeStmt +== 527 +-- should fail +drop type intr_multirange +-- +STMT: DropStmt +== 528 +|-- +-- Test multiple multirange types over the same subtype and manual naming of +-- the multirange type. +|-- + +-- should fail +create type textrange1 as range(subtype=text, multirange_type_name=int, collation="C") +-- +STMT: CreateRangeStmt +== 529 +-- should pass +create type textrange1 as range(subtype=text, multirange_type_name=multirange_of_text, collation="C") +-- +STMT: CreateRangeStmt +== 530 +-- should pass, because existing _textrange1 is automatically renamed +create type textrange2 as range(subtype=text, multirange_type_name=_textrange1, collation="C") +-- +STMT: CreateRangeStmt +== 531 +select multirange_of_text(textrange2('a','Z')) +-- +FUNCTION: name="multirange_of_text" function="multirange_of_text" schema="" ctx=Call +FUNCTION: name="textrange2" function="textrange2" schema="" ctx=Call +STMT: SelectStmt +== 532 +-- should fail +select multirange_of_text(textrange1('a','Z')) @> 'b'::text +-- +FUNCTION: name="multirange_of_text" function="multirange_of_text" schema="" ctx=Call +FUNCTION: name="textrange1" function="textrange1" schema="" ctx=Call +STMT: SelectStmt +== 533 +select unnest(multirange_of_text(textrange1('a','b'), textrange1('d','e'))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="multirange_of_text" function="multirange_of_text" schema="" ctx=Call +FUNCTION: name="textrange1" function="textrange1" schema="" ctx=Call +FUNCTION: name="textrange1" function="textrange1" schema="" ctx=Call +STMT: SelectStmt +== 534 +select _textrange1(textrange2('a','z')) @> 'b'::text +-- +FUNCTION: name="_textrange1" function="_textrange1" schema="" ctx=Call +FUNCTION: name="textrange2" function="textrange2" schema="" ctx=Call +STMT: SelectStmt +== 535 +drop type textrange1 +-- +STMT: DropStmt +== 536 +drop type textrange2 +-- +STMT: DropStmt +== 537 +|-- +-- Multiranges don't have their own ownership or permissions. +|-- +create type textrange1 as range(subtype=text, multirange_type_name=multitextrange1, collation="C") +-- +STMT: CreateRangeStmt +== 538 +create role regress_multirange_owner +-- +STMT: CreateRoleStmt +== 539 +alter type multitextrange1 owner to regress_multirange_owner +-- +STMT: AlterOwnerStmt +== 540 +-- fail +alter type textrange1 owner to regress_multirange_owner +-- +STMT: AlterOwnerStmt +== 541 +set role regress_multirange_owner +-- +STMT: VariableSetStmt +== 542 +revoke usage on type multitextrange1 from public +-- +STMT: GrantStmt +== 543 +-- fail +revoke usage on type textrange1 from public +-- +STMT: GrantStmt +== 544 +create temp table test1(f1 multitextrange1[]) +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: CreateStmt +== 545 +revoke usage on type textrange1 from regress_multirange_owner +-- +STMT: GrantStmt +== 546 +create temp table test2(f1 multitextrange1[]) +-- +TABLE: name="test2" schema="" table="test2" ctx=DDL +STMT: CreateStmt +== 547 +-- fail + +drop table test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: DropStmt +== 548 +drop type textrange1 +-- +STMT: DropStmt +== 549 +reset role +-- +STMT: VariableSetStmt +== 550 +drop role regress_multirange_owner +-- +STMT: DropRoleStmt +== 551 +|-- +-- Test polymorphic type system +|-- + +create function anyarray_anymultirange_func(a anyarray, r anymultirange) + returns anyelement as 'select $1[1] + lower($2);' language sql +-- +FUNCTION: name="anyarray_anymultirange_func" function="anyarray_anymultirange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 552 +select anyarray_anymultirange_func(ARRAY[1,2], int4multirange(int4range(10,20))) +-- +FUNCTION: name="anyarray_anymultirange_func" function="anyarray_anymultirange_func" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 553 +-- should fail +select anyarray_anymultirange_func(ARRAY[1,2], nummultirange(numrange(10,20))) +-- +FUNCTION: name="anyarray_anymultirange_func" function="anyarray_anymultirange_func" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 554 +drop function anyarray_anymultirange_func(anyarray, anymultirange) +-- +FUNCTION: name="anyarray_anymultirange_func" function="anyarray_anymultirange_func" schema="" ctx=DDL +STMT: DropStmt +== 555 +-- should fail +create function bogus_func(anyelement) + returns anymultirange as 'select int4multirange(int4range(1,10))' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 556 +-- should fail +create function bogus_func(int) + returns anymultirange as 'select int4multirange(int4range(1,10))' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 557 +create function range_add_bounds(anymultirange) + returns anyelement as 'select lower($1) + upper($1)' language sql +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 558 +select range_add_bounds(int4multirange(int4range(1, 17))) +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 559 +select range_add_bounds(nummultirange(numrange(1.0001, 123.123))) +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 560 +create function multirangetypes_sql(q anymultirange, b anyarray, out c anyelement) + as $$ select upper($1) + $2[1] $$ + language sql +-- +FUNCTION: name="multirangetypes_sql" function="multirangetypes_sql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 561 +select multirangetypes_sql(int4multirange(int4range(1,10)), ARRAY[2,20]) +-- +FUNCTION: name="multirangetypes_sql" function="multirangetypes_sql" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 562 +select multirangetypes_sql(nummultirange(numrange(1,10)), ARRAY[2,20]) +-- +FUNCTION: name="multirangetypes_sql" function="multirangetypes_sql" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 563 +-- match failure + +create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange) + returns anycompatible as 'select $1[1] + lower($2);' language sql +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 564 +select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20))) +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 565 +select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(numrange(10,20))) +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 566 +-- should fail +select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1.1,2], multirange(int4range(10,20))) +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 567 +drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange) +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=DDL +STMT: DropStmt +== 568 +create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange) + returns anycompatible as 'select lower($1) + lower($2);' language sql +-- +FUNCTION: name="anycompatiblerange_anycompatiblemultirange_func" function="anycompatiblerange_anycompatiblemultirange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 569 +select anycompatiblerange_anycompatiblemultirange_func(int4range(1,2), multirange(int4range(10,20))) +-- +FUNCTION: name="anycompatiblerange_anycompatiblemultirange_func" function="anycompatiblerange_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 570 +-- should fail +select anycompatiblerange_anycompatiblemultirange_func(numrange(1,2), multirange(int4range(10,20))) +-- +FUNCTION: name="anycompatiblerange_anycompatiblemultirange_func" function="anycompatiblerange_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 571 +drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange, anycompatiblemultirange) +-- +FUNCTION: name="anycompatiblerange_anycompatiblemultirange_func" function="anycompatiblerange_anycompatiblemultirange_func" schema="" ctx=DDL +STMT: DropStmt +== 572 +-- should fail +create function bogus_func(anycompatible) + returns anycompatiblerange as 'select int4range(1,10)' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 573 +|-- +-- Arrays of multiranges +|-- + +select ARRAY[nummultirange(numrange(1.1, 1.2)), nummultirange(numrange(12.3, 155.5))] +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 574 +create table i8mr_array (f1 int, f2 int8multirange[]) +-- +TABLE: name="i8mr_array" schema="" table="i8mr_array" ctx=DDL +STMT: CreateStmt +== 575 +insert into i8mr_array values (42, array[int8multirange(int8range(1,10)), int8multirange(int8range(2,20))]) +-- +TABLE: name="i8mr_array" schema="" table="i8mr_array" ctx=DML +FUNCTION: name="int8multirange" function="int8multirange" schema="" ctx=Call +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +FUNCTION: name="int8multirange" function="int8multirange" schema="" ctx=Call +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 576 +select * from i8mr_array +-- +TABLE: name="i8mr_array" schema="" table="i8mr_array" ctx=Select +STMT: SelectStmt +== 577 +drop table i8mr_array +-- +TABLE: name="i8mr_array" schema="" table="i8mr_array" ctx=DDL +STMT: DropStmt +== 578 +|-- +-- Multiranges of arrays +|-- + +select arraymultirange(arrayrange(ARRAY[1,2], ARRAY[2,1])) +-- +FUNCTION: name="arraymultirange" function="arraymultirange" schema="" ctx=Call +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +== 579 +select arraymultirange(arrayrange(ARRAY[2,1], ARRAY[1,2])) +-- +FUNCTION: name="arraymultirange" function="arraymultirange" schema="" ctx=Call +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +== 580 +-- fail + +select array[1,1] <@ arraymultirange(arrayrange(array[1,2], array[2,1])) +-- +FUNCTION: name="arraymultirange" function="arraymultirange" schema="" ctx=Call +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +== 581 +select array[1,3] <@ arraymultirange(arrayrange(array[1,2], array[2,1])) +-- +FUNCTION: name="arraymultirange" function="arraymultirange" schema="" ctx=Call +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +== 582 +|-- +-- Ranges of composites +|-- + +create type two_ints as (a int, b int) +-- +STMT: CompositeTypeStmt +== 583 +create type two_ints_range as range (subtype = two_ints) +-- +STMT: CreateRangeStmt +== 584 +-- with debug_parallel_query on, this exercises tqueue.c's range remapping +select *, row_to_json(upper(t)) as u from + (values (two_ints_multirange(two_ints_range(row(1,2), row(3,4)))), + (two_ints_multirange(two_ints_range(row(5,6), row(7,8))))) v(t) +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="two_ints_multirange" function="two_ints_multirange" schema="" ctx=Call +FUNCTION: name="two_ints_range" function="two_ints_range" schema="" ctx=Call +FUNCTION: name="two_ints_multirange" function="two_ints_multirange" schema="" ctx=Call +FUNCTION: name="two_ints_range" function="two_ints_range" schema="" ctx=Call +STMT: SelectStmt +== 585 +drop type two_ints cascade +-- +STMT: DropStmt +== 586 +|-- +-- Check behavior when subtype lacks a hash function +|-- + +set enable_sort = off +-- +STMT: VariableSetStmt +== 587 +-- try to make it pick a hash setop implementation + +select '{(01,10)}'::varbitmultirange except select '{(10,11)}'::varbitmultirange +-- +STMT: SelectStmt +== 588 +reset enable_sort +-- +STMT: VariableSetStmt +== 589 +|-- +-- OUT/INOUT/TABLE functions +|-- + +-- infer anymultirange from anymultirange +create function mr_outparam_succeed(i anymultirange, out r anymultirange, out t text) + as $$ select $1, 'foo'::text $$ language sql +-- +FUNCTION: name="mr_outparam_succeed" function="mr_outparam_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 590 +select * from mr_outparam_succeed(int4multirange(int4range(1,2))) +-- +FUNCTION: name="mr_outparam_succeed" function="mr_outparam_succeed" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 591 +-- infer anyarray from anymultirange +create function mr_outparam_succeed2(i anymultirange, out r anyarray, out t text) + as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql +-- +FUNCTION: name="mr_outparam_succeed2" function="mr_outparam_succeed2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 592 +select * from mr_outparam_succeed2(int4multirange(int4range(1,2))) +-- +FUNCTION: name="mr_outparam_succeed2" function="mr_outparam_succeed2" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 593 +-- infer anyrange from anymultirange +create function mr_outparam_succeed3(i anymultirange, out r anyrange, out t text) + as $$ select range_merge($1), 'foo'::text $$ language sql +-- +FUNCTION: name="mr_outparam_succeed3" function="mr_outparam_succeed3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 594 +select * from mr_outparam_succeed3(int4multirange(int4range(1,2))) +-- +FUNCTION: name="mr_outparam_succeed3" function="mr_outparam_succeed3" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 595 +-- infer anymultirange from anyrange +create function mr_outparam_succeed4(i anyrange, out r anymultirange, out t text) + as $$ select multirange($1), 'foo'::text $$ language sql +-- +FUNCTION: name="mr_outparam_succeed4" function="mr_outparam_succeed4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 596 +select * from mr_outparam_succeed4(int4range(1,2)) +-- +FUNCTION: name="mr_outparam_succeed4" function="mr_outparam_succeed4" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 597 +-- infer anyelement from anymultirange +create function mr_inoutparam_succeed(out i anyelement, inout r anymultirange) + as $$ select upper($1), $1 $$ language sql +-- +FUNCTION: name="mr_inoutparam_succeed" function="mr_inoutparam_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 598 +select * from mr_inoutparam_succeed(int4multirange(int4range(1,2))) +-- +FUNCTION: name="mr_inoutparam_succeed" function="mr_inoutparam_succeed" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 599 +-- infer anyelement+anymultirange from anyelement+anymultirange +create function mr_table_succeed(i anyelement, r anymultirange) returns table(i anyelement, r anymultirange) + as $$ select $1, $2 $$ language sql +-- +FUNCTION: name="mr_table_succeed" function="mr_table_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 600 +select * from mr_table_succeed(123, int4multirange(int4range(1,11))) +-- +FUNCTION: name="mr_table_succeed" function="mr_table_succeed" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 601 +-- use anymultirange in plpgsql +create function mr_polymorphic(i anyrange) returns anymultirange + as $$ begin return multirange($1); end; $$ language plpgsql +-- +FUNCTION: name="mr_polymorphic" function="mr_polymorphic" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 602 +select mr_polymorphic(int4range(1, 4)) +-- +FUNCTION: name="mr_polymorphic" function="mr_polymorphic" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 603 +-- should fail +create function mr_outparam_fail(i anyelement, out r anymultirange, out t text) + as $$ select '[1,10]', 'foo' $$ language sql +-- +FUNCTION: name="mr_outparam_fail" function="mr_outparam_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 604 +--should fail +create function mr_inoutparam_fail(inout i anyelement, out r anymultirange) + as $$ select $1, '[1,10]' $$ language sql +-- +FUNCTION: name="mr_inoutparam_fail" function="mr_inoutparam_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 605 +--should fail +create function mr_table_fail(i anyelement) returns table(i anyelement, r anymultirange) + as $$ select $1, '[1,10]' $$ language sql +-- +FUNCTION: name="mr_table_fail" function="mr_table_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt diff --git a/parser/testdata/summary/postgres_regress/mvcc.metadata.json b/parser/testdata/summary/postgres_regress/mvcc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/mvcc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/mvcc.test b/parser/testdata/summary/postgres_regress/mvcc.test new file mode 100644 index 0000000..8b175a5 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/mvcc.test @@ -0,0 +1,79 @@ +== 001 +|-- +-- Verify that index scans encountering dead rows produced by an +-- aborted subtransaction of the current transaction can utilize the +-- kill_prior_tuple optimization +|-- +-- NB: The table size is currently *not* expected to stay the same, we +-- don't have logic to trigger opportunistic pruning in cases like +-- this. +BEGIN +-- +STMT: TransactionStmt +== 002 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +== 003 +SET LOCAL enable_indexonlyscan = false +-- +STMT: VariableSetStmt +== 004 +SET LOCAL enable_bitmapscan = false +-- +STMT: VariableSetStmt +== 005 +-- Can't easily use a unique index, since dead tuples can be found +-- independent of the kill_prior_tuples optimization. +CREATE TABLE clean_aborted_self(key int, data text) +-- +TABLE: name="clean_aborted_self" schema="" table="clean_aborted_self" ctx=DDL +STMT: CreateStmt +== 006 +CREATE INDEX clean_aborted_self_key ON clean_aborted_self(key) +-- +TABLE: name="clean_aborted_self" schema="" table="clean_aborted_self" ctx=DDL +STMT: IndexStmt +== 007 +INSERT INTO clean_aborted_self (key, data) VALUES (-1, 'just to allocate metapage') +-- +TABLE: name="clean_aborted_self" schema="" table="clean_aborted_self" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +-- save index size from before the changes, for comparison +SELECT pg_relation_size('clean_aborted_self_key') AS clean_aborted_self_key_before +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +== 009 +DO $$ +BEGIN + -- iterate often enough to see index growth even on larger-than-default page sizes + FOR i IN 1..100 LOOP + BEGIN + -- perform index scan over all the inserted keys to get them to be seen as dead + IF EXISTS(SELECT * FROM clean_aborted_self WHERE key > 0 AND key < 100) THEN + RAISE data_corrupted USING MESSAGE = 'these rows should not exist'; + END IF; + INSERT INTO clean_aborted_self SELECT g.i, 'rolling back in a sec' FROM generate_series(1, 100) g(i); + -- just some error that's not normally thrown + RAISE reading_sql_data_not_permitted USING MESSAGE = 'round and round again'; + EXCEPTION WHEN reading_sql_data_not_permitted THEN END; + END LOOP; +END;$$ +-- +STMT: DoStmt +== 010 +-- show sizes only if they differ +SELECT :clean_aborted_self_key_before AS size_before, pg_relation_size('clean_aborted_self_key') size_after +WHERE :clean_aborted_self_key_before != pg_relation_size('clean_aborted_self_key') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 42 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 011 +ROLLBACK +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/name.metadata.json b/parser/testdata/summary/postgres_regress/name.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/name.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/name.test b/parser/testdata/summary/postgres_regress/name.test new file mode 100644 index 0000000..eef1459 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/name.test @@ -0,0 +1,250 @@ +== 001 +|-- +-- NAME +-- all inputs are silently truncated at NAMEDATALEN-1 (63) characters +|-- + +-- fixed-length by reference +SELECT name 'name string' = name 'name string' AS "True" +-- +STMT: SelectStmt +== 002 +SELECT name 'name string' = name 'name string ' AS "False" +-- +STMT: SelectStmt +== 003 +|-- +|-- +|-- + +CREATE TABLE NAME_TBL(f1 name) +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DDL +STMT: CreateStmt +== 004 +INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO NAME_TBL(f1) VALUES ('1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqr') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO NAME_TBL(f1) VALUES ('asdfghjkl;') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO NAME_TBL(f1) VALUES ('343f%2a') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO NAME_TBL(f1) VALUES ('d34aaasdf') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO NAME_TBL(f1) VALUES ('') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +SELECT * FROM NAME_TBL +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +STMT: SelectStmt +== 012 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 <> '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 013 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 014 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 < '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 015 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 <= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 016 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 > '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 017 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 >= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 018 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 019 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 !~ '.*' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 020 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '[0-9]' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 021 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*asdf.*' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 022 +DROP TABLE NAME_TBL +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DDL +STMT: DropStmt +== 023 +DO $$ +DECLARE r text[]; +BEGIN + r := parse_ident('Schemax.Tabley'); + RAISE NOTICE '%', format('%I.%I', r[1], r[2]); + r := parse_ident('"SchemaX"."TableY"'); + RAISE NOTICE '%', format('%I.%I', r[1], r[2]); +END; +$$ +-- +STMT: DoStmt +== 024 +SELECT parse_ident('foo.boo') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT parse_ident('foo.boo[]') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 026 +-- should fail +SELECT parse_ident('foo.boo[]', strict => false) +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 027 +-- ok + +-- should fail +SELECT parse_ident(' ') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT parse_ident(' .aaa') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT parse_ident(' aaa . ') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT parse_ident('aaa.a%b') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT parse_ident(E'X\rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT length(a[1]), length(a[2]) from parse_ident('"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy') as a +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT parse_ident(' first . " second " ." third ". " ' || repeat('x',66) || '"') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT parse_ident(' first . " second " ." third ". " ' || repeat('x',66) || '"')::name[] +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT parse_ident(E'"c".X XXXX\002XXXXXX') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 036 +SELECT parse_ident('1020') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT parse_ident('10.20') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT parse_ident('.') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 039 +SELECT parse_ident('.1020') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT parse_ident('xxx.1020') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/namespace.metadata.json b/parser/testdata/summary/postgres_regress/namespace.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/namespace.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/namespace.test b/parser/testdata/summary/postgres_regress/namespace.test new file mode 100644 index 0000000..a42220e --- /dev/null +++ b/parser/testdata/summary/postgres_regress/namespace.test @@ -0,0 +1,249 @@ +== 001 +|-- +-- Regression tests for schemas (namespaces) +|-- + +-- set the whitespace-only search_path to test that the +-- GUC list syntax is preserved during a schema creation +SELECT pg_catalog.set_config('search_path', ' ', false) +-- +FUNCTION: name="pg_catalog.set_config" function="set_config" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 002 +CREATE SCHEMA test_ns_schema_1 + CREATE UNIQUE INDEX abc_a_idx ON abc (a) + + CREATE VIEW abc_view AS + SELECT a+1 AS a, b+1 AS b FROM abc + + CREATE TABLE abc ( + a serial, + b int UNIQUE + ) +-- +STMT: CreateSchemaStmt +== 003 +-- verify that the correct search_path restored on abort +SET search_path to public +-- +STMT: VariableSetStmt +== 004 +BEGIN +-- +STMT: TransactionStmt +== 005 +SET search_path to public, test_ns_schema_1 +-- +STMT: VariableSetStmt +== 006 +CREATE SCHEMA test_ns_schema_2 + CREATE VIEW abc_view AS SELECT c FROM abc +-- +STMT: CreateSchemaStmt +== 007 +COMMIT +-- +STMT: TransactionStmt +== 008 +SHOW search_path +-- +STMT: VariableShowStmt +== 009 +-- verify that the correct search_path preserved +-- after creating the schema and on commit +BEGIN +-- +STMT: TransactionStmt +== 010 +SET search_path to public, test_ns_schema_1 +-- +STMT: VariableSetStmt +== 011 +CREATE SCHEMA test_ns_schema_2 + CREATE VIEW abc_view AS SELECT a FROM abc +-- +STMT: CreateSchemaStmt +== 012 +SHOW search_path +-- +STMT: VariableShowStmt +== 013 +COMMIT +-- +STMT: TransactionStmt +== 014 +SHOW search_path +-- +STMT: VariableShowStmt +== 015 +DROP SCHEMA test_ns_schema_2 CASCADE +-- +STMT: DropStmt +== 016 +-- verify that the objects were created +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_1') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 017 +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES +-- +TABLE: name="test_ns_schema_1.abc" schema="test_ns_schema_1" table="abc" ctx=DML +STMT: InsertStmt +== 018 +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES +-- +TABLE: name="test_ns_schema_1.abc" schema="test_ns_schema_1" table="abc" ctx=DML +STMT: InsertStmt +== 019 +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES +-- +TABLE: name="test_ns_schema_1.abc" schema="test_ns_schema_1" table="abc" ctx=DML +STMT: InsertStmt +== 020 +SELECT * FROM test_ns_schema_1.abc +-- +TABLE: name="test_ns_schema_1.abc" schema="test_ns_schema_1" table="abc" ctx=Select +STMT: SelectStmt +== 021 +SELECT * FROM test_ns_schema_1.abc_view +-- +TABLE: name="test_ns_schema_1.abc_view" schema="test_ns_schema_1" table="abc_view" ctx=Select +STMT: SelectStmt +== 022 +ALTER SCHEMA test_ns_schema_1 RENAME TO test_ns_schema_renamed +-- +STMT: RenameStmt +== 023 +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_1') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 024 +-- test IF NOT EXISTS cases +CREATE SCHEMA test_ns_schema_renamed +-- +STMT: CreateSchemaStmt +== 025 +-- fail, already exists +CREATE SCHEMA IF NOT EXISTS test_ns_schema_renamed +-- +STMT: CreateSchemaStmt +== 026 +-- ok with notice +CREATE SCHEMA IF NOT EXISTS test_ns_schema_renamed -- fail, disallowed + CREATE TABLE abc ( + a serial, + b int UNIQUE + ) +-- +ERROR: CREATE SCHEMA IF NOT EXISTS cannot include schema elements +CURSORPOS: 97 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 027 +DROP SCHEMA test_ns_schema_renamed CASCADE +-- +STMT: DropStmt +== 028 +-- verify that the objects were dropped +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_renamed') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 029 +|-- +-- Verify that search_path is set to a safe value during maintenance +-- commands. +|-- + +CREATE SCHEMA test_maint_search_path +-- +STMT: CreateSchemaStmt +== 030 +SET search_path = test_maint_search_path +-- +STMT: VariableSetStmt +== 031 +CREATE FUNCTION fn(INT) RETURNS INT IMMUTABLE LANGUAGE plpgsql AS $$ + BEGIN + RAISE NOTICE 'current search_path: %', current_setting('search_path'); + RETURN $1; + END; +$$ +-- +FUNCTION: name="fn" function="fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 032 +CREATE TABLE test_maint(i INT) +-- +TABLE: name="test_maint" schema="" table="test_maint" ctx=DDL +STMT: CreateStmt +== 033 +INSERT INTO test_maint VALUES (1), (2) +-- +TABLE: name="test_maint" schema="" table="test_maint" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +CREATE MATERIALIZED VIEW test_maint_mv AS SELECT fn(i) FROM test_maint +-- +TABLE: name="test_maint_mv" schema="" table="test_maint_mv" ctx=DDL +TABLE: name="test_maint" schema="" table="test_maint" ctx=Select +FUNCTION: name="fn" function="fn" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 035 +-- the following commands should see search_path as pg_catalog, pg_temp + +CREATE INDEX test_maint_idx ON test_maint_search_path.test_maint (fn(i)) +-- +TABLE: name="test_maint_search_path.test_maint" schema="test_maint_search_path" table="test_maint" ctx=DDL +FUNCTION: name="fn" function="fn" schema="" ctx=Call +STMT: IndexStmt +== 036 +REINDEX TABLE test_maint_search_path.test_maint +-- +STMT: ReindexStmt +== 037 +ANALYZE test_maint_search_path.test_maint +-- +TABLE: name="test_maint_search_path.test_maint" schema="test_maint_search_path" table="test_maint" ctx=DDL +STMT: VacuumStmt +== 038 +VACUUM FULL test_maint_search_path.test_maint +-- +TABLE: name="test_maint_search_path.test_maint" schema="test_maint_search_path" table="test_maint" ctx=DDL +STMT: VacuumStmt +== 039 +CLUSTER test_maint_search_path.test_maint USING test_maint_idx +-- +STMT: ClusterStmt +== 040 +REFRESH MATERIALIZED VIEW test_maint_search_path.test_maint_mv +-- +TABLE: name="test_maint_search_path.test_maint_mv" schema="test_maint_search_path" table="test_maint_mv" ctx=DDL +STMT: RefreshMatViewStmt +== 041 +RESET search_path +-- +STMT: VariableSetStmt +== 042 +DROP SCHEMA test_maint_search_path CASCADE +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/numeric.metadata.json b/parser/testdata/summary/postgres_regress/numeric.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/numeric.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/numeric.test b/parser/testdata/summary/postgres_regress/numeric.test new file mode 100644 index 0000000..f6dcf07 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/numeric.test @@ -0,0 +1,6239 @@ +== 001 +|-- +-- NUMERIC +|-- + +CREATE TABLE num_data (id int4, val numeric(210,10)) +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE num_exp_sub (id1 int4, id2 int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE num_exp_div (id1 int4, id2 int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: CreateStmt +== 005 +CREATE TABLE num_exp_mul (id1 int4, id2 int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: CreateStmt +== 006 +CREATE TABLE num_exp_sqrt (id int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: CreateStmt +== 007 +CREATE TABLE num_exp_ln (id int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE num_exp_log10 (id int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: CreateStmt +== 009 +CREATE TABLE num_exp_power_10_ln (id int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: CreateStmt +== 010 +CREATE TABLE num_result (id1 int4, id2 int4, result numeric(210,10)) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DDL +STMT: CreateStmt +== 011 +-- ****************************** +-- * The following EXPECTED results are computed by bc(1) +-- * with a scale of 200 +-- ****************************** + +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 012 +INSERT INTO num_exp_add VALUES (0,0,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO num_exp_sub VALUES (0,0,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO num_exp_mul VALUES (0,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO num_exp_div VALUES (0,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO num_exp_add VALUES (0,1,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO num_exp_sub VALUES (0,1,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO num_exp_mul VALUES (0,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO num_exp_div VALUES (0,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO num_exp_add VALUES (0,2,'-34338492.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO num_exp_sub VALUES (0,2,'34338492.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO num_exp_mul VALUES (0,2,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO num_exp_div VALUES (0,2,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO num_exp_add VALUES (0,3,'4.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO num_exp_sub VALUES (0,3,'-4.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO num_exp_mul VALUES (0,3,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO num_exp_div VALUES (0,3,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO num_exp_add VALUES (0,4,'7799461.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +INSERT INTO num_exp_sub VALUES (0,4,'-7799461.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO num_exp_mul VALUES (0,4,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO num_exp_div VALUES (0,4,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO num_exp_add VALUES (0,5,'16397.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO num_exp_sub VALUES (0,5,'-16397.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO num_exp_mul VALUES (0,5,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO num_exp_div VALUES (0,5,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +INSERT INTO num_exp_add VALUES (0,6,'93901.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO num_exp_sub VALUES (0,6,'-93901.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO num_exp_mul VALUES (0,6,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO num_exp_div VALUES (0,6,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO num_exp_add VALUES (0,7,'-83028485') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO num_exp_sub VALUES (0,7,'83028485') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO num_exp_mul VALUES (0,7,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO num_exp_div VALUES (0,7,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO num_exp_add VALUES (0,8,'74881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO num_exp_sub VALUES (0,8,'-74881') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO num_exp_mul VALUES (0,8,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO num_exp_div VALUES (0,8,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO num_exp_add VALUES (0,9,'-24926804.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +INSERT INTO num_exp_sub VALUES (0,9,'24926804.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO num_exp_mul VALUES (0,9,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +INSERT INTO num_exp_div VALUES (0,9,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO num_exp_add VALUES (1,0,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +INSERT INTO num_exp_sub VALUES (1,0,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +INSERT INTO num_exp_mul VALUES (1,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +INSERT INTO num_exp_div VALUES (1,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +INSERT INTO num_exp_add VALUES (1,1,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +INSERT INTO num_exp_sub VALUES (1,1,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +INSERT INTO num_exp_mul VALUES (1,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +INSERT INTO num_exp_div VALUES (1,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +INSERT INTO num_exp_add VALUES (1,2,'-34338492.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +INSERT INTO num_exp_sub VALUES (1,2,'34338492.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +INSERT INTO num_exp_mul VALUES (1,2,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +INSERT INTO num_exp_div VALUES (1,2,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +INSERT INTO num_exp_add VALUES (1,3,'4.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +INSERT INTO num_exp_sub VALUES (1,3,'-4.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 066 +INSERT INTO num_exp_mul VALUES (1,3,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +INSERT INTO num_exp_div VALUES (1,3,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 068 +INSERT INTO num_exp_add VALUES (1,4,'7799461.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 069 +INSERT INTO num_exp_sub VALUES (1,4,'-7799461.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +INSERT INTO num_exp_mul VALUES (1,4,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +INSERT INTO num_exp_div VALUES (1,4,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +INSERT INTO num_exp_add VALUES (1,5,'16397.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +INSERT INTO num_exp_sub VALUES (1,5,'-16397.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 074 +INSERT INTO num_exp_mul VALUES (1,5,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +INSERT INTO num_exp_div VALUES (1,5,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 076 +INSERT INTO num_exp_add VALUES (1,6,'93901.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +INSERT INTO num_exp_sub VALUES (1,6,'-93901.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +INSERT INTO num_exp_mul VALUES (1,6,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 079 +INSERT INTO num_exp_div VALUES (1,6,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +INSERT INTO num_exp_add VALUES (1,7,'-83028485') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +INSERT INTO num_exp_sub VALUES (1,7,'83028485') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 082 +INSERT INTO num_exp_mul VALUES (1,7,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 083 +INSERT INTO num_exp_div VALUES (1,7,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 084 +INSERT INTO num_exp_add VALUES (1,8,'74881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 085 +INSERT INTO num_exp_sub VALUES (1,8,'-74881') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 086 +INSERT INTO num_exp_mul VALUES (1,8,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +INSERT INTO num_exp_div VALUES (1,8,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +INSERT INTO num_exp_add VALUES (1,9,'-24926804.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +INSERT INTO num_exp_sub VALUES (1,9,'24926804.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 090 +INSERT INTO num_exp_mul VALUES (1,9,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 091 +INSERT INTO num_exp_div VALUES (1,9,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +INSERT INTO num_exp_add VALUES (2,0,'-34338492.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +INSERT INTO num_exp_sub VALUES (2,0,'-34338492.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 094 +INSERT INTO num_exp_mul VALUES (2,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +INSERT INTO num_exp_div VALUES (2,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +INSERT INTO num_exp_add VALUES (2,1,'-34338492.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +INSERT INTO num_exp_sub VALUES (2,1,'-34338492.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +INSERT INTO num_exp_mul VALUES (2,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 099 +INSERT INTO num_exp_div VALUES (2,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 100 +INSERT INTO num_exp_add VALUES (2,2,'-68676984.430794094') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +INSERT INTO num_exp_sub VALUES (2,2,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 102 +INSERT INTO num_exp_mul VALUES (2,2,'1179132047626883.596862135856320209') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +INSERT INTO num_exp_div VALUES (2,2,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +INSERT INTO num_exp_add VALUES (2,3,'-34338487.905397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +INSERT INTO num_exp_sub VALUES (2,3,'-34338496.525397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 106 +INSERT INTO num_exp_mul VALUES (2,3,'-147998901.44836127257') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +INSERT INTO num_exp_div VALUES (2,3,'-7967167.56737750510440835266') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +INSERT INTO num_exp_add VALUES (2,4,'-26539030.803497047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +INSERT INTO num_exp_sub VALUES (2,4,'-42137953.627297047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +INSERT INTO num_exp_mul VALUES (2,4,'-267821744976817.8111137106593') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +INSERT INTO num_exp_div VALUES (2,4,'-4.40267480046830116685') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 112 +INSERT INTO num_exp_add VALUES (2,5,'-34322095.176906047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 113 +INSERT INTO num_exp_sub VALUES (2,5,'-34354889.253888047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 114 +INSERT INTO num_exp_mul VALUES (2,5,'-563049578578.769242506736077') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +INSERT INTO num_exp_div VALUES (2,5,'-2094.18866914563535496429') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +INSERT INTO num_exp_add VALUES (2,6,'-34244590.637766787') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +INSERT INTO num_exp_sub VALUES (2,6,'-34432393.793027307') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 118 +INSERT INTO num_exp_mul VALUES (2,6,'-3224438592470.18449811926184222') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 119 +INSERT INTO num_exp_div VALUES (2,6,'-365.68599891479766440940') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 120 +INSERT INTO num_exp_add VALUES (2,7,'-117366977.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +INSERT INTO num_exp_sub VALUES (2,7,'48689992.784602953') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +INSERT INTO num_exp_mul VALUES (2,7,'2851072985828710.485883795') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +INSERT INTO num_exp_div VALUES (2,7,'.41357483778485235518') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 124 +INSERT INTO num_exp_add VALUES (2,8,'-34263611.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 125 +INSERT INTO num_exp_sub VALUES (2,8,'-34413373.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 126 +INSERT INTO num_exp_mul VALUES (2,8,'-2571300635581.146276407') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 127 +INSERT INTO num_exp_div VALUES (2,8,'-458.57416721727870888476') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 128 +INSERT INTO num_exp_add VALUES (2,9,'-59265296.260444467') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +INSERT INTO num_exp_sub VALUES (2,9,'-9411688.170349627') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 130 +INSERT INTO num_exp_mul VALUES (2,9,'855948866655588.453741509242968740') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 131 +INSERT INTO num_exp_div VALUES (2,9,'1.37757299946438931811') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 132 +INSERT INTO num_exp_add VALUES (3,0,'4.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 133 +INSERT INTO num_exp_sub VALUES (3,0,'4.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 134 +INSERT INTO num_exp_mul VALUES (3,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 135 +INSERT INTO num_exp_div VALUES (3,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +INSERT INTO num_exp_add VALUES (3,1,'4.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +INSERT INTO num_exp_sub VALUES (3,1,'4.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +INSERT INTO num_exp_mul VALUES (3,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +INSERT INTO num_exp_div VALUES (3,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 140 +INSERT INTO num_exp_add VALUES (3,2,'-34338487.905397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 141 +INSERT INTO num_exp_sub VALUES (3,2,'34338496.525397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +INSERT INTO num_exp_mul VALUES (3,2,'-147998901.44836127257') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +INSERT INTO num_exp_div VALUES (3,2,'-.00000012551512084352') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +INSERT INTO num_exp_add VALUES (3,3,'8.62') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 145 +INSERT INTO num_exp_sub VALUES (3,3,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +INSERT INTO num_exp_mul VALUES (3,3,'18.5761') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +INSERT INTO num_exp_div VALUES (3,3,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 148 +INSERT INTO num_exp_add VALUES (3,4,'7799465.7219') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 149 +INSERT INTO num_exp_sub VALUES (3,4,'-7799457.1019') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +INSERT INTO num_exp_mul VALUES (3,4,'33615678.685289') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 151 +INSERT INTO num_exp_div VALUES (3,4,'.00000055260225961552') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +INSERT INTO num_exp_add VALUES (3,5,'16401.348491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 153 +INSERT INTO num_exp_sub VALUES (3,5,'-16392.728491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 154 +INSERT INTO num_exp_mul VALUES (3,5,'70671.23589621') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +INSERT INTO num_exp_div VALUES (3,5,'.00026285234387695504') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 156 +INSERT INTO num_exp_add VALUES (3,6,'93905.88763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 157 +INSERT INTO num_exp_sub VALUES (3,6,'-93897.26763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 158 +INSERT INTO num_exp_mul VALUES (3,6,'404715.7995864206') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 159 +INSERT INTO num_exp_div VALUES (3,6,'.00004589912234457595') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 160 +INSERT INTO num_exp_add VALUES (3,7,'-83028480.69') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 161 +INSERT INTO num_exp_sub VALUES (3,7,'83028489.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 162 +INSERT INTO num_exp_mul VALUES (3,7,'-357852770.35') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 163 +INSERT INTO num_exp_div VALUES (3,7,'-.00000005190989574240') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +INSERT INTO num_exp_add VALUES (3,8,'74885.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 165 +INSERT INTO num_exp_sub VALUES (3,8,'-74876.69') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 166 +INSERT INTO num_exp_mul VALUES (3,8,'322737.11') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 167 +INSERT INTO num_exp_div VALUES (3,8,'.00005755799201399553') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +INSERT INTO num_exp_add VALUES (3,9,'-24926799.735047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 169 +INSERT INTO num_exp_sub VALUES (3,9,'24926808.355047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 170 +INSERT INTO num_exp_mul VALUES (3,9,'-107434525.43415438020') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 171 +INSERT INTO num_exp_div VALUES (3,9,'-.00000017290624149854') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 172 +INSERT INTO num_exp_add VALUES (4,0,'7799461.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +INSERT INTO num_exp_sub VALUES (4,0,'7799461.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 174 +INSERT INTO num_exp_mul VALUES (4,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 175 +INSERT INTO num_exp_div VALUES (4,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 176 +INSERT INTO num_exp_add VALUES (4,1,'7799461.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 177 +INSERT INTO num_exp_sub VALUES (4,1,'7799461.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 178 +INSERT INTO num_exp_mul VALUES (4,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 179 +INSERT INTO num_exp_div VALUES (4,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 180 +INSERT INTO num_exp_add VALUES (4,2,'-26539030.803497047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 181 +INSERT INTO num_exp_sub VALUES (4,2,'42137953.627297047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 182 +INSERT INTO num_exp_mul VALUES (4,2,'-267821744976817.8111137106593') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 183 +INSERT INTO num_exp_div VALUES (4,2,'-.22713465002993920385') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 184 +INSERT INTO num_exp_add VALUES (4,3,'7799465.7219') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 185 +INSERT INTO num_exp_sub VALUES (4,3,'7799457.1019') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +INSERT INTO num_exp_mul VALUES (4,3,'33615678.685289') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +INSERT INTO num_exp_div VALUES (4,3,'1809619.81714617169373549883') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +INSERT INTO num_exp_add VALUES (4,4,'15598922.8238') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +INSERT INTO num_exp_sub VALUES (4,4,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +INSERT INTO num_exp_mul VALUES (4,4,'60831598315717.14146161') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +INSERT INTO num_exp_div VALUES (4,4,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 192 +INSERT INTO num_exp_add VALUES (4,5,'7815858.450391') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 193 +INSERT INTO num_exp_sub VALUES (4,5,'7783064.373409') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 194 +INSERT INTO num_exp_mul VALUES (4,5,'127888068979.9935054429') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 195 +INSERT INTO num_exp_div VALUES (4,5,'475.66281046305802686061') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +INSERT INTO num_exp_add VALUES (4,6,'7893362.98953026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 197 +INSERT INTO num_exp_sub VALUES (4,6,'7705559.83426974') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 198 +INSERT INTO num_exp_mul VALUES (4,6,'732381731243.745115764094') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 199 +INSERT INTO num_exp_div VALUES (4,6,'83.05996138436129499606') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 200 +INSERT INTO num_exp_add VALUES (4,7,'-75229023.5881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 201 +INSERT INTO num_exp_sub VALUES (4,7,'90827946.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +INSERT INTO num_exp_mul VALUES (4,7,'-647577464846017.9715') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 203 +INSERT INTO num_exp_div VALUES (4,7,'-.09393717604145131637') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 204 +INSERT INTO num_exp_add VALUES (4,8,'7874342.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 205 +INSERT INTO num_exp_sub VALUES (4,8,'7724580.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 206 +INSERT INTO num_exp_mul VALUES (4,8,'584031469984.4839') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 207 +INSERT INTO num_exp_div VALUES (4,8,'104.15808298366741897143') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 208 +INSERT INTO num_exp_add VALUES (4,9,'-17127342.633147420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 209 +INSERT INTO num_exp_sub VALUES (4,9,'32726265.456947420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 210 +INSERT INTO num_exp_mul VALUES (4,9,'-194415646271340.1815956522980') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 211 +INSERT INTO num_exp_div VALUES (4,9,'-.31289456112403769409') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 212 +INSERT INTO num_exp_add VALUES (5,0,'16397.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 213 +INSERT INTO num_exp_sub VALUES (5,0,'16397.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 214 +INSERT INTO num_exp_mul VALUES (5,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 215 +INSERT INTO num_exp_div VALUES (5,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +INSERT INTO num_exp_add VALUES (5,1,'16397.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 217 +INSERT INTO num_exp_sub VALUES (5,1,'16397.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 218 +INSERT INTO num_exp_mul VALUES (5,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 219 +INSERT INTO num_exp_div VALUES (5,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 220 +INSERT INTO num_exp_add VALUES (5,2,'-34322095.176906047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 221 +INSERT INTO num_exp_sub VALUES (5,2,'34354889.253888047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 222 +INSERT INTO num_exp_mul VALUES (5,2,'-563049578578.769242506736077') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 223 +INSERT INTO num_exp_div VALUES (5,2,'-.00047751189505192446') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 224 +INSERT INTO num_exp_add VALUES (5,3,'16401.348491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 225 +INSERT INTO num_exp_sub VALUES (5,3,'16392.728491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 226 +INSERT INTO num_exp_mul VALUES (5,3,'70671.23589621') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 227 +INSERT INTO num_exp_div VALUES (5,3,'3804.41728329466357308584') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 228 +INSERT INTO num_exp_add VALUES (5,4,'7815858.450391') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 229 +INSERT INTO num_exp_sub VALUES (5,4,'-7783064.373409') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 230 +INSERT INTO num_exp_mul VALUES (5,4,'127888068979.9935054429') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 231 +INSERT INTO num_exp_div VALUES (5,4,'.00210232958726897192') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 232 +INSERT INTO num_exp_add VALUES (5,5,'32794.076982') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 233 +INSERT INTO num_exp_sub VALUES (5,5,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 234 +INSERT INTO num_exp_mul VALUES (5,5,'268862871.275335557081') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 235 +INSERT INTO num_exp_div VALUES (5,5,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 236 +INSERT INTO num_exp_add VALUES (5,6,'110298.61612126') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 237 +INSERT INTO num_exp_sub VALUES (5,6,'-77504.53913926') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 238 +INSERT INTO num_exp_mul VALUES (5,6,'1539707782.76899778633766') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 239 +INSERT INTO num_exp_div VALUES (5,6,'.17461941433576102689') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 240 +INSERT INTO num_exp_add VALUES (5,7,'-83012087.961509') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 241 +INSERT INTO num_exp_sub VALUES (5,7,'83044882.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 242 +INSERT INTO num_exp_mul VALUES (5,7,'-1361421264394.416135') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 243 +INSERT INTO num_exp_div VALUES (5,7,'-.00019748690453643710') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +INSERT INTO num_exp_add VALUES (5,8,'91278.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +INSERT INTO num_exp_sub VALUES (5,8,'-58483.961509') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 246 +INSERT INTO num_exp_mul VALUES (5,8,'1227826639.244571') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 247 +INSERT INTO num_exp_div VALUES (5,8,'.21897461960978085228') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 248 +INSERT INTO num_exp_add VALUES (5,9,'-24910407.006556420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 249 +INSERT INTO num_exp_sub VALUES (5,9,'24943201.083538420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 250 +INSERT INTO num_exp_mul VALUES (5,9,'-408725765384.257043660243220') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 251 +INSERT INTO num_exp_div VALUES (5,9,'-.00065780749354660427') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 252 +INSERT INTO num_exp_add VALUES (6,0,'93901.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +INSERT INTO num_exp_sub VALUES (6,0,'93901.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 254 +INSERT INTO num_exp_mul VALUES (6,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 255 +INSERT INTO num_exp_div VALUES (6,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 256 +INSERT INTO num_exp_add VALUES (6,1,'93901.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 257 +INSERT INTO num_exp_sub VALUES (6,1,'93901.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 258 +INSERT INTO num_exp_mul VALUES (6,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 259 +INSERT INTO num_exp_div VALUES (6,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 260 +INSERT INTO num_exp_add VALUES (6,2,'-34244590.637766787') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 261 +INSERT INTO num_exp_sub VALUES (6,2,'34432393.793027307') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 262 +INSERT INTO num_exp_mul VALUES (6,2,'-3224438592470.18449811926184222') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 263 +INSERT INTO num_exp_div VALUES (6,2,'-.00273458651128995823') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 264 +INSERT INTO num_exp_add VALUES (6,3,'93905.88763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 265 +INSERT INTO num_exp_sub VALUES (6,3,'93897.26763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 266 +INSERT INTO num_exp_mul VALUES (6,3,'404715.7995864206') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 267 +INSERT INTO num_exp_div VALUES (6,3,'21786.90896293735498839907') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 268 +INSERT INTO num_exp_add VALUES (6,4,'7893362.98953026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +INSERT INTO num_exp_sub VALUES (6,4,'-7705559.83426974') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 270 +INSERT INTO num_exp_mul VALUES (6,4,'732381731243.745115764094') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 271 +INSERT INTO num_exp_div VALUES (6,4,'.01203949512295682469') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 272 +INSERT INTO num_exp_add VALUES (6,5,'110298.61612126') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 273 +INSERT INTO num_exp_sub VALUES (6,5,'77504.53913926') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 274 +INSERT INTO num_exp_mul VALUES (6,5,'1539707782.76899778633766') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 275 +INSERT INTO num_exp_div VALUES (6,5,'5.72674008674192359679') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 276 +INSERT INTO num_exp_add VALUES (6,6,'187803.15526052') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 277 +INSERT INTO num_exp_sub VALUES (6,6,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 278 +INSERT INTO num_exp_mul VALUES (6,6,'8817506281.4517452372676676') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 279 +INSERT INTO num_exp_div VALUES (6,6,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 280 +INSERT INTO num_exp_add VALUES (6,7,'-82934583.42236974') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 281 +INSERT INTO num_exp_sub VALUES (6,7,'83122386.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 282 +INSERT INTO num_exp_mul VALUES (6,7,'-7796505729750.37795610') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 283 +INSERT INTO num_exp_div VALUES (6,7,'-.00113095617281538980') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 284 +INSERT INTO num_exp_add VALUES (6,8,'168782.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 285 +INSERT INTO num_exp_sub VALUES (6,8,'19020.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 286 +INSERT INTO num_exp_mul VALUES (6,8,'7031444034.53149906') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 287 +INSERT INTO num_exp_div VALUES (6,8,'1.25401073209839612184') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 288 +INSERT INTO num_exp_add VALUES (6,9,'-24832902.467417160') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 289 +INSERT INTO num_exp_sub VALUES (6,9,'25020705.622677680') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 290 +INSERT INTO num_exp_mul VALUES (6,9,'-2340666225110.29929521292692920') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 291 +INSERT INTO num_exp_div VALUES (6,9,'-.00376709254265256789') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 292 +INSERT INTO num_exp_add VALUES (7,0,'-83028485') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +INSERT INTO num_exp_sub VALUES (7,0,'-83028485') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 294 +INSERT INTO num_exp_mul VALUES (7,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 295 +INSERT INTO num_exp_div VALUES (7,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 296 +INSERT INTO num_exp_add VALUES (7,1,'-83028485') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 297 +INSERT INTO num_exp_sub VALUES (7,1,'-83028485') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 298 +INSERT INTO num_exp_mul VALUES (7,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 299 +INSERT INTO num_exp_div VALUES (7,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 300 +INSERT INTO num_exp_add VALUES (7,2,'-117366977.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 301 +INSERT INTO num_exp_sub VALUES (7,2,'-48689992.784602953') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 302 +INSERT INTO num_exp_mul VALUES (7,2,'2851072985828710.485883795') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 303 +INSERT INTO num_exp_div VALUES (7,2,'2.41794207151503385700') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 304 +INSERT INTO num_exp_add VALUES (7,3,'-83028480.69') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 305 +INSERT INTO num_exp_sub VALUES (7,3,'-83028489.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 306 +INSERT INTO num_exp_mul VALUES (7,3,'-357852770.35') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 307 +INSERT INTO num_exp_div VALUES (7,3,'-19264149.65197215777262180974') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 308 +INSERT INTO num_exp_add VALUES (7,4,'-75229023.5881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 309 +INSERT INTO num_exp_sub VALUES (7,4,'-90827946.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 310 +INSERT INTO num_exp_mul VALUES (7,4,'-647577464846017.9715') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 311 +INSERT INTO num_exp_div VALUES (7,4,'-10.64541262725136247686') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 312 +INSERT INTO num_exp_add VALUES (7,5,'-83012087.961509') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 313 +INSERT INTO num_exp_sub VALUES (7,5,'-83044882.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 314 +INSERT INTO num_exp_mul VALUES (7,5,'-1361421264394.416135') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 315 +INSERT INTO num_exp_div VALUES (7,5,'-5063.62688881730941836574') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 316 +INSERT INTO num_exp_add VALUES (7,6,'-82934583.42236974') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 317 +INSERT INTO num_exp_sub VALUES (7,6,'-83122386.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 318 +INSERT INTO num_exp_mul VALUES (7,6,'-7796505729750.37795610') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 319 +INSERT INTO num_exp_div VALUES (7,6,'-884.20756174009028770294') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 320 +INSERT INTO num_exp_add VALUES (7,7,'-166056970') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 321 +INSERT INTO num_exp_sub VALUES (7,7,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 322 +INSERT INTO num_exp_mul VALUES (7,7,'6893729321395225') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 323 +INSERT INTO num_exp_div VALUES (7,7,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 324 +INSERT INTO num_exp_add VALUES (7,8,'-82953604') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 325 +INSERT INTO num_exp_sub VALUES (7,8,'-83103366') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 326 +INSERT INTO num_exp_mul VALUES (7,8,'-6217255985285') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 327 +INSERT INTO num_exp_div VALUES (7,8,'-1108.80577182462841041118') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 328 +INSERT INTO num_exp_add VALUES (7,9,'-107955289.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 329 +INSERT INTO num_exp_sub VALUES (7,9,'-58101680.954952580') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 330 +INSERT INTO num_exp_mul VALUES (7,9,'2069634775752159.035758700') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 331 +INSERT INTO num_exp_div VALUES (7,9,'3.33089171198810413382') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 332 +INSERT INTO num_exp_add VALUES (8,0,'74881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 333 +INSERT INTO num_exp_sub VALUES (8,0,'74881') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 334 +INSERT INTO num_exp_mul VALUES (8,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 335 +INSERT INTO num_exp_div VALUES (8,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 336 +INSERT INTO num_exp_add VALUES (8,1,'74881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 337 +INSERT INTO num_exp_sub VALUES (8,1,'74881') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 338 +INSERT INTO num_exp_mul VALUES (8,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 339 +INSERT INTO num_exp_div VALUES (8,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 340 +INSERT INTO num_exp_add VALUES (8,2,'-34263611.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 341 +INSERT INTO num_exp_sub VALUES (8,2,'34413373.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 342 +INSERT INTO num_exp_mul VALUES (8,2,'-2571300635581.146276407') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 343 +INSERT INTO num_exp_div VALUES (8,2,'-.00218067233500788615') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 344 +INSERT INTO num_exp_add VALUES (8,3,'74885.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 345 +INSERT INTO num_exp_sub VALUES (8,3,'74876.69') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 346 +INSERT INTO num_exp_mul VALUES (8,3,'322737.11') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 347 +INSERT INTO num_exp_div VALUES (8,3,'17373.78190255220417633410') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 348 +INSERT INTO num_exp_add VALUES (8,4,'7874342.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 349 +INSERT INTO num_exp_sub VALUES (8,4,'-7724580.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 350 +INSERT INTO num_exp_mul VALUES (8,4,'584031469984.4839') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 351 +INSERT INTO num_exp_div VALUES (8,4,'.00960079113741758956') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 352 +INSERT INTO num_exp_add VALUES (8,5,'91278.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 353 +INSERT INTO num_exp_sub VALUES (8,5,'58483.961509') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 354 +INSERT INTO num_exp_mul VALUES (8,5,'1227826639.244571') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 355 +INSERT INTO num_exp_div VALUES (8,5,'4.56673929509287019456') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 356 +INSERT INTO num_exp_add VALUES (8,6,'168782.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 357 +INSERT INTO num_exp_sub VALUES (8,6,'-19020.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 358 +INSERT INTO num_exp_mul VALUES (8,6,'7031444034.53149906') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 359 +INSERT INTO num_exp_div VALUES (8,6,'.79744134113322314424') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 360 +INSERT INTO num_exp_add VALUES (8,7,'-82953604') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 361 +INSERT INTO num_exp_sub VALUES (8,7,'83103366') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 362 +INSERT INTO num_exp_mul VALUES (8,7,'-6217255985285') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 363 +INSERT INTO num_exp_div VALUES (8,7,'-.00090187120721280172') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 364 +INSERT INTO num_exp_add VALUES (8,8,'149762') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 365 +INSERT INTO num_exp_sub VALUES (8,8,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 366 +INSERT INTO num_exp_mul VALUES (8,8,'5607164161') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 367 +INSERT INTO num_exp_div VALUES (8,8,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 368 +INSERT INTO num_exp_add VALUES (8,9,'-24851923.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 369 +INSERT INTO num_exp_sub VALUES (8,9,'25001685.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 370 +INSERT INTO num_exp_mul VALUES (8,9,'-1866544013697.195857020') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 371 +INSERT INTO num_exp_div VALUES (8,9,'-.00300403532938582735') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 372 +INSERT INTO num_exp_add VALUES (9,0,'-24926804.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 373 +INSERT INTO num_exp_sub VALUES (9,0,'-24926804.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 374 +INSERT INTO num_exp_mul VALUES (9,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 375 +INSERT INTO num_exp_div VALUES (9,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 376 +INSERT INTO num_exp_add VALUES (9,1,'-24926804.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 377 +INSERT INTO num_exp_sub VALUES (9,1,'-24926804.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 378 +INSERT INTO num_exp_mul VALUES (9,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 379 +INSERT INTO num_exp_div VALUES (9,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 380 +INSERT INTO num_exp_add VALUES (9,2,'-59265296.260444467') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 381 +INSERT INTO num_exp_sub VALUES (9,2,'9411688.170349627') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 382 +INSERT INTO num_exp_mul VALUES (9,2,'855948866655588.453741509242968740') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 383 +INSERT INTO num_exp_div VALUES (9,2,'.72591434384152961526') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 384 +INSERT INTO num_exp_add VALUES (9,3,'-24926799.735047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 385 +INSERT INTO num_exp_sub VALUES (9,3,'-24926808.355047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 386 +INSERT INTO num_exp_mul VALUES (9,3,'-107434525.43415438020') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 387 +INSERT INTO num_exp_div VALUES (9,3,'-5783481.21694835730858468677') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 388 +INSERT INTO num_exp_add VALUES (9,4,'-17127342.633147420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 389 +INSERT INTO num_exp_sub VALUES (9,4,'-32726265.456947420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 390 +INSERT INTO num_exp_mul VALUES (9,4,'-194415646271340.1815956522980') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 391 +INSERT INTO num_exp_div VALUES (9,4,'-3.19596478892958416484') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 392 +INSERT INTO num_exp_add VALUES (9,5,'-24910407.006556420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 393 +INSERT INTO num_exp_sub VALUES (9,5,'-24943201.083538420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 394 +INSERT INTO num_exp_mul VALUES (9,5,'-408725765384.257043660243220') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 395 +INSERT INTO num_exp_div VALUES (9,5,'-1520.20159364322004505807') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 396 +INSERT INTO num_exp_add VALUES (9,6,'-24832902.467417160') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 397 +INSERT INTO num_exp_sub VALUES (9,6,'-25020705.622677680') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 398 +INSERT INTO num_exp_mul VALUES (9,6,'-2340666225110.29929521292692920') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 399 +INSERT INTO num_exp_div VALUES (9,6,'-265.45671195426965751280') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 400 +INSERT INTO num_exp_add VALUES (9,7,'-107955289.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 401 +INSERT INTO num_exp_sub VALUES (9,7,'58101680.954952580') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 402 +INSERT INTO num_exp_mul VALUES (9,7,'2069634775752159.035758700') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 403 +INSERT INTO num_exp_div VALUES (9,7,'.30021990699995814689') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 404 +INSERT INTO num_exp_add VALUES (9,8,'-24851923.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 405 +INSERT INTO num_exp_sub VALUES (9,8,'-25001685.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 406 +INSERT INTO num_exp_mul VALUES (9,8,'-1866544013697.195857020') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 407 +INSERT INTO num_exp_div VALUES (9,8,'-332.88556569820675471748') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 408 +INSERT INTO num_exp_add VALUES (9,9,'-49853608.090094840') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 409 +INSERT INTO num_exp_sub VALUES (9,9,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 410 +INSERT INTO num_exp_mul VALUES (9,9,'621345559900192.420120630048656400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 411 +INSERT INTO num_exp_div VALUES (9,9,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 412 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 413 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 414 +INSERT INTO num_exp_sqrt VALUES (0,'0') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 415 +INSERT INTO num_exp_sqrt VALUES (1,'0') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 416 +INSERT INTO num_exp_sqrt VALUES (2,'5859.90547836712524903505') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 417 +INSERT INTO num_exp_sqrt VALUES (3,'2.07605394920266944396') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 418 +INSERT INTO num_exp_sqrt VALUES (4,'2792.75158435189147418923') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 419 +INSERT INTO num_exp_sqrt VALUES (5,'128.05092147657509145473') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 420 +INSERT INTO num_exp_sqrt VALUES (6,'306.43364311096782703406') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 421 +INSERT INTO num_exp_sqrt VALUES (7,'9111.99676251039939975230') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 422 +INSERT INTO num_exp_sqrt VALUES (8,'273.64392922189960397542') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 423 +INSERT INTO num_exp_sqrt VALUES (9,'4992.67503899937593364766') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 424 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 425 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 426 +INSERT INTO num_exp_ln VALUES (0,'NaN') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 427 +INSERT INTO num_exp_ln VALUES (1,'NaN') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 428 +INSERT INTO num_exp_ln VALUES (2,'17.35177750493897715514') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 429 +INSERT INTO num_exp_ln VALUES (3,'1.46093790411565641971') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 430 +INSERT INTO num_exp_ln VALUES (4,'15.86956523951936572464') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 431 +INSERT INTO num_exp_ln VALUES (5,'9.70485601768871834038') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 432 +INSERT INTO num_exp_ln VALUES (6,'11.45000246622944403127') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 433 +INSERT INTO num_exp_ln VALUES (7,'18.23469429965478772991') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 434 +INSERT INTO num_exp_ln VALUES (8,'11.22365546576315513668') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 435 +INSERT INTO num_exp_ln VALUES (9,'17.03145425013166006962') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 436 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 437 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 438 +INSERT INTO num_exp_log10 VALUES (0,'NaN') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 439 +INSERT INTO num_exp_log10 VALUES (1,'NaN') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 440 +INSERT INTO num_exp_log10 VALUES (2,'7.53578122160797276459') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 441 +INSERT INTO num_exp_log10 VALUES (3,'.63447727016073160075') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 442 +INSERT INTO num_exp_log10 VALUES (4,'6.89206461372691743345') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 443 +INSERT INTO num_exp_log10 VALUES (5,'4.21476541614777768626') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 444 +INSERT INTO num_exp_log10 VALUES (6,'4.97267288886207207671') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 445 +INSERT INTO num_exp_log10 VALUES (7,'7.91922711353275546914') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 446 +INSERT INTO num_exp_log10 VALUES (8,'4.87437163556421004138') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 447 +INSERT INTO num_exp_log10 VALUES (9,'7.39666659961986567059') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 448 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 449 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 450 +INSERT INTO num_exp_power_10_ln VALUES (0,'NaN') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 451 +INSERT INTO num_exp_power_10_ln VALUES (1,'NaN') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 452 +INSERT INTO num_exp_power_10_ln VALUES (2,'224790267919917955.13261618583642653184') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 453 +INSERT INTO num_exp_power_10_ln VALUES (3,'28.90266599445155957393') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 454 +INSERT INTO num_exp_power_10_ln VALUES (4,'7405685069594999.07733999469386277636') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 455 +INSERT INTO num_exp_power_10_ln VALUES (5,'5068226527.32127265408584640098') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 456 +INSERT INTO num_exp_power_10_ln VALUES (6,'281839893606.99372343357047819067') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 457 +INSERT INTO num_exp_power_10_ln VALUES (7,'1716699575118597095.42330819910640247627') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 458 +INSERT INTO num_exp_power_10_ln VALUES (8,'167361463828.07491320069016125952') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 459 +INSERT INTO num_exp_power_10_ln VALUES (9,'107511333880052007.04141124673540337457') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 460 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 461 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 462 +INSERT INTO num_data VALUES (0, '0') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 463 +INSERT INTO num_data VALUES (1, '0') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 464 +INSERT INTO num_data VALUES (2, '-34338492.215397047') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 465 +INSERT INTO num_data VALUES (3, '4.31') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 466 +INSERT INTO num_data VALUES (4, '7799461.4119') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 467 +INSERT INTO num_data VALUES (5, '16397.038491') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 468 +INSERT INTO num_data VALUES (6, '93901.57763026') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 469 +INSERT INTO num_data VALUES (7, '-83028485') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 470 +INSERT INTO num_data VALUES (8, '74881') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 471 +INSERT INTO num_data VALUES (9, '-24926804.045047420') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 472 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 473 +-- ****************************** +-- * Create indices for faster checks +-- ****************************** + +CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add (id1, id2) +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: IndexStmt +== 474 +CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub (id1, id2) +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: IndexStmt +== 475 +CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div (id1, id2) +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: IndexStmt +== 476 +CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul (id1, id2) +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: IndexStmt +== 477 +CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt (id) +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: IndexStmt +== 478 +CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln (id) +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: IndexStmt +== 479 +CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 (id) +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: IndexStmt +== 480 +CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln (id) +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: IndexStmt +== 481 +VACUUM ANALYZE num_exp_add +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: VacuumStmt +== 482 +VACUUM ANALYZE num_exp_sub +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: VacuumStmt +== 483 +VACUUM ANALYZE num_exp_div +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: VacuumStmt +== 484 +VACUUM ANALYZE num_exp_mul +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: VacuumStmt +== 485 +VACUUM ANALYZE num_exp_sqrt +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: VacuumStmt +== 486 +VACUUM ANALYZE num_exp_ln +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: VacuumStmt +== 487 +VACUUM ANALYZE num_exp_log10 +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: VacuumStmt +== 488 +VACUUM ANALYZE num_exp_power_10_ln +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: VacuumStmt +== 489 +-- ****************************** +-- * Now check the behaviour of the NUMERIC type +-- ****************************** + +-- ****************************** +-- * Addition check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 490 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +== 491 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_add" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 492 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 493 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 494 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 10) as expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 10) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_add" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 495 +-- ****************************** +-- * Subtraction check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 496 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +== 497 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sub" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 498 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 499 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 500 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 40) + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 40) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sub" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 501 +-- ****************************** +-- * Multiply check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 502 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +== 503 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_mul" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 504 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 505 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 506 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 30) as expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 30) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_mul" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 507 +-- ****************************** +-- * Division check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 508 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val / t2.val + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FILTER: schema="" table="t2" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 509 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_div" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 510 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 511 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val / t2.val, 80) + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t2" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 512 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 80) as expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 80) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_div" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 513 +-- ****************************** +-- * Square root check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 514 +INSERT INTO num_result SELECT id, 0, SQRT(ABS(val)) + FROM num_data +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 515 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_sqrt t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sqrt" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 516 +-- ****************************** +-- * Natural logarithm check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 517 +INSERT INTO num_result SELECT id, 0, LN(ABS(val)) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 518 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_ln" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 519 +-- ****************************** +-- * Logarithm base 10 check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 520 +INSERT INTO num_result SELECT id, 0, LOG(numeric '10', ABS(val)) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 521 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_log10 t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_log10" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 522 +-- ****************************** +-- * POWER(10, LN(value)) check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 523 +INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200)))) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="power" function="power" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 524 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_power_10_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_power_10_ln" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 525 +-- ****************************** +-- * Check behavior with Inf and NaN inputs. It's easiest to handle these +-- * separately from the num_data framework used above, because some input +-- * combinations will throw errors. +-- ****************************** + +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('inf'),('-inf'),('nan')) +SELECT x1, x2, + x1 + x2 AS sum, + x1 - x2 AS diff, + x1 * x2 AS prod +FROM v AS v1(x1), v AS v2(x2) +-- +ALIAS: "v1"="v" +ALIAS: "v2"="v" +CTE: "v" +STMT: SelectStmt +== 526 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('inf'),('-inf'),('nan')) +SELECT x1, x2, + x1 / x2 AS quot, + x1 % x2 AS mod, + div(x1, x2) AS div +FROM v AS v1(x1), v AS v2(x2) WHERE x2 != 0 +-- +ALIAS: "v1"="v" +ALIAS: "v2"="v" +CTE: "v" +FUNCTION: name="div" function="div" schema="" ctx=Call +FILTER: schema="" table="" column="x2" +STMT: SelectStmt +== 527 +SELECT 'inf'::numeric / '0' +-- +STMT: SelectStmt +== 528 +SELECT '-inf'::numeric / '0' +-- +STMT: SelectStmt +== 529 +SELECT 'nan'::numeric / '0' +-- +STMT: SelectStmt +== 530 +SELECT '0'::numeric / '0' +-- +STMT: SelectStmt +== 531 +SELECT 'inf'::numeric % '0' +-- +STMT: SelectStmt +== 532 +SELECT '-inf'::numeric % '0' +-- +STMT: SelectStmt +== 533 +SELECT 'nan'::numeric % '0' +-- +STMT: SelectStmt +== 534 +SELECT '0'::numeric % '0' +-- +STMT: SelectStmt +== 535 +SELECT div('inf'::numeric, '0') +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 536 +SELECT div('-inf'::numeric, '0') +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 537 +SELECT div('nan'::numeric, '0') +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 538 +SELECT div('0'::numeric, '0') +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 539 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('inf'),('-inf'),('nan')) +SELECT x, -x as minusx, abs(x), floor(x), ceil(x), sign(x), numeric_inc(x) as inc +FROM v +-- +CTE: "v" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="floor" function="floor" schema="" ctx=Call +FUNCTION: name="ceil" function="ceil" schema="" ctx=Call +FUNCTION: name="sign" function="sign" schema="" ctx=Call +FUNCTION: name="numeric_inc" function="numeric_inc" schema="" ctx=Call +STMT: SelectStmt +== 540 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('inf'),('-inf'),('nan')) +SELECT x, round(x), round(x,1) as round1, trunc(x), trunc(x,1) as trunc1 +FROM v +-- +CTE: "v" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 541 +-- the large values fall into the numeric abbreviation code's maximal classes +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('1e340'),('-1e340'), + ('inf'),('-inf'),('nan'), + ('inf'),('-inf'),('nan')) +SELECT substring(x::text, 1, 32) +FROM v ORDER BY x +-- +CTE: "v" +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +== 542 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('4.2'),('inf'),('nan')) +SELECT x, sqrt(x) +FROM v +-- +CTE: "v" +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 543 +SELECT sqrt('-1'::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 544 +SELECT sqrt('-inf'::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 545 +WITH v(x) AS + (VALUES('1'::numeric),('4.2'),('inf'),('nan')) +SELECT x, + log(x), + log10(x), + ln(x) +FROM v +-- +CTE: "v" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log10" function="log10" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 546 +SELECT ln('0'::numeric) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 547 +SELECT ln('-1'::numeric) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 548 +SELECT ln('-inf'::numeric) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 549 +WITH v(x) AS + (VALUES('2'::numeric),('4.2'),('inf'),('nan')) +SELECT x1, x2, + log(x1, x2) +FROM v AS v1(x1), v AS v2(x2) +-- +ALIAS: "v1"="v" +ALIAS: "v2"="v" +CTE: "v" +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 550 +SELECT log('0'::numeric, '10') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 551 +SELECT log('10'::numeric, '0') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 552 +SELECT log('-inf'::numeric, '10') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 553 +SELECT log('10'::numeric, '-inf') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 554 +SELECT log('inf'::numeric, '0') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 555 +SELECT log('inf'::numeric, '-inf') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 556 +SELECT log('-inf'::numeric, 'inf') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 557 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('2'),('4.2'),('inf'),('nan')) +SELECT x1, x2, + power(x1, x2) +FROM v AS v1(x1), v AS v2(x2) WHERE x1 != 0 OR x2 >= 0 +-- +ALIAS: "v1"="v" +ALIAS: "v2"="v" +CTE: "v" +FUNCTION: name="power" function="power" schema="" ctx=Call +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="x2" +STMT: SelectStmt +== 558 +SELECT power('0'::numeric, '-1') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 559 +SELECT power('0'::numeric, '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 560 +SELECT power('-1'::numeric, 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 561 +SELECT power('-2'::numeric, '3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 562 +SELECT power('-2'::numeric, '3.3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 563 +SELECT power('-2'::numeric, '-1') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 564 +SELECT power('-2'::numeric, '-1.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 565 +SELECT power('-2'::numeric, 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 566 +SELECT power('-2'::numeric, '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 567 +SELECT power('inf'::numeric, '-2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 568 +SELECT power('inf'::numeric, '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 569 +SELECT power('-inf'::numeric, '2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 570 +SELECT power('-inf'::numeric, '3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 571 +SELECT power('-inf'::numeric, '4.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 572 +SELECT power('-inf'::numeric, '-2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 573 +SELECT power('-inf'::numeric, '-3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 574 +SELECT power('-inf'::numeric, '0') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 575 +SELECT power('-inf'::numeric, 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 576 +SELECT power('-inf'::numeric, '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +== 577 +-- ****************************** +-- * miscellaneous checks for things that have been broken in the past... +-- ****************************** +-- numeric AVG used to fail on some platforms +SELECT AVG(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 578 +SELECT MAX(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 579 +SELECT MIN(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 580 +SELECT STDDEV(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +== 581 +SELECT VARIANCE(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 582 +-- Check for appropriate rounding and overflow +CREATE TABLE fract_only (id int, val numeric(4,4)) +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DDL +STMT: CreateStmt +== 583 +INSERT INTO fract_only VALUES (1, '0.0') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 584 +INSERT INTO fract_only VALUES (2, '0.1') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 585 +INSERT INTO fract_only VALUES (3, '1.0') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 586 +-- should fail +INSERT INTO fract_only VALUES (4, '-0.9999') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 587 +INSERT INTO fract_only VALUES (5, '0.99994') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 588 +INSERT INTO fract_only VALUES (6, '0.99995') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 589 +-- should fail +INSERT INTO fract_only VALUES (7, '0.00001') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 590 +INSERT INTO fract_only VALUES (8, '0.00017') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 591 +INSERT INTO fract_only VALUES (9, 'NaN') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 592 +INSERT INTO fract_only VALUES (10, 'Inf') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 593 +-- should fail +INSERT INTO fract_only VALUES (11, '-Inf') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 594 +-- should fail +SELECT * FROM fract_only +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=Select +STMT: SelectStmt +== 595 +DROP TABLE fract_only +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DDL +STMT: DropStmt +== 596 +-- Check conversion to integers +SELECT (-9223372036854775808.5)::int8 +-- +STMT: SelectStmt +== 597 +-- should fail +SELECT (-9223372036854775808.4)::int8 +-- +STMT: SelectStmt +== 598 +-- ok +SELECT 9223372036854775807.4::int8 +-- +STMT: SelectStmt +== 599 +-- ok +SELECT 9223372036854775807.5::int8 +-- +STMT: SelectStmt +== 600 +-- should fail +SELECT (-2147483648.5)::int4 +-- +STMT: SelectStmt +== 601 +-- should fail +SELECT (-2147483648.4)::int4 +-- +STMT: SelectStmt +== 602 +-- ok +SELECT 2147483647.4::int4 +-- +STMT: SelectStmt +== 603 +-- ok +SELECT 2147483647.5::int4 +-- +STMT: SelectStmt +== 604 +-- should fail +SELECT (-32768.5)::int2 +-- +STMT: SelectStmt +== 605 +-- should fail +SELECT (-32768.4)::int2 +-- +STMT: SelectStmt +== 606 +-- ok +SELECT 32767.4::int2 +-- +STMT: SelectStmt +== 607 +-- ok +SELECT 32767.5::int2 +-- +STMT: SelectStmt +== 608 +-- should fail + +-- Check inf/nan conversion behavior +SELECT 'NaN'::float8::numeric +-- +STMT: SelectStmt +== 609 +SELECT 'Infinity'::float8::numeric +-- +STMT: SelectStmt +== 610 +SELECT '-Infinity'::float8::numeric +-- +STMT: SelectStmt +== 611 +SELECT 'NaN'::numeric::float8 +-- +STMT: SelectStmt +== 612 +SELECT 'Infinity'::numeric::float8 +-- +STMT: SelectStmt +== 613 +SELECT '-Infinity'::numeric::float8 +-- +STMT: SelectStmt +== 614 +SELECT 'NaN'::float4::numeric +-- +STMT: SelectStmt +== 615 +SELECT 'Infinity'::float4::numeric +-- +STMT: SelectStmt +== 616 +SELECT '-Infinity'::float4::numeric +-- +STMT: SelectStmt +== 617 +SELECT 'NaN'::numeric::float4 +-- +STMT: SelectStmt +== 618 +SELECT 'Infinity'::numeric::float4 +-- +STMT: SelectStmt +== 619 +SELECT '-Infinity'::numeric::float4 +-- +STMT: SelectStmt +== 620 +SELECT '42'::int2::numeric +-- +STMT: SelectStmt +== 621 +SELECT 'NaN'::numeric::int2 +-- +STMT: SelectStmt +== 622 +SELECT 'Infinity'::numeric::int2 +-- +STMT: SelectStmt +== 623 +SELECT '-Infinity'::numeric::int2 +-- +STMT: SelectStmt +== 624 +SELECT 'NaN'::numeric::int4 +-- +STMT: SelectStmt +== 625 +SELECT 'Infinity'::numeric::int4 +-- +STMT: SelectStmt +== 626 +SELECT '-Infinity'::numeric::int4 +-- +STMT: SelectStmt +== 627 +SELECT 'NaN'::numeric::int8 +-- +STMT: SelectStmt +== 628 +SELECT 'Infinity'::numeric::int8 +-- +STMT: SelectStmt +== 629 +SELECT '-Infinity'::numeric::int8 +-- +STMT: SelectStmt +== 630 +-- Simple check that ceil(), floor(), and round() work correctly +CREATE TABLE ceil_floor_round (a numeric) +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DDL +STMT: CreateStmt +== 631 +INSERT INTO ceil_floor_round VALUES ('-5.5') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 632 +INSERT INTO ceil_floor_round VALUES ('-5.499999') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 633 +INSERT INTO ceil_floor_round VALUES ('9.5') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 634 +INSERT INTO ceil_floor_round VALUES ('9.4999999') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 635 +INSERT INTO ceil_floor_round VALUES ('0.0') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 636 +INSERT INTO ceil_floor_round VALUES ('0.0000001') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 637 +INSERT INTO ceil_floor_round VALUES ('-0.000001') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 638 +SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=Select +FUNCTION: name="ceil" function="ceil" schema="" ctx=Call +FUNCTION: name="ceiling" function="ceiling" schema="" ctx=Call +FUNCTION: name="floor" function="floor" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 639 +DROP TABLE ceil_floor_round +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DDL +STMT: DropStmt +== 640 +-- Check rounding, it should round ties away from zero. +SELECT i as pow, + round((-2.5 * 10 ^ i)::numeric, -i), + round((-1.5 * 10 ^ i)::numeric, -i), + round((-0.5 * 10 ^ i)::numeric, -i), + round((0.5 * 10 ^ i)::numeric, -i), + round((1.5 * 10 ^ i)::numeric, -i), + round((2.5 * 10 ^ i)::numeric, -i) +FROM generate_series(-5,5) AS t(i) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 641 +-- Check limits of rounding before the decimal point +SELECT round(4.4e131071, -131071) = 4e131071 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 642 +SELECT round(4.5e131071, -131071) = 5e131071 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 643 +SELECT round(4.5e131071, -131072) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 644 +-- loses all digits +SELECT round(5.5e131071, -131072) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 645 +-- rounds up and overflows +SELECT round(5.5e131071, -131073) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 646 +-- loses all digits +SELECT round(5.5e131071, -1000000) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 647 +-- loses all digits + +-- Check limits of rounding after the decimal point +SELECT round(5e-16383, 1000000) = 5e-16383 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 648 +SELECT round(5e-16383, 16383) = 5e-16383 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 649 +SELECT round(5e-16383, 16382) = 1e-16382 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 650 +SELECT round(5e-16383, 16381) = 0 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 651 +-- Check limits of trunc() before the decimal point +SELECT trunc(9.9e131071, -131071) = 9e131071 +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 652 +SELECT trunc(9.9e131071, -131072) +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 653 +-- loses all digits +SELECT trunc(9.9e131071, -131073) +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 654 +-- loses all digits +SELECT trunc(9.9e131071, -1000000) +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 655 +-- loses all digits + +-- Check limits of trunc() after the decimal point +SELECT trunc(5e-16383, 1000000) = 5e-16383 +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 656 +SELECT trunc(5e-16383, 16383) = 5e-16383 +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 657 +SELECT trunc(5e-16383, 16382) = 0 +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +== 658 +-- Testing for width_bucket(). For convenience, we test both the +-- numeric and float8 versions of the function in this file. + +-- errors +SELECT width_bucket(5.0, 3.0, 4.0, 0) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 659 +SELECT width_bucket(5.0, 3.0, 4.0, -5) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 660 +SELECT width_bucket(3.5, 3.0, 3.0, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 661 +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, 0) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 662 +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, -5) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 663 +SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 664 +SELECT width_bucket('NaN', 3.0, 4.0, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 665 +SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 666 +SELECT width_bucket(2.0, 3.0, '-inf', 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 667 +SELECT width_bucket(0::float8, '-inf', 4.0::float8, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 668 +-- normal operation +CREATE TABLE width_bucket_test (operand_num numeric, operand_f8 float8) +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=DDL +STMT: CreateStmt +== 669 +COPY width_bucket_test (operand_num) FROM stdin +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=Select +STMT: CopyStmt +== 670 +UPDATE width_bucket_test SET operand_f8 = operand_num::float8 +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=DML +STMT: UpdateStmt +== 671 +SELECT + operand_num, + width_bucket(operand_num, 0, 10, 5) AS wb_1, + width_bucket(operand_f8, 0, 10, 5) AS wb_1f, + width_bucket(operand_num, 10, 0, 5) AS wb_2, + width_bucket(operand_f8, 10, 0, 5) AS wb_2f, + width_bucket(operand_num, 2, 8, 4) AS wb_3, + width_bucket(operand_f8, 2, 8, 4) AS wb_3f, + width_bucket(operand_num, 5.0, 5.5, 20) AS wb_4, + width_bucket(operand_f8, 5.0, 5.5, 20) AS wb_4f, + width_bucket(operand_num, -25, 25, 10) AS wb_5, + width_bucket(operand_f8, -25, 25, 10) AS wb_5f + FROM width_bucket_test +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=Select +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 672 +-- Check positive and negative infinity: we require +-- finite bucket bounds, but allow an infinite operand +SELECT width_bucket(0.0::numeric, 'Infinity'::numeric, 5, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 673 +-- error +SELECT width_bucket(0.0::numeric, 5, '-Infinity'::numeric, 20) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 674 +-- error +SELECT width_bucket('Infinity'::numeric, 1, 10, 10), + width_bucket('-Infinity'::numeric, 1, 10, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 675 +SELECT width_bucket(0.0::float8, 'Infinity'::float8, 5, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 676 +-- error +SELECT width_bucket(0.0::float8, 5, '-Infinity'::float8, 20) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 677 +-- error +SELECT width_bucket('Infinity'::float8, 1, 10, 10), + width_bucket('-Infinity'::float8, 1, 10, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 678 +DROP TABLE width_bucket_test +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=DDL +STMT: DropStmt +== 679 +-- Simple test for roundoff error when results should be exact +SELECT x, width_bucket(x::float8, 10, 100, 9) as flt, + width_bucket(x::numeric, 10, 100, 9) as num +FROM generate_series(0, 110, 10) x +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 680 +SELECT x, width_bucket(x::float8, 100, 10, 9) as flt, + width_bucket(x::numeric, 100, 10, 9) as num +FROM generate_series(0, 110, 10) x +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 681 +-- Another roundoff-error hazard +SELECT width_bucket(0, -1e100::numeric, 1, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 682 +SELECT width_bucket(0, -1e100::float8, 1, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 683 +SELECT width_bucket(1, 1e100::numeric, 0, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 684 +SELECT width_bucket(1, 1e100::float8, 0, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 685 +-- Check cases that could trigger overflow or underflow within the calculation +SELECT oper, low, high, cnt, width_bucket(oper, low, high, cnt) +FROM + (SELECT 1.797e+308::float8 AS big, 5e-324::float8 AS tiny) as v, + LATERAL (VALUES + (10.5::float8, -big, big, 1), + (10.5::float8, -big, big, 2), + (10.5::float8, -big, big, 3), + (big / 4, -big / 2, big / 2, 10), + (10.5::float8, big, -big, 1), + (10.5::float8, big, -big, 2), + (10.5::float8, big, -big, 3), + (big / 4, big / 2, -big / 2, 10), + (0, 0, tiny, 4), + (tiny, 0, tiny, 4), + (0, 0, 1, 2147483647), + (1, 1, 0, 2147483647) + ) as sample(oper, low, high, cnt) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 686 +-- These fail because the result would be out of int32 range: +SELECT width_bucket(1::float8, 0, 1, 2147483647) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 687 +SELECT width_bucket(0::float8, 1, 0, 2147483647) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +== 688 +|-- +-- TO_CHAR() +|-- +SELECT to_char(val, '9G999G999G999G999G999') + FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 689 +SELECT to_char(val, '9G999G999G999G999G999D999G999G999G999G999') + FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 690 +SELECT to_char(val, '9999999999999999.999999999999999PR') + FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 691 +SELECT to_char(val, '9999999999999999.999999999999999S') + FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 692 +SELECT to_char(val, 'MI9999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 693 +SELECT to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 694 +SELECT to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 695 +SELECT to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 696 +SELECT to_char(val, '0999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 697 +SELECT to_char(val, 'S0999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 698 +SELECT to_char(val, 'FM0999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 699 +SELECT to_char(val, 'FM9999999999999999.099999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 700 +SELECT to_char(val, 'FM9999999999990999.990999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 701 +SELECT to_char(val, 'FM0999999999999999.999909999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 702 +SELECT to_char(val, 'FM9999999990999999.099999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 703 +SELECT to_char(val, 'L9999999999999999.099999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 704 +SELECT to_char(val, 'FM9999999999999999.99999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 705 +SELECT to_char(val, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 706 +SELECT to_char(val, 'FMS 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 707 +SELECT to_char(val, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 708 +SELECT to_char(val, '999999SG9999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 709 +SELECT to_char(val, 'FM9999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 710 +SELECT to_char(val, '9.999EEEE') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 711 +WITH v(val) AS + (VALUES('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan')) +SELECT val, + to_char(val, '9.999EEEE') as numeric, + to_char(val::float8, '9.999EEEE') as float8, + to_char(val::float4, '9.999EEEE') as float4 +FROM v +-- +CTE: "v" +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 712 +WITH v(exp) AS + (VALUES(-16379),(-16378),(-1234),(-789),(-45),(-5),(-4),(-3),(-2),(-1),(0), + (1),(2),(3),(4),(5),(38),(275),(2345),(45678),(131070),(131071)) +SELECT exp, + to_char(('1.2345e'||exp)::numeric, '9.999EEEE') as numeric +FROM v +-- +CTE: "v" +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 713 +WITH v(val) AS + (VALUES('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan')) +SELECT val, + to_char(val, 'MI9999999999.99') as numeric, + to_char(val::float8, 'MI9999999999.99') as float8, + to_char(val::float4, 'MI9999999999.99') as float4 +FROM v +-- +CTE: "v" +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 714 +WITH v(val) AS + (VALUES('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan')) +SELECT val, + to_char(val, 'MI99.99') as numeric, + to_char(val::float8, 'MI99.99') as float8, + to_char(val::float4, 'MI99.99') as float4 +FROM v +-- +CTE: "v" +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 715 +SELECT to_char('100'::numeric, 'FM999.9') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 716 +SELECT to_char('100'::numeric, 'FM999.') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 717 +SELECT to_char('100'::numeric, 'FM999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 718 +SELECT to_char('12345678901'::float8, 'FM9999999999D9999900000000000000000') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 719 +-- Check parsing of literal text in a format string +SELECT to_char('100'::numeric, 'foo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 720 +SELECT to_char('100'::numeric, 'f\oo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 721 +SELECT to_char('100'::numeric, 'f\\oo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 722 +SELECT to_char('100'::numeric, 'f\"oo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 723 +SELECT to_char('100'::numeric, 'f\\"oo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 724 +SELECT to_char('100'::numeric, 'f"ool"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 725 +SELECT to_char('100'::numeric, 'f"\ool"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 726 +SELECT to_char('100'::numeric, 'f"\\ool"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 727 +SELECT to_char('100'::numeric, 'f"ool\"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 728 +SELECT to_char('100'::numeric, 'f"ool\\"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 729 +-- TO_NUMBER() +|-- +SET lc_numeric = 'C' +-- +STMT: VariableSetStmt +== 730 +SELECT to_number('-34,338,492', '99G999G999') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 731 +SELECT to_number('-34,338,492.654,878', '99G999G999D999G999') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 732 +SELECT to_number('<564646.654564>', '999999.999999PR') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 733 +SELECT to_number('0.00001-', '9.999999S') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 734 +SELECT to_number('5.01-', 'FM9.999999S') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 735 +SELECT to_number('5.01-', 'FM9.999999MI') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 736 +SELECT to_number('5 4 4 4 4 8 . 7 8', '9 9 9 9 9 9 . 9 9') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 737 +SELECT to_number('.01', 'FM9.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 738 +SELECT to_number('.0', '99999999.99999999') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 739 +SELECT to_number('0', '99.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 740 +SELECT to_number('.-01', 'S99.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 741 +SELECT to_number('.01-', '99.99S') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 742 +SELECT to_number(' . 0 1-', ' 9 9 . 9 9 S') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 743 +SELECT to_number('34,50','999,99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 744 +SELECT to_number('123,000','999G') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 745 +SELECT to_number('123456','999G999') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 746 +SELECT to_number('$1234.56','L9,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 747 +SELECT to_number('$1234.56','L99,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 748 +SELECT to_number('$1,234.56','L99,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 749 +SELECT to_number('1234.56','L99,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 750 +SELECT to_number('1,234.56','L99,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 751 +SELECT to_number('42nd', '99th') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +== 752 +RESET lc_numeric +-- +STMT: VariableSetStmt +== 753 +|-- +-- Input syntax +|-- + +CREATE TABLE num_input_test (n1 numeric) +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DDL +STMT: CreateStmt +== 754 +-- good inputs +INSERT INTO num_input_test(n1) VALUES (' 123') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 755 +INSERT INTO num_input_test(n1) VALUES (' 3245874 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 756 +INSERT INTO num_input_test(n1) VALUES (' -93853') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 757 +INSERT INTO num_input_test(n1) VALUES ('555.50') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 758 +INSERT INTO num_input_test(n1) VALUES ('-555.50') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 759 +INSERT INTO num_input_test(n1) VALUES ('NaN ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 760 +INSERT INTO num_input_test(n1) VALUES (' nan') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 761 +INSERT INTO num_input_test(n1) VALUES (' inf ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 762 +INSERT INTO num_input_test(n1) VALUES (' +inf ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 763 +INSERT INTO num_input_test(n1) VALUES (' -inf ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 764 +INSERT INTO num_input_test(n1) VALUES (' Infinity ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 765 +INSERT INTO num_input_test(n1) VALUES (' +inFinity ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 766 +INSERT INTO num_input_test(n1) VALUES (' -INFINITY ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 767 +INSERT INTO num_input_test(n1) VALUES ('12_000_000_000') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 768 +INSERT INTO num_input_test(n1) VALUES ('12_000.123_456') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 769 +INSERT INTO num_input_test(n1) VALUES ('23_000_000_000e-1_0') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 770 +INSERT INTO num_input_test(n1) VALUES ('.000_000_000_123e1_0') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 771 +INSERT INTO num_input_test(n1) VALUES ('.000_000_000_123e+1_1') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 772 +INSERT INTO num_input_test(n1) VALUES ('0b10001110111100111100001001010') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 773 +INSERT INTO num_input_test(n1) VALUES (' -0B_1010_1011_0101_0100_1010_1001_1000_1100_1110_1011_0001_1111_0000_1010_1101_0010 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 774 +INSERT INTO num_input_test(n1) VALUES (' +0o112402761777 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 775 +INSERT INTO num_input_test(n1) VALUES ('-0O0012_5524_5230_6334_3167_0261') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 776 +INSERT INTO num_input_test(n1) VALUES ('-0x0000000000000000000000000deadbeef') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 777 +INSERT INTO num_input_test(n1) VALUES (' 0X_30b1_F33a_6DF0_bD4E_64DF_9BdA_7D15 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 778 +-- bad inputs +INSERT INTO num_input_test(n1) VALUES (' ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 779 +INSERT INTO num_input_test(n1) VALUES (' 1234 %') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 780 +INSERT INTO num_input_test(n1) VALUES ('xyz') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 781 +INSERT INTO num_input_test(n1) VALUES ('- 1234') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 782 +INSERT INTO num_input_test(n1) VALUES ('5 . 0') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 783 +INSERT INTO num_input_test(n1) VALUES ('5. 0 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 784 +INSERT INTO num_input_test(n1) VALUES ('') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 785 +INSERT INTO num_input_test(n1) VALUES (' N aN ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 786 +INSERT INTO num_input_test(n1) VALUES ('+NaN') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 787 +INSERT INTO num_input_test(n1) VALUES ('-NaN') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 788 +INSERT INTO num_input_test(n1) VALUES ('+ infinity') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 789 +INSERT INTO num_input_test(n1) VALUES ('_123') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 790 +INSERT INTO num_input_test(n1) VALUES ('123_') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 791 +INSERT INTO num_input_test(n1) VALUES ('12__34') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 792 +INSERT INTO num_input_test(n1) VALUES ('123_.456') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 793 +INSERT INTO num_input_test(n1) VALUES ('123._456') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 794 +INSERT INTO num_input_test(n1) VALUES ('1.2e_34') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 795 +INSERT INTO num_input_test(n1) VALUES ('1.2e34_') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 796 +INSERT INTO num_input_test(n1) VALUES ('1.2e3__4') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 797 +INSERT INTO num_input_test(n1) VALUES ('0b1112') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 798 +INSERT INTO num_input_test(n1) VALUES ('0c1112') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 799 +INSERT INTO num_input_test(n1) VALUES ('0o12345678') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 800 +INSERT INTO num_input_test(n1) VALUES ('0x1eg') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 801 +INSERT INTO num_input_test(n1) VALUES ('0x12.34') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 802 +INSERT INTO num_input_test(n1) VALUES ('0x__1234') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 803 +INSERT INTO num_input_test(n1) VALUES ('0x1234_') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 804 +INSERT INTO num_input_test(n1) VALUES ('0x12__34') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 805 +SELECT * FROM num_input_test +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=Select +STMT: SelectStmt +== 806 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34.5', 'numeric') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 807 +SELECT pg_input_is_valid('34xyz', 'numeric') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 808 +SELECT pg_input_is_valid('1e400000', 'numeric') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 809 +SELECT * FROM pg_input_error_info('1e400000', 'numeric') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 810 +SELECT pg_input_is_valid('1234.567', 'numeric(8,4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 811 +SELECT pg_input_is_valid('1234.567', 'numeric(7,4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 812 +SELECT * FROM pg_input_error_info('1234.567', 'numeric(7,4)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 813 +SELECT * FROM pg_input_error_info('0x1234.567', 'numeric') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 814 +|-- +-- Test precision and scale typemods +|-- + +CREATE TABLE num_typemod_test ( + millions numeric(3, -6), + thousands numeric(3, -3), + units numeric(3, 0), + thousandths numeric(3, 3), + millionths numeric(3, 6) +) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DDL +STMT: CreateStmt +== 815 +-- rounding of valid inputs +INSERT INTO num_typemod_test VALUES (123456, 123, 0.123, 0.000123, 0.000000123) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 816 +INSERT INTO num_typemod_test VALUES (654321, 654, 0.654, 0.000654, 0.000000654) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 817 +INSERT INTO num_typemod_test VALUES (2345678, 2345, 2.345, 0.002345, 0.000002345) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 818 +INSERT INTO num_typemod_test VALUES (7654321, 7654, 7.654, 0.007654, 0.000007654) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 819 +INSERT INTO num_typemod_test VALUES (12345678, 12345, 12.345, 0.012345, 0.000012345) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 820 +INSERT INTO num_typemod_test VALUES (87654321, 87654, 87.654, 0.087654, 0.000087654) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 821 +INSERT INTO num_typemod_test VALUES (123456789, 123456, 123.456, 0.123456, 0.000123456) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 822 +INSERT INTO num_typemod_test VALUES (987654321, 987654, 987.654, 0.987654, 0.000987654) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 823 +INSERT INTO num_typemod_test VALUES ('NaN', 'NaN', 'NaN', 'NaN', 'NaN') +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 824 +SELECT scale(millions), * FROM num_typemod_test ORDER BY millions +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=Select +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 825 +-- invalid inputs +INSERT INTO num_typemod_test (millions) VALUES ('inf') +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 826 +INSERT INTO num_typemod_test (millions) VALUES (999500000) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 827 +INSERT INTO num_typemod_test (thousands) VALUES (999500) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 828 +INSERT INTO num_typemod_test (units) VALUES (999.5) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 829 +INSERT INTO num_typemod_test (thousandths) VALUES (0.9995) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 830 +INSERT INTO num_typemod_test (millionths) VALUES (0.0009995) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 831 +|-- +-- Test some corner cases for multiplication +|-- + +select 4790999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +-- +STMT: SelectStmt +== 832 +select 4789999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +-- +STMT: SelectStmt +== 833 +select 4770999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +-- +STMT: SelectStmt +== 834 +select 4769999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +-- +STMT: SelectStmt +== 835 +select trim_scale((0.1 - 2e-16383) * (0.1 - 3e-16383)) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 836 +|-- +-- Test some corner cases for division +|-- + +select 999999999999999999999::numeric/1000000000000000000000 +-- +STMT: SelectStmt +== 837 +select div(999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 838 +select mod(999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="mod" function="mod" schema="" ctx=Call +STMT: SelectStmt +== 839 +select div(-9999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 840 +select mod(-9999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="mod" function="mod" schema="" ctx=Call +STMT: SelectStmt +== 841 +select div(-9999999999999999999999::numeric,1000000000000000000000)*1000000000000000000000 + mod(-9999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +STMT: SelectStmt +== 842 +select mod (70.0,70) +-- +FUNCTION: name="mod" function="mod" schema="" ctx=Call +STMT: SelectStmt +== 843 +select div (70.0,70) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 844 +select 70.0 / 70 +-- +STMT: SelectStmt +== 845 +select 12345678901234567890 % 123 +-- +STMT: SelectStmt +== 846 +select 12345678901234567890 / 123 +-- +STMT: SelectStmt +== 847 +select div(12345678901234567890, 123) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 848 +select div(12345678901234567890, 123) * 123 + 12345678901234567890 % 123 +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +== 849 +|-- +-- Test some corner cases for square root +|-- + +select sqrt(1.000000000000003::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 850 +select sqrt(1.000000000000004::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 851 +select sqrt(96627521408608.56340355805::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 852 +select sqrt(96627521408608.56340355806::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 853 +select sqrt(515549506212297735.073688290367::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 854 +select sqrt(515549506212297735.073688290368::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 855 +select sqrt(8015491789940783531003294973900306::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 856 +select sqrt(8015491789940783531003294973900307::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +== 857 +|-- +-- Test code path for raising to integer powers +|-- + +select 10.0 ^ -2147483648 as rounds_to_zero +-- +STMT: SelectStmt +== 858 +select 10.0 ^ -2147483647 as rounds_to_zero +-- +STMT: SelectStmt +== 859 +select 10.0 ^ 2147483647 as overflows +-- +STMT: SelectStmt +== 860 +select 117743296169.0 ^ 1000000000 as overflows +-- +STMT: SelectStmt +== 861 +-- cases that used to return inaccurate results +select 3.789 ^ 21.0000000000000000 +-- +STMT: SelectStmt +== 862 +select 3.789 ^ 35.0000000000000000 +-- +STMT: SelectStmt +== 863 +select 1.2 ^ 345 +-- +STMT: SelectStmt +== 864 +select 0.12 ^ (-20) +-- +STMT: SelectStmt +== 865 +select 1.000000000123 ^ (-2147483648) +-- +STMT: SelectStmt +== 866 +select coalesce(nullif(0.9999999999 ^ 23300000000000, 0), 0) as rounds_to_zero +-- +STMT: SelectStmt +== 867 +select round(((1 - 1.500012345678e-1000) ^ 1.45e1003) * 1e1000) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +== 868 +-- cases that used to error out +select 0.12 ^ (-25) +-- +STMT: SelectStmt +== 869 +select 0.5678 ^ (-85) +-- +STMT: SelectStmt +== 870 +select coalesce(nullif(0.9999999999 ^ 70000000000000, 0), 0) as underflows +-- +STMT: SelectStmt +== 871 +-- negative base to integer powers +select (-1.0) ^ 2147483646 +-- +STMT: SelectStmt +== 872 +select (-1.0) ^ 2147483647 +-- +STMT: SelectStmt +== 873 +select (-1.0) ^ 2147483648 +-- +STMT: SelectStmt +== 874 +select (-1.0) ^ 1000000000000000 +-- +STMT: SelectStmt +== 875 +select (-1.0) ^ 1000000000000001 +-- +STMT: SelectStmt +== 876 +-- integer powers of 10 +select n, 10.0 ^ n as "10^n", (10.0 ^ n) * (10.0 ^ (-n)) = 1 as ok +from generate_series(-20, 20) n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 877 +|-- +-- Tests for raising to non-integer powers +|-- + +-- special cases +select 0.0 ^ 0.0 +-- +STMT: SelectStmt +== 878 +select (-12.34) ^ 0.0 +-- +STMT: SelectStmt +== 879 +select 12.34 ^ 0.0 +-- +STMT: SelectStmt +== 880 +select 0.0 ^ 12.34 +-- +STMT: SelectStmt +== 881 +-- NaNs +select 'NaN'::numeric ^ 'NaN'::numeric +-- +STMT: SelectStmt +== 882 +select 'NaN'::numeric ^ 0 +-- +STMT: SelectStmt +== 883 +select 'NaN'::numeric ^ 1 +-- +STMT: SelectStmt +== 884 +select 0 ^ 'NaN'::numeric +-- +STMT: SelectStmt +== 885 +select 1 ^ 'NaN'::numeric +-- +STMT: SelectStmt +== 886 +-- invalid inputs +select 0.0 ^ (-12.34) +-- +STMT: SelectStmt +== 887 +select (-12.34) ^ 1.2 +-- +STMT: SelectStmt +== 888 +-- cases that used to generate inaccurate results +select 32.1 ^ 9.8 +-- +STMT: SelectStmt +== 889 +select 32.1 ^ (-9.8) +-- +STMT: SelectStmt +== 890 +select 12.3 ^ 45.6 +-- +STMT: SelectStmt +== 891 +select 12.3 ^ (-45.6) +-- +STMT: SelectStmt +== 892 +-- big test +select 1.234 ^ 5678 +-- +STMT: SelectStmt +== 893 +|-- +-- Tests for EXP() +|-- + +-- special cases +select exp(0.0) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 894 +select exp(1.0) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 895 +select exp(1.0::numeric(71,70)) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 896 +select exp('nan'::numeric) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 897 +select exp('inf'::numeric) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 898 +select exp('-inf'::numeric) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 899 +select coalesce(nullif(exp(-5000::numeric), 0), 0) as rounds_to_zero +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 900 +select coalesce(nullif(exp(-10000::numeric), 0), 0) as underflows +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 901 +-- cases that used to generate inaccurate results +select exp(32.999) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 902 +select exp(-32.999) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 903 +select exp(123.456) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 904 +select exp(-123.456) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 905 +-- big test +select exp(1234.5678) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 906 +|-- +-- Tests for generate_series +|-- +select * from generate_series(0.0::numeric, 4.0::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 907 +select * from generate_series(0.1::numeric, 4.0::numeric, 1.3::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 908 +select * from generate_series(4.0::numeric, -1.5::numeric, -2.2::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 909 +-- Trigger errors +select * from generate_series(-100::numeric, 100::numeric, 0::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 910 +select * from generate_series(-100::numeric, 100::numeric, 'nan'::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 911 +select * from generate_series('nan'::numeric, 100::numeric, 10::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 912 +select * from generate_series(0::numeric, 'nan'::numeric, 10::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 913 +select * from generate_series('inf'::numeric, 'inf'::numeric, 10::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 914 +select * from generate_series(0::numeric, 'inf'::numeric, 10::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 915 +select * from generate_series(0::numeric, '42'::numeric, '-inf'::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 916 +-- Checks maximum, output is truncated +select (i / (10::numeric ^ 131071))::numeric(1,0) + from generate_series(6 * (10::numeric ^ 131071), + 9 * (10::numeric ^ 131071), + 10::numeric ^ 131071) as a(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 917 +-- Check usage with variables +select * from generate_series(1::numeric, 3::numeric) i, generate_series(i,3) j +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 918 +select * from generate_series(1::numeric, 3::numeric) i, generate_series(1,i) j +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 919 +select * from generate_series(1::numeric, 3::numeric) i, generate_series(1,5,i) j +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 920 +|-- +-- Tests for LN() +|-- + +-- Invalid inputs +select ln(-12.34) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 921 +select ln(0.0) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 922 +-- Some random tests +select ln(1.2345678e-28) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 923 +select ln(0.0456789) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 924 +select ln(0.349873948359354029493948309745709580730482050975) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 925 +select ln(0.99949452) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 926 +select ln(1.00049687395) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 927 +select ln(1234.567890123456789) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 928 +select ln(5.80397490724e5) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 929 +select ln(9.342536355e34) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 930 +|-- +-- Tests for LOG() (base 10) +|-- + +-- invalid inputs +select log(-12.34) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 931 +select log(0.0) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 932 +-- some random tests +select log(1.234567e-89) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 933 +select log(3.4634998359873254962349856073435545) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 934 +select log(9.999999999999999999) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 935 +select log(10.00000000000000000) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 936 +select log(10.00000000000000001) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 937 +select log(590489.45235237) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 938 +|-- +-- Tests for LOG() (arbitrary base) +|-- + +-- invalid inputs +select log(-12.34, 56.78) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 939 +select log(-12.34, -56.78) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 940 +select log(12.34, -56.78) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 941 +select log(0.0, 12.34) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 942 +select log(12.34, 0.0) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 943 +select log(1.0, 12.34) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 944 +-- some random tests +select log(1.23e-89, 6.4689e45) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 945 +select log(0.99923, 4.58934e34) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 946 +select log(1.000016, 8.452010e18) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 947 +select log(3.1954752e47, 9.4792021e-73) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 948 +|-- +-- Tests for scale() +|-- + +select scale(numeric 'NaN') +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 949 +select scale(numeric 'inf') +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 950 +select scale(NULL::numeric) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 951 +select scale(1.12) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 952 +select scale(0) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 953 +select scale(0.00) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 954 +select scale(1.12345) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 955 +select scale(110123.12475871856128) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 956 +select scale(-1123.12471856128) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 957 +select scale(-13.000000000000000) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +== 958 +|-- +-- Tests for min_scale() +|-- + +select min_scale(numeric 'NaN') is NULL +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 959 +-- should be true +select min_scale(numeric 'inf') is NULL +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 960 +-- should be true +select min_scale(0) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 961 +-- no digits +select min_scale(0.00) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 962 +-- no digits again +select min_scale(1.0) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 963 +-- no scale +select min_scale(1.1) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 964 +-- scale 1 +select min_scale(1.12) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 965 +-- scale 2 +select min_scale(1.123) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 966 +-- scale 3 +select min_scale(1.1234) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 967 +-- scale 4, filled digit +select min_scale(1.12345) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 968 +-- scale 5, 2 NDIGITS +select min_scale(1.1000) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 969 +-- 1 pos in NDIGITS +select min_scale(1e100) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +== 970 +-- very big number + +|-- +-- Tests for trim_scale() +|-- + +select trim_scale(numeric 'NaN') +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 971 +select trim_scale(numeric 'inf') +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 972 +select trim_scale(1.120) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 973 +select trim_scale(0) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 974 +select trim_scale(0.00) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 975 +select trim_scale(1.1234500) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 976 +select trim_scale(110123.12475871856128000) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 977 +select trim_scale(-1123.124718561280000000) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 978 +select trim_scale(-13.00000000000000000000) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 979 +select trim_scale(1e100) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +== 980 +|-- +-- Tests for SUM() +|-- + +-- cases that need carry propagation +SELECT SUM(9999::numeric) FROM generate_series(1, 100000) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 981 +SELECT SUM((-9999)::numeric) FROM generate_series(1, 100000) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 982 +|-- +-- Tests for VARIANCE() +|-- +CREATE TABLE num_variance (a numeric) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DDL +STMT: CreateStmt +== 983 +INSERT INTO num_variance VALUES (0) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 984 +INSERT INTO num_variance VALUES (3e-500) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 985 +INSERT INTO num_variance VALUES (-3e-500) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 986 +INSERT INTO num_variance VALUES (4e-500 - 1e-16383) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 987 +INSERT INTO num_variance VALUES (-4e-500 + 1e-16383) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 988 +-- variance is just under 12.5e-1000 and so should round down to 12e-1000 +SELECT trim_scale(variance(a) * 1e1000) FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=Select +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 989 +-- check that parallel execution produces the same result +BEGIN +-- +STMT: TransactionStmt +== 990 +ALTER TABLE num_variance SET (parallel_workers = 4) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DDL +STMT: AlterTableStmt +== 991 +SET LOCAL parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 992 +SET LOCAL max_parallel_workers_per_gather = 4 +-- +STMT: VariableSetStmt +== 993 +SELECT trim_scale(variance(a) * 1e1000) FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=Select +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 994 +ROLLBACK +-- +STMT: TransactionStmt +== 995 +-- case where sum of squares would overflow but variance does not +DELETE FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: DeleteStmt +== 996 +INSERT INTO num_variance SELECT 9e131071 + x FROM generate_series(1, 5) x +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 997 +SELECT variance(a) FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 998 +-- check that parallel execution produces the same result +BEGIN +-- +STMT: TransactionStmt +== 999 +ALTER TABLE num_variance SET (parallel_workers = 4) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DDL +STMT: AlterTableStmt +== 1000 +SET LOCAL parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 1001 +SET LOCAL max_parallel_workers_per_gather = 4 +-- +STMT: VariableSetStmt +== 1002 +SELECT variance(a) FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 1003 +ROLLBACK +-- +STMT: TransactionStmt +== 1004 +DROP TABLE num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DDL +STMT: DropStmt +== 1005 +|-- +-- Tests for GCD() +|-- +SELECT a, b, gcd(a, b), gcd(a, -b), gcd(-b, a), gcd(-b, -a) +FROM (VALUES (0::numeric, 0::numeric), + (0::numeric, numeric 'NaN'), + (0::numeric, 46375::numeric), + (433125::numeric, 46375::numeric), + (43312.5::numeric, 4637.5::numeric), + (4331.250::numeric, 463.75000::numeric), + ('inf', '0'), + ('inf', '42'), + ('inf', 'inf') + ) AS v(a, b) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +== 1006 +|-- +-- Tests for LCM() +|-- +SELECT a,b, lcm(a, b), lcm(a, -b), lcm(-b, a), lcm(-b, -a) +FROM (VALUES (0::numeric, 0::numeric), + (0::numeric, numeric 'NaN'), + (0::numeric, 13272::numeric), + (13272::numeric, 13272::numeric), + (423282::numeric, 13272::numeric), + (42328.2::numeric, 1327.2::numeric), + (4232.820::numeric, 132.72000::numeric), + ('inf', '0'), + ('inf', '42'), + ('inf', 'inf') + ) AS v(a, b) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +== 1007 +SELECT lcm(9999 * (10::numeric)^131068 + (10::numeric^131068 - 1), 2) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +== 1008 +-- overflow + +|-- +-- Tests for factorial +|-- +SELECT factorial(4) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +== 1009 +SELECT factorial(15) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +== 1010 +SELECT factorial(100000) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +== 1011 +SELECT factorial(0) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +== 1012 +SELECT factorial(-4) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +== 1013 +|-- +-- Tests for pg_lsn() +|-- +SELECT pg_lsn(23783416::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +== 1014 +SELECT pg_lsn(0::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +== 1015 +SELECT pg_lsn(18446744073709551615::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +== 1016 +SELECT pg_lsn(-1::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +== 1017 +SELECT pg_lsn(18446744073709551616::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +== 1018 +SELECT pg_lsn('NaN'::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/numeric_big.metadata.json b/parser/testdata/summary/postgres_regress/numeric_big.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/numeric_big.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/numeric_big.test b/parser/testdata/summary/postgres_regress/numeric_big.test new file mode 100644 index 0000000..1e5f8b3 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/numeric_big.test @@ -0,0 +1,4180 @@ +== 001 +-- ****************************** +-- * Test suite for the Postgres NUMERIC data type +-- ****************************** + +-- Must drop tables created by short numeric test. +DROP TABLE num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DDL +STMT: DropStmt +== 002 +DROP TABLE num_exp_add +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: DropStmt +== 003 +DROP TABLE num_exp_sub +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: DropStmt +== 004 +DROP TABLE num_exp_div +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: DropStmt +== 005 +DROP TABLE num_exp_mul +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: DropStmt +== 006 +DROP TABLE num_exp_sqrt +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: DropStmt +== 007 +DROP TABLE num_exp_ln +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: DropStmt +== 008 +DROP TABLE num_exp_log10 +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: DropStmt +== 009 +DROP TABLE num_exp_power_10_ln +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: DropStmt +== 010 +DROP TABLE num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DDL +STMT: DropStmt +== 011 +CREATE TABLE num_data (id int4, val numeric(1000,800)) +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DDL +STMT: CreateStmt +== 012 +CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: CreateStmt +== 013 +CREATE TABLE num_exp_sub (id1 int4, id2 int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: CreateStmt +== 014 +CREATE TABLE num_exp_div (id1 int4, id2 int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: CreateStmt +== 015 +CREATE TABLE num_exp_mul (id1 int4, id2 int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: CreateStmt +== 016 +CREATE TABLE num_exp_sqrt (id int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: CreateStmt +== 017 +CREATE TABLE num_exp_ln (id int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: CreateStmt +== 018 +CREATE TABLE num_exp_log10 (id int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: CreateStmt +== 019 +CREATE TABLE num_exp_power_10_ln (id int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: CreateStmt +== 020 +CREATE TABLE num_result (id1 int4, id2 int4, result numeric(1000,800)) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DDL +STMT: CreateStmt +== 021 +-- ****************************** +-- * The following EXPECTED results are computed by bc(1) +-- * with a scale of 1000 +-- ****************************** + +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 022 +INSERT INTO num_exp_add VALUES (0,0,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO num_exp_sub VALUES (0,0,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO num_exp_mul VALUES (0,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO num_exp_div VALUES (0,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO num_exp_add VALUES (0,1,'85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO num_exp_sub VALUES (0,1,'-85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO num_exp_mul VALUES (0,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +INSERT INTO num_exp_div VALUES (0,1,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO num_exp_add VALUES (0,2,'-994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO num_exp_sub VALUES (0,2,'994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO num_exp_mul VALUES (0,2,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO num_exp_div VALUES (0,2,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO num_exp_add VALUES (0,3,'-60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO num_exp_sub VALUES (0,3,'60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +INSERT INTO num_exp_mul VALUES (0,3,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO num_exp_div VALUES (0,3,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO num_exp_add VALUES (0,4,'5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO num_exp_sub VALUES (0,4,'-5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO num_exp_mul VALUES (0,4,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO num_exp_div VALUES (0,4,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO num_exp_add VALUES (0,5,'-652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO num_exp_sub VALUES (0,5,'652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO num_exp_mul VALUES (0,5,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO num_exp_div VALUES (0,5,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO num_exp_add VALUES (0,6,'.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO num_exp_sub VALUES (0,6,'-.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO num_exp_mul VALUES (0,6,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +INSERT INTO num_exp_div VALUES (0,6,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO num_exp_add VALUES (0,7,'-818934540071845742') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +INSERT INTO num_exp_sub VALUES (0,7,'818934540071845742') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO num_exp_mul VALUES (0,7,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +INSERT INTO num_exp_div VALUES (0,7,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +INSERT INTO num_exp_add VALUES (0,8,'8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +INSERT INTO num_exp_sub VALUES (0,8,'-8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +INSERT INTO num_exp_mul VALUES (0,8,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +INSERT INTO num_exp_div VALUES (0,8,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +INSERT INTO num_exp_add VALUES (0,9,'54863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +INSERT INTO num_exp_sub VALUES (0,9,'-54863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +INSERT INTO num_exp_mul VALUES (0,9,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +INSERT INTO num_exp_div VALUES (0,9,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +INSERT INTO num_exp_add VALUES (1,0,'85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +INSERT INTO num_exp_sub VALUES (1,0,'85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +INSERT INTO num_exp_mul VALUES (1,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +INSERT INTO num_exp_div VALUES (1,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 066 +INSERT INTO num_exp_add VALUES (1,1,'170486.79080049955252152479695727201571965474311716541919780029226071455736587237347615553466832461907447637054203186991790701615551214692555785671028648640897898741246882118067609728317430043806625387779037980513762118868084887015059202190301421555269486602797852927777567694581746398790609996101506730430853942556475840126871131898407356048450541232591147357021858041662012293323494543567675306406079659294204054863522259037763051870433216859794083051717080761509518250300466106939998045710070') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +INSERT INTO num_exp_sub VALUES (1,1,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 068 +INSERT INTO num_exp_mul VALUES (1,1,'7266436459.363324713115467666113895787027372854351303425444968800459979742082292257107107767894843498525848597439323325297125474674300428669958003640228730876886174255457103020291514229439701871032118057857763809224712818579091741996335014138185389554630910658876423205103697147288306070059640369158894028731728589073730895396494400175420670713113234800826523252075036892246807434088405522834549449664122407363485486902219500109237667016524913027290777216477989904700729228025571098410870506256758678625928245828210775042611512394316804583459576285681159178280400209217948833631961377519855502763611693070238579591463373484424582723121059964236704135695706864890193388054537703767833595331866551990460050750959493829603581882430597105627056085260296454181999581594565113210481151487049158699087454047624433576922179904629') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 069 +INSERT INTO num_exp_div VALUES (1,1,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +INSERT INTO num_exp_add VALUES (1,2,'-994877526002806872754342148663997.64812998474240514147207095573950146764154822009863493316394610578375247334825932838513167168342610420582834742950389452212867974756590355021495169819086060202117180229196935525386766373096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +INSERT INTO num_exp_sub VALUES (1,2,'994877526002806872754342148834484.43893048429492666626902822775522112238466538551783273345620682034111834572173548391979999630250058057637037929942180153828419189449146140692523818459983958943364062347264545253704196416903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +INSERT INTO num_exp_mul VALUES (1,2,'-84806738323879544552397401815149740513.8505875535743013876823142649666132764556588225959336097903898464616542203793600590311980154402068027051522932586050753865288419084437796768749509032177577451738712965496693249429231838833655025794915864261585848007162358912070811805298210095333433397862313304655108809804359760907473898420016370058274978588765092161529583480924554820756527238472641797198545539410039895140087686344382628317530286295498797849942258314364503000942821309916954725689781458590617068629906894951122301020797266469357701283289275708774593896770378558232444454118891917258610753077932026885574920166837998049508644891327208474213193224700658584824407382455480657734911543930195324144216374573825') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +INSERT INTO num_exp_div VALUES (1,2,'-.000000000000000000000000000085682300757901809257711279577127388124986344391495296640171942990079130291883279872719240502687189411421655284515420074848478500192127657883342858267913417679786356766341637336955924836847768457039175660279784295612167899455618405343686908907695358239088351870495830739180518509859269437015797489301844593920484927630172344269378248455657186218762679357609204333669024237648538465053048724383898528808961206696787294681884412485427843796696788390072124570957047672341581447744981862017791206857428430183366004980966398716823512288330174863890117558744630102020144500158878244146399686532935435591262767487823942606452349972401012308378888947381934278131785907155692007064636085000405504866631011593239041758448995933095907216863744502344014999804306234830774259496097549717476344048') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 074 +INSERT INTO num_exp_add VALUES (1,3,'-60302029489319384367663884408085672236.83687099063256754698860828386302509843815398979402006244388708674093244201278399438376682321121138429850885935540924586964982855913223221441591310211730902799041126800414795030815514254713522692405212716783388698431088814919226444677188004928663343696636297536500970117716818423689175692808344185016908913828066250587407384563498516598672584120143890364303296142744031320345312431817858545326010704685255237541162931904446804064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +INSERT INTO num_exp_sub VALUES (1,3,'60302029489319384367663884408085842723.62767149018508907178556555587874475318127115521321786273614780129829831438626014991843514783028586066905089122532715288580534070605779007112619958852628801540288008918482404759132944298520148080184250697297150817299173701934285646867489426483932830299434150464278537812298564822479785688909850915447762856384542090714278516461905872647123125352735037721325154184406043613668806975385533851732090363979459292404685190942209855935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 076 +INSERT INTO num_exp_mul VALUES (1,3,'-5140349743195574373979577554212527512597024.162480344833040409158673429491690439298506850052285119390701002577176786023622062742050099464897084793357329597395417632908812044304066963549928478520702505283307379218587635434673128958824348493758429380623577527186462464399974242800361134191519694694139153279582776168995426125926314513926640766117733774558011741611075336271613675760116784769700605008122422944290652448956922432960815546502965310676913079866511016221573557684245901002643719965652152439520727383305120298495304784052489867651462175349450610643411043707261107569691076730261762793560088893354750383257372118118753366377402045596735023445172252225346164608897913115394905485106225627590643805003075069931177395059698550161546962768768895596088478488887530518018212441345360153523733317120037436403475909117998647781920105313938836144009539683') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +INSERT INTO num_exp_div VALUES (1,3,'-.000000000000000000000000000000001413607404628860353773457807436398753936801768769045711604884548436548520368932184112069166807060840219636509423284498981041814526856251281381511288768719259120481595036745286884246627534964287523188738499223075292690431699417313258943941279343383979626641848305343592679057491670166887054819766294147341982669243114259272404203080347707713358471397866402657818267495050115642987782080912962056565478445923456884713049272637646637760989004917643369240372476411912794578381690666695711891846833983534126217706309741885844723208036219144146342212915129560758201609824034610223907791643110990898577049488934294259106725414517181607988173722432655731491050637087261030314548853334338835938120502930424813699221083197863303458179445322810087784892821862085562891180364134284641396475') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +INSERT INTO num_exp_add VALUES (1,4,'5329378275943663322300488.64471790965256505869684245785528331091076155554650629138833809683459634328609777839510066435612911583108717191216693735823717997111970662575497378762952496582183738308720094529950793570383580785385569873278068217936841324404119828637880370718028782103860007754579779716996004352284614661690063919125301052941328989181561787543541920734755989452320799185700078241880935083616978140555713297241612718277766918005268951861880490889884082730841740604517529391011862694381726143520658746305661338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 079 +INSERT INTO num_exp_sub VALUES (1,4,'-5329378275943663322130001.85391741010004353389988518583956365616764439012730849109607738227723047091262162286043233973705463946054514004224903034208166782419414876904468730122054597840936856190652484801633363526576955397606531892764306099068756437389060626447578949162759295501062154826802212022414257953494004665588557188694447110384853149054690655645134564686305448219729651828678220200218922790293483596988037990835533058983562863141746692824117439019450865871047657552800448629502344444081260036580660700595591338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +INSERT INTO num_exp_mul VALUES (1,4,'454294299613767152878025320780.534199313974295807138790763501115780294529340799108297697573066187975311338382917022391830256203305238757334106943821060545424417350991354829668286194840925251162479496893943917530660694097932059166013476064988623431110002057735318529554555260199417935495388243829261809007709919225000608711536928171687251088217591210419208480251102484043683131687013687838713055660405381318396419588727500715930145098362997142075433472039319292466570912777345841400769387321465602989947078951135489852486382469990409873227894248208197179481868230244584527040573428134962626267135732247029762468417273891700661832893497067151409134724061246612631376075173287264787886064622106855886785805818642123776489793586531950438285720668411465570116161790343538663297713926678759640594912243360541590368666922379919514826022141331900181') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +INSERT INTO num_exp_div VALUES (1,4,'.000000000000000000015994998100440878014888861029956505927201309704413242103407885948184870841766875212766910686894450511886242468216220470061916924303252919423028993720180330014505454865704155281502763018913215741264982350384245753394656021401865680441649920273268554396350483440173848850052788410943178207336328451359951614056237100465802151856198860908371340425459435127133071447273887829397881221098443685586506647314622864702873235212396755866459409263439958011711379929751157260020133239574261188528305921244365838405372320186907437842180388704854605498842516581811515413843298370501194935797268161171428747542997504369133579105180311662221854071962295818264211400101689450830279979372422749150894553349570063000769685274875561760334738424509532610467832951796852051505383374693614022043010735004494395190') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 082 +INSERT INTO num_exp_add VALUES (1,5,'-652670387.03916046850422757312745971450663862747133703839829692066597367760104802542475264601221776157515632293978442027199108085723617181683235487266149426304575903892721468296143475297345699313102262188759506518376019936160961709578829069446312051432780603656651983414612264636232727512091101057374054475214114364113300402823059519499217878746766275164739724770556122895799337810694888119810524986616938847385753562624139431982468828696587199570410008890188532132652095915565323400735066310142303225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 083 +INSERT INTO num_exp_sub VALUES (1,5,'652840873.82996096805674909792441698652235828221445420381749472095823439215841389779822880154688608619423079931032645214190898787339168396375791272937178074945473802633968350414211085025663129356908887576538544498889782055029046596593888271636613472988050090259449836342389832330814473910881711053475561205644968306669776242949930651397625234795216816397330872127577980937461350104018382663378200293023018506679957617487661691020231880567020416430204091941905612894161614165865789507675064355852373225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 084 +INSERT INTO num_exp_mul VALUES (1,5,'-55643106304872.575994253221940844841058071061962511162776681458310912066379595519265546225338405882027547140476045378015935579066580347282075024392379464189067155567624835346798806677988850250198082355055954078446421075165109896091047534711081616362392995575466807084807876544560268050611445006601394735810211678919646667455478469014906335433468365011768049600750224822391684377238242162320161552720449713229523135506671063115436813348612986916614320012995541575293478341408982118538094438068036422562665160411591652618670802973618768526197813319204816293073794413317669922144705633308090832805914096147659820167569140291210526520361556881576175809360614782817717579318298657744021133210954279487777567785280633309576696708168342539425395482429923273623865667723482418178781573723597156804085501875735112311466228778929147929') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 085 +INSERT INTO num_exp_div VALUES (1,5,'-.000130590057635351941758745900947472461593749814351229292370661147301124533787181489468804246182606762727711479707901680546780430454163647774077629503207962424213266902732555945190365467801995495570282501722505521485829885605904543846887348545254658726343578684749830307120625129857380290225370772763609458975555029415082569247186899112975387051141777417911244576134390940441209829852154391377911942082738699481875795620569383196133124499983396562167632007454221121465745085962247988140942672429187053671899537331280701003778040796615094903602095098880716919238394057384949891444700347825726273725378453454782330181608182747900774711384845635284701538541452235224216112380245660177463043471814071809869894647262285332580556739424040615194137651616350340752691170045698234853734471923738591898290468792787543896') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 086 +INSERT INTO num_exp_add VALUES (1,6,'85243.44233732197133191329295927531563604777955507322414928382967007765263923984471408038635831036097817458527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +INSERT INTO num_exp_sub VALUES (1,6,'85243.34846317758118961150399799670008360696356209219504851646259063690472663252876207514831001425809630178527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +INSERT INTO num_exp_mul VALUES (1,6,'4001.075404054519813215296429095020391062109905613738157927030437221793757373268325953178030040276107574363822832168160758728653712686313134828282109532831190239521843808940611025488601517574653932032236616573457735900045655665690517797280666732780030171712864961531623060353548802466577910774711998056232872212688464691036260746751992072745518373073825852119460094113694393273456369345499434994672730920070410547163082189385645712866100999708173472360864669110044660667614583576570496399103026286828660558854973376227247132815728164629722965145778698957093136175449225024685874279280018547740') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +INSERT INTO num_exp_div VALUES (1,6,'1816120.848909727306817960620941575637231136442992819290405125420545200026620306446043740992108329883383706060582482495616151605111275635501481354526017831484915013545483361715432312183101964395505340188909970344423950565285639911521082834494088840596716495422427543520536844348040681236845850482165744696068209384509064196671206362539077218412355776790921130042376467606683622970728503408501481791356294886150690067651815776445750760428874351556866105285911902433352126498951242195408782804314174041618879250740246352525074791310920062276490422853700893340860452528740673590486626464460321410814395342850270921486724297414692313177440726749004398703147904603937755702369682956482832074779404350351752662820773690162594400557957241676636030332988289683112176900913522668426137377289536793838959751008646843014106876005') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 090 +INSERT INTO num_exp_add VALUES (1,7,'-818934540071760498.60459975022373923760152136399214017262844141729040109985386964272131706381326192223266583769046276181472898406504104649192224392653722107164485675679551050629376558940966195135841284978096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 091 +INSERT INTO num_exp_sub VALUES (1,7,'818934540071930985.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +INSERT INTO num_exp_mul VALUES (1,7,'-69808760806266041400340.70700818693892852138813934414383886494691670042143650609934777814995087699409404201920249076407981012095999320858479644760715204999741683528746097757549835956359129287002171391961763797857794730120426599135099619822532290339000466211195776337667123320942107370731349851576864242697412616810236323676004067839744992733887503405311090677026008324895177587064547630828026123718296429295638934384446325302964896473296829265805737112709269803814942537657996725913938408781715328945194948010970') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +INSERT INTO num_exp_div VALUES (1,7,'-.000000000000104090609479936344103210175655521317012597986331111866307697262848964666360492361638117930801818899121383806224630563676018240181412174154250663423230239912527388431901852952893943812666142740182651125508583527237123596541789628675379232473721293630968882045044077795828674268595016625198802475186587918019739056755398151182369187670251750080227679555002307777300392769289647975058449905106584837938556260801229545589323224752038795423164214112897202147313792076165011373139219134850954217300915326944185918762838321705825423789073869940092569940135329697980600082436317664012683589681419530904283106912171330819469065141821685734295058255484933744156717782754922568796985634397878149984177882018261742637463462647452140104146195353696596211873925359508622779658904411330975862442989437933211964821') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 094 +INSERT INTO num_exp_add VALUES (1,8,'8497071467.03603749330791582407836434318377133169438097066269854720538319012928851657498035372443556191720308219530866834905045144302106406146277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +INSERT INTO num_exp_sub VALUES (1,8,'-8496900980.24523699375539429928140707116805167695126380524350074691312247557192264420150419818976723729812860582476663647913254442686555191453722107164485675679551050629376558940966195135841284978096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +INSERT INTO num_exp_mul VALUES (1,8,'724311956372274.0135050255361637906710330203036651743488213007179039756514944640108625580172737414192938789413338554327986697518463087452612658955180411327002900979574347739956600177846996063741787205122007268468674386396156638261992679442768654367111433834151087792255469957061758837789341439211010331332174981459471333376067541234901538285101103690622656631026001337239036711179989456674399137008584021283568040818388709554256523118702728176420022080138548890713013682480239784198421500241995499841675772793497485550923152267616622892846304530712344886979674416990935007952941652591352603797627920865960622077762568060903908151958000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +INSERT INTO num_exp_div VALUES (1,8,'.000010032191786198542900505683562217892317481076466949299850809276743457759270150820565375820388277409258249926696079166209409657808406245382887790534127749833677458375931047385994887406206232330491317602830654688957983804698568410728278089250379255157030886262396950539100566975000094268415749476738358914633948867977798590927055566888255636132486899287919515638902721543629183577900872078173883974905921239149419877613723476347774771230668479296621531969573505480695490386225866950545725121902534610730154727385072738079149623798073810167706094070842646222833137345669922898403368997676634709281456818189049718956207208697021706186341405575300648248555331280690778367620868775005181264547924615247991795542738868003191757946979714250339430363902549866892041102771965653407197094250270379367437342632741280710') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +INSERT INTO num_exp_add VALUES (1,9,'54948723.74225051983134098996071145685528795757427462111901537365053896571438476055974853245403475510333627298551845046116291696445177112567064282766115207407461565363967417615506303416694032848457927390574251904212425813072768882213388082765916956736282110801611726537663292922699021333445658549608928179155685881583228490235606377831724593358583903616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 099 +INSERT INTO num_exp_sub VALUES (1,9,'-54778236.95145002027881946516375418483956830283115745569981757335827825115701888818627237691936643048426179661497641859124500994829625897874508497095086558766563666622720535497438693688376602804651302002795213923698663694204683995198328880575615535181012624198813873609885725228117274934655048553507421448724831939026752650108735245933317237310133362383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 100 +INSERT INTO num_exp_mul VALUES (1,9,'4676749348240.390309875431213992853550297086049749814750492488995108783145961719774217441193547534210468967573344456866203963659951312519988497979489304488948342258375915152429008993288817366720647491166024151209542534474867042837694499222928509320280684557676243780452100132238968233413333851595648146954975713386711764268506890884764704949969602122157394714663532141060559896359465918874990769222345665160127552795532197771168442486088776803398878354288847069602460071745966589164282641033852314335279121191855487126430176047553895892632834940595958394834437871886013513058514896870683979585091413977173250824451205330441299000850618134248917380244749589254309567551846327349592529960432446947239714236828401206843011440433362544797025114476612133622499094287321570559088587999417440664282418005102546343020409520421747216') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +INSERT INTO num_exp_div VALUES (1,9,'.001553736563217204408368240901181555234014339476186598647410198373122572205209277343865051610898136462487966496673511261433286284257044548634547569923035899634327495195510767312478861719221916387940027268721306540663743713345337497285507595251328382906111997524508729275471287648008479480805967901972481289402930660848950039779707354469389216931774094174326513465502460315792834278614886136688161679443873815113442220055827192996984074129528034845339130162104547166079591654852164993577408422015514100323825529286511720963047269483211930770803479398243069649400360625259869765138545866815758888670363356947311319523139395191102286838888146829667276592755438606664644975648828848738708349790766370694194763606850690923803984129157519048493985198591771429264967247245289970213262206709011468289046840862597010969') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 102 +INSERT INTO num_exp_add VALUES (2,0,'-994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +INSERT INTO num_exp_sub VALUES (2,0,'-994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +INSERT INTO num_exp_mul VALUES (2,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +INSERT INTO num_exp_div VALUES (2,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 106 +INSERT INTO num_exp_add VALUES (2,1,'-994877526002806872754342148663997.64812998474240514147207095573950146764154822009863493316394610578375247334825932838513167168342610420582834742950389452212867974756590355021495169819086060202117180229196935525386766373096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +INSERT INTO num_exp_sub VALUES (2,1,'-994877526002806872754342148834484.43893048429492666626902822775522112238466538551783273345620682034111834572173548391979999630250058057637037929942180153828419189449146140692523818459983958943364062347264545253704196416903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +INSERT INTO num_exp_mul VALUES (2,1,'-84806738323879544552397401815149740513.8505875535743013876823142649666132764556588225959336097903898464616542203793600590311980154402068027051522932586050753865288419084437796768749509032177577451738712965496693249429231838833655025794915864261585848007162358912070811805298210095333433397862313304655108809804359760907473898420016370058274978588765092161529583480924554820756527238472641797198545539410039895140087686344382628317530286295498797849942258314364503000942821309916954725689781458590617068629906894951122301020797266469357701283289275708774593896770378558232444454118891917258610753077932026885574920166837998049508644891327208474213193224700658584824407382455480657734911543930195324144216374573825') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +INSERT INTO num_exp_div VALUES (2,1,'-11671021799770914903865020509.301561107153561058074179843542446420696517132461554451075945807420674211966679216615407057626541711186781735967334896541890595771915856783008831770988426637435694856170266346306640678577376310547806764332837625966429200996250687908930748245035578756314083608655163891041399241377675534416837659335561005203219889972336214863417948542956735403991871098341470996860469878038840964359144637726669728240650066795729910649523281308716277906908340457162235831526838308777581569974551673352306004330423694524256415657620427590352277556907586751621496248973165690360552007637570957980230685679819820147036159174977086193494572117089582758015847544798464543446227632367713941117001423437766840744488426025388612316819120660814681298624293065972395923651314350558006567251033289878238407790871784676348196394482477767774') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +INSERT INTO num_exp_add VALUES (2,2,'-1989755052005613745508684297498482.08706046903733180774109918349472259002621360561646766662015292612487081906999481230493166798592668478219872672892569606041287164205736495714018988279070019145481242576461480779090962790') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +INSERT INTO num_exp_sub VALUES (2,2,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 112 +INSERT INTO num_exp_mul VALUES (2,2,'989781291745465665243281323944996915810556285052564220274237162526.1617859904902612197894543199389468971679632139059029459520163585971122643624316475417489000981872666677202334180945949860058384424993911721081868337499377890298636260338063268639283065887210924895929155083478140340889209440025415565915964293989840603863813531303253038823629712989041722072693449251635519992922148998556112923060331794396659338057474019846675262291146025') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 113 +INSERT INTO num_exp_div VALUES (2,2,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 114 +INSERT INTO num_exp_add VALUES (2,3,'-60303024366845387174536638750234506721.2758014749274942132576365116182462208228193753118527959000939070820507877345194783035668195137119648748792386548310474079340204536236936213411512867171486174240518914767934028451971067161683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +INSERT INTO num_exp_sub VALUES (2,3,'60301034611793381560791130065937008239.1887410058901624055165373281235236307966057696953851292799409809571799686645246659986351515277852800926805119259053513475211488115663286642009614039264484259692394657121785950542874788161683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +INSERT INTO num_exp_mul VALUES (2,3,'59993133911282372667149627097418449223835595194300848703012380022306762.154418449236691515146061305380465061074531890529497774836941002526095632166401249277270674802626154774328055399254982998368191676630276960361274433270795772477146870294928855773172789856196219950097157391050424577381777627004101100872747943673762087675405200265837631665464736842180920496158545887039337399558993437594084473932658319914390365451919627956823980800124880375978662052111797881386060353490432427832058851094210488804887183034572364751639107535041308434932952695103493677600969712634416241541391613699710826602011076372592299807609658979777598672141389319098817824624950794758296679318319299142035') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +INSERT INTO num_exp_div VALUES (2,3,'.000016498242835741013709859217005931279826178662180173096568520102488480129191427472581644597420895622947234184547373944996197105916093347103336318249582032230903680989710242610024298937774441533502282949127537125997753002819456724709929935850697744632904111143787011103837624936502324835260843148595669524694347566421203164808527739207590986975750648112133699756328511947175496694080071202064255118777680958612315513441989609682655431197367166056616661045712867189326408877133865572680407329449150282415810958772293869902662884761202424695742898573841869524376684740249281181605067345203479719345061595919652192297531638467223956758315591610733251562492794891852151639643060692698365496208796638230566761231611376199140556503620471090364900792180618741355091923808605890415081571900697282725022629812561702118') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 118 +INSERT INTO num_exp_add VALUES (2,4,'-994877520673428596810678826533995.79421257464236160757218576989993781147390382997132644206786872350652200243563770552469933194637146474528320738725486418004701192337175478117026439697031462361180324038544450723753402846519731908503949116978812841497201119103409772457270340059605961197538918709309004130294868847110690336360689446090125918336908930881873778405661757289469281163974774492810850778950071063044769131228124355961427111369335109426492177657001035045332525699055300921341010989742896430768506909949340276549373661076950964959025967328861569387160956730002517417236732463510495205173523163676450203614971844583064927040066684531931069310935516821795449174271052747559395296525950219449541557191520903507653089998307641491381797101485104546410643') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 119 +INSERT INTO num_exp_sub VALUES (2,4,'-994877531332185148698005470964486.29284789439497020016891341359478477855230977564514122455228420261834881663435710678023233603955522003691551934167083188036585971868561017596992548582038556784300918537917030055337559943480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 120 +INSERT INTO num_exp_mul VALUES (2,4,'-5302078674303935968062773235453828254014583744527466365136.236414807326868572353809920518232561005161225922028750078608989965741402418802255050636954800114792425419735155504035469350521800895164087027043476055514245942961100610551646034472084954313670284875310691807937254054948742125729353864014122131419164449567115006621212424805182687707372956385102095255735458593389920872596796806885847543910224476727171570873698525606016990229936284811067826588349092841322512643043008589065847223683467371925773023109720951609815041012521485326120380123169545818055967455575736140138663815073081494226676896278654189873597341203197903408668523514375373841493189836809506003729379742035629498519683885268256481104619815130659628225053833297766479068686119691010593208135616363994230674606991733148502293102108193522604968743948323130517040609601859735899914987426089053869350663') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +INSERT INTO num_exp_div VALUES (2,4,'-186677971.517539861245390308778107722315862721823627804195528485535806132067679059453022306691281662574091826898288146790399178357754908901382135796783067563944022498807930452234032896817601590728156392188660701355670595952594500812333935362955625137944589981298793332621503315902294100258945995827423279442031218510259915311555745581797315793010762585658196457363672908315687720174516274528662385172326028870945153551774300419158584379602045442200523311437013776079979639415633358878239012925000523542907592866797199229858272764668664323316251874027468128770456766875866492004650352654523634716923150212263912760225390093339729495231675627059805624175587380165509763048913150826017167286786277908970769297060278191518730887417202276531151575412404467497036737825989088867451153485938272367300939127313445244028528055624') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +INSERT INTO num_exp_add VALUES (2,5,'-994877526002806872754342801504871.47809095279915423939648794226185974985600242391612965412218049794216637114648812993201775787765690351615479957141288239552036371132381627958673244764559862836085530643408020551049895730005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +INSERT INTO num_exp_sub VALUES (2,5,'-994877526002806872754341495993610.60896951623817756834461124123286284017021118170033801249797242818270444792350668237291391010826978126604392715751281366489250793073354867755345743514510156309395711933053460228041067059994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 124 +INSERT INTO num_exp_mul VALUES (2,5,'649411906691138274293985410502516861224852.2323455192714410716272307781034189160865613770320102043319541634113746032638191509585045862973333645830298922352816245477556264222094036953195419857712804755170632292914187367964994214922001758104594052499795564860466055599417895782179851297585155129541589802249540436678824225950907268084876110445460948679383611117263673106597132046331719468816839434908155684738864149955129235751738204036443603521478609787295079710078973503970964790273461142497259987849074597264522099648376356902360358310245001183020992360260836105404118742418040965190000718736837422434593694808973939805954329718232693154128543253581495885789333274488461716809104532693754070810202831113003978085636579574171344721710232931261731022478029314435363413498991740750878099825781577297965642009156858479681236085226911858782115') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 125 +INSERT INTO num_exp_div VALUES (2,5,'1524119409495532727030986.638577103454261465522025182901477334004986357902177024959076085490119358611626688213654669281670407680244740174673394111775678935383154847014211641601227316639834450258566053805263858706381900273201146454036688771735398324537667996974210741719621449948660517037619359095556637235980122706739013220201060795557114248610410815988952748489854367480813823114296393315170621979351958306734282429929421779129764262568942699813166237466796852578307944635545174715298176546980314973426586923195248536376403319094417073026382024413817222396402299695717290716014320518777088811749776114378145110676170242861393274018655137797545194817703831240390631723050378397773341835222892981773205967439339460305257986693600088957772328044922955990976285151896366292514128607363007421484320868718566256882080399264346243272770200676') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 126 +INSERT INTO num_exp_add VALUES (2,6,'-994877526002806872754342148749240.99659316232359475297606895243958507460511031229368344962653674268847910587702140353344168594152240599109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 127 +INSERT INTO num_exp_sub VALUES (2,6,'-994877526002806872754342148749241.09046730671373705476503023105513751542110329332278421699361618343639171319297340877148998204440427879109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 128 +INSERT INTO num_exp_mul VALUES (2,6,'-46696638263247522384986521136500.479312417066793299922708112595886608370451213741279484136907754744903470430131032928908162742687359367826808123516519335458861613010646992354378739165872253762686683966945711430182491860196341344982195078000259063231136011430995647812149294224699587849791008794261026932467933475782780') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +INSERT INTO num_exp_div VALUES (2,6,'-21195986018643887410662481595901800.342199657994285865579781485758715114242459388977583220756870314514884887803267837816669111279417861218648323488364513921592045485003563036021370174294475403630933854767386355037781881144701319212711655881277140183173924089814927297045029394618083349813549439341772734606115369911736164723942330187830605893993276674913563980890459604886172701331890746621222114280438198802989678877404376001410627722336243835841751052795437979198996482216031399073597399901975686733315751292369326904428230195579137225651689857057115970784985439417129044974524632220457594191305254649113470116960582543784928547885740020507755033347968928034294570497118410435615856155184563329718831512839630769097935523279881940380220955993456451396417879773380305142918906742431812580562496634831735169817705720949712410595406012323294829461') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 130 +INSERT INTO num_exp_add VALUES (2,7,'-994877526002807691688882220594983.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 131 +INSERT INTO num_exp_sub VALUES (2,7,'-994877526002806053819802076903499.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 132 +INSERT INTO num_exp_mul VALUES (2,7,'814739569184924399102711674444306584731316176345067.39834031417849342571224916231092924046722938910652929295271097903377854123984307101079073134405782275535446337229706620713104545454319555885847481531722101704765783025789147453570970090') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 133 +INSERT INTO num_exp_div VALUES (2,7,'1214843772391778.127361407585140553741220126410637250571020684739034685508176000812180032686291124045768750332493129822580347351032145964983629059968936201592138368806173099130176852606440296388856520582890650384142745607345709716826703676313341953999327129144154152914234659001555055379537780751567782847296067128932113870102563522810980359433259696591977617184951677390423898232135100000764121508662830515405980450892222598485287609657612482190264517684867291774820716746063133066053446257163185646067618679478975882247893469409405379034723543061767846895135644429012095930584952053545016706315299076691015196261253199176743281648949731423486208098120903720124071047872917636988241710583721537777321338769039241700203546247947405745989053846970910400831817998342969657501678430211657755864160072525313889413731419647001970593') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 134 +INSERT INTO num_exp_add VALUES (2,8,'-994877526002806872754333651763017.40289299098701084219066388457144979069028441485513418625082363021182982914675513019536443438529749838106171095037135009526312783302868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 135 +INSERT INTO num_exp_sub VALUES (2,8,'-994877526002806872754350645735464.68416747805032096555043529892327279933592919076133348036932929591304098992323968210956723360062918640113701577855434596514974380902868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +INSERT INTO num_exp_mul VALUES (2,8,'-8453460632655529853033389979024265783461224.3195241893307807116624750282852146303290708492834695194274289713076935297734670940696121761483641291930931061232942894577813178566088927221374036301485916497770984757492912292002695944367308880163698595015497307574177176409203214324418237020500352652934909632442547242092296504047310806151851207329042221920888326000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +INSERT INTO num_exp_div VALUES (2,8,'-117085929036205907700251.219065234073336548829793284434494573185718678644093751558890746941383215425734761534822966779511801033216479269605150574332107020180872343673157350081102818832254463561564431056604957702984438484261858890324442581609284935850435611342611117035589511568432559140282381526487115307554496353616929034919886387903446436924514812698404129456069856633480965357915969548215985452939172313964007318881987188665231550330515412104367728617802960792164260429920719961650164518261501571220901151359208484337831586551714193024143212288426326740373893030225940355268499071669300664200888186064836443459131985786957267268845966279576380786883200277187591448294590370986026461176853573555996139940001165172158855197070946665074838360933025833716166930231164328918316437195201546383664484983447934244744303265471044295601062898') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +INSERT INTO num_exp_add VALUES (2,9,'-994877526002806872754342093885760.69667996446358567630831677089993316481039076439881735980566785462673358516198695146576524119916430759085192883825888457383242076882081857926408611052522393579396644731758241837010163568445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +INSERT INTO num_exp_sub VALUES (2,9,'-994877526002806872754342203612721.39038050457374613143278241259478942521582284121765030681448507149813723390800786083916642678676237719134679789066681148658045087323654637787610377226547625566084597844703238942080799221554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 140 +INSERT INTO num_exp_mul VALUES (2,9,'-54582443595378013373024060492546032003692.4875677735896411267274323339692558458420972958075073392126734000341372096298914875892612108329218081214550050039133117695428196702128258481789017059073444323729583900855712795086447886053552786449313809589992185978097430132940882612817775035217244553616977182049775786664446683332098226841743818600819221587510039430478859412452506872131851471967577741190323481953867845129745440745526578327709351120432530702446916035797432129052518980799424635406993848916727957825620638983706180841278402925286540375225365057191075559133035') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 141 +INSERT INTO num_exp_div VALUES (2,9,'-18133693300409132895168796.074616314168631402221003009151140409826855230810646429042722071403306917323628118792142878282108022292754325022530103525285999179488507720688317761243448898240836430183645778132937666952111134601563043980164547020295727057908447220163534134835130866457657964382363853570827467081988390359191484798677813656413640874450449802233520570178139244957518604566383671867773821069602665918688868868894979351219381089954104823746091972754649316823714354000113723793845707472924569647945844436702275724514171940901057842455729977729388911537391920702753167125695758365521631000334183494148229356487592577177344247694925635113222720411958290166668659311154664393442690740373285505786584987609789805525300762074682544164213490532272590665630428583216403362629445153016404037983825555019274338559686335405719430737559715778') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +INSERT INTO num_exp_add VALUES (3,0,'-60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +INSERT INTO num_exp_sub VALUES (3,0,'-60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +INSERT INTO num_exp_mul VALUES (3,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 145 +INSERT INTO num_exp_div VALUES (3,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +INSERT INTO num_exp_add VALUES (3,1,'-60302029489319384367663884408085672236.83687099063256754698860828386302509843815398979402006244388708674093244201278399438376682321121138429850885935540924586964982855913223221441591310211730902799041126800414795030815514254713522692405212716783388698431088814919226444677188004928663343696636297536500970117716818423689175692808344185016908913828066250587407384563498516598672584120143890364303296142744031320345312431817858545326010704685255237541162931904446804064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +INSERT INTO num_exp_sub VALUES (3,1,'-60302029489319384367663884408085842723.62767149018508907178556555587874475318127115521321786273614780129829831438626014991843514783028586066905089122532715288580534070605779007112619958852628801540288008918482404759132944298520148080184250697297150817299173701934285646867489426483932830299434150464278537812298564822479785688909850915447762856384542090714278516461905872647123125352735037721325154184406043613668806975385533851732090363979459292404685190942209855935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 148 +INSERT INTO num_exp_mul VALUES (3,1,'-5140349743195574373979577554212527512597024.162480344833040409158673429491690439298506850052285119390701002577176786023622062742050099464897084793357329597395417632908812044304066963549928478520702505283307379218587635434673128958824348493758429380623577527186462464399974242800361134191519694694139153279582776168995426125926314513926640766117733774558011741611075336271613675760116784769700605008122422944290652448956922432960815546502965310676913079866511016221573557684245901002643719965652152439520727383305120298495304784052489867651462175349450610643411043707261107569691076730261762793560088893354750383257372118118753366377402045596735023445172252225346164608897913115394905485106225627590643805003075069931177395059698550161546962768768895596088478488887530518018212441345360153523733317120037436403475909117998647781920105313938836144009539683') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 149 +INSERT INTO num_exp_div VALUES (3,1,'-707409990019504668223608170643582.082425157530076679823177950190511141917761066423266390864536360056345386873500583953954967225431526056199231768143978526582904071798714789552447782850723926323452633811653766838064983821149041415149067433978085927687765773012158659685363079191901396502099956189371719135315616249471739677995520904113581848295732911534266040260836644379296158092198514963023001686666281725991605685524015227112003429486755206848316731257322742428352116058878710728614841247581716185886403744830796740424927494009978599974431617064012221450054532987372285996679180090592706458366967534834069977644215413076082570497451654516268857039718730203921980307096740864747006176117071983875364434497517026142488015705391255750729200497229031250705777282987863242056223584453312226818451807347197583925624299372040413470456696588043062815') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +INSERT INTO num_exp_add VALUES (3,2,'-60303024366845387174536638750234506721.2758014749274942132576365116182462208228193753118527959000939070820507877345194783035668195137119648748792386548310474079340204536236936213411512867171486174240518914767934028451971067161683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 151 +INSERT INTO num_exp_sub VALUES (3,2,'-60301034611793381560791130065937008239.1887410058901624055165373281235236307966057696953851292799409809571799686645246659986351515277852800926805119259053513475211488115663286642009614039264484259692394657121785950542874788161683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +INSERT INTO num_exp_mul VALUES (3,2,'59993133911282372667149627097418449223835595194300848703012380022306762.154418449236691515146061305380465061074531890529497774836941002526095632166401249277270674802626154774328055399254982998368191676630276960361274433270795772477146870294928855773172789856196219950097157391050424577381777627004101100872747943673762087675405200265837631665464736842180920496158545887039337399558993437594084473932658319914390365451919627956823980800124880375978662052111797881386060353490432427832058851094210488804887183034572364751639107535041308434932952695103493677600969712634416241541391613699710826602011076372592299807609658979777598672141389319098817824624950794758296679318319299142035') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 153 +INSERT INTO num_exp_div VALUES (3,2,'60612.515523995516156897729403721504966784736064970538891936016753206905080265887046037910122269129293912171105589512464185386239562077778499936203155976336284324712221812806801062157592930664021782540155687632208890794166119782594464410498356083266087045927038416810562596141871858142749062925965665039981381277808608946877852933015970874447235220989360704166270479475802673572039541121473138382812420076284458769543418652217394352637294823914346726065145538710933281768776286965107974980550163605068693568717671571780028113969794125200592691656568731359981803586296135840575095063824258761205175762907549288801963550628589530419118771779395037240198270853609924445368393952404606326559485235840170339343865253618184271158932135392539396160392488927771488269959497352568205940636180870805982484030168838833607478593') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 154 +INSERT INTO num_exp_add VALUES (3,3,'-120604058978638768735327768816171514960.4645424808176566187741738397417698516194251450072379251800348880392307563990441443022019710414972449675597505807363987554551692651900222855421126906435970433932913571889719978994845855323367077258946341408053951573026251685351209154467743141259617399607044800077950793001538324616896138171819510046467177021260834130168590102540438924579570947287892808562845032715007493401411940720339239705810106866471452994584812284665666') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +INSERT INTO num_exp_sub VALUES (3,3,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 156 +INSERT INTO num_exp_mul VALUES (3,3,'3636334760530744652235488357607657374520053530993537920755375319352615385278.023608692512217812784472508939511216316773023870624171279878340621219698109986095090336065266376220109007718694455520948311677863167090936408887147442375455695868593092154861636486745490748828207939155392396090682312136290864359484540126174821846208064763823279315343506148025281475729723686566174395516982893064510403581479746673749128344955124070957545815390178764940816628194640888255387443237798761377617383817511745005525149990207764725040109364671749403389999498572538135588695345112358160274671918953118753964073105250116426665508214894805722798842017943220605600452911496071424281587802689830031742105619630787641205011894680546049982654601956546154572720177337696285354350903475239411654436042931409507429892682706228354459580412759920815932840348933425754970917910500027837428631661182510071352138858') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 157 +INSERT INTO num_exp_div VALUES (3,3,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 158 +INSERT INTO num_exp_add VALUES (3,4,'-60302029489314054989387940744763542234.98295358053252401308872309802346144227050959966671157134780970446370197110016237152333448347415674483796371931316021552756816073493808344537122580089676304958104270609762310229182150728136567294798680824019082599362332377530165818229609055765904048195574142709698758095302560470195171027219786996322461803443213101532716728918363951912367135900414238535625075942525108530051828834829820554490477645701692374399416239080329365045332525699055300921341010989742896430768506909949340276549373661076950964959025967328861569387160956730002517417236732463510495205173523163676450203614971844583064927040066684531931069310935516821795449174271052747559395296525950219449541557191520903507653089998307641491381797101485104546410643') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 159 +INSERT INTO num_exp_sub VALUES (3,4,'-60302029489324713745939828071407972725.48158890028513260568545074171830840934891554534052635383222518357552878529888177277886748756734050012959603126757618322788700853025193884017088688974683399381224865109134889560766307825097103477790782590061456916367930139323346273315068375646692125800496305291080749834712822775973790354498408104142209966769395239768969172107040437333428573572464689550003374384624966403962290572373571842567623422963022155546431883766327294954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 160 +INSERT INTO num_exp_mul VALUES (3,4,'-321372325955692885069615337209737469749246561535004445508427591.072860243358366933071485495726715620133686420023451450292996945184959542770492705998350644739298629407567812798540119555932604687814429669592481327761428042980782672136901602006622227365754036664912989085940235439697789102358431343119457114603363936544931303133371137532006899162833369543279729021228901466728220729625107362063321334489394782322741444425117731922691457341543446841167138481424319752111748042440994701571955325673470021626946676976482516292402239416632497972073915818846704053624707839813514171497746804751780741682011937606462260710753056669269928580460921188286249923152921382198282201761171043384698319895970192114563900025573490442674225227682235790590616707857188385274186584856872573669591460447105688151281208238908470285147895678001948902280493477604361481216667716971590499226735103039') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 161 +INSERT INTO num_exp_div VALUES (3,4,'-11315021446594.877643290091276308982961654569173523687151347727612592478433578066762912541361898899908505997444632820107356713116459078630334224890355872486337973552333755378190316811715776951317058334754704988120078733912131691682869448731717816749620336196719541702138949084375907248656748314375183301372633028246109596775255074617515860012417935744433243071057057560464360663978361945666099558526069794464437818864063206829678640156992474597480916575712563493776637239091589972373682399519931569163592317107392231951775499293572134702843085474656152913351183535194499521618027894129537558509428098859715020703897463518891082573242502356303078754574312965093639182648263511466558336912294702019648266054331227425119096294871153811412169351624751542166779635702042223762951850816568617453355571302500885410532963789364822647') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 162 +INSERT INTO num_exp_add VALUES (3,5,'-60302029489319384367663884408738513110.66683195868931664491302527038538338065260819361151478340212147889934633981101279593065290940544218360883531149731823374304151252289014494378769385157204705433009477214625880056478643611622410268943757215673170753460135411513114716313801477916713433956086133878890802448531292334570886746283905390661877220497842493537338035961123751393889400517474762491881277080205381424363695095196058838349029211365212855028824622924678684631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 163 +INSERT INTO num_exp_sub VALUES (3,5,'-60302029489319384367663884407433001849.79771052212833997386114856935638647096681695139572314177791340913988441658803134837154906163605506135872443908341816501241365674229987734175441883907154998906319658504271319733469814941611260503645706198407368762270127105340397375230875953495882740039984314121888705481484090911598074635434289709802794549714765847764347865064280637851906308955404165593747173246944693509650424312007333558709071857299501674917023499921977975368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +INSERT INTO num_exp_mul VALUES (3,5,'39362489275784146262776411377472433635883331946.794473520543457442955620133347015506556162839462623905489255080102447195050109095701660164272430316804466254467810714209179752718730906325952685817112992943656292503112803950215110778476301809440329937774061163668461957943313261962261081942055908935814323069621279128270849852239727888939033546870208376394878842958202403235309372240005941467570230067124830916866857395233038346727879951123599893174252558078732888910139309038957525961212820831321973219557165558911222848692996406741318948607549825343491479728117062814094258484536263158005174429922237853707635743736923521032098496725445243775790161216159399180889906705265012270270348146530113428221072591696851818281866095288773371414866822270689959827332258348570976075184933893434327278299820594014788148344260948638847457822697682605612771344335201258128') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 165 +INSERT INTO num_exp_div VALUES (3,5,'92380711368470856513514428781.033155715252174277753317877861994356621252232374386687048394529670637693505779282500567256835271428113529026462111032257747830329068594622091282098767000694818101994264352932243278144124687156236926607422077479412495979777588932692081795130282128890441931602671468684153168580234070246201722180460130467506344034452687371838907269162119534950946217165384250603250357360223255177692065141037447374172264943732616165429783010079281851748804739433821308362193703012671569249508710820679009084891198169587484117171861141580870066764275087111843275285564262902405980617569581840831518012986031156042600391943605532635833608358301306456966765206853910579231447150839538731157206153540873916893579943906851149770881336811951119112558311734171557608362620988555075663589827484854016702489324791126228380209309587206299') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 166 +INSERT INTO num_exp_add VALUES (3,6,'-60302029489319384367663884408085757480.1853341682137571584926062805631087054017160819890685789064777236456590745415460695320768374693076860837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 167 +INSERT INTO num_exp_sub VALUES (3,6,'-60302029489319384367663884408085757480.2792083126038994602815675591786611462177090630181693462735571643935716818574980747701251335721895588837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +INSERT INTO num_exp_mul VALUES (3,6,'-2830400711649493468815157129316992649.40542786074520931471973065281957756940496588853021620372179463538053123396140685749478530925306163968207226329985017644835203709485594362663495728106061878665324856417118064730721101615473194292620972173690618491026470353143141125614124440035267592258385099934706896692953497971326605145704135723011753705907329979207428661473172503098296622281647255008204864404416199384701720347319806375450632245634238172654086373193251877533131784268854289406126119630708578053354762596511353053106459297339360827562281168219966099848212') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 169 +INSERT INTO num_exp_div VALUES (3,6,'-1284742031601444539630782308463065726620.121021225455596762466053504195700643301310745151565435123335541550963124666304408503436412726848834604336377169205828654564329888653766451656774534718709065521243637375270687684572524302099749018591530352756390467862377335526634920857924031482455373589053524922608255779040656019538392173139295812160325688504210040741075388404155144782519528791757450256668977268409265390016721724966592135644698341754332845002439113523127047593325646484654291494607100188094186116001064043796216982681807318598789324900462932294782971663150070521334398542559480877366424630693734132836518604260869235580641521264976411493166969530737254118968281271908306432918913600567757535151861421384835424322504855607676315840963696944683182767935565256136130185809101891760917733694553800748568697830680328155128016670099315391685422333') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 170 +INSERT INTO num_exp_add VALUES (3,7,'-60302029489319384368482818948157603222.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 171 +INSERT INTO num_exp_sub VALUES (3,7,'-60302029489319384366844949868013911738.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 172 +INSERT INTO num_exp_mul VALUES (3,7,'49383414785234649002982046297226894664526726187218771083.0993243619030008310875293647868815940421844461627295157812843657782639833900543200310573708100000958929315945039020410482966753145208427035917753919085618457760620513481628641658765820294863970581642745379331727722585319163262763708386199720411053619449096019862596221607526610103408936214184850115071874430846697061554769773328338028749631552202705583855831155461651414320570061181212214810086436100771547030013079997847086') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +INSERT INTO num_exp_div VALUES (3,7,'73634737013325927185.787791148221519354461791539553527545166847382784629235192342551464898036004011575416717008403527685470842765455409054592207142526523023201841973047779202013398235864494503216973882479116841765663948294836180515686647139678530220909072497288527276378202532400736141014848907023234659020093073127450778982904578906877634654521825977382116752537063128793631412296206704078569268566614023846282524151679028060869175439188773864994186109445961525301841201265289707928211114515861536069733921800160245586536759625418951427346236213019358749196674633237197452976517130405065120577692737021174118093373953642724512531935525024447977867020930500433287279183436509990047372809400167546185096048971157700858970777301410692908939206693154161335335755844997198191427289546263182822280127912118140820265025555165337881999926') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 174 +INSERT INTO num_exp_add VALUES (3,8,'-60302029489319384367663884399588771256.5916339968771732477072012126949734214868901845505193155307646111690097978112797961939995859130827784737422228762767014427842766445950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 175 +INSERT INTO num_exp_sub VALUES (3,8,'-60302029489319384367663884416582743703.8729084839404833710669726270467964301325349604567186096492702768702209585877643481082023851284144664938175277044596973126708926205950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 176 +INSERT INTO num_exp_mul VALUES (3,8,'-512385513828318260570283740065493064477880918352.732624553690077857674083796435724202494963885926573907185100543184828131859183999195040110586155435203949963570735841632689374488877298209082579317039061893012560130258753218955057387206477423088065663401594359617882154814262843273526859406265633827109554791772242178864873774889091687515990672487380368975556580539271333144212685871370972163560839446696514092637412587953506052848750866803569213269271165856310101244342151576488190595936869490659700946174362872797854591188391982770203203644172999264143929484089237665313698600170041324566984832357000400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 177 +INSERT INTO num_exp_div VALUES (3,8,'-7096872691348467943606706217.907270287823269424282176534343841939501231816905820949045946136373255017076943323578903040918266385724756894003692978391468202345397178445216069294845721607024056189567609414049207292919519881725733381453217071918292453682942046440563446278374996563501512335133749731529362537349288419883140401056747081065947774593869673146309163791076953204291951821124894409171722911526435445719071769008713367057971351892550570642991097981458696464929009464411568672010548002196406312721789582428747564855324072212842315229302959908665089850886951261233852165624100634055045684536311382452553544676139507899503993644452161529145849579200003677255968757773363970434791501820320494192909660871475590637419913907191608957830524390049664686282439567943053924245852983990958276537000732363895444894582579142752920882750130052682') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 178 +INSERT INTO num_exp_add VALUES (3,9,'-60302029489319384367663884408030893999.8854209703537480818248540990234567956069965340942024890856088355839135538265116174644003927269495876835324407641642359213535695803871472434650475144516723617632059130297610134243891145006222068960999879308472500422640481972089756410157246974765071949782242392661524488959954348903412713930092273629207697480131360047867213863018127928853922173643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 179 +INSERT INTO num_exp_sub VALUES (3,9,'-60302029489319384367663884408140620960.5791215104639085369493197407183130560124286109130354360944260524553172025725325268378015783145476572840273098165721628341015996848028750420770651761919246816300854441592109844750954710317145008297946462099581451150385769713261452744310496166494545449824802407416426304041583975713483424241727236417259479541129474082301376239522310995725648773643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 180 +INSERT INTO num_exp_mul VALUES (3,9,'-3308379209762459471107480259839508279070920437.883503980178028214343751083865562028455061662673132221930429904398963590401793045470444301883103141901787466923883803951815572606105617157736442670792467625964359169270739534412932791178258858918086886061702512427989129732248215348301444245772127142869263635282888226326427510486246184233225114523636171202034558843515894542952126988613018789833835507734620046994907453602573865012044120483116345444810078666601100257620969379968264504287700045822481492526688635364586344704730579892342786173395802035361824932075736340405960099542224953439044947229246847140957298841482874444906129049023002897135347878048572628834749795298712449864571996898774444932083319581439741625832405434317985988163261591679157437224404970927012111196724239860528859217322132733404472897289') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 181 +INSERT INTO num_exp_div VALUES (3,9,'-1099128766678422054524173986658.839339966689456265703816212189145237878729886466041806078542573981227645802109969871638687985985845489422516004202630099080709709893022100481258818112345013009059633421290241583864468453396484606925071369550998772875840640325758308835852391176503689677263605949075815552026731067384737231681068134099746550363063940273625924224721503126912810251607546172009765059506591787282558727077669973711491157840340631805422942099954647016059576777054339588421998882440726473698513560202030309804089250300097589174314677765341104767702983421063649104691583044460507666600260994707192787133590502137391691330098102374713996115782701417107878938473243874299874872852713499024851414757892169376458916467621226859152075901273014182163212783658933754507272478777304254191033562324994395916168496097385872331012258027431094381') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 182 +INSERT INTO num_exp_add VALUES (4,0,'5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 183 +INSERT INTO num_exp_sub VALUES (4,0,'5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 184 +INSERT INTO num_exp_mul VALUES (4,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 185 +INSERT INTO num_exp_div VALUES (4,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +INSERT INTO num_exp_add VALUES (4,1,'5329378275943663322300488.64471790965256505869684245785528331091076155554650629138833809683459634328609777839510066435612911583108717191216693735823717997111970662575497378762952496582183738308720094529950793570383580785385569873278068217936841324404119828637880370718028782103860007754579779716996004352284614661690063919125301052941328989181561787543541920734755989452320799185700078241880935083616978140555713297241612718277766918005268951861880490889884082730841740604517529391011862694381726143520658746305661338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +INSERT INTO num_exp_sub VALUES (4,1,'5329378275943663322130001.85391741010004353389988518583956365616764439012730849109607738227723047091262162286043233973705463946054514004224903034208166782419414876904468730122054597840936856190652484801633363526576955397606531892764306099068756437389060626447578949162759295501062154826802212022414257953494004665588557188694447110384853149054690655645134564686305448219729651828678220200218922790293483596988037990835533058983562863141746692824117439019450865871047657552800448629502344444081260036580660700595591338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +INSERT INTO num_exp_mul VALUES (4,1,'454294299613767152878025320780.534199313974295807138790763501115780294529340799108297697573066187975311338382917022391830256203305238757334106943821060545424417350991354829668286194840925251162479496893943917530660694097932059166013476064988623431110002057735318529554555260199417935495388243829261809007709919225000608711536928171687251088217591210419208480251102484043683131687013687838713055660405381318396419588727500715930145098362997142075433472039319292466570912777345841400769387321465602989947078951135489852486382469990409873227894248208197179481868230244584527040573428134962626267135732247029762468417273891700661832893497067151409134724061246612631376075173287264787886064622106855886785805818642123776489793586531950438285720668411465570116161790343538663297713926678759640594912243360541590368666922379919514826022141331900181') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +INSERT INTO num_exp_div VALUES (4,1,'62519544780217042176.800424689664850775296526267109332647921183817056683200043718160298562843864918741523494444361916531159341418970534833628106062976341639276761669219281771109561175175033739624472497927501467465456946098280878993371659461957361369508794842102784763955539708800574418468150309301129490186416766691183270872711413796386178009615777589066235359283212636467980113350635181915492452697347977967985810294150853782607014649150457138118264698071689065469752702524632313088938504181640435324554007553994564705401249228914199354821595855823113730697333390936834057091883654016371107974899726642500486005445063301647520527084320363513388355471718583708935211830796440056542408492723718088396437530207347815505844074508948817594746824098278470533148171941442049323578854023683167934569551595335539887777638716651319134577441') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +INSERT INTO num_exp_add VALUES (4,2,'-994877520673428596810678826533995.79421257464236160757218576989993781147390382997132644206786872350652200243563770552469933194637146474528320738725486418004701192337175478117026439697031462361180324038544450723753402846519731908503949116978812841497201119103409772457270340059605961197538918709309004130294868847110690336360689446090125918336908930881873778405661757289469281163974774492810850778950071063044769131228124355961427111369335109426492177657001035045332525699055300921341010989742896430768506909949340276549373661076950964959025967328861569387160956730002517417236732463510495205173523163676450203614971844583064927040066684531931069310935516821795449174271052747559395296525950219449541557191520903507653089998307641491381797101485104546410643') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +INSERT INTO num_exp_sub VALUES (4,2,'994877531332185148698005470964486.29284789439497020016891341359478477855230977564514122455228420261834881663435710678023233603955522003691551934167083188036585971868561017596992548582038556784300918537917030055337559943480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 192 +INSERT INTO num_exp_mul VALUES (4,2,'-5302078674303935968062773235453828254014583744527466365136.236414807326868572353809920518232561005161225922028750078608989965741402418802255050636954800114792425419735155504035469350521800895164087027043476055514245942961100610551646034472084954313670284875310691807937254054948742125729353864014122131419164449567115006621212424805182687707372956385102095255735458593389920872596796806885847543910224476727171570873698525606016990229936284811067826588349092841322512643043008589065847223683467371925773023109720951609815041012521485326120380123169545818055967455575736140138663815073081494226676896278654189873597341203197903408668523514375373841493189836809506003729379742035629498519683885268256481104619815130659628225053833297766479068686119691010593208135616363994230674606991733148502293102108193522604968743948323130517040609601859735899914987426089053869350663') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 193 +INSERT INTO num_exp_div VALUES (4,2,'-.000000005356818439105666775800262590702859770599410113087721172791624002387236505438218124867814437523686300450045582100868990117124343222534568799037421944272316277130975314766456260710406160143182498931595199129228915695802952695510723443157825968340043198200740606202264287904755124946591110599335909404657109057432686191440989434662797205973563889238804413861126260401987949920244286377128599413927273444061572120561496904543200956508673923547626768641271397088562966176629018606103663605145666976048261236691866387601532424530473754175270500777679603569715192364542901360534980926452487443629100484491344001509360344122933911316486556042277769848194790964257060927912344609376571637126617813506411190014141992988288983968823792971270853369317867326071952900448455162898476163801382836761898292684175721846') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 194 +INSERT INTO num_exp_add VALUES (4,3,'-60302029489314054989387940744763542234.98295358053252401308872309802346144227050959966671157134780970446370197110016237152333448347415674483796371931316021552756816073493808344537122580089676304958104270609762310229182150728136567294798680824019082599362332377530165818229609055765904048195574142709698758095302560470195171027219786996322461803443213101532716728918363951912367135900414238535625075942525108530051828834829820554490477645701692374399416239080329365045332525699055300921341010989742896430768506909949340276549373661076950964959025967328861569387160956730002517417236732463510495205173523163676450203614971844583064927040066684531931069310935516821795449174271052747559395296525950219449541557191520903507653089998307641491381797101485104546410643') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 195 +INSERT INTO num_exp_sub VALUES (4,3,'60302029489324713745939828071407972725.48158890028513260568545074171830840934891554534052635383222518357552878529888177277886748756734050012959603126757618322788700853025193884017088688974683399381224865109134889560766307825097103477790782590061456916367930139323346273315068375646692125800496305291080749834712822775973790354498408104142209966769395239768969172107040437333428573572464689550003374384624966403962290572373571842567623422963022155546431883766327294954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +INSERT INTO num_exp_mul VALUES (4,3,'-321372325955692885069615337209737469749246561535004445508427591.072860243358366933071485495726715620133686420023451450292996945184959542770492705998350644739298629407567812798540119555932604687814429669592481327761428042980782672136901602006622227365754036664912989085940235439697789102358431343119457114603363936544931303133371137532006899162833369543279729021228901466728220729625107362063321334489394782322741444425117731922691457341543446841167138481424319752111748042440994701571955325673470021626946676976482516292402239416632497972073915818846704053624707839813514171497746804751780741682011937606462260710753056669269928580460921188286249923152921382198282201761171043384698319895970192114563900025573490442674225227682235790590616707857188385274186584856872573669591460447105688151281208238908470285147895678001948902280493477604361481216667716971590499226735103039') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 197 +INSERT INTO num_exp_div VALUES (4,3,'-.000000000000088378091435340426596348183959201660680284222502095357746364378698792730669202270228092348823133529449019715406417264278615046537007844589547485282959556860316942508808911542109265489435572674031608663747132688980867386885961271358592278360097086532747883342438036287136994589308551796702164612609710942175900921197001888540314760352113821737014875886635147123114456910985089625906448913621495025509697742196814421833448856595853403450682101743559369637786458968714240975228615283970739279506239628546165569688434254286341567486905374255702980370754235630955328837646999003123103831262789115646588779721625156078607919060762857866951417867378220773543985422722165221371084387943737083254760594128718841665355053236168688218864433967871311858292181233490194833547273501436630325295640020916257836404') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 198 +INSERT INTO num_exp_add VALUES (4,4,'10658756551887326644430490.49863531975260859259672764369484696707840594567381478248441547911182681419871940125553300409318375529163231195441596770031884779531385539479966108885007094423120594499372579331584157096960536182992101766042374317005597761793180455085459319880788077604922162581381991739410262305778619327278621107819748163326182138236252443188676485421061437672050451014378298442099857873910461737543751288077145777261329781147015644685997929909334948601889398157317978020514207138462986180101319446901252677846098070081948065342276861225678086539994965165526535072979009589652953672647099592770056310833870145919866630936137861378128966356409101651457894504881209406948099561100916885616958192984693820003384717017236405797029790907178714') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 199 +INSERT INTO num_exp_sub VALUES (4,4,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 200 +INSERT INTO num_exp_mul VALUES (4,4,'28402272808100253242547006276715304015308580784958.804614276533085644370816876160290159450291717634111299841065255625515058118012211808741402904995080624675460593676923639082981788732031193774047612589113654423166826140872334380708795266307037944059108148612979119729408762532396036043629484049508789880964586236575769826806092391573178899640321403656891487586452524427223891405519836671312830183895761747460911777623703557946796784873885800089025388390522992806365773290733075927321101736155663727528284512100509273076328103465333687228713897893434161293693971954442699482857938492961830350598789444266860160794913830991304996676299650460125000959751177037694425217989910261807246272771711816326991282202653917488360776928533800529297474279497910326579608191975246060946079639658615178160271122713225105861574160788280907842327681375920919676063500116492292319') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 201 +INSERT INTO num_exp_div VALUES (4,4,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +INSERT INTO num_exp_add VALUES (4,5,'5329378275943662669459614.81475694159581596077242547133292502869630735172901157043010370467618244548786897684821457816189831652076071977025794948484549600736179389638319303817478693948215387894509009504287664213474693208847025374388286162907794727810231557001266897729978691844410171412189947386181530441402903608214502713480332746271552746231631136145916685939539173054989927058122097304419584979598595477177513004218594211597809300517607260841648610322863666300637648662611916496850248528515936635845594390453288113296413254893687029540384176335735114863908372780241463999450547422213639667099644505472777149095004849805371205203850993689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 203 +INSERT INTO num_exp_sub VALUES (4,5,'5329378275943663974970875.68387837815679263182430217236192193838209859394480321205431177443564436871085042440731842593128543877087159218415801821547335178795206149841646805067528400474905206604863569827296492883485842974145076391654088154097803033982948898084192422150809385760511991169192044353228731864375715719064118394339415417054629392004621307042759799481522264617060523956256201137680272894311866260366238283858551565663520480629408383844349319586471282301251749494706061523663958609947049544255725056447964564549684815188261035801892684889942971676086592385285071073528462167439314005547455087297279161738865296114495425732286867689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 204 +INSERT INTO num_exp_mul VALUES (4,5,'-3478781676337858247983014311182511.567538638808357215203593479841446379226774481291286361639429856698999485760647422501864626078375852610019829111004807806660731243672830787729048847342063218718651165150612717759770504648306347926061960607388621011846314969634048226452709389995594961695723139571002939804473057725442880410434039783304583526414509590532906062732322732569475349107437896717416548237633532805602064623969799081086996320156575550896200848758685986331692388099427314008504506503745527468550106879602399030419569897808150076298414568875477195447656904373310322813412927463518325927626891046356679526447117311923853482118502868148386882363449163182892615259995945992014431502761210899772725227648729095696228388558331052524469604046072203605897109629560683446827492904111565278516043939137760721315953500281379039771826554155511347152') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 205 +INSERT INTO num_exp_div VALUES (4,5,'-8164430956184510.184223536017248184022252663660196916321116266103608317725855237211273642694947892658721606226082017525816544904635887836163201565923338826779819876742736219975639586566502584026349778499211535661173597356253186281116862244165796632756909578140184577853088376334255860281874385669242675881761388233070861374295536603371778669602656670852115614651462552069294889723058758969660566508798011830996965570446030123780674316363670374970480994905368006454513642480180066435609577311074332150098288374616437489163254821095377348025470309665651059603665062887597814064136313866690824972464351274062540825405003954064175728198182815347642172934453828192850870808373638597839434504241236228591053696481146252072190903430582534862988719805163692697482513169856291048966811374872266165034373412719593685881972700171726777938') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 206 +INSERT INTO num_exp_add VALUES (4,6,'5329378275943663322215245.29625473207137544719284446115519970394719946335145777492574745992986971075733570324679065009803281404581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 207 +INSERT INTO num_exp_sub VALUES (4,6,'5329378275943663322215245.20238058768123314540388318253964726313120648232235700755866801918195710344138369800874235399515094124581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 208 +INSERT INTO num_exp_mul VALUES (4,6,'250145412892811547138949.592621291590152419206270097656346630226508074074623894951308487425470437268130465956063593951784820669318897182831355375451719125809800516979013437732298382708070979871283132689492336823087794373113039154669229889503700598930220858275174342776478898670277868700384853696009897221747924643343353942154528501454689084608965009561564638167714973711022212547096732831847202912862290958304510651828842182545311077713664465815992616213663619529378061133917572474298028065850515876361609671565914027186063801852554353160801534696062207299890867876199323530337336273950892723090754719547285920090419070001019943385293110663922226230169381423410428577990604776655422105400452217085311617728003688836185608912367677734364834577573255789160419371322775733777518997638403409000055707558465286469808848200141192627396502735') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 209 +INSERT INTO num_exp_div VALUES (4,6,'113543048739697485358574290.758354267447744932153707340542459183720907885610125346262898114677742971240785031722334497858930434531517077525413654346644836353208132641713415396062580605566225794048569430676355036264762949452090151450855446984773994337170590068740235544320694721909983307239491151139099779296496785240814600627140543144068640768857707110930453204162312973998304574796413938461971472337040811785231390930046688391955000749644938061585377150632133417156866197053052425576957646564943278156977176976876921235395711611898108821587442609611001702344783440618040704066809035404237786023075676374788819144406909313755996914145273176359246052899650387182222905558751208368173052381982668563471143298720677965028880626152749773712037769548408324298835212547215352657271696665387200792785056233953536347605130973626194099064678842085') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 210 +INSERT INTO num_exp_add VALUES (4,7,'5329377457009123250369503.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 211 +INSERT INTO num_exp_sub VALUES (4,7,'5329379094878203394060987.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 212 +INSERT INTO num_exp_mul VALUES (4,7,'-4364411947278810125327066890819882483326918.05664098958260550284395870948992407314161088028674246708928421994893923699743452802989464864039994566042797942433140378990308345483670828497915478397481687305406460330009319949623844175096007381662809083363069100235985794575399268709260901964834244796150883807308976949196661411035264619638771824190014274817662519438658481432363824187693821267613212631153175155634316128036152465184903927860719447693468054624663668062006049759837326188252927823612718163916100588143128358998656306593393889422386501730237442526450419990376323903182669190482615734972147533221144682538647497701130447816148459762464395194383090936159579764712919396391813914821973715879062992249315474841639591907249142779103650773383644785606333916967894') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 213 +INSERT INTO num_exp_div VALUES (4,7,'-6507697.520580964829176145824902679560705744817573189143227837387224410616222039115571544850095278317993922427931439719549137387753697989249394347047436951117850128104928719365703899136632100669607126357491484781141296021264049762417528697619931558728863308905257358126654378784709213859234056696519305650316810797382293500878834933984458810656133463638442959750083607649924453935287420620424368291770694630751828333903156364366745210911640207075765008558904788350844410055253643515389003711759818446776538393914018427075074171758415188027562645239606914126802490579848138218395145734902830046359100742374008993296019987093605275289913663224324033923096998194326249508491872193747944673057257521552387923218450155737056841633810711295424578984452176016198348344913655301417872189073133147510027427530833694019910340299') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 214 +INSERT INTO num_exp_add VALUES (4,8,'5329378275943671819201468.88995490340795935797824952902333498786202536079000703830146057240651898748760197658486790165425772165585380839129948178510273188565692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 215 +INSERT INTO num_exp_sub VALUES (4,8,'5329378275943654825229021.60868041634464923461847811467151197921638058488380774418295490670530782671111742467066510243892603363577850356311648591521611590965692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +INSERT INTO num_exp_mul VALUES (4,8,'45283653791262997781451381354094822.762732909505051438036873220502792213670540454778361182993875916509061144859281577740137081988678361247725064336120451090222456518107029158304937620179032477664627949959143233370320432203497828243297406462513350790251761540074946469824444452248386782451723637769289822576372357189700319768797708375563651655860093365309717823602754924352327588945034832436331911584742966378275504545736896430718939807674966738116698454215555860047859161126694019895490767779791933882712567492115664113775047192011252893773389940988533801360010782816196288710063568554147458866942816721046004257953642508395867837127678980002737669139369781058046396738606563716339660654364541530532834806205571191828994250708412638796240377704994928921528330863683630622922959130920715261879547446054261914770022377059156125037157979236658010950') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 217 +INSERT INTO num_exp_div VALUES (4,8,'627208063620965.397582272040628872773601055303353339700043792111288801181637510303989399395425313995651311362368773096988861977687484912995632130587762386590996099363383976320342247076516604162469063709298438133327434461462906199160715395064249299615054970359309619951777972710299484596875999967582794277241285253106817446259313281064844416249524876385699646393555435017820686376877981018047574348711991428666249794623006175739581915209218834701034964043360823844816042368184094857692062884223864639972005010863342567608351008172649209459933114800143792514183138995700133608613158857147417653998048890116531052767737435620558349226865105888201598712435680481803901906613772821370519525404423549161696526405320391828194356063547089626322474164332505209233143121068245585662919687001395119229263995765376465304715643388771609446') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 218 +INSERT INTO num_exp_add VALUES (4,9,'5329378275943663377078725.59616792993138452386059664269485161374191901124632386474661634799161523147237015531446709484039091244606359050341194730653343894986479159670583937529516163204904273806158788218327396375034882788180783796976731912141525319602448709213495905899041406302673881364465504945113279286939663215197485367850132991968081639290297033476859158044889351836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 219 +INSERT INTO num_exp_sub VALUES (4,9,'5329378275943663267351764.90246738982122406873613100099999535333648693442749091773779913112021158272634924594106590925279284284556872145100402039378540884544906379809382171355490931218216320693213791113256760721925653394811317969065642404864072442190731745871963413981746671302248281216916486794296983018838956112081135739969615171358100498945955409711817327376172085836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 220 +INSERT INTO num_exp_mul VALUES (4,9,'292388240303165948041827159734686.255558469787242316676287235194652580157149226950109397295920730296960145548003120827363226435916209781396711693581454960342091452830648929118261388933297036933167543189308061917640517578583521401267417187854611829815212778183983326568586118831109538377828156118900313778053576483381085207892754728937946691892849474364477434665960112125254104966566712906532318984871145605839506991591027939136026602051635433295687547552796828217859648186757719639965988287173297286034098497871707197092627676226053609131138590878743560287292934815277894463305001278326023708395571840850120055316276256138004565442099731931051413153564744766098053176049414330146267604802971221161572130161432525297614616942172815141372973870720928125699420370428856022295499447755488148545048400795053604349570217878099721865670458104653570360') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 221 +INSERT INTO num_exp_div VALUES (4,9,'97138902640718538.241246716463110895614166618530828908023040947887095196830690221211560526562522274118188963051412359798837957512805692731972838989047910709158995922699598619854907969493232150042212406549916252602794415099066259707018021422154933830674786488990033885447289593742424717170197810316367637885248684134204152352748803532396210051700193575105804898183523770153431536054848843504020390623875664696278263569145547515663340450903772852615789980257449146000410036925975898331113013857953289990299253584950458042598491897496393582249411290555264437893099880371008957017323366523688894303458743415715114628052487518110654201696604914159777300997374156315186315524817636714210119873791848535246674326877611945112249137224923201544452904111118569299934059002046318394345055859769572070097973298522564724884895879226870720839') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 222 +INSERT INTO num_exp_add VALUES (5,0,'-652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 223 +INSERT INTO num_exp_sub VALUES (5,0,'-652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 224 +INSERT INTO num_exp_mul VALUES (5,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 225 +INSERT INTO num_exp_div VALUES (5,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 226 +INSERT INTO num_exp_add VALUES (5,1,'-652670387.03916046850422757312745971450663862747133703839829692066597367760104802542475264601221776157515632293978442027199108085723617181683235487266149426304575903892721468296143475297345699313102262188759506518376019936160961709578829069446312051432780603656651983414612264636232727512091101057374054475214114364113300402823059519499217878746766275164739724770556122895799337810694888119810524986616938847385753562624139431982468828696587199570410008890188532132652095915565323400735066310142303225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 227 +INSERT INTO num_exp_sub VALUES (5,1,'-652840873.82996096805674909792441698652235828221445420381749472095823439215841389779822880154688608619423079931032645214190898787339168396375791272937178074945473802633968350414211085025663129356908887576538544498889782055029046596593888271636613472988050090259449836342389832330814473910881711053475561205644968306669776242949930651397625234795216816397330872127577980937461350104018382663378200293023018506679957617487661691020231880567020416430204091941905612894161614165865789507675064355852373225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 228 +INSERT INTO num_exp_mul VALUES (5,1,'-55643106304872.575994253221940844841058071061962511162776681458310912066379595519265546225338405882027547140476045378015935579066580347282075024392379464189067155567624835346798806677988850250198082355055954078446421075165109896091047534711081616362392995575466807084807876544560268050611445006601394735810211678919646667455478469014906335433468365011768049600750224822391684377238242162320161552720449713229523135506671063115436813348612986916614320012995541575293478341408982118538094438068036422562665160411591652618670802973618768526197813319204816293073794413317669922144705633308090832805914096147659820167569140291210526520361556881576175809360614782817717579318298657744021133210954279487777567785280633309576696708168342539425395482429923273623865667723482418178781573723597156804085501875735112311466228778929147929') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 229 +INSERT INTO num_exp_div VALUES (5,1,'-7657.550797567691019915353529993301413746369700087741672762343206271266232635965032053368224472333368713006346867984576168784127503674579531243603836945595880917241997606783133673324236134063757452734295148763280059050480246827193380861494669624151921824660313516974440913733511526807313019192263170823268678149435664224184903925632177789052038092611394447709922076676981043877747276056677801802695466205531230350209787298926245402046182150996849906836743231861317120171583577624262765589605263477198809166390259128339127005924586833372241946051704497188891325715185091060185547236923494393813210904033520844572880475265306843414506359253445517738473745552980984097762509546161690823646176501838559393690565709795724159196133663168004773260451322595899506776323262195323943138344537866088159583331807728944620284996') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 230 +INSERT INTO num_exp_add VALUES (5,2,'-994877526002806872754342801504871.47809095279915423939648794226185974985600242391612965412218049794216637114648812993201775787765690351615479957141288239552036371132381627958673244764559862836085530643408020551049895730005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 231 +INSERT INTO num_exp_sub VALUES (5,2,'994877526002806872754341495993610.60896951623817756834461124123286284017021118170033801249797242818270444792350668237291391010826978126604392715751281366489250793073354867755345743514510156309395711933053460228041067059994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 232 +INSERT INTO num_exp_mul VALUES (5,2,'649411906691138274293985410502516861224852.2323455192714410716272307781034189160865613770320102043319541634113746032638191509585045862973333645830298922352816245477556264222094036953195419857712804755170632292914187367964994214922001758104594052499795564860466055599417895782179851297585155129541589802249540436678824225950907268084876110445460948679383611117263673106597132046331719468816839434908155684738864149955129235751738204036443603521478609787295079710078973503970964790273461142497259987849074597264522099648376356902360358310245001183020992360260836105404118742418040965190000718736837422434593694808973939805954329718232693154128543253581495885789333274488461716809104532693754070810202831113003978085636579574171344721710232931261731022478029314435363413498991740750878099825781577297965642009156858479681236085226911858782115') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 233 +INSERT INTO num_exp_div VALUES (5,2,'.000000000000000000000000656116570506105776235076334177868550033347254561166417969910286926369599900073757929714260350320362090452092025380232792749476245042480546813848702351830607516880397305138543526307608094143028291193163613755680419049060162928958489964834941920423432354996040147818253087783193280640282263490705632002572757216731766513434035163528102590524432221718194164133959630768718395847710529339782880381264265894322494716854757290930538739000043383104085867828258790010654331660516512156519838978751447311068903958136482041673109857552178367614498426226323001399275980281507353231821022591045797658991388304873240910526149138339658220844723880158150606035181559877351791752701872877147074033569061408920725522180134133183999181370354585872214368766629114773129541658653693832843354053701079334077') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 234 +INSERT INTO num_exp_add VALUES (5,3,'-60302029489319384367663884408738513110.66683195868931664491302527038538338065260819361151478340212147889934633981101279593065290940544218360883531149731823374304151252289014494378769385157204705433009477214625880056478643611622410268943757215673170753460135411513114716313801477916713433956086133878890802448531292334570886746283905390661877220497842493537338035961123751393889400517474762491881277080205381424363695095196058838349029211365212855028824622924678684631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 235 +INSERT INTO num_exp_sub VALUES (5,3,'60302029489319384367663884407433001849.79771052212833997386114856935638647096681695139572314177791340913988441658803134837154906163605506135872443908341816501241365674229987734175441883907154998906319658504271319733469814941611260503645706198407368762270127105340397375230875953495882740039984314121888705481484090911598074635434289709802794549714765847764347865064280637851906308955404165593747173246944693509650424312007333558709071857299501674917023499921977975368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 236 +INSERT INTO num_exp_mul VALUES (5,3,'39362489275784146262776411377472433635883331946.794473520543457442955620133347015506556162839462623905489255080102447195050109095701660164272430316804466254467810714209179752718730906325952685817112992943656292503112803950215110778476301809440329937774061163668461957943313261962261081942055908935814323069621279128270849852239727888939033546870208376394878842958202403235309372240005941467570230067124830916866857395233038346727879951123599893174252558078732888910139309038957525961212820831321973219557165558911222848692996406741318948607549825343491479728117062814094258484536263158005174429922237853707635743736923521032098496725445243775790161216159399180889906705265012270270348146530113428221072591696851818281866095288773371414866822270689959827332258348570976075184933893434327278299820594014788148344260948638847457822697682605612771344335201258128') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 237 +INSERT INTO num_exp_div VALUES (5,3,'.000000000000000000000000000010824770508763323320533297369674519056450544793568147911931789010432012750062661590994728968589403602468229106206242395792957238667714358401601098858606386995096923432407249369639633268143022787987190106724545750803196130511146323174462918572423414631798141263222875752767731279138952850500369328934959764805948568471324562210715908420467881411844098258193571194910997918428786213948547748701831331312040839544355427357749520227124858111324859160114175254197992204974033767300989488517391063188153561391320190653403747521648794370679322504188364455328709488846777004202196382575648619395139553279192346251133156445942281048959845827006761160755031086836046398020850814350246219929303018051720203943879538087954853996826539712240458022307680912400297508925714946398031304516583939283') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 238 +INSERT INTO num_exp_add VALUES (5,4,'5329378275943662669459614.81475694159581596077242547133292502869630735172901157043010370467618244548786897684821457816189831652076071977025794948484549600736179389638319303817478693948215387894509009504287664213474693208847025374388286162907794727810231557001266897729978691844410171412189947386181530441402903608214502713480332746271552746231631136145916685939539173054989927058122097304419584979598595477177513004218594211597809300517607260841648610322863666300637648662611916496850248528515936635845594390453288113296413254893687029540384176335735114863908372780241463999450547422213639667099644505472777149095004849805371205203850993689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 239 +INSERT INTO num_exp_sub VALUES (5,4,'-5329378275943663974970875.68387837815679263182430217236192193838209859394480321205431177443564436871085042440731842593128543877087159218415801821547335178795206149841646805067528400474905206604863569827296492883485842974145076391654088154097803033982948898084192422150809385760511991169192044353228731864375715719064118394339415417054629392004621307042759799481522264617060523956256201137680272894311866260366238283858551565663520480629408383844349319586471282301251749494706061523663958609947049544255725056447964564549684815188261035801892684889942971676086592385285071073528462167439314005547455087297279161738865296114495425732286867689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 240 +INSERT INTO num_exp_mul VALUES (5,4,'-3478781676337858247983014311182511.567538638808357215203593479841446379226774481291286361639429856698999485760647422501864626078375852610019829111004807806660731243672830787729048847342063218718651165150612717759770504648306347926061960607388621011846314969634048226452709389995594961695723139571002939804473057725442880410434039783304583526414509590532906062732322732569475349107437896717416548237633532805602064623969799081086996320156575550896200848758685986331692388099427314008504506503745527468550106879602399030419569897808150076298414568875477195447656904373310322813412927463518325927626891046356679526447117311923853482118502868148386882363449163182892615259995945992014431502761210899772725227648729095696228388558331052524469604046072203605897109629560683446827492904111565278516043939137760721315953500281379039771826554155511347152') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 241 +INSERT INTO num_exp_div VALUES (5,4,'-.000000000000000122482510461124748279475400009367345900846466958806966807399903713411658400733717078392550780910604704603123670767210550800752620037863340961255721285160854785449315208955654408132775022766783343331151895973970395232686910362226184006990485313002943710214511418310741271074710741339586430026286272098156531835438969774325517509155992092194349661122678547097423264670055720422496527272118788005921590521726691666219504214087867030003203385360001614199656989667055583749577099440092378355805901262289841168751608673297446473709956390142112843400255748161809121986096092991616144443486023218404881798896685413932215981950393130292001833627899480153863300557853617312991880655905907971211246077450786084079040513198340644157868678782195341316027563717617074364438885981635394382733697473265872796207') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 242 +INSERT INTO num_exp_add VALUES (5,5,'-1305511260.86912143656097667105187670102899690968579124221579164162420806975946192322298144755910384776938712225011087241390006873062785578059026760203327501250049706526689818710354560323008828670011149765298051017265801991190008306172717341082925524420830693916101819757002096967047201422972812110849615680859082670783076645772990170896843113541983091562070596898134103833260687914713270783188725279639957354065711180111801123002700709263607616000614100832094145026813710081431112908410130665994676451253271560294574006261508508554207856812178219605043607074077914745225674338447810581824502012643860446309124220528435874') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 243 +INSERT INTO num_exp_sub VALUES (5,5,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +INSERT INTO num_exp_mul VALUES (5,5,'426089913064020811.057708378200224487694731586862745370027417544052374884336177893807736467646454486029424673621605232432043672119510371547153895504456723242262639262542904151307250842477327375961936454637964429999741717244285121019840463692418987118402683746281993192269229200465080358289645050337976214115902915692028162689089167194843185708212911364017271332623359100711545479273675423617018342297822477514128997410642005300368966199980354369928371655155437291469427189561877718971914040675572136507472590254222870537216617260612835805368361975725573009455402822669103118872235140158440342063571894152305875004532651814592458133460160514384171804043127771746596286988679698684698755896736275307574630777027620558428909546664763675431701332632828281070572045822129984625797185173815273651376003614106277727279230096226977335510') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +INSERT INTO num_exp_div VALUES (5,5,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 246 +INSERT INTO num_exp_add VALUES (5,6,'-652755630.38762364608541718463145771120672223443489913059334543712856431450577465795351472116052777583325262472505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 247 +INSERT INTO num_exp_sub VALUES (5,6,'-652755630.48149779047555948642041898982227467525089211162244620449564375525368726526946672639857607193613449752505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 248 +INSERT INTO num_exp_mul VALUES (5,6,'-30638438.151446159804025029882398388155309149089870990062944469684482366692824338098201222171115395923414887930224163525189097571163687285244255335505387733673499447610577050114902372990462064696637481657064525319516004273769831260452832960893174173254560250804003884280384718123289136453955482855362019158401218620018346500189769819687260476334734259702665316562988639223597110627626759216850014150105605927773639897638043177685498804811787888811168524202700283461266793154726325540776914500415140842975457394524215869103737379109516024460317825645645301237375972914247141703084877141866316168268901439172491577729880760950895760711857112463508064820414904611059588717092145484656103798852859978690742216940980929562068') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 249 +INSERT INTO num_exp_div VALUES (5,6,'-13907037655.047994416383638650569341223199042786813441967582376077478024677494832069402897226848055043557486983268019376307288565911231748501636517992289743940159005664424461285010295150828744259113760652210086696250085454819340987566229400805422509198052317518991183515696724846560872057916862620762789778660622787735923967096950195583369113574365386627110408307941105082873469072519133330718161987781080307947247163619814890462416622144825161521790673339279047700672881113718394727610096366361422482794458375587355933614201638489194194834709433413694420512869179976485096875057742460003147602405353823942488343056906912173170809084207937229591627643451380735179767199816663168139837088183577975769442341678933576388936845704303859241320794255052627716474860113993958556604381707826493168941926878481079724185426298004604') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 250 +INSERT INTO num_exp_add VALUES (5,7,'-818934540724601372.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 251 +INSERT INTO num_exp_sub VALUES (5,7,'818934539419090111.56543928171951166447406164948550154515710437889210417918789596512026903838850927622044807611530643887494456379304996563468607210970486619898336249374975146736655090644822719838495585664994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 252 +INSERT INTO num_exp_mul VALUES (5,7,'534564131989234694540350103.27821462973515555648644772098605028371173048154132108733819196629002548296868548691993248746628993380136454426833349407578676005545111508293942736555269938962058196496152360848131645787941032968937794930046928523006455386861100809286408671908320322523368135203881520526880998279355848280412933152306299256343179622513731096363088094541514890135766460631462465021694553063366717467560655272004461368865264059368514271105464855575429914212085797297268595943955105608543373940035636033207568676745293499106348500559628723682588033431457023964317090780615020801564861497990103549650624438425421690193862533733474254') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +INSERT INTO num_exp_div VALUES (5,7,'.000000000797079129642393611556079160915147221153735075943759104977169600937534508973732991117540626046659124172765761873705978811124901421049332579161931652390647472911517923131800238903184679028518657818755558526885018755394697157094867449047655737107085020874974955627907737126958129710597811740696534189608639914753884882702680512272194316887744972931453458445314561564591875764930680945589486999586667912816485821717403892703364322658245615895415781719033810595358092343690359557942948213374234065052300866661453767599465059289920067095083062096458980564265691295895672503728815182981118876144075942348853666085714846210822847053889733510154276933759200630639642310562242207518883342516103725757482864105340008709446643820864294556778969997115586027866760708448174502158738150605938364482719960251612464993') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 254 +INSERT INTO num_exp_add VALUES (5,8,'7844230593.20607652525116672615394735666141304947992676684520382624714879797087461877675155217754947572297228288498221620714146356962938009770486619898336249374975146736655090644822719838495585664994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 255 +INSERT INTO num_exp_sub VALUES (5,8,'-9149741854.07519796181214339720582405769040995916571800906099546787135686773033654199973299973665332349235940513509308862104153230025723587829513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 256 +INSERT INTO num_exp_mul VALUES (5,8,'-5546455599206321494.0676583421119904300307105296377723816472192007866147764761501865875232824814135783697976183493106885436876081315217834621720906478074798596116645640251460842350553806256223963023430631066024389364515688765194373161385579258482225808660340732705687558150699172147896486727530192499184101617379930846663835628510376484675411350654979679181852179924386290069790336316958202582966248703889464308649631486542724072047294216362186036638115240070658004553260251510288423749333873893917690832829128021808383128393431810674177390352413548658782609064839524756041501835115152819802758773711821322162752064589750295542985780512921839490040396053737870038534216948323935020460307350020911362024271167085905714873548388570602799432705061561572854498075600') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 257 +INSERT INTO num_exp_div VALUES (5,8,'-.076822018213756690975099471985461347542955923191183223634407380481978143225129486622351714276452369661632980197282261508936298649901018470846144321441236073683990324039849865750139470288565622579952182053792815638469841531577235191276257498209844422440366423136595067535337374223115507557306455001792362506235886189722508617024948653046102060677266555476719102193278190540414934812073355995577639986512222998268934000209944414236509139290657402937840986061987219441410741189615344050459067454369371094189930607834375561948483494321255500497786795636801854613881105643003358210407867114145806225724880370339074242480071595684502491827709175732777776915682786771730423733673667248186336046898260378049328204094804755195626798951644386924178161926128482002518979482630732440619051262620098544265763306253807191182') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 258 +INSERT INTO num_exp_add VALUES (5,9,'-597892150.08771044822540810796370552966707032464017958269847934730769542644402913723848026909285133109089452632480800168074607090893991283808726990171062867538012237270000932798704781608969096508450960185964292594677356241956277714380500188870696516251767979457838109804726539408115452577436052503866633026489282425086547752714324273565900641436632912781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 259 +INSERT INTO num_exp_sub VALUES (5,9,'-707619110.78141098833556856308817117136192658504561165951731229431651264331543278598450117846625251667849259592530287073315399782168794294250299770032264633712037469256688885911649778714039732161560189579333758422588445749233730591792217152212229008169062714458263709952275557558931748845536759606982982654369800245696528893058665897330942472105350178781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 260 +INSERT INTO num_exp_mul VALUES (5,9,'-35812445701642379.972368737320206275515144213236752803936806738624588812089615098329765811617509505790110909629109400553415312470540217508070421816878544125783329593128638405659896184248784794258084116406472768709113030915308410565617764394827427154923321461158387012978726512246146545834669665093228316853342805604075936530371665576147966721599968786161939347726656168798065647411457701453987215491345496003650288850096338695703984042549594979897253521041581573388369367579323607093487743440894765114619634001789457486407909224339065748496715380572175183589195611952939575073075140094901024063428239223964510824958346570603142906309198033196987949067156046076497974760641964978711558209708743776024313916111738542765749928287600981397080809041007714387564206594515733287925008053261840295560398311905155157989225181164097547541') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 261 +INSERT INTO num_exp_div VALUES (5,9,'-11.897816658873986795664687519069203701902563457968097729876034796143085813450454323128600602495745166997629078984618283588337379184733369491549230343315369634754204412939757136108898254582353378508832611703989221079986765793923635928759179573599208612516427628403686659479459867527627014558600521732194240404211484706621458983727740143568799713006127585168144158660566534382037451913967363675002134687952374080694449905223371627606557311710348820900963340884001770733452314715448053233208783321215998063958966729954113843581448912079950334969908657535514847005768455377990262943747367245613296497099716892292154137652893990339292671106003657659470243633112063075297194691349631518467702876183897580432003030164590920118726657290102377710611324297862045849839571689192181090062958059281673245670440852080202548743') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 262 +INSERT INTO num_exp_add VALUES (6,0,'.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 263 +INSERT INTO num_exp_sub VALUES (6,0,'.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 264 +INSERT INTO num_exp_mul VALUES (6,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 265 +INSERT INTO num_exp_div VALUES (6,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 266 +INSERT INTO num_exp_add VALUES (6,1,'85243.44233732197133191329295927531563604777955507322414928382967007765263923984471408038635831036097817458527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 267 +INSERT INTO num_exp_sub VALUES (6,1,'-85243.34846317758118961150399799670008360696356209219504851646259063690472663252876207514831001425809630178527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 268 +INSERT INTO num_exp_mul VALUES (6,1,'4001.075404054519813215296429095020391062109905613738157927030437221793757373268325953178030040276107574363822832168160758728653712686313134828282109532831190239521843808940611025488601517574653932032236616573457735900045655665690517797280666732780030171712864961531623060353548802466577910774711998056232872212688464691036260746751992072745518373073825852119460094113694393273456369345499434994672730920070410547163082189385645712866100999708173472360864669110044660667614583576570496399103026286828660558854973376227247132815728164629722965145778698957093136175449225024685874279280018547740') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +INSERT INTO num_exp_div VALUES (6,1,'.000000550624150700285432940805295709861455424264970126953321538967550091614148982212874391026630805836518138806917934859138493583812313778188030836027246840794439412443826640206464415527687555214009725107630387889854278497875708390050387195108441635824296563108288712340902423706104029452615686971019125750530034798026103476074158922893374911891438688457439945897348811702908216883650280617098402133628688982793791562476980709924382381505517834196446365877784931355599480881104446907801805570471686295270927836995181422963320376948188855989986414581755633425437161760674162177776773597848142496583128607548351599750592863590334617838124741567654525843413232313914310487355539260264225486180000012813397807525203822863232682089295055713257835007742845010741137213301116647610033909062369843750685396196342928455') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 270 +INSERT INTO num_exp_add VALUES (6,2,'-994877526002806872754342148749240.99659316232359475297606895243958507460511031229368344962653674268847910587702140353344168594152240599109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 271 +INSERT INTO num_exp_sub VALUES (6,2,'994877526002806872754342148749241.09046730671373705476503023105513751542110329332278421699361618343639171319297340877148998204440427879109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 272 +INSERT INTO num_exp_mul VALUES (6,2,'-46696638263247522384986521136500.479312417066793299922708112595886608370451213741279484136907754744903470430131032928908162742687359367826808123516519335458861613010646992354378739165872253762686683966945711430182491860196341344982195078000259063231136011430995647812149294224699587849791008794261026932467933475782780') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 273 +INSERT INTO num_exp_div VALUES (6,2,'-.000000000000000000000000000000000047178744084866106587600962473825168237820701199970144691815329658682341685812472535816245052671243808078367856957579485152424914481414614360809698177236664771558713606961423658442962083541733004775309314926918118528217478256885324362912426275407382550929085958089798861918760121727491366034496581249711153289495601712583077918760003840368008056353090552282274780428335438032908213783490070198414584291402513547386013689752310173492320159738977752795528725029134841933604057954874523842273790958618375118974623107241366036640538085329921129023905888674299774726871808862832797230915933851225308164365269753526489223540580759951230801125605963901491073619448437890841032149898629231552019804656219062534881074125995130202820302133432951999011667568746004715268323913437054078537') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 274 +INSERT INTO num_exp_add VALUES (6,3,'-60302029489319384367663884408085757480.1853341682137571584926062805631087054017160819890685789064777236456590745415460695320768374693076860837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 275 +INSERT INTO num_exp_sub VALUES (6,3,'60302029489319384367663884408085757480.2792083126038994602815675591786611462177090630181693462735571643935716818574980747701251335721895588837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 276 +INSERT INTO num_exp_mul VALUES (6,3,'-2830400711649493468815157129316992649.40542786074520931471973065281957756940496588853021620372179463538053123396140685749478530925306163968207226329985017644835203709485594362663495728106061878665324856417118064730721101615473194292620972173690618491026470353143141125614124440035267592258385099934706896692953497971326605145704135723011753705907329979207428661473172503098296622281647255008204864404416199384701720347319806375450632245634238172654086373193251877533131784268854289406126119630708578053354762596511353053106459297339360827562281168219966099848212') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 277 +INSERT INTO num_exp_div VALUES (6,3,'-.000000000000000000000000000000000000000778366376597400971124059102619954214055884926284646546105035591052258074563706355894551049631537984053410850060739107742208523938741961208742831871056600773325053133977559789796700130019975964192371715826863472981072974742704091801166438465082519558956925444635729210849210496466189037623555622901738570979273502405907969114110345815802999687171113749364073269902319653450479463404003706147915064100959774312307195946966281098140229199529866429134937742584938255441169541436021827079647129394362379406256722903991353136733939395366152312959281905058592776286736536360235356737359904478313225848562436632109470589310799000750518904145312512621838935796912993778920622238202744037977772169066929474233952081158212174549695244127987299282384885288897893503991509410567351494') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 278 +INSERT INTO num_exp_add VALUES (6,4,'5329378275943663322215245.29625473207137544719284446115519970394719946335145777492574745992986971075733570324679065009803281404581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 279 +INSERT INTO num_exp_sub VALUES (6,4,'-5329378275943663322215245.20238058768123314540388318253964726313120648232235700755866801918195710344138369800874235399515094124581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 280 +INSERT INTO num_exp_mul VALUES (6,4,'250145412892811547138949.592621291590152419206270097656346630226508074074623894951308487425470437268130465956063593951784820669318897182831355375451719125809800516979013437732298382708070979871283132689492336823087794373113039154669229889503700598930220858275174342776478898670277868700384853696009897221747924643343353942154528501454689084608965009561564638167714973711022212547096732831847202912862290958304510651828842182545311077713664465815992616213663619529378061133917572474298028065850515876361609671565914027186063801852554353160801534696062207299890867876199323530337336273950892723090754719547285920090419070001019943385293110663922226230169381423410428577990604776655422105400452217085311617728003688836185608912367677734364834577573255789160419371322775733777518997638403409000055707558465286469808848200141192627396502735') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 281 +INSERT INTO num_exp_div VALUES (6,4,'.000000000000000000000000008807232244507937251856465017967626593430084223212999583902527587737263981869382895220711835510154989851222501080395520249593128253795609198666884523792646863341248402687314509176781281863891589925961900674092953408613128961234166906173266411035009516545964362406728942021813644419154548354247112601793685146960840364604115937119024575638240439041250900118977183124605578660115160551830946251713350556181960983267689939549506518185340972020820080460565392359379680036788592213479105831301723237102710863182596413567756605711230290883888612188805367801369264231165178487334557824054205160222371548005742602736713668548450400926514169967213301919971189065307721110805424950794015852531342286935114651278691214233054575660712537044810163930633456573860895791198853393107188289695511873068') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 282 +INSERT INTO num_exp_add VALUES (6,5,'-652755630.38762364608541718463145771120672223443489913059334543712856431450577465795351472116052777583325262472505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 283 +INSERT INTO num_exp_sub VALUES (6,5,'652755630.48149779047555948642041898982227467525089211162244620449564375525368726526946672639857607193613449752505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 284 +INSERT INTO num_exp_mul VALUES (6,5,'-30638438.151446159804025029882398388155309149089870990062944469684482366692824338098201222171115395923414887930224163525189097571163687285244255335505387733673499447610577050114902372990462064696637481657064525319516004273769831260452832960893174173254560250804003884280384718123289136453955482855362019158401218620018346500189769819687260476334734259702665316562988639223597110627626759216850014150105605927773639897638043177685498804811787888811168524202700283461266793154726325540776914500415140842975457394524215869103737379109516024460317825645645301237375972914247141703084877141866316168268901439172491577729880760950895760711857112463508064820414904611059588717092145484656103798852859978690742216940980929562068') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 285 +INSERT INTO num_exp_div VALUES (6,5,'-.000000000071906039575366987930696117572143566208825430801491864851999044659045681114433294052065377679745375399878664822361548237094424148992770296383642432040129230180142339557437679166815114510467763288057917694948929009212876391059413439647163295629904270262780935228234994930653489111444964446097124407804311494588517082748514970905563707392765567625639455978464081409330528324962333492925267647686759704415549221137291475247571296491073010175087298752769122449499990102435819414671847617062560524758344361194566796343756743243766853291113852464023843527189221162680613675369708907935197867458588904367993736363321133720345058432019986643353417257503619558797249295232894674255060861358071309619524800424087896023710729815248847792174290644245138831518072176198607255346603270853333176255533974364728342822') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 286 +INSERT INTO num_exp_add VALUES (6,6,'.0938741443901423017889612786155524408159929810291007673670794407479126073159520052380482961028818728') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 287 +INSERT INTO num_exp_sub VALUES (6,6,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 288 +INSERT INTO num_exp_mul VALUES (6,6,'.00220308874624532134736695825088747995945783791378828770826401323533973395137378460250799184832278118133622563295093909508983301127615815865216895482784469538070133388154961402881325731054433770884496') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 289 +INSERT INTO num_exp_div VALUES (6,6,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 290 +INSERT INTO num_exp_add VALUES (6,7,'-818934540071845741.9530629278049288491055193606922237795920035094854496163164602796260436963420239973809758519485590636') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 291 +INSERT INTO num_exp_sub VALUES (6,7,'818934540071845742.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 292 +INSERT INTO num_exp_mul VALUES (6,7,'-38438389630389612.0042045464692275627184627672063157323631169405883031379129843031477339360597564128205768842448328088') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +INSERT INTO num_exp_div VALUES (6,7,'-.000000000000000000057314803440765029050667129936880528769333499793237773980613524885506515999851858649385968476426313207429914995755091541422893944525222307473169425244462149015717526718376299808423552027796204632286454853167559026787019718806449038446612978917236245943248168920696452018925986743620392955122431521581268518101342690974749463089739042586011924590503136498488946387508310209984849243014542648765897536338824721211252335866349509669538308454367849024503312249951727948786393404944555844863805495937835281927012430439403132382055464307180153473189842433614777883826783689904293115204700185380661601223693428304020047393499702811581067120117405280772944184877279069842269329959037186324135435468322336398566440055479142909170224780318371473684868152271947368867666706912563225912012901437076773416') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 294 +INSERT INTO num_exp_add VALUES (6,8,'8496986223.68757431572672621257436634648368772473081887846765003074279255322456188404621827857612554765910678041003765241409149793494330798800') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 295 +INSERT INTO num_exp_sub VALUES (6,8,'-8496986223.59370017133658391078540506786813528391482589743854926337571311247664927673026627333807725155622490761003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 296 +INSERT INTO num_exp_mul VALUES (6,8,'398823655.819545574205652791249227663407026876411660299394659390409794761643751582473390322547798567169668246138880832642141417531427935520467563318363116897177899262525720710134129529640376020947774470933902793259531840625444267816319963200') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 297 +INSERT INTO num_exp_div VALUES (6,8,'.000000000005523967081937952184172713994498918048454262874017009201501812494019618863622631634736130436187167745347383745890248619882896153083428308074678908731005176810208100004498415662458272149380846809398637385270265351808328466537502823071145089961996689711299405627596294988646826454676198092260759424935699382655736524042353938814268760468122584678267125994645166955751211397353140569987758938572953312303398024147927938612934833827734142292697389251052485981023756760420972614486278837214553818521196182883489483756785207650821722660455451660719560529693418375773124813290305501923899840247103166971466167032437598057958226806335324315214908788839919408525748236713611579486768218564733151121028172253396652755590051310396973181595992981076269789287489208817712754098019817792758730835341151711523474207') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 298 +INSERT INTO num_exp_add VALUES (6,9,'54863480.39378734225015137845671346015520435061071252892396685718794832880965812803098645730572474084523997120024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 299 +INSERT INTO num_exp_sub VALUES (6,9,'-54863480.29991319786000907666775218153965190979471954789486608982086888806174552071503445206767644474235809840024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 300 +INSERT INTO num_exp_mul VALUES (6,9,'2575131.137912978352131546639620215541477987701194164886305951830806120142596646541302305984776928560906754259789485960991272272782091464270104432109904222200473616116525297615725803495463468272171161659654385929185160689572943852767523792651123455283534072794326647404332228203001469884016996499768656263775233430922446983838511590562929268821678518640501686017030536100955531423152839988008496919169395159653034847677470665418765966542111749439412') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 301 +INSERT INTO num_exp_div VALUES (6,9,'.000000000855524875533453524582534418967571681572635027972658867593464437484123442242521660317156546196609749230372398872487667521984251509483676665788527375343148382604836976332389890799079878151841905152004537926201190193814594954194044560537664560344224646197027029681984683465852110060077865421064400958821808374370779297676624123638191407441015008434084079839721156870032377372497814037418047056438760664237367081226979226606227037631073946209105678283624370820396871058367779887709720661001099338250009251834581804647326512873792849059661525874160414378459696930831877643599421297749483849526695657467708603491876916749718079725746259119898269814551222336219537198318796277931946529242436502235147453584237994498566122973953203597470078105606906752099294162422474758048436539653041606499637623370030079916') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 302 +INSERT INTO num_exp_add VALUES (7,0,'-818934540071845742') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 303 +INSERT INTO num_exp_sub VALUES (7,0,'-818934540071845742') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 304 +INSERT INTO num_exp_mul VALUES (7,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 305 +INSERT INTO num_exp_div VALUES (7,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 306 +INSERT INTO num_exp_add VALUES (7,1,'-818934540071760498.60459975022373923760152136399214017262844141729040109985386964272131706381326192223266583769046276181472898406504104649192224392653722107164485675679551050629376558940966195135841284978096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 307 +INSERT INTO num_exp_sub VALUES (7,1,'-818934540071930985.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 308 +INSERT INTO num_exp_mul VALUES (7,1,'-69808760806266041400340.70700818693892852138813934414383886494691670042143650609934777814995087699409404201920249076407981012095999320858479644760715204999741683528746097757549835956359129287002171391961763797857794730120426599135099619822532290339000466211195776337667123320942107370731349851576864242697412616810236323676004067839744992733887503405311090677026008324895177587064547630828026123718296429295638934384446325302964896473296829265805737112709269803814942537657996725913938408781715328945194948010970') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 309 +INSERT INTO num_exp_div VALUES (7,1,'-9607014551997.140858001442365669993007297071681832468350855627077185145567261170534005832165603932891201648027598773639089125980996652005412450490063683624648655909636499261774535015914730479401090227915382926027949990128880284298688443593909017437720828163877690126019616194376778317148693270900349151496295698078575648169637635898560612738481294674167553369445426793073304518646116539082953755973571046622684332425840412198776081251646424875405772676893185726872613804612566569794177506268399878105117763696990094108960076591684779180089885283939385808214239337829666227427148603057941899878123459708920227867371285837642561064461118016739395972994827327543594846953341750907541716807985738518071480209106185726125017342997283356926976052909493074301401955202616191210810331245427141945840542129607439703255628683506772979') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 310 +INSERT INTO num_exp_add VALUES (7,2,'-994877526002807691688882220594983.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 311 +INSERT INTO num_exp_sub VALUES (7,2,'994877526002806053819802076903499.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 312 +INSERT INTO num_exp_mul VALUES (7,2,'814739569184924399102711674444306584731316176345067.39834031417849342571224916231092924046722938910652929295271097903377854123984307101079073134405782275535446337229706620713104545454319555885847481531722101704765783025789147453570970090') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 313 +INSERT INTO num_exp_div VALUES (7,2,'.000000000000000823151110229758332661330617426417726331211894330147399760458555778324097596176117291103184653828305857999638466183347321835058943563347767579219763002258622507889760416640758842509635599414768344140175277742935564567127659688612699366182158030839083982896107176174766408199870924563237827899202849733606842856491701660599599211106794572237923985121475458446997860253437578966578617985764298513928307852082168209458400544457824307270777530312648199364084272310536024283945598340590403612752287693234647719354745060851129534452514828239800716088248915975054881011343555492596002595181046121935660176097475159074973635534016835214952415720717896518544064238656360099884889450237541254761746029507300068198731306211736696956568648033834554273602524147075895460874922913883751452403825099444642503437') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 314 +INSERT INTO num_exp_add VALUES (7,3,'-60302029489319384368482818948157603222.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 315 +INSERT INTO num_exp_sub VALUES (7,3,'60302029489319384366844949868013911738.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 316 +INSERT INTO num_exp_mul VALUES (7,3,'49383414785234649002982046297226894664526726187218771083.0993243619030008310875293647868815940421844461627295157812843657782639833900543200310573708100000958929315945039020410482966753145208427035917753919085618457760620513481628641658765820294863970581642745379331727722585319163262763708386199720411053619449096019862596221607526610103408936214184850115071874430846697061554769773328338028749631552202705583855831155461651414320570061181212214810086436100771547030013079997847086') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 317 +INSERT INTO num_exp_div VALUES (7,3,'.000000000000000000013580546907080371873577430837141172674171921610919544849037647398734065712983603204704663262116138799357430947986241590690589753181299773842880079777640016786921825609617596862828930939366173224366864448436461306602680780407912534492687474933386043505172346330210659476505435994582446405414027199938970759003336829722057241708213838318628292667946636226143164221380503228191376939596663443230082698085439531600756771639601022064620204571458766303985028143400866776954225590745596639602613498355332049777798367675438365442468743270334407716567057368347458892075084694158566383133325959042076573734408841629149903649365079563374278550978052491499304166424686842598833319515705663176855033865872333988551611996194856472662292344160194821687681312501127516922809221030420253714666026321243515830') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 318 +INSERT INTO num_exp_add VALUES (7,4,'5329377457009123250369503.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 319 +INSERT INTO num_exp_sub VALUES (7,4,'-5329379094878203394060987.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 320 +INSERT INTO num_exp_mul VALUES (7,4,'-4364411947278810125327066890819882483326918.05664098958260550284395870948992407314161088028674246708928421994893923699743452802989464864039994566042797942433140378990308345483670828497915478397481687305406460330009319949623844175096007381662809083363069100235985794575399268709260901964834244796150883807308976949196661411035264619638771824190014274817662519438658481432363824187693821267613212631153175155634316128036152465184903927860719447693468054624663668062006049759837326188252927823612718163916100588143128358998656306593393889422386501730237442526450419990376323903182669190482615734972147533221144682538647497701130447816148459762464395194383090936159579764712919396391813914821973715879062992249315474841639591907249142779103650773383644785606333916967894') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 321 +INSERT INTO num_exp_div VALUES (7,4,'-.000000153664179510102140733858340480800294287837601105047285453457000254577644933901525444082336054243749405512900867540483190494113677173628646221933766421338612376123824684592850465460156248403574333545090544920568230979754949827013129083778435107488003838746926270955224758508832133483591156567868631938590248213604979638895901933775098150684618378235712437137852195098700137765601802898366867034641606131280434771339920637353140131159441790904703083143627590062236537714415872864218260252838432414759890832271190606933534662897006726154587341385852258168335058931957995901987808602365467861573344491265289043037273815504867254228957776127752540924854546837197432384563153608878864912196453587628891285275067452280357349897203095502806923463147414086919014592380804424300739713935051357374227246098303140106') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 322 +INSERT INTO num_exp_add VALUES (7,5,'-818934540724601372.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 323 +INSERT INTO num_exp_sub VALUES (7,5,'-818934539419090111.56543928171951166447406164948550154515710437889210417918789596512026903838850927622044807611530643887494456379304996563468607210970486619898336249374975146736655090644822719838495585664994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 324 +INSERT INTO num_exp_mul VALUES (7,5,'534564131989234694540350103.27821462973515555648644772098605028371173048154132108733819196629002548296868548691993248746628993380136454426833349407578676005545111508293942736555269938962058196496152360848131645787941032968937794930046928523006455386861100809286408671908320322523368135203881520526880998279355848280412933152306299256343179622513731096363088094541514890135766460631462465021694553063366717467560655272004461368865264059368514271105464855575429914212085797297268595943955105608543373940035636033207568676745293499106348500559628723682588033431457023964317090780615020801564861497990103549650624438425421690193862533733474254') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 325 +INSERT INTO num_exp_div VALUES (7,5,'1254580584.048971438599349046867230181719371038956756285986415773300837165755558702217197735811549684202279755101552533605390208155708695952004683670878589028717509749282693444655857296902117478518511492735290086040573521482737598395369632843374456793385511847676556826348943588519880411018079886373631771830925920986588708409208527042927229627786932908015502292313887561198156623702404977221789649731458241770690830680067801377815840764873662400590343236662968218256211697981048576328148435241545372543075051594952109757428031762469834781538302930957095080167901199455226976113347018972534334210416375400979738414416582588689496706548495076287263281908191770792203069614447622517839588243746755480572371988630084226963919158931419126724681617069720048557166545204944250492282054791996953359013543036918134163144772567093') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 326 +INSERT INTO num_exp_add VALUES (7,6,'-818934540071845741.9530629278049288491055193606922237795920035094854496163164602796260436963420239973809758519485590636') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 327 +INSERT INTO num_exp_sub VALUES (7,6,'-818934540071845742.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 328 +INSERT INTO num_exp_mul VALUES (7,6,'-38438389630389612.0042045464692275627184627672063157323631169405883031379129843031477339360597564128205768842448328088') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 329 +INSERT INTO num_exp_div VALUES (7,6,'-17447499423661151023.558342555162228919125358089491573318627107322332520978657843895009110781773496490472817700487707134216424855867015781267287628022535529641238372370292374146871103236048507252055787621394728096799222976387108688980537900309311204203302960751747509648304056939321473462375648710590981564101023812800603438271190184064874290215309040519813024962909469701968804925443161094255632624090623433640078421818321246597728308302979223833487133268472455479442002005374793705431817866798804822885690193667521606781156962792120052947767160957903073698536973292205899421787948529970837601521657406211962967291912148632072929662185840265855612193255596825032457033402506154930851214421895488796227471490998190312007513478459049382774782886773158311656817014322925167278223360446454868236479549745612973293185989975394307678926') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 330 +INSERT INTO num_exp_add VALUES (7,7,'-1637869080143691484') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 331 +INSERT INTO num_exp_sub VALUES (7,7,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 332 +INSERT INTO num_exp_mul VALUES (7,7,'670653780922685519356619170643530564') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 333 +INSERT INTO num_exp_div VALUES (7,7,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 334 +INSERT INTO num_exp_add VALUES (7,8,'-818934531574859518.35936275646834493832011429282408849567717761204690035294074716714939441961175772404289860039233415598996234758590850206505669201200') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 335 +INSERT INTO num_exp_sub VALUES (7,8,'-818934548568831965.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 336 +INSERT INTO num_exp_mul VALUES (7,8,'-6958475505053954666339703437.48985528725312694198056665033448258303533387675711770743843194274181580881296671866212320171337132096489224277825857521033238709600') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 337 +INSERT INTO num_exp_div VALUES (7,8,'-96379412.478435590945480884955616049873645089637121682284625533034225619945532704111492738646389632607594293500930307222576571876059094206480673293295865214240456906965855425738072430281475736130342229749511650392658808510082775031098547507966544723255869156056349218776847523349173551313282283869146710349521487706884633419341568648959204688757523312579312713453540395840470692533267158388401676533369105590789036132185107859069994833345453200014884023709597817280132465224778002071890368479648934317322270613208789859930618055792958996389145963056607200020526949699302565905917600478429628844015684879886549766473809801710003649193772354147104446894109928903223843036925147624639466770660174828940577089095480826473544099693433597812637069287644606693066736302793687011165899362920686114156254982709172925265118077531') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 338 +INSERT INTO num_exp_add VALUES (7,9,'-818934540016982261.65314972994491977243776717915257186979728396159058352649559139156429817562698954531329940720620096519975256547379603654362598494779213610069399116912987384006656023443527501447464682173445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 339 +INSERT INTO num_exp_sub VALUES (7,9,'-818934540126709222.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 340 +INSERT INTO num_exp_mul VALUES (7,9,'-44929599044588573810654775.83678007633232843418115790847152455559258007804727916986432256198687661496804050903769496933400455947645400628259699874770581538122521805603947464462448454681701547899144129061961394870320463199545502030106801911915987309444301341575451240764927967432593181449618816978119423290767783843864768557371257918447461479570164065303599994081990686') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 341 +INSERT INTO num_exp_div VALUES (7,9,'-14926769772.797708334489652004325241753714626257641081061212878627972973992233480868793527325656854681817156284203427388055525855608883067129036717726368707982450450575794623567027457808927082390474261155500697096284790656757163047499531247323702909360444831707029353441147768321257650234732286165724178549576948957405037843360446785505536809409054071975214796532504678683693402401018726571884721963641317944453797513145055081061680091585467186975354801535734149952115333241283186621720677488342266420359417174224757781125498130120775969091933838082305123652811689513300403051544682523761263183781206840940347226802620226164265210810994106136738030959199259066517106713585343004140573604437146025585149934286364795122716971496775012412420105368351774715982565252533025207453326002101655121126631180162560463548157187175671') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 342 +INSERT INTO num_exp_add VALUES (8,0,'8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 343 +INSERT INTO num_exp_sub VALUES (8,0,'8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 344 +INSERT INTO num_exp_mul VALUES (8,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 345 +INSERT INTO num_exp_div VALUES (8,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 346 +INSERT INTO num_exp_add VALUES (8,1,'8497071467.03603749330791582407836434318377133169438097066269854720538319012928851657498035372443556191720308219530866834905045144302106406146277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 347 +INSERT INTO num_exp_sub VALUES (8,1,'8496900980.24523699375539429928140707116805167695126380524350074691312247557192264420150419818976723729812860582476663647913254442686555191453722107164485675679551050629376558940966195135841284978096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 348 +INSERT INTO num_exp_mul VALUES (8,1,'724311956372274.0135050255361637906710330203036651743488213007179039756514944640108625580172737414192938789413338554327986697518463087452612658955180411327002900979574347739956600177846996063741787205122007268468674386396156638261992679442768654367111433834151087792255469957061758837789341439211010331332174981459471333376067541234901538285101103690622656631026001337239036711179989456674399137008584021283568040818388709554256523118702728176420022080138548890713013682480239784198421500241995499841675772793497485550923152267616622892846304530712344886979674416990935007952941652591352603797627920865960622077762568060903908151958000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 349 +INSERT INTO num_exp_div VALUES (8,1,'99679.115123747637190903598543851248555278745675862923884476564848911494649941770503156134872464666625927195645517181131678518619856156844072856993813601495176097972982587061507650426363887871820112714099226501603733968262566093655417466145183587899155614471697804006772915054739361437054029183182533671508695646413074668188590846200362324428338974890534273352188276373478524543505805545661569395314989170104140776362043880099775594658817242753124957385625811310332354760117110779649164022618274859298031549851269619167173746259018497289174255201452265070501056913033329291819570027877856677145579673495987354805150868813877928857472561883332547900866904764950837506993759536410161752469488392566682723027340638271076406246129989851281210810196699482980833204884400423019400653089825859983062096326294783573417554749') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 350 +INSERT INTO num_exp_add VALUES (8,2,'-994877526002806872754333651763017.40289299098701084219066388457144979069028441485513418625082363021182982914675513019536443438529749838106171095037135009526312783302868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 351 +INSERT INTO num_exp_sub VALUES (8,2,'994877526002806872754350645735464.68416747805032096555043529892327279933592919076133348036932929591304098992323968210956723360062918640113701577855434596514974380902868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 352 +INSERT INTO num_exp_mul VALUES (8,2,'-8453460632655529853033389979024265783461224.3195241893307807116624750282852146303290708492834695194274289713076935297734670940696121761483641291930931061232942894577813178566088927221374036301485916497770984757492912292002695944367308880163698595015497307574177176409203214324418237020500352652934909632442547242092296504047310806151851207329042221920888326000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 353 +INSERT INTO num_exp_div VALUES (8,2,'-.000000000000000000000008540735921314463871578184793632135730756619558669911183806487803411545406462244216408739432325839683804021466133071768612386706692296158696852363349481716813410857655324486448455846562309041306880675446880859847445987588059144788756984750993583865748280824370754934966494724951583311563735533173023858438364336214213295786266815116844775733072416507474834701984381586060478606371028156925222726225495235702395502085206072985373035972506738983640539009567237336002073370431753469632428303255926718930619221521257726366850472572830063284204851204189447233044832163423057501488364913539948261528280564870049935369825245920984413480757133585498984374354957754078525161296201228031555280486615145365039415418251448980923331334883673792135893857917681235883506783408111446970710546686739582471') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 354 +INSERT INTO num_exp_add VALUES (8,3,'-60302029489319384367663884399588771256.5916339968771732477072012126949734214868901845505193155307646111690097978112797961939995859130827784737422228762767014427842766445950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 355 +INSERT INTO num_exp_sub VALUES (8,3,'60302029489319384367663884416582743703.8729084839404833710669726270467964301325349604567186096492702768702209585877643481082023851284144664938175277044596973126708926205950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 356 +INSERT INTO num_exp_mul VALUES (8,3,'-512385513828318260570283740065493064477880918352.732624553690077857674083796435724202494963885926573907185100543184828131859183999195040110586155435203949963570735841632689374488877298209082579317039061893012560130258753218955057387206477423088065663401594359617882154814262843273526859406265633827109554791772242178864873774889091687515990672487380368975556580539271333144212685871370972163560839446696514092637412587953506052848750866803569213269271165856310101244342151576488190595936869490659700946174362872797854591188391982770203203644172999264143929484089237665313698600170041324566984832357000400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 357 +INSERT INTO num_exp_div VALUES (8,3,'-.000000000000000000000000000140907135225782279761112255989433531718277338909398600029580768021365259747075253760824424092983497958717844671162530550507041138147836569244869107757945370200122955794509365120853536859837243314494576053441804831018954867623755033888264275704547752628348151132333655667171970175829826792355986148522268067032057293494927558322394395160508723637192234110428953945018965078022622950949911124494740703606109543716688008516750321047603009424529696862953094999450658951089435460411028678817795100630449046993274191915359520936265372754315076684798942557329584282177053819106884196674660057281227248874819417305259132106690385871316407455034281900110779740008476645291647094776093567400422266906817555937149628005629880142615126571231411138926043531449659320501743591992888328328980526602') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 358 +INSERT INTO num_exp_add VALUES (8,4,'5329378275943671819201468.88995490340795935797824952902333498786202536079000703830146057240651898748760197658486790165425772165585380839129948178510273188565692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 359 +INSERT INTO num_exp_sub VALUES (8,4,'-5329378275943654825229021.60868041634464923461847811467151197921638058488380774418295490670530782671111742467066510243892603363577850356311648591521611590965692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 360 +INSERT INTO num_exp_mul VALUES (8,4,'45283653791262997781451381354094822.762732909505051438036873220502792213670540454778361182993875916509061144859281577740137081988678361247725064336120451090222456518107029158304937620179032477664627949959143233370320432203497828243297406462513350790251761540074946469824444452248386782451723637769289822576372357189700319768797708375563651655860093365309717823602754924352327588945034832436331911584742966378275504545736896430718939807674966738116698454215555860047859161126694019895490767779791933882712567492115664113775047192011252893773389940988533801360010782816196288710063568554147458866942816721046004257953642508395867837127678980002737669139369781058046396738606563716339660654364541530532834806205571191828994250708412638796240377704994928921528330863683630622922959130920715261879547446054261914770022377059156125037157979236658010950') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 361 +INSERT INTO num_exp_div VALUES (8,4,'.000000000000001594367257057971052149628499448029056279649281098852958322409409919964709324200796473211884339143791758566019217634542932882694487712398244322522748736692741288668885362384266615527166964187404128216235057387796054457728789109537338988453837993084016408244895452291151218602815057669592284587317035387004942691671916981967449109983992675125005085762403043329820872839739877674121174083273716295673230993049263574856197011389828478636779342320299895806297835595427859271617831720398457416685435560152182883615601663820189195644140652141180949257192740185075408019971747810015931542757445763460947106918998459997631117642552273815713467150465548031203738878873114842844016176922502916339025283749846225376341878386377192605865913018132981323065698049618379727531925408677611856682983907951667054819') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 362 +INSERT INTO num_exp_add VALUES (8,5,'7844230593.20607652525116672615394735666141304947992676684520382624714879797087461877675155217754947572297228288498221620714146356962938009770486619898336249374975146736655090644822719838495585664994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 363 +INSERT INTO num_exp_sub VALUES (8,5,'9149741854.07519796181214339720582405769040995916571800906099546787135686773033654199973299973665332349235940513509308862104153230025723587829513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 364 +INSERT INTO num_exp_mul VALUES (8,5,'-5546455599206321494.0676583421119904300307105296377723816472192007866147764761501865875232824814135783697976183493106885436876081315217834621720906478074798596116645640251460842350553806256223963023430631066024389364515688765194373161385579258482225808660340732705687558150699172147896486727530192499184101617379930846663835628510376484675411350654979679181852179924386290069790336316958202582966248703889464308649631486542724072047294216362186036638115240070658004553260251510288423749333873893917690832829128021808383128393431810674177390352413548658782609064839524756041501835115152819802758773711821322162752064589750295542985780512921839490040396053737870038534216948323935020460307350020911362024271167085905714873548388570602799432705061561572854498075600') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 365 +INSERT INTO num_exp_div VALUES (8,5,'-13.017101389051085341042057308965769356145255575582875626848796382322826525772114256699384710400140437710569924703769685567402446691691210934185000959063158239023412379691360587119206695513775971704926722817528818197919265145207032750407924774510773427697188520818450702875142190949766251178733262143962213111236591970766836685919581025629742334704854852196126735685421250263035895756028805974153787560164935038227108975229771590754808331856162035119882347418116049174638416621093907738608991987582465865527947015457540650512339263071898410531735438556948115098562123055444965056347091625748703503220861221718449714020622377233272042277814766996198081939221253025243417993701684007826177845003391944496774674489538520354606358872276671998045196738090133576377830721671972381371985771591052597345572374064920279182') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 366 +INSERT INTO num_exp_add VALUES (8,6,'8496986223.68757431572672621257436634648368772473081887846765003074279255322456188404621827857612554765910678041003765241409149793494330798800') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 367 +INSERT INTO num_exp_sub VALUES (8,6,'8496986223.59370017133658391078540506786813528391482589743854926337571311247664927673026627333807725155622490761003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 368 +INSERT INTO num_exp_mul VALUES (8,6,'398823655.819545574205652791249227663407026876411660299394659390409794761643751582473390322547798567169668246138880832642141417531427935520467563318363116897177899262525720710134129529640376020947774470933902793259531840625444267816319963200') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 369 +INSERT INTO num_exp_div VALUES (8,6,'181029319177.110996740664566780784253502559986936959009611748146099327460471609593148344991059106574612143724330935988823134137686051475120980257829276671900076859337187540608483895641504622910361858962883971613675309676443079313179200981488761707281247447120551917205792352229666049191991270809865110506639390610910481490688182068719005593641339338678014189749279508731647492051879768743158839680867283217578754666643688259810863605002821607490100820241093473083445658378988069593782353275713240897038366242558466047071334385431080003439842348547427066389352198560236731403235927478177780757802759046212921140424771887928786549573201311120885052685761195784207710933764480136690216943336587118385525047554334029388869436622866247240903231799829259264158812528305210833683370536416861544931420820452512390255774498188962903') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 370 +INSERT INTO num_exp_add VALUES (8,7,'-818934531574859518.35936275646834493832011429282408849567717761204690035294074716714939441961175772404289860039233415598996234758590850206505669201200') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 371 +INSERT INTO num_exp_sub VALUES (8,7,'818934548568831965.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 372 +INSERT INTO num_exp_mul VALUES (8,7,'-6958475505053954666339703437.48985528725312694198056665033448258303533387675711770743843194274181580881296671866212320171337132096489224277825857521033238709600') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 373 +INSERT INTO num_exp_div VALUES (8,7,'-.000000010375659845651632013446652385870617923988120764298690164486716047614260682259722116360931978511176121353975789418625836899338225571166376573732227571704071000348895791547943896682585450808398324252224265156214259224488248639550967292466343168350213394398101712526534464002532408445204630441167137710565437434313424987517531891145368203998329086865151248833625645567863740298397742783405267970015165358620026813812552194344790169289440822038223606218360105618852154152168496637886434061050281055613760360200323363465925493033734895631921307644481639236601187225135325401868178006133838932915485272554505684060229409404902185944047523033315868230944723282246159741659387362889777495094736963530708159604929268812778894177095572578862150793098548829744006499229853198046828954650334595737117597239208825268') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 374 +INSERT INTO num_exp_add VALUES (8,8,'16993972447.28127448706331012335977141435182300864564477590619929411850566570121116077648455191420279921533168802007530482818299586988661597600') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 375 +INSERT INTO num_exp_sub VALUES (8,8,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 376 +INSERT INTO num_exp_mul VALUES (8,8,'72198774884738777393.8687539247642452953425155400068591498151280875559609979248583367700231031634872342122563819478919600402159024059794279536786611373504966204744811722007869415559012475160471227957857756325962941799428857291371597146319816910515366298862558849452235442246081440000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 377 +INSERT INTO num_exp_div VALUES (8,8,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 378 +INSERT INTO num_exp_add VALUES (8,9,'8551849703.98748751358673528924211852802333963452553842636251612056366144128630740476125273064380199240146487881028508694029546139131732304020786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 379 +INSERT INTO num_exp_sub VALUES (8,9,'8442122743.29378697347657483411765288632848337412010634954368317355484422441490375601523182127040080681386680920979021788788753447856929293579213610069399116912987384006656023443527501447464682173445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 380 +INSERT INTO num_exp_mul VALUES (8,9,'466174236688165594.9218054325256670866060556227711696100465581464881295978997280335378678072434776702952026828137140986670189756965420183565968027969700090735690246176791371115610886533930223141650377886909408268207750238603105232560663571044993507074695683027062426288270199495225881785499139012931143826099668999261931834700467395442768201666740663642498098541516326470052372008385656719236306238735524802875519713512894448940917708118676095378518264553310312628830009314653641136566040400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 381 +INSERT INTO num_exp_div VALUES (8,9,'154.875085756903716715488911525453064308758123952566428258639786597308109810869086867746263482721081985848551254298524280231489145092826397833394044637104667137816928932471315095067524966582810436282901424423215992139000153713476369887383242289102867530775908269805285313842050961754114751975054515055089553180717444020378611767296609130477264722612784088270193199394531972594028420402254831778715196248487757266330454269044609134602570688339750190391651801546906342796660819535014295618246236706572780627362908121159003488810140236665846928586992082180006454824311789091323774002510945263351862712964422865623934112293184149374573706760114682326698881257123280119140924775171374360283137569618025005229268057970275164869735173660958715166148344076027212231446680947914004346760896298312286730627916684448923824769') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 382 +INSERT INTO num_exp_add VALUES (9,0,'54863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 383 +INSERT INTO num_exp_sub VALUES (9,0,'54863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 384 +INSERT INTO num_exp_mul VALUES (9,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 385 +INSERT INTO num_exp_div VALUES (9,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 386 +INSERT INTO num_exp_add VALUES (9,1,'54948723.74225051983134098996071145685528795757427462111901537365053896571438476055974853245403475510333627298551845046116291696445177112567064282766115207407461565363967417615506303416694032848457927390574251904212425813072768882213388082765916956736282110801611726537663292922699021333445658549608928179155685881583228490235606377831724593358583903616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 387 +INSERT INTO num_exp_sub VALUES (9,1,'54778236.95145002027881946516375418483956830283115745569981757335827825115701888818627237691936643048426179661497641859124500994829625897874508497095086558766563666622720535497438693688376602804651302002795213923698663694204683995198328880575615535181012624198813873609885725228117274934655048553507421448724831939026752650108735245933317237310133362383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 388 +INSERT INTO num_exp_mul VALUES (9,1,'4676749348240.390309875431213992853550297086049749814750492488995108783145961719774217441193547534210468967573344456866203963659951312519988497979489304488948342258375915152429008993288817366720647491166024151209542534474867042837694499222928509320280684557676243780452100132238968233413333851595648146954975713386711764268506890884764704949969602122157394714663532141060559896359465918874990769222345665160127552795532197771168442486088776803398878354288847069602460071745966589164282641033852314335279121191855487126430176047553895892632834940595958394834437871886013513058514896870683979585091413977173250824451205330441299000850618134248917380244749589254309567551846327349592529960432446947239714236828401206843011440433362544797025114476612133622499094287321570559088587999417440664282418005102546343020409520421747216') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 389 +INSERT INTO num_exp_div VALUES (9,1,'643.609749344751131516972294140174556703217311736700045690413622699888869645595256683013323517984528456698303984909359393772036036540901870537096836621035845014213031549051156299974682317824766457362427063305495772666640279328909129870227828460705733995380145417663304348663705694070309475835826101153850359826502235923289787750107778906593010060115662191620280031872002110849782776325630424918493602259707267214006217268630948545349980430128422952869610116216278256812581821942763705098526140427280008360043829906543029486315209818099697988089748683904695870401517598840185535891464842870210715421728852789815860153472208176465166954851895457846723102438114697692610933532992841803219018495137378534010155991355251803548866919409031477821173935696065078362044927492034445482457329200246282082707380974745411383781') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 390 +INSERT INTO num_exp_add VALUES (9,2,'-994877526002806872754342093885760.69667996446358567630831677089993316481039076439881735980566785462673358516198695146576524119916430759085192883825888457383242076882081857926408611052522393579396644731758241837010163568445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 391 +INSERT INTO num_exp_sub VALUES (9,2,'994877526002806872754342203612721.39038050457374613143278241259478942521582284121765030681448507149813723390800786083916642678676237719134679789066681148658045087323654637787610377226547625566084597844703238942080799221554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 392 +INSERT INTO num_exp_mul VALUES (9,2,'-54582443595378013373024060492546032003692.4875677735896411267274323339692558458420972958075073392126734000341372096298914875892612108329218081214550050039133117695428196702128258481789017059073444323729583900855712795086447886053552786449313809589992185978097430132940882612817775035217244553616977182049775786664446683332098226841743818600819221587510039430478859412452506872131851471967577741190323481953867845129745440745526578327709351120432530702446916035797432129052518980799424635406993848916727957825620638983706180841278402925286540375225365057191075559133035') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 393 +INSERT INTO num_exp_div VALUES (9,2,'-.000000000000000000000000055145964114074763360265614481666934002579974728749248345352023099030383962250681574081874554842623852433135871821620640200582985140388676650602814646133317791813938390695683843848260103199745295436998313216878337673674660966362155480524935736646623766057029148471463569162153009963312016563281545776175277904913263614668092319707343286073000287493274965714031678784835459999763925833141049057636632430975424499618419962303087175237320046300285962065818926167792812657620724550768858763098967149546312995222223400007044549870620849992226072041407997925405957501929449911416474388622107825120486594723448780503829317691081601820425151593487431389373265285594626753418140874747955925763163132984655078996173911578832035721963554569605730262976354029623260224710106409129114204296314733036') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 394 +INSERT INTO num_exp_add VALUES (9,3,'-60302029489319384367663884408030893999.8854209703537480818248540990234567956069965340942024890856088355839135538265116174644003927269495876835324407641642359213535695803871472434650475144516723617632059130297610134243891145006222068960999879308472500422640481972089756410157246974765071949782242392661524488959954348903412713930092273629207697480131360047867213863018127928853922173643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 395 +INSERT INTO num_exp_sub VALUES (9,3,'60302029489319384367663884408140620960.5791215104639085369493197407183130560124286109130354360944260524553172025725325268378015783145476572840273098165721628341015996848028750420770651761919246816300854441592109844750954710317145008297946462099581451150385769713261452744310496166494545449824802407416426304041583975713483424241727236417259479541129474082301376239522310995725648773643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 396 +INSERT INTO num_exp_mul VALUES (9,3,'-3308379209762459471107480259839508279070920437.883503980178028214343751083865562028455061662673132221930429904398963590401793045470444301883103141901787466923883803951815572606105617157736442670792467625964359169270739534412932791178258858918086886061702512427989129732248215348301444245772127142869263635282888226326427510486246184233225114523636171202034558843515894542952126988613018789833835507734620046994907453602573865012044120483116345444810078666601100257620969379968264504287700045822481492526688635364586344704730579892342786173395802035361824932075736340405960099542224953439044947229246847140957298841482874444906129049023002897135347878048572628834749795298712449864571996898774444932083319581439741625832405434317985988163261591679157437224404970927012111196724239860528859217322132733404472897289') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 397 +INSERT INTO num_exp_div VALUES (9,3,'-.000000000000000000000000000000909811507365065002714756487495210579371808512079908127938523896001746219475805196061435010714649189975968123072269549018826343830061696154665503565341929634172463095299662727352635590451263034658630449260378893723785917860125051787451512267088404686342938118993621396641623525252649748977992770709930435013456855344203854749977414354164157192885125263071636468941596567220391082793700307461350484216679632552883058303710297475827456761138832914743429330069022439380297715971317819244718196187172770061156794130040674050533617155253444764036426045091327368023602807193742585178432544430741520636125146531502042579276206322507516332917325631822606079220413965396706334639331097621824106950192993127113903265025719013680733760540930122186345919977470628988674677630636632053583144327') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 398 +INSERT INTO num_exp_add VALUES (9,4,'5329378275943663377078725.59616792993138452386059664269485161374191901124632386474661634799161523147237015531446709484039091244606359050341194730653343894986479159670583937529516163204904273806158788218327396375034882788180783796976731912141525319602448709213495905899041406302673881364465504945113279286939663215197485367850132991968081639290297033476859158044889351836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 399 +INSERT INTO num_exp_sub VALUES (9,4,'-5329378275943663267351764.90246738982122406873613100099999535333648693442749091773779913112021158272634924594106590925279284284556872145100402039378540884544906379809382171355490931218216320693213791113256760721925653394811317969065642404864072442190731745871963413981746671302248281216916486794296983018838956112081135739969615171358100498945955409711817327376172085836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 400 +INSERT INTO num_exp_mul VALUES (9,4,'292388240303165948041827159734686.255558469787242316676287235194652580157149226950109397295920730296960145548003120827363226435916209781396711693581454960342091452830648929118261388933297036933167543189308061917640517578583521401267417187854611829815212778183983326568586118831109538377828156118900313778053576483381085207892754728937946691892849474364477434665960112125254104966566712906532318984871145605839506991591027939136026602051635433295687547552796828217859648186757719639965988287173297286034098497871707197092627676226053609131138590878743560287292934815277894463305001278326023708395571840850120055316276256138004565442099731931051413153564744766098053176049414330146267604802971221161572130161432525297614616942172815141372973870720928125699420370428856022295499447755488148545048400795053604349570217878099721865670458104653570360') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 401 +INSERT INTO num_exp_div VALUES (9,4,'.000000000000000010294536718194523982241053267404812827031741197656209184880073175960433631103885281961037127283726462743623757855378209281373475473018922090781553213750339001555832360656399849031527008437303091226051008068950896796359518673740801770866360774945096397034708173365378527676779736929035450380795854046109380272505550244458858231227568118355064007614608452292270378691774826689216790090661497154742954386244856792006376222923780801296832612827123778915598893970651480451509706836620045721191411824060983487064555397842027454385628620582036592315345973096405447742002746762099231557054678593446667904250189208490698468539396733604833688133512716508825505666644390119877423938820483653319376926639295680552194966870285838815705038244628263602997511842285889300557188773128635554621378148419364876651') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 402 +INSERT INTO num_exp_add VALUES (9,5,'-597892150.08771044822540810796370552966707032464017958269847934730769542644402913723848026909285133109089452632480800168074607090893991283808726990171062867538012237270000932798704781608969096508450960185964292594677356241956277714380500188870696516251767979457838109804726539408115452577436052503866633026489282425086547752714324273565900641436632912781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 403 +INSERT INTO num_exp_sub VALUES (9,5,'707619110.78141098833556856308817117136192658504561165951731229431651264331543278598450117846625251667849259592530287073315399782168794294250299770032264633712037469256688885911649778714039732161560189579333758422588445749233730591792217152212229008169062714458263709952275557558931748845536759606982982654369800245696528893058665897330942472105350178781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 404 +INSERT INTO num_exp_mul VALUES (9,5,'-35812445701642379.972368737320206275515144213236752803936806738624588812089615098329765811617509505790110909629109400553415312470540217508070421816878544125783329593128638405659896184248784794258084116406472768709113030915308410565617764394827427154923321461158387012978726512246146545834669665093228316853342805604075936530371665576147966721599968786161939347726656168798065647411457701453987215491345496003650288850096338695703984042549594979897253521041581573388369367579323607093487743440894765114619634001789457486407909224339065748496715380572175183589195611952939575073075140094901024063428239223964510824958346570603142906309198033196987949067156046076497974760641964978711558209708743776024313916111738542765749928287600981397080809041007714387564206594515733287925008053261840295560398311905155157989225181164097547541') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 405 +INSERT INTO num_exp_div VALUES (9,5,'-.084049034261605466896663277055600903951276881294745183935726262038673990196778002490449355450474227878560465916800470848046625257516764244432096856845087412397406701521972651300484716852035267197801389708234913163750232707469240634303111868882057393120649919262424619226282082184091177505826009374043368623853156698509808569378758387708910629731005691079770517679511879694426434724918004419953301426679939010592502325130576915399009756468717124460489039474155719834555522581553817856854607844133431854471292027873672356863673617090151801474016666978499651970627896504709551656249007718965259502928591648533670568214972768900993459927860068104745163979267716597907297073374689384723943955361288974065531322408839914599555769945298758102515352082822617428033648130099822033393662643586331479103933840387663729387') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 406 +INSERT INTO num_exp_add VALUES (9,6,'54863480.39378734225015137845671346015520435061071252892396685718794832880965812803098645730572474084523997120024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 407 +INSERT INTO num_exp_sub VALUES (9,6,'54863480.29991319786000907666775218153965190979471954789486608982086888806174552071503445206767644474235809840024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 408 +INSERT INTO num_exp_mul VALUES (9,6,'2575131.137912978352131546639620215541477987701194164886305951830806120142596646541302305984776928560906754259789485960991272272782091464270104432109904222200473616116525297615725803495463468272171161659654385929185160689572943852767523792651123455283534072794326647404332228203001469884016996499768656263775233430922446983838511590562929268821678518640501686017030536100955531423152839988008496919169395159653034847677470665418765966542111749439412') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 409 +INSERT INTO num_exp_div VALUES (9,6,'1168873084.346566233232746391559830634361431940000227460271861554316197556566224118756340501278103405856646766537018954185964066240457859194626558143313125824412559635129130086906976028635444060218797992547370132082916380788496584864016645155338102476357490305222392452114945853620686975383081427840791892729407194179236897452655907829255937027286698570784397487382242990326347080472574546312522326038419753951437799831430690304084087684303035538181812523230890783372773953961677974396907303758903934808035747944477277528267001070234880092255363221274303820343225415479126819937070570562654065195009839593938440374000473302075568746771126391307584779249330981594640387657042725725493800876630516005713789705652827210295338592985225924959199657729900181287069808881130884115897407246324220524401243575641227725030779990490') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 410 +INSERT INTO num_exp_add VALUES (9,7,'-818934540016982261.65314972994491977243776717915257186979728396159058352649559139156429817562698954531329940720620096519975256547379603654362598494779213610069399116912987384006656023443527501447464682173445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 411 +INSERT INTO num_exp_sub VALUES (9,7,'818934540126709222.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 412 +INSERT INTO num_exp_mul VALUES (9,7,'-44929599044588573810654775.83678007633232843418115790847152455559258007804727916986432256198687661496804050903769496933400455947645400628259699874770581538122521805603947464462448454681701547899144129061961394870320463199545502030106801911915987309444301341575451240764927967432593181449618816978119423290767783843864768557371257918447461479570164065303599994081990686') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 413 +INSERT INTO num_exp_div VALUES (9,7,'-.000000000066993731076524206362744068866774567920404984046399050881532938231826344009126898802592302273719505485084766150904380671495128604515800845609713368334606489445184535043833069145643553083555507533900955661105251251918425885537513359541698046533092111969478225528665278023069818968531644884466229545497943710817187632203193468836772459599856856811131193744272314519908999458320275710240994009061040198159739169960258978462113813370513611735006229733329565083659159456172425715216475781507996483885669437855000029758892126410922067202159414570164537031153818197618428471046051340835826664787585016361564969663413176434498159140395476980277574789931364078570781760777773379636490084338326576889857824344578398580499610233575273027387501809967324874264742269453420400624883982643066864175851881870402856698') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 414 +INSERT INTO num_exp_add VALUES (9,8,'8551849703.98748751358673528924211852802333963452553842636251612056366144128630740476125273064380199240146487881028508694029546139131732304020786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 415 +INSERT INTO num_exp_sub VALUES (9,8,'-8442122743.29378697347657483411765288632848337412010634954368317355484422441490375601523182127040080681386680920979021788788753447856929293579213610069399116912987384006656023443527501447464682173445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 416 +INSERT INTO num_exp_mul VALUES (9,8,'466174236688165594.9218054325256670866060556227711696100465581464881295978997280335378678072434776702952026828137140986670189756965420183565968027969700090735690246176791371115610886533930223141650377886909408268207750238603105232560663571044993507074695683027062426288270199495225881785499139012931143826099668999261931834700467395442768201666740663642498098541516326470052372008385656719236306238735524802875519713512894448940917708118676095378518264553310312628830009314653641136566040400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 417 +INSERT INTO num_exp_div VALUES (9,8,'.006456816440893715330247418029019114736889626790871612141686117271826070935285769018710680035004320626745647926106882508048159628931624522666638442625219959259156539178378186912871506893482633695438850964052285542425753626455183282159259999492971992739484319464700978750304962671213318202670228197968646486740006148091321740497272644910882302412140576608739962605210964504469426861972705740810533465451230811358870068391007718532021526225893542801514255726272411690175555142385382688220121052891017808391607717500701760375927811435030512071347521837090721052128992926357375527600337655573639413811262412492632491693179011503973930804928749370652038245414768103001067902012962988384812280453070895781287237746786414435546976395632454474312533482077585837153357017362048554313154580576238549196250793055676215164') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 418 +INSERT INTO num_exp_add VALUES (9,9,'109726960.69370054011016045512446564169485626040543207681883294700881721687140364874602090937340118558759806960049486905240792691274803010441572779861201766174025231986687953112944997105070635653109229393369465827911089507277452877411716963341532491917294735000425600147549018150816296268100707103116349627880517820609981140344341623765041830668717266') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 419 +INSERT INTO num_exp_sub VALUES (9,9,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 420 +INSERT INTO num_exp_mul VALUES (9,9,'3010001475769225.8286280957637941018500905354415197182850820227163907782811814730309044010416886791014702373809932926301368137684091094408663914110947072451332976891128659038142954192986392936981664792370678656287232795203974766040821110221158579481177539669363513848425151485663431478439528936592701070340012569297177488556353760756495238304538439278682066056721729656193616571456456325016960870401748115848423105783116854283646624807603476682295234280408938557209608025246638166902335016025467565869375885610813662767004038102486303756741615124814580306266901273803721191779461890468156043551004644728343579032524687612403663816107770451694666844862368101122025340182510019516924578414085461628689') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 421 +INSERT INTO num_exp_div VALUES (9,9,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 422 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 423 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 424 +INSERT INTO num_exp_sqrt VALUES (0,'0') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 425 +INSERT INTO num_exp_sqrt VALUES (1,'291.964716019333021494947753821238960905461614737525349376826064492714634914263808902604580614735501799528494357560837535773816469841426747889103714048646989532842972129124080559131220979335403729022278994440514872845756198274805589586120535745968205107562348427941379641465378272611453955517402598409789621997041856848783989993820946766177453801729783316269310186191833995557234577548740940419224137195404391193633808203715191863638616433190672511651125299379882126530500870287424768024674231651229908224729856278167033444719242144302972892419034855417126978468296581589282861879645409909873113678361180607775255758820910366926076380306290306477790931129670172989289536405788838857428768869345763784112862591549008321546447442552533919976570125718481191724503352619626562352280522949665158335559389298720990302071') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 426 +INSERT INTO num_exp_sqrt VALUES (2,'31541679188064906.712574384704440356216787857626740375004266523720148374188511622980520374202725176835435173058936870163875556102907654264048353814040480579464700545975346621546520503928314632418705230212623378642743044255181848913683862360044189531298446109955034944189751302497670367665492719604026161836224535961347218522748523360100432275693829501972749859329753224444694962089604095212784768854310289429208671271394086829270986183171968944659703708706544668326267327938226750760690620258967209626420981505237183055363540806281098871221581265173394406715458619627534396065960117454160969749739483126059760636526242783235685190739315590041294766649891987044641492234243404608847939002062827210734973778130441825067858641461599799772535304379732674727995848518807202053316225824685704785148921785964036119338754973714515974054') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 427 +INSERT INTO num_exp_sqrt VALUES (3,'7765438138915239878.949520541017683429203286303188179443533225547096446554008374834292278237558244698868300666061834105683999048386497322007336816482648302911579331582895326423063492240235074387242190187374869842856897538718280497895072291181675294000739548676781615025944675912072664211455701112700937190832332966000160156597821149428032612782336278939437593991008833233156511435294360065004167893309428565243314846456225604669764879344135321428948841659419438769652686215993544390780212859309497190065178705035652106614050448518931820975038314187040226298661787490226917902356569717171481159691409131778764973037046501816919243659681416263730519167614043077472097520207347950292377914586524327206547377189493301153212000966249655331053184913579513686655963686155890934436604123384536027235444923674128269748280097789270784333442') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 428 +INSERT INTO num_exp_sqrt VALUES (4,'2308544622905.016172868282330339228589083058636874526727829838244942341440716909466939214393597311710652963849541394758298277969240038668406494621950956862959196896847352631445328917063551082418729435554972200530109505384839391233286173517804321019323644218483570886304028175359854335870835404627608254205407525763332087823548640923282031978903399118139052814618531713327991857575390136755426466065839913887477577516426991104516201265995293600539957187007068885368699949673989051443005684755994465547159213587471972139403333249259808344536605314911144950465968669770276463111776581675944967401948957460097365849699783091843609965345747287667911324039374314413430490112443463386381631812537639503425989372084906324702158112088898424705684574998783112519152403201231176840068666882123684602080460378627639651465436618032671756') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 429 +INSERT INTO num_exp_sqrt VALUES (5,'25549.082770905117529972076915050747181125832857399138345044265535151111965091602789684342996759657333588444489085160336703294705499665424408218434077722506748278242942379566431768762487954917389137120540138359870652558814224523699917122023018717544160579704907452934297025088008618627873220397030397424422097405152321366495319708580932627092620533785271831833326130796638935296720064431288560292191928489034307645738331451165431755179025359993690642194334018457793169983249853388987495489562746304107188105521296156525984787815685365255240654972150342496329030279439124533240114879332406941960563154881888172285475336782757262639979527682925214971861707635327995621436598536743180180978457735632181738067997521785965451385630326464388080990200265186437768409003553910194212076755448477164192901658547251079126833187') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 430 +INSERT INTO num_exp_sqrt VALUES (6,'.216649653115510782473161631235601739254284877523828136703593069337209747459679979369185882839688430004369697316986054374456779366220242645866798278985273820408495361607183119980716020227424205519727777568954933592987351750339481522149106749713967143685591960510946511796062486795368200503801097611436787402191532618456991115230272084771674098613479989808680789347124789253499967359190605681912854639520917409710307182238065185749856554472717209097115325999946728168357936779767099041518574001682560265549916593333117469681763348860131760281253987626822958726920016922608371657319505153308390495179319529587670415367205193280809809356733443291197315823747505896510820272670040485083775482983378341120809542502350385555577946098824446199419354197416933858522419312733314383889554606932774046771497129486979593226') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 431 +INSERT INTO num_exp_sqrt VALUES (7,'904950020.759072496304165474991957396337281699986101765045213964054286624338102141970514306010139529492299343393832200631760194440206005974547202512275476562767685193838576516154915404389465528270010938533075930081897392863141132529694804621418663424569202655893682412466871297412964570322984865326770090075582481194532433411398133265643849129084449161396724635797324126396071308557057830046688990212282866035593809633839882468628249964862932050189148498591642162462777480125024786829078066012617362076651920045684345679767223337287825546294839320770903419463644110383560050404456170063805115223954191445548226706113970164823214416171441655706141596091717118495955441099867737827763335880891937222647408575142200256804313345924443344596462585960919126827045197885802122062165934504665811115031150357820196176799560314653') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 432 +INSERT INTO num_exp_sqrt VALUES (8,'92179.098626752893864900181023972781406074846653380680747862421481598042923358730531575438403865501429843141967819802251116774924400485954931201776260931315313253827346015775662310076094882239170765060649024538403329505426563390044695320714825481746233901773893996663258170360232639353378395244461670781152793416950717050461856097473105730100523010642696332151571372764781034028324977128554099993021459338419164426784774496292405945103200724413639660488309795423335142455569853549710795692020963174011003447023610692365550245567840477105794884132665155376243735213346877116105595296043532605899184658904822980397411096930267453332143879534914237169761039374689145860503772331147367757318826885494994339695470190886515765452545019167989882527248872835783707554463866334705735781549392895480816605355996057201589681125') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 433 +INSERT INTO num_exp_sqrt VALUES (9,'7406.988615277484686670011157489572203134420118818648711986549881046321377798441006745317356200279801348355202517703531020643333388857073977704009782384103170022716610432579974132111487533733493986910583223121269323909760573942980360508642443245341392335557152177332615977623338526935953706604224108508582338123915133189529507760875123300397933931420500010248194253078118618381590347297853307090813639981736227771834732256867579490224181748450683295253634852775448770576585177080941820456051588076218688792321741398867304684922665590162004919486643750098085197190000638539994723704724550600891137853975703823903659121582583388450687255538838161486019214242094423895463814933532217776443473765708693285683261505695170847285063013324823850724236845500162436661946026097459146424122412596018946436589967013641971183281') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 434 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 435 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 436 +INSERT INTO num_exp_ln VALUES (0,'NaN') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 437 +INSERT INTO num_exp_ln VALUES (1,'11.353265918833698201334218522735144514838241118349715803442713722607336732214173255618762341321138898556011520430414052782971985419141860417968593746833898952016980791997105866598425597066404919489902082738711038276194174786383758877067916049129476352925010880025206629976454341252818402788928939407784629386362069592202090897264194883276572978998896242281239126931595483958092059051047739223830394259082355969005503976135238921488192773135287876801394308064862257453262299764712613486466254696464150007113953810688169396432889052881763511661127351872408811370081346456019961324265446884877073712053408327408917588393884214304220369626106333713688792094943405258431214313197283237071070354654837081449831786573831004911008790533179001070424813584405346221388686999574752038655226138085374176702005198770598232862') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 438 +INSERT INTO num_exp_ln VALUES (2,'75.980172429959420723484178622920965327708652620924912610122049843800380131746381968266727388919414524075492921510147435877107720844487333947572033626887969846858337336557672107987074468763307953130616555202495401302128216460637786993535376622372745654109623249396257174895352222213037880060756992073605135503615371392439827458529942230210514752764526895030759481226199720092008002458654297737883219558685499445394647863430593136350562417924068100891680398878483362058595716232013516337079804607378041880078724811071904523716775991447489914128580100888252698281559809224785596795038122963619830942475652745611551345360922016753939774272970008770647516790944335173711498988149783075646985898883858697162003144539047532603946093022417842140993960433780913606807466518632121884254341907122163281927271483110212890483') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 439 +INSERT INTO num_exp_ln VALUES (3,'86.992429107491709045555322727377654177072455841678650084144967727028762699430180506209786297136121512625728883607972513154010138109866327600596617277403558404624813332464431424791338402731178416819791932126837396086742033973404980654712734845137075562739300866280737071167943367603243180515859476717635339619107593771719314284984269343476343816253634799874584843436046260962736006310389088154751401911743739429257286834178656182340416539923956100441369280015412718483971113838923221170027312390404790743389872757674342133486652087007983701950040432125562287337697971646750563062524010514537132255605131615248097901911480464339325353279118429890601202554448469387179349495284716473293965884844451619766312048304583068386805927433174443889441171878078987788018564357316138422561213329104267180509029624308926098065') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 440 +INSERT INTO num_exp_ln VALUES (4,'56.935276817066740776567329017240462885579486075188456418197311631774373422196025180114152248099799048545382060930401786002025479108787121595516444894009593031141335985913019897883627990503003577804436730367402618412514152465206336556967419434371593632864308139215157721913158949066717186782560422199668568894551013785702491365073449320535603830475158258853167712460432995074161536886421366716995573365924430692151761737886552457036412140640821310927642146210426044265504978418405684030862182425702683702307323138985481047994648222224089112998195621687911787785594701557252468626097576375468916953563766801336922479861708649876362257086586679701715813254414915314296890025577780265459584203893089574567331742100451277992780400302806430264717887468808962517029442262560742822875484362427192693300423729233467613910') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 441 +INSERT INTO num_exp_ln VALUES (5,'20.296713391219923821414834924710998522858242536565236229645868008008504475111229451635162536658197320282791428572861452713483981402773630985812066048575864982038046409484905688236579134672910905547858248343712686247795669280482288748331949478864729205285910525962001251260319741279139167559906461672936902355959755164523720443059989357054368460911050707727029320725144824995614445423492687177126412520389766864793826362309254124276325522276592246655562770110024099522184080118637524912964002223613671995639705240767929562023556724031894855094820328152633412077228479168557819219970917880393852962560319397442566813746504969336443969816954424715197797253670026862362130664772772977978222813915593329422557592316429203293264572088112274848838446633519530653849595288125585730314673691986554304725866754516304420665') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 442 +INSERT INTO num_exp_ln VALUES (6,'-3.058947463851998053084898503420969773173569760507671013593014983772013099601022840164736581595033399273677583253456908293015637115395777673836877852797643436458673662566205707359569792482081945396989472318998080581824382006377064185813936544714612287417301161454496258176319380348780934551188852900784476213986897306897793456700682073399936398243222895442594762628402487110466705108765286617060826203345783502301472192906817785365563881556293576463515218574477264521950513789471494214626744754200844840310516235570475410854073969787604451971790833680742315518808178608136598148628107328076871698598743664423452623124027059698038466681488746505289551548778131621576387262707147068500249466398507704796800459013580425992071957391417767257856002976954566094297724379688683375704613872658653366052459242767328235849') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 443 +INSERT INTO num_exp_ln VALUES (7,'41.246780548917246608934265057073076900048579756649769602488660179351587788197892095257027979113051775079905924990472069951828742350559917110289416201523653941731339141666097617614477426376799479821365070373247490598890520285155435501242427296281987676879064510605563522117334502131946383957407685328562874307957108543536378261847119286989184256009392692140821396916222386573424618796707564187152459973446833193743614720624765332006827171872712331032607870580880807058576154429597725560836582655488602546786785520452359711161305828045237044625934404295366273012300148250900116489718279757540843657039519736455668388572899273464839528462223812926410544976290646668870192676914370659142463304861500879195867873346447316374869974900582948166687948531910220128160490935170837209017355954301127162240133341813847180541') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 444 +INSERT INTO num_exp_ln VALUES (8,'22.862977375646110045361670561177818139082238721442691850491173190000619222046296383571431877856442345505931635735363450488731186880557789439424987680284612480261693386095598289519783790826332183796775862215503493910816035128476952347072320869461206895223935484838130924268616681347949695029657753251443811448783435000569829291535036468240771401957519222523032235686030017496209956550934543164421459898155836108824017735809352580723262896259290484291175350770265895317482371895188221452083719817251845416195168686335127805092334984596224320638378502008767433534450949989322562311171685891891122105437154553106840103473941148230953978989145470651955269817951560544095229079088083494695756914405635176899994279484466773598435268700064279990885608144109747858515514066444373797446449729058958270758597627587968112958') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 445 +INSERT INTO num_exp_ln VALUES (9,'17.820358481980064387183481028572263407130633079314879566896470101569251997264841660326428805413719418277889123643557369421967068805165885825106611310020187894256310674762734896979157570968168599492401269694048046876387337971177513661006711375440365724346137980004810780215236524986274043416621637509807126148966029923572853117418545426960105154053049098579812135003711132897895016476695223444397389521434633067499404903493027304737402519428197015899833229473322655155458942323004249812974150129789653469524573801259946118454333405580647485894435301530550214095993989552176497867244278699359917247910082169086524111229983698975613609318418313798992088206507831757327320958918656453341769110558376097374227592021075267882222057385413453949580066342977546145482215220982989992069525148522710254796105001938615214263') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 446 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 447 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 448 +INSERT INTO num_exp_log10 VALUES (0,'NaN') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 449 +INSERT INTO num_exp_log10 VALUES (1,'4.930660740129727276654889314296515979425461685461970306647398411855044094312185293195497201658739777714943974003690119189101973212927970410047992001003936259467465542044528955416040460487922970233600641954269411521809500203864460110903973264337093883907933081597350982496469748131390809569321256206859934619579029279954574676601709408712255490686948453752571699579252140062805776361984468580258289509013081691778727372026090522694670379557247829136504595898935235926069699309392675806881162434168418505908116911054206058735257796918687777716036307205415038158583184624809880157060625643069601549803887864772092583549388533013233603450097615537162442973385137488450178790573546382354482351187412256794374383453695483855501587939419102008302408157959291557415763034668013452188944554607063362933134950906875499201') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 450 +INSERT INTO num_exp_log10 VALUES (2,'32.997769620388965086774969704518222090258389987679691893351902336370051104718852164011301929506188893338106627980171059175447833290713847317665944354651476245003161501753612545484635275306181777040447675475670149066399611203341262105766118892586541910243351018829302798733989560900125591073082441126709911019648451232244139674063434385451279378543163944005973452562993913383659295688375546058256196254319767218634546732685705517341998116744642480938405113447415486950667007645850519659606476727681944251201236366198374488204017630268083077471516734133869728427050843306716313813724061560369884508660845630727190444623729815564381063131729592825825486515070406390371638817503915214206586939112681762984038333298146999891250107667687034785493312416966635780188163871680959873288697497561452228182734430749066579749') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 451 +INSERT INTO num_exp_log10 VALUES (3,'37.780331928743475574895606142114739140772838801045013007323050327909196792739138159615327729728110344767302636436234256468332011934881494997184865617793179255006442447189720642997935223133982347184994174261506212652322213673745795726283311685835974151422721233207287206894148660531800622455957268888702309499182978182878524951883775154983702898237404558813230370364953160102391101897560104513279410610948028599674950811462114131673380477843456965645417025376374320207504913806546872166094337441573669261285052323206348035827948287081776955945081345131570610652073053464020209215624179904586956137079321655773178387441622685682721151900601340680061607114354850640946256225260430676099781727317540719923791064452012925902993317349390523278687089530234444415688602090547516647302454865526291471706301790881694022223') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 452 +INSERT INTO num_exp_log10 VALUES (4,'24.726676547286224970759328746582840552419566534667446425423046931401641497155587075591229106937829957279943690528061985864558314570189069764367933957499905044566413640017549478921384160584906257607957223101377816440084188042395098536074479064548620374152344954289432050971466476174493306432228880930006524504974367146536665170956555486181410864034862861231267121149652317599303804477688621597163730470970207231328339082779056152481480926452142005969020950341307977091850953883445808399574256295803245530993204179747743812544604144379381347499056545148243304041538981954204310612049423688645476667184129189153715486929216331980316967699254518020077226689317148303152585009031597809279387172427408557115400021035692880631275593381822805377317270568779655383061987766693697518921188619814204902583361096973421134004') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 453 +INSERT INTO num_exp_log10 VALUES (5,'8.814750626578650238811431417807018895270298639823442501111235973209197727215795256506525221092818797578008152140054383421240180435087611869193019443372556081555311825248667278358330916098378127100899126895012782320751838528480712942601038190627182482614147263228588284866661508052724762701223357327343090598060805245853527435948381893458352744679795853650453594546267600486696643924152372736774331080527157374379043696696647158270918245668579680394279565181670004245143555617589138267976417280970718829942998800499312890580011246294669585429723974582350357991472101919333996770115834067969654217063942059882195268353998096891812525364797586486311202350700339609637274043915687880562465121559531284337603363356183320193656553931871200575467929714875483123706358278876389849119105053294688326141759401230994901405') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 454 +INSERT INTO num_exp_log10 VALUES (6,'-1.328484003982869642690619298690906747763234110040562640557173509402512757735587333095924652711056556491908059708986413635120656426593745303715671199761364516107844087845783714418487426723538440387069985879601248897538855843115404484229652166941838283489828419407478748732927617251897244190697443966424660881366993754577233476597163021768156814527570512834684713730559883782625870597080940193303268818336816535968869931456641949301731046034660616615392129109391145214470757259042172416816936479713743188047425796931722546185493217275537303458837771965375448968719169174136287532752370175863826715450565025635651343928205805494319778539652563499901671319955144823432132740582617949774638538594081514904904341299199113721131520557004571803778698005652464301037962272085633628653321081368256925971558076970172779715') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 455 +INSERT INTO num_exp_log10 VALUES (7,'17.913249188669140643510654105014358282516966474257460687880559542190804665566625978925406311113121982595279826214959603627387555578965653325278444455875162277940655989601428868642914577248262147833499137348602966573601719040813549936948178463592211685237720748377879836890106515699728652218324794927458352954247096536337594789471529493944292143186953509162522579060020018226817623648563806559917579317916242706559131476179714031602207057714677845347616752450567251644277767418397621490301286115159509360375419599968738067461569666699939732107480135216621373057421990702923042287910730395998082514702629760389192370666675364405730936537832803383367187639209534697198515928978064543150195911463663617683085348965065679311986715357338675515370634753254774665197233934933271954463040729779956682570415317734489164385') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 456 +INSERT INTO num_exp_log10 VALUES (8,'9.929264914121995501917993119394933531225401243275938207624866270551448544301376913376130982251708700134720886862945040266148728213253651323129942781577143957084726727561987639140151337848818195806259935747329665025823709044567138449084349729747202164413995795609659711723455165142329822773177102845804114214340046404641970845707372809306219463962664551623665322610139794354769767829380018857313559373283673392337954610346290037758389035140213224696023751541663171574697035012610534455189013755134090933979479069288110010954211669067225249755249337768792642303351914884187159646984708862430789018895140670365476746734456807215043628059581947593694929159076346249490593187993386780521089745819640214783614157516171005086731241769146397577246387886107367648843380733370112546792442909347322732196805316614555689762') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 457 +INSERT INTO num_exp_log10 VALUES (9,'7.739283354261751283625223433456284905560931805428759681411970457812279544250432389511382263439324085689734710188041049046660480575958686859942980599595036769090747781359217248301544587434077376812293034848418204834388504169166350770257248896025815531248627658465029806509131631454856186387892627989218208026727504548130018922325585619738185507999433763118148418722504204066578294826264005398891049629199412773138457218976050467479292777172717500219850781664314597312411301296201533610562886229900497272268364496763758868455934979903774531992886483396489868888731578355541611359130188566524240259770918423445785338175040098706500034487703124623745259139247432324145633151895802637182446905097253961951018926565652497920605819785424451050191604602898777804133717341512568151920576684198443843944721398831404081859') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 458 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 459 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 460 +INSERT INTO num_exp_power_10_ln VALUES (0,'NaN') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 461 +INSERT INTO num_exp_power_10_ln VALUES (1,'225561990715.277245515991117670624124484084762557459065170589803293759247930753528436379932442146759103295277479258327642314622036941865221478746258727236601688778946696303277607709407496616423493315166963938393760548678730128692212077086588682984700837334554241405763691119669847463520746595280034536307041368063462023793177898200220207765205127584303464304601759554817607633012272490650155253979182893585119965271975927569080191838676053084168631217591768468344106219831174026139608715965691941366334940196517120885214887008671956523579678156919416435031020452971977153991139145404842034138317592877675821045409772456977018293365238179815614004574330200783530118851005077771478448804470170641452481992602803877112958872108069738434946694089025321283178188028224338756015337492913115267362635647236447601252924834642796058') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 462 +INSERT INTO num_exp_power_10_ln VALUES (2,'9553718264533556311125292459627965006385666643531070061102266984368939757379.536714147420215784125170401370065894858487440153494392538261078415409784085960333028254155527328359894197540839556987826344995348426293585457768226283066583722499658006242709930685932246087653832230889613022921575445199055131152661556678809191264086381976922223866204038615136758192929883317207903579770917317641181652055458721731297347443662717939116561947785705140374908203404860090658919334137955075887697259604047657534191202566335372150375993361370075961180728155127447781364264047857624746079509591666068708743260905728661917791822925979235918475633100283148558978385583805341715868143937062092264994833222352433299015979561976964779350640064096690062929265992966564232453102431600199173711947391200249130712039686700111791790265309426741120465259677894665532560198051256215915373145226284270408649736509') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 463 +INSERT INTO num_exp_power_10_ln VALUES (3,'982718444846268846508445482774217796844461660819285525931206164100817251856409365450682.362683768066405322653747385034480250394145008573806022660379219602846285813744865438912887625784087005970975437905783802114553690522787857272953842288090141945268495451006273685577260054069522075046955466204804067271437138871789034722069934693546671607506851844248427950939791205412350536883779850165603116191193657054604569586553874805856647223849267039531773072343908345333155562072887754900969504551717514980465801806565999410206735831440712124661645970935112535081991606671600328471264697018198676317466846450405861359235297846597981143547119390922405594115478086038680663368675222949247096131378724350715530605691796680604309063173515781378545860473572389718345696107553363715518601596249508215455106779522851210398208919496668879040223859884166805448827948087400426315425231119801173387715922086154065273') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 464 +INSERT INTO num_exp_power_10_ln VALUES (4,'861542720105376650266753999919217194383259935058507531116.774511336660822591851369622743235084609149542494189385785321912210129989390054947787009383210009523204976629456268332186620016067379702483800883493431423160815760933380418976582725913410929214462739708321325884209636272001805871036779154087677637129248122540412937033791526383240502286607736226090213753913654673523613612439527815137888202973659987501649474772884055648603290154867585312925699571949539600328906295652872654314913539778815035321695215634102441494403825526533235061083947035338872599854931230001361227174477274708230470794066733245241594719912710139298949856243576688344051439047966427547889756037265151798639614843866387316916203238068277912991427278268083231579195846744438643659745041780103653332041031419793815914447232121937821142169172566753399257291244398531365781832297786941359729799400') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 465 +INSERT INTO num_exp_power_10_ln VALUES (5,'198021976607570296508.271597639984889464620426933601643322058775615235389194561064983706229795978402690473201671702614911129095149240715527556855309177671128442458698638704394974473956869419481315262823632891676087912529523219333012290621046361106033860210270638559271706082115529424772192777643046125905852037759566224116373416253787241195450409652089019290072319861181399387753223422998872180810295299831487867222464355713552301775702554189470264147325049133532522718679336524769566984150923939420759804463781082299907043016120177416779442865059261387111806785876531152192378576258351599534512031062777609734092707165605364139201322351960602280089186180302246827234844736393745487324460438448807241887783263546165171099497316415863122023114646876909575845860402164818094500541234974716577550807551946414081410743197768993152975501') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 466 +INSERT INTO num_exp_power_10_ln VALUES (6,'.000873076977206566818052116526263730226812004454463281371489634779519089200224205946321120805055212090024554381349223642352209212670470260295303361873760972918129853308169576675500721645609379420329169271088810484607337679253503247351324049221970104335289487989027621978310506220905131150125321713385148268584530413680037620544212746920563790371941626294733473967065607791756894237438288480748407449237446113996117912144587258434808327522518688617394025018756570740098795745692805352377041347367240475846033282850136270250633825482156304826383360291164928049344226886150285595932088884965511963310715773499733217615863523253012606066583814112265708693122563204149232245895551314975524172504103194858904869273185785182598234060315036187756490539352752560361560286717869643902435677448962235275054804452967413005') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 467 +INSERT INTO num_exp_power_10_ln VALUES (7,'176514565873872717825163931126806100435750.096278384530154766967061948052237623936423931849868926020451465515367348890410352640552194499619062823622476972850692557798609619250753020363520533767813563613425606228355802781302735485038377521515850536680425059519814786118919994914180918228654298075183514200191737597656810036850772127169441661576862538643715648802139886576391427423689320082366572297580054381937437005879583216745596935643579262248665490169331304003204939561361718554509909313409421397022626924406091551900222555950699170864234411017062042057683304265485826061096835531732950909546314722726990314852356462874701181085379772134121978510387397276859318242238150439474660772561390798432890789762504242822787017140808209820627435991445529404692793744568204608385843245177656436105160780897472099970336514833257055017279707999437302548655364559') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 468 +INSERT INTO num_exp_power_10_ln VALUES (8,'72941951052009383458167.300747500436981484566111756088702608000390737594784514635592222758882092500858797317505303492923829092720870826490477962201959426813271424853341826896270963213736922458746003100613943600855942721319226948714369219316345322636075285343544788982588956431405042577296229122673590336976893594798942025893296105815818487227300314490440902574022885833779324177053242170024559675073866612316965636832258283516275906085642459351367507561963945012828379111856700009391438637054015804558386733558956649061672420804826896303889067785497738203077050774825608647969196321506624991188638449047860249367840775936911749905927108478444112230174584693363226143549933224252679398881354887872642908328737917862751077365602631600279486028043329404269490375935308156815477700961014566228692743960491745353377403533037122586797765130') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 469 +INSERT INTO num_exp_power_10_ln VALUES (9,'661239032819374816.097553651299556484820492272269662685578275493609248662925676004753503494252951243895572437264999063878330704584509915845096232798927524470286655554736724913758600775591269525423912692080421094644542553026831758426157681271572808657664918053119324646138457659418857926209701677786068580819823633713337632456905824562235373422309621872998037966404189020165296080436871220718574009921789858751384547836431858428729570977259373272041837411903005303672798845573379758630607982213326716018594073712340609488043353995410508475153538231445235003980586600882223782814368245305160648543466496726973755388826656879616734762068443462618454921858705377028522664844761719759342490380417060255776725333319537746890406213693117052223545525717132695297770810635066731941724108167146710297146989770382041617889670713111888375717') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 470 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 471 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +== 472 +INSERT INTO num_data VALUES (0, '0') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 473 +INSERT INTO num_data VALUES (1, '85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 474 +INSERT INTO num_data VALUES (2, '-994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 475 +INSERT INTO num_data VALUES (3, '-60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 476 +INSERT INTO num_data VALUES (4, '5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 477 +INSERT INTO num_data VALUES (5, '-652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 478 +INSERT INTO num_data VALUES (6, '0.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 479 +INSERT INTO num_data VALUES (7, '-818934540071845742') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 480 +INSERT INTO num_data VALUES (8, '8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 481 +INSERT INTO num_data VALUES (9, '054863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 482 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +== 483 +-- ****************************** +-- * Create indices for faster checks +-- ****************************** + +CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add (id1, id2) +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: IndexStmt +== 484 +CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub (id1, id2) +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: IndexStmt +== 485 +CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div (id1, id2) +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: IndexStmt +== 486 +CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul (id1, id2) +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: IndexStmt +== 487 +CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt (id) +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: IndexStmt +== 488 +CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln (id) +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: IndexStmt +== 489 +CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 (id) +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: IndexStmt +== 490 +CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln (id) +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: IndexStmt +== 491 +VACUUM ANALYZE num_exp_add +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: VacuumStmt +== 492 +VACUUM ANALYZE num_exp_sub +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: VacuumStmt +== 493 +VACUUM ANALYZE num_exp_div +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: VacuumStmt +== 494 +VACUUM ANALYZE num_exp_mul +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: VacuumStmt +== 495 +VACUUM ANALYZE num_exp_sqrt +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: VacuumStmt +== 496 +VACUUM ANALYZE num_exp_ln +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: VacuumStmt +== 497 +VACUUM ANALYZE num_exp_log10 +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: VacuumStmt +== 498 +VACUUM ANALYZE num_exp_power_10_ln +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: VacuumStmt +== 499 +-- ****************************** +-- * Now check the behaviour of the NUMERIC type +-- ****************************** + +-- ****************************** +-- * Addition check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 500 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +== 501 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_add" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 502 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 503 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 504 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 10) as expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 10) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_add" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 505 +-- ****************************** +-- * Subtraction check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 506 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +== 507 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sub" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 508 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 509 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 510 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 40) + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 40) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sub" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 511 +-- ****************************** +-- * Multiply check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 512 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +== 513 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_mul" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 514 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 515 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 516 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 30) as expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 30) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_mul" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 517 +-- ****************************** +-- * Division check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 518 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val / t2.val + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FILTER: schema="" table="t2" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 519 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_div" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 520 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 521 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val / t2.val, 80) + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t2" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 522 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 80) as expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 80) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_div" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 523 +-- ****************************** +-- * Square root check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 524 +INSERT INTO num_result SELECT id, 0, SQRT(ABS(val)) + FROM num_data +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 525 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_sqrt t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sqrt" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 526 +-- ****************************** +-- * Natural logarithm check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 527 +INSERT INTO num_result SELECT id, 0, LN(ABS(val)) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 528 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_ln" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 529 +-- ****************************** +-- * Logarithm base 10 check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 530 +INSERT INTO num_result SELECT id, 0, LOG('10'::numeric, ABS(val)) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 531 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_log10 t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_log10" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 532 +-- ****************************** +-- * POW(10, LN(value)) check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +== 533 +INSERT INTO num_result SELECT id, 0, POW(numeric '10', LN(ABS(round(val,1000)))) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="pow" function="pow" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +== 534 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_power_10_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_power_10_ln" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +== 535 +|-- +-- Test code path for raising to integer powers +|-- + +-- base less than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of POW(): +|-- +-- for p in {-20..20} +-- do +-- b="0.084738" +-- r=$(bc -ql <<< "scale=500 ; $b^$p" | head -n 1) +-- echo "($b, $p, $r)," +-- done + +WITH t(b, p, bc_result) AS (VALUES +(0.084738, -20, 2744326694304960114888.785913), +(0.084738, -19, 232548755422013710215.445941), +(0.084738, -18, 19705716436950597776.236458), +(0.084738, -17, 1669822999434319754.362725), +(0.084738, -16, 141497461326065387.345189), +(0.084738, -15, 11990211877848128.792857), +(0.084738, -14, 1016026574105094.737649), +(0.084738, -13, 86096059836517.517879), +(0.084738, -12, 7295607918426.821430), +(0.084738, -11, 618215223791.651994), +(0.084738, -10, 52386321633.657007), +(0.084738, -9, 4439112122.5928274), +(0.084738, -8, 376161483.04427101), +(0.084738, -7, 31875171.750205437), +(0.084738, -6, 2701038.3037689083), +(0.084738, -5, 228880.58378476975), +(0.084738, -4, 19394.882908753819), +(0.084738, -3, 1643.4835879219811), +(0.084738, -2, 139.26551227333284), +(0.084738, -1, 11.801080979017678), +(0.084738, 0, 1), +(0.084738, 1, .084738), +(0.084738, 2, .007180528644), +(0.084738, 3, .000608463636235272), +(0.084738, 4, .00005155999160730448), +(0.084738, 5, .000004369090568819767), +(0.084738, 6, .0000003702279966206494), +(0.084738, 7, .00000003137237997764059), +(0.084738, 8, .000000002658432734545308), +(0.084738, 9, .0000000002252702730599003), +(0.084738, 10, .00000000001908895239854983), +(0.084738, 11, .000000000001617559648348316), +(0.084738, 12, .0000000000001370687694817396), +(0.084738, 13, .00000000000001161493338834365), +(0.084738, 14, .0000000000000009842262254614642), +(0.084738, 15, .00000000000000008340136189315355), +(0.084738, 16, .000000000000000007067264604102046), +(0.084738, 17, .0000000000000000005988658680223991), +(0.084738, 18, .00000000000000000005074669592448206), +(0.084738, 19, .000000000000000000004300173519248761), +(0.084738, 20, .0000000000000000000003643881036741015)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +== 536 +-- base greater than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of POW(): +|-- +-- for p in {-20..20} +-- do +-- b="37.821637" +-- r=$(bc -ql <<< "scale=500 ; $b^$p" | head -n 1) +-- echo "($b, $p, $r)," +-- done + +WITH t(b, p, bc_result) AS (VALUES +(37.821637, -20, .00000000000000000000000000000002787363175065101), +(37.821637, -19, .000000000000000000000000000001054226381944797), +(37.821637, -18, .00000000000000000000000000003987256753373947), +(37.821637, -17, .000000000000000000000000001508045775519079), +(37.821637, -16, .00000000000000000000000005703675990106610), +(37.821637, -15, .000000000000000000000002157223628634278), +(37.821637, -14, .00000000000000000000008158972901002847), +(37.821637, -13, .000000000000000000003085857113545666), +(37.821637, -12, .0000000000000000001167121675823920), +(37.821637, -11, .000000000000000004414245235784397), +(37.821637, -10, .0000000000000001669539809368169), +(37.821637, -9, .000000000000006314472862697207), +(37.821637, -8, .0000000000002388237004592846), +(37.821637, -7, .000000000009032703305767796), +(37.821637, -6, .0000000003416316255594496), +(37.821637, -5, .00000001292106732962942), +(37.821637, -4, .0000004886959181938034), +(37.821637, -3, .00001848327962130773), +(37.821637, -2, .0006990678924065984), +(37.821637, -1, .02643989206495742), +(37.821637, 0, 1), +(37.821637, 1, 37.821637), +(37.821637, 2, 1430.476225359769), +(37.821637, 3, 54102.952532687378), +(37.821637, 4, 2046262.2313195326), +(37.821637, 5, 77392987.319777394), +(37.821637, 6, 2927129472.7542235), +(37.821637, 7, 110708828370.511632), +(37.821637, 8, 4187189119324.792454), +(37.821637, 9, 158366346921451.985294), +(37.821637, 10, 5989674486279224.500736), +(37.821637, 11, 226539294168214309.708325), +(37.821637, 12, 8568086950266418559.993831), +(37.821637, 13, 324059074417413536066.149409), +(37.821637, 14, 12256444679171401239980.310926), +(37.821637, 15, 463558801566202198479885.206986), +(37.821637, 16, 17532552720991931019508170.100286), +(37.821637, 17, 663109844696719094948877928.067252), +(37.821637, 18, 25079899837245684700124994552.671731), +(37.821637, 19, 948562867640665366544581398598.127577), +(37.821637, 20, 35876200451584291931921101974730.690104)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +== 537 +|-- +-- Tests for raising to non-integer powers +|-- + +-- base less than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of POW(): +|-- +-- for n in {-20..20} +-- do +-- b="0.06933247" +-- p="$n.342987" +-- r=$(bc -ql <<< "scale=500 ; e($p*l($b))" | head -n 1) +-- echo "($b, $p, $r)," +-- done + +WITH t(b, p, bc_result) AS (VALUES +(0.06933247, -20.342987, 379149253615977128356318.39406340), +(0.06933247, -19.342987, 26287354251852125772450.59436685), +(0.06933247, -18.342987, 1822567200045909954554.65766042), +(0.06933247, -17.342987, 126363085720167050546.86216560), +(0.06933247, -16.342987, 8761064849800910427.02880469), +(0.06933247, -15.342987, 607426265866876128.15466179), +(0.06933247, -14.342987, 42114363355427213.14899924), +(0.06933247, -13.342987, 2919892833909256.59283660), +(0.06933247, -12.342987, 202443382310228.51544515), +(0.06933247, -11.342987, 14035899730722.44924025), +(0.06933247, -10.342987, 973143597003.32229028), +(0.06933247, -9.342987, 67470449244.92493259), +(0.06933247, -8.342987, 4677892898.16028054), +(0.06933247, -7.342987, 324329869.02491071), +(0.06933247, -6.342987, 22486590.914273551), +(0.06933247, -5.342987, 1559050.8899661435), +(0.06933247, -4.342987, 108092.84905705095), +(0.06933247, -3.342987, 7494.3442144625131), +(0.06933247, -2.342987, 519.60139541889576), +(0.06933247, -1.342987, 36.025248159838727), +(0.06933247, 0.342987, .40036522320023350), +(0.06933247, 1.342987, .02775830982657349), +(0.06933247, 2.342987, .001924552183301612), +(0.06933247, 3.342987, .0001334339565121935), +(0.06933247, 4.342987, .000009251305786862961), +(0.06933247, 5.342987, .0000006414158809285026), +(0.06933247, 6.342987, .00000004447094732199898), +(0.06933247, 7.342987, .000000003083280621074075), +(0.06933247, 8.342987, .0000000002137714611621997), +(0.06933247, 9.342987, .00000000001482130341788437), +(0.06933247, 10.342987, .000000000001027597574581366), +(0.06933247, 11.342987, .00000000000007124587801173530), +(0.06933247, 12.342987, .000000000000004939652699872298), +(0.06933247, 13.342987, .0000000000000003424783226243151), +(0.06933247, 14.342987, .00000000000000002374486802900065), +(0.06933247, 15.342987, .000000000000000001646290350274646), +(0.06933247, 16.342987, .0000000000000000001141413763217064), +(0.06933247, 17.342987, .000000000000000000007913703549583420), +(0.06933247, 18.342987, .0000000000000000000005486766139403860), +(0.06933247, 19.342987, .00000000000000000000003804110487572339), +(0.06933247, 20.342987, .000000000000000000000002637483762562946)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +== 538 +-- base greater than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of POW(): +|-- +-- for n in {-20..20} +-- do +-- b="27.234987" +-- p="$n.230957" +-- r=$(bc -ql <<< "scale=500 ; e($p*l($b))" | head -n 1) +-- echo "($b, $p, $r)," +-- done + +WITH t(b, p, bc_result) AS (VALUES +(27.234987, -20.230957, .000000000000000000000000000009247064512095633), +(27.234987, -19.230957, .0000000000000000000000000002518436817750859), +(27.234987, -18.230957, .000000000000000000000000006858959399176602), +(27.234987, -17.230957, .0000000000000000000000001868036700701026), +(27.234987, -16.230957, .000000000000000000000005087595525911532), +(27.234987, -15.230957, .0000000000000000000001385605980094587), +(27.234987, -14.230957, .000000000000000000003773696085499835), +(27.234987, -13.230957, .0000000000000000001027765638305389), +(27.234987, -12.230957, .000000000000000002799118379829397), +(27.234987, -11.230957, .00000000000000007623395268611469), +(27.234987, -10.230957, .000000000000002076230710364949), +(27.234987, -9.230957, .00000000000005654611640579014), +(27.234987, -8.230957, .000000000001540032745212181), +(27.234987, -7.230957, .00000000004194277179542807), +(27.234987, -6.230957, .000000001142310844592450), +(27.234987, -5.230957, .00000003111082100243440), +(27.234987, -4.230957, .0000008473028055606278), +(27.234987, -3.230957, .00002307628089450723), +(27.234987, -2.230957, .0006284822101702527), +(27.234987, -1.230957, .01711670482371810), +(27.234987, 0.230957, 2.1451253063142300), +(27.234987, 1.230957, 58.422459830839071), +(27.234987, 2.230957, 1591.1349340009243), +(27.234987, 3.230957, 43334.539242761031), +(27.234987, 4.230957, 1180215.6129275865), +(27.234987, 5.230957, 32143156.875279851), +(27.234987, 6.230957, 875418459.63720737), +(27.234987, 7.230957, 23842010367.779367), +(27.234987, 8.230957, 649336842420.336290), +(27.234987, 9.230957, 17684680461938.907402), +(27.234987, 10.230957, 481642042480060.137900), +(27.234987, 11.230957, 13117514765597885.614921), +(27.234987, 12.230957, 357255344113366461.949871), +(27.234987, 13.230957, 9729844652608062117.440722), +(27.234987, 14.230957, 264992192625800087863.690528), +(27.234987, 15.230957, 7217058921265161257566.469315), +(27.234987, 16.230957, 196556505898890690402726.443417), +(27.234987, 17.230957, 5353213882921711267539279.451015), +(27.234987, 18.230957, 145794710509592328389185797.837767), +(27.234987, 19.230957, 3970717045397510438979206144.696206), +(27.234987, 20.230957, 108142427112079606637962972621.121293)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +== 539 +-- Inputs close to overflow +|-- +-- bc(1) results computed with a scale of 2700 and truncated to 4 decimal +-- places. + +WITH t(b, p, bc_result) AS (VALUES +(0.12, -2829.8369, 58463948950011752465280493160293790845494328939320966633018493248607815580903065923369555885857984675501574162389726507612128133630191173383130639968378879506624785786843501848666498440326970769604109017960864573408272864266102690849952650095786874354625921641729880352858506454246180842452983243549491658464046163869265572232996388827878976066830374513768599285647145439771472435206769249126377164951470622827631950210853282324510655982757098065657709137845327135766013147354253426364240746381620690117663724329288646510198895137275207992825719846135857839292915100523542874885080351683587865157015032404901182924720371819942957083390475846809517968191151435281268695782594904484795360890092607679215675240583291240729468370895035823777914792823688291214492607109455017754453939895630226174304357121900605689015734289765672740769194115142607443713769825894380064727556869268488695795705030158832909348803019429370973064732712469794182891757241046263341655894972953512257981661670321890336672832647028099324621932563236459127918144141230217523147304565594514812518826936144181257723061181656522095236928347413997136815409159361412494284201481609684892562646522086577634100783077813105675590737823924220663206479031113753135119759722725207724879578900186075841393115040465401462266086907464970054073340036852442184414587772177753008511913377364966775792477387717262694468450099866775550614257191941835797445874557362115814601886902749237439492398087966544817154173072811937702110580330775581851211123491341435883319798273456296794954514173820352334127081705706502510709179711510240917772628308487366740741280043704807717608366220401933596364641284631036907635403895053036499618723044314773148779735006542501244942039455169872946018271985844759209768927953340447524637670938413827595013338859796135512187473850161303598087634723542727044978083220970836296653305188470017342167913572166172051819741354902582606590658382067039498769674611071582171914886494269818475850690414812481252963932223686078322390396586222238852602472958831686564971334200490182175112490433364675164900946902818404704835106260174052265784055642968397240262737313737007322288203637798365320295080314524864099419556398713380156353062937736280885716820226469419928595465390700629307079710611273715705695938635644841913194091407807776191951797748706106000922803167645881087385311847268311361092838264814899353459146959869764278464187826798546290981492648723002412475976344071283321798061003719251864595518596639432393032991023409676558943539937377229130132816883146259468718344018277257037013406135980469482324577407154032999045733141275895.3432), +(1.2, 32908.8896, 58463467728170833376633133695001863276259293590926929026251227859007891876739460057725441400966420577009060860805883032969522911803372870882799865787473726926215148161529632590083389287080925059682489116446754279752928005457087175157581627230586554364417068189211136840990661174760199073702207450133797324318403866058202372178813998850887986769280847189341565507156189065295823921162851958925352114220880236114784962150135485415106748467247897246441194126125699204912883449386043559785865023459356275014504597646990160571664166410683323036984805434677654413174177920726210827006973855410386789516533036723888687725436216478665958434776205940192130053647653715221076841771578099896259902368829351569726536927952661429685419815305418450230567773264738536471211804481206474781470237730069753206249915908804615495060673071058534441654604668770343616386612119048579369195201590008082689834456232255266932976831478404670192731621439902738547169253818323045451045749609624500171633897705543164388470746657118050314064066768449450440405619135824055131398727045420324382226572368236570500391463795989258779677208133531636928003546809249007993065200108076924439703799231711400266122025052209803513232429907231051873161206025860851056337427740362763618748092029386371493898291580557004812947013231371383576580415676519066503391905962989205397824064923920045371823949776899815750413244195402085917098964452866825666226141169411712884994564949174271056284898570445214367063763956186792886147126466387576513166370247576466566827375268334148320298849218878848928271566491769458471357076035396330179659440244425914213309776100351793665960978678576150833311810944729586040624059867137538839913141142139636023129691775489034134511666020819676247950267220131499463010350308195762769192775344260909521732256844149916046793599150786757764962585268686580124987490115873389726527572428003433405659445349155536369077209682951123806333170190998931670309088422483075609203671527331975811507450670132060984691061148836994322505371265263690017938762760088575875666254883673433331627055180154954694693433502522592907190906966067656027637884202418119121728966267936832338377284832958974299187166554160783467156478554899314000348357280306042140481751668215838656488457943830180819301102535170705017482946779698265096226184239631924271857062033454725540956591929965181603262502135610768915716020374362368495244256420143645126927013882334008435586481691725030031204304273292938132599127402133470745819213047706793887965197191137237066440328777206799072470374264316425913530947082957300047105685634407092811630672103242089966046839626911122.7149)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +== 540 +|-- +-- Tests for EXP() +|-- + +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of EXP(): +|-- +-- for n in {-20..20} +-- do +-- x="$n.29837" +-- r=$(bc -ql <<< "scale=500 ; e($x)" | head -n 1) +-- echo "($x, $r)," +-- done + +WITH t(x, bc_result) AS (VALUES +(-20.29837, .000000001529431101152222), +(-19.29837, .000000004157424770142192), +(-18.29837, .00000001130105220586304), +(-17.29837, .00000003071944485366452), +(-16.29837, .00000008350410872606600), +(-15.29837, .0000002269877013517336), +(-14.29837, .0000006170165438681061), +(-13.29837, .000001677224859055276), +(-12.29837, .000004559169856609741), +(-11.29837, .00001239310857408049), +(-10.29837, .00003368796183504298), +(-9.29837, .00009157337449401917), +(-8.29837, .0002489222398577673), +(-7.29837, .0006766408013046928), +(-6.29837, .001839300394580514), +(-5.29837, .004999736839665763), +(-4.29837, .01359069379834070), +(-3.29837, .03694333598818056), +(-2.29837, .1004223988993283), +(-1.29837, .2729763820983097), +(0.29837, 1.3476603299656679), +(1.29837, 3.6633205858807959), +(2.29837, 9.9579377804197108), +(3.29837, 27.068481317440698), +(4.29837, 73.579760889182206), +(5.29837, 200.01052696742555), +(6.29837, 543.68498095607070), +(7.29837, 1477.8890041389891), +(8.29837, 4017.3188244304487), +(9.29837, 10920.204759575742), +(10.29837, 29684.194161006717), +(11.29837, 80690.005580314652), +(12.29837, 219338.17590722828), +(13.29837, 596222.97785597218), +(14.29837, 1620702.0864156289), +(15.29837, 4405525.0308492653), +(16.29837, 11975458.636179032), +(17.29837, 32552671.598188404), +(18.29837, 88487335.673150406), +(19.29837, 240533516.60908059), +(20.29837, 653837887.33381570)) +SELECT x, bc_result, exp(x), exp(x)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="exp" function="exp" schema="" ctx=Call +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +== 541 +|-- +-- Tests for LN() +|-- + +-- input very small +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(10^-$p)" | head -n 1) +-- echo "('1.0e-$p', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e-1', -2.3025850929940457), +('1.0e-2', -4.6051701859880914), +('1.0e-3', -6.9077552789821371), +('1.0e-4', -9.2103403719761827), +('1.0e-5', -11.512925464970228), +('1.0e-6', -13.815510557964274), +('1.0e-7', -16.118095650958320), +('1.0e-8', -18.420680743952365), +('1.0e-9', -20.723265836946411), +('1.0e-10', -23.025850929940457), +('1.0e-11', -25.328436022934503), +('1.0e-12', -27.631021115928548), +('1.0e-13', -29.933606208922594), +('1.0e-14', -32.236191301916640), +('1.0e-15', -34.5387763949106853), +('1.0e-16', -36.84136148790473094), +('1.0e-17', -39.143946580898776628), +('1.0e-18', -41.4465316738928223123), +('1.0e-19', -43.74911676688686799634), +('1.0e-20', -46.051701859880913680360), +('1.0e-21', -48.3542869528749593643778), +('1.0e-22', -50.65687204586900504839581), +('1.0e-23', -52.959457138863050732413803), +('1.0e-24', -55.2620422318570964164317949), +('1.0e-25', -57.56462732485114210044978637), +('1.0e-26', -59.867212417845187784467777822), +('1.0e-27', -62.1697975108392334684857692765), +('1.0e-28', -64.47238260383327915250376073116), +('1.0e-29', -66.774967696827324836521752185847), +('1.0e-30', -69.0775527898213705205397436405309), +('1.0e-31', -71.38013788281541620455773509521529), +('1.0e-32', -73.682722975809461888575726549899655), +('1.0e-33', -75.9853080688035075725937180045840189), +('1.0e-34', -78.28789316179755325661170945926838306), +('1.0e-35', -80.590478254791598940629700913952747266), +('1.0e-36', -82.8930633477856446246476923686371114736), +('1.0e-37', -85.19564844077969030866568382332147568124), +('1.0e-38', -87.498233533773735992683675278005839888842), +('1.0e-39', -89.8008186267677816767016667326902040964430), +('1.0e-40', -92.10340371976182736071965818737456830404406)) +SELECT x, bc_result, ln(x::numeric), ln(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 542 +-- input very close to but smaller than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(1-10^-$p)" | head -n 1) +-- echo "('1.0e-$p', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e-1', -.10536051565782630), +('1.0e-2', -.010050335853501441), +('1.0e-3', -.0010005003335835335), +('1.0e-4', -.00010000500033335834), +('1.0e-5', -.000010000050000333336), +('1.0e-6', -.0000010000005000003333), +('1.0e-7', -.00000010000000500000033), +('1.0e-8', -.000000010000000050000000), +('1.0e-9', -.0000000010000000005000000), +('1.0e-10', -.00000000010000000000500000), +('1.0e-11', -.000000000010000000000050000), +('1.0e-12', -.0000000000010000000000005000), +('1.0e-13', -.00000000000010000000000000500), +('1.0e-14', -.000000000000010000000000000050), +('1.0e-15', -.0000000000000010000000000000005), +('1.0e-16', -.00000000000000010000000000000001), +('1.0e-17', -.000000000000000010000000000000000), +('1.0e-18', -.0000000000000000010000000000000000), +('1.0e-19', -.00000000000000000010000000000000000), +('1.0e-20', -.000000000000000000010000000000000000), +('1.0e-21', -.0000000000000000000010000000000000000), +('1.0e-22', -.00000000000000000000010000000000000000), +('1.0e-23', -.000000000000000000000010000000000000000), +('1.0e-24', -.0000000000000000000000010000000000000000), +('1.0e-25', -.00000000000000000000000010000000000000000), +('1.0e-26', -.000000000000000000000000010000000000000000), +('1.0e-27', -.0000000000000000000000000010000000000000000), +('1.0e-28', -.00000000000000000000000000010000000000000000), +('1.0e-29', -.000000000000000000000000000010000000000000000), +('1.0e-30', -.0000000000000000000000000000010000000000000000), +('1.0e-31', -.00000000000000000000000000000010000000000000000), +('1.0e-32', -.000000000000000000000000000000010000000000000000), +('1.0e-33', -.0000000000000000000000000000000010000000000000000), +('1.0e-34', -.00000000000000000000000000000000010000000000000000), +('1.0e-35', -.000000000000000000000000000000000010000000000000000), +('1.0e-36', -.0000000000000000000000000000000000010000000000000000), +('1.0e-37', -.00000000000000000000000000000000000010000000000000000), +('1.0e-38', -.000000000000000000000000000000000000010000000000000000), +('1.0e-39', -.0000000000000000000000000000000000000010000000000000000), +('1.0e-40', -.00000000000000000000000000000000000000010000000000000000)) +SELECT '1-'||x, bc_result, ln(1.0-x::numeric), ln(1.0-x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 543 +-- input very close to but larger than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(1+10^-$p)" | head -n 1) +-- echo "('1.0e-$p', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e-1', .09531017980432486), +('1.0e-2', .009950330853168083), +('1.0e-3', .0009995003330835332), +('1.0e-4', .00009999500033330834), +('1.0e-5', .000009999950000333331), +('1.0e-6', .0000009999995000003333), +('1.0e-7', .00000009999999500000033), +('1.0e-8', .000000009999999950000000), +('1.0e-9', .0000000009999999995000000), +('1.0e-10', .00000000009999999999500000), +('1.0e-11', .000000000009999999999950000), +('1.0e-12', .0000000000009999999999995000), +('1.0e-13', .00000000000009999999999999500), +('1.0e-14', .000000000000009999999999999950), +('1.0e-15', .0000000000000009999999999999995), +('1.0e-16', .00000000000000010000000000000000), +('1.0e-17', .000000000000000010000000000000000), +('1.0e-18', .0000000000000000010000000000000000), +('1.0e-19', .00000000000000000010000000000000000), +('1.0e-20', .000000000000000000010000000000000000), +('1.0e-21', .0000000000000000000010000000000000000), +('1.0e-22', .00000000000000000000010000000000000000), +('1.0e-23', .000000000000000000000010000000000000000), +('1.0e-24', .0000000000000000000000010000000000000000), +('1.0e-25', .00000000000000000000000010000000000000000), +('1.0e-26', .000000000000000000000000010000000000000000), +('1.0e-27', .0000000000000000000000000010000000000000000), +('1.0e-28', .00000000000000000000000000010000000000000000), +('1.0e-29', .000000000000000000000000000010000000000000000), +('1.0e-30', .0000000000000000000000000000010000000000000000), +('1.0e-31', .00000000000000000000000000000010000000000000000), +('1.0e-32', .000000000000000000000000000000010000000000000000), +('1.0e-33', .0000000000000000000000000000000010000000000000000), +('1.0e-34', .00000000000000000000000000000000010000000000000000), +('1.0e-35', .000000000000000000000000000000000010000000000000000), +('1.0e-36', .0000000000000000000000000000000000010000000000000000), +('1.0e-37', .00000000000000000000000000000000000010000000000000000), +('1.0e-38', .000000000000000000000000000000000000010000000000000000), +('1.0e-39', .0000000000000000000000000000000000000010000000000000000), +('1.0e-40', .00000000000000000000000000000000000000010000000000000000)) +SELECT '1+'||x, bc_result, ln(1.0+x::numeric), ln(1.0+x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 544 +-- input very large +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(10^$p)" | head -n 1) +-- echo "('1.0e$p', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e1', 2.3025850929940457), +('1.0e2', 4.6051701859880914), +('1.0e3', 6.9077552789821371), +('1.0e4', 9.2103403719761827), +('1.0e5', 11.512925464970228), +('1.0e6', 13.815510557964274), +('1.0e7', 16.118095650958320), +('1.0e8', 18.420680743952365), +('1.0e9', 20.723265836946411), +('1.0e10', 23.025850929940457), +('1.0e11', 25.328436022934503), +('1.0e12', 27.631021115928548), +('1.0e13', 29.933606208922594), +('1.0e14', 32.236191301916640), +('1.0e15', 34.538776394910685), +('1.0e16', 36.841361487904731), +('1.0e17', 39.143946580898777), +('1.0e18', 41.446531673892822), +('1.0e19', 43.749116766886868), +('1.0e20', 46.051701859880914), +('1.0e21', 48.354286952874959), +('1.0e22', 50.656872045869005), +('1.0e23', 52.959457138863051), +('1.0e24', 55.262042231857096), +('1.0e25', 57.564627324851142), +('1.0e26', 59.867212417845188), +('1.0e27', 62.169797510839233), +('1.0e28', 64.472382603833279), +('1.0e29', 66.774967696827325), +('1.0e30', 69.077552789821371), +('1.0e31', 71.380137882815416), +('1.0e32', 73.682722975809462), +('1.0e33', 75.985308068803508), +('1.0e34', 78.287893161797553), +('1.0e35', 80.590478254791599), +('1.0e36', 82.893063347785645), +('1.0e37', 85.195648440779690), +('1.0e38', 87.498233533773736), +('1.0e39', 89.800818626767782), +('1.0e40', 92.103403719761827)) +SELECT x, bc_result, ln(x::numeric), ln(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 545 +-- input huge +|-- +-- bc(1) results computed with a scale of 1000 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..10} +-- do +-- l=$(bc -ql <<< "scale=1000 ; l(10^${p}00)" | head -n 1) +-- echo "('1.0e${p}00', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e100', 230.25850929940457), +('1.0e200', 460.51701859880914), +('1.0e300', 690.77552789821371), +('1.0e400', 921.03403719761827), +('1.0e500', 1151.2925464970228), +('1.0e600', 1381.5510557964274), +('1.0e700', 1611.8095650958320), +('1.0e800', 1842.0680743952365), +('1.0e900', 2072.3265836946411), +('1.0e1000', 2302.5850929940457)) +SELECT x, bc_result, ln(x::numeric), ln(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 546 +-- inputs with 1000 decimal places +|-- +-- bc(1) results computed with a scale of 2000 and rounded to 1000 decimal +-- places + +WITH t(x, bc_result) AS (VALUES +(484990182159328900690402236933516249572671683638747490717351807610531884491845416923860371219625151551889257298200816555016472471293780254009492949585031653913930735918829139712249577547959394351523545901788627247613322896296041868431769047433229466634098452564756860190085118463828382895145244362033728480588969626012192733802377468089120757046364393407262957242230928854711898925295251902007136232994524624903257456111389508582206404271734668422903183500589303866613158037169610592539145461637447957948521714058034772237111009429638870236361143304703683377693378577075353794118557951847394763531830696578809001981568860219578880229402696449243344235099860421846016326538272155937175661905904288335499593232232926636205909086901191153907183842087577811871344870731324067822883041265129394268082883745408414994.8967939438561591657171240282983703914075472645212002662497023142663831371447287624846942598424990784971781730103682951722370983277124599054059027055336437808366784501932987082321905202623642371063626378290734289114618092750984153422293450048717769065428713836637664433167768445609659527458911187829232316677137895259433038764404970599325009178297626038331436654541552998098529141205301472138026818453893127265938030066392881979113522757891639646670670272542401773230506961559808927249585675430838495658225557294666522469887436551840596777627408780618586500922973500018513068499587683746133637919751545157547095670767246977244726331271787622126889459658539988980096764323712767863722912919120929339399753431689512753214200090670880647731689804555417871258907716687575767185444541243606329768784843125926070743277339790277626515824924290352180761378846035233155198504033292692893297993698953705472933411199778880561376633444249703838589180474329586470353212010427945060694794274109764269805332803290229, + 1864.3702986939570026328504202935192533137907736189919154633800554877738455118081651650863235106905871352085850240570561347180517240105510505203972860921397909573687877993477806728098306202020229409548306695695574102950949468160529713610952021974630774784174851619325758380143625473386495586347322798415543385655090746985183329114860118551572428921774322172798724455202876781611633419444058398798142214904998877857425038669920064728855823072107227506485770367799671977282350083029452784747350395161797215115525867416898416360638482342253129160308632504217096916335590470843180746834864303790913372081974355613359678634194879425862536147988835528973291020680020540866655622823550861337486588647231688134992810403147262346312159819432914207194632564009749236609081399504118359354620598232725290537215007867979331582119891661859015726276335168158288396939655310210558566592649049602925182137256134162660116182293851038854455437841571331011002023088829768308520393956515509475418031437505751407687618234418262), +(87190145885430429849953615409019208993240447426362428988181639909267773304254748257120061524000254226856815085523676417146197197996896030672521334101413071112068202429835905642444187493717977611730127126387257253646790849384975208460867137315507010888782632024640844766297185244443116696943912406389670302370461137850160539373600494054874979342373255280815156048999900951842673141766630630919020492255966628630634124452614590400422133958133100159154995520080124736657520969784129924799670552560034302960877087853678350801769339861812435411200669026902417951572668727488315537985378304242438181615160041688723201917323705450185975141141262578884689500612295576288125956289035673242989906973367691922065122033180281670221390667818909912035903387888639331486823729897326624516015340.0330856710565117793999512551468220085711713631167607285185762046751452975325645379302403715842570486302993296501788672462090620871511446272026693318239212657949496275318383141403236705902077406660768573015707706831878445598837931116223956945944726162551477136715847593742032488181481888084716920605114101902724395659898621880016853548602514706686907951229872573180602614761229992106144727082722940736406782659562775289407005631298246624198606031298081220736931229256511054595028182057216042683060059115371651410352645266000330509331097811566633211452233019461903115970558624057877018778178814946285827512359903934291318219271464841957435711594154280905473802599888081783098187210283997106131616471807951265003903143099667366508222327805543948921694362089860577380749774036318574113007382111997454202845559941557812813566442364810680529092880773126707073967537693927177460459341763934709686530005721141046645111784404932103241501569571235364365556796422998363930810983452790309019295181282099408260156, + 1793.5767085750017553306932533574391150814202249805881581227430032600579405884415934520704053351781361105595296647510475380766428668443641914861849764330704062323054023252886955844207807229267936432730818329225450152491146839618683772020068682795388746108876393249306737841247788224204701299467519965182171772253974884845661168860422489046657965359832930382114760565628765599962013955588754803194908990025689040598990346417563277021386852342928910383706995866844541160576254266641602065102228267316550706943783591722246885978355472097314691737807509436806788803362444745551013400341861820755594413819894154786253014501454443272120342005711761286524843010157182464200556865694401941794983935172457481497909987740544409272349152397774548604845897687504977786762391359552407068124283290504752932824699865504970420939586707791994870941813718246825616335675307740641350673558328821461530563823677144691877374809441673507467507447891562257806191361453045937798278733402269265623588493124129181374135958668436774), +(93936642222690597390233191619858485419795942047468396309991947772747208870873993801669373075421461116465960407843923269693395211616591453397070258466704654943689268224479477016161636938138334729982904232438440955361656138189836032891825113139184685132178764873033678116450665758561650355252211196676137179184043639278410827092182700922151290703747496962700158844772453483316974221113826173404445159281421213715669245417896170368554410830320000019029956317336703559699859949692222685614036912057150632902650913831404804982509990655560731349634628713944739168096272097122388116038119844786988276635032016787352796502360718569977397214936366251320294621522016.6483354941025384161536675750898007896744690911429670830432784905421638721478353275821072200938900938046264210604940707974410950770029535636602548377806284157951164875821446035013896786653932045182167021839184824627082391478016195098055107001433336586881395912782883663046617432598969149948351689103230162742769845955320418573803127107923535948653168889411316007796459064267436246637115946581149511513369842911210359447262641996566147462977170742544980481275049898092152042927981394239266559286915303786701737610786594006685748456635797125029722684151298695274097006242412384086302106763844070230264910503179385988626477852818174114043927841085089058972074427820150462261941575665882880501074676800316585217150509780489224388148722603385921057007086785238310735038314861960410473809826927329368597558806004392175746233568789445929554890241140656324160187253042639339549705859147930476532359840809944163908006480881926041259363654863689570520534301207043189181147254153307163555433328278834311658232337, + 1510.4332713542154696529645934345554302578243896764921637693542962119938599884313210100957753316832762996428481801312323020427109678979117469716796746760060470871840325255146954580681101106876674367471955788143763250819168311353856748872452260808797135108102729064040463343792765872545182299889360257515315869180266759715933989413256377582681707188367254513700731642913479683031478361835565783219287780434673712341147656477670848734998849030451414278832848680301511646182446524915091598080243532068451726548537866633622180283865668708517173065893429240665300584705585310049892047293928733753369421499719516009692095913169665213597158441636480707309244604139865130782756488091268094213446272360006907802989573582755585110277620911226015342778471352130366770729972784317323917141031824334355639769512749560550167491709646539950725523461943580211843652293561678342656010571108219244870234329176123205423872844099992204896411752620881541000940129833754169391528449211839693800724450201835161044717173715867437)) +SELECT trim_scale(ln(x::numeric)-bc_result) AS diff FROM t +-- +CTE: "t" +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +== 547 +|-- +-- Tests for LOG() (base 10) +|-- + +-- input very small, exact result known +WITH t(x) AS (SELECT '1e-'||n FROM generate_series(1, 100) g(n)) +SELECT x, log(x::numeric) FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 548 +-- input very small, non-exact results +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..50..7} +-- do +-- for d in {9..1..3} +-- do +-- l=$(bc -ql <<< "scale=500 ; l($d*10^-$p) / l(10)" | head -n 1) +-- echo "('${d}.0e-$p', $l)," +-- done +-- done + +WITH t(x, bc_result) AS (VALUES +('9.0e-1', -.04575749056067513), +('6.0e-1', -.2218487496163564), +('3.0e-1', -.5228787452803376), +('9.0e-8', -7.045757490560675), +('6.0e-8', -7.221848749616356), +('3.0e-8', -7.522878745280338), +('9.0e-15', -14.0457574905606751), +('6.0e-15', -14.2218487496163564), +('3.0e-15', -14.5228787452803376), +('9.0e-22', -21.04575749056067512540994), +('6.0e-22', -21.22184874961635636749123), +('3.0e-22', -21.52287874528033756270497), +('9.0e-29', -28.045757490560675125409944193490), +('6.0e-29', -28.221848749616356367491233202020), +('3.0e-29', -28.522878745280337562704972096745), +('9.0e-36', -35.0457574905606751254099441934897693816), +('6.0e-36', -35.2218487496163563674912332020203916640), +('3.0e-36', -35.5228787452803375627049720967448846908), +('9.0e-43', -42.04575749056067512540994419348976938159974227), +('6.0e-43', -42.22184874961635636749123320202039166403168125), +('3.0e-43', -42.52287874528033756270497209674488469079987114), +('9.0e-50', -49.045757490560675125409944193489769381599742271618608), +('6.0e-50', -49.221848749616356367491233202020391664031681254347196), +('3.0e-50', -49.522878745280337562704972096744884690799871135809304)) +SELECT x, bc_result, log(x::numeric), log(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 549 +-- input very close to but smaller than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40..7} +-- do +-- for d in {9..1..3} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(1-$d*10^-$p) / l(10)" | head -n 1) +-- echo "('${d}.0e-$p', $l)," +-- done +-- done + +WITH t(x, bc_result) AS (VALUES +('9.0e-1', -1.0000000000000000), +('6.0e-1', -.3979400086720376), +('3.0e-1', -.1549019599857432), +('9.0e-8', -.000000039086505130185422), +('6.0e-8', -.000000026057669695925208), +('3.0e-8', -.000000013028834652530076), +('9.0e-15', -.0000000000000039086503371292840), +('6.0e-15', -.0000000000000026057668914195188), +('3.0e-15', -.0000000000000013028834457097574), +('9.0e-22', -.00000000000000000000039086503371292664), +('6.0e-22', -.00000000000000000000026057668914195110), +('3.0e-22', -.00000000000000000000013028834457097555), +('9.0e-29', -.000000000000000000000000000039086503371292664), +('6.0e-29', -.000000000000000000000000000026057668914195110), +('3.0e-29', -.000000000000000000000000000013028834457097555), +('9.0e-36', -.0000000000000000000000000000000000039086503371292664), +('6.0e-36', -.0000000000000000000000000000000000026057668914195110), +('3.0e-36', -.0000000000000000000000000000000000013028834457097555)) +SELECT '1-'||x, bc_result, log(1.0-x::numeric), log(1.0-x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 550 +-- input very close to but larger than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40..7} +-- do +-- for d in {9..1..3} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(1+$d*10^-$p) / l(10)" | head -n 1) +-- echo "('${d}.0e-$p', $l)," +-- done +-- done + +WITH t(x, bc_result) AS (VALUES +('9.0e-1', .2787536009528290), +('6.0e-1', .2041199826559248), +('3.0e-1', .1139433523068368), +('9.0e-8', .000000039086501612400118), +('6.0e-8', .000000026057668132465074), +('3.0e-8', .000000013028834261665042), +('9.0e-15', .0000000000000039086503371292489), +('6.0e-15', .0000000000000026057668914195031), +('3.0e-15', .0000000000000013028834457097535), +('9.0e-22', .00000000000000000000039086503371292664), +('6.0e-22', .00000000000000000000026057668914195110), +('3.0e-22', .00000000000000000000013028834457097555), +('9.0e-29', .000000000000000000000000000039086503371292664), +('6.0e-29', .000000000000000000000000000026057668914195110), +('3.0e-29', .000000000000000000000000000013028834457097555), +('9.0e-36', .0000000000000000000000000000000000039086503371292664), +('6.0e-36', .0000000000000000000000000000000000026057668914195110), +('3.0e-36', .0000000000000000000000000000000000013028834457097555)) +SELECT '1+'||x, bc_result, log(1.0+x::numeric), log(1.0+x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +== 551 +-- input very large, exact result known +WITH t(x) AS (SELECT '1e'||n FROM generate_series(1, 100) g(n)) +SELECT x, log(x::numeric) FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 552 +-- input very large, non-exact results +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {10..50..7} +-- do +-- for d in {2..9..3} +-- do +-- l=$(bc -ql <<< "scale=500 ; l($d*10^$p) / l(10)" | head -n 1) +-- echo "('${d}.0e$p', $l)," +-- done +-- done + +WITH t(x, bc_result) AS (VALUES +('2.0e10', 10.301029995663981), +('5.0e10', 10.698970004336019), +('8.0e10', 10.903089986991944), +('2.0e17', 17.301029995663981), +('5.0e17', 17.698970004336019), +('8.0e17', 17.903089986991944), +('2.0e24', 24.301029995663981), +('5.0e24', 24.698970004336019), +('8.0e24', 24.903089986991944), +('2.0e31', 31.301029995663981), +('5.0e31', 31.698970004336019), +('8.0e31', 31.903089986991944), +('2.0e38', 38.301029995663981), +('5.0e38', 38.698970004336019), +('8.0e38', 38.903089986991944), +('2.0e45', 45.30102999566398), +('5.0e45', 45.69897000433602), +('8.0e45', 45.90308998699194)) +SELECT x, bc_result, log(x::numeric), log(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/numerology.metadata.json b/parser/testdata/summary/postgres_regress/numerology.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/numerology.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/numerology.test b/parser/testdata/summary/postgres_regress/numerology.test new file mode 100644 index 0000000..2f88268 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/numerology.test @@ -0,0 +1,200 @@ +== 001 +|-- +-- NUMEROLOGY +-- Test various combinations of numeric types and functions. +|-- + + +|-- +-- numeric literals +|-- + +SELECT 0b100101; +SELECT 0o273; +SELECT 0x42F; + +-- cases near int4 overflow +SELECT 0b1111111111111111111111111111111; +SELECT 0b10000000000000000000000000000000; +SELECT 0o17777777777; +SELECT 0o20000000000; +SELECT 0x7FFFFFFF; +SELECT 0x80000000; + +SELECT -0b10000000000000000000000000000000; +SELECT -0b10000000000000000000000000000001; +SELECT -0o20000000000; +SELECT -0o20000000001; +SELECT -0x80000000; +SELECT -0x80000001; + +-- cases near int8 overflow +SELECT 0b111111111111111111111111111111111111111111111111111111111111111; +SELECT 0b1000000000000000000000000000000000000000000000000000000000000000; +SELECT 0o777777777777777777777; +SELECT 0o1000000000000000000000; +SELECT 0x7FFFFFFFFFFFFFFF; +SELECT 0x8000000000000000; + +SELECT -0b1000000000000000000000000000000000000000000000000000000000000000; +SELECT -0b1000000000000000000000000000000000000000000000000000000000000001; +SELECT -0o1000000000000000000000; +SELECT -0o1000000000000000000001; +SELECT -0x8000000000000000; +SELECT -0x8000000000000001; + +-- error cases +SELECT 123abc; +SELECT 0x0o; +SELECT 0.a; +SELECT 0.0a; +SELECT .0a; +SELECT 0.0e1a; +SELECT 0.0e; +SELECT 0.0e+a; +PREPARE p1 AS SELECT $1a; + +SELECT 0b; +SELECT 1b; +SELECT 0b0x; + +SELECT 0o; +SELECT 1o; +SELECT 0o0x; + +SELECT 0x; +SELECT 1x; +SELECT 0x0y; + +-- underscores +SELECT 1_000_000; +SELECT 1_2_3; +SELECT 0x1EEE_FFFF; +SELECT 0o2_73; +SELECT 0b_10_0101; + +SELECT 1_000.000_005; +SELECT 1_000.; +SELECT .000_005; +SELECT 1_000.5e0_1; + +DO $$ +DECLARE + i int; +BEGIN + FOR i IN 1_001..1_003 LOOP + RAISE NOTICE 'i = %', i; + END LOOP; +END $$; + +-- error cases +SELECT _100; +SELECT 100_; +SELECT 100__000; + +SELECT _1_000.5; +SELECT 1_000_.5; +SELECT 1_000._5; +SELECT 1_000.5_; +SELECT 1_000.5e_1; + +PREPARE p1 AS SELECT $0_1; + +|-- +-- Test implicit type conversions +-- This fails for Postgres v6.1 (and earlier?) +-- so let's try explicit conversions for now - tgl 97/05/07 +|-- + +CREATE TABLE TEMP_FLOAT (f1 FLOAT8); + +INSERT INTO TEMP_FLOAT (f1) + SELECT float8(f1) FROM INT4_TBL; + +INSERT INTO TEMP_FLOAT (f1) + SELECT float8(f1) FROM INT2_TBL; + +SELECT f1 FROM TEMP_FLOAT + ORDER BY f1; + +-- int4 + +CREATE TABLE TEMP_INT4 (f1 INT4); + +INSERT INTO TEMP_INT4 (f1) + SELECT int4(f1) FROM FLOAT8_TBL + WHERE (f1 > -2147483647) AND (f1 < 2147483647); + +INSERT INTO TEMP_INT4 (f1) + SELECT int4(f1) FROM INT2_TBL; + +SELECT f1 FROM TEMP_INT4 + ORDER BY f1; + +-- int2 + +CREATE TABLE TEMP_INT2 (f1 INT2); + +INSERT INTO TEMP_INT2 (f1) + SELECT int2(f1) FROM FLOAT8_TBL + WHERE (f1 >= -32767) AND (f1 <= 32767); + +INSERT INTO TEMP_INT2 (f1) + SELECT int2(f1) FROM INT4_TBL + WHERE (f1 >= -32767) AND (f1 <= 32767); + +SELECT f1 FROM TEMP_INT2 + ORDER BY f1; + +|-- +-- Group-by combinations +|-- + +CREATE TABLE TEMP_GROUP (f1 INT4, f2 INT4, f3 FLOAT8); + +INSERT INTO TEMP_GROUP + SELECT 1, (- i.f1), (- f.f1) + FROM INT4_TBL i, FLOAT8_TBL f; + +INSERT INTO TEMP_GROUP + SELECT 2, i.f1, f.f1 + FROM INT4_TBL i, FLOAT8_TBL f; + +SELECT DISTINCT f1 AS two FROM TEMP_GROUP ORDER BY 1; + +SELECT f1 AS two, max(f3) AS max_float, min(f3) as min_float + FROM TEMP_GROUP + GROUP BY f1 + ORDER BY two, max_float, min_float; + +-- GROUP BY a result column name is not legal per SQL92, but we accept it +-- anyway (if the name is not the name of any column exposed by FROM). +SELECT f1 AS two, max(f3) AS max_float, min(f3) AS min_float + FROM TEMP_GROUP + GROUP BY two + ORDER BY two, max_float, min_float; + +SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1 + FROM TEMP_GROUP + GROUP BY f1 + ORDER BY two, min_minus_1; + +SELECT f1 AS two, + max(f2) + min(f2) AS max_plus_min, + min(f3) - 1 AS min_minus_1 + FROM TEMP_GROUP + GROUP BY f1 + ORDER BY two, min_minus_1; + +DROP TABLE TEMP_INT2; + +DROP TABLE TEMP_INT4; + +DROP TABLE TEMP_FLOAT; + +DROP TABLE TEMP_GROUP; +-- +ERROR: trailing junk after numeric literal at or near "123abc" +CURSORPOS: 1124 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary/postgres_regress/object_address.metadata.json b/parser/testdata/summary/postgres_regress/object_address.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/object_address.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/object_address.test b/parser/testdata/summary/postgres_regress/object_address.test new file mode 100644 index 0000000..3139b37 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/object_address.test @@ -0,0 +1,579 @@ +== 001 +|-- +-- Test for pg_get_object_address +|-- + +-- Clean up in case a prior regression run failed +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +== 002 +DROP ROLE IF EXISTS regress_addr_user +-- +STMT: DropRoleStmt +== 003 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 004 +CREATE USER regress_addr_user +-- +STMT: CreateRoleStmt +== 005 +-- Test generic object addressing/identification functions +CREATE SCHEMA addr_nsp +-- +STMT: CreateSchemaStmt +== 006 +SET search_path TO 'addr_nsp' +-- +STMT: VariableSetStmt +== 007 +CREATE FOREIGN DATA WRAPPER addr_fdw +-- +STMT: CreateFdwStmt +== 008 +CREATE SERVER addr_fserv FOREIGN DATA WRAPPER addr_fdw +-- +STMT: CreateForeignServerStmt +== 009 +CREATE TEXT SEARCH DICTIONARY addr_ts_dict (template=simple) +-- +STMT: DefineStmt +== 010 +CREATE TEXT SEARCH CONFIGURATION addr_ts_conf (copy=english) +-- +STMT: DefineStmt +== 011 +CREATE TEXT SEARCH TEMPLATE addr_ts_temp (lexize=dsimple_lexize) +-- +STMT: DefineStmt +== 012 +CREATE TEXT SEARCH PARSER addr_ts_prs + (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +== 013 +CREATE TABLE addr_nsp.gentable ( + a serial primary key CONSTRAINT a_chk CHECK (a > 0), + b text DEFAULT 'hello' +) +-- +TABLE: name="addr_nsp.gentable" schema="addr_nsp" table="gentable" ctx=DDL +STMT: CreateStmt +== 014 +CREATE TABLE addr_nsp.parttable ( + a int PRIMARY KEY +) PARTITION BY RANGE (a) +-- +TABLE: name="addr_nsp.parttable" schema="addr_nsp" table="parttable" ctx=DDL +STMT: CreateStmt +== 015 +CREATE VIEW addr_nsp.genview AS SELECT * from addr_nsp.gentable +-- +TABLE: name="addr_nsp.genview" schema="addr_nsp" table="genview" ctx=DDL +TABLE: name="addr_nsp.gentable" schema="addr_nsp" table="gentable" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 016 +CREATE MATERIALIZED VIEW addr_nsp.genmatview AS SELECT * FROM addr_nsp.gentable +-- +TABLE: name="addr_nsp.genmatview" schema="addr_nsp" table="genmatview" ctx=DDL +TABLE: name="addr_nsp.gentable" schema="addr_nsp" table="gentable" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 017 +CREATE TYPE addr_nsp.gencomptype AS (a int) +-- +STMT: CompositeTypeStmt +== 018 +CREATE TYPE addr_nsp.genenum AS ENUM ('one', 'two') +-- +STMT: CreateEnumStmt +== 019 +CREATE FOREIGN TABLE addr_nsp.genftable (a int) SERVER addr_fserv +-- +STMT: CreateForeignTableStmt +== 020 +CREATE AGGREGATE addr_nsp.genaggr(int4) (sfunc = int4pl, stype = int4) +-- +STMT: DefineStmt +== 021 +CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0) +-- +STMT: CreateDomainStmt +== 022 +CREATE FUNCTION addr_nsp.trig() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN END; $$ +-- +FUNCTION: name="addr_nsp.trig" function="trig" schema="addr_nsp" ctx=DDL +STMT: CreateFunctionStmt +== 023 +CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE PROCEDURE addr_nsp.trig() +-- +TABLE: name="addr_nsp.gentable" schema="addr_nsp" table="gentable" ctx=DDL +STMT: CreateTrigStmt +== 024 +CREATE POLICY genpol ON addr_nsp.gentable +-- +STMT: CreatePolicyStmt +== 025 +CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQL AS $$ $$ +-- +FUNCTION: name="addr_nsp.proc" function="proc" schema="addr_nsp" ctx=DDL +STMT: CreateFunctionStmt +== 026 +CREATE SERVER "integer" FOREIGN DATA WRAPPER addr_fdw +-- +STMT: CreateForeignServerStmt +== 027 +CREATE USER MAPPING FOR regress_addr_user SERVER "integer" +-- +STMT: CreateUserMappingStmt +== 028 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regress_addr_user +-- +STMT: AlterDefaultPrivilegesStmt +== 029 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM regress_addr_user +-- +STMT: AlterDefaultPrivilegesStmt +== 030 +-- this transform would be quite unsafe to leave lying around, +-- except that the SQL language pays no attention to transforms: +CREATE TRANSFORM FOR int LANGUAGE SQL ( + FROM SQL WITH FUNCTION prsd_lextype(internal), + TO SQL WITH FUNCTION int4recv(internal)) +-- +STMT: CreateTransformStmt +== 031 +-- suppress warning that depends on wal_level +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 032 +CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable +-- +STMT: CreatePublicationStmt +== 033 +CREATE PUBLICATION addr_pub_schema FOR TABLES IN SCHEMA addr_nsp +-- +STMT: CreatePublicationStmt +== 034 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 035 +CREATE SUBSCRIPTION regress_addr_sub CONNECTION '' PUBLICATION bar WITH (connect = false, slot_name = NONE) +-- +STMT: CreateSubscriptionStmt +== 036 +CREATE STATISTICS addr_nsp.gentable_stat ON a, b FROM addr_nsp.gentable +-- +STMT: CreateStatsStmt +== 037 +-- test some error cases +SELECT pg_get_object_address('stone', '{}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT pg_get_object_address('table', '{}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 039 +SELECT pg_get_object_address('table', '{NULL}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 040 +-- unrecognized object types +DO $$ +DECLARE + objtype text; +BEGIN + FOR objtype IN VALUES ('toast table'), ('index column'), ('sequence column'), + ('toast table column'), ('view column'), ('materialized view column') + LOOP + BEGIN + PERFORM pg_get_object_address(objtype, '{one}', '{}'); + EXCEPTION WHEN invalid_parameter_value THEN + RAISE WARNING 'error for %: %', objtype, sqlerrm; + END; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 041 +-- miscellaneous other errors +select * from pg_get_object_address('operator of access method', '{btree,integer_ops,1}', '{int4,bool}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 042 +select * from pg_get_object_address('operator of access method', '{btree,integer_ops,99}', '{int4,int4}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 043 +select * from pg_get_object_address('function of access method', '{btree,integer_ops,1}', '{int4,bool}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 044 +select * from pg_get_object_address('function of access method', '{btree,integer_ops,99}', '{int4,int4}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 045 +DO $$ +DECLARE + objtype text; + names text[]; + args text[]; +BEGIN + FOR objtype IN VALUES + ('table'), ('index'), ('sequence'), ('view'), + ('materialized view'), ('foreign table'), + ('table column'), ('foreign table column'), + ('aggregate'), ('function'), ('procedure'), ('type'), ('cast'), + ('table constraint'), ('domain constraint'), ('conversion'), ('default value'), + ('operator'), ('operator class'), ('operator family'), ('rule'), ('trigger'), + ('text search parser'), ('text search dictionary'), + ('text search template'), ('text search configuration'), + ('policy'), ('user mapping'), ('default acl'), ('transform'), + ('operator of access method'), ('function of access method'), + ('publication namespace'), ('publication relation') + LOOP + FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}') + LOOP + FOR args IN VALUES ('{}'), ('{integer}') + LOOP + BEGIN + PERFORM pg_get_object_address(objtype, names, args); + EXCEPTION WHEN OTHERS THEN + RAISE WARNING 'error for %,%,%: %', objtype, names, args, sqlerrm; + END; + END LOOP; + END LOOP; + END LOOP; +END; +$$ +-- +STMT: DoStmt +== 046 +-- these object types cannot be qualified names +SELECT pg_get_object_address('language', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 047 +SELECT pg_get_object_address('language', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT pg_get_object_address('large object', '{123}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 049 +SELECT pg_get_object_address('large object', '{123,456}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 050 +SELECT pg_get_object_address('large object', '{blargh}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 051 +SELECT pg_get_object_address('schema', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 052 +SELECT pg_get_object_address('schema', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 053 +SELECT pg_get_object_address('role', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 054 +SELECT pg_get_object_address('role', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 055 +SELECT pg_get_object_address('database', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 056 +SELECT pg_get_object_address('database', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 057 +SELECT pg_get_object_address('tablespace', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 058 +SELECT pg_get_object_address('tablespace', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT pg_get_object_address('foreign-data wrapper', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT pg_get_object_address('foreign-data wrapper', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT pg_get_object_address('server', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 062 +SELECT pg_get_object_address('server', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT pg_get_object_address('extension', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT pg_get_object_address('extension', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 065 +SELECT pg_get_object_address('event trigger', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 066 +SELECT pg_get_object_address('event trigger', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT pg_get_object_address('access method', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT pg_get_object_address('access method', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT pg_get_object_address('publication', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT pg_get_object_address('publication', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT pg_get_object_address('subscription', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 072 +SELECT pg_get_object_address('subscription', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 073 +-- Make sure that NULL handling is correct. + +-- Temporarily disable fancy output, so as future additions never create +-- a large amount of diffs. + +-- test successful cases +WITH objects (type, name, args) AS (VALUES + ('table', '{addr_nsp, gentable}'::text[], '{}'::text[]), + ('table', '{addr_nsp, parttable}'::text[], '{}'::text[]), + ('index', '{addr_nsp, gentable_pkey}', '{}'), + ('index', '{addr_nsp, parttable_pkey}', '{}'), + ('sequence', '{addr_nsp, gentable_a_seq}', '{}'), + -- toast table + ('view', '{addr_nsp, genview}', '{}'), + ('materialized view', '{addr_nsp, genmatview}', '{}'), + ('foreign table', '{addr_nsp, genftable}', '{}'), + ('table column', '{addr_nsp, gentable, b}', '{}'), + ('foreign table column', '{addr_nsp, genftable, a}', '{}'), + ('aggregate', '{addr_nsp, genaggr}', '{int4}'), + ('function', '{pg_catalog, pg_identify_object}', '{pg_catalog.oid, pg_catalog.oid, int4}'), + ('procedure', '{addr_nsp, proc}', '{int4}'), + ('type', '{pg_catalog._int4}', '{}'), + ('type', '{addr_nsp.gendomain}', '{}'), + ('type', '{addr_nsp.gencomptype}', '{}'), + ('type', '{addr_nsp.genenum}', '{}'), + ('cast', '{int8}', '{int4}'), + ('collation', '{default}', '{}'), + ('table constraint', '{addr_nsp, gentable, a_chk}', '{}'), + ('domain constraint', '{addr_nsp.gendomain}', '{domconstr}'), + ('conversion', '{pg_catalog, koi8_r_to_mic}', '{}'), + ('default value', '{addr_nsp, gentable, b}', '{}'), + ('language', '{plpgsql}', '{}'), + -- large object + ('operator', '{+}', '{int4, int4}'), + ('operator class', '{btree, int4_ops}', '{}'), + ('operator family', '{btree, integer_ops}', '{}'), + ('operator of access method', '{btree,integer_ops,1}', '{integer,integer}'), + ('function of access method', '{btree,integer_ops,2}', '{integer,integer}'), + ('rule', '{addr_nsp, genview, _RETURN}', '{}'), + ('trigger', '{addr_nsp, gentable, t}', '{}'), + ('schema', '{addr_nsp}', '{}'), + ('text search parser', '{addr_ts_prs}', '{}'), + ('text search dictionary', '{addr_ts_dict}', '{}'), + ('text search template', '{addr_ts_temp}', '{}'), + ('text search configuration', '{addr_ts_conf}', '{}'), + ('role', '{regress_addr_user}', '{}'), + -- database + -- tablespace + ('foreign-data wrapper', '{addr_fdw}', '{}'), + ('server', '{addr_fserv}', '{}'), + ('user mapping', '{regress_addr_user}', '{integer}'), + ('default acl', '{regress_addr_user,public}', '{r}'), + ('default acl', '{regress_addr_user}', '{r}'), + -- extension + -- event trigger + ('policy', '{addr_nsp, gentable, genpol}', '{}'), + ('transform', '{int}', '{sql}'), + ('access method', '{btree}', '{}'), + ('publication', '{addr_pub}', '{}'), + ('publication namespace', '{addr_nsp}', '{addr_pub_schema}'), + ('publication relation', '{addr_nsp, gentable}', '{addr_pub}'), + ('subscription', '{regress_addr_sub}', '{}'), + ('statistics object', '{addr_nsp, gentable_stat}', '{}') + ) +SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*, + -- test roundtrip through pg_identify_object_as_address + ROW(pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)) = + ROW(pg_identify_object(addr2.classid, addr2.objid, addr2.objsubid)) AS roundtrip +FROM objects, + pg_get_object_address(type, name, args) AS addr1, + pg_identify_object_as_address(classid, objid, objsubid) AS ioa (typ, nms, args), + pg_get_object_address(typ, nms, ioa.args) AS addr2 +ORDER BY addr1.classid, addr1.objid, addr1.objsubid +-- +CTE: "objects" +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +FUNCTION: name="pg_identify_object_as_address" function="pg_identify_object_as_address" schema="" ctx=Call +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +== 074 +--- +--- Cleanup resources +--- +DROP FOREIGN DATA WRAPPER addr_fdw CASCADE +-- +STMT: DropStmt +== 075 +DROP PUBLICATION addr_pub +-- +STMT: DropStmt +== 076 +DROP PUBLICATION addr_pub_schema +-- +STMT: DropStmt +== 077 +DROP SUBSCRIPTION regress_addr_sub +-- +STMT: DropSubscriptionStmt +== 078 +DROP SCHEMA addr_nsp CASCADE +-- +STMT: DropStmt +== 079 +DROP OWNED BY regress_addr_user +-- +STMT: DropOwnedStmt +== 080 +DROP USER regress_addr_user +-- +STMT: DropRoleStmt +== 081 +|-- +-- Checks for invalid objects +|-- + +-- Keep this list in the same order as getObjectIdentityParts() +-- in objectaddress.c. +WITH objects (classid, objid, objsubid) AS (VALUES + ('pg_class'::regclass, 0, 0), -- no relation + ('pg_class'::regclass, 'pg_class'::regclass, 100), -- no column for relation + ('pg_proc'::regclass, 0, 0), -- no function + ('pg_type'::regclass, 0, 0), -- no type + ('pg_cast'::regclass, 0, 0), -- no cast + ('pg_collation'::regclass, 0, 0), -- no collation + ('pg_constraint'::regclass, 0, 0), -- no constraint + ('pg_conversion'::regclass, 0, 0), -- no conversion + ('pg_attrdef'::regclass, 0, 0), -- no default attribute + ('pg_language'::regclass, 0, 0), -- no language + ('pg_largeobject'::regclass, 0, 0), -- no large object, no error + ('pg_operator'::regclass, 0, 0), -- no operator + ('pg_opclass'::regclass, 0, 0), -- no opclass, no need to check for no access method + ('pg_opfamily'::regclass, 0, 0), -- no opfamily + ('pg_am'::regclass, 0, 0), -- no access method + ('pg_amop'::regclass, 0, 0), -- no AM operator + ('pg_amproc'::regclass, 0, 0), -- no AM proc + ('pg_rewrite'::regclass, 0, 0), -- no rewrite + ('pg_trigger'::regclass, 0, 0), -- no trigger + ('pg_namespace'::regclass, 0, 0), -- no schema + ('pg_statistic_ext'::regclass, 0, 0), -- no statistics + ('pg_ts_parser'::regclass, 0, 0), -- no TS parser + ('pg_ts_dict'::regclass, 0, 0), -- no TS dictionary + ('pg_ts_template'::regclass, 0, 0), -- no TS template + ('pg_ts_config'::regclass, 0, 0), -- no TS configuration + ('pg_authid'::regclass, 0, 0), -- no role + ('pg_auth_members'::regclass, 0, 0), -- no role membership + ('pg_database'::regclass, 0, 0), -- no database + ('pg_tablespace'::regclass, 0, 0), -- no tablespace + ('pg_foreign_data_wrapper'::regclass, 0, 0), -- no FDW + ('pg_foreign_server'::regclass, 0, 0), -- no server + ('pg_user_mapping'::regclass, 0, 0), -- no user mapping + ('pg_default_acl'::regclass, 0, 0), -- no default ACL + ('pg_extension'::regclass, 0, 0), -- no extension + ('pg_event_trigger'::regclass, 0, 0), -- no event trigger + ('pg_parameter_acl'::regclass, 0, 0), -- no parameter ACL + ('pg_policy'::regclass, 0, 0), -- no policy + ('pg_publication'::regclass, 0, 0), -- no publication + ('pg_publication_namespace'::regclass, 0, 0), -- no publication namespace + ('pg_publication_rel'::regclass, 0, 0), -- no publication relation + ('pg_subscription'::regclass, 0, 0), -- no subscription + ('pg_transform'::regclass, 0, 0) -- no transformation + ) +SELECT ROW(pg_identify_object(objects.classid, objects.objid, objects.objsubid)) + AS ident, + ROW(pg_identify_object_as_address(objects.classid, objects.objid, objects.objsubid)) + AS addr, + pg_describe_object(objects.classid, objects.objid, objects.objsubid) + AS descr +FROM objects +ORDER BY objects.classid, objects.objid, objects.objsubid +-- +CTE: "objects" +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object_as_address" function="pg_identify_object_as_address" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/oid.metadata.json b/parser/testdata/summary/postgres_regress/oid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/oid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/oid.test b/parser/testdata/summary/postgres_regress/oid.test new file mode 100644 index 0000000..04fcabd --- /dev/null +++ b/parser/testdata/summary/postgres_regress/oid.test @@ -0,0 +1,223 @@ +== 001 +|-- +-- OID +|-- + +CREATE TABLE OID_TBL(f1 oid) +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO OID_TBL(f1) VALUES ('1234') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO OID_TBL(f1) VALUES ('1235') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO OID_TBL(f1) VALUES ('987') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO OID_TBL(f1) VALUES ('-1040') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO OID_TBL(f1) VALUES ('99999999') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO OID_TBL(f1) VALUES ('5 ') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO OID_TBL(f1) VALUES (' 10 ') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +-- leading/trailing hard tab is also allowed +INSERT INTO OID_TBL(f1) VALUES (' 15 ') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +-- bad inputs +INSERT INTO OID_TBL(f1) VALUES ('') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO OID_TBL(f1) VALUES (' ') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO OID_TBL(f1) VALUES ('asdfasd') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO OID_TBL(f1) VALUES ('99asdfasd') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO OID_TBL(f1) VALUES ('5 d') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO OID_TBL(f1) VALUES (' 5d') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO OID_TBL(f1) VALUES ('5 5') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO OID_TBL(f1) VALUES (' - 500') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO OID_TBL(f1) VALUES ('32958209582039852935') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO OID_TBL(f1) VALUES ('-23582358720398502385') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +SELECT * FROM OID_TBL +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +STMT: SelectStmt +== 021 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('1234', 'oid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT pg_input_is_valid('01XYZ', 'oid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT * FROM pg_input_error_info('01XYZ', 'oid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT pg_input_is_valid('9999999999', 'oid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT * FROM pg_input_error_info('9999999999', 'oid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 026 +-- While we're here, check oidvector as well +SELECT pg_input_is_valid(' 1 2 4 ', 'oidvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT pg_input_is_valid('01 01XYZ', 'oidvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT * FROM pg_input_error_info('01 01XYZ', 'oidvector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT pg_input_is_valid('01 9999999999', 'oidvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT * FROM pg_input_error_info('01 9999999999', 'oidvector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT o.* FROM OID_TBL o WHERE o.f1 = 1234 +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +== 032 +SELECT o.* FROM OID_TBL o WHERE o.f1 <> '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +== 033 +SELECT o.* FROM OID_TBL o WHERE o.f1 <= '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +== 034 +SELECT o.* FROM OID_TBL o WHERE o.f1 < '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +== 035 +SELECT o.* FROM OID_TBL o WHERE o.f1 >= '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +== 036 +SELECT o.* FROM OID_TBL o WHERE o.f1 > '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +== 037 +DROP TABLE OID_TBL +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/oidjoins.metadata.json b/parser/testdata/summary/postgres_regress/oidjoins.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/oidjoins.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/oidjoins.test b/parser/testdata/summary/postgres_regress/oidjoins.test new file mode 100644 index 0000000..6e429e2 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/oidjoins.test @@ -0,0 +1,52 @@ +== 001 +|-- +-- Verify system catalog foreign key relationships +|-- +DO $doblock$ +declare + fk record; + nkeys integer; + cmd text; + err record; +begin + for fk in select * from pg_get_catalog_foreign_keys() + loop + raise notice 'checking % % => % %', + fk.fktable, fk.fkcols, fk.pktable, fk.pkcols; + nkeys := array_length(fk.fkcols, 1); + cmd := 'SELECT ctid'; + for i in 1 .. nkeys loop + cmd := cmd || ', ' || quote_ident(fk.fkcols[i]); + end loop; + if fk.is_array then + cmd := cmd || ' FROM (SELECT ctid'; + for i in 1 .. nkeys-1 loop + cmd := cmd || ', ' || quote_ident(fk.fkcols[i]); + end loop; + cmd := cmd || ', unnest(' || quote_ident(fk.fkcols[nkeys]); + cmd := cmd || ') as ' || quote_ident(fk.fkcols[nkeys]); + cmd := cmd || ' FROM ' || fk.fktable::text || ') fk WHERE '; + else + cmd := cmd || ' FROM ' || fk.fktable::text || ' fk WHERE '; + end if; + if fk.is_opt then + for i in 1 .. nkeys loop + cmd := cmd || quote_ident(fk.fkcols[i]) || ' != 0 AND '; + end loop; + end if; + cmd := cmd || 'NOT EXISTS(SELECT 1 FROM ' || fk.pktable::text || ' pk WHERE '; + for i in 1 .. nkeys loop + if i > 1 then cmd := cmd || ' AND '; end if; + cmd := cmd || 'pk.' || quote_ident(fk.pkcols[i]); + cmd := cmd || ' = fk.' || quote_ident(fk.fkcols[i]); + end loop; + cmd := cmd || ')'; + -- raise notice 'cmd = %', cmd; + for err in execute cmd loop + raise warning 'FK VIOLATION IN %(%): %', fk.fktable, fk.fkcols, err; + end loop; + end loop; +end +$doblock$ +-- +STMT: DoStmt diff --git a/parser/testdata/summary/postgres_regress/opr_sanity.metadata.json b/parser/testdata/summary/postgres_regress/opr_sanity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/opr_sanity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/opr_sanity.test b/parser/testdata/summary/postgres_regress/opr_sanity.test new file mode 100644 index 0000000..13fa5b5 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/opr_sanity.test @@ -0,0 +1,3189 @@ +== 001 +|-- +-- OPR_SANITY +-- Sanity checks for common errors in making operator/procedure system tables: +-- pg_operator, pg_proc, pg_cast, pg_conversion, pg_aggregate, pg_am, +-- pg_amop, pg_amproc, pg_opclass, pg_opfamily, pg_index. +|-- +-- Every test failure in this file should be closely inspected. +-- The description of the failing test should be read carefully before +-- adjusting the expected output. In most cases, the queries should +-- not find *any* matching entries. +|-- +-- NB: we assume the oidjoins test will have caught any dangling links, +-- that is OID or REGPROC fields that are not zero and do not match some +-- row in the linked-to table. However, if we want to enforce that a link +-- field can't be 0, we have to check it here. +|-- +-- NB: run this test earlier than the create_operator test, because +-- that test creates some bogus operators... + + +-- **************** pg_proc **************** + +-- Look for illegal values in pg_proc fields. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prolang = 0 OR p1.prorettype = 0 OR + p1.pronargs < 0 OR + p1.pronargdefaults < 0 OR + p1.pronargdefaults > p1.pronargs OR + array_lower(p1.proargtypes, 1) != 0 OR + array_upper(p1.proargtypes, 1) != p1.pronargs-1 OR + 0::oid = ANY (p1.proargtypes) OR + procost <= 0 OR + CASE WHEN proretset THEN prorows <= 0 ELSE prorows != 0 END OR + prokind NOT IN ('f', 'a', 'w', 'p') OR + provolatile NOT IN ('i', 's', 'v') OR + proparallel NOT IN ('s', 'r', 'u') +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="pronargdefaults" +FILTER: schema="" table="p1" column="pronargdefaults" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="" column="procost" +FILTER: schema="" table="" column="proretset" +FILTER: schema="" table="" column="prorows" +FILTER: schema="" table="" column="prorows" +FILTER: schema="" table="" column="prokind" +FILTER: schema="" table="" column="provolatile" +FILTER: schema="" table="" column="proparallel" +STMT: SelectStmt +== 002 +-- prosrc should never be null; it can be empty only if prosqlbody isn't null +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE prosrc IS NULL +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prosrc" +STMT: SelectStmt +== 003 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE (prosrc = '' OR prosrc = '-') AND prosqlbody IS NULL +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prosrc" +FILTER: schema="" table="" column="prosrc" +FILTER: schema="" table="" column="prosqlbody" +STMT: SelectStmt +== 004 +-- proretset should only be set for normal functions +SELECT p1.oid, p1.proname +FROM pg_proc AS p1 +WHERE proretset AND prokind != 'f' +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="proretset" +FILTER: schema="" table="" column="prokind" +STMT: SelectStmt +== 005 +-- currently, no built-in functions should be SECURITY DEFINER; +-- this might change in future, but there will probably never be many. +SELECT p1.oid, p1.proname +FROM pg_proc AS p1 +WHERE prosecdef +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prosecdef" +STMT: SelectStmt +== 006 +-- pronargdefaults should be 0 iff proargdefaults is null +SELECT p1.oid, p1.proname +FROM pg_proc AS p1 +WHERE (pronargdefaults <> 0) != (proargdefaults IS NOT NULL) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="pronargdefaults" +FILTER: schema="" table="" column="proargdefaults" +STMT: SelectStmt +== 007 +-- probin should be non-empty for C functions, null everywhere else +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE prolang = 13 AND (probin IS NULL OR probin = '' OR probin = '-') +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prolang" +FILTER: schema="" table="" column="probin" +FILTER: schema="" table="" column="probin" +FILTER: schema="" table="" column="probin" +STMT: SelectStmt +== 008 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE prolang != 13 AND probin IS NOT NULL +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prolang" +FILTER: schema="" table="" column="probin" +STMT: SelectStmt +== 009 +-- Look for conflicting proc definitions (same names and input datatypes). +-- (This test should be dead code now that we have the unique index +-- pg_proc_proname_args_nsp_index, but I'll leave it in anyway.) + +SELECT p1.oid, p1.proname, p2.oid, p2.proname +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.proname = p2.proname AND + p1.pronargs = p2.pronargs AND + p1.proargtypes = p2.proargtypes +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="proname" +FILTER: schema="" table="p2" column="proname" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p2" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 010 +-- Considering only built-in procs (prolang = 12), look for multiple uses +-- of the same internal function (ie, matching prosrc fields). It's OK to +-- have several entries with different pronames for the same internal function, +-- but conflicts in the number of arguments and other critical items should +-- be complained of. (We don't check data types here; see next query.) +-- Note: ignore aggregate functions here, since they all point to the same +-- dummy built-in function. + +SELECT p1.oid, p1.proname, p2.oid, p2.proname +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid < p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + (p1.prokind != 'a' OR p2.prokind != 'a') AND + (p1.prolang != p2.prolang OR + p1.prokind != p2.prokind OR + p1.prosecdef != p2.prosecdef OR + p1.proleakproof != p2.proleakproof OR + p1.proisstrict != p2.proisstrict OR + p1.proretset != p2.proretset OR + p1.provolatile != p2.provolatile OR + p1.pronargs != p2.pronargs) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prosecdef" +FILTER: schema="" table="p2" column="prosecdef" +FILTER: schema="" table="p1" column="proleakproof" +FILTER: schema="" table="p2" column="proleakproof" +FILTER: schema="" table="p1" column="proisstrict" +FILTER: schema="" table="p2" column="proisstrict" +FILTER: schema="" table="p1" column="proretset" +FILTER: schema="" table="p2" column="proretset" +FILTER: schema="" table="p1" column="provolatile" +FILTER: schema="" table="p2" column="provolatile" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p2" column="pronargs" +STMT: SelectStmt +== 011 +-- Look for uses of different type OIDs in the argument/result type fields +-- for different aliases of the same built-in function. +-- This indicates that the types are being presumed to be binary-equivalent, +-- or that the built-in function is prepared to deal with different types. +-- That's not wrong, necessarily, but we make lists of all the types being +-- so treated. Note that the expected output of this part of the test will +-- need to be modified whenever new pairs of types are made binary-equivalent, +-- or when new polymorphic built-in functions are added! +-- Note: ignore aggregate functions here, since they all point to the same +-- dummy built-in function. Likewise, ignore range and multirange constructor +-- functions. + +SELECT DISTINCT p1.prorettype::regtype, p2.prorettype::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + p1.prosrc NOT LIKE E'range\\_constructor_' AND + p2.prosrc NOT LIKE E'range\\_constructor_' AND + p1.prosrc NOT LIKE E'multirange\\_constructor_' AND + p2.prosrc NOT LIKE E'multirange\\_constructor_' AND + (p1.prorettype < p2.prorettype) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p2" column="prorettype" +STMT: SelectStmt +== 012 +SELECT DISTINCT p1.proargtypes[0]::regtype, p2.proargtypes[0]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + p1.prosrc NOT LIKE E'range\\_constructor_' AND + p2.prosrc NOT LIKE E'range\\_constructor_' AND + p1.prosrc NOT LIKE E'multirange\\_constructor_' AND + p2.prosrc NOT LIKE E'multirange\\_constructor_' AND + (p1.proargtypes[0] < p2.proargtypes[0]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 013 +SELECT DISTINCT p1.proargtypes[1]::regtype, p2.proargtypes[1]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + p1.prosrc NOT LIKE E'range\\_constructor_' AND + p2.prosrc NOT LIKE E'range\\_constructor_' AND + p1.prosrc NOT LIKE E'multirange\\_constructor_' AND + p2.prosrc NOT LIKE E'multirange\\_constructor_' AND + (p1.proargtypes[1] < p2.proargtypes[1]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 014 +SELECT DISTINCT p1.proargtypes[2]::regtype, p2.proargtypes[2]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[2] < p2.proargtypes[2]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 015 +SELECT DISTINCT p1.proargtypes[3]::regtype, p2.proargtypes[3]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[3] < p2.proargtypes[3]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 016 +SELECT DISTINCT p1.proargtypes[4]::regtype, p2.proargtypes[4]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[4] < p2.proargtypes[4]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 017 +SELECT DISTINCT p1.proargtypes[5]::regtype, p2.proargtypes[5]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[5] < p2.proargtypes[5]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 018 +SELECT DISTINCT p1.proargtypes[6]::regtype, p2.proargtypes[6]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[6] < p2.proargtypes[6]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 019 +SELECT DISTINCT p1.proargtypes[7]::regtype, p2.proargtypes[7]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[7] < p2.proargtypes[7]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 020 +-- Look for functions that return type "internal" and do not have any +-- "internal" argument. Such a function would be a security hole since +-- it might be used to call an internal function from an SQL command. +-- As of 7.3 this query should find only internal_in, which is safe because +-- it always throws an error when called. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype = 'internal'::regtype AND NOT + 'internal'::regtype = ANY (p1.proargtypes) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 021 +-- Look for functions that return a polymorphic type and do not have any +-- polymorphic argument. Calls of such functions would be unresolvable +-- at parse time. As of 9.6 this query should find only some input functions +-- and GiST support functions associated with these pseudotypes. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype IN + ('anyelement'::regtype, 'anyarray'::regtype, 'anynonarray'::regtype, + 'anyenum'::regtype) + AND NOT + ('anyelement'::regtype = ANY (p1.proargtypes) OR + 'anyarray'::regtype = ANY (p1.proargtypes) OR + 'anynonarray'::regtype = ANY (p1.proargtypes) OR + 'anyenum'::regtype = ANY (p1.proargtypes) OR + 'anyrange'::regtype = ANY (p1.proargtypes) OR + 'anymultirange'::regtype = ANY (p1.proargtypes)) +ORDER BY 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 022 +-- anyrange and anymultirange are tighter than the rest, can only resolve +-- from each other + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype IN ('anyrange'::regtype, 'anymultirange'::regtype) + AND NOT + ('anyrange'::regtype = ANY (p1.proargtypes) OR + 'anymultirange'::regtype = ANY (p1.proargtypes)) +ORDER BY 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 023 +-- similarly for the anycompatible family + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype IN + ('anycompatible'::regtype, 'anycompatiblearray'::regtype, + 'anycompatiblenonarray'::regtype) + AND NOT + ('anycompatible'::regtype = ANY (p1.proargtypes) OR + 'anycompatiblearray'::regtype = ANY (p1.proargtypes) OR + 'anycompatiblenonarray'::regtype = ANY (p1.proargtypes) OR + 'anycompatiblerange'::regtype = ANY (p1.proargtypes)) +ORDER BY 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 024 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype = 'anycompatiblerange'::regtype + AND NOT + 'anycompatiblerange'::regtype = ANY (p1.proargtypes) +ORDER BY 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 025 +-- Look for functions that accept cstring and are neither datatype input +-- functions nor encoding conversion functions. It's almost never a good +-- idea to use cstring input for a function meant to be called from SQL; +-- text should be used instead, because cstring lacks suitable casts. +-- As of 9.6 this query should find only cstring_out and cstring_send. +-- However, we must manually exclude shell_in, which might or might not be +-- rejected by the EXISTS clause depending on whether there are currently +-- any shell types. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE 'cstring'::regtype = ANY (p1.proargtypes) + AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typinput = p1.oid) + AND NOT EXISTS(SELECT 1 FROM pg_conversion WHERE conproc = p1.oid) + AND p1.oid != 'shell_in(cstring)'::regprocedure +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="" column="conproc" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +== 026 +-- Likewise, look for functions that return cstring and aren't datatype output +-- functions nor typmod output functions. +-- As of 9.6 this query should find only cstring_in and cstring_recv. +-- However, we must manually exclude shell_out. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype = 'cstring'::regtype + AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typoutput = p1.oid) + AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typmodout = p1.oid) + AND p1.oid != 'shell_out(void)'::regprocedure +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="" column="typoutput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="" column="typmodout" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +== 027 +-- Check for length inconsistencies between the various argument-info arrays. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proallargtypes IS NOT NULL AND + array_length(proallargtypes,1) < array_length(proargtypes,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargtypes" +STMT: SelectStmt +== 028 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proargmodes IS NOT NULL AND + array_length(proargmodes,1) < array_length(proargtypes,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargtypes" +STMT: SelectStmt +== 029 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proargnames IS NOT NULL AND + array_length(proargnames,1) < array_length(proargtypes,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proargnames" +FILTER: schema="" table="" column="proargnames" +FILTER: schema="" table="" column="proargtypes" +STMT: SelectStmt +== 030 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proallargtypes IS NOT NULL AND proargmodes IS NOT NULL AND + array_length(proallargtypes,1) <> array_length(proargmodes,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargmodes" +STMT: SelectStmt +== 031 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proallargtypes IS NOT NULL AND proargnames IS NOT NULL AND + array_length(proallargtypes,1) <> array_length(proargnames,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargnames" +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargnames" +STMT: SelectStmt +== 032 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proargmodes IS NOT NULL AND proargnames IS NOT NULL AND + array_length(proargmodes,1) <> array_length(proargnames,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargnames" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargnames" +STMT: SelectStmt +== 033 +-- Check that proallargtypes matches proargtypes +SELECT p1.oid, p1.proname, p1.proargtypes, p1.proallargtypes, p1.proargmodes +FROM pg_proc as p1 +WHERE proallargtypes IS NOT NULL AND + ARRAY(SELECT unnest(proargtypes)) <> + ARRAY(SELECT proallargtypes[i] + FROM generate_series(1, array_length(proallargtypes, 1)) g(i) + WHERE proargmodes IS NULL OR proargmodes[i] IN ('i', 'b', 'v')) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 034 +-- Check for type of the variadic array parameter's elements. +-- provariadic should be ANYOID if the type of the last element is ANYOID, +-- ANYELEMENTOID if the type of the last element is ANYARRAYOID, +-- ANYCOMPATIBLEOID if the type of the last element is ANYCOMPATIBLEARRAYOID, +-- and otherwise the element type corresponding to the array type. + +SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[] +FROM pg_proc +WHERE provariadic != 0 +AND case proargtypes[array_length(proargtypes, 1)-1] + WHEN '"any"'::regtype THEN '"any"'::regtype + WHEN 'anyarray'::regtype THEN 'anyelement'::regtype + WHEN 'anycompatiblearray'::regtype THEN 'anycompatible'::regtype + ELSE (SELECT t.oid + FROM pg_type t + WHERE t.typarray = proargtypes[array_length(proargtypes, 1)-1]) + END != provariadic +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t"="pg_type" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="provariadic" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="t" column="typarray" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="proargtypes" +STMT: SelectStmt +== 035 +-- Check that all and only those functions with a variadic type have +-- a variadic argument. +SELECT oid::regprocedure, proargmodes, provariadic +FROM pg_proc +WHERE (proargmodes IS NOT NULL AND 'v' = any(proargmodes)) + IS DISTINCT FROM + (provariadic != 0) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="provariadic" +STMT: SelectStmt +== 036 +-- Check for prosupport functions with the wrong signature +SELECT p1.oid, p1.proname, p2.oid, p2.proname +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p2.oid = p1.prosupport AND + (p2.prorettype != 'internal'::regtype OR p2.proretset OR p2.pronargs != 1 + OR p2.proargtypes[0] != 'internal'::regtype) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosupport" +FILTER: schema="" table="p2" column="prorettype" +FILTER: schema="" table="p2" column="proretset" +FILTER: schema="" table="p2" column="pronargs" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 037 +-- Insist that all built-in pg_proc entries have descriptions +SELECT p1.oid, p1.proname +FROM pg_proc as p1 LEFT JOIN pg_description as d + ON p1.tableoid = d.classoid and p1.oid = d.objoid and d.objsubid = 0 +WHERE d.classoid IS NULL AND p1.oid <= 9999 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +ALIAS: "d"="pg_description" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="d" column="classoid" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +== 038 +-- List of built-in leakproof functions +|-- +-- Leakproof functions should only be added after carefully +-- scrutinizing all possibly executed codepaths for possible +-- information leaks. Don't add functions here unless you know what a +-- leakproof function is. If unsure, don't mark it as such. + +-- temporarily disable fancy output, so catalog changes create less diff noise + +SELECT p1.oid::regprocedure +FROM pg_proc p1 JOIN pg_namespace pn + ON pronamespace = pn.oid +WHERE nspname = 'pg_catalog' AND proleakproof +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "pn"="pg_namespace" +FILTER: schema="" table="" column="nspname" +FILTER: schema="" table="" column="proleakproof" +STMT: SelectStmt +== 039 +-- restore normal output mode + +-- List of functions used by libpq's fe-lobj.c +|-- +-- If the output of this query changes, you probably broke libpq. +-- lo_initialize() assumes that there will be at most one match for +-- each listed name. +select proname, oid from pg_catalog.pg_proc +where proname in ( + 'lo_open', + 'lo_close', + 'lo_creat', + 'lo_create', + 'lo_unlink', + 'lo_lseek', + 'lo_lseek64', + 'lo_tell', + 'lo_tell64', + 'lo_truncate', + 'lo_truncate64', + 'loread', + 'lowrite') +and pronamespace = (select oid from pg_catalog.pg_namespace + where nspname = 'pg_catalog') +order by 1 +-- +TABLE: name="pg_catalog.pg_proc" schema="pg_catalog" table="pg_proc" ctx=Select +TABLE: name="pg_catalog.pg_namespace" schema="pg_catalog" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="proname" +FILTER: schema="" table="" column="pronamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +== 040 +-- Check that all immutable functions are marked parallel safe +SELECT p1.oid, p1.proname +FROM pg_proc AS p1 +WHERE provolatile = 'i' AND proparallel = 'u' +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="provolatile" +FILTER: schema="" table="" column="proparallel" +STMT: SelectStmt +== 041 +-- **************** pg_cast **************** + +-- Catch bogus values in pg_cast columns (other than cases detected by +-- oidjoins test). + +SELECT * +FROM pg_cast c +WHERE castsource = 0 OR casttarget = 0 OR castcontext NOT IN ('e', 'a', 'i') + OR castmethod NOT IN ('f', 'b' ,'i') +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +ALIAS: "c"="pg_cast" +FILTER: schema="" table="" column="castsource" +FILTER: schema="" table="" column="casttarget" +FILTER: schema="" table="" column="castcontext" +FILTER: schema="" table="" column="castmethod" +STMT: SelectStmt +== 042 +-- Check that castfunc is nonzero only for cast methods that need a function, +-- and zero otherwise + +SELECT * +FROM pg_cast c +WHERE (castmethod = 'f' AND castfunc = 0) + OR (castmethod IN ('b', 'i') AND castfunc <> 0) +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +ALIAS: "c"="pg_cast" +FILTER: schema="" table="" column="castmethod" +FILTER: schema="" table="" column="castfunc" +FILTER: schema="" table="" column="castmethod" +FILTER: schema="" table="" column="castfunc" +STMT: SelectStmt +== 043 +-- Look for casts to/from the same type that aren't length coercion functions. +-- (We assume they are length coercions if they take multiple arguments.) +-- Such entries are not necessarily harmful, but they are useless. + +SELECT * +FROM pg_cast c +WHERE castsource = casttarget AND castfunc = 0 +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +ALIAS: "c"="pg_cast" +FILTER: schema="" table="" column="castsource" +FILTER: schema="" table="" column="casttarget" +FILTER: schema="" table="" column="castfunc" +STMT: SelectStmt +== 044 +SELECT c.* +FROM pg_cast c, pg_proc p +WHERE c.castfunc = p.oid AND p.pronargs < 2 AND castsource = casttarget +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "c"="pg_cast" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="c" column="castfunc" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="" column="castsource" +FILTER: schema="" table="" column="casttarget" +STMT: SelectStmt +== 045 +-- Look for cast functions that don't have the right signature. The +-- argument and result types in pg_proc must be the same as, or binary +-- compatible with, what it says in pg_cast. +-- As a special case, we allow casts from CHAR(n) that use functions +-- declared to take TEXT. This does not pass the binary-coercibility test +-- because CHAR(n)-to-TEXT normally invokes rtrim(). However, the results +-- are the same, so long as the function is one that ignores trailing blanks. + +SELECT c.* +FROM pg_cast c, pg_proc p +WHERE c.castfunc = p.oid AND + (p.pronargs < 1 OR p.pronargs > 3 + OR NOT (binary_coercible(c.castsource, p.proargtypes[0]) + OR (c.castsource = 'character'::regtype AND + p.proargtypes[0] = 'text'::regtype)) + OR NOT binary_coercible(p.prorettype, c.casttarget)) +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "c"="pg_cast" +ALIAS: "p"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="c" column="castfunc" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="c" column="castsource" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="c" column="castsource" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="c" column="casttarget" +STMT: SelectStmt +== 046 +SELECT c.* +FROM pg_cast c, pg_proc p +WHERE c.castfunc = p.oid AND + ((p.pronargs > 1 AND p.proargtypes[1] != 'int4'::regtype) OR + (p.pronargs > 2 AND p.proargtypes[2] != 'bool'::regtype)) +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "c"="pg_cast" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="c" column="castfunc" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +STMT: SelectStmt +== 047 +-- Look for binary compatible casts that do not have the reverse +-- direction registered as well, or where the reverse direction is not +-- also binary compatible. This is legal, but usually not intended. + +-- As of 7.4, this finds the casts from text and varchar to bpchar, because +-- those are binary-compatible while the reverse way goes through rtrim(). + +-- As of 8.2, this finds the cast from cidr to inet, because that is a +-- trivial binary coercion while the other way goes through inet_to_cidr(). + +-- As of 8.3, this finds the casts from xml to text, varchar, and bpchar, +-- because those are binary-compatible while the reverse goes through +-- texttoxml(), which does an XML syntax check. + +-- As of 9.1, this finds the cast from pg_node_tree to text, which we +-- intentionally do not provide a reverse pathway for. + +SELECT castsource::regtype, casttarget::regtype, castfunc, castcontext +FROM pg_cast c +WHERE c.castmethod = 'b' AND + NOT EXISTS (SELECT 1 FROM pg_cast k + WHERE k.castmethod = 'b' AND + k.castsource = c.casttarget AND + k.casttarget = c.castsource) +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +ALIAS: "c"="pg_cast" +ALIAS: "k"="pg_cast" +FILTER: schema="" table="c" column="castmethod" +FILTER: schema="" table="k" column="castmethod" +FILTER: schema="" table="k" column="castsource" +FILTER: schema="" table="c" column="casttarget" +FILTER: schema="" table="k" column="casttarget" +FILTER: schema="" table="c" column="castsource" +STMT: SelectStmt +== 048 +-- **************** pg_conversion **************** + +-- Look for illegal values in pg_conversion fields. + +SELECT c.oid, c.conname +FROM pg_conversion as c +WHERE c.conproc = 0 OR + pg_encoding_to_char(conforencoding) = '' OR + pg_encoding_to_char(contoencoding) = '' +-- +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +ALIAS: "c"="pg_conversion" +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FILTER: schema="" table="c" column="conproc" +FILTER: schema="" table="" column="conforencoding" +FILTER: schema="" table="" column="contoencoding" +STMT: SelectStmt +== 049 +-- Look for conprocs that don't have the expected signature. + +SELECT p.oid, p.proname, c.oid, c.conname +FROM pg_proc p, pg_conversion c +WHERE p.oid = c.conproc AND + (p.prorettype != 'int4'::regtype OR p.proretset OR + p.pronargs != 6 OR + p.proargtypes[0] != 'int4'::regtype OR + p.proargtypes[1] != 'int4'::regtype OR + p.proargtypes[2] != 'cstring'::regtype OR + p.proargtypes[3] != 'internal'::regtype OR + p.proargtypes[4] != 'int4'::regtype OR + p.proargtypes[5] != 'bool'::regtype) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +ALIAS: "c"="pg_conversion" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="c" column="conproc" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="proretset" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +STMT: SelectStmt +== 050 +-- Check for conprocs that don't perform the specific conversion that +-- pg_conversion alleges they do, by trying to invoke each conversion +-- on some simple ASCII data. (The conproc should throw an error if +-- it doesn't accept the encodings that are passed to it.) +-- Unfortunately, we can't test non-default conprocs this way, because +-- there is no way to ask convert() to invoke them, and we cannot call +-- them directly from SQL. But there are no non-default built-in +-- conversions anyway. +-- (Similarly, this doesn't cope with any search path issues.) + +SELECT c.oid, c.conname +FROM pg_conversion as c +WHERE condefault AND + convert('ABC'::bytea, pg_encoding_to_char(conforencoding), + pg_encoding_to_char(contoencoding)) != 'ABC' +-- +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +ALIAS: "c"="pg_conversion" +FUNCTION: name="convert" function="convert" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="convert" function="convert" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FILTER: schema="" table="" column="condefault" +FILTER: schema="" table="" column="conforencoding" +FILTER: schema="" table="" column="contoencoding" +STMT: SelectStmt +== 051 +-- **************** pg_operator **************** + +-- Look for illegal values in pg_operator fields. + +SELECT o1.oid, o1.oprname +FROM pg_operator as o1 +WHERE (o1.oprkind != 'b' AND o1.oprkind != 'l') OR + o1.oprresult = 0 OR o1.oprcode = 0 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o1" column="oprcode" +STMT: SelectStmt +== 052 +-- Look for missing or unwanted operand types + +SELECT o1.oid, o1.oprname +FROM pg_operator as o1 +WHERE (o1.oprleft = 0 and o1.oprkind != 'l') OR + (o1.oprleft != 0 and o1.oprkind = 'l') OR + o1.oprright = 0 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprright" +STMT: SelectStmt +== 053 +-- Look for conflicting operator definitions (same names and input datatypes). + +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2 +WHERE o1.oid != o2.oid AND + o1.oprname = o2.oprname AND + o1.oprkind = o2.oprkind AND + o1.oprleft = o2.oprleft AND + o1.oprright = o2.oprright +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprname" +FILTER: schema="" table="o2" column="oprname" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o2" column="oprkind" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o2" column="oprleft" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="o2" column="oprright" +STMT: SelectStmt +== 054 +-- Look for commutative operators that don't commute. +-- DEFINITIONAL NOTE: If A.oprcom = B, then x A y has the same result as y B x. +-- We expect that B will always say that B.oprcom = A as well; that's not +-- inherently essential, but it would be inefficient not to mark it so. + +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2 +WHERE o1.oprcom = o2.oid AND + (o1.oprkind != 'b' OR + o1.oprleft != o2.oprright OR + o1.oprright != o2.oprleft OR + o1.oprresult != o2.oprresult OR + o1.oid != o2.oprcom) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprcom" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o2" column="oprright" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="o2" column="oprleft" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o2" column="oprresult" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o2" column="oprcom" +STMT: SelectStmt +== 055 +-- Look for negatory operators that don't agree. +-- DEFINITIONAL NOTE: If A.oprnegate = B, then both A and B must yield +-- boolean results, and (x A y) == ! (x B y), or the equivalent for +-- single-operand operators. +-- We expect that B will always say that B.oprnegate = A as well; that's not +-- inherently essential, but it would be inefficient not to mark it so. +-- Also, A and B had better not be the same operator. + +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2 +WHERE o1.oprnegate = o2.oid AND + (o1.oprkind != o2.oprkind OR + o1.oprleft != o2.oprleft OR + o1.oprright != o2.oprright OR + o1.oprresult != 'bool'::regtype OR + o2.oprresult != 'bool'::regtype OR + o1.oid != o2.oprnegate OR + o1.oid = o2.oid) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprnegate" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o2" column="oprkind" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o2" column="oprleft" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="o2" column="oprright" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o2" column="oprresult" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o2" column="oprnegate" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o2" column="oid" +STMT: SelectStmt +== 056 +-- Make a list of the names of operators that are claimed to be commutator +-- pairs. This list will grow over time, but before accepting a new entry +-- make sure you didn't link the wrong operators. + +SELECT DISTINCT o1.oprname AS op1, o2.oprname AS op2 +FROM pg_operator o1, pg_operator o2 +WHERE o1.oprcom = o2.oid AND o1.oprname <= o2.oprname +ORDER BY 1, 2 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprcom" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprname" +FILTER: schema="" table="o2" column="oprname" +STMT: SelectStmt +== 057 +-- Likewise for negator pairs. + +SELECT DISTINCT o1.oprname AS op1, o2.oprname AS op2 +FROM pg_operator o1, pg_operator o2 +WHERE o1.oprnegate = o2.oid AND o1.oprname <= o2.oprname +ORDER BY 1, 2 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprnegate" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprname" +FILTER: schema="" table="o2" column="oprname" +STMT: SelectStmt +== 058 +-- A mergejoinable or hashjoinable operator must be binary, must return +-- boolean, and must have a commutator (itself, unless it's a cross-type +-- operator). + +SELECT o1.oid, o1.oprname FROM pg_operator AS o1 +WHERE (o1.oprcanmerge OR o1.oprcanhash) AND NOT + (o1.oprkind = 'b' AND o1.oprresult = 'bool'::regtype AND o1.oprcom != 0) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprcanmerge" +FILTER: schema="" table="o1" column="oprcanhash" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o1" column="oprcom" +STMT: SelectStmt +== 059 +-- What's more, the commutator had better be mergejoinable/hashjoinable too. + +SELECT o1.oid, o1.oprname, o2.oid, o2.oprname +FROM pg_operator AS o1, pg_operator AS o2 +WHERE o1.oprcom = o2.oid AND + (o1.oprcanmerge != o2.oprcanmerge OR + o1.oprcanhash != o2.oprcanhash) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprcom" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprcanmerge" +FILTER: schema="" table="o2" column="oprcanmerge" +FILTER: schema="" table="o1" column="oprcanhash" +FILTER: schema="" table="o2" column="oprcanhash" +STMT: SelectStmt +== 060 +-- Mergejoinable operators should appear as equality members of btree index +-- opfamilies. + +SELECT o1.oid, o1.oprname +FROM pg_operator AS o1 +WHERE o1.oprcanmerge AND NOT EXISTS + (SELECT 1 FROM pg_amop + WHERE amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') AND + amopopr = o1.oid AND amopstrategy = 3) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprcanmerge" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +== 061 +-- And the converse. + +SELECT o1.oid, o1.oprname, p.amopfamily +FROM pg_operator AS o1, pg_amop p +WHERE amopopr = o1.oid + AND amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') + AND amopstrategy = 3 + AND NOT o1.oprcanmerge +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p"="pg_amop" +FILTER: schema="" table="" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +== 062 +-- Hashable operators should appear as members of hash index opfamilies. + +SELECT o1.oid, o1.oprname +FROM pg_operator AS o1 +WHERE o1.oprcanhash AND NOT EXISTS + (SELECT 1 FROM pg_amop + WHERE amopmethod = (SELECT oid FROM pg_am WHERE amname = 'hash') AND + amopopr = o1.oid AND amopstrategy = 1) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprcanhash" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +== 063 +-- And the converse. + +SELECT o1.oid, o1.oprname, p.amopfamily +FROM pg_operator AS o1, pg_amop p +WHERE amopopr = o1.oid + AND amopmethod = (SELECT oid FROM pg_am WHERE amname = 'hash') + AND NOT o1.oprcanhash +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p"="pg_amop" +FILTER: schema="" table="" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +== 064 +-- Check that each operator defined in pg_operator matches its oprcode entry +-- in pg_proc. Easiest to do this separately for each oprkind. + +SELECT o1.oid, o1.oprname, p1.oid, p1.proname +FROM pg_operator AS o1, pg_proc AS p1 +WHERE o1.oprcode = p1.oid AND + o1.oprkind = 'b' AND + (p1.pronargs != 2 + OR NOT binary_coercible(p1.prorettype, o1.oprresult) + OR NOT binary_coercible(o1.oprleft, p1.proargtypes[0]) + OR NOT binary_coercible(o1.oprright, p1.proargtypes[1])) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 065 +SELECT o1.oid, o1.oprname, p1.oid, p1.proname +FROM pg_operator AS o1, pg_proc AS p1 +WHERE o1.oprcode = p1.oid AND + o1.oprkind = 'l' AND + (p1.pronargs != 1 + OR NOT binary_coercible(p1.prorettype, o1.oprresult) + OR NOT binary_coercible(o1.oprright, p1.proargtypes[0]) + OR o1.oprleft != 0) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="o1" column="oprleft" +STMT: SelectStmt +== 066 +-- If the operator is mergejoinable or hashjoinable, its underlying function +-- should not be volatile. + +SELECT o1.oid, o1.oprname, p1.oid, p1.proname +FROM pg_operator AS o1, pg_proc AS p1 +WHERE o1.oprcode = p1.oid AND + (o1.oprcanmerge OR o1.oprcanhash) AND + p1.provolatile = 'v' +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprcanmerge" +FILTER: schema="" table="o1" column="oprcanhash" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 067 +-- If oprrest is set, the operator must return boolean, +-- and it must link to a proc with the right signature +-- to be a restriction selectivity estimator. +-- The proc signature we want is: float8 proc(internal, oid, internal, int4) + +SELECT o1.oid, o1.oprname, p2.oid, p2.proname +FROM pg_operator AS o1, pg_proc AS p2 +WHERE o1.oprrest = p2.oid AND + (o1.oprresult != 'bool'::regtype OR + p2.prorettype != 'float8'::regtype OR p2.proretset OR + p2.pronargs != 4 OR + p2.proargtypes[0] != 'internal'::regtype OR + p2.proargtypes[1] != 'oid'::regtype OR + p2.proargtypes[2] != 'internal'::regtype OR + p2.proargtypes[3] != 'int4'::regtype) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="o1" column="oprrest" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="p2" column="prorettype" +FILTER: schema="" table="p2" column="proretset" +FILTER: schema="" table="p2" column="pronargs" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 068 +-- If oprjoin is set, the operator must be a binary boolean op, +-- and it must link to a proc with the right signature +-- to be a join selectivity estimator. +-- The proc signature we want is: float8 proc(internal, oid, internal, int2, internal) +-- (Note: the old signature with only 4 args is still allowed, but no core +-- estimator should be using it.) + +SELECT o1.oid, o1.oprname, p2.oid, p2.proname +FROM pg_operator AS o1, pg_proc AS p2 +WHERE o1.oprjoin = p2.oid AND + (o1.oprkind != 'b' OR o1.oprresult != 'bool'::regtype OR + p2.prorettype != 'float8'::regtype OR p2.proretset OR + p2.pronargs != 5 OR + p2.proargtypes[0] != 'internal'::regtype OR + p2.proargtypes[1] != 'oid'::regtype OR + p2.proargtypes[2] != 'internal'::regtype OR + p2.proargtypes[3] != 'int2'::regtype OR + p2.proargtypes[4] != 'internal'::regtype) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="o1" column="oprjoin" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="p2" column="prorettype" +FILTER: schema="" table="p2" column="proretset" +FILTER: schema="" table="p2" column="pronargs" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 069 +-- Insist that all built-in pg_operator entries have descriptions +SELECT o1.oid, o1.oprname +FROM pg_operator as o1 LEFT JOIN pg_description as d + ON o1.tableoid = d.classoid and o1.oid = d.objoid and d.objsubid = 0 +WHERE d.classoid IS NULL AND o1.oid <= 9999 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +ALIAS: "d"="pg_description" +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="d" column="classoid" +FILTER: schema="" table="o1" column="oid" +STMT: SelectStmt +== 070 +-- Check that operators' underlying functions have suitable comments, +-- namely 'implementation of XXX operator'. (Note: it's not necessary to +-- put such comments into pg_proc.dat; initdb will generate them as needed.) +-- In some cases involving legacy names for operators, there are multiple +-- operators referencing the same pg_proc entry, so ignore operators whose +-- comments say they are deprecated. +-- We also have a few functions that are both operator support and meant to +-- be called directly; those should have comments matching their operator. +WITH funcdescs AS ( + SELECT p.oid as p_oid, proname, o.oid as o_oid, + pd.description as prodesc, + 'implementation of ' || oprname || ' operator' as expecteddesc, + od.description as oprdesc + FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid + LEFT JOIN pg_description pd ON + (pd.objoid = p.oid and pd.classoid = p.tableoid and pd.objsubid = 0) + LEFT JOIN pg_description od ON + (od.objoid = o.oid and od.classoid = o.tableoid and od.objsubid = 0) + WHERE o.oid <= 9999 +) +SELECT * FROM funcdescs + WHERE prodesc IS DISTINCT FROM expecteddesc + AND oprdesc NOT LIKE 'deprecated%' + AND prodesc IS DISTINCT FROM oprdesc +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +ALIAS: "o"="pg_operator" +ALIAS: "od"="pg_description" +ALIAS: "p"="pg_proc" +ALIAS: "pd"="pg_description" +CTE: "funcdescs" +FILTER: schema="" table="" column="prodesc" +FILTER: schema="" table="" column="expecteddesc" +FILTER: schema="" table="" column="oprdesc" +FILTER: schema="" table="" column="prodesc" +FILTER: schema="" table="" column="oprdesc" +FILTER: schema="" table="o" column="oid" +STMT: SelectStmt +== 071 +-- Show all the operator-implementation functions that have their own +-- comments. This should happen only in cases where the function and +-- operator syntaxes are both documented at the user level. +-- This should be a pretty short list; it's mostly legacy cases. +WITH funcdescs AS ( + SELECT p.oid as p_oid, proname, o.oid as o_oid, + pd.description as prodesc, + 'implementation of ' || oprname || ' operator' as expecteddesc, + od.description as oprdesc + FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid + LEFT JOIN pg_description pd ON + (pd.objoid = p.oid and pd.classoid = p.tableoid and pd.objsubid = 0) + LEFT JOIN pg_description od ON + (od.objoid = o.oid and od.classoid = o.tableoid and od.objsubid = 0) + WHERE o.oid <= 9999 +) +SELECT p_oid, proname, prodesc FROM funcdescs + WHERE prodesc IS DISTINCT FROM expecteddesc + AND oprdesc NOT LIKE 'deprecated%' +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +ALIAS: "o"="pg_operator" +ALIAS: "od"="pg_description" +ALIAS: "p"="pg_proc" +ALIAS: "pd"="pg_description" +CTE: "funcdescs" +FILTER: schema="" table="" column="prodesc" +FILTER: schema="" table="" column="expecteddesc" +FILTER: schema="" table="" column="oprdesc" +FILTER: schema="" table="o" column="oid" +STMT: SelectStmt +== 072 +-- Operators that are commutator pairs should have identical volatility +-- and leakproofness markings on their implementation functions. +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2, pg_proc AS p1, pg_proc AS p2 +WHERE o1.oprcom = o2.oid AND p1.oid = o1.oprcode AND p2.oid = o2.oprcode AND + (p1.provolatile != p2.provolatile OR + p1.proleakproof != p2.proleakproof) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="o1" column="oprcom" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="o2" column="oprcode" +FILTER: schema="" table="p1" column="provolatile" +FILTER: schema="" table="p2" column="provolatile" +FILTER: schema="" table="p1" column="proleakproof" +FILTER: schema="" table="p2" column="proleakproof" +STMT: SelectStmt +== 073 +-- Likewise for negator pairs. +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2, pg_proc AS p1, pg_proc AS p2 +WHERE o1.oprnegate = o2.oid AND p1.oid = o1.oprcode AND p2.oid = o2.oprcode AND + (p1.provolatile != p2.provolatile OR + p1.proleakproof != p2.proleakproof) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="o1" column="oprnegate" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="o2" column="oprcode" +FILTER: schema="" table="p1" column="provolatile" +FILTER: schema="" table="p2" column="provolatile" +FILTER: schema="" table="p1" column="proleakproof" +FILTER: schema="" table="p2" column="proleakproof" +STMT: SelectStmt +== 074 +-- Btree comparison operators' functions should have the same volatility +-- and leakproofness markings as the associated comparison support function. +SELECT pp.oid::regprocedure as proc, pp.provolatile as vp, pp.proleakproof as lp, + po.oid::regprocedure as opr, po.provolatile as vo, po.proleakproof as lo +FROM pg_proc pp, pg_proc po, pg_operator o, pg_amproc ap, pg_amop ao +WHERE pp.oid = ap.amproc AND po.oid = o.oprcode AND o.oid = ao.amopopr AND + ao.amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') AND + ao.amopfamily = ap.amprocfamily AND + ao.amoplefttype = ap.amproclefttype AND + ao.amoprighttype = ap.amprocrighttype AND + ap.amprocnum = 1 AND + (pp.provolatile != po.provolatile OR + pp.proleakproof != po.proleakproof) +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "ao"="pg_amop" +ALIAS: "ap"="pg_amproc" +ALIAS: "o"="pg_operator" +ALIAS: "po"="pg_proc" +ALIAS: "pp"="pg_proc" +FILTER: schema="" table="pp" column="oid" +FILTER: schema="" table="ap" column="amproc" +FILTER: schema="" table="po" column="oid" +FILTER: schema="" table="o" column="oprcode" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="ao" column="amopopr" +FILTER: schema="" table="ao" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +== 075 +-- **************** pg_aggregate **************** + +-- Look for illegal values in pg_aggregate fields. + +SELECT ctid, aggfnoid::oid +FROM pg_aggregate as a +WHERE aggfnoid = 0 OR aggtransfn = 0 OR + aggkind NOT IN ('n', 'o', 'h') OR + aggnumdirectargs < 0 OR + (aggkind = 'n' AND aggnumdirectargs > 0) OR + aggfinalmodify NOT IN ('r', 's', 'w') OR + aggmfinalmodify NOT IN ('r', 's', 'w') OR + aggtranstype = 0 OR aggtransspace < 0 OR aggmtransspace < 0 +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +FILTER: schema="" table="" column="aggfnoid" +FILTER: schema="" table="" column="aggtransfn" +FILTER: schema="" table="" column="aggkind" +FILTER: schema="" table="" column="aggnumdirectargs" +FILTER: schema="" table="" column="aggkind" +FILTER: schema="" table="" column="aggnumdirectargs" +FILTER: schema="" table="" column="aggfinalmodify" +FILTER: schema="" table="" column="aggmfinalmodify" +FILTER: schema="" table="" column="aggtranstype" +FILTER: schema="" table="" column="aggtransspace" +FILTER: schema="" table="" column="aggmtransspace" +STMT: SelectStmt +== 076 +-- Make sure the matching pg_proc entry is sensible, too. + +SELECT a.aggfnoid::oid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggfnoid = p.oid AND + (p.prokind != 'a' OR p.proretset OR p.pronargs < a.aggnumdirectargs) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="prokind" +FILTER: schema="" table="p" column="proretset" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +STMT: SelectStmt +== 077 +-- Make sure there are no prokind = PROKIND_AGGREGATE pg_proc entries without matches. + +SELECT oid, proname +FROM pg_proc as p +WHERE p.prokind = 'a' AND + NOT EXISTS (SELECT 1 FROM pg_aggregate a WHERE a.aggfnoid = p.oid) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="p" column="prokind" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +STMT: SelectStmt +== 078 +-- If there is no finalfn then the output type must be the transtype. + +SELECT a.aggfnoid::oid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggfnoid = p.oid AND + a.aggfinalfn = 0 AND p.prorettype != a.aggtranstype +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggfinalfn" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="a" column="aggtranstype" +STMT: SelectStmt +== 079 +-- Cross-check transfn against its entry in pg_proc. +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggtransfn = ptr.oid AND + (ptr.proretset + OR NOT (ptr.pronargs = + CASE WHEN a.aggkind = 'n' THEN p.pronargs + 1 + ELSE greatest(p.pronargs - a.aggnumdirectargs, 1) + 1 END) + OR NOT binary_coercible(ptr.prorettype, a.aggtranstype) + OR NOT binary_coercible(a.aggtranstype, ptr.proargtypes[0]) + OR (p.pronargs > 0 AND + NOT binary_coercible(p.proargtypes[0], ptr.proargtypes[1])) + OR (p.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[1], ptr.proargtypes[2])) + OR (p.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[2], ptr.proargtypes[3])) + OR (p.pronargs > 3 AND + NOT binary_coercible(p.proargtypes[3], ptr.proargtypes[4])) + -- we could carry the check further, but 4 args is enough for now + OR (p.pronargs > 4) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proretset" +FILTER: schema="" table="ptr" column="pronargs" +FILTER: schema="" table="a" column="aggkind" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="ptr" column="prorettype" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +STMT: SelectStmt +== 080 +-- Cross-check finalfn (if present) against its entry in pg_proc. + +SELECT a.aggfnoid::oid, p.proname, pfn.oid, pfn.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS pfn +WHERE a.aggfnoid = p.oid AND + a.aggfinalfn = pfn.oid AND + (pfn.proretset OR + NOT binary_coercible(pfn.prorettype, p.prorettype) OR + NOT binary_coercible(a.aggtranstype, pfn.proargtypes[0]) OR + CASE WHEN a.aggfinalextra THEN pfn.pronargs != p.pronargs + 1 + ELSE pfn.pronargs != a.aggnumdirectargs + 1 END + OR (pfn.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[0], pfn.proargtypes[1])) + OR (pfn.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[1], pfn.proargtypes[2])) + OR (pfn.pronargs > 3 AND + NOT binary_coercible(p.proargtypes[2], pfn.proargtypes[3])) + -- we could carry the check further, but 4 args is enough for now + OR (pfn.pronargs > 4) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "pfn"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggfinalfn" +FILTER: schema="" table="pfn" column="oid" +FILTER: schema="" table="pfn" column="proretset" +FILTER: schema="" table="pfn" column="prorettype" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="a" column="aggfinalextra" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +STMT: SelectStmt +== 081 +-- If transfn is strict then either initval should be non-NULL, or +-- input type should match transtype so that the first non-null input +-- can be assigned as the state value. + +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggtransfn = ptr.oid AND ptr.proisstrict AND + a.agginitval IS NULL AND + NOT binary_coercible(p.proargtypes[0], a.aggtranstype) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proisstrict" +FILTER: schema="" table="a" column="agginitval" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="a" column="aggtranstype" +STMT: SelectStmt +== 082 +-- Check for inconsistent specifications of moving-aggregate columns. + +SELECT ctid, aggfnoid::oid +FROM pg_aggregate as a +WHERE aggmtranstype != 0 AND + (aggmtransfn = 0 OR aggminvtransfn = 0) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +FILTER: schema="" table="" column="aggmtranstype" +FILTER: schema="" table="" column="aggmtransfn" +FILTER: schema="" table="" column="aggminvtransfn" +STMT: SelectStmt +== 083 +SELECT ctid, aggfnoid::oid +FROM pg_aggregate as a +WHERE aggmtranstype = 0 AND + (aggmtransfn != 0 OR aggminvtransfn != 0 OR aggmfinalfn != 0 OR + aggmtransspace != 0 OR aggminitval IS NOT NULL) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +FILTER: schema="" table="" column="aggmtranstype" +FILTER: schema="" table="" column="aggmtransfn" +FILTER: schema="" table="" column="aggminvtransfn" +FILTER: schema="" table="" column="aggmfinalfn" +FILTER: schema="" table="" column="aggmtransspace" +FILTER: schema="" table="" column="aggminitval" +STMT: SelectStmt +== 084 +-- If there is no mfinalfn then the output type must be the mtranstype. + +SELECT a.aggfnoid::oid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggfnoid = p.oid AND + a.aggmtransfn != 0 AND + a.aggmfinalfn = 0 AND p.prorettype != a.aggmtranstype +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmtransfn" +FILTER: schema="" table="a" column="aggmfinalfn" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="a" column="aggmtranstype" +STMT: SelectStmt +== 085 +-- Cross-check mtransfn (if present) against its entry in pg_proc. +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggmtransfn = ptr.oid AND + (ptr.proretset + OR NOT (ptr.pronargs = + CASE WHEN a.aggkind = 'n' THEN p.pronargs + 1 + ELSE greatest(p.pronargs - a.aggnumdirectargs, 1) + 1 END) + OR NOT binary_coercible(ptr.prorettype, a.aggmtranstype) + OR NOT binary_coercible(a.aggmtranstype, ptr.proargtypes[0]) + OR (p.pronargs > 0 AND + NOT binary_coercible(p.proargtypes[0], ptr.proargtypes[1])) + OR (p.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[1], ptr.proargtypes[2])) + OR (p.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[2], ptr.proargtypes[3])) + -- we could carry the check further, but 3 args is enough for now + OR (p.pronargs > 3) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proretset" +FILTER: schema="" table="ptr" column="pronargs" +FILTER: schema="" table="a" column="aggkind" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="ptr" column="prorettype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +STMT: SelectStmt +== 086 +-- Cross-check minvtransfn (if present) against its entry in pg_proc. +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggminvtransfn = ptr.oid AND + (ptr.proretset + OR NOT (ptr.pronargs = + CASE WHEN a.aggkind = 'n' THEN p.pronargs + 1 + ELSE greatest(p.pronargs - a.aggnumdirectargs, 1) + 1 END) + OR NOT binary_coercible(ptr.prorettype, a.aggmtranstype) + OR NOT binary_coercible(a.aggmtranstype, ptr.proargtypes[0]) + OR (p.pronargs > 0 AND + NOT binary_coercible(p.proargtypes[0], ptr.proargtypes[1])) + OR (p.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[1], ptr.proargtypes[2])) + OR (p.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[2], ptr.proargtypes[3])) + -- we could carry the check further, but 3 args is enough for now + OR (p.pronargs > 3) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggminvtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proretset" +FILTER: schema="" table="ptr" column="pronargs" +FILTER: schema="" table="a" column="aggkind" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="ptr" column="prorettype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +STMT: SelectStmt +== 087 +-- Cross-check mfinalfn (if present) against its entry in pg_proc. + +SELECT a.aggfnoid::oid, p.proname, pfn.oid, pfn.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS pfn +WHERE a.aggfnoid = p.oid AND + a.aggmfinalfn = pfn.oid AND + (pfn.proretset OR + NOT binary_coercible(pfn.prorettype, p.prorettype) OR + NOT binary_coercible(a.aggmtranstype, pfn.proargtypes[0]) OR + CASE WHEN a.aggmfinalextra THEN pfn.pronargs != p.pronargs + 1 + ELSE pfn.pronargs != a.aggnumdirectargs + 1 END + OR (pfn.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[0], pfn.proargtypes[1])) + OR (pfn.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[1], pfn.proargtypes[2])) + OR (pfn.pronargs > 3 AND + NOT binary_coercible(p.proargtypes[2], pfn.proargtypes[3])) + -- we could carry the check further, but 4 args is enough for now + OR (pfn.pronargs > 4) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "pfn"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmfinalfn" +FILTER: schema="" table="pfn" column="oid" +FILTER: schema="" table="pfn" column="proretset" +FILTER: schema="" table="pfn" column="prorettype" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="a" column="aggmfinalextra" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +STMT: SelectStmt +== 088 +-- If mtransfn is strict then either minitval should be non-NULL, or +-- input type should match mtranstype so that the first non-null input +-- can be assigned as the state value. + +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggmtransfn = ptr.oid AND ptr.proisstrict AND + a.aggminitval IS NULL AND + NOT binary_coercible(p.proargtypes[0], a.aggmtranstype) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proisstrict" +FILTER: schema="" table="a" column="aggminitval" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="a" column="aggmtranstype" +STMT: SelectStmt +== 089 +-- mtransfn and minvtransfn should have same strictness setting. + +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname, iptr.oid, iptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr, pg_proc AS iptr +WHERE a.aggfnoid = p.oid AND + a.aggmtransfn = ptr.oid AND + a.aggminvtransfn = iptr.oid AND + ptr.proisstrict != iptr.proisstrict +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "iptr"="pg_proc" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="a" column="aggminvtransfn" +FILTER: schema="" table="iptr" column="oid" +FILTER: schema="" table="ptr" column="proisstrict" +FILTER: schema="" table="iptr" column="proisstrict" +STMT: SelectStmt +== 090 +-- Check that all combine functions have signature +-- combine(transtype, transtype) returns transtype + +SELECT a.aggfnoid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggcombinefn = p.oid AND + (p.pronargs != 2 OR + p.prorettype != p.proargtypes[0] OR + p.prorettype != p.proargtypes[1] OR + NOT binary_coercible(a.aggtranstype, p.proargtypes[0])) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggcombinefn" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="p" column="proargtypes" +STMT: SelectStmt +== 091 +-- Check that no combine function for an INTERNAL transtype is strict. + +SELECT a.aggfnoid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggcombinefn = p.oid AND + a.aggtranstype = 'internal'::regtype AND p.proisstrict +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggcombinefn" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="p" column="proisstrict" +STMT: SelectStmt +== 092 +-- serialize/deserialize functions should be specified only for aggregates +-- with transtype internal and a combine function, and we should have both +-- or neither of them. + +SELECT aggfnoid, aggtranstype, aggserialfn, aggdeserialfn +FROM pg_aggregate +WHERE (aggserialfn != 0 OR aggdeserialfn != 0) + AND (aggtranstype != 'internal'::regtype OR aggcombinefn = 0 OR + aggserialfn = 0 OR aggdeserialfn = 0) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +FILTER: schema="" table="" column="aggserialfn" +FILTER: schema="" table="" column="aggdeserialfn" +FILTER: schema="" table="" column="aggtranstype" +FILTER: schema="" table="" column="aggcombinefn" +FILTER: schema="" table="" column="aggserialfn" +FILTER: schema="" table="" column="aggdeserialfn" +STMT: SelectStmt +== 093 +-- Check that all serialization functions have signature +-- serialize(internal) returns bytea +-- Also insist that they be strict; it's wasteful to run them on NULLs. + +SELECT a.aggfnoid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggserialfn = p.oid AND + (p.prorettype != 'bytea'::regtype OR p.pronargs != 1 OR + p.proargtypes[0] != 'internal'::regtype OR + NOT p.proisstrict) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggserialfn" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proisstrict" +STMT: SelectStmt +== 094 +-- Check that all deserialization functions have signature +-- deserialize(bytea, internal) returns internal +-- Also insist that they be strict; it's wasteful to run them on NULLs. + +SELECT a.aggfnoid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggdeserialfn = p.oid AND + (p.prorettype != 'internal'::regtype OR p.pronargs != 2 OR + p.proargtypes[0] != 'bytea'::regtype OR + p.proargtypes[1] != 'internal'::regtype OR + NOT p.proisstrict) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggdeserialfn" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proisstrict" +STMT: SelectStmt +== 095 +-- Check that aggregates which have the same transition function also have +-- the same combine, serialization, and deserialization functions. +-- While that isn't strictly necessary, it's fishy if they don't. + +SELECT a.aggfnoid, a.aggcombinefn, a.aggserialfn, a.aggdeserialfn, + b.aggfnoid, b.aggcombinefn, b.aggserialfn, b.aggdeserialfn +FROM + pg_aggregate a, pg_aggregate b +WHERE + a.aggfnoid < b.aggfnoid AND a.aggtransfn = b.aggtransfn AND + (a.aggcombinefn != b.aggcombinefn OR a.aggserialfn != b.aggserialfn + OR a.aggdeserialfn != b.aggdeserialfn) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "b"="pg_aggregate" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="b" column="aggfnoid" +FILTER: schema="" table="a" column="aggtransfn" +FILTER: schema="" table="b" column="aggtransfn" +FILTER: schema="" table="a" column="aggcombinefn" +FILTER: schema="" table="b" column="aggcombinefn" +FILTER: schema="" table="a" column="aggserialfn" +FILTER: schema="" table="b" column="aggserialfn" +FILTER: schema="" table="a" column="aggdeserialfn" +FILTER: schema="" table="b" column="aggdeserialfn" +STMT: SelectStmt +== 096 +-- Cross-check aggsortop (if present) against pg_operator. +-- We expect to find entries for bool_and, bool_or, every, max, and min. + +SELECT DISTINCT proname, oprname +FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p +WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid +ORDER BY 1, 2 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "o"="pg_operator" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggsortop" +FILTER: schema="" table="o" column="oid" +STMT: SelectStmt +== 097 +-- Check datatypes match + +SELECT a.aggfnoid::oid, o.oid +FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p +WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid AND + (oprkind != 'b' OR oprresult != 'boolean'::regtype + OR oprleft != p.proargtypes[0] OR oprright != p.proargtypes[0]) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "o"="pg_operator" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggsortop" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="" column="oprkind" +FILTER: schema="" table="" column="oprresult" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="" column="oprright" +FILTER: schema="" table="p" column="proargtypes" +STMT: SelectStmt +== 098 +-- Check operator is a suitable btree opfamily member + +SELECT a.aggfnoid::oid, o.oid +FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p +WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid AND + NOT EXISTS(SELECT 1 FROM pg_amop + WHERE amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') + AND amopopr = o.oid + AND amoplefttype = o.oprleft + AND amoprighttype = o.oprright) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "o"="pg_operator" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggsortop" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +== 099 +-- Check correspondence of btree strategies and names + +SELECT DISTINCT proname, oprname, amopstrategy +FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p, + pg_amop as ao +WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid AND + amopopr = o.oid AND + amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') +ORDER BY 1, 2 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "ao"="pg_amop" +ALIAS: "o"="pg_operator" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggsortop" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="" column="amopopr" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +== 100 +-- Check that there are not aggregates with the same name and different +-- numbers of arguments. While not technically wrong, we have a project policy +-- to avoid this because it opens the door for confusion in connection with +-- ORDER BY: novices frequently put the ORDER BY in the wrong place. +-- See the fate of the single-argument form of string_agg() for history. +-- (Note: we don't forbid users from creating such aggregates; the policy is +-- just to think twice before creating built-in aggregates like this.) +-- The only aggregates that should show up here are count(x) and count(*). + +SELECT p1.oid::regprocedure, p2.oid::regprocedure +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid < p2.oid AND p1.proname = p2.proname AND + p1.prokind = 'a' AND p2.prokind = 'a' AND + array_dims(p1.proargtypes) != array_dims(p2.proargtypes) +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="proname" +FILTER: schema="" table="p2" column="proname" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +== 101 +-- For the same reason, built-in aggregates with default arguments are no good. + +SELECT oid, proname +FROM pg_proc AS p +WHERE prokind = 'a' AND proargdefaults IS NOT NULL +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p"="pg_proc" +FILTER: schema="" table="" column="prokind" +FILTER: schema="" table="" column="proargdefaults" +STMT: SelectStmt +== 102 +-- For the same reason, we avoid creating built-in variadic aggregates, except +-- that variadic ordered-set aggregates are OK (since they have special syntax +-- that is not subject to the misplaced ORDER BY issue). + +SELECT p.oid, proname +FROM pg_proc AS p JOIN pg_aggregate AS a ON a.aggfnoid = p.oid +WHERE prokind = 'a' AND provariadic != 0 AND a.aggkind = 'n' +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="" column="prokind" +FILTER: schema="" table="" column="provariadic" +FILTER: schema="" table="a" column="aggkind" +STMT: SelectStmt +== 103 +-- **************** pg_opfamily **************** + +-- Look for illegal values in pg_opfamily fields + +SELECT f.oid +FROM pg_opfamily as f +WHERE f.opfmethod = 0 OR f.opfnamespace = 0 +-- +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +ALIAS: "f"="pg_opfamily" +FILTER: schema="" table="f" column="opfmethod" +FILTER: schema="" table="f" column="opfnamespace" +STMT: SelectStmt +== 104 +-- Look for opfamilies having no opclasses. While most validation of +-- opfamilies is now handled by AM-specific amvalidate functions, that's +-- driven from pg_opclass entries below, so an empty opfamily would not +-- get noticed. + +SELECT oid, opfname FROM pg_opfamily f +WHERE NOT EXISTS (SELECT 1 FROM pg_opclass WHERE opcfamily = f.oid) +-- +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +ALIAS: "f"="pg_opfamily" +FILTER: schema="" table="" column="opcfamily" +FILTER: schema="" table="f" column="oid" +STMT: SelectStmt +== 105 +-- **************** pg_opclass **************** + +-- Look for illegal values in pg_opclass fields + +SELECT c1.oid +FROM pg_opclass AS c1 +WHERE c1.opcmethod = 0 OR c1.opcnamespace = 0 OR c1.opcfamily = 0 + OR c1.opcintype = 0 +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +ALIAS: "c1"="pg_opclass" +FILTER: schema="" table="c1" column="opcmethod" +FILTER: schema="" table="c1" column="opcnamespace" +FILTER: schema="" table="c1" column="opcfamily" +FILTER: schema="" table="c1" column="opcintype" +STMT: SelectStmt +== 106 +-- opcmethod must match owning opfamily's opfmethod + +SELECT c1.oid, f1.oid +FROM pg_opclass AS c1, pg_opfamily AS f1 +WHERE c1.opcfamily = f1.oid AND c1.opcmethod != f1.opfmethod +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +ALIAS: "c1"="pg_opclass" +ALIAS: "f1"="pg_opfamily" +FILTER: schema="" table="c1" column="opcfamily" +FILTER: schema="" table="f1" column="oid" +FILTER: schema="" table="c1" column="opcmethod" +FILTER: schema="" table="f1" column="opfmethod" +STMT: SelectStmt +== 107 +-- There should not be multiple entries in pg_opclass with opcdefault true +-- and the same opcmethod/opcintype combination. + +SELECT c1.oid, c2.oid +FROM pg_opclass AS c1, pg_opclass AS c2 +WHERE c1.oid != c2.oid AND + c1.opcmethod = c2.opcmethod AND c1.opcintype = c2.opcintype AND + c1.opcdefault AND c2.opcdefault +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +ALIAS: "c1"="pg_opclass" +ALIAS: "c2"="pg_opclass" +FILTER: schema="" table="c1" column="oid" +FILTER: schema="" table="c2" column="oid" +FILTER: schema="" table="c1" column="opcmethod" +FILTER: schema="" table="c2" column="opcmethod" +FILTER: schema="" table="c1" column="opcintype" +FILTER: schema="" table="c2" column="opcintype" +FILTER: schema="" table="c1" column="opcdefault" +FILTER: schema="" table="c2" column="opcdefault" +STMT: SelectStmt +== 108 +-- Ask access methods to validate opclasses +-- (this replaces a lot of SQL-level checks that used to be done in this file) + +SELECT oid, opcname FROM pg_opclass WHERE NOT amvalidate(oid) +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +FUNCTION: name="amvalidate" function="amvalidate" schema="" ctx=Call +FUNCTION: name="amvalidate" function="amvalidate" schema="" ctx=Call +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 109 +-- **************** pg_am **************** + +-- Look for illegal values in pg_am fields + +SELECT a1.oid, a1.amname +FROM pg_am AS a1 +WHERE a1.amhandler = 0 +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a1"="pg_am" +FILTER: schema="" table="a1" column="amhandler" +STMT: SelectStmt +== 110 +-- Check for index amhandler functions with the wrong signature + +SELECT a1.oid, a1.amname, p1.oid, p1.proname +FROM pg_am AS a1, pg_proc AS p1 +WHERE p1.oid = a1.amhandler AND a1.amtype = 'i' AND + (p1.prorettype != 'index_am_handler'::regtype + OR p1.proretset + OR p1.pronargs != 1 + OR p1.proargtypes[0] != 'internal'::regtype) +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_am" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amhandler" +FILTER: schema="" table="a1" column="amtype" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 111 +-- Check for table amhandler functions with the wrong signature + +SELECT a1.oid, a1.amname, p1.oid, p1.proname +FROM pg_am AS a1, pg_proc AS p1 +WHERE p1.oid = a1.amhandler AND a1.amtype = 't' AND + (p1.prorettype != 'table_am_handler'::regtype + OR p1.proretset + OR p1.pronargs != 1 + OR p1.proargtypes[0] != 'internal'::regtype) +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_am" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amhandler" +FILTER: schema="" table="a1" column="amtype" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 112 +-- **************** pg_amop **************** + +-- Look for illegal values in pg_amop fields + +SELECT a1.amopfamily, a1.amopstrategy +FROM pg_amop as a1 +WHERE a1.amopfamily = 0 OR a1.amoplefttype = 0 OR a1.amoprighttype = 0 + OR a1.amopopr = 0 OR a1.amopmethod = 0 OR a1.amopstrategy < 1 +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +ALIAS: "a1"="pg_amop" +FILTER: schema="" table="a1" column="amopfamily" +FILTER: schema="" table="a1" column="amoplefttype" +FILTER: schema="" table="a1" column="amoprighttype" +FILTER: schema="" table="a1" column="amopopr" +FILTER: schema="" table="a1" column="amopmethod" +FILTER: schema="" table="a1" column="amopstrategy" +STMT: SelectStmt +== 113 +SELECT a1.amopfamily, a1.amopstrategy +FROM pg_amop as a1 +WHERE NOT ((a1.amoppurpose = 's' AND a1.amopsortfamily = 0) OR + (a1.amoppurpose = 'o' AND a1.amopsortfamily <> 0)) +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +ALIAS: "a1"="pg_amop" +FILTER: schema="" table="a1" column="amoppurpose" +FILTER: schema="" table="a1" column="amopsortfamily" +FILTER: schema="" table="a1" column="amoppurpose" +FILTER: schema="" table="a1" column="amopsortfamily" +STMT: SelectStmt +== 114 +-- amopmethod must match owning opfamily's opfmethod + +SELECT a1.oid, f1.oid +FROM pg_amop AS a1, pg_opfamily AS f1 +WHERE a1.amopfamily = f1.oid AND a1.amopmethod != f1.opfmethod +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "f1"="pg_opfamily" +FILTER: schema="" table="a1" column="amopfamily" +FILTER: schema="" table="f1" column="oid" +FILTER: schema="" table="a1" column="amopmethod" +FILTER: schema="" table="f1" column="opfmethod" +STMT: SelectStmt +== 115 +-- Make a list of all the distinct operator names being used in particular +-- strategy slots. This is a bit hokey, since the list might need to change +-- in future releases, but it's an effective way of spotting mistakes such as +-- swapping two operators within a family. + +SELECT DISTINCT amopmethod, amopstrategy, oprname +FROM pg_amop a1 LEFT JOIN pg_operator o1 ON amopopr = o1.oid +ORDER BY 1, 2, 3 +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "o1"="pg_operator" +STMT: SelectStmt +== 116 +-- Check that all opclass search operators have selectivity estimators. +-- This is not absolutely required, but it seems a reasonable thing +-- to insist on for all standard datatypes. + +SELECT a1.amopfamily, a1.amopopr, o1.oid, o1.oprname +FROM pg_amop AS a1, pg_operator AS o1 +WHERE a1.amopopr = o1.oid AND a1.amoppurpose = 's' AND + (o1.oprrest = 0 OR o1.oprjoin = 0) +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="a1" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="a1" column="amoppurpose" +FILTER: schema="" table="o1" column="oprrest" +FILTER: schema="" table="o1" column="oprjoin" +STMT: SelectStmt +== 117 +-- Check that each opclass in an opfamily has associated operators, that is +-- ones whose oprleft matches opcintype (possibly by coercion). + +SELECT c1.opcname, c1.opcfamily +FROM pg_opclass AS c1 +WHERE NOT EXISTS(SELECT 1 FROM pg_amop AS a1 + WHERE a1.amopfamily = c1.opcfamily + AND binary_coercible(c1.opcintype, a1.amoplefttype)) +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "c1"="pg_opclass" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a1" column="amopfamily" +FILTER: schema="" table="c1" column="opcfamily" +FILTER: schema="" table="c1" column="opcintype" +FILTER: schema="" table="a1" column="amoplefttype" +STMT: SelectStmt +== 118 +-- Check that each operator listed in pg_amop has an associated opclass, +-- that is one whose opcintype matches oprleft (possibly by coercion). +-- Otherwise the operator is useless because it cannot be matched to an index. +-- (In principle it could be useful to list such operators in multiple-datatype +-- btree opfamilies, but in practice you'd expect there to be an opclass for +-- every datatype the family knows about.) + +SELECT a1.amopfamily, a1.amopstrategy, a1.amopopr +FROM pg_amop AS a1 +WHERE NOT EXISTS(SELECT 1 FROM pg_opclass AS c1 + WHERE c1.opcfamily = a1.amopfamily + AND binary_coercible(c1.opcintype, a1.amoplefttype)) +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "c1"="pg_opclass" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="c1" column="opcfamily" +FILTER: schema="" table="a1" column="amopfamily" +FILTER: schema="" table="c1" column="opcintype" +FILTER: schema="" table="a1" column="amoplefttype" +STMT: SelectStmt +== 119 +-- Operators that are primary members of opclasses must be immutable (else +-- it suggests that the index ordering isn't fixed). Operators that are +-- cross-type members need only be stable, since they are just shorthands +-- for index probe queries. + +SELECT a1.amopfamily, a1.amopopr, o1.oprname, p1.prosrc +FROM pg_amop AS a1, pg_operator AS o1, pg_proc AS p1 +WHERE a1.amopopr = o1.oid AND o1.oprcode = p1.oid AND + a1.amoplefttype = a1.amoprighttype AND + p1.provolatile != 'i' +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="a1" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amoplefttype" +FILTER: schema="" table="a1" column="amoprighttype" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 120 +SELECT a1.amopfamily, a1.amopopr, o1.oprname, p1.prosrc +FROM pg_amop AS a1, pg_operator AS o1, pg_proc AS p1 +WHERE a1.amopopr = o1.oid AND o1.oprcode = p1.oid AND + a1.amoplefttype != a1.amoprighttype AND + p1.provolatile = 'v' +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="a1" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amoplefttype" +FILTER: schema="" table="a1" column="amoprighttype" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 121 +-- **************** pg_amproc **************** + +-- Look for illegal values in pg_amproc fields + +SELECT a1.amprocfamily, a1.amprocnum +FROM pg_amproc as a1 +WHERE a1.amprocfamily = 0 OR a1.amproclefttype = 0 OR a1.amprocrighttype = 0 + OR a1.amprocnum < 0 OR a1.amproc = 0 +-- +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +ALIAS: "a1"="pg_amproc" +FILTER: schema="" table="a1" column="amprocfamily" +FILTER: schema="" table="a1" column="amproclefttype" +FILTER: schema="" table="a1" column="amprocrighttype" +FILTER: schema="" table="a1" column="amprocnum" +FILTER: schema="" table="a1" column="amproc" +STMT: SelectStmt +== 122 +-- Support routines that are primary members of opfamilies must be immutable +-- (else it suggests that the index ordering isn't fixed). But cross-type +-- members need only be stable, since they are just shorthands +-- for index probe queries. + +SELECT a1.amprocfamily, a1.amproc, p1.prosrc +FROM pg_amproc AS a1, pg_proc AS p1 +WHERE a1.amproc = p1.oid AND + a1.amproclefttype = a1.amprocrighttype AND + p1.provolatile != 'i' +-- +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_amproc" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="a1" column="amproc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amproclefttype" +FILTER: schema="" table="a1" column="amprocrighttype" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 123 +SELECT a1.amprocfamily, a1.amproc, p1.prosrc +FROM pg_amproc AS a1, pg_proc AS p1 +WHERE a1.amproc = p1.oid AND + a1.amproclefttype != a1.amprocrighttype AND + p1.provolatile = 'v' +-- +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_amproc" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="a1" column="amproc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amproclefttype" +FILTER: schema="" table="a1" column="amprocrighttype" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 124 +-- Almost all of the core distribution's Btree opclasses can use one of the +-- two generic "equalimage" functions as their support function 4. Look for +-- opclasses that don't allow deduplication unconditionally here. +|-- +-- Newly added Btree opclasses don't have to support deduplication. It will +-- usually be trivial to add support, though. Note that the expected output +-- of this part of the test will need to be updated when a new opclass cannot +-- support deduplication (by using btequalimage). +SELECT amp.amproc::regproc AS proc, opf.opfname AS opfamily_name, + opc.opcname AS opclass_name, opc.opcintype::regtype AS opcintype +FROM pg_am AS am +JOIN pg_opclass AS opc ON opc.opcmethod = am.oid +JOIN pg_opfamily AS opf ON opc.opcfamily = opf.oid +LEFT JOIN pg_amproc AS amp ON amp.amprocfamily = opf.oid AND + amp.amproclefttype = opc.opcintype AND amp.amprocnum = 4 +WHERE am.amname = 'btree' AND + amp.amproc IS DISTINCT FROM 'btequalimage'::regproc +ORDER BY 1, 2, 3 +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "amp"="pg_amproc" +ALIAS: "opc"="pg_opclass" +ALIAS: "opf"="pg_opfamily" +FILTER: schema="" table="am" column="amname" +FILTER: schema="" table="amp" column="amproc" +STMT: SelectStmt +== 125 +-- **************** pg_index **************** + +-- Look for illegal values in pg_index fields. + +SELECT indexrelid, indrelid +FROM pg_index +WHERE indexrelid = 0 OR indrelid = 0 OR + indnatts <= 0 OR indnatts > 32 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indexrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indnatts" +STMT: SelectStmt +== 126 +-- oidvector and int2vector fields should be of length indnatts. + +SELECT indexrelid, indrelid +FROM pg_index +WHERE array_lower(indkey, 1) != 0 OR array_upper(indkey, 1) != indnatts-1 OR + array_lower(indclass, 1) != 0 OR array_upper(indclass, 1) != indnatts-1 OR + array_lower(indcollation, 1) != 0 OR array_upper(indcollation, 1) != indnatts-1 OR + array_lower(indoption, 1) != 0 OR array_upper(indoption, 1) != indnatts-1 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FILTER: schema="" table="" column="indkey" +FILTER: schema="" table="" column="indkey" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indclass" +FILTER: schema="" table="" column="indclass" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indcollation" +FILTER: schema="" table="" column="indcollation" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indoption" +FILTER: schema="" table="" column="indoption" +FILTER: schema="" table="" column="indnatts" +STMT: SelectStmt +== 127 +-- Check that opclasses and collations match the underlying columns. +-- (As written, this test ignores expression indexes.) + +SELECT indexrelid::regclass, indrelid::regclass, attname, atttypid::regtype, opcname +FROM (SELECT indexrelid, indrelid, unnest(indkey) as ikey, + unnest(indclass) as iclass, unnest(indcollation) as icoll + FROM pg_index) ss, + pg_attribute a, + pg_opclass opc +WHERE a.attrelid = indrelid AND a.attnum = ikey AND opc.oid = iclass AND + (NOT binary_coercible(atttypid, opcintype) OR icoll != attcollation) +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "opc"="pg_opclass" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="attrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="a" column="attnum" +FILTER: schema="" table="" column="ikey" +FILTER: schema="" table="opc" column="oid" +FILTER: schema="" table="" column="iclass" +FILTER: schema="" table="" column="atttypid" +FILTER: schema="" table="" column="opcintype" +FILTER: schema="" table="" column="icoll" +FILTER: schema="" table="" column="attcollation" +STMT: SelectStmt +== 128 +-- For system catalogs, be even tighter: nearly all indexes should be +-- exact type matches not binary-coercible matches. At this writing +-- the only exception is an OID index on a regproc column. + +SELECT indexrelid::regclass, indrelid::regclass, attname, atttypid::regtype, opcname +FROM (SELECT indexrelid, indrelid, unnest(indkey) as ikey, + unnest(indclass) as iclass, unnest(indcollation) as icoll + FROM pg_index + WHERE indrelid < 16384) ss, + pg_attribute a, + pg_opclass opc +WHERE a.attrelid = indrelid AND a.attnum = ikey AND opc.oid = iclass AND + (opcintype != atttypid OR icoll != attcollation) +ORDER BY 1 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "opc"="pg_opclass" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="a" column="attrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="a" column="attnum" +FILTER: schema="" table="" column="ikey" +FILTER: schema="" table="opc" column="oid" +FILTER: schema="" table="" column="iclass" +FILTER: schema="" table="" column="opcintype" +FILTER: schema="" table="" column="atttypid" +FILTER: schema="" table="" column="icoll" +FILTER: schema="" table="" column="attcollation" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +== 129 +-- Check for system catalogs with collation-sensitive ordering. This is not +-- a representational error in pg_index, but simply wrong catalog design. +-- It's bad because we expect to be able to clone template0 and assign the +-- copy a different database collation. It would especially not work for +-- shared catalogs. + +SELECT relname, attname, attcollation +FROM pg_class c, pg_attribute a +WHERE c.oid = attrelid AND c.oid < 16384 AND + c.relkind != 'v' AND -- we don't care about columns in views + attcollation != 0 AND + attcollation != (SELECT oid FROM pg_collation WHERE collname = 'C') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="c" column="relkind" +FILTER: schema="" table="" column="attcollation" +FILTER: schema="" table="" column="attcollation" +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +== 130 +-- Double-check that collation-sensitive indexes have "C" collation, too. + +SELECT indexrelid::regclass, indrelid::regclass, iclass, icoll +FROM (SELECT indexrelid, indrelid, + unnest(indclass) as iclass, unnest(indcollation) as icoll + FROM pg_index + WHERE indrelid < 16384) ss +WHERE icoll != 0 AND + icoll != (SELECT oid FROM pg_collation WHERE collname = 'C') +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="" column="icoll" +FILTER: schema="" table="" column="icoll" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="collname" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/partition_aggregate.metadata.json b/parser/testdata/summary/postgres_regress/partition_aggregate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/partition_aggregate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/partition_aggregate.test b/parser/testdata/summary/postgres_regress/partition_aggregate.test new file mode 100644 index 0000000..c273a80 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/partition_aggregate.test @@ -0,0 +1,1132 @@ +== 001 +|-- +-- PARTITION_AGGREGATE +-- Test partitionwise aggregation on partitioned tables +|-- +-- Note: to ensure plan stability, it's a good idea to make the partitions of +-- any one partitioned table in this test all have different numbers of rows. +|-- + +-- Enable partitionwise aggregate, which by default is disabled. +SET enable_partitionwise_aggregate TO true +-- +STMT: VariableSetStmt +== 002 +-- Enable partitionwise join, which by default is disabled. +SET enable_partitionwise_join TO true +-- +STMT: VariableSetStmt +== 003 +-- Disable parallel plans. +SET max_parallel_workers_per_gather TO 0 +-- +STMT: VariableSetStmt +== 004 +-- Disable incremental sort, which can influence selected plans due to fuzz factor. +SET enable_incremental_sort TO off +-- +STMT: VariableSetStmt +== 005 +|-- +-- Tests for list partitioned tables. +|-- +CREATE TABLE pagg_tab (a int, b int, c text, d int) PARTITION BY LIST(c) +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=DDL +STMT: CreateStmt +== 006 +CREATE TABLE pagg_tab_p1 PARTITION OF pagg_tab FOR VALUES IN ('0000', '0001', '0002', '0003', '0004') +-- +TABLE: name="pagg_tab_p1" schema="" table="pagg_tab_p1" ctx=DDL +STMT: CreateStmt +== 007 +CREATE TABLE pagg_tab_p2 PARTITION OF pagg_tab FOR VALUES IN ('0005', '0006', '0007', '0008') +-- +TABLE: name="pagg_tab_p2" schema="" table="pagg_tab_p2" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE pagg_tab_p3 PARTITION OF pagg_tab FOR VALUES IN ('0009', '0010', '0011') +-- +TABLE: name="pagg_tab_p3" schema="" table="pagg_tab_p3" ctx=DDL +STMT: CreateStmt +== 009 +INSERT INTO pagg_tab SELECT i % 20, i % 30, to_char(i % 12, 'FM0000'), i % 30 FROM generate_series(0, 2999) i +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 010 +ANALYZE pagg_tab +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=DDL +STMT: VacuumStmt +== 011 +-- When GROUP BY clause matches; full aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT c, sum(a), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY c HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 012 +SELECT c, sum(a), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY c HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- When GROUP BY clause does not match; partial aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY a HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 014 +SELECT a, sum(b), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY a HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 015 +-- Check with multiple columns in GROUP BY +EXPLAIN (COSTS OFF) +SELECT a, c, count(*) FROM pagg_tab GROUP BY a, c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 016 +-- Check with multiple columns in GROUP BY, order in GROUP BY is reversed +EXPLAIN (COSTS OFF) +SELECT a, c, count(*) FROM pagg_tab GROUP BY c, a +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 017 +-- Check with multiple columns in GROUP BY, order in target-list is reversed +EXPLAIN (COSTS OFF) +SELECT c, a, count(*) FROM pagg_tab GROUP BY a, c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 018 +-- Test when input relation for grouping is dummy +EXPLAIN (COSTS OFF) +SELECT c, sum(a) FROM pagg_tab WHERE 1 = 2 GROUP BY c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 019 +SELECT c, sum(a) FROM pagg_tab WHERE 1 = 2 GROUP BY c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 020 +EXPLAIN (COSTS OFF) +SELECT c, sum(a) FROM pagg_tab WHERE c = 'x' GROUP BY c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 021 +SELECT c, sum(a) FROM pagg_tab WHERE c = 'x' GROUP BY c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +== 022 +-- Test GroupAggregate paths by disabling hash aggregates. +SET enable_hashagg TO false +-- +STMT: VariableSetStmt +== 023 +-- When GROUP BY clause matches full aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT c, sum(a), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 024 +SELECT c, sum(a), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 025 +-- When GROUP BY clause does not match; partial aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 026 +SELECT a, sum(b), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 027 +-- Test partitionwise grouping without any aggregates +EXPLAIN (COSTS OFF) +SELECT c FROM pagg_tab GROUP BY c ORDER BY 1 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 028 +SELECT c FROM pagg_tab GROUP BY c ORDER BY 1 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +STMT: SelectStmt +== 029 +EXPLAIN (COSTS OFF) +SELECT a FROM pagg_tab WHERE a < 3 GROUP BY a ORDER BY 1 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 030 +SELECT a FROM pagg_tab WHERE a < 3 GROUP BY a ORDER BY 1 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 031 +RESET enable_hashagg +-- +STMT: VariableSetStmt +== 032 +-- ROLLUP, partitionwise aggregation does not apply +EXPLAIN (COSTS OFF) +SELECT c, sum(a) FROM pagg_tab GROUP BY rollup(c) ORDER BY 1, 2 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 033 +-- ORDERED SET within the aggregate. +-- Full aggregation; since all the rows that belong to the same group come +-- from the same partition, having an ORDER BY within the aggregate doesn't +-- make any difference. +EXPLAIN (COSTS OFF) +SELECT c, sum(b order by a) FROM pagg_tab GROUP BY c ORDER BY 1, 2 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 034 +-- Since GROUP BY clause does not match with PARTITION KEY; we need to do +-- partial aggregation. However, ORDERED SET are not partial safe and thus +-- partitionwise aggregation plan is not generated. +EXPLAIN (COSTS OFF) +SELECT a, sum(b order by a) FROM pagg_tab GROUP BY a ORDER BY 1, 2 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 035 +-- JOIN query + +CREATE TABLE pagg_tab1(x int, y int) PARTITION BY RANGE(x) +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=DDL +STMT: CreateStmt +== 036 +CREATE TABLE pagg_tab1_p1 PARTITION OF pagg_tab1 FOR VALUES FROM (0) TO (10) +-- +TABLE: name="pagg_tab1_p1" schema="" table="pagg_tab1_p1" ctx=DDL +STMT: CreateStmt +== 037 +CREATE TABLE pagg_tab1_p2 PARTITION OF pagg_tab1 FOR VALUES FROM (10) TO (20) +-- +TABLE: name="pagg_tab1_p2" schema="" table="pagg_tab1_p2" ctx=DDL +STMT: CreateStmt +== 038 +CREATE TABLE pagg_tab1_p3 PARTITION OF pagg_tab1 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="pagg_tab1_p3" schema="" table="pagg_tab1_p3" ctx=DDL +STMT: CreateStmt +== 039 +CREATE TABLE pagg_tab2(x int, y int) PARTITION BY RANGE(y) +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=DDL +STMT: CreateStmt +== 040 +CREATE TABLE pagg_tab2_p1 PARTITION OF pagg_tab2 FOR VALUES FROM (0) TO (10) +-- +TABLE: name="pagg_tab2_p1" schema="" table="pagg_tab2_p1" ctx=DDL +STMT: CreateStmt +== 041 +CREATE TABLE pagg_tab2_p2 PARTITION OF pagg_tab2 FOR VALUES FROM (10) TO (20) +-- +TABLE: name="pagg_tab2_p2" schema="" table="pagg_tab2_p2" ctx=DDL +STMT: CreateStmt +== 042 +CREATE TABLE pagg_tab2_p3 PARTITION OF pagg_tab2 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="pagg_tab2_p3" schema="" table="pagg_tab2_p3" ctx=DDL +STMT: CreateStmt +== 043 +INSERT INTO pagg_tab1 SELECT i % 30, i % 20 FROM generate_series(0, 299, 2) i +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO pagg_tab2 SELECT i % 20, i % 30 FROM generate_series(0, 299, 3) i +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 045 +ANALYZE pagg_tab1 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=DDL +STMT: VacuumStmt +== 046 +ANALYZE pagg_tab2 +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=DDL +STMT: VacuumStmt +== 047 +-- When GROUP BY clause matches; full aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT t1.x, sum(t1.y), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 048 +SELECT t1.x, sum(t1.y), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: SelectStmt +== 049 +-- Check with whole-row reference; partitionwise aggregation does not apply +EXPLAIN (COSTS OFF) +SELECT t1.x, sum(t1.y), count(t1) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 050 +SELECT t1.x, sum(t1.y), count(t1) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: SelectStmt +== 051 +-- GROUP BY having other matching key +EXPLAIN (COSTS OFF) +SELECT t2.y, sum(t1.y), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t2.y ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 052 +-- When GROUP BY clause does not match; partial aggregation is performed for each partition. +-- Also test GroupAggregate paths by disabling hash aggregates. +SET enable_hashagg TO false +-- +STMT: VariableSetStmt +== 053 +EXPLAIN (COSTS OFF) +SELECT t1.y, sum(t1.x), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.y HAVING avg(t1.x) > 10 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 054 +SELECT t1.y, sum(t1.x), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.y HAVING avg(t1.x) > 10 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: SelectStmt +== 055 +RESET enable_hashagg +-- +STMT: VariableSetStmt +== 056 +-- Check with LEFT/RIGHT/FULL OUTER JOINs which produces NULL values for +-- aggregation + +-- LEFT JOIN, should produce partial partitionwise aggregation plan as +-- GROUP BY is on nullable column +EXPLAIN (COSTS OFF) +SELECT b.y, sum(a.y) FROM pagg_tab1 a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 057 +SELECT b.y, sum(a.y) FROM pagg_tab1 a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 058 +-- RIGHT JOIN, should produce full partitionwise aggregation plan as +-- GROUP BY is on non-nullable column +EXPLAIN (COSTS OFF) +SELECT b.y, sum(a.y) FROM pagg_tab1 a RIGHT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 059 +SELECT b.y, sum(a.y) FROM pagg_tab1 a RIGHT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 060 +-- FULL JOIN, should produce partial partitionwise aggregation plan as +-- GROUP BY is on nullable column +EXPLAIN (COSTS OFF) +SELECT a.x, sum(b.x) FROM pagg_tab1 a FULL OUTER JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 061 +SELECT a.x, sum(b.x) FROM pagg_tab1 a FULL OUTER JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 062 +-- LEFT JOIN, with dummy relation on right side, ideally +-- should produce full partitionwise aggregation plan as GROUP BY is on +-- non-nullable columns. +-- But right now we are unable to do partitionwise join in this case. +EXPLAIN (COSTS OFF) +SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a LEFT JOIN (SELECT * FROM pagg_tab2 WHERE y > 10) b ON a.x = b.y WHERE a.x > 5 or b.y < 20 GROUP BY a.x, b.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="x" +FILTER: schema="" table="b" column="y" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 063 +SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a LEFT JOIN (SELECT * FROM pagg_tab2 WHERE y > 10) b ON a.x = b.y WHERE a.x > 5 or b.y < 20 GROUP BY a.x, b.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="x" +FILTER: schema="" table="b" column="y" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +== 064 +-- FULL JOIN, with dummy relations on both sides, ideally +-- should produce partial partitionwise aggregation plan as GROUP BY is on +-- nullable columns. +-- But right now we are unable to do partitionwise join in this case. +EXPLAIN (COSTS OFF) +SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a FULL JOIN (SELECT * FROM pagg_tab2 WHERE y > 10) b ON a.x = b.y WHERE a.x > 5 or b.y < 20 GROUP BY a.x, b.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="x" +FILTER: schema="" table="b" column="y" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 065 +SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a FULL JOIN (SELECT * FROM pagg_tab2 WHERE y > 10) b ON a.x = b.y WHERE a.x > 5 or b.y < 20 GROUP BY a.x, b.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="x" +FILTER: schema="" table="b" column="y" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +== 066 +-- Empty join relation because of empty outer side, no partitionwise agg plan +EXPLAIN (COSTS OFF) +SELECT a.x, a.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x = 1 AND x = 2) a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x, a.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +ALIAS: "b"="pagg_tab2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 067 +SELECT a.x, a.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x = 1 AND x = 2) a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x, a.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +ALIAS: "b"="pagg_tab2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 068 +-- Partition by multiple columns + +CREATE TABLE pagg_tab_m (a int, b int, c int) PARTITION BY RANGE(a, ((a+b)/2)) +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=DDL +STMT: CreateStmt +== 069 +CREATE TABLE pagg_tab_m_p1 PARTITION OF pagg_tab_m FOR VALUES FROM (0, 0) TO (12, 12) +-- +TABLE: name="pagg_tab_m_p1" schema="" table="pagg_tab_m_p1" ctx=DDL +STMT: CreateStmt +== 070 +CREATE TABLE pagg_tab_m_p2 PARTITION OF pagg_tab_m FOR VALUES FROM (12, 12) TO (22, 22) +-- +TABLE: name="pagg_tab_m_p2" schema="" table="pagg_tab_m_p2" ctx=DDL +STMT: CreateStmt +== 071 +CREATE TABLE pagg_tab_m_p3 PARTITION OF pagg_tab_m FOR VALUES FROM (22, 22) TO (30, 30) +-- +TABLE: name="pagg_tab_m_p3" schema="" table="pagg_tab_m_p3" ctx=DDL +STMT: CreateStmt +== 072 +INSERT INTO pagg_tab_m SELECT i % 30, i % 40, i % 50 FROM generate_series(0, 2999) i +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 073 +ANALYZE pagg_tab_m +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=DDL +STMT: VacuumStmt +== 074 +-- Partial aggregation as GROUP BY clause does not match with PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a HAVING avg(c) < 22 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 075 +SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a HAVING avg(c) < 22 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 076 +-- Full aggregation as GROUP BY clause matches with PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a, (a+b)/2 HAVING sum(b) < 50 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 077 +SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a, (a+b)/2 HAVING sum(b) < 50 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 078 +-- Full aggregation as PARTITION KEY is part of GROUP BY clause +EXPLAIN (COSTS OFF) +SELECT a, c, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY (a+b)/2, 2, 1 HAVING sum(b) = 50 AND avg(c) > 25 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 079 +SELECT a, c, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY (a+b)/2, 2, 1 HAVING sum(b) = 50 AND avg(c) > 25 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 080 +-- Test with multi-level partitioning scheme + +CREATE TABLE pagg_tab_ml (a int, b int, c text) PARTITION BY RANGE(a) +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=DDL +STMT: CreateStmt +== 081 +CREATE TABLE pagg_tab_ml_p1 PARTITION OF pagg_tab_ml FOR VALUES FROM (0) TO (12) +-- +TABLE: name="pagg_tab_ml_p1" schema="" table="pagg_tab_ml_p1" ctx=DDL +STMT: CreateStmt +== 082 +CREATE TABLE pagg_tab_ml_p2 PARTITION OF pagg_tab_ml FOR VALUES FROM (12) TO (20) PARTITION BY LIST (c) +-- +TABLE: name="pagg_tab_ml_p2" schema="" table="pagg_tab_ml_p2" ctx=DDL +STMT: CreateStmt +== 083 +CREATE TABLE pagg_tab_ml_p2_s1 PARTITION OF pagg_tab_ml_p2 FOR VALUES IN ('0000', '0001', '0002') +-- +TABLE: name="pagg_tab_ml_p2_s1" schema="" table="pagg_tab_ml_p2_s1" ctx=DDL +STMT: CreateStmt +== 084 +CREATE TABLE pagg_tab_ml_p2_s2 PARTITION OF pagg_tab_ml_p2 FOR VALUES IN ('0003') +-- +TABLE: name="pagg_tab_ml_p2_s2" schema="" table="pagg_tab_ml_p2_s2" ctx=DDL +STMT: CreateStmt +== 085 +-- This level of partitioning has different column positions than the parent +CREATE TABLE pagg_tab_ml_p3(b int, c text, a int) PARTITION BY RANGE (b) +-- +TABLE: name="pagg_tab_ml_p3" schema="" table="pagg_tab_ml_p3" ctx=DDL +STMT: CreateStmt +== 086 +CREATE TABLE pagg_tab_ml_p3_s1(c text, a int, b int) +-- +TABLE: name="pagg_tab_ml_p3_s1" schema="" table="pagg_tab_ml_p3_s1" ctx=DDL +STMT: CreateStmt +== 087 +CREATE TABLE pagg_tab_ml_p3_s2 PARTITION OF pagg_tab_ml_p3 FOR VALUES FROM (7) TO (10) +-- +TABLE: name="pagg_tab_ml_p3_s2" schema="" table="pagg_tab_ml_p3_s2" ctx=DDL +STMT: CreateStmt +== 088 +ALTER TABLE pagg_tab_ml_p3 ATTACH PARTITION pagg_tab_ml_p3_s1 FOR VALUES FROM (0) TO (7) +-- +TABLE: name="pagg_tab_ml_p3" schema="" table="pagg_tab_ml_p3" ctx=DDL +STMT: AlterTableStmt +== 089 +ALTER TABLE pagg_tab_ml ATTACH PARTITION pagg_tab_ml_p3 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=DDL +STMT: AlterTableStmt +== 090 +INSERT INTO pagg_tab_ml SELECT i % 30, i % 10, to_char(i % 4, 'FM0000') FROM generate_series(0, 29999) i +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 091 +ANALYZE pagg_tab_ml +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=DDL +STMT: VacuumStmt +== 092 +-- For Parallel Append +SET max_parallel_workers_per_gather TO 2 +-- +STMT: VariableSetStmt +== 093 +SET parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 094 +-- Full aggregation at level 1 as GROUP BY clause matches with PARTITION KEY +-- for level 1 only. For subpartitions, GROUP BY clause does not match with +-- PARTITION KEY, but still we do not see a partial aggregation as array_agg() +-- is not partial agg safe. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), array_agg(distinct c), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 095 +SELECT a, sum(b), array_agg(distinct c), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 096 +-- Without ORDER BY clause, to test Gather at top-most path +EXPLAIN (COSTS OFF) +SELECT a, sum(b), array_agg(distinct c), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 097 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +== 098 +-- Full aggregation at level 1 as GROUP BY clause matches with PARTITION KEY +-- for level 1 only. For subpartitions, GROUP BY clause does not match with +-- PARTITION KEY, thus we will have a partial aggregation for them. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 099 +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 100 +-- Partial aggregation at all levels as GROUP BY clause does not match with +-- PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 101 +SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b HAVING avg(a) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 102 +-- Full aggregation at all levels as GROUP BY clause matches with PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 103 +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 104 +-- Parallelism within partitionwise aggregates + +SET min_parallel_table_scan_size TO '8kB' +-- +STMT: VariableSetStmt +== 105 +SET parallel_setup_cost TO 0 +-- +STMT: VariableSetStmt +== 106 +-- Full aggregation at level 1 as GROUP BY clause matches with PARTITION KEY +-- for level 1 only. For subpartitions, GROUP BY clause does not match with +-- PARTITION KEY, thus we will have a partial aggregation for them. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 107 +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 108 +-- Partial aggregation at all levels as GROUP BY clause does not match with +-- PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 109 +SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b HAVING avg(a) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 110 +-- Full aggregation at all levels as GROUP BY clause matches with PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 111 +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 112 +-- Parallelism within partitionwise aggregates (single level) + +-- Add few parallel setup cost, so that we will see a plan which gathers +-- partially created paths even for full aggregation and sticks a single Gather +-- followed by finalization step. +-- Without this, the cost of doing partial aggregation + Gather + finalization +-- for each partition and then Append over it turns out to be same and this +-- wins as we add it first. This parallel_setup_cost plays a vital role in +-- costing such plans. +SET parallel_setup_cost TO 10 +-- +STMT: VariableSetStmt +== 113 +CREATE TABLE pagg_tab_para(x int, y int) PARTITION BY RANGE(x) +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DDL +STMT: CreateStmt +== 114 +CREATE TABLE pagg_tab_para_p1 PARTITION OF pagg_tab_para FOR VALUES FROM (0) TO (12) +-- +TABLE: name="pagg_tab_para_p1" schema="" table="pagg_tab_para_p1" ctx=DDL +STMT: CreateStmt +== 115 +CREATE TABLE pagg_tab_para_p2 PARTITION OF pagg_tab_para FOR VALUES FROM (12) TO (22) +-- +TABLE: name="pagg_tab_para_p2" schema="" table="pagg_tab_para_p2" ctx=DDL +STMT: CreateStmt +== 116 +CREATE TABLE pagg_tab_para_p3 PARTITION OF pagg_tab_para FOR VALUES FROM (22) TO (30) +-- +TABLE: name="pagg_tab_para_p3" schema="" table="pagg_tab_para_p3" ctx=DDL +STMT: CreateStmt +== 117 +INSERT INTO pagg_tab_para SELECT i % 30, i % 20 FROM generate_series(0, 29999) i +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 118 +ANALYZE pagg_tab_para +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DDL +STMT: VacuumStmt +== 119 +-- When GROUP BY clause matches; full aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 120 +SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 121 +-- When GROUP BY clause does not match; partial aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT y, sum(x), avg(x), count(*) FROM pagg_tab_para GROUP BY y HAVING avg(x) < 12 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 122 +SELECT y, sum(x), avg(x), count(*) FROM pagg_tab_para GROUP BY y HAVING avg(x) < 12 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 123 +-- Test when parent can produce parallel paths but not any (or some) of its children +-- (Use one more aggregate to tilt the cost estimates for the plan we want) +ALTER TABLE pagg_tab_para_p1 SET (parallel_workers = 0) +-- +TABLE: name="pagg_tab_para_p1" schema="" table="pagg_tab_para_p1" ctx=DDL +STMT: AlterTableStmt +== 124 +ALTER TABLE pagg_tab_para_p3 SET (parallel_workers = 0) +-- +TABLE: name="pagg_tab_para_p3" schema="" table="pagg_tab_para_p3" ctx=DDL +STMT: AlterTableStmt +== 125 +ANALYZE pagg_tab_para +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DDL +STMT: VacuumStmt +== 126 +EXPLAIN (COSTS OFF) +SELECT x, sum(y), avg(y), sum(x+y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 127 +SELECT x, sum(y), avg(y), sum(x+y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 128 +ALTER TABLE pagg_tab_para_p2 SET (parallel_workers = 0) +-- +TABLE: name="pagg_tab_para_p2" schema="" table="pagg_tab_para_p2" ctx=DDL +STMT: AlterTableStmt +== 129 +ANALYZE pagg_tab_para +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DDL +STMT: VacuumStmt +== 130 +EXPLAIN (COSTS OFF) +SELECT x, sum(y), avg(y), sum(x+y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 131 +SELECT x, sum(y), avg(y), sum(x+y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 132 +-- Reset parallelism parameters to get partitionwise aggregation plan. +RESET min_parallel_table_scan_size +-- +STMT: VariableSetStmt +== 133 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +== 134 +EXPLAIN (COSTS OFF) +SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 135 +SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/partition_info.metadata.json b/parser/testdata/summary/postgres_regress/partition_info.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/partition_info.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/partition_info.test b/parser/testdata/summary/postgres_regress/partition_info.test new file mode 100644 index 0000000..e3c4cc8 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/partition_info.test @@ -0,0 +1,425 @@ +== 001 +|-- +-- Tests for functions providing information about partitions +|-- +SELECT * FROM pg_partition_tree(NULL) +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 002 +SELECT * FROM pg_partition_tree(0) +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 003 +SELECT * FROM pg_partition_ancestors(NULL) +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT * FROM pg_partition_ancestors(0) +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT pg_partition_root(NULL) +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT pg_partition_root(0) +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- Test table partition trees +CREATE TABLE ptif_test (a int, b int) PARTITION BY range (a) +-- +TABLE: name="ptif_test" schema="" table="ptif_test" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE ptif_test0 PARTITION OF ptif_test + FOR VALUES FROM (minvalue) TO (0) PARTITION BY list (b) +-- +TABLE: name="ptif_test0" schema="" table="ptif_test0" ctx=DDL +STMT: CreateStmt +== 009 +CREATE TABLE ptif_test01 PARTITION OF ptif_test0 FOR VALUES IN (1) +-- +TABLE: name="ptif_test01" schema="" table="ptif_test01" ctx=DDL +STMT: CreateStmt +== 010 +CREATE TABLE ptif_test1 PARTITION OF ptif_test + FOR VALUES FROM (0) TO (100) PARTITION BY list (b) +-- +TABLE: name="ptif_test1" schema="" table="ptif_test1" ctx=DDL +STMT: CreateStmt +== 011 +CREATE TABLE ptif_test11 PARTITION OF ptif_test1 FOR VALUES IN (1) +-- +TABLE: name="ptif_test11" schema="" table="ptif_test11" ctx=DDL +STMT: CreateStmt +== 012 +CREATE TABLE ptif_test2 PARTITION OF ptif_test + FOR VALUES FROM (100) TO (200) +-- +TABLE: name="ptif_test2" schema="" table="ptif_test2" ctx=DDL +STMT: CreateStmt +== 013 +-- This partitioned table should remain with no partitions. +CREATE TABLE ptif_test3 PARTITION OF ptif_test + FOR VALUES FROM (200) TO (maxvalue) PARTITION BY list (b) +-- +TABLE: name="ptif_test3" schema="" table="ptif_test3" ctx=DDL +STMT: CreateStmt +== 014 +-- Test pg_partition_root for tables +SELECT pg_partition_root('ptif_test') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT pg_partition_root('ptif_test0') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT pg_partition_root('ptif_test01') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT pg_partition_root('ptif_test3') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- Test index partition tree +CREATE INDEX ptif_test_index ON ONLY ptif_test (a) +-- +TABLE: name="ptif_test" schema="" table="ptif_test" ctx=DDL +STMT: IndexStmt +== 019 +CREATE INDEX ptif_test0_index ON ONLY ptif_test0 (a) +-- +TABLE: name="ptif_test0" schema="" table="ptif_test0" ctx=DDL +STMT: IndexStmt +== 020 +ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test0_index +-- +STMT: AlterTableStmt +== 021 +CREATE INDEX ptif_test01_index ON ptif_test01 (a) +-- +TABLE: name="ptif_test01" schema="" table="ptif_test01" ctx=DDL +STMT: IndexStmt +== 022 +ALTER INDEX ptif_test0_index ATTACH PARTITION ptif_test01_index +-- +STMT: AlterTableStmt +== 023 +CREATE INDEX ptif_test1_index ON ONLY ptif_test1 (a) +-- +TABLE: name="ptif_test1" schema="" table="ptif_test1" ctx=DDL +STMT: IndexStmt +== 024 +ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test1_index +-- +STMT: AlterTableStmt +== 025 +CREATE INDEX ptif_test11_index ON ptif_test11 (a) +-- +TABLE: name="ptif_test11" schema="" table="ptif_test11" ctx=DDL +STMT: IndexStmt +== 026 +ALTER INDEX ptif_test1_index ATTACH PARTITION ptif_test11_index +-- +STMT: AlterTableStmt +== 027 +CREATE INDEX ptif_test2_index ON ptif_test2 (a) +-- +TABLE: name="ptif_test2" schema="" table="ptif_test2" ctx=DDL +STMT: IndexStmt +== 028 +ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test2_index +-- +STMT: AlterTableStmt +== 029 +CREATE INDEX ptif_test3_index ON ptif_test3 (a) +-- +TABLE: name="ptif_test3" schema="" table="ptif_test3" ctx=DDL +STMT: IndexStmt +== 030 +ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test3_index +-- +STMT: AlterTableStmt +== 031 +-- Test pg_partition_root for indexes +SELECT pg_partition_root('ptif_test_index') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT pg_partition_root('ptif_test0_index') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT pg_partition_root('ptif_test01_index') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT pg_partition_root('ptif_test3_index') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 035 +-- List all tables members of the tree +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- List tables from an intermediate level +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test0') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- List from leaf table +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test01') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 038 +-- List from partitioned table with no partitions +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test3') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 039 +-- List all ancestors of root and leaf tables +SELECT * FROM pg_partition_ancestors('ptif_test01') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT * FROM pg_partition_ancestors('ptif_test') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- List all members using pg_partition_root with leaf table reference +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree(pg_partition_root('ptif_test01')) p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 042 +-- List all indexes members of the tree +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test_index') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 043 +-- List indexes from an intermediate level +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test0_index') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 044 +-- List from leaf index +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test01_index') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- List from partitioned index with no partitions +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test3_index') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 046 +-- List all members using pg_partition_root with leaf index reference +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree(pg_partition_root('ptif_test01_index')) p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- List all ancestors of root and leaf indexes +SELECT * FROM pg_partition_ancestors('ptif_test01_index') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT * FROM pg_partition_ancestors('ptif_test_index') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 049 +DROP TABLE ptif_test +-- +TABLE: name="ptif_test" schema="" table="ptif_test" ctx=DDL +STMT: DropStmt +== 050 +-- Table that is not part of any partition tree is not listed. +CREATE TABLE ptif_normal_table(a int) +-- +TABLE: name="ptif_normal_table" schema="" table="ptif_normal_table" ctx=DDL +STMT: CreateStmt +== 051 +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_normal_table') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 052 +SELECT * FROM pg_partition_ancestors('ptif_normal_table') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 053 +SELECT pg_partition_root('ptif_normal_table') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 054 +DROP TABLE ptif_normal_table +-- +TABLE: name="ptif_normal_table" schema="" table="ptif_normal_table" ctx=DDL +STMT: DropStmt +== 055 +-- Various partitioning-related functions return empty/NULL if passed relations +-- of types that cannot be part of a partition tree; for example, views, +-- materialized views, legacy inheritance children or parents, etc. +CREATE VIEW ptif_test_view AS SELECT 1 +-- +TABLE: name="ptif_test_view" schema="" table="ptif_test_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 056 +CREATE MATERIALIZED VIEW ptif_test_matview AS SELECT 1 +-- +TABLE: name="ptif_test_matview" schema="" table="ptif_test_matview" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 057 +CREATE TABLE ptif_li_parent () +-- +TABLE: name="ptif_li_parent" schema="" table="ptif_li_parent" ctx=DDL +STMT: CreateStmt +== 058 +CREATE TABLE ptif_li_child () INHERITS (ptif_li_parent) +-- +TABLE: name="ptif_li_child" schema="" table="ptif_li_child" ctx=DDL +STMT: CreateStmt +== 059 +SELECT * FROM pg_partition_tree('ptif_test_view') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT * FROM pg_partition_tree('ptif_test_matview') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT * FROM pg_partition_tree('ptif_li_parent') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 062 +SELECT * FROM pg_partition_tree('ptif_li_child') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT * FROM pg_partition_ancestors('ptif_test_view') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT * FROM pg_partition_ancestors('ptif_test_matview') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 065 +SELECT * FROM pg_partition_ancestors('ptif_li_parent') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 066 +SELECT * FROM pg_partition_ancestors('ptif_li_child') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT pg_partition_root('ptif_test_view') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT pg_partition_root('ptif_test_matview') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT pg_partition_root('ptif_li_parent') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT pg_partition_root('ptif_li_child') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +== 071 +DROP VIEW ptif_test_view +-- +STMT: DropStmt +== 072 +DROP MATERIALIZED VIEW ptif_test_matview +-- +STMT: DropStmt +== 073 +DROP TABLE ptif_li_parent, ptif_li_child +-- +TABLE: name="ptif_li_parent" schema="" table="ptif_li_parent" ctx=DDL +TABLE: name="ptif_li_child" schema="" table="ptif_li_child" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/partition_join.metadata.json b/parser/testdata/summary/postgres_regress/partition_join.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/partition_join.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/partition_join.test b/parser/testdata/summary/postgres_regress/partition_join.test new file mode 100644 index 0000000..eb24433 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/partition_join.test @@ -0,0 +1,4915 @@ +== 001 +|-- +-- PARTITION_JOIN +-- Test partitionwise join between partitioned tables +|-- + +-- Enable partitionwise join, which by default is disabled. +SET enable_partitionwise_join to true +-- +STMT: VariableSetStmt +== 002 +|-- +-- partitioned by a single column +|-- +CREATE TABLE prt1 (a int, b int, c varchar) PARTITION BY RANGE(a) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE prt1_p1 PARTITION OF prt1 FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt1_p1" schema="" table="prt1_p1" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE prt1_p3 PARTITION OF prt1 FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt1_p3" schema="" table="prt1_p3" ctx=DDL +STMT: CreateStmt +== 005 +CREATE TABLE prt1_p2 PARTITION OF prt1 FOR VALUES FROM (250) TO (500) +-- +TABLE: name="prt1_p2" schema="" table="prt1_p2" ctx=DDL +STMT: CreateStmt +== 006 +INSERT INTO prt1 SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(0, 599) i WHERE i % 2 = 0 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 007 +CREATE INDEX iprt1_p1_a on prt1_p1(a) +-- +TABLE: name="prt1_p1" schema="" table="prt1_p1" ctx=DDL +STMT: IndexStmt +== 008 +CREATE INDEX iprt1_p2_a on prt1_p2(a) +-- +TABLE: name="prt1_p2" schema="" table="prt1_p2" ctx=DDL +STMT: IndexStmt +== 009 +CREATE INDEX iprt1_p3_a on prt1_p3(a) +-- +TABLE: name="prt1_p3" schema="" table="prt1_p3" ctx=DDL +STMT: IndexStmt +== 010 +ANALYZE prt1 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: VacuumStmt +== 011 +CREATE TABLE prt2 (a int, b int, c varchar) PARTITION BY RANGE(b) +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: CreateStmt +== 012 +CREATE TABLE prt2_p1 PARTITION OF prt2 FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt2_p1" schema="" table="prt2_p1" ctx=DDL +STMT: CreateStmt +== 013 +CREATE TABLE prt2_p2 PARTITION OF prt2 FOR VALUES FROM (250) TO (500) +-- +TABLE: name="prt2_p2" schema="" table="prt2_p2" ctx=DDL +STMT: CreateStmt +== 014 +CREATE TABLE prt2_p3 PARTITION OF prt2 FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt2_p3" schema="" table="prt2_p3" ctx=DDL +STMT: CreateStmt +== 015 +INSERT INTO prt2 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(0, 599) i WHERE i % 3 = 0 +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 016 +CREATE INDEX iprt2_p1_b on prt2_p1(b) +-- +TABLE: name="prt2_p1" schema="" table="prt2_p1" ctx=DDL +STMT: IndexStmt +== 017 +CREATE INDEX iprt2_p2_b on prt2_p2(b) +-- +TABLE: name="prt2_p2" schema="" table="prt2_p2" ctx=DDL +STMT: IndexStmt +== 018 +CREATE INDEX iprt2_p3_b on prt2_p3(b) +-- +TABLE: name="prt2_p3" schema="" table="prt2_p3" ctx=DDL +STMT: IndexStmt +== 019 +ANALYZE prt2 +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: VacuumStmt +== 020 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 021 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 022 +-- left outer join, 3-way +EXPLAIN (COSTS OFF) +SELECT COUNT(*) FROM prt1 t1 + LEFT JOIN prt1 t2 ON t1.a = t2.a + LEFT JOIN prt1 t3 ON t2.a = t3.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 023 +SELECT COUNT(*) FROM prt1 t1 + LEFT JOIN prt1 t2 ON t1.a = t2.a + LEFT JOIN prt1 t3 ON t2.a = t3.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 024 +-- left outer join, with whole-row reference; partitionwise join does not apply +EXPLAIN (COSTS OFF) +SELECT t1, t2 FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 025 +SELECT t1, t2 FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 026 +-- right outer join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 027 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t2" column="a" +STMT: SelectStmt +== 028 +-- full outer join, with placeholder vars +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 50 phv, * FROM prt1 WHERE prt1.b = 0) t1 FULL JOIN (SELECT 75 phv, * FROM prt2 WHERE prt2.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1" column="b" +FILTER: schema="" table="prt2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 029 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 50 phv, * FROM prt1 WHERE prt1.b = 0) t1 FULL JOIN (SELECT 75 phv, * FROM prt2 WHERE prt2.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1" column="b" +FILTER: schema="" table="prt2" column="a" +STMT: SelectStmt +== 030 +-- Join with pruned partitions from joining relations +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.a < 450 AND t2.b > 250 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 031 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.a < 450 AND t2.b > 250 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 032 +-- Currently we can't do partitioned join if nullable-side partitions are pruned +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 033 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 034 +-- Currently we can't do partitioned join if nullable-side partitions are pruned +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 FULL JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 OR t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 035 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 FULL JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 OR t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 036 +-- Semi-join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t2.b FROM prt2 t2 WHERE t2.a = 0) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 037 +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t2.b FROM prt2 t2 WHERE t2.a = 0) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +STMT: SelectStmt +== 038 +-- Anti-join with aggregates +EXPLAIN (COSTS OFF) +SELECT sum(t1.a), avg(t1.a), sum(t1.b), avg(t1.b) FROM prt1 t1 WHERE NOT EXISTS (SELECT 1 FROM prt2 t2 WHERE t1.a = t2.b) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 039 +SELECT sum(t1.a), avg(t1.a), sum(t1.b), avg(t1.b) FROM prt1 t1 WHERE NOT EXISTS (SELECT 1 FROM prt2 t2 WHERE t1.a = t2.b) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 040 +-- lateral reference +EXPLAIN (COSTS OFF) +SELECT * FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t3.a AS t3a, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss + ON t1.a = ss.t2a WHERE t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 041 +SELECT * FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t3.a AS t3a, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss + ON t1.a = ss.t2a WHERE t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 042 +EXPLAIN (COSTS OFF) +SELECT t1.a, ss.t2a, ss.t2c FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t3.a AS t3a, t2.b t2b, t2.c t2c, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss + ON t1.c = ss.t2c WHERE (t1.b + coalesce(ss.t2b, 0)) = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="ss" column="t2b" +STMT: ExplainStmt +STMT: SelectStmt +== 043 +SELECT t1.a, ss.t2a, ss.t2c FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t3.a AS t3a, t2.b t2b, t2.c t2c, least(t1.a,t2.a,t3.a) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss + ON t1.c = ss.t2c WHERE (t1.b + coalesce(ss.t2b, 0)) = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="ss" column="t2b" +STMT: SelectStmt +== 044 +-- lateral reference in sample scan +EXPLAIN (COSTS OFF) +SELECT * FROM prt1 t1 JOIN LATERAL + (SELECT * FROM prt1 t2 TABLESAMPLE SYSTEM (t1.a) REPEATABLE(t1.b)) s + ON t1.a = s.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +STMT: ExplainStmt +STMT: SelectStmt +== 045 +-- lateral reference in scan's restriction clauses +EXPLAIN (COSTS OFF) +SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2 t2) s + ON t1.a = s.b WHERE s.t1b = s.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 046 +SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2 t2) s + ON t1.a = s.b WHERE s.t1b = s.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="a" +STMT: SelectStmt +== 047 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2 t2) s + ON t1.a = s.b WHERE s.t1b = s.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 048 +SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2 t2) s + ON t1.a = s.b WHERE s.t1b = s.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="b" +STMT: SelectStmt +== 049 +-- bug with inadequate sort key representation +SET enable_partitionwise_aggregate TO true +-- +STMT: VariableSetStmt +== 050 +SET enable_hashjoin TO false +-- +STMT: VariableSetStmt +== 051 +EXPLAIN (COSTS OFF) +SELECT a, b FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) + WHERE a BETWEEN 490 AND 510 + GROUP BY 1, 2 ORDER BY 1, 2 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "p2"="prt2" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 052 +SELECT a, b FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) + WHERE a BETWEEN 490 AND 510 + GROUP BY 1, 2 ORDER BY 1, 2 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "p2"="prt2" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 053 +RESET enable_partitionwise_aggregate +-- +STMT: VariableSetStmt +== 054 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +== 055 +-- bug in freeing the SpecialJoinInfo of a child-join +EXPLAIN (COSTS OFF) +SELECT * FROM prt1 t1 JOIN prt1 t2 ON t1.a = t2.a WHERE t1.a IN (SELECT a FROM prt1 t3) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt1" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 056 +|-- +-- partitioned by expression +|-- +CREATE TABLE prt1_e (a int, b int, c int) PARTITION BY RANGE(((a + b)/2)) +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=DDL +STMT: CreateStmt +== 057 +CREATE TABLE prt1_e_p1 PARTITION OF prt1_e FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt1_e_p1" schema="" table="prt1_e_p1" ctx=DDL +STMT: CreateStmt +== 058 +CREATE TABLE prt1_e_p2 PARTITION OF prt1_e FOR VALUES FROM (250) TO (500) +-- +TABLE: name="prt1_e_p2" schema="" table="prt1_e_p2" ctx=DDL +STMT: CreateStmt +== 059 +CREATE TABLE prt1_e_p3 PARTITION OF prt1_e FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt1_e_p3" schema="" table="prt1_e_p3" ctx=DDL +STMT: CreateStmt +== 060 +INSERT INTO prt1_e SELECT i, i, i % 25 FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 061 +CREATE INDEX iprt1_e_p1_ab2 on prt1_e_p1(((a+b)/2)) +-- +TABLE: name="prt1_e_p1" schema="" table="prt1_e_p1" ctx=DDL +STMT: IndexStmt +== 062 +CREATE INDEX iprt1_e_p2_ab2 on prt1_e_p2(((a+b)/2)) +-- +TABLE: name="prt1_e_p2" schema="" table="prt1_e_p2" ctx=DDL +STMT: IndexStmt +== 063 +CREATE INDEX iprt1_e_p3_ab2 on prt1_e_p3(((a+b)/2)) +-- +TABLE: name="prt1_e_p3" schema="" table="prt1_e_p3" ctx=DDL +STMT: IndexStmt +== 064 +ANALYZE prt1_e +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=DDL +STMT: VacuumStmt +== 065 +CREATE TABLE prt2_e (a int, b int, c int) PARTITION BY RANGE(((b + a)/2)) +-- +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=DDL +STMT: CreateStmt +== 066 +CREATE TABLE prt2_e_p1 PARTITION OF prt2_e FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt2_e_p1" schema="" table="prt2_e_p1" ctx=DDL +STMT: CreateStmt +== 067 +CREATE TABLE prt2_e_p2 PARTITION OF prt2_e FOR VALUES FROM (250) TO (500) +-- +TABLE: name="prt2_e_p2" schema="" table="prt2_e_p2" ctx=DDL +STMT: CreateStmt +== 068 +CREATE TABLE prt2_e_p3 PARTITION OF prt2_e FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt2_e_p3" schema="" table="prt2_e_p3" ctx=DDL +STMT: CreateStmt +== 069 +INSERT INTO prt2_e SELECT i, i, i % 25 FROM generate_series(0, 599, 3) i +-- +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 070 +ANALYZE prt2_e +-- +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=DDL +STMT: VacuumStmt +== 071 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_e t1, prt2_e t2 WHERE (t1.a + t1.b)/2 = (t2.b + t2.a)/2 AND t1.c = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=Select +ALIAS: "t1"="prt1_e" +ALIAS: "t2"="prt2_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 072 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_e t1, prt2_e t2 WHERE (t1.a + t1.b)/2 = (t2.b + t2.a)/2 AND t1.c = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=Select +ALIAS: "t1"="prt1_e" +ALIAS: "t2"="prt2_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +== 073 +|-- +-- N-way join +|-- +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_e t3 WHERE t1.a = t2.b AND t1.a = (t3.a + t3.b)/2 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t3" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 074 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_e t3 WHERE t1.a = t2.b AND t1.a = (t3.a + t3.b)/2 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t3" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 075 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) LEFT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t1.b = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 076 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) LEFT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t1.b = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 077 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t3" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 078 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t3" column="c" +STMT: SelectStmt +== 079 +|-- +-- 3-way full join +|-- +EXPLAIN (COSTS OFF) +SELECT COUNT(*) FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) FULL JOIN prt2 p3(b,a,c) USING (a, b) + WHERE a BETWEEN 490 AND 510 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "p2"="prt2" +ALIAS: "p3"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 080 +SELECT COUNT(*) FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) FULL JOIN prt2 p3(b,a,c) USING (a, b) + WHERE a BETWEEN 490 AND 510 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "p2"="prt2" +ALIAS: "p3"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 081 +|-- +-- 4-way full join +|-- +EXPLAIN (COSTS OFF) +SELECT COUNT(*) FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) FULL JOIN prt2 p3(b,a,c) USING (a, b) FULL JOIN prt1 p4 (a,b,c) USING (a, b) + WHERE a BETWEEN 490 AND 510 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "p2"="prt2" +ALIAS: "p3"="prt2" +ALIAS: "p4"="prt1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 082 +SELECT COUNT(*) FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) FULL JOIN prt2 p3(b,a,c) USING (a, b) FULL JOIN prt1 p4 (a,b,c) USING (a, b) + WHERE a BETWEEN 490 AND 510 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "p2"="prt2" +ALIAS: "p3"="prt2" +ALIAS: "p4"="prt1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 083 +-- Cases with non-nullable expressions in subquery results; +-- make sure these go to null as expected +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.phv, t2.b, t2.phv, t3.a + t3.b, t3.phv FROM ((SELECT 50 phv, * FROM prt1 WHERE prt1.b = 0) t1 FULL JOIN (SELECT 75 phv, * FROM prt2 WHERE prt2.a = 0) t2 ON (t1.a = t2.b)) FULL JOIN (SELECT 50 phv, * FROM prt1_e WHERE prt1_e.c = 0) t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t1.a = t1.phv OR t2.b = t2.phv OR (t3.a + t3.b)/2 = t3.phv ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t3" column="b" +FILTER: schema="" table="t3" column="phv" +FILTER: schema="" table="prt1" column="b" +FILTER: schema="" table="prt2" column="a" +FILTER: schema="" table="prt1_e" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 084 +SELECT t1.a, t1.phv, t2.b, t2.phv, t3.a + t3.b, t3.phv FROM ((SELECT 50 phv, * FROM prt1 WHERE prt1.b = 0) t1 FULL JOIN (SELECT 75 phv, * FROM prt2 WHERE prt2.a = 0) t2 ON (t1.a = t2.b)) FULL JOIN (SELECT 50 phv, * FROM prt1_e WHERE prt1_e.c = 0) t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t1.a = t1.phv OR t2.b = t2.phv OR (t3.a + t3.b)/2 = t3.phv ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t3" column="b" +FILTER: schema="" table="t3" column="phv" +FILTER: schema="" table="prt1" column="b" +FILTER: schema="" table="prt2" column="a" +FILTER: schema="" table="prt1_e" column="c" +STMT: SelectStmt +== 085 +-- Semi-join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 WHERE t1.a = 0 AND t1.b = (t2.a + t2.b)/2) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt2" +ALIAS: "t2"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 086 +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 WHERE t1.a = 0 AND t1.b = (t2.a + t2.b)/2) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt2" +ALIAS: "t2"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 087 +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 088 +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +== 089 +-- test merge joins +SET enable_hashjoin TO off +-- +STMT: VariableSetStmt +== 090 +SET enable_nestloop TO off +-- +STMT: VariableSetStmt +== 091 +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 092 +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +== 093 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t3" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 094 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t3" column="c" +STMT: SelectStmt +== 095 +-- MergeAppend on nullable column +-- This should generate a partitionwise join, but currently fails to +EXPLAIN (COSTS OFF) +SELECT t1.a, t2.b FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 096 +SELECT t1.a, t2.b FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 097 +-- merge join when expression with whole-row reference needs to be sorted; +-- partitionwise join does not apply +EXPLAIN (COSTS OFF) +SELECT t1.a, t2.b FROM prt1 t1, prt2 t2 WHERE t1::text = t2::text AND t1.a = t2.b ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="" column="t1" +FILTER: schema="" table="" column="t2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 098 +SELECT t1.a, t2.b FROM prt1 t1, prt2 t2 WHERE t1::text = t2::text AND t1.a = t2.b ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="" column="t1" +FILTER: schema="" table="" column="t2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 099 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +== 100 +RESET enable_nestloop +-- +STMT: VariableSetStmt +== 101 +|-- +-- partitioned by multiple columns +|-- +CREATE TABLE prt1_m (a int, b int, c int) PARTITION BY RANGE(a, ((a + b)/2)) +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=DDL +STMT: CreateStmt +== 102 +CREATE TABLE prt1_m_p1 PARTITION OF prt1_m FOR VALUES FROM (0, 0) TO (250, 250) +-- +TABLE: name="prt1_m_p1" schema="" table="prt1_m_p1" ctx=DDL +STMT: CreateStmt +== 103 +CREATE TABLE prt1_m_p2 PARTITION OF prt1_m FOR VALUES FROM (250, 250) TO (500, 500) +-- +TABLE: name="prt1_m_p2" schema="" table="prt1_m_p2" ctx=DDL +STMT: CreateStmt +== 104 +CREATE TABLE prt1_m_p3 PARTITION OF prt1_m FOR VALUES FROM (500, 500) TO (600, 600) +-- +TABLE: name="prt1_m_p3" schema="" table="prt1_m_p3" ctx=DDL +STMT: CreateStmt +== 105 +INSERT INTO prt1_m SELECT i, i, i % 25 FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 106 +ANALYZE prt1_m +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=DDL +STMT: VacuumStmt +== 107 +CREATE TABLE prt2_m (a int, b int, c int) PARTITION BY RANGE(((b + a)/2), b) +-- +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=DDL +STMT: CreateStmt +== 108 +CREATE TABLE prt2_m_p1 PARTITION OF prt2_m FOR VALUES FROM (0, 0) TO (250, 250) +-- +TABLE: name="prt2_m_p1" schema="" table="prt2_m_p1" ctx=DDL +STMT: CreateStmt +== 109 +CREATE TABLE prt2_m_p2 PARTITION OF prt2_m FOR VALUES FROM (250, 250) TO (500, 500) +-- +TABLE: name="prt2_m_p2" schema="" table="prt2_m_p2" ctx=DDL +STMT: CreateStmt +== 110 +CREATE TABLE prt2_m_p3 PARTITION OF prt2_m FOR VALUES FROM (500, 500) TO (600, 600) +-- +TABLE: name="prt2_m_p3" schema="" table="prt2_m_p3" ctx=DDL +STMT: CreateStmt +== 111 +INSERT INTO prt2_m SELECT i, i, i % 25 FROM generate_series(0, 599, 3) i +-- +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 112 +ANALYZE prt2_m +-- +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=DDL +STMT: VacuumStmt +== 113 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_m WHERE prt1_m.c = 0) t1 FULL JOIN (SELECT * FROM prt2_m WHERE prt2_m.c = 0) t2 ON (t1.a = (t2.b + t2.a)/2 AND t2.b = (t1.a + t1.b)/2) ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +FILTER: schema="" table="prt1_m" column="c" +FILTER: schema="" table="prt2_m" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 114 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_m WHERE prt1_m.c = 0) t1 FULL JOIN (SELECT * FROM prt2_m WHERE prt2_m.c = 0) t2 ON (t1.a = (t2.b + t2.a)/2 AND t2.b = (t1.a + t1.b)/2) ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +FILTER: schema="" table="prt1_m" column="c" +FILTER: schema="" table="prt2_m" column="c" +STMT: SelectStmt +== 115 +|-- +-- tests for list partitioned tables. +|-- +CREATE TABLE plt1 (a int, b int, c text) PARTITION BY LIST(c) +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: CreateStmt +== 116 +CREATE TABLE plt1_p1 PARTITION OF plt1 FOR VALUES IN ('0000', '0003', '0004', '0010') +-- +TABLE: name="plt1_p1" schema="" table="plt1_p1" ctx=DDL +STMT: CreateStmt +== 117 +CREATE TABLE plt1_p2 PARTITION OF plt1 FOR VALUES IN ('0001', '0005', '0002', '0009') +-- +TABLE: name="plt1_p2" schema="" table="plt1_p2" ctx=DDL +STMT: CreateStmt +== 118 +CREATE TABLE plt1_p3 PARTITION OF plt1 FOR VALUES IN ('0006', '0007', '0008', '0011') +-- +TABLE: name="plt1_p3" schema="" table="plt1_p3" ctx=DDL +STMT: CreateStmt +== 119 +INSERT INTO plt1 SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 120 +ANALYZE plt1 +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: VacuumStmt +== 121 +CREATE TABLE plt2 (a int, b int, c text) PARTITION BY LIST(c) +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: CreateStmt +== 122 +CREATE TABLE plt2_p1 PARTITION OF plt2 FOR VALUES IN ('0000', '0003', '0004', '0010') +-- +TABLE: name="plt2_p1" schema="" table="plt2_p1" ctx=DDL +STMT: CreateStmt +== 123 +CREATE TABLE plt2_p2 PARTITION OF plt2 FOR VALUES IN ('0001', '0005', '0002', '0009') +-- +TABLE: name="plt2_p2" schema="" table="plt2_p2" ctx=DDL +STMT: CreateStmt +== 124 +CREATE TABLE plt2_p3 PARTITION OF plt2 FOR VALUES IN ('0006', '0007', '0008', '0011') +-- +TABLE: name="plt2_p3" schema="" table="plt2_p3" ctx=DDL +STMT: CreateStmt +== 125 +INSERT INTO plt2 SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 3) i +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 126 +ANALYZE plt2 +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: VacuumStmt +== 127 +|-- +-- list partitioned by expression +|-- +CREATE TABLE plt1_e (a int, b int, c text) PARTITION BY LIST(ltrim(c, 'A')) +-- +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=DDL +STMT: CreateStmt +== 128 +CREATE TABLE plt1_e_p1 PARTITION OF plt1_e FOR VALUES IN ('0000', '0003', '0004', '0010') +-- +TABLE: name="plt1_e_p1" schema="" table="plt1_e_p1" ctx=DDL +STMT: CreateStmt +== 129 +CREATE TABLE plt1_e_p2 PARTITION OF plt1_e FOR VALUES IN ('0001', '0005', '0002', '0009') +-- +TABLE: name="plt1_e_p2" schema="" table="plt1_e_p2" ctx=DDL +STMT: CreateStmt +== 130 +CREATE TABLE plt1_e_p3 PARTITION OF plt1_e FOR VALUES IN ('0006', '0007', '0008', '0011') +-- +TABLE: name="plt1_e_p3" schema="" table="plt1_e_p3" ctx=DDL +STMT: CreateStmt +== 131 +INSERT INTO plt1_e SELECT i, i, 'A' || to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 132 +ANALYZE plt1_e +-- +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=DDL +STMT: VacuumStmt +== 133 +-- test partition matching with N-way join +EXPLAIN (COSTS OFF) +SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1, plt2 t2, plt1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c +-- +TABLE: name="plt1" schema="" table="plt1" ctx=Select +TABLE: name="plt2" schema="" table="plt2" ctx=Select +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=Select +ALIAS: "t1"="plt1" +ALIAS: "t2"="plt2" +ALIAS: "t3"="plt1_e" +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t3" column="c" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 134 +SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1, plt2 t2, plt1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c +-- +TABLE: name="plt1" schema="" table="plt1" ctx=Select +TABLE: name="plt2" schema="" table="plt2" ctx=Select +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=Select +ALIAS: "t1"="plt1" +ALIAS: "t2"="plt2" +ALIAS: "t3"="plt1_e" +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t3" column="c" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +== 135 +-- joins where one of the relations is proven empty +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.a = 1 AND t1.a = 2 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 136 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2) t1 LEFT JOIN prt2 t2 ON t1.a = t2.b +-- +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t2"="prt2" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 137 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2) t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b, prt1 t3 WHERE t2.b = t3.a +-- +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 138 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2) t1 FULL JOIN prt2 t2 ON t1.a = t2.b WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t2"="prt2" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 139 +|-- +-- tests for hash partitioned tables. +|-- +CREATE TABLE pht1 (a int, b int, c text) PARTITION BY HASH(c) +-- +TABLE: name="pht1" schema="" table="pht1" ctx=DDL +STMT: CreateStmt +== 140 +CREATE TABLE pht1_p1 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 0) +-- +TABLE: name="pht1_p1" schema="" table="pht1_p1" ctx=DDL +STMT: CreateStmt +== 141 +CREATE TABLE pht1_p2 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 1) +-- +TABLE: name="pht1_p2" schema="" table="pht1_p2" ctx=DDL +STMT: CreateStmt +== 142 +CREATE TABLE pht1_p3 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 2) +-- +TABLE: name="pht1_p3" schema="" table="pht1_p3" ctx=DDL +STMT: CreateStmt +== 143 +INSERT INTO pht1 SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="pht1" schema="" table="pht1" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 144 +ANALYZE pht1 +-- +TABLE: name="pht1" schema="" table="pht1" ctx=DDL +STMT: VacuumStmt +== 145 +CREATE TABLE pht2 (a int, b int, c text) PARTITION BY HASH(c) +-- +TABLE: name="pht2" schema="" table="pht2" ctx=DDL +STMT: CreateStmt +== 146 +CREATE TABLE pht2_p1 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 0) +-- +TABLE: name="pht2_p1" schema="" table="pht2_p1" ctx=DDL +STMT: CreateStmt +== 147 +CREATE TABLE pht2_p2 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 1) +-- +TABLE: name="pht2_p2" schema="" table="pht2_p2" ctx=DDL +STMT: CreateStmt +== 148 +CREATE TABLE pht2_p3 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 2) +-- +TABLE: name="pht2_p3" schema="" table="pht2_p3" ctx=DDL +STMT: CreateStmt +== 149 +INSERT INTO pht2 SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 3) i +-- +TABLE: name="pht2" schema="" table="pht2" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 150 +ANALYZE pht2 +-- +TABLE: name="pht2" schema="" table="pht2" ctx=DDL +STMT: VacuumStmt +== 151 +|-- +-- hash partitioned by expression +|-- +CREATE TABLE pht1_e (a int, b int, c text) PARTITION BY HASH(ltrim(c, 'A')) +-- +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=DDL +STMT: CreateStmt +== 152 +CREATE TABLE pht1_e_p1 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 0) +-- +TABLE: name="pht1_e_p1" schema="" table="pht1_e_p1" ctx=DDL +STMT: CreateStmt +== 153 +CREATE TABLE pht1_e_p2 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 1) +-- +TABLE: name="pht1_e_p2" schema="" table="pht1_e_p2" ctx=DDL +STMT: CreateStmt +== 154 +CREATE TABLE pht1_e_p3 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 2) +-- +TABLE: name="pht1_e_p3" schema="" table="pht1_e_p3" ctx=DDL +STMT: CreateStmt +== 155 +INSERT INTO pht1_e SELECT i, i, 'A' || to_char(i/50, 'FM0000') FROM generate_series(0, 299, 2) i +-- +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 156 +ANALYZE pht1_e +-- +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=DDL +STMT: VacuumStmt +== 157 +-- test partition matching with N-way join +EXPLAIN (COSTS OFF) +SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1, pht2 t2, pht1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c +-- +TABLE: name="pht1" schema="" table="pht1" ctx=Select +TABLE: name="pht2" schema="" table="pht2" ctx=Select +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=Select +ALIAS: "t1"="pht1" +ALIAS: "t2"="pht2" +ALIAS: "t3"="pht1_e" +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t3" column="c" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 158 +SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1, pht2 t2, pht1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c +-- +TABLE: name="pht1" schema="" table="pht1" ctx=Select +TABLE: name="pht2" schema="" table="pht2" ctx=Select +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=Select +ALIAS: "t1"="pht1" +ALIAS: "t2"="pht2" +ALIAS: "t3"="pht1_e" +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t3" column="c" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +== 159 +-- test default partition behavior for range +ALTER TABLE prt1 DETACH PARTITION prt1_p3 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: AlterTableStmt +== 160 +ALTER TABLE prt1 ATTACH PARTITION prt1_p3 DEFAULT +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: AlterTableStmt +== 161 +ANALYZE prt1 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: VacuumStmt +== 162 +ALTER TABLE prt2 DETACH PARTITION prt2_p3 +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: AlterTableStmt +== 163 +ALTER TABLE prt2 ATTACH PARTITION prt2_p3 DEFAULT +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: AlterTableStmt +== 164 +ANALYZE prt2 +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: VacuumStmt +== 165 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 166 +-- test default partition behavior for list +ALTER TABLE plt1 DETACH PARTITION plt1_p3 +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: AlterTableStmt +== 167 +ALTER TABLE plt1 ATTACH PARTITION plt1_p3 DEFAULT +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: AlterTableStmt +== 168 +ANALYZE plt1 +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: VacuumStmt +== 169 +ALTER TABLE plt2 DETACH PARTITION plt2_p3 +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: AlterTableStmt +== 170 +ALTER TABLE plt2 ATTACH PARTITION plt2_p3 DEFAULT +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: AlterTableStmt +== 171 +ANALYZE plt2 +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: VacuumStmt +== 172 +EXPLAIN (COSTS OFF) +SELECT avg(t1.a), avg(t2.b), t1.c, t2.c FROM plt1 t1 RIGHT JOIN plt2 t2 ON t1.c = t2.c WHERE t1.a % 25 = 0 GROUP BY t1.c, t2.c ORDER BY t1.c, t2.c +-- +TABLE: name="plt1" schema="" table="plt1" ctx=Select +TABLE: name="plt2" schema="" table="plt2" ctx=Select +ALIAS: "t1"="plt1" +ALIAS: "t2"="plt2" +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 173 +|-- +-- multiple levels of partitioning +|-- +CREATE TABLE prt1_l (a int, b int, c varchar) PARTITION BY RANGE(a) +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=DDL +STMT: CreateStmt +== 174 +CREATE TABLE prt1_l_p1 PARTITION OF prt1_l FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt1_l_p1" schema="" table="prt1_l_p1" ctx=DDL +STMT: CreateStmt +== 175 +CREATE TABLE prt1_l_p2 PARTITION OF prt1_l FOR VALUES FROM (250) TO (500) PARTITION BY LIST (c) +-- +TABLE: name="prt1_l_p2" schema="" table="prt1_l_p2" ctx=DDL +STMT: CreateStmt +== 176 +CREATE TABLE prt1_l_p2_p1 PARTITION OF prt1_l_p2 FOR VALUES IN ('0000', '0001') +-- +TABLE: name="prt1_l_p2_p1" schema="" table="prt1_l_p2_p1" ctx=DDL +STMT: CreateStmt +== 177 +CREATE TABLE prt1_l_p2_p2 PARTITION OF prt1_l_p2 FOR VALUES IN ('0002', '0003') +-- +TABLE: name="prt1_l_p2_p2" schema="" table="prt1_l_p2_p2" ctx=DDL +STMT: CreateStmt +== 178 +CREATE TABLE prt1_l_p3 PARTITION OF prt1_l FOR VALUES FROM (500) TO (600) PARTITION BY RANGE (b) +-- +TABLE: name="prt1_l_p3" schema="" table="prt1_l_p3" ctx=DDL +STMT: CreateStmt +== 179 +CREATE TABLE prt1_l_p3_p1 PARTITION OF prt1_l_p3 FOR VALUES FROM (0) TO (13) +-- +TABLE: name="prt1_l_p3_p1" schema="" table="prt1_l_p3_p1" ctx=DDL +STMT: CreateStmt +== 180 +CREATE TABLE prt1_l_p3_p2 PARTITION OF prt1_l_p3 FOR VALUES FROM (13) TO (25) +-- +TABLE: name="prt1_l_p3_p2" schema="" table="prt1_l_p3_p2" ctx=DDL +STMT: CreateStmt +== 181 +INSERT INTO prt1_l SELECT i, i % 25, to_char(i % 4, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 182 +ANALYZE prt1_l +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=DDL +STMT: VacuumStmt +== 183 +CREATE TABLE prt2_l (a int, b int, c varchar) PARTITION BY RANGE(b) +-- +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=DDL +STMT: CreateStmt +== 184 +CREATE TABLE prt2_l_p1 PARTITION OF prt2_l FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt2_l_p1" schema="" table="prt2_l_p1" ctx=DDL +STMT: CreateStmt +== 185 +CREATE TABLE prt2_l_p2 PARTITION OF prt2_l FOR VALUES FROM (250) TO (500) PARTITION BY LIST (c) +-- +TABLE: name="prt2_l_p2" schema="" table="prt2_l_p2" ctx=DDL +STMT: CreateStmt +== 186 +CREATE TABLE prt2_l_p2_p1 PARTITION OF prt2_l_p2 FOR VALUES IN ('0000', '0001') +-- +TABLE: name="prt2_l_p2_p1" schema="" table="prt2_l_p2_p1" ctx=DDL +STMT: CreateStmt +== 187 +CREATE TABLE prt2_l_p2_p2 PARTITION OF prt2_l_p2 FOR VALUES IN ('0002', '0003') +-- +TABLE: name="prt2_l_p2_p2" schema="" table="prt2_l_p2_p2" ctx=DDL +STMT: CreateStmt +== 188 +CREATE TABLE prt2_l_p3 PARTITION OF prt2_l FOR VALUES FROM (500) TO (600) PARTITION BY RANGE (a) +-- +TABLE: name="prt2_l_p3" schema="" table="prt2_l_p3" ctx=DDL +STMT: CreateStmt +== 189 +CREATE TABLE prt2_l_p3_p1 PARTITION OF prt2_l_p3 FOR VALUES FROM (0) TO (13) +-- +TABLE: name="prt2_l_p3_p1" schema="" table="prt2_l_p3_p1" ctx=DDL +STMT: CreateStmt +== 190 +CREATE TABLE prt2_l_p3_p2 PARTITION OF prt2_l_p3 FOR VALUES FROM (13) TO (25) +-- +TABLE: name="prt2_l_p3_p2" schema="" table="prt2_l_p3_p2" ctx=DDL +STMT: CreateStmt +== 191 +INSERT INTO prt2_l SELECT i % 25, i, to_char(i % 4, 'FM0000') FROM generate_series(0, 599, 3) i +-- +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 192 +ANALYZE prt2_l +-- +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=DDL +STMT: VacuumStmt +== 193 +-- inner join, qual covering only top-level partitions +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1, prt2_l t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 194 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1, prt2_l t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 195 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 LEFT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 196 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 LEFT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 197 +-- right join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 RIGHT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 198 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 RIGHT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t2" column="a" +STMT: SelectStmt +== 199 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1 FULL JOIN (SELECT * FROM prt2_l WHERE prt2_l.a = 0) t2 ON (t1.a = t2.b AND t1.c = t2.c) ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +FILTER: schema="" table="prt1_l" column="b" +FILTER: schema="" table="prt2_l" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 200 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1 FULL JOIN (SELECT * FROM prt2_l WHERE prt2_l.a = 0) t2 ON (t1.a = t2.b AND t1.c = t2.c) ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +FILTER: schema="" table="prt1_l" column="b" +FILTER: schema="" table="prt2_l" column="a" +STMT: SelectStmt +== 201 +-- lateral partitionwise join +EXPLAIN (COSTS OFF) +SELECT * FROM prt1_l t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t2.c AS t2c, t2.b AS t2b, t3.b AS t3b, least(t1.a,t2.a,t3.b) FROM prt1_l t2 JOIN prt2_l t3 ON (t2.a = t3.b AND t2.c = t3.c)) ss + ON t1.a = ss.t2a AND t1.c = ss.t2c WHERE t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt1_l" +ALIAS: "t3"="prt2_l" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 202 +SELECT * FROM prt1_l t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t2.c AS t2c, t2.b AS t2b, t3.b AS t3b, least(t1.a,t2.a,t3.b) FROM prt1_l t2 JOIN prt2_l t3 ON (t2.a = t3.b AND t2.c = t3.c)) ss + ON t1.a = ss.t2a AND t1.c = ss.t2c WHERE t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt1_l" +ALIAS: "t3"="prt2_l" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 203 +-- partitionwise join with lateral reference in sample scan +EXPLAIN (COSTS OFF) +SELECT * FROM prt1_l t1 JOIN LATERAL + (SELECT * FROM prt1_l t2 TABLESAMPLE SYSTEM (t1.a) REPEATABLE(t1.b)) s + ON t1.a = s.a AND t1.b = s.b AND t1.c = s.c +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt1_l" +STMT: ExplainStmt +STMT: SelectStmt +== 204 +-- partitionwise join with lateral reference in scan's restriction clauses +EXPLAIN (COSTS OFF) +SELECT COUNT(*) FROM prt1_l t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2_l t2) s + ON t1.a = s.b AND t1.b = s.a AND t1.c = s.c + WHERE s.t1b = s.a +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 205 +SELECT COUNT(*) FROM prt1_l t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2_l t2) s + ON t1.a = s.b AND t1.b = s.a AND t1.c = s.c + WHERE s.t1b = s.a +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="a" +STMT: SelectStmt +== 206 +-- join with one side empty +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE a = 1 AND a = 2) t1 RIGHT JOIN prt2_l t2 ON t1.a = t2.b AND t1.b = t2.a AND t1.c = t2.c +-- +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 207 +-- Test case to verify proper handling of subqueries in a partitioned delete. +-- The weird-looking lateral join is just there to force creation of a +-- nestloop parameter within the subquery, which exposes the problem if the +-- planner fails to make multiple copies of the subquery as appropriate. +EXPLAIN (COSTS OFF) +DELETE FROM prt1_l +WHERE EXISTS ( + SELECT 1 + FROM int4_tbl, + LATERAL (SELECT int4_tbl.f1 FROM int8_tbl LIMIT 2) ss + WHERE prt1_l.c IS NULL) +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="prt1_l" column="c" +STMT: ExplainStmt +STMT: DeleteStmt +STMT: SelectStmt +== 208 +|-- +-- negative testcases +|-- +CREATE TABLE prt1_n (a int, b int, c varchar) PARTITION BY RANGE(c) +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=DDL +STMT: CreateStmt +== 209 +CREATE TABLE prt1_n_p1 PARTITION OF prt1_n FOR VALUES FROM ('0000') TO ('0250') +-- +TABLE: name="prt1_n_p1" schema="" table="prt1_n_p1" ctx=DDL +STMT: CreateStmt +== 210 +CREATE TABLE prt1_n_p2 PARTITION OF prt1_n FOR VALUES FROM ('0250') TO ('0500') +-- +TABLE: name="prt1_n_p2" schema="" table="prt1_n_p2" ctx=DDL +STMT: CreateStmt +== 211 +INSERT INTO prt1_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 499, 2) i +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 212 +ANALYZE prt1_n +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=DDL +STMT: VacuumStmt +== 213 +CREATE TABLE prt2_n (a int, b int, c text) PARTITION BY LIST(c) +-- +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=DDL +STMT: CreateStmt +== 214 +CREATE TABLE prt2_n_p1 PARTITION OF prt2_n FOR VALUES IN ('0000', '0003', '0004', '0010', '0006', '0007') +-- +TABLE: name="prt2_n_p1" schema="" table="prt2_n_p1" ctx=DDL +STMT: CreateStmt +== 215 +CREATE TABLE prt2_n_p2 PARTITION OF prt2_n FOR VALUES IN ('0001', '0005', '0002', '0009', '0008', '0011') +-- +TABLE: name="prt2_n_p2" schema="" table="prt2_n_p2" ctx=DDL +STMT: CreateStmt +== 216 +INSERT INTO prt2_n SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 217 +ANALYZE prt2_n +-- +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=DDL +STMT: VacuumStmt +== 218 +CREATE TABLE prt3_n (a int, b int, c text) PARTITION BY LIST(c) +-- +TABLE: name="prt3_n" schema="" table="prt3_n" ctx=DDL +STMT: CreateStmt +== 219 +CREATE TABLE prt3_n_p1 PARTITION OF prt3_n FOR VALUES IN ('0000', '0004', '0006', '0007') +-- +TABLE: name="prt3_n_p1" schema="" table="prt3_n_p1" ctx=DDL +STMT: CreateStmt +== 220 +CREATE TABLE prt3_n_p2 PARTITION OF prt3_n FOR VALUES IN ('0001', '0002', '0008', '0010') +-- +TABLE: name="prt3_n_p2" schema="" table="prt3_n_p2" ctx=DDL +STMT: CreateStmt +== 221 +CREATE TABLE prt3_n_p3 PARTITION OF prt3_n FOR VALUES IN ('0003', '0005', '0009', '0011') +-- +TABLE: name="prt3_n_p3" schema="" table="prt3_n_p3" ctx=DDL +STMT: CreateStmt +== 222 +INSERT INTO prt2_n SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 223 +ANALYZE prt3_n +-- +TABLE: name="prt3_n" schema="" table="prt3_n" ctx=DDL +STMT: VacuumStmt +== 224 +CREATE TABLE prt4_n (a int, b int, c text) PARTITION BY RANGE(a) +-- +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=DDL +STMT: CreateStmt +== 225 +CREATE TABLE prt4_n_p1 PARTITION OF prt4_n FOR VALUES FROM (0) TO (300) +-- +TABLE: name="prt4_n_p1" schema="" table="prt4_n_p1" ctx=DDL +STMT: CreateStmt +== 226 +CREATE TABLE prt4_n_p2 PARTITION OF prt4_n FOR VALUES FROM (300) TO (500) +-- +TABLE: name="prt4_n_p2" schema="" table="prt4_n_p2" ctx=DDL +STMT: CreateStmt +== 227 +CREATE TABLE prt4_n_p3 PARTITION OF prt4_n FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt4_n_p3" schema="" table="prt4_n_p3" ctx=DDL +STMT: CreateStmt +== 228 +INSERT INTO prt4_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 229 +ANALYZE prt4_n +-- +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=DDL +STMT: VacuumStmt +== 230 +-- partitionwise join can not be applied if the partition ranges differ +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2 WHERE t1.a = t2.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt4_n" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 231 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2, prt2 t3 WHERE t1.a = t2.a and t1.a = t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt4_n" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t3" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 232 +-- partitionwise join can not be applied if there are no equi-join conditions +-- between partition keys +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON (t1.a < t2.b) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +STMT: ExplainStmt +STMT: SelectStmt +== 233 +-- equi-join with join condition on partial keys does not qualify for +-- partitionwise join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1, prt2_m t2 WHERE t1.a = (t2.b + t2.a)/2 +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +ALIAS: "t1"="prt1_m" +ALIAS: "t2"="prt2_m" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 234 +-- equi-join between out-of-order partition key columns does not qualify for +-- partitionwise join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.a = t2.b +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +ALIAS: "t1"="prt1_m" +ALIAS: "t2"="prt2_m" +STMT: ExplainStmt +STMT: SelectStmt +== 235 +-- equi-join between non-key columns does not qualify for partitionwise join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.c = t2.c +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +ALIAS: "t1"="prt1_m" +ALIAS: "t2"="prt2_m" +STMT: ExplainStmt +STMT: SelectStmt +== 236 +-- partitionwise join can not be applied for a join between list and range +-- partitioned tables +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 LEFT JOIN prt2_n t2 ON (t1.c = t2.c) +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=Select +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=Select +ALIAS: "t1"="prt1_n" +ALIAS: "t2"="prt2_n" +STMT: ExplainStmt +STMT: SelectStmt +== 237 +-- partitionwise join can not be applied between tables with different +-- partition lists +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 JOIN prt2_n t2 ON (t1.c = t2.c) JOIN plt1 t3 ON (t1.c = t3.c) +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=Select +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=Select +TABLE: name="plt1" schema="" table="plt1" ctx=Select +ALIAS: "t1"="prt1_n" +ALIAS: "t2"="prt2_n" +ALIAS: "t3"="plt1" +STMT: ExplainStmt +STMT: SelectStmt +== 238 +-- partitionwise join can not be applied for a join between key column and +-- non-key column +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 FULL JOIN prt1 t2 ON (t1.c = t2.c) +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1_n" +ALIAS: "t2"="prt1" +STMT: ExplainStmt +STMT: SelectStmt +== 239 +|-- +-- Test some other plan types in a partitionwise join (unfortunately, +-- we need larger tables to get the planner to choose these plan types) +|-- +create temp table prtx1 (a integer, b integer, c integer) + partition by range (a) +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=DDL +STMT: CreateStmt +== 240 +create temp table prtx1_1 partition of prtx1 for values from (1) to (11) +-- +TABLE: name="prtx1_1" schema="" table="prtx1_1" ctx=DDL +STMT: CreateStmt +== 241 +create temp table prtx1_2 partition of prtx1 for values from (11) to (21) +-- +TABLE: name="prtx1_2" schema="" table="prtx1_2" ctx=DDL +STMT: CreateStmt +== 242 +create temp table prtx1_3 partition of prtx1 for values from (21) to (31) +-- +TABLE: name="prtx1_3" schema="" table="prtx1_3" ctx=DDL +STMT: CreateStmt +== 243 +create temp table prtx2 (a integer, b integer, c integer) + partition by range (a) +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DDL +STMT: CreateStmt +== 244 +create temp table prtx2_1 partition of prtx2 for values from (1) to (11) +-- +TABLE: name="prtx2_1" schema="" table="prtx2_1" ctx=DDL +STMT: CreateStmt +== 245 +create temp table prtx2_2 partition of prtx2 for values from (11) to (21) +-- +TABLE: name="prtx2_2" schema="" table="prtx2_2" ctx=DDL +STMT: CreateStmt +== 246 +create temp table prtx2_3 partition of prtx2 for values from (21) to (31) +-- +TABLE: name="prtx2_3" schema="" table="prtx2_3" ctx=DDL +STMT: CreateStmt +== 247 +insert into prtx1 select 1 + i%30, i, i + from generate_series(1,1000) i +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 248 +insert into prtx2 select 1 + i%30, i, i + from generate_series(1,500) i, generate_series(1,10) j +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 249 +create index on prtx2 (b) +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DDL +STMT: IndexStmt +== 250 +create index on prtx2 (c) +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DDL +STMT: IndexStmt +== 251 +analyze prtx1 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=DDL +STMT: VacuumStmt +== 252 +analyze prtx2 +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DDL +STMT: VacuumStmt +== 253 +explain (costs off) +select * from prtx1 +where not exists (select 1 from prtx2 + where prtx2.a=prtx1.a and prtx2.b=prtx1.b and prtx2.c=123) + and a<20 and c=120 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=Select +TABLE: name="prtx2" schema="" table="prtx2" ctx=Select +FILTER: schema="" table="prtx2" column="a" +FILTER: schema="" table="prtx1" column="a" +FILTER: schema="" table="prtx2" column="b" +FILTER: schema="" table="prtx1" column="b" +FILTER: schema="" table="prtx2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 254 +select * from prtx1 +where not exists (select 1 from prtx2 + where prtx2.a=prtx1.a and prtx2.b=prtx1.b and prtx2.c=123) + and a<20 and c=120 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=Select +TABLE: name="prtx2" schema="" table="prtx2" ctx=Select +FILTER: schema="" table="prtx2" column="a" +FILTER: schema="" table="prtx1" column="a" +FILTER: schema="" table="prtx2" column="b" +FILTER: schema="" table="prtx1" column="b" +FILTER: schema="" table="prtx2" column="c" +STMT: SelectStmt +== 255 +explain (costs off) +select * from prtx1 +where not exists (select 1 from prtx2 + where prtx2.a=prtx1.a and (prtx2.b=prtx1.b+1 or prtx2.c=99)) + and a<20 and c=91 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=Select +TABLE: name="prtx2" schema="" table="prtx2" ctx=Select +FILTER: schema="" table="prtx2" column="a" +FILTER: schema="" table="prtx1" column="a" +FILTER: schema="" table="prtx2" column="b" +FILTER: schema="" table="prtx1" column="b" +FILTER: schema="" table="prtx2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 256 +select * from prtx1 +where not exists (select 1 from prtx2 + where prtx2.a=prtx1.a and (prtx2.b=prtx1.b+1 or prtx2.c=99)) + and a<20 and c=91 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=Select +TABLE: name="prtx2" schema="" table="prtx2" ctx=Select +FILTER: schema="" table="prtx2" column="a" +FILTER: schema="" table="prtx1" column="a" +FILTER: schema="" table="prtx2" column="b" +FILTER: schema="" table="prtx1" column="b" +FILTER: schema="" table="prtx2" column="c" +STMT: SelectStmt +== 257 +|-- +-- Test advanced partition-matching algorithm for partitioned join +|-- + +-- Tests for range-partitioned tables +CREATE TABLE prt1_adv (a int, b int, c varchar) PARTITION BY RANGE (a) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: CreateStmt +== 258 +CREATE TABLE prt1_adv_p1 PARTITION OF prt1_adv FOR VALUES FROM (100) TO (200) +-- +TABLE: name="prt1_adv_p1" schema="" table="prt1_adv_p1" ctx=DDL +STMT: CreateStmt +== 259 +CREATE TABLE prt1_adv_p2 PARTITION OF prt1_adv FOR VALUES FROM (200) TO (300) +-- +TABLE: name="prt1_adv_p2" schema="" table="prt1_adv_p2" ctx=DDL +STMT: CreateStmt +== 260 +CREATE TABLE prt1_adv_p3 PARTITION OF prt1_adv FOR VALUES FROM (300) TO (400) +-- +TABLE: name="prt1_adv_p3" schema="" table="prt1_adv_p3" ctx=DDL +STMT: CreateStmt +== 261 +CREATE INDEX prt1_adv_a_idx ON prt1_adv (a) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: IndexStmt +== 262 +INSERT INTO prt1_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(100, 399) i +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 263 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +== 264 +CREATE TABLE prt2_adv (a int, b int, c varchar) PARTITION BY RANGE (b) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: CreateStmt +== 265 +CREATE TABLE prt2_adv_p1 PARTITION OF prt2_adv FOR VALUES FROM (100) TO (150) +-- +TABLE: name="prt2_adv_p1" schema="" table="prt2_adv_p1" ctx=DDL +STMT: CreateStmt +== 266 +CREATE TABLE prt2_adv_p2 PARTITION OF prt2_adv FOR VALUES FROM (200) TO (300) +-- +TABLE: name="prt2_adv_p2" schema="" table="prt2_adv_p2" ctx=DDL +STMT: CreateStmt +== 267 +CREATE TABLE prt2_adv_p3 PARTITION OF prt2_adv FOR VALUES FROM (350) TO (500) +-- +TABLE: name="prt2_adv_p3" schema="" table="prt2_adv_p3" ctx=DDL +STMT: CreateStmt +== 268 +CREATE INDEX prt2_adv_b_idx ON prt2_adv (b) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: IndexStmt +== 269 +INSERT INTO prt2_adv_p1 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(100, 149) i +-- +TABLE: name="prt2_adv_p1" schema="" table="prt2_adv_p1" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 270 +INSERT INTO prt2_adv_p2 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(200, 299) i +-- +TABLE: name="prt2_adv_p2" schema="" table="prt2_adv_p2" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 271 +INSERT INTO prt2_adv_p3 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(350, 499) i +-- +TABLE: name="prt2_adv_p3" schema="" table="prt2_adv_p3" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 272 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 273 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 274 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 275 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 276 +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 277 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 278 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 279 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 280 +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 281 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 phv, * FROM prt1_adv WHERE prt1_adv.b = 0) t1 FULL JOIN (SELECT 425 phv, * FROM prt2_adv WHERE prt2_adv.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1_adv" column="b" +FILTER: schema="" table="prt2_adv" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 282 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 phv, * FROM prt1_adv WHERE prt1_adv.b = 0) t1 FULL JOIN (SELECT 425 phv, * FROM prt2_adv WHERE prt2_adv.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1_adv" column="b" +FILTER: schema="" table="prt2_adv" column="a" +STMT: SelectStmt +== 283 +-- Test cases where one side has an extra partition +CREATE TABLE prt2_adv_extra PARTITION OF prt2_adv FOR VALUES FROM (500) TO (MAXVALUE) +-- +TABLE: name="prt2_adv_extra" schema="" table="prt2_adv_extra" ctx=DDL +STMT: CreateStmt +== 284 +INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(500, 599) i +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 285 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 286 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 287 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 288 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 289 +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 290 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 291 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 292 +-- left join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.b, t1.c, t2.a, t2.c FROM prt2_adv t1 LEFT JOIN prt1_adv t2 ON (t1.b = t2.a) WHERE t1.a = 0 ORDER BY t1.b, t2.a +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +ALIAS: "t1"="prt2_adv" +ALIAS: "t2"="prt1_adv" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 293 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 294 +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 295 +-- anti join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt2_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt1_adv t2 WHERE t1.b = t2.a) AND t1.a = 0 ORDER BY t1.b +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +ALIAS: "t1"="prt2_adv" +ALIAS: "t2"="prt1_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 296 +-- full join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 phv, * FROM prt1_adv WHERE prt1_adv.b = 0) t1 FULL JOIN (SELECT 425 phv, * FROM prt2_adv WHERE prt2_adv.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1_adv" column="b" +FILTER: schema="" table="prt2_adv" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 297 +-- 3-way join where not every pair of relations can do partitioned join +EXPLAIN (COSTS OFF) +SELECT t1.b, t1.c, t2.a, t2.c, t3.a, t3.c FROM prt2_adv t1 LEFT JOIN prt1_adv t2 ON (t1.b = t2.a) INNER JOIN prt1_adv t3 ON (t1.b = t3.a) WHERE t1.a = 0 ORDER BY t1.b, t2.a, t3.a +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +ALIAS: "t1"="prt2_adv" +ALIAS: "t2"="prt1_adv" +ALIAS: "t3"="prt1_adv" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 298 +SELECT t1.b, t1.c, t2.a, t2.c, t3.a, t3.c FROM prt2_adv t1 LEFT JOIN prt1_adv t2 ON (t1.b = t2.a) INNER JOIN prt1_adv t3 ON (t1.b = t3.a) WHERE t1.a = 0 ORDER BY t1.b, t2.a, t3.a +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +ALIAS: "t1"="prt2_adv" +ALIAS: "t2"="prt1_adv" +ALIAS: "t3"="prt1_adv" +FILTER: schema="" table="t1" column="a" +STMT: SelectStmt +== 299 +DROP TABLE prt2_adv_extra +-- +TABLE: name="prt2_adv_extra" schema="" table="prt2_adv_extra" ctx=DDL +STMT: DropStmt +== 300 +-- Test cases where a partition on one side matches multiple partitions on +-- the other side; we currently can't do partitioned join in such cases +ALTER TABLE prt2_adv DETACH PARTITION prt2_adv_p3 +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: AlterTableStmt +== 301 +-- Split prt2_adv_p3 into two partitions so that prt1_adv_p3 matches both +CREATE TABLE prt2_adv_p3_1 PARTITION OF prt2_adv FOR VALUES FROM (350) TO (375) +-- +TABLE: name="prt2_adv_p3_1" schema="" table="prt2_adv_p3_1" ctx=DDL +STMT: CreateStmt +== 302 +CREATE TABLE prt2_adv_p3_2 PARTITION OF prt2_adv FOR VALUES FROM (375) TO (500) +-- +TABLE: name="prt2_adv_p3_2" schema="" table="prt2_adv_p3_2" ctx=DDL +STMT: CreateStmt +== 303 +INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(350, 499) i +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 304 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 305 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 306 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 307 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 308 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 309 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 phv, * FROM prt1_adv WHERE prt1_adv.b = 0) t1 FULL JOIN (SELECT 425 phv, * FROM prt2_adv WHERE prt2_adv.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1_adv" column="b" +FILTER: schema="" table="prt2_adv" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 310 +DROP TABLE prt2_adv_p3_1 +-- +TABLE: name="prt2_adv_p3_1" schema="" table="prt2_adv_p3_1" ctx=DDL +STMT: DropStmt +== 311 +DROP TABLE prt2_adv_p3_2 +-- +TABLE: name="prt2_adv_p3_2" schema="" table="prt2_adv_p3_2" ctx=DDL +STMT: DropStmt +== 312 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 313 +-- Test default partitions +ALTER TABLE prt1_adv DETACH PARTITION prt1_adv_p1 +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: AlterTableStmt +== 314 +-- Change prt1_adv_p1 to the default partition +ALTER TABLE prt1_adv ATTACH PARTITION prt1_adv_p1 DEFAULT +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: AlterTableStmt +== 315 +ALTER TABLE prt1_adv DETACH PARTITION prt1_adv_p3 +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: AlterTableStmt +== 316 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +== 317 +-- We can do partitioned join even if only one of relations has the default +-- partition +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 318 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 319 +-- Restore prt1_adv_p3 +ALTER TABLE prt1_adv ATTACH PARTITION prt1_adv_p3 FOR VALUES FROM (300) TO (400) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: AlterTableStmt +== 320 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +== 321 +-- Restore prt2_adv_p3 +ALTER TABLE prt2_adv ATTACH PARTITION prt2_adv_p3 FOR VALUES FROM (350) TO (500) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: AlterTableStmt +== 322 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 323 +-- Partitioned join can't be applied because the default partition of prt1_adv +-- matches prt2_adv_p1 and prt2_adv_p3 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 324 +ALTER TABLE prt2_adv DETACH PARTITION prt2_adv_p3 +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: AlterTableStmt +== 325 +-- Change prt2_adv_p3 to the default partition +ALTER TABLE prt2_adv ATTACH PARTITION prt2_adv_p3 DEFAULT +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: AlterTableStmt +== 326 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 327 +-- Partitioned join can't be applied because the default partition of prt1_adv +-- matches prt2_adv_p1 and prt2_adv_p3 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 328 +DROP TABLE prt1_adv_p3 +-- +TABLE: name="prt1_adv_p3" schema="" table="prt1_adv_p3" ctx=DDL +STMT: DropStmt +== 329 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +== 330 +DROP TABLE prt2_adv_p3 +-- +TABLE: name="prt2_adv_p3" schema="" table="prt2_adv_p3" ctx=DDL +STMT: DropStmt +== 331 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 332 +CREATE TABLE prt3_adv (a int, b int, c varchar) PARTITION BY RANGE (a) +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DDL +STMT: CreateStmt +== 333 +CREATE TABLE prt3_adv_p1 PARTITION OF prt3_adv FOR VALUES FROM (200) TO (300) +-- +TABLE: name="prt3_adv_p1" schema="" table="prt3_adv_p1" ctx=DDL +STMT: CreateStmt +== 334 +CREATE TABLE prt3_adv_p2 PARTITION OF prt3_adv FOR VALUES FROM (300) TO (400) +-- +TABLE: name="prt3_adv_p2" schema="" table="prt3_adv_p2" ctx=DDL +STMT: CreateStmt +== 335 +CREATE INDEX prt3_adv_a_idx ON prt3_adv (a) +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DDL +STMT: IndexStmt +== 336 +INSERT INTO prt3_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(200, 399) i +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 337 +ANALYZE prt3_adv +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DDL +STMT: VacuumStmt +== 338 +-- 3-way join to test the default partition of a join relation +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a, t3.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) LEFT JOIN prt3_adv t3 ON (t1.a = t3.a) WHERE t1.b = 0 ORDER BY t1.a, t2.b, t3.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +ALIAS: "t3"="prt3_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 339 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a, t3.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) LEFT JOIN prt3_adv t3 ON (t1.a = t3.a) WHERE t1.b = 0 ORDER BY t1.a, t2.b, t3.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +ALIAS: "t3"="prt3_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 340 +DROP TABLE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: DropStmt +== 341 +DROP TABLE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: DropStmt +== 342 +DROP TABLE prt3_adv +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DDL +STMT: DropStmt +== 343 +-- Test interaction of partitioned join with partition pruning +CREATE TABLE prt1_adv (a int, b int, c varchar) PARTITION BY RANGE (a) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: CreateStmt +== 344 +CREATE TABLE prt1_adv_p1 PARTITION OF prt1_adv FOR VALUES FROM (100) TO (200) +-- +TABLE: name="prt1_adv_p1" schema="" table="prt1_adv_p1" ctx=DDL +STMT: CreateStmt +== 345 +CREATE TABLE prt1_adv_p2 PARTITION OF prt1_adv FOR VALUES FROM (200) TO (300) +-- +TABLE: name="prt1_adv_p2" schema="" table="prt1_adv_p2" ctx=DDL +STMT: CreateStmt +== 346 +CREATE TABLE prt1_adv_p3 PARTITION OF prt1_adv FOR VALUES FROM (300) TO (400) +-- +TABLE: name="prt1_adv_p3" schema="" table="prt1_adv_p3" ctx=DDL +STMT: CreateStmt +== 347 +CREATE INDEX prt1_adv_a_idx ON prt1_adv (a) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: IndexStmt +== 348 +INSERT INTO prt1_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(100, 399) i +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 349 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +== 350 +CREATE TABLE prt2_adv (a int, b int, c varchar) PARTITION BY RANGE (b) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: CreateStmt +== 351 +CREATE TABLE prt2_adv_p1 PARTITION OF prt2_adv FOR VALUES FROM (100) TO (200) +-- +TABLE: name="prt2_adv_p1" schema="" table="prt2_adv_p1" ctx=DDL +STMT: CreateStmt +== 352 +CREATE TABLE prt2_adv_p2 PARTITION OF prt2_adv FOR VALUES FROM (200) TO (400) +-- +TABLE: name="prt2_adv_p2" schema="" table="prt2_adv_p2" ctx=DDL +STMT: CreateStmt +== 353 +CREATE INDEX prt2_adv_b_idx ON prt2_adv (b) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: IndexStmt +== 354 +INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(100, 399) i +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 355 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 356 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.a < 300 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 357 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.a < 300 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 358 +DROP TABLE prt1_adv_p3 +-- +TABLE: name="prt1_adv_p3" schema="" table="prt1_adv_p3" ctx=DDL +STMT: DropStmt +== 359 +CREATE TABLE prt1_adv_default PARTITION OF prt1_adv DEFAULT +-- +TABLE: name="prt1_adv_default" schema="" table="prt1_adv_default" ctx=DDL +STMT: CreateStmt +== 360 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +== 361 +CREATE TABLE prt2_adv_default PARTITION OF prt2_adv DEFAULT +-- +TABLE: name="prt2_adv_default" schema="" table="prt2_adv_default" ctx=DDL +STMT: CreateStmt +== 362 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +== 363 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.a >= 100 AND t1.a < 300 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 364 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.a >= 100 AND t1.a < 300 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 365 +DROP TABLE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: DropStmt +== 366 +DROP TABLE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: DropStmt +== 367 +-- Tests for list-partitioned tables +CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: CreateStmt +== 368 +CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0001', '0003') +-- +TABLE: name="plt1_adv_p1" schema="" table="plt1_adv_p1" ctx=DDL +STMT: CreateStmt +== 369 +CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt1_adv_p2" schema="" table="plt1_adv_p2" ctx=DDL +STMT: CreateStmt +== 370 +CREATE TABLE plt1_adv_p3 PARTITION OF plt1_adv FOR VALUES IN ('0008', '0009') +-- +TABLE: name="plt1_adv_p3" schema="" table="plt1_adv_p3" ctx=DDL +STMT: CreateStmt +== 371 +INSERT INTO plt1_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 372 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +== 373 +CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: CreateStmt +== 374 +CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0002', '0003') +-- +TABLE: name="plt2_adv_p1" schema="" table="plt2_adv_p1" ctx=DDL +STMT: CreateStmt +== 375 +CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt2_adv_p2" schema="" table="plt2_adv_p2" ctx=DDL +STMT: CreateStmt +== 376 +CREATE TABLE plt2_adv_p3 PARTITION OF plt2_adv FOR VALUES IN ('0007', '0009') +-- +TABLE: name="plt2_adv_p3" schema="" table="plt2_adv_p3" ctx=DDL +STMT: CreateStmt +== 377 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 378 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 379 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 380 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 381 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 382 +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +== 383 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 384 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 385 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 386 +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +== 387 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 388 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 389 +-- Test cases where one side has an extra partition +CREATE TABLE plt2_adv_extra PARTITION OF plt2_adv FOR VALUES IN ('0000') +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DDL +STMT: CreateStmt +== 390 +INSERT INTO plt2_adv_extra VALUES (0, 0, '0000') +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 391 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 392 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 393 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 394 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 395 +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +== 396 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 397 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 398 +-- left join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt2_adv t1 LEFT JOIN plt1_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +ALIAS: "t1"="plt2_adv" +ALIAS: "t2"="plt1_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 399 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 400 +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +== 401 +-- anti join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt2_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt1_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +ALIAS: "t1"="plt2_adv" +ALIAS: "t2"="plt1_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 402 +-- full join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 403 +DROP TABLE plt2_adv_extra +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DDL +STMT: DropStmt +== 404 +-- Test cases where a partition on one side matches multiple partitions on +-- the other side; we currently can't do partitioned join in such cases +ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2 +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +== 405 +-- Split plt2_adv_p2 into two partitions so that plt1_adv_p2 matches both +CREATE TABLE plt2_adv_p2_1 PARTITION OF plt2_adv FOR VALUES IN ('0004') +-- +TABLE: name="plt2_adv_p2_1" schema="" table="plt2_adv_p2_1" ctx=DDL +STMT: CreateStmt +== 406 +CREATE TABLE plt2_adv_p2_2 PARTITION OF plt2_adv FOR VALUES IN ('0006') +-- +TABLE: name="plt2_adv_p2_2" schema="" table="plt2_adv_p2_2" ctx=DDL +STMT: CreateStmt +== 407 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (4, 6) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 408 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 409 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 410 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 411 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 412 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 413 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 414 +DROP TABLE plt2_adv_p2_1 +-- +TABLE: name="plt2_adv_p2_1" schema="" table="plt2_adv_p2_1" ctx=DDL +STMT: DropStmt +== 415 +DROP TABLE plt2_adv_p2_2 +-- +TABLE: name="plt2_adv_p2_2" schema="" table="plt2_adv_p2_2" ctx=DDL +STMT: DropStmt +== 416 +-- Restore plt2_adv_p2 +ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2 FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +== 417 +-- Test NULL partitions +ALTER TABLE plt1_adv DETACH PARTITION plt1_adv_p1 +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: AlterTableStmt +== 418 +-- Change plt1_adv_p1 to the NULL partition +CREATE TABLE plt1_adv_p1_null PARTITION OF plt1_adv FOR VALUES IN (NULL, '0001', '0003') +-- +TABLE: name="plt1_adv_p1_null" schema="" table="plt1_adv_p1_null" ctx=DDL +STMT: CreateStmt +== 419 +INSERT INTO plt1_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 420 +INSERT INTO plt1_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 421 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +== 422 +ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p3 +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +== 423 +-- Change plt2_adv_p3 to the NULL partition +CREATE TABLE plt2_adv_p3_null PARTITION OF plt2_adv FOR VALUES IN (NULL, '0007', '0009') +-- +TABLE: name="plt2_adv_p3_null" schema="" table="plt2_adv_p3_null" ctx=DDL +STMT: CreateStmt +== 424 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (7, 9) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 425 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 426 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 427 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 428 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 429 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 430 +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +== 431 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 432 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 433 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 434 +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +== 435 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 436 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 437 +DROP TABLE plt1_adv_p1_null +-- +TABLE: name="plt1_adv_p1_null" schema="" table="plt1_adv_p1_null" ctx=DDL +STMT: DropStmt +== 438 +-- Restore plt1_adv_p1 +ALTER TABLE plt1_adv ATTACH PARTITION plt1_adv_p1 FOR VALUES IN ('0001', '0003') +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: AlterTableStmt +== 439 +-- Add to plt1_adv the extra NULL partition containing only NULL values as the +-- key values +CREATE TABLE plt1_adv_extra PARTITION OF plt1_adv FOR VALUES IN (NULL) +-- +TABLE: name="plt1_adv_extra" schema="" table="plt1_adv_extra" ctx=DDL +STMT: CreateStmt +== 440 +INSERT INTO plt1_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 441 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +== 442 +DROP TABLE plt2_adv_p3_null +-- +TABLE: name="plt2_adv_p3_null" schema="" table="plt2_adv_p3_null" ctx=DDL +STMT: DropStmt +== 443 +-- Restore plt2_adv_p3 +ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p3 FOR VALUES IN ('0007', '0009') +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +== 444 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 445 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 446 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 447 +-- left join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 448 +-- full join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 449 +-- Add to plt2_adv the extra NULL partition containing only NULL values as the +-- key values +CREATE TABLE plt2_adv_extra PARTITION OF plt2_adv FOR VALUES IN (NULL) +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DDL +STMT: CreateStmt +== 450 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 451 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 452 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 453 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 454 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 455 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 456 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 457 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +== 458 +-- 3-way join to test the NULL partition of a join relation +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt1_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt1_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 459 +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt1_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt1_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 460 +DROP TABLE plt1_adv_extra +-- +TABLE: name="plt1_adv_extra" schema="" table="plt1_adv_extra" ctx=DDL +STMT: DropStmt +== 461 +DROP TABLE plt2_adv_extra +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DDL +STMT: DropStmt +== 462 +-- Test default partitions +ALTER TABLE plt1_adv DETACH PARTITION plt1_adv_p1 +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: AlterTableStmt +== 463 +-- Change plt1_adv_p1 to the default partition +ALTER TABLE plt1_adv ATTACH PARTITION plt1_adv_p1 DEFAULT +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: AlterTableStmt +== 464 +DROP TABLE plt1_adv_p3 +-- +TABLE: name="plt1_adv_p3" schema="" table="plt1_adv_p3" ctx=DDL +STMT: DropStmt +== 465 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +== 466 +DROP TABLE plt2_adv_p3 +-- +TABLE: name="plt2_adv_p3" schema="" table="plt2_adv_p3" ctx=DDL +STMT: DropStmt +== 467 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 468 +-- We can do partitioned join even if only one of relations has the default +-- partition +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 469 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 470 +ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2 +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +== 471 +-- Change plt2_adv_p2 to contain '0005' in addition to '0004' and '0006' as +-- the key values +CREATE TABLE plt2_adv_p2_ext PARTITION OF plt2_adv FOR VALUES IN ('0004', '0005', '0006') +-- +TABLE: name="plt2_adv_p2_ext" schema="" table="plt2_adv_p2_ext" ctx=DDL +STMT: CreateStmt +== 472 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (4, 5, 6) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 473 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 474 +-- Partitioned join can't be applied because the default partition of plt1_adv +-- matches plt2_adv_p1 and plt2_adv_p2_ext +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 475 +ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2_ext +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +== 476 +-- Change plt2_adv_p2_ext to the default partition +ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2_ext DEFAULT +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +== 477 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 478 +-- Partitioned join can't be applied because the default partition of plt1_adv +-- matches plt2_adv_p1 and plt2_adv_p2_ext +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 479 +DROP TABLE plt2_adv_p2_ext +-- +TABLE: name="plt2_adv_p2_ext" schema="" table="plt2_adv_p2_ext" ctx=DDL +STMT: DropStmt +== 480 +-- Restore plt2_adv_p2 +ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2 FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +== 481 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 482 +CREATE TABLE plt3_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: CreateStmt +== 483 +CREATE TABLE plt3_adv_p1 PARTITION OF plt3_adv FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt3_adv_p1" schema="" table="plt3_adv_p1" ctx=DDL +STMT: CreateStmt +== 484 +CREATE TABLE plt3_adv_p2 PARTITION OF plt3_adv FOR VALUES IN ('0007', '0009') +-- +TABLE: name="plt3_adv_p2" schema="" table="plt3_adv_p2" ctx=DDL +STMT: CreateStmt +== 485 +INSERT INTO plt3_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (4, 6, 7, 9) +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 486 +ANALYZE plt3_adv +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: VacuumStmt +== 487 +-- 3-way join to test the default partition of a join relation +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt3_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt3_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 488 +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt3_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt3_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 489 +-- Test cases where one side has the default partition while the other side +-- has the NULL partition +DROP TABLE plt2_adv_p1 +-- +TABLE: name="plt2_adv_p1" schema="" table="plt2_adv_p1" ctx=DDL +STMT: DropStmt +== 490 +-- Add the NULL partition to plt2_adv +CREATE TABLE plt2_adv_p1_null PARTITION OF plt2_adv FOR VALUES IN (NULL, '0001', '0003') +-- +TABLE: name="plt2_adv_p1_null" schema="" table="plt2_adv_p1_null" ctx=DDL +STMT: CreateStmt +== 491 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 492 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 493 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 494 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 495 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 496 +DROP TABLE plt2_adv_p1_null +-- +TABLE: name="plt2_adv_p1_null" schema="" table="plt2_adv_p1_null" ctx=DDL +STMT: DropStmt +== 497 +-- Add the NULL partition that contains only NULL values as the key values +CREATE TABLE plt2_adv_p1_null PARTITION OF plt2_adv FOR VALUES IN (NULL) +-- +TABLE: name="plt2_adv_p1_null" schema="" table="plt2_adv_p1_null" ctx=DDL +STMT: CreateStmt +== 498 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 499 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 500 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 501 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 502 +DROP TABLE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: DropStmt +== 503 +DROP TABLE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: DropStmt +== 504 +DROP TABLE plt3_adv +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: DropStmt +== 505 +-- Test interaction of partitioned join with partition pruning +CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: CreateStmt +== 506 +CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0001') +-- +TABLE: name="plt1_adv_p1" schema="" table="plt1_adv_p1" ctx=DDL +STMT: CreateStmt +== 507 +CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0002') +-- +TABLE: name="plt1_adv_p2" schema="" table="plt1_adv_p2" ctx=DDL +STMT: CreateStmt +== 508 +CREATE TABLE plt1_adv_p3 PARTITION OF plt1_adv FOR VALUES IN ('0003') +-- +TABLE: name="plt1_adv_p3" schema="" table="plt1_adv_p3" ctx=DDL +STMT: CreateStmt +== 509 +CREATE TABLE plt1_adv_p4 PARTITION OF plt1_adv FOR VALUES IN (NULL, '0004', '0005') +-- +TABLE: name="plt1_adv_p4" schema="" table="plt1_adv_p4" ctx=DDL +STMT: CreateStmt +== 510 +INSERT INTO plt1_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 2, 3, 4, 5) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 511 +INSERT INTO plt1_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 512 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +== 513 +CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: CreateStmt +== 514 +CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0001', '0002') +-- +TABLE: name="plt2_adv_p1" schema="" table="plt2_adv_p1" ctx=DDL +STMT: CreateStmt +== 515 +CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN (NULL) +-- +TABLE: name="plt2_adv_p2" schema="" table="plt2_adv_p2" ctx=DDL +STMT: CreateStmt +== 516 +CREATE TABLE plt2_adv_p3 PARTITION OF plt2_adv FOR VALUES IN ('0003') +-- +TABLE: name="plt2_adv_p3" schema="" table="plt2_adv_p3" ctx=DDL +STMT: CreateStmt +== 517 +CREATE TABLE plt2_adv_p4 PARTITION OF plt2_adv FOR VALUES IN ('0004', '0005') +-- +TABLE: name="plt2_adv_p4" schema="" table="plt2_adv_p4" ctx=DDL +STMT: CreateStmt +== 518 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 2, 3, 4, 5) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 519 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 520 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 521 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IN ('0003', '0004', '0005') AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 522 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IN ('0003', '0004', '0005') AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 523 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IS NULL AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 524 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IS NULL AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 525 +CREATE TABLE plt1_adv_default PARTITION OF plt1_adv DEFAULT +-- +TABLE: name="plt1_adv_default" schema="" table="plt1_adv_default" ctx=DDL +STMT: CreateStmt +== 526 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +== 527 +CREATE TABLE plt2_adv_default PARTITION OF plt2_adv DEFAULT +-- +TABLE: name="plt2_adv_default" schema="" table="plt2_adv_default" ctx=DDL +STMT: CreateStmt +== 528 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 529 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IN ('0003', '0004', '0005') AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 530 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IN ('0003', '0004', '0005') AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 531 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IS NULL AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 532 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IS NULL AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 533 +DROP TABLE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: DropStmt +== 534 +DROP TABLE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: DropStmt +== 535 +-- Test the process_outer_partition() code path +CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: CreateStmt +== 536 +CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0000', '0001', '0002') +-- +TABLE: name="plt1_adv_p1" schema="" table="plt1_adv_p1" ctx=DDL +STMT: CreateStmt +== 537 +CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0003', '0004') +-- +TABLE: name="plt1_adv_p2" schema="" table="plt1_adv_p2" ctx=DDL +STMT: CreateStmt +== 538 +INSERT INTO plt1_adv SELECT i, i, to_char(i % 5, 'FM0000') FROM generate_series(0, 24) i +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 539 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +== 540 +CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: CreateStmt +== 541 +CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0002') +-- +TABLE: name="plt2_adv_p1" schema="" table="plt2_adv_p1" ctx=DDL +STMT: CreateStmt +== 542 +CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN ('0003', '0004') +-- +TABLE: name="plt2_adv_p2" schema="" table="plt2_adv_p2" ctx=DDL +STMT: CreateStmt +== 543 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 5, 'FM0000') FROM generate_series(0, 24) i WHERE i % 5 IN (2, 3, 4) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 544 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +== 545 +CREATE TABLE plt3_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: CreateStmt +== 546 +CREATE TABLE plt3_adv_p1 PARTITION OF plt3_adv FOR VALUES IN ('0001') +-- +TABLE: name="plt3_adv_p1" schema="" table="plt3_adv_p1" ctx=DDL +STMT: CreateStmt +== 547 +CREATE TABLE plt3_adv_p2 PARTITION OF plt3_adv FOR VALUES IN ('0003', '0004') +-- +TABLE: name="plt3_adv_p2" schema="" table="plt3_adv_p2" ctx=DDL +STMT: CreateStmt +== 548 +INSERT INTO plt3_adv SELECT i, i, to_char(i % 5, 'FM0000') FROM generate_series(0, 24) i WHERE i % 5 IN (1, 3, 4) +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 549 +ANALYZE plt3_adv +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: VacuumStmt +== 550 +-- This tests that when merging partitions from plt1_adv and plt2_adv in +-- merge_list_bounds(), process_outer_partition() returns an already-assigned +-- merged partition when re-called with plt1_adv_p1 for the second list value +-- '0001' of that partition +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM (plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.c = t2.c)) FULL JOIN plt3_adv t3 ON (t1.c = t3.c) WHERE coalesce(t1.a, 0) % 5 != 3 AND coalesce(t1.a, 0) % 5 != 4 ORDER BY t1.c, t1.a, t2.a, t3.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt3_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 551 +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM (plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.c = t2.c)) FULL JOIN plt3_adv t3 ON (t1.c = t3.c) WHERE coalesce(t1.a, 0) % 5 != 3 AND coalesce(t1.a, 0) % 5 != 4 ORDER BY t1.c, t1.a, t2.a, t3.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt3_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +STMT: SelectStmt +== 552 +DROP TABLE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: DropStmt +== 553 +DROP TABLE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: DropStmt +== 554 +DROP TABLE plt3_adv +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: DropStmt +== 555 +-- Tests for multi-level partitioned tables +CREATE TABLE alpha (a double precision, b int, c text) PARTITION BY RANGE (a) +-- +TABLE: name="alpha" schema="" table="alpha" ctx=DDL +STMT: CreateStmt +== 556 +CREATE TABLE alpha_neg PARTITION OF alpha FOR VALUES FROM ('-Infinity') TO (0) PARTITION BY RANGE (b) +-- +TABLE: name="alpha_neg" schema="" table="alpha_neg" ctx=DDL +STMT: CreateStmt +== 557 +CREATE TABLE alpha_pos PARTITION OF alpha FOR VALUES FROM (0) TO (10.0) PARTITION BY LIST (c) +-- +TABLE: name="alpha_pos" schema="" table="alpha_pos" ctx=DDL +STMT: CreateStmt +== 558 +CREATE TABLE alpha_neg_p1 PARTITION OF alpha_neg FOR VALUES FROM (100) TO (200) +-- +TABLE: name="alpha_neg_p1" schema="" table="alpha_neg_p1" ctx=DDL +STMT: CreateStmt +== 559 +CREATE TABLE alpha_neg_p2 PARTITION OF alpha_neg FOR VALUES FROM (200) TO (300) +-- +TABLE: name="alpha_neg_p2" schema="" table="alpha_neg_p2" ctx=DDL +STMT: CreateStmt +== 560 +CREATE TABLE alpha_neg_p3 PARTITION OF alpha_neg FOR VALUES FROM (300) TO (400) +-- +TABLE: name="alpha_neg_p3" schema="" table="alpha_neg_p3" ctx=DDL +STMT: CreateStmt +== 561 +CREATE TABLE alpha_pos_p1 PARTITION OF alpha_pos FOR VALUES IN ('0001', '0003') +-- +TABLE: name="alpha_pos_p1" schema="" table="alpha_pos_p1" ctx=DDL +STMT: CreateStmt +== 562 +CREATE TABLE alpha_pos_p2 PARTITION OF alpha_pos FOR VALUES IN ('0004', '0006') +-- +TABLE: name="alpha_pos_p2" schema="" table="alpha_pos_p2" ctx=DDL +STMT: CreateStmt +== 563 +CREATE TABLE alpha_pos_p3 PARTITION OF alpha_pos FOR VALUES IN ('0008', '0009') +-- +TABLE: name="alpha_pos_p3" schema="" table="alpha_pos_p3" ctx=DDL +STMT: CreateStmt +== 564 +INSERT INTO alpha_neg SELECT -1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(100, 399) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9) +-- +TABLE: name="alpha_neg" schema="" table="alpha_neg" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 565 +INSERT INTO alpha_pos SELECT 1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(100, 399) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9) +-- +TABLE: name="alpha_pos" schema="" table="alpha_pos" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 566 +ANALYZE alpha +-- +TABLE: name="alpha" schema="" table="alpha" ctx=DDL +STMT: VacuumStmt +== 567 +CREATE TABLE beta (a double precision, b int, c text) PARTITION BY RANGE (a) +-- +TABLE: name="beta" schema="" table="beta" ctx=DDL +STMT: CreateStmt +== 568 +CREATE TABLE beta_neg PARTITION OF beta FOR VALUES FROM (-10.0) TO (0) PARTITION BY RANGE (b) +-- +TABLE: name="beta_neg" schema="" table="beta_neg" ctx=DDL +STMT: CreateStmt +== 569 +CREATE TABLE beta_pos PARTITION OF beta FOR VALUES FROM (0) TO ('Infinity') PARTITION BY LIST (c) +-- +TABLE: name="beta_pos" schema="" table="beta_pos" ctx=DDL +STMT: CreateStmt +== 570 +CREATE TABLE beta_neg_p1 PARTITION OF beta_neg FOR VALUES FROM (100) TO (150) +-- +TABLE: name="beta_neg_p1" schema="" table="beta_neg_p1" ctx=DDL +STMT: CreateStmt +== 571 +CREATE TABLE beta_neg_p2 PARTITION OF beta_neg FOR VALUES FROM (200) TO (300) +-- +TABLE: name="beta_neg_p2" schema="" table="beta_neg_p2" ctx=DDL +STMT: CreateStmt +== 572 +CREATE TABLE beta_neg_p3 PARTITION OF beta_neg FOR VALUES FROM (350) TO (500) +-- +TABLE: name="beta_neg_p3" schema="" table="beta_neg_p3" ctx=DDL +STMT: CreateStmt +== 573 +CREATE TABLE beta_pos_p1 PARTITION OF beta_pos FOR VALUES IN ('0002', '0003') +-- +TABLE: name="beta_pos_p1" schema="" table="beta_pos_p1" ctx=DDL +STMT: CreateStmt +== 574 +CREATE TABLE beta_pos_p2 PARTITION OF beta_pos FOR VALUES IN ('0004', '0006') +-- +TABLE: name="beta_pos_p2" schema="" table="beta_pos_p2" ctx=DDL +STMT: CreateStmt +== 575 +CREATE TABLE beta_pos_p3 PARTITION OF beta_pos FOR VALUES IN ('0007', '0009') +-- +TABLE: name="beta_pos_p3" schema="" table="beta_pos_p3" ctx=DDL +STMT: CreateStmt +== 576 +INSERT INTO beta_neg SELECT -1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(100, 149) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_neg" schema="" table="beta_neg" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 577 +INSERT INTO beta_neg SELECT -1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(200, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_neg" schema="" table="beta_neg" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 578 +INSERT INTO beta_neg SELECT -1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(350, 499) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_neg" schema="" table="beta_neg" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 579 +INSERT INTO beta_pos SELECT 1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(100, 149) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_pos" schema="" table="beta_pos" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 580 +INSERT INTO beta_pos SELECT 1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(200, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_pos" schema="" table="beta_pos" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 581 +INSERT INTO beta_pos SELECT 1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(350, 499) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_pos" schema="" table="beta_pos" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +== 582 +ANALYZE beta +-- +TABLE: name="beta" schema="" table="beta" ctx=DDL +STMT: VacuumStmt +== 583 +EXPLAIN (COSTS OFF) +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.b = t2.b) WHERE t1.b >= 125 AND t1.b < 225 ORDER BY t1.a, t1.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 584 +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.b = t2.b) WHERE t1.b >= 125 AND t1.b < 225 ORDER BY t1.a, t1.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +== 585 +EXPLAIN (COSTS OFF) +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE ((t1.b >= 100 AND t1.b < 110) OR (t1.b >= 200 AND t1.b < 210)) AND ((t2.b >= 100 AND t2.b < 110) OR (t2.b >= 200 AND t2.b < 210)) AND t1.c IN ('0004', '0009') ORDER BY t1.a, t1.b, t2.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 586 +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE ((t1.b >= 100 AND t1.b < 110) OR (t1.b >= 200 AND t1.b < 210)) AND ((t2.b >= 100 AND t2.b < 110) OR (t2.b >= 200 AND t2.b < 210)) AND t1.c IN ('0004', '0009') ORDER BY t1.a, t1.b, t2.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +== 587 +EXPLAIN (COSTS OFF) +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.b = t2.b AND t1.c = t2.c) WHERE ((t1.b >= 100 AND t1.b < 110) OR (t1.b >= 200 AND t1.b < 210)) AND ((t2.b >= 100 AND t2.b < 110) OR (t2.b >= 200 AND t2.b < 210)) AND t1.c IN ('0004', '0009') ORDER BY t1.a, t1.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 588 +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.b = t2.b AND t1.c = t2.c) WHERE ((t1.b >= 100 AND t1.b < 110) OR (t1.b >= 200 AND t1.b < 210)) AND ((t2.b >= 100 AND t2.b < 110) OR (t2.b >= 200 AND t2.b < 210)) AND t1.c IN ('0004', '0009') ORDER BY t1.a, t1.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +== 589 +-- partitionwise join with fractional paths +CREATE TABLE fract_t (id BIGINT, PRIMARY KEY (id)) PARTITION BY RANGE (id) +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=DDL +STMT: CreateStmt +== 590 +CREATE TABLE fract_t0 PARTITION OF fract_t FOR VALUES FROM ('0') TO ('1000') +-- +TABLE: name="fract_t0" schema="" table="fract_t0" ctx=DDL +STMT: CreateStmt +== 591 +CREATE TABLE fract_t1 PARTITION OF fract_t FOR VALUES FROM ('1000') TO ('2000') +-- +TABLE: name="fract_t1" schema="" table="fract_t1" ctx=DDL +STMT: CreateStmt +== 592 +-- insert data +INSERT INTO fract_t (id) (SELECT generate_series(0, 1999)) +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 593 +ANALYZE fract_t +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=DDL +STMT: VacuumStmt +== 594 +-- verify plan; nested index only scans +SET max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +== 595 +SET enable_partitionwise_join = on +-- +STMT: VariableSetStmt +== 596 +EXPLAIN (COSTS OFF) +SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id ASC LIMIT 10 +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=Select +TABLE: name="fract_t" schema="" table="fract_t" ctx=Select +ALIAS: "x"="fract_t" +ALIAS: "y"="fract_t" +STMT: ExplainStmt +STMT: SelectStmt +== 597 +EXPLAIN (COSTS OFF) +SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id DESC LIMIT 10 +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=Select +TABLE: name="fract_t" schema="" table="fract_t" ctx=Select +ALIAS: "x"="fract_t" +ALIAS: "y"="fract_t" +STMT: ExplainStmt +STMT: SelectStmt +== 598 +-- cleanup +DROP TABLE fract_t +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=DDL +STMT: DropStmt +== 599 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +== 600 +RESET enable_partitionwise_join +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/partition_prune.metadata.json b/parser/testdata/summary/postgres_regress/partition_prune.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/partition_prune.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/partition_prune.test b/parser/testdata/summary/postgres_regress/partition_prune.test new file mode 100644 index 0000000..f8bcdda --- /dev/null +++ b/parser/testdata/summary/postgres_regress/partition_prune.test @@ -0,0 +1,4633 @@ +== 001 +|-- +-- Test partitioning planner code +|-- + +-- Force generic plans to be used for all prepared statements in this file. +set plan_cache_mode = force_generic_plan +-- +STMT: VariableSetStmt +== 002 +create table lp (a char) partition by list (a) +-- +TABLE: name="lp" schema="" table="lp" ctx=DDL +STMT: CreateStmt +== 003 +create table lp_default partition of lp default +-- +TABLE: name="lp_default" schema="" table="lp_default" ctx=DDL +STMT: CreateStmt +== 004 +create table lp_ef partition of lp for values in ('e', 'f') +-- +TABLE: name="lp_ef" schema="" table="lp_ef" ctx=DDL +STMT: CreateStmt +== 005 +create table lp_ad partition of lp for values in ('a', 'd') +-- +TABLE: name="lp_ad" schema="" table="lp_ad" ctx=DDL +STMT: CreateStmt +== 006 +create table lp_bc partition of lp for values in ('b', 'c') +-- +TABLE: name="lp_bc" schema="" table="lp_bc" ctx=DDL +STMT: CreateStmt +== 007 +create table lp_g partition of lp for values in ('g') +-- +TABLE: name="lp_g" schema="" table="lp_g" ctx=DDL +STMT: CreateStmt +== 008 +create table lp_null partition of lp for values in (null) +-- +TABLE: name="lp_null" schema="" table="lp_null" ctx=DDL +STMT: CreateStmt +== 009 +explain (costs off) select * from lp +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 010 +explain (costs off) select * from lp where a > 'a' and a < 'd' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 011 +explain (costs off) select * from lp where a > 'a' and a <= 'd' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 012 +explain (costs off) select * from lp where a = 'a' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 013 +explain (costs off) select * from lp where 'a' = a +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 014 +/* commuted */ +explain (costs off) select * from lp where a is not null +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 015 +explain (costs off) select * from lp where a is null +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 016 +explain (costs off) select * from lp where a = 'a' or a = 'c' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 017 +explain (costs off) select * from lp where a is not null and (a = 'a' or a = 'c') +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 018 +explain (costs off) select * from lp where a <> 'g' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 019 +explain (costs off) select * from lp where a <> 'a' and a <> 'd' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 020 +explain (costs off) select * from lp where a not in ('a', 'd') +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 021 +-- collation matches the partitioning collation, pruning works +create table coll_pruning (a text collate "C") partition by list (a) +-- +TABLE: name="coll_pruning" schema="" table="coll_pruning" ctx=DDL +STMT: CreateStmt +== 022 +create table coll_pruning_a partition of coll_pruning for values in ('a') +-- +TABLE: name="coll_pruning_a" schema="" table="coll_pruning_a" ctx=DDL +STMT: CreateStmt +== 023 +create table coll_pruning_b partition of coll_pruning for values in ('b') +-- +TABLE: name="coll_pruning_b" schema="" table="coll_pruning_b" ctx=DDL +STMT: CreateStmt +== 024 +create table coll_pruning_def partition of coll_pruning default +-- +TABLE: name="coll_pruning_def" schema="" table="coll_pruning_def" ctx=DDL +STMT: CreateStmt +== 025 +explain (costs off) select * from coll_pruning where a collate "C" = 'a' collate "C" +-- +TABLE: name="coll_pruning" schema="" table="coll_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 026 +-- collation doesn't match the partitioning collation, no pruning occurs +explain (costs off) select * from coll_pruning where a collate "POSIX" = 'a' collate "POSIX" +-- +TABLE: name="coll_pruning" schema="" table="coll_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 027 +create table rlp (a int, b varchar) partition by range (a) +-- +TABLE: name="rlp" schema="" table="rlp" ctx=DDL +STMT: CreateStmt +== 028 +create table rlp_default partition of rlp default partition by list (a) +-- +TABLE: name="rlp_default" schema="" table="rlp_default" ctx=DDL +STMT: CreateStmt +== 029 +create table rlp_default_default partition of rlp_default default +-- +TABLE: name="rlp_default_default" schema="" table="rlp_default_default" ctx=DDL +STMT: CreateStmt +== 030 +create table rlp_default_10 partition of rlp_default for values in (10) +-- +TABLE: name="rlp_default_10" schema="" table="rlp_default_10" ctx=DDL +STMT: CreateStmt +== 031 +create table rlp_default_30 partition of rlp_default for values in (30) +-- +TABLE: name="rlp_default_30" schema="" table="rlp_default_30" ctx=DDL +STMT: CreateStmt +== 032 +create table rlp_default_null partition of rlp_default for values in (null) +-- +TABLE: name="rlp_default_null" schema="" table="rlp_default_null" ctx=DDL +STMT: CreateStmt +== 033 +create table rlp1 partition of rlp for values from (minvalue) to (1) +-- +TABLE: name="rlp1" schema="" table="rlp1" ctx=DDL +STMT: CreateStmt +== 034 +create table rlp2 partition of rlp for values from (1) to (10) +-- +TABLE: name="rlp2" schema="" table="rlp2" ctx=DDL +STMT: CreateStmt +== 035 +create table rlp3 (b varchar, a int) partition by list (b varchar_ops) +-- +TABLE: name="rlp3" schema="" table="rlp3" ctx=DDL +STMT: CreateStmt +== 036 +create table rlp3_default partition of rlp3 default +-- +TABLE: name="rlp3_default" schema="" table="rlp3_default" ctx=DDL +STMT: CreateStmt +== 037 +create table rlp3abcd partition of rlp3 for values in ('ab', 'cd') +-- +TABLE: name="rlp3abcd" schema="" table="rlp3abcd" ctx=DDL +STMT: CreateStmt +== 038 +create table rlp3efgh partition of rlp3 for values in ('ef', 'gh') +-- +TABLE: name="rlp3efgh" schema="" table="rlp3efgh" ctx=DDL +STMT: CreateStmt +== 039 +create table rlp3nullxy partition of rlp3 for values in (null, 'xy') +-- +TABLE: name="rlp3nullxy" schema="" table="rlp3nullxy" ctx=DDL +STMT: CreateStmt +== 040 +alter table rlp attach partition rlp3 for values from (15) to (20) +-- +TABLE: name="rlp" schema="" table="rlp" ctx=DDL +STMT: AlterTableStmt +== 041 +create table rlp4 partition of rlp for values from (20) to (30) partition by range (a) +-- +TABLE: name="rlp4" schema="" table="rlp4" ctx=DDL +STMT: CreateStmt +== 042 +create table rlp4_default partition of rlp4 default +-- +TABLE: name="rlp4_default" schema="" table="rlp4_default" ctx=DDL +STMT: CreateStmt +== 043 +create table rlp4_1 partition of rlp4 for values from (20) to (25) +-- +TABLE: name="rlp4_1" schema="" table="rlp4_1" ctx=DDL +STMT: CreateStmt +== 044 +create table rlp4_2 partition of rlp4 for values from (25) to (29) +-- +TABLE: name="rlp4_2" schema="" table="rlp4_2" ctx=DDL +STMT: CreateStmt +== 045 +create table rlp5 partition of rlp for values from (31) to (maxvalue) partition by range (a) +-- +TABLE: name="rlp5" schema="" table="rlp5" ctx=DDL +STMT: CreateStmt +== 046 +create table rlp5_default partition of rlp5 default +-- +TABLE: name="rlp5_default" schema="" table="rlp5_default" ctx=DDL +STMT: CreateStmt +== 047 +create table rlp5_1 partition of rlp5 for values from (31) to (40) +-- +TABLE: name="rlp5_1" schema="" table="rlp5_1" ctx=DDL +STMT: CreateStmt +== 048 +explain (costs off) select * from rlp where a < 1 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 049 +explain (costs off) select * from rlp where 1 > a +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 050 +/* commuted */ +explain (costs off) select * from rlp where a <= 1 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 051 +explain (costs off) select * from rlp where a = 1 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 052 +explain (costs off) select * from rlp where a = 1::bigint +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 053 +/* same as above */ +explain (costs off) select * from rlp where a = 1::numeric +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 054 +/* no pruning */ +explain (costs off) select * from rlp where a <= 10 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 055 +explain (costs off) select * from rlp where a > 10 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 056 +explain (costs off) select * from rlp where a < 15 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 057 +explain (costs off) select * from rlp where a <= 15 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 058 +explain (costs off) select * from rlp where a > 15 and b = 'ab' +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 059 +explain (costs off) select * from rlp where a = 16 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 060 +explain (costs off) select * from rlp where a = 16 and b in ('not', 'in', 'here') +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 061 +explain (costs off) select * from rlp where a = 16 and b < 'ab' +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 062 +explain (costs off) select * from rlp where a = 16 and b <= 'ab' +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 063 +explain (costs off) select * from rlp where a = 16 and b is null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 064 +explain (costs off) select * from rlp where a = 16 and b is not null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 065 +explain (costs off) select * from rlp where a is null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 066 +explain (costs off) select * from rlp where a is not null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 067 +explain (costs off) select * from rlp where a > 30 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 068 +explain (costs off) select * from rlp where a = 30 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 069 +/* only default is scanned */ +explain (costs off) select * from rlp where a <= 31 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 070 +explain (costs off) select * from rlp where a = 1 or a = 7 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 071 +explain (costs off) select * from rlp where a = 1 or b = 'ab' +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 072 +explain (costs off) select * from rlp where a > 20 and a < 27 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 073 +explain (costs off) select * from rlp where a = 29 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 074 +explain (costs off) select * from rlp where a >= 29 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 075 +explain (costs off) select * from rlp where a < 1 or (a > 20 and a < 25) +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 076 +-- where clause contradicts sub-partition's constraint +explain (costs off) select * from rlp where a = 20 or a = 40 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 077 +explain (costs off) select * from rlp3 where a = 20 +-- +TABLE: name="rlp3" schema="" table="rlp3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 078 +/* empty */ + +-- redundant clauses are eliminated +explain (costs off) select * from rlp where a > 1 and a = 10 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 079 +/* only default */ +explain (costs off) select * from rlp where a > 1 and a >=15 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 080 +/* rlp3 onwards, including default */ +explain (costs off) select * from rlp where a = 1 and a = 3 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 081 +/* empty */ +explain (costs off) select * from rlp where (a = 1 and a = 3) or (a > 1 and a = 15) +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 082 +-- multi-column keys +create table mc3p (a int, b int, c int) partition by range (a, abs(b), c) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=DDL +STMT: CreateStmt +== 083 +create table mc3p_default partition of mc3p default +-- +TABLE: name="mc3p_default" schema="" table="mc3p_default" ctx=DDL +STMT: CreateStmt +== 084 +create table mc3p0 partition of mc3p for values from (minvalue, minvalue, minvalue) to (1, 1, 1) +-- +TABLE: name="mc3p0" schema="" table="mc3p0" ctx=DDL +STMT: CreateStmt +== 085 +create table mc3p1 partition of mc3p for values from (1, 1, 1) to (10, 5, 10) +-- +TABLE: name="mc3p1" schema="" table="mc3p1" ctx=DDL +STMT: CreateStmt +== 086 +create table mc3p2 partition of mc3p for values from (10, 5, 10) to (10, 10, 10) +-- +TABLE: name="mc3p2" schema="" table="mc3p2" ctx=DDL +STMT: CreateStmt +== 087 +create table mc3p3 partition of mc3p for values from (10, 10, 10) to (10, 10, 20) +-- +TABLE: name="mc3p3" schema="" table="mc3p3" ctx=DDL +STMT: CreateStmt +== 088 +create table mc3p4 partition of mc3p for values from (10, 10, 20) to (10, maxvalue, maxvalue) +-- +TABLE: name="mc3p4" schema="" table="mc3p4" ctx=DDL +STMT: CreateStmt +== 089 +create table mc3p5 partition of mc3p for values from (11, 1, 1) to (20, 10, 10) +-- +TABLE: name="mc3p5" schema="" table="mc3p5" ctx=DDL +STMT: CreateStmt +== 090 +create table mc3p6 partition of mc3p for values from (20, 10, 10) to (20, 20, 20) +-- +TABLE: name="mc3p6" schema="" table="mc3p6" ctx=DDL +STMT: CreateStmt +== 091 +create table mc3p7 partition of mc3p for values from (20, 20, 20) to (maxvalue, maxvalue, maxvalue) +-- +TABLE: name="mc3p7" schema="" table="mc3p7" ctx=DDL +STMT: CreateStmt +== 092 +explain (costs off) select * from mc3p where a = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 093 +explain (costs off) select * from mc3p where a = 1 and abs(b) < 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 094 +explain (costs off) select * from mc3p where a = 1 and abs(b) = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 095 +explain (costs off) select * from mc3p where a = 1 and abs(b) = 1 and c < 8 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 096 +explain (costs off) select * from mc3p where a = 10 and abs(b) between 5 and 35 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 097 +explain (costs off) select * from mc3p where a > 10 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 098 +explain (costs off) select * from mc3p where a >= 10 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 099 +explain (costs off) select * from mc3p where a < 10 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 100 +explain (costs off) select * from mc3p where a <= 10 and abs(b) < 10 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 101 +explain (costs off) select * from mc3p where a = 11 and abs(b) = 0 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 102 +explain (costs off) select * from mc3p where a = 20 and abs(b) = 10 and c = 100 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 103 +explain (costs off) select * from mc3p where a > 20 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 104 +explain (costs off) select * from mc3p where a >= 20 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 105 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1 and c = 1) or (a = 10 and abs(b) = 5 and c = 10) or (a > 11 and a < 20) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 106 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1 and c = 1) or (a = 10 and abs(b) = 5 and c = 10) or (a > 11 and a < 20) or a < 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 107 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1 and c = 1) or (a = 10 and abs(b) = 5 and c = 10) or (a > 11 and a < 20) or a < 1 or a = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 108 +explain (costs off) select * from mc3p where a = 1 or abs(b) = 1 or c = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 109 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1) or (a = 10 and abs(b) = 10) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 110 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1) or (a = 10 and abs(b) = 9) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 111 +-- a simpler multi-column keys case +create table mc2p (a int, b int) partition by range (a, b) +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=DDL +STMT: CreateStmt +== 112 +create table mc2p_default partition of mc2p default +-- +TABLE: name="mc2p_default" schema="" table="mc2p_default" ctx=DDL +STMT: CreateStmt +== 113 +create table mc2p0 partition of mc2p for values from (minvalue, minvalue) to (1, minvalue) +-- +TABLE: name="mc2p0" schema="" table="mc2p0" ctx=DDL +STMT: CreateStmt +== 114 +create table mc2p1 partition of mc2p for values from (1, minvalue) to (1, 1) +-- +TABLE: name="mc2p1" schema="" table="mc2p1" ctx=DDL +STMT: CreateStmt +== 115 +create table mc2p2 partition of mc2p for values from (1, 1) to (2, minvalue) +-- +TABLE: name="mc2p2" schema="" table="mc2p2" ctx=DDL +STMT: CreateStmt +== 116 +create table mc2p3 partition of mc2p for values from (2, minvalue) to (2, 1) +-- +TABLE: name="mc2p3" schema="" table="mc2p3" ctx=DDL +STMT: CreateStmt +== 117 +create table mc2p4 partition of mc2p for values from (2, 1) to (2, maxvalue) +-- +TABLE: name="mc2p4" schema="" table="mc2p4" ctx=DDL +STMT: CreateStmt +== 118 +create table mc2p5 partition of mc2p for values from (2, maxvalue) to (maxvalue, maxvalue) +-- +TABLE: name="mc2p5" schema="" table="mc2p5" ctx=DDL +STMT: CreateStmt +== 119 +explain (costs off) select * from mc2p where a < 2 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 120 +explain (costs off) select * from mc2p where a = 2 and b < 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 121 +explain (costs off) select * from mc2p where a > 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 122 +explain (costs off) select * from mc2p where a = 1 and b > 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 123 +-- all partitions but the default one should be pruned +explain (costs off) select * from mc2p where a = 1 and b is null +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 124 +explain (costs off) select * from mc2p where a is null and b is null +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 125 +explain (costs off) select * from mc2p where a is null and b = 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 126 +explain (costs off) select * from mc2p where a is null +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 127 +explain (costs off) select * from mc2p where b is null +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 128 +-- boolean partitioning +create table boolpart (a bool) partition by list (a) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=DDL +STMT: CreateStmt +== 129 +create table boolpart_default partition of boolpart default +-- +TABLE: name="boolpart_default" schema="" table="boolpart_default" ctx=DDL +STMT: CreateStmt +== 130 +create table boolpart_t partition of boolpart for values in ('true') +-- +TABLE: name="boolpart_t" schema="" table="boolpart_t" ctx=DDL +STMT: CreateStmt +== 131 +create table boolpart_f partition of boolpart for values in ('false') +-- +TABLE: name="boolpart_f" schema="" table="boolpart_f" ctx=DDL +STMT: CreateStmt +== 132 +insert into boolpart values (true), (false), (null) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 133 +explain (costs off) select * from boolpart where a in (true, false) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 134 +explain (costs off) select * from boolpart where a = false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 135 +explain (costs off) select * from boolpart where not a = false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 136 +explain (costs off) select * from boolpart where a is true or a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 137 +explain (costs off) select * from boolpart where a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 138 +explain (costs off) select * from boolpart where a is not true and a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 139 +explain (costs off) select * from boolpart where a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 140 +explain (costs off) select * from boolpart where a is not unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 141 +select * from boolpart where a in (true, false) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 142 +select * from boolpart where a = false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 143 +select * from boolpart where not a = false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 144 +select * from boolpart where a is true or a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 145 +select * from boolpart where a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 146 +select * from boolpart where a is not true and a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 147 +select * from boolpart where a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 148 +select * from boolpart where a is not unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 149 +-- try some other permutations with a NULL partition instead of a DEFAULT +delete from boolpart where a is null +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=DML +STMT: DeleteStmt +== 150 +create table boolpart_null partition of boolpart for values in (null) +-- +TABLE: name="boolpart_null" schema="" table="boolpart_null" ctx=DDL +STMT: CreateStmt +== 151 +insert into boolpart values(null) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +explain (costs off) select * from boolpart where a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 153 +explain (costs off) select * from boolpart where a is not true and a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 154 +explain (costs off) select * from boolpart where a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 155 +explain (costs off) select * from boolpart where a is not unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 156 +select * from boolpart where a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 157 +select * from boolpart where a is not true and a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 158 +select * from boolpart where a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 159 +select * from boolpart where a is not unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 160 +-- check that all partitions are pruned when faced with conflicting clauses +explain (costs off) select * from boolpart where a is not unknown and a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 161 +explain (costs off) select * from boolpart where a is false and a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 162 +explain (costs off) select * from boolpart where a is true and a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 163 +-- inverse boolean partitioning - a seemingly unlikely design, but we've got +-- code for it, so we'd better test it. +create table iboolpart (a bool) partition by list ((not a)) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DDL +STMT: CreateStmt +== 164 +create table iboolpart_default partition of iboolpart default +-- +TABLE: name="iboolpart_default" schema="" table="iboolpart_default" ctx=DDL +STMT: CreateStmt +== 165 +create table iboolpart_f partition of iboolpart for values in ('true') +-- +TABLE: name="iboolpart_f" schema="" table="iboolpart_f" ctx=DDL +STMT: CreateStmt +== 166 +create table iboolpart_t partition of iboolpart for values in ('false') +-- +TABLE: name="iboolpart_t" schema="" table="iboolpart_t" ctx=DDL +STMT: CreateStmt +== 167 +insert into iboolpart values (true), (false), (null) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +explain (costs off) select * from iboolpart where a in (true, false) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 169 +explain (costs off) select * from iboolpart where a = false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 170 +explain (costs off) select * from iboolpart where not a = false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 171 +explain (costs off) select * from iboolpart where a is true or a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 172 +explain (costs off) select * from iboolpart where a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 173 +explain (costs off) select * from iboolpart where a is not true and a is not false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 174 +explain (costs off) select * from iboolpart where a is unknown +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 175 +explain (costs off) select * from iboolpart where a is not unknown +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 176 +select * from iboolpart where a in (true, false) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 177 +select * from iboolpart where a = false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 178 +select * from iboolpart where not a = false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 179 +select * from iboolpart where a is true or a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 180 +select * from iboolpart where a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 181 +select * from iboolpart where a is not true and a is not false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 182 +select * from iboolpart where a is unknown +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 183 +select * from iboolpart where a is not unknown +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 184 +-- Try some other permutations with a NULL partition instead of a DEFAULT +delete from iboolpart where a is null +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DML +STMT: DeleteStmt +== 185 +create table iboolpart_null partition of iboolpart for values in (null) +-- +TABLE: name="iboolpart_null" schema="" table="iboolpart_null" ctx=DDL +STMT: CreateStmt +== 186 +insert into iboolpart values(null) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +-- Pruning shouldn't take place for these. Just check the result is correct +select * from iboolpart where a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 188 +select * from iboolpart where a is not true and a is not false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 189 +select * from iboolpart where a is not false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 190 +create table boolrangep (a bool, b bool, c int) partition by range (a,b,c) +-- +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=DDL +STMT: CreateStmt +== 191 +create table boolrangep_tf partition of boolrangep for values from ('true', 'false', 0) to ('true', 'false', 100) +-- +TABLE: name="boolrangep_tf" schema="" table="boolrangep_tf" ctx=DDL +STMT: CreateStmt +== 192 +create table boolrangep_ft partition of boolrangep for values from ('false', 'true', 0) to ('false', 'true', 100) +-- +TABLE: name="boolrangep_ft" schema="" table="boolrangep_ft" ctx=DDL +STMT: CreateStmt +== 193 +create table boolrangep_ff1 partition of boolrangep for values from ('false', 'false', 0) to ('false', 'false', 50) +-- +TABLE: name="boolrangep_ff1" schema="" table="boolrangep_ff1" ctx=DDL +STMT: CreateStmt +== 194 +create table boolrangep_ff2 partition of boolrangep for values from ('false', 'false', 50) to ('false', 'false', 100) +-- +TABLE: name="boolrangep_ff2" schema="" table="boolrangep_ff2" ctx=DDL +STMT: CreateStmt +== 195 +create table boolrangep_null partition of boolrangep default +-- +TABLE: name="boolrangep_null" schema="" table="boolrangep_null" ctx=DDL +STMT: CreateStmt +== 196 +-- try a more complex case that's been known to trip up pruning in the past +explain (costs off) select * from boolrangep where not a and not b and c = 25 +-- +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 197 +-- ensure we prune boolrangep_tf +explain (costs off) select * from boolrangep where a is not true and not b and c = 25 +-- +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 198 +-- ensure we prune everything apart from boolrangep_tf and boolrangep_null +explain (costs off) select * from boolrangep where a is not false and not b and c = 25 +-- +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 199 +-- test scalar-to-array operators +create table coercepart (a varchar) partition by list (a) +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=DDL +STMT: CreateStmt +== 200 +create table coercepart_ab partition of coercepart for values in ('ab') +-- +TABLE: name="coercepart_ab" schema="" table="coercepart_ab" ctx=DDL +STMT: CreateStmt +== 201 +create table coercepart_bc partition of coercepart for values in ('bc') +-- +TABLE: name="coercepart_bc" schema="" table="coercepart_bc" ctx=DDL +STMT: CreateStmt +== 202 +create table coercepart_cd partition of coercepart for values in ('cd') +-- +TABLE: name="coercepart_cd" schema="" table="coercepart_cd" ctx=DDL +STMT: CreateStmt +== 203 +explain (costs off) select * from coercepart where a in ('ab', to_char(125, '999')) +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 204 +explain (costs off) select * from coercepart where a ~ any ('{ab}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 205 +explain (costs off) select * from coercepart where a !~ all ('{ab}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 206 +explain (costs off) select * from coercepart where a ~ any ('{ab,bc}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 207 +explain (costs off) select * from coercepart where a !~ all ('{ab,bc}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 208 +explain (costs off) select * from coercepart where a = any ('{ab,bc}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 209 +explain (costs off) select * from coercepart where a = any ('{ab,null}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 210 +explain (costs off) select * from coercepart where a = any (null::text[]) +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 211 +explain (costs off) select * from coercepart where a = all ('{ab}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 212 +explain (costs off) select * from coercepart where a = all ('{ab,bc}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 213 +explain (costs off) select * from coercepart where a = all ('{ab,null}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 214 +explain (costs off) select * from coercepart where a = all (null::text[]) +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 215 +drop table coercepart +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=DDL +STMT: DropStmt +== 216 +CREATE TABLE part (a INT, b INT) PARTITION BY LIST (a) +-- +TABLE: name="part" schema="" table="part" ctx=DDL +STMT: CreateStmt +== 217 +CREATE TABLE part_p1 PARTITION OF part FOR VALUES IN (-2,-1,0,1,2) +-- +TABLE: name="part_p1" schema="" table="part_p1" ctx=DDL +STMT: CreateStmt +== 218 +CREATE TABLE part_p2 PARTITION OF part DEFAULT PARTITION BY RANGE(a) +-- +TABLE: name="part_p2" schema="" table="part_p2" ctx=DDL +STMT: CreateStmt +== 219 +CREATE TABLE part_p2_p1 PARTITION OF part_p2 DEFAULT +-- +TABLE: name="part_p2_p1" schema="" table="part_p2_p1" ctx=DDL +STMT: CreateStmt +== 220 +CREATE TABLE part_rev (b INT, c INT, a INT) +-- +TABLE: name="part_rev" schema="" table="part_rev" ctx=DDL +STMT: CreateStmt +== 221 +ALTER TABLE part ATTACH PARTITION part_rev FOR VALUES IN (3) +-- +TABLE: name="part" schema="" table="part" ctx=DDL +STMT: AlterTableStmt +== 222 +-- fail +ALTER TABLE part_rev DROP COLUMN c +-- +TABLE: name="part_rev" schema="" table="part_rev" ctx=DDL +STMT: AlterTableStmt +== 223 +ALTER TABLE part ATTACH PARTITION part_rev FOR VALUES IN (3) +-- +TABLE: name="part" schema="" table="part" ctx=DDL +STMT: AlterTableStmt +== 224 +-- now it's ok +INSERT INTO part VALUES (-1,-1), (1,1), (2,NULL), (NULL,-2),(NULL,NULL) +-- +TABLE: name="part" schema="" table="part" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 225 +EXPLAIN (COSTS OFF) SELECT tableoid::regclass as part, a, b FROM part WHERE a IS NULL ORDER BY 1, 2, 3 +-- +TABLE: name="part" schema="" table="part" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 226 +EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM part p(x) ORDER BY x +-- +TABLE: name="part" schema="" table="part" ctx=Select +ALIAS: "p"="part" +STMT: ExplainStmt +STMT: SelectStmt +== 227 +|-- +-- some more cases +|-- + +|-- +-- pruning for partitioned table appearing inside a sub-query +|-- +-- pruning won't work for mc3p, because some keys are Params +explain (costs off) select * from mc2p t1, lateral (select count(*) from mc3p t2 where t2.a = t1.b and abs(t2.b) = 1 and t2.c = 1) s where t1.a = 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +ALIAS: "t1"="mc2p" +ALIAS: "t2"="mc3p" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 228 +-- pruning should work fine, because values for a prefix of keys (a, b) are +-- available +explain (costs off) select * from mc2p t1, lateral (select count(*) from mc3p t2 where t2.c = t1.b and abs(t2.b) = 1 and t2.a = 1) s where t1.a = 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +ALIAS: "t1"="mc2p" +ALIAS: "t2"="mc3p" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 229 +-- also here, because values for all keys are provided +explain (costs off) select * from mc2p t1, lateral (select count(*) from mc3p t2 where t2.a = 1 and abs(t2.b) = 1 and t2.c = 1) s where t1.a = 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +ALIAS: "t1"="mc2p" +ALIAS: "t2"="mc3p" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 230 +|-- +-- pruning with clauses containing <> operator +|-- + +-- doesn't prune range partitions +create table rp (a int) partition by range (a) +-- +TABLE: name="rp" schema="" table="rp" ctx=DDL +STMT: CreateStmt +== 231 +create table rp0 partition of rp for values from (minvalue) to (1) +-- +TABLE: name="rp0" schema="" table="rp0" ctx=DDL +STMT: CreateStmt +== 232 +create table rp1 partition of rp for values from (1) to (2) +-- +TABLE: name="rp1" schema="" table="rp1" ctx=DDL +STMT: CreateStmt +== 233 +create table rp2 partition of rp for values from (2) to (maxvalue) +-- +TABLE: name="rp2" schema="" table="rp2" ctx=DDL +STMT: CreateStmt +== 234 +explain (costs off) select * from rp where a <> 1 +-- +TABLE: name="rp" schema="" table="rp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 235 +explain (costs off) select * from rp where a <> 1 and a <> 2 +-- +TABLE: name="rp" schema="" table="rp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 236 +-- null partition should be eliminated due to strict <> clause. +explain (costs off) select * from lp where a <> 'a' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 237 +-- ensure we detect contradictions in clauses; a can't be NULL and NOT NULL. +explain (costs off) select * from lp where a <> 'a' and a is null +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 238 +explain (costs off) select * from lp where (a <> 'a' and a <> 'd') or a is null +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 239 +-- check that it also works for a partitioned table that's not root, +-- which in this case are partitions of rlp that are themselves +-- list-partitioned on b +explain (costs off) select * from rlp where a = 15 and b <> 'ab' and b <> 'cd' and b <> 'xy' and b is not null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 240 +|-- +-- different collations for different keys with same expression +|-- +create table coll_pruning_multi (a text) partition by range (substr(a, 1) collate "POSIX", substr(a, 1) collate "C") +-- +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=DDL +STMT: CreateStmt +== 241 +create table coll_pruning_multi1 partition of coll_pruning_multi for values from ('a', 'a') to ('a', 'e') +-- +TABLE: name="coll_pruning_multi1" schema="" table="coll_pruning_multi1" ctx=DDL +STMT: CreateStmt +== 242 +create table coll_pruning_multi2 partition of coll_pruning_multi for values from ('a', 'e') to ('a', 'z') +-- +TABLE: name="coll_pruning_multi2" schema="" table="coll_pruning_multi2" ctx=DDL +STMT: CreateStmt +== 243 +create table coll_pruning_multi3 partition of coll_pruning_multi for values from ('b', 'a') to ('b', 'e') +-- +TABLE: name="coll_pruning_multi3" schema="" table="coll_pruning_multi3" ctx=DDL +STMT: CreateStmt +== 244 +-- no pruning, because no value for the leading key +explain (costs off) select * from coll_pruning_multi where substr(a, 1) = 'e' collate "C" +-- +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 245 +-- pruning, with a value provided for the leading key +explain (costs off) select * from coll_pruning_multi where substr(a, 1) = 'a' collate "POSIX" +-- +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 246 +-- pruning, with values provided for both keys +explain (costs off) select * from coll_pruning_multi where substr(a, 1) = 'e' collate "C" and substr(a, 1) = 'a' collate "POSIX" +-- +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 247 +|-- +-- LIKE operators don't prune +|-- +create table like_op_noprune (a text) partition by list (a) +-- +TABLE: name="like_op_noprune" schema="" table="like_op_noprune" ctx=DDL +STMT: CreateStmt +== 248 +create table like_op_noprune1 partition of like_op_noprune for values in ('ABC') +-- +TABLE: name="like_op_noprune1" schema="" table="like_op_noprune1" ctx=DDL +STMT: CreateStmt +== 249 +create table like_op_noprune2 partition of like_op_noprune for values in ('BCD') +-- +TABLE: name="like_op_noprune2" schema="" table="like_op_noprune2" ctx=DDL +STMT: CreateStmt +== 250 +explain (costs off) select * from like_op_noprune where a like '%BC' +-- +TABLE: name="like_op_noprune" schema="" table="like_op_noprune" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 251 +|-- +-- tests wherein clause value requires a cross-type comparison function +|-- +create table lparted_by_int2 (a smallint) partition by list (a) +-- +TABLE: name="lparted_by_int2" schema="" table="lparted_by_int2" ctx=DDL +STMT: CreateStmt +== 252 +create table lparted_by_int2_1 partition of lparted_by_int2 for values in (1) +-- +TABLE: name="lparted_by_int2_1" schema="" table="lparted_by_int2_1" ctx=DDL +STMT: CreateStmt +== 253 +create table lparted_by_int2_16384 partition of lparted_by_int2 for values in (16384) +-- +TABLE: name="lparted_by_int2_16384" schema="" table="lparted_by_int2_16384" ctx=DDL +STMT: CreateStmt +== 254 +explain (costs off) select * from lparted_by_int2 where a = 100_000_000_000_000 +-- +TABLE: name="lparted_by_int2" schema="" table="lparted_by_int2" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 255 +create table rparted_by_int2 (a smallint) partition by range (a) +-- +TABLE: name="rparted_by_int2" schema="" table="rparted_by_int2" ctx=DDL +STMT: CreateStmt +== 256 +create table rparted_by_int2_1 partition of rparted_by_int2 for values from (1) to (10) +-- +TABLE: name="rparted_by_int2_1" schema="" table="rparted_by_int2_1" ctx=DDL +STMT: CreateStmt +== 257 +create table rparted_by_int2_16384 partition of rparted_by_int2 for values from (10) to (16384) +-- +TABLE: name="rparted_by_int2_16384" schema="" table="rparted_by_int2_16384" ctx=DDL +STMT: CreateStmt +== 258 +-- all partitions pruned +explain (costs off) select * from rparted_by_int2 where a > 100_000_000_000_000 +-- +TABLE: name="rparted_by_int2" schema="" table="rparted_by_int2" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 259 +create table rparted_by_int2_maxvalue partition of rparted_by_int2 for values from (16384) to (maxvalue) +-- +TABLE: name="rparted_by_int2_maxvalue" schema="" table="rparted_by_int2_maxvalue" ctx=DDL +STMT: CreateStmt +== 260 +-- all partitions but rparted_by_int2_maxvalue pruned +explain (costs off) select * from rparted_by_int2 where a > 100_000_000_000_000 +-- +TABLE: name="rparted_by_int2" schema="" table="rparted_by_int2" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 261 +drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, iboolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2 +-- +TABLE: name="lp" schema="" table="lp" ctx=DDL +TABLE: name="coll_pruning" schema="" table="coll_pruning" ctx=DDL +TABLE: name="rlp" schema="" table="rlp" ctx=DDL +TABLE: name="mc3p" schema="" table="mc3p" ctx=DDL +TABLE: name="mc2p" schema="" table="mc2p" ctx=DDL +TABLE: name="boolpart" schema="" table="boolpart" ctx=DDL +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DDL +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=DDL +TABLE: name="rp" schema="" table="rp" ctx=DDL +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=DDL +TABLE: name="like_op_noprune" schema="" table="like_op_noprune" ctx=DDL +TABLE: name="lparted_by_int2" schema="" table="lparted_by_int2" ctx=DDL +TABLE: name="rparted_by_int2" schema="" table="rparted_by_int2" ctx=DDL +STMT: DropStmt +== 262 +-- check that AlternativeSubPlan within a pruning expression gets cleaned up + +create table asptab (id int primary key) partition by range (id) +-- +TABLE: name="asptab" schema="" table="asptab" ctx=DDL +STMT: CreateStmt +== 263 +create table asptab0 partition of asptab for values from (0) to (1) +-- +TABLE: name="asptab0" schema="" table="asptab0" ctx=DDL +STMT: CreateStmt +== 264 +create table asptab1 partition of asptab for values from (1) to (2) +-- +TABLE: name="asptab1" schema="" table="asptab1" ctx=DDL +STMT: CreateStmt +== 265 +explain (costs off) +select * from + (select exists (select 1 from int4_tbl tinner where f1 = touter.f1) as b + from int4_tbl touter) ss, + asptab +where asptab.id > ss.b::int +-- +TABLE: name="asptab" schema="" table="asptab" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "tinner"="int4_tbl" +ALIAS: "touter"="int4_tbl" +FILTER: schema="" table="asptab" column="id" +FILTER: schema="" table="ss" column="b" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="touter" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 266 +drop table asptab +-- +TABLE: name="asptab" schema="" table="asptab" ctx=DDL +STMT: DropStmt +== 267 +|-- +-- Test Partition pruning for HASH partitioning +|-- +-- Use hand-rolled hash functions and operator classes to get predictable +-- result on different machines. See the definitions of +-- part_test_int4_ops and part_test_text_ops in test_setup.sql. +|-- + +create table hp (a int, b text, c int) + partition by hash (a part_test_int4_ops, b part_test_text_ops) +-- +TABLE: name="hp" schema="" table="hp" ctx=DDL +STMT: CreateStmt +== 268 +create table hp0 partition of hp for values with (modulus 4, remainder 0) +-- +TABLE: name="hp0" schema="" table="hp0" ctx=DDL +STMT: CreateStmt +== 269 +create table hp3 partition of hp for values with (modulus 4, remainder 3) +-- +TABLE: name="hp3" schema="" table="hp3" ctx=DDL +STMT: CreateStmt +== 270 +create table hp1 partition of hp for values with (modulus 4, remainder 1) +-- +TABLE: name="hp1" schema="" table="hp1" ctx=DDL +STMT: CreateStmt +== 271 +create table hp2 partition of hp for values with (modulus 4, remainder 2) +-- +TABLE: name="hp2" schema="" table="hp2" ctx=DDL +STMT: CreateStmt +== 272 +insert into hp values (null, null, 0) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 273 +insert into hp values (1, null, 1) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 274 +insert into hp values (1, 'xxx', 2) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 275 +insert into hp values (null, 'xxx', 3) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 276 +insert into hp values (2, 'xxx', 4) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 277 +insert into hp values (1, 'abcde', 5) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 278 +select tableoid::regclass, * from hp order by c +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +STMT: SelectStmt +== 279 +-- partial keys won't prune, nor would non-equality conditions +explain (costs off) select * from hp where a = 1 +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 280 +explain (costs off) select * from hp where b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 281 +explain (costs off) select * from hp where a is null +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 282 +explain (costs off) select * from hp where b is null +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 283 +explain (costs off) select * from hp where a < 1 and b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 284 +explain (costs off) select * from hp where a <> 1 and b = 'yyy' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 285 +explain (costs off) select * from hp where a <> 1 and b <> 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 286 +-- pruning should work if either a value or a IS NULL clause is provided for +-- each of the keys +explain (costs off) select * from hp where a is null and b is null +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 287 +explain (costs off) select * from hp where a = 1 and b is null +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 288 +explain (costs off) select * from hp where a = 1 and b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 289 +explain (costs off) select * from hp where a is null and b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 290 +explain (costs off) select * from hp where a = 2 and b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 291 +explain (costs off) select * from hp where a = 1 and b = 'abcde' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 292 +explain (costs off) select * from hp where (a = 1 and b = 'abcde') or (a = 2 and b = 'xxx') or (a is null and b is null) +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 293 +-- test pruning when not all the partitions exist +drop table hp1 +-- +TABLE: name="hp1" schema="" table="hp1" ctx=DDL +STMT: DropStmt +== 294 +drop table hp3 +-- +TABLE: name="hp3" schema="" table="hp3" ctx=DDL +STMT: DropStmt +== 295 +explain (costs off) select * from hp where a = 1 and b = 'abcde' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 296 +explain (costs off) select * from hp where a = 1 and b = 'abcde' and + (c = 2 or c = 3) +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 297 +drop table hp2 +-- +TABLE: name="hp2" schema="" table="hp2" ctx=DDL +STMT: DropStmt +== 298 +explain (costs off) select * from hp where a = 1 and b = 'abcde' and + (c = 2 or c = 3) +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 299 +|-- +-- Test runtime partition pruning +|-- +create table ab (a int not null, b int not null) partition by list (a) +-- +TABLE: name="ab" schema="" table="ab" ctx=DDL +STMT: CreateStmt +== 300 +create table ab_a2 partition of ab for values in(2) partition by list (b) +-- +TABLE: name="ab_a2" schema="" table="ab_a2" ctx=DDL +STMT: CreateStmt +== 301 +create table ab_a2_b1 partition of ab_a2 for values in (1) +-- +TABLE: name="ab_a2_b1" schema="" table="ab_a2_b1" ctx=DDL +STMT: CreateStmt +== 302 +create table ab_a2_b2 partition of ab_a2 for values in (2) +-- +TABLE: name="ab_a2_b2" schema="" table="ab_a2_b2" ctx=DDL +STMT: CreateStmt +== 303 +create table ab_a2_b3 partition of ab_a2 for values in (3) +-- +TABLE: name="ab_a2_b3" schema="" table="ab_a2_b3" ctx=DDL +STMT: CreateStmt +== 304 +create table ab_a1 partition of ab for values in(1) partition by list (b) +-- +TABLE: name="ab_a1" schema="" table="ab_a1" ctx=DDL +STMT: CreateStmt +== 305 +create table ab_a1_b1 partition of ab_a1 for values in (1) +-- +TABLE: name="ab_a1_b1" schema="" table="ab_a1_b1" ctx=DDL +STMT: CreateStmt +== 306 +create table ab_a1_b2 partition of ab_a1 for values in (2) +-- +TABLE: name="ab_a1_b2" schema="" table="ab_a1_b2" ctx=DDL +STMT: CreateStmt +== 307 +create table ab_a1_b3 partition of ab_a1 for values in (3) +-- +TABLE: name="ab_a1_b3" schema="" table="ab_a1_b3" ctx=DDL +STMT: CreateStmt +== 308 +create table ab_a3 partition of ab for values in(3) partition by list (b) +-- +TABLE: name="ab_a3" schema="" table="ab_a3" ctx=DDL +STMT: CreateStmt +== 309 +create table ab_a3_b1 partition of ab_a3 for values in (1) +-- +TABLE: name="ab_a3_b1" schema="" table="ab_a3_b1" ctx=DDL +STMT: CreateStmt +== 310 +create table ab_a3_b2 partition of ab_a3 for values in (2) +-- +TABLE: name="ab_a3_b2" schema="" table="ab_a3_b2" ctx=DDL +STMT: CreateStmt +== 311 +create table ab_a3_b3 partition of ab_a3 for values in (3) +-- +TABLE: name="ab_a3_b3" schema="" table="ab_a3_b3" ctx=DDL +STMT: CreateStmt +== 312 +-- Disallow index only scans as concurrent transactions may stop visibility +-- bits being set causing "Heap Fetches" to be unstable in the EXPLAIN ANALYZE +-- output. +set enable_indexonlyscan = off +-- +STMT: VariableSetStmt +== 313 +prepare ab_q1 (int, int, int) as +select * from ab where a between $1 and $2 and b <= $3 +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 314 +explain (analyze, costs off, summary off, timing off) execute ab_q1 (2, 2, 3) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 315 +explain (analyze, costs off, summary off, timing off) execute ab_q1 (1, 2, 3) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 316 +deallocate ab_q1 +-- +STMT: DeallocateStmt +== 317 +-- Runtime pruning after optimizer pruning +prepare ab_q1 (int, int) as +select a from ab where a between $1 and $2 and b < 3 +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 318 +explain (analyze, costs off, summary off, timing off) execute ab_q1 (2, 2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 319 +explain (analyze, costs off, summary off, timing off) execute ab_q1 (2, 4) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 320 +-- Ensure a mix of PARAM_EXTERN and PARAM_EXEC Params work together at +-- different levels of partitioning. +prepare ab_q2 (int, int) as +select a from ab where a between $1 and $2 and b < (select 3) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 321 +explain (analyze, costs off, summary off, timing off) execute ab_q2 (2, 2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 322 +-- As above, but swap the PARAM_EXEC Param to the first partition level +prepare ab_q3 (int, int) as +select a from ab where b between $1 and $2 and a < (select 3) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +== 323 +explain (analyze, costs off, summary off, timing off) execute ab_q3 (2, 2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 324 +|-- +-- Test runtime pruning with hash partitioned tables +|-- + +-- recreate partitions dropped above +create table hp1 partition of hp for values with (modulus 4, remainder 1) +-- +TABLE: name="hp1" schema="" table="hp1" ctx=DDL +STMT: CreateStmt +== 325 +create table hp2 partition of hp for values with (modulus 4, remainder 2) +-- +TABLE: name="hp2" schema="" table="hp2" ctx=DDL +STMT: CreateStmt +== 326 +create table hp3 partition of hp for values with (modulus 4, remainder 3) +-- +TABLE: name="hp3" schema="" table="hp3" ctx=DDL +STMT: CreateStmt +== 327 +-- Ensure we correctly prune unneeded partitions when there is an IS NULL qual +prepare hp_q1 (text) as +select * from hp where a is null and b = $1 +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 328 +explain (costs off) execute hp_q1('xxx') +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 329 +deallocate hp_q1 +-- +STMT: DeallocateStmt +== 330 +drop table hp +-- +TABLE: name="hp" schema="" table="hp" ctx=DDL +STMT: DropStmt +== 331 +-- Test a backwards Append scan +create table list_part (a int) partition by list (a) +-- +TABLE: name="list_part" schema="" table="list_part" ctx=DDL +STMT: CreateStmt +== 332 +create table list_part1 partition of list_part for values in (1) +-- +TABLE: name="list_part1" schema="" table="list_part1" ctx=DDL +STMT: CreateStmt +== 333 +create table list_part2 partition of list_part for values in (2) +-- +TABLE: name="list_part2" schema="" table="list_part2" ctx=DDL +STMT: CreateStmt +== 334 +create table list_part3 partition of list_part for values in (3) +-- +TABLE: name="list_part3" schema="" table="list_part3" ctx=DDL +STMT: CreateStmt +== 335 +create table list_part4 partition of list_part for values in (4) +-- +TABLE: name="list_part4" schema="" table="list_part4" ctx=DDL +STMT: CreateStmt +== 336 +insert into list_part select generate_series(1,4) +-- +TABLE: name="list_part" schema="" table="list_part" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 337 +begin +-- +STMT: TransactionStmt +== 338 +-- Don't select an actual value out of the table as the order of the Append's +-- subnodes may not be stable. +declare cur SCROLL CURSOR for select 1 from list_part where a > (select 1) and a < (select 4) +-- +STMT: DeclareCursorStmt +== 339 +-- move beyond the final row +move 3 from cur +-- +STMT: FetchStmt +== 340 +-- Ensure we get two rows. +fetch backward all from cur +-- +STMT: FetchStmt +== 341 +commit +-- +STMT: TransactionStmt +== 342 +begin +-- +STMT: TransactionStmt +== 343 +-- Test run-time pruning using stable functions +create function list_part_fn(int) returns int as $$ begin return $1; end;$$ language plpgsql stable +-- +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 344 +-- Ensure pruning works using a stable function containing no Vars +explain (analyze, costs off, summary off, timing off) select * from list_part where a = list_part_fn(1) +-- +TABLE: name="list_part" schema="" table="list_part" ctx=Select +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 345 +-- Ensure pruning does not take place when the function has a Var parameter +explain (analyze, costs off, summary off, timing off) select * from list_part where a = list_part_fn(a) +-- +TABLE: name="list_part" schema="" table="list_part" ctx=Select +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 346 +-- Ensure pruning does not take place when the expression contains a Var. +explain (analyze, costs off, summary off, timing off) select * from list_part where a = list_part_fn(1) + a +-- +TABLE: name="list_part" schema="" table="list_part" ctx=Select +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 347 +rollback +-- +STMT: TransactionStmt +== 348 +drop table list_part +-- +TABLE: name="list_part" schema="" table="list_part" ctx=DDL +STMT: DropStmt +== 349 +-- Parallel append + +-- Parallel queries won't necessarily get as many workers as the planner +-- asked for. This affects not only the "Workers Launched:" field of EXPLAIN +-- results, but also row counts and loop counts for parallel scans, Gathers, +-- and everything in between. This function filters out the values we can't +-- rely on to be stable. +-- This removes enough info that you might wonder why bother with EXPLAIN +-- ANALYZE at all. The answer is that we need to see '(never executed)' +-- notations because that's the only way to verify runtime pruning. +create function explain_parallel_append(text) returns setof text +language plpgsql as +$$ +declare + ln text; +begin + for ln in + execute format('explain (analyze, costs off, summary off, timing off) %s', + $1) + loop + ln := regexp_replace(ln, 'Workers Launched: \d+', 'Workers Launched: N'); + ln := regexp_replace(ln, 'actual rows=\d+ loops=\d+', 'actual rows=N loops=N'); + ln := regexp_replace(ln, 'Rows Removed by Filter: \d+', 'Rows Removed by Filter: N'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 350 +prepare ab_q4 (int, int) as +select avg(a) from ab where a between $1 and $2 and b < 4 +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 351 +-- Encourage use of parallel plans +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +== 352 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +== 353 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +== 354 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +== 355 +select explain_parallel_append('execute ab_q4 (2, 2)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 356 +-- Test run-time pruning with IN lists. +prepare ab_q5 (int, int, int) as +select avg(a) from ab where a in($1,$2,$3) and b < 4 +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 357 +select explain_parallel_append('execute ab_q5 (1, 1, 1)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 358 +select explain_parallel_append('execute ab_q5 (2, 3, 3)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 359 +-- Try some params whose values do not belong to any partition. +select explain_parallel_append('execute ab_q5 (33, 44, 55)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 360 +-- Test Parallel Append with PARAM_EXEC Params +select explain_parallel_append('select count(*) from ab where (a = (select 1) or a = (select 3)) and b = 2') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 361 +-- Test pruning during parallel nested loop query +create table lprt_a (a int not null) +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DDL +STMT: CreateStmt +== 362 +-- Insert some values we won't find in ab +insert into lprt_a select 0 from generate_series(1,100) +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 363 +-- and insert some values that we should find. +insert into lprt_a values(1),(1) +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 364 +analyze lprt_a +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DDL +STMT: VacuumStmt +== 365 +create index ab_a2_b1_a_idx on ab_a2_b1 (a) +-- +TABLE: name="ab_a2_b1" schema="" table="ab_a2_b1" ctx=DDL +STMT: IndexStmt +== 366 +create index ab_a2_b2_a_idx on ab_a2_b2 (a) +-- +TABLE: name="ab_a2_b2" schema="" table="ab_a2_b2" ctx=DDL +STMT: IndexStmt +== 367 +create index ab_a2_b3_a_idx on ab_a2_b3 (a) +-- +TABLE: name="ab_a2_b3" schema="" table="ab_a2_b3" ctx=DDL +STMT: IndexStmt +== 368 +create index ab_a1_b1_a_idx on ab_a1_b1 (a) +-- +TABLE: name="ab_a1_b1" schema="" table="ab_a1_b1" ctx=DDL +STMT: IndexStmt +== 369 +create index ab_a1_b2_a_idx on ab_a1_b2 (a) +-- +TABLE: name="ab_a1_b2" schema="" table="ab_a1_b2" ctx=DDL +STMT: IndexStmt +== 370 +create index ab_a1_b3_a_idx on ab_a1_b3 (a) +-- +TABLE: name="ab_a1_b3" schema="" table="ab_a1_b3" ctx=DDL +STMT: IndexStmt +== 371 +create index ab_a3_b1_a_idx on ab_a3_b1 (a) +-- +TABLE: name="ab_a3_b1" schema="" table="ab_a3_b1" ctx=DDL +STMT: IndexStmt +== 372 +create index ab_a3_b2_a_idx on ab_a3_b2 (a) +-- +TABLE: name="ab_a3_b2" schema="" table="ab_a3_b2" ctx=DDL +STMT: IndexStmt +== 373 +create index ab_a3_b3_a_idx on ab_a3_b3 (a) +-- +TABLE: name="ab_a3_b3" schema="" table="ab_a3_b3" ctx=DDL +STMT: IndexStmt +== 374 +set enable_hashjoin = 0 +-- +STMT: VariableSetStmt +== 375 +set enable_mergejoin = 0 +-- +STMT: VariableSetStmt +== 376 +set enable_memoize = 0 +-- +STMT: VariableSetStmt +== 377 +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(0, 0, 1)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 378 +-- Ensure the same partitions are pruned when we make the nested loop +-- parameter an Expr rather than a plain Param. +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a + 0 where a.a in(0, 0, 1)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 379 +insert into lprt_a values(3),(3) +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 380 +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 3)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 381 +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 0)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 382 +delete from lprt_a where a = 1 +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DML +STMT: DeleteStmt +== 383 +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 0)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 384 +reset enable_hashjoin +-- +STMT: VariableSetStmt +== 385 +reset enable_mergejoin +-- +STMT: VariableSetStmt +== 386 +reset enable_memoize +-- +STMT: VariableSetStmt +== 387 +reset parallel_setup_cost +-- +STMT: VariableSetStmt +== 388 +reset parallel_tuple_cost +-- +STMT: VariableSetStmt +== 389 +reset min_parallel_table_scan_size +-- +STMT: VariableSetStmt +== 390 +reset max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +== 391 +-- Test run-time partition pruning with an initplan +explain (analyze, costs off, summary off, timing off) +select * from ab where a = (select max(a) from lprt_a) and b = (select max(a)-1 from lprt_a) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=Select +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 392 +-- Test run-time partition pruning with UNION ALL parents +explain (analyze, costs off, summary off, timing off) +select * from (select * from ab where a = 1 union all select * from ab) ab where b = (select 1) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 393 +-- A case containing a UNION ALL with a non-partitioned child. +explain (analyze, costs off, summary off, timing off) +select * from (select * from ab where a = 1 union all (values(10,5)) union all select * from ab) ab where b = (select 1) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 394 +-- Another UNION ALL test, but containing a mix of exec init and exec run-time pruning. +create table xy_1 (x int, y int) +-- +TABLE: name="xy_1" schema="" table="xy_1" ctx=DDL +STMT: CreateStmt +== 395 +insert into xy_1 values(100,-10) +-- +TABLE: name="xy_1" schema="" table="xy_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 396 +set enable_bitmapscan = 0 +-- +STMT: VariableSetStmt +== 397 +set enable_indexscan = 0 +-- +STMT: VariableSetStmt +== 398 +prepare ab_q6 as +select * from ( + select tableoid::regclass,a,b from ab +union all + select tableoid::regclass,x,y from xy_1 +union all + select tableoid::regclass,a,b from ab +) ab where a = $1 and b = (select -10) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +TABLE: name="xy_1" schema="" table="xy_1" ctx=Select +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 399 +-- Ensure the xy_1 subplan is not pruned. +explain (analyze, costs off, summary off, timing off) execute ab_q6(1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 400 +-- Ensure we see just the xy_1 row. +execute ab_q6(100) +-- +STMT: ExecuteStmt +== 401 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 402 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 403 +deallocate ab_q1 +-- +STMT: DeallocateStmt +== 404 +deallocate ab_q2 +-- +STMT: DeallocateStmt +== 405 +deallocate ab_q3 +-- +STMT: DeallocateStmt +== 406 +deallocate ab_q4 +-- +STMT: DeallocateStmt +== 407 +deallocate ab_q5 +-- +STMT: DeallocateStmt +== 408 +deallocate ab_q6 +-- +STMT: DeallocateStmt +== 409 +-- UPDATE on a partition subtree has been seen to have problems. +insert into ab values (1,2) +-- +TABLE: name="ab" schema="" table="ab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 410 +explain (analyze, costs off, summary off, timing off) +update ab_a1 set b = 3 from ab where ab.a = 1 and ab.a = ab_a1.a +-- +TABLE: name="ab_a1" schema="" table="ab_a1" ctx=DML +TABLE: name="ab" schema="" table="ab" ctx=Select +STMT: ExplainStmt +STMT: UpdateStmt +== 411 +table ab +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +STMT: SelectStmt +== 412 +-- Test UPDATE where source relation has run-time pruning enabled +truncate ab +-- +TABLE: name="ab" schema="" table="ab" ctx=DDL +STMT: TruncateStmt +== 413 +insert into ab values (1, 1), (1, 2), (1, 3), (2, 1) +-- +TABLE: name="ab" schema="" table="ab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 414 +explain (analyze, costs off, summary off, timing off) +update ab_a1 set b = 3 from ab_a2 where ab_a2.b = (select 1) +-- +TABLE: name="ab_a1" schema="" table="ab_a1" ctx=DML +TABLE: name="ab_a2" schema="" table="ab_a2" ctx=Select +STMT: ExplainStmt +STMT: UpdateStmt +STMT: SelectStmt +== 415 +select tableoid::regclass, * from ab +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +STMT: SelectStmt +== 416 +drop table ab, lprt_a +-- +TABLE: name="ab" schema="" table="ab" ctx=DDL +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DDL +STMT: DropStmt +== 417 +-- Join +create table tbl1(col1 int) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DDL +STMT: CreateStmt +== 418 +insert into tbl1 values (501), (505) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 419 +-- Basic table +create table tprt (col1 int) partition by range (col1) +-- +TABLE: name="tprt" schema="" table="tprt" ctx=DDL +STMT: CreateStmt +== 420 +create table tprt_1 partition of tprt for values from (1) to (501) +-- +TABLE: name="tprt_1" schema="" table="tprt_1" ctx=DDL +STMT: CreateStmt +== 421 +create table tprt_2 partition of tprt for values from (501) to (1001) +-- +TABLE: name="tprt_2" schema="" table="tprt_2" ctx=DDL +STMT: CreateStmt +== 422 +create table tprt_3 partition of tprt for values from (1001) to (2001) +-- +TABLE: name="tprt_3" schema="" table="tprt_3" ctx=DDL +STMT: CreateStmt +== 423 +create table tprt_4 partition of tprt for values from (2001) to (3001) +-- +TABLE: name="tprt_4" schema="" table="tprt_4" ctx=DDL +STMT: CreateStmt +== 424 +create table tprt_5 partition of tprt for values from (3001) to (4001) +-- +TABLE: name="tprt_5" schema="" table="tprt_5" ctx=DDL +STMT: CreateStmt +== 425 +create table tprt_6 partition of tprt for values from (4001) to (5001) +-- +TABLE: name="tprt_6" schema="" table="tprt_6" ctx=DDL +STMT: CreateStmt +== 426 +create index tprt1_idx on tprt_1 (col1) +-- +TABLE: name="tprt_1" schema="" table="tprt_1" ctx=DDL +STMT: IndexStmt +== 427 +create index tprt2_idx on tprt_2 (col1) +-- +TABLE: name="tprt_2" schema="" table="tprt_2" ctx=DDL +STMT: IndexStmt +== 428 +create index tprt3_idx on tprt_3 (col1) +-- +TABLE: name="tprt_3" schema="" table="tprt_3" ctx=DDL +STMT: IndexStmt +== 429 +create index tprt4_idx on tprt_4 (col1) +-- +TABLE: name="tprt_4" schema="" table="tprt_4" ctx=DDL +STMT: IndexStmt +== 430 +create index tprt5_idx on tprt_5 (col1) +-- +TABLE: name="tprt_5" schema="" table="tprt_5" ctx=DDL +STMT: IndexStmt +== 431 +create index tprt6_idx on tprt_6 (col1) +-- +TABLE: name="tprt_6" schema="" table="tprt_6" ctx=DDL +STMT: IndexStmt +== 432 +insert into tprt values (10), (20), (501), (502), (505), (1001), (4500) +-- +TABLE: name="tprt" schema="" table="tprt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 433 +set enable_hashjoin = off +-- +STMT: VariableSetStmt +== 434 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +== 435 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 join tprt on tbl1.col1 > tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 436 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 join tprt on tbl1.col1 = tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 437 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 > tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +== 438 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 = tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +== 439 +-- Multiple partitions +insert into tbl1 values (1001), (1010), (1011) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 440 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 inner join tprt on tbl1.col1 > tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 441 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 inner join tprt on tbl1.col1 = tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 442 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 > tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +== 443 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 = tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +== 444 +-- Last partition +delete from tbl1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: DeleteStmt +== 445 +insert into tbl1 values (4400) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 446 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 join tprt on tbl1.col1 < tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 447 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 < tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +== 448 +-- No matching partition +delete from tbl1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: DeleteStmt +== 449 +insert into tbl1 values (10000) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 450 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 join tprt on tbl1.col1 = tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 451 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 = tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +== 452 +drop table tbl1, tprt +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DDL +TABLE: name="tprt" schema="" table="tprt" ctx=DDL +STMT: DropStmt +== 453 +-- Test with columns defined in varying orders between each level +create table part_abc (a int not null, b int not null, c int not null) partition by list (a) +-- +TABLE: name="part_abc" schema="" table="part_abc" ctx=DDL +STMT: CreateStmt +== 454 +create table part_bac (b int not null, a int not null, c int not null) partition by list (b) +-- +TABLE: name="part_bac" schema="" table="part_bac" ctx=DDL +STMT: CreateStmt +== 455 +create table part_cab (c int not null, a int not null, b int not null) partition by list (c) +-- +TABLE: name="part_cab" schema="" table="part_cab" ctx=DDL +STMT: CreateStmt +== 456 +create table part_abc_p1 (a int not null, b int not null, c int not null) +-- +TABLE: name="part_abc_p1" schema="" table="part_abc_p1" ctx=DDL +STMT: CreateStmt +== 457 +alter table part_abc attach partition part_bac for values in(1) +-- +TABLE: name="part_abc" schema="" table="part_abc" ctx=DDL +STMT: AlterTableStmt +== 458 +alter table part_bac attach partition part_cab for values in(2) +-- +TABLE: name="part_bac" schema="" table="part_bac" ctx=DDL +STMT: AlterTableStmt +== 459 +alter table part_cab attach partition part_abc_p1 for values in(3) +-- +TABLE: name="part_cab" schema="" table="part_cab" ctx=DDL +STMT: AlterTableStmt +== 460 +prepare part_abc_q1 (int, int, int) as +select * from part_abc where a = $1 and b = $2 and c = $3 +-- +TABLE: name="part_abc" schema="" table="part_abc" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: PrepareStmt +STMT: SelectStmt +== 461 +-- Single partition should be scanned. +explain (analyze, costs off, summary off, timing off) execute part_abc_q1 (1, 2, 3) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 462 +deallocate part_abc_q1 +-- +STMT: DeallocateStmt +== 463 +drop table part_abc +-- +TABLE: name="part_abc" schema="" table="part_abc" ctx=DDL +STMT: DropStmt +== 464 +-- Ensure that an Append node properly handles a sub-partitioned table +-- matching without any of its leaf partitions matching the clause. +create table listp (a int, b int) partition by list (a) +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: CreateStmt +== 465 +create table listp_1 partition of listp for values in(1) partition by list (b) +-- +TABLE: name="listp_1" schema="" table="listp_1" ctx=DDL +STMT: CreateStmt +== 466 +create table listp_1_1 partition of listp_1 for values in(1) +-- +TABLE: name="listp_1_1" schema="" table="listp_1_1" ctx=DDL +STMT: CreateStmt +== 467 +create table listp_2 partition of listp for values in(2) partition by list (b) +-- +TABLE: name="listp_2" schema="" table="listp_2" ctx=DDL +STMT: CreateStmt +== 468 +create table listp_2_1 partition of listp_2 for values in(2) +-- +TABLE: name="listp_2_1" schema="" table="listp_2_1" ctx=DDL +STMT: CreateStmt +== 469 +select * from listp where b = 1 +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 470 +-- Ensure that an Append node properly can handle selection of all first level +-- partitions before finally detecting the correct set of 2nd level partitions +-- which match the given parameter. +prepare q1 (int,int) as select * from listp where b in ($1,$2) +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 471 +explain (analyze, costs off, summary off, timing off) execute q1 (1,1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 472 +explain (analyze, costs off, summary off, timing off) execute q1 (2,2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 473 +-- Try with no matching partitions. +explain (analyze, costs off, summary off, timing off) execute q1 (0,0) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 474 +deallocate q1 +-- +STMT: DeallocateStmt +== 475 +-- Test more complex cases where a not-equal condition further eliminates partitions. +prepare q1 (int,int,int,int) as select * from listp where b in($1,$2) and $3 <> b and $4 <> b +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 476 +-- Both partitions allowed by IN clause, but one disallowed by <> clause +explain (analyze, costs off, summary off, timing off) execute q1 (1,2,2,0) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 477 +-- Both partitions allowed by IN clause, then both excluded again by <> clauses. +explain (analyze, costs off, summary off, timing off) execute q1 (1,2,2,1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 478 +-- Ensure Params that evaluate to NULL properly prune away all partitions +explain (analyze, costs off, summary off, timing off) +select * from listp where a = (select null::int) +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 479 +drop table listp +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: DropStmt +== 480 +|-- +-- check that stable query clauses are only used in run-time pruning +|-- +create table stable_qual_pruning (a timestamp) partition by range (a) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=DDL +STMT: CreateStmt +== 481 +create table stable_qual_pruning1 partition of stable_qual_pruning + for values from ('2000-01-01') to ('2000-02-01') +-- +TABLE: name="stable_qual_pruning1" schema="" table="stable_qual_pruning1" ctx=DDL +STMT: CreateStmt +== 482 +create table stable_qual_pruning2 partition of stable_qual_pruning + for values from ('2000-02-01') to ('2000-03-01') +-- +TABLE: name="stable_qual_pruning2" schema="" table="stable_qual_pruning2" ctx=DDL +STMT: CreateStmt +== 483 +create table stable_qual_pruning3 partition of stable_qual_pruning + for values from ('3000-02-01') to ('3000-03-01') +-- +TABLE: name="stable_qual_pruning3" schema="" table="stable_qual_pruning3" ctx=DDL +STMT: CreateStmt +== 484 +-- comparison against a stable value requires run-time pruning +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning where a < localtimestamp +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 485 +-- timestamp < timestamptz comparison is only stable, not immutable +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning where a < '2000-02-01'::timestamptz +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 486 +-- check ScalarArrayOp cases +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2010-02-01', '2020-01-01']::timestamp[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 487 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2000-02-01', '2010-01-01']::timestamp[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 488 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2000-02-01', localtimestamp]::timestamp[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 489 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2010-02-01', '2020-01-01']::timestamptz[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 490 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2000-02-01', '2010-01-01']::timestamptz[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 491 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(null::timestamptz[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 492 +drop table stable_qual_pruning +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=DDL +STMT: DropStmt +== 493 +|-- +-- Check that pruning with composite range partitioning works correctly when +-- it must ignore clauses for trailing keys once it has seen a clause with +-- non-inclusive operator for an earlier key +|-- +create table mc3p (a int, b int, c int) partition by range (a, abs(b), c) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=DDL +STMT: CreateStmt +== 494 +create table mc3p0 partition of mc3p + for values from (0, 0, 0) to (0, maxvalue, maxvalue) +-- +TABLE: name="mc3p0" schema="" table="mc3p0" ctx=DDL +STMT: CreateStmt +== 495 +create table mc3p1 partition of mc3p + for values from (1, 1, 1) to (2, minvalue, minvalue) +-- +TABLE: name="mc3p1" schema="" table="mc3p1" ctx=DDL +STMT: CreateStmt +== 496 +create table mc3p2 partition of mc3p + for values from (2, minvalue, minvalue) to (3, maxvalue, maxvalue) +-- +TABLE: name="mc3p2" schema="" table="mc3p2" ctx=DDL +STMT: CreateStmt +== 497 +insert into mc3p values (0, 1, 1), (1, 1, 1), (2, 1, 1) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 498 +explain (analyze, costs off, summary off, timing off) +select * from mc3p where a < 3 and abs(b) = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 499 +|-- +-- Check that pruning with composite range partitioning works correctly when +-- a combination of runtime parameters is specified, not all of whose values +-- are available at the same time +|-- +prepare ps1 as + select * from mc3p where a = $1 and abs(b) < (select 3) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 500 +explain (analyze, costs off, summary off, timing off) +execute ps1(1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 501 +deallocate ps1 +-- +STMT: DeallocateStmt +== 502 +prepare ps2 as + select * from mc3p where a <= $1 and abs(b) < (select 3) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 503 +explain (analyze, costs off, summary off, timing off) +execute ps2(1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 504 +deallocate ps2 +-- +STMT: DeallocateStmt +== 505 +drop table mc3p +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=DDL +STMT: DropStmt +== 506 +-- Ensure runtime pruning works with initplans params with boolean types +create table boolvalues (value bool not null) +-- +TABLE: name="boolvalues" schema="" table="boolvalues" ctx=DDL +STMT: CreateStmt +== 507 +insert into boolvalues values('t'),('f') +-- +TABLE: name="boolvalues" schema="" table="boolvalues" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 508 +create table boolp (a bool) partition by list (a) +-- +TABLE: name="boolp" schema="" table="boolp" ctx=DDL +STMT: CreateStmt +== 509 +create table boolp_t partition of boolp for values in('t') +-- +TABLE: name="boolp_t" schema="" table="boolp_t" ctx=DDL +STMT: CreateStmt +== 510 +create table boolp_f partition of boolp for values in('f') +-- +TABLE: name="boolp_f" schema="" table="boolp_f" ctx=DDL +STMT: CreateStmt +== 511 +explain (analyze, costs off, summary off, timing off) +select * from boolp where a = (select value from boolvalues where value) +-- +TABLE: name="boolp" schema="" table="boolp" ctx=Select +TABLE: name="boolvalues" schema="" table="boolvalues" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="value" +STMT: ExplainStmt +STMT: SelectStmt +== 512 +explain (analyze, costs off, summary off, timing off) +select * from boolp where a = (select value from boolvalues where not value) +-- +TABLE: name="boolp" schema="" table="boolp" ctx=Select +TABLE: name="boolvalues" schema="" table="boolvalues" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="value" +STMT: ExplainStmt +STMT: SelectStmt +== 513 +drop table boolp +-- +TABLE: name="boolp" schema="" table="boolp" ctx=DDL +STMT: DropStmt +== 514 +|-- +-- Test run-time pruning of MergeAppend subnodes +|-- +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 515 +set enable_sort = off +-- +STMT: VariableSetStmt +== 516 +create table ma_test (a int, b int) partition by range (a) +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DDL +STMT: CreateStmt +== 517 +create table ma_test_p1 partition of ma_test for values from (0) to (10) +-- +TABLE: name="ma_test_p1" schema="" table="ma_test_p1" ctx=DDL +STMT: CreateStmt +== 518 +create table ma_test_p2 partition of ma_test for values from (10) to (20) +-- +TABLE: name="ma_test_p2" schema="" table="ma_test_p2" ctx=DDL +STMT: CreateStmt +== 519 +create table ma_test_p3 partition of ma_test for values from (20) to (30) +-- +TABLE: name="ma_test_p3" schema="" table="ma_test_p3" ctx=DDL +STMT: CreateStmt +== 520 +insert into ma_test select x,x from generate_series(0,29) t(x) +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 521 +create index on ma_test (b) +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DDL +STMT: IndexStmt +== 522 +analyze ma_test +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DDL +STMT: VacuumStmt +== 523 +prepare mt_q1 (int) as select a from ma_test where a >= $1 and a % 10 = 5 order by b +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +== 524 +explain (analyze, costs off, summary off, timing off) execute mt_q1(15) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 525 +execute mt_q1(15) +-- +STMT: ExecuteStmt +== 526 +explain (analyze, costs off, summary off, timing off) execute mt_q1(25) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 527 +execute mt_q1(25) +-- +STMT: ExecuteStmt +== 528 +-- Ensure MergeAppend behaves correctly when no subplans match +explain (analyze, costs off, summary off, timing off) execute mt_q1(35) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 529 +execute mt_q1(35) +-- +STMT: ExecuteStmt +== 530 +deallocate mt_q1 +-- +STMT: DeallocateStmt +== 531 +prepare mt_q2 (int) as select * from ma_test where a >= $1 order by b limit 1 +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +== 532 +-- Ensure output list looks sane when the MergeAppend has no subplans. +explain (analyze, verbose, costs off, summary off, timing off) execute mt_q2 (35) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 533 +deallocate mt_q2 +-- +STMT: DeallocateStmt +== 534 +-- ensure initplan params properly prune partitions +explain (analyze, costs off, summary off, timing off) select * from ma_test where a >= (select min(b) from ma_test_p2) order by b +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=Select +TABLE: name="ma_test_p2" schema="" table="ma_test_p2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 535 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 536 +reset enable_sort +-- +STMT: VariableSetStmt +== 537 +drop table ma_test +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DDL +STMT: DropStmt +== 538 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +== 539 +|-- +-- check that pruning works properly when the partition key is of a +-- pseudotype +|-- + +-- array type list partition key +create table pp_arrpart (a int[]) partition by list (a) +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=DDL +STMT: CreateStmt +== 540 +create table pp_arrpart1 partition of pp_arrpart for values in ('{1}') +-- +TABLE: name="pp_arrpart1" schema="" table="pp_arrpart1" ctx=DDL +STMT: CreateStmt +== 541 +create table pp_arrpart2 partition of pp_arrpart for values in ('{2, 3}', '{4, 5}') +-- +TABLE: name="pp_arrpart2" schema="" table="pp_arrpart2" ctx=DDL +STMT: CreateStmt +== 542 +explain (costs off) select * from pp_arrpart where a = '{1}' +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 543 +explain (costs off) select * from pp_arrpart where a = '{1, 2}' +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 544 +explain (costs off) select * from pp_arrpart where a in ('{4, 5}', '{1}') +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 545 +explain (costs off) update pp_arrpart set a = a where a = '{1}' +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 546 +explain (costs off) delete from pp_arrpart where a = '{1}' +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 547 +drop table pp_arrpart +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=DDL +STMT: DropStmt +== 548 +-- array type hash partition key +create table pph_arrpart (a int[]) partition by hash (a) +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=DDL +STMT: CreateStmt +== 549 +create table pph_arrpart1 partition of pph_arrpart for values with (modulus 2, remainder 0) +-- +TABLE: name="pph_arrpart1" schema="" table="pph_arrpart1" ctx=DDL +STMT: CreateStmt +== 550 +create table pph_arrpart2 partition of pph_arrpart for values with (modulus 2, remainder 1) +-- +TABLE: name="pph_arrpart2" schema="" table="pph_arrpart2" ctx=DDL +STMT: CreateStmt +== 551 +insert into pph_arrpart values ('{1}'), ('{1, 2}'), ('{4, 5}') +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 552 +select tableoid::regclass, * from pph_arrpart order by 1 +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=Select +STMT: SelectStmt +== 553 +explain (costs off) select * from pph_arrpart where a = '{1}' +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 554 +explain (costs off) select * from pph_arrpart where a = '{1, 2}' +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 555 +explain (costs off) select * from pph_arrpart where a in ('{4, 5}', '{1}') +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 556 +drop table pph_arrpart +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=DDL +STMT: DropStmt +== 557 +-- enum type list partition key +create type pp_colors as enum ('green', 'blue', 'black') +-- +STMT: CreateEnumStmt +== 558 +create table pp_enumpart (a pp_colors) partition by list (a) +-- +TABLE: name="pp_enumpart" schema="" table="pp_enumpart" ctx=DDL +STMT: CreateStmt +== 559 +create table pp_enumpart_green partition of pp_enumpart for values in ('green') +-- +TABLE: name="pp_enumpart_green" schema="" table="pp_enumpart_green" ctx=DDL +STMT: CreateStmt +== 560 +create table pp_enumpart_blue partition of pp_enumpart for values in ('blue') +-- +TABLE: name="pp_enumpart_blue" schema="" table="pp_enumpart_blue" ctx=DDL +STMT: CreateStmt +== 561 +explain (costs off) select * from pp_enumpart where a = 'blue' +-- +TABLE: name="pp_enumpart" schema="" table="pp_enumpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 562 +explain (costs off) select * from pp_enumpart where a = 'black' +-- +TABLE: name="pp_enumpart" schema="" table="pp_enumpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 563 +drop table pp_enumpart +-- +TABLE: name="pp_enumpart" schema="" table="pp_enumpart" ctx=DDL +STMT: DropStmt +== 564 +drop type pp_colors +-- +STMT: DropStmt +== 565 +-- record type as partition key +create type pp_rectype as (a int, b int) +-- +STMT: CompositeTypeStmt +== 566 +create table pp_recpart (a pp_rectype) partition by list (a) +-- +TABLE: name="pp_recpart" schema="" table="pp_recpart" ctx=DDL +STMT: CreateStmt +== 567 +create table pp_recpart_11 partition of pp_recpart for values in ('(1,1)') +-- +TABLE: name="pp_recpart_11" schema="" table="pp_recpart_11" ctx=DDL +STMT: CreateStmt +== 568 +create table pp_recpart_23 partition of pp_recpart for values in ('(2,3)') +-- +TABLE: name="pp_recpart_23" schema="" table="pp_recpart_23" ctx=DDL +STMT: CreateStmt +== 569 +explain (costs off) select * from pp_recpart where a = '(1,1)'::pp_rectype +-- +TABLE: name="pp_recpart" schema="" table="pp_recpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 570 +explain (costs off) select * from pp_recpart where a = '(1,2)'::pp_rectype +-- +TABLE: name="pp_recpart" schema="" table="pp_recpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 571 +drop table pp_recpart +-- +TABLE: name="pp_recpart" schema="" table="pp_recpart" ctx=DDL +STMT: DropStmt +== 572 +drop type pp_rectype +-- +STMT: DropStmt +== 573 +-- range type partition key +create table pp_intrangepart (a int4range) partition by list (a) +-- +TABLE: name="pp_intrangepart" schema="" table="pp_intrangepart" ctx=DDL +STMT: CreateStmt +== 574 +create table pp_intrangepart12 partition of pp_intrangepart for values in ('[1,2]') +-- +TABLE: name="pp_intrangepart12" schema="" table="pp_intrangepart12" ctx=DDL +STMT: CreateStmt +== 575 +create table pp_intrangepart2inf partition of pp_intrangepart for values in ('[2,)') +-- +TABLE: name="pp_intrangepart2inf" schema="" table="pp_intrangepart2inf" ctx=DDL +STMT: CreateStmt +== 576 +explain (costs off) select * from pp_intrangepart where a = '[1,2]'::int4range +-- +TABLE: name="pp_intrangepart" schema="" table="pp_intrangepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 577 +explain (costs off) select * from pp_intrangepart where a = '(1,2)'::int4range +-- +TABLE: name="pp_intrangepart" schema="" table="pp_intrangepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 578 +drop table pp_intrangepart +-- +TABLE: name="pp_intrangepart" schema="" table="pp_intrangepart" ctx=DDL +STMT: DropStmt +== 579 +|-- +-- Ensure the enable_partition_prune GUC properly disables partition pruning. +|-- + +create table pp_lp (a int, value int) partition by list (a) +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DDL +STMT: CreateStmt +== 580 +create table pp_lp1 partition of pp_lp for values in(1) +-- +TABLE: name="pp_lp1" schema="" table="pp_lp1" ctx=DDL +STMT: CreateStmt +== 581 +create table pp_lp2 partition of pp_lp for values in(2) +-- +TABLE: name="pp_lp2" schema="" table="pp_lp2" ctx=DDL +STMT: CreateStmt +== 582 +explain (costs off) select * from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 583 +explain (costs off) update pp_lp set value = 10 where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 584 +explain (costs off) delete from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 585 +set enable_partition_pruning = off +-- +STMT: VariableSetStmt +== 586 +set constraint_exclusion = 'partition' +-- +STMT: VariableSetStmt +== 587 +-- this should not affect the result. + +explain (costs off) select * from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 588 +explain (costs off) update pp_lp set value = 10 where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 589 +explain (costs off) delete from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 590 +set constraint_exclusion = 'off' +-- +STMT: VariableSetStmt +== 591 +-- this should not affect the result. + +explain (costs off) select * from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 592 +explain (costs off) update pp_lp set value = 10 where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 593 +explain (costs off) delete from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 594 +drop table pp_lp +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DDL +STMT: DropStmt +== 595 +-- Ensure enable_partition_prune does not affect non-partitioned tables. + +create table inh_lp (a int, value int) +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=DDL +STMT: CreateStmt +== 596 +create table inh_lp1 (a int, value int, check(a = 1)) inherits (inh_lp) +-- +TABLE: name="inh_lp1" schema="" table="inh_lp1" ctx=DDL +STMT: CreateStmt +== 597 +create table inh_lp2 (a int, value int, check(a = 2)) inherits (inh_lp) +-- +TABLE: name="inh_lp2" schema="" table="inh_lp2" ctx=DDL +STMT: CreateStmt +== 598 +set constraint_exclusion = 'partition' +-- +STMT: VariableSetStmt +== 599 +-- inh_lp2 should be removed in the following 3 cases. +explain (costs off) select * from inh_lp where a = 1 +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 600 +explain (costs off) update inh_lp set value = 10 where a = 1 +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 601 +explain (costs off) delete from inh_lp where a = 1 +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 602 +-- Ensure we don't exclude normal relations when we only expect to exclude +-- inheritance children +explain (costs off) update inh_lp1 set value = 10 where a = 2 +-- +TABLE: name="inh_lp1" schema="" table="inh_lp1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 603 +drop table inh_lp cascade +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=DDL +STMT: DropStmt +== 604 +reset enable_partition_pruning +-- +STMT: VariableSetStmt +== 605 +reset constraint_exclusion +-- +STMT: VariableSetStmt +== 606 +-- Check pruning for a partition tree containing only temporary relations +create temp table pp_temp_parent (a int) partition by list (a) +-- +TABLE: name="pp_temp_parent" schema="" table="pp_temp_parent" ctx=DDL +STMT: CreateStmt +== 607 +create temp table pp_temp_part_1 partition of pp_temp_parent for values in (1) +-- +TABLE: name="pp_temp_part_1" schema="" table="pp_temp_part_1" ctx=DDL +STMT: CreateStmt +== 608 +create temp table pp_temp_part_def partition of pp_temp_parent default +-- +TABLE: name="pp_temp_part_def" schema="" table="pp_temp_part_def" ctx=DDL +STMT: CreateStmt +== 609 +explain (costs off) select * from pp_temp_parent where true +-- +TABLE: name="pp_temp_parent" schema="" table="pp_temp_parent" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 610 +explain (costs off) select * from pp_temp_parent where a = 2 +-- +TABLE: name="pp_temp_parent" schema="" table="pp_temp_parent" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 611 +drop table pp_temp_parent +-- +TABLE: name="pp_temp_parent" schema="" table="pp_temp_parent" ctx=DDL +STMT: DropStmt +== 612 +-- Stress run-time partition pruning a bit more, per bug reports +create temp table p (a int, b int, c int) partition by list (a) +-- +TABLE: name="p" schema="" table="p" ctx=DDL +STMT: CreateStmt +== 613 +create temp table p1 partition of p for values in (1) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +== 614 +create temp table p2 partition of p for values in (2) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +== 615 +create temp table q (a int, b int, c int) partition by list (a) +-- +TABLE: name="q" schema="" table="q" ctx=DDL +STMT: CreateStmt +== 616 +create temp table q1 partition of q for values in (1) partition by list (b) +-- +TABLE: name="q1" schema="" table="q1" ctx=DDL +STMT: CreateStmt +== 617 +create temp table q11 partition of q1 for values in (1) partition by list (c) +-- +TABLE: name="q11" schema="" table="q11" ctx=DDL +STMT: CreateStmt +== 618 +create temp table q111 partition of q11 for values in (1) +-- +TABLE: name="q111" schema="" table="q111" ctx=DDL +STMT: CreateStmt +== 619 +create temp table q2 partition of q for values in (2) partition by list (b) +-- +TABLE: name="q2" schema="" table="q2" ctx=DDL +STMT: CreateStmt +== 620 +create temp table q21 partition of q2 for values in (1) +-- +TABLE: name="q21" schema="" table="q21" ctx=DDL +STMT: CreateStmt +== 621 +create temp table q22 partition of q2 for values in (2) +-- +TABLE: name="q22" schema="" table="q22" ctx=DDL +STMT: CreateStmt +== 622 +insert into q22 values (2, 2, 3) +-- +TABLE: name="q22" schema="" table="q22" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 623 +explain (costs off) +select * +from ( + select * from p + union all + select * from q1 + union all + select 1, 1, 1 + ) s(a, b, c) +where s.a = 1 and s.b = 1 and s.c = (select 1) +-- +TABLE: name="p" schema="" table="p" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="b" +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 624 +select * +from ( + select * from p + union all + select * from q1 + union all + select 1, 1, 1 + ) s(a, b, c) +where s.a = 1 and s.b = 1 and s.c = (select 1) +-- +TABLE: name="p" schema="" table="p" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="b" +FILTER: schema="" table="s" column="c" +STMT: SelectStmt +== 625 +prepare q (int, int) as +select * +from ( + select * from p + union all + select * from q1 + union all + select 1, 1, 1 + ) s(a, b, c) +where s.a = $1 and s.b = $2 and s.c = (select 1) +-- +TABLE: name="p" schema="" table="p" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="b" +FILTER: schema="" table="s" column="c" +STMT: PrepareStmt +STMT: SelectStmt +== 626 +explain (costs off) execute q (1, 1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 627 +execute q (1, 1) +-- +STMT: ExecuteStmt +== 628 +drop table p, q +-- +TABLE: name="p" schema="" table="p" ctx=DDL +TABLE: name="q" schema="" table="q" ctx=DDL +STMT: DropStmt +== 629 +-- Ensure run-time pruning works correctly when we match a partitioned table +-- on the first level but find no matching partitions on the second level. +create table listp (a int, b int) partition by list (a) +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: CreateStmt +== 630 +create table listp1 partition of listp for values in(1) +-- +TABLE: name="listp1" schema="" table="listp1" ctx=DDL +STMT: CreateStmt +== 631 +create table listp2 partition of listp for values in(2) partition by list(b) +-- +TABLE: name="listp2" schema="" table="listp2" ctx=DDL +STMT: CreateStmt +== 632 +create table listp2_10 partition of listp2 for values in (10) +-- +TABLE: name="listp2_10" schema="" table="listp2_10" ctx=DDL +STMT: CreateStmt +== 633 +explain (analyze, costs off, summary off, timing off) +select * from listp where a = (select 2) and b <> 10 +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 634 +|-- +-- check that a partition directly accessed in a query is excluded with +-- constraint_exclusion = on +|-- + +-- turn off partition pruning, so that it doesn't interfere +set enable_partition_pruning to off +-- +STMT: VariableSetStmt +== 635 +-- setting constraint_exclusion to 'partition' disables exclusion +set constraint_exclusion to 'partition' +-- +STMT: VariableSetStmt +== 636 +explain (costs off) select * from listp1 where a = 2 +-- +TABLE: name="listp1" schema="" table="listp1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 637 +explain (costs off) update listp1 set a = 1 where a = 2 +-- +TABLE: name="listp1" schema="" table="listp1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 638 +-- constraint exclusion enabled +set constraint_exclusion to 'on' +-- +STMT: VariableSetStmt +== 639 +explain (costs off) select * from listp1 where a = 2 +-- +TABLE: name="listp1" schema="" table="listp1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 640 +explain (costs off) update listp1 set a = 1 where a = 2 +-- +TABLE: name="listp1" schema="" table="listp1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 641 +reset constraint_exclusion +-- +STMT: VariableSetStmt +== 642 +reset enable_partition_pruning +-- +STMT: VariableSetStmt +== 643 +drop table listp +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: DropStmt +== 644 +-- Ensure run-time pruning works correctly for nested Append nodes +set parallel_setup_cost to 0 +-- +STMT: VariableSetStmt +== 645 +set parallel_tuple_cost to 0 +-- +STMT: VariableSetStmt +== 646 +create table listp (a int) partition by list(a) +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: CreateStmt +== 647 +create table listp_12 partition of listp for values in(1,2) partition by list(a) +-- +TABLE: name="listp_12" schema="" table="listp_12" ctx=DDL +STMT: CreateStmt +== 648 +create table listp_12_1 partition of listp_12 for values in(1) +-- +TABLE: name="listp_12_1" schema="" table="listp_12_1" ctx=DDL +STMT: CreateStmt +== 649 +create table listp_12_2 partition of listp_12 for values in(2) +-- +TABLE: name="listp_12_2" schema="" table="listp_12_2" ctx=DDL +STMT: CreateStmt +== 650 +-- Force the 2nd subnode of the Append to be non-parallel. This results in +-- a nested Append node because the mixed parallel / non-parallel paths cannot +-- be pulled into the top-level Append. +alter table listp_12_1 set (parallel_workers = 0) +-- +TABLE: name="listp_12_1" schema="" table="listp_12_1" ctx=DDL +STMT: AlterTableStmt +== 651 +-- Ensure that listp_12_2 is not scanned. (The nested Append is not seen in +-- the plan as it's pulled in setref.c due to having just a single subnode). +select explain_parallel_append('select * from listp where a = (select 1);') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 652 +-- Like the above but throw some more complexity at the planner by adding +-- a UNION ALL. We expect both sides of the union not to scan the +-- non-required partitions. +select explain_parallel_append( +'select * from listp where a = (select 1) + union all +select * from listp where a = (select 2);') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +== 653 +drop table listp +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: DropStmt +== 654 +reset parallel_tuple_cost +-- +STMT: VariableSetStmt +== 655 +reset parallel_setup_cost +-- +STMT: VariableSetStmt +== 656 +-- Test case for run-time pruning with a nested Merge Append +set enable_sort to 0 +-- +STMT: VariableSetStmt +== 657 +create table rangep (a int, b int) partition by range (a) +-- +TABLE: name="rangep" schema="" table="rangep" ctx=DDL +STMT: CreateStmt +== 658 +create table rangep_0_to_100 partition of rangep for values from (0) to (100) partition by list (b) +-- +TABLE: name="rangep_0_to_100" schema="" table="rangep_0_to_100" ctx=DDL +STMT: CreateStmt +== 659 +-- We need 3 sub-partitions. 1 to validate pruning worked and another two +-- because a single remaining partition would be pulled up to the main Append. +create table rangep_0_to_100_1 partition of rangep_0_to_100 for values in(1) +-- +TABLE: name="rangep_0_to_100_1" schema="" table="rangep_0_to_100_1" ctx=DDL +STMT: CreateStmt +== 660 +create table rangep_0_to_100_2 partition of rangep_0_to_100 for values in(2) +-- +TABLE: name="rangep_0_to_100_2" schema="" table="rangep_0_to_100_2" ctx=DDL +STMT: CreateStmt +== 661 +create table rangep_0_to_100_3 partition of rangep_0_to_100 for values in(3) +-- +TABLE: name="rangep_0_to_100_3" schema="" table="rangep_0_to_100_3" ctx=DDL +STMT: CreateStmt +== 662 +create table rangep_100_to_200 partition of rangep for values from (100) to (200) +-- +TABLE: name="rangep_100_to_200" schema="" table="rangep_100_to_200" ctx=DDL +STMT: CreateStmt +== 663 +create index on rangep (a) +-- +TABLE: name="rangep" schema="" table="rangep" ctx=DDL +STMT: IndexStmt +== 664 +-- Ensure run-time pruning works on the nested Merge Append +explain (analyze on, costs off, timing off, summary off) +select * from rangep where b IN((select 1),(select 2)) order by a +-- +TABLE: name="rangep" schema="" table="rangep" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 665 +reset enable_sort +-- +STMT: VariableSetStmt +== 666 +drop table rangep +-- +TABLE: name="rangep" schema="" table="rangep" ctx=DDL +STMT: DropStmt +== 667 +|-- +-- Check that gen_prune_steps_from_opexps() works well for various cases of +-- clauses for different partition keys +|-- + +create table rp_prefix_test1 (a int, b varchar) partition by range(a, b) +-- +TABLE: name="rp_prefix_test1" schema="" table="rp_prefix_test1" ctx=DDL +STMT: CreateStmt +== 668 +create table rp_prefix_test1_p1 partition of rp_prefix_test1 for values from (1, 'a') to (1, 'b') +-- +TABLE: name="rp_prefix_test1_p1" schema="" table="rp_prefix_test1_p1" ctx=DDL +STMT: CreateStmt +== 669 +create table rp_prefix_test1_p2 partition of rp_prefix_test1 for values from (2, 'a') to (2, 'b') +-- +TABLE: name="rp_prefix_test1_p2" schema="" table="rp_prefix_test1_p2" ctx=DDL +STMT: CreateStmt +== 670 +-- Don't call get_steps_using_prefix() with the last partition key b plus +-- an empty prefix +explain (costs off) select * from rp_prefix_test1 where a <= 1 and b = 'a' +-- +TABLE: name="rp_prefix_test1" schema="" table="rp_prefix_test1" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 671 +create table rp_prefix_test2 (a int, b int, c int) partition by range(a, b, c) +-- +TABLE: name="rp_prefix_test2" schema="" table="rp_prefix_test2" ctx=DDL +STMT: CreateStmt +== 672 +create table rp_prefix_test2_p1 partition of rp_prefix_test2 for values from (1, 1, 0) to (1, 1, 10) +-- +TABLE: name="rp_prefix_test2_p1" schema="" table="rp_prefix_test2_p1" ctx=DDL +STMT: CreateStmt +== 673 +create table rp_prefix_test2_p2 partition of rp_prefix_test2 for values from (2, 2, 0) to (2, 2, 10) +-- +TABLE: name="rp_prefix_test2_p2" schema="" table="rp_prefix_test2_p2" ctx=DDL +STMT: CreateStmt +== 674 +-- Don't call get_steps_using_prefix() with the last partition key c plus +-- an invalid prefix (ie, b = 1) +explain (costs off) select * from rp_prefix_test2 where a <= 1 and b = 1 and c >= 0 +-- +TABLE: name="rp_prefix_test2" schema="" table="rp_prefix_test2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 675 +create table rp_prefix_test3 (a int, b int, c int, d int) partition by range(a, b, c, d) +-- +TABLE: name="rp_prefix_test3" schema="" table="rp_prefix_test3" ctx=DDL +STMT: CreateStmt +== 676 +create table rp_prefix_test3_p1 partition of rp_prefix_test3 for values from (1, 1, 1, 0) to (1, 1, 1, 10) +-- +TABLE: name="rp_prefix_test3_p1" schema="" table="rp_prefix_test3_p1" ctx=DDL +STMT: CreateStmt +== 677 +create table rp_prefix_test3_p2 partition of rp_prefix_test3 for values from (2, 2, 2, 0) to (2, 2, 2, 10) +-- +TABLE: name="rp_prefix_test3_p2" schema="" table="rp_prefix_test3_p2" ctx=DDL +STMT: CreateStmt +== 678 +-- Test that get_steps_using_prefix() handles a prefix that contains multiple +-- clauses for the partition key b (ie, b >= 1 and b >= 2) +explain (costs off) select * from rp_prefix_test3 where a >= 1 and b >= 1 and b >= 2 and c >= 2 and d >= 0 +-- +TABLE: name="rp_prefix_test3" schema="" table="rp_prefix_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +== 679 +-- Test that get_steps_using_prefix() handles a prefix that contains multiple +-- clauses for the partition key b (ie, b >= 1 and b = 2) (This also tests +-- that the caller arranges clauses in that prefix in the required order) +explain (costs off) select * from rp_prefix_test3 where a >= 1 and b >= 1 and b = 2 and c = 2 and d >= 0 +-- +TABLE: name="rp_prefix_test3" schema="" table="rp_prefix_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +== 680 +drop table rp_prefix_test1 +-- +TABLE: name="rp_prefix_test1" schema="" table="rp_prefix_test1" ctx=DDL +STMT: DropStmt +== 681 +drop table rp_prefix_test2 +-- +TABLE: name="rp_prefix_test2" schema="" table="rp_prefix_test2" ctx=DDL +STMT: DropStmt +== 682 +drop table rp_prefix_test3 +-- +TABLE: name="rp_prefix_test3" schema="" table="rp_prefix_test3" ctx=DDL +STMT: DropStmt +== 683 +|-- +-- Test that get_steps_using_prefix() handles IS NULL clauses correctly +|-- +create table hp_prefix_test (a int, b int, c int, d int) + partition by hash (a part_test_int4_ops, b part_test_int4_ops, c part_test_int4_ops, d part_test_int4_ops) +-- +TABLE: name="hp_prefix_test" schema="" table="hp_prefix_test" ctx=DDL +STMT: CreateStmt +== 684 +-- create 8 partitions +select 'create table hp_prefix_test_p' || x::text || ' partition of hp_prefix_test for values with (modulus 8, remainder ' || x::text || ');' +from generate_Series(0,7) x +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 685 +-- insert 16 rows, one row for each test to perform. +insert into hp_prefix_test +select + case a when 0 then null else 1 end, + case b when 0 then null else 2 end, + case c when 0 then null else 3 end, + case d when 0 then null else 4 end +from + generate_series(0,1) a, + generate_series(0,1) b, + generate_Series(0,1) c, + generate_Series(0,1) d +-- +TABLE: name="hp_prefix_test" schema="" table="hp_prefix_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 686 +-- Ensure partition pruning works correctly for each combination of IS NULL +-- and equality quals. This may seem a little excessive, but there have been +-- a number of bugs in this area over the years. We make use of row only +-- output to reduce the size of the expected results. +select + 'explain (costs off) select tableoid::regclass,* from hp_prefix_test where ' || + string_agg(c.colname || case when g.s & (1 << c.colpos) = 0 then ' is null' else ' = ' || (colpos+1)::text end, ' and ' order by c.colpos) +from (values('a',0),('b',1),('c',2),('d',3)) c(colname, colpos), generate_Series(0,15) g(s) +group by g.s +order by g.s +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 687 +-- And ensure we get exactly 1 row from each. Again, all 16 possible combinations. +select + 'select tableoid::regclass,* from hp_prefix_test where ' || + string_agg(c.colname || case when g.s & (1 << c.colpos) = 0 then ' is null' else ' = ' || (colpos+1)::text end, ' and ' order by c.colpos) +from (values('a',0),('b',1),('c',2),('d',3)) c(colname, colpos), generate_Series(0,15) g(s) +group by g.s +order by g.s +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 688 +drop table hp_prefix_test +-- +TABLE: name="hp_prefix_test" schema="" table="hp_prefix_test" ctx=DDL +STMT: DropStmt +== 689 +|-- +-- Check that gen_partprune_steps() detects self-contradiction from clauses +-- regardless of the order of the clauses (Here we use a custom operator to +-- prevent the equivclass.c machinery from reordering the clauses) +|-- + +create operator === ( + leftarg = int4, + rightarg = int4, + procedure = int4eq, + commutator = ===, + hashes +) +-- +STMT: DefineStmt +== 690 +create operator class part_test_int4_ops2 +for type int4 +using hash as +operator 1 ===, +function 2 part_hashint4_noop(int4, int8) +-- +STMT: CreateOpClassStmt +== 691 +create table hp_contradict_test (a int, b int) partition by hash (a part_test_int4_ops2, b part_test_int4_ops2) +-- +TABLE: name="hp_contradict_test" schema="" table="hp_contradict_test" ctx=DDL +STMT: CreateStmt +== 692 +create table hp_contradict_test_p1 partition of hp_contradict_test for values with (modulus 2, remainder 0) +-- +TABLE: name="hp_contradict_test_p1" schema="" table="hp_contradict_test_p1" ctx=DDL +STMT: CreateStmt +== 693 +create table hp_contradict_test_p2 partition of hp_contradict_test for values with (modulus 2, remainder 1) +-- +TABLE: name="hp_contradict_test_p2" schema="" table="hp_contradict_test_p2" ctx=DDL +STMT: CreateStmt +== 694 +explain (costs off) select * from hp_contradict_test where a is null and a === 1 and b === 1 +-- +TABLE: name="hp_contradict_test" schema="" table="hp_contradict_test" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 695 +explain (costs off) select * from hp_contradict_test where a === 1 and b === 1 and a is null +-- +TABLE: name="hp_contradict_test" schema="" table="hp_contradict_test" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 696 +drop table hp_contradict_test +-- +TABLE: name="hp_contradict_test" schema="" table="hp_contradict_test" ctx=DDL +STMT: DropStmt +== 697 +drop operator class part_test_int4_ops2 using hash +-- +STMT: DropStmt +== 698 +drop operator ===(int4, int4) +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/password.metadata.json b/parser/testdata/summary/postgres_regress/password.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/password.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/password.test b/parser/testdata/summary/postgres_regress/password.test new file mode 100644 index 0000000..7bd5f9d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/password.test @@ -0,0 +1,274 @@ +== 001 +|-- +-- Tests for password types +|-- + +-- Tests for GUC password_encryption +SET password_encryption = 'novalue' +-- +STMT: VariableSetStmt +== 002 +-- error +SET password_encryption = true +-- +STMT: VariableSetStmt +== 003 +-- error +SET password_encryption = 'md5' +-- +STMT: VariableSetStmt +== 004 +-- ok +SET password_encryption = 'scram-sha-256' +-- +STMT: VariableSetStmt +== 005 +-- ok + +-- consistency of password entries +SET password_encryption = 'md5' +-- +STMT: VariableSetStmt +== 006 +CREATE ROLE regress_passwd1 +-- +STMT: CreateRoleStmt +== 007 +ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1' +-- +STMT: AlterRoleStmt +== 008 +CREATE ROLE regress_passwd2 +-- +STMT: CreateRoleStmt +== 009 +ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2' +-- +STMT: AlterRoleStmt +== 010 +SET password_encryption = 'scram-sha-256' +-- +STMT: VariableSetStmt +== 011 +CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3' +-- +STMT: CreateRoleStmt +== 012 +CREATE ROLE regress_passwd4 PASSWORD NULL +-- +STMT: CreateRoleStmt +== 013 +-- check list of created entries +|-- +-- The scram secret will look something like: +-- SCRAM-SHA-256$4096:E4HxLGtnRzsYwg==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo= +|-- +-- Since the salt is random, the exact value stored will be different on every test +-- run. Use a regular expression to mask the changing parts. +SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+/=]+)\$([a-zA-Z0-9+=/]+):([a-zA-Z0-9+/=]+)', '\1$\2:$:') as rolpassword_masked + FROM pg_authid + WHERE rolname LIKE 'regress_passwd%' + ORDER BY rolname, rolpassword +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FUNCTION: name="regexp_replace" function="regexp_replace" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 014 +-- Rename a role +ALTER ROLE regress_passwd2 RENAME TO regress_passwd2_new +-- +STMT: RenameStmt +== 015 +-- md5 entry should have been removed +SELECT rolname, rolpassword + FROM pg_authid + WHERE rolname LIKE 'regress_passwd2_new' + ORDER BY rolname, rolpassword +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 016 +ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2 +-- +STMT: RenameStmt +== 017 +-- Change passwords with ALTER USER. With plaintext or already-encrypted +-- passwords. +SET password_encryption = 'md5' +-- +STMT: VariableSetStmt +== 018 +-- encrypt with MD5 +ALTER ROLE regress_passwd2 PASSWORD 'foo' +-- +STMT: AlterRoleStmt +== 019 +-- already encrypted, use as they are +ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70' +-- +STMT: AlterRoleStmt +== 020 +ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=' +-- +STMT: AlterRoleStmt +== 021 +SET password_encryption = 'scram-sha-256' +-- +STMT: VariableSetStmt +== 022 +-- create SCRAM secret +ALTER ROLE regress_passwd4 PASSWORD 'foo' +-- +STMT: AlterRoleStmt +== 023 +-- already encrypted with MD5, use as it is +CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023' +-- +STMT: CreateRoleStmt +== 024 +-- This looks like a valid SCRAM-SHA-256 secret, but it is not +-- so it should be hashed with SCRAM-SHA-256. +CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234' +-- +STMT: CreateRoleStmt +== 025 +-- These may look like valid MD5 secrets, but they are not, so they +-- should be hashed with SCRAM-SHA-256. +-- trailing garbage at the end +CREATE ROLE regress_passwd7 PASSWORD 'md5012345678901234567890123456789zz' +-- +STMT: CreateRoleStmt +== 026 +-- invalid length +CREATE ROLE regress_passwd8 PASSWORD 'md501234567890123456789012345678901zz' +-- +STMT: CreateRoleStmt +== 027 +-- Changing the SCRAM iteration count +SET scram_iterations = 1024 +-- +STMT: VariableSetStmt +== 028 +CREATE ROLE regress_passwd9 PASSWORD 'alterediterationcount' +-- +STMT: CreateRoleStmt +== 029 +SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+/=]+)\$([a-zA-Z0-9+=/]+):([a-zA-Z0-9+/=]+)', '\1$\2:$:') as rolpassword_masked + FROM pg_authid + WHERE rolname LIKE 'regress_passwd%' + ORDER BY rolname, rolpassword +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FUNCTION: name="regexp_replace" function="regexp_replace" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 030 +-- An empty password is not allowed, in any form +CREATE ROLE regress_passwd_empty PASSWORD '' +-- +STMT: CreateRoleStmt +== 031 +ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a' +-- +STMT: AlterRoleStmt +== 032 +ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=' +-- +STMT: AlterRoleStmt +== 033 +SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 034 +-- Test with invalid stored and server keys. +|-- +-- The first is valid, to act as a control. The others have too long +-- stored/server keys. They will be re-hashed. +CREATE ROLE regress_passwd_sha_len0 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=' +-- +STMT: CreateRoleStmt +== 035 +CREATE ROLE regress_passwd_sha_len1 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96RqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=' +-- +STMT: CreateRoleStmt +== 036 +CREATE ROLE regress_passwd_sha_len2 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' +-- +STMT: CreateRoleStmt +== 037 +-- Check that the invalid secrets were re-hashed. A re-hashed secret +-- should not contain the original salt. +SELECT rolname, rolpassword not like '%A6xHKoH/494E941doaPOYg==%' as is_rolpassword_rehashed + FROM pg_authid + WHERE rolname LIKE 'regress_passwd_sha_len%' + ORDER BY rolname +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 038 +DROP ROLE regress_passwd1 +-- +STMT: DropRoleStmt +== 039 +DROP ROLE regress_passwd2 +-- +STMT: DropRoleStmt +== 040 +DROP ROLE regress_passwd3 +-- +STMT: DropRoleStmt +== 041 +DROP ROLE regress_passwd4 +-- +STMT: DropRoleStmt +== 042 +DROP ROLE regress_passwd5 +-- +STMT: DropRoleStmt +== 043 +DROP ROLE regress_passwd6 +-- +STMT: DropRoleStmt +== 044 +DROP ROLE regress_passwd7 +-- +STMT: DropRoleStmt +== 045 +DROP ROLE regress_passwd8 +-- +STMT: DropRoleStmt +== 046 +DROP ROLE regress_passwd9 +-- +STMT: DropRoleStmt +== 047 +DROP ROLE regress_passwd_empty +-- +STMT: DropRoleStmt +== 048 +DROP ROLE regress_passwd_sha_len0 +-- +STMT: DropRoleStmt +== 049 +DROP ROLE regress_passwd_sha_len1 +-- +STMT: DropRoleStmt +== 050 +DROP ROLE regress_passwd_sha_len2 +-- +STMT: DropRoleStmt +== 051 +-- all entries should have been removed +SELECT rolname, rolpassword + FROM pg_authid + WHERE rolname LIKE 'regress_passwd%' + ORDER BY rolname, rolpassword +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/path.metadata.json b/parser/testdata/summary/postgres_regress/path.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/path.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/path.test b/parser/testdata/summary/postgres_regress/path.test new file mode 100644 index 0000000..ac103ef --- /dev/null +++ b/parser/testdata/summary/postgres_regress/path.test @@ -0,0 +1,147 @@ +== 001 +|-- +-- PATH +|-- + +--DROP TABLE PATH_TBL; + +CREATE TABLE PATH_TBL (f1 path) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO PATH_TBL VALUES ('[(1,2),(3,4)]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO PATH_TBL VALUES (' ( ( 1 , 2 ) , ( 3 , 4 ) ) ') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO PATH_TBL VALUES ('[ (0,0),(3,0),(4,5),(1,6) ]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO PATH_TBL VALUES ('((1,2) ,(3,4 ))') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO PATH_TBL VALUES ('1,2 ,3,4 ') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO PATH_TBL VALUES (' [1,2,3, 4] ') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO PATH_TBL VALUES ('((10,20))') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +-- Only one point + +INSERT INTO PATH_TBL VALUES ('[ 11,12,13,14 ]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO PATH_TBL VALUES ('( 11,12,13,14) ') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +-- bad values for parser testing +INSERT INTO PATH_TBL VALUES ('[]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO PATH_TBL VALUES ('[(,2),(3,4)]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO PATH_TBL VALUES ('[(1,2),(3,4)') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO PATH_TBL VALUES ('(1,2,3,4') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +INSERT INTO PATH_TBL VALUES ('(1,2),(3,4)]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +SELECT f1 AS open_path FROM PATH_TBL WHERE isopen(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 017 +SELECT f1 AS closed_path FROM PATH_TBL WHERE isclosed(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 018 +SELECT pclose(f1) AS closed_path FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="pclose" function="pclose" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT popen(f1) AS open_path FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="popen" function="popen" schema="" ctx=Call +STMT: SelectStmt +== 020 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('[(1,2),(3)]', 'path') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'path') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT * FROM pg_input_error_info('[(1,2,6),(3,4,6)]', 'path') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/pg_lsn.metadata.json b/parser/testdata/summary/postgres_regress/pg_lsn.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/pg_lsn.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/pg_lsn.test b/parser/testdata/summary/postgres_regress/pg_lsn.test new file mode 100644 index 0000000..e6d64c1 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/pg_lsn.test @@ -0,0 +1,181 @@ +== 001 +|-- +-- PG_LSN +|-- + +CREATE TABLE PG_LSN_TBL (f1 pg_lsn) +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DDL +STMT: CreateStmt +== 002 +-- Largest and smallest input +INSERT INTO PG_LSN_TBL VALUES ('0/0') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO PG_LSN_TBL VALUES ('FFFFFFFF/FFFFFFFF') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +-- Incorrect input +INSERT INTO PG_LSN_TBL VALUES ('G/0') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO PG_LSN_TBL VALUES ('-1/0') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO PG_LSN_TBL VALUES (' 0/12345678') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO PG_LSN_TBL VALUES ('ABCD/') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO PG_LSN_TBL VALUES ('/ABCD') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('16AE7F7', 'pg_lsn') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 011 +-- Min/Max aggregation +SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 012 +DROP TABLE PG_LSN_TBL +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DDL +STMT: DropStmt +== 013 +-- Operators +SELECT '0/16AE7F8' = '0/16AE7F8'::pg_lsn +-- +STMT: SelectStmt +== 014 +SELECT '0/16AE7F8'::pg_lsn != '0/16AE7F7' +-- +STMT: SelectStmt +== 015 +SELECT '0/16AE7F7' < '0/16AE7F8'::pg_lsn +-- +STMT: SelectStmt +== 016 +SELECT '0/16AE7F8' > pg_lsn '0/16AE7F7' +-- +STMT: SelectStmt +== 017 +SELECT '0/16AE7F7'::pg_lsn - '0/16AE7F8'::pg_lsn +-- +STMT: SelectStmt +== 018 +SELECT '0/16AE7F8'::pg_lsn - '0/16AE7F7'::pg_lsn +-- +STMT: SelectStmt +== 019 +SELECT '0/16AE7F7'::pg_lsn + 16::numeric +-- +STMT: SelectStmt +== 020 +SELECT 16::numeric + '0/16AE7F7'::pg_lsn +-- +STMT: SelectStmt +== 021 +SELECT '0/16AE7F7'::pg_lsn - 16::numeric +-- +STMT: SelectStmt +== 022 +SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 1::numeric +-- +STMT: SelectStmt +== 023 +SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 2::numeric +-- +STMT: SelectStmt +== 024 +-- out of range error +SELECT '0/1'::pg_lsn - 1::numeric +-- +STMT: SelectStmt +== 025 +SELECT '0/1'::pg_lsn - 2::numeric +-- +STMT: SelectStmt +== 026 +-- out of range error +SELECT '0/0'::pg_lsn + ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn) +-- +STMT: SelectStmt +== 027 +SELECT 'FFFFFFFF/FFFFFFFF'::pg_lsn - ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn) +-- +STMT: SelectStmt +== 028 +SELECT '0/16AE7F7'::pg_lsn + 'NaN'::numeric +-- +STMT: SelectStmt +== 029 +SELECT '0/16AE7F7'::pg_lsn - 'NaN'::numeric +-- +STMT: SelectStmt +== 030 +-- Check btree and hash opclasses +EXPLAIN (COSTS OFF) +SELECT DISTINCT (i || '/' || j)::pg_lsn f + FROM generate_series(1, 10) i, + generate_series(1, 10) j, + generate_series(1, 5) k + WHERE i <= 10 AND j > 0 AND j <= 10 + ORDER BY f +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="j" +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +== 031 +SELECT DISTINCT (i || '/' || j)::pg_lsn f + FROM generate_series(1, 10) i, + generate_series(1, 10) j, + generate_series(1, 5) k + WHERE i <= 10 AND j > 0 AND j <= 10 + ORDER BY f +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="j" +FILTER: schema="" table="" column="j" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/plancache.metadata.json b/parser/testdata/summary/postgres_regress/plancache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/plancache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/plancache.test b/parser/testdata/summary/postgres_regress/plancache.test new file mode 100644 index 0000000..2bfd3de --- /dev/null +++ b/parser/testdata/summary/postgres_regress/plancache.test @@ -0,0 +1,559 @@ +== 001 +|-- +-- Tests to exercise the plan caching/invalidation mechanism +|-- + +CREATE TEMP TABLE pcachetest AS SELECT * FROM int8_tbl +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 002 +-- create and use a cached plan +PREPARE prepstmt AS SELECT * FROM pcachetest +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +== 003 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +== 004 +-- and one with parameters +PREPARE prepstmt2(bigint) AS SELECT * FROM pcachetest WHERE q1 = $1 +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: PrepareStmt +STMT: SelectStmt +== 005 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +== 006 +-- invalidate the plans and see what happens +DROP TABLE pcachetest +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +STMT: DropStmt +== 007 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +== 008 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +== 009 +-- recreate the temp table (this demonstrates that the raw plan is +-- purely textual and doesn't depend on OIDs, for instance) +CREATE TEMP TABLE pcachetest AS SELECT * FROM int8_tbl ORDER BY 2 +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 010 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +== 011 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +== 012 +-- prepared statements should prevent change in output tupdesc, +-- since clients probably aren't expecting that to change on the fly +ALTER TABLE pcachetest ADD COLUMN q3 bigint +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +STMT: AlterTableStmt +== 013 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +== 014 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +== 015 +-- but we're nice guys and will let you undo your mistake +ALTER TABLE pcachetest DROP COLUMN q3 +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +STMT: AlterTableStmt +== 016 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +== 017 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +== 018 +-- Try it with a view, which isn't directly used in the resulting plan +-- but should trigger invalidation anyway +CREATE TEMP VIEW pcacheview AS + SELECT * FROM pcachetest +-- +TABLE: name="pcacheview" schema="" table="pcacheview" ctx=DDL +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 019 +PREPARE vprep AS SELECT * FROM pcacheview +-- +TABLE: name="pcacheview" schema="" table="pcacheview" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +== 020 +EXECUTE vprep +-- +STMT: ExecuteStmt +== 021 +CREATE OR REPLACE TEMP VIEW pcacheview AS + SELECT q1, q2/2 AS q2 FROM pcachetest +-- +TABLE: name="pcacheview" schema="" table="pcacheview" ctx=DDL +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 022 +EXECUTE vprep +-- +STMT: ExecuteStmt +== 023 +-- Check basic SPI plan invalidation + +create function cache_test(int) returns int as $$ +declare total int; +begin + create temp table t1(f1 int); + insert into t1 values($1); + insert into t1 values(11); + insert into t1 values(12); + insert into t1 values(13); + select sum(f1) into total from t1; + drop table t1; + return total; +end +$$ language plpgsql +-- +FUNCTION: name="cache_test" function="cache_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 024 +select cache_test(1) +-- +FUNCTION: name="cache_test" function="cache_test" schema="" ctx=Call +STMT: SelectStmt +== 025 +select cache_test(2) +-- +FUNCTION: name="cache_test" function="cache_test" schema="" ctx=Call +STMT: SelectStmt +== 026 +select cache_test(3) +-- +FUNCTION: name="cache_test" function="cache_test" schema="" ctx=Call +STMT: SelectStmt +== 027 +-- Check invalidation of plpgsql "simple expression" + +create temp view v1 as + select 2+2 as f1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 028 +create function cache_test_2() returns int as $$ +begin + return f1 from v1; +end$$ language plpgsql +-- +FUNCTION: name="cache_test_2" function="cache_test_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +select cache_test_2() +-- +FUNCTION: name="cache_test_2" function="cache_test_2" schema="" ctx=Call +STMT: SelectStmt +== 030 +create or replace temp view v1 as + select 2+2+4 as f1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 031 +select cache_test_2() +-- +FUNCTION: name="cache_test_2" function="cache_test_2" schema="" ctx=Call +STMT: SelectStmt +== 032 +create or replace temp view v1 as + select 2+2+4+(select max(unique1) from tenk1) as f1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 033 +select cache_test_2() +-- +FUNCTION: name="cache_test_2" function="cache_test_2" schema="" ctx=Call +STMT: SelectStmt +== 034 +--- Check that change of search_path is honored when re-using cached plan + +create schema s1 + create table abc (f1 int) +-- +STMT: CreateSchemaStmt +== 035 +create schema s2 + create table abc (f1 int) +-- +STMT: CreateSchemaStmt +== 036 +insert into s1.abc values(123) +-- +TABLE: name="s1.abc" schema="s1" table="abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +insert into s2.abc values(456) +-- +TABLE: name="s2.abc" schema="s2" table="abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +set search_path = s1 +-- +STMT: VariableSetStmt +== 039 +prepare p1 as select f1 from abc +-- +TABLE: name="abc" schema="" table="abc" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +== 040 +execute p1 +-- +STMT: ExecuteStmt +== 041 +set search_path = s2 +-- +STMT: VariableSetStmt +== 042 +select f1 from abc +-- +TABLE: name="abc" schema="" table="abc" ctx=Select +STMT: SelectStmt +== 043 +execute p1 +-- +STMT: ExecuteStmt +== 044 +alter table s1.abc add column f2 float8 +-- +TABLE: name="s1.abc" schema="s1" table="abc" ctx=DDL +STMT: AlterTableStmt +== 045 +-- force replan + +execute p1 +-- +STMT: ExecuteStmt +== 046 +drop schema s1 cascade +-- +STMT: DropStmt +== 047 +drop schema s2 cascade +-- +STMT: DropStmt +== 048 +reset search_path +-- +STMT: VariableSetStmt +== 049 +-- Check that invalidation deals with regclass constants + +create temp sequence seq +-- +STMT: CreateSeqStmt +== 050 +prepare p2 as select nextval('seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 051 +execute p2 +-- +STMT: ExecuteStmt +== 052 +drop sequence seq +-- +STMT: DropStmt +== 053 +create temp sequence seq +-- +STMT: CreateSeqStmt +== 054 +execute p2 +-- +STMT: ExecuteStmt +== 055 +-- Check DDL via SPI, immediately followed by SPI plan re-use +-- (bug in original coding) + +create function cachebug() returns void as $$ +declare r int; +begin + drop table if exists temptable cascade; + create temp table temptable as select * from generate_series(1,3) as f1; + create temp view vv as select * from temptable; + for r in select * from vv loop + raise notice '%', r; + end loop; +end$$ language plpgsql +-- +FUNCTION: name="cachebug" function="cachebug" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 056 +select cachebug() +-- +FUNCTION: name="cachebug" function="cachebug" schema="" ctx=Call +STMT: SelectStmt +== 057 +select cachebug() +-- +FUNCTION: name="cachebug" function="cachebug" schema="" ctx=Call +STMT: SelectStmt +== 058 +-- Check that addition or removal of any partition is correctly dealt with by +-- default partition table when it is being used in prepared statement. +create table pc_list_parted (a int) partition by list(a) +-- +TABLE: name="pc_list_parted" schema="" table="pc_list_parted" ctx=DDL +STMT: CreateStmt +== 059 +create table pc_list_part_null partition of pc_list_parted for values in (null) +-- +TABLE: name="pc_list_part_null" schema="" table="pc_list_part_null" ctx=DDL +STMT: CreateStmt +== 060 +create table pc_list_part_1 partition of pc_list_parted for values in (1) +-- +TABLE: name="pc_list_part_1" schema="" table="pc_list_part_1" ctx=DDL +STMT: CreateStmt +== 061 +create table pc_list_part_def partition of pc_list_parted default +-- +TABLE: name="pc_list_part_def" schema="" table="pc_list_part_def" ctx=DDL +STMT: CreateStmt +== 062 +prepare pstmt_def_insert (int) as insert into pc_list_part_def values($1) +-- +TABLE: name="pc_list_part_def" schema="" table="pc_list_part_def" ctx=DML +STMT: PrepareStmt +STMT: InsertStmt +STMT: SelectStmt +== 063 +-- should fail +execute pstmt_def_insert(null) +-- +STMT: ExecuteStmt +== 064 +execute pstmt_def_insert(1) +-- +STMT: ExecuteStmt +== 065 +create table pc_list_part_2 partition of pc_list_parted for values in (2) +-- +TABLE: name="pc_list_part_2" schema="" table="pc_list_part_2" ctx=DDL +STMT: CreateStmt +== 066 +execute pstmt_def_insert(2) +-- +STMT: ExecuteStmt +== 067 +alter table pc_list_parted detach partition pc_list_part_null +-- +TABLE: name="pc_list_parted" schema="" table="pc_list_parted" ctx=DDL +STMT: AlterTableStmt +== 068 +-- should be ok +execute pstmt_def_insert(null) +-- +STMT: ExecuteStmt +== 069 +drop table pc_list_part_1 +-- +TABLE: name="pc_list_part_1" schema="" table="pc_list_part_1" ctx=DDL +STMT: DropStmt +== 070 +-- should be ok +execute pstmt_def_insert(1) +-- +STMT: ExecuteStmt +== 071 +drop table pc_list_parted, pc_list_part_null +-- +TABLE: name="pc_list_parted" schema="" table="pc_list_parted" ctx=DDL +TABLE: name="pc_list_part_null" schema="" table="pc_list_part_null" ctx=DDL +STMT: DropStmt +== 072 +deallocate pstmt_def_insert +-- +STMT: DeallocateStmt +== 073 +-- Test plan_cache_mode + +create table test_mode (a int) +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DDL +STMT: CreateStmt +== 074 +insert into test_mode select 1 from generate_series(1,1000) union all select 2 +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 075 +create index on test_mode (a) +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DDL +STMT: IndexStmt +== 076 +analyze test_mode +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DDL +STMT: VacuumStmt +== 077 +prepare test_mode_pp (int) as select count(*) from test_mode where a = $1 +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +== 078 +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 079 +-- up to 5 executions, custom plan is used +set plan_cache_mode to auto +-- +STMT: VariableSetStmt +== 080 +explain (costs off) execute test_mode_pp(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 081 +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 082 +-- force generic plan +set plan_cache_mode to force_generic_plan +-- +STMT: VariableSetStmt +== 083 +explain (costs off) execute test_mode_pp(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 084 +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 085 +-- get to generic plan by 5 executions +set plan_cache_mode to auto +-- +STMT: VariableSetStmt +== 086 +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +== 087 +-- 1x +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +== 088 +-- 2x +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +== 089 +-- 3x +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +== 090 +-- 4x +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 091 +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +== 092 +-- 5x +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 093 +-- we should now get a really bad plan +explain (costs off) execute test_mode_pp(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 094 +-- but we can force a custom plan +set plan_cache_mode to force_custom_plan +-- +STMT: VariableSetStmt +== 095 +explain (costs off) execute test_mode_pp(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 096 +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 097 +drop table test_mode +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/plpgsql.metadata.json b/parser/testdata/summary/postgres_regress/plpgsql.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/plpgsql.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/plpgsql.test b/parser/testdata/summary/postgres_regress/plpgsql.test new file mode 100644 index 0000000..5161779 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/plpgsql.test @@ -0,0 +1,8012 @@ +== 001 +|-- +-- PLPGSQL +|-- +-- Scenario: +|-- +-- A building with a modern TP cable installation where any +-- of the wall connectors can be used to plug in phones, +-- ethernet interfaces or local office hubs. The backside +-- of the wall connectors is wired to one of several patch- +-- fields in the building. +|-- +-- In the patchfields, there are hubs and all the slots +-- representing the wall connectors. In addition there are +-- slots that can represent a phone line from the central +-- phone system. +|-- +-- Triggers ensure consistency of the patching information. +|-- +-- Functions are used to build up powerful views that let +-- you look behind the wall when looking at a patchfield +-- or into a room. +|-- + + +create table Room ( + roomno char(8), + comment text +) +-- +TABLE: name="room" schema="" table="room" ctx=DDL +STMT: CreateStmt +== 002 +create unique index Room_rno on Room using btree (roomno bpchar_ops) +-- +TABLE: name="room" schema="" table="room" ctx=DDL +STMT: IndexStmt +== 003 +create table WSlot ( + slotname char(20), + roomno char(8), + slotlink char(20), + backlink char(20) +) +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateStmt +== 004 +create unique index WSlot_name on WSlot using btree (slotname bpchar_ops) +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: IndexStmt +== 005 +create table PField ( + name text, + comment text +) +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DDL +STMT: CreateStmt +== 006 +create unique index PField_name on PField using btree (name text_ops) +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DDL +STMT: IndexStmt +== 007 +create table PSlot ( + slotname char(20), + pfname text, + slotlink char(20), + backlink char(20) +) +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateStmt +== 008 +create unique index PSlot_name on PSlot using btree (slotname bpchar_ops) +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: IndexStmt +== 009 +create table PLine ( + slotname char(20), + phonenumber char(20), + comment text, + backlink char(20) +) +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateStmt +== 010 +create unique index PLine_name on PLine using btree (slotname bpchar_ops) +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: IndexStmt +== 011 +create table Hub ( + name char(14), + comment text, + nslots integer +) +-- +TABLE: name="hub" schema="" table="hub" ctx=DDL +STMT: CreateStmt +== 012 +create unique index Hub_name on Hub using btree (name bpchar_ops) +-- +TABLE: name="hub" schema="" table="hub" ctx=DDL +STMT: IndexStmt +== 013 +create table HSlot ( + slotname char(20), + hubname char(14), + slotno integer, + slotlink char(20) +) +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateStmt +== 014 +create unique index HSlot_name on HSlot using btree (slotname bpchar_ops) +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: IndexStmt +== 015 +create index HSlot_hubname on HSlot using btree (hubname bpchar_ops) +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: IndexStmt +== 016 +create table System ( + name text, + comment text +) +-- +TABLE: name="system" schema="" table="system" ctx=DDL +STMT: CreateStmt +== 017 +create unique index System_name on System using btree (name text_ops) +-- +TABLE: name="system" schema="" table="system" ctx=DDL +STMT: IndexStmt +== 018 +create table IFace ( + slotname char(20), + sysname text, + ifname text, + slotlink char(20) +) +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateStmt +== 019 +create unique index IFace_name on IFace using btree (slotname bpchar_ops) +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: IndexStmt +== 020 +create table PHone ( + slotname char(20), + comment text, + slotlink char(20) +) +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateStmt +== 021 +create unique index PHone_name on PHone using btree (slotname bpchar_ops) +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: IndexStmt +== 022 +-- ************************************************************ +-- * +-- * Trigger procedures and functions for the patchfield +-- * test of PL/pgSQL +-- * +-- ************************************************************ + + +-- ************************************************************ +-- * AFTER UPDATE on Room +-- * - If room no changes let wall slots follow +-- ************************************************************ +create function tg_room_au() returns trigger as ' +begin + if new.roomno != old.roomno then + update WSlot set roomno = new.roomno where roomno = old.roomno; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_room_au" function="tg_room_au" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 023 +create trigger tg_room_au after update + on Room for each row execute procedure tg_room_au() +-- +TABLE: name="room" schema="" table="room" ctx=DDL +STMT: CreateTrigStmt +== 024 +-- ************************************************************ +-- * AFTER DELETE on Room +-- * - delete wall slots in this room +-- ************************************************************ +create function tg_room_ad() returns trigger as ' +begin + delete from WSlot where roomno = old.roomno; + return old; +end; +' language plpgsql +-- +FUNCTION: name="tg_room_ad" function="tg_room_ad" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 025 +create trigger tg_room_ad after delete + on Room for each row execute procedure tg_room_ad() +-- +TABLE: name="room" schema="" table="room" ctx=DDL +STMT: CreateTrigStmt +== 026 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on WSlot +-- * - Check that room exists +-- ************************************************************ +create function tg_wslot_biu() returns trigger as $$ +begin + if count(*) = 0 from Room where roomno = new.roomno then + raise exception 'Room % does not exist', new.roomno; + end if; + return new; +end; +$$ language plpgsql +-- +FUNCTION: name="tg_wslot_biu" function="tg_wslot_biu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 027 +create trigger tg_wslot_biu before insert or update + on WSlot for each row execute procedure tg_wslot_biu() +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +== 028 +-- ************************************************************ +-- * AFTER UPDATE on PField +-- * - Let PSlots of this field follow +-- ************************************************************ +create function tg_pfield_au() returns trigger as ' +begin + if new.name != old.name then + update PSlot set pfname = new.name where pfname = old.name; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_pfield_au" function="tg_pfield_au" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 029 +create trigger tg_pfield_au after update + on PField for each row execute procedure tg_pfield_au() +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DDL +STMT: CreateTrigStmt +== 030 +-- ************************************************************ +-- * AFTER DELETE on PField +-- * - Remove all slots of this patchfield +-- ************************************************************ +create function tg_pfield_ad() returns trigger as ' +begin + delete from PSlot where pfname = old.name; + return old; +end; +' language plpgsql +-- +FUNCTION: name="tg_pfield_ad" function="tg_pfield_ad" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 031 +create trigger tg_pfield_ad after delete + on PField for each row execute procedure tg_pfield_ad() +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DDL +STMT: CreateTrigStmt +== 032 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on PSlot +-- * - Ensure that our patchfield does exist +-- ************************************************************ +create function tg_pslot_biu() returns trigger as $proc$ +declare + pfrec record; + ps alias for new; +begin + select into pfrec * from PField where name = ps.pfname; + if not found then + raise exception $$Patchfield "%" does not exist$$, ps.pfname; + end if; + return ps; +end; +$proc$ language plpgsql +-- +FUNCTION: name="tg_pslot_biu" function="tg_pslot_biu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 033 +create trigger tg_pslot_biu before insert or update + on PSlot for each row execute procedure tg_pslot_biu() +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +== 034 +-- ************************************************************ +-- * AFTER UPDATE on System +-- * - If system name changes let interfaces follow +-- ************************************************************ +create function tg_system_au() returns trigger as ' +begin + if new.name != old.name then + update IFace set sysname = new.name where sysname = old.name; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_system_au" function="tg_system_au" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 035 +create trigger tg_system_au after update + on System for each row execute procedure tg_system_au() +-- +TABLE: name="system" schema="" table="system" ctx=DDL +STMT: CreateTrigStmt +== 036 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on IFace +-- * - set the slotname to IF.sysname.ifname +-- ************************************************************ +create function tg_iface_biu() returns trigger as $$ +declare + sname text; + sysrec record; +begin + select into sysrec * from system where name = new.sysname; + if not found then + raise exception $q$system "%" does not exist$q$, new.sysname; + end if; + sname := 'IF.' || new.sysname; + sname := sname || '.'; + sname := sname || new.ifname; + if length(sname) > 20 then + raise exception 'IFace slotname "%" too long (20 char max)', sname; + end if; + new.slotname := sname; + return new; +end; +$$ language plpgsql +-- +FUNCTION: name="tg_iface_biu" function="tg_iface_biu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 037 +create trigger tg_iface_biu before insert or update + on IFace for each row execute procedure tg_iface_biu() +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +== 038 +-- ************************************************************ +-- * AFTER INSERT or UPDATE or DELETE on Hub +-- * - insert/delete/rename slots as required +-- ************************************************************ +create function tg_hub_a() returns trigger as ' +declare + hname text; + dummy integer; +begin + if tg_op = ''INSERT'' then + dummy := tg_hub_adjustslots(new.name, 0, new.nslots); + return new; + end if; + if tg_op = ''UPDATE'' then + if new.name != old.name then + update HSlot set hubname = new.name where hubname = old.name; + end if; + dummy := tg_hub_adjustslots(new.name, old.nslots, new.nslots); + return new; + end if; + if tg_op = ''DELETE'' then + dummy := tg_hub_adjustslots(old.name, old.nslots, 0); + return old; + end if; +end; +' language plpgsql +-- +FUNCTION: name="tg_hub_a" function="tg_hub_a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 039 +create trigger tg_hub_a after insert or update or delete + on Hub for each row execute procedure tg_hub_a() +-- +TABLE: name="hub" schema="" table="hub" ctx=DDL +STMT: CreateTrigStmt +== 040 +-- ************************************************************ +-- * Support function to add/remove slots of Hub +-- ************************************************************ +create function tg_hub_adjustslots(hname bpchar, + oldnslots integer, + newnslots integer) +returns integer as ' +begin + if newnslots = oldnslots then + return 0; + end if; + if newnslots < oldnslots then + delete from HSlot where hubname = hname and slotno > newnslots; + return 0; + end if; + for i in oldnslots + 1 .. newnslots loop + insert into HSlot (slotname, hubname, slotno, slotlink) + values (''HS.dummy'', hname, i, ''''); + end loop; + return 0; +end +' language plpgsql +-- +FUNCTION: name="tg_hub_adjustslots" function="tg_hub_adjustslots" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 041 +-- Test comments +COMMENT ON FUNCTION tg_hub_adjustslots_wrong(bpchar, integer, integer) IS 'function with args' +-- +STMT: CommentStmt +== 042 +COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, integer, integer) IS 'function with args' +-- +STMT: CommentStmt +== 043 +COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, integer, integer) IS NULL +-- +STMT: CommentStmt +== 044 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on HSlot +-- * - prevent from manual manipulation +-- * - set the slotname to HS.hubname.slotno +-- ************************************************************ +create function tg_hslot_biu() returns trigger as ' +declare + sname text; + xname HSlot.slotname%TYPE; + hubrec record; +begin + select into hubrec * from Hub where name = new.hubname; + if not found then + raise exception ''no manual manipulation of HSlot''; + end if; + if new.slotno < 1 or new.slotno > hubrec.nslots then + raise exception ''no manual manipulation of HSlot''; + end if; + if tg_op = ''UPDATE'' and new.hubname != old.hubname then + if count(*) > 0 from Hub where name = old.hubname then + raise exception ''no manual manipulation of HSlot''; + end if; + end if; + sname := ''HS.'' || trim(new.hubname); + sname := sname || ''.''; + sname := sname || new.slotno::text; + if length(sname) > 20 then + raise exception ''HSlot slotname "%" too long (20 char max)'', sname; + end if; + new.slotname := sname; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_hslot_biu" function="tg_hslot_biu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 045 +create trigger tg_hslot_biu before insert or update + on HSlot for each row execute procedure tg_hslot_biu() +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +== 046 +-- ************************************************************ +-- * BEFORE DELETE on HSlot +-- * - prevent from manual manipulation +-- ************************************************************ +create function tg_hslot_bd() returns trigger as ' +declare + hubrec record; +begin + select into hubrec * from Hub where name = old.hubname; + if not found then + return old; + end if; + if old.slotno > hubrec.nslots then + return old; + end if; + raise exception ''no manual manipulation of HSlot''; +end; +' language plpgsql +-- +FUNCTION: name="tg_hslot_bd" function="tg_hslot_bd" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 047 +create trigger tg_hslot_bd before delete + on HSlot for each row execute procedure tg_hslot_bd() +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +== 048 +-- ************************************************************ +-- * BEFORE INSERT on all slots +-- * - Check name prefix +-- ************************************************************ +create function tg_chkslotname() returns trigger as ' +begin + if substr(new.slotname, 1, 2) != tg_argv[0] then + raise exception ''slotname must begin with %'', tg_argv[0]; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_chkslotname" function="tg_chkslotname" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 049 +create trigger tg_chkslotname before insert + on PSlot for each row execute procedure tg_chkslotname('PS') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +== 050 +create trigger tg_chkslotname before insert + on WSlot for each row execute procedure tg_chkslotname('WS') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +== 051 +create trigger tg_chkslotname before insert + on PLine for each row execute procedure tg_chkslotname('PL') +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateTrigStmt +== 052 +create trigger tg_chkslotname before insert + on IFace for each row execute procedure tg_chkslotname('IF') +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +== 053 +create trigger tg_chkslotname before insert + on PHone for each row execute procedure tg_chkslotname('PH') +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateTrigStmt +== 054 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on all slots with slotlink +-- * - Set slotlink to empty string if NULL value given +-- ************************************************************ +create function tg_chkslotlink() returns trigger as ' +begin + if new.slotlink isnull then + new.slotlink := ''''; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_chkslotlink" function="tg_chkslotlink" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 055 +create trigger tg_chkslotlink before insert or update + on PSlot for each row execute procedure tg_chkslotlink() +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +== 056 +create trigger tg_chkslotlink before insert or update + on WSlot for each row execute procedure tg_chkslotlink() +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +== 057 +create trigger tg_chkslotlink before insert or update + on IFace for each row execute procedure tg_chkslotlink() +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +== 058 +create trigger tg_chkslotlink before insert or update + on HSlot for each row execute procedure tg_chkslotlink() +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +== 059 +create trigger tg_chkslotlink before insert or update + on PHone for each row execute procedure tg_chkslotlink() +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateTrigStmt +== 060 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on all slots with backlink +-- * - Set backlink to empty string if NULL value given +-- ************************************************************ +create function tg_chkbacklink() returns trigger as ' +begin + if new.backlink isnull then + new.backlink := ''''; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_chkbacklink" function="tg_chkbacklink" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 061 +create trigger tg_chkbacklink before insert or update + on PSlot for each row execute procedure tg_chkbacklink() +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +== 062 +create trigger tg_chkbacklink before insert or update + on WSlot for each row execute procedure tg_chkbacklink() +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +== 063 +create trigger tg_chkbacklink before insert or update + on PLine for each row execute procedure tg_chkbacklink() +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateTrigStmt +== 064 +-- ************************************************************ +-- * BEFORE UPDATE on PSlot +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_pslot_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from PSlot where slotname = old.slotname; + insert into PSlot ( + slotname, + pfname, + slotlink, + backlink + ) values ( + new.slotname, + new.pfname, + new.slotlink, + new.backlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_pslot_bu" function="tg_pslot_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 065 +create trigger tg_pslot_bu before update + on PSlot for each row execute procedure tg_pslot_bu() +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +== 066 +-- ************************************************************ +-- * BEFORE UPDATE on WSlot +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_wslot_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from WSlot where slotname = old.slotname; + insert into WSlot ( + slotname, + roomno, + slotlink, + backlink + ) values ( + new.slotname, + new.roomno, + new.slotlink, + new.backlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_wslot_bu" function="tg_wslot_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 067 +create trigger tg_wslot_bu before update + on WSlot for each row execute procedure tg_Wslot_bu() +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +== 068 +-- ************************************************************ +-- * BEFORE UPDATE on PLine +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_pline_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from PLine where slotname = old.slotname; + insert into PLine ( + slotname, + phonenumber, + comment, + backlink + ) values ( + new.slotname, + new.phonenumber, + new.comment, + new.backlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_pline_bu" function="tg_pline_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 069 +create trigger tg_pline_bu before update + on PLine for each row execute procedure tg_pline_bu() +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateTrigStmt +== 070 +-- ************************************************************ +-- * BEFORE UPDATE on IFace +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_iface_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from IFace where slotname = old.slotname; + insert into IFace ( + slotname, + sysname, + ifname, + slotlink + ) values ( + new.slotname, + new.sysname, + new.ifname, + new.slotlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_iface_bu" function="tg_iface_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 071 +create trigger tg_iface_bu before update + on IFace for each row execute procedure tg_iface_bu() +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +== 072 +-- ************************************************************ +-- * BEFORE UPDATE on HSlot +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_hslot_bu() returns trigger as ' +begin + if new.slotname != old.slotname or new.hubname != old.hubname then + delete from HSlot where slotname = old.slotname; + insert into HSlot ( + slotname, + hubname, + slotno, + slotlink + ) values ( + new.slotname, + new.hubname, + new.slotno, + new.slotlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_hslot_bu" function="tg_hslot_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 073 +create trigger tg_hslot_bu before update + on HSlot for each row execute procedure tg_hslot_bu() +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +== 074 +-- ************************************************************ +-- * BEFORE UPDATE on PHone +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_phone_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from PHone where slotname = old.slotname; + insert into PHone ( + slotname, + comment, + slotlink + ) values ( + new.slotname, + new.comment, + new.slotlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_phone_bu" function="tg_phone_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 075 +create trigger tg_phone_bu before update + on PHone for each row execute procedure tg_phone_bu() +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateTrigStmt +== 076 +-- ************************************************************ +-- * AFTER INSERT or UPDATE or DELETE on slot with backlink +-- * - Ensure that the opponent correctly points back to us +-- ************************************************************ +create function tg_backlink_a() returns trigger as ' +declare + dummy integer; +begin + if tg_op = ''INSERT'' then + if new.backlink != '''' then + dummy := tg_backlink_set(new.backlink, new.slotname); + end if; + return new; + end if; + if tg_op = ''UPDATE'' then + if new.backlink != old.backlink then + if old.backlink != '''' then + dummy := tg_backlink_unset(old.backlink, old.slotname); + end if; + if new.backlink != '''' then + dummy := tg_backlink_set(new.backlink, new.slotname); + end if; + else + if new.slotname != old.slotname and new.backlink != '''' then + dummy := tg_slotlink_set(new.backlink, new.slotname); + end if; + end if; + return new; + end if; + if tg_op = ''DELETE'' then + if old.backlink != '''' then + dummy := tg_backlink_unset(old.backlink, old.slotname); + end if; + return old; + end if; +end; +' language plpgsql +-- +FUNCTION: name="tg_backlink_a" function="tg_backlink_a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 077 +create trigger tg_backlink_a after insert or update or delete + on PSlot for each row execute procedure tg_backlink_a('PS') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +== 078 +create trigger tg_backlink_a after insert or update or delete + on WSlot for each row execute procedure tg_backlink_a('WS') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +== 079 +create trigger tg_backlink_a after insert or update or delete + on PLine for each row execute procedure tg_backlink_a('PL') +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateTrigStmt +== 080 +-- ************************************************************ +-- * Support function to set the opponents backlink field +-- * if it does not already point to the requested slot +-- ************************************************************ +create function tg_backlink_set(myname bpchar, blname bpchar) +returns integer as ' +declare + mytype char(2); + link char(4); + rec record; +begin + mytype := substr(myname, 1, 2); + link := mytype || substr(blname, 1, 2); + if link = ''PLPL'' then + raise exception + ''backlink between two phone lines does not make sense''; + end if; + if link in (''PLWS'', ''WSPL'') then + raise exception + ''direct link of phone line to wall slot not permitted''; + end if; + if mytype = ''PS'' then + select into rec * from PSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.backlink != blname then + update PSlot set backlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''WS'' then + select into rec * from WSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.backlink != blname then + update WSlot set backlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''PL'' then + select into rec * from PLine where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.backlink != blname then + update PLine set backlink = blname where slotname = myname; + end if; + return 0; + end if; + raise exception ''illegal backlink beginning with %'', mytype; +end; +' language plpgsql +-- +FUNCTION: name="tg_backlink_set" function="tg_backlink_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 081 +-- ************************************************************ +-- * Support function to clear out the backlink field if +-- * it still points to specific slot +-- ************************************************************ +create function tg_backlink_unset(bpchar, bpchar) +returns integer as ' +declare + myname alias for $1; + blname alias for $2; + mytype char(2); + rec record; +begin + mytype := substr(myname, 1, 2); + if mytype = ''PS'' then + select into rec * from PSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.backlink = blname then + update PSlot set backlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''WS'' then + select into rec * from WSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.backlink = blname then + update WSlot set backlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''PL'' then + select into rec * from PLine where slotname = myname; + if not found then + return 0; + end if; + if rec.backlink = blname then + update PLine set backlink = '''' where slotname = myname; + end if; + return 0; + end if; +end +' language plpgsql +-- +FUNCTION: name="tg_backlink_unset" function="tg_backlink_unset" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 082 +-- ************************************************************ +-- * AFTER INSERT or UPDATE or DELETE on slot with slotlink +-- * - Ensure that the opponent correctly points back to us +-- ************************************************************ +create function tg_slotlink_a() returns trigger as ' +declare + dummy integer; +begin + if tg_op = ''INSERT'' then + if new.slotlink != '''' then + dummy := tg_slotlink_set(new.slotlink, new.slotname); + end if; + return new; + end if; + if tg_op = ''UPDATE'' then + if new.slotlink != old.slotlink then + if old.slotlink != '''' then + dummy := tg_slotlink_unset(old.slotlink, old.slotname); + end if; + if new.slotlink != '''' then + dummy := tg_slotlink_set(new.slotlink, new.slotname); + end if; + else + if new.slotname != old.slotname and new.slotlink != '''' then + dummy := tg_slotlink_set(new.slotlink, new.slotname); + end if; + end if; + return new; + end if; + if tg_op = ''DELETE'' then + if old.slotlink != '''' then + dummy := tg_slotlink_unset(old.slotlink, old.slotname); + end if; + return old; + end if; +end; +' language plpgsql +-- +FUNCTION: name="tg_slotlink_a" function="tg_slotlink_a" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 083 +create trigger tg_slotlink_a after insert or update or delete + on PSlot for each row execute procedure tg_slotlink_a('PS') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +== 084 +create trigger tg_slotlink_a after insert or update or delete + on WSlot for each row execute procedure tg_slotlink_a('WS') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +== 085 +create trigger tg_slotlink_a after insert or update or delete + on IFace for each row execute procedure tg_slotlink_a('IF') +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +== 086 +create trigger tg_slotlink_a after insert or update or delete + on HSlot for each row execute procedure tg_slotlink_a('HS') +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +== 087 +create trigger tg_slotlink_a after insert or update or delete + on PHone for each row execute procedure tg_slotlink_a('PH') +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateTrigStmt +== 088 +-- ************************************************************ +-- * Support function to set the opponents slotlink field +-- * if it does not already point to the requested slot +-- ************************************************************ +create function tg_slotlink_set(bpchar, bpchar) +returns integer as ' +declare + myname alias for $1; + blname alias for $2; + mytype char(2); + link char(4); + rec record; +begin + mytype := substr(myname, 1, 2); + link := mytype || substr(blname, 1, 2); + if link = ''PHPH'' then + raise exception + ''slotlink between two phones does not make sense''; + end if; + if link in (''PHHS'', ''HSPH'') then + raise exception + ''link of phone to hub does not make sense''; + end if; + if link in (''PHIF'', ''IFPH'') then + raise exception + ''link of phone to hub does not make sense''; + end if; + if link in (''PSWS'', ''WSPS'') then + raise exception + ''slotlink from patchslot to wallslot not permitted''; + end if; + if mytype = ''PS'' then + select into rec * from PSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update PSlot set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''WS'' then + select into rec * from WSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update WSlot set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''IF'' then + select into rec * from IFace where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update IFace set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''HS'' then + select into rec * from HSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update HSlot set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''PH'' then + select into rec * from PHone where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update PHone set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + raise exception ''illegal slotlink beginning with %'', mytype; +end; +' language plpgsql +-- +FUNCTION: name="tg_slotlink_set" function="tg_slotlink_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 089 +-- ************************************************************ +-- * Support function to clear out the slotlink field if +-- * it still points to specific slot +-- ************************************************************ +create function tg_slotlink_unset(bpchar, bpchar) +returns integer as ' +declare + myname alias for $1; + blname alias for $2; + mytype char(2); + rec record; +begin + mytype := substr(myname, 1, 2); + if mytype = ''PS'' then + select into rec * from PSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update PSlot set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''WS'' then + select into rec * from WSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update WSlot set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''IF'' then + select into rec * from IFace where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update IFace set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''HS'' then + select into rec * from HSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update HSlot set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''PH'' then + select into rec * from PHone where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update PHone set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; +end; +' language plpgsql +-- +FUNCTION: name="tg_slotlink_unset" function="tg_slotlink_unset" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 090 +-- ************************************************************ +-- * Describe the backside of a patchfield slot +-- ************************************************************ +create function pslot_backlink_view(bpchar) +returns text as ' +<> +declare + rec record; + bltype char(2); + retval text; +begin + select into rec * from PSlot where slotname = $1; + if not found then + return ''''; + end if; + if rec.backlink = '''' then + return ''-''; + end if; + bltype := substr(rec.backlink, 1, 2); + if bltype = ''PL'' then + declare + rec record; + begin + select into rec * from PLine where slotname = "outer".rec.backlink; + retval := ''Phone line '' || trim(rec.phonenumber); + if rec.comment != '''' then + retval := retval || '' (''; + retval := retval || rec.comment; + retval := retval || '')''; + end if; + return retval; + end; + end if; + if bltype = ''WS'' then + select into rec * from WSlot where slotname = rec.backlink; + retval := trim(rec.slotname) || '' in room ''; + retval := retval || trim(rec.roomno); + retval := retval || '' -> ''; + return retval || wslot_slotlink_view(rec.slotname); + end if; + return rec.backlink; +end; +' language plpgsql +-- +FUNCTION: name="pslot_backlink_view" function="pslot_backlink_view" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 091 +-- ************************************************************ +-- * Describe the front of a patchfield slot +-- ************************************************************ +create function pslot_slotlink_view(bpchar) +returns text as ' +declare + psrec record; + sltype char(2); + retval text; +begin + select into psrec * from PSlot where slotname = $1; + if not found then + return ''''; + end if; + if psrec.slotlink = '''' then + return ''-''; + end if; + sltype := substr(psrec.slotlink, 1, 2); + if sltype = ''PS'' then + retval := trim(psrec.slotlink) || '' -> ''; + return retval || pslot_backlink_view(psrec.slotlink); + end if; + if sltype = ''HS'' then + retval := comment from Hub H, HSlot HS + where HS.slotname = psrec.slotlink + and H.name = HS.hubname; + retval := retval || '' slot ''; + retval := retval || slotno::text from HSlot + where slotname = psrec.slotlink; + return retval; + end if; + return psrec.slotlink; +end; +' language plpgsql +-- +FUNCTION: name="pslot_slotlink_view" function="pslot_slotlink_view" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 092 +-- ************************************************************ +-- * Describe the front of a wall connector slot +-- ************************************************************ +create function wslot_slotlink_view(bpchar) +returns text as ' +declare + rec record; + sltype char(2); + retval text; +begin + select into rec * from WSlot where slotname = $1; + if not found then + return ''''; + end if; + if rec.slotlink = '''' then + return ''-''; + end if; + sltype := substr(rec.slotlink, 1, 2); + if sltype = ''PH'' then + select into rec * from PHone where slotname = rec.slotlink; + retval := ''Phone '' || trim(rec.slotname); + if rec.comment != '''' then + retval := retval || '' (''; + retval := retval || rec.comment; + retval := retval || '')''; + end if; + return retval; + end if; + if sltype = ''IF'' then + declare + syrow System%RowType; + ifrow IFace%ROWTYPE; + begin + select into ifrow * from IFace where slotname = rec.slotlink; + select into syrow * from System where name = ifrow.sysname; + retval := syrow.name || '' IF ''; + retval := retval || ifrow.ifname; + if syrow.comment != '''' then + retval := retval || '' (''; + retval := retval || syrow.comment; + retval := retval || '')''; + end if; + return retval; + end; + end if; + return rec.slotlink; +end; +' language plpgsql +-- +FUNCTION: name="wslot_slotlink_view" function="wslot_slotlink_view" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 093 +-- ************************************************************ +-- * View of a patchfield describing backside and patches +-- ************************************************************ +create view Pfield_v1 as select PF.pfname, PF.slotname, + pslot_backlink_view(PF.slotname) as backside, + pslot_slotlink_view(PF.slotname) as patch + from PSlot PF +-- +TABLE: name="pfield_v1" schema="" table="pfield_v1" ctx=DDL +TABLE: name="pslot" schema="" table="pslot" ctx=Select +ALIAS: "pf"="pslot" +FUNCTION: name="pslot_backlink_view" function="pslot_backlink_view" schema="" ctx=Call +FUNCTION: name="pslot_slotlink_view" function="pslot_slotlink_view" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 094 +|-- +-- First we build the house - so we create the rooms +|-- +insert into Room values ('001', 'Entrance') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +insert into Room values ('002', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +insert into Room values ('003', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +insert into Room values ('004', 'Technical') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +insert into Room values ('101', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 099 +insert into Room values ('102', 'Conference') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 100 +insert into Room values ('103', 'Restroom') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +insert into Room values ('104', 'Technical') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 102 +insert into Room values ('105', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +insert into Room values ('106', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +|-- +-- Second we install the wall connectors +|-- +insert into WSlot values ('WS.001.1a', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +insert into WSlot values ('WS.001.1b', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 106 +insert into WSlot values ('WS.001.2a', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +insert into WSlot values ('WS.001.2b', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +insert into WSlot values ('WS.001.3a', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +insert into WSlot values ('WS.001.3b', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +insert into WSlot values ('WS.002.1a', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +insert into WSlot values ('WS.002.1b', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 112 +insert into WSlot values ('WS.002.2a', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 113 +insert into WSlot values ('WS.002.2b', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 114 +insert into WSlot values ('WS.002.3a', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +insert into WSlot values ('WS.002.3b', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +insert into WSlot values ('WS.003.1a', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 117 +insert into WSlot values ('WS.003.1b', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 118 +insert into WSlot values ('WS.003.2a', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 119 +insert into WSlot values ('WS.003.2b', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 120 +insert into WSlot values ('WS.003.3a', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +insert into WSlot values ('WS.003.3b', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +insert into WSlot values ('WS.101.1a', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +insert into WSlot values ('WS.101.1b', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 124 +insert into WSlot values ('WS.101.2a', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 125 +insert into WSlot values ('WS.101.2b', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 126 +insert into WSlot values ('WS.101.3a', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 127 +insert into WSlot values ('WS.101.3b', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 128 +insert into WSlot values ('WS.102.1a', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +insert into WSlot values ('WS.102.1b', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 130 +insert into WSlot values ('WS.102.2a', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 131 +insert into WSlot values ('WS.102.2b', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 132 +insert into WSlot values ('WS.102.3a', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 133 +insert into WSlot values ('WS.102.3b', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 134 +insert into WSlot values ('WS.105.1a', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 135 +insert into WSlot values ('WS.105.1b', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +insert into WSlot values ('WS.105.2a', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +insert into WSlot values ('WS.105.2b', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +insert into WSlot values ('WS.105.3a', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +insert into WSlot values ('WS.105.3b', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 140 +insert into WSlot values ('WS.106.1a', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 141 +insert into WSlot values ('WS.106.1b', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +insert into WSlot values ('WS.106.2a', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +insert into WSlot values ('WS.106.2b', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +insert into WSlot values ('WS.106.3a', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 145 +insert into WSlot values ('WS.106.3b', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +|-- +-- Now create the patch fields and their slots +|-- +insert into PField values ('PF0_1', 'Wallslots basement') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +|-- +-- The cables for these will be made later, so they are unconnected for now +|-- +insert into PSlot values ('PS.base.a1', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 148 +insert into PSlot values ('PS.base.a2', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 149 +insert into PSlot values ('PS.base.a3', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +insert into PSlot values ('PS.base.a4', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 151 +insert into PSlot values ('PS.base.a5', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +insert into PSlot values ('PS.base.a6', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 153 +|-- +-- These are already wired to the wall connectors +|-- +insert into PSlot values ('PS.base.b1', 'PF0_1', '', 'WS.002.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 154 +insert into PSlot values ('PS.base.b2', 'PF0_1', '', 'WS.002.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +insert into PSlot values ('PS.base.b3', 'PF0_1', '', 'WS.002.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 156 +insert into PSlot values ('PS.base.b4', 'PF0_1', '', 'WS.002.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 157 +insert into PSlot values ('PS.base.b5', 'PF0_1', '', 'WS.002.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 158 +insert into PSlot values ('PS.base.b6', 'PF0_1', '', 'WS.002.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 159 +insert into PSlot values ('PS.base.c1', 'PF0_1', '', 'WS.003.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 160 +insert into PSlot values ('PS.base.c2', 'PF0_1', '', 'WS.003.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 161 +insert into PSlot values ('PS.base.c3', 'PF0_1', '', 'WS.003.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 162 +insert into PSlot values ('PS.base.c4', 'PF0_1', '', 'WS.003.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 163 +insert into PSlot values ('PS.base.c5', 'PF0_1', '', 'WS.003.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +insert into PSlot values ('PS.base.c6', 'PF0_1', '', 'WS.003.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 165 +|-- +-- This patchfield will be renamed later into PF0_2 - so its +-- slots references in pfname should follow +|-- +insert into PField values ('PF0_X', 'Phonelines basement') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 166 +insert into PSlot values ('PS.base.ta1', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 167 +insert into PSlot values ('PS.base.ta2', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +insert into PSlot values ('PS.base.ta3', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 169 +insert into PSlot values ('PS.base.ta4', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 170 +insert into PSlot values ('PS.base.ta5', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 171 +insert into PSlot values ('PS.base.ta6', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 172 +insert into PSlot values ('PS.base.tb1', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +insert into PSlot values ('PS.base.tb2', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 174 +insert into PSlot values ('PS.base.tb3', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 175 +insert into PSlot values ('PS.base.tb4', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 176 +insert into PSlot values ('PS.base.tb5', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 177 +insert into PSlot values ('PS.base.tb6', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 178 +insert into PField values ('PF1_1', 'Wallslots first floor') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 179 +insert into PSlot values ('PS.first.a1', 'PF1_1', '', 'WS.101.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 180 +insert into PSlot values ('PS.first.a2', 'PF1_1', '', 'WS.101.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 181 +insert into PSlot values ('PS.first.a3', 'PF1_1', '', 'WS.101.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 182 +insert into PSlot values ('PS.first.a4', 'PF1_1', '', 'WS.101.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 183 +insert into PSlot values ('PS.first.a5', 'PF1_1', '', 'WS.101.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 184 +insert into PSlot values ('PS.first.a6', 'PF1_1', '', 'WS.101.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 185 +insert into PSlot values ('PS.first.b1', 'PF1_1', '', 'WS.102.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +insert into PSlot values ('PS.first.b2', 'PF1_1', '', 'WS.102.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +insert into PSlot values ('PS.first.b3', 'PF1_1', '', 'WS.102.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +insert into PSlot values ('PS.first.b4', 'PF1_1', '', 'WS.102.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +insert into PSlot values ('PS.first.b5', 'PF1_1', '', 'WS.102.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +insert into PSlot values ('PS.first.b6', 'PF1_1', '', 'WS.102.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +insert into PSlot values ('PS.first.c1', 'PF1_1', '', 'WS.105.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 192 +insert into PSlot values ('PS.first.c2', 'PF1_1', '', 'WS.105.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 193 +insert into PSlot values ('PS.first.c3', 'PF1_1', '', 'WS.105.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 194 +insert into PSlot values ('PS.first.c4', 'PF1_1', '', 'WS.105.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 195 +insert into PSlot values ('PS.first.c5', 'PF1_1', '', 'WS.105.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +insert into PSlot values ('PS.first.c6', 'PF1_1', '', 'WS.105.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 197 +insert into PSlot values ('PS.first.d1', 'PF1_1', '', 'WS.106.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 198 +insert into PSlot values ('PS.first.d2', 'PF1_1', '', 'WS.106.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 199 +insert into PSlot values ('PS.first.d3', 'PF1_1', '', 'WS.106.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 200 +insert into PSlot values ('PS.first.d4', 'PF1_1', '', 'WS.106.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 201 +insert into PSlot values ('PS.first.d5', 'PF1_1', '', 'WS.106.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +insert into PSlot values ('PS.first.d6', 'PF1_1', '', 'WS.106.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 203 +|-- +-- Now we wire the wall connectors 1a-2a in room 001 to the +-- patchfield. In the second update we make an error, and +-- correct it after +|-- +update PSlot set backlink = 'WS.001.1a' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 204 +update PSlot set backlink = 'WS.001.1b' where slotname = 'PS.base.a3' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 205 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +== 206 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +== 207 +update PSlot set backlink = 'WS.001.2a' where slotname = 'PS.base.a3' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 208 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +== 209 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +== 210 +update PSlot set backlink = 'WS.001.1b' where slotname = 'PS.base.a2' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 211 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +== 212 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +== 213 +|-- +-- Same procedure for 2b-3b but this time updating the WSlot instead +-- of the PSlot. Due to the triggers the result is the same: +-- WSlot and corresponding PSlot point to each other. +|-- +update WSlot set backlink = 'PS.base.a4' where slotname = 'WS.001.2b' +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: UpdateStmt +== 214 +update WSlot set backlink = 'PS.base.a6' where slotname = 'WS.001.3a' +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: UpdateStmt +== 215 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +== 216 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +== 217 +update WSlot set backlink = 'PS.base.a6' where slotname = 'WS.001.3b' +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: UpdateStmt +== 218 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +== 219 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +== 220 +update WSlot set backlink = 'PS.base.a5' where slotname = 'WS.001.3a' +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: UpdateStmt +== 221 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +== 222 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +== 223 +insert into PField values ('PF1_2', 'Phonelines first floor') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 224 +insert into PSlot values ('PS.first.ta1', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 225 +insert into PSlot values ('PS.first.ta2', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 226 +insert into PSlot values ('PS.first.ta3', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 227 +insert into PSlot values ('PS.first.ta4', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 228 +insert into PSlot values ('PS.first.ta5', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 229 +insert into PSlot values ('PS.first.ta6', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 230 +insert into PSlot values ('PS.first.tb1', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 231 +insert into PSlot values ('PS.first.tb2', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 232 +insert into PSlot values ('PS.first.tb3', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 233 +insert into PSlot values ('PS.first.tb4', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 234 +insert into PSlot values ('PS.first.tb5', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 235 +insert into PSlot values ('PS.first.tb6', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 236 +|-- +-- Fix the wrong name for patchfield PF0_2 +|-- +update PField set name = 'PF0_2' where name = 'PF0_X' +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: UpdateStmt +== 237 +select * from PSlot order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +STMT: SelectStmt +== 238 +select * from WSlot order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +STMT: SelectStmt +== 239 +|-- +-- Install the central phone system and create the phone numbers. +-- They are wired on insert to the patchfields. Again the +-- triggers automatically tell the PSlots to update their +-- backlink field. +|-- +insert into PLine values ('PL.001', '-0', 'Central call', 'PS.base.ta1') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 240 +insert into PLine values ('PL.002', '-101', '', 'PS.base.ta2') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 241 +insert into PLine values ('PL.003', '-102', '', 'PS.base.ta3') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 242 +insert into PLine values ('PL.004', '-103', '', 'PS.base.ta5') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 243 +insert into PLine values ('PL.005', '-104', '', 'PS.base.ta6') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +insert into PLine values ('PL.006', '-106', '', 'PS.base.tb2') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +insert into PLine values ('PL.007', '-108', '', 'PS.base.tb3') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 246 +insert into PLine values ('PL.008', '-109', '', 'PS.base.tb4') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 247 +insert into PLine values ('PL.009', '-121', '', 'PS.base.tb5') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 248 +insert into PLine values ('PL.010', '-122', '', 'PS.base.tb6') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 249 +insert into PLine values ('PL.015', '-134', '', 'PS.first.ta1') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 250 +insert into PLine values ('PL.016', '-137', '', 'PS.first.ta3') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 251 +insert into PLine values ('PL.017', '-139', '', 'PS.first.ta4') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 252 +insert into PLine values ('PL.018', '-362', '', 'PS.first.tb1') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +insert into PLine values ('PL.019', '-363', '', 'PS.first.tb2') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 254 +insert into PLine values ('PL.020', '-364', '', 'PS.first.tb3') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 255 +insert into PLine values ('PL.021', '-365', '', 'PS.first.tb5') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 256 +insert into PLine values ('PL.022', '-367', '', 'PS.first.tb6') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 257 +insert into PLine values ('PL.028', '-501', 'Fax entrance', 'PS.base.ta2') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 258 +insert into PLine values ('PL.029', '-502', 'Fax first floor', 'PS.first.ta1') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 259 +|-- +-- Buy some phones, plug them into the wall and patch the +-- phone lines to the corresponding patchfield slots. +|-- +insert into PHone values ('PH.hc001', 'Hicom standard', 'WS.001.1a') +-- +TABLE: name="phone" schema="" table="phone" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 260 +update PSlot set slotlink = 'PS.base.ta1' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 261 +insert into PHone values ('PH.hc002', 'Hicom standard', 'WS.002.1a') +-- +TABLE: name="phone" schema="" table="phone" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 262 +update PSlot set slotlink = 'PS.base.ta5' where slotname = 'PS.base.b1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 263 +insert into PHone values ('PH.hc003', 'Hicom standard', 'WS.002.2a') +-- +TABLE: name="phone" schema="" table="phone" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 264 +update PSlot set slotlink = 'PS.base.tb2' where slotname = 'PS.base.b3' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 265 +insert into PHone values ('PH.fax001', 'Canon fax', 'WS.001.2a') +-- +TABLE: name="phone" schema="" table="phone" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 266 +update PSlot set slotlink = 'PS.base.ta2' where slotname = 'PS.base.a3' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 267 +|-- +-- Install a hub at one of the patchfields, plug a computers +-- ethernet interface into the wall and patch it to the hub. +|-- +insert into Hub values ('base.hub1', 'Patchfield PF0_1 hub', 16) +-- +TABLE: name="hub" schema="" table="hub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 268 +insert into System values ('orion', 'PC') +-- +TABLE: name="system" schema="" table="system" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +insert into IFace values ('IF', 'orion', 'eth0', 'WS.002.1b') +-- +TABLE: name="iface" schema="" table="iface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 270 +update PSlot set slotlink = 'HS.base.hub1.1' where slotname = 'PS.base.b2' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 271 +|-- +-- Now we take a look at the patchfield +|-- +select * from PField_v1 where pfname = 'PF0_1' order by slotname +-- +TABLE: name="pfield_v1" schema="" table="pfield_v1" ctx=Select +FILTER: schema="" table="" column="pfname" +STMT: SelectStmt +== 272 +select * from PField_v1 where pfname = 'PF0_2' order by slotname +-- +TABLE: name="pfield_v1" schema="" table="pfield_v1" ctx=Select +FILTER: schema="" table="" column="pfname" +STMT: SelectStmt +== 273 +|-- +-- Finally we want errors +|-- +insert into PField values ('PF1_1', 'should fail due to unique index') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 274 +update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 275 +update PSlot set backlink = 'XX.illegal' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 276 +update PSlot set slotlink = 'PS.not.there' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 277 +update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +== 278 +insert into HSlot values ('HS', 'base.hub1', 1, '') +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 279 +insert into HSlot values ('HS', 'base.hub1', 20, '') +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 280 +delete from HSlot +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DML +STMT: DeleteStmt +== 281 +insert into IFace values ('IF', 'notthere', 'eth0', '') +-- +TABLE: name="iface" schema="" table="iface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 282 +insert into IFace values ('IF', 'orion', 'ethernet_interface_name_too_long', '') +-- +TABLE: name="iface" schema="" table="iface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 283 +|-- +-- The following tests are unrelated to the scenario outlined above; +-- they merely exercise specific parts of PL/pgSQL +|-- + +|-- +-- Test recursion, per bug report 7-Sep-01 +|-- +CREATE FUNCTION recursion_test(int,int) RETURNS text AS ' +DECLARE rslt text; +BEGIN + IF $1 <= 0 THEN + rslt = CAST($2 AS TEXT); + ELSE + rslt = CAST($1 AS TEXT) || '','' || recursion_test($1 - 1, $2); + END IF; + RETURN rslt; +END;' LANGUAGE plpgsql +-- +FUNCTION: name="recursion_test" function="recursion_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 284 +SELECT recursion_test(4,3) +-- +FUNCTION: name="recursion_test" function="recursion_test" schema="" ctx=Call +STMT: SelectStmt +== 285 +|-- +-- Test the FOUND magic variable +|-- +CREATE TABLE found_test_tbl (a int) +-- +TABLE: name="found_test_tbl" schema="" table="found_test_tbl" ctx=DDL +STMT: CreateStmt +== 286 +create function test_found() + returns boolean as ' + declare + begin + insert into found_test_tbl values (1); + if FOUND then + insert into found_test_tbl values (2); + end if; + + update found_test_tbl set a = 100 where a = 1; + if FOUND then + insert into found_test_tbl values (3); + end if; + + delete from found_test_tbl where a = 9999; -- matches no rows + if not FOUND then + insert into found_test_tbl values (4); + end if; + + for i in 1 .. 10 loop + -- no need to do anything + end loop; + if FOUND then + insert into found_test_tbl values (5); + end if; + + -- never executes the loop + for i in 2 .. 1 loop + -- no need to do anything + end loop; + if not FOUND then + insert into found_test_tbl values (6); + end if; + return true; + end;' language plpgsql +-- +FUNCTION: name="test_found" function="test_found" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 287 +select test_found() +-- +FUNCTION: name="test_found" function="test_found" schema="" ctx=Call +STMT: SelectStmt +== 288 +select * from found_test_tbl +-- +TABLE: name="found_test_tbl" schema="" table="found_test_tbl" ctx=Select +STMT: SelectStmt +== 289 +|-- +-- Test set-returning functions for PL/pgSQL +|-- + +create function test_table_func_rec() returns setof found_test_tbl as ' +DECLARE + rec RECORD; +BEGIN + FOR rec IN select * from found_test_tbl LOOP + RETURN NEXT rec; + END LOOP; + RETURN; +END;' language plpgsql +-- +FUNCTION: name="test_table_func_rec" function="test_table_func_rec" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 290 +select * from test_table_func_rec() +-- +FUNCTION: name="test_table_func_rec" function="test_table_func_rec" schema="" ctx=Call +STMT: SelectStmt +== 291 +create function test_table_func_row() returns setof found_test_tbl as ' +DECLARE + row found_test_tbl%ROWTYPE; +BEGIN + FOR row IN select * from found_test_tbl LOOP + RETURN NEXT row; + END LOOP; + RETURN; +END;' language plpgsql +-- +FUNCTION: name="test_table_func_row" function="test_table_func_row" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 292 +select * from test_table_func_row() +-- +FUNCTION: name="test_table_func_row" function="test_table_func_row" schema="" ctx=Call +STMT: SelectStmt +== 293 +create function test_ret_set_scalar(int,int) returns setof int as ' +DECLARE + i int; +BEGIN + FOR i IN $1 .. $2 LOOP + RETURN NEXT i + 1; + END LOOP; + RETURN; +END;' language plpgsql +-- +FUNCTION: name="test_ret_set_scalar" function="test_ret_set_scalar" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 294 +select * from test_ret_set_scalar(1,10) +-- +FUNCTION: name="test_ret_set_scalar" function="test_ret_set_scalar" schema="" ctx=Call +STMT: SelectStmt +== 295 +create function test_ret_set_rec_dyn(int) returns setof record as ' +DECLARE + retval RECORD; +BEGIN + IF $1 > 10 THEN + SELECT INTO retval 5, 10, 15; + RETURN NEXT retval; + RETURN NEXT retval; + ELSE + SELECT INTO retval 50, 5::numeric, ''xxx''::text; + RETURN NEXT retval; + RETURN NEXT retval; + END IF; + RETURN; +END;' language plpgsql +-- +FUNCTION: name="test_ret_set_rec_dyn" function="test_ret_set_rec_dyn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 296 +SELECT * FROM test_ret_set_rec_dyn(1500) AS (a int, b int, c int) +-- +FUNCTION: name="test_ret_set_rec_dyn" function="test_ret_set_rec_dyn" schema="" ctx=Call +STMT: SelectStmt +== 297 +SELECT * FROM test_ret_set_rec_dyn(5) AS (a int, b numeric, c text) +-- +FUNCTION: name="test_ret_set_rec_dyn" function="test_ret_set_rec_dyn" schema="" ctx=Call +STMT: SelectStmt +== 298 +create function test_ret_rec_dyn(int) returns record as ' +DECLARE + retval RECORD; +BEGIN + IF $1 > 10 THEN + SELECT INTO retval 5, 10, 15; + RETURN retval; + ELSE + SELECT INTO retval 50, 5::numeric, ''xxx''::text; + RETURN retval; + END IF; +END;' language plpgsql +-- +FUNCTION: name="test_ret_rec_dyn" function="test_ret_rec_dyn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 299 +SELECT * FROM test_ret_rec_dyn(1500) AS (a int, b int, c int) +-- +FUNCTION: name="test_ret_rec_dyn" function="test_ret_rec_dyn" schema="" ctx=Call +STMT: SelectStmt +== 300 +SELECT * FROM test_ret_rec_dyn(5) AS (a int, b numeric, c text) +-- +FUNCTION: name="test_ret_rec_dyn" function="test_ret_rec_dyn" schema="" ctx=Call +STMT: SelectStmt +== 301 +|-- +-- Test some simple polymorphism cases. +|-- + +create function f1(x anyelement) returns anyelement as $$ +begin + return x + 1; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 302 +select f1(42) as int, f1(4.5) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 303 +select f1(point(3,4)) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 304 +-- fail for lack of + operator + +drop function f1(x anyelement) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 305 +create function f1(x anyelement) returns anyarray as $$ +begin + return array[x + 1, x + 2]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 306 +select f1(42) as int, f1(4.5) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 307 +drop function f1(x anyelement) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 308 +create function f1(x anyarray) returns anyelement as $$ +begin + return x[1]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 309 +select f1(array[2,4]) as int, f1(array[4.5, 7.7]) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 310 +select f1(stavalues1) from pg_statistic +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 311 +-- fail, can't infer element type + +drop function f1(x anyarray) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 312 +create function f1(x anyarray) returns anyarray as $$ +begin + return x; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 313 +select f1(array[2,4]) as int, f1(array[4.5, 7.7]) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 314 +select f1(stavalues1) from pg_statistic +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 315 +-- fail, can't infer element type + +drop function f1(x anyarray) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 316 +-- fail, can't infer type: +create function f1(x anyelement) returns anyrange as $$ +begin + return array[x + 1, x + 2]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 317 +create function f1(x anyrange) returns anyarray as $$ +begin + return array[lower(x), upper(x)]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 318 +select f1(int4range(42, 49)) as int, f1(float8range(4.5, 7.8)) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +== 319 +drop function f1(x anyrange) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 320 +create function f1(x anycompatible, y anycompatible) returns anycompatiblearray as $$ +begin + return array[x, y]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 321 +select f1(2, 4) as int, f1(2, 4.5) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 322 +drop function f1(x anycompatible, y anycompatible) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 323 +create function f1(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$ +begin + return array[lower(x), upper(x), y, z]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 324 +select f1(int4range(42, 49), 11, 2::smallint) as int, f1(float8range(4.5, 7.8), 7.8, 11::real) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +== 325 +select f1(int4range(42, 49), 11, 4.5) as fail +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 326 +-- range type doesn't fit + +drop function f1(x anycompatiblerange, y anycompatible, z anycompatible) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 327 +-- fail, can't infer type: +create function f1(x anycompatible) returns anycompatiblerange as $$ +begin + return array[x + 1, x + 2]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 328 +create function f1(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$ +begin + return x; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 329 +select f1(int4range(42, 49), array[11]) as int, f1(float8range(4.5, 7.8), array[7]) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +== 330 +drop function f1(x anycompatiblerange, y anycompatiblearray) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 331 +create function f1(a anyelement, b anyarray, + c anycompatible, d anycompatible, + OUT x anyarray, OUT y anycompatiblearray) +as $$ +begin + x := a || b; + y := array[c, d]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 332 +select x, pg_typeof(x), y, pg_typeof(y) + from f1(11, array[1, 2], 42, 34.5) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 333 +select x, pg_typeof(x), y, pg_typeof(y) + from f1(11, array[1, 2], point(1,2), point(3,4)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 334 +select x, pg_typeof(x), y, pg_typeof(y) + from f1(11, '{1,2}', point(1,2), '(3,4)') +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 335 +select x, pg_typeof(x), y, pg_typeof(y) + from f1(11, array[1, 2.2], 42, 34.5) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 336 +-- fail + +drop function f1(a anyelement, b anyarray, + c anycompatible, d anycompatible) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 337 +|-- +-- Test handling of OUT parameters, including polymorphic cases. +-- Note that RETURN is optional with OUT params; we try both ways. +|-- + +-- wrong way to do it: +create function f1(in i int, out j int) returns int as $$ +begin + return i+1; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 338 +create function f1(in i int, out j int) as $$ +begin + j := i+1; + return; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 339 +select f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 340 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 341 +create or replace function f1(inout i int) as $$ +begin + i := i+1; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 342 +select f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 343 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 344 +drop function f1(int) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 345 +create function f1(in i int, out j int) returns setof int as $$ +begin + j := i+1; + return next; + j := i+2; + return next; + return; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 346 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 347 +drop function f1(int) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 348 +create function f1(in i int, out j int, out k text) as $$ +begin + j := i; + j := j+1; + k := 'foo'; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 349 +select f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 350 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 351 +drop function f1(int) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 352 +create function f1(in i int, out j int, out k text) returns setof record as $$ +begin + j := i+1; + k := 'foo'; + return next; + j := j+1; + k := 'foot'; + return next; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 353 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +== 354 +drop function f1(int) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +== 355 +create function duplic(in i anyelement, out j anyelement, out k anyarray) as $$ +begin + j := i; + k := array[j,j]; + return; +end$$ language plpgsql +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 356 +select * from duplic(42) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=Call +STMT: SelectStmt +== 357 +select * from duplic('foo'::text) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=Call +STMT: SelectStmt +== 358 +drop function duplic(anyelement) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=DDL +STMT: DropStmt +== 359 +create function duplic(in i anycompatiblerange, out j anycompatible, out k anycompatiblearray) as $$ +begin + j := lower(i); + k := array[lower(i),upper(i)]; + return; +end$$ language plpgsql +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 360 +select * from duplic(int4range(42,49)) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 361 +select * from duplic(textrange('aaa', 'bbb')) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 362 +drop function duplic(anycompatiblerange) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=DDL +STMT: DropStmt +== 363 +|-- +-- test PERFORM +|-- + +create table perform_test ( + a INT, + b INT +) +-- +TABLE: name="perform_test" schema="" table="perform_test" ctx=DDL +STMT: CreateStmt +== 364 +create function perform_simple_func(int) returns boolean as ' +BEGIN + IF $1 < 20 THEN + INSERT INTO perform_test VALUES ($1, $1 + 10); + RETURN TRUE; + ELSE + RETURN FALSE; + END IF; +END;' language plpgsql +-- +FUNCTION: name="perform_simple_func" function="perform_simple_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 365 +create function perform_test_func() returns void as ' +BEGIN + IF FOUND then + INSERT INTO perform_test VALUES (100, 100); + END IF; + + PERFORM perform_simple_func(5); + + IF FOUND then + INSERT INTO perform_test VALUES (100, 100); + END IF; + + PERFORM perform_simple_func(50); + + IF FOUND then + INSERT INTO perform_test VALUES (100, 100); + END IF; + + RETURN; +END;' language plpgsql +-- +FUNCTION: name="perform_test_func" function="perform_test_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 366 +SELECT perform_test_func() +-- +FUNCTION: name="perform_test_func" function="perform_test_func" schema="" ctx=Call +STMT: SelectStmt +== 367 +SELECT * FROM perform_test +-- +TABLE: name="perform_test" schema="" table="perform_test" ctx=Select +STMT: SelectStmt +== 368 +drop table perform_test +-- +TABLE: name="perform_test" schema="" table="perform_test" ctx=DDL +STMT: DropStmt +== 369 +|-- +-- Test proper snapshot handling in simple expressions +|-- + +create temp table users(login text, id serial) +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: CreateStmt +== 370 +create function sp_id_user(a_login text) returns int as $$ +declare x int; +begin + select into x id from users where login = a_login; + if found then return x; end if; + return 0; +end$$ language plpgsql stable +-- +FUNCTION: name="sp_id_user" function="sp_id_user" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 371 +insert into users values('user1') +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 372 +select sp_id_user('user1') +-- +FUNCTION: name="sp_id_user" function="sp_id_user" schema="" ctx=Call +STMT: SelectStmt +== 373 +select sp_id_user('userx') +-- +FUNCTION: name="sp_id_user" function="sp_id_user" schema="" ctx=Call +STMT: SelectStmt +== 374 +create function sp_add_user(a_login text) returns int as $$ +declare my_id_user int; +begin + my_id_user = sp_id_user( a_login ); + IF my_id_user > 0 THEN + RETURN -1; -- error code for existing user + END IF; + INSERT INTO users ( login ) VALUES ( a_login ); + my_id_user = sp_id_user( a_login ); + IF my_id_user = 0 THEN + RETURN -2; -- error code for insertion failure + END IF; + RETURN my_id_user; +end$$ language plpgsql +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 375 +select sp_add_user('user1') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +== 376 +select sp_add_user('user2') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +== 377 +select sp_add_user('user2') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +== 378 +select sp_add_user('user3') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +== 379 +select sp_add_user('user3') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +== 380 +drop function sp_add_user(text) +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=DDL +STMT: DropStmt +== 381 +drop function sp_id_user(text) +-- +FUNCTION: name="sp_id_user" function="sp_id_user" schema="" ctx=DDL +STMT: DropStmt +== 382 +|-- +-- tests for refcursors +|-- +create table rc_test (a int, b int) +-- +TABLE: name="rc_test" schema="" table="rc_test" ctx=DDL +STMT: CreateStmt +== 383 +copy rc_test from stdin +-- +TABLE: name="rc_test" schema="" table="rc_test" ctx=Select +STMT: CopyStmt +== 384 +create function return_unnamed_refcursor() returns refcursor as $$ +declare + rc refcursor; +begin + open rc for select a from rc_test; + return rc; +end +$$ language plpgsql +-- +FUNCTION: name="return_unnamed_refcursor" function="return_unnamed_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 385 +create function use_refcursor(rc refcursor) returns int as $$ +declare + rc refcursor; + x record; +begin + rc := return_unnamed_refcursor(); + fetch next from rc into x; + return x.a; +end +$$ language plpgsql +-- +FUNCTION: name="use_refcursor" function="use_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 386 +select use_refcursor(return_unnamed_refcursor()) +-- +FUNCTION: name="use_refcursor" function="use_refcursor" schema="" ctx=Call +FUNCTION: name="return_unnamed_refcursor" function="return_unnamed_refcursor" schema="" ctx=Call +STMT: SelectStmt +== 387 +create function return_refcursor(rc refcursor) returns refcursor as $$ +begin + open rc for select a from rc_test; + return rc; +end +$$ language plpgsql +-- +FUNCTION: name="return_refcursor" function="return_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 388 +create function refcursor_test1(refcursor) returns refcursor as $$ +begin + perform return_refcursor($1); + return $1; +end +$$ language plpgsql +-- +FUNCTION: name="refcursor_test1" function="refcursor_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 389 +begin +-- +STMT: TransactionStmt +== 390 +select refcursor_test1('test1') +-- +FUNCTION: name="refcursor_test1" function="refcursor_test1" schema="" ctx=Call +STMT: SelectStmt +== 391 +fetch next in test1 +-- +STMT: FetchStmt +== 392 +select refcursor_test1('test2') +-- +FUNCTION: name="refcursor_test1" function="refcursor_test1" schema="" ctx=Call +STMT: SelectStmt +== 393 +fetch all from test2 +-- +STMT: FetchStmt +== 394 +commit +-- +STMT: TransactionStmt +== 395 +-- should fail +fetch next from test1 +-- +STMT: FetchStmt +== 396 +create function refcursor_test2(int, int) returns boolean as $$ +declare + c1 cursor (param1 int, param2 int) for select * from rc_test where a > param1 and b > param2; + nonsense record; +begin + open c1($1, $2); + fetch c1 into nonsense; + close c1; + if found then + return true; + else + return false; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="refcursor_test2" function="refcursor_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 397 +select refcursor_test2(20000, 20000) as "Should be false", + refcursor_test2(20, 20) as "Should be true" +-- +FUNCTION: name="refcursor_test2" function="refcursor_test2" schema="" ctx=Call +FUNCTION: name="refcursor_test2" function="refcursor_test2" schema="" ctx=Call +STMT: SelectStmt +== 398 +-- should fail +create function constant_refcursor() returns refcursor as $$ +declare + rc constant refcursor; +begin + open rc for select a from rc_test; + return rc; +end +$$ language plpgsql +-- +FUNCTION: name="constant_refcursor" function="constant_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 399 +select constant_refcursor() +-- +FUNCTION: name="constant_refcursor" function="constant_refcursor" schema="" ctx=Call +STMT: SelectStmt +== 400 +-- but it's okay like this +create or replace function constant_refcursor() returns refcursor as $$ +declare + rc constant refcursor := 'my_cursor_name'; +begin + open rc for select a from rc_test; + return rc; +end +$$ language plpgsql +-- +FUNCTION: name="constant_refcursor" function="constant_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 401 +select constant_refcursor() +-- +FUNCTION: name="constant_refcursor" function="constant_refcursor" schema="" ctx=Call +STMT: SelectStmt +== 402 +|-- +-- tests for cursors with named parameter arguments +|-- +create function namedparmcursor_test1(int, int) returns boolean as $$ +declare + c1 cursor (param1 int, param12 int) for select * from rc_test where a > param1 and b > param12; + nonsense record; +begin + open c1(param12 := $2, param1 := $1); + fetch c1 into nonsense; + close c1; + if found then + return true; + else + return false; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test1" function="namedparmcursor_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 403 +select namedparmcursor_test1(20000, 20000) as "Should be false", + namedparmcursor_test1(20, 20) as "Should be true" +-- +FUNCTION: name="namedparmcursor_test1" function="namedparmcursor_test1" schema="" ctx=Call +FUNCTION: name="namedparmcursor_test1" function="namedparmcursor_test1" schema="" ctx=Call +STMT: SelectStmt +== 404 +-- mixing named and positional argument notations +create function namedparmcursor_test2(int, int) returns boolean as $$ +declare + c1 cursor (param1 int, param2 int) for select * from rc_test where a > param1 and b > param2; + nonsense record; +begin + open c1(param1 := $1, $2); + fetch c1 into nonsense; + close c1; + if found then + return true; + else + return false; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test2" function="namedparmcursor_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 405 +select namedparmcursor_test2(20, 20) +-- +FUNCTION: name="namedparmcursor_test2" function="namedparmcursor_test2" schema="" ctx=Call +STMT: SelectStmt +== 406 +-- mixing named and positional: param2 is given twice, once in named notation +-- and second time in positional notation. Should throw an error at parse time +create function namedparmcursor_test3() returns void as $$ +declare + c1 cursor (param1 int, param2 int) for select * from rc_test where a > param1 and b > param2; +begin + open c1(param2 := 20, 21); +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test3" function="namedparmcursor_test3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 407 +-- mixing named and positional: same as previous test, but param1 is duplicated +create function namedparmcursor_test4() returns void as $$ +declare + c1 cursor (param1 int, param2 int) for select * from rc_test where a > param1 and b > param2; +begin + open c1(20, param1 := 21); +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test4" function="namedparmcursor_test4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 408 +-- duplicate named parameter, should throw an error at parse time +create function namedparmcursor_test5() returns void as $$ +declare + c1 cursor (p1 int, p2 int) for + select * from tenk1 where thousand = p1 and tenthous = p2; +begin + open c1 (p2 := 77, p2 := 42); +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test5" function="namedparmcursor_test5" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 409 +-- not enough parameters, should throw an error at parse time +create function namedparmcursor_test6() returns void as $$ +declare + c1 cursor (p1 int, p2 int) for + select * from tenk1 where thousand = p1 and tenthous = p2; +begin + open c1 (p2 := 77); +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test6" function="namedparmcursor_test6" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 410 +-- division by zero runtime error, the context given in the error message +-- should be sensible +create function namedparmcursor_test7() returns void as $$ +declare + c1 cursor (p1 int, p2 int) for + select * from tenk1 where thousand = p1 and tenthous = p2; +begin + open c1 (p2 := 77, p1 := 42/0); +end $$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test7" function="namedparmcursor_test7" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 411 +select namedparmcursor_test7() +-- +FUNCTION: name="namedparmcursor_test7" function="namedparmcursor_test7" schema="" ctx=Call +STMT: SelectStmt +== 412 +-- check that line comments work correctly within the argument list +-- (this used to require a special hack in the code; it no longer does, +-- but let's keep the test anyway) +create function namedparmcursor_test8() returns int4 as $$ +declare + c1 cursor (p1 int, p2 int) for + select count(*) from tenk1 where thousand = p1 and tenthous = p2; + n int4; +begin + open c1 (77 -- test + , 42); + fetch c1 into n; + return n; +end $$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test8" function="namedparmcursor_test8" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 413 +select namedparmcursor_test8() +-- +FUNCTION: name="namedparmcursor_test8" function="namedparmcursor_test8" schema="" ctx=Call +STMT: SelectStmt +== 414 +-- cursor parameter name can match plpgsql variable or unreserved keyword +create function namedparmcursor_test9(p1 int) returns int4 as $$ +declare + c1 cursor (p1 int, p2 int, debug int) for + select count(*) from tenk1 where thousand = p1 and tenthous = p2 + and four = debug; + p2 int4 := 1006; + n int4; +begin + open c1 (p1 := p1, p2 := p2, debug := 2); + fetch c1 into n; + return n; +end $$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test9" function="namedparmcursor_test9" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 415 +select namedparmcursor_test9(6) +-- +FUNCTION: name="namedparmcursor_test9" function="namedparmcursor_test9" schema="" ctx=Call +STMT: SelectStmt +== 416 +|-- +-- tests for "raise" processing +|-- +create function raise_test1(int) returns int as $$ +begin + raise notice 'This message has too many parameters!', $1; + return $1; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test1" function="raise_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 417 +create function raise_test2(int) returns int as $$ +begin + raise notice 'This message has too few parameters: %, %, %', $1, $1; + return $1; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test2" function="raise_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 418 +create function raise_test3(int) returns int as $$ +begin + raise notice 'This message has no parameters (despite having %% signs in it)!'; + return $1; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test3" function="raise_test3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 419 +select raise_test3(1) +-- +FUNCTION: name="raise_test3" function="raise_test3" schema="" ctx=Call +STMT: SelectStmt +== 420 +-- Test re-RAISE inside a nested exception block. This case is allowed +-- by Oracle's PL/SQL but was handled differently by PG before 9.1. + +CREATE FUNCTION reraise_test() RETURNS void AS $$ +BEGIN + BEGIN + RAISE syntax_error; + EXCEPTION + WHEN syntax_error THEN + BEGIN + raise notice 'exception % thrown in inner block, reraising', sqlerrm; + RAISE; + EXCEPTION + WHEN OTHERS THEN + raise notice 'RIGHT - exception % caught in inner block', sqlerrm; + END; + END; +EXCEPTION + WHEN OTHERS THEN + raise notice 'WRONG - exception % caught in outer block', sqlerrm; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="reraise_test" function="reraise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 421 +SELECT reraise_test() +-- +FUNCTION: name="reraise_test" function="reraise_test" schema="" ctx=Call +STMT: SelectStmt +== 422 +|-- +-- reject function definitions that contain malformed SQL queries at +-- compile-time, where possible +|-- +create function bad_sql1() returns int as $$ +declare a int; +begin + a := 5; + Johnny Yuma; + a := 10; + return a; +end$$ language plpgsql +-- +FUNCTION: name="bad_sql1" function="bad_sql1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 423 +create function bad_sql2() returns int as $$ +declare r record; +begin + for r in select I fought the law, the law won LOOP + raise notice 'in loop'; + end loop; + return 5; +end;$$ language plpgsql +-- +FUNCTION: name="bad_sql2" function="bad_sql2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 424 +-- a RETURN expression is mandatory, except for void-returning +-- functions, where it is not allowed +create function missing_return_expr() returns int as $$ +begin + return ; +end;$$ language plpgsql +-- +FUNCTION: name="missing_return_expr" function="missing_return_expr" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 425 +create function void_return_expr() returns void as $$ +begin + return 5; +end;$$ language plpgsql +-- +FUNCTION: name="void_return_expr" function="void_return_expr" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 426 +-- VOID functions are allowed to omit RETURN +create function void_return_expr() returns void as $$ +begin + perform 2+2; +end;$$ language plpgsql +-- +FUNCTION: name="void_return_expr" function="void_return_expr" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 427 +select void_return_expr() +-- +FUNCTION: name="void_return_expr" function="void_return_expr" schema="" ctx=Call +STMT: SelectStmt +== 428 +-- but ordinary functions are not +create function missing_return_expr() returns int as $$ +begin + perform 2+2; +end;$$ language plpgsql +-- +FUNCTION: name="missing_return_expr" function="missing_return_expr" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 429 +select missing_return_expr() +-- +FUNCTION: name="missing_return_expr" function="missing_return_expr" schema="" ctx=Call +STMT: SelectStmt +== 430 +drop function void_return_expr() +-- +FUNCTION: name="void_return_expr" function="void_return_expr" schema="" ctx=DDL +STMT: DropStmt +== 431 +drop function missing_return_expr() +-- +FUNCTION: name="missing_return_expr" function="missing_return_expr" schema="" ctx=DDL +STMT: DropStmt +== 432 +|-- +-- EXECUTE ... INTO test +|-- + +create table eifoo (i integer, y integer) +-- +TABLE: name="eifoo" schema="" table="eifoo" ctx=DDL +STMT: CreateStmt +== 433 +create type eitype as (i integer, y integer) +-- +STMT: CompositeTypeStmt +== 434 +create or replace function execute_into_test(varchar) returns record as $$ +declare + _r record; + _rt eifoo%rowtype; + _v eitype; + i int; + j int; + k int; +begin + execute 'insert into '||$1||' values(10,15)'; + execute 'select (row).* from (select row(10,1)::eifoo) s' into _r; + raise notice '% %', _r.i, _r.y; + execute 'select * from '||$1||' limit 1' into _rt; + raise notice '% %', _rt.i, _rt.y; + execute 'select *, 20 from '||$1||' limit 1' into i, j, k; + raise notice '% % %', i, j, k; + execute 'select 1,2' into _v; + return _v; +end; $$ language plpgsql +-- +FUNCTION: name="execute_into_test" function="execute_into_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 435 +select execute_into_test('eifoo') +-- +FUNCTION: name="execute_into_test" function="execute_into_test" schema="" ctx=Call +STMT: SelectStmt +== 436 +drop table eifoo cascade +-- +TABLE: name="eifoo" schema="" table="eifoo" ctx=DDL +STMT: DropStmt +== 437 +drop type eitype cascade +-- +STMT: DropStmt +== 438 +|-- +-- SQLSTATE and SQLERRM test +|-- + +create function excpt_test1() returns void as $$ +begin + raise notice '% %', sqlstate, sqlerrm; +end; $$ language plpgsql +-- +FUNCTION: name="excpt_test1" function="excpt_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 439 +-- should fail: SQLSTATE and SQLERRM are only in defined EXCEPTION +-- blocks +select excpt_test1() +-- +FUNCTION: name="excpt_test1" function="excpt_test1" schema="" ctx=Call +STMT: SelectStmt +== 440 +create function excpt_test2() returns void as $$ +begin + begin + begin + raise notice '% %', sqlstate, sqlerrm; + end; + end; +end; $$ language plpgsql +-- +FUNCTION: name="excpt_test2" function="excpt_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 441 +-- should fail +select excpt_test2() +-- +FUNCTION: name="excpt_test2" function="excpt_test2" schema="" ctx=Call +STMT: SelectStmt +== 442 +create function excpt_test3() returns void as $$ +begin + begin + raise exception 'user exception'; + exception when others then + raise notice 'caught exception % %', sqlstate, sqlerrm; + begin + raise notice '% %', sqlstate, sqlerrm; + perform 10/0; + exception + when substring_error then + -- this exception handler shouldn't be invoked + raise notice 'unexpected exception: % %', sqlstate, sqlerrm; + when division_by_zero then + raise notice 'caught exception % %', sqlstate, sqlerrm; + end; + raise notice '% %', sqlstate, sqlerrm; + end; +end; $$ language plpgsql +-- +FUNCTION: name="excpt_test3" function="excpt_test3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 443 +select excpt_test3() +-- +FUNCTION: name="excpt_test3" function="excpt_test3" schema="" ctx=Call +STMT: SelectStmt +== 444 +create function excpt_test4() returns text as $$ +begin + begin perform 1/0; + exception when others then return sqlerrm; end; +end; $$ language plpgsql +-- +FUNCTION: name="excpt_test4" function="excpt_test4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 445 +select excpt_test4() +-- +FUNCTION: name="excpt_test4" function="excpt_test4" schema="" ctx=Call +STMT: SelectStmt +== 446 +drop function excpt_test1() +-- +FUNCTION: name="excpt_test1" function="excpt_test1" schema="" ctx=DDL +STMT: DropStmt +== 447 +drop function excpt_test2() +-- +FUNCTION: name="excpt_test2" function="excpt_test2" schema="" ctx=DDL +STMT: DropStmt +== 448 +drop function excpt_test3() +-- +FUNCTION: name="excpt_test3" function="excpt_test3" schema="" ctx=DDL +STMT: DropStmt +== 449 +drop function excpt_test4() +-- +FUNCTION: name="excpt_test4" function="excpt_test4" schema="" ctx=DDL +STMT: DropStmt +== 450 +-- parameters of raise stmt can be expressions +create function raise_exprs() returns void as $$ +declare + a integer[] = '{10,20,30}'; + c varchar = 'xyz'; + i integer; +begin + i := 2; + raise notice '%; %; %; %; %; %', a, a[i], c, (select c || 'abc'), row(10,'aaa',NULL,30), NULL; +end;$$ language plpgsql +-- +FUNCTION: name="raise_exprs" function="raise_exprs" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 451 +select raise_exprs() +-- +FUNCTION: name="raise_exprs" function="raise_exprs" schema="" ctx=Call +STMT: SelectStmt +== 452 +drop function raise_exprs() +-- +FUNCTION: name="raise_exprs" function="raise_exprs" schema="" ctx=DDL +STMT: DropStmt +== 453 +-- regression test: verify that multiple uses of same plpgsql datum within +-- a SQL command all get mapped to the same $n parameter. The return value +-- of the SELECT is not important, we only care that it doesn't fail with +-- a complaint about an ungrouped column reference. +create function multi_datum_use(p1 int) returns bool as $$ +declare + x int; + y int; +begin + select into x,y unique1/p1, unique1/$1 from tenk1 group by unique1/p1; + return x = y; +end$$ language plpgsql +-- +FUNCTION: name="multi_datum_use" function="multi_datum_use" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 454 +select multi_datum_use(42) +-- +FUNCTION: name="multi_datum_use" function="multi_datum_use" schema="" ctx=Call +STMT: SelectStmt +== 455 +|-- +-- Test STRICT limiter in both planned and EXECUTE invocations. +-- Note that a data-modifying query is quasi strict (disallow multi rows) +-- by default in the planned case, but not in EXECUTE. +|-- + +create temp table foo (f1 int, f2 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 456 +insert into foo values (1,2), (3,4) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 457 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should work + insert into foo values(5,6) returning * into x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 458 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 459 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail due to implicit strict + insert into foo values(7,8),(9,10) returning * into x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 460 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 461 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should work + execute 'insert into foo values(5,6) returning *' into x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 462 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 463 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- this should work since EXECUTE isn't as picky + execute 'insert into foo values(7,8),(9,10) returning *' into x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 464 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 465 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 466 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should work + select * from foo where f1 = 3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 467 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 468 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail, no rows + select * from foo where f1 = 0 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 469 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 470 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail, too many rows + select * from foo where f1 > 3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 471 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 472 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should work + execute 'select * from foo where f1 = 3' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 473 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 474 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail, no rows + execute 'select * from foo where f1 = 0' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 475 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 476 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail, too many rows + execute 'select * from foo where f1 > 3' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 477 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 478 +drop function stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: DropStmt +== 479 +-- test printing parameters after failure due to STRICT + +set plpgsql.print_strict_params to true +-- +STMT: VariableSetStmt +== 480 +create or replace function stricttest() returns void as $$ +declare +x record; +p1 int := 2; +p3 text := 'foo'; +begin + -- no rows + select * from foo where f1 = p1 and f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 481 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 482 +create or replace function stricttest() returns void as $$ +declare +x record; +p1 int := 2; +p3 text := $a$'Valame Dios!' dijo Sancho; 'no le dije yo a vuestra merced que mirase bien lo que hacia?'$a$; +begin + -- no rows + select * from foo where f1 = p1 and f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 483 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 484 +create or replace function stricttest() returns void as $$ +declare +x record; +p1 int := 2; +p3 text := 'foo'; +begin + -- too many rows + select * from foo where f1 > p1 or f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 485 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 486 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- too many rows, no params + select * from foo where f1 > 3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 487 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 488 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- no rows + execute 'select * from foo where f1 = $1 or f1::text = $2' using 0, 'foo' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 489 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 490 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- too many rows + execute 'select * from foo where f1 > $1' using 1 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 491 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 492 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- too many rows, no parameters + execute 'select * from foo where f1 > 3' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 493 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 494 +create or replace function stricttest() returns void as $$ +-- override the global +#print_strict_params off +declare +x record; +p1 int := 2; +p3 text := 'foo'; +begin + -- too many rows + select * from foo where f1 > p1 or f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 495 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 496 +reset plpgsql.print_strict_params +-- +STMT: VariableSetStmt +== 497 +create or replace function stricttest() returns void as $$ +-- override the global +#print_strict_params on +declare +x record; +p1 int := 2; +p3 text := 'foo'; +begin + -- too many rows + select * from foo where f1 > p1 or f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 498 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +== 499 +-- test warnings and errors +set plpgsql.extra_warnings to 'all' +-- +STMT: VariableSetStmt +== 500 +set plpgsql.extra_warnings to 'none' +-- +STMT: VariableSetStmt +== 501 +set plpgsql.extra_errors to 'all' +-- +STMT: VariableSetStmt +== 502 +set plpgsql.extra_errors to 'none' +-- +STMT: VariableSetStmt +== 503 +-- test warnings when shadowing a variable + +set plpgsql.extra_warnings to 'shadowed_variables' +-- +STMT: VariableSetStmt +== 504 +-- simple shadowing of input and output parameters +create or replace function shadowtest(in1 int) + returns table (out1 int) as $$ +declare +in1 int; +out1 int; +begin +end +$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 505 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +== 506 +set plpgsql.extra_warnings to 'shadowed_variables' +-- +STMT: VariableSetStmt +== 507 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +== 508 +create or replace function shadowtest(in1 int) + returns table (out1 int) as $$ +declare +in1 int; +out1 int; +begin +end +$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 509 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +== 510 +drop function shadowtest(int) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: DropStmt +== 511 +-- shadowing in a second DECLARE block +create or replace function shadowtest() + returns void as $$ +declare +f1 int; +begin + declare + f1 int; + begin + end; +end$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 512 +drop function shadowtest() +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: DropStmt +== 513 +-- several levels of shadowing +create or replace function shadowtest(in1 int) + returns void as $$ +declare +in1 int; +begin + declare + in1 int; + begin + end; +end$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 514 +drop function shadowtest(int) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: DropStmt +== 515 +-- shadowing in cursor definitions +create or replace function shadowtest() + returns void as $$ +declare +f1 int; +c1 cursor (f1 int) for select 1; +begin +end$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 516 +drop function shadowtest() +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: DropStmt +== 517 +-- test errors when shadowing a variable + +set plpgsql.extra_errors to 'shadowed_variables' +-- +STMT: VariableSetStmt +== 518 +create or replace function shadowtest(f1 int) + returns boolean as $$ +declare f1 int; begin return 1; end $$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 519 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +== 520 +reset plpgsql.extra_errors +-- +STMT: VariableSetStmt +== 521 +reset plpgsql.extra_warnings +-- +STMT: VariableSetStmt +== 522 +create or replace function shadowtest(f1 int) + returns boolean as $$ +declare f1 int; begin return 1; end $$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 523 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +== 524 +-- runtime extra checks +set plpgsql.extra_warnings to 'too_many_rows' +-- +STMT: VariableSetStmt +== 525 +do $$ +declare x int; +begin + select v from generate_series(1,2) g(v) into x; +end; +$$ +-- +STMT: DoStmt +== 526 +set plpgsql.extra_errors to 'too_many_rows' +-- +STMT: VariableSetStmt +== 527 +do $$ +declare x int; +begin + select v from generate_series(1,2) g(v) into x; +end; +$$ +-- +STMT: DoStmt +== 528 +reset plpgsql.extra_errors +-- +STMT: VariableSetStmt +== 529 +reset plpgsql.extra_warnings +-- +STMT: VariableSetStmt +== 530 +set plpgsql.extra_warnings to 'strict_multi_assignment' +-- +STMT: VariableSetStmt +== 531 +do $$ +declare + x int; + y int; +begin + select 1 into x, y; + select 1,2 into x, y; + select 1,2,3 into x, y; +end +$$ +-- +STMT: DoStmt +== 532 +set plpgsql.extra_errors to 'strict_multi_assignment' +-- +STMT: VariableSetStmt +== 533 +do $$ +declare + x int; + y int; +begin + select 1 into x, y; + select 1,2 into x, y; + select 1,2,3 into x, y; +end +$$ +-- +STMT: DoStmt +== 534 +create table test_01(a int, b int, c int) +-- +TABLE: name="test_01" schema="" table="test_01" ctx=DDL +STMT: CreateStmt +== 535 +alter table test_01 drop column a +-- +TABLE: name="test_01" schema="" table="test_01" ctx=DDL +STMT: AlterTableStmt +== 536 +-- the check is active only when source table is not empty +insert into test_01 values(10,20) +-- +TABLE: name="test_01" schema="" table="test_01" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 537 +do $$ +declare + x int; + y int; +begin + select * from test_01 into x, y; -- should be ok + raise notice 'ok'; + select * from test_01 into x; -- should to fail +end; +$$ +-- +STMT: DoStmt +== 538 +do $$ +declare + t test_01; +begin + select 1, 2 into t; -- should be ok + raise notice 'ok'; + select 1, 2, 3 into t; -- should fail; +end; +$$ +-- +STMT: DoStmt +== 539 +do $$ +declare + t test_01; +begin + select 1 into t; -- should fail; +end; +$$ +-- +STMT: DoStmt +== 540 +drop table test_01 +-- +TABLE: name="test_01" schema="" table="test_01" ctx=DDL +STMT: DropStmt +== 541 +reset plpgsql.extra_errors +-- +STMT: VariableSetStmt +== 542 +reset plpgsql.extra_warnings +-- +STMT: VariableSetStmt +== 543 +-- test scrollable cursor support + +create function sc_test() returns setof integer as $$ +declare + c scroll cursor for select f1 from int4_tbl; + x integer; +begin + open c; + fetch last from c into x; + while found loop + return next x; + fetch prior from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 544 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +== 545 +create or replace function sc_test() returns setof integer as $$ +declare + c no scroll cursor for select f1 from int4_tbl; + x integer; +begin + open c; + fetch last from c into x; + while found loop + return next x; + fetch prior from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 546 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +== 547 +-- fails because of NO SCROLL specification + +create or replace function sc_test() returns setof integer as $$ +declare + c refcursor; + x integer; +begin + open c scroll for select f1 from int4_tbl; + fetch last from c into x; + while found loop + return next x; + fetch prior from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 548 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +== 549 +create or replace function sc_test() returns setof integer as $$ +declare + c refcursor; + x integer; +begin + open c scroll for execute 'select f1 from int4_tbl'; + fetch last from c into x; + while found loop + return next x; + fetch relative -2 from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 550 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +== 551 +create or replace function sc_test() returns setof integer as $$ +declare + c refcursor; + x integer; +begin + open c scroll for execute 'select f1 from int4_tbl'; + fetch last from c into x; + while found loop + return next x; + move backward 2 from c; + fetch relative -1 from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 552 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +== 553 +create or replace function sc_test() returns setof integer as $$ +declare + c cursor for select * from generate_series(1, 10); + x integer; +begin + open c; + loop + move relative 2 in c; + if not found then + exit; + end if; + fetch next from c into x; + if found then + return next x; + end if; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 554 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +== 555 +create or replace function sc_test() returns setof integer as $$ +declare + c cursor for select * from generate_series(1, 10); + x integer; +begin + open c; + move forward all in c; + fetch backward from c into x; + if found then + return next x; + end if; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 556 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +== 557 +drop function sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: DropStmt +== 558 +-- test qualified variable names + +create function pl_qual_names (param1 int) returns void as $$ +<> +declare + param1 int := 1; +begin + <> + declare + param1 int := 2; + begin + raise notice 'param1 = %', param1; + raise notice 'pl_qual_names.param1 = %', pl_qual_names.param1; + raise notice 'outerblock.param1 = %', outerblock.param1; + raise notice 'innerblock.param1 = %', innerblock.param1; + end; +end; +$$ language plpgsql +-- +FUNCTION: name="pl_qual_names" function="pl_qual_names" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 559 +select pl_qual_names(42) +-- +FUNCTION: name="pl_qual_names" function="pl_qual_names" schema="" ctx=Call +STMT: SelectStmt +== 560 +drop function pl_qual_names(int) +-- +FUNCTION: name="pl_qual_names" function="pl_qual_names" schema="" ctx=DDL +STMT: DropStmt +== 561 +-- tests for RETURN QUERY +create function ret_query1(out int, out int) returns setof record as $$ +begin + $1 := -1; + $2 := -2; + return next; + return query select x + 1, x * 10 from generate_series(0, 10) s (x); + return next; +end; +$$ language plpgsql +-- +FUNCTION: name="ret_query1" function="ret_query1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 562 +select * from ret_query1() +-- +FUNCTION: name="ret_query1" function="ret_query1" schema="" ctx=Call +STMT: SelectStmt +== 563 +create type record_type as (x text, y int, z boolean) +-- +STMT: CompositeTypeStmt +== 564 +create or replace function ret_query2(lim int) returns setof record_type as $$ +begin + return query select fipshash(s.x::text), s.x, s.x > 0 + from generate_series(-8, lim) s (x) where s.x % 2 = 0; +end; +$$ language plpgsql +-- +FUNCTION: name="ret_query2" function="ret_query2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 565 +select * from ret_query2(8) +-- +FUNCTION: name="ret_query2" function="ret_query2" schema="" ctx=Call +STMT: SelectStmt +== 566 +-- test EXECUTE USING +create function exc_using(int, text) returns int as $$ +declare i int; +begin + for i in execute 'select * from generate_series(1,$1)' using $1+1 loop + raise notice '%', i; + end loop; + execute 'select $2 + $2*3 + length($1)' into i using $2,$1; + return i; +end +$$ language plpgsql +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 567 +select exc_using(5, 'foobar') +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=Call +STMT: SelectStmt +== 568 +drop function exc_using(int, text) +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=DDL +STMT: DropStmt +== 569 +create or replace function exc_using(int) returns void as $$ +declare + c refcursor; + i int; +begin + open c for execute 'select * from generate_series(1,$1)' using $1+1; + loop + fetch c into i; + exit when not found; + raise notice '%', i; + end loop; + close c; + return; +end; +$$ language plpgsql +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 570 +select exc_using(5) +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=Call +STMT: SelectStmt +== 571 +drop function exc_using(int) +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=DDL +STMT: DropStmt +== 572 +-- test FOR-over-cursor + +create or replace function forc01() returns void as $$ +declare + c cursor(r1 integer, r2 integer) + for select * from generate_series(r1,r2) i; + c2 cursor + for select * from generate_series(41,43) i; +begin + -- assign portal names to cursors to get stable output + c := 'c'; + c2 := 'c2'; + for r in c(5,7) loop + raise notice '% from %', r.i, c; + end loop; + -- again, to test if cursor was closed properly + for r in c(9,10) loop + raise notice '% from %', r.i, c; + end loop; + -- and test a parameterless cursor + for r in c2 loop + raise notice '% from %', r.i, c2; + end loop; + -- and try it with a hand-assigned name + raise notice 'after loop, c2 = %', c2; + c2 := 'special_name'; + for r in c2 loop + raise notice '% from %', r.i, c2; + end loop; + raise notice 'after loop, c2 = %', c2; + -- and try it with a generated name + -- (which we can't show in the output because it's variable) + c2 := null; + for r in c2 loop + raise notice '%', r.i; + end loop; + raise notice 'after loop, c2 = %', c2; + return; +end; +$$ language plpgsql +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 573 +select forc01() +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=Call +STMT: SelectStmt +== 574 +-- try updating the cursor's current row + +create temp table forc_test as + select n as i, n as j from generate_series(1,10) n +-- +TABLE: name="forc_test" schema="" table="forc_test" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 575 +create or replace function forc01() returns void as $$ +declare + c cursor for select * from forc_test; +begin + for r in c loop + raise notice '%, %', r.i, r.j; + update forc_test set i = i * 100, j = r.j * 2 where current of c; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 576 +select forc01() +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=Call +STMT: SelectStmt +== 577 +select * from forc_test +-- +TABLE: name="forc_test" schema="" table="forc_test" ctx=Select +STMT: SelectStmt +== 578 +-- same, with a cursor whose portal name doesn't match variable name +create or replace function forc01() returns void as $$ +declare + c refcursor := 'fooled_ya'; + r record; +begin + open c for select * from forc_test; + loop + fetch c into r; + exit when not found; + raise notice '%, %', r.i, r.j; + update forc_test set i = i * 100, j = r.j * 2 where current of c; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 579 +select forc01() +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=Call +STMT: SelectStmt +== 580 +select * from forc_test +-- +TABLE: name="forc_test" schema="" table="forc_test" ctx=Select +STMT: SelectStmt +== 581 +drop function forc01() +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=DDL +STMT: DropStmt +== 582 +-- it's okay to re-use a cursor variable name, even when bound + +do $$ +declare cnt int := 0; + c1 cursor for select * from forc_test; +begin + for r1 in c1 loop + declare c1 cursor for select * from forc_test; + begin + for r2 in c1 loop + cnt := cnt + 1; + end loop; + end; + end loop; + raise notice 'cnt = %', cnt; +end $$ +-- +STMT: DoStmt +== 583 +-- fail because cursor has no query bound to it + +create or replace function forc_bad() returns void as $$ +declare + c refcursor; +begin + for r in c loop + raise notice '%', r.i; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="forc_bad" function="forc_bad" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 584 +-- test RETURN QUERY EXECUTE + +create or replace function return_dquery() +returns setof int as $$ +begin + return query execute 'select * from (values(10),(20)) f'; + return query execute 'select * from (values($1),($2)) f' using 40,50; +end; +$$ language plpgsql +-- +FUNCTION: name="return_dquery" function="return_dquery" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 585 +select * from return_dquery() +-- +FUNCTION: name="return_dquery" function="return_dquery" schema="" ctx=Call +STMT: SelectStmt +== 586 +drop function return_dquery() +-- +FUNCTION: name="return_dquery" function="return_dquery" schema="" ctx=DDL +STMT: DropStmt +== 587 +-- test RETURN QUERY with dropped columns + +create table tabwithcols(a int, b int, c int, d int) +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: CreateStmt +== 588 +insert into tabwithcols values(10,20,30,40),(50,60,70,80) +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 589 +create or replace function returnqueryf() +returns setof tabwithcols as $$ +begin + return query select * from tabwithcols; + return query execute 'select * from tabwithcols'; +end; +$$ language plpgsql +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 590 +select * from returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=Call +STMT: SelectStmt +== 591 +alter table tabwithcols drop column b +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: AlterTableStmt +== 592 +select * from returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=Call +STMT: SelectStmt +== 593 +alter table tabwithcols drop column d +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: AlterTableStmt +== 594 +select * from returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=Call +STMT: SelectStmt +== 595 +alter table tabwithcols add column d int +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: AlterTableStmt +== 596 +select * from returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=Call +STMT: SelectStmt +== 597 +drop function returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=DDL +STMT: DropStmt +== 598 +drop table tabwithcols +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: DropStmt +== 599 +|-- +-- Tests for composite-type results +|-- + +create type compostype as (x int, y varchar) +-- +STMT: CompositeTypeStmt +== 600 +-- test: use of variable of composite type in return statement +create or replace function compos() returns compostype as $$ +declare + v compostype; +begin + v := (1, 'hello'); + return v; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 601 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 602 +-- test: use of variable of record type in return statement +create or replace function compos() returns compostype as $$ +declare + v record; +begin + v := (1, 'hello'::varchar); + return v; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 603 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 604 +-- test: use of row expr in return statement +create or replace function compos() returns compostype as $$ +begin + return (1, 'hello'::varchar); +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 605 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 606 +-- this does not work currently (no implicit casting) +create or replace function compos() returns compostype as $$ +begin + return (1, 'hello'); +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 607 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 608 +-- ... but this does +create or replace function compos() returns compostype as $$ +begin + return (1, 'hello')::compostype; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 609 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 610 +drop function compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: DropStmt +== 611 +-- test: return a row expr as record. +create or replace function composrec() returns record as $$ +declare + v record; +begin + v := (1, 'hello'); + return v; +end; +$$ language plpgsql +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 612 +select composrec() +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=Call +STMT: SelectStmt +== 613 +-- test: return row expr in return statement. +create or replace function composrec() returns record as $$ +begin + return (1, 'hello'); +end; +$$ language plpgsql +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 614 +select composrec() +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=Call +STMT: SelectStmt +== 615 +drop function composrec() +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=DDL +STMT: DropStmt +== 616 +-- test: row expr in RETURN NEXT statement. +create or replace function compos() returns setof compostype as $$ +begin + for i in 1..3 + loop + return next (1, 'hello'::varchar); + end loop; + return next null::compostype; + return next (2, 'goodbye')::compostype; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 617 +select * from compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 618 +drop function compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: DropStmt +== 619 +-- test: use invalid expr in return statement. +create or replace function compos() returns compostype as $$ +begin + return 1 + 1; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 620 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 621 +-- RETURN variable is a different code path ... +create or replace function compos() returns compostype as $$ +declare x int := 42; +begin + return x; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 622 +select * from compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 623 +drop function compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: DropStmt +== 624 +-- test: invalid use of composite variable in scalar-returning function +create or replace function compos() returns int as $$ +declare + v compostype; +begin + v := (1, 'hello'); + return v; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 625 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 626 +-- test: invalid use of composite expression in scalar-returning function +create or replace function compos() returns int as $$ +begin + return (1, 'hello')::compostype; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 627 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +== 628 +drop function compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: DropStmt +== 629 +drop type compostype +-- +STMT: DropStmt +== 630 +|-- +-- Tests for 8.4's new RAISE features +|-- + +create or replace function raise_test() returns void as $$ +begin + raise notice '% % %', 1, 2, 3 + using errcode = '55001', detail = 'some detail info', hint = 'some hint'; + raise '% % %', 1, 2, 3 + using errcode = 'division_by_zero', detail = 'some detail info'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 631 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 632 +-- Since we can't actually see the thrown SQLSTATE in default psql output, +-- test it like this; this also tests re-RAISE + +create or replace function raise_test() returns void as $$ +begin + raise 'check me' + using errcode = 'division_by_zero', detail = 'some detail info'; + exception + when others then + raise notice 'SQLSTATE: % SQLERRM: %', sqlstate, sqlerrm; + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 633 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 634 +create or replace function raise_test() returns void as $$ +begin + raise 'check me' + using errcode = '1234F', detail = 'some detail info'; + exception + when others then + raise notice 'SQLSTATE: % SQLERRM: %', sqlstate, sqlerrm; + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 635 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 636 +-- SQLSTATE specification in WHEN +create or replace function raise_test() returns void as $$ +begin + raise 'check me' + using errcode = '1234F', detail = 'some detail info'; + exception + when sqlstate '1234F' then + raise notice 'SQLSTATE: % SQLERRM: %', sqlstate, sqlerrm; + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 637 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 638 +create or replace function raise_test() returns void as $$ +begin + raise division_by_zero using detail = 'some detail info'; + exception + when others then + raise notice 'SQLSTATE: % SQLERRM: %', sqlstate, sqlerrm; + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 639 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 640 +create or replace function raise_test() returns void as $$ +begin + raise division_by_zero; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 641 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 642 +create or replace function raise_test() returns void as $$ +begin + raise sqlstate '1234F'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 643 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 644 +create or replace function raise_test() returns void as $$ +begin + raise division_by_zero using message = 'custom' || ' message'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 645 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 646 +create or replace function raise_test() returns void as $$ +begin + raise using message = 'custom' || ' message', errcode = '22012'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 647 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 648 +-- conflict on message +create or replace function raise_test() returns void as $$ +begin + raise notice 'some message' using message = 'custom' || ' message', errcode = '22012'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 649 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 650 +-- conflict on errcode +create or replace function raise_test() returns void as $$ +begin + raise division_by_zero using message = 'custom' || ' message', errcode = '22012'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 651 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 652 +-- nothing to re-RAISE +create or replace function raise_test() returns void as $$ +begin + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 653 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 654 +-- test access to exception data +create function zero_divide() returns int as $$ +declare v int := 0; +begin + return 10 / v; +end; +$$ language plpgsql parallel safe +-- +FUNCTION: name="zero_divide" function="zero_divide" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 655 +create or replace function raise_test() returns void as $$ +begin + raise exception 'custom exception' + using detail = 'some detail of custom exception', + hint = 'some hint related to custom exception'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 656 +create function stacked_diagnostics_test() returns void as $$ +declare _sqlstate text; + _message text; + _context text; +begin + perform zero_divide(); +exception when others then + get stacked diagnostics + _sqlstate = returned_sqlstate, + _message = message_text, + _context = pg_exception_context; + raise notice 'sqlstate: %, message: %, context: [%]', + _sqlstate, _message, replace(_context, E'\n', ' <- '); +end; +$$ language plpgsql +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 657 +select stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=Call +STMT: SelectStmt +== 658 +create or replace function stacked_diagnostics_test() returns void as $$ +declare _detail text; + _hint text; + _message text; +begin + perform raise_test(); +exception when others then + get stacked diagnostics + _message = message_text, + _detail = pg_exception_detail, + _hint = pg_exception_hint; + raise notice 'message: %, detail: %, hint: %', _message, _detail, _hint; +end; +$$ language plpgsql +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 659 +select stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=Call +STMT: SelectStmt +== 660 +-- fail, cannot use stacked diagnostics statement outside handler +create or replace function stacked_diagnostics_test() returns void as $$ +declare _detail text; + _hint text; + _message text; +begin + get stacked diagnostics + _message = message_text, + _detail = pg_exception_detail, + _hint = pg_exception_hint; + raise notice 'message: %, detail: %, hint: %', _message, _detail, _hint; +end; +$$ language plpgsql +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 661 +select stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=Call +STMT: SelectStmt +== 662 +drop function stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: DropStmt +== 663 +-- Test that an error recovery subtransaction is parallel safe + +create function error_trap_test() returns text as $$ +begin + perform zero_divide(); + return 'no error detected!'; +exception when division_by_zero then + return 'division_by_zero detected'; +end; +$$ language plpgsql parallel safe +-- +FUNCTION: name="error_trap_test" function="error_trap_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 664 +set debug_parallel_query to on +-- +STMT: VariableSetStmt +== 665 +explain (verbose, costs off) select error_trap_test() +-- +FUNCTION: name="error_trap_test" function="error_trap_test" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 666 +select error_trap_test() +-- +FUNCTION: name="error_trap_test" function="error_trap_test" schema="" ctx=Call +STMT: SelectStmt +== 667 +reset debug_parallel_query +-- +STMT: VariableSetStmt +== 668 +drop function error_trap_test() +-- +FUNCTION: name="error_trap_test" function="error_trap_test" schema="" ctx=DDL +STMT: DropStmt +== 669 +drop function zero_divide() +-- +FUNCTION: name="zero_divide" function="zero_divide" schema="" ctx=DDL +STMT: DropStmt +== 670 +-- check cases where implicit SQLSTATE variable could be confused with +-- SQLSTATE as a keyword, cf bug #5524 +create or replace function raise_test() returns void as $$ +begin + perform 1/0; +exception + when sqlstate '22012' then + raise notice using message = sqlstate; + raise sqlstate '22012' using message = 'substitute message'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 671 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +== 672 +drop function raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: DropStmt +== 673 +-- test passing column_name, constraint_name, datatype_name, table_name +-- and schema_name error fields + +create or replace function stacked_diagnostics_test() returns void as $$ +declare _column_name text; + _constraint_name text; + _datatype_name text; + _table_name text; + _schema_name text; +begin + raise exception using + column = '>>some column name<<', + constraint = '>>some constraint name<<', + datatype = '>>some datatype name<<', + table = '>>some table name<<', + schema = '>>some schema name<<'; +exception when others then + get stacked diagnostics + _column_name = column_name, + _constraint_name = constraint_name, + _datatype_name = pg_datatype_name, + _table_name = table_name, + _schema_name = schema_name; + raise notice 'column %, constraint %, type %, table %, schema %', + _column_name, _constraint_name, _datatype_name, _table_name, _schema_name; +end; +$$ language plpgsql +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 674 +select stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=Call +STMT: SelectStmt +== 675 +drop function stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: DropStmt +== 676 +-- test variadic functions + +create or replace function vari(variadic int[]) +returns void as $$ +begin + for i in array_lower($1,1)..array_upper($1,1) loop + raise notice '%', $1[i]; + end loop; end; +$$ language plpgsql +-- +FUNCTION: name="vari" function="vari" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 677 +select vari(1,2,3,4,5) +-- +FUNCTION: name="vari" function="vari" schema="" ctx=Call +STMT: SelectStmt +== 678 +select vari(3,4,5) +-- +FUNCTION: name="vari" function="vari" schema="" ctx=Call +STMT: SelectStmt +== 679 +select vari(variadic array[5,6,7]) +-- +FUNCTION: name="vari" function="vari" schema="" ctx=Call +STMT: SelectStmt +== 680 +drop function vari(int[]) +-- +FUNCTION: name="vari" function="vari" schema="" ctx=DDL +STMT: DropStmt +== 681 +-- coercion test +create or replace function pleast(variadic numeric[]) +returns numeric as $$ +declare aux numeric = $1[array_lower($1,1)]; +begin + for i in array_lower($1,1)+1..array_upper($1,1) loop + if $1[i] < aux then aux := $1[i]; end if; + end loop; + return aux; +end; +$$ language plpgsql immutable strict +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 682 +select pleast(10,1,2,3,-16) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +== 683 +select pleast(10.2,2.2,-1.1) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +== 684 +select pleast(10.2,10, -20) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +== 685 +select pleast(10,20, -1.0) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +== 686 +-- in case of conflict, non-variadic version is preferred +create or replace function pleast(numeric) +returns numeric as $$ +begin + raise notice 'non-variadic function called'; + return $1; +end; +$$ language plpgsql immutable strict +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 687 +select pleast(10) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +== 688 +drop function pleast(numeric[]) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=DDL +STMT: DropStmt +== 689 +drop function pleast(numeric) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=DDL +STMT: DropStmt +== 690 +-- test table functions + +create function tftest(int) returns table(a int, b int) as $$ +begin + return query select $1, $1+i from generate_series(1,5) g(i); +end; +$$ language plpgsql immutable strict +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 691 +select * from tftest(10) +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=Call +STMT: SelectStmt +== 692 +create or replace function tftest(a1 int) returns table(a int, b int) as $$ +begin + a := a1; b := a1 + 1; + return next; + a := a1 * 10; b := a1 * 10 + 1; + return next; +end; +$$ language plpgsql immutable strict +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 693 +select * from tftest(10) +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=Call +STMT: SelectStmt +== 694 +drop function tftest(int) +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: DropStmt +== 695 +create function rttest() +returns setof int as $$ +declare rc int; +begin + return query values(10),(20); + get diagnostics rc = row_count; + raise notice '% %', found, rc; + return query select * from (values(10),(20)) f(a) where false; + get diagnostics rc = row_count; + raise notice '% %', found, rc; + return query execute 'values(10),(20)'; + get diagnostics rc = row_count; + raise notice '% %', found, rc; + return query execute 'select * from (values(10),(20)) f(a) where false'; + get diagnostics rc = row_count; + raise notice '% %', found, rc; +end; +$$ language plpgsql +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 696 +select * from rttest() +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=Call +STMT: SelectStmt +== 697 +-- check some error cases, too + +create or replace function rttest() +returns setof int as $$ +begin + return query select 10 into no_such_table; +end; +$$ language plpgsql +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 698 +select * from rttest() +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=Call +STMT: SelectStmt +== 699 +create or replace function rttest() +returns setof int as $$ +begin + return query execute 'select 10 into no_such_table'; +end; +$$ language plpgsql +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 700 +select * from rttest() +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=Call +STMT: SelectStmt +== 701 +select * from no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=Select +STMT: SelectStmt +== 702 +drop function rttest() +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=DDL +STMT: DropStmt +== 703 +-- Test for proper cleanup at subtransaction exit. This example +-- exposed a bug in PG 8.2. + +CREATE FUNCTION leaker_1(fail BOOL) RETURNS INTEGER AS $$ +DECLARE + v_var INTEGER; +BEGIN + BEGIN + v_var := (leaker_2(fail)).error_code; + EXCEPTION + WHEN others THEN RETURN 0; + END; + RETURN 1; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="leaker_1" function="leaker_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 704 +CREATE FUNCTION leaker_2(fail BOOL, OUT error_code INTEGER, OUT new_id INTEGER) + RETURNS RECORD AS $$ +BEGIN + IF fail THEN + RAISE EXCEPTION 'fail ...'; + END IF; + error_code := 1; + new_id := 1; + RETURN; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="leaker_2" function="leaker_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 705 +SELECT * FROM leaker_1(false) +-- +FUNCTION: name="leaker_1" function="leaker_1" schema="" ctx=Call +STMT: SelectStmt +== 706 +SELECT * FROM leaker_1(true) +-- +FUNCTION: name="leaker_1" function="leaker_1" schema="" ctx=Call +STMT: SelectStmt +== 707 +DROP FUNCTION leaker_1(bool) +-- +FUNCTION: name="leaker_1" function="leaker_1" schema="" ctx=DDL +STMT: DropStmt +== 708 +DROP FUNCTION leaker_2(bool) +-- +FUNCTION: name="leaker_2" function="leaker_2" schema="" ctx=DDL +STMT: DropStmt +== 709 +-- Test for appropriate cleanup of non-simple expression evaluations +-- (bug in all versions prior to August 2010) + +CREATE FUNCTION nonsimple_expr_test() RETURNS text[] AS $$ +DECLARE + arr text[]; + lr text; + i integer; +BEGIN + arr := array[array['foo','bar'], array['baz', 'quux']]; + lr := 'fool'; + i := 1; + -- use sub-SELECTs to make expressions non-simple + arr[(SELECT i)][(SELECT i+1)] := (SELECT lr); + RETURN arr; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 710 +SELECT nonsimple_expr_test() +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=Call +STMT: SelectStmt +== 711 +DROP FUNCTION nonsimple_expr_test() +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=DDL +STMT: DropStmt +== 712 +CREATE FUNCTION nonsimple_expr_test() RETURNS integer AS $$ +declare + i integer NOT NULL := 0; +begin + begin + i := (SELECT NULL::integer); -- should throw error + exception + WHEN OTHERS THEN + i := (SELECT 1::integer); + end; + return i; +end; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 713 +SELECT nonsimple_expr_test() +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=Call +STMT: SelectStmt +== 714 +DROP FUNCTION nonsimple_expr_test() +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=DDL +STMT: DropStmt +== 715 +|-- +-- Test cases involving recursion and error recovery in simple expressions +-- (bugs in all versions before October 2010). The problems are most +-- easily exposed by mutual recursion between plpgsql and sql functions. +|-- + +create function recurse(float8) returns float8 as +$$ +begin + if ($1 > 0) then + return sql_recurse($1 - 1); + else + return $1; + end if; +end; +$$ language plpgsql +-- +FUNCTION: name="recurse" function="recurse" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 716 +-- "limit" is to prevent this from being inlined +create function sql_recurse(float8) returns float8 as +$$ select recurse($1) limit 1; $$ language sql +-- +FUNCTION: name="sql_recurse" function="sql_recurse" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 717 +select recurse(10) +-- +FUNCTION: name="recurse" function="recurse" schema="" ctx=Call +STMT: SelectStmt +== 718 +create function error1(text) returns text language sql as +$$ SELECT relname::text FROM pg_class c WHERE c.oid = $1::regclass $$ +-- +FUNCTION: name="error1" function="error1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 719 +create function error2(p_name_table text) returns text language plpgsql as $$ +begin + return error1(p_name_table); +end$$ +-- +FUNCTION: name="error2" function="error2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 720 +BEGIN +-- +STMT: TransactionStmt +== 721 +create table public.stuffs (stuff text) +-- +TABLE: name="public.stuffs" schema="public" table="stuffs" ctx=DDL +STMT: CreateStmt +== 722 +SAVEPOINT a +-- +STMT: TransactionStmt +== 723 +select error2('nonexistent.stuffs') +-- +FUNCTION: name="error2" function="error2" schema="" ctx=Call +STMT: SelectStmt +== 724 +ROLLBACK TO a +-- +STMT: TransactionStmt +== 725 +select error2('public.stuffs') +-- +FUNCTION: name="error2" function="error2" schema="" ctx=Call +STMT: SelectStmt +== 726 +rollback +-- +STMT: TransactionStmt +== 727 +drop function error2(p_name_table text) +-- +FUNCTION: name="error2" function="error2" schema="" ctx=DDL +STMT: DropStmt +== 728 +drop function error1(text) +-- +FUNCTION: name="error1" function="error1" schema="" ctx=DDL +STMT: DropStmt +== 729 +-- Test for proper handling of cast-expression caching + +create function sql_to_date(integer) returns date as $$ +select $1::text::date +$$ language sql immutable strict +-- +FUNCTION: name="sql_to_date" function="sql_to_date" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 730 +create cast (integer as date) with function sql_to_date(integer) as assignment +-- +STMT: CreateCastStmt +== 731 +create function cast_invoker(integer) returns date as $$ +begin + return $1; +end$$ language plpgsql +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 732 +select cast_invoker(20150717) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +== 733 +select cast_invoker(20150718) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +== 734 +-- second call crashed in pre-release 9.5 + +begin +-- +STMT: TransactionStmt +== 735 +select cast_invoker(20150717) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +== 736 +select cast_invoker(20150718) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +== 737 +savepoint s1 +-- +STMT: TransactionStmt +== 738 +select cast_invoker(20150718) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +== 739 +select cast_invoker(-1) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +== 740 +-- fails +rollback to savepoint s1 +-- +STMT: TransactionStmt +== 741 +select cast_invoker(20150719) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +== 742 +select cast_invoker(20150720) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +== 743 +commit +-- +STMT: TransactionStmt +== 744 +drop function cast_invoker(integer) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=DDL +STMT: DropStmt +== 745 +drop function sql_to_date(integer) cascade +-- +FUNCTION: name="sql_to_date" function="sql_to_date" schema="" ctx=DDL +STMT: DropStmt +== 746 +-- Test handling of cast cache inside DO blocks +-- (to check the original crash case, this must be a cast not previously +-- used in this session) + +begin +-- +STMT: TransactionStmt +== 747 +do $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$ +-- +STMT: DoStmt +== 748 +do $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$ +-- +STMT: DoStmt +== 749 +end +-- +STMT: TransactionStmt +== 750 +-- Test for consistent reporting of error context + +create function fail() returns int language plpgsql as $$ +begin + return 1/0; +end +$$ +-- +FUNCTION: name="fail" function="fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 751 +select fail() +-- +FUNCTION: name="fail" function="fail" schema="" ctx=Call +STMT: SelectStmt +== 752 +select fail() +-- +FUNCTION: name="fail" function="fail" schema="" ctx=Call +STMT: SelectStmt +== 753 +drop function fail() +-- +FUNCTION: name="fail" function="fail" schema="" ctx=DDL +STMT: DropStmt +== 754 +-- Test handling of string literals. + +set standard_conforming_strings = off +-- +STMT: VariableSetStmt +== 755 +create or replace function strtest() returns text as $$ +begin + raise notice 'foo\\bar\041baz'; + return 'foo\\bar\041baz'; +end +$$ language plpgsql +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 756 +select strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=Call +STMT: SelectStmt +== 757 +create or replace function strtest() returns text as $$ +begin + raise notice E'foo\\bar\041baz'; + return E'foo\\bar\041baz'; +end +$$ language plpgsql +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 758 +select strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=Call +STMT: SelectStmt +== 759 +set standard_conforming_strings = on +-- +STMT: VariableSetStmt +== 760 +create or replace function strtest() returns text as $$ +begin + raise notice 'foo\\bar\041baz\'; + return 'foo\\bar\041baz\'; +end +$$ language plpgsql +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 761 +select strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=Call +STMT: SelectStmt +== 762 +create or replace function strtest() returns text as $$ +begin + raise notice E'foo\\bar\041baz'; + return E'foo\\bar\041baz'; +end +$$ language plpgsql +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 763 +select strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=Call +STMT: SelectStmt +== 764 +drop function strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: DropStmt +== 765 +-- Test anonymous code blocks. + +DO $$ +DECLARE r record; +BEGIN + FOR r IN SELECT rtrim(roomno) AS roomno, comment FROM Room ORDER BY roomno + LOOP + RAISE NOTICE '%, %', r.roomno, r.comment; + END LOOP; +END$$ +-- +STMT: DoStmt +== 766 +-- these are to check syntax error reporting +DO LANGUAGE plpgsql $$begin return 1; end$$ +-- +STMT: DoStmt +== 767 +DO $$ +DECLARE r record; +BEGIN + FOR r IN SELECT rtrim(roomno) AS roomno, foo FROM Room ORDER BY roomno + LOOP + RAISE NOTICE '%, %', r.roomno, r.comment; + END LOOP; +END$$ +-- +STMT: DoStmt +== 768 +-- Check handling of errors thrown from/into anonymous code blocks. +do $outer$ +begin + for i in 1..10 loop + begin + execute $ex$ + do $$ + declare x int = 0; + begin + x := 1 / x; + end; + $$; + $ex$; + exception when division_by_zero then + raise notice 'caught division by zero'; + end; + end loop; +end; +$outer$ +-- +STMT: DoStmt +== 769 +-- Check variable scoping -- a var is not available in its own or prior +-- default expressions, but it is available in later ones. + +do $$ +declare x int := x + 1; -- error +begin + raise notice 'x = %', x; +end; +$$ +-- +STMT: DoStmt +== 770 +do $$ +declare y int := x + 1; -- error + x int := 42; +begin + raise notice 'x = %, y = %', x, y; +end; +$$ +-- +STMT: DoStmt +== 771 +do $$ +declare x int := 42; + y int := x + 1; +begin + raise notice 'x = %, y = %', x, y; +end; +$$ +-- +STMT: DoStmt +== 772 +do $$ +declare x int := 42; +begin + declare y int := x + 1; + x int := x + 2; + z int := x * 10; + begin + raise notice 'x = %, y = %, z = %', x, y, z; + end; +end; +$$ +-- +STMT: DoStmt +== 773 +-- Check handling of conflicts between plpgsql vars and table columns. + +set plpgsql.variable_conflict = error +-- +STMT: VariableSetStmt +== 774 +create function conflict_test() returns setof int8_tbl as $$ +declare r record; + q1 bigint := 42; +begin + for r in select q1,q2 from int8_tbl loop + return next r; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 775 +select * from conflict_test() +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=Call +STMT: SelectStmt +== 776 +create or replace function conflict_test() returns setof int8_tbl as $$ +#variable_conflict use_variable +declare r record; + q1 bigint := 42; +begin + for r in select q1,q2 from int8_tbl loop + return next r; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 777 +select * from conflict_test() +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=Call +STMT: SelectStmt +== 778 +create or replace function conflict_test() returns setof int8_tbl as $$ +#variable_conflict use_column +declare r record; + q1 bigint := 42; +begin + for r in select q1,q2 from int8_tbl loop + return next r; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 779 +select * from conflict_test() +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=Call +STMT: SelectStmt +== 780 +drop function conflict_test() +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=DDL +STMT: DropStmt +== 781 +-- Check that an unreserved keyword can be used as a variable name + +create function unreserved_test() returns int as $$ +declare + forward int := 21; +begin + forward := forward * 2; + return forward; +end +$$ language plpgsql +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 782 +select unreserved_test() +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=Call +STMT: SelectStmt +== 783 +create or replace function unreserved_test() returns int as $$ +declare + return int := 42; +begin + return := return + 1; + return return; +end +$$ language plpgsql +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 784 +select unreserved_test() +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=Call +STMT: SelectStmt +== 785 +create or replace function unreserved_test() returns int as $$ +declare + comment int := 21; +begin + comment := comment * 2; + comment on function unreserved_test() is 'this is a test'; + return comment; +end +$$ language plpgsql +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 786 +select unreserved_test() +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=Call +STMT: SelectStmt +== 787 +select obj_description('unreserved_test()'::regprocedure, 'pg_proc') +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +== 788 +drop function unreserved_test() +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=DDL +STMT: DropStmt +== 789 +|-- +-- Test FOREACH over arrays +|-- + +create function foreach_test(anyarray) +returns void as $$ +declare x int; +begin + foreach x in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 790 +select foreach_test(ARRAY[1,2,3,4]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 791 +select foreach_test(ARRAY[[1,2],[3,4]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 792 +create or replace function foreach_test(anyarray) +returns void as $$ +declare x int; +begin + foreach x slice 1 in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 793 +-- should fail +select foreach_test(ARRAY[1,2,3,4]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 794 +select foreach_test(ARRAY[[1,2],[3,4]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 795 +create or replace function foreach_test(anyarray) +returns void as $$ +declare x int[]; +begin + foreach x slice 1 in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 796 +select foreach_test(ARRAY[1,2,3,4]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 797 +select foreach_test(ARRAY[[1,2],[3,4]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 798 +-- higher level of slicing +create or replace function foreach_test(anyarray) +returns void as $$ +declare x int[]; +begin + foreach x slice 2 in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 799 +-- should fail +select foreach_test(ARRAY[1,2,3,4]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 800 +-- ok +select foreach_test(ARRAY[[1,2],[3,4]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 801 +select foreach_test(ARRAY[[[1,2]],[[3,4]]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 802 +create type xy_tuple AS (x int, y int) +-- +STMT: CompositeTypeStmt +== 803 +-- iteration over array of records +create or replace function foreach_test(anyarray) +returns void as $$ +declare r record; +begin + foreach r in array $1 + loop + raise notice '%', r; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 804 +select foreach_test(ARRAY[(10,20),(40,69),(35,78)]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 805 +select foreach_test(ARRAY[[(10,20),(40,69)],[(35,78),(88,76)]]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 806 +create or replace function foreach_test(anyarray) +returns void as $$ +declare x int; y int; +begin + foreach x, y in array $1 + loop + raise notice 'x = %, y = %', x, y; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 807 +select foreach_test(ARRAY[(10,20),(40,69),(35,78)]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 808 +select foreach_test(ARRAY[[(10,20),(40,69)],[(35,78),(88,76)]]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 809 +-- slicing over array of composite types +create or replace function foreach_test(anyarray) +returns void as $$ +declare x xy_tuple[]; +begin + foreach x slice 1 in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 810 +select foreach_test(ARRAY[(10,20),(40,69),(35,78)]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 811 +select foreach_test(ARRAY[[(10,20),(40,69)],[(35,78),(88,76)]]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +== 812 +drop function foreach_test(anyarray) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: DropStmt +== 813 +drop type xy_tuple +-- +STMT: DropStmt +== 814 +|-- +-- Assorted tests for array subscript assignment +|-- + +create temp table rtype (id int, ar text[]) +-- +TABLE: name="rtype" schema="" table="rtype" ctx=DDL +STMT: CreateStmt +== 815 +create function arrayassign1() returns text[] language plpgsql as $$ +declare + r record; +begin + r := row(12, '{foo,bar,baz}')::rtype; + r.ar[2] := 'replace'; + return r.ar; +end$$ +-- +FUNCTION: name="arrayassign1" function="arrayassign1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 816 +select arrayassign1() +-- +FUNCTION: name="arrayassign1" function="arrayassign1" schema="" ctx=Call +STMT: SelectStmt +== 817 +select arrayassign1() +-- +FUNCTION: name="arrayassign1" function="arrayassign1" schema="" ctx=Call +STMT: SelectStmt +== 818 +-- try again to exercise internal caching + +create domain orderedarray as int[2] + constraint sorted check (value[1] < value[2]) +-- +STMT: CreateDomainStmt +== 819 +select '{1,2}'::orderedarray +-- +STMT: SelectStmt +== 820 +select '{2,1}'::orderedarray +-- +STMT: SelectStmt +== 821 +-- fail + +create function testoa(x1 int, x2 int, x3 int) returns orderedarray +language plpgsql as $$ +declare res orderedarray; +begin + res := array[x1, x2]; + res[2] := x3; + return res; +end$$ +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 822 +select testoa(1,2,3) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=Call +STMT: SelectStmt +== 823 +select testoa(1,2,3) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=Call +STMT: SelectStmt +== 824 +-- try again to exercise internal caching +select testoa(2,1,3) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=Call +STMT: SelectStmt +== 825 +-- fail at initial assign +select testoa(1,2,1) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=Call +STMT: SelectStmt +== 826 +-- fail at update + +drop function arrayassign1() +-- +FUNCTION: name="arrayassign1" function="arrayassign1" schema="" ctx=DDL +STMT: DropStmt +== 827 +drop function testoa(x1 int, x2 int, x3 int) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=DDL +STMT: DropStmt +== 828 +|-- +-- Test handling of expanded arrays +|-- + +create function returns_rw_array(int) returns int[] +language plpgsql as $$ + declare r int[]; + begin r := array[$1, $1]; return r; end; +$$ stable +-- +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 829 +create function consumes_rw_array(int[]) returns int +language plpgsql as $$ + begin return $1[1]; end; +$$ stable +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 830 +select consumes_rw_array(returns_rw_array(42)) +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: SelectStmt +== 831 +-- bug #14174 +explain (verbose, costs off) +select i, a from + (select returns_rw_array(1) as a offset 0) ss, + lateral consumes_rw_array(a) i +-- +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 832 +select i, a from + (select returns_rw_array(1) as a offset 0) ss, + lateral consumes_rw_array(a) i +-- +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +STMT: SelectStmt +== 833 +explain (verbose, costs off) +select consumes_rw_array(a), a from returns_rw_array(1) a +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 834 +select consumes_rw_array(a), a from returns_rw_array(1) a +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: SelectStmt +== 835 +explain (verbose, costs off) +select consumes_rw_array(a), a from + (values (returns_rw_array(1)), (returns_rw_array(2))) v(a) +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 836 +select consumes_rw_array(a), a from + (values (returns_rw_array(1)), (returns_rw_array(2))) v(a) +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: SelectStmt +== 837 +do $$ +declare a int[] := array[1,2]; +begin + a := a || 3; + raise notice 'a = %', a; +end$$ +-- +STMT: DoStmt +== 838 +|-- +-- Test access to call stack +|-- + +create function inner_func(int) +returns int as $$ +declare _context text; +begin + get diagnostics _context = pg_context; + raise notice '***%***', _context; + -- lets do it again, just for fun.. + get diagnostics _context = pg_context; + raise notice '***%***', _context; + raise notice 'lets make sure we didnt break anything'; + return 2 * $1; +end; +$$ language plpgsql +-- +FUNCTION: name="inner_func" function="inner_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 839 +create or replace function outer_func(int) +returns int as $$ +declare + myresult int; +begin + raise notice 'calling down into inner_func()'; + myresult := inner_func($1); + raise notice 'inner_func() done'; + return myresult; +end; +$$ language plpgsql +-- +FUNCTION: name="outer_func" function="outer_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 840 +create or replace function outer_outer_func(int) +returns int as $$ +declare + myresult int; +begin + raise notice 'calling down into outer_func()'; + myresult := outer_func($1); + raise notice 'outer_func() done'; + return myresult; +end; +$$ language plpgsql +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 841 +select outer_outer_func(10) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=Call +STMT: SelectStmt +== 842 +-- repeated call should work +select outer_outer_func(20) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=Call +STMT: SelectStmt +== 843 +drop function outer_outer_func(int) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=DDL +STMT: DropStmt +== 844 +drop function outer_func(int) +-- +FUNCTION: name="outer_func" function="outer_func" schema="" ctx=DDL +STMT: DropStmt +== 845 +drop function inner_func(int) +-- +FUNCTION: name="inner_func" function="inner_func" schema="" ctx=DDL +STMT: DropStmt +== 846 +-- access to call stack from exception +create function inner_func(int) +returns int as $$ +declare + _context text; + sx int := 5; +begin + begin + perform sx / 0; + exception + when division_by_zero then + get diagnostics _context = pg_context; + raise notice '***%***', _context; + end; + + -- lets do it again, just for fun.. + get diagnostics _context = pg_context; + raise notice '***%***', _context; + raise notice 'lets make sure we didnt break anything'; + return 2 * $1; +end; +$$ language plpgsql +-- +FUNCTION: name="inner_func" function="inner_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 847 +create or replace function outer_func(int) +returns int as $$ +declare + myresult int; +begin + raise notice 'calling down into inner_func()'; + myresult := inner_func($1); + raise notice 'inner_func() done'; + return myresult; +end; +$$ language plpgsql +-- +FUNCTION: name="outer_func" function="outer_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 848 +create or replace function outer_outer_func(int) +returns int as $$ +declare + myresult int; +begin + raise notice 'calling down into outer_func()'; + myresult := outer_func($1); + raise notice 'outer_func() done'; + return myresult; +end; +$$ language plpgsql +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 849 +select outer_outer_func(10) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=Call +STMT: SelectStmt +== 850 +-- repeated call should work +select outer_outer_func(20) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=Call +STMT: SelectStmt +== 851 +drop function outer_outer_func(int) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=DDL +STMT: DropStmt +== 852 +drop function outer_func(int) +-- +FUNCTION: name="outer_func" function="outer_func" schema="" ctx=DDL +STMT: DropStmt +== 853 +drop function inner_func(int) +-- +FUNCTION: name="inner_func" function="inner_func" schema="" ctx=DDL +STMT: DropStmt +== 854 +-- Test pg_routine_oid +create function current_function(text) +returns regprocedure as $$ +declare + fn_oid regprocedure; +begin + get diagnostics fn_oid = pg_routine_oid; + return fn_oid; +end; +$$ language plpgsql +-- +FUNCTION: name="current_function" function="current_function" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 855 +select current_function('foo') +-- +FUNCTION: name="current_function" function="current_function" schema="" ctx=Call +STMT: SelectStmt +== 856 +drop function current_function(text) +-- +FUNCTION: name="current_function" function="current_function" schema="" ctx=DDL +STMT: DropStmt +== 857 +-- shouldn't fail in DO, even though there's no useful data +do $$ +declare + fn_oid oid; +begin + get diagnostics fn_oid = pg_routine_oid; + raise notice 'pg_routine_oid = %', fn_oid; +end; +$$ +-- +STMT: DoStmt +== 858 +|-- +-- Test ASSERT +|-- + +do $$ +begin + assert 1=1; -- should succeed +end; +$$ +-- +STMT: DoStmt +== 859 +do $$ +begin + assert 1=0; -- should fail +end; +$$ +-- +STMT: DoStmt +== 860 +do $$ +begin + assert NULL; -- should fail +end; +$$ +-- +STMT: DoStmt +== 861 +-- check controlling GUC +set plpgsql.check_asserts = off +-- +STMT: VariableSetStmt +== 862 +do $$ +begin + assert 1=0; -- won't be tested +end; +$$ +-- +STMT: DoStmt +== 863 +reset plpgsql.check_asserts +-- +STMT: VariableSetStmt +== 864 +-- test custom message +do $$ +declare var text := 'some value'; +begin + assert 1=0, format('assertion failed, var = "%s"', var); +end; +$$ +-- +STMT: DoStmt +== 865 +-- ensure assertions are not trapped by 'others' +do $$ +begin + assert 1=0, 'unhandled assertion'; +exception when others then + null; -- do nothing +end; +$$ +-- +STMT: DoStmt +== 866 +-- Test use of plpgsql in a domain check constraint (cf. bug #14414) + +create function plpgsql_domain_check(val int) returns boolean as $$ +begin return val > 0; end +$$ language plpgsql immutable +-- +FUNCTION: name="plpgsql_domain_check" function="plpgsql_domain_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 867 +create domain plpgsql_domain as integer check(plpgsql_domain_check(value)) +-- +STMT: CreateDomainStmt +== 868 +do $$ +declare v_test plpgsql_domain; +begin + v_test := 1; +end; +$$ +-- +STMT: DoStmt +== 869 +do $$ +declare v_test plpgsql_domain := 1; +begin + v_test := 0; -- fail +end; +$$ +-- +STMT: DoStmt +== 870 +-- Test handling of expanded array passed to a domain constraint (bug #14472) + +create function plpgsql_arr_domain_check(val int[]) returns boolean as $$ +begin return val[1] > 0; end +$$ language plpgsql immutable +-- +FUNCTION: name="plpgsql_arr_domain_check" function="plpgsql_arr_domain_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 871 +create domain plpgsql_arr_domain as int[] check(plpgsql_arr_domain_check(value)) +-- +STMT: CreateDomainStmt +== 872 +do $$ +declare v_test plpgsql_arr_domain; +begin + v_test := array[1]; + v_test := v_test || 2; +end; +$$ +-- +STMT: DoStmt +== 873 +do $$ +declare v_test plpgsql_arr_domain := array[1]; +begin + v_test := 0 || v_test; -- fail +end; +$$ +-- +STMT: DoStmt +== 874 +|-- +-- test usage of transition tables in AFTER triggers +|-- + +CREATE TABLE transition_table_base (id int PRIMARY KEY, val text) +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DDL +STMT: CreateStmt +== 875 +CREATE FUNCTION transition_table_base_ins_func() + RETURNS trigger + LANGUAGE plpgsql +AS $$ +DECLARE + t text; + l text; +BEGIN + t = ''; + FOR l IN EXECUTE + $q$ + EXPLAIN (TIMING off, COSTS off, VERBOSE on) + SELECT * FROM newtable + $q$ LOOP + t = t || l || E'\n'; + END LOOP; + + RAISE INFO '%', t; + RETURN new; +END; +$$ +-- +FUNCTION: name="transition_table_base_ins_func" function="transition_table_base_ins_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 876 +CREATE TRIGGER transition_table_base_ins_trig + AFTER INSERT ON transition_table_base + REFERENCING OLD TABLE AS oldtable NEW TABLE AS newtable + FOR EACH STATEMENT + EXECUTE PROCEDURE transition_table_base_ins_func() +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DDL +STMT: CreateTrigStmt +== 877 +CREATE TRIGGER transition_table_base_ins_trig + AFTER INSERT ON transition_table_base + REFERENCING NEW TABLE AS newtable + FOR EACH STATEMENT + EXECUTE PROCEDURE transition_table_base_ins_func() +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DDL +STMT: CreateTrigStmt +== 878 +INSERT INTO transition_table_base VALUES (1, 'One'), (2, 'Two') +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 879 +INSERT INTO transition_table_base VALUES (3, 'Three'), (4, 'Four') +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 880 +CREATE OR REPLACE FUNCTION transition_table_base_upd_func() + RETURNS trigger + LANGUAGE plpgsql +AS $$ +DECLARE + t text; + l text; +BEGIN + t = ''; + FOR l IN EXECUTE + $q$ + EXPLAIN (TIMING off, COSTS off, VERBOSE on) + SELECT * FROM oldtable ot FULL JOIN newtable nt USING (id) + $q$ LOOP + t = t || l || E'\n'; + END LOOP; + + RAISE INFO '%', t; + RETURN new; +END; +$$ +-- +FUNCTION: name="transition_table_base_upd_func" function="transition_table_base_upd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 881 +CREATE TRIGGER transition_table_base_upd_trig + AFTER UPDATE ON transition_table_base + REFERENCING OLD TABLE AS oldtable NEW TABLE AS newtable + FOR EACH STATEMENT + EXECUTE PROCEDURE transition_table_base_upd_func() +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DDL +STMT: CreateTrigStmt +== 882 +UPDATE transition_table_base + SET val = '*' || val || '*' + WHERE id BETWEEN 2 AND 3 +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DML +STMT: UpdateStmt +== 883 +CREATE TABLE transition_table_level1 +( + level1_no serial NOT NULL , + level1_node_name varchar(255), + PRIMARY KEY (level1_no) +) WITHOUT OIDS +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: CreateStmt +== 884 +CREATE TABLE transition_table_level2 +( + level2_no serial NOT NULL , + parent_no int NOT NULL, + level1_node_name varchar(255), + PRIMARY KEY (level2_no) +) WITHOUT OIDS +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: CreateStmt +== 885 +CREATE TABLE transition_table_status +( + level int NOT NULL, + node_no int NOT NULL, + status int, + PRIMARY KEY (level, node_no) +) WITHOUT OIDS +-- +TABLE: name="transition_table_status" schema="" table="transition_table_status" ctx=DDL +STMT: CreateStmt +== 886 +CREATE FUNCTION transition_table_level1_ri_parent_del_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ + DECLARE n bigint; + BEGIN + PERFORM FROM p JOIN transition_table_level2 c ON c.parent_no = p.level1_no; + IF FOUND THEN + RAISE EXCEPTION 'RI error'; + END IF; + RETURN NULL; + END; +$$ +-- +FUNCTION: name="transition_table_level1_ri_parent_del_func" function="transition_table_level1_ri_parent_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 887 +CREATE TRIGGER transition_table_level1_ri_parent_del_trigger + AFTER DELETE ON transition_table_level1 + REFERENCING OLD TABLE AS p + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level1_ri_parent_del_func() +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: CreateTrigStmt +== 888 +CREATE FUNCTION transition_table_level1_ri_parent_upd_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ + DECLARE + x int; + BEGIN + WITH p AS (SELECT level1_no, sum(delta) cnt + FROM (SELECT level1_no, 1 AS delta FROM i + UNION ALL + SELECT level1_no, -1 AS delta FROM d) w + GROUP BY level1_no + HAVING sum(delta) < 0) + SELECT level1_no + FROM p JOIN transition_table_level2 c ON c.parent_no = p.level1_no + INTO x; + IF FOUND THEN + RAISE EXCEPTION 'RI error'; + END IF; + RETURN NULL; + END; +$$ +-- +FUNCTION: name="transition_table_level1_ri_parent_upd_func" function="transition_table_level1_ri_parent_upd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 889 +CREATE TRIGGER transition_table_level1_ri_parent_upd_trigger + AFTER UPDATE ON transition_table_level1 + REFERENCING OLD TABLE AS d NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level1_ri_parent_upd_func() +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: CreateTrigStmt +== 890 +CREATE FUNCTION transition_table_level2_ri_child_insupd_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ + BEGIN + PERFORM FROM i + LEFT JOIN transition_table_level1 p + ON p.level1_no IS NOT NULL AND p.level1_no = i.parent_no + WHERE p.level1_no IS NULL; + IF FOUND THEN + RAISE EXCEPTION 'RI error'; + END IF; + RETURN NULL; + END; +$$ +-- +FUNCTION: name="transition_table_level2_ri_child_insupd_func" function="transition_table_level2_ri_child_insupd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 891 +CREATE TRIGGER transition_table_level2_ri_child_ins_trigger + AFTER INSERT ON transition_table_level2 + REFERENCING NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level2_ri_child_insupd_func() +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: CreateTrigStmt +== 892 +CREATE TRIGGER transition_table_level2_ri_child_upd_trigger + AFTER UPDATE ON transition_table_level2 + REFERENCING NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level2_ri_child_insupd_func() +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: CreateTrigStmt +== 893 +-- create initial test data +INSERT INTO transition_table_level1 (level1_no) + SELECT generate_series(1,200) +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 894 +ANALYZE transition_table_level1 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: VacuumStmt +== 895 +INSERT INTO transition_table_level2 (level2_no, parent_no) + SELECT level2_no, level2_no / 50 + 1 AS parent_no + FROM generate_series(1,9999) level2_no +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 896 +ANALYZE transition_table_level2 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: VacuumStmt +== 897 +INSERT INTO transition_table_status (level, node_no, status) + SELECT 1, level1_no, 0 FROM transition_table_level1 +-- +TABLE: name="transition_table_status" schema="" table="transition_table_status" ctx=DML +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 898 +INSERT INTO transition_table_status (level, node_no, status) + SELECT 2, level2_no, 0 FROM transition_table_level2 +-- +TABLE: name="transition_table_status" schema="" table="transition_table_status" ctx=DML +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 899 +ANALYZE transition_table_status +-- +TABLE: name="transition_table_status" schema="" table="transition_table_status" ctx=DDL +STMT: VacuumStmt +== 900 +INSERT INTO transition_table_level1(level1_no) + SELECT generate_series(201,1000) +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 901 +ANALYZE transition_table_level1 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: VacuumStmt +== 902 +-- behave reasonably if someone tries to modify a transition table +CREATE FUNCTION transition_table_level2_bad_usage_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ + BEGIN + INSERT INTO dx VALUES (1000000, 1000000, 'x'); + RETURN NULL; + END; +$$ +-- +FUNCTION: name="transition_table_level2_bad_usage_func" function="transition_table_level2_bad_usage_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 903 +CREATE TRIGGER transition_table_level2_bad_usage_trigger + AFTER DELETE ON transition_table_level2 + REFERENCING OLD TABLE AS dx + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level2_bad_usage_func() +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: CreateTrigStmt +== 904 +DELETE FROM transition_table_level2 + WHERE level2_no BETWEEN 301 AND 305 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +STMT: DeleteStmt +== 905 +DROP TRIGGER transition_table_level2_bad_usage_trigger + ON transition_table_level2 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: DropStmt +== 906 +-- attempt modifications which would break RI (should all fail) +DELETE FROM transition_table_level1 + WHERE level1_no = 25 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +STMT: DeleteStmt +== 907 +UPDATE transition_table_level1 SET level1_no = -1 + WHERE level1_no = 30 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +STMT: UpdateStmt +== 908 +INSERT INTO transition_table_level2 (level2_no, parent_no) + VALUES (10000, 10000) +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 909 +UPDATE transition_table_level2 SET parent_no = 2000 + WHERE level2_no = 40 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +STMT: UpdateStmt +== 910 +-- attempt modifications which would not break RI (should all succeed) +DELETE FROM transition_table_level1 + WHERE level1_no BETWEEN 201 AND 1000 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +STMT: DeleteStmt +== 911 +DELETE FROM transition_table_level1 + WHERE level1_no BETWEEN 100000000 AND 100000010 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +STMT: DeleteStmt +== 912 +SELECT count(*) FROM transition_table_level1 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 913 +DELETE FROM transition_table_level2 + WHERE level2_no BETWEEN 211 AND 220 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +STMT: DeleteStmt +== 914 +SELECT count(*) FROM transition_table_level2 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 915 +CREATE TABLE alter_table_under_transition_tables +( + id int PRIMARY KEY, + name text +) +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: CreateStmt +== 916 +CREATE FUNCTION alter_table_under_transition_tables_upd_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ +BEGIN + RAISE WARNING 'old table = %, new table = %', + (SELECT string_agg(id || '=' || name, ',') FROM d), + (SELECT string_agg(id || '=' || name, ',') FROM i); + RAISE NOTICE 'one = %', (SELECT 1 FROM alter_table_under_transition_tables LIMIT 1); + RETURN NULL; +END; +$$ +-- +FUNCTION: name="alter_table_under_transition_tables_upd_func" function="alter_table_under_transition_tables_upd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 917 +-- should fail, TRUNCATE is not compatible with transition tables +CREATE TRIGGER alter_table_under_transition_tables_upd_trigger + AFTER TRUNCATE OR UPDATE ON alter_table_under_transition_tables + REFERENCING OLD TABLE AS d NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + alter_table_under_transition_tables_upd_func() +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: CreateTrigStmt +== 918 +-- should work +CREATE TRIGGER alter_table_under_transition_tables_upd_trigger + AFTER UPDATE ON alter_table_under_transition_tables + REFERENCING OLD TABLE AS d NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + alter_table_under_transition_tables_upd_func() +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: CreateTrigStmt +== 919 +INSERT INTO alter_table_under_transition_tables + VALUES (1, '1'), (2, '2'), (3, '3') +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 920 +UPDATE alter_table_under_transition_tables + SET name = name || name +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DML +STMT: UpdateStmt +== 921 +-- now change 'name' to an integer to see what happens... +ALTER TABLE alter_table_under_transition_tables + ALTER COLUMN name TYPE int USING name::integer +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: AlterTableStmt +== 922 +UPDATE alter_table_under_transition_tables + SET name = (name::text || name::text)::integer +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DML +STMT: UpdateStmt +== 923 +-- now drop column 'name' +ALTER TABLE alter_table_under_transition_tables + DROP column name +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: AlterTableStmt +== 924 +UPDATE alter_table_under_transition_tables + SET id = id +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DML +STMT: UpdateStmt +== 925 +|-- +-- Test multiple reference to a transition table +|-- + +CREATE TABLE multi_test (i int) +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DDL +STMT: CreateStmt +== 926 +INSERT INTO multi_test VALUES (1) +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 927 +CREATE OR REPLACE FUNCTION multi_test_trig() RETURNS trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'count = %', (SELECT COUNT(*) FROM new_test); + RAISE NOTICE 'count union = %', + (SELECT COUNT(*) + FROM (SELECT * FROM new_test UNION ALL SELECT * FROM new_test) ss); + RETURN NULL; +END$$ +-- +FUNCTION: name="multi_test_trig" function="multi_test_trig" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 928 +CREATE TRIGGER my_trigger AFTER UPDATE ON multi_test + REFERENCING NEW TABLE AS new_test OLD TABLE as old_test + FOR EACH STATEMENT EXECUTE PROCEDURE multi_test_trig() +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DDL +STMT: CreateTrigStmt +== 929 +UPDATE multi_test SET i = i +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DML +STMT: UpdateStmt +== 930 +DROP TABLE multi_test +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DDL +STMT: DropStmt +== 931 +DROP FUNCTION multi_test_trig() +-- +FUNCTION: name="multi_test_trig" function="multi_test_trig" schema="" ctx=DDL +STMT: DropStmt +== 932 +|-- +-- Check type parsing and record fetching from partitioned tables +|-- + +CREATE TABLE partitioned_table (a int, b text) PARTITION BY LIST (a) +-- +TABLE: name="partitioned_table" schema="" table="partitioned_table" ctx=DDL +STMT: CreateStmt +== 933 +CREATE TABLE pt_part1 PARTITION OF partitioned_table FOR VALUES IN (1) +-- +TABLE: name="pt_part1" schema="" table="pt_part1" ctx=DDL +STMT: CreateStmt +== 934 +CREATE TABLE pt_part2 PARTITION OF partitioned_table FOR VALUES IN (2) +-- +TABLE: name="pt_part2" schema="" table="pt_part2" ctx=DDL +STMT: CreateStmt +== 935 +INSERT INTO partitioned_table VALUES (1, 'Row 1') +-- +TABLE: name="partitioned_table" schema="" table="partitioned_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 936 +INSERT INTO partitioned_table VALUES (2, 'Row 2') +-- +TABLE: name="partitioned_table" schema="" table="partitioned_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 937 +CREATE OR REPLACE FUNCTION get_from_partitioned_table(partitioned_table.a%type) +RETURNS partitioned_table AS $$ +DECLARE + a_val partitioned_table.a%TYPE; + result partitioned_table%ROWTYPE; +BEGIN + a_val := $1; + SELECT * INTO result FROM partitioned_table WHERE a = a_val; + RETURN result; +END; $$ LANGUAGE plpgsql +-- +FUNCTION: name="get_from_partitioned_table" function="get_from_partitioned_table" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 938 +SELECT * FROM get_from_partitioned_table(1) AS t +-- +FUNCTION: name="get_from_partitioned_table" function="get_from_partitioned_table" schema="" ctx=Call +STMT: SelectStmt +== 939 +CREATE OR REPLACE FUNCTION list_partitioned_table() +RETURNS SETOF public.partitioned_table.a%TYPE AS $$ +DECLARE + row public.partitioned_table%ROWTYPE; + a_val public.partitioned_table.a%TYPE; +BEGIN + FOR row IN SELECT * FROM public.partitioned_table ORDER BY a LOOP + a_val := row.a; + RETURN NEXT a_val; + END LOOP; + RETURN; +END; $$ LANGUAGE plpgsql +-- +FUNCTION: name="list_partitioned_table" function="list_partitioned_table" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 940 +SELECT * FROM list_partitioned_table() AS t +-- +FUNCTION: name="list_partitioned_table" function="list_partitioned_table" schema="" ctx=Call +STMT: SelectStmt +== 941 +|-- +-- Check argument name is used instead of $n in error message +|-- +CREATE FUNCTION fx(x WSlot) RETURNS void AS $$ +BEGIN + GET DIAGNOSTICS x = ROW_COUNT; + RETURN; +END; $$ LANGUAGE plpgsql +-- +FUNCTION: name="fx" function="fx" schema="" ctx=DDL +STMT: CreateFunctionStmt diff --git a/parser/testdata/summary/postgres_regress/point.metadata.json b/parser/testdata/summary/postgres_regress/point.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/point.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/point.test b/parser/testdata/summary/postgres_regress/point.test new file mode 100644 index 0000000..13512cc --- /dev/null +++ b/parser/testdata/summary/postgres_regress/point.test @@ -0,0 +1,308 @@ +== 001 +|-- +-- POINT +|-- + +-- avoid bit-exact output here because operations may not be bit-exact. +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +== 002 +-- point_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. + +INSERT INTO POINT_TBL(f1) VALUES ('asdfasdf') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO POINT_TBL(f1) VALUES ('(10.0, 10.0) x') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO POINT_TBL(f1) VALUES ('(10.0, 1e+500)') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- Out of range + + +SELECT * FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +== 008 +-- left of +SELECT p.* FROM POINT_TBL p WHERE p.f1 << '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 009 +-- right of +SELECT p.* FROM POINT_TBL p WHERE '(0.0,0.0)' >> p.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 010 +-- above +SELECT p.* FROM POINT_TBL p WHERE '(0.0,0.0)' |>> p.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 011 +-- below +SELECT p.* FROM POINT_TBL p WHERE p.f1 <<| '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 012 +-- equal +SELECT p.* FROM POINT_TBL p WHERE p.f1 ~= '(5.1, 34.5)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 013 +-- point in box +SELECT p.* FROM POINT_TBL p + WHERE p.f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 014 +SELECT p.* FROM POINT_TBL p + WHERE box '(0,0,100,100)' @> p.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 015 +SELECT p.* FROM POINT_TBL p + WHERE not p.f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 016 +SELECT p.* FROM POINT_TBL p + WHERE p.f1 <@ path '[(0,0),(-10,0),(-10,10)]' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 017 +SELECT p.* FROM POINT_TBL p + WHERE not box '(0,0,100,100)' @> p.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +== 018 +SELECT p.f1, p.f1 <-> point '(0,0)' AS dist + FROM POINT_TBL p + ORDER BY dist +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +STMT: SelectStmt +== 019 +SELECT p1.f1 AS point1, p2.f1 AS point2, p1.f1 <-> p2.f1 AS dist + FROM POINT_TBL p1, POINT_TBL p2 + ORDER BY dist, p1.f1[0], p2.f1[0] +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +STMT: SelectStmt +== 020 +SELECT p1.f1 AS point1, p2.f1 AS point2 + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 021 +-- put distance result into output to allow sorting with GEQ optimizer - tgl 97/05/10 +SELECT p1.f1 AS point1, p2.f1 AS point2, (p1.f1 <-> p2.f1) AS distance + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1 + ORDER BY distance, p1.f1[0], p2.f1[0] +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 022 +-- put distance result into output to allow sorting with GEQ optimizer - tgl 97/05/10 +SELECT p1.f1 AS point1, p2.f1 AS point2, (p1.f1 <-> p2.f1) AS distance + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1 and p1.f1 |>> p2.f1 + ORDER BY distance +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +== 023 +-- Test that GiST indexes provide same behavior as sequential scan +CREATE TEMP TABLE point_gist_tbl(f1 point) +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=DDL +STMT: CreateStmt +== 024 +INSERT INTO point_gist_tbl SELECT '(0,0)' FROM generate_series(0,1000) +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 025 +CREATE INDEX point_gist_tbl_index ON point_gist_tbl USING gist (f1) +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=DDL +STMT: IndexStmt +== 026 +INSERT INTO point_gist_tbl VALUES ('(0.0000009,0.0000009)') +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +SET enable_seqscan TO true +-- +STMT: VariableSetStmt +== 028 +SET enable_indexscan TO false +-- +STMT: VariableSetStmt +== 029 +SET enable_bitmapscan TO false +-- +STMT: VariableSetStmt +== 030 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000009,0.0000009)'::point +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 031 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 <@ '(0.0000009,0.0000009),(0.0000009,0.0000009)'::box +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 032 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 033 +SET enable_seqscan TO false +-- +STMT: VariableSetStmt +== 034 +SET enable_indexscan TO true +-- +STMT: VariableSetStmt +== 035 +SET enable_bitmapscan TO true +-- +STMT: VariableSetStmt +== 036 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000009,0.0000009)'::point +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 037 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 <@ '(0.0000009,0.0000009),(0.0000009,0.0000009)'::box +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 038 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 039 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 040 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 041 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 042 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('1,y', 'point') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT * FROM pg_input_error_info('1,y', 'point') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/polygon.metadata.json b/parser/testdata/summary/postgres_regress/polygon.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/polygon.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/polygon.test b/parser/testdata/summary/postgres_regress/polygon.test new file mode 100644 index 0000000..f04d37d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/polygon.test @@ -0,0 +1,444 @@ +== 001 +|-- +-- POLYGON +|-- +-- polygon logic +|-- + +CREATE TABLE POLYGON_TBL(f1 polygon) +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO POLYGON_TBL(f1) VALUES ('(2.0,0.0),(2.0,4.0),(0.0,0.0)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO POLYGON_TBL(f1) VALUES ('(3.0,1.0),(3.0,3.0),(1.0,0.0)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO POLYGON_TBL(f1) VALUES ('(1,2),(3,4),(5,6),(7,8)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO POLYGON_TBL(f1) VALUES ('(7,8),(5,6),(3,4),(1,2)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +-- Reverse +INSERT INTO POLYGON_TBL(f1) VALUES ('(1,2),(7,8),(5,6),(3,-4)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- degenerate polygons +INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0,0.0)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0,1.0),(0.0,1.0)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +-- bad polygon input strings +INSERT INTO POLYGON_TBL(f1) VALUES ('0.0') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0 0.0') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2,3') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO POLYGON_TBL(f1) VALUES ('asdf') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +SELECT * FROM POLYGON_TBL +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +STMT: SelectStmt +== 015 +|-- +-- Test the SP-GiST index +|-- + +CREATE TABLE quad_poly_tbl (id int, p polygon) +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DDL +STMT: CreateStmt +== 016 +INSERT INTO quad_poly_tbl + SELECT (x - 1) * 100 + y, polygon(circle(point(x * 10, y * 10), 1 + (x + y) % 10)) + FROM generate_series(1, 100) x, + generate_series(1, 100) y +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DML +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO quad_poly_tbl + SELECT i, polygon '((200, 300),(210, 310),(230, 290))' + FROM generate_series(10001, 11000) AS i +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO quad_poly_tbl + VALUES + (11001, NULL), + (11002, NULL), + (11003, NULL) +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +CREATE INDEX quad_poly_tbl_idx ON quad_poly_tbl USING spgist(p) +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DDL +STMT: IndexStmt +== 020 +-- get reference results for ORDER BY distance from seq scan +SET enable_seqscan = ON +-- +STMT: VariableSetStmt +== 021 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +== 022 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 023 +CREATE TEMP TABLE quad_poly_tbl_ord_seq2 AS +SELECT rank() OVER (ORDER BY p <-> point '123,456') n, p <-> point '123,456' dist, id +FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl_ord_seq2" schema="" table="quad_poly_tbl_ord_seq2" ctx=DDL +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 024 +-- check results from index scan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +== 025 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +== 026 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +== 027 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p << polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 028 +SELECT count(*) FROM quad_poly_tbl WHERE p << polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 029 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p &< polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 030 +SELECT count(*) FROM quad_poly_tbl WHERE p &< polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 031 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p && polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 032 +SELECT count(*) FROM quad_poly_tbl WHERE p && polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 033 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p &> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 034 +SELECT count(*) FROM quad_poly_tbl WHERE p &> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 035 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p >> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 036 +SELECT count(*) FROM quad_poly_tbl WHERE p >> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 037 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p <<| polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 038 +SELECT count(*) FROM quad_poly_tbl WHERE p <<| polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 039 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p &<| polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 040 +SELECT count(*) FROM quad_poly_tbl WHERE p &<| polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 041 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p |&> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 042 +SELECT count(*) FROM quad_poly_tbl WHERE p |&> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 043 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p |>> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 044 +SELECT count(*) FROM quad_poly_tbl WHERE p |>> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 045 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 046 +SELECT count(*) FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 047 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p @> polygon '((340,550),(343,552),(341,553))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 048 +SELECT count(*) FROM quad_poly_tbl WHERE p @> polygon '((340,550),(343,552),(341,553))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 049 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p ~= polygon '((200, 300),(210, 310),(230, 290))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 050 +SELECT count(*) FROM quad_poly_tbl WHERE p ~= polygon '((200, 300),(210, 310),(230, 290))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +== 051 +-- test ORDER BY distance +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +== 052 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +== 053 +EXPLAIN (COSTS OFF) +SELECT rank() OVER (ORDER BY p <-> point '123,456') n, p <-> point '123,456' dist, id +FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +== 054 +CREATE TEMP TABLE quad_poly_tbl_ord_idx2 AS +SELECT rank() OVER (ORDER BY p <-> point '123,456') n, p <-> point '123,456' dist, id +FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl_ord_idx2" schema="" table="quad_poly_tbl_ord_idx2" ctx=DDL +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 055 +SELECT * +FROM quad_poly_tbl_ord_seq2 seq FULL JOIN quad_poly_tbl_ord_idx2 idx + ON seq.n = idx.n AND seq.id = idx.id AND + (seq.dist = idx.dist OR seq.dist IS NULL AND idx.dist IS NULL) +WHERE seq.id IS NULL OR idx.id IS NULL +-- +TABLE: name="quad_poly_tbl_ord_seq2" schema="" table="quad_poly_tbl_ord_seq2" ctx=Select +TABLE: name="quad_poly_tbl_ord_idx2" schema="" table="quad_poly_tbl_ord_idx2" ctx=Select +ALIAS: "idx"="quad_poly_tbl_ord_idx2" +ALIAS: "seq"="quad_poly_tbl_ord_seq2" +FILTER: schema="" table="seq" column="id" +FILTER: schema="" table="idx" column="id" +STMT: SelectStmt +== 056 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 057 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 058 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 059 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('(2.0,0.8,0.1)', 'polygon') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT * FROM pg_input_error_info('(2.0,0.8,0.1)', 'polygon') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT pg_input_is_valid('(2.0,xyz)', 'polygon') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 062 +SELECT * FROM pg_input_error_info('(2.0,xyz)', 'polygon') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/polymorphism.metadata.json b/parser/testdata/summary/postgres_regress/polymorphism.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/polymorphism.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/polymorphism.test b/parser/testdata/summary/postgres_regress/polymorphism.test new file mode 100644 index 0000000..5016c8b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/polymorphism.test @@ -0,0 +1,2812 @@ +== 001 +|-- +-- Tests for polymorphic SQL functions and aggregates based on them. +-- Tests for other features related to function-calling have snuck in, too. +|-- + +create function polyf(x anyelement) returns anyelement as $$ + select x + 1 +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +select polyf(42) as int, polyf(4.5) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 003 +select polyf(point(3,4)) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 004 +-- fail for lack of + operator + +drop function polyf(x anyelement) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 005 +create function polyf(x anyelement) returns anyarray as $$ + select array[x + 1, x + 2] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +select polyf(42) as int, polyf(4.5) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 007 +drop function polyf(x anyelement) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 008 +create function polyf(x anyarray) returns anyelement as $$ + select x[1] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 009 +select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 010 +select polyf(stavalues1) from pg_statistic +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 011 +-- fail, can't infer element type + +drop function polyf(x anyarray) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 012 +create function polyf(x anyarray) returns anyarray as $$ + select x +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 013 +select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 014 +select polyf(stavalues1) from pg_statistic +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 015 +-- fail, can't infer element type + +drop function polyf(x anyarray) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 016 +-- fail, can't infer type: +create function polyf(x anyelement) returns anyrange as $$ + select array[x + 1, x + 2] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 017 +create function polyf(x anyrange) returns anyarray as $$ + select array[lower(x), upper(x)] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 018 +select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +== 019 +drop function polyf(x anyrange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 020 +create function polyf(x anycompatible, y anycompatible) returns anycompatiblearray as $$ + select array[x, y] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 021 +select polyf(2, 4) as int, polyf(2, 4.5) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 022 +drop function polyf(x anycompatible, y anycompatible) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 023 +create function polyf(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$ + select array[lower(x), upper(x), y, z] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 024 +select polyf(int4range(42, 49), 11, 2::smallint) as int, polyf(float8range(4.5, 7.8), 7.8, 11::real) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +== 025 +select polyf(int4range(42, 49), 11, 4.5) as fail +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 026 +-- range type doesn't fit + +drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 027 +create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$ + select array[lower(x), upper(x), y, z] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 028 +select polyf(multirange(int4range(42, 49)), 11, 2::smallint) as int, polyf(multirange(float8range(4.5, 7.8)), 7.8, 11::real) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +== 029 +select polyf(multirange(int4range(42, 49)), 11, 4.5) as fail +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 030 +-- range type doesn't fit + +drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 031 +-- fail, can't infer type: +create function polyf(x anycompatible) returns anycompatiblerange as $$ + select array[x + 1, x + 2] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 032 +create function polyf(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$ + select x +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 033 +select polyf(int4range(42, 49), array[11]) as int, polyf(float8range(4.5, 7.8), array[7]) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +== 034 +drop function polyf(x anycompatiblerange, y anycompatiblearray) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 035 +-- fail, can't infer type: +create function polyf(x anycompatible) returns anycompatiblemultirange as $$ + select array[x + 1, x + 2] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 036 +create function polyf(x anycompatiblemultirange, y anycompatiblearray) returns anycompatiblemultirange as $$ + select x +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 037 +select polyf(multirange(int4range(42, 49)), array[11]) as int, polyf(multirange(float8range(4.5, 7.8)), array[7]) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +== 038 +drop function polyf(x anycompatiblemultirange, y anycompatiblearray) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 039 +create function polyf(a anyelement, b anyarray, + c anycompatible, d anycompatible, + OUT x anyarray, OUT y anycompatiblearray) +as $$ + select a || b, array[c, d] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 040 +select x, pg_typeof(x), y, pg_typeof(y) + from polyf(11, array[1, 2], 42, 34.5) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 041 +select x, pg_typeof(x), y, pg_typeof(y) + from polyf(11, array[1, 2], point(1,2), point(3,4)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 042 +select x, pg_typeof(x), y, pg_typeof(y) + from polyf(11, '{1,2}', point(1,2), '(3,4)') +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +== 043 +select x, pg_typeof(x), y, pg_typeof(y) + from polyf(11, array[1, 2.2], 42, 34.5) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 044 +-- fail + +drop function polyf(a anyelement, b anyarray, + c anycompatible, d anycompatible) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 045 +create function polyf(anyrange) returns anymultirange +as 'select multirange($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 046 +select polyf(int4range(1,10)) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 047 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 048 +drop function polyf(anyrange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 049 +create function polyf(anymultirange) returns anyelement +as 'select lower($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 050 +select polyf(int4multirange(int4range(1,10), int4range(20,30))) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 051 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 052 +drop function polyf(anymultirange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 053 +create function polyf(anycompatiblerange) returns anycompatiblemultirange +as 'select multirange($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 054 +select polyf(int4range(1,10)) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 055 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 056 +drop function polyf(anycompatiblerange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 057 +create function polyf(anymultirange) returns anyrange +as 'select range_merge($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 058 +select polyf(int4multirange(int4range(1,10), int4range(20,30))) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 059 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 060 +drop function polyf(anymultirange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 061 +create function polyf(anycompatiblemultirange) returns anycompatiblerange +as 'select range_merge($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 062 +select polyf(int4multirange(int4range(1,10), int4range(20,30))) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 063 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 064 +drop function polyf(anycompatiblemultirange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 065 +create function polyf(anycompatiblemultirange) returns anycompatible +as 'select lower($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 066 +select polyf(int4multirange(int4range(1,10), int4range(20,30))) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 067 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +== 068 +drop function polyf(anycompatiblemultirange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +== 069 +|-- +-- Polymorphic aggregate tests +|-- +-- Legend: +----------- +-- A = type is ANY +-- P = type is polymorphic +-- N = type is non-polymorphic +-- B = aggregate base type +-- S = aggregate state type +-- R = aggregate return type +-- 1 = arg1 of a function +-- 2 = arg2 of a function +-- ag = aggregate +-- tf = trans (state) function +-- ff = final function +-- rt = return type of a function +-- -> = implies +-- => = allowed +-- !> = not allowed +-- E = exists +-- NE = not-exists +|-- +-- Possible states: +-- ---------------- +-- B = (A || P || N) +-- when (B = A) -> (tf2 = NE) +-- S = (P || N) +-- ff = (E || NE) +-- tf1 = (P || N) +-- tf2 = (NE || P || N) +-- R = (P || N) + +-- create functions for use as tf and ff with the needed combinations of +-- argument polymorphism, but within the constraints of valid aggregate +-- functions, i.e. tf arg1 and tf return type must match + +-- polymorphic single arg transfn +CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="stfp" function="stfp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 070 +-- non-polymorphic single arg transfn +CREATE FUNCTION stfnp(int[]) RETURNS int[] AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="stfnp" function="stfnp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 071 +-- dual polymorphic transfn +CREATE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS +'select $1 || $2' LANGUAGE SQL +-- +FUNCTION: name="tfp" function="tfp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 072 +-- dual non-polymorphic transfn +CREATE FUNCTION tfnp(int[],int) RETURNS int[] AS +'select $1 || $2' LANGUAGE SQL +-- +FUNCTION: name="tfnp" function="tfnp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 073 +-- arg1 only polymorphic transfn +CREATE FUNCTION tf1p(anyarray,int) RETURNS anyarray AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="tf1p" function="tf1p" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 074 +-- arg2 only polymorphic transfn +CREATE FUNCTION tf2p(int[],anyelement) RETURNS int[] AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="tf2p" function="tf2p" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 075 +-- multi-arg polymorphic +CREATE FUNCTION sum3(anyelement,anyelement,anyelement) returns anyelement AS +'select $1+$2+$3' language sql strict +-- +FUNCTION: name="sum3" function="sum3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 076 +-- finalfn polymorphic +CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="ffp" function="ffp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 077 +-- finalfn non-polymorphic +CREATE FUNCTION ffnp(int[]) returns int[] as +'select $1' LANGUAGE SQL +-- +FUNCTION: name="ffnp" function="ffnp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 078 +-- Try to cover all the possible states: +|-- +-- Note: in Cases 1 & 2, we are trying to return P. Therefore, if the transfn +-- is stfnp, tfnp, or tf2p, we must use ffp as finalfn, because stfnp, tfnp, +-- and tf2p do not return P. Conversely, in Cases 3 & 4, we are trying to +-- return N. Therefore, if the transfn is stfp, tfp, or tf1p, we must use ffnp +-- as finalfn, because stfp, tfp, and tf1p do not return N. +|-- +-- Case1 (R = P) && (B = A) +-- ------------------------ +-- S tf1 +-- ------- +-- N N +-- should CREATE +CREATE AGGREGATE myaggp01a(*) (SFUNC = stfnp, STYPE = int4[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 079 +-- P N +-- should ERROR: stfnp(anyarray) not matched by stfnp(int[]) +CREATE AGGREGATE myaggp02a(*) (SFUNC = stfnp, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 080 +-- N P +-- should CREATE +CREATE AGGREGATE myaggp03a(*) (SFUNC = stfp, STYPE = int4[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 081 +CREATE AGGREGATE myaggp03b(*) (SFUNC = stfp, STYPE = int4[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 082 +-- P P +-- should ERROR: we have no way to resolve S +CREATE AGGREGATE myaggp04a(*) (SFUNC = stfp, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 083 +CREATE AGGREGATE myaggp04b(*) (SFUNC = stfp, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +== 084 +-- Case2 (R = P) && ((B = P) || (B = N)) +-- ------------------------------------- +-- S tf1 B tf2 +-- ----------------------- +-- N N N N +-- should CREATE +CREATE AGGREGATE myaggp05a(BASETYPE = int, SFUNC = tfnp, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 085 +-- N N N P +-- should CREATE +CREATE AGGREGATE myaggp06a(BASETYPE = int, SFUNC = tf2p, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 086 +-- N N P N +-- should ERROR: tfnp(int[], anyelement) not matched by tfnp(int[], int) +CREATE AGGREGATE myaggp07a(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 087 +-- N N P P +-- should CREATE +CREATE AGGREGATE myaggp08a(BASETYPE = anyelement, SFUNC = tf2p, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 088 +-- N P N N +-- should CREATE +CREATE AGGREGATE myaggp09a(BASETYPE = int, SFUNC = tf1p, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 089 +CREATE AGGREGATE myaggp09b(BASETYPE = int, SFUNC = tf1p, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 090 +-- N P N P +-- should CREATE +CREATE AGGREGATE myaggp10a(BASETYPE = int, SFUNC = tfp, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 091 +CREATE AGGREGATE myaggp10b(BASETYPE = int, SFUNC = tfp, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 092 +-- N P P N +-- should ERROR: tf1p(int[],anyelement) not matched by tf1p(anyarray,int) +CREATE AGGREGATE myaggp11a(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 093 +CREATE AGGREGATE myaggp11b(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 094 +-- N P P P +-- should ERROR: tfp(int[],anyelement) not matched by tfp(anyarray,anyelement) +CREATE AGGREGATE myaggp12a(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 095 +CREATE AGGREGATE myaggp12b(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 096 +-- P N N N +-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int) +CREATE AGGREGATE myaggp13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 097 +-- P N N P +-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement) +CREATE AGGREGATE myaggp14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 098 +-- P N P N +-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int) +CREATE AGGREGATE myaggp15a(BASETYPE = anyelement, SFUNC = tfnp, + STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 099 +-- P N P P +-- should ERROR: tf2p(anyarray, anyelement) not matched by tf2p(int[],anyelement) +CREATE AGGREGATE myaggp16a(BASETYPE = anyelement, SFUNC = tf2p, + STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 100 +-- P P N N +-- should ERROR: we have no way to resolve S +CREATE AGGREGATE myaggp17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 101 +CREATE AGGREGATE myaggp17b(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +== 102 +-- P P N P +-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement) +CREATE AGGREGATE myaggp18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 103 +CREATE AGGREGATE myaggp18b(BASETYPE = int, SFUNC = tfp, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +== 104 +-- P P P N +-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int) +CREATE AGGREGATE myaggp19a(BASETYPE = anyelement, SFUNC = tf1p, + STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 105 +CREATE AGGREGATE myaggp19b(BASETYPE = anyelement, SFUNC = tf1p, + STYPE = anyarray, INITCOND = '{}') +-- +STMT: DefineStmt +== 106 +-- P P P P +-- should CREATE +CREATE AGGREGATE myaggp20a(BASETYPE = anyelement, SFUNC = tfp, + STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +== 107 +CREATE AGGREGATE myaggp20b(BASETYPE = anyelement, SFUNC = tfp, + STYPE = anyarray, INITCOND = '{}') +-- +STMT: DefineStmt +== 108 +-- Case3 (R = N) && (B = A) +-- ------------------------ +-- S tf1 +-- ------- +-- N N +-- should CREATE +CREATE AGGREGATE myaggn01a(*) (SFUNC = stfnp, STYPE = int4[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 109 +CREATE AGGREGATE myaggn01b(*) (SFUNC = stfnp, STYPE = int4[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 110 +-- P N +-- should ERROR: stfnp(anyarray) not matched by stfnp(int[]) +CREATE AGGREGATE myaggn02a(*) (SFUNC = stfnp, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 111 +CREATE AGGREGATE myaggn02b(*) (SFUNC = stfnp, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +== 112 +-- N P +-- should CREATE +CREATE AGGREGATE myaggn03a(*) (SFUNC = stfp, STYPE = int4[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 113 +-- P P +-- should ERROR: ffnp(anyarray) not matched by ffnp(int[]) +CREATE AGGREGATE myaggn04a(*) (SFUNC = stfp, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 114 +-- Case4 (R = N) && ((B = P) || (B = N)) +-- ------------------------------------- +-- S tf1 B tf2 +-- ----------------------- +-- N N N N +-- should CREATE +CREATE AGGREGATE myaggn05a(BASETYPE = int, SFUNC = tfnp, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 115 +CREATE AGGREGATE myaggn05b(BASETYPE = int, SFUNC = tfnp, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 116 +-- N N N P +-- should CREATE +CREATE AGGREGATE myaggn06a(BASETYPE = int, SFUNC = tf2p, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 117 +CREATE AGGREGATE myaggn06b(BASETYPE = int, SFUNC = tf2p, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 118 +-- N N P N +-- should ERROR: tfnp(int[], anyelement) not matched by tfnp(int[], int) +CREATE AGGREGATE myaggn07a(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 119 +CREATE AGGREGATE myaggn07b(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 120 +-- N N P P +-- should CREATE +CREATE AGGREGATE myaggn08a(BASETYPE = anyelement, SFUNC = tf2p, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 121 +CREATE AGGREGATE myaggn08b(BASETYPE = anyelement, SFUNC = tf2p, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +== 122 +-- N P N N +-- should CREATE +CREATE AGGREGATE myaggn09a(BASETYPE = int, SFUNC = tf1p, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 123 +-- N P N P +-- should CREATE +CREATE AGGREGATE myaggn10a(BASETYPE = int, SFUNC = tfp, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 124 +-- N P P N +-- should ERROR: tf1p(int[],anyelement) not matched by tf1p(anyarray,int) +CREATE AGGREGATE myaggn11a(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 125 +-- N P P P +-- should ERROR: tfp(int[],anyelement) not matched by tfp(anyarray,anyelement) +CREATE AGGREGATE myaggn12a(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 126 +-- P N N N +-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int) +CREATE AGGREGATE myaggn13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 127 +CREATE AGGREGATE myaggn13b(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +== 128 +-- P N N P +-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement) +CREATE AGGREGATE myaggn14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 129 +CREATE AGGREGATE myaggn14b(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +== 130 +-- P N P N +-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int) +CREATE AGGREGATE myaggn15a(BASETYPE = anyelement, SFUNC = tfnp, + STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 131 +CREATE AGGREGATE myaggn15b(BASETYPE = anyelement, SFUNC = tfnp, + STYPE = anyarray, INITCOND = '{}') +-- +STMT: DefineStmt +== 132 +-- P N P P +-- should ERROR: tf2p(anyarray, anyelement) not matched by tf2p(int[],anyelement) +CREATE AGGREGATE myaggn16a(BASETYPE = anyelement, SFUNC = tf2p, + STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 133 +CREATE AGGREGATE myaggn16b(BASETYPE = anyelement, SFUNC = tf2p, + STYPE = anyarray, INITCOND = '{}') +-- +STMT: DefineStmt +== 134 +-- P P N N +-- should ERROR: ffnp(anyarray) not matched by ffnp(int[]) +CREATE AGGREGATE myaggn17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 135 +-- P P N P +-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement) +CREATE AGGREGATE myaggn18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 136 +-- P P P N +-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int) +CREATE AGGREGATE myaggn19a(BASETYPE = anyelement, SFUNC = tf1p, + STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 137 +-- P P P P +-- should ERROR: ffnp(anyarray) not matched by ffnp(int[]) +CREATE AGGREGATE myaggn20a(BASETYPE = anyelement, SFUNC = tfp, + STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +== 138 +-- multi-arg polymorphic +CREATE AGGREGATE mysum2(anyelement,anyelement) (SFUNC = sum3, + STYPE = anyelement, INITCOND = '0') +-- +STMT: DefineStmt +== 139 +-- create test data for polymorphic aggregates +create temp table t(f1 int, f2 int[], f3 text) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +== 140 +insert into t values(1,array[1],'a') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 141 +insert into t values(1,array[11],'b') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +insert into t values(1,array[111],'c') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +insert into t values(2,array[2],'a') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +insert into t values(2,array[22],'b') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 145 +insert into t values(2,array[222],'c') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +insert into t values(3,array[3],'a') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +insert into t values(3,array[3],'b') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 148 +-- test the successfully created polymorphic aggregates +select f3, myaggp01a(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp01a" function="myaggp01a" schema="" ctx=Call +STMT: SelectStmt +== 149 +select f3, myaggp03a(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp03a" function="myaggp03a" schema="" ctx=Call +STMT: SelectStmt +== 150 +select f3, myaggp03b(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp03b" function="myaggp03b" schema="" ctx=Call +STMT: SelectStmt +== 151 +select f3, myaggp05a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp05a" function="myaggp05a" schema="" ctx=Call +STMT: SelectStmt +== 152 +select f3, myaggp06a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp06a" function="myaggp06a" schema="" ctx=Call +STMT: SelectStmt +== 153 +select f3, myaggp08a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp08a" function="myaggp08a" schema="" ctx=Call +STMT: SelectStmt +== 154 +select f3, myaggp09a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp09a" function="myaggp09a" schema="" ctx=Call +STMT: SelectStmt +== 155 +select f3, myaggp09b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp09b" function="myaggp09b" schema="" ctx=Call +STMT: SelectStmt +== 156 +select f3, myaggp10a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp10a" function="myaggp10a" schema="" ctx=Call +STMT: SelectStmt +== 157 +select f3, myaggp10b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp10b" function="myaggp10b" schema="" ctx=Call +STMT: SelectStmt +== 158 +select f3, myaggp20a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp20a" function="myaggp20a" schema="" ctx=Call +STMT: SelectStmt +== 159 +select f3, myaggp20b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp20b" function="myaggp20b" schema="" ctx=Call +STMT: SelectStmt +== 160 +select f3, myaggn01a(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn01a" function="myaggn01a" schema="" ctx=Call +STMT: SelectStmt +== 161 +select f3, myaggn01b(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn01b" function="myaggn01b" schema="" ctx=Call +STMT: SelectStmt +== 162 +select f3, myaggn03a(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn03a" function="myaggn03a" schema="" ctx=Call +STMT: SelectStmt +== 163 +select f3, myaggn05a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn05a" function="myaggn05a" schema="" ctx=Call +STMT: SelectStmt +== 164 +select f3, myaggn05b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn05b" function="myaggn05b" schema="" ctx=Call +STMT: SelectStmt +== 165 +select f3, myaggn06a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn06a" function="myaggn06a" schema="" ctx=Call +STMT: SelectStmt +== 166 +select f3, myaggn06b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn06b" function="myaggn06b" schema="" ctx=Call +STMT: SelectStmt +== 167 +select f3, myaggn08a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn08a" function="myaggn08a" schema="" ctx=Call +STMT: SelectStmt +== 168 +select f3, myaggn08b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn08b" function="myaggn08b" schema="" ctx=Call +STMT: SelectStmt +== 169 +select f3, myaggn09a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn09a" function="myaggn09a" schema="" ctx=Call +STMT: SelectStmt +== 170 +select f3, myaggn10a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn10a" function="myaggn10a" schema="" ctx=Call +STMT: SelectStmt +== 171 +select mysum2(f1, f1 + 1) from t +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="mysum2" function="mysum2" schema="" ctx=Call +STMT: SelectStmt +== 172 +-- test inlining of polymorphic SQL functions +create function bleat(int) returns int as $$ +begin + raise notice 'bleat %', $1; + return $1; +end$$ language plpgsql +-- +FUNCTION: name="bleat" function="bleat" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 173 +create function sql_if(bool, anyelement, anyelement) returns anyelement as $$ +select case when $1 then $2 else $3 end $$ language sql +-- +FUNCTION: name="sql_if" function="sql_if" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 174 +-- Note this would fail with integer overflow, never mind wrong bleat() output, +-- if the CASE expression were not successfully inlined +select f1, sql_if(f1 > 0, bleat(f1), bleat(f1 + 1)) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="sql_if" function="sql_if" schema="" ctx=Call +FUNCTION: name="bleat" function="bleat" schema="" ctx=Call +FUNCTION: name="bleat" function="bleat" schema="" ctx=Call +STMT: SelectStmt +== 175 +select q2, sql_if(q2 > 0, q2, q2 + 1) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="sql_if" function="sql_if" schema="" ctx=Call +STMT: SelectStmt +== 176 +-- another sort of polymorphic aggregate + +CREATE AGGREGATE array_larger_accum (anyarray) +( + sfunc = array_larger, + stype = anyarray, + initcond = '{}' +) +-- +STMT: DefineStmt +== 177 +SELECT array_larger_accum(i) +FROM (VALUES (ARRAY[1,2]), (ARRAY[3,4])) as t(i) +-- +FUNCTION: name="array_larger_accum" function="array_larger_accum" schema="" ctx=Call +STMT: SelectStmt +== 178 +SELECT array_larger_accum(i) +FROM (VALUES (ARRAY[row(1,2),row(3,4)]), (ARRAY[row(5,6),row(7,8)])) as t(i) +-- +FUNCTION: name="array_larger_accum" function="array_larger_accum" schema="" ctx=Call +STMT: SelectStmt +== 179 +-- another kind of polymorphic aggregate + +create function add_group(grp anyarray, ad anyelement, size integer) + returns anyarray + as $$ +begin + if grp is null then + return array[ad]; + end if; + if array_upper(grp, 1) < size then + return grp || ad; + end if; + return grp; +end; +$$ + language plpgsql immutable +-- +FUNCTION: name="add_group" function="add_group" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 180 +create aggregate build_group(anyelement, integer) ( + SFUNC = add_group, + STYPE = anyarray +) +-- +STMT: DefineStmt +== 181 +select build_group(q1,3) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="build_group" function="build_group" schema="" ctx=Call +STMT: SelectStmt +== 182 +-- this should fail because stype isn't compatible with arg +create aggregate build_group(int8, integer) ( + SFUNC = add_group, + STYPE = int2[] +) +-- +STMT: DefineStmt +== 183 +-- but we can make a non-poly agg from a poly sfunc if types are OK +create aggregate build_group(int8, integer) ( + SFUNC = add_group, + STYPE = int8[] +) +-- +STMT: DefineStmt +== 184 +-- check proper resolution of data types for polymorphic transfn/finalfn + +create function first_el_transfn(anyarray, anyelement) returns anyarray as +'select $1 || $2' language sql immutable +-- +FUNCTION: name="first_el_transfn" function="first_el_transfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 185 +create function first_el(anyarray) returns anyelement as +'select $1[1]' language sql strict immutable +-- +FUNCTION: name="first_el" function="first_el" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 186 +create aggregate first_el_agg_f8(float8) ( + SFUNC = array_append, + STYPE = float8[], + FINALFUNC = first_el +) +-- +STMT: DefineStmt +== 187 +create aggregate first_el_agg_any(anyelement) ( + SFUNC = first_el_transfn, + STYPE = anyarray, + FINALFUNC = first_el +) +-- +STMT: DefineStmt +== 188 +select first_el_agg_f8(x::float8) from generate_series(1,10) x +-- +FUNCTION: name="first_el_agg_f8" function="first_el_agg_f8" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 189 +select first_el_agg_any(x) from generate_series(1,10) x +-- +FUNCTION: name="first_el_agg_any" function="first_el_agg_any" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 190 +select first_el_agg_f8(x::float8) over(order by x) from generate_series(1,10) x +-- +FUNCTION: name="first_el_agg_f8" function="first_el_agg_f8" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 191 +select first_el_agg_any(x) over(order by x) from generate_series(1,10) x +-- +FUNCTION: name="first_el_agg_any" function="first_el_agg_any" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 192 +-- check that we can apply functions taking ANYARRAY to pg_stats +select distinct array_ndims(histogram_bounds) from pg_stats +where histogram_bounds is not null +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +FUNCTION: name="array_ndims" function="array_ndims" schema="" ctx=Call +FILTER: schema="" table="" column="histogram_bounds" +STMT: SelectStmt +== 193 +-- such functions must protect themselves if varying element type isn't OK +-- (WHERE clause here is to avoid possibly getting a collation error instead) +select max(histogram_bounds) from pg_stats where tablename = 'pg_am' +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 194 +-- another corner case is the input functions for polymorphic pseudotypes +select array_in('{1,2,3}','int4'::regtype,-1) +-- +FUNCTION: name="array_in" function="array_in" schema="" ctx=Call +STMT: SelectStmt +== 195 +-- this has historically worked +select * from array_in('{1,2,3}','int4'::regtype,-1) +-- +FUNCTION: name="array_in" function="array_in" schema="" ctx=Call +STMT: SelectStmt +== 196 +-- this not +select anyrange_in('[10,20)','int4range'::regtype,-1) +-- +FUNCTION: name="anyrange_in" function="anyrange_in" schema="" ctx=Call +STMT: SelectStmt +== 197 +-- test variadic polymorphic functions + +create function myleast(variadic anyarray) returns anyelement as $$ + select min($1[i]) from generate_subscripts($1,1) g(i) +$$ language sql immutable strict +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 198 +select myleast(10, 1, 20, 33) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +== 199 +select myleast(1.1, 0.22, 0.55) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +== 200 +select myleast('z'::text) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +== 201 +select myleast() +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +== 202 +-- fail + +-- test with variadic call parameter +select myleast(variadic array[1,2,3,4,-1]) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +== 203 +select myleast(variadic array[1.1, -5.5]) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +== 204 +--test with empty variadic call parameter +select myleast(variadic array[]::int[]) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +== 205 +-- an example with some ordinary arguments too +create function concat(text, variadic anyarray) returns text as $$ + select array_to_string($2, $1); +$$ language sql immutable strict +-- +FUNCTION: name="concat" function="concat" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 206 +select concat('%', 1, 2, 3, 4, 5) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +== 207 +select concat('|', 'a'::text, 'b', 'c') +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +== 208 +select concat('|', variadic array[1,2,33]) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +== 209 +select concat('|', variadic array[]::int[]) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +== 210 +drop function concat(text, anyarray) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=DDL +STMT: DropStmt +== 211 +-- mix variadic with anyelement +create function formarray(anyelement, variadic anyarray) returns anyarray as $$ + select array_prepend($1, $2); +$$ language sql immutable strict +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 212 +select formarray(1,2,3,4,5) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +== 213 +select formarray(1.1, variadic array[1.2,55.5]) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +== 214 +select formarray(1.1, array[1.2,55.5]) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +== 215 +-- fail without variadic +select formarray(1, 'x'::text) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +== 216 +-- fail, type mismatch +select formarray(1, variadic array['x'::text]) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +== 217 +-- fail, type mismatch + +drop function formarray(anyelement, variadic anyarray) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=DDL +STMT: DropStmt +== 218 +-- test pg_typeof() function +select pg_typeof(null) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 219 +-- unknown +select pg_typeof(0) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 220 +-- integer +select pg_typeof(0.0) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 221 +-- numeric +select pg_typeof(1+1 = 2) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 222 +-- boolean +select pg_typeof('x') +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 223 +-- unknown +select pg_typeof('' || '') +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 224 +-- text +select pg_typeof(pg_typeof(0)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 225 +-- regtype +select pg_typeof(array[1.2,55.5]) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 226 +-- numeric[] +select pg_typeof(myleast(10, 1, 20, 33)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +== 227 +-- polymorphic input + +-- test functions with default parameters + +-- test basic functionality +create function dfunc(a int = 1, int = 2) returns int as $$ + select $1 + $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 228 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 229 +select dfunc(10) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 230 +select dfunc(10, 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 231 +select dfunc(10, 20, 30) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 232 +-- fail + +drop function dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 233 +-- fail +drop function dfunc(int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 234 +-- fail +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 235 +-- ok + +-- fail: defaults must be at end of argument list +create function dfunc(a int = 1, b int) returns int as $$ + select $1 + $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 236 +-- however, this should work: +create function dfunc(a int = 1, out sum int, b int = 2) as $$ + select $1 + $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 237 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 238 +-- verify it lists properly + +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 239 +-- check implicit coercion +create function dfunc(a int DEFAULT 1.0, int DEFAULT '-1') returns int as $$ + select $1 + $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 240 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 241 +create function dfunc(a text DEFAULT 'Hello', b text DEFAULT 'World') returns text as $$ + select $1 || ', ' || $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 242 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 243 +-- fail: which dfunc should be called? int or text +select dfunc('Hi') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 244 +-- ok +select dfunc('Hi', 'City') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 245 +-- ok +select dfunc(0) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 246 +-- ok +select dfunc(10, 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 247 +-- ok + +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 248 +drop function dfunc(text, text) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 249 +create function dfunc(int = 1, int = 2) returns int as $$ + select 2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 250 +create function dfunc(int = 1, int = 2, int = 3, int = 4) returns int as $$ + select 4; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 251 +-- Now, dfunc(nargs = 2) and dfunc(nargs = 4) are ambiguous when called +-- with 0 to 2 arguments. + +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 252 +-- fail +select dfunc(1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 253 +-- fail +select dfunc(1, 2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 254 +-- fail +select dfunc(1, 2, 3) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 255 +-- ok +select dfunc(1, 2, 3, 4) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 256 +-- ok + +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 257 +drop function dfunc(int, int, int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 258 +-- default values are not allowed for output parameters +create function dfunc(out int = 20) returns int as $$ + select 1; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 259 +-- polymorphic parameter test +create function dfunc(anyelement = 'World'::text) returns text as $$ + select 'Hello, ' || $1::text; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 260 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 261 +select dfunc(0) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 262 +select dfunc(to_date('20081215','YYYYMMDD')) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 263 +select dfunc('City'::text) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 264 +drop function dfunc(anyelement) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 265 +-- check defaults for variadics + +create function dfunc(a variadic int[]) returns int as +$$ select array_upper($1, 1) $$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 266 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 267 +-- fail +select dfunc(10) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 268 +select dfunc(10,20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 269 +create or replace function dfunc(a variadic int[] default array[]::int[]) returns int as +$$ select array_upper($1, 1) $$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 270 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 271 +-- now ok +select dfunc(10) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 272 +select dfunc(10,20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 273 +-- can't remove the default once it exists +create or replace function dfunc(a variadic int[]) returns int as +$$ select array_upper($1, 1) $$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 274 +drop function dfunc(a variadic int[]) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 275 +-- Ambiguity should be reported only if there's not a better match available + +create function dfunc(int = 1, int = 2, int = 3) returns int as $$ + select 3; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 276 +create function dfunc(int = 1, int = 2) returns int as $$ + select 2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 277 +create function dfunc(text) returns text as $$ + select $1; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 278 +-- dfunc(narg=2) and dfunc(narg=3) are ambiguous +select dfunc(1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 279 +-- fail + +-- but this works since the ambiguous functions aren't preferred anyway +select dfunc('Hi') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 280 +drop function dfunc(int, int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 281 +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 282 +drop function dfunc(text) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 283 +|-- +-- Tests for named- and mixed-notation function calling +|-- + +create function dfunc(a int, b int, c int = 0, d int = 0) + returns table (a int, b int, c int, d int) as $$ + select $1, $2, $3, $4; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 284 +select (dfunc(10,20,30)).* +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 285 +select (dfunc(a := 10, b := 20, c := 30)).* +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 286 +select * from dfunc(a := 10, b := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 287 +select * from dfunc(b := 10, a := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 288 +select * from dfunc(0) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 289 +-- fail +select * from dfunc(1,2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 290 +select * from dfunc(1,2,c := 3) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 291 +select * from dfunc(1,2,d := 3) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 292 +select * from dfunc(x := 20, b := 10, x := 30) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 293 +-- fail, duplicate name +select * from dfunc(10, b := 20, 30) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 294 +-- fail, named args must be last +select * from dfunc(x := 10, b := 20, c := 30) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 295 +-- fail, unknown param +select * from dfunc(10, 10, a := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 296 +-- fail, a overlaps positional parameter +select * from dfunc(1,c := 2,d := 3) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 297 +-- fail, no value for b + +drop function dfunc(int, int, int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 298 +-- test with different parameter types +create function dfunc(a varchar, b numeric, c date = current_date) + returns table (a varchar, b numeric, c date) as $$ + select $1, $2, $3; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 299 +select (dfunc('Hello World', 20, '2009-07-25'::date)).* +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 300 +select * from dfunc('Hello World', 20, '2009-07-25'::date) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 301 +select * from dfunc(c := '2009-07-25'::date, a := 'Hello World', b := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 302 +select * from dfunc('Hello World', b := 20, c := '2009-07-25'::date) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 303 +select * from dfunc('Hello World', c := '2009-07-25'::date, b := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 304 +select * from dfunc('Hello World', c := 20, b := '2009-07-25'::date) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 305 +-- fail + +drop function dfunc(varchar, numeric, date) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 306 +-- test out parameters with named params +create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric) +returns record as $$ + select $1, $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 307 +select (dfunc()).* +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 308 +select * from dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 309 +select * from dfunc('Hello', 100) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 310 +select * from dfunc(a := 'Hello', c := 100) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 311 +select * from dfunc(c := 100, a := 'Hello') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 312 +select * from dfunc('Hello') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 313 +select * from dfunc('Hello', c := 100) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 314 +select * from dfunc(c := 100) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 315 +-- fail, can no longer change an input parameter's name +create or replace function dfunc(a varchar = 'def a', out _a varchar, x numeric = NULL, out _c numeric) +returns record as $$ + select $1, $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 316 +create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric = NULL, out _c numeric) +returns record as $$ + select $1, $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 317 +drop function dfunc(varchar, numeric) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +== 318 +--fail, named parameters are not unique +create function testpolym(a int, a int) returns int as $$ select 1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 319 +create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 320 +create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 321 +create function testpolym(a int, inout a int) returns int as $$ select 1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 322 +-- valid +create function testpolym(a int, out a int) returns int as $$ select $1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 323 +select testpolym(37) +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=Call +STMT: SelectStmt +== 324 +drop function testpolym(int) +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: DropStmt +== 325 +create function testpolym(a int) returns table(a int) as $$ select $1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 326 +select * from testpolym(37) +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=Call +STMT: SelectStmt +== 327 +drop function testpolym(int) +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: DropStmt +== 328 +-- test polymorphic params and defaults +create function dfunc(a anyelement, b anyelement = null, flag bool = true) +returns anyelement as $$ + select case when $3 then $1 else $2 end; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 329 +select dfunc(1,2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 330 +select dfunc('a'::text, 'b') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 331 +-- positional notation with default + +select dfunc(a := 1, b := 2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 332 +select dfunc(a := 'a'::text, b := 'b') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 333 +select dfunc(a := 'a'::text, b := 'b', flag := false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 334 +-- named notation + +select dfunc(b := 'b'::text, a := 'a') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 335 +-- named notation with default +select dfunc(a := 'a'::text, flag := true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 336 +-- named notation with default +select dfunc(a := 'a'::text, flag := false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 337 +-- named notation with default +select dfunc(b := 'b'::text, a := 'a', flag := true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 338 +-- named notation + +select dfunc('a'::text, 'b', false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 339 +-- full positional notation +select dfunc('a'::text, 'b', flag := false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 340 +-- mixed notation +select dfunc('a'::text, 'b', true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 341 +-- full positional notation +select dfunc('a'::text, 'b', flag := true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 342 +-- mixed notation + +-- ansi/sql syntax +select dfunc(a => 1, b => 2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 343 +select dfunc(a => 'a'::text, b => 'b') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 344 +select dfunc(a => 'a'::text, b => 'b', flag => false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 345 +-- named notation + +select dfunc(b => 'b'::text, a => 'a') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 346 +-- named notation with default +select dfunc(a => 'a'::text, flag => true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 347 +-- named notation with default +select dfunc(a => 'a'::text, flag => false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 348 +-- named notation with default +select dfunc(b => 'b'::text, a => 'a', flag => true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 349 +-- named notation + +select dfunc('a'::text, 'b', false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 350 +-- full positional notation +select dfunc('a'::text, 'b', flag => false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 351 +-- mixed notation +select dfunc('a'::text, 'b', true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 352 +-- full positional notation +select dfunc('a'::text, 'b', flag => true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 353 +-- mixed notation + +-- this tests lexer edge cases around => +select dfunc(a =>-1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 354 +select dfunc(a =>+1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 355 +select dfunc(a =>/**/1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 356 +select dfunc(a =>--comment to be removed by psql + 1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +== 357 +-- need DO to protect the -- from psql +do $$ + declare r integer; + begin + select dfunc(a=>-- comment + 1) into r; + raise info 'r = %', r; + end; +$$ +-- +STMT: DoStmt +== 358 +-- check reverse-listing of named-arg calls +CREATE VIEW dfview AS + SELECT q1, q2, + dfunc(q1,q2, flag := q1>q2) as c3, + dfunc(q1, flag := q1= 1000 AND oid < 3000 ORDER BY oid +-- +TABLE: name="pg_largeobject_metadata" schema="" table="pg_largeobject_metadata" ctx=Select +FUNCTION: name="lo_unlink" function="lo_unlink" schema="" ctx=Call +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 012 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 013 +-- test proper begins here + +CREATE USER regress_priv_user1 +-- +STMT: CreateRoleStmt +== 014 +CREATE USER regress_priv_user2 +-- +STMT: CreateRoleStmt +== 015 +CREATE USER regress_priv_user3 +-- +STMT: CreateRoleStmt +== 016 +CREATE USER regress_priv_user4 +-- +STMT: CreateRoleStmt +== 017 +CREATE USER regress_priv_user5 +-- +STMT: CreateRoleStmt +== 018 +CREATE USER regress_priv_user5 +-- +STMT: CreateRoleStmt +== 019 +-- duplicate +CREATE USER regress_priv_user6 +-- +STMT: CreateRoleStmt +== 020 +CREATE USER regress_priv_user7 +-- +STMT: CreateRoleStmt +== 021 +CREATE USER regress_priv_user8 +-- +STMT: CreateRoleStmt +== 022 +CREATE USER regress_priv_user9 +-- +STMT: CreateRoleStmt +== 023 +CREATE USER regress_priv_user10 +-- +STMT: CreateRoleStmt +== 024 +CREATE ROLE regress_priv_role +-- +STMT: CreateRoleStmt +== 025 +-- circular ADMIN OPTION grants should be disallowed +GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +== 026 +GRANT regress_priv_user1 TO regress_priv_user3 WITH ADMIN OPTION GRANTED BY regress_priv_user2 +-- +STMT: GrantRoleStmt +== 027 +GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION GRANTED BY regress_priv_user3 +-- +STMT: GrantRoleStmt +== 028 +-- need CASCADE to revoke grant or admin option if dependent grants exist +REVOKE ADMIN OPTION FOR regress_priv_user1 FROM regress_priv_user2 +-- +STMT: GrantRoleStmt +== 029 +-- fail +REVOKE regress_priv_user1 FROM regress_priv_user2 +-- +STMT: GrantRoleStmt +== 030 +-- fail +SELECT member::regrole, admin_option FROM pg_auth_members WHERE roleid = 'regress_priv_user1'::regrole +-- +TABLE: name="pg_auth_members" schema="" table="pg_auth_members" ctx=Select +FILTER: schema="" table="" column="roleid" +STMT: SelectStmt +== 031 +BEGIN +-- +STMT: TransactionStmt +== 032 +REVOKE ADMIN OPTION FOR regress_priv_user1 FROM regress_priv_user2 CASCADE +-- +STMT: GrantRoleStmt +== 033 +SELECT member::regrole, admin_option FROM pg_auth_members WHERE roleid = 'regress_priv_user1'::regrole +-- +TABLE: name="pg_auth_members" schema="" table="pg_auth_members" ctx=Select +FILTER: schema="" table="" column="roleid" +STMT: SelectStmt +== 034 +ROLLBACK +-- +STMT: TransactionStmt +== 035 +REVOKE regress_priv_user1 FROM regress_priv_user2 CASCADE +-- +STMT: GrantRoleStmt +== 036 +SELECT member::regrole, admin_option FROM pg_auth_members WHERE roleid = 'regress_priv_user1'::regrole +-- +TABLE: name="pg_auth_members" schema="" table="pg_auth_members" ctx=Select +FILTER: schema="" table="" column="roleid" +STMT: SelectStmt +== 037 +-- inferred grantor must be a role with ADMIN OPTION +GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +== 038 +GRANT regress_priv_user2 TO regress_priv_user3 +-- +STMT: GrantRoleStmt +== 039 +SET ROLE regress_priv_user3 +-- +STMT: VariableSetStmt +== 040 +GRANT regress_priv_user1 TO regress_priv_user4 +-- +STMT: GrantRoleStmt +== 041 +SELECT grantor::regrole FROM pg_auth_members WHERE roleid = 'regress_priv_user1'::regrole and member = 'regress_priv_user4'::regrole +-- +TABLE: name="pg_auth_members" schema="" table="pg_auth_members" ctx=Select +FILTER: schema="" table="" column="roleid" +FILTER: schema="" table="" column="member" +STMT: SelectStmt +== 042 +RESET ROLE +-- +STMT: VariableSetStmt +== 043 +REVOKE regress_priv_user2 FROM regress_priv_user3 +-- +STMT: GrantRoleStmt +== 044 +REVOKE regress_priv_user1 FROM regress_priv_user2 CASCADE +-- +STMT: GrantRoleStmt +== 045 +-- test GRANTED BY with DROP OWNED and REASSIGN OWNED +GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +== 046 +GRANT regress_priv_user1 TO regress_priv_user3 GRANTED BY regress_priv_user2 +-- +STMT: GrantRoleStmt +== 047 +DROP ROLE regress_priv_user2 +-- +STMT: DropRoleStmt +== 048 +-- fail, dependency +REASSIGN OWNED BY regress_priv_user2 TO regress_priv_user4 +-- +STMT: ReassignOwnedStmt +== 049 +DROP ROLE regress_priv_user2 +-- +STMT: DropRoleStmt +== 050 +-- still fail, REASSIGN OWNED doesn't help +DROP OWNED BY regress_priv_user2 +-- +STMT: DropOwnedStmt +== 051 +DROP ROLE regress_priv_user2 +-- +STMT: DropRoleStmt +== 052 +-- ok now, DROP OWNED does the job + +-- test that removing granted role or grantee role removes dependency +GRANT regress_priv_user1 TO regress_priv_user3 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +== 053 +GRANT regress_priv_user1 TO regress_priv_user4 GRANTED BY regress_priv_user3 +-- +STMT: GrantRoleStmt +== 054 +DROP ROLE regress_priv_user3 +-- +STMT: DropRoleStmt +== 055 +-- should fail, dependency +DROP ROLE regress_priv_user4 +-- +STMT: DropRoleStmt +== 056 +-- ok +DROP ROLE regress_priv_user3 +-- +STMT: DropRoleStmt +== 057 +-- ok now +GRANT regress_priv_user1 TO regress_priv_user5 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +== 058 +GRANT regress_priv_user1 TO regress_priv_user6 GRANTED BY regress_priv_user5 +-- +STMT: GrantRoleStmt +== 059 +DROP ROLE regress_priv_user5 +-- +STMT: DropRoleStmt +== 060 +-- should fail, dependency +DROP ROLE regress_priv_user1, regress_priv_user5 +-- +STMT: DropRoleStmt +== 061 +-- ok, despite order + +-- recreate the roles we just dropped +CREATE USER regress_priv_user1 +-- +STMT: CreateRoleStmt +== 062 +CREATE USER regress_priv_user2 +-- +STMT: CreateRoleStmt +== 063 +CREATE USER regress_priv_user3 +-- +STMT: CreateRoleStmt +== 064 +CREATE USER regress_priv_user4 +-- +STMT: CreateRoleStmt +== 065 +CREATE USER regress_priv_user5 +-- +STMT: CreateRoleStmt +== 066 +GRANT pg_read_all_data TO regress_priv_user6 +-- +STMT: GrantRoleStmt +== 067 +GRANT pg_write_all_data TO regress_priv_user7 +-- +STMT: GrantRoleStmt +== 068 +GRANT pg_read_all_settings TO regress_priv_user8 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +== 069 +GRANT regress_priv_user9 TO regress_priv_user8 +-- +STMT: GrantRoleStmt +== 070 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +== 071 +GRANT pg_read_all_settings TO regress_priv_user9 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +== 072 +SET SESSION AUTHORIZATION regress_priv_user9 +-- +STMT: VariableSetStmt +== 073 +GRANT pg_read_all_settings TO regress_priv_user10 +-- +STMT: GrantRoleStmt +== 074 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +== 075 +REVOKE pg_read_all_settings FROM regress_priv_user10 GRANTED BY regress_priv_user9 +-- +STMT: GrantRoleStmt +== 076 +REVOKE ADMIN OPTION FOR pg_read_all_settings FROM regress_priv_user9 +-- +STMT: GrantRoleStmt +== 077 +REVOKE pg_read_all_settings FROM regress_priv_user9 +-- +STMT: GrantRoleStmt +== 078 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 079 +REVOKE regress_priv_user9 FROM regress_priv_user8 +-- +STMT: GrantRoleStmt +== 080 +REVOKE ADMIN OPTION FOR pg_read_all_settings FROM regress_priv_user8 +-- +STMT: GrantRoleStmt +== 081 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +== 082 +SET ROLE pg_read_all_settings +-- +STMT: VariableSetStmt +== 083 +RESET ROLE +-- +STMT: VariableSetStmt +== 084 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 085 +REVOKE SET OPTION FOR pg_read_all_settings FROM regress_priv_user8 +-- +STMT: GrantRoleStmt +== 086 +GRANT pg_read_all_stats TO regress_priv_user8 WITH SET FALSE +-- +STMT: GrantRoleStmt +== 087 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +== 088 +SET ROLE pg_read_all_settings +-- +STMT: VariableSetStmt +== 089 +-- fail, no SET option any more +SET ROLE pg_read_all_stats +-- +STMT: VariableSetStmt +== 090 +-- fail, granted without SET option +RESET ROLE +-- +STMT: VariableSetStmt +== 091 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 092 +-- test interaction of SET SESSION AUTHORIZATION and SET ROLE, +-- as well as propagation of these settings to parallel workers +GRANT regress_priv_user9 TO regress_priv_user8 +-- +STMT: GrantRoleStmt +== 093 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +== 094 +SET ROLE regress_priv_user9 +-- +STMT: VariableSetStmt +== 095 +SET debug_parallel_query = 0 +-- +STMT: VariableSetStmt +== 096 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 097 +SET debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 098 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 099 +BEGIN +-- +STMT: TransactionStmt +== 100 +SET SESSION AUTHORIZATION regress_priv_user10 +-- +STMT: VariableSetStmt +== 101 +SET debug_parallel_query = 0 +-- +STMT: VariableSetStmt +== 102 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 103 +SET debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 104 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 105 +ROLLBACK +-- +STMT: TransactionStmt +== 106 +SET debug_parallel_query = 0 +-- +STMT: VariableSetStmt +== 107 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 108 +SET debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 109 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 110 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 111 +-- session_user at this point is installation-dependent +SET debug_parallel_query = 0 +-- +STMT: VariableSetStmt +== 112 +SELECT session_user = current_role as c_r_ok, session_user = current_user as c_u_ok, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 113 +SET debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 114 +SELECT session_user = current_role as c_r_ok, session_user = current_user as c_u_ok, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 115 +RESET debug_parallel_query +-- +STMT: VariableSetStmt +== 116 +REVOKE pg_read_all_settings FROM regress_priv_user8 +-- +STMT: GrantRoleStmt +== 117 +DROP USER regress_priv_user10 +-- +STMT: DropRoleStmt +== 118 +DROP USER regress_priv_user9 +-- +STMT: DropRoleStmt +== 119 +DROP USER regress_priv_user8 +-- +STMT: DropRoleStmt +== 120 +CREATE GROUP regress_priv_group1 +-- +STMT: CreateRoleStmt +== 121 +CREATE GROUP regress_priv_group2 WITH ADMIN regress_priv_user1 USER regress_priv_user2 +-- +STMT: CreateRoleStmt +== 122 +ALTER GROUP regress_priv_group1 ADD USER regress_priv_user4 +-- +STMT: AlterRoleStmt +== 123 +GRANT regress_priv_group2 TO regress_priv_user2 GRANTED BY regress_priv_user1 +-- +STMT: GrantRoleStmt +== 124 +SET SESSION AUTHORIZATION regress_priv_user3 +-- +STMT: VariableSetStmt +== 125 +ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2 +-- +STMT: AlterRoleStmt +== 126 +-- fail +ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2 +-- +STMT: AlterRoleStmt +== 127 +-- fail +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 128 +ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2 +-- +STMT: AlterRoleStmt +== 129 +ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2 +-- +STMT: AlterRoleStmt +== 130 +-- duplicate +ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2 +-- +STMT: AlterRoleStmt +== 131 +ALTER USER regress_priv_user2 PASSWORD 'verysecret' +-- +STMT: AlterRoleStmt +== 132 +-- not permitted +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 133 +ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2 +-- +STMT: AlterRoleStmt +== 134 +REVOKE ADMIN OPTION FOR regress_priv_group2 FROM regress_priv_user1 +-- +STMT: GrantRoleStmt +== 135 +GRANT regress_priv_group2 TO regress_priv_user4 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +== 136 +-- prepare non-leakproof function for later +CREATE FUNCTION leak(integer,integer) RETURNS boolean + AS 'int4lt' + LANGUAGE internal IMMUTABLE STRICT +-- +FUNCTION: name="leak" function="leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 137 +-- but deliberately not LEAKPROOF +ALTER FUNCTION leak(integer,integer) OWNER TO regress_priv_user1 +-- +STMT: AlterOwnerStmt +== 138 +-- test owner privileges + +GRANT regress_priv_role TO regress_priv_user1 WITH ADMIN OPTION GRANTED BY regress_priv_role +-- +STMT: GrantRoleStmt +== 139 +-- error, doesn't have ADMIN OPTION +GRANT regress_priv_role TO regress_priv_user1 WITH ADMIN OPTION GRANTED BY CURRENT_ROLE +-- +STMT: GrantRoleStmt +== 140 +REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY foo +-- +STMT: GrantRoleStmt +== 141 +-- error +REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY regress_priv_user2 +-- +STMT: GrantRoleStmt +== 142 +-- warning, noop +REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY CURRENT_USER +-- +STMT: GrantRoleStmt +== 143 +REVOKE regress_priv_role FROM regress_priv_user1 GRANTED BY CURRENT_ROLE +-- +STMT: GrantRoleStmt +== 144 +DROP ROLE regress_priv_role +-- +STMT: DropRoleStmt +== 145 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 146 +SELECT session_user, current_user +-- +STMT: SelectStmt +== 147 +CREATE TABLE atest1 ( a int, b text ) +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: CreateStmt +== 148 +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +== 149 +INSERT INTO atest1 VALUES (1, 'one') +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +DELETE FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: DeleteStmt +== 151 +UPDATE atest1 SET a = 1 WHERE b = 'blech' +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: UpdateStmt +== 152 +TRUNCATE atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: TruncateStmt +== 153 +BEGIN +-- +STMT: TransactionStmt +== 154 +LOCK atest1 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: LockStmt +== 155 +COMMIT +-- +STMT: TransactionStmt +== 156 +REVOKE ALL ON atest1 FROM PUBLIC +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: GrantStmt +== 157 +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +== 158 +GRANT ALL ON atest1 TO regress_priv_user2 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: GrantStmt +== 159 +GRANT SELECT ON atest1 TO regress_priv_user3, regress_priv_user4 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: GrantStmt +== 160 +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +== 161 +CREATE TABLE atest2 (col1 varchar(10), col2 boolean) +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: CreateStmt +== 162 +GRANT SELECT ON atest2 TO regress_priv_user2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +== 163 +GRANT UPDATE ON atest2 TO regress_priv_user3 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +== 164 +GRANT INSERT ON atest2 TO regress_priv_user4 GRANTED BY CURRENT_USER +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +== 165 +GRANT TRUNCATE ON atest2 TO regress_priv_user5 GRANTED BY CURRENT_ROLE +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +== 166 +GRANT TRUNCATE ON atest2 TO regress_priv_user4 GRANTED BY regress_priv_user5 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +== 167 +-- error + + +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +== 168 +SELECT session_user, current_user +-- +STMT: SelectStmt +== 169 +-- try various combinations of queries on atest1 and atest2 + +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +== 170 +-- ok +SELECT * FROM atest2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: SelectStmt +== 171 +-- ok +INSERT INTO atest1 VALUES (2, 'two') +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 172 +-- ok +INSERT INTO atest2 VALUES ('foo', true) +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +-- fail +INSERT INTO atest1 SELECT 1, b FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 174 +-- ok +UPDATE atest1 SET a = 1 WHERE a = 2 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: UpdateStmt +== 175 +-- ok +UPDATE atest2 SET col2 = NOT col2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DML +STMT: UpdateStmt +== 176 +-- fail +SELECT * FROM atest1 FOR UPDATE +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +== 177 +-- ok +SELECT * FROM atest2 FOR UPDATE +-- +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: SelectStmt +== 178 +-- fail +DELETE FROM atest2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DML +STMT: DeleteStmt +== 179 +-- fail +TRUNCATE atest2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: TruncateStmt +== 180 +-- fail +BEGIN +-- +STMT: TransactionStmt +== 181 +LOCK atest2 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: LockStmt +== 182 +-- fail +COMMIT +-- +STMT: TransactionStmt +== 183 +COPY atest2 FROM stdin +-- +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: CopyStmt +== 184 +-- fail +GRANT ALL ON atest1 TO PUBLIC +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: GrantStmt +== 185 +-- fail + +-- checks in subquery, both ok +SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) ) +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest2" schema="" table="atest2" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 186 +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +== 187 +-- ok + + +-- test leaky-function protections in selfuncs + +-- regress_priv_user1 will own a table and provide views for it. +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 188 +CREATE TABLE atest12 as + SELECT x AS a, 10001 - x AS b FROM generate_series(1,10000) x +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 189 +CREATE INDEX ON atest12 (a) +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +STMT: IndexStmt +== 190 +CREATE INDEX ON atest12 (abs(a)) +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +== 191 +-- results below depend on having quite accurate stats for atest12, so... +ALTER TABLE atest12 SET (autovacuum_enabled = off) +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +STMT: AlterTableStmt +== 192 +SET default_statistics_target = 10000 +-- +STMT: VariableSetStmt +== 193 +VACUUM ANALYZE atest12 +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +STMT: VacuumStmt +== 194 +RESET default_statistics_target +-- +STMT: VariableSetStmt +== 195 +CREATE OPERATOR <<< (procedure = leak, leftarg = integer, rightarg = integer, + restrict = scalarltsel) +-- +STMT: DefineStmt +== 196 +-- views with leaky operator +CREATE VIEW atest12v AS + SELECT * FROM atest12 WHERE b <<< 5 +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=DDL +TABLE: name="atest12" schema="" table="atest12" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 197 +CREATE VIEW atest12sbv WITH (security_barrier=true) AS + SELECT * FROM atest12 WHERE b <<< 5 +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=DDL +TABLE: name="atest12" schema="" table="atest12" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 198 +-- This plan should use nestloop, knowing that few rows will be selected. +EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +ALIAS: "x"="atest12v" +ALIAS: "y"="atest12v" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 199 +-- And this one. +EXPLAIN (COSTS OFF) SELECT * FROM atest12 x, atest12 y + WHERE x.a = y.b and abs(y.a) <<< 5 +-- +TABLE: name="atest12" schema="" table="atest12" ctx=Select +TABLE: name="atest12" schema="" table="atest12" ctx=Select +ALIAS: "x"="atest12" +ALIAS: "y"="atest12" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +FILTER: schema="" table="y" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 200 +-- This should also be a nestloop, but the security barrier forces the inner +-- scan to be materialized +EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y WHERE x.a = y.b +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +ALIAS: "x"="atest12sbv" +ALIAS: "y"="atest12sbv" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 201 +-- Check if regress_priv_user2 can break security. +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +== 202 +CREATE FUNCTION leak2(integer,integer) RETURNS boolean + AS $$begin raise notice 'leak % %', $1, $2; return $1 > $2; end$$ + LANGUAGE plpgsql immutable +-- +FUNCTION: name="leak2" function="leak2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 203 +CREATE OPERATOR >>> (procedure = leak2, leftarg = integer, rightarg = integer, + restrict = scalargtsel) +-- +STMT: DefineStmt +== 204 +-- These should not show any "leak" notices before failing. +EXPLAIN (COSTS OFF) SELECT * FROM atest12 WHERE a >>> 0 +-- +TABLE: name="atest12" schema="" table="atest12" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 205 +EXPLAIN (COSTS OFF) SELECT * FROM atest12v WHERE a >>> 0 +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 206 +EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv WHERE a >>> 0 +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 207 +-- Now regress_priv_user1 grants access to regress_priv_user2 via the views. +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 208 +GRANT SELECT ON atest12v TO PUBLIC +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=DDL +STMT: GrantStmt +== 209 +GRANT SELECT ON atest12sbv TO PUBLIC +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=DDL +STMT: GrantStmt +== 210 +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +== 211 +-- These plans should continue to use a nestloop, since they execute with the +-- privileges of the view owner. +EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +ALIAS: "x"="atest12v" +ALIAS: "y"="atest12v" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 212 +EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y WHERE x.a = y.b +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +ALIAS: "x"="atest12sbv" +ALIAS: "y"="atest12sbv" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 213 +-- A non-security barrier view does not guard against information leakage. +EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y + WHERE x.a = y.b and abs(y.a) <<< 5 +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +ALIAS: "x"="atest12v" +ALIAS: "y"="atest12v" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +FILTER: schema="" table="y" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 214 +-- But a security barrier view isolates the leaky operator. +EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y + WHERE x.a = y.b and abs(y.a) <<< 5 +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +ALIAS: "x"="atest12sbv" +ALIAS: "y"="atest12sbv" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +FILTER: schema="" table="y" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 215 +-- Now regress_priv_user1 grants sufficient access to regress_priv_user2. +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 216 +GRANT SELECT (a, b) ON atest12 TO PUBLIC +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +STMT: GrantStmt +== 217 +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +== 218 +-- regress_priv_user2 should continue to get a good row estimate. +EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +ALIAS: "x"="atest12v" +ALIAS: "y"="atest12v" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 219 +-- But not for this, due to lack of table-wide permissions needed +-- to make use of the expression index's statistics. +EXPLAIN (COSTS OFF) SELECT * FROM atest12 x, atest12 y + WHERE x.a = y.b and abs(y.a) <<< 5 +-- +TABLE: name="atest12" schema="" table="atest12" ctx=Select +TABLE: name="atest12" schema="" table="atest12" ctx=Select +ALIAS: "x"="atest12" +ALIAS: "y"="atest12" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +FILTER: schema="" table="y" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 220 +-- clean up (regress_priv_user1's objects are all dropped later) +DROP FUNCTION leak2(integer, integer) CASCADE +-- +FUNCTION: name="leak2" function="leak2" schema="" ctx=DDL +STMT: DropStmt +== 221 +-- groups + +SET SESSION AUTHORIZATION regress_priv_user3 +-- +STMT: VariableSetStmt +== 222 +CREATE TABLE atest3 (one int, two int, three int) +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DDL +STMT: CreateStmt +== 223 +GRANT DELETE ON atest3 TO GROUP regress_priv_group2 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DDL +STMT: GrantStmt +== 224 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 225 +SELECT * FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=Select +STMT: SelectStmt +== 226 +-- fail +DELETE FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DML +STMT: DeleteStmt +== 227 +-- ok + +BEGIN +-- +STMT: TransactionStmt +== 228 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 229 +ALTER ROLE regress_priv_user1 NOINHERIT +-- +STMT: AlterRoleStmt +== 230 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 231 +SAVEPOINT s1 +-- +STMT: TransactionStmt +== 232 +DELETE FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DML +STMT: DeleteStmt +== 233 +-- ok because grant-level option is unchanged +ROLLBACK TO s1 +-- +STMT: TransactionStmt +== 234 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 235 +GRANT regress_priv_group2 TO regress_priv_user1 WITH INHERIT FALSE +-- +STMT: GrantRoleStmt +== 236 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 237 +DELETE FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DML +STMT: DeleteStmt +== 238 +-- fail +ROLLBACK TO s1 +-- +STMT: TransactionStmt +== 239 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 240 +REVOKE INHERIT OPTION FOR regress_priv_group2 FROM regress_priv_user1 +-- +STMT: GrantRoleStmt +== 241 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 242 +DELETE FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DML +STMT: DeleteStmt +== 243 +-- also fail +ROLLBACK +-- +STMT: TransactionStmt +== 244 +-- views + +SET SESSION AUTHORIZATION regress_priv_user3 +-- +STMT: VariableSetStmt +== 245 +CREATE VIEW atestv1 AS SELECT * FROM atest1 +-- +TABLE: name="atestv1" schema="" table="atestv1" ctx=DDL +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 246 +-- ok +/* The next *should* fail, but it's not implemented that way yet. */ +CREATE VIEW atestv2 AS SELECT * FROM atest2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=DDL +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 247 +CREATE VIEW atestv3 AS SELECT * FROM atest3 +-- +TABLE: name="atestv3" schema="" table="atestv3" ctx=DDL +TABLE: name="atest3" schema="" table="atest3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 248 +-- ok +/* Empty view is a corner case that failed in 9.2. */ +CREATE VIEW atestv0 AS SELECT 0 as x WHERE false +-- +TABLE: name="atestv0" schema="" table="atestv0" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 249 +-- ok + +SELECT * FROM atestv1 +-- +TABLE: name="atestv1" schema="" table="atestv1" ctx=Select +STMT: SelectStmt +== 250 +-- ok +SELECT * FROM atestv2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=Select +STMT: SelectStmt +== 251 +-- fail +GRANT SELECT ON atestv1, atestv3 TO regress_priv_user4 +-- +TABLE: name="atestv1" schema="" table="atestv1" ctx=DDL +TABLE: name="atestv3" schema="" table="atestv3" ctx=DDL +STMT: GrantStmt +== 252 +GRANT SELECT ON atestv2 TO regress_priv_user2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=DDL +STMT: GrantStmt +== 253 +SET SESSION AUTHORIZATION regress_priv_user4 +-- +STMT: VariableSetStmt +== 254 +SELECT * FROM atestv1 +-- +TABLE: name="atestv1" schema="" table="atestv1" ctx=Select +STMT: SelectStmt +== 255 +-- ok +SELECT * FROM atestv2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=Select +STMT: SelectStmt +== 256 +-- fail +SELECT * FROM atestv3 +-- +TABLE: name="atestv3" schema="" table="atestv3" ctx=Select +STMT: SelectStmt +== 257 +-- ok +SELECT * FROM atestv0 +-- +TABLE: name="atestv0" schema="" table="atestv0" ctx=Select +STMT: SelectStmt +== 258 +-- fail + +-- Appendrels excluded by constraints failed to check permissions in 8.4-9.2. +select * from + ((select a.q1 as x from int8_tbl a offset 0) + union all + (select b.q2 as x from int8_tbl b offset 0)) ss +where false +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: SelectStmt +== 259 +set constraint_exclusion = on +-- +STMT: VariableSetStmt +== 260 +select * from + ((select a.q1 as x, random() from int8_tbl a where q1 > 0) + union all + (select b.q2 as x, random() from int8_tbl b where q2 > 0)) ss +where x < 0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 261 +reset constraint_exclusion +-- +STMT: VariableSetStmt +== 262 +CREATE VIEW atestv4 AS SELECT * FROM atestv3 +-- +TABLE: name="atestv4" schema="" table="atestv4" ctx=DDL +TABLE: name="atestv3" schema="" table="atestv3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 263 +-- nested view +SELECT * FROM atestv4 +-- +TABLE: name="atestv4" schema="" table="atestv4" ctx=Select +STMT: SelectStmt +== 264 +-- ok +GRANT SELECT ON atestv4 TO regress_priv_user2 +-- +TABLE: name="atestv4" schema="" table="atestv4" ctx=DDL +STMT: GrantStmt +== 265 +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +== 266 +-- Two complex cases: + +SELECT * FROM atestv3 +-- +TABLE: name="atestv3" schema="" table="atestv3" ctx=Select +STMT: SelectStmt +== 267 +-- fail +SELECT * FROM atestv4 +-- +TABLE: name="atestv4" schema="" table="atestv4" ctx=Select +STMT: SelectStmt +== 268 +-- ok (even though regress_priv_user2 cannot access underlying atestv3) + +SELECT * FROM atest2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: SelectStmt +== 269 +-- ok +SELECT * FROM atestv2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=Select +STMT: SelectStmt +== 270 +-- fail (even though regress_priv_user2 can access underlying atest2) + +-- Test column level permissions + +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 271 +CREATE TABLE atest5 (one int, two int unique, three int, four int unique) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DDL +STMT: CreateStmt +== 272 +CREATE TABLE atest6 (one int, two int, blue int) +-- +TABLE: name="atest6" schema="" table="atest6" ctx=DDL +STMT: CreateStmt +== 273 +GRANT SELECT (one), INSERT (two), UPDATE (three) ON atest5 TO regress_priv_user4 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DDL +STMT: GrantStmt +== 274 +GRANT ALL (one) ON atest5 TO regress_priv_user3 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DDL +STMT: GrantStmt +== 275 +INSERT INTO atest5 VALUES (1,2,3) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 276 +SET SESSION AUTHORIZATION regress_priv_user4 +-- +STMT: VariableSetStmt +== 277 +SELECT * FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 278 +-- fail +SELECT one FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 279 +-- ok +COPY atest5 (one) TO stdout +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +== 280 +-- ok +SELECT two FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 281 +-- fail +COPY atest5 (two) TO stdout +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +== 282 +-- fail +SELECT atest5 FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 283 +-- fail +COPY atest5 (one,two) TO stdout +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +== 284 +-- fail +SELECT 1 FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 285 +-- ok +SELECT 1 FROM atest5 a JOIN atest5 b USING (one) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 286 +-- ok +SELECT 1 FROM atest5 a JOIN atest5 b USING (two) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 287 +-- fail +SELECT 1 FROM atest5 a NATURAL JOIN atest5 b +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 288 +-- fail +SELECT * FROM (atest5 a JOIN atest5 b USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 289 +-- fail +SELECT j.* FROM (atest5 a JOIN atest5 b USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 290 +-- fail +SELECT (j.*) IS NULL FROM (atest5 a JOIN atest5 b USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 291 +-- fail +SELECT one FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 292 +-- ok +SELECT j.one FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 293 +-- ok +SELECT two FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 294 +-- fail +SELECT j.two FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 295 +-- fail +SELECT y FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 296 +-- fail +SELECT j.y FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 297 +-- fail +SELECT * FROM (atest5 a JOIN atest5 b USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 298 +-- fail +SELECT a.* FROM (atest5 a JOIN atest5 b USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 299 +-- fail +SELECT (a.*) IS NULL FROM (atest5 a JOIN atest5 b USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 300 +-- fail +SELECT two FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 301 +-- fail +SELECT a.two FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 302 +-- fail +SELECT y FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 303 +-- fail +SELECT b.y FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 304 +-- fail +SELECT y FROM (atest5 a LEFT JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 305 +-- fail +SELECT b.y FROM (atest5 a LEFT JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 306 +-- fail +SELECT y FROM (atest5 a FULL JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 307 +-- fail +SELECT b.y FROM (atest5 a FULL JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +== 308 +-- fail +SELECT 1 FROM atest5 WHERE two = 2 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +FILTER: schema="" table="" column="two" +STMT: SelectStmt +== 309 +-- fail +SELECT * FROM atest1, atest5 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 310 +-- fail +SELECT atest1.* FROM atest1, atest5 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 311 +-- ok +SELECT atest1.*,atest5.one FROM atest1, atest5 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 312 +-- ok +SELECT atest1.*,atest5.one FROM atest1 JOIN atest5 ON (atest1.a = atest5.two) +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 313 +-- fail +SELECT atest1.*,atest5.one FROM atest1 JOIN atest5 ON (atest1.a = atest5.one) +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 314 +-- ok +SELECT one, two FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +== 315 +-- fail + +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 316 +GRANT SELECT (one,two) ON atest6 TO regress_priv_user4 +-- +TABLE: name="atest6" schema="" table="atest6" ctx=DDL +STMT: GrantStmt +== 317 +SET SESSION AUTHORIZATION regress_priv_user4 +-- +STMT: VariableSetStmt +== 318 +SELECT one, two FROM atest5 NATURAL JOIN atest6 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest6" schema="" table="atest6" ctx=Select +STMT: SelectStmt +== 319 +-- fail still + +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +== 320 +GRANT SELECT (two) ON atest5 TO regress_priv_user4 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DDL +STMT: GrantStmt +== 321 +SET SESSION AUTHORIZATION regress_priv_user4 +-- +STMT: VariableSetStmt +== 322 +SELECT one, two FROM atest5 NATURAL JOIN atest6 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest6" schema="" table="atest6" ctx=Select +STMT: SelectStmt +== 323 +-- ok now + +-- test column-level privileges for INSERT and UPDATE +INSERT INTO atest5 (two) VALUES (3) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 324 +-- ok +COPY atest5 FROM stdin +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +== 325 +-- fail +COPY atest5 (two) FROM stdin +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +== 326 +-- ok +1 +INSERT INTO atest5 (three) VALUES (4) +-- +ERROR: syntax error at or near "1" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 327 +-- fail +INSERT INTO atest5 VALUES (5,5,5) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 328 +-- fail +UPDATE atest5 SET three = 10 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: UpdateStmt +== 329 +-- ok +UPDATE atest5 SET one = 8 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: UpdateStmt +== 330 +-- fail +UPDATE atest5 SET three = 5, one = 2 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: UpdateStmt +== 331 +-- fail +-- Check that column level privs are enforced in RETURNING +-- Ok. +INSERT INTO atest5(two) VALUES (6) ON CONFLICT (two) DO UPDATE set three = 10 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/psql.metadata.json b/parser/testdata/summary/postgres_regress/psql.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/psql.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/psql.test b/parser/testdata/summary/postgres_regress/psql.test new file mode 100644 index 0000000..38494ec --- /dev/null +++ b/parser/testdata/summary/postgres_regress/psql.test @@ -0,0 +1,1032 @@ +== 001 +|-- +-- Tests for psql features that aren't closely connected to any +-- specific server features +|-- + +-- \set + +-- fail: invalid name +-- fail: invalid value for special variable +-- check handling of built-in boolean variable + +-- ; + +SELECT 1 as one, 2 as two +-- +STMT: SelectStmt +== 002 +SELECT 3 as three, 4 as four \gx + +-- \gx should work in FETCH_COUNT mode too + +SELECT 1 as one, 2 as two +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +SELECT 3 as three, 4 as four \gx + + +-- ; + +SELECT 1 as one, 2 as two \g (format=csv csv_fieldsep='\t') +SELECT 1 as one, 2 as two \gx (title='foo bar') + +-- \bind (extended query protocol) + +SELECT 1 \bind +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +SELECT $1 \bind 'foo' +-- +ERROR: syntax error at or near "\" +CURSORPOS: 11 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +SELECT $1, $2 \bind 'foo' 'bar' +-- +ERROR: syntax error at or near "\" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +-- errors +-- parse error +SELECT foo \bind +-- +ERROR: syntax error at or near "\" +CURSORPOS: 37 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- tcop error +SELECT 1 \ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +SELECT 2 \bind +-- +ERROR: syntax error at or near "\" +CURSORPOS: 10 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- bind error +SELECT $1, $2 \bind 'foo' +-- +ERROR: syntax error at or near "\" +CURSORPOS: 29 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 010 +-- ; + +select 10 as test01, 20 as test02, 'Hello' as test03 +-- +STMT: SelectStmt +== 011 +-- should fail: bad variable name +select 10 as "bad name" + +select 97 as "EOF", 'ok' as _foo +-- +ERROR: syntax error at or near "select" +CURSORPOS: 60 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +-- multiple backslash commands in one line +select 1 as x, 2 as y +-- +STMT: SelectStmt +== 013 +select 3 as x, 4 as y +-- +STMT: SelectStmt +== 014 +select 5 as x, 6 as y +-- +STMT: SelectStmt +== 015 +select 7 as x, 8 as y +-- +STMT: SelectStmt +== 016 +-- NULL should unset the variable +select 1 as var1, NULL as var2, 3 as var3 +-- +STMT: SelectStmt +== 017 +-- ; +select 10 as test01, 20 as test02 from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 018 +select 10 as test01, 20 as test02 from generate_series(1,0) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- ; +select a from generate_series(1, 10) as a where a = 11 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 020 +-- ; + +select 1 as x, 2 as y +-- +STMT: SelectStmt +== 021 +select 3 as x, 4 as y +-- +STMT: SelectStmt +== 022 +select 10 as test01, 20 as test02 from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 023 +select 10 as test01, 20 as test02 from generate_series(1,0) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 024 +-- ; + +SELECT + NULL AS zero, + 1 AS one, + 2.0 AS two, + 'three' AS three, + $1 AS four, + sin($2) as five, + 'foo'::varchar(4) as six, + CURRENT_DATE AS now + +-- should work with tuple-returning utilities, such as EXECUTE +PREPARE test AS SELECT 1 AS first, 2 AS second +-- +ERROR: syntax error at or near "PREPARE" +CURSORPOS: 239 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 025 +EXECUTE test +-- +STMT: ExecuteStmt +== 026 +EXPLAIN EXECUTE test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 027 +-- should fail cleanly - syntax error +SELECT 1 + +-- +ERROR: syntax error at end of input +CURSORPOS: 49 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 028 +-- check behavior with empty results +SELECT +-- +STMT: SelectStmt +== 029 +CREATE TABLE bububu(a int) +-- +TABLE: name="bububu" schema="" table="bububu" ctx=DDL +STMT: CreateStmt +== 030 +-- subject command should not have executed +TABLE bububu +-- +TABLE: name="bububu" schema="" table="bububu" ctx=Select +STMT: SelectStmt +== 031 +-- fail + +-- query buffer should remain unchanged +SELECT 1 AS x, 'Hello', 2 AS y, true AS "dirty\name" + +-- all on one line +SELECT 3 AS x, 'Hello', 4 AS y, true AS "dirty\name" +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 123 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 032 +-- test for server bug #17983 with empty statement in aborted transaction +set search_path = default +-- +STMT: VariableSetStmt +== 033 +begin +-- +STMT: TransactionStmt +== 034 +rollback +-- +STMT: TransactionStmt +== 035 +-- ; + +create temporary table gexec_test(a int, b text, c date, d float) +-- +TABLE: name="gexec_test" schema="" table="gexec_test" ctx=DDL +STMT: CreateStmt +== 036 +select format('create index on gexec_test(%I)', attname) +from pg_attribute +where attrelid = 'gexec_test'::regclass and attnum > 0 +order by attnum + +-- ; +-- (though the fetch limit applies to the executed queries not the meta query) + +select 'select 1 as ones', 'select x.y, x.y*2 as double from generate_series(1,4) as x(y)' +union all +select 'drop table gexec_test', NULL +union all +select 'drop table gexec_test', 'select ''2000-01-01''::date as party_over' + + +-- \setenv, \getenv + +-- ensure MYVAR isn't set +-- in which case, reading it doesn't change the target +-- now set it + +-- show all pset options + +-- test multi-line headers, wrapping, and newline indicators +-- in aligned, unaligned, and wrapped formats +prepare q as select array_to_string(array_agg(repeat('x',2*n)),E'\n') as "ab + +c", array_to_string(array_agg(repeat('y',20-2*n)),E'\n') as "a +bc" from generate_series(1,10) as n(n) group by n>1 order by n>1 +-- +ERROR: syntax error at or near "select" +CURSORPOS: 233 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 037 +execute q +-- +STMT: ExecuteStmt +== 038 +execute q +-- +STMT: ExecuteStmt +== 039 +execute q +-- +STMT: ExecuteStmt +== 040 +execute q +-- +STMT: ExecuteStmt +== 041 +execute q +-- +STMT: ExecuteStmt +== 042 +execute q +-- +STMT: ExecuteStmt +== 043 +execute q +-- +STMT: ExecuteStmt +== 044 +execute q +-- +STMT: ExecuteStmt +== 045 +execute q +-- +STMT: ExecuteStmt +== 046 +execute q +-- +STMT: ExecuteStmt +== 047 +execute q +-- +STMT: ExecuteStmt +== 048 +execute q +-- +STMT: ExecuteStmt +== 049 +execute q +-- +STMT: ExecuteStmt +== 050 +execute q +-- +STMT: ExecuteStmt +== 051 +execute q +-- +STMT: ExecuteStmt +== 052 +execute q +-- +STMT: ExecuteStmt +== 053 +execute q +-- +STMT: ExecuteStmt +== 054 +execute q +-- +STMT: ExecuteStmt +== 055 +execute q +-- +STMT: ExecuteStmt +== 056 +execute q +-- +STMT: ExecuteStmt +== 057 +execute q +-- +STMT: ExecuteStmt +== 058 +execute q +-- +STMT: ExecuteStmt +== 059 +execute q +-- +STMT: ExecuteStmt +== 060 +execute q +-- +STMT: ExecuteStmt +== 061 +execute q +-- +STMT: ExecuteStmt +== 062 +execute q +-- +STMT: ExecuteStmt +== 063 +execute q +-- +STMT: ExecuteStmt +== 064 +execute q +-- +STMT: ExecuteStmt +== 065 +execute q +-- +STMT: ExecuteStmt +== 066 +execute q +-- +STMT: ExecuteStmt +== 067 +execute q +-- +STMT: ExecuteStmt +== 068 +execute q +-- +STMT: ExecuteStmt +== 069 +execute q +-- +STMT: ExecuteStmt +== 070 +execute q +-- +STMT: ExecuteStmt +== 071 +execute q +-- +STMT: ExecuteStmt +== 072 +execute q +-- +STMT: ExecuteStmt +== 073 +deallocate q +-- +STMT: DeallocateStmt +== 074 +-- test single-line header and data +prepare q as select repeat('x',2*n) as "0123456789abcdef", repeat('y',20-2*n) as "0123456789" from generate_series(1,10) as n +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 075 +execute q +-- +STMT: ExecuteStmt +== 076 +execute q +-- +STMT: ExecuteStmt +== 077 +execute q +-- +STMT: ExecuteStmt +== 078 +execute q +-- +STMT: ExecuteStmt +== 079 +execute q +-- +STMT: ExecuteStmt +== 080 +execute q +-- +STMT: ExecuteStmt +== 081 +execute q +-- +STMT: ExecuteStmt +== 082 +execute q +-- +STMT: ExecuteStmt +== 083 +execute q +-- +STMT: ExecuteStmt +== 084 +execute q +-- +STMT: ExecuteStmt +== 085 +execute q +-- +STMT: ExecuteStmt +== 086 +execute q +-- +STMT: ExecuteStmt +== 087 +execute q +-- +STMT: ExecuteStmt +== 088 +execute q +-- +STMT: ExecuteStmt +== 089 +execute q +-- +STMT: ExecuteStmt +== 090 +execute q +-- +STMT: ExecuteStmt +== 091 +execute q +-- +STMT: ExecuteStmt +== 092 +execute q +-- +STMT: ExecuteStmt +== 093 +execute q +-- +STMT: ExecuteStmt +== 094 +execute q +-- +STMT: ExecuteStmt +== 095 +execute q +-- +STMT: ExecuteStmt +== 096 +execute q +-- +STMT: ExecuteStmt +== 097 +execute q +-- +STMT: ExecuteStmt +== 098 +execute q +-- +STMT: ExecuteStmt +== 099 +execute q +-- +STMT: ExecuteStmt +== 100 +execute q +-- +STMT: ExecuteStmt +== 101 +execute q +-- +STMT: ExecuteStmt +== 102 +execute q +-- +STMT: ExecuteStmt +== 103 +execute q +-- +STMT: ExecuteStmt +== 104 +execute q +-- +STMT: ExecuteStmt +== 105 +execute q +-- +STMT: ExecuteStmt +== 106 +execute q +-- +STMT: ExecuteStmt +== 107 +execute q +-- +STMT: ExecuteStmt +== 108 +execute q +-- +STMT: ExecuteStmt +== 109 +execute q +-- +STMT: ExecuteStmt +== 110 +execute q +-- +STMT: ExecuteStmt +== 111 +execute q +-- +STMT: ExecuteStmt +== 112 +execute q +-- +STMT: ExecuteStmt +== 113 +execute q +-- +STMT: ExecuteStmt +== 114 +execute q +-- +STMT: ExecuteStmt +== 115 +execute q +-- +STMT: ExecuteStmt +== 116 +execute q +-- +STMT: ExecuteStmt +== 117 +execute q +-- +STMT: ExecuteStmt +== 118 +execute q +-- +STMT: ExecuteStmt +== 119 +execute q +-- +STMT: ExecuteStmt +== 120 +deallocate q +-- +STMT: DeallocateStmt +== 121 +-- support table for output-format tests (useful to create a footer) + +create table psql_serial_tab (id serial) +-- +TABLE: name="psql_serial_tab" schema="" table="psql_serial_tab" ctx=DDL +STMT: CreateStmt +== 122 +-- test header/footer/tuples_only behavior in aligned/unaligned/wrapped cases + + +-- empty table is a special case for this format +select 1 where false +-- +STMT: SelectStmt +== 123 +-- check conditional am display + +CREATE SCHEMA tableam_display +-- +STMT: CreateSchemaStmt +== 124 +CREATE ROLE regress_display_role +-- +STMT: CreateRoleStmt +== 125 +ALTER SCHEMA tableam_display OWNER TO regress_display_role +-- +STMT: AlterOwnerStmt +== 126 +SET search_path TO tableam_display +-- +STMT: VariableSetStmt +== 127 +CREATE ACCESS METHOD heap_psql TYPE TABLE HANDLER heap_tableam_handler +-- +STMT: CreateAmStmt +== 128 +SET ROLE TO regress_display_role +-- +STMT: VariableSetStmt +== 129 +-- Use only relations with a physical size of zero. +CREATE TABLE tbl_heap_psql(f1 int, f2 char(100)) using heap_psql +-- +TABLE: name="tbl_heap_psql" schema="" table="tbl_heap_psql" ctx=DDL +STMT: CreateStmt +== 130 +CREATE TABLE tbl_heap(f1 int, f2 char(100)) using heap +-- +TABLE: name="tbl_heap" schema="" table="tbl_heap" ctx=DDL +STMT: CreateStmt +== 131 +CREATE VIEW view_heap_psql AS SELECT f1 from tbl_heap_psql +-- +TABLE: name="view_heap_psql" schema="" table="view_heap_psql" ctx=DDL +TABLE: name="tbl_heap_psql" schema="" table="tbl_heap_psql" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 132 +CREATE MATERIALIZED VIEW mat_view_heap_psql USING heap_psql AS SELECT f1 from tbl_heap_psql +-- +TABLE: name="mat_view_heap_psql" schema="" table="mat_view_heap_psql" ctx=DDL +TABLE: name="tbl_heap_psql" schema="" table="tbl_heap_psql" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 133 +-- AM is displayed for tables, indexes and materialized views. +-- But not for views and sequences. +RESET ROLE +-- +STMT: VariableSetStmt +== 134 +RESET search_path +-- +STMT: VariableSetStmt +== 135 +DROP SCHEMA tableam_display CASCADE +-- +STMT: DropStmt +== 136 +DROP ACCESS METHOD heap_psql +-- +STMT: DropStmt +== 137 +DROP ROLE regress_display_role +-- +STMT: DropRoleStmt +== 138 +-- test numericlocale (as best we can without control of psql's locale) + + +select n, -n as m, n * 111 as x, '1e90'::float8 as f +from generate_series(0,3) n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 139 +-- test asciidoc output format + + + +prepare q as + select 'some|text' as "a|title", ' ' as "empty ", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 140 +execute q +-- +STMT: ExecuteStmt +== 141 +execute q +-- +STMT: ExecuteStmt +== 142 +execute q +-- +STMT: ExecuteStmt +== 143 +execute q +-- +STMT: ExecuteStmt +== 144 +execute q +-- +STMT: ExecuteStmt +== 145 +execute q +-- +STMT: ExecuteStmt +== 146 +deallocate q +-- +STMT: DeallocateStmt +== 147 +-- test csv output format + + + +prepare q as + select 'some"text' as "a""title", E' \n' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 148 +execute q +-- +STMT: ExecuteStmt +== 149 +execute q +-- +STMT: ExecuteStmt +== 150 +deallocate q +-- +STMT: DeallocateStmt +== 151 +-- special cases +select 'comma,comma' as comma, 'semi;semi' as semi +-- +STMT: SelectStmt +== 152 +select 'comma,comma' as comma, 'semi;semi' as semi +-- +STMT: SelectStmt +== 153 +select '\.' as data +-- +STMT: SelectStmt +== 154 +select '\' as d1, '' as d2 +-- +STMT: SelectStmt +== 155 +-- illegal csv separators + + +-- test html output format + + + +prepare q as + select 'some"text' as "a&title", E' \n' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 156 +execute q +-- +STMT: ExecuteStmt +== 157 +execute q +-- +STMT: ExecuteStmt +== 158 +execute q +-- +STMT: ExecuteStmt +== 159 +execute q +-- +STMT: ExecuteStmt +== 160 +execute q +-- +STMT: ExecuteStmt +== 161 +execute q +-- +STMT: ExecuteStmt +== 162 +deallocate q +-- +STMT: DeallocateStmt +== 163 +-- test latex output format + + + +prepare q as + select 'some\more_text' as "a$title", E' #%&^~|\n{bar}' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 164 +execute q +-- +STMT: ExecuteStmt +== 165 +execute q +-- +STMT: ExecuteStmt +== 166 +execute q +-- +STMT: ExecuteStmt +== 167 +execute q +-- +STMT: ExecuteStmt +== 168 +execute q +-- +STMT: ExecuteStmt +== 169 +execute q +-- +STMT: ExecuteStmt +== 170 +execute q +-- +STMT: ExecuteStmt +== 171 +execute q +-- +STMT: ExecuteStmt +== 172 +deallocate q +-- +STMT: DeallocateStmt +== 173 +-- test latex-longtable output format + + + +prepare q as + select 'some\more_text' as "a$title", E' #%&^~|\n{bar}' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 174 +execute q +-- +STMT: ExecuteStmt +== 175 +execute q +-- +STMT: ExecuteStmt +== 176 +execute q +-- +STMT: ExecuteStmt +== 177 +execute q +-- +STMT: ExecuteStmt +== 178 +execute q +-- +STMT: ExecuteStmt +== 179 +execute q +-- +STMT: ExecuteStmt +== 180 +execute q +-- +STMT: ExecuteStmt +== 181 +execute q +-- +STMT: ExecuteStmt +== 182 +execute q +-- +STMT: ExecuteStmt +== 183 +execute q +-- +STMT: ExecuteStmt +== 184 +deallocate q +-- +STMT: DeallocateStmt +== 185 +-- test troff-ms output format + + + +prepare q as + select 'some\text' as "a\title", E' \n' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 186 +execute q +-- +STMT: ExecuteStmt +== 187 +execute q +-- +STMT: ExecuteStmt +== 188 +execute q +-- +STMT: ExecuteStmt +== 189 +execute q +-- +STMT: ExecuteStmt +== 190 +execute q +-- +STMT: ExecuteStmt +== 191 +execute q +-- +STMT: ExecuteStmt +== 192 +deallocate q +-- +STMT: DeallocateStmt +== 193 +-- check ambiguous format requests + + +-- clean up after output format tests + +drop table psql_serial_tab +-- +TABLE: name="psql_serial_tab" schema="" table="psql_serial_tab" ctx=DDL +STMT: DropStmt +== 194 +-- \echo and allied features + + + + + +-- tests for \if ... \endif + + select 'okay' +-- +STMT: SelectStmt +== 195 +select 'still okay' +-- +STMT: SelectStmt +== 196 +not okay +-- +ERROR: syntax error at or near "not" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary/postgres_regress/psql_crosstab.metadata.json b/parser/testdata/summary/postgres_regress/psql_crosstab.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/psql_crosstab.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/psql_crosstab.test b/parser/testdata/summary/postgres_regress/psql_crosstab.test new file mode 100644 index 0000000..4f9da1d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/psql_crosstab.test @@ -0,0 +1,145 @@ +== 001 +|-- +-- \crosstabview +|-- + +CREATE TABLE ctv_data (v, h, c, i, d) AS +VALUES + ('v1','h2','foo', 3, '2015-04-01'::date), + ('v2','h1','bar', 3, '2015-01-02'), + ('v1','h0','baz', NULL, '2015-07-12'), + ('v0','h4','qux', 4, '2015-07-15'), + ('v0','h4','dbl', -3, '2014-12-15'), + ('v0',NULL,'qux', 5, '2014-07-15'), + ('v1','h2','quux',7, '2015-04-04') +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 002 +-- make plans more stable +ANALYZE ctv_data +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=DDL +STMT: VacuumStmt +== 003 +-- running \crosstabview after query uses query in buffer +SELECT v, EXTRACT(year FROM d), count(*) + FROM ctv_data + GROUP BY 1, 2 + ORDER BY 1, 2 +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=Select +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 004 +-- basic usage with 3 columns + +-- ordered months in horizontal header, quoted column name +SELECT v, to_char(d, 'Mon') AS "month name", EXTRACT(month FROM d) AS num, + count(*) FROM ctv_data GROUP BY 1,2,3 ORDER BY 1 + +-- ordered months in vertical header, ordered years in horizontal header +SELECT EXTRACT(year FROM d) AS year, to_char(d,'Mon') AS """month"" name", + EXTRACT(month FROM d) AS month, + format('sum=%s avg=%s', sum(i), avg(i)::numeric(2,1)) + FROM ctv_data + GROUP BY EXTRACT(year FROM d), to_char(d,'Mon'), EXTRACT(month FROM d) +ORDER BY month + +-- combine contents vertically into the same cell (V/H duplicates) +SELECT v, h, string_agg(c, E'\n') FROM ctv_data GROUP BY v, h ORDER BY 1,2,3 + +-- horizontal ASC order from window function +SELECT v,h, string_agg(c, E'\n') AS c, row_number() OVER(ORDER BY h) AS r +FROM ctv_data GROUP BY v, h ORDER BY 1,3,2 + +-- horizontal DESC order from window function +SELECT v, h, string_agg(c, E'\n') AS c, row_number() OVER(ORDER BY h DESC) AS r +FROM ctv_data GROUP BY v, h ORDER BY 1,3,2 + +-- horizontal ASC order from window function, NULLs pushed rightmost +SELECT v,h, string_agg(c, E'\n') AS c, row_number() OVER(ORDER BY h NULLS LAST) AS r +FROM ctv_data GROUP BY v, h ORDER BY 1,3,2 + +-- only null, no column name, 2 columns: error +SELECT null,null \crosstabview + +-- only null, no column name, 3 columns: works +SELECT null,null,null \crosstabview + +-- null display +SELECT v,h, string_agg(i::text, E'\n') AS i FROM ctv_data +GROUP BY v, h ORDER BY h,v + +-- refer to columns by position +SELECT v,h,string_agg(i::text, E'\n'), string_agg(c, E'\n') +FROM ctv_data GROUP BY v, h ORDER BY h,v + +-- refer to columns by positions and names mixed +SELECT v,h, string_agg(i::text, E'\n') AS i, string_agg(c, E'\n') AS c +FROM ctv_data GROUP BY v, h ORDER BY h,v + +-- refer to columns by quoted names, check downcasing of unquoted name +SELECT 1 as "22", 2 as b, 3 as "Foo" + +-- error: bad column name +SELECT v,h,c,i FROM ctv_data + +-- error: need to quote name +SELECT 1 as "22", 2 as b, 3 as "Foo" + +-- error: need to not quote name +SELECT 1 as "22", 2 as b, 3 as "Foo" + +-- error: bad column number +SELECT v,h,i,c FROM ctv_data + +-- error: same H and V columns +SELECT v,h,i,c FROM ctv_data + +-- error: too many columns +SELECT a,a,1 FROM generate_series(1,3000) AS a + +-- error: only one column +SELECT 1 \crosstabview + +DROP TABLE ctv_data +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 291 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- check error reporting (bug #14476) +CREATE TABLE ctv_data (x int, y int, v text) +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=DDL +STMT: CreateStmt +== 006 +INSERT INTO ctv_data SELECT 1, x, '*' || x FROM generate_series(1,10) x +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 007 +SELECT * FROM ctv_data \crosstabview + +INSERT INTO ctv_data VALUES (1, 10, '*') +-- +ERROR: syntax error at or near "\" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +-- duplicate data to cause error +SELECT * FROM ctv_data \crosstabview + +DROP TABLE ctv_data +-- +ERROR: syntax error at or near "\" +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary/postgres_regress/publication.metadata.json b/parser/testdata/summary/postgres_regress/publication.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/publication.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/publication.test b/parser/testdata/summary/postgres_regress/publication.test new file mode 100644 index 0000000..0e71b6d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/publication.test @@ -0,0 +1,3236 @@ +== 001 +|-- +-- PUBLICATION +|-- +CREATE ROLE regress_publication_user LOGIN SUPERUSER +-- +STMT: CreateRoleStmt +== 002 +CREATE ROLE regress_publication_user2 +-- +STMT: CreateRoleStmt +== 003 +CREATE ROLE regress_publication_user_dummy LOGIN NOSUPERUSER +-- +STMT: CreateRoleStmt +== 004 +SET SESSION AUTHORIZATION 'regress_publication_user' +-- +STMT: VariableSetStmt +== 005 +-- suppress warning that depends on wal_level +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 006 +CREATE PUBLICATION testpub_default +-- +STMT: CreatePublicationStmt +== 007 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 008 +COMMENT ON PUBLICATION testpub_default IS 'test publication' +-- +STMT: CommentStmt +== 009 +SELECT obj_description(p.oid, 'pg_publication') FROM pg_publication p +-- +TABLE: name="pg_publication" schema="" table="pg_publication" ctx=Select +ALIAS: "p"="pg_publication" +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +== 010 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 011 +CREATE PUBLICATION testpib_ins_trunct WITH (publish = insert) +-- +STMT: CreatePublicationStmt +== 012 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 013 +ALTER PUBLICATION testpub_default SET (publish = update) +-- +STMT: AlterPublicationStmt +== 014 +-- error cases +CREATE PUBLICATION testpub_xxx WITH (foo) +-- +STMT: CreatePublicationStmt +== 015 +CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum') +-- +STMT: CreatePublicationStmt +== 016 +CREATE PUBLICATION testpub_xxx WITH (publish_via_partition_root = 'true', publish_via_partition_root = '0') +-- +STMT: CreatePublicationStmt +== 017 +ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete') +-- +STMT: AlterPublicationStmt +== 018 +--- adding tables +CREATE SCHEMA pub_test +-- +STMT: CreateSchemaStmt +== 019 +CREATE TABLE testpub_tbl1 (id serial primary key, data text) +-- +TABLE: name="testpub_tbl1" schema="" table="testpub_tbl1" ctx=DDL +STMT: CreateStmt +== 020 +CREATE TABLE pub_test.testpub_nopk (foo int, bar int) +-- +TABLE: name="pub_test.testpub_nopk" schema="pub_test" table="testpub_nopk" ctx=DDL +STMT: CreateStmt +== 021 +CREATE VIEW testpub_view AS SELECT 1 +-- +TABLE: name="testpub_view" schema="" table="testpub_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 022 +CREATE TABLE testpub_parted (a int) PARTITION BY LIST (a) +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: CreateStmt +== 023 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 024 +CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 025 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 026 +ALTER PUBLICATION testpub_foralltables SET (publish = 'insert, update') +-- +STMT: AlterPublicationStmt +== 027 +CREATE TABLE testpub_tbl2 (id serial primary key, data text) +-- +TABLE: name="testpub_tbl2" schema="" table="testpub_tbl2" ctx=DDL +STMT: CreateStmt +== 028 +-- fail - can't add to for all tables publication +ALTER PUBLICATION testpub_foralltables ADD TABLE testpub_tbl2 +-- +STMT: AlterPublicationStmt +== 029 +-- fail - can't drop from all tables publication +ALTER PUBLICATION testpub_foralltables DROP TABLE testpub_tbl2 +-- +STMT: AlterPublicationStmt +== 030 +-- fail - can't add to for all tables publication +ALTER PUBLICATION testpub_foralltables SET TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +== 031 +-- fail - can't add schema to 'FOR ALL TABLES' publication +ALTER PUBLICATION testpub_foralltables ADD TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +== 032 +-- fail - can't drop schema from 'FOR ALL TABLES' publication +ALTER PUBLICATION testpub_foralltables DROP TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +== 033 +-- fail - can't set schema to 'FOR ALL TABLES' publication +ALTER PUBLICATION testpub_foralltables SET TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +== 034 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 035 +CREATE PUBLICATION testpub_fortable FOR TABLE testpub_tbl1 +-- +STMT: CreatePublicationStmt +== 036 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 037 +-- should be able to add schema to 'FOR TABLE' publication +ALTER PUBLICATION testpub_fortable ADD TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +== 038 +-- should be able to drop schema from 'FOR TABLE' publication +ALTER PUBLICATION testpub_fortable DROP TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +== 039 +-- should be able to set schema to 'FOR TABLE' publication +ALTER PUBLICATION testpub_fortable SET TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +== 040 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 041 +CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pub_test +-- +STMT: CreatePublicationStmt +== 042 +-- should be able to create publication with schema and table of the same +-- schema +CREATE PUBLICATION testpub_for_tbl_schema FOR TABLES IN SCHEMA pub_test, TABLE pub_test.testpub_nopk +-- +STMT: CreatePublicationStmt +== 043 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 044 +-- weird parser corner case +CREATE PUBLICATION testpub_parsertst FOR TABLE pub_test.testpub_nopk, CURRENT_SCHEMA +-- +ERROR: invalid table name +CURSORPOS: 99 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 045 +CREATE PUBLICATION testpub_parsertst FOR TABLES IN SCHEMA foo, test.foo +-- +ERROR: invalid schema name +CURSORPOS: 64 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 046 +-- should be able to add a table of the same schema to the schema publication +ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +== 047 +-- should be able to drop the table +ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +== 048 +-- fail - can't drop a table from the schema publication which isn't in the +-- publication +ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +== 049 +-- should be able to set table to schema publication +ALTER PUBLICATION testpub_forschema SET TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +== 050 +SELECT pubname, puballtables FROM pg_publication WHERE pubname = 'testpub_foralltables' +-- +TABLE: name="pg_publication" schema="" table="pg_publication" ctx=Select +FILTER: schema="" table="" column="pubname" +STMT: SelectStmt +== 051 +DROP TABLE testpub_tbl2 +-- +TABLE: name="testpub_tbl2" schema="" table="testpub_tbl2" ctx=DDL +STMT: DropStmt +== 052 +DROP PUBLICATION testpub_foralltables, testpub_fortable, testpub_forschema, testpub_for_tbl_schema +-- +STMT: DropStmt +== 053 +CREATE TABLE testpub_tbl3 (a int) +-- +TABLE: name="testpub_tbl3" schema="" table="testpub_tbl3" ctx=DDL +STMT: CreateStmt +== 054 +CREATE TABLE testpub_tbl3a (b text) INHERITS (testpub_tbl3) +-- +TABLE: name="testpub_tbl3a" schema="" table="testpub_tbl3a" ctx=DDL +STMT: CreateStmt +== 055 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 056 +CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3 +-- +STMT: CreatePublicationStmt +== 057 +CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3 +-- +STMT: CreatePublicationStmt +== 058 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 059 +DROP TABLE testpub_tbl3, testpub_tbl3a +-- +TABLE: name="testpub_tbl3" schema="" table="testpub_tbl3" ctx=DDL +TABLE: name="testpub_tbl3a" schema="" table="testpub_tbl3a" ctx=DDL +STMT: DropStmt +== 060 +DROP PUBLICATION testpub3, testpub4 +-- +STMT: DropStmt +== 061 +-- Tests for partitioned tables +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 062 +CREATE PUBLICATION testpub_forparted +-- +STMT: CreatePublicationStmt +== 063 +CREATE PUBLICATION testpub_forparted1 +-- +STMT: CreatePublicationStmt +== 064 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 065 +CREATE TABLE testpub_parted1 (LIKE testpub_parted) +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DDL +STMT: CreateStmt +== 066 +CREATE TABLE testpub_parted2 (LIKE testpub_parted) +-- +TABLE: name="testpub_parted2" schema="" table="testpub_parted2" ctx=DDL +STMT: CreateStmt +== 067 +ALTER PUBLICATION testpub_forparted1 SET (publish='insert') +-- +STMT: AlterPublicationStmt +== 068 +ALTER TABLE testpub_parted ATTACH PARTITION testpub_parted1 FOR VALUES IN (1) +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: AlterTableStmt +== 069 +ALTER TABLE testpub_parted ATTACH PARTITION testpub_parted2 FOR VALUES IN (2) +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: AlterTableStmt +== 070 +-- works despite missing REPLICA IDENTITY, because updates are not replicated +UPDATE testpub_parted1 SET a = 1 +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DML +STMT: UpdateStmt +== 071 +-- only parent is listed as being in publication, not the partition +ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted +-- +STMT: AlterPublicationStmt +== 072 +-- works despite missing REPLICA IDENTITY, because no actual update happened +UPDATE testpub_parted SET a = 1 WHERE false +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DML +STMT: UpdateStmt +== 073 +-- should now fail, because parent's publication replicates updates +UPDATE testpub_parted1 SET a = 1 +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DML +STMT: UpdateStmt +== 074 +ALTER TABLE testpub_parted DETACH PARTITION testpub_parted1 +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: AlterTableStmt +== 075 +-- works again, because parent's publication is no longer considered +UPDATE testpub_parted1 SET a = 1 +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DML +STMT: UpdateStmt +== 076 +ALTER PUBLICATION testpub_forparted SET (publish_via_partition_root = true) +-- +STMT: AlterPublicationStmt +== 077 +-- still fail, because parent's publication replicates updates +UPDATE testpub_parted2 SET a = 2 +-- +TABLE: name="testpub_parted2" schema="" table="testpub_parted2" ctx=DML +STMT: UpdateStmt +== 078 +ALTER PUBLICATION testpub_forparted DROP TABLE testpub_parted +-- +STMT: AlterPublicationStmt +== 079 +-- works again, because update is no longer replicated +UPDATE testpub_parted2 SET a = 2 +-- +TABLE: name="testpub_parted2" schema="" table="testpub_parted2" ctx=DML +STMT: UpdateStmt +== 080 +DROP TABLE testpub_parted1, testpub_parted2 +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DDL +TABLE: name="testpub_parted2" schema="" table="testpub_parted2" ctx=DDL +STMT: DropStmt +== 081 +DROP PUBLICATION testpub_forparted, testpub_forparted1 +-- +STMT: DropStmt +== 082 +-- Tests for row filters +CREATE TABLE testpub_rf_tbl1 (a integer, b text) +-- +TABLE: name="testpub_rf_tbl1" schema="" table="testpub_rf_tbl1" ctx=DDL +STMT: CreateStmt +== 083 +CREATE TABLE testpub_rf_tbl2 (c text, d integer) +-- +TABLE: name="testpub_rf_tbl2" schema="" table="testpub_rf_tbl2" ctx=DDL +STMT: CreateStmt +== 084 +CREATE TABLE testpub_rf_tbl3 (e integer) +-- +TABLE: name="testpub_rf_tbl3" schema="" table="testpub_rf_tbl3" ctx=DDL +STMT: CreateStmt +== 085 +CREATE TABLE testpub_rf_tbl4 (g text) +-- +TABLE: name="testpub_rf_tbl4" schema="" table="testpub_rf_tbl4" ctx=DDL +STMT: CreateStmt +== 086 +CREATE TABLE testpub_rf_tbl5 (a xml) +-- +TABLE: name="testpub_rf_tbl5" schema="" table="testpub_rf_tbl5" ctx=DDL +STMT: CreateStmt +== 087 +CREATE SCHEMA testpub_rf_schema1 +-- +STMT: CreateSchemaStmt +== 088 +CREATE TABLE testpub_rf_schema1.testpub_rf_tbl5 (h integer) +-- +TABLE: name="testpub_rf_schema1.testpub_rf_tbl5" schema="testpub_rf_schema1" table="testpub_rf_tbl5" ctx=DDL +STMT: CreateStmt +== 089 +CREATE SCHEMA testpub_rf_schema2 +-- +STMT: CreateSchemaStmt +== 090 +CREATE TABLE testpub_rf_schema2.testpub_rf_tbl6 (i integer) +-- +TABLE: name="testpub_rf_schema2.testpub_rf_tbl6" schema="testpub_rf_schema2" table="testpub_rf_tbl6" ctx=DDL +STMT: CreateStmt +== 091 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 092 +-- Firstly, test using the option publish='insert' because the row filter +-- validation of referenced columns is less strict than for delete/update. +CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 093 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 094 +ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000) +-- +STMT: AlterPublicationStmt +== 095 +ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2 +-- +STMT: AlterPublicationStmt +== 096 +-- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression) +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500) +-- +STMT: AlterPublicationStmt +== 097 +-- test \d (now it displays filter information) +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 098 +CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 099 +CREATE PUBLICATION testpub_rf_no FOR TABLE testpub_rf_tbl1 +-- +STMT: CreatePublicationStmt +== 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 101 +DROP PUBLICATION testpub_rf_yes, testpub_rf_no +-- +STMT: DropStmt +== 102 +-- some more syntax tests to exercise other parser pathways +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 103 +CREATE PUBLICATION testpub_syntax1 FOR TABLE testpub_rf_tbl1, ONLY testpub_rf_tbl3 WHERE (e < 999) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 104 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 105 +DROP PUBLICATION testpub_syntax1 +-- +STMT: DropStmt +== 106 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 107 +CREATE PUBLICATION testpub_syntax2 FOR TABLE testpub_rf_tbl1, testpub_rf_schema1.testpub_rf_tbl5 WHERE (h < 999) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 108 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 109 +DROP PUBLICATION testpub_syntax2 +-- +STMT: DropStmt +== 110 +-- fail - schemas don't allow WHERE clause +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 111 +CREATE PUBLICATION testpub_syntax3 FOR TABLES IN SCHEMA testpub_rf_schema1 WHERE (a = 123) +-- +ERROR: syntax error at or near "WHERE" +CURSORPOS: 76 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 112 +CREATE PUBLICATION testpub_syntax3 FOR TABLES IN SCHEMA testpub_rf_schema1, testpub_rf_schema1 WHERE (a = 123) +-- +ERROR: WHERE clause not allowed for schema +CURSORPOS: 77 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 113 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 114 +-- fail - duplicate tables are not allowed if that table has any WHERE clause +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 115 +CREATE PUBLICATION testpub_dups FOR TABLE testpub_rf_tbl1 WHERE (a = 1), testpub_rf_tbl1 WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 116 +CREATE PUBLICATION testpub_dups FOR TABLE testpub_rf_tbl1, testpub_rf_tbl1 WHERE (a = 2) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 117 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 118 +-- fail - publication WHERE clause must be boolean +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (1234) +-- +STMT: AlterPublicationStmt +== 119 +-- fail - aggregate functions not allowed in WHERE clause +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e < AVG(e)) +-- +STMT: AlterPublicationStmt +== 120 +-- fail - user-defined operators are not allowed +CREATE FUNCTION testpub_rf_func1(integer, integer) RETURNS boolean AS $$ SELECT hashint4($1) > $2 $$ LANGUAGE SQL +-- +FUNCTION: name="testpub_rf_func1" function="testpub_rf_func1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 121 +CREATE OPERATOR =#> (PROCEDURE = testpub_rf_func1, LEFTARG = integer, RIGHTARG = integer) +-- +STMT: DefineStmt +== 122 +CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl3 WHERE (e =#> 27) +-- +STMT: CreatePublicationStmt +== 123 +-- fail - user-defined functions are not allowed +CREATE FUNCTION testpub_rf_func2() RETURNS integer AS $$ BEGIN RETURN 123; END; $$ LANGUAGE plpgsql +-- +FUNCTION: name="testpub_rf_func2" function="testpub_rf_func2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 124 +ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (a >= testpub_rf_func2()) +-- +STMT: AlterPublicationStmt +== 125 +-- fail - non-immutable functions are not allowed. random() is volatile. +ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (a < random()) +-- +STMT: AlterPublicationStmt +== 126 +-- fail - user-defined collations are not allowed +CREATE COLLATION user_collation FROM "C" +-- +STMT: DefineStmt +== 127 +ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (b < '2' COLLATE user_collation) +-- +STMT: AlterPublicationStmt +== 128 +-- ok - NULLIF is allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (NULLIF(1,2) = a) +-- +STMT: AlterPublicationStmt +== 129 +-- ok - built-in operators are allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IS NULL) +-- +STMT: AlterPublicationStmt +== 130 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE ((a > 5) IS FALSE) +-- +STMT: AlterPublicationStmt +== 131 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IS DISTINCT FROM 5) +-- +STMT: AlterPublicationStmt +== 132 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE ((a, a + 1) < (2, 3)) +-- +STMT: AlterPublicationStmt +== 133 +-- ok - built-in type coercions between two binary compatible datatypes are allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (b::varchar < '2') +-- +STMT: AlterPublicationStmt +== 134 +-- ok - immutable built-in functions are allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl4 WHERE (length(g) < 6) +-- +STMT: AlterPublicationStmt +== 135 +-- fail - user-defined types are not allowed +CREATE TYPE rf_bug_status AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +== 136 +CREATE TABLE rf_bug (id serial, description text, status rf_bug_status) +-- +TABLE: name="rf_bug" schema="" table="rf_bug" ctx=DDL +STMT: CreateStmt +== 137 +CREATE PUBLICATION testpub6 FOR TABLE rf_bug WHERE (status = 'open') WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 138 +DROP TABLE rf_bug +-- +TABLE: name="rf_bug" schema="" table="rf_bug" ctx=DDL +STMT: DropStmt +== 139 +DROP TYPE rf_bug_status +-- +STMT: DropStmt +== 140 +-- fail - row filter expression is not simple +CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl1 WHERE (a IN (SELECT generate_series(1,5))) +-- +STMT: CreatePublicationStmt +== 141 +-- fail - system columns are not allowed +CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl1 WHERE ('(0,1)'::tid = ctid) +-- +STMT: CreatePublicationStmt +== 142 +-- ok - conditional expressions are allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl5 WHERE (a IS DOCUMENT) +-- +STMT: AlterPublicationStmt +== 143 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl5 WHERE (xmlexists('//foo[text() = ''bar'']' PASSING BY VALUE a)) +-- +STMT: AlterPublicationStmt +== 144 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (NULLIF(1, 2) = a) +-- +STMT: AlterPublicationStmt +== 145 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (CASE a WHEN 5 THEN true ELSE false END) +-- +STMT: AlterPublicationStmt +== 146 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (COALESCE(b, 'foo') = 'foo') +-- +STMT: AlterPublicationStmt +== 147 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (GREATEST(a, 10) > 10) +-- +STMT: AlterPublicationStmt +== 148 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IN (2, 4, 6)) +-- +STMT: AlterPublicationStmt +== 149 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (ARRAY[a] <@ ARRAY[2, 4, 6]) +-- +STMT: AlterPublicationStmt +== 150 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (ROW(a, 2) IS NULL) +-- +STMT: AlterPublicationStmt +== 151 +-- fail - WHERE not allowed in DROP +ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl1 WHERE (e < 27) +-- +STMT: AlterPublicationStmt +== 152 +-- fail - cannot ALTER SET table which is a member of a pre-existing schema +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 153 +CREATE PUBLICATION testpub6 FOR TABLES IN SCHEMA testpub_rf_schema2 +-- +STMT: CreatePublicationStmt +== 154 +-- should be able to set publication with schema and table of the same schema +ALTER PUBLICATION testpub6 SET TABLES IN SCHEMA testpub_rf_schema2, TABLE testpub_rf_schema2.testpub_rf_tbl6 WHERE (i < 99) +-- +STMT: AlterPublicationStmt +== 155 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 156 +DROP TABLE testpub_rf_tbl1 +-- +TABLE: name="testpub_rf_tbl1" schema="" table="testpub_rf_tbl1" ctx=DDL +STMT: DropStmt +== 157 +DROP TABLE testpub_rf_tbl2 +-- +TABLE: name="testpub_rf_tbl2" schema="" table="testpub_rf_tbl2" ctx=DDL +STMT: DropStmt +== 158 +DROP TABLE testpub_rf_tbl3 +-- +TABLE: name="testpub_rf_tbl3" schema="" table="testpub_rf_tbl3" ctx=DDL +STMT: DropStmt +== 159 +DROP TABLE testpub_rf_tbl4 +-- +TABLE: name="testpub_rf_tbl4" schema="" table="testpub_rf_tbl4" ctx=DDL +STMT: DropStmt +== 160 +DROP TABLE testpub_rf_tbl5 +-- +TABLE: name="testpub_rf_tbl5" schema="" table="testpub_rf_tbl5" ctx=DDL +STMT: DropStmt +== 161 +DROP TABLE testpub_rf_schema1.testpub_rf_tbl5 +-- +TABLE: name="testpub_rf_schema1.testpub_rf_tbl5" schema="testpub_rf_schema1" table="testpub_rf_tbl5" ctx=DDL +STMT: DropStmt +== 162 +DROP TABLE testpub_rf_schema2.testpub_rf_tbl6 +-- +TABLE: name="testpub_rf_schema2.testpub_rf_tbl6" schema="testpub_rf_schema2" table="testpub_rf_tbl6" ctx=DDL +STMT: DropStmt +== 163 +DROP SCHEMA testpub_rf_schema1 +-- +STMT: DropStmt +== 164 +DROP SCHEMA testpub_rf_schema2 +-- +STMT: DropStmt +== 165 +DROP PUBLICATION testpub5 +-- +STMT: DropStmt +== 166 +DROP PUBLICATION testpub6 +-- +STMT: DropStmt +== 167 +DROP OPERATOR =#>(integer, integer) +-- +STMT: DropStmt +== 168 +DROP FUNCTION testpub_rf_func1(integer, integer) +-- +FUNCTION: name="testpub_rf_func1" function="testpub_rf_func1" schema="" ctx=DDL +STMT: DropStmt +== 169 +DROP FUNCTION testpub_rf_func2() +-- +FUNCTION: name="testpub_rf_func2" function="testpub_rf_func2" schema="" ctx=DDL +STMT: DropStmt +== 170 +DROP COLLATION user_collation +-- +STMT: DropStmt +== 171 +-- ====================================================== +-- More row filter tests for validating column references +CREATE TABLE rf_tbl_abcd_nopk(a int, b int, c int, d int) +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: CreateStmt +== 172 +CREATE TABLE rf_tbl_abcd_pk(a int, b int, c int, d int, PRIMARY KEY(a,b)) +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: CreateStmt +== 173 +CREATE TABLE rf_tbl_abcd_part_pk (a int PRIMARY KEY, b int) PARTITION by RANGE (a) +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: CreateStmt +== 174 +CREATE TABLE rf_tbl_abcd_part_pk_1 (b int, a int PRIMARY KEY) +-- +TABLE: name="rf_tbl_abcd_part_pk_1" schema="" table="rf_tbl_abcd_part_pk_1" ctx=DDL +STMT: CreateStmt +== 175 +ALTER TABLE rf_tbl_abcd_part_pk ATTACH PARTITION rf_tbl_abcd_part_pk_1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: AlterTableStmt +== 176 +-- Case 1. REPLICA IDENTITY DEFAULT (means use primary key or nothing) +-- 1a. REPLICA IDENTITY is DEFAULT and table has a PK. +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 177 +CREATE PUBLICATION testpub6 FOR TABLE rf_tbl_abcd_pk WHERE (a > 99) +-- +STMT: CreatePublicationStmt +== 178 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 179 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 180 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (b > 99) +-- +STMT: AlterPublicationStmt +== 181 +-- ok - "b" is a PK col +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 182 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +== 183 +-- fail - "c" is not part of the PK +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 184 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (d > 99) +-- +STMT: AlterPublicationStmt +== 185 +-- fail - "d" is not part of the PK +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 186 +-- 1b. REPLICA IDENTITY is DEFAULT and table has no PK +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 187 +-- fail - "a" is not part of REPLICA IDENTITY +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 188 +-- Case 2. REPLICA IDENTITY FULL +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY FULL +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +== 189 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY FULL +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +== 190 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +== 191 +-- ok - "c" is in REPLICA IDENTITY now even though not in PK +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 192 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 193 +-- ok - "a" is in REPLICA IDENTITY now +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 194 +-- Case 3. REPLICA IDENTITY NOTHING +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY NOTHING +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +== 195 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY NOTHING +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +== 196 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 197 +-- fail - "a" is in PK but it is not part of REPLICA IDENTITY NOTHING +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 198 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +== 199 +-- fail - "c" is not in PK and not in REPLICA IDENTITY NOTHING +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 200 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 201 +-- fail - "a" is not in REPLICA IDENTITY NOTHING +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 202 +-- Case 4. REPLICA IDENTITY INDEX +ALTER TABLE rf_tbl_abcd_pk ALTER COLUMN c SET NOT NULL +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +== 203 +CREATE UNIQUE INDEX idx_abcd_pk_c ON rf_tbl_abcd_pk(c) +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: IndexStmt +== 204 +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY USING INDEX idx_abcd_pk_c +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +== 205 +ALTER TABLE rf_tbl_abcd_nopk ALTER COLUMN c SET NOT NULL +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +== 206 +CREATE UNIQUE INDEX idx_abcd_nopk_c ON rf_tbl_abcd_nopk(c) +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: IndexStmt +== 207 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY USING INDEX idx_abcd_nopk_c +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +== 208 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 209 +-- fail - "a" is in PK but it is not part of REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 210 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +== 211 +-- ok - "c" is not in PK but it is part of REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 212 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 213 +-- fail - "a" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 214 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +== 215 +-- ok - "c" is part of REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 216 +-- Tests for partitioned table + +-- set PUBLISH_VIA_PARTITION_ROOT to false and test row filter for partitioned +-- table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +== 217 +-- fail - cannot use row filter for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 218 +-- ok - can use row filter for partition +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 219 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +== 220 +-- set PUBLISH_VIA_PARTITION_ROOT to true and test row filter for partitioned +-- table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: AlterPublicationStmt +== 221 +-- ok - can use row filter for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +== 222 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +== 223 +-- fail - cannot set PUBLISH_VIA_PARTITION_ROOT to false if any row filter is +-- used for partitioned table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +== 224 +-- remove partitioned table's row filter +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk +-- +STMT: AlterPublicationStmt +== 225 +-- ok - we don't have row filter for partitioned table. +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +== 226 +-- Now change the root filter to use a column "b" +-- (which is not in the replica identity) +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 WHERE (b > 99) +-- +STMT: AlterPublicationStmt +== 227 +-- ok - we don't have row filter for partitioned table. +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +== 228 +-- fail - "b" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +== 229 +-- set PUBLISH_VIA_PARTITION_ROOT to true +-- can use row filter for partitioned table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: AlterPublicationStmt +== 230 +-- ok - can use row filter for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (b > 99) +-- +STMT: AlterPublicationStmt +== 231 +-- fail - "b" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +== 232 +DROP PUBLICATION testpub6 +-- +STMT: DropStmt +== 233 +DROP TABLE rf_tbl_abcd_pk +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: DropStmt +== 234 +DROP TABLE rf_tbl_abcd_nopk +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: DropStmt +== 235 +DROP TABLE rf_tbl_abcd_part_pk +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: DropStmt +== 236 +-- ====================================================== + +-- fail - duplicate tables are not allowed if that table has any column lists +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 237 +CREATE PUBLICATION testpub_dups FOR TABLE testpub_tbl1 (a), testpub_tbl1 WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 238 +CREATE PUBLICATION testpub_dups FOR TABLE testpub_tbl1, testpub_tbl1 (a) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 239 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 240 +-- test for column lists +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 241 +CREATE PUBLICATION testpub_fortable FOR TABLE testpub_tbl1 +-- +STMT: CreatePublicationStmt +== 242 +CREATE PUBLICATION testpub_fortable_insert WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +== 243 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 244 +CREATE TABLE testpub_tbl5 (a int PRIMARY KEY, b text, c text, + d int generated always as (a + length(b)) stored) +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: CreateStmt +== 245 +-- error: column "x" does not exist +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, x) +-- +STMT: AlterPublicationStmt +== 246 +-- error: replica identity "a" not included in the column list +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (b, c) +-- +STMT: AlterPublicationStmt +== 247 +UPDATE testpub_tbl5 SET a = 1 +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DML +STMT: UpdateStmt +== 248 +ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl5 +-- +STMT: AlterPublicationStmt +== 249 +-- error: generated column "d" can't be in list +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, d) +-- +STMT: AlterPublicationStmt +== 250 +-- error: system attributes "ctid" not allowed in column list +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, ctid) +-- +STMT: AlterPublicationStmt +== 251 +-- ok +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, c) +-- +STMT: AlterPublicationStmt +== 252 +ALTER TABLE testpub_tbl5 DROP COLUMN c +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: AlterTableStmt +== 253 +-- no dice +-- ok: for insert-only publication, any column list is acceptable +ALTER PUBLICATION testpub_fortable_insert ADD TABLE testpub_tbl5 (b, c) +-- +STMT: AlterPublicationStmt +== 254 +/* not all replica identities are good enough */ +CREATE UNIQUE INDEX testpub_tbl5_b_key ON testpub_tbl5 (b, c) +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: IndexStmt +== 255 +ALTER TABLE testpub_tbl5 ALTER b SET NOT NULL, ALTER c SET NOT NULL +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: AlterTableStmt +== 256 +ALTER TABLE testpub_tbl5 REPLICA IDENTITY USING INDEX testpub_tbl5_b_key +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: AlterTableStmt +== 257 +-- error: replica identity (b,c) is not covered by column list (a, c) +UPDATE testpub_tbl5 SET a = 1 +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DML +STMT: UpdateStmt +== 258 +ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl5 +-- +STMT: AlterPublicationStmt +== 259 +-- error: change the replica identity to "b", and column list to (a, c) +-- then update fails, because (a, c) does not cover replica identity +ALTER TABLE testpub_tbl5 REPLICA IDENTITY USING INDEX testpub_tbl5_b_key +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: AlterTableStmt +== 260 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, c) +-- +STMT: AlterPublicationStmt +== 261 +UPDATE testpub_tbl5 SET a = 1 +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DML +STMT: UpdateStmt +== 262 +/* But if upd/del are not published, it works OK */ +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 263 +CREATE PUBLICATION testpub_table_ins WITH (publish = 'insert, truncate') +-- +STMT: CreatePublicationStmt +== 264 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 265 +ALTER PUBLICATION testpub_table_ins ADD TABLE testpub_tbl5 (a) +-- +STMT: AlterPublicationStmt +== 266 +-- ok + +-- error: cannot work with deferrable primary keys +CREATE TABLE testpub_tbl5d (a int PRIMARY KEY DEFERRABLE) +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DDL +STMT: CreateStmt +== 267 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5d +-- +STMT: AlterPublicationStmt +== 268 +UPDATE testpub_tbl5d SET a = 1 +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DML +STMT: UpdateStmt +== 269 +/* but works fine with FULL replica identity */ +ALTER TABLE testpub_tbl5d REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DDL +STMT: AlterTableStmt +== 270 +UPDATE testpub_tbl5d SET a = 1 +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DML +STMT: UpdateStmt +== 271 +DROP TABLE testpub_tbl5d +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DDL +STMT: DropStmt +== 272 +-- tests with REPLICA IDENTITY FULL +CREATE TABLE testpub_tbl6 (a int, b text, c text) +-- +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DDL +STMT: CreateStmt +== 273 +ALTER TABLE testpub_tbl6 REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DDL +STMT: AlterTableStmt +== 274 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl6 (a, b, c) +-- +STMT: AlterPublicationStmt +== 275 +UPDATE testpub_tbl6 SET a = 1 +-- +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DML +STMT: UpdateStmt +== 276 +ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl6 +-- +STMT: AlterPublicationStmt +== 277 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl6 +-- +STMT: AlterPublicationStmt +== 278 +-- ok +UPDATE testpub_tbl6 SET a = 1 +-- +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DML +STMT: UpdateStmt +== 279 +-- make sure changing the column list is propagated to the catalog +CREATE TABLE testpub_tbl7 (a int primary key, b text, c text) +-- +TABLE: name="testpub_tbl7" schema="" table="testpub_tbl7" ctx=DDL +STMT: CreateStmt +== 280 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl7 (a, b) +-- +STMT: AlterPublicationStmt +== 281 +-- ok: the column list is the same, we should skip this table (or at least not fail) +ALTER PUBLICATION testpub_fortable SET TABLE testpub_tbl7 (a, b) +-- +STMT: AlterPublicationStmt +== 282 +-- ok: the column list changes, make sure the catalog gets updated +ALTER PUBLICATION testpub_fortable SET TABLE testpub_tbl7 (a, c) +-- +STMT: AlterPublicationStmt +== 283 +-- column list for partitioned tables has to cover replica identities for +-- all child relations +CREATE TABLE testpub_tbl8 (a int, b text, c text) PARTITION BY HASH (a) +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: CreateStmt +== 284 +-- first partition has replica identity "a" +CREATE TABLE testpub_tbl8_0 PARTITION OF testpub_tbl8 FOR VALUES WITH (modulus 2, remainder 0) +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: CreateStmt +== 285 +ALTER TABLE testpub_tbl8_0 ADD PRIMARY KEY (a) +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +== 286 +ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY USING INDEX testpub_tbl8_0_pkey +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +== 287 +-- second partition has replica identity "b" +CREATE TABLE testpub_tbl8_1 PARTITION OF testpub_tbl8 FOR VALUES WITH (modulus 2, remainder 1) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: CreateStmt +== 288 +ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (b) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 289 +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 290 +-- ok: column list covers both "a" and "b" +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 291 +CREATE PUBLICATION testpub_col_list FOR TABLE testpub_tbl8 (a, b) WITH (publish_via_partition_root = 'true') +-- +STMT: CreatePublicationStmt +== 292 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 293 +-- ok: the same thing, but try plain ADD TABLE +ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8 +-- +STMT: AlterPublicationStmt +== 294 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, b) +-- +STMT: AlterPublicationStmt +== 295 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +== 296 +-- failure: column list does not cover replica identity for the second partition +ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8 +-- +STMT: AlterPublicationStmt +== 297 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, c) +-- +STMT: AlterPublicationStmt +== 298 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +== 299 +ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8 +-- +STMT: AlterPublicationStmt +== 300 +-- failure: one of the partitions has REPLICA IDENTITY FULL +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 301 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, c) +-- +STMT: AlterPublicationStmt +== 302 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +== 303 +ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8 +-- +STMT: AlterPublicationStmt +== 304 +-- add table and then try changing replica identity +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 305 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, b) +-- +STMT: AlterPublicationStmt +== 306 +-- failure: replica identity full can't be used with a column list +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 307 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +== 308 +-- failure: replica identity has to be covered by the column list +ALTER TABLE testpub_tbl8_1 DROP CONSTRAINT testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 309 +ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (c) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 310 +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 311 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +== 312 +DROP TABLE testpub_tbl8 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: DropStmt +== 313 +-- column list for partitioned tables has to cover replica identities for +-- all child relations +CREATE TABLE testpub_tbl8 (a int, b text, c text) PARTITION BY HASH (a) +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: CreateStmt +== 314 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, b) +-- +STMT: AlterPublicationStmt +== 315 +-- first partition has replica identity "a" +CREATE TABLE testpub_tbl8_0 (a int, b text, c text) +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: CreateStmt +== 316 +ALTER TABLE testpub_tbl8_0 ADD PRIMARY KEY (a) +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +== 317 +ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY USING INDEX testpub_tbl8_0_pkey +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +== 318 +-- second partition has replica identity "b" +CREATE TABLE testpub_tbl8_1 (a int, b text, c text) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: CreateStmt +== 319 +ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (c) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 320 +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +== 321 +-- ok: attaching first partition works, because (a) is in column list +ALTER TABLE testpub_tbl8 ATTACH PARTITION testpub_tbl8_0 FOR VALUES WITH (modulus 2, remainder 0) +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: AlterTableStmt +== 322 +-- failure: second partition has replica identity (c), which si not in column list +ALTER TABLE testpub_tbl8 ATTACH PARTITION testpub_tbl8_1 FOR VALUES WITH (modulus 2, remainder 1) +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: AlterTableStmt +== 323 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +== 324 +-- failure: changing replica identity to FULL for partition fails, because +-- of the column list on the parent +ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +== 325 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +== 326 +-- test that using column list for table is disallowed if any schemas are +-- part of the publication +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 327 +-- failure - cannot use column list and schema together +CREATE PUBLICATION testpub_tbl9 FOR TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a) +-- +STMT: CreatePublicationStmt +== 328 +-- ok - only publish schema +CREATE PUBLICATION testpub_tbl9 FOR TABLES IN SCHEMA public +-- +STMT: CreatePublicationStmt +== 329 +-- failure - add a table with column list when there is already a schema in the +-- publication +ALTER PUBLICATION testpub_tbl9 ADD TABLE public.testpub_tbl7(a) +-- +STMT: AlterPublicationStmt +== 330 +-- ok - only publish table with column list +ALTER PUBLICATION testpub_tbl9 SET TABLE public.testpub_tbl7(a) +-- +STMT: AlterPublicationStmt +== 331 +-- failure - specify a schema when there is already a column list in the +-- publication +ALTER PUBLICATION testpub_tbl9 ADD TABLES IN SCHEMA public +-- +STMT: AlterPublicationStmt +== 332 +-- failure - cannot SET column list and schema together +ALTER PUBLICATION testpub_tbl9 SET TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a) +-- +STMT: AlterPublicationStmt +== 333 +-- ok - drop table +ALTER PUBLICATION testpub_tbl9 DROP TABLE public.testpub_tbl7 +-- +STMT: AlterPublicationStmt +== 334 +-- failure - cannot ADD column list and schema together +ALTER PUBLICATION testpub_tbl9 ADD TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a) +-- +STMT: AlterPublicationStmt +== 335 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 336 +DROP TABLE testpub_tbl5, testpub_tbl6, testpub_tbl7, testpub_tbl8, testpub_tbl8_1 +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DDL +TABLE: name="testpub_tbl7" schema="" table="testpub_tbl7" ctx=DDL +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: DropStmt +== 337 +DROP PUBLICATION testpub_table_ins, testpub_fortable, testpub_fortable_insert, testpub_col_list, testpub_tbl9 +-- +STMT: DropStmt +== 338 +-- ====================================================== + +-- Test combination of column list and row filter +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 339 +CREATE PUBLICATION testpub_both_filters +-- +STMT: CreatePublicationStmt +== 340 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 341 +CREATE TABLE testpub_tbl_both_filters (a int, b int, c int, PRIMARY KEY (a,c)) +-- +TABLE: name="testpub_tbl_both_filters" schema="" table="testpub_tbl_both_filters" ctx=DDL +STMT: CreateStmt +== 342 +ALTER TABLE testpub_tbl_both_filters REPLICA IDENTITY USING INDEX testpub_tbl_both_filters_pkey +-- +TABLE: name="testpub_tbl_both_filters" schema="" table="testpub_tbl_both_filters" ctx=DDL +STMT: AlterTableStmt +== 343 +ALTER PUBLICATION testpub_both_filters ADD TABLE testpub_tbl_both_filters (a,c) WHERE (c != 1) +-- +STMT: AlterPublicationStmt +== 344 +DROP TABLE testpub_tbl_both_filters +-- +TABLE: name="testpub_tbl_both_filters" schema="" table="testpub_tbl_both_filters" ctx=DDL +STMT: DropStmt +== 345 +DROP PUBLICATION testpub_both_filters +-- +STMT: DropStmt +== 346 +-- ====================================================== + +-- More column list tests for validating column references +CREATE TABLE rf_tbl_abcd_nopk(a int, b int, c int, d int) +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: CreateStmt +== 347 +CREATE TABLE rf_tbl_abcd_pk(a int, b int, c int, d int, PRIMARY KEY(a,b)) +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: CreateStmt +== 348 +CREATE TABLE rf_tbl_abcd_part_pk (a int PRIMARY KEY, b int) PARTITION by RANGE (a) +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: CreateStmt +== 349 +CREATE TABLE rf_tbl_abcd_part_pk_1 (b int, a int PRIMARY KEY) +-- +TABLE: name="rf_tbl_abcd_part_pk_1" schema="" table="rf_tbl_abcd_part_pk_1" ctx=DDL +STMT: CreateStmt +== 350 +ALTER TABLE rf_tbl_abcd_part_pk ATTACH PARTITION rf_tbl_abcd_part_pk_1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: AlterTableStmt +== 351 +-- Case 1. REPLICA IDENTITY DEFAULT (means use primary key or nothing) + +-- 1a. REPLICA IDENTITY is DEFAULT and table has a PK. +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 352 +CREATE PUBLICATION testpub6 FOR TABLE rf_tbl_abcd_pk (a, b) +-- +STMT: CreatePublicationStmt +== 353 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 354 +-- ok - (a,b) covers all PK cols +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 355 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a, b, c) +-- +STMT: AlterPublicationStmt +== 356 +-- ok - (a,b,c) covers all PK cols +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 357 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a) +-- +STMT: AlterPublicationStmt +== 358 +-- fail - "b" is missing from the column list +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 359 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (b) +-- +STMT: AlterPublicationStmt +== 360 +-- fail - "a" is missing from the column list +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 361 +-- 1b. REPLICA IDENTITY is DEFAULT and table has no PK +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (a) +-- +STMT: AlterPublicationStmt +== 362 +-- ok - there's no replica identity, so any column list works +-- note: it fails anyway, just a bit later because UPDATE requires RI +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 363 +-- Case 2. REPLICA IDENTITY FULL +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY FULL +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +== 364 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY FULL +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +== 365 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (c) +-- +STMT: AlterPublicationStmt +== 366 +-- fail - with REPLICA IDENTITY FULL no column list is allowed +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 367 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (a, b, c, d) +-- +STMT: AlterPublicationStmt +== 368 +-- fail - with REPLICA IDENTITY FULL no column list is allowed +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 369 +-- Case 3. REPLICA IDENTITY NOTHING +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY NOTHING +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +== 370 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY NOTHING +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +== 371 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a) +-- +STMT: AlterPublicationStmt +== 372 +-- ok - REPLICA IDENTITY NOTHING means all column lists are valid +-- it still fails later because without RI we can't replicate updates +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 373 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a, b, c, d) +-- +STMT: AlterPublicationStmt +== 374 +-- ok - REPLICA IDENTITY NOTHING means all column lists are valid +-- it still fails later because without RI we can't replicate updates +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 375 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (d) +-- +STMT: AlterPublicationStmt +== 376 +-- ok - REPLICA IDENTITY NOTHING means all column lists are valid +-- it still fails later because without RI we can't replicate updates +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 377 +-- Case 4. REPLICA IDENTITY INDEX +ALTER TABLE rf_tbl_abcd_pk ALTER COLUMN c SET NOT NULL +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +== 378 +CREATE UNIQUE INDEX idx_abcd_pk_c ON rf_tbl_abcd_pk(c) +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: IndexStmt +== 379 +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY USING INDEX idx_abcd_pk_c +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +== 380 +ALTER TABLE rf_tbl_abcd_nopk ALTER COLUMN c SET NOT NULL +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +== 381 +CREATE UNIQUE INDEX idx_abcd_nopk_c ON rf_tbl_abcd_nopk(c) +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: IndexStmt +== 382 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY USING INDEX idx_abcd_nopk_c +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +== 383 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a) +-- +STMT: AlterPublicationStmt +== 384 +-- fail - column list "a" does not cover the REPLICA IDENTITY INDEX on "c" +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 385 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (c) +-- +STMT: AlterPublicationStmt +== 386 +-- ok - column list "c" does cover the REPLICA IDENTITY INDEX on "c" +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +== 387 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (a) +-- +STMT: AlterPublicationStmt +== 388 +-- fail - column list "a" does not cover the REPLICA IDENTITY INDEX on "c" +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 389 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (c) +-- +STMT: AlterPublicationStmt +== 390 +-- ok - column list "c" does cover the REPLICA IDENTITY INDEX on "c" +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +== 391 +-- Tests for partitioned table + +-- set PUBLISH_VIA_PARTITION_ROOT to false and test column list for partitioned +-- table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +== 392 +-- fail - cannot use column list for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk (a) +-- +STMT: AlterPublicationStmt +== 393 +-- ok - can use column list for partition +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 (a) +-- +STMT: AlterPublicationStmt +== 394 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +== 395 +-- set PUBLISH_VIA_PARTITION_ROOT to true and test column list for partitioned +-- table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: AlterPublicationStmt +== 396 +-- ok - can use column list for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk (a) +-- +STMT: AlterPublicationStmt +== 397 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +== 398 +-- fail - cannot set PUBLISH_VIA_PARTITION_ROOT to false if any column list is +-- used for partitioned table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +== 399 +-- remove partitioned table's column list +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk +-- +STMT: AlterPublicationStmt +== 400 +-- ok - we don't have column list for partitioned table. +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +== 401 +-- Now change the root column list to use a column "b" +-- (which is not in the replica identity) +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 (b) +-- +STMT: AlterPublicationStmt +== 402 +-- ok - we don't have column list for partitioned table. +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +== 403 +-- fail - "b" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +== 404 +-- set PUBLISH_VIA_PARTITION_ROOT to true +-- can use column list for partitioned table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: AlterPublicationStmt +== 405 +-- ok - can use column list for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk (b) +-- +STMT: AlterPublicationStmt +== 406 +-- fail - "b" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +== 407 +DROP PUBLICATION testpub6 +-- +STMT: DropStmt +== 408 +DROP TABLE rf_tbl_abcd_pk +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: DropStmt +== 409 +DROP TABLE rf_tbl_abcd_nopk +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: DropStmt +== 410 +DROP TABLE rf_tbl_abcd_part_pk +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: DropStmt +== 411 +-- ====================================================== + +-- Test cache invalidation FOR ALL TABLES publication +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 412 +CREATE TABLE testpub_tbl4(a int) +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DDL +STMT: CreateStmt +== 413 +INSERT INTO testpub_tbl4 values(1) +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 414 +UPDATE testpub_tbl4 set a = 2 +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DML +STMT: UpdateStmt +== 415 +CREATE PUBLICATION testpub_foralltables FOR ALL TABLES +-- +STMT: CreatePublicationStmt +== 416 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 417 +-- fail missing REPLICA IDENTITY +UPDATE testpub_tbl4 set a = 3 +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DML +STMT: UpdateStmt +== 418 +DROP PUBLICATION testpub_foralltables +-- +STMT: DropStmt +== 419 +-- should pass after dropping the publication +UPDATE testpub_tbl4 set a = 3 +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DML +STMT: UpdateStmt +== 420 +DROP TABLE testpub_tbl4 +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DDL +STMT: DropStmt +== 421 +-- fail - view +CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_view +-- +STMT: CreatePublicationStmt +== 422 +CREATE TEMPORARY TABLE testpub_temptbl(a int) +-- +TABLE: name="testpub_temptbl" schema="" table="testpub_temptbl" ctx=DDL +STMT: CreateStmt +== 423 +-- fail - temporary table +CREATE PUBLICATION testpub_fortemptbl FOR TABLE testpub_temptbl +-- +STMT: CreatePublicationStmt +== 424 +DROP TABLE testpub_temptbl +-- +TABLE: name="testpub_temptbl" schema="" table="testpub_temptbl" ctx=DDL +STMT: DropStmt +== 425 +CREATE UNLOGGED TABLE testpub_unloggedtbl(a int) +-- +TABLE: name="testpub_unloggedtbl" schema="" table="testpub_unloggedtbl" ctx=DDL +STMT: CreateStmt +== 426 +-- fail - unlogged table +CREATE PUBLICATION testpub_forunloggedtbl FOR TABLE testpub_unloggedtbl +-- +STMT: CreatePublicationStmt +== 427 +DROP TABLE testpub_unloggedtbl +-- +TABLE: name="testpub_unloggedtbl" schema="" table="testpub_unloggedtbl" ctx=DDL +STMT: DropStmt +== 428 +-- fail - system table +CREATE PUBLICATION testpub_forsystemtbl FOR TABLE pg_publication +-- +STMT: CreatePublicationStmt +== 429 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 430 +CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1, pub_test.testpub_nopk +-- +STMT: CreatePublicationStmt +== 431 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 432 +-- fail - already added +ALTER PUBLICATION testpub_fortbl ADD TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +== 433 +-- fail - already added +CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1 +-- +STMT: CreatePublicationStmt +== 434 +-- fail - view +ALTER PUBLICATION testpub_default ADD TABLE testpub_view +-- +STMT: AlterPublicationStmt +== 435 +ALTER PUBLICATION testpub_default ADD TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +== 436 +ALTER PUBLICATION testpub_default SET TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +== 437 +ALTER PUBLICATION testpub_default ADD TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +== 438 +ALTER PUBLICATION testpib_ins_trunct ADD TABLE pub_test.testpub_nopk, testpub_tbl1 +-- +STMT: AlterPublicationStmt +== 439 +ALTER PUBLICATION testpub_default DROP TABLE testpub_tbl1, pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +== 440 +-- fail - nonexistent +ALTER PUBLICATION testpub_default DROP TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +== 441 +-- verify relation cache invalidation when a primary key is added using +-- an existing index +CREATE TABLE pub_test.testpub_addpk (id int not null, data int) +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DDL +STMT: CreateStmt +== 442 +ALTER PUBLICATION testpub_default ADD TABLE pub_test.testpub_addpk +-- +STMT: AlterPublicationStmt +== 443 +INSERT INTO pub_test.testpub_addpk VALUES(1, 11) +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 444 +CREATE UNIQUE INDEX testpub_addpk_id_idx ON pub_test.testpub_addpk(id) +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DDL +STMT: IndexStmt +== 445 +-- fail: +UPDATE pub_test.testpub_addpk SET id = 2 +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DML +STMT: UpdateStmt +== 446 +ALTER TABLE pub_test.testpub_addpk ADD PRIMARY KEY USING INDEX testpub_addpk_id_idx +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DDL +STMT: AlterTableStmt +== 447 +-- now it should work: +UPDATE pub_test.testpub_addpk SET id = 2 +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DML +STMT: UpdateStmt +== 448 +DROP TABLE pub_test.testpub_addpk +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DDL +STMT: DropStmt +== 449 +-- permissions +SET ROLE regress_publication_user2 +-- +STMT: VariableSetStmt +== 450 +CREATE PUBLICATION testpub2 +-- +STMT: CreatePublicationStmt +== 451 +-- fail + +SET ROLE regress_publication_user +-- +STMT: VariableSetStmt +== 452 +GRANT CREATE ON DATABASE regression TO regress_publication_user2 +-- +STMT: GrantStmt +== 453 +SET ROLE regress_publication_user2 +-- +STMT: VariableSetStmt +== 454 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 455 +CREATE PUBLICATION testpub2 +-- +STMT: CreatePublicationStmt +== 456 +-- ok +CREATE PUBLICATION testpub3 FOR TABLES IN SCHEMA pub_test +-- +STMT: CreatePublicationStmt +== 457 +-- fail +CREATE PUBLICATION testpub3 +-- +STMT: CreatePublicationStmt +== 458 +-- ok +RESET client_min_messages +-- +STMT: VariableSetStmt +== 459 +ALTER PUBLICATION testpub2 ADD TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +== 460 +-- fail +ALTER PUBLICATION testpub3 ADD TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +== 461 +-- fail + +SET ROLE regress_publication_user +-- +STMT: VariableSetStmt +== 462 +GRANT regress_publication_user TO regress_publication_user2 +-- +STMT: GrantRoleStmt +== 463 +SET ROLE regress_publication_user2 +-- +STMT: VariableSetStmt +== 464 +ALTER PUBLICATION testpub2 ADD TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +== 465 +-- ok + +DROP PUBLICATION testpub2 +-- +STMT: DropStmt +== 466 +DROP PUBLICATION testpub3 +-- +STMT: DropStmt +== 467 +SET ROLE regress_publication_user +-- +STMT: VariableSetStmt +== 468 +CREATE ROLE regress_publication_user3 +-- +STMT: CreateRoleStmt +== 469 +GRANT regress_publication_user2 TO regress_publication_user3 +-- +STMT: GrantRoleStmt +== 470 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 471 +CREATE PUBLICATION testpub4 FOR TABLES IN SCHEMA pub_test +-- +STMT: CreatePublicationStmt +== 472 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 473 +ALTER PUBLICATION testpub4 OWNER TO regress_publication_user3 +-- +STMT: AlterOwnerStmt +== 474 +SET ROLE regress_publication_user3 +-- +STMT: VariableSetStmt +== 475 +-- fail - new owner must be superuser +ALTER PUBLICATION testpub4 owner to regress_publication_user2 +-- +STMT: AlterOwnerStmt +== 476 +-- fail +ALTER PUBLICATION testpub4 owner to regress_publication_user +-- +STMT: AlterOwnerStmt +== 477 +-- ok + +SET ROLE regress_publication_user +-- +STMT: VariableSetStmt +== 478 +DROP PUBLICATION testpub4 +-- +STMT: DropStmt +== 479 +DROP ROLE regress_publication_user3 +-- +STMT: DropRoleStmt +== 480 +REVOKE CREATE ON DATABASE regression FROM regress_publication_user2 +-- +STMT: GrantStmt +== 481 +DROP TABLE testpub_parted +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: DropStmt +== 482 +DROP TABLE testpub_tbl1 +-- +TABLE: name="testpub_tbl1" schema="" table="testpub_tbl1" ctx=DDL +STMT: DropStmt +== 483 +-- fail - must be owner of publication +SET ROLE regress_publication_user_dummy +-- +STMT: VariableSetStmt +== 484 +ALTER PUBLICATION testpub_default RENAME TO testpub_dummy +-- +STMT: RenameStmt +== 485 +RESET ROLE +-- +STMT: VariableSetStmt +== 486 +ALTER PUBLICATION testpub_default RENAME TO testpub_foo +-- +STMT: RenameStmt +== 487 +-- rename back to keep the rest simple +ALTER PUBLICATION testpub_foo RENAME TO testpub_default +-- +STMT: RenameStmt +== 488 +ALTER PUBLICATION testpub_default OWNER TO regress_publication_user2 +-- +STMT: AlterOwnerStmt +== 489 +-- adding schemas and tables +CREATE SCHEMA pub_test1 +-- +STMT: CreateSchemaStmt +== 490 +CREATE SCHEMA pub_test2 +-- +STMT: CreateSchemaStmt +== 491 +CREATE SCHEMA pub_test3 +-- +STMT: CreateSchemaStmt +== 492 +CREATE SCHEMA "CURRENT_SCHEMA" +-- +STMT: CreateSchemaStmt +== 493 +CREATE TABLE pub_test1.tbl (id int, data text) +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DDL +STMT: CreateStmt +== 494 +CREATE TABLE pub_test1.tbl1 (id serial primary key, data text) +-- +TABLE: name="pub_test1.tbl1" schema="pub_test1" table="tbl1" ctx=DDL +STMT: CreateStmt +== 495 +CREATE TABLE pub_test2.tbl1 (id serial primary key, data text) +-- +TABLE: name="pub_test2.tbl1" schema="pub_test2" table="tbl1" ctx=DDL +STMT: CreateStmt +== 496 +CREATE TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA"(id int) +-- +TABLE: name="\"CURRENT_SCHEMA\".\"CURRENT_SCHEMA\"" schema="CURRENT_SCHEMA" table="CURRENT_SCHEMA" ctx=DDL +STMT: CreateStmt +== 497 +-- suppress warning that depends on wal_level +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 498 +CREATE PUBLICATION testpub1_forschema FOR TABLES IN SCHEMA pub_test1 +-- +STMT: CreatePublicationStmt +== 499 +CREATE PUBLICATION testpub2_forschema FOR TABLES IN SCHEMA pub_test1, pub_test2, pub_test3 +-- +STMT: CreatePublicationStmt +== 500 +-- check create publication on CURRENT_SCHEMA +CREATE PUBLICATION testpub3_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA +-- +STMT: CreatePublicationStmt +== 501 +CREATE PUBLICATION testpub4_forschema FOR TABLES IN SCHEMA "CURRENT_SCHEMA" +-- +STMT: CreatePublicationStmt +== 502 +CREATE PUBLICATION testpub5_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA, "CURRENT_SCHEMA" +-- +STMT: CreatePublicationStmt +== 503 +CREATE PUBLICATION testpub6_forschema FOR TABLES IN SCHEMA "CURRENT_SCHEMA", CURRENT_SCHEMA +-- +STMT: CreatePublicationStmt +== 504 +CREATE PUBLICATION testpub_fortable FOR TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA" +-- +STMT: CreatePublicationStmt +== 505 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 506 +-- check create publication on CURRENT_SCHEMA where search_path is not set +SET SEARCH_PATH='' +-- +STMT: VariableSetStmt +== 507 +CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA +-- +STMT: CreatePublicationStmt +== 508 +RESET SEARCH_PATH +-- +STMT: VariableSetStmt +== 509 +-- check create publication on CURRENT_SCHEMA where TABLE/TABLES in SCHEMA +-- is not specified +CREATE PUBLICATION testpub_forschema1 FOR CURRENT_SCHEMA +-- +ERROR: invalid publication object list +CURSORPOS: 138 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 510 +-- check create publication on CURRENT_SCHEMA along with FOR TABLE +CREATE PUBLICATION testpub_forschema1 FOR TABLE CURRENT_SCHEMA +-- +ERROR: syntax error at or near "CURRENT_SCHEMA" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 511 +-- check create publication on a schema that does not exist +CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA non_existent_schema +-- +STMT: CreatePublicationStmt +== 512 +-- check create publication on a system schema +CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pg_catalog +-- +STMT: CreatePublicationStmt +== 513 +-- check create publication on an object which is not schema +CREATE PUBLICATION testpub1_forschema1 FOR TABLES IN SCHEMA testpub_view +-- +STMT: CreatePublicationStmt +== 514 +-- dropping the schema should reflect the change in publication +DROP SCHEMA pub_test3 +-- +STMT: DropStmt +== 515 +-- renaming the schema should reflect the change in publication +ALTER SCHEMA pub_test1 RENAME to pub_test1_renamed +-- +STMT: RenameStmt +== 516 +ALTER SCHEMA pub_test1_renamed RENAME to pub_test1 +-- +STMT: RenameStmt +== 517 +-- alter publication add schema +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test2 +-- +STMT: AlterPublicationStmt +== 518 +-- add non existent schema +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA non_existent_schema +-- +STMT: AlterPublicationStmt +== 519 +-- add a schema which is already added to the publication +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +== 520 +-- alter publication drop schema +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2 +-- +STMT: AlterPublicationStmt +== 521 +-- drop schema that is not present in the publication +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2 +-- +STMT: AlterPublicationStmt +== 522 +-- drop a schema that does not exist in the system +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA non_existent_schema +-- +STMT: AlterPublicationStmt +== 523 +-- drop all schemas +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +== 524 +-- alter publication set multiple schema +ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test2 +-- +STMT: AlterPublicationStmt +== 525 +-- alter publication set non-existent schema +ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA non_existent_schema +-- +STMT: AlterPublicationStmt +== 526 +-- alter publication set it duplicate schemas should set the schemas after +-- removing the duplicate schemas +ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test1 +-- +STMT: AlterPublicationStmt +== 527 +-- Verify that it fails to add a schema with a column specification +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA foo (a, b) +-- +ERROR: syntax error at or near "(" +CURSORPOS: 131 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 528 +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA foo, bar (a, b) +-- +ERROR: column specification not allowed for schema +CURSORPOS: 64 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 529 +-- cleanup pub_test1 schema for invalidation tests +ALTER PUBLICATION testpub2_forschema DROP TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +== 530 +DROP PUBLICATION testpub3_forschema, testpub4_forschema, testpub5_forschema, testpub6_forschema, testpub_fortable +-- +STMT: DropStmt +== 531 +DROP SCHEMA "CURRENT_SCHEMA" CASCADE +-- +STMT: DropStmt +== 532 +-- verify relation cache invalidations through update statement for the +-- default REPLICA IDENTITY on the relation, if schema is part of the +-- publication then update will fail because relation's relreplident +-- option will be set, if schema is not part of the publication then update +-- will be successful. +INSERT INTO pub_test1.tbl VALUES(1, 'test') +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 533 +-- fail +UPDATE pub_test1.tbl SET id = 2 +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DML +STMT: UpdateStmt +== 534 +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +== 535 +-- success +UPDATE pub_test1.tbl SET id = 2 +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DML +STMT: UpdateStmt +== 536 +ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +== 537 +-- fail +UPDATE pub_test1.tbl SET id = 2 +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DML +STMT: UpdateStmt +== 538 +-- verify invalidation of partition table having parent and child tables in +-- different schema +CREATE SCHEMA pub_testpart1 +-- +STMT: CreateSchemaStmt +== 539 +CREATE SCHEMA pub_testpart2 +-- +STMT: CreateSchemaStmt +== 540 +CREATE TABLE pub_testpart1.parent1 (a int) partition by list (a) +-- +TABLE: name="pub_testpart1.parent1" schema="pub_testpart1" table="parent1" ctx=DDL +STMT: CreateStmt +== 541 +CREATE TABLE pub_testpart2.child_parent1 partition of pub_testpart1.parent1 for values in (1) +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DDL +STMT: CreateStmt +== 542 +INSERT INTO pub_testpart2.child_parent1 values(1) +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 543 +UPDATE pub_testpart2.child_parent1 set a = 1 +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DML +STMT: UpdateStmt +== 544 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 545 +CREATE PUBLICATION testpubpart_forschema FOR TABLES IN SCHEMA pub_testpart1 +-- +STMT: CreatePublicationStmt +== 546 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 547 +-- fail +UPDATE pub_testpart1.parent1 set a = 1 +-- +TABLE: name="pub_testpart1.parent1" schema="pub_testpart1" table="parent1" ctx=DML +STMT: UpdateStmt +== 548 +UPDATE pub_testpart2.child_parent1 set a = 1 +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DML +STMT: UpdateStmt +== 549 +DROP PUBLICATION testpubpart_forschema +-- +STMT: DropStmt +== 550 +-- verify invalidation of partition tables for schema publication that has +-- parent and child tables of different partition hierarchies +CREATE TABLE pub_testpart2.parent2 (a int) partition by list (a) +-- +TABLE: name="pub_testpart2.parent2" schema="pub_testpart2" table="parent2" ctx=DDL +STMT: CreateStmt +== 551 +CREATE TABLE pub_testpart1.child_parent2 partition of pub_testpart2.parent2 for values in (1) +-- +TABLE: name="pub_testpart1.child_parent2" schema="pub_testpart1" table="child_parent2" ctx=DDL +STMT: CreateStmt +== 552 +INSERT INTO pub_testpart1.child_parent2 values(1) +-- +TABLE: name="pub_testpart1.child_parent2" schema="pub_testpart1" table="child_parent2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 553 +UPDATE pub_testpart1.child_parent2 set a = 1 +-- +TABLE: name="pub_testpart1.child_parent2" schema="pub_testpart1" table="child_parent2" ctx=DML +STMT: UpdateStmt +== 554 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 555 +CREATE PUBLICATION testpubpart_forschema FOR TABLES IN SCHEMA pub_testpart2 +-- +STMT: CreatePublicationStmt +== 556 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 557 +-- fail +UPDATE pub_testpart2.child_parent1 set a = 1 +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DML +STMT: UpdateStmt +== 558 +UPDATE pub_testpart2.parent2 set a = 1 +-- +TABLE: name="pub_testpart2.parent2" schema="pub_testpart2" table="parent2" ctx=DML +STMT: UpdateStmt +== 559 +UPDATE pub_testpart1.child_parent2 set a = 1 +-- +TABLE: name="pub_testpart1.child_parent2" schema="pub_testpart1" table="child_parent2" ctx=DML +STMT: UpdateStmt +== 560 +-- alter publication set 'TABLES IN SCHEMA' on an empty publication. +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 561 +CREATE PUBLICATION testpub3_forschema +-- +STMT: CreatePublicationStmt +== 562 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 563 +ALTER PUBLICATION testpub3_forschema SET TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +== 564 +-- create publication including both 'FOR TABLE' and 'FOR TABLES IN SCHEMA' +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 565 +CREATE PUBLICATION testpub_forschema_fortable FOR TABLES IN SCHEMA pub_test1, TABLE pub_test2.tbl1 +-- +STMT: CreatePublicationStmt +== 566 +CREATE PUBLICATION testpub_fortable_forschema FOR TABLE pub_test2.tbl1, TABLES IN SCHEMA pub_test1 +-- +STMT: CreatePublicationStmt +== 567 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 568 +-- fail specifying table without any of 'FOR TABLES IN SCHEMA' or +--'FOR TABLE' or 'FOR ALL TABLES' +CREATE PUBLICATION testpub_error FOR pub_test2.tbl1 +-- +ERROR: invalid publication object list +CURSORPOS: 138 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 569 +DROP VIEW testpub_view +-- +STMT: DropStmt +== 570 +DROP PUBLICATION testpub_default +-- +STMT: DropStmt +== 571 +DROP PUBLICATION testpib_ins_trunct +-- +STMT: DropStmt +== 572 +DROP PUBLICATION testpub_fortbl +-- +STMT: DropStmt +== 573 +DROP PUBLICATION testpub1_forschema +-- +STMT: DropStmt +== 574 +DROP PUBLICATION testpub2_forschema +-- +STMT: DropStmt +== 575 +DROP PUBLICATION testpub3_forschema +-- +STMT: DropStmt +== 576 +DROP PUBLICATION testpub_forschema_fortable +-- +STMT: DropStmt +== 577 +DROP PUBLICATION testpub_fortable_forschema +-- +STMT: DropStmt +== 578 +DROP PUBLICATION testpubpart_forschema +-- +STMT: DropStmt +== 579 +DROP SCHEMA pub_test CASCADE +-- +STMT: DropStmt +== 580 +DROP SCHEMA pub_test1 CASCADE +-- +STMT: DropStmt +== 581 +DROP SCHEMA pub_test2 CASCADE +-- +STMT: DropStmt +== 582 +DROP SCHEMA pub_testpart1 CASCADE +-- +STMT: DropStmt +== 583 +DROP SCHEMA pub_testpart2 CASCADE +-- +STMT: DropStmt +== 584 +-- Test the list of partitions published with or without +-- 'PUBLISH_VIA_PARTITION_ROOT' parameter +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 585 +CREATE SCHEMA sch1 +-- +STMT: CreateSchemaStmt +== 586 +CREATE SCHEMA sch2 +-- +STMT: CreateSchemaStmt +== 587 +CREATE TABLE sch1.tbl1 (a int) PARTITION BY RANGE(a) +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: CreateStmt +== 588 +CREATE TABLE sch2.tbl1_part1 PARTITION OF sch1.tbl1 FOR VALUES FROM (1) to (10) +-- +TABLE: name="sch2.tbl1_part1" schema="sch2" table="tbl1_part1" ctx=DDL +STMT: CreateStmt +== 589 +-- Schema publication that does not include the schema that has the parent table +CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch2 WITH (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: CreatePublicationStmt +== 590 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +== 591 +DROP PUBLICATION pub +-- +STMT: DropStmt +== 592 +-- Table publication that does not include the parent table +CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: CreatePublicationStmt +== 593 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +== 594 +-- Table publication that includes both the parent table and the child table +ALTER PUBLICATION pub ADD TABLE sch1.tbl1 +-- +STMT: AlterPublicationStmt +== 595 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +== 596 +DROP PUBLICATION pub +-- +STMT: DropStmt +== 597 +-- Schema publication that does not include the schema that has the parent table +CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch2 WITH (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: CreatePublicationStmt +== 598 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +== 599 +DROP PUBLICATION pub +-- +STMT: DropStmt +== 600 +-- Table publication that does not include the parent table +CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: CreatePublicationStmt +== 601 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +== 602 +-- Table publication that includes both the parent table and the child table +ALTER PUBLICATION pub ADD TABLE sch1.tbl1 +-- +STMT: AlterPublicationStmt +== 603 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +== 604 +DROP PUBLICATION pub +-- +STMT: DropStmt +== 605 +DROP TABLE sch2.tbl1_part1 +-- +TABLE: name="sch2.tbl1_part1" schema="sch2" table="tbl1_part1" ctx=DDL +STMT: DropStmt +== 606 +DROP TABLE sch1.tbl1 +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: DropStmt +== 607 +CREATE TABLE sch1.tbl1 (a int) PARTITION BY RANGE(a) +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: CreateStmt +== 608 +CREATE TABLE sch1.tbl1_part1 PARTITION OF sch1.tbl1 FOR VALUES FROM (1) to (10) +-- +TABLE: name="sch1.tbl1_part1" schema="sch1" table="tbl1_part1" ctx=DDL +STMT: CreateStmt +== 609 +CREATE TABLE sch1.tbl1_part2 PARTITION OF sch1.tbl1 FOR VALUES FROM (10) to (20) +-- +TABLE: name="sch1.tbl1_part2" schema="sch1" table="tbl1_part2" ctx=DDL +STMT: CreateStmt +== 610 +CREATE TABLE sch1.tbl1_part3 (a int) PARTITION BY RANGE(a) +-- +TABLE: name="sch1.tbl1_part3" schema="sch1" table="tbl1_part3" ctx=DDL +STMT: CreateStmt +== 611 +ALTER TABLE sch1.tbl1 ATTACH PARTITION sch1.tbl1_part3 FOR VALUES FROM (20) to (30) +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: AlterTableStmt +== 612 +CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch1 WITH (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: CreatePublicationStmt +== 613 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +== 614 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 615 +DROP PUBLICATION pub +-- +STMT: DropStmt +== 616 +DROP TABLE sch1.tbl1 +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: DropStmt +== 617 +DROP SCHEMA sch1 cascade +-- +STMT: DropStmt +== 618 +DROP SCHEMA sch2 cascade +-- +STMT: DropStmt +== 619 +-- Test that the INSERT ON CONFLICT command correctly checks REPLICA IDENTITY +-- when the target table is published. +CREATE TABLE testpub_insert_onconfl_no_ri (a int unique, b int) +-- +TABLE: name="testpub_insert_onconfl_no_ri" schema="" table="testpub_insert_onconfl_no_ri" ctx=DDL +STMT: CreateStmt +== 620 +CREATE TABLE testpub_insert_onconfl_parted (a int unique, b int) PARTITION by RANGE (a) +-- +TABLE: name="testpub_insert_onconfl_parted" schema="" table="testpub_insert_onconfl_parted" ctx=DDL +STMT: CreateStmt +== 621 +CREATE TABLE testpub_insert_onconfl_part_no_ri PARTITION OF testpub_insert_onconfl_parted FOR VALUES FROM (1) TO (10) +-- +TABLE: name="testpub_insert_onconfl_part_no_ri" schema="" table="testpub_insert_onconfl_part_no_ri" ctx=DDL +STMT: CreateStmt +== 622 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 623 +CREATE PUBLICATION pub1 FOR ALL TABLES +-- +STMT: CreatePublicationStmt +== 624 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 625 +-- fail - missing REPLICA IDENTITY +INSERT INTO testpub_insert_onconfl_no_ri VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = 2 +-- +TABLE: name="testpub_insert_onconfl_no_ri" schema="" table="testpub_insert_onconfl_no_ri" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 626 +-- ok - no updates +INSERT INTO testpub_insert_onconfl_no_ri VALUES (1, 1) ON CONFLICT DO NOTHING +-- +TABLE: name="testpub_insert_onconfl_no_ri" schema="" table="testpub_insert_onconfl_no_ri" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 627 +-- fail - missing REPLICA IDENTITY in partition testpub_insert_onconfl_no_ri +INSERT INTO testpub_insert_onconfl_parted VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = 2 +-- +TABLE: name="testpub_insert_onconfl_parted" schema="" table="testpub_insert_onconfl_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 628 +-- ok - no updates +INSERT INTO testpub_insert_onconfl_parted VALUES (1, 1) ON CONFLICT DO NOTHING +-- +TABLE: name="testpub_insert_onconfl_parted" schema="" table="testpub_insert_onconfl_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 629 +DROP PUBLICATION pub1 +-- +STMT: DropStmt +== 630 +DROP TABLE testpub_insert_onconfl_no_ri +-- +TABLE: name="testpub_insert_onconfl_no_ri" schema="" table="testpub_insert_onconfl_no_ri" ctx=DDL +STMT: DropStmt +== 631 +DROP TABLE testpub_insert_onconfl_parted +-- +TABLE: name="testpub_insert_onconfl_parted" schema="" table="testpub_insert_onconfl_parted" ctx=DDL +STMT: DropStmt +== 632 +-- Test that the MERGE command correctly checks REPLICA IDENTITY when the +-- target table is published. +CREATE TABLE testpub_merge_no_ri (a int, b int) +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DDL +STMT: CreateStmt +== 633 +CREATE TABLE testpub_merge_pk (a int primary key, b int) +-- +TABLE: name="testpub_merge_pk" schema="" table="testpub_merge_pk" ctx=DDL +STMT: CreateStmt +== 634 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 635 +CREATE PUBLICATION pub1 FOR ALL TABLES +-- +STMT: CreatePublicationStmt +== 636 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 637 +-- fail - missing REPLICA IDENTITY +MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 + WHEN MATCHED THEN UPDATE SET b = s.b +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DML +STMT: MergeStmt +== 638 +-- fail - missing REPLICA IDENTITY +MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 + WHEN MATCHED THEN DELETE +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DML +STMT: MergeStmt +== 639 +-- ok - insert and do nothing are not restricted +MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 + WHEN MATCHED THEN DO NOTHING + WHEN NOT MATCHED THEN INSERT (a, b) VALUES (0, 0) +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DML +STMT: MergeStmt +== 640 +-- ok - REPLICA IDENTITY is DEFAULT and table has a PK +MERGE INTO testpub_merge_pk USING testpub_merge_no_ri s ON s.a >= 1 + WHEN MATCHED AND s.a > 0 THEN UPDATE SET b = s.b + WHEN MATCHED THEN DELETE +-- +TABLE: name="testpub_merge_pk" schema="" table="testpub_merge_pk" ctx=DML +STMT: MergeStmt +== 641 +DROP PUBLICATION pub1 +-- +STMT: DropStmt +== 642 +DROP TABLE testpub_merge_no_ri +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DDL +STMT: DropStmt +== 643 +DROP TABLE testpub_merge_pk +-- +TABLE: name="testpub_merge_pk" schema="" table="testpub_merge_pk" ctx=DDL +STMT: DropStmt +== 644 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 645 +DROP ROLE regress_publication_user, regress_publication_user2 +-- +STMT: DropRoleStmt +== 646 +DROP ROLE regress_publication_user_dummy +-- +STMT: DropRoleStmt +== 647 +-- stage objects for pg_dump tests +CREATE SCHEMA pubme CREATE TABLE t0 (c int, d int) CREATE TABLE t1 (c int) +-- +STMT: CreateSchemaStmt +== 648 +CREATE SCHEMA pubme2 CREATE TABLE t0 (c int, d int) +-- +STMT: CreateSchemaStmt +== 649 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +== 650 +CREATE PUBLICATION dump_pub_qual_1ct FOR + TABLE ONLY pubme.t0 (c, d) WHERE (c > 0) +-- +STMT: CreatePublicationStmt +== 651 +CREATE PUBLICATION dump_pub_qual_2ct FOR + TABLE ONLY pubme.t0 (c) WHERE (c > 0), + TABLE ONLY pubme.t1 (c) +-- +STMT: CreatePublicationStmt +== 652 +CREATE PUBLICATION dump_pub_nsp_1ct FOR + TABLES IN SCHEMA pubme +-- +STMT: CreatePublicationStmt +== 653 +CREATE PUBLICATION dump_pub_nsp_2ct FOR + TABLES IN SCHEMA pubme, + TABLES IN SCHEMA pubme2 +-- +STMT: CreatePublicationStmt +== 654 +CREATE PUBLICATION dump_pub_all FOR + TABLE ONLY pubme.t0, + TABLE ONLY pubme.t1 WHERE (c < 0), + TABLES IN SCHEMA pubme, + TABLES IN SCHEMA pubme2 + WITH (publish_via_partition_root = true) +-- +STMT: CreatePublicationStmt +== 655 +RESET client_min_messages +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/random.metadata.json b/parser/testdata/summary/postgres_regress/random.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/random.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/random.test b/parser/testdata/summary/postgres_regress/random.test new file mode 100644 index 0000000..54ec12c --- /dev/null +++ b/parser/testdata/summary/postgres_regress/random.test @@ -0,0 +1,514 @@ +== 001 +|-- +-- RANDOM +-- Test random() and allies +|-- +-- Tests in this file may have a small probability of failure, +-- since we are dealing with randomness. Try to keep the failure +-- risk for any one test case under 1e-9. +|-- + +-- There should be no duplicates in 1000 random() values. +-- (Assuming 52 random bits in the float8 results, we could +-- take as many as 3000 values and still have less than 1e-9 chance +-- of failure, per https://en.wikipedia.org/wiki/Birthday_problem) +SELECT r, count(*) +FROM (SELECT random() r FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 002 +-- The range should be [0, 1). We can expect that at least one out of 2000 +-- random values is in the lowest or highest 1% of the range with failure +-- probability less than about 1e-9. + +SELECT count(*) FILTER (WHERE r < 0 OR r >= 1) AS out_of_range, + (count(*) FILTER (WHERE r < 0.01)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 0.99)) > 0 AS has_large +FROM (SELECT random() r FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 003 +-- Check for uniform distribution using the Kolmogorov-Smirnov test. + +CREATE FUNCTION ks_test_uniform_random() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random() r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs(i/n-r)) < c / sqrt(n) FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_uniform_random" function="ks_test_uniform_random" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 004 +-- As written, ks_test_uniform_random() returns true about 99.9% +-- of the time. To get down to a roughly 1e-9 test failure rate, +-- just run it 3 times and accept if any one of them passes. +SELECT ks_test_uniform_random() OR + ks_test_uniform_random() OR + ks_test_uniform_random() AS uniform +-- +FUNCTION: name="ks_test_uniform_random" function="ks_test_uniform_random" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random" function="ks_test_uniform_random" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random" function="ks_test_uniform_random" schema="" ctx=Call +STMT: SelectStmt +== 005 +-- now test random_normal() + +-- As above, there should be no duplicates in 1000 random_normal() values. +SELECT r, count(*) +FROM (SELECT random_normal() r FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 006 +-- ... unless we force the range (standard deviation) to zero. +-- This is a good place to check that the mean input does something, too. +SELECT r, count(*) +FROM (SELECT random_normal(10, 0) r FROM generate_series(1, 100)) ss +GROUP BY r +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT r, count(*) +FROM (SELECT random_normal(-10, 0) r FROM generate_series(1, 100)) ss +GROUP BY r +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- Check standard normal distribution using the Kolmogorov-Smirnov test. + +CREATE FUNCTION ks_test_normal_random() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random_normal() r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs((1+erf(r/sqrt(2)))/2 - i/n)) < c / sqrt(n) + FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_normal_random" function="ks_test_normal_random" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 009 +-- As above, ks_test_normal_random() returns true about 99.9% +-- of the time, so try it 3 times and accept if any test passes. +SELECT ks_test_normal_random() OR + ks_test_normal_random() OR + ks_test_normal_random() AS standard_normal +-- +FUNCTION: name="ks_test_normal_random" function="ks_test_normal_random" schema="" ctx=Call +FUNCTION: name="ks_test_normal_random" function="ks_test_normal_random" schema="" ctx=Call +FUNCTION: name="ks_test_normal_random" function="ks_test_normal_random" schema="" ctx=Call +STMT: SelectStmt +== 010 +-- Test random(min, max) + +-- invalid range bounds +SELECT random(1, 0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT random(1000000000001, 1000000000000) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT random(-2.0, -3.0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT random('NaN'::numeric, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT random('-Inf'::numeric, 0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT random(0, 'NaN'::numeric) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT random(0, 'Inf'::numeric) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- empty range is OK +SELECT random(101, 101) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT random(1000000000001, 1000000000001) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT random(3.14, 3.14) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 020 +-- There should be no triple duplicates in 1000 full-range 32-bit random() +-- values. (Each of the C(1000, 3) choices of triplets from the 1000 values +-- has a probability of 1/(2^32)^2 of being a triple duplicate, so the +-- average number of triple duplicates is 1000 * 999 * 998 / 6 / 2^64, which +-- is roughly 9e-12.) +SELECT r, count(*) +FROM (SELECT random(-2147483648, 2147483647) r + FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 2 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 021 +-- There should be no duplicates in 1000 full-range 64-bit random() values. +SELECT r, count(*) +FROM (SELECT random_normal(-9223372036854775808, 9223372036854775807) r + FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- There should be no duplicates in 1000 15-digit random() numeric values. +SELECT r, count(*) +FROM (SELECT random_normal(0, 1 - 1e-15) r + FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 023 +-- Expect at least one out of 2000 random values to be in the lowest and +-- highest 1% of the range. +SELECT (count(*) FILTER (WHERE r < -2104533975)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 2104533974)) > 0 AS has_large +FROM (SELECT random(-2147483648, 2147483647) r FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT count(*) FILTER (WHERE r < -1500000000 OR r > 1500000000) AS out_of_range, + (count(*) FILTER (WHERE r < -1470000000)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 1470000000)) > 0 AS has_large +FROM (SELECT random(-1500000000, 1500000000) r FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT (count(*) FILTER (WHERE r < -9038904596117680292)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 9038904596117680291)) > 0 AS has_large +FROM (SELECT random(-9223372036854775808, 9223372036854775807) r + FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 026 +SELECT count(*) FILTER (WHERE r < -1500000000000000 OR r > 1500000000000000) AS out_of_range, + (count(*) FILTER (WHERE r < -1470000000000000)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 1470000000000000)) > 0 AS has_large +FROM (SELECT random(-1500000000000000, 1500000000000000) r + FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT count(*) FILTER (WHERE r < -1.5 OR r > 1.5) AS out_of_range, + (count(*) FILTER (WHERE r < -1.47)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 1.47)) > 0 AS has_large +FROM (SELECT random(-1.500000000000000, 1.500000000000000) r + FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 028 +-- Every possible value should occur at least once in 2500 random() values +-- chosen from a range with 100 distinct values. +SELECT min(r), max(r), count(r) FROM ( + SELECT DISTINCT random(-50, 49) r FROM generate_series(1, 2500)) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT min(r), max(r), count(r) FROM ( + SELECT DISTINCT random(123000000000, 123000000099) r + FROM generate_series(1, 2500)) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT min(r), max(r), count(r) FROM ( + SELECT DISTINCT random(-0.5, 0.49) r FROM generate_series(1, 2500)) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- Check for uniform distribution using the Kolmogorov-Smirnov test. + +CREATE FUNCTION ks_test_uniform_random_int_in_range() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random(0, 999999) / 1000000.0 r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs(i/n-r)) < c / sqrt(n) FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_uniform_random_int_in_range" function="ks_test_uniform_random_int_in_range" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 032 +SELECT ks_test_uniform_random_int_in_range() OR + ks_test_uniform_random_int_in_range() OR + ks_test_uniform_random_int_in_range() AS uniform_int +-- +FUNCTION: name="ks_test_uniform_random_int_in_range" function="ks_test_uniform_random_int_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_int_in_range" function="ks_test_uniform_random_int_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_int_in_range" function="ks_test_uniform_random_int_in_range" schema="" ctx=Call +STMT: SelectStmt +== 033 +CREATE FUNCTION ks_test_uniform_random_bigint_in_range() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random(0, 999999999999) / 1000000000000.0 r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs(i/n-r)) < c / sqrt(n) FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_uniform_random_bigint_in_range" function="ks_test_uniform_random_bigint_in_range" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 034 +SELECT ks_test_uniform_random_bigint_in_range() OR + ks_test_uniform_random_bigint_in_range() OR + ks_test_uniform_random_bigint_in_range() AS uniform_bigint +-- +FUNCTION: name="ks_test_uniform_random_bigint_in_range" function="ks_test_uniform_random_bigint_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_bigint_in_range" function="ks_test_uniform_random_bigint_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_bigint_in_range" function="ks_test_uniform_random_bigint_in_range" schema="" ctx=Call +STMT: SelectStmt +== 035 +CREATE FUNCTION ks_test_uniform_random_numeric_in_range() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random(0, 0.999999) r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs(i/n-r)) < c / sqrt(n) FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_uniform_random_numeric_in_range" function="ks_test_uniform_random_numeric_in_range" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 036 +SELECT ks_test_uniform_random_numeric_in_range() OR + ks_test_uniform_random_numeric_in_range() OR + ks_test_uniform_random_numeric_in_range() AS uniform_numeric +-- +FUNCTION: name="ks_test_uniform_random_numeric_in_range" function="ks_test_uniform_random_numeric_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_numeric_in_range" function="ks_test_uniform_random_numeric_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_numeric_in_range" function="ks_test_uniform_random_numeric_in_range" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- setseed() should produce a reproducible series of random() values. + +SELECT setseed(0.5) +-- +FUNCTION: name="setseed" function="setseed" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT random() FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 039 +-- Likewise for random_normal(); however, since its implementation relies +-- on libm functions that have different roundoff behaviors on different +-- machines, we have to round off the results a bit to get consistent output. +SET extra_float_digits = -1 +-- +STMT: VariableSetStmt +== 040 +SELECT random_normal() FROM generate_series(1, 10) +-- +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 041 +SELECT random_normal(mean => 1, stddev => 0.1) r FROM generate_series(1, 10) +-- +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 042 +-- Reproducible random(min, max) values. +SELECT random(1, 6) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT random(-2147483648, 2147483647) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT random(-9223372036854775808, 9223372036854775807) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 045 +SELECT random(-1e30, 1e30) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 046 +SELECT random(-0.4, 0.4) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 047 +SELECT random(0, 1 - 1e-30) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT n, random(0, trim_scale(abs(1 - 10.0^(-n)))) FROM generate_series(-20, 20) n +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/rangefuncs.metadata.json b/parser/testdata/summary/postgres_regress/rangefuncs.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rangefuncs.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/rangefuncs.test b/parser/testdata/summary/postgres_regress/rangefuncs.test new file mode 100644 index 0000000..ed54bac --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rangefuncs.test @@ -0,0 +1,2557 @@ +== 001 +CREATE TABLE rngfunc2(rngfuncid int, f2 int) +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO rngfunc2 VALUES(1, 11) +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO rngfunc2 VALUES(2, 22) +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO rngfunc2 VALUES(1, 111) +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQL +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +-- function with ORDINALITY +select * from rngfunct(1) with ordinality as z(a,b,ord) +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: SelectStmt +== 007 +select * from rngfunct(1) with ordinality as z(a,b,ord) where b > 100 +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 008 +-- ordinal 2, not 1 +-- ordinality vs. column names and types +select a,b,ord from rngfunct(1) with ordinality as z(a,b,ord) +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: SelectStmt +== 009 +select a,ord from unnest(array['a','b']) with ordinality as z(a,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 010 +select * from unnest(array['a','b']) with ordinality as z(a,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 011 +select a,ord from unnest(array[1.0::float8]) with ordinality as z(a,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 012 +select * from unnest(array[1.0::float8]) with ordinality as z(a,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 013 +select row_to_json(s.*) from generate_series(11,14) with ordinality s +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- ordinality vs. views +create temporary view vw_ord as select * from (values (1)) v(n) join rngfunct(1) with ordinality as z(a,b,ord) on (n=ord) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 015 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +== 016 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +== 017 +drop view vw_ord +-- +STMT: DropStmt +== 018 +-- multiple functions +select * from rows from(rngfunct(1),rngfunct(2)) with ordinality as z(a,b,c,d,ord) +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: SelectStmt +== 019 +create temporary view vw_ord as select * from (values (1)) v(n) join rows from(rngfunct(1),rngfunct(2)) with ordinality as z(a,b,c,d,ord) on (n=ord) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 020 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +== 021 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +== 022 +drop view vw_ord +-- +STMT: DropStmt +== 023 +-- expansions of unnest() +select * from unnest(array[10,20],array['foo','bar'],array[1.0]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 024 +select * from unnest(array[10,20],array['foo','bar'],array[1.0]) with ordinality as z(a,b,c,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 025 +select * from rows from(unnest(array[10,20],array['foo','bar'],array[1.0])) with ordinality as z(a,b,c,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 026 +select * from rows from(unnest(array[10,20],array['foo','bar']), generate_series(101,102)) with ordinality as z(a,b,c,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 027 +create temporary view vw_ord as select * from unnest(array[10,20],array['foo','bar'],array[1.0]) as z(a,b,c) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 028 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +== 029 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +== 030 +drop view vw_ord +-- +STMT: DropStmt +== 031 +create temporary view vw_ord as select * from rows from(unnest(array[10,20],array['foo','bar'],array[1.0])) as z(a,b,c) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 032 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +== 033 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +== 034 +drop view vw_ord +-- +STMT: DropStmt +== 035 +create temporary view vw_ord as select * from rows from(unnest(array[10,20],array['foo','bar']), generate_series(1,2)) as z(a,b,c) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 036 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +== 037 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +== 038 +drop view vw_ord +-- +STMT: DropStmt +== 039 +-- ordinality and multiple functions vs. rewind and reverse scan +begin +-- +STMT: TransactionStmt +== 040 +declare rf_cur scroll cursor for select * from rows from(generate_series(1,5),generate_series(1,2)) with ordinality as g(i,j,o) +-- +STMT: DeclareCursorStmt +== 041 +fetch all from rf_cur +-- +STMT: FetchStmt +== 042 +fetch backward all from rf_cur +-- +STMT: FetchStmt +== 043 +fetch all from rf_cur +-- +STMT: FetchStmt +== 044 +fetch next from rf_cur +-- +STMT: FetchStmt +== 045 +fetch next from rf_cur +-- +STMT: FetchStmt +== 046 +fetch prior from rf_cur +-- +STMT: FetchStmt +== 047 +fetch absolute 1 from rf_cur +-- +STMT: FetchStmt +== 048 +fetch next from rf_cur +-- +STMT: FetchStmt +== 049 +fetch next from rf_cur +-- +STMT: FetchStmt +== 050 +fetch next from rf_cur +-- +STMT: FetchStmt +== 051 +fetch prior from rf_cur +-- +STMT: FetchStmt +== 052 +fetch prior from rf_cur +-- +STMT: FetchStmt +== 053 +fetch prior from rf_cur +-- +STMT: FetchStmt +== 054 +commit +-- +STMT: TransactionStmt +== 055 +-- function with implicit LATERAL +select * from rngfunc2, rngfunct(rngfunc2.rngfuncid) z where rngfunc2.f2 = z.f2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="rngfunc2" column="f2" +FILTER: schema="" table="z" column="f2" +STMT: SelectStmt +== 056 +-- function with implicit LATERAL and explicit ORDINALITY +select * from rngfunc2, rngfunct(rngfunc2.rngfuncid) with ordinality as z(rngfuncid,f2,ord) where rngfunc2.f2 = z.f2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="rngfunc2" column="f2" +FILTER: schema="" table="z" column="f2" +STMT: SelectStmt +== 057 +-- function in subselect +select * from rngfunc2 where f2 in (select f2 from rngfunct(rngfunc2.rngfuncid) z where z.rngfuncid = rngfunc2.rngfuncid) ORDER BY 1,2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="z" column="rngfuncid" +FILTER: schema="" table="rngfunc2" column="rngfuncid" +STMT: SelectStmt +== 058 +-- function in subselect +select * from rngfunc2 where f2 in (select f2 from rngfunct(1) z where z.rngfuncid = rngfunc2.rngfuncid) ORDER BY 1,2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="z" column="rngfuncid" +FILTER: schema="" table="rngfunc2" column="rngfuncid" +STMT: SelectStmt +== 059 +-- function in subselect +select * from rngfunc2 where f2 in (select f2 from rngfunct(rngfunc2.rngfuncid) z where z.rngfuncid = 1) ORDER BY 1,2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="z" column="rngfuncid" +STMT: SelectStmt +== 060 +-- nested functions +select rngfunct.rngfuncid, rngfunct.f2 from rngfunct(sin(pi()/2)::int) ORDER BY 1,2 +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FUNCTION: name="sin" function="sin" schema="" ctx=Call +FUNCTION: name="pi" function="pi" schema="" ctx=Call +STMT: SelectStmt +== 061 +CREATE TABLE rngfunc (rngfuncid int, rngfuncsubid int, rngfuncname text, primary key(rngfuncid,rngfuncsubid)) +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DDL +STMT: CreateStmt +== 062 +INSERT INTO rngfunc VALUES(1,1,'Joe') +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +INSERT INTO rngfunc VALUES(1,2,'Ed') +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +INSERT INTO rngfunc VALUES(2,1,'Mary') +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +-- sql, proretset = f, prorettype = b +CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 066 +SELECT * FROM getrngfunc1(1) AS t1 +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT * FROM getrngfunc1(1) WITH ORDINALITY AS t1(v,o) +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: SelectStmt +== 068 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 069 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 070 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 071 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1) WITH ORDINALITY as t1(v,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 072 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 073 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 074 +-- sql, proretset = t, prorettype = b +CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 075 +SELECT * FROM getrngfunc2(1) AS t1 +-- +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT * FROM getrngfunc2(1) WITH ORDINALITY AS t1(v,o) +-- +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +STMT: SelectStmt +== 077 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 078 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 079 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 080 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1) WITH ORDINALITY AS t1(v,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 081 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 082 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 083 +-- sql, proretset = t, prorettype = b +CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 084 +SELECT * FROM getrngfunc3(1) AS t1 +-- +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +STMT: SelectStmt +== 085 +SELECT * FROM getrngfunc3(1) WITH ORDINALITY AS t1(v,o) +-- +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +STMT: SelectStmt +== 086 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 087 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 088 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 089 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1) WITH ORDINALITY AS t1(v,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 090 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 091 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 092 +-- sql, proretset = f, prorettype = c +CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 093 +SELECT * FROM getrngfunc4(1) AS t1 +-- +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +STMT: SelectStmt +== 094 +SELECT * FROM getrngfunc4(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +STMT: SelectStmt +== 095 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 096 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 097 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 098 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 099 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 101 +-- sql, proretset = t, prorettype = c +CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 102 +SELECT * FROM getrngfunc5(1) AS t1 +-- +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +STMT: SelectStmt +== 103 +SELECT * FROM getrngfunc5(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +STMT: SelectStmt +== 104 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 105 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 106 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 107 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 108 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 109 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 110 +-- sql, proretset = f, prorettype = record +CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 111 +SELECT * FROM getrngfunc6(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text) +-- +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +STMT: SelectStmt +== 112 +SELECT * FROM ROWS FROM( getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY +-- +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +STMT: SelectStmt +== 113 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc6(1) AS +(rngfuncid int, rngfuncsubid int, rngfuncname text) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 114 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 115 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 116 +CREATE VIEW vw_getrngfunc AS + SELECT * FROM ROWS FROM( getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) + WITH ORDINALITY +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 117 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 118 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 119 +-- sql, proretset = t, prorettype = record +CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 120 +SELECT * FROM getrngfunc7(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text) +-- +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +STMT: SelectStmt +== 121 +SELECT * FROM ROWS FROM( getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY +-- +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +STMT: SelectStmt +== 122 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc7(1) AS +(rngfuncid int, rngfuncsubid int, rngfuncname text) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 123 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 124 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 125 +CREATE VIEW vw_getrngfunc AS + SELECT * FROM ROWS FROM( getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) + WITH ORDINALITY +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 126 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 127 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 128 +-- plpgsql, proretset = f, prorettype = b +CREATE FUNCTION getrngfunc8(int) RETURNS int AS 'DECLARE rngfuncint int; BEGIN SELECT rngfuncid into rngfuncint FROM rngfunc WHERE rngfuncid = $1; RETURN rngfuncint; END;' LANGUAGE plpgsql +-- +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 129 +SELECT * FROM getrngfunc8(1) AS t1 +-- +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +STMT: SelectStmt +== 130 +SELECT * FROM getrngfunc8(1) WITH ORDINALITY AS t1(v,o) +-- +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +STMT: SelectStmt +== 131 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc8(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 132 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 133 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 134 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc8(1) WITH ORDINALITY AS t1(v,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 135 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 136 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 137 +-- plpgsql, proretset = f, prorettype = c +CREATE FUNCTION getrngfunc9(int) RETURNS rngfunc AS 'DECLARE rngfunctup rngfunc%ROWTYPE; BEGIN SELECT * into rngfunctup FROM rngfunc WHERE rngfuncid = $1; RETURN rngfunctup; END;' LANGUAGE plpgsql +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 138 +SELECT * FROM getrngfunc9(1) AS t1 +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: SelectStmt +== 139 +SELECT * FROM getrngfunc9(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: SelectStmt +== 140 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc9(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 141 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 142 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 143 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc9(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 144 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +== 145 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +== 146 +-- mix 'n match kinds, to exercise expandRTE and related logic + +select * from rows from(getrngfunc1(1),getrngfunc2(1),getrngfunc3(1),getrngfunc4(1),getrngfunc5(1), + getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc8(1),getrngfunc9(1)) + with ordinality as t1(a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u) +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: SelectStmt +== 147 +select * from rows from(getrngfunc9(1),getrngfunc8(1), + getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc5(1),getrngfunc4(1),getrngfunc3(1),getrngfunc2(1),getrngfunc1(1)) + with ordinality as t1(a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u) +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: SelectStmt +== 148 +create temporary view vw_rngfunc as + select * from rows from(getrngfunc9(1), + getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc1(1)) + with ordinality as t1(a,b,c,d,e,f,g,n) +-- +TABLE: name="vw_rngfunc" schema="" table="vw_rngfunc" ctx=DDL +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 149 +select * from vw_rngfunc +-- +TABLE: name="vw_rngfunc" schema="" table="vw_rngfunc" ctx=Select +STMT: SelectStmt +== 150 +select pg_get_viewdef('vw_rngfunc') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 151 +drop view vw_rngfunc +-- +STMT: DropStmt +== 152 +DROP FUNCTION getrngfunc1(int) +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=DDL +STMT: DropStmt +== 153 +DROP FUNCTION getrngfunc2(int) +-- +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=DDL +STMT: DropStmt +== 154 +DROP FUNCTION getrngfunc3(int) +-- +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=DDL +STMT: DropStmt +== 155 +DROP FUNCTION getrngfunc4(int) +-- +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=DDL +STMT: DropStmt +== 156 +DROP FUNCTION getrngfunc5(int) +-- +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=DDL +STMT: DropStmt +== 157 +DROP FUNCTION getrngfunc6(int) +-- +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=DDL +STMT: DropStmt +== 158 +DROP FUNCTION getrngfunc7(int) +-- +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=DDL +STMT: DropStmt +== 159 +DROP FUNCTION getrngfunc8(int) +-- +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=DDL +STMT: DropStmt +== 160 +DROP FUNCTION getrngfunc9(int) +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=DDL +STMT: DropStmt +== 161 +DROP FUNCTION rngfunct(int) +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=DDL +STMT: DropStmt +== 162 +DROP TABLE rngfunc2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DDL +STMT: DropStmt +== 163 +DROP TABLE rngfunc +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DDL +STMT: DropStmt +== 164 +-- Rescan tests -- +CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1 +-- +STMT: CreateSeqStmt +== 165 +CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2 +-- +STMT: CreateSeqStmt +== 166 +CREATE TYPE rngfunc_rescan_t AS (i integer, s bigint) +-- +STMT: CompositeTypeStmt +== 167 +CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQL +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 168 +-- plpgsql functions use materialize mode +CREATE FUNCTION rngfunc_mat(int,int) RETURNS setof rngfunc_rescan_t AS 'begin for i in $1..$2 loop return next (i, nextval(''rngfunc_rescan_seq2'')); end loop; end;' LANGUAGE plpgsql +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 169 +--invokes ExecReScanFunctionScan - all these cases should materialize the function only once +-- LEFT JOIN on a condition that the planner can't prove to be true is used to ensure the function +-- is on the inner path of a nestloop join + +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 170 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN rngfunc_sql(11,13) ON (r+i)<100 +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +== 171 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 172 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN rngfunc_sql(11,13) WITH ORDINALITY AS f(i,s,o) ON (r+i)<100 +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +== 173 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 174 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN rngfunc_mat(11,13) ON (r+i)<100 +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 175 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 176 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN rngfunc_mat(11,13) WITH ORDINALITY AS f(i,s,o) ON (r+i)<100 +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 177 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 178 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN ROWS FROM( rngfunc_sql(11,13), rngfunc_mat(11,13) ) WITH ORDINALITY AS f(i1,s1,i2,s2,o) ON (r+i1+i2)<100 +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 179 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN generate_series(11,13) f(i) ON (r+i)<100 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 180 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN generate_series(11,13) WITH ORDINALITY AS f(i,o) ON (r+i)<100 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 181 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN unnest(array[10,20,30]) f(i) ON (r+i)<100 +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 182 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN unnest(array[10,20,30]) WITH ORDINALITY AS f(i,o) ON (r+i)<100 +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 183 +--invokes ExecReScanFunctionScan with chgParam != NULL (using implied LATERAL) + +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 184 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_sql(10+r,13) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +== 185 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 186 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_sql(10+r,13) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +== 187 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 188 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_sql(11,10+r) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +== 189 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 190 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_sql(11,10+r) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +== 191 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 192 +SELECT * FROM (VALUES (11,12),(13,15),(16,20)) v(r1,r2), rngfunc_sql(r1,r2) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +== 193 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 194 +SELECT * FROM (VALUES (11,12),(13,15),(16,20)) v(r1,r2), rngfunc_sql(r1,r2) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +== 195 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 196 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_mat(10+r,13) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 197 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 198 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_mat(10+r,13) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 199 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 200 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_mat(11,10+r) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 201 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 202 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_mat(11,10+r) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 203 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 204 +SELECT * FROM (VALUES (11,12),(13,15),(16,20)) v(r1,r2), rngfunc_mat(r1,r2) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 205 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 206 +SELECT * FROM (VALUES (11,12),(13,15),(16,20)) v(r1,r2), rngfunc_mat(r1,r2) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 207 +-- selective rescan of multiple functions: + +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 208 +SELECT * FROM (VALUES (1),(2),(3)) v(r), ROWS FROM( rngfunc_sql(11,11), rngfunc_mat(10+r,13) ) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 209 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 210 +SELECT * FROM (VALUES (1),(2),(3)) v(r), ROWS FROM( rngfunc_sql(10+r,13), rngfunc_mat(11,11) ) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 211 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 212 +SELECT * FROM (VALUES (1),(2),(3)) v(r), ROWS FROM( rngfunc_sql(10+r,13), rngfunc_mat(10+r,13) ) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 213 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 214 +SELECT * FROM generate_series(1,2) r1, generate_series(r1,3) r2, ROWS FROM( rngfunc_sql(10+r1,13), rngfunc_mat(10+r2,13) ) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +== 215 +SELECT * FROM (VALUES (1),(2),(3)) v(r), generate_series(10+r,20-r) f(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 216 +SELECT * FROM (VALUES (1),(2),(3)) v(r), generate_series(10+r,20-r) WITH ORDINALITY AS f(i,o) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 217 +SELECT * FROM (VALUES (1),(2),(3)) v(r), unnest(array[r*10,r*20,r*30]) f(i) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 218 +SELECT * FROM (VALUES (1),(2),(3)) v(r), unnest(array[r*10,r*20,r*30]) WITH ORDINALITY AS f(i,o) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 219 +-- deep nesting + +SELECT * FROM (VALUES (1),(2),(3)) v1(r1), + LATERAL (SELECT r1, * FROM (VALUES (10),(20),(30)) v2(r2) + LEFT JOIN generate_series(21,23) f(i) ON ((r2+i)<100) OFFSET 0) s1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 220 +SELECT * FROM (VALUES (1),(2),(3)) v1(r1), + LATERAL (SELECT r1, * FROM (VALUES (10),(20),(30)) v2(r2) + LEFT JOIN generate_series(20+r1,23) f(i) ON ((r2+i)<100) OFFSET 0) s1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 221 +SELECT * FROM (VALUES (1),(2),(3)) v1(r1), + LATERAL (SELECT r1, * FROM (VALUES (10),(20),(30)) v2(r2) + LEFT JOIN generate_series(r2,r2+3) f(i) ON ((r2+i)<100) OFFSET 0) s1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 222 +SELECT * FROM (VALUES (1),(2),(3)) v1(r1), + LATERAL (SELECT r1, * FROM (VALUES (10),(20),(30)) v2(r2) + LEFT JOIN generate_series(r1,2+r2/5) f(i) ON ((r2+i)<100) OFFSET 0) s1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 223 +-- check handling of FULL JOIN with multiple lateral references (bug #15741) + +SELECT * +FROM (VALUES (1),(2)) v1(r1) + LEFT JOIN LATERAL ( + SELECT * + FROM generate_series(1, v1.r1) AS gs1 + LEFT JOIN LATERAL ( + SELECT * + FROM generate_series(1, gs1) AS gs2 + LEFT JOIN generate_series(1, gs2) AS gs3 ON TRUE + ) AS ss1 ON TRUE + FULL JOIN generate_series(1, v1.r1) AS gs4 ON FALSE + ) AS ss0 ON TRUE +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 224 +DROP FUNCTION rngfunc_sql(int,int) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=DDL +STMT: DropStmt +== 225 +DROP FUNCTION rngfunc_mat(int,int) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=DDL +STMT: DropStmt +== 226 +DROP SEQUENCE rngfunc_rescan_seq1 +-- +STMT: DropStmt +== 227 +DROP SEQUENCE rngfunc_rescan_seq2 +-- +STMT: DropStmt +== 228 +|-- +-- Test cases involving OUT parameters +|-- + +CREATE FUNCTION rngfunc(in f1 int, out f2 int) +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 229 +SELECT rngfunc(42) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +== 230 +SELECT * FROM rngfunc(42) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +== 231 +SELECT * FROM rngfunc(42) AS p(x) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +== 232 +-- explicit spec of return type is OK +CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS int +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 233 +-- error, wrong result type +CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS float +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 234 +-- with multiple OUT params you must get a RECORD result +CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) RETURNS int +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 235 +CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) +RETURNS record +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 236 +CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text) +AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql +-- +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 237 +SELECT f1, rngfuncr(f1) FROM int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=Call +STMT: SelectStmt +== 238 +SELECT * FROM rngfuncr(42) +-- +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=Call +STMT: SelectStmt +== 239 +SELECT * FROM rngfuncr(42) AS p(a,b) +-- +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=Call +STMT: SelectStmt +== 240 +CREATE OR REPLACE FUNCTION rngfuncb(in f1 int, inout f2 int, out text) +AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sql +-- +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 241 +SELECT f1, rngfuncb(f1, f1/2) FROM int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=Call +STMT: SelectStmt +== 242 +SELECT * FROM rngfuncb(42, 99) +-- +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=Call +STMT: SelectStmt +== 243 +SELECT * FROM rngfuncb(42, 99) AS p(a,b) +-- +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=Call +STMT: SelectStmt +== 244 +-- Can reference function with or without OUT params for DROP, etc +DROP FUNCTION rngfunc(int) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: DropStmt +== 245 +DROP FUNCTION rngfuncr(in f2 int, out f1 int, out text) +-- +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=DDL +STMT: DropStmt +== 246 +DROP FUNCTION rngfuncb(in f1 int, inout f2 int) +-- +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=DDL +STMT: DropStmt +== 247 +|-- +-- For my next trick, polymorphic OUT parameters +|-- + +CREATE FUNCTION dup (f1 anyelement, f2 out anyelement, f3 out anyarray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 248 +SELECT dup(22) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 249 +SELECT dup('xyz') +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 250 +-- fails +SELECT dup('xyz'::text) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 251 +SELECT * FROM dup('xyz'::text) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 252 +-- fails, as we are attempting to rename first argument +CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 253 +DROP FUNCTION dup(anyelement) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: DropStmt +== 254 +-- equivalent behavior, though different name exposed for input arg +CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 255 +SELECT dup(22) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 256 +DROP FUNCTION dup(anyelement) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: DropStmt +== 257 +-- fails, no way to deduce outputs +CREATE FUNCTION bad (f1 int, out f2 anyelement, out f3 anyarray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="bad" function="bad" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 258 +CREATE FUNCTION dup (f1 anycompatible, f2 anycompatiblearray, f3 out anycompatible, f4 out anycompatiblearray) +AS 'select $1, $2' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 259 +SELECT dup(22, array[44]) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 260 +SELECT dup(4.5, array[44]) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 261 +SELECT dup(22, array[44::bigint]) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 262 +SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, array[44::bigint]) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +== 263 +DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: DropStmt +== 264 +CREATE FUNCTION dup (f1 anycompatiblerange, f2 out anycompatible, f3 out anycompatiblearray, f4 out anycompatiblerange) +AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 265 +SELECT dup(int4range(4,7)) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 266 +SELECT dup(numrange(4,7)) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 267 +SELECT dup(textrange('aaa', 'bbb')) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +== 268 +DROP FUNCTION dup(f1 anycompatiblerange) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: DropStmt +== 269 +-- fails, no way to deduce outputs +CREATE FUNCTION bad (f1 anyarray, out f2 anycompatible, out f3 anycompatiblearray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="bad" function="bad" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 270 +|-- +-- table functions +|-- + +CREATE OR REPLACE FUNCTION rngfunc() +RETURNS TABLE(a int) +AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 271 +SELECT * FROM rngfunc() +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +== 272 +DROP FUNCTION rngfunc() +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: DropStmt +== 273 +CREATE OR REPLACE FUNCTION rngfunc(int) +RETURNS TABLE(a int, b int) +AS $$ SELECT a, b + FROM generate_series(1,$1) a(a), + generate_series(1,$1) b(b) $$ LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 274 +SELECT * FROM rngfunc(3) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +== 275 +DROP FUNCTION rngfunc(int) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: DropStmt +== 276 +-- case that causes change of typmod knowledge during inlining +CREATE OR REPLACE FUNCTION rngfunc() +RETURNS TABLE(a varchar(5)) +AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sql STABLE +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 277 +SELECT * FROM rngfunc() GROUP BY 1 +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +== 278 +DROP FUNCTION rngfunc() +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: DropStmt +== 279 +|-- +-- some tests on SQL functions with RETURNING +|-- + +create temp table tt(f1 serial, data text) +-- +TABLE: name="tt" schema="" table="tt" ctx=DDL +STMT: CreateStmt +== 280 +create function insert_tt(text) returns int as +$$ insert into tt(data) values($1) returning f1 $$ +language sql +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 281 +select insert_tt('foo') +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=Call +STMT: SelectStmt +== 282 +select insert_tt('bar') +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=Call +STMT: SelectStmt +== 283 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +== 284 +-- insert will execute to completion even if function needs just 1 row +create or replace function insert_tt(text) returns int as +$$ insert into tt(data) values($1),($1||$1) returning f1 $$ +language sql +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 285 +select insert_tt('fool') +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=Call +STMT: SelectStmt +== 286 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +== 287 +-- setof does what's expected +create or replace function insert_tt2(text,text) returns setof int as +$$ insert into tt(data) values($1),($2) returning f1 $$ +language sql +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 288 +select insert_tt2('foolish','barrish') +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +== 289 +select * from insert_tt2('baz','quux') +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +== 290 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +== 291 +-- limit doesn't prevent execution to completion +select insert_tt2('foolish','barrish') limit 1 +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +== 292 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +== 293 +-- triggers will fire, too +create function noticetrigger() returns trigger as $$ +begin + raise notice 'noticetrigger % %', new.f1, new.data; + return null; +end $$ language plpgsql +-- +FUNCTION: name="noticetrigger" function="noticetrigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 294 +create trigger tnoticetrigger after insert on tt for each row +execute procedure noticetrigger() +-- +TABLE: name="tt" schema="" table="tt" ctx=DDL +STMT: CreateTrigStmt +== 295 +select insert_tt2('foolme','barme') limit 1 +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +== 296 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +== 297 +-- and rules work +create temp table tt_log(f1 int, data text) +-- +TABLE: name="tt_log" schema="" table="tt_log" ctx=DDL +STMT: CreateStmt +== 298 +create rule insert_tt_rule as on insert to tt do also + insert into tt_log values(new.*) +-- +TABLE: name="tt" schema="" table="tt" ctx=DDL +STMT: RuleStmt +== 299 +select insert_tt2('foollog','barlog') limit 1 +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +== 300 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +== 301 +-- note that nextval() gets executed a second time in the rule expansion, +-- which is expected. +select * from tt_log +-- +TABLE: name="tt_log" schema="" table="tt_log" ctx=Select +STMT: SelectStmt +== 302 +-- test case for a whole-row-variable bug +create function rngfunc1(n integer, out a text, out b text) + returns setof record + language sql + as $$ select 'foo ' || i, 'bar ' || i from generate_series(1,$1) i $$ +-- +FUNCTION: name="rngfunc1" function="rngfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 303 +set work_mem='64kB' +-- +STMT: VariableSetStmt +== 304 +select t.a, t, t.a from rngfunc1(10000) t limit 1 +-- +FUNCTION: name="rngfunc1" function="rngfunc1" schema="" ctx=Call +STMT: SelectStmt +== 305 +reset work_mem +-- +STMT: VariableSetStmt +== 306 +select t.a, t, t.a from rngfunc1(10000) t limit 1 +-- +FUNCTION: name="rngfunc1" function="rngfunc1" schema="" ctx=Call +STMT: SelectStmt +== 307 +drop function rngfunc1(n integer) +-- +FUNCTION: name="rngfunc1" function="rngfunc1" schema="" ctx=DDL +STMT: DropStmt +== 308 +-- test use of SQL functions returning record +-- this is supported in some cases where the query doesn't specify +-- the actual record type ... + +create function array_to_set(anyarray) returns setof record as $$ + select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i +$$ language sql strict immutable +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 309 +select array_to_set(array['one', 'two']) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 310 +select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 311 +select * from array_to_set(array['one', 'two']) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 312 +-- fail +-- after-the-fact coercion of the columns is now possible, too +select * from array_to_set(array['one', 'two']) as t(f1 numeric(4,2),f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 313 +-- and if it doesn't work, you get a compile-time not run-time error +select * from array_to_set(array['one', 'two']) as t(f1 point,f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 314 +-- with "strict", this function can't be inlined in FROM +explain (verbose, costs off) + select * from array_to_set(array['one', 'two']) as t(f1 numeric(4,2),f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 315 +-- but without, it can be: + +create or replace function array_to_set(anyarray) returns setof record as $$ + select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i +$$ language sql immutable +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 316 +select array_to_set(array['one', 'two']) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 317 +select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 318 +select * from array_to_set(array['one', 'two']) as t(f1 numeric(4,2),f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 319 +select * from array_to_set(array['one', 'two']) as t(f1 point,f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +== 320 +explain (verbose, costs off) + select * from array_to_set(array['one', 'two']) as t(f1 numeric(4,2),f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 321 +create temp table rngfunc(f1 int8, f2 int8) +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DDL +STMT: CreateStmt +== 322 +create function testrngfunc() returns record as $$ + insert into rngfunc values (1,2) returning *; +$$ language sql +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 323 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 324 +select * from testrngfunc() as t(f1 int8,f2 int8) +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 325 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 326 +-- fail + +drop function testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: DropStmt +== 327 +create function testrngfunc() returns setof record as $$ + insert into rngfunc values (1,2), (3,4) returning *; +$$ language sql +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 328 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 329 +select * from testrngfunc() as t(f1 int8,f2 int8) +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 330 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 331 +-- fail + +drop function testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: DropStmt +== 332 +-- Check that typmod imposed by a composite type is honored +create type rngfunc_type as (f1 numeric(35,6), f2 numeric(35,2)) +-- +STMT: CompositeTypeStmt +== 333 +create function testrngfunc() returns rngfunc_type as $$ + select 7.136178319899999964, 7.136178319899999964; +$$ language sql immutable +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 334 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 335 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 336 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 337 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 338 +create or replace function testrngfunc() returns rngfunc_type as $$ + select 7.136178319899999964, 7.136178319899999964; +$$ language sql volatile +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 339 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 340 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 341 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 342 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 343 +drop function testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: DropStmt +== 344 +create function testrngfunc() returns setof rngfunc_type as $$ + select 7.136178319899999964, 7.136178319899999964; +$$ language sql immutable +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 345 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 346 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 347 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 348 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 349 +create or replace function testrngfunc() returns setof rngfunc_type as $$ + select 7.136178319899999964, 7.136178319899999964; +$$ language sql volatile +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 350 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 351 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 352 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 353 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 354 +create or replace function testrngfunc() returns setof rngfunc_type as $$ + select 1, 2 union select 3, 4 order by 1; +$$ language sql immutable +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 355 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 356 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 357 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 358 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 359 +-- Check a couple of error cases while we're here +select * from testrngfunc() as t(f1 int8,f2 int8) +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +== 360 +-- fail, composite result +select * from pg_get_keywords() as t(f1 int8,f2 int8) +-- +FUNCTION: name="pg_get_keywords" function="pg_get_keywords" schema="" ctx=Call +STMT: SelectStmt +== 361 +-- fail, OUT params +select * from sin(3) as t(f1 int8,f2 int8) +-- +FUNCTION: name="sin" function="sin" schema="" ctx=Call +STMT: SelectStmt +== 362 +-- fail, scalar result type + +drop type rngfunc_type cascade +-- +STMT: DropStmt +== 363 +|-- +-- Check some cases involving added/dropped columns in a rowtype result +|-- + +create temp table users (userid text, seq int, email text, todrop bool, moredrop int, enabled bool) +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: CreateStmt +== 364 +insert into users values ('id',1,'email',true,11,true) +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 365 +insert into users values ('id2',2,'email2',true,12,true) +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 366 +alter table users drop column todrop +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +== 367 +create or replace function get_first_user() returns users as +$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$ +language sql stable +-- +FUNCTION: name="get_first_user" function="get_first_user" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 368 +SELECT get_first_user() +-- +FUNCTION: name="get_first_user" function="get_first_user" schema="" ctx=Call +STMT: SelectStmt +== 369 +SELECT * FROM get_first_user() +-- +FUNCTION: name="get_first_user" function="get_first_user" schema="" ctx=Call +STMT: SelectStmt +== 370 +create or replace function get_users() returns setof users as +$$ SELECT * FROM users ORDER BY userid; $$ +language sql stable +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 371 +SELECT get_users() +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +STMT: SelectStmt +== 372 +SELECT * FROM get_users() +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +STMT: SelectStmt +== 373 +SELECT * FROM get_users() WITH ORDINALITY +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +STMT: SelectStmt +== 374 +-- make sure ordinality copes + +-- multiple functions vs. dropped columns +SELECT * FROM ROWS FROM(generate_series(10,11), get_users()) WITH ORDINALITY +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +STMT: SelectStmt +== 375 +SELECT * FROM ROWS FROM(get_users(), generate_series(10,11)) WITH ORDINALITY +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 376 +-- check that we can cope with post-parsing changes in rowtypes +create temp view usersview as +SELECT * FROM ROWS FROM(get_users(), generate_series(10,11)) WITH ORDINALITY +-- +TABLE: name="usersview" schema="" table="usersview" ctx=DDL +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 377 +select * from usersview +-- +TABLE: name="usersview" schema="" table="usersview" ctx=Select +STMT: SelectStmt +== 378 +alter table users add column junk text +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +== 379 +select * from usersview +-- +TABLE: name="usersview" schema="" table="usersview" ctx=Select +STMT: SelectStmt +== 380 +alter table users drop column moredrop +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +== 381 +-- fail, view has reference + +-- We used to have a bug that would allow the above to succeed, posing +-- hazards for later execution of the view. Check that the internal +-- defenses for those hazards haven't bit-rotted, in case some other +-- bug with similar symptoms emerges. +begin +-- +STMT: TransactionStmt +== 382 +-- destroy the dependency entry that prevents the DROP: +delete from pg_depend where + objid = (select oid from pg_rewrite + where ev_class = 'usersview'::regclass and rulename = '_RETURN') + and refobjsubid = 5 +returning pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as ref, + deptype +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=DML +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="rulename" +STMT: DeleteStmt +STMT: SelectStmt +== 383 +alter table users drop column moredrop +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +== 384 +select * from usersview +-- +TABLE: name="usersview" schema="" table="usersview" ctx=Select +STMT: SelectStmt +== 385 +-- expect clean failure +rollback +-- +STMT: TransactionStmt +== 386 +alter table users alter column seq type numeric +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +== 387 +-- fail, view has reference + +-- likewise, check we don't crash if the dependency goes wrong +begin +-- +STMT: TransactionStmt +== 388 +-- destroy the dependency entry that prevents the ALTER: +delete from pg_depend where + objid = (select oid from pg_rewrite + where ev_class = 'usersview'::regclass and rulename = '_RETURN') + and refobjsubid = 2 +returning pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as ref, + deptype +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=DML +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="rulename" +STMT: DeleteStmt +STMT: SelectStmt +== 389 +alter table users alter column seq type numeric +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +== 390 +select * from usersview +-- +TABLE: name="usersview" schema="" table="usersview" ctx=Select +STMT: SelectStmt +== 391 +-- expect clean failure +rollback +-- +STMT: TransactionStmt +== 392 +drop view usersview +-- +STMT: DropStmt +== 393 +drop function get_first_user() +-- +FUNCTION: name="get_first_user" function="get_first_user" schema="" ctx=DDL +STMT: DropStmt +== 394 +drop function get_users() +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=DDL +STMT: DropStmt +== 395 +drop table users +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: DropStmt +== 396 +-- check behavior with type coercion required for a set-op + +create or replace function rngfuncbar() returns setof text as +$$ select 'foo'::varchar union all select 'bar'::varchar ; $$ +language sql stable +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 397 +select rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +== 398 +select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +== 399 +-- this function is now inlinable, too: +explain (verbose, costs off) select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 400 +drop function rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: DropStmt +== 401 +-- check handling of a SQL function with multiple OUT params (bug #5777) + +create or replace function rngfuncbar(out integer, out numeric) as +$$ select (1, 2.1) $$ language sql +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 402 +select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +== 403 +create or replace function rngfuncbar(out integer, out numeric) as +$$ select (1, 2) $$ language sql +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 404 +select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +== 405 +-- fail + +create or replace function rngfuncbar(out integer, out numeric) as +$$ select (1, 2.1, 3) $$ language sql +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 406 +select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +== 407 +-- fail + +drop function rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: DropStmt +== 408 +-- check whole-row-Var handling in nested lateral functions (bug #11703) + +create function extractq2(t int8_tbl) returns int8 as $$ + select t.q2 +$$ language sql immutable +-- +FUNCTION: name="extractq2" function="extractq2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 409 +explain (verbose, costs off) +select x from int8_tbl, extractq2(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2" function="extractq2" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 410 +select x from int8_tbl, extractq2(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2" function="extractq2" schema="" ctx=Call +STMT: SelectStmt +== 411 +create function extractq2_2(t int8_tbl) returns table(ret1 int8) as $$ + select extractq2(t) offset 0 +$$ language sql immutable +-- +FUNCTION: name="extractq2_2" function="extractq2_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 412 +explain (verbose, costs off) +select x from int8_tbl, extractq2_2(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2_2" function="extractq2_2" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 413 +select x from int8_tbl, extractq2_2(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2_2" function="extractq2_2" schema="" ctx=Call +STMT: SelectStmt +== 414 +-- without the "offset 0", this function gets optimized quite differently + +create function extractq2_2_opt(t int8_tbl) returns table(ret1 int8) as $$ + select extractq2(t) +$$ language sql immutable +-- +FUNCTION: name="extractq2_2_opt" function="extractq2_2_opt" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 415 +explain (verbose, costs off) +select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2_2_opt" function="extractq2_2_opt" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 416 +select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2_2_opt" function="extractq2_2_opt" schema="" ctx=Call +STMT: SelectStmt +== 417 +-- check handling of nulls in SRF results (bug #7808) + +create type rngfunc2 as (a integer, b text) +-- +STMT: CompositeTypeStmt +== 418 +select *, row_to_json(u) from unnest(array[(1,'foo')::rngfunc2, null::rngfunc2]) u +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 419 +select *, row_to_json(u) from unnest(array[null::rngfunc2, null::rngfunc2]) u +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 420 +select *, row_to_json(u) from unnest(array[null::rngfunc2, (1,'foo')::rngfunc2, null::rngfunc2]) u +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 421 +select *, row_to_json(u) from unnest(array[]::rngfunc2[]) u +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 422 +drop type rngfunc2 +-- +STMT: DropStmt +== 423 +-- check handling of functions pulled up into function RTEs (bug #17227) + +explain (verbose, costs off) +select * from + (select jsonb_path_query_array(module->'lectures', '$[*]') as lecture + from unnest(array['{"lectures": [{"id": "1"}]}'::jsonb]) + as unnested_modules(module)) as ss, + jsonb_to_recordset(ss.lecture) as j (id text) +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="jsonb_to_recordset" function="jsonb_to_recordset" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 424 +select * from + (select jsonb_path_query_array(module->'lectures', '$[*]') as lecture + from unnest(array['{"lectures": [{"id": "1"}]}'::jsonb]) + as unnested_modules(module)) as ss, + jsonb_to_recordset(ss.lecture) as j (id text) +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="jsonb_to_recordset" function="jsonb_to_recordset" schema="" ctx=Call +STMT: SelectStmt +== 425 +-- check detection of mismatching record types with a const-folded expression + +with a(b) as (values (row(1,2,3))) +select * from a, coalesce(b) as c(d int, e int) +-- +CTE: "a" +STMT: SelectStmt +== 426 +-- fail +with a(b) as (values (row(1,2,3))) +select * from a, coalesce(b) as c(d int, e int, f int, g int) +-- +CTE: "a" +STMT: SelectStmt +== 427 +-- fail +with a(b) as (values (row(1,2,3))) +select * from a, coalesce(b) as c(d int, e int, f float) +-- +CTE: "a" +STMT: SelectStmt +== 428 +-- fail +select * from int8_tbl, coalesce(row(1)) as (a int, b int) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/rangetypes.metadata.json b/parser/testdata/summary/postgres_regress/rangetypes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rangetypes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/rangetypes.test b/parser/testdata/summary/postgres_regress/rangetypes.test new file mode 100644 index 0000000..24d246d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rangetypes.test @@ -0,0 +1,2802 @@ +== 001 +-- Tests for range data types. + +|-- +-- test input parser +-- (type textrange was already made in test_setup.sql) +|-- + +-- negative tests; should fail +select ''::textrange +-- +STMT: SelectStmt +== 002 +select '-[a,z)'::textrange +-- +STMT: SelectStmt +== 003 +select '[a,z) - '::textrange +-- +STMT: SelectStmt +== 004 +select '(",a)'::textrange +-- +STMT: SelectStmt +== 005 +select '(,,a)'::textrange +-- +STMT: SelectStmt +== 006 +select '(),a)'::textrange +-- +STMT: SelectStmt +== 007 +select '(a,))'::textrange +-- +STMT: SelectStmt +== 008 +select '(],a)'::textrange +-- +STMT: SelectStmt +== 009 +select '(a,])'::textrange +-- +STMT: SelectStmt +== 010 +select '[z,a]'::textrange +-- +STMT: SelectStmt +== 011 +-- should succeed +select ' empty '::textrange +-- +STMT: SelectStmt +== 012 +select ' ( empty, empty ) '::textrange +-- +STMT: SelectStmt +== 013 +select ' ( " a " " a ", " z " " z " ) '::textrange +-- +STMT: SelectStmt +== 014 +select '(a,)'::textrange +-- +STMT: SelectStmt +== 015 +select '[,z]'::textrange +-- +STMT: SelectStmt +== 016 +select '[a,]'::textrange +-- +STMT: SelectStmt +== 017 +select '(,)'::textrange +-- +STMT: SelectStmt +== 018 +select '[ , ]'::textrange +-- +STMT: SelectStmt +== 019 +select '["",""]'::textrange +-- +STMT: SelectStmt +== 020 +select '[",",","]'::textrange +-- +STMT: SelectStmt +== 021 +select '["\\","\\"]'::textrange +-- +STMT: SelectStmt +== 022 +select '(\\,a)'::textrange +-- +STMT: SelectStmt +== 023 +select '((,z)'::textrange +-- +STMT: SelectStmt +== 024 +select '([,z)'::textrange +-- +STMT: SelectStmt +== 025 +select '(!,()'::textrange +-- +STMT: SelectStmt +== 026 +select '(!,[)'::textrange +-- +STMT: SelectStmt +== 027 +select '[a,a]'::textrange +-- +STMT: SelectStmt +== 028 +-- these are allowed but normalize to empty: +select '[a,a)'::textrange +-- +STMT: SelectStmt +== 029 +select '(a,a]'::textrange +-- +STMT: SelectStmt +== 030 +select '(a,a)'::textrange +-- +STMT: SelectStmt +== 031 +-- Also try it with non-error-throwing API +select pg_input_is_valid('(1,4)', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 032 +select pg_input_is_valid('(1,4', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 033 +select * from pg_input_error_info('(1,4', 'int4range') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 034 +select pg_input_is_valid('(4,1)', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 035 +select * from pg_input_error_info('(4,1)', 'int4range') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 036 +select pg_input_is_valid('(4,zed)', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 037 +select * from pg_input_error_info('(4,zed)', 'int4range') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 038 +select pg_input_is_valid('[1,2147483647]', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 039 +select * from pg_input_error_info('[1,2147483647]', 'int4range') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 040 +select pg_input_is_valid('[2000-01-01,5874897-12-31]', 'daterange') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 041 +select * from pg_input_error_info('[2000-01-01,5874897-12-31]', 'daterange') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 042 +|-- +-- create some test data and test the operators +|-- + +CREATE TABLE numrange_test (nr NUMRANGE) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DDL +STMT: CreateStmt +== 043 +create index numrange_test_btree on numrange_test(nr) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DDL +STMT: IndexStmt +== 044 +INSERT INTO numrange_test VALUES('[,)') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO numrange_test VALUES('[3,]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO numrange_test VALUES('[, 5)') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO numrange_test VALUES(numrange(1.1, 2.2)) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO numrange_test VALUES('empty') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +INSERT INTO numrange_test VALUES(numrange(1.7, 1.7, '[]')) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 050 +SELECT nr, isempty(nr), lower(nr), upper(nr) FROM numrange_test +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="isempty" function="isempty" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +== 051 +SELECT nr, lower_inc(nr), lower_inf(nr), upper_inc(nr), upper_inf(nr) FROM numrange_test +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="lower_inc" function="lower_inc" schema="" ctx=Call +FUNCTION: name="lower_inf" function="lower_inf" schema="" ctx=Call +FUNCTION: name="upper_inc" function="upper_inc" schema="" ctx=Call +FUNCTION: name="upper_inf" function="upper_inf" schema="" ctx=Call +STMT: SelectStmt +== 052 +SELECT * FROM numrange_test WHERE range_contains(nr, numrange(1.9,1.91)) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_contains" function="range_contains" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="range_contains" function="range_contains" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 053 +SELECT * FROM numrange_test WHERE nr @> numrange(1.0,10000.1) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 054 +SELECT * FROM numrange_test WHERE range_contained_by(numrange(-1e7,-10000.1), nr) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_contained_by" function="range_contained_by" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="range_contained_by" function="range_contained_by" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 055 +SELECT * FROM numrange_test WHERE 1.9 <@ nr +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 056 +select * from numrange_test where nr = 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 057 +select * from numrange_test where nr = '(1.1, 2.2)' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 058 +select * from numrange_test where nr = '[1.1, 2.2)' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 059 +select * from numrange_test where nr < 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 060 +select * from numrange_test where nr < numrange(-1000.0, -1000.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 061 +select * from numrange_test where nr < numrange(0.0, 1.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 062 +select * from numrange_test where nr < numrange(1000.0, 1001.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 063 +select * from numrange_test where nr <= 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 064 +select * from numrange_test where nr >= 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 065 +select * from numrange_test where nr > 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 066 +select * from numrange_test where nr > numrange(-1001.0, -1000.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 067 +select * from numrange_test where nr > numrange(0.0, 1.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 068 +select * from numrange_test where nr > numrange(1000.0, 1000.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 069 +select numrange(2.0, 1.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 070 +select numrange(2.0, 3.0) -|- numrange(3.0, 4.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 071 +select range_adjacent(numrange(2.0, 3.0), numrange(3.1, 4.0)) +-- +FUNCTION: name="range_adjacent" function="range_adjacent" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 072 +select range_adjacent(numrange(2.0, 3.0), numrange(3.1, null)) +-- +FUNCTION: name="range_adjacent" function="range_adjacent" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 073 +select numrange(2.0, 3.0, '[]') -|- numrange(3.0, 4.0, '()') +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 074 +select numrange(1.0, 2.0) -|- numrange(2.0, 3.0,'[]') +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 075 +select range_adjacent(numrange(2.0, 3.0, '(]'), numrange(1.0, 2.0, '(]')) +-- +FUNCTION: name="range_adjacent" function="range_adjacent" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 076 +select numrange(1.1, 3.3) <@ numrange(0.1,10.1) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 077 +select numrange(0.1, 10.1) <@ numrange(1.1,3.3) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 078 +select numrange(1.1, 2.2) - numrange(2.0, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 079 +select numrange(1.1, 2.2) - numrange(2.2, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 080 +select numrange(1.1, 2.2,'[]') - numrange(2.0, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 081 +select range_minus(numrange(10.1,12.2,'[]'), numrange(110.0,120.2,'(]')) +-- +FUNCTION: name="range_minus" function="range_minus" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 082 +select range_minus(numrange(10.1,12.2,'[]'), numrange(0.0,120.2,'(]')) +-- +FUNCTION: name="range_minus" function="range_minus" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 083 +select numrange(4.5, 5.5, '[]') && numrange(5.5, 6.5) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 084 +select numrange(1.0, 2.0) << numrange(3.0, 4.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 085 +select numrange(1.0, 3.0,'[]') << numrange(3.0, 4.0,'[]') +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 086 +select numrange(1.0, 3.0,'()') << numrange(3.0, 4.0,'()') +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 087 +select numrange(1.0, 2.0) >> numrange(3.0, 4.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 088 +select numrange(3.0, 70.0) &< numrange(6.6, 100.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 089 +select numrange(1.1, 2.2) < numrange(1.0, 200.2) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 090 +select numrange(1.1, 2.2) < numrange(1.1, 1.2) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 091 +select numrange(1.0, 2.0) + numrange(2.0, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 092 +select numrange(1.0, 2.0) + numrange(1.5, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 093 +select numrange(1.0, 2.0) + numrange(2.5, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 094 +-- should fail + +select range_merge(numrange(1.0, 2.0), numrange(2.0, 3.0)) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 095 +select range_merge(numrange(1.0, 2.0), numrange(1.5, 3.0)) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 096 +select range_merge(numrange(1.0, 2.0), numrange(2.5, 3.0)) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 097 +-- shouldn't fail + +select numrange(1.0, 2.0) * numrange(2.0, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 098 +select numrange(1.0, 2.0) * numrange(1.5, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 099 +select numrange(1.0, 2.0) * numrange(2.5, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 100 +select range_intersect_agg(nr) from numrange_test +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 101 +select range_intersect_agg(nr) from numrange_test where false +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +== 102 +select range_intersect_agg(nr) from numrange_test where nr @> 4.0 +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 103 +analyze numrange_test +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DDL +STMT: VacuumStmt +== 104 +create table numrange_test2(nr numrange) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DDL +STMT: CreateStmt +== 105 +create index numrange_test2_hash_idx on numrange_test2 using hash (nr) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DDL +STMT: IndexStmt +== 106 +INSERT INTO numrange_test2 VALUES('[, 5)') +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +INSERT INTO numrange_test2 VALUES(numrange(1.1, 2.2)) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 108 +INSERT INTO numrange_test2 VALUES(numrange(1.1, 2.2)) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 109 +INSERT INTO numrange_test2 VALUES(numrange(1.1, 2.2,'()')) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 110 +INSERT INTO numrange_test2 VALUES('empty') +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +select * from numrange_test2 where nr = 'empty'::numrange +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 112 +select * from numrange_test2 where nr = numrange(1.1, 2.2) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 113 +select * from numrange_test2 where nr = numrange(1.1, 2.3) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 114 +set enable_nestloop=t +-- +STMT: VariableSetStmt +== 115 +set enable_hashjoin=f +-- +STMT: VariableSetStmt +== 116 +set enable_mergejoin=f +-- +STMT: VariableSetStmt +== 117 +select * from numrange_test natural join numrange_test2 order by nr +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +STMT: SelectStmt +== 118 +set enable_nestloop=f +-- +STMT: VariableSetStmt +== 119 +set enable_hashjoin=t +-- +STMT: VariableSetStmt +== 120 +set enable_mergejoin=f +-- +STMT: VariableSetStmt +== 121 +select * from numrange_test natural join numrange_test2 order by nr +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +STMT: SelectStmt +== 122 +set enable_nestloop=f +-- +STMT: VariableSetStmt +== 123 +set enable_hashjoin=f +-- +STMT: VariableSetStmt +== 124 +set enable_mergejoin=t +-- +STMT: VariableSetStmt +== 125 +select * from numrange_test natural join numrange_test2 order by nr +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +STMT: SelectStmt +== 126 +set enable_nestloop to default +-- +STMT: VariableSetStmt +== 127 +set enable_hashjoin to default +-- +STMT: VariableSetStmt +== 128 +set enable_mergejoin to default +-- +STMT: VariableSetStmt +== 129 +-- keep numrange_test around to help exercise dump/reload +DROP TABLE numrange_test2 +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DDL +STMT: DropStmt +== 130 +|-- +-- Apply a subset of the above tests on a collatable type, too +|-- + +CREATE TABLE textrange_test (tr textrange) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DDL +STMT: CreateStmt +== 131 +create index textrange_test_btree on textrange_test(tr) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DDL +STMT: IndexStmt +== 132 +INSERT INTO textrange_test VALUES('[,)') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 133 +INSERT INTO textrange_test VALUES('["a",]') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 134 +INSERT INTO textrange_test VALUES('[,"q")') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 135 +INSERT INTO textrange_test VALUES(textrange('b', 'g')) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 136 +INSERT INTO textrange_test VALUES('empty') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 137 +INSERT INTO textrange_test VALUES(textrange('d', 'd', '[]')) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 138 +SELECT tr, isempty(tr), lower(tr), upper(tr) FROM textrange_test +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="isempty" function="isempty" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +== 139 +SELECT tr, lower_inc(tr), lower_inf(tr), upper_inc(tr), upper_inf(tr) FROM textrange_test +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="lower_inc" function="lower_inc" schema="" ctx=Call +FUNCTION: name="lower_inf" function="lower_inf" schema="" ctx=Call +FUNCTION: name="upper_inc" function="upper_inc" schema="" ctx=Call +FUNCTION: name="upper_inf" function="upper_inf" schema="" ctx=Call +STMT: SelectStmt +== 140 +SELECT * FROM textrange_test WHERE range_contains(tr, textrange('f', 'fx')) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="range_contains" function="range_contains" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="range_contains" function="range_contains" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +== 141 +SELECT * FROM textrange_test WHERE tr @> textrange('a', 'z') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +== 142 +SELECT * FROM textrange_test WHERE range_contained_by(textrange('0','9'), tr) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="range_contained_by" function="range_contained_by" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="range_contained_by" function="range_contained_by" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +== 143 +SELECT * FROM textrange_test WHERE 'e'::text <@ tr +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +== 144 +select * from textrange_test where tr = 'empty' +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +== 145 +select * from textrange_test where tr = '("b","g")' +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +== 146 +select * from textrange_test where tr = '["b","g")' +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +== 147 +select * from textrange_test where tr < 'empty' +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +== 148 +-- test canonical form for int4range +select int4range(1, 10, '[]') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 149 +select int4range(1, 10, '[)') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 150 +select int4range(1, 10, '(]') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 151 +select int4range(1, 10, '()') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 152 +select int4range(1, 2, '()') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 153 +-- test canonical form for daterange +select daterange('2000-01-10'::date, '2000-01-20'::date, '[]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 154 +select daterange('2000-01-10'::date, '2000-01-20'::date, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 155 +select daterange('2000-01-10'::date, '2000-01-20'::date, '(]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 156 +select daterange('2000-01-10'::date, '2000-01-20'::date, '()') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 157 +select daterange('2000-01-10'::date, '2000-01-11'::date, '()') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 158 +select daterange('2000-01-10'::date, '2000-01-11'::date, '(]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 159 +select daterange('-infinity'::date, '2000-01-01'::date, '()') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 160 +select daterange('-infinity'::date, '2000-01-01'::date, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 161 +select daterange('2000-01-01'::date, 'infinity'::date, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 162 +select daterange('2000-01-01'::date, 'infinity'::date, '[]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +== 163 +-- test GiST index that's been built incrementally +create table test_range_gist(ir int4range) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DDL +STMT: CreateStmt +== 164 +create index test_range_gist_idx on test_range_gist using gist (ir) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DDL +STMT: IndexStmt +== 165 +insert into test_range_gist select int4range(g, g+10) from generate_series(1,2000) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 166 +insert into test_range_gist select 'empty'::int4range from generate_series(1,500) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 167 +insert into test_range_gist select int4range(g, g+10000) from generate_series(1,1000) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 168 +insert into test_range_gist select 'empty'::int4range from generate_series(1,500) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 169 +insert into test_range_gist select int4range(NULL,g*10,'(]') from generate_series(1,100) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 170 +insert into test_range_gist select int4range(g*10,NULL,'(]') from generate_series(1,100) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 171 +insert into test_range_gist select int4range(g, g+10) from generate_series(1,2000) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 172 +-- test statistics and selectivity estimation as well +|-- +-- We don't check the accuracy of selectivity estimation, but at least check +-- it doesn't fall. +analyze test_range_gist +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DDL +STMT: VacuumStmt +== 173 +-- first, verify non-indexed results +SET enable_seqscan = t +-- +STMT: VariableSetStmt +== 174 +SET enable_indexscan = f +-- +STMT: VariableSetStmt +== 175 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +== 176 +select count(*) from test_range_gist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 177 +select count(*) from test_range_gist where ir = int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 178 +select count(*) from test_range_gist where ir @> 10 +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 179 +select count(*) from test_range_gist where ir @> int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 180 +select count(*) from test_range_gist where ir && int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 181 +select count(*) from test_range_gist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 182 +select count(*) from test_range_gist where ir << int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 183 +select count(*) from test_range_gist where ir >> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 184 +select count(*) from test_range_gist where ir &< int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 185 +select count(*) from test_range_gist where ir &> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 186 +select count(*) from test_range_gist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 187 +select count(*) from test_range_gist where ir @> '{}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 188 +select count(*) from test_range_gist where ir @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 189 +select count(*) from test_range_gist where ir && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 190 +select count(*) from test_range_gist where ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 191 +select count(*) from test_range_gist where ir << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 192 +select count(*) from test_range_gist where ir >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 193 +select count(*) from test_range_gist where ir &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 194 +select count(*) from test_range_gist where ir &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 195 +select count(*) from test_range_gist where ir -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 196 +-- now check same queries using index +SET enable_seqscan = f +-- +STMT: VariableSetStmt +== 197 +SET enable_indexscan = t +-- +STMT: VariableSetStmt +== 198 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +== 199 +select count(*) from test_range_gist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 200 +select count(*) from test_range_gist where ir = int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 201 +select count(*) from test_range_gist where ir @> 10 +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 202 +select count(*) from test_range_gist where ir @> int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 203 +select count(*) from test_range_gist where ir && int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 204 +select count(*) from test_range_gist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 205 +select count(*) from test_range_gist where ir << int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 206 +select count(*) from test_range_gist where ir >> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 207 +select count(*) from test_range_gist where ir &< int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 208 +select count(*) from test_range_gist where ir &> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 209 +select count(*) from test_range_gist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 210 +select count(*) from test_range_gist where ir @> '{}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 211 +select count(*) from test_range_gist where ir @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 212 +select count(*) from test_range_gist where ir && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 213 +select count(*) from test_range_gist where ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 214 +select count(*) from test_range_gist where ir << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 215 +select count(*) from test_range_gist where ir >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 216 +select count(*) from test_range_gist where ir &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 217 +select count(*) from test_range_gist where ir &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 218 +select count(*) from test_range_gist where ir -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 219 +-- now check same queries using a bulk-loaded index +drop index test_range_gist_idx +-- +STMT: DropStmt +== 220 +create index test_range_gist_idx on test_range_gist using gist (ir) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DDL +STMT: IndexStmt +== 221 +select count(*) from test_range_gist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 222 +select count(*) from test_range_gist where ir = int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 223 +select count(*) from test_range_gist where ir @> 10 +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 224 +select count(*) from test_range_gist where ir @> int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 225 +select count(*) from test_range_gist where ir && int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 226 +select count(*) from test_range_gist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 227 +select count(*) from test_range_gist where ir << int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 228 +select count(*) from test_range_gist where ir >> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 229 +select count(*) from test_range_gist where ir &< int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 230 +select count(*) from test_range_gist where ir &> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 231 +select count(*) from test_range_gist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 232 +select count(*) from test_range_gist where ir @> '{}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 233 +select count(*) from test_range_gist where ir @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 234 +select count(*) from test_range_gist where ir && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 235 +select count(*) from test_range_gist where ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 236 +select count(*) from test_range_gist where ir << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 237 +select count(*) from test_range_gist where ir >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 238 +select count(*) from test_range_gist where ir &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 239 +select count(*) from test_range_gist where ir &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 240 +select count(*) from test_range_gist where ir -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 241 +-- test SP-GiST index that's been built incrementally +create table test_range_spgist(ir int4range) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DDL +STMT: CreateStmt +== 242 +create index test_range_spgist_idx on test_range_spgist using spgist (ir) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DDL +STMT: IndexStmt +== 243 +insert into test_range_spgist select int4range(g, g+10) from generate_series(1,2000) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 244 +insert into test_range_spgist select 'empty'::int4range from generate_series(1,500) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 245 +insert into test_range_spgist select int4range(g, g+10000) from generate_series(1,1000) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 246 +insert into test_range_spgist select 'empty'::int4range from generate_series(1,500) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 247 +insert into test_range_spgist select int4range(NULL,g*10,'(]') from generate_series(1,100) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 248 +insert into test_range_spgist select int4range(g*10,NULL,'(]') from generate_series(1,100) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 249 +insert into test_range_spgist select int4range(g, g+10) from generate_series(1,2000) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 250 +-- first, verify non-indexed results +SET enable_seqscan = t +-- +STMT: VariableSetStmt +== 251 +SET enable_indexscan = f +-- +STMT: VariableSetStmt +== 252 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +== 253 +select count(*) from test_range_spgist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 254 +select count(*) from test_range_spgist where ir = int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 255 +select count(*) from test_range_spgist where ir @> 10 +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 256 +select count(*) from test_range_spgist where ir @> int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 257 +select count(*) from test_range_spgist where ir && int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 258 +select count(*) from test_range_spgist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 259 +select count(*) from test_range_spgist where ir << int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 260 +select count(*) from test_range_spgist where ir >> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 261 +select count(*) from test_range_spgist where ir &< int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 262 +select count(*) from test_range_spgist where ir &> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 263 +select count(*) from test_range_spgist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 264 +-- now check same queries using index +SET enable_seqscan = f +-- +STMT: VariableSetStmt +== 265 +SET enable_indexscan = t +-- +STMT: VariableSetStmt +== 266 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +== 267 +select count(*) from test_range_spgist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 268 +select count(*) from test_range_spgist where ir = int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 269 +select count(*) from test_range_spgist where ir @> 10 +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 270 +select count(*) from test_range_spgist where ir @> int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 271 +select count(*) from test_range_spgist where ir && int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 272 +select count(*) from test_range_spgist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 273 +select count(*) from test_range_spgist where ir << int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 274 +select count(*) from test_range_spgist where ir >> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 275 +select count(*) from test_range_spgist where ir &< int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 276 +select count(*) from test_range_spgist where ir &> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 277 +select count(*) from test_range_spgist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 278 +-- now check same queries using a bulk-loaded index +drop index test_range_spgist_idx +-- +STMT: DropStmt +== 279 +create index test_range_spgist_idx on test_range_spgist using spgist (ir) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DDL +STMT: IndexStmt +== 280 +select count(*) from test_range_spgist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 281 +select count(*) from test_range_spgist where ir = int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 282 +select count(*) from test_range_spgist where ir @> 10 +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 283 +select count(*) from test_range_spgist where ir @> int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 284 +select count(*) from test_range_spgist where ir && int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 285 +select count(*) from test_range_spgist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 286 +select count(*) from test_range_spgist where ir << int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 287 +select count(*) from test_range_spgist where ir >> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 288 +select count(*) from test_range_spgist where ir &< int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 289 +select count(*) from test_range_spgist where ir &> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 290 +select count(*) from test_range_spgist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 291 +-- test index-only scans +explain (costs off) +select ir from test_range_spgist where ir -|- int4range(10,20) order by ir +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: ExplainStmt +STMT: SelectStmt +== 292 +select ir from test_range_spgist where ir -|- int4range(10,20) order by ir +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +== 293 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 294 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 295 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 296 +-- test elem <@ range operator +create table test_range_elem(i int4) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DDL +STMT: CreateStmt +== 297 +create index test_range_elem_idx on test_range_elem (i) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DDL +STMT: IndexStmt +== 298 +insert into test_range_elem select i from generate_series(1,100) i +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 299 +SET enable_seqscan = f +-- +STMT: VariableSetStmt +== 300 +select count(*) from test_range_elem where i <@ int4range(10,50) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 301 +-- also test spgist index on anyrange expression +create index on test_range_elem using spgist(int4range(i,i+10)) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DDL +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: IndexStmt +== 302 +explain (costs off) +select count(*) from test_range_elem where int4range(i,i+10) <@ int4range(10,30) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +== 303 +select count(*) from test_range_elem where int4range(i,i+10) <@ int4range(10,30) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 304 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 305 +drop table test_range_elem +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DDL +STMT: DropStmt +== 306 +|-- +-- Btree_gist is not included by default, so to test exclusion +-- constraints with range types, use singleton int ranges for the "=" +-- portion of the constraint. +|-- + +create table test_range_excl( + room int4range, + speaker int4range, + during tsrange, + exclude using gist (room with =, during with &&), + exclude using gist (speaker with =, during with &&) +) +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DDL +STMT: CreateStmt +== 307 +insert into test_range_excl + values(int4range(123, 123, '[]'), int4range(1, 1, '[]'), '[2010-01-02 10:00, 2010-01-02 11:00)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 308 +insert into test_range_excl + values(int4range(123, 123, '[]'), int4range(2, 2, '[]'), '[2010-01-02 11:00, 2010-01-02 12:00)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 309 +insert into test_range_excl + values(int4range(123, 123, '[]'), int4range(3, 3, '[]'), '[2010-01-02 10:10, 2010-01-02 11:00)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 310 +insert into test_range_excl + values(int4range(124, 124, '[]'), int4range(3, 3, '[]'), '[2010-01-02 10:10, 2010-01-02 11:10)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 311 +insert into test_range_excl + values(int4range(125, 125, '[]'), int4range(1, 1, '[]'), '[2010-01-02 10:10, 2010-01-02 11:00)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 312 +-- test bigint ranges +select int8range(10000000000::int8, 20000000000::int8,'(]') +-- +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +STMT: SelectStmt +== 313 +-- test tstz ranges +set timezone to '-08' +-- +STMT: VariableSetStmt +== 314 +select '[2010-01-01 01:00:00 -05, 2010-01-01 02:00:00 -08)'::tstzrange +-- +STMT: SelectStmt +== 315 +-- should fail +select '[2010-01-01 01:00:00 -08, 2010-01-01 02:00:00 -05)'::tstzrange +-- +STMT: SelectStmt +== 316 +set timezone to default +-- +STMT: VariableSetStmt +== 317 +|-- +-- Test user-defined range of floats +-- (type float8range was already made in test_setup.sql) +|-- + +--should fail +create type bogus_float8range as range (subtype=float8, subtype_diff=float4mi) +-- +STMT: CreateRangeStmt +== 318 +select '[123.001, 5.e9)'::float8range @> 888.882::float8 +-- +STMT: SelectStmt +== 319 +create table float8range_test(f8r float8range, i int) +-- +TABLE: name="float8range_test" schema="" table="float8range_test" ctx=DDL +STMT: CreateStmt +== 320 +insert into float8range_test values(float8range(-100.00007, '1.111113e9'), 42) +-- +TABLE: name="float8range_test" schema="" table="float8range_test" ctx=DML +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 321 +select * from float8range_test +-- +TABLE: name="float8range_test" schema="" table="float8range_test" ctx=Select +STMT: SelectStmt +== 322 +drop table float8range_test +-- +TABLE: name="float8range_test" schema="" table="float8range_test" ctx=DDL +STMT: DropStmt +== 323 +|-- +-- Test range types over domains +|-- + +create domain mydomain as int4 +-- +STMT: CreateDomainStmt +== 324 +create type mydomainrange as range(subtype=mydomain) +-- +STMT: CreateRangeStmt +== 325 +select '[4,50)'::mydomainrange @> 7::mydomain +-- +STMT: SelectStmt +== 326 +drop domain mydomain +-- +STMT: DropStmt +== 327 +-- fail +drop domain mydomain cascade +-- +STMT: DropStmt +== 328 +|-- +-- Test domains over range types +|-- + +create domain restrictedrange as int4range check (upper(value) < 10) +-- +STMT: CreateDomainStmt +== 329 +select '[4,5)'::restrictedrange @> 7 +-- +STMT: SelectStmt +== 330 +select '[4,50)'::restrictedrange @> 7 +-- +STMT: SelectStmt +== 331 +-- should fail +drop domain restrictedrange +-- +STMT: DropStmt +== 332 +|-- +-- Test multiple range types over the same subtype +|-- + +create type textrange1 as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +== 333 +create type textrange2 as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +== 334 +select textrange1('a','Z') @> 'b'::text +-- +FUNCTION: name="textrange1" function="textrange1" schema="" ctx=Call +STMT: SelectStmt +== 335 +select textrange2('a','z') @> 'b'::text +-- +FUNCTION: name="textrange2" function="textrange2" schema="" ctx=Call +STMT: SelectStmt +== 336 +drop type textrange1 +-- +STMT: DropStmt +== 337 +drop type textrange2 +-- +STMT: DropStmt +== 338 +|-- +-- Test polymorphic type system +|-- + +create function anyarray_anyrange_func(a anyarray, r anyrange) + returns anyelement as 'select $1[1] + lower($2);' language sql +-- +FUNCTION: name="anyarray_anyrange_func" function="anyarray_anyrange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 339 +select anyarray_anyrange_func(ARRAY[1,2], int4range(10,20)) +-- +FUNCTION: name="anyarray_anyrange_func" function="anyarray_anyrange_func" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 340 +-- should fail +select anyarray_anyrange_func(ARRAY[1,2], numrange(10,20)) +-- +FUNCTION: name="anyarray_anyrange_func" function="anyarray_anyrange_func" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 341 +drop function anyarray_anyrange_func(anyarray, anyrange) +-- +FUNCTION: name="anyarray_anyrange_func" function="anyarray_anyrange_func" schema="" ctx=DDL +STMT: DropStmt +== 342 +-- should fail +create function bogus_func(anyelement) + returns anyrange as 'select int4range(1,10)' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 343 +-- should fail +create function bogus_func(int) + returns anyrange as 'select int4range(1,10)' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 344 +create function range_add_bounds(anyrange) + returns anyelement as 'select lower($1) + upper($1)' language sql +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 345 +select range_add_bounds(int4range(1, 17)) +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 346 +select range_add_bounds(numrange(1.0001, 123.123)) +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 347 +create function rangetypes_sql(q anyrange, b anyarray, out c anyelement) + as $$ select upper($1) + $2[1] $$ + language sql +-- +FUNCTION: name="rangetypes_sql" function="rangetypes_sql" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 348 +select rangetypes_sql(int4range(1,10), ARRAY[2,20]) +-- +FUNCTION: name="rangetypes_sql" function="rangetypes_sql" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 349 +select rangetypes_sql(numrange(1,10), ARRAY[2,20]) +-- +FUNCTION: name="rangetypes_sql" function="rangetypes_sql" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 350 +-- match failure + +create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange) + returns anycompatible as 'select $1[1] + lower($2);' language sql +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 351 +select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20)) +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 352 +select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], numrange(10,20)) +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 353 +-- should fail +select anycompatiblearray_anycompatiblerange_func(ARRAY[1.1,2], int4range(10,20)) +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 354 +drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, anycompatiblerange) +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=DDL +STMT: DropStmt +== 355 +-- should fail +create function bogus_func(anycompatible) + returns anycompatiblerange as 'select int4range(1,10)' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 356 +|-- +-- Arrays of ranges +|-- + +select ARRAY[numrange(1.1, 1.2), numrange(12.3, 155.5)] +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +== 357 +create table i8r_array (f1 int, f2 int8range[]) +-- +TABLE: name="i8r_array" schema="" table="i8r_array" ctx=DDL +STMT: CreateStmt +== 358 +insert into i8r_array values (42, array[int8range(1,10), int8range(2,20)]) +-- +TABLE: name="i8r_array" schema="" table="i8r_array" ctx=DML +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 359 +select * from i8r_array +-- +TABLE: name="i8r_array" schema="" table="i8r_array" ctx=Select +STMT: SelectStmt +== 360 +drop table i8r_array +-- +TABLE: name="i8r_array" schema="" table="i8r_array" ctx=DDL +STMT: DropStmt +== 361 +|-- +-- Ranges of arrays +|-- + +create type arrayrange as range (subtype=int4[]) +-- +STMT: CreateRangeStmt +== 362 +select arrayrange(ARRAY[1,2], ARRAY[2,1]) +-- +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +== 363 +select arrayrange(ARRAY[2,1], ARRAY[1,2]) +-- +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +== 364 +-- fail + +select array[1,1] <@ arrayrange(array[1,2], array[2,1]) +-- +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +== 365 +select array[1,3] <@ arrayrange(array[1,2], array[2,1]) +-- +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +== 366 +|-- +-- Ranges of composites +|-- + +create type two_ints as (a int, b int) +-- +STMT: CompositeTypeStmt +== 367 +create type two_ints_range as range (subtype = two_ints) +-- +STMT: CreateRangeStmt +== 368 +-- with debug_parallel_query on, this exercises tqueue.c's range remapping +select *, row_to_json(upper(t)) as u from + (values (two_ints_range(row(1,2), row(3,4))), + (two_ints_range(row(5,6), row(7,8)))) v(t) +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="two_ints_range" function="two_ints_range" schema="" ctx=Call +FUNCTION: name="two_ints_range" function="two_ints_range" schema="" ctx=Call +STMT: SelectStmt +== 369 +-- this must be rejected to avoid self-inclusion issues: +alter type two_ints add attribute c two_ints_range +-- +TABLE: name="two_ints" schema="" table="two_ints" ctx=DDL +STMT: AlterTableStmt +== 370 +drop type two_ints cascade +-- +STMT: DropStmt +== 371 +|-- +-- Check behavior when subtype lacks a hash function +|-- + +create type varbitrange as range (subtype = varbit) +-- +STMT: CreateRangeStmt +== 372 +set enable_sort = off +-- +STMT: VariableSetStmt +== 373 +-- try to make it pick a hash setop implementation + +select '(01,10)'::varbitrange except select '(10,11)'::varbitrange +-- +STMT: SelectStmt +== 374 +reset enable_sort +-- +STMT: VariableSetStmt +== 375 +|-- +-- OUT/INOUT/TABLE functions +|-- + +-- infer anyrange from anyrange +create function outparam_succeed(i anyrange, out r anyrange, out t text) + as $$ select $1, 'foo'::text $$ language sql +-- +FUNCTION: name="outparam_succeed" function="outparam_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 376 +select * from outparam_succeed(int4range(1,2)) +-- +FUNCTION: name="outparam_succeed" function="outparam_succeed" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 377 +create function outparam2_succeed(r anyrange, out lu anyarray, out ul anyarray) + as $$ select array[lower($1), upper($1)], array[upper($1), lower($1)] $$ + language sql +-- +FUNCTION: name="outparam2_succeed" function="outparam2_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 378 +select * from outparam2_succeed(int4range(1,11)) +-- +FUNCTION: name="outparam2_succeed" function="outparam2_succeed" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 379 +-- infer anyarray from anyrange +create function outparam_succeed2(i anyrange, out r anyarray, out t text) + as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql +-- +FUNCTION: name="outparam_succeed2" function="outparam_succeed2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 380 +select * from outparam_succeed2(int4range(int4range(1,2))) +-- +FUNCTION: name="outparam_succeed2" function="outparam_succeed2" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 381 +-- infer anyelement from anyrange +create function inoutparam_succeed(out i anyelement, inout r anyrange) + as $$ select upper($1), $1 $$ language sql +-- +FUNCTION: name="inoutparam_succeed" function="inoutparam_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 382 +select * from inoutparam_succeed(int4range(1,2)) +-- +FUNCTION: name="inoutparam_succeed" function="inoutparam_succeed" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 383 +create function table_succeed(r anyrange) + returns table(l anyelement, u anyelement) + as $$ select lower($1), upper($1) $$ + language sql +-- +FUNCTION: name="table_succeed" function="table_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 384 +select * from table_succeed(int4range(1,11)) +-- +FUNCTION: name="table_succeed" function="table_succeed" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +== 385 +-- should fail +create function outparam_fail(i anyelement, out r anyrange, out t text) + as $$ select '[1,10]', 'foo' $$ language sql +-- +FUNCTION: name="outparam_fail" function="outparam_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 386 +--should fail +create function inoutparam_fail(inout i anyelement, out r anyrange) + as $$ select $1, '[1,10]' $$ language sql +-- +FUNCTION: name="inoutparam_fail" function="inoutparam_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 387 +--should fail +create function table_fail(i anyelement) returns table(i anyelement, r anyrange) + as $$ select $1, '[1,10]' $$ language sql +-- +FUNCTION: name="table_fail" function="table_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 388 +|-- +-- Test support functions +|-- + +-- empty range +explain (verbose, costs off) +select current_date <@ daterange 'empty' +-- +STMT: ExplainStmt +STMT: SelectStmt +== 389 +-- unbounded range +explain (verbose, costs off) +select current_date <@ daterange(NULL, NULL) +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 390 +-- only lower bound present +explain (verbose, costs off) +select current_date <@ daterange('2000-01-01', NULL, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 391 +-- only upper bound present +explain (verbose, costs off) +select current_date <@ daterange(NULL, '2000-01-01', '(]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 392 +-- lower range "-Infinity" excluded +explain (verbose, costs off) +select current_date <@ daterange('-Infinity', '1997-04-10'::date, '()') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 393 +-- lower range "-Infinity" included +explain (verbose, costs off) +select current_date <@ daterange('-Infinity', '1997-04-10'::date, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 394 +-- upper range "Infinity" excluded +explain (verbose, costs off) +select current_date <@ daterange('2002-09-25'::date, 'Infinity', '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 395 +-- upper range "Infinity" included +explain (verbose, costs off) +select current_date <@ daterange('2002-09-25'::date, 'Infinity', '[]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 396 +-- should also work if we use "@>" +explain (verbose, costs off) +select daterange('-Infinity', '1997-04-10'::date, '()') @> current_date +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 397 +explain (verbose, costs off) +select daterange('2002-09-25'::date, 'Infinity', '[]') @> current_date +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 398 +-- Check that volatile cases are not optimized +explain (verbose, costs off) +select now() <@ tstzrange('2024-01-20 00:00', '2024-01-21 00:00') +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="tstzrange" function="tstzrange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 399 +explain (verbose, costs off) -- unsafe! +select clock_timestamp() <@ tstzrange('2024-01-20 00:00', '2024-01-21 00:00') +-- +FUNCTION: name="clock_timestamp" function="clock_timestamp" schema="" ctx=Call +FUNCTION: name="tstzrange" function="tstzrange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 400 +explain (verbose, costs off) +select clock_timestamp() <@ tstzrange('2024-01-20 00:00', NULL) +-- +FUNCTION: name="clock_timestamp" function="clock_timestamp" schema="" ctx=Call +FUNCTION: name="tstzrange" function="tstzrange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 401 +-- test a custom range type with a non-default operator class +create type textrange_supp as range ( + subtype = text, + subtype_opclass = text_pattern_ops +) +-- +STMT: CreateRangeStmt +== 402 +create temp table text_support_test (t text collate "C") +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=DDL +STMT: CreateStmt +== 403 +insert into text_support_test values ('a'), ('c'), ('d'), ('ch') +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 404 +explain (costs off) +select * from text_support_test where t <@ textrange_supp('a', 'd') +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=Select +FUNCTION: name="textrange_supp" function="textrange_supp" schema="" ctx=Call +FUNCTION: name="textrange_supp" function="textrange_supp" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 405 +select * from text_support_test where t <@ textrange_supp('a', 'd') +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=Select +FUNCTION: name="textrange_supp" function="textrange_supp" schema="" ctx=Call +FUNCTION: name="textrange_supp" function="textrange_supp" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +== 406 +drop table text_support_test +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=DDL +STMT: DropStmt +== 407 +drop type textrange_supp +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/regex.metadata.json b/parser/testdata/summary/postgres_regress/regex.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/regex.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/regex.test b/parser/testdata/summary/postgres_regress/regex.test new file mode 100644 index 0000000..13b7095 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/regex.test @@ -0,0 +1,527 @@ +== 001 +|-- +-- Regular expression tests +|-- + +-- Don't want to have to double backslashes in regexes +set standard_conforming_strings = on +-- +STMT: VariableSetStmt +== 002 +-- Test simple quantified backrefs +select 'bbbbb' ~ '^([bc])\1*$' as t +-- +STMT: SelectStmt +== 003 +select 'ccc' ~ '^([bc])\1*$' as t +-- +STMT: SelectStmt +== 004 +select 'xxx' ~ '^([bc])\1*$' as f +-- +STMT: SelectStmt +== 005 +select 'bbc' ~ '^([bc])\1*$' as f +-- +STMT: SelectStmt +== 006 +select 'b' ~ '^([bc])\1*$' as t +-- +STMT: SelectStmt +== 007 +-- Test quantified backref within a larger expression +select 'abc abc abc' ~ '^(\w+)( \1)+$' as t +-- +STMT: SelectStmt +== 008 +select 'abc abd abc' ~ '^(\w+)( \1)+$' as f +-- +STMT: SelectStmt +== 009 +select 'abc abc abd' ~ '^(\w+)( \1)+$' as f +-- +STMT: SelectStmt +== 010 +select 'abc abc abc' ~ '^(.+)( \1)+$' as t +-- +STMT: SelectStmt +== 011 +select 'abc abd abc' ~ '^(.+)( \1)+$' as f +-- +STMT: SelectStmt +== 012 +select 'abc abc abd' ~ '^(.+)( \1)+$' as f +-- +STMT: SelectStmt +== 013 +-- Test some cases that crashed in 9.2beta1 due to pmatch[] array overrun +select substring('asd TO foo' from ' TO (([a-z0-9._]+|"([^"]+|"")+")+)') +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 014 +select substring('a' from '((a))+') +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 015 +select substring('a' from '((a)+)') +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 016 +-- Test regexp_match() +select regexp_match('abc', '') +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +== 017 +select regexp_match('abc', 'bc') +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +== 018 +select regexp_match('abc', 'd') is null +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +== 019 +select regexp_match('abc', '(B)(c)', 'i') +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +== 020 +select regexp_match('abc', 'Bd', 'ig') +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +== 021 +-- error + +-- Test lookahead constraints +select regexp_matches('ab', 'a(?=b)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 022 +select regexp_matches('a', 'a(?=b)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 023 +select regexp_matches('abc', 'a(?=b)b*(?=c)c*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 024 +select regexp_matches('ab', 'a(?=b)b*(?=c)c*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 025 +select regexp_matches('ab', 'a(?!b)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 026 +select regexp_matches('a', 'a(?!b)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 027 +select regexp_matches('b', '(?=b)b') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 028 +select regexp_matches('a', '(?=b)b') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 029 +-- Test lookbehind constraints +select regexp_matches('abb', '(?<=a)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 030 +select regexp_matches('a', 'a(?<=a)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 031 +select regexp_matches('abc', 'a(?<=a)b*(?<=b)c*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 032 +select regexp_matches('ab', 'a(?<=a)b*(?<=b)c*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +== 033 +select regexp_matches('ab', 'a*(? 0 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT reloptions FROM pg_class WHERE oid = + (SELECT reltoastrelid FROM pg_class + WHERE oid = 'reloptions_test'::regclass) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 038 +ALTER TABLE reloptions_test RESET (vacuum_truncate) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: AlterTableStmt +== 039 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 040 +INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +-- Do an aggressive vacuum to prevent page-skipping. +VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) reloptions_test +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: VacuumStmt +== 042 +SELECT pg_relation_size('reloptions_test') = 0 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +== 043 +-- Test toast.* options +DROP TABLE reloptions_test +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: DropStmt +== 044 +CREATE TABLE reloptions_test (s VARCHAR) + WITH (toast.autovacuum_vacuum_cost_delay = 23) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: CreateStmt +== 045 +SELECT reltoastrelid as toast_oid + FROM pg_class WHERE oid = 'reloptions_test'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 046 +SELECT reloptions FROM pg_class WHERE oid = :toast_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 45 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 047 +ALTER TABLE reloptions_test SET (toast.autovacuum_vacuum_cost_delay = 24) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: AlterTableStmt +== 048 +SELECT reloptions FROM pg_class WHERE oid = :toast_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 45 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 049 +ALTER TABLE reloptions_test RESET (toast.autovacuum_vacuum_cost_delay) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: AlterTableStmt +== 050 +SELECT reloptions FROM pg_class WHERE oid = :toast_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 45 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 051 +-- Fail on non-existent options in toast namespace +CREATE TABLE reloptions_test2 (i int) WITH (toast.not_existing_option = 42) +-- +TABLE: name="reloptions_test2" schema="" table="reloptions_test2" ctx=DDL +STMT: CreateStmt +== 052 +-- Mix TOAST & heap +DROP TABLE reloptions_test +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: DropStmt +== 053 +CREATE TABLE reloptions_test (s VARCHAR) WITH + (toast.autovacuum_vacuum_cost_delay = 23, + autovacuum_vacuum_cost_delay = 24, fillfactor = 40) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: CreateStmt +== 054 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 055 +SELECT reloptions FROM pg_class WHERE oid = ( + SELECT reltoastrelid FROM pg_class WHERE oid = 'reloptions_test'::regclass) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 056 +|-- +-- CREATE INDEX, ALTER INDEX for btrees +|-- + +CREATE INDEX reloptions_test_idx ON reloptions_test (s) WITH (fillfactor=30) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +== 057 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 058 +-- Fail when option and namespace do not exist +CREATE INDEX reloptions_test_idx ON reloptions_test (s) + WITH (not_existing_option=2) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +== 059 +CREATE INDEX reloptions_test_idx ON reloptions_test (s) + WITH (not_existing_ns.fillfactor=2) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +== 060 +-- Check allowed ranges +CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=1) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +== 061 +CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=130) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +== 062 +-- Check ALTER +ALTER INDEX reloptions_test_idx SET (fillfactor=40) +-- +STMT: AlterTableStmt +== 063 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 064 +-- Check ALTER on empty reloption list +CREATE INDEX reloptions_test_idx3 ON reloptions_test (s) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +== 065 +ALTER INDEX reloptions_test_idx3 SET (fillfactor=40) +-- +STMT: AlterTableStmt +== 066 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx3'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/replica_identity.metadata.json b/parser/testdata/summary/postgres_regress/replica_identity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/replica_identity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/replica_identity.test b/parser/testdata/summary/postgres_regress/replica_identity.test new file mode 100644 index 0000000..6407b70 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/replica_identity.test @@ -0,0 +1,342 @@ +== 001 +CREATE TABLE test_replica_identity ( + id serial primary key, + keya text not null, + keyb text not null, + nonkey text, + CONSTRAINT test_replica_identity_unique_defer UNIQUE (keya, keyb) DEFERRABLE, + CONSTRAINT test_replica_identity_unique_nondefer UNIQUE (keya, keyb) +) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE test_replica_identity_othertable (id serial primary key) +-- +TABLE: name="test_replica_identity_othertable" schema="" table="test_replica_identity_othertable" ctx=DDL +STMT: CreateStmt +== 003 +CREATE TABLE test_replica_identity_t3 (id serial constraint pk primary key deferrable) +-- +TABLE: name="test_replica_identity_t3" schema="" table="test_replica_identity_t3" ctx=DDL +STMT: CreateStmt +== 004 +CREATE INDEX test_replica_identity_keyab ON test_replica_identity (keya, keyb) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +== 005 +CREATE UNIQUE INDEX test_replica_identity_keyab_key ON test_replica_identity (keya, keyb) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +== 006 +CREATE UNIQUE INDEX test_replica_identity_nonkey ON test_replica_identity (keya, nonkey) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +== 007 +CREATE INDEX test_replica_identity_hash ON test_replica_identity USING hash (nonkey) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +== 008 +CREATE UNIQUE INDEX test_replica_identity_expr ON test_replica_identity (keya, keyb, (3)) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +== 009 +CREATE UNIQUE INDEX test_replica_identity_partial ON test_replica_identity (keya, keyb) WHERE keyb != '3' +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +== 010 +-- default is 'd'/DEFAULT for user created tables +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 011 +-- but 'none' for system tables +SELECT relreplident FROM pg_class WHERE oid = 'pg_class'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 012 +SELECT relreplident FROM pg_class WHERE oid = 'pg_constraint'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 013 +---- +-- Make sure we detect ineligible indexes +---- + +-- fail, not unique +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 014 +-- fail, not a candidate key, nullable column +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_nonkey +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 015 +-- fail, hash indexes cannot do uniqueness +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_hash +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 016 +-- fail, expression index +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_expr +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 017 +-- fail, partial index +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_partial +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 018 +-- fail, not our index +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_othertable_pkey +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 019 +-- fail, deferrable +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_unique_defer +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 020 +-- fail, deferrable +ALTER TABLE test_replica_identity_t3 REPLICA IDENTITY USING INDEX pk +-- +TABLE: name="test_replica_identity_t3" schema="" table="test_replica_identity_t3" ctx=DDL +STMT: AlterTableStmt +== 021 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 022 +---- +-- Make sure index cases succeed +---- + +-- succeed, primary key +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_pkey +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 023 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 024 +-- succeed, nondeferrable unique constraint over nonnullable cols +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_unique_nondefer +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 025 +-- succeed unique index over nonnullable cols +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab_key +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 026 +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab_key +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 027 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 028 +SELECT count(*) FROM pg_index WHERE indrelid = 'test_replica_identity'::regclass AND indisreplident +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="indisreplident" +STMT: SelectStmt +== 029 +---- +-- Make sure non index cases work +---- +ALTER TABLE test_replica_identity REPLICA IDENTITY DEFAULT +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 030 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 031 +SELECT count(*) FROM pg_index WHERE indrelid = 'test_replica_identity'::regclass AND indisreplident +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="indisreplident" +STMT: SelectStmt +== 032 +ALTER TABLE test_replica_identity REPLICA IDENTITY FULL +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 033 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 034 +ALTER TABLE test_replica_identity REPLICA IDENTITY NOTHING +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +== 035 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 036 +--- +-- Test that ALTER TABLE rewrite preserves nondefault replica identity +--- + +-- constraint variant +CREATE TABLE test_replica_identity2 (id int UNIQUE NOT NULL) +-- +TABLE: name="test_replica_identity2" schema="" table="test_replica_identity2" ctx=DDL +STMT: CreateStmt +== 037 +ALTER TABLE test_replica_identity2 REPLICA IDENTITY USING INDEX test_replica_identity2_id_key +-- +TABLE: name="test_replica_identity2" schema="" table="test_replica_identity2" ctx=DDL +STMT: AlterTableStmt +== 038 +ALTER TABLE test_replica_identity2 ALTER COLUMN id TYPE bigint +-- +TABLE: name="test_replica_identity2" schema="" table="test_replica_identity2" ctx=DDL +STMT: AlterTableStmt +== 039 +-- straight index variant +CREATE TABLE test_replica_identity3 (id int NOT NULL) +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: CreateStmt +== 040 +CREATE UNIQUE INDEX test_replica_identity3_id_key ON test_replica_identity3 (id) +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: IndexStmt +== 041 +ALTER TABLE test_replica_identity3 REPLICA IDENTITY USING INDEX test_replica_identity3_id_key +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: AlterTableStmt +== 042 +ALTER TABLE test_replica_identity3 ALTER COLUMN id TYPE bigint +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: AlterTableStmt +== 043 +-- ALTER TABLE DROP NOT NULL is not allowed for columns part of an index +-- used as replica identity. +ALTER TABLE test_replica_identity3 ALTER COLUMN id DROP NOT NULL +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: AlterTableStmt +== 044 +|-- +-- Test that replica identity can be set on an index that's not yet valid. +-- (This matches the way pg_dump will try to dump a partitioned table.) +|-- +CREATE TABLE test_replica_identity4(id integer NOT NULL) PARTITION BY LIST (id) +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: CreateStmt +== 045 +CREATE TABLE test_replica_identity4_1(id integer NOT NULL) +-- +TABLE: name="test_replica_identity4_1" schema="" table="test_replica_identity4_1" ctx=DDL +STMT: CreateStmt +== 046 +ALTER TABLE ONLY test_replica_identity4 + ATTACH PARTITION test_replica_identity4_1 FOR VALUES IN (1) +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: AlterTableStmt +== 047 +ALTER TABLE ONLY test_replica_identity4 + ADD CONSTRAINT test_replica_identity4_pkey PRIMARY KEY (id) +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: AlterTableStmt +== 048 +ALTER TABLE ONLY test_replica_identity4 + REPLICA IDENTITY USING INDEX test_replica_identity4_pkey +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: AlterTableStmt +== 049 +ALTER TABLE ONLY test_replica_identity4_1 + ADD CONSTRAINT test_replica_identity4_1_pkey PRIMARY KEY (id) +-- +TABLE: name="test_replica_identity4_1" schema="" table="test_replica_identity4_1" ctx=DDL +STMT: AlterTableStmt +== 050 +ALTER INDEX test_replica_identity4_pkey + ATTACH PARTITION test_replica_identity4_1_pkey +-- +STMT: AlterTableStmt +== 051 +DROP TABLE test_replica_identity +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: DropStmt +== 052 +DROP TABLE test_replica_identity2 +-- +TABLE: name="test_replica_identity2" schema="" table="test_replica_identity2" ctx=DDL +STMT: DropStmt +== 053 +DROP TABLE test_replica_identity3 +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: DropStmt +== 054 +DROP TABLE test_replica_identity4 +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: DropStmt +== 055 +DROP TABLE test_replica_identity_othertable +-- +TABLE: name="test_replica_identity_othertable" schema="" table="test_replica_identity_othertable" ctx=DDL +STMT: DropStmt +== 056 +DROP TABLE test_replica_identity_t3 +-- +TABLE: name="test_replica_identity_t3" schema="" table="test_replica_identity_t3" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/returning.metadata.json b/parser/testdata/summary/postgres_regress/returning.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/returning.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/returning.test b/parser/testdata/summary/postgres_regress/returning.test new file mode 100644 index 0000000..cfda694 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/returning.test @@ -0,0 +1,491 @@ +== 001 +|-- +-- Test INSERT/UPDATE/DELETE RETURNING +|-- + +-- Simple cases + +CREATE TEMP TABLE foo (f1 serial, f2 text, f3 int default 42) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO foo (f2,f3) + VALUES ('test', DEFAULT), ('More', 11), (upper('more'), 7+9) + RETURNING *, f1+f3 AS sum +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 004 +UPDATE foo SET f2 = lower(f2), f3 = DEFAULT RETURNING foo.*, f1+f3 AS sum13 +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: UpdateStmt +== 005 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 006 +DELETE FROM foo WHERE f1 > 2 RETURNING f3, f2, f1, least(f1,f3) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: DeleteStmt +== 007 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 008 +-- Subplans and initplans in the RETURNING list + +INSERT INTO foo SELECT f1+10, f2, f3+99 FROM foo + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 009 +UPDATE foo SET f3 = f3 * 2 + WHERE f1 > 10 + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +== 010 +DELETE FROM foo + WHERE f1 > 10 + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: DeleteStmt +STMT: SelectStmt +== 011 +-- Joins + +UPDATE foo SET f3 = f3*2 + FROM int4_tbl i + WHERE foo.f1 + 123455 = i.f1 + RETURNING foo.*, i.f1 as "i.f1" +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: UpdateStmt +== 012 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 013 +DELETE FROM foo + USING int4_tbl i + WHERE foo.f1 + 123455 = i.f1 + RETURNING foo.*, i.f1 as "i.f1" +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: DeleteStmt +== 014 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 015 +-- Check inheritance cases + +CREATE TEMP TABLE foochild (fc int) INHERITS (foo) +-- +TABLE: name="foochild" schema="" table="foochild" ctx=DDL +STMT: CreateStmt +== 016 +INSERT INTO foochild VALUES(123,'child',999,-123) +-- +TABLE: name="foochild" schema="" table="foochild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +ALTER TABLE foo ADD COLUMN f4 int8 DEFAULT 99 +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: AlterTableStmt +== 018 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 019 +SELECT * FROM foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=Select +STMT: SelectStmt +== 020 +UPDATE foo SET f4 = f4 + f3 WHERE f4 = 99 RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: UpdateStmt +== 021 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 022 +SELECT * FROM foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=Select +STMT: SelectStmt +== 023 +UPDATE foo SET f3 = f3*2 + FROM int8_tbl i + WHERE foo.f1 = i.q2 + RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: UpdateStmt +== 024 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 025 +SELECT * FROM foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=Select +STMT: SelectStmt +== 026 +DELETE FROM foo + USING int8_tbl i + WHERE foo.f1 = i.q2 + RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: DeleteStmt +== 027 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 028 +SELECT * FROM foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=Select +STMT: SelectStmt +== 029 +DROP TABLE foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=DDL +STMT: DropStmt +== 030 +-- Rules and views + +CREATE TEMP VIEW voo AS SELECT f1, f2 FROM foo +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 031 +CREATE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57) +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +== 032 +INSERT INTO voo VALUES(11,'zit') +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +-- fails: +INSERT INTO voo VALUES(12,'zoo') RETURNING *, f1*2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +-- fails, incompatible list: +CREATE OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57) RETURNING * +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +== 035 +CREATE OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57) RETURNING f1, f2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +== 036 +-- should still work +INSERT INTO voo VALUES(13,'zit2') +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +-- works now +INSERT INTO voo VALUES(14,'zoo2') RETURNING * +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 039 +SELECT * FROM voo +-- +TABLE: name="voo" schema="" table="voo" ctx=Select +STMT: SelectStmt +== 040 +CREATE OR REPLACE RULE voo_u AS ON UPDATE TO voo DO INSTEAD + UPDATE foo SET f1 = new.f1, f2 = new.f2 WHERE f1 = old.f1 + RETURNING f1, f2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +== 041 +update voo set f1 = f1 + 1 where f2 = 'zoo2' +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: UpdateStmt +== 042 +update voo set f1 = f1 + 1 where f2 = 'zoo2' RETURNING *, f1*2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: UpdateStmt +== 043 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 044 +SELECT * FROM voo +-- +TABLE: name="voo" schema="" table="voo" ctx=Select +STMT: SelectStmt +== 045 +CREATE OR REPLACE RULE voo_d AS ON DELETE TO voo DO INSTEAD + DELETE FROM foo WHERE f1 = old.f1 + RETURNING f1, f2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +== 046 +DELETE FROM foo WHERE f1 = 13 +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: DeleteStmt +== 047 +DELETE FROM foo WHERE f2 = 'zit' RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: DeleteStmt +== 048 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 049 +SELECT * FROM voo +-- +TABLE: name="voo" schema="" table="voo" ctx=Select +STMT: SelectStmt +== 050 +-- Check use of a whole-row variable for an un-flattenable view +CREATE TEMP VIEW foo_v AS SELECT * FROM foo OFFSET 0 +-- +TABLE: name="foo_v" schema="" table="foo_v" ctx=DDL +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 051 +UPDATE foo SET f2 = foo_v.f2 FROM foo_v WHERE foo_v.f1 = foo.f1 + RETURNING foo_v +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="foo_v" schema="" table="foo_v" ctx=Select +STMT: UpdateStmt +== 052 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 053 +-- Check use of a whole-row variable for an inlined set-returning function +CREATE FUNCTION foo_f() RETURNS SETOF foo AS + $$ SELECT * FROM foo OFFSET 0 $$ LANGUAGE sql STABLE +-- +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 054 +UPDATE foo SET f2 = foo_f.f2 FROM foo_f() WHERE foo_f.f1 = foo.f1 + RETURNING foo_f +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=Call +STMT: UpdateStmt +== 055 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 056 +DROP FUNCTION foo_f() +-- +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=DDL +STMT: DropStmt +== 057 +-- As above, but SRF is defined to return a composite type +CREATE TYPE foo_t AS (f1 int, f2 text, f3 int, f4 int8) +-- +STMT: CompositeTypeStmt +== 058 +CREATE FUNCTION foo_f() RETURNS SETOF foo_t AS + $$ SELECT * FROM foo OFFSET 0 $$ LANGUAGE sql STABLE +-- +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 059 +UPDATE foo SET f2 = foo_f.f2 FROM foo_f() WHERE foo_f.f1 = foo.f1 + RETURNING foo_f +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=Call +STMT: UpdateStmt +== 060 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 061 +DROP FUNCTION foo_f() +-- +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=DDL +STMT: DropStmt +== 062 +DROP TYPE foo_t +-- +STMT: DropStmt +== 063 +-- Try a join case + +CREATE TEMP TABLE joinme (f2j text, other int) +-- +TABLE: name="joinme" schema="" table="joinme" ctx=DDL +STMT: CreateStmt +== 064 +INSERT INTO joinme VALUES('more', 12345) +-- +TABLE: name="joinme" schema="" table="joinme" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +INSERT INTO joinme VALUES('zoo2', 54321) +-- +TABLE: name="joinme" schema="" table="joinme" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 066 +INSERT INTO joinme VALUES('other', 0) +-- +TABLE: name="joinme" schema="" table="joinme" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +CREATE TEMP VIEW joinview AS + SELECT foo.*, other FROM foo JOIN joinme ON (f2 = f2j) +-- +TABLE: name="joinview" schema="" table="joinview" ctx=DDL +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="joinme" schema="" table="joinme" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 068 +SELECT * FROM joinview +-- +TABLE: name="joinview" schema="" table="joinview" ctx=Select +STMT: SelectStmt +== 069 +CREATE RULE joinview_u AS ON UPDATE TO joinview DO INSTEAD + UPDATE foo SET f1 = new.f1, f3 = new.f3 + FROM joinme WHERE f2 = f2j AND f2 = old.f2 + RETURNING foo.*, other +-- +TABLE: name="joinview" schema="" table="joinview" ctx=DDL +STMT: RuleStmt +== 070 +UPDATE joinview SET f1 = f1 + 1 WHERE f3 = 57 RETURNING *, other + 1 +-- +TABLE: name="joinview" schema="" table="joinview" ctx=DML +STMT: UpdateStmt +== 071 +SELECT * FROM joinview +-- +TABLE: name="joinview" schema="" table="joinview" ctx=Select +STMT: SelectStmt +== 072 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 073 +SELECT * FROM voo +-- +TABLE: name="voo" schema="" table="voo" ctx=Select +STMT: SelectStmt +== 074 +-- Check aliased target relation +INSERT INTO foo AS bar DEFAULT VALUES RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +ALIAS: "bar"="foo" +STMT: InsertStmt +== 075 +-- ok +INSERT INTO foo AS bar DEFAULT VALUES RETURNING foo.* +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +ALIAS: "bar"="foo" +STMT: InsertStmt +== 076 +-- fails, wrong name +INSERT INTO foo AS bar DEFAULT VALUES RETURNING bar.* +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +ALIAS: "bar"="foo" +STMT: InsertStmt +== 077 +-- ok +INSERT INTO foo AS bar DEFAULT VALUES RETURNING bar.f3 +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +ALIAS: "bar"="foo" +STMT: InsertStmt diff --git a/parser/testdata/summary/postgres_regress/roleattributes.metadata.json b/parser/testdata/summary/postgres_regress/roleattributes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/roleattributes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/roleattributes.test b/parser/testdata/summary/postgres_regress/roleattributes.test new file mode 100644 index 0000000..e294b2c --- /dev/null +++ b/parser/testdata/summary/postgres_regress/roleattributes.test @@ -0,0 +1,393 @@ +== 001 +-- default for superuser is false +CREATE ROLE regress_test_def_superuser +-- +STMT: CreateRoleStmt +== 002 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_superuser' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 003 +CREATE ROLE regress_test_superuser WITH SUPERUSER +-- +STMT: CreateRoleStmt +== 004 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_superuser' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 005 +ALTER ROLE regress_test_superuser WITH NOSUPERUSER +-- +STMT: AlterRoleStmt +== 006 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_superuser' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 007 +ALTER ROLE regress_test_superuser WITH SUPERUSER +-- +STMT: AlterRoleStmt +== 008 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_superuser' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 009 +-- default for inherit is true +CREATE ROLE regress_test_def_inherit +-- +STMT: CreateRoleStmt +== 010 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_inherit' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 011 +CREATE ROLE regress_test_inherit WITH NOINHERIT +-- +STMT: CreateRoleStmt +== 012 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_inherit' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 013 +ALTER ROLE regress_test_inherit WITH INHERIT +-- +STMT: AlterRoleStmt +== 014 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_inherit' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 015 +ALTER ROLE regress_test_inherit WITH NOINHERIT +-- +STMT: AlterRoleStmt +== 016 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_inherit' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 017 +-- default for create role is false +CREATE ROLE regress_test_def_createrole +-- +STMT: CreateRoleStmt +== 018 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_createrole' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 019 +CREATE ROLE regress_test_createrole WITH CREATEROLE +-- +STMT: CreateRoleStmt +== 020 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createrole' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 021 +ALTER ROLE regress_test_createrole WITH NOCREATEROLE +-- +STMT: AlterRoleStmt +== 022 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createrole' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 023 +ALTER ROLE regress_test_createrole WITH CREATEROLE +-- +STMT: AlterRoleStmt +== 024 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createrole' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 025 +-- default for create database is false +CREATE ROLE regress_test_def_createdb +-- +STMT: CreateRoleStmt +== 026 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_createdb' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 027 +CREATE ROLE regress_test_createdb WITH CREATEDB +-- +STMT: CreateRoleStmt +== 028 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createdb' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 029 +ALTER ROLE regress_test_createdb WITH NOCREATEDB +-- +STMT: AlterRoleStmt +== 030 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createdb' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 031 +ALTER ROLE regress_test_createdb WITH CREATEDB +-- +STMT: AlterRoleStmt +== 032 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createdb' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 033 +-- default for can login is false for role +CREATE ROLE regress_test_def_role_canlogin +-- +STMT: CreateRoleStmt +== 034 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_role_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 035 +CREATE ROLE regress_test_role_canlogin WITH LOGIN +-- +STMT: CreateRoleStmt +== 036 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_role_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 037 +ALTER ROLE regress_test_role_canlogin WITH NOLOGIN +-- +STMT: AlterRoleStmt +== 038 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_role_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 039 +ALTER ROLE regress_test_role_canlogin WITH LOGIN +-- +STMT: AlterRoleStmt +== 040 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_role_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 041 +-- default for can login is true for user +CREATE USER regress_test_def_user_canlogin +-- +STMT: CreateRoleStmt +== 042 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_user_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 043 +CREATE USER regress_test_user_canlogin WITH NOLOGIN +-- +STMT: CreateRoleStmt +== 044 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_user_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 045 +ALTER USER regress_test_user_canlogin WITH LOGIN +-- +STMT: AlterRoleStmt +== 046 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_user_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 047 +ALTER USER regress_test_user_canlogin WITH NOLOGIN +-- +STMT: AlterRoleStmt +== 048 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_user_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 049 +-- default for replication is false +CREATE ROLE regress_test_def_replication +-- +STMT: CreateRoleStmt +== 050 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_replication' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 051 +CREATE ROLE regress_test_replication WITH REPLICATION +-- +STMT: CreateRoleStmt +== 052 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_replication' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 053 +ALTER ROLE regress_test_replication WITH NOREPLICATION +-- +STMT: AlterRoleStmt +== 054 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_replication' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 055 +ALTER ROLE regress_test_replication WITH REPLICATION +-- +STMT: AlterRoleStmt +== 056 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_replication' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 057 +-- default for bypassrls is false +CREATE ROLE regress_test_def_bypassrls +-- +STMT: CreateRoleStmt +== 058 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_bypassrls' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 059 +CREATE ROLE regress_test_bypassrls WITH BYPASSRLS +-- +STMT: CreateRoleStmt +== 060 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_bypassrls' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 061 +ALTER ROLE regress_test_bypassrls WITH NOBYPASSRLS +-- +STMT: AlterRoleStmt +== 062 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_bypassrls' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 063 +ALTER ROLE regress_test_bypassrls WITH BYPASSRLS +-- +STMT: AlterRoleStmt +== 064 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_bypassrls' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +== 065 +-- clean up roles +DROP ROLE regress_test_def_superuser +-- +STMT: DropRoleStmt +== 066 +DROP ROLE regress_test_superuser +-- +STMT: DropRoleStmt +== 067 +DROP ROLE regress_test_def_inherit +-- +STMT: DropRoleStmt +== 068 +DROP ROLE regress_test_inherit +-- +STMT: DropRoleStmt +== 069 +DROP ROLE regress_test_def_createrole +-- +STMT: DropRoleStmt +== 070 +DROP ROLE regress_test_createrole +-- +STMT: DropRoleStmt +== 071 +DROP ROLE regress_test_def_createdb +-- +STMT: DropRoleStmt +== 072 +DROP ROLE regress_test_createdb +-- +STMT: DropRoleStmt +== 073 +DROP ROLE regress_test_def_role_canlogin +-- +STMT: DropRoleStmt +== 074 +DROP ROLE regress_test_role_canlogin +-- +STMT: DropRoleStmt +== 075 +DROP USER regress_test_def_user_canlogin +-- +STMT: DropRoleStmt +== 076 +DROP USER regress_test_user_canlogin +-- +STMT: DropRoleStmt +== 077 +DROP ROLE regress_test_def_replication +-- +STMT: DropRoleStmt +== 078 +DROP ROLE regress_test_replication +-- +STMT: DropRoleStmt +== 079 +DROP ROLE regress_test_def_bypassrls +-- +STMT: DropRoleStmt +== 080 +DROP ROLE regress_test_bypassrls +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/rowsecurity.metadata.json b/parser/testdata/summary/postgres_regress/rowsecurity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rowsecurity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/rowsecurity.test b/parser/testdata/summary/postgres_regress/rowsecurity.test new file mode 100644 index 0000000..148e48e --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rowsecurity.test @@ -0,0 +1,4822 @@ +== 001 +|-- +-- Test of Row-level security feature +|-- + +-- Clean up in case a prior regression run failed + +-- Suppress NOTICE messages when users/groups don't exist +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +== 002 +DROP USER IF EXISTS regress_rls_alice +-- +STMT: DropRoleStmt +== 003 +DROP USER IF EXISTS regress_rls_bob +-- +STMT: DropRoleStmt +== 004 +DROP USER IF EXISTS regress_rls_carol +-- +STMT: DropRoleStmt +== 005 +DROP USER IF EXISTS regress_rls_dave +-- +STMT: DropRoleStmt +== 006 +DROP USER IF EXISTS regress_rls_exempt_user +-- +STMT: DropRoleStmt +== 007 +DROP ROLE IF EXISTS regress_rls_group1 +-- +STMT: DropRoleStmt +== 008 +DROP ROLE IF EXISTS regress_rls_group2 +-- +STMT: DropRoleStmt +== 009 +DROP SCHEMA IF EXISTS regress_rls_schema CASCADE +-- +STMT: DropStmt +== 010 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 011 +-- initial setup +CREATE USER regress_rls_alice NOLOGIN +-- +STMT: CreateRoleStmt +== 012 +CREATE USER regress_rls_bob NOLOGIN +-- +STMT: CreateRoleStmt +== 013 +CREATE USER regress_rls_carol NOLOGIN +-- +STMT: CreateRoleStmt +== 014 +CREATE USER regress_rls_dave NOLOGIN +-- +STMT: CreateRoleStmt +== 015 +CREATE USER regress_rls_exempt_user BYPASSRLS NOLOGIN +-- +STMT: CreateRoleStmt +== 016 +CREATE ROLE regress_rls_group1 NOLOGIN +-- +STMT: CreateRoleStmt +== 017 +CREATE ROLE regress_rls_group2 NOLOGIN +-- +STMT: CreateRoleStmt +== 018 +GRANT regress_rls_group1 TO regress_rls_bob +-- +STMT: GrantRoleStmt +== 019 +GRANT regress_rls_group2 TO regress_rls_carol +-- +STMT: GrantRoleStmt +== 020 +CREATE SCHEMA regress_rls_schema +-- +STMT: CreateSchemaStmt +== 021 +GRANT ALL ON SCHEMA regress_rls_schema to public +-- +STMT: GrantStmt +== 022 +SET search_path = regress_rls_schema +-- +STMT: VariableSetStmt +== 023 +-- setup of malicious function +CREATE OR REPLACE FUNCTION f_leak(text) RETURNS bool + COST 0.0000001 LANGUAGE plpgsql + AS 'BEGIN RAISE NOTICE ''f_leak => %'', $1; RETURN true; END' +-- +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 024 +GRANT EXECUTE ON FUNCTION f_leak(text) TO public +-- +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=DDL +STMT: GrantStmt +== 025 +-- BASIC Row-Level Security Scenario + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 026 +CREATE TABLE uaccount ( + pguser name primary key, + seclv int +) +-- +TABLE: name="uaccount" schema="" table="uaccount" ctx=DDL +STMT: CreateStmt +== 027 +GRANT SELECT ON uaccount TO public +-- +TABLE: name="uaccount" schema="" table="uaccount" ctx=DDL +STMT: GrantStmt +== 028 +INSERT INTO uaccount VALUES + ('regress_rls_alice', 99), + ('regress_rls_bob', 1), + ('regress_rls_carol', 2), + ('regress_rls_dave', 3) +-- +TABLE: name="uaccount" schema="" table="uaccount" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +CREATE TABLE category ( + cid int primary key, + cname text +) +-- +TABLE: name="category" schema="" table="category" ctx=DDL +STMT: CreateStmt +== 030 +GRANT ALL ON category TO public +-- +TABLE: name="category" schema="" table="category" ctx=DDL +STMT: GrantStmt +== 031 +INSERT INTO category VALUES + (11, 'novel'), + (22, 'science fiction'), + (33, 'technology'), + (44, 'manga') +-- +TABLE: name="category" schema="" table="category" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +CREATE TABLE document ( + did int primary key, + cid int references category(cid), + dlevel int not null, + dauthor name, + dtitle text +) +-- +TABLE: name="document" schema="" table="document" ctx=DDL +STMT: CreateStmt +== 033 +GRANT ALL ON document TO public +-- +TABLE: name="document" schema="" table="document" ctx=DDL +STMT: GrantStmt +== 034 +INSERT INTO document VALUES + ( 1, 11, 1, 'regress_rls_bob', 'my first novel'), + ( 2, 11, 2, 'regress_rls_bob', 'my second novel'), + ( 3, 22, 2, 'regress_rls_bob', 'my science fiction'), + ( 4, 44, 1, 'regress_rls_bob', 'my first manga'), + ( 5, 44, 2, 'regress_rls_bob', 'my second manga'), + ( 6, 22, 1, 'regress_rls_carol', 'great science fiction'), + ( 7, 33, 2, 'regress_rls_carol', 'great technology book'), + ( 8, 44, 1, 'regress_rls_carol', 'great manga'), + ( 9, 22, 1, 'regress_rls_dave', 'awesome science fiction'), + (10, 33, 2, 'regress_rls_dave', 'awesome technology book') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +ALTER TABLE document ENABLE ROW LEVEL SECURITY +-- +TABLE: name="document" schema="" table="document" ctx=DDL +STMT: AlterTableStmt +== 036 +-- user's security level must be higher than or equal to document's +CREATE POLICY p1 ON document AS PERMISSIVE + USING (dlevel <= (SELECT seclv FROM uaccount WHERE pguser = current_user)) +-- +STMT: CreatePolicyStmt +== 037 +-- try to create a policy of bogus type +CREATE POLICY p1 ON document AS UGLY + USING (dlevel <= (SELECT seclv FROM uaccount WHERE pguser = current_user)) +-- +ERROR: unrecognized row security option "ugly" +CURSORPOS: 73 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 038 +-- but Dave isn't allowed to anything at cid 50 or above +-- this is to make sure that we sort the policies by name first +-- when applying WITH CHECK, a later INSERT by Dave should fail due +-- to p1r first +CREATE POLICY p2r ON document AS RESTRICTIVE TO regress_rls_dave + USING (cid <> 44 AND cid < 50) +-- +STMT: CreatePolicyStmt +== 039 +-- and Dave isn't allowed to see manga documents +CREATE POLICY p1r ON document AS RESTRICTIVE TO regress_rls_dave + USING (cid <> 44) +-- +STMT: CreatePolicyStmt +== 040 +SELECT * FROM pg_policies WHERE schemaname = 'regress_rls_schema' AND tablename = 'document' ORDER BY policyname +-- +TABLE: name="pg_policies" schema="" table="pg_policies" ctx=Select +FILTER: schema="" table="" column="schemaname" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 041 +-- viewpoint from regress_rls_bob +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 042 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 043 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 044 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 045 +-- try a sampled version +SELECT * FROM document TABLESAMPLE BERNOULLI(50) REPEATABLE(0) + WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 046 +-- viewpoint from regress_rls_carol +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 047 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 048 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 049 +-- try a sampled version +SELECT * FROM document TABLESAMPLE BERNOULLI(50) REPEATABLE(0) + WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 050 +EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 051 +EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 052 +-- viewpoint from regress_rls_dave +SET SESSION AUTHORIZATION regress_rls_dave +-- +STMT: VariableSetStmt +== 053 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 054 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 055 +EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 056 +EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 057 +-- 44 would technically fail for both p2r and p1r, but we should get an error +-- back from p1r for this because it sorts first +INSERT INTO document VALUES (100, 44, 1, 'regress_rls_dave', 'testing sorting of policies') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +-- fail +-- Just to see a p2r error +INSERT INTO document VALUES (100, 55, 1, 'regress_rls_dave', 'testing sorting of policies') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +-- fail + +-- only owner can change policies +ALTER POLICY p1 ON document USING (true) +-- +STMT: AlterPolicyStmt +== 060 +--fail +DROP POLICY p1 ON document +-- +STMT: DropStmt +== 061 +--fail + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 062 +ALTER POLICY p1 ON document USING (dauthor = current_user) +-- +STMT: AlterPolicyStmt +== 063 +-- viewpoint from regress_rls_bob again +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 064 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 065 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER by did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 066 +-- viewpoint from rls_regres_carol again +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 067 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 068 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER by did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 069 +EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 070 +EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 071 +-- interaction of FK/PK constraints +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 072 +CREATE POLICY p2 ON category + USING (CASE WHEN current_user = 'regress_rls_bob' THEN cid IN (11, 33) + WHEN current_user = 'regress_rls_carol' THEN cid IN (22, 44) + ELSE false END) +-- +STMT: CreatePolicyStmt +== 073 +ALTER TABLE category ENABLE ROW LEVEL SECURITY +-- +TABLE: name="category" schema="" table="category" ctx=DDL +STMT: AlterTableStmt +== 074 +-- cannot delete PK referenced by invisible FK +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 075 +SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +ALIAS: "c"="category" +ALIAS: "d"="document" +STMT: SelectStmt +== 076 +DELETE FROM category WHERE cid = 33 +-- +TABLE: name="category" schema="" table="category" ctx=DML +STMT: DeleteStmt +== 077 +-- fails with FK violation + +-- can insert FK referencing invisible PK +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 078 +SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +ALIAS: "c"="category" +ALIAS: "d"="document" +STMT: SelectStmt +== 079 +INSERT INTO document VALUES (11, 33, 1, current_user, 'hoge') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +-- UNIQUE or PRIMARY KEY constraint violation DOES reveal presence of row +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 081 +INSERT INTO document VALUES (8, 44, 1, 'regress_rls_bob', 'my third manga') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 082 +-- Must fail with unique violation, revealing presence of did we can't see +SELECT * FROM document WHERE did = 8 +-- +TABLE: name="document" schema="" table="document" ctx=Select +FILTER: schema="" table="" column="did" +STMT: SelectStmt +== 083 +-- and confirm we can't see it + +-- RLS policies are checked before constraints +INSERT INTO document VALUES (8, 44, 1, 'regress_rls_carol', 'my third manga') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 084 +-- Should fail with RLS check violation, not duplicate key violation +UPDATE document SET did = 8, dauthor = 'regress_rls_carol' WHERE did = 5 +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: UpdateStmt +== 085 +-- Should fail with RLS check violation, not duplicate key violation + +-- database superuser does bypass RLS policy when enabled +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 086 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 087 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +== 088 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +== 089 +-- database superuser does bypass RLS policy when disabled +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 090 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 091 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +== 092 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +== 093 +-- database non-superuser with bypass privilege can bypass RLS policy when disabled +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +== 094 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 095 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +== 096 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +== 097 +-- RLS policy does not apply to table owner when RLS enabled. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 098 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 099 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +== 100 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +== 101 +-- RLS policy does not apply to table owner when RLS disabled. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 102 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 103 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +== 104 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +== 105 +|-- +-- Table inheritance and RLS policy +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 106 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 107 +CREATE TABLE t1 (id int not null primary key, a int, junk1 text, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 108 +ALTER TABLE t1 DROP COLUMN junk1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +== 109 +-- just a disturbing factor +GRANT ALL ON t1 TO public +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: GrantStmt +== 110 +COPY t1 FROM stdin WITH +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: CopyStmt +== 111 +CREATE TABLE t2 (c float) INHERITS (t1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 112 +GRANT ALL ON t2 TO public +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: GrantStmt +== 113 +COPY t2 FROM stdin +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: CopyStmt +== 114 +CREATE TABLE t3 (id int not null primary key, c text, b text, a int) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: CreateStmt +== 115 +ALTER TABLE t3 INHERIT t1 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: AlterTableStmt +== 116 +GRANT ALL ON t3 TO public +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: GrantStmt +== 117 +COPY t3(id, a,b,c) FROM stdin +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: CopyStmt +== 118 +CREATE POLICY p1 ON t1 FOR ALL TO PUBLIC USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 119 +-- be even number +CREATE POLICY p2 ON t2 FOR ALL TO PUBLIC USING (a % 2 = 1) +-- +STMT: CreatePolicyStmt +== 120 +-- be odd number + +ALTER TABLE t1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +== 121 +ALTER TABLE t2 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +== 122 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 123 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 124 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 125 +SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 126 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 127 +-- reference to system column +SELECT tableoid::regclass, * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 128 +EXPLAIN (COSTS OFF) SELECT *, t1 FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 129 +-- reference to whole-row reference +SELECT *, t1 FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 130 +EXPLAIN (COSTS OFF) SELECT *, t1 FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 131 +-- for share/update lock +SELECT * FROM t1 FOR SHARE +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 132 +EXPLAIN (COSTS OFF) SELECT * FROM t1 FOR SHARE +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 133 +SELECT * FROM t1 WHERE f_leak(b) FOR SHARE +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 134 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) FOR SHARE +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 135 +-- union all query +SELECT a, b, tableoid::regclass FROM t2 UNION ALL SELECT a, b, tableoid::regclass FROM t3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 136 +EXPLAIN (COSTS OFF) SELECT a, b, tableoid::regclass FROM t2 UNION ALL SELECT a, b, tableoid::regclass FROM t3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 137 +-- superuser is allowed to bypass RLS checks +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 138 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 139 +SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 140 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 141 +-- non-superuser with bypass privilege can bypass RLS policy when disabled +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +== 142 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 143 +SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 144 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 145 +|-- +-- Partitioned Tables +|-- + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 146 +CREATE TABLE part_document ( + did int, + cid int, + dlevel int not null, + dauthor name, + dtitle text +) PARTITION BY RANGE (cid) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DDL +STMT: CreateStmt +== 147 +GRANT ALL ON part_document TO public +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DDL +STMT: GrantStmt +== 148 +-- Create partitions for document categories +CREATE TABLE part_document_fiction PARTITION OF part_document FOR VALUES FROM (11) to (12) +-- +TABLE: name="part_document_fiction" schema="" table="part_document_fiction" ctx=DDL +STMT: CreateStmt +== 149 +CREATE TABLE part_document_satire PARTITION OF part_document FOR VALUES FROM (55) to (56) +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DDL +STMT: CreateStmt +== 150 +CREATE TABLE part_document_nonfiction PARTITION OF part_document FOR VALUES FROM (99) to (100) +-- +TABLE: name="part_document_nonfiction" schema="" table="part_document_nonfiction" ctx=DDL +STMT: CreateStmt +== 151 +GRANT ALL ON part_document_fiction TO public +-- +TABLE: name="part_document_fiction" schema="" table="part_document_fiction" ctx=DDL +STMT: GrantStmt +== 152 +GRANT ALL ON part_document_satire TO public +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DDL +STMT: GrantStmt +== 153 +GRANT ALL ON part_document_nonfiction TO public +-- +TABLE: name="part_document_nonfiction" schema="" table="part_document_nonfiction" ctx=DDL +STMT: GrantStmt +== 154 +INSERT INTO part_document VALUES + ( 1, 11, 1, 'regress_rls_bob', 'my first novel'), + ( 2, 11, 2, 'regress_rls_bob', 'my second novel'), + ( 3, 99, 2, 'regress_rls_bob', 'my science textbook'), + ( 4, 55, 1, 'regress_rls_bob', 'my first satire'), + ( 5, 99, 2, 'regress_rls_bob', 'my history book'), + ( 6, 11, 1, 'regress_rls_carol', 'great science fiction'), + ( 7, 99, 2, 'regress_rls_carol', 'great technology book'), + ( 8, 55, 2, 'regress_rls_carol', 'great satire'), + ( 9, 11, 1, 'regress_rls_dave', 'awesome science fiction'), + (10, 99, 2, 'regress_rls_dave', 'awesome technology book') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +ALTER TABLE part_document ENABLE ROW LEVEL SECURITY +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DDL +STMT: AlterTableStmt +== 156 +-- Create policy on parent +-- user's security level must be higher than or equal to document's +CREATE POLICY pp1 ON part_document AS PERMISSIVE + USING (dlevel <= (SELECT seclv FROM uaccount WHERE pguser = current_user)) +-- +STMT: CreatePolicyStmt +== 157 +-- Dave is only allowed to see cid < 55 +CREATE POLICY pp1r ON part_document AS RESTRICTIVE TO regress_rls_dave + USING (cid < 55) +-- +STMT: CreatePolicyStmt +== 158 +SELECT * FROM pg_policies WHERE schemaname = 'regress_rls_schema' AND tablename like '%part_document%' ORDER BY policyname +-- +TABLE: name="pg_policies" schema="" table="pg_policies" ctx=Select +FILTER: schema="" table="" column="schemaname" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 159 +-- viewpoint from regress_rls_bob +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 160 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 161 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 162 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 163 +-- viewpoint from regress_rls_carol +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 164 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 165 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 166 +-- viewpoint from regress_rls_dave +SET SESSION AUTHORIZATION regress_rls_dave +-- +STMT: VariableSetStmt +== 167 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 168 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 169 +-- pp1 ERROR +INSERT INTO part_document VALUES (100, 11, 5, 'regress_rls_dave', 'testing pp1') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 170 +-- fail +-- pp1r ERROR +INSERT INTO part_document VALUES (100, 99, 1, 'regress_rls_dave', 'testing pp1r') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 171 +-- fail + +-- Show that RLS policy does not apply for direct inserts to children +-- This should fail with RLS POLICY pp1r violation. +INSERT INTO part_document VALUES (100, 55, 1, 'regress_rls_dave', 'testing RLS with partitions') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 172 +-- fail +-- But this should succeed. +INSERT INTO part_document_satire VALUES (100, 55, 1, 'regress_rls_dave', 'testing RLS with partitions') +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +-- success +-- We still cannot see the row using the parent +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 174 +-- But we can if we look directly +SELECT * FROM part_document_satire WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 175 +-- Turn on RLS and create policy on child to show RLS is checked before constraints +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 176 +ALTER TABLE part_document_satire ENABLE ROW LEVEL SECURITY +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DDL +STMT: AlterTableStmt +== 177 +CREATE POLICY pp3 ON part_document_satire AS RESTRICTIVE + USING (cid < 55) +-- +STMT: CreatePolicyStmt +== 178 +-- This should fail with RLS violation now. +SET SESSION AUTHORIZATION regress_rls_dave +-- +STMT: VariableSetStmt +== 179 +INSERT INTO part_document_satire VALUES (101, 55, 1, 'regress_rls_dave', 'testing RLS with partitions') +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 180 +-- fail +-- And now we cannot see directly into the partition either, due to RLS +SELECT * FROM part_document_satire WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 181 +-- The parent looks same as before +-- viewpoint from regress_rls_dave +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 182 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 183 +-- viewpoint from regress_rls_carol +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 184 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 185 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 186 +-- only owner can change policies +ALTER POLICY pp1 ON part_document USING (true) +-- +STMT: AlterPolicyStmt +== 187 +--fail +DROP POLICY pp1 ON part_document +-- +STMT: DropStmt +== 188 +--fail + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 189 +ALTER POLICY pp1 ON part_document USING (dauthor = current_user) +-- +STMT: AlterPolicyStmt +== 190 +-- viewpoint from regress_rls_bob again +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 191 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 192 +-- viewpoint from rls_regres_carol again +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 193 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +== 194 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +== 195 +-- database superuser does bypass RLS policy when enabled +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 196 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 197 +SELECT * FROM part_document ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +STMT: SelectStmt +== 198 +SELECT * FROM part_document_satire ORDER by did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +STMT: SelectStmt +== 199 +-- database non-superuser with bypass privilege can bypass RLS policy when disabled +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +== 200 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 201 +SELECT * FROM part_document ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +STMT: SelectStmt +== 202 +SELECT * FROM part_document_satire ORDER by did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +STMT: SelectStmt +== 203 +-- RLS policy does not apply to table owner when RLS enabled. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 204 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 205 +SELECT * FROM part_document ORDER by did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +STMT: SelectStmt +== 206 +SELECT * FROM part_document_satire ORDER by did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +STMT: SelectStmt +== 207 +-- When RLS disabled, other users get ERROR. +SET SESSION AUTHORIZATION regress_rls_dave +-- +STMT: VariableSetStmt +== 208 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 209 +SELECT * FROM part_document ORDER by did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +STMT: SelectStmt +== 210 +SELECT * FROM part_document_satire ORDER by did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +STMT: SelectStmt +== 211 +-- Check behavior with a policy that uses a SubPlan not an InitPlan. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 212 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 213 +CREATE POLICY pp3 ON part_document AS RESTRICTIVE + USING ((SELECT dlevel <= seclv FROM uaccount WHERE pguser = current_user)) +-- +STMT: CreatePolicyStmt +== 214 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 215 +INSERT INTO part_document VALUES (100, 11, 5, 'regress_rls_carol', 'testing pp3') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +-- fail + +----- Dependencies ----- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 217 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 218 +CREATE TABLE dependee (x integer, y integer) +-- +TABLE: name="dependee" schema="" table="dependee" ctx=DDL +STMT: CreateStmt +== 219 +CREATE TABLE dependent (x integer, y integer) +-- +TABLE: name="dependent" schema="" table="dependent" ctx=DDL +STMT: CreateStmt +== 220 +CREATE POLICY d1 ON dependent FOR ALL + TO PUBLIC + USING (x = (SELECT d.x FROM dependee d WHERE d.y = y)) +-- +STMT: CreatePolicyStmt +== 221 +DROP TABLE dependee +-- +TABLE: name="dependee" schema="" table="dependee" ctx=DDL +STMT: DropStmt +== 222 +-- Should fail without CASCADE due to dependency on row security qual? + +DROP TABLE dependee CASCADE +-- +TABLE: name="dependee" schema="" table="dependee" ctx=DDL +STMT: DropStmt +== 223 +EXPLAIN (COSTS OFF) SELECT * FROM dependent +-- +TABLE: name="dependent" schema="" table="dependent" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 224 +-- After drop, should be unqualified + +----- RECURSION ---- + +|-- +-- Simple recursion +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 225 +CREATE TABLE rec1 (x integer, y integer) +-- +TABLE: name="rec1" schema="" table="rec1" ctx=DDL +STMT: CreateStmt +== 226 +CREATE POLICY r1 ON rec1 USING (x = (SELECT r.x FROM rec1 r WHERE y = r.y)) +-- +STMT: CreatePolicyStmt +== 227 +ALTER TABLE rec1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="rec1" schema="" table="rec1" ctx=DDL +STMT: AlterTableStmt +== 228 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 229 +SELECT * FROM rec1 +-- +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: SelectStmt +== 230 +-- fail, direct recursion + +|-- +-- Mutual recursion +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 231 +CREATE TABLE rec2 (a integer, b integer) +-- +TABLE: name="rec2" schema="" table="rec2" ctx=DDL +STMT: CreateStmt +== 232 +ALTER POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2 WHERE b = y)) +-- +STMT: AlterPolicyStmt +== 233 +CREATE POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1 WHERE y = b)) +-- +STMT: CreatePolicyStmt +== 234 +ALTER TABLE rec2 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="rec2" schema="" table="rec2" ctx=DDL +STMT: AlterTableStmt +== 235 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 236 +SELECT * FROM rec1 +-- +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: SelectStmt +== 237 +-- fail, mutual recursion + +|-- +-- Mutual recursion via views +|-- +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 238 +CREATE VIEW rec1v AS SELECT * FROM rec1 +-- +TABLE: name="rec1v" schema="" table="rec1v" ctx=DDL +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 239 +CREATE VIEW rec2v AS SELECT * FROM rec2 +-- +TABLE: name="rec2v" schema="" table="rec2v" ctx=DDL +TABLE: name="rec2" schema="" table="rec2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 240 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 241 +ALTER POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2v WHERE b = y)) +-- +STMT: AlterPolicyStmt +== 242 +ALTER POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1v WHERE y = b)) +-- +STMT: AlterPolicyStmt +== 243 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 244 +SELECT * FROM rec1 +-- +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: SelectStmt +== 245 +-- fail, mutual recursion via views + +|-- +-- Mutual recursion via .s.b views +|-- +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 246 +DROP VIEW rec1v, rec2v CASCADE +-- +STMT: DropStmt +== 247 +CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1 +-- +TABLE: name="rec1v" schema="" table="rec1v" ctx=DDL +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 248 +CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2 +-- +TABLE: name="rec2v" schema="" table="rec2v" ctx=DDL +TABLE: name="rec2" schema="" table="rec2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 249 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 250 +CREATE POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2v WHERE b = y)) +-- +STMT: CreatePolicyStmt +== 251 +CREATE POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1v WHERE y = b)) +-- +STMT: CreatePolicyStmt +== 252 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 253 +SELECT * FROM rec1 +-- +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: SelectStmt +== 254 +-- fail, mutual recursion via s.b. views + +|-- +-- recursive RLS and VIEWs in policy +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 255 +CREATE TABLE s1 (a int, b text) +-- +TABLE: name="s1" schema="" table="s1" ctx=DDL +STMT: CreateStmt +== 256 +INSERT INTO s1 (SELECT x, public.fipshash(x::text) FROM generate_series(-10,10) x) +-- +TABLE: name="s1" schema="" table="s1" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 257 +CREATE TABLE s2 (x int, y text) +-- +TABLE: name="s2" schema="" table="s2" ctx=DDL +STMT: CreateStmt +== 258 +INSERT INTO s2 (SELECT x, public.fipshash(x::text) FROM generate_series(-6,6) x) +-- +TABLE: name="s2" schema="" table="s2" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 259 +GRANT SELECT ON s1, s2 TO regress_rls_bob +-- +TABLE: name="s1" schema="" table="s1" ctx=DDL +TABLE: name="s2" schema="" table="s2" ctx=DDL +STMT: GrantStmt +== 260 +CREATE POLICY p1 ON s1 USING (a in (select x from s2 where y like '%2f%')) +-- +STMT: CreatePolicyStmt +== 261 +CREATE POLICY p2 ON s2 USING (x in (select a from s1 where b like '%22%')) +-- +STMT: CreatePolicyStmt +== 262 +CREATE POLICY p3 ON s1 FOR INSERT WITH CHECK (a = (SELECT a FROM s1)) +-- +STMT: CreatePolicyStmt +== 263 +ALTER TABLE s1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="s1" schema="" table="s1" ctx=DDL +STMT: AlterTableStmt +== 264 +ALTER TABLE s2 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="s2" schema="" table="s2" ctx=DDL +STMT: AlterTableStmt +== 265 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 266 +CREATE VIEW v2 AS SELECT * FROM s2 WHERE y like '%af%' +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="s2" schema="" table="s2" ctx=Select +FILTER: schema="" table="" column="y" +STMT: ViewStmt +STMT: SelectStmt +== 267 +SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 268 +-- fail (infinite recursion) + +INSERT INTO s1 VALUES (1, 'foo') +-- +TABLE: name="s1" schema="" table="s1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 269 +-- fail (infinite recursion) + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 270 +DROP POLICY p3 on s1 +-- +STMT: DropStmt +== 271 +ALTER POLICY p2 ON s2 USING (x % 2 = 0) +-- +STMT: AlterPolicyStmt +== 272 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 273 +SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 274 +-- OK +EXPLAIN (COSTS OFF) SELECT * FROM only s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 275 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 276 +ALTER POLICY p1 ON s1 USING (a in (select x from v2)) +-- +STMT: AlterPolicyStmt +== 277 +-- using VIEW in RLS policy +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 278 +SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 279 +-- OK +EXPLAIN (COSTS OFF) SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 280 +SELECT (SELECT x FROM s1 LIMIT 1) xx, * FROM s2 WHERE y like '%28%' +-- +TABLE: name="s2" schema="" table="s2" ctx=Select +TABLE: name="s1" schema="" table="s1" ctx=Select +FILTER: schema="" table="" column="y" +STMT: SelectStmt +== 281 +EXPLAIN (COSTS OFF) SELECT (SELECT x FROM s1 LIMIT 1) xx, * FROM s2 WHERE y like '%28%' +-- +TABLE: name="s2" schema="" table="s2" ctx=Select +TABLE: name="s1" schema="" table="s1" ctx=Select +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 282 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 283 +ALTER POLICY p2 ON s2 USING (x in (select a from s1 where b like '%d2%')) +-- +STMT: AlterPolicyStmt +== 284 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 285 +SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 286 +-- fail (infinite recursion via view) + +-- prepared statement with regress_rls_alice privilege +PREPARE p1(int) AS SELECT * FROM t1 WHERE a <= $1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +== 287 +EXECUTE p1(2) +-- +STMT: ExecuteStmt +== 288 +EXPLAIN (COSTS OFF) EXECUTE p1(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 289 +-- superuser is allowed to bypass RLS checks +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 290 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 291 +SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 292 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 293 +-- plan cache should be invalidated +EXECUTE p1(2) +-- +STMT: ExecuteStmt +== 294 +EXPLAIN (COSTS OFF) EXECUTE p1(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 295 +PREPARE p2(int) AS SELECT * FROM t1 WHERE a = $1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +== 296 +EXECUTE p2(2) +-- +STMT: ExecuteStmt +== 297 +EXPLAIN (COSTS OFF) EXECUTE p2(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 298 +-- also, case when privilege switch from superuser +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 299 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 300 +EXECUTE p2(2) +-- +STMT: ExecuteStmt +== 301 +EXPLAIN (COSTS OFF) EXECUTE p2(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 302 +|-- +-- UPDATE / DELETE and Row-level security +|-- +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 303 +EXPLAIN (COSTS OFF) UPDATE t1 SET b = b || b WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 304 +UPDATE t1 SET b = b || b WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 305 +EXPLAIN (COSTS OFF) UPDATE only t1 SET b = b || '_updt' WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 306 +UPDATE only t1 SET b = b || '_updt' WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 307 +-- returning clause with system column +UPDATE only t1 SET b = b WHERE f_leak(b) RETURNING tableoid::regclass, *, t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 308 +UPDATE t1 SET b = b WHERE f_leak(b) RETURNING * +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 309 +UPDATE t1 SET b = b WHERE f_leak(b) RETURNING tableoid::regclass, *, t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 310 +-- updates with from clause +EXPLAIN (COSTS OFF) UPDATE t2 SET b=t2.b FROM t3 +WHERE t2.a = 3 and t3.a = 2 AND f_leak(t2.b) AND f_leak(t3.b) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t3" schema="" table="t3" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 311 +UPDATE t2 SET b=t2.b FROM t3 +WHERE t2.a = 3 and t3.a = 2 AND f_leak(t2.b) AND f_leak(t3.b) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t3" schema="" table="t3" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 312 +EXPLAIN (COSTS OFF) UPDATE t1 SET b=t1.b FROM t2 +WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +TABLE: name="t2" schema="" table="t2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 313 +UPDATE t1 SET b=t1.b FROM t2 +WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +TABLE: name="t2" schema="" table="t2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 314 +EXPLAIN (COSTS OFF) UPDATE t2 SET b=t2.b FROM t1 +WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 315 +UPDATE t2 SET b=t2.b FROM t1 +WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 316 +-- updates with from clause self join +EXPLAIN (COSTS OFF) UPDATE t2 t2_1 SET b = t2_2.b FROM t2 t2_2 +WHERE t2_1.a = 3 AND t2_2.a = t2_1.a AND t2_2.b = t2_1.b +AND f_leak(t2_1.b) AND f_leak(t2_2.b) RETURNING *, t2_1, t2_2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t2" schema="" table="t2" ctx=Select +ALIAS: "t2_1"="t2" +ALIAS: "t2_2"="t2" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 317 +UPDATE t2 t2_1 SET b = t2_2.b FROM t2 t2_2 +WHERE t2_1.a = 3 AND t2_2.a = t2_1.a AND t2_2.b = t2_1.b +AND f_leak(t2_1.b) AND f_leak(t2_2.b) RETURNING *, t2_1, t2_2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t2" schema="" table="t2" ctx=Select +ALIAS: "t2_1"="t2" +ALIAS: "t2_2"="t2" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 318 +EXPLAIN (COSTS OFF) UPDATE t1 t1_1 SET b = t1_2.b FROM t1 t1_2 +WHERE t1_1.a = 4 AND t1_2.a = t1_1.a AND t1_2.b = t1_1.b +AND f_leak(t1_1.b) AND f_leak(t1_2.b) RETURNING *, t1_1, t1_2 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +ALIAS: "t1_1"="t1" +ALIAS: "t1_2"="t1" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 319 +UPDATE t1 t1_1 SET b = t1_2.b FROM t1 t1_2 +WHERE t1_1.a = 4 AND t1_2.a = t1_1.a AND t1_2.b = t1_1.b +AND f_leak(t1_1.b) AND f_leak(t1_2.b) RETURNING *, t1_1, t1_2 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +ALIAS: "t1_1"="t1" +ALIAS: "t1_2"="t1" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 320 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 321 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 322 +SELECT * FROM t1 ORDER BY a,b +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 323 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 324 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 325 +EXPLAIN (COSTS OFF) DELETE FROM only t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +== 326 +EXPLAIN (COSTS OFF) DELETE FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +== 327 +DELETE FROM only t1 WHERE f_leak(b) RETURNING tableoid::regclass, *, t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: DeleteStmt +== 328 +DELETE FROM t1 WHERE f_leak(b) RETURNING tableoid::regclass, *, t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: DeleteStmt +== 329 +|-- +-- S.b. view on top of Row-level security +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 330 +CREATE TABLE b1 (a int, b text) +-- +TABLE: name="b1" schema="" table="b1" ctx=DDL +STMT: CreateStmt +== 331 +INSERT INTO b1 (SELECT x, public.fipshash(x::text) FROM generate_series(-10,10) x) +-- +TABLE: name="b1" schema="" table="b1" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 332 +CREATE POLICY p1 ON b1 USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 333 +ALTER TABLE b1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="b1" schema="" table="b1" ctx=DDL +STMT: AlterTableStmt +== 334 +GRANT ALL ON b1 TO regress_rls_bob +-- +TABLE: name="b1" schema="" table="b1" ctx=DDL +STMT: GrantStmt +== 335 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 336 +CREATE VIEW bv1 WITH (security_barrier) AS SELECT * FROM b1 WHERE a > 0 WITH CHECK OPTION +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DDL +TABLE: name="b1" schema="" table="b1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 337 +GRANT ALL ON bv1 TO regress_rls_carol +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DDL +STMT: GrantStmt +== 338 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 339 +EXPLAIN (COSTS OFF) SELECT * FROM bv1 WHERE f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 340 +SELECT * FROM bv1 WHERE f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 341 +INSERT INTO bv1 VALUES (-1, 'xxx') +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 342 +-- should fail view WCO +INSERT INTO bv1 VALUES (11, 'xxx') +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 343 +-- should fail RLS check +INSERT INTO bv1 VALUES (12, 'xxx') +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 344 +-- ok + +EXPLAIN (COSTS OFF) UPDATE bv1 SET b = 'yyy' WHERE a = 4 AND f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 345 +UPDATE bv1 SET b = 'yyy' WHERE a = 4 AND f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 346 +EXPLAIN (COSTS OFF) DELETE FROM bv1 WHERE a = 6 AND f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +== 347 +DELETE FROM bv1 WHERE a = 6 AND f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: DeleteStmt +== 348 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 349 +SELECT * FROM b1 +-- +TABLE: name="b1" schema="" table="b1" ctx=Select +STMT: SelectStmt +== 350 +|-- +-- INSERT ... ON CONFLICT DO UPDATE and Row-level security +|-- + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 351 +DROP POLICY p1 ON document +-- +STMT: DropStmt +== 352 +DROP POLICY p1r ON document +-- +STMT: DropStmt +== 353 +CREATE POLICY p1 ON document FOR SELECT USING (true) +-- +STMT: CreatePolicyStmt +== 354 +CREATE POLICY p2 ON document FOR INSERT WITH CHECK (dauthor = current_user) +-- +STMT: CreatePolicyStmt +== 355 +CREATE POLICY p3 ON document FOR UPDATE + USING (cid = (SELECT cid from category WHERE cname = 'novel')) + WITH CHECK (dauthor = current_user) +-- +STMT: CreatePolicyStmt +== 356 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 357 +-- Exists... +SELECT * FROM document WHERE did = 2 +-- +TABLE: name="document" schema="" table="document" ctx=Select +FILTER: schema="" table="" column="did" +STMT: SelectStmt +== 358 +-- ...so violates actual WITH CHECK OPTION within UPDATE (not INSERT, since +-- alternative UPDATE path happens to be taken): +INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_carol', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, dauthor = EXCLUDED.dauthor +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 359 +-- Violates USING qual for UPDATE policy p3. +|-- +-- UPDATE path is taken, but UPDATE fails purely because *existing* row to be +-- updated is not a "novel"/cid 11 (row is not leaked, even though we have +-- SELECT privileges sufficient to see the row in this instance): +INSERT INTO document VALUES (33, 22, 1, 'regress_rls_bob', 'okay science fiction') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 360 +-- preparation for next statement +INSERT INTO document VALUES (33, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'Some novel, replaces sci-fi') -- takes UPDATE path + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 361 +-- Fine (we UPDATE, since INSERT WCOs and UPDATE security barrier quals + WCOs +-- not violated): +INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 362 +-- Fine (we INSERT, so "cid = 33" ("technology") isn't evaluated): +INSERT INTO document VALUES (78, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'some technology novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, cid = 33 RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 363 +-- Fine (same query, but we UPDATE, so "cid = 33", ("technology") is not the +-- case in respect of *existing* tuple): +INSERT INTO document VALUES (78, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'some technology novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, cid = 33 RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 364 +-- Same query a third time, but now fails due to existing tuple finally not +-- passing quals: +INSERT INTO document VALUES (78, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'some technology novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, cid = 33 RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 365 +-- Don't fail just because INSERT doesn't satisfy WITH CHECK option that +-- originated as a barrier/USING() qual from the UPDATE. Note that the UPDATE +-- path *isn't* taken, and so UPDATE-related policy does not apply: +INSERT INTO document VALUES (79, (SELECT cid from category WHERE cname = 'technology'), 1, 'regress_rls_bob', 'technology book, can only insert') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 366 +-- But this time, the same statement fails, because the UPDATE path is taken, +-- and updating the row just inserted falls afoul of security barrier qual +-- (enforced as WCO) -- what we might have updated target tuple to is +-- irrelevant, in fact. +INSERT INTO document VALUES (79, (SELECT cid from category WHERE cname = 'technology'), 1, 'regress_rls_bob', 'technology book, can only insert') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 367 +-- Test default USING qual enforced as WCO +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 368 +DROP POLICY p1 ON document +-- +STMT: DropStmt +== 369 +DROP POLICY p2 ON document +-- +STMT: DropStmt +== 370 +DROP POLICY p3 ON document +-- +STMT: DropStmt +== 371 +CREATE POLICY p3_with_default ON document FOR UPDATE + USING (cid = (SELECT cid from category WHERE cname = 'novel')) +-- +STMT: CreatePolicyStmt +== 372 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 373 +-- Just because WCO-style enforcement of USING quals occurs with +-- existing/target tuple does not mean that the implementation can be allowed +-- to fail to also enforce this qual against the final tuple appended to +-- relation (since in the absence of an explicit WCO, this is also interpreted +-- as an UPDATE/ALL WCO in general). +|-- +-- UPDATE path is taken here (fails due to existing tuple). Note that this is +-- not reported as a "USING expression", because it's an RLS UPDATE check that originated as +-- a USING qual for the purposes of RLS in general, as opposed to an explicit +-- USING qual that is ordinarily a security barrier. We leave it up to the +-- UPDATE to make this fail: +INSERT INTO document VALUES (79, (SELECT cid from category WHERE cname = 'technology'), 1, 'regress_rls_bob', 'technology book, can only insert') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 374 +-- UPDATE path is taken here. Existing tuple passes, since its cid +-- corresponds to "novel", but default USING qual is enforced against +-- post-UPDATE tuple too (as always when updating with a policy that lacks an +-- explicit WCO), and so this fails: +INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'technology'), 1, 'regress_rls_bob', 'my first novel') + ON CONFLICT (did) DO UPDATE SET cid = EXCLUDED.cid, dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 375 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 376 +DROP POLICY p3_with_default ON document +-- +STMT: DropStmt +== 377 +|-- +-- Test ALL policies with ON CONFLICT DO UPDATE (much the same as existing UPDATE +-- tests) +|-- +CREATE POLICY p3_with_all ON document FOR ALL + USING (cid = (SELECT cid from category WHERE cname = 'novel')) + WITH CHECK (dauthor = current_user) +-- +STMT: CreatePolicyStmt +== 378 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 379 +-- Fails, since ALL WCO is enforced in insert path: +INSERT INTO document VALUES (80, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_carol', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, cid = 33 +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 380 +-- Fails, since ALL policy USING qual is enforced (existing, target tuple is in +-- violation, since it has the "manga" cid): +INSERT INTO document VALUES (4, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 381 +-- Fails, since ALL WCO are enforced: +INSERT INTO document VALUES (1, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dauthor = 'regress_rls_carol' +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +== 382 +|-- +-- MERGE +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 383 +DROP POLICY p3_with_all ON document +-- +STMT: DropStmt +== 384 +ALTER TABLE document ADD COLUMN dnotes text DEFAULT '' +-- +TABLE: name="document" schema="" table="document" ctx=DDL +STMT: AlterTableStmt +== 385 +-- all documents are readable +CREATE POLICY p1 ON document FOR SELECT USING (true) +-- +STMT: CreatePolicyStmt +== 386 +-- one may insert documents only authored by them +CREATE POLICY p2 ON document FOR INSERT WITH CHECK (dauthor = current_user) +-- +STMT: CreatePolicyStmt +== 387 +-- one may only update documents in 'novel' category and new dlevel must be > 0 +CREATE POLICY p3 ON document FOR UPDATE + USING (cid = (SELECT cid from category WHERE cname = 'novel')) + WITH CHECK (dlevel > 0) +-- +STMT: CreatePolicyStmt +== 388 +-- one may only delete documents in 'manga' category +CREATE POLICY p4 ON document FOR DELETE + USING (cid = (SELECT cid from category WHERE cname = 'manga')) +-- +STMT: CreatePolicyStmt +== 389 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +== 390 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 391 +-- Fails, since update violates WITH CHECK qual on dlevel +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge1 ', dlevel = 0 +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 392 +-- Should be OK since USING and WITH CHECK quals pass +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge2 ' +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 393 +-- Even when dlevel is updated explicitly, but to the existing value +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge3 ', dlevel = 1 +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 394 +-- There is a MATCH for did = 3, but UPDATE's USING qual does not allow +-- updating an item in category 'science fiction' +MERGE INTO document d +USING (SELECT 3 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 395 +-- The same thing with DELETE action, but fails again because no permissions +-- to delete items in 'science fiction' category that did 3 belongs to. +MERGE INTO document d +USING (SELECT 3 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 396 +-- Document with did 4 belongs to 'manga' category which is allowed for +-- deletion. But this fails because the UPDATE action is matched first and +-- UPDATE policy does not allow updation in the category. +MERGE INTO document d +USING (SELECT 4 as sdid) s +ON did = s.sdid +WHEN MATCHED AND dnotes = '' THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +WHEN MATCHED THEN + DELETE +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 397 +-- UPDATE action is not matched this time because of the WHEN qual. +-- DELETE still fails because role regress_rls_bob does not have SELECT +-- privileges on 'manga' category row in the category table. +MERGE INTO document d +USING (SELECT 4 as sdid) s +ON did = s.sdid +WHEN MATCHED AND dnotes <> '' THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +WHEN MATCHED THEN + DELETE +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 398 +-- OK if DELETE is replaced with DO NOTHING +MERGE INTO document d +USING (SELECT 4 as sdid) s +ON did = s.sdid +WHEN MATCHED AND dnotes <> '' THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +WHEN MATCHED THEN + DO NOTHING +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 399 +SELECT * FROM document WHERE did = 4 +-- +TABLE: name="document" schema="" table="document" ctx=Select +FILTER: schema="" table="" column="did" +STMT: SelectStmt +== 400 +-- Switch to regress_rls_carol role and try the DELETE again. It should succeed +-- this time +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 401 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 402 +MERGE INTO document d +USING (SELECT 4 as sdid) s +ON did = s.sdid +WHEN MATCHED AND dnotes <> '' THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +WHEN MATCHED THEN + DELETE +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 403 +-- Switch back to regress_rls_bob role +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 404 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 405 +-- Try INSERT action. This fails because we are trying to insert +-- dauthor = regress_rls_dave and INSERT's WITH CHECK does not allow +-- that +MERGE INTO document d +USING (SELECT 12 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + DELETE +WHEN NOT MATCHED THEN + INSERT VALUES (12, 11, 1, 'regress_rls_dave', 'another novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 406 +-- This should be fine +MERGE INTO document d +USING (SELECT 12 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + DELETE +WHEN NOT MATCHED THEN + INSERT VALUES (12, 11, 1, 'regress_rls_bob', 'another novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 407 +-- ok +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge4 ' +WHEN NOT MATCHED THEN + INSERT VALUES (12, 11, 1, 'regress_rls_bob', 'another novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 408 +-- drop and create a new SELECT policy which prevents us from reading +-- any document except with category 'novel' +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 409 +DROP POLICY p1 ON document +-- +STMT: DropStmt +== 410 +CREATE POLICY p1 ON document FOR SELECT + USING (cid = (SELECT cid from category WHERE cname = 'novel')) +-- +STMT: CreatePolicyStmt +== 411 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 412 +-- MERGE can no longer see the matching row and hence attempts the +-- NOT MATCHED action, which results in unique key violation +MERGE INTO document d +USING (SELECT 7 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge5 ' +WHEN NOT MATCHED THEN + INSERT VALUES (12, 11, 1, 'regress_rls_bob', 'another novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 413 +-- UPDATE action fails if new row is not visible +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge6 ', + cid = (SELECT cid from category WHERE cname = 'technology') +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +ALIAS: "d"="document" +FILTER: schema="" table="" column="cname" +STMT: MergeStmt +STMT: SelectStmt +== 414 +-- but OK if new row is visible +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge7 ', + cid = (SELECT cid from category WHERE cname = 'novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +ALIAS: "d"="document" +FILTER: schema="" table="" column="cname" +STMT: MergeStmt +STMT: SelectStmt +== 415 +-- OK to insert a new row that is not visible +MERGE INTO document d +USING (SELECT 13 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge8 ' +WHEN NOT MATCHED THEN + INSERT VALUES (13, 44, 1, 'regress_rls_bob', 'new manga') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 416 +SELECT * FROM document WHERE did = 13 +-- +TABLE: name="document" schema="" table="document" ctx=Select +FILTER: schema="" table="" column="did" +STMT: SelectStmt +== 417 +-- but not OK if RETURNING is used +MERGE INTO document d +USING (SELECT 14 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge9 ' +WHEN NOT MATCHED THEN + INSERT VALUES (14, 44, 1, 'regress_rls_bob', 'new manga') +RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 418 +-- but OK if new row is visible +MERGE INTO document d +USING (SELECT 14 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge10 ' +WHEN NOT MATCHED THEN + INSERT VALUES (14, 11, 1, 'regress_rls_bob', 'new novel') +RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +== 419 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 420 +-- drop the restrictive SELECT policy so that we can look at the +-- final state of the table +DROP POLICY p1 ON document +-- +STMT: DropStmt +== 421 +-- Just check everything went per plan +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +== 422 +|-- +-- ROLE/GROUP +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 423 +CREATE TABLE z1 (a int, b text) +-- +TABLE: name="z1" schema="" table="z1" ctx=DDL +STMT: CreateStmt +== 424 +CREATE TABLE z2 (a int, b text) +-- +TABLE: name="z2" schema="" table="z2" ctx=DDL +STMT: CreateStmt +== 425 +GRANT SELECT ON z1,z2 TO regress_rls_group1, regress_rls_group2, + regress_rls_bob, regress_rls_carol +-- +TABLE: name="z1" schema="" table="z1" ctx=DDL +TABLE: name="z2" schema="" table="z2" ctx=DDL +STMT: GrantStmt +== 426 +INSERT INTO z1 VALUES + (1, 'aba'), + (2, 'bbb'), + (3, 'ccc'), + (4, 'dad') +-- +TABLE: name="z1" schema="" table="z1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 427 +CREATE POLICY p1 ON z1 TO regress_rls_group1 USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 428 +CREATE POLICY p2 ON z1 TO regress_rls_group2 USING (a % 2 = 1) +-- +STMT: CreatePolicyStmt +== 429 +ALTER TABLE z1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="z1" schema="" table="z1" ctx=DDL +STMT: AlterTableStmt +== 430 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 431 +SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 432 +EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 433 +PREPARE plancache_test AS SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 434 +EXPLAIN (COSTS OFF) EXECUTE plancache_test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 435 +PREPARE plancache_test2 AS WITH q AS MATERIALIZED (SELECT * FROM z1 WHERE f_leak(b)) SELECT * FROM q,z2 +-- +TABLE: name="z2" schema="" table="z2" ctx=Select +TABLE: name="z1" schema="" table="z1" ctx=Select +CTE: "q" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 436 +EXPLAIN (COSTS OFF) EXECUTE plancache_test2 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 437 +PREPARE plancache_test3 AS WITH q AS MATERIALIZED (SELECT * FROM z2) SELECT * FROM q,z1 WHERE f_leak(z1.b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +TABLE: name="z2" schema="" table="z2" ctx=Select +CTE: "q" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="z1" column="b" +STMT: PrepareStmt +STMT: SelectStmt +== 438 +EXPLAIN (COSTS OFF) EXECUTE plancache_test3 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 439 +SET ROLE regress_rls_group1 +-- +STMT: VariableSetStmt +== 440 +SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 441 +EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 442 +EXPLAIN (COSTS OFF) EXECUTE plancache_test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 443 +EXPLAIN (COSTS OFF) EXECUTE plancache_test2 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 444 +EXPLAIN (COSTS OFF) EXECUTE plancache_test3 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 445 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 446 +SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 447 +EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 448 +EXPLAIN (COSTS OFF) EXECUTE plancache_test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 449 +EXPLAIN (COSTS OFF) EXECUTE plancache_test2 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 450 +EXPLAIN (COSTS OFF) EXECUTE plancache_test3 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 451 +SET ROLE regress_rls_group2 +-- +STMT: VariableSetStmt +== 452 +SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 453 +EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 454 +EXPLAIN (COSTS OFF) EXECUTE plancache_test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 455 +EXPLAIN (COSTS OFF) EXECUTE plancache_test2 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 456 +EXPLAIN (COSTS OFF) EXECUTE plancache_test3 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 457 +|-- +-- Views should follow policy for view owner. +|-- +-- View and Table owner are the same. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 458 +CREATE VIEW rls_view AS SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 459 +GRANT SELECT ON rls_view TO regress_rls_bob +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +== 460 +-- Query as role that is not owner of view or table. Should return all records. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 461 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 462 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 463 +-- Query as view/table owner. Should return all records. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 464 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 465 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 466 +DROP VIEW rls_view +-- +STMT: DropStmt +== 467 +-- View and Table owners are different. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 468 +CREATE VIEW rls_view AS SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 469 +GRANT SELECT ON rls_view TO regress_rls_alice +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +== 470 +-- Query as role that is not owner of view but is owner of table. +-- Should return records based on view owner policies. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 471 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 472 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 473 +-- Query as role that is not owner of table but is owner of view. +-- Should return records based on view owner policies. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 474 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 475 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 476 +-- Query as role that is not the owner of the table or view without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 477 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 478 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 479 +--fail - permission denied. + +-- Query as role that is not the owner of the table or view with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 480 +GRANT SELECT ON rls_view TO regress_rls_carol +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +== 481 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 482 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 483 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 484 +-- Policy requiring access to another table. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 485 +CREATE TABLE z1_blacklist (a int) +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: CreateStmt +== 486 +INSERT INTO z1_blacklist VALUES (3), (4) +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 487 +CREATE POLICY p3 ON z1 AS RESTRICTIVE USING (a NOT IN (SELECT a FROM z1_blacklist)) +-- +STMT: CreatePolicyStmt +== 488 +-- Query as role that is not owner of table but is owner of view without permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 489 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 490 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 491 +--fail - permission denied. + +-- Query as role that is not the owner of the table or view without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 492 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 493 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 494 +--fail - permission denied. + +-- Query as role that is not owner of table but is owner of view with permissions. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 495 +GRANT SELECT ON z1_blacklist TO regress_rls_bob +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: GrantStmt +== 496 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 497 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 498 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 499 +-- Query as role that is not the owner of the table or view with permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 500 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 501 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 502 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 503 +REVOKE SELECT ON z1_blacklist FROM regress_rls_bob +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: GrantStmt +== 504 +DROP POLICY p3 ON z1 +-- +STMT: DropStmt +== 505 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 506 +DROP VIEW rls_view +-- +STMT: DropStmt +== 507 +|-- +-- Security invoker views should follow policy for current user. +|-- +-- View and table owner are the same. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 508 +CREATE VIEW rls_view WITH (security_invoker) AS + SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 509 +GRANT SELECT ON rls_view TO regress_rls_bob +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +== 510 +GRANT SELECT ON rls_view TO regress_rls_carol +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +== 511 +-- Query as table owner. Should return all records. +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 512 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 513 +-- Queries as other users. +-- Should return records based on current user's policies. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 514 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 515 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 516 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 517 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 518 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 519 +-- View and table owners are different. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 520 +DROP VIEW rls_view +-- +STMT: DropStmt +== 521 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 522 +CREATE VIEW rls_view WITH (security_invoker) AS + SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 523 +GRANT SELECT ON rls_view TO regress_rls_alice +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +== 524 +GRANT SELECT ON rls_view TO regress_rls_carol +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +== 525 +-- Query as table owner. Should return all records. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 526 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 527 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 528 +-- Queries as other users. +-- Should return records based on current user's policies. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 529 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 530 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 531 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 532 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 533 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 534 +-- Policy requiring access to another table. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 535 +CREATE POLICY p3 ON z1 AS RESTRICTIVE USING (a NOT IN (SELECT a FROM z1_blacklist)) +-- +STMT: CreatePolicyStmt +== 536 +-- Query as role that is not owner of table but is owner of view without permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 537 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 538 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 539 +--fail - permission denied. + +-- Query as role that is not the owner of the table or view without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 540 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 541 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 542 +--fail - permission denied. + +-- Query as role that is not owner of table but is owner of view with permissions. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 543 +GRANT SELECT ON z1_blacklist TO regress_rls_bob +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: GrantStmt +== 544 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 545 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 546 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 547 +-- Query as role that is not the owner of the table or view without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 548 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 549 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 550 +--fail - permission denied. + +-- Query as role that is not the owner of the table or view with permissions. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 551 +GRANT SELECT ON z1_blacklist TO regress_rls_carol +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: GrantStmt +== 552 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 553 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +== 554 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 555 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 556 +DROP VIEW rls_view +-- +STMT: DropStmt +== 557 +|-- +-- Command specific +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 558 +CREATE TABLE x1 (a int, b text, c text) +-- +TABLE: name="x1" schema="" table="x1" ctx=DDL +STMT: CreateStmt +== 559 +GRANT ALL ON x1 TO PUBLIC +-- +TABLE: name="x1" schema="" table="x1" ctx=DDL +STMT: GrantStmt +== 560 +INSERT INTO x1 VALUES + (1, 'abc', 'regress_rls_bob'), + (2, 'bcd', 'regress_rls_bob'), + (3, 'cde', 'regress_rls_carol'), + (4, 'def', 'regress_rls_carol'), + (5, 'efg', 'regress_rls_bob'), + (6, 'fgh', 'regress_rls_bob'), + (7, 'fgh', 'regress_rls_carol'), + (8, 'fgh', 'regress_rls_carol') +-- +TABLE: name="x1" schema="" table="x1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 561 +CREATE POLICY p0 ON x1 FOR ALL USING (c = current_user) +-- +STMT: CreatePolicyStmt +== 562 +CREATE POLICY p1 ON x1 FOR SELECT USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 563 +CREATE POLICY p2 ON x1 FOR INSERT WITH CHECK (a % 2 = 1) +-- +STMT: CreatePolicyStmt +== 564 +CREATE POLICY p3 ON x1 FOR UPDATE USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 565 +CREATE POLICY p4 ON x1 FOR DELETE USING (a < 8) +-- +STMT: CreatePolicyStmt +== 566 +ALTER TABLE x1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="x1" schema="" table="x1" ctx=DDL +STMT: AlterTableStmt +== 567 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 568 +SELECT * FROM x1 WHERE f_leak(b) ORDER BY a ASC +-- +TABLE: name="x1" schema="" table="x1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 569 +UPDATE x1 SET b = b || '_updt' WHERE f_leak(b) RETURNING * +-- +TABLE: name="x1" schema="" table="x1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 570 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 571 +SELECT * FROM x1 WHERE f_leak(b) ORDER BY a ASC +-- +TABLE: name="x1" schema="" table="x1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 572 +UPDATE x1 SET b = b || '_updt' WHERE f_leak(b) RETURNING * +-- +TABLE: name="x1" schema="" table="x1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +== 573 +DELETE FROM x1 WHERE f_leak(b) RETURNING * +-- +TABLE: name="x1" schema="" table="x1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: DeleteStmt +== 574 +|-- +-- Duplicate Policy Names +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 575 +CREATE TABLE y1 (a int, b text) +-- +TABLE: name="y1" schema="" table="y1" ctx=DDL +STMT: CreateStmt +== 576 +CREATE TABLE y2 (a int, b text) +-- +TABLE: name="y2" schema="" table="y2" ctx=DDL +STMT: CreateStmt +== 577 +GRANT ALL ON y1, y2 TO regress_rls_bob +-- +TABLE: name="y1" schema="" table="y1" ctx=DDL +TABLE: name="y2" schema="" table="y2" ctx=DDL +STMT: GrantStmt +== 578 +CREATE POLICY p1 ON y1 FOR ALL USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 579 +CREATE POLICY p2 ON y1 FOR SELECT USING (a > 2) +-- +STMT: CreatePolicyStmt +== 580 +CREATE POLICY p1 ON y1 FOR SELECT USING (a % 2 = 1) +-- +STMT: CreatePolicyStmt +== 581 +--fail +CREATE POLICY p1 ON y2 FOR ALL USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 582 +--OK + +ALTER TABLE y1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="y1" schema="" table="y1" ctx=DDL +STMT: AlterTableStmt +== 583 +ALTER TABLE y2 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="y2" schema="" table="y2" ctx=DDL +STMT: AlterTableStmt +== 584 +|-- +-- Expression structure with SBV +|-- +-- Create view as table owner. RLS should NOT be applied. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 585 +CREATE VIEW rls_sbv WITH (security_barrier) AS + SELECT * FROM y1 WHERE f_leak(b) +-- +TABLE: name="rls_sbv" schema="" table="rls_sbv" ctx=DDL +TABLE: name="y1" schema="" table="y1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 586 +EXPLAIN (COSTS OFF) SELECT * FROM rls_sbv WHERE (a = 1) +-- +TABLE: name="rls_sbv" schema="" table="rls_sbv" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 587 +DROP VIEW rls_sbv +-- +STMT: DropStmt +== 588 +-- Create view as role that does not own table. RLS should be applied. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 589 +CREATE VIEW rls_sbv WITH (security_barrier) AS + SELECT * FROM y1 WHERE f_leak(b) +-- +TABLE: name="rls_sbv" schema="" table="rls_sbv" ctx=DDL +TABLE: name="y1" schema="" table="y1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 590 +EXPLAIN (COSTS OFF) SELECT * FROM rls_sbv WHERE (a = 1) +-- +TABLE: name="rls_sbv" schema="" table="rls_sbv" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 591 +DROP VIEW rls_sbv +-- +STMT: DropStmt +== 592 +|-- +-- Expression structure +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 593 +INSERT INTO y2 (SELECT x, public.fipshash(x::text) FROM generate_series(0,20) x) +-- +TABLE: name="y2" schema="" table="y2" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 594 +CREATE POLICY p2 ON y2 USING (a % 3 = 0) +-- +STMT: CreatePolicyStmt +== 595 +CREATE POLICY p3 ON y2 USING (a % 4 = 0) +-- +STMT: CreatePolicyStmt +== 596 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 597 +SELECT * FROM y2 WHERE f_leak(b) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 598 +EXPLAIN (COSTS OFF) SELECT * FROM y2 WHERE f_leak(b) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 599 +|-- +-- Qual push-down of leaky functions, when not referring to table +|-- +SELECT * FROM y2 WHERE f_leak('abc') +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: SelectStmt +== 600 +EXPLAIN (COSTS OFF) SELECT * FROM y2 WHERE f_leak('abc') +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 601 +CREATE TABLE test_qual_pushdown ( + abc text +) +-- +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=DDL +STMT: CreateStmt +== 602 +INSERT INTO test_qual_pushdown VALUES ('abc'),('def') +-- +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 603 +SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(abc) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="abc" +STMT: SelectStmt +== 604 +EXPLAIN (COSTS OFF) SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(abc) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="abc" +STMT: ExplainStmt +STMT: SelectStmt +== 605 +SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(b) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 606 +EXPLAIN (COSTS OFF) SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(b) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 607 +DROP TABLE test_qual_pushdown +-- +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=DDL +STMT: DropStmt +== 608 +|-- +-- Plancache invalidate on user change. +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 609 +DROP TABLE t1 CASCADE +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 610 +CREATE TABLE t1 (a integer) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 611 +GRANT SELECT ON t1 TO regress_rls_bob, regress_rls_carol +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: GrantStmt +== 612 +CREATE POLICY p1 ON t1 TO regress_rls_bob USING ((a % 2) = 0) +-- +STMT: CreatePolicyStmt +== 613 +CREATE POLICY p2 ON t1 TO regress_rls_carol USING ((a % 4) = 0) +-- +STMT: CreatePolicyStmt +== 614 +ALTER TABLE t1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +== 615 +-- Prepare as regress_rls_bob +SET ROLE regress_rls_bob +-- +STMT: VariableSetStmt +== 616 +PREPARE role_inval AS SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +== 617 +-- Check plan +EXPLAIN (COSTS OFF) EXECUTE role_inval +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 618 +-- Change to regress_rls_carol +SET ROLE regress_rls_carol +-- +STMT: VariableSetStmt +== 619 +-- Check plan- should be different +EXPLAIN (COSTS OFF) EXECUTE role_inval +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 620 +-- Change back to regress_rls_bob +SET ROLE regress_rls_bob +-- +STMT: VariableSetStmt +== 621 +-- Check plan- should be back to original +EXPLAIN (COSTS OFF) EXECUTE role_inval +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 622 +|-- +-- CTE and RLS +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 623 +DROP TABLE t1 CASCADE +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 624 +CREATE TABLE t1 (a integer, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 625 +CREATE POLICY p1 ON t1 USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 626 +ALTER TABLE t1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +== 627 +GRANT ALL ON t1 TO regress_rls_bob +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: GrantStmt +== 628 +INSERT INTO t1 (SELECT x, public.fipshash(x::text) FROM generate_series(0,20) x) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 629 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 630 +WITH cte1 AS MATERIALIZED (SELECT * FROM t1 WHERE f_leak(b)) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +CTE: "cte1" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 631 +EXPLAIN (COSTS OFF) +WITH cte1 AS MATERIALIZED (SELECT * FROM t1 WHERE f_leak(b)) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +CTE: "cte1" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 632 +WITH cte1 AS (UPDATE t1 SET a = a + 1 RETURNING *) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +CTE: "cte1" +STMT: SelectStmt +STMT: UpdateStmt +== 633 +--fail +WITH cte1 AS (UPDATE t1 SET a = a RETURNING *) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +CTE: "cte1" +STMT: SelectStmt +STMT: UpdateStmt +== 634 +--ok + +WITH cte1 AS (INSERT INTO t1 VALUES (21, 'Fail') RETURNING *) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +CTE: "cte1" +STMT: SelectStmt +STMT: InsertStmt +== 635 +--fail +WITH cte1 AS (INSERT INTO t1 VALUES (20, 'Success') RETURNING *) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +CTE: "cte1" +STMT: SelectStmt +STMT: InsertStmt +== 636 +--ok + +|-- +-- Rename Policy +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 637 +ALTER POLICY p1 ON t1 RENAME TO p1 +-- +STMT: RenameStmt +== 638 +--fail + +SELECT polname, relname + FROM pg_policy pol + JOIN pg_class pc ON (pc.oid = pol.polrelid) + WHERE relname = 't1' +-- +TABLE: name="pg_policy" schema="" table="pg_policy" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pol"="pg_policy" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 639 +ALTER POLICY p1 ON t1 RENAME TO p2 +-- +STMT: RenameStmt +== 640 +--ok + +SELECT polname, relname + FROM pg_policy pol + JOIN pg_class pc ON (pc.oid = pol.polrelid) + WHERE relname = 't1' +-- +TABLE: name="pg_policy" schema="" table="pg_policy" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pol"="pg_policy" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 641 +|-- +-- Check INSERT SELECT +|-- +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 642 +CREATE TABLE t2 (a integer, b text) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 643 +INSERT INTO t2 (SELECT * FROM t1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 644 +EXPLAIN (COSTS OFF) INSERT INTO t2 (SELECT * FROM t1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 645 +SELECT * FROM t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +== 646 +EXPLAIN (COSTS OFF) SELECT * FROM t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 647 +CREATE TABLE t3 AS SELECT * FROM t1 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 648 +SELECT * FROM t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +== 649 +SELECT * INTO t4 FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t4" schema="" table="t4" ctx=DDL +STMT: SelectStmt +== 650 +SELECT * FROM t4 +-- +TABLE: name="t4" schema="" table="t4" ctx=Select +STMT: SelectStmt +== 651 +|-- +-- RLS with JOIN +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 652 +CREATE TABLE blog (id integer, author text, post text) +-- +TABLE: name="blog" schema="" table="blog" ctx=DDL +STMT: CreateStmt +== 653 +CREATE TABLE comment (blog_id integer, message text) +-- +TABLE: name="comment" schema="" table="comment" ctx=DDL +STMT: CreateStmt +== 654 +GRANT ALL ON blog, comment TO regress_rls_bob +-- +TABLE: name="blog" schema="" table="blog" ctx=DDL +TABLE: name="comment" schema="" table="comment" ctx=DDL +STMT: GrantStmt +== 655 +CREATE POLICY blog_1 ON blog USING (id % 2 = 0) +-- +STMT: CreatePolicyStmt +== 656 +ALTER TABLE blog ENABLE ROW LEVEL SECURITY +-- +TABLE: name="blog" schema="" table="blog" ctx=DDL +STMT: AlterTableStmt +== 657 +INSERT INTO blog VALUES + (1, 'alice', 'blog #1'), + (2, 'bob', 'blog #1'), + (3, 'alice', 'blog #2'), + (4, 'alice', 'blog #3'), + (5, 'john', 'blog #1') +-- +TABLE: name="blog" schema="" table="blog" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 658 +INSERT INTO comment VALUES + (1, 'cool blog'), + (1, 'fun blog'), + (3, 'crazy blog'), + (5, 'what?'), + (4, 'insane!'), + (2, 'who did it?') +-- +TABLE: name="comment" schema="" table="comment" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 659 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 660 +-- Check RLS JOIN with Non-RLS. +SELECT id, author, message FROM blog JOIN comment ON id = blog_id +-- +TABLE: name="blog" schema="" table="blog" ctx=Select +TABLE: name="comment" schema="" table="comment" ctx=Select +STMT: SelectStmt +== 661 +-- Check Non-RLS JOIN with RLS. +SELECT id, author, message FROM comment JOIN blog ON id = blog_id +-- +TABLE: name="comment" schema="" table="comment" ctx=Select +TABLE: name="blog" schema="" table="blog" ctx=Select +STMT: SelectStmt +== 662 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 663 +CREATE POLICY comment_1 ON comment USING (blog_id < 4) +-- +STMT: CreatePolicyStmt +== 664 +ALTER TABLE comment ENABLE ROW LEVEL SECURITY +-- +TABLE: name="comment" schema="" table="comment" ctx=DDL +STMT: AlterTableStmt +== 665 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 666 +-- Check RLS JOIN RLS +SELECT id, author, message FROM blog JOIN comment ON id = blog_id +-- +TABLE: name="blog" schema="" table="blog" ctx=Select +TABLE: name="comment" schema="" table="comment" ctx=Select +STMT: SelectStmt +== 667 +SELECT id, author, message FROM comment JOIN blog ON id = blog_id +-- +TABLE: name="comment" schema="" table="comment" ctx=Select +TABLE: name="blog" schema="" table="blog" ctx=Select +STMT: SelectStmt +== 668 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 669 +DROP TABLE blog, comment +-- +TABLE: name="blog" schema="" table="blog" ctx=DDL +TABLE: name="comment" schema="" table="comment" ctx=DDL +STMT: DropStmt +== 670 +|-- +-- Default Deny Policy +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 671 +DROP POLICY p2 ON t1 +-- +STMT: DropStmt +== 672 +ALTER TABLE t1 OWNER TO regress_rls_alice +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +== 673 +-- Check that default deny does not apply to superuser. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 674 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 675 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 676 +-- Check that default deny does not apply to table owner. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +== 677 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 678 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 679 +-- Check that default deny applies to non-owner/non-superuser when RLS on. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 680 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 681 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 682 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 683 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 684 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 685 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 686 +|-- +-- COPY TO/FROM +|-- + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 687 +DROP TABLE copy_t CASCADE +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DDL +STMT: DropStmt +== 688 +CREATE TABLE copy_t (a integer, b text) +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DDL +STMT: CreateStmt +== 689 +CREATE POLICY p1 ON copy_t USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 690 +ALTER TABLE copy_t ENABLE ROW LEVEL SECURITY +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DDL +STMT: AlterTableStmt +== 691 +GRANT ALL ON copy_t TO regress_rls_bob, regress_rls_exempt_user +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DDL +STMT: GrantStmt +== 692 +INSERT INTO copy_t (SELECT x, public.fipshash(x::text) FROM generate_series(0,10) x) +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 693 +-- Check COPY TO as Superuser/owner. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 694 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 695 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 696 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 697 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 698 +-- Check COPY TO as user with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 699 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 700 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 701 +--fail - would be affected by RLS +SET row_security TO ON +-- +STMT: VariableSetStmt +== 702 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 703 +--ok + +-- Check COPY TO as user with permissions and BYPASSRLS +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +== 704 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 705 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 706 +--ok +SET row_security TO ON +-- +STMT: VariableSetStmt +== 707 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 708 +--ok + +-- Check COPY TO as user without permissions. SET row_security TO OFF; +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 709 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 710 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 711 +--fail - would be affected by RLS +SET row_security TO ON +-- +STMT: VariableSetStmt +== 712 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 713 +--fail - permission denied + +-- Check COPY relation TO; keep it just one row to avoid reordering issues +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 714 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 715 +CREATE TABLE copy_rel_to (a integer, b text) +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=DDL +STMT: CreateStmt +== 716 +CREATE POLICY p1 ON copy_rel_to USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +== 717 +ALTER TABLE copy_rel_to ENABLE ROW LEVEL SECURITY +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=DDL +STMT: AlterTableStmt +== 718 +GRANT ALL ON copy_rel_to TO regress_rls_bob, regress_rls_exempt_user +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=DDL +STMT: GrantStmt +== 719 +INSERT INTO copy_rel_to VALUES (1, public.fipshash('1')) +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 720 +-- Check COPY TO as Superuser/owner. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 721 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 722 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 723 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 724 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 725 +-- Check COPY TO as user with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 726 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 727 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 728 +--fail - would be affected by RLS +SET row_security TO ON +-- +STMT: VariableSetStmt +== 729 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 730 +--ok + +-- Check COPY TO as user with permissions and BYPASSRLS +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +== 731 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 732 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 733 +--ok +SET row_security TO ON +-- +STMT: VariableSetStmt +== 734 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 735 +--ok + +-- Check COPY TO as user without permissions. SET row_security TO OFF; +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 736 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 737 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 738 +--fail - permission denied +SET row_security TO ON +-- +STMT: VariableSetStmt +== 739 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 740 +--fail - permission denied + +-- Check behavior with a child table. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 741 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 742 +CREATE TABLE copy_rel_to_child () INHERITS (copy_rel_to) +-- +TABLE: name="copy_rel_to_child" schema="" table="copy_rel_to_child" ctx=DDL +STMT: CreateStmt +== 743 +INSERT INTO copy_rel_to_child VALUES (1, 'one'), (2, 'two') +-- +TABLE: name="copy_rel_to_child" schema="" table="copy_rel_to_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 744 +-- Check COPY TO as Superuser/owner. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 745 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 746 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 747 +SET row_security TO ON +-- +STMT: VariableSetStmt +== 748 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 749 +-- Check COPY TO as user with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 750 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 751 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 752 +--fail - would be affected by RLS +SET row_security TO ON +-- +STMT: VariableSetStmt +== 753 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 754 +--ok + +-- Check COPY TO as user with permissions and BYPASSRLS +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +== 755 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 756 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 757 +--ok +SET row_security TO ON +-- +STMT: VariableSetStmt +== 758 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 759 +--ok + +-- Check COPY TO as user without permissions. SET row_security TO OFF; +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 760 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 761 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 762 +--fail - permission denied +SET row_security TO ON +-- +STMT: VariableSetStmt +== 763 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +== 764 +--fail - permission denied + +-- Check COPY FROM as Superuser/owner. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 765 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 766 +COPY copy_t FROM STDIN +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 767 +--ok +1 abc +2 bcd +3 cde +4 def +SET row_security TO ON +-- +ERROR: syntax error at or near "1" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 768 +-- Check COPY FROM as user with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +== 769 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 770 +COPY copy_t FROM STDIN +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 771 +--fail - would be affected by RLS. +SET row_security TO ON +-- +STMT: VariableSetStmt +== 772 +-- Check COPY FROM as user without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +== 773 +SET row_security TO OFF +-- +STMT: VariableSetStmt +== 774 +COPY copy_t FROM STDIN +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +== 775 +--fail - permission denied. +SET row_security TO ON +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/rowtypes.metadata.json b/parser/testdata/summary/postgres_regress/rowtypes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rowtypes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/rowtypes.test b/parser/testdata/summary/postgres_regress/rowtypes.test new file mode 100644 index 0000000..4c064f9 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rowtypes.test @@ -0,0 +1,1424 @@ +== 001 +|-- +-- ROWTYPES +|-- + +-- Make both a standalone composite type and a table rowtype + +create type complex as (r float8, i float8) +-- +STMT: CompositeTypeStmt +== 002 +create temp table fullname (first text, last text) +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DDL +STMT: CreateStmt +== 003 +-- Nested composite + +create type quad as (c1 complex, c2 complex) +-- +STMT: CompositeTypeStmt +== 004 +-- Some simple tests of I/O conversions and row construction + +select (1.1,2.2)::complex, row((3.3,4.4),(5.5,null))::quad +-- +STMT: SelectStmt +== 005 +select row('Joe', 'Blow')::fullname, '(Joe,Blow)'::fullname +-- +STMT: SelectStmt +== 006 +select '(Joe,von Blow)'::fullname, '(Joe,d''Blow)'::fullname +-- +STMT: SelectStmt +== 007 +select '(Joe,"von""Blow")'::fullname, E'(Joe,d\\\\Blow)'::fullname +-- +STMT: SelectStmt +== 008 +select '(Joe,"Blow,Jr")'::fullname +-- +STMT: SelectStmt +== 009 +select '(Joe,)'::fullname +-- +STMT: SelectStmt +== 010 +-- ok, null 2nd column +select '(Joe)'::fullname +-- +STMT: SelectStmt +== 011 +-- bad +select '(Joe,,)'::fullname +-- +STMT: SelectStmt +== 012 +-- bad +select '[]'::fullname +-- +STMT: SelectStmt +== 013 +-- bad +select ' (Joe,Blow) '::fullname +-- +STMT: SelectStmt +== 014 +-- ok, extra whitespace +select '(Joe,Blow) /'::fullname +-- +STMT: SelectStmt +== 015 +-- bad + +-- test non-error-throwing API +SELECT pg_input_is_valid('(1,2)', 'complex') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT pg_input_is_valid('(1,2', 'complex') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT pg_input_is_valid('(1,zed)', 'complex') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT * FROM pg_input_error_info('(1,zed)', 'complex') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT * FROM pg_input_error_info('(1,1e400)', 'complex') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 020 +create temp table quadtable(f1 int, q quad) +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DDL +STMT: CreateStmt +== 021 +insert into quadtable values (1, ((3.3,4.4),(5.5,6.6))) +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +insert into quadtable values (2, ((null,4.4),(5.5,6.6))) +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +select * from quadtable +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=Select +STMT: SelectStmt +== 024 +select f1, q.c1 from quadtable +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=Select +STMT: SelectStmt +== 025 +-- fails, q is a table reference + +select f1, (q).c1, (qq.q).c1.i from quadtable qq +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=Select +ALIAS: "qq"="quadtable" +STMT: SelectStmt +== 026 +create temp table people (fn fullname, bd date) +-- +TABLE: name="people" schema="" table="people" ctx=DDL +STMT: CreateStmt +== 027 +insert into people values ('(Joe,Blow)', '1984-01-10') +-- +TABLE: name="people" schema="" table="people" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +select * from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +STMT: SelectStmt +== 029 +-- at the moment this will not work due to ALTER TABLE inadequacy: +alter table fullname add column suffix text default '' +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DDL +STMT: AlterTableStmt +== 030 +-- but this should work: +alter table fullname add column suffix text default null +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DDL +STMT: AlterTableStmt +== 031 +select * from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +STMT: SelectStmt +== 032 +-- test insertion/updating of subfields +update people set fn.suffix = 'Jr' +-- +TABLE: name="people" schema="" table="people" ctx=DML +STMT: UpdateStmt +== 033 +select * from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +STMT: SelectStmt +== 034 +insert into quadtable (f1, q.c1.r, q.c2.i) values(44,55,66) +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +update quadtable set q.c1.r = 12 where f1 = 2 +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: UpdateStmt +== 036 +update quadtable set q.c1 = 12 +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: UpdateStmt +== 037 +-- error, type mismatch + +select * from quadtable +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=Select +STMT: SelectStmt +== 038 +-- The object here is to ensure that toasted references inside +-- composite values don't cause problems. The large f1 value will +-- be toasted inside pp, it must still work after being copied to people. + +create temp table pp (f1 text) +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +STMT: CreateStmt +== 039 +insert into pp values (repeat('abcdefghijkl', 100000)) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 040 +insert into people select ('Jim', f1, null)::fullname, current_date from pp +-- +TABLE: name="people" schema="" table="people" ctx=DML +TABLE: name="pp" schema="" table="pp" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 041 +select (fn).first, substr((fn).last, 1, 20), length((fn).last) from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 042 +-- try an update on a toasted composite value, too +update people set fn.first = 'Jack' +-- +TABLE: name="people" schema="" table="people" ctx=DML +STMT: UpdateStmt +== 043 +select (fn).first, substr((fn).last, 1, 20), length((fn).last) from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 044 +-- Test row comparison semantics. Prior to PG 8.2 we did this in a totally +-- non-spec-compliant way. + +select ROW(1,2) < ROW(1,3) as true +-- +STMT: SelectStmt +== 045 +select ROW(1,2) < ROW(1,1) as false +-- +STMT: SelectStmt +== 046 +select ROW(1,2) < ROW(1,NULL) as null +-- +STMT: SelectStmt +== 047 +select ROW(1,2,3) < ROW(1,3,NULL) as true +-- +STMT: SelectStmt +== 048 +-- the NULL is not examined +select ROW(11,'ABC') < ROW(11,'DEF') as true +-- +STMT: SelectStmt +== 049 +select ROW(11,'ABC') > ROW(11,'DEF') as false +-- +STMT: SelectStmt +== 050 +select ROW(12,'ABC') > ROW(11,'DEF') as true +-- +STMT: SelectStmt +== 051 +-- = and <> have different NULL-behavior than < etc +select ROW(1,2,3) < ROW(1,NULL,4) as null +-- +STMT: SelectStmt +== 052 +select ROW(1,2,3) = ROW(1,NULL,4) as false +-- +STMT: SelectStmt +== 053 +select ROW(1,2,3) <> ROW(1,NULL,4) as true +-- +STMT: SelectStmt +== 054 +-- We allow operators beyond the six standard ones, if they have btree +-- operator classes. +select ROW('ABC','DEF') ~<=~ ROW('DEF','ABC') as true +-- +STMT: SelectStmt +== 055 +select ROW('ABC','DEF') ~>=~ ROW('DEF','ABC') as false +-- +STMT: SelectStmt +== 056 +select ROW('ABC','DEF') ~~ ROW('DEF','ABC') as fail +-- +STMT: SelectStmt +== 057 +-- Comparisons of ROW() expressions can cope with some type mismatches +select ROW(1,2) = ROW(1,2::int8) +-- +STMT: SelectStmt +== 058 +select ROW(1,2) in (ROW(3,4), ROW(1,2)) +-- +STMT: SelectStmt +== 059 +select ROW(1,2) in (ROW(3,4), ROW(1,2::int8)) +-- +STMT: SelectStmt +== 060 +-- Check row comparison with a subselect +select unique1, unique2 from tenk1 +where (unique1, unique2) < any (select ten, ten from tenk1 where hundred < 3) + and unique1 <= 20 +order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 061 +-- Also check row comparison with an indexable condition +explain (costs off) +select thousand, tenthous from tenk1 +where (thousand, tenthous) >= (997, 5000) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 062 +select thousand, tenthous from tenk1 +where (thousand, tenthous) >= (997, 5000) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 063 +explain (costs off) +select thousand, tenthous, four from tenk1 +where (thousand, tenthous, four) > (998, 5000, 3) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 064 +select thousand, tenthous, four from tenk1 +where (thousand, tenthous, four) > (998, 5000, 3) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="four" +STMT: SelectStmt +== 065 +explain (costs off) +select thousand, tenthous from tenk1 +where (998, 5000) < (thousand, tenthous) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 066 +select thousand, tenthous from tenk1 +where (998, 5000) < (thousand, tenthous) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 067 +explain (costs off) +select thousand, hundred from tenk1 +where (998, 5000) < (thousand, hundred) +order by thousand, hundred +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 068 +select thousand, hundred from tenk1 +where (998, 5000) < (thousand, hundred) +order by thousand, hundred +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 069 +-- Test case for bug #14010: indexed row comparisons fail with nulls +create temp table test_table (a text, b text) +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DDL +STMT: CreateStmt +== 070 +insert into test_table values ('a', 'b') +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +insert into test_table select 'a', null from generate_series(1,1000) +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 072 +insert into test_table values ('b', 'a') +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +create index on test_table (a,b) +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DDL +STMT: IndexStmt +== 074 +set enable_sort = off +-- +STMT: VariableSetStmt +== 075 +explain (costs off) +select a,b from test_table where (a,b) > ('a','a') order by a,b +-- +TABLE: name="test_table" schema="" table="test_table" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 076 +select a,b from test_table where (a,b) > ('a','a') order by a,b +-- +TABLE: name="test_table" schema="" table="test_table" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 077 +reset enable_sort +-- +STMT: VariableSetStmt +== 078 +-- Check row comparisons with IN +select * from int8_tbl i8 where i8 in (row(123,456)) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="" column="i8" +STMT: SelectStmt +== 079 +-- fail, type mismatch + +explain (costs off) +select * from int8_tbl i8 +where i8 in (row(123,456)::int8_tbl, '(4567890123456789,123)') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="" column="i8" +STMT: ExplainStmt +STMT: SelectStmt +== 080 +select * from int8_tbl i8 +where i8 in (row(123,456)::int8_tbl, '(4567890123456789,123)') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="" column="i8" +STMT: SelectStmt +== 081 +-- Check ability to select columns from an anonymous rowtype +select (row(1, 2.0)).f1 +-- +STMT: SelectStmt +== 082 +select (row(1, 2.0)).f2 +-- +STMT: SelectStmt +== 083 +select (row(1, 2.0)).nosuch +-- +STMT: SelectStmt +== 084 +-- fail +select (row(1, 2.0)).* +-- +STMT: SelectStmt +== 085 +select (r).f1 from (select row(1, 2.0) as r) ss +-- +STMT: SelectStmt +== 086 +select (r).f3 from (select row(1, 2.0) as r) ss +-- +STMT: SelectStmt +== 087 +-- fail +select (r).* from (select row(1, 2.0) as r) ss +-- +STMT: SelectStmt +== 088 +-- Check some corner cases involving empty rowtypes +select ROW() +-- +STMT: SelectStmt +== 089 +select ROW() IS NULL +-- +STMT: SelectStmt +== 090 +select ROW() = ROW() +-- +STMT: SelectStmt +== 091 +-- Check ability to create arrays of anonymous rowtypes +select array[ row(1,2), row(3,4), row(5,6) ] +-- +STMT: SelectStmt +== 092 +-- Check ability to compare an anonymous row to elements of an array +select row(1,1.1) = any (array[ row(7,7.7), row(1,1.1), row(0,0.0) ]) +-- +STMT: SelectStmt +== 093 +select row(1,1.1) = any (array[ row(7,7.7), row(1,1.0), row(0,0.0) ]) +-- +STMT: SelectStmt +== 094 +-- Check behavior with a non-comparable rowtype +create type cantcompare as (p point, r float8) +-- +STMT: CompositeTypeStmt +== 095 +create temp table cc (f1 cantcompare) +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: CreateStmt +== 096 +insert into cc values('("(1,2)",3)') +-- +TABLE: name="cc" schema="" table="cc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +insert into cc values('("(4,5)",6)') +-- +TABLE: name="cc" schema="" table="cc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +select * from cc order by f1 +-- +TABLE: name="cc" schema="" table="cc" ctx=Select +STMT: SelectStmt +== 099 +-- fail, but should complain about cantcompare + +|-- +-- Tests for record_{eq,cmp} +|-- + +create type testtype1 as (a int, b int) +-- +STMT: CompositeTypeStmt +== 100 +-- all true +select row(1, 2)::testtype1 < row(1, 3)::testtype1 +-- +STMT: SelectStmt +== 101 +select row(1, 2)::testtype1 <= row(1, 3)::testtype1 +-- +STMT: SelectStmt +== 102 +select row(1, 2)::testtype1 = row(1, 2)::testtype1 +-- +STMT: SelectStmt +== 103 +select row(1, 2)::testtype1 <> row(1, 3)::testtype1 +-- +STMT: SelectStmt +== 104 +select row(1, 3)::testtype1 >= row(1, 2)::testtype1 +-- +STMT: SelectStmt +== 105 +select row(1, 3)::testtype1 > row(1, 2)::testtype1 +-- +STMT: SelectStmt +== 106 +-- all false +select row(1, -2)::testtype1 < row(1, -3)::testtype1 +-- +STMT: SelectStmt +== 107 +select row(1, -2)::testtype1 <= row(1, -3)::testtype1 +-- +STMT: SelectStmt +== 108 +select row(1, -2)::testtype1 = row(1, -3)::testtype1 +-- +STMT: SelectStmt +== 109 +select row(1, -2)::testtype1 <> row(1, -2)::testtype1 +-- +STMT: SelectStmt +== 110 +select row(1, -3)::testtype1 >= row(1, -2)::testtype1 +-- +STMT: SelectStmt +== 111 +select row(1, -3)::testtype1 > row(1, -2)::testtype1 +-- +STMT: SelectStmt +== 112 +-- true, but see *< below +select row(1, -2)::testtype1 < row(1, 3)::testtype1 +-- +STMT: SelectStmt +== 113 +-- mismatches +create type testtype3 as (a int, b text) +-- +STMT: CompositeTypeStmt +== 114 +select row(1, 2)::testtype1 < row(1, 'abc')::testtype3 +-- +STMT: SelectStmt +== 115 +select row(1, 2)::testtype1 <> row(1, 'abc')::testtype3 +-- +STMT: SelectStmt +== 116 +create type testtype5 as (a int) +-- +STMT: CompositeTypeStmt +== 117 +select row(1, 2)::testtype1 < row(1)::testtype5 +-- +STMT: SelectStmt +== 118 +select row(1, 2)::testtype1 <> row(1)::testtype5 +-- +STMT: SelectStmt +== 119 +-- non-comparable types +create type testtype6 as (a int, b point) +-- +STMT: CompositeTypeStmt +== 120 +select row(1, '(1,2)')::testtype6 < row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +== 121 +select row(1, '(1,2)')::testtype6 <> row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +== 122 +drop type testtype1, testtype3, testtype5, testtype6 +-- +STMT: DropStmt +== 123 +|-- +-- Tests for record_image_{eq,cmp} +|-- + +create type testtype1 as (a int, b int) +-- +STMT: CompositeTypeStmt +== 124 +-- all true +select row(1, 2)::testtype1 *< row(1, 3)::testtype1 +-- +STMT: SelectStmt +== 125 +select row(1, 2)::testtype1 *<= row(1, 3)::testtype1 +-- +STMT: SelectStmt +== 126 +select row(1, 2)::testtype1 *= row(1, 2)::testtype1 +-- +STMT: SelectStmt +== 127 +select row(1, 2)::testtype1 *<> row(1, 3)::testtype1 +-- +STMT: SelectStmt +== 128 +select row(1, 3)::testtype1 *>= row(1, 2)::testtype1 +-- +STMT: SelectStmt +== 129 +select row(1, 3)::testtype1 *> row(1, 2)::testtype1 +-- +STMT: SelectStmt +== 130 +-- all false +select row(1, -2)::testtype1 *< row(1, -3)::testtype1 +-- +STMT: SelectStmt +== 131 +select row(1, -2)::testtype1 *<= row(1, -3)::testtype1 +-- +STMT: SelectStmt +== 132 +select row(1, -2)::testtype1 *= row(1, -3)::testtype1 +-- +STMT: SelectStmt +== 133 +select row(1, -2)::testtype1 *<> row(1, -2)::testtype1 +-- +STMT: SelectStmt +== 134 +select row(1, -3)::testtype1 *>= row(1, -2)::testtype1 +-- +STMT: SelectStmt +== 135 +select row(1, -3)::testtype1 *> row(1, -2)::testtype1 +-- +STMT: SelectStmt +== 136 +-- This returns the "wrong" order because record_image_cmp works on +-- unsigned datums without knowing about the actual data type. +select row(1, -2)::testtype1 *< row(1, 3)::testtype1 +-- +STMT: SelectStmt +== 137 +-- other types +create type testtype2 as (a smallint, b bool) +-- +STMT: CompositeTypeStmt +== 138 +-- byval different sizes +select row(1, true)::testtype2 *< row(2, true)::testtype2 +-- +STMT: SelectStmt +== 139 +select row(-2, true)::testtype2 *< row(-1, true)::testtype2 +-- +STMT: SelectStmt +== 140 +select row(0, false)::testtype2 *< row(0, true)::testtype2 +-- +STMT: SelectStmt +== 141 +select row(0, false)::testtype2 *<> row(0, true)::testtype2 +-- +STMT: SelectStmt +== 142 +create type testtype3 as (a int, b text) +-- +STMT: CompositeTypeStmt +== 143 +-- variable length +select row(1, 'abc')::testtype3 *< row(1, 'abd')::testtype3 +-- +STMT: SelectStmt +== 144 +select row(1, 'abc')::testtype3 *< row(1, 'abcd')::testtype3 +-- +STMT: SelectStmt +== 145 +select row(1, 'abc')::testtype3 *> row(1, 'abd')::testtype3 +-- +STMT: SelectStmt +== 146 +select row(1, 'abc')::testtype3 *<> row(1, 'abd')::testtype3 +-- +STMT: SelectStmt +== 147 +create type testtype4 as (a int, b point) +-- +STMT: CompositeTypeStmt +== 148 +-- by ref, fixed length +select row(1, '(1,2)')::testtype4 *< row(1, '(1,3)')::testtype4 +-- +STMT: SelectStmt +== 149 +select row(1, '(1,2)')::testtype4 *<> row(1, '(1,3)')::testtype4 +-- +STMT: SelectStmt +== 150 +-- mismatches +select row(1, 2)::testtype1 *< row(1, 'abc')::testtype3 +-- +STMT: SelectStmt +== 151 +select row(1, 2)::testtype1 *<> row(1, 'abc')::testtype3 +-- +STMT: SelectStmt +== 152 +create type testtype5 as (a int) +-- +STMT: CompositeTypeStmt +== 153 +select row(1, 2)::testtype1 *< row(1)::testtype5 +-- +STMT: SelectStmt +== 154 +select row(1, 2)::testtype1 *<> row(1)::testtype5 +-- +STMT: SelectStmt +== 155 +-- non-comparable types +create type testtype6 as (a int, b point) +-- +STMT: CompositeTypeStmt +== 156 +select row(1, '(1,2)')::testtype6 *< row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +== 157 +select row(1, '(1,2)')::testtype6 *>= row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +== 158 +select row(1, '(1,2)')::testtype6 *<> row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +== 159 +-- anonymous rowtypes in coldeflists +select q.a, q.b = row(2), q.c = array[row(3)], q.d = row(row(4)) from + unnest(array[row(1, row(2), array[row(3)], row(row(4))), + row(2, row(3), array[row(4)], row(row(5)))]) + as q(a int, b record, c record[], d record) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 160 +drop type testtype1, testtype2, testtype3, testtype4, testtype5, testtype6 +-- +STMT: DropStmt +== 161 +|-- +-- Test case derived from bug #5716: check multiple uses of a rowtype result +|-- + +BEGIN +-- +STMT: TransactionStmt +== 162 +CREATE TABLE price ( + id SERIAL PRIMARY KEY, + active BOOLEAN NOT NULL, + price NUMERIC +) +-- +TABLE: name="price" schema="" table="price" ctx=DDL +STMT: CreateStmt +== 163 +CREATE TYPE price_input AS ( + id INTEGER, + price NUMERIC +) +-- +STMT: CompositeTypeStmt +== 164 +CREATE TYPE price_key AS ( + id INTEGER +) +-- +STMT: CompositeTypeStmt +== 165 +CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$ + SELECT $1.id +$$ LANGUAGE SQL +-- +FUNCTION: name="price_key_from_table" function="price_key_from_table" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 166 +CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$ + SELECT $1.id +$$ LANGUAGE SQL +-- +FUNCTION: name="price_key_from_input" function="price_key_from_input" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 167 +insert into price values (1,false,42), (10,false,100), (11,true,17.99) +-- +TABLE: name="price" schema="" table="price" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +UPDATE price + SET active = true, price = input_prices.price + FROM unnest(ARRAY[(10, 123.00), (11, 99.99)]::price_input[]) input_prices + WHERE price_key_from_table(price.*) = price_key_from_input(input_prices.*) +-- +TABLE: name="price" schema="" table="price" ctx=DML +FUNCTION: name="price_key_from_table" function="price_key_from_table" schema="" ctx=Call +FUNCTION: name="price_key_from_input" function="price_key_from_input" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: UpdateStmt +== 169 +select * from price +-- +TABLE: name="price" schema="" table="price" ctx=Select +STMT: SelectStmt +== 170 +rollback +-- +STMT: TransactionStmt +== 171 +|-- +-- Test case derived from bug #9085: check * qualification of composite +-- parameters for SQL functions +|-- + +create temp table compos (f1 int, f2 text) +-- +TABLE: name="compos" schema="" table="compos" ctx=DDL +STMT: CreateStmt +== 172 +create function fcompos1(v compos) returns void as $$ +insert into compos values (v); -- fail +$$ language sql +-- +FUNCTION: name="fcompos1" function="fcompos1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 173 +create function fcompos1(v compos) returns void as $$ +insert into compos values (v.*); +$$ language sql +-- +FUNCTION: name="fcompos1" function="fcompos1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 174 +create function fcompos2(v compos) returns void as $$ +select fcompos1(v); +$$ language sql +-- +FUNCTION: name="fcompos2" function="fcompos2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 175 +create function fcompos3(v compos) returns void as $$ +select fcompos1(fcompos3.v.*); +$$ language sql +-- +FUNCTION: name="fcompos3" function="fcompos3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 176 +select fcompos1(row(1,'one')) +-- +FUNCTION: name="fcompos1" function="fcompos1" schema="" ctx=Call +STMT: SelectStmt +== 177 +select fcompos2(row(2,'two')) +-- +FUNCTION: name="fcompos2" function="fcompos2" schema="" ctx=Call +STMT: SelectStmt +== 178 +select fcompos3(row(3,'three')) +-- +FUNCTION: name="fcompos3" function="fcompos3" schema="" ctx=Call +STMT: SelectStmt +== 179 +select * from compos +-- +TABLE: name="compos" schema="" table="compos" ctx=Select +STMT: SelectStmt +== 180 +|-- +-- We allow I/O conversion casts from composite types to strings to be +-- invoked via cast syntax, but not functional syntax. This is because +-- the latter is too prone to be invoked unintentionally. +|-- +select cast (fullname as text) from fullname +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +STMT: SelectStmt +== 181 +select fullname::text from fullname +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +STMT: SelectStmt +== 182 +select text(fullname) from fullname +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +FUNCTION: name="text" function="text" schema="" ctx=Call +STMT: SelectStmt +== 183 +-- error +select fullname.text from fullname +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +STMT: SelectStmt +== 184 +-- error +-- same, but RECORD instead of named composite type: +select cast (row('Jim', 'Beam') as text) +-- +STMT: SelectStmt +== 185 +select (row('Jim', 'Beam'))::text +-- +STMT: SelectStmt +== 186 +select text(row('Jim', 'Beam')) +-- +FUNCTION: name="text" function="text" schema="" ctx=Call +STMT: SelectStmt +== 187 +-- error +select (row('Jim', 'Beam')).text +-- +STMT: SelectStmt +== 188 +-- error + +|-- +-- Check the equivalence of functional and column notation +|-- +insert into fullname values ('Joe', 'Blow') +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +select f.last from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +STMT: SelectStmt +== 190 +select last(f) from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +FUNCTION: name="last" function="last" schema="" ctx=Call +STMT: SelectStmt +== 191 +create function longname(fullname) returns text language sql +as $$select $1.first || ' ' || $1.last$$ +-- +FUNCTION: name="longname" function="longname" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 192 +select f.longname from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +STMT: SelectStmt +== 193 +select longname(f) from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +FUNCTION: name="longname" function="longname" schema="" ctx=Call +STMT: SelectStmt +== 194 +-- Starting in v11, the notational form does matter if there's ambiguity +alter table fullname add column longname text +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DDL +STMT: AlterTableStmt +== 195 +select f.longname from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +STMT: SelectStmt +== 196 +select longname(f) from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +FUNCTION: name="longname" function="longname" schema="" ctx=Call +STMT: SelectStmt +== 197 +|-- +-- Test that composite values are seen to have the correct column names +-- (bug #11210 and other reports) +|-- + +select row_to_json(i) from int8_tbl i +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 198 +-- since "i" is of type "int8_tbl", attaching aliases doesn't change anything: +select row_to_json(i) from int8_tbl i(x,y) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 199 +-- in these examples, we'll report the exposed column names of the subselect: +select row_to_json(ss) from + (select q1, q2 from int8_tbl) as ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 200 +select row_to_json(ss) from + (select q1, q2 from int8_tbl offset 0) as ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 201 +select row_to_json(ss) from + (select q1 as a, q2 as b from int8_tbl) as ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 202 +select row_to_json(ss) from + (select q1 as a, q2 as b from int8_tbl offset 0) as ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 203 +select row_to_json(ss) from + (select q1 as a, q2 as b from int8_tbl) as ss(x,y) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 204 +select row_to_json(ss) from + (select q1 as a, q2 as b from int8_tbl offset 0) as ss(x,y) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 205 +explain (costs off) +select row_to_json(q) from + (select thousand, tenthous from tenk1 + where thousand = 42 and tenthous < 2000 offset 0) q +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 206 +select row_to_json(q) from + (select thousand, tenthous from tenk1 + where thousand = 42 and tenthous < 2000 offset 0) q +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 207 +select row_to_json(q) from + (select thousand as x, tenthous as y from tenk1 + where thousand = 42 and tenthous < 2000 offset 0) q +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 208 +select row_to_json(q) from + (select thousand as x, tenthous as y from tenk1 + where thousand = 42 and tenthous < 2000 offset 0) q(a,b) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +== 209 +create temp table tt1 as select * from int8_tbl limit 2 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 210 +create temp table tt2 () inherits(tt1) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: CreateStmt +== 211 +insert into tt2 values(0,0) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 212 +select row_to_json(r) from (select q2,q1 from tt1 offset 0) r +-- +TABLE: name="tt1" schema="" table="tt1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 213 +-- check no-op rowtype conversions +create temp table tt3 () inherits(tt2) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: CreateStmt +== 214 +insert into tt3 values(33,44) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 215 +select row_to_json(tt3::tt2::tt1) from tt3 +-- +TABLE: name="tt3" schema="" table="tt3" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +== 216 +|-- +-- IS [NOT] NULL should not recurse into nested composites (bug #14235) +|-- + +explain (verbose, costs off) +select r, r is null as isnull, r is not null as isnotnull +from (values (1,row(1,2)), (1,row(null,null)), (1,null), + (null,row(1,2)), (null,row(null,null)), (null,null) ) r(a,b) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 217 +select r, r is null as isnull, r is not null as isnotnull +from (values (1,row(1,2)), (1,row(null,null)), (1,null), + (null,row(1,2)), (null,row(null,null)), (null,null) ) r(a,b) +-- +STMT: SelectStmt +== 218 +explain (verbose, costs off) +with r(a,b) as materialized + (values (1,row(1,2)), (1,row(null,null)), (1,null), + (null,row(1,2)), (null,row(null,null)), (null,null) ) +select r, r is null as isnull, r is not null as isnotnull from r +-- +CTE: "r" +STMT: ExplainStmt +STMT: SelectStmt +== 219 +with r(a,b) as materialized + (values (1,row(1,2)), (1,row(null,null)), (1,null), + (null,row(1,2)), (null,row(null,null)), (null,null) ) +select r, r is null as isnull, r is not null as isnotnull from r +-- +CTE: "r" +STMT: SelectStmt +== 220 +|-- +-- Check parsing of indirect references to composite values (bug #18077) +|-- +explain (verbose, costs off) +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select * from cte2 as t +where (select * from (select c as c1) s + where (select (c1).f1 > 0)) is not null +-- +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: ExplainStmt +STMT: SelectStmt +== 221 +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select * from cte2 as t +where (select * from (select c as c1) s + where (select (c1).f1 > 0)) is not null +-- +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: SelectStmt +== 222 +-- Also check deparsing of such cases +create view composite_v as +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select 1 as one from cte2 as t +where (select * from (select c as c1) s + where (select (c1).f1 > 0)) is not null +-- +TABLE: name="composite_v" schema="" table="composite_v" ctx=DDL +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: ViewStmt +STMT: SelectStmt +== 223 +select pg_get_viewdef('composite_v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 224 +drop view composite_v +-- +STMT: DropStmt +== 225 +|-- +-- Check cases where the composite comes from a proven-dummy rel (bug #18576) +|-- +explain (verbose, costs off) +select (ss.a).x, (ss.a).n from + (select information_schema._pg_expandarray(array[1,2]) AS a) ss +-- +FUNCTION: name="information_schema._pg_expandarray" function="_pg_expandarray" schema="information_schema" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 226 +explain (verbose, costs off) +select (ss.a).x, (ss.a).n from + (select information_schema._pg_expandarray(array[1,2]) AS a) ss +where false +-- +FUNCTION: name="information_schema._pg_expandarray" function="_pg_expandarray" schema="information_schema" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 227 +explain (verbose, costs off) +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select (c).f1 from cte2 as t +-- +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: ExplainStmt +STMT: SelectStmt +== 228 +explain (verbose, costs off) +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select (c).f1 from cte2 as t +where false +-- +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: ExplainStmt +STMT: SelectStmt +== 229 +|-- +-- Tests for component access / FieldSelect +|-- +CREATE TABLE compositetable(a text, b text) +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=DDL +STMT: CreateStmt +== 230 +INSERT INTO compositetable(a, b) VALUES('fa', 'fb') +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 231 +-- composite type columns can't directly be accessed (error) +SELECT d.a FROM (SELECT compositetable AS d FROM compositetable) s +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=Select +STMT: SelectStmt +== 232 +-- but can be accessed with proper parens +SELECT (d).a, (d).b FROM (SELECT compositetable AS d FROM compositetable) s +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=Select +STMT: SelectStmt +== 233 +-- system columns can't be accessed in composite types (error) +SELECT (d).ctid FROM (SELECT compositetable AS d FROM compositetable) s +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=Select +STMT: SelectStmt +== 234 +-- accessing non-existing column in NULL datum errors out +SELECT (NULL::compositetable).nonexistent +-- +STMT: SelectStmt +== 235 +-- existing column in a NULL composite yield NULL +SELECT (NULL::compositetable).a +-- +STMT: SelectStmt +== 236 +-- oids can't be accessed in composite types (error) +SELECT (NULL::compositetable).oid +-- +STMT: SelectStmt +== 237 +DROP TABLE compositetable +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/rules.metadata.json b/parser/testdata/summary/postgres_regress/rules.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rules.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/rules.test b/parser/testdata/summary/postgres_regress/rules.test new file mode 100644 index 0000000..8081287 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/rules.test @@ -0,0 +1,4008 @@ +== 001 +|-- +-- RULES +-- From Jan's original setup_ruletest.sql and run_ruletest.sql +-- - thomas 1998-09-13 +|-- + +|-- +-- Tables and rules for the view test +|-- +create table rtest_t1 (a int4, b int4) +-- +TABLE: name="rtest_t1" schema="" table="rtest_t1" ctx=DDL +STMT: CreateStmt +== 002 +create table rtest_t2 (a int4, b int4) +-- +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=DDL +STMT: CreateStmt +== 003 +create table rtest_t3 (a int4, b int4) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DDL +STMT: CreateStmt +== 004 +create view rtest_v1 as select * from rtest_t1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DDL +TABLE: name="rtest_t1" schema="" table="rtest_t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 005 +create rule rtest_v1_ins as on insert to rtest_v1 do instead + insert into rtest_t1 values (new.a, new.b) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DDL +STMT: RuleStmt +== 006 +create rule rtest_v1_upd as on update to rtest_v1 do instead + update rtest_t1 set a = new.a, b = new.b + where a = old.a +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DDL +STMT: RuleStmt +== 007 +create rule rtest_v1_del as on delete to rtest_v1 do instead + delete from rtest_t1 where a = old.a +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DDL +STMT: RuleStmt +== 008 +-- Test comments +COMMENT ON RULE rtest_v1_bad ON rtest_v1 IS 'bad rule' +-- +STMT: CommentStmt +== 009 +COMMENT ON RULE rtest_v1_del ON rtest_v1 IS 'delete rule' +-- +STMT: CommentStmt +== 010 +COMMENT ON RULE rtest_v1_del ON rtest_v1 IS NULL +-- +STMT: CommentStmt +== 011 +|-- +-- Tables and rules for the constraint update/delete test +|-- +-- Note: +-- Now that we have multiple action rule support, we check +-- both possible syntaxes to define them (The last action +-- can but must not have a semicolon at the end). +|-- +create table rtest_system (sysname text, sysdesc text) +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DDL +STMT: CreateStmt +== 012 +create table rtest_interface (sysname text, ifname text) +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DDL +STMT: CreateStmt +== 013 +create table rtest_person (pname text, pdesc text) +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DDL +STMT: CreateStmt +== 014 +create table rtest_admin (pname text, sysname text) +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=DDL +STMT: CreateStmt +== 015 +create rule rtest_sys_upd as on update to rtest_system do also ( + update rtest_interface set sysname = new.sysname + where sysname = old.sysname; + update rtest_admin set sysname = new.sysname + where sysname = old.sysname + ) +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DDL +STMT: RuleStmt +== 016 +create rule rtest_sys_del as on delete to rtest_system do also ( + delete from rtest_interface where sysname = old.sysname; + delete from rtest_admin where sysname = old.sysname; + ) +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DDL +STMT: RuleStmt +== 017 +create rule rtest_pers_upd as on update to rtest_person do also + update rtest_admin set pname = new.pname where pname = old.pname +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DDL +STMT: RuleStmt +== 018 +create rule rtest_pers_del as on delete to rtest_person do also + delete from rtest_admin where pname = old.pname +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DDL +STMT: RuleStmt +== 019 +|-- +-- Tables and rules for the logging test +|-- +create table rtest_emp (ename char(20), salary numeric) +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DDL +STMT: CreateStmt +== 020 +create table rtest_emplog (ename char(20), who name, action char(10), newsal numeric, oldsal numeric) +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=DDL +STMT: CreateStmt +== 021 +create table rtest_empmass (ename char(20), salary numeric) +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DDL +STMT: CreateStmt +== 022 +create rule rtest_emp_ins as on insert to rtest_emp do + insert into rtest_emplog values (new.ename, current_user, + 'hired', new.salary, '0.00') +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DDL +STMT: RuleStmt +== 023 +create rule rtest_emp_upd as on update to rtest_emp where new.salary != old.salary do + insert into rtest_emplog values (new.ename, current_user, + 'honored', new.salary, old.salary) +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DDL +STMT: RuleStmt +== 024 +create rule rtest_emp_del as on delete to rtest_emp do + insert into rtest_emplog values (old.ename, current_user, + 'fired', '0.00', old.salary) +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DDL +STMT: RuleStmt +== 025 +|-- +-- Tables and rules for the multiple cascaded qualified instead +-- rule test +|-- +create table rtest_t4 (a int4, b text) +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DDL +STMT: CreateStmt +== 026 +create table rtest_t5 (a int4, b text) +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=DDL +STMT: CreateStmt +== 027 +create table rtest_t6 (a int4, b text) +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=DDL +STMT: CreateStmt +== 028 +create table rtest_t7 (a int4, b text) +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=DDL +STMT: CreateStmt +== 029 +create table rtest_t8 (a int4, b text) +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=DDL +STMT: CreateStmt +== 030 +create table rtest_t9 (a int4, b text) +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DDL +STMT: CreateStmt +== 031 +create rule rtest_t4_ins1 as on insert to rtest_t4 + where new.a >= 10 and new.a < 20 do instead + insert into rtest_t5 values (new.a, new.b) +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DDL +STMT: RuleStmt +== 032 +create rule rtest_t4_ins2 as on insert to rtest_t4 + where new.a >= 20 and new.a < 30 do + insert into rtest_t6 values (new.a, new.b) +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DDL +STMT: RuleStmt +== 033 +create rule rtest_t5_ins as on insert to rtest_t5 + where new.a > 15 do + insert into rtest_t7 values (new.a, new.b) +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=DDL +STMT: RuleStmt +== 034 +create rule rtest_t6_ins as on insert to rtest_t6 + where new.a > 25 do instead + insert into rtest_t8 values (new.a, new.b) +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=DDL +STMT: RuleStmt +== 035 +|-- +-- Tables and rules for the rule fire order test +|-- +-- As of PG 7.3, the rules should fire in order by name, regardless +-- of INSTEAD attributes or creation order. +|-- +create table rtest_order1 (a int4) +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: CreateStmt +== 036 +create table rtest_order2 (a int4, b int4, c text) +-- +TABLE: name="rtest_order2" schema="" table="rtest_order2" ctx=DDL +STMT: CreateStmt +== 037 +create sequence rtest_seq +-- +STMT: CreateSeqStmt +== 038 +create rule rtest_order_r3 as on insert to rtest_order1 do instead + insert into rtest_order2 values (new.a, nextval('rtest_seq'), + 'rule 3 - this should run 3rd') +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: RuleStmt +== 039 +create rule rtest_order_r4 as on insert to rtest_order1 + where a < 100 do instead + insert into rtest_order2 values (new.a, nextval('rtest_seq'), + 'rule 4 - this should run 4th') +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: RuleStmt +== 040 +create rule rtest_order_r2 as on insert to rtest_order1 do + insert into rtest_order2 values (new.a, nextval('rtest_seq'), + 'rule 2 - this should run 2nd') +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: RuleStmt +== 041 +create rule rtest_order_r1 as on insert to rtest_order1 do instead + insert into rtest_order2 values (new.a, nextval('rtest_seq'), + 'rule 1 - this should run 1st') +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: RuleStmt +== 042 +|-- +-- Tables and rules for the instead nothing test +|-- +create table rtest_nothn1 (a int4, b text) +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DDL +STMT: CreateStmt +== 043 +create table rtest_nothn2 (a int4, b text) +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DDL +STMT: CreateStmt +== 044 +create table rtest_nothn3 (a int4, b text) +-- +TABLE: name="rtest_nothn3" schema="" table="rtest_nothn3" ctx=DDL +STMT: CreateStmt +== 045 +create table rtest_nothn4 (a int4, b text) +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DDL +STMT: CreateStmt +== 046 +create rule rtest_nothn_r1 as on insert to rtest_nothn1 + where new.a >= 10 and new.a < 20 do instead nothing +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DDL +STMT: RuleStmt +== 047 +create rule rtest_nothn_r2 as on insert to rtest_nothn1 + where new.a >= 30 and new.a < 40 do instead nothing +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DDL +STMT: RuleStmt +== 048 +create rule rtest_nothn_r3 as on insert to rtest_nothn2 + where new.a >= 100 do instead + insert into rtest_nothn3 values (new.a, new.b) +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DDL +STMT: RuleStmt +== 049 +create rule rtest_nothn_r4 as on insert to rtest_nothn2 + do instead nothing +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DDL +STMT: RuleStmt +== 050 +|-- +-- Tests on a view that is select * of a table +-- and has insert/update/delete instead rules to +-- behave close like the real table. +|-- + +|-- +-- We need test date later +|-- +insert into rtest_t2 values (1, 21) +-- +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +insert into rtest_t2 values (2, 22) +-- +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +insert into rtest_t2 values (3, 23) +-- +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +insert into rtest_t3 values (1, 31) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +insert into rtest_t3 values (2, 32) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +insert into rtest_t3 values (3, 33) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +insert into rtest_t3 values (4, 34) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +insert into rtest_t3 values (5, 35) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +-- insert values +insert into rtest_v1 values (1, 11) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +insert into rtest_v1 values (2, 12) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 061 +-- delete with constant expression +delete from rtest_v1 where a = 1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +== 062 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 063 +insert into rtest_v1 values (1, 11) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +delete from rtest_v1 where b = 12 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +== 065 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 066 +insert into rtest_v1 values (2, 12) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +insert into rtest_v1 values (2, 13) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 068 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 069 +** Remember the delete rule on rtest_v1: It says +** DO INSTEAD DELETE FROM rtest_t1 WHERE a = old.a +** So this time both rows with a = 2 must get deleted +delete from rtest_v1 where b = 12 +-- +ERROR: syntax error at or near "**" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 070 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 071 +delete from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +== 072 +-- insert select +insert into rtest_v1 select * from rtest_t2 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 073 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 074 +delete from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +== 075 +-- same with swapped targetlist +insert into rtest_v1 (b, a) select b, a from rtest_t2 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 076 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 077 +-- now with only one target attribute +insert into rtest_v1 (a) select a from rtest_t3 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 078 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 079 +select * from rtest_v1 where b isnull +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 080 +-- let attribute a differ (must be done on rtest_t1 - see above) +update rtest_t1 set a = a + 10 where b isnull +-- +TABLE: name="rtest_t1" schema="" table="rtest_t1" ctx=DML +STMT: UpdateStmt +== 081 +delete from rtest_v1 where b isnull +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +== 082 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 083 +-- now updates with constant expression +update rtest_v1 set b = 42 where a = 2 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: UpdateStmt +== 084 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 085 +update rtest_v1 set b = 99 where b = 42 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: UpdateStmt +== 086 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 087 +update rtest_v1 set b = 88 where b < 50 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: UpdateStmt +== 088 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 089 +delete from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +== 090 +insert into rtest_v1 select rtest_t2.a, rtest_t3.b + from rtest_t2, rtest_t3 + where rtest_t2.a = rtest_t3.a +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=Select +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=Select +FILTER: schema="" table="rtest_t2" column="a" +FILTER: schema="" table="rtest_t3" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 091 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 092 +-- updates in a mergejoin +update rtest_v1 set b = rtest_t2.b from rtest_t2 where rtest_v1.a = rtest_t2.a +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=Select +STMT: UpdateStmt +== 093 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 094 +insert into rtest_v1 select * from rtest_t3 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 095 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 096 +update rtest_t1 set a = a + 10 where b > 30 +-- +TABLE: name="rtest_t1" schema="" table="rtest_t1" ctx=DML +STMT: UpdateStmt +== 097 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 098 +update rtest_v1 set a = rtest_t3.a + 20 from rtest_t3 where rtest_v1.b = rtest_t3.b +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=Select +STMT: UpdateStmt +== 099 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +== 100 +|-- +-- Test for constraint updates/deletes +|-- +insert into rtest_system values ('orion', 'Linux Jan Wieck') +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +insert into rtest_system values ('notjw', 'WinNT Jan Wieck (notebook)') +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 102 +insert into rtest_system values ('neptun', 'Fileserver') +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +insert into rtest_interface values ('orion', 'eth0') +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +insert into rtest_interface values ('orion', 'eth1') +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +insert into rtest_interface values ('notjw', 'eth0') +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 106 +insert into rtest_interface values ('neptun', 'eth0') +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +insert into rtest_person values ('jw', 'Jan Wieck') +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +insert into rtest_person values ('bm', 'Bruce Momjian') +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +insert into rtest_admin values ('jw', 'orion') +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +insert into rtest_admin values ('jw', 'notjw') +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +insert into rtest_admin values ('bm', 'neptun') +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 112 +update rtest_system set sysname = 'pluto' where sysname = 'neptun' +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: UpdateStmt +== 113 +select * from rtest_interface +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=Select +STMT: SelectStmt +== 114 +select * from rtest_admin +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=Select +STMT: SelectStmt +== 115 +update rtest_person set pname = 'jwieck' where pdesc = 'Jan Wieck' +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DML +STMT: UpdateStmt +== 116 +-- Note: use ORDER BY here to ensure consistent output across all systems. +-- The above UPDATE affects two rows with equal keys, so they could be +-- updated in either order depending on the whim of the local qsort(). + +select * from rtest_admin order by pname, sysname +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=Select +STMT: SelectStmt +== 117 +delete from rtest_system where sysname = 'orion' +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: DeleteStmt +== 118 +select * from rtest_interface +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=Select +STMT: SelectStmt +== 119 +select * from rtest_admin +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=Select +STMT: SelectStmt +== 120 +|-- +-- Rule qualification test +|-- +insert into rtest_emp values ('wiecc', '5000.00') +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +insert into rtest_emp values ('gates', '80000.00') +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +update rtest_emp set ename = 'wiecx' where ename = 'wiecc' +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: UpdateStmt +== 123 +update rtest_emp set ename = 'wieck', salary = '6000.00' where ename = 'wiecx' +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: UpdateStmt +== 124 +update rtest_emp set salary = '7000.00' where ename = 'wieck' +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: UpdateStmt +== 125 +delete from rtest_emp where ename = 'gates' +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: DeleteStmt +== 126 +select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=Select +STMT: SelectStmt +== 127 +insert into rtest_empmass values ('meyer', '4000.00') +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 128 +insert into rtest_empmass values ('maier', '5000.00') +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +insert into rtest_empmass values ('mayr', '6000.00') +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 130 +insert into rtest_emp select * from rtest_empmass +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 131 +select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=Select +STMT: SelectStmt +== 132 +update rtest_empmass set salary = salary + '1000.00' +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DML +STMT: UpdateStmt +== 133 +update rtest_emp set salary = rtest_empmass.salary from rtest_empmass where rtest_emp.ename = rtest_empmass.ename +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=Select +STMT: UpdateStmt +== 134 +select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=Select +STMT: SelectStmt +== 135 +delete from rtest_emp using rtest_empmass where rtest_emp.ename = rtest_empmass.ename +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=Select +STMT: DeleteStmt +== 136 +select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=Select +STMT: SelectStmt +== 137 +|-- +-- Multiple cascaded qualified instead rule test +|-- +insert into rtest_t4 values (1, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 138 +insert into rtest_t4 values (2, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +insert into rtest_t4 values (10, 'Record should go to rtest_t5') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 140 +insert into rtest_t4 values (15, 'Record should go to rtest_t5') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 141 +insert into rtest_t4 values (19, 'Record should go to rtest_t5 and t7') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +insert into rtest_t4 values (20, 'Record should go to rtest_t4 and t6') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +insert into rtest_t4 values (26, 'Record should go to rtest_t4 and t8') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +insert into rtest_t4 values (28, 'Record should go to rtest_t4 and t8') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 145 +insert into rtest_t4 values (30, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +insert into rtest_t4 values (40, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +select * from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=Select +STMT: SelectStmt +== 148 +select * from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=Select +STMT: SelectStmt +== 149 +select * from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=Select +STMT: SelectStmt +== 150 +select * from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=Select +STMT: SelectStmt +== 151 +select * from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=Select +STMT: SelectStmt +== 152 +delete from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: DeleteStmt +== 153 +delete from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=DML +STMT: DeleteStmt +== 154 +delete from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=DML +STMT: DeleteStmt +== 155 +delete from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=DML +STMT: DeleteStmt +== 156 +delete from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=DML +STMT: DeleteStmt +== 157 +insert into rtest_t9 values (1, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 158 +insert into rtest_t9 values (2, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 159 +insert into rtest_t9 values (10, 'Record should go to rtest_t5') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 160 +insert into rtest_t9 values (15, 'Record should go to rtest_t5') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 161 +insert into rtest_t9 values (19, 'Record should go to rtest_t5 and t7') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 162 +insert into rtest_t9 values (20, 'Record should go to rtest_t4 and t6') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 163 +insert into rtest_t9 values (26, 'Record should go to rtest_t4 and t8') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +insert into rtest_t9 values (28, 'Record should go to rtest_t4 and t8') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 165 +insert into rtest_t9 values (30, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 166 +insert into rtest_t9 values (40, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 167 +insert into rtest_t4 select * from rtest_t9 where a < 20 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=Select +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 168 +select * from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=Select +STMT: SelectStmt +== 169 +select * from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=Select +STMT: SelectStmt +== 170 +select * from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=Select +STMT: SelectStmt +== 171 +select * from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=Select +STMT: SelectStmt +== 172 +select * from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=Select +STMT: SelectStmt +== 173 +insert into rtest_t4 select * from rtest_t9 where b ~ 'and t8' +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=Select +FILTER: schema="" table="" column="b" +STMT: InsertStmt +STMT: SelectStmt +== 174 +select * from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=Select +STMT: SelectStmt +== 175 +select * from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=Select +STMT: SelectStmt +== 176 +select * from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=Select +STMT: SelectStmt +== 177 +select * from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=Select +STMT: SelectStmt +== 178 +select * from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=Select +STMT: SelectStmt +== 179 +insert into rtest_t4 select a + 1, b from rtest_t9 where a in (20, 30, 40) +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=Select +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 180 +select * from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=Select +STMT: SelectStmt +== 181 +select * from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=Select +STMT: SelectStmt +== 182 +select * from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=Select +STMT: SelectStmt +== 183 +select * from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=Select +STMT: SelectStmt +== 184 +select * from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=Select +STMT: SelectStmt +== 185 +|-- +-- Check that the ordering of rules fired is correct +|-- +insert into rtest_order1 values (1) +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +select * from rtest_order2 +-- +TABLE: name="rtest_order2" schema="" table="rtest_order2" ctx=Select +STMT: SelectStmt +== 187 +|-- +-- Check if instead nothing w/without qualification works +|-- +insert into rtest_nothn1 values (1, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +insert into rtest_nothn1 values (2, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +insert into rtest_nothn1 values (10, 'don''t want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +insert into rtest_nothn1 values (19, 'don''t want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +insert into rtest_nothn1 values (20, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 192 +insert into rtest_nothn1 values (29, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 193 +insert into rtest_nothn1 values (30, 'don''t want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 194 +insert into rtest_nothn1 values (39, 'don''t want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 195 +insert into rtest_nothn1 values (40, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +insert into rtest_nothn1 values (50, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 197 +insert into rtest_nothn1 values (60, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 198 +select * from rtest_nothn1 +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=Select +STMT: SelectStmt +== 199 +insert into rtest_nothn2 values (10, 'too small') +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 200 +insert into rtest_nothn2 values (50, 'too small') +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 201 +insert into rtest_nothn2 values (100, 'OK') +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 202 +insert into rtest_nothn2 values (200, 'OK') +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 203 +select * from rtest_nothn2 +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=Select +STMT: SelectStmt +== 204 +select * from rtest_nothn3 +-- +TABLE: name="rtest_nothn3" schema="" table="rtest_nothn3" ctx=Select +STMT: SelectStmt +== 205 +delete from rtest_nothn1 +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: DeleteStmt +== 206 +delete from rtest_nothn2 +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: DeleteStmt +== 207 +delete from rtest_nothn3 +-- +TABLE: name="rtest_nothn3" schema="" table="rtest_nothn3" ctx=DML +STMT: DeleteStmt +== 208 +insert into rtest_nothn4 values (1, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 209 +insert into rtest_nothn4 values (2, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 210 +insert into rtest_nothn4 values (10, 'don''t want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 211 +insert into rtest_nothn4 values (19, 'don''t want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 212 +insert into rtest_nothn4 values (20, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 213 +insert into rtest_nothn4 values (29, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 214 +insert into rtest_nothn4 values (30, 'don''t want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 215 +insert into rtest_nothn4 values (39, 'don''t want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +insert into rtest_nothn4 values (40, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 217 +insert into rtest_nothn4 values (50, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 218 +insert into rtest_nothn4 values (60, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 219 +insert into rtest_nothn1 select * from rtest_nothn4 +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 220 +select * from rtest_nothn1 +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=Select +STMT: SelectStmt +== 221 +delete from rtest_nothn4 +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: DeleteStmt +== 222 +insert into rtest_nothn4 values (10, 'too small') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 223 +insert into rtest_nothn4 values (50, 'too small') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 224 +insert into rtest_nothn4 values (100, 'OK') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 225 +insert into rtest_nothn4 values (200, 'OK') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 226 +insert into rtest_nothn2 select * from rtest_nothn4 +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 227 +select * from rtest_nothn2 +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=Select +STMT: SelectStmt +== 228 +select * from rtest_nothn3 +-- +TABLE: name="rtest_nothn3" schema="" table="rtest_nothn3" ctx=Select +STMT: SelectStmt +== 229 +create table rtest_view1 (a int4, b text, v bool) +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DDL +STMT: CreateStmt +== 230 +create table rtest_view2 (a int4) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DDL +STMT: CreateStmt +== 231 +create table rtest_view3 (a int4, b text) +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DDL +STMT: CreateStmt +== 232 +create table rtest_view4 (a int4, b text, c int4) +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DDL +STMT: CreateStmt +== 233 +create view rtest_vview1 as select a, b from rtest_view1 X + where 0 < (select count(*) from rtest_view2 Y where Y.a = X.a) +-- +TABLE: name="rtest_vview1" schema="" table="rtest_vview1" ctx=DDL +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=Select +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=Select +ALIAS: "x"="rtest_view1" +ALIAS: "y"="rtest_view2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="y" column="a" +FILTER: schema="" table="x" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 234 +create view rtest_vview2 as select a, b from rtest_view1 where v +-- +TABLE: name="rtest_vview2" schema="" table="rtest_vview2" ctx=DDL +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=Select +FILTER: schema="" table="" column="v" +STMT: ViewStmt +STMT: SelectStmt +== 235 +create view rtest_vview3 as select a, b from rtest_vview2 X + where 0 < (select count(*) from rtest_view2 Y where Y.a = X.a) +-- +TABLE: name="rtest_vview3" schema="" table="rtest_vview3" ctx=DDL +TABLE: name="rtest_vview2" schema="" table="rtest_vview2" ctx=Select +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=Select +ALIAS: "x"="rtest_vview2" +ALIAS: "y"="rtest_view2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="y" column="a" +FILTER: schema="" table="x" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 236 +create view rtest_vview4 as select X.a, X.b, count(Y.a) as refcount + from rtest_view1 X, rtest_view2 Y + where X.a = Y.a + group by X.a, X.b +-- +TABLE: name="rtest_vview4" schema="" table="rtest_vview4" ctx=DDL +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=Select +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=Select +ALIAS: "x"="rtest_view1" +ALIAS: "y"="rtest_view2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 237 +create function rtest_viewfunc1(int4) returns int4 as + 'select count(*)::int4 from rtest_view2 where a = $1' + language sql +-- +FUNCTION: name="rtest_viewfunc1" function="rtest_viewfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 238 +create view rtest_vview5 as select a, b, rtest_viewfunc1(a) as refcount + from rtest_view1 +-- +TABLE: name="rtest_vview5" schema="" table="rtest_vview5" ctx=DDL +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=Select +FUNCTION: name="rtest_viewfunc1" function="rtest_viewfunc1" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 239 +insert into rtest_view1 values (1, 'item 1', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 240 +insert into rtest_view1 values (2, 'item 2', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 241 +insert into rtest_view1 values (3, 'item 3', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 242 +insert into rtest_view1 values (4, 'item 4', 'f') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 243 +insert into rtest_view1 values (5, 'item 5', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +insert into rtest_view1 values (6, 'item 6', 'f') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +insert into rtest_view1 values (7, 'item 7', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 246 +insert into rtest_view1 values (8, 'item 8', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 247 +insert into rtest_view2 values (2) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 248 +insert into rtest_view2 values (2) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 249 +insert into rtest_view2 values (4) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 250 +insert into rtest_view2 values (5) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 251 +insert into rtest_view2 values (7) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 252 +insert into rtest_view2 values (7) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +insert into rtest_view2 values (7) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 254 +insert into rtest_view2 values (7) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 255 +select * from rtest_vview1 +-- +TABLE: name="rtest_vview1" schema="" table="rtest_vview1" ctx=Select +STMT: SelectStmt +== 256 +select * from rtest_vview2 +-- +TABLE: name="rtest_vview2" schema="" table="rtest_vview2" ctx=Select +STMT: SelectStmt +== 257 +select * from rtest_vview3 +-- +TABLE: name="rtest_vview3" schema="" table="rtest_vview3" ctx=Select +STMT: SelectStmt +== 258 +select * from rtest_vview4 order by a, b +-- +TABLE: name="rtest_vview4" schema="" table="rtest_vview4" ctx=Select +STMT: SelectStmt +== 259 +select * from rtest_vview5 +-- +TABLE: name="rtest_vview5" schema="" table="rtest_vview5" ctx=Select +STMT: SelectStmt +== 260 +insert into rtest_view3 select * from rtest_vview1 where a < 7 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +TABLE: name="rtest_vview1" schema="" table="rtest_vview1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 261 +select * from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=Select +STMT: SelectStmt +== 262 +delete from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +STMT: DeleteStmt +== 263 +insert into rtest_view3 select * from rtest_vview2 where a != 5 and b !~ '2' +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +TABLE: name="rtest_vview2" schema="" table="rtest_vview2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: InsertStmt +STMT: SelectStmt +== 264 +select * from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=Select +STMT: SelectStmt +== 265 +delete from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +STMT: DeleteStmt +== 266 +insert into rtest_view3 select * from rtest_vview3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +TABLE: name="rtest_vview3" schema="" table="rtest_vview3" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 267 +select * from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=Select +STMT: SelectStmt +== 268 +delete from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +STMT: DeleteStmt +== 269 +insert into rtest_view4 select * from rtest_vview4 where 3 > refcount +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DML +TABLE: name="rtest_vview4" schema="" table="rtest_vview4" ctx=Select +FILTER: schema="" table="" column="refcount" +STMT: InsertStmt +STMT: SelectStmt +== 270 +select * from rtest_view4 order by a, b +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=Select +STMT: SelectStmt +== 271 +delete from rtest_view4 +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DML +STMT: DeleteStmt +== 272 +insert into rtest_view4 select * from rtest_vview5 where a > 2 and refcount = 0 +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DML +TABLE: name="rtest_vview5" schema="" table="rtest_vview5" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="refcount" +STMT: InsertStmt +STMT: SelectStmt +== 273 +select * from rtest_view4 +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=Select +STMT: SelectStmt +== 274 +delete from rtest_view4 +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DML +STMT: DeleteStmt +== 275 +|-- +-- Test for computations in views +|-- +create table rtest_comp ( + part text, + unit char(4), + size float +) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DDL +STMT: CreateStmt +== 276 +create table rtest_unitfact ( + unit char(4), + factor float +) +-- +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=DDL +STMT: CreateStmt +== 277 +create view rtest_vcomp as + select X.part, (X.size * Y.factor) as size_in_cm + from rtest_comp X, rtest_unitfact Y + where X.unit = Y.unit +-- +TABLE: name="rtest_vcomp" schema="" table="rtest_vcomp" ctx=DDL +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=Select +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=Select +ALIAS: "x"="rtest_comp" +ALIAS: "y"="rtest_unitfact" +FILTER: schema="" table="x" column="unit" +FILTER: schema="" table="y" column="unit" +STMT: ViewStmt +STMT: SelectStmt +== 278 +insert into rtest_unitfact values ('m', 100.0) +-- +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 279 +insert into rtest_unitfact values ('cm', 1.0) +-- +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 280 +insert into rtest_unitfact values ('inch', 2.54) +-- +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 281 +insert into rtest_comp values ('p1', 'm', 5.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 282 +insert into rtest_comp values ('p2', 'm', 3.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 283 +insert into rtest_comp values ('p3', 'cm', 5.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 284 +insert into rtest_comp values ('p4', 'cm', 15.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 285 +insert into rtest_comp values ('p5', 'inch', 7.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 286 +insert into rtest_comp values ('p6', 'inch', 4.4) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 287 +select * from rtest_vcomp order by part +-- +TABLE: name="rtest_vcomp" schema="" table="rtest_vcomp" ctx=Select +STMT: SelectStmt +== 288 +select * from rtest_vcomp where size_in_cm > 10.0 order by size_in_cm using > +-- +TABLE: name="rtest_vcomp" schema="" table="rtest_vcomp" ctx=Select +FILTER: schema="" table="" column="size_in_cm" +STMT: SelectStmt +== 289 +|-- +-- In addition run the (slightly modified) queries from the +-- programmers manual section on the rule system. +|-- +CREATE TABLE shoe_data ( + shoename char(10), -- primary key + sh_avail integer, -- available # of pairs + slcolor char(10), -- preferred shoelace color + slminlen float, -- minimum shoelace length + slmaxlen float, -- maximum shoelace length + slunit char(8) -- length unit +) +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DDL +STMT: CreateStmt +== 290 +CREATE TABLE shoelace_data ( + sl_name char(10), -- primary key + sl_avail integer, -- available # of pairs + sl_color char(10), -- shoelace color + sl_len float, -- shoelace length + sl_unit char(8) -- length unit +) +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DDL +STMT: CreateStmt +== 291 +CREATE TABLE unit ( + un_name char(8), -- the primary key + un_fact float -- factor to transform to cm +) +-- +TABLE: name="unit" schema="" table="unit" ctx=DDL +STMT: CreateStmt +== 292 +CREATE VIEW shoe AS + SELECT sh.shoename, + sh.sh_avail, + sh.slcolor, + sh.slminlen, + sh.slminlen * un.un_fact AS slminlen_cm, + sh.slmaxlen, + sh.slmaxlen * un.un_fact AS slmaxlen_cm, + sh.slunit + FROM shoe_data sh, unit un + WHERE sh.slunit = un.un_name +-- +TABLE: name="shoe" schema="" table="shoe" ctx=DDL +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=Select +TABLE: name="unit" schema="" table="unit" ctx=Select +ALIAS: "sh"="shoe_data" +ALIAS: "un"="unit" +FILTER: schema="" table="sh" column="slunit" +FILTER: schema="" table="un" column="un_name" +STMT: ViewStmt +STMT: SelectStmt +== 293 +CREATE VIEW shoelace AS + SELECT s.sl_name, + s.sl_avail, + s.sl_color, + s.sl_len, + s.sl_unit, + s.sl_len * u.un_fact AS sl_len_cm + FROM shoelace_data s, unit u + WHERE s.sl_unit = u.un_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DDL +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=Select +TABLE: name="unit" schema="" table="unit" ctx=Select +ALIAS: "s"="shoelace_data" +ALIAS: "u"="unit" +FILTER: schema="" table="s" column="sl_unit" +FILTER: schema="" table="u" column="un_name" +STMT: ViewStmt +STMT: SelectStmt +== 294 +CREATE VIEW shoe_ready AS + SELECT rsh.shoename, + rsh.sh_avail, + rsl.sl_name, + rsl.sl_avail, + int4smaller(rsh.sh_avail, rsl.sl_avail) AS total_avail + FROM shoe rsh, shoelace rsl + WHERE rsl.sl_color = rsh.slcolor + AND rsl.sl_len_cm >= rsh.slminlen_cm + AND rsl.sl_len_cm <= rsh.slmaxlen_cm +-- +TABLE: name="shoe_ready" schema="" table="shoe_ready" ctx=DDL +TABLE: name="shoe" schema="" table="shoe" ctx=Select +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +ALIAS: "rsh"="shoe" +ALIAS: "rsl"="shoelace" +FUNCTION: name="int4smaller" function="int4smaller" schema="" ctx=Call +FILTER: schema="" table="rsl" column="sl_color" +FILTER: schema="" table="rsh" column="slcolor" +FILTER: schema="" table="rsl" column="sl_len_cm" +FILTER: schema="" table="rsh" column="slminlen_cm" +FILTER: schema="" table="rsl" column="sl_len_cm" +FILTER: schema="" table="rsh" column="slmaxlen_cm" +STMT: ViewStmt +STMT: SelectStmt +== 295 +INSERT INTO unit VALUES ('cm', 1.0) +-- +TABLE: name="unit" schema="" table="unit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 296 +INSERT INTO unit VALUES ('m', 100.0) +-- +TABLE: name="unit" schema="" table="unit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 297 +INSERT INTO unit VALUES ('inch', 2.54) +-- +TABLE: name="unit" schema="" table="unit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 298 +INSERT INTO shoe_data VALUES ('sh1', 2, 'black', 70.0, 90.0, 'cm') +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 299 +INSERT INTO shoe_data VALUES ('sh2', 0, 'black', 30.0, 40.0, 'inch') +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 300 +INSERT INTO shoe_data VALUES ('sh3', 4, 'brown', 50.0, 65.0, 'cm') +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 301 +INSERT INTO shoe_data VALUES ('sh4', 3, 'brown', 40.0, 50.0, 'inch') +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 302 +INSERT INTO shoelace_data VALUES ('sl1', 5, 'black', 80.0, 'cm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 303 +INSERT INTO shoelace_data VALUES ('sl2', 6, 'black', 100.0, 'cm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 304 +INSERT INTO shoelace_data VALUES ('sl3', 0, 'black', 35.0 , 'inch') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 305 +INSERT INTO shoelace_data VALUES ('sl4', 8, 'black', 40.0 , 'inch') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 306 +INSERT INTO shoelace_data VALUES ('sl5', 4, 'brown', 1.0 , 'm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 307 +INSERT INTO shoelace_data VALUES ('sl6', 0, 'brown', 0.9 , 'm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 308 +INSERT INTO shoelace_data VALUES ('sl7', 7, 'brown', 60 , 'cm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 309 +INSERT INTO shoelace_data VALUES ('sl8', 1, 'brown', 40 , 'inch') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 310 +-- SELECTs in doc +SELECT * FROM shoelace ORDER BY sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +STMT: SelectStmt +== 311 +SELECT * FROM shoe_ready WHERE total_avail >= 2 ORDER BY 1 +-- +TABLE: name="shoe_ready" schema="" table="shoe_ready" ctx=Select +FILTER: schema="" table="" column="total_avail" +STMT: SelectStmt +== 312 +CREATE TABLE shoelace_log ( + sl_name char(10), -- shoelace changed + sl_avail integer, -- new available value + log_who name, -- who did it + log_when timestamp -- when + ) +-- +TABLE: name="shoelace_log" schema="" table="shoelace_log" ctx=DDL +STMT: CreateStmt +== 313 +-- Want "log_who" to be CURRENT_USER, +-- but that is non-portable for the regression test +-- - thomas 1999-02-21 + + CREATE RULE log_shoelace AS ON UPDATE TO shoelace_data + WHERE NEW.sl_avail != OLD.sl_avail + DO INSERT INTO shoelace_log VALUES ( + NEW.sl_name, + NEW.sl_avail, + 'Al Bundy', + 'epoch' + ) +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DDL +STMT: RuleStmt +== 314 +UPDATE shoelace_data SET sl_avail = 6 WHERE sl_name = 'sl7' +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: UpdateStmt +== 315 +SELECT * FROM shoelace_log +-- +TABLE: name="shoelace_log" schema="" table="shoelace_log" ctx=Select +STMT: SelectStmt +== 316 +CREATE RULE shoelace_ins AS ON INSERT TO shoelace + DO INSTEAD + INSERT INTO shoelace_data VALUES ( + NEW.sl_name, + NEW.sl_avail, + NEW.sl_color, + NEW.sl_len, + NEW.sl_unit) +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DDL +STMT: RuleStmt +== 317 +CREATE RULE shoelace_upd AS ON UPDATE TO shoelace + DO INSTEAD + UPDATE shoelace_data SET + sl_name = NEW.sl_name, + sl_avail = NEW.sl_avail, + sl_color = NEW.sl_color, + sl_len = NEW.sl_len, + sl_unit = NEW.sl_unit + WHERE sl_name = OLD.sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DDL +STMT: RuleStmt +== 318 +CREATE RULE shoelace_del AS ON DELETE TO shoelace + DO INSTEAD + DELETE FROM shoelace_data + WHERE sl_name = OLD.sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DDL +STMT: RuleStmt +== 319 +CREATE TABLE shoelace_arrive ( + arr_name char(10), + arr_quant integer + ) +-- +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=DDL +STMT: CreateStmt +== 320 +CREATE TABLE shoelace_ok ( + ok_name char(10), + ok_quant integer + ) +-- +TABLE: name="shoelace_ok" schema="" table="shoelace_ok" ctx=DDL +STMT: CreateStmt +== 321 +CREATE RULE shoelace_ok_ins AS ON INSERT TO shoelace_ok + DO INSTEAD + UPDATE shoelace SET + sl_avail = sl_avail + NEW.ok_quant + WHERE sl_name = NEW.ok_name +-- +TABLE: name="shoelace_ok" schema="" table="shoelace_ok" ctx=DDL +STMT: RuleStmt +== 322 +INSERT INTO shoelace_arrive VALUES ('sl3', 10) +-- +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 323 +INSERT INTO shoelace_arrive VALUES ('sl6', 20) +-- +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 324 +INSERT INTO shoelace_arrive VALUES ('sl8', 20) +-- +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 325 +SELECT * FROM shoelace ORDER BY sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +STMT: SelectStmt +== 326 +insert into shoelace_ok select * from shoelace_arrive +-- +TABLE: name="shoelace_ok" schema="" table="shoelace_ok" ctx=DML +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 327 +SELECT * FROM shoelace ORDER BY sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +STMT: SelectStmt +== 328 +SELECT * FROM shoelace_log ORDER BY sl_name +-- +TABLE: name="shoelace_log" schema="" table="shoelace_log" ctx=Select +STMT: SelectStmt +== 329 +CREATE VIEW shoelace_obsolete AS + SELECT * FROM shoelace WHERE NOT EXISTS + (SELECT shoename FROM shoe WHERE slcolor = sl_color) +-- +TABLE: name="shoelace_obsolete" schema="" table="shoelace_obsolete" ctx=DDL +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +TABLE: name="shoe" schema="" table="shoe" ctx=Select +FILTER: schema="" table="" column="slcolor" +FILTER: schema="" table="" column="sl_color" +STMT: ViewStmt +STMT: SelectStmt +== 330 +CREATE VIEW shoelace_candelete AS + SELECT * FROM shoelace_obsolete WHERE sl_avail = 0 +-- +TABLE: name="shoelace_candelete" schema="" table="shoelace_candelete" ctx=DDL +TABLE: name="shoelace_obsolete" schema="" table="shoelace_obsolete" ctx=Select +FILTER: schema="" table="" column="sl_avail" +STMT: ViewStmt +STMT: SelectStmt +== 331 +insert into shoelace values ('sl9', 0, 'pink', 35.0, 'inch', 0.0) +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 332 +insert into shoelace values ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0) +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 333 +-- Unsupported (even though a similar updatable view construct is) +insert into shoelace values ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0) + on conflict do nothing +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 334 +SELECT * FROM shoelace_obsolete ORDER BY sl_len_cm +-- +TABLE: name="shoelace_obsolete" schema="" table="shoelace_obsolete" ctx=Select +STMT: SelectStmt +== 335 +SELECT * FROM shoelace_candelete +-- +TABLE: name="shoelace_candelete" schema="" table="shoelace_candelete" ctx=Select +STMT: SelectStmt +== 336 +DELETE FROM shoelace WHERE EXISTS + (SELECT * FROM shoelace_candelete + WHERE sl_name = shoelace.sl_name) +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +TABLE: name="shoelace_candelete" schema="" table="shoelace_candelete" ctx=Select +FILTER: schema="" table="" column="sl_name" +FILTER: schema="" table="shoelace" column="sl_name" +STMT: DeleteStmt +STMT: SelectStmt +== 337 +SELECT * FROM shoelace ORDER BY sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +STMT: SelectStmt +== 338 +SELECT * FROM shoe ORDER BY shoename +-- +TABLE: name="shoe" schema="" table="shoe" ctx=Select +STMT: SelectStmt +== 339 +SELECT count(*) FROM shoe +-- +TABLE: name="shoe" schema="" table="shoe" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 340 +|-- +-- Simple test of qualified ON INSERT ... this did not work in 7.0 ... +|-- +create table rules_foo (f1 int) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: CreateStmt +== 341 +create table rules_foo2 (f1 int) +-- +TABLE: name="rules_foo2" schema="" table="rules_foo2" ctx=DDL +STMT: CreateStmt +== 342 +create rule rules_foorule as on insert to rules_foo where f1 < 100 +do instead nothing +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: RuleStmt +== 343 +insert into rules_foo values(1) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 344 +insert into rules_foo values(1001) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 345 +select * from rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=Select +STMT: SelectStmt +== 346 +drop rule rules_foorule on rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: DropStmt +== 347 +-- this should fail because f1 is not exposed for unqualified reference: +create rule rules_foorule as on insert to rules_foo where f1 < 100 +do instead insert into rules_foo2 values (f1) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: RuleStmt +== 348 +-- this is the correct way: +create rule rules_foorule as on insert to rules_foo where f1 < 100 +do instead insert into rules_foo2 values (new.f1) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: RuleStmt +== 349 +insert into rules_foo values(2) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 350 +insert into rules_foo values(100) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 351 +select * from rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=Select +STMT: SelectStmt +== 352 +select * from rules_foo2 +-- +TABLE: name="rules_foo2" schema="" table="rules_foo2" ctx=Select +STMT: SelectStmt +== 353 +drop rule rules_foorule on rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: DropStmt +== 354 +drop table rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: DropStmt +== 355 +drop table rules_foo2 +-- +TABLE: name="rules_foo2" schema="" table="rules_foo2" ctx=DDL +STMT: DropStmt +== 356 +|-- +-- Test rules containing INSERT ... SELECT, which is a very ugly special +-- case as of 7.1. Example is based on bug report from Joel Burton. +|-- +create table pparent (pid int, txt text) +-- +TABLE: name="pparent" schema="" table="pparent" ctx=DDL +STMT: CreateStmt +== 357 +insert into pparent values (1,'parent1') +-- +TABLE: name="pparent" schema="" table="pparent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 358 +insert into pparent values (2,'parent2') +-- +TABLE: name="pparent" schema="" table="pparent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 359 +create table cchild (pid int, descrip text) +-- +TABLE: name="cchild" schema="" table="cchild" ctx=DDL +STMT: CreateStmt +== 360 +insert into cchild values (1,'descrip1') +-- +TABLE: name="cchild" schema="" table="cchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 361 +create view vview as + select pparent.pid, txt, descrip from + pparent left join cchild using (pid) +-- +TABLE: name="vview" schema="" table="vview" ctx=DDL +TABLE: name="pparent" schema="" table="pparent" ctx=Select +TABLE: name="cchild" schema="" table="cchild" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 362 +create rule rrule as + on update to vview do instead +( + insert into cchild (pid, descrip) + select old.pid, new.descrip where old.descrip isnull; + update cchild set descrip = new.descrip where cchild.pid = old.pid; +) +-- +TABLE: name="vview" schema="" table="vview" ctx=DDL +STMT: RuleStmt +== 363 +select * from vview +-- +TABLE: name="vview" schema="" table="vview" ctx=Select +STMT: SelectStmt +== 364 +update vview set descrip='test1' where pid=1 +-- +TABLE: name="vview" schema="" table="vview" ctx=DML +STMT: UpdateStmt +== 365 +select * from vview +-- +TABLE: name="vview" schema="" table="vview" ctx=Select +STMT: SelectStmt +== 366 +update vview set descrip='test2' where pid=2 +-- +TABLE: name="vview" schema="" table="vview" ctx=DML +STMT: UpdateStmt +== 367 +select * from vview +-- +TABLE: name="vview" schema="" table="vview" ctx=Select +STMT: SelectStmt +== 368 +update vview set descrip='test3' where pid=3 +-- +TABLE: name="vview" schema="" table="vview" ctx=DML +STMT: UpdateStmt +== 369 +select * from vview +-- +TABLE: name="vview" schema="" table="vview" ctx=Select +STMT: SelectStmt +== 370 +select * from cchild +-- +TABLE: name="cchild" schema="" table="cchild" ctx=Select +STMT: SelectStmt +== 371 +drop rule rrule on vview +-- +TABLE: name="vview" schema="" table="vview" ctx=DDL +STMT: DropStmt +== 372 +drop view vview +-- +STMT: DropStmt +== 373 +drop table pparent +-- +TABLE: name="pparent" schema="" table="pparent" ctx=DDL +STMT: DropStmt +== 374 +drop table cchild +-- +TABLE: name="cchild" schema="" table="cchild" ctx=DDL +STMT: DropStmt +== 375 +|-- +-- Check that ruleutils are working +|-- + +-- temporarily disable fancy output, so view changes create less diff noise + +SELECT viewname, definition FROM pg_views +WHERE schemaname = 'pg_catalog' +ORDER BY viewname +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +== 376 +SELECT tablename, rulename, definition FROM pg_rules +WHERE schemaname = 'pg_catalog' +ORDER BY tablename, rulename +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +== 377 +-- restore normal output mode + +|-- +-- CREATE OR REPLACE RULE +|-- + +CREATE TABLE ruletest_tbl (a int, b int) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DDL +STMT: CreateStmt +== 378 +CREATE TABLE ruletest_tbl2 (a int, b int) +-- +TABLE: name="ruletest_tbl2" schema="" table="ruletest_tbl2" ctx=DDL +STMT: CreateStmt +== 379 +CREATE OR REPLACE RULE myrule AS ON INSERT TO ruletest_tbl + DO INSTEAD INSERT INTO ruletest_tbl2 VALUES (10, 10) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DDL +STMT: RuleStmt +== 380 +INSERT INTO ruletest_tbl VALUES (99, 99) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 381 +CREATE OR REPLACE RULE myrule AS ON INSERT TO ruletest_tbl + DO INSTEAD INSERT INTO ruletest_tbl2 VALUES (1000, 1000) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DDL +STMT: RuleStmt +== 382 +INSERT INTO ruletest_tbl VALUES (99, 99) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 383 +SELECT * FROM ruletest_tbl2 +-- +TABLE: name="ruletest_tbl2" schema="" table="ruletest_tbl2" ctx=Select +STMT: SelectStmt +== 384 +-- Check that rewrite rules splitting one INSERT into multiple +-- conditional statements does not disable FK checking. +create table rule_and_refint_t1 ( + id1a integer, + id1b integer, + + primary key (id1a, id1b) +) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DDL +STMT: CreateStmt +== 385 +create table rule_and_refint_t2 ( + id2a integer, + id2c integer, + + primary key (id2a, id2c) +) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DDL +STMT: CreateStmt +== 386 +create table rule_and_refint_t3 ( + id3a integer, + id3b integer, + id3c integer, + data text, + + primary key (id3a, id3b, id3c), + + foreign key (id3a, id3b) references rule_and_refint_t1 (id1a, id1b), + foreign key (id3a, id3c) references rule_and_refint_t2 (id2a, id2c) +) +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DDL +STMT: CreateStmt +== 387 +insert into rule_and_refint_t1 values (1, 11) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 388 +insert into rule_and_refint_t1 values (1, 12) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 389 +insert into rule_and_refint_t1 values (2, 21) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 390 +insert into rule_and_refint_t1 values (2, 22) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 391 +insert into rule_and_refint_t2 values (1, 11) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 392 +insert into rule_and_refint_t2 values (1, 12) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 393 +insert into rule_and_refint_t2 values (2, 21) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 394 +insert into rule_and_refint_t2 values (2, 22) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 395 +insert into rule_and_refint_t3 values (1, 11, 11, 'row1') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 396 +insert into rule_and_refint_t3 values (1, 11, 12, 'row2') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 397 +insert into rule_and_refint_t3 values (1, 12, 11, 'row3') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 398 +insert into rule_and_refint_t3 values (1, 12, 12, 'row4') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 399 +insert into rule_and_refint_t3 values (1, 11, 13, 'row5') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 400 +insert into rule_and_refint_t3 values (1, 13, 11, 'row6') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 401 +-- Ordinary table +insert into rule_and_refint_t3 values (1, 13, 11, 'row6') + on conflict do nothing +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 402 +-- rule not fired, so fk violation +insert into rule_and_refint_t3 values (1, 13, 11, 'row6') + on conflict (id3a, id3b, id3c) do update + set id3b = excluded.id3b +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 403 +-- rule fired, so unsupported +insert into shoelace values ('sl9', 0, 'pink', 35.0, 'inch', 0.0) + on conflict (sl_name) do update + set sl_avail = excluded.sl_avail +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 404 +create rule rule_and_refint_t3_ins as on insert to rule_and_refint_t3 + where (exists (select 1 from rule_and_refint_t3 + where (((rule_and_refint_t3.id3a = new.id3a) + and (rule_and_refint_t3.id3b = new.id3b)) + and (rule_and_refint_t3.id3c = new.id3c)))) + do instead update rule_and_refint_t3 set data = new.data + where (((rule_and_refint_t3.id3a = new.id3a) + and (rule_and_refint_t3.id3b = new.id3b)) + and (rule_and_refint_t3.id3c = new.id3c)) +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DDL +STMT: RuleStmt +== 405 +insert into rule_and_refint_t3 values (1, 11, 13, 'row7') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 406 +insert into rule_and_refint_t3 values (1, 13, 11, 'row8') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 407 +|-- +-- disallow dropping a view's rule (bug #5072) +|-- + +create view rules_fooview as select 'rules_foo'::text +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 408 +drop rule "_RETURN" on rules_fooview +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: DropStmt +== 409 +drop view rules_fooview +-- +STMT: DropStmt +== 410 +|-- +-- We used to allow converting a table to a view by creating a "_RETURN" +-- rule for it, but no more. +|-- + +create table rules_fooview (x int, y text) +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: CreateStmt +== 411 +create rule "_RETURN" as on select to rules_fooview do instead + select 1 as x, 'aaa'::text as y +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: RuleStmt +== 412 +drop table rules_fooview +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: DropStmt +== 413 +-- likewise, converting a partitioned table or partition to view is not allowed +create table rules_fooview (x int, y text) partition by list (x) +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: CreateStmt +== 414 +create rule "_RETURN" as on select to rules_fooview do instead + select 1 as x, 'aaa'::text as y +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: RuleStmt +== 415 +create table rules_fooview_part partition of rules_fooview for values in (1) +-- +TABLE: name="rules_fooview_part" schema="" table="rules_fooview_part" ctx=DDL +STMT: CreateStmt +== 416 +create rule "_RETURN" as on select to rules_fooview_part do instead + select 1 as x, 'aaa'::text as y +-- +TABLE: name="rules_fooview_part" schema="" table="rules_fooview_part" ctx=DDL +STMT: RuleStmt +== 417 +drop table rules_fooview +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: DropStmt +== 418 +|-- +-- check for planner problems with complex inherited UPDATES +|-- + +create table id (id serial primary key, name text) +-- +TABLE: name="id" schema="" table="id" ctx=DDL +STMT: CreateStmt +== 419 +-- currently, must respecify PKEY for each inherited subtable +create table test_1 (id integer primary key) inherits (id) +-- +TABLE: name="test_1" schema="" table="test_1" ctx=DDL +STMT: CreateStmt +== 420 +create table test_2 (id integer primary key) inherits (id) +-- +TABLE: name="test_2" schema="" table="test_2" ctx=DDL +STMT: CreateStmt +== 421 +create table test_3 (id integer primary key) inherits (id) +-- +TABLE: name="test_3" schema="" table="test_3" ctx=DDL +STMT: CreateStmt +== 422 +insert into test_1 (name) values ('Test 1') +-- +TABLE: name="test_1" schema="" table="test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 423 +insert into test_1 (name) values ('Test 2') +-- +TABLE: name="test_1" schema="" table="test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 424 +insert into test_2 (name) values ('Test 3') +-- +TABLE: name="test_2" schema="" table="test_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 425 +insert into test_2 (name) values ('Test 4') +-- +TABLE: name="test_2" schema="" table="test_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 426 +insert into test_3 (name) values ('Test 5') +-- +TABLE: name="test_3" schema="" table="test_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 427 +insert into test_3 (name) values ('Test 6') +-- +TABLE: name="test_3" schema="" table="test_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 428 +create view id_ordered as select * from id order by id +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DDL +TABLE: name="id" schema="" table="id" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 429 +create rule update_id_ordered as on update to id_ordered + do instead update id set name = new.name where id = old.id +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DDL +STMT: RuleStmt +== 430 +select * from id_ordered +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=Select +STMT: SelectStmt +== 431 +update id_ordered set name = 'update 2' where id = 2 +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DML +STMT: UpdateStmt +== 432 +update id_ordered set name = 'update 4' where id = 4 +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DML +STMT: UpdateStmt +== 433 +update id_ordered set name = 'update 5' where id = 5 +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DML +STMT: UpdateStmt +== 434 +select * from id_ordered +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=Select +STMT: SelectStmt +== 435 +drop table id cascade +-- +TABLE: name="id" schema="" table="id" ctx=DDL +STMT: DropStmt +== 436 +|-- +-- check corner case where an entirely-dummy subplan is created by +-- constraint exclusion +|-- + +create temp table t1 (a integer primary key) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 437 +create temp table t1_1 (check (a >= 0 and a < 10)) inherits (t1) +-- +TABLE: name="t1_1" schema="" table="t1_1" ctx=DDL +STMT: CreateStmt +== 438 +create temp table t1_2 (check (a >= 10 and a < 20)) inherits (t1) +-- +TABLE: name="t1_2" schema="" table="t1_2" ctx=DDL +STMT: CreateStmt +== 439 +create rule t1_ins_1 as on insert to t1 + where new.a >= 0 and new.a < 10 + do instead + insert into t1_1 values (new.a) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +== 440 +create rule t1_ins_2 as on insert to t1 + where new.a >= 10 and new.a < 20 + do instead + insert into t1_2 values (new.a) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +== 441 +create rule t1_upd_1 as on update to t1 + where old.a >= 0 and old.a < 10 + do instead + update t1_1 set a = new.a where a = old.a +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +== 442 +create rule t1_upd_2 as on update to t1 + where old.a >= 10 and old.a < 20 + do instead + update t1_2 set a = new.a where a = old.a +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +== 443 +set constraint_exclusion = on +-- +STMT: VariableSetStmt +== 444 +insert into t1 select * from generate_series(5,19,1) g +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 445 +update t1 set a = 4 where a = 5 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: UpdateStmt +== 446 +select * from only t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 447 +select * from only t1_1 +-- +TABLE: name="t1_1" schema="" table="t1_1" ctx=Select +STMT: SelectStmt +== 448 +select * from only t1_2 +-- +TABLE: name="t1_2" schema="" table="t1_2" ctx=Select +STMT: SelectStmt +== 449 +reset constraint_exclusion +-- +STMT: VariableSetStmt +== 450 +-- test FOR UPDATE in rules + +create table rules_base(f1 int, f2 int) +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: CreateStmt +== 451 +insert into rules_base values(1,2), (11,12) +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 452 +create rule r1 as on update to rules_base do instead + select * from rules_base where f1 = 1 for update +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: RuleStmt +== 453 +update rules_base set f2 = f2 + 1 +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DML +STMT: UpdateStmt +== 454 +create or replace rule r1 as on update to rules_base do instead + select * from rules_base where f1 = 11 for update of rules_base +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: RuleStmt +== 455 +update rules_base set f2 = f2 + 1 +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DML +STMT: UpdateStmt +== 456 +create or replace rule r1 as on update to rules_base do instead + select * from rules_base where f1 = 11 for update of old +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: RuleStmt +== 457 +-- error +drop table rules_base +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: DropStmt +== 458 +-- test various flavors of pg_get_viewdef() + +select pg_get_viewdef('shoe'::regclass) as unpretty +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 459 +select pg_get_viewdef('shoe'::regclass,true) as pretty +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 460 +select pg_get_viewdef('shoe'::regclass,0) as prettier +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 461 +|-- +-- check multi-row VALUES in rules +|-- + +create table rules_src(f1 int, f2 int default 0) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: CreateStmt +== 462 +create table rules_log(f1 int, f2 int, tag text, id serial) +-- +TABLE: name="rules_log" schema="" table="rules_log" ctx=DDL +STMT: CreateStmt +== 463 +insert into rules_src values(1,2), (11,12) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 464 +create rule r1 as on update to rules_src do also + insert into rules_log values(old.*, 'old', default), (new.*, 'new', default) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +== 465 +update rules_src set f2 = f2 + 1 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: UpdateStmt +== 466 +update rules_src set f2 = f2 * 10 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: UpdateStmt +== 467 +select * from rules_src +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=Select +STMT: SelectStmt +== 468 +select * from rules_log +-- +TABLE: name="rules_log" schema="" table="rules_log" ctx=Select +STMT: SelectStmt +== 469 +create rule r2 as on update to rules_src do also + values(old.*, 'old'), (new.*, 'new') +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +== 470 +update rules_src set f2 = f2 / 10 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: UpdateStmt +== 471 +create rule r3 as on insert to rules_src do also + insert into rules_log values(null, null, '-', default), (new.*, 'new', default) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +== 472 +insert into rules_src values(22,23), (33,default) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 473 +select * from rules_src +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=Select +STMT: SelectStmt +== 474 +select * from rules_log +-- +TABLE: name="rules_log" schema="" table="rules_log" ctx=Select +STMT: SelectStmt +== 475 +create rule r4 as on delete to rules_src do notify rules_src_deletion +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +== 476 +|-- +-- Ensure an aliased target relation for insert is correctly deparsed. +|-- +create rule r5 as on insert to rules_src do instead insert into rules_log AS trgt SELECT NEW.* RETURNING trgt.f1, trgt.f2 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +== 477 +create rule r6 as on update to rules_src do instead UPDATE rules_log AS trgt SET tag = 'updated' WHERE trgt.f1 = new.f1 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +== 478 +|-- +-- Check deparse disambiguation of INSERT/UPDATE/DELETE targets. +|-- +create rule r7 as on delete to rules_src do instead + with wins as (insert into int4_tbl as trgt values (0) returning *), + wupd as (update int4_tbl trgt set f1 = f1+1 returning *), + wdel as (delete from int4_tbl trgt where f1 = 0 returning *) + insert into rules_log AS trgt select old.* from wins, wupd, wdel + returning trgt.f1, trgt.f2 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +== 479 +-- check display of all rules added above + +|-- +-- Also check multiassignment deparsing. +|-- +create table rule_t1(f1 int, f2 int) +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: CreateStmt +== 480 +create table rule_dest(f1 int, f2 int[], tag text) +-- +TABLE: name="rule_dest" schema="" table="rule_dest" ctx=DDL +STMT: CreateStmt +== 481 +create rule rr as on update to rule_t1 do instead UPDATE rule_dest trgt + SET (f2[1], f1, tag) = (SELECT new.f2, new.f1, 'updated'::varchar) + WHERE trgt.f1 = new.f1 RETURNING new.* +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: RuleStmt +== 482 +drop table rule_t1, rule_dest +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +TABLE: name="rule_dest" schema="" table="rule_dest" ctx=DDL +STMT: DropStmt +== 483 +|-- +-- Test implicit LATERAL references to old/new in rules +|-- +CREATE TABLE rule_t1(a int, b text DEFAULT 'xxx', c int) +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: CreateStmt +== 484 +CREATE VIEW rule_v1 AS SELECT * FROM rule_t1 +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 485 +CREATE RULE v1_ins AS ON INSERT TO rule_v1 + DO ALSO INSERT INTO rule_t1 + SELECT * FROM (SELECT a + 10 FROM rule_t1 WHERE a = NEW.a) tt +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: RuleStmt +== 486 +CREATE RULE v1_upd AS ON UPDATE TO rule_v1 + DO ALSO UPDATE rule_t1 t + SET c = tt.a * 10 + FROM (SELECT a FROM rule_t1 WHERE a = OLD.a) tt WHERE t.a = tt.a +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: RuleStmt +== 487 +INSERT INTO rule_v1 VALUES (1, 'a'), (2, 'b') +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 488 +UPDATE rule_v1 SET b = upper(b) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: UpdateStmt +== 489 +SELECT * FROM rule_t1 +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=Select +STMT: SelectStmt +== 490 +DROP TABLE rule_t1 CASCADE +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: DropStmt +== 491 +|-- +-- check alter rename rule +|-- +CREATE TABLE rule_t1 (a INT) +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: CreateStmt +== 492 +CREATE VIEW rule_v1 AS SELECT * FROM rule_t1 +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 493 +CREATE RULE InsertRule AS + ON INSERT TO rule_v1 + DO INSTEAD + INSERT INTO rule_t1 VALUES(new.a) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: RuleStmt +== 494 +ALTER RULE InsertRule ON rule_v1 RENAME to NewInsertRule +-- +STMT: RenameStmt +== 495 +INSERT INTO rule_v1 VALUES(1) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 496 +SELECT * FROM rule_v1 +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=Select +STMT: SelectStmt +== 497 +|-- +-- error conditions for alter rename rule +|-- +ALTER RULE InsertRule ON rule_v1 RENAME TO NewInsertRule +-- +STMT: RenameStmt +== 498 +-- doesn't exist +ALTER RULE NewInsertRule ON rule_v1 RENAME TO "_RETURN" +-- +STMT: RenameStmt +== 499 +-- already exists +ALTER RULE "_RETURN" ON rule_v1 RENAME TO abc +-- +STMT: RenameStmt +== 500 +-- ON SELECT rule cannot be renamed + +DROP VIEW rule_v1 +-- +STMT: DropStmt +== 501 +DROP TABLE rule_t1 +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: DropStmt +== 502 +|-- +-- check display of VALUES in view definitions +|-- +create view rule_v1 as values(1,2) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 503 +alter table rule_v1 rename column column2 to q2 +-- +STMT: RenameStmt +== 504 +drop view rule_v1 +-- +STMT: DropStmt +== 505 +create view rule_v1(x) as values(1,2) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 506 +drop view rule_v1 +-- +STMT: DropStmt +== 507 +create view rule_v1(x) as select * from (values(1,2)) v +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 508 +drop view rule_v1 +-- +STMT: DropStmt +== 509 +create view rule_v1(x) as select * from (values(1,2)) v(q,w) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 510 +drop view rule_v1 +-- +STMT: DropStmt +== 511 +|-- +-- Check DO INSTEAD rules with ON CONFLICT +|-- +CREATE TABLE hats ( + hat_name char(10) primary key, + hat_color char(10) -- hat color +) +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: CreateStmt +== 512 +CREATE TABLE hat_data ( + hat_name char(10), + hat_color char(10) -- hat color +) +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=DDL +STMT: CreateStmt +== 513 +create unique index hat_data_unique_idx + on hat_data (hat_name COLLATE "C" bpchar_pattern_ops) +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=DDL +STMT: IndexStmt +== 514 +-- DO NOTHING with ON CONFLICT +CREATE RULE hat_nosert AS ON INSERT TO hats + DO INSTEAD + INSERT INTO hat_data VALUES ( + NEW.hat_name, + NEW.hat_color) + ON CONFLICT (hat_name COLLATE "C" bpchar_pattern_ops) WHERE hat_color = 'green' + DO NOTHING + RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: RuleStmt +== 515 +SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 516 +-- Works (projects row) +INSERT INTO hats VALUES ('h7', 'black') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 517 +-- Works (does nothing) +INSERT INTO hats VALUES ('h7', 'black') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 518 +SELECT tablename, rulename, definition FROM pg_rules + WHERE tablename = 'hats' +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 519 +DROP RULE hat_nosert ON hats +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: DropStmt +== 520 +-- DO NOTHING without ON CONFLICT +CREATE RULE hat_nosert_all AS ON INSERT TO hats + DO INSTEAD + INSERT INTO hat_data VALUES ( + NEW.hat_name, + NEW.hat_color) + ON CONFLICT + DO NOTHING + RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: RuleStmt +== 521 +SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 522 +DROP RULE hat_nosert_all ON hats +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: DropStmt +== 523 +-- Works (does nothing) +INSERT INTO hats VALUES ('h7', 'black') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 524 +-- DO UPDATE with a WHERE clause +CREATE RULE hat_upsert AS ON INSERT TO hats + DO INSTEAD + INSERT INTO hat_data VALUES ( + NEW.hat_name, + NEW.hat_color) + ON CONFLICT (hat_name) + DO UPDATE + SET hat_name = hat_data.hat_name, hat_color = excluded.hat_color + WHERE excluded.hat_color <> 'forbidden' AND hat_data.* != excluded.* + RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: RuleStmt +== 525 +SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 526 +-- Works (does upsert) +INSERT INTO hats VALUES ('h8', 'black') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 527 +SELECT * FROM hat_data WHERE hat_name = 'h8' +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=Select +FILTER: schema="" table="" column="hat_name" +STMT: SelectStmt +== 528 +INSERT INTO hats VALUES ('h8', 'white') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 529 +SELECT * FROM hat_data WHERE hat_name = 'h8' +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=Select +FILTER: schema="" table="" column="hat_name" +STMT: SelectStmt +== 530 +INSERT INTO hats VALUES ('h8', 'forbidden') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 531 +SELECT * FROM hat_data WHERE hat_name = 'h8' +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=Select +FILTER: schema="" table="" column="hat_name" +STMT: SelectStmt +== 532 +SELECT tablename, rulename, definition FROM pg_rules + WHERE tablename = 'hats' +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 533 +-- ensure explain works for on insert conflict rules +explain (costs off) INSERT INTO hats VALUES ('h8', 'forbidden') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 534 +-- ensure upserting into a rule, with a CTE (different offsets!) works +WITH data(hat_name, hat_color) AS MATERIALIZED ( + VALUES ('h8', 'green'), + ('h9', 'blue'), + ('h7', 'forbidden') +) +INSERT INTO hats + SELECT * FROM data +RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +CTE: "data" +STMT: InsertStmt +STMT: SelectStmt +== 535 +EXPLAIN (costs off) +WITH data(hat_name, hat_color) AS MATERIALIZED ( + VALUES ('h8', 'green'), + ('h9', 'blue'), + ('h7', 'forbidden') +) +INSERT INTO hats + SELECT * FROM data +RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +CTE: "data" +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 536 +SELECT * FROM hat_data WHERE hat_name IN ('h8', 'h9', 'h7') ORDER BY hat_name +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=Select +FILTER: schema="" table="" column="hat_name" +STMT: SelectStmt +== 537 +DROP RULE hat_upsert ON hats +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: DropStmt +== 538 +drop table hats +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: DropStmt +== 539 +drop table hat_data +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=DDL +STMT: DropStmt +== 540 +-- test for pg_get_functiondef properly regurgitating SET parameters +-- Note that the function is kept around to stress pg_dump. +CREATE FUNCTION func_with_set_params() RETURNS integer + AS 'select 1;' + LANGUAGE SQL + SET search_path TO PG_CATALOG + SET extra_float_digits TO 2 + SET work_mem TO '4MB' + SET datestyle to iso, mdy + SET local_preload_libraries TO "Mixed/Case", 'c:/''a"/path', '', '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' + IMMUTABLE STRICT +-- +FUNCTION: name="func_with_set_params" function="func_with_set_params" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 541 +SELECT pg_get_functiondef('func_with_set_params()'::regprocedure) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 542 +-- tests for pg_get_*def with invalid objects +SELECT pg_get_constraintdef(0) +-- +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +STMT: SelectStmt +== 543 +SELECT pg_get_functiondef(0) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +== 544 +SELECT pg_get_indexdef(0) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +== 545 +SELECT pg_get_ruledef(0) +-- +FUNCTION: name="pg_get_ruledef" function="pg_get_ruledef" schema="" ctx=Call +STMT: SelectStmt +== 546 +SELECT pg_get_statisticsobjdef(0) +-- +FUNCTION: name="pg_get_statisticsobjdef" function="pg_get_statisticsobjdef" schema="" ctx=Call +STMT: SelectStmt +== 547 +SELECT pg_get_triggerdef(0) +-- +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +STMT: SelectStmt +== 548 +SELECT pg_get_viewdef(0) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 549 +SELECT pg_get_function_arguments(0) +-- +FUNCTION: name="pg_get_function_arguments" function="pg_get_function_arguments" schema="" ctx=Call +STMT: SelectStmt +== 550 +SELECT pg_get_function_identity_arguments(0) +-- +FUNCTION: name="pg_get_function_identity_arguments" function="pg_get_function_identity_arguments" schema="" ctx=Call +STMT: SelectStmt +== 551 +SELECT pg_get_function_result(0) +-- +FUNCTION: name="pg_get_function_result" function="pg_get_function_result" schema="" ctx=Call +STMT: SelectStmt +== 552 +SELECT pg_get_function_arg_default(0, 0) +-- +FUNCTION: name="pg_get_function_arg_default" function="pg_get_function_arg_default" schema="" ctx=Call +STMT: SelectStmt +== 553 +SELECT pg_get_function_arg_default('pg_class'::regclass, 0) +-- +FUNCTION: name="pg_get_function_arg_default" function="pg_get_function_arg_default" schema="" ctx=Call +STMT: SelectStmt +== 554 +SELECT pg_get_partkeydef(0) +-- +FUNCTION: name="pg_get_partkeydef" function="pg_get_partkeydef" schema="" ctx=Call +STMT: SelectStmt +== 555 +-- test rename for a rule defined on a partitioned table +CREATE TABLE rules_parted_table (a int) PARTITION BY LIST (a) +-- +TABLE: name="rules_parted_table" schema="" table="rules_parted_table" ctx=DDL +STMT: CreateStmt +== 556 +CREATE TABLE rules_parted_table_1 PARTITION OF rules_parted_table FOR VALUES IN (1) +-- +TABLE: name="rules_parted_table_1" schema="" table="rules_parted_table_1" ctx=DDL +STMT: CreateStmt +== 557 +CREATE RULE rules_parted_table_insert AS ON INSERT to rules_parted_table + DO INSTEAD INSERT INTO rules_parted_table_1 VALUES (NEW.*) +-- +TABLE: name="rules_parted_table" schema="" table="rules_parted_table" ctx=DDL +STMT: RuleStmt +== 558 +ALTER RULE rules_parted_table_insert ON rules_parted_table RENAME TO rules_parted_table_insert_redirect +-- +STMT: RenameStmt +== 559 +DROP TABLE rules_parted_table +-- +TABLE: name="rules_parted_table" schema="" table="rules_parted_table" ctx=DDL +STMT: DropStmt +== 560 +|-- +-- test MERGE +|-- +CREATE TABLE rule_merge1 (a int, b text) +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: CreateStmt +== 561 +CREATE TABLE rule_merge2 (a int, b text) +-- +TABLE: name="rule_merge2" schema="" table="rule_merge2" ctx=DDL +STMT: CreateStmt +== 562 +CREATE RULE rule1 AS ON INSERT TO rule_merge1 + DO INSTEAD INSERT INTO rule_merge2 VALUES (NEW.*) +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: RuleStmt +== 563 +CREATE RULE rule2 AS ON UPDATE TO rule_merge1 + DO INSTEAD UPDATE rule_merge2 SET a = NEW.a, b = NEW.b + WHERE a = OLD.a +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: RuleStmt +== 564 +CREATE RULE rule3 AS ON DELETE TO rule_merge1 + DO INSTEAD DELETE FROM rule_merge2 WHERE a = OLD.a +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: RuleStmt +== 565 +-- MERGE not supported for table with rules +MERGE INTO rule_merge1 t USING (SELECT 1 AS a) s + ON t.a = s.a + WHEN MATCHED AND t.a < 2 THEN + UPDATE SET b = b || ' updated by merge' + WHEN MATCHED AND t.a > 2 THEN + DELETE + WHEN NOT MATCHED THEN + INSERT VALUES (s.a, '') +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DML +ALIAS: "t"="rule_merge1" +STMT: MergeStmt +STMT: SelectStmt +== 566 +-- should be ok with the other table though +MERGE INTO rule_merge2 t USING (SELECT 1 AS a) s + ON t.a = s.a + WHEN MATCHED AND t.a < 2 THEN + UPDATE SET b = b || ' updated by merge' + WHEN MATCHED AND t.a > 2 THEN + DELETE + WHEN NOT MATCHED THEN + INSERT VALUES (s.a, '') +-- +TABLE: name="rule_merge2" schema="" table="rule_merge2" ctx=DML +ALIAS: "t"="rule_merge2" +STMT: MergeStmt +STMT: SelectStmt +== 567 +-- also ok if the rules are disabled +ALTER TABLE rule_merge1 DISABLE RULE rule1 +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: AlterTableStmt +== 568 +ALTER TABLE rule_merge1 DISABLE RULE rule2 +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: AlterTableStmt +== 569 +ALTER TABLE rule_merge1 DISABLE RULE rule3 +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: AlterTableStmt +== 570 +MERGE INTO rule_merge1 t USING (SELECT 1 AS a) s + ON t.a = s.a + WHEN MATCHED AND t.a < 2 THEN + UPDATE SET b = b || ' updated by merge' + WHEN MATCHED AND t.a > 2 THEN + DELETE + WHEN NOT MATCHED THEN + INSERT VALUES (s.a, '') +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DML +ALIAS: "t"="rule_merge1" +STMT: MergeStmt +STMT: SelectStmt +== 571 +-- test deparsing +CREATE TABLE sf_target(id int, data text, filling int[]) +-- +TABLE: name="sf_target" schema="" table="sf_target" ctx=DDL +STMT: CreateStmt +== 572 +CREATE FUNCTION merge_sf_test() + RETURNS TABLE(action text, a int, b text, id int, data text, filling int[]) + LANGUAGE sql +BEGIN ATOMIC + MERGE INTO sf_target t + USING rule_merge1 s + ON (s.a = t.id) +WHEN MATCHED + AND (s.a + t.id) = 42 + THEN UPDATE SET data = repeat(t.data, s.a) || s.b, id = length(s.b) +WHEN NOT MATCHED + AND (s.b IS NOT NULL) + THEN INSERT (data, id) + VALUES (s.b, s.a) +WHEN MATCHED + AND length(s.b || t.data) > 10 + THEN UPDATE SET data = s.b +WHEN MATCHED + AND s.a > 200 + THEN UPDATE SET filling[s.a] = t.id +WHEN MATCHED + AND s.a > 100 + THEN DELETE +WHEN MATCHED + THEN DO NOTHING +WHEN NOT MATCHED + AND s.a > 200 + THEN INSERT DEFAULT VALUES +WHEN NOT MATCHED + AND s.a > 100 + THEN INSERT (id, data) OVERRIDING USER VALUE + VALUES (s.a, DEFAULT) +WHEN NOT MATCHED + AND s.a > 0 + THEN INSERT + VALUES (s.a, s.b, DEFAULT) +WHEN NOT MATCHED + THEN INSERT (filling[1], id) + VALUES (s.a, s.a) +RETURNING + merge_action() AS action, * +-- +ERROR: syntax error at end of input +CURSORPOS: 982 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 573 +END +-- +STMT: TransactionStmt +== 574 +CREATE FUNCTION merge_sf_test2() + RETURNS void + LANGUAGE sql +BEGIN ATOMIC + MERGE INTO sf_target t + USING rule_merge1 s + ON (s.a = t.id) +WHEN NOT MATCHED + THEN INSERT (data, id) + VALUES (s.a, s.a) +WHEN MATCHED + THEN UPDATE SET data = s.b +WHEN NOT MATCHED BY SOURCE + THEN DELETE +-- +ERROR: syntax error at end of input +CURSORPOS: 289 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 575 +END +-- +STMT: TransactionStmt +== 576 +DROP FUNCTION merge_sf_test +-- +FUNCTION: name="merge_sf_test" function="merge_sf_test" schema="" ctx=DDL +STMT: DropStmt +== 577 +DROP FUNCTION merge_sf_test2 +-- +FUNCTION: name="merge_sf_test2" function="merge_sf_test2" schema="" ctx=DDL +STMT: DropStmt +== 578 +DROP TABLE sf_target +-- +TABLE: name="sf_target" schema="" table="sf_target" ctx=DDL +STMT: DropStmt +== 579 +|-- +-- Test enabling/disabling +|-- +CREATE TABLE ruletest1 (a int) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: CreateStmt +== 580 +CREATE TABLE ruletest2 (b int) +-- +TABLE: name="ruletest2" schema="" table="ruletest2" ctx=DDL +STMT: CreateStmt +== 581 +CREATE RULE rule1 AS ON INSERT TO ruletest1 + DO INSTEAD INSERT INTO ruletest2 VALUES (NEW.*) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: RuleStmt +== 582 +INSERT INTO ruletest1 VALUES (1) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 583 +ALTER TABLE ruletest1 DISABLE RULE rule1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: AlterTableStmt +== 584 +INSERT INTO ruletest1 VALUES (2) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 585 +ALTER TABLE ruletest1 ENABLE RULE rule1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: AlterTableStmt +== 586 +SET session_replication_role = replica +-- +STMT: VariableSetStmt +== 587 +INSERT INTO ruletest1 VALUES (3) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 588 +ALTER TABLE ruletest1 ENABLE REPLICA RULE rule1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: AlterTableStmt +== 589 +INSERT INTO ruletest1 VALUES (4) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 590 +RESET session_replication_role +-- +STMT: VariableSetStmt +== 591 +INSERT INTO ruletest1 VALUES (5) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 592 +SELECT * FROM ruletest1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=Select +STMT: SelectStmt +== 593 +SELECT * FROM ruletest2 +-- +TABLE: name="ruletest2" schema="" table="ruletest2" ctx=Select +STMT: SelectStmt +== 594 +DROP TABLE ruletest1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: DropStmt +== 595 +DROP TABLE ruletest2 +-- +TABLE: name="ruletest2" schema="" table="ruletest2" ctx=DDL +STMT: DropStmt +== 596 +|-- +-- Test non-SELECT rule on security invoker view. +-- Should use view owner's permissions. +|-- +CREATE USER regress_rule_user1 +-- +STMT: CreateRoleStmt +== 597 +CREATE TABLE ruletest_t1 (x int) +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: CreateStmt +== 598 +CREATE TABLE ruletest_t2 (x int) +-- +TABLE: name="ruletest_t2" schema="" table="ruletest_t2" ctx=DDL +STMT: CreateStmt +== 599 +CREATE VIEW ruletest_v1 WITH (security_invoker=true) AS + SELECT * FROM ruletest_t1 +-- +TABLE: name="ruletest_v1" schema="" table="ruletest_v1" ctx=DDL +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 600 +GRANT INSERT ON ruletest_v1 TO regress_rule_user1 +-- +TABLE: name="ruletest_v1" schema="" table="ruletest_v1" ctx=DDL +STMT: GrantStmt +== 601 +CREATE RULE rule1 AS ON INSERT TO ruletest_v1 + DO INSTEAD INSERT INTO ruletest_t2 VALUES (NEW.*) +-- +TABLE: name="ruletest_v1" schema="" table="ruletest_v1" ctx=DDL +STMT: RuleStmt +== 602 +SET SESSION AUTHORIZATION regress_rule_user1 +-- +STMT: VariableSetStmt +== 603 +INSERT INTO ruletest_v1 VALUES (1) +-- +TABLE: name="ruletest_v1" schema="" table="ruletest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 604 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 605 +-- Test that main query's relation's permissions are checked before +-- the rule action's relation's. +CREATE TABLE ruletest_t3 (x int) +-- +TABLE: name="ruletest_t3" schema="" table="ruletest_t3" ctx=DDL +STMT: CreateStmt +== 606 +CREATE RULE rule2 AS ON UPDATE TO ruletest_t1 + DO INSTEAD INSERT INTO ruletest_t2 VALUES (OLD.*) +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: RuleStmt +== 607 +REVOKE ALL ON ruletest_t2 FROM regress_rule_user1 +-- +TABLE: name="ruletest_t2" schema="" table="ruletest_t2" ctx=DDL +STMT: GrantStmt +== 608 +REVOKE ALL ON ruletest_t3 FROM regress_rule_user1 +-- +TABLE: name="ruletest_t3" schema="" table="ruletest_t3" ctx=DDL +STMT: GrantStmt +== 609 +ALTER TABLE ruletest_t1 OWNER TO regress_rule_user1 +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: AlterTableStmt +== 610 +SET SESSION AUTHORIZATION regress_rule_user1 +-- +STMT: VariableSetStmt +== 611 +UPDATE ruletest_t1 t1 SET x = 0 FROM ruletest_t3 t3 WHERE t1.x = t3.x +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DML +TABLE: name="ruletest_t3" schema="" table="ruletest_t3" ctx=Select +ALIAS: "t1"="ruletest_t1" +ALIAS: "t3"="ruletest_t3" +STMT: UpdateStmt +== 612 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 613 +SELECT * FROM ruletest_t1 +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=Select +STMT: SelectStmt +== 614 +SELECT * FROM ruletest_t2 +-- +TABLE: name="ruletest_t2" schema="" table="ruletest_t2" ctx=Select +STMT: SelectStmt +== 615 +DROP VIEW ruletest_v1 +-- +STMT: DropStmt +== 616 +DROP RULE rule2 ON ruletest_t1 +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: DropStmt +== 617 +DROP TABLE ruletest_t3 +-- +TABLE: name="ruletest_t3" schema="" table="ruletest_t3" ctx=DDL +STMT: DropStmt +== 618 +DROP TABLE ruletest_t2 +-- +TABLE: name="ruletest_t2" schema="" table="ruletest_t2" ctx=DDL +STMT: DropStmt +== 619 +DROP TABLE ruletest_t1 +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: DropStmt +== 620 +DROP USER regress_rule_user1 +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/sanity_check.metadata.json b/parser/testdata/summary/postgres_regress/sanity_check.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sanity_check.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/sanity_check.test b/parser/testdata/summary/postgres_regress/sanity_check.test new file mode 100644 index 0000000..c09018f --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sanity_check.test @@ -0,0 +1,49 @@ +== 001 +VACUUM +-- +STMT: VacuumStmt +== 002 +|-- +-- Sanity check: every system catalog that has OIDs should have +-- a unique index on OID. This ensures that the OIDs will be unique, +-- even after the OID counter wraps around. +-- We exclude non-system tables from the check by looking at nspname. +|-- +SELECT relname, nspname + FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace JOIN pg_attribute a ON (attrelid = c.oid AND attname = 'oid') + WHERE relkind = 'r' and c.oid < 16384 + AND ((nspname ~ '^pg_') IS NOT FALSE) + AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid + AND indkey[0] = a.attnum AND indnatts = 1 + AND indisunique AND indimmediate) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +ALIAS: "n"="pg_namespace" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="nspname" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="indkey" +FILTER: schema="" table="a" column="attnum" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indisunique" +FILTER: schema="" table="" column="indimmediate" +STMT: SelectStmt +== 003 +-- check that relations without storage don't have relfilenode +SELECT relname, relkind + FROM pg_class + WHERE relkind IN ('v', 'c', 'f', 'p', 'I') + AND relfilenode <> 0 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relfilenode" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/security_label.metadata.json b/parser/testdata/summary/postgres_regress/security_label.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/security_label.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/security_label.test b/parser/testdata/summary/postgres_regress/security_label.test new file mode 100644 index 0000000..994f339 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/security_label.test @@ -0,0 +1,142 @@ +== 001 +|-- +-- Test for facilities of security label +|-- + +-- initial setups +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +== 002 +DROP ROLE IF EXISTS regress_seclabel_user1 +-- +STMT: DropRoleStmt +== 003 +DROP ROLE IF EXISTS regress_seclabel_user2 +-- +STMT: DropRoleStmt +== 004 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 005 +CREATE USER regress_seclabel_user1 WITH CREATEROLE +-- +STMT: CreateRoleStmt +== 006 +CREATE USER regress_seclabel_user2 +-- +STMT: CreateRoleStmt +== 007 +CREATE TABLE seclabel_tbl1 (a int, b text) +-- +TABLE: name="seclabel_tbl1" schema="" table="seclabel_tbl1" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE seclabel_tbl2 (x int, y text) +-- +TABLE: name="seclabel_tbl2" schema="" table="seclabel_tbl2" ctx=DDL +STMT: CreateStmt +== 009 +CREATE VIEW seclabel_view1 AS SELECT * FROM seclabel_tbl2 +-- +TABLE: name="seclabel_view1" schema="" table="seclabel_view1" ctx=DDL +TABLE: name="seclabel_tbl2" schema="" table="seclabel_tbl2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 010 +CREATE FUNCTION seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql +-- +FUNCTION: name="seclabel_four" function="seclabel_four" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 011 +CREATE DOMAIN seclabel_domain AS text +-- +STMT: CreateDomainStmt +== 012 +ALTER TABLE seclabel_tbl1 OWNER TO regress_seclabel_user1 +-- +TABLE: name="seclabel_tbl1" schema="" table="seclabel_tbl1" ctx=DDL +STMT: AlterTableStmt +== 013 +ALTER TABLE seclabel_tbl2 OWNER TO regress_seclabel_user2 +-- +TABLE: name="seclabel_tbl2" schema="" table="seclabel_tbl2" ctx=DDL +STMT: AlterTableStmt +== 014 +|-- +-- Test of SECURITY LABEL statement without a plugin +|-- +SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified' +-- +STMT: SecLabelStmt +== 015 +-- fail +SECURITY LABEL FOR 'dummy' ON TABLE seclabel_tbl1 IS 'classified' +-- +STMT: SecLabelStmt +== 016 +-- fail +SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...' +-- +STMT: SecLabelStmt +== 017 +-- fail +SECURITY LABEL ON TABLE seclabel_tbl3 IS 'unclassified' +-- +STMT: SecLabelStmt +== 018 +-- fail + +SECURITY LABEL ON ROLE regress_seclabel_user1 IS 'classified' +-- +STMT: SecLabelStmt +== 019 +-- fail +SECURITY LABEL FOR 'dummy' ON ROLE regress_seclabel_user1 IS 'classified' +-- +STMT: SecLabelStmt +== 020 +-- fail +SECURITY LABEL ON ROLE regress_seclabel_user1 IS '...invalid label...' +-- +STMT: SecLabelStmt +== 021 +-- fail +SECURITY LABEL ON ROLE regress_seclabel_user3 IS 'unclassified' +-- +STMT: SecLabelStmt +== 022 +-- fail + +-- clean up objects +DROP FUNCTION seclabel_four() +-- +FUNCTION: name="seclabel_four" function="seclabel_four" schema="" ctx=DDL +STMT: DropStmt +== 023 +DROP DOMAIN seclabel_domain +-- +STMT: DropStmt +== 024 +DROP VIEW seclabel_view1 +-- +STMT: DropStmt +== 025 +DROP TABLE seclabel_tbl1 +-- +TABLE: name="seclabel_tbl1" schema="" table="seclabel_tbl1" ctx=DDL +STMT: DropStmt +== 026 +DROP TABLE seclabel_tbl2 +-- +TABLE: name="seclabel_tbl2" schema="" table="seclabel_tbl2" ctx=DDL +STMT: DropStmt +== 027 +DROP USER regress_seclabel_user1 +-- +STMT: DropRoleStmt +== 028 +DROP USER regress_seclabel_user2 +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/select.metadata.json b/parser/testdata/summary/postgres_regress/select.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/select.test b/parser/testdata/summary/postgres_regress/select.test new file mode 100644 index 0000000..91be8cd --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select.test @@ -0,0 +1,637 @@ +== 001 +|-- +-- SELECT +|-- + +-- btree index +-- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1 +|-- +SELECT * FROM onek + WHERE onek.unique1 < 10 + ORDER BY onek.unique1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +== 002 +|-- +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 +|-- +SELECT onek.unique1, onek.stringu1 FROM onek + WHERE onek.unique1 < 20 + ORDER BY unique1 using > +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +== 003 +|-- +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 +|-- +SELECT onek.unique1, onek.stringu1 FROM onek + WHERE onek.unique1 > 980 + ORDER BY stringu1 using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +== 004 +|-- +-- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | +-- sort +1d -2 +0nr -1 +|-- +SELECT onek.unique1, onek.string4 FROM onek + WHERE onek.unique1 > 980 + ORDER BY string4 using <, unique1 using > +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +== 005 +|-- +-- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | +-- sort +1dr -2 +0n -1 +|-- +SELECT onek.unique1, onek.string4 FROM onek + WHERE onek.unique1 > 980 + ORDER BY string4 using >, unique1 using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +== 006 +|-- +-- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | +-- sort +0nr -1 +1d -2 +|-- +SELECT onek.unique1, onek.string4 FROM onek + WHERE onek.unique1 < 20 + ORDER BY unique1 using >, string4 using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +== 007 +|-- +-- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | +-- sort +0n -1 +1dr -2 +|-- +SELECT onek.unique1, onek.string4 FROM onek + WHERE onek.unique1 < 20 + ORDER BY unique1 using <, string4 using > +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +== 008 +|-- +-- test partial btree indexes +|-- +-- As of 7.2, planner probably won't pick an indexscan without stats, +-- so ANALYZE first. Also, we want to prevent it from picking a bitmapscan +-- followed by sort, because that could hide index ordering problems. +|-- +ANALYZE onek2 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: VacuumStmt +== 009 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +== 010 +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +== 011 +SET enable_sort TO off +-- +STMT: VariableSetStmt +== 012 +|-- +-- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1 +|-- +SELECT onek2.* FROM onek2 WHERE onek2.unique1 < 10 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="onek2" column="unique1" +STMT: SelectStmt +== 013 +|-- +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 +|-- +SELECT onek2.unique1, onek2.stringu1 FROM onek2 + WHERE onek2.unique1 < 20 + ORDER BY unique1 using > +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="onek2" column="unique1" +STMT: SelectStmt +== 014 +|-- +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 +|-- +SELECT onek2.unique1, onek2.stringu1 FROM onek2 + WHERE onek2.unique1 > 980 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="onek2" column="unique1" +STMT: SelectStmt +== 015 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 016 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 017 +RESET enable_sort +-- +STMT: VariableSetStmt +== 018 +|-- +-- awk '{print $1,$2;}' person.data | +-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | +-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data | +-- awk 'BEGIN{FS=" ";}{if(NF!=2){print $4,$5;}else{print;}}' - stud_emp.data +|-- +-- SELECT name, age FROM person*; ??? check if different +SELECT p.name, p.age FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +STMT: SelectStmt +== 019 +|-- +-- awk '{print $1,$2;}' person.data | +-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | +-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data | +-- awk 'BEGIN{FS=" ";}{if(NF!=1){print $4,$5;}else{print;}}' - stud_emp.data | +-- sort +1nr -2 +|-- +SELECT p.name, p.age FROM person* p ORDER BY age using >, name +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +STMT: SelectStmt +== 020 +|-- +-- Test some cases involving whole-row Var referencing a subquery +|-- +select foo from (select 1 offset 0) as foo +-- +STMT: SelectStmt +== 021 +select foo from (select null offset 0) as foo +-- +STMT: SelectStmt +== 022 +select foo from (select 'xyzzy',1,null offset 0) as foo +-- +STMT: SelectStmt +== 023 +|-- +-- Test VALUES lists +|-- +select * from onek, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j) + WHERE onek.unique1 = v.i and onek.stringu1 = v.j +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +FILTER: schema="" table="v" column="i" +FILTER: schema="" table="onek" column="stringu1" +FILTER: schema="" table="v" column="j" +STMT: SelectStmt +== 024 +-- a more complex case +-- looks like we're coding lisp :-) +select * from onek, + (values ((select i from + (values(10000), (2), (389), (1000), (2000), ((select 10029))) as foo(i) + order by i asc limit 1))) bar (i) + where onek.unique1 = bar.i +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +FILTER: schema="" table="bar" column="i" +STMT: SelectStmt +== 025 +-- try VALUES in a subquery +select * from onek + where (unique1,ten) in (values (1,1), (20,0), (99,9), (17,99)) + order by unique1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="ten" +STMT: SelectStmt +== 026 +-- VALUES is also legal as a standalone query or a set-operation member +VALUES (1,2), (3,4+4), (7,77.7) +-- +STMT: SelectStmt +== 027 +VALUES (1,2), (3,4+4), (7,77.7) +UNION ALL +SELECT 2+2, 57 +UNION ALL +TABLE int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 028 +-- corner case: VALUES with no columns +CREATE TEMP TABLE nocols() +-- +TABLE: name="nocols" schema="" table="nocols" ctx=DDL +STMT: CreateStmt +== 029 +INSERT INTO nocols DEFAULT VALUES +-- +TABLE: name="nocols" schema="" table="nocols" ctx=DML +STMT: InsertStmt +== 030 +SELECT * FROM nocols n, LATERAL (VALUES(n.*)) v +-- +TABLE: name="nocols" schema="" table="nocols" ctx=Select +ALIAS: "n"="nocols" +STMT: SelectStmt +== 031 +|-- +-- Test ORDER BY options +|-- + +CREATE TEMP TABLE foo (f1 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 032 +INSERT INTO foo VALUES (42),(3),(10),(7),(null),(null),(1) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +SELECT * FROM foo ORDER BY f1 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 034 +SELECT * FROM foo ORDER BY f1 ASC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 035 +-- same thing +SELECT * FROM foo ORDER BY f1 NULLS FIRST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 036 +SELECT * FROM foo ORDER BY f1 DESC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 037 +SELECT * FROM foo ORDER BY f1 DESC NULLS LAST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 038 +-- check if indexscans do the right things +CREATE INDEX fooi ON foo (f1) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +== 039 +SET enable_sort = false +-- +STMT: VariableSetStmt +== 040 +SELECT * FROM foo ORDER BY f1 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 041 +SELECT * FROM foo ORDER BY f1 NULLS FIRST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 042 +SELECT * FROM foo ORDER BY f1 DESC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 043 +SELECT * FROM foo ORDER BY f1 DESC NULLS LAST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 044 +DROP INDEX fooi +-- +STMT: DropStmt +== 045 +CREATE INDEX fooi ON foo (f1 DESC) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +== 046 +SELECT * FROM foo ORDER BY f1 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 047 +SELECT * FROM foo ORDER BY f1 NULLS FIRST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 048 +SELECT * FROM foo ORDER BY f1 DESC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 049 +SELECT * FROM foo ORDER BY f1 DESC NULLS LAST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 050 +DROP INDEX fooi +-- +STMT: DropStmt +== 051 +CREATE INDEX fooi ON foo (f1 DESC NULLS LAST) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +== 052 +SELECT * FROM foo ORDER BY f1 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 053 +SELECT * FROM foo ORDER BY f1 NULLS FIRST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 054 +SELECT * FROM foo ORDER BY f1 DESC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 055 +SELECT * FROM foo ORDER BY f1 DESC NULLS LAST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +== 056 +|-- +-- Test planning of some cases with partial indexes +|-- + +-- partial index is usable +explain (costs off) +select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 057 +select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 058 +-- actually run the query with an analyze to use the partial index +explain (costs off, analyze on, timing off, summary off) +select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 059 +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 060 +select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 061 +-- partial index predicate implies clause, so no need for retest +explain (costs off) +select * from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 062 +select * from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 063 +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 064 +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 065 +-- but if it's an update target, must retest anyway +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 066 +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 067 +-- partial index is not applicable +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 < 'C' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 068 +select unique2 from onek2 where unique2 = 11 and stringu1 < 'C' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 069 +-- partial index implies clause, but bitmap scan must recheck predicate anyway +SET enable_indexscan TO off +-- +STMT: VariableSetStmt +== 070 +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 071 +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 072 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 073 +-- check multi-index cases too +explain (costs off) +select unique1, unique2 from onek2 + where (unique2 = 11 or unique1 = 0) and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 074 +select unique1, unique2 from onek2 + where (unique2 = 11 or unique1 = 0) and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 075 +explain (costs off) +select unique1, unique2 from onek2 + where (unique2 = 11 and stringu1 < 'B') or unique1 = 0 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 076 +select unique1, unique2 from onek2 + where (unique2 = 11 and stringu1 < 'B') or unique1 = 0 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 077 +|-- +-- Test some corner cases that have been known to confuse the planner +|-- + +-- ORDER BY on a constant doesn't really need any sorting +SELECT 1 AS x ORDER BY x +-- +STMT: SelectStmt +== 078 +-- But ORDER BY on a set-valued expression does +create function sillysrf(int) returns setof int as + 'values (1),(10),(2),($1)' language sql immutable +-- +FUNCTION: name="sillysrf" function="sillysrf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 079 +select sillysrf(42) +-- +FUNCTION: name="sillysrf" function="sillysrf" schema="" ctx=Call +STMT: SelectStmt +== 080 +select sillysrf(-1) order by 1 +-- +FUNCTION: name="sillysrf" function="sillysrf" schema="" ctx=Call +STMT: SelectStmt +== 081 +drop function sillysrf(int) +-- +FUNCTION: name="sillysrf" function="sillysrf" schema="" ctx=DDL +STMT: DropStmt +== 082 +-- X = X isn't a no-op, it's effectively X IS NOT NULL assuming = is strict +-- (see bug #5084) +select * from (values (2),(null),(1)) v(k) where k = k order by k +-- +FILTER: schema="" table="" column="k" +FILTER: schema="" table="" column="k" +STMT: SelectStmt +== 083 +select * from (values (2),(null),(1)) v(k) where k = k +-- +FILTER: schema="" table="" column="k" +FILTER: schema="" table="" column="k" +STMT: SelectStmt +== 084 +-- Test partitioned tables with no partitions, which should be handled the +-- same as the non-inheritance case when expanding its RTE. +create table list_parted_tbl (a int,b int) partition by list (a) +-- +TABLE: name="list_parted_tbl" schema="" table="list_parted_tbl" ctx=DDL +STMT: CreateStmt +== 085 +create table list_parted_tbl1 partition of list_parted_tbl + for values in (1) partition by list(b) +-- +TABLE: name="list_parted_tbl1" schema="" table="list_parted_tbl1" ctx=DDL +STMT: CreateStmt +== 086 +explain (costs off) select * from list_parted_tbl +-- +TABLE: name="list_parted_tbl" schema="" table="list_parted_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 087 +drop table list_parted_tbl +-- +TABLE: name="list_parted_tbl" schema="" table="list_parted_tbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/select_distinct.metadata.json b/parser/testdata/summary/postgres_regress/select_distinct.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_distinct.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/select_distinct.test b/parser/testdata/summary/postgres_regress/select_distinct.test new file mode 100644 index 0000000..0ee19ec --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_distinct.test @@ -0,0 +1,487 @@ +== 001 +|-- +-- SELECT_DISTINCT +|-- + +|-- +-- awk '{print $3;}' onek.data | sort -n | uniq +|-- +SELECT DISTINCT two FROM onek ORDER BY 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 002 +|-- +-- awk '{print $5;}' onek.data | sort -n | uniq +|-- +SELECT DISTINCT ten FROM onek ORDER BY 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 003 +|-- +-- awk '{print $16;}' onek.data | sort -d | uniq +|-- +SELECT DISTINCT string4 FROM onek ORDER BY 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 004 +|-- +-- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq | +-- sort +0n -1 +1d -2 +2n -3 +|-- +SELECT DISTINCT two, string4, ten + FROM onek + ORDER BY two using <, string4 using <, ten using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 005 +|-- +-- awk '{print $2;}' person.data | +-- awk '{if(NF!=1){print $2;}else{print;}}' - emp.data | +-- awk '{if(NF!=1){print $2;}else{print;}}' - student.data | +-- awk 'BEGIN{FS=" ";}{if(NF!=1){print $5;}else{print;}}' - stud_emp.data | +-- sort -n -r | uniq +|-- +SELECT DISTINCT p.age FROM person* p ORDER BY age using > +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +STMT: SelectStmt +== 006 +|-- +-- Check mentioning same column more than once +|-- + +EXPLAIN (VERBOSE, COSTS OFF) +SELECT count(*) FROM + (SELECT DISTINCT two, four, two FROM tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 007 +SELECT count(*) FROM + (SELECT DISTINCT two, four, two FROM tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 008 +|-- +-- Compare results between plans using sorting and plans using hash +-- aggregation. Force spilling in both cases by setting work_mem low. +|-- + +SET work_mem='64kB' +-- +STMT: VariableSetStmt +== 009 +-- Produce results with sorting. + +SET enable_hashagg=FALSE +-- +STMT: VariableSetStmt +== 010 +SET jit_above_cost=0 +-- +STMT: VariableSetStmt +== 011 +EXPLAIN (costs off) +SELECT DISTINCT g%1000 FROM generate_series(0,9999) g +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 012 +CREATE TABLE distinct_group_1 AS +SELECT DISTINCT g%1000 FROM generate_series(0,9999) g +-- +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 013 +SET jit_above_cost TO DEFAULT +-- +STMT: VariableSetStmt +== 014 +CREATE TABLE distinct_group_2 AS +SELECT DISTINCT (g%1000)::text FROM generate_series(0,9999) g +-- +TABLE: name="distinct_group_2" schema="" table="distinct_group_2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 015 +SET enable_seqscan = 0 +-- +STMT: VariableSetStmt +== 016 +-- Check to see we get an incremental sort plan +EXPLAIN (costs off) +SELECT DISTINCT hundred, two FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 017 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 018 +SET enable_hashagg=TRUE +-- +STMT: VariableSetStmt +== 019 +-- Produce results with hash aggregation. + +SET enable_sort=FALSE +-- +STMT: VariableSetStmt +== 020 +SET jit_above_cost=0 +-- +STMT: VariableSetStmt +== 021 +EXPLAIN (costs off) +SELECT DISTINCT g%1000 FROM generate_series(0,9999) g +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 022 +CREATE TABLE distinct_hash_1 AS +SELECT DISTINCT g%1000 FROM generate_series(0,9999) g +-- +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 023 +SET jit_above_cost TO DEFAULT +-- +STMT: VariableSetStmt +== 024 +CREATE TABLE distinct_hash_2 AS +SELECT DISTINCT (g%1000)::text FROM generate_series(0,9999) g +-- +TABLE: name="distinct_hash_2" schema="" table="distinct_hash_2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 025 +SET enable_sort=TRUE +-- +STMT: VariableSetStmt +== 026 +SET work_mem TO DEFAULT +-- +STMT: VariableSetStmt +== 027 +-- Compare results + +(SELECT * FROM distinct_hash_1 EXCEPT SELECT * FROM distinct_group_1) + UNION ALL +(SELECT * FROM distinct_group_1 EXCEPT SELECT * FROM distinct_hash_1) +-- +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=Select +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=Select +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=Select +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=Select +STMT: SelectStmt +== 028 +(SELECT * FROM distinct_hash_1 EXCEPT SELECT * FROM distinct_group_1) + UNION ALL +(SELECT * FROM distinct_group_1 EXCEPT SELECT * FROM distinct_hash_1) +-- +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=Select +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=Select +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=Select +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=Select +STMT: SelectStmt +== 029 +DROP TABLE distinct_hash_1 +-- +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=DDL +STMT: DropStmt +== 030 +DROP TABLE distinct_hash_2 +-- +TABLE: name="distinct_hash_2" schema="" table="distinct_hash_2" ctx=DDL +STMT: DropStmt +== 031 +DROP TABLE distinct_group_1 +-- +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=DDL +STMT: DropStmt +== 032 +DROP TABLE distinct_group_2 +-- +TABLE: name="distinct_group_2" schema="" table="distinct_group_2" ctx=DDL +STMT: DropStmt +== 033 +-- Test parallel DISTINCT +SET parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +== 034 +SET parallel_setup_cost=0 +-- +STMT: VariableSetStmt +== 035 +SET min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +== 036 +SET max_parallel_workers_per_gather=2 +-- +STMT: VariableSetStmt +== 037 +-- Ensure we get a parallel plan +EXPLAIN (costs off) +SELECT DISTINCT four FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 038 +-- Ensure the parallel plan produces the correct results +SELECT DISTINCT four FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +== 039 +CREATE OR REPLACE FUNCTION distinct_func(a INT) RETURNS INT AS $$ + BEGIN + RETURN a; + END; +$$ LANGUAGE plpgsql PARALLEL UNSAFE +-- +FUNCTION: name="distinct_func" function="distinct_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 040 +-- Ensure we don't do parallel distinct with a parallel unsafe function +EXPLAIN (COSTS OFF) +SELECT DISTINCT distinct_func(1) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="distinct_func" function="distinct_func" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 041 +-- make the function parallel safe +CREATE OR REPLACE FUNCTION distinct_func(a INT) RETURNS INT AS $$ + BEGIN + RETURN a; + END; +$$ LANGUAGE plpgsql PARALLEL SAFE +-- +FUNCTION: name="distinct_func" function="distinct_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 042 +-- Ensure we do parallel distinct now that the function is parallel safe +EXPLAIN (COSTS OFF) +SELECT DISTINCT distinct_func(1) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="distinct_func" function="distinct_func" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 043 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +== 044 +RESET min_parallel_table_scan_size +-- +STMT: VariableSetStmt +== 045 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +== 046 +RESET parallel_tuple_cost +-- +STMT: VariableSetStmt +== 047 +|-- +-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when +-- all of the distinct_pathkeys have been marked as redundant +|-- + +-- Ensure we get a plan with a Limit 1 +EXPLAIN (COSTS OFF) +SELECT DISTINCT four FROM tenk1 WHERE four = 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 048 +-- Ensure the above gives us the correct result +SELECT DISTINCT four FROM tenk1 WHERE four = 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: SelectStmt +== 049 +-- Ensure we get a plan with a Limit 1 +EXPLAIN (COSTS OFF) +SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="two" +STMT: ExplainStmt +STMT: SelectStmt +== 050 +-- Ensure no rows are returned +SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="two" +STMT: SelectStmt +== 051 +-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants +EXPLAIN (COSTS OFF) +SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 052 +-- Ensure we only get 1 row +SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: SelectStmt +== 053 +SET parallel_setup_cost=0 +-- +STMT: VariableSetStmt +== 054 +SET min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +== 055 +SET max_parallel_workers_per_gather=2 +-- +STMT: VariableSetStmt +== 056 +-- Ensure we get a plan with a Limit 1 in both partial distinct and final +-- distinct +EXPLAIN (COSTS OFF) +SELECT DISTINCT four FROM tenk1 WHERE four = 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 057 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +== 058 +RESET min_parallel_table_scan_size +-- +STMT: VariableSetStmt +== 059 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +== 060 +|-- +-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its +-- very own regression file. +|-- + +CREATE TEMP TABLE disttable (f1 integer) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DDL +STMT: CreateStmt +== 061 +INSERT INTO DISTTABLE VALUES(1) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +INSERT INTO DISTTABLE VALUES(2) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +INSERT INTO DISTTABLE VALUES(3) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +INSERT INTO DISTTABLE VALUES(NULL) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +-- basic cases +SELECT f1, f1 IS DISTINCT FROM 2 as "not 2" FROM disttable +-- +TABLE: name="disttable" schema="" table="disttable" ctx=Select +STMT: SelectStmt +== 066 +SELECT f1, f1 IS DISTINCT FROM NULL as "not null" FROM disttable +-- +TABLE: name="disttable" schema="" table="disttable" ctx=Select +STMT: SelectStmt +== 067 +SELECT f1, f1 IS DISTINCT FROM f1 as "false" FROM disttable +-- +TABLE: name="disttable" schema="" table="disttable" ctx=Select +STMT: SelectStmt +== 068 +SELECT f1, f1 IS DISTINCT FROM f1+1 as "not null" FROM disttable +-- +TABLE: name="disttable" schema="" table="disttable" ctx=Select +STMT: SelectStmt +== 069 +-- check that optimizer constant-folds it properly +SELECT 1 IS DISTINCT FROM 2 as "yes" +-- +STMT: SelectStmt +== 070 +SELECT 2 IS DISTINCT FROM 2 as "no" +-- +STMT: SelectStmt +== 071 +SELECT 2 IS DISTINCT FROM null as "yes" +-- +STMT: SelectStmt +== 072 +SELECT null IS DISTINCT FROM null as "no" +-- +STMT: SelectStmt +== 073 +-- negated form +SELECT 1 IS NOT DISTINCT FROM 2 as "no" +-- +STMT: SelectStmt +== 074 +SELECT 2 IS NOT DISTINCT FROM 2 as "yes" +-- +STMT: SelectStmt +== 075 +SELECT 2 IS NOT DISTINCT FROM null as "no" +-- +STMT: SelectStmt +== 076 +SELECT null IS NOT DISTINCT FROM null as "yes" +-- +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/select_distinct_on.metadata.json b/parser/testdata/summary/postgres_regress/select_distinct_on.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_distinct_on.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/select_distinct_on.test b/parser/testdata/summary/postgres_regress/select_distinct_on.test new file mode 100644 index 0000000..ad84e1d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_distinct_on.test @@ -0,0 +1,78 @@ +== 001 +|-- +-- SELECT_DISTINCT_ON +|-- + +SELECT DISTINCT ON (string4) string4, two, ten + FROM onek + ORDER BY string4 using <, two using >, ten using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 002 +-- this will fail due to conflict of ordering requirements +SELECT DISTINCT ON (string4, ten) string4, two, ten + FROM onek + ORDER BY string4 using <, two using <, ten using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 003 +SELECT DISTINCT ON (string4, ten) string4, ten, two + FROM onek + ORDER BY string4 using <, ten using >, two using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +== 004 +-- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses +select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="floor" function="floor" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 005 +|-- +-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when +-- all of the distinct_pathkeys have been marked as redundant +|-- + +-- Ensure we also get a LIMIT plan with DISTINCT ON +EXPLAIN (COSTS OFF) +SELECT DISTINCT ON (four) four,two + FROM tenk1 WHERE four = 0 ORDER BY 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 006 +-- and check the result of the above query is correct +SELECT DISTINCT ON (four) four,two + FROM tenk1 WHERE four = 0 ORDER BY 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: SelectStmt +== 007 +-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols +EXPLAIN (COSTS OFF) +SELECT DISTINCT ON (four) four,two + FROM tenk1 WHERE four = 0 ORDER BY 1,2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 008 +-- Same again but use a column that is indexed so that we get an index scan +-- then a limit +EXPLAIN (COSTS OFF) +SELECT DISTINCT ON (four) four,hundred + FROM tenk1 WHERE four = 0 ORDER BY 1,2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/select_having.metadata.json b/parser/testdata/summary/postgres_regress/select_having.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_having.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/select_having.test b/parser/testdata/summary/postgres_regress/select_having.test new file mode 100644 index 0000000..a1c38f1 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_having.test @@ -0,0 +1,166 @@ +== 001 +|-- +-- SELECT_HAVING +|-- + +-- load test data +CREATE TABLE test_having (a int, b int, c char(8), d char) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO test_having VALUES (0, 1, 'XXXX', 'A') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO test_having VALUES (1, 2, 'AAAA', 'b') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO test_having VALUES (2, 2, 'AAAA', 'c') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO test_having VALUES (3, 3, 'BBBB', 'D') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO test_having VALUES (4, 3, 'BBBB', 'e') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO test_having VALUES (5, 3, 'bbbb', 'F') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO test_having VALUES (6, 4, 'cccc', 'g') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO test_having VALUES (7, 4, 'cccc', 'h') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO test_having VALUES (8, 4, 'CCCC', 'I') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO test_having VALUES (9, 4, 'CCCC', 'j') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +SELECT b, c FROM test_having + GROUP BY b, c HAVING count(*) = 1 ORDER BY b, c +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- HAVING is effectively equivalent to WHERE in this case +SELECT b, c FROM test_having + GROUP BY b, c HAVING b = 3 ORDER BY b, c +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +STMT: SelectStmt +== 014 +SELECT lower(c), count(c) FROM test_having + GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a) + ORDER BY lower(c) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT c, max(a) FROM test_having + GROUP BY c HAVING count(*) > 2 OR min(a) = max(a) + ORDER BY c +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- test degenerate cases involving HAVING without GROUP BY +-- Per SQL spec, these should generate 0 or 1 row, even without aggregates + +SELECT min(a), max(a) FROM test_having HAVING min(a) = max(a) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT min(a), max(a) FROM test_having HAVING min(a) < max(a) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- errors: ungrouped column references +SELECT a FROM test_having HAVING min(a) < max(a) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT 1 AS one FROM test_having HAVING a > 1 +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +STMT: SelectStmt +== 020 +-- the really degenerate case: need not scan table at all +SELECT 1 AS one FROM test_having HAVING 1 > 2 +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +STMT: SelectStmt +== 021 +SELECT 1 AS one FROM test_having HAVING 1 < 2 +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +STMT: SelectStmt +== 022 +-- and just to prove that we aren't scanning the table: +SELECT 1 AS one FROM test_having WHERE 1/a = 1 HAVING 1 < 2 +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 023 +DROP TABLE test_having +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/select_implicit.metadata.json b/parser/testdata/summary/postgres_regress/select_implicit.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_implicit.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/select_implicit.test b/parser/testdata/summary/postgres_regress/select_implicit.test new file mode 100644 index 0000000..a63c323 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_implicit.test @@ -0,0 +1,384 @@ +== 001 +|-- +-- SELECT_IMPLICIT +-- Test cases for queries with ordering terms missing from the target list. +-- This used to be called "junkfilter.sql". +-- The parser uses the term "resjunk" to handle these cases. +-- - thomas 1998-07-09 +|-- + +-- load test data +CREATE TABLE test_missing_target (a int, b int, c char(8), d char) +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO test_missing_target VALUES (0, 1, 'XXXX', 'A') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO test_missing_target VALUES (1, 2, 'ABAB', 'b') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO test_missing_target VALUES (2, 2, 'ABAB', 'c') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO test_missing_target VALUES (3, 3, 'BBBB', 'D') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO test_missing_target VALUES (4, 3, 'BBBB', 'e') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO test_missing_target VALUES (5, 3, 'bbbb', 'F') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO test_missing_target VALUES (6, 4, 'cccc', 'g') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO test_missing_target VALUES (7, 4, 'cccc', 'h') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO test_missing_target VALUES (8, 4, 'CCCC', 'I') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO test_missing_target VALUES (9, 4, 'CCCC', 'j') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +-- w/ existing GROUP BY target +SELECT c, count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY c +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- w/o existing GROUP BY target using a relation name in GROUP BY clause +SELECT count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY c +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- w/o existing GROUP BY target and w/o existing a different ORDER BY target +-- failure expected +SELECT count(*) FROM test_missing_target GROUP BY a ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 015 +-- w/o existing GROUP BY target and w/o existing same ORDER BY target +SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- w/ existing GROUP BY target using a relation name in target +SELECT test_missing_target.b, count(*) + FROM test_missing_target GROUP BY b ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- w/o existing GROUP BY target +SELECT c FROM test_missing_target ORDER BY a +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +STMT: SelectStmt +== 018 +-- w/o existing ORDER BY target +SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b desc +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- group using reference number +SELECT count(*) FROM test_missing_target ORDER BY 1 desc +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 020 +-- order using reference number +SELECT c, count(*) FROM test_missing_target GROUP BY 1 ORDER BY 1 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 021 +-- group using reference number out of range +-- failure expected +SELECT c, count(*) FROM test_missing_target GROUP BY 3 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- group w/o existing GROUP BY and ORDER BY target under ambiguous condition +-- failure expected +SELECT count(*) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY b ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +== 023 +-- order w/ target under ambiguous condition +-- failure NOT expected +SELECT a, a FROM test_missing_target + ORDER BY a +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +STMT: SelectStmt +== 024 +-- order expression w/ target under ambiguous condition +-- failure NOT expected +SELECT a/2, a/2 FROM test_missing_target + ORDER BY a/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +STMT: SelectStmt +== 025 +-- group expression w/ target under ambiguous condition +-- failure NOT expected +SELECT a/2, a/2 FROM test_missing_target + GROUP BY a/2 ORDER BY a/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +STMT: SelectStmt +== 026 +-- group w/ existing GROUP BY target under ambiguous condition +SELECT x.b, count(*) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b ORDER BY x.b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +== 027 +-- group w/o existing GROUP BY target under ambiguous condition +SELECT count(*) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b ORDER BY x.b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +== 028 +-- group w/o existing GROUP BY target under ambiguous condition +-- into a table +CREATE TABLE test_missing_target2 AS +SELECT count(*) +FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b ORDER BY x.b +-- +TABLE: name="test_missing_target2" schema="" table="test_missing_target2" ctx=DDL +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 029 +SELECT * FROM test_missing_target2 +-- +TABLE: name="test_missing_target2" schema="" table="test_missing_target2" ctx=Select +STMT: SelectStmt +== 030 +-- Functions and expressions + +-- w/ existing GROUP BY target +SELECT a%2, count(b) FROM test_missing_target +GROUP BY test_missing_target.a%2 +ORDER BY test_missing_target.a%2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- w/o existing GROUP BY target using a relation name in GROUP BY clause +SELECT count(c) FROM test_missing_target +GROUP BY lower(test_missing_target.c) +ORDER BY lower(test_missing_target.c) +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 032 +-- w/o existing GROUP BY target and w/o existing a different ORDER BY target +-- failure expected +SELECT count(a) FROM test_missing_target GROUP BY a ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 033 +-- w/o existing GROUP BY target and w/o existing same ORDER BY target +SELECT count(b) FROM test_missing_target GROUP BY b/2 ORDER BY b/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 034 +-- w/ existing GROUP BY target using a relation name in target +SELECT lower(test_missing_target.c), count(c) + FROM test_missing_target GROUP BY lower(c) ORDER BY lower(c) +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 035 +-- w/o existing GROUP BY target +SELECT a FROM test_missing_target ORDER BY upper(d) +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- w/o existing ORDER BY target +SELECT count(b) FROM test_missing_target + GROUP BY (b + 1) / 2 ORDER BY (b + 1) / 2 desc +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- group w/o existing GROUP BY and ORDER BY target under ambiguous condition +-- failure expected +SELECT count(x.a) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY b/2 ORDER BY b/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +== 038 +-- group w/ existing GROUP BY target under ambiguous condition +SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b/2 ORDER BY x.b/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +== 039 +-- group w/o existing GROUP BY target under ambiguous condition +-- failure expected due to ambiguous b in count(b) +SELECT count(b) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +== 040 +-- group w/o existing GROUP BY target under ambiguous condition +-- into a table +CREATE TABLE test_missing_target3 AS +SELECT count(x.b) +FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b/2 ORDER BY x.b/2 +-- +TABLE: name="test_missing_target3" schema="" table="test_missing_target3" ctx=DDL +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 041 +SELECT * FROM test_missing_target3 +-- +TABLE: name="test_missing_target3" schema="" table="test_missing_target3" ctx=Select +STMT: SelectStmt +== 042 +-- Cleanup +DROP TABLE test_missing_target +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DDL +STMT: DropStmt +== 043 +DROP TABLE test_missing_target2 +-- +TABLE: name="test_missing_target2" schema="" table="test_missing_target2" ctx=DDL +STMT: DropStmt +== 044 +DROP TABLE test_missing_target3 +-- +TABLE: name="test_missing_target3" schema="" table="test_missing_target3" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/select_into.metadata.json b/parser/testdata/summary/postgres_regress/select_into.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_into.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/select_into.test b/parser/testdata/summary/postgres_regress/select_into.test new file mode 100644 index 0000000..c93e453 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_into.test @@ -0,0 +1,449 @@ +== 001 +|-- +-- SELECT_INTO +|-- + +SELECT * + INTO TABLE sitmp1 + FROM onek + WHERE onek.unique1 < 2 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="sitmp1" schema="" table="sitmp1" ctx=DDL +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +== 002 +DROP TABLE sitmp1 +-- +TABLE: name="sitmp1" schema="" table="sitmp1" ctx=DDL +STMT: DropStmt +== 003 +SELECT * + INTO TABLE sitmp1 + FROM onek2 + WHERE onek2.unique1 < 2 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +TABLE: name="sitmp1" schema="" table="sitmp1" ctx=DDL +FILTER: schema="" table="onek2" column="unique1" +STMT: SelectStmt +== 004 +DROP TABLE sitmp1 +-- +TABLE: name="sitmp1" schema="" table="sitmp1" ctx=DDL +STMT: DropStmt +== 005 +|-- +-- SELECT INTO and INSERT permission, if owner is not allowed to insert. +|-- +CREATE SCHEMA selinto_schema +-- +STMT: CreateSchemaStmt +== 006 +CREATE USER regress_selinto_user +-- +STMT: CreateRoleStmt +== 007 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_selinto_user + REVOKE INSERT ON TABLES FROM regress_selinto_user +-- +STMT: AlterDefaultPrivilegesStmt +== 008 +GRANT ALL ON SCHEMA selinto_schema TO public +-- +STMT: GrantStmt +== 009 +SET SESSION AUTHORIZATION regress_selinto_user +-- +STMT: VariableSetStmt +== 010 +-- WITH DATA, passes. +CREATE TABLE selinto_schema.tbl_withdata1 (a) + AS SELECT generate_series(1,3) WITH DATA +-- +TABLE: name="selinto_schema.tbl_withdata1" schema="selinto_schema" table="tbl_withdata1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 011 +INSERT INTO selinto_schema.tbl_withdata1 VALUES (4) +-- +TABLE: name="selinto_schema.tbl_withdata1" schema="selinto_schema" table="tbl_withdata1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE selinto_schema.tbl_withdata2 (a) AS + SELECT generate_series(1,3) WITH DATA +-- +TABLE: name="selinto_schema.tbl_withdata2" schema="selinto_schema" table="tbl_withdata2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 013 +-- WITH NO DATA, passes. +CREATE TABLE selinto_schema.tbl_nodata1 (a) AS + SELECT generate_series(1,3) WITH NO DATA +-- +TABLE: name="selinto_schema.tbl_nodata1" schema="selinto_schema" table="tbl_nodata1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 014 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE selinto_schema.tbl_nodata2 (a) AS + SELECT generate_series(1,3) WITH NO DATA +-- +TABLE: name="selinto_schema.tbl_nodata2" schema="selinto_schema" table="tbl_nodata2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 015 +-- EXECUTE and WITH DATA, passes. +PREPARE data_sel AS SELECT generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 016 +CREATE TABLE selinto_schema.tbl_withdata3 (a) AS + EXECUTE data_sel WITH DATA +-- +TABLE: name="selinto_schema.tbl_withdata3" schema="selinto_schema" table="tbl_withdata3" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 017 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE selinto_schema.tbl_withdata4 (a) AS + EXECUTE data_sel WITH DATA +-- +TABLE: name="selinto_schema.tbl_withdata4" schema="selinto_schema" table="tbl_withdata4" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 018 +-- EXECUTE and WITH NO DATA, passes. +CREATE TABLE selinto_schema.tbl_nodata3 (a) AS + EXECUTE data_sel WITH NO DATA +-- +TABLE: name="selinto_schema.tbl_nodata3" schema="selinto_schema" table="tbl_nodata3" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 019 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE selinto_schema.tbl_nodata4 (a) AS + EXECUTE data_sel WITH NO DATA +-- +TABLE: name="selinto_schema.tbl_nodata4" schema="selinto_schema" table="tbl_nodata4" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 020 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 021 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_selinto_user + GRANT INSERT ON TABLES TO regress_selinto_user +-- +STMT: AlterDefaultPrivilegesStmt +== 022 +SET SESSION AUTHORIZATION regress_selinto_user +-- +STMT: VariableSetStmt +== 023 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 024 +DEALLOCATE data_sel +-- +STMT: DeallocateStmt +== 025 +DROP SCHEMA selinto_schema CASCADE +-- +STMT: DropStmt +== 026 +DROP USER regress_selinto_user +-- +STMT: DropRoleStmt +== 027 +-- Tests for WITH NO DATA and column name consistency +CREATE TABLE ctas_base (i int, j int) +-- +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=DDL +STMT: CreateStmt +== 028 +INSERT INTO ctas_base VALUES (1, 2) +-- +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +CREATE TABLE ctas_nodata (ii, jj, kk) AS SELECT i, j FROM ctas_base +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 030 +-- Error +CREATE TABLE ctas_nodata (ii, jj, kk) AS SELECT i, j FROM ctas_base WITH NO DATA +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 031 +-- Error +CREATE TABLE ctas_nodata (ii, jj) AS SELECT i, j FROM ctas_base +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 032 +-- OK +CREATE TABLE ctas_nodata_2 (ii, jj) AS SELECT i, j FROM ctas_base WITH NO DATA +-- +TABLE: name="ctas_nodata_2" schema="" table="ctas_nodata_2" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 033 +-- OK +CREATE TABLE ctas_nodata_3 (ii) AS SELECT i, j FROM ctas_base +-- +TABLE: name="ctas_nodata_3" schema="" table="ctas_nodata_3" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 034 +-- OK +CREATE TABLE ctas_nodata_4 (ii) AS SELECT i, j FROM ctas_base WITH NO DATA +-- +TABLE: name="ctas_nodata_4" schema="" table="ctas_nodata_4" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 035 +-- OK +SELECT * FROM ctas_nodata +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=Select +STMT: SelectStmt +== 036 +SELECT * FROM ctas_nodata_2 +-- +TABLE: name="ctas_nodata_2" schema="" table="ctas_nodata_2" ctx=Select +STMT: SelectStmt +== 037 +SELECT * FROM ctas_nodata_3 +-- +TABLE: name="ctas_nodata_3" schema="" table="ctas_nodata_3" ctx=Select +STMT: SelectStmt +== 038 +SELECT * FROM ctas_nodata_4 +-- +TABLE: name="ctas_nodata_4" schema="" table="ctas_nodata_4" ctx=Select +STMT: SelectStmt +== 039 +DROP TABLE ctas_base +-- +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=DDL +STMT: DropStmt +== 040 +DROP TABLE ctas_nodata +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=DDL +STMT: DropStmt +== 041 +DROP TABLE ctas_nodata_2 +-- +TABLE: name="ctas_nodata_2" schema="" table="ctas_nodata_2" ctx=DDL +STMT: DropStmt +== 042 +DROP TABLE ctas_nodata_3 +-- +TABLE: name="ctas_nodata_3" schema="" table="ctas_nodata_3" ctx=DDL +STMT: DropStmt +== 043 +DROP TABLE ctas_nodata_4 +-- +TABLE: name="ctas_nodata_4" schema="" table="ctas_nodata_4" ctx=DDL +STMT: DropStmt +== 044 +|-- +-- CREATE TABLE AS/SELECT INTO as last command in a SQL function +-- have been known to cause problems +|-- +CREATE FUNCTION make_table() RETURNS VOID +AS $$ + CREATE TABLE created_table AS SELECT * FROM int8_tbl; +$$ LANGUAGE SQL +-- +FUNCTION: name="make_table" function="make_table" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 045 +SELECT make_table() +-- +FUNCTION: name="make_table" function="make_table" schema="" ctx=Call +STMT: SelectStmt +== 046 +SELECT * FROM created_table +-- +TABLE: name="created_table" schema="" table="created_table" ctx=Select +STMT: SelectStmt +== 047 +-- Try EXPLAIN ANALYZE SELECT INTO and EXPLAIN ANALYZE CREATE TABLE AS +-- WITH NO DATA, but hide the outputs since they won't be stable. +DO $$ +BEGIN + EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl'; + EXECUTE 'EXPLAIN ANALYZE CREATE TABLE easi2 AS SELECT * FROM int8_tbl WITH NO DATA'; +END$$ +-- +STMT: DoStmt +== 048 +DROP TABLE created_table +-- +TABLE: name="created_table" schema="" table="created_table" ctx=DDL +STMT: DropStmt +== 049 +DROP TABLE easi, easi2 +-- +TABLE: name="easi" schema="" table="easi" ctx=DDL +TABLE: name="easi2" schema="" table="easi2" ctx=DDL +STMT: DropStmt +== 050 +|-- +-- Disallowed uses of SELECT ... INTO. All should fail +|-- +DECLARE foo CURSOR FOR SELECT 1 INTO int4_tbl +-- +STMT: DeclareCursorStmt +== 051 +COPY (SELECT 1 INTO frak UNION SELECT 2) TO 'blob' +-- +TABLE: name="frak" schema="" table="frak" ctx=DDL +STMT: CopyStmt +== 052 +SELECT * FROM (SELECT 1 INTO f) bar +-- +TABLE: name="f" schema="" table="f" ctx=DDL +STMT: SelectStmt +== 053 +CREATE VIEW foo AS SELECT 1 INTO int4_tbl +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 054 +INSERT INTO int4_tbl SELECT 1 INTO f +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +TABLE: name="f" schema="" table="f" ctx=DDL +STMT: InsertStmt +STMT: SelectStmt +== 055 +-- Test CREATE TABLE AS ... IF NOT EXISTS +CREATE TABLE ctas_ine_tbl AS SELECT 1 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 056 +CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 057 +-- error +CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 058 +-- ok +CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 059 +-- error +CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 060 +-- ok +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 061 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 062 +-- ok +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 063 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 064 +-- ok +PREPARE ctas_ine_query AS SELECT 1 / 0 +-- +STMT: PrepareStmt +STMT: SelectStmt +== 065 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE ctas_ine_tbl AS EXECUTE ctas_ine_query +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 066 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS EXECUTE ctas_ine_query +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 067 +-- ok +DROP TABLE ctas_ine_tbl +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/select_parallel.metadata.json b/parser/testdata/summary/postgres_regress/select_parallel.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_parallel.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/select_parallel.test b/parser/testdata/summary/postgres_regress/select_parallel.test new file mode 100644 index 0000000..7ee0734 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_parallel.test @@ -0,0 +1,1540 @@ +== 001 +|-- +-- PARALLEL +|-- + +create function sp_parallel_restricted(int) returns int as + $$begin return $1; end$$ language plpgsql parallel restricted +-- +FUNCTION: name="sp_parallel_restricted" function="sp_parallel_restricted" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +begin +-- +STMT: TransactionStmt +== 003 +-- encourage use of parallel plans +set parallel_setup_cost=0 +-- +STMT: VariableSetStmt +== 004 +set parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +== 005 +set min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +== 006 +set max_parallel_workers_per_gather=4 +-- +STMT: VariableSetStmt +== 007 +-- Parallel Append with partial-subplans +explain (costs off) + select round(avg(aa)), sum(aa) from a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 008 +select round(avg(aa)), sum(aa) from a_star a1 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "a1"="a_star" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 009 +-- Parallel Append with both partial and non-partial subplans +alter table c_star set (parallel_workers = 0) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DDL +STMT: AlterTableStmt +== 010 +alter table d_star set (parallel_workers = 0) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DDL +STMT: AlterTableStmt +== 011 +explain (costs off) + select round(avg(aa)), sum(aa) from a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 012 +select round(avg(aa)), sum(aa) from a_star a2 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "a2"="a_star" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- Parallel Append with only non-partial subplans +alter table a_star set (parallel_workers = 0) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: AlterTableStmt +== 014 +alter table b_star set (parallel_workers = 0) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DDL +STMT: AlterTableStmt +== 015 +alter table e_star set (parallel_workers = 0) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: AlterTableStmt +== 016 +alter table f_star set (parallel_workers = 0) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: AlterTableStmt +== 017 +explain (costs off) + select round(avg(aa)), sum(aa) from a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 018 +select round(avg(aa)), sum(aa) from a_star a3 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "a3"="a_star" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- Disable Parallel Append +alter table a_star reset (parallel_workers) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: AlterTableStmt +== 020 +alter table b_star reset (parallel_workers) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DDL +STMT: AlterTableStmt +== 021 +alter table c_star reset (parallel_workers) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DDL +STMT: AlterTableStmt +== 022 +alter table d_star reset (parallel_workers) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DDL +STMT: AlterTableStmt +== 023 +alter table e_star reset (parallel_workers) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: AlterTableStmt +== 024 +alter table f_star reset (parallel_workers) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: AlterTableStmt +== 025 +set enable_parallel_append to off +-- +STMT: VariableSetStmt +== 026 +explain (costs off) + select round(avg(aa)), sum(aa) from a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 027 +select round(avg(aa)), sum(aa) from a_star a4 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "a4"="a_star" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 028 +reset enable_parallel_append +-- +STMT: VariableSetStmt +== 029 +-- Parallel Append that runs serially +create function sp_test_func() returns setof text as +$$ select 'foo'::varchar union all select 'bar'::varchar $$ +language sql stable +-- +FUNCTION: name="sp_test_func" function="sp_test_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 030 +select sp_test_func() order by 1 +-- +FUNCTION: name="sp_test_func" function="sp_test_func" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- Parallel Append is not to be used when the subpath depends on the outer param +create table part_pa_test(a int, b int) partition by range(a) +-- +TABLE: name="part_pa_test" schema="" table="part_pa_test" ctx=DDL +STMT: CreateStmt +== 032 +create table part_pa_test_p1 partition of part_pa_test for values from (minvalue) to (0) +-- +TABLE: name="part_pa_test_p1" schema="" table="part_pa_test_p1" ctx=DDL +STMT: CreateStmt +== 033 +create table part_pa_test_p2 partition of part_pa_test for values from (0) to (maxvalue) +-- +TABLE: name="part_pa_test_p2" schema="" table="part_pa_test_p2" ctx=DDL +STMT: CreateStmt +== 034 +explain (costs off) + select (select max((select pa1.b from part_pa_test pa1 where pa1.a = pa2.a))) + from part_pa_test pa2 +-- +TABLE: name="part_pa_test" schema="" table="part_pa_test" ctx=Select +TABLE: name="part_pa_test" schema="" table="part_pa_test" ctx=Select +ALIAS: "pa1"="part_pa_test" +ALIAS: "pa2"="part_pa_test" +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="pa1" column="a" +FILTER: schema="" table="pa2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 035 +drop table part_pa_test +-- +TABLE: name="part_pa_test" schema="" table="part_pa_test" ctx=DDL +STMT: DropStmt +== 036 +-- test with leader participation disabled +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 037 +explain (costs off) + select count(*) from tenk1 where stringu1 = 'GRAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 038 +select count(*) from tenk1 where stringu1 = 'GRAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 039 +-- test with leader participation disabled, but no workers available (so +-- the leader will have to run the plan despite the setting) +set max_parallel_workers = 0 +-- +STMT: VariableSetStmt +== 040 +explain (costs off) + select count(*) from tenk1 where stringu1 = 'GRAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 041 +select count(*) from tenk1 where stringu1 = 'GRAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +== 042 +reset max_parallel_workers +-- +STMT: VariableSetStmt +== 043 +reset parallel_leader_participation +-- +STMT: VariableSetStmt +== 044 +-- test that parallel_restricted function doesn't run in worker +alter table tenk1 set (parallel_workers = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: AlterTableStmt +== 045 +explain (verbose, costs off) +select sp_parallel_restricted(unique1) from tenk1 + where stringu1 = 'GRAAAA' order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sp_parallel_restricted" function="sp_parallel_restricted" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 046 +-- test parallel plan when group by expression is in target list. +explain (costs off) + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 047 +select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 048 +explain (costs off) + select stringu1, count(*) from tenk1 group by stringu1 order by stringu1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 049 +-- test that parallel plan for aggregates is not selected when +-- target list contains parallel restricted clause. +explain (costs off) + select sum(sp_parallel_restricted(unique1)) from tenk1 + group by(sp_parallel_restricted(unique1)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sp_parallel_restricted" function="sp_parallel_restricted" schema="" ctx=Call +FUNCTION: name="sp_parallel_restricted" function="sp_parallel_restricted" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 050 +-- test prepared statement +prepare tenk1_count(integer) As select count((unique1)) from tenk1 where hundred > $1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: PrepareStmt +STMT: SelectStmt +== 051 +explain (costs off) execute tenk1_count(1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 052 +execute tenk1_count(1) +-- +STMT: ExecuteStmt +== 053 +deallocate tenk1_count +-- +STMT: DeallocateStmt +== 054 +-- test parallel plans for queries containing un-correlated subplans. +alter table tenk2 set (parallel_workers = 0) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +== 055 +explain (costs off) + select count(*) from tenk1 where (two, four) not in + (select hundred, thousand from tenk2 where thousand > 100) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="two" +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 056 +select count(*) from tenk1 where (two, four) not in + (select hundred, thousand from tenk2 where thousand > 100) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="two" +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 057 +-- this is not parallel-safe due to use of random() within SubLink's testexpr: +explain (costs off) + select * from tenk1 where (unique1 + random())::integer not in + (select ten from tenk2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 058 +alter table tenk2 reset (parallel_workers) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +== 059 +-- test parallel plan for a query containing initplan. +set enable_indexscan = off +-- +STMT: VariableSetStmt +== 060 +set enable_indexonlyscan = off +-- +STMT: VariableSetStmt +== 061 +set enable_bitmapscan = off +-- +STMT: VariableSetStmt +== 062 +alter table tenk2 set (parallel_workers = 2) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +== 063 +explain (costs off) + select count(*) from tenk1 + where tenk1.unique1 = (Select max(tenk2.unique1) from tenk2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 064 +select count(*) from tenk1 + where tenk1.unique1 = (Select max(tenk2.unique1) from tenk2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +STMT: SelectStmt +== 065 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 066 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +== 067 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 068 +alter table tenk2 reset (parallel_workers) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +== 069 +-- test parallel index scans. +set enable_seqscan to off +-- +STMT: VariableSetStmt +== 070 +set enable_bitmapscan to off +-- +STMT: VariableSetStmt +== 071 +set random_page_cost = 2 +-- +STMT: VariableSetStmt +== 072 +explain (costs off) + select count((unique1)) from tenk1 where hundred > 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 073 +select count((unique1)) from tenk1 where hundred > 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 074 +-- Parallel ScalarArrayOp index scan +explain (costs off) + select count((unique1)) from tenk1 + where hundred = any ((select array_agg(i) from generate_series(1, 100, 15) i)::int[]) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 075 +select count((unique1)) from tenk1 +where hundred = any ((select array_agg(i) from generate_series(1, 100, 15) i)::int[]) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 076 +-- test parallel index-only scans. +explain (costs off) + select count(*) from tenk1 where thousand > 95 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 077 +select count(*) from tenk1 where thousand > 95 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 078 +-- test rescan cases too +set enable_material = false +-- +STMT: VariableSetStmt +== 079 +explain (costs off) +select * from + (select count(unique1) from tenk1 where hundred > 10) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 080 +select * from + (select count(unique1) from tenk1 where hundred > 10) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +== 081 +explain (costs off) +select * from + (select count(*) from tenk1 where thousand > 99) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 082 +select * from + (select count(*) from tenk1 where thousand > 99) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +== 083 +-- test rescans for a Limit node with a parallel node beneath it. +reset enable_seqscan +-- +STMT: VariableSetStmt +== 084 +set enable_indexonlyscan to off +-- +STMT: VariableSetStmt +== 085 +set enable_indexscan to off +-- +STMT: VariableSetStmt +== 086 +alter table tenk1 set (parallel_workers = 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: AlterTableStmt +== 087 +alter table tenk2 set (parallel_workers = 1) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +== 088 +explain (costs off) +select count(*) from tenk1 + left join (select tenk2.unique1 from tenk2 order by 1 limit 1000) ss + on tenk1.unique1 < ss.unique1 + 1 + where tenk1.unique1 < 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 089 +select count(*) from tenk1 + left join (select tenk2.unique1 from tenk2 order by 1 limit 1000) ss + on tenk1.unique1 < ss.unique1 + 1 + where tenk1.unique1 < 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +STMT: SelectStmt +== 090 +--reset the value of workers for each table as it was before this test. +alter table tenk1 set (parallel_workers = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: AlterTableStmt +== 091 +alter table tenk2 reset (parallel_workers) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +== 092 +reset enable_material +-- +STMT: VariableSetStmt +== 093 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 094 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +== 095 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 096 +-- test parallel bitmap heap scan. +set enable_seqscan to off +-- +STMT: VariableSetStmt +== 097 +set enable_indexscan to off +-- +STMT: VariableSetStmt +== 098 +set enable_hashjoin to off +-- +STMT: VariableSetStmt +== 099 +set enable_mergejoin to off +-- +STMT: VariableSetStmt +== 100 +set enable_material to off +-- +STMT: VariableSetStmt +== 101 +-- test prefetching, if the platform allows it +DO $$ +BEGIN + SET effective_io_concurrency = 50; +EXCEPTION WHEN invalid_parameter_value THEN +END $$ +-- +STMT: DoStmt +== 102 +set work_mem='64kB' +-- +STMT: VariableSetStmt +== 103 +--set small work mem to force lossy pages +explain (costs off) + select count(*) from tenk1, tenk2 where tenk1.hundred > 1 and tenk2.thousand=0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="hundred" +FILTER: schema="" table="tenk2" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 104 +select count(*) from tenk1, tenk2 where tenk1.hundred > 1 and tenk2.thousand=0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="hundred" +FILTER: schema="" table="tenk2" column="thousand" +STMT: SelectStmt +== 105 +create table bmscantest (a int, t text) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: CreateStmt +== 106 +insert into bmscantest select r, 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' FROM generate_series(1,100000) r +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 107 +create index i_bmtest ON bmscantest(a) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: IndexStmt +== 108 +select count(*) from bmscantest where a>1 +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 109 +-- test accumulation of stats for parallel nodes +reset enable_seqscan +-- +STMT: VariableSetStmt +== 110 +alter table tenk2 set (parallel_workers = 0) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +== 111 +explain (analyze, timing off, summary off, costs off) + select count(*) from tenk1, tenk2 where tenk1.hundred > 1 + and tenk2.thousand=0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="hundred" +FILTER: schema="" table="tenk2" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +== 112 +alter table tenk2 reset (parallel_workers) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +== 113 +reset work_mem +-- +STMT: VariableSetStmt +== 114 +create function explain_parallel_sort_stats() returns setof text +language plpgsql as +$$ +declare ln text; +begin + for ln in + explain (analyze, timing off, summary off, costs off) + select * from + (select ten from tenk1 where ten < 100 order by ten) ss + right join (values (1),(2),(3)) v(x) on true + loop + ln := regexp_replace(ln, 'Memory: \S*', 'Memory: xxx'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_parallel_sort_stats" function="explain_parallel_sort_stats" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 115 +select * from explain_parallel_sort_stats() +-- +FUNCTION: name="explain_parallel_sort_stats" function="explain_parallel_sort_stats" schema="" ctx=Call +STMT: SelectStmt +== 116 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 117 +reset enable_hashjoin +-- +STMT: VariableSetStmt +== 118 +reset enable_mergejoin +-- +STMT: VariableSetStmt +== 119 +reset enable_material +-- +STMT: VariableSetStmt +== 120 +reset effective_io_concurrency +-- +STMT: VariableSetStmt +== 121 +drop table bmscantest +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: DropStmt +== 122 +drop function explain_parallel_sort_stats() +-- +FUNCTION: name="explain_parallel_sort_stats" function="explain_parallel_sort_stats" schema="" ctx=DDL +STMT: DropStmt +== 123 +-- test parallel merge join path. +set enable_hashjoin to off +-- +STMT: VariableSetStmt +== 124 +set enable_nestloop to off +-- +STMT: VariableSetStmt +== 125 +explain (costs off) + select count(*) from tenk1, tenk2 where tenk1.unique1 = tenk2.unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +FILTER: schema="" table="tenk2" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 126 +select count(*) from tenk1, tenk2 where tenk1.unique1 = tenk2.unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +FILTER: schema="" table="tenk2" column="unique1" +STMT: SelectStmt +== 127 +reset enable_hashjoin +-- +STMT: VariableSetStmt +== 128 +reset enable_nestloop +-- +STMT: VariableSetStmt +== 129 +-- test gather merge +set enable_hashagg = false +-- +STMT: VariableSetStmt +== 130 +explain (costs off) + select count(*) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 131 +select count(*) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 132 +--test expressions in targetlist are pushed down for gather merge +create function sp_simple_func(var1 integer) returns integer +as $$ +begin + return var1 + 10; +end; +$$ language plpgsql PARALLEL SAFE +-- +FUNCTION: name="sp_simple_func" function="sp_simple_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 133 +explain (costs off, verbose) + select ten, sp_simple_func(ten) from tenk1 where ten < 100 order by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sp_simple_func" function="sp_simple_func" schema="" ctx=Call +FILTER: schema="" table="" column="ten" +STMT: ExplainStmt +STMT: SelectStmt +== 134 +drop function sp_simple_func(integer) +-- +FUNCTION: name="sp_simple_func" function="sp_simple_func" schema="" ctx=DDL +STMT: DropStmt +== 135 +-- test handling of SRFs in targetlist (bug in 10.0) + +explain (costs off) + select count(*), generate_series(1,2) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 136 +select count(*), generate_series(1,2) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 137 +-- test gather merge with parallel leader participation disabled +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 138 +explain (costs off) + select count(*) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 139 +select count(*) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 140 +reset parallel_leader_participation +-- +STMT: VariableSetStmt +== 141 +--test rescan behavior of gather merge +set enable_material = false +-- +STMT: VariableSetStmt +== 142 +explain (costs off) +select * from + (select string4, count(unique2) + from tenk1 group by string4 order by string4) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 143 +select * from + (select string4, count(unique2) + from tenk1 group by string4 order by string4) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 144 +reset enable_material +-- +STMT: VariableSetStmt +== 145 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 146 +-- check parallelized int8 aggregate (bug #14897) +explain (costs off) +select avg(unique1::int8) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 147 +select avg(unique1::int8) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 148 +-- gather merge test with a LIMIT +explain (costs off) + select fivethous from tenk1 order by fivethous limit 4 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 149 +select fivethous from tenk1 order by fivethous limit 4 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +== 150 +-- gather merge test with 0 worker +set max_parallel_workers = 0 +-- +STMT: VariableSetStmt +== 151 +explain (costs off) + select string4 from tenk1 order by string4 limit 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 152 +select string4 from tenk1 order by string4 limit 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +== 153 +-- gather merge test with 0 workers, with parallel leader +-- participation disabled (the leader will have to run the plan +-- despite the setting) +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +== 154 +explain (costs off) + select string4 from tenk1 order by string4 limit 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 155 +select string4 from tenk1 order by string4 limit 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +== 156 +reset parallel_leader_participation +-- +STMT: VariableSetStmt +== 157 +reset max_parallel_workers +-- +STMT: VariableSetStmt +== 158 +create function parallel_safe_volatile(a int) returns int as + $$ begin return a; end; $$ parallel safe volatile language plpgsql +-- +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 159 +-- Test gather merge atop of a sort of a partial path +explain (costs off) +select * from tenk1 where four = 2 +order by four, hundred, parallel_safe_volatile(thousand) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=Call +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 160 +-- Test gather merge atop of an incremental sort a of partial path +set min_parallel_index_scan_size = 0 +-- +STMT: VariableSetStmt +== 161 +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 162 +explain (costs off) +select * from tenk1 where four = 2 +order by four, hundred, parallel_safe_volatile(thousand) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=Call +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +== 163 +reset min_parallel_index_scan_size +-- +STMT: VariableSetStmt +== 164 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 165 +-- Test GROUP BY with a gather merge path atop of a sort of a partial path +explain (costs off) +select count(*) from tenk1 +group by twenty, parallel_safe_volatile(two) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 166 +drop function parallel_safe_volatile(int) +-- +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=DDL +STMT: DropStmt +== 167 +SAVEPOINT settings +-- +STMT: TransactionStmt +== 168 +SET LOCAL debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 169 +explain (costs off) + select stringu1::int2 from tenk1 where unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 170 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +== 171 +-- exercise record typmod remapping between backends +CREATE FUNCTION make_record(n int) + RETURNS RECORD LANGUAGE plpgsql PARALLEL SAFE AS +$$ +BEGIN + RETURN CASE n + WHEN 1 THEN ROW(1) + WHEN 2 THEN ROW(1, 2) + WHEN 3 THEN ROW(1, 2, 3) + WHEN 4 THEN ROW(1, 2, 3, 4) + ELSE ROW(1, 2, 3, 4, 5) + END; +END; +$$ +-- +FUNCTION: name="make_record" function="make_record" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 172 +SAVEPOINT settings +-- +STMT: TransactionStmt +== 173 +SET LOCAL debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 174 +SELECT make_record(x) FROM (SELECT generate_series(1, 5) x) ss ORDER BY x +-- +FUNCTION: name="make_record" function="make_record" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 175 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +== 176 +DROP function make_record(n int) +-- +FUNCTION: name="make_record" function="make_record" schema="" ctx=DDL +STMT: DropStmt +== 177 +-- test the sanity of parallel query after the active role is dropped. +drop role if exists regress_parallel_worker +-- +STMT: DropRoleStmt +== 178 +create role regress_parallel_worker +-- +STMT: CreateRoleStmt +== 179 +set role regress_parallel_worker +-- +STMT: VariableSetStmt +== 180 +reset session authorization +-- +STMT: VariableSetStmt +== 181 +drop role regress_parallel_worker +-- +STMT: DropRoleStmt +== 182 +set debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 183 +select count(*) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 184 +reset debug_parallel_query +-- +STMT: VariableSetStmt +== 185 +reset role +-- +STMT: VariableSetStmt +== 186 +-- Window function calculation can't be pushed to workers. +explain (costs off, verbose) + select count(*) from tenk1 a where (unique1, two) in + (select unique1, row_number() over() from tenk1 b) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="two" +STMT: ExplainStmt +STMT: SelectStmt +== 187 +-- LIMIT/OFFSET within sub-selects can't be pushed to workers. +explain (costs off) + select * from tenk1 a where two in + (select two from tenk1 b where stringu1 like '%AAAA' limit 3) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="two" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +== 188 +-- to increase the parallel query test coverage +SAVEPOINT settings +-- +STMT: TransactionStmt +== 189 +SET LOCAL debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 190 +EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 191 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +== 192 +-- provoke error in worker +-- (make the error message long enough to require multiple bufferloads) +SAVEPOINT settings +-- +STMT: TransactionStmt +== 193 +SET LOCAL debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 194 +select (stringu1 || repeat('abcd', 5000))::int2 from tenk1 where unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 195 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +== 196 +-- test interaction with set-returning functions +SAVEPOINT settings +-- +STMT: TransactionStmt +== 197 +-- multiple subqueries under a single Gather node +-- must set parallel_setup_cost > 0 to discourage multiple Gather nodes +SET LOCAL parallel_setup_cost = 10 +-- +STMT: VariableSetStmt +== 198 +EXPLAIN (COSTS OFF) +SELECT unique1 FROM tenk1 WHERE fivethous = tenthous + 1 +UNION ALL +SELECT unique1 FROM tenk1 WHERE fivethous = tenthous + 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +== 199 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +== 200 +-- can't use multiple subqueries under a single Gather node due to initPlans +EXPLAIN (COSTS OFF) +SELECT unique1 FROM tenk1 WHERE fivethous = + (SELECT unique1 FROM tenk1 WHERE fivethous = 1 LIMIT 1) +UNION ALL +SELECT unique1 FROM tenk1 WHERE fivethous = + (SELECT unique2 FROM tenk1 WHERE fivethous = 1 LIMIT 1) +ORDER BY 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="fivethous" +STMT: ExplainStmt +STMT: SelectStmt +== 201 +-- test interaction with SRFs +SELECT * FROM information_schema.foreign_data_wrapper_options +ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.foreign_data_wrapper_options" schema="information_schema" table="foreign_data_wrapper_options" ctx=Select +STMT: SelectStmt +== 202 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT generate_series(1, two), array(select generate_series(1, two)) + FROM tenk1 ORDER BY tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 203 +-- must disallow pushing sort below gather when pathkey contains an SRF +EXPLAIN (VERBOSE, COSTS OFF) +SELECT unnest(ARRAY[]::integer[]) + 1 AS pathkey + FROM tenk1 t1 JOIN tenk1 t2 ON TRUE + ORDER BY pathkey +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 204 +-- test passing expanded-value representations to workers +CREATE FUNCTION make_some_array(int,int) returns int[] as +$$declare x int[]; + begin + x[1] := $1; + x[2] := $2; + return x; + end$$ language plpgsql parallel safe +-- +FUNCTION: name="make_some_array" function="make_some_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 205 +CREATE TABLE fooarr(f1 text, f2 int[], f3 text) +-- +TABLE: name="fooarr" schema="" table="fooarr" ctx=DDL +STMT: CreateStmt +== 206 +INSERT INTO fooarr VALUES('1', ARRAY[1,2], 'one') +-- +TABLE: name="fooarr" schema="" table="fooarr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 207 +PREPARE pstmt(text, int[]) AS SELECT * FROM fooarr WHERE f1 = $1 AND f2 = $2 +-- +TABLE: name="fooarr" schema="" table="fooarr" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: PrepareStmt +STMT: SelectStmt +== 208 +EXPLAIN (COSTS OFF) EXECUTE pstmt('1', make_some_array(1,2)) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +== 209 +EXECUTE pstmt('1', make_some_array(1,2)) +-- +STMT: ExecuteStmt +== 210 +DEALLOCATE pstmt +-- +STMT: DeallocateStmt +== 211 +-- test interaction between subquery and partial_paths +CREATE VIEW tenk1_vw_sec WITH (security_barrier) AS SELECT * FROM tenk1 +-- +TABLE: name="tenk1_vw_sec" schema="" table="tenk1_vw_sec" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 212 +EXPLAIN (COSTS OFF) +SELECT 1 FROM tenk1_vw_sec + WHERE (SELECT sum(f1) FROM int4_tbl WHERE f1 < unique1) < 100 +-- +TABLE: name="tenk1_vw_sec" schema="" table="tenk1_vw_sec" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 213 +rollback +-- +STMT: TransactionStmt +== 214 +-- test that function option SET ROLE works in parallel workers. +create role regress_parallel_worker +-- +STMT: CreateRoleStmt +== 215 +create function set_and_report_role() returns text as + $$ select current_setting('role') $$ language sql parallel safe + set role = regress_parallel_worker +-- +FUNCTION: name="set_and_report_role" function="set_and_report_role" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 216 +create function set_role_and_error(int) returns int as + $$ select 1 / $1 $$ language sql parallel safe + set role = regress_parallel_worker +-- +FUNCTION: name="set_role_and_error" function="set_role_and_error" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 217 +set debug_parallel_query = 0 +-- +STMT: VariableSetStmt +== 218 +select set_and_report_role() +-- +FUNCTION: name="set_and_report_role" function="set_and_report_role" schema="" ctx=Call +STMT: SelectStmt +== 219 +select set_role_and_error(0) +-- +FUNCTION: name="set_role_and_error" function="set_role_and_error" schema="" ctx=Call +STMT: SelectStmt +== 220 +set debug_parallel_query = 1 +-- +STMT: VariableSetStmt +== 221 +select set_and_report_role() +-- +FUNCTION: name="set_and_report_role" function="set_and_report_role" schema="" ctx=Call +STMT: SelectStmt +== 222 +select set_role_and_error(0) +-- +FUNCTION: name="set_role_and_error" function="set_role_and_error" schema="" ctx=Call +STMT: SelectStmt +== 223 +reset debug_parallel_query +-- +STMT: VariableSetStmt +== 224 +drop function set_and_report_role() +-- +FUNCTION: name="set_and_report_role" function="set_and_report_role" schema="" ctx=DDL +STMT: DropStmt +== 225 +drop function set_role_and_error(int) +-- +FUNCTION: name="set_role_and_error" function="set_role_and_error" schema="" ctx=DDL +STMT: DropStmt +== 226 +drop role regress_parallel_worker +-- +STMT: DropRoleStmt +== 227 +-- don't freeze in ParallelFinish while holding an LWLock +BEGIN +-- +STMT: TransactionStmt +== 228 +CREATE FUNCTION my_cmp (int4, int4) +RETURNS int LANGUAGE sql AS +$$ + SELECT + CASE WHEN $1 < $2 THEN -1 + WHEN $1 > $2 THEN 1 + ELSE 0 + END; +$$ +-- +FUNCTION: name="my_cmp" function="my_cmp" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 229 +CREATE TABLE parallel_hang (i int4) +-- +TABLE: name="parallel_hang" schema="" table="parallel_hang" ctx=DDL +STMT: CreateStmt +== 230 +INSERT INTO parallel_hang + (SELECT * FROM generate_series(1, 400) gs) +-- +TABLE: name="parallel_hang" schema="" table="parallel_hang" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 231 +CREATE OPERATOR CLASS int4_custom_ops FOR TYPE int4 USING btree AS + OPERATOR 1 < (int4, int4), OPERATOR 2 <= (int4, int4), + OPERATOR 3 = (int4, int4), OPERATOR 4 >= (int4, int4), + OPERATOR 5 > (int4, int4), FUNCTION 1 my_cmp(int4, int4) +-- +STMT: CreateOpClassStmt +== 232 +CREATE UNIQUE INDEX parallel_hang_idx + ON parallel_hang + USING btree (i int4_custom_ops) +-- +TABLE: name="parallel_hang" schema="" table="parallel_hang" ctx=DDL +STMT: IndexStmt +== 233 +SET debug_parallel_query = on +-- +STMT: VariableSetStmt +== 234 +DELETE FROM parallel_hang WHERE 380 <= i AND i <= 420 +-- +TABLE: name="parallel_hang" schema="" table="parallel_hang" ctx=DML +STMT: DeleteStmt +== 235 +ROLLBACK +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/select_views.metadata.json b/parser/testdata/summary/postgres_regress/select_views.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_views.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/select_views.test b/parser/testdata/summary/postgres_regress/select_views.test new file mode 100644 index 0000000..f8c677d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/select_views.test @@ -0,0 +1,449 @@ +== 001 +|-- +-- SELECT_VIEWS +-- test the views defined in CREATE_VIEWS +|-- + +SELECT * FROM street +-- +TABLE: name="street" schema="" table="street" ctx=Select +STMT: SelectStmt +== 002 +SELECT name, #thepath FROM iexit ORDER BY name COLLATE "C", 2 +-- +TABLE: name="iexit" schema="" table="iexit" ctx=Select +STMT: SelectStmt +== 003 +SELECT * FROM toyemp WHERE name = 'sharon' +-- +TABLE: name="toyemp" schema="" table="toyemp" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 004 +|-- +-- Test for Leaky view scenario +|-- +CREATE ROLE regress_alice +-- +STMT: CreateRoleStmt +== 005 +CREATE FUNCTION f_leak (text) + RETURNS bool LANGUAGE 'plpgsql' COST 0.0000001 + AS 'BEGIN RAISE NOTICE ''f_leak => %'', $1; RETURN true; END' +-- +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 006 +CREATE TABLE customer ( + cid int primary key, + name text not null, + tel text, + passwd text +) +-- +TABLE: name="customer" schema="" table="customer" ctx=DDL +STMT: CreateStmt +== 007 +CREATE TABLE credit_card ( + cid int references customer(cid), + cnum text, + climit int +) +-- +TABLE: name="credit_card" schema="" table="credit_card" ctx=DDL +STMT: CreateStmt +== 008 +CREATE TABLE credit_usage ( + cid int references customer(cid), + ymd date, + usage int +) +-- +TABLE: name="credit_usage" schema="" table="credit_usage" ctx=DDL +STMT: CreateStmt +== 009 +INSERT INTO customer + VALUES (101, 'regress_alice', '+81-12-3456-7890', 'passwd123'), + (102, 'regress_bob', '+01-234-567-8901', 'beafsteak'), + (103, 'regress_eve', '+49-8765-43210', 'hamburger') +-- +TABLE: name="customer" schema="" table="customer" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO credit_card + VALUES (101, '1111-2222-3333-4444', 4000), + (102, '5555-6666-7777-8888', 3000), + (103, '9801-2345-6789-0123', 2000) +-- +TABLE: name="credit_card" schema="" table="credit_card" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO credit_usage + VALUES (101, '2011-09-15', 120), + (101, '2011-10-05', 90), + (101, '2011-10-18', 110), + (101, '2011-10-21', 200), + (101, '2011-11-10', 80), + (102, '2011-09-22', 300), + (102, '2011-10-12', 120), + (102, '2011-10-28', 200), + (103, '2011-10-15', 480) +-- +TABLE: name="credit_usage" schema="" table="credit_usage" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +CREATE VIEW my_property_normal AS + SELECT * FROM customer WHERE name = current_user +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=DDL +TABLE: name="customer" schema="" table="customer" ctx=Select +FILTER: schema="" table="" column="name" +STMT: ViewStmt +STMT: SelectStmt +== 013 +CREATE VIEW my_property_secure WITH (security_barrier) AS + SELECT * FROM customer WHERE name = current_user +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=DDL +TABLE: name="customer" schema="" table="customer" ctx=Select +FILTER: schema="" table="" column="name" +STMT: ViewStmt +STMT: SelectStmt +== 014 +CREATE VIEW my_credit_card_normal AS + SELECT * FROM customer l NATURAL JOIN credit_card r + WHERE l.name = current_user +-- +TABLE: name="my_credit_card_normal" schema="" table="my_credit_card_normal" ctx=DDL +TABLE: name="customer" schema="" table="customer" ctx=Select +TABLE: name="credit_card" schema="" table="credit_card" ctx=Select +ALIAS: "l"="customer" +ALIAS: "r"="credit_card" +FILTER: schema="" table="l" column="name" +STMT: ViewStmt +STMT: SelectStmt +== 015 +CREATE VIEW my_credit_card_secure WITH (security_barrier) AS + SELECT * FROM customer l NATURAL JOIN credit_card r + WHERE l.name = current_user +-- +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=DDL +TABLE: name="customer" schema="" table="customer" ctx=Select +TABLE: name="credit_card" schema="" table="credit_card" ctx=Select +ALIAS: "l"="customer" +ALIAS: "r"="credit_card" +FILTER: schema="" table="l" column="name" +STMT: ViewStmt +STMT: SelectStmt +== 016 +CREATE VIEW my_credit_card_usage_normal AS + SELECT * FROM my_credit_card_secure l NATURAL JOIN credit_usage r +-- +TABLE: name="my_credit_card_usage_normal" schema="" table="my_credit_card_usage_normal" ctx=DDL +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=Select +TABLE: name="credit_usage" schema="" table="credit_usage" ctx=Select +ALIAS: "l"="my_credit_card_secure" +ALIAS: "r"="credit_usage" +STMT: ViewStmt +STMT: SelectStmt +== 017 +CREATE VIEW my_credit_card_usage_secure WITH (security_barrier) AS + SELECT * FROM my_credit_card_secure l NATURAL JOIN credit_usage r +-- +TABLE: name="my_credit_card_usage_secure" schema="" table="my_credit_card_usage_secure" ctx=DDL +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=Select +TABLE: name="credit_usage" schema="" table="credit_usage" ctx=Select +ALIAS: "l"="my_credit_card_secure" +ALIAS: "r"="credit_usage" +STMT: ViewStmt +STMT: SelectStmt +== 018 +GRANT SELECT ON my_property_normal TO public +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=DDL +STMT: GrantStmt +== 019 +GRANT SELECT ON my_property_secure TO public +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=DDL +STMT: GrantStmt +== 020 +GRANT SELECT ON my_credit_card_normal TO public +-- +TABLE: name="my_credit_card_normal" schema="" table="my_credit_card_normal" ctx=DDL +STMT: GrantStmt +== 021 +GRANT SELECT ON my_credit_card_secure TO public +-- +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=DDL +STMT: GrantStmt +== 022 +GRANT SELECT ON my_credit_card_usage_normal TO public +-- +TABLE: name="my_credit_card_usage_normal" schema="" table="my_credit_card_usage_normal" ctx=DDL +STMT: GrantStmt +== 023 +GRANT SELECT ON my_credit_card_usage_secure TO public +-- +TABLE: name="my_credit_card_usage_secure" schema="" table="my_credit_card_usage_secure" ctx=DDL +STMT: GrantStmt +== 024 +|-- +-- Run leaky view scenarios +|-- +SET SESSION AUTHORIZATION regress_alice +-- +STMT: VariableSetStmt +== 025 +|-- +-- scenario: if a qualifier with tiny-cost is given, it shall be launched +-- prior to the security policy of the view. +|-- +SELECT * FROM my_property_normal WHERE f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: SelectStmt +== 026 +EXPLAIN (COSTS OFF) SELECT * FROM my_property_normal WHERE f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: ExplainStmt +STMT: SelectStmt +== 027 +SELECT * FROM my_property_secure WHERE f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: SelectStmt +== 028 +EXPLAIN (COSTS OFF) SELECT * FROM my_property_secure WHERE f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: ExplainStmt +STMT: SelectStmt +== 029 +|-- +-- scenario: qualifiers can be pushed down if they contain leaky functions, +-- provided they aren't passed data from inside the view. +|-- +SELECT * FROM my_property_normal v + WHERE f_leak('passwd') AND f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +ALIAS: "v"="my_property_normal" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: SelectStmt +== 030 +EXPLAIN (COSTS OFF) SELECT * FROM my_property_normal v + WHERE f_leak('passwd') AND f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +ALIAS: "v"="my_property_normal" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: ExplainStmt +STMT: SelectStmt +== 031 +SELECT * FROM my_property_secure v + WHERE f_leak('passwd') AND f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +ALIAS: "v"="my_property_secure" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: SelectStmt +== 032 +EXPLAIN (COSTS OFF) SELECT * FROM my_property_secure v + WHERE f_leak('passwd') AND f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +ALIAS: "v"="my_property_secure" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: ExplainStmt +STMT: SelectStmt +== 033 +|-- +-- scenario: if a qualifier references only one-side of a particular join- +-- tree, it shall be distributed to the most deep scan plan as +-- possible as we can. +|-- +SELECT * FROM my_credit_card_normal WHERE f_leak(cnum) +-- +TABLE: name="my_credit_card_normal" schema="" table="my_credit_card_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +STMT: SelectStmt +== 034 +EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_normal WHERE f_leak(cnum) +-- +TABLE: name="my_credit_card_normal" schema="" table="my_credit_card_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +STMT: ExplainStmt +STMT: SelectStmt +== 035 +SELECT * FROM my_credit_card_secure WHERE f_leak(cnum) +-- +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +STMT: SelectStmt +== 036 +EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_secure WHERE f_leak(cnum) +-- +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +STMT: ExplainStmt +STMT: SelectStmt +== 037 +|-- +-- scenario: an external qualifier can be pushed-down by in-front-of the +-- views with "security_barrier" attribute, except for operators +-- implemented with leakproof functions. +|-- +SELECT * FROM my_credit_card_usage_normal + WHERE f_leak(cnum) AND ymd >= '2011-10-01' AND ymd < '2011-11-01' +-- +TABLE: name="my_credit_card_usage_normal" schema="" table="my_credit_card_usage_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +FILTER: schema="" table="" column="ymd" +FILTER: schema="" table="" column="ymd" +STMT: SelectStmt +== 038 +EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_normal + WHERE f_leak(cnum) AND ymd >= '2011-10-01' AND ymd < '2011-11-01' +-- +TABLE: name="my_credit_card_usage_normal" schema="" table="my_credit_card_usage_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +FILTER: schema="" table="" column="ymd" +FILTER: schema="" table="" column="ymd" +STMT: ExplainStmt +STMT: SelectStmt +== 039 +SELECT * FROM my_credit_card_usage_secure + WHERE f_leak(cnum) AND ymd >= '2011-10-01' AND ymd < '2011-11-01' +-- +TABLE: name="my_credit_card_usage_secure" schema="" table="my_credit_card_usage_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +FILTER: schema="" table="" column="ymd" +FILTER: schema="" table="" column="ymd" +STMT: SelectStmt +== 040 +EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_secure + WHERE f_leak(cnum) AND ymd >= '2011-10-01' AND ymd < '2011-11-01' +-- +TABLE: name="my_credit_card_usage_secure" schema="" table="my_credit_card_usage_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +FILTER: schema="" table="" column="ymd" +FILTER: schema="" table="" column="ymd" +STMT: ExplainStmt +STMT: SelectStmt +== 041 +|-- +-- Test for the case when security_barrier gets changed between rewriter +-- and planner stage. +|-- +PREPARE p1 AS SELECT * FROM my_property_normal WHERE f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: PrepareStmt +STMT: SelectStmt +== 042 +PREPARE p2 AS SELECT * FROM my_property_secure WHERE f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: PrepareStmt +STMT: SelectStmt +== 043 +EXECUTE p1 +-- +STMT: ExecuteStmt +== 044 +EXECUTE p2 +-- +STMT: ExecuteStmt +== 045 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 046 +ALTER VIEW my_property_normal SET (security_barrier=true) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=DDL +STMT: AlterTableStmt +== 047 +ALTER VIEW my_property_secure SET (security_barrier=false) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=DDL +STMT: AlterTableStmt +== 048 +SET SESSION AUTHORIZATION regress_alice +-- +STMT: VariableSetStmt +== 049 +EXECUTE p1 +-- +STMT: ExecuteStmt +== 050 +-- To be perform as a view with security-barrier +EXECUTE p2 +-- +STMT: ExecuteStmt +== 051 +-- To be perform as a view without security-barrier + +-- Cleanup. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 052 +DROP ROLE regress_alice +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/sequence.metadata.json b/parser/testdata/summary/postgres_regress/sequence.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sequence.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/sequence.test b/parser/testdata/summary/postgres_regress/sequence.test new file mode 100644 index 0000000..7360fb5 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sequence.test @@ -0,0 +1,1314 @@ +== 001 +|-- +-- CREATE SEQUENCE +|-- + +-- various error cases +CREATE SEQUENCE sequence_testx INCREMENT BY 0 +-- +STMT: CreateSeqStmt +== 002 +CREATE SEQUENCE sequence_testx INCREMENT BY -1 MINVALUE 20 +-- +STMT: CreateSeqStmt +== 003 +CREATE SEQUENCE sequence_testx INCREMENT BY 1 MAXVALUE -20 +-- +STMT: CreateSeqStmt +== 004 +CREATE SEQUENCE sequence_testx INCREMENT BY -1 START 10 +-- +STMT: CreateSeqStmt +== 005 +CREATE SEQUENCE sequence_testx INCREMENT BY 1 START -10 +-- +STMT: CreateSeqStmt +== 006 +CREATE SEQUENCE sequence_testx CACHE 0 +-- +STMT: CreateSeqStmt +== 007 +-- OWNED BY errors +CREATE SEQUENCE sequence_testx OWNED BY nobody +-- +STMT: CreateSeqStmt +== 008 +-- nonsense word +CREATE SEQUENCE sequence_testx OWNED BY pg_class_oid_index.oid +-- +STMT: CreateSeqStmt +== 009 +-- not a table +CREATE SEQUENCE sequence_testx OWNED BY pg_class.relname +-- +STMT: CreateSeqStmt +== 010 +-- not same schema +CREATE TABLE sequence_test_table (a int) +-- +TABLE: name="sequence_test_table" schema="" table="sequence_test_table" ctx=DDL +STMT: CreateStmt +== 011 +CREATE SEQUENCE sequence_testx OWNED BY sequence_test_table.b +-- +STMT: CreateSeqStmt +== 012 +-- wrong column +DROP TABLE sequence_test_table +-- +TABLE: name="sequence_test_table" schema="" table="sequence_test_table" ctx=DDL +STMT: DropStmt +== 013 +-- sequence data types +CREATE SEQUENCE sequence_test5 AS integer +-- +STMT: CreateSeqStmt +== 014 +CREATE SEQUENCE sequence_test6 AS smallint +-- +STMT: CreateSeqStmt +== 015 +CREATE SEQUENCE sequence_test7 AS bigint +-- +STMT: CreateSeqStmt +== 016 +CREATE SEQUENCE sequence_test8 AS integer MAXVALUE 100000 +-- +STMT: CreateSeqStmt +== 017 +CREATE SEQUENCE sequence_test9 AS integer INCREMENT BY -1 +-- +STMT: CreateSeqStmt +== 018 +CREATE SEQUENCE sequence_test10 AS integer MINVALUE -100000 START 1 +-- +STMT: CreateSeqStmt +== 019 +CREATE SEQUENCE sequence_test11 AS smallint +-- +STMT: CreateSeqStmt +== 020 +CREATE SEQUENCE sequence_test12 AS smallint INCREMENT -1 +-- +STMT: CreateSeqStmt +== 021 +CREATE SEQUENCE sequence_test13 AS smallint MINVALUE -32768 +-- +STMT: CreateSeqStmt +== 022 +CREATE SEQUENCE sequence_test14 AS smallint MAXVALUE 32767 INCREMENT -1 +-- +STMT: CreateSeqStmt +== 023 +CREATE SEQUENCE sequence_testx AS text +-- +STMT: CreateSeqStmt +== 024 +CREATE SEQUENCE sequence_testx AS nosuchtype +-- +STMT: CreateSeqStmt +== 025 +CREATE SEQUENCE sequence_testx AS smallint MAXVALUE 100000 +-- +STMT: CreateSeqStmt +== 026 +CREATE SEQUENCE sequence_testx AS smallint MINVALUE -100000 +-- +STMT: CreateSeqStmt +== 027 +ALTER SEQUENCE sequence_test5 AS smallint +-- +STMT: AlterSeqStmt +== 028 +-- success, max will be adjusted +ALTER SEQUENCE sequence_test8 AS smallint +-- +STMT: AlterSeqStmt +== 029 +-- fail, max has to be adjusted +ALTER SEQUENCE sequence_test8 AS smallint MAXVALUE 20000 +-- +STMT: AlterSeqStmt +== 030 +-- ok now +ALTER SEQUENCE sequence_test9 AS smallint +-- +STMT: AlterSeqStmt +== 031 +-- success, min will be adjusted +ALTER SEQUENCE sequence_test10 AS smallint +-- +STMT: AlterSeqStmt +== 032 +-- fail, min has to be adjusted +ALTER SEQUENCE sequence_test10 AS smallint MINVALUE -20000 +-- +STMT: AlterSeqStmt +== 033 +-- ok now + +ALTER SEQUENCE sequence_test11 AS int +-- +STMT: AlterSeqStmt +== 034 +-- max will be adjusted +ALTER SEQUENCE sequence_test12 AS int +-- +STMT: AlterSeqStmt +== 035 +-- min will be adjusted +ALTER SEQUENCE sequence_test13 AS int +-- +STMT: AlterSeqStmt +== 036 +-- min and max will be adjusted +ALTER SEQUENCE sequence_test14 AS int +-- +STMT: AlterSeqStmt +== 037 +-- min and max will be adjusted + +--- +--- test creation of SERIAL column +--- + +CREATE TABLE serialTest1 (f1 text, f2 serial) +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DDL +STMT: CreateStmt +== 038 +INSERT INTO serialTest1 VALUES ('foo') +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO serialTest1 VALUES ('bar') +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO serialTest1 VALUES ('force', 100) +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO serialTest1 VALUES ('wrong', NULL) +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +SELECT * FROM serialTest1 +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=Select +STMT: SelectStmt +== 043 +SELECT pg_get_serial_sequence('serialTest1', 'f2') +-- +FUNCTION: name="pg_get_serial_sequence" function="pg_get_serial_sequence" schema="" ctx=Call +STMT: SelectStmt +== 044 +-- test smallserial / bigserial +CREATE TABLE serialTest2 (f1 text, f2 serial, f3 smallserial, f4 serial2, + f5 bigserial, f6 serial8) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DDL +STMT: CreateStmt +== 045 +INSERT INTO serialTest2 (f1) + VALUES ('test_defaults') +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO serialTest2 (f1, f2, f3, f4, f5, f6) + VALUES ('test_max_vals', 2147483647, 32767, 32767, 9223372036854775807, + 9223372036854775807), + ('test_min_vals', -2147483648, -32768, -32768, -9223372036854775808, + -9223372036854775808) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +-- All these INSERTs should fail: +INSERT INTO serialTest2 (f1, f3) + VALUES ('bogus', -32769) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO serialTest2 (f1, f4) + VALUES ('bogus', -32769) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +INSERT INTO serialTest2 (f1, f3) + VALUES ('bogus', 32768) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO serialTest2 (f1, f4) + VALUES ('bogus', 32768) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +INSERT INTO serialTest2 (f1, f5) + VALUES ('bogus', -9223372036854775809) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO serialTest2 (f1, f6) + VALUES ('bogus', -9223372036854775809) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +INSERT INTO serialTest2 (f1, f5) + VALUES ('bogus', 9223372036854775808) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +INSERT INTO serialTest2 (f1, f6) + VALUES ('bogus', 9223372036854775808) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +SELECT * FROM serialTest2 ORDER BY f2 ASC +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=Select +STMT: SelectStmt +== 056 +SELECT nextval('serialTest2_f2_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 057 +SELECT nextval('serialTest2_f3_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 058 +SELECT nextval('serialTest2_f4_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT nextval('serialTest2_f5_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT nextval('serialTest2_f6_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 061 +-- basic sequence operations using both text and oid references +CREATE SEQUENCE sequence_test +-- +STMT: CreateSeqStmt +== 062 +CREATE SEQUENCE IF NOT EXISTS sequence_test +-- +STMT: CreateSeqStmt +== 063 +SELECT nextval('sequence_test'::text) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT nextval('sequence_test'::regclass) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 065 +SELECT currval('sequence_test'::text) +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 066 +SELECT currval('sequence_test'::regclass) +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT setval('sequence_test'::text, 32) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT nextval('sequence_test'::regclass) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT setval('sequence_test'::text, 99, false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT nextval('sequence_test'::regclass) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 071 +SELECT setval('sequence_test'::regclass, 32) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 072 +SELECT nextval('sequence_test'::text) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 073 +SELECT setval('sequence_test'::regclass, 99, false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT nextval('sequence_test'::text) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 075 +DISCARD SEQUENCES +-- +STMT: DiscardStmt +== 076 +SELECT currval('sequence_test'::regclass) +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 077 +DROP SEQUENCE sequence_test +-- +STMT: DropStmt +== 078 +-- renaming sequences +CREATE SEQUENCE foo_seq +-- +STMT: CreateSeqStmt +== 079 +ALTER TABLE foo_seq RENAME TO foo_seq_new +-- +TABLE: name="foo_seq" schema="" table="foo_seq" ctx=DDL +TABLE: name="foo_seq_new" schema="" table="foo_seq_new" ctx=DDL +STMT: RenameStmt +== 080 +SELECT * FROM foo_seq_new +-- +TABLE: name="foo_seq_new" schema="" table="foo_seq_new" ctx=Select +STMT: SelectStmt +== 081 +SELECT nextval('foo_seq_new') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 082 +SELECT nextval('foo_seq_new') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 083 +-- log_cnt can be higher if there is a checkpoint just at the right +-- time, so just test for the expected range +SELECT last_value, log_cnt IN (31, 32) AS log_cnt_ok, is_called FROM foo_seq_new +-- +TABLE: name="foo_seq_new" schema="" table="foo_seq_new" ctx=Select +STMT: SelectStmt +== 084 +DROP SEQUENCE foo_seq_new +-- +STMT: DropStmt +== 085 +-- renaming serial sequences +ALTER TABLE serialtest1_f2_seq RENAME TO serialtest1_f2_foo +-- +TABLE: name="serialtest1_f2_seq" schema="" table="serialtest1_f2_seq" ctx=DDL +TABLE: name="serialtest1_f2_foo" schema="" table="serialtest1_f2_foo" ctx=DDL +STMT: RenameStmt +== 086 +INSERT INTO serialTest1 VALUES ('more') +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +SELECT * FROM serialTest1 +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=Select +STMT: SelectStmt +== 088 +|-- +-- Check dependencies of serial and ordinary sequences +|-- +CREATE TEMP SEQUENCE myseq2 +-- +STMT: CreateSeqStmt +== 089 +CREATE TEMP SEQUENCE myseq3 +-- +STMT: CreateSeqStmt +== 090 +CREATE TEMP TABLE t1 ( + f1 serial, + f2 int DEFAULT nextval('myseq2'), + f3 int DEFAULT nextval('myseq3'::text) +) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 091 +-- Both drops should fail, but with different error messages: +DROP SEQUENCE t1_f1_seq +-- +STMT: DropStmt +== 092 +DROP SEQUENCE myseq2 +-- +STMT: DropStmt +== 093 +-- This however will work: +DROP SEQUENCE myseq3 +-- +STMT: DropStmt +== 094 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 095 +-- Fails because no longer existent: +DROP SEQUENCE t1_f1_seq +-- +STMT: DropStmt +== 096 +-- Now OK: +DROP SEQUENCE myseq2 +-- +STMT: DropStmt +== 097 +|-- +-- Alter sequence +|-- + +ALTER SEQUENCE IF EXISTS sequence_test2 RESTART WITH 24 + INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE +-- +STMT: AlterSeqStmt +== 098 +ALTER SEQUENCE serialTest1 CYCLE +-- +STMT: AlterSeqStmt +== 099 +-- error, not a sequence + +CREATE SEQUENCE sequence_test2 START WITH 32 +-- +STMT: CreateSeqStmt +== 100 +CREATE SEQUENCE sequence_test4 INCREMENT BY -1 +-- +STMT: CreateSeqStmt +== 101 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 102 +SELECT nextval('sequence_test4') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 103 +ALTER SEQUENCE sequence_test2 RESTART +-- +STMT: AlterSeqStmt +== 104 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 105 +ALTER SEQUENCE sequence_test2 RESTART WITH 0 +-- +STMT: AlterSeqStmt +== 106 +-- error +ALTER SEQUENCE sequence_test4 RESTART WITH 40 +-- +STMT: AlterSeqStmt +== 107 +-- error + +-- test CYCLE and NO CYCLE +ALTER SEQUENCE sequence_test2 RESTART WITH 24 + INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE +-- +STMT: AlterSeqStmt +== 108 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 109 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 110 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 111 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 112 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 113 +-- cycled + +ALTER SEQUENCE sequence_test2 RESTART WITH 24 + NO CYCLE +-- +STMT: AlterSeqStmt +== 114 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 115 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 116 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 117 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 118 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 119 +-- error + +ALTER SEQUENCE sequence_test2 RESTART WITH -24 START WITH -24 + INCREMENT BY -4 MINVALUE -36 MAXVALUE -5 CYCLE +-- +STMT: AlterSeqStmt +== 120 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 121 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 122 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 123 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 124 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 125 +-- cycled + +ALTER SEQUENCE sequence_test2 RESTART WITH -24 + NO CYCLE +-- +STMT: AlterSeqStmt +== 126 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 127 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 128 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 129 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 130 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 131 +-- error + +-- reset +ALTER SEQUENCE IF EXISTS sequence_test2 RESTART WITH 32 START WITH 32 + INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE +-- +STMT: AlterSeqStmt +== 132 +SELECT setval('sequence_test2', -100) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 133 +-- error +SELECT setval('sequence_test2', 100) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 134 +-- error +SELECT setval('sequence_test2', 5) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 135 +CREATE SEQUENCE sequence_test3 +-- +STMT: CreateSeqStmt +== 136 +-- not read from, to test is_called + + +-- Information schema +SELECT * FROM information_schema.sequences + WHERE sequence_name ~ ANY(ARRAY['sequence_test', 'serialtest']) + ORDER BY sequence_name ASC +-- +TABLE: name="information_schema.sequences" schema="information_schema" table="sequences" ctx=Select +FILTER: schema="" table="" column="sequence_name" +STMT: SelectStmt +== 137 +SELECT schemaname, sequencename, start_value, min_value, max_value, increment_by, cycle, cache_size, last_value +FROM pg_sequences +WHERE sequencename ~ ANY(ARRAY['sequence_test', 'serialtest']) + ORDER BY sequencename ASC +-- +TABLE: name="pg_sequences" schema="" table="pg_sequences" ctx=Select +FILTER: schema="" table="" column="sequencename" +STMT: SelectStmt +== 138 +SELECT * FROM pg_sequence_parameters('sequence_test4'::regclass) +-- +FUNCTION: name="pg_sequence_parameters" function="pg_sequence_parameters" schema="" ctx=Call +STMT: SelectStmt +== 139 +-- Test comments +COMMENT ON SEQUENCE asdf IS 'won''t work' +-- +STMT: CommentStmt +== 140 +COMMENT ON SEQUENCE sequence_test2 IS 'will work' +-- +STMT: CommentStmt +== 141 +COMMENT ON SEQUENCE sequence_test2 IS NULL +-- +STMT: CommentStmt +== 142 +-- Test lastval() +CREATE SEQUENCE seq +-- +STMT: CreateSeqStmt +== 143 +SELECT nextval('seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 144 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +== 145 +SELECT setval('seq', 99) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 146 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +== 147 +DISCARD SEQUENCES +-- +STMT: DiscardStmt +== 148 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +== 149 +CREATE SEQUENCE seq2 +-- +STMT: CreateSeqStmt +== 150 +SELECT nextval('seq2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 151 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +== 152 +DROP SEQUENCE seq2 +-- +STMT: DropStmt +== 153 +-- should fail +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +== 154 +-- unlogged sequences +-- (more tests in src/test/recovery/) +CREATE UNLOGGED SEQUENCE sequence_test_unlogged +-- +STMT: CreateSeqStmt +== 155 +ALTER SEQUENCE sequence_test_unlogged SET LOGGED +-- +TABLE: name="sequence_test_unlogged" schema="" table="sequence_test_unlogged" ctx=DDL +STMT: AlterTableStmt +== 156 +ALTER SEQUENCE sequence_test_unlogged SET UNLOGGED +-- +TABLE: name="sequence_test_unlogged" schema="" table="sequence_test_unlogged" ctx=DDL +STMT: AlterTableStmt +== 157 +DROP SEQUENCE sequence_test_unlogged +-- +STMT: DropStmt +== 158 +-- Test sequences in read-only transactions +CREATE TEMPORARY SEQUENCE sequence_test_temp1 +-- +STMT: CreateSeqStmt +== 159 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 160 +SELECT nextval('sequence_test_temp1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 161 +-- ok +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 162 +-- error +ROLLBACK +-- +STMT: TransactionStmt +== 163 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 164 +SELECT setval('sequence_test_temp1', 1) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 165 +-- ok +SELECT setval('sequence_test2', 1) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 166 +-- error +ROLLBACK +-- +STMT: TransactionStmt +== 167 +-- privileges tests + +CREATE USER regress_seq_user +-- +STMT: CreateRoleStmt +== 168 +-- nextval +BEGIN +-- +STMT: TransactionStmt +== 169 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 170 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 171 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 172 +GRANT SELECT ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 173 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 174 +ROLLBACK +-- +STMT: TransactionStmt +== 175 +BEGIN +-- +STMT: TransactionStmt +== 176 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 177 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 178 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 179 +GRANT UPDATE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 180 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 181 +ROLLBACK +-- +STMT: TransactionStmt +== 182 +BEGIN +-- +STMT: TransactionStmt +== 183 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 184 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 185 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 186 +GRANT USAGE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 187 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 188 +ROLLBACK +-- +STMT: TransactionStmt +== 189 +-- currval +BEGIN +-- +STMT: TransactionStmt +== 190 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 191 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 192 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 193 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 194 +GRANT SELECT ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 195 +SELECT currval('seq3') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 196 +ROLLBACK +-- +STMT: TransactionStmt +== 197 +BEGIN +-- +STMT: TransactionStmt +== 198 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 199 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 200 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 201 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 202 +GRANT UPDATE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 203 +SELECT currval('seq3') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 204 +ROLLBACK +-- +STMT: TransactionStmt +== 205 +BEGIN +-- +STMT: TransactionStmt +== 206 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 207 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 208 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 209 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 210 +GRANT USAGE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 211 +SELECT currval('seq3') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +== 212 +ROLLBACK +-- +STMT: TransactionStmt +== 213 +-- lastval +BEGIN +-- +STMT: TransactionStmt +== 214 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 215 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 216 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 217 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 218 +GRANT SELECT ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 219 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +== 220 +ROLLBACK +-- +STMT: TransactionStmt +== 221 +BEGIN +-- +STMT: TransactionStmt +== 222 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 223 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 224 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 225 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 226 +GRANT UPDATE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 227 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +== 228 +ROLLBACK +-- +STMT: TransactionStmt +== 229 +BEGIN +-- +STMT: TransactionStmt +== 230 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 231 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 232 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 233 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 234 +GRANT USAGE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 235 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +== 236 +ROLLBACK +-- +STMT: TransactionStmt +== 237 +-- setval +BEGIN +-- +STMT: TransactionStmt +== 238 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 239 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +== 240 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 241 +SAVEPOINT save +-- +STMT: TransactionStmt +== 242 +SELECT setval('seq3', 5) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 243 +ROLLBACK TO save +-- +STMT: TransactionStmt +== 244 +GRANT UPDATE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +== 245 +SELECT setval('seq3', 5) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +== 246 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 247 +ROLLBACK +-- +STMT: TransactionStmt +== 248 +-- ALTER SEQUENCE +BEGIN +-- +STMT: TransactionStmt +== 249 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +== 250 +ALTER SEQUENCE sequence_test2 START WITH 1 +-- +STMT: AlterSeqStmt +== 251 +ROLLBACK +-- +STMT: TransactionStmt +== 252 +-- Sequences should get wiped out as well: +DROP TABLE serialTest1, serialTest2 +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DDL +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DDL +STMT: DropStmt +== 253 +-- Make sure sequences are gone: +SELECT * FROM information_schema.sequences WHERE sequence_name IN + ('sequence_test2', 'serialtest2_f2_seq', 'serialtest2_f3_seq', + 'serialtest2_f4_seq', 'serialtest2_f5_seq', 'serialtest2_f6_seq') + ORDER BY sequence_name ASC +-- +TABLE: name="information_schema.sequences" schema="information_schema" table="sequences" ctx=Select +FILTER: schema="" table="" column="sequence_name" +STMT: SelectStmt +== 254 +DROP USER regress_seq_user +-- +STMT: DropRoleStmt +== 255 +DROP SEQUENCE seq +-- +STMT: DropStmt +== 256 +-- cache tests +CREATE SEQUENCE test_seq1 CACHE 10 +-- +STMT: CreateSeqStmt +== 257 +SELECT nextval('test_seq1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 258 +SELECT nextval('test_seq1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 259 +SELECT nextval('test_seq1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 260 +DROP SEQUENCE test_seq1 +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/spgist.metadata.json b/parser/testdata/summary/postgres_regress/spgist.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/spgist.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/spgist.test b/parser/testdata/summary/postgres_regress/spgist.test new file mode 100644 index 0000000..b531ca0 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/spgist.test @@ -0,0 +1,239 @@ +== 001 +|-- +-- Test SP-GiST indexes. +|-- +-- There are other tests to test different SP-GiST opclasses. This is for +-- testing SP-GiST code itself. + +create table spgist_point_tbl(id int4, p point) +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: CreateStmt +== 002 +create index spgist_point_idx on spgist_point_tbl using spgist(p) with (fillfactor = 75) +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: IndexStmt +== 003 +-- Test vacuum-root operation. It gets invoked when the root is also a leaf, +-- i.e. the index is very small. +insert into spgist_point_tbl (id, p) +select g, point(g*10, g*10) from generate_series(1, 10) g +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 004 +delete from spgist_point_tbl where id < 5 +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +STMT: DeleteStmt +== 005 +vacuum spgist_point_tbl +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: VacuumStmt +== 006 +-- Insert more data, to make the index a few levels deep. +insert into spgist_point_tbl (id, p) +select g, point(g*10, g*10) from generate_series(1, 10000) g +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 007 +insert into spgist_point_tbl (id, p) +select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 008 +-- To test vacuum, delete some entries from all over the index. +delete from spgist_point_tbl where id % 2 = 1 +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +STMT: DeleteStmt +== 009 +-- And also delete some concentration of values. (SP-GiST doesn't currently +-- attempt to delete pages even when they become empty, but if it did, this +-- would exercise it) +delete from spgist_point_tbl where id < 10000 +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +STMT: DeleteStmt +== 010 +vacuum spgist_point_tbl +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: VacuumStmt +== 011 +-- Test rescan paths (cf. bug #15378) +-- use box and && rather than point, so that rescan happens when the +-- traverse stack is non-empty + +create table spgist_box_tbl(id serial, b box) +-- +TABLE: name="spgist_box_tbl" schema="" table="spgist_box_tbl" ctx=DDL +STMT: CreateStmt +== 012 +insert into spgist_box_tbl(b) +select box(point(i,j),point(i+s,j+s)) + from generate_series(1,100,5) i, + generate_series(1,100,5) j, + generate_series(1,10) s +-- +TABLE: name="spgist_box_tbl" schema="" table="spgist_box_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 013 +create index spgist_box_idx on spgist_box_tbl using spgist (b) +-- +TABLE: name="spgist_box_tbl" schema="" table="spgist_box_tbl" ctx=DDL +STMT: IndexStmt +== 014 +select count(*) + from (values (point(5,5)),(point(8,8)),(point(12,12))) v(p) + where exists(select * from spgist_box_tbl b where b.b && box(v.p,v.p)) +-- +TABLE: name="spgist_box_tbl" schema="" table="spgist_box_tbl" ctx=Select +ALIAS: "b"="spgist_box_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FILTER: schema="" table="b" column="b" +FILTER: schema="" table="v" column="p" +FILTER: schema="" table="v" column="p" +STMT: SelectStmt +== 015 +-- The point opclass's choose method only uses the spgMatchNode action, +-- so the other actions are not tested by the above. Create an index using +-- text opclass, which uses the others actions. + +create table spgist_text_tbl(id int4, t text) +-- +TABLE: name="spgist_text_tbl" schema="" table="spgist_text_tbl" ctx=DDL +STMT: CreateStmt +== 016 +create index spgist_text_idx on spgist_text_tbl using spgist(t) +-- +TABLE: name="spgist_text_tbl" schema="" table="spgist_text_tbl" ctx=DDL +STMT: IndexStmt +== 017 +insert into spgist_text_tbl (id, t) +select g, 'f' || repeat('o', 100) || g from generate_series(1, 10000) g +union all +select g, 'baaaaaaaaaaaaaar' || g from generate_series(1, 1000) g +-- +TABLE: name="spgist_text_tbl" schema="" table="spgist_text_tbl" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 018 +-- Do a lot of insertions that have to split an existing node. Hopefully +-- one of these will cause the page to run out of space, causing the inner +-- tuple to be moved to another page. +insert into spgist_text_tbl (id, t) +select -g, 'f' || repeat('o', 100-g) || 'surprise' from generate_series(1, 100) g +-- +TABLE: name="spgist_text_tbl" schema="" table="spgist_text_tbl" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 019 +-- Test out-of-range fillfactor values +create index spgist_point_idx2 on spgist_point_tbl using spgist(p) with (fillfactor = 9) +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: IndexStmt +== 020 +create index spgist_point_idx2 on spgist_point_tbl using spgist(p) with (fillfactor = 101) +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: IndexStmt +== 021 +-- Modify fillfactor in existing index +alter index spgist_point_idx set (fillfactor = 90) +-- +STMT: AlterTableStmt +== 022 +reindex index spgist_point_idx +-- +STMT: ReindexStmt +== 023 +-- Test index over a domain +create domain spgist_text as varchar +-- +STMT: CreateDomainStmt +== 024 +create table spgist_domain_tbl (f1 spgist_text) +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=DDL +STMT: CreateStmt +== 025 +create index spgist_domain_idx on spgist_domain_tbl using spgist(f1) +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=DDL +STMT: IndexStmt +== 026 +insert into spgist_domain_tbl values('fee'), ('fi'), ('fo'), ('fum') +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +explain (costs off) +select * from spgist_domain_tbl where f1 = 'fo' +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 028 +select * from spgist_domain_tbl where f1 = 'fo' +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 029 +-- test an unlogged table, mostly to get coverage of spgistbuildempty +create unlogged table spgist_unlogged_tbl(id serial, b box) +-- +TABLE: name="spgist_unlogged_tbl" schema="" table="spgist_unlogged_tbl" ctx=DDL +STMT: CreateStmt +== 030 +create index spgist_unlogged_idx on spgist_unlogged_tbl using spgist (b) +-- +TABLE: name="spgist_unlogged_tbl" schema="" table="spgist_unlogged_tbl" ctx=DDL +STMT: IndexStmt +== 031 +insert into spgist_unlogged_tbl(b) +select box(point(i,j)) + from generate_series(1,100,5) i, + generate_series(1,10,5) j +-- +TABLE: name="spgist_unlogged_tbl" schema="" table="spgist_unlogged_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/sqljson.metadata.json b/parser/testdata/summary/postgres_regress/sqljson.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sqljson.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/sqljson.test b/parser/testdata/summary/postgres_regress/sqljson.test new file mode 100644 index 0000000..6d6a9e7 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sqljson.test @@ -0,0 +1,1163 @@ +== 001 +-- JSON() +SELECT JSON() +-- +ERROR: syntax error at or near ")" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +SELECT JSON(NULL) +-- +STMT: SelectStmt +== 003 +SELECT JSON('{ "a" : 1 } ') +-- +STMT: SelectStmt +== 004 +SELECT JSON('{ "a" : 1 } ' FORMAT JSON) +-- +STMT: SelectStmt +== 005 +SELECT JSON('{ "a" : 1 } ' FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 006 +SELECT JSON('{ "a" : 1 } '::bytea FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 007 +SELECT pg_typeof(JSON('{ "a" : 1 } ')) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 008 +SELECT JSON(' 1 '::json) +-- +STMT: SelectStmt +== 009 +SELECT JSON(' 1 '::jsonb) +-- +STMT: SelectStmt +== 010 +SELECT JSON(' 1 '::json WITH UNIQUE KEYS) +-- +STMT: SelectStmt +== 011 +SELECT JSON(123) +-- +STMT: SelectStmt +== 012 +SELECT JSON('{"a": 1, "a": 2}') +-- +STMT: SelectStmt +== 013 +SELECT JSON('{"a": 1, "a": 2}' WITH UNIQUE KEYS) +-- +STMT: SelectStmt +== 014 +SELECT JSON('{"a": 1, "a": 2}' WITHOUT UNIQUE KEYS) +-- +STMT: SelectStmt +== 015 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123') +-- +STMT: ExplainStmt +STMT: SelectStmt +== 016 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' FORMAT JSON) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 017 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123'::bytea FORMAT JSON) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 018 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123'::bytea FORMAT JSON ENCODING UTF8) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 019 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' WITH UNIQUE KEYS) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 020 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' WITHOUT UNIQUE KEYS) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 021 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123') +-- +STMT: ExplainStmt +STMT: SelectStmt +== 022 +SELECT pg_typeof(JSON('123')) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 023 +-- JSON_SCALAR() +SELECT JSON_SCALAR() +-- +ERROR: syntax error at or near ")" +CURSORPOS: 37 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 024 +SELECT JSON_SCALAR(NULL) +-- +STMT: SelectStmt +== 025 +SELECT JSON_SCALAR(NULL::int) +-- +STMT: SelectStmt +== 026 +SELECT JSON_SCALAR(123) +-- +STMT: SelectStmt +== 027 +SELECT JSON_SCALAR(123.45) +-- +STMT: SelectStmt +== 028 +SELECT JSON_SCALAR(123.45::numeric) +-- +STMT: SelectStmt +== 029 +SELECT JSON_SCALAR(true) +-- +STMT: SelectStmt +== 030 +SELECT JSON_SCALAR(false) +-- +STMT: SelectStmt +== 031 +SELECT JSON_SCALAR(' 123.45') +-- +STMT: SelectStmt +== 032 +SELECT JSON_SCALAR('2020-06-07'::date) +-- +STMT: SelectStmt +== 033 +SELECT JSON_SCALAR('2020-06-07 01:02:03'::timestamp) +-- +STMT: SelectStmt +== 034 +SELECT JSON_SCALAR('{}'::json) +-- +STMT: SelectStmt +== 035 +SELECT JSON_SCALAR('{}'::jsonb) +-- +STMT: SelectStmt +== 036 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR(123) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 037 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR('123') +-- +STMT: ExplainStmt +STMT: SelectStmt +== 038 +-- JSON_SERIALIZE() +SELECT JSON_SERIALIZE() +-- +ERROR: syntax error at or near ")" +CURSORPOS: 43 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 039 +SELECT JSON_SERIALIZE(NULL) +-- +STMT: SelectStmt +== 040 +SELECT JSON_SERIALIZE(JSON('{ "a" : 1 } ')) +-- +STMT: SelectStmt +== 041 +SELECT JSON_SERIALIZE('{ "a" : 1 } ') +-- +STMT: SelectStmt +== 042 +SELECT JSON_SERIALIZE('1') +-- +STMT: SelectStmt +== 043 +SELECT JSON_SERIALIZE('1' FORMAT JSON) +-- +STMT: SelectStmt +== 044 +SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING bytea) +-- +STMT: SelectStmt +== 045 +SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING varchar) +-- +STMT: SelectStmt +== 046 +SELECT pg_typeof(JSON_SERIALIZE(NULL)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- only string types or bytea allowed +SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING jsonb) +-- +STMT: SelectStmt +== 048 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}') +-- +STMT: ExplainStmt +STMT: SelectStmt +== 049 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}' RETURNING bytea) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 050 +-- JSON_OBJECT() +SELECT JSON_OBJECT() +-- +STMT: SelectStmt +== 051 +SELECT JSON_OBJECT(RETURNING json) +-- +STMT: SelectStmt +== 052 +SELECT JSON_OBJECT(RETURNING json FORMAT JSON) +-- +STMT: SelectStmt +== 053 +SELECT JSON_OBJECT(RETURNING jsonb) +-- +STMT: SelectStmt +== 054 +SELECT JSON_OBJECT(RETURNING jsonb FORMAT JSON) +-- +STMT: SelectStmt +== 055 +SELECT JSON_OBJECT(RETURNING text) +-- +STMT: SelectStmt +== 056 +SELECT JSON_OBJECT(RETURNING text FORMAT JSON) +-- +STMT: SelectStmt +== 057 +SELECT JSON_OBJECT(RETURNING text FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 058 +SELECT JSON_OBJECT(RETURNING text FORMAT JSON ENCODING INVALID_ENCODING) +-- +ERROR: unrecognized JSON encoding: invalid_encoding +FILENAME: gram.y +FUNCNAME: base_yyparse +== 059 +SELECT JSON_OBJECT(RETURNING bytea) +-- +STMT: SelectStmt +== 060 +SELECT JSON_OBJECT(RETURNING bytea FORMAT JSON) +-- +STMT: SelectStmt +== 061 +SELECT JSON_OBJECT(RETURNING bytea FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 062 +SELECT JSON_OBJECT(RETURNING bytea FORMAT JSON ENCODING UTF16) +-- +STMT: SelectStmt +== 063 +SELECT JSON_OBJECT(RETURNING bytea FORMAT JSON ENCODING UTF32) +-- +STMT: SelectStmt +== 064 +SELECT JSON_OBJECT('foo': NULL::int FORMAT JSON) +-- +STMT: SelectStmt +== 065 +SELECT JSON_OBJECT('foo': NULL::int FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 066 +SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON) +-- +STMT: SelectStmt +== 067 +SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 068 +SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON) +-- +STMT: SelectStmt +== 069 +SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 070 +SELECT JSON_OBJECT(NULL: 1) +-- +STMT: SelectStmt +== 071 +SELECT JSON_OBJECT('a': 2 + 3) +-- +STMT: SelectStmt +== 072 +SELECT JSON_OBJECT('a' VALUE 2 + 3) +-- +STMT: SelectStmt +== 073 +--SELECT JSON_OBJECT(KEY 'a' VALUE 2 + 3); +SELECT JSON_OBJECT('a' || 2: 1) +-- +STMT: SelectStmt +== 074 +SELECT JSON_OBJECT(('a' || 2) VALUE 1) +-- +STMT: SelectStmt +== 075 +--SELECT JSON_OBJECT('a' || 2 VALUE 1); +--SELECT JSON_OBJECT(KEY 'a' || 2 VALUE 1); +SELECT JSON_OBJECT('a': 2::text) +-- +STMT: SelectStmt +== 076 +SELECT JSON_OBJECT('a' VALUE 2::text) +-- +STMT: SelectStmt +== 077 +--SELECT JSON_OBJECT(KEY 'a' VALUE 2::text); +SELECT JSON_OBJECT(1::text: 2) +-- +STMT: SelectStmt +== 078 +SELECT JSON_OBJECT((1::text) VALUE 2) +-- +STMT: SelectStmt +== 079 +--SELECT JSON_OBJECT(1::text VALUE 2); +--SELECT JSON_OBJECT(KEY 1::text VALUE 2); +SELECT JSON_OBJECT(json '[1]': 123) +-- +STMT: SelectStmt +== 080 +SELECT JSON_OBJECT(ARRAY[1,2,3]: 'aaa') +-- +STMT: SelectStmt +== 081 +SELECT JSON_OBJECT( + 'a': '123', + 1.23: 123, + 'c': json '[ 1,true,{ } ]', + 'd': jsonb '{ "x" : 123.45 }' +) +-- +STMT: SelectStmt +== 082 +SELECT JSON_OBJECT( + 'a': '123', + 1.23: 123, + 'c': json '[ 1,true,{ } ]', + 'd': jsonb '{ "x" : 123.45 }' + RETURNING jsonb +) +-- +STMT: SelectStmt +== 083 +/* +SELECT JSON_OBJECT( + 'a': '123', + KEY 1.23 VALUE 123, + 'c' VALUE json '[1, true, {}]' +); +*/ + +SELECT JSON_OBJECT('a': '123', 'b': JSON_OBJECT('a': 111, 'b': 'aaa')) +-- +STMT: SelectStmt +== 084 +SELECT JSON_OBJECT('a': '123', 'b': JSON_OBJECT('a': 111, 'b': 'aaa' RETURNING jsonb)) +-- +STMT: SelectStmt +== 085 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING text)) +-- +STMT: SelectStmt +== 086 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING text) FORMAT JSON) +-- +STMT: SelectStmt +== 087 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING bytea)) +-- +STMT: SelectStmt +== 088 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING bytea) FORMAT JSON) +-- +STMT: SelectStmt +== 089 +SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2) +-- +STMT: SelectStmt +== 090 +SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2 NULL ON NULL) +-- +STMT: SelectStmt +== 091 +SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2 ABSENT ON NULL) +-- +STMT: SelectStmt +== 092 +SELECT JSON_OBJECT(1: 1, '2': NULL, '3': 1, repeat('x', 1000): 1, 2: repeat('a', 100) WITH UNIQUE) +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 093 +SELECT JSON_OBJECT(1: 1, '1': NULL WITH UNIQUE) +-- +STMT: SelectStmt +== 094 +SELECT JSON_OBJECT(1: 1, '1': NULL ABSENT ON NULL WITH UNIQUE) +-- +STMT: SelectStmt +== 095 +SELECT JSON_OBJECT(1: 1, '1': NULL NULL ON NULL WITH UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +== 096 +SELECT JSON_OBJECT(1: 1, '1': NULL ABSENT ON NULL WITH UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +== 097 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 NULL ON NULL WITH UNIQUE) +-- +STMT: SelectStmt +== 098 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITH UNIQUE) +-- +STMT: SelectStmt +== 099 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITHOUT UNIQUE) +-- +STMT: SelectStmt +== 100 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITH UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +== 101 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITHOUT UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +== 102 +SELECT JSON_OBJECT(1: 1, '2': NULL, '3': 1, 4: NULL, '5': 'a' ABSENT ON NULL WITH UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +== 103 +-- BUG: https://postgr.es/m/CADXhmgTJtJZK9A3Na_ry%2BXrq-ghjcejBRhcRMzWZvbd__QdgJA%40mail.gmail.com +-- datum_to_jsonb_internal() didn't catch keys that are casts instead of a simple scalar +CREATE TYPE mood AS ENUM ('happy', 'sad', 'neutral') +-- +STMT: CreateEnumStmt +== 104 +CREATE FUNCTION mood_to_json(mood) RETURNS json AS $$ + SELECT to_json($1::text); +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="mood_to_json" function="mood_to_json" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 105 +CREATE CAST (mood AS json) WITH FUNCTION mood_to_json(mood) AS IMPLICIT +-- +STMT: CreateCastStmt +== 106 +SELECT JSON_OBJECT('happy'::mood: '123'::jsonb) +-- +STMT: SelectStmt +== 107 +DROP CAST (mood AS json) +-- +STMT: DropStmt +== 108 +DROP FUNCTION mood_to_json +-- +FUNCTION: name="mood_to_json" function="mood_to_json" schema="" ctx=DDL +STMT: DropStmt +== 109 +DROP TYPE mood +-- +STMT: DropStmt +== 110 +-- JSON_ARRAY() +SELECT JSON_ARRAY() +-- +STMT: SelectStmt +== 111 +SELECT JSON_ARRAY(RETURNING json) +-- +STMT: SelectStmt +== 112 +SELECT JSON_ARRAY(RETURNING json FORMAT JSON) +-- +STMT: SelectStmt +== 113 +SELECT JSON_ARRAY(RETURNING jsonb) +-- +STMT: SelectStmt +== 114 +SELECT JSON_ARRAY(RETURNING jsonb FORMAT JSON) +-- +STMT: SelectStmt +== 115 +SELECT JSON_ARRAY(RETURNING text) +-- +STMT: SelectStmt +== 116 +SELECT JSON_ARRAY(RETURNING text FORMAT JSON) +-- +STMT: SelectStmt +== 117 +SELECT JSON_ARRAY(RETURNING text FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 118 +SELECT JSON_ARRAY(RETURNING text FORMAT JSON ENCODING INVALID_ENCODING) +-- +ERROR: unrecognized JSON encoding: invalid_encoding +FILENAME: gram.y +FUNCNAME: base_yyparse +== 119 +SELECT JSON_ARRAY(RETURNING bytea) +-- +STMT: SelectStmt +== 120 +SELECT JSON_ARRAY(RETURNING bytea FORMAT JSON) +-- +STMT: SelectStmt +== 121 +SELECT JSON_ARRAY(RETURNING bytea FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +== 122 +SELECT JSON_ARRAY(RETURNING bytea FORMAT JSON ENCODING UTF16) +-- +STMT: SelectStmt +== 123 +SELECT JSON_ARRAY(RETURNING bytea FORMAT JSON ENCODING UTF32) +-- +STMT: SelectStmt +== 124 +SELECT JSON_ARRAY('aaa', 111, true, array[1,2,3], NULL, json '{"a": [1]}', jsonb '["a",3]') +-- +STMT: SelectStmt +== 125 +SELECT JSON_ARRAY('a', NULL, 'b' NULL ON NULL) +-- +STMT: SelectStmt +== 126 +SELECT JSON_ARRAY('a', NULL, 'b' ABSENT ON NULL) +-- +STMT: SelectStmt +== 127 +SELECT JSON_ARRAY(NULL, NULL, 'b' ABSENT ON NULL) +-- +STMT: SelectStmt +== 128 +SELECT JSON_ARRAY('a', NULL, 'b' NULL ON NULL RETURNING jsonb) +-- +STMT: SelectStmt +== 129 +SELECT JSON_ARRAY('a', NULL, 'b' ABSENT ON NULL RETURNING jsonb) +-- +STMT: SelectStmt +== 130 +SELECT JSON_ARRAY(NULL, NULL, 'b' ABSENT ON NULL RETURNING jsonb) +-- +STMT: SelectStmt +== 131 +SELECT JSON_ARRAY(JSON_ARRAY('{ "a" : 123 }' RETURNING text)) +-- +STMT: SelectStmt +== 132 +SELECT JSON_ARRAY(JSON_ARRAY('{ "a" : 123 }' FORMAT JSON RETURNING text)) +-- +STMT: SelectStmt +== 133 +SELECT JSON_ARRAY(JSON_ARRAY('{ "a" : 123 }' FORMAT JSON RETURNING text) FORMAT JSON) +-- +STMT: SelectStmt +== 134 +SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL), (4)) foo(i)) +-- +STMT: SelectStmt +== 135 +SELECT JSON_ARRAY(SELECT i FROM (VALUES (NULL::int[]), ('{1,2}'), (NULL), (NULL), ('{3,4}'), (NULL)) foo(i)) +-- +STMT: SelectStmt +== 136 +SELECT JSON_ARRAY(SELECT i FROM (VALUES (NULL::int[]), ('{1,2}'), (NULL), (NULL), ('{3,4}'), (NULL)) foo(i) RETURNING jsonb) +-- +STMT: SelectStmt +== 137 +--SELECT JSON_ARRAY(SELECT i FROM (VALUES (NULL::int[]), ('{1,2}'), (NULL), (NULL), ('{3,4}'), (NULL)) foo(i) NULL ON NULL); +--SELECT JSON_ARRAY(SELECT i FROM (VALUES (NULL::int[]), ('{1,2}'), (NULL), (NULL), ('{3,4}'), (NULL)) foo(i) NULL ON NULL RETURNING jsonb); +SELECT JSON_ARRAY(SELECT i FROM (VALUES (3), (1), (NULL), (2)) foo(i) ORDER BY i) +-- +STMT: SelectStmt +== 138 +SELECT JSON_ARRAY(WITH x AS (SELECT 1) VALUES (TRUE)) +-- +CTE: "x" +STMT: SelectStmt +== 139 +-- Should fail +SELECT JSON_ARRAY(SELECT FROM (VALUES (1)) foo(i)) +-- +STMT: SelectStmt +== 140 +SELECT JSON_ARRAY(SELECT i, i FROM (VALUES (1)) foo(i)) +-- +STMT: SelectStmt +== 141 +SELECT JSON_ARRAY(SELECT * FROM (VALUES (1, 2)) foo(i, j)) +-- +STMT: SelectStmt +== 142 +-- JSON_ARRAYAGG() +SELECT JSON_ARRAYAGG(i) IS NULL, + JSON_ARRAYAGG(i RETURNING jsonb) IS NULL +FROM generate_series(1, 0) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 143 +SELECT JSON_ARRAYAGG(i), + JSON_ARRAYAGG(i RETURNING jsonb) +FROM generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 144 +SELECT JSON_ARRAYAGG(i ORDER BY i DESC) +FROM generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 145 +SELECT JSON_ARRAYAGG(i::text::json) +FROM generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 146 +SELECT JSON_ARRAYAGG(JSON_ARRAY(i, i + 1 RETURNING text) FORMAT JSON) +FROM generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 147 +SELECT JSON_ARRAYAGG(NULL), + JSON_ARRAYAGG(NULL RETURNING jsonb) +FROM generate_series(1, 5) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 148 +SELECT JSON_ARRAYAGG(NULL NULL ON NULL), + JSON_ARRAYAGG(NULL NULL ON NULL RETURNING jsonb) +FROM generate_series(1, 5) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 149 +SELECT + JSON_ARRAYAGG(bar) as no_options, + JSON_ARRAYAGG(bar RETURNING jsonb) as returning_jsonb, + JSON_ARRAYAGG(bar ABSENT ON NULL) as absent_on_null, + JSON_ARRAYAGG(bar ABSENT ON NULL RETURNING jsonb) as absentonnull_returning_jsonb, + JSON_ARRAYAGG(bar NULL ON NULL) as null_on_null, + JSON_ARRAYAGG(bar NULL ON NULL RETURNING jsonb) as nullonnull_returning_jsonb, + JSON_ARRAYAGG(foo) as row_no_options, + JSON_ARRAYAGG(foo RETURNING jsonb) as row_returning_jsonb, + JSON_ARRAYAGG(foo ORDER BY bar) FILTER (WHERE bar > 2) as row_filtered_agg, + JSON_ARRAYAGG(foo ORDER BY bar RETURNING jsonb) FILTER (WHERE bar > 2) as row_filtered_agg_returning_jsonb +FROM + (VALUES (NULL), (3), (1), (NULL), (NULL), (5), (2), (4), (NULL)) foo(bar) +-- +STMT: SelectStmt +== 150 +SELECT + bar, JSON_ARRAYAGG(bar) FILTER (WHERE bar > 2) OVER (PARTITION BY foo.bar % 2) +FROM + (VALUES (NULL), (3), (1), (NULL), (NULL), (5), (2), (4), (NULL), (5), (4)) foo(bar) +-- +STMT: SelectStmt +== 151 +-- JSON_OBJECTAGG() +SELECT JSON_OBJECTAGG('key': 1) IS NULL, + JSON_OBJECTAGG('key': 1 RETURNING jsonb) IS NULL +WHERE FALSE +-- +STMT: SelectStmt +== 152 +SELECT JSON_OBJECTAGG(NULL: 1) +-- +STMT: SelectStmt +== 153 +SELECT JSON_OBJECTAGG(NULL: 1 RETURNING jsonb) +-- +STMT: SelectStmt +== 154 +SELECT + JSON_OBJECTAGG(i: i), +-- JSON_OBJECTAGG(i VALUE i), +-- JSON_OBJECTAGG(KEY i VALUE i), + JSON_OBJECTAGG(i: i RETURNING jsonb) +FROM + generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 155 +SELECT + JSON_OBJECTAGG(k: v), + JSON_OBJECTAGG(k: v NULL ON NULL), + JSON_OBJECTAGG(k: v ABSENT ON NULL), + JSON_OBJECTAGG(k: v RETURNING jsonb), + JSON_OBJECTAGG(k: v NULL ON NULL RETURNING jsonb), + JSON_OBJECTAGG(k: v ABSENT ON NULL RETURNING jsonb) +FROM + (VALUES (1, 1), (1, NULL), (2, NULL), (3, 3)) foo(k, v) +-- +STMT: SelectStmt +== 156 +SELECT JSON_OBJECTAGG(k: v WITH UNIQUE KEYS) +FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v) +-- +STMT: SelectStmt +== 157 +SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS) +FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v) +-- +STMT: SelectStmt +== 158 +SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS) +FROM (VALUES (1, 1), (0, NULL), (3, NULL), (2, 2), (4, NULL)) foo(k, v) +-- +STMT: SelectStmt +== 159 +SELECT JSON_OBJECTAGG(k: v WITH UNIQUE KEYS RETURNING jsonb) +FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v) +-- +STMT: SelectStmt +== 160 +SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING jsonb) +FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v) +-- +STMT: SelectStmt +== 161 +SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING jsonb) +FROM (VALUES (1, 1), (0, NULL),(4, null), (5, null),(6, null),(2, 2)) foo(k, v) +-- +STMT: SelectStmt +== 162 +SELECT JSON_OBJECTAGG(mod(i,100): (i)::text FORMAT JSON WITH UNIQUE) +FROM generate_series(0, 199) i +-- +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 163 +-- Test JSON_OBJECT deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_OBJECT('foo' : '1' FORMAT JSON, 'bar' : 'baz' RETURNING json) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 164 +CREATE VIEW json_object_view AS +SELECT JSON_OBJECT('foo' : '1' FORMAT JSON, 'bar' : 'baz' RETURNING json) +-- +TABLE: name="json_object_view" schema="" table="json_object_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 165 +DROP VIEW json_object_view +-- +STMT: DropStmt +== 166 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v WITH UNIQUE KEYS) OVER (ORDER BY k) +FROM (VALUES (1,1), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 167 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v WITH UNIQUE KEYS) OVER (ORDER BY k) +FROM (VALUES (1,1), (1,2), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 168 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v ABSENT ON NULL WITH UNIQUE KEYS) + OVER (ORDER BY k) +FROM (VALUES (1,1), (1,null), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 169 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v ABSENT ON NULL) +OVER (ORDER BY k) +FROM (VALUES (1,1), (1,null), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 170 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v ABSENT ON NULL) +OVER (ORDER BY k RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) +FROM (VALUES (1,1), (1,null), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +== 171 +-- Test JSON_ARRAY deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_ARRAY('1' FORMAT JSON, 2 RETURNING json) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 172 +CREATE VIEW json_array_view AS +SELECT JSON_ARRAY('1' FORMAT JSON, 2 RETURNING json) +-- +TABLE: name="json_array_view" schema="" table="json_array_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 173 +DROP VIEW json_array_view +-- +STMT: DropStmt +== 174 +-- Test JSON_OBJECTAGG deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING text) FILTER (WHERE i > 3) +FROM generate_series(1,5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 175 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING text) OVER (PARTITION BY i % 2) +FROM generate_series(1,5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 176 +CREATE VIEW json_objectagg_view AS +SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING text) FILTER (WHERE i > 3) +FROM generate_series(1,5) i +-- +TABLE: name="json_objectagg_view" schema="" table="json_objectagg_view" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 177 +DROP VIEW json_objectagg_view +-- +STMT: DropStmt +== 178 +-- Test JSON_ARRAYAGG deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RETURNING text) FILTER (WHERE i > 3) +FROM generate_series(1,5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 179 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RETURNING text) OVER (PARTITION BY i % 2) +FROM generate_series(1,5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 180 +CREATE VIEW json_arrayagg_view AS +SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RETURNING text) FILTER (WHERE i > 3) +FROM generate_series(1,5) i +-- +TABLE: name="json_arrayagg_view" schema="" table="json_arrayagg_view" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 181 +DROP VIEW json_arrayagg_view +-- +STMT: DropStmt +== 182 +-- Test JSON_ARRAY(subquery) deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL), (4)) foo(i) RETURNING jsonb) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 183 +CREATE VIEW json_array_subquery_view AS +SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL), (4)) foo(i) RETURNING jsonb) +-- +TABLE: name="json_array_subquery_view" schema="" table="json_array_subquery_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 184 +DROP VIEW json_array_subquery_view +-- +STMT: DropStmt +== 185 +-- IS JSON predicate +SELECT NULL IS JSON +-- +STMT: SelectStmt +== 186 +SELECT NULL IS NOT JSON +-- +STMT: SelectStmt +== 187 +SELECT NULL::json IS JSON +-- +STMT: SelectStmt +== 188 +SELECT NULL::jsonb IS JSON +-- +STMT: SelectStmt +== 189 +SELECT NULL::text IS JSON +-- +STMT: SelectStmt +== 190 +SELECT NULL::bytea IS JSON +-- +STMT: SelectStmt +== 191 +SELECT NULL::int IS JSON +-- +STMT: SelectStmt +== 192 +SELECT '' IS JSON +-- +STMT: SelectStmt +== 193 +SELECT bytea '\x00' IS JSON +-- +STMT: SelectStmt +== 194 +CREATE TABLE test_is_json (js text) +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=DDL +STMT: CreateStmt +== 195 +INSERT INTO test_is_json VALUES + (NULL), + (''), + ('123'), + ('"aaa "'), + ('true'), + ('null'), + ('[]'), + ('[1, "2", {}]'), + ('{}'), + ('{ "a": 1, "b": null }'), + ('{ "a": 1, "a": null }'), + ('{ "a": 1, "b": [{ "a": 1 }, { "a": 2 }] }'), + ('{ "a": 1, "b": [{ "a": 1, "b": 0, "a": 2 }] }'), + ('aaa'), + ('{a:1}'), + ('["a",]') +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 196 +SELECT + js, + js IS JSON "IS JSON", + js IS NOT JSON "IS NOT JSON", + js IS JSON VALUE "IS VALUE", + js IS JSON OBJECT "IS OBJECT", + js IS JSON ARRAY "IS ARRAY", + js IS JSON SCALAR "IS SCALAR", + js IS JSON WITHOUT UNIQUE KEYS "WITHOUT UNIQUE", + js IS JSON WITH UNIQUE KEYS "WITH UNIQUE" +FROM + test_is_json +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=Select +STMT: SelectStmt +== 197 +SELECT + js, + js IS JSON "IS JSON", + js IS NOT JSON "IS NOT JSON", + js IS JSON VALUE "IS VALUE", + js IS JSON OBJECT "IS OBJECT", + js IS JSON ARRAY "IS ARRAY", + js IS JSON SCALAR "IS SCALAR", + js IS JSON WITHOUT UNIQUE KEYS "WITHOUT UNIQUE", + js IS JSON WITH UNIQUE KEYS "WITH UNIQUE" +FROM + (SELECT js::json FROM test_is_json WHERE js IS JSON) foo(js) +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=Select +FILTER: schema="" table="" column="js" +STMT: SelectStmt +== 198 +SELECT + js0, + js IS JSON "IS JSON", + js IS NOT JSON "IS NOT JSON", + js IS JSON VALUE "IS VALUE", + js IS JSON OBJECT "IS OBJECT", + js IS JSON ARRAY "IS ARRAY", + js IS JSON SCALAR "IS SCALAR", + js IS JSON WITHOUT UNIQUE KEYS "WITHOUT UNIQUE", + js IS JSON WITH UNIQUE KEYS "WITH UNIQUE" +FROM + (SELECT js, js::bytea FROM test_is_json WHERE js IS JSON) foo(js0, js) +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=Select +FILTER: schema="" table="" column="js" +STMT: SelectStmt +== 199 +SELECT + js, + js IS JSON "IS JSON", + js IS NOT JSON "IS NOT JSON", + js IS JSON VALUE "IS VALUE", + js IS JSON OBJECT "IS OBJECT", + js IS JSON ARRAY "IS ARRAY", + js IS JSON SCALAR "IS SCALAR", + js IS JSON WITHOUT UNIQUE KEYS "WITHOUT UNIQUE", + js IS JSON WITH UNIQUE KEYS "WITH UNIQUE" +FROM + (SELECT js::jsonb FROM test_is_json WHERE js IS JSON) foo(js) +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=Select +FILTER: schema="" table="" column="js" +STMT: SelectStmt +== 200 +-- Test IS JSON deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT '1' IS JSON AS "any", ('1' || i) IS JSON SCALAR AS "scalar", '[]' IS NOT JSON ARRAY AS "array", '{}' IS JSON OBJECT WITH UNIQUE AS "object" FROM generate_series(1, 3) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 201 +CREATE VIEW is_json_view AS +SELECT '1' IS JSON AS "any", ('1' || i) IS JSON SCALAR AS "scalar", '[]' IS NOT JSON ARRAY AS "array", '{}' IS JSON OBJECT WITH UNIQUE AS "object" FROM generate_series(1, 3) i +-- +TABLE: name="is_json_view" schema="" table="is_json_view" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 202 +DROP VIEW is_json_view +-- +STMT: DropStmt +== 203 +-- Test implicit coercion to a fixed-length type specified in RETURNING +SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING varchar(2)) +-- +STMT: SelectStmt +== 204 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING varchar(2))) +-- +STMT: SelectStmt +== 205 +SELECT JSON_ARRAY(JSON_ARRAY('{ "a" : 123 }' RETURNING varchar(2))) +-- +STMT: SelectStmt +== 206 +SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RETURNING varchar(2)) FROM generate_series(1,1) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 207 +SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING varchar(2)) FROM generate_series(1, 1) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 208 +-- Now try domain over fixed-length type +CREATE DOMAIN sqljson_char2 AS char(2) CHECK (VALUE NOT IN ('12')) +-- +STMT: CreateDomainStmt +== 209 +SELECT JSON_SERIALIZE('123' RETURNING sqljson_char2) +-- +STMT: SelectStmt +== 210 +SELECT JSON_SERIALIZE('12' RETURNING sqljson_char2) +-- +STMT: SelectStmt +== 211 +-- Bug #18657: JsonValueExpr.raw_expr was not initialized in ExecInitExprRec() +-- causing the Aggrefs contained in it to also not be initialized, which led +-- to a crash in ExecBuildAggTrans() as mentioned in the bug report: +-- https://postgr.es/m/18657-1b90ccce2b16bdb8@postgresql.org +CREATE FUNCTION volatile_one() RETURNS int AS $$ BEGIN RETURN 1; END; $$ LANGUAGE plpgsql VOLATILE +-- +FUNCTION: name="volatile_one" function="volatile_one" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 212 +CREATE FUNCTION stable_one() RETURNS int AS $$ BEGIN RETURN 1; END; $$ LANGUAGE plpgsql STABLE +-- +FUNCTION: name="stable_one" function="stable_one" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 213 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': volatile_one() RETURNING text) FORMAT JSON) +-- +FUNCTION: name="volatile_one" function="volatile_one" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 214 +SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': volatile_one() RETURNING text) FORMAT JSON) +-- +FUNCTION: name="volatile_one" function="volatile_one" schema="" ctx=Call +STMT: SelectStmt +== 215 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': stable_one() RETURNING text) FORMAT JSON) +-- +FUNCTION: name="stable_one" function="stable_one" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 216 +SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': stable_one() RETURNING text) FORMAT JSON) +-- +FUNCTION: name="stable_one" function="stable_one" schema="" ctx=Call +STMT: SelectStmt +== 217 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': 1 RETURNING text) FORMAT JSON) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 218 +SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': 1 RETURNING text) FORMAT JSON) +-- +STMT: SelectStmt +== 219 +DROP FUNCTION volatile_one, stable_one +-- +FUNCTION: name="volatile_one" function="volatile_one" schema="" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/sqljson_jsontable.metadata.json b/parser/testdata/summary/postgres_regress/sqljson_jsontable.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sqljson_jsontable.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/sqljson_jsontable.test b/parser/testdata/summary/postgres_regress/sqljson_jsontable.test new file mode 100644 index 0000000..ee78d4b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sqljson_jsontable.test @@ -0,0 +1,913 @@ +== 001 +-- JSON_TABLE + +-- Should fail (JSON_TABLE can be used only in FROM clause) +SELECT JSON_TABLE('[]', '$') +-- +ERROR: syntax error at or near "(" +CURSORPOS: 93 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- Only allow EMPTY and ERROR for ON ERROR +SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +== 003 +SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') NULL ON ERROR) +-- +STMT: SelectStmt +== 004 +SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') EMPTY ON ERROR) +-- +STMT: SelectStmt +== 005 +SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') ERROR ON ERROR) +-- +STMT: SelectStmt +== 006 +-- Column and path names must be distinct +SELECT * FROM JSON_TABLE(jsonb'"1.23"', '$.a' as js2 COLUMNS (js2 int path '$')) +-- +STMT: SelectStmt +== 007 +-- Should fail (no columns) +SELECT * FROM JSON_TABLE(NULL, '$' COLUMNS ()) +-- +ERROR: syntax error at or near ")" +CURSORPOS: 73 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +SELECT * FROM JSON_TABLE (NULL::jsonb, '$' COLUMNS (v1 timestamp)) AS f (v1, v2) +-- +STMT: SelectStmt +== 009 +--duplicated column name +SELECT * FROM JSON_TABLE(jsonb'"1.23"', '$.a' COLUMNS (js2 int path '$', js2 int path '$')) +-- +STMT: SelectStmt +== 010 +--return composite data type. +create type comp as (a int, b int) +-- +STMT: CompositeTypeStmt +== 011 +SELECT * FROM JSON_TABLE(jsonb '{"rec": "(1,2)"}', '$' COLUMNS (id FOR ORDINALITY, comp comp path '$.rec' omit quotes)) jt +-- +STMT: SelectStmt +== 012 +drop type comp +-- +STMT: DropStmt +== 013 +-- NULL => empty table +SELECT * FROM JSON_TABLE(NULL::jsonb, '$' COLUMNS (foo int)) bar +-- +STMT: SelectStmt +== 014 +SELECT * FROM JSON_TABLE(jsonb'"1.23"', 'strict $.a' COLUMNS (js2 int PATH '$')) +-- +STMT: SelectStmt +== 015 +|-- +SELECT * FROM JSON_TABLE(jsonb '123', '$' + COLUMNS (item int PATH '$', foo int)) bar +-- +STMT: SelectStmt +== 016 +-- JSON_TABLE: basic functionality +CREATE DOMAIN jsonb_test_domain AS text CHECK (value <> 'foo') +-- +STMT: CreateDomainStmt +== 017 +CREATE TEMP TABLE json_table_test (js) AS + (VALUES + ('1'), + ('[]'), + ('{}'), + ('[1, 1.23, "2", "aaaaaaa", "foo", null, false, true, {"aaa": 123}, "[1,2]", "\"str\""]') + ) +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 018 +-- Regular "unformatted" columns +SELECT * +FROM json_table_test vals + LEFT OUTER JOIN + JSON_TABLE( + vals.js::jsonb, 'lax $[*]' + COLUMNS ( + id FOR ORDINALITY, + "int" int PATH '$', + "text" text PATH '$', + "char(4)" char(4) PATH '$', + "bool" bool PATH '$', + "numeric" numeric PATH '$', + "domain" jsonb_test_domain PATH '$', + js json PATH '$', + jb jsonb PATH '$' + ) + ) jt + ON true +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=Select +ALIAS: "vals"="json_table_test" +STMT: SelectStmt +== 019 +-- "formatted" columns +SELECT * +FROM json_table_test vals + LEFT OUTER JOIN + JSON_TABLE( + vals.js::jsonb, 'lax $[*]' + COLUMNS ( + id FOR ORDINALITY, + jst text FORMAT JSON PATH '$', + jsc char(4) FORMAT JSON PATH '$', + jsv varchar(4) FORMAT JSON PATH '$', + jsb jsonb FORMAT JSON PATH '$', + jsbq jsonb FORMAT JSON PATH '$' OMIT QUOTES + ) + ) jt + ON true +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=Select +ALIAS: "vals"="json_table_test" +STMT: SelectStmt +== 020 +-- EXISTS columns +SELECT * +FROM json_table_test vals + LEFT OUTER JOIN + JSON_TABLE( + vals.js::jsonb, 'lax $[*]' + COLUMNS ( + id FOR ORDINALITY, + exists1 bool EXISTS PATH '$.aaa', + exists2 int EXISTS PATH '$.aaa', + exists3 int EXISTS PATH 'strict $.aaa' UNKNOWN ON ERROR, + exists4 text EXISTS PATH 'strict $.aaa' FALSE ON ERROR + ) + ) jt + ON true +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=Select +ALIAS: "vals"="json_table_test" +STMT: SelectStmt +== 021 +-- Other miscellaneous checks +SELECT * +FROM json_table_test vals + LEFT OUTER JOIN + JSON_TABLE( + vals.js::jsonb, 'lax $[*]' + COLUMNS ( + id FOR ORDINALITY, + aaa int, -- "aaa" has implicit path '$."aaa"' + aaa1 int PATH '$.aaa', + js2 json PATH '$', + jsb2w jsonb PATH '$' WITH WRAPPER, + jsb2q jsonb PATH '$' OMIT QUOTES, + ia int[] PATH '$', + ta text[] PATH '$', + jba jsonb[] PATH '$' + ) + ) jt + ON true +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=Select +ALIAS: "vals"="json_table_test" +STMT: SelectStmt +== 022 +-- Test using casts in DEFAULT .. ON ERROR expression +SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' + COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT '"foo1"'::jsonb::text ON EMPTY)) +-- +STMT: SelectStmt +== 023 +SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' + COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo'::jsonb_test_domain ON EMPTY)) +-- +STMT: SelectStmt +== 024 +SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' + COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo1'::jsonb_test_domain ON EMPTY)) +-- +STMT: SelectStmt +== 025 +SELECT * FROM JSON_TABLE(jsonb '{"d1": "foo"}', '$' + COLUMNS (js1 jsonb_test_domain PATH '$.d1' DEFAULT 'foo2'::jsonb_test_domain ON ERROR)) +-- +STMT: SelectStmt +== 026 +SELECT * FROM JSON_TABLE(jsonb '{"d1": "foo"}', '$' + COLUMNS (js1 oid[] PATH '$.d2' DEFAULT '{1}'::int[]::oid[] ON EMPTY)) +-- +STMT: SelectStmt +== 027 +-- JSON_TABLE: Test backward parsing + +CREATE VIEW jsonb_table_view2 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + "int" int PATH '$', + "text" text PATH '$', + "char(4)" char(4) PATH '$', + "bool" bool PATH '$', + "numeric" numeric PATH '$', + "domain" jsonb_test_domain PATH '$')) +-- +TABLE: name="jsonb_table_view2" schema="" table="jsonb_table_view2" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 028 +CREATE VIEW jsonb_table_view3 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + js json PATH '$', + jb jsonb PATH '$', + jst text FORMAT JSON PATH '$', + jsc char(4) FORMAT JSON PATH '$', + jsv varchar(4) FORMAT JSON PATH '$')) +-- +TABLE: name="jsonb_table_view3" schema="" table="jsonb_table_view3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 029 +CREATE VIEW jsonb_table_view4 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + jsb jsonb FORMAT JSON PATH '$', + jsbq jsonb FORMAT JSON PATH '$' OMIT QUOTES, + aaa int, -- implicit path '$."aaa"', + aaa1 int PATH '$.aaa')) +-- +TABLE: name="jsonb_table_view4" schema="" table="jsonb_table_view4" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 030 +CREATE VIEW jsonb_table_view5 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + exists1 bool EXISTS PATH '$.aaa', + exists2 int EXISTS PATH '$.aaa' TRUE ON ERROR, + exists3 text EXISTS PATH 'strict $.aaa' UNKNOWN ON ERROR)) +-- +TABLE: name="jsonb_table_view5" schema="" table="jsonb_table_view5" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 031 +CREATE VIEW jsonb_table_view6 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + js2 json PATH '$', + jsb2w jsonb PATH '$' WITH WRAPPER, + jsb2q jsonb PATH '$' OMIT QUOTES, + ia int[] PATH '$', + ta text[] PATH '$', + jba jsonb[] PATH '$')) +-- +TABLE: name="jsonb_table_view6" schema="" table="jsonb_table_view6" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 032 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view2 +-- +TABLE: name="jsonb_table_view2" schema="" table="jsonb_table_view2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 033 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view3 +-- +TABLE: name="jsonb_table_view3" schema="" table="jsonb_table_view3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 034 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view4 +-- +TABLE: name="jsonb_table_view4" schema="" table="jsonb_table_view4" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 035 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view5 +-- +TABLE: name="jsonb_table_view5" schema="" table="jsonb_table_view5" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 036 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view6 +-- +TABLE: name="jsonb_table_view6" schema="" table="jsonb_table_view6" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 037 +-- JSON_TABLE() with alias +EXPLAIN (COSTS OFF, VERBOSE) +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + id FOR ORDINALITY, + "int" int PATH '$', + "text" text PATH '$' + )) json_table_func +-- +STMT: ExplainStmt +STMT: SelectStmt +== 038 +EXPLAIN (COSTS OFF, FORMAT JSON, VERBOSE) +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + id FOR ORDINALITY, + "int" int PATH '$', + "text" text PATH '$' + )) json_table_func +-- +STMT: ExplainStmt +STMT: SelectStmt +== 039 +DROP VIEW jsonb_table_view2 +-- +STMT: DropStmt +== 040 +DROP VIEW jsonb_table_view3 +-- +STMT: DropStmt +== 041 +DROP VIEW jsonb_table_view4 +-- +STMT: DropStmt +== 042 +DROP VIEW jsonb_table_view5 +-- +STMT: DropStmt +== 043 +DROP VIEW jsonb_table_view6 +-- +STMT: DropStmt +== 044 +DROP DOMAIN jsonb_test_domain +-- +STMT: DropStmt +== 045 +-- JSON_TABLE: only one FOR ORDINALITY columns allowed +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (id FOR ORDINALITY, id2 FOR ORDINALITY, a int PATH '$.a' ERROR ON EMPTY)) jt +-- +STMT: SelectStmt +== 046 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (id FOR ORDINALITY, a int PATH '$' ERROR ON EMPTY)) jt +-- +STMT: SelectStmt +== 047 +-- JSON_TABLE: ON EMPTY/ON ERROR behavior +SELECT * +FROM + (VALUES ('1'), ('"err"')) vals(js), + JSON_TABLE(vals.js::jsonb, '$' COLUMNS (a int PATH '$')) jt +-- +STMT: SelectStmt +== 048 +SELECT * +FROM + (VALUES ('1'), ('"err"')) vals(js) + LEFT OUTER JOIN + JSON_TABLE(vals.js::jsonb, '$' COLUMNS (a int PATH '$' ERROR ON ERROR)) jt + ON true +-- +STMT: SelectStmt +== 049 +-- TABLE-level ERROR ON ERROR is not propagated to columns +SELECT * +FROM + (VALUES ('1'), ('"err"')) vals(js) + LEFT OUTER JOIN + JSON_TABLE(vals.js::jsonb, '$' COLUMNS (a int PATH '$' ERROR ON ERROR)) jt + ON true +-- +STMT: SelectStmt +== 050 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int PATH '$.a' ERROR ON EMPTY)) jt +-- +STMT: SelectStmt +== 051 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int PATH 'strict $.a' ERROR ON ERROR) ERROR ON ERROR) jt +-- +STMT: SelectStmt +== 052 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int PATH 'lax $.a' ERROR ON EMPTY) ERROR ON ERROR) jt +-- +STMT: SelectStmt +== 053 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int PATH '$' DEFAULT 1 ON EMPTY DEFAULT 2 ON ERROR)) jt +-- +STMT: SelectStmt +== 054 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int PATH 'strict $.a' DEFAULT 1 ON EMPTY DEFAULT 2 ON ERROR)) jt +-- +STMT: SelectStmt +== 055 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int PATH 'lax $.a' DEFAULT 1 ON EMPTY DEFAULT 2 ON ERROR)) jt +-- +STMT: SelectStmt +== 056 +-- JSON_TABLE: EXISTS PATH types +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int4 EXISTS PATH '$.a' ERROR ON ERROR)) +-- +STMT: SelectStmt +== 057 +-- ok; can cast to int4 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int4 EXISTS PATH '$' ERROR ON ERROR)) +-- +STMT: SelectStmt +== 058 +-- ok; can cast to int4 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int2 EXISTS PATH '$.a')) +-- +STMT: SelectStmt +== 059 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int8 EXISTS PATH '$.a')) +-- +STMT: SelectStmt +== 060 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a float4 EXISTS PATH '$.a')) +-- +STMT: SelectStmt +== 061 +-- Default FALSE (ON ERROR) doesn't fit char(3) +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a char(3) EXISTS PATH '$.a')) +-- +STMT: SelectStmt +== 062 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a char(3) EXISTS PATH '$.a' ERROR ON ERROR)) +-- +STMT: SelectStmt +== 063 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a char(5) EXISTS PATH '$.a' ERROR ON ERROR)) +-- +STMT: SelectStmt +== 064 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a json EXISTS PATH '$.a')) +-- +STMT: SelectStmt +== 065 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a jsonb EXISTS PATH '$.a')) +-- +STMT: SelectStmt +== 066 +-- EXISTS PATH domain over int +CREATE DOMAIN dint4 AS int +-- +STMT: CreateDomainStmt +== 067 +CREATE DOMAIN dint4_0 AS int CHECK (VALUE <> 0 ) +-- +STMT: CreateDomainStmt +== 068 +SELECT a, a::bool FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a dint4 EXISTS PATH '$.a' )) +-- +STMT: SelectStmt +== 069 +SELECT a, a::bool FROM JSON_TABLE(jsonb '{"a":1}', '$' COLUMNS (a dint4_0 EXISTS PATH '$.b')) +-- +STMT: SelectStmt +== 070 +SELECT a, a::bool FROM JSON_TABLE(jsonb '{"a":1}', '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' ERROR ON ERROR)) +-- +STMT: SelectStmt +== 071 +SELECT a, a::bool FROM JSON_TABLE(jsonb '{"a":1}', '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' FALSE ON ERROR)) +-- +STMT: SelectStmt +== 072 +SELECT a, a::bool FROM JSON_TABLE(jsonb '{"a":1}', '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' TRUE ON ERROR)) +-- +STMT: SelectStmt +== 073 +DROP DOMAIN dint4, dint4_0 +-- +STMT: DropStmt +== 074 +-- JSON_TABLE: WRAPPER/QUOTES clauses on scalar columns +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text PATH '$' KEEP QUOTES ON SCALAR STRING)) +-- +STMT: SelectStmt +== 075 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text PATH '$' OMIT QUOTES ON SCALAR STRING)) +-- +STMT: SelectStmt +== 076 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' KEEP QUOTES)) +-- +STMT: SelectStmt +== 077 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' OMIT QUOTES)) +-- +STMT: SelectStmt +== 078 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' WITHOUT WRAPPER KEEP QUOTES)) +-- +STMT: SelectStmt +== 079 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text PATH '$' WITHOUT WRAPPER OMIT QUOTES)) +-- +STMT: SelectStmt +== 080 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' WITH WRAPPER)) +-- +STMT: SelectStmt +== 081 +-- Error: OMIT QUOTES should not be specified when WITH WRAPPER is present +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text PATH '$' WITH WRAPPER OMIT QUOTES)) +-- +STMT: SelectStmt +== 082 +-- But KEEP QUOTES (the default) is fine +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' WITH WRAPPER KEEP QUOTES)) +-- +STMT: SelectStmt +== 083 +-- Test PASSING args +SELECT * +FROM JSON_TABLE( + jsonb '[1,2,3]', + '$[*] ? (@ < $x)' + PASSING 3 AS x + COLUMNS (y text FORMAT JSON PATH '$') + ) jt +-- +STMT: SelectStmt +== 084 +-- PASSING arguments are also passed to column paths +SELECT * +FROM JSON_TABLE( + jsonb '[1,2,3]', + '$[*] ? (@ < $x)' + PASSING 10 AS x, 3 AS y + COLUMNS (a text FORMAT JSON PATH '$ ? (@ < $y)') + ) jt +-- +STMT: SelectStmt +== 085 +-- Should fail (not supported) +SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || 'a' COLUMNS (foo int)) +-- +ERROR: only string constants are supported in JSON_TABLE path specification +CURSORPOS: 77 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 086 +-- JsonPathQuery() error message mentioning column name +SELECT * FROM JSON_TABLE('{"a": [{"b": "1"}, {"b": "2"}]}', '$' COLUMNS (b json path '$.a[*].b' ERROR ON ERROR)) +-- +STMT: SelectStmt +== 087 +-- JSON_TABLE: nested paths + +-- Duplicate path names +SELECT * FROM JSON_TABLE( + jsonb '[]', '$' AS a + COLUMNS ( + b int, + NESTED PATH '$' AS a + COLUMNS ( + c int + ) + ) +) jt +-- +STMT: SelectStmt +== 088 +SELECT * FROM JSON_TABLE( + jsonb '[]', '$' AS a + COLUMNS ( + b int, + NESTED PATH '$' AS n_a + COLUMNS ( + c int + ) + ) +) jt +-- +STMT: SelectStmt +== 089 +SELECT * FROM JSON_TABLE( + jsonb '[]', '$' + COLUMNS ( + b int, + NESTED PATH '$' AS b + COLUMNS ( + c int + ) + ) +) jt +-- +STMT: SelectStmt +== 090 +SELECT * FROM JSON_TABLE( + jsonb '[]', '$' + COLUMNS ( + NESTED PATH '$' AS a + COLUMNS ( + b int + ), + NESTED PATH '$' + COLUMNS ( + NESTED PATH '$' AS a + COLUMNS ( + c int + ) + ) + ) +) jt +-- +STMT: SelectStmt +== 091 +-- JSON_TABLE: plan execution + +CREATE TEMP TABLE jsonb_table_test (js jsonb) +-- +TABLE: name="jsonb_table_test" schema="" table="jsonb_table_test" ctx=DDL +STMT: CreateStmt +== 092 +INSERT INTO jsonb_table_test +VALUES ( + '[ + {"a": 1, "b": [], "c": []}, + {"a": 2, "b": [1, 2, 3], "c": [10, null, 20]}, + {"a": 3, "b": [1, 2], "c": []}, + {"x": "4", "b": [1, 2], "c": 123} + ]' +) +-- +TABLE: name="jsonb_table_test" schema="" table="jsonb_table_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +select + jt.* +from + jsonb_table_test jtt, + json_table ( + jtt.js,'strict $[*]' as p + columns ( + n for ordinality, + a int path 'lax $.a' default -1 on empty, + nested path 'strict $.b[*]' as pb columns (b_id for ordinality, b int path '$' ), + nested path 'strict $.c[*]' as pc columns (c_id for ordinality, c int path '$' ) + ) + ) jt +-- +TABLE: name="jsonb_table_test" schema="" table="jsonb_table_test" ctx=Select +ALIAS: "jtt"="jsonb_table_test" +STMT: SelectStmt +== 094 +-- PASSING arguments are passed to nested paths and their columns' paths +SELECT * +FROM + generate_series(1, 3) x, + generate_series(1, 3) y, + JSON_TABLE(jsonb + '[[1,2,3],[2,3,4,5],[3,4,5,6]]', + 'strict $[*] ? (@[*] <= $x)' + PASSING x AS x, y AS y + COLUMNS ( + y text FORMAT JSON PATH '$', + NESTED PATH 'strict $[*] ? (@ == $y)' + COLUMNS ( + z int PATH '$' + ) + ) + ) jt +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 095 +-- JSON_TABLE: Test backward parsing with nested paths + +CREATE VIEW jsonb_table_view_nested AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + id FOR ORDINALITY, + NESTED PATH '$[1]' AS p1 COLUMNS ( + a1 int, + NESTED PATH '$[*]' AS "p1 1" COLUMNS ( + a11 text + ), + b1 text + ), + NESTED PATH '$[2]' AS p2 COLUMNS ( + NESTED PATH '$[*]' AS "p2:1" COLUMNS ( + a21 text + ), + NESTED PATH '$[*]' AS p22 COLUMNS ( + a22 text + ) + ) + ) + ) +-- +TABLE: name="jsonb_table_view_nested" schema="" table="jsonb_table_view_nested" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 096 +DROP VIEW jsonb_table_view_nested +-- +STMT: DropStmt +== 097 +CREATE TABLE s (js jsonb) +-- +TABLE: name="s" schema="" table="s" ctx=DDL +STMT: CreateStmt +== 098 +INSERT INTO s VALUES + ('{"a":{"za":[{"z1": [11,2222]},{"z21": [22, 234,2345]},{"z22": [32, 204,145]}]},"c": 3}'), + ('{"a":{"za":[{"z1": [21,4222]},{"z21": [32, 134,1345]}]},"c": 10}') +-- +TABLE: name="s" schema="" table="s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 099 +-- error +SELECT sub.* FROM s, + JSON_TABLE(js, '$' PASSING 32 AS x, 13 AS y COLUMNS ( + xx int path '$.c', + NESTED PATH '$.a.za[1]' columns (NESTED PATH '$.z21[*]' COLUMNS (z21 int path '$?(@ >= $"x")' ERROR ON ERROR)) + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +STMT: SelectStmt +== 100 +-- Parent columns xx1, xx appear before NESTED ones +SELECT sub.* FROM s, + (VALUES (23)) x(x), generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y COLUMNS ( + NESTED PATH '$.a.za[2]' COLUMNS ( + NESTED PATH '$.z22[*]' as z22 COLUMNS (c int PATH '$')), + NESTED PATH '$.a.za[1]' columns (d int[] PATH '$.z21'), + NESTED PATH '$.a.za[0]' columns (NESTED PATH '$.z1[*]' as z1 COLUMNS (a int PATH '$')), + xx1 int PATH '$.c', + NESTED PATH '$.a.za[1]' columns (NESTED PATH '$.z21[*]' as z21 COLUMNS (b int PATH '$')), + xx int PATH '$.c' + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 101 +-- Test applying PASSING variables at different nesting levels +SELECT sub.* FROM s, + (VALUES (23)) x(x), generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y COLUMNS ( + xx1 int PATH '$.c', + NESTED PATH '$.a.za[0].z1[*]' COLUMNS (NESTED PATH '$ ?(@ >= ($"x" -2))' COLUMNS (a int PATH '$')), + NESTED PATH '$.a.za[0]' COLUMNS (NESTED PATH '$.z1[*] ? (@ >= ($"x" -2))' COLUMNS (b int PATH '$')) + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 102 +-- Test applying PASSING variable to paths all the levels +SELECT sub.* FROM s, + (VALUES (23)) x(x), + generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y + COLUMNS ( + xx1 int PATH '$.c', + NESTED PATH '$.a.za[1]' + COLUMNS (NESTED PATH '$.z21[*]' COLUMNS (b int PATH '$')), + NESTED PATH '$.a.za[1] ? (@.z21[*] >= ($"x"-1))' COLUMNS + (NESTED PATH '$.z21[*] ? (@ >= ($"y" + 3))' as z22 COLUMNS (a int PATH '$ ? (@ >= ($"y" + 12))')), + NESTED PATH '$.a.za[1]' COLUMNS + (NESTED PATH '$.z21[*] ? (@ >= ($"y" +121))' as z21 COLUMNS (c int PATH '$ ? (@ > ($"x" +111))')) + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 103 +----- test on empty behavior +SELECT sub.* FROM s, + (values(23)) x(x), + generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y + COLUMNS ( + xx1 int PATH '$.c', + NESTED PATH '$.a.za[2]' COLUMNS (NESTED PATH '$.z22[*]' as z22 COLUMNS (c int PATH '$')), + NESTED PATH '$.a.za[1]' COLUMNS (d json PATH '$ ? (@.z21[*] == ($"x" -1))'), + NESTED PATH '$.a.za[0]' COLUMNS (NESTED PATH '$.z1[*] ? (@ >= ($"x" -2))' as z1 COLUMNS (a int PATH '$')), + NESTED PATH '$.a.za[1]' COLUMNS + (NESTED PATH '$.z21[*] ? (@ >= ($"y" +121))' as z21 COLUMNS (b int PATH '$ ? (@ > ($"x" +111))' DEFAULT 0 ON EMPTY)) + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 104 +CREATE OR REPLACE VIEW jsonb_table_view7 AS +SELECT sub.* FROM s, + (values(23)) x(x), + generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y + COLUMNS ( + xx1 int PATH '$.c', + NESTED PATH '$.a.za[2]' COLUMNS (NESTED PATH '$.z22[*]' as z22 COLUMNS (c int PATH '$' WITHOUT WRAPPER OMIT QUOTES)), + NESTED PATH '$.a.za[1]' COLUMNS (d json PATH '$ ? (@.z21[*] == ($"x" -1))' WITH WRAPPER), + NESTED PATH '$.a.za[0]' COLUMNS (NESTED PATH '$.z1[*] ? (@ >= ($"x" -2))' as z1 COLUMNS (a int PATH '$' KEEP QUOTES)), + NESTED PATH '$.a.za[1]' COLUMNS + (NESTED PATH '$.z21[*] ? (@ >= ($"y" +121))' as z21 COLUMNS (b int PATH '$ ? (@ > ($"x" +111))' DEFAULT 0 ON EMPTY)) + )) sub +-- +TABLE: name="jsonb_table_view7" schema="" table="jsonb_table_view7" ctx=DDL +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 105 +DROP VIEW jsonb_table_view7 +-- +STMT: DropStmt +== 106 +DROP TABLE s +-- +TABLE: name="s" schema="" table="s" ctx=DDL +STMT: DropStmt +== 107 +-- Prevent ON EMPTY specification on EXISTS columns +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on empty)) +-- +ERROR: syntax error at or near "empty" +CURSORPOS: 131 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 108 +-- Test ON ERROR / EMPTY value validity for the function and column types; +-- all fail +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int) NULL ON ERROR) +-- +STMT: SelectStmt +== 109 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int true on empty)) +-- +STMT: SelectStmt +== 110 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int omit quotes true on error)) +-- +STMT: SelectStmt +== 111 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on error)) +-- +STMT: SelectStmt +== 112 +-- Test JSON_TABLE() column deparsing -- don't emit default ON ERROR / EMPTY +-- behavior +CREATE VIEW json_table_view8 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$')) +-- +TABLE: name="json_table_view8" schema="" table="json_table_view8" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 113 +CREATE VIEW json_table_view9 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') ERROR ON ERROR) +-- +TABLE: name="json_table_view9" schema="" table="json_table_view9" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 114 +DROP VIEW json_table_view8, json_table_view9 +-- +STMT: DropStmt +== 115 +-- Test JSON_TABLE() deparsing -- don't emit default ON ERROR behavior +CREATE VIEW json_table_view8 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') EMPTY ON ERROR) +-- +TABLE: name="json_table_view8" schema="" table="json_table_view8" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 116 +CREATE VIEW json_table_view9 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') EMPTY ARRAY ON ERROR) +-- +TABLE: name="json_table_view9" schema="" table="json_table_view9" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 117 +DROP VIEW json_table_view8, json_table_view9 +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/sqljson_queryfuncs.metadata.json b/parser/testdata/summary/postgres_regress/sqljson_queryfuncs.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sqljson_queryfuncs.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/sqljson_queryfuncs.test b/parser/testdata/summary/postgres_regress/sqljson_queryfuncs.test new file mode 100644 index 0000000..db5f97d --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sqljson_queryfuncs.test @@ -0,0 +1,1455 @@ +== 001 +-- JSON_EXISTS +SELECT JSON_EXISTS(NULL::jsonb, '$') +-- +STMT: SelectStmt +== 002 +SELECT JSON_EXISTS(jsonb '[]', '$') +-- +STMT: SelectStmt +== 003 +SELECT JSON_EXISTS(JSON_OBJECT(RETURNING jsonb), '$') +-- +STMT: SelectStmt +== 004 +SELECT JSON_EXISTS(jsonb '1', '$') +-- +STMT: SelectStmt +== 005 +SELECT JSON_EXISTS(jsonb 'null', '$') +-- +STMT: SelectStmt +== 006 +SELECT JSON_EXISTS(jsonb '[]', '$') +-- +STMT: SelectStmt +== 007 +SELECT JSON_EXISTS(jsonb '1', '$.a') +-- +STMT: SelectStmt +== 008 +SELECT JSON_EXISTS(jsonb '1', 'strict $.a') +-- +STMT: SelectStmt +== 009 +-- FALSE on error +SELECT JSON_EXISTS(jsonb '1', 'strict $.a' ERROR ON ERROR) +-- +STMT: SelectStmt +== 010 +SELECT JSON_EXISTS(jsonb 'null', '$.a') +-- +STMT: SelectStmt +== 011 +SELECT JSON_EXISTS(jsonb '[]', '$.a') +-- +STMT: SelectStmt +== 012 +SELECT JSON_EXISTS(jsonb '[1, "aaa", {"a": 1}]', 'strict $.a') +-- +STMT: SelectStmt +== 013 +-- FALSE on error +SELECT JSON_EXISTS(jsonb '[1, "aaa", {"a": 1}]', 'lax $.a') +-- +STMT: SelectStmt +== 014 +SELECT JSON_EXISTS(jsonb '{}', '$.a') +-- +STMT: SelectStmt +== 015 +SELECT JSON_EXISTS(jsonb '{"b": 1, "a": 2}', '$.a') +-- +STMT: SelectStmt +== 016 +SELECT JSON_EXISTS(jsonb '1', '$.a.b') +-- +STMT: SelectStmt +== 017 +SELECT JSON_EXISTS(jsonb '{"a": {"b": 1}}', '$.a.b') +-- +STMT: SelectStmt +== 018 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.a.b') +-- +STMT: SelectStmt +== 019 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.* ? (@ > $x)' PASSING 1 AS x) +-- +STMT: SelectStmt +== 020 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.* ? (@ > $x)' PASSING '1' AS x) +-- +STMT: SelectStmt +== 021 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.* ? (@ > $x && @ < $y)' PASSING 0 AS x, 2 AS y) +-- +STMT: SelectStmt +== 022 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.* ? (@ > $x && @ < $y)' PASSING 0 AS x, 1 AS y) +-- +STMT: SelectStmt +== 023 +-- extension: boolean expressions +SELECT JSON_EXISTS(jsonb '1', '$ > 2') +-- +STMT: SelectStmt +== 024 +SELECT JSON_EXISTS(jsonb '1', '$.a > 2' ERROR ON ERROR) +-- +STMT: SelectStmt +== 025 +-- JSON_VALUE +SELECT JSON_VALUE(NULL::jsonb, '$') +-- +STMT: SelectStmt +== 026 +SELECT JSON_VALUE(jsonb 'null', '$') +-- +STMT: SelectStmt +== 027 +SELECT JSON_VALUE(jsonb 'null', '$' RETURNING int) +-- +STMT: SelectStmt +== 028 +SELECT JSON_VALUE(jsonb 'true', '$') +-- +STMT: SelectStmt +== 029 +SELECT JSON_VALUE(jsonb 'true', '$' RETURNING bool) +-- +STMT: SelectStmt +== 030 +SELECT JSON_VALUE(jsonb '123', '$') +-- +STMT: SelectStmt +== 031 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING int) + 234 +-- +STMT: SelectStmt +== 032 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING text) +-- +STMT: SelectStmt +== 033 +/* jsonb bytea ??? */ +SELECT JSON_VALUE(jsonb '123', '$' RETURNING bytea ERROR ON ERROR) +-- +STMT: SelectStmt +== 034 +SELECT JSON_VALUE(jsonb '1.23', '$') +-- +STMT: SelectStmt +== 035 +SELECT JSON_VALUE(jsonb '1.23', '$' RETURNING int) +-- +STMT: SelectStmt +== 036 +SELECT JSON_VALUE(jsonb '"1.23"', '$' RETURNING numeric) +-- +STMT: SelectStmt +== 037 +SELECT JSON_VALUE(jsonb '"1.23"', '$' RETURNING int ERROR ON ERROR) +-- +STMT: SelectStmt +== 038 +SELECT JSON_VALUE(jsonb '"aaa"', '$') +-- +STMT: SelectStmt +== 039 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING text) +-- +STMT: SelectStmt +== 040 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING char(5)) +-- +STMT: SelectStmt +== 041 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING char(2) ERROR ON ERROR) +-- +STMT: SelectStmt +== 042 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING char(2)) +-- +STMT: SelectStmt +== 043 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING char(3) ERROR ON ERROR) +-- +STMT: SelectStmt +== 044 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING json) +-- +STMT: SelectStmt +== 045 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING jsonb) +-- +STMT: SelectStmt +== 046 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING json ERROR ON ERROR) +-- +STMT: SelectStmt +== 047 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING jsonb ERROR ON ERROR) +-- +STMT: SelectStmt +== 048 +SELECT JSON_VALUE(jsonb '"\"aaa\""', '$' RETURNING json) +-- +STMT: SelectStmt +== 049 +SELECT JSON_VALUE(jsonb '"\"aaa\""', '$' RETURNING jsonb) +-- +STMT: SelectStmt +== 050 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING int) +-- +STMT: SelectStmt +== 051 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING int ERROR ON ERROR) +-- +STMT: SelectStmt +== 052 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING int DEFAULT 111 ON ERROR) +-- +STMT: SelectStmt +== 053 +SELECT JSON_VALUE(jsonb '"123"', '$' RETURNING int) + 234 +-- +STMT: SelectStmt +== 054 +SELECT JSON_VALUE(jsonb '"2017-02-20"', '$' RETURNING date) + 9 +-- +STMT: SelectStmt +== 055 +-- Test NULL checks execution in domain types +CREATE DOMAIN sqljsonb_int_not_null AS int NOT NULL +-- +STMT: CreateDomainStmt +== 056 +SELECT JSON_VALUE(jsonb 'null', '$' RETURNING sqljsonb_int_not_null) +-- +STMT: SelectStmt +== 057 +SELECT JSON_VALUE(jsonb 'null', '$' RETURNING sqljsonb_int_not_null ERROR ON ERROR) +-- +STMT: SelectStmt +== 058 +SELECT JSON_VALUE(jsonb 'null', '$' RETURNING sqljsonb_int_not_null DEFAULT 2 ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +== 059 +SELECT JSON_VALUE(jsonb '1', '$.a' RETURNING sqljsonb_int_not_null DEFAULT 2 ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +== 060 +SELECT JSON_VALUE(jsonb '1', '$.a' RETURNING sqljsonb_int_not_null DEFAULT NULL ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +== 061 +CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple') +-- +STMT: CreateEnumStmt +== 062 +CREATE DOMAIN rgb AS rainbow CHECK (VALUE IN ('red', 'green', 'blue')) +-- +STMT: CreateDomainStmt +== 063 +SELECT JSON_VALUE('"purple"'::jsonb, 'lax $[*]' RETURNING rgb) +-- +STMT: SelectStmt +== 064 +SELECT JSON_VALUE('"purple"'::jsonb, 'lax $[*]' RETURNING rgb ERROR ON ERROR) +-- +STMT: SelectStmt +== 065 +SELECT JSON_VALUE(jsonb '[]', '$') +-- +STMT: SelectStmt +== 066 +SELECT JSON_VALUE(jsonb '[]', '$' ERROR ON ERROR) +-- +STMT: SelectStmt +== 067 +SELECT JSON_VALUE(jsonb '{}', '$') +-- +STMT: SelectStmt +== 068 +SELECT JSON_VALUE(jsonb '{}', '$' ERROR ON ERROR) +-- +STMT: SelectStmt +== 069 +SELECT JSON_VALUE(jsonb '1', '$.a') +-- +STMT: SelectStmt +== 070 +SELECT JSON_VALUE(jsonb '1', 'strict $.a' ERROR ON ERROR) +-- +STMT: SelectStmt +== 071 +SELECT JSON_VALUE(jsonb '1', 'strict $.a' DEFAULT 'error' ON ERROR) +-- +STMT: SelectStmt +== 072 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' ERROR ON ERROR) +-- +STMT: SelectStmt +== 073 +-- NULL ON EMPTY +SELECT JSON_VALUE(jsonb '1', 'lax $.a' ERROR ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +== 074 +SELECT JSON_VALUE(jsonb '1', 'strict $.*' DEFAULT 2 ON ERROR) +-- +STMT: SelectStmt +== 075 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' DEFAULT 2 ON ERROR) +-- +STMT: SelectStmt +== 076 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' DEFAULT '2' ON EMPTY) +-- +STMT: SelectStmt +== 077 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' NULL ON EMPTY DEFAULT '2' ON ERROR) +-- +STMT: SelectStmt +== 078 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' DEFAULT '2' ON EMPTY DEFAULT '3' ON ERROR) +-- +STMT: SelectStmt +== 079 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' ERROR ON EMPTY DEFAULT '3' ON ERROR) +-- +STMT: SelectStmt +== 080 +SELECT JSON_VALUE(jsonb '[1,2]', '$[*]' ERROR ON ERROR) +-- +STMT: SelectStmt +== 081 +SELECT JSON_VALUE(jsonb '[1,2]', '$[*]' DEFAULT '0' ON ERROR) +-- +STMT: SelectStmt +== 082 +SELECT JSON_VALUE(jsonb '[" "]', '$[*]' RETURNING int ERROR ON ERROR) +-- +STMT: SelectStmt +== 083 +SELECT JSON_VALUE(jsonb '[" "]', '$[*]' RETURNING int DEFAULT 2 + 3 ON ERROR) +-- +STMT: SelectStmt +== 084 +SELECT JSON_VALUE(jsonb '["1"]', '$[*]' RETURNING int DEFAULT 2 + 3 ON ERROR) +-- +STMT: SelectStmt +== 085 +SELECT JSON_VALUE(jsonb '["1"]', '$[*]' RETURNING int FORMAT JSON) +-- +STMT: SelectStmt +== 086 +-- RETURNING FORMAT not allowed + +-- RETUGNING pseudo-types not allowed +SELECT JSON_VALUE(jsonb '["1"]', '$[*]' RETURNING record) +-- +STMT: SelectStmt +== 087 +SELECT + x, + JSON_VALUE( + jsonb '{"a": 1, "b": 2}', + '$.* ? (@ > $x)' PASSING x AS x + RETURNING int + DEFAULT -1 ON EMPTY + DEFAULT -2 ON ERROR + ) y +FROM + generate_series(0, 2) x +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 088 +SELECT JSON_VALUE(jsonb 'null', '$a' PASSING point ' (1, 2 )' AS a) +-- +STMT: SelectStmt +== 089 +SELECT JSON_VALUE(jsonb 'null', '$a' PASSING point ' (1, 2 )' AS a RETURNING point) +-- +STMT: SelectStmt +== 090 +SELECT JSON_VALUE(jsonb 'null', '$a' PASSING point ' (1, 2 )' AS a RETURNING point ERROR ON ERROR) +-- +STMT: SelectStmt +== 091 +-- Test PASSING and RETURNING date/time types +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts) +-- +STMT: SelectStmt +== 092 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING timestamptz) +-- +STMT: SelectStmt +== 093 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING timestamp) +-- +STMT: SelectStmt +== 094 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING date '2018-02-21 12:34:56 +10' AS ts RETURNING date) +-- +STMT: SelectStmt +== 095 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING time '2018-02-21 12:34:56 +10' AS ts RETURNING time) +-- +STMT: SelectStmt +== 096 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timetz '2018-02-21 12:34:56 +10' AS ts RETURNING timetz) +-- +STMT: SelectStmt +== 097 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamp '2018-02-21 12:34:56 +10' AS ts RETURNING timestamp) +-- +STMT: SelectStmt +== 098 +-- Also test RETURNING json[b] +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING json) +-- +STMT: SelectStmt +== 099 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING jsonb) +-- +STMT: SelectStmt +== 100 +-- Test that numeric JSON values are coerced uniformly +select json_value('{"a": 1.234}', '$.a' returning int error on error) +-- +STMT: SelectStmt +== 101 +select json_value('{"a": "1.234"}', '$.a' returning int error on error) +-- +STMT: SelectStmt +== 102 +-- JSON_QUERY + +SELECT JSON_VALUE(NULL::jsonb, '$') +-- +STMT: SelectStmt +== 103 +SELECT + JSON_QUERY(js, '$') AS "unspec", + JSON_QUERY(js, '$' WITHOUT WRAPPER) AS "without", + JSON_QUERY(js, '$' WITH CONDITIONAL WRAPPER) AS "with cond", + JSON_QUERY(js, '$' WITH UNCONDITIONAL ARRAY WRAPPER) AS "with uncond", + JSON_QUERY(js, '$' WITH ARRAY WRAPPER) AS "with" +FROM + (VALUES + (jsonb 'null'), + ('12.3'), + ('true'), + ('"aaa"'), + ('[1, null, "2"]'), + ('{"a": 1, "b": [2]}') + ) foo(js) +-- +STMT: SelectStmt +== 104 +SELECT + JSON_QUERY(js, 'strict $[*]') AS "unspec", + JSON_QUERY(js, 'strict $[*]' WITHOUT WRAPPER) AS "without", + JSON_QUERY(js, 'strict $[*]' WITH CONDITIONAL WRAPPER) AS "with cond", + JSON_QUERY(js, 'strict $[*]' WITH UNCONDITIONAL ARRAY WRAPPER) AS "with uncond", + JSON_QUERY(js, 'strict $[*]' WITH ARRAY WRAPPER) AS "with" +FROM + (VALUES + (jsonb '1'), + ('[]'), + ('[null]'), + ('[12.3]'), + ('[true]'), + ('["aaa"]'), + ('[[1, 2, 3]]'), + ('[{"a": 1, "b": [2]}]'), + ('[1, "2", null, [3]]') + ) foo(js) +-- +STMT: SelectStmt +== 105 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text) +-- +STMT: SelectStmt +== 106 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text KEEP QUOTES) +-- +STMT: SelectStmt +== 107 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text KEEP QUOTES ON SCALAR STRING) +-- +STMT: SelectStmt +== 108 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text OMIT QUOTES) +-- +STMT: SelectStmt +== 109 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text OMIT QUOTES ON SCALAR STRING) +-- +STMT: SelectStmt +== 110 +SELECT JSON_QUERY(jsonb '"aaa"', '$' OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +== 111 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING json OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +== 112 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING bytea FORMAT JSON OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +== 113 +-- Behavior when a RETURNING type has typmod != -1 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING char(3) ERROR ON ERROR) +-- +STMT: SelectStmt +== 114 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING char(3)) +-- +STMT: SelectStmt +== 115 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING char(3) OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +== 116 +SELECT JSON_QUERY(jsonb '"aaa"', '$.a' RETURNING char(2) OMIT QUOTES DEFAULT 'bb' ON EMPTY) +-- +STMT: SelectStmt +== 117 +SELECT JSON_QUERY(jsonb '"aaa"', '$.a' RETURNING char(2) OMIT QUOTES DEFAULT '"bb"'::jsonb ON EMPTY) +-- +STMT: SelectStmt +== 118 +-- OMIT QUOTES behavior should not be specified when WITH WRAPPER used: +-- Should fail +SELECT JSON_QUERY(jsonb '[1]', '$' WITH WRAPPER OMIT QUOTES) +-- +STMT: SelectStmt +== 119 +SELECT JSON_QUERY(jsonb '[1]', '$' WITH CONDITIONAL WRAPPER OMIT QUOTES) +-- +STMT: SelectStmt +== 120 +-- Should succeed +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITH CONDITIONAL WRAPPER KEEP QUOTES) +-- +STMT: SelectStmt +== 121 +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITH UNCONDITIONAL WRAPPER KEEP QUOTES) +-- +STMT: SelectStmt +== 122 +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITH WRAPPER KEEP QUOTES) +-- +STMT: SelectStmt +== 123 +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITHOUT WRAPPER OMIT QUOTES) +-- +STMT: SelectStmt +== 124 +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITHOUT WRAPPER KEEP QUOTES) +-- +STMT: SelectStmt +== 125 +-- test QUOTES behavior. +SELECT JSON_QUERY(jsonb'{"rec": "{1,2,3}"}', '$.rec' returning int[] omit quotes) +-- +STMT: SelectStmt +== 126 +SELECT JSON_QUERY(jsonb'{"rec": "{1,2,3}"}', '$.rec' returning int[] keep quotes) +-- +STMT: SelectStmt +== 127 +SELECT JSON_QUERY(jsonb'{"rec": "{1,2,3}"}', '$.rec' returning int[] keep quotes error on error) +-- +STMT: SelectStmt +== 128 +SELECT JSON_QUERY(jsonb'{"rec": "[1,2]"}', '$.rec' returning int4range omit quotes) +-- +STMT: SelectStmt +== 129 +SELECT JSON_QUERY(jsonb'{"rec": "[1,2]"}', '$.rec' returning int4range keep quotes) +-- +STMT: SelectStmt +== 130 +SELECT JSON_QUERY(jsonb'{"rec": "[1,2]"}', '$.rec' returning int4range keep quotes error on error) +-- +STMT: SelectStmt +== 131 +CREATE DOMAIN qf_char_domain AS char(1) +-- +STMT: CreateDomainStmt +== 132 +CREATE DOMAIN qf_jsonb_domain AS jsonb +-- +STMT: CreateDomainStmt +== 133 +SELECT JSON_QUERY(jsonb '"1"', '$' RETURNING qf_char_domain OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +== 134 +SELECT JSON_QUERY(jsonb '"1"', '$' RETURNING qf_jsonb_domain OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +== 135 +DROP DOMAIN qf_char_domain, qf_jsonb_domain +-- +STMT: DropStmt +== 136 +SELECT JSON_QUERY(jsonb '[]', '$[*]') +-- +STMT: SelectStmt +== 137 +SELECT JSON_QUERY(jsonb '[]', '$[*]' NULL ON EMPTY) +-- +STMT: SelectStmt +== 138 +SELECT JSON_QUERY(jsonb '[]', '$[*]' EMPTY ON EMPTY) +-- +STMT: SelectStmt +== 139 +SELECT JSON_QUERY(jsonb '[]', '$[*]' EMPTY ARRAY ON EMPTY) +-- +STMT: SelectStmt +== 140 +SELECT JSON_QUERY(jsonb '[]', '$[*]' EMPTY OBJECT ON EMPTY) +-- +STMT: SelectStmt +== 141 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY) +-- +STMT: SelectStmt +== 142 +SELECT JSON_QUERY(jsonb '[]', '$[*]' DEFAULT '"empty"' ON EMPTY) +-- +STMT: SelectStmt +== 143 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY NULL ON ERROR) +-- +STMT: SelectStmt +== 144 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY EMPTY ARRAY ON ERROR) +-- +STMT: SelectStmt +== 145 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +== 146 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +== 147 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON ERROR) +-- +STMT: SelectStmt +== 148 +-- NULL ON EMPTY + +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' ERROR ON ERROR) +-- +STMT: SelectStmt +== 149 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' DEFAULT '"empty"' ON ERROR) +-- +STMT: SelectStmt +== 150 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING json) +-- +STMT: SelectStmt +== 151 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING json FORMAT JSON) +-- +STMT: SelectStmt +== 152 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING jsonb) +-- +STMT: SelectStmt +== 153 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING jsonb FORMAT JSON) +-- +STMT: SelectStmt +== 154 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING text) +-- +STMT: SelectStmt +== 155 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING char(10)) +-- +STMT: SelectStmt +== 156 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING text FORMAT JSON) +-- +STMT: SelectStmt +== 157 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING bytea) +-- +STMT: SelectStmt +== 158 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING bytea FORMAT JSON) +-- +STMT: SelectStmt +== 159 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' RETURNING bytea EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +== 160 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' RETURNING bytea FORMAT JSON EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +== 161 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' RETURNING json EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +== 162 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' RETURNING jsonb EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +== 163 +SELECT JSON_QUERY(jsonb '[3,4]', '$[*]' RETURNING bigint[] EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +== 164 +SELECT JSON_QUERY(jsonb '"[3,4]"', '$[*]' RETURNING bigint[] EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +== 165 +-- Coercion fails with quotes on +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING int2 error on error) +-- +STMT: SelectStmt +== 166 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING int4 error on error) +-- +STMT: SelectStmt +== 167 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING int8 error on error) +-- +STMT: SelectStmt +== 168 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING bool error on error) +-- +STMT: SelectStmt +== 169 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING numeric error on error) +-- +STMT: SelectStmt +== 170 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING real error on error) +-- +STMT: SelectStmt +== 171 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING float8 error on error) +-- +STMT: SelectStmt +== 172 +-- Fine with OMIT QUOTES +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING int2 omit quotes error on error) +-- +STMT: SelectStmt +== 173 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING float8 omit quotes error on error) +-- +STMT: SelectStmt +== 174 +-- RETUGNING pseudo-types not allowed +SELECT JSON_QUERY(jsonb '[3,4]', '$[*]' RETURNING anyarray EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +== 175 +SELECT + x, y, + JSON_QUERY( + jsonb '[1,2,3,4,5,null]', + '$[*] ? (@ >= $x && @ <= $y)' + PASSING x AS x, y AS y + WITH CONDITIONAL WRAPPER + EMPTY ARRAY ON EMPTY + ) list +FROM + generate_series(0, 4) x, + generate_series(0, 4) y +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 176 +-- record type returning with quotes behavior. +CREATE TYPE comp_abc AS (a text, b int, c timestamp) +-- +STMT: CompositeTypeStmt +== 177 +SELECT JSON_QUERY(jsonb'{"rec": "(abc,42,01.02.2003)"}', '$.rec' returning comp_abc omit quotes) +-- +STMT: SelectStmt +== 178 +SELECT JSON_QUERY(jsonb'{"rec": "(abc,42,01.02.2003)"}', '$.rec' returning comp_abc keep quotes) +-- +STMT: SelectStmt +== 179 +SELECT JSON_QUERY(jsonb'{"rec": "(abc,42,01.02.2003)"}', '$.rec' returning comp_abc keep quotes error on error) +-- +STMT: SelectStmt +== 180 +DROP TYPE comp_abc +-- +STMT: DropStmt +== 181 +-- Extension: record types returning +CREATE TYPE sqljsonb_rec AS (a int, t text, js json, jb jsonb, jsa json[]) +-- +STMT: CompositeTypeStmt +== 182 +CREATE TYPE sqljsonb_reca AS (reca sqljsonb_rec[]) +-- +STMT: CompositeTypeStmt +== 183 +SELECT JSON_QUERY(jsonb '[{"a": 1, "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING sqljsonb_rec) +-- +STMT: SelectStmt +== 184 +SELECT JSON_QUERY(jsonb '[{"a": "a", "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING sqljsonb_rec ERROR ON ERROR) +-- +STMT: SelectStmt +== 185 +SELECT JSON_QUERY(jsonb '[{"a": "a", "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING sqljsonb_rec) +-- +STMT: SelectStmt +== 186 +SELECT * FROM unnest((JSON_QUERY(jsonb '{"jsa": [{"a": 1, "b": ["foo"]}, {"a": 2, "c": {}}, 123]}', '$' RETURNING sqljsonb_rec)).jsa) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 187 +SELECT * FROM unnest((JSON_QUERY(jsonb '{"reca": [{"a": 1, "t": ["foo", []]}, {"a": 2, "jb": [{}, true]}]}', '$' RETURNING sqljsonb_reca)).reca) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 188 +SELECT JSON_QUERY(jsonb '[{"a": 1, "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING jsonpath) +-- +STMT: SelectStmt +== 189 +SELECT JSON_QUERY(jsonb '[{"a": 1, "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING jsonpath ERROR ON ERROR) +-- +STMT: SelectStmt +== 190 +-- Extension: array types returning +SELECT JSON_QUERY(jsonb '[1,2,null,"3"]', '$[*]' RETURNING int[] WITH WRAPPER) +-- +STMT: SelectStmt +== 191 +SELECT JSON_QUERY(jsonb '[1,2,null,"a"]', '$[*]' RETURNING int[] WITH WRAPPER ERROR ON ERROR) +-- +STMT: SelectStmt +== 192 +SELECT JSON_QUERY(jsonb '[1,2,null,"a"]', '$[*]' RETURNING int[] WITH WRAPPER) +-- +STMT: SelectStmt +== 193 +SELECT * FROM unnest(JSON_QUERY(jsonb '[{"a": 1, "t": ["foo", []]}, {"a": 2, "jb": [{}, true]}]', '$' RETURNING sqljsonb_rec[])) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 194 +-- Extension: domain types returning +SELECT JSON_QUERY(jsonb '{"a": 1}', '$.a' RETURNING sqljsonb_int_not_null) +-- +STMT: SelectStmt +== 195 +SELECT JSON_QUERY(jsonb '{"a": 1}', '$.b' RETURNING sqljsonb_int_not_null) +-- +STMT: SelectStmt +== 196 +SELECT JSON_QUERY(jsonb '{"a": 1}', '$.b' RETURNING sqljsonb_int_not_null ERROR ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +== 197 +-- Test timestamptz passing and output +SELECT JSON_QUERY(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts) +-- +STMT: SelectStmt +== 198 +SELECT JSON_QUERY(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING json) +-- +STMT: SelectStmt +== 199 +SELECT JSON_QUERY(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING jsonb) +-- +STMT: SelectStmt +== 200 +-- Test constraints + +CREATE TABLE test_jsonb_constraints ( + js text, + i int, + x jsonb DEFAULT JSON_QUERY(jsonb '[1,2]', '$[*]' WITH WRAPPER) + CONSTRAINT test_jsonb_constraint1 + CHECK (js IS JSON) + CONSTRAINT test_jsonb_constraint2 + CHECK (JSON_EXISTS(js::jsonb, '$.a' PASSING i + 5 AS int, i::text AS "TXT", array[1,2,3] as arr)) + CONSTRAINT test_jsonb_constraint3 + CHECK (JSON_VALUE(js::jsonb, '$.a' RETURNING int DEFAULT '12' ON EMPTY ERROR ON ERROR) > i) + CONSTRAINT test_jsonb_constraint4 + CHECK (JSON_QUERY(js::jsonb, '$.a' WITH CONDITIONAL WRAPPER EMPTY OBJECT ON ERROR) = jsonb '[10]') + CONSTRAINT test_jsonb_constraint5 + CHECK (JSON_QUERY(js::jsonb, '$.a' RETURNING char(5) OMIT QUOTES EMPTY ARRAY ON EMPTY) > 'a' COLLATE "C") +) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DDL +STMT: CreateStmt +== 201 +SELECT check_clause +FROM information_schema.check_constraints +WHERE constraint_name LIKE 'test_jsonb_constraint%' +ORDER BY 1 +-- +TABLE: name="information_schema.check_constraints" schema="information_schema" table="check_constraints" ctx=Select +FILTER: schema="" table="" column="constraint_name" +STMT: SelectStmt +== 202 +SELECT pg_get_expr(adbin, adrelid) +FROM pg_attrdef +WHERE adrelid = 'test_jsonb_constraints'::regclass +ORDER BY 1 +-- +TABLE: name="pg_attrdef" schema="" table="pg_attrdef" ctx=Select +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="" column="adrelid" +STMT: SelectStmt +== 203 +INSERT INTO test_jsonb_constraints VALUES ('', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 204 +INSERT INTO test_jsonb_constraints VALUES ('1', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 205 +INSERT INTO test_jsonb_constraints VALUES ('[]') +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 206 +INSERT INTO test_jsonb_constraints VALUES ('{"b": 1}', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 207 +INSERT INTO test_jsonb_constraints VALUES ('{"a": 1}', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 208 +INSERT INTO test_jsonb_constraints VALUES ('{"a": 10}', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 209 +DROP TABLE test_jsonb_constraints +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DDL +STMT: DropStmt +== 210 +-- Test mutabilily of query functions +CREATE TABLE test_jsonb_mutability(js jsonb, b int) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: CreateStmt +== 211 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 212 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a[0]')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 213 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.time()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 214 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.date()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 215 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.time_tz()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 216 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.timestamp()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 217 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.timestamp_tz()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 218 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.date() < $.time_tz())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 219 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.date() < $.time())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 220 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.time() < $.time())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 221 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.time() < $.time_tz())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 222 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp() < $.timestamp_tz())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 223 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp_tz() < $.timestamp_tz())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 224 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.time() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 225 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.date() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 226 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 227 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp() < $.datetime("HH:MI"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 228 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp_tz() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 229 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp_tz() < $.datetime("HH:MI"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 230 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.date() < $x' PASSING '12:34'::timetz AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 231 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.date() < $x' PASSING '1234'::int AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 232 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp(2) < $.timestamp(3))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 233 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 234 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@ < $.datetime())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 235 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime() < $.datetime())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 236 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 237 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime("HH:MI TZH") < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 238 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime("HH:MI") < $.datetime("YY-MM-DD HH:MI"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 239 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime("HH:MI TZH") < $.datetime("YY-MM-DD HH:MI"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 240 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime("HH:MI TZH") < $x' PASSING '12:34'::timetz AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 241 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime("HH:MI TZH") < $y' PASSING '12:34'::timetz AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 242 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime() < $x' PASSING '12:34'::timetz AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 243 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime() < $x' PASSING '1234'::int AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 244 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime() ? (@ == $x)' PASSING '12:34'::time AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 245 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime("YY-MM-DD") ? (@ == $x)' PASSING '2020-07-14'::date AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 246 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$[1, $.a ? (@.datetime() == $x)]' PASSING '12:34'::time AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 247 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$[1, 0 to $.a ? (@.datetime() == $x)]' PASSING '12:34'::time AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 248 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$[1, $.a ? (@.datetime("HH:MI") == $x)]' PASSING '12:34'::time AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +== 249 +CREATE INDEX ON test_jsonb_mutability (JSON_VALUE(js, '$' DEFAULT random()::int ON ERROR)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: IndexStmt +== 250 +-- DEFAULT expression +CREATE OR REPLACE FUNCTION ret_setint() RETURNS SETOF integer AS +$$ +BEGIN + RETURN QUERY EXECUTE 'select 1 union all select 1'; +END; +$$ +LANGUAGE plpgsql IMMUTABLE +-- +FUNCTION: name="ret_setint" function="ret_setint" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 251 +SELECT JSON_QUERY(js, '$' RETURNING int DEFAULT ret_setint() ON ERROR) FROM test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=Select +FUNCTION: name="ret_setint" function="ret_setint" schema="" ctx=Call +STMT: SelectStmt +== 252 +SELECT JSON_QUERY(js, '$' RETURNING int DEFAULT b + 1 ON ERROR) FROM test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=Select +STMT: SelectStmt +== 253 +SELECT JSON_QUERY(js, '$' RETURNING int DEFAULT sum(1) over() ON ERROR) FROM test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 254 +SELECT JSON_QUERY(js, '$' RETURNING int DEFAULT (SELECT 1) ON ERROR) FROM test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=Select +STMT: SelectStmt +== 255 +DROP TABLE test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: DropStmt +== 256 +DROP FUNCTION ret_setint +-- +FUNCTION: name="ret_setint" function="ret_setint" schema="" ctx=DDL +STMT: DropStmt +== 257 +CREATE DOMAIN queryfuncs_test_domain AS text CHECK (value <> 'foo') +-- +STMT: CreateDomainStmt +== 258 +SELECT JSON_VALUE(jsonb '{"d1": "H"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT 'foo'::queryfuncs_test_domain ON EMPTY) +-- +STMT: SelectStmt +== 259 +SELECT JSON_VALUE(jsonb '{"d1": "H"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT 'foo1'::queryfuncs_test_domain ON EMPTY) +-- +STMT: SelectStmt +== 260 +SELECT JSON_VALUE(jsonb '{"d1": "H"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT '"foo1"'::jsonb::text ON EMPTY) +-- +STMT: SelectStmt +== 261 +SELECT JSON_VALUE(jsonb '{"d1": "foo"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT 'foo1'::queryfuncs_test_domain ON EMPTY) +-- +STMT: SelectStmt +== 262 +-- Check the cases where a coercion-related expression is masking an +-- unsupported expressions + +-- CoerceViaIO +SELECT JSON_QUERY('"a"', '$.a' RETURNING int DEFAULT (SELECT '"1"')::jsonb ON ERROR) +-- +STMT: SelectStmt +== 263 +-- CoerceToDomain +SELECT JSON_QUERY('"a"', '$.a' RETURNING queryfuncs_test_domain DEFAULT (select '"1"')::queryfuncs_test_domain ON ERROR) +-- +STMT: SelectStmt +== 264 +-- RelabelType +SELECT JSON_QUERY('"a"', '$.a' RETURNING int DEFAULT (SELECT 1)::oid::int ON ERROR) +-- +STMT: SelectStmt +== 265 +-- ArrayCoerceExpr +SELECT JSON_QUERY('"a"', '$.a' RETURNING int[] DEFAULT (SELECT '{1}')::oid[]::int[] ON ERROR) +-- +STMT: SelectStmt +== 266 +-- CollateExpr +SELECT JSON_QUERY('"a"', '$.a' RETURNING int[] DEFAULT (SELECT '{1}')::text COLLATE "C" ON ERROR) +-- +STMT: SelectStmt +== 267 +-- ConvertRowtypeExpr +CREATE TABLE someparent (a int) +-- +TABLE: name="someparent" schema="" table="someparent" ctx=DDL +STMT: CreateStmt +== 268 +CREATE TABLE somechild () INHERITS (someparent) +-- +TABLE: name="somechild" schema="" table="somechild" ctx=DDL +STMT: CreateStmt +== 269 +SELECT JSON_QUERY('"a"', '$.a' RETURNING someparent DEFAULT (SELECT '(1)')::somechild::someparent ON ERROR) +-- +STMT: SelectStmt +== 270 +DROP DOMAIN queryfuncs_test_domain +-- +STMT: DropStmt +== 271 +DROP TABLE someparent, somechild +-- +TABLE: name="someparent" schema="" table="someparent" ctx=DDL +TABLE: name="somechild" schema="" table="somechild" ctx=DDL +STMT: DropStmt +== 272 +-- Extension: non-constant JSON path +SELECT JSON_EXISTS(jsonb '{"a": 123}', '$' || '.' || 'a') +-- +STMT: SelectStmt +== 273 +SELECT JSON_VALUE(jsonb '{"a": 123}', '$' || '.' || 'a') +-- +STMT: SelectStmt +== 274 +SELECT JSON_VALUE(jsonb '{"a": 123}', '$' || '.' || 'b' DEFAULT 'foo' ON EMPTY) +-- +STMT: SelectStmt +== 275 +SELECT JSON_QUERY(jsonb '{"a": 123}', '$' || '.' || 'a') +-- +STMT: SelectStmt +== 276 +SELECT JSON_QUERY(jsonb '{"a": 123}', '$' || '.' || 'a' WITH WRAPPER) +-- +STMT: SelectStmt +== 277 +-- Should fail (invalid path) +SELECT JSON_QUERY(jsonb '{"a": 123}', 'error' || ' ' || 'error') +-- +STMT: SelectStmt +== 278 +-- Non-jsonb inputs automatically coerced to jsonb +SELECT JSON_EXISTS(json '{"a": 123}', '$' || '.' || 'a') +-- +STMT: SelectStmt +== 279 +SELECT JSON_QUERY(NULL FORMAT JSON, '$') +-- +STMT: SelectStmt +== 280 +-- Test non-const jsonpath +CREATE TEMP TABLE jsonpaths (path) AS SELECT '$' +-- +TABLE: name="jsonpaths" schema="" table="jsonpaths" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 281 +SELECT json_value('"aaa"', path RETURNING json) FROM jsonpaths +-- +TABLE: name="jsonpaths" schema="" table="jsonpaths" ctx=Select +STMT: SelectStmt +== 282 +-- Test PASSING argument parsing +SELECT JSON_QUERY(jsonb 'null', '$xyz' PASSING 1 AS xy) +-- +STMT: SelectStmt +== 283 +SELECT JSON_QUERY(jsonb 'null', '$xy' PASSING 1 AS xyz) +-- +STMT: SelectStmt +== 284 +SELECT JSON_QUERY(jsonb 'null', '$xyz' PASSING 1 AS xyz) +-- +STMT: SelectStmt +== 285 +SELECT JSON_QUERY(jsonb 'null', '$Xyz' PASSING 1 AS Xyz) +-- +STMT: SelectStmt +== 286 +SELECT JSON_QUERY(jsonb 'null', '$Xyz' PASSING 1 AS "Xyz") +-- +STMT: SelectStmt +== 287 +SELECT JSON_QUERY(jsonb 'null', '$"Xyz"' PASSING 1 AS "Xyz") +-- +STMT: SelectStmt +== 288 +-- Test ON ERROR / EMPTY value validity for the function; all fail. +SELECT JSON_EXISTS(jsonb '1', '$' DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +== 289 +SELECT JSON_VALUE(jsonb '1', '$' EMPTY ON ERROR) +-- +STMT: SelectStmt +== 290 +SELECT JSON_QUERY(jsonb '1', '$' TRUE ON ERROR) +-- +STMT: SelectStmt +== 291 +-- Test implicit coercion to a domain over fixed-length type specified in +-- RETURNING +CREATE DOMAIN queryfuncs_char2 AS char(2) +-- +STMT: CreateDomainStmt +== 292 +CREATE DOMAIN queryfuncs_char2_chk AS char(2) CHECK (VALUE NOT IN ('12')) +-- +STMT: CreateDomainStmt +== 293 +SELECT JSON_QUERY(jsonb '123', '$' RETURNING queryfuncs_char2 ERROR ON ERROR) +-- +STMT: SelectStmt +== 294 +SELECT JSON_QUERY(jsonb '123', '$' RETURNING queryfuncs_char2 DEFAULT '1' ON ERROR) +-- +STMT: SelectStmt +== 295 +SELECT JSON_QUERY(jsonb '123', '$' RETURNING queryfuncs_char2_chk ERROR ON ERROR) +-- +STMT: SelectStmt +== 296 +SELECT JSON_QUERY(jsonb '123', '$' RETURNING queryfuncs_char2_chk DEFAULT '1' ON ERROR) +-- +STMT: SelectStmt +== 297 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING queryfuncs_char2 ERROR ON ERROR) +-- +STMT: SelectStmt +== 298 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING queryfuncs_char2 DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +== 299 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING queryfuncs_char2_chk ERROR ON ERROR) +-- +STMT: SelectStmt +== 300 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING queryfuncs_char2_chk DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +== 301 +DROP DOMAIN queryfuncs_char2, queryfuncs_char2_chk +-- +STMT: DropStmt +== 302 +-- Test coercion to domain over another fixed-length type of the ON ERROR / +-- EMPTY expressions. Ask user to cast the DEFAULT expression explicitly if +-- automatic casting cannot be done, for example, from int to bit(2). +CREATE DOMAIN queryfuncs_d_varbit3 AS varbit(3) CHECK (VALUE <> '01') +-- +STMT: CreateDomainStmt +== 303 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING queryfuncs_d_varbit3 DEFAULT '111111' ON ERROR) +-- +STMT: SelectStmt +== 304 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING queryfuncs_d_varbit3 DEFAULT '010' ON ERROR) +-- +STMT: SelectStmt +== 305 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING queryfuncs_d_varbit3 DEFAULT '01' ON ERROR) +-- +STMT: SelectStmt +== 306 +SELECT JSON_VALUE(jsonb '"111"', '$' RETURNING bit(2) ERROR ON ERROR) +-- +STMT: SelectStmt +== 307 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING bit(3) DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +== 308 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING bit(3) DEFAULT 1::bit(3) ON ERROR) +-- +STMT: SelectStmt +== 309 +SELECT JSON_VALUE(jsonb '"111"', '$.a' RETURNING bit(3) DEFAULT '1111' ON EMPTY) +-- +STMT: SelectStmt +== 310 +DROP DOMAIN queryfuncs_d_varbit3 +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/stats.metadata.json b/parser/testdata/summary/postgres_regress/stats.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/stats.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/stats.test b/parser/testdata/summary/postgres_regress/stats.test new file mode 100644 index 0000000..e8240f4 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/stats.test @@ -0,0 +1,2782 @@ +== 001 +|-- +-- Test cumulative stats system +|-- +-- Must be run after tenk2 has been created (by create_table), +-- populated (by create_misc) and indexed (by create_index). +|-- + +-- conditio sine qua non +SHOW track_counts +-- +STMT: VariableShowStmt +== 002 +-- must be on + +-- ensure that both seqscan and indexscan plans are allowed +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +== 003 +SET enable_indexscan TO on +-- +STMT: VariableSetStmt +== 004 +-- for the moment, we don't want index-only scans here +SET enable_indexonlyscan TO off +-- +STMT: VariableSetStmt +== 005 +-- not enabled by default, but we want to test it... +SET track_functions TO 'all' +-- +STMT: VariableSetStmt +== 006 +-- record dboid for later use +SELECT oid AS dboid from pg_database where datname = current_database() +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +== 007 +-- save counters +BEGIN +-- +STMT: TransactionStmt +== 008 +SET LOCAL stats_fetch_consistency = snapshot +-- +STMT: VariableSetStmt +== 009 +CREATE TABLE prevstats AS +SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch, + (b.heap_blks_read + b.heap_blks_hit) AS heap_blks, + (b.idx_blks_read + b.idx_blks_hit) AS idx_blks, + pg_stat_get_snapshot_timestamp() as snap_ts + FROM pg_catalog.pg_stat_user_tables AS t, + pg_catalog.pg_statio_user_tables AS b + WHERE t.relname='tenk2' AND b.relname='tenk2' +-- +TABLE: name="prevstats" schema="" table="prevstats" ctx=DDL +TABLE: name="pg_catalog.pg_stat_user_tables" schema="pg_catalog" table="pg_stat_user_tables" ctx=Select +TABLE: name="pg_catalog.pg_statio_user_tables" schema="pg_catalog" table="pg_statio_user_tables" ctx=Select +ALIAS: "b"="pg_catalog.pg_statio_user_tables" +ALIAS: "t"="pg_catalog.pg_stat_user_tables" +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +FILTER: schema="" table="t" column="relname" +FILTER: schema="" table="b" column="relname" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 010 +COMMIT +-- +STMT: TransactionStmt +== 011 +-- test effects of TRUNCATE on n_live_tup/n_dead_tup counters +CREATE TABLE trunc_stats_test(id serial) +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DDL +STMT: CreateStmt +== 012 +CREATE TABLE trunc_stats_test1(id serial, stuff text) +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DDL +STMT: CreateStmt +== 013 +CREATE TABLE trunc_stats_test2(id serial) +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DDL +STMT: CreateStmt +== 014 +CREATE TABLE trunc_stats_test3(id serial, stuff text) +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DDL +STMT: CreateStmt +== 015 +CREATE TABLE trunc_stats_test4(id serial) +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DDL +STMT: CreateStmt +== 016 +-- check that n_live_tup is reset to 0 after truncate +INSERT INTO trunc_stats_test DEFAULT VALUES +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DML +STMT: InsertStmt +== 017 +INSERT INTO trunc_stats_test DEFAULT VALUES +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DML +STMT: InsertStmt +== 018 +INSERT INTO trunc_stats_test DEFAULT VALUES +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DML +STMT: InsertStmt +== 019 +TRUNCATE trunc_stats_test +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DDL +STMT: TruncateStmt +== 020 +-- test involving a truncate in a transaction; 4 ins but only 1 live +INSERT INTO trunc_stats_test1 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: InsertStmt +== 021 +INSERT INTO trunc_stats_test1 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: InsertStmt +== 022 +INSERT INTO trunc_stats_test1 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: InsertStmt +== 023 +UPDATE trunc_stats_test1 SET id = id + 10 WHERE id IN (1, 2) +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: UpdateStmt +== 024 +DELETE FROM trunc_stats_test1 WHERE id = 3 +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: DeleteStmt +== 025 +BEGIN +-- +STMT: TransactionStmt +== 026 +UPDATE trunc_stats_test1 SET id = id + 100 +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: UpdateStmt +== 027 +TRUNCATE trunc_stats_test1 +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DDL +STMT: TruncateStmt +== 028 +INSERT INTO trunc_stats_test1 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: InsertStmt +== 029 +COMMIT +-- +STMT: TransactionStmt +== 030 +-- use a savepoint: 1 insert, 1 live +BEGIN +-- +STMT: TransactionStmt +== 031 +INSERT INTO trunc_stats_test2 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DML +STMT: InsertStmt +== 032 +INSERT INTO trunc_stats_test2 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DML +STMT: InsertStmt +== 033 +SAVEPOINT p1 +-- +STMT: TransactionStmt +== 034 +INSERT INTO trunc_stats_test2 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DML +STMT: InsertStmt +== 035 +TRUNCATE trunc_stats_test2 +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DDL +STMT: TruncateStmt +== 036 +INSERT INTO trunc_stats_test2 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DML +STMT: InsertStmt +== 037 +RELEASE SAVEPOINT p1 +-- +STMT: TransactionStmt +== 038 +COMMIT +-- +STMT: TransactionStmt +== 039 +-- rollback a savepoint: this should count 4 inserts and have 2 +-- live tuples after commit (and 2 dead ones due to aborted subxact) +BEGIN +-- +STMT: TransactionStmt +== 040 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +== 041 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +== 042 +SAVEPOINT p1 +-- +STMT: TransactionStmt +== 043 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +== 044 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +== 045 +TRUNCATE trunc_stats_test3 +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DDL +STMT: TruncateStmt +== 046 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +== 047 +ROLLBACK TO SAVEPOINT p1 +-- +STMT: TransactionStmt +== 048 +COMMIT +-- +STMT: TransactionStmt +== 049 +-- rollback a truncate: this should count 2 inserts and produce 2 dead tuples +BEGIN +-- +STMT: TransactionStmt +== 050 +INSERT INTO trunc_stats_test4 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DML +STMT: InsertStmt +== 051 +INSERT INTO trunc_stats_test4 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DML +STMT: InsertStmt +== 052 +TRUNCATE trunc_stats_test4 +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DDL +STMT: TruncateStmt +== 053 +INSERT INTO trunc_stats_test4 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DML +STMT: InsertStmt +== 054 +ROLLBACK +-- +STMT: TransactionStmt +== 055 +-- do a seqscan +SELECT count(*) FROM tenk2 +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- do an indexscan +-- make sure it is not a bitmap scan, which might skip fetching heap tuples +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +== 057 +SELECT count(*) FROM tenk2 WHERE unique1 = 1 +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 058 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 059 +-- ensure pending stats are flushed +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 060 +-- check effects +BEGIN +-- +STMT: TransactionStmt +== 061 +SET LOCAL stats_fetch_consistency = snapshot +-- +STMT: VariableSetStmt +== 062 +SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup + FROM pg_stat_user_tables + WHERE relname like 'trunc_stats_test%' order by relname +-- +TABLE: name="pg_stat_user_tables" schema="" table="pg_stat_user_tables" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 063 +SELECT st.seq_scan >= pr.seq_scan + 1, + st.seq_tup_read >= pr.seq_tup_read + cl.reltuples, + st.idx_scan >= pr.idx_scan + 1, + st.idx_tup_fetch >= pr.idx_tup_fetch + 1 + FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr + WHERE st.relname='tenk2' AND cl.relname='tenk2' +-- +TABLE: name="pg_stat_user_tables" schema="" table="pg_stat_user_tables" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="prevstats" schema="" table="prevstats" ctx=Select +ALIAS: "cl"="pg_class" +ALIAS: "pr"="prevstats" +ALIAS: "st"="pg_stat_user_tables" +FILTER: schema="" table="st" column="relname" +FILTER: schema="" table="cl" column="relname" +STMT: SelectStmt +== 064 +SELECT st.heap_blks_read + st.heap_blks_hit >= pr.heap_blks + cl.relpages, + st.idx_blks_read + st.idx_blks_hit >= pr.idx_blks + 1 + FROM pg_statio_user_tables AS st, pg_class AS cl, prevstats AS pr + WHERE st.relname='tenk2' AND cl.relname='tenk2' +-- +TABLE: name="pg_statio_user_tables" schema="" table="pg_statio_user_tables" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="prevstats" schema="" table="prevstats" ctx=Select +ALIAS: "cl"="pg_class" +ALIAS: "pr"="prevstats" +ALIAS: "st"="pg_statio_user_tables" +FILTER: schema="" table="st" column="relname" +FILTER: schema="" table="cl" column="relname" +STMT: SelectStmt +== 065 +SELECT pr.snap_ts < pg_stat_get_snapshot_timestamp() as snapshot_newer +FROM prevstats AS pr +-- +TABLE: name="prevstats" schema="" table="prevstats" ctx=Select +ALIAS: "pr"="prevstats" +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 066 +COMMIT +-- +STMT: TransactionStmt +== 067 +---- +-- Basic tests for track_functions +--- +CREATE FUNCTION stats_test_func1() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN END;$$ +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 068 +SELECT 'stats_test_func1()'::regprocedure::oid AS stats_test_func1_oid +-- +STMT: SelectStmt +== 069 +CREATE FUNCTION stats_test_func2() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN END;$$ +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 070 +SELECT 'stats_test_func2()'::regprocedure::oid AS stats_test_func2_oid +-- +STMT: SelectStmt +== 071 +-- test that stats are accumulated +BEGIN +-- +STMT: TransactionStmt +== 072 +SET LOCAL stats_fetch_consistency = none +-- +STMT: VariableSetStmt +== 073 +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 074 +SELECT pg_stat_get_xact_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 075 +SELECT stats_test_func1() +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT pg_stat_get_xact_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 077 +SELECT stats_test_func1() +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT pg_stat_get_xact_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 079 +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 080 +COMMIT +-- +STMT: TransactionStmt +== 081 +-- Verify that function stats are not transactional + +-- rolled back savepoint in committing transaction +BEGIN +-- +STMT: TransactionStmt +== 082 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +== 083 +SAVEPOINT foo +-- +STMT: TransactionStmt +== 084 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +== 085 +ROLLBACK TO SAVEPOINT foo +-- +STMT: TransactionStmt +== 086 +SELECT pg_stat_get_xact_function_calls(:stats_test_func2_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 087 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +== 088 +COMMIT +-- +STMT: TransactionStmt +== 089 +-- rolled back transaction +BEGIN +-- +STMT: TransactionStmt +== 090 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +== 091 +ROLLBACK +-- +STMT: TransactionStmt +== 092 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 093 +-- check collected stats +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 92 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 094 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func2_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 095 +-- check that a rolled back drop function stats leaves stats alive +BEGIN +-- +STMT: TransactionStmt +== 096 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 097 +DROP FUNCTION stats_test_func1() +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=DDL +STMT: DropStmt +== 098 +-- shouldn't be visible via view +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 100 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 099 +-- but still via oid access +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 100 +ROLLBACK +-- +STMT: TransactionStmt +== 101 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 102 +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 103 +-- check that function dropped in main transaction leaves no stats behind +BEGIN +-- +STMT: TransactionStmt +== 104 +DROP FUNCTION stats_test_func1() +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=DDL +STMT: DropStmt +== 105 +COMMIT +-- +STMT: TransactionStmt +== 106 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 107 +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 108 +-- check that function dropped in a subtransaction leaves no stats behind +BEGIN +-- +STMT: TransactionStmt +== 109 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +== 110 +SAVEPOINT a +-- +STMT: TransactionStmt +== 111 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +== 112 +SAVEPOINT b +-- +STMT: TransactionStmt +== 113 +DROP FUNCTION stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=DDL +STMT: DropStmt +== 114 +COMMIT +-- +STMT: TransactionStmt +== 115 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func2_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 116 +SELECT pg_stat_get_function_calls(:stats_test_func2_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 117 +-- Check that stats for relations are dropped. For that we need to access stats +-- by oid after the DROP TABLE. Save oids. +CREATE TABLE drop_stats_test() +-- +TABLE: name="drop_stats_test" schema="" table="drop_stats_test" ctx=DDL +STMT: CreateStmt +== 118 +INSERT INTO drop_stats_test DEFAULT VALUES +-- +TABLE: name="drop_stats_test" schema="" table="drop_stats_test" ctx=DML +STMT: InsertStmt +== 119 +SELECT 'drop_stats_test'::regclass::oid AS drop_stats_test_oid +-- +STMT: SelectStmt +== 120 +CREATE TABLE drop_stats_test_xact() +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DDL +STMT: CreateStmt +== 121 +INSERT INTO drop_stats_test_xact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DML +STMT: InsertStmt +== 122 +SELECT 'drop_stats_test_xact'::regclass::oid AS drop_stats_test_xact_oid +-- +STMT: SelectStmt +== 123 +CREATE TABLE drop_stats_test_subxact() +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DDL +STMT: CreateStmt +== 124 +INSERT INTO drop_stats_test_subxact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DML +STMT: InsertStmt +== 125 +SELECT 'drop_stats_test_subxact'::regclass::oid AS drop_stats_test_subxact_oid +-- +STMT: SelectStmt +== 126 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 127 +SELECT pg_stat_get_live_tuples(:drop_stats_test_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 128 +DROP TABLE drop_stats_test +-- +TABLE: name="drop_stats_test" schema="" table="drop_stats_test" ctx=DDL +STMT: DropStmt +== 129 +SELECT pg_stat_get_live_tuples(:drop_stats_test_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 130 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 131 +-- check that rollback protects against having stats dropped and that local +-- modifications don't pose a problem +SELECT pg_stat_get_live_tuples(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 146 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 132 +SELECT pg_stat_get_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 133 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 134 +BEGIN +-- +STMT: TransactionStmt +== 135 +INSERT INTO drop_stats_test_xact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DML +STMT: InsertStmt +== 136 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 137 +DROP TABLE drop_stats_test_xact +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DDL +STMT: DropStmt +== 138 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 139 +ROLLBACK +-- +STMT: TransactionStmt +== 140 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 141 +SELECT pg_stat_get_live_tuples(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 142 +SELECT pg_stat_get_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 143 +-- transactional drop +SELECT pg_stat_get_live_tuples(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 54 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 144 +SELECT pg_stat_get_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 145 +BEGIN +-- +STMT: TransactionStmt +== 146 +INSERT INTO drop_stats_test_xact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DML +STMT: InsertStmt +== 147 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 148 +DROP TABLE drop_stats_test_xact +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DDL +STMT: DropStmt +== 149 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 150 +COMMIT +-- +STMT: TransactionStmt +== 151 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 152 +SELECT pg_stat_get_live_tuples(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 153 +SELECT pg_stat_get_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 154 +-- savepoint rollback (2 levels) +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 65 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 155 +BEGIN +-- +STMT: TransactionStmt +== 156 +INSERT INTO drop_stats_test_subxact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DML +STMT: InsertStmt +== 157 +SAVEPOINT sp1 +-- +STMT: TransactionStmt +== 158 +INSERT INTO drop_stats_test_subxact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DML +STMT: InsertStmt +== 159 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 160 +SAVEPOINT sp2 +-- +STMT: TransactionStmt +== 161 +DROP TABLE drop_stats_test_subxact +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DDL +STMT: DropStmt +== 162 +ROLLBACK TO SAVEPOINT sp2 +-- +STMT: TransactionStmt +== 163 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 164 +COMMIT +-- +STMT: TransactionStmt +== 165 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 166 +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 167 +-- savepoint rolback (1 level) +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 168 +BEGIN +-- +STMT: TransactionStmt +== 169 +SAVEPOINT sp1 +-- +STMT: TransactionStmt +== 170 +DROP TABLE drop_stats_test_subxact +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DDL +STMT: DropStmt +== 171 +SAVEPOINT sp2 +-- +STMT: TransactionStmt +== 172 +ROLLBACK TO SAVEPOINT sp1 +-- +STMT: TransactionStmt +== 173 +COMMIT +-- +STMT: TransactionStmt +== 174 +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 175 +-- and now actually drop +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 176 +BEGIN +-- +STMT: TransactionStmt +== 177 +SAVEPOINT sp1 +-- +STMT: TransactionStmt +== 178 +DROP TABLE drop_stats_test_subxact +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DDL +STMT: DropStmt +== 179 +SAVEPOINT sp2 +-- +STMT: TransactionStmt +== 180 +RELEASE SAVEPOINT sp1 +-- +STMT: TransactionStmt +== 181 +COMMIT +-- +STMT: TransactionStmt +== 182 +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 183 +DROP TABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats_test4 +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DDL +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DDL +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DDL +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DDL +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DDL +STMT: DropStmt +== 184 +DROP TABLE prevstats +-- +TABLE: name="prevstats" schema="" table="prevstats" ctx=DDL +STMT: DropStmt +== 185 +----- +-- Test that last_seq_scan, last_idx_scan are correctly maintained +|-- +-- Perform test using a temporary table. That way autovacuum etc won't +-- interfere. To be able to check that timestamps increase, we sleep for 100ms +-- between tests, assuming that there aren't systems with a coarser timestamp +-- granularity. +----- + +BEGIN +-- +STMT: TransactionStmt +== 186 +CREATE TEMPORARY TABLE test_last_scan(idx_col int primary key, noidx_col int) +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=DDL +STMT: CreateStmt +== 187 +INSERT INTO test_last_scan(idx_col, noidx_col) VALUES(1, 1) +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 189 +SELECT last_seq_scan, last_idx_scan FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +== 190 +COMMIT +-- +STMT: TransactionStmt +== 191 +SELECT pg_stat_reset_single_table_counters('test_last_scan'::regclass) +-- +FUNCTION: name="pg_stat_reset_single_table_counters" function="pg_stat_reset_single_table_counters" schema="" ctx=Call +STMT: SelectStmt +== 192 +SELECT seq_scan, idx_scan FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +== 193 +-- ensure we start out with exactly one index and sequential scan +BEGIN +-- +STMT: TransactionStmt +== 194 +SET LOCAL enable_seqscan TO on +-- +STMT: VariableSetStmt +== 195 +SET LOCAL enable_indexscan TO on +-- +STMT: VariableSetStmt +== 196 +SET LOCAL enable_bitmapscan TO off +-- +STMT: VariableSetStmt +== 197 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE noidx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="noidx_col" +STMT: ExplainStmt +STMT: SelectStmt +== 198 +SELECT count(*) FROM test_last_scan WHERE noidx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="noidx_col" +STMT: SelectStmt +== 199 +SET LOCAL enable_seqscan TO off +-- +STMT: VariableSetStmt +== 200 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: ExplainStmt +STMT: SelectStmt +== 201 +SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: SelectStmt +== 202 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 203 +COMMIT +-- +STMT: TransactionStmt +== 204 +-- fetch timestamps from before the next test +SELECT last_seq_scan AS test_last_seq, last_idx_scan AS test_last_idx +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +== 205 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 206 +-- assume a minimum timestamp granularity of 100ms + +-- cause one sequential scan +BEGIN +-- +STMT: TransactionStmt +== 207 +SET LOCAL enable_seqscan TO on +-- +STMT: VariableSetStmt +== 208 +SET LOCAL enable_indexscan TO off +-- +STMT: VariableSetStmt +== 209 +SET LOCAL enable_bitmapscan TO off +-- +STMT: VariableSetStmt +== 210 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE noidx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="noidx_col" +STMT: ExplainStmt +STMT: SelectStmt +== 211 +SELECT count(*) FROM test_last_scan WHERE noidx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="noidx_col" +STMT: SelectStmt +== 212 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 213 +COMMIT +-- +STMT: TransactionStmt +== 214 +-- check that just sequential scan stats were incremented +SELECT seq_scan, :'test_last_seq' < last_seq_scan AS seq_ok, idx_scan, :'test_last_idx' = last_idx_scan AS idx_ok +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +ERROR: syntax error at or near ":" +CURSORPOS: 76 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 215 +-- fetch timestamps from before the next test +SELECT last_seq_scan AS test_last_seq, last_idx_scan AS test_last_idx +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +== 216 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 217 +-- cause one index scan +BEGIN +-- +STMT: TransactionStmt +== 218 +SET LOCAL enable_seqscan TO off +-- +STMT: VariableSetStmt +== 219 +SET LOCAL enable_indexscan TO on +-- +STMT: VariableSetStmt +== 220 +SET LOCAL enable_bitmapscan TO off +-- +STMT: VariableSetStmt +== 221 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: ExplainStmt +STMT: SelectStmt +== 222 +SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: SelectStmt +== 223 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 224 +COMMIT +-- +STMT: TransactionStmt +== 225 +-- check that just index scan stats were incremented +SELECT seq_scan, :'test_last_seq' = last_seq_scan AS seq_ok, idx_scan, :'test_last_idx' < last_idx_scan AS idx_ok +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +ERROR: syntax error at or near ":" +CURSORPOS: 71 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 226 +-- fetch timestamps from before the next test +SELECT last_seq_scan AS test_last_seq, last_idx_scan AS test_last_idx +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +== 227 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 228 +-- cause one bitmap index scan +BEGIN +-- +STMT: TransactionStmt +== 229 +SET LOCAL enable_seqscan TO off +-- +STMT: VariableSetStmt +== 230 +SET LOCAL enable_indexscan TO off +-- +STMT: VariableSetStmt +== 231 +SET LOCAL enable_bitmapscan TO on +-- +STMT: VariableSetStmt +== 232 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: ExplainStmt +STMT: SelectStmt +== 233 +SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: SelectStmt +== 234 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 235 +COMMIT +-- +STMT: TransactionStmt +== 236 +-- check that just index scan stats were incremented +SELECT seq_scan, :'test_last_seq' = last_seq_scan AS seq_ok, idx_scan, :'test_last_idx' < last_idx_scan AS idx_ok +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +ERROR: syntax error at or near ":" +CURSORPOS: 71 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 237 +----- +-- Test reset of some stats for shared table +----- + +-- This updates the comment of the database currently in use in +-- pg_shdescription with a fake value, then sets it back to its +-- original value. +SELECT shobj_description(d.oid, 'pg_database') as description_before + FROM pg_database d WHERE datname = current_database() +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +ALIAS: "d"="pg_database" +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FUNCTION: name="shobj_description" function="shobj_description" schema="" ctx=Call +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +== 238 +-- force some stats in pg_shdescription. +BEGIN +-- +STMT: TransactionStmt +== 239 +SELECT current_database() as datname +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +== 240 +COMMENT ON DATABASE :"datname" IS 'This is a test comment' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 241 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 242 +COMMIT +-- +STMT: TransactionStmt +== 243 +-- check that the stats are reset. +SELECT (n_tup_ins + n_tup_upd) > 0 AS has_data FROM pg_stat_all_tables + WHERE relid = 'pg_shdescription'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +== 244 +SELECT pg_stat_reset_single_table_counters('pg_shdescription'::regclass) +-- +FUNCTION: name="pg_stat_reset_single_table_counters" function="pg_stat_reset_single_table_counters" schema="" ctx=Call +STMT: SelectStmt +== 245 +SELECT (n_tup_ins + n_tup_upd) > 0 AS has_data FROM pg_stat_all_tables + WHERE relid = 'pg_shdescription'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +== 246 +-- set back comment + COMMENT ON DATABASE :"datname" IS :'description_before' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 43 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 247 +COMMENT ON DATABASE :"datname" IS NULL +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 248 +----- +-- Test that various stats views are being properly populated +----- + +-- Test that sessions is incremented when a new session is started in pg_stat_database +SELECT sessions AS db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database()) +-- +TABLE: name="pg_stat_database" schema="" table="pg_stat_database" ctx=Select +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +== 249 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 250 +SELECT sessions > :db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database()) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 251 +-- Test pg_stat_checkpointer checkpointer-related stats, together with pg_stat_wal +SELECT num_requested AS rqst_ckpts_before FROM pg_stat_checkpointer +-- +TABLE: name="pg_stat_checkpointer" schema="" table="pg_stat_checkpointer" ctx=Select +STMT: SelectStmt +== 252 +-- Test pg_stat_wal (and make a temp table so our temp schema exists) +SELECT wal_bytes AS wal_bytes_before FROM pg_stat_wal +-- +TABLE: name="pg_stat_wal" schema="" table="pg_stat_wal" ctx=Select +STMT: SelectStmt +== 253 +CREATE TEMP TABLE test_stats_temp AS SELECT 17 +-- +TABLE: name="test_stats_temp" schema="" table="test_stats_temp" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 254 +DROP TABLE test_stats_temp +-- +TABLE: name="test_stats_temp" schema="" table="test_stats_temp" ctx=DDL +STMT: DropStmt +== 255 +-- Checkpoint twice: The checkpointer reports stats after reporting completion +-- of the checkpoint. But after a second checkpoint we'll see at least the +-- results of the first. +CHECKPOINT +-- +STMT: CheckPointStmt +== 256 +CHECKPOINT +-- +STMT: CheckPointStmt +== 257 +SELECT num_requested > :rqst_ckpts_before FROM pg_stat_checkpointer +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 258 +SELECT wal_bytes > :wal_bytes_before FROM pg_stat_wal +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 259 +-- Test pg_stat_get_backend_idset() and some allied functions. +-- In particular, verify that their notion of backend ID matches +-- our temp schema index. +SELECT (current_schemas(true))[1] = ('pg_temp_' || beid::text) AS match +FROM pg_stat_get_backend_idset() beid +WHERE pg_stat_get_backend_pid(beid) = pg_backend_pid() +-- +FUNCTION: name="pg_stat_get_backend_pid" function="pg_stat_get_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="current_schemas" function="current_schemas" schema="" ctx=Call +FUNCTION: name="pg_stat_get_backend_idset" function="pg_stat_get_backend_idset" schema="" ctx=Call +FUNCTION: name="pg_stat_get_backend_pid" function="pg_stat_get_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="beid" +STMT: SelectStmt +== 260 +----- +-- Test that resetting stats works for reset timestamp +----- + +-- Test that reset_slru with a specified SLRU works. +SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 261 +SELECT stats_reset AS slru_notify_reset_ts FROM pg_stat_slru WHERE name = 'notify' +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 262 +SELECT pg_stat_reset_slru('commit_timestamp') +-- +FUNCTION: name="pg_stat_reset_slru" function="pg_stat_reset_slru" schema="" ctx=Call +STMT: SelectStmt +== 263 +SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 264 +SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 265 +-- Test that multiple SLRUs are reset when no specific SLRU provided to reset function +SELECT pg_stat_reset_slru() +-- +FUNCTION: name="pg_stat_reset_slru" function="pg_stat_reset_slru" schema="" ctx=Call +STMT: SelectStmt +== 266 +SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 267 +SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'notify' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 268 +-- Test that reset_shared with archiver specified as the stats type works +SELECT stats_reset AS archiver_reset_ts FROM pg_stat_archiver +-- +TABLE: name="pg_stat_archiver" schema="" table="pg_stat_archiver" ctx=Select +STMT: SelectStmt +== 269 +SELECT pg_stat_reset_shared('archiver') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +== 270 +SELECT stats_reset > :'archiver_reset_ts'::timestamptz FROM pg_stat_archiver +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 271 +-- Test that reset_shared with bgwriter specified as the stats type works +SELECT stats_reset AS bgwriter_reset_ts FROM pg_stat_bgwriter +-- +TABLE: name="pg_stat_bgwriter" schema="" table="pg_stat_bgwriter" ctx=Select +STMT: SelectStmt +== 272 +SELECT pg_stat_reset_shared('bgwriter') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +== 273 +SELECT stats_reset > :'bgwriter_reset_ts'::timestamptz FROM pg_stat_bgwriter +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 274 +-- Test that reset_shared with checkpointer specified as the stats type works +SELECT stats_reset AS checkpointer_reset_ts FROM pg_stat_checkpointer +-- +TABLE: name="pg_stat_checkpointer" schema="" table="pg_stat_checkpointer" ctx=Select +STMT: SelectStmt +== 275 +SELECT pg_stat_reset_shared('checkpointer') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +== 276 +SELECT stats_reset > :'checkpointer_reset_ts'::timestamptz FROM pg_stat_checkpointer +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 277 +-- Test that reset_shared with recovery_prefetch specified as the stats type works +SELECT stats_reset AS recovery_prefetch_reset_ts FROM pg_stat_recovery_prefetch +-- +TABLE: name="pg_stat_recovery_prefetch" schema="" table="pg_stat_recovery_prefetch" ctx=Select +STMT: SelectStmt +== 278 +SELECT pg_stat_reset_shared('recovery_prefetch') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +== 279 +SELECT stats_reset > :'recovery_prefetch_reset_ts'::timestamptz FROM pg_stat_recovery_prefetch +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 280 +-- Test that reset_shared with slru specified as the stats type works +SELECT max(stats_reset) AS slru_reset_ts FROM pg_stat_slru +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 281 +SELECT pg_stat_reset_shared('slru') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +== 282 +SELECT max(stats_reset) > :'slru_reset_ts'::timestamptz FROM pg_stat_slru +-- +ERROR: syntax error at or near ":" +CURSORPOS: 27 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 283 +-- Test that reset_shared with wal specified as the stats type works +SELECT stats_reset AS wal_reset_ts FROM pg_stat_wal +-- +TABLE: name="pg_stat_wal" schema="" table="pg_stat_wal" ctx=Select +STMT: SelectStmt +== 284 +SELECT pg_stat_reset_shared('wal') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +== 285 +SELECT stats_reset > :'wal_reset_ts'::timestamptz FROM pg_stat_wal +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 286 +-- Test error case for reset_shared with unknown stats type +SELECT pg_stat_reset_shared('unknown') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +== 287 +-- Test that reset works for pg_stat_database + +-- Since pg_stat_database stats_reset starts out as NULL, reset it once first so we have something to compare it to +SELECT pg_stat_reset() +-- +FUNCTION: name="pg_stat_reset" function="pg_stat_reset" schema="" ctx=Call +STMT: SelectStmt +== 288 +SELECT stats_reset AS db_reset_ts FROM pg_stat_database WHERE datname = (SELECT current_database()) +-- +TABLE: name="pg_stat_database" schema="" table="pg_stat_database" ctx=Select +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +== 289 +SELECT pg_stat_reset() +-- +FUNCTION: name="pg_stat_reset" function="pg_stat_reset" schema="" ctx=Call +STMT: SelectStmt +== 290 +SELECT stats_reset > :'db_reset_ts'::timestamptz FROM pg_stat_database WHERE datname = (SELECT current_database()) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 291 +---- +-- pg_stat_get_snapshot_timestamp behavior +---- +BEGIN +-- +STMT: TransactionStmt +== 292 +SET LOCAL stats_fetch_consistency = snapshot +-- +STMT: VariableSetStmt +== 293 +-- no snapshot yet, return NULL +SELECT pg_stat_get_snapshot_timestamp() +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 294 +-- any attempt at accessing stats will build snapshot +SELECT pg_stat_get_function_calls(0) +-- +FUNCTION: name="pg_stat_get_function_calls" function="pg_stat_get_function_calls" schema="" ctx=Call +STMT: SelectStmt +== 295 +SELECT pg_stat_get_snapshot_timestamp() >= NOW() +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 296 +-- shows NULL again after clearing +SELECT pg_stat_clear_snapshot() +-- +FUNCTION: name="pg_stat_clear_snapshot" function="pg_stat_clear_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 297 +SELECT pg_stat_get_snapshot_timestamp() +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 298 +COMMIT +-- +STMT: TransactionStmt +== 299 +---- +-- Changing stats_fetch_consistency in a transaction. +---- +BEGIN +-- +STMT: TransactionStmt +== 300 +-- Stats filled under the cache mode +SET LOCAL stats_fetch_consistency = cache +-- +STMT: VariableSetStmt +== 301 +SELECT pg_stat_get_function_calls(0) +-- +FUNCTION: name="pg_stat_get_function_calls" function="pg_stat_get_function_calls" schema="" ctx=Call +STMT: SelectStmt +== 302 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 303 +-- Success in accessing pre-existing snapshot data. +SET LOCAL stats_fetch_consistency = snapshot +-- +STMT: VariableSetStmt +== 304 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 305 +SELECT pg_stat_get_function_calls(0) +-- +FUNCTION: name="pg_stat_get_function_calls" function="pg_stat_get_function_calls" schema="" ctx=Call +STMT: SelectStmt +== 306 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 307 +-- Snapshot cleared. +SET LOCAL stats_fetch_consistency = none +-- +STMT: VariableSetStmt +== 308 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 309 +SELECT pg_stat_get_function_calls(0) +-- +FUNCTION: name="pg_stat_get_function_calls" function="pg_stat_get_function_calls" schema="" ctx=Call +STMT: SelectStmt +== 310 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 311 +ROLLBACK +-- +STMT: TransactionStmt +== 312 +---- +-- pg_stat_have_stats behavior +---- +-- fixed-numbered stats exist +SELECT pg_stat_have_stats('bgwriter', 0, 0) +-- +FUNCTION: name="pg_stat_have_stats" function="pg_stat_have_stats" schema="" ctx=Call +STMT: SelectStmt +== 313 +-- unknown stats kinds error out +SELECT pg_stat_have_stats('zaphod', 0, 0) +-- +FUNCTION: name="pg_stat_have_stats" function="pg_stat_have_stats" schema="" ctx=Call +STMT: SelectStmt +== 314 +-- db stats have objoid 0 +SELECT pg_stat_have_stats('database', :dboid, 1) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 65 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 315 +SELECT pg_stat_have_stats('database', :dboid, 0) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 316 +-- pg_stat_have_stats returns true for committed index creation +CREATE table stats_test_tab1 as select generate_series(1,10) a +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 317 +CREATE index stats_test_idx1 on stats_test_tab1(a) +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=DDL +STMT: IndexStmt +== 318 +SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid +-- +STMT: SelectStmt +== 319 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +== 320 +select a from stats_test_tab1 where a = 3 +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 321 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 322 +-- pg_stat_have_stats returns false for dropped index with stats +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 104 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 323 +DROP index stats_test_idx1 +-- +STMT: DropStmt +== 324 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 325 +-- pg_stat_have_stats returns false for rolled back index creation +BEGIN +-- +STMT: TransactionStmt +== 326 +CREATE index stats_test_idx1 on stats_test_tab1(a) +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=DDL +STMT: IndexStmt +== 327 +SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid +-- +STMT: SelectStmt +== 328 +select a from stats_test_tab1 where a = 3 +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 329 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 330 +ROLLBACK +-- +STMT: TransactionStmt +== 331 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 332 +-- pg_stat_have_stats returns true for reindex CONCURRENTLY +CREATE index stats_test_idx1 on stats_test_tab1(a) +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=DDL +STMT: IndexStmt +== 333 +SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid +-- +STMT: SelectStmt +== 334 +select a from stats_test_tab1 where a = 3 +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 335 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 336 +REINDEX index CONCURRENTLY stats_test_idx1 +-- +STMT: ReindexStmt +== 337 +-- false for previous oid +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 65 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 338 +-- true for new oid +SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid +-- +STMT: SelectStmt +== 339 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 340 +-- pg_stat_have_stats returns true for a rolled back drop index with stats +BEGIN +-- +STMT: TransactionStmt +== 341 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 342 +DROP index stats_test_idx1 +-- +STMT: DropStmt +== 343 +ROLLBACK +-- +STMT: TransactionStmt +== 344 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 345 +-- put enable_seqscan back to on +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +== 346 +-- ensure that stats accessors handle NULL input correctly +SELECT pg_stat_get_replication_slot(NULL) +-- +FUNCTION: name="pg_stat_get_replication_slot" function="pg_stat_get_replication_slot" schema="" ctx=Call +STMT: SelectStmt +== 347 +SELECT pg_stat_get_subscription_stats(NULL) +-- +FUNCTION: name="pg_stat_get_subscription_stats" function="pg_stat_get_subscription_stats" schema="" ctx=Call +STMT: SelectStmt +== 348 +-- Test that the following operations are tracked in pg_stat_io: +-- - reads of target blocks into shared buffers +-- - writes of shared buffers to permanent storage +-- - extends of relations using shared buffers +-- - fsyncs done to ensure the durability of data dirtying shared buffers +-- - shared buffer hits + +-- There is no test for blocks evicted from shared buffers, because we cannot +-- be sure of the state of shared buffers at the point the test is run. + +-- Create a regular table and insert some data to generate IOCONTEXT_NORMAL +-- extends. +SELECT sum(extends) AS io_sum_shared_before_extends + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 349 +SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs + FROM pg_stat_io + WHERE object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 350 +CREATE TABLE test_io_shared(a int) +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=DDL +STMT: CreateStmt +== 351 +INSERT INTO test_io_shared SELECT i FROM generate_series(1,100)i +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 352 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 353 +SELECT sum(extends) AS io_sum_shared_after_extends + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 354 +SELECT :io_sum_shared_after_extends > :io_sum_shared_before_extends +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 355 +-- After a checkpoint, there should be some additional IOCONTEXT_NORMAL writes +-- and fsyncs. +-- See comment above for rationale for two explicit CHECKPOINTs. +CHECKPOINT +-- +STMT: CheckPointStmt +== 356 +CHECKPOINT +-- +STMT: CheckPointStmt +== 357 +SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs + FROM pg_stat_io + WHERE object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 358 +SELECT :io_sum_shared_after_writes > :io_sum_shared_before_writes +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 359 +SELECT current_setting('fsync') = 'off' + OR :io_sum_shared_after_fsyncs > :io_sum_shared_before_fsyncs +-- +ERROR: syntax error at or near ":" +CURSORPOS: 46 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 360 +-- Change the tablespace so that the table is rewritten directly, then SELECT +-- from it to cause it to be read back into shared buffers. +SELECT sum(reads) AS io_sum_shared_before_reads + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 361 +-- Do this in a transaction to prevent spurious failures due to concurrent accesses to our newly +-- rewritten table, e.g. by autovacuum. +BEGIN +-- +STMT: TransactionStmt +== 362 +ALTER TABLE test_io_shared SET TABLESPACE regress_tblspace +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=DDL +STMT: AlterTableStmt +== 363 +-- SELECT from the table so that the data is read into shared buffers and +-- context 'normal', object 'relation' reads are counted. +SELECT COUNT(*) FROM test_io_shared +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 364 +COMMIT +-- +STMT: TransactionStmt +== 365 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 366 +SELECT sum(reads) AS io_sum_shared_after_reads + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 367 +SELECT :io_sum_shared_after_reads > :io_sum_shared_before_reads +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 368 +SELECT sum(hits) AS io_sum_shared_before_hits + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 369 +-- Select from the table again to count hits. +-- Ensure we generate hits by forcing a nested loop self-join with no +-- materialize node. The outer side's buffer will stay pinned, preventing its +-- eviction, while we loop through the inner side and generate hits. +BEGIN +-- +STMT: TransactionStmt +== 370 +SET LOCAL enable_nestloop TO on +-- +STMT: VariableSetStmt +== 371 +SET LOCAL enable_mergejoin TO off +-- +STMT: VariableSetStmt +== 372 +SET LOCAL enable_hashjoin TO off +-- +STMT: VariableSetStmt +== 373 +SET LOCAL enable_material TO off +-- +STMT: VariableSetStmt +== 374 +-- ensure plan stays as we expect it to +EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM test_io_shared t1 INNER JOIN test_io_shared t2 USING (a) +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +ALIAS: "t1"="test_io_shared" +ALIAS: "t2"="test_io_shared" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 375 +SELECT COUNT(*) FROM test_io_shared t1 INNER JOIN test_io_shared t2 USING (a) +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +ALIAS: "t1"="test_io_shared" +ALIAS: "t2"="test_io_shared" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 376 +COMMIT +-- +STMT: TransactionStmt +== 377 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 378 +SELECT sum(hits) AS io_sum_shared_after_hits + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 379 +SELECT :io_sum_shared_after_hits > :io_sum_shared_before_hits +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 380 +DROP TABLE test_io_shared +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=DDL +STMT: DropStmt +== 381 +-- Test that the follow IOCONTEXT_LOCAL IOOps are tracked in pg_stat_io: +-- - eviction of local buffers in order to reuse them +-- - reads of temporary table blocks into local buffers +-- - writes of local buffers to permanent storage +-- - extends of temporary tables + +-- Set temp_buffers to its minimum so that we can trigger writes with fewer +-- inserted tuples. Do so in a new session in case temporary tables have been +-- accessed by previous tests in this session. +SET temp_buffers TO 100 +-- +STMT: VariableSetStmt +== 382 +CREATE TEMPORARY TABLE test_io_local(a int, b TEXT) +-- +TABLE: name="test_io_local" schema="" table="test_io_local" ctx=DDL +STMT: CreateStmt +== 383 +SELECT sum(extends) AS extends, sum(evictions) AS evictions, sum(writes) AS writes + FROM pg_stat_io + WHERE context = 'normal' AND object = 'temp relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 384 +-- Insert tuples into the temporary table, generating extends in the stats. +-- Insert enough values that we need to reuse and write out dirty local +-- buffers, generating evictions and writes. +INSERT INTO test_io_local SELECT generate_series(1, 5000) as id, repeat('a', 200) +-- +TABLE: name="test_io_local" schema="" table="test_io_local" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 385 +-- Ensure the table is large enough to exceed our temp_buffers setting. +SELECT pg_relation_size('test_io_local') / current_setting('block_size')::int8 > 100 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +== 386 +SELECT sum(reads) AS io_sum_local_before_reads + FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 387 +-- Read in evicted buffers, generating reads. +SELECT COUNT(*) FROM test_io_local +-- +TABLE: name="test_io_local" schema="" table="test_io_local" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 388 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 389 +SELECT sum(evictions) AS evictions, + sum(reads) AS reads, + sum(writes) AS writes, + sum(extends) AS extends + FROM pg_stat_io + WHERE context = 'normal' AND object = 'temp relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 390 +SELECT :io_sum_local_after_evictions > :io_sum_local_before_evictions, + :io_sum_local_after_reads > :io_sum_local_before_reads, + :io_sum_local_after_writes > :io_sum_local_before_writes, + :io_sum_local_after_extends > :io_sum_local_before_extends +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 391 +-- Change the tablespaces so that the temporary table is rewritten to other +-- local buffers, exercising a different codepath than standard local buffer +-- writes. +ALTER TABLE test_io_local SET TABLESPACE regress_tblspace +-- +TABLE: name="test_io_local" schema="" table="test_io_local" ctx=DDL +STMT: AlterTableStmt +== 392 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 393 +SELECT sum(writes) AS io_sum_local_new_tblspc_writes + FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +== 394 +SELECT :io_sum_local_new_tblspc_writes > :io_sum_local_after_writes +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 395 +RESET temp_buffers +-- +STMT: VariableSetStmt +== 396 +-- Test that reuse of strategy buffers and reads of blocks into these reused +-- buffers while VACUUMing are tracked in pg_stat_io. If there is sufficient +-- demand for shared buffers from concurrent queries, some buffers may be +-- pinned by other backends before they can be reused. In such cases, the +-- backend will evict a buffer from outside the ring and add it to the +-- ring. This is considered an eviction and not a reuse. + +-- Set wal_skip_threshold smaller than the expected size of +-- test_io_vac_strategy so that, even if wal_level is minimal, VACUUM FULL will +-- fsync the newly rewritten test_io_vac_strategy instead of writing it to WAL. +-- Writing it to WAL will result in the newly written relation pages being in +-- shared buffers -- preventing us from testing BAS_VACUUM BufferAccessStrategy +-- reads. +SET wal_skip_threshold = '1 kB' +-- +STMT: VariableSetStmt +== 397 +SELECT sum(reuses) AS reuses, sum(reads) AS reads, sum(evictions) AS evictions + FROM pg_stat_io WHERE context = 'vacuum' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +STMT: SelectStmt +== 398 +CREATE TABLE test_io_vac_strategy(a int, b int) WITH (autovacuum_enabled = 'false') +-- +TABLE: name="test_io_vac_strategy" schema="" table="test_io_vac_strategy" ctx=DDL +STMT: CreateStmt +== 399 +INSERT INTO test_io_vac_strategy SELECT i, i from generate_series(1, 4500)i +-- +TABLE: name="test_io_vac_strategy" schema="" table="test_io_vac_strategy" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 400 +-- Ensure that the next VACUUM will need to perform IO by rewriting the table +-- first with VACUUM (FULL). +VACUUM (FULL) test_io_vac_strategy +-- +TABLE: name="test_io_vac_strategy" schema="" table="test_io_vac_strategy" ctx=DDL +STMT: VacuumStmt +== 401 +-- Use the minimum BUFFER_USAGE_LIMIT to cause reuses or evictions with the +-- smallest table possible. +VACUUM (PARALLEL 0, BUFFER_USAGE_LIMIT 128) test_io_vac_strategy +-- +TABLE: name="test_io_vac_strategy" schema="" table="test_io_vac_strategy" ctx=DDL +STMT: VacuumStmt +== 402 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 403 +SELECT sum(reuses) AS reuses, sum(reads) AS reads, sum(evictions) AS evictions + FROM pg_stat_io WHERE context = 'vacuum' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +STMT: SelectStmt +== 404 +SELECT :io_sum_vac_strategy_after_reads > :io_sum_vac_strategy_before_reads +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 405 +SELECT (:io_sum_vac_strategy_after_reuses + :io_sum_vac_strategy_after_evictions) > + (:io_sum_vac_strategy_before_reuses + :io_sum_vac_strategy_before_evictions) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 406 +RESET wal_skip_threshold +-- +STMT: VariableSetStmt +== 407 +-- Test that extends done by a CTAS, which uses a BAS_BULKWRITE +-- BufferAccessStrategy, are tracked in pg_stat_io. +SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_before + FROM pg_stat_io WHERE context = 'bulkwrite' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +STMT: SelectStmt +== 408 +CREATE TABLE test_io_bulkwrite_strategy AS SELECT i FROM generate_series(1,100)i +-- +TABLE: name="test_io_bulkwrite_strategy" schema="" table="test_io_bulkwrite_strategy" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 409 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +== 410 +SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_after + FROM pg_stat_io WHERE context = 'bulkwrite' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +STMT: SelectStmt +== 411 +SELECT :io_sum_bulkwrite_strategy_extends_after > :io_sum_bulkwrite_strategy_extends_before +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 412 +-- Test IO stats reset +SELECT pg_stat_have_stats('io', 0, 0) +-- +FUNCTION: name="pg_stat_have_stats" function="pg_stat_have_stats" schema="" ctx=Call +STMT: SelectStmt +== 413 +SELECT sum(evictions) + sum(reuses) + sum(extends) + sum(fsyncs) + sum(reads) + sum(writes) + sum(writebacks) + sum(hits) AS io_stats_pre_reset + FROM pg_stat_io +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 414 +SELECT pg_stat_reset_shared('io') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +== 415 +SELECT sum(evictions) + sum(reuses) + sum(extends) + sum(fsyncs) + sum(reads) + sum(writes) + sum(writebacks) + sum(hits) AS io_stats_post_reset + FROM pg_stat_io +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 416 +SELECT :io_stats_post_reset < :io_stats_pre_reset +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 417 +-- test BRIN index doesn't block HOT update +CREATE TABLE brin_hot ( + id integer PRIMARY KEY, + val integer NOT NULL +) WITH (autovacuum_enabled = off, fillfactor = 70) +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DDL +STMT: CreateStmt +== 418 +INSERT INTO brin_hot SELECT *, 0 FROM generate_series(1, 235) +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 419 +CREATE INDEX val_brin ON brin_hot using brin(val) +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DDL +STMT: IndexStmt +== 420 +CREATE FUNCTION wait_for_hot_stats() RETURNS void AS $$ +DECLARE + start_time timestamptz := clock_timestamp(); + updated bool; +BEGIN + -- we don't want to wait forever; loop will exit after 30 seconds + FOR i IN 1 .. 300 LOOP + SELECT (pg_stat_get_tuples_hot_updated('brin_hot'::regclass::oid) > 0) INTO updated; + EXIT WHEN updated; + + -- wait a little + PERFORM pg_sleep_for('100 milliseconds'); + -- reset stats snapshot so we can test again + PERFORM pg_stat_clear_snapshot(); + END LOOP; + -- report time waited in postmaster log (where it won't change test output) + RAISE log 'wait_for_hot_stats delayed % seconds', + EXTRACT(epoch FROM clock_timestamp() - start_time); +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="wait_for_hot_stats" function="wait_for_hot_stats" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 421 +UPDATE brin_hot SET val = -3 WHERE id = 42 +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DML +STMT: UpdateStmt +== 422 +-- We can't just call wait_for_hot_stats() at this point, because we only +-- transmit stats when the session goes idle, and we probably didn't +-- transmit the last couple of counts yet thanks to the rate-limiting logic +-- in pgstat_report_stat(). But instead of waiting for the rate limiter's +-- timeout to elapse, let's just start a new session. The old one will +-- then send its stats before dying. + +SELECT wait_for_hot_stats() +-- +FUNCTION: name="wait_for_hot_stats" function="wait_for_hot_stats" schema="" ctx=Call +STMT: SelectStmt +== 423 +SELECT pg_stat_get_tuples_hot_updated('brin_hot'::regclass::oid) +-- +FUNCTION: name="pg_stat_get_tuples_hot_updated" function="pg_stat_get_tuples_hot_updated" schema="" ctx=Call +STMT: SelectStmt +== 424 +DROP TABLE brin_hot +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DDL +STMT: DropStmt +== 425 +DROP FUNCTION wait_for_hot_stats() +-- +FUNCTION: name="wait_for_hot_stats" function="wait_for_hot_stats" schema="" ctx=DDL +STMT: DropStmt +== 426 +-- Test handling of index predicates - updating attributes in precicates +-- should not block HOT when summarizing indexes are involved. We update +-- a row that was not indexed due to the index predicate, and becomes +-- indexable - the HOT-updated tuple is forwarded to the BRIN index. +CREATE TABLE brin_hot_2 (a int, b int) +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DDL +STMT: CreateStmt +== 427 +INSERT INTO brin_hot_2 VALUES (1, 100) +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 428 +CREATE INDEX ON brin_hot_2 USING brin (b) WHERE a = 2 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DDL +STMT: IndexStmt +== 429 +UPDATE brin_hot_2 SET a = 2 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DML +STMT: UpdateStmt +== 430 +EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_2 WHERE a = 2 AND b = 100 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 431 +SELECT COUNT(*) FROM brin_hot_2 WHERE a = 2 AND b = 100 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 432 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +== 433 +EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_2 WHERE a = 2 AND b = 100 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +== 434 +SELECT COUNT(*) FROM brin_hot_2 WHERE a = 2 AND b = 100 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 435 +DROP TABLE brin_hot_2 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DDL +STMT: DropStmt +== 436 +-- Test that updates to indexed columns are still propagated to the +-- BRIN column. +-- https://postgr.es/m/05ebcb44-f383-86e3-4f31-0a97a55634cf@enterprisedb.com +CREATE TABLE brin_hot_3 (a int, filler text) WITH (fillfactor = 10) +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DDL +STMT: CreateStmt +== 437 +INSERT INTO brin_hot_3 SELECT 1, repeat(' ', 500) FROM generate_series(1, 20) +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 438 +CREATE INDEX ON brin_hot_3 USING brin (a) WITH (pages_per_range = 1) +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DDL +STMT: IndexStmt +== 439 +UPDATE brin_hot_3 SET a = 2 +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DML +STMT: UpdateStmt +== 440 +EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_3 WHERE a = 2 +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 441 +SELECT COUNT(*) FROM brin_hot_3 WHERE a = 2 +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 442 +DROP TABLE brin_hot_3 +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DDL +STMT: DropStmt +== 443 +SET enable_seqscan = on +-- +STMT: VariableSetStmt +== 444 +-- Test that estimation of relation size works with tuples wider than the +-- relation fillfactor. We create a table with wide inline attributes and +-- low fillfactor, insert rows and then see how many rows EXPLAIN shows +-- before running analyze. We disable autovacuum so that it does not +-- interfere with the test. +CREATE TABLE table_fillfactor ( + n char(1000) +) with (fillfactor=10, autovacuum_enabled=off) +-- +TABLE: name="table_fillfactor" schema="" table="table_fillfactor" ctx=DDL +STMT: CreateStmt +== 445 +INSERT INTO table_fillfactor +SELECT 'x' FROM generate_series(1,1000) +-- +TABLE: name="table_fillfactor" schema="" table="table_fillfactor" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 446 +SELECT * FROM check_estimated_rows('SELECT * FROM table_fillfactor') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 447 +DROP TABLE table_fillfactor +-- +TABLE: name="table_fillfactor" schema="" table="table_fillfactor" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/stats_ext.metadata.json b/parser/testdata/summary/postgres_regress/stats_ext.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/stats_ext.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/stats_ext.test b/parser/testdata/summary/postgres_regress/stats_ext.test new file mode 100644 index 0000000..a7ed210 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/stats_ext.test @@ -0,0 +1,4569 @@ +== 001 +-- Generic extended statistics support + +|-- +-- Note: tables for which we check estimated row counts should be created +-- with autovacuum_enabled = off, so that we don't have unstable results +-- from auto-analyze happening when we didn't expect it. +|-- + +-- check the number of estimated/actual rows in the top node +create function check_estimated_rows(text) returns table (estimated int, actual int) +language plpgsql as +$$ +declare + ln text; + tmp text[]; + first_row bool := true; +begin + for ln in + execute format('explain analyze %s', $1) + loop + if first_row then + first_row := false; + tmp := regexp_match(ln, 'rows=(\d*) .* rows=(\d*)'); + return query select tmp[1]::int, tmp[2]::int; + end if; + end loop; +end; +$$ +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 002 +-- Verify failures +CREATE TABLE ext_stats_test (x text, y int, z int) +-- +TABLE: name="ext_stats_test" schema="" table="ext_stats_test" ctx=DDL +STMT: CreateStmt +== 003 +CREATE STATISTICS tst +-- +ERROR: syntax error at end of input +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +CREATE STATISTICS tst ON a, b +-- +ERROR: syntax error at end of input +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +CREATE STATISTICS tst FROM sometab +-- +ERROR: syntax error at or near "FROM" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +CREATE STATISTICS tst ON a, b FROM nonexistent +-- +STMT: CreateStatsStmt +== 007 +CREATE STATISTICS tst ON a, b FROM ext_stats_test +-- +STMT: CreateStatsStmt +== 008 +CREATE STATISTICS tst ON x, x, y FROM ext_stats_test +-- +STMT: CreateStatsStmt +== 009 +CREATE STATISTICS tst ON x, x, y, x, x, y, x, x, y FROM ext_stats_test +-- +STMT: CreateStatsStmt +== 010 +CREATE STATISTICS tst ON x, x, y, x, x, (x || 'x'), (y + 1), (x || 'x'), (x || 'x'), (y + 1) FROM ext_stats_test +-- +STMT: CreateStatsStmt +== 011 +CREATE STATISTICS tst ON (x || 'x'), (x || 'x'), (y + 1), (x || 'x'), (x || 'x'), (y + 1), (x || 'x'), (x || 'x'), (y + 1) FROM ext_stats_test +-- +STMT: CreateStatsStmt +== 012 +CREATE STATISTICS tst ON (x || 'x'), (x || 'x'), y FROM ext_stats_test +-- +STMT: CreateStatsStmt +== 013 +CREATE STATISTICS tst (unrecognized) ON x, y FROM ext_stats_test +-- +STMT: CreateStatsStmt +== 014 +-- unsupported targets +CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo +-- +STMT: CreateStatsStmt +== 015 +CREATE STATISTICS tst ON a FROM foo NATURAL JOIN bar +-- +STMT: CreateStatsStmt +== 016 +CREATE STATISTICS tst ON a FROM (SELECT * FROM ext_stats_test) AS foo +-- +STMT: CreateStatsStmt +== 017 +CREATE STATISTICS tst ON a FROM ext_stats_test s TABLESAMPLE system (x) +-- +STMT: CreateStatsStmt +== 018 +CREATE STATISTICS tst ON a FROM XMLTABLE('foo' PASSING 'bar' COLUMNS a text) +-- +STMT: CreateStatsStmt +== 019 +CREATE STATISTICS tst ON a FROM JSON_TABLE(jsonb '123', '$' COLUMNS (item int)) +-- +STMT: CreateStatsStmt +== 020 +CREATE FUNCTION tftest(int) returns table(a int, b int) as $$ +SELECT $1, $1+i FROM generate_series(1,5) g(i); +$$ LANGUAGE sql IMMUTABLE STRICT +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 021 +CREATE STATISTICS alt_stat2 ON a FROM tftest(1) +-- +STMT: CreateStatsStmt +== 022 +DROP FUNCTION tftest +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: DropStmt +== 023 +-- incorrect expressions +CREATE STATISTICS tst ON (y) FROM ext_stats_test +-- +STMT: CreateStatsStmt +== 024 +-- single column reference +CREATE STATISTICS tst ON y + z FROM ext_stats_test +-- +ERROR: syntax error at or near "+" +CURSORPOS: 55 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 025 +-- missing parentheses +CREATE STATISTICS tst ON (x, y) FROM ext_stats_test +-- +ERROR: syntax error at or near "," +CURSORPOS: 51 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 026 +-- tuple expression +DROP TABLE ext_stats_test +-- +TABLE: name="ext_stats_test" schema="" table="ext_stats_test" ctx=DDL +STMT: DropStmt +== 027 +-- Ensure stats are dropped sanely, and test IF NOT EXISTS while at it +CREATE TABLE ab1 (a INTEGER, b INTEGER, c INTEGER) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: CreateStmt +== 028 +CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +== 029 +COMMENT ON STATISTICS ab1_a_b_stats IS 'new comment' +-- +STMT: CommentStmt +== 030 +CREATE ROLE regress_stats_ext +-- +STMT: CreateRoleStmt +== 031 +SET SESSION AUTHORIZATION regress_stats_ext +-- +STMT: VariableSetStmt +== 032 +COMMENT ON STATISTICS ab1_a_b_stats IS 'changed comment' +-- +STMT: CommentStmt +== 033 +DROP STATISTICS ab1_a_b_stats +-- +STMT: DropStmt +== 034 +ALTER STATISTICS ab1_a_b_stats RENAME TO ab1_a_b_stats_new +-- +STMT: RenameStmt +== 035 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 036 +DROP ROLE regress_stats_ext +-- +STMT: DropRoleStmt +== 037 +CREATE STATISTICS pg_temp.stats_ext_temp ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +== 038 +SELECT regexp_replace(pg_describe_object(tableoid, oid, 0), + 'pg_temp_[0-9]*', 'pg_temp_REDACTED') AS descr, + pg_statistics_obj_is_visible(oid) AS visible + FROM pg_statistic_ext + WHERE stxname = 'stats_ext_temp' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FUNCTION: name="regexp_replace" function="regexp_replace" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_statistics_obj_is_visible" function="pg_statistics_obj_is_visible" schema="" ctx=Call +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +== 039 +DROP STATISTICS stats_ext_temp +-- +STMT: DropStmt +== 040 +-- shall fail +DROP STATISTICS pg_temp.stats_ext_temp +-- +STMT: DropStmt +== 041 +CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +== 042 +DROP STATISTICS ab1_a_b_stats +-- +STMT: DropStmt +== 043 +CREATE SCHEMA regress_schema_2 +-- +STMT: CreateSchemaStmt +== 044 +CREATE STATISTICS regress_schema_2.ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +== 045 +-- Let's also verify the pg_get_statisticsobjdef output looks sane. +SELECT pg_get_statisticsobjdef(oid) FROM pg_statistic_ext WHERE stxname = 'ab1_a_b_stats' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FUNCTION: name="pg_get_statisticsobjdef" function="pg_get_statisticsobjdef" schema="" ctx=Call +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +== 046 +DROP STATISTICS regress_schema_2.ab1_a_b_stats +-- +STMT: DropStmt +== 047 +-- Ensure statistics are dropped when columns are +CREATE STATISTICS ab1_b_c_stats ON b, c FROM ab1 +-- +STMT: CreateStatsStmt +== 048 +CREATE STATISTICS ab1_a_b_c_stats ON a, b, c FROM ab1 +-- +STMT: CreateStatsStmt +== 049 +CREATE STATISTICS ab1_b_a_stats ON b, a FROM ab1 +-- +STMT: CreateStatsStmt +== 050 +ALTER TABLE ab1 DROP COLUMN a +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: AlterTableStmt +== 051 +-- Ensure statistics are dropped when table is +SELECT stxname FROM pg_statistic_ext WHERE stxname LIKE 'ab1%' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +== 052 +DROP TABLE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: DropStmt +== 053 +SELECT stxname FROM pg_statistic_ext WHERE stxname LIKE 'ab1%' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +== 054 +-- Ensure things work sanely with SET STATISTICS 0 +CREATE TABLE ab1 (a INTEGER, b INTEGER) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: CreateStmt +== 055 +ALTER TABLE ab1 ALTER a SET STATISTICS 0 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: AlterTableStmt +== 056 +INSERT INTO ab1 SELECT a, a%23 FROM generate_series(1, 1000) a +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 057 +CREATE STATISTICS ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +== 058 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +== 059 +ALTER TABLE ab1 ALTER a SET STATISTICS -1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: AlterTableStmt +== 060 +-- setting statistics target 0 skips the statistics, without printing any message, so check catalog +ALTER STATISTICS ab1_a_b_stats SET STATISTICS 0 +-- +STMT: AlterStatsStmt +== 061 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +== 062 +SELECT stxname, stxdndistinct, stxddependencies, stxdmcv, stxdinherit + FROM pg_statistic_ext s LEFT JOIN pg_statistic_ext_data d ON (d.stxoid = s.oid) + WHERE s.stxname = 'ab1_a_b_stats' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxname" +STMT: SelectStmt +== 063 +ALTER STATISTICS ab1_a_b_stats SET STATISTICS -1 +-- +STMT: AlterStatsStmt +== 064 +-- partial analyze doesn't build stats either +ANALYZE ab1 (a) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +== 065 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +== 066 +DROP TABLE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: DropStmt +== 067 +ALTER STATISTICS ab1_a_b_stats SET STATISTICS 0 +-- +STMT: AlterStatsStmt +== 068 +ALTER STATISTICS IF EXISTS ab1_a_b_stats SET STATISTICS 0 +-- +STMT: AlterStatsStmt +== 069 +-- Ensure we can build statistics for tables with inheritance. +CREATE TABLE ab1 (a INTEGER, b INTEGER) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: CreateStmt +== 070 +CREATE TABLE ab1c () INHERITS (ab1) +-- +TABLE: name="ab1c" schema="" table="ab1c" ctx=DDL +STMT: CreateStmt +== 071 +INSERT INTO ab1 VALUES (1,1) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +CREATE STATISTICS ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +== 073 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +== 074 +DROP TABLE ab1 CASCADE +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: DropStmt +== 075 +-- Tests for stats with inheritance +CREATE TABLE stxdinh(a int, b int) +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DDL +STMT: CreateStmt +== 076 +CREATE TABLE stxdinh1() INHERITS(stxdinh) +-- +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DDL +STMT: CreateStmt +== 077 +CREATE TABLE stxdinh2() INHERITS(stxdinh) +-- +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DDL +STMT: CreateStmt +== 078 +INSERT INTO stxdinh SELECT mod(a,50), mod(a,100) FROM generate_series(0, 1999) a +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 079 +INSERT INTO stxdinh1 SELECT mod(a,100), mod(a,100) FROM generate_series(0, 999) a +-- +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 080 +INSERT INTO stxdinh2 SELECT mod(a,100), mod(a,100) FROM generate_series(0, 999) a +-- +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 081 +VACUUM ANALYZE stxdinh, stxdinh1, stxdinh2 +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DDL +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DDL +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DDL +STMT: VacuumStmt +== 082 +-- Ensure non-inherited stats are not applied to inherited query +-- Without stats object, it looks like this +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 084 +CREATE STATISTICS stxdinh ON a, b FROM stxdinh +-- +STMT: CreateStatsStmt +== 085 +VACUUM ANALYZE stxdinh, stxdinh1, stxdinh2 +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DDL +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DDL +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DDL +STMT: VacuumStmt +== 086 +-- See if the extended stats affect the estimates +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 087 +-- Dependencies are applied at individual relations (within append), so +-- this estimate changes a bit because we improve estimates for the parent +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 088 +-- Ensure correct (non-inherited) stats are applied to inherited query +SELECT * FROM check_estimated_rows('SELECT a, b FROM ONLY stxdinh GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 089 +SELECT * FROM check_estimated_rows('SELECT a, b FROM ONLY stxdinh WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 090 +DROP TABLE stxdinh, stxdinh1, stxdinh2 +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DDL +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DDL +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DDL +STMT: DropStmt +== 091 +-- Ensure inherited stats ARE applied to inherited query in partitioned table +CREATE TABLE stxdinp(i int, a int, b int) PARTITION BY RANGE (i) +-- +TABLE: name="stxdinp" schema="" table="stxdinp" ctx=DDL +STMT: CreateStmt +== 092 +CREATE TABLE stxdinp1 PARTITION OF stxdinp FOR VALUES FROM (1) TO (100) +-- +TABLE: name="stxdinp1" schema="" table="stxdinp1" ctx=DDL +STMT: CreateStmt +== 093 +INSERT INTO stxdinp SELECT 1, a/100, a/100 FROM generate_series(1, 999) a +-- +TABLE: name="stxdinp" schema="" table="stxdinp" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 094 +CREATE STATISTICS stxdinp ON (a + 1), a, b FROM stxdinp +-- +STMT: CreateStatsStmt +== 095 +VACUUM ANALYZE stxdinp +-- +TABLE: name="stxdinp" schema="" table="stxdinp" ctx=DDL +STMT: VacuumStmt +== 096 +-- partitions are processed recursively +SELECT 1 FROM pg_statistic_ext WHERE stxrelid = 'stxdinp'::regclass +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxrelid" +STMT: SelectStmt +== 097 +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinp GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 098 +SELECT * FROM check_estimated_rows('SELECT a + 1, b FROM ONLY stxdinp GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 099 +DROP TABLE stxdinp +-- +TABLE: name="stxdinp" schema="" table="stxdinp" ctx=DDL +STMT: DropStmt +== 100 +-- basic test for statistics on expressions +CREATE TABLE ab1 (a INTEGER, b INTEGER, c TIMESTAMP, d TIMESTAMPTZ) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: CreateStmt +== 101 +-- expression stats may be built on a single expression column +CREATE STATISTICS ab1_exprstat_1 ON (a+b) FROM ab1 +-- +STMT: CreateStatsStmt +== 102 +-- with a single expression, we only enable expression statistics +CREATE STATISTICS ab1_exprstat_2 ON (a+b) FROM ab1 +-- +STMT: CreateStatsStmt +== 103 +SELECT stxkind FROM pg_statistic_ext WHERE stxname = 'ab1_exprstat_2' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +== 104 +-- adding anything to the expression builds all statistics kinds +CREATE STATISTICS ab1_exprstat_3 ON (a+b), a FROM ab1 +-- +STMT: CreateStatsStmt +== 105 +SELECT stxkind FROM pg_statistic_ext WHERE stxname = 'ab1_exprstat_3' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +== 106 +-- date_trunc on timestamptz is not immutable, but that should not matter +CREATE STATISTICS ab1_exprstat_4 ON date_trunc('day', d) FROM ab1 +-- +STMT: CreateStatsStmt +== 107 +-- date_trunc on timestamp is immutable +CREATE STATISTICS ab1_exprstat_5 ON date_trunc('day', c) FROM ab1 +-- +STMT: CreateStatsStmt +== 108 +-- check use of a boolean-returning expression +CREATE STATISTICS ab1_exprstat_6 ON + (case a when 1 then true else false end), b FROM ab1 +-- +STMT: CreateStatsStmt +== 109 +-- insert some data and run analyze, to test that these cases build properly +INSERT INTO ab1 +SELECT x / 10, x / 3, + '2020-10-01'::timestamp + x * interval '1 day', + '2020-10-01'::timestamptz + x * interval '1 day' +FROM generate_series(1, 100) x +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 110 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +== 111 +-- apply some stats +SELECT * FROM check_estimated_rows('SELECT * FROM ab1 WHERE (case a when 1 then true else false end) AND b=2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 112 +DROP TABLE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: DropStmt +== 113 +-- Verify supported object types for extended statistics +CREATE schema tststats +-- +STMT: CreateSchemaStmt +== 114 +CREATE TABLE tststats.t (a int, b int, c text) +-- +TABLE: name="tststats.t" schema="tststats" table="t" ctx=DDL +STMT: CreateStmt +== 115 +CREATE INDEX ti ON tststats.t (a, b) +-- +TABLE: name="tststats.t" schema="tststats" table="t" ctx=DDL +STMT: IndexStmt +== 116 +CREATE SEQUENCE tststats.s +-- +STMT: CreateSeqStmt +== 117 +CREATE VIEW tststats.v AS SELECT * FROM tststats.t +-- +TABLE: name="tststats.v" schema="tststats" table="v" ctx=DDL +TABLE: name="tststats.t" schema="tststats" table="t" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 118 +CREATE MATERIALIZED VIEW tststats.mv AS SELECT * FROM tststats.t +-- +TABLE: name="tststats.mv" schema="tststats" table="mv" ctx=DDL +TABLE: name="tststats.t" schema="tststats" table="t" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 119 +CREATE TYPE tststats.ty AS (a int, b int, c text) +-- +STMT: CompositeTypeStmt +== 120 +CREATE FOREIGN DATA WRAPPER extstats_dummy_fdw +-- +STMT: CreateFdwStmt +== 121 +CREATE SERVER extstats_dummy_srv FOREIGN DATA WRAPPER extstats_dummy_fdw +-- +STMT: CreateForeignServerStmt +== 122 +CREATE FOREIGN TABLE tststats.f (a int, b int, c text) SERVER extstats_dummy_srv +-- +STMT: CreateForeignTableStmt +== 123 +CREATE TABLE tststats.pt (a int, b int, c text) PARTITION BY RANGE (a, b) +-- +TABLE: name="tststats.pt" schema="tststats" table="pt" ctx=DDL +STMT: CreateStmt +== 124 +CREATE TABLE tststats.pt1 PARTITION OF tststats.pt FOR VALUES FROM (-10, -10) TO (10, 10) +-- +TABLE: name="tststats.pt1" schema="tststats" table="pt1" ctx=DDL +STMT: CreateStmt +== 125 +CREATE STATISTICS tststats.s1 ON a, b FROM tststats.t +-- +STMT: CreateStatsStmt +== 126 +CREATE STATISTICS tststats.s2 ON a, b FROM tststats.ti +-- +STMT: CreateStatsStmt +== 127 +CREATE STATISTICS tststats.s3 ON a, b FROM tststats.s +-- +STMT: CreateStatsStmt +== 128 +CREATE STATISTICS tststats.s4 ON a, b FROM tststats.v +-- +STMT: CreateStatsStmt +== 129 +CREATE STATISTICS tststats.s5 ON a, b FROM tststats.mv +-- +STMT: CreateStatsStmt +== 130 +CREATE STATISTICS tststats.s6 ON a, b FROM tststats.ty +-- +STMT: CreateStatsStmt +== 131 +CREATE STATISTICS tststats.s7 ON a, b FROM tststats.f +-- +STMT: CreateStatsStmt +== 132 +CREATE STATISTICS tststats.s8 ON a, b FROM tststats.pt +-- +STMT: CreateStatsStmt +== 133 +CREATE STATISTICS tststats.s9 ON a, b FROM tststats.pt1 +-- +STMT: CreateStatsStmt +== 134 +DO $$ +DECLARE + relname text := reltoastrelid::regclass FROM pg_class WHERE oid = 'tststats.t'::regclass; +BEGIN + EXECUTE 'CREATE STATISTICS tststats.s10 ON a, b FROM ' || relname; +EXCEPTION WHEN wrong_object_type THEN + RAISE NOTICE 'stats on toast table not created'; +END; +$$ +-- +STMT: DoStmt +== 135 +DROP SCHEMA tststats CASCADE +-- +STMT: DropStmt +== 136 +DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE +-- +STMT: DropStmt +== 137 +-- n-distinct tests +CREATE TABLE ndistinct ( + filler1 TEXT, + filler2 NUMERIC, + a INT, + b INT, + filler3 DATE, + c INT, + d INT +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: CreateStmt +== 138 +-- over-estimates when using only per-column statistics +INSERT INTO ndistinct (a, b, c, filler1) + SELECT i/100, i/100, i/100, (i/100) || ' dollars and zero cents' + FROM generate_series(1,1000) s(i) +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 139 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 140 +-- Group Aggregate, due to over-estimate of the number of groups +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 141 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 142 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 143 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 144 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 145 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 146 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 147 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 148 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 149 +-- correct command +CREATE STATISTICS s10 ON a, b, c FROM ndistinct +-- +STMT: CreateStatsStmt +== 150 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 151 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +== 152 +-- minor improvement, make sure the ctid does not break the matching +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY ctid, a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 153 +-- Hash Aggregate, thanks to estimates improved by the statistic +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 154 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 155 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 156 +-- partial improvement (match on attributes) +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 157 +-- expressions - no improvement +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 158 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 159 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 160 +-- last two plans keep using Group Aggregate, because 'd' is not covered +-- by the statistic and while it's NULL-only we assume 200 values for it +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 161 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 162 +TRUNCATE TABLE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: TruncateStmt +== 163 +-- under-estimates when using only per-column statistics +INSERT INTO ndistinct (a, b, c, filler1) + SELECT mod(i,13), mod(i,17), mod(i,19), + mod(i,23) || ' dollars and zero cents' + FROM generate_series(1,1000) s(i) +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 164 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 165 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +== 166 +-- correct estimates +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 167 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 168 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 169 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 170 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 171 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 172 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 173 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 174 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 175 +DROP STATISTICS s10 +-- +STMT: DropStmt +== 176 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +== 177 +-- dropping the statistics results in under-estimates +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 178 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 179 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 180 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 181 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 182 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 183 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 184 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 185 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 186 +-- ndistinct estimates with statistics on expressions +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 187 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 188 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 189 +CREATE STATISTICS s10 (ndistinct) ON (a+1), (b+100), (2*c) FROM ndistinct +-- +STMT: CreateStatsStmt +== 190 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 191 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +== 192 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 193 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 194 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 195 +DROP STATISTICS s10 +-- +STMT: DropStmt +== 196 +-- a mix of attributes and expressions +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 197 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 198 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 199 +CREATE STATISTICS s10 (ndistinct) ON a, b, (2*c) FROM ndistinct +-- +STMT: CreateStatsStmt +== 200 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 201 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +== 202 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 203 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 204 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 205 +DROP STATISTICS s10 +-- +STMT: DropStmt +== 206 +-- combination of multiple ndistinct statistics, with/without expressions +TRUNCATE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: TruncateStmt +== 207 +-- two mostly independent groups of columns +INSERT INTO ndistinct (a, b, c, d) + SELECT mod(i,3), mod(i,9), mod(i,5), mod(i,20) + FROM generate_series(1,1000) s(i) +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 208 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 209 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 210 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 211 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 212 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 213 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 214 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 215 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 216 +-- basic statistics on both attributes (no expressions) +CREATE STATISTICS s11 (ndistinct) ON a, b FROM ndistinct +-- +STMT: CreateStatsStmt +== 217 +CREATE STATISTICS s12 (ndistinct) ON c, d FROM ndistinct +-- +STMT: CreateStatsStmt +== 218 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 219 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 220 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 221 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 222 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 223 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 224 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 225 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 226 +-- replace the second statistics by statistics on expressions + +DROP STATISTICS s12 +-- +STMT: DropStmt +== 227 +CREATE STATISTICS s12 (ndistinct) ON (c * 10), (d - 1) FROM ndistinct +-- +STMT: CreateStatsStmt +== 228 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 229 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 230 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 231 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 232 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 233 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 234 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 235 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 236 +-- replace the second statistics by statistics on both attributes and expressions + +DROP STATISTICS s12 +-- +STMT: DropStmt +== 237 +CREATE STATISTICS s12 (ndistinct) ON c, d, (c * 10), (d - 1) FROM ndistinct +-- +STMT: CreateStatsStmt +== 238 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 239 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 240 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 241 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 242 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 243 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 244 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 245 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 246 +-- replace the other statistics by statistics on both attributes and expressions + +DROP STATISTICS s11 +-- +STMT: DropStmt +== 247 +CREATE STATISTICS s11 (ndistinct) ON a, b, (a*5), (b+1) FROM ndistinct +-- +STMT: CreateStatsStmt +== 248 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 249 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 250 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 251 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 252 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 253 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 254 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 255 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 256 +-- replace statistics by somewhat overlapping ones (this expected to get worse estimate +-- because the first statistics shall be applied to 3 columns, and the second one can't +-- be really applied) + +DROP STATISTICS s11 +-- +STMT: DropStmt +== 257 +DROP STATISTICS s12 +-- +STMT: DropStmt +== 258 +CREATE STATISTICS s11 (ndistinct) ON a, b, (a*5), (b+1) FROM ndistinct +-- +STMT: CreateStatsStmt +== 259 +CREATE STATISTICS s12 (ndistinct) ON a, (b+1), (c * 10) FROM ndistinct +-- +STMT: CreateStatsStmt +== 260 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +== 261 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 262 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 263 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 264 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 265 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 266 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 267 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 268 +DROP STATISTICS s11 +-- +STMT: DropStmt +== 269 +DROP STATISTICS s12 +-- +STMT: DropStmt +== 270 +-- functional dependencies tests +CREATE TABLE functional_dependencies ( + filler1 TEXT, + filler2 NUMERIC, + a INT, + b TEXT, + filler3 DATE, + c INT, + d TEXT +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: CreateStmt +== 271 +CREATE INDEX fdeps_ab_idx ON functional_dependencies (a, b) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: IndexStmt +== 272 +CREATE INDEX fdeps_abc_idx ON functional_dependencies (a, b, c) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: IndexStmt +== 273 +-- random data (no functional dependencies) +INSERT INTO functional_dependencies (a, b, c, filler1) + SELECT mod(i, 5), mod(i, 7), mod(i, 11), i FROM generate_series(1,1000) s(i) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 274 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +== 275 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 276 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 277 +-- create statistics +CREATE STATISTICS func_deps_stat (dependencies) ON a, b, c FROM functional_dependencies +-- +STMT: CreateStatsStmt +== 278 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +== 279 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 280 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 281 +-- a => b, a => c, b => c +TRUNCATE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: TruncateStmt +== 282 +DROP STATISTICS func_deps_stat +-- +STMT: DropStmt +== 283 +-- now do the same thing, but with expressions +INSERT INTO functional_dependencies (a, b, c, filler1) + SELECT i, i, i, i FROM generate_series(1,5000) s(i) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 284 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +== 285 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AND mod(b::int, 13) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 286 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AND mod(b::int, 13) = 1 AND mod(c, 7) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 287 +-- create statistics +CREATE STATISTICS func_deps_stat (dependencies) ON (mod(a,11)), (mod(b::int, 13)), (mod(c, 7)) FROM functional_dependencies +-- +STMT: CreateStatsStmt +== 288 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +== 289 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AND mod(b::int, 13) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 290 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AND mod(b::int, 13) = 1 AND mod(c, 7) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 291 +-- a => b, a => c, b => c +TRUNCATE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: TruncateStmt +== 292 +DROP STATISTICS func_deps_stat +-- +STMT: DropStmt +== 293 +INSERT INTO functional_dependencies (a, b, c, filler1) + SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 294 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +== 295 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 296 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 297 +-- IN +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 298 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 299 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 300 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 301 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, 76) AND b IN (''1'', ''26'') AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 302 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, 76) AND b IN (''1'', ''26'') AND c IN (1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 303 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 26, 27, 51, 52, 76, 77) AND b IN (''1'', ''2'', ''26'', ''27'') AND c IN (1, 2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 304 +-- OR clauses referencing the same attribute +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 305 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND (b = ''1'' OR b = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 306 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 2 OR a = 51 OR a = 52) AND (b = ''1'' OR b = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 307 +-- OR clauses referencing different attributes +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR b = ''1'') AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 308 +-- ANY +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 51]) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 309 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 51]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 310 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 311 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 26, 51, 76]) AND b = ANY (ARRAY[''1'', ''26'']) AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 312 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 26, 51, 76]) AND b = ANY (ARRAY[''1'', ''26'']) AND c = ANY (ARRAY[1])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 313 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 2, 26, 27, 51, 52, 76, 77]) AND b = ANY (ARRAY[''1'', ''2'', ''26'', ''27'']) AND c = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 314 +-- ANY with inequalities should not benefit from functional dependencies +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a < ANY (ARRAY[1, 51]) AND b > ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 315 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a >= ANY (ARRAY[1, 51]) AND b <= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 316 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a <= ANY (ARRAY[1, 2, 51, 52]) AND b >= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 317 +-- ALL (should not benefit from functional dependencies) +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ALL (ARRAY[''1''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 318 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 319 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 320 +-- create statistics +CREATE STATISTICS func_deps_stat (dependencies) ON a, b, c FROM functional_dependencies +-- +STMT: CreateStatsStmt +== 321 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +== 322 +-- print the detected dependencies +SELECT dependencies FROM pg_stats_ext WHERE statistics_name = 'func_deps_stat' +-- +TABLE: name="pg_stats_ext" schema="" table="pg_stats_ext" ctx=Select +FILTER: schema="" table="" column="statistics_name" +STMT: SelectStmt +== 323 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 324 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 325 +-- IN +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 326 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 327 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 328 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 329 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, 76) AND b IN (''1'', ''26'') AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 330 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, 76) AND b IN (''1'', ''26'') AND c IN (1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 331 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 26, 27, 51, 52, 76, 77) AND b IN (''1'', ''2'', ''26'', ''27'') AND c IN (1, 2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 332 +-- OR clauses referencing the same attribute +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 333 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND (b = ''1'' OR b = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 334 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 2 OR a = 51 OR a = 52) AND (b = ''1'' OR b = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 335 +-- OR clauses referencing different attributes are incompatible +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR b = ''1'') AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 336 +-- ANY +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 51]) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 337 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 51]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 338 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 339 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 26, 51, 76]) AND b = ANY (ARRAY[''1'', ''26'']) AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 340 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 26, 51, 76]) AND b = ANY (ARRAY[''1'', ''26'']) AND c = ANY (ARRAY[1])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 341 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 2, 26, 27, 51, 52, 76, 77]) AND b = ANY (ARRAY[''1'', ''2'', ''26'', ''27'']) AND c = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 342 +-- ANY with inequalities should not benefit from functional dependencies +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a < ANY (ARRAY[1, 51]) AND b > ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 343 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a >= ANY (ARRAY[1, 51]) AND b <= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 344 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a <= ANY (ARRAY[1, 2, 51, 52]) AND b >= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 345 +-- ALL (should not benefit from functional dependencies) +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ALL (ARRAY[''1''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 346 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 347 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 348 +-- changing the type of column c causes all its stats to be dropped, reverting +-- to default estimates without any statistics, i.e. 0.5% selectivity for each +-- condition +ALTER TABLE functional_dependencies ALTER COLUMN c TYPE numeric +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: AlterTableStmt +== 349 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 350 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +== 351 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 352 +DROP STATISTICS func_deps_stat +-- +STMT: DropStmt +== 353 +-- now try functional dependencies with expressions + +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 354 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND upper(b) = ''1'' AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 355 +-- IN +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 356 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 357 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 358 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 359 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52, 102, 152) AND upper(b) IN (''1'', ''26'') AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 360 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52, 102, 152) AND upper(b) IN (''1'', ''26'') AND (c + 1) IN (2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 361 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 52, 54, 102, 104, 152, 154) AND upper(b) IN (''1'', ''2'', ''26'', ''27'') AND (c + 1) IN (2, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 362 +-- OR clauses referencing the same attribute +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 363 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND (upper(b) = ''1'' OR upper(b) = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 364 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 4 OR (a * 2) = 102 OR (a * 2) = 104) AND (upper(b) = ''1'' OR upper(b) = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 365 +-- OR clauses referencing different attributes +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR upper(b) = ''1'') AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 366 +-- ANY +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 102]) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 367 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 102]) AND upper(b) = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 368 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 4, 102, 104]) AND upper(b) = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 369 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 52, 102, 152]) AND upper(b) = ANY (ARRAY[''1'', ''26'']) AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 370 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 52, 102, 152]) AND upper(b) = ANY (ARRAY[''1'', ''26'']) AND (c + 1) = ANY (ARRAY[2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 371 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 4, 52, 54, 102, 104, 152, 154]) AND upper(b) = ANY (ARRAY[''1'', ''2'', ''26'', ''27'']) AND (c + 1) = ANY (ARRAY[2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 372 +-- ANY with inequalities should not benefit from functional dependencies +-- the estimates however improve thanks to having expression statistics +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) < ANY (ARRAY[2, 102]) AND upper(b) > ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 373 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) >= ANY (ARRAY[2, 102]) AND upper(b) <= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 374 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) <= ANY (ARRAY[2, 4, 102, 104]) AND upper(b) >= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 375 +-- ALL (should not benefit from functional dependencies) +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ALL (ARRAY[''1''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 376 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 377 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 378 +-- create statistics on expressions +CREATE STATISTICS func_deps_stat (dependencies) ON (a * 2), upper(b), (c + 1) FROM functional_dependencies +-- +STMT: CreateStatsStmt +== 379 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +== 380 +-- print the detected dependencies +SELECT dependencies FROM pg_stats_ext WHERE statistics_name = 'func_deps_stat' +-- +TABLE: name="pg_stats_ext" schema="" table="pg_stats_ext" ctx=Select +FILTER: schema="" table="" column="statistics_name" +STMT: SelectStmt +== 381 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 382 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND upper(b) = ''1'' AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 383 +-- IN +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 384 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 385 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 386 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 387 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52, 102, 152) AND upper(b) IN (''1'', ''26'') AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 388 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52, 102, 152) AND upper(b) IN (''1'', ''26'') AND (c + 1) IN (2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 389 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 52, 54, 102, 104, 152, 154) AND upper(b) IN (''1'', ''2'', ''26'', ''27'') AND (c + 1) IN (2, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 390 +-- OR clauses referencing the same attribute +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 391 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND (upper(b) = ''1'' OR upper(b) = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 392 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 4 OR (a * 2) = 102 OR (a * 2) = 104) AND (upper(b) = ''1'' OR upper(b) = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 393 +-- OR clauses referencing different attributes +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR upper(b) = ''1'') AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 394 +-- ANY +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 102]) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 395 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 102]) AND upper(b) = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 396 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 4, 102, 104]) AND upper(b) = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 397 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 52, 102, 152]) AND upper(b) = ANY (ARRAY[''1'', ''26'']) AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 398 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 52, 102, 152]) AND upper(b) = ANY (ARRAY[''1'', ''26'']) AND (c + 1) = ANY (ARRAY[2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 399 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 4, 52, 54, 102, 104, 152, 154]) AND upper(b) = ANY (ARRAY[''1'', ''2'', ''26'', ''27'']) AND (c + 1) = ANY (ARRAY[2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 400 +-- ANY with inequalities should not benefit from functional dependencies +-- the estimates however improve thanks to having expression statistics +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) < ANY (ARRAY[2, 102]) AND upper(b) > ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 401 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) >= ANY (ARRAY[2, 102]) AND upper(b) <= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 402 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) <= ANY (ARRAY[2, 4, 102, 104]) AND upper(b) >= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 403 +-- ALL (should not benefit from functional dependencies) +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ALL (ARRAY[''1''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 404 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 405 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 406 +-- check the ability to use multiple functional dependencies +CREATE TABLE functional_dependencies_multi ( + a INTEGER, + b INTEGER, + c INTEGER, + d INTEGER +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DDL +STMT: CreateStmt +== 407 +INSERT INTO functional_dependencies_multi (a, b, c, d) + SELECT + mod(i,7), + mod(i,7), + mod(i,11), + mod(i,11) + FROM generate_series(1,5000) s(i) +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 408 +ANALYZE functional_dependencies_multi +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DDL +STMT: VacuumStmt +== 409 +-- estimates without any functional dependencies +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 410 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND 0 = b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 411 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 412 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b = 0 AND c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 413 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND b = 0 AND 0 = c AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 414 +-- create separate functional dependencies +CREATE STATISTICS functional_dependencies_multi_1 (dependencies) ON a, b FROM functional_dependencies_multi +-- +STMT: CreateStatsStmt +== 415 +CREATE STATISTICS functional_dependencies_multi_2 (dependencies) ON c, d FROM functional_dependencies_multi +-- +STMT: CreateStatsStmt +== 416 +ANALYZE functional_dependencies_multi +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DDL +STMT: VacuumStmt +== 417 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 418 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND 0 = b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 419 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 420 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b = 0 AND c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 421 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND b = 0 AND 0 = c AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 422 +DROP TABLE functional_dependencies_multi +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DDL +STMT: DropStmt +== 423 +-- MCV lists +CREATE TABLE mcv_lists ( + filler1 TEXT, + filler2 NUMERIC, + a INT, + b VARCHAR, + filler3 DATE, + c INT, + d TEXT, + ia INT[] +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: CreateStmt +== 424 +-- random data (no MCV list) +INSERT INTO mcv_lists (a, b, c, filler1) + SELECT mod(i,37), mod(i,41), mod(i,43), mod(i,47) FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 425 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 426 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 427 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 428 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c FROM mcv_lists +-- +STMT: CreateStatsStmt +== 429 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 430 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 431 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 432 +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +== 433 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +== 434 +-- random data (no MCV list), but with expression +INSERT INTO mcv_lists (a, b, c, filler1) + SELECT i, i, i, i FROM generate_series(1,1000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 435 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 436 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 437 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11) = 1 AND mod(c,13) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 438 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON (mod(a,7)), (mod(b::int,11)), (mod(c,13)) FROM mcv_lists +-- +STMT: CreateStatsStmt +== 439 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 440 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 441 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11) = 1 AND mod(c,13) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 442 +-- 100 distinct combinations, all in the MCV list +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +== 443 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +== 444 +INSERT INTO mcv_lists (a, b, c, ia, filler1) + SELECT mod(i,100), mod(i,50), mod(i,25), array[mod(i,25)], i + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 445 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 446 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 447 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = a AND ''1'' = b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 448 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 1 AND b < ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 449 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > a AND ''1'' > b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 450 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 0 AND b <= ''0''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 451 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 0 >= a AND ''0'' >= b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 452 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 453 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND b < ''1'' AND c < 5') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 454 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND ''1'' > b AND 5 > c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 455 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 4 AND b <= ''0'' AND c <= 4') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 456 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 4 >= a AND ''0'' >= b AND 4 >= c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 457 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 458 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 459 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52) AND b IN ( ''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 460 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52, NULL) AND b IN ( ''1'', ''2'', NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 461 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 462 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[NULL, 1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2'', NULL])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 463 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, 2, 3]) AND b IN (''1'', ''2'', ''3'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 464 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, NULL, 2, 3]) AND b IN (''1'', ''2'', NULL, ''3'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 465 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 466 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > ANY (ARRAY[1, 2, 3, NULL])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 467 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN (''1'', ''2'', ''3'') AND c > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 468 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN (''1'', ''2'', NULL, ''3'') AND c > ANY (ARRAY[1, 2, NULL, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 469 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[4,5]) AND 4 = ANY(ia)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 470 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c, ia FROM mcv_lists +-- +STMT: CreateStatsStmt +== 471 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 472 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 473 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = a AND ''1'' = b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 474 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 1 AND b < ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 475 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > a AND ''1'' > b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 476 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 0 AND b <= ''0''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 477 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 0 >= a AND ''0'' >= b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 478 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 479 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND b < ''1'' AND c < 5') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 480 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND ''1'' > b AND 5 > c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 481 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 4 AND b <= ''0'' AND c <= 4') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 482 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 4 >= a AND ''0'' >= b AND 4 >= c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 483 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 484 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 485 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 486 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52) AND b IN ( ''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 487 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52, NULL) AND b IN ( ''1'', ''2'', NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 488 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 489 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[NULL, 1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2'', NULL])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 490 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, 2, 3]) AND b IN (''1'', ''2'', ''3'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 491 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, NULL, 2, 3]) AND b IN (''1'', ''2'', NULL, ''3'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 492 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 493 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > ANY (ARRAY[1, 2, 3, NULL])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 494 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN (''1'', ''2'', ''3'') AND c > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 495 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN (''1'', ''2'', NULL, ''3'') AND c > ANY (ARRAY[1, 2, NULL, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 496 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[4,5]) AND 4 = ANY(ia)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 497 +-- check change of unrelated column type does not reset the MCV statistics +ALTER TABLE mcv_lists ALTER COLUMN d TYPE VARCHAR(64) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: AlterTableStmt +== 498 +SELECT d.stxdmcv IS NOT NULL + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxname = 'mcv_lists_stats' + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxname" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +== 499 +-- check change of column type resets the MCV statistics +ALTER TABLE mcv_lists ALTER COLUMN c TYPE numeric +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: AlterTableStmt +== 500 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 501 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 502 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 503 +-- 100 distinct combinations, all in the MCV list, but with expressions +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +== 504 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +== 505 +INSERT INTO mcv_lists (a, b, c, filler1) + SELECT i, i, i, i FROM generate_series(1,1000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 506 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 507 +-- without any stats on the expressions, we have to use default selectivities, which +-- is why the estimates here are different from the pre-computed case above + +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 508 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 509 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10) < 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 510 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 511 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1 AND mod(c,5) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 512 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10) = 1 OR mod(c,25) = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 513 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NULL) AND mod(b::int,10) IN ( 1, 2, NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 514 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51, 52]) AND mod(b::int,10) = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 515 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL, 2, 3]) AND mod(b::int,10) IN (1, 2, NULL, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 516 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) AND mod(b::int,10) IN (1, 2, 3) AND mod(c,5) > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 517 +-- create statistics with expressions only (we create three separate stats, in order not to build more complex extended stats) +CREATE STATISTICS mcv_lists_stats_1 ON (mod(a,20)) FROM mcv_lists +-- +STMT: CreateStatsStmt +== 518 +CREATE STATISTICS mcv_lists_stats_2 ON (mod(b::int,10)) FROM mcv_lists +-- +STMT: CreateStatsStmt +== 519 +CREATE STATISTICS mcv_lists_stats_3 ON (mod(c,5)) FROM mcv_lists +-- +STMT: CreateStatsStmt +== 520 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 521 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 522 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 523 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10) < 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 524 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 525 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1 AND mod(c,5) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 526 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10) = 1 OR mod(c,25) = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 527 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NULL) AND mod(b::int,10) IN ( 1, 2, NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 528 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51, 52]) AND mod(b::int,10) = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 529 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL, 2, 3]) AND mod(b::int,10) IN (1, 2, NULL, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 530 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) AND mod(b::int,10) IN (1, 2, 3) AND mod(c,5) > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 531 +DROP STATISTICS mcv_lists_stats_1 +-- +STMT: DropStmt +== 532 +DROP STATISTICS mcv_lists_stats_2 +-- +STMT: DropStmt +== 533 +DROP STATISTICS mcv_lists_stats_3 +-- +STMT: DropStmt +== 534 +-- create statistics with both MCV and expressions +CREATE STATISTICS mcv_lists_stats (mcv) ON (mod(a,20)), (mod(b::int,10)), (mod(c,5)) FROM mcv_lists +-- +STMT: CreateStatsStmt +== 535 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 536 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 537 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 538 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10) < 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 539 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 540 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1 AND mod(c,5) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 541 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10) = 1 OR mod(c,25) = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 542 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NULL) AND mod(b::int,10) IN ( 1, 2, NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 543 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51, 52]) AND mod(b::int,10) = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 544 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL, 2, 3]) AND mod(b::int,10) IN (1, 2, NULL, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 545 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) AND mod(b::int,10) IN (1, 2, 3) AND mod(c,5) > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 546 +-- we can't use the statistic for OR clauses that are not fully covered (missing 'd' attribute) +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10) = 1 OR mod(c,5) = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 547 +-- 100 distinct combinations with NULL values, all in the MCV list +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +== 548 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +== 549 +INSERT INTO mcv_lists (a, b, c, filler1) + SELECT + (CASE WHEN mod(i,100) = 1 THEN NULL ELSE mod(i,100) END), + (CASE WHEN mod(i,50) = 1 THEN NULL ELSE mod(i,50) END), + (CASE WHEN mod(i,25) = 1 THEN NULL ELSE mod(i,25) END), + i + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 550 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 551 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 552 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL AND c IS NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 553 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 554 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NOT NULL AND b IS NULL AND c IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 555 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (0, 1) AND b IN (''0'', ''1'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 556 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c FROM mcv_lists +-- +STMT: CreateStatsStmt +== 557 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 558 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 559 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL AND c IS NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 560 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 561 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NOT NULL AND b IS NULL AND c IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 562 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (0, 1) AND b IN (''0'', ''1'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 563 +-- test pg_mcv_list_items with a very simple (single item) MCV list +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +== 564 +INSERT INTO mcv_lists (a, b, c) SELECT 1, 2, 3 FROM generate_series(1,1000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 565 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 566 +SELECT m.* + FROM pg_statistic_ext s, pg_statistic_ext_data d, + pg_mcv_list_items(d.stxdmcv) m + WHERE s.stxname = 'mcv_lists_stats' + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FUNCTION: name="pg_mcv_list_items" function="pg_mcv_list_items" schema="" ctx=Call +FILTER: schema="" table="s" column="stxname" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +== 567 +-- 2 distinct combinations with NULL values, all in the MCV list +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +== 568 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +== 569 +INSERT INTO mcv_lists (a, b, c, d) + SELECT + NULL, -- always NULL + (CASE WHEN mod(i,2) = 0 THEN NULL ELSE 'x' END), + (CASE WHEN mod(i,2) = 0 THEN NULL ELSE 0 END), + (CASE WHEN mod(i,2) = 0 THEN NULL ELSE 'x' END) + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 570 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 571 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 572 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''x'' OR d = ''x''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 573 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND (b = ''x'' OR d = ''x'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 574 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, d FROM mcv_lists +-- +STMT: CreateStatsStmt +== 575 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +== 576 +-- test pg_mcv_list_items with MCV list containing variable-length data and NULLs +SELECT m.* + FROM pg_statistic_ext s, pg_statistic_ext_data d, + pg_mcv_list_items(d.stxdmcv) m + WHERE s.stxname = 'mcv_lists_stats' + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FUNCTION: name="pg_mcv_list_items" function="pg_mcv_list_items" schema="" ctx=Call +FILTER: schema="" table="s" column="stxname" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +== 577 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 578 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''x'' OR d = ''x''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 579 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND (b = ''x'' OR d = ''x'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 580 +-- mcv with pass-by-ref fixlen types, e.g. uuid +CREATE TABLE mcv_lists_uuid ( + a UUID, + b UUID, + c UUID +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DDL +STMT: CreateStmt +== 581 +INSERT INTO mcv_lists_uuid (a, b, c) + SELECT + fipshash(mod(i,100)::text)::uuid, + fipshash(mod(i,50)::text)::uuid, + fipshash(mod(i,25)::text)::uuid + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DML +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 582 +ANALYZE mcv_lists_uuid +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DDL +STMT: VacuumStmt +== 583 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND b = ''e7f6c011-776e-8db7-cd33-0b54174fd76f''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 584 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND b = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND c = ''e7f6c011-776e-8db7-cd33-0b54174fd76f''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 585 +CREATE STATISTICS mcv_lists_uuid_stats (mcv) ON a, b, c + FROM mcv_lists_uuid +-- +STMT: CreateStatsStmt +== 586 +ANALYZE mcv_lists_uuid +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DDL +STMT: VacuumStmt +== 587 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND b = ''e7f6c011-776e-8db7-cd33-0b54174fd76f''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 588 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND b = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND c = ''e7f6c011-776e-8db7-cd33-0b54174fd76f''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 589 +DROP TABLE mcv_lists_uuid +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DDL +STMT: DropStmt +== 590 +-- mcv with arrays +CREATE TABLE mcv_lists_arrays ( + a TEXT[], + b NUMERIC[], + c INT[] +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists_arrays" schema="" table="mcv_lists_arrays" ctx=DDL +STMT: CreateStmt +== 591 +INSERT INTO mcv_lists_arrays (a, b, c) + SELECT + ARRAY[fipshash((i/100)::text), fipshash((i/100-1)::text), fipshash((i/100+1)::text)], + ARRAY[(i/100-1)::numeric/1000, (i/100)::numeric/1000, (i/100+1)::numeric/1000], + ARRAY[(i/100-1), i/100, (i/100+1)] + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists_arrays" schema="" table="mcv_lists_arrays" ctx=DML +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 592 +CREATE STATISTICS mcv_lists_arrays_stats (mcv) ON a, b, c + FROM mcv_lists_arrays +-- +STMT: CreateStatsStmt +== 593 +ANALYZE mcv_lists_arrays +-- +TABLE: name="mcv_lists_arrays" schema="" table="mcv_lists_arrays" ctx=DDL +STMT: VacuumStmt +== 594 +-- mcv with bool +CREATE TABLE mcv_lists_bool ( + a BOOL, + b BOOL, + c BOOL +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists_bool" schema="" table="mcv_lists_bool" ctx=DDL +STMT: CreateStmt +== 595 +INSERT INTO mcv_lists_bool (a, b, c) + SELECT + (mod(i,2) = 0), (mod(i,4) = 0), (mod(i,8) = 0) + FROM generate_series(1,10000) s(i) +-- +TABLE: name="mcv_lists_bool" schema="" table="mcv_lists_bool" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 596 +ANALYZE mcv_lists_bool +-- +TABLE: name="mcv_lists_bool" schema="" table="mcv_lists_bool" ctx=DDL +STMT: VacuumStmt +== 597 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 598 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 599 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND NOT b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 600 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND NOT c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 601 +CREATE STATISTICS mcv_lists_bool_stats (mcv) ON a, b, c + FROM mcv_lists_bool +-- +STMT: CreateStatsStmt +== 602 +ANALYZE mcv_lists_bool +-- +TABLE: name="mcv_lists_bool" schema="" table="mcv_lists_bool" ctx=DDL +STMT: VacuumStmt +== 603 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 604 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 605 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND NOT b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 606 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND NOT c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 607 +-- mcv covering just a small fraction of data +CREATE TABLE mcv_lists_partial ( + a INT, + b INT, + c INT +) +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DDL +STMT: CreateStmt +== 608 +-- 10 frequent groups, each with 100 elements +INSERT INTO mcv_lists_partial (a, b, c) + SELECT + mod(i,10), + mod(i,10), + mod(i,10) + FROM generate_series(0,999) s(i) +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 609 +-- 100 groups that will make it to the MCV list (includes the 10 frequent ones) +INSERT INTO mcv_lists_partial (a, b, c) + SELECT + i, + i, + i + FROM generate_series(0,99) s(i) +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 610 +-- 4000 groups in total, most of which won't make it (just a single item) +INSERT INTO mcv_lists_partial (a, b, c) + SELECT + i, + i, + i + FROM generate_series(0,3999) s(i) +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 611 +ANALYZE mcv_lists_partial +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DDL +STMT: VacuumStmt +== 612 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 613 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 614 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 AND b = 10 AND c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 615 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 OR b = 10 OR c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 616 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 617 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 618 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0 AND c = 0) OR (a = 1 AND b = 1 AND c = 1) OR (a = 2 AND b = 2 AND c = 2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 619 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0) OR (a = 0 AND c = 0) OR (b = 0 AND c = 0)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 620 +CREATE STATISTICS mcv_lists_partial_stats (mcv) ON a, b, c + FROM mcv_lists_partial +-- +STMT: CreateStatsStmt +== 621 +ANALYZE mcv_lists_partial +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DDL +STMT: VacuumStmt +== 622 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 623 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 624 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 AND b = 10 AND c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 625 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 OR b = 10 OR c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 626 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 627 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 628 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0 AND c = 0) OR (a = 1 AND b = 1 AND c = 1) OR (a = 2 AND b = 2 AND c = 2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 629 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0) OR (a = 0 AND c = 0) OR (b = 0 AND c = 0)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 630 +DROP TABLE mcv_lists_partial +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DDL +STMT: DropStmt +== 631 +-- check the ability to use multiple MCV lists +CREATE TABLE mcv_lists_multi ( + a INTEGER, + b INTEGER, + c INTEGER, + d INTEGER +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DDL +STMT: CreateStmt +== 632 +INSERT INTO mcv_lists_multi (a, b, c, d) + SELECT + mod(i,5), + mod(i,5), + mod(i,7), + mod(i,7) + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 633 +ANALYZE mcv_lists_multi +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DDL +STMT: VacuumStmt +== 634 +-- estimates without any mcv statistics +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 635 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 636 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 AND c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 637 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 OR c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 638 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0 AND c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 639 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE (a = 0 AND b = 0) OR (c = 0 AND d = 0)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 640 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 OR b = 0 OR c = 0 OR d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 641 +-- create separate MCV statistics +CREATE STATISTICS mcv_lists_multi_1 (mcv) ON a, b FROM mcv_lists_multi +-- +STMT: CreateStatsStmt +== 642 +CREATE STATISTICS mcv_lists_multi_2 (mcv) ON c, d FROM mcv_lists_multi +-- +STMT: CreateStatsStmt +== 643 +ANALYZE mcv_lists_multi +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DDL +STMT: VacuumStmt +== 644 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 645 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 646 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 AND c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 647 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 OR c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 648 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0 AND c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 649 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE (a = 0 AND b = 0) OR (c = 0 AND d = 0)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 650 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 OR b = 0 OR c = 0 OR d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 651 +DROP TABLE mcv_lists_multi +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DDL +STMT: DropStmt +== 652 +-- statistics on integer expressions +CREATE TABLE expr_stats (a int, b int, c int) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: CreateStmt +== 653 +INSERT INTO expr_stats SELECT mod(i,10), mod(i,10), mod(i,10) FROM generate_series(1,1000) s(i) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 654 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +== 655 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (2*a) = 0 AND (3*b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 656 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (a+b) = 0 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 657 +CREATE STATISTICS expr_stats_1 (mcv) ON (a+b), (a-b), (2*a), (3*b) FROM expr_stats +-- +STMT: CreateStatsStmt +== 658 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +== 659 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (2*a) = 0 AND (3*b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 660 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (a+b) = 0 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 661 +DROP STATISTICS expr_stats_1 +-- +STMT: DropStmt +== 662 +DROP TABLE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: DropStmt +== 663 +-- statistics on a mix columns and expressions +CREATE TABLE expr_stats (a int, b int, c int) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: CreateStmt +== 664 +INSERT INTO expr_stats SELECT mod(i,10), mod(i,10), mod(i,10) FROM generate_series(1,1000) s(i) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 665 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +== 666 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (2*a) = 0 AND (3*b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 667 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 3 AND b = 3 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 668 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND b = 1 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 669 +CREATE STATISTICS expr_stats_1 (mcv) ON a, b, (2*a), (3*b), (a+b), (a-b) FROM expr_stats +-- +STMT: CreateStatsStmt +== 670 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +== 671 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (2*a) = 0 AND (3*b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 672 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 3 AND b = 3 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 673 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND b = 1 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 674 +DROP TABLE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: DropStmt +== 675 +-- statistics on expressions with different data types +CREATE TABLE expr_stats (a int, b name, c text) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: CreateStmt +== 676 +INSERT INTO expr_stats SELECT mod(i,10), fipshash(mod(i,10)::text), fipshash(mod(i,10)::text) FROM generate_series(1,1000) s(i) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 677 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +== 678 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (b || c) <= ''z'' AND (c || b) >= ''0''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 679 +CREATE STATISTICS expr_stats_1 (mcv) ON a, b, (b || c), (c || b) FROM expr_stats +-- +STMT: CreateStatsStmt +== 680 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +== 681 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (b || c) <= ''z'' AND (c || b) >= ''0''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +== 682 +DROP TABLE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: DropStmt +== 683 +-- test handling of a mix of compatible and incompatible expressions +CREATE TABLE expr_stats_incompatible_test ( + c0 double precision, + c1 boolean NOT NULL +) +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=DDL +STMT: CreateStmt +== 684 +CREATE STATISTICS expr_stat_comp_1 ON c0, c1 FROM expr_stats_incompatible_test +-- +STMT: CreateStatsStmt +== 685 +INSERT INTO expr_stats_incompatible_test VALUES (1234,false), (5678,true) +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 686 +ANALYZE expr_stats_incompatible_test +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=DDL +STMT: VacuumStmt +== 687 +SELECT c0 FROM ONLY expr_stats_incompatible_test WHERE +( + upper('x') LIKE ('x'||('[0,1]'::int4range)) + AND + (c0 IN (0, 1) OR c1) +) +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="c0" +FILTER: schema="" table="" column="c1" +STMT: SelectStmt +== 688 +DROP TABLE expr_stats_incompatible_test +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=DDL +STMT: DropStmt +== 689 +-- Permission tests. Users should not be able to see specific data values in +-- the extended statistics, if they lack permission to see those values in +-- the underlying table. +|-- +-- Currently this is only relevant for MCV stats. +CREATE SCHEMA tststats +-- +STMT: CreateSchemaStmt +== 690 +CREATE TABLE tststats.priv_test_tbl ( + a int, + b int +) +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: CreateStmt +== 691 +INSERT INTO tststats.priv_test_tbl + SELECT mod(i,5), mod(i,10) FROM generate_series(1,100) s(i) +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 692 +CREATE STATISTICS tststats.priv_test_stats (mcv) ON a, b + FROM tststats.priv_test_tbl +-- +STMT: CreateStatsStmt +== 693 +ANALYZE tststats.priv_test_tbl +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: VacuumStmt +== 694 +-- Check printing info about extended statistics by \dX +create table stts_t1 (a int, b int) +-- +TABLE: name="stts_t1" schema="" table="stts_t1" ctx=DDL +STMT: CreateStmt +== 695 +create statistics (ndistinct) on a, b from stts_t1 +-- +STMT: CreateStatsStmt +== 696 +create statistics (ndistinct, dependencies) on a, b from stts_t1 +-- +STMT: CreateStatsStmt +== 697 +create statistics (ndistinct, dependencies, mcv) on a, b from stts_t1 +-- +STMT: CreateStatsStmt +== 698 +create table stts_t2 (a int, b int, c int) +-- +TABLE: name="stts_t2" schema="" table="stts_t2" ctx=DDL +STMT: CreateStmt +== 699 +create statistics on b, c from stts_t2 +-- +STMT: CreateStatsStmt +== 700 +create table stts_t3 (col1 int, col2 int, col3 int) +-- +TABLE: name="stts_t3" schema="" table="stts_t3" ctx=DDL +STMT: CreateStmt +== 701 +create statistics stts_hoge on col1, col2, col3 from stts_t3 +-- +STMT: CreateStatsStmt +== 702 +create schema stts_s1 +-- +STMT: CreateSchemaStmt +== 703 +create schema stts_s2 +-- +STMT: CreateSchemaStmt +== 704 +create statistics stts_s1.stts_foo on col1, col2 from stts_t3 +-- +STMT: CreateStatsStmt +== 705 +create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_t3 +-- +STMT: CreateStatsStmt +== 706 +insert into stts_t1 select i,i from generate_series(1,100) i +-- +TABLE: name="stts_t1" schema="" table="stts_t1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 707 +analyze stts_t1 +-- +TABLE: name="stts_t1" schema="" table="stts_t1" ctx=DDL +STMT: VacuumStmt +== 708 +set search_path to public, stts_s1, stts_s2, tststats +-- +STMT: VariableSetStmt +== 709 +create statistics (mcv) ON a, b, (a+b), (a-b) FROM stts_t1 +-- +STMT: CreateStatsStmt +== 710 +create statistics (mcv) ON a, b, (a+b), (a-b) FROM stts_t1 +-- +STMT: CreateStatsStmt +== 711 +create statistics (mcv) ON (a+b), (a-b) FROM stts_t1 +-- +STMT: CreateStatsStmt +== 712 +drop statistics stts_t1_a_b_expr_expr_stat +-- +STMT: DropStmt +== 713 +drop statistics stts_t1_a_b_expr_expr_stat1 +-- +STMT: DropStmt +== 714 +drop statistics stts_t1_expr_expr_stat +-- +STMT: DropStmt +== 715 +set search_path to public, stts_s1 +-- +STMT: VariableSetStmt +== 716 +create role regress_stats_ext nosuperuser +-- +STMT: CreateRoleStmt +== 717 +set role regress_stats_ext +-- +STMT: VariableSetStmt +== 718 +reset role +-- +STMT: VariableSetStmt +== 719 +drop table stts_t1, stts_t2, stts_t3 +-- +TABLE: name="stts_t1" schema="" table="stts_t1" ctx=DDL +TABLE: name="stts_t2" schema="" table="stts_t2" ctx=DDL +TABLE: name="stts_t3" schema="" table="stts_t3" ctx=DDL +STMT: DropStmt +== 720 +drop schema stts_s1, stts_s2 cascade +-- +STMT: DropStmt +== 721 +drop user regress_stats_ext +-- +STMT: DropRoleStmt +== 722 +reset search_path +-- +STMT: VariableSetStmt +== 723 +-- User with no access +CREATE USER regress_stats_user1 +-- +STMT: CreateRoleStmt +== 724 +GRANT USAGE ON SCHEMA tststats TO regress_stats_user1 +-- +STMT: GrantStmt +== 725 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 726 +SELECT * FROM tststats.priv_test_tbl +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +STMT: SelectStmt +== 727 +-- Permission denied + +-- Check individual columns if we don't have table privilege +SELECT * FROM tststats.priv_test_tbl + WHERE a = 1 and tststats.priv_test_tbl.* > (1, 1) is not null +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 728 +-- Attempt to gain access using a leaky operator +CREATE FUNCTION op_leak(int, int) RETURNS bool + AS 'BEGIN RAISE NOTICE ''op_leak => %, %'', $1, $2; RETURN $1 < $2; END' + LANGUAGE plpgsql +-- +FUNCTION: name="op_leak" function="op_leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 729 +CREATE OPERATOR <<< (procedure = op_leak, leftarg = int, rightarg = int, + restrict = scalarltsel) +-- +STMT: DefineStmt +== 730 +CREATE FUNCTION op_leak(record, record) RETURNS bool + AS 'BEGIN RAISE NOTICE ''op_leak => %, %'', $1, $2; RETURN $1 < $2; END' + LANGUAGE plpgsql +-- +FUNCTION: name="op_leak" function="op_leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 731 +CREATE OPERATOR <<< (procedure = op_leak, leftarg = record, rightarg = record, + restrict = scalarltsel) +-- +STMT: DefineStmt +== 732 +SELECT * FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 733 +-- Permission denied +SELECT * FROM tststats.priv_test_tbl t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +ALIAS: "t"="tststats.priv_test_tbl" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 734 +-- Permission denied +DELETE FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DML +STMT: DeleteStmt +== 735 +-- Permission denied + +-- Grant access via a security barrier view, but hide all data +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 736 +CREATE VIEW tststats.priv_test_view WITH (security_barrier=true) + AS SELECT * FROM tststats.priv_test_tbl WHERE false +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=DDL +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 737 +GRANT SELECT, DELETE ON tststats.priv_test_view TO regress_stats_user1 +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=DDL +STMT: GrantStmt +== 738 +-- Should now have access via the view, but see nothing and leak nothing +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 739 +SELECT * FROM tststats.priv_test_view WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 740 +-- Should not leak +SELECT * FROM tststats.priv_test_view t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=Select +ALIAS: "t"="tststats.priv_test_view" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 741 +-- Should not leak +DELETE FROM tststats.priv_test_view WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=DML +STMT: DeleteStmt +== 742 +-- Should not leak + +-- Grant table access, but hide all data with RLS +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 743 +ALTER TABLE tststats.priv_test_tbl ENABLE ROW LEVEL SECURITY +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: AlterTableStmt +== 744 +CREATE POLICY priv_test_tbl_pol ON tststats.priv_test_tbl USING (2 * a < 0) +-- +STMT: CreatePolicyStmt +== 745 +GRANT SELECT, DELETE ON tststats.priv_test_tbl TO regress_stats_user1 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: GrantStmt +== 746 +-- Should now have direct table access, but see nothing and leak nothing +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 747 +SELECT * FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 748 +-- Should not leak +SELECT * FROM tststats.priv_test_tbl t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +ALIAS: "t"="tststats.priv_test_tbl" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 749 +-- Should not leak +DELETE FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DML +STMT: DeleteStmt +== 750 +-- Should not leak + +-- Create plain inheritance parent table with no access permissions +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 751 +CREATE TABLE tststats.priv_test_parent_tbl (a int, b int) +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DDL +STMT: CreateStmt +== 752 +ALTER TABLE tststats.priv_test_tbl INHERIT tststats.priv_test_parent_tbl +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: AlterTableStmt +== 753 +-- Should not have access to parent, and should leak nothing +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 754 +SELECT * FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 755 +-- Permission denied +SELECT * FROM tststats.priv_test_parent_tbl t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=Select +ALIAS: "t"="tststats.priv_test_parent_tbl" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 756 +-- Permission denied +DELETE FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DML +STMT: DeleteStmt +== 757 +-- Permission denied + +-- Grant table access to parent, but hide all data with RLS +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 758 +ALTER TABLE tststats.priv_test_parent_tbl ENABLE ROW LEVEL SECURITY +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DDL +STMT: AlterTableStmt +== 759 +CREATE POLICY priv_test_parent_tbl_pol ON tststats.priv_test_parent_tbl USING (2 * a < 0) +-- +STMT: CreatePolicyStmt +== 760 +GRANT SELECT, DELETE ON tststats.priv_test_parent_tbl TO regress_stats_user1 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DDL +STMT: GrantStmt +== 761 +-- Should now have direct table access to parent, but see nothing and leak nothing +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 762 +SELECT * FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 763 +-- Should not leak +SELECT * FROM tststats.priv_test_parent_tbl t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=Select +ALIAS: "t"="tststats.priv_test_parent_tbl" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 764 +-- Should not leak +DELETE FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DML +STMT: DeleteStmt +== 765 +-- Should not leak + +-- privilege checks for pg_stats_ext and pg_stats_ext_exprs +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 766 +CREATE TABLE stats_ext_tbl (id INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, col TEXT) +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DDL +STMT: CreateStmt +== 767 +INSERT INTO stats_ext_tbl (col) VALUES ('secret'), ('secret'), ('very secret') +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 768 +CREATE STATISTICS s_col ON id, col FROM stats_ext_tbl +-- +STMT: CreateStatsStmt +== 769 +CREATE STATISTICS s_expr ON mod(id, 2), lower(col) FROM stats_ext_tbl +-- +STMT: CreateStatsStmt +== 770 +ANALYZE stats_ext_tbl +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DDL +STMT: VacuumStmt +== 771 +-- unprivileged role should not have access +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 772 +SELECT statistics_name, most_common_vals FROM pg_stats_ext x + WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*) +-- +TABLE: name="pg_stats_ext" schema="" table="pg_stats_ext" ctx=Select +ALIAS: "x"="pg_stats_ext" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 773 +SELECT statistics_name, most_common_vals FROM pg_stats_ext_exprs x + WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*) +-- +TABLE: name="pg_stats_ext_exprs" schema="" table="pg_stats_ext_exprs" ctx=Select +ALIAS: "x"="pg_stats_ext_exprs" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 774 +-- give unprivileged role ownership of table +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 775 +ALTER TABLE stats_ext_tbl OWNER TO regress_stats_user1 +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DDL +STMT: AlterTableStmt +== 776 +-- unprivileged role should now have access +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 777 +SELECT statistics_name, most_common_vals FROM pg_stats_ext x + WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*) +-- +TABLE: name="pg_stats_ext" schema="" table="pg_stats_ext" ctx=Select +ALIAS: "x"="pg_stats_ext" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 778 +SELECT statistics_name, most_common_vals FROM pg_stats_ext_exprs x + WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*) +-- +TABLE: name="pg_stats_ext_exprs" schema="" table="pg_stats_ext_exprs" ctx=Select +ALIAS: "x"="pg_stats_ext_exprs" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +== 779 +-- CREATE STATISTICS checks for CREATE on the schema +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 780 +CREATE SCHEMA sts_sch1 CREATE TABLE sts_sch1.tbl (a INT, b INT, c INT GENERATED ALWAYS AS (b * 2) STORED) +-- +STMT: CreateSchemaStmt +== 781 +CREATE SCHEMA sts_sch2 +-- +STMT: CreateSchemaStmt +== 782 +GRANT USAGE ON SCHEMA sts_sch1, sts_sch2 TO regress_stats_user1 +-- +STMT: GrantStmt +== 783 +ALTER TABLE sts_sch1.tbl OWNER TO regress_stats_user1 +-- +TABLE: name="sts_sch1.tbl" schema="sts_sch1" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 784 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 785 +CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +== 786 +CREATE STATISTICS sts_sch2.fail ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +== 787 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 788 +GRANT CREATE ON SCHEMA sts_sch1 TO regress_stats_user1 +-- +STMT: GrantStmt +== 789 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 790 +CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +== 791 +CREATE STATISTICS sts_sch2.fail ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +== 792 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 793 +REVOKE CREATE ON SCHEMA sts_sch1 FROM regress_stats_user1 +-- +STMT: GrantStmt +== 794 +GRANT CREATE ON SCHEMA sts_sch2 TO regress_stats_user1 +-- +STMT: GrantStmt +== 795 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 796 +CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +== 797 +CREATE STATISTICS sts_sch2.pass1 ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +== 798 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 799 +GRANT CREATE ON SCHEMA sts_sch1, sts_sch2 TO regress_stats_user1 +-- +STMT: GrantStmt +== 800 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 801 +CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +== 802 +CREATE STATISTICS sts_sch2.pass2 ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +== 803 +-- re-creating statistics via ALTER TABLE bypasses checks for CREATE on schema +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 804 +REVOKE CREATE ON SCHEMA sts_sch1, sts_sch2 FROM regress_stats_user1 +-- +STMT: GrantStmt +== 805 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +== 806 +ALTER TABLE sts_sch1.tbl ALTER COLUMN a TYPE SMALLINT +-- +TABLE: name="sts_sch1.tbl" schema="sts_sch1" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 807 +ALTER TABLE sts_sch1.tbl ALTER COLUMN c SET EXPRESSION AS (a * 3) +-- +TABLE: name="sts_sch1.tbl" schema="sts_sch1" table="tbl" ctx=DDL +STMT: AlterTableStmt +== 808 +-- Tidy up +DROP OPERATOR <<< (int, int) +-- +STMT: DropStmt +== 809 +DROP FUNCTION op_leak(int, int) +-- +FUNCTION: name="op_leak" function="op_leak" schema="" ctx=DDL +STMT: DropStmt +== 810 +DROP OPERATOR <<< (record, record) +-- +STMT: DropStmt +== 811 +DROP FUNCTION op_leak(record, record) +-- +FUNCTION: name="op_leak" function="op_leak" schema="" ctx=DDL +STMT: DropStmt +== 812 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 813 +DROP TABLE stats_ext_tbl +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DDL +STMT: DropStmt +== 814 +DROP SCHEMA tststats CASCADE +-- +STMT: DropStmt +== 815 +DROP SCHEMA sts_sch1, sts_sch2 CASCADE +-- +STMT: DropStmt +== 816 +DROP USER regress_stats_user1 +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/strings.metadata.json b/parser/testdata/summary/postgres_regress/strings.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/strings.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/strings.test b/parser/testdata/summary/postgres_regress/strings.test new file mode 100644 index 0000000..38b698b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/strings.test @@ -0,0 +1,868 @@ +== 001 +|-- +-- STRINGS +-- Test various data entry syntaxes. +|-- + +-- SQL string continuation syntax +-- E021-03 character string literals +SELECT 'first line' +' - next line' + ' - third line' + AS "Three lines to one"; + +-- illegal string continuation syntax +SELECT 'first line' +' - next line' /* this comment is not allowed here */ +' - third line' + AS "Illegal comment within continuation"; + +-- Unicode escapes +SET standard_conforming_strings TO on; + +SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061"; +SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*'; +SELECT U&'a\\b' AS "a\b"; + +SELECT U&' \' UESCAPE '!' AS "tricky"; +SELECT 'tricky' AS U&"\" UESCAPE '!'; + +SELECT U&'wrong: \061'; +SELECT U&'wrong: \+0061'; +SELECT U&'wrong: +0061' UESCAPE +; +SELECT U&'wrong: +0061' UESCAPE '+'; + +SELECT U&'wrong: \db99'; +SELECT U&'wrong: \db99xy'; +SELECT U&'wrong: \db99\\'; +SELECT U&'wrong: \db99\0061'; +SELECT U&'wrong: \+00db99\+000061'; +SELECT U&'wrong: \+2FFFFF'; + +-- while we're here, check the same cases in E-style literals +SELECT E'd\u0061t\U00000061' AS "data"; +SELECT E'a\\b' AS "a\b"; +SELECT E'wrong: \u061'; +SELECT E'wrong: \U0061'; +SELECT E'wrong: \udb99'; +SELECT E'wrong: \udb99xy'; +SELECT E'wrong: \udb99\\'; +SELECT E'wrong: \udb99\u0061'; +SELECT E'wrong: \U0000db99\U00000061'; +SELECT E'wrong: \U002FFFFF'; + +SET standard_conforming_strings TO off; + +SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061"; +SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*'; + +SELECT U&' \' UESCAPE '!' AS "tricky"; +SELECT 'tricky' AS U&"\" UESCAPE '!'; + +SELECT U&'wrong: \061'; +SELECT U&'wrong: \+0061'; +SELECT U&'wrong: +0061' UESCAPE '+'; + +RESET standard_conforming_strings; + +-- bytea +SET bytea_output TO hex; +SELECT E'\\xDeAdBeEf'::bytea; +SELECT E'\\x De Ad Be Ef '::bytea; +SELECT E'\\xDeAdBeE'::bytea; +SELECT E'\\xDeAdBeEx'::bytea; +SELECT E'\\xDe00BeEf'::bytea; +SELECT E'DeAdBeEf'::bytea; +SELECT E'De\\000dBeEf'::bytea; +SELECT E'De\123dBeEf'::bytea; +SELECT E'De\\123dBeEf'::bytea; +SELECT E'De\\678dBeEf'::bytea; + +SET bytea_output TO escape; +SELECT E'\\xDeAdBeEf'::bytea; +SELECT E'\\x De Ad Be Ef '::bytea; +SELECT E'\\xDe00BeEf'::bytea; +SELECT E'DeAdBeEf'::bytea; +SELECT E'De\\000dBeEf'::bytea; +SELECT E'De\\123dBeEf'::bytea; + +-- Test non-error-throwing API too +SELECT pg_input_is_valid(E'\\xDeAdBeE', 'bytea'); +SELECT * FROM pg_input_error_info(E'\\xDeAdBeE', 'bytea'); +SELECT * FROM pg_input_error_info(E'\\xDeAdBeEx', 'bytea'); +SELECT * FROM pg_input_error_info(E'foo\\99bar', 'bytea'); + +|-- +-- test conversions between various string types +-- E021-10 implicit casting among the character data types +|-- + +SELECT CAST(f1 AS text) AS "text(char)" FROM CHAR_TBL; + +SELECT CAST(f1 AS text) AS "text(varchar)" FROM VARCHAR_TBL; + +SELECT CAST(name 'namefield' AS text) AS "text(name)"; + +-- since this is an explicit cast, it should truncate w/o error: +SELECT CAST(f1 AS char(10)) AS "char(text)" FROM TEXT_TBL; +-- note: implicit-cast case is tested in char.sql + +SELECT CAST(f1 AS char(20)) AS "char(text)" FROM TEXT_TBL; + +SELECT CAST(f1 AS char(10)) AS "char(varchar)" FROM VARCHAR_TBL; + +SELECT CAST(name 'namefield' AS char(10)) AS "char(name)"; + +SELECT CAST(f1 AS varchar) AS "varchar(text)" FROM TEXT_TBL; + +SELECT CAST(f1 AS varchar) AS "varchar(char)" FROM CHAR_TBL; + +SELECT CAST(name 'namefield' AS varchar) AS "varchar(name)"; + +|-- +-- test SQL string functions +-- E### and T### are feature reference numbers from SQL99 +|-- + +-- E021-09 trim function +SELECT TRIM(BOTH FROM ' bunch o blanks ') = 'bunch o blanks' AS "bunch o blanks"; + +SELECT TRIM(LEADING FROM ' bunch o blanks ') = 'bunch o blanks ' AS "bunch o blanks "; + +SELECT TRIM(TRAILING FROM ' bunch o blanks ') = ' bunch o blanks' AS " bunch o blanks"; + +SELECT TRIM(BOTH 'x' FROM 'xxxxxsome Xsxxxxx') = 'some Xs' AS "some Xs"; + +-- E021-06 substring expression +SELECT SUBSTRING('1234567890' FROM 3) = '34567890' AS "34567890"; + +SELECT SUBSTRING('1234567890' FROM 4 FOR 3) = '456' AS "456"; + +-- test overflow cases +SELECT SUBSTRING('string' FROM 2 FOR 2147483646) AS "tring"; +SELECT SUBSTRING('string' FROM -10 FOR 2147483646) AS "string"; +SELECT SUBSTRING('string' FROM -10 FOR -2147483646) AS "error"; + +-- T581 regular expression substring (with SQL's bizarre regexp syntax) +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"(b_d)#"%' ESCAPE '#') AS "bcd"; +-- obsolete SQL99 syntax +SELECT SUBSTRING('abcdefg' FROM 'a#"(b_d)#"%' FOR '#') AS "bcd"; + +-- No match should return NULL +SELECT SUBSTRING('abcdefg' SIMILAR '#"(b_d)#"%' ESCAPE '#') IS NULL AS "True"; + +-- Null inputs should return NULL +SELECT SUBSTRING('abcdefg' SIMILAR '%' ESCAPE NULL) IS NULL AS "True"; +SELECT SUBSTRING(NULL SIMILAR '%' ESCAPE '#') IS NULL AS "True"; +SELECT SUBSTRING('abcdefg' SIMILAR NULL ESCAPE '#') IS NULL AS "True"; + +-- The first and last parts should act non-greedy +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"%#"g' ESCAPE '#') AS "bcdef"; +SELECT SUBSTRING('abcdefg' SIMILAR 'a*#"%#"g*' ESCAPE '#') AS "abcdefg"; + +-- Vertical bar in any part affects only that part +SELECT SUBSTRING('abcdefg' SIMILAR 'a|b#"%#"g' ESCAPE '#') AS "bcdef"; +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"%#"x|g' ESCAPE '#') AS "bcdef"; +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"%|ab#"g' ESCAPE '#') AS "bcdef"; + +-- Can't have more than two part separators +SELECT SUBSTRING('abcdefg' SIMILAR 'a*#"%#"g*#"x' ESCAPE '#') AS "error"; + +-- Postgres extension: with 0 or 1 separator, assume parts 1 and 3 are empty +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"%g' ESCAPE '#') AS "bcdefg"; +SELECT SUBSTRING('abcdefg' SIMILAR 'a%g' ESCAPE '#') AS "abcdefg"; + +-- substring() with just two arguments is not allowed by SQL spec; +-- we accept it, but we interpret the pattern as a POSIX regexp not SQL +SELECT SUBSTRING('abcdefg' FROM 'c.e') AS "cde"; + +-- With a parenthesized subexpression, return only what matches the subexpr +SELECT SUBSTRING('abcdefg' FROM 'b(.*)f') AS "cde"; +-- Check case where we have a match, but not a subexpression match +SELECT SUBSTRING('foo' FROM 'foo(bar)?') IS NULL AS t; + +-- Check behavior of SIMILAR TO, which uses largely the same regexp variant +SELECT 'abcdefg' SIMILAR TO '_bcd%' AS true; +SELECT 'abcdefg' SIMILAR TO 'bcd%' AS false; +SELECT 'abcdefg' SIMILAR TO '_bcd#%' ESCAPE '#' AS false; +SELECT 'abcd%' SIMILAR TO '_bcd#%' ESCAPE '#' AS true; +-- Postgres uses '\' as the default escape character, which is not per spec +SELECT 'abcdefg' SIMILAR TO '_bcd\%' AS false; +-- and an empty string to mean "no escape", which is also not per spec +SELECT 'abcd\efg' SIMILAR TO '_bcd\%' ESCAPE '' AS true; +-- these behaviors are per spec, though: +SELECT 'abcdefg' SIMILAR TO '_bcd%' ESCAPE NULL AS null; +SELECT 'abcdefg' SIMILAR TO '_bcd#%' ESCAPE '##' AS error; + +-- Characters that should be left alone in character classes when a +-- SIMILAR TO regexp pattern is converted to POSIX style. +-- Underscore "_" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '_[_[:alpha:]_]_'; +-- Percentage "%" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '%[%[:alnum:]%]%'; +-- Dot "." +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '.[.[:alnum:].].'; +-- Dollar "$" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '$[$[:alnum:]$]$'; +-- Opening parenthesis "(" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '()[([:alnum:](]()'; +-- Caret "^" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '^[^[:alnum:]^[^^][[^^]][\^][[\^]]\^]^'; +-- Closing square bracket "]" at the beginning of character class +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '[]%][^]%][^%]%'; +-- Closing square bracket effective after two carets at the beginning +-- of character class. +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '[^^]^'; +-- Closing square bracket after an escape sequence at the beginning of +-- a character closes the character class +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '[|a]%' ESCAPE '|'; + +-- Test backslash escapes in regexp_replace's replacement string +SELECT regexp_replace('1112223333', E'(\\d{3})(\\d{3})(\\d{4})', E'(\\1) \\2-\\3'); +SELECT regexp_replace('foobarrbazz', E'(.)\\1', E'X\\&Y', 'g'); +SELECT regexp_replace('foobarrbazz', E'(.)\\1', E'X\\\\Y', 'g'); +-- not an error, though perhaps it should be: +SELECT regexp_replace('foobarrbazz', E'(.)\\1', E'X\\Y\\1Z\\'); + +SELECT regexp_replace('AAA BBB CCC ', E'\\s+', ' ', 'g'); +SELECT regexp_replace('AAA', '^|$', 'Z', 'g'); +SELECT regexp_replace('AAA aaa', 'A+', 'Z', 'gi'); +-- invalid regexp option +SELECT regexp_replace('AAA aaa', 'A+', 'Z', 'z'); + +-- extended regexp_replace tests +SELECT regexp_replace('A PostgreSQL function', 'A|e|i|o|u', 'X', 1); +SELECT regexp_replace('A PostgreSQL function', 'A|e|i|o|u', 'X', 1, 2); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 0, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 1, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 2, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 3, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 9, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'A|e|i|o|u', 'X', 7, 0, 'i'); +-- 'g' flag should be ignored when N is specified +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 1, 'g'); +-- errors +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', -1, 0, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, -1, 'i'); +-- erroneous invocation of non-extended form +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', '1'); + +-- regexp_count tests +SELECT regexp_count('123123123123123', '(12)3'); +SELECT regexp_count('123123123123', '123', 1); +SELECT regexp_count('123123123123', '123', 3); +SELECT regexp_count('123123123123', '123', 33); +SELECT regexp_count('ABCABCABCABC', 'Abc', 1, ''); +SELECT regexp_count('ABCABCABCABC', 'Abc', 1, 'i'); +-- errors +SELECT regexp_count('123123123123', '123', 0); +SELECT regexp_count('123123123123', '123', -3); + +-- regexp_like tests +SELECT regexp_like('Steven', '^Ste(v|ph)en$'); +SELECT regexp_like('a'||CHR(10)||'d', 'a.d', 'n'); +SELECT regexp_like('a'||CHR(10)||'d', 'a.d', 's'); +SELECT regexp_like('abc', ' a . c ', 'x'); +SELECT regexp_like('abc', 'a.c', 'g'); -- error + +-- regexp_instr tests +SELECT regexp_instr('abcdefghi', 'd.f'); +SELECT regexp_instr('abcdefghi', 'd.q'); +SELECT regexp_instr('abcabcabc', 'a.c'); +SELECT regexp_instr('abcabcabc', 'a.c', 2); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 3); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 4); +SELECT regexp_instr('abcabcabc', 'A.C', 1, 2, 0, 'i'); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 0); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 1); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 2); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 3); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 4); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 5); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 0); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 1); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 2); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 3); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 4); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 5); +-- Check case where we have a match, but not a subexpression match +SELECT regexp_instr('foo', 'foo(bar)?', 1, 1, 0, '', 1); +-- errors +SELECT regexp_instr('abcabcabc', 'a.c', 0, 1); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 0); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 1, -1); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 1, 2); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 1, 0, 'g'); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 1, 0, '', -1); + +-- regexp_substr tests +SELECT regexp_substr('abcdefghi', 'd.f'); +SELECT regexp_substr('abcdefghi', 'd.q') IS NULL AS t; +SELECT regexp_substr('abcabcabc', 'a.c'); +SELECT regexp_substr('abcabcabc', 'a.c', 2); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 3); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 4) IS NULL AS t; +SELECT regexp_substr('abcabcabc', 'A.C', 1, 2, 'i'); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 0); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 1); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 2); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 3); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 4); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 5) IS NULL AS t; +-- Check case where we have a match, but not a subexpression match +SELECT regexp_substr('foo', 'foo(bar)?', 1, 1, '', 1) IS NULL AS t; +-- errors +SELECT regexp_substr('abcabcabc', 'a.c', 0, 1); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 0); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 1, 'g'); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 1, '', -1); + +-- set so we can tell NULL from empty string + +-- return all matches from regexp +SELECT regexp_matches('foobarbequebaz', $re$(bar)(beque)$re$); + +-- test case insensitive +SELECT regexp_matches('foObARbEqUEbAz', $re$(bar)(beque)$re$, 'i'); + +-- global option - more than one match +SELECT regexp_matches('foobarbequebazilbarfbonk', $re$(b[^b]+)(b[^b]+)$re$, 'g'); + +-- empty capture group (matched empty string) +SELECT regexp_matches('foobarbequebaz', $re$(bar)(.*)(beque)$re$); +-- no match +SELECT regexp_matches('foobarbequebaz', $re$(bar)(.+)(beque)$re$); +-- optional capture group did not match, null entry in array +SELECT regexp_matches('foobarbequebaz', $re$(bar)(.+)?(beque)$re$); + +-- no capture groups +SELECT regexp_matches('foobarbequebaz', $re$barbeque$re$); + +-- start/end-of-line matches are of zero length +SELECT regexp_matches('foo' || chr(10) || 'bar' || chr(10) || 'bequq' || chr(10) || 'baz', '^', 'mg'); +SELECT regexp_matches('foo' || chr(10) || 'bar' || chr(10) || 'bequq' || chr(10) || 'baz', '$', 'mg'); +SELECT regexp_matches('1' || chr(10) || '2' || chr(10) || '3' || chr(10) || '4' || chr(10), '^.?', 'mg'); +SELECT regexp_matches(chr(10) || '1' || chr(10) || '2' || chr(10) || '3' || chr(10) || '4' || chr(10), '.?$', 'mg'); +SELECT regexp_matches(chr(10) || '1' || chr(10) || '2' || chr(10) || '3' || chr(10) || '4', '.?$', 'mg'); + +-- give me errors +SELECT regexp_matches('foobarbequebaz', $re$(bar)(beque)$re$, 'gz'); +SELECT regexp_matches('foobarbequebaz', $re$(barbeque$re$); +SELECT regexp_matches('foobarbequebaz', $re$(bar)(beque){2,1}$re$); + +-- split string on regexp +SELECT foo, length(foo) FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', $re$\s+$re$) AS foo; +SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', $re$\s+$re$); + +SELECT foo, length(foo) FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', $re$\s*$re$) AS foo; +SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', $re$\s*$re$); +SELECT foo, length(foo) FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', '') AS foo; +SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', ''); +-- case insensitive +SELECT foo, length(foo) FROM regexp_split_to_table('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'i') AS foo; +SELECT regexp_split_to_array('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'i'); +-- no match of pattern +SELECT foo, length(foo) FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', 'nomatch') AS foo; +SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', 'nomatch'); +-- some corner cases +SELECT regexp_split_to_array('123456','1'); +SELECT regexp_split_to_array('123456','6'); +SELECT regexp_split_to_array('123456','.'); +SELECT regexp_split_to_array('123456',''); +SELECT regexp_split_to_array('123456','(?:)'); +SELECT regexp_split_to_array('1',''); +-- errors +SELECT foo, length(foo) FROM regexp_split_to_table('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'zippy') AS foo; +SELECT regexp_split_to_array('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'iz'); +-- global option meaningless for regexp_split +SELECT foo, length(foo) FROM regexp_split_to_table('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'g') AS foo; +SELECT regexp_split_to_array('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'g'); + +-- change NULL-display back + +-- E021-11 position expression +SELECT POSITION('4' IN '1234567890') = '4' AS "4"; + +SELECT POSITION('5' IN '1234567890') = '5' AS "5"; + +-- T312 character overlay function +SELECT OVERLAY('abcdef' PLACING '45' FROM 4) AS "abc45f"; + +SELECT OVERLAY('yabadoo' PLACING 'daba' FROM 5) AS "yabadaba"; + +SELECT OVERLAY('yabadoo' PLACING 'daba' FROM 5 FOR 0) AS "yabadabadoo"; + +SELECT OVERLAY('babosa' PLACING 'ubb' FROM 2 FOR 4) AS "bubba"; + +|-- +-- test LIKE +-- Be sure to form every test as a LIKE/NOT LIKE pair. +|-- + +-- simplest examples +-- E061-04 like predicate +SELECT 'hawkeye' LIKE 'h%' AS "true"; +SELECT 'hawkeye' NOT LIKE 'h%' AS "false"; + +SELECT 'hawkeye' LIKE 'H%' AS "false"; +SELECT 'hawkeye' NOT LIKE 'H%' AS "true"; + +SELECT 'hawkeye' LIKE 'indio%' AS "false"; +SELECT 'hawkeye' NOT LIKE 'indio%' AS "true"; + +SELECT 'hawkeye' LIKE 'h%eye' AS "true"; +SELECT 'hawkeye' NOT LIKE 'h%eye' AS "false"; + +SELECT 'indio' LIKE '_ndio' AS "true"; +SELECT 'indio' NOT LIKE '_ndio' AS "false"; + +SELECT 'indio' LIKE 'in__o' AS "true"; +SELECT 'indio' NOT LIKE 'in__o' AS "false"; + +SELECT 'indio' LIKE 'in_o' AS "false"; +SELECT 'indio' NOT LIKE 'in_o' AS "true"; + +SELECT 'abc'::name LIKE '_b_' AS "true"; +SELECT 'abc'::name NOT LIKE '_b_' AS "false"; + +SELECT 'abc'::bytea LIKE '_b_'::bytea AS "true"; +SELECT 'abc'::bytea NOT LIKE '_b_'::bytea AS "false"; + +-- unused escape character +SELECT 'hawkeye' LIKE 'h%' ESCAPE '#' AS "true"; +SELECT 'hawkeye' NOT LIKE 'h%' ESCAPE '#' AS "false"; + +SELECT 'indio' LIKE 'ind_o' ESCAPE '$' AS "true"; +SELECT 'indio' NOT LIKE 'ind_o' ESCAPE '$' AS "false"; + +-- escape character +-- E061-05 like predicate with escape clause +SELECT 'h%' LIKE 'h#%' ESCAPE '#' AS "true"; +SELECT 'h%' NOT LIKE 'h#%' ESCAPE '#' AS "false"; + +SELECT 'h%wkeye' LIKE 'h#%' ESCAPE '#' AS "false"; +SELECT 'h%wkeye' NOT LIKE 'h#%' ESCAPE '#' AS "true"; + +SELECT 'h%wkeye' LIKE 'h#%%' ESCAPE '#' AS "true"; +SELECT 'h%wkeye' NOT LIKE 'h#%%' ESCAPE '#' AS "false"; + +SELECT 'h%awkeye' LIKE 'h#%a%k%e' ESCAPE '#' AS "true"; +SELECT 'h%awkeye' NOT LIKE 'h#%a%k%e' ESCAPE '#' AS "false"; + +SELECT 'indio' LIKE '_ndio' ESCAPE '$' AS "true"; +SELECT 'indio' NOT LIKE '_ndio' ESCAPE '$' AS "false"; + +SELECT 'i_dio' LIKE 'i$_d_o' ESCAPE '$' AS "true"; +SELECT 'i_dio' NOT LIKE 'i$_d_o' ESCAPE '$' AS "false"; + +SELECT 'i_dio' LIKE 'i$_nd_o' ESCAPE '$' AS "false"; +SELECT 'i_dio' NOT LIKE 'i$_nd_o' ESCAPE '$' AS "true"; + +SELECT 'i_dio' LIKE 'i$_d%o' ESCAPE '$' AS "true"; +SELECT 'i_dio' NOT LIKE 'i$_d%o' ESCAPE '$' AS "false"; + +SELECT 'a_c'::bytea LIKE 'a$__'::bytea ESCAPE '$'::bytea AS "true"; +SELECT 'a_c'::bytea NOT LIKE 'a$__'::bytea ESCAPE '$'::bytea AS "false"; + +-- escape character same as pattern character +SELECT 'maca' LIKE 'm%aca' ESCAPE '%' AS "true"; +SELECT 'maca' NOT LIKE 'm%aca' ESCAPE '%' AS "false"; + +SELECT 'ma%a' LIKE 'm%a%%a' ESCAPE '%' AS "true"; +SELECT 'ma%a' NOT LIKE 'm%a%%a' ESCAPE '%' AS "false"; + +SELECT 'bear' LIKE 'b_ear' ESCAPE '_' AS "true"; +SELECT 'bear' NOT LIKE 'b_ear' ESCAPE '_' AS "false"; + +SELECT 'be_r' LIKE 'b_e__r' ESCAPE '_' AS "true"; +SELECT 'be_r' NOT LIKE 'b_e__r' ESCAPE '_' AS "false"; + +SELECT 'be_r' LIKE '__e__r' ESCAPE '_' AS "false"; +SELECT 'be_r' NOT LIKE '__e__r' ESCAPE '_' AS "true"; + + +|-- +-- test ILIKE (case-insensitive LIKE) +-- Be sure to form every test as an ILIKE/NOT ILIKE pair. +|-- + +SELECT 'hawkeye' ILIKE 'h%' AS "true"; +SELECT 'hawkeye' NOT ILIKE 'h%' AS "false"; + +SELECT 'hawkeye' ILIKE 'H%' AS "true"; +SELECT 'hawkeye' NOT ILIKE 'H%' AS "false"; + +SELECT 'hawkeye' ILIKE 'H%Eye' AS "true"; +SELECT 'hawkeye' NOT ILIKE 'H%Eye' AS "false"; + +SELECT 'Hawkeye' ILIKE 'h%' AS "true"; +SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; + +SELECT 'ABC'::name ILIKE '_b_' AS "true"; +SELECT 'ABC'::name NOT ILIKE '_b_' AS "false"; + +|-- +-- test %/_ combination cases, cf bugs #4821 and #5478 +|-- + +SELECT 'foo' LIKE '_%' as t, 'f' LIKE '_%' as t, '' LIKE '_%' as f; +SELECT 'foo' LIKE '%_' as t, 'f' LIKE '%_' as t, '' LIKE '%_' as f; + +SELECT 'foo' LIKE '__%' as t, 'foo' LIKE '___%' as t, 'foo' LIKE '____%' as f; +SELECT 'foo' LIKE '%__' as t, 'foo' LIKE '%___' as t, 'foo' LIKE '%____' as f; + +SELECT 'jack' LIKE '%____%' AS t; + + +|-- +-- basic tests of LIKE with indexes +|-- + +CREATE TABLE texttest (a text PRIMARY KEY, b int); +SELECT * FROM texttest WHERE a LIKE '%1%'; + +CREATE TABLE byteatest (a bytea PRIMARY KEY, b int); +SELECT * FROM byteatest WHERE a LIKE '%1%'; + +DROP TABLE texttest, byteatest; + + +|-- +-- test implicit type conversion +|-- + +-- E021-07 character concatenation +SELECT 'unknown' || ' and unknown' AS "Concat unknown types"; + +SELECT text 'text' || ' and unknown' AS "Concat text to unknown type"; + +SELECT char(20) 'characters' || ' and text' AS "Concat char to unknown type"; + +SELECT text 'text' || char(20) ' and characters' AS "Concat text to char"; + +SELECT text 'text' || varchar ' and varchar' AS "Concat text to varchar"; + +|-- +-- test substr with toasted text values +|-- +CREATE TABLE toasttest(f1 text); + +insert into toasttest values(repeat('1234567890',10000)); +insert into toasttest values(repeat('1234567890',10000)); + +|-- +-- Ensure that some values are uncompressed, to test the faster substring +-- operation used in that case +|-- +alter table toasttest alter column f1 set storage external; +insert into toasttest values(repeat('1234567890',10000)); +insert into toasttest values(repeat('1234567890',10000)); + +-- If the starting position is zero or less, then return from the start of the string +-- adjusting the length to be consistent with the "negative start" per SQL. +SELECT substr(f1, -1, 5) from toasttest; + +-- If the length is less than zero, an ERROR is thrown. +SELECT substr(f1, 5, -1) from toasttest; + +-- If no third argument (length) is provided, the length to the end of the +-- string is assumed. +SELECT substr(f1, 99995) from toasttest; + +-- If start plus length is > string length, the result is truncated to +-- string length +SELECT substr(f1, 99995, 10) from toasttest; + +TRUNCATE TABLE toasttest; +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +-- expect >0 blocks +SELECT pg_relation_size(reltoastrelid) = 0 AS is_empty + FROM pg_class where relname = 'toasttest'; + +TRUNCATE TABLE toasttest; +ALTER TABLE toasttest set (toast_tuple_target = 4080); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +-- expect 0 blocks +SELECT pg_relation_size(reltoastrelid) = 0 AS is_empty + FROM pg_class where relname = 'toasttest'; + +DROP TABLE toasttest; + +|-- +-- test substr with toasted bytea values +|-- +CREATE TABLE toasttest(f1 bytea); + +insert into toasttest values(decode(repeat('1234567890',10000),'escape')); +insert into toasttest values(decode(repeat('1234567890',10000),'escape')); + +|-- +-- Ensure that some values are uncompressed, to test the faster substring +-- operation used in that case +|-- +alter table toasttest alter column f1 set storage external; +insert into toasttest values(decode(repeat('1234567890',10000),'escape')); +insert into toasttest values(decode(repeat('1234567890',10000),'escape')); + +-- If the starting position is zero or less, then return from the start of the string +-- adjusting the length to be consistent with the "negative start" per SQL. +SELECT substr(f1, -1, 5) from toasttest; + +-- If the length is less than zero, an ERROR is thrown. +SELECT substr(f1, 5, -1) from toasttest; + +-- If no third argument (length) is provided, the length to the end of the +-- string is assumed. +SELECT substr(f1, 99995) from toasttest; + +-- If start plus length is > string length, the result is truncated to +-- string length +SELECT substr(f1, 99995, 10) from toasttest; + +DROP TABLE toasttest; + +-- test internally compressing datums + +-- this tests compressing a datum to a very small size which exercises a +-- corner case in packed-varlena handling: even though small, the compressed +-- datum must be given a 4-byte header because there are no bits to indicate +-- compression in a 1-byte header + +CREATE TABLE toasttest (c char(4096)); +INSERT INTO toasttest VALUES('x'); +SELECT length(c), c::text FROM toasttest; +SELECT c FROM toasttest; +DROP TABLE toasttest; + +|-- +-- test length +|-- + +SELECT length('abcdef') AS "length_6"; + +|-- +-- test strpos +|-- + +SELECT strpos('abcdef', 'cd') AS "pos_3"; + +SELECT strpos('abcdef', 'xy') AS "pos_0"; + +SELECT strpos('abcdef', '') AS "pos_1"; + +SELECT strpos('', 'xy') AS "pos_0"; + +SELECT strpos('', '') AS "pos_1"; + +|-- +-- test replace +|-- +SELECT replace('abcdef', 'de', '45') AS "abc45f"; + +SELECT replace('yabadabadoo', 'ba', '123') AS "ya123da123doo"; + +SELECT replace('yabadoo', 'bad', '') AS "yaoo"; + +|-- +-- test split_part +|-- +select split_part('','@',1) AS "empty string"; + +select split_part('','@',-1) AS "empty string"; + +select split_part('joeuser@mydatabase','',1) AS "joeuser@mydatabase"; + +select split_part('joeuser@mydatabase','',2) AS "empty string"; + +select split_part('joeuser@mydatabase','',-1) AS "joeuser@mydatabase"; + +select split_part('joeuser@mydatabase','',-2) AS "empty string"; + +select split_part('joeuser@mydatabase','@',0) AS "an error"; + +select split_part('joeuser@mydatabase','@@',1) AS "joeuser@mydatabase"; + +select split_part('joeuser@mydatabase','@@',2) AS "empty string"; + +select split_part('joeuser@mydatabase','@',1) AS "joeuser"; + +select split_part('joeuser@mydatabase','@',2) AS "mydatabase"; + +select split_part('joeuser@mydatabase','@',3) AS "empty string"; + +select split_part('@joeuser@mydatabase@','@',2) AS "joeuser"; + +select split_part('joeuser@mydatabase','@',-1) AS "mydatabase"; + +select split_part('joeuser@mydatabase','@',-2) AS "joeuser"; + +select split_part('joeuser@mydatabase','@',-3) AS "empty string"; + +select split_part('@joeuser@mydatabase@','@',-2) AS "mydatabase"; + +|-- +-- test to_bin, to_oct, and to_hex +|-- +select to_bin(-1234) AS "11111111111111111111101100101110"; +select to_bin(-1234::bigint); +select to_bin(256*256*256 - 1) AS "111111111111111111111111"; +select to_bin(256::bigint*256::bigint*256::bigint*256::bigint - 1) AS "11111111111111111111111111111111"; + +select to_oct(-1234) AS "37777775456"; +select to_oct(-1234::bigint) AS "1777777777777777775456"; +select to_oct(256*256*256 - 1) AS "77777777"; +select to_oct(256::bigint*256::bigint*256::bigint*256::bigint - 1) AS "37777777777"; + +select to_hex(-1234) AS "fffffb2e"; +select to_hex(-1234::bigint) AS "fffffffffffffb2e"; +select to_hex(256*256*256 - 1) AS "ffffff"; +select to_hex(256::bigint*256::bigint*256::bigint*256::bigint - 1) AS "ffffffff"; + +|-- +-- SHA-2 +|-- +SET bytea_output TO hex; + +SELECT sha224(''); +SELECT sha224('The quick brown fox jumps over the lazy dog.'); + +SELECT sha256(''); +SELECT sha256('The quick brown fox jumps over the lazy dog.'); + +SELECT sha384(''); +SELECT sha384('The quick brown fox jumps over the lazy dog.'); + +SELECT sha512(''); +SELECT sha512('The quick brown fox jumps over the lazy dog.'); + +|-- +-- encode/decode +|-- +SELECT encode('\x1234567890abcdef00', 'hex'); +SELECT decode('1234567890abcdef00', 'hex'); +SELECT encode(('\x' || repeat('1234567890abcdef0001', 7))::bytea, 'base64'); +SELECT decode(encode(('\x' || repeat('1234567890abcdef0001', 7))::bytea, + 'base64'), 'base64'); +SELECT encode('\x1234567890abcdef00', 'escape'); +SELECT decode(encode('\x1234567890abcdef00', 'escape'), 'escape'); + +|-- +-- get_bit/set_bit etc +|-- +SELECT get_bit('\x1234567890abcdef00'::bytea, 43); +SELECT get_bit('\x1234567890abcdef00'::bytea, 99); -- error +SELECT set_bit('\x1234567890abcdef00'::bytea, 43, 0); +SELECT set_bit('\x1234567890abcdef00'::bytea, 99, 0); -- error +SELECT get_byte('\x1234567890abcdef00'::bytea, 3); +SELECT get_byte('\x1234567890abcdef00'::bytea, 99); -- error +SELECT set_byte('\x1234567890abcdef00'::bytea, 7, 11); +SELECT set_byte('\x1234567890abcdef00'::bytea, 99, 11); -- error + +|-- +-- test behavior of escape_string_warning and standard_conforming_strings options +|-- +set escape_string_warning = off; +set standard_conforming_strings = off; + +show escape_string_warning; +show standard_conforming_strings; + +set escape_string_warning = on; +set standard_conforming_strings = on; + +show escape_string_warning; +show standard_conforming_strings; + +select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6; + +set standard_conforming_strings = off; + +select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6; + +set escape_string_warning = off; +set standard_conforming_strings = on; + +select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6; + +set standard_conforming_strings = off; + +select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6; + +reset standard_conforming_strings; + + +|-- +-- Additional string functions +|-- +SET bytea_output TO escape; + +SELECT initcap('hi THOMAS'); + +SELECT lpad('hi', 5, 'xy'); +SELECT lpad('hi', 5); +SELECT lpad('hi', -5, 'xy'); +SELECT lpad('hello', 2); +SELECT lpad('hi', 5, ''); + +SELECT rpad('hi', 5, 'xy'); +SELECT rpad('hi', 5); +SELECT rpad('hi', -5, 'xy'); +SELECT rpad('hello', 2); +SELECT rpad('hi', 5, ''); + +SELECT ltrim('zzzytrim', 'xyz'); + +SELECT translate('', '14', 'ax'); +SELECT translate('12345', '14', 'ax'); +SELECT translate('12345', '134', 'a'); + +SELECT ascii('x'); +SELECT ascii(''); + +SELECT chr(65); +SELECT chr(0); + +SELECT repeat('Pg', 4); +SELECT repeat('Pg', -4); + +SELECT SUBSTRING('1234567890'::bytea FROM 3) "34567890"; +SELECT SUBSTRING('1234567890'::bytea FROM 4 FOR 3) AS "456"; +SELECT SUBSTRING('string'::bytea FROM 2 FOR 2147483646) AS "tring"; +SELECT SUBSTRING('string'::bytea FROM -10 FOR 2147483646) AS "string"; +SELECT SUBSTRING('string'::bytea FROM -10 FOR -2147483646) AS "error"; + +SELECT trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea); +SELECT trim(leading E'\\000'::bytea from E'\\000Tom\\000'::bytea); +SELECT trim(trailing E'\\000'::bytea from E'\\000Tom\\000'::bytea); +SELECT btrim(E'\\000trim\\000'::bytea, E'\\000'::bytea); +SELECT btrim(''::bytea, E'\\000'::bytea); +SELECT btrim(E'\\000trim\\000'::bytea, ''::bytea); +SELECT encode(overlay(E'Th\\000omas'::bytea placing E'Th\\001omas'::bytea from 2),'escape'); +SELECT encode(overlay(E'Th\\000omas'::bytea placing E'\\002\\003'::bytea from 8),'escape'); +SELECT encode(overlay(E'Th\\000omas'::bytea placing E'\\002\\003'::bytea from 5 for 3),'escape'); + +SELECT bit_count('\x1234567890'::bytea); + +SELECT unistr('\0064at\+0000610'); +SELECT unistr('d\u0061t\U000000610'); +SELECT unistr('a\\b'); +-- errors: +SELECT unistr('wrong: \db99'); +SELECT unistr('wrong: \db99\0061'); +SELECT unistr('wrong: \+00db99\+000061'); +SELECT unistr('wrong: \+2FFFFF'); +SELECT unistr('wrong: \udb99\u0061'); +SELECT unistr('wrong: \U0000db99\U00000061'); +SELECT unistr('wrong: \U002FFFFF'); +SELECT unistr('wrong: \xyz'); +-- +ERROR: syntax error at or near "' - third line'" +CURSORPOS: 318 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary/postgres_regress/subscription.metadata.json b/parser/testdata/summary/postgres_regress/subscription.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/subscription.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/subscription.test b/parser/testdata/summary/postgres_regress/subscription.test new file mode 100644 index 0000000..0972398 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/subscription.test @@ -0,0 +1,733 @@ +== 001 +|-- +-- SUBSCRIPTION +|-- + +CREATE ROLE regress_subscription_user LOGIN SUPERUSER +-- +STMT: CreateRoleStmt +== 002 +CREATE ROLE regress_subscription_user2 +-- +STMT: CreateRoleStmt +== 003 +CREATE ROLE regress_subscription_user3 IN ROLE pg_create_subscription +-- +STMT: CreateRoleStmt +== 004 +CREATE ROLE regress_subscription_user_dummy LOGIN NOSUPERUSER +-- +STMT: CreateRoleStmt +== 005 +SET SESSION AUTHORIZATION 'regress_subscription_user' +-- +STMT: VariableSetStmt +== 006 +-- fail - no publications +CREATE SUBSCRIPTION regress_testsub CONNECTION 'foo' +-- +ERROR: syntax error at end of input +CURSORPOS: 79 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- fail - no connection +CREATE SUBSCRIPTION regress_testsub PUBLICATION foo +-- +ERROR: syntax error at or near "PUBLICATION" +CURSORPOS: 61 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +-- fail - cannot do CREATE SUBSCRIPTION CREATE SLOT inside transaction block +BEGIN +-- +STMT: TransactionStmt +== 009 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'testconn' PUBLICATION testpub WITH (create_slot) +-- +STMT: CreateSubscriptionStmt +== 010 +COMMIT +-- +STMT: TransactionStmt +== 011 +-- fail - invalid connection string +CREATE SUBSCRIPTION regress_testsub CONNECTION 'testconn' PUBLICATION testpub +-- +STMT: CreateSubscriptionStmt +== 012 +-- fail - duplicate publications +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION foo, testpub, foo WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +== 013 +-- ok +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +== 014 +COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription' +-- +STMT: CommentStmt +== 015 +SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s +-- +TABLE: name="pg_subscription" schema="" table="pg_subscription" ctx=Select +ALIAS: "s"="pg_subscription" +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- Check if the subscription stats are created and stats_reset is updated +-- by pg_stat_reset_subscription_stats(). +SELECT subname, stats_reset IS NULL stats_reset_is_null FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_stat_subscription_stats" schema="" table="pg_stat_subscription_stats" ctx=Select +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +== 017 +SELECT pg_stat_reset_subscription_stats(oid) FROM pg_subscription WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_subscription" schema="" table="pg_subscription" ctx=Select +FUNCTION: name="pg_stat_reset_subscription_stats" function="pg_stat_reset_subscription_stats" schema="" ctx=Call +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +== 018 +SELECT subname, stats_reset IS NULL stats_reset_is_null FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_stat_subscription_stats" schema="" table="pg_stat_subscription_stats" ctx=Select +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +== 019 +-- Reset the stats again and check if the new reset_stats is updated. +SELECT stats_reset as prev_stats_reset FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_stat_subscription_stats" schema="" table="pg_stat_subscription_stats" ctx=Select +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +== 020 +SELECT pg_stat_reset_subscription_stats(oid) FROM pg_subscription WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_subscription" schema="" table="pg_subscription" ctx=Select +FUNCTION: name="pg_stat_reset_subscription_stats" function="pg_stat_reset_subscription_stats" schema="" ctx=Call +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +== 021 +SELECT :'prev_stats_reset' < stats_reset FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 022 +-- fail - name already exists +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +== 023 +-- fail - must be superuser +SET SESSION AUTHORIZATION 'regress_subscription_user2' +-- +STMT: VariableSetStmt +== 024 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION foo WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +== 025 +SET SESSION AUTHORIZATION 'regress_subscription_user' +-- +STMT: VariableSetStmt +== 026 +-- fail - invalid option combinations +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, copy_data = true) +-- +STMT: CreateSubscriptionStmt +== 027 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, enabled = true) +-- +STMT: CreateSubscriptionStmt +== 028 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, create_slot = true) +-- +STMT: CreateSubscriptionStmt +== 029 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, enabled = true) +-- +STMT: CreateSubscriptionStmt +== 030 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, enabled = false, create_slot = true) +-- +STMT: CreateSubscriptionStmt +== 031 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE) +-- +STMT: CreateSubscriptionStmt +== 032 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, enabled = false) +-- +STMT: CreateSubscriptionStmt +== 033 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, create_slot = false) +-- +STMT: CreateSubscriptionStmt +== 034 +-- ok - with slot_name = NONE +CREATE SUBSCRIPTION regress_testsub3 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false) +-- +STMT: CreateSubscriptionStmt +== 035 +-- fail +ALTER SUBSCRIPTION regress_testsub3 ENABLE +-- +STMT: AlterSubscriptionStmt +== 036 +ALTER SUBSCRIPTION regress_testsub3 REFRESH PUBLICATION +-- +STMT: AlterSubscriptionStmt +== 037 +-- fail - origin must be either none or any +CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false, origin = foo) +-- +STMT: CreateSubscriptionStmt +== 038 +-- now it works +CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false, origin = none) +-- +STMT: CreateSubscriptionStmt +== 039 +ALTER SUBSCRIPTION regress_testsub4 SET (origin = any) +-- +STMT: AlterSubscriptionStmt +== 040 +DROP SUBSCRIPTION regress_testsub3 +-- +STMT: DropSubscriptionStmt +== 041 +DROP SUBSCRIPTION regress_testsub4 +-- +STMT: DropSubscriptionStmt +== 042 +-- fail, connection string does not parse +CREATE SUBSCRIPTION regress_testsub5 CONNECTION 'i_dont_exist=param' PUBLICATION testpub +-- +STMT: CreateSubscriptionStmt +== 043 +-- fail, connection string parses, but doesn't work (and does so without +-- connecting, so this is reliable and safe) +CREATE SUBSCRIPTION regress_testsub5 CONNECTION 'port=-1' PUBLICATION testpub +-- +STMT: CreateSubscriptionStmt +== 044 +-- fail - invalid connection string during ALTER +ALTER SUBSCRIPTION regress_testsub CONNECTION 'foobar' +-- +STMT: AlterSubscriptionStmt +== 045 +ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 046 +ALTER SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist2' +-- +STMT: AlterSubscriptionStmt +== 047 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname') +-- +STMT: AlterSubscriptionStmt +== 048 +ALTER SUBSCRIPTION regress_testsub SET (password_required = false) +-- +STMT: AlterSubscriptionStmt +== 049 +ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true) +-- +STMT: AlterSubscriptionStmt +== 050 +ALTER SUBSCRIPTION regress_testsub SET (password_required = true) +-- +STMT: AlterSubscriptionStmt +== 051 +ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = false) +-- +STMT: AlterSubscriptionStmt +== 052 +-- fail +ALTER SUBSCRIPTION regress_testsub SET (slot_name = '') +-- +STMT: AlterSubscriptionStmt +== 053 +-- fail +ALTER SUBSCRIPTION regress_doesnotexist CONNECTION 'dbname=regress_doesnotexist2' +-- +STMT: AlterSubscriptionStmt +== 054 +ALTER SUBSCRIPTION regress_testsub SET (create_slot = false) +-- +STMT: AlterSubscriptionStmt +== 055 +-- ok +ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/12345') +-- +STMT: AlterSubscriptionStmt +== 056 +-- ok - with lsn = NONE +ALTER SUBSCRIPTION regress_testsub SKIP (lsn = NONE) +-- +STMT: AlterSubscriptionStmt +== 057 +-- fail +ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/0') +-- +STMT: AlterSubscriptionStmt +== 058 +BEGIN +-- +STMT: TransactionStmt +== 059 +ALTER SUBSCRIPTION regress_testsub ENABLE +-- +STMT: AlterSubscriptionStmt +== 060 +ALTER SUBSCRIPTION regress_testsub DISABLE +-- +STMT: AlterSubscriptionStmt +== 061 +COMMIT +-- +STMT: TransactionStmt +== 062 +-- fail - must be owner of subscription +SET ROLE regress_subscription_user_dummy +-- +STMT: VariableSetStmt +== 063 +ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_dummy +-- +STMT: RenameStmt +== 064 +RESET ROLE +-- +STMT: VariableSetStmt +== 065 +ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_foo +-- +STMT: RenameStmt +== 066 +ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local) +-- +STMT: AlterSubscriptionStmt +== 067 +ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar) +-- +STMT: AlterSubscriptionStmt +== 068 +-- rename back to keep the rest simple +ALTER SUBSCRIPTION regress_testsub_foo RENAME TO regress_testsub +-- +STMT: RenameStmt +== 069 +-- ok, we're a superuser +ALTER SUBSCRIPTION regress_testsub OWNER TO regress_subscription_user2 +-- +STMT: AlterOwnerStmt +== 070 +-- fail - cannot do DROP SUBSCRIPTION inside transaction block with slot name +BEGIN +-- +STMT: TransactionStmt +== 071 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 072 +COMMIT +-- +STMT: TransactionStmt +== 073 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +== 074 +-- now it works +BEGIN +-- +STMT: TransactionStmt +== 075 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 076 +COMMIT +-- +STMT: TransactionStmt +== 077 +DROP SUBSCRIPTION IF EXISTS regress_testsub +-- +STMT: DropSubscriptionStmt +== 078 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 079 +-- fail + +-- fail - binary must be boolean +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, binary = foo) +-- +STMT: CreateSubscriptionStmt +== 080 +-- now it works +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, binary = true) +-- +STMT: CreateSubscriptionStmt +== 081 +ALTER SUBSCRIPTION regress_testsub SET (binary = false) +-- +STMT: AlterSubscriptionStmt +== 082 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +== 083 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 084 +-- fail - streaming must be boolean or 'parallel' +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, streaming = foo) +-- +STMT: CreateSubscriptionStmt +== 085 +-- now it works +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, streaming = true) +-- +STMT: CreateSubscriptionStmt +== 086 +ALTER SUBSCRIPTION regress_testsub SET (streaming = parallel) +-- +STMT: AlterSubscriptionStmt +== 087 +ALTER SUBSCRIPTION regress_testsub SET (streaming = false) +-- +STMT: AlterSubscriptionStmt +== 088 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +== 089 +-- fail - publication already exists +ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 090 +-- fail - publication used more than once +ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub1 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 091 +-- ok - add two publications into subscription +ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 092 +-- fail - publications already exist +ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 093 +-- fail - publication used more than once +ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub1 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 094 +-- fail - all publications are deleted +ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub, testpub1, testpub2 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 095 +-- fail - publication does not exist in subscription +ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub3 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 096 +-- ok - delete publications +ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +== 097 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 098 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION mypub + WITH (connect = false, create_slot = false, copy_data = false) +-- +STMT: CreateSubscriptionStmt +== 099 +ALTER SUBSCRIPTION regress_testsub ENABLE +-- +STMT: AlterSubscriptionStmt +== 100 +-- fail - ALTER SUBSCRIPTION with refresh is not allowed in a transaction +-- block or function +BEGIN +-- +STMT: TransactionStmt +== 101 +ALTER SUBSCRIPTION regress_testsub SET PUBLICATION mypub WITH (refresh = true) +-- +STMT: AlterSubscriptionStmt +== 102 +END +-- +STMT: TransactionStmt +== 103 +BEGIN +-- +STMT: TransactionStmt +== 104 +ALTER SUBSCRIPTION regress_testsub REFRESH PUBLICATION +-- +STMT: AlterSubscriptionStmt +== 105 +END +-- +STMT: TransactionStmt +== 106 +CREATE FUNCTION func() RETURNS VOID AS +$$ ALTER SUBSCRIPTION regress_testsub SET PUBLICATION mypub WITH (refresh = true) $$ LANGUAGE SQL +-- +FUNCTION: name="func" function="func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 107 +SELECT func() +-- +FUNCTION: name="func" function="func" schema="" ctx=Call +STMT: SelectStmt +== 108 +ALTER SUBSCRIPTION regress_testsub DISABLE +-- +STMT: AlterSubscriptionStmt +== 109 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +== 110 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 111 +DROP FUNCTION func +-- +FUNCTION: name="func" function="func" schema="" ctx=DDL +STMT: DropStmt +== 112 +-- fail - two_phase must be boolean +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, two_phase = foo) +-- +STMT: CreateSubscriptionStmt +== 113 +-- now it works +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, two_phase = true) +-- +STMT: CreateSubscriptionStmt +== 114 +--fail - alter of two_phase option not supported. +ALTER SUBSCRIPTION regress_testsub SET (two_phase = false) +-- +STMT: AlterSubscriptionStmt +== 115 +-- but can alter streaming when two_phase enabled +ALTER SUBSCRIPTION regress_testsub SET (streaming = true) +-- +STMT: AlterSubscriptionStmt +== 116 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +== 117 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 118 +-- two_phase and streaming are compatible. +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, streaming = true, two_phase = true) +-- +STMT: CreateSubscriptionStmt +== 119 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +== 120 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 121 +-- fail - disable_on_error must be boolean +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, disable_on_error = foo) +-- +STMT: CreateSubscriptionStmt +== 122 +-- now it works +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, disable_on_error = false) +-- +STMT: CreateSubscriptionStmt +== 123 +ALTER SUBSCRIPTION regress_testsub SET (disable_on_error = true) +-- +STMT: AlterSubscriptionStmt +== 124 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +== 125 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 126 +-- let's do some tests with pg_create_subscription rather than superuser +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +== 127 +-- fail, not enough privileges +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +== 128 +-- fail, must specify password +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 129 +GRANT CREATE ON DATABASE REGRESSION TO regress_subscription_user3 +-- +STMT: GrantStmt +== 130 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +== 131 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +== 132 +-- fail, can't set password_required=false +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 133 +GRANT CREATE ON DATABASE REGRESSION TO regress_subscription_user3 +-- +STMT: GrantStmt +== 134 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +== 135 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, password_required = false) +-- +STMT: CreateSubscriptionStmt +== 136 +-- ok +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 137 +GRANT CREATE ON DATABASE REGRESSION TO regress_subscription_user3 +-- +STMT: GrantStmt +== 138 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +== 139 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist password=regress_fakepassword' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +== 140 +-- we cannot give the subscription away to some random user +ALTER SUBSCRIPTION regress_testsub OWNER TO regress_subscription_user +-- +STMT: AlterOwnerStmt +== 141 +-- but we can rename the subscription we just created +ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub2 +-- +STMT: RenameStmt +== 142 +-- ok, even after losing pg_create_subscription we can still rename it +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 143 +REVOKE pg_create_subscription FROM regress_subscription_user3 +-- +STMT: GrantRoleStmt +== 144 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +== 145 +ALTER SUBSCRIPTION regress_testsub2 RENAME TO regress_testsub +-- +STMT: RenameStmt +== 146 +-- fail, after losing CREATE on the database we can't rename it any more +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 147 +REVOKE CREATE ON DATABASE REGRESSION FROM regress_subscription_user3 +-- +STMT: GrantStmt +== 148 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +== 149 +ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub2 +-- +STMT: RenameStmt +== 150 +-- fail - cannot do ALTER SUBSCRIPTION SET (failover) inside transaction block +BEGIN +-- +STMT: TransactionStmt +== 151 +ALTER SUBSCRIPTION regress_testsub SET (failover) +-- +STMT: AlterSubscriptionStmt +== 152 +COMMIT +-- +STMT: TransactionStmt +== 153 +-- ok, owning it is enough for this stuff +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +== 154 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +== 155 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 156 +DROP ROLE regress_subscription_user +-- +STMT: DropRoleStmt +== 157 +DROP ROLE regress_subscription_user2 +-- +STMT: DropRoleStmt +== 158 +DROP ROLE regress_subscription_user3 +-- +STMT: DropRoleStmt +== 159 +DROP ROLE regress_subscription_user_dummy +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/subselect.metadata.json b/parser/testdata/summary/postgres_regress/subselect.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/subselect.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/subselect.test b/parser/testdata/summary/postgres_regress/subselect.test new file mode 100644 index 0000000..2ad91e8 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/subselect.test @@ -0,0 +1,2560 @@ +== 001 +|-- +-- SUBSELECT +|-- + +SELECT 1 AS one WHERE 1 IN (SELECT 1) +-- +STMT: SelectStmt +== 002 +SELECT 1 AS zero WHERE 1 NOT IN (SELECT 1) +-- +STMT: SelectStmt +== 003 +SELECT 1 AS zero WHERE 1 IN (SELECT 2) +-- +STMT: SelectStmt +== 004 +-- Check grammar's handling of extra parens in assorted contexts + +SELECT * FROM (SELECT 1 AS x) ss +-- +STMT: SelectStmt +== 005 +SELECT * FROM ((SELECT 1 AS x)) ss +-- +STMT: SelectStmt +== 006 +SELECT * FROM ((SELECT 1 AS x)), ((SELECT * FROM ((SELECT 2 AS y)))) +-- +STMT: SelectStmt +== 007 +(SELECT 2) UNION SELECT 2 +-- +STMT: SelectStmt +== 008 +((SELECT 2)) UNION SELECT 2 +-- +STMT: SelectStmt +== 009 +SELECT ((SELECT 2) UNION SELECT 2) +-- +STMT: SelectStmt +== 010 +SELECT (((SELECT 2)) UNION SELECT 2) +-- +STMT: SelectStmt +== 011 +SELECT (SELECT ARRAY[1,2,3])[1] +-- +STMT: SelectStmt +== 012 +SELECT ((SELECT ARRAY[1,2,3]))[2] +-- +STMT: SelectStmt +== 013 +SELECT (((SELECT ARRAY[1,2,3])))[3] +-- +STMT: SelectStmt +== 014 +-- Set up some simple test tables + +CREATE TABLE SUBSELECT_TBL ( + f1 integer, + f2 integer, + f3 float +) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DDL +STMT: CreateStmt +== 015 +INSERT INTO SUBSELECT_TBL VALUES (1, 2, 3) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +INSERT INTO SUBSELECT_TBL VALUES (2, 3, 4) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +INSERT INTO SUBSELECT_TBL VALUES (3, 4, 5) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +INSERT INTO SUBSELECT_TBL VALUES (1, 1, 1) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +INSERT INTO SUBSELECT_TBL VALUES (2, 2, 2) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO SUBSELECT_TBL VALUES (3, 3, 3) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO SUBSELECT_TBL VALUES (6, 7, 8) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO SUBSELECT_TBL VALUES (8, 9, NULL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +SELECT * FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: SelectStmt +== 024 +-- Uncorrelated subselects + +SELECT f1 AS "Constant Select" FROM SUBSELECT_TBL + WHERE f1 IN (SELECT 1) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 025 +SELECT f1 AS "Uncorrelated Field" FROM SUBSELECT_TBL + WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 026 +SELECT f1 AS "Uncorrelated Field" FROM SUBSELECT_TBL + WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE + f2 IN (SELECT f1 FROM SUBSELECT_TBL)) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 027 +SELECT f1, f2 + FROM SUBSELECT_TBL + WHERE (f1, f2) NOT IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL + WHERE f3 IS NOT NULL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="" column="f3" +STMT: SelectStmt +== 028 +-- Correlated subselects + +SELECT f1 AS "Correlated Field", f2 AS "Second Field" + FROM SUBSELECT_TBL upper + WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE f1 = upper.f1) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "upper"="subselect_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="upper" column="f1" +STMT: SelectStmt +== 029 +SELECT f1 AS "Correlated Field", f3 AS "Second Field" + FROM SUBSELECT_TBL upper + WHERE f1 IN + (SELECT f2 FROM SUBSELECT_TBL WHERE CAST(upper.f2 AS float) = f3) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "upper"="subselect_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="upper" column="f2" +FILTER: schema="" table="" column="f3" +STMT: SelectStmt +== 030 +SELECT f1 AS "Correlated Field", f3 AS "Second Field" + FROM SUBSELECT_TBL upper + WHERE f3 IN (SELECT upper.f1 + f2 FROM SUBSELECT_TBL + WHERE f2 = CAST(f3 AS integer)) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "upper"="subselect_tbl" +FILTER: schema="" table="" column="f3" +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="" column="f3" +STMT: SelectStmt +== 031 +SELECT f1 AS "Correlated Field" + FROM SUBSELECT_TBL + WHERE (f1, f2) IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL + WHERE f3 IS NOT NULL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="" column="f3" +STMT: SelectStmt +== 032 +-- Check ROWCOMPARE cases, both correlated and not + +EXPLAIN (VERBOSE, COSTS OFF) +SELECT ROW(1, 2) = (SELECT f1, f2) AS eq FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 033 +SELECT ROW(1, 2) = (SELECT f1, f2) AS eq FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: SelectStmt +== 034 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT ROW(1, 2) = (SELECT 3, 4) AS eq FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 035 +SELECT ROW(1, 2) = (SELECT 3, 4) AS eq FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: SelectStmt +== 036 +SELECT ROW(1, 2) = (SELECT f1, f2 FROM SUBSELECT_TBL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: SelectStmt +== 037 +-- error + +-- Subselects without aliases + +SELECT count FROM (SELECT COUNT(DISTINCT name) FROM road) +-- +TABLE: name="road" schema="" table="road" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT COUNT(*) FROM (SELECT DISTINCT name FROM road) +-- +TABLE: name="road" schema="" table="road" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 039 +SELECT * FROM (SELECT * FROM int4_tbl), (VALUES (123456)) WHERE f1 = column1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="column1" +STMT: SelectStmt +== 040 +CREATE VIEW view_unnamed_ss AS +SELECT * FROM (SELECT * FROM (SELECT abs(f1) AS a1 FROM int4_tbl)), + (SELECT * FROM int8_tbl) + WHERE a1 < 10 AND q1 > a1 ORDER BY q1, q2 +-- +TABLE: name="view_unnamed_ss" schema="" table="view_unnamed_ss" ctx=DDL +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a1" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="a1" +STMT: ViewStmt +STMT: SelectStmt +== 041 +SELECT * FROM view_unnamed_ss +-- +TABLE: name="view_unnamed_ss" schema="" table="view_unnamed_ss" ctx=Select +STMT: SelectStmt +== 042 +DROP VIEW view_unnamed_ss +-- +STMT: DropStmt +== 043 +-- Test matching of locking clause to correct alias + +CREATE VIEW view_unnamed_ss_locking AS +SELECT * FROM (SELECT * FROM int4_tbl), int8_tbl AS unnamed_subquery + WHERE f1 = q1 + FOR UPDATE OF unnamed_subquery +-- +TABLE: name="view_unnamed_ss_locking" schema="" table="view_unnamed_ss_locking" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "unnamed_subquery"="int8_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="q1" +STMT: ViewStmt +STMT: SelectStmt +== 044 +DROP VIEW view_unnamed_ss_locking +-- +STMT: DropStmt +== 045 +|-- +-- Use some existing tables in the regression test +|-- + +SELECT ss.f1 AS "Correlated Field", ss.f3 AS "Second Field" + FROM SUBSELECT_TBL ss + WHERE f1 NOT IN (SELECT f1+1 FROM INT4_TBL + WHERE f1 != ss.f1 AND f1 < 2147483647) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "ss"="subselect_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="ss" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 046 +select q1, float8(count(*)) / (select count(*) from int8_tbl) +from int8_tbl group by q1 order by q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="float8" function="float8" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- Unspecified-type literals in output columns should resolve as text + +SELECT *, pg_typeof(f1) FROM + (SELECT 'foo' AS f1 FROM generate_series(1,3)) ss ORDER BY 1 +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 048 +-- ... unless there's context to suggest differently + +explain (verbose, costs off) select '42' union all select '43' +-- +STMT: ExplainStmt +STMT: SelectStmt +== 049 +explain (verbose, costs off) select '42' union all select 43 +-- +STMT: ExplainStmt +STMT: SelectStmt +== 050 +-- check materialization of an initplan reference (bug #14524) +explain (verbose, costs off) +select 1 = all (select (select 1)) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 051 +select 1 = all (select (select 1)) +-- +STMT: SelectStmt +== 052 +|-- +-- Check EXISTS simplification with LIMIT +|-- +explain (costs off) +select * from int4_tbl o where exists + (select 1 from int4_tbl i where i.f1=o.f1 limit null) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="o" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 053 +explain (costs off) +select * from int4_tbl o where not exists + (select 1 from int4_tbl i where i.f1=o.f1 limit 1) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="o" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 054 +explain (costs off) +select * from int4_tbl o where exists + (select 1 from int4_tbl i where i.f1=o.f1 limit 0) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="o" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 055 +|-- +-- Test cases to catch unpleasant interactions between IN-join processing +-- and subquery pullup. +|-- + +select count(*) from + (select 1 from tenk1 a + where unique1 IN (select hundred from tenk1 b)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 056 +select count(distinct ss.ten) from + (select ten from tenk1 a + where unique1 IN (select hundred from tenk1 b)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 057 +select count(*) from + (select 1 from tenk1 a + where unique1 IN (select distinct hundred from tenk1 b)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 058 +select count(distinct ss.ten) from + (select ten from tenk1 a + where unique1 IN (select distinct hundred from tenk1 b)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 059 +|-- +-- Test cases to check for overenthusiastic optimization of +-- "IN (SELECT DISTINCT ...)" and related cases. Per example from +-- Luca Pireddu and Michael Fuhr. +|-- + +CREATE TEMP TABLE foo (id integer) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +== 060 +CREATE TEMP TABLE bar (id1 integer, id2 integer) +-- +TABLE: name="bar" schema="" table="bar" ctx=DDL +STMT: CreateStmt +== 061 +INSERT INTO foo VALUES (1) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +INSERT INTO bar VALUES (1, 1) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +INSERT INTO bar VALUES (2, 2) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +INSERT INTO bar VALUES (3, 1) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +-- These cases require an extra level of distinct-ing above subquery s +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT DISTINCT id1, id2 FROM bar) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 066 +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT id1,id2 FROM bar GROUP BY id1,id2) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 067 +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT id1, id2 FROM bar UNION + SELECT id1, id2 FROM bar) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 068 +-- These cases do not +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT DISTINCT ON (id2) id1, id2 FROM bar) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 069 +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT id2 FROM bar GROUP BY id2) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 070 +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT id2 FROM bar UNION + SELECT id2 FROM bar) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 071 +|-- +-- Test case to catch problems with multiply nested sub-SELECTs not getting +-- recalculated properly. Per bug report from Didier Moens. +|-- + +CREATE TABLE orderstest ( + approver_ref integer, + po_ref integer, + ordercanceled boolean +) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DDL +STMT: CreateStmt +== 072 +INSERT INTO orderstest VALUES (1, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +INSERT INTO orderstest VALUES (66, 5, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 074 +INSERT INTO orderstest VALUES (66, 6, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +INSERT INTO orderstest VALUES (66, 7, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 076 +INSERT INTO orderstest VALUES (66, 1, true) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +INSERT INTO orderstest VALUES (66, 8, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +INSERT INTO orderstest VALUES (66, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 079 +INSERT INTO orderstest VALUES (77, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +INSERT INTO orderstest VALUES (1, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +INSERT INTO orderstest VALUES (66, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 082 +INSERT INTO orderstest VALUES (1, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 083 +CREATE VIEW orders_view AS +SELECT *, +(SELECT CASE + WHEN ord.approver_ref=1 THEN '---' ELSE 'Approved' + END) AS "Approved", +(SELECT CASE + WHEN ord.ordercanceled + THEN 'Canceled' + ELSE + (SELECT CASE + WHEN ord.po_ref=1 + THEN + (SELECT CASE + WHEN ord.approver_ref=1 + THEN '---' + ELSE 'Approved' + END) + ELSE 'PO' + END) +END) AS "Status", +(CASE + WHEN ord.ordercanceled + THEN 'Canceled' + ELSE + (CASE + WHEN ord.po_ref=1 + THEN + (CASE + WHEN ord.approver_ref=1 + THEN '---' + ELSE 'Approved' + END) + ELSE 'PO' + END) +END) AS "Status_OK" +FROM orderstest ord +-- +TABLE: name="orders_view" schema="" table="orders_view" ctx=DDL +TABLE: name="orderstest" schema="" table="orderstest" ctx=Select +ALIAS: "ord"="orderstest" +STMT: ViewStmt +STMT: SelectStmt +== 084 +SELECT * FROM orders_view +-- +TABLE: name="orders_view" schema="" table="orders_view" ctx=Select +STMT: SelectStmt +== 085 +DROP TABLE orderstest cascade +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DDL +STMT: DropStmt +== 086 +|-- +-- Test cases to catch situations where rule rewriter fails to propagate +-- hasSubLinks flag correctly. Per example from Kyle Bateman. +|-- + +create temp table parts ( + partnum text, + cost float8 +) +-- +TABLE: name="parts" schema="" table="parts" ctx=DDL +STMT: CreateStmt +== 087 +create temp table shipped ( + ttype char(2), + ordnum int4, + partnum text, + value float8 +) +-- +TABLE: name="shipped" schema="" table="shipped" ctx=DDL +STMT: CreateStmt +== 088 +create temp view shipped_view as + select * from shipped where ttype = 'wt' +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DDL +TABLE: name="shipped" schema="" table="shipped" ctx=Select +FILTER: schema="" table="" column="ttype" +STMT: ViewStmt +STMT: SelectStmt +== 089 +create rule shipped_view_insert as on insert to shipped_view do instead + insert into shipped values('wt', new.ordnum, new.partnum, new.value) +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DDL +STMT: RuleStmt +== 090 +insert into parts (partnum, cost) values (1, 1234.56) +-- +TABLE: name="parts" schema="" table="parts" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 091 +insert into shipped_view (ordnum, partnum, value) + values (0, 1, (select cost from parts where partnum = '1')) +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DML +TABLE: name="parts" schema="" table="parts" ctx=Select +FILTER: schema="" table="" column="partnum" +STMT: InsertStmt +STMT: SelectStmt +== 092 +select * from shipped_view +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=Select +STMT: SelectStmt +== 093 +create rule shipped_view_update as on update to shipped_view do instead + update shipped set partnum = new.partnum, value = new.value + where ttype = new.ttype and ordnum = new.ordnum +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DDL +STMT: RuleStmt +== 094 +update shipped_view set value = 11 + from int4_tbl a join int4_tbl b + on (a.f1 = (select f1 from int4_tbl c where c.f1=b.f1)) + where ordnum = a.f1 +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +ALIAS: "c"="int4_tbl" +FILTER: schema="" table="c" column="f1" +FILTER: schema="" table="b" column="f1" +STMT: UpdateStmt +STMT: SelectStmt +== 095 +select * from shipped_view +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=Select +STMT: SelectStmt +== 096 +select f1, ss1 as relabel from + (select *, (select sum(f1) from int4_tbl b where f1 >= a.f1) as ss1 + from int4_tbl a) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="a" column="f1" +STMT: SelectStmt +== 097 +|-- +-- Test cases involving PARAM_EXEC parameters and min/max index optimizations. +-- Per bug report from David Sanchez i Gregori. +|-- + +select * from ( + select max(unique1) from tenk1 as a + where exists (select 1 from tenk1 as b where b.thousand = a.unique2) +) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="b" column="thousand" +FILTER: schema="" table="a" column="unique2" +STMT: SelectStmt +== 098 +select * from ( + select min(unique1) from tenk1 as a + where not exists (select 1 from tenk1 as b where b.unique2 = 10000) +) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="b" column="unique2" +STMT: SelectStmt +== 099 +|-- +-- Test that an IN implemented using a UniquePath does unique-ification +-- with the right semantics, as per bug #4113. (Unfortunately we have +-- no simple way to ensure that this test case actually chooses that type +-- of plan, but it does in releases 7.4-8.3. Note that an ordering difference +-- here might mean that some other plan type is being used, rendering the test +-- pointless.) +|-- + +create temp table numeric_table (num_col numeric) +-- +TABLE: name="numeric_table" schema="" table="numeric_table" ctx=DDL +STMT: CreateStmt +== 100 +insert into numeric_table values (1), (1.000000000000000000001), (2), (3) +-- +TABLE: name="numeric_table" schema="" table="numeric_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +create temp table float_table (float_col float8) +-- +TABLE: name="float_table" schema="" table="float_table" ctx=DDL +STMT: CreateStmt +== 102 +insert into float_table values (1), (2), (3) +-- +TABLE: name="float_table" schema="" table="float_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +select * from float_table + where float_col in (select num_col from numeric_table) +-- +TABLE: name="float_table" schema="" table="float_table" ctx=Select +TABLE: name="numeric_table" schema="" table="numeric_table" ctx=Select +FILTER: schema="" table="" column="float_col" +STMT: SelectStmt +== 104 +select * from numeric_table + where num_col in (select float_col from float_table) +-- +TABLE: name="numeric_table" schema="" table="numeric_table" ctx=Select +TABLE: name="float_table" schema="" table="float_table" ctx=Select +FILTER: schema="" table="" column="num_col" +STMT: SelectStmt +== 105 +|-- +-- Test case for bug #4290: bogus calculation of subplan param sets +|-- + +create temp table ta (id int primary key, val int) +-- +TABLE: name="ta" schema="" table="ta" ctx=DDL +STMT: CreateStmt +== 106 +insert into ta values(1,1) +-- +TABLE: name="ta" schema="" table="ta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +insert into ta values(2,2) +-- +TABLE: name="ta" schema="" table="ta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +create temp table tb (id int primary key, aval int) +-- +TABLE: name="tb" schema="" table="tb" ctx=DDL +STMT: CreateStmt +== 109 +insert into tb values(1,1) +-- +TABLE: name="tb" schema="" table="tb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +insert into tb values(2,1) +-- +TABLE: name="tb" schema="" table="tb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +insert into tb values(3,2) +-- +TABLE: name="tb" schema="" table="tb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 112 +insert into tb values(4,2) +-- +TABLE: name="tb" schema="" table="tb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 113 +create temp table tc (id int primary key, aid int) +-- +TABLE: name="tc" schema="" table="tc" ctx=DDL +STMT: CreateStmt +== 114 +insert into tc values(1,1) +-- +TABLE: name="tc" schema="" table="tc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +insert into tc values(2,2) +-- +TABLE: name="tc" schema="" table="tc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +select + ( select min(tb.id) from tb + where tb.aval = (select ta.val from ta where ta.id = tc.aid) ) as min_tb_id +from tc +-- +TABLE: name="tc" schema="" table="tc" ctx=Select +TABLE: name="tb" schema="" table="tb" ctx=Select +TABLE: name="ta" schema="" table="ta" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="tb" column="aval" +FILTER: schema="" table="ta" column="id" +FILTER: schema="" table="tc" column="aid" +STMT: SelectStmt +== 117 +|-- +-- Test case for 8.3 "failed to locate grouping columns" bug +|-- + +create temp table t1 (f1 numeric(14,0), f2 varchar(30)) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 118 +select * from + (select distinct f1, f2, (select f2 from t1 x where x.f1 = up.f1) as fs + from t1 up) ss +group by f1,f2,fs +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +ALIAS: "up"="t1" +ALIAS: "x"="t1" +FILTER: schema="" table="x" column="f1" +FILTER: schema="" table="up" column="f1" +STMT: SelectStmt +== 119 +|-- +-- Test case for bug #5514 (mishandling of whole-row Vars in subselects) +|-- + +create temp table table_a(id integer) +-- +TABLE: name="table_a" schema="" table="table_a" ctx=DDL +STMT: CreateStmt +== 120 +insert into table_a values (42) +-- +TABLE: name="table_a" schema="" table="table_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +create temp view view_a as select * from table_a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=DDL +TABLE: name="table_a" schema="" table="table_a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 122 +select view_a from view_a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=Select +STMT: SelectStmt +== 123 +select (select view_a) from view_a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=Select +STMT: SelectStmt +== 124 +select (select (select view_a)) from view_a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=Select +STMT: SelectStmt +== 125 +select (select (a.*)::text) from view_a a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=Select +ALIAS: "a"="view_a" +STMT: SelectStmt +== 126 +|-- +-- Test case for bug #19037: no relation entry for relid N +|-- + +explain (costs off) +select (1 = any(array_agg(f1))) = any (select false) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 127 +select (1 = any(array_agg(f1))) = any (select false) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +== 128 +|-- +-- Check that whole-row Vars reading the result of a subselect don't include +-- any junk columns therein +|-- + +select q from (select max(f1) from int4_tbl group by f1 order by f1) q +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 129 +with q as (select max(f1) from int4_tbl group by f1 order by f1) + select q from q +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "q" +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 130 +|-- +-- Test case for sublinks pulled up into joinaliasvars lists in an +-- inherited update/delete query +|-- + +begin +-- +STMT: TransactionStmt +== 131 +-- this shouldn't delete anything, but be safe + +delete from road +where exists ( + select 1 + from + int4_tbl cross join + ( select f1, array(select q1 from int8_tbl) as arr + from text_tbl ) ss + where road.name = ss.f1 ) +-- +TABLE: name="road" schema="" table="road" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="road" column="name" +FILTER: schema="" table="ss" column="f1" +STMT: DeleteStmt +STMT: SelectStmt +== 132 +rollback +-- +STMT: TransactionStmt +== 133 +|-- +-- Test case for sublinks pushed down into subselects via join alias expansion +|-- + +select + (select sq1) as qq1 +from + (select exists(select 1 from int4_tbl where f1 = q2) as sq1, 42 as dummy + from int8_tbl) sq0 + join + int4_tbl i4 on dummy = i4.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 134 +|-- +-- Test case for subselect within UPDATE of INSERT...ON CONFLICT DO UPDATE +|-- +create temp table upsert(key int4 primary key, val text) +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: CreateStmt +== 135 +insert into upsert values(1, 'val') on conflict (key) do update set val = 'not seen' +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 136 +insert into upsert values(1, 'val') on conflict (key) do update set val = 'seen with subselect ' || (select f1 from int4_tbl where f1 != 0 limit 1)::text +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: InsertStmt +STMT: SelectStmt +== 137 +select * from upsert +-- +TABLE: name="upsert" schema="" table="upsert" ctx=Select +STMT: SelectStmt +== 138 +with aa as (select 'int4_tbl' u from int4_tbl limit 1) +insert into upsert values (1, 'x'), (999, 'y') +on conflict (key) do update set val = (select u from aa) +returning * +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "aa" +STMT: InsertStmt +STMT: SelectStmt +== 139 +|-- +-- Test case for cross-type partial matching in hashed subplan (bug #7597) +|-- + +create temp table outer_7597 (f1 int4, f2 int4) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DDL +STMT: CreateStmt +== 140 +insert into outer_7597 values (0, 0) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 141 +insert into outer_7597 values (1, 0) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +insert into outer_7597 values (0, null) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +insert into outer_7597 values (1, null) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 144 +create temp table inner_7597(c1 int8, c2 int8) +-- +TABLE: name="inner_7597" schema="" table="inner_7597" ctx=DDL +STMT: CreateStmt +== 145 +insert into inner_7597 values(0, null) +-- +TABLE: name="inner_7597" schema="" table="inner_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +select * from outer_7597 where (f1, f2) not in (select * from inner_7597) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=Select +TABLE: name="inner_7597" schema="" table="inner_7597" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 147 +|-- +-- Similar test case using text that verifies that collation +-- information is passed through by execTuplesEqual() in nodeSubplan.c +-- (otherwise it would error in texteq()) +|-- + +create temp table outer_text (f1 text, f2 text) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DDL +STMT: CreateStmt +== 148 +insert into outer_text values ('a', 'a') +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 149 +insert into outer_text values ('b', 'a') +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +insert into outer_text values ('a', null) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 151 +insert into outer_text values ('b', null) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +create temp table inner_text (c1 text, c2 text) +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DDL +STMT: CreateStmt +== 153 +insert into inner_text values ('a', null) +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 154 +insert into inner_text values ('123', '456') +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +select * from outer_text where (f1, f2) not in (select * from inner_text) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 156 +|-- +-- Another test case for cross-type hashed subplans: comparison of +-- inner-side values must be done with appropriate operator +|-- + +explain (verbose, costs off) +select 'foo'::text in (select 'bar'::name union all select 'bar'::name) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 157 +select 'foo'::text in (select 'bar'::name union all select 'bar'::name) +-- +STMT: SelectStmt +== 158 +|-- +-- Test that we don't try to hash nested records (bug #17363) +-- (Hashing could be supported, but for now we don't) +|-- + +explain (verbose, costs off) +select row(row(row(1))) = any (select row(row(1))) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 159 +select row(row(row(1))) = any (select row(row(1))) +-- +STMT: SelectStmt +== 160 +|-- +-- Test case for premature memory release during hashing of subplan output +|-- + +select '1'::text in (select '1'::name union all select '1'::name) +-- +STMT: SelectStmt +== 161 +|-- +-- Test that we don't try to use a hashed subplan if the simplified +-- testexpr isn't of the right shape +|-- + +-- this fails by default, of course +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 162 +begin +-- +STMT: TransactionStmt +== 163 +-- make an operator to allow it to succeed +create function bogus_int8_text_eq(int8, text) returns boolean +language sql as 'select $1::text = $2' +-- +FUNCTION: name="bogus_int8_text_eq" function="bogus_int8_text_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 164 +create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text) +-- +STMT: DefineStmt +== 165 +explain (costs off) +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 166 +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 167 +-- inlining of this function results in unusual number of hash clauses, +-- which we can still cope with +create or replace function bogus_int8_text_eq(int8, text) returns boolean +language sql as 'select $1::text = $2 and $1::text = $2' +-- +FUNCTION: name="bogus_int8_text_eq" function="bogus_int8_text_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 168 +explain (costs off) +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 169 +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 170 +-- inlining of this function causes LHS and RHS to be switched, +-- which we can't cope with, so hashing should be abandoned +create or replace function bogus_int8_text_eq(int8, text) returns boolean +language sql as 'select $2 = $1::text' +-- +FUNCTION: name="bogus_int8_text_eq" function="bogus_int8_text_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 171 +explain (costs off) +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 172 +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +== 173 +rollback +-- +STMT: TransactionStmt +== 174 +-- to get rid of the bogus operator + +|-- +-- Test resolution of hashed vs non-hashed implementation of EXISTS subplan +|-- +explain (costs off) +select count(*) from tenk1 t +where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "k"="tenk1" +ALIAS: "t"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="k" column="unique1" +FILTER: schema="" table="t" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 175 +select count(*) from tenk1 t +where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "k"="tenk1" +ALIAS: "t"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="k" column="unique1" +FILTER: schema="" table="t" column="unique2" +STMT: SelectStmt +== 176 +explain (costs off) +select count(*) from tenk1 t +where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0) + and thousand = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "k"="tenk1" +ALIAS: "t"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="k" column="unique1" +FILTER: schema="" table="t" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 177 +select count(*) from tenk1 t +where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0) + and thousand = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "k"="tenk1" +ALIAS: "t"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="k" column="unique1" +FILTER: schema="" table="t" column="unique2" +STMT: SelectStmt +== 178 +-- It's possible for the same EXISTS to get resolved both ways +create temp table exists_tbl (c1 int, c2 int, c3 int) partition by list (c1) +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=DDL +STMT: CreateStmt +== 179 +create temp table exists_tbl_null partition of exists_tbl for values in (null) +-- +TABLE: name="exists_tbl_null" schema="" table="exists_tbl_null" ctx=DDL +STMT: CreateStmt +== 180 +create temp table exists_tbl_def partition of exists_tbl default +-- +TABLE: name="exists_tbl_def" schema="" table="exists_tbl_def" ctx=DDL +STMT: CreateStmt +== 181 +insert into exists_tbl select x, x/2, x+1 from generate_series(0,10) x +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 182 +analyze exists_tbl +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=DDL +STMT: VacuumStmt +== 183 +explain (costs off) +select * from exists_tbl t1 + where (exists(select 1 from exists_tbl t2 where t1.c1 = t2.c2) or c3 < 0) +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=Select +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=Select +ALIAS: "t1"="exists_tbl" +ALIAS: "t2"="exists_tbl" +FILTER: schema="" table="t1" column="c1" +FILTER: schema="" table="t2" column="c2" +STMT: ExplainStmt +STMT: SelectStmt +== 184 +select * from exists_tbl t1 + where (exists(select 1 from exists_tbl t2 where t1.c1 = t2.c2) or c3 < 0) +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=Select +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=Select +ALIAS: "t1"="exists_tbl" +ALIAS: "t2"="exists_tbl" +FILTER: schema="" table="t1" column="c1" +FILTER: schema="" table="t2" column="c2" +STMT: SelectStmt +== 185 +|-- +-- Test case for planner bug with nested EXISTS handling +|-- +select a.thousand from tenk1 a, tenk1 b +where a.thousand = b.thousand + and exists ( select 1 from tenk1 c where b.hundred = c.hundred + and not exists ( select 1 from tenk1 d + where a.thousand = d.thousand ) ) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +ALIAS: "d"="tenk1" +FILTER: schema="" table="a" column="thousand" +FILTER: schema="" table="b" column="thousand" +FILTER: schema="" table="b" column="hundred" +FILTER: schema="" table="c" column="hundred" +FILTER: schema="" table="a" column="thousand" +FILTER: schema="" table="d" column="thousand" +STMT: SelectStmt +== 186 +|-- +-- Check that nested sub-selects are not pulled up if they contain volatiles +|-- +explain (verbose, costs off) + select x, x from + (select (select now()) as x from (values(1),(2)) v(y)) ss +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 187 +explain (verbose, costs off) + select x, x from + (select (select random()) as x from (values(1),(2)) v(y)) ss +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 188 +explain (verbose, costs off) + select x, x from + (select (select now() where y=y) as x from (values(1),(2)) v(y)) ss +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 189 +explain (verbose, costs off) + select x, x from + (select (select random() where y=y) as x from (values(1),(2)) v(y)) ss +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +== 190 +|-- +-- Test rescan of a hashed subplan (the use of random() is to prevent the +-- sub-select from being pulled up, which would result in not hashing) +|-- +explain (verbose, costs off) +select sum(ss.tst::int) from + onek o cross join lateral ( + select i.ten in (select f1 from int4_tbl where f1 <= o.hundred) as tst, + random() as r + from onek i where i.unique1 = o.unique1 ) ss +where o.ten = 0 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="onek" +ALIAS: "o"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="i" column="unique1" +FILTER: schema="" table="o" column="unique1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="o" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +== 191 +select sum(ss.tst::int) from + onek o cross join lateral ( + select i.ten in (select f1 from int4_tbl where f1 <= o.hundred) as tst, + random() as r + from onek i where i.unique1 = o.unique1 ) ss +where o.ten = 0 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="onek" +ALIAS: "o"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="i" column="unique1" +FILTER: schema="" table="o" column="unique1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="o" column="hundred" +STMT: SelectStmt +== 192 +|-- +-- Test rescan of a SetOp node +|-- +explain (costs off) +select count(*) from + onek o cross join lateral ( + select * from onek i1 where i1.unique1 = o.unique1 + except + select * from onek i2 where i2.unique1 = o.unique2 + ) ss +where o.ten = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "i1"="onek" +ALIAS: "i2"="onek" +ALIAS: "o"="onek" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="i1" column="unique1" +FILTER: schema="" table="o" column="unique1" +FILTER: schema="" table="i2" column="unique1" +FILTER: schema="" table="o" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 193 +select count(*) from + onek o cross join lateral ( + select * from onek i1 where i1.unique1 = o.unique1 + except + select * from onek i2 where i2.unique1 = o.unique2 + ) ss +where o.ten = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "i1"="onek" +ALIAS: "i2"="onek" +ALIAS: "o"="onek" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="i1" column="unique1" +FILTER: schema="" table="o" column="unique1" +FILTER: schema="" table="i2" column="unique1" +FILTER: schema="" table="o" column="unique2" +STMT: SelectStmt +== 194 +|-- +-- Test rescan of a RecursiveUnion node +|-- +explain (costs off) +select sum(o.four), sum(ss.a) from + onek o cross join lateral ( + with recursive x(a) as + (select o.four as a + union + select a + 1 from x + where a < 10) + select * from x + ) ss +where o.ten = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "o"="onek" +CTE: "x" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 195 +select sum(o.four), sum(ss.a) from + onek o cross join lateral ( + with recursive x(a) as + (select o.four as a + union + select a + 1 from x + where a < 10) + select * from x + ) ss +where o.ten = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "o"="onek" +CTE: "x" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 196 +|-- +-- Check we don't misoptimize a NOT IN where the subquery returns no rows. +|-- +create temp table notinouter (a int) +-- +TABLE: name="notinouter" schema="" table="notinouter" ctx=DDL +STMT: CreateStmt +== 197 +create temp table notininner (b int not null) +-- +TABLE: name="notininner" schema="" table="notininner" ctx=DDL +STMT: CreateStmt +== 198 +insert into notinouter values (null), (1) +-- +TABLE: name="notinouter" schema="" table="notinouter" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 199 +select * from notinouter where a not in (select b from notininner) +-- +TABLE: name="notinouter" schema="" table="notinouter" ctx=Select +TABLE: name="notininner" schema="" table="notininner" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 200 +|-- +-- Check we behave sanely in corner case of empty SELECT list (bug #8648) +|-- +create temp table nocolumns() +-- +TABLE: name="nocolumns" schema="" table="nocolumns" ctx=DDL +STMT: CreateStmt +== 201 +select exists(select * from nocolumns) +-- +TABLE: name="nocolumns" schema="" table="nocolumns" ctx=Select +STMT: SelectStmt +== 202 +|-- +-- Check behavior with a SubPlan in VALUES (bug #14924) +|-- +select val.x + from generate_series(1,10) as s(i), + lateral ( + values ((select s.i + 1)), (s.i + 101) + ) as val(x) +where s.i < 10 and (select val.x) < 110 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="s" column="i" +STMT: SelectStmt +== 203 +-- another variant of that (bug #16213) +explain (verbose, costs off) +select * from +(values + (3 not in (select * from (values (1), (2)) ss1)), + (false) +) ss +-- +STMT: ExplainStmt +STMT: SelectStmt +== 204 +select * from +(values + (3 not in (select * from (values (1), (2)) ss1)), + (false) +) ss +-- +STMT: SelectStmt +== 205 +|-- +-- Check sane behavior with nested IN SubLinks +|-- +explain (verbose, costs off) +select * from int4_tbl where + (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in + (select ten from tenk1 b) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 206 +select * from int4_tbl where + (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in + (select ten from tenk1 b) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 207 +|-- +-- Check for incorrect optimization when IN subquery contains a SRF +|-- +explain (verbose, costs off) +select * from int4_tbl o where (f1, f1) in + (select f1, generate_series(1,50) / 10 g from int4_tbl i group by f1) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 208 +select * from int4_tbl o where (f1, f1) in + (select f1, generate_series(1,50) / 10 g from int4_tbl i group by f1) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 209 +|-- +-- check for over-optimization of whole-row Var referencing an Append plan +|-- +select (select q from + (select 1,2,3 where f1 > 0 + union all + select 4,5,6.0 where f1 <= 0 + ) q ) +from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 210 +|-- +-- Check for sane handling of a lateral reference in a subquery's quals +-- (most of the complication here is to prevent the test case from being +-- flattened too much) +|-- +explain (verbose, costs off) +select * from + int4_tbl i4, + lateral ( + select i4.f1 > 1 as b, 1 as id + from (select random() order by 1) as t1 + union all + select true as b, 2 as id + ) as t2 +where b and f1 >= 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 211 +select * from + int4_tbl i4, + lateral ( + select i4.f1 > 1 as b, 1 as id + from (select random() order by 1) as t1 + union all + select true as b, 2 as id + ) as t2 +where b and f1 >= 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 212 +|-- +-- Check that volatile quals aren't pushed down past a DISTINCT: +-- nextval() should not be called more than the nominal number of times +|-- +create temp sequence ts1 +-- +STMT: CreateSeqStmt +== 213 +select * from + (select distinct ten from tenk1) ss + where ten < 10 + nextval('ts1') + order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +FILTER: schema="" table="" column="ten" +STMT: SelectStmt +== 214 +select nextval('ts1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 215 +|-- +-- Check that volatile quals aren't pushed down past a set-returning function; +-- while a nonvolatile qual can be, if it doesn't reference the SRF. +|-- +create function tattle(x int, y int) returns bool +volatile language plpgsql as $$ +begin + raise notice 'x = %, y = %', x, y; + return x > y; +end$$ +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 216 +explain (verbose, costs off) +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, 8) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 217 +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, 8) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 218 +-- if we pretend it's stable, we get different results: +alter function tattle(x int, y int) stable +-- +STMT: AlterFunctionStmt +== 219 +explain (verbose, costs off) +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, 8) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 220 +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, 8) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 221 +-- although even a stable qual should not be pushed down if it references SRF +explain (verbose, costs off) +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, u) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="u" +STMT: ExplainStmt +STMT: SelectStmt +== 222 +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, u) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="u" +STMT: SelectStmt +== 223 +drop function tattle(x int, y int) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=DDL +STMT: DropStmt +== 224 +|-- +-- Test that LIMIT can be pushed to SORT through a subquery that just projects +-- columns. We check for that having happened by looking to see if EXPLAIN +-- ANALYZE shows that a top-N sort was used. We must suppress or filter away +-- all the non-invariant parts of the EXPLAIN ANALYZE output. +|-- +create table sq_limit (pk int primary key, c1 int, c2 int) +-- +TABLE: name="sq_limit" schema="" table="sq_limit" ctx=DDL +STMT: CreateStmt +== 225 +insert into sq_limit values + (1, 1, 1), + (2, 2, 2), + (3, 3, 3), + (4, 4, 4), + (5, 1, 1), + (6, 2, 2), + (7, 3, 3), + (8, 4, 4) +-- +TABLE: name="sq_limit" schema="" table="sq_limit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 226 +create function explain_sq_limit() returns setof text language plpgsql as +$$ +declare ln text; +begin + for ln in + explain (analyze, summary off, timing off, costs off) + select * from (select pk,c2 from sq_limit order by c1,pk) as x limit 3 + loop + ln := regexp_replace(ln, 'Memory: \S*', 'Memory: xxx'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_sq_limit" function="explain_sq_limit" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 227 +select * from explain_sq_limit() +-- +FUNCTION: name="explain_sq_limit" function="explain_sq_limit" schema="" ctx=Call +STMT: SelectStmt +== 228 +select * from (select pk,c2 from sq_limit order by c1,pk) as x limit 3 +-- +TABLE: name="sq_limit" schema="" table="sq_limit" ctx=Select +STMT: SelectStmt +== 229 +drop function explain_sq_limit() +-- +FUNCTION: name="explain_sq_limit" function="explain_sq_limit" schema="" ctx=DDL +STMT: DropStmt +== 230 +drop table sq_limit +-- +TABLE: name="sq_limit" schema="" table="sq_limit" ctx=DDL +STMT: DropStmt +== 231 +|-- +-- Ensure that backward scan direction isn't propagated into +-- expression subqueries (bug #15336) +|-- + +begin +-- +STMT: TransactionStmt +== 232 +declare c1 scroll cursor for + select * from generate_series(1,4) i + where i <> all (values (2),(3)) +-- +STMT: DeclareCursorStmt +== 233 +move forward all in c1 +-- +STMT: FetchStmt +== 234 +fetch backward all in c1 +-- +STMT: FetchStmt +== 235 +commit +-- +STMT: TransactionStmt +== 236 +|-- +-- Check that JsonConstructorExpr is treated as non-strict, and thus can be +-- wrapped in a PlaceHolderVar +|-- + +begin +-- +STMT: TransactionStmt +== 237 +create temp table json_tab (a int) +-- +TABLE: name="json_tab" schema="" table="json_tab" ctx=DDL +STMT: CreateStmt +== 238 +insert into json_tab values (1) +-- +TABLE: name="json_tab" schema="" table="json_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 239 +explain (verbose, costs off) +select * from json_tab t1 left join (select json_array(1, a) from json_tab t2) s on false +-- +TABLE: name="json_tab" schema="" table="json_tab" ctx=Select +TABLE: name="json_tab" schema="" table="json_tab" ctx=Select +ALIAS: "t1"="json_tab" +ALIAS: "t2"="json_tab" +STMT: ExplainStmt +STMT: SelectStmt +== 240 +select * from json_tab t1 left join (select json_array(1, a) from json_tab t2) s on false +-- +TABLE: name="json_tab" schema="" table="json_tab" ctx=Select +TABLE: name="json_tab" schema="" table="json_tab" ctx=Select +ALIAS: "t1"="json_tab" +ALIAS: "t2"="json_tab" +STMT: SelectStmt +== 241 +rollback +-- +STMT: TransactionStmt +== 242 +|-- +-- Verify that we correctly flatten cases involving a subquery output +-- expression that doesn't need to be wrapped in a PlaceHolderVar +|-- + +explain (costs off) +select tname, attname from ( +select relname::information_schema.sql_identifier as tname, * from + (select * from pg_class c) ss1) ss2 + right join pg_attribute a on a.attrelid = ss2.oid +where tname = 'tenk1' and attnum = 1 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="tname" +FILTER: schema="" table="" column="attnum" +STMT: ExplainStmt +STMT: SelectStmt +== 243 +select tname, attname from ( +select relname::information_schema.sql_identifier as tname, * from + (select * from pg_class c) ss1) ss2 + right join pg_attribute a on a.attrelid = ss2.oid +where tname = 'tenk1' and attnum = 1 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="tname" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +== 244 +-- Check behavior when there's a lateral reference in the output expression +explain (verbose, costs off) +select t1.ten, sum(x) from + tenk1 t1 left join lateral ( + select t1.ten + t2.ten as x, t2.fivethous from tenk1 t2 + ) ss on t1.unique1 = ss.fivethous +group by t1.ten +order by t1.ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 245 +select t1.ten, sum(x) from + tenk1 t1 left join lateral ( + select t1.ten + t2.ten as x, t2.fivethous from tenk1 t2 + ) ss on t1.unique1 = ss.fivethous +group by t1.ten +order by t1.ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 246 +explain (verbose, costs off) +select t1.q1, x from + int8_tbl t1 left join + (int8_tbl t2 left join + lateral (select t2.q1+t3.q1 as x, * from int8_tbl t3) t3 on t2.q2 = t3.q2) + on t1.q2 = t2.q2 +order by 1, 2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +== 247 +select t1.q1, x from + int8_tbl t1 left join + (int8_tbl t2 left join + lateral (select t2.q1+t3.q1 as x, * from int8_tbl t3) t3 on t2.q2 = t3.q2) + on t1.q2 = t2.q2 +order by 1, 2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +STMT: SelectStmt +== 248 +|-- +-- Tests for CTE inlining behavior +|-- + +-- Basic subquery that can be inlined +explain (verbose, costs off) +with x as (select * from (select f1 from subselect_tbl) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 249 +-- Explicitly request materialization +explain (verbose, costs off) +with x as materialized (select * from (select f1 from subselect_tbl) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 250 +-- Stable functions are safe to inline +explain (verbose, costs off) +with x as (select * from (select f1, now() from subselect_tbl) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 251 +-- Volatile functions prevent inlining +explain (verbose, costs off) +with x as (select * from (select f1, random() from subselect_tbl) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 252 +-- SELECT FOR UPDATE cannot be inlined +explain (verbose, costs off) +with x as (select * from (select f1 from subselect_tbl for update) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 253 +-- Multiply-referenced CTEs are inlined only when requested +explain (verbose, costs off) +with x as (select * from (select f1, now() as n from subselect_tbl) ss) +select * from x, x x2 where x.n = x2.n +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "x2"="x" +CTE: "x" +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="x" column="n" +FILTER: schema="" table="x2" column="n" +STMT: ExplainStmt +STMT: SelectStmt +== 254 +explain (verbose, costs off) +with x as not materialized (select * from (select f1, now() as n from subselect_tbl) ss) +select * from x, x x2 where x.n = x2.n +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "x2"="x" +CTE: "x" +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="x" column="n" +FILTER: schema="" table="x2" column="n" +STMT: ExplainStmt +STMT: SelectStmt +== 255 +-- Multiply-referenced CTEs can't be inlined if they contain outer self-refs +explain (verbose, costs off) +with recursive x(a) as + ((values ('a'), ('b')) + union all + (with z as not materialized (select * from x) + select z.a || z1.a as a from z cross join z as z1 + where length(z.a || z1.a) < 5)) +select * from x +-- +ALIAS: "z1"="z" +CTE: "x" +CTE: "z" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 256 +with recursive x(a) as + ((values ('a'), ('b')) + union all + (with z as not materialized (select * from x) + select z.a || z1.a as a from z cross join z as z1 + where length(z.a || z1.a) < 5)) +select * from x +-- +ALIAS: "z1"="z" +CTE: "x" +CTE: "z" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z1" column="a" +STMT: SelectStmt +== 257 +explain (verbose, costs off) +with recursive x(a) as + ((values ('a'), ('b')) + union all + (with z as not materialized (select * from x) + select z.a || z.a as a from z + where length(z.a || z.a) < 5)) +select * from x +-- +CTE: "x" +CTE: "z" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 258 +with recursive x(a) as + ((values ('a'), ('b')) + union all + (with z as not materialized (select * from x) + select z.a || z.a as a from z + where length(z.a || z.a) < 5)) +select * from x +-- +CTE: "x" +CTE: "z" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z" column="a" +STMT: SelectStmt +== 259 +-- Check handling of outer references +explain (verbose, costs off) +with x as (select * from int4_tbl) +select * from (with y as (select * from x) select * from y) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "y" +CTE: "x" +STMT: ExplainStmt +STMT: SelectStmt +== 260 +explain (verbose, costs off) +with x as materialized (select * from int4_tbl) +select * from (with y as (select * from x) select * from y) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "y" +CTE: "x" +STMT: ExplainStmt +STMT: SelectStmt +== 261 +-- Ensure that we inline the correct CTE when there are +-- multiple CTEs with the same name +explain (verbose, costs off) +with x as (select 1 as y) +select * from (with x as (select 2 as y) select * from x) ss +-- +CTE: "x" +CTE: "x" +STMT: ExplainStmt +STMT: SelectStmt +== 262 +-- Row marks are not pushed into CTEs +explain (verbose, costs off) +with x as (select * from subselect_tbl) +select * from x for update +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +STMT: ExplainStmt +STMT: SelectStmt +== 263 +-- Pull up direct-correlated ANY_SUBLINKs +explain (costs off) +select * from tenk1 A where hundred in (select hundred from tenk2 B where B.odd = A.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="b" column="odd" +FILTER: schema="" table="a" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +== 264 +explain (costs off) +select * from tenk1 A where exists +(select 1 from tenk2 B +where A.hundred in (select C.hundred FROM tenk2 C +WHERE c.odd = b.odd)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="a" column="hundred" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +== 265 +-- we should only try to pull up the sublink into RHS of a left join +-- but a.hundred is not available. +explain (costs off) +SELECT * FROM tenk1 A LEFT JOIN tenk2 B +ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +== 266 +-- we should only try to pull up the sublink into RHS of a left join +-- but a.odd is not available for this. +explain (costs off) +SELECT * FROM tenk1 A LEFT JOIN tenk2 B +ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = a.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="a" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +== 267 +-- should be able to pull up since all the references are available. +explain (costs off) +SELECT * FROM tenk1 A LEFT JOIN tenk2 B +ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +== 268 +-- we can pull up the sublink into the inner JoinExpr. +explain (costs off) +SELECT * FROM tenk1 A INNER JOIN tenk2 B +ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd) +WHERE a.thousand < 750 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="a" column="thousand" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +== 269 +-- we can pull up the aggregate sublink into RHS of a left join. +explain (costs off) +SELECT * FROM tenk1 A LEFT JOIN tenk2 B +ON B.hundred in (SELECT min(c.hundred) FROM tenk2 C WHERE c.odd = b.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/sysviews.metadata.json b/parser/testdata/summary/postgres_regress/sysviews.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sysviews.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/sysviews.test b/parser/testdata/summary/postgres_regress/sysviews.test new file mode 100644 index 0000000..6033153 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/sysviews.test @@ -0,0 +1,199 @@ +== 001 +|-- +-- Test assorted system views +|-- +-- This test is mainly meant to provide some code coverage for the +-- set-returning functions that underlie certain system views. +-- The output of most of these functions is very environment-dependent, +-- so our ability to test with fixed expected output is pretty limited; +-- but even a trivial check of count(*) will exercise the normal code path +-- through the SRF. + +select count(*) >= 0 as ok from pg_available_extension_versions +-- +TABLE: name="pg_available_extension_versions" schema="" table="pg_available_extension_versions" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 002 +select count(*) >= 0 as ok from pg_available_extensions +-- +TABLE: name="pg_available_extensions" schema="" table="pg_available_extensions" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 003 +-- The entire output of pg_backend_memory_contexts is not stable, +-- we test only the existence and basic condition of TopMemoryContext. +select name, ident, parent, level, total_bytes >= free_bytes + from pg_backend_memory_contexts where level = 0 +-- +TABLE: name="pg_backend_memory_contexts" schema="" table="pg_backend_memory_contexts" ctx=Select +FILTER: schema="" table="" column="level" +STMT: SelectStmt +== 004 +-- We can exercise some MemoryContext type stats functions. Most of the +-- column values are too platform-dependant to display. + +-- Ensure stats from the bump allocator look sane. Bump isn't a commonly +-- used context, but it is used in tuplesort.c, so open a cursor to keep +-- the tuplesort alive long enough for us to query the context stats. +begin +-- +STMT: TransactionStmt +== 005 +declare cur cursor for select left(a,10), b + from (values(repeat('a', 512 * 1024),1),(repeat('b', 512),2)) v(a,b) + order by v.a desc +-- +STMT: DeclareCursorStmt +== 006 +fetch 1 from cur +-- +STMT: FetchStmt +== 007 +select name, parent, total_bytes > 0, total_nblocks, free_bytes > 0, free_chunks +from pg_backend_memory_contexts where name = 'Caller tuples' +-- +TABLE: name="pg_backend_memory_contexts" schema="" table="pg_backend_memory_contexts" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 008 +rollback +-- +STMT: TransactionStmt +== 009 +-- At introduction, pg_config had 23 entries; it may grow +select count(*) > 20 as ok from pg_config +-- +TABLE: name="pg_config" schema="" table="pg_config" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 010 +-- We expect no cursors in this test; see also portals.sql +select count(*) = 0 as ok from pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 011 +select count(*) >= 0 as ok from pg_file_settings +-- +TABLE: name="pg_file_settings" schema="" table="pg_file_settings" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- There will surely be at least one rule, with no errors. +select count(*) > 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err + from pg_hba_file_rules +-- +TABLE: name="pg_hba_file_rules" schema="" table="pg_hba_file_rules" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- There may be no rules, and there should be no errors. +select count(*) >= 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err + from pg_ident_file_mappings +-- +TABLE: name="pg_ident_file_mappings" schema="" table="pg_ident_file_mappings" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- There will surely be at least one active lock +select count(*) > 0 as ok from pg_locks +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 015 +-- We expect no prepared statements in this test; see also prepare.sql +select count(*) = 0 as ok from pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- See also prepared_xacts.sql +select count(*) >= 0 as ok from pg_prepared_xacts +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- There will surely be at least one SLRU cache +select count(*) > 0 as ok from pg_stat_slru +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- There must be only one record +select count(*) = 1 as ok from pg_stat_wal +-- +TABLE: name="pg_stat_wal" schema="" table="pg_stat_wal" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- We expect no walreceiver running in this test +select count(*) = 0 as ok from pg_stat_wal_receiver +-- +TABLE: name="pg_stat_wal_receiver" schema="" table="pg_stat_wal_receiver" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 020 +-- This is to record the prevailing planner enable_foo settings during +-- a regression test run. +select name, setting from pg_settings where name like 'enable%' +-- +TABLE: name="pg_settings" schema="" table="pg_settings" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 021 +-- There are always wait event descriptions for various types. InjectionPoint +-- may be present or absent, depending on history since last postmaster start. +select type, count(*) > 0 as ok FROM pg_wait_events + where type <> 'InjectionPoint' group by type order by type COLLATE "C" +-- +TABLE: name="pg_wait_events" schema="" table="pg_wait_events" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="type" +STMT: SelectStmt +== 022 +-- Test that the pg_timezone_names and pg_timezone_abbrevs views are +-- more-or-less working. We can't test their contents in any great detail +-- without the outputs changing anytime IANA updates the underlying data, +-- but it seems reasonable to expect at least one entry per major meridian. +-- (At the time of writing, the actual counts are around 38 because of +-- zones using fractional GMT offsets, so this is a pretty loose test.) +select count(distinct utc_offset) >= 24 as ok from pg_timezone_names +-- +TABLE: name="pg_timezone_names" schema="" table="pg_timezone_names" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 023 +select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs +-- +TABLE: name="pg_timezone_abbrevs" schema="" table="pg_timezone_abbrevs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 024 +-- Let's check the non-default timezone abbreviation sets, too +set timezone_abbreviations = 'Australia' +-- +STMT: VariableSetStmt +== 025 +select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs +-- +TABLE: name="pg_timezone_abbrevs" schema="" table="pg_timezone_abbrevs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 026 +set timezone_abbreviations = 'India' +-- +STMT: VariableSetStmt +== 027 +select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs +-- +TABLE: name="pg_timezone_abbrevs" schema="" table="pg_timezone_abbrevs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/tablesample.metadata.json b/parser/testdata/summary/postgres_regress/tablesample.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tablesample.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tablesample.test b/parser/testdata/summary/postgres_regress/tablesample.test new file mode 100644 index 0000000..7a52313 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tablesample.test @@ -0,0 +1,327 @@ +== 001 +CREATE TABLE test_tablesample (id int, name text) WITH (fillfactor=10) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=DDL +STMT: CreateStmt +== 002 +-- use fillfactor so we don't have to load too much data to get multiple pages + +INSERT INTO test_tablesample + SELECT i, repeat(i::text, 200) FROM generate_series(0, 9) s(i) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 003 +SELECT t.id FROM test_tablesample AS t TABLESAMPLE SYSTEM (50) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +ALIAS: "t"="test_tablesample" +STMT: SelectStmt +== 004 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (100.0/11) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 005 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 006 +SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (50) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 007 +SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (5.5) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 008 +-- 100% should give repeatable count results (ie, all rows) in any case +SELECT count(*) FROM test_tablesample TABLESAMPLE SYSTEM (100) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 009 +SELECT count(*) FROM test_tablesample TABLESAMPLE SYSTEM (100) REPEATABLE (1+2) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT count(*) FROM test_tablesample TABLESAMPLE SYSTEM (100) REPEATABLE (0.4) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 011 +CREATE VIEW test_tablesample_v1 AS + SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (10*2) REPEATABLE (2) +-- +TABLE: name="test_tablesample_v1" schema="" table="test_tablesample_v1" ctx=DDL +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 012 +CREATE VIEW test_tablesample_v2 AS + SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (99) +-- +TABLE: name="test_tablesample_v2" schema="" table="test_tablesample_v2" ctx=DDL +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 013 +-- check a sampled query doesn't affect cursor in progress +BEGIN +-- +STMT: TransactionStmt +== 014 +DECLARE tablesample_cur SCROLL CURSOR FOR + SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (0) +-- +STMT: DeclareCursorStmt +== 015 +FETCH FIRST FROM tablesample_cur +-- +STMT: FetchStmt +== 016 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 017 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 018 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 019 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 020 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 021 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 022 +FETCH FIRST FROM tablesample_cur +-- +STMT: FetchStmt +== 023 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 024 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 025 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 026 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 027 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +== 028 +CLOSE tablesample_cur +-- +STMT: ClosePortalStmt +== 029 +END +-- +STMT: TransactionStmt +== 030 +EXPLAIN (COSTS OFF) + SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (2) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 031 +EXPLAIN (COSTS OFF) + SELECT * FROM test_tablesample_v1 +-- +TABLE: name="test_tablesample_v1" schema="" table="test_tablesample_v1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 032 +-- check inheritance behavior +explain (costs off) + select count(*) from person tablesample bernoulli (100) +-- +TABLE: name="person" schema="" table="person" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 033 +select count(*) from person tablesample bernoulli (100) +-- +TABLE: name="person" schema="" table="person" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 034 +select count(*) from person +-- +TABLE: name="person" schema="" table="person" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 035 +-- check that collations get assigned within the tablesample arguments +SELECT count(*) FROM test_tablesample TABLESAMPLE bernoulli (('1'::text < '0'::text)::int) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- check behavior during rescans, as well as correct handling of min/max pct +select * from + (values (0),(100)) v(pct), + lateral (select count(*) from tenk1 tablesample bernoulli (pct)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 037 +select * from + (values (0),(100)) v(pct), + lateral (select count(*) from tenk1 tablesample system (pct)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 038 +explain (costs off) +select pct, count(unique1) from + (values (0),(100)) v(pct), + lateral (select * from tenk1 tablesample bernoulli (pct)) ss + group by pct +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 039 +select pct, count(unique1) from + (values (0),(100)) v(pct), + lateral (select * from tenk1 tablesample bernoulli (pct)) ss + group by pct +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 040 +select pct, count(unique1) from + (values (0),(100)) v(pct), + lateral (select * from tenk1 tablesample system (pct)) ss + group by pct +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- errors +SELECT id FROM test_tablesample TABLESAMPLE FOOBAR (1) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 042 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (NULL) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 043 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (NULL) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 044 +SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (-1) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 045 +SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (200) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 046 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (-1) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 047 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (200) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +== 048 +SELECT id FROM test_tablesample_v1 TABLESAMPLE BERNOULLI (1) +-- +TABLE: name="test_tablesample_v1" schema="" table="test_tablesample_v1" ctx=Select +STMT: SelectStmt +== 049 +INSERT INTO test_tablesample_v1 VALUES(1) +-- +TABLE: name="test_tablesample_v1" schema="" table="test_tablesample_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +WITH query_select AS (SELECT * FROM test_tablesample) +SELECT * FROM query_select TABLESAMPLE BERNOULLI (5.5) REPEATABLE (1) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +CTE: "query_select" +STMT: SelectStmt +== 051 +SELECT q.* FROM (SELECT * FROM test_tablesample) as q TABLESAMPLE BERNOULLI (5) +-- +ERROR: syntax error at or near "TABLESAMPLE" +CURSORPOS: 55 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 052 +-- check partitioned tables support tablesample +create table parted_sample (a int) partition by list (a) +-- +TABLE: name="parted_sample" schema="" table="parted_sample" ctx=DDL +STMT: CreateStmt +== 053 +create table parted_sample_1 partition of parted_sample for values in (1) +-- +TABLE: name="parted_sample_1" schema="" table="parted_sample_1" ctx=DDL +STMT: CreateStmt +== 054 +create table parted_sample_2 partition of parted_sample for values in (2) +-- +TABLE: name="parted_sample_2" schema="" table="parted_sample_2" ctx=DDL +STMT: CreateStmt +== 055 +explain (costs off) + select * from parted_sample tablesample bernoulli (100) +-- +TABLE: name="parted_sample" schema="" table="parted_sample" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 056 +drop table parted_sample, parted_sample_1, parted_sample_2 +-- +TABLE: name="parted_sample" schema="" table="parted_sample" ctx=DDL +TABLE: name="parted_sample_1" schema="" table="parted_sample_1" ctx=DDL +TABLE: name="parted_sample_2" schema="" table="parted_sample_2" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/tablespace.metadata.json b/parser/testdata/summary/postgres_regress/tablespace.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tablespace.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tablespace.test b/parser/testdata/summary/postgres_regress/tablespace.test new file mode 100644 index 0000000..c34cb0c --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tablespace.test @@ -0,0 +1,1200 @@ +== 001 +-- relative tablespace locations are not allowed +CREATE TABLESPACE regress_tblspace LOCATION 'relative' +-- +STMT: CreateTableSpaceStmt +== 002 +-- fail + +-- empty tablespace locations are not usually allowed +CREATE TABLESPACE regress_tblspace LOCATION '' +-- +STMT: CreateTableSpaceStmt +== 003 +-- fail + +-- as a special developer-only option to allow us to use tablespaces +-- with streaming replication on the same server, an empty location +-- can be allowed as a way to say that the tablespace should be created +-- as a directory in pg_tblspc, rather than being a symlink +SET allow_in_place_tablespaces = true +-- +STMT: VariableSetStmt +== 004 +-- create a tablespace using WITH clause +CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (some_nonexistent_parameter = true) +-- +STMT: CreateTableSpaceStmt +== 005 +-- fail +CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (random_page_cost = 3.0) +-- +STMT: CreateTableSpaceStmt +== 006 +-- ok + +-- check to see the parameter was used +SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith' +-- +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +FILTER: schema="" table="" column="spcname" +STMT: SelectStmt +== 007 +-- drop the tablespace so we can re-use the location +DROP TABLESPACE regress_tblspacewith +-- +STMT: DropTableSpaceStmt +== 008 +-- This returns a relative path as of an effect of allow_in_place_tablespaces, +-- masking the tablespace OID used in the path name. +SELECT regexp_replace(pg_tablespace_location(oid), '(pg_tblspc)/(\d+)', '\1/NNN') + FROM pg_tablespace WHERE spcname = 'regress_tblspace' +-- +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +FUNCTION: name="regexp_replace" function="regexp_replace" schema="" ctx=Call +FUNCTION: name="pg_tablespace_location" function="pg_tablespace_location" schema="" ctx=Call +FILTER: schema="" table="" column="spcname" +STMT: SelectStmt +== 009 +-- try setting and resetting some properties for the new tablespace +ALTER TABLESPACE regress_tblspace SET (random_page_cost = 1.0, seq_page_cost = 1.1) +-- +STMT: AlterTableSpaceOptionsStmt +== 010 +ALTER TABLESPACE regress_tblspace SET (some_nonexistent_parameter = true) +-- +STMT: AlterTableSpaceOptionsStmt +== 011 +-- fail +ALTER TABLESPACE regress_tblspace RESET (random_page_cost = 2.0) +-- +STMT: AlterTableSpaceOptionsStmt +== 012 +-- fail +ALTER TABLESPACE regress_tblspace RESET (random_page_cost, effective_io_concurrency) +-- +STMT: AlterTableSpaceOptionsStmt +== 013 +-- ok + +-- REINDEX (TABLESPACE) +-- catalogs and system tablespaces +-- system catalog, fail +REINDEX (TABLESPACE regress_tblspace) TABLE pg_am +-- +STMT: ReindexStmt +== 014 +REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_am +-- +STMT: ReindexStmt +== 015 +-- shared catalog, fail +REINDEX (TABLESPACE regress_tblspace) TABLE pg_authid +-- +STMT: ReindexStmt +== 016 +REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_authid +-- +STMT: ReindexStmt +== 017 +-- toast relations, fail +REINDEX (TABLESPACE regress_tblspace) INDEX pg_toast.pg_toast_1260_index +-- +STMT: ReindexStmt +== 018 +REINDEX (TABLESPACE regress_tblspace) INDEX CONCURRENTLY pg_toast.pg_toast_1260_index +-- +STMT: ReindexStmt +== 019 +REINDEX (TABLESPACE regress_tblspace) TABLE pg_toast.pg_toast_1260 +-- +STMT: ReindexStmt +== 020 +REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_toast.pg_toast_1260 +-- +STMT: ReindexStmt +== 021 +-- system catalog, fail +REINDEX (TABLESPACE pg_global) TABLE pg_authid +-- +STMT: ReindexStmt +== 022 +REINDEX (TABLESPACE pg_global) TABLE CONCURRENTLY pg_authid +-- +STMT: ReindexStmt +== 023 +-- table with toast relation +CREATE TABLE regress_tblspace_test_tbl (num1 bigint, num2 double precision, t text) +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: CreateStmt +== 024 +INSERT INTO regress_tblspace_test_tbl (num1, num2, t) + SELECT round(random()*100), random(), 'text' + FROM generate_series(1, 10) s(i) +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DML +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 025 +CREATE INDEX regress_tblspace_test_tbl_idx ON regress_tblspace_test_tbl (num1) +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: IndexStmt +== 026 +-- move to global tablespace, fail +REINDEX (TABLESPACE pg_global) INDEX regress_tblspace_test_tbl_idx +-- +STMT: ReindexStmt +== 027 +REINDEX (TABLESPACE pg_global) INDEX CONCURRENTLY regress_tblspace_test_tbl_idx +-- +STMT: ReindexStmt +== 028 +-- check transactional behavior of REINDEX (TABLESPACE) +BEGIN +-- +STMT: TransactionStmt +== 029 +REINDEX (TABLESPACE regress_tblspace) INDEX regress_tblspace_test_tbl_idx +-- +STMT: ReindexStmt +== 030 +REINDEX (TABLESPACE regress_tblspace) TABLE regress_tblspace_test_tbl +-- +STMT: ReindexStmt +== 031 +ROLLBACK +-- +STMT: TransactionStmt +== 032 +-- no relation moved to the new tablespace +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +== 033 +-- check that all indexes are moved to a new tablespace with different +-- relfilenode. +-- Save first the existing relfilenode for the toast and main relations. +SELECT relfilenode as main_filenode FROM pg_class + WHERE relname = 'regress_tblspace_test_tbl_idx' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 034 +SELECT relfilenode as toast_filenode FROM pg_class + WHERE oid = + (SELECT i.indexrelid + FROM pg_class c, + pg_index i + WHERE i.indrelid = c.reltoastrelid AND + c.relname = 'regress_tblspace_test_tbl') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="i" column="indrelid" +FILTER: schema="" table="c" column="reltoastrelid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +== 035 +REINDEX (TABLESPACE regress_tblspace) TABLE regress_tblspace_test_tbl +-- +STMT: ReindexStmt +== 036 +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' + ORDER BY c.relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +== 037 +ALTER TABLE regress_tblspace_test_tbl SET TABLESPACE regress_tblspace +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: AlterTableStmt +== 038 +ALTER TABLE regress_tblspace_test_tbl SET TABLESPACE pg_default +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: AlterTableStmt +== 039 +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' + ORDER BY c.relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +== 040 +-- Move back to the default tablespace. +ALTER INDEX regress_tblspace_test_tbl_idx SET TABLESPACE pg_default +-- +STMT: AlterTableStmt +== 041 +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' + ORDER BY c.relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +== 042 +REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE regress_tblspace_test_tbl +-- +STMT: ReindexStmt +== 043 +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' + ORDER BY c.relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +== 044 +SELECT relfilenode = :main_filenode AS main_same FROM pg_class + WHERE relname = 'regress_tblspace_test_tbl_idx' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 045 +SELECT relfilenode = :toast_filenode as toast_same FROM pg_class + WHERE oid = + (SELECT i.indexrelid + FROM pg_class c, + pg_index i + WHERE i.indrelid = c.reltoastrelid AND + c.relname = 'regress_tblspace_test_tbl') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 046 +DROP TABLE regress_tblspace_test_tbl +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: DropStmt +== 047 +-- REINDEX (TABLESPACE) with partitions +-- Create a partition tree and check the set of relations reindexed +-- with their new tablespace. +CREATE TABLE tbspace_reindex_part (c1 int, c2 int) PARTITION BY RANGE (c1) +-- +TABLE: name="tbspace_reindex_part" schema="" table="tbspace_reindex_part" ctx=DDL +STMT: CreateStmt +== 048 +CREATE TABLE tbspace_reindex_part_0 PARTITION OF tbspace_reindex_part + FOR VALUES FROM (0) TO (10) PARTITION BY list (c2) +-- +TABLE: name="tbspace_reindex_part_0" schema="" table="tbspace_reindex_part_0" ctx=DDL +STMT: CreateStmt +== 049 +CREATE TABLE tbspace_reindex_part_0_1 PARTITION OF tbspace_reindex_part_0 + FOR VALUES IN (1) +-- +TABLE: name="tbspace_reindex_part_0_1" schema="" table="tbspace_reindex_part_0_1" ctx=DDL +STMT: CreateStmt +== 050 +CREATE TABLE tbspace_reindex_part_0_2 PARTITION OF tbspace_reindex_part_0 + FOR VALUES IN (2) +-- +TABLE: name="tbspace_reindex_part_0_2" schema="" table="tbspace_reindex_part_0_2" ctx=DDL +STMT: CreateStmt +== 051 +-- This partitioned table will have no partitions. +CREATE TABLE tbspace_reindex_part_10 PARTITION OF tbspace_reindex_part + FOR VALUES FROM (10) TO (20) PARTITION BY list (c2) +-- +TABLE: name="tbspace_reindex_part_10" schema="" table="tbspace_reindex_part_10" ctx=DDL +STMT: CreateStmt +== 052 +-- Create some partitioned indexes +CREATE INDEX tbspace_reindex_part_index ON ONLY tbspace_reindex_part (c1) +-- +TABLE: name="tbspace_reindex_part" schema="" table="tbspace_reindex_part" ctx=DDL +STMT: IndexStmt +== 053 +CREATE INDEX tbspace_reindex_part_index_0 ON ONLY tbspace_reindex_part_0 (c1) +-- +TABLE: name="tbspace_reindex_part_0" schema="" table="tbspace_reindex_part_0" ctx=DDL +STMT: IndexStmt +== 054 +ALTER INDEX tbspace_reindex_part_index ATTACH PARTITION tbspace_reindex_part_index_0 +-- +STMT: AlterTableStmt +== 055 +-- This partitioned index will have no partitions. +CREATE INDEX tbspace_reindex_part_index_10 ON ONLY tbspace_reindex_part_10 (c1) +-- +TABLE: name="tbspace_reindex_part_10" schema="" table="tbspace_reindex_part_10" ctx=DDL +STMT: IndexStmt +== 056 +ALTER INDEX tbspace_reindex_part_index ATTACH PARTITION tbspace_reindex_part_index_10 +-- +STMT: AlterTableStmt +== 057 +CREATE INDEX tbspace_reindex_part_index_0_1 ON ONLY tbspace_reindex_part_0_1 (c1) +-- +TABLE: name="tbspace_reindex_part_0_1" schema="" table="tbspace_reindex_part_0_1" ctx=DDL +STMT: IndexStmt +== 058 +ALTER INDEX tbspace_reindex_part_index_0 ATTACH PARTITION tbspace_reindex_part_index_0_1 +-- +STMT: AlterTableStmt +== 059 +CREATE INDEX tbspace_reindex_part_index_0_2 ON ONLY tbspace_reindex_part_0_2 (c1) +-- +TABLE: name="tbspace_reindex_part_0_2" schema="" table="tbspace_reindex_part_0_2" ctx=DDL +STMT: IndexStmt +== 060 +ALTER INDEX tbspace_reindex_part_index_0 ATTACH PARTITION tbspace_reindex_part_index_0_2 +-- +STMT: AlterTableStmt +== 061 +SELECT relid, parentrelid, level FROM pg_partition_tree('tbspace_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +== 062 +-- Track the original tablespace, relfilenode and OID of each index +-- in the tree. +CREATE TEMP TABLE reindex_temp_before AS + SELECT oid, relname, relfilenode, reltablespace + FROM pg_class + WHERE relname ~ 'tbspace_reindex_part_index' +-- +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: CreateTableAsStmt +STMT: SelectStmt +== 063 +REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE tbspace_reindex_part +-- +STMT: ReindexStmt +== 064 +-- REINDEX CONCURRENTLY changes the OID of the old relation, hence a check +-- based on the relation name below. +SELECT b.relname, + CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged' + ELSE 'relfilenode has changed' END AS filenode, + CASE WHEN a.reltablespace = b.reltablespace THEN 'reltablespace is unchanged' + ELSE 'reltablespace has changed' END AS tbspace + FROM reindex_temp_before b JOIN pg_class a ON b.relname = a.relname + ORDER BY 1 +-- +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_class" +ALIAS: "b"="reindex_temp_before" +STMT: SelectStmt +== 065 +DROP TABLE tbspace_reindex_part +-- +TABLE: name="tbspace_reindex_part" schema="" table="tbspace_reindex_part" ctx=DDL +STMT: DropStmt +== 066 +-- create a schema we can use +CREATE SCHEMA testschema +-- +STMT: CreateSchemaStmt +== 067 +-- try a table +CREATE TABLE testschema.foo (i int) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.foo" schema="testschema" table="foo" ctx=DDL +STMT: CreateStmt +== 068 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'foo' +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +== 069 +INSERT INTO testschema.foo VALUES(1) +-- +TABLE: name="testschema.foo" schema="testschema" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +INSERT INTO testschema.foo VALUES(2) +-- +TABLE: name="testschema.foo" schema="testschema" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +-- tables from dynamic sources +CREATE TABLE testschema.asselect TABLESPACE regress_tblspace AS SELECT 1 +-- +TABLE: name="testschema.asselect" schema="testschema" table="asselect" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 072 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'asselect' +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +== 073 +PREPARE selectsource(int) AS SELECT $1 +-- +STMT: PrepareStmt +STMT: SelectStmt +== 074 +CREATE TABLE testschema.asexecute TABLESPACE regress_tblspace + AS EXECUTE selectsource(2) +-- +TABLE: name="testschema.asexecute" schema="testschema" table="asexecute" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 075 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'asexecute' +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +== 076 +-- index +CREATE INDEX foo_idx on testschema.foo(i) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.foo" schema="testschema" table="foo" ctx=DDL +STMT: IndexStmt +== 077 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'foo_idx' +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +== 078 +-- check \d output + +|-- +-- partitioned table +|-- +CREATE TABLE testschema.part (a int) PARTITION BY LIST (a) +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: CreateStmt +== 079 +SET default_tablespace TO pg_global +-- +STMT: VariableSetStmt +== 080 +CREATE TABLE testschema.part_1 PARTITION OF testschema.part FOR VALUES IN (1) +-- +TABLE: name="testschema.part_1" schema="testschema" table="part_1" ctx=DDL +STMT: CreateStmt +== 081 +RESET default_tablespace +-- +STMT: VariableSetStmt +== 082 +CREATE TABLE testschema.part_1 PARTITION OF testschema.part FOR VALUES IN (1) +-- +TABLE: name="testschema.part_1" schema="testschema" table="part_1" ctx=DDL +STMT: CreateStmt +== 083 +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +== 084 +CREATE TABLE testschema.part_2 PARTITION OF testschema.part FOR VALUES IN (2) +-- +TABLE: name="testschema.part_2" schema="testschema" table="part_2" ctx=DDL +STMT: CreateStmt +== 085 +SET default_tablespace TO pg_global +-- +STMT: VariableSetStmt +== 086 +CREATE TABLE testschema.part_3 PARTITION OF testschema.part FOR VALUES IN (3) +-- +TABLE: name="testschema.part_3" schema="testschema" table="part_3" ctx=DDL +STMT: CreateStmt +== 087 +ALTER TABLE testschema.part SET TABLESPACE regress_tblspace +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: AlterTableStmt +== 088 +CREATE TABLE testschema.part_3 PARTITION OF testschema.part FOR VALUES IN (3) +-- +TABLE: name="testschema.part_3" schema="testschema" table="part_3" ctx=DDL +STMT: CreateStmt +== 089 +CREATE TABLE testschema.part_4 PARTITION OF testschema.part FOR VALUES IN (4) + TABLESPACE pg_default +-- +TABLE: name="testschema.part_4" schema="testschema" table="part_4" ctx=DDL +STMT: CreateStmt +== 090 +CREATE TABLE testschema.part_56 PARTITION OF testschema.part FOR VALUES IN (5, 6) + PARTITION BY LIST (a) +-- +TABLE: name="testschema.part_56" schema="testschema" table="part_56" ctx=DDL +STMT: CreateStmt +== 091 +ALTER TABLE testschema.part SET TABLESPACE pg_default +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: AlterTableStmt +== 092 +CREATE TABLE testschema.part_78 PARTITION OF testschema.part FOR VALUES IN (7, 8) + PARTITION BY LIST (a) +-- +TABLE: name="testschema.part_78" schema="testschema" table="part_78" ctx=DDL +STMT: CreateStmt +== 093 +CREATE TABLE testschema.part_910 PARTITION OF testschema.part FOR VALUES IN (9, 10) + PARTITION BY LIST (a) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.part_910" schema="testschema" table="part_910" ctx=DDL +STMT: CreateStmt +== 094 +RESET default_tablespace +-- +STMT: VariableSetStmt +== 095 +CREATE TABLE testschema.part_78 PARTITION OF testschema.part FOR VALUES IN (7, 8) + PARTITION BY LIST (a) +-- +TABLE: name="testschema.part_78" schema="testschema" table="part_78" ctx=DDL +STMT: CreateStmt +== 096 +SELECT relname, spcname FROM pg_catalog.pg_class c + JOIN pg_catalog.pg_namespace n ON (c.relnamespace = n.oid) + LEFT JOIN pg_catalog.pg_tablespace t ON c.reltablespace = t.oid + where c.relname LIKE 'part%' AND n.nspname = 'testschema' order by relname +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +TABLE: name="pg_catalog.pg_namespace" schema="pg_catalog" table="pg_namespace" ctx=Select +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "n"="pg_catalog.pg_namespace" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +== 097 +RESET default_tablespace +-- +STMT: VariableSetStmt +== 098 +DROP TABLE testschema.part +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: DropStmt +== 099 +-- partitioned index +CREATE TABLE testschema.part (a int) PARTITION BY LIST (a) +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: CreateStmt +== 100 +CREATE TABLE testschema.part1 PARTITION OF testschema.part FOR VALUES IN (1) +-- +TABLE: name="testschema.part1" schema="testschema" table="part1" ctx=DDL +STMT: CreateStmt +== 101 +CREATE INDEX part_a_idx ON testschema.part (a) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: IndexStmt +== 102 +CREATE TABLE testschema.part2 PARTITION OF testschema.part FOR VALUES IN (2) +-- +TABLE: name="testschema.part2" schema="testschema" table="part2" ctx=DDL +STMT: CreateStmt +== 103 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname LIKE 'part%_idx' ORDER BY relname +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +== 104 +-- partitioned rels cannot specify the default tablespace. These fail: +CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE pg_default +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +== 105 +CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE pg_default) PARTITION BY LIST (a) +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +== 106 +SET default_tablespace TO 'pg_default' +-- +STMT: VariableSetStmt +== 107 +CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +== 108 +CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a) +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +== 109 +-- but these work: +CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +== 110 +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +== 111 +CREATE TABLE testschema.dflt2 (a int PRIMARY KEY) PARTITION BY LIST (a) +-- +TABLE: name="testschema.dflt2" schema="testschema" table="dflt2" ctx=DDL +STMT: CreateStmt +== 112 +DROP TABLE testschema.dflt, testschema.dflt2 +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +TABLE: name="testschema.dflt2" schema="testschema" table="dflt2" ctx=DDL +STMT: DropStmt +== 113 +-- check that default_tablespace doesn't affect ALTER TABLE index rebuilds +CREATE TABLE testschema.test_default_tab(id bigint) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: CreateStmt +== 114 +INSERT INTO testschema.test_default_tab VALUES (1) +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +CREATE INDEX test_index1 on testschema.test_default_tab (id) +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: IndexStmt +== 116 +CREATE INDEX test_index2 on testschema.test_default_tab (id) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: IndexStmt +== 117 +ALTER TABLE testschema.test_default_tab ADD CONSTRAINT test_index3 PRIMARY KEY (id) +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +== 118 +ALTER TABLE testschema.test_default_tab ADD CONSTRAINT test_index4 UNIQUE (id) USING INDEX TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +== 119 +-- use a custom tablespace for default_tablespace +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +== 120 +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +== 121 +SELECT * FROM testschema.test_default_tab +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=Select +STMT: SelectStmt +== 122 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE int +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +== 123 +SELECT * FROM testschema.test_default_tab +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=Select +STMT: SelectStmt +== 124 +-- now use the default tablespace for default_tablespace +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +== 125 +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE int +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +== 126 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +== 127 +DROP TABLE testschema.test_default_tab +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: DropStmt +== 128 +-- check that default_tablespace doesn't affect ALTER TABLE index rebuilds +-- (this time with a partitioned table) +CREATE TABLE testschema.test_default_tab_p(id bigint, val bigint) + PARTITION BY LIST (id) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: CreateStmt +== 129 +CREATE TABLE testschema.test_default_tab_p1 PARTITION OF testschema.test_default_tab_p + FOR VALUES IN (1) +-- +TABLE: name="testschema.test_default_tab_p1" schema="testschema" table="test_default_tab_p1" ctx=DDL +STMT: CreateStmt +== 130 +INSERT INTO testschema.test_default_tab_p VALUES (1) +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 131 +CREATE INDEX test_index1 on testschema.test_default_tab_p (val) +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: IndexStmt +== 132 +CREATE INDEX test_index2 on testschema.test_default_tab_p (val) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: IndexStmt +== 133 +ALTER TABLE testschema.test_default_tab_p ADD CONSTRAINT test_index3 PRIMARY KEY (id) +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +== 134 +ALTER TABLE testschema.test_default_tab_p ADD CONSTRAINT test_index4 UNIQUE (id) USING INDEX TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +== 135 +-- use a custom tablespace for default_tablespace +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +== 136 +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab_p ALTER val TYPE bigint +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +== 137 +SELECT * FROM testschema.test_default_tab_p +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=Select +STMT: SelectStmt +== 138 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab_p ALTER val TYPE int +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +== 139 +SELECT * FROM testschema.test_default_tab_p +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=Select +STMT: SelectStmt +== 140 +-- now use the default tablespace for default_tablespace +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +== 141 +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab_p ALTER val TYPE int +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +== 142 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab_p ALTER val TYPE bigint +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +== 143 +DROP TABLE testschema.test_default_tab_p +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: DropStmt +== 144 +-- check that default_tablespace affects index additions in ALTER TABLE +CREATE TABLE testschema.test_tab(id int) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: CreateStmt +== 145 +INSERT INTO testschema.test_tab VALUES (1) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 146 +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +== 147 +ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_unique UNIQUE (id) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: AlterTableStmt +== 148 +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +== 149 +ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_pkey PRIMARY KEY (id) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: AlterTableStmt +== 150 +SELECT * FROM testschema.test_tab +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=Select +STMT: SelectStmt +== 151 +DROP TABLE testschema.test_tab +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: DropStmt +== 152 +-- check that default_tablespace is handled correctly by multi-command +-- ALTER TABLE that includes a tablespace-preserving rewrite +CREATE TABLE testschema.test_tab(a int, b int, c int) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: CreateStmt +== 153 +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +== 154 +ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_unique UNIQUE (a) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: AlterTableStmt +== 155 +CREATE INDEX test_tab_a_idx ON testschema.test_tab (a) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: IndexStmt +== 156 +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +== 157 +CREATE INDEX test_tab_b_idx ON testschema.test_tab (b) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: IndexStmt +== 158 +ALTER TABLE testschema.test_tab ALTER b TYPE bigint, ADD UNIQUE (c) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: AlterTableStmt +== 159 +DROP TABLE testschema.test_tab +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: DropStmt +== 160 +-- let's try moving a table from one place to another +CREATE TABLE testschema.atable AS VALUES (1), (2) +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 161 +CREATE UNIQUE INDEX anindex ON testschema.atable(column1) +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DDL +STMT: IndexStmt +== 162 +ALTER TABLE testschema.atable SET TABLESPACE regress_tblspace +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DDL +STMT: AlterTableStmt +== 163 +ALTER INDEX testschema.anindex SET TABLESPACE regress_tblspace +-- +STMT: AlterTableStmt +== 164 +ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_global +-- +STMT: AlterTableStmt +== 165 +ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_default +-- +STMT: AlterTableStmt +== 166 +ALTER INDEX testschema.part_a_idx SET TABLESPACE regress_tblspace +-- +STMT: AlterTableStmt +== 167 +INSERT INTO testschema.atable VALUES(3) +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +-- ok +INSERT INTO testschema.atable VALUES(1) +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 169 +-- fail (checks index) +SELECT COUNT(*) FROM testschema.atable +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 170 +-- checks heap + +-- let's try moving a materialized view from one place to another +CREATE MATERIALIZED VIEW testschema.amv AS SELECT * FROM testschema.atable +-- +TABLE: name="testschema.amv" schema="testschema" table="amv" ctx=DDL +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 171 +ALTER MATERIALIZED VIEW testschema.amv SET TABLESPACE regress_tblspace +-- +TABLE: name="testschema.amv" schema="testschema" table="amv" ctx=DDL +STMT: AlterTableStmt +== 172 +REFRESH MATERIALIZED VIEW testschema.amv +-- +TABLE: name="testschema.amv" schema="testschema" table="amv" ctx=DDL +STMT: RefreshMatViewStmt +== 173 +SELECT COUNT(*) FROM testschema.amv +-- +TABLE: name="testschema.amv" schema="testschema" table="amv" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 174 +-- Will fail with bad path +CREATE TABLESPACE regress_badspace LOCATION '/no/such/location' +-- +STMT: CreateTableSpaceStmt +== 175 +-- No such tablespace +CREATE TABLE bar (i int) TABLESPACE regress_nosuchspace +-- +TABLE: name="bar" schema="" table="bar" ctx=DDL +STMT: CreateStmt +== 176 +-- Fail, in use for some partitioned object +DROP TABLESPACE regress_tblspace +-- +STMT: DropTableSpaceStmt +== 177 +ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_default +-- +STMT: AlterTableStmt +== 178 +-- Fail, not empty +DROP TABLESPACE regress_tblspace +-- +STMT: DropTableSpaceStmt +== 179 +-- Adequate cache initialization before GRANT +BEGIN +-- +STMT: TransactionStmt +== 180 +GRANT ALL ON TABLESPACE regress_tblspace TO PUBLIC +-- +STMT: GrantStmt +== 181 +ROLLBACK +-- +STMT: TransactionStmt +== 182 +CREATE ROLE regress_tablespace_user1 login +-- +STMT: CreateRoleStmt +== 183 +CREATE ROLE regress_tablespace_user2 login +-- +STMT: CreateRoleStmt +== 184 +GRANT USAGE ON SCHEMA testschema TO regress_tablespace_user2 +-- +STMT: GrantStmt +== 185 +ALTER TABLESPACE regress_tblspace OWNER TO regress_tablespace_user1 +-- +STMT: AlterOwnerStmt +== 186 +CREATE TABLE testschema.tablespace_acl (c int) +-- +TABLE: name="testschema.tablespace_acl" schema="testschema" table="tablespace_acl" ctx=DDL +STMT: CreateStmt +== 187 +-- new owner lacks permission to create this index from scratch +CREATE INDEX k ON testschema.tablespace_acl (c) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.tablespace_acl" schema="testschema" table="tablespace_acl" ctx=DDL +STMT: IndexStmt +== 188 +ALTER TABLE testschema.tablespace_acl OWNER TO regress_tablespace_user2 +-- +TABLE: name="testschema.tablespace_acl" schema="testschema" table="tablespace_acl" ctx=DDL +STMT: AlterTableStmt +== 189 +SET SESSION ROLE regress_tablespace_user2 +-- +STMT: VariableSetStmt +== 190 +CREATE TABLE tablespace_table (i int) TABLESPACE regress_tblspace +-- +TABLE: name="tablespace_table" schema="" table="tablespace_table" ctx=DDL +STMT: CreateStmt +== 191 +-- fail +ALTER TABLE testschema.tablespace_acl ALTER c TYPE bigint +-- +TABLE: name="testschema.tablespace_acl" schema="testschema" table="tablespace_acl" ctx=DDL +STMT: AlterTableStmt +== 192 +REINDEX (TABLESPACE regress_tblspace) TABLE tablespace_table +-- +STMT: ReindexStmt +== 193 +-- fail +REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE tablespace_table +-- +STMT: ReindexStmt +== 194 +-- fail +RESET ROLE +-- +STMT: VariableSetStmt +== 195 +ALTER TABLESPACE regress_tblspace RENAME TO regress_tblspace_renamed +-- +STMT: RenameStmt +== 196 +ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +== 197 +ALTER INDEX ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +== 198 +ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +== 199 +-- Should show notice that nothing was done +ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +== 200 +ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +== 201 +-- Should succeed +DROP TABLESPACE regress_tblspace_renamed +-- +STMT: DropTableSpaceStmt +== 202 +DROP SCHEMA testschema CASCADE +-- +STMT: DropStmt +== 203 +DROP ROLE regress_tablespace_user1 +-- +STMT: DropRoleStmt +== 204 +DROP ROLE regress_tablespace_user2 +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/temp.metadata.json b/parser/testdata/summary/postgres_regress/temp.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/temp.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/temp.test b/parser/testdata/summary/postgres_regress/temp.test new file mode 100644 index 0000000..743a826 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/temp.test @@ -0,0 +1,864 @@ +== 001 +|-- +-- TEMP +-- Test temp relations and indexes +|-- + +-- test temp table/index masking + +CREATE TABLE temptest(col int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 002 +CREATE INDEX i_temptest ON temptest(col) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: IndexStmt +== 003 +CREATE TEMP TABLE temptest(tcol int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 004 +CREATE INDEX i_temptest ON temptest(tcol) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: IndexStmt +== 005 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 006 +DROP INDEX i_temptest +-- +STMT: DropStmt +== 007 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +== 008 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 009 +DROP INDEX i_temptest +-- +STMT: DropStmt +== 010 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +== 011 +-- test temp table selects + +CREATE TABLE temptest(col int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 012 +INSERT INTO temptest VALUES (1) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +CREATE TEMP TABLE temptest(tcol float) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 014 +INSERT INTO temptest VALUES (2.1) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 016 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +== 017 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 018 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +== 019 +-- test temp table deletion + +CREATE TEMP TABLE temptest(col int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 020 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 021 +-- Test ON COMMIT DELETE ROWS + +CREATE TEMP TABLE temptest(col int) ON COMMIT DELETE ROWS +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 022 +-- while we're here, verify successful truncation of index with SQL function +CREATE INDEX ON temptest(bit_length('')) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +FUNCTION: name="bit_length" function="bit_length" schema="" ctx=Call +STMT: IndexStmt +== 023 +BEGIN +-- +STMT: TransactionStmt +== 024 +INSERT INTO temptest VALUES (1) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO temptest VALUES (2) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 027 +COMMIT +-- +STMT: TransactionStmt +== 028 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 029 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +== 030 +BEGIN +-- +STMT: TransactionStmt +== 031 +CREATE TEMP TABLE temptest(col) ON COMMIT DELETE ROWS AS SELECT 1 +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 032 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 033 +COMMIT +-- +STMT: TransactionStmt +== 034 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 035 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +== 036 +-- Test ON COMMIT DROP + +BEGIN +-- +STMT: TransactionStmt +== 037 +CREATE TEMP TABLE temptest(col int) ON COMMIT DROP +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 038 +INSERT INTO temptest VALUES (1) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO temptest VALUES (2) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 041 +COMMIT +-- +STMT: TransactionStmt +== 042 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 043 +BEGIN +-- +STMT: TransactionStmt +== 044 +CREATE TEMP TABLE temptest(col) ON COMMIT DROP AS SELECT 1 +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 045 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 046 +COMMIT +-- +STMT: TransactionStmt +== 047 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 048 +-- Test it with a CHECK condition that produces a toasted pg_constraint entry +BEGIN +-- +STMT: TransactionStmt +== 049 +do $$ +begin + execute format($cmd$ + CREATE TEMP TABLE temptest (col text CHECK (col < %L)) ON COMMIT DROP + $cmd$, + (SELECT string_agg(g.i::text || ':' || random()::text, '|') + FROM generate_series(1, 100) g(i))); +end$$ +-- +STMT: DoStmt +== 050 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 051 +COMMIT +-- +STMT: TransactionStmt +== 052 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 053 +-- ON COMMIT is only allowed for TEMP + +CREATE TABLE temptest(col int) ON COMMIT DELETE ROWS +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 054 +CREATE TABLE temptest(col) ON COMMIT DELETE ROWS AS SELECT 1 +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 055 +-- Test foreign keys +BEGIN +-- +STMT: TransactionStmt +== 056 +CREATE TEMP TABLE temptest1(col int PRIMARY KEY) +-- +TABLE: name="temptest1" schema="" table="temptest1" ctx=DDL +STMT: CreateStmt +== 057 +CREATE TEMP TABLE temptest2(col int REFERENCES temptest1) + ON COMMIT DELETE ROWS +-- +TABLE: name="temptest2" schema="" table="temptest2" ctx=DDL +STMT: CreateStmt +== 058 +INSERT INTO temptest1 VALUES (1) +-- +TABLE: name="temptest1" schema="" table="temptest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +INSERT INTO temptest2 VALUES (1) +-- +TABLE: name="temptest2" schema="" table="temptest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +COMMIT +-- +STMT: TransactionStmt +== 061 +SELECT * FROM temptest1 +-- +TABLE: name="temptest1" schema="" table="temptest1" ctx=Select +STMT: SelectStmt +== 062 +SELECT * FROM temptest2 +-- +TABLE: name="temptest2" schema="" table="temptest2" ctx=Select +STMT: SelectStmt +== 063 +BEGIN +-- +STMT: TransactionStmt +== 064 +CREATE TEMP TABLE temptest3(col int PRIMARY KEY) ON COMMIT DELETE ROWS +-- +TABLE: name="temptest3" schema="" table="temptest3" ctx=DDL +STMT: CreateStmt +== 065 +CREATE TEMP TABLE temptest4(col int REFERENCES temptest3) +-- +TABLE: name="temptest4" schema="" table="temptest4" ctx=DDL +STMT: CreateStmt +== 066 +COMMIT +-- +STMT: TransactionStmt +== 067 +-- Test manipulation of temp schema's placement in search path + +create table public.whereami (f1 text) +-- +TABLE: name="public.whereami" schema="public" table="whereami" ctx=DDL +STMT: CreateStmt +== 068 +insert into public.whereami values ('public') +-- +TABLE: name="public.whereami" schema="public" table="whereami" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 069 +create temp table whereami (f1 text) +-- +TABLE: name="whereami" schema="" table="whereami" ctx=DDL +STMT: CreateStmt +== 070 +insert into whereami values ('temp') +-- +TABLE: name="whereami" schema="" table="whereami" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +create function public.whoami() returns text + as $$select 'public'::text$$ language sql +-- +FUNCTION: name="public.whoami" function="whoami" schema="public" ctx=DDL +STMT: CreateFunctionStmt +== 072 +create function pg_temp.whoami() returns text + as $$select 'temp'::text$$ language sql +-- +FUNCTION: name="pg_temp.whoami" function="whoami" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +== 073 +-- default should have pg_temp implicitly first, but only for tables +select * from whereami +-- +TABLE: name="whereami" schema="" table="whereami" ctx=Select +STMT: SelectStmt +== 074 +select whoami() +-- +FUNCTION: name="whoami" function="whoami" schema="" ctx=Call +STMT: SelectStmt +== 075 +-- can list temp first explicitly, but it still doesn't affect functions +set search_path = pg_temp, public +-- +STMT: VariableSetStmt +== 076 +select * from whereami +-- +TABLE: name="whereami" schema="" table="whereami" ctx=Select +STMT: SelectStmt +== 077 +select whoami() +-- +FUNCTION: name="whoami" function="whoami" schema="" ctx=Call +STMT: SelectStmt +== 078 +-- or put it last for security +set search_path = public, pg_temp +-- +STMT: VariableSetStmt +== 079 +select * from whereami +-- +TABLE: name="whereami" schema="" table="whereami" ctx=Select +STMT: SelectStmt +== 080 +select whoami() +-- +FUNCTION: name="whoami" function="whoami" schema="" ctx=Call +STMT: SelectStmt +== 081 +-- you can invoke a temp function explicitly, though +select pg_temp.whoami() +-- +FUNCTION: name="pg_temp.whoami" function="whoami" schema="pg_temp" ctx=Call +STMT: SelectStmt +== 082 +drop table public.whereami +-- +TABLE: name="public.whereami" schema="public" table="whereami" ctx=DDL +STMT: DropStmt +== 083 +-- types in temp schema +set search_path = pg_temp, public +-- +STMT: VariableSetStmt +== 084 +create domain pg_temp.nonempty as text check (value <> '') +-- +STMT: CreateDomainStmt +== 085 +-- function-syntax invocation of types matches rules for functions +select nonempty('') +-- +FUNCTION: name="nonempty" function="nonempty" schema="" ctx=Call +STMT: SelectStmt +== 086 +select pg_temp.nonempty('') +-- +FUNCTION: name="pg_temp.nonempty" function="nonempty" schema="pg_temp" ctx=Call +STMT: SelectStmt +== 087 +-- other syntax matches rules for tables +select ''::nonempty +-- +STMT: SelectStmt +== 088 +reset search_path +-- +STMT: VariableSetStmt +== 089 +-- For partitioned temp tables, ON COMMIT actions ignore storage-less +-- partitioned tables. +begin +-- +STMT: TransactionStmt +== 090 +create temp table temp_parted_oncommit (a int) + partition by list (a) on commit delete rows +-- +TABLE: name="temp_parted_oncommit" schema="" table="temp_parted_oncommit" ctx=DDL +STMT: CreateStmt +== 091 +create temp table temp_parted_oncommit_1 + partition of temp_parted_oncommit + for values in (1) on commit delete rows +-- +TABLE: name="temp_parted_oncommit_1" schema="" table="temp_parted_oncommit_1" ctx=DDL +STMT: CreateStmt +== 092 +insert into temp_parted_oncommit values (1) +-- +TABLE: name="temp_parted_oncommit" schema="" table="temp_parted_oncommit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +commit +-- +STMT: TransactionStmt +== 094 +-- partitions are emptied by the previous commit +select * from temp_parted_oncommit +-- +TABLE: name="temp_parted_oncommit" schema="" table="temp_parted_oncommit" ctx=Select +STMT: SelectStmt +== 095 +drop table temp_parted_oncommit +-- +TABLE: name="temp_parted_oncommit" schema="" table="temp_parted_oncommit" ctx=DDL +STMT: DropStmt +== 096 +-- Check dependencies between ON COMMIT actions with a partitioned +-- table and its partitions. Using ON COMMIT DROP on a parent removes +-- the whole set. +begin +-- +STMT: TransactionStmt +== 097 +create temp table temp_parted_oncommit_test (a int) + partition by list (a) on commit drop +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DDL +STMT: CreateStmt +== 098 +create temp table temp_parted_oncommit_test1 + partition of temp_parted_oncommit_test + for values in (1) on commit delete rows +-- +TABLE: name="temp_parted_oncommit_test1" schema="" table="temp_parted_oncommit_test1" ctx=DDL +STMT: CreateStmt +== 099 +create temp table temp_parted_oncommit_test2 + partition of temp_parted_oncommit_test + for values in (2) on commit drop +-- +TABLE: name="temp_parted_oncommit_test2" schema="" table="temp_parted_oncommit_test2" ctx=DDL +STMT: CreateStmt +== 100 +insert into temp_parted_oncommit_test values (1), (2) +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +commit +-- +STMT: TransactionStmt +== 102 +-- no relations remain in this case. +select relname from pg_class where relname ~ '^temp_parted_oncommit_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 103 +-- Using ON COMMIT DELETE on a partitioned table does not remove +-- all rows if partitions preserve their data. +begin +-- +STMT: TransactionStmt +== 104 +create temp table temp_parted_oncommit_test (a int) + partition by list (a) on commit delete rows +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DDL +STMT: CreateStmt +== 105 +create temp table temp_parted_oncommit_test1 + partition of temp_parted_oncommit_test + for values in (1) on commit preserve rows +-- +TABLE: name="temp_parted_oncommit_test1" schema="" table="temp_parted_oncommit_test1" ctx=DDL +STMT: CreateStmt +== 106 +create temp table temp_parted_oncommit_test2 + partition of temp_parted_oncommit_test + for values in (2) on commit drop +-- +TABLE: name="temp_parted_oncommit_test2" schema="" table="temp_parted_oncommit_test2" ctx=DDL +STMT: CreateStmt +== 107 +insert into temp_parted_oncommit_test values (1), (2) +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +commit +-- +STMT: TransactionStmt +== 109 +-- Data from the remaining partition is still here as its rows are +-- preserved. +select * from temp_parted_oncommit_test +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=Select +STMT: SelectStmt +== 110 +-- two relations remain in this case. +select relname from pg_class where relname ~ '^temp_parted_oncommit_test' + order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 111 +drop table temp_parted_oncommit_test +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DDL +STMT: DropStmt +== 112 +-- Check dependencies between ON COMMIT actions with inheritance trees. +-- Using ON COMMIT DROP on a parent removes the whole set. +begin +-- +STMT: TransactionStmt +== 113 +create temp table temp_inh_oncommit_test (a int) on commit drop +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=DDL +STMT: CreateStmt +== 114 +create temp table temp_inh_oncommit_test1 () + inherits(temp_inh_oncommit_test) on commit delete rows +-- +TABLE: name="temp_inh_oncommit_test1" schema="" table="temp_inh_oncommit_test1" ctx=DDL +STMT: CreateStmt +== 115 +insert into temp_inh_oncommit_test1 values (1) +-- +TABLE: name="temp_inh_oncommit_test1" schema="" table="temp_inh_oncommit_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 116 +commit +-- +STMT: TransactionStmt +== 117 +-- no relations remain in this case +select relname from pg_class where relname ~ '^temp_inh_oncommit_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 118 +-- Data on the parent is removed, and the child goes away. +begin +-- +STMT: TransactionStmt +== 119 +create temp table temp_inh_oncommit_test (a int) on commit delete rows +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=DDL +STMT: CreateStmt +== 120 +create temp table temp_inh_oncommit_test1 () + inherits(temp_inh_oncommit_test) on commit drop +-- +TABLE: name="temp_inh_oncommit_test1" schema="" table="temp_inh_oncommit_test1" ctx=DDL +STMT: CreateStmt +== 121 +insert into temp_inh_oncommit_test1 values (1) +-- +TABLE: name="temp_inh_oncommit_test1" schema="" table="temp_inh_oncommit_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 122 +insert into temp_inh_oncommit_test values (1) +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 123 +commit +-- +STMT: TransactionStmt +== 124 +select * from temp_inh_oncommit_test +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=Select +STMT: SelectStmt +== 125 +-- one relation remains +select relname from pg_class where relname ~ '^temp_inh_oncommit_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 126 +drop table temp_inh_oncommit_test +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=DDL +STMT: DropStmt +== 127 +-- Tests with two-phase commit +-- Transactions creating objects in a temporary namespace cannot be used +-- with two-phase commit. + +-- These cases generate errors about temporary namespace. +-- Function creation +begin +-- +STMT: TransactionStmt +== 128 +create function pg_temp.twophase_func() returns void as + $$ select '2pc_func'::text $$ language sql +-- +FUNCTION: name="pg_temp.twophase_func" function="twophase_func" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +== 129 +prepare transaction 'twophase_func' +-- +STMT: TransactionStmt +== 130 +-- Function drop +create function pg_temp.twophase_func() returns void as + $$ select '2pc_func'::text $$ language sql +-- +FUNCTION: name="pg_temp.twophase_func" function="twophase_func" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +== 131 +begin +-- +STMT: TransactionStmt +== 132 +drop function pg_temp.twophase_func() +-- +FUNCTION: name="pg_temp.twophase_func" function="twophase_func" schema="pg_temp" ctx=DDL +STMT: DropStmt +== 133 +prepare transaction 'twophase_func' +-- +STMT: TransactionStmt +== 134 +-- Operator creation +begin +-- +STMT: TransactionStmt +== 135 +create operator pg_temp.@@ (leftarg = int4, rightarg = int4, procedure = int4mi) +-- +STMT: DefineStmt +== 136 +prepare transaction 'twophase_operator' +-- +STMT: TransactionStmt +== 137 +-- These generate errors about temporary tables. +begin +-- +STMT: TransactionStmt +== 138 +create type pg_temp.twophase_type as (a int) +-- +STMT: CompositeTypeStmt +== 139 +prepare transaction 'twophase_type' +-- +STMT: TransactionStmt +== 140 +begin +-- +STMT: TransactionStmt +== 141 +create view pg_temp.twophase_view as select 1 +-- +TABLE: name="pg_temp.twophase_view" schema="pg_temp" table="twophase_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 142 +prepare transaction 'twophase_view' +-- +STMT: TransactionStmt +== 143 +begin +-- +STMT: TransactionStmt +== 144 +create sequence pg_temp.twophase_seq +-- +STMT: CreateSeqStmt +== 145 +prepare transaction 'twophase_sequence' +-- +STMT: TransactionStmt +== 146 +-- Temporary tables cannot be used with two-phase commit. +create temp table twophase_tab (a int) +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=DDL +STMT: CreateStmt +== 147 +begin +-- +STMT: TransactionStmt +== 148 +select a from twophase_tab +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=Select +STMT: SelectStmt +== 149 +prepare transaction 'twophase_tab' +-- +STMT: TransactionStmt +== 150 +begin +-- +STMT: TransactionStmt +== 151 +insert into twophase_tab values (1) +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 152 +prepare transaction 'twophase_tab' +-- +STMT: TransactionStmt +== 153 +begin +-- +STMT: TransactionStmt +== 154 +lock twophase_tab in access exclusive mode +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=DDL +STMT: LockStmt +== 155 +prepare transaction 'twophase_tab' +-- +STMT: TransactionStmt +== 156 +begin +-- +STMT: TransactionStmt +== 157 +drop table twophase_tab +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=DDL +STMT: DropStmt +== 158 +prepare transaction 'twophase_tab' +-- +STMT: TransactionStmt +== 159 +-- Corner case: current_schema may create a temporary schema if namespace +-- creation is pending, so check after that. First reset the connection +-- to remove the temporary namespace. +SET search_path TO 'pg_temp' +-- +STMT: VariableSetStmt +== 160 +BEGIN +-- +STMT: TransactionStmt +== 161 +SELECT current_schema() ~ 'pg_temp' AS is_temp_schema +-- +FUNCTION: name="current_schema" function="current_schema" schema="" ctx=Call +STMT: SelectStmt +== 162 +PREPARE TRANSACTION 'twophase_search' +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/test_setup.metadata.json b/parser/testdata/summary/postgres_regress/test_setup.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/test_setup.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/test_setup.test b/parser/testdata/summary/postgres_regress/test_setup.test new file mode 100644 index 0000000..15cf1fe --- /dev/null +++ b/parser/testdata/summary/postgres_regress/test_setup.test @@ -0,0 +1,540 @@ +== 001 +|-- +-- TEST_SETUP --- prepare environment expected by regression test scripts +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +|-- +-- synchronous_commit=off delays when hint bits may be set. Some plans change +-- depending on the number of all-visible pages, which in turn can be +-- influenced by the delayed hint bits. Force synchronous_commit=on to avoid +-- that source of variability. +|-- +SET synchronous_commit = on +-- +STMT: VariableSetStmt +== 002 +|-- +-- Postgres formerly made the public schema read/write by default, +-- and most of the core regression tests still expect that. +|-- +GRANT ALL ON SCHEMA public TO public +-- +STMT: GrantStmt +== 003 +-- Create a tablespace we can use in tests. +SET allow_in_place_tablespaces = true +-- +STMT: VariableSetStmt +== 004 +CREATE TABLESPACE regress_tblspace LOCATION '' +-- +STMT: CreateTableSpaceStmt +== 005 +|-- +-- These tables have traditionally been referenced by many tests, +-- so create and populate them. Insert only non-error values here. +-- (Some subsequent tests try to insert erroneous values. That's okay +-- because the table won't actually change. Do not change the contents +-- of these tables in later tests, as it may affect other tests.) +|-- + +CREATE TABLE CHAR_TBL(f1 char(4)) +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DDL +STMT: CreateStmt +== 006 +INSERT INTO CHAR_TBL (f1) VALUES + ('a'), + ('ab'), + ('abcd'), + ('abcd ') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +VACUUM CHAR_TBL +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DDL +STMT: VacuumStmt +== 008 +CREATE TABLE FLOAT8_TBL(f1 float8) +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DDL +STMT: CreateStmt +== 009 +INSERT INTO FLOAT8_TBL(f1) VALUES + ('0.0'), + ('-34.84'), + ('-1004.30'), + ('-1.2345678901234e+200'), + ('-1.2345678901234e-200') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +VACUUM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DDL +STMT: VacuumStmt +== 011 +CREATE TABLE INT2_TBL(f1 int2) +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DDL +STMT: CreateStmt +== 012 +INSERT INTO INT2_TBL(f1) VALUES + ('0 '), + (' 1234 '), + (' -1234'), + ('32767'), -- largest and smallest values + ('-32767') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +VACUUM INT2_TBL +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DDL +STMT: VacuumStmt +== 014 +CREATE TABLE INT4_TBL(f1 int4) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DDL +STMT: CreateStmt +== 015 +INSERT INTO INT4_TBL(f1) VALUES + (' 0 '), + ('123456 '), + (' -123456'), + ('2147483647'), -- largest and smallest values + ('-2147483647') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +VACUUM INT4_TBL +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DDL +STMT: VacuumStmt +== 017 +CREATE TABLE INT8_TBL(q1 int8, q2 int8) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DDL +STMT: CreateStmt +== 018 +INSERT INTO INT8_TBL VALUES + (' 123 ',' 456'), + ('123 ','4567890123456789'), + ('4567890123456789','123'), + (+4567890123456789,'4567890123456789'), + ('+4567890123456789','-4567890123456789') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +VACUUM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DDL +STMT: VacuumStmt +== 020 +CREATE TABLE POINT_TBL(f1 point) +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DDL +STMT: CreateStmt +== 021 +INSERT INTO POINT_TBL(f1) VALUES + ('(0.0,0.0)'), + ('(-10.0,0.0)'), + ('(-3.0,4.0)'), + ('(5.1, 34.5)'), + ('(-5.0,-12.0)'), + ('(1e-300,-1e-300)'), -- To underflow + ('(1e+300,Inf)'), -- To overflow + ('(Inf,1e+300)'), -- Transposed + (' ( Nan , NaN ) '), + ('10.0,10.0') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +-- We intentionally don't vacuum point_tbl here; geometry depends on that + +CREATE TABLE TEXT_TBL (f1 text) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=DDL +STMT: CreateStmt +== 023 +INSERT INTO TEXT_TBL VALUES + ('doh!'), + ('hi de ho neighbor') +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +VACUUM TEXT_TBL +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=DDL +STMT: VacuumStmt +== 025 +CREATE TABLE VARCHAR_TBL(f1 varchar(4)) +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DDL +STMT: CreateStmt +== 026 +INSERT INTO VARCHAR_TBL (f1) VALUES + ('a'), + ('ab'), + ('abcd'), + ('abcd ') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +VACUUM VARCHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DDL +STMT: VacuumStmt +== 028 +CREATE TABLE onek ( + unique1 int4, + unique2 int4, + two int4, + four int4, + ten int4, + twenty int4, + hundred int4, + thousand int4, + twothousand int4, + fivethous int4, + tenthous int4, + odd int4, + even int4, + stringu1 name, + stringu2 name, + string4 name +) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: CreateStmt +== 029 +COPY onek FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 030 +VACUUM ANALYZE onek +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: VacuumStmt +== 031 +CREATE TABLE onek2 AS SELECT * FROM onek +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 032 +VACUUM ANALYZE onek2 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: VacuumStmt +== 033 +CREATE TABLE tenk1 ( + unique1 int4, + unique2 int4, + two int4, + four int4, + ten int4, + twenty int4, + hundred int4, + thousand int4, + twothousand int4, + fivethous int4, + tenthous int4, + odd int4, + even int4, + stringu1 name, + stringu2 name, + string4 name +) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: CreateStmt +== 034 +COPY tenk1 FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 17 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 035 +VACUUM ANALYZE tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: VacuumStmt +== 036 +CREATE TABLE tenk2 AS SELECT * FROM tenk1 +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 037 +VACUUM ANALYZE tenk2 +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: VacuumStmt +== 038 +CREATE TABLE person ( + name text, + age int4, + location point +) +-- +TABLE: name="person" schema="" table="person" ctx=DDL +STMT: CreateStmt +== 039 +COPY person FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 18 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 040 +VACUUM ANALYZE person +-- +TABLE: name="person" schema="" table="person" ctx=DDL +STMT: VacuumStmt +== 041 +CREATE TABLE emp ( + salary int4, + manager name +) INHERITS (person) +-- +TABLE: name="emp" schema="" table="emp" ctx=DDL +STMT: CreateStmt +== 042 +COPY emp FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 043 +VACUUM ANALYZE emp +-- +TABLE: name="emp" schema="" table="emp" ctx=DDL +STMT: VacuumStmt +== 044 +CREATE TABLE student ( + gpa float8 +) INHERITS (person) +-- +TABLE: name="student" schema="" table="student" ctx=DDL +STMT: CreateStmt +== 045 +COPY student FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 046 +VACUUM ANALYZE student +-- +TABLE: name="student" schema="" table="student" ctx=DDL +STMT: VacuumStmt +== 047 +CREATE TABLE stud_emp ( + percent int4 +) INHERITS (emp, student) +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: CreateStmt +== 048 +COPY stud_emp FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 049 +VACUUM ANALYZE stud_emp +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: VacuumStmt +== 050 +CREATE TABLE road ( + name text, + thepath path +) +-- +TABLE: name="road" schema="" table="road" ctx=DDL +STMT: CreateStmt +== 051 +COPY road FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 052 +VACUUM ANALYZE road +-- +TABLE: name="road" schema="" table="road" ctx=DDL +STMT: VacuumStmt +== 053 +CREATE TABLE ihighway () INHERITS (road) +-- +TABLE: name="ihighway" schema="" table="ihighway" ctx=DDL +STMT: CreateStmt +== 054 +INSERT INTO ihighway + SELECT * + FROM ONLY road + WHERE name ~ 'I- .*' +-- +TABLE: name="ihighway" schema="" table="ihighway" ctx=DML +TABLE: name="road" schema="" table="road" ctx=Select +FILTER: schema="" table="" column="name" +STMT: InsertStmt +STMT: SelectStmt +== 055 +VACUUM ANALYZE ihighway +-- +TABLE: name="ihighway" schema="" table="ihighway" ctx=DDL +STMT: VacuumStmt +== 056 +CREATE TABLE shighway ( + surface text +) INHERITS (road) +-- +TABLE: name="shighway" schema="" table="shighway" ctx=DDL +STMT: CreateStmt +== 057 +INSERT INTO shighway + SELECT *, 'asphalt' + FROM ONLY road + WHERE name ~ 'State Hwy.*' +-- +TABLE: name="shighway" schema="" table="shighway" ctx=DML +TABLE: name="road" schema="" table="road" ctx=Select +FILTER: schema="" table="" column="name" +STMT: InsertStmt +STMT: SelectStmt +== 058 +VACUUM ANALYZE shighway +-- +TABLE: name="shighway" schema="" table="shighway" ctx=DDL +STMT: VacuumStmt +== 059 +|-- +-- We must have some enum type in the database for opr_sanity and type_sanity. +|-- + +create type stoplight as enum ('red', 'yellow', 'green') +-- +STMT: CreateEnumStmt +== 060 +|-- +-- Also create some non-built-in range types. +|-- + +create type float8range as range (subtype = float8, subtype_diff = float8mi) +-- +STMT: CreateRangeStmt +== 061 +create type textrange as range (subtype = text, collation = "C") +-- +STMT: CreateRangeStmt +== 062 +|-- +-- Create some C functions that will be used by various tests. +|-- + +CREATE FUNCTION binary_coercible(oid, oid) + RETURNS bool + AS :'regresslib', 'binary_coercible' + LANGUAGE C STRICT STABLE PARALLEL SAFE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 138 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 063 +CREATE FUNCTION ttdummy () + RETURNS trigger + AS :'regresslib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 55 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 064 +-- Use hand-rolled hash functions and operator classes to get predictable +-- result on different machines. The hash function for int4 simply returns +-- the sum of the values passed to it and the one for text returns the length +-- of the non-empty string value passed to it or 0. + +create function part_hashint4_noop(value int4, seed int8) + returns int8 as $$ + select value + seed; + $$ language sql strict immutable parallel safe +-- +FUNCTION: name="part_hashint4_noop" function="part_hashint4_noop" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 065 +create operator class part_test_int4_ops for type int4 using hash as + operator 1 =, + function 2 part_hashint4_noop(int4, int8) +-- +STMT: CreateOpClassStmt +== 066 +create function part_hashtext_length(value text, seed int8) + returns int8 as $$ + select length(coalesce(value, ''))::int8 + $$ language sql strict immutable parallel safe +-- +FUNCTION: name="part_hashtext_length" function="part_hashtext_length" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 067 +create operator class part_test_text_ops for type text using hash as + operator 1 =, + function 2 part_hashtext_length(text, int8) +-- +STMT: CreateOpClassStmt +== 068 +|-- +-- These functions are used in tests that used to use md5(), which we now +-- mostly avoid so that the tests will pass in FIPS mode. +|-- + +create function fipshash(bytea) + returns text + strict immutable parallel safe leakproof + return substr(encode(sha256($1), 'hex'), 1, 32) +-- +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 069 +create function fipshash(text) + returns text + strict immutable parallel safe leakproof + return substr(encode(sha256($1::bytea), 'hex'), 1, 32) +-- +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=DDL +STMT: CreateFunctionStmt diff --git a/parser/testdata/summary/postgres_regress/text.metadata.json b/parser/testdata/summary/postgres_regress/text.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/text.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/text.test b/parser/testdata/summary/postgres_regress/text.test new file mode 100644 index 0000000..e896162 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/text.test @@ -0,0 +1,401 @@ +== 001 +|-- +-- TEXT +|-- + +SELECT text 'this is a text string' = text 'this is a text string' AS true +-- +STMT: SelectStmt +== 002 +SELECT text 'this is a text string' = text 'this is a text strin' AS false +-- +STMT: SelectStmt +== 003 +-- text_tbl was already created and filled in test_setup.sql. +SELECT * FROM TEXT_TBL +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +STMT: SelectStmt +== 004 +-- As of 8.3 we have removed most implicit casts to text, so that for example +-- this no longer works: + +select length(42) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 005 +-- But as a special exception for usability's sake, we still allow implicit +-- casting to text in concatenations, so long as the other input is text or +-- an unknown literal. So these work: + +select 'four: '::text || 2+2 +-- +STMT: SelectStmt +== 006 +select 'four: ' || 2+2 +-- +STMT: SelectStmt +== 007 +-- but not this: + +select 3 || 4.0 +-- +STMT: SelectStmt +== 008 +/* + * various string functions + */ +select concat('one') +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +== 009 +select concat(1,2,3,'hello',true, false, to_date('20100309','YYYYMMDD')) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 010 +select concat_ws('#','one') +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +== 011 +select concat_ws('#',1,2,3,'hello',true, false, to_date('20100309','YYYYMMDD')) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +== 012 +select concat_ws(',',10,20,null,30) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +== 013 +select concat_ws('',10,20,null,30) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +== 014 +select concat_ws(NULL,10,20,null,30) is null +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +== 015 +select reverse('abcde') +-- +FUNCTION: name="reverse" function="reverse" schema="" ctx=Call +STMT: SelectStmt +== 016 +select i, left('ahoj', i), right('ahoj', i) from generate_series(-5, 5) t(i) order by i +-- +FUNCTION: name="left" function="left" schema="" ctx=Call +FUNCTION: name="right" function="right" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 017 +select quote_literal('') +-- +FUNCTION: name="quote_literal" function="quote_literal" schema="" ctx=Call +STMT: SelectStmt +== 018 +select quote_literal('abc''') +-- +FUNCTION: name="quote_literal" function="quote_literal" schema="" ctx=Call +STMT: SelectStmt +== 019 +select quote_literal(e'\\') +-- +FUNCTION: name="quote_literal" function="quote_literal" schema="" ctx=Call +STMT: SelectStmt +== 020 +-- check variadic labeled argument +select concat(variadic array[1,2,3]) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +== 021 +select concat_ws(',', variadic array[1,2,3]) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +== 022 +select concat_ws(',', variadic NULL::int[]) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +== 023 +select concat(variadic NULL::int[]) is NULL +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +== 024 +select concat(variadic '{}'::int[]) = '' +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +== 025 +--should fail +select concat_ws(',', variadic 10) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +== 026 +/* + * format + */ +select format(NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 027 +select format('Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 028 +select format('Hello %s', 'World') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 029 +select format('Hello %%') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 030 +select format('Hello %%%%') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- should fail +select format('Hello %s %s', 'World') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 032 +select format('Hello %s') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 033 +select format('Hello %x', 20) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 034 +-- check literal and sql identifiers +select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 035 +select format('%s%s%s','Hello', NULL,'World') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 036 +select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', 10, NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 037 +select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', NULL, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 038 +-- should fail, sql identifier cannot be NULL +select format('INSERT INTO %I VALUES(%L,%L)', NULL, 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 039 +-- check positional placeholders +select format('%1$s %3$s', 1, 2, 3) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 040 +select format('%1$s %12$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- should fail +select format('%1$s %4$s', 1, 2, 3) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 042 +select format('%1$s %13$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 043 +select format('%0$s', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 044 +select format('%*0$s', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 045 +select format('%1$', 1) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 046 +select format('%1$1', 1) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- check mix of positional and ordered placeholders +select format('Hello %s %1$s %s', 'World', 'Hello again') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 048 +select format('Hello %s %s, %2$s %2$s', 'World', 'Hello again') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 049 +-- check variadic labeled arguments +select format('%s, %s', variadic array['Hello','World']) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 050 +select format('%s, %s', variadic array[1, 2]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 051 +select format('%s, %s', variadic array[true, false]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 052 +select format('%s, %s', variadic array[true, false]::text[]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 053 +-- check variadic with positional placeholders +select format('%2$s, %1$s', variadic array['first', 'second']) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 054 +select format('%2$s, %1$s', variadic array[1, 2]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 055 +-- variadic argument can be array type NULL, but should not be referenced +select format('Hello', variadic NULL::int[]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- variadic argument allows simulating more than FUNC_MAX_ARGS parameters +select format(string_agg('%s',','), variadic array_agg(i)) +from generate_series(1,200) g(i) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 057 +-- check field widths and left, right alignment +select format('>>%10s<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 058 +select format('>>%10s<<', NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 059 +select format('>>%10s<<', '') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 060 +select format('>>%-10s<<', '') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 061 +select format('>>%-10s<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 062 +select format('>>%-10s<<', NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 063 +select format('>>%1$10s<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 064 +select format('>>%1$-10I<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 065 +select format('>>%2$*1$L<<', 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 066 +select format('>>%2$*1$L<<', 10, NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 067 +select format('>>%2$*1$L<<', -10, NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 068 +select format('>>%*s<<', 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 069 +select format('>>%*1$s<<', 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 070 +select format('>>%-s<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 071 +select format('>>%10L<<', NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 072 +select format('>>%2$*1$L<<', NULL, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +== 073 +select format('>>%2$*1$L<<', 0, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/tid.metadata.json b/parser/testdata/summary/postgres_regress/tid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tid.test b/parser/testdata/summary/postgres_regress/tid.test new file mode 100644 index 0000000..113959f --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tid.test @@ -0,0 +1,239 @@ +== 001 +-- basic tests for the TID data type + +SELECT + '(0,0)'::tid as tid00, + '(0,1)'::tid as tid01, + '(-1,0)'::tid as tidm10, + '(4294967295,65535)'::tid as tidmax +-- +STMT: SelectStmt +== 002 +SELECT '(4294967296,1)'::tid +-- +STMT: SelectStmt +== 003 +-- error +SELECT '(1,65536)'::tid +-- +STMT: SelectStmt +== 004 +-- error + +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('(0)', 'tid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT * FROM pg_input_error_info('(0)', 'tid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT pg_input_is_valid('(0,-1)', 'tid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT * FROM pg_input_error_info('(0,-1)', 'tid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- tests for functions related to TID handling + +CREATE TABLE tid_tab (a int) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: CreateStmt +== 009 +-- min() and max() for TIDs +INSERT INTO tid_tab VALUES (1), (2) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +SELECT min(ctid) FROM tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT max(ctid) FROM tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 012 +TRUNCATE tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: TruncateStmt +== 013 +-- Tests for currtid2() with various relation kinds + +-- Materialized view +CREATE MATERIALIZED VIEW tid_matview AS SELECT a FROM tid_tab +-- +TABLE: name="tid_matview" schema="" table="tid_matview" ctx=DDL +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 014 +SELECT currtid2('tid_matview'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 015 +-- fails +INSERT INTO tid_tab VALUES (1) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +REFRESH MATERIALIZED VIEW tid_matview +-- +TABLE: name="tid_matview" schema="" table="tid_matview" ctx=DDL +STMT: RefreshMatViewStmt +== 017 +SELECT currtid2('tid_matview'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- ok +DROP MATERIALIZED VIEW tid_matview +-- +STMT: DropStmt +== 019 +TRUNCATE tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: TruncateStmt +== 020 +-- Sequence +CREATE SEQUENCE tid_seq +-- +STMT: CreateSeqStmt +== 021 +SELECT currtid2('tid_seq'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- ok +DROP SEQUENCE tid_seq +-- +STMT: DropStmt +== 023 +-- Index, fails with incorrect relation type +CREATE INDEX tid_ind ON tid_tab(a) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: IndexStmt +== 024 +SELECT currtid2('tid_ind'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 025 +-- fails +DROP INDEX tid_ind +-- +STMT: DropStmt +== 026 +-- Partitioned table, no storage +CREATE TABLE tid_part (a int) PARTITION BY RANGE (a) +-- +TABLE: name="tid_part" schema="" table="tid_part" ctx=DDL +STMT: CreateStmt +== 027 +SELECT currtid2('tid_part'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 028 +-- fails +DROP TABLE tid_part +-- +TABLE: name="tid_part" schema="" table="tid_part" ctx=DDL +STMT: DropStmt +== 029 +-- Views +-- ctid not defined in the view +CREATE VIEW tid_view_no_ctid AS SELECT a FROM tid_tab +-- +TABLE: name="tid_view_no_ctid" schema="" table="tid_view_no_ctid" ctx=DDL +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 030 +SELECT currtid2('tid_view_no_ctid'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- fails +DROP VIEW tid_view_no_ctid +-- +STMT: DropStmt +== 032 +-- ctid fetched directly from the source table. +CREATE VIEW tid_view_with_ctid AS SELECT ctid, a FROM tid_tab +-- +TABLE: name="tid_view_with_ctid" schema="" table="tid_view_with_ctid" ctx=DDL +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 033 +SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 034 +-- fails +INSERT INTO tid_tab VALUES (1) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- ok +DROP VIEW tid_view_with_ctid +-- +STMT: DropStmt +== 037 +TRUNCATE tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: TruncateStmt +== 038 +-- ctid attribute with incorrect data type +CREATE VIEW tid_view_fake_ctid AS SELECT 1 AS ctid, 2 AS a +-- +TABLE: name="tid_view_fake_ctid" schema="" table="tid_view_fake_ctid" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 039 +SELECT currtid2('tid_view_fake_ctid'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +== 040 +-- fails +DROP VIEW tid_view_fake_ctid +-- +STMT: DropStmt +== 041 +DROP TABLE tid_tab CASCADE +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/tidrangescan.metadata.json b/parser/testdata/summary/postgres_regress/tidrangescan.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tidrangescan.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tidrangescan.test b/parser/testdata/summary/postgres_regress/tidrangescan.test new file mode 100644 index 0000000..f419912 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tidrangescan.test @@ -0,0 +1,312 @@ +== 001 +-- tests for tidrangescans + +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +== 002 +CREATE TABLE tidrangescan(id integer, data text) +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DDL +STMT: CreateStmt +== 003 +-- empty table +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid < '(1, 0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 004 +SELECT ctid FROM tidrangescan WHERE ctid < '(1, 0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 005 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid > '(9, 0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 006 +SELECT ctid FROM tidrangescan WHERE ctid > '(9, 0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 007 +-- insert enough tuples to fill at least two pages +INSERT INTO tidrangescan SELECT i,repeat('x', 100) FROM generate_series(1,200) AS s(i) +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 008 +-- remove all tuples after the 10th tuple on each page. Trying to ensure +-- we get the same layout with all CPU architectures and smaller than standard +-- page sizes. +DELETE FROM tidrangescan +WHERE substring(ctid::text FROM ',(\d+)\)')::integer > 10 OR substring(ctid::text FROM '\((\d+),')::integer > 2 +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DML +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: DeleteStmt +== 009 +VACUUM tidrangescan +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DDL +STMT: VacuumStmt +== 010 +-- range scans with upper bound +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 011 +SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 012 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid <= '(1,5)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 013 +SELECT ctid FROM tidrangescan WHERE ctid <= '(1,5)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 014 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 015 +SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 016 +-- range scans with lower bound +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid > '(2,8)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 017 +SELECT ctid FROM tidrangescan WHERE ctid > '(2,8)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 018 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE '(2,8)' < ctid +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 019 +SELECT ctid FROM tidrangescan WHERE '(2,8)' < ctid +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 020 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid >= '(2,8)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 021 +SELECT ctid FROM tidrangescan WHERE ctid >= '(2,8)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 022 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid >= '(100,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 023 +SELECT ctid FROM tidrangescan WHERE ctid >= '(100,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 024 +-- range scans with both bounds +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid > '(1,4)' AND '(1,7)' >= ctid +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 025 +SELECT ctid FROM tidrangescan WHERE ctid > '(1,4)' AND '(1,7)' >= ctid +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 026 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE '(1,7)' >= ctid AND ctid > '(1,4)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 027 +SELECT ctid FROM tidrangescan WHERE '(1,7)' >= ctid AND ctid > '(1,4)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 028 +-- extreme offsets +SELECT ctid FROM tidrangescan WHERE ctid > '(0,65535)' AND ctid < '(1,0)' LIMIT 1 +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 029 +SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' LIMIT 1 +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 030 +SELECT ctid FROM tidrangescan WHERE ctid > '(4294967295,65535)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 031 +SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 032 +-- NULLs in the range cannot return tuples +SELECT ctid FROM tidrangescan WHERE ctid >= (SELECT NULL::tid) +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 033 +-- rescans +EXPLAIN (COSTS OFF) +SELECT t.ctid,t2.c FROM tidrangescan t, +LATERAL (SELECT count(*) c FROM tidrangescan t2 WHERE t2.ctid <= t.ctid) t2 +WHERE t.ctid < '(1,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +ALIAS: "t"="tidrangescan" +ALIAS: "t2"="tidrangescan" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t" column="ctid" +FILTER: schema="" table="t2" column="ctid" +FILTER: schema="" table="t" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 034 +SELECT t.ctid,t2.c FROM tidrangescan t, +LATERAL (SELECT count(*) c FROM tidrangescan t2 WHERE t2.ctid <= t.ctid) t2 +WHERE t.ctid < '(1,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +ALIAS: "t"="tidrangescan" +ALIAS: "t2"="tidrangescan" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t" column="ctid" +FILTER: schema="" table="t2" column="ctid" +FILTER: schema="" table="t" column="ctid" +STMT: SelectStmt +== 035 +-- cursors + +-- Ensure we get a TID Range scan without a Materialize node. +EXPLAIN (COSTS OFF) +DECLARE c SCROLL CURSOR FOR SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)' +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +== 036 +BEGIN +-- +STMT: TransactionStmt +== 037 +DECLARE c SCROLL CURSOR FOR SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)' +-- +STMT: DeclareCursorStmt +== 038 +FETCH NEXT c +-- +STMT: FetchStmt +== 039 +FETCH NEXT c +-- +STMT: FetchStmt +== 040 +FETCH PRIOR c +-- +STMT: FetchStmt +== 041 +FETCH FIRST c +-- +STMT: FetchStmt +== 042 +FETCH LAST c +-- +STMT: FetchStmt +== 043 +COMMIT +-- +STMT: TransactionStmt +== 044 +DROP TABLE tidrangescan +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DDL +STMT: DropStmt +== 045 +RESET enable_seqscan +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/tidscan.metadata.json b/parser/testdata/summary/postgres_regress/tidscan.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tidscan.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tidscan.test b/parser/testdata/summary/postgres_regress/tidscan.test new file mode 100644 index 0000000..5ef5ba4 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tidscan.test @@ -0,0 +1,340 @@ +== 001 +-- tests for tidscans + +CREATE TABLE tidscan(id integer) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DDL +STMT: CreateStmt +== 002 +-- only insert a few rows, we don't want to spill onto a second table page +INSERT INTO tidscan VALUES (1), (2), (3) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +-- show ctids +SELECT ctid, * FROM tidscan +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +STMT: SelectStmt +== 004 +-- ctid equality - implemented as tidscan +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE ctid = '(0,1)' +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 005 +SELECT ctid, * FROM tidscan WHERE ctid = '(0,1)' +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 006 +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE '(0,1)' = ctid +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 007 +SELECT ctid, * FROM tidscan WHERE '(0,1)' = ctid +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 008 +-- OR'd clauses +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE ctid = '(0,2)' OR '(0,1)' = ctid +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 009 +SELECT ctid, * FROM tidscan WHERE ctid = '(0,2)' OR '(0,1)' = ctid +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 010 +-- ctid = ScalarArrayOp - implemented as tidscan +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 011 +SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 012 +-- ctid != ScalarArrayOp - can't be implemented as tidscan +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE ctid != ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +== 013 +SELECT ctid, * FROM tidscan WHERE ctid != ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 014 +-- tid equality extracted from sub-AND clauses +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan +WHERE (id = 3 AND ctid IN ('(0,2)', '(0,3)')) OR (ctid = '(0,1)' AND id = 1) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="id" +STMT: ExplainStmt +STMT: SelectStmt +== 015 +SELECT ctid, * FROM tidscan +WHERE (id = 3 AND ctid IN ('(0,2)', '(0,3)')) OR (ctid = '(0,1)' AND id = 1) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 016 +-- nestloop-with-inner-tidscan joins on tid +SET enable_hashjoin TO off +-- +STMT: VariableSetStmt +== 017 +-- otherwise hash join might win +EXPLAIN (COSTS OFF) +SELECT t1.ctid, t1.*, t2.ctid, t2.* +FROM tidscan t1 JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1 +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +ALIAS: "t1"="tidscan" +ALIAS: "t2"="tidscan" +FILTER: schema="" table="t1" column="id" +STMT: ExplainStmt +STMT: SelectStmt +== 018 +SELECT t1.ctid, t1.*, t2.ctid, t2.* +FROM tidscan t1 JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1 +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +ALIAS: "t1"="tidscan" +ALIAS: "t2"="tidscan" +FILTER: schema="" table="t1" column="id" +STMT: SelectStmt +== 019 +EXPLAIN (COSTS OFF) +SELECT t1.ctid, t1.*, t2.ctid, t2.* +FROM tidscan t1 LEFT JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1 +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +ALIAS: "t1"="tidscan" +ALIAS: "t2"="tidscan" +FILTER: schema="" table="t1" column="id" +STMT: ExplainStmt +STMT: SelectStmt +== 020 +SELECT t1.ctid, t1.*, t2.ctid, t2.* +FROM tidscan t1 LEFT JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1 +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +ALIAS: "t1"="tidscan" +ALIAS: "t2"="tidscan" +FILTER: schema="" table="t1" column="id" +STMT: SelectStmt +== 021 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +== 022 +-- exercise backward scan and rewind +BEGIN +-- +STMT: TransactionStmt +== 023 +DECLARE c CURSOR FOR +SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +STMT: DeclareCursorStmt +== 024 +FETCH ALL FROM c +-- +STMT: FetchStmt +== 025 +FETCH BACKWARD 1 FROM c +-- +STMT: FetchStmt +== 026 +FETCH FIRST FROM c +-- +STMT: FetchStmt +== 027 +ROLLBACK +-- +STMT: TransactionStmt +== 028 +-- tidscan via CURRENT OF +BEGIN +-- +STMT: TransactionStmt +== 029 +DECLARE c CURSOR FOR SELECT ctid, * FROM tidscan +-- +STMT: DeclareCursorStmt +== 030 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 031 +-- skip one row +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 032 +-- perform update +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +UPDATE tidscan SET id = -id WHERE CURRENT OF c RETURNING * +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 033 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 034 +-- perform update +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +UPDATE tidscan SET id = -id WHERE CURRENT OF c RETURNING * +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 035 +SELECT * FROM tidscan +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +STMT: SelectStmt +== 036 +-- position cursor past any rows +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 037 +-- should error out +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +UPDATE tidscan SET id = -id WHERE CURRENT OF c RETURNING * +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 038 +ROLLBACK +-- +STMT: TransactionStmt +== 039 +-- bulk joins on CTID +-- (these plans don't use TID scans, but this still seems like an +-- appropriate place for these tests) +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 040 +SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 041 +SET enable_hashjoin TO off +-- +STMT: VariableSetStmt +== 042 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 043 +SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 044 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +== 045 +-- check predicate lock on CTID +BEGIN ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +== 046 +SELECT * FROM tidscan WHERE ctid = '(0,1)' +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +== 047 +-- locktype should be 'tuple' +SELECT locktype, mode FROM pg_locks WHERE pid = pg_backend_pid() AND mode = 'SIReadLock' +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="pid" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +== 048 +ROLLBACK +-- +STMT: TransactionStmt +== 049 +DROP TABLE tidscan +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/time.metadata.json b/parser/testdata/summary/postgres_regress/time.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/time.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/time.test b/parser/testdata/summary/postgres_regress/time.test new file mode 100644 index 0000000..0cdbc87 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/time.test @@ -0,0 +1,260 @@ +== 001 +|-- +-- TIME +|-- + +CREATE TABLE TIME_TBL (f1 time(2)) +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO TIME_TBL VALUES ('00:00') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO TIME_TBL VALUES ('01:00') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +-- as of 7.4, timezone spec should be accepted and ignored +INSERT INTO TIME_TBL VALUES ('02:03 PST') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO TIME_TBL VALUES ('11:59 EDT') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO TIME_TBL VALUES ('12:00') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO TIME_TBL VALUES ('12:01') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO TIME_TBL VALUES ('23:59') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +-- this should fail (the timezone offset is not known) +INSERT INTO TIME_TBL VALUES ('15:36:39 America/New_York') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +SELECT f1 AS "Time" FROM TIME_TBL +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +STMT: SelectStmt +== 014 +SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07' +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 015 +SELECT f1 AS "Five" FROM TIME_TBL WHERE f1 > '05:06:07' +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 016 +SELECT f1 AS "None" FROM TIME_TBL WHERE f1 < '00:00' +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 017 +SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00' +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 018 +-- Check edge cases +SELECT '23:59:59.999999'::time +-- +STMT: SelectStmt +== 019 +SELECT '23:59:59.9999999'::time +-- +STMT: SelectStmt +== 020 +-- rounds up +SELECT '23:59:60'::time +-- +STMT: SelectStmt +== 021 +-- rounds up +SELECT '24:00:00'::time +-- +STMT: SelectStmt +== 022 +-- allowed +SELECT '24:00:00.01'::time +-- +STMT: SelectStmt +== 023 +-- not allowed +SELECT '23:59:60.01'::time +-- +STMT: SelectStmt +== 024 +-- not allowed +SELECT '24:01:00'::time +-- +STMT: SelectStmt +== 025 +-- not allowed +SELECT '25:00:00'::time +-- +STMT: SelectStmt +== 026 +-- not allowed + +-- Test non-error-throwing API +SELECT pg_input_is_valid('12:00:00', 'time') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT pg_input_is_valid('25:00:00', 'time') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT pg_input_is_valid('15:36:39 America/New_York', 'time') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT * FROM pg_input_error_info('25:00:00', 'time') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT * FROM pg_input_error_info('15:36:39 America/New_York', 'time') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 031 +|-- +-- TIME simple math +|-- +-- We now make a distinction between time and intervals, +-- and adding two times together makes no sense at all. +-- Leave in one query to show that it is rejected, +-- and do the rest of the testing in horology.sql +-- where we do mixed-type arithmetic. - thomas 2000-12-02 + +SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +STMT: SelectStmt +== 032 +|-- +-- test EXTRACT +|-- +SELECT EXTRACT(MICROSECOND FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 033 +SELECT EXTRACT(MILLISECOND FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 034 +SELECT EXTRACT(SECOND FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 035 +SELECT EXTRACT(MINUTE FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 036 +SELECT EXTRACT(HOUR FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 037 +SELECT EXTRACT(DAY FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 038 +-- error +SELECT EXTRACT(FORTNIGHT FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 039 +-- error +SELECT EXTRACT(TIMEZONE FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 040 +-- error +SELECT EXTRACT(EPOCH FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 041 +-- date_part implementation is mostly the same as extract, so only +-- test a few cases for additional coverage. +SELECT date_part('microsecond', TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 042 +SELECT date_part('millisecond', TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT date_part('second', TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT date_part('epoch', TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/timestamp.metadata.json b/parser/testdata/summary/postgres_regress/timestamp.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/timestamp.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/timestamp.test b/parser/testdata/summary/postgres_regress/timestamp.test new file mode 100644 index 0000000..f3349aa --- /dev/null +++ b/parser/testdata/summary/postgres_regress/timestamp.test @@ -0,0 +1,1164 @@ +== 001 +|-- +-- TIMESTAMP +|-- + +CREATE TABLE TIMESTAMP_TBL (d1 timestamp(2) without time zone) +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DDL +STMT: CreateStmt +== 002 +-- Test shorthand input values +-- We can't just "select" the results since they aren't constants; test for +-- equality instead. We can do that by running the test inside a transaction +-- block, within which the value of 'now' shouldn't change, and so these +-- related values shouldn't either. + +BEGIN +-- +STMT: TransactionStmt +== 003 +INSERT INTO TIMESTAMP_TBL VALUES ('today') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO TIMESTAMP_TBL VALUES ('yesterday') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +-- time zone should be ignored by this data type +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow EST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'today' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 009 +SELECT count(*) AS Three FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'tomorrow' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 010 +SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'yesterday' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 011 +COMMIT +-- +STMT: TransactionStmt +== 012 +DELETE FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: DeleteStmt +== 013 +-- Verify that 'now' *does* change over a reasonable interval such as 100 msec, +-- and that it doesn't change over the same interval within a transaction block + +INSERT INTO TIMESTAMP_TBL VALUES ('now') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 015 +BEGIN +-- +STMT: TransactionStmt +== 016 +INSERT INTO TIMESTAMP_TBL VALUES ('now') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 018 +INSERT INTO TIMESTAMP_TBL VALUES ('now') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT count(*) AS two FROM TIMESTAMP_TBL WHERE d1 = timestamp(2) without time zone 'now' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 021 +SELECT count(d1) AS three, count(DISTINCT d1) AS two FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 022 +COMMIT +-- +STMT: TransactionStmt +== 023 +TRUNCATE TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DDL +STMT: TruncateStmt +== 024 +-- Special values +INSERT INTO TIMESTAMP_TBL VALUES ('-infinity') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO TIMESTAMP_TBL VALUES ('infinity') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO TIMESTAMP_TBL VALUES ('epoch') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +SELECT timestamp 'infinity' = timestamp '+infinity' AS t +-- +STMT: SelectStmt +== 028 +-- Postgres v6.0 standard output format +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +-- Variations on Postgres v6.1 standard output format +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +-- ISO 8601 format +INSERT INTO TIMESTAMP_TBL VALUES ('1997-01-02') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-01-02 03:04:05') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-08') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-0800') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 -08:00') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 -0800') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 17:32:01 -07:00') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO TIMESTAMP_TBL VALUES ('2001-09-22T18:19:20') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +-- POSIX format (note that the timezone abbrev is just decoration here) +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 08:14:01 GMT+8') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 13:14:02 GMT-1') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 12:14:03 GMT-2') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 03:14:04 PST+8') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 02:14:05 MST+7:00') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +-- Variations for acceptable input formats +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997 -0800') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 5:32PM 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO TIMESTAMP_TBL VALUES ('1997/02/10 17:32:01-0800') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb-10-1997 17:32:01 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +INSERT INTO TIMESTAMP_TBL VALUES ('02-10-1997 17:32:01 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +set datestyle to ymd +-- +STMT: VariableSetStmt +== 056 +INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +reset datestyle +-- +STMT: VariableSetStmt +== 059 +INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 America/New_York') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 061 +-- this fails (even though TZ is a no-op, we still look it up) +INSERT INTO TIMESTAMP_TBL VALUES ('19970710 173201 America/Does_not_exist') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +-- Test non-error-throwing API +SELECT pg_input_is_valid('now', 'timestamp') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT pg_input_is_valid('garbage', 'timestamp') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT pg_input_is_valid('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 065 +SELECT * FROM pg_input_error_info('garbage', 'timestamp') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 066 +SELECT * FROM pg_input_error_info('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 067 +-- Check date conversion and date arithmetic +INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 18:32:01 PDT') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 068 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 069 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 11 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 12 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 13 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 072 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 14 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 073 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 15 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 074 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0097 BC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 076 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0097') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0597') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1097') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 079 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1697') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1797') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1897') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 082 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 083 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 2097') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 084 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 085 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 086 +INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 090 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 091 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 094 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1999') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2000') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 2000') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 099 +-- Currently unsupported syntax and ranges +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +SELECT d1 FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +== 102 +-- Check behavior at the boundaries of the timestamp range +SELECT '4714-11-24 00:00:00 BC'::timestamp +-- +STMT: SelectStmt +== 103 +SELECT '4714-11-23 23:59:59 BC'::timestamp +-- +STMT: SelectStmt +== 104 +-- out of range +SELECT '294276-12-31 23:59:59'::timestamp +-- +STMT: SelectStmt +== 105 +SELECT '294277-01-01 00:00:00'::timestamp +-- +STMT: SelectStmt +== 106 +-- out of range + +-- Demonstrate functions and operators +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 > timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 107 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 < timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 108 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 = timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 109 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 != timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 110 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 <= timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 111 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 >= timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 112 +SELECT d1 - timestamp without time zone '1997-01-02' AS diff + FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 113 +SELECT date_trunc( 'week', timestamp '2004-02-29 15:44:17.71393' ) AS week_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 114 +-- verify date_bin behaves the same as date_trunc for relevant intervals + +-- case 1: AD dates, origin < input +SELECT + str, + interval, + date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2001-01-01') AS equal +FROM ( + VALUES + ('week', '7 d'), + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamp '2020-02-29 15:44:17.71393')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 115 +-- case 2: BC dates, origin < input +SELECT + str, + interval, + date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2000-01-01 BC') AS equal +FROM ( + VALUES + ('week', '7 d'), + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamp '0055-6-10 15:44:17.71393 BC')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 116 +-- case 3: AD dates, origin > input +SELECT + str, + interval, + date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2020-03-02') AS equal +FROM ( + VALUES + ('week', '7 d'), + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamp '2020-02-29 15:44:17.71393')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 117 +-- case 4: BC dates, origin > input +SELECT + str, + interval, + date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '0055-06-17 BC') AS equal +FROM ( + VALUES + ('week', '7 d'), + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamp '0055-6-10 15:44:17.71393 BC')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 118 +-- bin timestamps into arbitrary intervals +SELECT + interval, + ts, + origin, + date_bin(interval::interval, ts, origin) +FROM ( + VALUES + ('15 days'), + ('2 hours'), + ('1 hour 30 minutes'), + ('15 minutes'), + ('10 seconds'), + ('100 milliseconds'), + ('250 microseconds') +) intervals (interval), +(VALUES (timestamp '2020-02-11 15:44:17.71393')) ts (ts), +(VALUES (timestamp '2001-01-01')) origin (origin) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 119 +-- shift bins using the origin parameter: +SELECT date_bin('5 min'::interval, timestamp '2020-02-01 01:01:01', timestamp '2020-02-01 00:02:30') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 120 +-- test roundoff edge case when source < origin +SELECT date_bin('30 minutes'::interval, timestamp '2024-02-01 15:00:00', timestamp '2024-02-01 17:00:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 121 +-- disallow intervals with months or years +SELECT date_bin('5 months'::interval, timestamp '2020-02-01 01:01:01', timestamp '2001-01-01') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 122 +SELECT date_bin('5 years'::interval, timestamp '2020-02-01 01:01:01', timestamp '2001-01-01') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 123 +-- disallow zero intervals +SELECT date_bin('0 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp '1970-01-01 00:00:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 124 +-- disallow negative intervals +SELECT date_bin('-2 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp '1970-01-01 00:00:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 125 +-- test overflow cases +select date_bin('15 minutes'::interval, timestamp '294276-12-30', timestamp '4000-12-20 BC') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 126 +select date_bin('200000000 days'::interval, '2024-02-01'::timestamp, '2024-01-01'::timestamp) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 127 +select date_bin('365000 days'::interval, '4400-01-01 BC'::timestamp, '4000-01-01 BC'::timestamp) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 128 +-- Test casting within a BETWEEN qualifier +SELECT d1 - timestamp without time zone '1997-01-02' AS diff + FROM TIMESTAMP_TBL + WHERE d1 BETWEEN timestamp without time zone '1902-01-01' + AND timestamp without time zone '2038-01-01' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 129 +-- DATE_PART (timestamp_part) +SELECT d1 as "timestamp", + date_part( 'year', d1) AS year, date_part( 'month', d1) AS month, + date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour, + date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 130 +SELECT d1 as "timestamp", + date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec, + date_part( 'usec', d1) AS usec + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 131 +SELECT d1 as "timestamp", + date_part( 'isoyear', d1) AS isoyear, date_part( 'week', d1) AS week, + date_part( 'isodow', d1) AS isodow, date_part( 'dow', d1) AS dow, + date_part( 'doy', d1) AS doy + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 132 +SELECT d1 as "timestamp", + date_part( 'decade', d1) AS decade, + date_part( 'century', d1) AS century, + date_part( 'millennium', d1) AS millennium, + round(date_part( 'julian', d1)) AS julian, + date_part( 'epoch', d1) AS epoch + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 133 +-- extract implementation is mostly the same as date_part, so only +-- test a few cases for additional coverage. +SELECT d1 as "timestamp", + extract(microseconds from d1) AS microseconds, + extract(milliseconds from d1) AS milliseconds, + extract(seconds from d1) AS seconds, + round(extract(julian from d1)) AS julian, + extract(epoch from d1) AS epoch + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 134 +-- value near upper bound uses special case in code +SELECT date_part('epoch', '294270-01-01 00:00:00'::timestamp) +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 135 +SELECT extract(epoch from '294270-01-01 00:00:00'::timestamp) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 136 +-- another internal overflow test case +SELECT extract(epoch from '5000-01-01 00:00:00'::timestamp) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 137 +-- test edge-case overflow in timestamp subtraction +SELECT timestamp '294276-12-31 23:59:59' - timestamp '1999-12-23 19:59:04.224193' AS ok +-- +STMT: SelectStmt +== 138 +SELECT timestamp '294276-12-31 23:59:59' - timestamp '1999-12-23 19:59:04.224192' AS overflows +-- +STMT: SelectStmt +== 139 +-- TO_CHAR() +SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 140 +SELECT to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 141 +SELECT to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 142 +SELECT to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 143 +SELECT to_char(d1, 'HH HH12 HH24 MI SS SSSS') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 144 +SELECT to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 145 +SELECT to_char(d1, 'HH24--text--MI--text--SS') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 146 +SELECT to_char(d1, 'YYYYTH YYYYth Jth') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 147 +SELECT to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 148 +SELECT to_char(d1, 'IYYY IYY IY I IW IDDD ID') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 149 +SELECT to_char(d1, 'FMIYYY FMIYY FMIY FMI FMIW FMIDDD FMID') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 150 +SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US') + FROM (VALUES + ('2018-11-02 12:34:56'::timestamp), + ('2018-11-02 12:34:56.78'), + ('2018-11-02 12:34:56.78901'), + ('2018-11-02 12:34:56.78901234') + ) d(d) +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 151 +-- Roman months, with upper and lower case. +SELECT i, + to_char(i * interval '1mon', 'rm'), + to_char(i * interval '1mon', 'RM') + FROM generate_series(-13, 13) i +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 152 +-- timestamp numeric fields constructor +SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887) +-- +FUNCTION: name="make_timestamp" function="make_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 153 +SELECT make_timestamp(-44, 3, 15, 12, 30, 15) +-- +FUNCTION: name="make_timestamp" function="make_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 154 +-- should fail +select make_timestamp(0, 7, 15, 12, 30, 15) +-- +FUNCTION: name="make_timestamp" function="make_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 155 +-- generate_series for timestamp +select * from generate_series('2020-01-01 00:00'::timestamp, + '2020-01-02 03:00'::timestamp, + '1 hour'::interval) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 156 +-- the LIMIT should allow this to terminate in a reasonable amount of time +-- (but that unfortunately doesn't work yet for SELECT * FROM ...) +select generate_series('2022-01-01 00:00'::timestamp, + 'infinity'::timestamp, + '1 month'::interval) limit 10 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 157 +-- errors +select * from generate_series('2020-01-01 00:00'::timestamp, + '2020-01-02 03:00'::timestamp, + '0 hour'::interval) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 158 +select generate_series(timestamp '1995-08-06 12:12:12', timestamp '1996-08-06 12:12:12', interval 'infinity') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 159 +select generate_series(timestamp '1995-08-06 12:12:12', timestamp '1996-08-06 12:12:12', interval '-infinity') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 160 +-- test arithmetic with infinite timestamps +select timestamp 'infinity' - timestamp 'infinity' +-- +STMT: SelectStmt +== 161 +select timestamp 'infinity' - timestamp '-infinity' +-- +STMT: SelectStmt +== 162 +select timestamp '-infinity' - timestamp 'infinity' +-- +STMT: SelectStmt +== 163 +select timestamp '-infinity' - timestamp '-infinity' +-- +STMT: SelectStmt +== 164 +select timestamp 'infinity' - timestamp '1995-08-06 12:12:12' +-- +STMT: SelectStmt +== 165 +select timestamp '-infinity' - timestamp '1995-08-06 12:12:12' +-- +STMT: SelectStmt +== 166 +-- test age() with infinite timestamps +select age(timestamp 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 167 +select age(timestamp '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 168 +select age(timestamp 'infinity', timestamp 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 169 +select age(timestamp 'infinity', timestamp '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 170 +select age(timestamp '-infinity', timestamp 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 171 +select age(timestamp '-infinity', timestamp '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/timestamptz.metadata.json b/parser/testdata/summary/postgres_regress/timestamptz.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/timestamptz.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/timestamptz.test b/parser/testdata/summary/postgres_regress/timestamptz.test new file mode 100644 index 0000000..f390370 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/timestamptz.test @@ -0,0 +1,2227 @@ +== 001 +|-- +-- TIMESTAMPTZ +|-- + +CREATE TABLE TIMESTAMPTZ_TBL (d1 timestamp(2) with time zone) +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DDL +STMT: CreateStmt +== 002 +-- Test shorthand input values +-- We can't just "select" the results since they aren't constants; test for +-- equality instead. We can do that by running the test inside a transaction +-- block, within which the value of 'now' shouldn't change, and so these +-- related values shouldn't either. + +BEGIN +-- +STMT: TransactionStmt +== 003 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('today') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('yesterday') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow EST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow zulu') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'today' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 009 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 010 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'yesterday' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 011 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow EST' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 012 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow zulu' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 013 +COMMIT +-- +STMT: TransactionStmt +== 014 +DELETE FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: DeleteStmt +== 015 +-- Verify that 'now' *does* change over a reasonable interval such as 100 msec, +-- and that it doesn't change over the same interval within a transaction block + +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 017 +BEGIN +-- +STMT: TransactionStmt +== 018 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 020 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT count(*) AS two FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp(2) with time zone 'now' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 023 +SELECT count(d1) AS three, count(DISTINCT d1) AS two FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 024 +COMMIT +-- +STMT: TransactionStmt +== 025 +TRUNCATE TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DDL +STMT: TruncateStmt +== 026 +-- Special values +INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +SELECT timestamptz 'infinity' = timestamptz '+infinity' AS t +-- +STMT: SelectStmt +== 030 +-- Postgres v6.0 standard output format +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +-- Variations on Postgres v6.1 standard output format +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +-- ISO 8601 format +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02 03:04:05') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-08') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-0800') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 040 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 -08:00') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 -0800') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 17:32:01 -07:00') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2001-09-22T18:19:20') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +-- POSIX format (note that the timezone abbrev is just decoration here) +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 08:14:01 GMT+8') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 13:14:02 GMT-1') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 12:14:03 GMT-2') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 03:14:04 PST+8') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 02:14:05 MST+7:00') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +-- Variations for acceptable input formats +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997 -0800') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 5:32PM 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997/02/10 17:32:01-0800') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb-10-1997 17:32:01 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('02-10-1997 17:32:01 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 056 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +set datestyle to ymd +-- +STMT: VariableSetStmt +== 058 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('97FEB10 5:32:01PM UTC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('97/02/10 17:32:01 UTC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +reset datestyle +-- +STMT: VariableSetStmt +== 061 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997.041 17:32:01 UTC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +-- timestamps at different timezones +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 America/New_York') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 063 +SELECT '19970210 173201' AT TIME ZONE 'America/New_York' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 064 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/New_York') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 065 +SELECT '19970710 173201' AT TIME ZONE 'America/New_York' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 066 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/Does_not_exist') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 067 +SELECT '19970710 173201' AT TIME ZONE 'America/Does_not_exist' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 068 +-- Daylight saving time for timestamps beyond 32-bit time_t range. +SELECT '20500710 173201 Europe/Helsinki'::timestamptz +-- +STMT: SelectStmt +== 069 +-- DST +SELECT '20500110 173201 Europe/Helsinki'::timestamptz +-- +STMT: SelectStmt +== 070 +-- non-DST + +SELECT '205000-07-10 17:32:01 Europe/Helsinki'::timestamptz +-- +STMT: SelectStmt +== 071 +-- DST +SELECT '205000-01-10 17:32:01 Europe/Helsinki'::timestamptz +-- +STMT: SelectStmt +== 072 +-- non-DST + +-- Test non-error-throwing API +SELECT pg_input_is_valid('now', 'timestamptz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 073 +SELECT pg_input_is_valid('garbage', 'timestamptz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT pg_input_is_valid('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 075 +SELECT * FROM pg_input_error_info('garbage', 'timestamptz') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 076 +SELECT * FROM pg_input_error_info('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 077 +-- Check date conversion and date arithmetic +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 18:32:01 PDT') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 078 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 079 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 11 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 12 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 081 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 13 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 082 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 14 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 083 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 15 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 084 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 085 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097 BC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 086 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 087 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0597') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 088 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1097') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 089 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1697') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 090 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1797') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 091 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1897') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 093 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 2097') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 094 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 098 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 099 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 102 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 105 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1999') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 106 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2000') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 2000') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 108 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 109 +-- Currently unsupported syntax and ranges +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 110 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +-- Alternative field order that we've historically supported (sort of) +-- with regular and POSIXy timezone specs +SELECT 'Wed Jul 11 10:51:14 America/New_York 2001'::timestamptz +-- +STMT: SelectStmt +== 112 +SELECT 'Wed Jul 11 10:51:14 GMT-4 2001'::timestamptz +-- +STMT: SelectStmt +== 113 +SELECT 'Wed Jul 11 10:51:14 GMT+4 2001'::timestamptz +-- +STMT: SelectStmt +== 114 +SELECT 'Wed Jul 11 10:51:14 PST-03:00 2001'::timestamptz +-- +STMT: SelectStmt +== 115 +SELECT 'Wed Jul 11 10:51:14 PST+03:00 2001'::timestamptz +-- +STMT: SelectStmt +== 116 +SELECT d1 FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +STMT: SelectStmt +== 117 +-- Check behavior at the boundaries of the timestamp range +SELECT '4714-11-24 00:00:00+00 BC'::timestamptz +-- +STMT: SelectStmt +== 118 +SELECT '4714-11-23 16:00:00-08 BC'::timestamptz +-- +STMT: SelectStmt +== 119 +SELECT 'Sun Nov 23 16:00:00 4714 PST BC'::timestamptz +-- +STMT: SelectStmt +== 120 +SELECT '4714-11-23 23:59:59+00 BC'::timestamptz +-- +STMT: SelectStmt +== 121 +-- out of range +SELECT '294276-12-31 23:59:59+00'::timestamptz +-- +STMT: SelectStmt +== 122 +SELECT '294276-12-31 15:59:59-08'::timestamptz +-- +STMT: SelectStmt +== 123 +SELECT '294277-01-01 00:00:00+00'::timestamptz +-- +STMT: SelectStmt +== 124 +-- out of range +SELECT '294277-12-31 16:00:00-08'::timestamptz +-- +STMT: SelectStmt +== 125 +-- out of range + +-- Demonstrate functions and operators +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 > timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 126 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 < timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 127 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 = timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 128 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 != timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 129 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 <= timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 130 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 >= timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 131 +SELECT d1 - timestamp with time zone '1997-01-02' AS diff + FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 132 +SELECT date_trunc( 'week', timestamp with time zone '2004-02-29 15:44:17.71393' ) AS week_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 133 +SELECT date_trunc('day', timestamp with time zone '2001-02-16 20:38:40+00', 'Australia/Sydney') as sydney_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 134 +-- zone name +SELECT date_trunc('day', timestamp with time zone '2001-02-16 20:38:40+00', 'GMT') as gmt_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 135 +-- fixed-offset abbreviation +SELECT date_trunc('day', timestamp with time zone '2001-02-16 20:38:40+00', 'VET') as vet_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +== 136 +-- variable-offset abbreviation + +-- verify date_bin behaves the same as date_trunc for relevant intervals +SELECT + str, + interval, + date_trunc(str, ts, 'Australia/Sydney') = date_bin(interval::interval, ts, timestamp with time zone '2001-01-01+11') AS equal +FROM ( + VALUES + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamptz '2020-02-29 15:44:17.71393+00')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 137 +-- bin timestamps into arbitrary intervals +SELECT + interval, + ts, + origin, + date_bin(interval::interval, ts, origin) +FROM ( + VALUES + ('15 days'), + ('2 hours'), + ('1 hour 30 minutes'), + ('15 minutes'), + ('10 seconds'), + ('100 milliseconds'), + ('250 microseconds') +) intervals (interval), +(VALUES (timestamptz '2020-02-11 15:44:17.71393')) ts (ts), +(VALUES (timestamptz '2001-01-01')) origin (origin) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 138 +-- shift bins using the origin parameter: +SELECT date_bin('5 min'::interval, timestamptz '2020-02-01 01:01:01+00', timestamptz '2020-02-01 00:02:30+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 139 +-- test roundoff edge case when source < origin +SELECT date_bin('30 minutes'::interval, timestamptz '2024-02-01 15:00:00', timestamptz '2024-02-01 17:00:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 140 +-- disallow intervals with months or years +SELECT date_bin('5 months'::interval, timestamp with time zone '2020-02-01 01:01:01+00', timestamp with time zone '2001-01-01+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 141 +SELECT date_bin('5 years'::interval, timestamp with time zone '2020-02-01 01:01:01+00', timestamp with time zone '2001-01-01+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 142 +-- disallow zero intervals +SELECT date_bin('0 days'::interval, timestamp with time zone '1970-01-01 01:00:00+00' , timestamp with time zone '1970-01-01 00:00:00+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 143 +-- disallow negative intervals +SELECT date_bin('-2 days'::interval, timestamp with time zone '1970-01-01 01:00:00+00' , timestamp with time zone '1970-01-01 00:00:00+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 144 +-- test overflow cases +select date_bin('15 minutes'::interval, timestamptz '294276-12-30', timestamptz '4000-12-20 BC') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 145 +select date_bin('200000000 days'::interval, '2024-02-01'::timestamptz, '2024-01-01'::timestamptz) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 146 +select date_bin('365000 days'::interval, '4400-01-01 BC'::timestamptz, '4000-01-01 BC'::timestamptz) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +== 147 +-- Test casting within a BETWEEN qualifier +SELECT d1 - timestamp with time zone '1997-01-02' AS diff + FROM TIMESTAMPTZ_TBL + WHERE d1 BETWEEN timestamp with time zone '1902-01-01' AND timestamp with time zone '2038-01-01' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +== 148 +-- DATE_PART (timestamptz_part) +SELECT d1 as timestamptz, + date_part( 'year', d1) AS year, date_part( 'month', d1) AS month, + date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour, + date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 149 +SELECT d1 as timestamptz, + date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec, + date_part( 'usec', d1) AS usec + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 150 +SELECT d1 as timestamptz, + date_part( 'isoyear', d1) AS isoyear, date_part( 'week', d1) AS week, + date_part( 'isodow', d1) AS isodow, date_part( 'dow', d1) AS dow, + date_part( 'doy', d1) AS doy + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 151 +SELECT d1 as timestamptz, + date_part( 'decade', d1) AS decade, + date_part( 'century', d1) AS century, + date_part( 'millennium', d1) AS millennium, + round(date_part( 'julian', d1)) AS julian, + date_part( 'epoch', d1) AS epoch + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 152 +SELECT d1 as timestamptz, + date_part( 'timezone', d1) AS timezone, + date_part( 'timezone_hour', d1) AS timezone_hour, + date_part( 'timezone_minute', d1) AS timezone_minute + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 153 +-- extract implementation is mostly the same as date_part, so only +-- test a few cases for additional coverage. +SELECT d1 as "timestamp", + extract(microseconds from d1) AS microseconds, + extract(milliseconds from d1) AS milliseconds, + extract(seconds from d1) AS seconds, + round(extract(julian from d1)) AS julian, + extract(epoch from d1) AS epoch + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 154 +-- value near upper bound uses special case in code +SELECT date_part('epoch', '294270-01-01 00:00:00+00'::timestamptz) +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 155 +SELECT extract(epoch from '294270-01-01 00:00:00+00'::timestamptz) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 156 +-- another internal overflow test case +SELECT extract(epoch from '5000-01-01 00:00:00+00'::timestamptz) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 157 +-- test edge-case overflow in timestamp subtraction +SELECT timestamptz '294276-12-31 23:59:59 UTC' - timestamptz '1999-12-23 19:59:04.224193 UTC' AS ok +-- +STMT: SelectStmt +== 158 +SELECT timestamptz '294276-12-31 23:59:59 UTC' - timestamptz '1999-12-23 19:59:04.224192 UTC' AS overflows +-- +STMT: SelectStmt +== 159 +-- TO_CHAR() +SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 160 +SELECT to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 161 +SELECT to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 162 +SELECT to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 163 +SELECT to_char(d1, 'HH HH12 HH24 MI SS SSSS') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 164 +SELECT to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 165 +SELECT to_char(d1, 'HH24--text--MI--text--SS') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 166 +SELECT to_char(d1, 'YYYYTH YYYYth Jth') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 167 +SELECT to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 168 +SELECT to_char(d1, 'IYYY IYY IY I IW IDDD ID') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 169 +SELECT to_char(d1, 'FMIYYY FMIYY FMIY FMI FMIW FMIDDD FMID') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 170 +SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US') + FROM (VALUES + ('2018-11-02 12:34:56'::timestamptz), + ('2018-11-02 12:34:56.78'), + ('2018-11-02 12:34:56.78901'), + ('2018-11-02 12:34:56.78901234') + ) d(d) +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +== 171 +-- Check OF, TZH, TZM with various zone offsets, particularly fractional hours +SET timezone = '00:00' +-- +STMT: VariableSetStmt +== 172 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 173 +SET timezone = '+02:00' +-- +STMT: VariableSetStmt +== 174 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 175 +SET timezone = '-13:00' +-- +STMT: VariableSetStmt +== 176 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 177 +SET timezone = '-00:30' +-- +STMT: VariableSetStmt +== 178 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 179 +SET timezone = '00:30' +-- +STMT: VariableSetStmt +== 180 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 181 +SET timezone = '-04:30' +-- +STMT: VariableSetStmt +== 182 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 183 +SET timezone = '04:30' +-- +STMT: VariableSetStmt +== 184 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 185 +SET timezone = '-04:15' +-- +STMT: VariableSetStmt +== 186 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 187 +SET timezone = '04:15' +-- +STMT: VariableSetStmt +== 188 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 189 +RESET timezone +-- +STMT: VariableSetStmt +== 190 +-- Check of, tzh, tzm with various zone offsets. +SET timezone = '00:00' +-- +STMT: VariableSetStmt +== 191 +SELECT to_char(now(), 'of') as "Of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 192 +SET timezone = '+02:00' +-- +STMT: VariableSetStmt +== 193 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 194 +SET timezone = '-13:00' +-- +STMT: VariableSetStmt +== 195 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 196 +SET timezone = '-00:30' +-- +STMT: VariableSetStmt +== 197 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 198 +SET timezone = '00:30' +-- +STMT: VariableSetStmt +== 199 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 200 +SET timezone = '-04:30' +-- +STMT: VariableSetStmt +== 201 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 202 +SET timezone = '04:30' +-- +STMT: VariableSetStmt +== 203 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 204 +SET timezone = '-04:15' +-- +STMT: VariableSetStmt +== 205 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 206 +SET timezone = '04:15' +-- +STMT: VariableSetStmt +== 207 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 208 +RESET timezone +-- +STMT: VariableSetStmt +== 209 +CREATE TABLE TIMESTAMPTZ_TST (a int , b timestamptz) +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DDL +STMT: CreateStmt +== 210 +-- Test year field value with len > 4 +INSERT INTO TIMESTAMPTZ_TST VALUES(1, 'Sat Mar 12 23:58:48 1000 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 211 +INSERT INTO TIMESTAMPTZ_TST VALUES(2, 'Sat Mar 12 23:58:48 10000 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 212 +INSERT INTO TIMESTAMPTZ_TST VALUES(3, 'Sat Mar 12 23:58:48 100000 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 213 +INSERT INTO TIMESTAMPTZ_TST VALUES(3, '10000 Mar 12 23:58:48 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 214 +INSERT INTO TIMESTAMPTZ_TST VALUES(4, '100000312 23:58:48 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 215 +INSERT INTO TIMESTAMPTZ_TST VALUES(4, '1000000312 23:58:48 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +--Verify data +SELECT * FROM TIMESTAMPTZ_TST ORDER BY a +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=Select +STMT: SelectStmt +== 217 +--Cleanup +DROP TABLE TIMESTAMPTZ_TST +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DDL +STMT: DropStmt +== 218 +-- test timestamptz constructors +set TimeZone to 'America/New_York' +-- +STMT: VariableSetStmt +== 219 +-- numeric timezone +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33) +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 220 +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '+2') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 221 +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '-2') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 222 +WITH tzs (tz) AS (VALUES + ('+1'), ('+1:'), ('+1:0'), ('+100'), ('+1:00'), ('+01:00'), + ('+10'), ('+1000'), ('+10:'), ('+10:0'), ('+10:00'), ('+10:00:'), + ('+10:00:1'), ('+10:00:01'), + ('+10:00:10')) + SELECT make_timestamptz(2010, 2, 27, 3, 45, 00, tz), tz FROM tzs +-- +CTE: "tzs" +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 223 +-- these should fail +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '2') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 224 +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '+16') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 225 +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '-16') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 226 +-- should be true +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '+2') = '1973-07-15 08:15:55.33+02'::timestamptz +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 227 +-- full timezone names +SELECT make_timestamptz(2014, 12, 10, 0, 0, 0, 'Europe/Prague') = timestamptz '2014-12-10 00:00:00 Europe/Prague' +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 228 +SELECT make_timestamptz(2014, 12, 10, 0, 0, 0, 'Europe/Prague') AT TIME ZONE 'UTC' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 229 +SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Asia/Singapore') AT TIME ZONE 'UTC' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 230 +SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Pacific/Honolulu') AT TIME ZONE 'UTC' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 231 +SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Europe/Paris') AT TIME ZONE 'UTC' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 232 +SELECT make_timestamptz(1910, 12, 24, 0, 0, 0, 'Nehwon/Lankhmar') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 233 +-- abbreviations +SELECT make_timestamptz(2008, 12, 10, 10, 10, 10, 'EST') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 234 +SELECT make_timestamptz(2008, 12, 10, 10, 10, 10, 'EDT') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 235 +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, 'FOO8BAR') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 236 +-- POSIX +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, 'PST8PDT,M3.2.0,M11.1.0') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 237 +RESET TimeZone +-- +STMT: VariableSetStmt +== 238 +-- generate_series for timestamptz +select * from generate_series('2020-01-01 00:00'::timestamptz, + '2020-01-02 03:00'::timestamptz, + '1 hour'::interval) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 239 +-- the LIMIT should allow this to terminate in a reasonable amount of time +-- (but that unfortunately doesn't work yet for SELECT * FROM ...) +select generate_series('2022-01-01 00:00'::timestamptz, + 'infinity'::timestamptz, + '1 month'::interval) limit 10 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 240 +-- errors +select * from generate_series('2020-01-01 00:00'::timestamptz, + '2020-01-02 03:00'::timestamptz, + '0 hour'::interval) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 241 +select generate_series(timestamptz '1995-08-06 12:12:12', timestamptz '1996-08-06 12:12:12', interval 'infinity') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 242 +select generate_series(timestamptz '1995-08-06 12:12:12', timestamptz '1996-08-06 12:12:12', interval '-infinity') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 243 +-- Interval crossing time shift for Europe/Warsaw timezone (with DST) +SET TimeZone to 'UTC' +-- +STMT: VariableSetStmt +== 244 +SELECT date_add('2022-10-30 00:00:00+01'::timestamptz, + '1 day'::interval) +-- +FUNCTION: name="date_add" function="date_add" schema="" ctx=Call +STMT: SelectStmt +== 245 +SELECT date_add('2021-10-31 00:00:00+02'::timestamptz, + '1 day'::interval, + 'Europe/Warsaw') +-- +FUNCTION: name="date_add" function="date_add" schema="" ctx=Call +STMT: SelectStmt +== 246 +SELECT date_subtract('2022-10-30 00:00:00+01'::timestamptz, + '1 day'::interval) +-- +FUNCTION: name="date_subtract" function="date_subtract" schema="" ctx=Call +STMT: SelectStmt +== 247 +SELECT date_subtract('2021-10-31 00:00:00+02'::timestamptz, + '1 day'::interval, + 'Europe/Warsaw') +-- +FUNCTION: name="date_subtract" function="date_subtract" schema="" ctx=Call +STMT: SelectStmt +== 248 +SELECT * FROM generate_series('2021-12-31 23:00:00+00'::timestamptz, + '2020-12-31 23:00:00+00'::timestamptz, + '-1 month'::interval, + 'Europe/Warsaw') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 249 +RESET TimeZone +-- +STMT: VariableSetStmt +== 250 +|-- +-- Test behavior with a dynamic (time-varying) timezone abbreviation. +-- These tests rely on the knowledge that MSK (Europe/Moscow standard time) +-- moved forwards in Mar 2011 and backwards again in Oct 2014. +|-- + +SET TimeZone to 'UTC' +-- +STMT: VariableSetStmt +== 251 +SELECT '2011-03-27 00:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 252 +SELECT '2011-03-27 01:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 253 +SELECT '2011-03-27 01:59:59 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 254 +SELECT '2011-03-27 02:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 255 +SELECT '2011-03-27 02:00:01 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 256 +SELECT '2011-03-27 02:59:59 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 257 +SELECT '2011-03-27 03:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 258 +SELECT '2011-03-27 03:00:01 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 259 +SELECT '2011-03-27 04:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 260 +SELECT '2011-03-27 00:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +== 261 +SELECT '2011-03-27 01:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +== 262 +SELECT '2011-03-27 01:59:59 MSK'::timestamptz +-- +STMT: SelectStmt +== 263 +SELECT '2011-03-27 02:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +== 264 +SELECT '2011-03-27 02:00:01 MSK'::timestamptz +-- +STMT: SelectStmt +== 265 +SELECT '2011-03-27 02:59:59 MSK'::timestamptz +-- +STMT: SelectStmt +== 266 +SELECT '2011-03-27 03:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +== 267 +SELECT '2011-03-27 03:00:01 MSK'::timestamptz +-- +STMT: SelectStmt +== 268 +SELECT '2011-03-27 04:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +== 269 +SELECT '2014-10-26 00:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 270 +SELECT '2014-10-26 00:59:59 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 271 +SELECT '2014-10-26 01:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 272 +SELECT '2014-10-26 01:00:01 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 273 +SELECT '2014-10-26 02:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +== 274 +SELECT '2014-10-26 00:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +== 275 +SELECT '2014-10-26 00:59:59 MSK'::timestamptz +-- +STMT: SelectStmt +== 276 +SELECT '2014-10-26 01:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +== 277 +SELECT '2014-10-26 01:00:01 MSK'::timestamptz +-- +STMT: SelectStmt +== 278 +SELECT '2014-10-26 02:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +== 279 +SELECT '2011-03-27 00:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 280 +SELECT '2011-03-27 01:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 281 +SELECT '2011-03-27 01:59:59'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 282 +SELECT '2011-03-27 02:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 283 +SELECT '2011-03-27 02:00:01'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 284 +SELECT '2011-03-27 02:59:59'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 285 +SELECT '2011-03-27 03:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 286 +SELECT '2011-03-27 03:00:01'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 287 +SELECT '2011-03-27 04:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 288 +SELECT '2011-03-27 00:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 289 +SELECT '2011-03-27 01:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 290 +SELECT '2011-03-27 01:59:59'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 291 +SELECT '2011-03-27 02:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 292 +SELECT '2011-03-27 02:00:01'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 293 +SELECT '2011-03-27 02:59:59'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 294 +SELECT '2011-03-27 03:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 295 +SELECT '2011-03-27 03:00:01'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 296 +SELECT '2011-03-27 04:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 297 +SELECT '2014-10-26 00:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 298 +SELECT '2014-10-26 00:59:59'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 299 +SELECT '2014-10-26 01:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 300 +SELECT '2014-10-26 01:00:01'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 301 +SELECT '2014-10-26 02:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 302 +SELECT '2014-10-26 00:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 303 +SELECT '2014-10-26 00:59:59'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 304 +SELECT '2014-10-26 01:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 305 +SELECT '2014-10-26 01:00:01'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 306 +SELECT '2014-10-26 02:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 307 +SELECT make_timestamptz(2014, 10, 26, 0, 0, 0, 'MSK') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 308 +SELECT make_timestamptz(2014, 10, 26, 1, 0, 0, 'MSK') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +== 309 +SELECT to_timestamp( 0) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 310 +-- 1970-01-01 00:00:00+00 +SELECT to_timestamp( 946684800) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 311 +-- 2000-01-01 00:00:00+00 +SELECT to_timestamp(1262349296.7890123) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 312 +-- 2010-01-01 12:34:56.789012+00 +-- edge cases +SELECT to_timestamp(-210866803200) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 313 +-- 4714-11-24 00:00:00+00 BC +-- upper limit varies between integer and float timestamps, so hard to test +-- nonfinite values +SELECT to_timestamp(' Infinity'::float) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 314 +SELECT to_timestamp('-Infinity'::float) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 315 +SELECT to_timestamp('NaN'::float) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 316 +SET TimeZone to 'Europe/Moscow' +-- +STMT: VariableSetStmt +== 317 +SELECT '2011-03-26 21:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +== 318 +SELECT '2011-03-26 22:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +== 319 +SELECT '2011-03-26 22:59:59 UTC'::timestamptz +-- +STMT: SelectStmt +== 320 +SELECT '2011-03-26 23:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +== 321 +SELECT '2011-03-26 23:00:01 UTC'::timestamptz +-- +STMT: SelectStmt +== 322 +SELECT '2011-03-26 23:59:59 UTC'::timestamptz +-- +STMT: SelectStmt +== 323 +SELECT '2011-03-27 00:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +== 324 +SELECT '2014-10-25 21:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +== 325 +SELECT '2014-10-25 21:59:59 UTC'::timestamptz +-- +STMT: SelectStmt +== 326 +SELECT '2014-10-25 22:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +== 327 +SELECT '2014-10-25 22:00:01 UTC'::timestamptz +-- +STMT: SelectStmt +== 328 +SELECT '2014-10-25 23:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +== 329 +RESET TimeZone +-- +STMT: VariableSetStmt +== 330 +SELECT '2011-03-26 21:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 331 +SELECT '2011-03-26 22:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 332 +SELECT '2011-03-26 22:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 333 +SELECT '2011-03-26 23:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 334 +SELECT '2011-03-26 23:00:01 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 335 +SELECT '2011-03-26 23:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 336 +SELECT '2011-03-27 00:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 337 +SELECT '2014-10-25 21:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 338 +SELECT '2014-10-25 21:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 339 +SELECT '2014-10-25 22:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 340 +SELECT '2014-10-25 22:00:01 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 341 +SELECT '2014-10-25 23:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 342 +SELECT '2011-03-26 21:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 343 +SELECT '2011-03-26 22:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 344 +SELECT '2011-03-26 22:59:59 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 345 +SELECT '2011-03-26 23:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 346 +SELECT '2011-03-26 23:00:01 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 347 +SELECT '2011-03-26 23:59:59 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 348 +SELECT '2011-03-27 00:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 349 +SELECT '2014-10-25 21:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 350 +SELECT '2014-10-25 21:59:59 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 351 +SELECT '2014-10-25 22:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 352 +SELECT '2014-10-25 22:00:01 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 353 +SELECT '2014-10-25 23:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 354 +|-- +-- Test LOCAL time zone +|-- +BEGIN +-- +STMT: TransactionStmt +== 355 +SET LOCAL TIME ZONE 'Europe/Paris' +-- +STMT: VariableSetStmt +== 356 +VALUES (CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 357 +VALUES (TIMESTAMP '1978-07-07 19:38' AT LOCAL) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 358 +SET LOCAL TIME ZONE 'Australia/Sydney' +-- +STMT: VariableSetStmt +== 359 +VALUES (CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 360 +VALUES (TIMESTAMP '1978-07-07 19:38' AT LOCAL) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 361 +SET LOCAL TimeZone TO 'UTC' +-- +STMT: VariableSetStmt +== 362 +CREATE VIEW timestamp_local_view AS + SELECT CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL AS ttz_at_local, + timezone(CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE)) AS ttz_func, + TIMESTAMP '1978-07-07 19:38' AT LOCAL AS t_at_local, + timezone(TIMESTAMP '1978-07-07 19:38') AS t_func +-- +TABLE: name="timestamp_local_view" schema="" table="timestamp_local_view" ctx=DDL +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 363 +SELECT pg_get_viewdef('timestamp_local_view', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 364 +TABLE timestamp_local_view +-- +TABLE: name="timestamp_local_view" schema="" table="timestamp_local_view" ctx=Select +STMT: SelectStmt +== 365 +DROP VIEW timestamp_local_view +-- +STMT: DropStmt +== 366 +COMMIT +-- +STMT: TransactionStmt +== 367 +|-- +-- Test that AT TIME ZONE isn't misoptimized when using an index (bug #14504) +|-- +create temp table tmptz (f1 timestamptz primary key) +-- +TABLE: name="tmptz" schema="" table="tmptz" ctx=DDL +STMT: CreateStmt +== 368 +insert into tmptz values ('2017-01-18 00:00+00') +-- +TABLE: name="tmptz" schema="" table="tmptz" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 369 +explain (costs off) +select * from tmptz where f1 at time zone 'utc' = '2017-01-18 00:00' +-- +TABLE: name="tmptz" schema="" table="tmptz" ctx=Select +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +== 370 +select * from tmptz where f1 at time zone 'utc' = '2017-01-18 00:00' +-- +TABLE: name="tmptz" schema="" table="tmptz" ctx=Select +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 371 +-- test arithmetic with infinite timestamps +SELECT timestamptz 'infinity' - timestamptz 'infinity' +-- +STMT: SelectStmt +== 372 +SELECT timestamptz 'infinity' - timestamptz '-infinity' +-- +STMT: SelectStmt +== 373 +SELECT timestamptz '-infinity' - timestamptz 'infinity' +-- +STMT: SelectStmt +== 374 +SELECT timestamptz '-infinity' - timestamptz '-infinity' +-- +STMT: SelectStmt +== 375 +SELECT timestamptz 'infinity' - timestamptz '1995-08-06 12:12:12' +-- +STMT: SelectStmt +== 376 +SELECT timestamptz '-infinity' - timestamptz '1995-08-06 12:12:12' +-- +STMT: SelectStmt +== 377 +-- test age() with infinite timestamps +SELECT age(timestamptz 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 378 +SELECT age(timestamptz '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 379 +SELECT age(timestamptz 'infinity', timestamptz 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 380 +SELECT age(timestamptz 'infinity', timestamptz '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 381 +SELECT age(timestamptz '-infinity', timestamptz 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +== 382 +SELECT age(timestamptz '-infinity', timestamptz '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/timetz.metadata.json b/parser/testdata/summary/postgres_regress/timetz.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/timetz.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/timetz.test b/parser/testdata/summary/postgres_regress/timetz.test new file mode 100644 index 0000000..1586370 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/timetz.test @@ -0,0 +1,349 @@ +== 001 +|-- +-- TIMETZ +|-- + +CREATE TABLE TIMETZ_TBL (f1 time(2) with time zone) +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO TIMETZ_TBL VALUES ('00:01 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO TIMETZ_TBL VALUES ('01:00 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO TIMETZ_TBL VALUES ('02:03 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO TIMETZ_TBL VALUES ('07:07 PST') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO TIMETZ_TBL VALUES ('08:08 EDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO TIMETZ_TBL VALUES ('11:59 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO TIMETZ_TBL VALUES ('12:00 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO TIMETZ_TBL VALUES ('12:01 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO TIMETZ_TBL VALUES ('23:59 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO TIMETZ_TBL VALUES ('11:59:59.99 PM PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO TIMETZ_TBL VALUES ('2003-03-07 15:36:39 America/New_York') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO TIMETZ_TBL VALUES ('2003-07-07 15:36:39 America/New_York') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +-- this should fail (the timezone offset is not known) +INSERT INTO TIMETZ_TBL VALUES ('15:36:39 America/New_York') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +-- this should fail (timezone not specified without a date) +INSERT INTO TIMETZ_TBL VALUES ('15:36:39 m2') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +-- this should fail (dynamic timezone abbreviation without a date) +INSERT INTO TIMETZ_TBL VALUES ('15:36:39 MSK m2') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +SELECT f1 AS "Time TZ" FROM TIMETZ_TBL +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +STMT: SelectStmt +== 018 +SELECT f1 AS "Three" FROM TIMETZ_TBL WHERE f1 < '05:06:07-07' +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 019 +SELECT f1 AS "Seven" FROM TIMETZ_TBL WHERE f1 > '05:06:07-07' +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 020 +SELECT f1 AS "None" FROM TIMETZ_TBL WHERE f1 < '00:00-07' +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 021 +SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00-07' +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 022 +-- Check edge cases +SELECT '23:59:59.999999 PDT'::timetz +-- +STMT: SelectStmt +== 023 +SELECT '23:59:59.9999999 PDT'::timetz +-- +STMT: SelectStmt +== 024 +-- rounds up +SELECT '23:59:60 PDT'::timetz +-- +STMT: SelectStmt +== 025 +-- rounds up +SELECT '24:00:00 PDT'::timetz +-- +STMT: SelectStmt +== 026 +-- allowed +SELECT '24:00:00.01 PDT'::timetz +-- +STMT: SelectStmt +== 027 +-- not allowed +SELECT '23:59:60.01 PDT'::timetz +-- +STMT: SelectStmt +== 028 +-- not allowed +SELECT '24:01:00 PDT'::timetz +-- +STMT: SelectStmt +== 029 +-- not allowed +SELECT '25:00:00 PDT'::timetz +-- +STMT: SelectStmt +== 030 +-- not allowed + +-- Test non-error-throwing API +SELECT pg_input_is_valid('12:00:00 PDT', 'timetz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT pg_input_is_valid('25:00:00 PDT', 'timetz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT pg_input_is_valid('15:36:39 America/New_York', 'timetz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT * FROM pg_input_error_info('25:00:00 PDT', 'timetz') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT * FROM pg_input_error_info('15:36:39 America/New_York', 'timetz') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 035 +|-- +-- TIME simple math +|-- +-- We now make a distinction between time and intervals, +-- and adding two times together makes no sense at all. +-- Leave in one query to show that it is rejected, +-- and do the rest of the testing in horology.sql +-- where we do mixed-type arithmetic. - thomas 2000-12-02 + +SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +STMT: SelectStmt +== 036 +|-- +-- test EXTRACT +|-- +SELECT EXTRACT(MICROSECOND FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 037 +SELECT EXTRACT(MILLISECOND FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 038 +SELECT EXTRACT(SECOND FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 039 +SELECT EXTRACT(MINUTE FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 040 +SELECT EXTRACT(HOUR FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 041 +SELECT EXTRACT(DAY FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 042 +-- error +SELECT EXTRACT(FORTNIGHT FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 043 +-- error +SELECT EXTRACT(TIMEZONE FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04:30') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 044 +SELECT EXTRACT(TIMEZONE_HOUR FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04:30') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 045 +SELECT EXTRACT(TIMEZONE_MINUTE FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04:30') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 046 +SELECT EXTRACT(EPOCH FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 047 +-- date_part implementation is mostly the same as extract, so only +-- test a few cases for additional coverage. +SELECT date_part('microsecond', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT date_part('millisecond', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 049 +SELECT date_part('second', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 050 +SELECT date_part('epoch', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +== 051 +|-- +-- Test timetz_zone, timetz_izone, AT LOCAL +|-- +BEGIN +-- +STMT: TransactionStmt +== 052 +SET LOCAL TimeZone TO 'UTC' +-- +STMT: VariableSetStmt +== 053 +CREATE VIEW timetz_local_view AS + SELECT f1 AS dat, + timezone(f1) AS dat_func, + f1 AT LOCAL AS dat_at_local, + f1 AT TIME ZONE current_setting('TimeZone') AS dat_at_tz, + f1 AT TIME ZONE INTERVAL '00:00' AS dat_at_int + FROM TIMETZ_TBL + ORDER BY f1 +-- +TABLE: name="timetz_local_view" schema="" table="timetz_local_view" ctx=DDL +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 054 +SELECT pg_get_viewdef('timetz_local_view', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 055 +TABLE timetz_local_view +-- +TABLE: name="timetz_local_view" schema="" table="timetz_local_view" ctx=Select +STMT: SelectStmt +== 056 +SELECT f1 AS dat, + f1 AT TIME ZONE 'UTC+10' AS dat_at_tz, + f1 AT TIME ZONE INTERVAL '-10:00' AS dat_at_int + FROM TIMETZ_TBL + ORDER BY f1 +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 057 +ROLLBACK +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/transactions.metadata.json b/parser/testdata/summary/postgres_regress/transactions.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/transactions.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/transactions.test b/parser/testdata/summary/postgres_regress/transactions.test new file mode 100644 index 0000000..fea5947 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/transactions.test @@ -0,0 +1,2554 @@ +== 001 +|-- +-- TRANSACTIONS +|-- + +BEGIN +-- +STMT: TransactionStmt +== 002 +CREATE TABLE xacttest (a smallint, b real) +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO xacttest VALUES + (56, 7.8), + (100, 99.097), + (0, 0.09561), + (42, 324.78) +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO xacttest (a, b) VALUES (777, 777.777) +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +END +-- +STMT: TransactionStmt +== 006 +-- should retrieve one value-- +SELECT a FROM xacttest WHERE a > 100 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 007 +BEGIN +-- +STMT: TransactionStmt +== 008 +CREATE TABLE disappear (a int4) +-- +TABLE: name="disappear" schema="" table="disappear" ctx=DDL +STMT: CreateStmt +== 009 +DELETE FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +STMT: DeleteStmt +== 010 +-- should be empty +SELECT * FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +== 011 +ABORT +-- +STMT: TransactionStmt +== 012 +-- should not exist +SELECT oid FROM pg_class WHERE relname = 'disappear' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 013 +-- should have members again +SELECT * FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +== 014 +-- Test that transaction characteristics cannot be reset. +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +== 015 +SELECT COUNT(*) FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 016 +RESET transaction_isolation +-- +STMT: VariableSetStmt +== 017 +-- error +END +-- +STMT: TransactionStmt +== 018 +BEGIN TRANSACTION READ ONLY +-- +STMT: TransactionStmt +== 019 +SELECT COUNT(*) FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 020 +RESET transaction_read_only +-- +STMT: VariableSetStmt +== 021 +-- error +END +-- +STMT: TransactionStmt +== 022 +BEGIN TRANSACTION DEFERRABLE +-- +STMT: TransactionStmt +== 023 +SELECT COUNT(*) FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 024 +RESET transaction_deferrable +-- +STMT: VariableSetStmt +== 025 +-- error +END +-- +STMT: TransactionStmt +== 026 +CREATE FUNCTION errfunc() RETURNS int LANGUAGE SQL AS 'SELECT 1' +SET transaction_read_only = on +-- +FUNCTION: name="errfunc" function="errfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 027 +-- error + +-- Read-only tests + +CREATE TABLE writetest (a int) +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DDL +STMT: CreateStmt +== 028 +CREATE TEMPORARY TABLE temptest (a int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +== 029 +BEGIN +-- +STMT: TransactionStmt +== 030 +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE +-- +STMT: VariableSetStmt +== 031 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +== 032 +-- ok +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +== 033 +--fail +COMMIT +-- +STMT: TransactionStmt +== 034 +BEGIN +-- +STMT: TransactionStmt +== 035 +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 036 +-- ok +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +== 037 +-- ok +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 038 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +== 039 +-- ok +SAVEPOINT x +-- +STMT: TransactionStmt +== 040 +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 041 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +== 042 +-- ok +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 043 +-- ok +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +== 044 +--fail +COMMIT +-- +STMT: TransactionStmt +== 045 +BEGIN +-- +STMT: TransactionStmt +== 046 +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +== 047 +-- ok +SAVEPOINT x +-- +STMT: TransactionStmt +== 048 +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +== 049 +-- ok +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 050 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +== 051 +-- ok +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 052 +-- ok +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +== 053 +--fail +COMMIT +-- +STMT: TransactionStmt +== 054 +BEGIN +-- +STMT: TransactionStmt +== 055 +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +== 056 +-- ok +SAVEPOINT x +-- +STMT: TransactionStmt +== 057 +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 058 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +== 059 +-- ok +ROLLBACK TO SAVEPOINT x +-- +STMT: TransactionStmt +== 060 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 061 +-- off +SAVEPOINT y +-- +STMT: TransactionStmt +== 062 +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 063 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +== 064 +-- ok +RELEASE SAVEPOINT y +-- +STMT: TransactionStmt +== 065 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 066 +-- off +COMMIT +-- +STMT: TransactionStmt +== 067 +SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +== 068 +DROP TABLE writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DDL +STMT: DropStmt +== 069 +-- fail +INSERT INTO writetest VALUES (1) +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +-- fail +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +== 071 +-- ok +DELETE FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: DeleteStmt +== 072 +-- ok +UPDATE temptest SET a = 0 FROM writetest WHERE temptest.a = 1 AND writetest.a = temptest.a +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: UpdateStmt +== 073 +-- ok +PREPARE test AS UPDATE writetest SET a = 0 +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DML +STMT: PrepareStmt +STMT: UpdateStmt +== 074 +-- ok +EXECUTE test +-- +STMT: ExecuteStmt +== 075 +-- fail +SELECT * FROM writetest, temptest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +== 076 +-- ok +CREATE TABLE test AS SELECT * FROM writetest +-- +TABLE: name="test" schema="" table="test" ctx=DDL +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +== 077 +-- fail + +START TRANSACTION READ WRITE +-- +STMT: TransactionStmt +== 078 +DROP TABLE writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DDL +STMT: DropStmt +== 079 +-- ok +COMMIT +-- +STMT: TransactionStmt +== 080 +-- Subtransactions, basic tests +-- create & drop tables +SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +== 081 +CREATE TABLE trans_foobar (a int) +-- +TABLE: name="trans_foobar" schema="" table="trans_foobar" ctx=DDL +STMT: CreateStmt +== 082 +BEGIN +-- +STMT: TransactionStmt +== 083 +CREATE TABLE trans_foo (a int) +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DDL +STMT: CreateStmt +== 084 +SAVEPOINT one +-- +STMT: TransactionStmt +== 085 +DROP TABLE trans_foo +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DDL +STMT: DropStmt +== 086 +CREATE TABLE trans_bar (a int) +-- +TABLE: name="trans_bar" schema="" table="trans_bar" ctx=DDL +STMT: CreateStmt +== 087 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 088 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +== 089 +SAVEPOINT two +-- +STMT: TransactionStmt +== 090 +CREATE TABLE trans_baz (a int) +-- +TABLE: name="trans_baz" schema="" table="trans_baz" ctx=DDL +STMT: CreateStmt +== 091 +RELEASE SAVEPOINT two +-- +STMT: TransactionStmt +== 092 +drop TABLE trans_foobar +-- +TABLE: name="trans_foobar" schema="" table="trans_foobar" ctx=DDL +STMT: DropStmt +== 093 +CREATE TABLE trans_barbaz (a int) +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=DDL +STMT: CreateStmt +== 094 +COMMIT +-- +STMT: TransactionStmt +== 095 +-- should exist: trans_barbaz, trans_baz, trans_foo +SELECT * FROM trans_foo +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=Select +STMT: SelectStmt +== 096 +-- should be empty +SELECT * FROM trans_bar +-- +TABLE: name="trans_bar" schema="" table="trans_bar" ctx=Select +STMT: SelectStmt +== 097 +-- shouldn't exist +SELECT * FROM trans_barbaz +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=Select +STMT: SelectStmt +== 098 +-- should be empty +SELECT * FROM trans_baz +-- +TABLE: name="trans_baz" schema="" table="trans_baz" ctx=Select +STMT: SelectStmt +== 099 +-- should be empty + +-- inserts +BEGIN +-- +STMT: TransactionStmt +== 100 +INSERT INTO trans_foo VALUES (1) +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +SAVEPOINT one +-- +STMT: TransactionStmt +== 102 +INSERT into trans_bar VALUES (1) +-- +TABLE: name="trans_bar" schema="" table="trans_bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +ROLLBACK TO one +-- +STMT: TransactionStmt +== 104 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +== 105 +SAVEPOINT two +-- +STMT: TransactionStmt +== 106 +INSERT into trans_barbaz VALUES (1) +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 107 +RELEASE two +-- +STMT: TransactionStmt +== 108 +SAVEPOINT three +-- +STMT: TransactionStmt +== 109 +SAVEPOINT four +-- +STMT: TransactionStmt +== 110 +INSERT INTO trans_foo VALUES (2) +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 111 +RELEASE SAVEPOINT four +-- +STMT: TransactionStmt +== 112 +ROLLBACK TO SAVEPOINT three +-- +STMT: TransactionStmt +== 113 +RELEASE SAVEPOINT three +-- +STMT: TransactionStmt +== 114 +INSERT INTO trans_foo VALUES (3) +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 115 +COMMIT +-- +STMT: TransactionStmt +== 116 +SELECT * FROM trans_foo +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=Select +STMT: SelectStmt +== 117 +-- should have 1 and 3 +SELECT * FROM trans_barbaz +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=Select +STMT: SelectStmt +== 118 +-- should have 1 + +-- test whole-tree commit +BEGIN +-- +STMT: TransactionStmt +== 119 +SAVEPOINT one +-- +STMT: TransactionStmt +== 120 +SELECT trans_foo +-- +STMT: SelectStmt +== 121 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 122 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +== 123 +SAVEPOINT two +-- +STMT: TransactionStmt +== 124 +CREATE TABLE savepoints (a int) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DDL +STMT: CreateStmt +== 125 +SAVEPOINT three +-- +STMT: TransactionStmt +== 126 +INSERT INTO savepoints VALUES (1) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 127 +SAVEPOINT four +-- +STMT: TransactionStmt +== 128 +INSERT INTO savepoints VALUES (2) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 129 +SAVEPOINT five +-- +STMT: TransactionStmt +== 130 +INSERT INTO savepoints VALUES (3) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 131 +ROLLBACK TO SAVEPOINT five +-- +STMT: TransactionStmt +== 132 +COMMIT +-- +STMT: TransactionStmt +== 133 +COMMIT +-- +STMT: TransactionStmt +== 134 +-- should not be in a transaction block +SELECT * FROM savepoints +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +STMT: SelectStmt +== 135 +-- test whole-tree rollback +BEGIN +-- +STMT: TransactionStmt +== 136 +SAVEPOINT one +-- +STMT: TransactionStmt +== 137 +DELETE FROM savepoints WHERE a=1 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: DeleteStmt +== 138 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +== 139 +SAVEPOINT two +-- +STMT: TransactionStmt +== 140 +DELETE FROM savepoints WHERE a=1 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: DeleteStmt +== 141 +SAVEPOINT three +-- +STMT: TransactionStmt +== 142 +DELETE FROM savepoints WHERE a=2 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: DeleteStmt +== 143 +ROLLBACK +-- +STMT: TransactionStmt +== 144 +COMMIT +-- +STMT: TransactionStmt +== 145 +-- should not be in a transaction block + +SELECT * FROM savepoints +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +STMT: SelectStmt +== 146 +-- test whole-tree commit on an aborted subtransaction +BEGIN +-- +STMT: TransactionStmt +== 147 +INSERT INTO savepoints VALUES (4) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 148 +SAVEPOINT one +-- +STMT: TransactionStmt +== 149 +INSERT INTO savepoints VALUES (5) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +SELECT trans_foo +-- +STMT: SelectStmt +== 151 +COMMIT +-- +STMT: TransactionStmt +== 152 +SELECT * FROM savepoints +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +STMT: SelectStmt +== 153 +BEGIN +-- +STMT: TransactionStmt +== 154 +INSERT INTO savepoints VALUES (6) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 155 +SAVEPOINT one +-- +STMT: TransactionStmt +== 156 +INSERT INTO savepoints VALUES (7) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 157 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +== 158 +INSERT INTO savepoints VALUES (8) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 159 +COMMIT +-- +STMT: TransactionStmt +== 160 +-- rows 6 and 8 should have been created by the same xact +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=6 AND b.a=8 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +ALIAS: "a"="savepoints" +ALIAS: "b"="savepoints" +FILTER: schema="" table="a" column="a" +FILTER: schema="" table="b" column="a" +STMT: SelectStmt +== 161 +-- rows 6 and 7 should have been created by different xacts +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=6 AND b.a=7 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +ALIAS: "a"="savepoints" +ALIAS: "b"="savepoints" +FILTER: schema="" table="a" column="a" +FILTER: schema="" table="b" column="a" +STMT: SelectStmt +== 162 +BEGIN +-- +STMT: TransactionStmt +== 163 +INSERT INTO savepoints VALUES (9) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +SAVEPOINT one +-- +STMT: TransactionStmt +== 165 +INSERT INTO savepoints VALUES (10) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 166 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 167 +INSERT INTO savepoints VALUES (11) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +COMMIT +-- +STMT: TransactionStmt +== 169 +SELECT a FROM savepoints WHERE a in (9, 10, 11) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 170 +-- rows 9 and 11 should have been created by different xacts +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=9 AND b.a=11 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +ALIAS: "a"="savepoints" +ALIAS: "b"="savepoints" +FILTER: schema="" table="a" column="a" +FILTER: schema="" table="b" column="a" +STMT: SelectStmt +== 171 +BEGIN +-- +STMT: TransactionStmt +== 172 +INSERT INTO savepoints VALUES (12) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +SAVEPOINT one +-- +STMT: TransactionStmt +== 174 +INSERT INTO savepoints VALUES (13) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 175 +SAVEPOINT two +-- +STMT: TransactionStmt +== 176 +INSERT INTO savepoints VALUES (14) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 177 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 178 +INSERT INTO savepoints VALUES (15) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 179 +SAVEPOINT two +-- +STMT: TransactionStmt +== 180 +INSERT INTO savepoints VALUES (16) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 181 +SAVEPOINT three +-- +STMT: TransactionStmt +== 182 +INSERT INTO savepoints VALUES (17) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 183 +COMMIT +-- +STMT: TransactionStmt +== 184 +SELECT a FROM savepoints WHERE a BETWEEN 12 AND 17 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 185 +BEGIN +-- +STMT: TransactionStmt +== 186 +INSERT INTO savepoints VALUES (18) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 187 +SAVEPOINT one +-- +STMT: TransactionStmt +== 188 +INSERT INTO savepoints VALUES (19) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +SAVEPOINT two +-- +STMT: TransactionStmt +== 190 +INSERT INTO savepoints VALUES (20) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 191 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 192 +INSERT INTO savepoints VALUES (21) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 193 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 194 +INSERT INTO savepoints VALUES (22) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 195 +COMMIT +-- +STMT: TransactionStmt +== 196 +SELECT a FROM savepoints WHERE a BETWEEN 18 AND 22 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 197 +DROP TABLE savepoints +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DDL +STMT: DropStmt +== 198 +-- only in a transaction block: +SAVEPOINT one +-- +STMT: TransactionStmt +== 199 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 200 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +== 201 +-- Only "rollback to" allowed in aborted state +BEGIN +-- +STMT: TransactionStmt +== 202 +SAVEPOINT one +-- +STMT: TransactionStmt +== 203 +SELECT 0/0 +-- +STMT: SelectStmt +== 204 +SAVEPOINT two +-- +STMT: TransactionStmt +== 205 +-- ignored till the end of ... + RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +== 206 +-- ignored till the end of ... + ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 207 +SELECT 1 +-- +STMT: SelectStmt +== 208 +COMMIT +-- +STMT: TransactionStmt +== 209 +SELECT 1 +-- +STMT: SelectStmt +== 210 +-- this should work + +-- check non-transactional behavior of cursors +BEGIN +-- +STMT: TransactionStmt +== 211 +DECLARE c CURSOR FOR SELECT unique2 FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +== 212 +SAVEPOINT one +-- +STMT: TransactionStmt +== 213 +FETCH 10 FROM c +-- +STMT: FetchStmt +== 214 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +== 215 +FETCH 10 FROM c +-- +STMT: FetchStmt +== 216 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +== 217 +FETCH 10 FROM c +-- +STMT: FetchStmt +== 218 +CLOSE c +-- +STMT: ClosePortalStmt +== 219 +DECLARE c CURSOR FOR SELECT unique2/0 FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +== 220 +SAVEPOINT two +-- +STMT: TransactionStmt +== 221 +FETCH 10 FROM c +-- +STMT: FetchStmt +== 222 +ROLLBACK TO SAVEPOINT two +-- +STMT: TransactionStmt +== 223 +-- c is now dead to the world ... + FETCH 10 FROM c +-- +STMT: FetchStmt +== 224 +ROLLBACK TO SAVEPOINT two +-- +STMT: TransactionStmt +== 225 +RELEASE SAVEPOINT two +-- +STMT: TransactionStmt +== 226 +FETCH 10 FROM c +-- +STMT: FetchStmt +== 227 +COMMIT +-- +STMT: TransactionStmt +== 228 +|-- +-- Check that "stable" functions are really stable. They should not be +-- able to see the partial results of the calling query. (Ideally we would +-- also check that they don't see commits of concurrent transactions, but +-- that's a mite hard to do within the limitations of pg_regress.) +|-- +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +== 229 +create or replace function max_xacttest() returns smallint language sql as +'select max(a) from xacttest' stable +-- +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 230 +begin +-- +STMT: TransactionStmt +== 231 +update xacttest set a = max_xacttest() + 10 where a > 0 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=Call +STMT: UpdateStmt +== 232 +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +== 233 +rollback +-- +STMT: TransactionStmt +== 234 +-- But a volatile function can see the partial results of the calling query +create or replace function max_xacttest() returns smallint language sql as +'select max(a) from xacttest' volatile +-- +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 235 +begin +-- +STMT: TransactionStmt +== 236 +update xacttest set a = max_xacttest() + 10 where a > 0 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=Call +STMT: UpdateStmt +== 237 +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +== 238 +rollback +-- +STMT: TransactionStmt +== 239 +-- Now the same test with plpgsql (since it depends on SPI which is different) +create or replace function max_xacttest() returns smallint language plpgsql as +'begin return max(a) from xacttest; end' stable +-- +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 240 +begin +-- +STMT: TransactionStmt +== 241 +update xacttest set a = max_xacttest() + 10 where a > 0 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=Call +STMT: UpdateStmt +== 242 +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +== 243 +rollback +-- +STMT: TransactionStmt +== 244 +create or replace function max_xacttest() returns smallint language plpgsql as +'begin return max(a) from xacttest; end' volatile +-- +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 245 +begin +-- +STMT: TransactionStmt +== 246 +update xacttest set a = max_xacttest() + 10 where a > 0 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=Call +STMT: UpdateStmt +== 247 +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +== 248 +rollback +-- +STMT: TransactionStmt +== 249 +-- test case for problems with dropping an open relation during abort +BEGIN +-- +STMT: TransactionStmt +== 250 +savepoint x +-- +STMT: TransactionStmt +== 251 +CREATE TABLE koju (a INT UNIQUE) +-- +TABLE: name="koju" schema="" table="koju" ctx=DDL +STMT: CreateStmt +== 252 +INSERT INTO koju VALUES (1) +-- +TABLE: name="koju" schema="" table="koju" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 253 +INSERT INTO koju VALUES (1) +-- +TABLE: name="koju" schema="" table="koju" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 254 +rollback to x +-- +STMT: TransactionStmt +== 255 +CREATE TABLE koju (a INT UNIQUE) +-- +TABLE: name="koju" schema="" table="koju" ctx=DDL +STMT: CreateStmt +== 256 +INSERT INTO koju VALUES (1) +-- +TABLE: name="koju" schema="" table="koju" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 257 +INSERT INTO koju VALUES (1) +-- +TABLE: name="koju" schema="" table="koju" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 258 +ROLLBACK +-- +STMT: TransactionStmt +== 259 +DROP TABLE trans_foo +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DDL +STMT: DropStmt +== 260 +DROP TABLE trans_baz +-- +TABLE: name="trans_baz" schema="" table="trans_baz" ctx=DDL +STMT: DropStmt +== 261 +DROP TABLE trans_barbaz +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=DDL +STMT: DropStmt +== 262 +-- test case for problems with revalidating an open relation during abort +create function inverse(int) returns float8 as +$$ +begin + analyze revalidate_bug; + return 1::float8/$1; +exception + when division_by_zero then return 0; +end$$ language plpgsql volatile +-- +FUNCTION: name="inverse" function="inverse" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 263 +create table revalidate_bug (c float8 unique) +-- +TABLE: name="revalidate_bug" schema="" table="revalidate_bug" ctx=DDL +STMT: CreateStmt +== 264 +insert into revalidate_bug values (1) +-- +TABLE: name="revalidate_bug" schema="" table="revalidate_bug" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 265 +insert into revalidate_bug values (inverse(0)) +-- +TABLE: name="revalidate_bug" schema="" table="revalidate_bug" ctx=DML +FUNCTION: name="inverse" function="inverse" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 266 +drop table revalidate_bug +-- +TABLE: name="revalidate_bug" schema="" table="revalidate_bug" ctx=DDL +STMT: DropStmt +== 267 +drop function inverse(int) +-- +FUNCTION: name="inverse" function="inverse" schema="" ctx=DDL +STMT: DropStmt +== 268 +-- verify that cursors created during an aborted subtransaction are +-- closed, but that we do not rollback the effect of any FETCHs +-- performed in the aborted subtransaction +begin +-- +STMT: TransactionStmt +== 269 +savepoint x +-- +STMT: TransactionStmt +== 270 +create table trans_abc (a int) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: CreateStmt +== 271 +insert into trans_abc values (5) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 272 +insert into trans_abc values (10) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 273 +declare foo cursor for select * from trans_abc +-- +STMT: DeclareCursorStmt +== 274 +fetch from foo +-- +STMT: FetchStmt +== 275 +rollback to x +-- +STMT: TransactionStmt +== 276 +-- should fail +fetch from foo +-- +STMT: FetchStmt +== 277 +commit +-- +STMT: TransactionStmt +== 278 +begin +-- +STMT: TransactionStmt +== 279 +create table trans_abc (a int) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: CreateStmt +== 280 +insert into trans_abc values (5) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 281 +insert into trans_abc values (10) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 282 +insert into trans_abc values (15) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 283 +declare foo cursor for select * from trans_abc +-- +STMT: DeclareCursorStmt +== 284 +fetch from foo +-- +STMT: FetchStmt +== 285 +savepoint x +-- +STMT: TransactionStmt +== 286 +fetch from foo +-- +STMT: FetchStmt +== 287 +rollback to x +-- +STMT: TransactionStmt +== 288 +fetch from foo +-- +STMT: FetchStmt +== 289 +abort +-- +STMT: TransactionStmt +== 290 +-- Test for proper cleanup after a failure in a cursor portal +-- that was created in an outer subtransaction +CREATE FUNCTION invert(x float8) RETURNS float8 LANGUAGE plpgsql AS +$$ begin return 1/x; end $$ +-- +FUNCTION: name="invert" function="invert" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 291 +CREATE FUNCTION create_temp_tab() RETURNS text +LANGUAGE plpgsql AS $$ +BEGIN + CREATE TEMP TABLE new_table (f1 float8); + -- case of interest is that we fail while holding an open + -- relcache reference to new_table + INSERT INTO new_table SELECT invert(0.0); + RETURN 'foo'; +END $$ +-- +FUNCTION: name="create_temp_tab" function="create_temp_tab" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 292 +BEGIN +-- +STMT: TransactionStmt +== 293 +DECLARE ok CURSOR FOR SELECT * FROM int8_tbl +-- +STMT: DeclareCursorStmt +== 294 +DECLARE ctt CURSOR FOR SELECT create_temp_tab() +-- +STMT: DeclareCursorStmt +== 295 +FETCH ok +-- +STMT: FetchStmt +== 296 +SAVEPOINT s1 +-- +STMT: TransactionStmt +== 297 +FETCH ok +-- +STMT: FetchStmt +== 298 +-- should work +FETCH ctt +-- +STMT: FetchStmt +== 299 +-- error occurs here +ROLLBACK TO s1 +-- +STMT: TransactionStmt +== 300 +FETCH ok +-- +STMT: FetchStmt +== 301 +-- should work +FETCH ctt +-- +STMT: FetchStmt +== 302 +-- must be rejected +COMMIT +-- +STMT: TransactionStmt +== 303 +DROP FUNCTION create_temp_tab() +-- +FUNCTION: name="create_temp_tab" function="create_temp_tab" schema="" ctx=DDL +STMT: DropStmt +== 304 +DROP FUNCTION invert(x float8) +-- +FUNCTION: name="invert" function="invert" schema="" ctx=DDL +STMT: DropStmt +== 305 +-- Tests for AND CHAIN + +CREATE TABLE trans_abc (a int) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: CreateStmt +== 306 +-- set nondefault value so we have something to override below +SET default_transaction_read_only = on +-- +STMT: VariableSetStmt +== 307 +START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE +-- +STMT: TransactionStmt +== 308 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 309 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 310 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 311 +INSERT INTO trans_abc VALUES (1) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 312 +INSERT INTO trans_abc VALUES (2) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 313 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 314 +-- TBLOCK_END +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 315 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 316 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 317 +INSERT INTO trans_abc VALUES ('error') +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 318 +INSERT INTO trans_abc VALUES (3) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 319 +-- check it's really aborted +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 320 +-- TBLOCK_ABORT_END +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 321 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 322 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 323 +INSERT INTO trans_abc VALUES (4) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 324 +COMMIT +-- +STMT: TransactionStmt +== 325 +START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE +-- +STMT: TransactionStmt +== 326 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 327 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 328 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 329 +SAVEPOINT x +-- +STMT: TransactionStmt +== 330 +INSERT INTO trans_abc VALUES ('error') +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 331 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 332 +-- TBLOCK_ABORT_PENDING +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 333 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 334 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 335 +INSERT INTO trans_abc VALUES (5) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 336 +COMMIT +-- +STMT: TransactionStmt +== 337 +START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE +-- +STMT: TransactionStmt +== 338 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 339 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 340 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 341 +SAVEPOINT x +-- +STMT: TransactionStmt +== 342 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 343 +-- TBLOCK_SUBCOMMIT +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 344 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 345 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 346 +COMMIT +-- +STMT: TransactionStmt +== 347 +START TRANSACTION ISOLATION LEVEL READ COMMITTED, READ WRITE, DEFERRABLE +-- +STMT: TransactionStmt +== 348 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 349 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 350 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 351 +SAVEPOINT x +-- +STMT: TransactionStmt +== 352 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 353 +-- TBLOCK_SUBCOMMIT +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 354 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 355 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 356 +COMMIT +-- +STMT: TransactionStmt +== 357 +-- different mix of options just for fun +START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE +-- +STMT: TransactionStmt +== 358 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 359 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 360 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 361 +INSERT INTO trans_abc VALUES (6) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 362 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +== 363 +-- TBLOCK_ABORT_PENDING +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 364 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 365 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 366 +INSERT INTO trans_abc VALUES ('error') +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 367 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +== 368 +-- TBLOCK_ABORT_END +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 369 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 370 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +== 371 +ROLLBACK +-- +STMT: TransactionStmt +== 372 +-- not allowed outside a transaction block +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 373 +-- error +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +== 374 +-- error + +SELECT * FROM trans_abc ORDER BY 1 +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=Select +STMT: SelectStmt +== 375 +RESET default_transaction_read_only +-- +STMT: VariableSetStmt +== 376 +DROP TABLE trans_abc +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: DropStmt +== 377 +-- Test assorted behaviors around the implicit transaction block created +-- when multiple SQL commands are sent in a single Query message. These +-- tests rely on the fact that psql will not break SQL commands apart at a +-- backslash-quoted semicolon, but will send them as one Query. + +create temp table i_table (f1 int) +-- +TABLE: name="i_table" schema="" table="i_table" ctx=DDL +STMT: CreateStmt +== 378 +-- psql will show all results of a multi-statement Query +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 66 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 379 +SELECT 2\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 380 +SELECT 3 +-- +STMT: SelectStmt +== 381 +-- this implicitly commits: +insert into i_table values(1)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 58 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 382 +select * from i_table +-- +TABLE: name="i_table" schema="" table="i_table" ctx=Select +STMT: SelectStmt +== 383 +-- 1/0 error will cause rolling back the whole implicit transaction +insert into i_table values(2)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 98 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 384 +select * from i_table\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 385 +select 1/0 +-- +STMT: SelectStmt +== 386 +select * from i_table +-- +TABLE: name="i_table" schema="" table="i_table" ctx=Select +STMT: SelectStmt +== 387 +rollback +-- +STMT: TransactionStmt +== 388 +-- we are not in a transaction at this point + +-- can use regular begin/commit/rollback within a single Query +begin\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 115 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 389 +insert into i_table values(3)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 390 +commit +-- +STMT: TransactionStmt +== 391 +rollback +-- +STMT: TransactionStmt +== 392 +-- we are not in a transaction at this point +begin\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 51 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 393 +insert into i_table values(4)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 394 +rollback +-- +STMT: TransactionStmt +== 395 +rollback +-- +STMT: TransactionStmt +== 396 +-- we are not in a transaction at this point + +-- begin converts implicit transaction into a regular one that +-- can extend past the end of the Query +select 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 158 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 397 +begin\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 398 +insert into i_table values(5) +-- +TABLE: name="i_table" schema="" table="i_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 399 +commit +-- +STMT: TransactionStmt +== 400 +select 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 401 +begin\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 402 +insert into i_table values(6) +-- +TABLE: name="i_table" schema="" table="i_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 403 +rollback +-- +STMT: TransactionStmt +== 404 +-- commit in implicit-transaction state commits but issues a warning. +insert into i_table values(7)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 100 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 405 +commit\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 406 +insert into i_table values(8)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 407 +select 1/0 +-- +STMT: SelectStmt +== 408 +-- similarly, rollback aborts but issues a warning. +insert into i_table values(9)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 82 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 409 +rollback\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 410 +select 2 +-- +STMT: SelectStmt +== 411 +select * from i_table +-- +TABLE: name="i_table" schema="" table="i_table" ctx=Select +STMT: SelectStmt +== 412 +rollback +-- +STMT: TransactionStmt +== 413 +-- we are not in a transaction at this point + +-- implicit transaction block is still a transaction block, for e.g. VACUUM +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 131 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 414 +VACUUM +-- +STMT: VacuumStmt +== 415 +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 416 +COMMIT\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 417 +VACUUM +-- +STMT: VacuumStmt +== 418 +-- we disallow savepoint-related commands in implicit-transaction state +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 81 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 419 +SAVEPOINT sp +-- +STMT: TransactionStmt +== 420 +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 421 +COMMIT\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 422 +SAVEPOINT sp +-- +STMT: TransactionStmt +== 423 +ROLLBACK TO SAVEPOINT sp\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 424 +SELECT 2 +-- +STMT: SelectStmt +== 425 +SELECT 2\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 426 +RELEASE SAVEPOINT sp\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 427 +SELECT 3 +-- +STMT: SelectStmt +== 428 +-- but this is OK, because the BEGIN converts it to a regular xact +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 76 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 429 +BEGIN\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 430 +SAVEPOINT sp\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 13 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 431 +ROLLBACK TO SAVEPOINT sp\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 432 +COMMIT +-- +STMT: TransactionStmt +== 433 +-- Tests for AND CHAIN in implicit transaction blocks + +SET TRANSACTION READ ONLY\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 81 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 434 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 435 +-- error +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 436 +SET TRANSACTION READ ONLY\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 26 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 437 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +== 438 +-- error +SHOW transaction_read_only +-- +STMT: VariableShowStmt +== 439 +CREATE TABLE trans_abc (a int) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: CreateStmt +== 440 +-- COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN +INSERT INTO trans_abc VALUES (7)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 80 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 441 +COMMIT\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 442 +INSERT INTO trans_abc VALUES (8)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 33 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 443 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 444 +-- 7 commit, 8 error +INSERT INTO trans_abc VALUES (9)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 54 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 445 +ROLLBACK\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 446 +INSERT INTO trans_abc VALUES (10)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 447 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +== 448 +-- 9 rollback, 10 error + +-- COMMIT/ROLLBACK AND CHAIN + COMMIT/ROLLBACK +INSERT INTO trans_abc VALUES (11)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 106 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 449 +COMMIT AND CHAIN\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 17 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 450 +INSERT INTO trans_abc VALUES (12)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 451 +COMMIT +-- +STMT: TransactionStmt +== 452 +-- 11 error, 12 not reached +INSERT INTO trans_abc VALUES (13)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 62 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 453 +ROLLBACK AND CHAIN\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 454 +INSERT INTO trans_abc VALUES (14)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 455 +ROLLBACK +-- +STMT: TransactionStmt +== 456 +-- 13 error, 14 not reached + +-- START TRANSACTION + COMMIT/ROLLBACK AND CHAIN +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 128 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 457 +INSERT INTO trans_abc VALUES (15)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 458 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 459 +-- 15 ok +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 460 +-- transaction is active at this point +COMMIT +-- +STMT: TransactionStmt +== 461 +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 50 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 462 +INSERT INTO trans_abc VALUES (16)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 463 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +== 464 +-- 16 ok +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 465 +-- transaction is active at this point +ROLLBACK +-- +STMT: TransactionStmt +== 466 +SET default_transaction_isolation = 'read committed' +-- +STMT: VariableSetStmt +== 467 +-- START TRANSACTION + COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 117 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 468 +INSERT INTO trans_abc VALUES (17)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 469 +COMMIT\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 470 +INSERT INTO trans_abc VALUES (18)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 471 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +== 472 +-- 17 commit, 18 error +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 473 +-- out of transaction block + +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 79 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 474 +INSERT INTO trans_abc VALUES (19)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 475 +ROLLBACK\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 476 +INSERT INTO trans_abc VALUES (20)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 477 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +== 478 +-- 19 rollback, 20 error +SHOW transaction_isolation +-- +STMT: VariableShowStmt +== 479 +-- out of transaction block + +RESET default_transaction_isolation +-- +STMT: VariableSetStmt +== 480 +SELECT * FROM trans_abc ORDER BY 1 +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=Select +STMT: SelectStmt +== 481 +DROP TABLE trans_abc +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: DropStmt +== 482 +-- TRANSACTION SNAPSHOT +-- Incorrect identifier. +BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ +-- +STMT: TransactionStmt +== 483 +SET TRANSACTION SNAPSHOT 'Incorrect Identifier' +-- +STMT: VariableSetStmt +== 484 +ROLLBACK +-- +STMT: TransactionStmt +== 485 +-- Correct identifier, missing file. +BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ +-- +STMT: TransactionStmt +== 486 +SET TRANSACTION SNAPSHOT 'FFF-FFF-F' +-- +STMT: VariableSetStmt +== 487 +ROLLBACK +-- +STMT: TransactionStmt +== 488 +-- Test for successful cleanup of an aborted transaction at session exit. +-- THIS MUST BE THE LAST TEST IN THIS FILE. + +begin +-- +STMT: TransactionStmt +== 489 +select 1/0 +-- +STMT: SelectStmt +== 490 +rollback to X +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/triggers.metadata.json b/parser/testdata/summary/postgres_regress/triggers.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/triggers.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/triggers.test b/parser/testdata/summary/postgres_regress/triggers.test new file mode 100644 index 0000000..e9b37a6 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/triggers.test @@ -0,0 +1,6940 @@ +== 001 +|-- +-- TRIGGERS +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION autoinc () + RETURNS trigger + AS :'autoinclib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 144 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +CREATE FUNCTION check_primary_key () + RETURNS trigger + AS :'refintlib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 59 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +CREATE FUNCTION check_foreign_key () + RETURNS trigger + AS :'refintlib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 59 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +CREATE FUNCTION trigger_return_old () + RETURNS trigger + AS :'regresslib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +CREATE FUNCTION set_ttdummy (int4) + RETURNS int4 + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 68 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +create table pkeys (pkey1 int4 not null, pkey2 text not null) +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DDL +STMT: CreateStmt +== 007 +create table fkeys (fkey1 int4, fkey2 text, fkey3 int) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: CreateStmt +== 008 +create table fkeys2 (fkey21 int4, fkey22 text, pkey23 int not null) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: CreateStmt +== 009 +create index fkeys_i on fkeys (fkey1, fkey2) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: IndexStmt +== 010 +create index fkeys2_i on fkeys2 (fkey21, fkey22) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: IndexStmt +== 011 +create index fkeys2p_i on fkeys2 (pkey23) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: IndexStmt +== 012 +insert into pkeys values (10, '1') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +insert into pkeys values (20, '2') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +insert into pkeys values (30, '3') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +insert into pkeys values (40, '4') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 016 +insert into pkeys values (50, '5') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 017 +insert into pkeys values (60, '6') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 018 +create unique index pkeys_i on pkeys (pkey1, pkey2) +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DDL +STMT: IndexStmt +== 019 +|-- +-- For fkeys: +-- (fkey1, fkey2) --> pkeys (pkey1, pkey2) +-- (fkey3) --> fkeys2 (pkey23) +|-- +create trigger check_fkeys_pkey_exist + before insert or update on fkeys + for each row + execute function + check_primary_key ('fkey1', 'fkey2', 'pkeys', 'pkey1', 'pkey2') +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: CreateTrigStmt +== 020 +create trigger check_fkeys_pkey2_exist + before insert or update on fkeys + for each row + execute function check_primary_key ('fkey3', 'fkeys2', 'pkey23') +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: CreateTrigStmt +== 021 +|-- +-- For fkeys2: +-- (fkey21, fkey22) --> pkeys (pkey1, pkey2) +|-- +create trigger check_fkeys2_pkey_exist + before insert or update on fkeys2 + for each row + execute procedure + check_primary_key ('fkey21', 'fkey22', 'pkeys', 'pkey1', 'pkey2') +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: CreateTrigStmt +== 022 +-- Test comments +COMMENT ON TRIGGER check_fkeys2_pkey_bad ON fkeys2 IS 'wrong' +-- +STMT: CommentStmt +== 023 +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS 'right' +-- +STMT: CommentStmt +== 024 +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS NULL +-- +STMT: CommentStmt +== 025 +|-- +-- For pkeys: +-- ON DELETE/UPDATE (pkey1, pkey2) CASCADE: +-- fkeys (fkey1, fkey2) and fkeys2 (fkey21, fkey22) +|-- +create trigger check_pkeys_fkey_cascade + before delete or update on pkeys + for each row + execute procedure + check_foreign_key (2, 'cascade', 'pkey1', 'pkey2', + 'fkeys', 'fkey1', 'fkey2', 'fkeys2', 'fkey21', 'fkey22') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DDL +STMT: CreateTrigStmt +== 026 +|-- +-- For fkeys2: +-- ON DELETE/UPDATE (pkey23) RESTRICT: +-- fkeys (fkey3) +|-- +create trigger check_fkeys2_fkey_restrict + before delete or update on fkeys2 + for each row + execute procedure check_foreign_key (1, 'restrict', 'pkey23', 'fkeys', 'fkey3') +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: CreateTrigStmt +== 027 +insert into fkeys2 values (10, '1', 1) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 028 +insert into fkeys2 values (30, '3', 2) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +insert into fkeys2 values (40, '4', 5) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +insert into fkeys2 values (50, '5', 3) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +-- no key in pkeys +insert into fkeys2 values (70, '5', 3) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +insert into fkeys values (10, '1', 2) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +insert into fkeys values (30, '3', 3) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +insert into fkeys values (40, '4', 2) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 035 +insert into fkeys values (50, '5', 2) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 036 +-- no key in pkeys +insert into fkeys values (70, '5', 1) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 037 +-- no key in fkeys2 +insert into fkeys values (60, '6', 4) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 038 +delete from pkeys where pkey1 = 30 and pkey2 = '3' +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: DeleteStmt +== 039 +delete from pkeys where pkey1 = 40 and pkey2 = '4' +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: DeleteStmt +== 040 +update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 50 and pkey2 = '5' +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: UpdateStmt +== 041 +update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 10 and pkey2 = '1' +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: UpdateStmt +== 042 +SELECT trigger_name, event_manipulation, event_object_schema, event_object_table, + action_order, action_condition, action_orientation, action_timing, + action_reference_old_table, action_reference_new_table + FROM information_schema.triggers + WHERE event_object_table in ('pkeys', 'fkeys', 'fkeys2') + ORDER BY trigger_name COLLATE "C", 2 +-- +TABLE: name="information_schema.triggers" schema="information_schema" table="triggers" ctx=Select +FILTER: schema="" table="" column="event_object_table" +STMT: SelectStmt +== 043 +DROP TABLE pkeys +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DDL +STMT: DropStmt +== 044 +DROP TABLE fkeys +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: DropStmt +== 045 +DROP TABLE fkeys2 +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: DropStmt +== 046 +-- Check behavior when trigger returns unmodified trigtuple +create table trigtest (f1 int, f2 text) +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateStmt +== 047 +create trigger trigger_return_old + before insert or delete or update on trigtest + for each row execute procedure trigger_return_old() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +== 048 +insert into trigtest values(1, 'foo') +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 050 +update trigtest set f2 = f2 || 'bar' +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +== 051 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 052 +delete from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +== 053 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 054 +-- Also check what happens when such a trigger runs before or after others +create function f1_times_10() returns trigger as +$$ begin new.f1 := new.f1 * 10; return new; end $$ language plpgsql +-- +FUNCTION: name="f1_times_10" function="f1_times_10" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 055 +create trigger trigger_alpha + before insert or update on trigtest + for each row execute procedure f1_times_10() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +== 056 +insert into trigtest values(1, 'foo') +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 058 +update trigtest set f2 = f2 || 'bar' +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +== 059 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 060 +delete from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +== 061 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 062 +create trigger trigger_zed + before insert or update on trigtest + for each row execute procedure f1_times_10() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +== 063 +insert into trigtest values(1, 'foo') +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 065 +update trigtest set f2 = f2 || 'bar' +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +== 066 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 067 +delete from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +== 068 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 069 +drop trigger trigger_alpha on trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: DropStmt +== 070 +insert into trigtest values(1, 'foo') +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 071 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 072 +update trigtest set f2 = f2 || 'bar' +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +== 073 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 074 +delete from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +== 075 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 076 +drop table trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: DropStmt +== 077 +-- Check behavior with an implicit column default, too (bug #16644) +create table trigtest ( + a integer, + b bool default true not null, + c text default 'xyzzy' not null) +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateStmt +== 078 +create trigger trigger_return_old + before insert or delete or update on trigtest + for each row execute procedure trigger_return_old() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +== 079 +insert into trigtest values(1) +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 080 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 081 +alter table trigtest add column d integer default 42 not null +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +== 082 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 083 +update trigtest set a = 2 where a = 1 returning * +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +== 084 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 085 +alter table trigtest drop column b +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +== 086 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 087 +update trigtest set a = 2 where a = 1 returning * +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +== 088 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 089 +drop table trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: DropStmt +== 090 +create sequence ttdummy_seq increment 10 start 0 minvalue 0 +-- +STMT: CreateSeqStmt +== 091 +create table tttest ( + price_id int4, + price_val int4, + price_on int4, + price_off int4 default 999999 +) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DDL +STMT: CreateStmt +== 092 +create trigger ttdummy + before delete or update on tttest + for each row + execute procedure + ttdummy (price_on, price_off) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DDL +STMT: CreateTrigStmt +== 093 +create trigger ttserial + before insert or update on tttest + for each row + execute procedure + autoinc (price_on, ttdummy_seq) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DDL +STMT: CreateTrigStmt +== 094 +insert into tttest values (1, 1, null) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 095 +insert into tttest values (2, 2, null) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 096 +insert into tttest values (3, 3, 0) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 097 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +== 098 +delete from tttest where price_id = 2 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: DeleteStmt +== 099 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +== 100 +-- what do we see ? + +-- get current prices +select * from tttest where price_off = 999999 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +FILTER: schema="" table="" column="price_off" +STMT: SelectStmt +== 101 +-- change price for price_id == 3 +update tttest set price_val = 30 where price_id = 3 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +== 102 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +== 103 +-- now we want to change pric_id in ALL tuples +-- this gets us not what we need +update tttest set price_id = 5 where price_id = 3 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +== 104 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +== 105 +-- restore data as before last update: +select set_ttdummy(0) +-- +FUNCTION: name="set_ttdummy" function="set_ttdummy" schema="" ctx=Call +STMT: SelectStmt +== 106 +delete from tttest where price_id = 5 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: DeleteStmt +== 107 +update tttest set price_off = 999999 where price_val = 30 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +== 108 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +== 109 +-- and try change price_id now! +update tttest set price_id = 5 where price_id = 3 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +== 110 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +== 111 +-- isn't it what we need ? + +select set_ttdummy(1) +-- +FUNCTION: name="set_ttdummy" function="set_ttdummy" schema="" ctx=Call +STMT: SelectStmt +== 112 +-- we want to correct some "date" +update tttest set price_on = -1 where price_id = 1 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +== 113 +-- but this doesn't work + +-- try in this way +select set_ttdummy(0) +-- +FUNCTION: name="set_ttdummy" function="set_ttdummy" schema="" ctx=Call +STMT: SelectStmt +== 114 +update tttest set price_on = -1 where price_id = 1 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +== 115 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +== 116 +-- isn't it what we need ? + +-- get price for price_id == 5 as it was @ "date" 35 +select * from tttest where price_on <= 35 and price_off > 35 and price_id = 5 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +FILTER: schema="" table="" column="price_on" +FILTER: schema="" table="" column="price_off" +FILTER: schema="" table="" column="price_id" +STMT: SelectStmt +== 117 +drop table tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DDL +STMT: DropStmt +== 118 +drop sequence ttdummy_seq +-- +STMT: DropStmt +== 119 +|-- +-- tests for per-statement triggers +|-- + +CREATE TABLE log_table (tstamp timestamp default timeofday()::timestamp) +-- +TABLE: name="log_table" schema="" table="log_table" ctx=DDL +STMT: CreateStmt +== 120 +CREATE TABLE main_table (a int unique, b int) +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateStmt +== 121 +COPY main_table (a,b) FROM stdin +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: CopyStmt +== 122 +CREATE FUNCTION trigger_func() RETURNS trigger LANGUAGE plpgsql AS ' +BEGIN + RAISE NOTICE ''trigger_func(%) called: action = %, when = %, level = %'', TG_ARGV[0], TG_OP, TG_WHEN, TG_LEVEL; + RETURN NULL; +END;' +-- +FUNCTION: name="trigger_func" function="trigger_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 123 +CREATE TRIGGER before_ins_stmt_trig BEFORE INSERT ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('before_ins_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 124 +CREATE TRIGGER after_ins_stmt_trig AFTER INSERT ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('after_ins_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 125 +|-- +-- if neither 'FOR EACH ROW' nor 'FOR EACH STATEMENT' was specified, +-- CREATE TRIGGER should default to 'FOR EACH STATEMENT' +|-- +CREATE TRIGGER after_upd_stmt_trig AFTER UPDATE ON main_table +EXECUTE PROCEDURE trigger_func('after_upd_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 126 +-- Both insert and update statement level triggers (before and after) should +-- fire. Doesn't fire UPDATE before trigger, but only because one isn't +-- defined. +INSERT INTO main_table (a, b) VALUES (5, 10) ON CONFLICT (a) + DO UPDATE SET b = EXCLUDED.b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 127 +CREATE TRIGGER after_upd_row_trig AFTER UPDATE ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_row') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 128 +INSERT INTO main_table DEFAULT VALUES +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: InsertStmt +== 129 +UPDATE main_table SET a = a + 1 WHERE b < 30 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +== 130 +-- UPDATE that effects zero rows should still call per-statement trigger +UPDATE main_table SET a = a + 2 WHERE b > 100 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +== 131 +-- constraint now unneeded +ALTER TABLE main_table DROP CONSTRAINT main_table_a_key +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: AlterTableStmt +== 132 +-- COPY should fire per-row and per-statement INSERT triggers +COPY main_table (a, b) FROM stdin +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: CopyStmt +== 133 +SELECT * FROM main_table ORDER BY a, b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: SelectStmt +== 134 +|-- +-- test triggers with WHEN clause +|-- + +CREATE TRIGGER modified_a BEFORE UPDATE OF a ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) EXECUTE PROCEDURE trigger_func('modified_a') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 135 +CREATE TRIGGER modified_any BEFORE UPDATE OF a ON main_table +FOR EACH ROW WHEN (OLD.* IS DISTINCT FROM NEW.*) EXECUTE PROCEDURE trigger_func('modified_any') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 136 +CREATE TRIGGER insert_a AFTER INSERT ON main_table +FOR EACH ROW WHEN (NEW.a = 123) EXECUTE PROCEDURE trigger_func('insert_a') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 137 +CREATE TRIGGER delete_a AFTER DELETE ON main_table +FOR EACH ROW WHEN (OLD.a = 123) EXECUTE PROCEDURE trigger_func('delete_a') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 138 +CREATE TRIGGER insert_when BEFORE INSERT ON main_table +FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE trigger_func('insert_when') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 139 +CREATE TRIGGER delete_when AFTER DELETE ON main_table +FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE trigger_func('delete_when') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 140 +SELECT trigger_name, event_manipulation, event_object_schema, event_object_table, + action_order, action_condition, action_orientation, action_timing, + action_reference_old_table, action_reference_new_table + FROM information_schema.triggers + WHERE event_object_table IN ('main_table') + ORDER BY trigger_name COLLATE "C", 2 +-- +TABLE: name="information_schema.triggers" schema="information_schema" table="triggers" ctx=Select +FILTER: schema="" table="" column="event_object_table" +STMT: SelectStmt +== 141 +INSERT INTO main_table (a) VALUES (123), (456) +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +COPY main_table FROM stdin +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: CopyStmt +== 143 +DELETE FROM main_table WHERE a IN (123, 456) +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: DeleteStmt +== 144 +UPDATE main_table SET a = 50, b = 60 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +== 145 +SELECT * FROM main_table ORDER BY a, b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: SelectStmt +== 146 +SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +== 147 +SELECT pg_get_triggerdef(oid, false) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +== 148 +SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_any' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +== 149 +-- Test RENAME TRIGGER +ALTER TRIGGER modified_a ON main_table RENAME TO modified_modified_a +-- +STMT: RenameStmt +== 150 +SELECT count(*) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +== 151 +SELECT count(*) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_modified_a' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +== 152 +DROP TRIGGER modified_modified_a ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 153 +DROP TRIGGER modified_any ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 154 +DROP TRIGGER insert_a ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 155 +DROP TRIGGER delete_a ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 156 +DROP TRIGGER insert_when ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 157 +DROP TRIGGER delete_when ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 158 +-- Test WHEN condition accessing system columns. +create table table_with_oids(a int) +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DDL +STMT: CreateStmt +== 159 +insert into table_with_oids values (1) +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 160 +create trigger oid_unchanged_trig after update on table_with_oids + for each row + when (new.tableoid = old.tableoid AND new.tableoid <> 0) + execute procedure trigger_func('after_upd_oid_unchanged') +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DDL +STMT: CreateTrigStmt +== 161 +update table_with_oids set a = a + 1 +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DML +STMT: UpdateStmt +== 162 +drop table table_with_oids +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DDL +STMT: DropStmt +== 163 +-- Test column-level triggers +DROP TRIGGER after_upd_row_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 164 +CREATE TRIGGER before_upd_a_row_trig BEFORE UPDATE OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_upd_a_row') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 165 +CREATE TRIGGER after_upd_b_row_trig AFTER UPDATE OF b ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_b_row') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 166 +CREATE TRIGGER after_upd_a_b_row_trig AFTER UPDATE OF a, b ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_a_b_row') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 167 +CREATE TRIGGER before_upd_a_stmt_trig BEFORE UPDATE OF a ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('before_upd_a_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 168 +CREATE TRIGGER after_upd_b_stmt_trig AFTER UPDATE OF b ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('after_upd_b_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 169 +SELECT pg_get_triggerdef(oid) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'after_upd_a_b_row_trig' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +== 170 +UPDATE main_table SET a = 50 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +== 171 +UPDATE main_table SET b = 10 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +== 172 +|-- +-- Test case for bug with BEFORE trigger followed by AFTER trigger with WHEN +|-- + +CREATE TABLE some_t (some_col boolean NOT NULL) +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: CreateStmt +== 173 +CREATE FUNCTION dummy_update_func() RETURNS trigger AS $$ +BEGIN + RAISE NOTICE 'dummy_update_func(%) called: action = %, old = %, new = %', + TG_ARGV[0], TG_OP, OLD, NEW; + RETURN NEW; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="dummy_update_func" function="dummy_update_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 174 +CREATE TRIGGER some_trig_before BEFORE UPDATE ON some_t FOR EACH ROW + EXECUTE PROCEDURE dummy_update_func('before') +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: CreateTrigStmt +== 175 +CREATE TRIGGER some_trig_aftera AFTER UPDATE ON some_t FOR EACH ROW + WHEN (NOT OLD.some_col AND NEW.some_col) + EXECUTE PROCEDURE dummy_update_func('aftera') +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: CreateTrigStmt +== 176 +CREATE TRIGGER some_trig_afterb AFTER UPDATE ON some_t FOR EACH ROW + WHEN (NOT NEW.some_col) + EXECUTE PROCEDURE dummy_update_func('afterb') +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: CreateTrigStmt +== 177 +INSERT INTO some_t VALUES (TRUE) +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 178 +UPDATE some_t SET some_col = TRUE +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DML +STMT: UpdateStmt +== 179 +UPDATE some_t SET some_col = FALSE +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DML +STMT: UpdateStmt +== 180 +UPDATE some_t SET some_col = TRUE +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DML +STMT: UpdateStmt +== 181 +DROP TABLE some_t +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: DropStmt +== 182 +-- bogus cases +CREATE TRIGGER error_upd_and_col BEFORE UPDATE OR UPDATE OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_upd_and_col') +-- +ERROR: duplicate trigger events specified at or near "ON" +CURSORPOS: 78 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 183 +CREATE TRIGGER error_upd_a_a BEFORE UPDATE OF a, a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_upd_a_a') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 184 +CREATE TRIGGER error_ins_a BEFORE INSERT OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_ins_a') +-- +ERROR: syntax error at or near "OF" +CURSORPOS: 42 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 185 +CREATE TRIGGER error_ins_when BEFORE INSERT OR UPDATE ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) +EXECUTE PROCEDURE trigger_func('error_ins_old') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 186 +CREATE TRIGGER error_del_when BEFORE DELETE OR UPDATE ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) +EXECUTE PROCEDURE trigger_func('error_del_new') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 187 +CREATE TRIGGER error_del_when BEFORE INSERT OR UPDATE ON main_table +FOR EACH ROW WHEN (NEW.tableoid <> 0) +EXECUTE PROCEDURE trigger_func('error_when_sys_column') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 188 +CREATE TRIGGER error_stmt_when BEFORE UPDATE OF a ON main_table +FOR EACH STATEMENT WHEN (OLD.* IS DISTINCT FROM NEW.*) +EXECUTE PROCEDURE trigger_func('error_stmt_when') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 189 +-- check dependency restrictions +ALTER TABLE main_table DROP COLUMN b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: AlterTableStmt +== 190 +-- this should succeed, but we'll roll it back to keep the triggers around +begin +-- +STMT: TransactionStmt +== 191 +DROP TRIGGER after_upd_a_b_row_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 192 +DROP TRIGGER after_upd_b_row_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 193 +DROP TRIGGER after_upd_b_stmt_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 194 +ALTER TABLE main_table DROP COLUMN b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: AlterTableStmt +== 195 +rollback +-- +STMT: TransactionStmt +== 196 +-- Test enable/disable triggers + +create table trigtest (i serial primary key) +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateStmt +== 197 +-- test that disabling RI triggers works +create table trigtest2 (i int references trigtest(i) on delete cascade) +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=DDL +STMT: CreateStmt +== 198 +create function trigtest() returns trigger as $$ +begin + raise notice '% % % %', TG_TABLE_NAME, TG_OP, TG_WHEN, TG_LEVEL; + return new; +end;$$ language plpgsql +-- +FUNCTION: name="trigtest" function="trigtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 199 +create trigger trigtest_b_row_tg before insert or update or delete on trigtest +for each row execute procedure trigtest() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +== 200 +create trigger trigtest_a_row_tg after insert or update or delete on trigtest +for each row execute procedure trigtest() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +== 201 +create trigger trigtest_b_stmt_tg before insert or update or delete on trigtest +for each statement execute procedure trigtest() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +== 202 +create trigger trigtest_a_stmt_tg after insert or update or delete on trigtest +for each statement execute procedure trigtest() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +== 203 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +== 204 +alter table trigtest disable trigger trigtest_b_row_tg +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +== 205 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +== 206 +alter table trigtest disable trigger user +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +== 207 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +== 208 +alter table trigtest enable trigger trigtest_a_stmt_tg +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +== 209 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +== 210 +set session_replication_role = replica +-- +STMT: VariableSetStmt +== 211 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +== 212 +-- does not trigger +alter table trigtest enable always trigger trigtest_a_stmt_tg +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +== 213 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +== 214 +-- now it does +reset session_replication_role +-- +STMT: VariableSetStmt +== 215 +insert into trigtest2 values(1) +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +insert into trigtest2 values(2) +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 217 +delete from trigtest where i=2 +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +== 218 +select * from trigtest2 +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=Select +STMT: SelectStmt +== 219 +alter table trigtest disable trigger all +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +== 220 +delete from trigtest where i=1 +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +== 221 +select * from trigtest2 +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=Select +STMT: SelectStmt +== 222 +-- ensure we still insert, even when all triggers are disabled +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +== 223 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +== 224 +drop table trigtest2 +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=DDL +STMT: DropStmt +== 225 +drop table trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: DropStmt +== 226 +-- dump trigger data +CREATE TABLE trigger_test ( + i int, + v varchar +) +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: CreateStmt +== 227 +CREATE OR REPLACE FUNCTION trigger_data() RETURNS trigger +LANGUAGE plpgsql AS $$ + +declare + + argstr text; + relid text; + +begin + + relid := TG_relid::regclass; + + -- plpgsql can't discover its trigger data in a hash like perl and python + -- can, or by a sort of reflection like tcl can, + -- so we have to hard code the names. + raise NOTICE 'TG_NAME: %', TG_name; + raise NOTICE 'TG_WHEN: %', TG_when; + raise NOTICE 'TG_LEVEL: %', TG_level; + raise NOTICE 'TG_OP: %', TG_op; + raise NOTICE 'TG_RELID::regclass: %', relid; + raise NOTICE 'TG_RELNAME: %', TG_relname; + raise NOTICE 'TG_TABLE_NAME: %', TG_table_name; + raise NOTICE 'TG_TABLE_SCHEMA: %', TG_table_schema; + raise NOTICE 'TG_NARGS: %', TG_nargs; + + argstr := '['; + for i in 0 .. TG_nargs - 1 loop + if i > 0 then + argstr := argstr || ', '; + end if; + argstr := argstr || TG_argv[i]; + end loop; + argstr := argstr || ']'; + raise NOTICE 'TG_ARGV: %', argstr; + + if TG_OP != 'INSERT' then + raise NOTICE 'OLD: %', OLD; + end if; + + if TG_OP != 'DELETE' then + raise NOTICE 'NEW: %', NEW; + end if; + + if TG_OP = 'DELETE' then + return OLD; + else + return NEW; + end if; + +end; +$$ +-- +FUNCTION: name="trigger_data" function="trigger_data" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 228 +CREATE TRIGGER show_trigger_data_trig +BEFORE INSERT OR UPDATE OR DELETE ON trigger_test +FOR EACH ROW EXECUTE PROCEDURE trigger_data(23,'skidoo') +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: CreateTrigStmt +== 229 +insert into trigger_test values(1,'insert') +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 230 +update trigger_test set v = 'update' where i = 1 +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +== 231 +delete from trigger_test +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: DeleteStmt +== 232 +DROP TRIGGER show_trigger_data_trig on trigger_test +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: DropStmt +== 233 +DROP FUNCTION trigger_data() +-- +FUNCTION: name="trigger_data" function="trigger_data" schema="" ctx=DDL +STMT: DropStmt +== 234 +DROP TABLE trigger_test +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: DropStmt +== 235 +|-- +-- Test use of row comparisons on OLD/NEW +|-- + +CREATE TABLE trigger_test (f1 int, f2 text, f3 text) +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: CreateStmt +== 236 +-- this is the obvious (and wrong...) way to compare rows +CREATE FUNCTION mytrigger() RETURNS trigger LANGUAGE plpgsql as $$ +begin + if row(old.*) = row(new.*) then + raise notice 'row % not changed', new.f1; + else + raise notice 'row % changed', new.f1; + end if; + return new; +end$$ +-- +FUNCTION: name="mytrigger" function="mytrigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 237 +CREATE TRIGGER t +BEFORE UPDATE ON trigger_test +FOR EACH ROW EXECUTE PROCEDURE mytrigger() +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: CreateTrigStmt +== 238 +INSERT INTO trigger_test VALUES(1, 'foo', 'bar') +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 239 +INSERT INTO trigger_test VALUES(2, 'baz', 'quux') +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 240 +UPDATE trigger_test SET f3 = 'bar' +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +== 241 +UPDATE trigger_test SET f3 = NULL +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +== 242 +-- this demonstrates that the above isn't really working as desired: +UPDATE trigger_test SET f3 = NULL +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +== 243 +-- the right way when considering nulls is +CREATE OR REPLACE FUNCTION mytrigger() RETURNS trigger LANGUAGE plpgsql as $$ +begin + if row(old.*) is distinct from row(new.*) then + raise notice 'row % changed', new.f1; + else + raise notice 'row % not changed', new.f1; + end if; + return new; +end$$ +-- +FUNCTION: name="mytrigger" function="mytrigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 244 +UPDATE trigger_test SET f3 = 'bar' +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +== 245 +UPDATE trigger_test SET f3 = NULL +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +== 246 +UPDATE trigger_test SET f3 = NULL +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +== 247 +DROP TABLE trigger_test +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: DropStmt +== 248 +DROP FUNCTION mytrigger() +-- +FUNCTION: name="mytrigger" function="mytrigger" schema="" ctx=DDL +STMT: DropStmt +== 249 +-- Test snapshot management in serializable transactions involving triggers +-- per bug report in 6bc73d4c0910042358k3d1adff3qa36f8df75198ecea@mail.gmail.com +CREATE FUNCTION serializable_update_trig() RETURNS trigger LANGUAGE plpgsql AS +$$ +declare + rec record; +begin + new.description = 'updated in trigger'; + return new; +end; +$$ +-- +FUNCTION: name="serializable_update_trig" function="serializable_update_trig" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 250 +CREATE TABLE serializable_update_tab ( + id int, + filler text, + description text +) +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DDL +STMT: CreateStmt +== 251 +CREATE TRIGGER serializable_update_trig BEFORE UPDATE ON serializable_update_tab + FOR EACH ROW EXECUTE PROCEDURE serializable_update_trig() +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DDL +STMT: CreateTrigStmt +== 252 +INSERT INTO serializable_update_tab SELECT a, repeat('xyzxz', 100), 'new' + FROM generate_series(1, 50) a +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 253 +BEGIN +-- +STMT: TransactionStmt +== 254 +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: VariableSetStmt +== 255 +UPDATE serializable_update_tab SET description = 'no no', id = 1 WHERE id = 1 +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DML +STMT: UpdateStmt +== 256 +COMMIT +-- +STMT: TransactionStmt +== 257 +SELECT description FROM serializable_update_tab WHERE id = 1 +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 258 +DROP TABLE serializable_update_tab +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DDL +STMT: DropStmt +== 259 +-- minimal update trigger + +CREATE TABLE min_updates_test ( + f1 text, + f2 int, + f3 int) +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DDL +STMT: CreateStmt +== 260 +INSERT INTO min_updates_test VALUES ('a',1,2),('b','2',null) +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 261 +CREATE TRIGGER z_min_update +BEFORE UPDATE ON min_updates_test +FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger() +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DDL +STMT: CreateTrigStmt +== 262 +UPDATE min_updates_test SET f1 = f1 +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DML +STMT: UpdateStmt +== 263 +UPDATE min_updates_test SET f2 = f2 + 1 +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DML +STMT: UpdateStmt +== 264 +UPDATE min_updates_test SET f3 = 2 WHERE f3 is null +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DML +STMT: UpdateStmt +== 265 +SELECT * FROM min_updates_test +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=Select +STMT: SelectStmt +== 266 +DROP TABLE min_updates_test +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DDL +STMT: DropStmt +== 267 +|-- +-- Test triggers on views +|-- + +CREATE VIEW main_view AS SELECT a, b FROM main_table +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 268 +-- VIEW trigger function +CREATE OR REPLACE FUNCTION view_trigger() RETURNS trigger +LANGUAGE plpgsql AS $$ +declare + argstr text := ''; +begin + for i in 0 .. TG_nargs - 1 loop + if i > 0 then + argstr := argstr || ', '; + end if; + argstr := argstr || TG_argv[i]; + end loop; + + raise notice '% % % % (%)', TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, argstr; + + if TG_LEVEL = 'ROW' then + if TG_OP = 'INSERT' then + raise NOTICE 'NEW: %', NEW; + INSERT INTO main_table VALUES (NEW.a, NEW.b); + RETURN NEW; + end if; + + if TG_OP = 'UPDATE' then + raise NOTICE 'OLD: %, NEW: %', OLD, NEW; + UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b; + if NOT FOUND then RETURN NULL; end if; + RETURN NEW; + end if; + + if TG_OP = 'DELETE' then + raise NOTICE 'OLD: %', OLD; + DELETE FROM main_table WHERE a = OLD.a AND b = OLD.b; + if NOT FOUND then RETURN NULL; end if; + RETURN OLD; + end if; + end if; + + RETURN NULL; +end; +$$ +-- +FUNCTION: name="view_trigger" function="view_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 269 +-- Before row triggers aren't allowed on views +CREATE TRIGGER invalid_trig BEFORE INSERT ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_ins_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 270 +CREATE TRIGGER invalid_trig BEFORE UPDATE ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_upd_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 271 +CREATE TRIGGER invalid_trig BEFORE DELETE ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_del_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 272 +-- After row triggers aren't allowed on views +CREATE TRIGGER invalid_trig AFTER INSERT ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_ins_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 273 +CREATE TRIGGER invalid_trig AFTER UPDATE ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_upd_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 274 +CREATE TRIGGER invalid_trig AFTER DELETE ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_del_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 275 +-- Truncate triggers aren't allowed on views +CREATE TRIGGER invalid_trig BEFORE TRUNCATE ON main_view +EXECUTE PROCEDURE trigger_func('before_tru_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 276 +CREATE TRIGGER invalid_trig AFTER TRUNCATE ON main_view +EXECUTE PROCEDURE trigger_func('before_tru_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 277 +-- INSTEAD OF triggers aren't allowed on tables +CREATE TRIGGER invalid_trig INSTEAD OF INSERT ON main_table +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_ins') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 278 +CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_table +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 279 +CREATE TRIGGER invalid_trig INSTEAD OF DELETE ON main_table +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_del') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +== 280 +-- Don't support WHEN clauses with INSTEAD OF triggers +CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_view +FOR EACH ROW WHEN (OLD.a <> NEW.a) EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 281 +-- Don't support column-level INSTEAD OF triggers +CREATE TRIGGER invalid_trig INSTEAD OF UPDATE OF a ON main_view +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 282 +-- Don't support statement-level INSTEAD OF triggers +CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_view +EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 283 +-- Valid INSTEAD OF triggers +CREATE TRIGGER instead_of_insert_trig INSTEAD OF INSERT ON main_view +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_ins') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 284 +CREATE TRIGGER instead_of_update_trig INSTEAD OF UPDATE ON main_view +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 285 +CREATE TRIGGER instead_of_delete_trig INSTEAD OF DELETE ON main_view +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_del') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 286 +-- Valid BEFORE statement VIEW triggers +CREATE TRIGGER before_ins_stmt_trig BEFORE INSERT ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('before_view_ins_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 287 +CREATE TRIGGER before_upd_stmt_trig BEFORE UPDATE ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('before_view_upd_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 288 +CREATE TRIGGER before_del_stmt_trig BEFORE DELETE ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('before_view_del_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 289 +-- Valid AFTER statement VIEW triggers +CREATE TRIGGER after_ins_stmt_trig AFTER INSERT ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('after_view_ins_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 290 +CREATE TRIGGER after_upd_stmt_trig AFTER UPDATE ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('after_view_upd_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 291 +CREATE TRIGGER after_del_stmt_trig AFTER DELETE ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('after_view_del_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +== 292 +-- Insert into view using trigger +INSERT INTO main_view VALUES (20, 30) +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +INSERT INTO main_view VALUES (21, 31) RETURNING a, b +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 294 +-- Table trigger will prevent updates +UPDATE main_view SET b = 31 WHERE a = 20 +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +== 295 +UPDATE main_view SET b = 32 WHERE a = 21 AND b = 31 RETURNING a, b +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +== 296 +-- Remove table trigger to allow updates +DROP TRIGGER before_upd_a_row_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +== 297 +UPDATE main_view SET b = 31 WHERE a = 20 +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +== 298 +UPDATE main_view SET b = 32 WHERE a = 21 AND b = 31 RETURNING a, b +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +== 299 +-- Before and after stmt triggers should fire even when no rows are affected +UPDATE main_view SET b = 0 WHERE false +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +== 300 +-- Delete from view using trigger +DELETE FROM main_view WHERE a IN (20,21) +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: DeleteStmt +== 301 +DELETE FROM main_view WHERE a = 31 RETURNING a, b +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: DeleteStmt +== 302 +-- Describe view should list triggers + +-- Test dropping view triggers +DROP TRIGGER instead_of_insert_trig ON main_view +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: DropStmt +== 303 +DROP TRIGGER instead_of_delete_trig ON main_view +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: DropStmt +== 304 +DROP VIEW main_view +-- +STMT: DropStmt +== 305 +|-- +-- Test triggers on a join view +|-- +CREATE TABLE country_table ( + country_id serial primary key, + country_name text unique not null, + continent text not null +) +-- +TABLE: name="country_table" schema="" table="country_table" ctx=DDL +STMT: CreateStmt +== 306 +INSERT INTO country_table (country_name, continent) + VALUES ('Japan', 'Asia'), + ('UK', 'Europe'), + ('USA', 'North America') + RETURNING * +-- +TABLE: name="country_table" schema="" table="country_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 307 +CREATE TABLE city_table ( + city_id serial primary key, + city_name text not null, + population bigint, + country_id int references country_table +) +-- +TABLE: name="city_table" schema="" table="city_table" ctx=DDL +STMT: CreateStmt +== 308 +CREATE VIEW city_view AS + SELECT city_id, city_name, population, country_name, continent + FROM city_table ci + LEFT JOIN country_table co ON co.country_id = ci.country_id +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DDL +TABLE: name="city_table" schema="" table="city_table" ctx=Select +TABLE: name="country_table" schema="" table="country_table" ctx=Select +ALIAS: "ci"="city_table" +ALIAS: "co"="country_table" +STMT: ViewStmt +STMT: SelectStmt +== 309 +CREATE FUNCTION city_insert() RETURNS trigger LANGUAGE plpgsql AS $$ +declare + ctry_id int; +begin + if NEW.country_name IS NOT NULL then + SELECT country_id, continent INTO ctry_id, NEW.continent + FROM country_table WHERE country_name = NEW.country_name; + if NOT FOUND then + raise exception 'No such country: "%"', NEW.country_name; + end if; + else + NEW.continent := NULL; + end if; + + if NEW.city_id IS NOT NULL then + INSERT INTO city_table + VALUES(NEW.city_id, NEW.city_name, NEW.population, ctry_id); + else + INSERT INTO city_table(city_name, population, country_id) + VALUES(NEW.city_name, NEW.population, ctry_id) + RETURNING city_id INTO NEW.city_id; + end if; + + RETURN NEW; +end; +$$ +-- +FUNCTION: name="city_insert" function="city_insert" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 310 +CREATE TRIGGER city_insert_trig INSTEAD OF INSERT ON city_view +FOR EACH ROW EXECUTE PROCEDURE city_insert() +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DDL +STMT: CreateTrigStmt +== 311 +CREATE FUNCTION city_delete() RETURNS trigger LANGUAGE plpgsql AS $$ +begin + DELETE FROM city_table WHERE city_id = OLD.city_id; + if NOT FOUND then RETURN NULL; end if; + RETURN OLD; +end; +$$ +-- +FUNCTION: name="city_delete" function="city_delete" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 312 +CREATE TRIGGER city_delete_trig INSTEAD OF DELETE ON city_view +FOR EACH ROW EXECUTE PROCEDURE city_delete() +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DDL +STMT: CreateTrigStmt +== 313 +CREATE FUNCTION city_update() RETURNS trigger LANGUAGE plpgsql AS $$ +declare + ctry_id int; +begin + if NEW.country_name IS DISTINCT FROM OLD.country_name then + SELECT country_id, continent INTO ctry_id, NEW.continent + FROM country_table WHERE country_name = NEW.country_name; + if NOT FOUND then + raise exception 'No such country: "%"', NEW.country_name; + end if; + + UPDATE city_table SET city_name = NEW.city_name, + population = NEW.population, + country_id = ctry_id + WHERE city_id = OLD.city_id; + else + UPDATE city_table SET city_name = NEW.city_name, + population = NEW.population + WHERE city_id = OLD.city_id; + NEW.continent := OLD.continent; + end if; + + if NOT FOUND then RETURN NULL; end if; + RETURN NEW; +end; +$$ +-- +FUNCTION: name="city_update" function="city_update" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 314 +CREATE TRIGGER city_update_trig INSTEAD OF UPDATE ON city_view +FOR EACH ROW EXECUTE PROCEDURE city_update() +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DDL +STMT: CreateTrigStmt +== 315 +-- INSERT .. RETURNING +INSERT INTO city_view(city_name) VALUES('Tokyo') RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 316 +INSERT INTO city_view(city_name, population) VALUES('London', 7556900) RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 317 +INSERT INTO city_view(city_name, country_name) VALUES('Washington DC', 'USA') RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 318 +INSERT INTO city_view(city_id, city_name) VALUES(123456, 'New York') RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 319 +INSERT INTO city_view VALUES(234567, 'Birmingham', 1016800, 'UK', 'EU') RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 320 +-- UPDATE .. RETURNING +UPDATE city_view SET country_name = 'Japon' WHERE city_name = 'Tokyo' +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +== 321 +-- error +UPDATE city_view SET country_name = 'Japan' WHERE city_name = 'Takyo' +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +== 322 +-- no match +UPDATE city_view SET country_name = 'Japan' WHERE city_name = 'Tokyo' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +== 323 +-- OK + +UPDATE city_view SET population = 13010279 WHERE city_name = 'Tokyo' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +== 324 +UPDATE city_view SET country_name = 'UK' WHERE city_name = 'New York' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +== 325 +UPDATE city_view SET country_name = 'USA', population = 8391881 WHERE city_name = 'New York' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +== 326 +UPDATE city_view SET continent = 'EU' WHERE continent = 'Europe' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +== 327 +UPDATE city_view v1 SET country_name = v2.country_name FROM city_view v2 + WHERE v2.city_name = 'Birmingham' AND v1.city_name = 'London' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +TABLE: name="city_view" schema="" table="city_view" ctx=Select +ALIAS: "v1"="city_view" +ALIAS: "v2"="city_view" +STMT: UpdateStmt +== 328 +-- DELETE .. RETURNING +DELETE FROM city_view WHERE city_name = 'Birmingham' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: DeleteStmt +== 329 +-- read-only view with WHERE clause +CREATE VIEW european_city_view AS + SELECT * FROM city_view WHERE continent = 'Europe' +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +TABLE: name="city_view" schema="" table="city_view" ctx=Select +FILTER: schema="" table="" column="continent" +STMT: ViewStmt +STMT: SelectStmt +== 330 +SELECT count(*) FROM european_city_view +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 331 +CREATE FUNCTION no_op_trig_fn() RETURNS trigger LANGUAGE plpgsql +AS 'begin RETURN NULL; end' +-- +FUNCTION: name="no_op_trig_fn" function="no_op_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 332 +CREATE TRIGGER no_op_trig INSTEAD OF INSERT OR UPDATE OR DELETE +ON european_city_view FOR EACH ROW EXECUTE PROCEDURE no_op_trig_fn() +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +STMT: CreateTrigStmt +== 333 +INSERT INTO european_city_view VALUES (0, 'x', 10000, 'y', 'z') +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 334 +UPDATE european_city_view SET population = 10000 +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: UpdateStmt +== 335 +DELETE FROM european_city_view +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: DeleteStmt +== 336 +-- rules bypassing no-op triggers +CREATE RULE european_city_insert_rule AS ON INSERT TO european_city_view +DO INSTEAD INSERT INTO city_view +VALUES (NEW.city_id, NEW.city_name, NEW.population, NEW.country_name, NEW.continent) +RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +STMT: RuleStmt +== 337 +CREATE RULE european_city_update_rule AS ON UPDATE TO european_city_view +DO INSTEAD UPDATE city_view SET + city_name = NEW.city_name, + population = NEW.population, + country_name = NEW.country_name +WHERE city_id = OLD.city_id +RETURNING NEW.* +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +STMT: RuleStmt +== 338 +CREATE RULE european_city_delete_rule AS ON DELETE TO european_city_view +DO INSTEAD DELETE FROM city_view WHERE city_id = OLD.city_id RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +STMT: RuleStmt +== 339 +-- INSERT not limited by view's WHERE clause, but UPDATE AND DELETE are +INSERT INTO european_city_view(city_name, country_name) + VALUES ('Cambridge', 'USA') RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 340 +UPDATE european_city_view SET country_name = 'UK' + WHERE city_name = 'Cambridge' +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: UpdateStmt +== 341 +DELETE FROM european_city_view WHERE city_name = 'Cambridge' +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: DeleteStmt +== 342 +-- UPDATE and DELETE via rule and trigger +UPDATE city_view SET country_name = 'UK' + WHERE city_name = 'Cambridge' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +== 343 +UPDATE european_city_view SET population = 122800 + WHERE city_name = 'Cambridge' RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: UpdateStmt +== 344 +DELETE FROM european_city_view WHERE city_name = 'Cambridge' RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: DeleteStmt +== 345 +-- join UPDATE test +UPDATE city_view v SET population = 599657 + FROM city_table ci, country_table co + WHERE ci.city_name = 'Washington DC' and co.country_name = 'USA' + AND v.city_id = ci.city_id AND v.country_name = co.country_name + RETURNING co.country_id, v.country_name, + v.city_id, v.city_name, v.population +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +TABLE: name="city_table" schema="" table="city_table" ctx=Select +TABLE: name="country_table" schema="" table="country_table" ctx=Select +ALIAS: "ci"="city_table" +ALIAS: "co"="country_table" +ALIAS: "v"="city_view" +STMT: UpdateStmt +== 346 +SELECT * FROM city_view +-- +TABLE: name="city_view" schema="" table="city_view" ctx=Select +STMT: SelectStmt +== 347 +DROP TABLE city_table CASCADE +-- +TABLE: name="city_table" schema="" table="city_table" ctx=DDL +STMT: DropStmt +== 348 +DROP TABLE country_table +-- +TABLE: name="country_table" schema="" table="country_table" ctx=DDL +STMT: DropStmt +== 349 +-- Test pg_trigger_depth() + +create table depth_a (id int not null primary key) +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DDL +STMT: CreateStmt +== 350 +create table depth_b (id int not null primary key) +-- +TABLE: name="depth_b" schema="" table="depth_b" ctx=DDL +STMT: CreateStmt +== 351 +create table depth_c (id int not null primary key) +-- +TABLE: name="depth_c" schema="" table="depth_c" ctx=DDL +STMT: CreateStmt +== 352 +create function depth_a_tf() returns trigger + language plpgsql as $$ +begin + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + insert into depth_b values (new.id); + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + return new; +end; +$$ +-- +FUNCTION: name="depth_a_tf" function="depth_a_tf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 353 +create trigger depth_a_tr before insert on depth_a + for each row execute procedure depth_a_tf() +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DDL +STMT: CreateTrigStmt +== 354 +create function depth_b_tf() returns trigger + language plpgsql as $$ +begin + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + begin + execute 'insert into depth_c values (' || new.id::text || ')'; + exception + when sqlstate 'U9999' then + raise notice 'SQLSTATE = U9999: depth = %', pg_trigger_depth(); + end; + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + if new.id = 1 then + execute 'insert into depth_c values (' || new.id::text || ')'; + end if; + return new; +end; +$$ +-- +FUNCTION: name="depth_b_tf" function="depth_b_tf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 355 +create trigger depth_b_tr before insert on depth_b + for each row execute procedure depth_b_tf() +-- +TABLE: name="depth_b" schema="" table="depth_b" ctx=DDL +STMT: CreateTrigStmt +== 356 +create function depth_c_tf() returns trigger + language plpgsql as $$ +begin + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + if new.id = 1 then + raise exception sqlstate 'U9999'; + end if; + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + return new; +end; +$$ +-- +FUNCTION: name="depth_c_tf" function="depth_c_tf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 357 +create trigger depth_c_tr before insert on depth_c + for each row execute procedure depth_c_tf() +-- +TABLE: name="depth_c" schema="" table="depth_c" ctx=DDL +STMT: CreateTrigStmt +== 358 +select pg_trigger_depth() +-- +FUNCTION: name="pg_trigger_depth" function="pg_trigger_depth" schema="" ctx=Call +STMT: SelectStmt +== 359 +insert into depth_a values (1) +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 360 +select pg_trigger_depth() +-- +FUNCTION: name="pg_trigger_depth" function="pg_trigger_depth" schema="" ctx=Call +STMT: SelectStmt +== 361 +insert into depth_a values (2) +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 362 +select pg_trigger_depth() +-- +FUNCTION: name="pg_trigger_depth" function="pg_trigger_depth" schema="" ctx=Call +STMT: SelectStmt +== 363 +drop table depth_a, depth_b, depth_c +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DDL +TABLE: name="depth_b" schema="" table="depth_b" ctx=DDL +TABLE: name="depth_c" schema="" table="depth_c" ctx=DDL +STMT: DropStmt +== 364 +drop function depth_a_tf() +-- +FUNCTION: name="depth_a_tf" function="depth_a_tf" schema="" ctx=DDL +STMT: DropStmt +== 365 +drop function depth_b_tf() +-- +FUNCTION: name="depth_b_tf" function="depth_b_tf" schema="" ctx=DDL +STMT: DropStmt +== 366 +drop function depth_c_tf() +-- +FUNCTION: name="depth_c_tf" function="depth_c_tf" schema="" ctx=DDL +STMT: DropStmt +== 367 +|-- +-- Test updates to rows during firing of BEFORE ROW triggers. +-- As of 9.2, such cases should be rejected (see bug #6123). +|-- + +create temp table parent ( + aid int not null primary key, + val1 text, + val2 text, + val3 text, + val4 text, + bcnt int not null default 0) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 368 +create temp table child ( + bid int not null primary key, + aid int not null, + val1 text) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 369 +create function parent_upd_func() + returns trigger language plpgsql as +$$ +begin + if old.val1 <> new.val1 then + new.val2 = new.val1; + delete from child where child.aid = new.aid and child.val1 = new.val1; + end if; + return new; +end; +$$ +-- +FUNCTION: name="parent_upd_func" function="parent_upd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 370 +create trigger parent_upd_trig before update on parent + for each row execute procedure parent_upd_func() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 371 +create function parent_del_func() + returns trigger language plpgsql as +$$ +begin + delete from child where aid = old.aid; + return old; +end; +$$ +-- +FUNCTION: name="parent_del_func" function="parent_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 372 +create trigger parent_del_trig before delete on parent + for each row execute procedure parent_del_func() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 373 +create function child_ins_func() + returns trigger language plpgsql as +$$ +begin + update parent set bcnt = bcnt + 1 where aid = new.aid; + return new; +end; +$$ +-- +FUNCTION: name="child_ins_func" function="child_ins_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 374 +create trigger child_ins_trig after insert on child + for each row execute procedure child_ins_func() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +== 375 +create function child_del_func() + returns trigger language plpgsql as +$$ +begin + update parent set bcnt = bcnt - 1 where aid = old.aid; + return old; +end; +$$ +-- +FUNCTION: name="child_del_func" function="child_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 376 +create trigger child_del_trig after delete on child + for each row execute procedure child_del_func() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +== 377 +insert into parent values (1, 'a', 'a', 'a', 'a', 0) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 378 +insert into child values (10, 1, 'b') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 379 +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 380 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +== 381 +update parent set val1 = 'b' where aid = 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: UpdateStmt +== 382 +-- should fail +merge into parent p using (values (1)) as v(id) on p.aid = v.id + when matched then update set val1 = 'b' +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +ALIAS: "p"="parent" +STMT: MergeStmt +STMT: SelectStmt +== 383 +-- should fail +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 384 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +== 385 +delete from parent where aid = 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +== 386 +-- should fail +merge into parent p using (values (1)) as v(id) on p.aid = v.id + when matched then delete +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +ALIAS: "p"="parent" +STMT: MergeStmt +STMT: SelectStmt +== 387 +-- should fail +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 388 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +== 389 +-- replace the trigger function with one that restarts the deletion after +-- having modified a child +create or replace function parent_del_func() + returns trigger language plpgsql as +$$ +begin + delete from child where aid = old.aid; + if found then + delete from parent where aid = old.aid; + return null; -- cancel outer deletion + end if; + return old; +end; +$$ +-- +FUNCTION: name="parent_del_func" function="parent_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 390 +delete from parent where aid = 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +== 391 +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 392 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +== 393 +drop table parent, child +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +== 394 +drop function parent_upd_func() +-- +FUNCTION: name="parent_upd_func" function="parent_upd_func" schema="" ctx=DDL +STMT: DropStmt +== 395 +drop function parent_del_func() +-- +FUNCTION: name="parent_del_func" function="parent_del_func" schema="" ctx=DDL +STMT: DropStmt +== 396 +drop function child_ins_func() +-- +FUNCTION: name="child_ins_func" function="child_ins_func" schema="" ctx=DDL +STMT: DropStmt +== 397 +drop function child_del_func() +-- +FUNCTION: name="child_del_func" function="child_del_func" schema="" ctx=DDL +STMT: DropStmt +== 398 +-- similar case, but with a self-referencing FK so that parent and child +-- rows can be affected by a single operation + +create temp table self_ref_trigger ( + id int primary key, + parent int references self_ref_trigger, + data text, + nchildren int not null default 0 +) +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DDL +STMT: CreateStmt +== 399 +create function self_ref_trigger_ins_func() + returns trigger language plpgsql as +$$ +begin + if new.parent is not null then + update self_ref_trigger set nchildren = nchildren + 1 + where id = new.parent; + end if; + return new; +end; +$$ +-- +FUNCTION: name="self_ref_trigger_ins_func" function="self_ref_trigger_ins_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 400 +create trigger self_ref_trigger_ins_trig before insert on self_ref_trigger + for each row execute procedure self_ref_trigger_ins_func() +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DDL +STMT: CreateTrigStmt +== 401 +create function self_ref_trigger_del_func() + returns trigger language plpgsql as +$$ +begin + if old.parent is not null then + update self_ref_trigger set nchildren = nchildren - 1 + where id = old.parent; + end if; + return old; +end; +$$ +-- +FUNCTION: name="self_ref_trigger_del_func" function="self_ref_trigger_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 402 +create trigger self_ref_trigger_del_trig before delete on self_ref_trigger + for each row execute procedure self_ref_trigger_del_func() +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DDL +STMT: CreateTrigStmt +== 403 +insert into self_ref_trigger values (1, null, 'root') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 404 +insert into self_ref_trigger values (2, 1, 'root child A') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 405 +insert into self_ref_trigger values (3, 1, 'root child B') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 406 +insert into self_ref_trigger values (4, 2, 'grandchild 1') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 407 +insert into self_ref_trigger values (5, 3, 'grandchild 2') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 408 +update self_ref_trigger set data = 'root!' where id = 1 +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: UpdateStmt +== 409 +select * from self_ref_trigger +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=Select +STMT: SelectStmt +== 410 +delete from self_ref_trigger +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: DeleteStmt +== 411 +select * from self_ref_trigger +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=Select +STMT: SelectStmt +== 412 +drop table self_ref_trigger +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DDL +STMT: DropStmt +== 413 +drop function self_ref_trigger_ins_func() +-- +FUNCTION: name="self_ref_trigger_ins_func" function="self_ref_trigger_ins_func" schema="" ctx=DDL +STMT: DropStmt +== 414 +drop function self_ref_trigger_del_func() +-- +FUNCTION: name="self_ref_trigger_del_func" function="self_ref_trigger_del_func" schema="" ctx=DDL +STMT: DropStmt +== 415 +|-- +-- Check that statement triggers work correctly even with all children excluded +|-- + +create table stmt_trig_on_empty_upd (a int) +-- +TABLE: name="stmt_trig_on_empty_upd" schema="" table="stmt_trig_on_empty_upd" ctx=DDL +STMT: CreateStmt +== 416 +create table stmt_trig_on_empty_upd1 () inherits (stmt_trig_on_empty_upd) +-- +TABLE: name="stmt_trig_on_empty_upd1" schema="" table="stmt_trig_on_empty_upd1" ctx=DDL +STMT: CreateStmt +== 417 +create function update_stmt_notice() returns trigger as $$ +begin + raise notice 'updating %', TG_TABLE_NAME; + return null; +end; +$$ language plpgsql +-- +FUNCTION: name="update_stmt_notice" function="update_stmt_notice" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 418 +create trigger before_stmt_trigger + before update on stmt_trig_on_empty_upd + execute procedure update_stmt_notice() +-- +TABLE: name="stmt_trig_on_empty_upd" schema="" table="stmt_trig_on_empty_upd" ctx=DDL +STMT: CreateTrigStmt +== 419 +create trigger before_stmt_trigger + before update on stmt_trig_on_empty_upd1 + execute procedure update_stmt_notice() +-- +TABLE: name="stmt_trig_on_empty_upd1" schema="" table="stmt_trig_on_empty_upd1" ctx=DDL +STMT: CreateTrigStmt +== 420 +-- inherited no-op update +update stmt_trig_on_empty_upd set a = a where false returning a+1 as aa +-- +TABLE: name="stmt_trig_on_empty_upd" schema="" table="stmt_trig_on_empty_upd" ctx=DML +STMT: UpdateStmt +== 421 +-- simple no-op update +update stmt_trig_on_empty_upd1 set a = a where false returning a+1 as aa +-- +TABLE: name="stmt_trig_on_empty_upd1" schema="" table="stmt_trig_on_empty_upd1" ctx=DML +STMT: UpdateStmt +== 422 +drop table stmt_trig_on_empty_upd cascade +-- +TABLE: name="stmt_trig_on_empty_upd" schema="" table="stmt_trig_on_empty_upd" ctx=DDL +STMT: DropStmt +== 423 +drop function update_stmt_notice() +-- +FUNCTION: name="update_stmt_notice" function="update_stmt_notice" schema="" ctx=DDL +STMT: DropStmt +== 424 +|-- +-- Check that index creation (or DDL in general) is prohibited in a trigger +|-- + +create table trigger_ddl_table ( + col1 integer, + col2 integer +) +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DDL +STMT: CreateStmt +== 425 +create function trigger_ddl_func() returns trigger as $$ +begin + alter table trigger_ddl_table add primary key (col1); + return new; +end$$ language plpgsql +-- +FUNCTION: name="trigger_ddl_func" function="trigger_ddl_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 426 +create trigger trigger_ddl_func before insert on trigger_ddl_table for each row + execute procedure trigger_ddl_func() +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DDL +STMT: CreateTrigStmt +== 427 +insert into trigger_ddl_table values (1, 42) +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 428 +-- fail + +create or replace function trigger_ddl_func() returns trigger as $$ +begin + create index on trigger_ddl_table (col2); + return new; +end$$ language plpgsql +-- +FUNCTION: name="trigger_ddl_func" function="trigger_ddl_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 429 +insert into trigger_ddl_table values (1, 42) +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 430 +-- fail + +drop table trigger_ddl_table +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DDL +STMT: DropStmt +== 431 +drop function trigger_ddl_func() +-- +FUNCTION: name="trigger_ddl_func" function="trigger_ddl_func" schema="" ctx=DDL +STMT: DropStmt +== 432 +|-- +-- Verify behavior of before and after triggers with INSERT...ON CONFLICT +-- DO UPDATE +|-- +create table upsert (key int4 primary key, color text) +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: CreateStmt +== 433 +create function upsert_before_func() + returns trigger language plpgsql as +$$ +begin + if (TG_OP = 'UPDATE') then + raise warning 'before update (old): %', old.*::text; + raise warning 'before update (new): %', new.*::text; + elsif (TG_OP = 'INSERT') then + raise warning 'before insert (new): %', new.*::text; + if new.key % 2 = 0 then + new.key := new.key + 1; + new.color := new.color || ' trig modified'; + raise warning 'before insert (new, modified): %', new.*::text; + end if; + end if; + return new; +end; +$$ +-- +FUNCTION: name="upsert_before_func" function="upsert_before_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 434 +create trigger upsert_before_trig before insert or update on upsert + for each row execute procedure upsert_before_func() +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: CreateTrigStmt +== 435 +create function upsert_after_func() + returns trigger language plpgsql as +$$ +begin + if (TG_OP = 'UPDATE') then + raise warning 'after update (old): %', old.*::text; + raise warning 'after update (new): %', new.*::text; + elsif (TG_OP = 'INSERT') then + raise warning 'after insert (new): %', new.*::text; + end if; + return null; +end; +$$ +-- +FUNCTION: name="upsert_after_func" function="upsert_after_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 436 +create trigger upsert_after_trig after insert or update on upsert + for each row execute procedure upsert_after_func() +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: CreateTrigStmt +== 437 +insert into upsert values(1, 'black') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 438 +insert into upsert values(2, 'red') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 439 +insert into upsert values(3, 'orange') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 440 +insert into upsert values(4, 'green') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 441 +insert into upsert values(5, 'purple') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 442 +insert into upsert values(6, 'white') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 443 +insert into upsert values(7, 'pink') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 444 +insert into upsert values(8, 'yellow') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 445 +select * from upsert +-- +TABLE: name="upsert" schema="" table="upsert" ctx=Select +STMT: SelectStmt +== 446 +drop table upsert +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: DropStmt +== 447 +drop function upsert_before_func() +-- +FUNCTION: name="upsert_before_func" function="upsert_before_func" schema="" ctx=DDL +STMT: DropStmt +== 448 +drop function upsert_after_func() +-- +FUNCTION: name="upsert_after_func" function="upsert_after_func" schema="" ctx=DDL +STMT: DropStmt +== 449 +|-- +-- Verify that triggers with transition tables are not allowed on +-- views +|-- + +create table my_table (i int) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateStmt +== 450 +create view my_view as select * from my_table +-- +TABLE: name="my_view" schema="" table="my_view" ctx=DDL +TABLE: name="my_table" schema="" table="my_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 451 +create function my_trigger_function() returns trigger as $$ begin end; $$ language plpgsql +-- +FUNCTION: name="my_trigger_function" function="my_trigger_function" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 452 +create trigger my_trigger after update on my_view referencing old table as old_table + for each statement execute procedure my_trigger_function() +-- +TABLE: name="my_view" schema="" table="my_view" ctx=DDL +STMT: CreateTrigStmt +== 453 +drop function my_trigger_function() +-- +FUNCTION: name="my_trigger_function" function="my_trigger_function" schema="" ctx=DDL +STMT: DropStmt +== 454 +drop view my_view +-- +STMT: DropStmt +== 455 +drop table my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: DropStmt +== 456 +|-- +-- Verify cases that are unsupported with partitioned tables +|-- +create table parted_trig (a int) partition by list (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +== 457 +create function trigger_nothing() returns trigger + language plpgsql as $$ begin end; $$ +-- +FUNCTION: name="trigger_nothing" function="trigger_nothing" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 458 +create trigger failed instead of update on parted_trig + for each row execute procedure trigger_nothing() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 459 +create trigger failed after update on parted_trig + referencing old table as old_table + for each row execute procedure trigger_nothing() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 460 +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +== 461 +|-- +-- Verify trigger creation for partitioned tables, and drop behavior +|-- +create table trigpart (a int, b int) partition by range (a) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: CreateStmt +== 462 +create table trigpart1 partition of trigpart for values from (0) to (1000) +-- +TABLE: name="trigpart1" schema="" table="trigpart1" ctx=DDL +STMT: CreateStmt +== 463 +create trigger trg1 after insert on trigpart for each row execute procedure trigger_nothing() +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: CreateTrigStmt +== 464 +create table trigpart2 partition of trigpart for values from (1000) to (2000) +-- +TABLE: name="trigpart2" schema="" table="trigpart2" ctx=DDL +STMT: CreateStmt +== 465 +create table trigpart3 (like trigpart) +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: CreateStmt +== 466 +alter table trigpart attach partition trigpart3 for values from (2000) to (3000) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +== 467 +create table trigpart4 partition of trigpart for values from (3000) to (4000) partition by range (a) +-- +TABLE: name="trigpart4" schema="" table="trigpart4" ctx=DDL +STMT: CreateStmt +== 468 +create table trigpart41 partition of trigpart4 for values from (3000) to (3500) +-- +TABLE: name="trigpart41" schema="" table="trigpart41" ctx=DDL +STMT: CreateStmt +== 469 +create table trigpart42 (like trigpart) +-- +TABLE: name="trigpart42" schema="" table="trigpart42" ctx=DDL +STMT: CreateStmt +== 470 +alter table trigpart4 attach partition trigpart42 for values from (3500) to (4000) +-- +TABLE: name="trigpart4" schema="" table="trigpart4" ctx=DDL +STMT: AlterTableStmt +== 471 +select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger + where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 472 +drop trigger trg1 on trigpart1 +-- +TABLE: name="trigpart1" schema="" table="trigpart1" ctx=DDL +STMT: DropStmt +== 473 +-- fail +drop trigger trg1 on trigpart2 +-- +TABLE: name="trigpart2" schema="" table="trigpart2" ctx=DDL +STMT: DropStmt +== 474 +-- fail +drop trigger trg1 on trigpart3 +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: DropStmt +== 475 +-- fail +drop table trigpart2 +-- +TABLE: name="trigpart2" schema="" table="trigpart2" ctx=DDL +STMT: DropStmt +== 476 +-- ok, trigger should be gone in that partition +select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger + where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 477 +drop trigger trg1 on trigpart +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: DropStmt +== 478 +-- ok, all gone +select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger + where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 479 +-- check detach behavior +create trigger trg1 after insert on trigpart for each row execute procedure trigger_nothing() +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: CreateTrigStmt +== 480 +alter table trigpart detach partition trigpart3 +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +== 481 +drop trigger trg1 on trigpart3 +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: DropStmt +== 482 +-- fail due to "does not exist" +alter table trigpart detach partition trigpart4 +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +== 483 +drop trigger trg1 on trigpart41 +-- +TABLE: name="trigpart41" schema="" table="trigpart41" ctx=DDL +STMT: DropStmt +== 484 +-- fail due to "does not exist" +drop table trigpart4 +-- +TABLE: name="trigpart4" schema="" table="trigpart4" ctx=DDL +STMT: DropStmt +== 485 +alter table trigpart attach partition trigpart3 for values from (2000) to (3000) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +== 486 +alter table trigpart detach partition trigpart3 +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +== 487 +alter table trigpart attach partition trigpart3 for values from (2000) to (3000) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +== 488 +drop table trigpart3 +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: DropStmt +== 489 +select tgrelid::regclass::text, tgname, tgfoid::regproc, tgenabled, tgisinternal from pg_trigger + where tgname ~ '^trg1' order by 1 +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +== 490 +create table trigpart3 (like trigpart) +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: CreateStmt +== 491 +create trigger trg1 after insert on trigpart3 for each row execute procedure trigger_nothing() +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: CreateTrigStmt +== 492 +alter table trigpart attach partition trigpart3 FOR VALUES FROM (2000) to (3000) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +== 493 +-- fail +drop table trigpart3 +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: DropStmt +== 494 +-- check display of unrelated triggers +create trigger samename after delete on trigpart execute function trigger_nothing() +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: CreateTrigStmt +== 495 +create trigger samename after delete on trigpart1 execute function trigger_nothing() +-- +TABLE: name="trigpart1" schema="" table="trigpart1" ctx=DDL +STMT: CreateTrigStmt +== 496 +drop table trigpart +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: DropStmt +== 497 +drop function trigger_nothing() +-- +FUNCTION: name="trigger_nothing" function="trigger_nothing" schema="" ctx=DDL +STMT: DropStmt +== 498 +|-- +-- Verify that triggers are fired for partitioned tables +|-- +create table parted_stmt_trig (a int) partition by list (a) +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateStmt +== 499 +create table parted_stmt_trig1 partition of parted_stmt_trig for values in (1) +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateStmt +== 500 +create table parted_stmt_trig2 partition of parted_stmt_trig for values in (2) +-- +TABLE: name="parted_stmt_trig2" schema="" table="parted_stmt_trig2" ctx=DDL +STMT: CreateStmt +== 501 +create table parted2_stmt_trig (a int) partition by list (a) +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateStmt +== 502 +create table parted2_stmt_trig1 partition of parted2_stmt_trig for values in (1) +-- +TABLE: name="parted2_stmt_trig1" schema="" table="parted2_stmt_trig1" ctx=DDL +STMT: CreateStmt +== 503 +create table parted2_stmt_trig2 partition of parted2_stmt_trig for values in (2) +-- +TABLE: name="parted2_stmt_trig2" schema="" table="parted2_stmt_trig2" ctx=DDL +STMT: CreateStmt +== 504 +create or replace function trigger_notice() returns trigger as $$ + begin + raise notice 'trigger % on % % % for %', TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL; + if TG_LEVEL = 'ROW' then + return NEW; + end if; + return null; + end; + $$ language plpgsql +-- +FUNCTION: name="trigger_notice" function="trigger_notice" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 505 +-- insert/update/delete statement-level triggers on the parent +create trigger trig_ins_before before insert on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 506 +create trigger trig_ins_after after insert on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 507 +create trigger trig_upd_before before update on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 508 +create trigger trig_upd_after after update on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 509 +create trigger trig_del_before before delete on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 510 +create trigger trig_del_after after delete on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 511 +-- insert/update/delete row-level triggers on the parent +create trigger trig_ins_after_parent after insert on parted_stmt_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 512 +create trigger trig_upd_after_parent after update on parted_stmt_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 513 +create trigger trig_del_after_parent after delete on parted_stmt_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 514 +-- insert/update/delete row-level triggers on the first partition +create trigger trig_ins_before_child before insert on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +== 515 +create trigger trig_ins_after_child after insert on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +== 516 +create trigger trig_upd_before_child before update on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +== 517 +create trigger trig_upd_after_child after update on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +== 518 +create trigger trig_del_before_child before delete on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +== 519 +create trigger trig_del_after_child after delete on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +== 520 +-- insert/update/delete statement-level triggers on the parent +create trigger trig_ins_before_3 before insert on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 521 +create trigger trig_ins_after_3 after insert on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 522 +create trigger trig_upd_before_3 before update on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 523 +create trigger trig_upd_after_3 after update on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 524 +create trigger trig_del_before_3 before delete on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 525 +create trigger trig_del_after_3 after delete on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +== 526 +with ins (a) as ( + insert into parted2_stmt_trig values (1), (2) returning a +) insert into parted_stmt_trig select a from ins returning tableoid::regclass, a +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DML +CTE: "ins" +STMT: InsertStmt +STMT: SelectStmt +== 527 +with upd as ( + update parted2_stmt_trig set a = a +) update parted_stmt_trig set a = a +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DML +CTE: "upd" +STMT: UpdateStmt +== 528 +delete from parted_stmt_trig +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +STMT: DeleteStmt +== 529 +-- insert via copy on the parent +copy parted_stmt_trig(a) from stdin +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=Select +STMT: CopyStmt +== 530 +-- insert via copy on the first partition +copy parted_stmt_trig1(a) from stdin +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=Select +STMT: CopyStmt +== 531 +-- Disabling a trigger in the parent table should disable children triggers too +alter table parted_stmt_trig disable trigger trig_ins_after_parent +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: AlterTableStmt +== 532 +insert into parted_stmt_trig values (1) +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 533 +alter table parted_stmt_trig enable trigger trig_ins_after_parent +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: AlterTableStmt +== 534 +insert into parted_stmt_trig values (1) +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 535 +drop table parted_stmt_trig, parted2_stmt_trig +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: DropStmt +== 536 +-- Verify that triggers fire in alphabetical order +create table parted_trig (a int) partition by range (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +== 537 +create table parted_trig_1 partition of parted_trig for values from (0) to (1000) + partition by range (a) +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateStmt +== 538 +create table parted_trig_1_1 partition of parted_trig_1 for values from (0) to (100) +-- +TABLE: name="parted_trig_1_1" schema="" table="parted_trig_1_1" ctx=DDL +STMT: CreateStmt +== 539 +create table parted_trig_2 partition of parted_trig for values from (1000) to (2000) +-- +TABLE: name="parted_trig_2" schema="" table="parted_trig_2" ctx=DDL +STMT: CreateStmt +== 540 +create trigger zzz after insert on parted_trig for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 541 +create trigger mmm after insert on parted_trig_1_1 for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig_1_1" schema="" table="parted_trig_1_1" ctx=DDL +STMT: CreateTrigStmt +== 542 +create trigger aaa after insert on parted_trig_1 for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateTrigStmt +== 543 +create trigger bbb after insert on parted_trig for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 544 +create trigger qqq after insert on parted_trig_1_1 for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig_1_1" schema="" table="parted_trig_1_1" ctx=DDL +STMT: CreateTrigStmt +== 545 +insert into parted_trig values (50), (1500) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 546 +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +== 547 +-- Verify that the correct triggers fire for cross-partition updates +create table parted_trig (a int) partition by list (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +== 548 +create table parted_trig1 partition of parted_trig for values in (1) +-- +TABLE: name="parted_trig1" schema="" table="parted_trig1" ctx=DDL +STMT: CreateStmt +== 549 +create table parted_trig2 partition of parted_trig for values in (2) +-- +TABLE: name="parted_trig2" schema="" table="parted_trig2" ctx=DDL +STMT: CreateStmt +== 550 +insert into parted_trig values (1) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 551 +create or replace function trigger_notice() returns trigger as $$ + begin + raise notice 'trigger % on % % % for %', TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL; + if TG_LEVEL = 'ROW' then + if TG_OP = 'DELETE' then + return OLD; + else + return NEW; + end if; + end if; + return null; + end; + $$ language plpgsql +-- +FUNCTION: name="trigger_notice" function="trigger_notice" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 552 +create trigger parted_trig_before_stmt before insert or update or delete on parted_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 553 +create trigger parted_trig_before_row before insert or update or delete on parted_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 554 +create trigger parted_trig_after_row after insert or update or delete on parted_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 555 +create trigger parted_trig_after_stmt after insert or update or delete on parted_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 556 +update parted_trig set a = 2 where a = 1 +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: UpdateStmt +== 557 +-- update action in merge should behave the same +merge into parted_trig using (select 1) as ss on true + when matched and a = 2 then update set a = 1 +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: MergeStmt +STMT: SelectStmt +== 558 +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +== 559 +-- Verify propagation of trigger arguments to partitions +create table parted_trig (a int) partition by list (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +== 560 +create table parted_trig1 partition of parted_trig for values in (1) +-- +TABLE: name="parted_trig1" schema="" table="parted_trig1" ctx=DDL +STMT: CreateStmt +== 561 +create or replace function trigger_notice() returns trigger as $$ + declare + arg1 text = TG_ARGV[0]; + arg2 integer = TG_ARGV[1]; + begin + raise notice 'trigger % on % % % for % args % %', + TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, arg1, arg2; + return null; + end; + $$ language plpgsql +-- +FUNCTION: name="trigger_notice" function="trigger_notice" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 562 +create trigger aaa after insert on parted_trig + for each row execute procedure trigger_notice('quirky', 1) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 563 +-- Verify propagation of trigger arguments to partitions attached after creating trigger +create table parted_trig2 partition of parted_trig for values in (2) +-- +TABLE: name="parted_trig2" schema="" table="parted_trig2" ctx=DDL +STMT: CreateStmt +== 564 +create table parted_trig3 (like parted_trig) +-- +TABLE: name="parted_trig3" schema="" table="parted_trig3" ctx=DDL +STMT: CreateStmt +== 565 +alter table parted_trig attach partition parted_trig3 for values in (3) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: AlterTableStmt +== 566 +insert into parted_trig values (1), (2), (3) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 567 +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +== 568 +-- test irregular partitions (i.e., different column definitions), +-- including that the WHEN clause works +create function bark(text) returns bool language plpgsql immutable + as $$ begin raise notice '% <- woof!', $1; return true; end; $$ +-- +FUNCTION: name="bark" function="bark" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 569 +create or replace function trigger_notice_ab() returns trigger as $$ + begin + raise notice 'trigger % on % % % for %: (a,b)=(%,%)', + TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, + NEW.a, NEW.b; + if TG_LEVEL = 'ROW' then + return NEW; + end if; + return null; + end; + $$ language plpgsql +-- +FUNCTION: name="trigger_notice_ab" function="trigger_notice_ab" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 570 +create table parted_irreg_ancestor (fd text, b text, fd2 int, fd3 int, a int) + partition by range (b) +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DDL +STMT: CreateStmt +== 571 +alter table parted_irreg_ancestor drop column fd, + drop column fd2, drop column fd3 +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DDL +STMT: AlterTableStmt +== 572 +create table parted_irreg (fd int, a int, fd2 int, b text) + partition by range (b) +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: CreateStmt +== 573 +alter table parted_irreg drop column fd, drop column fd2 +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: AlterTableStmt +== 574 +alter table parted_irreg_ancestor attach partition parted_irreg + for values from ('aaaa') to ('zzzz') +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DDL +STMT: AlterTableStmt +== 575 +create table parted1_irreg (b text, fd int, a int) +-- +TABLE: name="parted1_irreg" schema="" table="parted1_irreg" ctx=DDL +STMT: CreateStmt +== 576 +alter table parted1_irreg drop column fd +-- +TABLE: name="parted1_irreg" schema="" table="parted1_irreg" ctx=DDL +STMT: AlterTableStmt +== 577 +alter table parted_irreg attach partition parted1_irreg + for values from ('aaaa') to ('bbbb') +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: AlterTableStmt +== 578 +create trigger parted_trig after insert on parted_irreg + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: CreateTrigStmt +== 579 +create trigger parted_trig_odd after insert on parted_irreg for each row + when (bark(new.b) AND new.a % 2 = 1) execute procedure trigger_notice_ab() +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: CreateTrigStmt +== 580 +-- we should hear barking for every insert, but parted_trig_odd only emits +-- noise for odd values of a. parted_trig does it for all inserts. +insert into parted_irreg values (1, 'aardvark'), (2, 'aanimals') +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 581 +insert into parted1_irreg values ('aardwolf', 2) +-- +TABLE: name="parted1_irreg" schema="" table="parted1_irreg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 582 +insert into parted_irreg_ancestor values ('aasvogel', 3) +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 583 +drop table parted_irreg_ancestor +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DDL +STMT: DropStmt +== 584 +-- Before triggers and partitions +create table parted (a int, b int, c text) partition by list (a) +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateStmt +== 585 +create table parted_1 partition of parted for values in (1) + partition by list (b) +-- +TABLE: name="parted_1" schema="" table="parted_1" ctx=DDL +STMT: CreateStmt +== 586 +create table parted_1_1 partition of parted_1 for values in (1) +-- +TABLE: name="parted_1_1" schema="" table="parted_1_1" ctx=DDL +STMT: CreateStmt +== 587 +create function parted_trigfunc() returns trigger language plpgsql as $$ +begin + new.a = new.a + 1; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 588 +insert into parted values (1, 1, 'uno uno v1') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 589 +-- works +create trigger t before insert or update or delete on parted + for each row execute function parted_trigfunc() +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateTrigStmt +== 590 +insert into parted values (1, 1, 'uno uno v2') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 591 +-- fail +update parted set c = c || 'v3' +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +== 592 +-- fail +create or replace function parted_trigfunc() returns trigger language plpgsql as $$ +begin + new.b = new.b + 1; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 593 +insert into parted values (1, 1, 'uno uno v4') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 594 +-- fail +update parted set c = c || 'v5' +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +== 595 +-- fail +create or replace function parted_trigfunc() returns trigger language plpgsql as $$ +begin + new.c = new.c || ' did '|| TG_OP; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 596 +insert into parted values (1, 1, 'uno uno') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 597 +-- works +update parted set c = c || ' v6' +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +== 598 +-- works +select tableoid::regclass, * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +== 599 +-- update itself moves tuple to new partition; trigger still works +truncate table parted +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: TruncateStmt +== 600 +create table parted_2 partition of parted for values in (2) +-- +TABLE: name="parted_2" schema="" table="parted_2" ctx=DDL +STMT: CreateStmt +== 601 +insert into parted values (1, 1, 'uno uno v5') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 602 +update parted set a = 2 +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +== 603 +select tableoid::regclass, * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +== 604 +-- both trigger and update change the partition +create or replace function parted_trigfunc2() returns trigger language plpgsql as $$ +begin + new.a = new.a + 1; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc2" function="parted_trigfunc2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 605 +create trigger t2 before update on parted + for each row execute function parted_trigfunc2() +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateTrigStmt +== 606 +truncate table parted +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: TruncateStmt +== 607 +insert into parted values (1, 1, 'uno uno v6') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 608 +create table parted_3 partition of parted for values in (3) +-- +TABLE: name="parted_3" schema="" table="parted_3" ctx=DDL +STMT: CreateStmt +== 609 +update parted set a = a + 1 +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +== 610 +select tableoid::regclass, * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +== 611 +-- there's no partition for a=0, but this update works anyway because +-- the trigger causes the tuple to be routed to another partition +update parted set a = 0 +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +== 612 +select tableoid::regclass, * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +== 613 +drop table parted +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: DropStmt +== 614 +create table parted (a int, b int, c text) partition by list ((a + b)) +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateStmt +== 615 +create or replace function parted_trigfunc() returns trigger language plpgsql as $$ +begin + new.a = new.a + new.b; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 616 +create table parted_1 partition of parted for values in (1, 2) +-- +TABLE: name="parted_1" schema="" table="parted_1" ctx=DDL +STMT: CreateStmt +== 617 +create table parted_2 partition of parted for values in (3, 4) +-- +TABLE: name="parted_2" schema="" table="parted_2" ctx=DDL +STMT: CreateStmt +== 618 +create trigger t before insert or update on parted + for each row execute function parted_trigfunc() +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateTrigStmt +== 619 +insert into parted values (0, 1, 'zero win') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 620 +insert into parted values (1, 1, 'one fail') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 621 +insert into parted values (1, 2, 'two fail') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 622 +select * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +== 623 +drop table parted +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: DropStmt +== 624 +drop function parted_trigfunc() +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: DropStmt +== 625 +|-- +-- Constraint triggers and partitioned tables +create table parted_constr_ancestor (a int, b text) + partition by range (b) +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DDL +STMT: CreateStmt +== 626 +create table parted_constr (a int, b text) + partition by range (b) +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DDL +STMT: CreateStmt +== 627 +alter table parted_constr_ancestor attach partition parted_constr + for values from ('aaaa') to ('zzzz') +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DDL +STMT: AlterTableStmt +== 628 +create table parted1_constr (a int, b text) +-- +TABLE: name="parted1_constr" schema="" table="parted1_constr" ctx=DDL +STMT: CreateStmt +== 629 +alter table parted_constr attach partition parted1_constr + for values from ('aaaa') to ('bbbb') +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DDL +STMT: AlterTableStmt +== 630 +create constraint trigger parted_trig after insert on parted_constr_ancestor + deferrable + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DDL +STMT: CreateTrigStmt +== 631 +create constraint trigger parted_trig_two after insert on parted_constr + deferrable initially deferred + for each row when (bark(new.b) AND new.a % 2 = 1) + execute procedure trigger_notice_ab() +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DDL +STMT: CreateTrigStmt +== 632 +-- The immediate constraint is fired immediately; the WHEN clause of the +-- deferred constraint is also called immediately. The deferred constraint +-- is fired at commit time. +begin +-- +STMT: TransactionStmt +== 633 +insert into parted_constr values (1, 'aardvark') +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 634 +insert into parted1_constr values (2, 'aardwolf') +-- +TABLE: name="parted1_constr" schema="" table="parted1_constr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 635 +insert into parted_constr_ancestor values (3, 'aasvogel') +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 636 +commit +-- +STMT: TransactionStmt +== 637 +-- The WHEN clause is immediate, and both constraint triggers are fired at +-- commit time. +begin +-- +STMT: TransactionStmt +== 638 +set constraints parted_trig deferred +-- +STMT: ConstraintsSetStmt +== 639 +insert into parted_constr values (1, 'aardvark') +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 640 +insert into parted1_constr values (2, 'aardwolf'), (3, 'aasvogel') +-- +TABLE: name="parted1_constr" schema="" table="parted1_constr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 641 +commit +-- +STMT: TransactionStmt +== 642 +drop table parted_constr_ancestor +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DDL +STMT: DropStmt +== 643 +drop function bark(text) +-- +FUNCTION: name="bark" function="bark" schema="" ctx=DDL +STMT: DropStmt +== 644 +-- Test that the WHEN clause is set properly to partitions +create table parted_trigger (a int, b text) partition by range (a) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateStmt +== 645 +create table parted_trigger_1 partition of parted_trigger for values from (0) to (1000) +-- +TABLE: name="parted_trigger_1" schema="" table="parted_trigger_1" ctx=DDL +STMT: CreateStmt +== 646 +create table parted_trigger_2 (drp int, a int, b text) +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: CreateStmt +== 647 +alter table parted_trigger_2 drop column drp +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: AlterTableStmt +== 648 +alter table parted_trigger attach partition parted_trigger_2 for values from (1000) to (2000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +== 649 +create trigger parted_trigger after update on parted_trigger + for each row when (new.a % 2 = 1 and length(old.b) >= 2) execute procedure trigger_notice_ab() +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateTrigStmt +== 650 +create table parted_trigger_3 (b text, a int) partition by range (length(b)) +-- +TABLE: name="parted_trigger_3" schema="" table="parted_trigger_3" ctx=DDL +STMT: CreateStmt +== 651 +create table parted_trigger_3_1 partition of parted_trigger_3 for values from (1) to (3) +-- +TABLE: name="parted_trigger_3_1" schema="" table="parted_trigger_3_1" ctx=DDL +STMT: CreateStmt +== 652 +create table parted_trigger_3_2 partition of parted_trigger_3 for values from (3) to (5) +-- +TABLE: name="parted_trigger_3_2" schema="" table="parted_trigger_3_2" ctx=DDL +STMT: CreateStmt +== 653 +alter table parted_trigger attach partition parted_trigger_3 for values from (2000) to (3000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +== 654 +insert into parted_trigger values + (0, 'a'), (1, 'bbb'), (2, 'bcd'), (3, 'c'), + (1000, 'c'), (1001, 'ddd'), (1002, 'efg'), (1003, 'f'), + (2000, 'e'), (2001, 'fff'), (2002, 'ghi'), (2003, 'h') +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 655 +update parted_trigger set a = a + 2 +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: UpdateStmt +== 656 +-- notice for odd 'a' values, long 'b' values +drop table parted_trigger +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: DropStmt +== 657 +-- try a constraint trigger, also +create table parted_referenced (a int) +-- +TABLE: name="parted_referenced" schema="" table="parted_referenced" ctx=DDL +STMT: CreateStmt +== 658 +create table unparted_trigger (a int, b text) +-- +TABLE: name="unparted_trigger" schema="" table="unparted_trigger" ctx=DDL +STMT: CreateStmt +== 659 +-- for comparison purposes +create table parted_trigger (a int, b text) partition by range (a) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateStmt +== 660 +create table parted_trigger_1 partition of parted_trigger for values from (0) to (1000) +-- +TABLE: name="parted_trigger_1" schema="" table="parted_trigger_1" ctx=DDL +STMT: CreateStmt +== 661 +create table parted_trigger_2 (drp int, a int, b text) +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: CreateStmt +== 662 +alter table parted_trigger_2 drop column drp +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: AlterTableStmt +== 663 +alter table parted_trigger attach partition parted_trigger_2 for values from (1000) to (2000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +== 664 +create constraint trigger parted_trigger after update on parted_trigger + from parted_referenced + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateTrigStmt +== 665 +create constraint trigger parted_trigger after update on unparted_trigger + from parted_referenced + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="unparted_trigger" schema="" table="unparted_trigger" ctx=DDL +STMT: CreateTrigStmt +== 666 +create table parted_trigger_3 (b text, a int) partition by range (length(b)) +-- +TABLE: name="parted_trigger_3" schema="" table="parted_trigger_3" ctx=DDL +STMT: CreateStmt +== 667 +create table parted_trigger_3_1 partition of parted_trigger_3 for values from (1) to (3) +-- +TABLE: name="parted_trigger_3_1" schema="" table="parted_trigger_3_1" ctx=DDL +STMT: CreateStmt +== 668 +create table parted_trigger_3_2 partition of parted_trigger_3 for values from (3) to (5) +-- +TABLE: name="parted_trigger_3_2" schema="" table="parted_trigger_3_2" ctx=DDL +STMT: CreateStmt +== 669 +alter table parted_trigger attach partition parted_trigger_3 for values from (2000) to (3000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +== 670 +select tgname, conname, t.tgrelid::regclass, t.tgconstrrelid::regclass, + c.conrelid::regclass, c.confrelid::regclass + from pg_trigger t join pg_constraint c on (t.tgconstraint = c.oid) + where tgname = 'parted_trigger' + order by t.tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "t"="pg_trigger" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +== 671 +drop table parted_referenced, parted_trigger, unparted_trigger +-- +TABLE: name="parted_referenced" schema="" table="parted_referenced" ctx=DDL +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +TABLE: name="unparted_trigger" schema="" table="unparted_trigger" ctx=DDL +STMT: DropStmt +== 672 +-- verify that the "AFTER UPDATE OF columns" event is propagated correctly +create table parted_trigger (a int, b text) partition by range (a) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateStmt +== 673 +create table parted_trigger_1 partition of parted_trigger for values from (0) to (1000) +-- +TABLE: name="parted_trigger_1" schema="" table="parted_trigger_1" ctx=DDL +STMT: CreateStmt +== 674 +create table parted_trigger_2 (drp int, a int, b text) +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: CreateStmt +== 675 +alter table parted_trigger_2 drop column drp +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: AlterTableStmt +== 676 +alter table parted_trigger attach partition parted_trigger_2 for values from (1000) to (2000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +== 677 +create trigger parted_trigger after update of b on parted_trigger + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateTrigStmt +== 678 +create table parted_trigger_3 (b text, a int) partition by range (length(b)) +-- +TABLE: name="parted_trigger_3" schema="" table="parted_trigger_3" ctx=DDL +STMT: CreateStmt +== 679 +create table parted_trigger_3_1 partition of parted_trigger_3 for values from (1) to (4) +-- +TABLE: name="parted_trigger_3_1" schema="" table="parted_trigger_3_1" ctx=DDL +STMT: CreateStmt +== 680 +create table parted_trigger_3_2 partition of parted_trigger_3 for values from (4) to (8) +-- +TABLE: name="parted_trigger_3_2" schema="" table="parted_trigger_3_2" ctx=DDL +STMT: CreateStmt +== 681 +alter table parted_trigger attach partition parted_trigger_3 for values from (2000) to (3000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +== 682 +insert into parted_trigger values (0, 'a'), (1000, 'c'), (2000, 'e'), (2001, 'eeee') +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 683 +update parted_trigger set a = a + 2 +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: UpdateStmt +== 684 +-- no notices here +update parted_trigger set b = b || 'b' +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: UpdateStmt +== 685 +-- all triggers should fire +drop table parted_trigger +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: DropStmt +== 686 +drop function trigger_notice_ab() +-- +FUNCTION: name="trigger_notice_ab" function="trigger_notice_ab" schema="" ctx=DDL +STMT: DropStmt +== 687 +-- Make sure we don't end up with unnecessary copies of triggers, when +-- cloning them. +create table trg_clone (a int) partition by range (a) +-- +TABLE: name="trg_clone" schema="" table="trg_clone" ctx=DDL +STMT: CreateStmt +== 688 +create table trg_clone1 partition of trg_clone for values from (0) to (1000) +-- +TABLE: name="trg_clone1" schema="" table="trg_clone1" ctx=DDL +STMT: CreateStmt +== 689 +alter table trg_clone add constraint uniq unique (a) deferrable +-- +TABLE: name="trg_clone" schema="" table="trg_clone" ctx=DDL +STMT: AlterTableStmt +== 690 +create table trg_clone2 partition of trg_clone for values from (1000) to (2000) +-- +TABLE: name="trg_clone2" schema="" table="trg_clone2" ctx=DDL +STMT: CreateStmt +== 691 +create table trg_clone3 partition of trg_clone for values from (2000) to (3000) + partition by range (a) +-- +TABLE: name="trg_clone3" schema="" table="trg_clone3" ctx=DDL +STMT: CreateStmt +== 692 +create table trg_clone_3_3 partition of trg_clone3 for values from (2000) to (2100) +-- +TABLE: name="trg_clone_3_3" schema="" table="trg_clone_3_3" ctx=DDL +STMT: CreateStmt +== 693 +select tgrelid::regclass, count(*) from pg_trigger + where tgrelid::regclass in ('trg_clone', 'trg_clone1', 'trg_clone2', + 'trg_clone3', 'trg_clone_3_3') + group by tgrelid::regclass order by tgrelid::regclass +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 694 +drop table trg_clone +-- +TABLE: name="trg_clone" schema="" table="trg_clone" ctx=DDL +STMT: DropStmt +== 695 +-- Test the interaction between ALTER TABLE .. DISABLE TRIGGER and +-- both kinds of inheritance. Historically, legacy inheritance has +-- not recursed to children, so that behavior is preserved. +create table parent (a int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 696 +create table child1 () inherits (parent) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +== 697 +create function trig_nothing() returns trigger language plpgsql + as $$ begin return null; end $$ +-- +FUNCTION: name="trig_nothing" function="trig_nothing" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 698 +create trigger tg after insert on parent + for each row execute function trig_nothing() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 699 +create trigger tg after insert on child1 + for each row execute function trig_nothing() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +== 700 +alter table parent disable trigger tg +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 701 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 702 +alter table only parent enable always trigger tg +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 703 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 704 +drop table parent, child1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 705 +create table parent (a int) partition by list (a) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 706 +create table child1 partition of parent for values in (1) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +== 707 +create trigger tg after insert on parent + for each row execute procedure trig_nothing() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 708 +create trigger tg_stmt after insert on parent + for statement execute procedure trig_nothing() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 709 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgname +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 710 +alter table only parent enable always trigger tg +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 711 +-- no recursion because ONLY +alter table parent enable always trigger tg_stmt +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 712 +-- no recursion because statement trigger +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgname +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 713 +-- The following is a no-op for the parent trigger but not so +-- for the child trigger, so recursion should be applied. +alter table parent enable always trigger tg +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 714 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgname +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 715 +-- This variant malfunctioned in some releases. +alter table parent disable trigger user +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 716 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgname +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 717 +drop table parent, child1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 718 +-- Check processing of foreign key triggers +create table parent (a int primary key, f int references parent) + partition by list (a) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 719 +create table child1 partition of parent for values in (1) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +== 720 +select tgrelid::regclass, rtrim(tgname, '0123456789') as tgname, + tgfoid::regproc, tgenabled + from pg_trigger where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgfoid +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="rtrim" function="rtrim" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 721 +alter table parent disable trigger all +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 722 +select tgrelid::regclass, rtrim(tgname, '0123456789') as tgname, + tgfoid::regproc, tgenabled + from pg_trigger where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgfoid +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="rtrim" function="rtrim" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +== 723 +drop table parent, child1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 724 +-- Verify that firing state propagates correctly on creation, too +CREATE TABLE trgfire (i int) PARTITION BY RANGE (i) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: CreateStmt +== 725 +CREATE TABLE trgfire1 PARTITION OF trgfire FOR VALUES FROM (1) TO (10) +-- +TABLE: name="trgfire1" schema="" table="trgfire1" ctx=DDL +STMT: CreateStmt +== 726 +CREATE OR REPLACE FUNCTION tgf() RETURNS trigger LANGUAGE plpgsql + AS $$ begin raise exception 'except'; end $$ +-- +FUNCTION: name="tgf" function="tgf" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 727 +CREATE TRIGGER tg AFTER INSERT ON trgfire FOR EACH ROW EXECUTE FUNCTION tgf() +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: CreateTrigStmt +== 728 +INSERT INTO trgfire VALUES (1) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 729 +ALTER TABLE trgfire DISABLE TRIGGER tg +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: AlterTableStmt +== 730 +INSERT INTO trgfire VALUES (1) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 731 +CREATE TABLE trgfire2 PARTITION OF trgfire FOR VALUES FROM (10) TO (20) +-- +TABLE: name="trgfire2" schema="" table="trgfire2" ctx=DDL +STMT: CreateStmt +== 732 +INSERT INTO trgfire VALUES (11) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 733 +CREATE TABLE trgfire3 (LIKE trgfire) +-- +TABLE: name="trgfire3" schema="" table="trgfire3" ctx=DDL +STMT: CreateStmt +== 734 +ALTER TABLE trgfire ATTACH PARTITION trgfire3 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: AlterTableStmt +== 735 +INSERT INTO trgfire VALUES (21) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 736 +CREATE TABLE trgfire4 PARTITION OF trgfire FOR VALUES FROM (30) TO (40) PARTITION BY LIST (i) +-- +TABLE: name="trgfire4" schema="" table="trgfire4" ctx=DDL +STMT: CreateStmt +== 737 +CREATE TABLE trgfire4_30 PARTITION OF trgfire4 FOR VALUES IN (30) +-- +TABLE: name="trgfire4_30" schema="" table="trgfire4_30" ctx=DDL +STMT: CreateStmt +== 738 +INSERT INTO trgfire VALUES (30) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 739 +CREATE TABLE trgfire5 (LIKE trgfire) PARTITION BY LIST (i) +-- +TABLE: name="trgfire5" schema="" table="trgfire5" ctx=DDL +STMT: CreateStmt +== 740 +CREATE TABLE trgfire5_40 PARTITION OF trgfire5 FOR VALUES IN (40) +-- +TABLE: name="trgfire5_40" schema="" table="trgfire5_40" ctx=DDL +STMT: CreateStmt +== 741 +ALTER TABLE trgfire ATTACH PARTITION trgfire5 FOR VALUES FROM (40) TO (50) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: AlterTableStmt +== 742 +INSERT INTO trgfire VALUES (40) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 743 +SELECT tgrelid::regclass, tgenabled FROM pg_trigger + WHERE tgrelid::regclass IN (SELECT oid from pg_class where relname LIKE 'trgfire%') + ORDER BY tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 744 +ALTER TABLE trgfire ENABLE TRIGGER tg +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: AlterTableStmt +== 745 +INSERT INTO trgfire VALUES (1) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 746 +INSERT INTO trgfire VALUES (11) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 747 +INSERT INTO trgfire VALUES (21) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 748 +INSERT INTO trgfire VALUES (30) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 749 +INSERT INTO trgfire VALUES (40) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 750 +DROP TABLE trgfire +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: DropStmt +== 751 +DROP FUNCTION tgf() +-- +FUNCTION: name="tgf" function="tgf" schema="" ctx=DDL +STMT: DropStmt +== 752 +|-- +-- Test the interaction between transition tables and both kinds of +-- inheritance. We'll dump the contents of the transition tables in a +-- format that shows the attribute order, so that we can distinguish +-- tuple formats (though not dropped attributes). +|-- + +create or replace function dump_insert() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, new table = %', + TG_NAME, + (select string_agg(new_table::text, ', ' order by a) from new_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_insert" function="dump_insert" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 753 +create or replace function dump_update() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, old table = %, new table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' order by a) from old_table), + (select string_agg(new_table::text, ', ' order by a) from new_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_update" function="dump_update" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 754 +create or replace function dump_delete() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, old table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' order by a) from old_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_delete" function="dump_delete" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 755 +|-- +-- Verify behavior of statement triggers on partition hierarchy with +-- transition tables. Tuples should appear to each trigger in the +-- format of the relation the trigger is attached to. +|-- + +-- set up a partition hierarchy with some different TupleDescriptors +create table parent (a text, b int) partition by list (a) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 756 +-- a child matching parent +create table child1 partition of parent for values in ('AAA') +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +== 757 +-- a child with a dropped column +create table child2 (x int, a text, b int) +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateStmt +== 758 +alter table child2 drop column x +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: AlterTableStmt +== 759 +alter table parent attach partition child2 for values in ('BBB') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 760 +-- a child with a different column order +create table child3 (b int, a text) +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateStmt +== 761 +alter table parent attach partition child3 for values in ('CCC') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 762 +create trigger parent_insert_trig + after insert on parent referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 763 +create trigger parent_update_trig + after update on parent referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 764 +create trigger parent_delete_trig + after delete on parent referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 765 +create trigger child1_insert_trig + after insert on child1 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +== 766 +create trigger child1_update_trig + after update on child1 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +== 767 +create trigger child1_delete_trig + after delete on child1 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +== 768 +create trigger child2_insert_trig + after insert on child2 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +== 769 +create trigger child2_update_trig + after update on child2 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +== 770 +create trigger child2_delete_trig + after delete on child2 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +== 771 +create trigger child3_insert_trig + after insert on child3 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +== 772 +create trigger child3_update_trig + after update on child3 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +== 773 +create trigger child3_delete_trig + after delete on child3 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +== 774 +SELECT trigger_name, event_manipulation, event_object_schema, event_object_table, + action_order, action_condition, action_orientation, action_timing, + action_reference_old_table, action_reference_new_table + FROM information_schema.triggers + WHERE event_object_table IN ('parent', 'child1', 'child2', 'child3') + ORDER BY trigger_name COLLATE "C", 2 +-- +TABLE: name="information_schema.triggers" schema="information_schema" table="triggers" ctx=Select +FILTER: schema="" table="" column="event_object_table" +STMT: SelectStmt +== 775 +-- insert directly into children sees respective child-format tuples +insert into child1 values ('AAA', 42) +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 776 +insert into child2 values ('BBB', 42) +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 777 +insert into child3 values (42, 'CCC') +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 778 +-- update via parent sees parent-format tuples +update parent set b = b + 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: UpdateStmt +== 779 +-- delete via parent sees parent-format tuples +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +== 780 +-- insert into parent sees parent-format tuples +insert into parent values ('AAA', 42) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 781 +insert into parent values ('BBB', 42) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 782 +insert into parent values ('CCC', 42) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 783 +-- delete from children sees respective child-format tuples +delete from child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: DeleteStmt +== 784 +delete from child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: DeleteStmt +== 785 +delete from child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: DeleteStmt +== 786 +-- copy into parent sees parent-format tuples +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +== 787 +-- check detach/reattach behavior; statement triggers with transition tables +-- should not prevent a table from becoming a partition again +alter table parent detach partition child1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 788 +alter table parent attach partition child1 for values in ('AAA') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 789 +-- DML affecting parent sees tuples collected from children even if +-- there is no transition table trigger on the children +drop trigger child1_insert_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 790 +drop trigger child1_update_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 791 +drop trigger child1_delete_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 792 +drop trigger child2_insert_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +== 793 +drop trigger child2_update_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +== 794 +drop trigger child2_delete_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +== 795 +drop trigger child3_insert_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +== 796 +drop trigger child3_update_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +== 797 +drop trigger child3_delete_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +== 798 +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +== 799 +-- copy into parent sees tuples collected from children even if there +-- is no transition-table trigger on the children +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +== 800 +-- insert into parent with a before trigger on a child tuple before +-- insertion, and we capture the newly modified row in parent format +create or replace function intercept_insert() returns trigger language plpgsql as +$$ + begin + new.b = new.b + 1000; + return new; + end; +$$ +-- +FUNCTION: name="intercept_insert" function="intercept_insert" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 801 +create trigger intercept_insert_child3 + before insert on child3 + for each row execute procedure intercept_insert() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +== 802 +-- insert, parent trigger sees post-modification parent-format tuple +insert into parent values ('AAA', 42), ('BBB', 42), ('CCC', 66) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 803 +-- copy, parent trigger sees post-modification parent-format tuple +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +== 804 +drop table child1, child2, child3, parent +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +TABLE: name="child2" schema="" table="child2" ctx=DDL +TABLE: name="child3" schema="" table="child3" ctx=DDL +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +== 805 +drop function intercept_insert() +-- +FUNCTION: name="intercept_insert" function="intercept_insert" schema="" ctx=DDL +STMT: DropStmt +== 806 +|-- +-- Verify prohibition of row triggers with transition triggers on +-- partitions +|-- +create table parent (a text, b int) partition by list (a) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 807 +create table child partition of parent for values in ('AAA') +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 808 +-- adding row trigger with transition table fails +create trigger child_row_trig + after insert on child referencing new table as new_table + for each row execute procedure dump_insert() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +== 809 +-- detaching it first works +alter table parent detach partition child +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 810 +create trigger child_row_trig + after insert on child referencing new table as new_table + for each row execute procedure dump_insert() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +== 811 +-- but now we're not allowed to reattach it +alter table parent attach partition child for values in ('AAA') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 812 +-- drop the trigger, and now we're allowed to attach it again +drop trigger child_row_trig on child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +== 813 +alter table parent attach partition child for values in ('AAA') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +== 814 +drop table child, parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +== 815 +|-- +-- Verify access of transition tables with UPDATE triggers and tuples +-- moved across partitions. +|-- +create or replace function dump_update_new() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, new table = %', TG_NAME, + (select string_agg(new_table::text, ', ' order by a) from new_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_update_new" function="dump_update_new" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 816 +create or replace function dump_update_old() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, old table = %', TG_NAME, + (select string_agg(old_table::text, ', ' order by a) from old_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_update_old" function="dump_update_old" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 817 +create table trans_tab_parent (a text) partition by list (a) +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateStmt +== 818 +create table trans_tab_child1 partition of trans_tab_parent for values in ('AAA1', 'AAA2') +-- +TABLE: name="trans_tab_child1" schema="" table="trans_tab_child1" ctx=DDL +STMT: CreateStmt +== 819 +create table trans_tab_child2 partition of trans_tab_parent for values in ('BBB1', 'BBB2') +-- +TABLE: name="trans_tab_child2" schema="" table="trans_tab_child2" ctx=DDL +STMT: CreateStmt +== 820 +create trigger trans_tab_parent_update_trig + after update on trans_tab_parent referencing old table as old_table + for each statement execute procedure dump_update_old() +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateTrigStmt +== 821 +create trigger trans_tab_parent_insert_trig + after insert on trans_tab_parent referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateTrigStmt +== 822 +create trigger trans_tab_parent_delete_trig + after delete on trans_tab_parent referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateTrigStmt +== 823 +insert into trans_tab_parent values ('AAA1'), ('BBB1') +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 824 +-- should not trigger access to new table when moving across partitions. +update trans_tab_parent set a = 'BBB2' where a = 'AAA1' +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DML +STMT: UpdateStmt +== 825 +drop trigger trans_tab_parent_update_trig on trans_tab_parent +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: DropStmt +== 826 +create trigger trans_tab_parent_update_trig + after update on trans_tab_parent referencing new table as new_table + for each statement execute procedure dump_update_new() +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateTrigStmt +== 827 +-- should not trigger access to old table when moving across partitions. +update trans_tab_parent set a = 'AAA2' where a = 'BBB1' +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DML +STMT: UpdateStmt +== 828 +delete from trans_tab_parent +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DML +STMT: DeleteStmt +== 829 +-- clean up +drop table trans_tab_parent, trans_tab_child1, trans_tab_child2 +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +TABLE: name="trans_tab_child1" schema="" table="trans_tab_child1" ctx=DDL +TABLE: name="trans_tab_child2" schema="" table="trans_tab_child2" ctx=DDL +STMT: DropStmt +== 830 +drop function dump_update_new, dump_update_old +-- +FUNCTION: name="dump_update_new" function="dump_update_new" schema="" ctx=DDL +STMT: DropStmt +== 831 +|-- +-- Verify behavior of statement triggers on (non-partition) +-- inheritance hierarchy with transition tables; similar to the +-- partition case, except there is no rerouting on insertion and child +-- tables can have extra columns +|-- + +-- set up inheritance hierarchy with different TupleDescriptors +create table parent (a text, b int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 832 +-- a child matching parent +create table child1 () inherits (parent) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +== 833 +-- a child with a different column order +create table child2 (b int, a text) +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateStmt +== 834 +alter table child2 inherit parent +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: AlterTableStmt +== 835 +-- a child with an extra column +create table child3 (c text) inherits (parent) +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateStmt +== 836 +create trigger parent_insert_trig + after insert on parent referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 837 +create trigger parent_update_trig + after update on parent referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 838 +create trigger parent_delete_trig + after delete on parent referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 839 +create trigger child1_insert_trig + after insert on child1 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +== 840 +create trigger child1_update_trig + after update on child1 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +== 841 +create trigger child1_delete_trig + after delete on child1 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +== 842 +create trigger child2_insert_trig + after insert on child2 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +== 843 +create trigger child2_update_trig + after update on child2 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +== 844 +create trigger child2_delete_trig + after delete on child2 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +== 845 +create trigger child3_insert_trig + after insert on child3 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +== 846 +create trigger child3_update_trig + after update on child3 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +== 847 +create trigger child3_delete_trig + after delete on child3 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +== 848 +-- insert directly into children sees respective child-format tuples +insert into child1 values ('AAA', 42) +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 849 +insert into child2 values (42, 'BBB') +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 850 +insert into child3 values ('CCC', 42, 'foo') +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 851 +-- update via parent sees parent-format tuples +update parent set b = b + 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: UpdateStmt +== 852 +-- delete via parent sees parent-format tuples +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +== 853 +-- reinsert values into children for next test... +insert into child1 values ('AAA', 42) +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 854 +insert into child2 values (42, 'BBB') +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 855 +insert into child3 values ('CCC', 42, 'foo') +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 856 +-- delete from children sees respective child-format tuples +delete from child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: DeleteStmt +== 857 +delete from child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: DeleteStmt +== 858 +delete from child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: DeleteStmt +== 859 +-- copy into parent sees parent-format tuples (no rerouting, so these +-- are really inserted into the parent) +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +== 860 +-- same behavior for copy if there is an index (interesting because rows are +-- captured by a different code path in copyfrom.c if there are indexes) +create index on parent(b) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: IndexStmt +== 861 +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +== 862 +-- check disinherit/reinherit behavior; statement triggers with transition +-- tables should not prevent a table from becoming an inheritance child again +alter table child1 no inherit parent +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: AlterTableStmt +== 863 +alter table child1 inherit parent +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: AlterTableStmt +== 864 +-- DML affecting parent sees tuples collected from children even if +-- there is no transition table trigger on the children +drop trigger child1_insert_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 865 +drop trigger child1_update_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 866 +drop trigger child1_delete_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +== 867 +drop trigger child2_insert_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +== 868 +drop trigger child2_update_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +== 869 +drop trigger child2_delete_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +== 870 +drop trigger child3_insert_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +== 871 +drop trigger child3_update_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +== 872 +drop trigger child3_delete_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +== 873 +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +== 874 +drop table child1, child2, child3, parent +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +TABLE: name="child2" schema="" table="child2" ctx=DDL +TABLE: name="child3" schema="" table="child3" ctx=DDL +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +== 875 +|-- +-- Verify prohibition of row triggers with transition triggers on +-- inheritance children +|-- +create table parent (a text, b int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 876 +create table child () inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 877 +-- adding row trigger with transition table fails +create trigger child_row_trig + after insert on child referencing new table as new_table + for each row execute procedure dump_insert() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +== 878 +-- disinheriting it first works +alter table child no inherit parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +== 879 +create trigger child_row_trig + after insert on child referencing new table as new_table + for each row execute procedure dump_insert() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +== 880 +-- but now we're not allowed to make it inherit anymore +alter table child inherit parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +== 881 +-- drop the trigger, and now we're allowed to make it inherit again +drop trigger child_row_trig on child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +== 882 +alter table child inherit parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +== 883 +drop table child, parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +== 884 +|-- +-- Verify behavior of queries with wCTEs, where multiple transition +-- tuplestores can be active at the same time because there are +-- multiple DML statements that might fire triggers with transition +-- tables +|-- +create table table1 (a int) +-- +TABLE: name="table1" schema="" table="table1" ctx=DDL +STMT: CreateStmt +== 885 +create table table2 (a text) +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: CreateStmt +== 886 +create trigger table1_trig + after insert on table1 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="table1" schema="" table="table1" ctx=DDL +STMT: CreateTrigStmt +== 887 +create trigger table2_trig + after insert on table2 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: CreateTrigStmt +== 888 +with wcte as (insert into table1 values (42)) + insert into table2 values ('hello world') +-- +TABLE: name="table2" schema="" table="table2" ctx=DML +TABLE: name="table1" schema="" table="table1" ctx=DML +CTE: "wcte" +STMT: InsertStmt +STMT: SelectStmt +== 889 +with wcte as (insert into table1 values (43)) + insert into table1 values (44) +-- +TABLE: name="table1" schema="" table="table1" ctx=DML +TABLE: name="table1" schema="" table="table1" ctx=DML +CTE: "wcte" +STMT: InsertStmt +STMT: SelectStmt +== 890 +select * from table1 +-- +TABLE: name="table1" schema="" table="table1" ctx=Select +STMT: SelectStmt +== 891 +select * from table2 +-- +TABLE: name="table2" schema="" table="table2" ctx=Select +STMT: SelectStmt +== 892 +drop table table1 +-- +TABLE: name="table1" schema="" table="table1" ctx=DDL +STMT: DropStmt +== 893 +drop table table2 +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: DropStmt +== 894 +|-- +-- Verify behavior of INSERT ... ON CONFLICT DO UPDATE ... with +-- transition tables. +|-- + +create table my_table (a int primary key, b text) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateStmt +== 895 +create trigger my_table_insert_trig + after insert on my_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +== 896 +create trigger my_table_update_trig + after update on my_table referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +== 897 +-- inserts only +insert into my_table values (1, 'AAA'), (2, 'BBB') + on conflict (a) do + update set b = my_table.b || ':' || excluded.b +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 898 +-- mixture of inserts and updates +insert into my_table values (1, 'AAA'), (2, 'BBB'), (3, 'CCC'), (4, 'DDD') + on conflict (a) do + update set b = my_table.b || ':' || excluded.b +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 899 +-- updates only +insert into my_table values (3, 'CCC'), (4, 'DDD') + on conflict (a) do + update set b = my_table.b || ':' || excluded.b +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 900 +|-- +-- now using a partitioned table +|-- + +create table iocdu_tt_parted (a int primary key, b text) partition by list (a) +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DDL +STMT: CreateStmt +== 901 +create table iocdu_tt_parted1 partition of iocdu_tt_parted for values in (1) +-- +TABLE: name="iocdu_tt_parted1" schema="" table="iocdu_tt_parted1" ctx=DDL +STMT: CreateStmt +== 902 +create table iocdu_tt_parted2 partition of iocdu_tt_parted for values in (2) +-- +TABLE: name="iocdu_tt_parted2" schema="" table="iocdu_tt_parted2" ctx=DDL +STMT: CreateStmt +== 903 +create table iocdu_tt_parted3 partition of iocdu_tt_parted for values in (3) +-- +TABLE: name="iocdu_tt_parted3" schema="" table="iocdu_tt_parted3" ctx=DDL +STMT: CreateStmt +== 904 +create table iocdu_tt_parted4 partition of iocdu_tt_parted for values in (4) +-- +TABLE: name="iocdu_tt_parted4" schema="" table="iocdu_tt_parted4" ctx=DDL +STMT: CreateStmt +== 905 +create trigger iocdu_tt_parted_insert_trig + after insert on iocdu_tt_parted referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DDL +STMT: CreateTrigStmt +== 906 +create trigger iocdu_tt_parted_update_trig + after update on iocdu_tt_parted referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DDL +STMT: CreateTrigStmt +== 907 +-- inserts only +insert into iocdu_tt_parted values (1, 'AAA'), (2, 'BBB') + on conflict (a) do + update set b = iocdu_tt_parted.b || ':' || excluded.b +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 908 +-- mixture of inserts and updates +insert into iocdu_tt_parted values (1, 'AAA'), (2, 'BBB'), (3, 'CCC'), (4, 'DDD') + on conflict (a) do + update set b = iocdu_tt_parted.b || ':' || excluded.b +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 909 +-- updates only +insert into iocdu_tt_parted values (3, 'CCC'), (4, 'DDD') + on conflict (a) do + update set b = iocdu_tt_parted.b || ':' || excluded.b +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 910 +drop table iocdu_tt_parted +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DDL +STMT: DropStmt +== 911 +|-- +-- Verify that you can't create a trigger with transition tables for +-- more than one event. +|-- + +create trigger my_table_multievent_trig + after insert or update on my_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +== 912 +|-- +-- Verify that you can't create a trigger with transition tables with +-- a column list. +|-- + +create trigger my_table_col_update_trig + after update of b on my_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +== 913 +drop table my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: DropStmt +== 914 +|-- +-- Test firing of triggers with transition tables by foreign key cascades +|-- + +create table refd_table (a int primary key, b text) +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DDL +STMT: CreateStmt +== 915 +create table trig_table (a int, b text, + foreign key (a) references refd_table on update cascade on delete cascade +) +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateStmt +== 916 +create trigger trig_table_before_trig + before insert or update or delete on trig_table + for each statement execute procedure trigger_func('trig_table') +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateTrigStmt +== 917 +create trigger trig_table_insert_trig + after insert on trig_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateTrigStmt +== 918 +create trigger trig_table_update_trig + after update on trig_table referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateTrigStmt +== 919 +create trigger trig_table_delete_trig + after delete on trig_table referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateTrigStmt +== 920 +insert into refd_table values + (1, 'one'), + (2, 'two'), + (3, 'three') +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 921 +insert into trig_table values + (1, 'one a'), + (1, 'one b'), + (2, 'two a'), + (2, 'two b'), + (3, 'three a'), + (3, 'three b') +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 922 +update refd_table set a = 11 where b = 'one' +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DML +STMT: UpdateStmt +== 923 +select * from trig_table +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=Select +STMT: SelectStmt +== 924 +delete from refd_table where length(b) = 3 +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DML +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: DeleteStmt +== 925 +select * from trig_table +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=Select +STMT: SelectStmt +== 926 +drop table refd_table, trig_table +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DDL +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: DropStmt +== 927 +|-- +-- Test that we can drop a not-yet-fired deferred trigger +|-- + +create table refd_table (id int primary key) +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DDL +STMT: CreateStmt +== 928 +create table trig_table (fk int references refd_table initially deferred) +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateStmt +== 929 +begin +-- +STMT: TransactionStmt +== 930 +insert into trig_table values (1) +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 931 +drop table refd_table cascade +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DDL +STMT: DropStmt +== 932 +commit +-- +STMT: TransactionStmt +== 933 +drop table trig_table +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: DropStmt +== 934 +|-- +-- self-referential FKs are even more fun +|-- + +create table self_ref (a int primary key, + b int references self_ref(a) on delete cascade) +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: CreateStmt +== 935 +create trigger self_ref_before_trig + before delete on self_ref + for each statement execute procedure trigger_func('self_ref') +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: CreateTrigStmt +== 936 +create trigger self_ref_r_trig + after delete on self_ref referencing old table as old_table + for each row execute procedure dump_delete() +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: CreateTrigStmt +== 937 +create trigger self_ref_s_trig + after delete on self_ref referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: CreateTrigStmt +== 938 +insert into self_ref values (1, null), (2, 1), (3, 2) +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 939 +delete from self_ref where a = 1 +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DML +STMT: DeleteStmt +== 940 +-- without AR trigger, cascaded deletes all end up in one transition table +drop trigger self_ref_r_trig on self_ref +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: DropStmt +== 941 +insert into self_ref values (1, null), (2, 1), (3, 2), (4, 3) +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 942 +delete from self_ref where a = 1 +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DML +STMT: DeleteStmt +== 943 +drop table self_ref +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: DropStmt +== 944 +|-- +-- test transition tables with MERGE +|-- +create table merge_target_table (a int primary key, b text) +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: CreateStmt +== 945 +create trigger merge_target_table_insert_trig + after insert on merge_target_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: CreateTrigStmt +== 946 +create trigger merge_target_table_update_trig + after update on merge_target_table referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: CreateTrigStmt +== 947 +create trigger merge_target_table_delete_trig + after delete on merge_target_table referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: CreateTrigStmt +== 948 +create table merge_source_table (a int, b text) +-- +TABLE: name="merge_source_table" schema="" table="merge_source_table" ctx=DDL +STMT: CreateStmt +== 949 +insert into merge_source_table + values (1, 'initial1'), (2, 'initial2'), + (3, 'initial3'), (4, 'initial4') +-- +TABLE: name="merge_source_table" schema="" table="merge_source_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 950 +merge into merge_target_table t +using merge_source_table s +on t.a = s.a +when not matched then + insert values (a, b) +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DML +ALIAS: "t"="merge_target_table" +STMT: MergeStmt +== 951 +merge into merge_target_table t +using merge_source_table s +on t.a = s.a +when matched and s.a <= 2 then + update set b = t.b || ' updated by merge' +when matched and s.a > 2 then + delete +when not matched then + insert values (a, b) +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DML +ALIAS: "t"="merge_target_table" +STMT: MergeStmt +== 952 +merge into merge_target_table t +using merge_source_table s +on t.a = s.a +when matched and s.a <= 2 then + update set b = t.b || ' updated again by merge' +when matched and s.a > 2 then + delete +when not matched then + insert values (a, b) +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DML +ALIAS: "t"="merge_target_table" +STMT: MergeStmt +== 953 +drop table merge_source_table, merge_target_table +-- +TABLE: name="merge_source_table" schema="" table="merge_source_table" ctx=DDL +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: DropStmt +== 954 +-- cleanup +drop function dump_insert() +-- +FUNCTION: name="dump_insert" function="dump_insert" schema="" ctx=DDL +STMT: DropStmt +== 955 +drop function dump_update() +-- +FUNCTION: name="dump_update" function="dump_update" schema="" ctx=DDL +STMT: DropStmt +== 956 +drop function dump_delete() +-- +FUNCTION: name="dump_delete" function="dump_delete" schema="" ctx=DDL +STMT: DropStmt +== 957 +|-- +-- Tests for CREATE OR REPLACE TRIGGER +|-- +create table my_table (id integer) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateStmt +== 958 +create function funcA() returns trigger as $$ +begin + raise notice 'hello from funcA'; + return null; +end; $$ language plpgsql +-- +FUNCTION: name="funca" function="funca" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 959 +create function funcB() returns trigger as $$ +begin + raise notice 'hello from funcB'; + return null; +end; $$ language plpgsql +-- +FUNCTION: name="funcb" function="funcb" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 960 +create trigger my_trig + after insert on my_table + for each row execute procedure funcA() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +== 961 +create trigger my_trig + before insert on my_table + for each row execute procedure funcB() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +== 962 +-- should fail + +insert into my_table values (1) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 963 +create or replace trigger my_trig + before insert on my_table + for each row execute procedure funcB() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +== 964 +-- OK + +insert into my_table values (2) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 965 +-- this insert should become a no-op + +table my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=Select +STMT: SelectStmt +== 966 +drop table my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: DropStmt +== 967 +-- test CREATE OR REPLACE TRIGGER on partition table +create table parted_trig (a int) partition by range (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +== 968 +create table parted_trig_1 partition of parted_trig + for values from (0) to (1000) partition by range (a) +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateStmt +== 969 +create table parted_trig_1_1 partition of parted_trig_1 for values from (0) to (100) +-- +TABLE: name="parted_trig_1_1" schema="" table="parted_trig_1_1" ctx=DDL +STMT: CreateStmt +== 970 +create table parted_trig_2 partition of parted_trig for values from (1000) to (2000) +-- +TABLE: name="parted_trig_2" schema="" table="parted_trig_2" ctx=DDL +STMT: CreateStmt +== 971 +create table default_parted_trig partition of parted_trig default +-- +TABLE: name="default_parted_trig" schema="" table="default_parted_trig" ctx=DDL +STMT: CreateStmt +== 972 +-- test that trigger can be replaced by another one +-- at the same level of partition table +create or replace trigger my_trig + after insert on parted_trig + for each row execute procedure funcA() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 973 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 974 +create or replace trigger my_trig + after insert on parted_trig + for each row execute procedure funcB() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 975 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 976 +-- test that child trigger cannot be replaced directly +create or replace trigger my_trig + after insert on parted_trig + for each row execute procedure funcA() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 977 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 978 +create or replace trigger my_trig + after insert on parted_trig_1 + for each row execute procedure funcB() +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateTrigStmt +== 979 +-- should fail +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 980 +drop trigger my_trig on parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +== 981 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 982 +-- test that user trigger can be overwritten by one defined at upper level +create trigger my_trig + after insert on parted_trig_1 + for each row execute procedure funcA() +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateTrigStmt +== 983 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 984 +create trigger my_trig + after insert on parted_trig + for each row execute procedure funcB() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 985 +-- should fail +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 986 +create or replace trigger my_trig + after insert on parted_trig + for each row execute procedure funcB() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +== 987 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 988 +-- cleanup +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +== 989 +drop function funcA() +-- +FUNCTION: name="funca" function="funca" schema="" ctx=DDL +STMT: DropStmt +== 990 +drop function funcB() +-- +FUNCTION: name="funcb" function="funcb" schema="" ctx=DDL +STMT: DropStmt +== 991 +-- Leave around some objects for other tests +create table trigger_parted (a int primary key) partition by list (a) +-- +TABLE: name="trigger_parted" schema="" table="trigger_parted" ctx=DDL +STMT: CreateStmt +== 992 +create function trigger_parted_trigfunc() returns trigger language plpgsql as + $$ begin end; $$ +-- +FUNCTION: name="trigger_parted_trigfunc" function="trigger_parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 993 +create trigger aft_row after insert or update on trigger_parted + for each row execute function trigger_parted_trigfunc() +-- +TABLE: name="trigger_parted" schema="" table="trigger_parted" ctx=DDL +STMT: CreateTrigStmt +== 994 +create table trigger_parted_p1 partition of trigger_parted for values in (1) + partition by list (a) +-- +TABLE: name="trigger_parted_p1" schema="" table="trigger_parted_p1" ctx=DDL +STMT: CreateStmt +== 995 +create table trigger_parted_p1_1 partition of trigger_parted_p1 for values in (1) +-- +TABLE: name="trigger_parted_p1_1" schema="" table="trigger_parted_p1_1" ctx=DDL +STMT: CreateStmt +== 996 +create table trigger_parted_p2 partition of trigger_parted for values in (2) + partition by list (a) +-- +TABLE: name="trigger_parted_p2" schema="" table="trigger_parted_p2" ctx=DDL +STMT: CreateStmt +== 997 +create table trigger_parted_p2_2 partition of trigger_parted_p2 for values in (2) +-- +TABLE: name="trigger_parted_p2_2" schema="" table="trigger_parted_p2_2" ctx=DDL +STMT: CreateStmt +== 998 +alter table only trigger_parted_p2 disable trigger aft_row +-- +TABLE: name="trigger_parted_p2" schema="" table="trigger_parted_p2" ctx=DDL +STMT: AlterTableStmt +== 999 +alter table trigger_parted_p2_2 enable always trigger aft_row +-- +TABLE: name="trigger_parted_p2_2" schema="" table="trigger_parted_p2_2" ctx=DDL +STMT: AlterTableStmt +== 1000 +-- verify transition table conversion slot's lifetime +-- https://postgr.es/m/39a71864-b120-5a5c-8cc5-c632b6f16761@amazon.com +create table convslot_test_parent (col1 text primary key) +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: CreateStmt +== 1001 +create table convslot_test_child (col1 text primary key, + foreign key (col1) references convslot_test_parent(col1) on delete cascade on update cascade +) +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: CreateStmt +== 1002 +alter table convslot_test_child add column col2 text not null default 'tutu' +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: AlterTableStmt +== 1003 +insert into convslot_test_parent(col1) values ('1') +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1004 +insert into convslot_test_child(col1) values ('1') +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1005 +insert into convslot_test_parent(col1) values ('3') +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1006 +insert into convslot_test_child(col1) values ('3') +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1007 +create function convslot_trig1() +returns trigger +language plpgsql +AS $$ +begin +raise notice 'trigger = %, old_table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' order by col1) from old_table); +return null; +end; $$ +-- +FUNCTION: name="convslot_trig1" function="convslot_trig1" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1008 +create function convslot_trig2() +returns trigger +language plpgsql +AS $$ +begin +raise notice 'trigger = %, new table = %', + TG_NAME, + (select string_agg(new_table::text, ', ' order by col1) from new_table); +return null; +end; $$ +-- +FUNCTION: name="convslot_trig2" function="convslot_trig2" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1009 +create trigger but_trigger after update on convslot_test_child +referencing new table as new_table +for each statement execute function convslot_trig2() +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: CreateTrigStmt +== 1010 +update convslot_test_parent set col1 = col1 || '1' +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: UpdateStmt +== 1011 +create function convslot_trig3() +returns trigger +language plpgsql +AS $$ +begin +raise notice 'trigger = %, old_table = %, new table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' order by col1) from old_table), + (select string_agg(new_table::text, ', ' order by col1) from new_table); +return null; +end; $$ +-- +FUNCTION: name="convslot_trig3" function="convslot_trig3" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1012 +create trigger but_trigger2 after update on convslot_test_child +referencing old table as old_table new table as new_table +for each statement execute function convslot_trig3() +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: CreateTrigStmt +== 1013 +update convslot_test_parent set col1 = col1 || '1' +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: UpdateStmt +== 1014 +create trigger bdt_trigger after delete on convslot_test_child +referencing old table as old_table +for each statement execute function convslot_trig1() +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: CreateTrigStmt +== 1015 +delete from convslot_test_parent +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: DeleteStmt +== 1016 +drop table convslot_test_child, convslot_test_parent +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: DropStmt +== 1017 +drop function convslot_trig1() +-- +FUNCTION: name="convslot_trig1" function="convslot_trig1" schema="" ctx=DDL +STMT: DropStmt +== 1018 +drop function convslot_trig2() +-- +FUNCTION: name="convslot_trig2" function="convslot_trig2" schema="" ctx=DDL +STMT: DropStmt +== 1019 +drop function convslot_trig3() +-- +FUNCTION: name="convslot_trig3" function="convslot_trig3" schema="" ctx=DDL +STMT: DropStmt +== 1020 +-- Bug #17607: variant of above in which trigger function raises an error; +-- we don't see any ill effects unless trigger tuple requires mapping + +create table convslot_test_parent (id int primary key, val int) +partition by range (id) +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: CreateStmt +== 1021 +create table convslot_test_part (val int, id int not null) +-- +TABLE: name="convslot_test_part" schema="" table="convslot_test_part" ctx=DDL +STMT: CreateStmt +== 1022 +alter table convslot_test_parent + attach partition convslot_test_part for values from (1) to (1000) +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: AlterTableStmt +== 1023 +create function convslot_trig4() returns trigger as +$$begin raise exception 'BOOM!'; end$$ language plpgsql +-- +FUNCTION: name="convslot_trig4" function="convslot_trig4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1024 +create trigger convslot_test_parent_update + after update on convslot_test_parent + referencing old table as old_rows new table as new_rows + for each statement execute procedure convslot_trig4() +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: CreateTrigStmt +== 1025 +insert into convslot_test_parent (id, val) values (1, 2) +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1026 +begin +-- +STMT: TransactionStmt +== 1027 +savepoint svp +-- +STMT: TransactionStmt +== 1028 +update convslot_test_parent set val = 3 +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: UpdateStmt +== 1029 +-- error expected +rollback to savepoint svp +-- +STMT: TransactionStmt +== 1030 +rollback +-- +STMT: TransactionStmt +== 1031 +drop table convslot_test_parent +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: DropStmt +== 1032 +drop function convslot_trig4() +-- +FUNCTION: name="convslot_trig4" function="convslot_trig4" schema="" ctx=DDL +STMT: DropStmt +== 1033 +-- Test trigger renaming on partitioned tables +create table grandparent (id int, primary key (id)) partition by range (id) +-- +TABLE: name="grandparent" schema="" table="grandparent" ctx=DDL +STMT: CreateStmt +== 1034 +create table middle partition of grandparent for values from (1) to (10) +partition by range (id) +-- +TABLE: name="middle" schema="" table="middle" ctx=DDL +STMT: CreateStmt +== 1035 +create table chi partition of middle for values from (1) to (5) +-- +TABLE: name="chi" schema="" table="chi" ctx=DDL +STMT: CreateStmt +== 1036 +create table cho partition of middle for values from (6) to (10) +-- +TABLE: name="cho" schema="" table="cho" ctx=DDL +STMT: CreateStmt +== 1037 +create function f () returns trigger as +$$ begin return new; end; $$ +language plpgsql +-- +FUNCTION: name="f" function="f" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1038 +create trigger a after insert on grandparent +for each row execute procedure f() +-- +TABLE: name="grandparent" schema="" table="grandparent" ctx=DDL +STMT: CreateTrigStmt +== 1039 +alter trigger a on grandparent rename to b +-- +STMT: RenameStmt +== 1040 +select tgrelid::regclass, tgname, +(select tgname from pg_trigger tr where tr.oid = pg_trigger.tgparentid) parent_tgname +from pg_trigger where tgrelid in (select relid from pg_partition_tree('grandparent')) +order by tgname, tgrelid::regclass::text COLLATE "C" +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +ALIAS: "tr"="pg_trigger" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="tr" column="oid" +FILTER: schema="" table="pg_trigger" column="tgparentid" +STMT: SelectStmt +== 1041 +alter trigger a on only grandparent rename to b +-- +ERROR: syntax error at or near "only" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 1042 +-- ONLY not supported +alter trigger b on middle rename to c +-- +STMT: RenameStmt +== 1043 +-- can't rename trigger on partition +create trigger c after insert on middle +for each row execute procedure f() +-- +TABLE: name="middle" schema="" table="middle" ctx=DDL +STMT: CreateTrigStmt +== 1044 +alter trigger b on grandparent rename to c +-- +STMT: RenameStmt +== 1045 +-- Rename cascading does not affect statement triggers +create trigger p after insert on grandparent for each statement execute function f() +-- +TABLE: name="grandparent" schema="" table="grandparent" ctx=DDL +STMT: CreateTrigStmt +== 1046 +create trigger p after insert on middle for each statement execute function f() +-- +TABLE: name="middle" schema="" table="middle" ctx=DDL +STMT: CreateTrigStmt +== 1047 +alter trigger p on grandparent rename to q +-- +STMT: RenameStmt +== 1048 +select tgrelid::regclass, tgname, +(select tgname from pg_trigger tr where tr.oid = pg_trigger.tgparentid) parent_tgname +from pg_trigger where tgrelid in (select relid from pg_partition_tree('grandparent')) +order by tgname, tgrelid::regclass::text COLLATE "C" +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +ALIAS: "tr"="pg_trigger" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="tr" column="oid" +FILTER: schema="" table="pg_trigger" column="tgparentid" +STMT: SelectStmt +== 1049 +drop table grandparent +-- +TABLE: name="grandparent" schema="" table="grandparent" ctx=DDL +STMT: DropStmt +== 1050 +-- Trigger renaming does not recurse on legacy inheritance +create table parent (a int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 1051 +create table child () inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +== 1052 +create trigger parenttrig after insert on parent +for each row execute procedure f() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +== 1053 +create trigger parenttrig after insert on child +for each row execute procedure f() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +== 1054 +alter trigger parenttrig on parent rename to anothertrig +-- +STMT: RenameStmt +== 1055 +drop table parent, child +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +== 1056 +drop function f() +-- +FUNCTION: name="f" function="f" schema="" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/truncate.metadata.json b/parser/testdata/summary/postgres_regress/truncate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/truncate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/truncate.test b/parser/testdata/summary/postgres_regress/truncate.test new file mode 100644 index 0000000..8372c9f --- /dev/null +++ b/parser/testdata/summary/postgres_regress/truncate.test @@ -0,0 +1,1111 @@ +== 001 +-- Test basic TRUNCATE functionality. +CREATE TABLE truncate_a (col1 integer primary key) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO truncate_a VALUES (1) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO truncate_a VALUES (2) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +== 005 +-- Roll truncate back +BEGIN +-- +STMT: TransactionStmt +== 006 +TRUNCATE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 007 +ROLLBACK +-- +STMT: TransactionStmt +== 008 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +== 009 +-- Commit the truncate this time +BEGIN +-- +STMT: TransactionStmt +== 010 +TRUNCATE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 011 +COMMIT +-- +STMT: TransactionStmt +== 012 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +== 013 +-- Test foreign-key checks +CREATE TABLE trunc_b (a int REFERENCES truncate_a) +-- +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +STMT: CreateStmt +== 014 +CREATE TABLE trunc_c (a serial PRIMARY KEY) +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +STMT: CreateStmt +== 015 +CREATE TABLE trunc_d (a int REFERENCES trunc_c) +-- +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +STMT: CreateStmt +== 016 +CREATE TABLE trunc_e (a int REFERENCES truncate_a, b int REFERENCES trunc_c) +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: CreateStmt +== 017 +TRUNCATE TABLE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 018 +-- fail +TRUNCATE TABLE truncate_a,trunc_b +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +STMT: TruncateStmt +== 019 +-- fail +TRUNCATE TABLE truncate_a,trunc_b,trunc_e +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: TruncateStmt +== 020 +-- ok +TRUNCATE TABLE truncate_a,trunc_e +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: TruncateStmt +== 021 +-- fail +TRUNCATE TABLE trunc_c +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +STMT: TruncateStmt +== 022 +-- fail +TRUNCATE TABLE trunc_c,trunc_d +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +STMT: TruncateStmt +== 023 +-- fail +TRUNCATE TABLE trunc_c,trunc_d,trunc_e +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: TruncateStmt +== 024 +-- ok +TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 025 +-- fail +TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a,trunc_b +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +STMT: TruncateStmt +== 026 +-- ok + +TRUNCATE TABLE truncate_a RESTRICT +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 027 +-- fail +TRUNCATE TABLE truncate_a CASCADE +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 028 +-- ok + +-- circular references +ALTER TABLE truncate_a ADD FOREIGN KEY (col1) REFERENCES trunc_c +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: AlterTableStmt +== 029 +-- Add some data to verify that truncating actually works ... +INSERT INTO trunc_c VALUES (1) +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO truncate_a VALUES (1) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO trunc_b VALUES (1) +-- +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +INSERT INTO trunc_d VALUES (1) +-- +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 033 +INSERT INTO trunc_e VALUES (1,1) +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 034 +TRUNCATE TABLE trunc_c +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +STMT: TruncateStmt +== 035 +TRUNCATE TABLE trunc_c,truncate_a +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 036 +TRUNCATE TABLE trunc_c,truncate_a,trunc_d +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +STMT: TruncateStmt +== 037 +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: TruncateStmt +== 038 +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e,trunc_b +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +STMT: TruncateStmt +== 039 +-- Verify that truncating did actually work +SELECT * FROM truncate_a + UNION ALL + SELECT * FROM trunc_c + UNION ALL + SELECT * FROM trunc_b + UNION ALL + SELECT * FROM trunc_d +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=Select +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=Select +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=Select +STMT: SelectStmt +== 040 +SELECT * FROM trunc_e +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=Select +STMT: SelectStmt +== 041 +-- Add data again to test TRUNCATE ... CASCADE +INSERT INTO trunc_c VALUES (1) +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 042 +INSERT INTO truncate_a VALUES (1) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +INSERT INTO trunc_b VALUES (1) +-- +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 044 +INSERT INTO trunc_d VALUES (1) +-- +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 045 +INSERT INTO trunc_e VALUES (1,1) +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +TRUNCATE TABLE trunc_c CASCADE +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +STMT: TruncateStmt +== 047 +-- ok + +SELECT * FROM truncate_a + UNION ALL + SELECT * FROM trunc_c + UNION ALL + SELECT * FROM trunc_b + UNION ALL + SELECT * FROM trunc_d +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=Select +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=Select +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=Select +STMT: SelectStmt +== 048 +SELECT * FROM trunc_e +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=Select +STMT: SelectStmt +== 049 +DROP TABLE truncate_a,trunc_c,trunc_b,trunc_d,trunc_e CASCADE +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: DropStmt +== 050 +-- Test TRUNCATE with inheritance + +CREATE TABLE trunc_f (col1 integer primary key) +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DDL +STMT: CreateStmt +== 051 +INSERT INTO trunc_f VALUES (1) +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 052 +INSERT INTO trunc_f VALUES (2) +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 053 +CREATE TABLE trunc_fa (col2a text) INHERITS (trunc_f) +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=DDL +STMT: CreateStmt +== 054 +INSERT INTO trunc_fa VALUES (3, 'three') +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 055 +CREATE TABLE trunc_fb (col2b int) INHERITS (trunc_f) +-- +TABLE: name="trunc_fb" schema="" table="trunc_fb" ctx=DDL +STMT: CreateStmt +== 056 +INSERT INTO trunc_fb VALUES (4, 444) +-- +TABLE: name="trunc_fb" schema="" table="trunc_fb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 057 +CREATE TABLE trunc_faa (col3 text) INHERITS (trunc_fa) +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=DDL +STMT: CreateStmt +== 058 +INSERT INTO trunc_faa VALUES (5, 'five', 'FIVE') +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +BEGIN +-- +STMT: TransactionStmt +== 060 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +== 061 +TRUNCATE trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DDL +STMT: TruncateStmt +== 062 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +== 063 +ROLLBACK +-- +STMT: TransactionStmt +== 064 +BEGIN +-- +STMT: TransactionStmt +== 065 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +== 066 +TRUNCATE ONLY trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DDL +STMT: TruncateStmt +== 067 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +== 068 +ROLLBACK +-- +STMT: TransactionStmt +== 069 +BEGIN +-- +STMT: TransactionStmt +== 070 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +== 071 +SELECT * FROM trunc_fa +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=Select +STMT: SelectStmt +== 072 +SELECT * FROM trunc_faa +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=Select +STMT: SelectStmt +== 073 +TRUNCATE ONLY trunc_fb, ONLY trunc_fa +-- +TABLE: name="trunc_fb" schema="" table="trunc_fb" ctx=DDL +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=DDL +STMT: TruncateStmt +== 074 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +== 075 +SELECT * FROM trunc_fa +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=Select +STMT: SelectStmt +== 076 +SELECT * FROM trunc_faa +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=Select +STMT: SelectStmt +== 077 +ROLLBACK +-- +STMT: TransactionStmt +== 078 +BEGIN +-- +STMT: TransactionStmt +== 079 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +== 080 +SELECT * FROM trunc_fa +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=Select +STMT: SelectStmt +== 081 +SELECT * FROM trunc_faa +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=Select +STMT: SelectStmt +== 082 +TRUNCATE ONLY trunc_fb, trunc_fa +-- +TABLE: name="trunc_fb" schema="" table="trunc_fb" ctx=DDL +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=DDL +STMT: TruncateStmt +== 083 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +== 084 +SELECT * FROM trunc_fa +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=Select +STMT: SelectStmt +== 085 +SELECT * FROM trunc_faa +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=Select +STMT: SelectStmt +== 086 +ROLLBACK +-- +STMT: TransactionStmt +== 087 +DROP TABLE trunc_f CASCADE +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DDL +STMT: DropStmt +== 088 +-- Test ON TRUNCATE triggers + +CREATE TABLE trunc_trigger_test (f1 int, f2 text, f3 text) +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: CreateStmt +== 089 +CREATE TABLE trunc_trigger_log (tgop text, tglevel text, tgwhen text, + tgargv text, tgtable name, rowcount bigint) +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=DDL +STMT: CreateStmt +== 090 +CREATE FUNCTION trunctrigger() RETURNS trigger as $$ +declare c bigint; +begin + execute 'select count(*) from ' || quote_ident(tg_table_name) into c; + insert into trunc_trigger_log values + (TG_OP, TG_LEVEL, TG_WHEN, TG_ARGV[0], tg_table_name, c); + return null; +end; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="trunctrigger" function="trunctrigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 091 +-- basic before trigger +INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux') +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 092 +CREATE TRIGGER t +BEFORE TRUNCATE ON trunc_trigger_test +FOR EACH STATEMENT +EXECUTE PROCEDURE trunctrigger('before trigger truncate') +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: CreateTrigStmt +== 093 +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 094 +SELECT * FROM trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=Select +STMT: SelectStmt +== 095 +TRUNCATE trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: TruncateStmt +== 096 +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 097 +SELECT * FROM trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=Select +STMT: SelectStmt +== 098 +DROP TRIGGER t ON trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: DropStmt +== 099 +truncate trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=DDL +STMT: TruncateStmt +== 100 +-- same test with an after trigger +INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux') +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 101 +CREATE TRIGGER tt +AFTER TRUNCATE ON trunc_trigger_test +FOR EACH STATEMENT +EXECUTE PROCEDURE trunctrigger('after trigger truncate') +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: CreateTrigStmt +== 102 +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 103 +SELECT * FROM trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=Select +STMT: SelectStmt +== 104 +TRUNCATE trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: TruncateStmt +== 105 +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 106 +SELECT * FROM trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=Select +STMT: SelectStmt +== 107 +DROP TABLE trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: DropStmt +== 108 +DROP TABLE trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=DDL +STMT: DropStmt +== 109 +DROP FUNCTION trunctrigger() +-- +FUNCTION: name="trunctrigger" function="trunctrigger" schema="" ctx=DDL +STMT: DropStmt +== 110 +-- test TRUNCATE ... RESTART IDENTITY +CREATE SEQUENCE truncate_a_id1 START WITH 33 +-- +STMT: CreateSeqStmt +== 111 +CREATE TABLE truncate_a (id serial, + id1 integer default nextval('truncate_a_id1')) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: CreateStmt +== 112 +ALTER SEQUENCE truncate_a_id1 OWNED BY truncate_a.id1 +-- +STMT: AlterSeqStmt +== 113 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 114 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 115 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +== 116 +TRUNCATE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 117 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 118 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 119 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +== 120 +TRUNCATE truncate_a RESTART IDENTITY +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 121 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 122 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 123 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +== 124 +CREATE TABLE truncate_b (id int GENERATED ALWAYS AS IDENTITY (START WITH 44)) +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DDL +STMT: CreateStmt +== 125 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +== 126 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +== 127 +SELECT * FROM truncate_b +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=Select +STMT: SelectStmt +== 128 +TRUNCATE truncate_b +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DDL +STMT: TruncateStmt +== 129 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +== 130 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +== 131 +SELECT * FROM truncate_b +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=Select +STMT: SelectStmt +== 132 +TRUNCATE truncate_b RESTART IDENTITY +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DDL +STMT: TruncateStmt +== 133 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +== 134 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +== 135 +SELECT * FROM truncate_b +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=Select +STMT: SelectStmt +== 136 +-- check rollback of a RESTART IDENTITY operation +BEGIN +-- +STMT: TransactionStmt +== 137 +TRUNCATE truncate_a RESTART IDENTITY +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +== 138 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 139 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +== 140 +ROLLBACK +-- +STMT: TransactionStmt +== 141 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 142 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +== 143 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +== 144 +DROP TABLE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: DropStmt +== 145 +SELECT nextval('truncate_a_id1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +== 146 +-- fail, seq should have been dropped + +-- partitioned table +CREATE TABLE truncparted (a int, b char) PARTITION BY LIST (a) +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: CreateStmt +== 147 +-- error, can't truncate a partitioned table +TRUNCATE ONLY truncparted +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: TruncateStmt +== 148 +CREATE TABLE truncparted1 PARTITION OF truncparted FOR VALUES IN (1) +-- +TABLE: name="truncparted1" schema="" table="truncparted1" ctx=DDL +STMT: CreateStmt +== 149 +INSERT INTO truncparted VALUES (1, 'a') +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 150 +-- error, must truncate partitions +TRUNCATE ONLY truncparted +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: TruncateStmt +== 151 +TRUNCATE truncparted +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: TruncateStmt +== 152 +DROP TABLE truncparted +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: DropStmt +== 153 +-- foreign key on partitioned table: partition key is referencing column. +-- Make sure truncate did execute on all tables +CREATE FUNCTION tp_ins_data() RETURNS void LANGUAGE plpgsql AS $$ + BEGIN + INSERT INTO truncprim VALUES (1), (100), (150); + INSERT INTO truncpart VALUES (1), (100), (150); + END +$$ +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 154 +CREATE FUNCTION tp_chk_data(OUT pktb regclass, OUT pkval int, OUT fktb regclass, OUT fkval int) + RETURNS SETOF record LANGUAGE plpgsql AS $$ + BEGIN + RETURN QUERY SELECT + pk.tableoid::regclass, pk.a, fk.tableoid::regclass, fk.a + FROM truncprim pk FULL JOIN truncpart fk USING (a) + ORDER BY 2, 4; + END +$$ +-- +FUNCTION: name="tp_chk_data" function="tp_chk_data" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 155 +CREATE TABLE truncprim (a int PRIMARY KEY) +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +STMT: CreateStmt +== 156 +CREATE TABLE truncpart (a int REFERENCES truncprim) + PARTITION BY RANGE (a) +-- +TABLE: name="truncpart" schema="" table="truncpart" ctx=DDL +STMT: CreateStmt +== 157 +CREATE TABLE truncpart_1 PARTITION OF truncpart FOR VALUES FROM (0) TO (100) +-- +TABLE: name="truncpart_1" schema="" table="truncpart_1" ctx=DDL +STMT: CreateStmt +== 158 +CREATE TABLE truncpart_2 PARTITION OF truncpart FOR VALUES FROM (100) TO (200) + PARTITION BY RANGE (a) +-- +TABLE: name="truncpart_2" schema="" table="truncpart_2" ctx=DDL +STMT: CreateStmt +== 159 +CREATE TABLE truncpart_2_1 PARTITION OF truncpart_2 FOR VALUES FROM (100) TO (150) +-- +TABLE: name="truncpart_2_1" schema="" table="truncpart_2_1" ctx=DDL +STMT: CreateStmt +== 160 +CREATE TABLE truncpart_2_d PARTITION OF truncpart_2 DEFAULT +-- +TABLE: name="truncpart_2_d" schema="" table="truncpart_2_d" ctx=DDL +STMT: CreateStmt +== 161 +TRUNCATE TABLE truncprim +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +STMT: TruncateStmt +== 162 +-- should fail + +select tp_ins_data() +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=Call +STMT: SelectStmt +== 163 +-- should truncate everything +TRUNCATE TABLE truncprim, truncpart +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +TABLE: name="truncpart" schema="" table="truncpart" ctx=DDL +STMT: TruncateStmt +== 164 +select * from tp_chk_data() +-- +FUNCTION: name="tp_chk_data" function="tp_chk_data" schema="" ctx=Call +STMT: SelectStmt +== 165 +select tp_ins_data() +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=Call +STMT: SelectStmt +== 166 +-- should truncate everything +TRUNCATE TABLE truncprim CASCADE +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +STMT: TruncateStmt +== 167 +SELECT * FROM tp_chk_data() +-- +FUNCTION: name="tp_chk_data" function="tp_chk_data" schema="" ctx=Call +STMT: SelectStmt +== 168 +SELECT tp_ins_data() +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=Call +STMT: SelectStmt +== 169 +-- should truncate all partitions +TRUNCATE TABLE truncpart +-- +TABLE: name="truncpart" schema="" table="truncpart" ctx=DDL +STMT: TruncateStmt +== 170 +SELECT * FROM tp_chk_data() +-- +FUNCTION: name="tp_chk_data" function="tp_chk_data" schema="" ctx=Call +STMT: SelectStmt +== 171 +DROP TABLE truncprim, truncpart +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +TABLE: name="truncpart" schema="" table="truncpart" ctx=DDL +STMT: DropStmt +== 172 +DROP FUNCTION tp_ins_data(), tp_chk_data() +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=DDL +STMT: DropStmt +== 173 +-- test cascade when referencing a partitioned table +CREATE TABLE trunc_a (a INT PRIMARY KEY) PARTITION BY RANGE (a) +-- +TABLE: name="trunc_a" schema="" table="trunc_a" ctx=DDL +STMT: CreateStmt +== 174 +CREATE TABLE trunc_a1 PARTITION OF trunc_a FOR VALUES FROM (0) TO (10) +-- +TABLE: name="trunc_a1" schema="" table="trunc_a1" ctx=DDL +STMT: CreateStmt +== 175 +CREATE TABLE trunc_a2 PARTITION OF trunc_a FOR VALUES FROM (10) TO (20) + PARTITION BY RANGE (a) +-- +TABLE: name="trunc_a2" schema="" table="trunc_a2" ctx=DDL +STMT: CreateStmt +== 176 +CREATE TABLE trunc_a21 PARTITION OF trunc_a2 FOR VALUES FROM (10) TO (12) +-- +TABLE: name="trunc_a21" schema="" table="trunc_a21" ctx=DDL +STMT: CreateStmt +== 177 +CREATE TABLE trunc_a22 PARTITION OF trunc_a2 FOR VALUES FROM (12) TO (16) +-- +TABLE: name="trunc_a22" schema="" table="trunc_a22" ctx=DDL +STMT: CreateStmt +== 178 +CREATE TABLE trunc_a2d PARTITION OF trunc_a2 DEFAULT +-- +TABLE: name="trunc_a2d" schema="" table="trunc_a2d" ctx=DDL +STMT: CreateStmt +== 179 +CREATE TABLE trunc_a3 PARTITION OF trunc_a FOR VALUES FROM (20) TO (30) +-- +TABLE: name="trunc_a3" schema="" table="trunc_a3" ctx=DDL +STMT: CreateStmt +== 180 +INSERT INTO trunc_a VALUES (0), (5), (10), (15), (20), (25) +-- +TABLE: name="trunc_a" schema="" table="trunc_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 181 +-- truncate a partition cascading to a table +CREATE TABLE ref_b ( + b INT PRIMARY KEY, + a INT REFERENCES trunc_a(a) ON DELETE CASCADE +) +-- +TABLE: name="ref_b" schema="" table="ref_b" ctx=DDL +STMT: CreateStmt +== 182 +INSERT INTO ref_b VALUES (10, 0), (50, 5), (100, 10), (150, 15) +-- +TABLE: name="ref_b" schema="" table="ref_b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 183 +TRUNCATE TABLE trunc_a1 CASCADE +-- +TABLE: name="trunc_a1" schema="" table="trunc_a1" ctx=DDL +STMT: TruncateStmt +== 184 +SELECT a FROM ref_b +-- +TABLE: name="ref_b" schema="" table="ref_b" ctx=Select +STMT: SelectStmt +== 185 +DROP TABLE ref_b +-- +TABLE: name="ref_b" schema="" table="ref_b" ctx=DDL +STMT: DropStmt +== 186 +-- truncate a partition cascading to a partitioned table +CREATE TABLE ref_c ( + c INT PRIMARY KEY, + a INT REFERENCES trunc_a(a) ON DELETE CASCADE +) PARTITION BY RANGE (c) +-- +TABLE: name="ref_c" schema="" table="ref_c" ctx=DDL +STMT: CreateStmt +== 187 +CREATE TABLE ref_c1 PARTITION OF ref_c FOR VALUES FROM (100) TO (200) +-- +TABLE: name="ref_c1" schema="" table="ref_c1" ctx=DDL +STMT: CreateStmt +== 188 +CREATE TABLE ref_c2 PARTITION OF ref_c FOR VALUES FROM (200) TO (300) +-- +TABLE: name="ref_c2" schema="" table="ref_c2" ctx=DDL +STMT: CreateStmt +== 189 +INSERT INTO ref_c VALUES (100, 10), (150, 15), (200, 20), (250, 25) +-- +TABLE: name="ref_c" schema="" table="ref_c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 190 +TRUNCATE TABLE trunc_a21 CASCADE +-- +TABLE: name="trunc_a21" schema="" table="trunc_a21" ctx=DDL +STMT: TruncateStmt +== 191 +SELECT a as "from table ref_c" FROM ref_c +-- +TABLE: name="ref_c" schema="" table="ref_c" ctx=Select +STMT: SelectStmt +== 192 +SELECT a as "from table trunc_a" FROM trunc_a ORDER BY a +-- +TABLE: name="trunc_a" schema="" table="trunc_a" ctx=Select +STMT: SelectStmt +== 193 +DROP TABLE trunc_a, ref_c +-- +TABLE: name="trunc_a" schema="" table="trunc_a" ctx=DDL +TABLE: name="ref_c" schema="" table="ref_c" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/tsdicts.metadata.json b/parser/testdata/summary/postgres_regress/tsdicts.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tsdicts.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tsdicts.test b/parser/testdata/summary/postgres_regress/tsdicts.test new file mode 100644 index 0000000..bfa3864 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tsdicts.test @@ -0,0 +1,732 @@ +== 001 +--Test text search dictionaries and configurations + +-- Test ISpell dictionary with ispell affix file +CREATE TEXT SEARCH DICTIONARY ispell ( + Template=ispell, + DictFile=ispell_sample, + AffFile=ispell_sample +) +-- +STMT: DefineStmt +== 002 +SELECT ts_lexize('ispell', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 003 +SELECT ts_lexize('ispell', 'bookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT ts_lexize('ispell', 'booking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT ts_lexize('ispell', 'foot') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT ts_lexize('ispell', 'foots') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT ts_lexize('ispell', 'rebookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 008 +SELECT ts_lexize('ispell', 'rebooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 009 +SELECT ts_lexize('ispell', 'rebook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT ts_lexize('ispell', 'unbookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT ts_lexize('ispell', 'unbooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT ts_lexize('ispell', 'unbook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT ts_lexize('ispell', 'footklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT ts_lexize('ispell', 'footballklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT ts_lexize('ispell', 'ballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT ts_lexize('ispell', 'footballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 017 +-- Test ISpell dictionary with hunspell affix file +CREATE TEXT SEARCH DICTIONARY hunspell ( + Template=ispell, + DictFile=ispell_sample, + AffFile=hunspell_sample +) +-- +STMT: DefineStmt +== 018 +SELECT ts_lexize('hunspell', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT ts_lexize('hunspell', 'bookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT ts_lexize('hunspell', 'booking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT ts_lexize('hunspell', 'foot') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT ts_lexize('hunspell', 'foots') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT ts_lexize('hunspell', 'rebookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT ts_lexize('hunspell', 'rebooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT ts_lexize('hunspell', 'rebook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 026 +SELECT ts_lexize('hunspell', 'unbookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT ts_lexize('hunspell', 'unbooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 028 +SELECT ts_lexize('hunspell', 'unbook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT ts_lexize('hunspell', 'footklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT ts_lexize('hunspell', 'footballklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT ts_lexize('hunspell', 'ballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT ts_lexize('hunspell', 'footballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 033 +-- Test ISpell dictionary with hunspell affix file with FLAG long parameter +CREATE TEXT SEARCH DICTIONARY hunspell_long ( + Template=ispell, + DictFile=hunspell_sample_long, + AffFile=hunspell_sample_long +) +-- +STMT: DefineStmt +== 034 +SELECT ts_lexize('hunspell_long', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT ts_lexize('hunspell_long', 'bookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 036 +SELECT ts_lexize('hunspell_long', 'booking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT ts_lexize('hunspell_long', 'foot') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 038 +SELECT ts_lexize('hunspell_long', 'foots') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 039 +SELECT ts_lexize('hunspell_long', 'rebookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT ts_lexize('hunspell_long', 'rebooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 041 +SELECT ts_lexize('hunspell_long', 'rebook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 042 +SELECT ts_lexize('hunspell_long', 'unbookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT ts_lexize('hunspell_long', 'unbooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 044 +SELECT ts_lexize('hunspell_long', 'unbook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 045 +SELECT ts_lexize('hunspell_long', 'booked') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 046 +SELECT ts_lexize('hunspell_long', 'footklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 047 +SELECT ts_lexize('hunspell_long', 'footballklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT ts_lexize('hunspell_long', 'ballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 049 +SELECT ts_lexize('hunspell_long', 'ballsklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 050 +SELECT ts_lexize('hunspell_long', 'footballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 051 +SELECT ts_lexize('hunspell_long', 'ex-machina') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 052 +-- Test ISpell dictionary with hunspell affix file with FLAG num parameter +CREATE TEXT SEARCH DICTIONARY hunspell_num ( + Template=ispell, + DictFile=hunspell_sample_num, + AffFile=hunspell_sample_num +) +-- +STMT: DefineStmt +== 053 +SELECT ts_lexize('hunspell_num', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 054 +SELECT ts_lexize('hunspell_num', 'sk') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 055 +SELECT ts_lexize('hunspell_num', 'bookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 056 +SELECT ts_lexize('hunspell_num', 'booking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 057 +SELECT ts_lexize('hunspell_num', 'foot') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 058 +SELECT ts_lexize('hunspell_num', 'foots') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 059 +SELECT ts_lexize('hunspell_num', 'rebookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 060 +SELECT ts_lexize('hunspell_num', 'rebooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 061 +SELECT ts_lexize('hunspell_num', 'rebook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 062 +SELECT ts_lexize('hunspell_num', 'unbookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT ts_lexize('hunspell_num', 'unbooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT ts_lexize('hunspell_num', 'unbook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 065 +SELECT ts_lexize('hunspell_num', 'booked') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 066 +SELECT ts_lexize('hunspell_num', 'footklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 067 +SELECT ts_lexize('hunspell_num', 'footballklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT ts_lexize('hunspell_num', 'ballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT ts_lexize('hunspell_num', 'footballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 070 +-- Test suitability of affix and dict files +CREATE TEXT SEARCH DICTIONARY hunspell_err ( + Template=ispell, + DictFile=ispell_sample, + AffFile=hunspell_sample_long +) +-- +STMT: DefineStmt +== 071 +CREATE TEXT SEARCH DICTIONARY hunspell_err ( + Template=ispell, + DictFile=ispell_sample, + AffFile=hunspell_sample_num +) +-- +STMT: DefineStmt +== 072 +CREATE TEXT SEARCH DICTIONARY hunspell_invalid_1 ( + Template=ispell, + DictFile=hunspell_sample_long, + AffFile=ispell_sample +) +-- +STMT: DefineStmt +== 073 +CREATE TEXT SEARCH DICTIONARY hunspell_invalid_2 ( + Template=ispell, + DictFile=hunspell_sample_long, + AffFile=hunspell_sample_num +) +-- +STMT: DefineStmt +== 074 +CREATE TEXT SEARCH DICTIONARY hunspell_invalid_3 ( + Template=ispell, + DictFile=hunspell_sample_num, + AffFile=ispell_sample +) +-- +STMT: DefineStmt +== 075 +CREATE TEXT SEARCH DICTIONARY hunspell_err ( + Template=ispell, + DictFile=hunspell_sample_num, + AffFile=hunspell_sample_long +) +-- +STMT: DefineStmt +== 076 +-- Synonym dictionary +CREATE TEXT SEARCH DICTIONARY synonym ( + Template=synonym, + Synonyms=synonym_sample +) +-- +STMT: DefineStmt +== 077 +SELECT ts_lexize('synonym', 'PoStGrEs') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT ts_lexize('synonym', 'Gogle') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 079 +SELECT ts_lexize('synonym', 'indices') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 080 +-- test altering boolean parameters +SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym' +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +FILTER: schema="" table="" column="dictname" +STMT: SelectStmt +== 081 +ALTER TEXT SEARCH DICTIONARY synonym (CaseSensitive = 1) +-- +STMT: AlterTSDictionaryStmt +== 082 +SELECT ts_lexize('synonym', 'PoStGrEs') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 083 +SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym' +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +FILTER: schema="" table="" column="dictname" +STMT: SelectStmt +== 084 +ALTER TEXT SEARCH DICTIONARY synonym (CaseSensitive = 2) +-- +STMT: AlterTSDictionaryStmt +== 085 +-- fail + +ALTER TEXT SEARCH DICTIONARY synonym (CaseSensitive = off) +-- +STMT: AlterTSDictionaryStmt +== 086 +SELECT ts_lexize('synonym', 'PoStGrEs') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 087 +SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym' +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +FILTER: schema="" table="" column="dictname" +STMT: SelectStmt +== 088 +-- Create and simple test thesaurus dictionary +-- More tests in configuration checks because ts_lexize() +-- cannot pass more than one word to thesaurus. +CREATE TEXT SEARCH DICTIONARY thesaurus ( + Template=thesaurus, + DictFile=thesaurus_sample, + Dictionary=english_stem +) +-- +STMT: DefineStmt +== 089 +SELECT ts_lexize('thesaurus', 'one') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 090 +-- Test ispell dictionary in configuration +CREATE TEXT SEARCH CONFIGURATION ispell_tst ( + COPY=english +) +-- +STMT: DefineStmt +== 091 +ALTER TEXT SEARCH CONFIGURATION ispell_tst ALTER MAPPING FOR + word, numword, asciiword, hword, numhword, asciihword, hword_part, hword_numpart, hword_asciipart + WITH ispell, english_stem +-- +STMT: AlterTSConfigurationStmt +== 092 +SELECT to_tsvector('ispell_tst', 'Booking the skies after rebookings for footballklubber from a foot') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 093 +SELECT to_tsquery('ispell_tst', 'footballklubber') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 094 +SELECT to_tsquery('ispell_tst', 'footballyklubber:b & rebookings:A & sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 095 +-- Test ispell dictionary with hunspell affix in configuration +CREATE TEXT SEARCH CONFIGURATION hunspell_tst ( + COPY=ispell_tst +) +-- +STMT: DefineStmt +== 096 +ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING + REPLACE ispell WITH hunspell +-- +STMT: AlterTSConfigurationStmt +== 097 +SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 098 +SELECT to_tsquery('hunspell_tst', 'footballklubber') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 099 +SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 100 +SELECT to_tsquery('hunspell_tst', 'footballyklubber:b <-> sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 101 +SELECT phraseto_tsquery('hunspell_tst', 'footballyklubber sky') +-- +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 102 +-- Test ispell dictionary with hunspell affix with FLAG long in configuration +ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING + REPLACE hunspell WITH hunspell_long +-- +STMT: AlterTSConfigurationStmt +== 103 +SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 104 +SELECT to_tsquery('hunspell_tst', 'footballklubber') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 105 +SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 106 +-- Test ispell dictionary with hunspell affix with FLAG num in configuration +ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING + REPLACE hunspell_long WITH hunspell_num +-- +STMT: AlterTSConfigurationStmt +== 107 +SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 108 +SELECT to_tsquery('hunspell_tst', 'footballklubber') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 109 +SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 110 +-- Test synonym dictionary in configuration +CREATE TEXT SEARCH CONFIGURATION synonym_tst ( + COPY=english +) +-- +STMT: DefineStmt +== 111 +ALTER TEXT SEARCH CONFIGURATION synonym_tst ALTER MAPPING FOR + asciiword, hword_asciipart, asciihword + WITH synonym, english_stem +-- +STMT: AlterTSConfigurationStmt +== 112 +SELECT to_tsvector('synonym_tst', 'Postgresql is often called as postgres or pgsql and pronounced as postgre') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 113 +SELECT to_tsvector('synonym_tst', 'Most common mistake is to write Gogle instead of Google') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 114 +SELECT to_tsvector('synonym_tst', 'Indexes or indices - Which is right plural form of index?') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 115 +SELECT to_tsquery('synonym_tst', 'Index & indices') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 116 +-- test thesaurus in configuration +-- see thesaurus_sample.ths to understand 'odd' resulting tsvector +CREATE TEXT SEARCH CONFIGURATION thesaurus_tst ( + COPY=synonym_tst +) +-- +STMT: DefineStmt +== 117 +ALTER TEXT SEARCH CONFIGURATION thesaurus_tst ALTER MAPPING FOR + asciiword, hword_asciipart, asciihword + WITH synonym, thesaurus, english_stem +-- +STMT: AlterTSConfigurationStmt +== 118 +SELECT to_tsvector('thesaurus_tst', 'one postgres one two one two three one') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 119 +SELECT to_tsvector('thesaurus_tst', 'Supernovae star is very new star and usually called supernovae (abbreviation SN)') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 120 +SELECT to_tsvector('thesaurus_tst', 'Booking tickets is looking like a booking a tickets') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 121 +-- invalid: non-lowercase quoted identifiers +CREATE TEXT SEARCH DICTIONARY tsdict_case +( + Template = ispell, + "DictFile" = ispell_sample, + "AffFile" = ispell_sample +) +-- +STMT: DefineStmt +== 122 +-- Test grammar for configurations +CREATE TEXT SEARCH CONFIGURATION dummy_tst (COPY=english) +-- +STMT: DefineStmt +== 123 +-- Overridden mapping change with duplicated tokens. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + ALTER MAPPING FOR word, word WITH ispell +-- +STMT: AlterTSConfigurationStmt +== 124 +-- Not a token supported by the configuration's parser, fails. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING FOR not_a_token, not_a_token +-- +STMT: AlterTSConfigurationStmt +== 125 +-- Not a token supported by the configuration's parser, fails even +-- with IF EXISTS. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING IF EXISTS FOR not_a_token, not_a_token +-- +STMT: AlterTSConfigurationStmt +== 126 +-- Token supported by the configuration's parser, succeeds. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING FOR word, word +-- +STMT: AlterTSConfigurationStmt +== 127 +-- No mapping for token supported by the configuration's parser, fails. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING FOR word +-- +STMT: AlterTSConfigurationStmt +== 128 +-- Token supported by the configuration's parser, cannot be found, +-- succeeds with IF EXISTS. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING IF EXISTS FOR word, word +-- +STMT: AlterTSConfigurationStmt +== 129 +-- Re-add mapping, with duplicated tokens supported by the parser. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + ADD MAPPING FOR word, word WITH ispell +-- +STMT: AlterTSConfigurationStmt +== 130 +-- Not a token supported by the configuration's parser, fails. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + ADD MAPPING FOR not_a_token WITH ispell +-- +STMT: AlterTSConfigurationStmt +== 131 +DROP TEXT SEARCH CONFIGURATION dummy_tst +-- +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/tsearch.metadata.json b/parser/testdata/summary/postgres_regress/tsearch.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tsearch.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tsearch.test b/parser/testdata/summary/postgres_regress/tsearch.test new file mode 100644 index 0000000..56eafe2 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tsearch.test @@ -0,0 +1,2992 @@ +== 001 +-- directory paths are passed to us in environment variables + +|-- +-- Sanity checks for text search catalogs +|-- +-- NB: we assume the oidjoins test will have caught any dangling links, +-- that is OID or REGPROC fields that are not zero and do not match some +-- row in the linked-to table. However, if we want to enforce that a link +-- field can't be 0, we have to check it here. + +-- Find unexpected zero link entries + +SELECT oid, prsname +FROM pg_ts_parser +WHERE prsnamespace = 0 OR prsstart = 0 OR prstoken = 0 OR prsend = 0 OR + -- prsheadline is optional + prslextype = 0 +-- +TABLE: name="pg_ts_parser" schema="" table="pg_ts_parser" ctx=Select +FILTER: schema="" table="" column="prsnamespace" +FILTER: schema="" table="" column="prsstart" +FILTER: schema="" table="" column="prstoken" +FILTER: schema="" table="" column="prsend" +FILTER: schema="" table="" column="prslextype" +STMT: SelectStmt +== 002 +SELECT oid, dictname +FROM pg_ts_dict +WHERE dictnamespace = 0 OR dictowner = 0 OR dicttemplate = 0 +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +FILTER: schema="" table="" column="dictnamespace" +FILTER: schema="" table="" column="dictowner" +FILTER: schema="" table="" column="dicttemplate" +STMT: SelectStmt +== 003 +SELECT oid, tmplname +FROM pg_ts_template +WHERE tmplnamespace = 0 OR tmpllexize = 0 +-- +TABLE: name="pg_ts_template" schema="" table="pg_ts_template" ctx=Select +FILTER: schema="" table="" column="tmplnamespace" +FILTER: schema="" table="" column="tmpllexize" +STMT: SelectStmt +== 004 +-- tmplinit is optional + +SELECT oid, cfgname +FROM pg_ts_config +WHERE cfgnamespace = 0 OR cfgowner = 0 OR cfgparser = 0 +-- +TABLE: name="pg_ts_config" schema="" table="pg_ts_config" ctx=Select +FILTER: schema="" table="" column="cfgnamespace" +FILTER: schema="" table="" column="cfgowner" +FILTER: schema="" table="" column="cfgparser" +STMT: SelectStmt +== 005 +SELECT mapcfg, maptokentype, mapseqno +FROM pg_ts_config_map +WHERE mapcfg = 0 OR mapdict = 0 +-- +TABLE: name="pg_ts_config_map" schema="" table="pg_ts_config_map" ctx=Select +FILTER: schema="" table="" column="mapcfg" +FILTER: schema="" table="" column="mapdict" +STMT: SelectStmt +== 006 +-- Look for pg_ts_config_map entries that aren't one of parser's token types +SELECT * FROM + ( SELECT oid AS cfgid, (ts_token_type(cfgparser)).tokid AS tokid + FROM pg_ts_config ) AS tt +RIGHT JOIN pg_ts_config_map AS m + ON (tt.cfgid=m.mapcfg AND tt.tokid=m.maptokentype) +WHERE + tt.cfgid IS NULL OR tt.tokid IS NULL +-- +TABLE: name="pg_ts_config_map" schema="" table="pg_ts_config_map" ctx=Select +TABLE: name="pg_ts_config" schema="" table="pg_ts_config" ctx=Select +ALIAS: "m"="pg_ts_config_map" +FUNCTION: name="ts_token_type" function="ts_token_type" schema="" ctx=Call +FILTER: schema="" table="tt" column="cfgid" +FILTER: schema="" table="tt" column="tokid" +STMT: SelectStmt +== 007 +-- Load some test data +CREATE TABLE test_tsvector( + t text, + a tsvector +) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: CreateStmt +== 008 +COPY test_tsvector FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +ANALYZE test_tsvector +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: VacuumStmt +== 010 +-- test basic text search behavior without indexes, then with + +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 011 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 012 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 013 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 014 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 015 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 016 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 017 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 018 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 019 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 020 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 021 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 022 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 023 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 024 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 025 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 026 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 027 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 028 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 029 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 030 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 031 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 032 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 033 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 034 +create index wowidx on test_tsvector using gist (a) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 035 +SET enable_seqscan=OFF +-- +STMT: VariableSetStmt +== 036 +SET enable_indexscan=ON +-- +STMT: VariableSetStmt +== 037 +SET enable_bitmapscan=OFF +-- +STMT: VariableSetStmt +== 038 +explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 039 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 040 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 041 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 042 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 043 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 044 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 045 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 046 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 047 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 048 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 049 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 050 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 051 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 052 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 053 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 054 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 055 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 056 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 057 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 058 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 059 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 060 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 061 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 062 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 063 +SET enable_indexscan=OFF +-- +STMT: VariableSetStmt +== 064 +SET enable_bitmapscan=ON +-- +STMT: VariableSetStmt +== 065 +explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 066 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 067 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 068 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 069 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 070 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 071 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 072 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 073 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 074 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 075 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 076 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 077 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 078 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 079 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 080 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 081 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 082 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 083 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 084 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 085 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 086 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 087 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 088 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 089 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 090 +-- Test siglen parameter of GiST tsvector_ops +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(foo=1)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 091 +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=0)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 092 +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=2048)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 093 +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=100,foo='bar')) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 094 +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=100, siglen = 200)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 095 +CREATE INDEX wowidx2 ON test_tsvector USING gist (a tsvector_ops(siglen=1)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 096 +DROP INDEX wowidx +-- +STMT: DropStmt +== 097 +EXPLAIN (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 098 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 099 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 101 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 102 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 103 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 104 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 105 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 106 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 107 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 108 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 109 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 110 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 111 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 112 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 113 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 114 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 115 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 116 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 117 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 118 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 119 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 120 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 121 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 122 +DROP INDEX wowidx2 +-- +STMT: DropStmt +== 123 +CREATE INDEX wowidx ON test_tsvector USING gist (a tsvector_ops(siglen=484)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 124 +EXPLAIN (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 125 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 126 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 127 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 128 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 129 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 130 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 131 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 132 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 133 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 134 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 135 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 136 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 137 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 138 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 139 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 140 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 141 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 142 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 143 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 144 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 145 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 146 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 147 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 148 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 149 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 150 +RESET enable_indexscan +-- +STMT: VariableSetStmt +== 151 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +== 152 +DROP INDEX wowidx +-- +STMT: DropStmt +== 153 +CREATE INDEX wowidx ON test_tsvector USING gin (a) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +== 154 +SET enable_seqscan=OFF +-- +STMT: VariableSetStmt +== 155 +-- GIN only supports bitmapscan, so no need to test plain indexscan + +explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 156 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 157 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 158 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 159 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 160 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 161 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 162 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 163 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 164 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 165 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 166 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 167 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 168 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 169 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 170 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 171 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 172 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 173 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 174 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 175 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 176 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 177 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 178 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 179 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 180 +-- Test optimization of non-empty GIN_SEARCH_MODE_ALL queries +EXPLAIN (COSTS OFF) +SELECT count(*) FROM test_tsvector WHERE a @@ '!qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 181 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 182 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr' AND a @@ '!qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +== 183 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr' AND a @@ '!qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 184 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 185 +INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10 +-- +FUNCTION: name="ts_stat" function="ts_stat" schema="" ctx=Call +STMT: SelectStmt +== 187 +SELECT * FROM ts_stat('SELECT a FROM test_tsvector', 'AB') ORDER BY ndoc DESC, nentry DESC, word +-- +FUNCTION: name="ts_stat" function="ts_stat" schema="" ctx=Call +STMT: SelectStmt +== 188 +--dictionaries and to_tsvector + +SELECT ts_lexize('english_stem', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 189 +SELECT ts_lexize('english_stem', 'identity') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +== 190 +SELECT * FROM ts_token_type('default') +-- +FUNCTION: name="ts_token_type" function="ts_token_type" schema="" ctx=Call +STMT: SelectStmt +== 191 +SELECT * FROM ts_parse('default', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf qwer jf sdjk ewr1> ewri2 +/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 + wow < jqw <> qwerty') +-- +FUNCTION: name="ts_parse" function="ts_parse" schema="" ctx=Call +STMT: SelectStmt +== 192 +SELECT to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf qwer jf sdjk ewr1> ewri2 +/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 + wow < jqw <> qwerty') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 193 +SELECT length(to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf qwer jf sdjk ewr1> ewri2 +/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 + wow < jqw <> qwerty')) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 194 +-- ts_debug + +SELECT * from ts_debug('english', 'abc&nm1;def©ghiõjkl') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +== 195 +-- check parsing of URLs +SELECT * from ts_debug('english', 'http://www.harewoodsolutions.co.uk/press.aspx') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +== 196 +SELECT * from ts_debug('english', 'http://aew.wer0c.ewr/id?ad=qwe&dw') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +== 197 +SELECT * from ts_debug('english', 'http://5aew.werc.ewr:8100/?') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +== 198 +SELECT * from ts_debug('english', '5aew.werc.ewr:8100/?xx') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +== 199 +SELECT token, alias, + dictionaries, dictionaries is null as dnull, array_dims(dictionaries) as ddims, + lexemes, lexemes is null as lnull, array_dims(lexemes) as ldims +from ts_debug('english', 'a title') +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +== 200 +-- to_tsquery + +SELECT to_tsquery('english', 'qwe & sKies ') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 201 +SELECT to_tsquery('simple', 'qwe & sKies ') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 202 +SELECT to_tsquery('english', '''the wether'':dc & '' sKies '':BC ') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 203 +SELECT to_tsquery('english', 'asd&(and|fghj)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 204 +SELECT to_tsquery('english', '(asd&and)|fghj') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 205 +SELECT to_tsquery('english', '(asd&!and)|fghj') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 206 +SELECT to_tsquery('english', '(the|and&(i&1))&fghj') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 207 +SELECT plainto_tsquery('english', 'the and z 1))& fghj') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 208 +SELECT plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 209 +SELECT plainto_tsquery('english', 'foo bar') || plainto_tsquery('english', 'asd fg') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 210 +SELECT plainto_tsquery('english', 'foo bar') || !!plainto_tsquery('english', 'asd fg') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 211 +SELECT plainto_tsquery('english', 'foo bar') && 'asd | fg' +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 212 +-- Check stop word deletion, a and s are stop-words +SELECT to_tsquery('english', '!(a & !b) & c') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 213 +SELECT to_tsquery('english', '!(a & !b)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 214 +SELECT to_tsquery('english', '(1 <-> 2) <-> a') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 215 +SELECT to_tsquery('english', '(1 <-> a) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 216 +SELECT to_tsquery('english', '(a <-> 1) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 217 +SELECT to_tsquery('english', 'a <-> (1 <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 218 +SELECT to_tsquery('english', '1 <-> (a <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 219 +SELECT to_tsquery('english', '1 <-> (2 <-> a)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 220 +SELECT to_tsquery('english', '(1 <-> 2) <3> a') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 221 +SELECT to_tsquery('english', '(1 <-> a) <3> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 222 +SELECT to_tsquery('english', '(a <-> 1) <3> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 223 +SELECT to_tsquery('english', 'a <3> (1 <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 224 +SELECT to_tsquery('english', '1 <3> (a <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 225 +SELECT to_tsquery('english', '1 <3> (2 <-> a)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 226 +SELECT to_tsquery('english', '(1 <3> 2) <-> a') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 227 +SELECT to_tsquery('english', '(1 <3> a) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 228 +SELECT to_tsquery('english', '(a <3> 1) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 229 +SELECT to_tsquery('english', 'a <-> (1 <3> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 230 +SELECT to_tsquery('english', '1 <-> (a <3> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 231 +SELECT to_tsquery('english', '1 <-> (2 <3> a)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 232 +SELECT to_tsquery('english', '((a <-> 1) <-> 2) <-> s') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 233 +SELECT to_tsquery('english', '(2 <-> (a <-> 1)) <-> s') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 234 +SELECT to_tsquery('english', '((1 <-> a) <-> 2) <-> s') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 235 +SELECT to_tsquery('english', '(2 <-> (1 <-> a)) <-> s') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 236 +SELECT to_tsquery('english', 's <-> ((a <-> 1) <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 237 +SELECT to_tsquery('english', 's <-> (2 <-> (a <-> 1))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 238 +SELECT to_tsquery('english', 's <-> ((1 <-> a) <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 239 +SELECT to_tsquery('english', 's <-> (2 <-> (1 <-> a))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 240 +SELECT to_tsquery('english', '((a <-> 1) <-> s) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 241 +SELECT to_tsquery('english', '(s <-> (a <-> 1)) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 242 +SELECT to_tsquery('english', '((1 <-> a) <-> s) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 243 +SELECT to_tsquery('english', '(s <-> (1 <-> a)) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 244 +SELECT to_tsquery('english', '2 <-> ((a <-> 1) <-> s)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 245 +SELECT to_tsquery('english', '2 <-> (s <-> (a <-> 1))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 246 +SELECT to_tsquery('english', '2 <-> ((1 <-> a) <-> s)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 247 +SELECT to_tsquery('english', '2 <-> (s <-> (1 <-> a))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 248 +SELECT to_tsquery('english', 'foo <-> (a <-> (the <-> bar))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 249 +SELECT to_tsquery('english', '((foo <-> a) <-> the) <-> bar') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 250 +SELECT to_tsquery('english', 'foo <-> a <-> the <-> bar') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 251 +SELECT phraseto_tsquery('english', 'PostgreSQL can be extended by the user in many ways') +-- +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 252 +SELECT ts_rank_cd(to_tsvector('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +'), to_tsquery('english', 'paint&water')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 253 +SELECT ts_rank_cd(to_tsvector('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +'), to_tsquery('english', 'breath&motion&water')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 254 +SELECT ts_rank_cd(to_tsvector('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +'), to_tsquery('english', 'ocean')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 255 +SELECT ts_rank_cd(to_tsvector('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +'), to_tsquery('english', 'painted <-> Ship')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 256 +SELECT ts_rank_cd(strip(to_tsvector('both stripped')), + to_tsquery('both & stripped')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 257 +SELECT ts_rank_cd(to_tsvector('unstripped') || strip(to_tsvector('stripped')), + to_tsquery('unstripped & stripped')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 258 +--headline tests +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'paint&water')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 259 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'breath&motion&water')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 260 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'ocean')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 261 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'day & drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 262 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'day | drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 263 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'day | !drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 264 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'painted <-> Ship & drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 265 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'painted <-> Ship | drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 266 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'painted <-> Ship | !drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 267 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', phraseto_tsquery('english', 'painted Ocean')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 268 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', phraseto_tsquery('english', 'idle as a painted Ship')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 269 +SELECT ts_headline('english', +'Lorem ipsum urna. Nullam nullam ullamcorper urna.', +to_tsquery('english','Lorem') && phraseto_tsquery('english','ullamcorper urna'), +'MaxWords=100, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 270 +SELECT ts_headline('english', +'Lorem ipsum urna. Nullam nullam ullamcorper urna.', +phraseto_tsquery('english','ullamcorper urna'), +'MaxWords=100, MinWords=5') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 271 +SELECT ts_headline('english', ' + + + +Sea view wow foo bar qq +YES   +ff-bg + + +', +to_tsquery('english', 'sea&foo'), 'HighlightAll=true') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 272 +SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 <-> 3', 'MaxWords=2, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +STMT: SelectStmt +== 273 +SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 & 3', 'MaxWords=4, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +STMT: SelectStmt +== 274 +SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 <-> 3', 'MaxWords=4, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +STMT: SelectStmt +== 275 +--Check if headline fragments work +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'ocean'), 'MaxFragments=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 276 +--Check if more than one fragments are displayed +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 277 +--Fragments when there all query words are not in the document +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'ocean & seahorse'), 'MaxFragments=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 278 +--FragmentDelimiter option +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2,FragmentDelimiter=***') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 279 +--Fragments with phrase search +SELECT ts_headline('english', +'Lorem ipsum urna. Nullam nullam ullamcorper urna.', +to_tsquery('english','Lorem') && phraseto_tsquery('english','ullamcorper urna'), +'MaxFragments=100, MaxWords=100, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 280 +-- Edge cases with empty query +SELECT ts_headline('english', +'', to_tsquery('english', '')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 281 +SELECT ts_headline('english', +'foo bar', to_tsquery('english', '')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 282 +--Rewrite sub system + +CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DDL +STMT: CreateStmt +== 283 +'New York' new <-> york | big <-> apple | nyc +Moscow moskva | moscow +'Sanct Peter' Peterburg | peter | 'Sanct Peterburg' +foo & bar & qq foo & (bar | qq) & city +1 & (2 <-> 3) 2 <-> 4 +5 <-> 6 5 <-> 7 + +ALTER TABLE test_tsquery ADD COLUMN keyword tsquery +-- +ERROR: syntax error at or near "'New York'" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 284 +UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DML +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: UpdateStmt +== 285 +ALTER TABLE test_tsquery ADD COLUMN sample tsquery +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DDL +STMT: AlterTableStmt +== 286 +UPDATE test_tsquery SET sample = to_tsquery('english', txtsample::text) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DML +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: UpdateStmt +== 287 +SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 288 +SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 289 +SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 290 +SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 291 +SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 292 +CREATE UNIQUE INDEX bt_tsq ON test_tsquery (keyword) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DDL +STMT: IndexStmt +== 293 +SET enable_seqscan=OFF +-- +STMT: VariableSetStmt +== 294 +SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 295 +SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 296 +SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 297 +SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 298 +SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 299 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 300 +SELECT ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big & apple | nyc | new & york & city') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 301 +SELECT ts_rewrite(ts_rewrite('new & !york ', 'york', '!jersey'), + 'jersey', 'mexico') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 302 +SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 303 +SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 304 +SELECT ts_rewrite('bar & qq & foo & (new <-> york)', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 305 +SELECT ts_rewrite( 'moscow', 'SELECT keyword, sample FROM test_tsquery') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 306 +SELECT ts_rewrite( 'moscow & hotel', 'SELECT keyword, sample FROM test_tsquery') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 307 +SELECT ts_rewrite( 'bar & qq & foo & (new <-> york)', 'SELECT keyword, sample FROM test_tsquery') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 308 +SELECT ts_rewrite('1 & (2 <-> 3)', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 309 +SELECT ts_rewrite('1 & (2 <2> 3)', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 310 +SELECT ts_rewrite('5 <-> (1 & (2 <-> 3))', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 311 +SELECT ts_rewrite('5 <-> (6 | 8)', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +== 312 +-- Check empty substitution +SELECT ts_rewrite(to_tsquery('5 & (6 | 5)'), to_tsquery('5'), to_tsquery('')) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 313 +SELECT ts_rewrite(to_tsquery('!5'), to_tsquery('5'), to_tsquery('')) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 314 +SELECT keyword FROM test_tsquery WHERE keyword @> 'new' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 315 +SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 316 +SELECT keyword FROM test_tsquery WHERE keyword <@ 'new' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 317 +SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 318 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 319 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 320 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 321 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 322 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 323 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 324 +CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DDL +STMT: IndexStmt +== 325 +SET enable_seqscan=OFF +-- +STMT: VariableSetStmt +== 326 +SELECT keyword FROM test_tsquery WHERE keyword @> 'new' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 327 +SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 328 +SELECT keyword FROM test_tsquery WHERE keyword <@ 'new' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 329 +SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +== 330 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 331 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 332 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 333 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 334 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 335 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 336 +SELECT ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="tsquery_phrase" function="tsquery_phrase" schema="" ctx=Call +STMT: SelectStmt +== 337 +SELECT to_tsvector('foo bar') @@ + ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="tsquery_phrase" function="tsquery_phrase" schema="" ctx=Call +STMT: SelectStmt +== 338 +SELECT to_tsvector('bar baz') @@ + ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="tsquery_phrase" function="tsquery_phrase" schema="" ctx=Call +STMT: SelectStmt +== 339 +RESET enable_seqscan +-- +STMT: VariableSetStmt +== 340 +--test GUC +SET default_text_search_config=simple +-- +STMT: VariableSetStmt +== 341 +SELECT to_tsvector('SKIES My booKs') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 342 +SELECT plainto_tsquery('SKIES My booKs') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 343 +SELECT to_tsquery('SKIES & My | booKs') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 344 +SET default_text_search_config=english +-- +STMT: VariableSetStmt +== 345 +SELECT to_tsvector('SKIES My booKs') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 346 +SELECT plainto_tsquery('SKIES My booKs') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 347 +SELECT to_tsquery('SKIES & My | booKs') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 348 +--trigger +CREATE TRIGGER tsvectorupdate +BEFORE UPDATE OR INSERT ON test_tsvector +FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(a, 'pg_catalog.english', t) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: CreateTrigStmt +== 349 +SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 350 +INSERT INTO test_tsvector (t) VALUES ('345 qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 351 +SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 352 +UPDATE test_tsvector SET t = null WHERE t = '345 qwerty' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DML +STMT: UpdateStmt +== 353 +SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 354 +INSERT INTO test_tsvector (t) VALUES ('345 qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 355 +SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 356 +-- Test inlining of immutable constant functions + +-- to_tsquery(text) is not immutable, so it won't be inlined +explain (costs off) +select * from test_tsquery, to_tsquery('new') q where txtsample @@ q +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="txtsample" +FILTER: schema="" table="" column="q" +STMT: ExplainStmt +STMT: SelectStmt +== 357 +-- to_tsquery(regconfig, text) is an immutable function. +-- That allows us to get rid of using function scan and join at all. +explain (costs off) +select * from test_tsquery, to_tsquery('english', 'new') q where txtsample @@ q +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="txtsample" +FILTER: schema="" table="" column="q" +STMT: ExplainStmt +STMT: SelectStmt +== 358 +-- test finding items in GIN's pending list +create temp table pendtest (ts tsvector) +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=DDL +STMT: CreateStmt +== 359 +create index pendtest_idx on pendtest using gin(ts) +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=DDL +STMT: IndexStmt +== 360 +insert into pendtest values (to_tsvector('Lore ipsam')) +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=DML +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 361 +insert into pendtest values (to_tsvector('Lore ipsum')) +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=DML +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 362 +select * from pendtest where 'ipsu:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +== 363 +select * from pendtest where 'ipsa:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +== 364 +select * from pendtest where 'ips:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +== 365 +select * from pendtest where 'ipt:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +== 366 +select * from pendtest where 'ipi:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +== 367 +--check OP_PHRASE on index +create temp table phrase_index_test(fts tsvector) +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=DDL +STMT: CreateStmt +== 368 +insert into phrase_index_test values ('A fat cat has just eaten a rat.') +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 369 +insert into phrase_index_test values (to_tsvector('english', 'A fat cat has just eaten a rat.')) +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=DML +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 370 +create index phrase_index_test_idx on phrase_index_test using gin(fts) +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=DDL +STMT: IndexStmt +== 371 +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 372 +select * from phrase_index_test where fts @@ phraseto_tsquery('english', 'fat cat') +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=Select +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="fts" +STMT: SelectStmt +== 373 +set enable_seqscan = on +-- +STMT: VariableSetStmt +== 374 +-- test websearch_to_tsquery function +select websearch_to_tsquery('simple', 'I have a fat:*ABCD cat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 375 +select websearch_to_tsquery('simple', 'orange:**AABBCCDD') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 376 +select websearch_to_tsquery('simple', 'fat:A!cat:B|rat:C<') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 377 +select websearch_to_tsquery('simple', 'fat:A : cat:B') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 378 +select websearch_to_tsquery('simple', 'fat*rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 379 +select websearch_to_tsquery('simple', 'fat-rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 380 +select websearch_to_tsquery('simple', 'fat_rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 381 +-- weights are completely ignored +select websearch_to_tsquery('simple', 'abc : def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 382 +select websearch_to_tsquery('simple', 'abc:def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 383 +select websearch_to_tsquery('simple', 'a:::b') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 384 +select websearch_to_tsquery('simple', 'abc:d') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 385 +select websearch_to_tsquery('simple', ':') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 386 +-- these operators are ignored +select websearch_to_tsquery('simple', 'abc & def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 387 +select websearch_to_tsquery('simple', 'abc | def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 388 +select websearch_to_tsquery('simple', 'abc <-> def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 389 +-- parens are ignored, too +select websearch_to_tsquery('simple', 'abc (pg or class)') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 390 +select websearch_to_tsquery('simple', '(foo bar) or (ding dong)') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 391 +-- NOT is ignored in quotes +select websearch_to_tsquery('english', 'My brand new smartphone') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 392 +select websearch_to_tsquery('english', 'My brand "new smartphone"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 393 +select websearch_to_tsquery('english', 'My brand "new -smartphone"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 394 +-- test OR operator +select websearch_to_tsquery('simple', 'cat or rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 395 +select websearch_to_tsquery('simple', 'cat OR rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 396 +select websearch_to_tsquery('simple', 'cat "OR" rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 397 +select websearch_to_tsquery('simple', 'cat OR') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 398 +select websearch_to_tsquery('simple', 'OR rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 399 +select websearch_to_tsquery('simple', '"fat cat OR rat"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 400 +select websearch_to_tsquery('simple', 'fat (cat OR rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 401 +select websearch_to_tsquery('simple', 'or OR or') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 402 +-- OR is an operator here ... +select websearch_to_tsquery('simple', '"fat cat"or"fat rat"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 403 +select websearch_to_tsquery('simple', 'fat or(rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 404 +select websearch_to_tsquery('simple', 'fat or)rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 405 +select websearch_to_tsquery('simple', 'fat or&rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 406 +select websearch_to_tsquery('simple', 'fat or|rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 407 +select websearch_to_tsquery('simple', 'fat or!rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 408 +select websearch_to_tsquery('simple', 'fat orrat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 410 +select websearch_to_tsquery('simple', 'fat or ') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 411 +-- ... but not here +select websearch_to_tsquery('simple', 'abc orange') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 412 +select websearch_to_tsquery('simple', 'abc OR1234') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 413 +select websearch_to_tsquery('simple', 'abc or-abc') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 414 +select websearch_to_tsquery('simple', 'abc OR_abc') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 415 +-- test quotes +select websearch_to_tsquery('english', '"pg_class pg') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 416 +select websearch_to_tsquery('english', 'pg_class pg"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 417 +select websearch_to_tsquery('english', '"pg_class pg"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 418 +select websearch_to_tsquery('english', '"pg_class : pg"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 419 +select websearch_to_tsquery('english', 'abc "pg_class pg"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 420 +select websearch_to_tsquery('english', '"pg_class pg" def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 421 +select websearch_to_tsquery('english', 'abc "pg pg_class pg" def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 422 +select websearch_to_tsquery('english', ' or "pg pg_class pg" or ') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 423 +select websearch_to_tsquery('english', '""pg pg_class pg""') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 424 +select websearch_to_tsquery('english', 'abc """"" def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 425 +select websearch_to_tsquery('english', 'cat -"fat rat"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 426 +select websearch_to_tsquery('english', 'cat -"fat rat" cheese') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 427 +select websearch_to_tsquery('english', 'abc "def -"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 428 +select websearch_to_tsquery('english', 'abc "def :"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 429 +select websearch_to_tsquery('english', '"A fat cat" has just eaten a -rat.') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 430 +select websearch_to_tsquery('english', '"A fat cat" has just eaten OR !rat.') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 431 +select websearch_to_tsquery('english', '"A fat cat" has just (+eaten OR -rat)') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 432 +select websearch_to_tsquery('english', 'this is ----fine') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 433 +select websearch_to_tsquery('english', '(()) )))) this ||| is && -fine, "dear friend" OR good') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 434 +select websearch_to_tsquery('english', 'an old <-> cat " is fine &&& too') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 435 +select websearch_to_tsquery('english', '"A the" OR just on') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 436 +select websearch_to_tsquery('english', '"a fat cat" ate a rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 437 +select to_tsvector('english', 'A fat cat ate a rat') @@ + websearch_to_tsquery('english', '"a fat cat" ate a rat') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 438 +select to_tsvector('english', 'A fat grey cat ate a rat') @@ + websearch_to_tsquery('english', '"a fat cat" ate a rat') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 439 +-- cases handled by gettoken_tsvector() +select websearch_to_tsquery('''') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 440 +select websearch_to_tsquery('''abc''''def''') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 441 +select websearch_to_tsquery('\abc') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +== 442 +select websearch_to_tsquery('\') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/tsrf.metadata.json b/parser/testdata/summary/postgres_regress/tsrf.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tsrf.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tsrf.test b/parser/testdata/summary/postgres_regress/tsrf.test new file mode 100644 index 0000000..d29cca5 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tsrf.test @@ -0,0 +1,547 @@ +== 001 +|-- +-- tsrf - targetlist set returning function tests +|-- + +-- simple srf +SELECT generate_series(1, 3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 002 +-- parallel iteration +SELECT generate_series(1, 3), generate_series(3,5) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 003 +-- parallel iteration, different number of rows +SELECT generate_series(1, 2), generate_series(1,4) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 004 +-- srf, with SRF argument +SELECT generate_series(1, generate_series(1, 3)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 005 +-- but we've traditionally rejected the same in FROM +SELECT * FROM generate_series(1, generate_series(1, 3)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 006 +-- srf, with two SRF arguments +SELECT generate_series(generate_series(1,3), generate_series(2, 4)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 007 +-- check proper nesting of SRFs in different expressions +explain (verbose, costs off) +SELECT generate_series(1, generate_series(1, 3)), generate_series(2, 4) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 008 +SELECT generate_series(1, generate_series(1, 3)), generate_series(2, 4) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 009 +CREATE TABLE few(id int, dataa text, datab text) +-- +TABLE: name="few" schema="" table="few" ctx=DDL +STMT: CreateStmt +== 010 +INSERT INTO few VALUES(1, 'a', 'foo'),(2, 'a', 'bar'),(3, 'b', 'bar') +-- +TABLE: name="few" schema="" table="few" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +-- SRF with a provably-dummy relation +explain (verbose, costs off) +SELECT unnest(ARRAY[1, 2]) FROM few WHERE false +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 012 +SELECT unnest(ARRAY[1, 2]) FROM few WHERE false +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 013 +-- SRF shouldn't prevent upper query from recognizing lower as dummy +explain (verbose, costs off) +SELECT * FROM few f1, + (SELECT unnest(ARRAY[1,2]) FROM few f2 WHERE false OFFSET 0) ss +-- +TABLE: name="few" schema="" table="few" ctx=Select +TABLE: name="few" schema="" table="few" ctx=Select +ALIAS: "f1"="few" +ALIAS: "f2"="few" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 014 +SELECT * FROM few f1, + (SELECT unnest(ARRAY[1,2]) FROM few f2 WHERE false OFFSET 0) ss +-- +TABLE: name="few" schema="" table="few" ctx=Select +TABLE: name="few" schema="" table="few" ctx=Select +ALIAS: "f1"="few" +ALIAS: "f2"="few" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 015 +-- SRF output order of sorting is maintained, if SRF is not referenced +SELECT few.id, generate_series(1,3) g FROM few ORDER BY id DESC +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 016 +-- but SRFs can be referenced in sort +SELECT few.id, generate_series(1,3) g FROM few ORDER BY id, g DESC +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT few.id, generate_series(1,3) g FROM few ORDER BY id, generate_series(1,3) DESC +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- it's weird to have ORDER BYs that increase the number of results +SELECT few.id FROM few ORDER BY id, generate_series(1,3) DESC +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- SRFs are computed after aggregation +SET enable_hashagg TO 0 +-- +STMT: VariableSetStmt +== 020 +-- stable output order +SELECT few.dataa, count(*), min(id), max(id), unnest('{1,1,3}'::int[]) FROM few WHERE few.id = 1 GROUP BY few.dataa +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="few" column="id" +STMT: SelectStmt +== 021 +-- unless referenced in GROUP BY clause +SELECT few.dataa, count(*), min(id), max(id), unnest('{1,1,3}'::int[]) FROM few WHERE few.id = 1 GROUP BY few.dataa, unnest('{1,1,3}'::int[]) +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="few" column="id" +STMT: SelectStmt +== 022 +SELECT few.dataa, count(*), min(id), max(id), unnest('{1,1,3}'::int[]) FROM few WHERE few.id = 1 GROUP BY few.dataa, 5 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="few" column="id" +STMT: SelectStmt +== 023 +RESET enable_hashagg +-- +STMT: VariableSetStmt +== 024 +-- check HAVING works when GROUP BY does [not] reference SRF output +SELECT dataa, generate_series(1,1), count(*) FROM few GROUP BY 1 HAVING count(*) > 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 025 +SELECT dataa, generate_series(1,1), count(*) FROM few GROUP BY 1, 2 HAVING count(*) > 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 026 +-- it's weird to have GROUP BYs that increase the number of results +SELECT few.dataa, count(*) FROM few WHERE dataa = 'a' GROUP BY few.dataa ORDER BY 2 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="dataa" +STMT: SelectStmt +== 027 +SELECT few.dataa, count(*) FROM few WHERE dataa = 'a' GROUP BY few.dataa, unnest('{1,1,3}'::int[]) ORDER BY 2 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="" column="dataa" +STMT: SelectStmt +== 028 +-- SRFs are not allowed if they'd need to be conditionally executed +SELECT q1, case when q1 > 0 then generate_series(1,3) else 0 end FROM int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 029 +SELECT q1, coalesce(generate_series(1,3), 0) FROM int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 030 +-- SRFs are not allowed in aggregate arguments +SELECT min(generate_series(1, 3)) FROM few +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 031 +-- ... unless they're within a sub-select +SELECT sum((3 = ANY(SELECT generate_series(1,4)))::int) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT sum((3 = ANY(SELECT lag(x) over(order by x) + FROM generate_series(1,4) x))::int) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 033 +-- SRFs are not allowed in window function arguments, either +SELECT min(generate_series(1, 3)) OVER() FROM few +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 034 +-- SRFs are normally computed after window functions +SELECT id,lag(id) OVER(), count(*) OVER(), generate_series(1,3) FROM few +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 035 +-- unless referencing SRFs +SELECT SUM(count(*)) OVER(PARTITION BY generate_series(1,3) ORDER BY generate_series(1,3)), generate_series(1,3) g FROM few GROUP BY g +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- sorting + grouping +SELECT few.dataa, count(*), min(id), max(id), generate_series(1,3) FROM few GROUP BY few.dataa ORDER BY 5, 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- grouping sets are a bit special, they produce NULLs in columns not actually NULL +set enable_hashagg = false +-- +STMT: VariableSetStmt +== 038 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab) +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 039 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab) ORDER BY dataa +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 040 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab) ORDER BY g +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 041 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab, g) +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 042 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab, g) ORDER BY dataa +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 043 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab, g) ORDER BY g +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 044 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 045 +-- case with degenerate ORDER BY +explain (verbose, costs off) +select 'foo' as f, generate_series(1,2) as g from few order by 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 046 +select 'foo' as f, generate_series(1,2) as g from few order by 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- data modification +CREATE TABLE fewmore AS SELECT generate_series(1,3) AS data +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 048 +INSERT INTO fewmore VALUES(generate_series(4,5)) +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 049 +SELECT * FROM fewmore +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=Select +STMT: SelectStmt +== 050 +-- SRFs are not allowed in UPDATE (they once were, but it was nonsense) +UPDATE fewmore SET data = generate_series(4,9) +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: UpdateStmt +== 051 +-- SRFs are not allowed in RETURNING +INSERT INTO fewmore VALUES(1) RETURNING generate_series(1,3) +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 052 +-- nor standalone VALUES (but surely this is a bug?) +VALUES(1, generate_series(1,2)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 053 +-- We allow tSRFs that are not at top level +SELECT int4mul(generate_series(1,2), 10) +-- +FUNCTION: name="int4mul" function="int4mul" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 054 +SELECT generate_series(1,3) IS DISTINCT FROM 2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 055 +-- but SRFs in function RTEs must be at top level (annoying restriction) +SELECT * FROM int4mul(generate_series(1,2), 10) +-- +FUNCTION: name="int4mul" function="int4mul" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- DISTINCT ON is evaluated before tSRF evaluation if SRF is not +-- referenced either in ORDER BY or in the DISTINCT ON list. The ORDER +-- BY reference can be implicitly generated, if there's no other ORDER BY. + +-- implicit reference (via implicit ORDER) to all columns +SELECT DISTINCT ON (a) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 057 +-- unreferenced in DISTINCT ON or ORDER BY +SELECT DISTINCT ON (a) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +ORDER BY a, b DESC +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 058 +-- referenced in ORDER BY +SELECT DISTINCT ON (a) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +ORDER BY a, b DESC, g DESC +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 059 +-- referenced in ORDER BY and DISTINCT ON +SELECT DISTINCT ON (a, b, g) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +ORDER BY a, b DESC, g DESC +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 060 +-- only SRF mentioned in DISTINCT ON +SELECT DISTINCT ON (g) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 061 +-- LIMIT / OFFSET is evaluated after SRF evaluation +SELECT a, generate_series(1,2) FROM (VALUES(1),(2),(3)) r(a) LIMIT 2 OFFSET 2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 062 +-- SRFs are not allowed in LIMIT. +SELECT 1 LIMIT generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 063 +-- tSRF in correlated subquery, referencing table outside +SELECT (SELECT generate_series(1,3) LIMIT 1 OFFSET few.id) FROM few +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 064 +-- tSRF in correlated subquery, referencing SRF outside +SELECT (SELECT generate_series(1,3) LIMIT 1 OFFSET g.i) FROM generate_series(0,3) g(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 065 +-- Operators can return sets too +CREATE OPERATOR |@| (PROCEDURE = unnest, RIGHTARG = ANYARRAY) +-- +STMT: DefineStmt +== 066 +SELECT |@|ARRAY[1,2,3] +-- +STMT: SelectStmt +== 067 +-- Some fun cases involving duplicate SRF calls +explain (verbose, costs off) +select generate_series(1,3) as x, generate_series(1,3) + 1 as xp1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 068 +select generate_series(1,3) as x, generate_series(1,3) + 1 as xp1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 069 +explain (verbose, costs off) +select generate_series(1,3)+1 order by generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 070 +select generate_series(1,3)+1 order by generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 071 +-- Check that SRFs of same nesting level run in lockstep +explain (verbose, costs off) +select generate_series(1,3) as x, generate_series(3,6) + 1 as y +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 072 +select generate_series(1,3) as x, generate_series(3,6) + 1 as y +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 073 +-- Clean up +DROP TABLE few +-- +TABLE: name="few" schema="" table="few" ctx=DDL +STMT: DropStmt +== 074 +DROP TABLE fewmore +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/tstypes.metadata.json b/parser/testdata/summary/postgres_regress/tstypes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tstypes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tstypes.test b/parser/testdata/summary/postgres_regress/tstypes.test new file mode 100644 index 0000000..6bdc6f8 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tstypes.test @@ -0,0 +1,1110 @@ +== 001 +-- deal with numeric instability of ts_rank +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +== 002 +--Base tsvector test + +SELECT '1'::tsvector +-- +STMT: SelectStmt +== 003 +SELECT '1 '::tsvector +-- +STMT: SelectStmt +== 004 +SELECT ' 1'::tsvector +-- +STMT: SelectStmt +== 005 +SELECT ' 1 '::tsvector +-- +STMT: SelectStmt +== 006 +SELECT '1 2'::tsvector +-- +STMT: SelectStmt +== 007 +SELECT '''1 2'''::tsvector +-- +STMT: SelectStmt +== 008 +SELECT E'''1 \\''2'''::tsvector +-- +STMT: SelectStmt +== 009 +SELECT E'''1 \\''2''3'::tsvector +-- +STMT: SelectStmt +== 010 +SELECT E'''1 \\''2'' 3'::tsvector +-- +STMT: SelectStmt +== 011 +SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector +-- +STMT: SelectStmt +== 012 +SELECT $$'\\as' ab\c ab\\c AB\\\c ab\\\\c$$::tsvector +-- +STMT: SelectStmt +== 013 +SELECT tsvectorin(tsvectorout($$'\\as' ab\c ab\\c AB\\\c ab\\\\c$$::tsvector)) +-- +FUNCTION: name="tsvectorin" function="tsvectorin" schema="" ctx=Call +FUNCTION: name="tsvectorout" function="tsvectorout" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT '''w'':4A,3B,2C,1D,5 a:8' +-- +STMT: SelectStmt +== 015 +SELECT 'a:3A b:2a'::tsvector || 'ba:1234 a:1B' +-- +STMT: SelectStmt +== 016 +SELECT $$'' '1' '2'$$::tsvector +-- +STMT: SelectStmt +== 017 +-- error, empty lexeme is not allowed + +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('foo', 'tsvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT pg_input_is_valid($$''$$, 'tsvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT * FROM pg_input_error_info($$''$$, 'tsvector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 020 +--Base tsquery test +SELECT '1'::tsquery +-- +STMT: SelectStmt +== 021 +SELECT '1 '::tsquery +-- +STMT: SelectStmt +== 022 +SELECT ' 1'::tsquery +-- +STMT: SelectStmt +== 023 +SELECT ' 1 '::tsquery +-- +STMT: SelectStmt +== 024 +SELECT '''1 2'''::tsquery +-- +STMT: SelectStmt +== 025 +SELECT E'''1 \\''2'''::tsquery +-- +STMT: SelectStmt +== 026 +SELECT '!1'::tsquery +-- +STMT: SelectStmt +== 027 +SELECT '1|2'::tsquery +-- +STMT: SelectStmt +== 028 +SELECT '1|!2'::tsquery +-- +STMT: SelectStmt +== 029 +SELECT '!1|2'::tsquery +-- +STMT: SelectStmt +== 030 +SELECT '!1|!2'::tsquery +-- +STMT: SelectStmt +== 031 +SELECT '!(!1|!2)'::tsquery +-- +STMT: SelectStmt +== 032 +SELECT '!(!1|2)'::tsquery +-- +STMT: SelectStmt +== 033 +SELECT '!(1|!2)'::tsquery +-- +STMT: SelectStmt +== 034 +SELECT '!(1|2)'::tsquery +-- +STMT: SelectStmt +== 035 +SELECT '1&2'::tsquery +-- +STMT: SelectStmt +== 036 +SELECT '!1&2'::tsquery +-- +STMT: SelectStmt +== 037 +SELECT '1&!2'::tsquery +-- +STMT: SelectStmt +== 038 +SELECT '!1&!2'::tsquery +-- +STMT: SelectStmt +== 039 +SELECT '(1&2)'::tsquery +-- +STMT: SelectStmt +== 040 +SELECT '1&(2)'::tsquery +-- +STMT: SelectStmt +== 041 +SELECT '!(1)&2'::tsquery +-- +STMT: SelectStmt +== 042 +SELECT '!(1&2)'::tsquery +-- +STMT: SelectStmt +== 043 +SELECT '1|2&3'::tsquery +-- +STMT: SelectStmt +== 044 +SELECT '1|(2&3)'::tsquery +-- +STMT: SelectStmt +== 045 +SELECT '(1|2)&3'::tsquery +-- +STMT: SelectStmt +== 046 +SELECT '1|2&!3'::tsquery +-- +STMT: SelectStmt +== 047 +SELECT '1|!2&3'::tsquery +-- +STMT: SelectStmt +== 048 +SELECT '!1|2&3'::tsquery +-- +STMT: SelectStmt +== 049 +SELECT '!1|(2&3)'::tsquery +-- +STMT: SelectStmt +== 050 +SELECT '!(1|2)&3'::tsquery +-- +STMT: SelectStmt +== 051 +SELECT '(!1|2)&3'::tsquery +-- +STMT: SelectStmt +== 052 +SELECT '1|(2|(4|(5|6)))'::tsquery +-- +STMT: SelectStmt +== 053 +SELECT '1|2|4|5|6'::tsquery +-- +STMT: SelectStmt +== 054 +SELECT '1&(2&(4&(5&6)))'::tsquery +-- +STMT: SelectStmt +== 055 +SELECT '1&2&4&5&6'::tsquery +-- +STMT: SelectStmt +== 056 +SELECT '1&(2&(4&(5|6)))'::tsquery +-- +STMT: SelectStmt +== 057 +SELECT '1&(2&(4&(5|!6)))'::tsquery +-- +STMT: SelectStmt +== 058 +SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery +-- +STMT: SelectStmt +== 059 +SELECT $$'\\as'$$::tsquery +-- +STMT: SelectStmt +== 060 +SELECT 'a:* & nbb:*ac | doo:a* | goo'::tsquery +-- +STMT: SelectStmt +== 061 +SELECT '!!b'::tsquery +-- +STMT: SelectStmt +== 062 +SELECT '!!!b'::tsquery +-- +STMT: SelectStmt +== 063 +SELECT '!(!b)'::tsquery +-- +STMT: SelectStmt +== 064 +SELECT 'a & !!b'::tsquery +-- +STMT: SelectStmt +== 065 +SELECT '!!a & b'::tsquery +-- +STMT: SelectStmt +== 066 +SELECT '!!a & !!b'::tsquery +-- +STMT: SelectStmt +== 067 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('foo', 'tsquery') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 068 +SELECT pg_input_is_valid('foo!', 'tsquery') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 069 +SELECT * FROM pg_input_error_info('foo!', 'tsquery') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 070 +SELECT * FROM pg_input_error_info('a <100000> b', 'tsquery') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 071 +--comparisons +SELECT 'a' < 'b & c'::tsquery as "true" +-- +STMT: SelectStmt +== 072 +SELECT 'a' > 'b & c'::tsquery as "false" +-- +STMT: SelectStmt +== 073 +SELECT 'a | f' < 'b & c'::tsquery as "false" +-- +STMT: SelectStmt +== 074 +SELECT 'a | ff' < 'b & c'::tsquery as "false" +-- +STMT: SelectStmt +== 075 +SELECT 'a | f | g' < 'b & c'::tsquery as "false" +-- +STMT: SelectStmt +== 076 +--concatenation +SELECT numnode( 'new'::tsquery ) +-- +FUNCTION: name="numnode" function="numnode" schema="" ctx=Call +STMT: SelectStmt +== 077 +SELECT numnode( 'new & york'::tsquery ) +-- +FUNCTION: name="numnode" function="numnode" schema="" ctx=Call +STMT: SelectStmt +== 078 +SELECT numnode( 'new & york | qwery'::tsquery ) +-- +FUNCTION: name="numnode" function="numnode" schema="" ctx=Call +STMT: SelectStmt +== 079 +SELECT 'foo & bar'::tsquery && 'asd' +-- +STMT: SelectStmt +== 080 +SELECT 'foo & bar'::tsquery || 'asd & fg' +-- +STMT: SelectStmt +== 081 +SELECT 'foo & bar'::tsquery || !!'asd & fg'::tsquery +-- +STMT: SelectStmt +== 082 +SELECT 'foo & bar'::tsquery && 'asd | fg' +-- +STMT: SelectStmt +== 083 +SELECT 'a' <-> 'b & d'::tsquery +-- +STMT: SelectStmt +== 084 +SELECT 'a & g' <-> 'b & d'::tsquery +-- +STMT: SelectStmt +== 085 +SELECT 'a & g' <-> 'b | d'::tsquery +-- +STMT: SelectStmt +== 086 +SELECT 'a & g' <-> 'b <-> d'::tsquery +-- +STMT: SelectStmt +== 087 +SELECT tsquery_phrase('a <3> g', 'b & d', 10) +-- +FUNCTION: name="tsquery_phrase" function="tsquery_phrase" schema="" ctx=Call +STMT: SelectStmt +== 088 +-- tsvector-tsquery operations + +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca' as "true" +-- +STMT: SelectStmt +== 089 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B' as "true" +-- +STMT: SelectStmt +== 090 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:A' as "true" +-- +STMT: SelectStmt +== 091 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:C' as "false" +-- +STMT: SelectStmt +== 092 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:CB' as "true" +-- +STMT: SelectStmt +== 093 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & c:*C' as "false" +-- +STMT: SelectStmt +== 094 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & c:*CB' as "true" +-- +STMT: SelectStmt +== 095 +SELECT 'a b:89 ca:23A,64b cb:80c d:34c'::tsvector @@ 'd:AC & c:*C' as "true" +-- +STMT: SelectStmt +== 096 +SELECT 'a b:89 ca:23A,64c cb:80b d:34c'::tsvector @@ 'd:AC & c:*C' as "true" +-- +STMT: SelectStmt +== 097 +SELECT 'a b:89 ca:23A,64c cb:80b d:34c'::tsvector @@ 'd:AC & c:*B' as "true" +-- +STMT: SelectStmt +== 098 +SELECT 'wa:1D wb:2A'::tsvector @@ 'w:*D & w:*A'::tsquery as "true" +-- +STMT: SelectStmt +== 099 +SELECT 'wa:1D wb:2A'::tsvector @@ 'w:*D <-> w:*A'::tsquery as "true" +-- +STMT: SelectStmt +== 100 +SELECT 'wa:1A wb:2D'::tsvector @@ 'w:*D <-> w:*A'::tsquery as "false" +-- +STMT: SelectStmt +== 101 +SELECT 'wa:1A'::tsvector @@ 'w:*A'::tsquery as "true" +-- +STMT: SelectStmt +== 102 +SELECT 'wa:1A'::tsvector @@ 'w:*D'::tsquery as "false" +-- +STMT: SelectStmt +== 103 +SELECT 'wa:1A'::tsvector @@ '!w:*A'::tsquery as "false" +-- +STMT: SelectStmt +== 104 +SELECT 'wa:1A'::tsvector @@ '!w:*D'::tsquery as "true" +-- +STMT: SelectStmt +== 105 +-- historically, a stripped tsvector matches queries ignoring weights: +SELECT strip('wa:1A'::tsvector) @@ 'w:*A'::tsquery as "true" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +== 106 +SELECT strip('wa:1A'::tsvector) @@ 'w:*D'::tsquery as "true" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +== 107 +SELECT strip('wa:1A'::tsvector) @@ '!w:*A'::tsquery as "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +== 108 +SELECT strip('wa:1A'::tsvector) @@ '!w:*D'::tsquery as "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +== 109 +SELECT 'supernova'::tsvector @@ 'super'::tsquery AS "false" +-- +STMT: SelectStmt +== 110 +SELECT 'supeanova supernova'::tsvector @@ 'super'::tsquery AS "false" +-- +STMT: SelectStmt +== 111 +SELECT 'supeznova supernova'::tsvector @@ 'super'::tsquery AS "false" +-- +STMT: SelectStmt +== 112 +SELECT 'supernova'::tsvector @@ 'super:*'::tsquery AS "true" +-- +STMT: SelectStmt +== 113 +SELECT 'supeanova supernova'::tsvector @@ 'super:*'::tsquery AS "true" +-- +STMT: SelectStmt +== 114 +SELECT 'supeznova supernova'::tsvector @@ 'super:*'::tsquery AS "true" +-- +STMT: SelectStmt +== 115 +--phrase search +SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <-> 2' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 116 +SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <2> 2' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 117 +SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <-> 3' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 118 +SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <2> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 119 +SELECT to_tsvector('simple', '1 2 1 2') @@ '1 <3> 2' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 120 +SELECT to_tsvector('simple', '1 2 11 3') @@ '1 <-> 3' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 121 +SELECT to_tsvector('simple', '1 2 11 3') @@ '1:* <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 122 +SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <-> 2 <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 123 +SELECT to_tsvector('simple', '1 2 3 4') @@ '(1 <-> 2) <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 124 +SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <-> (2 <-> 3)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 125 +SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <2> (2 <-> 3)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 126 +SELECT to_tsvector('simple', '1 2 1 2 3 4') @@ '(1 <-> 2) <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 127 +SELECT to_tsvector('simple', '1 2 1 2 3 4') @@ '1 <-> 2 <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 128 +-- without position data, phrase search does not match +SELECT strip(to_tsvector('simple', '1 2 3 4')) @@ '1 <-> 2 <-> 3' AS "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 129 +select to_tsvector('simple', 'q x q y') @@ 'q <-> (x & y)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 130 +select to_tsvector('simple', 'q x') @@ 'q <-> (x | y <-> z)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 131 +select to_tsvector('simple', 'q y') @@ 'q <-> (x | y <-> z)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 132 +select to_tsvector('simple', 'q y z') @@ 'q <-> (x | y <-> z)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 133 +select to_tsvector('simple', 'q y x') @@ 'q <-> (x | y <-> z)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 134 +select to_tsvector('simple', 'q x y') @@ 'q <-> (x | y <-> z)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 135 +select to_tsvector('simple', 'q x') @@ '(x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 136 +select to_tsvector('simple', 'x q') @@ '(x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 137 +select to_tsvector('simple', 'x y q') @@ '(x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 138 +select to_tsvector('simple', 'x y z') @@ '(x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 139 +select to_tsvector('simple', 'x y z q') @@ '(x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 140 +select to_tsvector('simple', 'y z q') @@ '(x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 141 +select to_tsvector('simple', 'y y q') @@ '(x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 142 +select to_tsvector('simple', 'y y q') @@ '(!x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 143 +select to_tsvector('simple', 'x y q') @@ '(!x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 144 +select to_tsvector('simple', 'y y q') @@ '(x | y <-> !z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 145 +select to_tsvector('simple', 'x q') @@ '(x | y <-> !z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 146 +select to_tsvector('simple', 'x q') @@ '(!x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 147 +select to_tsvector('simple', 'z q') @@ '(!x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 148 +select to_tsvector('simple', 'x y q') @@ '(!x | y) <-> y <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 149 +select to_tsvector('simple', 'x y q') @@ '(!x | !y) <-> y <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 150 +select to_tsvector('simple', 'x y q') @@ '(x | !y) <-> y <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 151 +select to_tsvector('simple', 'x y q') @@ '(x | !!z) <-> y <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 152 +select to_tsvector('simple', 'x y q y') @@ '!x <-> y' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 153 +select to_tsvector('simple', 'x y q y') @@ '!x <-> !y' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 154 +select to_tsvector('simple', 'x y q y') @@ '!x <-> !!y' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 155 +select to_tsvector('simple', 'x y q y') @@ '!(x <-> y)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 156 +select to_tsvector('simple', 'x y q y') @@ '!(x <2> y)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 157 +select strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> y' AS "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 158 +select strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> !y' AS "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 159 +select strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> !!y' AS "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 160 +select strip(to_tsvector('simple', 'x y q y')) @@ '!(x <-> y)' AS "true" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 161 +select strip(to_tsvector('simple', 'x y q y')) @@ '!(x <2> y)' AS "true" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 162 +select to_tsvector('simple', 'x y q y') @@ '!foo' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 163 +select to_tsvector('simple', '') @@ '!foo' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 164 +--ranking +SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 165 +SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 166 +SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s:*') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 167 +SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | sa:*') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 168 +SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 169 +SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 170 +SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 171 +SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 172 +SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +== 173 +SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 174 +SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 175 +SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | s:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 176 +SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | sa:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 177 +SELECT ts_rank_cd(' a:1 sa:3C sab:2c d g'::tsvector, 'a | sa:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 178 +SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 179 +SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 180 +SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 181 +SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 182 +SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 183 +SELECT ts_rank_cd(' a:1 s:2A d g'::tsvector, 'a <-> s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 184 +SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a <-> s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 185 +SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a <-> s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 186 +SELECT ts_rank_cd(' a:1 s:2 d:2A g'::tsvector, 'a <-> s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 187 +SELECT ts_rank_cd(' a:1 s:2,3A d:2A g'::tsvector, 'a <2> s:A') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 188 +SELECT ts_rank_cd(' a:1 b:2 s:3A d:2A g'::tsvector, 'a <2> s:A') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 189 +SELECT ts_rank_cd(' a:1 sa:2D sb:2A g'::tsvector, 'a <-> s:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 190 +SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 191 +SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:* <-> sa:A') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 192 +SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:* <-> sa:B') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +== 193 +SELECT 'a:1 b:2'::tsvector @@ 'a <-> b'::tsquery AS "true" +-- +STMT: SelectStmt +== 194 +SELECT 'a:1 b:2'::tsvector @@ 'a <0> b'::tsquery AS "false" +-- +STMT: SelectStmt +== 195 +SELECT 'a:1 b:2'::tsvector @@ 'a <1> b'::tsquery AS "true" +-- +STMT: SelectStmt +== 196 +SELECT 'a:1 b:2'::tsvector @@ 'a <2> b'::tsquery AS "false" +-- +STMT: SelectStmt +== 197 +SELECT 'a:1 b:3'::tsvector @@ 'a <-> b'::tsquery AS "false" +-- +STMT: SelectStmt +== 198 +SELECT 'a:1 b:3'::tsvector @@ 'a <0> b'::tsquery AS "false" +-- +STMT: SelectStmt +== 199 +SELECT 'a:1 b:3'::tsvector @@ 'a <1> b'::tsquery AS "false" +-- +STMT: SelectStmt +== 200 +SELECT 'a:1 b:3'::tsvector @@ 'a <2> b'::tsquery AS "true" +-- +STMT: SelectStmt +== 201 +SELECT 'a:1 b:3'::tsvector @@ 'a <3> b'::tsquery AS "false" +-- +STMT: SelectStmt +== 202 +SELECT 'a:1 b:3'::tsvector @@ 'a <0> a:*'::tsquery AS "true" +-- +STMT: SelectStmt +== 203 +-- tsvector editing operations + +SELECT strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector) +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +== 204 +SELECT strip('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +== 205 +SELECT strip('base hidden rebel spaceship strike'::tsvector) +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +== 206 +SELECT ts_delete(to_tsvector('english', 'Rebel spaceships, striking from a hidden base'), 'spaceship') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 207 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'base') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 208 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'bas') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 209 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'bases') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 210 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'spaceship') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 211 +SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, 'spaceship') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 212 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, ARRAY['spaceship','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 213 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, ARRAY['spaceships','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 214 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, ARRAY['spaceshi','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 215 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, ARRAY['spaceship','leya','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 216 +SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, ARRAY['spaceship','leya','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 217 +SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, ARRAY['spaceship','leya','rebel','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 218 +SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, ARRAY['spaceship','leya','rebel', '', NULL]) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +== 219 +SELECT unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 220 +SELECT unnest('base hidden rebel spaceship strike'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 221 +SELECT * FROM unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 222 +SELECT * FROM unnest('base hidden rebel spaceship strike'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 223 +SELECT lexeme, positions[1] from unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +== 224 +SELECT tsvector_to_array('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="tsvector_to_array" function="tsvector_to_array" schema="" ctx=Call +STMT: SelectStmt +== 225 +SELECT tsvector_to_array('base hidden rebel spaceship strike'::tsvector) +-- +FUNCTION: name="tsvector_to_array" function="tsvector_to_array" schema="" ctx=Call +STMT: SelectStmt +== 226 +SELECT array_to_tsvector(ARRAY['base','hidden','rebel','spaceship','strike']) +-- +FUNCTION: name="array_to_tsvector" function="array_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 227 +-- null and empty string are disallowed, since we mustn't make an empty lexeme +SELECT array_to_tsvector(ARRAY['base','hidden','rebel','spaceship', NULL]) +-- +FUNCTION: name="array_to_tsvector" function="array_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 228 +SELECT array_to_tsvector(ARRAY['base','hidden','rebel','spaceship', '']) +-- +FUNCTION: name="array_to_tsvector" function="array_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 229 +-- array_to_tsvector must sort and de-dup +SELECT array_to_tsvector(ARRAY['foo','bar','baz','bar']) +-- +FUNCTION: name="array_to_tsvector" function="array_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +== 230 +SELECT setweight('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd zxc:81,567,222A'::tsvector, 'c') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +== 231 +SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +== 232 +SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a}') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +== 233 +SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a}') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +== 234 +SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a,zxc}') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +== 235 +SELECT setweight('a asd w:5,6,12B,13A zxc'::tsvector, 'c', ARRAY['a', 'zxc', '', NULL]) +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +== 236 +SELECT ts_filter('base:7A empir:17 evil:15 first:11 galact:16 hidden:6A rebel:1A spaceship:2A strike:3A victori:12 won:9'::tsvector, '{a}') +-- +FUNCTION: name="ts_filter" function="ts_filter" schema="" ctx=Call +STMT: SelectStmt +== 237 +SELECT ts_filter('base hidden rebel spaceship strike'::tsvector, '{a}') +-- +FUNCTION: name="ts_filter" function="ts_filter" schema="" ctx=Call +STMT: SelectStmt +== 238 +SELECT ts_filter('base hidden rebel spaceship strike'::tsvector, '{a,b,NULL}') +-- +FUNCTION: name="ts_filter" function="ts_filter" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/tuplesort.metadata.json b/parser/testdata/summary/postgres_regress/tuplesort.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tuplesort.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/tuplesort.test b/parser/testdata/summary/postgres_regress/tuplesort.test new file mode 100644 index 0000000..ab5ddd6 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/tuplesort.test @@ -0,0 +1,659 @@ +== 001 +-- only use parallelism when explicitly intending to do so +SET max_parallel_maintenance_workers = 0 +-- +STMT: VariableSetStmt +== 002 +SET max_parallel_workers = 0 +-- +STMT: VariableSetStmt +== 003 +-- A table with contents that, when sorted, triggers abbreviated +-- key aborts. One easy way to achieve that is to use uuids that all +-- have the same prefix, as abbreviated keys for uuids just use the +-- first sizeof(Datum) bytes. +CREATE TEMP TABLE abbrev_abort_uuids ( + id serial not null, + abort_increasing uuid, + abort_decreasing uuid, + noabort_increasing uuid, + noabort_decreasing uuid) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: CreateStmt +== 004 +INSERT INTO abbrev_abort_uuids (abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing) + SELECT + ('00000000-0000-0000-0000-'||to_char(g.i, '000000000000FM'))::uuid abort_increasing, + ('00000000-0000-0000-0000-'||to_char(20000 - g.i, '000000000000FM'))::uuid abort_decreasing, + (to_char(g.i % 10009, '00000000FM')||'-0000-0000-0000-'||to_char(g.i, '000000000000FM'))::uuid noabort_increasing, + (to_char(((20000 - g.i) % 10009), '00000000FM')||'-0000-0000-0000-'||to_char(20000 - g.i, '000000000000FM'))::uuid noabort_decreasing + FROM generate_series(0, 20000, 1) g(i) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 005 +-- and a few NULLs +INSERT INTO abbrev_abort_uuids(id) VALUES(0) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO abbrev_abort_uuids DEFAULT VALUES +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +STMT: InsertStmt +== 007 +INSERT INTO abbrev_abort_uuids DEFAULT VALUES +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +STMT: InsertStmt +== 008 +-- add just a few duplicates +INSERT INTO abbrev_abort_uuids (abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing) + SELECT abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing + FROM abbrev_abort_uuids + WHERE (id < 10 OR id > 19990) AND id % 3 = 0 AND abort_increasing is not null +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="abort_increasing" +STMT: InsertStmt +STMT: SelectStmt +== 009 +---- +-- Check sort node uses of tuplesort wrt. abbreviated keys +---- + +-- plain sort triggering abbreviated abort +SELECT abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_increasing OFFSET 20000 - 4 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 010 +SELECT abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_decreasing NULLS FIRST OFFSET 20000 - 4 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 011 +-- plain sort not triggering abbreviated abort +SELECT noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_increasing OFFSET 20000 - 4 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 012 +SELECT noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing NULLS FIRST OFFSET 20000 - 4 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 013 +-- bounded sort (disables abbreviated keys) +SELECT abort_increasing, noabort_increasing FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 014 +SELECT abort_increasing, noabort_increasing FROM abbrev_abort_uuids ORDER BY noabort_increasing NULLS FIRST LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 015 +---- +-- Check index creation uses of tuplesort wrt. abbreviated keys +---- + +-- index creation using abbreviated keys successfully +CREATE INDEX abbrev_abort_uuids__noabort_increasing_idx ON abbrev_abort_uuids (noabort_increasing) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: IndexStmt +== 016 +CREATE INDEX abbrev_abort_uuids__noabort_decreasing_idx ON abbrev_abort_uuids (noabort_decreasing) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: IndexStmt +== 017 +-- verify +EXPLAIN (COSTS OFF) +SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 018 +SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 019 +EXPLAIN (COSTS OFF) +SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 020 +SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 021 +-- index creation using abbreviated keys, hitting abort +CREATE INDEX abbrev_abort_uuids__abort_increasing_idx ON abbrev_abort_uuids (abort_increasing) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: IndexStmt +== 022 +CREATE INDEX abbrev_abort_uuids__abort_decreasing_idx ON abbrev_abort_uuids (abort_decreasing) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: IndexStmt +== 023 +-- verify +EXPLAIN (COSTS OFF) +SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 024 +SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 025 +EXPLAIN (COSTS OFF) +SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_decreasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 026 +SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_decreasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 027 +---- +-- Check CLUSTER uses of tuplesort wrt. abbreviated keys +---- + +-- when aborting, increasing order +BEGIN +-- +STMT: TransactionStmt +== 028 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +== 029 +CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__abort_increasing_idx +-- +STMT: ClusterStmt +== 030 +-- head +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 031 +-- tail +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid DESC LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 032 +ROLLBACK +-- +STMT: TransactionStmt +== 033 +-- when aborting, decreasing order +BEGIN +-- +STMT: TransactionStmt +== 034 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +== 035 +CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__abort_decreasing_idx +-- +STMT: ClusterStmt +== 036 +-- head +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 037 +-- tail +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid DESC LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 038 +ROLLBACK +-- +STMT: TransactionStmt +== 039 +-- when not aborting, increasing order +BEGIN +-- +STMT: TransactionStmt +== 040 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +== 041 +CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__noabort_increasing_idx +-- +STMT: ClusterStmt +== 042 +-- head +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 043 +-- tail +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid DESC LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 044 +ROLLBACK +-- +STMT: TransactionStmt +== 045 +-- when no aborting, decreasing order +BEGIN +-- +STMT: TransactionStmt +== 046 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +== 047 +CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__noabort_decreasing_idx +-- +STMT: ClusterStmt +== 048 +-- head +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 049 +-- tail +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid DESC LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +== 050 +ROLLBACK +-- +STMT: TransactionStmt +== 051 +---- +-- test sorting of large datums VALUES +---- + +-- Ensure the order is correct and values look intact +SELECT LEFT(a,10),b FROM + (VALUES(REPEAT('a', 512 * 1024),1),(REPEAT('b', 512 * 1024),2)) v(a,b) +ORDER BY v.a DESC +-- +FUNCTION: name="left" function="left" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +== 052 +---- +-- test forward and backward scans for in-memory and disk based tuplesort +---- + +-- in-memory +BEGIN +-- +STMT: TransactionStmt +== 053 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +== 054 +-- unfortunately can't show analyze output confirming sort method, +-- the memory used output wouldn't be stable +EXPLAIN (COSTS OFF) DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +== 055 +DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing +-- +STMT: DeclareCursorStmt +== 056 +-- first and second +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 057 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 058 +-- scroll beyond beginning +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 059 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 060 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 061 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 062 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 063 +-- scroll beyond end +FETCH LAST FROM c +-- +STMT: FetchStmt +== 064 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 065 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 066 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 067 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 068 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 069 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 070 +COMMIT +-- +STMT: TransactionStmt +== 071 +-- disk based +BEGIN +-- +STMT: TransactionStmt +== 072 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +== 073 +SET LOCAL work_mem = '100kB' +-- +STMT: VariableSetStmt +== 074 +-- unfortunately can't show analyze output confirming sort method, +-- the memory used output wouldn't be stable +EXPLAIN (COSTS OFF) DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +== 075 +DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing +-- +STMT: DeclareCursorStmt +== 076 +-- first and second +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 077 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 078 +-- scroll beyond beginning +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 079 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 080 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 081 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 082 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 083 +-- scroll beyond end +FETCH LAST FROM c +-- +STMT: FetchStmt +== 084 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 085 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 086 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 087 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 088 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +== 089 +FETCH NEXT FROM c +-- +STMT: FetchStmt +== 090 +COMMIT +-- +STMT: TransactionStmt +== 091 +---- +-- test tuplesort using both in-memory and disk sort +--- + +-- memory based +SELECT + -- fixed-width by-value datum + (array_agg(id ORDER BY id DESC NULLS FIRST))[0:5], + -- fixed-width by-ref datum + (array_agg(abort_increasing ORDER BY abort_increasing DESC NULLS LAST))[0:5], + -- variable-width datum + (array_agg(id::text ORDER BY id::text DESC NULLS LAST))[0:5], + -- fixed width by-value datum tuplesort + percentile_disc(0.99) WITHIN GROUP (ORDER BY id), + -- ensure state is shared + percentile_disc(0.01) WITHIN GROUP (ORDER BY id), + -- fixed width by-ref datum tuplesort + percentile_disc(0.8) WITHIN GROUP (ORDER BY abort_increasing), + -- variable width by-ref datum tuplesort + percentile_disc(0.2) WITHIN GROUP (ORDER BY id::text), + -- multi-column tuplesort + rank('00000000-0000-0000-0000-000000000000', '2', '2') WITHIN GROUP (ORDER BY noabort_increasing, id, id::text) +FROM ( + SELECT * FROM abbrev_abort_uuids + UNION ALL + SELECT NULL, NULL, NULL, NULL, NULL) s +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 092 +-- disk based (see also above) +BEGIN +-- +STMT: TransactionStmt +== 093 +SET LOCAL work_mem = '100kB' +-- +STMT: VariableSetStmt +== 094 +SELECT + (array_agg(id ORDER BY id DESC NULLS FIRST))[0:5], + (array_agg(abort_increasing ORDER BY abort_increasing DESC NULLS LAST))[0:5], + (array_agg(id::text ORDER BY id::text DESC NULLS LAST))[0:5], + percentile_disc(0.99) WITHIN GROUP (ORDER BY id), + percentile_disc(0.01) WITHIN GROUP (ORDER BY id), + percentile_disc(0.8) WITHIN GROUP (ORDER BY abort_increasing), + percentile_disc(0.2) WITHIN GROUP (ORDER BY id::text), + rank('00000000-0000-0000-0000-000000000000', '2', '2') WITHIN GROUP (ORDER BY noabort_increasing, id, id::text) +FROM ( + SELECT * FROM abbrev_abort_uuids + UNION ALL + SELECT NULL, NULL, NULL, NULL, NULL) s +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 095 +ROLLBACK +-- +STMT: TransactionStmt +== 096 +---- +-- test tuplesort mark/restore +--- + +CREATE TEMP TABLE test_mark_restore(col1 int, col2 int, col12 int) +-- +TABLE: name="test_mark_restore" schema="" table="test_mark_restore" ctx=DDL +STMT: CreateStmt +== 097 +-- need a few duplicates for mark/restore to matter +INSERT INTO test_mark_restore(col1, col2, col12) + SELECT a.i, b.i, a.i * b.i FROM generate_series(1, 500) a(i), generate_series(1, 5) b(i) +-- +TABLE: name="test_mark_restore" schema="" table="test_mark_restore" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 098 +BEGIN +-- +STMT: TransactionStmt +== 099 +SET LOCAL enable_nestloop = off +-- +STMT: VariableSetStmt +== 100 +SET LOCAL enable_hashjoin = off +-- +STMT: VariableSetStmt +== 101 +SET LOCAL enable_material = off +-- +STMT: VariableSetStmt +== 102 +-- set query into variable once, to avoid repetition of the fairly long query +SELECT $$ + SELECT col12, count(distinct a.col1), count(distinct a.col2), count(distinct b.col1), count(distinct b.col2), count(*) + FROM test_mark_restore a + JOIN test_mark_restore b USING(col12) + GROUP BY 1 + HAVING count(*) > 1 + ORDER BY 2 DESC, 1 DESC, 3 DESC, 4 DESC, 5 DESC, 6 DESC + LIMIT 10 +$$ AS qry +-- +STMT: SelectStmt +== 103 +-- test mark/restore with in-memory sorts +EXPLAIN (COSTS OFF) :qry +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 104 +-- test mark/restore with on-disk sorts +SET LOCAL work_mem = '100kB' +-- +STMT: VariableSetStmt +== 105 +EXPLAIN (COSTS OFF) :qry +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 106 +COMMIT +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/txid.metadata.json b/parser/testdata/summary/postgres_regress/txid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/txid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/txid.test b/parser/testdata/summary/postgres_regress/txid.test new file mode 100644 index 0000000..b6a5cd0 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/txid.test @@ -0,0 +1,284 @@ +== 001 +-- txid_snapshot data type and related functions +-- Note: these are backward-compatibility functions and types, and have been +-- replaced by new xid8-based variants. See xid.sql. The txid variants will +-- be removed in a future release. + +-- i/o +select '12:13:'::txid_snapshot +-- +STMT: SelectStmt +== 002 +select '12:18:14,16'::txid_snapshot +-- +STMT: SelectStmt +== 003 +select '12:16:14,14'::txid_snapshot +-- +STMT: SelectStmt +== 004 +-- errors +select '31:12:'::txid_snapshot +-- +STMT: SelectStmt +== 005 +select '0:1:'::txid_snapshot +-- +STMT: SelectStmt +== 006 +select '12:13:0'::txid_snapshot +-- +STMT: SelectStmt +== 007 +select '12:16:14,13'::txid_snapshot +-- +STMT: SelectStmt +== 008 +create temp table snapshot_test ( + nr integer, + snap txid_snapshot +) +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DDL +STMT: CreateStmt +== 009 +insert into snapshot_test values (1, '12:13:') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +insert into snapshot_test values (2, '12:20:13,15,18') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 011 +insert into snapshot_test values (3, '100001:100009:100005,100007,100008') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +insert into snapshot_test values (4, '100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +select snap from snapshot_test order by nr +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +STMT: SelectStmt +== 014 +select txid_snapshot_xmin(snap), + txid_snapshot_xmax(snap), + txid_snapshot_xip(snap) +from snapshot_test order by nr +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="txid_snapshot_xmin" function="txid_snapshot_xmin" schema="" ctx=Call +FUNCTION: name="txid_snapshot_xmax" function="txid_snapshot_xmax" schema="" ctx=Call +FUNCTION: name="txid_snapshot_xip" function="txid_snapshot_xip" schema="" ctx=Call +STMT: SelectStmt +== 015 +select id, txid_visible_in_snapshot(id, snap) +from snapshot_test, generate_series(11, 21) id +where nr = 2 +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 016 +-- test bsearch +select id, txid_visible_in_snapshot(id, snap) +from snapshot_test, generate_series(90, 160) id +where nr = 4 +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 017 +-- test current values also +select txid_current() >= txid_snapshot_xmin(txid_current_snapshot()) +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +FUNCTION: name="txid_snapshot_xmin" function="txid_snapshot_xmin" schema="" ctx=Call +FUNCTION: name="txid_current_snapshot" function="txid_current_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 018 +-- we can't assume current is always less than xmax, however + +select txid_visible_in_snapshot(txid_current(), txid_current_snapshot()) +-- +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +FUNCTION: name="txid_current_snapshot" function="txid_current_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 019 +-- test 64bitness + +select txid_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013' +-- +STMT: SelectStmt +== 020 +select txid_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013') +-- +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 021 +select txid_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013') +-- +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 022 +-- test 64bit overflow +SELECT txid_snapshot '1:9223372036854775807:3' +-- +STMT: SelectStmt +== 023 +SELECT txid_snapshot '1:9223372036854775808:3' +-- +STMT: SelectStmt +== 024 +-- test txid_current_if_assigned +BEGIN +-- +STMT: TransactionStmt +== 025 +SELECT txid_current_if_assigned() IS NULL +-- +FUNCTION: name="txid_current_if_assigned" function="txid_current_if_assigned" schema="" ctx=Call +STMT: SelectStmt +== 026 +SELECT txid_current() +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT txid_current_if_assigned() IS NOT DISTINCT FROM BIGINT :'txid_current' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 028 +COMMIT +-- +STMT: TransactionStmt +== 029 +-- test xid status functions +BEGIN +-- +STMT: TransactionStmt +== 030 +SELECT txid_current() AS committed +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +STMT: SelectStmt +== 031 +COMMIT +-- +STMT: TransactionStmt +== 032 +BEGIN +-- +STMT: TransactionStmt +== 033 +SELECT txid_current() AS rolledback +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +STMT: SelectStmt +== 034 +ROLLBACK +-- +STMT: TransactionStmt +== 035 +BEGIN +-- +STMT: TransactionStmt +== 036 +SELECT txid_current() AS inprogress +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +STMT: SelectStmt +== 037 +SELECT txid_status(:committed) AS committed +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 038 +SELECT txid_status(:rolledback) AS rolledback +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 039 +SELECT txid_status(:inprogress) AS inprogress +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 040 +SELECT txid_status(1) +-- +FUNCTION: name="txid_status" function="txid_status" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- BootstrapTransactionId is always committed +SELECT txid_status(2) +-- +FUNCTION: name="txid_status" function="txid_status" schema="" ctx=Call +STMT: SelectStmt +== 042 +-- FrozenTransactionId is always committed +SELECT txid_status(3) +-- +FUNCTION: name="txid_status" function="txid_status" schema="" ctx=Call +STMT: SelectStmt +== 043 +-- in regress testing FirstNormalTransactionId will always be behind oldestXmin + +COMMIT +-- +STMT: TransactionStmt +== 044 +BEGIN +-- +STMT: TransactionStmt +== 045 +CREATE FUNCTION test_future_xid_status(bigint) +RETURNS void +LANGUAGE plpgsql +AS +$$ +BEGIN + PERFORM txid_status($1); + RAISE EXCEPTION 'didn''t ERROR at xid in the future as expected'; +EXCEPTION + WHEN invalid_parameter_value THEN + RAISE NOTICE 'Got expected error for xid in the future'; +END; +$$ +-- +FUNCTION: name="test_future_xid_status" function="test_future_xid_status" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 046 +SELECT test_future_xid_status(:inprogress + 10000) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 31 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 047 +ROLLBACK +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/type_sanity.metadata.json b/parser/testdata/summary/postgres_regress/type_sanity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/type_sanity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/type_sanity.test b/parser/testdata/summary/postgres_regress/type_sanity.test new file mode 100644 index 0000000..ddb7771 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/type_sanity.test @@ -0,0 +1,1180 @@ +== 001 +|-- +-- TYPE_SANITY +-- Sanity checks for common errors in making type-related system tables: +-- pg_type, pg_class, pg_attribute, pg_range. +|-- +-- None of the SELECTs here should ever find any matching entries, +-- so the expected output is easy to maintain ;-). +-- A test failure indicates someone messed up an entry in the system tables. +|-- +-- NB: we assume the oidjoins test will have caught any dangling links, +-- that is OID or REGPROC fields that are not zero and do not match some +-- row in the linked-to table. However, if we want to enforce that a link +-- field can't be 0, we have to check it here. + +-- **************** pg_type **************** + +-- Look for illegal values in pg_type fields. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typnamespace = 0 OR + (t1.typlen <= 0 AND t1.typlen != -1 AND t1.typlen != -2) OR + (t1.typtype not in ('b', 'c', 'd', 'e', 'm', 'p', 'r')) OR + NOT t1.typisdefined OR + (t1.typalign not in ('c', 's', 'i', 'd')) OR + (t1.typstorage not in ('p', 'x', 'e', 'm')) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typnamespace" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typisdefined" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t1" column="typstorage" +STMT: SelectStmt +== 002 +-- Look for "pass by value" types that can't be passed by value. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typbyval AND + (t1.typlen != 1 OR t1.typalign != 'c') AND + (t1.typlen != 2 OR t1.typalign != 's') AND + (t1.typlen != 4 OR t1.typalign != 'i') AND + (t1.typlen != 8 OR t1.typalign != 'd') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typbyval" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typalign" +STMT: SelectStmt +== 003 +-- Look for "toastable" types that aren't varlena. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typstorage != 'p' AND + (t1.typbyval OR t1.typlen != -1) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typstorage" +FILTER: schema="" table="t1" column="typbyval" +FILTER: schema="" table="t1" column="typlen" +STMT: SelectStmt +== 004 +-- Look for complex types that do not have a typrelid entry, +-- or basic types that do. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE (t1.typtype = 'c' AND t1.typrelid = 0) OR + (t1.typtype != 'c' AND t1.typrelid != 0) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typrelid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typrelid" +STMT: SelectStmt +== 005 +-- Look for types that should have an array type but don't. +-- Generally anything that's not a pseudotype should have an array type. +-- However, we do have a small number of exceptions. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typtype not in ('p') AND t1.typname NOT LIKE E'\\_%' + AND NOT EXISTS + (SELECT 1 FROM pg_type as t2 + WHERE t2.typname = ('_' || t1.typname)::name AND + t2.typelem = t1.oid and t1.typarray = t2.oid) +ORDER BY t1.oid +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typname" +FILTER: schema="" table="t2" column="typname" +FILTER: schema="" table="t1" column="typname" +FILTER: schema="" table="t2" column="typelem" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="t1" column="typarray" +FILTER: schema="" table="t2" column="oid" +STMT: SelectStmt +== 006 +-- Make sure typarray points to a "true" array type of our own base +SELECT t1.oid, t1.typname as basetype, t2.typname as arraytype, + t2.typsubscript +FROM pg_type t1 LEFT JOIN pg_type t2 ON (t1.typarray = t2.oid) +WHERE t1.typarray <> 0 AND + (t2.oid IS NULL OR + t2.typsubscript <> 'array_subscript_handler'::regproc) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typarray" +FILTER: schema="" table="t2" column="oid" +FILTER: schema="" table="t2" column="typsubscript" +STMT: SelectStmt +== 007 +-- Look for range types that do not have a pg_range entry +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typtype = 'r' AND + NOT EXISTS(SELECT 1 FROM pg_range r WHERE rngtypid = t1.oid) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +ALIAS: "r"="pg_range" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="" column="rngtypid" +FILTER: schema="" table="t1" column="oid" +STMT: SelectStmt +== 008 +-- Look for range types whose typalign isn't sufficient +SELECT t1.oid, t1.typname, t1.typalign, t2.typname, t2.typalign +FROM pg_type as t1 + LEFT JOIN pg_range as r ON rngtypid = t1.oid + LEFT JOIN pg_type as t2 ON rngsubtype = t2.oid +WHERE t1.typtype = 'r' AND + (t1.typalign != (CASE WHEN t2.typalign = 'd' THEN 'd'::"char" + ELSE 'i'::"char" END) + OR t2.oid IS NULL) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "r"="pg_range" +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t2" column="typalign" +FILTER: schema="" table="t2" column="oid" +STMT: SelectStmt +== 009 +-- Text conversion routines must be provided. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE (t1.typinput = 0 OR t1.typoutput = 0) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="t1" column="typoutput" +STMT: SelectStmt +== 010 +-- Check for bogus typinput routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typinput = p1.oid AND NOT + ((p1.pronargs = 1 AND p1.proargtypes[0] = 'cstring'::regtype) OR + (p1.pronargs = 2 AND p1.proargtypes[0] = 'cstring'::regtype AND + p1.proargtypes[1] = 'oid'::regtype) OR + (p1.pronargs = 3 AND p1.proargtypes[0] = 'cstring'::regtype AND + p1.proargtypes[1] = 'oid'::regtype AND + p1.proargtypes[2] = 'int4'::regtype)) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 011 +-- As of 8.0, this check finds refcursor, which is borrowing +-- other types' I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typinput = p1.oid AND t1.typtype in ('b', 'p') AND NOT + (t1.typelem != 0 AND t1.typlen < 0) AND NOT + (p1.prorettype = t1.oid AND NOT p1.proretset) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +== 012 +-- Varlena array types will point to array_in +-- Exception as of 8.1: int2vector and oidvector have their own I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typinput = p1.oid AND + (t1.typelem != 0 AND t1.typlen < 0) AND NOT + (p1.oid = 'array_in'::regproc) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +== 013 +-- typinput routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typinput = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 014 +-- Composites, domains, enums, multiranges, ranges should all use the same input routines +SELECT DISTINCT typtype, typinput +FROM pg_type AS t1 +WHERE t1.typtype not in ('b', 'p') +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +STMT: SelectStmt +== 015 +-- Check for bogus typoutput routines + +-- As of 8.0, this check finds refcursor, which is borrowing +-- other types' I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typoutput = p1.oid AND t1.typtype in ('b', 'p') AND NOT + (p1.pronargs = 1 AND + (p1.proargtypes[0] = t1.oid OR + (p1.oid = 'array_out'::regproc AND + t1.typelem != 0 AND t1.typlen = -1))) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typoutput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +STMT: SelectStmt +== 016 +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typoutput = p1.oid AND NOT + (p1.prorettype = 'cstring'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typoutput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +== 017 +-- typoutput routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typoutput = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typoutput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 018 +-- Composites, enums, multiranges, ranges should all use the same output routines +SELECT DISTINCT typtype, typoutput +FROM pg_type AS t1 +WHERE t1.typtype not in ('b', 'd', 'p') +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +STMT: SelectStmt +== 019 +-- Domains should have same typoutput as their base types +SELECT t1.oid, t1.typname, t2.oid, t2.typname +FROM pg_type AS t1 LEFT JOIN pg_type AS t2 ON t1.typbasetype = t2.oid +WHERE t1.typtype = 'd' AND t1.typoutput IS DISTINCT FROM t2.typoutput +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typoutput" +FILTER: schema="" table="t2" column="typoutput" +STMT: SelectStmt +== 020 +-- Check for bogus typreceive routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typreceive = p1.oid AND NOT + ((p1.pronargs = 1 AND p1.proargtypes[0] = 'internal'::regtype) OR + (p1.pronargs = 2 AND p1.proargtypes[0] = 'internal'::regtype AND + p1.proargtypes[1] = 'oid'::regtype) OR + (p1.pronargs = 3 AND p1.proargtypes[0] = 'internal'::regtype AND + p1.proargtypes[1] = 'oid'::regtype AND + p1.proargtypes[2] = 'int4'::regtype)) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +== 021 +-- As of 7.4, this check finds refcursor, which is borrowing +-- other types' I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typreceive = p1.oid AND t1.typtype in ('b', 'p') AND NOT + (t1.typelem != 0 AND t1.typlen < 0) AND NOT + (p1.prorettype = t1.oid AND NOT p1.proretset) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +== 022 +-- Varlena array types will point to array_recv +-- Exception as of 8.1: int2vector and oidvector have their own I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typreceive = p1.oid AND + (t1.typelem != 0 AND t1.typlen < 0) AND NOT + (p1.oid = 'array_recv'::regproc) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +== 023 +-- Suspicious if typreceive doesn't take same number of args as typinput +SELECT t1.oid, t1.typname, p1.oid, p1.proname, p2.oid, p2.proname +FROM pg_type AS t1, pg_proc AS p1, pg_proc AS p2 +WHERE t1.typinput = p1.oid AND t1.typreceive = p2.oid AND + p1.pronargs != p2.pronargs +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p2" column="pronargs" +STMT: SelectStmt +== 024 +-- typreceive routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typreceive = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 025 +-- Composites, domains, enums, multiranges, ranges should all use the same receive routines +SELECT DISTINCT typtype, typreceive +FROM pg_type AS t1 +WHERE t1.typtype not in ('b', 'p') +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +STMT: SelectStmt +== 026 +-- Check for bogus typsend routines + +-- As of 7.4, this check finds refcursor, which is borrowing +-- other types' I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typsend = p1.oid AND t1.typtype in ('b', 'p') AND NOT + (p1.pronargs = 1 AND + (p1.proargtypes[0] = t1.oid OR + (p1.oid = 'array_send'::regproc AND + t1.typelem != 0 AND t1.typlen = -1))) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsend" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +STMT: SelectStmt +== 027 +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typsend = p1.oid AND NOT + (p1.prorettype = 'bytea'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsend" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +== 028 +-- typsend routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typsend = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsend" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 029 +-- Composites, enums, multiranges, ranges should all use the same send routines +SELECT DISTINCT typtype, typsend +FROM pg_type AS t1 +WHERE t1.typtype not in ('b', 'd', 'p') +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +STMT: SelectStmt +== 030 +-- Domains should have same typsend as their base types +SELECT t1.oid, t1.typname, t2.oid, t2.typname +FROM pg_type AS t1 LEFT JOIN pg_type AS t2 ON t1.typbasetype = t2.oid +WHERE t1.typtype = 'd' AND t1.typsend IS DISTINCT FROM t2.typsend +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typsend" +FILTER: schema="" table="t2" column="typsend" +STMT: SelectStmt +== 031 +-- Check for bogus typmodin routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typmodin = p1.oid AND NOT + (p1.pronargs = 1 AND + p1.proargtypes[0] = 'cstring[]'::regtype AND + p1.prorettype = 'int4'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typmodin" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +== 032 +-- typmodin routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typmodin = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typmodin" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 033 +-- Check for bogus typmodout routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typmodout = p1.oid AND NOT + (p1.pronargs = 1 AND + p1.proargtypes[0] = 'int4'::regtype AND + p1.prorettype = 'cstring'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typmodout" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +== 034 +-- typmodout routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typmodout = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typmodout" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +== 035 +-- Array types should have same typmodin/out as their element types + +SELECT t1.oid, t1.typname, t2.oid, t2.typname +FROM pg_type AS t1, pg_type AS t2 +WHERE t1.typelem = t2.oid AND NOT + (t1.typmodin = t2.typmodin AND t1.typmodout = t2.typmodout) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t2" column="oid" +FILTER: schema="" table="t1" column="typmodin" +FILTER: schema="" table="t2" column="typmodin" +FILTER: schema="" table="t1" column="typmodout" +FILTER: schema="" table="t2" column="typmodout" +STMT: SelectStmt +== 036 +-- Array types should have same typdelim as their element types + +SELECT t1.oid, t1.typname, t2.oid, t2.typname +FROM pg_type AS t1, pg_type AS t2 +WHERE t1.typarray = t2.oid AND NOT (t1.typdelim = t2.typdelim) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typarray" +FILTER: schema="" table="t2" column="oid" +FILTER: schema="" table="t1" column="typdelim" +FILTER: schema="" table="t2" column="typdelim" +STMT: SelectStmt +== 037 +-- Look for array types whose typalign isn't sufficient + +SELECT t1.oid, t1.typname, t1.typalign, t2.typname, t2.typalign +FROM pg_type AS t1, pg_type AS t2 +WHERE t1.typarray = t2.oid AND + t2.typalign != (CASE WHEN t1.typalign = 'd' THEN 'd'::"char" + ELSE 'i'::"char" END) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typarray" +FILTER: schema="" table="t2" column="oid" +FILTER: schema="" table="t2" column="typalign" +FILTER: schema="" table="t1" column="typalign" +STMT: SelectStmt +== 038 +-- Check for typelem set without a handler + +SELECT t1.oid, t1.typname, t1.typelem +FROM pg_type AS t1 +WHERE t1.typelem != 0 AND t1.typsubscript = 0 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typsubscript" +STMT: SelectStmt +== 039 +-- Check for misuse of standard subscript handlers + +SELECT t1.oid, t1.typname, + t1.typelem, t1.typlen, t1.typbyval +FROM pg_type AS t1 +WHERE t1.typsubscript = 'array_subscript_handler'::regproc AND NOT + (t1.typelem != 0 AND t1.typlen = -1 AND NOT t1.typbyval) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsubscript" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typbyval" +STMT: SelectStmt +== 040 +SELECT t1.oid, t1.typname, + t1.typelem, t1.typlen, t1.typbyval +FROM pg_type AS t1 +WHERE t1.typsubscript = 'raw_array_subscript_handler'::regproc AND NOT + (t1.typelem != 0 AND t1.typlen > 0 AND NOT t1.typbyval) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsubscript" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typbyval" +STMT: SelectStmt +== 041 +-- Check for bogus typanalyze routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typanalyze = p1.oid AND NOT + (p1.pronargs = 1 AND + p1.proargtypes[0] = 'internal'::regtype AND + p1.prorettype = 'bool'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typanalyze" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +== 042 +-- there does not seem to be a reason to care about volatility of typanalyze + +-- domains inherit their base type's typanalyze + +SELECT d.oid, d.typname, d.typanalyze, t.oid, t.typname, t.typanalyze +FROM pg_type d JOIN pg_type t ON d.typbasetype = t.oid +WHERE d.typanalyze != t.typanalyze +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "d"="pg_type" +ALIAS: "t"="pg_type" +FILTER: schema="" table="d" column="typanalyze" +FILTER: schema="" table="t" column="typanalyze" +STMT: SelectStmt +== 043 +-- range_typanalyze should be used for all and only range types +-- (but exclude domains, which we checked above) + +SELECT t.oid, t.typname, t.typanalyze +FROM pg_type t LEFT JOIN pg_range r on t.oid = r.rngtypid +WHERE t.typbasetype = 0 AND + (t.typanalyze = 'range_typanalyze'::regproc) != (r.rngtypid IS NOT NULL) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +ALIAS: "r"="pg_range" +ALIAS: "t"="pg_type" +FILTER: schema="" table="t" column="typbasetype" +FILTER: schema="" table="t" column="typanalyze" +FILTER: schema="" table="r" column="rngtypid" +STMT: SelectStmt +== 044 +-- array_typanalyze should be used for all and only array types +-- (but exclude domains, which we checked above) +-- As of 9.2 this finds int2vector and oidvector, which are weird anyway + +SELECT t.oid, t.typname, t.typanalyze +FROM pg_type t +WHERE t.typbasetype = 0 AND + (t.typanalyze = 'array_typanalyze'::regproc) != + (t.typsubscript = 'array_subscript_handler'::regproc) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t"="pg_type" +FILTER: schema="" table="t" column="typbasetype" +FILTER: schema="" table="t" column="typanalyze" +FILTER: schema="" table="t" column="typsubscript" +STMT: SelectStmt +== 045 +-- **************** pg_class **************** + +-- Look for illegal values in pg_class fields + +SELECT c1.oid, c1.relname +FROM pg_class as c1 +WHERE relkind NOT IN ('r', 'i', 'S', 't', 'v', 'm', 'c', 'f', 'p', 'I') OR + relpersistence NOT IN ('p', 'u', 't') OR + relreplident NOT IN ('d', 'n', 'f', 'i') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c1"="pg_class" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relpersistence" +FILTER: schema="" table="" column="relreplident" +STMT: SelectStmt +== 046 +-- All tables, indexes, partitioned indexes and matviews should have an +-- access method. +SELECT c1.oid, c1.relname +FROM pg_class as c1 +WHERE c1.relkind NOT IN ('S', 'v', 'f', 'c', 'p') and + c1.relam = 0 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c1"="pg_class" +FILTER: schema="" table="c1" column="relkind" +FILTER: schema="" table="c1" column="relam" +STMT: SelectStmt +== 047 +-- Conversely, sequences, views, foreign tables, types and partitioned +-- tables shouldn't have them. +SELECT c1.oid, c1.relname +FROM pg_class as c1 +WHERE c1.relkind IN ('S', 'v', 'f', 'c', 'p') and + c1.relam != 0 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c1"="pg_class" +FILTER: schema="" table="c1" column="relkind" +FILTER: schema="" table="c1" column="relam" +STMT: SelectStmt +== 048 +-- Indexes and partitioned indexes should have AMs of type 'i'. +SELECT pc.oid, pc.relname, pa.amname, pa.amtype +FROM pg_class as pc JOIN pg_am AS pa ON (pc.relam = pa.oid) +WHERE pc.relkind IN ('i', 'I') and + pa.amtype != 'i' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "pa"="pg_am" +ALIAS: "pc"="pg_class" +FILTER: schema="" table="pc" column="relkind" +FILTER: schema="" table="pa" column="amtype" +STMT: SelectStmt +== 049 +-- Tables, matviews etc should have AMs of type 't' +SELECT pc.oid, pc.relname, pa.amname, pa.amtype +FROM pg_class as pc JOIN pg_am AS pa ON (pc.relam = pa.oid) +WHERE pc.relkind IN ('r', 't', 'm') and + pa.amtype != 't' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "pa"="pg_am" +ALIAS: "pc"="pg_class" +FILTER: schema="" table="pc" column="relkind" +FILTER: schema="" table="pa" column="amtype" +STMT: SelectStmt +== 050 +-- **************** pg_attribute **************** + +-- Look for illegal values in pg_attribute fields + +SELECT a1.attrelid, a1.attname +FROM pg_attribute as a1 +WHERE a1.attrelid = 0 OR a1.atttypid = 0 OR a1.attnum = 0 OR + a1.attcacheoff != -1 OR a1.attinhcount < 0 OR + (a1.attinhcount = 0 AND NOT a1.attislocal) +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +ALIAS: "a1"="pg_attribute" +FILTER: schema="" table="a1" column="attrelid" +FILTER: schema="" table="a1" column="atttypid" +FILTER: schema="" table="a1" column="attnum" +FILTER: schema="" table="a1" column="attcacheoff" +FILTER: schema="" table="a1" column="attinhcount" +FILTER: schema="" table="a1" column="attinhcount" +FILTER: schema="" table="a1" column="attislocal" +STMT: SelectStmt +== 051 +-- Cross-check attnum against parent relation + +SELECT a1.attrelid, a1.attname, c1.oid, c1.relname +FROM pg_attribute AS a1, pg_class AS c1 +WHERE a1.attrelid = c1.oid AND a1.attnum > c1.relnatts +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a1"="pg_attribute" +ALIAS: "c1"="pg_class" +FILTER: schema="" table="a1" column="attrelid" +FILTER: schema="" table="c1" column="oid" +FILTER: schema="" table="a1" column="attnum" +FILTER: schema="" table="c1" column="relnatts" +STMT: SelectStmt +== 052 +-- Detect missing pg_attribute entries: should have as many non-system +-- attributes as parent relation expects + +SELECT c1.oid, c1.relname +FROM pg_class AS c1 +WHERE c1.relnatts != (SELECT count(*) FROM pg_attribute AS a1 + WHERE a1.attrelid = c1.oid AND a1.attnum > 0) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +ALIAS: "a1"="pg_attribute" +ALIAS: "c1"="pg_class" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="c1" column="relnatts" +FILTER: schema="" table="a1" column="attrelid" +FILTER: schema="" table="c1" column="oid" +FILTER: schema="" table="a1" column="attnum" +STMT: SelectStmt +== 053 +-- Cross-check against pg_type entry +-- NOTE: we allow attstorage to be 'plain' even when typstorage is not; +-- this is mainly for toast tables. + +SELECT a1.attrelid, a1.attname, t1.oid, t1.typname +FROM pg_attribute AS a1, pg_type AS t1 +WHERE a1.atttypid = t1.oid AND + (a1.attlen != t1.typlen OR + a1.attalign != t1.typalign OR + a1.attbyval != t1.typbyval OR + (a1.attstorage != t1.typstorage AND a1.attstorage != 'p')) +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "a1"="pg_attribute" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="a1" column="atttypid" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="a1" column="attlen" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="a1" column="attalign" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="a1" column="attbyval" +FILTER: schema="" table="t1" column="typbyval" +FILTER: schema="" table="a1" column="attstorage" +FILTER: schema="" table="t1" column="typstorage" +FILTER: schema="" table="a1" column="attstorage" +STMT: SelectStmt +== 054 +-- **************** pg_range **************** + +-- Look for illegal values in pg_range fields. + +SELECT r.rngtypid, r.rngsubtype +FROM pg_range as r +WHERE r.rngtypid = 0 OR r.rngsubtype = 0 OR r.rngsubopc = 0 +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +ALIAS: "r"="pg_range" +FILTER: schema="" table="r" column="rngtypid" +FILTER: schema="" table="r" column="rngsubtype" +FILTER: schema="" table="r" column="rngsubopc" +STMT: SelectStmt +== 055 +-- rngcollation should be specified iff subtype is collatable + +SELECT r.rngtypid, r.rngsubtype, r.rngcollation, t.typcollation +FROM pg_range r JOIN pg_type t ON t.oid = r.rngsubtype +WHERE (rngcollation = 0) != (typcollation = 0) +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "r"="pg_range" +ALIAS: "t"="pg_type" +FILTER: schema="" table="" column="rngcollation" +FILTER: schema="" table="" column="typcollation" +STMT: SelectStmt +== 056 +-- opclass had better be a btree opclass accepting the subtype. +-- We must allow anyarray matches, cf IsBinaryCoercible() + +SELECT r.rngtypid, r.rngsubtype, o.opcmethod, o.opcname +FROM pg_range r JOIN pg_opclass o ON o.oid = r.rngsubopc +WHERE o.opcmethod != 403 OR + ((o.opcintype != r.rngsubtype) AND NOT + (o.opcintype = 'pg_catalog.anyarray'::regtype AND + EXISTS(select 1 from pg_catalog.pg_type where + oid = r.rngsubtype and typelem != 0 and + typsubscript = 'array_subscript_handler'::regproc))) +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_catalog.pg_type" schema="pg_catalog" table="pg_type" ctx=Select +ALIAS: "o"="pg_opclass" +ALIAS: "r"="pg_range" +FILTER: schema="" table="o" column="opcmethod" +FILTER: schema="" table="o" column="opcintype" +FILTER: schema="" table="r" column="rngsubtype" +FILTER: schema="" table="o" column="opcintype" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="r" column="rngsubtype" +FILTER: schema="" table="" column="typelem" +FILTER: schema="" table="" column="typsubscript" +STMT: SelectStmt +== 057 +-- canonical function, if any, had better match the range type + +SELECT r.rngtypid, r.rngsubtype, p.proname +FROM pg_range r JOIN pg_proc p ON p.oid = r.rngcanonical +WHERE pronargs != 1 OR proargtypes[0] != rngtypid OR prorettype != rngtypid +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p"="pg_proc" +ALIAS: "r"="pg_range" +FILTER: schema="" table="" column="pronargs" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="rngtypid" +FILTER: schema="" table="" column="prorettype" +FILTER: schema="" table="" column="rngtypid" +STMT: SelectStmt +== 058 +-- subdiff function, if any, had better match the subtype + +SELECT r.rngtypid, r.rngsubtype, p.proname +FROM pg_range r JOIN pg_proc p ON p.oid = r.rngsubdiff +WHERE pronargs != 2 + OR proargtypes[0] != rngsubtype OR proargtypes[1] != rngsubtype + OR prorettype != 'pg_catalog.float8'::regtype +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p"="pg_proc" +ALIAS: "r"="pg_range" +FILTER: schema="" table="" column="pronargs" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="rngsubtype" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="rngsubtype" +FILTER: schema="" table="" column="prorettype" +STMT: SelectStmt +== 059 +-- every range should have a valid multirange + +SELECT r.rngtypid, r.rngsubtype, r.rngmultitypid +FROM pg_range r +WHERE r.rngmultitypid IS NULL OR r.rngmultitypid = 0 +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +ALIAS: "r"="pg_range" +FILTER: schema="" table="r" column="rngmultitypid" +FILTER: schema="" table="r" column="rngmultitypid" +STMT: SelectStmt +== 060 +-- Create a table that holds all the known in-core data types and leave it +-- around so as pg_upgrade is able to test their binary compatibility. +CREATE TABLE tab_core_types AS SELECT + '(11,12)'::point, + '(1,1),(2,2)'::line, + '((11,11),(12,12))'::lseg, + '((11,11),(13,13))'::box, + '((11,12),(13,13),(14,14))'::path AS openedpath, + '[(11,12),(13,13),(14,14)]'::path AS closedpath, + '((11,12),(13,13),(14,14))'::polygon, + '1,1,1'::circle, + 'today'::date, + 'now'::time, + 'now'::timestamp, + 'now'::timetz, + 'now'::timestamptz, + '12 seconds'::interval, + '{"reason":"because"}'::json, + '{"when":"now"}'::jsonb, + '$.a[*] ? (@ > 2)'::jsonpath, + '127.0.0.1'::inet, + '127.0.0.0/8'::cidr, + '00:01:03:86:1c:ba'::macaddr8, + '00:01:03:86:1c:ba'::macaddr, + 2::int2, 4::int4, 8::int8, + 4::float4, '8'::float8, pi()::numeric, + 'foo'::"char", + 'c'::bpchar, + 'abc'::varchar, + 'name'::name, + 'txt'::text, + true::bool, + E'\\xDEADBEEF'::bytea, + B'10001'::bit, + B'10001'::varbit AS varbit, + '12.34'::money, + 'abc'::refcursor, + '1 2'::int2vector, + '1 2'::oidvector, + format('%I=UC/%I', USER, USER)::aclitem AS aclitem, + 'a fat cat sat on a mat and ate a fat rat'::tsvector, + 'fat & rat'::tsquery, + 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid, + '11'::xid8, + 'pg_class'::regclass, + 'regtype'::regtype type, + 'pg_monitor'::regrole, + 'pg_class'::regclass::oid, + '(1,1)'::tid, '2'::xid, '3'::cid, + '10:20:10,14,15'::txid_snapshot, + '10:20:10,14,15'::pg_snapshot, + '16/B374D848'::pg_lsn, + 1::information_schema.cardinal_number, + 'l'::information_schema.character_data, + 'n'::information_schema.sql_identifier, + 'now'::information_schema.time_stamp, + 'YES'::information_schema.yes_or_no, + '(1,2)'::int4range, '{(1,2)}'::int4multirange, + '(3,4)'::int8range, '{(3,4)}'::int8multirange, + '(3,4)'::numrange, '{(3,4)}'::nummultirange, + '(2020-01-02, 2021-02-03)'::daterange, + '{(2020-01-02, 2021-02-03)}'::datemultirange, + '(2020-01-02 03:04:05, 2021-02-03 06:07:08)'::tsrange, + '{(2020-01-02 03:04:05, 2021-02-03 06:07:08)}'::tsmultirange, + '(2020-01-02 03:04:05, 2021-02-03 06:07:08)'::tstzrange, + '{(2020-01-02 03:04:05, 2021-02-03 06:07:08)}'::tstzmultirange +-- +TABLE: name="tab_core_types" schema="" table="tab_core_types" ctx=DDL +FUNCTION: name="pi" function="pi" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 061 +-- Sanity check on the previous table, checking that all core types are +-- included in this table. +SELECT oid, typname, typtype, typelem, typarray + FROM pg_type t + WHERE oid < 16384 AND + -- Exclude pseudotypes and composite types. + typtype NOT IN ('p', 'c') AND + -- These reg* types cannot be pg_upgraded, so discard them. + oid != ALL(ARRAY['regproc', 'regprocedure', 'regoper', + 'regoperator', 'regconfig', 'regdictionary', + 'regnamespace', 'regcollation']::regtype[]) AND + -- Discard types that do not accept input values as these cannot be + -- tested easily. + -- Note: XML might be disabled at compile-time. + oid != ALL(ARRAY['gtsvector', 'pg_node_tree', + 'pg_ndistinct', 'pg_dependencies', 'pg_mcv_list', + 'pg_brin_bloom_summary', + 'pg_brin_minmax_multi_summary', 'xml']::regtype[]) AND + -- Discard arrays. + NOT EXISTS (SELECT 1 FROM pg_type u WHERE u.typarray = t.oid) + -- Exclude everything from the table created above. This checks + -- that no in-core types are missing in tab_core_types. + AND NOT EXISTS (SELECT 1 + FROM pg_attribute a + WHERE a.atttypid=t.oid AND + a.attnum > 0 AND + a.attrelid='tab_core_types'::regclass) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "t"="pg_type" +ALIAS: "u"="pg_type" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="typtype" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="u" column="typarray" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="a" column="atttypid" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="a" column="attnum" +FILTER: schema="" table="a" column="attrelid" +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/typed_table.metadata.json b/parser/testdata/summary/postgres_regress/typed_table.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/typed_table.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/typed_table.test b/parser/testdata/summary/postgres_regress/typed_table.test new file mode 100644 index 0000000..af16fff --- /dev/null +++ b/parser/testdata/summary/postgres_regress/typed_table.test @@ -0,0 +1,163 @@ +== 001 +CREATE TABLE ttable1 OF nothing +-- +TABLE: name="ttable1" schema="" table="ttable1" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TYPE person_type AS (id int, name text) +-- +STMT: CompositeTypeStmt +== 003 +CREATE TABLE persons OF person_type +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: CreateStmt +== 004 +CREATE TABLE IF NOT EXISTS persons OF person_type +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: CreateStmt +== 005 +SELECT * FROM persons +-- +TABLE: name="persons" schema="" table="persons" ctx=Select +STMT: SelectStmt +== 006 +CREATE FUNCTION get_all_persons() RETURNS SETOF person_type +LANGUAGE SQL +AS $$ + SELECT * FROM persons; +$$ +-- +FUNCTION: name="get_all_persons" function="get_all_persons" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 007 +SELECT * FROM get_all_persons() +-- +FUNCTION: name="get_all_persons" function="get_all_persons" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- certain ALTER TABLE operations on typed tables are not allowed +ALTER TABLE persons ADD COLUMN comment text +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: AlterTableStmt +== 009 +ALTER TABLE persons DROP COLUMN name +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: AlterTableStmt +== 010 +ALTER TABLE persons RENAME COLUMN id TO num +-- +STMT: RenameStmt +== 011 +ALTER TABLE persons ALTER COLUMN name TYPE varchar +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: AlterTableStmt +== 012 +CREATE TABLE stuff (id int) +-- +TABLE: name="stuff" schema="" table="stuff" ctx=DDL +STMT: CreateStmt +== 013 +ALTER TABLE persons INHERIT stuff +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: AlterTableStmt +== 014 +CREATE TABLE personsx OF person_type (myname WITH OPTIONS NOT NULL) +-- +TABLE: name="personsx" schema="" table="personsx" ctx=DDL +STMT: CreateStmt +== 015 +-- error + +CREATE TABLE persons2 OF person_type ( + id WITH OPTIONS PRIMARY KEY, + UNIQUE (name) +) +-- +TABLE: name="persons2" schema="" table="persons2" ctx=DDL +STMT: CreateStmt +== 016 +CREATE TABLE persons3 OF person_type ( + PRIMARY KEY (id), + name WITH OPTIONS DEFAULT '' +) +-- +TABLE: name="persons3" schema="" table="persons3" ctx=DDL +STMT: CreateStmt +== 017 +CREATE TABLE persons4 OF person_type ( + name WITH OPTIONS NOT NULL, + name WITH OPTIONS DEFAULT '' -- error, specified more than once +) +-- +TABLE: name="persons4" schema="" table="persons4" ctx=DDL +STMT: CreateStmt +== 018 +DROP TYPE person_type RESTRICT +-- +STMT: DropStmt +== 019 +DROP TYPE person_type CASCADE +-- +STMT: DropStmt +== 020 +CREATE TABLE persons5 OF stuff +-- +TABLE: name="persons5" schema="" table="persons5" ctx=DDL +STMT: CreateStmt +== 021 +-- only CREATE TYPE AS types may be used + +DROP TABLE stuff +-- +TABLE: name="stuff" schema="" table="stuff" ctx=DDL +STMT: DropStmt +== 022 +-- implicit casting + +CREATE TYPE person_type AS (id int, name text) +-- +STMT: CompositeTypeStmt +== 023 +CREATE TABLE persons OF person_type +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: CreateStmt +== 024 +INSERT INTO persons VALUES (1, 'test') +-- +TABLE: name="persons" schema="" table="persons" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$ +-- +FUNCTION: name="namelen" function="namelen" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 026 +SELECT id, namelen(persons) FROM persons +-- +TABLE: name="persons" schema="" table="persons" ctx=Select +FUNCTION: name="namelen" function="namelen" schema="" ctx=Call +STMT: SelectStmt +== 027 +CREATE TABLE persons2 OF person_type ( + id WITH OPTIONS PRIMARY KEY, + UNIQUE (name) +) +-- +TABLE: name="persons2" schema="" table="persons2" ctx=DDL +STMT: CreateStmt +== 028 +CREATE TABLE persons3 OF person_type ( + PRIMARY KEY (id), + name NOT NULL DEFAULT '' +) +-- +TABLE: name="persons3" schema="" table="persons3" ctx=DDL +STMT: CreateStmt diff --git a/parser/testdata/summary/postgres_regress/unicode.metadata.json b/parser/testdata/summary/postgres_regress/unicode.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/unicode.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/unicode.test b/parser/testdata/summary/postgres_regress/unicode.test new file mode 100644 index 0000000..52b53bd --- /dev/null +++ b/parser/testdata/summary/postgres_regress/unicode.test @@ -0,0 +1,100 @@ +== 001 +SELECT getdatabaseencoding() <> 'UTF8' AS skip_test +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +== 002 +SELECT U&'\0061\0308bc' <> U&'\00E4bc' COLLATE "C" AS sanity_check +-- +STMT: SelectStmt +== 003 +SELECT unicode_version() IS NOT NULL +-- +FUNCTION: name="unicode_version" function="unicode_version" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT unicode_assigned(U&'abc') +-- +FUNCTION: name="unicode_assigned" function="unicode_assigned" schema="" ctx=Call +STMT: SelectStmt +== 005 +SELECT unicode_assigned(U&'abc\+10FFFF') +-- +FUNCTION: name="unicode_assigned" function="unicode_assigned" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT normalize('') +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 007 +SELECT normalize(U&'\0061\0308\24D1c') = U&'\00E4\24D1c' COLLATE "C" AS test_default +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 008 +SELECT normalize(U&'\0061\0308\24D1c', NFC) = U&'\00E4\24D1c' COLLATE "C" AS test_nfc +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 009 +SELECT normalize(U&'\00E4bc', NFC) = U&'\00E4bc' COLLATE "C" AS test_nfc_idem +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 010 +SELECT normalize(U&'\00E4\24D1c', NFD) = U&'\0061\0308\24D1c' COLLATE "C" AS test_nfd +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 011 +SELECT normalize(U&'\0061\0308\24D1c', NFKC) = U&'\00E4bc' COLLATE "C" AS test_nfkc +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 012 +SELECT normalize(U&'\00E4\24D1c', NFKD) = U&'\0061\0308bc' COLLATE "C" AS test_nfkd +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 013 +SELECT "normalize"('abc', 'def') +-- +FUNCTION: name="normalize" function="normalize" schema="" ctx=Call +STMT: SelectStmt +== 014 +-- run-time error + +SELECT U&'\00E4\24D1c' IS NORMALIZED AS test_default +-- +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 015 +SELECT U&'\00E4\24D1c' IS NFC NORMALIZED AS test_nfc +-- +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 016 +SELECT num, val, + val IS NFC NORMALIZED AS NFC, + val IS NFD NORMALIZED AS NFD, + val IS NFKC NORMALIZED AS NFKC, + val IS NFKD NORMALIZED AS NFKD +FROM + (VALUES (1, U&'\00E4bc'), + (2, U&'\0061\0308bc'), + (3, U&'\00E4\24D1c'), + (4, U&'\0061\0308\24D1c'), + (5, '')) vals (num, val) +ORDER BY num +-- +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 017 +SELECT is_normalized('abc', 'def') +-- +FUNCTION: name="is_normalized" function="is_normalized" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/union.metadata.json b/parser/testdata/summary/postgres_regress/union.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/union.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/union.test b/parser/testdata/summary/postgres_regress/union.test new file mode 100644 index 0000000..94102d0 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/union.test @@ -0,0 +1,1333 @@ +== 001 +|-- +-- UNION (also INTERSECT, EXCEPT) +|-- + +-- Simple UNION constructs + +SELECT 1 AS two UNION SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +== 002 +SELECT 1 AS one UNION SELECT 1 ORDER BY 1 +-- +STMT: SelectStmt +== 003 +SELECT 1 AS two UNION ALL SELECT 2 +-- +STMT: SelectStmt +== 004 +SELECT 1 AS two UNION ALL SELECT 1 +-- +STMT: SelectStmt +== 005 +SELECT 1 AS three UNION SELECT 2 UNION SELECT 3 ORDER BY 1 +-- +STMT: SelectStmt +== 006 +SELECT 1 AS two UNION SELECT 2 UNION SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +== 007 +SELECT 1 AS three UNION SELECT 2 UNION ALL SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +== 008 +SELECT 1.1 AS two UNION SELECT 2.2 ORDER BY 1 +-- +STMT: SelectStmt +== 009 +-- Mixed types + +SELECT 1.1 AS two UNION SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +== 010 +SELECT 1 AS two UNION SELECT 2.2 ORDER BY 1 +-- +STMT: SelectStmt +== 011 +SELECT 1 AS one UNION SELECT 1.0::float8 ORDER BY 1 +-- +STMT: SelectStmt +== 012 +SELECT 1.1 AS two UNION ALL SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +== 013 +SELECT 1.0::float8 AS two UNION ALL SELECT 1 ORDER BY 1 +-- +STMT: SelectStmt +== 014 +SELECT 1.1 AS three UNION SELECT 2 UNION SELECT 3 ORDER BY 1 +-- +STMT: SelectStmt +== 015 +SELECT 1.1::float8 AS two UNION SELECT 2 UNION SELECT 2.0::float8 ORDER BY 1 +-- +STMT: SelectStmt +== 016 +SELECT 1.1 AS three UNION SELECT 2 UNION ALL SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +== 017 +SELECT 1.1 AS two UNION (SELECT 2 UNION ALL SELECT 2) ORDER BY 1 +-- +STMT: SelectStmt +== 018 +|-- +-- Try testing from tables... +|-- + +SELECT f1 AS five FROM FLOAT8_TBL +UNION +SELECT f1 FROM FLOAT8_TBL +ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +== 019 +SELECT f1 AS ten FROM FLOAT8_TBL +UNION ALL +SELECT f1 FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +== 020 +SELECT f1 AS nine FROM FLOAT8_TBL +UNION +SELECT f1 FROM INT4_TBL +ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +== 021 +SELECT f1 AS ten FROM FLOAT8_TBL +UNION ALL +SELECT f1 FROM INT4_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +== 022 +SELECT f1 AS five FROM FLOAT8_TBL + WHERE f1 BETWEEN -1e6 AND 1e6 +UNION +SELECT f1 FROM INT4_TBL + WHERE f1 BETWEEN 0 AND 1000000 +ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 023 +SELECT CAST(f1 AS char(4)) AS three FROM VARCHAR_TBL +UNION +SELECT f1 FROM CHAR_TBL +ORDER BY 1 +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +== 024 +SELECT f1 AS three FROM VARCHAR_TBL +UNION +SELECT CAST(f1 AS varchar) FROM CHAR_TBL +ORDER BY 1 +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +== 025 +SELECT f1 AS eight FROM VARCHAR_TBL +UNION ALL +SELECT f1 FROM CHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +== 026 +SELECT f1 AS five FROM TEXT_TBL +UNION +SELECT f1 FROM VARCHAR_TBL +UNION +SELECT TRIM(TRAILING FROM f1) FROM CHAR_TBL +ORDER BY 1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +FUNCTION: name="pg_catalog.rtrim" function="rtrim" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 027 +|-- +-- INTERSECT and EXCEPT +|-- + +SELECT q2 FROM int8_tbl INTERSECT SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 028 +SELECT q2 FROM int8_tbl INTERSECT ALL SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 029 +SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 030 +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 031 +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 032 +SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 033 +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q2 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 034 +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q2 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 035 +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl FOR NO KEY UPDATE +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 036 +-- nested cases +(SELECT 1,2,3 UNION SELECT 4,5,6) INTERSECT SELECT 4,5,6 +-- +STMT: SelectStmt +== 037 +(SELECT 1,2,3 UNION SELECT 4,5,6 ORDER BY 1,2) INTERSECT SELECT 4,5,6 +-- +STMT: SelectStmt +== 038 +(SELECT 1,2,3 UNION SELECT 4,5,6) EXCEPT SELECT 4,5,6 +-- +STMT: SelectStmt +== 039 +(SELECT 1,2,3 UNION SELECT 4,5,6 ORDER BY 1,2) EXCEPT SELECT 4,5,6 +-- +STMT: SelectStmt +== 040 +-- exercise both hashed and sorted implementations of UNION/INTERSECT/EXCEPT + +set enable_hashagg to on +-- +STMT: VariableSetStmt +== 041 +explain (costs off) +select count(*) from + ( select unique1 from tenk1 union select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 042 +select count(*) from + ( select unique1 from tenk1 union select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 043 +explain (costs off) +select count(*) from + ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 044 +select count(*) from + ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 045 +explain (costs off) +select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 046 +select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 047 +set enable_hashagg to off +-- +STMT: VariableSetStmt +== 048 +explain (costs off) +select count(*) from + ( select unique1 from tenk1 union select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 049 +select count(*) from + ( select unique1 from tenk1 union select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 050 +explain (costs off) +select count(*) from + ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 051 +select count(*) from + ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 052 +explain (costs off) +select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +== 053 +select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 054 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 055 +-- non-hashable type +set enable_hashagg to on +-- +STMT: VariableSetStmt +== 056 +explain (costs off) +select x from (values ('11'::varbit), ('10'::varbit)) _(x) union select x from (values ('11'::varbit), ('10'::varbit)) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 057 +set enable_hashagg to off +-- +STMT: VariableSetStmt +== 058 +explain (costs off) +select x from (values ('11'::varbit), ('10'::varbit)) _(x) union select x from (values ('11'::varbit), ('10'::varbit)) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 059 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 060 +-- arrays +set enable_hashagg to on +-- +STMT: VariableSetStmt +== 061 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 062 +select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +== 063 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 064 +select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +== 065 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 066 +select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +== 067 +-- non-hashable type +explain (costs off) +select x from (values (array['10'::varbit]), (array['11'::varbit])) _(x) union select x from (values (array['10'::varbit]), (array['01'::varbit])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 068 +select x from (values (array['10'::varbit]), (array['11'::varbit])) _(x) union select x from (values (array['10'::varbit]), (array['01'::varbit])) _(x) +-- +STMT: SelectStmt +== 069 +set enable_hashagg to off +-- +STMT: VariableSetStmt +== 070 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 071 +select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +== 072 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 073 +select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +== 074 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 075 +select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +== 076 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 077 +-- records +set enable_hashagg to on +-- +STMT: VariableSetStmt +== 078 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 079 +select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +== 080 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 081 +select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +== 082 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 083 +select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +== 084 +-- non-hashable type + +-- With an anonymous row type, the typcache does not report that the +-- type is hashable. (Otherwise, this would fail at execution time.) +explain (costs off) +select x from (values (row('10'::varbit)), (row('11'::varbit))) _(x) union select x from (values (row('10'::varbit)), (row('01'::varbit))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 085 +select x from (values (row('10'::varbit)), (row('11'::varbit))) _(x) union select x from (values (row('10'::varbit)), (row('01'::varbit))) _(x) +-- +STMT: SelectStmt +== 086 +-- With a defined row type, the typcache can inspect the type's fields +-- for hashability. +create type ct1 as (f1 varbit) +-- +STMT: CompositeTypeStmt +== 087 +explain (costs off) +select x from (values (row('10'::varbit)::ct1), (row('11'::varbit)::ct1)) _(x) union select x from (values (row('10'::varbit)::ct1), (row('01'::varbit)::ct1)) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 088 +select x from (values (row('10'::varbit)::ct1), (row('11'::varbit)::ct1)) _(x) union select x from (values (row('10'::varbit)::ct1), (row('01'::varbit)::ct1)) _(x) +-- +STMT: SelectStmt +== 089 +drop type ct1 +-- +STMT: DropStmt +== 090 +set enable_hashagg to off +-- +STMT: VariableSetStmt +== 091 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 092 +select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +== 093 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 094 +select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +== 095 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +== 096 +select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +== 097 +-- non-sortable type + +-- Ensure we get a HashAggregate plan. Keep enable_hashagg=off to ensure +-- there's no chance of a sort. +explain (costs off) select '123'::xid union select '123'::xid +-- +STMT: ExplainStmt +STMT: SelectStmt +== 098 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 099 +|-- +-- Mixed types +|-- + +SELECT f1 FROM float8_tbl INTERSECT SELECT f1 FROM int4_tbl ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +== 100 +SELECT f1 FROM float8_tbl EXCEPT SELECT f1 FROM int4_tbl ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +== 101 +|-- +-- Operator precedence and (((((extra))))) parentheses +|-- + +SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 102 +SELECT q1 FROM int8_tbl INTERSECT (((SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 103 +(((SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl ORDER BY 1))) UNION ALL SELECT q2 FROM int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 104 +SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 105 +SELECT q1 FROM int8_tbl UNION ALL (((SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1))) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 106 +(((SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 107 +|-- +-- Subqueries with ORDER BY & LIMIT clauses +|-- + +-- In this syntax, ORDER BY/LIMIT apply to the result of the EXCEPT +SELECT q1,q2 FROM int8_tbl EXCEPT SELECT q2,q1 FROM int8_tbl +ORDER BY q2,q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 108 +-- This should fail, because q2 isn't a name of an EXCEPT output column +SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 109 +-- But this should work: +SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))) ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 110 +|-- +-- New syntaxes (7.1) permit new tests +|-- + +(((((select * from int8_tbl))))) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +== 111 +|-- +-- Check behavior with empty select list (allowed since 9.4) +|-- + +select union select +-- +STMT: SelectStmt +== 112 +select intersect select +-- +STMT: SelectStmt +== 113 +select except select +-- +STMT: SelectStmt +== 114 +-- check hashed implementation +set enable_hashagg = true +-- +STMT: VariableSetStmt +== 115 +set enable_sort = false +-- +STMT: VariableSetStmt +== 116 +-- We've no way to check hashed UNION as the empty pathkeys in the Append are +-- fine to make use of Unique, which is cheaper than HashAggregate and we've +-- no means to disable Unique. +explain (costs off) +select from generate_series(1,5) intersect select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 117 +select from generate_series(1,5) union all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 118 +select from generate_series(1,5) intersect select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 119 +select from generate_series(1,5) intersect all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 120 +select from generate_series(1,5) except select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 121 +select from generate_series(1,5) except all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 122 +-- check sorted implementation +set enable_hashagg = false +-- +STMT: VariableSetStmt +== 123 +set enable_sort = true +-- +STMT: VariableSetStmt +== 124 +explain (costs off) +select from generate_series(1,5) union select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 125 +explain (costs off) +select from generate_series(1,5) intersect select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 126 +select from generate_series(1,5) union select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 127 +select from generate_series(1,5) union all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 128 +select from generate_series(1,5) intersect select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 129 +select from generate_series(1,5) intersect all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 130 +select from generate_series(1,5) except select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 131 +select from generate_series(1,5) except all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 132 +-- Try a variation of the above but with a CTE which contains a column, again +-- with an empty final select list. + +-- Ensure we get the expected 1 row with 0 columns +with cte as materialized (select s from generate_series(1,5) s) +select from cte union select from cte +-- +CTE: "cte" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 133 +-- Ensure we get the same result as the above. +with cte as not materialized (select s from generate_series(1,5) s) +select from cte union select from cte +-- +CTE: "cte" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 134 +reset enable_hashagg +-- +STMT: VariableSetStmt +== 135 +reset enable_sort +-- +STMT: VariableSetStmt +== 136 +|-- +-- Check handling of a case with unknown constants. We don't guarantee +-- an undecorated constant will work in all cases, but historically this +-- usage has worked, so test we don't break it. +|-- + +SELECT a.f1 FROM (SELECT 'test' AS f1 FROM varchar_tbl) a +UNION +SELECT b.f1 FROM (SELECT f1 FROM varchar_tbl) b +ORDER BY 1 +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +STMT: SelectStmt +== 137 +-- This should fail, but it should produce an error cursor +SELECT '3.4'::numeric UNION SELECT 'foo' +-- +STMT: SelectStmt +== 138 +|-- +-- Test that expression-index constraints can be pushed down through +-- UNION or UNION ALL +|-- + +CREATE TEMP TABLE t1 (a text, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 139 +CREATE INDEX t1_ab_idx on t1 ((a || b)) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: IndexStmt +== 140 +CREATE TEMP TABLE t2 (ab text primary key) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 141 +INSERT INTO t1 VALUES ('a', 'b'), ('x', 'y') +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 142 +INSERT INTO t2 VALUES ('ab'), ('xy') +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 143 +set enable_seqscan = off +-- +STMT: VariableSetStmt +== 144 +set enable_indexscan = on +-- +STMT: VariableSetStmt +== 145 +set enable_bitmapscan = off +-- +STMT: VariableSetStmt +== 146 +set enable_sort = off +-- +STMT: VariableSetStmt +== 147 +explain (costs off) + SELECT * FROM + (SELECT a || b AS ab FROM t1 + UNION ALL + SELECT * FROM t2) t + WHERE ab = 'ab' +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +FILTER: schema="" table="" column="ab" +STMT: ExplainStmt +STMT: SelectStmt +== 148 +explain (costs off) + SELECT * FROM + (SELECT a || b AS ab FROM t1 + UNION + SELECT * FROM t2) t + WHERE ab = 'ab' +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +FILTER: schema="" table="" column="ab" +STMT: ExplainStmt +STMT: SelectStmt +== 149 +|-- +-- Test that ORDER BY for UNION ALL can be pushed down to inheritance +-- children. +|-- + +CREATE TEMP TABLE t1c (b text, a text) +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DDL +STMT: CreateStmt +== 150 +ALTER TABLE t1c INHERIT t1 +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DDL +STMT: AlterTableStmt +== 151 +CREATE TEMP TABLE t2c (primary key (ab)) INHERITS (t2) +-- +TABLE: name="t2c" schema="" table="t2c" ctx=DDL +STMT: CreateStmt +== 152 +INSERT INTO t1c VALUES ('v', 'w'), ('c', 'd'), ('m', 'n'), ('e', 'f') +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 153 +INSERT INTO t2c VALUES ('vw'), ('cd'), ('mn'), ('ef') +-- +TABLE: name="t2c" schema="" table="t2c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 154 +CREATE INDEX t1c_ab_idx on t1c ((a || b)) +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DDL +STMT: IndexStmt +== 155 +set enable_seqscan = on +-- +STMT: VariableSetStmt +== 156 +set enable_indexonlyscan = off +-- +STMT: VariableSetStmt +== 157 +explain (costs off) + SELECT * FROM + (SELECT a || b AS ab FROM t1 + UNION ALL + SELECT ab FROM t2) t + ORDER BY 1 LIMIT 8 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 158 +SELECT * FROM + (SELECT a || b AS ab FROM t1 + UNION ALL + SELECT ab FROM t2) t + ORDER BY 1 LIMIT 8 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +== 159 +reset enable_seqscan +-- +STMT: VariableSetStmt +== 160 +reset enable_indexscan +-- +STMT: VariableSetStmt +== 161 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +== 162 +reset enable_sort +-- +STMT: VariableSetStmt +== 163 +-- This simpler variant of the above test has been observed to fail differently + +create table events (event_id int primary key) +-- +TABLE: name="events" schema="" table="events" ctx=DDL +STMT: CreateStmt +== 164 +create table other_events (event_id int primary key) +-- +TABLE: name="other_events" schema="" table="other_events" ctx=DDL +STMT: CreateStmt +== 165 +create table events_child () inherits (events) +-- +TABLE: name="events_child" schema="" table="events_child" ctx=DDL +STMT: CreateStmt +== 166 +explain (costs off) +select event_id + from (select event_id from events + union all + select event_id from other_events) ss + order by event_id +-- +TABLE: name="events" schema="" table="events" ctx=Select +TABLE: name="other_events" schema="" table="other_events" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 167 +drop table events_child, events, other_events +-- +TABLE: name="events_child" schema="" table="events_child" ctx=DDL +TABLE: name="events" schema="" table="events" ctx=DDL +TABLE: name="other_events" schema="" table="other_events" ctx=DDL +STMT: DropStmt +== 168 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +== 169 +-- Test constraint exclusion of UNION ALL subqueries +explain (costs off) + SELECT * FROM + (SELECT 1 AS t, * FROM tenk1 a + UNION ALL + SELECT 2 AS t, * FROM tenk1 b) c + WHERE t = 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 170 +-- Test that we push quals into UNION sub-selects only when it's safe +explain (costs off) +SELECT * FROM + (SELECT 1 AS t, 2 AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x < 4 +ORDER BY x +-- +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 171 +SELECT * FROM + (SELECT 1 AS t, 2 AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x < 4 +ORDER BY x +-- +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 172 +explain (costs off) +SELECT * FROM + (SELECT 1 AS t, generate_series(1,10) AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x < 4 +ORDER BY x +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 173 +SELECT * FROM + (SELECT 1 AS t, generate_series(1,10) AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x < 4 +ORDER BY x +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 174 +explain (costs off) +SELECT * FROM + (SELECT 1 AS t, (random()*3)::int AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x > 3 +ORDER BY x +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +== 175 +SELECT * FROM + (SELECT 1 AS t, (random()*3)::int AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x > 3 +ORDER BY x +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +== 176 +-- Test cases where the native ordering of a sub-select has more pathkeys +-- than the outer query cares about +explain (costs off) +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where q2 = q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 177 +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where q2 = q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 178 +explain (costs off) +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where -q1 = q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 179 +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where -q1 = q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 180 +-- Test proper handling of parameterized appendrel paths when the +-- potential join qual is expensive +create function expensivefunc(int) returns int +language plpgsql immutable strict cost 10000 +as $$begin return $1; end$$ +-- +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 181 +create temp table t3 as select generate_series(-1000,1000) as x +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 182 +create index t3i on t3 (expensivefunc(x)) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=Call +STMT: IndexStmt +== 183 +analyze t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: VacuumStmt +== 184 +explain (costs off) +select * from + (select * from t3 a union all select * from t3 b) ss + join int4_tbl on f1 = expensivefunc(x) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "a"="t3" +ALIAS: "b"="t3" +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 185 +select * from + (select * from t3 a union all select * from t3 b) ss + join int4_tbl on f1 = expensivefunc(x) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "a"="t3" +ALIAS: "b"="t3" +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=Call +STMT: SelectStmt +== 186 +drop table t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: DropStmt +== 187 +drop function expensivefunc(int) +-- +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=DDL +STMT: DropStmt +== 188 +-- Test handling of appendrel quals that const-simplify into an AND +explain (costs off) +select * from + (select *, 0 as x from int8_tbl a + union all + select *, 1 as x from int8_tbl b) ss +where (x = 0) or (q1 >= q2 and q1 <= q2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +== 189 +select * from + (select *, 0 as x from int8_tbl a + union all + select *, 1 as x from int8_tbl b) ss +where (x = 0) or (q1 >= q2 and q1 <= q2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +== 190 +|-- +-- Test the planner's ability to produce cheap startup plans with Append nodes +|-- + +-- Ensure we get a Nested Loop join between tenk1 and tenk2 +explain (costs off) +select t1.unique1 from tenk1 t1 +inner join tenk2 t2 on t1.tenthous = t2.tenthous and t2.thousand = 0 + union all +(values(1)) limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: ExplainStmt +STMT: SelectStmt +== 191 +-- Ensure there is no problem if cheapest_startup_path is NULL +explain (costs off) +select * from tenk1 t1 +left join lateral + (select t1.tenthous from tenk2 t2 union all (values(1))) +on true limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: ExplainStmt +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/updatable_views.metadata.json b/parser/testdata/summary/postgres_regress/updatable_views.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/updatable_views.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/updatable_views.test b/parser/testdata/summary/postgres_regress/updatable_views.test new file mode 100644 index 0000000..388471b --- /dev/null +++ b/parser/testdata/summary/postgres_regress/updatable_views.test @@ -0,0 +1,7250 @@ +== 001 +|-- +-- UPDATABLE VIEWS +|-- + +-- avoid bit-exact output here because operations may not be bit-exact. +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +== 002 +-- check that non-updatable views and columns are rejected with useful error +-- messages + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 004 +CREATE VIEW ro_view1 AS SELECT DISTINCT a, b FROM base_tbl +-- +TABLE: name="ro_view1" schema="" table="ro_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 005 +-- DISTINCT not supported +CREATE VIEW ro_view2 AS SELECT a, b FROM base_tbl GROUP BY a, b +-- +TABLE: name="ro_view2" schema="" table="ro_view2" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 006 +-- GROUP BY not supported +CREATE VIEW ro_view3 AS SELECT 1 FROM base_tbl HAVING max(a) > 0 +-- +TABLE: name="ro_view3" schema="" table="ro_view3" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 007 +-- HAVING not supported +CREATE VIEW ro_view4 AS SELECT count(*) FROM base_tbl +-- +TABLE: name="ro_view4" schema="" table="ro_view4" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 008 +-- Aggregate functions not supported +CREATE VIEW ro_view5 AS SELECT a, rank() OVER() FROM base_tbl +-- +TABLE: name="ro_view5" schema="" table="ro_view5" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 009 +-- Window functions not supported +CREATE VIEW ro_view6 AS SELECT a, b FROM base_tbl UNION SELECT -a, b FROM base_tbl +-- +TABLE: name="ro_view6" schema="" table="ro_view6" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 010 +-- Set ops not supported +CREATE VIEW ro_view7 AS WITH t AS (SELECT a, b FROM base_tbl) SELECT * FROM t +-- +TABLE: name="ro_view7" schema="" table="ro_view7" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +CTE: "t" +STMT: ViewStmt +STMT: SelectStmt +== 011 +-- WITH not supported +CREATE VIEW ro_view8 AS SELECT a, b FROM base_tbl ORDER BY a OFFSET 1 +-- +TABLE: name="ro_view8" schema="" table="ro_view8" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 012 +-- OFFSET not supported +CREATE VIEW ro_view9 AS SELECT a, b FROM base_tbl ORDER BY a LIMIT 1 +-- +TABLE: name="ro_view9" schema="" table="ro_view9" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 013 +-- LIMIT not supported +CREATE VIEW ro_view10 AS SELECT 1 AS a +-- +TABLE: name="ro_view10" schema="" table="ro_view10" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 014 +-- No base relations +CREATE VIEW ro_view11 AS SELECT b1.a, b2.b FROM base_tbl b1, base_tbl b2 +-- +TABLE: name="ro_view11" schema="" table="ro_view11" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +ALIAS: "b1"="base_tbl" +ALIAS: "b2"="base_tbl" +STMT: ViewStmt +STMT: SelectStmt +== 015 +-- Multiple base relations +CREATE VIEW ro_view12 AS SELECT * FROM generate_series(1, 10) AS g(a) +-- +TABLE: name="ro_view12" schema="" table="ro_view12" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 016 +-- SRF in rangetable +CREATE VIEW ro_view13 AS SELECT a, b FROM (SELECT * FROM base_tbl) AS t +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 017 +-- Subselect in rangetable +CREATE VIEW rw_view14 AS SELECT ctid, a, b FROM base_tbl +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 018 +-- System columns may be part of an updatable view +CREATE VIEW rw_view15 AS SELECT a, upper(b) FROM base_tbl +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 019 +-- Expression/function may be part of an updatable view +CREATE VIEW rw_view16 AS SELECT a, b, a AS aa FROM base_tbl +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 020 +-- Repeated column may be part of an updatable view +CREATE VIEW ro_view17 AS SELECT * FROM ro_view1 +-- +TABLE: name="ro_view17" schema="" table="ro_view17" ctx=DDL +TABLE: name="ro_view1" schema="" table="ro_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 021 +-- Base relation not updatable +CREATE VIEW ro_view18 AS SELECT * FROM (VALUES(1)) AS tmp(a) +-- +TABLE: name="ro_view18" schema="" table="ro_view18" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 022 +-- VALUES in rangetable +CREATE SEQUENCE uv_seq +-- +STMT: CreateSeqStmt +== 023 +CREATE VIEW ro_view19 AS SELECT * FROM uv_seq +-- +TABLE: name="ro_view19" schema="" table="ro_view19" ctx=DDL +TABLE: name="uv_seq" schema="" table="uv_seq" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 024 +-- View based on a sequence +CREATE VIEW ro_view20 AS SELECT a, b, generate_series(1, a) g FROM base_tbl +-- +TABLE: name="ro_view20" schema="" table="ro_view20" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 025 +-- SRF in targetlist not supported + +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 026 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 027 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 028 +-- Read-only views +DELETE FROM ro_view1 +-- +TABLE: name="ro_view1" schema="" table="ro_view1" ctx=DML +STMT: DeleteStmt +== 029 +DELETE FROM ro_view2 +-- +TABLE: name="ro_view2" schema="" table="ro_view2" ctx=DML +STMT: DeleteStmt +== 030 +DELETE FROM ro_view3 +-- +TABLE: name="ro_view3" schema="" table="ro_view3" ctx=DML +STMT: DeleteStmt +== 031 +DELETE FROM ro_view4 +-- +TABLE: name="ro_view4" schema="" table="ro_view4" ctx=DML +STMT: DeleteStmt +== 032 +DELETE FROM ro_view5 +-- +TABLE: name="ro_view5" schema="" table="ro_view5" ctx=DML +STMT: DeleteStmt +== 033 +DELETE FROM ro_view6 +-- +TABLE: name="ro_view6" schema="" table="ro_view6" ctx=DML +STMT: DeleteStmt +== 034 +UPDATE ro_view7 SET a=a+1 +-- +TABLE: name="ro_view7" schema="" table="ro_view7" ctx=DML +STMT: UpdateStmt +== 035 +UPDATE ro_view8 SET a=a+1 +-- +TABLE: name="ro_view8" schema="" table="ro_view8" ctx=DML +STMT: UpdateStmt +== 036 +UPDATE ro_view9 SET a=a+1 +-- +TABLE: name="ro_view9" schema="" table="ro_view9" ctx=DML +STMT: UpdateStmt +== 037 +UPDATE ro_view10 SET a=a+1 +-- +TABLE: name="ro_view10" schema="" table="ro_view10" ctx=DML +STMT: UpdateStmt +== 038 +UPDATE ro_view11 SET a=a+1 +-- +TABLE: name="ro_view11" schema="" table="ro_view11" ctx=DML +STMT: UpdateStmt +== 039 +UPDATE ro_view12 SET a=a+1 +-- +TABLE: name="ro_view12" schema="" table="ro_view12" ctx=DML +STMT: UpdateStmt +== 040 +INSERT INTO ro_view13 VALUES (3, 'Row 3') +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 041 +MERGE INTO ro_view13 AS t USING (VALUES (1, 'Row 1')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +== 042 +MERGE INTO ro_view13 AS t USING (VALUES (2, 'Row 2')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = v.b +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +== 043 +MERGE INTO ro_view13 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.b) +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +== 044 +MERGE INTO ro_view13 AS t USING (VALUES (2, 'Row 2')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING + WHEN NOT MATCHED THEN DO NOTHING +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +== 045 +-- should be OK to do nothing +MERGE INTO ro_view13 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING + WHEN NOT MATCHED THEN DO NOTHING +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +== 046 +-- should be OK to do nothing +-- Partially updatable view +INSERT INTO rw_view14 VALUES (null, 3, 'Row 3') +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +-- should fail +INSERT INTO rw_view14 (a, b) VALUES (3, 'Row 3') +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +-- should be OK +UPDATE rw_view14 SET ctid=null WHERE a=3 +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: UpdateStmt +== 049 +-- should fail +UPDATE rw_view14 SET b='ROW 3' WHERE a=3 +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: UpdateStmt +== 050 +-- should be OK +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 051 +DELETE FROM rw_view14 WHERE a=3 +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: DeleteStmt +== 052 +-- should be OK +MERGE INTO rw_view14 AS t + USING (VALUES (2, 'Merged row 2'), (3, 'Merged row 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = v.b -- should be OK, except... + WHEN NOT MATCHED THEN INSERT VALUES (null, v.a, v.b) +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +ALIAS: "t"="rw_view14" +STMT: MergeStmt +STMT: SelectStmt +== 053 +-- should fail +MERGE INTO rw_view14 AS t + USING (VALUES (2, 'Merged row 2'), (3, 'Merged row 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = v.b -- should be OK + WHEN NOT MATCHED THEN INSERT (a,b) VALUES (v.a, v.b) +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +ALIAS: "t"="rw_view14" +STMT: MergeStmt +STMT: SelectStmt +== 054 +-- should be OK +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 055 +MERGE INTO rw_view14 AS t + USING (VALUES (2, 'Row 2'), (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED AND t.a = 2 THEN UPDATE SET b = v.b -- should be OK + WHEN MATCHED AND t.a = 3 THEN DELETE +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +ALIAS: "t"="rw_view14" +STMT: MergeStmt +STMT: SelectStmt +== 056 +-- should be OK +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 057 +-- Partially updatable view +INSERT INTO rw_view15 VALUES (3, 'ROW 3') +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 058 +-- should fail +INSERT INTO rw_view15 (a) VALUES (3) +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 059 +-- should be OK +INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT DO NOTHING +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 060 +-- succeeds +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +== 061 +INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO NOTHING +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 062 +-- succeeds +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +== 063 +INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO UPDATE set a = excluded.a +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 064 +-- succeeds +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +== 065 +INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO UPDATE set upper = 'blarg' +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 066 +-- fails +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +== 067 +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +== 068 +ALTER VIEW rw_view15 ALTER COLUMN upper SET DEFAULT 'NOT SET' +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DDL +STMT: AlterTableStmt +== 069 +INSERT INTO rw_view15 (a) VALUES (4) +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 070 +-- should fail +UPDATE rw_view15 SET upper='ROW 3' WHERE a=3 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: UpdateStmt +== 071 +-- should fail +UPDATE rw_view15 SET upper=DEFAULT WHERE a=3 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: UpdateStmt +== 072 +-- should fail +UPDATE rw_view15 SET a=4 WHERE a=3 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: UpdateStmt +== 073 +-- should be OK +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 074 +DELETE FROM rw_view15 WHERE a=4 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: DeleteStmt +== 075 +-- should be OK +-- Partially updatable view +INSERT INTO rw_view16 VALUES (3, 'Row 3', 3) +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 076 +-- should fail +INSERT INTO rw_view16 (a, b) VALUES (3, 'Row 3') +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 077 +-- should be OK +UPDATE rw_view16 SET a=3, aa=-3 WHERE a=3 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: UpdateStmt +== 078 +-- should fail +UPDATE rw_view16 SET aa=-3 WHERE a=3 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: UpdateStmt +== 079 +-- should be OK +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 080 +DELETE FROM rw_view16 WHERE a=-3 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: DeleteStmt +== 081 +-- should be OK +-- Read-only views +INSERT INTO ro_view17 VALUES (3, 'ROW 3') +-- +TABLE: name="ro_view17" schema="" table="ro_view17" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 082 +DELETE FROM ro_view18 +-- +TABLE: name="ro_view18" schema="" table="ro_view18" ctx=DML +STMT: DeleteStmt +== 083 +MERGE INTO ro_view18 AS t USING (VALUES (1, 'Row 1')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING +-- +TABLE: name="ro_view18" schema="" table="ro_view18" ctx=DML +ALIAS: "t"="ro_view18" +STMT: MergeStmt +STMT: SelectStmt +== 084 +-- should be OK to do nothing +UPDATE ro_view19 SET last_value=1000 +-- +TABLE: name="ro_view19" schema="" table="ro_view19" ctx=DML +STMT: UpdateStmt +== 085 +UPDATE ro_view20 SET b=upper(b) +-- +TABLE: name="ro_view20" schema="" table="ro_view20" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: UpdateStmt +== 086 +-- A view with a conditional INSTEAD rule but no unconditional INSTEAD rules +-- or INSTEAD OF triggers should be non-updatable and generate useful error +-- messages with appropriate detail +CREATE RULE rw_view16_ins_rule AS ON INSERT TO rw_view16 + WHERE NEW.a > 0 DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a, NEW.b) +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DDL +STMT: RuleStmt +== 087 +CREATE RULE rw_view16_upd_rule AS ON UPDATE TO rw_view16 + WHERE OLD.a > 0 DO INSTEAD UPDATE base_tbl SET b=NEW.b WHERE a=OLD.a +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DDL +STMT: RuleStmt +== 088 +CREATE RULE rw_view16_del_rule AS ON DELETE TO rw_view16 + WHERE OLD.a > 0 DO INSTEAD DELETE FROM base_tbl WHERE a=OLD.a +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DDL +STMT: RuleStmt +== 089 +INSERT INTO rw_view16 (a, b) VALUES (3, 'Row 3') +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 090 +-- should fail +UPDATE rw_view16 SET b='ROW 2' WHERE a=2 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: UpdateStmt +== 091 +-- should fail +DELETE FROM rw_view16 WHERE a=2 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: DeleteStmt +== 092 +-- should fail +MERGE INTO rw_view16 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.b) +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +ALIAS: "t"="rw_view16" +STMT: MergeStmt +STMT: SelectStmt +== 093 +-- should fail + +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 094 +DROP VIEW ro_view10, ro_view12, ro_view18 +-- +STMT: DropStmt +== 095 +DROP SEQUENCE uv_seq CASCADE +-- +STMT: DropStmt +== 096 +-- simple updatable view + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 097 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 098 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a>0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 099 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 101 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name = 'rw_view1' + ORDER BY ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 102 +INSERT INTO rw_view1 VALUES (3, 'Row 3') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 103 +INSERT INTO rw_view1 (a) VALUES (4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 104 +UPDATE rw_view1 SET a=5 WHERE a=4 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 105 +DELETE FROM rw_view1 WHERE b='Row 2' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 106 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 107 +MERGE INTO rw_view1 t + USING (VALUES (0, 'ROW 0'), (1, 'ROW 1'), + (2, 'ROW 2'), (3, 'ROW 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED AND t.a <= 1 THEN UPDATE SET b = v.b + WHEN MATCHED THEN DELETE + WHEN NOT MATCHED AND a > 0 THEN INSERT (a) VALUES (v.a) + RETURNING merge_action(), v.*, t.* +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 108 +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 109 +MERGE INTO rw_view1 t + USING (VALUES (0, 'R0'), (1, 'R1'), + (2, 'R2'), (3, 'R3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED AND t.a <= 1 THEN UPDATE SET b = v.b + WHEN MATCHED THEN DELETE + WHEN NOT MATCHED BY SOURCE THEN DELETE + WHEN NOT MATCHED AND a > 0 THEN INSERT (a) VALUES (v.a) + RETURNING merge_action(), v.*, t.* +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 110 +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 111 +EXPLAIN (costs off) UPDATE rw_view1 SET a=6 WHERE a=5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 112 +EXPLAIN (costs off) DELETE FROM rw_view1 WHERE a=5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 113 +EXPLAIN (costs off) +MERGE INTO rw_view1 t USING (VALUES (5, 'X')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 114 +EXPLAIN (costs off) +MERGE INTO rw_view1 t + USING (SELECT * FROM generate_series(1,5)) AS s(a) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = 'Updated' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 115 +EXPLAIN (costs off) +MERGE INTO rw_view1 t + USING (SELECT * FROM generate_series(1,5)) AS s(a) ON t.a = s.a + WHEN NOT MATCHED BY SOURCE THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 116 +EXPLAIN (costs off) +MERGE INTO rw_view1 t + USING (SELECT * FROM generate_series(1,5)) AS s(a) ON t.a = s.a + WHEN NOT MATCHED THEN INSERT (a) VALUES (s.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 117 +-- it's still updatable if we add a DO ALSO rule + +CREATE TABLE base_tbl_hist(ts timestamptz default now(), a int, b text) +-- +TABLE: name="base_tbl_hist" schema="" table="base_tbl_hist" ctx=DDL +STMT: CreateStmt +== 118 +CREATE RULE base_tbl_log AS ON INSERT TO rw_view1 DO ALSO + INSERT INTO base_tbl_hist(a,b) VALUES(new.a, new.b) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +== 119 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 120 +-- Check behavior with DEFAULTs (bug #17633) + +INSERT INTO rw_view1 VALUES (9, DEFAULT), (10, DEFAULT) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 121 +SELECT a, b FROM base_tbl_hist +-- +TABLE: name="base_tbl_hist" schema="" table="base_tbl_hist" ctx=Select +STMT: SelectStmt +== 122 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 123 +DROP TABLE base_tbl_hist +-- +TABLE: name="base_tbl_hist" schema="" table="base_tbl_hist" ctx=DDL +STMT: DropStmt +== 124 +-- view on top of view + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 125 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 126 +CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl WHERE a>0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 127 +CREATE VIEW rw_view2 AS SELECT aa AS aaa, bb AS bbb FROM rw_view1 WHERE aa<10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="aa" +STMT: ViewStmt +STMT: SelectStmt +== 128 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 129 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 130 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name = 'rw_view2' + ORDER BY ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 131 +INSERT INTO rw_view2 VALUES (3, 'Row 3') +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 132 +INSERT INTO rw_view2 (aaa) VALUES (4) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 133 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 134 +UPDATE rw_view2 SET bbb='Row 4' WHERE aaa=4 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 135 +DELETE FROM rw_view2 WHERE aaa=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 136 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 137 +MERGE INTO rw_view2 t + USING (VALUES (3, 'R3'), (4, 'R4'), (5, 'R5')) AS v(a,b) ON aaa = v.a + WHEN MATCHED AND aaa = 3 THEN DELETE + WHEN MATCHED THEN UPDATE SET bbb = v.b + WHEN NOT MATCHED THEN INSERT (aaa) VALUES (v.a) + RETURNING merge_action(), v.*, t.* +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 138 +SELECT * FROM rw_view2 ORDER BY aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 139 +MERGE INTO rw_view2 t + USING (VALUES (4, 'r4'), (5, 'r5'), (6, 'r6')) AS v(a,b) ON aaa = v.a + WHEN MATCHED AND aaa = 4 THEN DELETE + WHEN MATCHED THEN UPDATE SET bbb = v.b + WHEN NOT MATCHED THEN INSERT (aaa) VALUES (v.a) + WHEN NOT MATCHED BY SOURCE THEN UPDATE SET bbb = 'Not matched by source' + RETURNING merge_action(), v.*, t.* +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 140 +SELECT * FROM rw_view2 ORDER BY aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 141 +EXPLAIN (costs off) UPDATE rw_view2 SET aaa=5 WHERE aaa=4 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 142 +EXPLAIN (costs off) DELETE FROM rw_view2 WHERE aaa=4 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 143 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 144 +-- view on top of view with rules + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 145 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 146 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a>0 OFFSET 0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 147 +-- not updatable without rules/triggers +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a<10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 148 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 149 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 150 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 151 +CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 + DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a, NEW.b) RETURNING * +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +== 152 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 153 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 154 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 155 +CREATE RULE rw_view1_upd_rule AS ON UPDATE TO rw_view1 + DO INSTEAD UPDATE base_tbl SET b=NEW.b WHERE a=OLD.a RETURNING NEW.* +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +== 156 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 157 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 158 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 159 +CREATE RULE rw_view1_del_rule AS ON DELETE TO rw_view1 + DO INSTEAD DELETE FROM base_tbl WHERE a=OLD.a RETURNING OLD.* +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +== 160 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 161 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 162 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 163 +INSERT INTO rw_view2 VALUES (3, 'Row 3') RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 164 +UPDATE rw_view2 SET b='Row three' WHERE a=3 RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 165 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 166 +DELETE FROM rw_view2 WHERE a=3 RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 167 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 168 +MERGE INTO rw_view2 t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 169 +-- should fail + +EXPLAIN (costs off) UPDATE rw_view2 SET a=3 WHERE a=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 170 +EXPLAIN (costs off) DELETE FROM rw_view2 WHERE a=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 171 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 172 +-- view on top of view with triggers + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 173 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 174 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a>0 OFFSET 0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 175 +-- not updatable without rules/triggers +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a<10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 176 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 177 +SELECT table_name, is_updatable, is_insertable_into, + is_trigger_updatable, is_trigger_deletable, + is_trigger_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 178 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 179 +CREATE FUNCTION rw_view1_trig_fn() +RETURNS trigger AS +$$ +BEGIN + IF TG_OP = 'INSERT' THEN + INSERT INTO base_tbl VALUES (NEW.a, NEW.b); + RETURN NEW; + ELSIF TG_OP = 'UPDATE' THEN + UPDATE base_tbl SET b=NEW.b WHERE a=OLD.a; + RETURN NEW; + ELSIF TG_OP = 'DELETE' THEN + DELETE FROM base_tbl WHERE a=OLD.a; + RETURN OLD; + END IF; +END; +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 180 +CREATE TRIGGER rw_view1_ins_trig INSTEAD OF INSERT ON rw_view1 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: CreateTrigStmt +== 181 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 182 +SELECT table_name, is_updatable, is_insertable_into, + is_trigger_updatable, is_trigger_deletable, + is_trigger_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 183 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 184 +CREATE TRIGGER rw_view1_upd_trig INSTEAD OF UPDATE ON rw_view1 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: CreateTrigStmt +== 185 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 186 +SELECT table_name, is_updatable, is_insertable_into, + is_trigger_updatable, is_trigger_deletable, + is_trigger_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 187 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 188 +CREATE TRIGGER rw_view1_del_trig INSTEAD OF DELETE ON rw_view1 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: CreateTrigStmt +== 189 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 190 +SELECT table_name, is_updatable, is_insertable_into, + is_trigger_updatable, is_trigger_deletable, + is_trigger_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 191 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 192 +INSERT INTO rw_view2 VALUES (3, 'Row 3') RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 193 +UPDATE rw_view2 SET b='Row three' WHERE a=3 RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 194 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 195 +DELETE FROM rw_view2 WHERE a=3 RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 196 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 197 +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED AND t.a <= 1 THEN DELETE + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) + RETURNING merge_action(), s.*, t.* +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 198 +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 199 +MERGE INTO rw_view2 t + USING (SELECT x, 'r'||x FROM generate_series(0,2) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) + WHEN NOT MATCHED BY SOURCE THEN UPDATE SET b = 'Not matched by source' + RETURNING merge_action(), s.*, t.* +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 200 +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 201 +EXPLAIN (costs off) UPDATE rw_view2 SET a=3 WHERE a=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 202 +EXPLAIN (costs off) DELETE FROM rw_view2 WHERE a=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +== 203 +EXPLAIN (costs off) +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED AND t.a <= 1 THEN DELETE + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 204 +-- MERGE with incomplete set of INSTEAD OF triggers +DROP TRIGGER rw_view1_del_trig ON rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: DropStmt +== 205 +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED AND t.a <= 1 THEN DELETE + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 206 +-- should fail +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 207 +-- ok + +DROP TRIGGER rw_view1_ins_trig ON rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: DropStmt +== 208 +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 209 +-- should fail +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 210 +-- ok + +-- MERGE with INSTEAD OF triggers on auto-updatable view +CREATE TRIGGER rw_view2_upd_trig INSTEAD OF UPDATE ON rw_view2 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +STMT: CreateTrigStmt +== 211 +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 212 +-- should fail +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 213 +-- ok +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 214 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 215 +DROP FUNCTION rw_view1_trig_fn() +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: DropStmt +== 216 +-- update using whole row from view + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 217 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 218 +CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 219 +CREATE FUNCTION rw_view1_aa(x rw_view1) + RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql +-- +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 220 +UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2 + RETURNING rw_view1_aa(v), v.bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "v"="rw_view1" +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=Call +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=Call +STMT: UpdateStmt +== 221 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 222 +EXPLAIN (costs off) +UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2 + RETURNING rw_view1_aa(v), v.bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "v"="rw_view1" +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=Call +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 223 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 224 +-- permissions checks + +CREATE USER regress_view_user1 +-- +STMT: CreateRoleStmt +== 225 +CREATE USER regress_view_user2 +-- +STMT: CreateRoleStmt +== 226 +CREATE USER regress_view_user3 +-- +STMT: CreateRoleStmt +== 227 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 228 +CREATE TABLE base_tbl(a int, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 229 +INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 230 +CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 231 +INSERT INTO rw_view1 VALUES ('Row 2', 2.0, 2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 232 +GRANT SELECT ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 233 +GRANT SELECT ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 234 +GRANT UPDATE (a,c) ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 235 +GRANT UPDATE (bb,cc) ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 236 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 237 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 238 +CREATE VIEW rw_view2 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 239 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 240 +-- ok +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 241 +-- ok +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 242 +-- ok + +INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 243 +-- not allowed +INSERT INTO rw_view1 VALUES ('Row 3', 3.0, 3) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 244 +-- not allowed +INSERT INTO rw_view2 VALUES ('Row 3', 3.0, 3) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 245 +-- not allowed + +MERGE INTO rw_view1 t + USING (VALUES ('Row 3', 3.0, 3)) AS v(b,c,a) ON t.aa = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.b, v.c, v.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 246 +-- not allowed +MERGE INTO rw_view2 t + USING (VALUES ('Row 3', 3.0, 3)) AS v(b,c,a) ON t.aa = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.b, v.c, v.a) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 247 +-- not allowed + +UPDATE base_tbl SET a=a, c=c +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +== 248 +-- ok +UPDATE base_tbl SET b=b +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +== 249 +-- not allowed +UPDATE rw_view1 SET bb=bb, cc=cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 250 +-- ok +UPDATE rw_view1 SET aa=aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 251 +-- not allowed +UPDATE rw_view2 SET aa=aa, cc=cc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 252 +-- ok +UPDATE rw_view2 SET bb=bb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 253 +-- not allowed + +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET bb = bb, cc = cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 254 +-- ok +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 255 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa, cc = cc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 256 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET bb = bb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 257 +-- not allowed + +DELETE FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +== 258 +-- not allowed +DELETE FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 259 +-- not allowed +DELETE FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 260 +-- not allowed +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 261 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 262 +GRANT INSERT, DELETE ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 263 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 264 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 265 +INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 266 +-- ok +INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 267 +-- not allowed +INSERT INTO rw_view2 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 268 +-- ok +DELETE FROM base_tbl WHERE a=1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +== 269 +-- ok +DELETE FROM rw_view1 WHERE aa=2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 270 +-- not allowed +DELETE FROM rw_view2 WHERE aa=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 271 +-- ok +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED AND bb = 'xxx' THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 272 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED AND bb = 'xxx' THEN DELETE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 273 +-- ok +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 274 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 275 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 276 +REVOKE INSERT, DELETE ON base_tbl FROM regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 277 +GRANT INSERT, DELETE ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 278 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 279 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 280 +INSERT INTO base_tbl VALUES (5, 'Row 5', 5.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 281 +-- not allowed +INSERT INTO rw_view1 VALUES ('Row 5', 5.0, 5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 282 +-- ok +INSERT INTO rw_view2 VALUES ('Row 6', 6.0, 6) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 283 +-- not allowed +DELETE FROM base_tbl WHERE a=3 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +== 284 +-- not allowed +DELETE FROM rw_view1 WHERE aa=3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 285 +-- ok +DELETE FROM rw_view2 WHERE aa=4 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 286 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED AND bb = 'xxx' THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 287 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED AND bb = 'xxx' THEN DELETE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 288 +-- not allowed +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 289 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 290 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 291 +-- nested-view permissions + +CREATE TABLE base_tbl(a int, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 292 +INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 293 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 294 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 295 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 296 +-- not allowed +SELECT * FROM rw_view1 FOR UPDATE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 297 +-- not allowed +UPDATE rw_view1 SET b = 'foo' WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 298 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 299 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 300 +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 301 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 302 +-- not allowed +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 303 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 304 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 305 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 306 +GRANT SELECT ON base_tbl TO regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 307 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 308 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 309 +SELECT * FROM rw_view1 FOR UPDATE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 310 +-- not allowed +UPDATE rw_view1 SET b = 'foo' WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 311 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 312 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 313 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 314 +-- not allowed +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 315 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 316 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 317 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 318 +GRANT SELECT ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 319 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 320 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 321 +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 322 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 323 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 324 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 325 +GRANT UPDATE ON base_tbl TO regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 326 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 327 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 328 +SELECT * FROM rw_view1 FOR UPDATE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 329 +UPDATE rw_view1 SET b = 'foo' WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 330 +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 331 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 332 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 333 +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 334 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 335 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'bar' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 336 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 337 +GRANT UPDATE ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 338 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 339 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 340 +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 341 +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 342 +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'fud' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 343 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 344 +REVOKE UPDATE ON base_tbl FROM regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 345 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 346 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 347 +SELECT * FROM rw_view1 FOR UPDATE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 348 +-- not allowed +UPDATE rw_view1 SET b = 'foo' WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 349 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 350 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 351 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 352 +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 353 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 354 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 355 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 356 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 357 +-- security invoker view permissions + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 358 +CREATE TABLE base_tbl(a int, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 359 +INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 360 +CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 361 +ALTER VIEW rw_view1 SET (security_invoker = true) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +== 362 +INSERT INTO rw_view1 VALUES ('Row 2', 2.0, 2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 363 +GRANT SELECT ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 364 +GRANT UPDATE (bb,cc) ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 365 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 366 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 367 +-- not allowed +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 368 +-- not allowed +INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 369 +-- not allowed +INSERT INTO rw_view1 VALUES ('Row 3', 3.0, 3) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 370 +-- not allowed +UPDATE base_tbl SET a=a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +== 371 +-- not allowed +UPDATE rw_view1 SET bb=bb, cc=cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 372 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET bb = bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 373 +-- not allowed +DELETE FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +== 374 +-- not allowed +DELETE FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 375 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 376 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 377 +GRANT SELECT ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 378 +GRANT UPDATE (a,c) ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 379 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 380 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 381 +-- ok +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 382 +-- ok +UPDATE base_tbl SET a=a, c=c +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +== 383 +-- ok +UPDATE base_tbl SET b=b +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +== 384 +-- not allowed +UPDATE rw_view1 SET cc=cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 385 +-- ok +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET cc = cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 386 +-- ok +UPDATE rw_view1 SET aa=aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 387 +-- not allowed +UPDATE rw_view1 SET bb=bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 388 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 389 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET bb = bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 390 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 391 +GRANT INSERT, DELETE ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 392 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 393 +INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 394 +-- ok +INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 395 +-- not allowed +DELETE FROM base_tbl WHERE a=1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +== 396 +-- ok +DELETE FROM rw_view1 WHERE aa=2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 397 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 398 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 399 +REVOKE INSERT, DELETE ON base_tbl FROM regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 400 +GRANT INSERT, DELETE ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 401 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 402 +INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 403 +-- not allowed +DELETE FROM rw_view1 WHERE aa=2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 404 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 405 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 406 +GRANT INSERT, DELETE ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 407 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 408 +INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 409 +-- ok +DELETE FROM rw_view1 WHERE aa=2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 410 +-- ok +MERGE INTO rw_view1 t USING (VALUES (3)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 411 +-- ok +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 412 +-- ok + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 413 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 414 +-- ordinary view on top of security invoker view permissions + +CREATE TABLE base_tbl(a int, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 415 +INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 416 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 417 +CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 418 +ALTER VIEW rw_view1 SET (security_invoker = true) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +== 419 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 420 +-- not allowed +UPDATE rw_view1 SET aa=aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 421 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (2, 'Row 2', 2.0)) AS v(a,b,c) ON t.aa = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.b, v.c, v.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 422 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 423 +CREATE VIEW rw_view2 AS SELECT cc AS ccc, aa AS aaa, bb AS bbb FROM rw_view1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 424 +GRANT SELECT, UPDATE ON rw_view2 TO regress_view_user3 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +STMT: GrantStmt +== 425 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 426 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 427 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (2, 'Row 2', 2.0)) AS v(a,b,c) ON t.aaa = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.c, v.a, v.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 428 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 429 +GRANT SELECT ON base_tbl TO regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 430 +GRANT UPDATE (a, b) ON base_tbl TO regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 431 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 432 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 433 +-- ok +UPDATE rw_view1 SET aa=aa, bb=bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 434 +-- ok +UPDATE rw_view1 SET cc=cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 435 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa, bb = bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 436 +-- ok +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET cc = cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 437 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 438 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 439 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 440 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 441 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +== 442 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 443 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 444 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 445 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 446 +GRANT SELECT ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 447 +GRANT UPDATE (bb, cc) ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 448 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 449 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 450 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 451 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 452 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +== 453 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 454 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 455 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 456 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 457 +GRANT SELECT ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 458 +GRANT UPDATE (a, c) ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 459 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 460 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 461 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 462 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 463 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 464 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 465 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 466 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 467 +-- ok + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +== 468 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 469 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 470 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 471 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 472 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 473 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 474 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 475 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 476 +GRANT SELECT ON base_tbl TO regress_view_user3 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 477 +GRANT UPDATE (a, c) ON base_tbl TO regress_view_user3 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 478 +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +== 479 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 480 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 481 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 482 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 483 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 484 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 485 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 486 +-- ok + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 487 +REVOKE SELECT, UPDATE ON base_tbl FROM regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 488 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +== 489 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 490 +-- not allowed +UPDATE rw_view1 SET aa=aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 491 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 492 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 493 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 494 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 495 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 496 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 497 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 498 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 499 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 500 +-- ok + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +== 501 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 502 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 503 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 504 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 505 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 506 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 507 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 508 +-- ok + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 509 +REVOKE SELECT, UPDATE ON base_tbl FROM regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 510 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +== 511 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 512 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 513 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 514 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 515 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 516 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 517 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 518 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +== 519 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 520 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 521 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 522 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 523 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 524 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 525 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 526 +-- ok + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 527 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 528 +DROP USER regress_view_user1 +-- +STMT: DropRoleStmt +== 529 +DROP USER regress_view_user2 +-- +STMT: DropRoleStmt +== 530 +DROP USER regress_view_user3 +-- +STMT: DropRoleStmt +== 531 +-- column defaults + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified', c serial) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 532 +INSERT INTO base_tbl VALUES (1, 'Row 1') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 533 +INSERT INTO base_tbl VALUES (2, 'Row 2') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 534 +INSERT INTO base_tbl VALUES (3) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 535 +CREATE VIEW rw_view1 AS SELECT a AS aa, b AS bb FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 536 +ALTER VIEW rw_view1 ALTER COLUMN bb SET DEFAULT 'View default' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +== 537 +INSERT INTO rw_view1 VALUES (4, 'Row 4') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 538 +INSERT INTO rw_view1 (aa) VALUES (5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 539 +MERGE INTO rw_view1 t USING (VALUES (6)) AS v(a) ON t.aa = v.a + WHEN NOT MATCHED THEN INSERT (aa) VALUES (v.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 540 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 541 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 542 +-- Table having triggers + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 543 +INSERT INTO base_tbl VALUES (1, 'Row 1') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 544 +INSERT INTO base_tbl VALUES (2, 'Row 2') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 545 +CREATE FUNCTION rw_view1_trig_fn() +RETURNS trigger AS +$$ +BEGIN + IF TG_OP = 'INSERT' THEN + UPDATE base_tbl SET b=NEW.b WHERE a=1; + RETURN NULL; + END IF; + RETURN NULL; +END; +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 546 +CREATE TRIGGER rw_view1_ins_trig AFTER INSERT ON base_tbl + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateTrigStmt +== 547 +CREATE VIEW rw_view1 AS SELECT a AS aa, b AS bb FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 548 +INSERT INTO rw_view1 VALUES (3, 'Row 3') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 549 +select * from base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 550 +DROP VIEW rw_view1 +-- +STMT: DropStmt +== 551 +DROP TRIGGER rw_view1_ins_trig on base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 552 +DROP FUNCTION rw_view1_trig_fn() +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: DropStmt +== 553 +DROP TABLE base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 554 +-- view with ORDER BY + +CREATE TABLE base_tbl (a int, b int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 555 +INSERT INTO base_tbl VALUES (1,2), (4,5), (3,-3) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 556 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl ORDER BY a+b +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 557 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 558 +INSERT INTO rw_view1 VALUES (7,-8) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 559 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 560 +EXPLAIN (verbose, costs off) UPDATE rw_view1 SET b = b + 1 RETURNING * +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 561 +UPDATE rw_view1 SET b = b + 1 RETURNING * +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 562 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 563 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 564 +-- multiple array-column updates + +CREATE TABLE base_tbl (a int, arr int[]) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 565 +INSERT INTO base_tbl VALUES (1,ARRAY[2]), (3,ARRAY[4]) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 566 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 567 +UPDATE rw_view1 SET arr[1] = 42, arr[2] = 77 WHERE a = 3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 568 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 569 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 570 +-- views with updatable and non-updatable columns + +CREATE TABLE base_tbl(a float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 571 +INSERT INTO base_tbl SELECT i/10.0 FROM generate_series(1,10) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 572 +CREATE VIEW rw_view1 AS + SELECT ctid, sin(a) s, a, cos(a) c + FROM base_tbl + WHERE a != 0 + ORDER BY abs(a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="sin" function="sin" schema="" ctx=Call +FUNCTION: name="cos" function="cos" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 573 +INSERT INTO rw_view1 VALUES (null, null, 1.1, null) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 574 +-- should fail +INSERT INTO rw_view1 (s, c, a) VALUES (null, null, 1.1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 575 +-- should fail +INSERT INTO rw_view1 (s, c, a) VALUES (default, default, 1.1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 576 +-- should fail +INSERT INTO rw_view1 (a) VALUES (1.1) RETURNING a, s, c +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 577 +-- OK +UPDATE rw_view1 SET s = s WHERE a = 1.1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 578 +-- should fail +UPDATE rw_view1 SET a = 1.05 WHERE a = 1.1 RETURNING s +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 579 +-- OK +DELETE FROM rw_view1 WHERE a = 1.05 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 580 +-- OK + +CREATE VIEW rw_view2 AS + SELECT s, c, s/c t, a base_a, ctid + FROM rw_view1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 581 +INSERT INTO rw_view2 VALUES (null, null, null, 1.1, null) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 582 +-- should fail +INSERT INTO rw_view2(s, c, base_a) VALUES (null, null, 1.1) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 583 +-- should fail +INSERT INTO rw_view2(base_a) VALUES (1.1) RETURNING t +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 584 +-- OK +UPDATE rw_view2 SET s = s WHERE base_a = 1.1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 585 +-- should fail +UPDATE rw_view2 SET t = t WHERE base_a = 1.1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 586 +-- should fail +UPDATE rw_view2 SET base_a = 1.05 WHERE base_a = 1.1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 587 +-- OK +DELETE FROM rw_view2 WHERE base_a = 1.05 RETURNING base_a, s, c, t +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 588 +-- OK + +CREATE VIEW rw_view3 AS + SELECT s, c, s/c t, ctid + FROM rw_view1 +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 589 +INSERT INTO rw_view3 VALUES (null, null, null, null) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 590 +-- should fail +INSERT INTO rw_view3(s) VALUES (null) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 591 +-- should fail +UPDATE rw_view3 SET s = s +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: UpdateStmt +== 592 +-- should fail +DELETE FROM rw_view3 WHERE s = sin(0.1) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +FUNCTION: name="sin" function="sin" schema="" ctx=Call +STMT: DeleteStmt +== 593 +-- should be OK +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 594 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 595 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 596 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 597 +SELECT events & 4 != 0 AS upd, + events & 8 != 0 AS ins, + events & 16 != 0 AS del + FROM pg_catalog.pg_relation_is_updatable('rw_view3'::regclass, false) t(events) +-- +FUNCTION: name="pg_catalog.pg_relation_is_updatable" function="pg_relation_is_updatable" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 598 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 599 +-- view on table with GENERATED columns + +CREATE TABLE base_tbl (id int, idplus1 int GENERATED ALWAYS AS (id + 1) STORED) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 600 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 601 +INSERT INTO base_tbl (id) VALUES (1) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 602 +INSERT INTO rw_view1 (id) VALUES (2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 603 +INSERT INTO base_tbl (id, idplus1) VALUES (3, DEFAULT) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 604 +INSERT INTO rw_view1 (id, idplus1) VALUES (4, DEFAULT) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 605 +INSERT INTO base_tbl (id, idplus1) VALUES (5, 6) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 606 +-- error +INSERT INTO rw_view1 (id, idplus1) VALUES (6, 7) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 607 +-- error + +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 608 +UPDATE base_tbl SET id = 2000 WHERE id = 2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +== 609 +UPDATE rw_view1 SET id = 3000 WHERE id = 3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 610 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 611 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 612 +-- inheritance tests + +CREATE TABLE base_tbl_parent (a int) +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=DDL +STMT: CreateStmt +== 613 +CREATE TABLE base_tbl_child (CHECK (a > 0)) INHERITS (base_tbl_parent) +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=DDL +STMT: CreateStmt +== 614 +INSERT INTO base_tbl_parent SELECT * FROM generate_series(-8, -1) +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 615 +INSERT INTO base_tbl_child SELECT * FROM generate_series(1, 8) +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 616 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl_parent +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 617 +CREATE VIEW rw_view2 AS SELECT * FROM ONLY base_tbl_parent +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 618 +SELECT * FROM rw_view1 ORDER BY a +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 619 +SELECT * FROM ONLY rw_view1 ORDER BY a +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 620 +SELECT * FROM rw_view2 ORDER BY a +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +== 621 +INSERT INTO rw_view1 VALUES (-100), (100) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 622 +INSERT INTO rw_view2 VALUES (-200), (200) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 623 +UPDATE rw_view1 SET a = a*10 WHERE a IN (-1, 1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 624 +-- Should produce -10 and 10 +UPDATE ONLY rw_view1 SET a = a*10 WHERE a IN (-2, 2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 625 +-- Should produce -20 and 20 +UPDATE rw_view2 SET a = a*10 WHERE a IN (-3, 3) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 626 +-- Should produce -30 only +UPDATE ONLY rw_view2 SET a = a*10 WHERE a IN (-4, 4) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 627 +-- Should produce -40 only + +DELETE FROM rw_view1 WHERE a IN (-5, 5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 628 +-- Should delete -5 and 5 +DELETE FROM ONLY rw_view1 WHERE a IN (-6, 6) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +== 629 +-- Should delete -6 and 6 +DELETE FROM rw_view2 WHERE a IN (-7, 7) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 630 +-- Should delete -7 only +DELETE FROM ONLY rw_view2 WHERE a IN (-8, 8) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +== 631 +-- Should delete -8 only + +SELECT * FROM ONLY base_tbl_parent ORDER BY a +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: SelectStmt +== 632 +SELECT * FROM base_tbl_child ORDER BY a +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=Select +STMT: SelectStmt +== 633 +MERGE INTO rw_view1 t USING (VALUES (-200), (10)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a+1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 634 +-- Should produce -199 and 11 +MERGE INTO ONLY rw_view1 t USING (VALUES (-100), (20)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a+1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 635 +-- Should produce -99 and 21 +MERGE INTO rw_view2 t USING (VALUES (-40), (3)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a+1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 636 +-- Should produce -39 only +MERGE INTO ONLY rw_view2 t USING (VALUES (-30), (4)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a+1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 637 +-- Should produce -29 only + +SELECT * FROM ONLY base_tbl_parent ORDER BY a +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: SelectStmt +== 638 +SELECT * FROM base_tbl_child ORDER BY a +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=Select +STMT: SelectStmt +== 639 +CREATE TABLE other_tbl_parent (id int) +-- +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=DDL +STMT: CreateStmt +== 640 +CREATE TABLE other_tbl_child () INHERITS (other_tbl_parent) +-- +TABLE: name="other_tbl_child" schema="" table="other_tbl_child" ctx=DDL +STMT: CreateStmt +== 641 +INSERT INTO other_tbl_parent VALUES (7),(200) +-- +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 642 +INSERT INTO other_tbl_child VALUES (8),(100) +-- +TABLE: name="other_tbl_child" schema="" table="other_tbl_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 643 +EXPLAIN (costs off) +UPDATE rw_view1 SET a = a + 1000 FROM other_tbl_parent WHERE a = id +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=Select +STMT: ExplainStmt +STMT: UpdateStmt +== 644 +UPDATE rw_view1 SET a = a + 1000 FROM other_tbl_parent WHERE a = id +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=Select +STMT: UpdateStmt +== 645 +SELECT * FROM ONLY base_tbl_parent ORDER BY a +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: SelectStmt +== 646 +SELECT * FROM base_tbl_child ORDER BY a +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=Select +STMT: SelectStmt +== 647 +DROP TABLE base_tbl_parent, base_tbl_child CASCADE +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=DDL +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=DDL +STMT: DropStmt +== 648 +DROP TABLE other_tbl_parent CASCADE +-- +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=DDL +STMT: DropStmt +== 649 +-- simple WITH CHECK OPTION + +CREATE TABLE base_tbl (a int, b int DEFAULT 10) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 650 +INSERT INTO base_tbl VALUES (1,2), (2,3), (1,-1) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 651 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b + WITH LOCAL CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 652 +SELECT * FROM information_schema.views WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 653 +INSERT INTO rw_view1 VALUES(3,4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 654 +-- ok +INSERT INTO rw_view1 VALUES(4,3) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 655 +-- should fail +INSERT INTO rw_view1 VALUES(5,null) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 656 +-- should fail +UPDATE rw_view1 SET b = 5 WHERE a = 3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 657 +-- ok +UPDATE rw_view1 SET b = -5 WHERE a = 3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 658 +-- should fail +INSERT INTO rw_view1(a) VALUES (9) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 659 +-- ok +INSERT INTO rw_view1(a) VALUES (10) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 660 +-- should fail +SELECT * FROM base_tbl ORDER BY a, b +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 661 +MERGE INTO rw_view1 t USING (VALUES (10)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.a + 1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 662 +-- ok +MERGE INTO rw_view1 t USING (VALUES (11)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.a - 1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 663 +-- should fail +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a - 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 664 +-- ok +MERGE INTO rw_view1 t USING (VALUES (2)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a + 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +== 665 +-- should fail +SELECT * FROM base_tbl ORDER BY a, b +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 666 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 667 +-- WITH LOCAL/CASCADED CHECK OPTION + +CREATE TABLE base_tbl (a int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 668 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a > 0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 669 +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10 + WITH CHECK OPTION +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 670 +-- implicitly cascaded +SELECT * FROM information_schema.views WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 671 +INSERT INTO rw_view2 VALUES (-5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 672 +-- should fail +INSERT INTO rw_view2 VALUES (5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 673 +-- ok +INSERT INTO rw_view2 VALUES (15) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 674 +-- should fail +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 675 +UPDATE rw_view2 SET a = a - 10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 676 +-- should fail +UPDATE rw_view2 SET a = a + 10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 677 +-- should fail + +CREATE OR REPLACE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10 + WITH LOCAL CHECK OPTION +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 678 +SELECT * FROM information_schema.views WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 679 +INSERT INTO rw_view2 VALUES (-10) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 680 +-- ok, but not in view +INSERT INTO rw_view2 VALUES (20) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 681 +-- should fail +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 682 +ALTER VIEW rw_view1 SET (check_option=here) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +== 683 +-- invalid +ALTER VIEW rw_view1 SET (check_option=local) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +== 684 +INSERT INTO rw_view2 VALUES (-20) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 685 +-- should fail +INSERT INTO rw_view2 VALUES (30) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 686 +-- should fail + +ALTER VIEW rw_view2 RESET (check_option) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +STMT: AlterTableStmt +== 687 +SELECT * FROM information_schema.views WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 688 +INSERT INTO rw_view2 VALUES (30) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 689 +-- ok, but not in view +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 690 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 691 +-- WITH CHECK OPTION with no local view qual + +CREATE TABLE base_tbl (a int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 692 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WITH CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 693 +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > 0 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 694 +CREATE VIEW rw_view3 AS SELECT * FROM rw_view2 WITH CHECK OPTION +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DDL +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 695 +SELECT * FROM information_schema.views WHERE table_name LIKE E'rw\\_view_' ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 696 +INSERT INTO rw_view1 VALUES (-1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 697 +-- ok +INSERT INTO rw_view1 VALUES (1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 698 +-- ok +INSERT INTO rw_view2 VALUES (-2) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 699 +-- ok, but not in view +INSERT INTO rw_view2 VALUES (2) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 700 +-- ok +INSERT INTO rw_view3 VALUES (-3) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 701 +-- should fail +INSERT INTO rw_view3 VALUES (3) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 702 +-- ok + +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 703 +-- WITH CHECK OPTION with scalar array ops + +CREATE TABLE base_tbl (a int, b int[]) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 704 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a = ANY (b) + WITH CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 705 +INSERT INTO rw_view1 VALUES (1, ARRAY[1,2,3]) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 706 +-- ok +INSERT INTO rw_view1 VALUES (10, ARRAY[4,5]) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 707 +-- should fail + +UPDATE rw_view1 SET b[2] = -b[2] WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 708 +-- ok +UPDATE rw_view1 SET b[1] = -b[1] WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 709 +-- should fail + +PREPARE ins(int, int[]) AS INSERT INTO rw_view1 VALUES($1, $2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: PrepareStmt +STMT: InsertStmt +STMT: SelectStmt +== 710 +EXECUTE ins(2, ARRAY[1,2,3]) +-- +STMT: ExecuteStmt +== 711 +-- ok +EXECUTE ins(10, ARRAY[4,5]) +-- +STMT: ExecuteStmt +== 712 +-- should fail +DEALLOCATE PREPARE ins +-- +STMT: DeallocateStmt +== 713 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 714 +-- WITH CHECK OPTION with subquery + +CREATE TABLE base_tbl (a int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 715 +CREATE TABLE ref_tbl (a int PRIMARY KEY) +-- +TABLE: name="ref_tbl" schema="" table="ref_tbl" ctx=DDL +STMT: CreateStmt +== 716 +INSERT INTO ref_tbl SELECT * FROM generate_series(1,10) +-- +TABLE: name="ref_tbl" schema="" table="ref_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 717 +CREATE VIEW rw_view1 AS + SELECT * FROM base_tbl b + WHERE EXISTS(SELECT 1 FROM ref_tbl r WHERE r.a = b.a) + WITH CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +TABLE: name="ref_tbl" schema="" table="ref_tbl" ctx=Select +ALIAS: "b"="base_tbl" +ALIAS: "r"="ref_tbl" +FILTER: schema="" table="r" column="a" +FILTER: schema="" table="b" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 718 +INSERT INTO rw_view1 VALUES (5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 719 +-- ok +INSERT INTO rw_view1 VALUES (15) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 720 +-- should fail + +UPDATE rw_view1 SET a = a + 5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 721 +-- ok +UPDATE rw_view1 SET a = a + 5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 722 +-- should fail + +EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 723 +EXPLAIN (costs off) UPDATE rw_view1 SET a = a + 5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 724 +DROP TABLE base_tbl, ref_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +TABLE: name="ref_tbl" schema="" table="ref_tbl" ctx=DDL +STMT: DropStmt +== 725 +-- WITH CHECK OPTION with BEFORE trigger on base table + +CREATE TABLE base_tbl (a int, b int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 726 +CREATE FUNCTION base_tbl_trig_fn() +RETURNS trigger AS +$$ +BEGIN + NEW.b := 10; + RETURN NEW; +END; +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="base_tbl_trig_fn" function="base_tbl_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 727 +CREATE TRIGGER base_tbl_trig BEFORE INSERT OR UPDATE ON base_tbl + FOR EACH ROW EXECUTE PROCEDURE base_tbl_trig_fn() +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateTrigStmt +== 728 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b WITH CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 729 +INSERT INTO rw_view1 VALUES (5,0) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 730 +-- ok +INSERT INTO rw_view1 VALUES (15, 20) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 731 +-- should fail +UPDATE rw_view1 SET a = 20, b = 30 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +== 732 +-- should fail + +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 733 +DROP FUNCTION base_tbl_trig_fn() +-- +FUNCTION: name="base_tbl_trig_fn" function="base_tbl_trig_fn" schema="" ctx=DDL +STMT: DropStmt +== 734 +-- WITH LOCAL CHECK OPTION with INSTEAD OF trigger on base view + +CREATE TABLE base_tbl (a int, b int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 735 +CREATE VIEW rw_view1 AS SELECT a FROM base_tbl WHERE a < b +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 736 +CREATE FUNCTION rw_view1_trig_fn() +RETURNS trigger AS +$$ +BEGIN + IF TG_OP = 'INSERT' THEN + INSERT INTO base_tbl VALUES (NEW.a, 10); + RETURN NEW; + ELSIF TG_OP = 'UPDATE' THEN + UPDATE base_tbl SET a=NEW.a WHERE a=OLD.a; + RETURN NEW; + ELSIF TG_OP = 'DELETE' THEN + DELETE FROM base_tbl WHERE a=OLD.a; + RETURN OLD; + END IF; +END; +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 737 +CREATE TRIGGER rw_view1_trig + INSTEAD OF INSERT OR UPDATE OR DELETE ON rw_view1 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: CreateTrigStmt +== 738 +CREATE VIEW rw_view2 AS + SELECT * FROM rw_view1 WHERE a > 0 WITH LOCAL CHECK OPTION +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 739 +INSERT INTO rw_view2 VALUES (-5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 740 +-- should fail +MERGE INTO rw_view2 t USING (VALUES (-5)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 741 +-- should fail +INSERT INTO rw_view2 VALUES (5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 742 +-- ok +MERGE INTO rw_view2 t USING (VALUES (6)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 743 +-- ok +INSERT INTO rw_view2 VALUES (50) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 744 +-- ok, but not in view +MERGE INTO rw_view2 t USING (VALUES (60)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 745 +-- ok, but not in view +UPDATE rw_view2 SET a = a - 10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 746 +-- should fail +MERGE INTO rw_view2 t USING (VALUES (6)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a - 10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +== 747 +-- should fail +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 748 +-- Check option won't cascade down to base view with INSTEAD OF triggers + +ALTER VIEW rw_view2 SET (check_option=cascaded) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +STMT: AlterTableStmt +== 749 +INSERT INTO rw_view2 VALUES (100) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 750 +-- ok, but not in view (doesn't fail rw_view1's check) +UPDATE rw_view2 SET a = 200 WHERE a = 5 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 751 +-- ok, but not in view (doesn't fail rw_view1's check) +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 752 +-- Neither local nor cascaded check options work with INSTEAD rules + +DROP TRIGGER rw_view1_trig ON rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: DropStmt +== 753 +CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 + DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a, 10) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +== 754 +CREATE RULE rw_view1_upd_rule AS ON UPDATE TO rw_view1 + DO INSTEAD UPDATE base_tbl SET a=NEW.a WHERE a=OLD.a +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +== 755 +INSERT INTO rw_view2 VALUES (-10) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 756 +-- ok, but not in view (doesn't fail rw_view2's check) +INSERT INTO rw_view2 VALUES (5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 757 +-- ok +INSERT INTO rw_view2 VALUES (20) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 758 +-- ok, but not in view (doesn't fail rw_view1's check) +UPDATE rw_view2 SET a = 30 WHERE a = 5 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 759 +-- ok, but not in view (doesn't fail rw_view1's check) +INSERT INTO rw_view2 VALUES (5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 760 +-- ok +UPDATE rw_view2 SET a = -5 WHERE a = 5 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +== 761 +-- ok, but not in view (doesn't fail rw_view2's check) +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 762 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 763 +DROP FUNCTION rw_view1_trig_fn() +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: DropStmt +== 764 +CREATE TABLE base_tbl (a int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 765 +CREATE VIEW rw_view1 AS SELECT a,10 AS b FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 766 +CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 + DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +== 767 +CREATE VIEW rw_view2 AS + SELECT * FROM rw_view1 WHERE a > b WITH LOCAL CHECK OPTION +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +== 768 +INSERT INTO rw_view2 VALUES (2,3) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 769 +-- ok, but not in view (doesn't fail rw_view2's check) +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 770 +-- security barrier view + +CREATE TABLE base_tbl (person text, visibility text) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 771 +INSERT INTO base_tbl VALUES ('Tom', 'public'), + ('Dick', 'private'), + ('Harry', 'public') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 772 +CREATE VIEW rw_view1 AS + SELECT person FROM base_tbl WHERE visibility = 'public' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="visibility" +STMT: ViewStmt +STMT: SelectStmt +== 773 +CREATE FUNCTION snoop(anyelement) +RETURNS boolean AS +$$ +BEGIN + RAISE NOTICE 'snooped value: %', $1; + RETURN true; +END; +$$ +LANGUAGE plpgsql COST 0.000001 +-- +FUNCTION: name="snoop" function="snoop" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 774 +CREATE OR REPLACE FUNCTION leakproof(anyelement) +RETURNS boolean AS +$$ +BEGIN + RETURN true; +END; +$$ +LANGUAGE plpgsql STRICT IMMUTABLE LEAKPROOF +-- +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 775 +SELECT * FROM rw_view1 WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: SelectStmt +== 776 +UPDATE rw_view1 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: UpdateStmt +== 777 +DELETE FROM rw_view1 WHERE NOT snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: DeleteStmt +== 778 +ALTER VIEW rw_view1 SET (security_barrier = true) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +== 779 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 780 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 781 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name = 'rw_view1' + ORDER BY ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 782 +SELECT * FROM rw_view1 WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: SelectStmt +== 783 +UPDATE rw_view1 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: UpdateStmt +== 784 +DELETE FROM rw_view1 WHERE NOT snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: DeleteStmt +== 785 +MERGE INTO rw_view1 t + USING (VALUES ('Tom'), ('Dick'), ('Harry')) AS v(person) ON t.person = v.person + WHEN MATCHED AND snoop(t.person) THEN UPDATE SET person = v.person +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 786 +EXPLAIN (costs off) SELECT * FROM rw_view1 WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: ExplainStmt +STMT: SelectStmt +== 787 +EXPLAIN (costs off) UPDATE rw_view1 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 788 +EXPLAIN (costs off) DELETE FROM rw_view1 WHERE NOT snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +== 789 +EXPLAIN (costs off) +MERGE INTO rw_view1 t + USING (VALUES ('Tom'), ('Dick'), ('Harry')) AS v(person) ON t.person = v.person + WHEN MATCHED AND snoop(t.person) THEN UPDATE SET person = v.person +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 790 +-- security barrier view on top of security barrier view + +CREATE VIEW rw_view2 WITH (security_barrier = true) AS + SELECT * FROM rw_view1 WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: ViewStmt +STMT: SelectStmt +== 791 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 792 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 793 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name = 'rw_view2' + ORDER BY ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 794 +SELECT * FROM rw_view2 WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: SelectStmt +== 795 +UPDATE rw_view2 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: UpdateStmt +== 796 +DELETE FROM rw_view2 WHERE NOT snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: DeleteStmt +== 797 +MERGE INTO rw_view2 t + USING (VALUES ('Tom'), ('Dick'), ('Harry')) AS v(person) ON t.person = v.person + WHEN MATCHED AND snoop(t.person) THEN UPDATE SET person = v.person +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +== 798 +EXPLAIN (costs off) SELECT * FROM rw_view2 WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: ExplainStmt +STMT: SelectStmt +== 799 +EXPLAIN (costs off) UPDATE rw_view2 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 800 +EXPLAIN (costs off) DELETE FROM rw_view2 WHERE NOT snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +== 801 +EXPLAIN (costs off) +MERGE INTO rw_view2 t + USING (VALUES ('Tom'), ('Dick'), ('Harry')) AS v(person) ON t.person = v.person + WHEN MATCHED AND snoop(t.person) THEN UPDATE SET person = v.person +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 802 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 803 +-- security barrier view on top of table with rules + +CREATE TABLE base_tbl(id int PRIMARY KEY, data text, deleted boolean) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 804 +INSERT INTO base_tbl VALUES (1, 'Row 1', false), (2, 'Row 2', true) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 805 +CREATE RULE base_tbl_ins_rule AS ON INSERT TO base_tbl + WHERE EXISTS (SELECT 1 FROM base_tbl t WHERE t.id = new.id) + DO INSTEAD + UPDATE base_tbl SET data = new.data, deleted = false WHERE id = new.id +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: RuleStmt +== 806 +CREATE RULE base_tbl_del_rule AS ON DELETE TO base_tbl + DO INSTEAD + UPDATE base_tbl SET deleted = true WHERE id = old.id +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: RuleStmt +== 807 +CREATE VIEW rw_view1 WITH (security_barrier=true) AS + SELECT id, data FROM base_tbl WHERE NOT deleted +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="deleted" +STMT: ViewStmt +STMT: SelectStmt +== 808 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +== 809 +EXPLAIN (costs off) DELETE FROM rw_view1 WHERE id = 1 AND snoop(data) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +== 810 +DELETE FROM rw_view1 WHERE id = 1 AND snoop(data) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: DeleteStmt +== 811 +EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (2, 'New row 2') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 812 +INSERT INTO rw_view1 VALUES (2, 'New row 2') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 813 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 814 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 815 +-- security barrier view based on inheritance set +CREATE TABLE t1 (a int, b float, c text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 816 +CREATE INDEX t1_a_idx ON t1(a) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: IndexStmt +== 817 +INSERT INTO t1 +SELECT i,i,'t1' FROM generate_series(1,10) g(i) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 818 +ANALYZE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: VacuumStmt +== 819 +CREATE TABLE t11 (d text) INHERITS (t1) +-- +TABLE: name="t11" schema="" table="t11" ctx=DDL +STMT: CreateStmt +== 820 +CREATE INDEX t11_a_idx ON t11(a) +-- +TABLE: name="t11" schema="" table="t11" ctx=DDL +STMT: IndexStmt +== 821 +INSERT INTO t11 +SELECT i,i,'t11','t11d' FROM generate_series(1,10) g(i) +-- +TABLE: name="t11" schema="" table="t11" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 822 +ANALYZE t11 +-- +TABLE: name="t11" schema="" table="t11" ctx=DDL +STMT: VacuumStmt +== 823 +CREATE TABLE t12 (e int[]) INHERITS (t1) +-- +TABLE: name="t12" schema="" table="t12" ctx=DDL +STMT: CreateStmt +== 824 +CREATE INDEX t12_a_idx ON t12(a) +-- +TABLE: name="t12" schema="" table="t12" ctx=DDL +STMT: IndexStmt +== 825 +INSERT INTO t12 +SELECT i,i,'t12','{1,2}'::int[] FROM generate_series(1,10) g(i) +-- +TABLE: name="t12" schema="" table="t12" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 826 +ANALYZE t12 +-- +TABLE: name="t12" schema="" table="t12" ctx=DDL +STMT: VacuumStmt +== 827 +CREATE TABLE t111 () INHERITS (t11, t12) +-- +TABLE: name="t111" schema="" table="t111" ctx=DDL +STMT: CreateStmt +== 828 +CREATE INDEX t111_a_idx ON t111(a) +-- +TABLE: name="t111" schema="" table="t111" ctx=DDL +STMT: IndexStmt +== 829 +INSERT INTO t111 +SELECT i,i,'t111','t111d','{1,1,1}'::int[] FROM generate_series(1,10) g(i) +-- +TABLE: name="t111" schema="" table="t111" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 830 +ANALYZE t111 +-- +TABLE: name="t111" schema="" table="t111" ctx=DDL +STMT: VacuumStmt +== 831 +CREATE VIEW v1 WITH (security_barrier=true) AS +SELECT *, (SELECT d FROM t11 WHERE t11.a = t1.a LIMIT 1) AS d +FROM t1 +WHERE a > 5 AND EXISTS(SELECT 1 FROM t12 WHERE t12.a = t1.a) +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t11" schema="" table="t11" ctx=Select +TABLE: name="t12" schema="" table="t12" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="t11" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t12" column="a" +FILTER: schema="" table="t1" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 832 +SELECT * FROM v1 WHERE a=3 +-- +TABLE: name="v1" schema="" table="v1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 833 +-- should not see anything +SELECT * FROM v1 WHERE a=8 +-- +TABLE: name="v1" schema="" table="v1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 834 +EXPLAIN (VERBOSE, COSTS OFF) +UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND a != 6 +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 835 +UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND a != 6 +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: UpdateStmt +== 836 +SELECT * FROM v1 WHERE a=100 +-- +TABLE: name="v1" schema="" table="v1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 837 +-- Nothing should have been changed to 100 +SELECT * FROM t1 WHERE a=100 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 838 +-- Nothing should have been changed to 100 + +EXPLAIN (VERBOSE, COSTS OFF) +UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8 +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +== 839 +UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8 +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: UpdateStmt +== 840 +SELECT * FROM v1 WHERE b=8 +-- +TABLE: name="v1" schema="" table="v1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +== 841 +DELETE FROM v1 WHERE snoop(a) AND leakproof(a) +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: DeleteStmt +== 842 +-- should not delete everything, just where a>5 + +TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +== 843 +-- verify all a<=5 are intact + +DROP TABLE t1, t11, t12, t111 CASCADE +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +TABLE: name="t11" schema="" table="t11" ctx=DDL +TABLE: name="t12" schema="" table="t12" ctx=DDL +TABLE: name="t111" schema="" table="t111" ctx=DDL +STMT: DropStmt +== 844 +DROP FUNCTION snoop(anyelement) +-- +FUNCTION: name="snoop" function="snoop" schema="" ctx=DDL +STMT: DropStmt +== 845 +DROP FUNCTION leakproof(anyelement) +-- +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=DDL +STMT: DropStmt +== 846 +CREATE TABLE tx1 (a integer) +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: CreateStmt +== 847 +CREATE TABLE tx2 (b integer) +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: CreateStmt +== 848 +CREATE TABLE tx3 (c integer) +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: CreateStmt +== 849 +CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS(SELECT 1 FROM tx2 JOIN tx3 ON b=c) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=Select +TABLE: name="tx2" schema="" table="tx2" ctx=Select +TABLE: name="tx3" schema="" table="tx3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 850 +INSERT INTO vx1 values (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 851 +SELECT * FROM tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=Select +STMT: SelectStmt +== 852 +SELECT * FROM vx1 +-- +TABLE: name="vx1" schema="" table="vx1" ctx=Select +STMT: SelectStmt +== 853 +DROP VIEW vx1 +-- +STMT: DropStmt +== 854 +DROP TABLE tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: DropStmt +== 855 +DROP TABLE tx2 +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: DropStmt +== 856 +DROP TABLE tx3 +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: DropStmt +== 857 +CREATE TABLE tx1 (a integer) +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: CreateStmt +== 858 +CREATE TABLE tx2 (b integer) +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: CreateStmt +== 859 +CREATE TABLE tx3 (c integer) +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: CreateStmt +== 860 +CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS(SELECT 1 FROM tx2 JOIN tx3 ON b=c) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=Select +TABLE: name="tx2" schema="" table="tx2" ctx=Select +TABLE: name="tx3" schema="" table="tx3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 861 +INSERT INTO vx1 VALUES (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 862 +INSERT INTO vx1 VALUES (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 863 +SELECT * FROM tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=Select +STMT: SelectStmt +== 864 +SELECT * FROM vx1 +-- +TABLE: name="vx1" schema="" table="vx1" ctx=Select +STMT: SelectStmt +== 865 +DROP VIEW vx1 +-- +STMT: DropStmt +== 866 +DROP TABLE tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: DropStmt +== 867 +DROP TABLE tx2 +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: DropStmt +== 868 +DROP TABLE tx3 +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: DropStmt +== 869 +CREATE TABLE tx1 (a integer, b integer) +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: CreateStmt +== 870 +CREATE TABLE tx2 (b integer, c integer) +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: CreateStmt +== 871 +CREATE TABLE tx3 (c integer, d integer) +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: CreateStmt +== 872 +ALTER TABLE tx1 DROP COLUMN b +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: AlterTableStmt +== 873 +ALTER TABLE tx2 DROP COLUMN c +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: AlterTableStmt +== 874 +ALTER TABLE tx3 DROP COLUMN d +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: AlterTableStmt +== 875 +CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS(SELECT 1 FROM tx2 JOIN tx3 ON b=c) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=Select +TABLE: name="tx2" schema="" table="tx2" ctx=Select +TABLE: name="tx3" schema="" table="tx3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 876 +INSERT INTO vx1 VALUES (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 877 +INSERT INTO vx1 VALUES (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 878 +SELECT * FROM tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=Select +STMT: SelectStmt +== 879 +SELECT * FROM vx1 +-- +TABLE: name="vx1" schema="" table="vx1" ctx=Select +STMT: SelectStmt +== 880 +DROP VIEW vx1 +-- +STMT: DropStmt +== 881 +DROP TABLE tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: DropStmt +== 882 +DROP TABLE tx2 +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: DropStmt +== 883 +DROP TABLE tx3 +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: DropStmt +== 884 +|-- +-- Test handling of vars from correlated subqueries in quals from outer +-- security barrier views, per bug #13988 +|-- +CREATE TABLE t1 (a int, b text, c int) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 885 +INSERT INTO t1 VALUES (1, 'one', 10) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 886 +CREATE TABLE t2 (cc int) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +== 887 +INSERT INTO t2 VALUES (10), (20) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 888 +CREATE VIEW v1 WITH (security_barrier = true) AS + SELECT * FROM t1 WHERE (a > 0) + WITH CHECK OPTION +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 889 +CREATE VIEW v2 WITH (security_barrier = true) AS + SELECT * FROM v1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.cc = v1.c) + WITH CHECK OPTION +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="v1" schema="" table="v1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +FILTER: schema="" table="t2" column="cc" +FILTER: schema="" table="v1" column="c" +STMT: ViewStmt +STMT: SelectStmt +== 890 +INSERT INTO v2 VALUES (2, 'two', 20) +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 891 +-- ok +INSERT INTO v2 VALUES (-2, 'minus two', 20) +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 892 +-- not allowed +INSERT INTO v2 VALUES (3, 'three', 30) +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 893 +-- not allowed + +UPDATE v2 SET b = 'ONE' WHERE a = 1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: UpdateStmt +== 894 +-- ok +UPDATE v2 SET a = -1 WHERE a = 1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: UpdateStmt +== 895 +-- not allowed +UPDATE v2 SET c = 30 WHERE a = 1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: UpdateStmt +== 896 +-- not allowed + +DELETE FROM v2 WHERE a = 2 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: DeleteStmt +== 897 +-- ok +SELECT * FROM v2 +-- +TABLE: name="v2" schema="" table="v2" ctx=Select +STMT: SelectStmt +== 898 +DROP VIEW v2 +-- +STMT: DropStmt +== 899 +DROP VIEW v1 +-- +STMT: DropStmt +== 900 +DROP TABLE t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +== 901 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 902 +|-- +-- Test sub-select in nested security barrier views, per bug #17972 +|-- +CREATE TABLE t1 (a int) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 903 +CREATE VIEW v1 WITH (security_barrier = true) AS + SELECT * FROM t1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 904 +CREATE RULE v1_upd_rule AS ON UPDATE TO v1 DO INSTEAD + UPDATE t1 SET a = NEW.a WHERE a = OLD.a +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: RuleStmt +== 905 +CREATE VIEW v2 WITH (security_barrier = true) AS + SELECT * FROM v1 WHERE EXISTS (SELECT 1) +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="v1" schema="" table="v1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 906 +EXPLAIN (COSTS OFF) UPDATE v2 SET a = 1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 907 +DROP VIEW v2 +-- +STMT: DropStmt +== 908 +DROP VIEW v1 +-- +STMT: DropStmt +== 909 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 910 +|-- +-- Test CREATE OR REPLACE VIEW turning a non-updatable view into an +-- auto-updatable view and adding check options in a single step +|-- +CREATE TABLE t1 (a int, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 911 +CREATE VIEW v1 AS SELECT null::int AS a +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 912 +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1 WHERE a > 0 WITH CHECK OPTION +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 913 +INSERT INTO v1 VALUES (1, 'ok') +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 914 +-- ok +INSERT INTO v1 VALUES (-1, 'invalid') +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 915 +-- should fail + +DROP VIEW v1 +-- +STMT: DropStmt +== 916 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +== 917 +-- check that an auto-updatable view on a partitioned table works correctly +create table uv_pt (a int, b int, v varchar) partition by range (a, b) +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=DDL +STMT: CreateStmt +== 918 +create table uv_pt1 (b int not null, v varchar, a int not null) partition by range (b) +-- +TABLE: name="uv_pt1" schema="" table="uv_pt1" ctx=DDL +STMT: CreateStmt +== 919 +create table uv_pt11 (like uv_pt1) +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: CreateStmt +== 920 +alter table uv_pt11 drop a +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: AlterTableStmt +== 921 +alter table uv_pt11 add a int +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: AlterTableStmt +== 922 +alter table uv_pt11 drop a +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: AlterTableStmt +== 923 +alter table uv_pt11 add a int not null +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: AlterTableStmt +== 924 +alter table uv_pt1 attach partition uv_pt11 for values from (2) to (5) +-- +TABLE: name="uv_pt1" schema="" table="uv_pt1" ctx=DDL +STMT: AlterTableStmt +== 925 +alter table uv_pt attach partition uv_pt1 for values from (1, 2) to (1, 10) +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=DDL +STMT: AlterTableStmt +== 926 +create view uv_ptv as select * from uv_pt +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DDL +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 927 +select events & 4 != 0 AS upd, + events & 8 != 0 AS ins, + events & 16 != 0 AS del + from pg_catalog.pg_relation_is_updatable('uv_pt'::regclass, false) t(events) +-- +FUNCTION: name="pg_catalog.pg_relation_is_updatable" function="pg_relation_is_updatable" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 928 +select pg_catalog.pg_column_is_updatable('uv_pt'::regclass, 1::smallint, false) +-- +FUNCTION: name="pg_catalog.pg_column_is_updatable" function="pg_column_is_updatable" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 929 +select pg_catalog.pg_column_is_updatable('uv_pt'::regclass, 2::smallint, false) +-- +FUNCTION: name="pg_catalog.pg_column_is_updatable" function="pg_column_is_updatable" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 930 +select table_name, is_updatable, is_insertable_into + from information_schema.views where table_name = 'uv_ptv' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 931 +select table_name, column_name, is_updatable + from information_schema.columns where table_name = 'uv_ptv' order by column_name +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 932 +insert into uv_ptv values (1, 2) +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 933 +select tableoid::regclass, * from uv_pt +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=Select +STMT: SelectStmt +== 934 +create view uv_ptv_wco as select * from uv_pt where a = 0 with check option +-- +TABLE: name="uv_ptv_wco" schema="" table="uv_ptv_wco" ctx=DDL +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 935 +insert into uv_ptv_wco values (1, 2) +-- +TABLE: name="uv_ptv_wco" schema="" table="uv_ptv_wco" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 936 +merge into uv_ptv t + using (values (1,2), (1,4)) as v(a,b) on t.a = v.a -- fail: matches 2 src rows + when matched then update set b = t.b + 1 + when not matched then insert values (v.a, v.b + 1) +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DML +ALIAS: "t"="uv_ptv" +STMT: MergeStmt +STMT: SelectStmt +== 937 +merge into uv_ptv t + using (values (1,2), (1,4)) as v(a,b) on t.a = v.a and t.b = v.b + when matched then update set b = t.b + 1 + when not matched then insert values (v.a, v.b + 1) +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DML +ALIAS: "t"="uv_ptv" +STMT: MergeStmt +STMT: SelectStmt +== 938 +-- fail: no partition for b=5 +merge into uv_ptv t + using (values (1,2), (1,3)) as v(a,b) on t.a = v.a and t.b = v.b + when matched then update set b = t.b + 1 + when not matched then insert values (v.a, v.b + 1) +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DML +ALIAS: "t"="uv_ptv" +STMT: MergeStmt +STMT: SelectStmt +== 939 +-- ok +select tableoid::regclass, * from uv_pt order by a, b +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=Select +STMT: SelectStmt +== 940 +drop view uv_ptv, uv_ptv_wco +-- +STMT: DropStmt +== 941 +drop table uv_pt, uv_pt1, uv_pt11 +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=DDL +TABLE: name="uv_pt1" schema="" table="uv_pt1" ctx=DDL +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: DropStmt +== 942 +-- check that wholerow vars appearing in WITH CHECK OPTION constraint expressions +-- work fine with partitioned tables +create table wcowrtest (a int) partition by list (a) +-- +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=DDL +STMT: CreateStmt +== 943 +create table wcowrtest1 partition of wcowrtest for values in (1) +-- +TABLE: name="wcowrtest1" schema="" table="wcowrtest1" ctx=DDL +STMT: CreateStmt +== 944 +create view wcowrtest_v as select * from wcowrtest where wcowrtest = '(2)'::wcowrtest with check option +-- +TABLE: name="wcowrtest_v" schema="" table="wcowrtest_v" ctx=DDL +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=Select +FILTER: schema="" table="" column="wcowrtest" +STMT: ViewStmt +STMT: SelectStmt +== 945 +insert into wcowrtest_v values (1) +-- +TABLE: name="wcowrtest_v" schema="" table="wcowrtest_v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 946 +alter table wcowrtest add b text +-- +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=DDL +STMT: AlterTableStmt +== 947 +create table wcowrtest2 (b text, c int, a int) +-- +TABLE: name="wcowrtest2" schema="" table="wcowrtest2" ctx=DDL +STMT: CreateStmt +== 948 +alter table wcowrtest2 drop c +-- +TABLE: name="wcowrtest2" schema="" table="wcowrtest2" ctx=DDL +STMT: AlterTableStmt +== 949 +alter table wcowrtest attach partition wcowrtest2 for values in (2) +-- +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=DDL +STMT: AlterTableStmt +== 950 +create table sometable (a int, b text) +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DDL +STMT: CreateStmt +== 951 +insert into sometable values (1, 'a'), (2, 'b') +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 952 +create view wcowrtest_v2 as + select * + from wcowrtest r + where r in (select s from sometable s where r.a = s.a) +with check option +-- +TABLE: name="wcowrtest_v2" schema="" table="wcowrtest_v2" ctx=DDL +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=Select +TABLE: name="sometable" schema="" table="sometable" ctx=Select +ALIAS: "r"="wcowrtest" +ALIAS: "s"="sometable" +FILTER: schema="" table="" column="r" +FILTER: schema="" table="r" column="a" +FILTER: schema="" table="s" column="a" +STMT: ViewStmt +STMT: SelectStmt +== 953 +-- WITH CHECK qual will be processed with wcowrtest2's +-- rowtype after tuple-routing +insert into wcowrtest_v2 values (2, 'no such row in sometable') +-- +TABLE: name="wcowrtest_v2" schema="" table="wcowrtest_v2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 954 +drop view wcowrtest_v, wcowrtest_v2 +-- +STMT: DropStmt +== 955 +drop table wcowrtest, sometable +-- +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=DDL +TABLE: name="sometable" schema="" table="sometable" ctx=DDL +STMT: DropStmt +== 956 +-- Check INSERT .. ON CONFLICT DO UPDATE works correctly when the view's +-- columns are named and ordered differently than the underlying table's. +create table uv_iocu_tab (a text unique, b float) +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: CreateStmt +== 957 +insert into uv_iocu_tab values ('xyxyxy', 0) +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 958 +create view uv_iocu_view as + select b, b+1 as c, a, '2.0'::text as two from uv_iocu_tab +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DDL +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 959 +insert into uv_iocu_view (a, b) values ('xyxyxy', 1) + on conflict (a) do update set b = uv_iocu_view.b +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 960 +select * from uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: SelectStmt +== 961 +insert into uv_iocu_view (a, b) values ('xyxyxy', 1) + on conflict (a) do update set b = excluded.b +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 962 +select * from uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: SelectStmt +== 963 +-- OK to access view columns that are not present in underlying base +-- relation in the ON CONFLICT portion of the query +insert into uv_iocu_view (a, b) values ('xyxyxy', 3) + on conflict (a) do update set b = cast(excluded.two as float) +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 964 +select * from uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: SelectStmt +== 965 +explain (costs off) +insert into uv_iocu_view (a, b) values ('xyxyxy', 3) + on conflict (a) do update set b = excluded.b where excluded.c > 0 +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 966 +insert into uv_iocu_view (a, b) values ('xyxyxy', 3) + on conflict (a) do update set b = excluded.b where excluded.c > 0 +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 967 +select * from uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: SelectStmt +== 968 +drop view uv_iocu_view +-- +STMT: DropStmt +== 969 +drop table uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: DropStmt +== 970 +-- Test whole-row references to the view +create table uv_iocu_tab (a int unique, b text) +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: CreateStmt +== 971 +create view uv_iocu_view as + select b as bb, a as aa, uv_iocu_tab::text as cc from uv_iocu_tab +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DDL +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 972 +insert into uv_iocu_view (aa,bb) values (1,'x') +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 973 +explain (costs off) +insert into uv_iocu_view (aa,bb) values (1,'y') + on conflict (aa) do update set bb = 'Rejected: '||excluded.* + where excluded.aa > 0 + and excluded.bb != '' + and excluded.cc is not null +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +== 974 +insert into uv_iocu_view (aa,bb) values (1,'y') + on conflict (aa) do update set bb = 'Rejected: '||excluded.* + where excluded.aa > 0 + and excluded.bb != '' + and excluded.cc is not null +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 975 +select * from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=Select +STMT: SelectStmt +== 976 +-- Test omitting a column of the base relation +delete from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: DeleteStmt +== 977 +insert into uv_iocu_view (aa,bb) values (1,'x') +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 978 +insert into uv_iocu_view (aa) values (1) + on conflict (aa) do update set bb = 'Rejected: '||excluded.* +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 979 +select * from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=Select +STMT: SelectStmt +== 980 +alter table uv_iocu_tab alter column b set default 'table default' +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: AlterTableStmt +== 981 +insert into uv_iocu_view (aa) values (1) + on conflict (aa) do update set bb = 'Rejected: '||excluded.* +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 982 +select * from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=Select +STMT: SelectStmt +== 983 +alter view uv_iocu_view alter column bb set default 'view default' +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DDL +STMT: AlterTableStmt +== 984 +insert into uv_iocu_view (aa) values (1) + on conflict (aa) do update set bb = 'Rejected: '||excluded.* +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 985 +select * from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=Select +STMT: SelectStmt +== 986 +-- Should fail to update non-updatable columns +insert into uv_iocu_view (aa) values (1) + on conflict (aa) do update set cc = 'XXX' +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 987 +drop view uv_iocu_view +-- +STMT: DropStmt +== 988 +drop table uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: DropStmt +== 989 +-- ON CONFLICT DO UPDATE permissions checks +create user regress_view_user1 +-- +STMT: CreateRoleStmt +== 990 +create user regress_view_user2 +-- +STMT: CreateRoleStmt +== 991 +set session authorization regress_view_user1 +-- +STMT: VariableSetStmt +== 992 +create table base_tbl(a int unique, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +== 993 +insert into base_tbl values (1,'xxx',1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 994 +create view rw_view1 as select b as bb, c as cc, a as aa from base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 995 +grant select (aa,bb) on rw_view1 to regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 996 +grant insert on rw_view1 to regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 997 +grant update (bb) on rw_view1 to regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +== 998 +set session authorization regress_view_user2 +-- +STMT: VariableSetStmt +== 999 +insert into rw_view1 values ('yyy',2.0,1) + on conflict (aa) do update set bb = excluded.cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1000 +-- Not allowed +insert into rw_view1 values ('yyy',2.0,1) + on conflict (aa) do update set bb = rw_view1.cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1001 +-- Not allowed +insert into rw_view1 values ('yyy',2.0,1) + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1002 +-- OK +insert into rw_view1 values ('zzz',2.0,1) + on conflict (aa) do update set bb = rw_view1.bb||'xxx' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1003 +-- OK +insert into rw_view1 values ('zzz',2.0,1) + on conflict (aa) do update set cc = 3.0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1004 +-- Not allowed +reset session authorization +-- +STMT: VariableSetStmt +== 1005 +select * from base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 1006 +set session authorization regress_view_user1 +-- +STMT: VariableSetStmt +== 1007 +grant select (a,b) on base_tbl to regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 1008 +grant insert (a,b) on base_tbl to regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 1009 +grant update (a,b) on base_tbl to regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +== 1010 +set session authorization regress_view_user2 +-- +STMT: VariableSetStmt +== 1011 +create view rw_view2 as select b as bb, c as cc, a as aa from base_tbl +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 1012 +insert into rw_view2 (aa,bb) values (1,'xxx') + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1013 +-- Not allowed +create view rw_view3 as select b as bb, a as aa from base_tbl +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 1014 +insert into rw_view3 (aa,bb) values (1,'xxx') + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1015 +-- OK +reset session authorization +-- +STMT: VariableSetStmt +== 1016 +select * from base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 1017 +set session authorization regress_view_user2 +-- +STMT: VariableSetStmt +== 1018 +create view rw_view4 as select aa, bb, cc FROM rw_view1 +-- +TABLE: name="rw_view4" schema="" table="rw_view4" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 1019 +insert into rw_view4 (aa,bb) values (1,'yyy') + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view4" schema="" table="rw_view4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1020 +-- Not allowed +create view rw_view5 as select aa, bb FROM rw_view1 +-- +TABLE: name="rw_view5" schema="" table="rw_view5" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 1021 +insert into rw_view5 (aa,bb) values (1,'yyy') + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view5" schema="" table="rw_view5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1022 +-- OK +reset session authorization +-- +STMT: VariableSetStmt +== 1023 +select * from base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +== 1024 +drop view rw_view5 +-- +STMT: DropStmt +== 1025 +drop view rw_view4 +-- +STMT: DropStmt +== 1026 +drop view rw_view3 +-- +STMT: DropStmt +== 1027 +drop view rw_view2 +-- +STMT: DropStmt +== 1028 +drop view rw_view1 +-- +STMT: DropStmt +== 1029 +drop table base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +== 1030 +drop user regress_view_user1 +-- +STMT: DropRoleStmt +== 1031 +drop user regress_view_user2 +-- +STMT: DropRoleStmt +== 1032 +-- Test single- and multi-row inserts with table and view defaults. +-- Table defaults should be used, unless overridden by view defaults. +create table base_tab_def (a int, b text default 'Table default', + c text default 'Table default', d text, e text) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: CreateStmt +== 1033 +create view base_tab_def_view as select * from base_tab_def +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 1034 +alter view base_tab_def_view alter b set default 'View default' +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: AlterTableStmt +== 1035 +alter view base_tab_def_view alter d set default 'View default' +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: AlterTableStmt +== 1036 +insert into base_tab_def values (1) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1037 +insert into base_tab_def values (2), (3) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1038 +insert into base_tab_def values (4, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1039 +insert into base_tab_def values (5, default, default, default, default), + (6, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1040 +insert into base_tab_def_view values (11) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1041 +insert into base_tab_def_view values (12), (13) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1042 +insert into base_tab_def_view values (14, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1043 +insert into base_tab_def_view values (15, default, default, default, default), + (16, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1044 +insert into base_tab_def_view values (17), (default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1045 +select * from base_tab_def order by a +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +== 1046 +-- Adding an INSTEAD OF trigger should cause NULLs to be inserted instead of +-- table defaults, where there are no view defaults. +create function base_tab_def_view_instrig_func() returns trigger +as +$$ +begin + insert into base_tab_def values (new.a, new.b, new.c, new.d, new.e); + return new; +end; +$$ +language plpgsql +-- +FUNCTION: name="base_tab_def_view_instrig_func" function="base_tab_def_view_instrig_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 1047 +create trigger base_tab_def_view_instrig instead of insert on base_tab_def_view + for each row execute function base_tab_def_view_instrig_func() +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: CreateTrigStmt +== 1048 +truncate base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: TruncateStmt +== 1049 +insert into base_tab_def values (1) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1050 +insert into base_tab_def values (2), (3) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1051 +insert into base_tab_def values (4, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1052 +insert into base_tab_def values (5, default, default, default, default), + (6, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1053 +insert into base_tab_def_view values (11) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1054 +insert into base_tab_def_view values (12), (13) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1055 +insert into base_tab_def_view values (14, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1056 +insert into base_tab_def_view values (15, default, default, default, default), + (16, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1057 +insert into base_tab_def_view values (17), (default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1058 +select * from base_tab_def order by a +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +== 1059 +-- Using an unconditional DO INSTEAD rule should also cause NULLs to be +-- inserted where there are no view defaults. +drop trigger base_tab_def_view_instrig on base_tab_def_view +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: DropStmt +== 1060 +drop function base_tab_def_view_instrig_func +-- +FUNCTION: name="base_tab_def_view_instrig_func" function="base_tab_def_view_instrig_func" schema="" ctx=DDL +STMT: DropStmt +== 1061 +create rule base_tab_def_view_ins_rule as on insert to base_tab_def_view + do instead insert into base_tab_def values (new.a, new.b, new.c, new.d, new.e) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: RuleStmt +== 1062 +truncate base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: TruncateStmt +== 1063 +insert into base_tab_def values (1) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1064 +insert into base_tab_def values (2), (3) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1065 +insert into base_tab_def values (4, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1066 +insert into base_tab_def values (5, default, default, default, default), + (6, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1067 +insert into base_tab_def_view values (11) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1068 +insert into base_tab_def_view values (12), (13) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1069 +insert into base_tab_def_view values (14, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1070 +insert into base_tab_def_view values (15, default, default, default, default), + (16, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1071 +insert into base_tab_def_view values (17), (default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1072 +select * from base_tab_def order by a +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +== 1073 +-- A DO ALSO rule should cause each row to be inserted twice. The first +-- insert should behave the same as an auto-updatable view (using table +-- defaults, unless overridden by view defaults). The second insert should +-- behave the same as a rule-updatable view (inserting NULLs where there are +-- no view defaults). +drop rule base_tab_def_view_ins_rule on base_tab_def_view +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: DropStmt +== 1074 +create rule base_tab_def_view_ins_rule as on insert to base_tab_def_view + do also insert into base_tab_def values (new.a, new.b, new.c, new.d, new.e) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: RuleStmt +== 1075 +truncate base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: TruncateStmt +== 1076 +insert into base_tab_def values (1) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1077 +insert into base_tab_def values (2), (3) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1078 +insert into base_tab_def values (4, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1079 +insert into base_tab_def values (5, default, default, default, default), + (6, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1080 +insert into base_tab_def_view values (11) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1081 +insert into base_tab_def_view values (12), (13) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1082 +insert into base_tab_def_view values (14, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1083 +insert into base_tab_def_view values (15, default, default, default, default), + (16, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1084 +insert into base_tab_def_view values (17), (default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1085 +select * from base_tab_def order by a, c NULLS LAST +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +== 1086 +-- Test a DO ALSO INSERT ... SELECT rule +drop rule base_tab_def_view_ins_rule on base_tab_def_view +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: DropStmt +== 1087 +create rule base_tab_def_view_ins_rule as on insert to base_tab_def_view + do also insert into base_tab_def (a, b, e) select new.a, new.b, 'xxx' +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: RuleStmt +== 1088 +truncate base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: TruncateStmt +== 1089 +insert into base_tab_def_view values (1, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1090 +insert into base_tab_def_view values (2, default, default, default, default), + (3, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1091 +select * from base_tab_def order by a, e nulls first +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +== 1092 +drop view base_tab_def_view +-- +STMT: DropStmt +== 1093 +drop table base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: DropStmt +== 1094 +-- Test defaults with array assignments +create table base_tab (a serial, b int[], c text, d text default 'Table default') +-- +TABLE: name="base_tab" schema="" table="base_tab" ctx=DDL +STMT: CreateStmt +== 1095 +create view base_tab_view as select c, a, b from base_tab +-- +TABLE: name="base_tab_view" schema="" table="base_tab_view" ctx=DDL +TABLE: name="base_tab" schema="" table="base_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 1096 +alter view base_tab_view alter column c set default 'View default' +-- +TABLE: name="base_tab_view" schema="" table="base_tab_view" ctx=DDL +STMT: AlterTableStmt +== 1097 +insert into base_tab_view (b[1], b[2], c, b[5], b[4], a, b[3]) +values (1, 2, default, 5, 4, default, 3), (10, 11, 'C value', 14, 13, 100, 12) +-- +TABLE: name="base_tab_view" schema="" table="base_tab_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 1098 +select * from base_tab order by a +-- +TABLE: name="base_tab" schema="" table="base_tab" ctx=Select +STMT: SelectStmt +== 1099 +drop view base_tab_view +-- +STMT: DropStmt +== 1100 +drop table base_tab +-- +TABLE: name="base_tab" schema="" table="base_tab" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/update.metadata.json b/parser/testdata/summary/postgres_regress/update.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/update.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/update.test b/parser/testdata/summary/postgres_regress/update.test new file mode 100644 index 0000000..3818afe --- /dev/null +++ b/parser/testdata/summary/postgres_regress/update.test @@ -0,0 +1,1678 @@ +== 001 +|-- +-- UPDATE syntax tests +|-- + +CREATE TABLE update_test ( + a INT DEFAULT 10, + b INT, + c TEXT +) +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE upsert_test ( + a INT PRIMARY KEY, + b TEXT +) +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO update_test VALUES (5, 10, 'foo') +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO update_test(b, a) VALUES (15, 10) +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 006 +UPDATE update_test SET a = DEFAULT, b = DEFAULT +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +== 007 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 008 +-- aliases for the UPDATE target table +UPDATE update_test AS t SET b = 10 WHERE t.a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +ALIAS: "t"="update_test" +STMT: UpdateStmt +== 009 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 010 +UPDATE update_test t SET b = t.b + 10 WHERE t.a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +ALIAS: "t"="update_test" +STMT: UpdateStmt +== 011 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 012 +-- error, you're not supposed to qualify the target column +UPDATE update_test t SET t.b = t.b + 10 WHERE t.a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +ALIAS: "t"="update_test" +STMT: UpdateStmt +== 013 +|-- +-- Test VALUES in FROM +|-- + +UPDATE update_test SET a=v.i FROM (VALUES(100, 20)) AS v(i, j) + WHERE update_test.b = v.j +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +== 014 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 015 +-- fail, wrong data type: +UPDATE update_test SET a = v.* FROM (VALUES(100, 20)) AS v(i, j) + WHERE update_test.b = v.j +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +== 016 +|-- +-- Test multiple-set-clause syntax +|-- + +INSERT INTO update_test SELECT a,b+1,c FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 017 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 018 +UPDATE update_test SET (c,b,a) = ('bugle', b+11, DEFAULT) WHERE c = 'foo' +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +== 019 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 020 +UPDATE update_test SET (c,b) = ('car', a+b), a = a + 1 WHERE a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +== 021 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 022 +-- fail, multi assignment to same column: +UPDATE update_test SET (c,b) = ('car', a+b), b = a + 1 WHERE a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +== 023 +-- uncorrelated sub-select: +UPDATE update_test + SET (b,a) = (select a,b from update_test where b = 41 and c = 'car') + WHERE a = 100 AND b = 20 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: UpdateStmt +STMT: SelectStmt +== 024 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 025 +-- correlated sub-select: +UPDATE update_test o + SET (b,a) = (select a+1,b from update_test i + where i.a=o.a and i.b=o.b and i.c is not distinct from o.c) +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +ALIAS: "i"="update_test" +ALIAS: "o"="update_test" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="o" column="a" +FILTER: schema="" table="i" column="b" +FILTER: schema="" table="o" column="b" +FILTER: schema="" table="i" column="c" +FILTER: schema="" table="o" column="c" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="o" column="a" +FILTER: schema="" table="i" column="b" +FILTER: schema="" table="o" column="b" +FILTER: schema="" table="i" column="c" +FILTER: schema="" table="o" column="c" +STMT: UpdateStmt +STMT: SelectStmt +== 026 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 027 +-- fail, multiple rows supplied: +UPDATE update_test SET (b,a) = (select a+1,b from update_test) +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +== 028 +-- set to null if no rows supplied: +UPDATE update_test SET (b,a) = (select a+1,b from update_test where a = 1000) + WHERE a = 11 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: UpdateStmt +STMT: SelectStmt +== 029 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +== 030 +-- *-expansion should work in this context: +UPDATE update_test SET (a,b) = ROW(v.*) FROM (VALUES(21, 100)) AS v(i, j) + WHERE update_test.a = v.i +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +== 031 +-- you might expect this to work, but syntactically it's not a RowExpr: +UPDATE update_test SET (a,b) = (v.*) FROM (VALUES(21, 101)) AS v(i, j) + WHERE update_test.a = v.i +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +== 032 +-- if an alias for the target table is specified, don't allow references +-- to the original table name +UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +ALIAS: "t"="update_test" +STMT: UpdateStmt +== 033 +-- Make sure that we can update to a TOASTed value. +UPDATE update_test SET c = repeat('x', 10000) WHERE c = 'car' +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: UpdateStmt +== 034 +SELECT a, b, char_length(c) FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +== 035 +-- Check multi-assignment with a Result node to handle a one-time filter. +EXPLAIN (VERBOSE, COSTS OFF) +UPDATE update_test t + SET (a, b) = (SELECT b, a FROM update_test s WHERE s.a = t.a) + WHERE CURRENT_USER = SESSION_USER +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +ALIAS: "s"="update_test" +ALIAS: "t"="update_test" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="t" column="a" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="t" column="a" +STMT: ExplainStmt +STMT: UpdateStmt +STMT: SelectStmt +== 036 +UPDATE update_test t + SET (a, b) = (SELECT b, a FROM update_test s WHERE s.a = t.a) + WHERE CURRENT_USER = SESSION_USER +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +ALIAS: "s"="update_test" +ALIAS: "t"="update_test" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="t" column="a" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="t" column="a" +STMT: UpdateStmt +STMT: SelectStmt +== 037 +SELECT a, b, char_length(c) FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +== 038 +-- Test ON CONFLICT DO UPDATE + +INSERT INTO upsert_test VALUES(1, 'Boo'), (3, 'Zoo') +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 039 +-- uncorrelated sub-select: +WITH aaa AS (SELECT 1 AS a, 'Foo' AS b) INSERT INTO upsert_test + VALUES (1, 'Bar') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b, a FROM aaa) RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +CTE: "aaa" +STMT: InsertStmt +STMT: SelectStmt +== 040 +-- correlated sub-select: +INSERT INTO upsert_test VALUES (1, 'Baz'), (3, 'Zaz') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b || ', Correlated', a from upsert_test i WHERE i.a = upsert_test.a) + RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +ALIAS: "i"="upsert_test" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="upsert_test" column="a" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="upsert_test" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 041 +-- correlated sub-select (EXCLUDED.* alias): +INSERT INTO upsert_test VALUES (1, 'Bat'), (3, 'Zot') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b || ', Excluded', a from upsert_test i WHERE i.a = excluded.a) + RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +ALIAS: "i"="upsert_test" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 042 +-- ON CONFLICT using system attributes in RETURNING, testing both the +-- inserting and updating paths. See bug report at: +-- https://www.postgresql.org/message-id/73436355-6432-49B1-92ED-1FE4F7E7E100%40finefun.com.au +INSERT INTO upsert_test VALUES (2, 'Beeble') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b || ', Excluded', a from upsert_test i WHERE i.a = excluded.a) + RETURNING tableoid::regclass, xmin = pg_current_xact_id()::xid AS xmin_correct, xmax = 0 AS xmax_correct +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +ALIAS: "i"="upsert_test" +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 043 +-- currently xmax is set after a conflict - that's probably not good, +-- but it seems worthwhile to have to be explicit if that changes. +INSERT INTO upsert_test VALUES (2, 'Brox') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b || ', Excluded', a from upsert_test i WHERE i.a = excluded.a) + RETURNING tableoid::regclass, xmin = pg_current_xact_id()::xid AS xmin_correct, xmax = pg_current_xact_id()::xid AS xmax_correct +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +ALIAS: "i"="upsert_test" +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 044 +DROP TABLE update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DDL +STMT: DropStmt +== 045 +DROP TABLE upsert_test +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: DropStmt +== 046 +-- Test ON CONFLICT DO UPDATE with partitioned table and non-identical children + +CREATE TABLE upsert_test ( + a INT PRIMARY KEY, + b TEXT +) PARTITION BY LIST (a) +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: CreateStmt +== 047 +CREATE TABLE upsert_test_1 PARTITION OF upsert_test FOR VALUES IN (1) +-- +TABLE: name="upsert_test_1" schema="" table="upsert_test_1" ctx=DDL +STMT: CreateStmt +== 048 +CREATE TABLE upsert_test_2 (b TEXT, a INT PRIMARY KEY) +-- +TABLE: name="upsert_test_2" schema="" table="upsert_test_2" ctx=DDL +STMT: CreateStmt +== 049 +ALTER TABLE upsert_test ATTACH PARTITION upsert_test_2 FOR VALUES IN (2) +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: AlterTableStmt +== 050 +INSERT INTO upsert_test VALUES(1, 'Boo'), (2, 'Zoo') +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 051 +-- uncorrelated sub-select: +WITH aaa AS (SELECT 1 AS a, 'Foo' AS b) INSERT INTO upsert_test + VALUES (1, 'Bar') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b, a FROM aaa) RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +CTE: "aaa" +STMT: InsertStmt +STMT: SelectStmt +== 052 +-- correlated sub-select: +WITH aaa AS (SELECT 1 AS ctea, ' Foo' AS cteb) INSERT INTO upsert_test + VALUES (1, 'Bar'), (2, 'Baz') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT upsert_test.b||cteb, upsert_test.a FROM aaa) RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +CTE: "aaa" +STMT: InsertStmt +STMT: SelectStmt +== 053 +DROP TABLE upsert_test +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: DropStmt +== 054 +--------------------------- +-- UPDATE with row movement +--------------------------- + +-- When a partitioned table receives an UPDATE to the partitioned key and the +-- new values no longer meet the partition's bound, the row must be moved to +-- the correct partition for the new partition key (if one exists). We must +-- also ensure that updatable views on partitioned tables properly enforce any +-- WITH CHECK OPTION that is defined. The situation with triggers in this case +-- also requires thorough testing as partition key updates causing row +-- movement convert UPDATEs into DELETE+INSERT. + +CREATE TABLE range_parted ( + a text, + b bigint, + c numeric, + d int, + e varchar +) PARTITION BY RANGE (a, b) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +== 055 +-- Create partitions intentionally in descending bound order, so as to test +-- that update-row-movement works with the leaf partitions not in bound order. +CREATE TABLE part_b_20_b_30 (e varchar, c numeric, a text, b bigint, d int) +-- +TABLE: name="part_b_20_b_30" schema="" table="part_b_20_b_30" ctx=DDL +STMT: CreateStmt +== 056 +ALTER TABLE range_parted ATTACH PARTITION part_b_20_b_30 FOR VALUES FROM ('b', 20) TO ('b', 30) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 057 +CREATE TABLE part_b_10_b_20 (e varchar, c numeric, a text, b bigint, d int) PARTITION BY RANGE (c) +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DDL +STMT: CreateStmt +== 058 +CREATE TABLE part_b_1_b_10 PARTITION OF range_parted FOR VALUES FROM ('b', 1) TO ('b', 10) +-- +TABLE: name="part_b_1_b_10" schema="" table="part_b_1_b_10" ctx=DDL +STMT: CreateStmt +== 059 +ALTER TABLE range_parted ATTACH PARTITION part_b_10_b_20 FOR VALUES FROM ('b', 10) TO ('b', 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 060 +CREATE TABLE part_a_10_a_20 PARTITION OF range_parted FOR VALUES FROM ('a', 10) TO ('a', 20) +-- +TABLE: name="part_a_10_a_20" schema="" table="part_a_10_a_20" ctx=DDL +STMT: CreateStmt +== 061 +CREATE TABLE part_a_1_a_10 PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('a', 10) +-- +TABLE: name="part_a_1_a_10" schema="" table="part_a_1_a_10" ctx=DDL +STMT: CreateStmt +== 062 +-- Check that partition-key UPDATE works sanely on a partitioned table that +-- does not have any child partitions. +UPDATE part_b_10_b_20 set b = b - 6 +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DML +STMT: UpdateStmt +== 063 +-- Create some more partitions following the above pattern of descending bound +-- order, but let's make the situation a bit more complex by having the +-- attribute numbers of the columns vary from their parent partition. +CREATE TABLE part_c_100_200 (e varchar, c numeric, a text, b bigint, d int) PARTITION BY range (abs(d)) +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: CreateStmt +== 064 +ALTER TABLE part_c_100_200 DROP COLUMN e, DROP COLUMN c, DROP COLUMN a +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: AlterTableStmt +== 065 +ALTER TABLE part_c_100_200 ADD COLUMN c numeric, ADD COLUMN e varchar, ADD COLUMN a text +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: AlterTableStmt +== 066 +ALTER TABLE part_c_100_200 DROP COLUMN b +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: AlterTableStmt +== 067 +ALTER TABLE part_c_100_200 ADD COLUMN b bigint +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: AlterTableStmt +== 068 +CREATE TABLE part_d_1_15 PARTITION OF part_c_100_200 FOR VALUES FROM (1) TO (15) +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateStmt +== 069 +CREATE TABLE part_d_15_20 PARTITION OF part_c_100_200 FOR VALUES FROM (15) TO (20) +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateStmt +== 070 +ALTER TABLE part_b_10_b_20 ATTACH PARTITION part_c_100_200 FOR VALUES FROM (100) TO (200) +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DDL +STMT: AlterTableStmt +== 071 +CREATE TABLE part_c_1_100 (e varchar, d int, c numeric, b bigint, a text) +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateStmt +== 072 +ALTER TABLE part_b_10_b_20 ATTACH PARTITION part_c_1_100 FOR VALUES FROM (1) TO (100) +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DDL +STMT: AlterTableStmt +== 073 +-- The order of subplans should be in bound order +EXPLAIN (costs off) UPDATE range_parted set c = c - 50 WHERE c > 97 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +== 074 +-- fail, row movement happens only within the partition subtree. +UPDATE part_c_100_200 set c = c - 20, d = c WHERE c = 105 +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DML +STMT: UpdateStmt +== 075 +-- fail, no partition key update, so no attempt to move tuple, +-- but "a = 'a'" violates partition constraint enforced by root partition) +UPDATE part_b_10_b_20 set a = 'a' +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DML +STMT: UpdateStmt +== 076 +-- ok, partition key update, no constraint violation +UPDATE range_parted set d = d - 10 WHERE d > 10 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 077 +-- ok, no partition key update, no constraint violation +UPDATE range_parted set e = d +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 078 +-- No row found +UPDATE part_c_1_100 set c = c + 20 WHERE c = 98 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DML +STMT: UpdateStmt +== 079 +-- ok, row movement +UPDATE part_b_10_b_20 set c = c + 20 returning c, b, a +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DML +STMT: UpdateStmt +== 080 +-- fail, row movement happens only within the partition subtree. +UPDATE part_b_10_b_20 set b = b - 6 WHERE c > 116 returning * +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DML +STMT: UpdateStmt +== 081 +-- ok, row movement, with subset of rows moved into different partition. +UPDATE range_parted set b = b - 6 WHERE c > 116 returning a, b + c +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 082 +-- Common table needed for multiple test scenarios. +CREATE TABLE mintab(c1 int) +-- +TABLE: name="mintab" schema="" table="mintab" ctx=DDL +STMT: CreateStmt +== 083 +INSERT into mintab VALUES (120) +-- +TABLE: name="mintab" schema="" table="mintab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 084 +-- update partition key using updatable view. +CREATE VIEW upview AS SELECT * FROM range_parted WHERE (select c > c1 FROM mintab) WITH CHECK OPTION +-- +TABLE: name="upview" schema="" table="upview" ctx=DDL +TABLE: name="range_parted" schema="" table="range_parted" ctx=Select +TABLE: name="mintab" schema="" table="mintab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 085 +-- ok +UPDATE upview set c = 199 WHERE b = 4 +-- +TABLE: name="upview" schema="" table="upview" ctx=DML +STMT: UpdateStmt +== 086 +-- fail, check option violation +UPDATE upview set c = 120 WHERE b = 4 +-- +TABLE: name="upview" schema="" table="upview" ctx=DML +STMT: UpdateStmt +== 087 +-- fail, row movement with check option violation +UPDATE upview set a = 'b', b = 15, c = 120 WHERE b = 4 +-- +TABLE: name="upview" schema="" table="upview" ctx=DML +STMT: UpdateStmt +== 088 +-- ok, row movement, check option passes +UPDATE upview set a = 'b', b = 15 WHERE b = 4 +-- +TABLE: name="upview" schema="" table="upview" ctx=DML +STMT: UpdateStmt +== 089 +-- cleanup +DROP VIEW upview +-- +STMT: DropStmt +== 090 +UPDATE range_parted set c = 95 WHERE a = 'b' and b > 10 and c > 100 returning (range_parted), * +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 091 +CREATE FUNCTION trans_updatetrigfunc() RETURNS trigger LANGUAGE plpgsql AS +$$ + begin + raise notice 'trigger = %, old table = %, new table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' ORDER BY a) FROM old_table), + (select string_agg(new_table::text, ', ' ORDER BY a) FROM new_table); + return null; + end; +$$ +-- +FUNCTION: name="trans_updatetrigfunc" function="trans_updatetrigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 092 +CREATE TRIGGER trans_updatetrig + AFTER UPDATE ON range_parted REFERENCING OLD TABLE AS old_table NEW TABLE AS new_table + FOR EACH STATEMENT EXECUTE PROCEDURE trans_updatetrigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +== 093 +UPDATE range_parted set c = (case when c = 96 then 110 else c + 1 end ) WHERE a = 'b' and b > 10 and c >= 96 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 094 +-- Enabling OLD TABLE capture for both DELETE as well as UPDATE stmt triggers +-- should not cause DELETEd rows to be captured twice. Similar thing for +-- INSERT triggers and inserted rows. +CREATE TRIGGER trans_deletetrig + AFTER DELETE ON range_parted REFERENCING OLD TABLE AS old_table + FOR EACH STATEMENT EXECUTE PROCEDURE trans_updatetrigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +== 095 +CREATE TRIGGER trans_inserttrig + AFTER INSERT ON range_parted REFERENCING NEW TABLE AS new_table + FOR EACH STATEMENT EXECUTE PROCEDURE trans_updatetrigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +== 096 +UPDATE range_parted set c = c + 50 WHERE a = 'b' and b > 10 and c >= 96 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 097 +DROP TRIGGER trans_deletetrig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 098 +DROP TRIGGER trans_inserttrig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 099 +-- Don't drop trans_updatetrig yet. It is required below. + +-- Test with transition tuple conversion happening for rows moved into the +-- new partition. This requires a trigger that references transition table +-- (we already have trans_updatetrig). For inserted rows, the conversion +-- is not usually needed, because the original tuple is already compatible with +-- the desired transition tuple format. But conversion happens when there is a +-- BR trigger because the trigger can change the inserted row. So install a +-- BR triggers on those child partitions where the rows will be moved. +CREATE FUNCTION func_parted_mod_b() RETURNS trigger AS $$ +BEGIN + NEW.b = NEW.b + 1; + return NEW; +END $$ language plpgsql +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 100 +CREATE TRIGGER trig_c1_100 BEFORE UPDATE OR INSERT ON part_c_1_100 + FOR EACH ROW EXECUTE PROCEDURE func_parted_mod_b() +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateTrigStmt +== 101 +CREATE TRIGGER trig_d1_15 BEFORE UPDATE OR INSERT ON part_d_1_15 + FOR EACH ROW EXECUTE PROCEDURE func_parted_mod_b() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +== 102 +CREATE TRIGGER trig_d15_20 BEFORE UPDATE OR INSERT ON part_d_15_20 + FOR EACH ROW EXECUTE PROCEDURE func_parted_mod_b() +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateTrigStmt +== 103 +UPDATE range_parted set c = (case when c = 96 then 110 else c + 1 end) WHERE a = 'b' and b > 10 and c >= 96 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 104 +UPDATE range_parted set c = c + 50 WHERE a = 'b' and b > 10 and c >= 96 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 105 +UPDATE range_parted set b = 15 WHERE b = 1 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 106 +DROP TRIGGER trans_updatetrig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 107 +DROP TRIGGER trig_c1_100 ON part_c_1_100 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: DropStmt +== 108 +DROP TRIGGER trig_d1_15 ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +== 109 +DROP TRIGGER trig_d15_20 ON part_d_15_20 +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: DropStmt +== 110 +DROP FUNCTION func_parted_mod_b() +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: DropStmt +== 111 +-- RLS policies with update-row-movement +----------------------------------------- + +ALTER TABLE range_parted ENABLE ROW LEVEL SECURITY +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +== 112 +CREATE USER regress_range_parted_user +-- +STMT: CreateRoleStmt +== 113 +GRANT ALL ON range_parted, mintab TO regress_range_parted_user +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +TABLE: name="mintab" schema="" table="mintab" ctx=DDL +STMT: GrantStmt +== 114 +CREATE POLICY seeall ON range_parted AS PERMISSIVE FOR SELECT USING (true) +-- +STMT: CreatePolicyStmt +== 115 +CREATE POLICY policy_range_parted ON range_parted for UPDATE USING (true) WITH CHECK (c % 2 = 0) +-- +STMT: CreatePolicyStmt +== 116 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +== 117 +-- This should fail with RLS violation error while moving row from +-- part_a_10_a_20 to part_d_1_15, because we are setting 'c' to an odd number. +UPDATE range_parted set a = 'b', c = 151 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 118 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 119 +-- Create a trigger on part_d_1_15 +CREATE FUNCTION func_d_1_15() RETURNS trigger AS $$ +BEGIN + NEW.c = NEW.c + 1; -- Make even numbers odd, or vice versa + return NEW; +END $$ LANGUAGE plpgsql +-- +FUNCTION: name="func_d_1_15" function="func_d_1_15" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 120 +CREATE TRIGGER trig_d_1_15 BEFORE INSERT ON part_d_1_15 + FOR EACH ROW EXECUTE PROCEDURE func_d_1_15() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +== 121 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +== 122 +-- Here, RLS checks should succeed while moving row from part_a_10_a_20 to +-- part_d_1_15. Even though the UPDATE is setting 'c' to an odd number, the +-- trigger at the destination partition again makes it an even number. +UPDATE range_parted set a = 'b', c = 151 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 123 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 124 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +== 125 +-- This should fail with RLS violation error. Even though the UPDATE is setting +-- 'c' to an even number, the trigger at the destination partition again makes +-- it an odd number. +UPDATE range_parted set a = 'b', c = 150 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 126 +-- Cleanup +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 127 +DROP TRIGGER trig_d_1_15 ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +== 128 +DROP FUNCTION func_d_1_15() +-- +FUNCTION: name="func_d_1_15" function="func_d_1_15" schema="" ctx=DDL +STMT: DropStmt +== 129 +-- Policy expression contains SubPlan +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 130 +CREATE POLICY policy_range_parted_subplan on range_parted + AS RESTRICTIVE for UPDATE USING (true) + WITH CHECK ((SELECT range_parted.c <= c1 FROM mintab)) +-- +STMT: CreatePolicyStmt +== 131 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +== 132 +-- fail, mintab has row with c1 = 120 +UPDATE range_parted set a = 'b', c = 122 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 133 +-- ok +UPDATE range_parted set a = 'b', c = 120 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 134 +-- RLS policy expression contains whole row. + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 135 +CREATE POLICY policy_range_parted_wholerow on range_parted AS RESTRICTIVE for UPDATE USING (true) + WITH CHECK (range_parted = row('b', 10, 112, 1, NULL)::range_parted) +-- +STMT: CreatePolicyStmt +== 136 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +== 137 +-- ok, should pass the RLS check +UPDATE range_parted set a = 'b', c = 112 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 138 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 139 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +== 140 +-- fail, the whole row RLS check should fail +UPDATE range_parted set a = 'b', c = 116 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 141 +-- Cleanup +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +== 142 +DROP POLICY policy_range_parted ON range_parted +-- +STMT: DropStmt +== 143 +DROP POLICY policy_range_parted_subplan ON range_parted +-- +STMT: DropStmt +== 144 +DROP POLICY policy_range_parted_wholerow ON range_parted +-- +STMT: DropStmt +== 145 +REVOKE ALL ON range_parted, mintab FROM regress_range_parted_user +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +TABLE: name="mintab" schema="" table="mintab" ctx=DDL +STMT: GrantStmt +== 146 +DROP USER regress_range_parted_user +-- +STMT: DropRoleStmt +== 147 +DROP TABLE mintab +-- +TABLE: name="mintab" schema="" table="mintab" ctx=DDL +STMT: DropStmt +== 148 +CREATE FUNCTION trigfunc() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = % fired on table % during %', + TG_NAME, TG_TABLE_NAME, TG_OP; + return null; + end; +$$ +-- +FUNCTION: name="trigfunc" function="trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 149 +-- Triggers on root partition +CREATE TRIGGER parent_delete_trig + AFTER DELETE ON range_parted for each statement execute procedure trigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +== 150 +CREATE TRIGGER parent_update_trig + AFTER UPDATE ON range_parted for each statement execute procedure trigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +== 151 +CREATE TRIGGER parent_insert_trig + AFTER INSERT ON range_parted for each statement execute procedure trigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +== 152 +-- Triggers on leaf partition part_c_1_100 +CREATE TRIGGER c1_delete_trig + AFTER DELETE ON part_c_1_100 for each statement execute procedure trigfunc() +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateTrigStmt +== 153 +CREATE TRIGGER c1_update_trig + AFTER UPDATE ON part_c_1_100 for each statement execute procedure trigfunc() +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateTrigStmt +== 154 +CREATE TRIGGER c1_insert_trig + AFTER INSERT ON part_c_1_100 for each statement execute procedure trigfunc() +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateTrigStmt +== 155 +-- Triggers on leaf partition part_d_1_15 +CREATE TRIGGER d1_delete_trig + AFTER DELETE ON part_d_1_15 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +== 156 +CREATE TRIGGER d1_update_trig + AFTER UPDATE ON part_d_1_15 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +== 157 +CREATE TRIGGER d1_insert_trig + AFTER INSERT ON part_d_1_15 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +== 158 +-- Triggers on leaf partition part_d_15_20 +CREATE TRIGGER d15_delete_trig + AFTER DELETE ON part_d_15_20 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateTrigStmt +== 159 +CREATE TRIGGER d15_update_trig + AFTER UPDATE ON part_d_15_20 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateTrigStmt +== 160 +CREATE TRIGGER d15_insert_trig + AFTER INSERT ON part_d_15_20 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateTrigStmt +== 161 +-- Move all rows from part_c_100_200 to part_c_1_100. None of the delete or +-- insert statement triggers should be fired. +UPDATE range_parted set c = c - 50 WHERE c > 97 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 162 +DROP TRIGGER parent_delete_trig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 163 +DROP TRIGGER parent_update_trig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 164 +DROP TRIGGER parent_insert_trig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 165 +DROP TRIGGER c1_delete_trig ON part_c_1_100 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: DropStmt +== 166 +DROP TRIGGER c1_update_trig ON part_c_1_100 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: DropStmt +== 167 +DROP TRIGGER c1_insert_trig ON part_c_1_100 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: DropStmt +== 168 +DROP TRIGGER d1_delete_trig ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +== 169 +DROP TRIGGER d1_update_trig ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +== 170 +DROP TRIGGER d1_insert_trig ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +== 171 +DROP TRIGGER d15_delete_trig ON part_d_15_20 +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: DropStmt +== 172 +DROP TRIGGER d15_update_trig ON part_d_15_20 +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: DropStmt +== 173 +DROP TRIGGER d15_insert_trig ON part_d_15_20 +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: DropStmt +== 174 +create table part_def partition of range_parted default +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DDL +STMT: CreateStmt +== 175 +insert into range_parted values ('c', 9) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 176 +-- ok +update part_def set a = 'd' where a = 'c' +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DML +STMT: UpdateStmt +== 177 +-- fail +update part_def set a = 'a' where a = 'd' +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DML +STMT: UpdateStmt +== 178 +-- Update row movement from non-default to default partition. +-- fail, default partition is not under part_a_10_a_20; +UPDATE part_a_10_a_20 set a = 'ad' WHERE a = 'a' +-- +TABLE: name="part_a_10_a_20" schema="" table="part_a_10_a_20" ctx=DML +STMT: UpdateStmt +== 179 +-- ok +UPDATE range_parted set a = 'ad' WHERE a = 'a' +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 180 +UPDATE range_parted set a = 'bd' WHERE a = 'b' +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 181 +-- Update row movement from default to non-default partitions. +-- ok +UPDATE range_parted set a = 'a' WHERE a = 'ad' +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 182 +UPDATE range_parted set a = 'b' WHERE a = 'bd' +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +== 183 +-- Cleanup: range_parted no longer needed. +DROP TABLE range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +== 184 +CREATE TABLE list_parted ( + a text, + b int +) PARTITION BY list (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +== 185 +CREATE TABLE list_part1 PARTITION OF list_parted for VALUES in ('a', 'b') +-- +TABLE: name="list_part1" schema="" table="list_part1" ctx=DDL +STMT: CreateStmt +== 186 +CREATE TABLE list_default PARTITION OF list_parted default +-- +TABLE: name="list_default" schema="" table="list_default" ctx=DDL +STMT: CreateStmt +== 187 +INSERT into list_part1 VALUES ('a', 1) +-- +TABLE: name="list_part1" schema="" table="list_part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 188 +INSERT into list_default VALUES ('d', 10) +-- +TABLE: name="list_default" schema="" table="list_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 189 +-- fail +UPDATE list_default set a = 'a' WHERE a = 'd' +-- +TABLE: name="list_default" schema="" table="list_default" ctx=DML +STMT: UpdateStmt +== 190 +-- ok +UPDATE list_default set a = 'x' WHERE a = 'd' +-- +TABLE: name="list_default" schema="" table="list_default" ctx=DML +STMT: UpdateStmt +== 191 +DROP TABLE list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +== 192 +-- Test retrieval of system columns with non-consistent partition row types. +-- This is only partially supported, as seen in the results. + +create table utrtest (a int, b text) partition by list (a) +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DDL +STMT: CreateStmt +== 193 +create table utr1 (a int check (a in (1)), q text, b text) +-- +TABLE: name="utr1" schema="" table="utr1" ctx=DDL +STMT: CreateStmt +== 194 +create table utr2 (a int check (a in (2)), b text) +-- +TABLE: name="utr2" schema="" table="utr2" ctx=DDL +STMT: CreateStmt +== 195 +alter table utr1 drop column q +-- +TABLE: name="utr1" schema="" table="utr1" ctx=DDL +STMT: AlterTableStmt +== 196 +alter table utrtest attach partition utr1 for values in (1) +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DDL +STMT: AlterTableStmt +== 197 +alter table utrtest attach partition utr2 for values in (2) +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DDL +STMT: AlterTableStmt +== 198 +insert into utrtest values (1, 'foo') + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 199 +insert into utrtest values (2, 'bar') + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 200 +-- fails +insert into utrtest values (2, 'bar') + returning *, tableoid::regclass +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 201 +update utrtest set b = b || b from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: UpdateStmt +STMT: SelectStmt +== 202 +update utrtest set a = 3 - a from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: UpdateStmt +STMT: SelectStmt +== 203 +-- fails + +update utrtest set a = 3 - a from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +== 204 +delete from utrtest + returning *, tableoid::regclass, xmax = pg_current_xact_id()::xid as xmax_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: DeleteStmt +== 205 +drop table utrtest +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DDL +STMT: DropStmt +== 206 +-------------- +-- Some more update-partition-key test scenarios below. This time use list +-- partitions. +-------------- + +-- Setup for list partitions +CREATE TABLE list_parted (a numeric, b int, c int8) PARTITION BY list (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +== 207 +CREATE TABLE sub_parted PARTITION OF list_parted for VALUES in (1) PARTITION BY list (b) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DDL +STMT: CreateStmt +== 208 +CREATE TABLE sub_part1(b int, c int8, a numeric) +-- +TABLE: name="sub_part1" schema="" table="sub_part1" ctx=DDL +STMT: CreateStmt +== 209 +ALTER TABLE sub_parted ATTACH PARTITION sub_part1 for VALUES in (1) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DDL +STMT: AlterTableStmt +== 210 +CREATE TABLE sub_part2(b int, c int8, a numeric) +-- +TABLE: name="sub_part2" schema="" table="sub_part2" ctx=DDL +STMT: CreateStmt +== 211 +ALTER TABLE sub_parted ATTACH PARTITION sub_part2 for VALUES in (2) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DDL +STMT: AlterTableStmt +== 212 +CREATE TABLE list_part1(a numeric, b int, c int8) +-- +TABLE: name="list_part1" schema="" table="list_part1" ctx=DDL +STMT: CreateStmt +== 213 +ALTER TABLE list_parted ATTACH PARTITION list_part1 for VALUES in (2,3) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +== 214 +INSERT into list_parted VALUES (2,5,50) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 215 +INSERT into list_parted VALUES (3,6,60) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +INSERT into sub_parted VALUES (1,1,60) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 217 +INSERT into sub_parted VALUES (1,2,10) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 218 +-- Test partition constraint violation when intermediate ancestor is used and +-- constraint is inherited from upper root. +UPDATE sub_parted set a = 2 WHERE c = 10 +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DML +STMT: UpdateStmt +== 219 +-- Test update-partition-key, where the unpruned partitions do not have their +-- partition keys updated. +SELECT tableoid::regclass::text, * FROM list_parted WHERE a = 2 ORDER BY 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 220 +UPDATE list_parted set b = c + a WHERE a = 2 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: UpdateStmt +== 221 +SELECT tableoid::regclass::text, * FROM list_parted WHERE a = 2 ORDER BY 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +== 222 +-- Test the case where BR UPDATE triggers change the partition key. +CREATE FUNCTION func_parted_mod_b() returns trigger as $$ +BEGIN + NEW.b = 2; -- This is changing partition key column. + return NEW; +END $$ LANGUAGE plpgsql +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 223 +CREATE TRIGGER parted_mod_b before update on sub_part1 + for each row execute procedure func_parted_mod_b() +-- +TABLE: name="sub_part1" schema="" table="sub_part1" ctx=DDL +STMT: CreateTrigStmt +== 224 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 225 +-- This should do the tuple routing even though there is no explicit +-- partition-key update, because there is a trigger on sub_part1. +UPDATE list_parted set c = 70 WHERE b = 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: UpdateStmt +== 226 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 227 +DROP TRIGGER parted_mod_b ON sub_part1 +-- +TABLE: name="sub_part1" schema="" table="sub_part1" ctx=DDL +STMT: DropStmt +== 228 +-- If BR DELETE trigger prevented DELETE from happening, we should also skip +-- the INSERT if that delete is part of UPDATE=>DELETE+INSERT. +CREATE OR REPLACE FUNCTION func_parted_mod_b() returns trigger as $$ +BEGIN + raise notice 'Trigger: Got OLD row %, but returning NULL', OLD; + return NULL; +END $$ LANGUAGE plpgsql +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 229 +CREATE TRIGGER trig_skip_delete before delete on sub_part2 + for each row execute procedure func_parted_mod_b() +-- +TABLE: name="sub_part2" schema="" table="sub_part2" ctx=DDL +STMT: CreateTrigStmt +== 230 +UPDATE list_parted set b = 1 WHERE c = 70 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: UpdateStmt +== 231 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 232 +-- Drop the trigger. Now the row should be moved. +DROP TRIGGER trig_skip_delete ON sub_part2 +-- +TABLE: name="sub_part2" schema="" table="sub_part2" ctx=DDL +STMT: DropStmt +== 233 +UPDATE list_parted set b = 1 WHERE c = 70 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: UpdateStmt +== 234 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 235 +DROP FUNCTION func_parted_mod_b() +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: DropStmt +== 236 +-- UPDATE partition-key with FROM clause. If join produces multiple output +-- rows for the same row to be modified, we should tuple-route the row only +-- once. There should not be any rows inserted. +CREATE TABLE non_parted (id int) +-- +TABLE: name="non_parted" schema="" table="non_parted" ctx=DDL +STMT: CreateStmt +== 237 +INSERT into non_parted VALUES (1), (1), (1), (2), (2), (2), (3), (3), (3) +-- +TABLE: name="non_parted" schema="" table="non_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 238 +UPDATE list_parted t1 set a = 2 FROM non_parted t2 WHERE t1.a = t2.id and a = 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +TABLE: name="non_parted" schema="" table="non_parted" ctx=Select +ALIAS: "t1"="list_parted" +ALIAS: "t2"="non_parted" +STMT: UpdateStmt +== 239 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +== 240 +DROP TABLE non_parted +-- +TABLE: name="non_parted" schema="" table="non_parted" ctx=DDL +STMT: DropStmt +== 241 +-- Cleanup: list_parted no longer needed. +DROP TABLE list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +== 242 +-- create custom operator class and hash function, for the same reason +-- explained in alter_table.sql +create or replace function dummy_hashint4(a int4, seed int8) returns int8 as +$$ begin return (a + seed); end; $$ language 'plpgsql' immutable +-- +FUNCTION: name="dummy_hashint4" function="dummy_hashint4" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 243 +create operator class custom_opclass for type int4 using hash as +operator 1 = , function 2 dummy_hashint4(int4, int8) +-- +STMT: CreateOpClassStmt +== 244 +create table hash_parted ( + a int, + b int +) partition by hash (a custom_opclass, b custom_opclass) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: CreateStmt +== 245 +create table hpart1 partition of hash_parted for values with (modulus 2, remainder 1) +-- +TABLE: name="hpart1" schema="" table="hpart1" ctx=DDL +STMT: CreateStmt +== 246 +create table hpart2 partition of hash_parted for values with (modulus 4, remainder 2) +-- +TABLE: name="hpart2" schema="" table="hpart2" ctx=DDL +STMT: CreateStmt +== 247 +create table hpart3 partition of hash_parted for values with (modulus 8, remainder 0) +-- +TABLE: name="hpart3" schema="" table="hpart3" ctx=DDL +STMT: CreateStmt +== 248 +create table hpart4 partition of hash_parted for values with (modulus 8, remainder 4) +-- +TABLE: name="hpart4" schema="" table="hpart4" ctx=DDL +STMT: CreateStmt +== 249 +insert into hpart1 values (1, 1) +-- +TABLE: name="hpart1" schema="" table="hpart1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 250 +insert into hpart2 values (2, 5) +-- +TABLE: name="hpart2" schema="" table="hpart2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 251 +insert into hpart4 values (3, 4) +-- +TABLE: name="hpart4" schema="" table="hpart4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 252 +-- fail +update hpart1 set a = 3, b=4 where a = 1 +-- +TABLE: name="hpart1" schema="" table="hpart1" ctx=DML +STMT: UpdateStmt +== 253 +-- ok, row movement +update hash_parted set b = b - 1 where b = 1 +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DML +STMT: UpdateStmt +== 254 +-- ok +update hash_parted set b = b + 8 where b = 1 +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DML +STMT: UpdateStmt +== 255 +-- cleanup +drop table hash_parted +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: DropStmt +== 256 +drop operator class custom_opclass using hash +-- +STMT: DropStmt +== 257 +drop function dummy_hashint4(a int4, seed int8) +-- +FUNCTION: name="dummy_hashint4" function="dummy_hashint4" schema="" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/uuid.metadata.json b/parser/testdata/summary/postgres_regress/uuid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/uuid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/uuid.test b/parser/testdata/summary/postgres_regress/uuid.test new file mode 100644 index 0000000..e3e5ded --- /dev/null +++ b/parser/testdata/summary/postgres_regress/uuid.test @@ -0,0 +1,312 @@ +== 001 +-- regression test for the uuid datatype +-- creating test tables +CREATE TABLE guid1 +( + guid_field UUID, + text_field TEXT DEFAULT(now()) +) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: CreateStmt +== 002 +CREATE TABLE guid2 +( + guid_field UUID, + text_field TEXT DEFAULT(now()) +) +-- +TABLE: name="guid2" schema="" table="guid2" ctx=DDL +STMT: CreateStmt +== 003 +-- inserting invalid data tests +-- too long +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111F') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +-- too short +INSERT INTO guid1(guid_field) VALUES('{11111111-1111-1111-1111-11111111111}') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +-- valid data but invalid format +INSERT INTO guid1(guid_field) VALUES('111-11111-1111-1111-1111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-2222-222222222222 ') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- invalid data +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-G111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO guid1(guid_field) VALUES('11+11111-1111-1111-1111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +-- test non-error-throwing API +SELECT pg_input_is_valid('11', 'uuid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT * FROM pg_input_error_info('11', 'uuid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 011 +--inserting three input formats +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-2222-222222222222}') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO guid1(guid_field) VALUES('3f3e3c3b3a3039383736353433a2313e') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 014 +-- retrieving the inserted data +SELECT guid_field FROM guid1 +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +STMT: SelectStmt +== 015 +-- ordering test +SELECT guid_field FROM guid1 ORDER BY guid_field ASC +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +STMT: SelectStmt +== 016 +SELECT guid_field FROM guid1 ORDER BY guid_field DESC +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +STMT: SelectStmt +== 017 +-- = operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field = '3f3e3c3b-3a30-3938-3736-353433a2313e' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +== 018 +-- <> operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field <> '11111111111111111111111111111111' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +== 019 +-- < operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field < '22222222-2222-2222-2222-222222222222' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +== 020 +-- <= operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field <= '22222222-2222-2222-2222-222222222222' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +== 021 +-- > operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field > '22222222-2222-2222-2222-222222222222' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +== 022 +-- >= operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field >= '22222222-2222-2222-2222-222222222222' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +== 023 +-- btree and hash index creation test +CREATE INDEX guid1_btree ON guid1 USING BTREE (guid_field) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: IndexStmt +== 024 +CREATE INDEX guid1_hash ON guid1 USING HASH (guid_field) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: IndexStmt +== 025 +-- unique index test +CREATE UNIQUE INDEX guid1_unique_BTREE ON guid1 USING BTREE (guid_field) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: IndexStmt +== 026 +-- should fail +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +-- check to see whether the new indexes are actually there +SELECT count(*) FROM pg_class WHERE relkind='i' AND relname LIKE 'guid%' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 028 +-- populating the test tables with additional records +INSERT INTO guid1(guid_field) VALUES('44444444-4444-4444-4444-444444444444') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +INSERT INTO guid2(guid_field) VALUES('11111111-1111-1111-1111-111111111111') +-- +TABLE: name="guid2" schema="" table="guid2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO guid2(guid_field) VALUES('{22222222-2222-2222-2222-222222222222}') +-- +TABLE: name="guid2" schema="" table="guid2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO guid2(guid_field) VALUES('3f3e3c3b3a3039383736353433a2313e') +-- +TABLE: name="guid2" schema="" table="guid2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +-- join test +SELECT COUNT(*) FROM guid1 g1 INNER JOIN guid2 g2 ON g1.guid_field = g2.guid_field +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +TABLE: name="guid2" schema="" table="guid2" ctx=Select +ALIAS: "g1"="guid1" +ALIAS: "g2"="guid2" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT COUNT(*) FROM guid1 g1 LEFT JOIN guid2 g2 ON g1.guid_field = g2.guid_field WHERE g2.guid_field IS NULL +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +TABLE: name="guid2" schema="" table="guid2" ctx=Select +ALIAS: "g1"="guid1" +ALIAS: "g2"="guid2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="g2" column="guid_field" +STMT: SelectStmt +== 034 +-- generation test +TRUNCATE guid1 +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: TruncateStmt +== 035 +INSERT INTO guid1 (guid_field) VALUES (gen_random_uuid()) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +FUNCTION: name="gen_random_uuid" function="gen_random_uuid" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 036 +INSERT INTO guid1 (guid_field) VALUES (gen_random_uuid()) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +FUNCTION: name="gen_random_uuid" function="gen_random_uuid" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 037 +SELECT count(DISTINCT guid_field) FROM guid1 +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 038 +-- extract functions + +-- version +SELECT uuid_extract_version('11111111-1111-5111-8111-111111111111') +-- +FUNCTION: name="uuid_extract_version" function="uuid_extract_version" schema="" ctx=Call +STMT: SelectStmt +== 039 +-- 5 +SELECT uuid_extract_version(gen_random_uuid()) +-- +FUNCTION: name="uuid_extract_version" function="uuid_extract_version" schema="" ctx=Call +FUNCTION: name="gen_random_uuid" function="gen_random_uuid" schema="" ctx=Call +STMT: SelectStmt +== 040 +-- 4 +SELECT uuid_extract_version('11111111-1111-1111-1111-111111111111') +-- +FUNCTION: name="uuid_extract_version" function="uuid_extract_version" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- null + +-- timestamp +SELECT uuid_extract_timestamp('C232AB00-9414-11EC-B3C8-9F6BDECED846') = 'Tuesday, February 22, 2022 2:22:22.00 PM GMT+05:00' +-- +FUNCTION: name="uuid_extract_timestamp" function="uuid_extract_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 042 +-- RFC 4122bis test vector +SELECT uuid_extract_timestamp(gen_random_uuid()) +-- +FUNCTION: name="uuid_extract_timestamp" function="uuid_extract_timestamp" schema="" ctx=Call +FUNCTION: name="gen_random_uuid" function="gen_random_uuid" schema="" ctx=Call +STMT: SelectStmt +== 043 +-- null +SELECT uuid_extract_timestamp('11111111-1111-1111-1111-111111111111') +-- +FUNCTION: name="uuid_extract_timestamp" function="uuid_extract_timestamp" schema="" ctx=Call +STMT: SelectStmt +== 044 +-- null + + +-- clean up +DROP TABLE guid1, guid2 CASCADE +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +TABLE: name="guid2" schema="" table="guid2" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/vacuum.metadata.json b/parser/testdata/summary/postgres_regress/vacuum.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/vacuum.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/vacuum.test b/parser/testdata/summary/postgres_regress/vacuum.test new file mode 100644 index 0000000..06486cf --- /dev/null +++ b/parser/testdata/summary/postgres_regress/vacuum.test @@ -0,0 +1,1674 @@ +== 001 +|-- +-- VACUUM +|-- + +CREATE TABLE vactst (i INT) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO vactst VALUES (1) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 007 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 008 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 010 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 011 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 012 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 013 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 014 +INSERT INTO vactst VALUES (0) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 015 +SELECT count(*) FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 016 +DELETE FROM vactst WHERE i != 0 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +== 017 +SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: SelectStmt +== 018 +VACUUM FULL vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 019 +UPDATE vactst SET i = i + 1 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: UpdateStmt +== 020 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 027 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 028 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 029 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 030 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +== 031 +INSERT INTO vactst VALUES (0) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 032 +SELECT count(*) FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 033 +DELETE FROM vactst WHERE i != 0 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +== 034 +VACUUM (FULL) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 035 +DELETE FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +== 036 +SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: SelectStmt +== 037 +VACUUM (FULL, FREEZE) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 038 +VACUUM (ANALYZE, FULL) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 039 +CREATE TABLE vaccluster (i INT PRIMARY KEY) +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: CreateStmt +== 040 +ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: AlterTableStmt +== 041 +CLUSTER vaccluster +-- +STMT: ClusterStmt +== 042 +CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL + AS 'ANALYZE pg_am' +-- +FUNCTION: name="do_analyze" function="do_analyze" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 043 +CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL + AS 'SELECT $1 FROM public.do_analyze()' +-- +FUNCTION: name="wrap_do_analyze" function="wrap_do_analyze" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 044 +CREATE INDEX ON vaccluster(wrap_do_analyze(i)) +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +FUNCTION: name="wrap_do_analyze" function="wrap_do_analyze" schema="" ctx=Call +STMT: IndexStmt +== 045 +INSERT INTO vaccluster VALUES (1), (2) +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 046 +ANALYZE vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +== 047 +-- Test ANALYZE in transaction, where the transaction surrounding +-- analyze performed modifications. This tests for the bug at +-- https://postgr.es/m/c7988239-d42c-ddc4-41db-171b23b35e4f%40ssinger.info +-- (which hopefully is unlikely to be reintroduced), but also seems +-- independently worthwhile to cover. +INSERT INTO vactst SELECT generate_series(1, 300) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 048 +DELETE FROM vactst WHERE i % 7 = 0 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +== 049 +-- delete a few rows outside +BEGIN +-- +STMT: TransactionStmt +== 050 +INSERT INTO vactst SELECT generate_series(301, 400) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 051 +DELETE FROM vactst WHERE i % 5 <> 0 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +== 052 +-- delete a few rows inside +ANALYZE vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 053 +COMMIT +-- +STMT: TransactionStmt +== 054 +-- Test ANALYZE setting relhassubclass=f for non-partitioning inheritance +BEGIN +-- +STMT: TransactionStmt +== 055 +CREATE TABLE past_inh_parent () +-- +TABLE: name="past_inh_parent" schema="" table="past_inh_parent" ctx=DDL +STMT: CreateStmt +== 056 +CREATE TABLE past_inh_child () INHERITS (past_inh_parent) +-- +TABLE: name="past_inh_child" schema="" table="past_inh_child" ctx=DDL +STMT: CreateStmt +== 057 +INSERT INTO past_inh_child DEFAULT VALUES +-- +TABLE: name="past_inh_child" schema="" table="past_inh_child" ctx=DML +STMT: InsertStmt +== 058 +INSERT INTO past_inh_child DEFAULT VALUES +-- +TABLE: name="past_inh_child" schema="" table="past_inh_child" ctx=DML +STMT: InsertStmt +== 059 +ANALYZE past_inh_parent +-- +TABLE: name="past_inh_parent" schema="" table="past_inh_parent" ctx=DDL +STMT: VacuumStmt +== 060 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_inh_parent'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 061 +DROP TABLE past_inh_child +-- +TABLE: name="past_inh_child" schema="" table="past_inh_child" ctx=DDL +STMT: DropStmt +== 062 +ANALYZE past_inh_parent +-- +TABLE: name="past_inh_parent" schema="" table="past_inh_parent" ctx=DDL +STMT: VacuumStmt +== 063 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_inh_parent'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 064 +COMMIT +-- +STMT: TransactionStmt +== 065 +-- Test ANALYZE setting relhassubclass=f for partitioning +BEGIN +-- +STMT: TransactionStmt +== 066 +CREATE TABLE past_parted (i int) PARTITION BY LIST(i) +-- +TABLE: name="past_parted" schema="" table="past_parted" ctx=DDL +STMT: CreateStmt +== 067 +CREATE TABLE past_part PARTITION OF past_parted FOR VALUES IN (1) +-- +TABLE: name="past_part" schema="" table="past_part" ctx=DDL +STMT: CreateStmt +== 068 +INSERT INTO past_parted VALUES (1),(1) +-- +TABLE: name="past_parted" schema="" table="past_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 069 +ANALYZE past_parted +-- +TABLE: name="past_parted" schema="" table="past_parted" ctx=DDL +STMT: VacuumStmt +== 070 +DROP TABLE past_part +-- +TABLE: name="past_part" schema="" table="past_part" ctx=DDL +STMT: DropStmt +== 071 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_parted'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 072 +ANALYZE past_parted +-- +TABLE: name="past_parted" schema="" table="past_parted" ctx=DDL +STMT: VacuumStmt +== 073 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_parted'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 074 +COMMIT +-- +STMT: TransactionStmt +== 075 +VACUUM FULL pg_am +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=DDL +STMT: VacuumStmt +== 076 +VACUUM FULL pg_class +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DDL +STMT: VacuumStmt +== 077 +VACUUM FULL pg_database +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=DDL +STMT: VacuumStmt +== 078 +VACUUM FULL vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +== 079 +VACUUM FULL vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 080 +VACUUM (DISABLE_PAGE_SKIPPING) vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +== 081 +-- PARALLEL option +CREATE TABLE pvactst (i INT, a INT[], p POINT) with (autovacuum_enabled = off) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: CreateStmt +== 082 +INSERT INTO pvactst SELECT i, array[1,2,3], point(i, i+1) FROM generate_series(1,1000) i +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 083 +CREATE INDEX btree_pvactst ON pvactst USING btree (i) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +== 084 +CREATE INDEX hash_pvactst ON pvactst USING hash (i) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +== 085 +CREATE INDEX brin_pvactst ON pvactst USING brin (i) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +== 086 +CREATE INDEX gin_pvactst ON pvactst USING gin (a) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +== 087 +CREATE INDEX gist_pvactst ON pvactst USING gist (p) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +== 088 +CREATE INDEX spgist_pvactst ON pvactst USING spgist (p) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +== 089 +CREATE TABLE pvactst2 (i INT) WITH (autovacuum_enabled = off) +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: CreateStmt +== 090 +INSERT INTO pvactst2 SELECT generate_series(1, 1000) +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 091 +CREATE INDEX ON pvactst2 (i) +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: IndexStmt +== 092 +CREATE INDEX ON pvactst2 (i) +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: IndexStmt +== 093 +-- VACUUM invokes parallel index cleanup +SET min_parallel_index_scan_size to 0 +-- +STMT: VariableSetStmt +== 094 +VACUUM (PARALLEL 2) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +== 095 +-- VACUUM invokes parallel bulk-deletion +UPDATE pvactst SET i = i WHERE i < 1000 +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DML +STMT: UpdateStmt +== 096 +VACUUM (PARALLEL 2) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +== 097 +UPDATE pvactst SET i = i WHERE i < 1000 +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DML +STMT: UpdateStmt +== 098 +VACUUM (PARALLEL 0) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +== 099 +-- disable parallel vacuum + +VACUUM (PARALLEL -1) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +== 100 +-- error +VACUUM (PARALLEL 2, INDEX_CLEANUP FALSE) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +== 101 +VACUUM (PARALLEL 2, FULL TRUE) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +== 102 +-- error, cannot use both PARALLEL and FULL +VACUUM (PARALLEL) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +== 103 +-- error, cannot use PARALLEL option without parallel degree + +-- Test parallel vacuum using the minimum maintenance_work_mem with and without +-- dead tuples. +SET maintenance_work_mem TO 64 +-- +STMT: VariableSetStmt +== 104 +VACUUM (PARALLEL 2) pvactst2 +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: VacuumStmt +== 105 +DELETE FROM pvactst2 WHERE i < 1000 +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DML +STMT: DeleteStmt +== 106 +VACUUM (PARALLEL 2) pvactst2 +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: VacuumStmt +== 107 +RESET maintenance_work_mem +-- +STMT: VariableSetStmt +== 108 +-- Test different combinations of parallel and full options for temporary tables +CREATE TEMPORARY TABLE tmp (a int PRIMARY KEY) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: CreateStmt +== 109 +CREATE INDEX tmp_idx1 ON tmp (a) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: IndexStmt +== 110 +VACUUM (PARALLEL 1, FULL FALSE) tmp +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: VacuumStmt +== 111 +-- parallel vacuum disabled for temp tables +VACUUM (PARALLEL 0, FULL TRUE) tmp +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: VacuumStmt +== 112 +-- can specify parallel disabled (even though that's implied by FULL) +RESET min_parallel_index_scan_size +-- +STMT: VariableSetStmt +== 113 +DROP TABLE pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: DropStmt +== 114 +DROP TABLE pvactst2 +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: DropStmt +== 115 +-- INDEX_CLEANUP option +CREATE TABLE no_index_cleanup (i INT PRIMARY KEY, t TEXT) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: CreateStmt +== 116 +-- Use uncompressed data stored in toast. +CREATE INDEX no_index_cleanup_idx ON no_index_cleanup(t) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: IndexStmt +== 117 +ALTER TABLE no_index_cleanup ALTER COLUMN t SET STORAGE EXTERNAL +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +== 118 +INSERT INTO no_index_cleanup(i, t) VALUES (generate_series(1,30), + repeat('1234567890',269)) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 119 +-- index cleanup option is ignored if VACUUM FULL +VACUUM (INDEX_CLEANUP TRUE, FULL TRUE) no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +== 120 +VACUUM (FULL TRUE) no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +== 121 +-- Toast inherits the value from its parent table. +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = false) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +== 122 +DELETE FROM no_index_cleanup WHERE i < 15 +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DML +STMT: DeleteStmt +== 123 +-- Nothing is cleaned up. +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +== 124 +-- Both parent relation and toast are cleaned up. +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = true) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +== 125 +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +== 126 +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = auto) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +== 127 +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +== 128 +-- Parameter is set for both the parent table and its toast relation. +INSERT INTO no_index_cleanup(i, t) VALUES (generate_series(31,60), + repeat('1234567890',269)) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 129 +DELETE FROM no_index_cleanup WHERE i < 45 +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DML +STMT: DeleteStmt +== 130 +-- Only toast index is cleaned up. +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = off, + toast.vacuum_index_cleanup = yes) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +== 131 +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +== 132 +-- Only parent is cleaned up. +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = true, + toast.vacuum_index_cleanup = false) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +== 133 +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +== 134 +-- Test some extra relations. +VACUUM (INDEX_CLEANUP FALSE) vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +== 135 +VACUUM (INDEX_CLEANUP AUTO) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 136 +-- index cleanup option is ignored if no indexes +VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +== 137 +-- TRUNCATE option +CREATE TEMP TABLE vac_truncate_test(i INT NOT NULL, j text) + WITH (vacuum_truncate=true, autovacuum_enabled=false) +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: CreateStmt +== 138 +INSERT INTO vac_truncate_test VALUES (1, NULL), (NULL, NULL) +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 139 +VACUUM (TRUNCATE FALSE, DISABLE_PAGE_SKIPPING) vac_truncate_test +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: VacuumStmt +== 140 +SELECT pg_relation_size('vac_truncate_test') > 0 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +== 141 +VACUUM (DISABLE_PAGE_SKIPPING) vac_truncate_test +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: VacuumStmt +== 142 +SELECT pg_relation_size('vac_truncate_test') = 0 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +== 143 +VACUUM (TRUNCATE FALSE, FULL TRUE) vac_truncate_test +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: VacuumStmt +== 144 +DROP TABLE vac_truncate_test +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: DropStmt +== 145 +-- partitioned table +CREATE TABLE vacparted (a int, b char) PARTITION BY LIST (a) +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: CreateStmt +== 146 +CREATE TABLE vacparted1 PARTITION OF vacparted FOR VALUES IN (1) +-- +TABLE: name="vacparted1" schema="" table="vacparted1" ctx=DDL +STMT: CreateStmt +== 147 +INSERT INTO vacparted VALUES (1, 'a') +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 148 +UPDATE vacparted SET b = 'b' +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DML +STMT: UpdateStmt +== 149 +VACUUM (ANALYZE) vacparted +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 150 +VACUUM (FULL) vacparted +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 151 +VACUUM (FREEZE) vacparted +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 152 +-- check behavior with duplicate column mentions +VACUUM ANALYZE vacparted(a,b,a) +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 153 +ANALYZE vacparted(a,b,b) +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 154 +-- partitioned table with index +CREATE TABLE vacparted_i (a int primary key, b varchar(100)) + PARTITION BY HASH (a) +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: CreateStmt +== 155 +CREATE TABLE vacparted_i1 PARTITION OF vacparted_i + FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="vacparted_i1" schema="" table="vacparted_i1" ctx=DDL +STMT: CreateStmt +== 156 +CREATE TABLE vacparted_i2 PARTITION OF vacparted_i + FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="vacparted_i2" schema="" table="vacparted_i2" ctx=DDL +STMT: CreateStmt +== 157 +INSERT INTO vacparted_i SELECT i, 'test_'|| i from generate_series(1,10) i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 158 +VACUUM (ANALYZE) vacparted_i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: VacuumStmt +== 159 +VACUUM (FULL) vacparted_i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: VacuumStmt +== 160 +VACUUM (FREEZE) vacparted_i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: VacuumStmt +== 161 +SELECT relname, relhasindex FROM pg_class + WHERE relname LIKE 'vacparted_i%' AND relkind IN ('p','r') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relkind" +STMT: SelectStmt +== 162 +DROP TABLE vacparted_i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: DropStmt +== 163 +-- multiple tables specified +VACUUM vaccluster, vactst +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 164 +VACUUM vacparted, does_not_exist +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +STMT: VacuumStmt +== 165 +VACUUM (FREEZE) vacparted, vaccluster, vactst +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 166 +VACUUM (FREEZE) does_not_exist, vaccluster +-- +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +== 167 +VACUUM ANALYZE vactst, vacparted (a) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 168 +VACUUM ANALYZE vactst (does_not_exist), vacparted (b) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 169 +VACUUM FULL vacparted, vactst +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 170 +VACUUM FULL vactst, vacparted (a, b), vaccluster (i) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +== 171 +ANALYZE vactst, vacparted +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 172 +ANALYZE vacparted (b), vactst +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 173 +ANALYZE vactst, does_not_exist, vacparted +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 174 +ANALYZE vactst (i), vacparted (does_not_exist) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +== 175 +ANALYZE vactst, vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 176 +BEGIN +-- +STMT: TransactionStmt +== 177 +-- ANALYZE behaves differently inside a transaction block +ANALYZE vactst, vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 178 +COMMIT +-- +STMT: TransactionStmt +== 179 +-- parenthesized syntax for ANALYZE +ANALYZE (VERBOSE) does_not_exist +-- +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +STMT: VacuumStmt +== 180 +ANALYZE (nonexistent-arg) does_not_exist +-- +ERROR: syntax error at or near "arg" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 181 +ANALYZE (nonexistentarg) does_not_exit +-- +TABLE: name="does_not_exit" schema="" table="does_not_exit" ctx=DDL +STMT: VacuumStmt +== 182 +-- ensure argument order independence, and that SKIP_LOCKED on non-existing +-- relation still errors out. Suppress WARNING messages caused by concurrent +-- autovacuums. +SET client_min_messages TO 'ERROR' +-- +STMT: VariableSetStmt +== 183 +ANALYZE (SKIP_LOCKED, VERBOSE) does_not_exist +-- +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +STMT: VacuumStmt +== 184 +ANALYZE (VERBOSE, SKIP_LOCKED) does_not_exist +-- +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +STMT: VacuumStmt +== 185 +-- SKIP_LOCKED option +VACUUM (SKIP_LOCKED) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 186 +VACUUM (SKIP_LOCKED, FULL) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 187 +ANALYZE (SKIP_LOCKED) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 188 +RESET client_min_messages +-- +STMT: VariableSetStmt +== 189 +-- ensure VACUUM and ANALYZE don't have a problem with serializable +SET default_transaction_isolation = serializable +-- +STMT: VariableSetStmt +== 190 +VACUUM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 191 +ANALYZE vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 192 +RESET default_transaction_isolation +-- +STMT: VariableSetStmt +== 193 +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +== 194 +ANALYZE vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 195 +COMMIT +-- +STMT: TransactionStmt +== 196 +-- PROCESS_TOAST option +CREATE TABLE vac_option_tab (a INT, t TEXT) +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: CreateStmt +== 197 +INSERT INTO vac_option_tab SELECT a, 't' || a FROM generate_series(1, 10) AS a +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 198 +ALTER TABLE vac_option_tab ALTER COLUMN t SET STORAGE EXTERNAL +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: AlterTableStmt +== 199 +-- Check the number of vacuums done on table vac_option_tab and on its +-- toast relation, to check that PROCESS_TOAST and PROCESS_MAIN work on +-- what they should. +CREATE VIEW vac_option_tab_counts AS + SELECT CASE WHEN c.relname IS NULL + THEN 'main' ELSE 'toast' END as rel, + s.vacuum_count + FROM pg_stat_all_tables s + LEFT JOIN pg_class c ON s.relid = c.reltoastrelid + WHERE c.relname = 'vac_option_tab' OR s.relname = 'vac_option_tab' + ORDER BY rel +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=DDL +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_stat_all_tables" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="s" column="relname" +STMT: ViewStmt +STMT: SelectStmt +== 200 +VACUUM (PROCESS_TOAST TRUE) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 201 +SELECT * FROM vac_option_tab_counts +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=Select +STMT: SelectStmt +== 202 +VACUUM (PROCESS_TOAST FALSE) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 203 +SELECT * FROM vac_option_tab_counts +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=Select +STMT: SelectStmt +== 204 +VACUUM (PROCESS_TOAST FALSE, FULL) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 205 +-- error + +-- PROCESS_MAIN option +-- Only the toast table is processed. +VACUUM (PROCESS_MAIN FALSE) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 206 +SELECT * FROM vac_option_tab_counts +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=Select +STMT: SelectStmt +== 207 +-- Nothing is processed. +VACUUM (PROCESS_MAIN FALSE, PROCESS_TOAST FALSE) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 208 +SELECT * FROM vac_option_tab_counts +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=Select +STMT: SelectStmt +== 209 +-- Check if the filenodes nodes have been updated as wanted after FULL. +SELECT relfilenode AS main_filenode FROM pg_class + WHERE relname = 'vac_option_tab' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +== 210 +SELECT t.relfilenode AS toast_filenode FROM pg_class c, pg_class t + WHERE c.reltoastrelid = t.oid AND c.relname = 'vac_option_tab' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="c" column="reltoastrelid" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +== 211 +-- Only the toast relation is processed. +VACUUM (PROCESS_MAIN FALSE, FULL) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 212 +SELECT relfilenode = :main_filenode AS is_same_main_filenode + FROM pg_class WHERE relname = 'vac_option_tab' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 213 +SELECT t.relfilenode = :toast_filenode AS is_same_toast_filenode + FROM pg_class c, pg_class t + WHERE c.reltoastrelid = t.oid AND c.relname = 'vac_option_tab' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 214 +-- BUFFER_USAGE_LIMIT option +VACUUM (BUFFER_USAGE_LIMIT '512 kB') vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 215 +ANALYZE (BUFFER_USAGE_LIMIT '512 kB') vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 216 +-- try disabling the buffer usage limit +VACUUM (BUFFER_USAGE_LIMIT 0) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 217 +ANALYZE (BUFFER_USAGE_LIMIT 0) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 218 +-- value exceeds max size error +VACUUM (BUFFER_USAGE_LIMIT 16777220) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 219 +-- value is less than min size error +VACUUM (BUFFER_USAGE_LIMIT 120) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 220 +-- integer overflow error +VACUUM (BUFFER_USAGE_LIMIT 10000000000) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 221 +-- incompatible with VACUUM FULL error +VACUUM (BUFFER_USAGE_LIMIT '512 kB', FULL) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +== 222 +-- SKIP_DATABASE_STATS option +VACUUM (SKIP_DATABASE_STATS) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 223 +-- ONLY_DATABASE_STATS option +VACUUM (ONLY_DATABASE_STATS) +-- +STMT: VacuumStmt +== 224 +VACUUM (ONLY_DATABASE_STATS) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +== 225 +-- error + +DROP VIEW vac_option_tab_counts +-- +STMT: DropStmt +== 226 +DROP TABLE vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: DropStmt +== 227 +DROP TABLE vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: DropStmt +== 228 +DROP TABLE vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: DropStmt +== 229 +DROP TABLE vacparted +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: DropStmt +== 230 +DROP TABLE no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: DropStmt +== 231 +-- relation ownership, WARNING logs generated as all are skipped. +CREATE TABLE vacowned (a int) +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: CreateStmt +== 232 +CREATE TABLE vacowned_parted (a int) PARTITION BY LIST (a) +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: CreateStmt +== 233 +CREATE TABLE vacowned_part1 PARTITION OF vacowned_parted FOR VALUES IN (1) +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: CreateStmt +== 234 +CREATE TABLE vacowned_part2 PARTITION OF vacowned_parted FOR VALUES IN (2) +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: CreateStmt +== 235 +CREATE ROLE regress_vacuum +-- +STMT: CreateRoleStmt +== 236 +SET ROLE regress_vacuum +-- +STMT: VariableSetStmt +== 237 +-- Simple table +VACUUM vacowned +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: VacuumStmt +== 238 +ANALYZE vacowned +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: VacuumStmt +== 239 +VACUUM (ANALYZE) vacowned +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: VacuumStmt +== 240 +-- Catalog +VACUUM pg_catalog.pg_class +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=DDL +STMT: VacuumStmt +== 241 +ANALYZE pg_catalog.pg_class +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=DDL +STMT: VacuumStmt +== 242 +VACUUM (ANALYZE) pg_catalog.pg_class +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=DDL +STMT: VacuumStmt +== 243 +-- Shared catalog +VACUUM pg_catalog.pg_authid +-- +TABLE: name="pg_catalog.pg_authid" schema="pg_catalog" table="pg_authid" ctx=DDL +STMT: VacuumStmt +== 244 +ANALYZE pg_catalog.pg_authid +-- +TABLE: name="pg_catalog.pg_authid" schema="pg_catalog" table="pg_authid" ctx=DDL +STMT: VacuumStmt +== 245 +VACUUM (ANALYZE) pg_catalog.pg_authid +-- +TABLE: name="pg_catalog.pg_authid" schema="pg_catalog" table="pg_authid" ctx=DDL +STMT: VacuumStmt +== 246 +-- Partitioned table and its partitions, nothing owned by other user. +-- Relations are not listed in a single command to test ownership +-- independently. +VACUUM vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 247 +VACUUM vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 248 +VACUUM vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 249 +ANALYZE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 250 +ANALYZE vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 251 +ANALYZE vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 252 +VACUUM (ANALYZE) vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 253 +VACUUM (ANALYZE) vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 254 +VACUUM (ANALYZE) vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 255 +RESET ROLE +-- +STMT: VariableSetStmt +== 256 +-- Partitioned table and one partition owned by other user. +ALTER TABLE vacowned_parted OWNER TO regress_vacuum +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: AlterTableStmt +== 257 +ALTER TABLE vacowned_part1 OWNER TO regress_vacuum +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: AlterTableStmt +== 258 +SET ROLE regress_vacuum +-- +STMT: VariableSetStmt +== 259 +VACUUM vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 260 +VACUUM vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 261 +VACUUM vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 262 +ANALYZE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 263 +ANALYZE vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 264 +ANALYZE vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 265 +VACUUM (ANALYZE) vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 266 +VACUUM (ANALYZE) vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 267 +VACUUM (ANALYZE) vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 268 +RESET ROLE +-- +STMT: VariableSetStmt +== 269 +-- Only one partition owned by other user. +ALTER TABLE vacowned_parted OWNER TO CURRENT_USER +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: AlterTableStmt +== 270 +SET ROLE regress_vacuum +-- +STMT: VariableSetStmt +== 271 +VACUUM vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 272 +VACUUM vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 273 +VACUUM vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 274 +ANALYZE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 275 +ANALYZE vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 276 +ANALYZE vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 277 +VACUUM (ANALYZE) vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 278 +VACUUM (ANALYZE) vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 279 +VACUUM (ANALYZE) vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 280 +RESET ROLE +-- +STMT: VariableSetStmt +== 281 +-- Only partitioned table owned by other user. +ALTER TABLE vacowned_parted OWNER TO regress_vacuum +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: AlterTableStmt +== 282 +ALTER TABLE vacowned_part1 OWNER TO CURRENT_USER +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: AlterTableStmt +== 283 +SET ROLE regress_vacuum +-- +STMT: VariableSetStmt +== 284 +VACUUM vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 285 +VACUUM vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 286 +VACUUM vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 287 +ANALYZE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 288 +ANALYZE vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 289 +ANALYZE vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 290 +VACUUM (ANALYZE) vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +== 291 +VACUUM (ANALYZE) vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +== 292 +VACUUM (ANALYZE) vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +== 293 +RESET ROLE +-- +STMT: VariableSetStmt +== 294 +DROP TABLE vacowned +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: DropStmt +== 295 +DROP TABLE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: DropStmt +== 296 +DROP ROLE regress_vacuum +-- +STMT: DropRoleStmt diff --git a/parser/testdata/summary/postgres_regress/vacuum_parallel.metadata.json b/parser/testdata/summary/postgres_regress/vacuum_parallel.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/vacuum_parallel.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/vacuum_parallel.test b/parser/testdata/summary/postgres_regress/vacuum_parallel.test new file mode 100644 index 0000000..60cfd29 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/vacuum_parallel.test @@ -0,0 +1,110 @@ +== 001 +SET max_parallel_maintenance_workers TO 4 +-- +STMT: VariableSetStmt +== 002 +SET min_parallel_index_scan_size TO '128kB' +-- +STMT: VariableSetStmt +== 003 +-- Bug #17245: Make sure that we don't totally fail to VACUUM individual indexes that +-- happen to be below min_parallel_index_scan_size during parallel VACUUM: +CREATE TABLE parallel_vacuum_table (a int) WITH (autovacuum_enabled = off) +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: CreateStmt +== 004 +INSERT INTO parallel_vacuum_table SELECT i from generate_series(1, 10000) i +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 005 +-- Parallel VACUUM will never be used unless there are at least two indexes +-- that exceed min_parallel_index_scan_size. Create two such indexes, and +-- a third index that is smaller than min_parallel_index_scan_size. +CREATE INDEX regular_sized_index ON parallel_vacuum_table(a) +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: IndexStmt +== 006 +CREATE INDEX typically_sized_index ON parallel_vacuum_table(a) +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: IndexStmt +== 007 +-- Note: vacuum_in_leader_small_index can apply deduplication, making it ~3x +-- smaller than the other indexes +CREATE INDEX vacuum_in_leader_small_index ON parallel_vacuum_table((1)) +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: IndexStmt +== 008 +-- Verify (as best we can) that the cost model for parallel VACUUM +-- will make our VACUUM run in parallel, while always leaving it up to the +-- parallel leader to handle the vacuum_in_leader_small_index index: +SELECT EXISTS ( +SELECT 1 +FROM pg_class +WHERE oid = 'vacuum_in_leader_small_index'::regclass AND + pg_relation_size(oid) < + pg_size_bytes(current_setting('min_parallel_index_scan_size')) +) as leader_will_handle_small_index +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 009 +SELECT count(*) as trigger_parallel_vacuum_nindexes +FROM pg_class +WHERE oid in ('regular_sized_index'::regclass, 'typically_sized_index'::regclass) AND + pg_relation_size(oid) >= + pg_size_bytes(current_setting('min_parallel_index_scan_size')) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +== 010 +-- Parallel VACUUM with B-Tree page deletions, ambulkdelete calls: +DELETE FROM parallel_vacuum_table +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DML +STMT: DeleteStmt +== 011 +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: VacuumStmt +== 012 +-- Since vacuum_in_leader_small_index uses deduplication, we expect an +-- assertion failure with bug #17245 (in the absence of bugfix): +INSERT INTO parallel_vacuum_table SELECT i FROM generate_series(1, 10000) i +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 013 +RESET max_parallel_maintenance_workers +-- +STMT: VariableSetStmt +== 014 +RESET min_parallel_index_scan_size +-- +STMT: VariableSetStmt diff --git a/parser/testdata/summary/postgres_regress/varchar.metadata.json b/parser/testdata/summary/postgres_regress/varchar.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/varchar.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/varchar.test b/parser/testdata/summary/postgres_regress/varchar.test new file mode 100644 index 0000000..7d0468a --- /dev/null +++ b/parser/testdata/summary/postgres_regress/varchar.test @@ -0,0 +1,163 @@ +== 001 +|-- +-- VARCHAR +|-- + +|-- +-- Build a table for testing +-- (This temporarily hides the table created in test_setup.sql) +|-- + +CREATE TEMP TABLE VARCHAR_TBL(f1 varchar(1)) +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO VARCHAR_TBL (f1) VALUES ('a') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO VARCHAR_TBL (f1) VALUES ('A') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +-- any of the following three input formats are acceptable +INSERT INTO VARCHAR_TBL (f1) VALUES ('1') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 005 +INSERT INTO VARCHAR_TBL (f1) VALUES (2) +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 006 +INSERT INTO VARCHAR_TBL (f1) VALUES ('3') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 007 +-- zero-length char +INSERT INTO VARCHAR_TBL (f1) VALUES ('') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +-- try varchar's of greater than 1 length +INSERT INTO VARCHAR_TBL (f1) VALUES ('cd') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 009 +INSERT INTO VARCHAR_TBL (f1) VALUES ('c ') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 010 +SELECT * FROM VARCHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +STMT: SelectStmt +== 011 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 <> 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 012 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 = 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 013 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 < 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 014 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 <= 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 015 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 > 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 016 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 >= 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +== 017 +DROP TABLE VARCHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DDL +STMT: DropStmt +== 018 +|-- +-- Now test longer arrays of char +|-- +-- This varchar_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. +|-- + +INSERT INTO VARCHAR_TBL (f1) VALUES ('abcde') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 019 +SELECT * FROM VARCHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +STMT: SelectStmt +== 020 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('abcd ', 'varchar(4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT pg_input_is_valid('abcde', 'varchar(4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT * FROM pg_input_error_info('abcde', 'varchar(4)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/window.metadata.json b/parser/testdata/summary/postgres_regress/window.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/window.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/window.test b/parser/testdata/summary/postgres_regress/window.test new file mode 100644 index 0000000..20c84d3 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/window.test @@ -0,0 +1,3859 @@ +== 001 +|-- +-- WINDOW FUNCTIONS +|-- + +CREATE TEMPORARY TABLE empsalary ( + depname varchar, + empno bigint, + salary int, + enroll_date date +) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO empsalary VALUES +('develop', 10, 5200, '2007-08-01'), +('sales', 1, 5000, '2006-10-01'), +('personnel', 5, 3500, '2007-12-10'), +('sales', 4, 4800, '2007-08-08'), +('personnel', 2, 3900, '2006-12-23'), +('develop', 7, 4200, '2008-01-01'), +('develop', 9, 4500, '2008-01-01'), +('sales', 3, 4800, '2007-08-01'), +('develop', 8, 6000, '2006-10-01'), +('develop', 11, 5200, '2007-08-15') +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +SELECT depname, empno, salary, sum(salary) OVER (PARTITION BY depname) FROM empsalary ORDER BY depname, salary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 004 +SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 005 +-- with GROUP BY +SELECT four, ten, SUM(SUM(four)) OVER (PARTITION BY four), AVG(ten) FROM tenk1 +GROUP BY four, ten ORDER BY four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 006 +SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 008 +-- empty window specification +SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 009 +SELECT COUNT(*) OVER w FROM tenk1 WHERE unique2 < 10 WINDOW w AS () +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 010 +-- no window operation +SELECT four FROM tenk1 WHERE FALSE WINDOW w AS (PARTITION BY ten) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +== 011 +-- cumulative aggregate +SELECT sum(four) OVER (PARTITION BY ten ORDER BY unique2) AS sum_1, ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 012 +SELECT row_number() OVER (ORDER BY unique2) FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 013 +SELECT rank() OVER (PARTITION BY four ORDER BY ten) AS rank_1, ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 014 +SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 015 +SELECT percent_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percent_rank" function="percent_rank" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 016 +SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="cume_dist" function="cume_dist" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 017 +SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 018 +SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 020 +SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 021 +SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 022 +SELECT lag(ten, four, 0.7) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 023 +SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 024 +SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 025 +SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 026 +SELECT lead(ten * 2, 1, -1.4) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 027 +SELECT first_value(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 028 +-- last_value returns the last row of the frame, which is CURRENT ROW in ORDER BY window. +SELECT last_value(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 029 +SELECT last_value(ten) OVER (PARTITION BY four), ten, four FROM + (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s + ORDER BY four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 030 +SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four + FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 031 +SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER (PARTITION BY two ORDER BY ten) AS wsum +FROM tenk1 GROUP BY ten, two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT count(*) OVER (PARTITION BY four), four FROM (SELECT * FROM tenk1 WHERE two = 1)s WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="two" +STMT: SelectStmt +== 033 +SELECT (count(*) OVER (PARTITION BY four ORDER BY ten) + + sum(hundred) OVER (PARTITION BY four ORDER BY ten))::varchar AS cntsum + FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 034 +-- opexpr with different windows evaluation. +SELECT * FROM( + SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS total, + count(*) OVER (PARTITION BY four ORDER BY ten) AS fourcount, + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS twosum + FROM tenk1 +)sub +WHERE total <> fourcount + twosum +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="total" +FILTER: schema="" table="" column="fourcount" +FILTER: schema="" table="" column="twosum" +STMT: SelectStmt +== 035 +SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 036 +SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER win AS wsum +FROM tenk1 GROUP BY ten, two WINDOW win AS (PARTITION BY two ORDER BY ten) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- more than one window with GROUP BY +SELECT sum(salary), + row_number() OVER (ORDER BY depname), + sum(sum(salary)) OVER (ORDER BY depname DESC) +FROM empsalary GROUP BY depname +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 038 +-- identical windows with different names +SELECT sum(salary) OVER w1, count(*) OVER w2 +FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 039 +-- subplan +SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) +FROM tenk1 s WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "s"="tenk1" +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="s" column="unique2" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 040 +-- empty table +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 041 +-- mixture of agg/wfunc in the same window +SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +== 042 +-- strict aggs +SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( + SELECT *, + CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(YEAR FROM enroll_date) END * 500 AS bonus, + CASE WHEN + AVG(salary) OVER (PARTITION BY depname) < salary + THEN 200 END AS depadj FROM empsalary +)s +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 043 +-- window function over ungrouped agg over empty row set (bug before 9.1) +SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +== 044 +-- window function with ORDER BY an expression involving aggregates (9.1 bug) +select ten, + sum(unique1) + sum(unique2) as res, + rank() over (order by sum(unique1) + sum(unique2)) as rank +from tenk1 +group by ten order by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- window and aggregate with GROUP BY expression (9.2 bug) +explain (costs off) +select first_value(max(x)) over (), y + from (select unique1 as x, ten+four as y from tenk1) ss + group by y +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 046 +-- window functions returning pass-by-ref values from different rows +select x, lag(x, 1) over (order by x), lead(x, 3) over (order by x) +from (select x::numeric as x from generate_series(1,10) x) +-- +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 047 +-- test non-default frame specifications +SELECT four, ten, + sum(ten) over (partition by four order by ten), + last_value(ten) over (partition by four order by ten) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 048 +SELECT four, ten, + sum(ten) over (partition by four order by ten range between unbounded preceding and current row), + last_value(ten) over (partition by four order by ten range between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 049 +SELECT four, ten, + sum(ten) over (partition by four order by ten range between unbounded preceding and unbounded following), + last_value(ten) over (partition by four order by ten range between unbounded preceding and unbounded following) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 050 +SELECT four, ten/4 as two, + sum(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row), + last_value(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 051 +SELECT four, ten/4 as two, + sum(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row), + last_value(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 052 +SELECT sum(unique1) over (order by four range between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 053 +SELECT sum(unique1) over (rows between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 054 +SELECT sum(unique1) over (rows between 2 preceding and 2 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 055 +SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 056 +SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 057 +SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 058 +SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 059 +SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 060 +SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 061 +SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 062 +SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 063 +SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 064 +SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 065 +SELECT sum(unique1) over (rows between 2 preceding and 1 preceding), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 066 +SELECT sum(unique1) over (rows between 1 following and 3 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 067 +SELECT sum(unique1) over (rows between unbounded preceding and 1 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 068 +SELECT sum(unique1) over (w range between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 069 +SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 070 +SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 071 +SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 072 +SELECT first_value(unique1) over w, + nth_value(unique1, 2) over w AS nth_2, + last_value(unique1) over w, unique1, four +FROM tenk1 WHERE unique1 < 10 +WINDOW w AS (order by four range between current row and unbounded following) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 073 +SELECT sum(unique1) over + (order by unique1 + rows (SELECT unique1 FROM tenk1 ORDER BY unique1 LIMIT 1) + 1 PRECEDING), + unique1 +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 074 +CREATE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following) as sum_rows + FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 075 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +== 076 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 077 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following + exclude current row) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 078 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +== 079 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 080 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following + exclude group) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 081 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +== 082 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 083 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following + exclude ties) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 084 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +== 085 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 086 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following + exclude no others) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 087 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +== 088 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 089 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i groups between 1 preceding and 1 following) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 090 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +== 091 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 092 +DROP VIEW v_window +-- +STMT: DropStmt +== 093 +CREATE TEMP VIEW v_window AS + SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i + FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 094 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 095 +-- RANGE offset PRECEDING/FOLLOWING tests + +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 096 +SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 097 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 098 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 099 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 100 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 101 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 102 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 103 +SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 104 +SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following + exclude current row),unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 105 +select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 106 +select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 107 +select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 108 +select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + exclude current row), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 109 +select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + exclude group), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 110 +select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 111 +select first_value(salary) over(order by salary range between 1000 preceding and 1000 following), + lead(salary) over(order by salary range between 1000 preceding and 1000 following), + nth_value(salary, 1) over(order by salary range between 1000 preceding and 1000 following), + salary from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +== 112 +select last_value(salary) over(order by salary range between 1000 preceding and 1000 following), + lag(salary) over(order by salary range between 1000 preceding and 1000 following), + salary from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: SelectStmt +== 113 +select first_value(salary) over(order by salary range between 1000 following and 3000 following + exclude current row), + lead(salary) over(order by salary range between 1000 following and 3000 following exclude ties), + nth_value(salary, 1) over(order by salary range between 1000 following and 3000 following + exclude ties), + salary from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +== 114 +select last_value(salary) over(order by salary range between 1000 following and 3000 following + exclude group), + lag(salary) over(order by salary range between 1000 following and 3000 following exclude group), + salary from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: SelectStmt +== 115 +select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude ties), + last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 116 +select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude ties), + last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude ties), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 117 +select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude group), + last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude group), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 118 +select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude current row), + last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude current row), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 119 +-- RANGE offset PRECEDING/FOLLOWING with null values +select x, y, + first_value(y) over w, + last_value(y) over w +from + (select x, x as y from generate_series(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by x asc nulls first range between 2 preceding and 2 following) +-- +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 120 +select x, y, + first_value(y) over w, + last_value(y) over w +from + (select x, x as y from generate_series(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by x asc nulls last range between 2 preceding and 2 following) +-- +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 121 +select x, y, + first_value(y) over w, + last_value(y) over w +from + (select x, x as y from generate_series(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by x desc nulls first range between 2 preceding and 2 following) +-- +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 122 +select x, y, + first_value(y) over w, + last_value(y) over w +from + (select x, x as y from generate_series(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by x desc nulls last range between 2 preceding and 2 following) +-- +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 123 +-- There is a syntactic ambiguity in the SQL standard. Since +-- UNBOUNDED is a non-reserved word, it could be the name of a +-- function parameter and be used as an expression. There is a +-- grammar hack to resolve such cases as the keyword. The following +-- tests record this behavior. + +CREATE FUNCTION unbounded_syntax_test1a(x int) RETURNS TABLE (a int, b int, c int) +LANGUAGE SQL +BEGIN ATOMIC + SELECT sum(unique1) over (rows between x preceding and x following), + unique1, four + FROM tenk1 WHERE unique1 < 10 +-- +ERROR: syntax error at end of input +CURSORPOS: 525 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 124 +END +-- +STMT: TransactionStmt +== 125 +CREATE FUNCTION unbounded_syntax_test1b(x int) RETURNS TABLE (a int, b int, c int) +LANGUAGE SQL +AS $$ + SELECT sum(unique1) over (rows between x preceding and x following), + unique1, four + FROM tenk1 WHERE unique1 < 10; +$$ +-- +FUNCTION: name="unbounded_syntax_test1b" function="unbounded_syntax_test1b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 126 +-- These will apply the argument to the window specification inside the function. +SELECT * FROM unbounded_syntax_test1a(2) +-- +FUNCTION: name="unbounded_syntax_test1a" function="unbounded_syntax_test1a" schema="" ctx=Call +STMT: SelectStmt +== 127 +SELECT * FROM unbounded_syntax_test1b(2) +-- +FUNCTION: name="unbounded_syntax_test1b" function="unbounded_syntax_test1b" schema="" ctx=Call +STMT: SelectStmt +== 128 +CREATE FUNCTION unbounded_syntax_test2a(unbounded int) RETURNS TABLE (a int, b int, c int) +LANGUAGE SQL +BEGIN ATOMIC + SELECT sum(unique1) over (rows between unbounded preceding and unbounded following), + unique1, four + FROM tenk1 WHERE unique1 < 10 +-- +ERROR: syntax error at end of input +CURSORPOS: 259 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 129 +END +-- +STMT: TransactionStmt +== 130 +CREATE FUNCTION unbounded_syntax_test2b(unbounded int) RETURNS TABLE (a int, b int, c int) +LANGUAGE SQL +AS $$ + SELECT sum(unique1) over (rows between unbounded preceding and unbounded following), + unique1, four + FROM tenk1 WHERE unique1 < 10; +$$ +-- +FUNCTION: name="unbounded_syntax_test2b" function="unbounded_syntax_test2b" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 131 +-- These will not apply the argument but instead treat UNBOUNDED as a keyword. +SELECT * FROM unbounded_syntax_test2a(2) +-- +FUNCTION: name="unbounded_syntax_test2a" function="unbounded_syntax_test2a" schema="" ctx=Call +STMT: SelectStmt +== 132 +SELECT * FROM unbounded_syntax_test2b(2) +-- +FUNCTION: name="unbounded_syntax_test2b" function="unbounded_syntax_test2b" schema="" ctx=Call +STMT: SelectStmt +== 133 +DROP FUNCTION unbounded_syntax_test1a, unbounded_syntax_test1b, + unbounded_syntax_test2a, unbounded_syntax_test2b +-- +FUNCTION: name="unbounded_syntax_test1a" function="unbounded_syntax_test1a" schema="" ctx=DDL +STMT: DropStmt +== 134 +-- Other tests with token UNBOUNDED in potentially problematic position +CREATE FUNCTION unbounded(x int) RETURNS int LANGUAGE SQL IMMUTABLE RETURN x +-- +FUNCTION: name="unbounded" function="unbounded" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 135 +SELECT sum(unique1) over (rows between 1 preceding and 1 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 136 +SELECT sum(unique1) over (rows between unbounded(1) preceding and unbounded(1) following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="unbounded" function="unbounded" schema="" ctx=Call +FUNCTION: name="unbounded" function="unbounded" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 137 +SELECT sum(unique1) over (rows between unbounded.x preceding and unbounded.x following), + unique1, four +FROM tenk1, (values (1)) as unbounded(x) WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 138 +DROP FUNCTION unbounded +-- +FUNCTION: name="unbounded" function="unbounded" schema="" ctx=DDL +STMT: DropStmt +== 139 +-- Check overflow behavior for various integer sizes + +select x, last_value(x) over (order by x::smallint range between current row and 2147450884 following) +from generate_series(32764, 32766) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 140 +select x, last_value(x) over (order by x::smallint desc range between current row and 2147450885 following) +from generate_series(-32766, -32764) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 141 +select x, last_value(x) over (order by x range between current row and 4 following) +from generate_series(2147483644, 2147483646) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 142 +select x, last_value(x) over (order by x desc range between current row and 5 following) +from generate_series(-2147483646, -2147483644) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 143 +select x, last_value(x) over (order by x range between current row and 4 following) +from generate_series(9223372036854775804, 9223372036854775806) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 144 +select x, last_value(x) over (order by x desc range between current row and 5 following) +from generate_series(-9223372036854775806, -9223372036854775804) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 145 +-- Test in_range for other numeric datatypes + +create temp table numerics( + id int, + f_float4 float4, + f_float8 float8, + f_numeric numeric +) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=DDL +STMT: CreateStmt +== 146 +insert into numerics values +(0, '-infinity', '-infinity', '-infinity'), +(1, -3, -3, -3), +(2, -1, -1, -1), +(3, 0, 0, 0), +(4, 1.1, 1.1, 1.1), +(5, 1.12, 1.12, 1.12), +(6, 2, 2, 2), +(7, 100, 100, 100), +(8, 'infinity', 'infinity', 'infinity'), +(9, 'NaN', 'NaN', 'NaN') +-- +TABLE: name="numerics" schema="" table="numerics" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 147 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 1 preceding and 1 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 148 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 1 preceding and 1.1::float4 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 149 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 'inf' preceding and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 150 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 'inf' preceding and 'inf' preceding) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 151 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 'inf' following and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 152 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 1.1 preceding and 'NaN' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 153 +-- error, NaN disallowed + +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 1 preceding and 1 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 154 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 1 preceding and 1.1::float8 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 155 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 'inf' preceding and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 156 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 'inf' preceding and 'inf' preceding) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 157 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 'inf' following and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 158 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 1.1 preceding and 'NaN' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 159 +-- error, NaN disallowed + +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 160 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1.1::numeric following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 161 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1.1::float8 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 162 +-- currently unsupported +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 'inf' preceding and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 163 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 'inf' preceding and 'inf' preceding) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 164 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 'inf' following and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 165 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 1.1 preceding and 'NaN' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 166 +-- error, NaN disallowed + +-- Test in_range for other datetime datatypes + +create temp table datetimes( + id int, + f_time time, + f_timetz timetz, + f_interval interval, + f_timestamptz timestamptz, + f_timestamp timestamp +) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=DDL +STMT: CreateStmt +== 167 +insert into datetimes values +(0, '10:00', '10:00 BST', '-infinity', '-infinity', '-infinity'), +(1, '11:00', '11:00 BST', '1 year', '2000-10-19 10:23:54+01', '2000-10-19 10:23:54'), +(2, '12:00', '12:00 BST', '2 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), +(3, '13:00', '13:00 BST', '3 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), +(4, '14:00', '14:00 BST', '4 years', '2002-10-19 10:23:54+01', '2002-10-19 10:23:54'), +(5, '15:00', '15:00 BST', '5 years', '2003-10-19 10:23:54+01', '2003-10-19 10:23:54'), +(6, '15:00', '15:00 BST', '5 years', '2004-10-19 10:23:54+01', '2004-10-19 10:23:54'), +(7, '17:00', '17:00 BST', '7 years', '2005-10-19 10:23:54+01', '2005-10-19 10:23:54'), +(8, '18:00', '18:00 BST', '8 years', '2006-10-19 10:23:54+01', '2006-10-19 10:23:54'), +(9, '19:00', '19:00 BST', '9 years', '2007-10-19 10:23:54+01', '2007-10-19 10:23:54'), +(10, '20:00', '20:00 BST', '10 years', '2008-10-19 10:23:54+01', '2008-10-19 10:23:54'), +(11, '21:00', '21:00 BST', 'infinity', 'infinity', 'infinity') +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 168 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + '70 min'::interval preceding and '2 hours'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 169 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time desc range between + '70 min' preceding and '2 hours' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 170 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time desc range between + '-70 min' preceding and '2 hours' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 171 +-- error, negative offset disallowed + +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 172 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 173 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 174 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + '-infinity'::interval following and + 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 175 +-- error, negative offset disallowed + +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + '70 min'::interval preceding and '2 hours'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 176 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz desc range between + '70 min' preceding and '2 hours' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 177 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz desc range between + '70 min' preceding and '-2 hours' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 178 +-- error, negative offset disallowed + +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 179 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 180 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 181 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + 'infinity'::interval following and + '-infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 182 +-- error, negative offset disallowed + +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + '1 year'::interval preceding and '1 year'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 183 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval desc range between + '1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 184 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval desc range between + '-1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 185 +-- error, negative offset disallowed + +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 186 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 187 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 188 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + '-infinity'::interval following and + 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 189 +-- error, negative offset disallowed + +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + '1 year'::interval preceding and '1 year'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 190 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz desc range between + '1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 191 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz desc range between + '1 year' preceding and '-1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 192 +-- error, negative offset disallowed + +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 193 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 194 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 195 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + '-infinity'::interval following and + 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 196 +-- error, negative offset disallowed + +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + '1 year'::interval preceding and '1 year'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 197 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp desc range between + '1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 198 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp desc range between + '-1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 199 +-- error, negative offset disallowed + +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 200 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 201 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 202 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + '-infinity'::interval following and + 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +== 203 +-- error, negative offset disallowed + +-- RANGE offset PRECEDING/FOLLOWING error cases +select sum(salary) over (order by enroll_date, salary range between '1 year'::interval preceding and '2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 204 +select sum(salary) over (range between '1 year'::interval preceding and '2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 205 +select sum(salary) over (order by depname range between '1 year'::interval preceding and '2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 206 +select max(enroll_date) over (order by enroll_date range between 1 preceding and 2 following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 207 +select max(enroll_date) over (order by salary range between -1 preceding and 2 following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 208 +select max(enroll_date) over (order by salary range between 1 preceding and -2 following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 209 +select max(enroll_date) over (order by salary range between '1 year'::interval preceding and '2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 210 +select max(enroll_date) over (order by enroll_date range between '1 year'::interval preceding and '-2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 211 +-- GROUPS tests + +SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 212 +SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 213 +SELECT sum(unique1) over (order by four groups between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 214 +SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 215 +SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 216 +SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 217 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 218 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 219 +SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 220 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following + exclude current row), unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 221 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following + exclude group), unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 222 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following + exclude ties), unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 223 +SELECT sum(unique1) over (partition by ten + order by four groups between 0 preceding and 0 following),unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 224 +SELECT sum(unique1) over (partition by ten + order by four groups between 0 preceding and 0 following exclude current row), unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 225 +SELECT sum(unique1) over (partition by ten + order by four groups between 0 preceding and 0 following exclude group), unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 226 +SELECT sum(unique1) over (partition by ten + order by four groups between 0 preceding and 0 following exclude ties), unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +== 227 +select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), + lead(salary) over(order by enroll_date groups between 1 preceding and 1 following), + nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +== 228 +select last_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), + lag(salary) over(order by enroll_date groups between 1 preceding and 1 following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: SelectStmt +== 229 +select first_value(salary) over(order by enroll_date groups between 1 following and 3 following + exclude current row), + lead(salary) over(order by enroll_date groups between 1 following and 3 following exclude ties), + nth_value(salary, 1) over(order by enroll_date groups between 1 following and 3 following + exclude ties), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +== 230 +select last_value(salary) over(order by enroll_date groups between 1 following and 3 following + exclude group), + lag(salary) over(order by enroll_date groups between 1 following and 3 following exclude group), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: SelectStmt +== 231 +-- Show differences in offset interpretation between ROWS, RANGE, and GROUPS +WITH cte (x) AS ( + SELECT * FROM generate_series(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 232 +WITH cte (x) AS ( + SELECT * FROM generate_series(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 233 +WITH cte (x) AS ( + SELECT * FROM generate_series(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 234 +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM generate_series(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 235 +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM generate_series(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 236 +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM generate_series(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 237 +-- with UNION +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 238 +-- check some degenerate cases +create temp table t1 (f1 int, f2 int8) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +== 239 +insert into t1 values (1,1),(1,2),(2,2) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 240 +select f1, sum(f1) over (partition by f1 + range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 241 +-- error, must have order by +explain (costs off) +select f1, sum(f1) over (partition by f1 order by f2 + range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: ExplainStmt +STMT: SelectStmt +== 242 +select f1, sum(f1) over (partition by f1 order by f2 + range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 243 +select f1, sum(f1) over (partition by f1, f1 order by f2 + range between 2 preceding and 1 preceding) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 244 +select f1, sum(f1) over (partition by f1, f2 order by f2 + range between 1 following and 2 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 245 +select f1, sum(f1) over (partition by f1 + groups between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 246 +-- error, must have order by +explain (costs off) +select f1, sum(f1) over (partition by f1 order by f2 + groups between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: ExplainStmt +STMT: SelectStmt +== 247 +select f1, sum(f1) over (partition by f1 order by f2 + groups between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 248 +select f1, sum(f1) over (partition by f1, f1 order by f2 + groups between 2 preceding and 1 preceding) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 249 +select f1, sum(f1) over (partition by f1, f2 order by f2 + groups between 1 following and 2 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +== 250 +-- ordering by a non-integer constant is allowed +SELECT rank() OVER (ORDER BY length('abc')) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 251 +-- can't order by another window function +SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 252 +-- some other errors +SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="salary" +STMT: SelectStmt +== 253 +SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: SelectStmt +== 254 +SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 255 +SELECT * FROM rank() OVER (ORDER BY random()) +-- +ERROR: syntax error at or near "ORDER" +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 256 +DELETE FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DML +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: DeleteStmt +== 257 +DELETE FROM empsalary RETURNING rank() OVER (ORDER BY random()) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DML +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: DeleteStmt +== 258 +SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 259 +SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1 +-- +ERROR: syntax error at or near "ORDER" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 260 +SELECT count() OVER () FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 261 +SELECT generate_series(1, 100) OVER () FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 262 +SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +STMT: SelectStmt +== 263 +SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +== 264 +-- filter + +SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( + sum(salary) FILTER (WHERE enroll_date > '2007-01-01') +) FILTER (WHERE depname <> 'sales') OVER (ORDER BY depname DESC) AS "filtered_sum", + depname +FROM empsalary GROUP BY depname +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 265 +|-- +-- Test SupportRequestOptimizeWindowClause's ability to de-duplicate +-- WindowClauses +|-- + +-- Ensure WindowClause frameOptions are changed so that only a single +-- WindowAgg exists in the plan. +EXPLAIN (COSTS OFF) +SELECT + empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) rn, + rank() OVER (PARTITION BY depname ORDER BY enroll_date ROWS BETWEEN + UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) rnk, + dense_rank() OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND CURRENT ROW) drnk, + ntile(10) OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND UNBOUNDED FOLLOWING) nt, + percent_rank() OVER (PARTITION BY depname ORDER BY enroll_date ROWS BETWEEN + CURRENT ROW AND UNBOUNDED FOLLOWING) pr, + cume_dist() OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND UNBOUNDED FOLLOWING) cd +FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FUNCTION: name="percent_rank" function="percent_rank" schema="" ctx=Call +FUNCTION: name="cume_dist" function="cume_dist" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 266 +-- Ensure WindowFuncs which cannot support their WindowClause's frameOptions +-- being changed are untouched +EXPLAIN (COSTS OFF, VERBOSE) +SELECT + empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) rn, + rank() OVER (PARTITION BY depname ORDER BY enroll_date ROWS BETWEEN + UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) rnk, + count(*) OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND CURRENT ROW) cnt +FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 267 +-- Ensure the above query gives us the expected results +SELECT + empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) rn, + rank() OVER (PARTITION BY depname ORDER BY enroll_date ROWS BETWEEN + UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) rnk, + count(*) OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND CURRENT ROW) cnt +FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 268 +-- Test pushdown of quals into a subquery containing window functions + +-- pushdown is safe because all PARTITION BY clauses include depname: +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT depname, + sum(salary) OVER (PARTITION BY depname) depsalary, + min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary + FROM empsalary) emp +WHERE depname = 'sales' +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="depname" +STMT: ExplainStmt +STMT: SelectStmt +== 269 +-- pushdown is unsafe because there's a PARTITION BY clause without depname: +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT depname, + sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, + min(salary) OVER (PARTITION BY depname) depminsalary + FROM empsalary) emp +WHERE depname = 'sales' +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="depname" +STMT: ExplainStmt +STMT: SelectStmt +== 270 +-- Test window function run conditions are properly pushed down into the +-- WindowAgg +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + row_number() OVER (ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: ExplainStmt +STMT: SelectStmt +== 271 +-- The following 3 statements should result the same result. +SELECT * FROM + (SELECT empno, + row_number() OVER (ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +== 272 +SELECT * FROM + (SELECT empno, + row_number() OVER (ORDER BY empno) rn + FROM empsalary) emp +WHERE 3 > rn +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +== 273 +SELECT * FROM + (SELECT empno, + row_number() OVER (ORDER BY empno) rn + FROM empsalary) emp +WHERE 2 >= rn +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +== 274 +-- Ensure r <= 3 is pushed down into the run condition of the window agg +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + rank() OVER (ORDER BY salary DESC) r + FROM empsalary) emp +WHERE r <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="r" +STMT: ExplainStmt +STMT: SelectStmt +== 275 +SELECT * FROM + (SELECT empno, + salary, + rank() OVER (ORDER BY salary DESC) r + FROM empsalary) emp +WHERE r <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="r" +STMT: SelectStmt +== 276 +-- Ensure dr = 1 is converted to dr <= 1 to get all rows leading up to dr = 1 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + dense_rank() OVER (ORDER BY salary DESC) dr + FROM empsalary) emp +WHERE dr = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FILTER: schema="" table="" column="dr" +STMT: ExplainStmt +STMT: SelectStmt +== 277 +SELECT * FROM + (SELECT empno, + salary, + dense_rank() OVER (ORDER BY salary DESC) dr + FROM empsalary) emp +WHERE dr = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FILTER: schema="" table="" column="dr" +STMT: SelectStmt +== 278 +-- Check COUNT() and COUNT(*) +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 279 +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +== 280 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(empno) OVER (ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 281 +SELECT * FROM + (SELECT empno, + salary, + count(empno) OVER (ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +== 282 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) c + FROM empsalary) emp +WHERE c >= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 283 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER () c + FROM empsalary) emp +WHERE 11 <= c +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 284 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC) c, + dense_rank() OVER (ORDER BY salary DESC) dr + FROM empsalary) emp +WHERE dr = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FILTER: schema="" table="" column="dr" +STMT: ExplainStmt +STMT: SelectStmt +== 285 +-- Ensure we get a run condition when there's a PARTITION BY clause +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: ExplainStmt +STMT: SelectStmt +== 286 +-- and ensure we get the correct results from the above plan +SELECT * FROM + (SELECT empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +== 287 +-- ensure that "unused" subquery columns are not removed when the column only +-- exists in the run condition +EXPLAIN (COSTS OFF) +SELECT empno, depname FROM + (SELECT empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: ExplainStmt +STMT: SelectStmt +== 288 +-- likewise with count(empno) instead of row_number() +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + depname, + salary, + count(empno) OVER (PARTITION BY depname ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 289 +-- and again, check the results are what we expect. +SELECT * FROM + (SELECT empno, + depname, + salary, + count(empno) OVER (PARTITION BY depname ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +== 290 +-- Ensure we get the correct run condition when the window function is both +-- monotonically increasing and decreasing. +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + depname, + salary, + count(empno) OVER () c + FROM empsalary) emp +WHERE c = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 291 +-- Try another case with a WindowFunc with a byref return type +SELECT * FROM + (SELECT row_number() OVER (PARTITION BY salary) AS rn, + lead(depname) OVER (PARTITION BY salary) || ' Department' AS n_dep + FROM empsalary) emp +WHERE rn < 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +== 292 +-- Some more complex cases with multiple window clauses +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT *, + count(salary) OVER (PARTITION BY depname || '') c1, -- w1 + row_number() OVER (PARTITION BY depname) rn, -- w2 + count(*) OVER (PARTITION BY depname) c2, -- w2 + count(*) OVER (PARTITION BY '' || depname) c3, -- w3 + ntile(2) OVER (PARTITION BY depname) nt -- w2 + FROM empsalary +) e WHERE rn <= 1 AND c1 <= 3 AND nt < 2 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="nt" +STMT: ExplainStmt +STMT: SelectStmt +== 293 +-- Ensure we correctly filter out all of the run conditions from each window +SELECT * FROM + (SELECT *, + count(salary) OVER (PARTITION BY depname || '') c1, -- w1 + row_number() OVER (PARTITION BY depname) rn, -- w2 + count(*) OVER (PARTITION BY depname) c2, -- w2 + count(*) OVER (PARTITION BY '' || depname) c3, -- w3 + ntile(2) OVER (PARTITION BY depname) nt -- w2 + FROM empsalary +) e WHERE rn <= 1 AND c1 <= 3 AND nt < 2 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="nt" +STMT: SelectStmt +== 294 +-- Ensure we remove references to reduced outer joins as nulling rels in run +-- conditions +EXPLAIN (COSTS OFF) +SELECT 1 FROM + (SELECT ntile(e2.salary) OVER (PARTITION BY e1.depname) AS c + FROM empsalary e1 LEFT JOIN empsalary e2 ON TRUE + WHERE e1.empno = e2.empno) s +WHERE s.c = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +ALIAS: "e1"="empsalary" +ALIAS: "e2"="empsalary" +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="s" column="c" +FILTER: schema="" table="e1" column="empno" +FILTER: schema="" table="e2" column="empno" +STMT: ExplainStmt +STMT: SelectStmt +== 295 +-- Ensure the run condition optimization is used in cases where the WindowFunc +-- has a Var from another query level +EXPLAIN (COSTS OFF) +SELECT 1 FROM + (SELECT ntile(s1.x) OVER () AS c + FROM (SELECT (SELECT 1) AS x) AS s1) s +WHERE s.c = 1 +-- +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 296 +-- Tests to ensure we don't push down the run condition when it's not valid to +-- do so. + +-- Ensure we don't push down when the frame options show that the window +-- function is not monotonically increasing +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 297 +-- Ensure we don't push down when the window function's monotonic properties +-- don't match that of the clauses. +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary) c + FROM empsalary) emp +WHERE 3 <= c +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 298 +-- Ensure we don't use a run condition when there's a volatile function in the +-- WindowFunc +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(random()) OVER (ORDER BY empno DESC) c + FROM empsalary) emp +WHERE c = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 299 +-- Ensure we don't use a run condition when the WindowFunc contains subplans +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count((SELECT 1)) OVER (ORDER BY empno DESC) c + FROM empsalary) emp +WHERE c = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +== 300 +-- Test Sort node collapsing +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary + FROM empsalary) emp +WHERE depname = 'sales' +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="depname" +STMT: ExplainStmt +STMT: SelectStmt +== 301 +-- Ensure that the evaluation order of the WindowAggs results in the WindowAgg +-- with the same sort order that's required by the ORDER BY is evaluated last. +EXPLAIN (COSTS OFF) +SELECT empno, + enroll_date, + depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname order by enroll_date) depminsalary +FROM empsalary +ORDER BY depname, empno +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 302 +-- As above, but with an adjusted ORDER BY to ensure the above plan didn't +-- perform only 2 sorts by accident. +EXPLAIN (COSTS OFF) +SELECT empno, + enroll_date, + depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname order by enroll_date) depminsalary +FROM empsalary +ORDER BY depname, enroll_date +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 303 +SET enable_hashagg TO off +-- +STMT: VariableSetStmt +== 304 +-- Ensure we don't get a sort for both DISTINCT and ORDER BY. We expect the +-- sort for the DISTINCT to provide presorted input for the ORDER BY. +EXPLAIN (COSTS OFF) +SELECT DISTINCT + empno, + enroll_date, + depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname order by enroll_date) depminsalary +FROM empsalary +ORDER BY depname, enroll_date +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 305 +-- As above but adjust the ORDER BY clause to help ensure the plan with the +-- minimum amount of sorting wasn't a fluke. +EXPLAIN (COSTS OFF) +SELECT DISTINCT + empno, + enroll_date, + depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname order by enroll_date) depminsalary +FROM empsalary +ORDER BY depname, empno +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 306 +RESET enable_hashagg +-- +STMT: VariableSetStmt +== 307 +-- Test Sort node reordering +EXPLAIN (COSTS OFF) +SELECT + lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), + lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) +FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 308 +-- Test incremental sorting +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT depname, + empno, + salary, + enroll_date, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) AS first_emp, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date DESC) AS last_emp + FROM empsalary) emp +WHERE first_emp = 1 OR last_emp = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="first_emp" +FILTER: schema="" table="" column="last_emp" +STMT: ExplainStmt +STMT: SelectStmt +== 309 +SELECT * FROM + (SELECT depname, + empno, + salary, + enroll_date, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) AS first_emp, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date DESC) AS last_emp + FROM empsalary) emp +WHERE first_emp = 1 OR last_emp = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="first_emp" +FILTER: schema="" table="" column="last_emp" +STMT: SelectStmt +== 310 +-- cleanup +DROP TABLE empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DDL +STMT: DropStmt +== 311 +-- test user-defined window function with named args and default args +CREATE FUNCTION nth_value_def(val anyelement, n integer = 1) RETURNS anyelement + LANGUAGE internal WINDOW IMMUTABLE STRICT AS 'window_nth_value' +-- +FUNCTION: name="nth_value_def" function="nth_value_def" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 312 +SELECT nth_value_def(n := 2, val := ten) OVER (PARTITION BY four), ten, four + FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten) s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nth_value_def" function="nth_value_def" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 313 +SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four + FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten) s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nth_value_def" function="nth_value_def" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +== 314 +|-- +-- Test the basic moving-aggregate machinery +|-- + +-- create aggregates that record the series of transform calls (these are +-- intentionally not true inverses) + +CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS +$$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$ +LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="logging_sfunc_nonstrict" function="logging_sfunc_nonstrict" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 315 +CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS +$$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$ +LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="logging_msfunc_nonstrict" function="logging_msfunc_nonstrict" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 316 +CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS +$$ SELECT $1 || '-' || quote_nullable($2) $$ +LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="logging_minvfunc_nonstrict" function="logging_minvfunc_nonstrict" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 317 +CREATE AGGREGATE logging_agg_nonstrict (anyelement) +( + stype = text, + sfunc = logging_sfunc_nonstrict, + mstype = text, + msfunc = logging_msfunc_nonstrict, + minvfunc = logging_minvfunc_nonstrict +) +-- +STMT: DefineStmt +== 318 +CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement) +( + stype = text, + sfunc = logging_sfunc_nonstrict, + mstype = text, + msfunc = logging_msfunc_nonstrict, + minvfunc = logging_minvfunc_nonstrict, + initcond = 'I', + minitcond = 'MI' +) +-- +STMT: DefineStmt +== 319 +CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS +$$ SELECT $1 || '*' || quote_nullable($2) $$ +LANGUAGE SQL STRICT IMMUTABLE +-- +FUNCTION: name="logging_sfunc_strict" function="logging_sfunc_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 320 +CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS +$$ SELECT $1 || '+' || quote_nullable($2) $$ +LANGUAGE SQL STRICT IMMUTABLE +-- +FUNCTION: name="logging_msfunc_strict" function="logging_msfunc_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 321 +CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS +$$ SELECT $1 || '-' || quote_nullable($2) $$ +LANGUAGE SQL STRICT IMMUTABLE +-- +FUNCTION: name="logging_minvfunc_strict" function="logging_minvfunc_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 322 +CREATE AGGREGATE logging_agg_strict (text) +( + stype = text, + sfunc = logging_sfunc_strict, + mstype = text, + msfunc = logging_msfunc_strict, + minvfunc = logging_minvfunc_strict +) +-- +STMT: DefineStmt +== 323 +CREATE AGGREGATE logging_agg_strict_initcond (anyelement) +( + stype = text, + sfunc = logging_sfunc_strict, + mstype = text, + msfunc = logging_msfunc_strict, + minvfunc = logging_minvfunc_strict, + initcond = 'I', + minitcond = 'MI' +) +-- +STMT: DefineStmt +== 324 +-- test strict and non-strict cases +SELECT + p::text || ',' || i::text || ':' || COALESCE(v::text, 'NULL') AS row, + logging_agg_nonstrict(v) over wnd as nstrict, + logging_agg_nonstrict_initcond(v) over wnd as nstrict_init, + logging_agg_strict(v::text) over wnd as strict, + logging_agg_strict_initcond(v) over wnd as strict_init +FROM (VALUES + (1, 1, NULL), + (1, 2, 'a'), + (1, 3, 'b'), + (1, 4, NULL), + (1, 5, NULL), + (1, 6, 'c'), + (2, 1, NULL), + (2, 2, 'x'), + (3, 1, 'z') +) AS t(p, i, v) +WINDOW wnd AS (PARTITION BY P ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +ORDER BY p, i +-- +FUNCTION: name="logging_agg_nonstrict" function="logging_agg_nonstrict" schema="" ctx=Call +FUNCTION: name="logging_agg_nonstrict_initcond" function="logging_agg_nonstrict_initcond" schema="" ctx=Call +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="logging_agg_strict_initcond" function="logging_agg_strict_initcond" schema="" ctx=Call +STMT: SelectStmt +== 325 +-- and again, but with filter +SELECT + p::text || ',' || i::text || ':' || + CASE WHEN f THEN COALESCE(v::text, 'NULL') ELSE '-' END as row, + logging_agg_nonstrict(v) filter(where f) over wnd as nstrict_filt, + logging_agg_nonstrict_initcond(v) filter(where f) over wnd as nstrict_init_filt, + logging_agg_strict(v::text) filter(where f) over wnd as strict_filt, + logging_agg_strict_initcond(v) filter(where f) over wnd as strict_init_filt +FROM (VALUES + (1, 1, true, NULL), + (1, 2, false, 'a'), + (1, 3, true, 'b'), + (1, 4, false, NULL), + (1, 5, false, NULL), + (1, 6, false, 'c'), + (2, 1, false, NULL), + (2, 2, true, 'x'), + (3, 1, true, 'z') +) AS t(p, i, f, v) +WINDOW wnd AS (PARTITION BY p ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +ORDER BY p, i +-- +FUNCTION: name="logging_agg_nonstrict" function="logging_agg_nonstrict" schema="" ctx=Call +FUNCTION: name="logging_agg_nonstrict_initcond" function="logging_agg_nonstrict_initcond" schema="" ctx=Call +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="logging_agg_strict_initcond" function="logging_agg_strict_initcond" schema="" ctx=Call +STMT: SelectStmt +== 326 +-- test that volatile arguments disable moving-aggregate mode +SELECT + i::text || ':' || COALESCE(v::text, 'NULL') as row, + logging_agg_strict(v::text) + over wnd as inverse, + logging_agg_strict(v::text || CASE WHEN random() < 0 then '?' ELSE '' END) + over wnd as noinverse +FROM (VALUES + (1, 'a'), + (2, 'b'), + (3, 'c') +) AS t(i, v) +WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +ORDER BY i +-- +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 327 +SELECT + i::text || ':' || COALESCE(v::text, 'NULL') as row, + logging_agg_strict(v::text) filter(where true) + over wnd as inverse, + logging_agg_strict(v::text) filter(where random() >= 0) + over wnd as noinverse +FROM (VALUES + (1, 'a'), + (2, 'b'), + (3, 'c') +) AS t(i, v) +WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +ORDER BY i +-- +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +== 328 +-- test that non-overlapping windows don't use inverse transitions +SELECT + logging_agg_strict(v::text) OVER wnd +FROM (VALUES + (1, 'a'), + (2, 'b'), + (3, 'c') +) AS t(i, v) +WINDOW wnd AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) +ORDER BY i +-- +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +STMT: SelectStmt +== 329 +-- test that returning NULL from the inverse transition functions +-- restarts the aggregation from scratch. The second aggregate is supposed +-- to test cases where only some aggregates restart, the third one checks +-- that one aggregate restarting doesn't cause others to restart. + +CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS +$$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$ +LANGUAGE SQL STRICT +-- +FUNCTION: name="sum_int_randrestart_minvfunc" function="sum_int_randrestart_minvfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 330 +CREATE AGGREGATE sum_int_randomrestart (int4) +( + stype = int4, + sfunc = int4pl, + mstype = int4, + msfunc = int4pl, + minvfunc = sum_int_randrestart_minvfunc +) +-- +STMT: DefineStmt +== 331 +WITH +vs AS ( + SELECT i, (random() * 100)::int4 AS v + FROM generate_series(1, 100) AS i +), +sum_following AS ( + SELECT i, SUM(v) OVER + (ORDER BY i DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS s + FROM vs +) +SELECT DISTINCT + sum_following.s = sum_int_randomrestart(v) OVER fwd AS eq1, + -sum_following.s = sum_int_randomrestart(-v) OVER fwd AS eq2, + 100*3+(vs.i-1)*3 = length(logging_agg_nonstrict(''::text) OVER fwd) AS eq3 +FROM vs +JOIN sum_following ON sum_following.i = vs.i +WINDOW fwd AS ( + ORDER BY vs.i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING +) +-- +CTE: "vs" +CTE: "sum_following" +FUNCTION: name="sum_int_randomrestart" function="sum_int_randomrestart" schema="" ctx=Call +FUNCTION: name="sum_int_randomrestart" function="sum_int_randomrestart" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="logging_agg_nonstrict" function="logging_agg_nonstrict" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 332 +|-- +-- Test various built-in aggregates that have moving-aggregate support +|-- + +-- test inverse transition functions handle NULLs properly +SELECT i,AVG(v::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 333 +SELECT i,AVG(v::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 334 +SELECT i,AVG(v::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 335 +SELECT i,AVG(v::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 336 +SELECT i,AVG(v::interval) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +== 337 +-- moving aggregates over infinite intervals +SELECT x + ,avg(x) OVER(ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING ) as curr_next_avg + ,avg(x) OVER(ROWS BETWEEN 1 PRECEDING AND CURRENT ROW ) as prev_curr_avg + ,sum(x) OVER(ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING ) as curr_next_sum + ,sum(x) OVER(ROWS BETWEEN 1 PRECEDING AND CURRENT ROW ) as prev_curr_sum +FROM (VALUES (NULL::interval), + ('infinity'::interval), + ('-2147483648 days -2147483648 months -9223372036854775807 usecs'), -- extreme interval value + ('-infinity'::interval), + ('2147483647 days 2147483647 months 9223372036854775806 usecs'), -- extreme interval value + ('infinity'::interval), + ('6 days'::interval), + ('7 days'::interval), + (NULL::interval), + ('-infinity'::interval)) v(x) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 338 +--should fail. +SELECT x, avg(x) OVER(ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) +FROM (VALUES (NULL::interval), + ('3 days'::interval), + ('infinity'::timestamptz - now()), + ('6 days'::interval), + ('-infinity'::interval)) v(x) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 339 +--should fail. +SELECT x, sum(x) OVER(ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) +FROM (VALUES (NULL::interval), + ('3 days'::interval), + ('infinity'::timestamptz - now()), + ('6 days'::interval), + ('-infinity'::interval)) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +== 340 +SELECT i,SUM(v::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 341 +SELECT i,SUM(v::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 342 +SELECT i,SUM(v::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 343 +SELECT i,SUM(v::money) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 344 +SELECT i,SUM(v::interval) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 345 +SELECT i,SUM(v::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 346 +SELECT SUM(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 347 +SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 348 +SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 349 +SELECT VAR_POP(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 350 +SELECT VAR_POP(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 351 +SELECT VAR_POP(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 352 +SELECT VAR_POP(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +== 353 +SELECT VAR_SAMP(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 354 +SELECT VAR_SAMP(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 355 +SELECT VAR_SAMP(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 356 +SELECT VAR_SAMP(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +== 357 +SELECT VARIANCE(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 358 +SELECT VARIANCE(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 359 +SELECT VARIANCE(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 360 +SELECT VARIANCE(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +== 361 +SELECT STDDEV_POP(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +== 362 +SELECT STDDEV_POP(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +== 363 +SELECT STDDEV_POP(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +== 364 +SELECT STDDEV_POP(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +== 365 +SELECT STDDEV_SAMP(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 366 +SELECT STDDEV_SAMP(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 367 +SELECT STDDEV_SAMP(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 368 +SELECT STDDEV_SAMP(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +== 369 +SELECT STDDEV(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +== 370 +SELECT STDDEV(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +== 371 +SELECT STDDEV(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +== 372 +SELECT STDDEV(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +== 373 +-- test that inverse transition functions work with various frame options +SELECT i,SUM(v::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 374 +SELECT i,SUM(v::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 375 +SELECT i,SUM(v::int) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 376 +-- ensure aggregate over numeric properly recovers from NaN values +SELECT a, b, + SUM(b) OVER(ORDER BY A ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +FROM (VALUES(1,1::numeric),(2,2),(3,'NaN'),(4,3),(5,4)) t(a,b) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 377 +-- It might be tempting for someone to add an inverse trans function for +-- float and double precision. This should not be done as it can give incorrect +-- results. This test should fail if anyone ever does this without thinking too +-- hard about it. +SELECT to_char(SUM(n::float8) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING),'999999999999999999999D9') + FROM (VALUES(1,1e20),(2,1)) n(i,n) +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 378 +SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w + FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) + WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) +-- +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +== 379 +|-- +-- Test WindowAgg costing takes into account the number of rows that need to +-- be fetched before the first row can be output. +|-- + +-- Ensure we get a cheap start up plan as the WindowAgg can output the first +-- row after reading 1 row from the join. +EXPLAIN (COSTS OFF) +SELECT COUNT(*) OVER (ORDER BY t1.unique1) +FROM tenk1 t1 INNER JOIN tenk1 t2 ON t1.unique1 = t2.tenthous +LIMIT 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 380 +-- Ensure we get a cheap total plan. Lack of ORDER BY in the WindowClause +-- means that all rows must be read from the join, so a cheap startup plan +-- isn't a good choice. +EXPLAIN (COSTS OFF) +SELECT COUNT(*) OVER () +FROM tenk1 t1 INNER JOIN tenk1 t2 ON t1.unique1 = t2.tenthous +WHERE t2.two = 1 +LIMIT 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t2" column="two" +STMT: ExplainStmt +STMT: SelectStmt +== 381 +-- Ensure we get a cheap total plan. This time use UNBOUNDED FOLLOWING, which +-- needs to read all join rows to output the first WindowAgg row. +EXPLAIN (COSTS OFF) +SELECT COUNT(*) OVER (ORDER BY t1.unique1 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) +FROM tenk1 t1 INNER JOIN tenk1 t2 ON t1.unique1 = t2.tenthous +LIMIT 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 382 +-- Ensure we get a cheap total plan. This time use 10000 FOLLOWING so we need +-- to read all join rows. +EXPLAIN (COSTS OFF) +SELECT COUNT(*) OVER (ORDER BY t1.unique1 ROWS BETWEEN UNBOUNDED PRECEDING AND 10000 FOLLOWING) +FROM tenk1 t1 INNER JOIN tenk1 t2 ON t1.unique1 = t2.tenthous +LIMIT 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 383 +-- Tests for problems with failure to walk or mutate expressions +-- within window frame clauses. + +-- test walker (fails with collation error if expressions are not walked) +SELECT array_agg(i) OVER w + FROM generate_series(1,5) i +WINDOW w AS (ORDER BY i ROWS BETWEEN (('foo' < 'foobar')::integer) PRECEDING AND CURRENT ROW) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 384 +-- test mutator (fails when inlined if expressions are not mutated) +CREATE FUNCTION pg_temp.f(group_size BIGINT) RETURNS SETOF integer[] +AS $$ + SELECT array_agg(s) OVER w + FROM generate_series(1,5) s + WINDOW w AS (ORDER BY s ROWS BETWEEN CURRENT ROW AND GROUP_SIZE FOLLOWING) +$$ LANGUAGE SQL STABLE +-- +FUNCTION: name="pg_temp.f" function="f" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +== 385 +EXPLAIN (costs off) SELECT * FROM pg_temp.f(2) +-- +FUNCTION: name="pg_temp.f" function="f" schema="pg_temp" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 386 +SELECT * FROM pg_temp.f(2) +-- +FUNCTION: name="pg_temp.f" function="f" schema="pg_temp" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/with.metadata.json b/parser/testdata/summary/postgres_regress/with.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/with.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/with.test b/parser/testdata/summary/postgres_regress/with.test new file mode 100644 index 0000000..a558ffb --- /dev/null +++ b/parser/testdata/summary/postgres_regress/with.test @@ -0,0 +1,3310 @@ +== 001 +|-- +-- Tests for common table expressions (WITH query, ... SELECT ...) +|-- + +-- Basic WITH +WITH q1(x,y) AS (SELECT 1,2) +SELECT * FROM q1, q1 AS q2 +-- +ALIAS: "q2"="q1" +CTE: "q1" +STMT: SelectStmt +== 002 +-- Multiple uses are evaluated only once +SELECT count(*) FROM ( + WITH q1(x) AS (SELECT random() FROM generate_series(1, 5)) + SELECT * FROM q1 + UNION + SELECT * FROM q1 +) ss +-- +CTE: "q1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +== 003 +-- WITH RECURSIVE + +-- sum of 1..100 +WITH RECURSIVE t(n) AS ( + VALUES (1) +UNION ALL + SELECT n+1 FROM t WHERE n < 100 +) +SELECT sum(n) FROM t +-- +CTE: "t" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 004 +WITH RECURSIVE t(n) AS ( + SELECT (VALUES(1)) +UNION ALL + SELECT n+1 FROM t WHERE n < 5 +) +SELECT * FROM t +-- +CTE: "t" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 005 +-- UNION DISTINCT requires hashable type +WITH RECURSIVE t(n) AS ( + VALUES ('01'::varbit) +UNION + SELECT n || '10'::varbit FROM t WHERE n < '100'::varbit +) +SELECT n FROM t +-- +CTE: "t" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 006 +-- recursive view +CREATE RECURSIVE VIEW nums (n) AS + VALUES (1) +UNION ALL + SELECT n+1 FROM nums WHERE n < 5 +-- +CTE: "nums" +FILTER: schema="" table="" column="n" +STMT: ViewStmt +STMT: SelectStmt +== 007 +SELECT * FROM nums +-- +TABLE: name="nums" schema="" table="nums" ctx=Select +STMT: SelectStmt +== 008 +CREATE OR REPLACE RECURSIVE VIEW nums (n) AS + VALUES (1) +UNION ALL + SELECT n+1 FROM nums WHERE n < 6 +-- +CTE: "nums" +FILTER: schema="" table="" column="n" +STMT: ViewStmt +STMT: SelectStmt +== 009 +SELECT * FROM nums +-- +TABLE: name="nums" schema="" table="nums" ctx=Select +STMT: SelectStmt +== 010 +-- This is an infinite loop with UNION ALL, but not with UNION +WITH RECURSIVE t(n) AS ( + SELECT 1 +UNION + SELECT 10-n FROM t) +SELECT * FROM t +-- +CTE: "t" +STMT: SelectStmt +== 011 +-- This'd be an infinite loop, but outside query reads only as much as needed +WITH RECURSIVE t(n) AS ( + VALUES (1) +UNION ALL + SELECT n+1 FROM t) +SELECT * FROM t LIMIT 10 +-- +CTE: "t" +STMT: SelectStmt +== 012 +-- UNION case should have same property +WITH RECURSIVE t(n) AS ( + SELECT 1 +UNION + SELECT n+1 FROM t) +SELECT * FROM t LIMIT 10 +-- +CTE: "t" +STMT: SelectStmt +== 013 +-- Test behavior with an unknown-type literal in the WITH +WITH q AS (SELECT 'foo' AS x) +SELECT x, pg_typeof(x) FROM q +-- +CTE: "q" +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +== 014 +WITH RECURSIVE t(n) AS ( + SELECT 'foo' +UNION ALL + SELECT n || ' bar' FROM t WHERE length(n) < 20 +) +SELECT n, pg_typeof(n) FROM t +-- +CTE: "t" +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 015 +-- In a perfect world, this would work and resolve the literal as int ... +-- but for now, we have to be content with resolving to text too soon. +WITH RECURSIVE t(n) AS ( + SELECT '7' +UNION ALL + SELECT n+1 FROM t WHERE n < 10 +) +SELECT n, pg_typeof(n) FROM t +-- +CTE: "t" +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 016 +-- Deeply nested WITH caused a list-munging problem in v13 +-- Detection of cross-references and self-references +WITH RECURSIVE w1(c1) AS + (WITH w2(c2) AS + (WITH w3(c3) AS + (WITH w4(c4) AS + (WITH w5(c5) AS + (WITH RECURSIVE w6(c6) AS + (WITH w6(c6) AS + (WITH w8(c8) AS + (SELECT 1) + SELECT * FROM w8) + SELECT * FROM w6) + SELECT * FROM w6) + SELECT * FROM w5) + SELECT * FROM w4) + SELECT * FROM w3) + SELECT * FROM w2) +SELECT * FROM w1 +-- +CTE: "w1" +CTE: "w2" +CTE: "w3" +CTE: "w4" +CTE: "w5" +CTE: "w6" +CTE: "w6" +CTE: "w8" +STMT: SelectStmt +== 017 +-- Detection of invalid self-references +WITH RECURSIVE outermost(x) AS ( + SELECT 1 + UNION (WITH innermost1 AS ( + SELECT 2 + UNION (WITH innermost2 AS ( + SELECT 3 + UNION (WITH innermost3 AS ( + SELECT 4 + UNION (WITH innermost4 AS ( + SELECT 5 + UNION (WITH innermost5 AS ( + SELECT 6 + UNION (WITH innermost6 AS + (SELECT 7) + SELECT * FROM innermost6)) + SELECT * FROM innermost5)) + SELECT * FROM innermost4)) + SELECT * FROM innermost3)) + SELECT * FROM innermost2)) + SELECT * FROM outermost + UNION SELECT * FROM innermost1) + ) + SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost1" +CTE: "innermost2" +CTE: "innermost3" +CTE: "innermost4" +CTE: "innermost5" +CTE: "innermost6" +STMT: SelectStmt +== 018 +|-- +-- Some examples with a tree +|-- +-- department structure represented here is as follows: +|-- +-- ROOT-+->A-+->B-+->C +-- | | +-- | +->D-+->F +-- +->E-+->G + +CREATE TEMP TABLE department ( + id INTEGER PRIMARY KEY, -- department ID + parent_department INTEGER REFERENCES department, -- upper department ID + name TEXT -- department name +) +-- +TABLE: name="department" schema="" table="department" ctx=DDL +STMT: CreateStmt +== 019 +INSERT INTO department VALUES (0, NULL, 'ROOT') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 020 +INSERT INTO department VALUES (1, 0, 'A') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 021 +INSERT INTO department VALUES (2, 1, 'B') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 022 +INSERT INTO department VALUES (3, 2, 'C') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 023 +INSERT INTO department VALUES (4, 2, 'D') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 024 +INSERT INTO department VALUES (5, 0, 'E') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 025 +INSERT INTO department VALUES (6, 4, 'F') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 026 +INSERT INTO department VALUES (7, 5, 'G') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 027 +-- extract all departments under 'A'. Result should be A, B, C, D and F +WITH RECURSIVE subdepartment AS +( + -- non recursive term + SELECT name as root_name, * FROM department WHERE name = 'A' + + UNION ALL + + -- recursive term + SELECT sd.root_name, d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id +) +SELECT * FROM subdepartment ORDER BY name +-- +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +ALIAS: "d"="department" +ALIAS: "sd"="subdepartment" +CTE: "subdepartment" +FILTER: schema="" table="" column="name" +FILTER: schema="" table="d" column="parent_department" +FILTER: schema="" table="sd" column="id" +STMT: SelectStmt +== 028 +-- extract all departments under 'A' with "level" number +WITH RECURSIVE subdepartment(level, id, parent_department, name) AS +( + -- non recursive term + SELECT 1, * FROM department WHERE name = 'A' + + UNION ALL + + -- recursive term + SELECT sd.level + 1, d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id +) +SELECT * FROM subdepartment ORDER BY name +-- +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +ALIAS: "d"="department" +ALIAS: "sd"="subdepartment" +CTE: "subdepartment" +FILTER: schema="" table="" column="name" +FILTER: schema="" table="d" column="parent_department" +FILTER: schema="" table="sd" column="id" +STMT: SelectStmt +== 029 +-- extract all departments under 'A' with "level" number. +-- Only shows level 2 or more +WITH RECURSIVE subdepartment(level, id, parent_department, name) AS +( + -- non recursive term + SELECT 1, * FROM department WHERE name = 'A' + + UNION ALL + + -- recursive term + SELECT sd.level + 1, d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id +) +SELECT * FROM subdepartment WHERE level >= 2 ORDER BY name +-- +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +ALIAS: "d"="department" +ALIAS: "sd"="subdepartment" +CTE: "subdepartment" +FILTER: schema="" table="" column="level" +FILTER: schema="" table="" column="name" +FILTER: schema="" table="d" column="parent_department" +FILTER: schema="" table="sd" column="id" +STMT: SelectStmt +== 030 +-- "RECURSIVE" is ignored if the query has no self-reference +WITH RECURSIVE subdepartment AS +( + -- note lack of recursive UNION structure + SELECT * FROM department WHERE name = 'A' +) +SELECT * FROM subdepartment ORDER BY name +-- +TABLE: name="department" schema="" table="department" ctx=Select +CTE: "subdepartment" +FILTER: schema="" table="" column="name" +STMT: SelectStmt +== 031 +-- inside subqueries +SELECT count(*) FROM ( + WITH RECURSIVE t(n) AS ( + SELECT 1 UNION ALL SELECT n + 1 FROM t WHERE n < 500 + ) + SELECT * FROM t) AS t WHERE n < ( + SELECT count(*) FROM ( + WITH RECURSIVE t(n) AS ( + SELECT 1 UNION ALL SELECT n + 1 FROM t WHERE n < 100 + ) + SELECT * FROM t WHERE n < 50000 + ) AS t WHERE n < 100) +-- +CTE: "t" +CTE: "t" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="n" +FILTER: schema="" table="" column="n" +FILTER: schema="" table="" column="n" +FILTER: schema="" table="" column="n" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 032 +-- use same CTE twice at different subquery levels +WITH q1(x,y) AS ( + SELECT hundred, sum(ten) FROM tenk1 GROUP BY hundred + ) +SELECT count(*) FROM q1 WHERE y > (SELECT sum(y)/100 FROM q1 qsub) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "qsub"="q1" +CTE: "q1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="y" +STMT: SelectStmt +== 033 +-- via a VIEW +CREATE TEMPORARY VIEW vsubdepartment AS + WITH RECURSIVE subdepartment AS + ( + -- non recursive term + SELECT * FROM department WHERE name = 'A' + UNION ALL + -- recursive term + SELECT d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id + ) + SELECT * FROM subdepartment +-- +TABLE: name="vsubdepartment" schema="" table="vsubdepartment" ctx=DDL +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +ALIAS: "d"="department" +ALIAS: "sd"="subdepartment" +CTE: "subdepartment" +FILTER: schema="" table="" column="name" +FILTER: schema="" table="d" column="parent_department" +FILTER: schema="" table="sd" column="id" +STMT: ViewStmt +STMT: SelectStmt +== 034 +SELECT * FROM vsubdepartment ORDER BY name +-- +TABLE: name="vsubdepartment" schema="" table="vsubdepartment" ctx=Select +STMT: SelectStmt +== 035 +-- Check reverse listing +SELECT pg_get_viewdef('vsubdepartment'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 036 +SELECT pg_get_viewdef('vsubdepartment'::regclass, true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 037 +-- Another reverse-listing example +CREATE VIEW sums_1_100 AS +WITH RECURSIVE t(n) AS ( + VALUES (1) +UNION ALL + SELECT n+1 FROM t WHERE n < 100 +) +SELECT sum(n) FROM t +-- +TABLE: name="sums_1_100" schema="" table="sums_1_100" ctx=DDL +CTE: "t" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="n" +STMT: ViewStmt +STMT: SelectStmt +== 038 +-- corner case in which sub-WITH gets initialized first +with recursive q as ( + select * from department + union all + (with x as (select * from q) + select * from x) + ) +select * from q limit 24 +-- +TABLE: name="department" schema="" table="department" ctx=Select +CTE: "q" +CTE: "x" +STMT: SelectStmt +== 039 +with recursive q as ( + select * from department + union all + (with recursive x as ( + select * from department + union all + (select * from q union all select * from x) + ) + select * from x) + ) +select * from q limit 32 +-- +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +CTE: "q" +CTE: "x" +STMT: SelectStmt +== 040 +-- recursive term has sub-UNION +WITH RECURSIVE t(i,j) AS ( + VALUES (1,2) + UNION ALL + SELECT t2.i, t.j+1 FROM + (SELECT 2 AS i UNION ALL SELECT 3 AS i) AS t2 + JOIN t ON (t2.i = t.i+1)) + + SELECT * FROM t +-- +CTE: "t" +STMT: SelectStmt +== 041 +|-- +-- different tree example +|-- +CREATE TEMPORARY TABLE tree( + id INTEGER PRIMARY KEY, + parent_id INTEGER REFERENCES tree(id) +) +-- +TABLE: name="tree" schema="" table="tree" ctx=DDL +STMT: CreateStmt +== 042 +INSERT INTO tree +VALUES (1, NULL), (2, 1), (3,1), (4,2), (5,2), (6,2), (7,3), (8,3), + (9,4), (10,4), (11,7), (12,7), (13,7), (14, 9), (15,11), (16,11) +-- +TABLE: name="tree" schema="" table="tree" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 043 +|-- +-- get all paths from "second level" nodes to leaf nodes +|-- +WITH RECURSIVE t(id, path) AS ( + VALUES(1,ARRAY[]::integer[]) +UNION ALL + SELECT tree.id, t.path || tree.id + FROM tree JOIN t ON (tree.parent_id = t.id) +) +SELECT t1.*, t2.* FROM t AS t1 JOIN t AS t2 ON + (t1.path[1] = t2.path[1] AND + array_upper(t1.path,1) = 1 AND + array_upper(t2.path,1) > 1) + ORDER BY t1.id, t2.id +-- +TABLE: name="tree" schema="" table="tree" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +CTE: "t" +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +STMT: SelectStmt +== 044 +-- just count 'em +WITH RECURSIVE t(id, path) AS ( + VALUES(1,ARRAY[]::integer[]) +UNION ALL + SELECT tree.id, t.path || tree.id + FROM tree JOIN t ON (tree.parent_id = t.id) +) +SELECT t1.id, count(t2.*) FROM t AS t1 JOIN t AS t2 ON + (t1.path[1] = t2.path[1] AND + array_upper(t1.path,1) = 1 AND + array_upper(t2.path,1) > 1) + GROUP BY t1.id + ORDER BY t1.id +-- +TABLE: name="tree" schema="" table="tree" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +CTE: "t" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +STMT: SelectStmt +== 045 +-- this variant tickled a whole-row-variable bug in 8.4devel +WITH RECURSIVE t(id, path) AS ( + VALUES(1,ARRAY[]::integer[]) +UNION ALL + SELECT tree.id, t.path || tree.id + FROM tree JOIN t ON (tree.parent_id = t.id) +) +SELECT t1.id, t2.path, t2 FROM t AS t1 JOIN t AS t2 ON +(t1.id=t2.id) +-- +TABLE: name="tree" schema="" table="tree" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +CTE: "t" +STMT: SelectStmt +== 046 +CREATE TEMP TABLE duplicates (a INT NOT NULL) +-- +TABLE: name="duplicates" schema="" table="duplicates" ctx=DDL +STMT: CreateStmt +== 047 +INSERT INTO duplicates VALUES(1), (1) +-- +TABLE: name="duplicates" schema="" table="duplicates" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +-- Try out a recursive UNION case where the non-recursive part's table slot +-- uses TTSOpsBufferHeapTuple and contains duplicate rows. +WITH RECURSIVE cte (a) as ( + SELECT a FROM duplicates + UNION + SELECT a FROM cte +) +SELECT a FROM cte +-- +TABLE: name="duplicates" schema="" table="duplicates" ctx=Select +CTE: "cte" +STMT: SelectStmt +== 049 +-- test that column statistics from a materialized CTE are available +-- to upper planner (otherwise, we'd get a stupider plan) +explain (costs off) +with x as materialized (select unique1 from tenk1 b) +select count(*) from tenk1 a + where unique1 in (select * from x) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +CTE: "x" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 050 +explain (costs off) +with x as materialized (insert into tenk1 default values returning unique1) +select count(*) from tenk1 a + where unique1 in (select * from x) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=DML +ALIAS: "a"="tenk1" +CTE: "x" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +STMT: InsertStmt +== 051 +-- test that pathkeys from a materialized CTE are propagated up to the +-- outer query +explain (costs off) +with x as materialized (select unique1 from tenk1 b order by unique1) +select count(*) from tenk1 a + where unique1 in (select * from x) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +CTE: "x" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +== 052 +-- SEARCH clause + +create temp table graph0( f int, t int, label text ) +-- +TABLE: name="graph0" schema="" table="graph0" ctx=DDL +STMT: CreateStmt +== 053 +insert into graph0 values + (1, 2, 'arc 1 -> 2'), + (1, 3, 'arc 1 -> 3'), + (2, 3, 'arc 2 -> 3'), + (1, 4, 'arc 1 -> 4'), + (4, 5, 'arc 4 -> 5') +-- +TABLE: name="graph0" schema="" table="graph0" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 054 +explain (verbose, costs off) +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 055 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 056 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union distinct + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 057 +explain (verbose, costs off) +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search breadth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 058 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search breadth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 059 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union distinct + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search breadth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 060 +-- a constant initial value causes issues for EXPLAIN +explain (verbose, costs off) +with recursive test as ( + select 1 as x + union all + select x + 1 + from test +) search depth first by x set y +select * from test limit 5 +-- +CTE: "test" +STMT: ExplainStmt +STMT: SelectStmt +== 061 +with recursive test as ( + select 1 as x + union all + select x + 1 + from test +) search depth first by x set y +select * from test limit 5 +-- +CTE: "test" +STMT: SelectStmt +== 062 +explain (verbose, costs off) +with recursive test as ( + select 1 as x + union all + select x + 1 + from test +) search breadth first by x set y +select * from test limit 5 +-- +CTE: "test" +STMT: ExplainStmt +STMT: SelectStmt +== 063 +with recursive test as ( + select 1 as x + union all + select x + 1 + from test +) search breadth first by x set y +select * from test limit 5 +-- +CTE: "test" +STMT: SelectStmt +== 064 +-- various syntax errors +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by foo, tar set seq +select * from search_graph +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 065 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set label +select * from search_graph +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 066 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t, f set seq +select * from search_graph +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 067 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 068 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + (select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t) +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 069 +-- check that we distinguish same CTE name used at different levels +-- (this case could be supported, perhaps, but it isn't today) +with recursive x(col) as ( + select 1 + union + (with x as (select * from x) + select * from x) +) search depth first by col set seq +select * from x +-- +CTE: "x" +CTE: "x" +STMT: SelectStmt +== 070 +-- test ruleutils and view expansion +create temp view v_search as +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select f, t, label from search_graph +-- +TABLE: name="v_search" schema="" table="v_search" ctx=DDL +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ViewStmt +STMT: SelectStmt +== 071 +select pg_get_viewdef('v_search') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 072 +select * from v_search +-- +TABLE: name="v_search" schema="" table="v_search" ctx=Select +STMT: SelectStmt +== 073 +|-- +-- test cycle detection +|-- +create temp table graph( f int, t int, label text ) +-- +TABLE: name="graph" schema="" table="graph" ctx=DDL +STMT: CreateStmt +== 074 +insert into graph values + (1, 2, 'arc 1 -> 2'), + (1, 3, 'arc 1 -> 3'), + (2, 3, 'arc 2 -> 3'), + (1, 4, 'arc 1 -> 4'), + (4, 5, 'arc 4 -> 5'), + (5, 1, 'arc 5 -> 1') +-- +TABLE: name="graph" schema="" table="graph" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 075 +with recursive search_graph(f, t, label, is_cycle, path) as ( + select *, false, array[row(g.f, g.t)] from graph g + union all + select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) + from graph g, search_graph sg + where g.f = sg.t and not is_cycle +) +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +FILTER: schema="" table="" column="is_cycle" +STMT: SelectStmt +== 076 +-- UNION DISTINCT exercises row type hashing support +with recursive search_graph(f, t, label, is_cycle, path) as ( + select *, false, array[row(g.f, g.t)] from graph g + union distinct + select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) + from graph g, search_graph sg + where g.f = sg.t and not is_cycle +) +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +FILTER: schema="" table="" column="is_cycle" +STMT: SelectStmt +== 077 +-- ordering by the path column has same effect as SEARCH DEPTH FIRST +with recursive search_graph(f, t, label, is_cycle, path) as ( + select *, false, array[row(g.f, g.t)] from graph g + union all + select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) + from graph g, search_graph sg + where g.f = sg.t and not is_cycle +) +select * from search_graph order by path +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +FILTER: schema="" table="" column="is_cycle" +STMT: SelectStmt +== 078 +-- CYCLE clause + +explain (verbose, costs off) +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ExplainStmt +STMT: SelectStmt +== 079 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 080 +with recursive search_graph(f, t, label) as ( + select * from graph g + union distinct + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to 'Y' default 'N' using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 081 +explain (verbose, costs off) +with recursive test as ( + select 0 as x + union all + select (x + 1) % 10 + from test +) cycle x set is_cycle using path +select * from test +-- +CTE: "test" +STMT: ExplainStmt +STMT: SelectStmt +== 082 +with recursive test as ( + select 0 as x + union all + select (x + 1) % 10 + from test +) cycle x set is_cycle using path +select * from test +-- +CTE: "test" +STMT: SelectStmt +== 083 +with recursive test as ( + select 0 as x + union all + select (x + 1) % 10 + from test + where not is_cycle -- redundant, but legal +) cycle x set is_cycle using path +select * from test +-- +CTE: "test" +FILTER: schema="" table="" column="is_cycle" +STMT: SelectStmt +== 084 +-- multiple CTEs +with recursive +graph(f, t, label) as ( + values (1, 2, 'arc 1 -> 2'), + (1, 3, 'arc 1 -> 3'), + (2, 3, 'arc 2 -> 3'), + (1, 4, 'arc 1 -> 4'), + (4, 5, 'arc 4 -> 5'), + (5, 1, 'arc 5 -> 1') +), +search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to true default false using path +select f, t, label from search_graph +-- +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 085 +-- star expansion +with recursive a as ( + select 1 as b + union all + select * from a +) cycle b set c using p +select * from a +-- +CTE: "a" +STMT: SelectStmt +== 086 +-- search+cycle +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq + cycle f, t set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 087 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) search breadth first by f, t set seq + cycle f, t set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 088 +-- various syntax errors +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle foo, tar set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 089 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to true default 55 using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 090 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to point '(1,1)' default point '(0,0)' using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 091 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set label to true default false using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 092 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to true default false using label +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 093 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set foo to true default false using foo +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 094 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t, f set is_cycle to true default false using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 095 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) search depth first by f, t set foo + cycle f, t set foo to true default false using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 096 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) search depth first by f, t set foo + cycle f, t set is_cycle to true default false using foo +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +== 097 +-- test ruleutils and view expansion +create temp view v_cycle1 as +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle using path +select f, t, label from search_graph +-- +TABLE: name="v_cycle1" schema="" table="v_cycle1" ctx=DDL +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ViewStmt +STMT: SelectStmt +== 098 +create temp view v_cycle2 as +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to 'Y' default 'N' using path +select f, t, label from search_graph +-- +TABLE: name="v_cycle2" schema="" table="v_cycle2" ctx=DDL +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ViewStmt +STMT: SelectStmt +== 099 +select pg_get_viewdef('v_cycle1') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 100 +select pg_get_viewdef('v_cycle2') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +== 101 +select * from v_cycle1 +-- +TABLE: name="v_cycle1" schema="" table="v_cycle1" ctx=Select +STMT: SelectStmt +== 102 +select * from v_cycle2 +-- +TABLE: name="v_cycle2" schema="" table="v_cycle2" ctx=Select +STMT: SelectStmt +== 103 +|-- +-- test multiple WITH queries +|-- +WITH RECURSIVE + y (id) AS (VALUES (1)), + x (id) AS (SELECT * FROM y UNION ALL SELECT id+1 FROM x WHERE id < 5) +SELECT * FROM x +-- +CTE: "y" +CTE: "x" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 104 +-- forward reference OK +WITH RECURSIVE + x(id) AS (SELECT * FROM y UNION ALL SELECT id+1 FROM x WHERE id < 5), + y(id) AS (values (1)) + SELECT * FROM x +-- +CTE: "x" +CTE: "y" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 105 +WITH RECURSIVE + x(id) AS + (VALUES (1) UNION ALL SELECT id+1 FROM x WHERE id < 5), + y(id) AS + (VALUES (1) UNION ALL SELECT id+1 FROM y WHERE id < 10) + SELECT y.*, x.* FROM y LEFT JOIN x USING (id) +-- +CTE: "x" +CTE: "y" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 106 +WITH RECURSIVE + x(id) AS + (VALUES (1) UNION ALL SELECT id+1 FROM x WHERE id < 5), + y(id) AS + (VALUES (1) UNION ALL SELECT id+1 FROM x WHERE id < 10) + SELECT y.*, x.* FROM y LEFT JOIN x USING (id) +-- +CTE: "x" +CTE: "y" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 107 +WITH RECURSIVE + x(id) AS + (SELECT 1 UNION ALL SELECT id+1 FROM x WHERE id < 3 ), + y(id) AS + (SELECT * FROM x UNION ALL SELECT * FROM x), + z(id) AS + (SELECT * FROM x UNION ALL SELECT id+1 FROM z WHERE id < 10) + SELECT * FROM z +-- +CTE: "x" +CTE: "y" +CTE: "z" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 108 +WITH RECURSIVE + x(id) AS + (SELECT 1 UNION ALL SELECT id+1 FROM x WHERE id < 3 ), + y(id) AS + (SELECT * FROM x UNION ALL SELECT * FROM x), + z(id) AS + (SELECT * FROM y UNION ALL SELECT id+1 FROM z WHERE id < 10) + SELECT * FROM z +-- +CTE: "x" +CTE: "y" +CTE: "z" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 109 +|-- +-- Test WITH attached to a data-modifying statement +|-- + +CREATE TEMPORARY TABLE y (a INTEGER) +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateStmt +== 110 +INSERT INTO y SELECT generate_series(1, 10) +-- +TABLE: name="y" schema="" table="y" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 111 +WITH t AS ( + SELECT a FROM y +) +INSERT INTO y +SELECT a+20 FROM t RETURNING * +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "t" +STMT: InsertStmt +STMT: SelectStmt +== 112 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 113 +WITH t AS ( + SELECT a FROM y +) +UPDATE y SET a = y.a-10 FROM t WHERE y.a > 20 AND t.a = y.a RETURNING y.a +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "t" +STMT: UpdateStmt +STMT: SelectStmt +== 114 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 115 +WITH RECURSIVE t(a) AS ( + SELECT 11 + UNION ALL + SELECT a+1 FROM t WHERE a < 50 +) +DELETE FROM y USING t WHERE t.a = y.a RETURNING y.a +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +FILTER: schema="" table="" column="a" +STMT: DeleteStmt +STMT: SelectStmt +== 116 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 117 +DROP TABLE y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +== 118 +|-- +-- error cases +|-- + +WITH x(n, b) AS (SELECT 1) +SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 119 +-- INTERSECT +WITH RECURSIVE x(n) AS (SELECT 1 INTERSECT SELECT n+1 FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 120 +WITH RECURSIVE x(n) AS (SELECT 1 INTERSECT ALL SELECT n+1 FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 121 +-- EXCEPT +WITH RECURSIVE x(n) AS (SELECT 1 EXCEPT SELECT n+1 FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 122 +WITH RECURSIVE x(n) AS (SELECT 1 EXCEPT ALL SELECT n+1 FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 123 +-- no non-recursive term +WITH RECURSIVE x(n) AS (SELECT n FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 124 +-- recursive term in the left hand side (strictly speaking, should allow this) +WITH RECURSIVE x(n) AS (SELECT n FROM x UNION ALL SELECT 1) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 125 +-- allow this, because we historically have +WITH RECURSIVE x(n) AS ( + WITH x1 AS (SELECT 1 AS n) + SELECT 0 + UNION + SELECT * FROM x1) + SELECT * FROM x +-- +CTE: "x" +CTE: "x1" +STMT: SelectStmt +== 126 +-- but this should be rejected +WITH RECURSIVE x(n) AS ( + WITH x1 AS (SELECT 1 FROM x) + SELECT 0 + UNION + SELECT * FROM x1) + SELECT * FROM x +-- +CTE: "x" +CTE: "x1" +STMT: SelectStmt +== 127 +-- and this too +WITH RECURSIVE x(n) AS ( + (WITH x1 AS (SELECT 1 FROM x) SELECT * FROM x1) + UNION + SELECT 0) + SELECT * FROM x +-- +CTE: "x" +CTE: "x1" +STMT: SelectStmt +== 128 +-- and this +WITH RECURSIVE x(n) AS ( + SELECT 0 UNION SELECT 1 + ORDER BY (SELECT n FROM x)) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 129 +-- and this +WITH RECURSIVE x(n) AS ( + WITH sub_cte AS (SELECT * FROM x) + DELETE FROM graph RETURNING f) + SELECT * FROM x +-- +TABLE: name="graph" schema="" table="graph" ctx=DML +CTE: "x" +CTE: "sub_cte" +STMT: SelectStmt +STMT: DeleteStmt +== 130 +CREATE TEMPORARY TABLE y (a INTEGER) +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateStmt +== 131 +INSERT INTO y SELECT generate_series(1, 10) +-- +TABLE: name="y" schema="" table="y" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 132 +-- LEFT JOIN + +WITH RECURSIVE x(n) AS (SELECT a FROM y WHERE a = 1 + UNION ALL + SELECT x.n+1 FROM y LEFT JOIN x ON x.n = y.a WHERE n < 10) +SELECT * FROM x +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 133 +-- RIGHT JOIN +WITH RECURSIVE x(n) AS (SELECT a FROM y WHERE a = 1 + UNION ALL + SELECT x.n+1 FROM x RIGHT JOIN y ON x.n = y.a WHERE n < 10) +SELECT * FROM x +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 134 +-- FULL JOIN +WITH RECURSIVE x(n) AS (SELECT a FROM y WHERE a = 1 + UNION ALL + SELECT x.n+1 FROM x FULL JOIN y ON x.n = y.a WHERE n < 10) +SELECT * FROM x +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 135 +-- subquery +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM x + WHERE n IN (SELECT * FROM x)) + SELECT * FROM x +-- +CTE: "x" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +== 136 +-- aggregate functions +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT count(*) FROM x) + SELECT * FROM x +-- +CTE: "x" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 137 +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT sum(n) FROM x) + SELECT * FROM x +-- +CTE: "x" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +== 138 +-- ORDER BY +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM x ORDER BY 1) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 139 +-- LIMIT/OFFSET +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM x LIMIT 10 OFFSET 1) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 140 +-- FOR UPDATE +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM x FOR UPDATE) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +== 141 +-- target list has a recursive query name +WITH RECURSIVE x(id) AS (values (1) + UNION ALL + SELECT (SELECT * FROM x) FROM x WHERE id < 5 +) SELECT * FROM x +-- +CTE: "x" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 142 +-- mutual recursive query (not implemented) +WITH RECURSIVE + x (id) AS (SELECT 1 UNION ALL SELECT id+1 FROM y WHERE id < 5), + y (id) AS (SELECT 1 UNION ALL SELECT id+1 FROM x WHERE id < 5) +SELECT * FROM x +-- +CTE: "x" +CTE: "y" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 143 +-- non-linear recursion is not allowed +WITH RECURSIVE foo(i) AS + (values (1) + UNION ALL + (SELECT i+1 FROM foo WHERE i < 10 + UNION ALL + SELECT i+1 FROM foo WHERE i < 5) +) SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 144 +WITH RECURSIVE foo(i) AS + (values (1) + UNION ALL + SELECT * FROM + (SELECT i+1 FROM foo WHERE i < 10 + UNION ALL + SELECT i+1 FROM foo WHERE i < 5) AS t +) SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 145 +WITH RECURSIVE foo(i) AS + (values (1) + UNION ALL + (SELECT i+1 FROM foo WHERE i < 10 + EXCEPT + SELECT i+1 FROM foo WHERE i < 5) +) SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 146 +WITH RECURSIVE foo(i) AS + (values (1) + UNION ALL + (SELECT i+1 FROM foo WHERE i < 10 + INTERSECT + SELECT i+1 FROM foo WHERE i < 5) +) SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 147 +-- Wrong type induced from non-recursive term +WITH RECURSIVE foo(i) AS + (SELECT i FROM (VALUES(1),(2)) t(i) + UNION ALL + SELECT (i+1)::numeric(10,0) FROM foo WHERE i < 10) +SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 148 +-- rejects different typmod, too (should we allow this?) +WITH RECURSIVE foo(i) AS + (SELECT i::numeric(3,0) FROM (VALUES(1),(2)) t(i) + UNION ALL + SELECT (i+1)::numeric(10,0) FROM foo WHERE i < 10) +SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +== 149 +-- disallow OLD/NEW reference in CTE +CREATE TEMPORARY TABLE x (n integer) +-- +TABLE: name="x" schema="" table="x" ctx=DDL +STMT: CreateStmt +== 150 +CREATE RULE r2 AS ON UPDATE TO x DO INSTEAD + WITH t AS (SELECT OLD.*) UPDATE y SET a = t.n FROM t +-- +TABLE: name="x" schema="" table="x" ctx=DDL +STMT: RuleStmt +== 151 +|-- +-- test for bug #4902 +|-- +with cte(foo) as ( values(42) ) values((select foo from cte)) +-- +CTE: "cte" +STMT: SelectStmt +== 152 +with cte(foo) as ( select 42 ) select * from ((select foo from cte)) q +-- +CTE: "cte" +STMT: SelectStmt +== 153 +-- test CTE referencing an outer-level variable (to see that changed-parameter +-- signaling still works properly after fixing this bug) +select ( with cte(foo) as ( values(f1) ) + select (select foo from cte) ) +from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "cte" +STMT: SelectStmt +== 154 +select ( with cte(foo) as ( values(f1) ) + values((select foo from cte)) ) +from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "cte" +STMT: SelectStmt +== 155 +|-- +-- test for bug #19055: interaction of WITH with aggregates +|-- +-- The reference to cte1 must determine the aggregate's level, +-- even though it contains no Vars referencing cte1 +explain (verbose, costs off) +select f1, (with cte1(x,y) as (select 1,2) + select count((select i4.f1 from cte1))) as ss +from int4_tbl i4 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +CTE: "cte1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 156 +select f1, (with cte1(x,y) as (select 1,2) + select count((select i4.f1 from cte1))) as ss +from int4_tbl i4 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +CTE: "cte1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +== 157 +|-- +-- test for nested-recursive-WITH bug +|-- +WITH RECURSIVE t(j) AS ( + WITH RECURSIVE s(i) AS ( + VALUES (1) + UNION ALL + SELECT i+1 FROM s WHERE i < 10 + ) + SELECT i FROM s + UNION ALL + SELECT j+1 FROM t WHERE j < 10 +) +SELECT * FROM t +-- +CTE: "t" +CTE: "s" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="j" +STMT: SelectStmt +== 158 +|-- +-- test WITH attached to intermediate-level set operation +|-- + +WITH outermost(x) AS ( + SELECT 1 + UNION (WITH innermost as (SELECT 2) + SELECT * FROM innermost + UNION SELECT 3) +) +SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost" +STMT: SelectStmt +== 159 +WITH outermost(x) AS ( + SELECT 1 + UNION (WITH innermost as (SELECT 2) + SELECT * FROM outermost -- fail + UNION SELECT * FROM innermost) +) +SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost" +STMT: SelectStmt +== 160 +WITH RECURSIVE outermost(x) AS ( + SELECT 1 + UNION (WITH innermost as (SELECT 2) + SELECT * FROM outermost + UNION SELECT * FROM innermost) +) +SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost" +STMT: SelectStmt +== 161 +WITH RECURSIVE outermost(x) AS ( + WITH innermost as (SELECT 2 FROM outermost) -- fail + SELECT * FROM innermost + UNION SELECT * from outermost +) +SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost" +STMT: SelectStmt +== 162 +|-- +-- This test will fail with the old implementation of PARAM_EXEC parameter +-- assignment, because the "q1" Var passed down to A's targetlist subselect +-- looks exactly like the "A.id" Var passed down to C's subselect, causing +-- the old code to give them the same runtime PARAM_EXEC slot. But the +-- lifespans of the two parameters overlap, thanks to B also reading A. +|-- + +with +A as ( select q2 as id, (select q1) as x from int8_tbl ), +B as ( select id, row_number() over (partition by id) as r from A ), +C as ( select A.id, array(select B.id from B where B.id = A.id) from A ) +select * from C +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +CTE: "a" +CTE: "b" +CTE: "c" +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="b" column="id" +FILTER: schema="" table="a" column="id" +STMT: SelectStmt +== 163 +|-- +-- Test CTEs read in non-initialization orders +|-- + +WITH RECURSIVE + tab(id_key,link) AS (VALUES (1,17), (2,17), (3,17), (4,17), (6,17), (5,17)), + iter (id_key, row_type, link) AS ( + SELECT 0, 'base', 17 + UNION ALL ( + WITH remaining(id_key, row_type, link, min) AS ( + SELECT tab.id_key, 'true'::text, iter.link, MIN(tab.id_key) OVER () + FROM tab INNER JOIN iter USING (link) + WHERE tab.id_key > iter.id_key + ), + first_remaining AS ( + SELECT id_key, row_type, link + FROM remaining + WHERE id_key=min + ), + effect AS ( + SELECT tab.id_key, 'new'::text, tab.link + FROM first_remaining e INNER JOIN tab ON e.id_key=tab.id_key + WHERE e.row_type = 'false' + ) + SELECT * FROM first_remaining + UNION ALL SELECT * FROM effect + ) + ) +SELECT * FROM iter +-- +ALIAS: "e"="first_remaining" +CTE: "tab" +CTE: "iter" +CTE: "remaining" +CTE: "first_remaining" +CTE: "effect" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="tab" column="id_key" +FILTER: schema="" table="iter" column="id_key" +FILTER: schema="" table="" column="id_key" +FILTER: schema="" table="" column="min" +FILTER: schema="" table="e" column="row_type" +STMT: SelectStmt +== 164 +WITH RECURSIVE + tab(id_key,link) AS (VALUES (1,17), (2,17), (3,17), (4,17), (6,17), (5,17)), + iter (id_key, row_type, link) AS ( + SELECT 0, 'base', 17 + UNION ( + WITH remaining(id_key, row_type, link, min) AS ( + SELECT tab.id_key, 'true'::text, iter.link, MIN(tab.id_key) OVER () + FROM tab INNER JOIN iter USING (link) + WHERE tab.id_key > iter.id_key + ), + first_remaining AS ( + SELECT id_key, row_type, link + FROM remaining + WHERE id_key=min + ), + effect AS ( + SELECT tab.id_key, 'new'::text, tab.link + FROM first_remaining e INNER JOIN tab ON e.id_key=tab.id_key + WHERE e.row_type = 'false' + ) + SELECT * FROM first_remaining + UNION ALL SELECT * FROM effect + ) + ) +SELECT * FROM iter +-- +ALIAS: "e"="first_remaining" +CTE: "tab" +CTE: "iter" +CTE: "remaining" +CTE: "first_remaining" +CTE: "effect" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="tab" column="id_key" +FILTER: schema="" table="iter" column="id_key" +FILTER: schema="" table="" column="id_key" +FILTER: schema="" table="" column="min" +FILTER: schema="" table="e" column="row_type" +STMT: SelectStmt +== 165 +|-- +-- Data-modifying statements in WITH +|-- + +-- INSERT ... RETURNING +WITH t AS ( + INSERT INTO y + VALUES + (11), + (12), + (13), + (14), + (15), + (16), + (17), + (18), + (19), + (20) + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 166 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 167 +-- UPDATE ... RETURNING +WITH t AS ( + UPDATE y + SET a=a+1 + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: UpdateStmt +== 168 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 169 +-- DELETE ... RETURNING +WITH t AS ( + DELETE FROM y + WHERE a <= 10 + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: DeleteStmt +== 170 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 171 +-- forward reference +WITH RECURSIVE t AS ( + INSERT INTO y + SELECT a+5 FROM t2 WHERE a > 5 + RETURNING * +), t2 AS ( + UPDATE y SET a=a-11 RETURNING * +) +SELECT * FROM t +UNION ALL +SELECT * FROM t2 +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +CTE: "t2" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +STMT: InsertStmt +STMT: UpdateStmt +== 172 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 173 +-- unconditional DO INSTEAD rule +CREATE RULE y_rule AS ON DELETE TO y DO INSTEAD + INSERT INTO y VALUES(42) RETURNING * +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +== 174 +WITH t AS ( + DELETE FROM y RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: DeleteStmt +== 175 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 176 +DROP RULE y_rule ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +== 177 +-- check merging of outer CTE with CTE in a rule action +CREATE TEMP TABLE bug6051 AS + select i from generate_series(1,3) as t(i) +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 178 +SELECT * FROM bug6051 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=Select +STMT: SelectStmt +== 179 +WITH t1 AS ( DELETE FROM bug6051 RETURNING * ) +INSERT INTO bug6051 SELECT * FROM t1 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +CTE: "t1" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +== 180 +SELECT * FROM bug6051 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=Select +STMT: SelectStmt +== 181 +CREATE TEMP TABLE bug6051_2 (i int) +-- +TABLE: name="bug6051_2" schema="" table="bug6051_2" ctx=DDL +STMT: CreateStmt +== 182 +CREATE RULE bug6051_ins AS ON INSERT TO bug6051 DO INSTEAD + INSERT INTO bug6051_2 + VALUES(NEW.i) +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DDL +STMT: RuleStmt +== 183 +WITH t1 AS ( DELETE FROM bug6051 RETURNING * ) +INSERT INTO bug6051 SELECT * FROM t1 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +CTE: "t1" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +== 184 +SELECT * FROM bug6051 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=Select +STMT: SelectStmt +== 185 +SELECT * FROM bug6051_2 +-- +TABLE: name="bug6051_2" schema="" table="bug6051_2" ctx=Select +STMT: SelectStmt +== 186 +-- check INSERT ... SELECT rule actions are disallowed on commands +-- that have modifyingCTEs +CREATE OR REPLACE RULE bug6051_ins AS ON INSERT TO bug6051 DO INSTEAD + INSERT INTO bug6051_2 + SELECT NEW.i +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DDL +STMT: RuleStmt +== 187 +WITH t1 AS ( DELETE FROM bug6051 RETURNING * ) +INSERT INTO bug6051 SELECT * FROM t1 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +CTE: "t1" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +== 188 +-- silly example to verify that hasModifyingCTE flag is propagated +CREATE TEMP TABLE bug6051_3 AS + SELECT a FROM generate_series(11,13) AS a +-- +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 189 +CREATE RULE bug6051_3_ins AS ON INSERT TO bug6051_3 DO INSTEAD + SELECT i FROM bug6051_2 +-- +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=DDL +STMT: RuleStmt +== 190 +BEGIN +-- +STMT: TransactionStmt +== 191 +SET LOCAL debug_parallel_query = on +-- +STMT: VariableSetStmt +== 192 +WITH t1 AS ( DELETE FROM bug6051_3 RETURNING * ) + INSERT INTO bug6051_3 SELECT * FROM t1 +-- +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=DML +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=DML +CTE: "t1" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +== 193 +COMMIT +-- +STMT: TransactionStmt +== 194 +SELECT * FROM bug6051_3 +-- +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=Select +STMT: SelectStmt +== 195 +-- check case where CTE reference is removed due to optimization +EXPLAIN (VERBOSE, COSTS OFF) +SELECT q1 FROM +( + WITH t_cte AS (SELECT * FROM int8_tbl t) + SELECT q1, (SELECT q2 FROM t_cte WHERE t_cte.q1 = i8.q1) AS t_sub + FROM int8_tbl i8 +) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="int8_tbl" +CTE: "t_cte" +FILTER: schema="" table="t_cte" column="q1" +FILTER: schema="" table="i8" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 196 +SELECT q1 FROM +( + WITH t_cte AS (SELECT * FROM int8_tbl t) + SELECT q1, (SELECT q2 FROM t_cte WHERE t_cte.q1 = i8.q1) AS t_sub + FROM int8_tbl i8 +) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="int8_tbl" +CTE: "t_cte" +FILTER: schema="" table="t_cte" column="q1" +FILTER: schema="" table="i8" column="q1" +STMT: SelectStmt +== 197 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT q1 FROM +( + WITH t_cte AS MATERIALIZED (SELECT * FROM int8_tbl t) + SELECT q1, (SELECT q2 FROM t_cte WHERE t_cte.q1 = i8.q1) AS t_sub + FROM int8_tbl i8 +) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="int8_tbl" +CTE: "t_cte" +FILTER: schema="" table="t_cte" column="q1" +FILTER: schema="" table="i8" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +== 198 +SELECT q1 FROM +( + WITH t_cte AS MATERIALIZED (SELECT * FROM int8_tbl t) + SELECT q1, (SELECT q2 FROM t_cte WHERE t_cte.q1 = i8.q1) AS t_sub + FROM int8_tbl i8 +) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="int8_tbl" +CTE: "t_cte" +FILTER: schema="" table="t_cte" column="q1" +FILTER: schema="" table="i8" column="q1" +STMT: SelectStmt +== 199 +-- a truly recursive CTE in the same list +WITH RECURSIVE t(a) AS ( + SELECT 0 + UNION ALL + SELECT a+1 FROM t WHERE a+1 < 5 +), t2 as ( + INSERT INTO y + SELECT * FROM t RETURNING * +) +SELECT * FROM t2 JOIN y USING (a) ORDER BY a +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +CTE: "t2" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +STMT: InsertStmt +== 200 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 201 +-- data-modifying WITH in a modifying statement +WITH t AS ( + DELETE FROM y + WHERE a <= 10 + RETURNING * +) +INSERT INTO y SELECT -a FROM t RETURNING * +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +== 202 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 203 +-- check that WITH query is run to completion even if outer query isn't +WITH t AS ( + UPDATE y SET a = a * 100 RETURNING * +) +SELECT * FROM t LIMIT 10 +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: UpdateStmt +== 204 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 205 +-- data-modifying WITH containing INSERT...ON CONFLICT DO UPDATE +CREATE TABLE withz AS SELECT i AS k, (i || ' v')::text v FROM generate_series(1, 16, 3) i +-- +TABLE: name="withz" schema="" table="withz" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 206 +ALTER TABLE withz ADD UNIQUE (k) +-- +TABLE: name="withz" schema="" table="withz" ctx=DDL +STMT: AlterTableStmt +== 207 +WITH t AS ( + INSERT INTO withz SELECT i, 'insert' + FROM generate_series(0, 16) i + ON CONFLICT (k) DO UPDATE SET v = withz.v || ', now update' + RETURNING * +) +SELECT * FROM t JOIN y ON t.k = y.a ORDER BY a, k +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "t" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +STMT: InsertStmt +== 208 +-- Test EXCLUDED.* reference within CTE +WITH aa AS ( + INSERT INTO withz VALUES(1, 5) ON CONFLICT (k) DO UPDATE SET v = EXCLUDED.v + WHERE withz.k != EXCLUDED.k + RETURNING * +) +SELECT * FROM aa +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +STMT: SelectStmt +STMT: InsertStmt +== 209 +-- New query/snapshot demonstrates side-effects of previous query. +SELECT * FROM withz ORDER BY k +-- +TABLE: name="withz" schema="" table="withz" ctx=Select +STMT: SelectStmt +== 210 +|-- +-- Ensure subqueries within the update clause work, even if they +-- reference outside values +|-- +WITH aa AS (SELECT 1 a, 2 b) +INSERT INTO withz VALUES(1, 'insert') +ON CONFLICT (k) DO UPDATE SET v = (SELECT b || ' update' FROM aa WHERE a = 1 LIMIT 1) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 211 +WITH aa AS (SELECT 1 a, 2 b) +INSERT INTO withz VALUES(1, 'insert') +ON CONFLICT (k) DO UPDATE SET v = ' update' WHERE withz.k = (SELECT a FROM aa) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +STMT: InsertStmt +STMT: SelectStmt +== 212 +WITH aa AS (SELECT 1 a, 2 b) +INSERT INTO withz VALUES(1, 'insert') +ON CONFLICT (k) DO UPDATE SET v = (SELECT b || ' update' FROM aa WHERE a = 1 LIMIT 1) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 213 +WITH aa AS (SELECT 'a' a, 'b' b UNION ALL SELECT 'a' a, 'b' b) +INSERT INTO withz VALUES(1, 'insert') +ON CONFLICT (k) DO UPDATE SET v = (SELECT b || ' update' FROM aa WHERE a = 'a' LIMIT 1) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 214 +WITH aa AS (SELECT 1 a, 2 b) +INSERT INTO withz VALUES(1, (SELECT b || ' insert' FROM aa WHERE a = 1 )) +ON CONFLICT (k) DO UPDATE SET v = (SELECT b || ' update' FROM aa WHERE a = 1 LIMIT 1) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +== 215 +-- Update a row more than once, in different parts of a wCTE. That is +-- an allowed, presumably very rare, edge case, but since it was +-- broken in the past, having a test seems worthwhile. +WITH simpletup AS ( + SELECT 2 k, 'Green' v), +upsert_cte AS ( + INSERT INTO withz VALUES(2, 'Blue') ON CONFLICT (k) DO + UPDATE SET (k, v) = (SELECT k, v FROM simpletup WHERE simpletup.k = withz.k) + RETURNING k, v) +INSERT INTO withz VALUES(2, 'Red') ON CONFLICT (k) DO +UPDATE SET (k, v) = (SELECT k, v FROM upsert_cte WHERE upsert_cte.k = withz.k) +RETURNING k, v +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "simpletup" +CTE: "upsert_cte" +FILTER: schema="" table="upsert_cte" column="k" +FILTER: schema="" table="withz" column="k" +FILTER: schema="" table="upsert_cte" column="k" +FILTER: schema="" table="withz" column="k" +FILTER: schema="" table="simpletup" column="k" +FILTER: schema="" table="withz" column="k" +FILTER: schema="" table="simpletup" column="k" +FILTER: schema="" table="withz" column="k" +STMT: InsertStmt +STMT: SelectStmt +== 216 +DROP TABLE withz +-- +TABLE: name="withz" schema="" table="withz" ctx=DDL +STMT: DropStmt +== 217 +-- WITH referenced by MERGE statement +CREATE TABLE m AS SELECT i AS k, (i || ' v')::text v FROM generate_series(1, 16, 3) i +-- +TABLE: name="m" schema="" table="m" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 218 +ALTER TABLE m ADD UNIQUE (k) +-- +TABLE: name="m" schema="" table="m" ctx=DDL +STMT: AlterTableStmt +== 219 +WITH RECURSIVE cte_basic AS (SELECT 1 a, 'cte_basic val' b) +MERGE INTO m USING (select 0 k, 'merge source SubPlan' v) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_basic" +FILTER: schema="" table="cte_basic" column="a" +FILTER: schema="" table="m" column="k" +STMT: MergeStmt +STMT: SelectStmt +== 220 +-- Basic: +WITH cte_basic AS MATERIALIZED (SELECT 1 a, 'cte_basic val' b) +MERGE INTO m USING (select 0 k, 'merge source SubPlan' v offset 0) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_basic" +FILTER: schema="" table="cte_basic" column="a" +FILTER: schema="" table="m" column="k" +STMT: MergeStmt +STMT: SelectStmt +== 221 +-- Examine +SELECT * FROM m where k = 0 +-- +TABLE: name="m" schema="" table="m" ctx=Select +FILTER: schema="" table="" column="k" +STMT: SelectStmt +== 222 +-- See EXPLAIN output for same query: +EXPLAIN (VERBOSE, COSTS OFF) +WITH cte_basic AS MATERIALIZED (SELECT 1 a, 'cte_basic val' b) +MERGE INTO m USING (select 0 k, 'merge source SubPlan' v offset 0) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_basic" +FILTER: schema="" table="cte_basic" column="a" +FILTER: schema="" table="m" column="k" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 223 +-- InitPlan +WITH cte_init AS MATERIALIZED (SELECT 1 a, 'cte_init val' b) +MERGE INTO m USING (select 1 k, 'merge source InitPlan' v offset 0) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_init WHERE a = 1 LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_init" +FILTER: schema="" table="" column="a" +STMT: MergeStmt +STMT: SelectStmt +== 224 +-- Examine +SELECT * FROM m where k = 1 +-- +TABLE: name="m" schema="" table="m" ctx=Select +FILTER: schema="" table="" column="k" +STMT: SelectStmt +== 225 +-- See EXPLAIN output for same query: +EXPLAIN (VERBOSE, COSTS OFF) +WITH cte_init AS MATERIALIZED (SELECT 1 a, 'cte_init val' b) +MERGE INTO m USING (select 1 k, 'merge source InitPlan' v offset 0) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_init WHERE a = 1 LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_init" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 226 +-- MERGE source comes from CTE: +WITH merge_source_cte AS MATERIALIZED (SELECT 15 a, 'merge_source_cte val' b) +MERGE INTO m USING (select * from merge_source_cte) o ON m.k=o.a +WHEN MATCHED THEN UPDATE SET v = (SELECT b || merge_source_cte.*::text || ' merge update' FROM merge_source_cte WHERE a = 15) +WHEN NOT MATCHED THEN INSERT VALUES(o.a, o.b || (SELECT merge_source_cte.*::text || ' merge insert' FROM merge_source_cte)) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "merge_source_cte" +FILTER: schema="" table="" column="a" +STMT: MergeStmt +STMT: SelectStmt +== 227 +-- Examine +SELECT * FROM m where k = 15 +-- +TABLE: name="m" schema="" table="m" ctx=Select +FILTER: schema="" table="" column="k" +STMT: SelectStmt +== 228 +-- See EXPLAIN output for same query: +EXPLAIN (VERBOSE, COSTS OFF) +WITH merge_source_cte AS MATERIALIZED (SELECT 15 a, 'merge_source_cte val' b) +MERGE INTO m USING (select * from merge_source_cte) o ON m.k=o.a +WHEN MATCHED THEN UPDATE SET v = (SELECT b || merge_source_cte.*::text || ' merge update' FROM merge_source_cte WHERE a = 15) +WHEN NOT MATCHED THEN INSERT VALUES(o.a, o.b || (SELECT merge_source_cte.*::text || ' merge insert' FROM merge_source_cte)) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "merge_source_cte" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +== 229 +DROP TABLE m +-- +TABLE: name="m" schema="" table="m" ctx=DDL +STMT: DropStmt +== 230 +-- check that run to completion happens in proper ordering + +TRUNCATE TABLE y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: TruncateStmt +== 231 +INSERT INTO y SELECT generate_series(1, 3) +-- +TABLE: name="y" schema="" table="y" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 232 +CREATE TEMPORARY TABLE yy (a INTEGER) +-- +TABLE: name="yy" schema="" table="yy" ctx=DDL +STMT: CreateStmt +== 233 +WITH RECURSIVE t1 AS ( + INSERT INTO y SELECT * FROM y RETURNING * +), t2 AS ( + INSERT INTO yy SELECT * FROM t1 RETURNING * +) +SELECT 1 +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="yy" schema="" table="yy" ctx=DML +CTE: "t1" +CTE: "t2" +STMT: SelectStmt +STMT: InsertStmt +== 234 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 235 +SELECT * FROM yy +-- +TABLE: name="yy" schema="" table="yy" ctx=Select +STMT: SelectStmt +== 236 +WITH RECURSIVE t1 AS ( + INSERT INTO yy SELECT * FROM t2 RETURNING * +), t2 AS ( + INSERT INTO y SELECT * FROM y RETURNING * +) +SELECT 1 +-- +TABLE: name="yy" schema="" table="yy" ctx=DML +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "t1" +CTE: "t2" +STMT: SelectStmt +STMT: InsertStmt +== 237 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 238 +SELECT * FROM yy +-- +TABLE: name="yy" schema="" table="yy" ctx=Select +STMT: SelectStmt +== 239 +-- triggers + +TRUNCATE TABLE y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: TruncateStmt +== 240 +INSERT INTO y SELECT generate_series(1, 10) +-- +TABLE: name="y" schema="" table="y" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +== 241 +CREATE FUNCTION y_trigger() RETURNS trigger AS $$ +begin + raise notice 'y_trigger: a = %', new.a; + return new; +end; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="y_trigger" function="y_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 242 +CREATE TRIGGER y_trig BEFORE INSERT ON y FOR EACH ROW + EXECUTE PROCEDURE y_trigger() +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateTrigStmt +== 243 +WITH t AS ( + INSERT INTO y + VALUES + (21), + (22), + (23) + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 244 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 245 +DROP TRIGGER y_trig ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +== 246 +CREATE TRIGGER y_trig AFTER INSERT ON y FOR EACH ROW + EXECUTE PROCEDURE y_trigger() +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateTrigStmt +== 247 +WITH t AS ( + INSERT INTO y + VALUES + (31), + (32), + (33) + RETURNING * +) +SELECT * FROM t LIMIT 1 +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 248 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 249 +DROP TRIGGER y_trig ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +== 250 +CREATE OR REPLACE FUNCTION y_trigger() RETURNS trigger AS $$ +begin + raise notice 'y_trigger'; + return null; +end; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="y_trigger" function="y_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 251 +CREATE TRIGGER y_trig AFTER INSERT ON y FOR EACH STATEMENT + EXECUTE PROCEDURE y_trigger() +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateTrigStmt +== 252 +WITH t AS ( + INSERT INTO y + VALUES + (41), + (42), + (43) + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 253 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +== 254 +DROP TRIGGER y_trig ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +== 255 +DROP FUNCTION y_trigger() +-- +FUNCTION: name="y_trigger" function="y_trigger" schema="" ctx=DDL +STMT: DropStmt +== 256 +-- WITH attached to inherited UPDATE or DELETE + +CREATE TEMP TABLE parent ( id int, val text ) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +== 257 +CREATE TEMP TABLE child1 ( ) INHERITS ( parent ) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +== 258 +CREATE TEMP TABLE child2 ( ) INHERITS ( parent ) +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateStmt +== 259 +INSERT INTO parent VALUES ( 1, 'p1' ) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 260 +INSERT INTO child1 VALUES ( 11, 'c11' ),( 12, 'c12' ) +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 261 +INSERT INTO child2 VALUES ( 23, 'c21' ),( 24, 'c22' ) +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 262 +WITH rcte AS ( SELECT sum(id) AS totalid FROM parent ) +UPDATE parent SET id = id + totalid FROM rcte +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +TABLE: name="parent" schema="" table="parent" ctx=Select +CTE: "rcte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: UpdateStmt +STMT: SelectStmt +== 263 +SELECT * FROM parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 264 +WITH wcte AS ( INSERT INTO child1 VALUES ( 42, 'new' ) RETURNING id AS newid ) +UPDATE parent SET id = id + newid FROM wcte +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +TABLE: name="child1" schema="" table="child1" ctx=DML +CTE: "wcte" +STMT: UpdateStmt +STMT: InsertStmt +STMT: SelectStmt +== 265 +SELECT * FROM parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 266 +WITH rcte AS ( SELECT max(id) AS maxid FROM parent ) +DELETE FROM parent USING rcte WHERE id = maxid +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +TABLE: name="parent" schema="" table="parent" ctx=Select +CTE: "rcte" +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: DeleteStmt +STMT: SelectStmt +== 267 +SELECT * FROM parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 268 +WITH wcte AS ( INSERT INTO child2 VALUES ( 42, 'new2' ) RETURNING id AS newid ) +DELETE FROM parent USING wcte WHERE id = newid +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +TABLE: name="child2" schema="" table="child2" ctx=DML +CTE: "wcte" +STMT: DeleteStmt +STMT: InsertStmt +STMT: SelectStmt +== 269 +SELECT * FROM parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +== 270 +-- check EXPLAIN VERBOSE for a wCTE with RETURNING + +EXPLAIN (VERBOSE, COSTS OFF) +WITH wcte AS ( INSERT INTO int8_tbl VALUES ( 42, 47 ) RETURNING q2 ) +DELETE FROM a_star USING wcte WHERE aa = q2 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +CTE: "wcte" +STMT: ExplainStmt +STMT: DeleteStmt +STMT: InsertStmt +STMT: SelectStmt +== 271 +-- error cases + +-- data-modifying WITH tries to use its own output +WITH RECURSIVE t AS ( + INSERT INTO y + SELECT * FROM t +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 272 +-- no RETURNING in a referenced data-modifying WITH +WITH t AS ( + INSERT INTO y VALUES(0) +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 273 +-- RETURNING tries to return its own output +WITH RECURSIVE t(action, a) AS ( + MERGE INTO y USING (VALUES (11)) v(a) ON y.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a) + RETURNING merge_action(), (SELECT a FROM t) +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: MergeStmt +== 274 +-- data-modifying WITH allowed only at the top level +SELECT * FROM ( + WITH t AS (UPDATE y SET a=a+1 RETURNING *) + SELECT * FROM t +) ss +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: UpdateStmt +== 275 +-- most variants of rules aren't allowed +CREATE RULE y_rule AS ON INSERT TO y WHERE a=0 DO INSTEAD DELETE FROM y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +== 276 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 277 +CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO INSTEAD NOTHING +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +== 278 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 279 +CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO INSTEAD NOTIFY foo +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +== 280 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 281 +CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO ALSO NOTIFY foo +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +== 282 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 283 +CREATE OR REPLACE RULE y_rule AS ON INSERT TO y + DO INSTEAD (NOTIFY foo; NOTIFY bar) +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +== 284 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +== 285 +DROP RULE y_rule ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +== 286 +-- check that parser lookahead for WITH doesn't cause any odd behavior +create table foo (with baz) +-- +ERROR: syntax error at or near "with" +CURSORPOS: 90 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 287 +-- fail, WITH is a reserved word +create table foo (with ordinality) +-- +ERROR: syntax error at or near "with" +CURSORPOS: 52 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 288 +-- fail, WITH is a reserved word +with ordinality as (select 1 as x) select * from ordinality +-- +CTE: "ordinality" +STMT: SelectStmt +== 289 +-- check sane response to attempt to modify CTE relation +WITH with_test AS (SELECT 42) INSERT INTO with_test VALUES (1) +-- +CTE: "with_test" +STMT: InsertStmt +STMT: SelectStmt +== 290 +-- check response to attempt to modify table with same name as a CTE (perhaps +-- surprisingly it works, because CTEs don't hide tables from data-modifying +-- statements) +create temp table with_test (i int) +-- +TABLE: name="with_test" schema="" table="with_test" ctx=DDL +STMT: CreateStmt +== 291 +with with_test as (select 42) insert into with_test select * from with_test +-- +CTE: "with_test" +STMT: InsertStmt +STMT: SelectStmt +== 292 +select * from with_test +-- +TABLE: name="with_test" schema="" table="with_test" ctx=Select +STMT: SelectStmt +== 293 +drop table with_test +-- +TABLE: name="with_test" schema="" table="with_test" ctx=DDL +STMT: DropStmt diff --git a/parser/testdata/summary/postgres_regress/write_parallel.metadata.json b/parser/testdata/summary/postgres_regress/write_parallel.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/write_parallel.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/write_parallel.test b/parser/testdata/summary/postgres_regress/write_parallel.test new file mode 100644 index 0000000..4ecb49e --- /dev/null +++ b/parser/testdata/summary/postgres_regress/write_parallel.test @@ -0,0 +1,149 @@ +== 001 +|-- +-- PARALLEL +|-- + +begin +-- +STMT: TransactionStmt +== 002 +-- encourage use of parallel plans +set parallel_setup_cost=0 +-- +STMT: VariableSetStmt +== 003 +set parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +== 004 +set min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +== 005 +set max_parallel_workers_per_gather=4 +-- +STMT: VariableSetStmt +== 006 +|-- +-- Test write operations that has an underlying query that is eligible +-- for parallel plans +|-- +explain (costs off) create table parallel_write as + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 007 +create table parallel_write as + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 008 +drop table parallel_write +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: DropStmt +== 009 +explain (costs off) select length(stringu1) into parallel_write + from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +== 010 +select length(stringu1) into parallel_write + from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +== 011 +drop table parallel_write +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: DropStmt +== 012 +explain (costs off) create materialized view parallel_mat_view as + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +== 013 +create materialized view parallel_mat_view as + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +== 014 +create unique index on parallel_mat_view(length) +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +STMT: IndexStmt +== 015 +refresh materialized view parallel_mat_view +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +STMT: RefreshMatViewStmt +== 016 +refresh materialized view concurrently parallel_mat_view +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +STMT: RefreshMatViewStmt +== 017 +drop materialized view parallel_mat_view +-- +STMT: DropStmt +== 018 +prepare prep_stmt as select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +== 019 +explain (costs off) create table parallel_write as execute prep_stmt +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 020 +create table parallel_write as execute prep_stmt +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +== 021 +drop table parallel_write +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: DropStmt +== 022 +rollback +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/xid.metadata.json b/parser/testdata/summary/postgres_regress/xid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/xid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/xid.test b/parser/testdata/summary/postgres_regress/xid.test new file mode 100644 index 0000000..051bcca --- /dev/null +++ b/parser/testdata/summary/postgres_regress/xid.test @@ -0,0 +1,475 @@ +== 001 +-- xid and xid8 + +-- values in range, in octal, decimal, hex +select '010'::xid, + '42'::xid, + '0xffffffff'::xid, + '-1'::xid, + '010'::xid8, + '42'::xid8, + '0xffffffffffffffff'::xid8, + '-1'::xid8 +-- +STMT: SelectStmt +== 002 +-- garbage values +select ''::xid +-- +STMT: SelectStmt +== 003 +select 'asdf'::xid +-- +STMT: SelectStmt +== 004 +select ''::xid8 +-- +STMT: SelectStmt +== 005 +select 'asdf'::xid8 +-- +STMT: SelectStmt +== 006 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('42', 'xid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT pg_input_is_valid('asdf', 'xid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 008 +SELECT * FROM pg_input_error_info('0xffffffffff', 'xid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 009 +SELECT pg_input_is_valid('42', 'xid8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT pg_input_is_valid('asdf', 'xid8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT * FROM pg_input_error_info('0xffffffffffffffffffff', 'xid8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 012 +-- equality +select '1'::xid = '1'::xid +-- +STMT: SelectStmt +== 013 +select '1'::xid != '1'::xid +-- +STMT: SelectStmt +== 014 +select '1'::xid8 = '1'::xid8 +-- +STMT: SelectStmt +== 015 +select '1'::xid8 != '1'::xid8 +-- +STMT: SelectStmt +== 016 +-- conversion +select '1'::xid = '1'::xid8::xid +-- +STMT: SelectStmt +== 017 +select '1'::xid != '1'::xid8::xid +-- +STMT: SelectStmt +== 018 +-- we don't want relational operators for xid, due to use of modular arithmetic +select '1'::xid < '2'::xid +-- +STMT: SelectStmt +== 019 +select '1'::xid <= '2'::xid +-- +STMT: SelectStmt +== 020 +select '1'::xid > '2'::xid +-- +STMT: SelectStmt +== 021 +select '1'::xid >= '2'::xid +-- +STMT: SelectStmt +== 022 +-- we want them for xid8 though +select '1'::xid8 < '2'::xid8, '2'::xid8 < '2'::xid8, '2'::xid8 < '1'::xid8 +-- +STMT: SelectStmt +== 023 +select '1'::xid8 <= '2'::xid8, '2'::xid8 <= '2'::xid8, '2'::xid8 <= '1'::xid8 +-- +STMT: SelectStmt +== 024 +select '1'::xid8 > '2'::xid8, '2'::xid8 > '2'::xid8, '2'::xid8 > '1'::xid8 +-- +STMT: SelectStmt +== 025 +select '1'::xid8 >= '2'::xid8, '2'::xid8 >= '2'::xid8, '2'::xid8 >= '1'::xid8 +-- +STMT: SelectStmt +== 026 +-- we also have a 3way compare for btrees +select xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1') +-- +FUNCTION: name="xid8cmp" function="xid8cmp" schema="" ctx=Call +FUNCTION: name="xid8cmp" function="xid8cmp" schema="" ctx=Call +FUNCTION: name="xid8cmp" function="xid8cmp" schema="" ctx=Call +STMT: SelectStmt +== 027 +-- min() and max() for xid8 +create table xid8_t1 (x xid8) +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DDL +STMT: CreateStmt +== 028 +insert into xid8_t1 values ('0'), ('010'), ('42'), ('0xffffffffffffffff'), ('-1') +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 029 +select min(x), max(x) from xid8_t1 +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +== 030 +-- xid8 has btree and hash opclasses +create index on xid8_t1 using btree(x) +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DDL +STMT: IndexStmt +== 031 +create index on xid8_t1 using hash(x) +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DDL +STMT: IndexStmt +== 032 +drop table xid8_t1 +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DDL +STMT: DropStmt +== 033 +-- pg_snapshot data type and related functions + +-- Note: another set of tests similar to this exists in txid.sql, for a limited +-- time (the relevant functions share C code) + +-- i/o +select '12:13:'::pg_snapshot +-- +STMT: SelectStmt +== 034 +select '12:18:14,16'::pg_snapshot +-- +STMT: SelectStmt +== 035 +select '12:16:14,14'::pg_snapshot +-- +STMT: SelectStmt +== 036 +-- errors +select '31:12:'::pg_snapshot +-- +STMT: SelectStmt +== 037 +select '0:1:'::pg_snapshot +-- +STMT: SelectStmt +== 038 +select '12:13:0'::pg_snapshot +-- +STMT: SelectStmt +== 039 +select '12:16:14,13'::pg_snapshot +-- +STMT: SelectStmt +== 040 +-- also try it with non-error-throwing API +select pg_input_is_valid('12:13:', 'pg_snapshot') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 041 +select pg_input_is_valid('31:12:', 'pg_snapshot') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 042 +select * from pg_input_error_info('31:12:', 'pg_snapshot') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 043 +select pg_input_is_valid('12:16:14,13', 'pg_snapshot') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 044 +select * from pg_input_error_info('12:16:14,13', 'pg_snapshot') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 045 +create temp table snapshot_test ( + nr integer, + snap pg_snapshot +) +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DDL +STMT: CreateStmt +== 046 +insert into snapshot_test values (1, '12:13:') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 047 +insert into snapshot_test values (2, '12:20:13,15,18') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 048 +insert into snapshot_test values (3, '100001:100009:100005,100007,100008') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 049 +insert into snapshot_test values (4, '100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 050 +select snap from snapshot_test order by nr +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +STMT: SelectStmt +== 051 +select pg_snapshot_xmin(snap), + pg_snapshot_xmax(snap), + pg_snapshot_xip(snap) +from snapshot_test order by nr +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="pg_snapshot_xmin" function="pg_snapshot_xmin" schema="" ctx=Call +FUNCTION: name="pg_snapshot_xmax" function="pg_snapshot_xmax" schema="" ctx=Call +FUNCTION: name="pg_snapshot_xip" function="pg_snapshot_xip" schema="" ctx=Call +STMT: SelectStmt +== 052 +select id, pg_visible_in_snapshot(id::text::xid8, snap) +from snapshot_test, generate_series(11, 21) id +where nr = 2 +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 053 +-- test bsearch +select id, pg_visible_in_snapshot(id::text::xid8, snap) +from snapshot_test, generate_series(90, 160) id +where nr = 4 +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +== 054 +-- test current values also +select pg_current_xact_id() >= pg_snapshot_xmin(pg_current_snapshot()) +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_snapshot_xmin" function="pg_snapshot_xmin" schema="" ctx=Call +FUNCTION: name="pg_current_snapshot" function="pg_current_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 055 +-- we can't assume current is always less than xmax, however + +select pg_visible_in_snapshot(pg_current_xact_id(), pg_current_snapshot()) +-- +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_current_snapshot" function="pg_current_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 056 +-- test 64bitness + +select pg_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013' +-- +STMT: SelectStmt +== 057 +select pg_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013') +-- +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 058 +select pg_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013') +-- +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +STMT: SelectStmt +== 059 +-- test 64bit overflow +SELECT pg_snapshot '1:9223372036854775807:3' +-- +STMT: SelectStmt +== 060 +SELECT pg_snapshot '1:9223372036854775808:3' +-- +STMT: SelectStmt +== 061 +-- test pg_current_xact_id_if_assigned +BEGIN +-- +STMT: TransactionStmt +== 062 +SELECT pg_current_xact_id_if_assigned() IS NULL +-- +FUNCTION: name="pg_current_xact_id_if_assigned" function="pg_current_xact_id_if_assigned" schema="" ctx=Call +STMT: SelectStmt +== 063 +SELECT pg_current_xact_id() +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: SelectStmt +== 064 +SELECT pg_current_xact_id_if_assigned() IS NOT DISTINCT FROM xid8 :'pg_current_xact_id' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 065 +COMMIT +-- +STMT: TransactionStmt +== 066 +-- test xid status functions +BEGIN +-- +STMT: TransactionStmt +== 067 +SELECT pg_current_xact_id() AS committed +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: SelectStmt +== 068 +COMMIT +-- +STMT: TransactionStmt +== 069 +BEGIN +-- +STMT: TransactionStmt +== 070 +SELECT pg_current_xact_id() AS rolledback +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: SelectStmt +== 071 +ROLLBACK +-- +STMT: TransactionStmt +== 072 +BEGIN +-- +STMT: TransactionStmt +== 073 +SELECT pg_current_xact_id() AS inprogress +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: SelectStmt +== 074 +SELECT pg_xact_status(:committed::text::xid8) AS committed +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 075 +SELECT pg_xact_status(:rolledback::text::xid8) AS rolledback +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 076 +SELECT pg_xact_status(:inprogress::text::xid8) AS inprogress +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 077 +SELECT pg_xact_status('1'::xid8) +-- +FUNCTION: name="pg_xact_status" function="pg_xact_status" schema="" ctx=Call +STMT: SelectStmt +== 078 +-- BootstrapTransactionId is always committed +SELECT pg_xact_status('2'::xid8) +-- +FUNCTION: name="pg_xact_status" function="pg_xact_status" schema="" ctx=Call +STMT: SelectStmt +== 079 +-- FrozenTransactionId is always committed +SELECT pg_xact_status('3'::xid8) +-- +FUNCTION: name="pg_xact_status" function="pg_xact_status" schema="" ctx=Call +STMT: SelectStmt +== 080 +-- in regress testing FirstNormalTransactionId will always be behind oldestXmin + +COMMIT +-- +STMT: TransactionStmt +== 081 +BEGIN +-- +STMT: TransactionStmt +== 082 +CREATE FUNCTION test_future_xid_status(xid8) +RETURNS void +LANGUAGE plpgsql +AS +$$ +BEGIN + PERFORM pg_xact_status($1); + RAISE EXCEPTION 'didn''t ERROR at xid in the future as expected'; +EXCEPTION + WHEN invalid_parameter_value THEN + RAISE NOTICE 'Got expected error for xid in the future'; +END; +$$ +-- +FUNCTION: name="test_future_xid_status" function="test_future_xid_status" schema="" ctx=DDL +STMT: CreateFunctionStmt +== 083 +SELECT test_future_xid_status((:inprogress + 10000)::text::xid8) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 084 +ROLLBACK +-- +STMT: TransactionStmt diff --git a/parser/testdata/summary/postgres_regress/xml.metadata.json b/parser/testdata/summary/postgres_regress/xml.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/xml.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/xml.test b/parser/testdata/summary/postgres_regress/xml.test new file mode 100644 index 0000000..c5b5ec8 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/xml.test @@ -0,0 +1,1650 @@ +== 001 +CREATE TABLE xmltest ( + id int, + data xml +) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DDL +STMT: CreateStmt +== 002 +INSERT INTO xmltest VALUES (1, 'one') +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 003 +INSERT INTO xmltest VALUES (2, 'two') +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +INSERT INTO xmltest VALUES (3, 'one', 'xml') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 007 +SELECT pg_input_is_valid('oneone', 'xml') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT message FROM pg_input_error_info('', 'xml') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT xmlcomment('test') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT xmlcomment('-test') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT xmlcomment('test-') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT xmlcomment('--test') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT xmlcomment('te st') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT xmlconcat(xmlcomment('hello'), + xmlelement(NAME qux, 'foo'), + xmlcomment('world')) +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT xmlconcat('hello', 'you') +-- +STMT: SelectStmt +== 018 +SELECT xmlconcat(1, 2) +-- +STMT: SelectStmt +== 019 +SELECT xmlconcat('bad', '', NULL, '') +-- +STMT: SelectStmt +== 021 +SELECT xmlconcat('', NULL, '') +-- +STMT: SelectStmt +== 022 +SELECT xmlconcat(NULL) +-- +STMT: SelectStmt +== 023 +SELECT xmlconcat(NULL, NULL) +-- +STMT: SelectStmt +== 024 +SELECT xmlelement(name element, + xmlattributes (1 as one, 'deuce' as two), + 'content') +-- +STMT: SelectStmt +== 025 +SELECT xmlelement(name element, + xmlattributes ('unnamed and wrong')) +-- +STMT: SelectStmt +== 026 +SELECT xmlelement(name element, xmlelement(name nested, 'stuff')) +-- +STMT: SelectStmt +== 027 +SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp +-- +TABLE: name="emp" schema="" table="emp" ctx=Select +STMT: SelectStmt +== 028 +SELECT xmlelement(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a)) +-- +STMT: SelectStmt +== 029 +SELECT xmlelement(name num, 37) +-- +STMT: SelectStmt +== 030 +SELECT xmlelement(name foo, text 'bar') +-- +STMT: SelectStmt +== 031 +SELECT xmlelement(name foo, xml 'bar') +-- +STMT: SelectStmt +== 032 +SELECT xmlelement(name foo, text 'br') +-- +STMT: SelectStmt +== 033 +SELECT xmlelement(name foo, xml 'br') +-- +STMT: SelectStmt +== 034 +SELECT xmlelement(name foo, array[1, 2, 3]) +-- +STMT: SelectStmt +== 035 +SET xmlbinary TO base64 +-- +STMT: VariableSetStmt +== 036 +SELECT xmlelement(name foo, bytea 'bar') +-- +STMT: SelectStmt +== 037 +SET xmlbinary TO hex +-- +STMT: VariableSetStmt +== 038 +SELECT xmlelement(name foo, bytea 'bar') +-- +STMT: SelectStmt +== 039 +SELECT xmlelement(name foo, xmlattributes(true as bar)) +-- +STMT: SelectStmt +== 040 +SELECT xmlelement(name foo, xmlattributes('2009-04-09 00:24:37'::timestamp as bar)) +-- +STMT: SelectStmt +== 041 +SELECT xmlelement(name foo, xmlattributes('infinity'::timestamp as bar)) +-- +STMT: SelectStmt +== 042 +SELECT xmlelement(name foo, xmlattributes('<>&"''' as funny, xml 'br' as funnier)) +-- +STMT: SelectStmt +== 043 +SELECT xmlparse(content '') +-- +STMT: SelectStmt +== 044 +SELECT xmlparse(content ' ') +-- +STMT: SelectStmt +== 045 +SELECT xmlparse(content 'abc') +-- +STMT: SelectStmt +== 046 +SELECT xmlparse(content 'x') +-- +STMT: SelectStmt +== 047 +SELECT xmlparse(content '&') +-- +STMT: SelectStmt +== 048 +SELECT xmlparse(content '&idontexist;') +-- +STMT: SelectStmt +== 049 +SELECT xmlparse(content '') +-- +STMT: SelectStmt +== 050 +SELECT xmlparse(content '') +-- +STMT: SelectStmt +== 051 +SELECT xmlparse(content '&idontexist;') +-- +STMT: SelectStmt +== 052 +SELECT xmlparse(content '') +-- +STMT: SelectStmt +== 053 +SELECT xmlparse(document ' ') +-- +STMT: SelectStmt +== 054 +SELECT xmlparse(document 'abc') +-- +STMT: SelectStmt +== 055 +SELECT xmlparse(document 'x') +-- +STMT: SelectStmt +== 056 +SELECT xmlparse(document '&') +-- +STMT: SelectStmt +== 057 +SELECT xmlparse(document '&idontexist;') +-- +STMT: SelectStmt +== 058 +SELECT xmlparse(document '') +-- +STMT: SelectStmt +== 059 +SELECT xmlparse(document '') +-- +STMT: SelectStmt +== 060 +SELECT xmlparse(document '&idontexist;') +-- +STMT: SelectStmt +== 061 +SELECT xmlparse(document '') +-- +STMT: SelectStmt +== 062 +SELECT xmlpi(name foo) +-- +STMT: SelectStmt +== 063 +SELECT xmlpi(name xml) +-- +STMT: SelectStmt +== 064 +SELECT xmlpi(name xmlstuff) +-- +STMT: SelectStmt +== 065 +SELECT xmlpi(name foo, 'bar') +-- +STMT: SelectStmt +== 066 +SELECT xmlpi(name foo, 'in?>valid') +-- +STMT: SelectStmt +== 067 +SELECT xmlpi(name foo, null) +-- +STMT: SelectStmt +== 068 +SELECT xmlpi(name xml, null) +-- +STMT: SelectStmt +== 069 +SELECT xmlpi(name xmlstuff, null) +-- +STMT: SelectStmt +== 070 +SELECT xmlpi(name "xml-stylesheet", 'href="mystyle.css" type="text/css"') +-- +STMT: SelectStmt +== 071 +SELECT xmlpi(name foo, ' bar') +-- +STMT: SelectStmt +== 072 +SELECT xmlroot(xml '', version no value, standalone no value) +-- +STMT: SelectStmt +== 073 +SELECT xmlroot(xml '', version '2.0') +-- +STMT: SelectStmt +== 074 +SELECT xmlroot(xml '', version no value, standalone yes) +-- +STMT: SelectStmt +== 075 +SELECT xmlroot(xml '', version no value, standalone yes) +-- +STMT: SelectStmt +== 076 +SELECT xmlroot(xmlroot(xml '', version '1.0'), version '1.1', standalone no) +-- +STMT: SelectStmt +== 077 +SELECT xmlroot('', version no value, standalone no) +-- +STMT: SelectStmt +== 078 +SELECT xmlroot('', version no value, standalone no value) +-- +STMT: SelectStmt +== 079 +SELECT xmlroot('', version no value) +-- +STMT: SelectStmt +== 080 +SELECT xmlroot ( + xmlelement ( + name gazonk, + xmlattributes ( + 'val' AS name, + 1 + 1 AS num + ), + xmlelement ( + NAME qux, + 'foo' + ) + ), + version '1.0', + standalone yes +) +-- +STMT: SelectStmt +== 081 +SELECT xmlserialize(content data as character varying(20)) FROM xmltest +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +STMT: SelectStmt +== 082 +SELECT xmlserialize(content 'good' as char(10)) +-- +STMT: SelectStmt +== 083 +SELECT xmlserialize(document 'bad' as text) +-- +STMT: SelectStmt +== 084 +-- indent +SELECT xmlserialize(DOCUMENT '42' AS text INDENT) +-- +STMT: SelectStmt +== 085 +SELECT xmlserialize(CONTENT '42' AS text INDENT) +-- +STMT: SelectStmt +== 086 +-- no indent +SELECT xmlserialize(DOCUMENT '42' AS text NO INDENT) +-- +STMT: SelectStmt +== 087 +SELECT xmlserialize(CONTENT '42' AS text NO INDENT) +-- +STMT: SelectStmt +== 088 +-- indent non singly-rooted xml +SELECT xmlserialize(DOCUMENT '7342' AS text INDENT) +-- +STMT: SelectStmt +== 089 +SELECT xmlserialize(CONTENT '7342' AS text INDENT) +-- +STMT: SelectStmt +== 090 +-- indent non singly-rooted xml with mixed contents +SELECT xmlserialize(DOCUMENT 'text node73text node42' AS text INDENT) +-- +STMT: SelectStmt +== 091 +SELECT xmlserialize(CONTENT 'text node73text node42' AS text INDENT) +-- +STMT: SelectStmt +== 092 +-- indent singly-rooted xml with mixed contents +SELECT xmlserialize(DOCUMENT '42text node73' AS text INDENT) +-- +STMT: SelectStmt +== 093 +SELECT xmlserialize(CONTENT '42text node73' AS text INDENT) +-- +STMT: SelectStmt +== 094 +-- indent empty string +SELECT xmlserialize(DOCUMENT '' AS text INDENT) +-- +STMT: SelectStmt +== 095 +SELECT xmlserialize(CONTENT '' AS text INDENT) +-- +STMT: SelectStmt +== 096 +-- whitespaces +SELECT xmlserialize(DOCUMENT ' ' AS text INDENT) +-- +STMT: SelectStmt +== 097 +SELECT xmlserialize(CONTENT ' ' AS text INDENT) +-- +STMT: SelectStmt +== 098 +-- indent null +SELECT xmlserialize(DOCUMENT NULL AS text INDENT) +-- +STMT: SelectStmt +== 099 +SELECT xmlserialize(CONTENT NULL AS text INDENT) +-- +STMT: SelectStmt +== 100 +-- indent with XML declaration +SELECT xmlserialize(DOCUMENT '73' AS text INDENT) +-- +STMT: SelectStmt +== 101 +SELECT xmlserialize(CONTENT '73' AS text INDENT) +-- +STMT: SelectStmt +== 102 +-- indent containing DOCTYPE declaration +SELECT xmlserialize(DOCUMENT '' AS text INDENT) +-- +STMT: SelectStmt +== 103 +SELECT xmlserialize(CONTENT '' AS text INDENT) +-- +STMT: SelectStmt +== 104 +-- indent xml with empty element +SELECT xmlserialize(DOCUMENT '' AS text INDENT) +-- +STMT: SelectStmt +== 105 +SELECT xmlserialize(CONTENT '' AS text INDENT) +-- +STMT: SelectStmt +== 106 +-- 'no indent' = not using 'no indent' +SELECT xmlserialize(DOCUMENT '42' AS text) = xmlserialize(DOCUMENT '42' AS text NO INDENT) +-- +STMT: SelectStmt +== 107 +SELECT xmlserialize(CONTENT '42' AS text) = xmlserialize(CONTENT '42' AS text NO INDENT) +-- +STMT: SelectStmt +== 108 +-- indent xml strings containing blank nodes +SELECT xmlserialize(DOCUMENT ' ' AS text INDENT) +-- +STMT: SelectStmt +== 109 +SELECT xmlserialize(CONTENT 'text node ' AS text INDENT) +-- +STMT: SelectStmt +== 110 +SELECT xml 'bar' IS DOCUMENT +-- +STMT: SelectStmt +== 111 +SELECT xml 'barfoo' IS DOCUMENT +-- +STMT: SelectStmt +== 112 +SELECT xml '' IS NOT DOCUMENT +-- +STMT: SelectStmt +== 113 +SELECT xml 'abc' IS NOT DOCUMENT +-- +STMT: SelectStmt +== 114 +SELECT '<>' IS NOT DOCUMENT +-- +STMT: SelectStmt +== 115 +SELECT xmlagg(data) FROM xmltest +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xmlagg" function="xmlagg" schema="" ctx=Call +STMT: SelectStmt +== 116 +SELECT xmlagg(data) FROM xmltest WHERE id > 10 +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xmlagg" function="xmlagg" schema="" ctx=Call +FILTER: schema="" table="" column="id" +STMT: SelectStmt +== 117 +SELECT xmlelement(name employees, xmlagg(xmlelement(name name, name))) FROM emp +-- +TABLE: name="emp" schema="" table="emp" ctx=Select +FUNCTION: name="xmlagg" function="xmlagg" schema="" ctx=Call +STMT: SelectStmt +== 118 +-- Check mapping SQL identifier to XML name + +SELECT xmlpi(name ":::_xml_abc135.%-&_") +-- +STMT: SelectStmt +== 119 +SELECT xmlpi(name "123") +-- +STMT: SelectStmt +== 120 +PREPARE foo (xml) AS SELECT xmlconcat('', $1) +-- +STMT: PrepareStmt +STMT: SelectStmt +== 121 +SET XML OPTION DOCUMENT +-- +STMT: VariableSetStmt +== 122 +EXECUTE foo ('') +-- +STMT: ExecuteStmt +== 123 +EXECUTE foo ('bad') +-- +STMT: ExecuteStmt +== 124 +SELECT xml '' +-- +STMT: SelectStmt +== 125 +SET XML OPTION CONTENT +-- +STMT: VariableSetStmt +== 126 +EXECUTE foo ('') +-- +STMT: ExecuteStmt +== 127 +EXECUTE foo ('good') +-- +STMT: ExecuteStmt +== 128 +SELECT xml ' ' +-- +STMT: SelectStmt +== 129 +SELECT xml ' ' +-- +STMT: SelectStmt +== 130 +SELECT xml '' +-- +STMT: SelectStmt +== 131 +SELECT xml ' oops ' +-- +STMT: SelectStmt +== 132 +SELECT xml ' ' +-- +STMT: SelectStmt +== 133 +SELECT xml '' +-- +STMT: SelectStmt +== 134 +-- Test backwards parsing + +CREATE VIEW xmlview1 AS SELECT xmlcomment('test') +-- +TABLE: name="xmlview1" schema="" table="xmlview1" ctx=DDL +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +== 135 +CREATE VIEW xmlview2 AS SELECT xmlconcat('hello', 'you') +-- +TABLE: name="xmlview2" schema="" table="xmlview2" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 136 +CREATE VIEW xmlview3 AS SELECT xmlelement(name element, xmlattributes (1 as ":one:", 'deuce' as two), 'content&') +-- +TABLE: name="xmlview3" schema="" table="xmlview3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 137 +CREATE VIEW xmlview4 AS SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp +-- +TABLE: name="xmlview4" schema="" table="xmlview4" ctx=DDL +TABLE: name="emp" schema="" table="emp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 138 +CREATE VIEW xmlview5 AS SELECT xmlparse(content 'x') +-- +TABLE: name="xmlview5" schema="" table="xmlview5" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 139 +CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar') +-- +TABLE: name="xmlview6" schema="" table="xmlview6" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 140 +CREATE VIEW xmlview7 AS SELECT xmlroot(xml '', version no value, standalone yes) +-- +TABLE: name="xmlview7" schema="" table="xmlview7" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 141 +CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10)) +-- +TABLE: name="xmlview8" schema="" table="xmlview8" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 142 +CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text) +-- +TABLE: name="xmlview9" schema="" table="xmlview9" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 143 +CREATE VIEW xmlview10 AS SELECT xmlserialize(document '42' AS text indent) +-- +TABLE: name="xmlview10" schema="" table="xmlview10" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 144 +CREATE VIEW xmlview11 AS SELECT xmlserialize(document '42' AS character varying no indent) +-- +TABLE: name="xmlview11" schema="" table="xmlview11" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 145 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'xmlview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +== 146 +-- Text XPath expressions evaluation + +SELECT xpath('/value', data) FROM xmltest +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 147 +SELECT xpath(NULL, NULL) IS NULL FROM xmltest +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 148 +SELECT xpath('', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 149 +SELECT xpath('//text()', 'number one') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 150 +SELECT xpath('//loc:piece/@id', 'number one', ARRAY[ARRAY['loc', 'http://127.0.0.1']]) +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 151 +SELECT xpath('//loc:piece', 'number one', ARRAY[ARRAY['loc', 'http://127.0.0.1']]) +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 152 +SELECT xpath('//loc:piece', 'number one', ARRAY[ARRAY['loc', 'http://127.0.0.1']]) +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 153 +SELECT xpath('//b', 'one two three etc') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 154 +SELECT xpath('//text()', '<') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 155 +SELECT xpath('//@value', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 156 +SELECT xpath('''<>''', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 157 +SELECT xpath('count(//*)', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 158 +SELECT xpath('count(//*)=0', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 159 +SELECT xpath('count(//*)=3', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 160 +SELECT xpath('name(/*)', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 161 +SELECT xpath('/nosuchtag', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 162 +SELECT xpath('root', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 163 +-- Round-trip non-ASCII data through xpath(). +DO $$ +DECLARE + xml_declaration text := ''; + degree_symbol text; + res xml[]; +BEGIN + -- Per the documentation, except when the server encoding is UTF8, xpath() + -- may not work on non-ASCII data. The untranslatable_character and + -- undefined_function traps below, currently dead code, will become relevant + -- if we remove this limitation. + IF current_setting('server_encoding') <> 'UTF8' THEN + RAISE LOG 'skip: encoding % unsupported for xpath', + current_setting('server_encoding'); + RETURN; + END IF; + + degree_symbol := convert_from('\xc2b0', 'UTF8'); + res := xpath('text()', (xml_declaration || + '' || degree_symbol || '')::xml); + IF degree_symbol <> res[1]::text THEN + RAISE 'expected % (%), got % (%)', + degree_symbol, convert_to(degree_symbol, 'UTF8'), + res[1], convert_to(res[1]::text, 'UTF8'); + END IF; +EXCEPTION + -- character with byte sequence 0xc2 0xb0 in encoding "UTF8" has no equivalent in encoding "LATIN8" + WHEN untranslatable_character + -- default conversion function for encoding "UTF8" to "MULE_INTERNAL" does not exist + OR undefined_function + -- unsupported XML feature + OR feature_not_supported THEN + RAISE LOG 'skip: %', SQLERRM; +END +$$ +-- +STMT: DoStmt +== 164 +-- Test xmlexists and xpath_exists +SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF 'Bidford-on-AvonCwmbranBristol') +-- +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 165 +SELECT xmlexists('//town[text() = ''Cwmbran'']' PASSING BY REF 'Bidford-on-AvonCwmbranBristol') +-- +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 166 +SELECT xmlexists('count(/nosuchtag)' PASSING BY REF '') +-- +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +STMT: SelectStmt +== 167 +SELECT xpath_exists('//town[text() = ''Toronto'']','Bidford-on-AvonCwmbranBristol'::xml) +-- +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +STMT: SelectStmt +== 168 +SELECT xpath_exists('//town[text() = ''Cwmbran'']','Bidford-on-AvonCwmbranBristol'::xml) +-- +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +STMT: SelectStmt +== 169 +SELECT xpath_exists('count(/nosuchtag)', ''::xml) +-- +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +STMT: SelectStmt +== 170 +INSERT INTO xmltest VALUES (4, 'BudvarfreeCarlinglots'::xml) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 171 +INSERT INTO xmltest VALUES (5, 'MolsonfreeCarlinglots'::xml) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 172 +INSERT INTO xmltest VALUES (6, 'BudvarfreeCarlinglots'::xml) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 173 +INSERT INTO xmltest VALUES (7, 'MolsonfreeCarlinglots'::xml) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 174 +SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beer' PASSING data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 175 +SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beer' PASSING BY REF data BY REF) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 176 +SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers' PASSING BY REF data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 177 +SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers/name[text() = ''Molson'']' PASSING BY REF data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 178 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beer',data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 179 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beers',data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 180 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beers/name[text() = ''Molson'']',data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 181 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beer',data,ARRAY[ARRAY['myns','http://myns.com']]) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 182 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beers',data,ARRAY[ARRAY['myns','http://myns.com']]) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 183 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beers/myns:name[text() = ''Molson'']',data,ARRAY[ARRAY['myns','http://myns.com']]) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 184 +CREATE TABLE query ( expr TEXT ) +-- +TABLE: name="query" schema="" table="query" ctx=DDL +STMT: CreateStmt +== 185 +INSERT INTO query VALUES ('/menu/beers/cost[text() = ''lots'']') +-- +TABLE: name="query" schema="" table="query" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 186 +SELECT COUNT(id) FROM xmltest, query WHERE xmlexists(expr PASSING BY REF data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +TABLE: name="query" schema="" table="query" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="expr" +FILTER: schema="" table="" column="data" +STMT: SelectStmt +== 187 +-- Test xml_is_well_formed and variants + +SELECT xml_is_well_formed_document('bar') +-- +FUNCTION: name="xml_is_well_formed_document" function="xml_is_well_formed_document" schema="" ctx=Call +STMT: SelectStmt +== 188 +SELECT xml_is_well_formed_document('abc') +-- +FUNCTION: name="xml_is_well_formed_document" function="xml_is_well_formed_document" schema="" ctx=Call +STMT: SelectStmt +== 189 +SELECT xml_is_well_formed_content('bar') +-- +FUNCTION: name="xml_is_well_formed_content" function="xml_is_well_formed_content" schema="" ctx=Call +STMT: SelectStmt +== 190 +SELECT xml_is_well_formed_content('abc') +-- +FUNCTION: name="xml_is_well_formed_content" function="xml_is_well_formed_content" schema="" ctx=Call +STMT: SelectStmt +== 191 +SET xmloption TO DOCUMENT +-- +STMT: VariableSetStmt +== 192 +SELECT xml_is_well_formed('abc') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 193 +SELECT xml_is_well_formed('<>') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 194 +SELECT xml_is_well_formed('') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 195 +SELECT xml_is_well_formed('bar') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 196 +SELECT xml_is_well_formed('barbaz') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 198 +SELECT xml_is_well_formed('number one') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 199 +SELECT xml_is_well_formed('bar') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 200 +SELECT xml_is_well_formed('bar') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 201 +SELECT xml_is_well_formed('&') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 202 +SELECT xml_is_well_formed('&idontexist;') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 203 +SELECT xml_is_well_formed('') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 204 +SELECT xml_is_well_formed('') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 205 +SELECT xml_is_well_formed('&idontexist;') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 206 +SET xmloption TO CONTENT +-- +STMT: VariableSetStmt +== 207 +SELECT xml_is_well_formed('abc') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +== 208 +-- Since xpath() deals with namespaces, it's a bit stricter about +-- what's well-formed and what's not. If we don't obey these rules +-- (i.e. ignore namespace-related errors from libxml), xpath() +-- fails in subtle ways. The following would for example produce +-- the xml value +-- +-- which is invalid because '<' may not appear un-escaped in +-- attribute values. +-- Since different libxml versions emit slightly different +-- error messages, we suppress the DETAIL in this test. +SELECT xpath('/*', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 209 +-- Again, the XML isn't well-formed for namespace purposes +SELECT xpath('/*', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 210 +-- XPath deprecates relative namespaces, but they're not supposed to +-- throw an error, only a warning. +SELECT xpath('/*', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +== 211 +-- External entity references should not leak filesystem information. +SELECT XMLPARSE(DOCUMENT ']>&c;') +-- +STMT: SelectStmt +== 212 +SELECT XMLPARSE(DOCUMENT ']>&c;') +-- +STMT: SelectStmt +== 213 +-- This might or might not load the requested DTD, but it mustn't throw error. +SELECT XMLPARSE(DOCUMENT ' ') +-- +STMT: SelectStmt +== 214 +-- XMLPATH tests +CREATE TABLE xmldata(data xml) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=DDL +STMT: CreateStmt +== 215 +INSERT INTO xmldata VALUES(' + + AU + Australia + 3 + + + CN + China + 3 + + + HK + HongKong + 3 + + + IN + India + 3 + + + JP + Japan + 3Sinzo Abe + + + SG + Singapore + 3791 + +') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 216 +-- XMLTABLE with columns +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME/text()' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 217 +CREATE VIEW xmltableview1 AS SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME/text()' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmltableview1" schema="" table="xmltableview1" ctx=DDL +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +== 218 +SELECT * FROM xmltableview1 +-- +TABLE: name="xmltableview1" schema="" table="xmltableview1" ctx=Select +STMT: SelectStmt +== 219 +EXPLAIN (COSTS OFF) SELECT * FROM xmltableview1 +-- +TABLE: name="xmltableview1" schema="" table="xmltableview1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 220 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM xmltableview1 +-- +TABLE: name="xmltableview1" schema="" table="xmltableview1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 221 +-- errors +SELECT * FROM XMLTABLE (ROW () PASSING null COLUMNS v1 timestamp) AS f (v1, v2) +-- +STMT: SelectStmt +== 222 +SELECT * FROM XMLTABLE (ROW () PASSING null COLUMNS v1 timestamp __pg__is_not_null 1) AS f (v1) +-- +ERROR: option name "__pg__is_not_null" cannot be used in XMLTABLE +CURSORPOS: 66 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 223 +-- XMLNAMESPACES tests +SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS zz), + '/zz:rows/zz:row' + PASSING '10' + COLUMNS a int PATH 'zz:a') +-- +STMT: SelectStmt +== 224 +CREATE VIEW xmltableview2 AS SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS "Zz"), + '/Zz:rows/Zz:row' + PASSING '10' + COLUMNS a int PATH 'Zz:a') +-- +TABLE: name="xmltableview2" schema="" table="xmltableview2" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +== 225 +SELECT * FROM xmltableview2 +-- +TABLE: name="xmltableview2" schema="" table="xmltableview2" ctx=Select +STMT: SelectStmt +== 226 +SELECT * FROM XMLTABLE(XMLNAMESPACES(DEFAULT 'http://x.y'), + '/rows/row' + PASSING '10' + COLUMNS a int PATH 'a') +-- +STMT: SelectStmt +== 227 +SELECT * FROM XMLTABLE('.' + PASSING '' + COLUMNS a text PATH 'foo/namespace::node()') +-- +STMT: SelectStmt +== 228 +-- used in prepare statements +PREPARE pp AS +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +== 229 +EXECUTE pp +-- +STMT: ExecuteStmt +== 230 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 231 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id FOR ORDINALITY, "COUNTRY_NAME" text, "REGION_ID" int) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 232 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 233 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 234 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id FOR ORDINALITY) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 235 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int, rawdata xml PATH '.') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 236 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int, rawdata xml PATH './*') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 237 +SELECT * FROM xmltable('/root' passing 'a1aa2a bbbbxxxcccc' COLUMNS element text) +-- +STMT: SelectStmt +== 238 +SELECT * FROM xmltable('/root' passing 'a1aa2a bbbbxxxcccc' COLUMNS element text PATH 'element/text()') +-- +STMT: SelectStmt +== 239 +-- should fail + +-- CDATA test +select * from xmltable('d/r' passing ' &"<>!foo]]>2' columns c text) +-- +STMT: SelectStmt +== 240 +-- XML builtin entities +SELECT * FROM xmltable('/x/a' PASSING ''"&<>' COLUMNS ent text) +-- +STMT: SelectStmt +== 241 +SELECT * FROM xmltable('/x/a' PASSING ''"&<>' COLUMNS ent xml) +-- +STMT: SelectStmt +== 242 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +== 243 +-- test qual +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) WHERE "COUNTRY_NAME" = 'Japan' +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +FILTER: schema="" table="" column="COUNTRY_NAME" +STMT: SelectStmt +== 244 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT f.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) AS f WHERE "COUNTRY_NAME" = 'Japan' +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +FILTER: schema="" table="" column="COUNTRY_NAME" +STMT: ExplainStmt +STMT: SelectStmt +== 245 +EXPLAIN (VERBOSE, FORMAT JSON, COSTS OFF) +SELECT f.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) AS f WHERE "COUNTRY_NAME" = 'Japan' +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +FILTER: schema="" table="" column="COUNTRY_NAME" +STMT: ExplainStmt +STMT: SelectStmt +== 246 +-- should to work with more data +INSERT INTO xmldata VALUES(' + + CZ + Czech Republic + 2Milos Zeman + + + DE + Germany + 2 + + + FR + France + 2 + +') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 247 +INSERT INTO xmldata VALUES(' + + EG + Egypt + 1 + + + SD + Sudan + 1 + +') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 248 +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 249 +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') + WHERE region_id = 2 +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +FILTER: schema="" table="" column="region_id" +STMT: SelectStmt +== 250 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') + WHERE region_id = 2 +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +FILTER: schema="" table="" column="region_id" +STMT: ExplainStmt +STMT: SelectStmt +== 251 +-- should fail, NULL value +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE' NOT NULL, + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +== 252 +-- if all is ok, then result is empty +-- one line xml test +WITH + x AS (SELECT proname, proowner, procost::numeric, pronargs, + array_to_string(proargnames,',') as proargnames, + case when proargtypes <> '' then array_to_string(proargtypes::oid[],',') end as proargtypes + FROM pg_proc WHERE proname = 'f_leak'), + y AS (SELECT xmlelement(name proc, + xmlforest(proname, proowner, + procost, pronargs, + proargnames, proargtypes)) as proc + FROM x), + z AS (SELECT xmltable.* + FROM y, + LATERAL xmltable('/proc' PASSING proc + COLUMNS proname name, + proowner oid, + procost float, + pronargs int, + proargnames text, + proargtypes text)) + SELECT * FROM z + EXCEPT SELECT * FROM x +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +CTE: "x" +CTE: "y" +CTE: "z" +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +== 253 +-- multi line xml test, result should be empty too +WITH + x AS (SELECT proname, proowner, procost::numeric, pronargs, + array_to_string(proargnames,',') as proargnames, + case when proargtypes <> '' then array_to_string(proargtypes::oid[],',') end as proargtypes + FROM pg_proc), + y AS (SELECT xmlelement(name data, + xmlagg(xmlelement(name proc, + xmlforest(proname, proowner, procost, + pronargs, proargnames, proargtypes)))) as doc + FROM x), + z AS (SELECT xmltable.* + FROM y, + LATERAL xmltable('/data/proc' PASSING doc + COLUMNS proname name, + proowner oid, + procost float, + pronargs int, + proargnames text, + proargtypes text)) + SELECT * FROM z + EXCEPT SELECT * FROM x +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +CTE: "x" +CTE: "y" +CTE: "z" +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FUNCTION: name="xmlagg" function="xmlagg" schema="" ctx=Call +STMT: SelectStmt +== 254 +CREATE TABLE xmltest2(x xml, _path text) +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DDL +STMT: CreateStmt +== 255 +INSERT INTO xmltest2 VALUES('1', 'A') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 256 +INSERT INTO xmltest2 VALUES('2', 'B') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 257 +INSERT INTO xmltest2 VALUES('3', 'C') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 258 +INSERT INTO xmltest2 VALUES('2', 'D') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 259 +SELECT xmltable.* FROM xmltest2, LATERAL xmltable('/d/r' PASSING x COLUMNS a int PATH '' || lower(_path) || 'c') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 260 +SELECT xmltable.* FROM xmltest2, LATERAL xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH '.') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +== 261 +SELECT xmltable.* FROM xmltest2, LATERAL xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH 'x' DEFAULT ascii(_path) - 54) +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="ascii" function="ascii" schema="" ctx=Call +STMT: SelectStmt +== 262 +-- XPath result can be boolean or number too +SELECT * FROM XMLTABLE('*' PASSING 'a' COLUMNS a xml PATH '.', b text PATH '.', c text PATH '"hi"', d boolean PATH '. = "a"', e integer PATH 'string-length(.)') +-- +STMT: SelectStmt +== 263 +SELECT * FROM XMLTABLE('*' PASSING 'pre&deeppost' COLUMNS x xml PATH '/e/n2', y xml PATH '/') +-- +STMT: SelectStmt +== 264 +SELECT * FROM XMLTABLE('.' PASSING XMLELEMENT(NAME a) columns a varchar(20) PATH '""', b xml PATH '""') +-- +STMT: SelectStmt +== 265 +SELECT xmltext(NULL) +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +== 266 +SELECT xmltext('') +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +== 267 +SELECT xmltext(' ') +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +== 268 +SELECT xmltext('foo `$_-+?=*^%!|/\()[]{}') +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +== 269 +SELECT xmltext('foo & <"bar">') +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +== 270 +SELECT xmltext('x'|| '

73

'::xml || .42 || true || 'j'::char) +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary/postgres_regress/xmlmap.metadata.json b/parser/testdata/summary/postgres_regress/xmlmap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/xmlmap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary/postgres_regress/xmlmap.test b/parser/testdata/summary/postgres_regress/xmlmap.test new file mode 100644 index 0000000..824ce75 --- /dev/null +++ b/parser/testdata/summary/postgres_regress/xmlmap.test @@ -0,0 +1,209 @@ +== 001 +CREATE SCHEMA testxmlschema +-- +STMT: CreateSchemaStmt +== 002 +CREATE TABLE testxmlschema.test1 (a int, b text) +-- +TABLE: name="testxmlschema.test1" schema="testxmlschema" table="test1" ctx=DDL +STMT: CreateStmt +== 003 +INSERT INTO testxmlschema.test1 VALUES (1, 'one'), (2, 'two'), (-1, null) +-- +TABLE: name="testxmlschema.test1" schema="testxmlschema" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 004 +CREATE DOMAIN testxmldomain AS varchar +-- +STMT: CreateDomainStmt +== 005 +CREATE TABLE testxmlschema.test2 (z int, y varchar(500), x char(6), + w numeric(9,2), v smallint, u bigint, t real, + s time, stz timetz, r timestamp, rtz timestamptz, q date, + p xml, o testxmldomain, n bool, m bytea, aaa text) +-- +TABLE: name="testxmlschema.test2" schema="testxmlschema" table="test2" ctx=DDL +STMT: CreateStmt +== 006 +ALTER TABLE testxmlschema.test2 DROP COLUMN aaa +-- +TABLE: name="testxmlschema.test2" schema="testxmlschema" table="test2" ctx=DDL +STMT: AlterTableStmt +== 007 +INSERT INTO testxmlschema.test2 VALUES (55, 'abc', 'def', + 98.6, 2, 999, 0, + '21:07', '21:11 +05', '2009-06-08 21:07:30', '2009-06-08 21:07:30 -07', '2009-06-08', + NULL, 'ABC', true, 'XYZ') +-- +TABLE: name="testxmlschema.test2" schema="testxmlschema" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +== 008 +SELECT table_to_xml('testxmlschema.test1', false, false, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 009 +SELECT table_to_xml('testxmlschema.test1', true, false, 'foo') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 010 +SELECT table_to_xml('testxmlschema.test1', false, true, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 011 +SELECT table_to_xml('testxmlschema.test1', true, true, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 012 +SELECT table_to_xml('testxmlschema.test2', false, false, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 013 +SELECT table_to_xmlschema('testxmlschema.test1', false, false, '') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 014 +SELECT table_to_xmlschema('testxmlschema.test1', true, false, '') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 015 +SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 016 +SELECT table_to_xmlschema('testxmlschema.test1', true, true, '') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 017 +SELECT table_to_xmlschema('testxmlschema.test2', false, false, '') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 018 +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, '') +-- +FUNCTION: name="table_to_xml_and_xmlschema" function="table_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 019 +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, '') +-- +FUNCTION: name="table_to_xml_and_xmlschema" function="table_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 020 +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '') +-- +FUNCTION: name="table_to_xml_and_xmlschema" function="table_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 021 +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo') +-- +FUNCTION: name="table_to_xml_and_xmlschema" function="table_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 022 +SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, '') +-- +FUNCTION: name="query_to_xml" function="query_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 023 +SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, '') +-- +FUNCTION: name="query_to_xmlschema" function="query_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 024 +SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, '') +-- +FUNCTION: name="query_to_xml_and_xmlschema" function="query_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 025 +DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2 +-- +STMT: DeclareCursorStmt +== 026 +SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '') +-- +FUNCTION: name="cursor_to_xml" function="cursor_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 027 +SELECT cursor_to_xmlschema('xc'::refcursor, false, true, '') +-- +FUNCTION: name="cursor_to_xmlschema" function="cursor_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 028 +MOVE BACKWARD ALL IN xc +-- +STMT: FetchStmt +== 029 +SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '') +-- +FUNCTION: name="cursor_to_xml" function="cursor_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 030 +SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '') +-- +FUNCTION: name="cursor_to_xmlschema" function="cursor_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 031 +SELECT schema_to_xml('testxmlschema', false, true, '') +-- +FUNCTION: name="schema_to_xml" function="schema_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 032 +SELECT schema_to_xml('testxmlschema', true, false, '') +-- +FUNCTION: name="schema_to_xml" function="schema_to_xml" schema="" ctx=Call +STMT: SelectStmt +== 033 +SELECT schema_to_xmlschema('testxmlschema', false, true, '') +-- +FUNCTION: name="schema_to_xmlschema" function="schema_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 034 +SELECT schema_to_xmlschema('testxmlschema', true, false, '') +-- +FUNCTION: name="schema_to_xmlschema" function="schema_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 035 +SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo') +-- +FUNCTION: name="schema_to_xml_and_xmlschema" function="schema_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +== 036 +-- test that domains are transformed like their base types + +CREATE DOMAIN testboolxmldomain AS bool +-- +STMT: CreateDomainStmt +== 037 +CREATE DOMAIN testdatexmldomain AS date +-- +STMT: CreateDomainStmt +== 038 +CREATE TABLE testxmlschema.test3 + AS SELECT true c1, + true::testboolxmldomain c2, + '2013-02-21'::date c3, + '2013-02-21'::testdatexmldomain c4 +-- +TABLE: name="testxmlschema.test3" schema="testxmlschema" table="test3" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +== 039 +SELECT xmlforest(c1, c2, c3, c4) FROM testxmlschema.test3 +-- +TABLE: name="testxmlschema.test3" schema="testxmlschema" table="test3" ctx=Select +STMT: SelectStmt +== 040 +SELECT table_to_xml('testxmlschema.test3', true, true, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt diff --git a/parser/testdata/summary_truncate/libpg_query.metadata.json b/parser/testdata/summary_truncate/libpg_query.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/libpg_query.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/libpg_query.test b/parser/testdata/summary_truncate/libpg_query.test new file mode 100644 index 0000000..3967025 --- /dev/null +++ b/parser/testdata/summary_truncate/libpg_query.test @@ -0,0 +1,1222 @@ +== 001 +-- truncate_limit: 40 +SELECT a, b, c, d, e, f FROM xyz WHERE a = b +-- +TABLE: name="xyz" schema="" table="xyz" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xyz WHERE a = b" +== 002 +-- truncate_limit: 40 +WITH x AS (SELECT * FROM y) SELECT * FROM x +-- +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH x AS (...) SELECT * FROM x" +== 003 +-- truncate_limit: 30 +SELECT * FROM z WHERE a = b AND x = y +-- +TABLE: name="z" schema="" table="z" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM z WHERE ..." +== 004 +-- truncate_limit: 32 +INSERT INTO "x" (a, b, c, d, e, f) VALUES ($1) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO x (...) VALUES ($1)" +== 005 +-- truncate_limit: 100 +SELECT $1 /* application:test */ +-- +STMT: SelectStmt +TRUNCATED: "SELECT $1" +== 006 +-- truncate_limit: 10 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 007 +-- truncate_limit: 50 +SELECT CASE WHEN $2.typtype = $1 THEN $2.typtypmod ELSE $1.atttypmod END +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 008 +-- truncate_limit: 30 +UPDATE x SET a = 1, c = 2, e = 'str' +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE x SET ... = ..." +== 009 +-- truncate_limit: 65 +INSERT INTO y(a) VALUES(1) ON CONFLICT DO UPDATE SET a = 123456789 +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y (a) VALUES (1) ON CONFLICT DO UPDATE SET ... = ..." +== 010 +-- truncate_limit: 100 + INSERT INTO foo (a, b, c, d) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29) ON CONFLICT (id) DO UPDATE SET (a, b, c, d) = (excluded.a,excluded.b,excluded.c,case when foo.d = excluded.d then excluded.d end) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo (a, b, c, d) VALUES (...) ON CONFLICT (id) DO UPDATE SET ... = ..." +== 011 +-- truncate_limit: 35 +GRANT SELECT (abc, def, ghj) ON TABLE t1 TO r1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (abc, def, ghj) ON ..." +== 012 +-- truncate_limit: 100 + WITH activity AS ( SELECT pid, COALESCE(a.usename, '') AS usename FROM pganalyze.get_stat_activity() a ) SELECT FROM pganalyze.get_stat_progress_vacuum() v JOIN activity a USING (pid) +-- +ALIAS: "a"="activity" +CTE: "activity" +FUNCTION: name="pganalyze.get_stat_progress_vacuum" function="get_stat_progress_vacuum" schema="pganalyze" ctx=Call +FUNCTION: name="pganalyze.get_stat_activity" function="get_stat_activity" schema="pganalyze" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH activity AS (...) SELECT FROM pganalyze.get_stat_progress_vacuum() v JOIN activity a USING (..." +== 013 +-- truncate_limit: 60 +CREATE INDEX testidx ON test USING btree ((lower(d) || upper(d)), a, (b+c)) +-- +TABLE: name="test" schema="" table="test" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX testidx ON test USING btree ((lower(d) || up..." +== 014 +-- truncate_limit: 21 +WITH "原チコ氏にはす腹腹腹腹腹腹腹腹腹腹腹" AS (SELECT) SELECT w +-- +CTE: "原チコ氏にはす腹腹腹腹腹腹腹腹腹腹腹" +STMT: SelectStmt +TRUNCATED: "WITH \"原チコ氏にはす腹腹腹腹腹..." +== 015 +-- truncate_limit: 50 +SELECT * FROM test WHERE a = 1 +-- +TABLE: name="test" schema="" table="test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test WHERE a = 1" +== 016 +-- truncate_limit: 50 +SELECT * FROM test AS x WHERE a = 1 +-- +TABLE: name="test" schema="" table="test" ctx=Select +ALIAS: "x"="test" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test x WHERE a = 1" +== 017 +-- truncate_limit: 50 +SELECT * FROM test WHERE col1 = (SELECT col2 FROM test2 WHERE col3 = 123) +-- +TABLE: name="test" schema="" table="test" ctx=Select +TABLE: name="test2" schema="" table="test2" ctx=Select +FILTER: schema="" table="" column="col1" +FILTER: schema="" table="" column="col3" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test WHERE ..." +== 018 +-- truncate_limit: 50 +CREATE RANDOM ix_test ON contacts.person; +-- +ERROR: syntax error at or near "RANDOM" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 019 +-- truncate_limit: 50 +SELECT 'ERR +-- +ERROR: unterminated quoted string at or near "'ERR" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 020 +-- truncate_limit: 50 +SELECT * FROM "t0" +-- +TABLE: name="t0" schema="" table="t0" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t0" +== 021 +-- truncate_limit: 50 +SELECT * FROM "t0" JOIN "t1" ON (1) +-- +TABLE: name="t0" schema="" table="t0" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t0 JOIN t1 ON 1" +== 022 +-- truncate_limit: 50 +SELECT * FROM "t0" + JOIN "t1" ON (1) JOIN "t2" ON (1) JOIN "t3" ON (1) JOIN "t4" ON (1) JOIN "t5" ON (1) + JOIN "t6" ON (1) JOIN "t7" ON (1) JOIN "t8" ON (1) JOIN "t9" ON (1) JOIN "t10" ON (1) + JOIN "t11" ON (1) JOIN "t12" ON (1) JOIN "t13" ON (1) JOIN "t14" ON (1) JOIN "t15" ON (1) + JOIN "t16" ON (1) JOIN "t17" ON (1) JOIN "t18" ON (1) JOIN "t19" ON (1) JOIN "t20" ON (1) + JOIN "t21" ON (1) JOIN "t22" ON (1) JOIN "t23" ON (1) JOIN "t24" ON (1) JOIN "t25" ON (1) + JOIN "t26" ON (1) JOIN "t27" ON (1) JOIN "t28" ON (1) JOIN "t29" ON (1) +-- +TABLE: name="t0" schema="" table="t0" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +TABLE: name="t4" schema="" table="t4" ctx=Select +TABLE: name="t5" schema="" table="t5" ctx=Select +TABLE: name="t6" schema="" table="t6" ctx=Select +TABLE: name="t7" schema="" table="t7" ctx=Select +TABLE: name="t8" schema="" table="t8" ctx=Select +TABLE: name="t9" schema="" table="t9" ctx=Select +TABLE: name="t10" schema="" table="t10" ctx=Select +TABLE: name="t11" schema="" table="t11" ctx=Select +TABLE: name="t12" schema="" table="t12" ctx=Select +TABLE: name="t13" schema="" table="t13" ctx=Select +TABLE: name="t14" schema="" table="t14" ctx=Select +TABLE: name="t15" schema="" table="t15" ctx=Select +TABLE: name="t16" schema="" table="t16" ctx=Select +TABLE: name="t17" schema="" table="t17" ctx=Select +TABLE: name="t18" schema="" table="t18" ctx=Select +TABLE: name="t19" schema="" table="t19" ctx=Select +TABLE: name="t20" schema="" table="t20" ctx=Select +TABLE: name="t21" schema="" table="t21" ctx=Select +TABLE: name="t22" schema="" table="t22" ctx=Select +TABLE: name="t23" schema="" table="t23" ctx=Select +TABLE: name="t24" schema="" table="t24" ctx=Select +TABLE: name="t25" schema="" table="t25" ctx=Select +TABLE: name="t26" schema="" table="t26" ctx=Select +TABLE: name="t27" schema="" table="t27" ctx=Select +TABLE: name="t28" schema="" table="t28" ctx=Select +TABLE: name="t29" schema="" table="t29" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t0 JOIN t1 ON 1 JOIN t2 ON 1 JOIN..." +== 023 +-- truncate_limit: 50 + + SELECT memory_total_bytes, memory_free_bytes, memory_pagecache_bytes, memory_buffers_bytes, memory_applications_bytes, + (memory_swap_total_bytes - memory_swap_free_bytes) AS swap, date_part($0, s.collected_at) AS collected_at + FROM snapshots s JOIN system_snapshots ON (snapshot_id = s.id) + WHERE s.database_id = $0 AND s.collected_at BETWEEN $0 AND $0 + ORDER BY collected_at +-- +TABLE: name="snapshots" schema="" table="snapshots" ctx=Select +TABLE: name="system_snapshots" schema="" table="system_snapshots" ctx=Select +ALIAS: "s"="snapshots" +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FILTER: schema="" table="s" column="database_id" +FILTER: schema="" table="s" column="collected_at" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM snapshots s JOIN system_snapsho..." +== 024 +-- truncate_limit: 50 +-- nothing +-- + +== 025 +-- truncate_limit: 50 +SELECT .1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT .1" +== 026 +-- truncate_limit: 50 +SELECT X'EFFF' +-- +STMT: SelectStmt +TRUNCATED: "SELECT x'EFFF'" +== 027 +-- truncate_limit: 50 +ALTER TABLE test ADD PRIMARY KEY (gid) +-- +TABLE: name="test" schema="" table="test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test ADD PRIMARY KEY (gid)" +== 028 +-- truncate_limit: 50 +SET statement_timeout=1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET statement_timeout TO 1" +== 029 +-- truncate_limit: 50 +SHOW work_mem +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW work_mem" +== 030 +-- truncate_limit: 50 +COPY test (id) TO stdout +-- +TABLE: name="test" schema="" table="test" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY test(id) TO STDOUT" +== 031 +-- truncate_limit: 50 +drop table abc.test123 cascade +-- +TABLE: name="abc.test123" schema="abc" table="test123" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE abc.test123 CASCADE" +== 032 +-- truncate_limit: 50 +drop table abc.test123, test +-- +TABLE: name="abc.test123" schema="abc" table="test123" ctx=DDL +TABLE: name="test" schema="" table="test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE abc.test123, test" +== 033 +-- truncate_limit: 50 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 034 +-- truncate_limit: 50 +CHECKPOINT +-- +STMT: CheckPointStmt +TRUNCATED: "CHECKPOINT" +== 035 +-- truncate_limit: 50 +VACUUM my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM my_table" +== 036 +-- truncate_limit: 50 +WITH cte AS (SELECT * FROM g.other_table CROSS JOIN p) MERGE INTO my_table USING cte ON (id=oid) WHEN MATCHED THEN UPDATE SET a=b WHEN NOT MATCHED THEN INSERT (id, a) VALUES (oid, b); +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +TABLE: name="g.other_table" schema="g" table="other_table" ctx=Select +TABLE: name="p" schema="" table="p" ctx=Select +CTE: "cte" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "WITH cte AS (...) MERGE INTO my_table USING cte..." +== 037 +-- truncate_limit: 50 +EXPLAIN DELETE FROM test +-- +TABLE: name="test" schema="" table="test" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN DELETE FROM test" +== 038 +-- truncate_limit: 50 +CREATE TEMP TABLE test AS SELECT 1 +-- +TABLE: name="test" schema="" table="test" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE test AS SELECT 1" +== 039 +-- truncate_limit: 50 +LOCK TABLE public.schema_migrations IN ACCESS SHARE MODE +-- +TABLE: name="public.schema_migrations" schema="public" table="schema_migrations" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE public.schema_migrations IN ACCESS S..." +== 040 +-- truncate_limit: 50 +CREATE TABLE test (a int4) +-- +TABLE: name="test" schema="" table="test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test (a int4)" +== 041 +-- truncate_limit: 50 +CREATE TABLE foo AS SELECT * FROM bar; +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +TABLE: name="bar" schema="" table="bar" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE foo AS SELECT * FROM bar" +== 042 +-- truncate_limit: 50 +CREATE TABLE foo AS SELECT id FROM bar UNION SELECT id from baz; +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +TABLE: name="bar" schema="" table="bar" ctx=Select +TABLE: name="baz" schema="" table="baz" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE foo AS SELECT id FROM bar UNION SE..." +== 043 +-- truncate_limit: 50 +CREATE TABLE test (a int4) WITH OIDS +-- +ERROR: syntax error at or near "OIDS" +CURSORPOS: 33 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 044 +-- truncate_limit: 50 +CREATE INDEX testidx ON test USING btree (a, (lower(b) || upper(c))) WHERE pow(a, 2) > 25 +-- +TABLE: name="test" schema="" table="test" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="pow" function="pow" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX testidx ON test USING btree (a, (l..." +== 045 +-- truncate_limit: 50 +CREATE SCHEMA IF NOT EXISTS test AUTHORIZATION joe +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA IF NOT EXISTS test AUTHORIZATION joe" +== 046 +-- truncate_limit: 50 +CREATE VIEW myview AS SELECT * FROM mytab +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +TABLE: name="mytab" schema="" table="mytab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW myview AS SELECT * FROM mytab" +== 047 +-- truncate_limit: 50 +REFRESH MATERIALIZED VIEW myview +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW myview" +== 048 +-- truncate_limit: 50 +CREATE RULE shoe_ins_protect AS ON INSERT TO shoe DO INSTEAD NOTHING +-- +TABLE: name="shoe" schema="" table="shoe" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE shoe_ins_protect AS ON INSERT TO sh..." +== 049 +-- truncate_limit: 50 +CREATE TRIGGER check_update BEFORE UPDATE ON accounts FOR EACH ROW EXECUTE PROCEDURE check_account_update() +-- +TABLE: name="accounts" schema="" table="accounts" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER check_update BEFORE UPDATE ON ac..." +== 050 +-- truncate_limit: 50 +DROP SCHEMA myschema +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA myschema" +== 051 +-- truncate_limit: 50 +DROP VIEW myview, myview2 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW myview, myview2" +== 052 +-- truncate_limit: 50 +DROP INDEX CONCURRENTLY myindex +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY myindex" +== 053 +-- truncate_limit: 50 +DROP RULE myrule ON mytable CASCADE +-- +TABLE: name="mytable" schema="" table="mytable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE myrule ON mytable CASCADE" +== 054 +-- truncate_limit: 50 +DROP TRIGGER IF EXISTS mytrigger ON mytable RESTRICT +-- +TABLE: name="mytable" schema="" table="mytable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER IF EXISTS mytrigger ON mytable" +== 055 +-- truncate_limit: 50 +GRANT INSERT, UPDATE ON mytable TO myuser +-- +TABLE: name="mytable" schema="" table="mytable" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert, update ON mytable TO myuser" +== 056 +-- truncate_limit: 50 +REVOKE admins FROM joe +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE admins FROM joe" +== 057 +-- truncate_limit: 50 +TRUNCATE bigtable, "fattable" RESTART IDENTITY +-- +TABLE: name="bigtable" schema="" table="bigtable" ctx=DDL +TABLE: name="fattable" schema="" table="fattable" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE bigtable, fattable RESTART IDENTITY" +== 058 +-- truncate_limit: 50 +WITH a AS (SELECT * FROM x WHERE x.y = $1 AND x.z = 1) SELECT * FROM a +-- +TABLE: name="x" schema="" table="x" ctx=Select +CTE: "a" +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +TRUNCATED: "WITH a AS (...) SELECT * FROM a" +== 059 +-- truncate_limit: 50 +CREATE OR REPLACE FUNCTION thing(parameter_thing text) + RETURNS bigint AS +$BODY$ +DECLARE + local_thing_id BIGINT := 0; +BEGIN + SELECT thing_id INTO local_thing_id FROM thing_map + WHERE + thing_map_field = parameter_thing + ORDER BY 1 LIMIT 1; + + IF NOT FOUND THEN + local_thing_id = 0; + END IF; + RETURN local_thing_id; +END; +$BODY$ + LANGUAGE plpgsql STABLE +-- +FUNCTION: name="thing" function="thing" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION thing(parameter_thin..." +== 060 +-- truncate_limit: 50 +CREATE FUNCTION getfoo(int) RETURNS TABLE (f1 int) AS 'SELECT * FROM foo WHERE fooid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getfoo" function="getfoo" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getfoo(int) RETURNS TABLE (f1 i..." +== 061 +-- truncate_limit: 50 +SELECT testfunc(1); +-- +FUNCTION: name="testfunc" function="testfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testfunc(1)" +== 062 +-- truncate_limit: 50 +CALL testfunc(1); +-- +FUNCTION: name="testfunc" function="testfunc" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL testfunc(1)" +== 063 +-- truncate_limit: 50 +DROP FUNCTION IF EXISTS testfunc(x integer); +-- +FUNCTION: name="testfunc" function="testfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION IF EXISTS testfunc(x int)" +== 064 +-- truncate_limit: 50 +ALTER FUNCTION testfunc(integer) RENAME TO testfunc2; +-- +FUNCTION: name="testfunc" function="testfunc" schema="" ctx=DDL +FUNCTION: name="testfunc2" function="testfunc2" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER FUNCTION testfunc(int) RENAME TO testfunc2" +== 065 +-- truncate_limit: 50 +select u.email, (select count(*) from enrollments e where e.user_id = u.id) as num_enrollments from users u +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="enrollments" schema="" table="enrollments" ctx=Select +ALIAS: "e"="enrollments" +ALIAS: "u"="users" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="e" column="user_id" +FILTER: schema="" table="u" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM users u" +== 066 +-- truncate_limit: 50 +WITH cte_name AS (SELECT 1) SELECT * FROM table_name, cte_name +-- +TABLE: name="table_name" schema="" table="table_name" ctx=Select +CTE: "cte_name" +STMT: SelectStmt +TRUNCATED: "WITH cte_name AS (...) SELECT * FROM table_name..." +== 067 +-- truncate_limit: 50 +SELECT * FROM tbl TABLESAMPLE sample(1) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tbl TABLESAMPLE sample(1)" +== 068 +-- truncate_limit: 50 +SELECT xmltable.* FROM xmlelements, XMLTABLE('/root' PASSING data COLUMNS element text) +-- +TABLE: name="xmlelements" schema="" table="xmlelements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmlelements, xmltable(('/root')..." +== 069 +-- truncate_limit: 50 +SELECT jt.* FROM my_films, JSON_TABLE (js, '$.favorites[*]' COLUMNS (id FOR ORDINALITY, kind text PATH '$.kind')) AS jt; +-- +TABLE: name="my_films" schema="" table="my_films" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM my_films, JSON_TABLE(js , '$.fa..." +== 070 +-- truncate_limit: 50 +select u.* from (select * from users) u +-- +TABLE: name="users" schema="" table="users" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT u.* FROM (SELECT * FROM users) u" +== 071 +-- truncate_limit: 50 +select users.id from users where 1 = (select count(*) from user_roles) +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT users.id FROM users WHERE ..." +== 072 +-- truncate_limit: 50 + + SELECT * + FROM pg_catalog.pg_class c + JOIN ( + SELECT 17650 AS oid + UNION ALL + SELECT 17663 AS oid + ) vals ON c.oid = vals.oid + +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_catalog.pg_class c JOIN (SELEC..." +== 073 +-- truncate_limit: 50 + + select users.* + from users + where users.id IN (select user_roles.user_id from user_roles) + and (users.created_at between '2016-06-01' and '2016-06-30') + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT users.* FROM users WHERE ..." +== 074 +-- truncate_limit: 50 + + select users.* + from users + order by ( + select max(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM users ORDER BY (SELECT ... FROM..." +== 075 +-- truncate_limit: 50 + + select users.* + from users + order by ( + select max(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) asc, ( + select max(user_logins.role_id) + from user_logins + where user_logins.user_id = users.id + ) desc + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +TABLE: name="user_logins" schema="" table="user_logins" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +FILTER: schema="" table="user_logins" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM users ORDER BY (SELECT ... FROM..." +== 076 +-- truncate_limit: 50 + + select users.* + from users + group by ( + select max(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM users GROUP BY (SELECT ... FROM..." +== 077 +-- truncate_limit: 50 + + select users.* + from users + group by ( + select max(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ), ( + select max(user_logins.role_id) + from user_logins + where user_logins.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +TABLE: name="user_logins" schema="" table="user_logins" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +FILTER: schema="" table="user_logins" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM users GROUP BY (SELECT ... FROM..." +== 078 +-- truncate_limit: 50 + + select users.* + from users + group by users.id + having 1 > ( + select count(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM users GROUP BY users.id HAVING ..." +== 079 +-- truncate_limit: 50 + + select users.* + from users + group by users.id + having true and 1 > ( + select count(user_roles.role_id) + from user_roles + where user_roles.user_id = users.id + ) + +-- +TABLE: name="users" schema="" table="users" ctx=Select +TABLE: name="user_roles" schema="" table="user_roles" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="user_roles" column="user_id" +FILTER: schema="" table="users" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM users GROUP BY users.id HAVING ..." +== 080 +-- truncate_limit: 50 + + select foo.* + from foo + join ( select * from bar ) b + on b.baz = foo.quux + +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM foo JOIN (SELECT * FROM bar) b ..." +== 081 +-- truncate_limit: 50 + + SELECT * + FROM foo + INNER JOIN join_a ON foo.id = join_a.id AND join_a.id IN ( + SELECT id + FROM sub_a + INNER JOIN sub_b ON sub_a.id = sub_b.id AND sub_b.id IN ( + SELECT id + FROM sub_c + INNER JOIN sub_d ON sub_c.id IN (SELECT id from sub_e) + ) + ) + INNER JOIN join_b ON foo.id = join_b.id AND join_b.id IN ( + SELECT id FROM sub_f + ) + +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="join_a" schema="" table="join_a" ctx=Select +TABLE: name="join_b" schema="" table="join_b" ctx=Select +TABLE: name="sub_a" schema="" table="sub_a" ctx=Select +TABLE: name="sub_b" schema="" table="sub_b" ctx=Select +TABLE: name="sub_c" schema="" table="sub_c" ctx=Select +TABLE: name="sub_d" schema="" table="sub_d" ctx=Select +TABLE: name="sub_e" schema="" table="sub_e" ctx=Select +TABLE: name="sub_f" schema="" table="sub_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo JOIN join_a ON foo.id = join_..." +== 082 +-- truncate_limit: 50 + + WITH cte_a AS ( + SELECT * FROM table_a + ), cte_b AS ( + SELECT * FROM table_b + ) + SELECT id FROM table_c + LEFT JOIN cte_b ON table_c.id = cte_b.c_id + UNION + SELECT * FROM cte_a + +-- +TABLE: name="table_a" schema="" table="table_a" ctx=Select +TABLE: name="table_b" schema="" table="table_b" ctx=Select +TABLE: name="table_c" schema="" table="table_c" ctx=Select +CTE: "cte_a" +CTE: "cte_b" +STMT: SelectStmt +TRUNCATED: "WITH cte_a AS (...), cte_b AS (...) SELECT id F..." +== 083 +-- truncate_limit: 50 + + WITH cte_a AS ( + SELECT * FROM table_a + ), cte_b AS ( + SELECT * FROM table_b + ) + SELECT id FROM table_c + LEFT JOIN cte_b ON table_c.id = cte_b.c_id + EXCEPT + SELECT * FROM cte_a + +-- +TABLE: name="table_a" schema="" table="table_a" ctx=Select +TABLE: name="table_b" schema="" table="table_b" ctx=Select +TABLE: name="table_c" schema="" table="table_c" ctx=Select +CTE: "cte_a" +CTE: "cte_b" +STMT: SelectStmt +TRUNCATED: "WITH cte_a AS (...), cte_b AS (...) SELECT id F..." +== 084 +-- truncate_limit: 50 + + WITH cte_a AS ( + SELECT * FROM table_a + ), cte_b AS ( + SELECT * FROM table_b + ) + SELECT id FROM table_c + LEFT JOIN cte_b ON table_c.id = cte_b.c_id + INTERSECT + SELECT * FROM cte_a + +-- +TABLE: name="table_a" schema="" table="table_a" ctx=Select +TABLE: name="table_b" schema="" table="table_b" ctx=Select +TABLE: name="table_c" schema="" table="table_c" ctx=Select +CTE: "cte_a" +CTE: "cte_b" +STMT: SelectStmt +TRUNCATED: "WITH cte_a AS (...), cte_b AS (...) SELECT id F..." +== 085 +-- truncate_limit: 50 + + SELECT GREATEST( + date_trunc($1, $2::timestamptz) + $3::interval, + COALESCE( + ( + SELECT first_aggregate_starts_at + FROM schema_aggregate_infos + WHERE base_table = $4 LIMIT $5 + ), + now() + $6::interval + ) + ) AS first_hourly_start_ts + +-- +TABLE: name="schema_aggregate_infos" schema="" table="schema_aggregate_infos" ctx=Select +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="" column="base_table" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 086 +-- truncate_limit: 50 + + SELECT + CASE + WHEN id IN (SELECT foo_id FROM when_a) THEN (SELECT MAX(id) FROM then_a) + WHEN id IN (SELECT foo_id FROM when_b) THEN (SELECT MAX(id) FROM then_b) + ELSE (SELECT MAX(id) FROM elsey) + END + FROM foo + +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="when_a" schema="" table="when_a" ctx=Select +TABLE: name="then_a" schema="" table="then_a" ctx=Select +TABLE: name="when_b" schema="" table="when_b" ctx=Select +TABLE: name="then_b" schema="" table="then_b" ctx=Select +TABLE: name="elsey" schema="" table="elsey" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM foo" +== 087 +-- truncate_limit: 50 + + SELECT 1 + FROM foo + WHERE x = any(cast(array(SELECT a FROM bar) as bigint[])) + OR x = any(array(SELECT a FROM baz)::bigint[]) + +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +TABLE: name="baz" schema="" table="baz" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM foo WHERE ..." +== 088 +-- truncate_limit: 50 +SELECT * FROM my_custom_func() +-- +FUNCTION: name="my_custom_func" function="my_custom_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_custom_func()" +== 089 +-- truncate_limit: 50 + + SELECT * + FROM unnest($1::text[]) AS a(x) + LEFT OUTER JOIN LATERAL ( + SELECT json_build_object($2, z.z) + FROM ( + SELECT * + FROM ( + SELECT row_to_json( + (SELECT * FROM (SELECT public.my_function(b) FROM public.c) d) + ) + ) e + ) f + ) AS g ON (1) + +-- +TABLE: name="public.c" schema="public" table="c" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="public.my_function" function="my_function" schema="public" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest($1::text[]) a(x) LEFT JOIN..." +== 090 +-- truncate_limit: 50 +insert into users(pk, name) values (1, 'bob'); +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO users (pk, name) VALUES (1, 'bob')" +== 091 +-- truncate_limit: 50 +insert into users(pk, name) select pk, name from other_users; +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO users (...) SELECT ... FROM other_u..." +== 092 +-- truncate_limit: 50 + + with cte as ( + select pk, name from other_users + ) + insert into users(pk, name) select * from cte; + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +CTE: "cte" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH cte AS (...) INSERT INTO users (...) SELEC..." +== 093 +-- truncate_limit: 50 +update users set name = 'bob'; +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE users SET name = 'bob'" +== 094 +-- truncate_limit: 50 +update users set name = (select name from other_users limit 1); +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE users SET ... = ..." +== 095 +-- truncate_limit: 50 + + with cte as ( + select name from other_users limit 1 + ) + update users set name = (select name from cte); + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +CTE: "cte" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "WITH cte AS (...) UPDATE users SET ... = ..." +== 096 +-- truncate_limit: 50 + + with cte as ( + select name from other_users limit 1 + ) + update users set name = (select name from cte); + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="other_users" schema="" table="other_users" ctx=Select +CTE: "cte" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "WITH cte AS (...) UPDATE users SET ... = ..." +== 097 +-- truncate_limit: 50 +DELETE FROM users; +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM users" +== 098 +-- truncate_limit: 50 + + DELETE FROM users USING foo + WHERE foo_id = foo.id AND foo.action = 'delete'; + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: DeleteStmt +TRUNCATED: "DELETE FROM users USING foo WHERE ..." +== 099 +-- truncate_limit: 50 + + DELETE FROM users USING foo + WHERE foo_id = foo.id AND foo.action = 'delete'; + +-- +TABLE: name="users" schema="" table="users" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: DeleteStmt +TRUNCATED: "DELETE FROM users USING foo WHERE ..." +== 100 +-- truncate_limit: 50 +DROP TYPE IF EXISTS repack.pk_something +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE IF EXISTS repack.pk_something" +== 101 +-- truncate_limit: 50 +SELECT * FROM x WHERE y = $1 AND z = 1 +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE y = $1 AND z = 1" +== 102 +-- truncate_limit: 50 +SELECT * FROM x WHERE x.y = $1 AND x.z = 1 +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE x.y = $1 AND x.z = 1" +== 103 +-- truncate_limit: 50 +WITH a AS (SELECT * FROM x WHERE x.y = $1 AND x.z = 1) SELECT * FROM a WHERE b = 5 +-- +TABLE: name="x" schema="" table="x" ctx=Select +CTE: "a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +TRUNCATED: "WITH a AS (...) SELECT * FROM a WHERE b = 5" +== 104 +-- truncate_limit: 50 +SELECT * FROM x WHERE x.y IS TRUE AND x.z IS NOT FALSE +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ..." +== 105 +-- truncate_limit: 50 +SELECT * FROM x WHERE x.y IS NULL AND x.z IS NOT NULL +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ..." +== 106 +-- truncate_limit: 50 +SELECT * FROM x WHERE x.y = COALESCE(z.a, z.b) +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE x.y = COALESCE(z.a, z.b)" +== 107 +-- truncate_limit: 50 +SELECT * FROM x where y = $1 UNION SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ... UNION SELECT * FROM x..." +== 108 +-- truncate_limit: 50 +SELECT * FROM x where y = $1 UNION ALL SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ... UNION ALL SELECT * FR..." +== 109 +-- truncate_limit: 50 +SELECT * FROM x where y = $1 EXCEPT SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ... EXCEPT SELECT * FROM ..." +== 110 +-- truncate_limit: 50 +SELECT * FROM x where y = $1 EXCEPT ALL SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ... EXCEPT ALL SELECT * F..." +== 111 +-- truncate_limit: 50 +SELECT * FROM x where y = $1 INTERSECT SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ... INTERSECT SELECT * FR..." +== 112 +-- truncate_limit: 50 +SELECT * FROM x where y = $1 INTERSECT ALL SELECT * FROM x where z = $2 +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ... INTERSECT ALL SELECT ..." +== 113 +-- truncate_limit: 50 +SELECT a, y, z FROM x WHERE x.y = $1 AND x.z = 1 +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT a, y, z FROM x WHERE x.y = $1 AND x.z = 1" +== 114 +-- truncate_limit: 50 +SELECT * FROM x WHERE x.y = $1 AND x.z = 1 ORDER BY a, b +-- +TABLE: name="x" schema="" table="x" ctx=Select +FILTER: schema="" table="x" column="y" +FILTER: schema="" table="x" column="z" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x WHERE ... ORDER BY a, b" +== 115 +-- truncate_limit: 50 +GRANT SELECT ON ALL TABLES IN SCHEMA public TO myrole +-- +STMT: GrantStmt +TRUNCATED: "GRANT select ON ALL TABLES IN SCHEMA public TO ..." +== 116 +-- truncate_limit: 50 +SELECT * FROM b.c WHERE a.b.c = 1 +-- +TABLE: name="b.c" schema="b" table="c" ctx=Select +FILTER: schema="a" table="b" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM b.c WHERE a.b.c = 1" diff --git a/parser/testdata/summary_truncate/postgres_regress/advisory_lock.metadata.json b/parser/testdata/summary_truncate/postgres_regress/advisory_lock.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/advisory_lock.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/advisory_lock.test b/parser/testdata/summary_truncate/postgres_regress/advisory_lock.test new file mode 100644 index 0000000..3827ffc --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/advisory_lock.test @@ -0,0 +1,394 @@ +== 001 +-- truncate_limit: 100 +|-- +-- ADVISORY LOCKS +|-- + +SELECT oid AS datoid FROM pg_database WHERE datname = current_database() +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +TRUNCATED: "SELECT oid AS datoid FROM pg_database WHERE datname = current_database()" +== 002 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 003 +-- truncate_limit: 100 +SELECT + pg_advisory_xact_lock(1), pg_advisory_xact_lock_shared(2), + pg_advisory_xact_lock(1, 1), pg_advisory_xact_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 004 +-- truncate_limit: 100 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- truncate_limit: 100 +-- pg_advisory_unlock_all() shouldn't release xact locks +SELECT pg_advisory_unlock_all() +-- +FUNCTION: name="pg_advisory_unlock_all" function="pg_advisory_unlock_all" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_advisory_unlock_all()" +== 006 +-- truncate_limit: 100 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- truncate_limit: 100 +-- can't unlock xact locks +SELECT + pg_advisory_unlock(1), pg_advisory_unlock_shared(2), + pg_advisory_unlock(1, 1), pg_advisory_unlock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 008 +-- truncate_limit: 100 +-- automatically release xact locks at commit +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 009 +-- truncate_limit: 100 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 010 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 011 +-- truncate_limit: 100 +-- holding both session and xact locks on the same objects, xact first +SELECT + pg_advisory_xact_lock(1), pg_advisory_xact_lock_shared(2), + pg_advisory_xact_lock(1, 1), pg_advisory_xact_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 012 +-- truncate_limit: 100 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 013 +-- truncate_limit: 100 +SELECT + pg_advisory_lock(1), pg_advisory_lock_shared(2), + pg_advisory_lock(1, 1), pg_advisory_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 014 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 015 +-- truncate_limit: 100 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 016 +-- truncate_limit: 100 +-- unlocking session locks +SELECT + pg_advisory_unlock(1), pg_advisory_unlock(1), + pg_advisory_unlock_shared(2), pg_advisory_unlock_shared(2), + pg_advisory_unlock(1, 1), pg_advisory_unlock(1, 1), + pg_advisory_unlock_shared(2, 2), pg_advisory_unlock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 017 +-- truncate_limit: 100 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 018 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 019 +-- truncate_limit: 100 +-- holding both session and xact locks on the same objects, session first +SELECT + pg_advisory_lock(1), pg_advisory_lock_shared(2), + pg_advisory_lock(1, 1), pg_advisory_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 020 +-- truncate_limit: 100 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 021 +-- truncate_limit: 100 +SELECT + pg_advisory_xact_lock(1), pg_advisory_xact_lock_shared(2), + pg_advisory_xact_lock(1, 1), pg_advisory_xact_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 022 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 023 +-- truncate_limit: 100 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 024 +-- truncate_limit: 100 +-- releasing all session locks +SELECT pg_advisory_unlock_all() +-- +FUNCTION: name="pg_advisory_unlock_all" function="pg_advisory_unlock_all" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_advisory_unlock_all()" +== 025 +-- truncate_limit: 100 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 026 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 027 +-- truncate_limit: 100 +-- grabbing txn locks multiple times + +SELECT + pg_advisory_xact_lock(1), pg_advisory_xact_lock(1), + pg_advisory_xact_lock_shared(2), pg_advisory_xact_lock_shared(2), + pg_advisory_xact_lock(1, 1), pg_advisory_xact_lock(1, 1), + pg_advisory_xact_lock_shared(2, 2), pg_advisory_xact_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock" function="pg_advisory_xact_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 028 +-- truncate_limit: 100 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 029 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 030 +-- truncate_limit: 100 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 031 +-- truncate_limit: 100 +-- grabbing session locks multiple times + +SELECT + pg_advisory_lock(1), pg_advisory_lock(1), + pg_advisory_lock_shared(2), pg_advisory_lock_shared(2), + pg_advisory_lock(1, 1), pg_advisory_lock(1, 1), + pg_advisory_lock_shared(2, 2), pg_advisory_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 032 +-- truncate_limit: 100 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 033 +-- truncate_limit: 100 +SELECT + pg_advisory_unlock(1), pg_advisory_unlock(1), + pg_advisory_unlock_shared(2), pg_advisory_unlock_shared(2), + pg_advisory_unlock(1, 1), pg_advisory_unlock(1, 1), + pg_advisory_unlock_shared(2, 2), pg_advisory_unlock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock" function="pg_advisory_unlock" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_unlock_shared" function="pg_advisory_unlock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 034 +-- truncate_limit: 100 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 035 +-- truncate_limit: 100 +-- .. and releasing them all at once + +SELECT + pg_advisory_lock(1), pg_advisory_lock(1), + pg_advisory_lock_shared(2), pg_advisory_lock_shared(2), + pg_advisory_lock(1, 1), pg_advisory_lock(1, 1), + pg_advisory_lock_shared(2, 2), pg_advisory_lock_shared(2, 2) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +FUNCTION: name="pg_advisory_lock_shared" function="pg_advisory_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 036 +-- truncate_limit: 100 +SELECT locktype, classid, objid, objsubid, mode, granted + FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid + ORDER BY classid, objid, objsubid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 037 +-- truncate_limit: 100 +SELECT pg_advisory_unlock_all() +-- +FUNCTION: name="pg_advisory_unlock_all" function="pg_advisory_unlock_all" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_advisory_unlock_all()" +== 038 +-- truncate_limit: 100 +SELECT count(*) FROM pg_locks WHERE locktype = 'advisory' AND database = :datoid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary_truncate/postgres_regress/aggregates.metadata.json b/parser/testdata/summary_truncate/postgres_regress/aggregates.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/aggregates.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/aggregates.test b/parser/testdata/summary_truncate/postgres_regress/aggregates.test new file mode 100644 index 0000000..c66a4f6 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/aggregates.test @@ -0,0 +1,5035 @@ +== 001 +-- truncate_limit: 100 +|-- +-- AGGREGATES +|-- + +-- directory paths are passed to us in environment variables + +-- avoid bit-exact output here because operations may not be bit-exact. +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO 0" +== 002 +-- truncate_limit: 100 +-- prepare some test data +CREATE TABLE aggtest ( + a int2, + b float4 +) +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE aggtest (a int2, b float4)" +== 003 +-- truncate_limit: 100 +COPY aggtest FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +ANALYZE aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE aggtest" +== 005 +-- truncate_limit: 100 +SELECT avg(four) AS avg_1 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(four) AS avg_1 FROM onek" +== 006 +-- truncate_limit: 100 +SELECT avg(a) AS avg_32 FROM aggtest WHERE a < 100 +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT avg(a) AS avg_32 FROM aggtest WHERE a < 100" +== 007 +-- truncate_limit: 100 +SELECT any_value(v) FROM (VALUES (1), (2), (3)) AS v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT any_value(v) FROM (VALUES (1), (2), (3)) v(v)" +== 008 +-- truncate_limit: 100 +SELECT any_value(v) FROM (VALUES (NULL)) AS v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT any_value(v) FROM (VALUES (NULL)) v(v)" +== 009 +-- truncate_limit: 100 +SELECT any_value(v) FROM (VALUES (NULL), (1), (2)) AS v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT any_value(v) FROM (VALUES (NULL), (1), (2)) v(v)" +== 010 +-- truncate_limit: 100 +SELECT any_value(v) FROM (VALUES (array['hello', 'world'])) AS v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT any_value(v) FROM (VALUES (ARRAY['hello', 'world'])) v(v)" +== 011 +-- truncate_limit: 100 +-- In 7.1, avg(float4) is computed using float8 arithmetic. +-- Round the result to 3 digits to avoid platform-specific results. + +SELECT avg(b)::numeric(10,3) AS avg_107_943 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(b)::numeric(10, 3) AS avg_107_943 FROM aggtest" +== 012 +-- truncate_limit: 100 +SELECT avg(gpa) AS avg_3_4 FROM ONLY student +-- +TABLE: name="student" schema="" table="student" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(gpa) AS avg_3_4 FROM ONLY student" +== 013 +-- truncate_limit: 100 +SELECT sum(four) AS sum_1500 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(four) AS sum_1500 FROM onek" +== 014 +-- truncate_limit: 100 +SELECT sum(a) AS sum_198 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(a) AS sum_198 FROM aggtest" +== 015 +-- truncate_limit: 100 +SELECT sum(b) AS avg_431_773 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(b) AS avg_431_773 FROM aggtest" +== 016 +-- truncate_limit: 100 +SELECT sum(gpa) AS avg_6_8 FROM ONLY student +-- +TABLE: name="student" schema="" table="student" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(gpa) AS avg_6_8 FROM ONLY student" +== 017 +-- truncate_limit: 100 +SELECT max(four) AS max_3 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(four) AS max_3 FROM onek" +== 018 +-- truncate_limit: 100 +SELECT max(a) AS max_100 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(a) AS max_100 FROM aggtest" +== 019 +-- truncate_limit: 100 +SELECT max(aggtest.b) AS max_324_78 FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(aggtest.b) AS max_324_78 FROM aggtest" +== 020 +-- truncate_limit: 100 +SELECT max(student.gpa) AS max_3_7 FROM student +-- +TABLE: name="student" schema="" table="student" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(student.gpa) AS max_3_7 FROM student" +== 021 +-- truncate_limit: 100 +SELECT stddev_pop(b) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop(b) FROM aggtest" +== 022 +-- truncate_limit: 100 +SELECT stddev_samp(b) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_samp(b) FROM aggtest" +== 023 +-- truncate_limit: 100 +SELECT var_pop(b) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop(b) FROM aggtest" +== 024 +-- truncate_limit: 100 +SELECT var_samp(b) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_samp(b) FROM aggtest" +== 025 +-- truncate_limit: 100 +SELECT stddev_pop(b::numeric) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop(b::numeric) FROM aggtest" +== 026 +-- truncate_limit: 100 +SELECT stddev_samp(b::numeric) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_samp(b::numeric) FROM aggtest" +== 027 +-- truncate_limit: 100 +SELECT var_pop(b::numeric) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop(b::numeric) FROM aggtest" +== 028 +-- truncate_limit: 100 +SELECT var_samp(b::numeric) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_samp(b::numeric) FROM aggtest" +== 029 +-- truncate_limit: 100 +-- population variance is defined for a single tuple, sample variance +-- is not +SELECT var_pop(1.0::float8), var_samp(2.0::float8) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop((1.0)::float8), var_samp((2.0)::float8)" +== 030 +-- truncate_limit: 100 +SELECT stddev_pop(3.0::float8), stddev_samp(4.0::float8) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop((3.0)::float8), stddev_samp((4.0)::float8)" +== 031 +-- truncate_limit: 100 +SELECT var_pop('inf'::float8), var_samp('inf'::float8) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop('inf'::float8), var_samp('inf'::float8)" +== 032 +-- truncate_limit: 100 +SELECT stddev_pop('inf'::float8), stddev_samp('inf'::float8) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop('inf'::float8), stddev_samp('inf'::float8)" +== 033 +-- truncate_limit: 100 +SELECT var_pop('nan'::float8), var_samp('nan'::float8) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop('nan'::float8), var_samp('nan'::float8)" +== 034 +-- truncate_limit: 100 +SELECT stddev_pop('nan'::float8), stddev_samp('nan'::float8) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop('nan'::float8), stddev_samp('nan'::float8)" +== 035 +-- truncate_limit: 100 +SELECT var_pop(1.0::float4), var_samp(2.0::float4) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop((1.0)::float4), var_samp((2.0)::float4)" +== 036 +-- truncate_limit: 100 +SELECT stddev_pop(3.0::float4), stddev_samp(4.0::float4) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop((3.0)::float4), stddev_samp((4.0)::float4)" +== 037 +-- truncate_limit: 100 +SELECT var_pop('inf'::float4), var_samp('inf'::float4) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop('inf'::float4), var_samp('inf'::float4)" +== 038 +-- truncate_limit: 100 +SELECT stddev_pop('inf'::float4), stddev_samp('inf'::float4) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop('inf'::float4), stddev_samp('inf'::float4)" +== 039 +-- truncate_limit: 100 +SELECT var_pop('nan'::float4), var_samp('nan'::float4) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop('nan'::float4), var_samp('nan'::float4)" +== 040 +-- truncate_limit: 100 +SELECT stddev_pop('nan'::float4), stddev_samp('nan'::float4) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop('nan'::float4), stddev_samp('nan'::float4)" +== 041 +-- truncate_limit: 100 +SELECT var_pop(1.0::numeric), var_samp(2.0::numeric) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop((1.0)::numeric), var_samp((2.0)::numeric)" +== 042 +-- truncate_limit: 100 +SELECT stddev_pop(3.0::numeric), stddev_samp(4.0::numeric) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop((3.0)::numeric), stddev_samp((4.0)::numeric)" +== 043 +-- truncate_limit: 100 +SELECT var_pop('inf'::numeric), var_samp('inf'::numeric) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop('inf'::numeric), var_samp('inf'::numeric)" +== 044 +-- truncate_limit: 100 +SELECT stddev_pop('inf'::numeric), stddev_samp('inf'::numeric) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop('inf'::numeric), stddev_samp('inf'::numeric)" +== 045 +-- truncate_limit: 100 +SELECT var_pop('nan'::numeric), var_samp('nan'::numeric) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT var_pop('nan'::numeric), var_samp('nan'::numeric)" +== 046 +-- truncate_limit: 100 +SELECT stddev_pop('nan'::numeric), stddev_samp('nan'::numeric) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev_pop('nan'::numeric), stddev_samp('nan'::numeric)" +== 047 +-- truncate_limit: 100 +-- verify correct results for null and NaN inputs +select sum(null::int4) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(NULL::int4) FROM generate_series(1, 3)" +== 048 +-- truncate_limit: 100 +select sum(null::int8) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(NULL::int8) FROM generate_series(1, 3)" +== 049 +-- truncate_limit: 100 +select sum(null::numeric) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(NULL::numeric) FROM generate_series(1, 3)" +== 050 +-- truncate_limit: 100 +select sum(null::float8) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(NULL::float8) FROM generate_series(1, 3)" +== 051 +-- truncate_limit: 100 +select avg(null::int4) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(NULL::int4) FROM generate_series(1, 3)" +== 052 +-- truncate_limit: 100 +select avg(null::int8) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(NULL::int8) FROM generate_series(1, 3)" +== 053 +-- truncate_limit: 100 +select avg(null::numeric) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(NULL::numeric) FROM generate_series(1, 3)" +== 054 +-- truncate_limit: 100 +select avg(null::float8) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(NULL::float8) FROM generate_series(1, 3)" +== 055 +-- truncate_limit: 100 +select sum('NaN'::numeric) from generate_series(1,3) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum('NaN'::numeric) FROM generate_series(1, 3)" +== 056 +-- truncate_limit: 100 +select avg('NaN'::numeric) from generate_series(1,3) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg('NaN'::numeric) FROM generate_series(1, 3)" +== 057 +-- truncate_limit: 100 +-- verify correct results for infinite inputs +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('1'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) FROM (VALUES ('1'), ('infinity')) v(x)" +== 058 +-- truncate_limit: 100 +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('infinity'), ('1')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) FROM (VALUES ('infinity'), ('1')) v(x)" +== 059 +-- truncate_limit: 100 +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('infinity'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) FROM (VALUES (...)) v(x)" +== 060 +-- truncate_limit: 100 +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('-infinity'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) FROM (VALUES (...)) v(x)" +== 061 +-- truncate_limit: 100 +SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) +FROM (VALUES ('-infinity'), ('-infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::float8), avg(x::float8), var_pop(x::float8) FROM (VALUES (...)) v(x)" +== 062 +-- truncate_limit: 100 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('1'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) FROM (VALUES ('1'), ('infinity')) v(x)" +== 063 +-- truncate_limit: 100 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('infinity'), ('1')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) FROM (VALUES ('infinity'), ('1')) v(x)" +== 064 +-- truncate_limit: 100 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('infinity'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) FROM (VALUES (...)) v(x)" +== 065 +-- truncate_limit: 100 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('-infinity'), ('infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) FROM (VALUES (...)) v(x)" +== 066 +-- truncate_limit: 100 +SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) +FROM (VALUES ('-infinity'), ('-infinity')) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(x::numeric), avg(x::numeric), var_pop(x::numeric) FROM (VALUES (...)) v(x)" +== 067 +-- truncate_limit: 100 +-- test accuracy with a large input offset +SELECT avg(x::float8), var_pop(x::float8) +FROM (VALUES (100000003), (100000004), (100000006), (100000007)) v(x) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(x::float8), var_pop(x::float8) FROM (VALUES (...)) v(x)" +== 068 +-- truncate_limit: 100 +SELECT avg(x::float8), var_pop(x::float8) +FROM (VALUES (7000000000005), (7000000000007)) v(x) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(x::float8), var_pop(x::float8) FROM (VALUES (7000000000005), (7000000000007)) v(x)" +== 069 +-- truncate_limit: 100 +-- SQL2003 binary aggregates +SELECT regr_count(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_count" function="regr_count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regr_count(b, a) FROM aggtest" +== 070 +-- truncate_limit: 100 +SELECT regr_sxx(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regr_sxx(b, a) FROM aggtest" +== 071 +-- truncate_limit: 100 +SELECT regr_syy(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regr_syy(b, a) FROM aggtest" +== 072 +-- truncate_limit: 100 +SELECT regr_sxy(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regr_sxy(b, a) FROM aggtest" +== 073 +-- truncate_limit: 100 +SELECT regr_avgx(b, a), regr_avgy(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_avgx" function="regr_avgx" schema="" ctx=Call +FUNCTION: name="regr_avgy" function="regr_avgy" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regr_avgx(b, a), regr_avgy(b, a) FROM aggtest" +== 074 +-- truncate_limit: 100 +SELECT regr_r2(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_r2" function="regr_r2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regr_r2(b, a) FROM aggtest" +== 075 +-- truncate_limit: 100 +SELECT regr_slope(b, a), regr_intercept(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="regr_slope" function="regr_slope" schema="" ctx=Call +FUNCTION: name="regr_intercept" function="regr_intercept" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regr_slope(b, a), regr_intercept(b, a) FROM aggtest" +== 076 +-- truncate_limit: 100 +SELECT covar_pop(b, a), covar_samp(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="covar_pop" function="covar_pop" schema="" ctx=Call +FUNCTION: name="covar_samp" function="covar_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT covar_pop(b, a), covar_samp(b, a) FROM aggtest" +== 077 +-- truncate_limit: 100 +SELECT corr(b, a) FROM aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="corr" function="corr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT corr(b, a) FROM aggtest" +== 078 +-- truncate_limit: 100 +-- check single-tuple behavior +SELECT covar_pop(1::float8,2::float8), covar_samp(3::float8,4::float8) +-- +FUNCTION: name="covar_pop" function="covar_pop" schema="" ctx=Call +FUNCTION: name="covar_samp" function="covar_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT covar_pop(1::float8, 2::float8), covar_samp(3::float8, 4::float8)" +== 079 +-- truncate_limit: 100 +SELECT covar_pop(1::float8,'inf'::float8), covar_samp(3::float8,'inf'::float8) +-- +FUNCTION: name="covar_pop" function="covar_pop" schema="" ctx=Call +FUNCTION: name="covar_samp" function="covar_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT covar_pop(1::float8, 'inf'::float8), covar_samp(3::float8, 'inf'::float8)" +== 080 +-- truncate_limit: 100 +SELECT covar_pop(1::float8,'nan'::float8), covar_samp(3::float8,'nan'::float8) +-- +FUNCTION: name="covar_pop" function="covar_pop" schema="" ctx=Call +FUNCTION: name="covar_samp" function="covar_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT covar_pop(1::float8, 'nan'::float8), covar_samp(3::float8, 'nan'::float8)" +== 081 +-- truncate_limit: 100 +-- test accum and combine functions directly +CREATE TABLE regr_test (x float8, y float8) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE regr_test (x float8, y float8)" +== 082 +-- truncate_limit: 100 +INSERT INTO regr_test VALUES (10,150),(20,250),(30,350),(80,540),(100,200) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO regr_test VALUES (10, 150), (20, 250), (30, 350), (80, 540), (100, 200)" +== 083 +-- truncate_limit: 100 +SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x) +FROM regr_test WHERE x IN (10,20,30,80) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM regr_test WHERE x IN (10, 20, 30, 80)" +== 084 +-- truncate_limit: 100 +SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x) +FROM regr_test +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*), sum(x), regr_sxx(y, x), sum(y), regr_syy(y, x), regr_sxy(y, x) FROM regr_test" +== 085 +-- truncate_limit: 100 +SELECT float8_accum('{4,140,2900}'::float8[], 100) +-- +FUNCTION: name="float8_accum" function="float8_accum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float8_accum('{4,140,2900}'::float8[], 100)" +== 086 +-- truncate_limit: 100 +SELECT float8_regr_accum('{4,140,2900,1290,83075,15050}'::float8[], 200, 100) +-- +FUNCTION: name="float8_regr_accum" function="float8_regr_accum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float8_regr_accum('{4,140,2900,1290,83075,15050}'::float8[], 200, 100)" +== 087 +-- truncate_limit: 100 +SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x) +FROM regr_test WHERE x IN (10,20,30) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM regr_test WHERE x IN (10, 20, 30)" +== 088 +-- truncate_limit: 100 +SELECT count(*), sum(x), regr_sxx(y,x), sum(y),regr_syy(y,x), regr_sxy(y,x) +FROM regr_test WHERE x IN (80,100) +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_sxx" function="regr_sxx" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_syy" function="regr_syy" schema="" ctx=Call +FUNCTION: name="regr_sxy" function="regr_sxy" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM regr_test WHERE x IN (80, 100)" +== 089 +-- truncate_limit: 100 +SELECT float8_combine('{3,60,200}'::float8[], '{0,0,0}'::float8[]) +-- +FUNCTION: name="float8_combine" function="float8_combine" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float8_combine('{3,60,200}'::float8[], '{0,0,0}'::float8[])" +== 090 +-- truncate_limit: 100 +SELECT float8_combine('{0,0,0}'::float8[], '{2,180,200}'::float8[]) +-- +FUNCTION: name="float8_combine" function="float8_combine" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float8_combine('{0,0,0}'::float8[], '{2,180,200}'::float8[])" +== 091 +-- truncate_limit: 100 +SELECT float8_combine('{3,60,200}'::float8[], '{2,180,200}'::float8[]) +-- +FUNCTION: name="float8_combine" function="float8_combine" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float8_combine('{3,60,200}'::float8[], '{2,180,200}'::float8[])" +== 092 +-- truncate_limit: 100 +SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[], + '{0,0,0,0,0,0}'::float8[]) +-- +FUNCTION: name="float8_regr_combine" function="float8_regr_combine" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[], '{0,0,0,0,0,0}'::float8[])" +== 093 +-- truncate_limit: 100 +SELECT float8_regr_combine('{0,0,0,0,0,0}'::float8[], + '{2,180,200,740,57800,-3400}'::float8[]) +-- +FUNCTION: name="float8_regr_combine" function="float8_regr_combine" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float8_regr_combine('{0,0,0,0,0,0}'::float8[], '{2,180,200,740,57800,-3400}'::float8[])" +== 094 +-- truncate_limit: 100 +SELECT float8_regr_combine('{3,60,200,750,20000,2000}'::float8[], + '{2,180,200,740,57800,-3400}'::float8[]) +-- +FUNCTION: name="float8_regr_combine" function="float8_regr_combine" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 095 +-- truncate_limit: 100 +DROP TABLE regr_test +-- +TABLE: name="regr_test" schema="" table="regr_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE regr_test" +== 096 +-- truncate_limit: 100 +-- test count, distinct +SELECT count(four) AS cnt_1000 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(four) AS cnt_1000 FROM onek" +== 097 +-- truncate_limit: 100 +SELECT count(DISTINCT four) AS cnt_4 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT four) AS cnt_4 FROM onek" +== 098 +-- truncate_limit: 100 +select ten, count(*), sum(four) from onek +group by ten order by ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ten, count(*), sum(four) FROM onek GROUP BY ten ORDER BY ten" +== 099 +-- truncate_limit: 100 +select ten, count(four), sum(DISTINCT four) from onek +group by ten order by ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ten, count(four), sum(DISTINCT four) FROM onek GROUP BY ten ORDER BY ten" +== 100 +-- truncate_limit: 100 +-- user-defined aggregates +SELECT newavg(four) AS avg_1 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="newavg" function="newavg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT newavg(four) AS avg_1 FROM onek" +== 101 +-- truncate_limit: 100 +SELECT newsum(four) AS sum_1500 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="newsum" function="newsum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT newsum(four) AS sum_1500 FROM onek" +== 102 +-- truncate_limit: 100 +SELECT newcnt(four) AS cnt_1000 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="newcnt" function="newcnt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT newcnt(four) AS cnt_1000 FROM onek" +== 103 +-- truncate_limit: 100 +SELECT newcnt(*) AS cnt_1000 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="newcnt" function="newcnt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT newcnt(*) AS cnt_1000 FROM onek" +== 104 +-- truncate_limit: 100 +SELECT oldcnt(*) AS cnt_1000 FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="oldcnt" function="oldcnt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT oldcnt(*) AS cnt_1000 FROM onek" +== 105 +-- truncate_limit: 100 +SELECT sum2(q1,q2) FROM int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="sum2" function="sum2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum2(q1, q2) FROM int8_tbl" +== 106 +-- truncate_limit: 100 +-- test for outer-level aggregates + +-- this should work +select ten, sum(distinct four) from onek a +group by ten +having exists (select 1 from onek b where sum(distinct a.four) = b.four) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="a" column="four" +FILTER: schema="" table="b" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek a GROUP BY ten HAVING EXISTS (SELECT 1 FROM onek b WHERE ...)" +== 107 +-- truncate_limit: 100 +-- this should fail because subquery has an agg of its own in WHERE +select ten, sum(distinct four) from onek a +group by ten +having exists (select 1 from onek b + where sum(distinct a.four + b.four) = b.four) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="a" column="four" +FILTER: schema="" table="b" column="four" +FILTER: schema="" table="b" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek a GROUP BY ten HAVING EXISTS (SELECT 1 FROM onek b WHERE ...)" +== 108 +-- truncate_limit: 100 +-- Test handling of sublinks within outer-level aggregates. +-- Per bug report from Daniel Grace. +select + (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1))) +from tenk1 o +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i"="tenk1" +ALIAS: "o"="tenk1" +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="i" column="unique1" +FILTER: schema="" table="o" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT max((SELECT i.unique2 FROM tenk1 i WHERE i.unique1 = o.unique1))) FROM tenk1 o" +== 109 +-- truncate_limit: 100 +-- Test handling of Params within aggregate arguments in hashed aggregation. +-- Per bug report from Jeevan Chalke. +explain (verbose, costs off) +select s1, s2, sm +from generate_series(1, 3) s1, + lateral (select s2, sum(s1 + s2) sm + from generate_series(1, 3) s2 group by s2) ss +order by 1, 2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT s1, s2, sm FROM generate_series(1, 3) s1, LATERAL (SELECT s2,..." +== 110 +-- truncate_limit: 100 +select s1, s2, sm +from generate_series(1, 3) s1, + lateral (select s2, sum(s1 + s2) sm + from generate_series(1, 3) s2 group by s2) ss +order by 1, 2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 3) s1, LATERAL (SELECT ... FROM generate_series(1, 3) s2 GROUP..." +== 111 +-- truncate_limit: 100 +explain (verbose, costs off) +select array(select sum(x+y) s + from generate_series(1,3) y group by y order by s) + from generate_series(1,3) x +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT ARRAY(SELECT sum(x + y) AS s FROM generate_series(1, 3) y GRO..." +== 112 +-- truncate_limit: 100 +select array(select sum(x+y) s + from generate_series(1,3) y group by y order by s) + from generate_series(1,3) x +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 3) x" +== 113 +-- truncate_limit: 100 +|-- +-- test for bitwise integer aggregates +|-- +CREATE TEMPORARY TABLE bitwise_test( + i2 INT2, + i4 INT4, + i8 INT8, + i INTEGER, + x INT2, + y BIT(4) +) +-- +TABLE: name="bitwise_test" schema="" table="bitwise_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE bitwise_test (i2 int2, i4 int4, i8 int8, i int, x int2, y pg_catalog.bit(4))" +== 114 +-- truncate_limit: 100 +-- empty case +SELECT + BIT_AND(i2) AS "?", + BIT_OR(i4) AS "?", + BIT_XOR(i8) AS "?" +FROM bitwise_test +-- +TABLE: name="bitwise_test" schema="" table="bitwise_test" ctx=Select +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bit_and(i2) AS \"?\", bit_or(i4) AS \"?\", bit_xor(i8) AS \"?\" FROM bitwise_test" +== 115 +-- truncate_limit: 100 +COPY bitwise_test FROM STDIN NULL 'null' +-- +TABLE: name="bitwise_test" schema="" table="bitwise_test" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY bitwise_test FROM STDIN WITH (NULL 'null')" +== 116 +-- truncate_limit: 100 +SELECT + BIT_AND(i2) AS "1", + BIT_AND(i4) AS "1", + BIT_AND(i8) AS "1", + BIT_AND(i) AS "?", + BIT_AND(x) AS "0", + BIT_AND(y) AS "0100", + + BIT_OR(i2) AS "7", + BIT_OR(i4) AS "7", + BIT_OR(i8) AS "7", + BIT_OR(i) AS "?", + BIT_OR(x) AS "7", + BIT_OR(y) AS "1101", + + BIT_XOR(i2) AS "5", + BIT_XOR(i4) AS "5", + BIT_XOR(i8) AS "5", + BIT_XOR(i) AS "?", + BIT_XOR(x) AS "7", + BIT_XOR(y) AS "1101" +FROM bitwise_test +-- +TABLE: name="bitwise_test" schema="" table="bitwise_test" ctx=Select +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_and" function="bit_and" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_or" function="bit_or" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +FUNCTION: name="bit_xor" function="bit_xor" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM bitwise_test" +== 117 +-- truncate_limit: 100 +|-- +-- test boolean aggregates +|-- +-- first test all possible transition and final states + +SELECT + -- boolean and transitions + -- null because strict + booland_statefunc(NULL, NULL) IS NULL AS "t", + booland_statefunc(TRUE, NULL) IS NULL AS "t", + booland_statefunc(FALSE, NULL) IS NULL AS "t", + booland_statefunc(NULL, TRUE) IS NULL AS "t", + booland_statefunc(NULL, FALSE) IS NULL AS "t", + -- and actual computations + booland_statefunc(TRUE, TRUE) AS "t", + NOT booland_statefunc(TRUE, FALSE) AS "t", + NOT booland_statefunc(FALSE, TRUE) AS "t", + NOT booland_statefunc(FALSE, FALSE) AS "t" +-- +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +FUNCTION: name="booland_statefunc" function="booland_statefunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 118 +-- truncate_limit: 100 +SELECT + -- boolean or transitions + -- null because strict + boolor_statefunc(NULL, NULL) IS NULL AS "t", + boolor_statefunc(TRUE, NULL) IS NULL AS "t", + boolor_statefunc(FALSE, NULL) IS NULL AS "t", + boolor_statefunc(NULL, TRUE) IS NULL AS "t", + boolor_statefunc(NULL, FALSE) IS NULL AS "t", + -- actual computations + boolor_statefunc(TRUE, TRUE) AS "t", + boolor_statefunc(TRUE, FALSE) AS "t", + boolor_statefunc(FALSE, TRUE) AS "t", + NOT boolor_statefunc(FALSE, FALSE) AS "t" +-- +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +FUNCTION: name="boolor_statefunc" function="boolor_statefunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 119 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE bool_test( + b1 BOOL, + b2 BOOL, + b3 BOOL, + b4 BOOL) +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE bool_test (b1 bool, b2 bool, b3 bool, b4 bool)" +== 120 +-- truncate_limit: 100 +-- empty case +SELECT + BOOL_AND(b1) AS "n", + BOOL_OR(b3) AS "n" +FROM bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bool_and(b1) AS n, bool_or(b3) AS n FROM bool_test" +== 121 +-- truncate_limit: 100 +COPY bool_test FROM STDIN NULL 'null' +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY bool_test FROM STDIN WITH (NULL 'null')" +== 122 +-- truncate_limit: 100 +SELECT + BOOL_AND(b1) AS "f", + BOOL_AND(b2) AS "t", + BOOL_AND(b3) AS "f", + BOOL_AND(b4) AS "n", + BOOL_AND(NOT b2) AS "f", + BOOL_AND(NOT b3) AS "t" +FROM bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM bool_test" +== 123 +-- truncate_limit: 100 +SELECT + EVERY(b1) AS "f", + EVERY(b2) AS "t", + EVERY(b3) AS "f", + EVERY(b4) AS "n", + EVERY(NOT b2) AS "f", + EVERY(NOT b3) AS "t" +FROM bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +FUNCTION: name="every" function="every" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM bool_test" +== 124 +-- truncate_limit: 100 +SELECT + BOOL_OR(b1) AS "t", + BOOL_OR(b2) AS "t", + BOOL_OR(b3) AS "f", + BOOL_OR(b4) AS "n", + BOOL_OR(NOT b2) AS "f", + BOOL_OR(NOT b3) AS "t" +FROM bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM bool_test" +== 125 +-- truncate_limit: 100 +|-- +-- Test cases that should be optimized into indexscans instead of +-- the generic aggregate implementation. +|-- + +-- Basic cases +explain (costs off) + select min(unique1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT min(unique1) FROM tenk1" +== 126 +-- truncate_limit: 100 +select min(unique1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(unique1) FROM tenk1" +== 127 +-- truncate_limit: 100 +explain (costs off) + select max(unique1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(unique1) FROM tenk1" +== 128 +-- truncate_limit: 100 +select max(unique1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(unique1) FROM tenk1" +== 129 +-- truncate_limit: 100 +explain (costs off) + select max(unique1) from tenk1 where unique1 < 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(unique1) FROM tenk1 WHERE unique1 < 42" +== 130 +-- truncate_limit: 100 +select max(unique1) from tenk1 where unique1 < 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT max(unique1) FROM tenk1 WHERE unique1 < 42" +== 131 +-- truncate_limit: 100 +explain (costs off) + select max(unique1) from tenk1 where unique1 > 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(unique1) FROM tenk1 WHERE unique1 > 42" +== 132 +-- truncate_limit: 100 +select max(unique1) from tenk1 where unique1 > 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT max(unique1) FROM tenk1 WHERE unique1 > 42" +== 133 +-- truncate_limit: 100 +-- the planner may choose a generic aggregate here if parallel query is +-- enabled, since that plan will be parallel safe and the "optimized" +-- plan, which has almost identical cost, will not be. we want to test +-- the optimized plan, so temporarily disable parallel query. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 134 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 0" +== 135 +-- truncate_limit: 100 +explain (costs off) + select max(unique1) from tenk1 where unique1 > 42000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(unique1) FROM tenk1 WHERE unique1 > 42000" +== 136 +-- truncate_limit: 100 +select max(unique1) from tenk1 where unique1 > 42000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT max(unique1) FROM tenk1 WHERE unique1 > 42000" +== 137 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 138 +-- truncate_limit: 100 +-- multi-column index (uses tenk1_thous_tenthous) +explain (costs off) + select max(tenthous) from tenk1 where thousand = 33 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(tenthous) FROM tenk1 WHERE thousand = 33" +== 139 +-- truncate_limit: 100 +select max(tenthous) from tenk1 where thousand = 33 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT max(tenthous) FROM tenk1 WHERE thousand = 33" +== 140 +-- truncate_limit: 100 +explain (costs off) + select min(tenthous) from tenk1 where thousand = 33 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT min(tenthous) FROM tenk1 WHERE thousand = 33" +== 141 +-- truncate_limit: 100 +select min(tenthous) from tenk1 where thousand = 33 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT min(tenthous) FROM tenk1 WHERE thousand = 33" +== 142 +-- truncate_limit: 100 +-- check parameter propagation into an indexscan subquery +explain (costs off) + select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt + from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT f1, (SELECT min(unique1) FROM tenk1 WHERE unique1 > f1) AS gt FROM int..." +== 143 +-- truncate_limit: 100 +select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt + from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, (SELECT min(unique1) FROM tenk1 WHERE unique1 > f1) AS gt FROM int4_tbl" +== 144 +-- truncate_limit: 100 +-- check some cases that were handled incorrectly in 8.3.0 +explain (costs off) + select distinct max(unique2) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT max(unique2) FROM tenk1" +== 145 +-- truncate_limit: 100 +select distinct max(unique2) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT max(unique2) FROM tenk1" +== 146 +-- truncate_limit: 100 +explain (costs off) + select max(unique2) from tenk1 order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(unique2) FROM tenk1 ORDER BY 1" +== 147 +-- truncate_limit: 100 +select max(unique2) from tenk1 order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(unique2) FROM tenk1 ORDER BY 1" +== 148 +-- truncate_limit: 100 +explain (costs off) + select max(unique2) from tenk1 order by max(unique2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(unique2) FROM tenk1 ORDER BY max(unique2)" +== 149 +-- truncate_limit: 100 +select max(unique2) from tenk1 order by max(unique2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(unique2) FROM tenk1 ORDER BY max(unique2)" +== 150 +-- truncate_limit: 100 +explain (costs off) + select max(unique2) from tenk1 order by max(unique2)+1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(unique2) FROM tenk1 ORDER BY max(unique2) + 1" +== 151 +-- truncate_limit: 100 +select max(unique2) from tenk1 order by max(unique2)+1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(unique2) FROM tenk1 ORDER BY max(unique2) + 1" +== 152 +-- truncate_limit: 100 +explain (costs off) + select max(unique2), generate_series(1,3) as g from tenk1 order by g desc +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(unique2), generate_series(1, 3) AS g FROM tenk1 ORDER BY g DESC" +== 153 +-- truncate_limit: 100 +select max(unique2), generate_series(1,3) as g from tenk1 order by g desc +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(unique2), generate_series(1, 3) AS g FROM tenk1 ORDER BY g DESC" +== 154 +-- truncate_limit: 100 +-- interesting corner case: constant gets optimized into a seqscan +explain (costs off) + select max(100) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(100) FROM tenk1" +== 155 +-- truncate_limit: 100 +select max(100) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(100) FROM tenk1" +== 156 +-- truncate_limit: 100 +-- try it on an inheritance tree +create table minmaxtest(f1 int) +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE minmaxtest (f1 int)" +== 157 +-- truncate_limit: 100 +create table minmaxtest1() inherits (minmaxtest) +-- +TABLE: name="minmaxtest1" schema="" table="minmaxtest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE minmaxtest1 () INHERITS (minmaxtest)" +== 158 +-- truncate_limit: 100 +create table minmaxtest2() inherits (minmaxtest) +-- +TABLE: name="minmaxtest2" schema="" table="minmaxtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE minmaxtest2 () INHERITS (minmaxtest)" +== 159 +-- truncate_limit: 100 +create table minmaxtest3() inherits (minmaxtest) +-- +TABLE: name="minmaxtest3" schema="" table="minmaxtest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE minmaxtest3 () INHERITS (minmaxtest)" +== 160 +-- truncate_limit: 100 +create index minmaxtesti on minmaxtest(f1) +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX minmaxtesti ON minmaxtest USING btree (f1)" +== 161 +-- truncate_limit: 100 +create index minmaxtest1i on minmaxtest1(f1) +-- +TABLE: name="minmaxtest1" schema="" table="minmaxtest1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX minmaxtest1i ON minmaxtest1 USING btree (f1)" +== 162 +-- truncate_limit: 100 +create index minmaxtest2i on minmaxtest2(f1 desc) +-- +TABLE: name="minmaxtest2" schema="" table="minmaxtest2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX minmaxtest2i ON minmaxtest2 USING btree (f1 DESC)" +== 163 +-- truncate_limit: 100 +create index minmaxtest3i on minmaxtest3(f1) where f1 is not null +-- +TABLE: name="minmaxtest3" schema="" table="minmaxtest3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX minmaxtest3i ON minmaxtest3 USING btree (f1) WHERE f1 IS NOT NULL" +== 164 +-- truncate_limit: 100 +insert into minmaxtest values(11), (12) +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO minmaxtest VALUES (11), (12)" +== 165 +-- truncate_limit: 100 +insert into minmaxtest1 values(13), (14) +-- +TABLE: name="minmaxtest1" schema="" table="minmaxtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO minmaxtest1 VALUES (13), (14)" +== 166 +-- truncate_limit: 100 +insert into minmaxtest2 values(15), (16) +-- +TABLE: name="minmaxtest2" schema="" table="minmaxtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO minmaxtest2 VALUES (15), (16)" +== 167 +-- truncate_limit: 100 +insert into minmaxtest3 values(17), (18) +-- +TABLE: name="minmaxtest3" schema="" table="minmaxtest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO minmaxtest3 VALUES (17), (18)" +== 168 +-- truncate_limit: 100 +explain (costs off) + select min(f1), max(f1) from minmaxtest +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT min(f1), max(f1) FROM minmaxtest" +== 169 +-- truncate_limit: 100 +select min(f1), max(f1) from minmaxtest +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(f1), max(f1) FROM minmaxtest" +== 170 +-- truncate_limit: 100 +-- DISTINCT doesn't do anything useful here, but it shouldn't fail +explain (costs off) + select distinct min(f1), max(f1) from minmaxtest +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT min(f1), max(f1) FROM minmaxtest" +== 171 +-- truncate_limit: 100 +select distinct min(f1), max(f1) from minmaxtest +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT min(f1), max(f1) FROM minmaxtest" +== 172 +-- truncate_limit: 100 +drop table minmaxtest cascade +-- +TABLE: name="minmaxtest" schema="" table="minmaxtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE minmaxtest CASCADE" +== 173 +-- truncate_limit: 100 +-- DISTINCT can also trigger wrong answers with hash aggregation (bug #18465) +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 174 +-- truncate_limit: 100 +set local enable_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_sort TO OFF" +== 175 +-- truncate_limit: 100 +explain (costs off) + select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1) + from int4_tbl t0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t0"="int4_tbl" +ALIAS: "t1"="int4_tbl" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="t0" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT f1, (SELECT DISTINCT min(t1.f1) FROM int4_tbl t1 WHERE t1.f1 = t0.f1) ..." +== 176 +-- truncate_limit: 100 +select f1, (select distinct min(t1.f1) from int4_tbl t1 where t1.f1 = t0.f1) +from int4_tbl t0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t0"="int4_tbl" +ALIAS: "t1"="int4_tbl" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="t0" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, (SELECT DISTINCT min(t1.f1) FROM int4_tbl t1 WHERE t1.f1 = t0.f1) FROM int4_tbl t0" +== 177 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 178 +-- truncate_limit: 100 +-- check for correct detection of nested-aggregate errors +select max(min(unique1)) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(min(unique1)) FROM tenk1" +== 179 +-- truncate_limit: 100 +select (select max(min(unique1)) from int8_tbl) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT max(min(unique1)) FROM int8_tbl) FROM tenk1" +== 180 +-- truncate_limit: 100 +select avg((select avg(a1.col1 order by (select avg(a2.col2) from tenk1 a3)) + from tenk1 a1(col1))) +from tenk1 a2(col2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a1"="tenk1" +ALIAS: "a2"="tenk1" +ALIAS: "a3"="tenk1" +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg((SELECT ... FROM tenk1 a1(col1))) FROM tenk1 a2(col2)" +== 181 +-- truncate_limit: 100 +|-- +-- Test removal of redundant GROUP BY columns +|-- + +create temp table t1 (a int, b int, c int, d int, primary key (a, b)) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (a int, b int, c int, d int, PRIMARY KEY (a, b))" +== 182 +-- truncate_limit: 100 +create temp table t2 (x int, y int, z int, primary key (x, y)) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t2 (x int, y int, z int, PRIMARY KEY (x, y))" +== 183 +-- truncate_limit: 100 +create temp table t3 (a int, b int, c int, primary key(a, b) deferrable) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t3 (a int, b int, c int, PRIMARY KEY (a, b) DEFERRABLE)" +== 184 +-- truncate_limit: 100 +-- Non-primary-key columns can be removed from GROUP BY +explain (costs off) select * from t1 group by a,b,c,d +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 GROUP BY a, b, c, d" +== 185 +-- truncate_limit: 100 +-- No removal can happen if the complete PK is not present in GROUP BY +explain (costs off) select a,c from t1 group by a,c,d +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, c FROM t1 GROUP BY a, c, d" +== 186 +-- truncate_limit: 100 +-- Test removal across multiple relations +explain (costs off) select * +from t1 inner join t2 on t1.a = t2.x and t1.b = t2.y +group by t1.a,t1.b,t1.c,t1.d,t2.x,t2.y,t2.z +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 JOIN t2 ON t1.a = t2.x AND t1.b = t2.y GROUP BY t1.a, t1.b, ..." +== 187 +-- truncate_limit: 100 +-- Test case where t1 can be optimized but not t2 +explain (costs off) select t1.*,t2.x,t2.z +from t1 inner join t2 on t1.a = t2.x and t1.b = t2.y +group by t1.a,t1.b,t1.c,t1.d,t2.x,t2.z +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.*, t2.x, t2.z FROM t1 JOIN t2 ON t1.a = t2.x AND t1.b = t2.y GROUP ..." +== 188 +-- truncate_limit: 100 +-- Cannot optimize when PK is deferrable +explain (costs off) select * from t3 group by a,b,c +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t3 GROUP BY a, b, c" +== 189 +-- truncate_limit: 100 +create temp table t1c () inherits (t1) +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1c () INHERITS (t1)" +== 190 +-- truncate_limit: 100 +-- Ensure we don't remove any columns when t1 has a child table +explain (costs off) select * from t1 group by a,b,c,d +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 GROUP BY a, b, c, d" +== 191 +-- truncate_limit: 100 +-- Okay to remove columns if we're only querying the parent. +explain (costs off) select * from only t1 group by a,b,c,d +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ONLY t1 GROUP BY a, b, c, d" +== 192 +-- truncate_limit: 100 +create temp table p_t1 ( + a int, + b int, + c int, + d int, + primary key(a,b) +) partition by list(a) +-- +TABLE: name="p_t1" schema="" table="p_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE p_t1 (a int, b int, c int, d int, PRIMARY KEY (a, b)) PARTITION BY LIST (a)" +== 193 +-- truncate_limit: 100 +create temp table p_t1_1 partition of p_t1 for values in(1) +-- +TABLE: name="p_t1_1" schema="" table="p_t1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE p_t1_1 PARTITION OF p_t1 FOR VALUES IN (1)" +== 194 +-- truncate_limit: 100 +create temp table p_t1_2 partition of p_t1 for values in(2) +-- +TABLE: name="p_t1_2" schema="" table="p_t1_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE p_t1_2 PARTITION OF p_t1 FOR VALUES IN (2)" +== 195 +-- truncate_limit: 100 +-- Ensure we can remove non-PK columns for partitioned tables. +explain (costs off) select * from p_t1 group by a,b,c,d +-- +TABLE: name="p_t1" schema="" table="p_t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM p_t1 GROUP BY a, b, c, d" +== 196 +-- truncate_limit: 100 +drop table t1 cascade +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1 CASCADE" +== 197 +-- truncate_limit: 100 +drop table t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t2" +== 198 +-- truncate_limit: 100 +drop table t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t3" +== 199 +-- truncate_limit: 100 +drop table p_t1 +-- +TABLE: name="p_t1" schema="" table="p_t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p_t1" +== 200 +-- truncate_limit: 100 +|-- +-- Test GROUP BY matching of join columns that are type-coerced due to USING +|-- + +create temp table t1(f1 int, f2 int) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (f1 int, f2 int)" +== 201 +-- truncate_limit: 100 +create temp table t2(f1 bigint, f2 oid) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t2 (f1 bigint, f2 oid)" +== 202 +-- truncate_limit: 100 +select f1 from t1 left join t2 using (f1) group by f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM t1 LEFT JOIN t2 USING (f1) GROUP BY f1" +== 203 +-- truncate_limit: 100 +select f1 from t1 left join t2 using (f1) group by t1.f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM t1 LEFT JOIN t2 USING (f1) GROUP BY t1.f1" +== 204 +-- truncate_limit: 100 +select t1.f1 from t1 left join t2 using (f1) group by t1.f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT t1.f1 FROM t1 LEFT JOIN t2 USING (f1) GROUP BY t1.f1" +== 205 +-- truncate_limit: 100 +-- only this one should fail: +select t1.f1 from t1 left join t2 using (f1) group by f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT t1.f1 FROM t1 LEFT JOIN t2 USING (f1) GROUP BY f1" +== 206 +-- truncate_limit: 100 +-- check case where we have to inject nullingrels into coerced join alias +select f1, count(*) from +t1 x(x0,x1) left join (t1 left join t2 using(f1)) on (x0 = 0) +group by f1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +ALIAS: "x"="t1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, count(*) FROM t1 x(x0, x1) LEFT JOIN (t1 LEFT JOIN t2 USING (f1)) ON x0 = 0 GROUP BY f1" +== 207 +-- truncate_limit: 100 +-- same, for a RelabelType coercion +select f2, count(*) from +t1 x(x0,x1) left join (t1 left join t2 using(f2)) on (x0 = 0) +group by f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +ALIAS: "x"="t1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f2, count(*) FROM t1 x(x0, x1) LEFT JOIN (t1 LEFT JOIN t2 USING (f2)) ON x0 = 0 GROUP BY f2" +== 208 +-- truncate_limit: 100 +drop table t1, t2 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1, t2" +== 209 +-- truncate_limit: 100 +|-- +-- Test planner's selection of pathkeys for ORDER BY aggregates +|-- + +-- Ensure we order by four. This suits the most aggregate functions. +explain (costs off) +select sum(two order by two),max(four order by four), min(four order by four) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(two ORDER BY two), max(four ORDER BY four), min(four ORDER BY four..." +== 210 +-- truncate_limit: 100 +-- Ensure we order by two. It's a tie between ordering by two and four but +-- we tiebreak on the aggregate's position. +explain (costs off) +select + sum(two order by two), max(four order by four), + min(four order by four), max(two order by two) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(two ORDER BY two), max(four ORDER BY four), min(four ORDER BY four..." +== 211 +-- truncate_limit: 100 +-- Similar to above, but tiebreak on ordering by four +explain (costs off) +select + max(four order by four), sum(two order by two), + min(four order by four), max(two order by two) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(four ORDER BY four), sum(two ORDER BY two), min(four ORDER BY four..." +== 212 +-- truncate_limit: 100 +-- Ensure this one orders by ten since there are 3 aggregates that require ten +-- vs two that suit two and four. +explain (costs off) +select + max(four order by four), sum(two order by two), + min(four order by four), max(two order by two), + sum(ten order by ten), min(ten order by ten), max(ten order by ten) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT max(four ORDER BY four), sum(two ORDER BY two), min(four ORDER BY four..." +== 213 +-- truncate_limit: 100 +-- Try a case involving a GROUP BY clause where the GROUP BY column is also +-- part of an aggregate's ORDER BY clause. We want a sort order that works +-- for the GROUP BY along with the first and the last aggregate. +explain (costs off) +select + sum(unique1 order by ten, two), sum(unique1 order by four), + sum(unique1 order by two, four) +from tenk1 +group by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(unique1 ORDER BY ten, two), sum(unique1 ORDER BY four), sum(unique..." +== 214 +-- truncate_limit: 100 +-- Ensure that we never choose to provide presorted input to an Aggref with +-- a volatile function in the ORDER BY / DISTINCT clause. We want to ensure +-- these sorts are performed individually rather than at the query level. +explain (costs off) +select + sum(unique1 order by two), sum(unique1 order by four), + sum(unique1 order by four, two), sum(unique1 order by two, random()), + sum(unique1 order by two, random(), random() + 1) +from tenk1 +group by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(unique1 ORDER BY two), sum(unique1 ORDER BY four), sum(unique1 ORD..." +== 215 +-- truncate_limit: 100 +-- Ensure consecutive NULLs are properly treated as distinct from each other +select array_agg(distinct val) +from (select null as val from generate_series(1, 2)) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(DISTINCT val) FROM (SELECT NULL AS val FROM generate_series(1, 2))" +== 216 +-- truncate_limit: 100 +-- Ensure no ordering is requested when enable_presorted_aggregate is off +set enable_presorted_aggregate to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_presorted_aggregate TO OFF" +== 217 +-- truncate_limit: 100 +explain (costs off) +select sum(two order by two) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(two ORDER BY two) FROM tenk1" +== 218 +-- truncate_limit: 100 +reset enable_presorted_aggregate +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_presorted_aggregate" +== 219 +-- truncate_limit: 100 +|-- +-- Test cases with FILTER clause +|-- + +-- Ensure we presort when the aggregate contains plain Vars +explain (costs off) +select sum(two order by two) filter (where two > 1) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(two ORDER BY two) FILTER (WHERE two > 1) FROM tenk1" +== 220 +-- truncate_limit: 100 +-- Ensure we presort for RelabelType'd Vars +explain (costs off) +select string_agg(distinct f1, ',') filter (where length(f1) > 1) +from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT string_agg(DISTINCT f1, ',') FILTER (WHERE length(f1) > 1) FROM varcha..." +== 221 +-- truncate_limit: 100 +-- Ensure we don't presort when the aggregate's argument contains an +-- explicit cast. +explain (costs off) +select string_agg(distinct f1::varchar(2), ',') filter (where length(f1) > 1) +from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT string_agg(DISTINCT f1::varchar(2), ',') FILTER (WHERE length(f1) > 1)..." +== 222 +-- truncate_limit: 100 +|-- +-- Test combinations of DISTINCT and/or ORDER BY +|-- + +select array_agg(a order by b) + from (values (1,4),(2,3),(3,1),(4,2)) v(a,b) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(a ORDER BY b) FROM (VALUES (1, 4), (2, 3), (3, 1), (4, 2)) v(a, b)" +== 223 +-- truncate_limit: 100 +select array_agg(a order by a) + from (values (1,4),(2,3),(3,1),(4,2)) v(a,b) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(a ORDER BY a) FROM (VALUES (1, 4), (2, 3), (3, 1), (4, 2)) v(a, b)" +== 224 +-- truncate_limit: 100 +select array_agg(a order by a desc) + from (values (1,4),(2,3),(3,1),(4,2)) v(a,b) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(a ORDER BY a DESC) FROM (VALUES (1, 4), (2, 3), (3, 1), (4, 2)) v(a, b)" +== 225 +-- truncate_limit: 100 +select array_agg(b order by a desc) + from (values (1,4),(2,3),(3,1),(4,2)) v(a,b) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY a DESC) FROM (VALUES (1, 4), (2, 3), (3, 1), (4, 2)) v(a, b)" +== 226 +-- truncate_limit: 100 +select array_agg(distinct a) + from (values (1),(2),(1),(3),(null),(2)) v(a) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(DISTINCT a) FROM (VALUES (1), (2), (1), (3), (NULL), (2)) v(a)" +== 227 +-- truncate_limit: 100 +select array_agg(distinct a order by a) + from (values (1),(2),(1),(3),(null),(2)) v(a) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(DISTINCT a ORDER BY a) FROM (VALUES (1), (2), (1), (3), (NULL), (2)) v(a)" +== 228 +-- truncate_limit: 100 +select array_agg(distinct a order by a desc) + from (values (1),(2),(1),(3),(null),(2)) v(a) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(DISTINCT a ORDER BY a DESC) FROM (VALUES (1), (2), (1), (3), (NULL), (2)) v(a)" +== 229 +-- truncate_limit: 100 +select array_agg(distinct a order by a desc nulls last) + from (values (1),(2),(1),(3),(null),(2)) v(a) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(DISTINCT a ORDER BY a DESC NULLS LAST) FROM (VALUES (...)) v(a)" +== 230 +-- truncate_limit: 100 +-- multi-arg aggs, strict/nonstrict, distinct/order by + +select aggfstr(a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +FUNCTION: name="aggfstr" function="aggfstr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT aggfstr(a, b, c) FROM (VALUES (...)) v(a, b, c)" +== 231 +-- truncate_limit: 100 +select aggfns(a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT aggfns(a, b, c) FROM (VALUES (...)) v(a, b, c)" +== 232 +-- truncate_limit: 100 +select aggfstr(distinct a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +FUNCTION: name="aggfstr" function="aggfstr" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT aggfstr(DISTINCT a, b, c) FROM (VALUES (...)) v(a, b, c), generate_series(1, 3) i" +== 233 +-- truncate_limit: 100 +select aggfns(distinct a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT aggfns(DISTINCT a, b, c) FROM (VALUES (...)) v(a, b, c), generate_series(1, 3) i" +== 234 +-- truncate_limit: 100 +select aggfstr(distinct a,b,c order by b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +FUNCTION: name="aggfstr" function="aggfstr" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT aggfstr(DISTINCT a, b, c ORDER BY b) FROM (VALUES (...)) v(a, b, c), generate_series(1, 3) i" +== 235 +-- truncate_limit: 100 +select aggfns(distinct a,b,c order by b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT aggfns(DISTINCT a, b, c ORDER BY b) FROM (VALUES (...)) v(a, b, c), generate_series(1, 3) i" +== 236 +-- truncate_limit: 100 +-- test specific code paths + +select aggfns(distinct a,a,c order by c using ~<~,a) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 237 +-- truncate_limit: 100 +select aggfns(distinct a,a,c order by c using ~<~) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 238 +-- truncate_limit: 100 +select aggfns(distinct a,a,c order by a) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT aggfns(DISTINCT a, a, c ORDER BY a) FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 239 +-- truncate_limit: 100 +select aggfns(distinct a,b,c order by a,c using ~<~,b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 240 +-- truncate_limit: 100 +-- test a more complex permutation that has previous caused issues +select + string_agg(distinct 'a', ','), + sum(( + select sum(1) + from (values(1)) b(id) + where a.id = b.id +)) from unnest(array[1]) a(id) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="b" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY[1]) a(id)" +== 241 +-- truncate_limit: 100 +-- check node I/O via view creation and usage, also deparsing logic + +create view agg_view1 as + select aggfns(a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW agg_view1 AS SELECT aggfns(a, b, c) FROM (VALUES (1, 3, 'foo'), (0, NULL, NULL), (2, ..." +== 242 +-- truncate_limit: 100 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM agg_view1" +== 243 +-- truncate_limit: 100 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('agg_view1'::regclass)" +== 244 +-- truncate_limit: 100 +create or replace view agg_view1 as + select aggfns(distinct a,b,c) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW agg_view1 AS SELECT aggfns(DISTINCT a, b, c) FROM (VALUES (1, 3, 'foo'), (..." +== 245 +-- truncate_limit: 100 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM agg_view1" +== 246 +-- truncate_limit: 100 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('agg_view1'::regclass)" +== 247 +-- truncate_limit: 100 +create or replace view agg_view1 as + select aggfns(distinct a,b,c order by b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,3) i +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW agg_view1 AS SELECT aggfns(DISTINCT a, b, c ORDER BY b) FROM (VALUES (1, 3..." +== 248 +-- truncate_limit: 100 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM agg_view1" +== 249 +-- truncate_limit: 100 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('agg_view1'::regclass)" +== 250 +-- truncate_limit: 100 +create or replace view agg_view1 as + select aggfns(a,b,c order by b+1) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW agg_view1 AS SELECT aggfns(a, b, c ORDER BY b + 1) FROM (VALUES (1, 3, 'fo..." +== 251 +-- truncate_limit: 100 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM agg_view1" +== 252 +-- truncate_limit: 100 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('agg_view1'::regclass)" +== 253 +-- truncate_limit: 100 +create or replace view agg_view1 as + select aggfns(a,a,c order by b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW agg_view1 AS SELECT aggfns(a, a, c ORDER BY b) FROM (VALUES (1, 3, 'foo'),..." +== 254 +-- truncate_limit: 100 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM agg_view1" +== 255 +-- truncate_limit: 100 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('agg_view1'::regclass)" +== 256 +-- truncate_limit: 100 +create or replace view agg_view1 as + select aggfns(a,b,c order by c using ~<~) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c) +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW agg_view1 AS SELECT aggfns(a, b, c ORDER BY c USING ~<~) FROM (VALUES (1, ..." +== 257 +-- truncate_limit: 100 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM agg_view1" +== 258 +-- truncate_limit: 100 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('agg_view1'::regclass)" +== 259 +-- truncate_limit: 100 +create or replace view agg_view1 as + select aggfns(distinct a,b,c order by a,c using ~<~,b) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=DDL +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW agg_view1 AS SELECT aggfns(DISTINCT a, b, c ORDER BY a, c USING ~<~, b) FR..." +== 260 +-- truncate_limit: 100 +select * from agg_view1 +-- +TABLE: name="agg_view1" schema="" table="agg_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM agg_view1" +== 261 +-- truncate_limit: 100 +select pg_get_viewdef('agg_view1'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('agg_view1'::regclass)" +== 262 +-- truncate_limit: 100 +drop view agg_view1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW agg_view1" +== 263 +-- truncate_limit: 100 +-- incorrect DISTINCT usage errors + +select aggfns(distinct a,b,c order by i) + from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT aggfns(DISTINCT a, b, c ORDER BY i) FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 264 +-- truncate_limit: 100 +select aggfns(distinct a,b,c order by a,b+1) + from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 265 +-- truncate_limit: 100 +select aggfns(distinct a,b,c order by a,b,i,c) + from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 266 +-- truncate_limit: 100 +select aggfns(distinct a,a,c order by a,b) + from (values (1,1,'foo')) v(a,b,c), generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 267 +-- truncate_limit: 100 +-- string_agg tests +select string_agg(a,',') from (values('aaaa'),('bbbb'),('cccc')) g(a) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(a, ',') FROM (VALUES ('aaaa'), ('bbbb'), ('cccc')) g(a)" +== 268 +-- truncate_limit: 100 +select string_agg(a,',') from (values('aaaa'),(null),('bbbb'),('cccc')) g(a) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(a, ',') FROM (VALUES ('aaaa'), (NULL), ('bbbb'), ('cccc')) g(a)" +== 269 +-- truncate_limit: 100 +select string_agg(a,'AB') from (values(null),(null),('bbbb'),('cccc')) g(a) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(a, 'AB') FROM (VALUES (NULL), (NULL), ('bbbb'), ('cccc')) g(a)" +== 270 +-- truncate_limit: 100 +select string_agg(a,',') from (values(null),(null)) g(a) +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(a, ',') FROM (VALUES (NULL), (NULL)) g(a)" +== 271 +-- truncate_limit: 100 +-- check some implicit casting cases, as per bug #5564 +select string_agg(distinct f1, ',' order by f1) from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(DISTINCT f1, ',' ORDER BY f1) FROM varchar_tbl" +== 272 +-- truncate_limit: 100 +-- ok +select string_agg(distinct f1::text, ',' order by f1) from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(DISTINCT f1::text, ',' ORDER BY f1) FROM varchar_tbl" +== 273 +-- truncate_limit: 100 +-- not ok +select string_agg(distinct f1, ',' order by f1::text) from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(DISTINCT f1, ',' ORDER BY f1::text) FROM varchar_tbl" +== 274 +-- truncate_limit: 100 +-- not ok +select string_agg(distinct f1::text, ',' order by f1::text) from varchar_tbl +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(DISTINCT f1::text, ',' ORDER BY f1::text) FROM varchar_tbl" +== 275 +-- truncate_limit: 100 +-- ok + +-- string_agg bytea tests +create table bytea_test_table(v bytea) +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bytea_test_table (v bytea)" +== 276 +-- truncate_limit: 100 +select string_agg(v, '') from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(v, '') FROM bytea_test_table" +== 277 +-- truncate_limit: 100 +insert into bytea_test_table values(decode('ff','hex')) +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=DML +FUNCTION: name="decode" function="decode" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bytea_test_table VALUES (decode('ff', 'hex'))" +== 278 +-- truncate_limit: 100 +select string_agg(v, '') from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(v, '') FROM bytea_test_table" +== 279 +-- truncate_limit: 100 +insert into bytea_test_table values(decode('aa','hex')) +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=DML +FUNCTION: name="decode" function="decode" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bytea_test_table VALUES (decode('aa', 'hex'))" +== 280 +-- truncate_limit: 100 +select string_agg(v, '') from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(v, '') FROM bytea_test_table" +== 281 +-- truncate_limit: 100 +select string_agg(v, NULL) from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(v, NULL) FROM bytea_test_table" +== 282 +-- truncate_limit: 100 +select string_agg(v, decode('ee', 'hex')) from bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="decode" function="decode" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(v, decode('ee', 'hex')) FROM bytea_test_table" +== 283 +-- truncate_limit: 100 +drop table bytea_test_table +-- +TABLE: name="bytea_test_table" schema="" table="bytea_test_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bytea_test_table" +== 284 +-- truncate_limit: 100 +-- Test parallel string_agg and array_agg +create table pagg_test (x int, y int) with (autovacuum_enabled = off) +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_test (x int, y int) WITH (autovacuum_enabled=off)" +== 285 +-- truncate_limit: 100 +insert into pagg_test +select (case x % 4 when 1 then null else x end), x % 10 +from generate_series(1,5000) x +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pagg_test SELECT ... FROM generate_series(1, 5000) x" +== 286 +-- truncate_limit: 100 +set parallel_setup_cost TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 287 +-- truncate_limit: 100 +set parallel_tuple_cost TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 288 +-- truncate_limit: 100 +set parallel_leader_participation TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO 0" +== 289 +-- truncate_limit: 100 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 290 +-- truncate_limit: 100 +set bytea_output = 'escape' +-- +STMT: VariableSetStmt +TRUNCATED: "SET bytea_output TO escape" +== 291 +-- truncate_limit: 100 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 292 +-- truncate_limit: 100 +-- create a view as we otherwise have to repeat this query a few times. +create view v_pagg_test AS +select + y, + min(t) AS tmin,max(t) AS tmax,count(distinct t) AS tndistinct, + min(b) AS bmin,max(b) AS bmax,count(distinct b) AS bndistinct, + min(a) AS amin,max(a) AS amax,count(distinct a) AS andistinct, + min(aa) AS aamin,max(aa) AS aamax,count(distinct aa) AS aandistinct +from ( + select + y, + unnest(regexp_split_to_array(a1.t, ','))::int AS t, + unnest(regexp_split_to_array(a1.b::text, ',')) AS b, + unnest(a1.a) AS a, + unnest(a1.aa) AS aa + from ( + select + y, + string_agg(x::text, ',') AS t, + string_agg(x::text::bytea, ',') AS b, + array_agg(x) AS a, + array_agg(ARRAY[x]) AS aa + from pagg_test + group by y + ) a1 +) a2 +group by y +-- +TABLE: name="v_pagg_test" schema="" table="v_pagg_test" ctx=DDL +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="regexp_split_to_array" function="regexp_split_to_array" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="regexp_split_to_array" function="regexp_split_to_array" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v_pagg_test AS SELECT y, min(t) AS tmin, max(t) AS tmax, count(DISTINCT t) AS tndisti..." +== 293 +-- truncate_limit: 100 +-- Ensure results are correct. +select * from v_pagg_test order by y +-- +TABLE: name="v_pagg_test" schema="" table="v_pagg_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_pagg_test ORDER BY y" +== 294 +-- truncate_limit: 100 +-- Ensure parallel aggregation is actually being used. +explain (costs off) select * from v_pagg_test order by y +-- +TABLE: name="v_pagg_test" schema="" table="v_pagg_test" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM v_pagg_test ORDER BY y" +== 295 +-- truncate_limit: 100 +-- Ensure results are the same without parallel aggregation. +set max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 0" +== 296 +-- truncate_limit: 100 +select * from v_pagg_test order by y +-- +TABLE: name="v_pagg_test" schema="" table="v_pagg_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_pagg_test ORDER BY y" +== 297 +-- truncate_limit: 100 +-- Check that we don't fail on anonymous record types. +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 298 +-- truncate_limit: 100 +explain (costs off) +select array_dims(array_agg(s)) from (select * from pagg_test) s +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=Select +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT array_dims(array_agg(s)) FROM (SELECT * FROM pagg_test) s" +== 299 +-- truncate_limit: 100 +select array_dims(array_agg(s)) from (select * from pagg_test) s +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=Select +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_dims(array_agg(s)) FROM (SELECT * FROM pagg_test) s" +== 300 +-- truncate_limit: 100 +-- Clean up +reset max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers_per_gather" +== 301 +-- truncate_limit: 100 +reset bytea_output +-- +STMT: VariableSetStmt +TRUNCATED: "RESET bytea_output" +== 302 +-- truncate_limit: 100 +reset min_parallel_table_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_table_scan_size" +== 303 +-- truncate_limit: 100 +reset parallel_leader_participation +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_leader_participation" +== 304 +-- truncate_limit: 100 +reset parallel_tuple_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_tuple_cost" +== 305 +-- truncate_limit: 100 +reset parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 306 +-- truncate_limit: 100 +drop view v_pagg_test +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW v_pagg_test" +== 307 +-- truncate_limit: 100 +drop table pagg_test +-- +TABLE: name="pagg_test" schema="" table="pagg_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pagg_test" +== 308 +-- truncate_limit: 100 +-- FILTER tests + +select min(unique1) filter (where unique1 > 100) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(unique1) FILTER (WHERE unique1 > 100) FROM tenk1" +== 309 +-- truncate_limit: 100 +select sum(1/ten) filter (where ten > 0) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(1 / ten) FILTER (WHERE ten > 0) FROM tenk1" +== 310 +-- truncate_limit: 100 +select ten, sum(distinct four) filter (where four::text ~ '123') from onek a +group by ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ten, sum(DISTINCT four) FILTER (WHERE four::text ~ '123') FROM onek a GROUP BY ten" +== 311 +-- truncate_limit: 100 +select ten, sum(distinct four) filter (where four > 10) from onek a +group by ten +having exists (select 1 from onek b where sum(distinct a.four) = b.four) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="a" column="four" +FILTER: schema="" table="b" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek a GROUP BY ten HAVING EXISTS (SELECT 1 FROM onek b WHERE ...)" +== 312 +-- truncate_limit: 100 +select max(foo COLLATE "C") filter (where (bar collate "POSIX") > '0') +from (values ('a', 'b')) AS v(foo,bar) +-- +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(foo COLLATE \"C\") FILTER (WHERE bar COLLATE \"POSIX\" > '0') FROM (VALUES (...)) v(foo, bar)" +== 313 +-- truncate_limit: 100 +select any_value(v) filter (where v > 2) from (values (1), (2), (3)) as v (v) +-- +FUNCTION: name="any_value" function="any_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT any_value(v) FILTER (WHERE v > 2) FROM (VALUES (1), (2), (3)) v(v)" +== 314 +-- truncate_limit: 100 +-- outer reference in FILTER (PostgreSQL extension) +select (select count(*) + from (values (1)) t0(inner_c)) +from (values (2),(3)) t1(outer_c) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT count(*) FROM (VALUES (1)) t0(inner_c)) FROM (VALUES (2), (3)) t1(outer_c)" +== 315 +-- truncate_limit: 100 +-- inner query is aggregation query +select (select count(*) filter (where outer_c <> 0) + from (values (1)) t0(inner_c)) +from (values (2),(3)) t1(outer_c) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT ... FROM (VALUES (1)) t0(inner_c)) FROM (VALUES (2), (3)) t1(outer_c)" +== 316 +-- truncate_limit: 100 +-- outer query is aggregation query +select (select count(inner_c) filter (where outer_c <> 0) + from (values (1)) t0(inner_c)) +from (values (2),(3)) t1(outer_c) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT ... FROM (VALUES (1)) t0(inner_c)) FROM (VALUES (2), (3)) t1(outer_c)" +== 317 +-- truncate_limit: 100 +-- inner query is aggregation query +select + (select max((select i.unique2 from tenk1 i where i.unique1 = o.unique1)) + filter (where o.unique1 < 10)) +from tenk1 o +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i"="tenk1" +ALIAS: "o"="tenk1" +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="i" column="unique1" +FILTER: schema="" table="o" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT max((SELECT ... FROM tenk1 i WHERE ...)) FILTER (WHERE o.unique1 < 10)) FROM tenk1 o" +== 318 +-- truncate_limit: 100 +-- outer query is aggregation query + +-- subquery in FILTER clause (PostgreSQL extension) +select sum(unique1) FILTER (WHERE + unique1 IN (SELECT unique1 FROM onek where unique1 < 100)) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT sum(unique1) FILTER (WHERE unique1 IN (SELECT unique1 FROM onek WHERE ...)) FROM tenk1" +== 319 +-- truncate_limit: 100 +-- exercise lots of aggregate parts with FILTER +select aggfns(distinct a,b,c order by a,c using ~<~,b) filter (where a > 1) + from (values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz')) v(a,b,c), + generate_series(1,2) i +-- +FUNCTION: name="aggfns" function="aggfns" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a, b, c), generate_series(1, 2) i" +== 320 +-- truncate_limit: 100 +-- check handling of bare boolean Var in FILTER +select max(0) filter (where b1) from bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(0) FILTER (WHERE b1) FROM bool_test" +== 321 +-- truncate_limit: 100 +select (select max(0) filter (where b1)) from bool_test +-- +TABLE: name="bool_test" schema="" table="bool_test" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT max(0) FILTER (WHERE b1)) FROM bool_test" +== 322 +-- truncate_limit: 100 +-- check for correct detection of nested-aggregate errors in FILTER +select max(unique1) filter (where sum(ten) > 0) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(unique1) FILTER (WHERE sum(ten) > 0) FROM tenk1" +== 323 +-- truncate_limit: 100 +select (select max(unique1) filter (where sum(ten) > 0) from int8_tbl) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT max(unique1) FILTER (WHERE sum(ten) > 0) FROM int8_tbl) FROM tenk1" +== 324 +-- truncate_limit: 100 +select max(unique1) filter (where bool_or(ten > 0)) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(unique1) FILTER (WHERE bool_or(ten > 0)) FROM tenk1" +== 325 +-- truncate_limit: 100 +select (select max(unique1) filter (where bool_or(ten > 0)) from int8_tbl) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT max(unique1) FILTER (WHERE bool_or(ten > 0)) FROM int8_tbl) FROM tenk1" +== 326 +-- truncate_limit: 100 +-- ordered-set aggregates + +select p, percentile_cont(p) within group (order by x::float8) +from generate_series(1,5) x, + (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p) +group by p order by p +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 5) x, (VALUES (...)) v(p) GROUP BY p ORDER BY p" +== 327 +-- truncate_limit: 100 +select p, percentile_cont(p order by p) within group (order by x) -- error +from generate_series(1,5) x, + (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p) +group by p order by p +-- +ERROR: cannot use multiple ORDER BY clauses with WITHIN GROUP +CURSORPOS: 41 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 328 +-- truncate_limit: 100 +select p, sum() within group (order by x::float8) -- error +from generate_series(1,5) x, + (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p) +group by p order by p +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 5) x, (VALUES (...)) v(p) GROUP BY p ORDER BY p" +== 329 +-- truncate_limit: 100 +select p, percentile_cont(p,p) -- error +from generate_series(1,5) x, + (values (0::float8),(0.1),(0.25),(0.4),(0.5),(0.6),(0.75),(0.9),(1)) v(p) +group by p order by p +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 5) x, (VALUES (...)) v(p) GROUP BY p ORDER BY p" +== 330 +-- truncate_limit: 100 +select percentile_cont(0.5) within group (order by b) from aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY b) FROM aggtest" +== 331 +-- truncate_limit: 100 +select percentile_cont(0.5) within group (order by b), sum(b) from aggtest +-- +TABLE: name="aggtest" schema="" table="aggtest" ctx=Select +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY b), sum(b) FROM aggtest" +== 332 +-- truncate_limit: 100 +select percentile_cont(0.5) within group (order by thousand) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY thousand) FROM tenk1" +== 333 +-- truncate_limit: 100 +select percentile_disc(0.5) within group (order by thousand) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT percentile_disc(0.5) WITHIN GROUP (ORDER BY thousand) FROM tenk1" +== 334 +-- truncate_limit: 100 +select rank(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4)) v(x) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank(3) WITHIN GROUP (ORDER BY x) FROM (VALUES (1), (1), (2), (2), (3), (3), (4)) v(x)" +== 335 +-- truncate_limit: 100 +select cume_dist(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4)) v(x) +-- +FUNCTION: name="cume_dist" function="cume_dist" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cume_dist(3) WITHIN GROUP (ORDER BY x) FROM (VALUES (1), (1), (2), (2), (3), (3), (4)) v(x)" +== 336 +-- truncate_limit: 100 +select percent_rank(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4),(5)) v(x) +-- +FUNCTION: name="percent_rank" function="percent_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT percent_rank(3) WITHIN GROUP (ORDER BY x) FROM (VALUES (...)) v(x)" +== 337 +-- truncate_limit: 100 +select dense_rank(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4)) v(x) +-- +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dense_rank(3) WITHIN GROUP (ORDER BY x) FROM (VALUES (1), (1), (2), (2), (3), (3), (4)) v(x)" +== 338 +-- truncate_limit: 100 +select percentile_disc(array[0,0.1,0.25,0.5,0.75,0.9,1]) within group (order by thousand) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1" +== 339 +-- truncate_limit: 100 +select percentile_cont(array[0,0.25,0.5,0.75,1]) within group (order by thousand) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT percentile_cont(ARRAY[0, 0.25, 0.5, 0.75, 1]) WITHIN GROUP (ORDER BY thousand) FROM tenk1" +== 340 +-- truncate_limit: 100 +select percentile_disc(array[[null,1,0.5],[0.75,0.25,null]]) within group (order by thousand) +from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1" +== 341 +-- truncate_limit: 100 +select percentile_cont(array[0,1,0.25,0.75,0.5,1,0.3,0.32,0.35,0.38,0.4]) within group (order by x) +from generate_series(1,6) x +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) x" +== 342 +-- truncate_limit: 100 +select ten, mode() within group (order by string4) from tenk1 group by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="mode" function="mode" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ten, mode() WITHIN GROUP (ORDER BY string4) FROM tenk1 GROUP BY ten" +== 343 +-- truncate_limit: 100 +select percentile_disc(array[0.25,0.5,0.75]) within group (order by x) +from unnest('{fred,jim,fred,jack,jill,fred,jill,jim,jim,sheila,jim,sheila}'::text[]) u(x) +-- +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest('{fred,jim,fred,jack,jill,fred,jill,jim,jim,sheila,jim,sheila}'::text[]) u(x)" +== 344 +-- truncate_limit: 100 +-- check collation propagates up in suitable cases: +select pg_collation_for(percentile_disc(1) within group (order by x collate "POSIX")) + from (values ('fred'),('jim')) v(x) +-- +FUNCTION: name="pg_collation_for" function="pg_collation_for" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(x)" +== 345 +-- truncate_limit: 100 +-- ordered-set aggs created with CREATE AGGREGATE +select test_rank(3) within group (order by x) +from (values (1),(1),(2),(2),(3),(3),(4)) v(x) +-- +FUNCTION: name="test_rank" function="test_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_rank(3) WITHIN GROUP (ORDER BY x) FROM (VALUES (1), (1), (2), (2), (3), (3), (4)) v(x)" +== 346 +-- truncate_limit: 100 +select test_percentile_disc(0.5) within group (order by thousand) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="test_percentile_disc" function="test_percentile_disc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_percentile_disc(0.5) WITHIN GROUP (ORDER BY thousand) FROM tenk1" +== 347 +-- truncate_limit: 100 +-- ordered-set aggs can't use ungrouped vars in direct args: +select rank(x) within group (order by x) from generate_series(1,5) x +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank(x) WITHIN GROUP (ORDER BY x) FROM generate_series(1, 5) x" +== 348 +-- truncate_limit: 100 +-- outer-level agg can't use a grouped arg of a lower level, either: +select array(select percentile_disc(a) within group (order by x) + from (values (0.3),(0.7)) v(a) group by a) + from generate_series(1,5) g(x) +-- +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY(SELECT ... FROM (VALUES (...)) v(a) GROUP BY a) FROM generate_series(1, 5) g(x)" +== 349 +-- truncate_limit: 100 +-- agg in the direct args is a grouping violation, too: +select rank(sum(x)) within group (order by x) from generate_series(1,5) x +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank(sum(x)) WITHIN GROUP (ORDER BY x) FROM generate_series(1, 5) x" +== 350 +-- truncate_limit: 100 +-- hypothetical-set type unification and argument-count failures: +select rank(3) within group (order by x) from (values ('fred'),('jim')) v(x) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank(3) WITHIN GROUP (ORDER BY x) FROM (VALUES ('fred'), ('jim')) v(x)" +== 351 +-- truncate_limit: 100 +select rank(3) within group (order by stringu1,stringu2) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank(3) WITHIN GROUP (ORDER BY stringu1, stringu2) FROM tenk1" +== 352 +-- truncate_limit: 100 +select rank('fred') within group (order by x) from generate_series(1,5) x +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank('fred') WITHIN GROUP (ORDER BY x) FROM generate_series(1, 5) x" +== 353 +-- truncate_limit: 100 +select rank('adam'::text collate "C") within group (order by x collate "POSIX") + from (values ('fred'),('jim')) v(x) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(x)" +== 354 +-- truncate_limit: 100 +-- hypothetical-set type unification successes: +select rank('adam'::varchar) within group (order by x) from (values ('fred'),('jim')) v(x) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank('adam'::varchar) WITHIN GROUP (ORDER BY x) FROM (VALUES ('fred'), ('jim')) v(x)" +== 355 +-- truncate_limit: 100 +select rank('3') within group (order by x) from generate_series(1,5) x +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank('3') WITHIN GROUP (ORDER BY x) FROM generate_series(1, 5) x" +== 356 +-- truncate_limit: 100 +-- divide by zero check +select percent_rank(0) within group (order by x) from generate_series(1,0) x +-- +FUNCTION: name="percent_rank" function="percent_rank" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT percent_rank(0) WITHIN GROUP (ORDER BY x) FROM generate_series(1, 0) x" +== 357 +-- truncate_limit: 100 +-- deparse and multiple features: +create view aggordview1 as +select ten, + percentile_disc(0.5) within group (order by thousand) as p50, + percentile_disc(0.5) within group (order by thousand) filter (where hundred=1) as px, + rank(5,'AZZZZ',50) within group (order by hundred, string4 desc, hundred) + from tenk1 + group by ten order by ten +-- +TABLE: name="aggordview1" schema="" table="aggordview1" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW aggordview1 AS SELECT ten, percentile_disc(0.5) WITHIN GROUP (ORDER BY thousand) AS p..." +== 358 +-- truncate_limit: 100 +select pg_get_viewdef('aggordview1') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('aggordview1')" +== 359 +-- truncate_limit: 100 +select * from aggordview1 order by ten +-- +TABLE: name="aggordview1" schema="" table="aggordview1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM aggordview1 ORDER BY ten" +== 360 +-- truncate_limit: 100 +drop view aggordview1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW aggordview1" +== 361 +-- truncate_limit: 100 +-- variadic aggregates +select least_agg(q1,q2) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="least_agg" function="least_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT least_agg(q1, q2) FROM int8_tbl" +== 362 +-- truncate_limit: 100 +select least_agg(variadic array[q1,q2]) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="least_agg" function="least_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT least_agg(VARIADIC ARRAY[q1, q2]) FROM int8_tbl" +== 363 +-- truncate_limit: 100 +select cleast_agg(q1,q2) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="cleast_agg" function="cleast_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cleast_agg(q1, q2) FROM int8_tbl" +== 364 +-- truncate_limit: 100 +select cleast_agg(4.5,f1) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="cleast_agg" function="cleast_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cleast_agg(4.5, f1) FROM int4_tbl" +== 365 +-- truncate_limit: 100 +select cleast_agg(variadic array[4.5,f1]) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="cleast_agg" function="cleast_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cleast_agg(VARIADIC ARRAY[4.5, f1]) FROM int4_tbl" +== 366 +-- truncate_limit: 100 +select pg_typeof(cleast_agg(variadic array[4.5,f1])) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="cleast_agg" function="cleast_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(cleast_agg(VARIADIC ARRAY[4.5, f1])) FROM int4_tbl" +== 367 +-- truncate_limit: 100 +-- test aggregates with common transition functions share the same states +begin work +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 368 +-- truncate_limit: 100 +create type avg_state as (total bigint, count bigint) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE avg_state AS (total bigint, count bigint)" +== 369 +-- truncate_limit: 100 +create or replace function avg_transfn(state avg_state, n int) returns avg_state as +$$ +declare new_state avg_state; +begin + raise notice 'avg_transfn called with %', n; + if state is null then + if n is not null then + new_state.total := n; + new_state.count := 1; + return new_state; + end if; + return null; + elsif n is not null then + state.total := state.total + n; + state.count := state.count + 1; + return state; + end if; + + return null; +end +$$ language plpgsql +-- +FUNCTION: name="avg_transfn" function="avg_transfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION avg_transfn(state avg_state, n int) RETURNS avg_state AS $$\ndeclare ne..." +== 370 +-- truncate_limit: 100 +create function avg_finalfn(state avg_state) returns int4 as +$$ +begin + if state is null then + return NULL; + else + return state.total / state.count; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="avg_finalfn" function="avg_finalfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION avg_finalfn(state avg_state) RETURNS int4 AS $$\nbegin\n\tif state is null then\n\t\tre..." +== 371 +-- truncate_limit: 100 +create function sum_finalfn(state avg_state) returns int4 as +$$ +begin + if state is null then + return NULL; + else + return state.total; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="sum_finalfn" function="sum_finalfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sum_finalfn(state avg_state) RETURNS int4 AS $$\nbegin\n\tif state is null then\n\t\tre..." +== 372 +-- truncate_limit: 100 +create aggregate my_avg(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = avg_finalfn +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_avg (int4) (stype = avg_state, sfunc = avg_transfn, finalfunc = avg_finalfn)" +== 373 +-- truncate_limit: 100 +create aggregate my_sum(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = sum_finalfn +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_sum (int4) (stype = avg_state, sfunc = avg_transfn, finalfunc = sum_finalfn)" +== 374 +-- truncate_limit: 100 +-- aggregate state should be shared as aggs are the same. +select my_avg(one),my_avg(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_avg(one), my_avg(one) FROM (VALUES (1), (3)) t(one)" +== 375 +-- truncate_limit: 100 +-- aggregate state should be shared as transfn is the same for both aggs. +select my_avg(one),my_sum(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_avg(one), my_sum(one) FROM (VALUES (1), (3)) t(one)" +== 376 +-- truncate_limit: 100 +-- same as previous one, but with DISTINCT, which requires sorting the input. +select my_avg(distinct one),my_sum(distinct one) from (values(1),(3),(1)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_avg(DISTINCT one), my_sum(DISTINCT one) FROM (VALUES (1), (3), (1)) t(one)" +== 377 +-- truncate_limit: 100 +-- shouldn't share states due to the distinctness not matching. +select my_avg(distinct one),my_sum(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_avg(DISTINCT one), my_sum(one) FROM (VALUES (1), (3)) t(one)" +== 378 +-- truncate_limit: 100 +-- shouldn't share states due to the filter clause not matching. +select my_avg(one) filter (where one > 1),my_sum(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_avg(one) FILTER (WHERE one > 1), my_sum(one) FROM (VALUES (1), (3)) t(one)" +== 379 +-- truncate_limit: 100 +-- this should not share the state due to different input columns. +select my_avg(one),my_sum(two) from (values(1,2),(3,4)) t(one,two) +-- +FUNCTION: name="my_avg" function="my_avg" schema="" ctx=Call +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_avg(one), my_sum(two) FROM (VALUES (1, 2), (3, 4)) t(one, two)" +== 380 +-- truncate_limit: 100 +-- exercise cases where OSAs share state +select + percentile_cont(0.5) within group (order by a), + percentile_disc(0.5) within group (order by a) +from (values(1::float8),(3),(5),(7)) t(a) +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(a)" +== 381 +-- truncate_limit: 100 +select + percentile_cont(0.25) within group (order by a), + percentile_disc(0.5) within group (order by a) +from (values(1::float8),(3),(5),(7)) t(a) +-- +FUNCTION: name="percentile_cont" function="percentile_cont" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(a)" +== 382 +-- truncate_limit: 100 +-- these can't share state currently +select + rank(4) within group (order by a), + dense_rank(4) within group (order by a) +from (values(1),(3),(5),(7)) t(a) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(a)" +== 383 +-- truncate_limit: 100 +-- test that aggs with the same sfunc and initcond share the same agg state +create aggregate my_sum_init(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = sum_finalfn, + initcond = '(10,0)' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_sum_init (int4) (stype = avg_state, sfunc = avg_transfn, finalfunc = sum_fina..." +== 384 +-- truncate_limit: 100 +create aggregate my_avg_init(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = avg_finalfn, + initcond = '(10,0)' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_avg_init (int4) (stype = avg_state, sfunc = avg_transfn, finalfunc = avg_fina..." +== 385 +-- truncate_limit: 100 +create aggregate my_avg_init2(int4) +( + stype = avg_state, + sfunc = avg_transfn, + finalfunc = avg_finalfn, + initcond = '(4,0)' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_avg_init2 (int4) (stype = avg_state, sfunc = avg_transfn, finalfunc = avg_fin..." +== 386 +-- truncate_limit: 100 +-- state should be shared if INITCONDs are matching +select my_sum_init(one),my_avg_init(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_sum_init" function="my_sum_init" schema="" ctx=Call +FUNCTION: name="my_avg_init" function="my_avg_init" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_sum_init(one), my_avg_init(one) FROM (VALUES (1), (3)) t(one)" +== 387 +-- truncate_limit: 100 +-- Varying INITCONDs should cause the states not to be shared. +select my_sum_init(one),my_avg_init2(one) from (values(1),(3)) t(one) +-- +FUNCTION: name="my_sum_init" function="my_sum_init" schema="" ctx=Call +FUNCTION: name="my_avg_init2" function="my_avg_init2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_sum_init(one), my_avg_init2(one) FROM (VALUES (1), (3)) t(one)" +== 388 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 389 +-- truncate_limit: 100 +-- test aggregate state sharing to ensure it works if one aggregate has a +-- finalfn and the other one has none. +begin work +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 390 +-- truncate_limit: 100 +create or replace function sum_transfn(state int4, n int4) returns int4 as +$$ +declare new_state int4; +begin + raise notice 'sum_transfn called with %', n; + if state is null then + if n is not null then + new_state := n; + return new_state; + end if; + return null; + elsif n is not null then + state := state + n; + return state; + end if; + + return null; +end +$$ language plpgsql +-- +FUNCTION: name="sum_transfn" function="sum_transfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION sum_transfn(state int4, n int4) RETURNS int4 AS $$\ndeclare new_state i..." +== 391 +-- truncate_limit: 100 +create function halfsum_finalfn(state int4) returns int4 as +$$ +begin + if state is null then + return NULL; + else + return state / 2; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="halfsum_finalfn" function="halfsum_finalfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION halfsum_finalfn(state int4) RETURNS int4 AS $$\nbegin\n\tif state is null then\n\t\tret..." +== 392 +-- truncate_limit: 100 +create aggregate my_sum(int4) +( + stype = int4, + sfunc = sum_transfn +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_sum (int4) (stype = int4, sfunc = sum_transfn)" +== 393 +-- truncate_limit: 100 +create aggregate my_half_sum(int4) +( + stype = int4, + sfunc = sum_transfn, + finalfunc = halfsum_finalfn +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_half_sum (int4) (stype = int4, sfunc = sum_transfn, finalfunc = halfsum_finalfn)" +== 394 +-- truncate_limit: 100 +-- Agg state should be shared even though my_sum has no finalfn +select my_sum(one),my_half_sum(one) from (values(1),(2),(3),(4)) t(one) +-- +FUNCTION: name="my_sum" function="my_sum" schema="" ctx=Call +FUNCTION: name="my_half_sum" function="my_half_sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT my_sum(one), my_half_sum(one) FROM (VALUES (1), (2), (3), (4)) t(one)" +== 395 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 396 +-- truncate_limit: 100 +-- test that the aggregate transition logic correctly handles +-- transition / combine functions returning NULL + +-- First test the case of a normal transition function returning NULL +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 397 +-- truncate_limit: 100 +CREATE FUNCTION balkifnull(int8, int4) +RETURNS int8 +STRICT +LANGUAGE plpgsql AS $$ +BEGIN + IF $1 IS NULL THEN + RAISE 'erroneously called with NULL argument'; + END IF; + RETURN NULL; +END$$ +-- +FUNCTION: name="balkifnull" function="balkifnull" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION balkifnull(int8, int4) RETURNS int8 RETURNS NULL ON NULL INPUT LANGUAGE plpgsql A..." +== 398 +-- truncate_limit: 100 +CREATE AGGREGATE balk(int4) +( + SFUNC = balkifnull(int8, int4), + STYPE = int8, + PARALLEL = SAFE, + INITCOND = '0' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE balk (int4) (sfunc = balkifnull(int8, int4), stype = int8, parallel = safe, init..." +== 399 +-- truncate_limit: 100 +SELECT balk(hundred) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="balk" function="balk" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT balk(hundred) FROM tenk1" +== 400 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 401 +-- truncate_limit: 100 +-- GROUP BY optimization by reordering GROUP BY clauses +CREATE TABLE btg AS SELECT + i % 10 AS x, + i % 10 AS y, + 'abc' || i % 10 AS z, + i AS w +FROM generate_series(1, 100) AS i +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE btg AS SELECT i % 10 AS x, i % 10 AS y, 'abc' || (i % 10) AS z, i AS w FROM generate..." +== 402 +-- truncate_limit: 100 +CREATE INDEX btg_x_y_idx ON btg(x, y) +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX btg_x_y_idx ON btg USING btree (x, y)" +== 403 +-- truncate_limit: 100 +ANALYZE btg +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE btg" +== 404 +-- truncate_limit: 100 +SET enable_hashagg = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 405 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 406 +-- truncate_limit: 100 +-- Utilize the ordering of index scan to avoid a Sort operation +EXPLAIN (COSTS OFF) +SELECT count(*) FROM btg GROUP BY y, x +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM btg GROUP BY y, x" +== 407 +-- truncate_limit: 100 +-- Engage incremental sort +EXPLAIN (COSTS OFF) +SELECT count(*) FROM btg GROUP BY z, y, w, x +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM btg GROUP BY z, y, w, x" +== 408 +-- truncate_limit: 100 +-- Utilize the ordering of subquery scan to avoid a Sort operation +EXPLAIN (COSTS OFF) SELECT count(*) +FROM (SELECT * FROM btg ORDER BY x, y, w, z) AS q1 +GROUP BY w, x, z, y +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM (SELECT * FROM btg ORDER BY x, y, w, z) q1 GROUP BY w, x..." +== 409 +-- truncate_limit: 100 +-- Utilize the ordering of merge join to avoid a full Sort operation +SET enable_hashjoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 410 +-- truncate_limit: 100 +SET enable_nestloop = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 411 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) + FROM btg t1 JOIN btg t2 ON t1.z = t2.z AND t1.w = t2.w AND t1.x = t2.x + GROUP BY t1.x, t1.y, t1.z, t1.w +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +TABLE: name="btg" schema="" table="btg" ctx=Select +ALIAS: "t1"="btg" +ALIAS: "t2"="btg" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM btg t1 JOIN btg t2 ON t1.z = t2.z AND t1.w = t2.w AND t1..." +== 412 +-- truncate_limit: 100 +RESET enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 413 +-- truncate_limit: 100 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 414 +-- truncate_limit: 100 +-- Should work with and without GROUP-BY optimization +EXPLAIN (COSTS OFF) +SELECT count(*) FROM btg GROUP BY w, x, z, y ORDER BY y, x, z, w +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM btg GROUP BY w, x, z, y ORDER BY y, x, z, w" +== 415 +-- truncate_limit: 100 +-- Utilize incremental sort to make the ORDER BY rule a bit cheaper +EXPLAIN (COSTS OFF) +SELECT count(*) FROM btg GROUP BY w, x, y, z ORDER BY x*x, z +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM btg GROUP BY w, x, y, z ORDER BY x * x, z" +== 416 +-- truncate_limit: 100 +-- Test the case where the number of incoming subtree path keys is more than +-- the number of grouping keys. +CREATE INDEX btg_y_x_w_idx ON btg(y, x, w) +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX btg_y_x_w_idx ON btg USING btree (y, x, w)" +== 417 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT y, x, array_agg(distinct w) + FROM btg WHERE y < 0 GROUP BY x, y +-- +TABLE: name="btg" schema="" table="btg" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT y, x, array_agg(DISTINCT w) FROM btg WHERE y < 0 GROUP BY x, y" +== 418 +-- truncate_limit: 100 +-- Ensure that we do not select the aggregate pathkeys instead of the grouping +-- pathkeys +CREATE TABLE group_agg_pk AS SELECT + i % 10 AS x, + i % 2 AS y, + i % 2 AS z, + 2 AS w, + i % 10 AS f +FROM generate_series(1,100) AS i +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE group_agg_pk AS SELECT i % 10 AS x, i % 2 AS y, i % 2 AS z, 2 AS w, i % 10 AS f FROM..." +== 419 +-- truncate_limit: 100 +ANALYZE group_agg_pk +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE group_agg_pk" +== 420 +-- truncate_limit: 100 +SET enable_nestloop = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 421 +-- truncate_limit: 100 +SET enable_hashjoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 422 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT avg(c1.f ORDER BY c1.x, c1.y) +FROM group_agg_pk c1 JOIN group_agg_pk c2 ON c1.x = c2.x +GROUP BY c1.w, c1.z +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +ALIAS: "c1"="group_agg_pk" +ALIAS: "c2"="group_agg_pk" +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT avg(c1.f ORDER BY c1.x, c1.y) FROM group_agg_pk c1 JOIN group_agg_pk c..." +== 423 +-- truncate_limit: 100 +SELECT avg(c1.f ORDER BY c1.x, c1.y) +FROM group_agg_pk c1 JOIN group_agg_pk c2 ON c1.x = c2.x +GROUP BY c1.w, c1.z +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +ALIAS: "c1"="group_agg_pk" +ALIAS: "c2"="group_agg_pk" +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM group_agg_pk c1 JOIN group_agg_pk c2 ON c1.x = c2.x GROUP BY c1.w, c1.z" +== 424 +-- truncate_limit: 100 +-- Pathkeys, built in a subtree, can be used to optimize GROUP-BY clause +-- ordering. Also, here we check that it doesn't depend on the initial clause +-- order in the GROUP-BY list. +EXPLAIN (COSTS OFF) +SELECT c1.y,c1.x FROM group_agg_pk c1 + JOIN group_agg_pk c2 + ON c1.x = c2.x +GROUP BY c1.y,c1.x,c2.x +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +ALIAS: "c1"="group_agg_pk" +ALIAS: "c2"="group_agg_pk" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c1.y, c1.x FROM group_agg_pk c1 JOIN group_agg_pk c2 ON c1.x = c2.x GR..." +== 425 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT c1.y,c1.x FROM group_agg_pk c1 + JOIN group_agg_pk c2 + ON c1.x = c2.x +GROUP BY c1.y,c2.x,c1.x +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=Select +ALIAS: "c1"="group_agg_pk" +ALIAS: "c2"="group_agg_pk" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c1.y, c1.x FROM group_agg_pk c1 JOIN group_agg_pk c2 ON c1.x = c2.x GR..." +== 426 +-- truncate_limit: 100 +RESET enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 427 +-- truncate_limit: 100 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 428 +-- truncate_limit: 100 +DROP TABLE group_agg_pk +-- +TABLE: name="group_agg_pk" schema="" table="group_agg_pk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE group_agg_pk" +== 429 +-- truncate_limit: 100 +-- Test the case where the ordering of the scan matches the ordering within the +-- aggregate but cannot be found in the group-by list +CREATE TABLE agg_sort_order (c1 int PRIMARY KEY, c2 int) +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE agg_sort_order (c1 int PRIMARY KEY, c2 int)" +== 430 +-- truncate_limit: 100 +CREATE UNIQUE INDEX agg_sort_order_c2_idx ON agg_sort_order(c2) +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX agg_sort_order_c2_idx ON agg_sort_order USING btree (c2)" +== 431 +-- truncate_limit: 100 +INSERT INTO agg_sort_order SELECT i, i FROM generate_series(1,100)i +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO agg_sort_order SELECT i, i FROM generate_series(1, 100) i" +== 432 +-- truncate_limit: 100 +ANALYZE agg_sort_order +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE agg_sort_order" +== 433 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT array_agg(c1 ORDER BY c2),c2 +FROM agg_sort_order WHERE c2 < 100 GROUP BY c1 ORDER BY 2 +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="c2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT array_agg(c1 ORDER BY c2), c2 FROM agg_sort_order WHERE c2 < 100 GROUP..." +== 434 +-- truncate_limit: 100 +DROP TABLE agg_sort_order CASCADE +-- +TABLE: name="agg_sort_order" schema="" table="agg_sort_order" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_sort_order CASCADE" +== 435 +-- truncate_limit: 100 +DROP TABLE btg +-- +TABLE: name="btg" schema="" table="btg" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE btg" +== 436 +-- truncate_limit: 100 +RESET enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 437 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 438 +-- truncate_limit: 100 +-- Secondly test the case of a parallel aggregate combiner function +-- returning NULL. For that use normal transition function, but a +-- combiner function returning NULL. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 439 +-- truncate_limit: 100 +CREATE FUNCTION balkifnull(int8, int8) +RETURNS int8 +PARALLEL SAFE +STRICT +LANGUAGE plpgsql AS $$ +BEGIN + IF $1 IS NULL THEN + RAISE 'erroneously called with NULL argument'; + END IF; + RETURN NULL; +END$$ +-- +FUNCTION: name="balkifnull" function="balkifnull" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION balkifnull(int8, int8) RETURNS int8 PARALLEL safe RETURNS NULL ON NULL INPUT LANG..." +== 440 +-- truncate_limit: 100 +CREATE AGGREGATE balk(int4) +( + SFUNC = int4_sum(int8, int4), + STYPE = int8, + COMBINEFUNC = balkifnull(int8, int8), + PARALLEL = SAFE, + INITCOND = '0' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE balk (int4) (sfunc = int4_sum(int8, int4), stype = int8, combinefunc = balkifnul..." +== 441 +-- truncate_limit: 100 +-- force use of parallelism +ALTER TABLE tenk1 set (parallel_workers = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk1 SET (parallel_workers=4)" +== 442 +-- truncate_limit: 100 +SET LOCAL parallel_setup_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL parallel_setup_cost TO 0" +== 443 +-- truncate_limit: 100 +SET LOCAL max_parallel_workers_per_gather=4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 4" +== 444 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT balk(hundred) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="balk" function="balk" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT balk(hundred) FROM tenk1" +== 445 +-- truncate_limit: 100 +SELECT balk(hundred) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="balk" function="balk" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT balk(hundred) FROM tenk1" +== 446 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 447 +-- truncate_limit: 100 +-- test multiple usage of an aggregate whose finalfn returns a R/W datum +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 448 +-- truncate_limit: 100 +CREATE FUNCTION rwagg_sfunc(x anyarray, y anyarray) RETURNS anyarray +LANGUAGE plpgsql IMMUTABLE AS $$ +BEGIN + RETURN array_fill(y[1], ARRAY[4]); +END; +$$ +-- +FUNCTION: name="rwagg_sfunc" function="rwagg_sfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rwagg_sfunc(x anyarray, y anyarray) RETURNS anyarray LANGUAGE plpgsql IMMUTABLE A..." +== 449 +-- truncate_limit: 100 +CREATE FUNCTION rwagg_finalfunc(x anyarray) RETURNS anyarray +LANGUAGE plpgsql STRICT IMMUTABLE AS $$ +DECLARE + res x%TYPE; +BEGIN + -- assignment is essential for this test, it expands the array to R/W + res := array_fill(x[1], ARRAY[4]); + RETURN res; +END; +$$ +-- +FUNCTION: name="rwagg_finalfunc" function="rwagg_finalfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rwagg_finalfunc(x anyarray) RETURNS anyarray LANGUAGE plpgsql RETURNS NULL ON NUL..." +== 450 +-- truncate_limit: 100 +CREATE AGGREGATE rwagg(anyarray) ( + STYPE = anyarray, + SFUNC = rwagg_sfunc, + FINALFUNC = rwagg_finalfunc +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE rwagg (anyarray) (stype = anyarray, sfunc = rwagg_sfunc, finalfunc = rwagg_final..." +== 451 +-- truncate_limit: 100 +CREATE FUNCTION eatarray(x real[]) RETURNS real[] +LANGUAGE plpgsql STRICT IMMUTABLE AS $$ +BEGIN + x[1] := x[1] + 1; + RETURN x; +END; +$$ +-- +FUNCTION: name="eatarray" function="eatarray" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION eatarray(x real[]) RETURNS real[] LANGUAGE plpgsql RETURNS NULL ON NULL INPUT IMM..." +== 452 +-- truncate_limit: 100 +SELECT eatarray(rwagg(ARRAY[1.0::real])), eatarray(rwagg(ARRAY[1.0::real])) +-- +FUNCTION: name="eatarray" function="eatarray" schema="" ctx=Call +FUNCTION: name="rwagg" function="rwagg" schema="" ctx=Call +FUNCTION: name="eatarray" function="eatarray" schema="" ctx=Call +FUNCTION: name="rwagg" function="rwagg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT eatarray(rwagg(ARRAY[(1.0)::real])), eatarray(rwagg(ARRAY[(1.0)::real]))" +== 453 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 454 +-- truncate_limit: 100 +-- test coverage for aggregate combine/serial/deserial functions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 455 +-- truncate_limit: 100 +SET parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 456 +-- truncate_limit: 100 +SET parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 457 +-- truncate_limit: 100 +SET min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 458 +-- truncate_limit: 100 +SET max_parallel_workers_per_gather = 4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 4" +== 459 +-- truncate_limit: 100 +SET parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO OFF" +== 460 +-- truncate_limit: 100 +SET enable_indexonlyscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexonlyscan TO OFF" +== 461 +-- truncate_limit: 100 +-- variance(int4) covers numeric_poly_combine +-- sum(int8) covers int8_avg_combine +-- regr_count(float8, float8) covers int8inc_float8_float8 and aggregates with > 1 arg +EXPLAIN (COSTS OFF, VERBOSE) +SELECT variance(unique1::int4), sum(unique1::int8), regr_count(unique1::float8, unique1::float8) +FROM (SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1) u +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_count" function="regr_count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT variance(unique1::int4), sum(unique1::int8), regr_count(uniqu..." +== 462 +-- truncate_limit: 100 +SELECT variance(unique1::int4), sum(unique1::int8), regr_count(unique1::float8, unique1::float8) +FROM (SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1) u +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="regr_count" function="regr_count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (((SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1) UNION ALL SELECT * FROM ten..." +== 463 +-- truncate_limit: 100 +-- variance(int8) covers numeric_combine +-- avg(numeric) covers numeric_avg_combine +EXPLAIN (COSTS OFF, VERBOSE) +SELECT variance(unique1::int8), avg(unique1::numeric) +FROM (SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1) u +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT variance(unique1::int8), avg(unique1::numeric) FROM (((SELECT..." +== 464 +-- truncate_limit: 100 +SELECT variance(unique1::int8), avg(unique1::numeric) +FROM (SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1 + UNION ALL SELECT * FROM tenk1) u +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (((SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1) UNION ALL SELECT * FROM ten..." +== 465 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 466 +-- truncate_limit: 100 +-- test coverage for dense_rank +SELECT dense_rank(x) WITHIN GROUP (ORDER BY x) FROM (VALUES (1),(1),(2),(2),(3),(3)) v(x) GROUP BY (x) ORDER BY 1 +-- +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dense_rank(x) WITHIN GROUP (ORDER BY x) FROM (VALUES (...)) v(x) GROUP BY x ORDER BY 1" +== 467 +-- truncate_limit: 100 +-- Ensure that the STRICT checks for aggregates does not take NULLness +-- of ORDER BY columns into account. See bug report around +-- 2a505161-2727-2473-7c46-591ed108ac52@email.cz +SELECT min(x ORDER BY y) FROM (VALUES(1, NULL)) AS d(x,y) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(x ORDER BY y) FROM (VALUES (1, NULL)) d(x, y)" +== 468 +-- truncate_limit: 100 +SELECT min(x ORDER BY y) FROM (VALUES(1, 2)) AS d(x,y) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(x ORDER BY y) FROM (VALUES (1, 2)) d(x, y)" +== 469 +-- truncate_limit: 100 +-- check collation-sensitive matching between grouping expressions +select v||'a', case v||'a' when 'aa' then 1 else 0 end, count(*) + from unnest(array['a','b']) u(v) + group by v||'a' order by 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY['a', 'b']) u(v) GROUP BY v || 'a' ORDER BY 1" +== 470 +-- truncate_limit: 100 +select v||'a', case when v||'a' = 'aa' then 1 else 0 end, count(*) + from unnest(array['a','b']) u(v) + group by v||'a' order by 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY['a', 'b']) u(v) GROUP BY v || 'a' ORDER BY 1" +== 471 +-- truncate_limit: 100 +-- Make sure that generation of HashAggregate for uniqification purposes +-- does not lead to array overflow due to unexpected duplicate hash keys +-- see CAFeeJoKKu0u+A_A9R9316djW-YW3-+Gtgvy3ju655qRHR3jtdA@mail.gmail.com +set enable_memoize to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_memoize TO OFF" +== 472 +-- truncate_limit: 100 +explain (costs off) + select 1 from tenk1 + where (hundred, thousand) in (select twothousand, twothousand from onek) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM tenk1 WHERE (hundred, thousand) IN (SELECT twothousand, twothou..." +== 473 +-- truncate_limit: 100 +reset enable_memoize +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_memoize" +== 474 +-- truncate_limit: 100 +|-- +-- Hash Aggregation Spill tests +|-- + +set enable_sort=false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO FALSE" +== 475 +-- truncate_limit: 100 +set work_mem='64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 476 +-- truncate_limit: 100 +select unique1, count(*), sum(twothousand) from tenk1 +group by unique1 +having sum(fivethous) > 4975 +order by sum(twothousand) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 GROUP BY unique1 HAVING sum(fivethous) > 4975 ORDER BY sum(twothousand)" +== 477 +-- truncate_limit: 100 +set work_mem to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO DEFAULT" +== 478 +-- truncate_limit: 100 +set enable_sort to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO DEFAULT" +== 479 +-- truncate_limit: 100 +|-- +-- Compare results between plans using sorting and plans using hash +-- aggregation. Force spilling in both cases by setting work_mem low. +|-- + +set work_mem='64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 480 +-- truncate_limit: 100 +create table agg_data_2k as +select g from generate_series(0, 1999) g +-- +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_data_2k AS SELECT g FROM generate_series(0, 1999) g" +== 481 +-- truncate_limit: 100 +analyze agg_data_2k +-- +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE agg_data_2k" +== 482 +-- truncate_limit: 100 +create table agg_data_20k as +select g from generate_series(0, 19999) g +-- +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_data_20k AS SELECT g FROM generate_series(0, 19999) g" +== 483 +-- truncate_limit: 100 +analyze agg_data_20k +-- +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE agg_data_20k" +== 484 +-- truncate_limit: 100 +-- Produce results with sorting. + +set enable_hashagg = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 485 +-- truncate_limit: 100 +set jit_above_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO 0" +== 486 +-- truncate_limit: 100 +explain (costs off) +select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 + from agg_data_20k group by g%10000 +-- +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT g % 10000 AS c1, sum(g::numeric) AS c2, count(*) AS c3 FROM agg_data_2..." +== 487 +-- truncate_limit: 100 +create table agg_group_1 as +select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 + from agg_data_20k group by g%10000 +-- +TABLE: name="agg_group_1" schema="" table="agg_group_1" ctx=DDL +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_group_1 AS SELECT g % 10000 AS c1, sum(g::numeric) AS c2, count(*) AS c3 FROM ag..." +== 488 +-- truncate_limit: 100 +create table agg_group_2 as +select * from + (values (100), (300), (500)) as r(a), + lateral ( + select (g/2)::numeric as c1, + array_agg(g::numeric) as c2, + count(*) as c3 + from agg_data_2k + where g < r.a + group by g/2) as s +-- +TABLE: name="agg_group_2" schema="" table="agg_group_2" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="g" +FILTER: schema="" table="r" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_group_2 AS SELECT * FROM (VALUES (100), (300), (500)) r(a), LATERAL (SELECT (g /..." +== 489 +-- truncate_limit: 100 +set jit_above_cost to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO DEFAULT" +== 490 +-- truncate_limit: 100 +create table agg_group_3 as +select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3 + from agg_data_2k group by g/2 +-- +TABLE: name="agg_group_3" schema="" table="agg_group_3" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_group_3 AS SELECT (g / 2)::numeric AS c1, sum(7::int4) AS c2, count(*) AS c3 FRO..." +== 491 +-- truncate_limit: 100 +create table agg_group_4 as +select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3 + from agg_data_2k group by g/2 +-- +TABLE: name="agg_group_4" schema="" table="agg_group_4" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_group_4 AS SELECT (g / 2)::numeric AS c1, array_agg(g::numeric) AS c2, count(*) ..." +== 492 +-- truncate_limit: 100 +-- Produce results with hash aggregation + +set enable_hashagg = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO TRUE" +== 493 +-- truncate_limit: 100 +set enable_sort = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO FALSE" +== 494 +-- truncate_limit: 100 +set jit_above_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO 0" +== 495 +-- truncate_limit: 100 +explain (costs off) +select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 + from agg_data_20k group by g%10000 +-- +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT g % 10000 AS c1, sum(g::numeric) AS c2, count(*) AS c3 FROM agg_data_2..." +== 496 +-- truncate_limit: 100 +create table agg_hash_1 as +select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 + from agg_data_20k group by g%10000 +-- +TABLE: name="agg_hash_1" schema="" table="agg_hash_1" ctx=DDL +TABLE: name="agg_data_20k" schema="" table="agg_data_20k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_hash_1 AS SELECT g % 10000 AS c1, sum(g::numeric) AS c2, count(*) AS c3 FROM agg..." +== 497 +-- truncate_limit: 100 +create table agg_hash_2 as +select * from + (values (100), (300), (500)) as r(a), + lateral ( + select (g/2)::numeric as c1, + array_agg(g::numeric) as c2, + count(*) as c3 + from agg_data_2k + where g < r.a + group by g/2) as s +-- +TABLE: name="agg_hash_2" schema="" table="agg_hash_2" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="g" +FILTER: schema="" table="r" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_hash_2 AS SELECT * FROM (VALUES (100), (300), (500)) r(a), LATERAL (SELECT (g / ..." +== 498 +-- truncate_limit: 100 +set jit_above_cost to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO DEFAULT" +== 499 +-- truncate_limit: 100 +create table agg_hash_3 as +select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3 + from agg_data_2k group by g/2 +-- +TABLE: name="agg_hash_3" schema="" table="agg_hash_3" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_hash_3 AS SELECT (g / 2)::numeric AS c1, sum(7::int4) AS c2, count(*) AS c3 FROM..." +== 500 +-- truncate_limit: 100 +create table agg_hash_4 as +select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3 + from agg_data_2k group by g/2 +-- +TABLE: name="agg_hash_4" schema="" table="agg_hash_4" ctx=DDL +TABLE: name="agg_data_2k" schema="" table="agg_data_2k" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE agg_hash_4 AS SELECT (g / 2)::numeric AS c1, array_agg(g::numeric) AS c2, count(*) A..." +== 501 +-- truncate_limit: 100 +set enable_sort = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO TRUE" +== 502 +-- truncate_limit: 100 +set work_mem to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO DEFAULT" +== 503 +-- truncate_limit: 100 +-- Compare group aggregation results to hash aggregation results + +(select * from agg_hash_1 except select * from agg_group_1) + union all +(select * from agg_group_1 except select * from agg_hash_1) +-- +TABLE: name="agg_hash_1" schema="" table="agg_hash_1" ctx=Select +TABLE: name="agg_group_1" schema="" table="agg_group_1" ctx=Select +TABLE: name="agg_group_1" schema="" table="agg_group_1" ctx=Select +TABLE: name="agg_hash_1" schema="" table="agg_hash_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM agg_hash_1 EXCEPT SELECT * FROM agg_group_1) UNION ALL (SELECT * FROM agg_group_1 ..." +== 504 +-- truncate_limit: 100 +(select * from agg_hash_2 except select * from agg_group_2) + union all +(select * from agg_group_2 except select * from agg_hash_2) +-- +TABLE: name="agg_hash_2" schema="" table="agg_hash_2" ctx=Select +TABLE: name="agg_group_2" schema="" table="agg_group_2" ctx=Select +TABLE: name="agg_group_2" schema="" table="agg_group_2" ctx=Select +TABLE: name="agg_hash_2" schema="" table="agg_hash_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM agg_hash_2 EXCEPT SELECT * FROM agg_group_2) UNION ALL (SELECT * FROM agg_group_2 ..." +== 505 +-- truncate_limit: 100 +(select * from agg_hash_3 except select * from agg_group_3) + union all +(select * from agg_group_3 except select * from agg_hash_3) +-- +TABLE: name="agg_hash_3" schema="" table="agg_hash_3" ctx=Select +TABLE: name="agg_group_3" schema="" table="agg_group_3" ctx=Select +TABLE: name="agg_group_3" schema="" table="agg_group_3" ctx=Select +TABLE: name="agg_hash_3" schema="" table="agg_hash_3" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM agg_hash_3 EXCEPT SELECT * FROM agg_group_3) UNION ALL (SELECT * FROM agg_group_3 ..." +== 506 +-- truncate_limit: 100 +(select * from agg_hash_4 except select * from agg_group_4) + union all +(select * from agg_group_4 except select * from agg_hash_4) +-- +TABLE: name="agg_hash_4" schema="" table="agg_hash_4" ctx=Select +TABLE: name="agg_group_4" schema="" table="agg_group_4" ctx=Select +TABLE: name="agg_group_4" schema="" table="agg_group_4" ctx=Select +TABLE: name="agg_hash_4" schema="" table="agg_hash_4" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM agg_hash_4 EXCEPT SELECT * FROM agg_group_4) UNION ALL (SELECT * FROM agg_group_4 ..." +== 507 +-- truncate_limit: 100 +drop table agg_group_1 +-- +TABLE: name="agg_group_1" schema="" table="agg_group_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_group_1" +== 508 +-- truncate_limit: 100 +drop table agg_group_2 +-- +TABLE: name="agg_group_2" schema="" table="agg_group_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_group_2" +== 509 +-- truncate_limit: 100 +drop table agg_group_3 +-- +TABLE: name="agg_group_3" schema="" table="agg_group_3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_group_3" +== 510 +-- truncate_limit: 100 +drop table agg_group_4 +-- +TABLE: name="agg_group_4" schema="" table="agg_group_4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_group_4" +== 511 +-- truncate_limit: 100 +drop table agg_hash_1 +-- +TABLE: name="agg_hash_1" schema="" table="agg_hash_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_hash_1" +== 512 +-- truncate_limit: 100 +drop table agg_hash_2 +-- +TABLE: name="agg_hash_2" schema="" table="agg_hash_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_hash_2" +== 513 +-- truncate_limit: 100 +drop table agg_hash_3 +-- +TABLE: name="agg_hash_3" schema="" table="agg_hash_3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_hash_3" +== 514 +-- truncate_limit: 100 +drop table agg_hash_4 +-- +TABLE: name="agg_hash_4" schema="" table="agg_hash_4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE agg_hash_4" diff --git a/parser/testdata/summary_truncate/postgres_regress/alter_generic.metadata.json b/parser/testdata/summary_truncate/postgres_regress/alter_generic.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/alter_generic.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/alter_generic.test b/parser/testdata/summary_truncate/postgres_regress/alter_generic.test new file mode 100644 index 0000000..f26f10a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/alter_generic.test @@ -0,0 +1,2472 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test for ALTER some_object {RENAME TO, OWNER TO, SET SCHEMA} +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION test_opclass_options_func(internal) + RETURNS void + AS :'regresslib', 'test_opclass_options_func' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 224 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +-- Clean up in case a prior regression run failed +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 003 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_alter_generic_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_alter_generic_user1" +== 004 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_alter_generic_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_alter_generic_user2" +== 005 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_alter_generic_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_alter_generic_user3" +== 006 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 007 +-- truncate_limit: 100 +CREATE USER regress_alter_generic_user3 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_alter_generic_user3" +== 008 +-- truncate_limit: 100 +CREATE USER regress_alter_generic_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_alter_generic_user2" +== 009 +-- truncate_limit: 100 +CREATE USER regress_alter_generic_user1 IN ROLE regress_alter_generic_user3 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_alter_generic_user1 WITH IN ROLE regress_alter_generic_user3" +== 010 +-- truncate_limit: 100 +CREATE SCHEMA alt_nsp1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA alt_nsp1" +== 011 +-- truncate_limit: 100 +CREATE SCHEMA alt_nsp2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA alt_nsp2" +== 012 +-- truncate_limit: 100 +GRANT ALL ON SCHEMA alt_nsp1, alt_nsp2 TO public +-- +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON SCHEMA alt_nsp1, alt_nsp2 TO public" +== 013 +-- truncate_limit: 100 +SET search_path = alt_nsp1, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO alt_nsp1, public" +== 014 +-- truncate_limit: 100 +|-- +-- Function and Aggregate +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user1" +== 015 +-- truncate_limit: 100 +CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql + AS 'SELECT $1 + 1' +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql AS $$SELECT $1 + 1$$" +== 016 +-- truncate_limit: 100 +CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql + AS 'SELECT $1 - 1' +-- +FUNCTION: name="alt_func2" function="alt_func2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql AS $$SELECT $1 - 1$$" +== 017 +-- truncate_limit: 100 +CREATE AGGREGATE alt_agg1 ( + sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE alt_agg1 (sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0)" +== 018 +-- truncate_limit: 100 +CREATE AGGREGATE alt_agg2 ( + sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = 0 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE alt_agg2 (sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = 0)" +== 019 +-- truncate_limit: 100 +ALTER AGGREGATE alt_func1(int) RENAME TO alt_func3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER AGGREGATE alt_func1(int) RENAME TO alt_func3" +== 020 +-- truncate_limit: 100 +-- failed (not aggregate) +ALTER AGGREGATE alt_func1(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER AGGREGATE alt_func1(int) OWNER TO regress_alter_generic_user3" +== 021 +-- truncate_limit: 100 +-- failed (not aggregate) +ALTER AGGREGATE alt_func1(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER AGGREGATE alt_func1(int) SET SCHEMA alt_nsp2" +== 022 +-- truncate_limit: 100 +-- failed (not aggregate) + +ALTER FUNCTION alt_func1(int) RENAME TO alt_func2 +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +FUNCTION: name="alt_func2" function="alt_func2" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER FUNCTION alt_func1(int) RENAME TO alt_func2" +== 023 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER FUNCTION alt_func1(int) RENAME TO alt_func3 +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +FUNCTION: name="alt_func3" function="alt_func3" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER FUNCTION alt_func1(int) RENAME TO alt_func3" +== 024 +-- truncate_limit: 100 +-- OK +ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user2" +== 025 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user3" +== 026 +-- truncate_limit: 100 +-- OK +ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp1 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp1" +== 027 +-- truncate_limit: 100 +-- OK, already there +ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2" +== 028 +-- truncate_limit: 100 +-- OK + +ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg2" +== 029 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg3" +== 030 +-- truncate_limit: 100 +-- OK +ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user2" +== 031 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3" +== 032 +-- truncate_limit: 100 +-- OK +ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2" +== 033 +-- truncate_limit: 100 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user2" +== 034 +-- truncate_limit: 100 +CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql + AS 'SELECT $1 + 2' +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql AS $$SELECT $1 + 2$$" +== 035 +-- truncate_limit: 100 +CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql + AS 'SELECT $1 - 2' +-- +FUNCTION: name="alt_func2" function="alt_func2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql AS $$SELECT $1 - 2$$" +== 036 +-- truncate_limit: 100 +CREATE AGGREGATE alt_agg1 ( + sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE alt_agg1 (sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100)" +== 037 +-- truncate_limit: 100 +CREATE AGGREGATE alt_agg2 ( + sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = -100 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE alt_agg2 (sfunc1 = int4mi, basetype = int4, stype1 = int4, initcond = -100)" +== 038 +-- truncate_limit: 100 +ALTER FUNCTION alt_func3(int) RENAME TO alt_func4 +-- +FUNCTION: name="alt_func3" function="alt_func3" schema="" ctx=DDL +FUNCTION: name="alt_func4" function="alt_func4" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER FUNCTION alt_func3(int) RENAME TO alt_func4" +== 039 +-- truncate_limit: 100 +-- failed (not owner) +ALTER FUNCTION alt_func1(int) RENAME TO alt_func4 +-- +FUNCTION: name="alt_func1" function="alt_func1" schema="" ctx=DDL +FUNCTION: name="alt_func4" function="alt_func4" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER FUNCTION alt_func1(int) RENAME TO alt_func4" +== 040 +-- truncate_limit: 100 +-- OK +ALTER FUNCTION alt_func3(int) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FUNCTION alt_func3(int) OWNER TO regress_alter_generic_user2" +== 041 +-- truncate_limit: 100 +-- failed (not owner) +ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FUNCTION alt_func2(int) OWNER TO regress_alter_generic_user3" +== 042 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER FUNCTION alt_func3(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER FUNCTION alt_func3(int) SET SCHEMA alt_nsp2" +== 043 +-- truncate_limit: 100 +-- failed (not owner) +ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER FUNCTION alt_func2(int) SET SCHEMA alt_nsp2" +== 044 +-- truncate_limit: 100 +-- failed (name conflicts) + +ALTER AGGREGATE alt_agg3(int) RENAME TO alt_agg4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER AGGREGATE alt_agg3(int) RENAME TO alt_agg4" +== 045 +-- truncate_limit: 100 +-- failed (not owner) +ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER AGGREGATE alt_agg1(int) RENAME TO alt_agg4" +== 046 +-- truncate_limit: 100 +-- OK +ALTER AGGREGATE alt_agg3(int) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER AGGREGATE alt_agg3(int) OWNER TO regress_alter_generic_user2" +== 047 +-- truncate_limit: 100 +-- failed (not owner) +ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3" +== 048 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER AGGREGATE alt_agg3(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER AGGREGATE alt_agg3(int) SET SCHEMA alt_nsp2" +== 049 +-- truncate_limit: 100 +-- failed (not owner) +ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2" +== 050 +-- truncate_limit: 100 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 051 +-- truncate_limit: 100 +SELECT n.nspname, proname, prorettype::regtype, prokind, a.rolname + FROM pg_proc p, pg_namespace n, pg_authid a + WHERE p.pronamespace = n.oid AND p.proowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="p" column="pronamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="p" column="proowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_proc p, pg_namespace n, pg_authid a WHERE ... ORDER BY nspname, proname" +== 052 +-- truncate_limit: 100 +|-- +-- We would test collations here, but it's not possible because the error +-- messages tend to be nonportable. +|-- + +|-- +-- Conversion +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user1" +== 053 +-- truncate_limit: 100 +CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 054 +-- truncate_limit: 100 +CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 055 +-- truncate_limit: 100 +ALTER CONVERSION alt_conv1 RENAME TO alt_conv2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER CONVERSION alt_conv1 RENAME TO alt_conv2" +== 056 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER CONVERSION alt_conv1 RENAME TO alt_conv3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER CONVERSION alt_conv1 RENAME TO alt_conv3" +== 057 +-- truncate_limit: 100 +-- OK +ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user2" +== 058 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user3" +== 059 +-- truncate_limit: 100 +-- OK +ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2" +== 060 +-- truncate_limit: 100 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user2" +== 061 +-- truncate_limit: 100 +CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE CONVERSION alt_conv1 FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 062 +-- truncate_limit: 100 +CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE CONVERSION alt_conv2 FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 063 +-- truncate_limit: 100 +ALTER CONVERSION alt_conv3 RENAME TO alt_conv4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER CONVERSION alt_conv3 RENAME TO alt_conv4" +== 064 +-- truncate_limit: 100 +-- failed (not owner) +ALTER CONVERSION alt_conv1 RENAME TO alt_conv4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER CONVERSION alt_conv1 RENAME TO alt_conv4" +== 065 +-- truncate_limit: 100 +-- OK +ALTER CONVERSION alt_conv3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER CONVERSION alt_conv3 OWNER TO regress_alter_generic_user2" +== 066 +-- truncate_limit: 100 +-- failed (not owner) +ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER CONVERSION alt_conv2 OWNER TO regress_alter_generic_user3" +== 067 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER CONVERSION alt_conv3 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER CONVERSION alt_conv3 SET SCHEMA alt_nsp2" +== 068 +-- truncate_limit: 100 +-- failed (not owner) +ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER CONVERSION alt_conv2 SET SCHEMA alt_nsp2" +== 069 +-- truncate_limit: 100 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 070 +-- truncate_limit: 100 +SELECT n.nspname, c.conname, a.rolname + FROM pg_conversion c, pg_namespace n, pg_authid a + WHERE c.connamespace = n.oid AND c.conowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, conname +-- +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "c"="pg_conversion" +ALIAS: "n"="pg_namespace" +FILTER: schema="" table="c" column="connamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="c" column="conowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_conversion c, pg_namespace n, pg_authid a WHERE ... ORDER BY nspname, conname" +== 071 +-- truncate_limit: 100 +|-- +-- Foreign Data Wrapper and Foreign Server +|-- +CREATE FOREIGN DATA WRAPPER alt_fdw1 +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER alt_fdw1" +== 072 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER alt_fdw2 +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER alt_fdw2" +== 073 +-- truncate_limit: 100 +CREATE SERVER alt_fserv1 FOREIGN DATA WRAPPER alt_fdw1 +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER alt_fserv1 FOREIGN DATA WRAPPER alt_fdw1" +== 074 +-- truncate_limit: 100 +CREATE SERVER alt_fserv2 FOREIGN DATA WRAPPER alt_fdw2 +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER alt_fserv2 FOREIGN DATA WRAPPER alt_fdw2" +== 075 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw2" +== 076 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER alt_fdw1 RENAME TO alt_fdw3" +== 077 +-- truncate_limit: 100 +-- OK + +ALTER SERVER alt_fserv1 RENAME TO alt_fserv2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER SERVER alt_fserv1 RENAME TO alt_fserv2" +== 078 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER SERVER alt_fserv1 RENAME TO alt_fserv3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER SERVER alt_fserv1 RENAME TO alt_fserv3" +== 079 +-- truncate_limit: 100 +-- OK + +SELECT fdwname FROM pg_foreign_data_wrapper WHERE fdwname like 'alt_fdw%' +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +FILTER: schema="" table="" column="fdwname" +STMT: SelectStmt +TRUNCATED: "SELECT fdwname FROM pg_foreign_data_wrapper WHERE fdwname LIKE 'alt_fdw%'" +== 080 +-- truncate_limit: 100 +SELECT srvname FROM pg_foreign_server WHERE srvname like 'alt_fserv%' +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +FILTER: schema="" table="" column="srvname" +STMT: SelectStmt +TRUNCATED: "SELECT srvname FROM pg_foreign_server WHERE srvname LIKE 'alt_fserv%'" +== 081 +-- truncate_limit: 100 +|-- +-- Procedural Language +|-- +CREATE LANGUAGE alt_lang1 HANDLER plpgsql_call_handler +-- +STMT: CreatePLangStmt +TRUNCATED: "CREATE LANGUAGE alt_lang1 HANDLER plpgsql_call_handler" +== 082 +-- truncate_limit: 100 +CREATE LANGUAGE alt_lang2 HANDLER plpgsql_call_handler +-- +STMT: CreatePLangStmt +TRUNCATED: "CREATE LANGUAGE alt_lang2 HANDLER plpgsql_call_handler" +== 083 +-- truncate_limit: 100 +ALTER LANGUAGE alt_lang1 OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER LANGUAGE alt_lang1 OWNER TO regress_alter_generic_user1" +== 084 +-- truncate_limit: 100 +-- OK +ALTER LANGUAGE alt_lang2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER LANGUAGE alt_lang2 OWNER TO regress_alter_generic_user2" +== 085 +-- truncate_limit: 100 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user1" +== 086 +-- truncate_limit: 100 +ALTER LANGUAGE alt_lang1 RENAME TO alt_lang2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER LANGUAGE alt_lang1 RENAME TO alt_lang2" +== 087 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER LANGUAGE alt_lang2 RENAME TO alt_lang3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER LANGUAGE alt_lang2 RENAME TO alt_lang3" +== 088 +-- truncate_limit: 100 +-- failed (not owner) +ALTER LANGUAGE alt_lang1 RENAME TO alt_lang3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER LANGUAGE alt_lang1 RENAME TO alt_lang3" +== 089 +-- truncate_limit: 100 +-- OK + +ALTER LANGUAGE alt_lang2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER LANGUAGE alt_lang2 OWNER TO regress_alter_generic_user3" +== 090 +-- truncate_limit: 100 +-- failed (not owner) +ALTER LANGUAGE alt_lang3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER LANGUAGE alt_lang3 OWNER TO regress_alter_generic_user2" +== 091 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER LANGUAGE alt_lang3 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER LANGUAGE alt_lang3 OWNER TO regress_alter_generic_user3" +== 092 +-- truncate_limit: 100 +-- OK + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 093 +-- truncate_limit: 100 +SELECT lanname, a.rolname + FROM pg_language l, pg_authid a + WHERE l.lanowner = a.oid AND l.lanname like 'alt_lang%' + ORDER BY lanname +-- +TABLE: name="pg_language" schema="" table="pg_language" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "l"="pg_language" +FILTER: schema="" table="l" column="lanowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="l" column="lanname" +STMT: SelectStmt +TRUNCATED: "SELECT lanname, a.rolname FROM pg_language l, pg_authid a WHERE ... ORDER BY lanname" +== 094 +-- truncate_limit: 100 +|-- +-- Operator +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user1" +== 095 +-- truncate_limit: 100 +CREATE OPERATOR @-@ ( leftarg = int4, rightarg = int4, procedure = int4mi ) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR @-@ (leftarg = int4, rightarg = int4, procedure = int4mi)" +== 096 +-- truncate_limit: 100 +CREATE OPERATOR @+@ ( leftarg = int4, rightarg = int4, procedure = int4pl ) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR @+@ (leftarg = int4, rightarg = int4, procedure = int4pl)" +== 097 +-- truncate_limit: 100 +ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user2" +== 098 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user3" +== 099 +-- truncate_limit: 100 +-- OK +ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2" +== 100 +-- truncate_limit: 100 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user2" +== 101 +-- truncate_limit: 100 +CREATE OPERATOR @-@ ( leftarg = int4, rightarg = int4, procedure = int4mi ) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR @-@ (leftarg = int4, rightarg = int4, procedure = int4mi)" +== 102 +-- truncate_limit: 100 +ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR @+@(int4, int4) OWNER TO regress_alter_generic_user2" +== 103 +-- truncate_limit: 100 +-- failed (not owner) +ALTER OPERATOR @-@(int4, int4) OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR @-@(int4, int4) OWNER TO regress_alter_generic_user3" +== 104 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER OPERATOR @+@(int4, int4) SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR @+@(int4, int4) SET SCHEMA alt_nsp2" +== 105 +-- truncate_limit: 100 +-- failed (not owner) +-- can't test this: the error message includes the raw oid of namespace +-- ALTER OPERATOR @-@(int4, int4) SET SCHEMA alt_nsp2; -- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 106 +-- truncate_limit: 100 +SELECT n.nspname, oprname, a.rolname, + oprleft::regtype, oprright::regtype, oprcode::regproc + FROM pg_operator o, pg_namespace n, pg_authid a + WHERE o.oprnamespace = n.oid AND o.oprowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, oprname +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "o"="pg_operator" +FILTER: schema="" table="o" column="oprnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="o" column="oprowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_operator o, pg_namespace n, pg_authid a WHERE ... ORDER BY nspname, oprname" +== 107 +-- truncate_limit: 100 +|-- +-- OpFamily and OpClass +|-- +CREATE OPERATOR FAMILY alt_opf1 USING hash +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf1 USING hash" +== 108 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf2 USING hash +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf2 USING hash" +== 109 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regress_alter_generic_user1" +== 110 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user1" +== 111 +-- truncate_limit: 100 +CREATE OPERATOR CLASS alt_opc1 FOR TYPE uuid USING hash AS STORAGE uuid +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS alt_opc1 FOR TYPE uuid USING hash AS STORAGE uuid" +== 112 +-- truncate_limit: 100 +CREATE OPERATOR CLASS alt_opc2 FOR TYPE uuid USING hash AS STORAGE uuid +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS alt_opc2 FOR TYPE uuid USING hash AS STORAGE uuid" +== 113 +-- truncate_limit: 100 +ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regress_alter_generic_user1" +== 114 +-- truncate_limit: 100 +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user1 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user1" +== 115 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user1" +== 116 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf2" +== 117 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf3" +== 118 +-- truncate_limit: 100 +-- OK +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user2" +== 119 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user3" +== 120 +-- truncate_limit: 100 +-- OK +ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2" +== 121 +-- truncate_limit: 100 +-- OK + +ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc2" +== 122 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc3" +== 123 +-- truncate_limit: 100 +-- OK +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user2" +== 124 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user3" +== 125 +-- truncate_limit: 100 +-- OK +ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2" +== 126 +-- truncate_limit: 100 +-- OK + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 127 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf1 USING hash +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf1 USING hash" +== 128 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf2 USING hash +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf2 USING hash" +== 129 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf1 USING hash OWNER TO regress_alter_generic_user2" +== 130 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user2" +== 131 +-- truncate_limit: 100 +CREATE OPERATOR CLASS alt_opc1 FOR TYPE macaddr USING hash AS STORAGE macaddr +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS alt_opc1 FOR TYPE macaddr USING hash AS STORAGE macaddr" +== 132 +-- truncate_limit: 100 +CREATE OPERATOR CLASS alt_opc2 FOR TYPE macaddr USING hash AS STORAGE macaddr +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS alt_opc2 FOR TYPE macaddr USING hash AS STORAGE macaddr" +== 133 +-- truncate_limit: 100 +ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc1 USING hash OWNER TO regress_alter_generic_user2" +== 134 +-- truncate_limit: 100 +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user2" +== 135 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user2" +== 136 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf3 USING hash RENAME TO alt_opf4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf3 USING hash RENAME TO alt_opf4" +== 137 +-- truncate_limit: 100 +-- failed (not owner) +ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf1 USING hash RENAME TO alt_opf4" +== 138 +-- truncate_limit: 100 +-- OK +ALTER OPERATOR FAMILY alt_opf3 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf3 USING hash OWNER TO regress_alter_generic_user2" +== 139 +-- truncate_limit: 100 +-- failed (not owner) +ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf2 USING hash OWNER TO regress_alter_generic_user3" +== 140 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER OPERATOR FAMILY alt_opf3 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf3 USING hash SET SCHEMA alt_nsp2" +== 141 +-- truncate_limit: 100 +-- failed (not owner) +ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf2 USING hash SET SCHEMA alt_nsp2" +== 142 +-- truncate_limit: 100 +-- failed (name conflict) + +ALTER OPERATOR CLASS alt_opc3 USING hash RENAME TO alt_opc4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc3 USING hash RENAME TO alt_opc4" +== 143 +-- truncate_limit: 100 +-- failed (not owner) +ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc1 USING hash RENAME TO alt_opc4" +== 144 +-- truncate_limit: 100 +-- OK +ALTER OPERATOR CLASS alt_opc3 USING hash OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc3 USING hash OWNER TO regress_alter_generic_user2" +== 145 +-- truncate_limit: 100 +-- failed (not owner) +ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc2 USING hash OWNER TO regress_alter_generic_user3" +== 146 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER OPERATOR CLASS alt_opc3 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc3 USING hash SET SCHEMA alt_nsp2" +== 147 +-- truncate_limit: 100 +-- failed (not owner) +ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR CLASS alt_opc2 USING hash SET SCHEMA alt_nsp2" +== 148 +-- truncate_limit: 100 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 149 +-- truncate_limit: 100 +SELECT nspname, opfname, amname, rolname + FROM pg_opfamily o, pg_am m, pg_namespace n, pg_authid a + WHERE o.opfmethod = m.oid AND o.opfnamespace = n.oid AND o.opfowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + AND NOT opfname LIKE 'alt_opc%' + ORDER BY nspname, opfname +-- +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "m"="pg_am" +ALIAS: "n"="pg_namespace" +ALIAS: "o"="pg_opfamily" +FILTER: schema="" table="o" column="opfmethod" +FILTER: schema="" table="m" column="oid" +FILTER: schema="" table="o" column="opfnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="o" column="opfowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +FILTER: schema="" table="" column="opfname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_opfamily o, pg_am m, pg_namespace n, pg_authid a WHERE ... ORDER BY nspname, o..." +== 150 +-- truncate_limit: 100 +SELECT nspname, opcname, amname, rolname + FROM pg_opclass o, pg_am m, pg_namespace n, pg_authid a + WHERE o.opcmethod = m.oid AND o.opcnamespace = n.oid AND o.opcowner = a.oid + AND n.nspname IN ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, opcname +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "m"="pg_am" +ALIAS: "n"="pg_namespace" +ALIAS: "o"="pg_opclass" +FILTER: schema="" table="o" column="opcmethod" +FILTER: schema="" table="m" column="oid" +FILTER: schema="" table="o" column="opcnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="o" column="opcowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_opclass o, pg_am m, pg_namespace n, pg_authid a WHERE ... ORDER BY nspname, op..." +== 151 +-- truncate_limit: 100 +-- ALTER OPERATOR FAMILY ... ADD/DROP + +-- Should work. Textbook case of CREATE / ALTER ADD / ALTER DROP / DROP +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 152 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf4 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf4 USING btree" +== 153 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD + -- int4 vs int2 + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 1 <(int4, int2), OPERATOR 2 <=(int4, int2..." +== 154 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf4 USING btree DROP + -- int4 vs int2 + OPERATOR 1 (int4, int2) , + OPERATOR 2 (int4, int2) , + OPERATOR 3 (int4, int2) , + OPERATOR 4 (int4, int2) , + OPERATOR 5 (int4, int2) , + FUNCTION 1 (int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING btree DROP OPERATOR 1 (int4, int2), OPERATOR 2 (int4, int2),..." +== 155 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf4 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf4 USING btree" +== 156 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 157 +-- truncate_limit: 100 +-- Should fail. Invalid values for ALTER OPERATOR FAMILY .. ADD / DROP +CREATE OPERATOR FAMILY alt_opf4 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf4 USING btree" +== 158 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf4 USING invalid_index_method ADD OPERATOR 1 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING invalid_index_method ADD OPERATOR 1 <(int4, int2)" +== 159 +-- truncate_limit: 100 +-- invalid indexing_method +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 6 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 6 <(int4, int2)" +== 160 +-- truncate_limit: 100 +-- operator number should be between 1 and 5 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 0 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 0 <(int4, int2)" +== 161 +-- truncate_limit: 100 +-- operator number should be between 1 and 5 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 1 < +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING btree ADD OPERATOR 1 <" +== 162 +-- truncate_limit: 100 +-- operator without argument types +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 0 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 0 btint42cmp(int4, int2)" +== 163 +-- truncate_limit: 100 +-- invalid options parsing function +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 6 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING btree ADD FUNCTION 6 btint42cmp(int4, int2)" +== 164 +-- truncate_limit: 100 +-- function number should be between 1 and 5 +ALTER OPERATOR FAMILY alt_opf4 USING btree ADD STORAGE invalid_storage +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf4 USING btree ADD STORAGE invalid_storage" +== 165 +-- truncate_limit: 100 +-- Ensure STORAGE is not a part of ALTER OPERATOR FAMILY +DROP OPERATOR FAMILY alt_opf4 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf4 USING btree" +== 166 +-- truncate_limit: 100 +-- Should fail. Need to be SUPERUSER to do ALTER OPERATOR FAMILY .. ADD / DROP +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 167 +-- truncate_limit: 100 +CREATE ROLE regress_alter_generic_user5 NOSUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_alter_generic_user5 WITH NOSUPERUSER" +== 168 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf5 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf5 USING btree" +== 169 +-- truncate_limit: 100 +SET ROLE regress_alter_generic_user5 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_alter_generic_user5" +== 170 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf5 USING btree ADD OPERATOR 1 < (int4, int2), FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf5 USING btree ADD OPERATOR 1 <(int4, int2), FUNCTION 1 btint42cmp(in..." +== 171 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 172 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf5 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf5 USING btree" +== 173 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 174 +-- truncate_limit: 100 +-- Should fail. Need rights to namespace for ALTER OPERATOR FAMILY .. ADD / DROP +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 175 +-- truncate_limit: 100 +CREATE ROLE regress_alter_generic_user6 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_alter_generic_user6" +== 176 +-- truncate_limit: 100 +CREATE SCHEMA alt_nsp6 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA alt_nsp6" +== 177 +-- truncate_limit: 100 +REVOKE ALL ON SCHEMA alt_nsp6 FROM regress_alter_generic_user6 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON SCHEMA alt_nsp6 FROM regress_alter_generic_user6" +== 178 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_nsp6.alt_opf6 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_nsp6.alt_opf6 USING btree" +== 179 +-- truncate_limit: 100 +SET ROLE regress_alter_generic_user6 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_alter_generic_user6" +== 180 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_nsp6.alt_opf6 USING btree ADD OPERATOR 1 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_nsp6.alt_opf6 USING btree ADD OPERATOR 1 <(int4, int2)" +== 181 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 182 +-- truncate_limit: 100 +-- Should fail. Only two arguments required for ALTER OPERATOR FAMILY ... DROP OPERATOR +CREATE OPERATOR FAMILY alt_opf7 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf7 USING btree" +== 183 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf7 USING btree ADD OPERATOR 1 < (int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf7 USING btree ADD OPERATOR 1 <(int4, int2)" +== 184 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf7 USING btree DROP OPERATOR 1 (int4, int2, int8) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf7 USING btree DROP OPERATOR 1 (int4, int2, int8)" +== 185 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf7 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf7 USING btree" +== 186 +-- truncate_limit: 100 +-- Should work. During ALTER OPERATOR FAMILY ... DROP OPERATOR +-- when left type is the same as right type, a DROP with only one argument type should work +CREATE OPERATOR FAMILY alt_opf8 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf8 USING btree" +== 187 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf8 USING btree ADD OPERATOR 1 < (int4, int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf8 USING btree ADD OPERATOR 1 <(int4, int4)" +== 188 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf8 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf8 USING btree" +== 189 +-- truncate_limit: 100 +-- Should work. Textbook case of ALTER OPERATOR FAMILY ... ADD OPERATOR with FOR ORDER BY +CREATE OPERATOR FAMILY alt_opf9 USING gist +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf9 USING gist" +== 190 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf9 USING gist ADD OPERATOR 1 < (int4, int4) FOR ORDER BY float_ops +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf9 USING gist ADD OPERATOR 1 <(int4, int4) FOR ORDER BY float_ops" +== 191 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf9 USING gist +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf9 USING gist" +== 192 +-- truncate_limit: 100 +-- Should fail. Ensure correct ordering methods in ALTER OPERATOR FAMILY ... ADD OPERATOR .. FOR ORDER BY +CREATE OPERATOR FAMILY alt_opf10 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf10 USING btree" +== 193 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf10 USING btree ADD OPERATOR 1 < (int4, int4) FOR ORDER BY float_ops +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf10 USING btree ADD OPERATOR 1 <(int4, int4) FOR ORDER BY float_ops" +== 194 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf10 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf10 USING btree" +== 195 +-- truncate_limit: 100 +-- Should work. Textbook case of ALTER OPERATOR FAMILY ... ADD OPERATOR with FOR ORDER BY +CREATE OPERATOR FAMILY alt_opf11 USING gist +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf11 USING gist" +== 196 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf11 USING gist ADD OPERATOR 1 < (int4, int4) FOR ORDER BY float_ops +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf11 USING gist ADD OPERATOR 1 <(int4, int4) FOR ORDER BY float_ops" +== 197 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf11 USING gist DROP OPERATOR 1 (int4, int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf11 USING gist DROP OPERATOR 1 (int4, int4)" +== 198 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf11 USING gist +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf11 USING gist" +== 199 +-- truncate_limit: 100 +-- Should fail. btree comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 200 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf12 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf12 USING btree" +== 201 +-- truncate_limit: 100 +CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL +-- +FUNCTION: name="fn_opf12" function="fn_opf12" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn_opf12(int4, int2) RETURNS bigint AS $$SELECT NULL::BIGINT;$$ LANGUAGE sql" +== 202 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2)" +== 203 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf12 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf12 USING btree" +== 204 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 205 +-- truncate_limit: 100 +-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 206 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf13 USING hash +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf13 USING hash" +== 207 +-- truncate_limit: 100 +CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL +-- +FUNCTION: name="fn_opf13" function="fn_opf13" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn_opf13(int4) RETURNS bigint AS $$SELECT NULL::BIGINT;$$ LANGUAGE sql" +== 208 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4)" +== 209 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf13 USING hash +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf13 USING hash" +== 210 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 211 +-- truncate_limit: 100 +-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 212 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf14 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf14 USING btree" +== 213 +-- truncate_limit: 100 +CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL +-- +FUNCTION: name="fn_opf14" function="fn_opf14" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn_opf14(int4) RETURNS bigint AS $$SELECT NULL::BIGINT;$$ LANGUAGE sql" +== 214 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4)" +== 215 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf14 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf14 USING btree" +== 216 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 217 +-- truncate_limit: 100 +-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 218 +-- truncate_limit: 100 +CREATE OPERATOR FAMILY alt_opf15 USING hash +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf15 USING hash" +== 219 +-- truncate_limit: 100 +CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL +-- +FUNCTION: name="fn_opf15" function="fn_opf15" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn_opf15(int4, int2) RETURNS bigint AS $$SELECT NULL::BIGINT;$$ LANGUAGE sql" +== 220 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2)" +== 221 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf15 USING hash +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf15 USING hash" +== 222 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 223 +-- truncate_limit: 100 +-- Should fail. In gist throw an error when giving different data types for function argument +-- without defining left / right type in ALTER OPERATOR FAMILY ... ADD FUNCTION +CREATE OPERATOR FAMILY alt_opf16 USING gist +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf16 USING gist" +== 224 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf16 USING gist ADD FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf16 USING gist ADD FUNCTION 1 btint42cmp(int4, int2)" +== 225 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf16 USING gist +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf16 USING gist" +== 226 +-- truncate_limit: 100 +-- Should fail. duplicate operator number / function number in ALTER OPERATOR FAMILY ... ADD FUNCTION +CREATE OPERATOR FAMILY alt_opf17 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf17 USING btree" +== 227 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 < (int4, int4), OPERATOR 1 < (int4, int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 <(int4, int4), OPERATOR 1 <(int4, int4)" +== 228 +-- truncate_limit: 100 +-- operator # appears twice in same statement +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 < (int4, int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 <(int4, int4)" +== 229 +-- truncate_limit: 100 +-- operator 1 requested first-time +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 < (int4, int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 <(int4, int4)" +== 230 +-- truncate_limit: 100 +-- operator 1 requested again in separate statement +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 <(int4, int2), OPERATOR 2 <=(int4, int..." +== 231 +-- truncate_limit: 100 +-- procedure 1 appears twice in same statement +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 <(int4, int2), OPERATOR 2 <=(int4, int..." +== 232 +-- truncate_limit: 100 +-- procedure 1 appears first time +ALTER OPERATOR FAMILY alt_opf17 USING btree ADD + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf17 USING btree ADD OPERATOR 1 <(int4, int2), OPERATOR 2 <=(int4, int..." +== 233 +-- truncate_limit: 100 +-- procedure 1 requested again in separate statement +DROP OPERATOR FAMILY alt_opf17 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf17 USING btree" +== 234 +-- truncate_limit: 100 +-- Should fail. Ensure that DROP requests for missing OPERATOR / FUNCTIONS +-- return appropriate message in ALTER OPERATOR FAMILY ... DROP OPERATOR / FUNCTION +CREATE OPERATOR FAMILY alt_opf18 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf18 USING btree" +== 235 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf18 USING btree DROP OPERATOR 1 (int4, int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf18 USING btree DROP OPERATOR 1 (int4, int4)" +== 236 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf18 USING btree ADD + OPERATOR 1 < (int4, int2) , + OPERATOR 2 <= (int4, int2) , + OPERATOR 3 = (int4, int2) , + OPERATOR 4 >= (int4, int2) , + OPERATOR 5 > (int4, int2) , + FUNCTION 1 btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf18 USING btree ADD OPERATOR 1 <(int4, int2), OPERATOR 2 <=(int4, int..." +== 237 +-- truncate_limit: 100 +-- Should fail. Not allowed to have cross-type equalimage function. +ALTER OPERATOR FAMILY alt_opf18 USING btree + ADD FUNCTION 4 (int4, int2) btequalimage(oid) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf18 USING btree ADD FUNCTION 4 (int4, int2) btequalimage(oid)" +== 238 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf18 USING btree DROP FUNCTION 2 (int4, int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf18 USING btree DROP FUNCTION 2 (int4, int4)" +== 239 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf18 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf18 USING btree" +== 240 +-- truncate_limit: 100 +-- Should fail. Invalid opclass options function (#5) specifications. +CREATE OPERATOR FAMILY alt_opf19 USING btree +-- +STMT: CreateOpFamilyStmt +TRUNCATED: "CREATE OPERATOR FAMILY alt_opf19 USING btree" +== 241 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 test_opclass_options_func(internal, text[], bool) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 test_opclass_options_func(internal, te..." +== 242 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) btint42cmp(int4, int2)" +== 243 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4, int2) btint42cmp(int4, int2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4, int2) btint42cmp(int4, int2)" +== 244 +-- truncate_limit: 100 +ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) test_opclass_options_func(internal) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf19 USING btree ADD FUNCTION 5 (int4) test_opclass_options_func(inter..." +== 245 +-- truncate_limit: 100 +-- Ok +ALTER OPERATOR FAMILY alt_opf19 USING btree DROP FUNCTION 5 (int4, int4) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY alt_opf19 USING btree DROP FUNCTION 5 (int4, int4)" +== 246 +-- truncate_limit: 100 +DROP OPERATOR FAMILY alt_opf19 USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY alt_opf19 USING btree" +== 247 +-- truncate_limit: 100 +|-- +-- Statistics +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user1" +== 248 +-- truncate_limit: 100 +CREATE TABLE alt_regress_1 (a INTEGER, b INTEGER) +-- +TABLE: name="alt_regress_1" schema="" table="alt_regress_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alt_regress_1 (a int, b int)" +== 249 +-- truncate_limit: 100 +CREATE STATISTICS alt_stat1 ON a, b FROM alt_regress_1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS alt_stat1 ON a, b FROM alt_regress_1" +== 250 +-- truncate_limit: 100 +CREATE STATISTICS alt_stat2 ON a, b FROM alt_regress_1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS alt_stat2 ON a, b FROM alt_regress_1" +== 251 +-- truncate_limit: 100 +ALTER STATISTICS alt_stat1 RENAME TO alt_stat2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER STATISTICS alt_stat1 RENAME TO alt_stat2" +== 252 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER STATISTICS alt_stat1 RENAME TO alt_stat3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER STATISTICS alt_stat1 RENAME TO alt_stat3" +== 253 +-- truncate_limit: 100 +-- OK +ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user2" +== 254 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user3" +== 255 +-- truncate_limit: 100 +-- OK +ALTER STATISTICS alt_stat2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER STATISTICS alt_stat2 SET SCHEMA alt_nsp2" +== 256 +-- truncate_limit: 100 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user2" +== 257 +-- truncate_limit: 100 +CREATE TABLE alt_regress_2 (a INTEGER, b INTEGER) +-- +TABLE: name="alt_regress_2" schema="" table="alt_regress_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alt_regress_2 (a int, b int)" +== 258 +-- truncate_limit: 100 +CREATE STATISTICS alt_stat1 ON a, b FROM alt_regress_2 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS alt_stat1 ON a, b FROM alt_regress_2" +== 259 +-- truncate_limit: 100 +CREATE STATISTICS alt_stat2 ON a, b FROM alt_regress_2 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS alt_stat2 ON a, b FROM alt_regress_2" +== 260 +-- truncate_limit: 100 +ALTER STATISTICS alt_stat3 RENAME TO alt_stat4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER STATISTICS alt_stat3 RENAME TO alt_stat4" +== 261 +-- truncate_limit: 100 +-- failed (not owner) +ALTER STATISTICS alt_stat1 RENAME TO alt_stat4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER STATISTICS alt_stat1 RENAME TO alt_stat4" +== 262 +-- truncate_limit: 100 +-- OK +ALTER STATISTICS alt_stat3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER STATISTICS alt_stat3 OWNER TO regress_alter_generic_user2" +== 263 +-- truncate_limit: 100 +-- failed (not owner) +ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER STATISTICS alt_stat2 OWNER TO regress_alter_generic_user3" +== 264 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER STATISTICS alt_stat3 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER STATISTICS alt_stat3 SET SCHEMA alt_nsp2" +== 265 +-- truncate_limit: 100 +-- failed (not owner) +ALTER STATISTICS alt_stat2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER STATISTICS alt_stat2 SET SCHEMA alt_nsp2" +== 266 +-- truncate_limit: 100 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 267 +-- truncate_limit: 100 +SELECT nspname, stxname, rolname + FROM pg_statistic_ext s, pg_namespace n, pg_authid a + WHERE s.stxnamespace = n.oid AND s.stxowner = a.oid + AND n.nspname in ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, stxname +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="s" column="stxowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_statistic_ext s, pg_namespace n, pg_authid a WHERE ... ORDER BY nspname, stxname" +== 268 +-- truncate_limit: 100 +|-- +-- Text Search Dictionary +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user1" +== 269 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template = simple)" +== 270 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template=simple) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template = simple)" +== 271 +-- truncate_limit: 100 +ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict2" +== 272 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict3" +== 273 +-- truncate_limit: 100 +-- OK +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user2" +== 274 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user3" +== 275 +-- truncate_limit: 100 +-- OK +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2" +== 276 +-- truncate_limit: 100 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user2" +== 277 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template=simple) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY alt_ts_dict1 (template = simple)" +== 278 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template=simple) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY alt_ts_dict2 (template = simple)" +== 279 +-- truncate_limit: 100 +ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 RENAME TO alt_ts_dict4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 RENAME TO alt_ts_dict4" +== 280 +-- truncate_limit: 100 +-- failed (not owner) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 RENAME TO alt_ts_dict4" +== 281 +-- truncate_limit: 100 +-- OK +ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 OWNER TO regress_alter_generic_user2" +== 282 +-- truncate_limit: 100 +-- failed (not owner) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 OWNER TO regress_alter_generic_user3" +== 283 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict3 SET SCHEMA alt_nsp2" +== 284 +-- truncate_limit: 100 +-- failed (not owner) +ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alt_ts_dict2 SET SCHEMA alt_nsp2" +== 285 +-- truncate_limit: 100 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 286 +-- truncate_limit: 100 +SELECT nspname, dictname, rolname + FROM pg_ts_dict t, pg_namespace n, pg_authid a + WHERE t.dictnamespace = n.oid AND t.dictowner = a.oid + AND n.nspname in ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, dictname +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "t"="pg_ts_dict" +FILTER: schema="" table="t" column="dictnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="t" column="dictowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_ts_dict t, pg_namespace n, pg_authid a WHERE ... ORDER BY nspname, dictname" +== 287 +-- truncate_limit: 100 +|-- +-- Text Search Configuration +|-- +SET SESSION AUTHORIZATION regress_alter_generic_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user1" +== 288 +-- truncate_limit: 100 +CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy=english) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy = english)" +== 289 +-- truncate_limit: 100 +CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy=english) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy = english)" +== 290 +-- truncate_limit: 100 +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf2" +== 291 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf3" +== 292 +-- truncate_limit: 100 +-- OK +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user2" +== 293 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user3" +== 294 +-- truncate_limit: 100 +-- OK +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2" +== 295 +-- truncate_limit: 100 +-- OK + +SET SESSION AUTHORIZATION regress_alter_generic_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_generic_user2" +== 296 +-- truncate_limit: 100 +CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy=english) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION alt_ts_conf1 (copy = english)" +== 297 +-- truncate_limit: 100 +CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy=english) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION alt_ts_conf2 (copy = english)" +== 298 +-- truncate_limit: 100 +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 RENAME TO alt_ts_conf4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 RENAME TO alt_ts_conf4" +== 299 +-- truncate_limit: 100 +-- failed (not owner) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf4 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 RENAME TO alt_ts_conf4" +== 300 +-- truncate_limit: 100 +-- OK +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 OWNER TO regress_alter_generic_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 OWNER TO regress_alter_generic_user2" +== 301 +-- truncate_limit: 100 +-- failed (not owner) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 OWNER TO regress_alter_generic_user3" +== 302 +-- truncate_limit: 100 +-- failed (no role membership) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf3 SET SCHEMA alt_nsp2" +== 303 +-- truncate_limit: 100 +-- failed (not owner) +ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alt_ts_conf2 SET SCHEMA alt_nsp2" +== 304 +-- truncate_limit: 100 +-- failed (name conflict) + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 305 +-- truncate_limit: 100 +SELECT nspname, cfgname, rolname + FROM pg_ts_config t, pg_namespace n, pg_authid a + WHERE t.cfgnamespace = n.oid AND t.cfgowner = a.oid + AND n.nspname in ('alt_nsp1', 'alt_nsp2') + ORDER BY nspname, cfgname +-- +TABLE: name="pg_ts_config" schema="" table="pg_ts_config" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +ALIAS: "a"="pg_authid" +ALIAS: "n"="pg_namespace" +ALIAS: "t"="pg_ts_config" +FILTER: schema="" table="t" column="cfgnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="t" column="cfgowner" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_ts_config t, pg_namespace n, pg_authid a WHERE ... ORDER BY nspname, cfgname" +== 306 +-- truncate_limit: 100 +|-- +-- Text Search Template +|-- +CREATE TEXT SEARCH TEMPLATE alt_ts_temp1 (lexize=dsimple_lexize) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH TEMPLATE alt_ts_temp1 (lexize = dsimple_lexize)" +== 307 +-- truncate_limit: 100 +CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize=dsimple_lexize) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize = dsimple_lexize)" +== 308 +-- truncate_limit: 100 +ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp2" +== 309 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH TEMPLATE alt_ts_temp1 RENAME TO alt_ts_temp3" +== 310 +-- truncate_limit: 100 +-- OK +ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2" +== 311 +-- truncate_limit: 100 +-- OK + +CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize=dsimple_lexize) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH TEMPLATE alt_ts_temp2 (lexize = dsimple_lexize)" +== 312 +-- truncate_limit: 100 +ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH TEMPLATE alt_ts_temp2 SET SCHEMA alt_nsp2" +== 313 +-- truncate_limit: 100 +-- failed (name conflict) + +-- invalid: non-lowercase quoted identifiers +CREATE TEXT SEARCH TEMPLATE tstemp_case ("Init" = init_function) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH TEMPLATE tstemp_case (\"Init\" = init_function)" +== 314 +-- truncate_limit: 100 +SELECT nspname, tmplname + FROM pg_ts_template t, pg_namespace n + WHERE t.tmplnamespace = n.oid AND nspname like 'alt_nsp%' + ORDER BY nspname, tmplname +-- +TABLE: name="pg_ts_template" schema="" table="pg_ts_template" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "n"="pg_namespace" +ALIAS: "t"="pg_ts_template" +FILTER: schema="" table="t" column="tmplnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT nspname, tmplname FROM pg_ts_template t, pg_namespace n WHERE ... ORDER BY nspname, tmplname" +== 315 +-- truncate_limit: 100 +|-- +-- Text Search Parser +|-- + +CREATE TEXT SEARCH PARSER alt_ts_prs1 + (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH PARSER alt_ts_prs1 (start = prsd_start, gettoken = prsd_nexttoken, \"end\" = prs..." +== 316 +-- truncate_limit: 100 +CREATE TEXT SEARCH PARSER alt_ts_prs2 + (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH PARSER alt_ts_prs2 (start = prsd_start, gettoken = prsd_nexttoken, \"end\" = prs..." +== 317 +-- truncate_limit: 100 +ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs2" +== 318 +-- truncate_limit: 100 +-- failed (name conflict) +ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TEXT SEARCH PARSER alt_ts_prs1 RENAME TO alt_ts_prs3" +== 319 +-- truncate_limit: 100 +-- OK +ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2" +== 320 +-- truncate_limit: 100 +-- OK + +CREATE TEXT SEARCH PARSER alt_ts_prs2 + (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH PARSER alt_ts_prs2 (start = prsd_start, gettoken = prsd_nexttoken, \"end\" = prs..." +== 321 +-- truncate_limit: 100 +ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH PARSER alt_ts_prs2 SET SCHEMA alt_nsp2" +== 322 +-- truncate_limit: 100 +-- failed (name conflict) + +-- invalid: non-lowercase quoted identifiers +CREATE TEXT SEARCH PARSER tspars_case ("Start" = start_function) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH PARSER tspars_case (\"Start\" = start_function)" +== 323 +-- truncate_limit: 100 +SELECT nspname, prsname + FROM pg_ts_parser t, pg_namespace n + WHERE t.prsnamespace = n.oid AND nspname like 'alt_nsp%' + ORDER BY nspname, prsname +-- +TABLE: name="pg_ts_parser" schema="" table="pg_ts_parser" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "n"="pg_namespace" +ALIAS: "t"="pg_ts_parser" +FILTER: schema="" table="t" column="prsnamespace" +FILTER: schema="" table="n" column="oid" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT nspname, prsname FROM pg_ts_parser t, pg_namespace n WHERE ... ORDER BY nspname, prsname" +== 324 +-- truncate_limit: 100 +--- +--- Cleanup resources +--- +DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE" +== 325 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE" +== 326 +-- truncate_limit: 100 +DROP LANGUAGE alt_lang2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP LANGUAGE alt_lang2 CASCADE" +== 327 +-- truncate_limit: 100 +DROP LANGUAGE alt_lang3 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP LANGUAGE alt_lang3 CASCADE" +== 328 +-- truncate_limit: 100 +DROP SCHEMA alt_nsp1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA alt_nsp1 CASCADE" +== 329 +-- truncate_limit: 100 +DROP SCHEMA alt_nsp2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA alt_nsp2 CASCADE" +== 330 +-- truncate_limit: 100 +DROP USER regress_alter_generic_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_alter_generic_user1" +== 331 +-- truncate_limit: 100 +DROP USER regress_alter_generic_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_alter_generic_user2" +== 332 +-- truncate_limit: 100 +DROP USER regress_alter_generic_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_alter_generic_user3" diff --git a/parser/testdata/summary_truncate/postgres_regress/alter_operator.metadata.json b/parser/testdata/summary_truncate/postgres_regress/alter_operator.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/alter_operator.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/alter_operator.test b/parser/testdata/summary_truncate/postgres_regress/alter_operator.test new file mode 100644 index 0000000..0a3035d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/alter_operator.test @@ -0,0 +1,582 @@ +== 001 +-- truncate_limit: 100 +CREATE FUNCTION alter_op_test_fn(boolean, boolean) +RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="alter_op_test_fn" function="alter_op_test_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alter_op_test_fn(boolean, boolean) RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$..." +== 002 +-- truncate_limit: 100 +CREATE FUNCTION customcontsel(internal, oid, internal, integer) +RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT +-- +FUNCTION: name="customcontsel" function="customcontsel" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION customcontsel(internal, oid, internal, int) RETURNS float8 AS $$contsel$$ LANGUAG..." +== 003 +-- truncate_limit: 100 +CREATE OPERATOR === ( + LEFTARG = boolean, + RIGHTARG = boolean, + PROCEDURE = alter_op_test_fn, + COMMUTATOR = ===, + NEGATOR = !==, + RESTRICT = customcontsel, + JOIN = contjoinsel, + HASHES, MERGES +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (leftarg = boolean, rightarg = boolean, procedure = alter_op_test_fn, commuta..." +== 004 +-- truncate_limit: 100 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1" +== 005 +-- truncate_limit: 100 +|-- +-- Test resetting and setting restrict and join attributes. +|-- + +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (restrict = NONE)" +== 006 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, boolean) SET (JOIN = NONE) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (\"join\" = NONE)" +== 007 +-- truncate_limit: 100 +SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT oprrest, oprjoin FROM pg_operator WHERE ..." +== 008 +-- truncate_limit: 100 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1" +== 009 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = contsel) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (restrict = contsel)" +== 010 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, boolean) SET (JOIN = contjoinsel) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (\"join\" = contjoinsel)" +== 011 +-- truncate_limit: 100 +SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT oprrest, oprjoin FROM pg_operator WHERE ..." +== 012 +-- truncate_limit: 100 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1" +== 013 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE, JOIN = NONE) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (restrict = NONE, \"join\" = NONE)" +== 014 +-- truncate_limit: 100 +SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT oprrest, oprjoin FROM pg_operator WHERE ..." +== 015 +-- truncate_limit: 100 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1" +== 016 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = customcontsel, JOIN = contjoinsel) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (restrict = customcontsel, \"join\" = contjoinsel)" +== 017 +-- truncate_limit: 100 +SELECT oprrest, oprjoin FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT oprrest, oprjoin FROM pg_operator WHERE ..." +== 018 +-- truncate_limit: 100 +SELECT pg_describe_object(refclassid,refobjid,refobjsubid) as ref, deptype +FROM pg_depend +WHERE classid = 'pg_operator'::regclass AND + objid = '===(bool,bool)'::regoperator +ORDER BY 1 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1" +== 019 +-- truncate_limit: 100 +|-- +-- Test invalid options. +|-- +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = non_existent_func) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (restrict = non_existent_func)" +== 020 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, boolean) SET (JOIN = non_existent_func) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (\"join\" = non_existent_func)" +== 021 +-- truncate_limit: 100 +-- invalid: non-lowercase quoted identifiers +ALTER OPERATOR & (bit, bit) SET ("Restrict" = _int_contsel, "Join" = _int_contjoinsel) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR &(pg_catalog.bit(1), pg_catalog.bit(1)) SET (\"Restrict\" = _int_contsel, \"Join\" = _..." +== 022 +-- truncate_limit: 100 +|-- +-- Test permission check. Must be owner to ALTER OPERATOR. +|-- +CREATE USER regress_alter_op_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_alter_op_user" +== 023 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_alter_op_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alter_op_user" +== 024 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, boolean) SET (restrict = NONE)" +== 025 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 026 +-- truncate_limit: 100 +|-- +-- Test setting commutator, negator, merges, and hashes attributes, +-- which can only be set if not already set +|-- + +CREATE FUNCTION alter_op_test_fn_bool_real(boolean, real) +RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="alter_op_test_fn_bool_real" function="alter_op_test_fn_bool_real" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alter_op_test_fn_bool_real(boolean, real) RETURNS boolean AS $$ SELECT NULL::BOOL..." +== 027 +-- truncate_limit: 100 +CREATE FUNCTION alter_op_test_fn_real_bool(real, boolean) +RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="alter_op_test_fn_real_bool" function="alter_op_test_fn_real_bool" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alter_op_test_fn_real_bool(real, boolean) RETURNS boolean AS $$ SELECT NULL::BOOL..." +== 028 +-- truncate_limit: 100 +-- operator +CREATE OPERATOR === ( + LEFTARG = boolean, + RIGHTARG = real, + PROCEDURE = alter_op_test_fn_bool_real +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (leftarg = boolean, rightarg = real, procedure = alter_op_test_fn_bool_real)" +== 029 +-- truncate_limit: 100 +-- commutator +CREATE OPERATOR ==== ( + LEFTARG = real, + RIGHTARG = boolean, + PROCEDURE = alter_op_test_fn_real_bool +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR ==== (leftarg = real, rightarg = boolean, procedure = alter_op_test_fn_real_bool)" +== 030 +-- truncate_limit: 100 +-- negator +CREATE OPERATOR !==== ( + LEFTARG = boolean, + RIGHTARG = real, + PROCEDURE = alter_op_test_fn_bool_real +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR !==== (leftarg = boolean, rightarg = real, procedure = alter_op_test_fn_bool_real)" +== 031 +-- truncate_limit: 100 +-- No-op setting already false hashes and merges to false works +ALTER OPERATOR === (boolean, real) SET (MERGES = false) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (merges = false)" +== 032 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (HASHES = false) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (hashes = false)" +== 033 +-- truncate_limit: 100 +-- Test setting merges and hashes +ALTER OPERATOR === (boolean, real) SET (MERGES) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (merges = NONE)" +== 034 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (HASHES) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (hashes = NONE)" +== 035 +-- truncate_limit: 100 +SELECT oprcanmerge, oprcanhash +FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT oprcanmerge, oprcanhash FROM pg_operator WHERE ..." +== 036 +-- truncate_limit: 100 +-- Test setting commutator +ALTER OPERATOR === (boolean, real) SET (COMMUTATOR = ====) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (commutator = ====)" +== 037 +-- truncate_limit: 100 +-- Check that oprcom has been set on both the operator and commutator, +-- that they reference each other, and that the operator used is the existing +-- one we created and not a new shell operator. +SELECT op.oprname AS operator_name, com.oprname AS commutator_name, + com.oprcode AS commutator_func + FROM pg_operator op + INNER JOIN pg_operator com ON (op.oid = com.oprcom AND op.oprcom = com.oid) + WHERE op.oprname = '===' + AND op.oprleft = 'boolean'::regtype AND op.oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "com"="pg_operator" +ALIAS: "op"="pg_operator" +FILTER: schema="" table="op" column="oprname" +FILTER: schema="" table="op" column="oprleft" +FILTER: schema="" table="op" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_operator op JOIN pg_operator com ON op.oid = com.oprcom AND op.oprcom = com.oi..." +== 038 +-- truncate_limit: 100 +-- Cannot set self as negator +ALTER OPERATOR === (boolean, real) SET (NEGATOR = ===) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (negator = ===)" +== 039 +-- truncate_limit: 100 +-- Test setting negator +ALTER OPERATOR === (boolean, real) SET (NEGATOR = !====) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (negator = !====)" +== 040 +-- truncate_limit: 100 +-- Check that oprnegate has been set on both the operator and negator, +-- that they reference each other, and that the operator used is the existing +-- one we created and not a new shell operator. +SELECT op.oprname AS operator_name, neg.oprname AS negator_name, + neg.oprcode AS negator_func + FROM pg_operator op + INNER JOIN pg_operator neg ON (op.oid = neg.oprnegate AND op.oprnegate = neg.oid) + WHERE op.oprname = '===' + AND op.oprleft = 'boolean'::regtype AND op.oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "neg"="pg_operator" +ALIAS: "op"="pg_operator" +FILTER: schema="" table="op" column="oprname" +FILTER: schema="" table="op" column="oprleft" +FILTER: schema="" table="op" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_operator op JOIN pg_operator neg ON op.oid = neg.oprnegate AND op.oprnegate = ..." +== 041 +-- truncate_limit: 100 +-- Test that no-op set succeeds +ALTER OPERATOR === (boolean, real) SET (NEGATOR = !====) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (negator = !====)" +== 042 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (COMMUTATOR = ====) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (commutator = ====)" +== 043 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (MERGES) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (merges = NONE)" +== 044 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (HASHES) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (hashes = NONE)" +== 045 +-- truncate_limit: 100 +-- Check that the final state of the operator is as we expect +SELECT oprcanmerge, oprcanhash, + pg_describe_object('pg_operator'::regclass, oprcom, 0) AS commutator, + pg_describe_object('pg_operator'::regclass, oprnegate, 0) AS negator + FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_operator WHERE ..." +== 046 +-- truncate_limit: 100 +-- Cannot change commutator, negator, merges, and hashes when already set + +CREATE OPERATOR @= ( + LEFTARG = real, + RIGHTARG = boolean, + PROCEDURE = alter_op_test_fn_real_bool +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR @= (leftarg = real, rightarg = boolean, procedure = alter_op_test_fn_real_bool)" +== 047 +-- truncate_limit: 100 +CREATE OPERATOR @!= ( + LEFTARG = boolean, + RIGHTARG = real, + PROCEDURE = alter_op_test_fn_bool_real +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR @!= (leftarg = boolean, rightarg = real, procedure = alter_op_test_fn_bool_real)" +== 048 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (COMMUTATOR = @=) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (commutator = @=)" +== 049 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (NEGATOR = @!=) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (negator = @!=)" +== 050 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (MERGES = false) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (merges = false)" +== 051 +-- truncate_limit: 100 +ALTER OPERATOR === (boolean, real) SET (HASHES = false) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR ===(boolean, real) SET (hashes = false)" +== 052 +-- truncate_limit: 100 +-- Cannot set an operator that already has a commutator as the commutator +ALTER OPERATOR @=(real, boolean) SET (COMMUTATOR = ===) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR @=(real, boolean) SET (commutator = ===)" +== 053 +-- truncate_limit: 100 +-- Cannot set an operator that already has a negator as the negator +ALTER OPERATOR @!=(boolean, real) SET (NEGATOR = ===) +-- +STMT: AlterOperatorStmt +TRUNCATED: "ALTER OPERATOR @!=(boolean, real) SET (negator = ===)" +== 054 +-- truncate_limit: 100 +-- Check no changes made +SELECT oprcanmerge, oprcanhash, + pg_describe_object('pg_operator'::regclass, oprcom, 0) AS commutator, + pg_describe_object('pg_operator'::regclass, oprnegate, 0) AS negator + FROM pg_operator WHERE oprname = '===' + AND oprleft = 'boolean'::regtype AND oprright = 'real'::regtype +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="oprname" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_operator WHERE ..." +== 055 +-- truncate_limit: 100 +|-- +-- Clean up +|-- + +DROP USER regress_alter_op_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_alter_op_user" +== 056 +-- truncate_limit: 100 +DROP OPERATOR === (boolean, boolean) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ===(boolean, boolean)" +== 057 +-- truncate_limit: 100 +DROP OPERATOR === (boolean, real) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ===(boolean, real)" +== 058 +-- truncate_limit: 100 +DROP OPERATOR ==== (real, boolean) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ====(real, boolean)" +== 059 +-- truncate_limit: 100 +DROP OPERATOR !==== (boolean, real) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR !====(boolean, real)" +== 060 +-- truncate_limit: 100 +DROP OPERATOR @= (real, boolean) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR @=(real, boolean)" +== 061 +-- truncate_limit: 100 +DROP OPERATOR @!= (boolean, real) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR @!=(boolean, real)" +== 062 +-- truncate_limit: 100 +DROP FUNCTION customcontsel(internal, oid, internal, integer) +-- +FUNCTION: name="customcontsel" function="customcontsel" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION customcontsel(internal, oid, internal, int)" +== 063 +-- truncate_limit: 100 +DROP FUNCTION alter_op_test_fn(boolean, boolean) +-- +FUNCTION: name="alter_op_test_fn" function="alter_op_test_fn" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION alter_op_test_fn(boolean, boolean)" +== 064 +-- truncate_limit: 100 +DROP FUNCTION alter_op_test_fn_bool_real(boolean, real) +-- +FUNCTION: name="alter_op_test_fn_bool_real" function="alter_op_test_fn_bool_real" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION alter_op_test_fn_bool_real(boolean, real)" +== 065 +-- truncate_limit: 100 +DROP FUNCTION alter_op_test_fn_real_bool(real, boolean) +-- +FUNCTION: name="alter_op_test_fn_real_bool" function="alter_op_test_fn_real_bool" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION alter_op_test_fn_real_bool(real, boolean)" diff --git a/parser/testdata/summary_truncate/postgres_regress/alter_table.metadata.json b/parser/testdata/summary_truncate/postgres_regress/alter_table.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/alter_table.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/alter_table.test b/parser/testdata/summary_truncate/postgres_regress/alter_table.test new file mode 100644 index 0000000..d594340 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/alter_table.test @@ -0,0 +1,12806 @@ +== 001 +-- truncate_limit: 100 +|-- +-- ALTER_TABLE +|-- + +-- Clean up in case a prior regression run failed +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 002 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_alter_table_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_alter_table_user1" +== 003 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 004 +-- truncate_limit: 100 +CREATE USER regress_alter_table_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_alter_table_user1" +== 005 +-- truncate_limit: 100 +|-- +-- add attribute +|-- + +CREATE TABLE attmp (initial int4) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp (initial int4)" +== 006 +-- truncate_limit: 100 +COMMENT ON TABLE attmp_wrong IS 'table comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TABLE attmp_wrong IS 'table comment'" +== 007 +-- truncate_limit: 100 +COMMENT ON TABLE attmp IS 'table comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TABLE attmp IS 'table comment'" +== 008 +-- truncate_limit: 100 +COMMENT ON TABLE attmp IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TABLE attmp IS NULL" +== 009 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN xmin integer +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN xmin int" +== 010 +-- truncate_limit: 100 +-- fails + +ALTER TABLE attmp ADD COLUMN a int4 default 3 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN a int4 DEFAULT 3" +== 011 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN b name +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN b name" +== 012 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN c text +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN c text" +== 013 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN d float8 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN d float8" +== 014 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN e float4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN e float4" +== 015 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN f int2 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN f int2" +== 016 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN g polygon +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN g polygon" +== 017 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN i char +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN i char(1)" +== 018 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN k int4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN k int4" +== 019 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN l tid +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN l tid" +== 020 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN m xid +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN m xid" +== 021 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN n oidvector +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN n oidvector" +== 022 +-- truncate_limit: 100 +--ALTER TABLE attmp ADD COLUMN o lock; +ALTER TABLE attmp ADD COLUMN p boolean +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN p boolean" +== 023 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN q point +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN q point" +== 024 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN r lseg +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN r lseg" +== 025 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN s path +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN s path" +== 026 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN t box +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN t box" +== 027 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN v timestamp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN v timestamp" +== 028 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN w interval +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN w interval" +== 029 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN x float8[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN x float8[]" +== 030 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN y float4[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN y float4[]" +== 031 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN z int2[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN z int2[]" +== 032 +-- truncate_limit: 100 +INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t, + v, w, x, y, z) + VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)', + 'c', + 314159, '(1,1)', '512', + '1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)', + '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', + 'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}') +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t, v, w, x, y, z) VALUES (...)" +== 033 +-- truncate_limit: 100 +SELECT * FROM attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attmp" +== 034 +-- truncate_limit: 100 +DROP TABLE attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp" +== 035 +-- truncate_limit: 100 +-- the wolf bug - schema mods caused inconsistent row descriptors +CREATE TABLE attmp ( + initial int4 +) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp (initial int4)" +== 036 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN a int4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN a int4" +== 037 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN b name +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN b name" +== 038 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN c text +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN c text" +== 039 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN d float8 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN d float8" +== 040 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN e float4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN e float4" +== 041 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN f int2 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN f int2" +== 042 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN g polygon +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN g polygon" +== 043 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN i char +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN i char(1)" +== 044 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN k int4 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN k int4" +== 045 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN l tid +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN l tid" +== 046 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN m xid +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN m xid" +== 047 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN n oidvector +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN n oidvector" +== 048 +-- truncate_limit: 100 +--ALTER TABLE attmp ADD COLUMN o lock; +ALTER TABLE attmp ADD COLUMN p boolean +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN p boolean" +== 049 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN q point +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN q point" +== 050 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN r lseg +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN r lseg" +== 051 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN s path +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN s path" +== 052 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN t box +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN t box" +== 053 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN v timestamp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN v timestamp" +== 054 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN w interval +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN w interval" +== 055 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN x float8[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN x float8[]" +== 056 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN y float4[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN y float4[]" +== 057 +-- truncate_limit: 100 +ALTER TABLE attmp ADD COLUMN z int2[] +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ADD COLUMN z int2[]" +== 058 +-- truncate_limit: 100 +INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t, + v, w, x, y, z) + VALUES (4, 'name', 'text', 4.1, 4.1, 2, '(4.1,4.1,3.1,3.1)', + 'c', + 314159, '(1,1)', '512', + '1 2 3 4 5 6 7 8', true, '(1.1,1.1)', '(4.1,4.1,3.1,3.1)', + '(0,2,4.1,4.1,3.1,3.1)', '(4.1,4.1,3.1,3.1)', + 'epoch', '01:00:10', '{1.0,2.0,3.0,4.0}', '{1.0,2.0,3.0,4.0}', '{1,2,3,4}') +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp (a, b, c, d, e, f, g, i, k, l, m, n, p, q, r, s, t, v, w, x, y, z) VALUES (...)" +== 059 +-- truncate_limit: 100 +SELECT * FROM attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attmp" +== 060 +-- truncate_limit: 100 +CREATE INDEX attmp_idx ON attmp (a, (d + e), b) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX attmp_idx ON attmp USING btree (a, (d + e), b)" +== 061 +-- truncate_limit: 100 +ALTER INDEX attmp_idx ALTER COLUMN 0 SET STATISTICS 1000 +-- +ERROR: column number must be in range from 1 to 32767 +CURSORPOS: 36 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 062 +-- truncate_limit: 100 +ALTER INDEX attmp_idx ALTER COLUMN 1 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX attmp_idx ALTER COLUMN 1 SET STATISTICS 1000" +== 063 +-- truncate_limit: 100 +ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS 1000" +== 064 +-- truncate_limit: 100 +ALTER INDEX attmp_idx ALTER COLUMN 3 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX attmp_idx ALTER COLUMN 3 SET STATISTICS 1000" +== 065 +-- truncate_limit: 100 +ALTER INDEX attmp_idx ALTER COLUMN 4 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX attmp_idx ALTER COLUMN 4 SET STATISTICS 1000" +== 066 +-- truncate_limit: 100 +ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS -1 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX attmp_idx ALTER COLUMN 2 SET STATISTICS -1" +== 067 +-- truncate_limit: 100 +DROP TABLE attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp" +== 068 +-- truncate_limit: 100 +|-- +-- rename - check on both non-temp and temp tables +|-- +CREATE TABLE attmp (regtable int) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp (regtable int)" +== 069 +-- truncate_limit: 100 +CREATE TEMP TABLE attmp (attmptable int) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE attmp (attmptable int)" +== 070 +-- truncate_limit: 100 +ALTER TABLE attmp RENAME TO attmp_new +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +TABLE: name="attmp_new" schema="" table="attmp_new" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE attmp RENAME TO attmp_new" +== 071 +-- truncate_limit: 100 +SELECT * FROM attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attmp" +== 072 +-- truncate_limit: 100 +SELECT * FROM attmp_new +-- +TABLE: name="attmp_new" schema="" table="attmp_new" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attmp_new" +== 073 +-- truncate_limit: 100 +ALTER TABLE attmp RENAME TO attmp_new2 +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +TABLE: name="attmp_new2" schema="" table="attmp_new2" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE attmp RENAME TO attmp_new2" +== 074 +-- truncate_limit: 100 +SELECT * FROM attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attmp" +== 075 +-- truncate_limit: 100 +-- should fail +SELECT * FROM attmp_new +-- +TABLE: name="attmp_new" schema="" table="attmp_new" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attmp_new" +== 076 +-- truncate_limit: 100 +SELECT * FROM attmp_new2 +-- +TABLE: name="attmp_new2" schema="" table="attmp_new2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attmp_new2" +== 077 +-- truncate_limit: 100 +DROP TABLE attmp_new +-- +TABLE: name="attmp_new" schema="" table="attmp_new" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp_new" +== 078 +-- truncate_limit: 100 +DROP TABLE attmp_new2 +-- +TABLE: name="attmp_new2" schema="" table="attmp_new2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp_new2" +== 079 +-- truncate_limit: 100 +-- check rename of partitioned tables and indexes also +CREATE TABLE part_attmp (a int primary key) partition by range (a) +-- +TABLE: name="part_attmp" schema="" table="part_attmp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_attmp (a int PRIMARY KEY) PARTITION BY RANGE (a)" +== 080 +-- truncate_limit: 100 +CREATE TABLE part_attmp1 PARTITION OF part_attmp FOR VALUES FROM (0) TO (100) +-- +TABLE: name="part_attmp1" schema="" table="part_attmp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_attmp1 PARTITION OF part_attmp FOR VALUES FROM (0) TO (100)" +== 081 +-- truncate_limit: 100 +ALTER INDEX part_attmp_pkey RENAME TO part_attmp_index +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX part_attmp_pkey RENAME TO part_attmp_index" +== 082 +-- truncate_limit: 100 +ALTER INDEX part_attmp1_pkey RENAME TO part_attmp1_index +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX part_attmp1_pkey RENAME TO part_attmp1_index" +== 083 +-- truncate_limit: 100 +ALTER TABLE part_attmp RENAME TO part_at2tmp +-- +TABLE: name="part_attmp" schema="" table="part_attmp" ctx=DDL +TABLE: name="part_at2tmp" schema="" table="part_at2tmp" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE part_attmp RENAME TO part_at2tmp" +== 084 +-- truncate_limit: 100 +ALTER TABLE part_attmp1 RENAME TO part_at2tmp1 +-- +TABLE: name="part_attmp1" schema="" table="part_attmp1" ctx=DDL +TABLE: name="part_at2tmp1" schema="" table="part_at2tmp1" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE part_attmp1 RENAME TO part_at2tmp1" +== 085 +-- truncate_limit: 100 +SET ROLE regress_alter_table_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_alter_table_user1" +== 086 +-- truncate_limit: 100 +ALTER INDEX part_attmp_index RENAME TO fail +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX part_attmp_index RENAME TO fail" +== 087 +-- truncate_limit: 100 +ALTER INDEX part_attmp1_index RENAME TO fail +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX part_attmp1_index RENAME TO fail" +== 088 +-- truncate_limit: 100 +ALTER TABLE part_at2tmp RENAME TO fail +-- +TABLE: name="part_at2tmp" schema="" table="part_at2tmp" ctx=DDL +TABLE: name="fail" schema="" table="fail" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE part_at2tmp RENAME TO fail" +== 089 +-- truncate_limit: 100 +ALTER TABLE part_at2tmp1 RENAME TO fail +-- +TABLE: name="part_at2tmp1" schema="" table="part_at2tmp1" ctx=DDL +TABLE: name="fail" schema="" table="fail" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE part_at2tmp1 RENAME TO fail" +== 090 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 091 +-- truncate_limit: 100 +DROP TABLE part_at2tmp +-- +TABLE: name="part_at2tmp" schema="" table="part_at2tmp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_at2tmp" +== 092 +-- truncate_limit: 100 +|-- +-- check renaming to a table's array type's autogenerated name +-- (the array type's name should get out of the way) +|-- +CREATE TABLE attmp_array (id int) +-- +TABLE: name="attmp_array" schema="" table="attmp_array" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp_array (id int)" +== 093 +-- truncate_limit: 100 +CREATE TABLE attmp_array2 (id int) +-- +TABLE: name="attmp_array2" schema="" table="attmp_array2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp_array2 (id int)" +== 094 +-- truncate_limit: 100 +SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype" +== 095 +-- truncate_limit: 100 +SELECT typname FROM pg_type WHERE oid = 'attmp_array2[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT typname FROM pg_type WHERE oid = 'attmp_array2[]'::regtype" +== 096 +-- truncate_limit: 100 +ALTER TABLE attmp_array2 RENAME TO _attmp_array +-- +TABLE: name="attmp_array2" schema="" table="attmp_array2" ctx=DDL +TABLE: name="_attmp_array" schema="" table="_attmp_array" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE attmp_array2 RENAME TO _attmp_array" +== 097 +-- truncate_limit: 100 +SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype" +== 098 +-- truncate_limit: 100 +SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype" +== 099 +-- truncate_limit: 100 +DROP TABLE _attmp_array +-- +TABLE: name="_attmp_array" schema="" table="_attmp_array" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE _attmp_array" +== 100 +-- truncate_limit: 100 +DROP TABLE attmp_array +-- +TABLE: name="attmp_array" schema="" table="attmp_array" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp_array" +== 101 +-- truncate_limit: 100 +-- renaming to table's own array type's name is an interesting corner case +CREATE TABLE attmp_array (id int) +-- +TABLE: name="attmp_array" schema="" table="attmp_array" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp_array (id int)" +== 102 +-- truncate_limit: 100 +SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT typname FROM pg_type WHERE oid = 'attmp_array[]'::regtype" +== 103 +-- truncate_limit: 100 +ALTER TABLE attmp_array RENAME TO _attmp_array +-- +TABLE: name="attmp_array" schema="" table="attmp_array" ctx=DDL +TABLE: name="_attmp_array" schema="" table="_attmp_array" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE attmp_array RENAME TO _attmp_array" +== 104 +-- truncate_limit: 100 +SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT typname FROM pg_type WHERE oid = '_attmp_array[]'::regtype" +== 105 +-- truncate_limit: 100 +DROP TABLE _attmp_array +-- +TABLE: name="_attmp_array" schema="" table="_attmp_array" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE _attmp_array" +== 106 +-- truncate_limit: 100 +-- ALTER TABLE ... RENAME on non-table relations +-- renaming indexes (FIXME: this should probably test the index's functionality) +ALTER INDEX IF EXISTS __onek_unique1 RENAME TO attmp_onek_unique1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX IF EXISTS __onek_unique1 RENAME TO attmp_onek_unique1" +== 107 +-- truncate_limit: 100 +ALTER INDEX IF EXISTS __attmp_onek_unique1 RENAME TO onek_unique1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX IF EXISTS __attmp_onek_unique1 RENAME TO onek_unique1" +== 108 +-- truncate_limit: 100 +ALTER INDEX onek_unique1 RENAME TO attmp_onek_unique1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX onek_unique1 RENAME TO attmp_onek_unique1" +== 109 +-- truncate_limit: 100 +ALTER INDEX attmp_onek_unique1 RENAME TO onek_unique1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX attmp_onek_unique1 RENAME TO onek_unique1" +== 110 +-- truncate_limit: 100 +SET ROLE regress_alter_table_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_alter_table_user1" +== 111 +-- truncate_limit: 100 +ALTER INDEX onek_unique1 RENAME TO fail +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX onek_unique1 RENAME TO fail" +== 112 +-- truncate_limit: 100 +-- permission denied +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 113 +-- truncate_limit: 100 +-- rename statements with mismatching statement and object types +CREATE TABLE alter_idx_rename_test (a INT) +-- +TABLE: name="alter_idx_rename_test" schema="" table="alter_idx_rename_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alter_idx_rename_test (a int)" +== 114 +-- truncate_limit: 100 +CREATE INDEX alter_idx_rename_test_idx ON alter_idx_rename_test (a) +-- +TABLE: name="alter_idx_rename_test" schema="" table="alter_idx_rename_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX alter_idx_rename_test_idx ON alter_idx_rename_test USING btree (a)" +== 115 +-- truncate_limit: 100 +CREATE TABLE alter_idx_rename_test_parted (a INT) PARTITION BY LIST (a) +-- +TABLE: name="alter_idx_rename_test_parted" schema="" table="alter_idx_rename_test_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alter_idx_rename_test_parted (a int) PARTITION BY LIST (a)" +== 116 +-- truncate_limit: 100 +CREATE INDEX alter_idx_rename_test_parted_idx ON alter_idx_rename_test_parted (a) +-- +TABLE: name="alter_idx_rename_test_parted" schema="" table="alter_idx_rename_test_parted" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX alter_idx_rename_test_parted_idx ON alter_idx_rename_test_parted USING btree (a)" +== 117 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 118 +-- truncate_limit: 100 +ALTER INDEX alter_idx_rename_test RENAME TO alter_idx_rename_test_2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX alter_idx_rename_test RENAME TO alter_idx_rename_test_2" +== 119 +-- truncate_limit: 100 +ALTER INDEX alter_idx_rename_test_parted RENAME TO alter_idx_rename_test_parted_2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX alter_idx_rename_test_parted RENAME TO alter_idx_rename_test_parted_2" +== 120 +-- truncate_limit: 100 +SELECT relation::regclass, mode FROM pg_locks +WHERE pid = pg_backend_pid() AND locktype = 'relation' + AND relation::regclass::text LIKE 'alter\_idx%' +ORDER BY relation::regclass::text COLLATE "C" +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="pid" +FILTER: schema="" table="" column="locktype" +FILTER: schema="" table="" column="relation" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_locks WHERE ... ORDER BY relation::regclass::text COLLATE \"C\"" +== 121 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 122 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 123 +-- truncate_limit: 100 +ALTER INDEX alter_idx_rename_test_idx RENAME TO alter_idx_rename_test_idx_2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX alter_idx_rename_test_idx RENAME TO alter_idx_rename_test_idx_2" +== 124 +-- truncate_limit: 100 +ALTER INDEX alter_idx_rename_test_parted_idx RENAME TO alter_idx_rename_test_parted_idx_2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX alter_idx_rename_test_parted_idx RENAME TO alter_idx_rename_test_parted_idx_2" +== 125 +-- truncate_limit: 100 +SELECT relation::regclass, mode FROM pg_locks +WHERE pid = pg_backend_pid() AND locktype = 'relation' + AND relation::regclass::text LIKE 'alter\_idx%' +ORDER BY relation::regclass::text COLLATE "C" +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="pid" +FILTER: schema="" table="" column="locktype" +FILTER: schema="" table="" column="relation" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_locks WHERE ... ORDER BY relation::regclass::text COLLATE \"C\"" +== 126 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 127 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 128 +-- truncate_limit: 100 +ALTER TABLE alter_idx_rename_test_idx_2 RENAME TO alter_idx_rename_test_idx_3 +-- +TABLE: name="alter_idx_rename_test_idx_2" schema="" table="alter_idx_rename_test_idx_2" ctx=DDL +TABLE: name="alter_idx_rename_test_idx_3" schema="" table="alter_idx_rename_test_idx_3" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE alter_idx_rename_test_idx_2 RENAME TO alter_idx_rename_test_idx_3" +== 129 +-- truncate_limit: 100 +ALTER TABLE alter_idx_rename_test_parted_idx_2 RENAME TO alter_idx_rename_test_parted_idx_3 +-- +TABLE: name="alter_idx_rename_test_parted_idx_2" schema="" table="alter_idx_rename_test_parted_idx_2" ctx=DDL +TABLE: name="alter_idx_rename_test_parted_idx_3" schema="" table="alter_idx_rename_test_parted_idx_3" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE alter_idx_rename_test_parted_idx_2 RENAME TO alter_idx_rename_test_parted_idx_3" +== 130 +-- truncate_limit: 100 +SELECT relation::regclass, mode FROM pg_locks +WHERE pid = pg_backend_pid() AND locktype = 'relation' + AND relation::regclass::text LIKE 'alter\_idx%' +ORDER BY relation::regclass::text COLLATE "C" +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="pid" +FILTER: schema="" table="" column="locktype" +FILTER: schema="" table="" column="relation" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_locks WHERE ... ORDER BY relation::regclass::text COLLATE \"C\"" +== 131 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 132 +-- truncate_limit: 100 +DROP TABLE alter_idx_rename_test_2 +-- +TABLE: name="alter_idx_rename_test_2" schema="" table="alter_idx_rename_test_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE alter_idx_rename_test_2" +== 133 +-- truncate_limit: 100 +-- renaming views +CREATE VIEW attmp_view (unique1) AS SELECT unique1 FROM tenk1 +-- +TABLE: name="attmp_view" schema="" table="attmp_view" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW attmp_view (unique1) AS SELECT unique1 FROM tenk1" +== 134 +-- truncate_limit: 100 +ALTER TABLE attmp_view RENAME TO attmp_view_new +-- +TABLE: name="attmp_view" schema="" table="attmp_view" ctx=DDL +TABLE: name="attmp_view_new" schema="" table="attmp_view_new" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE attmp_view RENAME TO attmp_view_new" +== 135 +-- truncate_limit: 100 +SET ROLE regress_alter_table_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_alter_table_user1" +== 136 +-- truncate_limit: 100 +ALTER VIEW attmp_view_new RENAME TO fail +-- +STMT: RenameStmt +TRUNCATED: "ALTER VIEW attmp_view_new RENAME TO fail" +== 137 +-- truncate_limit: 100 +-- permission denied +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 138 +-- truncate_limit: 100 +-- hack to ensure we get an indexscan here +set enable_seqscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 139 +-- truncate_limit: 100 +set enable_bitmapscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 140 +-- truncate_limit: 100 +-- 5 values, sorted +SELECT unique1 FROM tenk1 WHERE unique1 < 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 < 5" +== 141 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 142 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 143 +-- truncate_limit: 100 +DROP VIEW attmp_view_new +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW attmp_view_new" +== 144 +-- truncate_limit: 100 +-- toast-like relation name +alter table stud_emp rename to pg_toast_stud_emp +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +TABLE: name="pg_toast_stud_emp" schema="" table="pg_toast_stud_emp" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE stud_emp RENAME TO pg_toast_stud_emp" +== 145 +-- truncate_limit: 100 +alter table pg_toast_stud_emp rename to stud_emp +-- +TABLE: name="pg_toast_stud_emp" schema="" table="pg_toast_stud_emp" ctx=DDL +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE pg_toast_stud_emp RENAME TO stud_emp" +== 146 +-- truncate_limit: 100 +-- renaming index should rename constraint as well +ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1)" +== 147 +-- truncate_limit: 100 +ALTER INDEX onek_unique1_constraint RENAME TO onek_unique1_constraint_foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER INDEX onek_unique1_constraint RENAME TO onek_unique1_constraint_foo" +== 148 +-- truncate_limit: 100 +ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo" +== 149 +-- truncate_limit: 100 +-- renaming constraint +ALTER TABLE onek ADD CONSTRAINT onek_check_constraint CHECK (unique1 >= 0) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE onek ADD CONSTRAINT onek_check_constraint CHECK (unique1 >= 0)" +== 150 +-- truncate_limit: 100 +ALTER TABLE onek RENAME CONSTRAINT onek_check_constraint TO onek_check_constraint_foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE onek RENAME CONSTRAINT onek_check_constraint TO onek_check_constraint_foo" +== 151 +-- truncate_limit: 100 +ALTER TABLE onek DROP CONSTRAINT onek_check_constraint_foo +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE onek DROP CONSTRAINT onek_check_constraint_foo" +== 152 +-- truncate_limit: 100 +-- renaming constraint should rename index as well +ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1)" +== 153 +-- truncate_limit: 100 +DROP INDEX onek_unique1_constraint +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX onek_unique1_constraint" +== 154 +-- truncate_limit: 100 +-- to see whether it's there +ALTER TABLE onek RENAME CONSTRAINT onek_unique1_constraint TO onek_unique1_constraint_foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE onek RENAME CONSTRAINT onek_unique1_constraint TO onek_unique1_constraint_foo" +== 155 +-- truncate_limit: 100 +DROP INDEX onek_unique1_constraint_foo +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX onek_unique1_constraint_foo" +== 156 +-- truncate_limit: 100 +-- to see whether it's there +ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo" +== 157 +-- truncate_limit: 100 +-- renaming constraints vs. inheritance +CREATE TABLE constraint_rename_test (a int CONSTRAINT con1 CHECK (a > 0), b int, c int) +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE constraint_rename_test (a int CONSTRAINT con1 CHECK (a > 0), b int, c int)" +== 158 +-- truncate_limit: 100 +CREATE TABLE constraint_rename_test2 (a int CONSTRAINT con1 CHECK (a > 0), d int) INHERITS (constraint_rename_test) +-- +TABLE: name="constraint_rename_test2" schema="" table="constraint_rename_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE constraint_rename_test2 (a int CONSTRAINT con1 CHECK (a > 0), d int) INHERITS (const..." +== 159 +-- truncate_limit: 100 +ALTER TABLE constraint_rename_test2 RENAME CONSTRAINT con1 TO con1foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE constraint_rename_test2 RENAME CONSTRAINT con1 TO con1foo" +== 160 +-- truncate_limit: 100 +-- fail +ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con1 TO con1foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con1 TO con1foo" +== 161 +-- truncate_limit: 100 +-- fail +ALTER TABLE constraint_rename_test RENAME CONSTRAINT con1 TO con1foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE constraint_rename_test RENAME CONSTRAINT con1 TO con1foo" +== 162 +-- truncate_limit: 100 +-- ok +ALTER TABLE constraint_rename_test ADD CONSTRAINT con2 CHECK (b > 0) NO INHERIT +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE constraint_rename_test ADD CONSTRAINT con2 CHECK (b > 0) NO INHERIT" +== 163 +-- truncate_limit: 100 +ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con2 TO con2foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE ONLY constraint_rename_test RENAME CONSTRAINT con2 TO con2foo" +== 164 +-- truncate_limit: 100 +-- ok +ALTER TABLE constraint_rename_test RENAME CONSTRAINT con2foo TO con2bar +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE constraint_rename_test RENAME CONSTRAINT con2foo TO con2bar" +== 165 +-- truncate_limit: 100 +-- ok +ALTER TABLE constraint_rename_test ADD CONSTRAINT con3 PRIMARY KEY (a) +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE constraint_rename_test ADD CONSTRAINT con3 PRIMARY KEY (a)" +== 166 +-- truncate_limit: 100 +ALTER TABLE constraint_rename_test RENAME CONSTRAINT con3 TO con3foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE constraint_rename_test RENAME CONSTRAINT con3 TO con3foo" +== 167 +-- truncate_limit: 100 +-- ok +DROP TABLE constraint_rename_test2 +-- +TABLE: name="constraint_rename_test2" schema="" table="constraint_rename_test2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE constraint_rename_test2" +== 168 +-- truncate_limit: 100 +DROP TABLE constraint_rename_test +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE constraint_rename_test" +== 169 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS constraint_not_exist RENAME CONSTRAINT con3 TO con3foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE IF EXISTS constraint_not_exist RENAME CONSTRAINT con3 TO con3foo" +== 170 +-- truncate_limit: 100 +-- ok +ALTER TABLE IF EXISTS constraint_rename_test ADD CONSTRAINT con4 UNIQUE (a) +-- +TABLE: name="constraint_rename_test" schema="" table="constraint_rename_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS constraint_rename_test ADD CONSTRAINT con4 UNIQUE (a)" +== 171 +-- truncate_limit: 100 +-- renaming constraints with cache reset of target relation +CREATE TABLE constraint_rename_cache (a int, + CONSTRAINT chk_a CHECK (a > 0), + PRIMARY KEY (a)) +-- +TABLE: name="constraint_rename_cache" schema="" table="constraint_rename_cache" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE constraint_rename_cache (a int, CONSTRAINT chk_a CHECK (a > 0), PRIMARY KEY (a))" +== 172 +-- truncate_limit: 100 +ALTER TABLE constraint_rename_cache + RENAME CONSTRAINT chk_a TO chk_a_new +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE constraint_rename_cache RENAME CONSTRAINT chk_a TO chk_a_new" +== 173 +-- truncate_limit: 100 +ALTER TABLE constraint_rename_cache + RENAME CONSTRAINT constraint_rename_cache_pkey TO constraint_rename_pkey_new +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE constraint_rename_cache RENAME CONSTRAINT constraint_rename_cache_pkey TO constraint_..." +== 174 +-- truncate_limit: 100 +CREATE TABLE like_constraint_rename_cache + (LIKE constraint_rename_cache INCLUDING ALL) +-- +TABLE: name="like_constraint_rename_cache" schema="" table="like_constraint_rename_cache" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE like_constraint_rename_cache (LIKE constraint_rename_cache INCLUDING ALL)" +== 175 +-- truncate_limit: 100 +DROP TABLE constraint_rename_cache +-- +TABLE: name="constraint_rename_cache" schema="" table="constraint_rename_cache" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE constraint_rename_cache" +== 176 +-- truncate_limit: 100 +DROP TABLE like_constraint_rename_cache +-- +TABLE: name="like_constraint_rename_cache" schema="" table="like_constraint_rename_cache" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE like_constraint_rename_cache" +== 177 +-- truncate_limit: 100 +-- FOREIGN KEY CONSTRAINT adding TEST + +CREATE TABLE attmp2 (a int primary key) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp2 (a int PRIMARY KEY)" +== 178 +-- truncate_limit: 100 +CREATE TABLE attmp3 (a int, b int) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp3 (a int, b int)" +== 179 +-- truncate_limit: 100 +CREATE TABLE attmp4 (a int, b int, unique(a,b)) +-- +TABLE: name="attmp4" schema="" table="attmp4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp4 (a int, b int, UNIQUE (a, b))" +== 180 +-- truncate_limit: 100 +CREATE TABLE attmp5 (a int, b int) +-- +TABLE: name="attmp5" schema="" table="attmp5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp5 (a int, b int)" +== 181 +-- truncate_limit: 100 +-- Insert rows into attmp2 (pktable) +INSERT INTO attmp2 values (1) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp2 VALUES (1)" +== 182 +-- truncate_limit: 100 +INSERT INTO attmp2 values (2) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp2 VALUES (2)" +== 183 +-- truncate_limit: 100 +INSERT INTO attmp2 values (3) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp2 VALUES (3)" +== 184 +-- truncate_limit: 100 +INSERT INTO attmp2 values (4) +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp2 VALUES (4)" +== 185 +-- truncate_limit: 100 +-- Insert rows into attmp3 +INSERT INTO attmp3 values (1,10) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp3 VALUES (1, 10)" +== 186 +-- truncate_limit: 100 +INSERT INTO attmp3 values (1,20) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp3 VALUES (1, 20)" +== 187 +-- truncate_limit: 100 +INSERT INTO attmp3 values (5,50) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp3 VALUES (5, 50)" +== 188 +-- truncate_limit: 100 +-- Try (and fail) to add constraint due to invalid source columns +ALTER TABLE attmp3 add constraint attmpconstr foreign key(c) references attmp2 match full +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT attmpconstr FOREIGN KEY (c) REFERENCES attmp2 MATCH FULL" +== 189 +-- truncate_limit: 100 +-- Try (and fail) to add constraint due to invalid destination columns explicitly given +ALTER TABLE attmp3 add constraint attmpconstr foreign key(a) references attmp2(b) match full +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT attmpconstr FOREIGN KEY (a) REFERENCES attmp2 (b) MATCH FULL" +== 190 +-- truncate_limit: 100 +-- Try (and fail) to add constraint due to invalid data +ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT attmpconstr FOREIGN KEY (a) REFERENCES attmp2 MATCH FULL" +== 191 +-- truncate_limit: 100 +-- Delete failing row +DELETE FROM attmp3 where a=5 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM attmp3 WHERE a = 5" +== 192 +-- truncate_limit: 100 +-- Try (and succeed) +ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT attmpconstr FOREIGN KEY (a) REFERENCES attmp2 MATCH FULL" +== 193 +-- truncate_limit: 100 +ALTER TABLE attmp3 drop constraint attmpconstr +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 DROP CONSTRAINT attmpconstr" +== 194 +-- truncate_limit: 100 +INSERT INTO attmp3 values (5,50) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp3 VALUES (5, 50)" +== 195 +-- truncate_limit: 100 +-- Try NOT VALID and then VALIDATE CONSTRAINT, but fails. Delete failure then re-validate +ALTER TABLE attmp3 add constraint attmpconstr foreign key (a) references attmp2 match full NOT VALID +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT attmpconstr FOREIGN KEY (a) REFERENCES attmp2 MATCH FULL NOT VALID" +== 196 +-- truncate_limit: 100 +ALTER TABLE attmp3 validate constraint attmpconstr +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT attmpconstr" +== 197 +-- truncate_limit: 100 +-- Delete failing row +DELETE FROM attmp3 where a=5 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM attmp3 WHERE a = 5" +== 198 +-- truncate_limit: 100 +-- Try (and succeed) and repeat to show it works on already valid constraint +ALTER TABLE attmp3 validate constraint attmpconstr +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT attmpconstr" +== 199 +-- truncate_limit: 100 +ALTER TABLE attmp3 validate constraint attmpconstr +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT attmpconstr" +== 200 +-- truncate_limit: 100 +-- Try a non-verified CHECK constraint +ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10) +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10)" +== 201 +-- truncate_limit: 100 +-- fail +ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10) NOT VALID +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT b_greater_than_ten CHECK (b > 10) NOT VALID" +== 202 +-- truncate_limit: 100 +-- succeeds +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten" +== 203 +-- truncate_limit: 100 +-- fails +DELETE FROM attmp3 WHERE NOT b > 10 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM attmp3 WHERE NOT b > 10" +== 204 +-- truncate_limit: 100 +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten" +== 205 +-- truncate_limit: 100 +-- succeeds +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT b_greater_than_ten" +== 206 +-- truncate_limit: 100 +-- succeeds + +-- Test inherited NOT VALID CHECK constraints +select * from attmp3 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attmp3" +== 207 +-- truncate_limit: 100 +CREATE TABLE attmp6 () INHERITS (attmp3) +-- +TABLE: name="attmp6" schema="" table="attmp6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp6 () INHERITS (attmp3)" +== 208 +-- truncate_limit: 100 +CREATE TABLE attmp7 () INHERITS (attmp3) +-- +TABLE: name="attmp7" schema="" table="attmp7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp7 () INHERITS (attmp3)" +== 209 +-- truncate_limit: 100 +INSERT INTO attmp6 VALUES (6, 30), (7, 16) +-- +TABLE: name="attmp6" schema="" table="attmp6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp6 VALUES (6, 30), (7, 16)" +== 210 +-- truncate_limit: 100 +ALTER TABLE attmp3 ADD CONSTRAINT b_le_20 CHECK (b <= 20) NOT VALID +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT b_le_20 CHECK (b <= 20) NOT VALID" +== 211 +-- truncate_limit: 100 +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20" +== 212 +-- truncate_limit: 100 +-- fails +DELETE FROM attmp6 WHERE b > 20 +-- +TABLE: name="attmp6" schema="" table="attmp6" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM attmp6 WHERE b > 20" +== 213 +-- truncate_limit: 100 +ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT b_le_20" +== 214 +-- truncate_limit: 100 +-- succeeds + +-- An already validated constraint must not be revalidated +CREATE FUNCTION boo(int) RETURNS int IMMUTABLE STRICT LANGUAGE plpgsql AS $$ BEGIN RAISE NOTICE 'boo: %', $1; RETURN $1; END; $$ +-- +FUNCTION: name="boo" function="boo" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION boo(int) RETURNS int IMMUTABLE RETURNS NULL ON NULL INPUT LANGUAGE plpgsql AS $$ ..." +== 215 +-- truncate_limit: 100 +INSERT INTO attmp7 VALUES (8, 18) +-- +TABLE: name="attmp7" schema="" table="attmp7" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp7 VALUES (8, 18)" +== 216 +-- truncate_limit: 100 +ALTER TABLE attmp7 ADD CONSTRAINT identity CHECK (b = boo(b)) +-- +TABLE: name="attmp7" schema="" table="attmp7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp7 ADD CONSTRAINT identity CHECK (b = boo(b))" +== 217 +-- truncate_limit: 100 +ALTER TABLE attmp3 ADD CONSTRAINT IDENTITY check (b = boo(b)) NOT VALID +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 ADD CONSTRAINT identity CHECK (b = boo(b)) NOT VALID" +== 218 +-- truncate_limit: 100 +ALTER TABLE attmp3 VALIDATE CONSTRAINT identity +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp3 VALIDATE CONSTRAINT identity" +== 219 +-- truncate_limit: 100 +-- A NO INHERIT constraint should not be looked for in children during VALIDATE CONSTRAINT +create table parent_noinh_convalid (a int) +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent_noinh_convalid (a int)" +== 220 +-- truncate_limit: 100 +create table child_noinh_convalid () inherits (parent_noinh_convalid) +-- +TABLE: name="child_noinh_convalid" schema="" table="child_noinh_convalid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child_noinh_convalid () INHERITS (parent_noinh_convalid)" +== 221 +-- truncate_limit: 100 +insert into parent_noinh_convalid values (1) +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent_noinh_convalid VALUES (1)" +== 222 +-- truncate_limit: 100 +insert into child_noinh_convalid values (1) +-- +TABLE: name="child_noinh_convalid" schema="" table="child_noinh_convalid" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child_noinh_convalid VALUES (1)" +== 223 +-- truncate_limit: 100 +alter table parent_noinh_convalid add constraint check_a_is_2 check (a = 2) no inherit not valid +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent_noinh_convalid ADD CONSTRAINT check_a_is_2 CHECK (a = 2) NO INHERIT NOT VALID" +== 224 +-- truncate_limit: 100 +-- fail, because of the row in parent +alter table parent_noinh_convalid validate constraint check_a_is_2 +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent_noinh_convalid VALIDATE CONSTRAINT check_a_is_2" +== 225 +-- truncate_limit: 100 +delete from only parent_noinh_convalid +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ONLY parent_noinh_convalid" +== 226 +-- truncate_limit: 100 +-- ok (parent itself contains no violating rows) +alter table parent_noinh_convalid validate constraint check_a_is_2 +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent_noinh_convalid VALIDATE CONSTRAINT check_a_is_2" +== 227 +-- truncate_limit: 100 +select convalidated from pg_constraint where conrelid = 'parent_noinh_convalid'::regclass and conname = 'check_a_is_2' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT convalidated FROM pg_constraint WHERE ..." +== 228 +-- truncate_limit: 100 +-- cleanup +drop table parent_noinh_convalid, child_noinh_convalid +-- +TABLE: name="parent_noinh_convalid" schema="" table="parent_noinh_convalid" ctx=DDL +TABLE: name="child_noinh_convalid" schema="" table="child_noinh_convalid" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent_noinh_convalid, child_noinh_convalid" +== 229 +-- truncate_limit: 100 +-- Try (and fail) to create constraint from attmp5(a) to attmp4(a) - unique constraint on +-- attmp4 is a,b + +ALTER TABLE attmp5 add constraint attmpconstr foreign key(a) references attmp4(a) match full +-- +TABLE: name="attmp5" schema="" table="attmp5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp5 ADD CONSTRAINT attmpconstr FOREIGN KEY (a) REFERENCES attmp4 (a) MATCH FULL" +== 230 +-- truncate_limit: 100 +DROP TABLE attmp7 +-- +TABLE: name="attmp7" schema="" table="attmp7" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp7" +== 231 +-- truncate_limit: 100 +DROP TABLE attmp6 +-- +TABLE: name="attmp6" schema="" table="attmp6" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp6" +== 232 +-- truncate_limit: 100 +DROP TABLE attmp5 +-- +TABLE: name="attmp5" schema="" table="attmp5" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp5" +== 233 +-- truncate_limit: 100 +DROP TABLE attmp4 +-- +TABLE: name="attmp4" schema="" table="attmp4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp4" +== 234 +-- truncate_limit: 100 +DROP TABLE attmp3 +-- +TABLE: name="attmp3" schema="" table="attmp3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp3" +== 235 +-- truncate_limit: 100 +DROP TABLE attmp2 +-- +TABLE: name="attmp2" schema="" table="attmp2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp2" +== 236 +-- truncate_limit: 100 +-- NOT VALID with plan invalidation -- ensure we don't use a constraint for +-- exclusion until validated +set constraint_exclusion TO 'partition' +-- +STMT: VariableSetStmt +TRUNCATED: "SET constraint_exclusion TO partition" +== 237 +-- truncate_limit: 100 +create table nv_parent (d date, check (false) no inherit not valid) +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE nv_parent (d date, CHECK (false) NO INHERIT NOT VALID)" +== 238 +-- truncate_limit: 100 +-- not valid constraint added at creation time should automatically become valid + +create table nv_child_2010 () inherits (nv_parent) +-- +TABLE: name="nv_child_2010" schema="" table="nv_child_2010" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE nv_child_2010 () INHERITS (nv_parent)" +== 239 +-- truncate_limit: 100 +create table nv_child_2011 () inherits (nv_parent) +-- +TABLE: name="nv_child_2011" schema="" table="nv_child_2011" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE nv_child_2011 () INHERITS (nv_parent)" +== 240 +-- truncate_limit: 100 +alter table nv_child_2010 add check (d between '2010-01-01'::date and '2010-12-31'::date) not valid +-- +TABLE: name="nv_child_2010" schema="" table="nv_child_2010" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE nv_child_2010 ADD CHECK (d BETWEEN '2010-01-01'::date AND '2010-12-31'::date) NOT VALID" +== 241 +-- truncate_limit: 100 +alter table nv_child_2011 add check (d between '2011-01-01'::date and '2011-12-31'::date) not valid +-- +TABLE: name="nv_child_2011" schema="" table="nv_child_2011" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE nv_child_2011 ADD CHECK (d BETWEEN '2011-01-01'::date AND '2011-12-31'::date) NOT VALID" +== 242 +-- truncate_limit: 100 +explain (costs off) select * from nv_parent where d between '2011-08-01' and '2011-08-31' +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=Select +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM nv_parent WHERE d BETWEEN '2011-08-01' AND '2011-08-31'" +== 243 +-- truncate_limit: 100 +create table nv_child_2009 (check (d between '2009-01-01'::date and '2009-12-31'::date)) inherits (nv_parent) +-- +TABLE: name="nv_child_2009" schema="" table="nv_child_2009" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE nv_child_2009 (CHECK (d BETWEEN '2009-01-01'::date AND '2009-12-31'::date)) INHERITS..." +== 244 +-- truncate_limit: 100 +explain (costs off) select * from nv_parent where d between '2011-08-01'::date and '2011-08-31'::date +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=Select +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM nv_parent WHERE d BETWEEN '2011-08-01'::date AND '2011-08-31'::..." +== 245 +-- truncate_limit: 100 +explain (costs off) select * from nv_parent where d between '2009-08-01'::date and '2009-08-31'::date +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=Select +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM nv_parent WHERE d BETWEEN '2009-08-01'::date AND '2009-08-31'::..." +== 246 +-- truncate_limit: 100 +-- after validation, the constraint should be used +alter table nv_child_2011 VALIDATE CONSTRAINT nv_child_2011_d_check +-- +TABLE: name="nv_child_2011" schema="" table="nv_child_2011" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE nv_child_2011 VALIDATE CONSTRAINT nv_child_2011_d_check" +== 247 +-- truncate_limit: 100 +explain (costs off) select * from nv_parent where d between '2009-08-01'::date and '2009-08-31'::date +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=Select +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM nv_parent WHERE d BETWEEN '2009-08-01'::date AND '2009-08-31'::..." +== 248 +-- truncate_limit: 100 +-- add an inherited NOT VALID constraint +alter table nv_parent add check (d between '2001-01-01'::date and '2099-12-31'::date) not valid +-- +TABLE: name="nv_parent" schema="" table="nv_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE nv_parent ADD CHECK (d BETWEEN '2001-01-01'::date AND '2099-12-31'::date) NOT VALID" +== 249 +-- truncate_limit: 100 +-- we leave nv_parent and children around to help test pg_dump logic + +-- Foreign key adding test with mixed types + +-- Note: these tables are TEMP to avoid name conflicts when this test +-- is run in parallel with foreign_key.sql. + +CREATE TEMP TABLE PKTABLE (ptest1 int PRIMARY KEY) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pktable (ptest1 int PRIMARY KEY)" +== 250 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES(42) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (42)" +== 251 +-- truncate_limit: 100 +CREATE TEMP TABLE FKTABLE (ftest1 inet) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (ftest1 inet)" +== 252 +-- truncate_limit: 100 +-- This next should fail, because int=inet does not exist +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1) REFERENCES pktable" +== 253 +-- truncate_limit: 100 +-- This should also fail for the same reason, but here we +-- give the column name +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1) REFERENCES pktable (ptest1)" +== 254 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 255 +-- truncate_limit: 100 +-- This should succeed, even though they are different types, +-- because int=int8 exists and is a member of the integer opfamily +CREATE TEMP TABLE FKTABLE (ftest1 int8) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (ftest1 int8)" +== 256 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1) REFERENCES pktable" +== 257 +-- truncate_limit: 100 +-- Check it actually works +INSERT INTO FKTABLE VALUES(42) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (42)" +== 258 +-- truncate_limit: 100 +-- should succeed +INSERT INTO FKTABLE VALUES(43) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (43)" +== 259 +-- truncate_limit: 100 +-- should fail +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 260 +-- truncate_limit: 100 +-- This should fail, because we'd have to cast numeric to int which is +-- not an implicit coercion (or use numeric=numeric, but that's not part +-- of the integer opfamily) +CREATE TEMP TABLE FKTABLE (ftest1 numeric) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (ftest1 numeric)" +== 261 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1) REFERENCES pktable" +== 262 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 263 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 264 +-- truncate_limit: 100 +-- On the other hand, this should work because int implicitly promotes to +-- numeric, and we allow promotion on the FK side +CREATE TEMP TABLE PKTABLE (ptest1 numeric PRIMARY KEY) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pktable (ptest1 numeric PRIMARY KEY)" +== 265 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES(42) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (42)" +== 266 +-- truncate_limit: 100 +CREATE TEMP TABLE FKTABLE (ftest1 int) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (ftest1 int)" +== 267 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1) REFERENCES pktable" +== 268 +-- truncate_limit: 100 +-- Check it actually works +INSERT INTO FKTABLE VALUES(42) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (42)" +== 269 +-- truncate_limit: 100 +-- should succeed +INSERT INTO FKTABLE VALUES(43) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (43)" +== 270 +-- truncate_limit: 100 +-- should fail +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 271 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 272 +-- truncate_limit: 100 +CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet, + PRIMARY KEY(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pktable (ptest1 int, ptest2 inet, PRIMARY KEY (ptest1, ptest2))" +== 273 +-- truncate_limit: 100 +-- This should fail, because we just chose really odd types +CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (ftest1 cidr, ftest2 timestamp)" +== 274 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1, ftest2) REFERENCES pktable" +== 275 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 276 +-- truncate_limit: 100 +-- Again, so should this... +CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (ftest1 cidr, ftest2 timestamp)" +== 277 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) + references pktable(ptest1, ptest2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1, ftest2) REFERENCES pktable (ptest1, ptest2)" +== 278 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 279 +-- truncate_limit: 100 +-- This fails because we mixed up the column ordering +CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 inet) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (ftest1 int, ftest2 inet)" +== 280 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) + references pktable(ptest2, ptest1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1, ftest2) REFERENCES pktable (ptest2, ptest1)" +== 281 +-- truncate_limit: 100 +-- As does this... +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest2, ftest1) + references pktable(ptest1, ptest2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest2, ftest1) REFERENCES pktable (ptest1, ptest2)" +== 282 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 283 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 284 +-- truncate_limit: 100 +-- Test that ALTER CONSTRAINT updates trigger deferrability properly + +CREATE TEMP TABLE PKTABLE (ptest1 int primary key) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pktable (ptest1 int PRIMARY KEY)" +== 285 +-- truncate_limit: 100 +CREATE TEMP TABLE FKTABLE (ftest1 int) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (ftest1 int)" +== 286 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD CONSTRAINT fknd FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fknd FOREIGN KEY (ftest1) REFERENCES pktable ON DELETE CASCADE" +== 287 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD CONSTRAINT fkdd FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fkdd FOREIGN KEY (ftest1) REFERENCES pktable ON DELETE CASCADE..." +== 288 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD CONSTRAINT fkdi FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY IMMEDIATE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fkdi FOREIGN KEY (ftest1) REFERENCES pktable ON DELETE CASCADE..." +== 289 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD CONSTRAINT fknd2 FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fknd2 FOREIGN KEY (ftest1) REFERENCES pktable ON DELETE CASCAD..." +== 290 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ALTER CONSTRAINT fknd2 NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ALTER CONSTRAINT fknd2" +== 291 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD CONSTRAINT fkdd2 FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fkdd2 FOREIGN KEY (ftest1) REFERENCES pktable ON DELETE CASCADE" +== 292 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ALTER CONSTRAINT fkdd2 DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ALTER CONSTRAINT fkdd2 DEFERRABLE INITIALLY DEFERRED" +== 293 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD CONSTRAINT fkdi2 FOREIGN KEY(ftest1) REFERENCES pktable + ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fkdi2 FOREIGN KEY (ftest1) REFERENCES pktable ON DELETE CASCADE" +== 294 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ALTER CONSTRAINT fkdi2 DEFERRABLE INITIALLY IMMEDIATE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ALTER CONSTRAINT fkdi2 DEFERRABLE" +== 295 +-- truncate_limit: 100 +SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred +FROM pg_trigger JOIN pg_constraint con ON con.oid = tgconstraint +WHERE tgrelid = 'pktable'::regclass +ORDER BY 1,2,3 +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger JOIN pg_constraint con ON con.oid = tgconstraint WHERE ... ORDER BY 1,..." +== 296 +-- truncate_limit: 100 +SELECT conname, tgfoid::regproc, tgtype, tgdeferrable, tginitdeferred +FROM pg_trigger JOIN pg_constraint con ON con.oid = tgconstraint +WHERE tgrelid = 'fktable'::regclass +ORDER BY 1,2,3 +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger JOIN pg_constraint con ON con.oid = tgconstraint WHERE ... ORDER BY 1,..." +== 297 +-- truncate_limit: 100 +-- temp tables should go away by themselves, need not drop them. + +-- test check constraint adding + +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 298 +-- truncate_limit: 100 +-- add a check constraint +alter table atacc1 add constraint atacc_test1 check (test>3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 CHECK (test > 3)" +== 299 +-- truncate_limit: 100 +-- should fail +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 300 +-- truncate_limit: 100 +-- should succeed +insert into atacc1 (test) values (4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (4)" +== 301 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 302 +-- truncate_limit: 100 +-- let's do one where the check fails when added +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 303 +-- truncate_limit: 100 +-- insert a soon to be failing row +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 304 +-- truncate_limit: 100 +-- add a check constraint (fails) +alter table atacc1 add constraint atacc_test1 check (test>3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 CHECK (test > 3)" +== 305 +-- truncate_limit: 100 +insert into atacc1 (test) values (4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (4)" +== 306 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 307 +-- truncate_limit: 100 +-- let's do one where the check fails because the column doesn't exist +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 308 +-- truncate_limit: 100 +-- add a check constraint (fails) +alter table atacc1 add constraint atacc_test1 check (test1>3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 CHECK (test1 > 3)" +== 309 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 310 +-- truncate_limit: 100 +-- something a little more complicated +create table atacc1 ( test int, test2 int, test3 int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int, test2 int, test3 int)" +== 311 +-- truncate_limit: 100 +-- add a check constraint (fails) +alter table atacc1 add constraint atacc_test1 check (test+test23), test2 int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int CHECK (test > 3), test2 int)" +== 316 +-- truncate_limit: 100 +alter table atacc1 add check (test2>test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CHECK (test2 > test)" +== 317 +-- truncate_limit: 100 +-- should fail for $2 +insert into atacc1 (test2, test) values (3, 4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test2, test) VALUES (3, 4)" +== 318 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 319 +-- truncate_limit: 100 +-- inheritance related tests +create table atacc1 (test int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 320 +-- truncate_limit: 100 +create table atacc2 (test2 int) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc2 (test2 int)" +== 321 +-- truncate_limit: 100 +create table atacc3 (test3 int) inherits (atacc1, atacc2) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc3 (test3 int) INHERITS (atacc1, atacc2)" +== 322 +-- truncate_limit: 100 +alter table atacc2 add constraint foo check (test2>0) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc2 ADD CONSTRAINT foo CHECK (test2 > 0)" +== 323 +-- truncate_limit: 100 +-- fail and then succeed on atacc2 +insert into atacc2 (test2) values (-3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc2 (test2) VALUES (-3)" +== 324 +-- truncate_limit: 100 +insert into atacc2 (test2) values (3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc2 (test2) VALUES (3)" +== 325 +-- truncate_limit: 100 +-- fail and then succeed on atacc3 +insert into atacc3 (test2) values (-3) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc3 (test2) VALUES (-3)" +== 326 +-- truncate_limit: 100 +insert into atacc3 (test2) values (3) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc3 (test2) VALUES (3)" +== 327 +-- truncate_limit: 100 +drop table atacc3 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc3" +== 328 +-- truncate_limit: 100 +drop table atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc2" +== 329 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 330 +-- truncate_limit: 100 +-- same things with one created with INHERIT +create table atacc1 (test int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 331 +-- truncate_limit: 100 +create table atacc2 (test2 int) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc2 (test2 int)" +== 332 +-- truncate_limit: 100 +create table atacc3 (test3 int) inherits (atacc1, atacc2) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc3 (test3 int) INHERITS (atacc1, atacc2)" +== 333 +-- truncate_limit: 100 +alter table atacc3 no inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 NO INHERIT atacc2" +== 334 +-- truncate_limit: 100 +-- fail +alter table atacc3 no inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 NO INHERIT atacc2" +== 335 +-- truncate_limit: 100 +-- make sure it really isn't a child +insert into atacc3 (test2) values (3) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc3 (test2) VALUES (3)" +== 336 +-- truncate_limit: 100 +select test2 from atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT test2 FROM atacc2" +== 337 +-- truncate_limit: 100 +-- fail due to missing constraint +alter table atacc2 add constraint foo check (test2>0) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc2 ADD CONSTRAINT foo CHECK (test2 > 0)" +== 338 +-- truncate_limit: 100 +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 INHERIT atacc2" +== 339 +-- truncate_limit: 100 +-- fail due to missing column +alter table atacc3 rename test2 to testx +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE atacc3 RENAME COLUMN test2 TO testx" +== 340 +-- truncate_limit: 100 +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 INHERIT atacc2" +== 341 +-- truncate_limit: 100 +-- fail due to mismatched data type +alter table atacc3 add test2 bool +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 ADD COLUMN test2 bool" +== 342 +-- truncate_limit: 100 +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 INHERIT atacc2" +== 343 +-- truncate_limit: 100 +alter table atacc3 drop test2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 DROP test2" +== 344 +-- truncate_limit: 100 +-- succeed +alter table atacc3 add test2 int +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 ADD COLUMN test2 int" +== 345 +-- truncate_limit: 100 +update atacc3 set test2 = 4 where test2 is null +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atacc3 SET test2 = 4 WHERE test2 IS NULL" +== 346 +-- truncate_limit: 100 +alter table atacc3 add constraint foo check (test2>0) +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 ADD CONSTRAINT foo CHECK (test2 > 0)" +== 347 +-- truncate_limit: 100 +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 INHERIT atacc2" +== 348 +-- truncate_limit: 100 +-- fail due to duplicates and circular inheritance +alter table atacc3 inherit atacc2 +-- +TABLE: name="atacc3" schema="" table="atacc3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc3 INHERIT atacc2" +== 349 +-- truncate_limit: 100 +alter table atacc2 inherit atacc3 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc2 INHERIT atacc3" +== 350 +-- truncate_limit: 100 +alter table atacc2 inherit atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc2 INHERIT atacc2" +== 351 +-- truncate_limit: 100 +-- test that we really are a child now (should see 4 not 3 and cascade should go through) +select test2 from atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT test2 FROM atacc2" +== 352 +-- truncate_limit: 100 +drop table atacc2 cascade +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc2 CASCADE" +== 353 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 354 +-- truncate_limit: 100 +-- adding only to a parent is allowed as of 9.2 + +create table atacc1 (test int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 355 +-- truncate_limit: 100 +create table atacc2 (test2 int) inherits (atacc1) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc2 (test2 int) INHERITS (atacc1)" +== 356 +-- truncate_limit: 100 +-- ok: +alter table atacc1 add constraint foo check (test>0) no inherit +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT foo CHECK (test > 0) NO INHERIT" +== 357 +-- truncate_limit: 100 +-- check constraint is not there on child +insert into atacc2 (test) values (-3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc2 (test) VALUES (-3)" +== 358 +-- truncate_limit: 100 +-- check constraint is there on parent +insert into atacc1 (test) values (-3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (-3)" +== 359 +-- truncate_limit: 100 +insert into atacc1 (test) values (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (3)" +== 360 +-- truncate_limit: 100 +-- fail, violating row: +alter table atacc2 add constraint foo check (test>0) no inherit +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc2 ADD CONSTRAINT foo CHECK (test > 0) NO INHERIT" +== 361 +-- truncate_limit: 100 +drop table atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc2" +== 362 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 363 +-- truncate_limit: 100 +-- test unique constraint adding + +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 364 +-- truncate_limit: 100 +-- add a unique constraint +alter table atacc1 add constraint atacc_test1 unique (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 UNIQUE (test)" +== 365 +-- truncate_limit: 100 +-- insert first value +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 366 +-- truncate_limit: 100 +-- should fail +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 367 +-- truncate_limit: 100 +-- should succeed +insert into atacc1 (test) values (4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (4)" +== 368 +-- truncate_limit: 100 +-- try to create duplicates via alter table using - should fail +alter table atacc1 alter column test type integer using 0 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test TYPE int USING 0" +== 369 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 370 +-- truncate_limit: 100 +-- let's do one where the unique constraint fails when added +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 371 +-- truncate_limit: 100 +-- insert soon to be failing rows +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 372 +-- truncate_limit: 100 +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 373 +-- truncate_limit: 100 +-- add a unique constraint (fails) +alter table atacc1 add constraint atacc_test1 unique (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 UNIQUE (test)" +== 374 +-- truncate_limit: 100 +insert into atacc1 (test) values (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (3)" +== 375 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 376 +-- truncate_limit: 100 +-- let's do one where the unique constraint fails +-- because the column doesn't exist +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 377 +-- truncate_limit: 100 +-- add a unique constraint (fails) +alter table atacc1 add constraint atacc_test1 unique (test1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 UNIQUE (test1)" +== 378 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 379 +-- truncate_limit: 100 +-- something a little more complicated +create table atacc1 ( test int, test2 int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int, test2 int)" +== 380 +-- truncate_limit: 100 +-- add a unique constraint +alter table atacc1 add constraint atacc_test1 unique (test, test2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 UNIQUE (test, test2)" +== 381 +-- truncate_limit: 100 +-- insert initial value +insert into atacc1 (test,test2) values (4,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (4, 4)" +== 382 +-- truncate_limit: 100 +-- should fail +insert into atacc1 (test,test2) values (4,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (4, 4)" +== 383 +-- truncate_limit: 100 +-- should all succeed +insert into atacc1 (test,test2) values (4,5) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (4, 5)" +== 384 +-- truncate_limit: 100 +insert into atacc1 (test,test2) values (5,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (5, 4)" +== 385 +-- truncate_limit: 100 +insert into atacc1 (test,test2) values (5,5) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (5, 5)" +== 386 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 387 +-- truncate_limit: 100 +-- lets do some naming tests +create table atacc1 (test int, test2 int, unique(test)) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int, test2 int, UNIQUE (test))" +== 388 +-- truncate_limit: 100 +alter table atacc1 add unique (test2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD UNIQUE (test2)" +== 389 +-- truncate_limit: 100 +-- should fail for @@ second one @@ +insert into atacc1 (test2, test) values (3, 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test2, test) VALUES (3, 3)" +== 390 +-- truncate_limit: 100 +insert into atacc1 (test2, test) values (2, 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test2, test) VALUES (2, 3)" +== 391 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 392 +-- truncate_limit: 100 +-- test primary key constraint adding + +create table atacc1 ( id serial, test int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (id serial, test int)" +== 393 +-- truncate_limit: 100 +-- add a primary key constraint +alter table atacc1 add constraint atacc_test1 primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 PRIMARY KEY (test)" +== 394 +-- truncate_limit: 100 +-- insert first value +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 395 +-- truncate_limit: 100 +-- should fail +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 396 +-- truncate_limit: 100 +-- should succeed +insert into atacc1 (test) values (4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (4)" +== 397 +-- truncate_limit: 100 +-- inserting NULL should fail +insert into atacc1 (test) values(NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (NULL)" +== 398 +-- truncate_limit: 100 +-- try adding a second primary key (should fail) +alter table atacc1 add constraint atacc_oid1 primary key(id) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_oid1 PRIMARY KEY (id)" +== 399 +-- truncate_limit: 100 +-- drop first primary key constraint +alter table atacc1 drop constraint atacc_test1 restrict +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP CONSTRAINT atacc_test1" +== 400 +-- truncate_limit: 100 +-- try adding a primary key on oid (should succeed) +alter table atacc1 add constraint atacc_oid1 primary key(id) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_oid1 PRIMARY KEY (id)" +== 401 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 402 +-- truncate_limit: 100 +-- let's do one where the primary key constraint fails when added +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 403 +-- truncate_limit: 100 +-- insert soon to be failing rows +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 404 +-- truncate_limit: 100 +insert into atacc1 (test) values (2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (2)" +== 405 +-- truncate_limit: 100 +-- add a primary key (fails) +alter table atacc1 add constraint atacc_test1 primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 PRIMARY KEY (test)" +== 406 +-- truncate_limit: 100 +insert into atacc1 (test) values (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (3)" +== 407 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 408 +-- truncate_limit: 100 +-- let's do another one where the primary key constraint fails when added +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 409 +-- truncate_limit: 100 +-- insert soon to be failing row +insert into atacc1 (test) values (NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (NULL)" +== 410 +-- truncate_limit: 100 +-- add a primary key (fails) +alter table atacc1 add constraint atacc_test1 primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 PRIMARY KEY (test)" +== 411 +-- truncate_limit: 100 +insert into atacc1 (test) values (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (3)" +== 412 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 413 +-- truncate_limit: 100 +-- let's do one where the primary key constraint fails +-- because the column doesn't exist +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 414 +-- truncate_limit: 100 +-- add a primary key constraint (fails) +alter table atacc1 add constraint atacc_test1 primary key (test1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 PRIMARY KEY (test1)" +== 415 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 416 +-- truncate_limit: 100 +-- adding a new column as primary key to a non-empty table. +-- should fail unless the column has a non-null default value. +create table atacc1 ( test int ) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int)" +== 417 +-- truncate_limit: 100 +insert into atacc1 (test) values (0) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (0)" +== 418 +-- truncate_limit: 100 +-- add a primary key column without a default (fails). +alter table atacc1 add column test2 int primary key +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD COLUMN test2 int PRIMARY KEY" +== 419 +-- truncate_limit: 100 +-- now add a primary key column with a default (succeeds). +alter table atacc1 add column test2 int default 0 primary key +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD COLUMN test2 int DEFAULT 0 PRIMARY KEY" +== 420 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 421 +-- truncate_limit: 100 +-- this combination used to have order-of-execution problems (bug #15580) +create table atacc1 (a int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (a int)" +== 422 +-- truncate_limit: 100 +insert into atacc1 values(1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (1)" +== 423 +-- truncate_limit: 100 +alter table atacc1 + add column b float8 not null default random(), + add primary key(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD COLUMN b float8 NOT NULL DEFAULT random(), ADD PRIMARY KEY (a)" +== 424 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 425 +-- truncate_limit: 100 +-- additionally, we've seen issues with foreign key validation not being +-- properly delayed until after a table rewrite. Check that works ok. +create table atacc1 (a int primary key) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (a int PRIMARY KEY)" +== 426 +-- truncate_limit: 100 +alter table atacc1 add constraint atacc1_fkey foreign key (a) references atacc1 (a) not valid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc1_fkey FOREIGN KEY (a) REFERENCES atacc1 (a) NOT VALID" +== 427 +-- truncate_limit: 100 +alter table atacc1 validate constraint atacc1_fkey, alter a type bigint +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 VALIDATE CONSTRAINT atacc1_fkey, ALTER COLUMN a TYPE bigint" +== 428 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 429 +-- truncate_limit: 100 +-- we've also seen issues with check constraints being validated at the wrong +-- time when there's a pending table rewrite. +create table atacc1 (a bigint, b int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (a bigint, b int)" +== 430 +-- truncate_limit: 100 +insert into atacc1 values(1,1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (1, 1)" +== 431 +-- truncate_limit: 100 +alter table atacc1 add constraint atacc1_chk check(b = 1) not valid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc1_chk CHECK (b = 1) NOT VALID" +== 432 +-- truncate_limit: 100 +alter table atacc1 validate constraint atacc1_chk, alter a type int +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 VALIDATE CONSTRAINT atacc1_chk, ALTER COLUMN a TYPE int" +== 433 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 434 +-- truncate_limit: 100 +-- same as above, but ensure the constraint violation is detected +create table atacc1 (a bigint, b int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (a bigint, b int)" +== 435 +-- truncate_limit: 100 +insert into atacc1 values(1,2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (1, 2)" +== 436 +-- truncate_limit: 100 +alter table atacc1 add constraint atacc1_chk check(b = 1) not valid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc1_chk CHECK (b = 1) NOT VALID" +== 437 +-- truncate_limit: 100 +alter table atacc1 validate constraint atacc1_chk, alter a type int +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 VALIDATE CONSTRAINT atacc1_chk, ALTER COLUMN a TYPE int" +== 438 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 439 +-- truncate_limit: 100 +-- something a little more complicated +create table atacc1 ( test int, test2 int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int, test2 int)" +== 440 +-- truncate_limit: 100 +-- add a primary key constraint +alter table atacc1 add constraint atacc_test1 primary key (test, test2) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test1 PRIMARY KEY (test, test2)" +== 441 +-- truncate_limit: 100 +-- try adding a second primary key - should fail +alter table atacc1 add constraint atacc_test2 primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc_test2 PRIMARY KEY (test)" +== 442 +-- truncate_limit: 100 +-- insert initial value +insert into atacc1 (test,test2) values (4,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (4, 4)" +== 443 +-- truncate_limit: 100 +-- should fail +insert into atacc1 (test,test2) values (4,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (4, 4)" +== 444 +-- truncate_limit: 100 +insert into atacc1 (test,test2) values (NULL,3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (NULL, 3)" +== 445 +-- truncate_limit: 100 +insert into atacc1 (test,test2) values (3, NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (3, NULL)" +== 446 +-- truncate_limit: 100 +insert into atacc1 (test,test2) values (NULL,NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (NULL, NULL)" +== 447 +-- truncate_limit: 100 +-- should all succeed +insert into atacc1 (test,test2) values (4,5) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (4, 5)" +== 448 +-- truncate_limit: 100 +insert into atacc1 (test,test2) values (5,4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (5, 4)" +== 449 +-- truncate_limit: 100 +insert into atacc1 (test,test2) values (5,5) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test, test2) VALUES (5, 5)" +== 450 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 451 +-- truncate_limit: 100 +-- lets do some naming tests +create table atacc1 (test int, test2 int, primary key(test)) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int, test2 int, PRIMARY KEY (test))" +== 452 +-- truncate_limit: 100 +-- only first should succeed +insert into atacc1 (test2, test) values (3, 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test2, test) VALUES (3, 3)" +== 453 +-- truncate_limit: 100 +insert into atacc1 (test2, test) values (2, 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test2, test) VALUES (2, 3)" +== 454 +-- truncate_limit: 100 +insert into atacc1 (test2, test) values (1, NULL) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test2, test) VALUES (1, NULL)" +== 455 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 456 +-- truncate_limit: 100 +-- alter table / alter column [set/drop] not null tests +-- try altering system catalogs, should fail +alter table pg_class alter column relname drop not null +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pg_class ALTER COLUMN relname DROP NOT NULL" +== 457 +-- truncate_limit: 100 +alter table pg_class alter relname set not null +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pg_class ALTER COLUMN relname SET NOT NULL" +== 458 +-- truncate_limit: 100 +-- try altering non-existent table, should fail +alter table non_existent alter column bar set not null +-- +TABLE: name="non_existent" schema="" table="non_existent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE non_existent ALTER COLUMN bar SET NOT NULL" +== 459 +-- truncate_limit: 100 +alter table non_existent alter column bar drop not null +-- +TABLE: name="non_existent" schema="" table="non_existent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE non_existent ALTER COLUMN bar DROP NOT NULL" +== 460 +-- truncate_limit: 100 +-- test setting columns to null and not null and vice versa +-- test checking for null values and primary key +create table atacc1 (test int not null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int NOT NULL)" +== 461 +-- truncate_limit: 100 +alter table atacc1 add constraint "atacc1_pkey" primary key (test) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc1_pkey PRIMARY KEY (test)" +== 462 +-- truncate_limit: 100 +alter table atacc1 alter column test drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test DROP NOT NULL" +== 463 +-- truncate_limit: 100 +alter table atacc1 drop constraint "atacc1_pkey" +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP CONSTRAINT atacc1_pkey" +== 464 +-- truncate_limit: 100 +alter table atacc1 alter column test drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test DROP NOT NULL" +== 465 +-- truncate_limit: 100 +insert into atacc1 values (null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (NULL)" +== 466 +-- truncate_limit: 100 +alter table atacc1 alter test set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test SET NOT NULL" +== 467 +-- truncate_limit: 100 +delete from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atacc1" +== 468 +-- truncate_limit: 100 +alter table atacc1 alter test set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test SET NOT NULL" +== 469 +-- truncate_limit: 100 +-- try altering a non-existent column, should fail +alter table atacc1 alter bar set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN bar SET NOT NULL" +== 470 +-- truncate_limit: 100 +alter table atacc1 alter bar drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN bar DROP NOT NULL" +== 471 +-- truncate_limit: 100 +-- try creating a view and altering that, should fail +create view myview as select * from atacc1 +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW myview AS SELECT * FROM atacc1" +== 472 +-- truncate_limit: 100 +alter table myview alter column test drop not null +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE myview ALTER COLUMN test DROP NOT NULL" +== 473 +-- truncate_limit: 100 +alter table myview alter column test set not null +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE myview ALTER COLUMN test SET NOT NULL" +== 474 +-- truncate_limit: 100 +drop view myview +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW myview" +== 475 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 476 +-- truncate_limit: 100 +-- set not null verified by constraints +create table atacc1 (test_a int, test_b int) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test_a int, test_b int)" +== 477 +-- truncate_limit: 100 +insert into atacc1 values (null, 1) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (NULL, 1)" +== 478 +-- truncate_limit: 100 +-- constraint not cover all values, should fail +alter table atacc1 add constraint atacc1_constr_or check(test_a is not null or test_b < 10) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc1_constr_or CHECK (test_a IS NOT NULL OR test_b < 10)" +== 479 +-- truncate_limit: 100 +alter table atacc1 alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_a SET NOT NULL" +== 480 +-- truncate_limit: 100 +alter table atacc1 drop constraint atacc1_constr_or +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP CONSTRAINT atacc1_constr_or" +== 481 +-- truncate_limit: 100 +-- not valid constraint, should fail +alter table atacc1 add constraint atacc1_constr_invalid check(test_a is not null) not valid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc1_constr_invalid CHECK (test_a IS NOT NULL) NOT VALID" +== 482 +-- truncate_limit: 100 +alter table atacc1 alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_a SET NOT NULL" +== 483 +-- truncate_limit: 100 +alter table atacc1 drop constraint atacc1_constr_invalid +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP CONSTRAINT atacc1_constr_invalid" +== 484 +-- truncate_limit: 100 +-- with valid constraint +update atacc1 set test_a = 1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atacc1 SET test_a = 1" +== 485 +-- truncate_limit: 100 +alter table atacc1 add constraint atacc1_constr_a_valid check(test_a is not null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc1_constr_a_valid CHECK (test_a IS NOT NULL)" +== 486 +-- truncate_limit: 100 +alter table atacc1 alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_a SET NOT NULL" +== 487 +-- truncate_limit: 100 +delete from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atacc1" +== 488 +-- truncate_limit: 100 +insert into atacc1 values (2, null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (2, NULL)" +== 489 +-- truncate_limit: 100 +alter table atacc1 alter test_a drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_a DROP NOT NULL" +== 490 +-- truncate_limit: 100 +-- test multiple set not null at same time +-- test_a checked by atacc1_constr_a_valid, test_b should fail by table scan +alter table atacc1 alter test_a set not null, alter test_b set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_a SET NOT NULL, ALTER COLUMN test_b SET NOT NULL" +== 491 +-- truncate_limit: 100 +-- commands order has no importance +alter table atacc1 alter test_b set not null, alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_b SET NOT NULL, ALTER COLUMN test_a SET NOT NULL" +== 492 +-- truncate_limit: 100 +-- valid one by table scan, one by check constraints +update atacc1 set test_b = 1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atacc1 SET test_b = 1" +== 493 +-- truncate_limit: 100 +alter table atacc1 alter test_b set not null, alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_b SET NOT NULL, ALTER COLUMN test_a SET NOT NULL" +== 494 +-- truncate_limit: 100 +alter table atacc1 alter test_a drop not null, alter test_b drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_a DROP NOT NULL, ALTER COLUMN test_b DROP NOT NULL" +== 495 +-- truncate_limit: 100 +-- both column has check constraints +alter table atacc1 add constraint atacc1_constr_b_valid check(test_b is not null) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CONSTRAINT atacc1_constr_b_valid CHECK (test_b IS NOT NULL)" +== 496 +-- truncate_limit: 100 +alter table atacc1 alter test_b set not null, alter test_a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN test_b SET NOT NULL, ALTER COLUMN test_a SET NOT NULL" +== 497 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 498 +-- truncate_limit: 100 +-- test inheritance +create table parent (a int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a int)" +== 499 +-- truncate_limit: 100 +create table child (b varchar(255)) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child (b varchar(255)) INHERITS (parent)" +== 500 +-- truncate_limit: 100 +alter table parent alter a set not null +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ALTER COLUMN a SET NOT NULL" +== 501 +-- truncate_limit: 100 +insert into parent values (NULL) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES (NULL)" +== 502 +-- truncate_limit: 100 +insert into child (a, b) values (NULL, 'foo') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child (a, b) VALUES (NULL, 'foo')" +== 503 +-- truncate_limit: 100 +alter table parent alter a drop not null +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ALTER COLUMN a DROP NOT NULL" +== 504 +-- truncate_limit: 100 +insert into parent values (NULL) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES (NULL)" +== 505 +-- truncate_limit: 100 +insert into child (a, b) values (NULL, 'foo') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child (a, b) VALUES (NULL, 'foo')" +== 506 +-- truncate_limit: 100 +alter table only parent alter a set not null +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parent ALTER COLUMN a SET NOT NULL" +== 507 +-- truncate_limit: 100 +alter table child alter a set not null +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child ALTER COLUMN a SET NOT NULL" +== 508 +-- truncate_limit: 100 +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parent" +== 509 +-- truncate_limit: 100 +alter table only parent alter a set not null +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parent ALTER COLUMN a SET NOT NULL" +== 510 +-- truncate_limit: 100 +insert into parent values (NULL) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES (NULL)" +== 511 +-- truncate_limit: 100 +alter table child alter a set not null +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child ALTER COLUMN a SET NOT NULL" +== 512 +-- truncate_limit: 100 +insert into child (a, b) values (NULL, 'foo') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child (a, b) VALUES (NULL, 'foo')" +== 513 +-- truncate_limit: 100 +delete from child +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM child" +== 514 +-- truncate_limit: 100 +alter table child alter a set not null +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child ALTER COLUMN a SET NOT NULL" +== 515 +-- truncate_limit: 100 +insert into child (a, b) values (NULL, 'foo') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child (a, b) VALUES (NULL, 'foo')" +== 516 +-- truncate_limit: 100 +drop table child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE child" +== 517 +-- truncate_limit: 100 +drop table parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent" +== 518 +-- truncate_limit: 100 +-- test setting and removing default values +create table def_test ( + c1 int4 default 5, + c2 text default 'initial_default' +) +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE def_test (c1 int4 DEFAULT 5, c2 text DEFAULT 'initial_default')" +== 519 +-- truncate_limit: 100 +insert into def_test default values +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO def_test DEFAULT VALUES" +== 520 +-- truncate_limit: 100 +alter table def_test alter column c1 drop default +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_test ALTER COLUMN c1 DROP DEFAULT" +== 521 +-- truncate_limit: 100 +insert into def_test default values +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO def_test DEFAULT VALUES" +== 522 +-- truncate_limit: 100 +alter table def_test alter column c2 drop default +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_test ALTER COLUMN c2 DROP DEFAULT" +== 523 +-- truncate_limit: 100 +insert into def_test default values +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO def_test DEFAULT VALUES" +== 524 +-- truncate_limit: 100 +alter table def_test alter column c1 set default 10 +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_test ALTER COLUMN c1 SET DEFAULT 10" +== 525 +-- truncate_limit: 100 +alter table def_test alter column c2 set default 'new_default' +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_test ALTER COLUMN c2 SET DEFAULT 'new_default'" +== 526 +-- truncate_limit: 100 +insert into def_test default values +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO def_test DEFAULT VALUES" +== 527 +-- truncate_limit: 100 +select * from def_test +-- +TABLE: name="def_test" schema="" table="def_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM def_test" +== 528 +-- truncate_limit: 100 +-- set defaults to an incorrect type: this should fail +alter table def_test alter column c1 set default 'wrong_datatype' +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_test ALTER COLUMN c1 SET DEFAULT 'wrong_datatype'" +== 529 +-- truncate_limit: 100 +alter table def_test alter column c2 set default 20 +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_test ALTER COLUMN c2 SET DEFAULT 20" +== 530 +-- truncate_limit: 100 +-- set defaults on a non-existent column: this should fail +alter table def_test alter column c3 set default 30 +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_test ALTER COLUMN c3 SET DEFAULT 30" +== 531 +-- truncate_limit: 100 +-- set defaults on views: we need to create a view, add a rule +-- to allow insertions into it, and then alter the view to add +-- a default +create view def_view_test as select * from def_test +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +TABLE: name="def_test" schema="" table="def_test" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW def_view_test AS SELECT * FROM def_test" +== 532 +-- truncate_limit: 100 +create rule def_view_test_ins as + on insert to def_view_test + do instead insert into def_test select new.* +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE def_view_test_ins AS ON INSERT TO def_view_test DO INSTEAD INSERT INTO def_test SELEC..." +== 533 +-- truncate_limit: 100 +insert into def_view_test default values +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO def_view_test DEFAULT VALUES" +== 534 +-- truncate_limit: 100 +alter table def_view_test alter column c1 set default 45 +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_view_test ALTER COLUMN c1 SET DEFAULT 45" +== 535 +-- truncate_limit: 100 +insert into def_view_test default values +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO def_view_test DEFAULT VALUES" +== 536 +-- truncate_limit: 100 +alter table def_view_test alter column c2 set default 'view_default' +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE def_view_test ALTER COLUMN c2 SET DEFAULT 'view_default'" +== 537 +-- truncate_limit: 100 +insert into def_view_test default values +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO def_view_test DEFAULT VALUES" +== 538 +-- truncate_limit: 100 +select * from def_view_test +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM def_view_test" +== 539 +-- truncate_limit: 100 +drop rule def_view_test_ins on def_view_test +-- +TABLE: name="def_view_test" schema="" table="def_view_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE def_view_test_ins ON def_view_test" +== 540 +-- truncate_limit: 100 +drop view def_view_test +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW def_view_test" +== 541 +-- truncate_limit: 100 +drop table def_test +-- +TABLE: name="def_test" schema="" table="def_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE def_test" +== 542 +-- truncate_limit: 100 +-- alter table / drop column tests +-- try altering system catalogs, should fail +alter table pg_class drop column relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pg_class DROP relname" +== 543 +-- truncate_limit: 100 +-- try altering non-existent table, should fail +alter table nosuchtable drop column bar +-- +TABLE: name="nosuchtable" schema="" table="nosuchtable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE nosuchtable DROP bar" +== 544 +-- truncate_limit: 100 +-- test dropping columns +create table atacc1 (a int4 not null, b int4, c int4 not null, d int4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (a int4 NOT NULL, b int4, c int4 NOT NULL, d int4)" +== 545 +-- truncate_limit: 100 +insert into atacc1 values (1, 2, 3, 4) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (1, 2, 3, 4)" +== 546 +-- truncate_limit: 100 +alter table atacc1 drop a +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP a" +== 547 +-- truncate_limit: 100 +alter table atacc1 drop a +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP a" +== 548 +-- truncate_limit: 100 +-- SELECTs +select * from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atacc1" +== 549 +-- truncate_limit: 100 +select * from atacc1 order by a +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atacc1 ORDER BY a" +== 550 +-- truncate_limit: 100 +select * from atacc1 order by "........pg.dropped.1........" +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atacc1 ORDER BY \"........pg.dropped.1........\"" +== 551 +-- truncate_limit: 100 +select * from atacc1 group by a +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atacc1 GROUP BY a" +== 552 +-- truncate_limit: 100 +select * from atacc1 group by "........pg.dropped.1........" +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atacc1 GROUP BY \"........pg.dropped.1........\"" +== 553 +-- truncate_limit: 100 +select atacc1.* from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT atacc1.* FROM atacc1" +== 554 +-- truncate_limit: 100 +select a from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a FROM atacc1" +== 555 +-- truncate_limit: 100 +select atacc1.a from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT atacc1.a FROM atacc1" +== 556 +-- truncate_limit: 100 +select b,c,d from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b, c, d FROM atacc1" +== 557 +-- truncate_limit: 100 +select a,b,c,d from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c, d FROM atacc1" +== 558 +-- truncate_limit: 100 +select * from atacc1 where a = 1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atacc1 WHERE a = 1" +== 559 +-- truncate_limit: 100 +select "........pg.dropped.1........" from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT \"........pg.dropped.1........\" FROM atacc1" +== 560 +-- truncate_limit: 100 +select atacc1."........pg.dropped.1........" from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT atacc1.\"........pg.dropped.1........\" FROM atacc1" +== 561 +-- truncate_limit: 100 +select "........pg.dropped.1........",b,c,d from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT \"........pg.dropped.1........\", b, c, d FROM atacc1" +== 562 +-- truncate_limit: 100 +select * from atacc1 where "........pg.dropped.1........" = 1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +FILTER: schema="" table="" column="........pg.dropped.1........" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atacc1 WHERE \"........pg.dropped.1........\" = 1" +== 563 +-- truncate_limit: 100 +-- UPDATEs +update atacc1 set a = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atacc1 SET a = 3" +== 564 +-- truncate_limit: 100 +update atacc1 set b = 2 where a = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atacc1 SET b = 2 WHERE a = 3" +== 565 +-- truncate_limit: 100 +update atacc1 set "........pg.dropped.1........" = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atacc1 SET \"........pg.dropped.1........\" = 3" +== 566 +-- truncate_limit: 100 +update atacc1 set b = 2 where "........pg.dropped.1........" = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atacc1 SET b = 2 WHERE \"........pg.dropped.1........\" = 3" +== 567 +-- truncate_limit: 100 +-- INSERTs +insert into atacc1 values (10, 11, 12, 13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (10, 11, 12, 13)" +== 568 +-- truncate_limit: 100 +insert into atacc1 values (default, 11, 12, 13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (DEFAULT, 11, 12, 13)" +== 569 +-- truncate_limit: 100 +insert into atacc1 values (11, 12, 13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (11, 12, 13)" +== 570 +-- truncate_limit: 100 +insert into atacc1 (a) values (10) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (a) VALUES (10)" +== 571 +-- truncate_limit: 100 +insert into atacc1 (a) values (default) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (a) VALUES (DEFAULT)" +== 572 +-- truncate_limit: 100 +insert into atacc1 (a,b,c,d) values (10,11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (a, b, c, d) VALUES (10, 11, 12, 13)" +== 573 +-- truncate_limit: 100 +insert into atacc1 (a,b,c,d) values (default,11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (a, b, c, d) VALUES (DEFAULT, 11, 12, 13)" +== 574 +-- truncate_limit: 100 +insert into atacc1 (b,c,d) values (11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (b, c, d) VALUES (11, 12, 13)" +== 575 +-- truncate_limit: 100 +insert into atacc1 ("........pg.dropped.1........") values (10) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (\"........pg.dropped.1........\") VALUES (10)" +== 576 +-- truncate_limit: 100 +insert into atacc1 ("........pg.dropped.1........") values (default) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (\"........pg.dropped.1........\") VALUES (DEFAULT)" +== 577 +-- truncate_limit: 100 +insert into atacc1 ("........pg.dropped.1........",b,c,d) values (10,11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (\"........pg.dropped.1........\", b, c, d) VALUES (10, 11, 12, 13)" +== 578 +-- truncate_limit: 100 +insert into atacc1 ("........pg.dropped.1........",b,c,d) values (default,11,12,13) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (\"........pg.dropped.1........\", b, c, d) VALUES (DEFAULT, 11, 12, 13)" +== 579 +-- truncate_limit: 100 +-- DELETEs +delete from atacc1 where a = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atacc1 WHERE a = 3" +== 580 +-- truncate_limit: 100 +delete from atacc1 where "........pg.dropped.1........" = 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atacc1 WHERE \"........pg.dropped.1........\" = 3" +== 581 +-- truncate_limit: 100 +delete from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atacc1" +== 582 +-- truncate_limit: 100 +-- try dropping a non-existent column, should fail +alter table atacc1 drop bar +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP bar" +== 583 +-- truncate_limit: 100 +-- try removing an oid column, should succeed (as it's nonexistent) +alter table atacc1 SET WITHOUT OIDS +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 SET WITHOUT OIDS" +== 584 +-- truncate_limit: 100 +-- try adding an oid column, should fail (not supported) +alter table atacc1 SET WITH OIDS +-- +ERROR: syntax error at or near "WITH" +CURSORPOS: 81 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 585 +-- truncate_limit: 100 +-- try dropping the xmin column, should fail +alter table atacc1 drop xmin +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP xmin" +== 586 +-- truncate_limit: 100 +-- try creating a view and altering that, should fail +create view myview as select * from atacc1 +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW myview AS SELECT * FROM atacc1" +== 587 +-- truncate_limit: 100 +select * from myview +-- +TABLE: name="myview" schema="" table="myview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM myview" +== 588 +-- truncate_limit: 100 +alter table myview drop d +-- +TABLE: name="myview" schema="" table="myview" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE myview DROP d" +== 589 +-- truncate_limit: 100 +drop view myview +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW myview" +== 590 +-- truncate_limit: 100 +-- test some commands to make sure they fail on the dropped column +analyze atacc1(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE atacc1(a)" +== 591 +-- truncate_limit: 100 +analyze atacc1("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE atacc1(\"........pg.dropped.1........\")" +== 592 +-- truncate_limit: 100 +vacuum analyze atacc1(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) atacc1(a)" +== 593 +-- truncate_limit: 100 +vacuum analyze atacc1("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) atacc1(\"........pg.dropped.1........\")" +== 594 +-- truncate_limit: 100 +comment on column atacc1.a is 'testing' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN atacc1.a IS 'testing'" +== 595 +-- truncate_limit: 100 +comment on column atacc1."........pg.dropped.1........" is 'testing' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN atacc1.\"........pg.dropped.1........\" IS 'testing'" +== 596 +-- truncate_limit: 100 +alter table atacc1 alter a set storage plain +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN a SET STORAGE plain" +== 597 +-- truncate_limit: 100 +alter table atacc1 alter "........pg.dropped.1........" set storage plain +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN \"........pg.dropped.1........\" SET STORAGE plain" +== 598 +-- truncate_limit: 100 +alter table atacc1 alter a set statistics 0 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN a SET STATISTICS 0" +== 599 +-- truncate_limit: 100 +alter table atacc1 alter "........pg.dropped.1........" set statistics 0 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN \"........pg.dropped.1........\" SET STATISTICS 0" +== 600 +-- truncate_limit: 100 +alter table atacc1 alter a set default 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN a SET DEFAULT 3" +== 601 +-- truncate_limit: 100 +alter table atacc1 alter "........pg.dropped.1........" set default 3 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN \"........pg.dropped.1........\" SET DEFAULT 3" +== 602 +-- truncate_limit: 100 +alter table atacc1 alter a drop default +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN a DROP DEFAULT" +== 603 +-- truncate_limit: 100 +alter table atacc1 alter "........pg.dropped.1........" drop default +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN \"........pg.dropped.1........\" DROP DEFAULT" +== 604 +-- truncate_limit: 100 +alter table atacc1 alter a set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN a SET NOT NULL" +== 605 +-- truncate_limit: 100 +alter table atacc1 alter "........pg.dropped.1........" set not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN \"........pg.dropped.1........\" SET NOT NULL" +== 606 +-- truncate_limit: 100 +alter table atacc1 alter a drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN a DROP NOT NULL" +== 607 +-- truncate_limit: 100 +alter table atacc1 alter "........pg.dropped.1........" drop not null +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ALTER COLUMN \"........pg.dropped.1........\" DROP NOT NULL" +== 608 +-- truncate_limit: 100 +alter table atacc1 rename a to x +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE atacc1 RENAME COLUMN a TO x" +== 609 +-- truncate_limit: 100 +alter table atacc1 rename "........pg.dropped.1........" to x +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE atacc1 RENAME COLUMN \"........pg.dropped.1........\" TO x" +== 610 +-- truncate_limit: 100 +alter table atacc1 add primary key(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD PRIMARY KEY (a)" +== 611 +-- truncate_limit: 100 +alter table atacc1 add primary key("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD PRIMARY KEY (\"........pg.dropped.1........\")" +== 612 +-- truncate_limit: 100 +alter table atacc1 add unique(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD UNIQUE (a)" +== 613 +-- truncate_limit: 100 +alter table atacc1 add unique("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD UNIQUE (\"........pg.dropped.1........\")" +== 614 +-- truncate_limit: 100 +alter table atacc1 add check (a > 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CHECK (a > 3)" +== 615 +-- truncate_limit: 100 +alter table atacc1 add check ("........pg.dropped.1........" > 3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD CHECK (\"........pg.dropped.1........\" > 3)" +== 616 +-- truncate_limit: 100 +create table atacc2 (id int4 unique) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc2 (id int4 UNIQUE)" +== 617 +-- truncate_limit: 100 +alter table atacc1 add foreign key (a) references atacc2(id) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD FOREIGN KEY (a) REFERENCES atacc2 (id)" +== 618 +-- truncate_limit: 100 +alter table atacc1 add foreign key ("........pg.dropped.1........") references atacc2(id) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD FOREIGN KEY (\"........pg.dropped.1........\") REFERENCES atacc2 (id)" +== 619 +-- truncate_limit: 100 +alter table atacc2 add foreign key (id) references atacc1(a) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc2 ADD FOREIGN KEY (id) REFERENCES atacc1 (a)" +== 620 +-- truncate_limit: 100 +alter table atacc2 add foreign key (id) references atacc1("........pg.dropped.1........") +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc2 ADD FOREIGN KEY (id) REFERENCES atacc1 (\"........pg.dropped.1........\")" +== 621 +-- truncate_limit: 100 +drop table atacc2 +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc2" +== 622 +-- truncate_limit: 100 +create index "testing_idx" on atacc1(a) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX testing_idx ON atacc1 USING btree (a)" +== 623 +-- truncate_limit: 100 +create index "testing_idx" on atacc1("........pg.dropped.1........") +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX testing_idx ON atacc1 USING btree (\"........pg.dropped.1........\")" +== 624 +-- truncate_limit: 100 +-- test create as and select into +insert into atacc1 values (21, 22, 23) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 VALUES (21, 22, 23)" +== 625 +-- truncate_limit: 100 +create table attest1 as select * from atacc1 +-- +TABLE: name="attest1" schema="" table="attest1" ctx=DDL +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE attest1 AS SELECT * FROM atacc1" +== 626 +-- truncate_limit: 100 +select * from attest1 +-- +TABLE: name="attest1" schema="" table="attest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attest1" +== 627 +-- truncate_limit: 100 +drop table attest1 +-- +TABLE: name="attest1" schema="" table="attest1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attest1" +== 628 +-- truncate_limit: 100 +select * into attest2 from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +TABLE: name="attest2" schema="" table="attest2" ctx=DDL +STMT: SelectStmt +TRUNCATED: "SELECT * INTO attest2 FROM atacc1" +== 629 +-- truncate_limit: 100 +select * from attest2 +-- +TABLE: name="attest2" schema="" table="attest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attest2" +== 630 +-- truncate_limit: 100 +drop table attest2 +-- +TABLE: name="attest2" schema="" table="attest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attest2" +== 631 +-- truncate_limit: 100 +-- try dropping all columns +alter table atacc1 drop c +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP c" +== 632 +-- truncate_limit: 100 +alter table atacc1 drop d +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP d" +== 633 +-- truncate_limit: 100 +alter table atacc1 drop b +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP b" +== 634 +-- truncate_limit: 100 +select * from atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atacc1" +== 635 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 636 +-- truncate_limit: 100 +-- test constraint error reporting in presence of dropped columns +create table atacc1 (id serial primary key, value int check (value < 10)) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (id serial PRIMARY KEY, value int CHECK (value < 10))" +== 637 +-- truncate_limit: 100 +insert into atacc1(value) values (100) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (value) VALUES (100)" +== 638 +-- truncate_limit: 100 +alter table atacc1 drop column value +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 DROP value" +== 639 +-- truncate_limit: 100 +alter table atacc1 add column value int check (value < 10) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atacc1 ADD COLUMN value int CHECK (value < 10)" +== 640 +-- truncate_limit: 100 +insert into atacc1(value) values (100) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (value) VALUES (100)" +== 641 +-- truncate_limit: 100 +insert into atacc1(id, value) values (null, 0) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (id, value) VALUES (NULL, 0)" +== 642 +-- truncate_limit: 100 +drop table atacc1 +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1" +== 643 +-- truncate_limit: 100 +-- test inheritance +create table parent (a int, b int, c int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a int, b int, c int)" +== 644 +-- truncate_limit: 100 +insert into parent values (1, 2, 3) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES (1, 2, 3)" +== 645 +-- truncate_limit: 100 +alter table parent drop a +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent DROP a" +== 646 +-- truncate_limit: 100 +create table child (d varchar(255)) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child (d varchar(255)) INHERITS (parent)" +== 647 +-- truncate_limit: 100 +insert into child values (12, 13, 'testing') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child VALUES (12, 13, 'testing')" +== 648 +-- truncate_limit: 100 +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 649 +-- truncate_limit: 100 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM child" +== 650 +-- truncate_limit: 100 +alter table parent drop c +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent DROP c" +== 651 +-- truncate_limit: 100 +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 652 +-- truncate_limit: 100 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM child" +== 653 +-- truncate_limit: 100 +drop table child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE child" +== 654 +-- truncate_limit: 100 +drop table parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent" +== 655 +-- truncate_limit: 100 +-- check error cases for inheritance column merging +create table parent (a float8, b numeric(10,4), c text collate "C") +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a float8, b numeric(10, 4), c text COLLATE \"C\")" +== 656 +-- truncate_limit: 100 +create table child (a float4) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child (a float4) INHERITS (parent)" +== 657 +-- truncate_limit: 100 +-- fail +create table child (b decimal(10,7)) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child (b numeric(10, 7)) INHERITS (parent)" +== 658 +-- truncate_limit: 100 +-- fail +create table child (c text collate "POSIX") inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child (c text COLLATE \"POSIX\") INHERITS (parent)" +== 659 +-- truncate_limit: 100 +-- fail +create table child (a double precision, b decimal(10,4)) inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child (a double precision, b numeric(10, 4)) INHERITS (parent)" +== 660 +-- truncate_limit: 100 +drop table child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE child" +== 661 +-- truncate_limit: 100 +drop table parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent" +== 662 +-- truncate_limit: 100 +-- test copy in/out +create table attest (a int4, b int4, c int4) +-- +TABLE: name="attest" schema="" table="attest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attest (a int4, b int4, c int4)" +== 663 +-- truncate_limit: 100 +insert into attest values (1,2,3) +-- +TABLE: name="attest" schema="" table="attest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attest VALUES (1, 2, 3)" +== 664 +-- truncate_limit: 100 +alter table attest drop a +-- +TABLE: name="attest" schema="" table="attest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attest DROP a" +== 665 +-- truncate_limit: 100 +copy attest to stdout +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY attest TO STDOUT" +== 666 +-- truncate_limit: 100 +copy attest(a) to stdout +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY attest(a) TO STDOUT" +== 667 +-- truncate_limit: 100 +copy attest("........pg.dropped.1........") to stdout +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY attest(\"........pg.dropped.1........\") TO STDOUT" +== 668 +-- truncate_limit: 100 +copy attest from stdin +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY attest FROM STDIN" +== 669 +-- truncate_limit: 100 +select * from attest +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attest" +== 670 +-- truncate_limit: 100 +copy attest from stdin +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY attest FROM STDIN" +== 671 +-- truncate_limit: 100 +select * from attest +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attest" +== 672 +-- truncate_limit: 100 +copy attest(a) from stdin +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY attest(a) FROM STDIN" +== 673 +-- truncate_limit: 100 +select * from attest +-- +TABLE: name="attest" schema="" table="attest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM attest" +== 674 +-- truncate_limit: 100 +drop table attest +-- +TABLE: name="attest" schema="" table="attest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attest" +== 675 +-- truncate_limit: 100 +-- test inheritance + +create table dropColumn (a int, b int, e int) +-- +TABLE: name="dropcolumn" schema="" table="dropcolumn" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dropcolumn (a int, b int, e int)" +== 676 +-- truncate_limit: 100 +create table dropColumnChild (c int) inherits (dropColumn) +-- +TABLE: name="dropcolumnchild" schema="" table="dropcolumnchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dropcolumnchild (c int) INHERITS (dropcolumn)" +== 677 +-- truncate_limit: 100 +create table dropColumnAnother (d int) inherits (dropColumnChild) +-- +TABLE: name="dropcolumnanother" schema="" table="dropcolumnanother" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dropcolumnanother (d int) INHERITS (dropcolumnchild)" +== 678 +-- truncate_limit: 100 +-- these two should fail +alter table dropColumnchild drop column a +-- +TABLE: name="dropcolumnchild" schema="" table="dropcolumnchild" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE dropcolumnchild DROP a" +== 679 +-- truncate_limit: 100 +alter table only dropColumnChild drop column b +-- +TABLE: name="dropcolumnchild" schema="" table="dropcolumnchild" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY dropcolumnchild DROP b" +== 680 +-- truncate_limit: 100 +-- these three should work +alter table only dropColumn drop column e +-- +TABLE: name="dropcolumn" schema="" table="dropcolumn" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY dropcolumn DROP e" +== 681 +-- truncate_limit: 100 +alter table dropColumnChild drop column c +-- +TABLE: name="dropcolumnchild" schema="" table="dropcolumnchild" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE dropcolumnchild DROP c" +== 682 +-- truncate_limit: 100 +alter table dropColumn drop column a +-- +TABLE: name="dropcolumn" schema="" table="dropcolumn" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE dropcolumn DROP a" +== 683 +-- truncate_limit: 100 +create table renameColumn (a int) +-- +TABLE: name="renamecolumn" schema="" table="renamecolumn" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE renamecolumn (a int)" +== 684 +-- truncate_limit: 100 +create table renameColumnChild (b int) inherits (renameColumn) +-- +TABLE: name="renamecolumnchild" schema="" table="renamecolumnchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE renamecolumnchild (b int) INHERITS (renamecolumn)" +== 685 +-- truncate_limit: 100 +create table renameColumnAnother (c int) inherits (renameColumnChild) +-- +TABLE: name="renamecolumnanother" schema="" table="renamecolumnanother" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE renamecolumnanother (c int) INHERITS (renamecolumnchild)" +== 686 +-- truncate_limit: 100 +-- these three should fail +alter table renameColumnChild rename column a to d +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE renamecolumnchild RENAME COLUMN a TO d" +== 687 +-- truncate_limit: 100 +alter table only renameColumnChild rename column a to d +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE ONLY renamecolumnchild RENAME COLUMN a TO d" +== 688 +-- truncate_limit: 100 +alter table only renameColumn rename column a to d +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE ONLY renamecolumn RENAME COLUMN a TO d" +== 689 +-- truncate_limit: 100 +-- these should work +alter table renameColumn rename column a to d +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE renamecolumn RENAME COLUMN a TO d" +== 690 +-- truncate_limit: 100 +alter table renameColumnChild rename column b to a +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE renamecolumnchild RENAME COLUMN b TO a" +== 691 +-- truncate_limit: 100 +-- these should work +alter table if exists doesnt_exist_tab rename column a to d +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE IF EXISTS doesnt_exist_tab RENAME COLUMN a TO d" +== 692 +-- truncate_limit: 100 +alter table if exists doesnt_exist_tab rename column b to a +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE IF EXISTS doesnt_exist_tab RENAME COLUMN b TO a" +== 693 +-- truncate_limit: 100 +-- this should work +alter table renameColumn add column w int +-- +TABLE: name="renamecolumn" schema="" table="renamecolumn" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE renamecolumn ADD COLUMN w int" +== 694 +-- truncate_limit: 100 +-- this should fail +alter table only renameColumn add column x int +-- +TABLE: name="renamecolumn" schema="" table="renamecolumn" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY renamecolumn ADD COLUMN x int" +== 695 +-- truncate_limit: 100 +-- Test corner cases in dropping of inherited columns + +create table p1 (f1 int, f2 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int, f2 int)" +== 696 +-- truncate_limit: 100 +create table c1 (f1 int not null) inherits(p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 (f1 int NOT NULL) INHERITS (p1)" +== 697 +-- truncate_limit: 100 +-- should be rejected since c1.f1 is inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c1 DROP f1" +== 698 +-- truncate_limit: 100 +-- should work +alter table p1 drop column f1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 DROP f1" +== 699 +-- truncate_limit: 100 +-- c1.f1 is still there, but no longer inherited +select f1 from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM c1" +== 700 +-- truncate_limit: 100 +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c1 DROP f1" +== 701 +-- truncate_limit: 100 +select f1 from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM c1" +== 702 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 703 +-- truncate_limit: 100 +create table p1 (f1 int, f2 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int, f2 int)" +== 704 +-- truncate_limit: 100 +create table c1 () inherits(p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 () INHERITS (p1)" +== 705 +-- truncate_limit: 100 +-- should be rejected since c1.f1 is inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c1 DROP f1" +== 706 +-- truncate_limit: 100 +alter table p1 drop column f1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 DROP f1" +== 707 +-- truncate_limit: 100 +-- c1.f1 is dropped now, since there is no local definition for it +select f1 from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM c1" +== 708 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 709 +-- truncate_limit: 100 +create table p1 (f1 int, f2 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int, f2 int)" +== 710 +-- truncate_limit: 100 +create table c1 () inherits(p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 () INHERITS (p1)" +== 711 +-- truncate_limit: 100 +-- should be rejected since c1.f1 is inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c1 DROP f1" +== 712 +-- truncate_limit: 100 +alter table only p1 drop column f1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY p1 DROP f1" +== 713 +-- truncate_limit: 100 +-- c1.f1 is NOT dropped, but must now be considered non-inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c1 DROP f1" +== 714 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 715 +-- truncate_limit: 100 +create table p1 (f1 int, f2 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int, f2 int)" +== 716 +-- truncate_limit: 100 +create table c1 (f1 int not null) inherits(p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 (f1 int NOT NULL) INHERITS (p1)" +== 717 +-- truncate_limit: 100 +-- should be rejected since c1.f1 is inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c1 DROP f1" +== 718 +-- truncate_limit: 100 +alter table only p1 drop column f1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY p1 DROP f1" +== 719 +-- truncate_limit: 100 +-- c1.f1 is still there, but no longer inherited +alter table c1 drop column f1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c1 DROP f1" +== 720 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 721 +-- truncate_limit: 100 +create table p1(id int, name text) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (id int, name text)" +== 722 +-- truncate_limit: 100 +create table p2(id2 int, name text, height int) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p2 (id2 int, name text, height int)" +== 723 +-- truncate_limit: 100 +create table c1(age int) inherits(p1,p2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 (age int) INHERITS (p1, p2)" +== 724 +-- truncate_limit: 100 +create table gc1() inherits (c1) +-- +TABLE: name="gc1" schema="" table="gc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gc1 () INHERITS (c1)" +== 725 +-- truncate_limit: 100 +select relname, attname, attinhcount, attislocal +from pg_class join pg_attribute on (pg_class.oid = pg_attribute.attrelid) +where relname in ('p1','p2','c1','gc1') and attnum > 0 and not attisdropped +order by relname, attnum +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attisdropped" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class JOIN pg_attribute ON pg_class.oid = pg_attribute.attrelid WHERE ... ORDE..." +== 726 +-- truncate_limit: 100 +-- should work +alter table only p1 drop column name +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY p1 DROP name" +== 727 +-- truncate_limit: 100 +-- should work. Now c1.name is local and inhcount is 0. +alter table p2 drop column name +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p2 DROP name" +== 728 +-- truncate_limit: 100 +-- should be rejected since its inherited +alter table gc1 drop column name +-- +TABLE: name="gc1" schema="" table="gc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE gc1 DROP name" +== 729 +-- truncate_limit: 100 +-- should work, and drop gc1.name along +alter table c1 drop column name +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c1 DROP name" +== 730 +-- truncate_limit: 100 +-- should fail: column does not exist +alter table gc1 drop column name +-- +TABLE: name="gc1" schema="" table="gc1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE gc1 DROP name" +== 731 +-- truncate_limit: 100 +-- should work and drop the attribute in all tables +alter table p2 drop column height +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p2 DROP height" +== 732 +-- truncate_limit: 100 +-- IF EXISTS test +create table dropColumnExists () +-- +TABLE: name="dropcolumnexists" schema="" table="dropcolumnexists" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dropcolumnexists ()" +== 733 +-- truncate_limit: 100 +alter table dropColumnExists drop column non_existing +-- +TABLE: name="dropcolumnexists" schema="" table="dropcolumnexists" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE dropcolumnexists DROP non_existing" +== 734 +-- truncate_limit: 100 +--fail +alter table dropColumnExists drop column if exists non_existing +-- +TABLE: name="dropcolumnexists" schema="" table="dropcolumnexists" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE dropcolumnexists DROP IF EXISTS non_existing" +== 735 +-- truncate_limit: 100 +--succeed + +select relname, attname, attinhcount, attislocal +from pg_class join pg_attribute on (pg_class.oid = pg_attribute.attrelid) +where relname in ('p1','p2','c1','gc1') and attnum > 0 and not attisdropped +order by relname, attnum +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attisdropped" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class JOIN pg_attribute ON pg_class.oid = pg_attribute.attrelid WHERE ... ORDE..." +== 736 +-- truncate_limit: 100 +drop table p1, p2 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1, p2 CASCADE" +== 737 +-- truncate_limit: 100 +-- test attinhcount tracking with merged columns + +create table depth0() +-- +TABLE: name="depth0" schema="" table="depth0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE depth0 ()" +== 738 +-- truncate_limit: 100 +create table depth1(c text) inherits (depth0) +-- +TABLE: name="depth1" schema="" table="depth1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE depth1 (c text) INHERITS (depth0)" +== 739 +-- truncate_limit: 100 +create table depth2() inherits (depth1) +-- +TABLE: name="depth2" schema="" table="depth2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE depth2 () INHERITS (depth1)" +== 740 +-- truncate_limit: 100 +alter table depth0 add c text +-- +TABLE: name="depth0" schema="" table="depth0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE depth0 ADD COLUMN c text" +== 741 +-- truncate_limit: 100 +select attrelid::regclass, attname, attinhcount, attislocal +from pg_attribute +where attnum > 0 and attrelid::regclass in ('depth0', 'depth1', 'depth2') +order by attrelid::regclass::text, attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE ... ORDER BY attrelid::regclass::text, attnum" +== 742 +-- truncate_limit: 100 +-- test renumbering of child-table columns in inherited operations + +create table p1 (f1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int)" +== 743 +-- truncate_limit: 100 +create table c1 (f2 text, f3 int) inherits (p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 (f2 text, f3 int) INHERITS (p1)" +== 744 +-- truncate_limit: 100 +alter table p1 add column a1 int check (a1 > 0) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 ADD COLUMN a1 int CHECK (a1 > 0)" +== 745 +-- truncate_limit: 100 +alter table p1 add column f2 text +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 ADD COLUMN f2 text" +== 746 +-- truncate_limit: 100 +insert into p1 values (1,2,'abc') +-- +TABLE: name="p1" schema="" table="p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO p1 VALUES (1, 2, 'abc')" +== 747 +-- truncate_limit: 100 +insert into c1 values(11,'xyz',33,0) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c1 VALUES (11, 'xyz', 33, 0)" +== 748 +-- truncate_limit: 100 +-- should fail +insert into c1 values(11,'xyz',33,22) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c1 VALUES (11, 'xyz', 33, 22)" +== 749 +-- truncate_limit: 100 +select * from p1 +-- +TABLE: name="p1" schema="" table="p1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM p1" +== 750 +-- truncate_limit: 100 +update p1 set a1 = a1 + 1, f2 = upper(f2) +-- +TABLE: name="p1" schema="" table="p1" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE p1 SET a1 = a1 + 1, f2 = upper(f2)" +== 751 +-- truncate_limit: 100 +select * from p1 +-- +TABLE: name="p1" schema="" table="p1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM p1" +== 752 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 753 +-- truncate_limit: 100 +-- test that operations with a dropped column do not try to reference +-- its datatype + +create domain mytype as text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN mytype AS text" +== 754 +-- truncate_limit: 100 +create temp table foo (f1 text, f2 mytype, f3 text) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (f1 text, f2 mytype, f3 text)" +== 755 +-- truncate_limit: 100 +insert into foo values('bb','cc','dd') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES ('bb', 'cc', 'dd')" +== 756 +-- truncate_limit: 100 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 757 +-- truncate_limit: 100 +drop domain mytype cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN mytype CASCADE" +== 758 +-- truncate_limit: 100 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 759 +-- truncate_limit: 100 +insert into foo values('qq','rr') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES ('qq', 'rr')" +== 760 +-- truncate_limit: 100 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 761 +-- truncate_limit: 100 +update foo set f3 = 'zz' +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE foo SET f3 = 'zz'" +== 762 +-- truncate_limit: 100 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 763 +-- truncate_limit: 100 +select f3,max(f1) from foo group by f3 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, max(f1) FROM foo GROUP BY f3" +== 764 +-- truncate_limit: 100 +-- Simple tests for alter table column type +alter table foo alter f1 TYPE integer +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE foo ALTER COLUMN f1 TYPE int" +== 765 +-- truncate_limit: 100 +-- fails +alter table foo alter f1 TYPE varchar(10) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE foo ALTER COLUMN f1 TYPE varchar(10)" +== 766 +-- truncate_limit: 100 +create table anothertab (atcol1 serial8, atcol2 boolean, + constraint anothertab_chk check (atcol1 <= 3)) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE anothertab (atcol1 serial8, atcol2 boolean, CONSTRAINT anothertab_chk CHECK (atcol1 ..." +== 767 +-- truncate_limit: 100 +insert into anothertab (atcol1, atcol2) values (default, true) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO anothertab (atcol1, atcol2) VALUES (DEFAULT, true)" +== 768 +-- truncate_limit: 100 +insert into anothertab (atcol1, atcol2) values (default, false) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO anothertab (atcol1, atcol2) VALUES (DEFAULT, false)" +== 769 +-- truncate_limit: 100 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM anothertab" +== 770 +-- truncate_limit: 100 +alter table anothertab alter column atcol1 type boolean +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN atcol1 TYPE boolean" +== 771 +-- truncate_limit: 100 +-- fails +alter table anothertab alter column atcol1 type boolean using atcol1::int +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN atcol1 TYPE boolean USING atcol1::int" +== 772 +-- truncate_limit: 100 +-- fails +alter table anothertab alter column atcol1 type integer +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN atcol1 TYPE int" +== 773 +-- truncate_limit: 100 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM anothertab" +== 774 +-- truncate_limit: 100 +insert into anothertab (atcol1, atcol2) values (45, null) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO anothertab (atcol1, atcol2) VALUES (45, NULL)" +== 775 +-- truncate_limit: 100 +-- fails +insert into anothertab (atcol1, atcol2) values (default, null) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO anothertab (atcol1, atcol2) VALUES (DEFAULT, NULL)" +== 776 +-- truncate_limit: 100 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM anothertab" +== 777 +-- truncate_limit: 100 +alter table anothertab alter column atcol2 type text + using case when atcol2 is true then 'IT WAS TRUE' + when atcol2 is false then 'IT WAS FALSE' + else 'IT WAS NULL!' end +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN atcol2 TYPE text USING CASE WHEN atcol2 IS TRUE THEN 'IT WAS ..." +== 778 +-- truncate_limit: 100 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM anothertab" +== 779 +-- truncate_limit: 100 +alter table anothertab alter column atcol1 type boolean + using case when atcol1 % 2 = 0 then true else false end +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN atcol1 TYPE boolean USING CASE WHEN (atcol1 % 2) = 0 THEN tru..." +== 780 +-- truncate_limit: 100 +-- fails +alter table anothertab alter column atcol1 drop default +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN atcol1 DROP DEFAULT" +== 781 +-- truncate_limit: 100 +alter table anothertab alter column atcol1 type boolean + using case when atcol1 % 2 = 0 then true else false end +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN atcol1 TYPE boolean USING CASE WHEN (atcol1 % 2) = 0 THEN tru..." +== 782 +-- truncate_limit: 100 +-- fails +alter table anothertab drop constraint anothertab_chk +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab DROP CONSTRAINT anothertab_chk" +== 783 +-- truncate_limit: 100 +alter table anothertab drop constraint anothertab_chk +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab DROP CONSTRAINT anothertab_chk" +== 784 +-- truncate_limit: 100 +-- fails +alter table anothertab drop constraint IF EXISTS anothertab_chk +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab DROP CONSTRAINT IF EXISTS anothertab_chk" +== 785 +-- truncate_limit: 100 +-- succeeds + +alter table anothertab alter column atcol1 type boolean + using case when atcol1 % 2 = 0 then true else false end +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN atcol1 TYPE boolean USING CASE WHEN (atcol1 % 2) = 0 THEN tru..." +== 786 +-- truncate_limit: 100 +select * from anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM anothertab" +== 787 +-- truncate_limit: 100 +drop table anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE anothertab" +== 788 +-- truncate_limit: 100 +-- Test index handling in alter table column type (cf. bugs #15835, #15865) +create table anothertab(f1 int primary key, f2 int unique, + f3 int, f4 int, f5 int) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE anothertab (f1 int PRIMARY KEY, f2 int UNIQUE, f3 int, f4 int, f5 int)" +== 789 +-- truncate_limit: 100 +alter table anothertab + add exclude using btree (f3 with =) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ADD EXCLUDE (f3 WITH =)" +== 790 +-- truncate_limit: 100 +alter table anothertab + add exclude using btree (f4 with =) where (f4 is not null) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ADD EXCLUDE (f4 WITH =) WHERE (f4 IS NOT NULL)" +== 791 +-- truncate_limit: 100 +alter table anothertab + add exclude using btree (f4 with =) where (f5 > 0) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ADD EXCLUDE (f4 WITH =) WHERE (f5 > 0)" +== 792 +-- truncate_limit: 100 +alter table anothertab + add unique(f1,f4) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ADD UNIQUE (f1, f4)" +== 793 +-- truncate_limit: 100 +create index on anothertab(f2,f3) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON anothertab USING btree (f2, f3)" +== 794 +-- truncate_limit: 100 +create unique index on anothertab(f4) +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON anothertab USING btree (f4)" +== 795 +-- truncate_limit: 100 +alter table anothertab alter column f1 type bigint +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN f1 TYPE bigint" +== 796 +-- truncate_limit: 100 +alter table anothertab + alter column f2 type bigint, + alter column f3 type bigint, + alter column f4 type bigint +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN f2 TYPE bigint, ALTER COLUMN f3 TYPE bigint, ALTER COLUMN f4 ..." +== 797 +-- truncate_limit: 100 +alter table anothertab alter column f5 type bigint +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE anothertab ALTER COLUMN f5 TYPE bigint" +== 798 +-- truncate_limit: 100 +drop table anothertab +-- +TABLE: name="anothertab" schema="" table="anothertab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE anothertab" +== 799 +-- truncate_limit: 100 +-- test that USING expressions are parsed before column alter type / drop steps +create table another (f1 int, f2 text, f3 text) +-- +TABLE: name="another" schema="" table="another" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE another (f1 int, f2 text, f3 text)" +== 800 +-- truncate_limit: 100 +insert into another values(1, 'one', 'uno') +-- +TABLE: name="another" schema="" table="another" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO another VALUES (1, 'one', 'uno')" +== 801 +-- truncate_limit: 100 +insert into another values(2, 'two', 'due') +-- +TABLE: name="another" schema="" table="another" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO another VALUES (2, 'two', 'due')" +== 802 +-- truncate_limit: 100 +insert into another values(3, 'three', 'tre') +-- +TABLE: name="another" schema="" table="another" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO another VALUES (3, 'three', 'tre')" +== 803 +-- truncate_limit: 100 +select * from another +-- +TABLE: name="another" schema="" table="another" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM another" +== 804 +-- truncate_limit: 100 +alter table another + alter f1 type text using f2 || ' and ' || f3 || ' more', + alter f2 type bigint using f1 * 10, + drop column f3 +-- +TABLE: name="another" schema="" table="another" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE another ALTER COLUMN f1 TYPE text USING ((f2 || ' and ') || f3) || ' more', ALTER COL..." +== 805 +-- truncate_limit: 100 +select * from another +-- +TABLE: name="another" schema="" table="another" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM another" +== 806 +-- truncate_limit: 100 +drop table another +-- +TABLE: name="another" schema="" table="another" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE another" +== 807 +-- truncate_limit: 100 +-- Create an index that skips WAL, then perform a SET DATA TYPE that skips +-- rewriting the index. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 808 +-- truncate_limit: 100 +create table skip_wal_skip_rewrite_index (c varchar(10) primary key) +-- +TABLE: name="skip_wal_skip_rewrite_index" schema="" table="skip_wal_skip_rewrite_index" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE skip_wal_skip_rewrite_index (c varchar(10) PRIMARY KEY)" +== 809 +-- truncate_limit: 100 +alter table skip_wal_skip_rewrite_index alter c type varchar(20) +-- +TABLE: name="skip_wal_skip_rewrite_index" schema="" table="skip_wal_skip_rewrite_index" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE skip_wal_skip_rewrite_index ALTER COLUMN c TYPE varchar(20)" +== 810 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 811 +-- truncate_limit: 100 +-- We disallow changing table's row type if it's used for storage +create table at_tab1 (a int, b text) +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_tab1 (a int, b text)" +== 812 +-- truncate_limit: 100 +create table at_tab2 (x int, y at_tab1) +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_tab2 (x int, y at_tab1)" +== 813 +-- truncate_limit: 100 +alter table at_tab1 alter column b type varchar +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE at_tab1 ALTER COLUMN b TYPE varchar" +== 814 +-- truncate_limit: 100 +-- fails +drop table at_tab2 +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE at_tab2" +== 815 +-- truncate_limit: 100 +-- Use of row type in an expression is defended differently +create table at_tab2 (x int, y text, check((x,y)::at_tab1 = (1,'42')::at_tab1)) +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_tab2 (x int, y text, CHECK ((x, y)::at_tab1 = (1, '42')::at_tab1))" +== 816 +-- truncate_limit: 100 +alter table at_tab1 alter column b type varchar +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE at_tab1 ALTER COLUMN b TYPE varchar" +== 817 +-- truncate_limit: 100 +-- allowed, but ... +insert into at_tab2 values(1,'42') +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO at_tab2 VALUES (1, '42')" +== 818 +-- truncate_limit: 100 +-- ... this will fail +drop table at_tab1, at_tab2 +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE at_tab1, at_tab2" +== 819 +-- truncate_limit: 100 +-- Check it for a partitioned table, too +create table at_tab1 (a int, b text) partition by list(a) +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_tab1 (a int, b text) PARTITION BY LIST (a)" +== 820 +-- truncate_limit: 100 +create table at_tab2 (x int, y at_tab1) +-- +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_tab2 (x int, y at_tab1)" +== 821 +-- truncate_limit: 100 +alter table at_tab1 alter column b type varchar +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE at_tab1 ALTER COLUMN b TYPE varchar" +== 822 +-- truncate_limit: 100 +-- fails +drop table at_tab1, at_tab2 +-- +TABLE: name="at_tab1" schema="" table="at_tab1" ctx=DDL +TABLE: name="at_tab2" schema="" table="at_tab2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE at_tab1, at_tab2" +== 823 +-- truncate_limit: 100 +-- Alter column type that's part of a partitioned index +create table at_partitioned (a int, b text) partition by range (a) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_partitioned (a int, b text) PARTITION BY RANGE (a)" +== 824 +-- truncate_limit: 100 +create table at_part_1 partition of at_partitioned for values from (0) to (1000) +-- +TABLE: name="at_part_1" schema="" table="at_part_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_part_1 PARTITION OF at_partitioned FOR VALUES FROM (0) TO (1000)" +== 825 +-- truncate_limit: 100 +insert into at_partitioned values (512, '0.123') +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO at_partitioned VALUES (512, '0.123')" +== 826 +-- truncate_limit: 100 +create table at_part_2 (b text, a int) +-- +TABLE: name="at_part_2" schema="" table="at_part_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_part_2 (b text, a int)" +== 827 +-- truncate_limit: 100 +insert into at_part_2 values ('1.234', 1024) +-- +TABLE: name="at_part_2" schema="" table="at_part_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO at_part_2 VALUES ('1.234', 1024)" +== 828 +-- truncate_limit: 100 +create index on at_partitioned (b) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON at_partitioned USING btree (b)" +== 829 +-- truncate_limit: 100 +create index on at_partitioned (a) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON at_partitioned USING btree (a)" +== 830 +-- truncate_limit: 100 +alter table at_partitioned attach partition at_part_2 for values from (1000) to (2000) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE at_partitioned ATTACH PARTITION at_part_2 FOR VALUES FROM (1000) TO (2000)" +== 831 +-- truncate_limit: 100 +alter table at_partitioned alter column b type numeric using b::numeric +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE at_partitioned ALTER COLUMN b TYPE numeric USING b::numeric" +== 832 +-- truncate_limit: 100 +drop table at_partitioned +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE at_partitioned" +== 833 +-- truncate_limit: 100 +-- Alter column type when no table rewrite is required +-- Also check that comments are preserved +create table at_partitioned(id int, name varchar(64), unique (id, name)) + partition by hash(id) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_partitioned (id int, name varchar(64), UNIQUE (id, name)) PARTITION BY HASH (id)" +== 834 +-- truncate_limit: 100 +comment on constraint at_partitioned_id_name_key on at_partitioned is 'parent constraint' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT at_partitioned_id_name_key ON at_partitioned IS 'parent constraint'" +== 835 +-- truncate_limit: 100 +comment on index at_partitioned_id_name_key is 'parent index' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX at_partitioned_id_name_key IS 'parent index'" +== 836 +-- truncate_limit: 100 +create table at_partitioned_0 partition of at_partitioned + for values with (modulus 2, remainder 0) +-- +TABLE: name="at_partitioned_0" schema="" table="at_partitioned_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_partitioned_0 PARTITION OF at_partitioned FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 837 +-- truncate_limit: 100 +comment on constraint at_partitioned_0_id_name_key on at_partitioned_0 is 'child 0 constraint' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT at_partitioned_0_id_name_key ON at_partitioned_0 IS 'child 0 constraint'" +== 838 +-- truncate_limit: 100 +comment on index at_partitioned_0_id_name_key is 'child 0 index' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX at_partitioned_0_id_name_key IS 'child 0 index'" +== 839 +-- truncate_limit: 100 +create table at_partitioned_1 partition of at_partitioned + for values with (modulus 2, remainder 1) +-- +TABLE: name="at_partitioned_1" schema="" table="at_partitioned_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_partitioned_1 PARTITION OF at_partitioned FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 840 +-- truncate_limit: 100 +comment on constraint at_partitioned_1_id_name_key on at_partitioned_1 is 'child 1 constraint' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT at_partitioned_1_id_name_key ON at_partitioned_1 IS 'child 1 constraint'" +== 841 +-- truncate_limit: 100 +comment on index at_partitioned_1_id_name_key is 'child 1 index' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX at_partitioned_1_id_name_key IS 'child 1 index'" +== 842 +-- truncate_limit: 100 +insert into at_partitioned values(1, 'foo') +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO at_partitioned VALUES (1, 'foo')" +== 843 +-- truncate_limit: 100 +insert into at_partitioned values(3, 'bar') +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO at_partitioned VALUES (3, 'bar')" +== 844 +-- truncate_limit: 100 +create temp table old_oids as + select relname, oid as oldoid, relfilenode as oldfilenode + from pg_class where relname like 'at_partitioned%' +-- +TABLE: name="old_oids" schema="" table="old_oids" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE old_oids AS SELECT relname, oid AS oldoid, relfilenode AS oldfilenode FROM..." +== 845 +-- truncate_limit: 100 +select relname, + c.oid = oldoid as orig_oid, + case relfilenode + when 0 then 'none' + when c.oid then 'own' + when oldfilenode then 'orig' + else 'OTHER' + end as storage, + obj_description(c.oid, 'pg_class') as desc + from pg_class c left join old_oids using (relname) + where relname like 'at_partitioned%' + order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="old_oids" schema="" table="old_oids" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c LEFT JOIN old_oids USING (relname) WHERE ... ORDER BY relname" +== 846 +-- truncate_limit: 100 +select conname, obj_description(oid, 'pg_constraint') as desc + from pg_constraint where conname like 'at_partitioned%' + order by conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conname LIKE 'at_partitioned%' ORDER BY conname" +== 847 +-- truncate_limit: 100 +alter table at_partitioned alter column name type varchar(127) +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE at_partitioned ALTER COLUMN name TYPE varchar(127)" +== 848 +-- truncate_limit: 100 +select relname, + c.oid = oldoid as orig_oid, + case relfilenode + when 0 then 'none' + when c.oid then 'own' + when oldfilenode then 'orig' + else 'OTHER' + end as storage, + obj_description(c.oid, 'pg_class') as desc + from pg_class c left join old_oids using (relname) + where relname like 'at_partitioned%' + order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="old_oids" schema="" table="old_oids" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c LEFT JOIN old_oids USING (relname) WHERE ... ORDER BY relname" +== 849 +-- truncate_limit: 100 +select conname, obj_description(oid, 'pg_constraint') as desc + from pg_constraint where conname like 'at_partitioned%' + order by conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conname LIKE 'at_partitioned%' ORDER BY conname" +== 850 +-- truncate_limit: 100 +-- Don't remove this DROP, it exposes bug #15672 +drop table at_partitioned +-- +TABLE: name="at_partitioned" schema="" table="at_partitioned" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE at_partitioned" +== 851 +-- truncate_limit: 100 +-- disallow recursive containment of row types +create temp table recur1 (f1 int) +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE recur1 (f1 int)" +== 852 +-- truncate_limit: 100 +alter table recur1 add column f2 recur1 +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE recur1 ADD COLUMN f2 recur1" +== 853 +-- truncate_limit: 100 +-- fails +alter table recur1 add column f2 recur1[] +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE recur1 ADD COLUMN f2 recur1[]" +== 854 +-- truncate_limit: 100 +-- fails +create domain array_of_recur1 as recur1[] +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN array_of_recur1 AS recur1[]" +== 855 +-- truncate_limit: 100 +alter table recur1 add column f2 array_of_recur1 +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE recur1 ADD COLUMN f2 array_of_recur1" +== 856 +-- truncate_limit: 100 +-- fails +create temp table recur2 (f1 int, f2 recur1) +-- +TABLE: name="recur2" schema="" table="recur2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE recur2 (f1 int, f2 recur1)" +== 857 +-- truncate_limit: 100 +alter table recur1 add column f2 recur2 +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE recur1 ADD COLUMN f2 recur2" +== 858 +-- truncate_limit: 100 +-- fails +alter table recur1 add column f2 int +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE recur1 ADD COLUMN f2 int" +== 859 +-- truncate_limit: 100 +alter table recur1 alter column f2 type recur2 +-- +TABLE: name="recur1" schema="" table="recur1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE recur1 ALTER COLUMN f2 TYPE recur2" +== 860 +-- truncate_limit: 100 +-- fails + +-- SET STORAGE may need to add a TOAST table +create table test_storage (a text, c text storage plain) +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_storage (a text, c text STORAGE plain)" +== 861 +-- truncate_limit: 100 +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltoastrelid <> 0 AS has_toast_table FROM pg_class WHERE oid = 'test_storage'::regclass" +== 862 +-- truncate_limit: 100 +alter table test_storage alter a set storage plain +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_storage ALTER COLUMN a SET STORAGE plain" +== 863 +-- truncate_limit: 100 +-- rewrite table to remove its TOAST table; need a non-constant column default +alter table test_storage add b int default random()::int +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_storage ADD COLUMN b int DEFAULT (random()::int)" +== 864 +-- truncate_limit: 100 +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltoastrelid <> 0 AS has_toast_table FROM pg_class WHERE oid = 'test_storage'::regclass" +== 865 +-- truncate_limit: 100 +alter table test_storage alter a set storage default +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_storage ALTER COLUMN a SET STORAGE \"default\"" +== 866 +-- truncate_limit: 100 +-- re-add TOAST table +select reltoastrelid <> 0 as has_toast_table + from pg_class where oid = 'test_storage'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltoastrelid <> 0 AS has_toast_table FROM pg_class WHERE oid = 'test_storage'::regclass" +== 867 +-- truncate_limit: 100 +-- check STORAGE correctness +create table test_storage_failed (a text, b int storage extended) +-- +TABLE: name="test_storage_failed" schema="" table="test_storage_failed" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_storage_failed (a text, b int STORAGE extended)" +== 868 +-- truncate_limit: 100 +-- test that SET STORAGE propagates to index correctly +create index test_storage_idx on test_storage (b, a) +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_storage_idx ON test_storage USING btree (b, a)" +== 869 +-- truncate_limit: 100 +alter table test_storage alter column a set storage external +-- +TABLE: name="test_storage" schema="" table="test_storage" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_storage ALTER COLUMN a SET STORAGE external" +== 870 +-- truncate_limit: 100 +-- ALTER COLUMN TYPE with a check constraint and a child table (bug #13779) +CREATE TABLE test_inh_check (a float check (a > 10.2), b float) +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_inh_check (a double precision CHECK (a > 10.2), b double precision)" +== 871 +-- truncate_limit: 100 +CREATE TABLE test_inh_check_child() INHERITS(test_inh_check) +-- +TABLE: name="test_inh_check_child" schema="" table="test_inh_check_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_inh_check_child () INHERITS (test_inh_check)" +== 872 +-- truncate_limit: 100 +select relname, conname, coninhcount, conislocal, connoinherit + from pg_constraint c, pg_class r + where relname like 'test_inh_check%' and c.conrelid = r.oid + order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "r"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="c" column="conrelid" +FILTER: schema="" table="r" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint c, pg_class r WHERE ... ORDER BY 1, 2" +== 873 +-- truncate_limit: 100 +ALTER TABLE test_inh_check ALTER COLUMN a TYPE numeric +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_inh_check ALTER COLUMN a TYPE numeric" +== 874 +-- truncate_limit: 100 +select relname, conname, coninhcount, conislocal, connoinherit + from pg_constraint c, pg_class r + where relname like 'test_inh_check%' and c.conrelid = r.oid + order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "r"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="c" column="conrelid" +FILTER: schema="" table="r" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint c, pg_class r WHERE ... ORDER BY 1, 2" +== 875 +-- truncate_limit: 100 +-- also try noinherit, local, and local+inherited cases +ALTER TABLE test_inh_check ADD CONSTRAINT bnoinherit CHECK (b > 100) NO INHERIT +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_inh_check ADD CONSTRAINT bnoinherit CHECK (b > 100) NO INHERIT" +== 876 +-- truncate_limit: 100 +ALTER TABLE test_inh_check_child ADD CONSTRAINT blocal CHECK (b < 1000) +-- +TABLE: name="test_inh_check_child" schema="" table="test_inh_check_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_inh_check_child ADD CONSTRAINT blocal CHECK (b < 1000)" +== 877 +-- truncate_limit: 100 +ALTER TABLE test_inh_check_child ADD CONSTRAINT bmerged CHECK (b > 1) +-- +TABLE: name="test_inh_check_child" schema="" table="test_inh_check_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_inh_check_child ADD CONSTRAINT bmerged CHECK (b > 1)" +== 878 +-- truncate_limit: 100 +ALTER TABLE test_inh_check ADD CONSTRAINT bmerged CHECK (b > 1) +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_inh_check ADD CONSTRAINT bmerged CHECK (b > 1)" +== 879 +-- truncate_limit: 100 +select relname, conname, coninhcount, conislocal, connoinherit + from pg_constraint c, pg_class r + where relname like 'test_inh_check%' and c.conrelid = r.oid + order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "r"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="c" column="conrelid" +FILTER: schema="" table="r" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint c, pg_class r WHERE ... ORDER BY 1, 2" +== 880 +-- truncate_limit: 100 +ALTER TABLE test_inh_check ALTER COLUMN b TYPE numeric +-- +TABLE: name="test_inh_check" schema="" table="test_inh_check" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_inh_check ALTER COLUMN b TYPE numeric" +== 881 +-- truncate_limit: 100 +select relname, conname, coninhcount, conislocal, connoinherit + from pg_constraint c, pg_class r + where relname like 'test_inh_check%' and c.conrelid = r.oid + order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "r"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="c" column="conrelid" +FILTER: schema="" table="r" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint c, pg_class r WHERE ... ORDER BY 1, 2" +== 882 +-- truncate_limit: 100 +-- ALTER COLUMN TYPE with different schema in children +-- Bug at https://postgr.es/m/20170102225618.GA10071@telsasoft.com +CREATE TABLE test_type_diff (f1 int) +-- +TABLE: name="test_type_diff" schema="" table="test_type_diff" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_type_diff (f1 int)" +== 883 +-- truncate_limit: 100 +CREATE TABLE test_type_diff_c (extra smallint) INHERITS (test_type_diff) +-- +TABLE: name="test_type_diff_c" schema="" table="test_type_diff_c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_type_diff_c (extra smallint) INHERITS (test_type_diff)" +== 884 +-- truncate_limit: 100 +ALTER TABLE test_type_diff ADD COLUMN f2 int +-- +TABLE: name="test_type_diff" schema="" table="test_type_diff" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_type_diff ADD COLUMN f2 int" +== 885 +-- truncate_limit: 100 +INSERT INTO test_type_diff_c VALUES (1, 2, 3) +-- +TABLE: name="test_type_diff_c" schema="" table="test_type_diff_c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_type_diff_c VALUES (1, 2, 3)" +== 886 +-- truncate_limit: 100 +ALTER TABLE test_type_diff ALTER COLUMN f2 TYPE bigint USING f2::bigint +-- +TABLE: name="test_type_diff" schema="" table="test_type_diff" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_type_diff ALTER COLUMN f2 TYPE bigint USING f2::bigint" +== 887 +-- truncate_limit: 100 +CREATE TABLE test_type_diff2 (int_two int2, int_four int4, int_eight int8) +-- +TABLE: name="test_type_diff2" schema="" table="test_type_diff2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_type_diff2 (int_two int2, int_four int4, int_eight int8)" +== 888 +-- truncate_limit: 100 +CREATE TABLE test_type_diff2_c1 (int_four int4, int_eight int8, int_two int2) +-- +TABLE: name="test_type_diff2_c1" schema="" table="test_type_diff2_c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_type_diff2_c1 (int_four int4, int_eight int8, int_two int2)" +== 889 +-- truncate_limit: 100 +CREATE TABLE test_type_diff2_c2 (int_eight int8, int_two int2, int_four int4) +-- +TABLE: name="test_type_diff2_c2" schema="" table="test_type_diff2_c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_type_diff2_c2 (int_eight int8, int_two int2, int_four int4)" +== 890 +-- truncate_limit: 100 +CREATE TABLE test_type_diff2_c3 (int_two int2, int_four int4, int_eight int8) +-- +TABLE: name="test_type_diff2_c3" schema="" table="test_type_diff2_c3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_type_diff2_c3 (int_two int2, int_four int4, int_eight int8)" +== 891 +-- truncate_limit: 100 +ALTER TABLE test_type_diff2_c1 INHERIT test_type_diff2 +-- +TABLE: name="test_type_diff2_c1" schema="" table="test_type_diff2_c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_type_diff2_c1 INHERIT test_type_diff2" +== 892 +-- truncate_limit: 100 +ALTER TABLE test_type_diff2_c2 INHERIT test_type_diff2 +-- +TABLE: name="test_type_diff2_c2" schema="" table="test_type_diff2_c2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_type_diff2_c2 INHERIT test_type_diff2" +== 893 +-- truncate_limit: 100 +ALTER TABLE test_type_diff2_c3 INHERIT test_type_diff2 +-- +TABLE: name="test_type_diff2_c3" schema="" table="test_type_diff2_c3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_type_diff2_c3 INHERIT test_type_diff2" +== 894 +-- truncate_limit: 100 +INSERT INTO test_type_diff2_c1 VALUES (1, 2, 3) +-- +TABLE: name="test_type_diff2_c1" schema="" table="test_type_diff2_c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_type_diff2_c1 VALUES (1, 2, 3)" +== 895 +-- truncate_limit: 100 +INSERT INTO test_type_diff2_c2 VALUES (4, 5, 6) +-- +TABLE: name="test_type_diff2_c2" schema="" table="test_type_diff2_c2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_type_diff2_c2 VALUES (4, 5, 6)" +== 896 +-- truncate_limit: 100 +INSERT INTO test_type_diff2_c3 VALUES (7, 8, 9) +-- +TABLE: name="test_type_diff2_c3" schema="" table="test_type_diff2_c3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_type_diff2_c3 VALUES (7, 8, 9)" +== 897 +-- truncate_limit: 100 +ALTER TABLE test_type_diff2 ALTER COLUMN int_four TYPE int8 USING int_four::int8 +-- +TABLE: name="test_type_diff2" schema="" table="test_type_diff2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_type_diff2 ALTER COLUMN int_four TYPE int8 USING int_four::int8" +== 898 +-- truncate_limit: 100 +-- whole-row references are disallowed +ALTER TABLE test_type_diff2 ALTER COLUMN int_four TYPE int4 USING (pg_column_size(test_type_diff2)) +-- +TABLE: name="test_type_diff2" schema="" table="test_type_diff2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_type_diff2 ALTER COLUMN int_four TYPE int4 USING pg_column_size(test_type_diff2)" +== 899 +-- truncate_limit: 100 +-- check for rollback of ANALYZE corrupting table property flags (bug #11638) +CREATE TABLE check_fk_presence_1 (id int PRIMARY KEY, t text) +-- +TABLE: name="check_fk_presence_1" schema="" table="check_fk_presence_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE check_fk_presence_1 (id int PRIMARY KEY, t text)" +== 900 +-- truncate_limit: 100 +CREATE TABLE check_fk_presence_2 (id int REFERENCES check_fk_presence_1, t text) +-- +TABLE: name="check_fk_presence_2" schema="" table="check_fk_presence_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE check_fk_presence_2 (id int REFERENCES check_fk_presence_1, t text)" +== 901 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 902 +-- truncate_limit: 100 +ALTER TABLE check_fk_presence_2 DROP CONSTRAINT check_fk_presence_2_id_fkey +-- +TABLE: name="check_fk_presence_2" schema="" table="check_fk_presence_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE check_fk_presence_2 DROP CONSTRAINT check_fk_presence_2_id_fkey" +== 903 +-- truncate_limit: 100 +ANALYZE check_fk_presence_2 +-- +TABLE: name="check_fk_presence_2" schema="" table="check_fk_presence_2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE check_fk_presence_2" +== 904 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 905 +-- truncate_limit: 100 +DROP TABLE check_fk_presence_1, check_fk_presence_2 +-- +TABLE: name="check_fk_presence_1" schema="" table="check_fk_presence_1" ctx=DDL +TABLE: name="check_fk_presence_2" schema="" table="check_fk_presence_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE check_fk_presence_1, check_fk_presence_2" +== 906 +-- truncate_limit: 100 +-- check column addition within a view (bug #14876) +create table at_base_table(id int, stuff text) +-- +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_base_table (id int, stuff text)" +== 907 +-- truncate_limit: 100 +insert into at_base_table values (23, 'skidoo') +-- +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO at_base_table VALUES (23, 'skidoo')" +== 908 +-- truncate_limit: 100 +create view at_view_1 as select * from at_base_table bt +-- +TABLE: name="at_view_1" schema="" table="at_view_1" ctx=DDL +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=Select +ALIAS: "bt"="at_base_table" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW at_view_1 AS SELECT * FROM at_base_table bt" +== 909 +-- truncate_limit: 100 +create view at_view_2 as select *, to_json(v1) as j from at_view_1 v1 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=DDL +TABLE: name="at_view_1" schema="" table="at_view_1" ctx=Select +ALIAS: "v1"="at_view_1" +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW at_view_2 AS SELECT *, to_json(v1) AS j FROM at_view_1 v1" +== 910 +-- truncate_limit: 100 +explain (verbose, costs off) select * from at_view_2 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM at_view_2" +== 911 +-- truncate_limit: 100 +select * from at_view_2 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM at_view_2" +== 912 +-- truncate_limit: 100 +create or replace view at_view_1 as select *, 2+2 as more from at_base_table bt +-- +TABLE: name="at_view_1" schema="" table="at_view_1" ctx=DDL +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=Select +ALIAS: "bt"="at_base_table" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW at_view_1 AS SELECT *, 2 + 2 AS more FROM at_base_table bt" +== 913 +-- truncate_limit: 100 +explain (verbose, costs off) select * from at_view_2 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM at_view_2" +== 914 +-- truncate_limit: 100 +select * from at_view_2 +-- +TABLE: name="at_view_2" schema="" table="at_view_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM at_view_2" +== 915 +-- truncate_limit: 100 +drop view at_view_2 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW at_view_2" +== 916 +-- truncate_limit: 100 +drop view at_view_1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW at_view_1" +== 917 +-- truncate_limit: 100 +drop table at_base_table +-- +TABLE: name="at_base_table" schema="" table="at_base_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE at_base_table" +== 918 +-- truncate_limit: 100 +-- related case (bug #17811) +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 919 +-- truncate_limit: 100 +create temp table t1 as select * from int8_tbl +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 AS SELECT * FROM int8_tbl" +== 920 +-- truncate_limit: 100 +create temp view v1 as select 1::int8 as q1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v1 AS SELECT 1::int8 AS q1" +== 921 +-- truncate_limit: 100 +create temp view v2 as select * from v1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="v1" schema="" table="v1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v2 AS SELECT * FROM v1" +== 922 +-- truncate_limit: 100 +create or replace temp view v1 with (security_barrier = true) + as select * from t1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW v1 WITH (security_barrier=true) AS SELECT * FROM t1" +== 923 +-- truncate_limit: 100 +create temp table log (q1 int8, q2 int8) +-- +TABLE: name="log" schema="" table="log" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE log (q1 int8, q2 int8)" +== 924 +-- truncate_limit: 100 +create rule v1_upd_rule as on update to v1 + do also insert into log values (new.*) +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE v1_upd_rule AS ON UPDATE TO v1 DO INSERT INTO log VALUES (new.*)" +== 925 +-- truncate_limit: 100 +update v2 set q1 = q1 + 1 where q1 = 123 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE v2 SET q1 = q1 + 1 WHERE q1 = 123" +== 926 +-- truncate_limit: 100 +select * from t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 927 +-- truncate_limit: 100 +select * from log +-- +TABLE: name="log" schema="" table="log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM log" +== 928 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 929 +-- truncate_limit: 100 +-- check adding a column not itself requiring a rewrite, together with +-- a column requiring a default (bug #16038) + +-- ensure that rewrites aren't silently optimized away, removing the +-- value of the test +CREATE FUNCTION check_ddl_rewrite(p_tablename regclass, p_ddl text) +RETURNS boolean +LANGUAGE plpgsql AS $$ +DECLARE + v_relfilenode oid; +BEGIN + v_relfilenode := relfilenode FROM pg_class WHERE oid = p_tablename; + + EXECUTE p_ddl; + + RETURN v_relfilenode <> (SELECT relfilenode FROM pg_class WHERE oid = p_tablename); +END; +$$ +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION check_ddl_rewrite(p_tablename regclass, p_ddl text) RETURNS boolean LANGUAGE plpg..." +== 930 +-- truncate_limit: 100 +CREATE TABLE rewrite_test(col text) +-- +TABLE: name="rewrite_test" schema="" table="rewrite_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rewrite_test (col text)" +== 931 +-- truncate_limit: 100 +INSERT INTO rewrite_test VALUES ('something') +-- +TABLE: name="rewrite_test" schema="" table="rewrite_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rewrite_test VALUES ('something')" +== 932 +-- truncate_limit: 100 +INSERT INTO rewrite_test VALUES (NULL) +-- +TABLE: name="rewrite_test" schema="" table="rewrite_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rewrite_test VALUES (NULL)" +== 933 +-- truncate_limit: 100 +-- empty[12] don't need rewrite, but notempty[12]_rewrite will force one +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN empty1 text, + ADD COLUMN notempty1_rewrite serial; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 934 +-- truncate_limit: 100 +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN notempty2_rewrite serial, + ADD COLUMN empty2 text; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 935 +-- truncate_limit: 100 +-- also check that fast defaults cause no problem, first without rewrite +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN empty3 text, + ADD COLUMN notempty3_norewrite int default 42; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 936 +-- truncate_limit: 100 +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN notempty4_norewrite int default 42, + ADD COLUMN empty4 text; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 937 +-- truncate_limit: 100 +-- then with rewrite +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN empty5 text, + ADD COLUMN notempty5_norewrite int default 42, + ADD COLUMN notempty5_rewrite serial; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 938 +-- truncate_limit: 100 +SELECT check_ddl_rewrite('rewrite_test', $$ + ALTER TABLE rewrite_test + ADD COLUMN notempty6_rewrite serial, + ADD COLUMN empty6 text, + ADD COLUMN notempty6_norewrite int default 42; +$$) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 939 +-- truncate_limit: 100 +-- cleanup +DROP FUNCTION check_ddl_rewrite(regclass, text) +-- +FUNCTION: name="check_ddl_rewrite" function="check_ddl_rewrite" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION check_ddl_rewrite(regclass, text)" +== 940 +-- truncate_limit: 100 +DROP TABLE rewrite_test +-- +TABLE: name="rewrite_test" schema="" table="rewrite_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rewrite_test" +== 941 +-- truncate_limit: 100 +|-- +-- lock levels +|-- +drop type lockmodes +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE lockmodes" +== 942 +-- truncate_limit: 100 +create type lockmodes as enum ( + 'SIReadLock' +,'AccessShareLock' +,'RowShareLock' +,'RowExclusiveLock' +,'ShareUpdateExclusiveLock' +,'ShareLock' +,'ShareRowExclusiveLock' +,'ExclusiveLock' +,'AccessExclusiveLock' +) +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE lockmodes AS ENUM ('SIReadLock', 'AccessShareLock', 'RowShareLock', 'RowExclusiveLock..." +== 943 +-- truncate_limit: 100 +drop view my_locks +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW my_locks" +== 944 +-- truncate_limit: 100 +create or replace view my_locks as +select case when c.relname like 'pg_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode +from pg_locks l join pg_class c on l.relation = c.oid +where virtualtransaction = ( + select virtualtransaction + from pg_locks + where transactionid = pg_current_xact_id()::xid) +and locktype = 'relation' +and relnamespace != (select oid from pg_namespace where nspname = 'pg_catalog') +and c.relname != 'my_locks' +group by c.relname +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FILTER: schema="" table="" column="virtualtransaction" +FILTER: schema="" table="" column="transactionid" +FILTER: schema="" table="" column="nspname" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW my_locks AS SELECT CASE WHEN c.relname LIKE 'pg_toast%' THEN 'pg_toast' EL..." +== 945 +-- truncate_limit: 100 +create table alterlock (f1 int primary key, f2 text) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alterlock (f1 int PRIMARY KEY, f2 text)" +== 946 +-- truncate_limit: 100 +insert into alterlock values (1, 'foo') +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alterlock VALUES (1, 'foo')" +== 947 +-- truncate_limit: 100 +create table alterlock2 (f3 int primary key, f1 int) +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alterlock2 (f3 int PRIMARY KEY, f1 int)" +== 948 +-- truncate_limit: 100 +insert into alterlock2 values (1, 1) +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alterlock2 VALUES (1, 1)" +== 949 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 950 +-- truncate_limit: 100 +alter table alterlock alter column f2 set statistics 150 +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock ALTER COLUMN f2 SET STATISTICS 150" +== 951 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 952 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 953 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 954 +-- truncate_limit: 100 +alter table alterlock cluster on alterlock_pkey +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock CLUSTER ON alterlock_pkey" +== 955 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 956 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 957 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 958 +-- truncate_limit: 100 +alter table alterlock set without cluster +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock SET WITHOUT CLUSTER" +== 959 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 960 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 961 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 962 +-- truncate_limit: 100 +alter table alterlock set (fillfactor = 100) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock SET (fillfactor=100)" +== 963 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 964 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 965 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 966 +-- truncate_limit: 100 +alter table alterlock reset (fillfactor) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock RESET (fillfactor)" +== 967 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 968 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 969 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 970 +-- truncate_limit: 100 +alter table alterlock set (toast.autovacuum_enabled = off) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock SET (toast.autovacuum_enabled=off)" +== 971 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 972 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 973 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 974 +-- truncate_limit: 100 +alter table alterlock set (autovacuum_enabled = off) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock SET (autovacuum_enabled=off)" +== 975 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 976 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 977 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 978 +-- truncate_limit: 100 +alter table alterlock alter column f2 set (n_distinct = 1) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock ALTER COLUMN f2 SET (n_distinct=1)" +== 979 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 980 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 981 +-- truncate_limit: 100 +-- test that mixing options with different lock levels works as expected +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 982 +-- truncate_limit: 100 +alter table alterlock set (autovacuum_enabled = off, fillfactor = 80) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock SET (autovacuum_enabled=off, fillfactor=80)" +== 983 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 984 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 985 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 986 +-- truncate_limit: 100 +alter table alterlock alter column f2 set storage extended +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock ALTER COLUMN f2 SET STORAGE extended" +== 987 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 988 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 989 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 990 +-- truncate_limit: 100 +alter table alterlock alter column f2 set default 'x' +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock ALTER COLUMN f2 SET DEFAULT 'x'" +== 991 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 992 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 993 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 994 +-- truncate_limit: 100 +create trigger ttdummy + before delete or update on alterlock + for each row + execute procedure + ttdummy (1, 1) +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER ttdummy BEFORE DELETE OR UPDATE ON alterlock FOR EACH ROW EXECUTE FUNCTION ttdummy..." +== 995 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 996 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 997 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 998 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 999 +-- truncate_limit: 100 +alter table alterlock2 add foreign key (f1) references alterlock (f1) +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock2 ADD FOREIGN KEY (f1) REFERENCES alterlock (f1)" +== 1000 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 1001 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 1002 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1003 +-- truncate_limit: 100 +alter table alterlock2 +add constraint alterlock2nv foreign key (f1) references alterlock (f1) NOT VALID +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock2 ADD CONSTRAINT alterlock2nv FOREIGN KEY (f1) REFERENCES alterlock (f1) NOT..." +== 1004 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 1005 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1006 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1007 +-- truncate_limit: 100 +alter table alterlock2 validate constraint alterlock2nv +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alterlock2 VALIDATE CONSTRAINT alterlock2nv" +== 1008 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 1009 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 1010 +-- truncate_limit: 100 +create or replace view my_locks as +select case when c.relname like 'pg_toast%' then 'pg_toast' else c.relname end, max(mode::lockmodes) as max_lockmode +from pg_locks l join pg_class c on l.relation = c.oid +where virtualtransaction = ( + select virtualtransaction + from pg_locks + where transactionid = pg_current_xact_id()::xid) +and locktype = 'relation' +and relnamespace != (select oid from pg_namespace where nspname = 'pg_catalog') +and c.relname = 'my_locks' +group by c.relname +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FILTER: schema="" table="" column="virtualtransaction" +FILTER: schema="" table="" column="transactionid" +FILTER: schema="" table="" column="nspname" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW my_locks AS SELECT CASE WHEN c.relname LIKE 'pg_toast%' THEN 'pg_toast' EL..." +== 1011 +-- truncate_limit: 100 +-- raise exception +alter table my_locks set (autovacuum_enabled = false) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE my_locks SET (autovacuum_enabled=false)" +== 1012 +-- truncate_limit: 100 +alter view my_locks set (autovacuum_enabled = false) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW my_locks SET (autovacuum_enabled=false)" +== 1013 +-- truncate_limit: 100 +alter table my_locks reset (autovacuum_enabled) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE my_locks RESET (autovacuum_enabled)" +== 1014 +-- truncate_limit: 100 +alter view my_locks reset (autovacuum_enabled) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW my_locks RESET (autovacuum_enabled)" +== 1015 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1016 +-- truncate_limit: 100 +alter view my_locks set (security_barrier=off) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW my_locks SET (security_barrier=off)" +== 1017 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 1018 +-- truncate_limit: 100 +alter view my_locks reset (security_barrier) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW my_locks RESET (security_barrier)" +== 1019 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 1020 +-- truncate_limit: 100 +-- this test intentionally applies the ALTER TABLE command against a view, but +-- uses a view option so we expect this to succeed. This form of SQL is +-- accepted for historical reasons, as shown in the docs for ALTER VIEW +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1021 +-- truncate_limit: 100 +alter table my_locks set (security_barrier=off) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE my_locks SET (security_barrier=off)" +== 1022 +-- truncate_limit: 100 +select * from my_locks order by 1 +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_locks ORDER BY 1" +== 1023 +-- truncate_limit: 100 +alter table my_locks reset (security_barrier) +-- +TABLE: name="my_locks" schema="" table="my_locks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE my_locks RESET (security_barrier)" +== 1024 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 1025 +-- truncate_limit: 100 +-- cleanup +drop table alterlock2 +-- +TABLE: name="alterlock2" schema="" table="alterlock2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE alterlock2" +== 1026 +-- truncate_limit: 100 +drop table alterlock +-- +TABLE: name="alterlock" schema="" table="alterlock" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE alterlock" +== 1027 +-- truncate_limit: 100 +drop view my_locks +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW my_locks" +== 1028 +-- truncate_limit: 100 +drop type lockmodes +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE lockmodes" +== 1029 +-- truncate_limit: 100 +|-- +-- alter function +|-- +create function test_strict(text) returns text as + 'select coalesce($1, ''got passed a null'');' + language sql returns null on null input +-- +FUNCTION: name="test_strict" function="test_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_strict(text) RETURNS text AS $$select coalesce($1, 'got passed a null');$$ L..." +== 1030 +-- truncate_limit: 100 +select test_strict(NULL) +-- +FUNCTION: name="test_strict" function="test_strict" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_strict(NULL)" +== 1031 +-- truncate_limit: 100 +alter function test_strict(text) called on null input +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION test_strict(text) CALLED ON NULL INPUT" +== 1032 +-- truncate_limit: 100 +select test_strict(NULL) +-- +FUNCTION: name="test_strict" function="test_strict" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_strict(NULL)" +== 1033 +-- truncate_limit: 100 +create function non_strict(text) returns text as + 'select coalesce($1, ''got passed a null'');' + language sql called on null input +-- +FUNCTION: name="non_strict" function="non_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION non_strict(text) RETURNS text AS $$select coalesce($1, 'got passed a null');$$ LA..." +== 1034 +-- truncate_limit: 100 +select non_strict(NULL) +-- +FUNCTION: name="non_strict" function="non_strict" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT non_strict(NULL)" +== 1035 +-- truncate_limit: 100 +alter function non_strict(text) returns null on null input +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION non_strict(text) RETURNS NULL ON NULL INPUT" +== 1036 +-- truncate_limit: 100 +select non_strict(NULL) +-- +FUNCTION: name="non_strict" function="non_strict" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT non_strict(NULL)" +== 1037 +-- truncate_limit: 100 +|-- +-- alter object set schema +|-- + +create schema alter1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA alter1" +== 1038 +-- truncate_limit: 100 +create schema alter2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA alter2" +== 1039 +-- truncate_limit: 100 +create table alter1.t1(f1 serial primary key, f2 int check (f2 > 0)) +-- +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alter1.t1 (f1 serial PRIMARY KEY, f2 int CHECK (f2 > 0))" +== 1040 +-- truncate_limit: 100 +create view alter1.v1 as select * from alter1.t1 +-- +TABLE: name="alter1.v1" schema="alter1" table="v1" ctx=DDL +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW alter1.v1 AS SELECT * FROM alter1.t1" +== 1041 +-- truncate_limit: 100 +create function alter1.plus1(int) returns int as 'select $1+1' language sql +-- +FUNCTION: name="alter1.plus1" function="plus1" schema="alter1" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alter1.plus1(int) RETURNS int AS $$select $1+1$$ LANGUAGE sql" +== 1042 +-- truncate_limit: 100 +create domain alter1.posint integer check (value > 0) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN alter1.posint AS int CHECK (value > 0)" +== 1043 +-- truncate_limit: 100 +create type alter1.ctype as (f1 int, f2 text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE alter1.ctype AS (f1 int, f2 text)" +== 1044 +-- truncate_limit: 100 +create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql +as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2' +-- +FUNCTION: name="alter1.same" function="same" schema="alter1" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alter1.same(alter1.ctype, alter1.ctype) RETURNS boolean LANGUAGE sql AS $$select ..." +== 1045 +-- truncate_limit: 100 +create operator alter1.=(procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR alter1.= (procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype)" +== 1046 +-- truncate_limit: 100 +create operator class alter1.ctype_hash_ops default for type alter1.ctype using hash as + operator 1 alter1.=(alter1.ctype, alter1.ctype) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS alter1.ctype_hash_ops DEFAULT FOR TYPE alter1.ctype USING hash AS OPERATOR ..." +== 1047 +-- truncate_limit: 100 +create conversion alter1.latin1_to_utf8 for 'latin1' to 'utf8' from iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE CONVERSION alter1.latin1_to_utf8 FOR 'latin1' TO 'utf8'FROM iso8859_1_to_utf8" +== 1048 +-- truncate_limit: 100 +create text search parser alter1.prs(start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH PARSER alter1.prs (start = prsd_start, gettoken = prsd_nexttoken, \"end\" = prsd..." +== 1049 +-- truncate_limit: 100 +create text search configuration alter1.cfg(parser = alter1.prs) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION alter1.cfg (parser = alter1.prs)" +== 1050 +-- truncate_limit: 100 +create text search template alter1.tmpl(init = dsimple_init, lexize = dsimple_lexize) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH TEMPLATE alter1.tmpl (init = dsimple_init, lexize = dsimple_lexize)" +== 1051 +-- truncate_limit: 100 +create text search dictionary alter1.dict(template = alter1.tmpl) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY alter1.dict (template = alter1.tmpl)" +== 1052 +-- truncate_limit: 100 +insert into alter1.t1(f2) values(11) +-- +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alter1.t1 (f2) VALUES (11)" +== 1053 +-- truncate_limit: 100 +insert into alter1.t1(f2) values(12) +-- +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alter1.t1 (f2) VALUES (12)" +== 1054 +-- truncate_limit: 100 +alter table alter1.t1 set schema alter1 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE alter1.t1 SET SCHEMA alter1" +== 1055 +-- truncate_limit: 100 +-- no-op, same schema +alter table alter1.t1 set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE alter1.t1 SET SCHEMA alter2" +== 1056 +-- truncate_limit: 100 +alter table alter1.v1 set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE alter1.v1 SET SCHEMA alter2" +== 1057 +-- truncate_limit: 100 +alter function alter1.plus1(int) set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER FUNCTION alter1.plus1(int) SET SCHEMA alter2" +== 1058 +-- truncate_limit: 100 +alter domain alter1.posint set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER DOMAIN alter1.posint SET SCHEMA alter2" +== 1059 +-- truncate_limit: 100 +alter operator class alter1.ctype_hash_ops using hash set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR CLASS alter1.ctype_hash_ops USING hash SET SCHEMA alter2" +== 1060 +-- truncate_limit: 100 +alter operator family alter1.ctype_hash_ops using hash set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR FAMILY alter1.ctype_hash_ops USING hash SET SCHEMA alter2" +== 1061 +-- truncate_limit: 100 +alter operator alter1.=(alter1.ctype, alter1.ctype) set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER OPERATOR alter1.=(alter1.ctype, alter1.ctype) SET SCHEMA alter2" +== 1062 +-- truncate_limit: 100 +alter function alter1.same(alter1.ctype, alter1.ctype) set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER FUNCTION alter1.same(alter1.ctype, alter1.ctype) SET SCHEMA alter2" +== 1063 +-- truncate_limit: 100 +alter type alter1.ctype set schema alter1 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TYPE alter1.ctype SET SCHEMA alter1" +== 1064 +-- truncate_limit: 100 +-- no-op, same schema +alter type alter1.ctype set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TYPE alter1.ctype SET SCHEMA alter2" +== 1065 +-- truncate_limit: 100 +alter conversion alter1.latin1_to_utf8 set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER CONVERSION alter1.latin1_to_utf8 SET SCHEMA alter2" +== 1066 +-- truncate_limit: 100 +alter text search parser alter1.prs set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH PARSER alter1.prs SET SCHEMA alter2" +== 1067 +-- truncate_limit: 100 +alter text search configuration alter1.cfg set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION alter1.cfg SET SCHEMA alter2" +== 1068 +-- truncate_limit: 100 +alter text search template alter1.tmpl set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH TEMPLATE alter1.tmpl SET SCHEMA alter2" +== 1069 +-- truncate_limit: 100 +alter text search dictionary alter1.dict set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY alter1.dict SET SCHEMA alter2" +== 1070 +-- truncate_limit: 100 +-- this should succeed because nothing is left in alter1 +drop schema alter1 +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA alter1" +== 1071 +-- truncate_limit: 100 +insert into alter2.t1(f2) values(13) +-- +TABLE: name="alter2.t1" schema="alter2" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alter2.t1 (f2) VALUES (13)" +== 1072 +-- truncate_limit: 100 +insert into alter2.t1(f2) values(14) +-- +TABLE: name="alter2.t1" schema="alter2" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alter2.t1 (f2) VALUES (14)" +== 1073 +-- truncate_limit: 100 +select * from alter2.t1 +-- +TABLE: name="alter2.t1" schema="alter2" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM alter2.t1" +== 1074 +-- truncate_limit: 100 +select * from alter2.v1 +-- +TABLE: name="alter2.v1" schema="alter2" table="v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM alter2.v1" +== 1075 +-- truncate_limit: 100 +select alter2.plus1(41) +-- +FUNCTION: name="alter2.plus1" function="plus1" schema="alter2" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT alter2.plus1(41)" +== 1076 +-- truncate_limit: 100 +-- clean up +drop schema alter2 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA alter2 CASCADE" +== 1077 +-- truncate_limit: 100 +|-- +-- composite types +|-- + +CREATE TYPE test_type AS (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE test_type AS (a int)" +== 1078 +-- truncate_limit: 100 +ALTER TYPE nosuchtype ADD ATTRIBUTE b text +-- +TABLE: name="nosuchtype" schema="" table="nosuchtype" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE nosuchtype ADD ATTRIBUTE b text" +== 1079 +-- truncate_limit: 100 +-- fails + +ALTER TYPE test_type ADD ATTRIBUTE b text +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type ADD ATTRIBUTE b text" +== 1080 +-- truncate_limit: 100 +ALTER TYPE test_type ADD ATTRIBUTE b text +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type ADD ATTRIBUTE b text" +== 1081 +-- truncate_limit: 100 +-- fails + +ALTER TYPE test_type ALTER ATTRIBUTE b SET DATA TYPE varchar +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type ALTER ATTRIBUTE b TYPE varchar" +== 1082 +-- truncate_limit: 100 +ALTER TYPE test_type ALTER ATTRIBUTE b SET DATA TYPE integer +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type ALTER ATTRIBUTE b TYPE int" +== 1083 +-- truncate_limit: 100 +ALTER TYPE test_type DROP ATTRIBUTE b +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type DROP ATTRIBUTE b" +== 1084 +-- truncate_limit: 100 +ALTER TYPE test_type DROP ATTRIBUTE c +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type DROP ATTRIBUTE c" +== 1085 +-- truncate_limit: 100 +-- fails + +ALTER TYPE test_type DROP ATTRIBUTE IF EXISTS c +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type DROP ATTRIBUTE IF EXISTS c" +== 1086 +-- truncate_limit: 100 +ALTER TYPE test_type DROP ATTRIBUTE a, ADD ATTRIBUTE d boolean +-- +TABLE: name="test_type" schema="" table="test_type" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type DROP ATTRIBUTE a, ADD ATTRIBUTE d boolean" +== 1087 +-- truncate_limit: 100 +ALTER TYPE test_type RENAME ATTRIBUTE a TO aa +-- +STMT: RenameStmt +TRUNCATED: "ALTER TYPE test_type RENAME ATTRIBUTE a TO aa" +== 1088 +-- truncate_limit: 100 +ALTER TYPE test_type RENAME ATTRIBUTE d TO dd +-- +STMT: RenameStmt +TRUNCATED: "ALTER TYPE test_type RENAME ATTRIBUTE d TO dd" +== 1089 +-- truncate_limit: 100 +DROP TYPE test_type +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE test_type" +== 1090 +-- truncate_limit: 100 +CREATE TYPE test_type1 AS (a int, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE test_type1 AS (a int, b text)" +== 1091 +-- truncate_limit: 100 +CREATE TABLE test_tbl1 (x int, y test_type1) +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_tbl1 (x int, y test_type1)" +== 1092 +-- truncate_limit: 100 +ALTER TYPE test_type1 ALTER ATTRIBUTE b TYPE varchar +-- +TABLE: name="test_type1" schema="" table="test_type1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type1 ALTER ATTRIBUTE b TYPE varchar" +== 1093 +-- truncate_limit: 100 +-- fails + +DROP TABLE test_tbl1 +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_tbl1" +== 1094 +-- truncate_limit: 100 +CREATE TABLE test_tbl1 (x int, y text) +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_tbl1 (x int, y text)" +== 1095 +-- truncate_limit: 100 +CREATE INDEX test_tbl1_idx ON test_tbl1((row(x,y)::test_type1)) +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_tbl1_idx ON test_tbl1 USING btree ((ROW(x, y)::test_type1))" +== 1096 +-- truncate_limit: 100 +ALTER TYPE test_type1 ALTER ATTRIBUTE b TYPE varchar +-- +TABLE: name="test_type1" schema="" table="test_type1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type1 ALTER ATTRIBUTE b TYPE varchar" +== 1097 +-- truncate_limit: 100 +-- fails + +DROP TABLE test_tbl1 +-- +TABLE: name="test_tbl1" schema="" table="test_tbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_tbl1" +== 1098 +-- truncate_limit: 100 +DROP TYPE test_type1 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE test_type1" +== 1099 +-- truncate_limit: 100 +CREATE TYPE test_type2 AS (a int, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE test_type2 AS (a int, b text)" +== 1100 +-- truncate_limit: 100 +CREATE TABLE test_tbl2 OF test_type2 +-- +TABLE: name="test_tbl2" schema="" table="test_tbl2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_tbl2 OF test_type2" +== 1101 +-- truncate_limit: 100 +CREATE TABLE test_tbl2_subclass () INHERITS (test_tbl2) +-- +TABLE: name="test_tbl2_subclass" schema="" table="test_tbl2_subclass" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_tbl2_subclass () INHERITS (test_tbl2)" +== 1102 +-- truncate_limit: 100 +ALTER TYPE test_type2 ADD ATTRIBUTE c text +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type2 ADD ATTRIBUTE c text" +== 1103 +-- truncate_limit: 100 +-- fails +ALTER TYPE test_type2 ADD ATTRIBUTE c text CASCADE +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type2 ADD ATTRIBUTE c text CASCADE" +== 1104 +-- truncate_limit: 100 +ALTER TYPE test_type2 ALTER ATTRIBUTE b TYPE varchar +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type2 ALTER ATTRIBUTE b TYPE varchar" +== 1105 +-- truncate_limit: 100 +-- fails +ALTER TYPE test_type2 ALTER ATTRIBUTE b TYPE varchar CASCADE +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type2 ALTER ATTRIBUTE b TYPE varchar CASCADE" +== 1106 +-- truncate_limit: 100 +ALTER TYPE test_type2 DROP ATTRIBUTE b +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type2 DROP ATTRIBUTE b" +== 1107 +-- truncate_limit: 100 +-- fails +ALTER TYPE test_type2 DROP ATTRIBUTE b CASCADE +-- +TABLE: name="test_type2" schema="" table="test_type2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type2 DROP ATTRIBUTE b CASCADE" +== 1108 +-- truncate_limit: 100 +ALTER TYPE test_type2 RENAME ATTRIBUTE a TO aa +-- +STMT: RenameStmt +TRUNCATED: "ALTER TYPE test_type2 RENAME ATTRIBUTE a TO aa" +== 1109 +-- truncate_limit: 100 +-- fails +ALTER TYPE test_type2 RENAME ATTRIBUTE a TO aa CASCADE +-- +STMT: RenameStmt +TRUNCATED: "ALTER TYPE test_type2 RENAME ATTRIBUTE a TO aa CASCADE" +== 1110 +-- truncate_limit: 100 +DROP TABLE test_tbl2_subclass, test_tbl2 +-- +TABLE: name="test_tbl2_subclass" schema="" table="test_tbl2_subclass" ctx=DDL +TABLE: name="test_tbl2" schema="" table="test_tbl2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_tbl2_subclass, test_tbl2" +== 1111 +-- truncate_limit: 100 +DROP TYPE test_type2 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE test_type2" +== 1112 +-- truncate_limit: 100 +CREATE TYPE test_typex AS (a int, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE test_typex AS (a int, b text)" +== 1113 +-- truncate_limit: 100 +CREATE TABLE test_tblx (x int, y test_typex check ((y).a > 0)) +-- +TABLE: name="test_tblx" schema="" table="test_tblx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_tblx (x int, y test_typex CHECK ((y).a > 0))" +== 1114 +-- truncate_limit: 100 +ALTER TYPE test_typex DROP ATTRIBUTE a +-- +TABLE: name="test_typex" schema="" table="test_typex" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_typex DROP ATTRIBUTE a" +== 1115 +-- truncate_limit: 100 +-- fails +ALTER TYPE test_typex DROP ATTRIBUTE a CASCADE +-- +TABLE: name="test_typex" schema="" table="test_typex" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_typex DROP ATTRIBUTE a CASCADE" +== 1116 +-- truncate_limit: 100 +DROP TABLE test_tblx +-- +TABLE: name="test_tblx" schema="" table="test_tblx" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_tblx" +== 1117 +-- truncate_limit: 100 +DROP TYPE test_typex +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE test_typex" +== 1118 +-- truncate_limit: 100 +-- This test isn't that interesting on its own, but the purpose is to leave +-- behind a table to test pg_upgrade with. The table has a composite type +-- column in it, and the composite type has a dropped attribute. +CREATE TYPE test_type3 AS (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE test_type3 AS (a int)" +== 1119 +-- truncate_limit: 100 +CREATE TABLE test_tbl3 (c) AS SELECT '(1)'::test_type3 +-- +TABLE: name="test_tbl3" schema="" table="test_tbl3" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test_tbl3(c) AS SELECT '(1)'::test_type3" +== 1120 +-- truncate_limit: 100 +ALTER TYPE test_type3 DROP ATTRIBUTE a, ADD ATTRIBUTE b int +-- +TABLE: name="test_type3" schema="" table="test_type3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE test_type3 DROP ATTRIBUTE a, ADD ATTRIBUTE b int" +== 1121 +-- truncate_limit: 100 +CREATE TYPE test_type_empty AS () +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE test_type_empty AS ()" +== 1122 +-- truncate_limit: 100 +DROP TYPE test_type_empty +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE test_type_empty" +== 1123 +-- truncate_limit: 100 +|-- +-- typed tables: OF / NOT OF +|-- + +CREATE TYPE tt_t0 AS (z inet, x int, y numeric(8,2)) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE tt_t0 AS (z inet, x int, y numeric(8, 2))" +== 1124 +-- truncate_limit: 100 +ALTER TYPE tt_t0 DROP ATTRIBUTE z +-- +TABLE: name="tt_t0" schema="" table="tt_t0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE tt_t0 DROP ATTRIBUTE z" +== 1125 +-- truncate_limit: 100 +CREATE TABLE tt0 (x int NOT NULL, y numeric(8,2)) +-- +TABLE: name="tt0" schema="" table="tt0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt0 (x int NOT NULL, y numeric(8, 2))" +== 1126 +-- truncate_limit: 100 +-- OK +CREATE TABLE tt1 (x int, y bigint) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt1 (x int, y bigint)" +== 1127 +-- truncate_limit: 100 +-- wrong base type +CREATE TABLE tt2 (x int, y numeric(9,2)) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt2 (x int, y numeric(9, 2))" +== 1128 +-- truncate_limit: 100 +-- wrong typmod +CREATE TABLE tt3 (y numeric(8,2), x int) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt3 (y numeric(8, 2), x int)" +== 1129 +-- truncate_limit: 100 +-- wrong column order +CREATE TABLE tt4 (x int) +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt4 (x int)" +== 1130 +-- truncate_limit: 100 +-- too few columns +CREATE TABLE tt5 (x int, y numeric(8,2), z int) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt5 (x int, y numeric(8, 2), z int)" +== 1131 +-- truncate_limit: 100 +-- too few columns +CREATE TABLE tt6 () INHERITS (tt0) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt6 () INHERITS (tt0)" +== 1132 +-- truncate_limit: 100 +-- can't have a parent +CREATE TABLE tt7 (x int, q text, y numeric(8,2)) +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt7 (x int, q text, y numeric(8, 2))" +== 1133 +-- truncate_limit: 100 +ALTER TABLE tt7 DROP q +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7 DROP q" +== 1134 +-- truncate_limit: 100 +-- OK + +ALTER TABLE tt0 OF tt_t0 +-- +TABLE: name="tt0" schema="" table="tt0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt0 OF tt_t0" +== 1135 +-- truncate_limit: 100 +ALTER TABLE tt1 OF tt_t0 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt1 OF tt_t0" +== 1136 +-- truncate_limit: 100 +ALTER TABLE tt2 OF tt_t0 +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt2 OF tt_t0" +== 1137 +-- truncate_limit: 100 +ALTER TABLE tt3 OF tt_t0 +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt3 OF tt_t0" +== 1138 +-- truncate_limit: 100 +ALTER TABLE tt4 OF tt_t0 +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt4 OF tt_t0" +== 1139 +-- truncate_limit: 100 +ALTER TABLE tt5 OF tt_t0 +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt5 OF tt_t0" +== 1140 +-- truncate_limit: 100 +ALTER TABLE tt6 OF tt_t0 +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt6 OF tt_t0" +== 1141 +-- truncate_limit: 100 +ALTER TABLE tt7 OF tt_t0 +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7 OF tt_t0" +== 1142 +-- truncate_limit: 100 +CREATE TYPE tt_t1 AS (x int, y numeric(8,2)) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE tt_t1 AS (x int, y numeric(8, 2))" +== 1143 +-- truncate_limit: 100 +ALTER TABLE tt7 OF tt_t1 +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7 OF tt_t1" +== 1144 +-- truncate_limit: 100 +-- reassign an already-typed table +ALTER TABLE tt7 NOT OF +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7 NOT OF" +== 1145 +-- truncate_limit: 100 +-- make sure we can drop a constraint on the parent but it remains on the child +CREATE TABLE test_drop_constr_parent (c text CHECK (c IS NOT NULL)) +-- +TABLE: name="test_drop_constr_parent" schema="" table="test_drop_constr_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_drop_constr_parent (c text CHECK (c IS NOT NULL))" +== 1146 +-- truncate_limit: 100 +CREATE TABLE test_drop_constr_child () INHERITS (test_drop_constr_parent) +-- +TABLE: name="test_drop_constr_child" schema="" table="test_drop_constr_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_drop_constr_child () INHERITS (test_drop_constr_parent)" +== 1147 +-- truncate_limit: 100 +ALTER TABLE ONLY test_drop_constr_parent DROP CONSTRAINT "test_drop_constr_parent_c_check" +-- +TABLE: name="test_drop_constr_parent" schema="" table="test_drop_constr_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY test_drop_constr_parent DROP CONSTRAINT test_drop_constr_parent_c_check" +== 1148 +-- truncate_limit: 100 +-- should fail +INSERT INTO test_drop_constr_child (c) VALUES (NULL) +-- +TABLE: name="test_drop_constr_child" schema="" table="test_drop_constr_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_drop_constr_child (c) VALUES (NULL)" +== 1149 +-- truncate_limit: 100 +DROP TABLE test_drop_constr_parent CASCADE +-- +TABLE: name="test_drop_constr_parent" schema="" table="test_drop_constr_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_drop_constr_parent CASCADE" +== 1150 +-- truncate_limit: 100 +|-- +-- IF EXISTS test +|-- +ALTER TABLE IF EXISTS tt8 ADD COLUMN f int +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 ADD COLUMN f int" +== 1151 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 ADD CONSTRAINT xxx PRIMARY KEY(f) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 ADD CONSTRAINT xxx PRIMARY KEY (f)" +== 1152 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 ADD CHECK (f BETWEEN 0 AND 10) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 ADD CHECK (f BETWEEN 0 AND 10)" +== 1153 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 ALTER COLUMN f SET DEFAULT 0 +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 ALTER COLUMN f SET DEFAULT 0" +== 1154 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 RENAME COLUMN f TO f1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 RENAME COLUMN f TO f1" +== 1155 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2" +== 1156 +-- truncate_limit: 100 +CREATE TABLE tt8(a int) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt8 (a int)" +== 1157 +-- truncate_limit: 100 +CREATE SCHEMA alter2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA alter2" +== 1158 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 ADD COLUMN f int +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 ADD COLUMN f int" +== 1159 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 ADD CONSTRAINT xxx PRIMARY KEY(f) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 ADD CONSTRAINT xxx PRIMARY KEY (f)" +== 1160 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 ADD CHECK (f BETWEEN 0 AND 10) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 ADD CHECK (f BETWEEN 0 AND 10)" +== 1161 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 ALTER COLUMN f SET DEFAULT 0 +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 ALTER COLUMN f SET DEFAULT 0" +== 1162 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 RENAME COLUMN f TO f1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 RENAME COLUMN f TO f1" +== 1163 +-- truncate_limit: 100 +ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2" +== 1164 +-- truncate_limit: 100 +DROP TABLE alter2.tt8 +-- +TABLE: name="alter2.tt8" schema="alter2" table="tt8" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE alter2.tt8" +== 1165 +-- truncate_limit: 100 +DROP SCHEMA alter2 +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA alter2" +== 1166 +-- truncate_limit: 100 +|-- +-- Check conflicts between index and CHECK constraint names +|-- +CREATE TABLE tt9(c integer) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt9 (c int)" +== 1167 +-- truncate_limit: 100 +ALTER TABLE tt9 ADD CHECK(c > 1) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD CHECK (c > 1)" +== 1168 +-- truncate_limit: 100 +ALTER TABLE tt9 ADD CHECK(c > 2) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD CHECK (c > 2)" +== 1169 +-- truncate_limit: 100 +-- picks nonconflicting name +ALTER TABLE tt9 ADD CONSTRAINT foo CHECK(c > 3) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD CONSTRAINT foo CHECK (c > 3)" +== 1170 +-- truncate_limit: 100 +ALTER TABLE tt9 ADD CONSTRAINT foo CHECK(c > 4) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD CONSTRAINT foo CHECK (c > 4)" +== 1171 +-- truncate_limit: 100 +-- fail, dup name +ALTER TABLE tt9 ADD UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD UNIQUE (c)" +== 1172 +-- truncate_limit: 100 +ALTER TABLE tt9 ADD UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD UNIQUE (c)" +== 1173 +-- truncate_limit: 100 +-- picks nonconflicting name +ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key UNIQUE (c)" +== 1174 +-- truncate_limit: 100 +-- fail, dup name +ALTER TABLE tt9 ADD CONSTRAINT foo UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD CONSTRAINT foo UNIQUE (c)" +== 1175 +-- truncate_limit: 100 +-- fail, dup name +ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key CHECK(c > 5) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key CHECK (c > 5)" +== 1176 +-- truncate_limit: 100 +-- fail, dup name +ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key2 CHECK(c > 6) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key2 CHECK (c > 6)" +== 1177 +-- truncate_limit: 100 +ALTER TABLE tt9 ADD UNIQUE(c) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 ADD UNIQUE (c)" +== 1178 +-- truncate_limit: 100 +-- picks nonconflicting name +DROP TABLE tt9 +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tt9" +== 1179 +-- truncate_limit: 100 +-- Check that comments on constraints and indexes are not lost at ALTER TABLE. +CREATE TABLE comment_test ( + id int, + positive_col int CHECK (positive_col > 0), + indexed_col int, + CONSTRAINT comment_test_pk PRIMARY KEY (id)) +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE comment_test (id int, positive_col int CHECK (positive_col > 0), indexed_col int, CO..." +== 1180 +-- truncate_limit: 100 +CREATE INDEX comment_test_index ON comment_test(indexed_col) +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX comment_test_index ON comment_test USING btree (indexed_col)" +== 1181 +-- truncate_limit: 100 +COMMENT ON COLUMN comment_test.id IS 'Column ''id'' on comment_test' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN comment_test.id IS 'Column ''id'' on comment_test'" +== 1182 +-- truncate_limit: 100 +COMMENT ON INDEX comment_test_index IS 'Simple index on comment_test' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX comment_test_index IS 'Simple index on comment_test'" +== 1183 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT comment_test_positive_col_check ON comment_test IS 'CHECK constraint on comment_test.positive_col' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT comment_test_positive_col_check ON comment_test IS 'CHECK constraint on com..." +== 1184 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT comment_test_pk ON comment_test IS 'PRIMARY KEY constraint of comment_test' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT comment_test_pk ON comment_test IS 'PRIMARY KEY constraint of comment_test'" +== 1185 +-- truncate_limit: 100 +COMMENT ON INDEX comment_test_pk IS 'Index backing the PRIMARY KEY of comment_test' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX comment_test_pk IS 'Index backing the PRIMARY KEY of comment_test'" +== 1186 +-- truncate_limit: 100 +SELECT col_description('comment_test'::regclass, 1) as comment +-- +FUNCTION: name="col_description" function="col_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT col_description('comment_test'::regclass, 1) AS comment" +== 1187 +-- truncate_limit: 100 +SELECT indexrelid::regclass::text as index, obj_description(indexrelid, 'pg_class') as comment FROM pg_index where indrelid = 'comment_test'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE indrelid = 'comment_test'::regclass ORDER BY 1, 2" +== 1188 +-- truncate_limit: 100 +SELECT conname as constraint, obj_description(oid, 'pg_constraint') as comment FROM pg_constraint where conrelid = 'comment_test'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'comment_test'::regclass ORDER BY 1, 2" +== 1189 +-- truncate_limit: 100 +-- Change the datatype of all the columns. ALTER TABLE is optimized to not +-- rebuild an index if the new data type is binary compatible with the old +-- one. Check do a dummy ALTER TABLE that doesn't change the datatype +-- first, to test that no-op codepath, and another one that does. +ALTER TABLE comment_test ALTER COLUMN indexed_col SET DATA TYPE int +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment_test ALTER COLUMN indexed_col TYPE int" +== 1190 +-- truncate_limit: 100 +ALTER TABLE comment_test ALTER COLUMN indexed_col SET DATA TYPE text +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment_test ALTER COLUMN indexed_col TYPE text" +== 1191 +-- truncate_limit: 100 +ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE int +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment_test ALTER COLUMN id TYPE int" +== 1192 +-- truncate_limit: 100 +ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE text +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment_test ALTER COLUMN id TYPE text" +== 1193 +-- truncate_limit: 100 +ALTER TABLE comment_test ALTER COLUMN positive_col SET DATA TYPE int +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment_test ALTER COLUMN positive_col TYPE int" +== 1194 +-- truncate_limit: 100 +ALTER TABLE comment_test ALTER COLUMN positive_col SET DATA TYPE bigint +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment_test ALTER COLUMN positive_col TYPE bigint" +== 1195 +-- truncate_limit: 100 +-- Check that the comments are intact. +SELECT col_description('comment_test'::regclass, 1) as comment +-- +FUNCTION: name="col_description" function="col_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT col_description('comment_test'::regclass, 1) AS comment" +== 1196 +-- truncate_limit: 100 +SELECT indexrelid::regclass::text as index, obj_description(indexrelid, 'pg_class') as comment FROM pg_index where indrelid = 'comment_test'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE indrelid = 'comment_test'::regclass ORDER BY 1, 2" +== 1197 +-- truncate_limit: 100 +SELECT conname as constraint, obj_description(oid, 'pg_constraint') as comment FROM pg_constraint where conrelid = 'comment_test'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'comment_test'::regclass ORDER BY 1, 2" +== 1198 +-- truncate_limit: 100 +-- Check compatibility for foreign keys and comments. This is done +-- separately as rebuilding the column type of the parent leads +-- to an error and would reduce the test scope. +CREATE TABLE comment_test_child ( + id text CONSTRAINT comment_test_child_fk REFERENCES comment_test) +-- +TABLE: name="comment_test_child" schema="" table="comment_test_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE comment_test_child (id text CONSTRAINT comment_test_child_fk REFERENCES comment_test)" +== 1199 +-- truncate_limit: 100 +CREATE INDEX comment_test_child_fk ON comment_test_child(id) +-- +TABLE: name="comment_test_child" schema="" table="comment_test_child" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX comment_test_child_fk ON comment_test_child USING btree (id)" +== 1200 +-- truncate_limit: 100 +COMMENT ON COLUMN comment_test_child.id IS 'Column ''id'' on comment_test_child' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN comment_test_child.id IS 'Column ''id'' on comment_test_child'" +== 1201 +-- truncate_limit: 100 +COMMENT ON INDEX comment_test_child_fk IS 'Index backing the FOREIGN KEY of comment_test_child' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX comment_test_child_fk IS 'Index backing the FOREIGN KEY of comment_test_child'" +== 1202 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT comment_test_child_fk ON comment_test_child IS 'FOREIGN KEY constraint of comment_test_child' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT comment_test_child_fk ON comment_test_child IS 'FOREIGN KEY constraint of c..." +== 1203 +-- truncate_limit: 100 +-- Change column type of parent +ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE text +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment_test ALTER COLUMN id TYPE text" +== 1204 +-- truncate_limit: 100 +ALTER TABLE comment_test ALTER COLUMN id SET DATA TYPE int USING id::integer +-- +TABLE: name="comment_test" schema="" table="comment_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment_test ALTER COLUMN id TYPE int USING id::int" +== 1205 +-- truncate_limit: 100 +-- Comments should be intact +SELECT col_description('comment_test_child'::regclass, 1) as comment +-- +FUNCTION: name="col_description" function="col_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT col_description('comment_test_child'::regclass, 1) AS comment" +== 1206 +-- truncate_limit: 100 +SELECT indexrelid::regclass::text as index, obj_description(indexrelid, 'pg_class') as comment FROM pg_index where indrelid = 'comment_test_child'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE indrelid = 'comment_test_child'::regclass ORDER BY 1, 2" +== 1207 +-- truncate_limit: 100 +SELECT conname as constraint, obj_description(oid, 'pg_constraint') as comment FROM pg_constraint where conrelid = 'comment_test_child'::regclass ORDER BY 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'comment_test_child'::regclass ORDER BY 1, 2" +== 1208 +-- truncate_limit: 100 +-- Check that we map relation oids to filenodes and back correctly. Only +-- display bad mappings so the test output doesn't change all the time. A +-- filenode function call can return NULL for a relation dropped concurrently +-- with the call's surrounding query, so ignore a NULL mapped_oid for +-- relations that no longer exist after all calls finish. +-- Temporary relations are ignored, as not supported by pg_filenode_relation(). +CREATE TEMP TABLE filenode_mapping AS +SELECT + oid, mapped_oid, reltablespace, relfilenode, relname +FROM pg_class, + pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid +WHERE relkind IN ('r', 'i', 'S', 't', 'm') + AND relpersistence != 't' + AND mapped_oid IS DISTINCT FROM oid +-- +TABLE: name="filenode_mapping" schema="" table="filenode_mapping" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_filenode_relation" function="pg_filenode_relation" schema="" ctx=Call +FUNCTION: name="pg_relation_filenode" function="pg_relation_filenode" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relpersistence" +FILTER: schema="" table="" column="mapped_oid" +FILTER: schema="" table="" column="oid" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE filenode_mapping AS SELECT oid, mapped_oid, reltablespace, relfilenode, re..." +== 1209 +-- truncate_limit: 100 +SELECT m.* FROM filenode_mapping m LEFT JOIN pg_class c ON c.oid = m.oid +WHERE c.oid IS NOT NULL OR m.mapped_oid IS NOT NULL +-- +TABLE: name="filenode_mapping" schema="" table="filenode_mapping" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "m"="filenode_mapping" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="m" column="mapped_oid" +STMT: SelectStmt +TRUNCATED: "SELECT m.* FROM filenode_mapping m LEFT JOIN pg_class c ON c.oid = m.oid WHERE ..." +== 1210 +-- truncate_limit: 100 +-- Checks on creating and manipulation of user defined relations in +-- pg_catalog. + +SHOW allow_system_table_mods +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW allow_system_table_mods" +== 1211 +-- truncate_limit: 100 +-- disallowed because of search_path issues with pg_dump +CREATE TABLE pg_catalog.new_system_table() +-- +TABLE: name="pg_catalog.new_system_table" schema="pg_catalog" table="new_system_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pg_catalog.new_system_table ()" +== 1212 +-- truncate_limit: 100 +-- instead create in public first, move to catalog +CREATE TABLE new_system_table(id serial primary key, othercol text) +-- +TABLE: name="new_system_table" schema="" table="new_system_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE new_system_table (id serial PRIMARY KEY, othercol text)" +== 1213 +-- truncate_limit: 100 +ALTER TABLE new_system_table SET SCHEMA pg_catalog +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE new_system_table SET SCHEMA pg_catalog" +== 1214 +-- truncate_limit: 100 +ALTER TABLE new_system_table SET SCHEMA public +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE new_system_table SET SCHEMA public" +== 1215 +-- truncate_limit: 100 +ALTER TABLE new_system_table SET SCHEMA pg_catalog +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE new_system_table SET SCHEMA pg_catalog" +== 1216 +-- truncate_limit: 100 +-- will be ignored -- already there: +ALTER TABLE new_system_table SET SCHEMA pg_catalog +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE new_system_table SET SCHEMA pg_catalog" +== 1217 +-- truncate_limit: 100 +ALTER TABLE new_system_table RENAME TO old_system_table +-- +TABLE: name="new_system_table" schema="" table="new_system_table" ctx=DDL +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE new_system_table RENAME TO old_system_table" +== 1218 +-- truncate_limit: 100 +CREATE INDEX old_system_table__othercol ON old_system_table (othercol) +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX old_system_table__othercol ON old_system_table USING btree (othercol)" +== 1219 +-- truncate_limit: 100 +INSERT INTO old_system_table(othercol) VALUES ('somedata'), ('otherdata') +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO old_system_table (othercol) VALUES ('somedata'), ('otherdata')" +== 1220 +-- truncate_limit: 100 +UPDATE old_system_table SET id = -id +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE old_system_table SET id = - id" +== 1221 +-- truncate_limit: 100 +DELETE FROM old_system_table WHERE othercol = 'somedata' +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM old_system_table WHERE othercol = 'somedata'" +== 1222 +-- truncate_limit: 100 +TRUNCATE old_system_table +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE old_system_table" +== 1223 +-- truncate_limit: 100 +ALTER TABLE old_system_table DROP CONSTRAINT new_system_table_pkey +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE old_system_table DROP CONSTRAINT new_system_table_pkey" +== 1224 +-- truncate_limit: 100 +ALTER TABLE old_system_table DROP COLUMN othercol +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE old_system_table DROP othercol" +== 1225 +-- truncate_limit: 100 +DROP TABLE old_system_table +-- +TABLE: name="old_system_table" schema="" table="old_system_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE old_system_table" +== 1226 +-- truncate_limit: 100 +-- set logged +CREATE UNLOGGED TABLE unlogged1(f1 SERIAL PRIMARY KEY, f2 TEXT) +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE unlogged1 (f1 serial PRIMARY KEY, f2 text)" +== 1227 +-- truncate_limit: 100 +-- has sequence, toast +-- check relpersistence of an unlogged table +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged1' +UNION ALL +SELECT r.relname || ' toast table', t.relkind, t.relpersistence FROM pg_class r JOIN pg_class t ON t.oid = r.reltoastrelid WHERE r.relname ~ '^unlogged1' +UNION ALL +SELECT r.relname || ' toast index', ri.relkind, ri.relpersistence FROM pg_class r join pg_class t ON t.oid = r.reltoastrelid JOIN pg_index i ON i.indrelid = t.oid JOIN pg_class ri ON ri.oid = i.indexrelid WHERE r.relname ~ '^unlogged1' +ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "i"="pg_index" +ALIAS: "r"="pg_class" +ALIAS: "ri"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="r" column="relname" +FILTER: schema="" table="r" column="relname" +STMT: SelectStmt +TRUNCATED: "(SELECT ... FROM pg_class WHERE ... UNION ALL SELECT ... FROM pg_class r JOIN pg_class t ON t.oid..." +== 1228 +-- truncate_limit: 100 +CREATE UNLOGGED TABLE unlogged2(f1 SERIAL PRIMARY KEY, f2 INTEGER REFERENCES unlogged1) +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE unlogged2 (f1 serial PRIMARY KEY, f2 int REFERENCES unlogged1)" +== 1229 +-- truncate_limit: 100 +-- foreign key +CREATE UNLOGGED TABLE unlogged3(f1 SERIAL PRIMARY KEY, f2 INTEGER REFERENCES unlogged3) +-- +TABLE: name="unlogged3" schema="" table="unlogged3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE unlogged3 (f1 serial PRIMARY KEY, f2 int REFERENCES unlogged3)" +== 1230 +-- truncate_limit: 100 +-- self-referencing foreign key +ALTER TABLE unlogged3 SET LOGGED +-- +TABLE: name="unlogged3" schema="" table="unlogged3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE unlogged3 SET LOGGED" +== 1231 +-- truncate_limit: 100 +-- skip self-referencing foreign key +ALTER TABLE unlogged2 SET LOGGED +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE unlogged2 SET LOGGED" +== 1232 +-- truncate_limit: 100 +-- fails because a foreign key to an unlogged table exists +ALTER TABLE unlogged1 SET LOGGED +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE unlogged1 SET LOGGED" +== 1233 +-- truncate_limit: 100 +-- check relpersistence of an unlogged table after changing to permanent +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged1' +UNION ALL +SELECT r.relname || ' toast table', t.relkind, t.relpersistence FROM pg_class r JOIN pg_class t ON t.oid = r.reltoastrelid WHERE r.relname ~ '^unlogged1' +UNION ALL +SELECT r.relname || ' toast index', ri.relkind, ri.relpersistence FROM pg_class r join pg_class t ON t.oid = r.reltoastrelid JOIN pg_index i ON i.indrelid = t.oid JOIN pg_class ri ON ri.oid = i.indexrelid WHERE r.relname ~ '^unlogged1' +ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "i"="pg_index" +ALIAS: "r"="pg_class" +ALIAS: "ri"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="r" column="relname" +FILTER: schema="" table="r" column="relname" +STMT: SelectStmt +TRUNCATED: "(SELECT ... FROM pg_class WHERE ... UNION ALL SELECT ... FROM pg_class r JOIN pg_class t ON t.oid..." +== 1234 +-- truncate_limit: 100 +ALTER TABLE unlogged1 SET LOGGED +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE unlogged1 SET LOGGED" +== 1235 +-- truncate_limit: 100 +-- silently do nothing +DROP TABLE unlogged3 +-- +TABLE: name="unlogged3" schema="" table="unlogged3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unlogged3" +== 1236 +-- truncate_limit: 100 +DROP TABLE unlogged2 +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unlogged2" +== 1237 +-- truncate_limit: 100 +DROP TABLE unlogged1 +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unlogged1" +== 1238 +-- truncate_limit: 100 +-- set unlogged +CREATE TABLE logged1(f1 SERIAL PRIMARY KEY, f2 TEXT) +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE logged1 (f1 serial PRIMARY KEY, f2 text)" +== 1239 +-- truncate_limit: 100 +-- has sequence, toast +-- check relpersistence of a permanent table +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^logged1' +UNION ALL +SELECT r.relname || ' toast table', t.relkind, t.relpersistence FROM pg_class r JOIN pg_class t ON t.oid = r.reltoastrelid WHERE r.relname ~ '^logged1' +UNION ALL +SELECT r.relname ||' toast index', ri.relkind, ri.relpersistence FROM pg_class r join pg_class t ON t.oid = r.reltoastrelid JOIN pg_index i ON i.indrelid = t.oid JOIN pg_class ri ON ri.oid = i.indexrelid WHERE r.relname ~ '^logged1' +ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "i"="pg_index" +ALIAS: "r"="pg_class" +ALIAS: "ri"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="r" column="relname" +FILTER: schema="" table="r" column="relname" +STMT: SelectStmt +TRUNCATED: "(SELECT ... FROM pg_class WHERE ... UNION ALL SELECT ... FROM pg_class r JOIN pg_class t ON t.oid..." +== 1240 +-- truncate_limit: 100 +CREATE TABLE logged2(f1 SERIAL PRIMARY KEY, f2 INTEGER REFERENCES logged1) +-- +TABLE: name="logged2" schema="" table="logged2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE logged2 (f1 serial PRIMARY KEY, f2 int REFERENCES logged1)" +== 1241 +-- truncate_limit: 100 +-- foreign key +CREATE TABLE logged3(f1 SERIAL PRIMARY KEY, f2 INTEGER REFERENCES logged3) +-- +TABLE: name="logged3" schema="" table="logged3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE logged3 (f1 serial PRIMARY KEY, f2 int REFERENCES logged3)" +== 1242 +-- truncate_limit: 100 +-- self-referencing foreign key +ALTER TABLE logged1 SET UNLOGGED +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE logged1 SET UNLOGGED" +== 1243 +-- truncate_limit: 100 +-- fails because a foreign key from a permanent table exists +ALTER TABLE logged3 SET UNLOGGED +-- +TABLE: name="logged3" schema="" table="logged3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE logged3 SET UNLOGGED" +== 1244 +-- truncate_limit: 100 +-- skip self-referencing foreign key +ALTER TABLE logged2 SET UNLOGGED +-- +TABLE: name="logged2" schema="" table="logged2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE logged2 SET UNLOGGED" +== 1245 +-- truncate_limit: 100 +ALTER TABLE logged1 SET UNLOGGED +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE logged1 SET UNLOGGED" +== 1246 +-- truncate_limit: 100 +-- check relpersistence of a permanent table after changing to unlogged +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^logged1' +UNION ALL +SELECT r.relname || ' toast table', t.relkind, t.relpersistence FROM pg_class r JOIN pg_class t ON t.oid = r.reltoastrelid WHERE r.relname ~ '^logged1' +UNION ALL +SELECT r.relname || ' toast index', ri.relkind, ri.relpersistence FROM pg_class r join pg_class t ON t.oid = r.reltoastrelid JOIN pg_index i ON i.indrelid = t.oid JOIN pg_class ri ON ri.oid = i.indexrelid WHERE r.relname ~ '^logged1' +ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "i"="pg_index" +ALIAS: "r"="pg_class" +ALIAS: "ri"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="r" column="relname" +FILTER: schema="" table="r" column="relname" +STMT: SelectStmt +TRUNCATED: "(SELECT ... FROM pg_class WHERE ... UNION ALL SELECT ... FROM pg_class r JOIN pg_class t ON t.oid..." +== 1247 +-- truncate_limit: 100 +ALTER TABLE logged1 SET UNLOGGED +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE logged1 SET UNLOGGED" +== 1248 +-- truncate_limit: 100 +-- silently do nothing +DROP TABLE logged3 +-- +TABLE: name="logged3" schema="" table="logged3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE logged3" +== 1249 +-- truncate_limit: 100 +DROP TABLE logged2 +-- +TABLE: name="logged2" schema="" table="logged2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE logged2" +== 1250 +-- truncate_limit: 100 +DROP TABLE logged1 +-- +TABLE: name="logged1" schema="" table="logged1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE logged1" +== 1251 +-- truncate_limit: 100 +-- test ADD COLUMN IF NOT EXISTS +CREATE TABLE test_add_column(c1 integer) +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_add_column (c1 int)" +== 1252 +-- truncate_limit: 100 +ALTER TABLE test_add_column + ADD COLUMN c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN c2 int" +== 1253 +-- truncate_limit: 100 +ALTER TABLE test_add_column + ADD COLUMN c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN c2 int" +== 1254 +-- truncate_limit: 100 +-- fail because c2 already exists +ALTER TABLE ONLY test_add_column + ADD COLUMN c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY test_add_column ADD COLUMN c2 int" +== 1255 +-- truncate_limit: 100 +-- fail because c2 already exists +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c2 int" +== 1256 +-- truncate_limit: 100 +-- skipping because c2 already exists +ALTER TABLE ONLY test_add_column + ADD COLUMN IF NOT EXISTS c2 integer +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY test_add_column ADD COLUMN IF NOT EXISTS c2 int" +== 1257 +-- truncate_limit: 100 +-- skipping because c2 already exists +ALTER TABLE test_add_column + ADD COLUMN c2 integer, -- fail because c2 already exists + ADD COLUMN c3 integer primary key +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN c2 int, ADD COLUMN c3 int PRIMARY KEY" +== 1258 +-- truncate_limit: 100 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists + ADD COLUMN c3 integer primary key +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c2 int, ADD COLUMN c3 int PRIMARY KEY" +== 1259 +-- truncate_limit: 100 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists + ADD COLUMN IF NOT EXISTS c3 integer primary key +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c2 int, ADD COLUMN IF NOT EXISTS c3 int PRIM..." +== 1260 +-- truncate_limit: 100 +-- skipping because c3 already exists +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c2 integer, -- skipping because c2 already exists + ADD COLUMN IF NOT EXISTS c3 integer, -- skipping because c3 already exists + ADD COLUMN c4 integer REFERENCES test_add_column +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c2 int, ADD COLUMN IF NOT EXISTS c3 int, ADD..." +== 1261 +-- truncate_limit: 100 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c4 integer REFERENCES test_add_column +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c4 int REFERENCES test_add_column" +== 1262 +-- truncate_limit: 100 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c5 SERIAL CHECK (c5 > 8) +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c5 serial CHECK (c5 > 8)" +== 1263 +-- truncate_limit: 100 +ALTER TABLE test_add_column + ADD COLUMN IF NOT EXISTS c5 SERIAL CHECK (c5 > 10) +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c5 serial CHECK (c5 > 10)" +== 1264 +-- truncate_limit: 100 +DROP TABLE test_add_column +-- +TABLE: name="test_add_column" schema="" table="test_add_column" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_add_column" +== 1265 +-- truncate_limit: 100 +-- assorted cases with multiple ALTER TABLE steps +CREATE TABLE ataddindex(f1 INT) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ataddindex (f1 int)" +== 1266 +-- truncate_limit: 100 +INSERT INTO ataddindex VALUES (42), (43) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ataddindex VALUES (42), (43)" +== 1267 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ataddindexi0 ON ataddindex(f1) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ataddindexi0 ON ataddindex USING btree (f1)" +== 1268 +-- truncate_limit: 100 +ALTER TABLE ataddindex + ADD PRIMARY KEY USING INDEX ataddindexi0, + ALTER f1 TYPE BIGINT +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ataddindex ADD PRIMARY KEY USING INDEX ataddindexi0, ALTER COLUMN f1 TYPE bigint" +== 1269 +-- truncate_limit: 100 +DROP TABLE ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ataddindex" +== 1270 +-- truncate_limit: 100 +CREATE TABLE ataddindex(f1 VARCHAR(10)) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ataddindex (f1 varchar(10))" +== 1271 +-- truncate_limit: 100 +INSERT INTO ataddindex(f1) VALUES ('foo'), ('a') +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ataddindex (f1) VALUES ('foo'), ('a')" +== 1272 +-- truncate_limit: 100 +ALTER TABLE ataddindex + ALTER f1 SET DATA TYPE TEXT, + ADD EXCLUDE ((f1 LIKE 'a') WITH =) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ataddindex ALTER COLUMN f1 TYPE text, ADD EXCLUDE ((f1 LIKE 'a') WITH =)" +== 1273 +-- truncate_limit: 100 +DROP TABLE ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ataddindex" +== 1274 +-- truncate_limit: 100 +CREATE TABLE ataddindex(id int, ref_id int) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ataddindex (id int, ref_id int)" +== 1275 +-- truncate_limit: 100 +ALTER TABLE ataddindex + ADD PRIMARY KEY (id), + ADD FOREIGN KEY (ref_id) REFERENCES ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ataddindex ADD PRIMARY KEY (id), ADD FOREIGN KEY (ref_id) REFERENCES ataddindex" +== 1276 +-- truncate_limit: 100 +DROP TABLE ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ataddindex" +== 1277 +-- truncate_limit: 100 +CREATE TABLE ataddindex(id int, ref_id int) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ataddindex (id int, ref_id int)" +== 1278 +-- truncate_limit: 100 +ALTER TABLE ataddindex + ADD UNIQUE (id), + ADD FOREIGN KEY (ref_id) REFERENCES ataddindex (id) +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ataddindex ADD UNIQUE (id), ADD FOREIGN KEY (ref_id) REFERENCES ataddindex (id)" +== 1279 +-- truncate_limit: 100 +DROP TABLE ataddindex +-- +TABLE: name="ataddindex" schema="" table="ataddindex" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ataddindex" +== 1280 +-- truncate_limit: 100 +CREATE TABLE atnotnull1 () +-- +TABLE: name="atnotnull1" schema="" table="atnotnull1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atnotnull1 ()" +== 1281 +-- truncate_limit: 100 +ALTER TABLE atnotnull1 + ADD COLUMN a INT, + ALTER a SET NOT NULL +-- +TABLE: name="atnotnull1" schema="" table="atnotnull1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atnotnull1 ADD COLUMN a int, ALTER COLUMN a SET NOT NULL" +== 1282 +-- truncate_limit: 100 +ALTER TABLE atnotnull1 + ADD COLUMN c INT, + ADD PRIMARY KEY (c) +-- +TABLE: name="atnotnull1" schema="" table="atnotnull1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atnotnull1 ADD COLUMN c int, ADD PRIMARY KEY (c)" +== 1283 +-- truncate_limit: 100 +-- cannot drop column that is part of the partition key +CREATE TABLE partitioned ( + a int, + b int +) PARTITION BY RANGE (a, (a+b+1)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int, b int) PARTITION BY RANGE (a, ((a + b) + 1))" +== 1284 +-- truncate_limit: 100 +ALTER TABLE partitioned DROP COLUMN a +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned DROP a" +== 1285 +-- truncate_limit: 100 +ALTER TABLE partitioned ALTER COLUMN a TYPE char(5) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned ALTER COLUMN a TYPE char(5)" +== 1286 +-- truncate_limit: 100 +ALTER TABLE partitioned DROP COLUMN b +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned DROP b" +== 1287 +-- truncate_limit: 100 +ALTER TABLE partitioned ALTER COLUMN b TYPE char(5) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned ALTER COLUMN b TYPE char(5)" +== 1288 +-- truncate_limit: 100 +-- specifying storage parameters for partitioned tables is not supported +ALTER TABLE partitioned SET (fillfactor=100) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned SET (fillfactor=100)" +== 1289 +-- truncate_limit: 100 +-- partitioned table cannot participate in regular inheritance +CREATE TABLE nonpartitioned ( + a int, + b int +) +-- +TABLE: name="nonpartitioned" schema="" table="nonpartitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE nonpartitioned (a int, b int)" +== 1290 +-- truncate_limit: 100 +ALTER TABLE partitioned INHERIT nonpartitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned INHERIT nonpartitioned" +== 1291 +-- truncate_limit: 100 +ALTER TABLE nonpartitioned INHERIT partitioned +-- +TABLE: name="nonpartitioned" schema="" table="nonpartitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE nonpartitioned INHERIT partitioned" +== 1292 +-- truncate_limit: 100 +-- cannot add NO INHERIT constraint to partitioned tables +ALTER TABLE partitioned ADD CONSTRAINT chk_a CHECK (a > 0) NO INHERIT +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned ADD CONSTRAINT chk_a CHECK (a > 0) NO INHERIT" +== 1293 +-- truncate_limit: 100 +DROP TABLE partitioned, nonpartitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +TABLE: name="nonpartitioned" schema="" table="nonpartitioned" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE partitioned, nonpartitioned" +== 1294 +-- truncate_limit: 100 +|-- +-- ATTACH PARTITION +|-- + +-- check that target table is partitioned +CREATE TABLE unparted ( + a int +) +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unparted (a int)" +== 1295 +-- truncate_limit: 100 +CREATE TABLE fail_part (like unparted) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (LIKE unparted)" +== 1296 +-- truncate_limit: 100 +ALTER TABLE unparted ATTACH PARTITION fail_part FOR VALUES IN ('a') +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE unparted ATTACH PARTITION fail_part FOR VALUES IN ('a')" +== 1297 +-- truncate_limit: 100 +DROP TABLE unparted, fail_part +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unparted, fail_part" +== 1298 +-- truncate_limit: 100 +-- check that partition bound is compatible +CREATE TABLE list_parted ( + a int NOT NULL, + b char(2) COLLATE "C", + CONSTRAINT check_a CHECK (a > 0) +) PARTITION BY LIST (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted (a int NOT NULL, b char(2) COLLATE \"C\", CONSTRAINT check_a CHECK (a > 0)..." +== 1299 +-- truncate_limit: 100 +CREATE TABLE fail_part (LIKE list_parted) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (LIKE list_parted)" +== 1300 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES FROM (1) TO (10) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES FROM (1) TO (10)" +== 1301 +-- truncate_limit: 100 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_part" +== 1302 +-- truncate_limit: 100 +-- check that the table being attached exists +ALTER TABLE list_parted ATTACH PARTITION nonexistent FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION nonexistent FOR VALUES IN (1)" +== 1303 +-- truncate_limit: 100 +-- check ownership of the source table +CREATE ROLE regress_test_me +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_me" +== 1304 +-- truncate_limit: 100 +CREATE ROLE regress_test_not_me +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_not_me" +== 1305 +-- truncate_limit: 100 +CREATE TABLE not_owned_by_me (LIKE list_parted) +-- +TABLE: name="not_owned_by_me" schema="" table="not_owned_by_me" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE not_owned_by_me (LIKE list_parted)" +== 1306 +-- truncate_limit: 100 +ALTER TABLE not_owned_by_me OWNER TO regress_test_not_me +-- +TABLE: name="not_owned_by_me" schema="" table="not_owned_by_me" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE not_owned_by_me OWNER TO regress_test_not_me" +== 1307 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_test_me +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_test_me" +== 1308 +-- truncate_limit: 100 +CREATE TABLE owned_by_me ( + a int +) PARTITION BY LIST (a) +-- +TABLE: name="owned_by_me" schema="" table="owned_by_me" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE owned_by_me (a int) PARTITION BY LIST (a)" +== 1309 +-- truncate_limit: 100 +ALTER TABLE owned_by_me ATTACH PARTITION not_owned_by_me FOR VALUES IN (1) +-- +TABLE: name="owned_by_me" schema="" table="owned_by_me" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE owned_by_me ATTACH PARTITION not_owned_by_me FOR VALUES IN (1)" +== 1310 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 1311 +-- truncate_limit: 100 +DROP TABLE owned_by_me, not_owned_by_me +-- +TABLE: name="owned_by_me" schema="" table="owned_by_me" ctx=DDL +TABLE: name="not_owned_by_me" schema="" table="not_owned_by_me" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE owned_by_me, not_owned_by_me" +== 1312 +-- truncate_limit: 100 +DROP ROLE regress_test_not_me +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_not_me" +== 1313 +-- truncate_limit: 100 +DROP ROLE regress_test_me +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_me" +== 1314 +-- truncate_limit: 100 +-- check that the table being attached is not part of regular inheritance +CREATE TABLE parent (LIKE list_parted) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (LIKE list_parted)" +== 1315 +-- truncate_limit: 100 +CREATE TABLE child () INHERITS (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child () INHERITS (parent)" +== 1316 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION child FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION child FOR VALUES IN (1)" +== 1317 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION parent FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION parent FOR VALUES IN (1)" +== 1318 +-- truncate_limit: 100 +DROP TABLE child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE child" +== 1319 +-- truncate_limit: 100 +-- now it should work, with a little tweak +ALTER TABLE parent ADD CONSTRAINT check_a CHECK (a > 0) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ADD CONSTRAINT check_a CHECK (a > 0)" +== 1320 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION parent FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION parent FOR VALUES IN (1)" +== 1321 +-- truncate_limit: 100 +-- test insert/update, per bug #18550 +INSERT INTO parent VALUES (1) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES (1)" +== 1322 +-- truncate_limit: 100 +UPDATE parent SET a = 2 WHERE a = 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parent SET a = 2 WHERE a = 1" +== 1323 +-- truncate_limit: 100 +DROP TABLE parent CASCADE +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent CASCADE" +== 1324 +-- truncate_limit: 100 +-- check any TEMP-ness +CREATE TEMP TABLE temp_parted (a int) PARTITION BY LIST (a) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted (a int) PARTITION BY LIST (a)" +== 1325 +-- truncate_limit: 100 +CREATE TABLE perm_part (a int) +-- +TABLE: name="perm_part" schema="" table="perm_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE perm_part (a int)" +== 1326 +-- truncate_limit: 100 +ALTER TABLE temp_parted ATTACH PARTITION perm_part FOR VALUES IN (1) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE temp_parted ATTACH PARTITION perm_part FOR VALUES IN (1)" +== 1327 +-- truncate_limit: 100 +DROP TABLE temp_parted, perm_part +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +TABLE: name="perm_part" schema="" table="perm_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_parted, perm_part" +== 1328 +-- truncate_limit: 100 +-- check that the table being attached is not a typed table +CREATE TYPE mytype AS (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE mytype AS (a int)" +== 1329 +-- truncate_limit: 100 +CREATE TABLE fail_part OF mytype +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part OF mytype" +== 1330 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1)" +== 1331 +-- truncate_limit: 100 +DROP TYPE mytype CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE mytype CASCADE" +== 1332 +-- truncate_limit: 100 +-- check that the table being attached has only columns present in the parent +CREATE TABLE fail_part (like list_parted, c int) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (LIKE list_parted, c int)" +== 1333 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1)" +== 1334 +-- truncate_limit: 100 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_part" +== 1335 +-- truncate_limit: 100 +-- check that the table being attached has every column of the parent +CREATE TABLE fail_part (a int NOT NULL) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (a int NOT NULL)" +== 1336 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1)" +== 1337 +-- truncate_limit: 100 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_part" +== 1338 +-- truncate_limit: 100 +-- check that columns match in type, collation and NOT NULL status +CREATE TABLE fail_part ( + b char(3), + a int NOT NULL +) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (b char(3), a int NOT NULL)" +== 1339 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1)" +== 1340 +-- truncate_limit: 100 +ALTER TABLE fail_part ALTER b TYPE char (2) COLLATE "POSIX" +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fail_part ALTER COLUMN b TYPE char(2) COLLATE \"POSIX\"" +== 1341 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1)" +== 1342 +-- truncate_limit: 100 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_part" +== 1343 +-- truncate_limit: 100 +-- check that the table being attached has all constraints of the parent +CREATE TABLE fail_part ( + b char(2) COLLATE "C", + a int NOT NULL +) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (b char(2) COLLATE \"C\", a int NOT NULL)" +== 1344 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1)" +== 1345 +-- truncate_limit: 100 +-- check that the constraint matches in definition with parent's constraint +ALTER TABLE fail_part ADD CONSTRAINT check_a CHECK (a >= 0) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fail_part ADD CONSTRAINT check_a CHECK (a >= 0)" +== 1346 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1)" +== 1347 +-- truncate_limit: 100 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_part" +== 1348 +-- truncate_limit: 100 +-- check the attributes and constraints after partition is attached +CREATE TABLE part_1 ( + a int NOT NULL, + b char(2) COLLATE "C", + CONSTRAINT check_a CHECK (a > 0) +) +-- +TABLE: name="part_1" schema="" table="part_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_1 (a int NOT NULL, b char(2) COLLATE \"C\", CONSTRAINT check_a CHECK (a > 0))" +== 1349 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION part_1 FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION part_1 FOR VALUES IN (1)" +== 1350 +-- truncate_limit: 100 +-- attislocal and conislocal are always false for merged attributes and constraints respectively. +SELECT attislocal, attinhcount FROM pg_attribute WHERE attrelid = 'part_1'::regclass AND attnum > 0 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT attislocal, attinhcount FROM pg_attribute WHERE attrelid = 'part_1'::regclass AND attnum > 0" +== 1351 +-- truncate_limit: 100 +SELECT conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_1'::regclass AND conname = 'check_a' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT conislocal, coninhcount FROM pg_constraint WHERE ..." +== 1352 +-- truncate_limit: 100 +-- check that the new partition won't overlap with an existing partition +CREATE TABLE fail_part (LIKE part_1 INCLUDING CONSTRAINTS) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (LIKE part_1 INCLUDING CONSTRAINTS)" +== 1353 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_part FOR VALUES IN (1)" +== 1354 +-- truncate_limit: 100 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_part" +== 1355 +-- truncate_limit: 100 +-- check that an existing table can be attached as a default partition +CREATE TABLE def_part (LIKE list_parted INCLUDING CONSTRAINTS) +-- +TABLE: name="def_part" schema="" table="def_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE def_part (LIKE list_parted INCLUDING CONSTRAINTS)" +== 1356 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION def_part DEFAULT +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION def_part DEFAULT" +== 1357 +-- truncate_limit: 100 +-- check attaching default partition fails if a default partition already +-- exists +CREATE TABLE fail_def_part (LIKE part_1 INCLUDING CONSTRAINTS) +-- +TABLE: name="fail_def_part" schema="" table="fail_def_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_def_part (LIKE part_1 INCLUDING CONSTRAINTS)" +== 1358 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION fail_def_part DEFAULT +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION fail_def_part DEFAULT" +== 1359 +-- truncate_limit: 100 +-- check validation when attaching list partitions +CREATE TABLE list_parted2 ( + a int, + b char +) PARTITION BY LIST (a) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted2 (a int, b char(1)) PARTITION BY LIST (a)" +== 1360 +-- truncate_limit: 100 +-- check that violating rows are correctly reported +CREATE TABLE part_2 (LIKE list_parted2) +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_2 (LIKE list_parted2)" +== 1361 +-- truncate_limit: 100 +INSERT INTO part_2 VALUES (3, 'a') +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_2 VALUES (3, 'a')" +== 1362 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2)" +== 1363 +-- truncate_limit: 100 +-- should be ok after deleting the bad row +DELETE FROM part_2 +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM part_2" +== 1364 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2)" +== 1365 +-- truncate_limit: 100 +-- check partition cannot be attached if default has some row for its values +CREATE TABLE list_parted2_def PARTITION OF list_parted2 DEFAULT +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted2_def PARTITION OF list_parted2 DEFAULT" +== 1366 +-- truncate_limit: 100 +INSERT INTO list_parted2_def VALUES (11, 'z') +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted2_def VALUES (11, 'z')" +== 1367 +-- truncate_limit: 100 +CREATE TABLE part_3 (LIKE list_parted2) +-- +TABLE: name="part_3" schema="" table="part_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_3 (LIKE list_parted2)" +== 1368 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_3 FOR VALUES IN (11) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_3 FOR VALUES IN (11)" +== 1369 +-- truncate_limit: 100 +-- should be ok after deleting the bad row +DELETE FROM list_parted2_def WHERE a = 11 +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM list_parted2_def WHERE a = 11" +== 1370 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_3 FOR VALUES IN (11) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_3 FOR VALUES IN (11)" +== 1371 +-- truncate_limit: 100 +-- adding constraints that describe the desired partition constraint +-- (or more restrictive) will help skip the validation scan +CREATE TABLE part_3_4 ( + LIKE list_parted2, + CONSTRAINT check_a CHECK (a IN (3)) +) +-- +TABLE: name="part_3_4" schema="" table="part_3_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_3_4 (LIKE list_parted2, CONSTRAINT check_a CHECK (a IN (3)))" +== 1372 +-- truncate_limit: 100 +-- however, if a list partition does not accept nulls, there should be +-- an explicit NOT NULL constraint on the partition key column for the +-- validation scan to be skipped; +ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4)" +== 1373 +-- truncate_limit: 100 +-- adding a NOT NULL constraint will cause the scan to be skipped +ALTER TABLE list_parted2 DETACH PARTITION part_3_4 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 DETACH PARTITION part_3_4" +== 1374 +-- truncate_limit: 100 +ALTER TABLE part_3_4 ALTER a SET NOT NULL +-- +TABLE: name="part_3_4" schema="" table="part_3_4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_3_4 ALTER COLUMN a SET NOT NULL" +== 1375 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_3_4 FOR VALUES IN (3, 4)" +== 1376 +-- truncate_limit: 100 +-- check if default partition scan skipped +ALTER TABLE list_parted2_def ADD CONSTRAINT check_a CHECK (a IN (5, 6)) +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2_def ADD CONSTRAINT check_a CHECK (a IN (5, 6))" +== 1377 +-- truncate_limit: 100 +CREATE TABLE part_55_66 PARTITION OF list_parted2 FOR VALUES IN (55, 66) +-- +TABLE: name="part_55_66" schema="" table="part_55_66" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_55_66 PARTITION OF list_parted2 FOR VALUES IN (55, 66)" +== 1378 +-- truncate_limit: 100 +-- check validation when attaching range partitions +CREATE TABLE range_parted ( + a int, + b int +) PARTITION BY RANGE (a, b) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted (a int, b int) PARTITION BY RANGE (a, b)" +== 1379 +-- truncate_limit: 100 +-- check that violating rows are correctly reported +CREATE TABLE part1 ( + a int NOT NULL CHECK (a = 1), + b int NOT NULL CHECK (b >= 1 AND b <= 10) +) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part1 (a int NOT NULL CHECK (a = 1), b int NOT NULL CHECK (b >= 1 AND b <= 10))" +== 1380 +-- truncate_limit: 100 +INSERT INTO part1 VALUES (1, 10) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part1 VALUES (1, 10)" +== 1381 +-- truncate_limit: 100 +-- Remember the TO bound is exclusive +ALTER TABLE range_parted ATTACH PARTITION part1 FOR VALUES FROM (1, 1) TO (1, 10) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ATTACH PARTITION part1 FOR VALUES FROM (1, 1) TO (1, 10)" +== 1382 +-- truncate_limit: 100 +-- should be ok after deleting the bad row +DELETE FROM part1 +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM part1" +== 1383 +-- truncate_limit: 100 +ALTER TABLE range_parted ATTACH PARTITION part1 FOR VALUES FROM (1, 1) TO (1, 10) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ATTACH PARTITION part1 FOR VALUES FROM (1, 1) TO (1, 10)" +== 1384 +-- truncate_limit: 100 +-- adding constraints that describe the desired partition constraint +-- (or more restrictive) will help skip the validation scan +CREATE TABLE part2 ( + a int NOT NULL CHECK (a = 1), + b int NOT NULL CHECK (b >= 10 AND b < 18) +) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part2 (a int NOT NULL CHECK (a = 1), b int NOT NULL CHECK (b >= 10 AND b < 18))" +== 1385 +-- truncate_limit: 100 +ALTER TABLE range_parted ATTACH PARTITION part2 FOR VALUES FROM (1, 10) TO (1, 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ATTACH PARTITION part2 FOR VALUES FROM (1, 10) TO (1, 20)" +== 1386 +-- truncate_limit: 100 +-- Create default partition +CREATE TABLE partr_def1 PARTITION OF range_parted DEFAULT +-- +TABLE: name="partr_def1" schema="" table="partr_def1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partr_def1 PARTITION OF range_parted DEFAULT" +== 1387 +-- truncate_limit: 100 +-- Only one default partition is allowed, hence, following should give error +CREATE TABLE partr_def2 (LIKE part1 INCLUDING CONSTRAINTS) +-- +TABLE: name="partr_def2" schema="" table="partr_def2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partr_def2 (LIKE part1 INCLUDING CONSTRAINTS)" +== 1388 +-- truncate_limit: 100 +ALTER TABLE range_parted ATTACH PARTITION partr_def2 DEFAULT +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ATTACH PARTITION partr_def2 DEFAULT" +== 1389 +-- truncate_limit: 100 +-- Overlapping partitions cannot be attached, hence, following should give error +INSERT INTO partr_def1 VALUES (2, 10) +-- +TABLE: name="partr_def1" schema="" table="partr_def1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO partr_def1 VALUES (2, 10)" +== 1390 +-- truncate_limit: 100 +CREATE TABLE part3 (LIKE range_parted) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part3 (LIKE range_parted)" +== 1391 +-- truncate_limit: 100 +ALTER TABLE range_parted ATTACH partition part3 FOR VALUES FROM (2, 10) TO (2, 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ATTACH PARTITION part3 FOR VALUES FROM (2, 10) TO (2, 20)" +== 1392 +-- truncate_limit: 100 +-- Attaching partitions should be successful when there are no overlapping rows +ALTER TABLE range_parted ATTACH partition part3 FOR VALUES FROM (3, 10) TO (3, 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ATTACH PARTITION part3 FOR VALUES FROM (3, 10) TO (3, 20)" +== 1393 +-- truncate_limit: 100 +-- check that leaf partitions are scanned when attaching a partitioned +-- table +CREATE TABLE part_5 ( + LIKE list_parted2 +) PARTITION BY LIST (b) +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_5 (LIKE list_parted2) PARTITION BY LIST (b)" +== 1394 +-- truncate_limit: 100 +-- check that violating rows are correctly reported +CREATE TABLE part_5_a PARTITION OF part_5 FOR VALUES IN ('a') +-- +TABLE: name="part_5_a" schema="" table="part_5_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_5_a PARTITION OF part_5 FOR VALUES IN ('a')" +== 1395 +-- truncate_limit: 100 +INSERT INTO part_5_a (a, b) VALUES (6, 'a') +-- +TABLE: name="part_5_a" schema="" table="part_5_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_5_a (a, b) VALUES (6, 'a')" +== 1396 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5)" +== 1397 +-- truncate_limit: 100 +-- delete the faulting row and also add a constraint to skip the scan +DELETE FROM part_5_a WHERE a NOT IN (3) +-- +TABLE: name="part_5_a" schema="" table="part_5_a" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM part_5_a WHERE a NOT IN (3)" +== 1398 +-- truncate_limit: 100 +ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 5) +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 5)" +== 1399 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5)" +== 1400 +-- truncate_limit: 100 +ALTER TABLE list_parted2 DETACH PARTITION part_5 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 DETACH PARTITION part_5" +== 1401 +-- truncate_limit: 100 +ALTER TABLE part_5 DROP CONSTRAINT check_a +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_5 DROP CONSTRAINT check_a" +== 1402 +-- truncate_limit: 100 +-- scan should again be skipped, even though NOT NULL is now a column property +ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IN (5)), ALTER a SET NOT NULL +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_5 ADD CONSTRAINT check_a CHECK (a IN (5)), ALTER COLUMN a SET NOT NULL" +== 1403 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_5 FOR VALUES IN (5)" +== 1404 +-- truncate_limit: 100 +-- Check the case where attnos of the partitioning columns in the table being +-- attached differs from the parent. It should not affect the constraint- +-- checking logic that allows to skip the scan. +CREATE TABLE part_6 ( + c int, + LIKE list_parted2, + CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 6) +) +-- +TABLE: name="part_6" schema="" table="part_6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_6 (c int, LIKE list_parted2, CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 6))" +== 1405 +-- truncate_limit: 100 +ALTER TABLE part_6 DROP c +-- +TABLE: name="part_6" schema="" table="part_6" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_6 DROP c" +== 1406 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_6 FOR VALUES IN (6) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_6 FOR VALUES IN (6)" +== 1407 +-- truncate_limit: 100 +-- Similar to above, but the table being attached is a partitioned table +-- whose partition has still different attnos for the root partitioning +-- columns. +CREATE TABLE part_7 ( + LIKE list_parted2, + CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7) +) PARTITION BY LIST (b) +-- +TABLE: name="part_7" schema="" table="part_7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_7 (LIKE list_parted2, CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7)) PARTI..." +== 1408 +-- truncate_limit: 100 +CREATE TABLE part_7_a_null ( + c int, + d int, + e int, + LIKE list_parted2, -- 'a' will have attnum = 4 + CONSTRAINT check_b CHECK (b IS NULL OR b = 'a'), + CONSTRAINT check_a CHECK (a IS NOT NULL AND a = 7) +) +-- +TABLE: name="part_7_a_null" schema="" table="part_7_a_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_7_a_null (c int, d int, e int, LIKE list_parted2, CONSTRAINT check_b CHECK (b I..." +== 1409 +-- truncate_limit: 100 +ALTER TABLE part_7_a_null DROP c, DROP d, DROP e +-- +TABLE: name="part_7_a_null" schema="" table="part_7_a_null" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_7_a_null DROP c, DROP d, DROP e" +== 1410 +-- truncate_limit: 100 +ALTER TABLE part_7 ATTACH PARTITION part_7_a_null FOR VALUES IN ('a', null) +-- +TABLE: name="part_7" schema="" table="part_7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_7 ATTACH PARTITION part_7_a_null FOR VALUES IN ('a', NULL)" +== 1411 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7)" +== 1412 +-- truncate_limit: 100 +-- Same example, but check this time that the constraint correctly detects +-- violating rows +ALTER TABLE list_parted2 DETACH PARTITION part_7 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 DETACH PARTITION part_7" +== 1413 +-- truncate_limit: 100 +ALTER TABLE part_7 DROP CONSTRAINT check_a +-- +TABLE: name="part_7" schema="" table="part_7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_7 DROP CONSTRAINT check_a" +== 1414 +-- truncate_limit: 100 +-- thusly, scan won't be skipped +INSERT INTO part_7 (a, b) VALUES (8, null), (9, 'a') +-- +TABLE: name="part_7" schema="" table="part_7" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_7 (a, b) VALUES (8, NULL), (9, 'a')" +== 1415 +-- truncate_limit: 100 +SELECT tableoid::regclass, a, b FROM part_7 order by a +-- +TABLE: name="part_7" schema="" table="part_7" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, a, b FROM part_7 ORDER BY a" +== 1416 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_7 FOR VALUES IN (7)" +== 1417 +-- truncate_limit: 100 +-- check that leaf partitions of default partition are scanned when +-- attaching a partitioned table. +ALTER TABLE part_5 DROP CONSTRAINT check_a +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_5 DROP CONSTRAINT check_a" +== 1418 +-- truncate_limit: 100 +CREATE TABLE part5_def PARTITION OF part_5 DEFAULT PARTITION BY LIST(a) +-- +TABLE: name="part5_def" schema="" table="part5_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part5_def PARTITION OF part_5 DEFAULT PARTITION BY LIST (a)" +== 1419 +-- truncate_limit: 100 +CREATE TABLE part5_def_p1 PARTITION OF part5_def FOR VALUES IN (5) +-- +TABLE: name="part5_def_p1" schema="" table="part5_def_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part5_def_p1 PARTITION OF part5_def FOR VALUES IN (5)" +== 1420 +-- truncate_limit: 100 +INSERT INTO part5_def_p1 VALUES (5, 'y') +-- +TABLE: name="part5_def_p1" schema="" table="part5_def_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part5_def_p1 VALUES (5, 'y')" +== 1421 +-- truncate_limit: 100 +CREATE TABLE part5_p1 (LIKE part_5) +-- +TABLE: name="part5_p1" schema="" table="part5_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part5_p1 (LIKE part_5)" +== 1422 +-- truncate_limit: 100 +ALTER TABLE part_5 ATTACH PARTITION part5_p1 FOR VALUES IN ('y') +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_5 ATTACH PARTITION part5_p1 FOR VALUES IN ('y')" +== 1423 +-- truncate_limit: 100 +-- should be ok after deleting the bad row +DELETE FROM part5_def_p1 WHERE b = 'y' +-- +TABLE: name="part5_def_p1" schema="" table="part5_def_p1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM part5_def_p1 WHERE b = 'y'" +== 1424 +-- truncate_limit: 100 +ALTER TABLE part_5 ATTACH PARTITION part5_p1 FOR VALUES IN ('y') +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_5 ATTACH PARTITION part5_p1 FOR VALUES IN ('y')" +== 1425 +-- truncate_limit: 100 +-- check that the table being attached is not already a partition +ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION part_2 FOR VALUES IN (2)" +== 1426 +-- truncate_limit: 100 +-- check that circular inheritance is not allowed +ALTER TABLE part_5 ATTACH PARTITION list_parted2 FOR VALUES IN ('b') +-- +TABLE: name="part_5" schema="" table="part_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_5 ATTACH PARTITION list_parted2 FOR VALUES IN ('b')" +== 1427 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ATTACH PARTITION list_parted2 FOR VALUES IN (0) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ATTACH PARTITION list_parted2 FOR VALUES IN (0)" +== 1428 +-- truncate_limit: 100 +-- If a partitioned table being created or an existing table being attached +-- as a partition does not have a constraint that would allow validation scan +-- to be skipped, but an individual partition does, then the partition's +-- validation scan is skipped. +CREATE TABLE quuux (a int, b text) PARTITION BY LIST (a) +-- +TABLE: name="quuux" schema="" table="quuux" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quuux (a int, b text) PARTITION BY LIST (a)" +== 1429 +-- truncate_limit: 100 +CREATE TABLE quuux_default PARTITION OF quuux DEFAULT PARTITION BY LIST (b) +-- +TABLE: name="quuux_default" schema="" table="quuux_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quuux_default PARTITION OF quuux DEFAULT PARTITION BY LIST (b)" +== 1430 +-- truncate_limit: 100 +CREATE TABLE quuux_default1 PARTITION OF quuux_default ( + CONSTRAINT check_1 CHECK (a IS NOT NULL AND a = 1) +) FOR VALUES IN ('b') +-- +TABLE: name="quuux_default1" schema="" table="quuux_default1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quuux_default1 PARTITION OF quuux_default (CONSTRAINT check_1 CHECK (a IS NOT NULL A..." +== 1431 +-- truncate_limit: 100 +CREATE TABLE quuux1 (a int, b text) +-- +TABLE: name="quuux1" schema="" table="quuux1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quuux1 (a int, b text)" +== 1432 +-- truncate_limit: 100 +ALTER TABLE quuux ATTACH PARTITION quuux1 FOR VALUES IN (1) +-- +TABLE: name="quuux" schema="" table="quuux" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE quuux ATTACH PARTITION quuux1 FOR VALUES IN (1)" +== 1433 +-- truncate_limit: 100 +-- validate! +CREATE TABLE quuux2 (a int, b text) +-- +TABLE: name="quuux2" schema="" table="quuux2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quuux2 (a int, b text)" +== 1434 +-- truncate_limit: 100 +ALTER TABLE quuux ATTACH PARTITION quuux2 FOR VALUES IN (2) +-- +TABLE: name="quuux" schema="" table="quuux" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE quuux ATTACH PARTITION quuux2 FOR VALUES IN (2)" +== 1435 +-- truncate_limit: 100 +-- skip validation +DROP TABLE quuux1, quuux2 +-- +TABLE: name="quuux1" schema="" table="quuux1" ctx=DDL +TABLE: name="quuux2" schema="" table="quuux2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE quuux1, quuux2" +== 1436 +-- truncate_limit: 100 +-- should validate for quuux1, but not for quuux2 +CREATE TABLE quuux1 PARTITION OF quuux FOR VALUES IN (1) +-- +TABLE: name="quuux1" schema="" table="quuux1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quuux1 PARTITION OF quuux FOR VALUES IN (1)" +== 1437 +-- truncate_limit: 100 +CREATE TABLE quuux2 PARTITION OF quuux FOR VALUES IN (2) +-- +TABLE: name="quuux2" schema="" table="quuux2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quuux2 PARTITION OF quuux FOR VALUES IN (2)" +== 1438 +-- truncate_limit: 100 +DROP TABLE quuux +-- +TABLE: name="quuux" schema="" table="quuux" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE quuux" +== 1439 +-- truncate_limit: 100 +-- check validation when attaching hash partitions + +-- Use hand-rolled hash functions and operator class to get predictable result +-- on different machines. part_test_int4_ops is defined in test_setup.sql. + +-- check that the new partition won't overlap with an existing partition +CREATE TABLE hash_parted ( + a int, + b int +) PARTITION BY HASH (a part_test_int4_ops) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_parted (a int, b int) PARTITION BY HASH (a part_test_int4_ops)" +== 1440 +-- truncate_limit: 100 +CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 4, REMAINDER 0) +-- +TABLE: name="hpart_1" schema="" table="hpart_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 4, REMAINDER 0)" +== 1441 +-- truncate_limit: 100 +CREATE TABLE fail_part (LIKE hpart_1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (LIKE hpart_1)" +== 1442 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 4) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 4)" +== 1443 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 0) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 0)" +== 1444 +-- truncate_limit: 100 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_part" +== 1445 +-- truncate_limit: 100 +-- check validation when attaching hash partitions + +-- check that violating rows are correctly reported +CREATE TABLE hpart_2 (LIKE hash_parted) +-- +TABLE: name="hpart_2" schema="" table="hpart_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart_2 (LIKE hash_parted)" +== 1446 +-- truncate_limit: 100 +INSERT INTO hpart_2 VALUES (3, 0) +-- +TABLE: name="hpart_2" schema="" table="hpart_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hpart_2 VALUES (3, 0)" +== 1447 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION hpart_2 FOR VALUES WITH (MODULUS 4, REMAINDER 1) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION hpart_2 FOR VALUES WITH (MODULUS 4, REMAINDER 1)" +== 1448 +-- truncate_limit: 100 +-- should be ok after deleting the bad row +DELETE FROM hpart_2 +-- +TABLE: name="hpart_2" schema="" table="hpart_2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM hpart_2" +== 1449 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION hpart_2 FOR VALUES WITH (MODULUS 4, REMAINDER 1) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION hpart_2 FOR VALUES WITH (MODULUS 4, REMAINDER 1)" +== 1450 +-- truncate_limit: 100 +-- check that leaf partitions are scanned when attaching a partitioned +-- table +CREATE TABLE hpart_5 ( + LIKE hash_parted +) PARTITION BY LIST (b) +-- +TABLE: name="hpart_5" schema="" table="hpart_5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart_5 (LIKE hash_parted) PARTITION BY LIST (b)" +== 1451 +-- truncate_limit: 100 +-- check that violating rows are correctly reported +CREATE TABLE hpart_5_a PARTITION OF hpart_5 FOR VALUES IN ('1', '2', '3') +-- +TABLE: name="hpart_5_a" schema="" table="hpart_5_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart_5_a PARTITION OF hpart_5 FOR VALUES IN ('1', '2', '3')" +== 1452 +-- truncate_limit: 100 +INSERT INTO hpart_5_a (a, b) VALUES (7, 1) +-- +TABLE: name="hpart_5_a" schema="" table="hpart_5_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hpart_5_a (a, b) VALUES (7, 1)" +== 1453 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION hpart_5 FOR VALUES WITH (MODULUS 4, REMAINDER 2) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION hpart_5 FOR VALUES WITH (MODULUS 4, REMAINDER 2)" +== 1454 +-- truncate_limit: 100 +-- should be ok after deleting the bad row +DELETE FROM hpart_5_a +-- +TABLE: name="hpart_5_a" schema="" table="hpart_5_a" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM hpart_5_a" +== 1455 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION hpart_5 FOR VALUES WITH (MODULUS 4, REMAINDER 2) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION hpart_5 FOR VALUES WITH (MODULUS 4, REMAINDER 2)" +== 1456 +-- truncate_limit: 100 +-- check that the table being attach is with valid modulus and remainder value +CREATE TABLE fail_part(LIKE hash_parted) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part (LIKE hash_parted)" +== 1457 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 0, REMAINDER 1) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 0, REMAINDER 1)" +== 1458 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 8) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 8, REMAINDER 8)" +== 1459 +-- truncate_limit: 100 +ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 3, REMAINDER 2) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted ATTACH PARTITION fail_part FOR VALUES WITH (MODULUS 3, REMAINDER 2)" +== 1460 +-- truncate_limit: 100 +DROP TABLE fail_part +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_part" +== 1461 +-- truncate_limit: 100 +|-- +-- DETACH PARTITION +|-- + +-- check that the table is partitioned at all +CREATE TABLE regular_table (a int) +-- +TABLE: name="regular_table" schema="" table="regular_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE regular_table (a int)" +== 1462 +-- truncate_limit: 100 +ALTER TABLE regular_table DETACH PARTITION any_name +-- +TABLE: name="regular_table" schema="" table="regular_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE regular_table DETACH PARTITION any_name" +== 1463 +-- truncate_limit: 100 +DROP TABLE regular_table +-- +TABLE: name="regular_table" schema="" table="regular_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE regular_table" +== 1464 +-- truncate_limit: 100 +-- check that the partition being detached exists at all +ALTER TABLE list_parted2 DETACH PARTITION part_4 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 DETACH PARTITION part_4" +== 1465 +-- truncate_limit: 100 +ALTER TABLE hash_parted DETACH PARTITION hpart_4 +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted DETACH PARTITION hpart_4" +== 1466 +-- truncate_limit: 100 +-- check that the partition being detached is actually a partition of the parent +CREATE TABLE not_a_part (a int) +-- +TABLE: name="not_a_part" schema="" table="not_a_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE not_a_part (a int)" +== 1467 +-- truncate_limit: 100 +ALTER TABLE list_parted2 DETACH PARTITION not_a_part +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 DETACH PARTITION not_a_part" +== 1468 +-- truncate_limit: 100 +ALTER TABLE list_parted2 DETACH PARTITION part_1 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 DETACH PARTITION part_1" +== 1469 +-- truncate_limit: 100 +ALTER TABLE hash_parted DETACH PARTITION not_a_part +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted DETACH PARTITION not_a_part" +== 1470 +-- truncate_limit: 100 +DROP TABLE not_a_part +-- +TABLE: name="not_a_part" schema="" table="not_a_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE not_a_part" +== 1471 +-- truncate_limit: 100 +-- check that, after being detached, attinhcount/coninhcount is dropped to 0 and +-- attislocal/conislocal is set to true +ALTER TABLE list_parted2 DETACH PARTITION part_3_4 +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 DETACH PARTITION part_3_4" +== 1472 +-- truncate_limit: 100 +SELECT attinhcount, attislocal FROM pg_attribute WHERE attrelid = 'part_3_4'::regclass AND attnum > 0 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT attinhcount, attislocal FROM pg_attribute WHERE ..." +== 1473 +-- truncate_limit: 100 +SELECT coninhcount, conislocal FROM pg_constraint WHERE conrelid = 'part_3_4'::regclass AND conname = 'check_a' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT coninhcount, conislocal FROM pg_constraint WHERE ..." +== 1474 +-- truncate_limit: 100 +DROP TABLE part_3_4 +-- +TABLE: name="part_3_4" schema="" table="part_3_4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_3_4" +== 1475 +-- truncate_limit: 100 +-- check that a detached partition is not dropped on dropping a partitioned table +CREATE TABLE range_parted2 ( + a int +) PARTITION BY RANGE(a) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted2 (a int) PARTITION BY RANGE (a)" +== 1476 +-- truncate_limit: 100 +CREATE TABLE part_rp PARTITION OF range_parted2 FOR VALUES FROM (0) to (100) +-- +TABLE: name="part_rp" schema="" table="part_rp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_rp PARTITION OF range_parted2 FOR VALUES FROM (0) TO (100)" +== 1477 +-- truncate_limit: 100 +ALTER TABLE range_parted2 DETACH PARTITION part_rp +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted2 DETACH PARTITION part_rp" +== 1478 +-- truncate_limit: 100 +DROP TABLE range_parted2 +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE range_parted2" +== 1479 +-- truncate_limit: 100 +SELECT * from part_rp +-- +TABLE: name="part_rp" schema="" table="part_rp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_rp" +== 1480 +-- truncate_limit: 100 +DROP TABLE part_rp +-- +TABLE: name="part_rp" schema="" table="part_rp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_rp" +== 1481 +-- truncate_limit: 100 +-- concurrent detach +CREATE TABLE range_parted2 ( + a int +) PARTITION BY RANGE(a) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted2 (a int) PARTITION BY RANGE (a)" +== 1482 +-- truncate_limit: 100 +CREATE TABLE part_rp PARTITION OF range_parted2 FOR VALUES FROM (0) to (100) +-- +TABLE: name="part_rp" schema="" table="part_rp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_rp PARTITION OF range_parted2 FOR VALUES FROM (0) TO (100)" +== 1483 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1484 +-- truncate_limit: 100 +-- doesn't work in a partition block +ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY" +== 1485 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1486 +-- truncate_limit: 100 +CREATE TABLE part_rpd PARTITION OF range_parted2 DEFAULT +-- +TABLE: name="part_rpd" schema="" table="part_rpd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_rpd PARTITION OF range_parted2 DEFAULT" +== 1487 +-- truncate_limit: 100 +-- doesn't work if there's a default partition +ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY" +== 1488 +-- truncate_limit: 100 +-- doesn't work for the default partition +ALTER TABLE range_parted2 DETACH PARTITION part_rpd CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted2 DETACH PARTITION part_rpd CONCURRENTLY" +== 1489 +-- truncate_limit: 100 +DROP TABLE part_rpd +-- +TABLE: name="part_rpd" schema="" table="part_rpd" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_rpd" +== 1490 +-- truncate_limit: 100 +-- works fine +ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted2 DETACH PARTITION part_rp CONCURRENTLY" +== 1491 +-- truncate_limit: 100 +-- constraint should be created +CREATE TABLE part_rp100 PARTITION OF range_parted2 (CHECK (a>=123 AND a<133 AND a IS NOT NULL)) FOR VALUES FROM (100) to (200) +-- +TABLE: name="part_rp100" schema="" table="part_rp100" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_rp100 PARTITION OF range_parted2 (CHECK (a >= 123 AND a < 133 AND a IS NOT NULL..." +== 1492 +-- truncate_limit: 100 +ALTER TABLE range_parted2 DETACH PARTITION part_rp100 CONCURRENTLY +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted2 DETACH PARTITION part_rp100 CONCURRENTLY" +== 1493 +-- truncate_limit: 100 +-- redundant constraint should not be created +DROP TABLE range_parted2 +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE range_parted2" +== 1494 +-- truncate_limit: 100 +-- Test that hash partitions continue to work after they're concurrently +-- detached (bugs #18371, #19070) +CREATE TABLE hash_parted2 (a int) PARTITION BY HASH(a) +-- +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_parted2 (a int) PARTITION BY HASH (a)" +== 1495 +-- truncate_limit: 100 +CREATE TABLE part_hp PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="part_hp" schema="" table="part_hp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_hp PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 1496 +-- truncate_limit: 100 +ALTER TABLE hash_parted2 DETACH PARTITION part_hp CONCURRENTLY +-- +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE hash_parted2 DETACH PARTITION part_hp CONCURRENTLY" +== 1497 +-- truncate_limit: 100 +DROP TABLE hash_parted2 +-- +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hash_parted2" +== 1498 +-- truncate_limit: 100 +INSERT INTO part_hp VALUES (1) +-- +TABLE: name="part_hp" schema="" table="part_hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_hp VALUES (1)" +== 1499 +-- truncate_limit: 100 +DROP TABLE part_hp +-- +TABLE: name="part_hp" schema="" table="part_hp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_hp" +== 1500 +-- truncate_limit: 100 +-- Check ALTER TABLE commands for partitioned tables and partitions + +-- cannot add/drop column to/from *only* the parent +ALTER TABLE ONLY list_parted2 ADD COLUMN c int +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY list_parted2 ADD COLUMN c int" +== 1501 +-- truncate_limit: 100 +ALTER TABLE ONLY list_parted2 DROP COLUMN b +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY list_parted2 DROP b" +== 1502 +-- truncate_limit: 100 +-- cannot add a column to partition or drop an inherited one +ALTER TABLE part_2 ADD COLUMN c text +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_2 ADD COLUMN c text" +== 1503 +-- truncate_limit: 100 +ALTER TABLE part_2 DROP COLUMN b +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_2 DROP b" +== 1504 +-- truncate_limit: 100 +-- Nor rename, alter type +ALTER TABLE part_2 RENAME COLUMN b to c +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE part_2 RENAME COLUMN b TO c" +== 1505 +-- truncate_limit: 100 +ALTER TABLE part_2 ALTER COLUMN b TYPE text +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_2 ALTER COLUMN b TYPE text" +== 1506 +-- truncate_limit: 100 +-- cannot add/drop NOT NULL or check constraints to *only* the parent, when +-- partitions exist +ALTER TABLE ONLY list_parted2 ALTER b SET NOT NULL +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY list_parted2 ALTER COLUMN b SET NOT NULL" +== 1507 +-- truncate_limit: 100 +ALTER TABLE ONLY list_parted2 ADD CONSTRAINT check_b CHECK (b <> 'zz') +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY list_parted2 ADD CONSTRAINT check_b CHECK (b <> 'zz')" +== 1508 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ALTER b SET NOT NULL +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ALTER COLUMN b SET NOT NULL" +== 1509 +-- truncate_limit: 100 +ALTER TABLE ONLY list_parted2 ALTER b DROP NOT NULL +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY list_parted2 ALTER COLUMN b DROP NOT NULL" +== 1510 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ADD CONSTRAINT check_b CHECK (b <> 'zz') +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ADD CONSTRAINT check_b CHECK (b <> 'zz')" +== 1511 +-- truncate_limit: 100 +ALTER TABLE ONLY list_parted2 DROP CONSTRAINT check_b +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY list_parted2 DROP CONSTRAINT check_b" +== 1512 +-- truncate_limit: 100 +-- It's alright though, if no partitions are yet created +CREATE TABLE parted_no_parts (a int) PARTITION BY LIST (a) +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_no_parts (a int) PARTITION BY LIST (a)" +== 1513 +-- truncate_limit: 100 +ALTER TABLE ONLY parted_no_parts ALTER a SET NOT NULL +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parted_no_parts ALTER COLUMN a SET NOT NULL" +== 1514 +-- truncate_limit: 100 +ALTER TABLE ONLY parted_no_parts ADD CONSTRAINT check_a CHECK (a > 0) +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parted_no_parts ADD CONSTRAINT check_a CHECK (a > 0)" +== 1515 +-- truncate_limit: 100 +ALTER TABLE ONLY parted_no_parts ALTER a DROP NOT NULL +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parted_no_parts ALTER COLUMN a DROP NOT NULL" +== 1516 +-- truncate_limit: 100 +ALTER TABLE ONLY parted_no_parts DROP CONSTRAINT check_a +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parted_no_parts DROP CONSTRAINT check_a" +== 1517 +-- truncate_limit: 100 +DROP TABLE parted_no_parts +-- +TABLE: name="parted_no_parts" schema="" table="parted_no_parts" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_no_parts" +== 1518 +-- truncate_limit: 100 +-- cannot drop inherited NOT NULL or check constraints from partition +ALTER TABLE list_parted2 ALTER b SET NOT NULL, ADD CONSTRAINT check_a2 CHECK (a > 0) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ALTER COLUMN b SET NOT NULL, ADD CONSTRAINT check_a2 CHECK (a > 0)" +== 1519 +-- truncate_limit: 100 +ALTER TABLE part_2 ALTER b DROP NOT NULL +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_2 ALTER COLUMN b DROP NOT NULL" +== 1520 +-- truncate_limit: 100 +ALTER TABLE part_2 DROP CONSTRAINT check_a2 +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_2 DROP CONSTRAINT check_a2" +== 1521 +-- truncate_limit: 100 +-- Doesn't make sense to add NO INHERIT constraints on partitioned tables +ALTER TABLE list_parted2 add constraint check_b2 check (b <> 'zz') NO INHERIT +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ADD CONSTRAINT check_b2 CHECK (b <> 'zz') NO INHERIT" +== 1522 +-- truncate_limit: 100 +-- check that a partition cannot participate in regular inheritance +CREATE TABLE inh_test () INHERITS (part_2) +-- +TABLE: name="inh_test" schema="" table="inh_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_test () INHERITS (part_2)" +== 1523 +-- truncate_limit: 100 +CREATE TABLE inh_test (LIKE part_2) +-- +TABLE: name="inh_test" schema="" table="inh_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_test (LIKE part_2)" +== 1524 +-- truncate_limit: 100 +ALTER TABLE inh_test INHERIT part_2 +-- +TABLE: name="inh_test" schema="" table="inh_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inh_test INHERIT part_2" +== 1525 +-- truncate_limit: 100 +ALTER TABLE part_2 INHERIT inh_test +-- +TABLE: name="part_2" schema="" table="part_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_2 INHERIT inh_test" +== 1526 +-- truncate_limit: 100 +-- cannot drop or alter type of partition key columns of lower level +-- partitioned tables; for example, part_5, which is list_parted2's +-- partition, is partitioned on b; +ALTER TABLE list_parted2 DROP COLUMN b +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 DROP b" +== 1527 +-- truncate_limit: 100 +ALTER TABLE list_parted2 ALTER COLUMN b TYPE text +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted2 ALTER COLUMN b TYPE text" +== 1528 +-- truncate_limit: 100 +-- dropping non-partition key columns should be allowed on the parent table. +ALTER TABLE list_parted DROP COLUMN b +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted DROP b" +== 1529 +-- truncate_limit: 100 +SELECT * FROM list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM list_parted" +== 1530 +-- truncate_limit: 100 +-- cleanup +DROP TABLE list_parted, list_parted2, range_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE list_parted, list_parted2, range_parted" +== 1531 +-- truncate_limit: 100 +DROP TABLE fail_def_part +-- +TABLE: name="fail_def_part" schema="" table="fail_def_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fail_def_part" +== 1532 +-- truncate_limit: 100 +DROP TABLE hash_parted +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hash_parted" +== 1533 +-- truncate_limit: 100 +-- more tests for certain multi-level partitioning scenarios +create table p (a int, b int) partition by range (a, b) +-- +TABLE: name="p" schema="" table="p" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p (a int, b int) PARTITION BY RANGE (a, b)" +== 1534 +-- truncate_limit: 100 +create table p1 (b int, a int not null) partition by range (b) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (b int, a int NOT NULL) PARTITION BY RANGE (b)" +== 1535 +-- truncate_limit: 100 +create table p11 (like p1) +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p11 (LIKE p1)" +== 1536 +-- truncate_limit: 100 +alter table p11 drop a +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p11 DROP a" +== 1537 +-- truncate_limit: 100 +alter table p11 add a int +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p11 ADD COLUMN a int" +== 1538 +-- truncate_limit: 100 +alter table p11 drop a +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p11 DROP a" +== 1539 +-- truncate_limit: 100 +alter table p11 add a int not null +-- +TABLE: name="p11" schema="" table="p11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p11 ADD COLUMN a int NOT NULL" +== 1540 +-- truncate_limit: 100 +-- attnum for key attribute 'a' is different in p, p1, and p11 +select attrelid::regclass, attname, attnum +from pg_attribute +where attname = 'a' + and (attrelid = 'p'::regclass + or attrelid = 'p1'::regclass + or attrelid = 'p11'::regclass) +order by attrelid::regclass::text +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attname" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE ... ORDER BY attrelid::regclass::text" +== 1541 +-- truncate_limit: 100 +alter table p1 attach partition p11 for values from (2) to (5) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 ATTACH PARTITION p11 FOR VALUES FROM (2) TO (5)" +== 1542 +-- truncate_limit: 100 +insert into p1 (a, b) values (2, 3) +-- +TABLE: name="p1" schema="" table="p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO p1 (a, b) VALUES (2, 3)" +== 1543 +-- truncate_limit: 100 +-- check that partition validation scan correctly detects violating rows +alter table p attach partition p1 for values from (1, 2) to (1, 10) +-- +TABLE: name="p" schema="" table="p" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p ATTACH PARTITION p1 FOR VALUES FROM (1, 2) TO (1, 10)" +== 1544 +-- truncate_limit: 100 +-- cleanup +drop table p +-- +TABLE: name="p" schema="" table="p" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p" +== 1545 +-- truncate_limit: 100 +drop table p1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1" +== 1546 +-- truncate_limit: 100 +-- validate constraint on partitioned tables should only scan leaf partitions +create table parted_validate_test (a int) partition by list (a) +-- +TABLE: name="parted_validate_test" schema="" table="parted_validate_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_validate_test (a int) PARTITION BY LIST (a)" +== 1547 +-- truncate_limit: 100 +create table parted_validate_test_1 partition of parted_validate_test for values in (0, 1) +-- +TABLE: name="parted_validate_test_1" schema="" table="parted_validate_test_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_validate_test_1 PARTITION OF parted_validate_test FOR VALUES IN (0, 1)" +== 1548 +-- truncate_limit: 100 +alter table parted_validate_test add constraint parted_validate_test_chka check (a > 0) not valid +-- +TABLE: name="parted_validate_test" schema="" table="parted_validate_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_validate_test ADD CONSTRAINT parted_validate_test_chka CHECK (a > 0) NOT VALID" +== 1549 +-- truncate_limit: 100 +alter table parted_validate_test validate constraint parted_validate_test_chka +-- +TABLE: name="parted_validate_test" schema="" table="parted_validate_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_validate_test VALIDATE CONSTRAINT parted_validate_test_chka" +== 1550 +-- truncate_limit: 100 +drop table parted_validate_test +-- +TABLE: name="parted_validate_test" schema="" table="parted_validate_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_validate_test" +== 1551 +-- truncate_limit: 100 +-- test alter column options +CREATE TABLE attmp(i integer) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attmp (i int)" +== 1552 +-- truncate_limit: 100 +INSERT INTO attmp VALUES (1) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attmp VALUES (1)" +== 1553 +-- truncate_limit: 100 +ALTER TABLE attmp ALTER COLUMN i SET (n_distinct = 1, n_distinct_inherited = 2) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ALTER COLUMN i SET (n_distinct=1, n_distinct_inherited=2)" +== 1554 +-- truncate_limit: 100 +ALTER TABLE attmp ALTER COLUMN i RESET (n_distinct_inherited) +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attmp ALTER COLUMN i RESET (n_distinct_inherited)" +== 1555 +-- truncate_limit: 100 +ANALYZE attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE attmp" +== 1556 +-- truncate_limit: 100 +DROP TABLE attmp +-- +TABLE: name="attmp" schema="" table="attmp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attmp" +== 1557 +-- truncate_limit: 100 +DROP USER regress_alter_table_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_alter_table_user1" +== 1558 +-- truncate_limit: 100 +-- check that violating rows are correctly reported when attaching as the +-- default partition +create table defpart_attach_test (a int) partition by list (a) +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defpart_attach_test (a int) PARTITION BY LIST (a)" +== 1559 +-- truncate_limit: 100 +create table defpart_attach_test1 partition of defpart_attach_test for values in (1) +-- +TABLE: name="defpart_attach_test1" schema="" table="defpart_attach_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defpart_attach_test1 PARTITION OF defpart_attach_test FOR VALUES IN (1)" +== 1560 +-- truncate_limit: 100 +create table defpart_attach_test_d (b int, a int) +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defpart_attach_test_d (b int, a int)" +== 1561 +-- truncate_limit: 100 +alter table defpart_attach_test_d drop b +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defpart_attach_test_d DROP b" +== 1562 +-- truncate_limit: 100 +insert into defpart_attach_test_d values (1), (2) +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defpart_attach_test_d VALUES (1), (2)" +== 1563 +-- truncate_limit: 100 +-- error because its constraint as the default partition would be violated +-- by the row containing 1 +alter table defpart_attach_test attach partition defpart_attach_test_d default +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defpart_attach_test ATTACH PARTITION defpart_attach_test_d DEFAULT" +== 1564 +-- truncate_limit: 100 +delete from defpart_attach_test_d where a = 1 +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM defpart_attach_test_d WHERE a = 1" +== 1565 +-- truncate_limit: 100 +alter table defpart_attach_test_d add check (a > 1) +-- +TABLE: name="defpart_attach_test_d" schema="" table="defpart_attach_test_d" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defpart_attach_test_d ADD CHECK (a > 1)" +== 1566 +-- truncate_limit: 100 +-- should be attached successfully and without needing to be scanned +alter table defpart_attach_test attach partition defpart_attach_test_d default +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defpart_attach_test ATTACH PARTITION defpart_attach_test_d DEFAULT" +== 1567 +-- truncate_limit: 100 +-- check that attaching a partition correctly reports any rows in the default +-- partition that should not be there for the new partition to be attached +-- successfully +create table defpart_attach_test_2 (like defpart_attach_test_d) +-- +TABLE: name="defpart_attach_test_2" schema="" table="defpart_attach_test_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defpart_attach_test_2 (LIKE defpart_attach_test_d)" +== 1568 +-- truncate_limit: 100 +alter table defpart_attach_test attach partition defpart_attach_test_2 for values in (2) +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defpart_attach_test ATTACH PARTITION defpart_attach_test_2 FOR VALUES IN (2)" +== 1569 +-- truncate_limit: 100 +drop table defpart_attach_test +-- +TABLE: name="defpart_attach_test" schema="" table="defpart_attach_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE defpart_attach_test" +== 1570 +-- truncate_limit: 100 +-- check combinations of temporary and permanent relations when attaching +-- partitions. +create table perm_part_parent (a int) partition by list (a) +-- +TABLE: name="perm_part_parent" schema="" table="perm_part_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE perm_part_parent (a int) PARTITION BY LIST (a)" +== 1571 +-- truncate_limit: 100 +create temp table temp_part_parent (a int) partition by list (a) +-- +TABLE: name="temp_part_parent" schema="" table="temp_part_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_part_parent (a int) PARTITION BY LIST (a)" +== 1572 +-- truncate_limit: 100 +create table perm_part_child (a int) +-- +TABLE: name="perm_part_child" schema="" table="perm_part_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE perm_part_child (a int)" +== 1573 +-- truncate_limit: 100 +create temp table temp_part_child (a int) +-- +TABLE: name="temp_part_child" schema="" table="temp_part_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_part_child (a int)" +== 1574 +-- truncate_limit: 100 +alter table temp_part_parent attach partition perm_part_child default +-- +TABLE: name="temp_part_parent" schema="" table="temp_part_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE temp_part_parent ATTACH PARTITION perm_part_child DEFAULT" +== 1575 +-- truncate_limit: 100 +-- error +alter table perm_part_parent attach partition temp_part_child default +-- +TABLE: name="perm_part_parent" schema="" table="perm_part_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE perm_part_parent ATTACH PARTITION temp_part_child DEFAULT" +== 1576 +-- truncate_limit: 100 +-- error +alter table temp_part_parent attach partition temp_part_child default +-- +TABLE: name="temp_part_parent" schema="" table="temp_part_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE temp_part_parent ATTACH PARTITION temp_part_child DEFAULT" +== 1577 +-- truncate_limit: 100 +-- ok +drop table perm_part_parent cascade +-- +TABLE: name="perm_part_parent" schema="" table="perm_part_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE perm_part_parent CASCADE" +== 1578 +-- truncate_limit: 100 +drop table temp_part_parent cascade +-- +TABLE: name="temp_part_parent" schema="" table="temp_part_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_part_parent CASCADE" +== 1579 +-- truncate_limit: 100 +-- check that attaching partitions to a table while it is being used is +-- prevented +create table tab_part_attach (a int) partition by list (a) +-- +TABLE: name="tab_part_attach" schema="" table="tab_part_attach" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tab_part_attach (a int) PARTITION BY LIST (a)" +== 1580 +-- truncate_limit: 100 +create or replace function func_part_attach() returns trigger + language plpgsql as $$ + begin + execute 'create table tab_part_attach_1 (a int)'; + execute 'alter table tab_part_attach attach partition tab_part_attach_1 for values in (1)'; + return null; + end $$ +-- +FUNCTION: name="func_part_attach" function="func_part_attach" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION func_part_attach() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n ..." +== 1581 +-- truncate_limit: 100 +create trigger trig_part_attach before insert on tab_part_attach + for each statement execute procedure func_part_attach() +-- +TABLE: name="tab_part_attach" schema="" table="tab_part_attach" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_part_attach BEFORE INSERT ON tab_part_attach EXECUTE FUNCTION func_part_attach()" +== 1582 +-- truncate_limit: 100 +insert into tab_part_attach values (1) +-- +TABLE: name="tab_part_attach" schema="" table="tab_part_attach" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tab_part_attach VALUES (1)" +== 1583 +-- truncate_limit: 100 +drop table tab_part_attach +-- +TABLE: name="tab_part_attach" schema="" table="tab_part_attach" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tab_part_attach" +== 1584 +-- truncate_limit: 100 +drop function func_part_attach() +-- +FUNCTION: name="func_part_attach" function="func_part_attach" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION func_part_attach()" +== 1585 +-- truncate_limit: 100 +-- test case where the partitioning operator is a SQL function whose +-- evaluation results in the table's relcache being rebuilt partway through +-- the execution of an ATTACH PARTITION command +create function at_test_sql_partop (int4, int4) returns int language sql +as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$ +-- +FUNCTION: name="at_test_sql_partop" function="at_test_sql_partop" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION at_test_sql_partop(int4, int4) RETURNS int LANGUAGE sql AS $$ select case when $1..." +== 1586 +-- truncate_limit: 100 +create operator class at_test_sql_partop for type int4 using btree as + operator 1 < (int4, int4), operator 2 <= (int4, int4), + operator 3 = (int4, int4), operator 4 >= (int4, int4), + operator 5 > (int4, int4), function 1 at_test_sql_partop(int4, int4) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS at_test_sql_partop FOR TYPE int4 USING btree AS OPERATOR 1 <(int4, int4), O..." +== 1587 +-- truncate_limit: 100 +create table at_test_sql_partop (a int) partition by range (a at_test_sql_partop) +-- +TABLE: name="at_test_sql_partop" schema="" table="at_test_sql_partop" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_test_sql_partop (a int) PARTITION BY RANGE (a at_test_sql_partop)" +== 1588 +-- truncate_limit: 100 +create table at_test_sql_partop_1 (a int) +-- +TABLE: name="at_test_sql_partop_1" schema="" table="at_test_sql_partop_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE at_test_sql_partop_1 (a int)" +== 1589 +-- truncate_limit: 100 +alter table at_test_sql_partop attach partition at_test_sql_partop_1 for values from (0) to (10) +-- +TABLE: name="at_test_sql_partop" schema="" table="at_test_sql_partop" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE at_test_sql_partop ATTACH PARTITION at_test_sql_partop_1 FOR VALUES FROM (0) TO (10)" +== 1590 +-- truncate_limit: 100 +drop table at_test_sql_partop +-- +TABLE: name="at_test_sql_partop" schema="" table="at_test_sql_partop" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE at_test_sql_partop" +== 1591 +-- truncate_limit: 100 +drop operator class at_test_sql_partop using btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS at_test_sql_partop USING btree" +== 1592 +-- truncate_limit: 100 +drop function at_test_sql_partop +-- +FUNCTION: name="at_test_sql_partop" function="at_test_sql_partop" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION at_test_sql_partop" +== 1593 +-- truncate_limit: 100 +/* Test case for bug #16242 */ + +-- We create a parent and child where the child has missing +-- non-null attribute values, and arrange to pass them through +-- tuple conversion from the child to the parent tupdesc +create table bar1 (a integer, b integer not null default 1) + partition by range (a) +-- +TABLE: name="bar1" schema="" table="bar1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bar1 (a int, b int NOT NULL DEFAULT 1) PARTITION BY RANGE (a)" +== 1594 +-- truncate_limit: 100 +create table bar2 (a integer) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bar2 (a int)" +== 1595 +-- truncate_limit: 100 +insert into bar2 values (1) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar2 VALUES (1)" +== 1596 +-- truncate_limit: 100 +alter table bar2 add column b integer not null default 1 +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bar2 ADD COLUMN b int NOT NULL DEFAULT 1" +== 1597 +-- truncate_limit: 100 +-- (at this point bar2 contains tuple with natts=1) +alter table bar1 attach partition bar2 default +-- +TABLE: name="bar1" schema="" table="bar1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bar1 ATTACH PARTITION bar2 DEFAULT" +== 1598 +-- truncate_limit: 100 +-- this works: +select * from bar1 +-- +TABLE: name="bar1" schema="" table="bar1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bar1" +== 1599 +-- truncate_limit: 100 +-- this exercises tuple conversion: +create function xtrig() + returns trigger language plpgsql +as $$ + declare + r record; + begin + for r in select * from old loop + raise info 'a=%, b=%', r.a, r.b; + end loop; + return NULL; + end; +$$ +-- +FUNCTION: name="xtrig" function="xtrig" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION xtrig() RETURNS trigger LANGUAGE plpgsql AS $$\n declare\n r record;\n begin\n ..." +== 1600 +-- truncate_limit: 100 +create trigger xtrig + after update on bar1 + referencing old table as old + for each statement execute procedure xtrig() +-- +TABLE: name="bar1" schema="" table="bar1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER xtrig AFTER UPDATE ON bar1 REFERENCING OLD TABLE old EXECUTE FUNCTION xtrig()" +== 1601 +-- truncate_limit: 100 +update bar1 set a = a + 1 +-- +TABLE: name="bar1" schema="" table="bar1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE bar1 SET a = a + 1" +== 1602 +-- truncate_limit: 100 +/* End test case for bug #16242 */ + +/* Test case for bug #17409 */ + +create table attbl (p1 int constraint pk_attbl primary key) +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attbl (p1 int CONSTRAINT pk_attbl PRIMARY KEY)" +== 1603 +-- truncate_limit: 100 +create table atref (c1 int references attbl(p1)) +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atref (c1 int REFERENCES attbl (p1))" +== 1604 +-- truncate_limit: 100 +cluster attbl using pk_attbl +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER attbl USING pk_attbl" +== 1605 +-- truncate_limit: 100 +alter table attbl alter column p1 set data type bigint +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attbl ALTER COLUMN p1 TYPE bigint" +== 1606 +-- truncate_limit: 100 +alter table atref alter column c1 set data type bigint +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atref ALTER COLUMN c1 TYPE bigint" +== 1607 +-- truncate_limit: 100 +drop table attbl, atref +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attbl, atref" +== 1608 +-- truncate_limit: 100 +create table attbl (p1 int constraint pk_attbl primary key) +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attbl (p1 int CONSTRAINT pk_attbl PRIMARY KEY)" +== 1609 +-- truncate_limit: 100 +alter table attbl replica identity using index pk_attbl +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attbl REPLICA IDENTITY USING INDEX pk_attbl" +== 1610 +-- truncate_limit: 100 +create table atref (c1 int references attbl(p1)) +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atref (c1 int REFERENCES attbl (p1))" +== 1611 +-- truncate_limit: 100 +alter table attbl alter column p1 set data type bigint +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attbl ALTER COLUMN p1 TYPE bigint" +== 1612 +-- truncate_limit: 100 +alter table atref alter column c1 set data type bigint +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atref ALTER COLUMN c1 TYPE bigint" +== 1613 +-- truncate_limit: 100 +drop table attbl, atref +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attbl, atref" +== 1614 +-- truncate_limit: 100 +/* End test case for bug #17409 */ + +/* Test case for bug #18970 */ + +create table attbl(a int) +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attbl (a int)" +== 1615 +-- truncate_limit: 100 +create table atref(b attbl check ((b).a is not null)) +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atref (b attbl CHECK ((b).a IS NOT NULL))" +== 1616 +-- truncate_limit: 100 +alter table attbl alter column a type numeric +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attbl ALTER COLUMN a TYPE numeric" +== 1617 +-- truncate_limit: 100 +-- someday this should work +alter table atref drop constraint atref_b_check +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atref DROP CONSTRAINT atref_b_check" +== 1618 +-- truncate_limit: 100 +create statistics atref_stat on ((b).a is not null) from atref +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS atref_stat ON ((b).a IS NOT NULL) FROM atref" +== 1619 +-- truncate_limit: 100 +alter table attbl alter column a type numeric +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attbl ALTER COLUMN a TYPE numeric" +== 1620 +-- truncate_limit: 100 +-- someday this should work +drop statistics atref_stat +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS atref_stat" +== 1621 +-- truncate_limit: 100 +create index atref_idx on atref (((b).a)) +-- +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX atref_idx ON atref USING btree (((b).a))" +== 1622 +-- truncate_limit: 100 +alter table attbl alter column a type numeric +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE attbl ALTER COLUMN a TYPE numeric" +== 1623 +-- truncate_limit: 100 +-- someday this should work +drop table attbl, atref +-- +TABLE: name="attbl" schema="" table="attbl" ctx=DDL +TABLE: name="atref" schema="" table="atref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE attbl, atref" +== 1624 +-- truncate_limit: 100 +/* End test case for bug #18970 */ + +-- Test that ALTER TABLE rewrite preserves a clustered index +-- for normal indexes and indexes on constraints. +create table alttype_cluster (a int) +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alttype_cluster (a int)" +== 1625 +-- truncate_limit: 100 +alter table alttype_cluster add primary key (a) +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alttype_cluster ADD PRIMARY KEY (a)" +== 1626 +-- truncate_limit: 100 +create index alttype_cluster_ind on alttype_cluster (a) +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX alttype_cluster_ind ON alttype_cluster USING btree (a)" +== 1627 +-- truncate_limit: 100 +alter table alttype_cluster cluster on alttype_cluster_ind +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alttype_cluster CLUSTER ON alttype_cluster_ind" +== 1628 +-- truncate_limit: 100 +-- Normal index remains clustered. +select indexrelid::regclass, indisclustered from pg_index + where indrelid = 'alttype_cluster'::regclass + order by indexrelid::regclass::text +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE ... ORDER BY indexrelid::regclass::text" +== 1629 +-- truncate_limit: 100 +alter table alttype_cluster alter a type bigint +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alttype_cluster ALTER COLUMN a TYPE bigint" +== 1630 +-- truncate_limit: 100 +select indexrelid::regclass, indisclustered from pg_index + where indrelid = 'alttype_cluster'::regclass + order by indexrelid::regclass::text +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE ... ORDER BY indexrelid::regclass::text" +== 1631 +-- truncate_limit: 100 +-- Constraint index remains clustered. +alter table alttype_cluster cluster on alttype_cluster_pkey +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alttype_cluster CLUSTER ON alttype_cluster_pkey" +== 1632 +-- truncate_limit: 100 +select indexrelid::regclass, indisclustered from pg_index + where indrelid = 'alttype_cluster'::regclass + order by indexrelid::regclass::text +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE ... ORDER BY indexrelid::regclass::text" +== 1633 +-- truncate_limit: 100 +alter table alttype_cluster alter a type int +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alttype_cluster ALTER COLUMN a TYPE int" +== 1634 +-- truncate_limit: 100 +select indexrelid::regclass, indisclustered from pg_index + where indrelid = 'alttype_cluster'::regclass + order by indexrelid::regclass::text +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE ... ORDER BY indexrelid::regclass::text" +== 1635 +-- truncate_limit: 100 +drop table alttype_cluster +-- +TABLE: name="alttype_cluster" schema="" table="alttype_cluster" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE alttype_cluster" +== 1636 +-- truncate_limit: 100 +|-- +-- Check that attaching or detaching a partitioned partition correctly leads +-- to its partitions' constraint being updated to reflect the parent's +-- newly added/removed constraint +create table target_parted (a int, b int) partition by list (a) +-- +TABLE: name="target_parted" schema="" table="target_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE target_parted (a int, b int) PARTITION BY LIST (a)" +== 1637 +-- truncate_limit: 100 +create table attach_parted (a int, b int) partition by list (b) +-- +TABLE: name="attach_parted" schema="" table="attach_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attach_parted (a int, b int) PARTITION BY LIST (b)" +== 1638 +-- truncate_limit: 100 +create table attach_parted_part1 partition of attach_parted for values in (1) +-- +TABLE: name="attach_parted_part1" schema="" table="attach_parted_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE attach_parted_part1 PARTITION OF attach_parted FOR VALUES IN (1)" +== 1639 +-- truncate_limit: 100 +-- insert a row directly into the leaf partition so that its partition +-- constraint is built and stored in the relcache +insert into attach_parted_part1 values (1, 1) +-- +TABLE: name="attach_parted_part1" schema="" table="attach_parted_part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attach_parted_part1 VALUES (1, 1)" +== 1640 +-- truncate_limit: 100 +-- the following better invalidate the partition constraint of the leaf +-- partition too... +alter table target_parted attach partition attach_parted for values in (1) +-- +TABLE: name="target_parted" schema="" table="target_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE target_parted ATTACH PARTITION attach_parted FOR VALUES IN (1)" +== 1641 +-- truncate_limit: 100 +-- ...such that the following insert fails +insert into attach_parted_part1 values (2, 1) +-- +TABLE: name="attach_parted_part1" schema="" table="attach_parted_part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attach_parted_part1 VALUES (2, 1)" +== 1642 +-- truncate_limit: 100 +-- ...and doesn't when the partition is detached along with its own partition +alter table target_parted detach partition attach_parted +-- +TABLE: name="target_parted" schema="" table="target_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE target_parted DETACH PARTITION attach_parted" +== 1643 +-- truncate_limit: 100 +insert into attach_parted_part1 values (2, 1) +-- +TABLE: name="attach_parted_part1" schema="" table="attach_parted_part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO attach_parted_part1 VALUES (2, 1)" +== 1644 +-- truncate_limit: 100 +-- Test altering table having publication +create schema alter1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA alter1" +== 1645 +-- truncate_limit: 100 +create schema alter2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA alter2" +== 1646 +-- truncate_limit: 100 +create table alter1.t1 (a int) +-- +TABLE: name="alter1.t1" schema="alter1" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alter1.t1 (a int)" +== 1647 +-- truncate_limit: 100 +set client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 1648 +-- truncate_limit: 100 +create publication pub1 for table alter1.t1, tables in schema alter2 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION pub1 FOR TABLE alter1.t1, TABLES IN SCHEMA alter2" +== 1649 +-- truncate_limit: 100 +reset client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 1650 +-- truncate_limit: 100 +alter table alter1.t1 set schema alter2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE alter1.t1 SET SCHEMA alter2" +== 1651 +-- truncate_limit: 100 +drop publication pub1 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION pub1" +== 1652 +-- truncate_limit: 100 +drop schema alter1 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA alter1 CASCADE" +== 1653 +-- truncate_limit: 100 +drop schema alter2 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA alter2 CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/amutils.metadata.json b/parser/testdata/summary_truncate/postgres_regress/amutils.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/amutils.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/amutils.test b/parser/testdata/summary_truncate/postgres_regress/amutils.test new file mode 100644 index 0000000..a0da3a2 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/amutils.test @@ -0,0 +1,181 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test index AM property-reporting functions +|-- + +select prop, + pg_indexam_has_property(a.oid, prop) as "AM", + pg_index_has_property('onek_hundred'::regclass, prop) as "Index", + pg_index_column_has_property('onek_hundred'::regclass, 1, prop) as "Column" + from pg_am a, + unnest(array['asc', 'desc', 'nulls_first', 'nulls_last', + 'orderable', 'distance_orderable', 'returnable', + 'search_array', 'search_nulls', + 'clusterable', 'index_scan', 'bitmap_scan', + 'backward_scan', + 'can_order', 'can_unique', 'can_multi_col', + 'can_exclude', 'can_include', + 'bogus']::text[]) + with ordinality as u(prop,ord) + where a.amname = 'btree' + order by ord +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +FUNCTION: name="pg_indexam_has_property" function="pg_indexam_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="a" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_am a, unnest(ARRAY['asc', 'desc', 'nulls_first', 'nulls_last', 'orderable', 'd..." +== 002 +-- truncate_limit: 100 +select prop, + pg_indexam_has_property(a.oid, prop) as "AM", + pg_index_has_property('gcircleind'::regclass, prop) as "Index", + pg_index_column_has_property('gcircleind'::regclass, 1, prop) as "Column" + from pg_am a, + unnest(array['asc', 'desc', 'nulls_first', 'nulls_last', + 'orderable', 'distance_orderable', 'returnable', + 'search_array', 'search_nulls', + 'clusterable', 'index_scan', 'bitmap_scan', + 'backward_scan', + 'can_order', 'can_unique', 'can_multi_col', + 'can_exclude', 'can_include', + 'bogus']::text[]) + with ordinality as u(prop,ord) + where a.amname = 'gist' + order by ord +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +FUNCTION: name="pg_indexam_has_property" function="pg_indexam_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="a" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_am a, unnest(ARRAY['asc', 'desc', 'nulls_first', 'nulls_last', 'orderable', 'd..." +== 003 +-- truncate_limit: 100 +select prop, + pg_index_column_has_property('onek_hundred'::regclass, 1, prop) as btree, + pg_index_column_has_property('hash_i4_index'::regclass, 1, prop) as hash, + pg_index_column_has_property('gcircleind'::regclass, 1, prop) as gist, + pg_index_column_has_property('sp_radix_ind'::regclass, 1, prop) as spgist_radix, + pg_index_column_has_property('sp_quad_ind'::regclass, 1, prop) as spgist_quad, + pg_index_column_has_property('botharrayidx'::regclass, 1, prop) as gin, + pg_index_column_has_property('brinidx'::regclass, 1, prop) as brin + from unnest(array['asc', 'desc', 'nulls_first', 'nulls_last', + 'orderable', 'distance_orderable', 'returnable', + 'search_array', 'search_nulls', + 'bogus']::text[]) + with ordinality as u(prop,ord) + order by ord +-- +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY['asc', 'desc', 'nulls_first', 'nulls_last', 'orderable', 'distance_o..." +== 004 +-- truncate_limit: 100 +select prop, + pg_index_has_property('onek_hundred'::regclass, prop) as btree, + pg_index_has_property('hash_i4_index'::regclass, prop) as hash, + pg_index_has_property('gcircleind'::regclass, prop) as gist, + pg_index_has_property('sp_radix_ind'::regclass, prop) as spgist, + pg_index_has_property('botharrayidx'::regclass, prop) as gin, + pg_index_has_property('brinidx'::regclass, prop) as brin + from unnest(array['clusterable', 'index_scan', 'bitmap_scan', + 'backward_scan', + 'bogus']::text[]) + with ordinality as u(prop,ord) + order by ord +-- +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="pg_index_has_property" function="pg_index_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY['clusterable', 'index_scan', 'bitmap_scan', 'backward_scan', 'bogus'..." +== 005 +-- truncate_limit: 100 +select amname, prop, pg_indexam_has_property(a.oid, prop) as p + from pg_am a, + unnest(array['can_order', 'can_unique', 'can_multi_col', + 'can_exclude', 'can_include', 'bogus']::text[]) + with ordinality as u(prop,ord) + where amtype = 'i' + order by amname, ord +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +FUNCTION: name="pg_indexam_has_property" function="pg_indexam_has_property" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="" column="amtype" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_am a, unnest(ARRAY['can_order', 'can_unique', 'can_multi_col', 'can_exclude', ..." +== 006 +-- truncate_limit: 100 +|-- +-- additional checks for pg_index_column_has_property +|-- +CREATE TEMP TABLE foo (f1 int, f2 int, f3 int, f4 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (f1 int, f2 int, f3 int, f4 int)" +== 007 +-- truncate_limit: 100 +CREATE INDEX fooindex ON foo (f1 desc, f2 asc, f3 nulls first, f4 nulls last) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fooindex ON foo USING btree (f1 DESC, f2 ASC, f3 NULLS FIRST, f4 NULLS LAST)" +== 008 +-- truncate_limit: 100 +select col, prop, pg_index_column_has_property(o, col, prop) + from (values ('fooindex'::regclass)) v1(o), + (values (1,'orderable'),(2,'asc'),(3,'desc'), + (4,'nulls_first'),(5,'nulls_last'), + (6, 'bogus')) v2(idx,prop), + generate_series(1,4) col + order by col, idx +-- +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v1(o), (VALUES (...)) v2(idx, prop), generate_series(1, 4) col ORD..." +== 009 +-- truncate_limit: 100 +CREATE INDEX foocover ON foo (f1) INCLUDE (f2,f3) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX foocover ON foo USING btree (f1) INCLUDE (f2, f3)" +== 010 +-- truncate_limit: 100 +select col, prop, pg_index_column_has_property(o, col, prop) + from (values ('foocover'::regclass)) v1(o), + (values (1,'orderable'),(2,'asc'),(3,'desc'), + (4,'nulls_first'),(5,'nulls_last'), + (6,'distance_orderable'),(7,'returnable'), + (8, 'bogus')) v2(idx,prop), + generate_series(1,3) col + order by col, idx +-- +FUNCTION: name="pg_index_column_has_property" function="pg_index_column_has_property" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v1(o), (VALUES (...)) v2(idx, prop), generate_series(1, 3) col ORD..." diff --git a/parser/testdata/summary_truncate/postgres_regress/arrays.metadata.json b/parser/testdata/summary_truncate/postgres_regress/arrays.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/arrays.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/arrays.test b/parser/testdata/summary_truncate/postgres_regress/arrays.test new file mode 100644 index 0000000..f831404 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/arrays.test @@ -0,0 +1,3752 @@ +== 001 +-- truncate_limit: 100 +|-- +-- ARRAYS +|-- + +-- directory paths are passed to us in environment variables + +CREATE TABLE arrtest ( + a int2[], + b int4[][][], + c name[], + d text[][], + e float8[], + f char(5)[], + g varchar(5)[] +) +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE arrtest (a int2[], b int4[][][], c name[], d text[][], e float8[], f char(5)[], g va..." +== 002 +-- truncate_limit: 100 +CREATE TABLE array_op_test ( + seqno int4, + i int4[], + t text[] +) +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE array_op_test (seqno int4, i int4[], t text[])" +== 003 +-- truncate_limit: 100 +COPY array_op_test FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +ANALYZE array_op_test +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE array_op_test" +== 005 +-- truncate_limit: 100 +|-- +-- only the 'e' array is 0-based, the others are 1-based. +|-- + +INSERT INTO arrtest (a[1:5], b[1:1][1:2][1:2], c, d, f, g) + VALUES ('{1,2,3,4,5}', '{{{0,0},{1,2}}}', '{}', '{}', '{}', '{}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest (a[1:5], b[1:1][1:2][1:2], c, d, f, g) VALUES (...)" +== 006 +-- truncate_limit: 100 +UPDATE arrtest SET e[0] = '1.1' +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET e[0] = '1.1'" +== 007 +-- truncate_limit: 100 +UPDATE arrtest SET e[1] = '2.2' +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET e[1] = '2.2'" +== 008 +-- truncate_limit: 100 +INSERT INTO arrtest (f) + VALUES ('{"too long"}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest (f) VALUES ('{\"too long\"}')" +== 009 +-- truncate_limit: 100 +INSERT INTO arrtest (a, b[1:2][1:2], c, d, e, f, g) + VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}', + '{{"elt1", "elt2"}}', '{"3.4", "6.7"}', + '{"abc","abcde"}', '{"abc","abcde"}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest (a, b[1:2][1:2], c, d, e, f, g) VALUES (...)" +== 010 +-- truncate_limit: 100 +INSERT INTO arrtest (a, b[1:2], c, d[1:2]) + VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest (a, b[1:2], c, d[1:2]) VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}')" +== 011 +-- truncate_limit: 100 +INSERT INTO arrtest (b[2]) VALUES(now()) +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest (b[2]) VALUES (now())" +== 012 +-- truncate_limit: 100 +-- error, type mismatch + +INSERT INTO arrtest (b[1:2]) VALUES(now()) +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest (b[1:2]) VALUES (now())" +== 013 +-- truncate_limit: 100 +-- error, type mismatch + +SELECT * FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest" +== 014 +-- truncate_limit: 100 +SELECT arrtest.a[1], + arrtest.b[1][1][1], + arrtest.c[1], + arrtest.d[1][1], + arrtest.e[0] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT arrtest.a[1], arrtest.b[1][1][1], arrtest.c[1], arrtest.d[1][1], arrtest.e[0] FROM arrtest" +== 015 +-- truncate_limit: 100 +SELECT a[1], b[1][1][1], c[1], d[1][1], e[0] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a[1], b[1][1][1], c[1], d[1][1], e[0] FROM arrtest" +== 016 +-- truncate_limit: 100 +SELECT a[1:3], + b[1:1][1:2][1:2], + c[1:2], + d[1:1][1:2] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a[1:3], b[1:1][1:2][1:2], c[1:2], d[1:1][1:2] FROM arrtest" +== 017 +-- truncate_limit: 100 +SELECT array_ndims(a) AS a,array_ndims(b) AS b,array_ndims(c) AS c + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FUNCTION: name="array_ndims" function="array_ndims" schema="" ctx=Call +FUNCTION: name="array_ndims" function="array_ndims" schema="" ctx=Call +FUNCTION: name="array_ndims" function="array_ndims" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_ndims(a) AS a, array_ndims(b) AS b, array_ndims(c) AS c FROM arrtest" +== 018 +-- truncate_limit: 100 +SELECT array_dims(a) AS a,array_dims(b) AS b,array_dims(c) AS c + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_dims(a) AS a, array_dims(b) AS b, array_dims(c) AS c FROM arrtest" +== 019 +-- truncate_limit: 100 +-- returns nothing +SELECT * + FROM arrtest + WHERE a[1] < 5 and + c = '{"foobar"}'::_name +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest WHERE a[1] < 5 AND c = '{\"foobar\"}'::_name" +== 020 +-- truncate_limit: 100 +UPDATE arrtest + SET a[1:2] = '{16,25}' + WHERE NOT a = '{}'::_int2 +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET a[1:2] = '{16,25}' WHERE NOT a = '{}'::_int2" +== 021 +-- truncate_limit: 100 +UPDATE arrtest + SET b[1:1][1:1][1:2] = '{113, 117}', + b[1:1][1:2][2:2] = '{142, 147}' + WHERE array_dims(b) = '[1:1][1:2][1:2]' +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET ... = ... WHERE array_dims(b) = '[1:1][1:2][1:2]'" +== 022 +-- truncate_limit: 100 +UPDATE arrtest + SET c[2:2] = '{"new_word"}' + WHERE array_dims(c) is not null +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET c[2:2] = '{\"new_word\"}' WHERE array_dims(c) IS NOT NULL" +== 023 +-- truncate_limit: 100 +SELECT a,b,c FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c FROM arrtest" +== 024 +-- truncate_limit: 100 +SELECT a[1:3], + b[1:1][1:2][1:2], + c[1:2], + d[1:1][2:2] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a[1:3], b[1:1][1:2][1:2], c[1:2], d[1:1][2:2] FROM arrtest" +== 025 +-- truncate_limit: 100 +SELECT b[1:1][2][2], + d[1:1][2] + FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b[1:1][2][2], d[1:1][2] FROM arrtest" +== 026 +-- truncate_limit: 100 +INSERT INTO arrtest(a) VALUES('{1,null,3}') +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest (a) VALUES ('{1,null,3}')" +== 027 +-- truncate_limit: 100 +SELECT a FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a FROM arrtest" +== 028 +-- truncate_limit: 100 +UPDATE arrtest SET a[4] = NULL WHERE a[2] IS NULL +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET a[4] = NULL WHERE a[2] IS NULL" +== 029 +-- truncate_limit: 100 +SELECT a FROM arrtest WHERE a[2] IS NULL +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM arrtest WHERE a[2] IS NULL" +== 030 +-- truncate_limit: 100 +DELETE FROM arrtest WHERE a[2] IS NULL AND b IS NULL +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM arrtest WHERE a[2] IS NULL AND b IS NULL" +== 031 +-- truncate_limit: 100 +SELECT a,b,c FROM arrtest +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c FROM arrtest" +== 032 +-- truncate_limit: 100 +-- test non-error-throwing API +SELECT pg_input_is_valid('{1,2,3}', 'integer[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{1,2,3}', 'integer[]')" +== 033 +-- truncate_limit: 100 +SELECT pg_input_is_valid('{1,2', 'integer[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{1,2', 'integer[]')" +== 034 +-- truncate_limit: 100 +SELECT pg_input_is_valid('{1,zed}', 'integer[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{1,zed}', 'integer[]')" +== 035 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('{1,zed}', 'integer[]') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{1,zed}', 'integer[]')" +== 036 +-- truncate_limit: 100 +-- test mixed slice/scalar subscripting +select '{{1,2,3},{4,5,6},{7,8,9}}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{1,2,3},{4,5,6},{7,8,9}}'::int[]" +== 037 +-- truncate_limit: 100 +select ('{{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2]" +== 038 +-- truncate_limit: 100 +select '[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[]" +== 039 +-- truncate_limit: 100 +select ('[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[0:2][0:2]={{1,2,3},{4,5,6},{7,8,9}}'::int[])[1:2][2]" +== 040 +-- truncate_limit: 100 +|-- +-- check subscription corner cases +|-- +-- More subscripts than MAXDIM (6) +SELECT ('{}'::int[])[1][2][3][4][5][6][7] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{}'::int[])[1][2][3][4][5][6][7]" +== 041 +-- truncate_limit: 100 +-- NULL index yields NULL when selecting +SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL][1] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL][1]" +== 042 +-- truncate_limit: 100 +SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL:1][1] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][NULL:1][1]" +== 043 +-- truncate_limit: 100 +SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][1:NULL][1] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{{{1},{2},{3}},{{4},{5},{6}}}'::int[])[1][1:NULL][1]" +== 044 +-- truncate_limit: 100 +-- NULL index in assignment is an error +UPDATE arrtest + SET c[NULL] = '{"can''t assign"}' + WHERE array_dims(c) is not null +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET c[NULL] = '{\"can''t assign\"}' WHERE array_dims(c) IS NOT NULL" +== 045 +-- truncate_limit: 100 +UPDATE arrtest + SET c[NULL:1] = '{"can''t assign"}' + WHERE array_dims(c) is not null +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET c[NULL:1] = '{\"can''t assign\"}' WHERE array_dims(c) IS NOT NULL" +== 046 +-- truncate_limit: 100 +UPDATE arrtest + SET c[1:NULL] = '{"can''t assign"}' + WHERE array_dims(c) is not null +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=DML +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest SET c[1:NULL] = '{\"can''t assign\"}' WHERE array_dims(c) IS NOT NULL" +== 047 +-- truncate_limit: 100 +-- Un-subscriptable type +SELECT (now())[1] +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (now())[1]" +== 048 +-- truncate_limit: 100 +-- test slices with empty lower and/or upper index +CREATE TEMP TABLE arrtest_s ( + a int2[], + b int2[][] +) +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE arrtest_s (a int2[], b int2[][])" +== 049 +-- truncate_limit: 100 +INSERT INTO arrtest_s VALUES ('{1,2,3,4,5}', '{{1,2,3}, {4,5,6}, {7,8,9}}') +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_s VALUES ('{1,2,3,4,5}', '{{1,2,3}, {4,5,6}, {7,8,9}}')" +== 050 +-- truncate_limit: 100 +INSERT INTO arrtest_s VALUES ('[0:4]={1,2,3,4,5}', '[0:2][0:2]={{1,2,3}, {4,5,6}, {7,8,9}}') +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_s VALUES ('[0:4]={1,2,3,4,5}', '[0:2][0:2]={{1,2,3}, {4,5,6}, {7,8,9}}')" +== 051 +-- truncate_limit: 100 +SELECT * FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest_s" +== 052 +-- truncate_limit: 100 +SELECT a[:3], b[:2][:2] FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a[:3], b[:2][:2] FROM arrtest_s" +== 053 +-- truncate_limit: 100 +SELECT a[2:], b[2:][2:] FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a[2:], b[2:][2:] FROM arrtest_s" +== 054 +-- truncate_limit: 100 +SELECT a[:], b[:] FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a[:], b[:] FROM arrtest_s" +== 055 +-- truncate_limit: 100 +-- updates +UPDATE arrtest_s SET a[:3] = '{11, 12, 13}', b[:2][:2] = '{{11,12}, {14,15}}' + WHERE array_lower(a,1) = 1 +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest_s SET ... = ... WHERE array_lower(a, 1) = 1" +== 056 +-- truncate_limit: 100 +SELECT * FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest_s" +== 057 +-- truncate_limit: 100 +UPDATE arrtest_s SET a[3:] = '{23, 24, 25}', b[2:][2:] = '{{25,26}, {28,29}}' +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest_s SET a[3:] = '{23, 24, 25}', b[2:][2:] = '{{25,26}, {28,29}}'" +== 058 +-- truncate_limit: 100 +SELECT * FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest_s" +== 059 +-- truncate_limit: 100 +UPDATE arrtest_s SET a[:] = '{11, 12, 13, 14, 15}' +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest_s SET a[:] = '{11, 12, 13, 14, 15}'" +== 060 +-- truncate_limit: 100 +SELECT * FROM arrtest_s +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest_s" +== 061 +-- truncate_limit: 100 +UPDATE arrtest_s SET a[:] = '{23, 24, 25}' +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest_s SET a[:] = '{23, 24, 25}'" +== 062 +-- truncate_limit: 100 +-- fail, too small +INSERT INTO arrtest_s VALUES(NULL, NULL) +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_s VALUES (NULL, NULL)" +== 063 +-- truncate_limit: 100 +UPDATE arrtest_s SET a[:] = '{11, 12, 13, 14, 15}' +-- +TABLE: name="arrtest_s" schema="" table="arrtest_s" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest_s SET a[:] = '{11, 12, 13, 14, 15}'" +== 064 +-- truncate_limit: 100 +-- fail, no good with null + +-- we want to work with a point_tbl that includes a null +CREATE TEMP TABLE point_tbl AS SELECT * FROM public.point_tbl +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DDL +TABLE: name="public.point_tbl" schema="public" table="point_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE point_tbl AS SELECT * FROM public.point_tbl" +== 065 +-- truncate_limit: 100 +INSERT INTO POINT_TBL(f1) VALUES (NULL) +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1) VALUES (NULL)" +== 066 +-- truncate_limit: 100 +-- check with fixed-length-array type, such as point +SELECT f1[0:1] FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1[0:1] FROM point_tbl" +== 067 +-- truncate_limit: 100 +SELECT f1[0:] FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1[0:] FROM point_tbl" +== 068 +-- truncate_limit: 100 +SELECT f1[:1] FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1[:1] FROM point_tbl" +== 069 +-- truncate_limit: 100 +SELECT f1[:] FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1[:] FROM point_tbl" +== 070 +-- truncate_limit: 100 +-- subscript assignments to fixed-width result in NULL if previous value is NULL +UPDATE point_tbl SET f1[0] = 10 WHERE f1 IS NULL RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE point_tbl SET f1[0] = 10 WHERE f1 IS NULL RETURNING *" +== 071 +-- truncate_limit: 100 +INSERT INTO point_tbl(f1[0]) VALUES(0) RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1[0]) VALUES (0) RETURNING *" +== 072 +-- truncate_limit: 100 +-- NULL assignments get ignored +UPDATE point_tbl SET f1[0] = NULL WHERE f1::text = '(10,10)'::point::text RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE point_tbl SET f1[0] = NULL WHERE f1::text = '(10,10)'::point::text RETURNING *" +== 073 +-- truncate_limit: 100 +-- but non-NULL subscript assignments work +UPDATE point_tbl SET f1[0] = -10, f1[1] = -10 WHERE f1::text = '(10,10)'::point::text RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE point_tbl SET f1[0] = -10, f1[1] = -10 WHERE f1::text = '(10,10)'::point::text RETURNING *" +== 074 +-- truncate_limit: 100 +-- but not to expand the range +UPDATE point_tbl SET f1[3] = 10 WHERE f1::text = '(-10,-10)'::point::text RETURNING * +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE point_tbl SET f1[3] = 10 WHERE f1::text = '(-10,-10)'::point::text RETURNING *" +== 075 +-- truncate_limit: 100 +|-- +-- test array extension +|-- +CREATE TEMP TABLE arrtest1 (i int[], t text[]) +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE arrtest1 (i int[], t text[])" +== 076 +-- truncate_limit: 100 +insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']) +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest1 VALUES (ARRAY[1, 2, NULL, 4], ARRAY['one', 'two', NULL, 'four'])" +== 077 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 078 +-- truncate_limit: 100 +update arrtest1 set i[2] = 22, t[2] = 'twenty-two' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[2] = 22, t[2] = 'twenty-two'" +== 079 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 080 +-- truncate_limit: 100 +update arrtest1 set i[5] = 5, t[5] = 'five' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[5] = 5, t[5] = 'five'" +== 081 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 082 +-- truncate_limit: 100 +update arrtest1 set i[8] = 8, t[8] = 'eight' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[8] = 8, t[8] = 'eight'" +== 083 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 084 +-- truncate_limit: 100 +update arrtest1 set i[0] = 0, t[0] = 'zero' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[0] = 0, t[0] = 'zero'" +== 085 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 086 +-- truncate_limit: 100 +update arrtest1 set i[-3] = -3, t[-3] = 'minus-three' +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[-3] = -3, t[-3] = 'minus-three'" +== 087 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 088 +-- truncate_limit: 100 +update arrtest1 set i[0:2] = array[10,11,12], t[0:2] = array['ten','eleven','twelve'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[0:2] = ARRAY[10, 11, 12], t[0:2] = ARRAY['ten', 'eleven', 'twelve']" +== 089 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 090 +-- truncate_limit: 100 +update arrtest1 set i[8:10] = array[18,null,20], t[8:10] = array['p18',null,'p20'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[8:10] = ARRAY[18, NULL, 20], t[8:10] = ARRAY['p18', NULL, 'p20']" +== 091 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 092 +-- truncate_limit: 100 +update arrtest1 set i[11:12] = array[null,22], t[11:12] = array[null,'p22'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[11:12] = ARRAY[NULL, 22], t[11:12] = ARRAY[NULL, 'p22']" +== 093 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 094 +-- truncate_limit: 100 +update arrtest1 set i[15:16] = array[null,26], t[15:16] = array[null,'p26'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[15:16] = ARRAY[NULL, 26], t[15:16] = ARRAY[NULL, 'p26']" +== 095 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 096 +-- truncate_limit: 100 +update arrtest1 set i[-5:-3] = array[-15,-14,-13], t[-5:-3] = array['m15','m14','m13'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[-5:-3] = ARRAY[-15, -14, -13], t[-5:-3] = ARRAY['m15', 'm14', 'm13']" +== 097 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 098 +-- truncate_limit: 100 +update arrtest1 set i[-7:-6] = array[-17,null], t[-7:-6] = array['m17',null] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[-7:-6] = ARRAY[-17, NULL], t[-7:-6] = ARRAY['m17', NULL]" +== 099 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 100 +-- truncate_limit: 100 +update arrtest1 set i[-12:-10] = array[-22,null,-20], t[-12:-10] = array['m22',null,'m20'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET i[-12:-10] = ARRAY[-22, NULL, -20], t[-12:-10] = ARRAY['m22', NULL, 'm20']" +== 101 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 102 +-- truncate_limit: 100 +delete from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM arrtest1" +== 103 +-- truncate_limit: 100 +insert into arrtest1 values(array[1,2,null,4], array['one','two',null,'four']) +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest1 VALUES (ARRAY[1, 2, NULL, 4], ARRAY['one', 'two', NULL, 'four'])" +== 104 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 105 +-- truncate_limit: 100 +update arrtest1 set i[0:5] = array[0,1,2,null,4,5], t[0:5] = array['z','p1','p2',null,'p4','p5'] +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arrtest1 SET ... = ..." +== 106 +-- truncate_limit: 100 +select * from arrtest1 +-- +TABLE: name="arrtest1" schema="" table="arrtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arrtest1" +== 107 +-- truncate_limit: 100 +|-- +-- array expressions and operators +|-- + +-- table creation and INSERTs +CREATE TEMP TABLE arrtest2 (i integer ARRAY[4], f float8[], n numeric[], t text[], d timestamp[]) +-- +TABLE: name="arrtest2" schema="" table="arrtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE arrtest2 (i int[4], f float8[], n numeric[], t text[], d timestamp[])" +== 108 +-- truncate_limit: 100 +INSERT INTO arrtest2 VALUES( + ARRAY[[[113,142],[1,147]]], + ARRAY[1.1,1.2,1.3]::float8[], + ARRAY[1.1,1.2,1.3], + ARRAY[[['aaa','aab'],['aba','abb'],['aca','acb']],[['baa','bab'],['bba','bbb'],['bca','bcb']]], + ARRAY['19620326','19931223','19970117']::timestamp[] +) +-- +TABLE: name="arrtest2" schema="" table="arrtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest2 VALUES (...)" +== 109 +-- truncate_limit: 100 +-- some more test data +CREATE TEMP TABLE arrtest_f (f0 int, f1 text, f2 float8) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE arrtest_f (f0 int, f1 text, f2 float8)" +== 110 +-- truncate_limit: 100 +insert into arrtest_f values(1,'cat1',1.21) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (1, 'cat1', 1.21)" +== 111 +-- truncate_limit: 100 +insert into arrtest_f values(2,'cat1',1.24) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (2, 'cat1', 1.24)" +== 112 +-- truncate_limit: 100 +insert into arrtest_f values(3,'cat1',1.18) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (3, 'cat1', 1.18)" +== 113 +-- truncate_limit: 100 +insert into arrtest_f values(4,'cat1',1.26) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (4, 'cat1', 1.26)" +== 114 +-- truncate_limit: 100 +insert into arrtest_f values(5,'cat1',1.15) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (5, 'cat1', 1.15)" +== 115 +-- truncate_limit: 100 +insert into arrtest_f values(6,'cat2',1.15) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (6, 'cat2', 1.15)" +== 116 +-- truncate_limit: 100 +insert into arrtest_f values(7,'cat2',1.26) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (7, 'cat2', 1.26)" +== 117 +-- truncate_limit: 100 +insert into arrtest_f values(8,'cat2',1.32) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (8, 'cat2', 1.32)" +== 118 +-- truncate_limit: 100 +insert into arrtest_f values(9,'cat2',1.30) +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_f VALUES (9, 'cat2', 1.30)" +== 119 +-- truncate_limit: 100 +CREATE TEMP TABLE arrtest_i (f0 int, f1 text, f2 int) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE arrtest_i (f0 int, f1 text, f2 int)" +== 120 +-- truncate_limit: 100 +insert into arrtest_i values(1,'cat1',21) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (1, 'cat1', 21)" +== 121 +-- truncate_limit: 100 +insert into arrtest_i values(2,'cat1',24) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (2, 'cat1', 24)" +== 122 +-- truncate_limit: 100 +insert into arrtest_i values(3,'cat1',18) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (3, 'cat1', 18)" +== 123 +-- truncate_limit: 100 +insert into arrtest_i values(4,'cat1',26) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (4, 'cat1', 26)" +== 124 +-- truncate_limit: 100 +insert into arrtest_i values(5,'cat1',15) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (5, 'cat1', 15)" +== 125 +-- truncate_limit: 100 +insert into arrtest_i values(6,'cat2',15) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (6, 'cat2', 15)" +== 126 +-- truncate_limit: 100 +insert into arrtest_i values(7,'cat2',26) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (7, 'cat2', 26)" +== 127 +-- truncate_limit: 100 +insert into arrtest_i values(8,'cat2',32) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (8, 'cat2', 32)" +== 128 +-- truncate_limit: 100 +insert into arrtest_i values(9,'cat2',30) +-- +TABLE: name="arrtest_i" schema="" table="arrtest_i" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arrtest_i VALUES (9, 'cat2', 30)" +== 129 +-- truncate_limit: 100 +-- expressions +SELECT t.f[1][3][1] AS "131", t.f[2][2][1] AS "221" FROM ( + SELECT ARRAY[[[111,112],[121,122],[131,132]],[[211,212],[221,122],[231,232]]] AS f +) AS t +-- +STMT: SelectStmt +TRUNCATED: "SELECT t.f[1][3][1] AS \"131\", t.f[2][2][1] AS \"221\" FROM (SELECT ...) t" +== 130 +-- truncate_limit: 100 +SELECT ARRAY[[[[[['hello'],['world']]]]]] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[ARRAY[ARRAY[ARRAY[ARRAY[ARRAY['hello'], ARRAY['world']]]]]]" +== 131 +-- truncate_limit: 100 +SELECT ARRAY[ARRAY['hello'],ARRAY['world']] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[ARRAY['hello'], ARRAY['world']]" +== 132 +-- truncate_limit: 100 +SELECT ARRAY(select f2 from arrtest_f order by f2) AS "ARRAY" +-- +TABLE: name="arrtest_f" schema="" table="arrtest_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY(SELECT f2 FROM arrtest_f ORDER BY f2) AS \"ARRAY\"" +== 133 +-- truncate_limit: 100 +-- with nulls +SELECT '{1,null,3}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{1,null,3}'::int[]" +== 134 +-- truncate_limit: 100 +SELECT ARRAY[1,NULL,3] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, NULL, 3]" +== 135 +-- truncate_limit: 100 +-- functions +SELECT array_append(array[42], 6) AS "{42,6}" +-- +FUNCTION: name="array_append" function="array_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_append(ARRAY[42], 6) AS \"{42,6}\"" +== 136 +-- truncate_limit: 100 +SELECT array_prepend(6, array[42]) AS "{6,42}" +-- +FUNCTION: name="array_prepend" function="array_prepend" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_prepend(6, ARRAY[42]) AS \"{6,42}\"" +== 137 +-- truncate_limit: 100 +SELECT array_cat(ARRAY[1,2], ARRAY[3,4]) AS "{1,2,3,4}" +-- +FUNCTION: name="array_cat" function="array_cat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_cat(ARRAY[1, 2], ARRAY[3, 4]) AS \"{1,2,3,4}\"" +== 138 +-- truncate_limit: 100 +SELECT array_cat(ARRAY[1,2], ARRAY[[3,4],[5,6]]) AS "{{1,2},{3,4},{5,6}}" +-- +FUNCTION: name="array_cat" function="array_cat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_cat(ARRAY[1, 2], ARRAY[ARRAY[3, 4], ARRAY[5, 6]]) AS \"{{1,2},{3,4},{5,6}}\"" +== 139 +-- truncate_limit: 100 +SELECT array_cat(ARRAY[[3,4],[5,6]], ARRAY[1,2]) AS "{{3,4},{5,6},{1,2}}" +-- +FUNCTION: name="array_cat" function="array_cat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_cat(ARRAY[ARRAY[3, 4], ARRAY[5, 6]], ARRAY[1, 2]) AS \"{{3,4},{5,6},{1,2}}\"" +== 140 +-- truncate_limit: 100 +SELECT array_position(ARRAY[1,2,3,4,5], 4) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ARRAY[1, 2, 3, 4, 5], 4)" +== 141 +-- truncate_limit: 100 +SELECT array_position(ARRAY[5,3,4,2,1], 4) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ARRAY[5, 3, 4, 2, 1], 4)" +== 142 +-- truncate_limit: 100 +SELECT array_position(ARRAY[[1,2],[3,4]], 3) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ARRAY[ARRAY[1, 2], ARRAY[3, 4]], 3)" +== 143 +-- truncate_limit: 100 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'mon') +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ARRAY['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], 'mon')" +== 144 +-- truncate_limit: 100 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'sat') +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ARRAY['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], 'sat')" +== 145 +-- truncate_limit: 100 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], NULL) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ARRAY['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], NULL)" +== 146 +-- truncate_limit: 100 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], NULL) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ARRAY['sun', 'mon', 'tue', 'wed', 'thu', NULL, 'fri', 'sat'], NULL)" +== 147 +-- truncate_limit: 100 +SELECT array_position(ARRAY['sun','mon','tue','wed','thu',NULL,'fri','sat'], 'sat') +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ARRAY['sun', 'mon', 'tue', 'wed', 'thu', NULL, 'fri', 'sat'], 'sat')" +== 148 +-- truncate_limit: 100 +SELECT array_positions(NULL, 10) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_positions(NULL, 10)" +== 149 +-- truncate_limit: 100 +SELECT array_positions(NULL, NULL::int) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_positions(NULL, NULL::int)" +== 150 +-- truncate_limit: 100 +SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], 4) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_positions(ARRAY[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], 4)" +== 151 +-- truncate_limit: 100 +SELECT array_positions(ARRAY[[1,2],[3,4]], 4) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_positions(ARRAY[ARRAY[1, 2], ARRAY[3, 4]], 4)" +== 152 +-- truncate_limit: 100 +SELECT array_positions(ARRAY[1,2,3,4,5,6,1,2,3,4,5,6], NULL) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_positions(ARRAY[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], NULL)" +== 153 +-- truncate_limit: 100 +SELECT array_positions(ARRAY[1,2,3,NULL,5,6,1,2,3,NULL,5,6], NULL) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_positions(ARRAY[1, 2, 3, NULL, 5, 6, 1, 2, 3, NULL, 5, 6], NULL)" +== 154 +-- truncate_limit: 100 +SELECT array_length(array_positions(ARRAY(SELECT 'AAAAAAAAAAAAAAAAAAAAAAAAA'::text || i % 10 + FROM generate_series(1,100) g(i)), + 'AAAAAAAAAAAAAAAAAAAAAAAAA5'), 1) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 155 +-- truncate_limit: 100 +DO $$ +DECLARE + o int; + a int[] := ARRAY[1,2,3,2,3,1,2]; +BEGIN + o := array_position(a, 2); + WHILE o IS NOT NULL + LOOP + RAISE NOTICE '%', o; + o := array_position(a, 2, o + 1); + END LOOP; +END +$$ LANGUAGE plpgsql +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n o int;\n a int[] := ARRAY[1,2,3,2,3,1,2];\nBEGIN\n o := array_position(a, 2);\n WH..." +== 156 +-- truncate_limit: 100 +SELECT array_position('[2:4]={1,2,3}'::int[], 1) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position('[2:4]={1,2,3}'::int[], 1)" +== 157 +-- truncate_limit: 100 +SELECT array_positions('[2:4]={1,2,3}'::int[], 1) +-- +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_positions('[2:4]={1,2,3}'::int[], 1)" +== 158 +-- truncate_limit: 100 +SELECT + array_position(ids, (1, 1)), + array_positions(ids, (1, 1)) + FROM +(VALUES + (ARRAY[(0, 0), (1, 1)]), + (ARRAY[(1, 1)]) +) AS f (ids) +-- +FUNCTION: name="array_position" function="array_position" schema="" ctx=Call +FUNCTION: name="array_positions" function="array_positions" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_position(ids, (1, 1)), array_positions(ids, (1, 1)) FROM (VALUES (...)) f(ids)" +== 159 +-- truncate_limit: 100 +-- operators +SELECT a FROM arrtest WHERE b = ARRAY[[[113,142],[1,147]]] +-- +TABLE: name="arrtest" schema="" table="arrtest" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM arrtest WHERE b = ARRAY[ARRAY[ARRAY[113, 142], ARRAY[1, 147]]]" +== 160 +-- truncate_limit: 100 +SELECT NOT ARRAY[1.1,1.2,1.3] = ARRAY[1.1,1.2,1.3] AS "FALSE" +-- +STMT: SelectStmt +TRUNCATED: "SELECT NOT ARRAY[1.1, 1.2, 1.3] = ARRAY[1.1, 1.2, 1.3] AS \"FALSE\"" +== 161 +-- truncate_limit: 100 +SELECT ARRAY[1,2] || 3 AS "{1,2,3}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, 2] || 3 AS \"{1,2,3}\"" +== 162 +-- truncate_limit: 100 +SELECT 0 || ARRAY[1,2] AS "{0,1,2}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0 || ARRAY[1, 2] AS \"{0,1,2}\"" +== 163 +-- truncate_limit: 100 +SELECT ARRAY[1,2] || ARRAY[3,4] AS "{1,2,3,4}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, 2] || ARRAY[3, 4] AS \"{1,2,3,4}\"" +== 164 +-- truncate_limit: 100 +SELECT ARRAY[[['hello','world']]] || ARRAY[[['happy','birthday']]] AS "ARRAY" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[ARRAY[ARRAY['hello', 'world']]] || ARRAY[ARRAY[ARRAY['happy', 'birthday']]] AS \"ARRAY\"" +== 165 +-- truncate_limit: 100 +SELECT ARRAY[[1,2],[3,4]] || ARRAY[5,6] AS "{{1,2},{3,4},{5,6}}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[ARRAY[1, 2], ARRAY[3, 4]] || ARRAY[5, 6] AS \"{{1,2},{3,4},{5,6}}\"" +== 166 +-- truncate_limit: 100 +SELECT ARRAY[0,0] || ARRAY[1,1] || ARRAY[2,2] AS "{0,0,1,1,2,2}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT (ARRAY[0, 0] || ARRAY[1, 1]) || ARRAY[2, 2] AS \"{0,0,1,1,2,2}\"" +== 167 +-- truncate_limit: 100 +SELECT 0 || ARRAY[1,2] || 3 AS "{0,1,2,3}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT (0 || ARRAY[1, 2]) || 3 AS \"{0,1,2,3}\"" +== 168 +-- truncate_limit: 100 +SELECT ARRAY[1.1] || ARRAY[2,3,4] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1.1] || ARRAY[2, 3, 4]" +== 169 +-- truncate_limit: 100 +SELECT array_agg(x) || array_agg(x) FROM (VALUES (ROW(1,2)), (ROW(3,4))) v(x) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(x) || array_agg(x) FROM (VALUES (ROW(1, 2)), (ROW(3, 4))) v(x)" +== 170 +-- truncate_limit: 100 +SELECT ROW(1,2) || array_agg(x) FROM (VALUES (ROW(3,4)), (ROW(5,6))) v(x) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) || array_agg(x) FROM (VALUES (ROW(3, 4)), (ROW(5, 6))) v(x)" +== 171 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i @> '{32}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i @> '{32}' ORDER BY seqno" +== 172 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i && '{32}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i && '{32}' ORDER BY seqno" +== 173 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i @> '{17}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i @> '{17}' ORDER BY seqno" +== 174 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i && '{17}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i && '{17}' ORDER BY seqno" +== 175 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i @> '{32,17}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i @> '{32,17}' ORDER BY seqno" +== 176 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i && '{32,17}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i && '{32,17}' ORDER BY seqno" +== 177 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i <@ '{38,34,32,89}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i <@ '{38,34,32,89}' ORDER BY seqno" +== 178 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i = '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i = '{}' ORDER BY seqno" +== 179 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i @> '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i @> '{}' ORDER BY seqno" +== 180 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i && '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i && '{}' ORDER BY seqno" +== 181 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i <@ '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i <@ '{}' ORDER BY seqno" +== 182 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i = '{NULL}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i = '{NULL}' ORDER BY seqno" +== 183 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i @> '{NULL}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i @> '{NULL}' ORDER BY seqno" +== 184 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i && '{NULL}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i && '{NULL}' ORDER BY seqno" +== 185 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE i <@ '{NULL}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE i <@ '{NULL}' ORDER BY seqno" +== 186 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno" +== 187 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t && '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t && '{AAAAAAAA72908}' ORDER BY seqno" +== 188 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t @> '{AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t @> '{AAAAAAAAAA646}' ORDER BY seqno" +== 189 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t && '{AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t && '{AAAAAAAAAA646}' ORDER BY seqno" +== 190 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t @> '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t @> '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno" +== 191 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t && '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t && '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno" +== 192 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t <@ '{AAAAAAAA72908,AAAAAAAAAAAAAAAAAAA17075,AA88409,AAAAAAAAAAAAAAAAAA36842,AAAAAAA48038,AAAAAAAAAAAAAA10611}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE ... ORDER BY seqno" +== 193 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t = '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t = '{}' ORDER BY seqno" +== 194 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t @> '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t @> '{}' ORDER BY seqno" +== 195 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t && '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t && '{}' ORDER BY seqno" +== 196 +-- truncate_limit: 100 +SELECT * FROM array_op_test WHERE t <@ '{}' ORDER BY seqno +-- +TABLE: name="array_op_test" schema="" table="array_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_op_test WHERE t <@ '{}' ORDER BY seqno" +== 197 +-- truncate_limit: 100 +-- array casts +SELECT ARRAY[1,2,3]::text[]::int[]::float8[] AS "{1,2,3}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, 2, 3]::text[]::int[]::float8[] AS \"{1,2,3}\"" +== 198 +-- truncate_limit: 100 +SELECT pg_typeof(ARRAY[1,2,3]::text[]::int[]::float8[]) AS "double precision[]" +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(ARRAY[1, 2, 3]::text[]::int[]::float8[]) AS \"double precision[]\"" +== 199 +-- truncate_limit: 100 +SELECT ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[] AS "{{a,bc},{def,hijk}}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[ARRAY['a', 'bc'], ARRAY['def', 'hijk']]::text[]::varchar[] AS \"{{a,bc},{def,hijk}}\"" +== 200 +-- truncate_limit: 100 +SELECT pg_typeof(ARRAY[['a','bc'],['def','hijk']]::text[]::varchar[]) AS "character varying[]" +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 201 +-- truncate_limit: 100 +SELECT CAST(ARRAY[[[[[['a','bb','ccc']]]]]] as text[]) as "{{{{{{a,bb,ccc}}}}}}" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[ARRAY[ARRAY[ARRAY[ARRAY[ARRAY['a', 'bb', 'ccc']]]]]]::text[] AS \"{{{{{{a,bb,ccc}}}}}}\"" +== 202 +-- truncate_limit: 100 +SELECT NULL::text[]::int[] AS "NULL" +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::text[]::int[] AS \"NULL\"" +== 203 +-- truncate_limit: 100 +-- scalar op any/all (array) +select 33 = any ('{1,2,3}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ANY('{1,2,3}')" +== 204 +-- truncate_limit: 100 +select 33 = any ('{1,2,33}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ANY('{1,2,33}')" +== 205 +-- truncate_limit: 100 +select 33 = all ('{1,2,33}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ALL('{1,2,33}')" +== 206 +-- truncate_limit: 100 +select 33 >= all ('{1,2,33}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 >= ALL('{1,2,33}')" +== 207 +-- truncate_limit: 100 +-- boundary cases +select null::int >= all ('{1,2,33}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::int >= ALL('{1,2,33}')" +== 208 +-- truncate_limit: 100 +select null::int >= all ('{}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::int >= ALL('{}')" +== 209 +-- truncate_limit: 100 +select null::int >= any ('{}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::int >= ANY('{}')" +== 210 +-- truncate_limit: 100 +-- cross-datatype +select 33.4 = any (array[1,2,3]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33.4 = ANY(ARRAY[1, 2, 3])" +== 211 +-- truncate_limit: 100 +select 33.4 > all (array[1,2,3]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33.4 > ALL(ARRAY[1, 2, 3])" +== 212 +-- truncate_limit: 100 +-- errors +select 33 * any ('{1,2,3}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 * ANY('{1,2,3}')" +== 213 +-- truncate_limit: 100 +select 33 * any (44) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 * ANY(44)" +== 214 +-- truncate_limit: 100 +-- nulls +select 33 = any (null::int[]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ANY(NULL::int[])" +== 215 +-- truncate_limit: 100 +select null::int = any ('{1,2,3}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::int = ANY('{1,2,3}')" +== 216 +-- truncate_limit: 100 +select 33 = any ('{1,null,3}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ANY('{1,null,3}')" +== 217 +-- truncate_limit: 100 +select 33 = any ('{1,null,33}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ANY('{1,null,33}')" +== 218 +-- truncate_limit: 100 +select 33 = all (null::int[]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ALL(NULL::int[])" +== 219 +-- truncate_limit: 100 +select null::int = all ('{1,2,3}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::int = ALL('{1,2,3}')" +== 220 +-- truncate_limit: 100 +select 33 = all ('{1,null,3}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ALL('{1,null,3}')" +== 221 +-- truncate_limit: 100 +select 33 = all ('{33,null,33}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT 33 = ALL('{33,null,33}')" +== 222 +-- truncate_limit: 100 +-- nulls later in the bitmap +SELECT -1 != ALL(ARRAY(SELECT NULLIF(g.i, 900) FROM generate_series(1,1000) g(i))) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT -1 <> ALL(ARRAY(SELECT NULLIF(g.i, 900) FROM generate_series(1, 1000) g(i)))" +== 223 +-- truncate_limit: 100 +-- test indexes on arrays +create temp table arr_tbl (f1 int[] unique) +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE arr_tbl (f1 int[] UNIQUE)" +== 224 +-- truncate_limit: 100 +insert into arr_tbl values ('{1,2,3}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_tbl VALUES ('{1,2,3}')" +== 225 +-- truncate_limit: 100 +insert into arr_tbl values ('{1,2}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_tbl VALUES ('{1,2}')" +== 226 +-- truncate_limit: 100 +-- failure expected: +insert into arr_tbl values ('{1,2,3}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_tbl VALUES ('{1,2,3}')" +== 227 +-- truncate_limit: 100 +insert into arr_tbl values ('{2,3,4}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_tbl VALUES ('{2,3,4}')" +== 228 +-- truncate_limit: 100 +insert into arr_tbl values ('{1,5,3}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_tbl VALUES ('{1,5,3}')" +== 229 +-- truncate_limit: 100 +insert into arr_tbl values ('{1,2,10}') +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_tbl VALUES ('{1,2,10}')" +== 230 +-- truncate_limit: 100 +set enable_seqscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 231 +-- truncate_limit: 100 +set enable_bitmapscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 232 +-- truncate_limit: 100 +select * from arr_tbl where f1 > '{1,2,3}' and f1 <= '{1,5,3}' +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arr_tbl WHERE f1 > '{1,2,3}' AND f1 <= '{1,5,3}'" +== 233 +-- truncate_limit: 100 +select * from arr_tbl where f1 >= '{1,2,3}' and f1 < '{1,5,3}' +-- +TABLE: name="arr_tbl" schema="" table="arr_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM arr_tbl WHERE f1 >= '{1,2,3}' AND f1 < '{1,5,3}'" +== 234 +-- truncate_limit: 100 +-- test ON CONFLICT DO UPDATE with arrays +create temp table arr_pk_tbl (pk int4 primary key, f1 int[]) +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE arr_pk_tbl (pk int4 PRIMARY KEY, f1 int[])" +== 235 +-- truncate_limit: 100 +insert into arr_pk_tbl values (1, '{1,2,3}') +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_pk_tbl VALUES (1, '{1,2,3}')" +== 236 +-- truncate_limit: 100 +insert into arr_pk_tbl values (1, '{3,4,5}') on conflict (pk) + do update set f1[1] = excluded.f1[1], f1[3] = excluded.f1[3] + returning pk, f1 +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_pk_tbl VALUES (...) ON CONFLICT (pk) DO UPDATE SET ... = ... RETURNING pk, f1" +== 237 +-- truncate_limit: 100 +insert into arr_pk_tbl(pk, f1[1:2]) values (1, '{6,7,8}') on conflict (pk) + do update set f1[1] = excluded.f1[1], + f1[2] = excluded.f1[2], + f1[3] = excluded.f1[3] + returning pk, f1 +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_pk_tbl (...) VALUES (...) ON CONFLICT (pk) DO UPDATE SET ... = ... RETURNING pk, f1" +== 238 +-- truncate_limit: 100 +-- note: if above selects don't produce the expected tuple order, +-- then you didn't get an indexscan plan, and something is busted. +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 239 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 240 +-- truncate_limit: 100 +-- test subscript overflow detection + +-- The normal error message includes a platform-dependent limit, +-- so suppress it to avoid needing multiple expected-files. + +insert into arr_pk_tbl values(10, '[-2147483648:-2147483647]={1,2}') +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_pk_tbl VALUES (10, '[-2147483648:-2147483647]={1,2}')" +== 241 +-- truncate_limit: 100 +update arr_pk_tbl set f1[2147483647] = 42 where pk = 10 +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arr_pk_tbl SET f1[2147483647] = 42 WHERE pk = 10" +== 242 +-- truncate_limit: 100 +update arr_pk_tbl set f1[2147483646:2147483647] = array[4,2] where pk = 10 +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE arr_pk_tbl SET f1[2147483646:2147483647] = ARRAY[4, 2] WHERE pk = 10" +== 243 +-- truncate_limit: 100 +insert into arr_pk_tbl(pk, f1[0:2147483647]) values (2, '{}') +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_pk_tbl (pk, f1[0:2147483647]) VALUES (2, '{}')" +== 244 +-- truncate_limit: 100 +insert into arr_pk_tbl(pk, f1[-2147483648:2147483647]) values (2, '{}') +-- +TABLE: name="arr_pk_tbl" schema="" table="arr_pk_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arr_pk_tbl (pk, f1[-2147483648:2147483647]) VALUES (2, '{}')" +== 245 +-- truncate_limit: 100 +-- also exercise the expanded-array case +do $$ declare a int[]; +begin + a := '[-2147483648:-2147483647]={1,2}'::int[]; + a[2147483647] := 42; +end $$ +-- +STMT: DoStmt +TRUNCATED: "DO $$ declare a int[];\nbegin\n a := '[-2147483648:-2147483647]={1,2}'::int[];\n a[2147483647] := ..." +== 246 +-- truncate_limit: 100 +-- test [not] (like|ilike) (any|all) (...) +select 'foo' like any (array['%a', '%o']) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' LIKE ANY(ARRAY['%a', '%o'])" +== 247 +-- truncate_limit: 100 +-- t +select 'foo' like any (array['%a', '%b']) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' LIKE ANY(ARRAY['%a', '%b'])" +== 248 +-- truncate_limit: 100 +-- f +select 'foo' like all (array['f%', '%o']) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' LIKE ALL(ARRAY['f%', '%o'])" +== 249 +-- truncate_limit: 100 +-- t +select 'foo' like all (array['f%', '%b']) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' LIKE ALL(ARRAY['f%', '%b'])" +== 250 +-- truncate_limit: 100 +-- f +select 'foo' not like any (array['%a', '%b']) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' NOT LIKE ANY(ARRAY['%a', '%b'])" +== 251 +-- truncate_limit: 100 +-- t +select 'foo' not like all (array['%a', '%o']) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' NOT LIKE ALL(ARRAY['%a', '%o'])" +== 252 +-- truncate_limit: 100 +-- f +select 'foo' ilike any (array['%A', '%O']) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' ILIKE ANY(ARRAY['%A', '%O'])" +== 253 +-- truncate_limit: 100 +-- t +select 'foo' ilike all (array['F%', '%O']) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' ILIKE ALL(ARRAY['F%', '%O'])" +== 254 +-- truncate_limit: 100 +-- t + +|-- +-- General array parser tests +|-- + +-- none of the following should be accepted +select '{{1,{2}},{2,3}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{1,{2}},{2,3}}'::text[]" +== 255 +-- truncate_limit: 100 +select E'{{1,2},\\{2,3}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{{1,2},\\\\{2,3}}'::text[]" +== 256 +-- truncate_limit: 100 +select '{"a"b}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\"b}'::text[]" +== 257 +-- truncate_limit: 100 +select '{a"b"}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{a\"b\"}'::text[]" +== 258 +-- truncate_limit: 100 +select '{"a""b"}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\"\"b\"}'::text[]" +== 259 +-- truncate_limit: 100 +select '{{"1 2" x},{3}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{\"1 2\" x},{3}}'::text[]" +== 260 +-- truncate_limit: 100 +select '{{"1 2"} x,{3}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{\"1 2\"} x,{3}}'::text[]" +== 261 +-- truncate_limit: 100 +select '{}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}}'::text[]" +== 262 +-- truncate_limit: 100 +select '{ }}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{ }}'::text[]" +== 263 +-- truncate_limit: 100 +select '}{'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '}{'::text[]" +== 264 +-- truncate_limit: 100 +select '{foo{}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{foo{}}'::text[]" +== 265 +-- truncate_limit: 100 +select '{"foo"{}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"foo\"{}}'::text[]" +== 266 +-- truncate_limit: 100 +select '{foo,,bar}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{foo,,bar}'::text[]" +== 267 +-- truncate_limit: 100 +select '{{1},{{2}}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{1},{{2}}}'::text[]" +== 268 +-- truncate_limit: 100 +select '{{{1}},{2}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{{1}},{2}}'::text[]" +== 269 +-- truncate_limit: 100 +select '{{},{{}}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{},{{}}}'::text[]" +== 270 +-- truncate_limit: 100 +select '{{{}},{}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{{}},{}}'::text[]" +== 271 +-- truncate_limit: 100 +select '{{1},{}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{1},{}}'::text[]" +== 272 +-- truncate_limit: 100 +select '{{},{1}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{},{1}}'::text[]" +== 273 +-- truncate_limit: 100 +select '[1:0]={}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1:0]={}'::int[]" +== 274 +-- truncate_limit: 100 +select '[2147483646:2147483647]={1,2}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[2147483646:2147483647]={1,2}'::int[]" +== 275 +-- truncate_limit: 100 +select '[1:-1]={}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1:-1]={}'::int[]" +== 276 +-- truncate_limit: 100 +select '[2]={1}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[2]={1}'::int[]" +== 277 +-- truncate_limit: 100 +select '[1:]={1}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1:]={1}'::int[]" +== 278 +-- truncate_limit: 100 +select '[:1]={1}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[:1]={1}'::int[]" +== 279 +-- truncate_limit: 100 +select array[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[]" +== 280 +-- truncate_limit: 100 +select '{{1,},{1},}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{1,},{1},}'::text[]" +== 281 +-- truncate_limit: 100 +select '{{1,},{1}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{1,},{1}}'::text[]" +== 282 +-- truncate_limit: 100 +select '{{1,}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{1,}}'::text[]" +== 283 +-- truncate_limit: 100 +select '{1,}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{1,}'::text[]" +== 284 +-- truncate_limit: 100 +select '[21474836488:21474836489]={1,2}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[21474836488:21474836489]={1,2}'::int[]" +== 285 +-- truncate_limit: 100 +select '[-2147483649:-2147483648]={1,2}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[-2147483649:-2147483648]={1,2}'::int[]" +== 286 +-- truncate_limit: 100 +-- none of the above should be accepted + +-- all of the following should be accepted +select '{}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::text[]" +== 287 +-- truncate_limit: 100 +select '{{},{}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{},{}}'::text[]" +== 288 +-- truncate_limit: 100 +select '{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{{{1,2,3,4},{2,3,4,5}},{{3,4,5,6},{4,5,6,7}}}'::text[]" +== 289 +-- truncate_limit: 100 +select '{null,n\ull,"null"}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{null,n\\\\ull,\"null\"}'::text[]" +== 290 +-- truncate_limit: 100 +select '{ ab\c , "ab\"c" }'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ ab\\\\c , \"ab\\\\\"c\" }'::text[]" +== 291 +-- truncate_limit: 100 +select '{0 second ,0 second}'::interval[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{0 second ,0 second}'::interval[]" +== 292 +-- truncate_limit: 100 +select '{ { "," } , { 3 } }'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{ { \",\" } , { 3 } }'::text[]" +== 293 +-- truncate_limit: 100 +select ' { { " 0 second " , 0 second } }'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' { { \" 0 second \" , 0 second } }'::text[]" +== 294 +-- truncate_limit: 100 +select '{ + 0 second, + @ 1 hour @ 42 minutes @ 20 seconds + }'::interval[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\n 0 second,\n @ 1 hour @ 42 minutes @ 20 seconds\n }'::interval[]" +== 295 +-- truncate_limit: 100 +select array[]::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[]::text[]" +== 296 +-- truncate_limit: 100 +select '[2]={1,7}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[2]={1,7}'::int[]" +== 297 +-- truncate_limit: 100 +select '[0:1]={1.1,2.2}'::float8[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[0:1]={1.1,2.2}'::float8[]" +== 298 +-- truncate_limit: 100 +select '[2147483646:2147483646]={1}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[2147483646:2147483646]={1}'::int[]" +== 299 +-- truncate_limit: 100 +select '[-2147483648:-2147483647]={1,2}'::int[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[-2147483648:-2147483647]={1,2}'::int[]" +== 300 +-- truncate_limit: 100 +-- all of the above should be accepted + +-- tests for array aggregates +CREATE TEMP TABLE arraggtest ( f1 INT[], f2 TEXT[][], f3 FLOAT[]) +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE arraggtest (f1 int[], f2 text[][], f3 double precision[])" +== 301 +-- truncate_limit: 100 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{1,2,3,4}','{{grey,red},{blue,blue}}','{1.6, 0.0}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arraggtest (f1, f2, f3) VALUES ('{1,2,3,4}', '{{grey,red},{blue,blue}}', '{1.6, 0.0}')" +== 302 +-- truncate_limit: 100 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{1,2,3}','{{grey,red},{grey,blue}}','{1.6}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arraggtest (f1, f2, f3) VALUES ('{1,2,3}', '{{grey,red},{grey,blue}}', '{1.6}')" +== 303 +-- truncate_limit: 100 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest" +== 304 +-- truncate_limit: 100 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{3,3,2,4,5,6}','{{white,yellow},{pink,orange}}','{2.1,3.3,1.8,1.7,1.6}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arraggtest (f1, f2, f3) VALUES (...)" +== 305 +-- truncate_limit: 100 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest" +== 306 +-- truncate_limit: 100 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{2}','{{black,red},{green,orange}}','{1.6,2.2,2.6,0.4}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arraggtest (f1, f2, f3) VALUES (...)" +== 307 +-- truncate_limit: 100 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest" +== 308 +-- truncate_limit: 100 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{4,2,6,7,8,1}','{{red},{black},{purple},{blue},{blue}}',NULL) +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arraggtest (f1, f2, f3) VALUES (...)" +== 309 +-- truncate_limit: 100 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest" +== 310 +-- truncate_limit: 100 +INSERT INTO arraggtest (f1, f2, f3) VALUES +('{}','{{pink,white,blue,red,grey,orange}}','{2.1,1.87,1.4,2.2}') +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO arraggtest (f1, f2, f3) VALUES (...)" +== 311 +-- truncate_limit: 100 +SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest +-- +TABLE: name="arraggtest" schema="" table="arraggtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(f1), min(f1), max(f2), min(f2), max(f3), min(f3) FROM arraggtest" +== 312 +-- truncate_limit: 100 +-- A few simple tests for arrays of composite types + +create type comptype as (f1 int, f2 text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE comptype AS (f1 int, f2 text)" +== 313 +-- truncate_limit: 100 +create table comptable (c1 comptype, c2 comptype[]) +-- +TABLE: name="comptable" schema="" table="comptable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE comptable (c1 comptype, c2 comptype[])" +== 314 +-- truncate_limit: 100 +-- XXX would like to not have to specify row() construct types here ... +insert into comptable + values (row(1,'foo'), array[row(2,'bar')::comptype, row(3,'baz')::comptype]) +-- +TABLE: name="comptable" schema="" table="comptable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO comptable VALUES (...)" +== 315 +-- truncate_limit: 100 +-- check that implicitly named array type _comptype isn't a problem +create type _comptype as enum('fooey') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE _comptype AS ENUM ('fooey')" +== 316 +-- truncate_limit: 100 +select * from comptable +-- +TABLE: name="comptable" schema="" table="comptable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM comptable" +== 317 +-- truncate_limit: 100 +select c2[2].f2 from comptable +-- +TABLE: name="comptable" schema="" table="comptable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT c2[2].f2 FROM comptable" +== 318 +-- truncate_limit: 100 +drop type _comptype +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE _comptype" +== 319 +-- truncate_limit: 100 +drop table comptable +-- +TABLE: name="comptable" schema="" table="comptable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE comptable" +== 320 +-- truncate_limit: 100 +drop type comptype +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE comptype" +== 321 +-- truncate_limit: 100 +create or replace function unnest1(anyarray) +returns setof anyelement as $$ +select $1[s] from generate_subscripts($1,1) g(s); +$$ language sql immutable +-- +FUNCTION: name="unnest1" function="unnest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION unnest1(anyarray) RETURNS SETOF anyelement AS $$\nselect $1[s] from gen..." +== 322 +-- truncate_limit: 100 +create or replace function unnest2(anyarray) +returns setof anyelement as $$ +select $1[s1][s2] from generate_subscripts($1,1) g1(s1), + generate_subscripts($1,2) g2(s2); +$$ language sql immutable +-- +FUNCTION: name="unnest2" function="unnest2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION unnest2(anyarray) RETURNS SETOF anyelement AS $$\nselect $1[s1][s2] fro..." +== 323 +-- truncate_limit: 100 +select * from unnest1(array[1,2,3]) +-- +FUNCTION: name="unnest1" function="unnest1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest1(ARRAY[1, 2, 3])" +== 324 +-- truncate_limit: 100 +select * from unnest2(array[[1,2,3],[4,5,6]]) +-- +FUNCTION: name="unnest2" function="unnest2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest2(ARRAY[ARRAY[1, 2, 3], ARRAY[4, 5, 6]])" +== 325 +-- truncate_limit: 100 +drop function unnest1(anyarray) +-- +FUNCTION: name="unnest1" function="unnest1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION unnest1(anyarray)" +== 326 +-- truncate_limit: 100 +drop function unnest2(anyarray) +-- +FUNCTION: name="unnest2" function="unnest2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION unnest2(anyarray)" +== 327 +-- truncate_limit: 100 +select array_fill(null::integer, array[3,3],array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(NULL::int, ARRAY[3, 3], ARRAY[2, 2])" +== 328 +-- truncate_limit: 100 +select array_fill(null::integer, array[3,3]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(NULL::int, ARRAY[3, 3])" +== 329 +-- truncate_limit: 100 +select array_fill(null::text, array[3,3],array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(NULL::text, ARRAY[3, 3], ARRAY[2, 2])" +== 330 +-- truncate_limit: 100 +select array_fill(null::text, array[3,3]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(NULL::text, ARRAY[3, 3])" +== 331 +-- truncate_limit: 100 +select array_fill(7, array[3,3],array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(7, ARRAY[3, 3], ARRAY[2, 2])" +== 332 +-- truncate_limit: 100 +select array_fill(7, array[3,3]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(7, ARRAY[3, 3])" +== 333 +-- truncate_limit: 100 +select array_fill('juhu'::text, array[3,3],array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill('juhu'::text, ARRAY[3, 3], ARRAY[2, 2])" +== 334 +-- truncate_limit: 100 +select array_fill('juhu'::text, array[3,3]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill('juhu'::text, ARRAY[3, 3])" +== 335 +-- truncate_limit: 100 +select a, a = '{}' as is_eq, array_dims(a) + from (select array_fill(42, array[0]) as a) ss +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, a = '{}' AS is_eq, array_dims(a) FROM (SELECT array_fill(42, ARRAY[0]) AS a) ss" +== 336 +-- truncate_limit: 100 +select a, a = '{}' as is_eq, array_dims(a) + from (select array_fill(42, '{}') as a) ss +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, a = '{}' AS is_eq, array_dims(a) FROM (SELECT array_fill(42, '{}') AS a) ss" +== 337 +-- truncate_limit: 100 +select a, a = '{}' as is_eq, array_dims(a) + from (select array_fill(42, '{}', '{}') as a) ss +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, a = '{}' AS is_eq, array_dims(a) FROM (SELECT array_fill(42, '{}', '{}') AS a) ss" +== 338 +-- truncate_limit: 100 +-- raise exception +select array_fill(1, null, array[2,2]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(1, NULL, ARRAY[2, 2])" +== 339 +-- truncate_limit: 100 +select array_fill(1, array[2,2], null) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(1, ARRAY[2, 2], NULL)" +== 340 +-- truncate_limit: 100 +select array_fill(1, array[2,2], '{}') +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(1, ARRAY[2, 2], '{}')" +== 341 +-- truncate_limit: 100 +select array_fill(1, array[3,3], array[1,1,1]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(1, ARRAY[3, 3], ARRAY[1, 1, 1])" +== 342 +-- truncate_limit: 100 +select array_fill(1, array[1,2,null]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(1, ARRAY[1, 2, NULL])" +== 343 +-- truncate_limit: 100 +select array_fill(1, array[[1,2],[3,4]]) +-- +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_fill(1, ARRAY[ARRAY[1, 2], ARRAY[3, 4]])" +== 344 +-- truncate_limit: 100 +select string_to_array('1|2|3', '|') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('1|2|3', '|')" +== 345 +-- truncate_limit: 100 +select string_to_array('1|2|3|', '|') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('1|2|3|', '|')" +== 346 +-- truncate_limit: 100 +select string_to_array('1||2|3||', '||') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('1||2|3||', '||')" +== 347 +-- truncate_limit: 100 +select string_to_array('1|2|3', '') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('1|2|3', '')" +== 348 +-- truncate_limit: 100 +select string_to_array('', '|') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('', '|')" +== 349 +-- truncate_limit: 100 +select string_to_array('1|2|3', NULL) +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('1|2|3', NULL)" +== 350 +-- truncate_limit: 100 +select string_to_array(NULL, '|') IS NULL +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array(NULL, '|') IS NULL" +== 351 +-- truncate_limit: 100 +select string_to_array('abc', '') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('abc', '')" +== 352 +-- truncate_limit: 100 +select string_to_array('abc', '', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('abc', '', 'abc')" +== 353 +-- truncate_limit: 100 +select string_to_array('abc', ',') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('abc', ',')" +== 354 +-- truncate_limit: 100 +select string_to_array('abc', ',', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('abc', ',', 'abc')" +== 355 +-- truncate_limit: 100 +select string_to_array('1,2,3,4,,6', ',') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('1,2,3,4,,6', ',')" +== 356 +-- truncate_limit: 100 +select string_to_array('1,2,3,4,,6', ',', '') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('1,2,3,4,,6', ',', '')" +== 357 +-- truncate_limit: 100 +select string_to_array('1,2,3,4,*,6', ',', '*') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('1,2,3,4,*,6', ',', '*')" +== 358 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('1|2|3', '|') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('1|2|3', '|') g(v)" +== 359 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('1|2|3|', '|') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('1|2|3|', '|') g(v)" +== 360 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('1||2|3||', '||') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('1||2|3||', '||') g(v)" +== 361 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('1|2|3', '') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('1|2|3', '') g(v)" +== 362 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('', '|') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('', '|') g(v)" +== 363 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('1|2|3', NULL) g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('1|2|3', NULL) g(v)" +== 364 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table(NULL, '|') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table(NULL, '|') g(v)" +== 365 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('abc', '') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('abc', '') g(v)" +== 366 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('abc', '', 'abc') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('abc', '', 'abc') g(v)" +== 367 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('abc', ',') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('abc', ',') g(v)" +== 368 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('abc', ',', 'abc') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('abc', ',', 'abc') g(v)" +== 369 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('1,2,3,4,,6', ',') g(v)" +== 370 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('1,2,3,4,,6', ',', '') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('1,2,3,4,,6', ',', '') g(v)" +== 371 +-- truncate_limit: 100 +select v, v is null as "is null" from string_to_table('1,2,3,4,*,6', ',', '*') g(v) +-- +FUNCTION: name="string_to_table" function="string_to_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, v IS NULL AS \"is null\" FROM string_to_table('1,2,3,4,*,6', ',', '*') g(v)" +== 372 +-- truncate_limit: 100 +select array_to_string(NULL::int4[], ',') IS NULL +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_string(NULL::int4[], ',') IS NULL" +== 373 +-- truncate_limit: 100 +select array_to_string('{}'::int4[], ',') +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_string('{}'::int4[], ',')" +== 374 +-- truncate_limit: 100 +select array_to_string(array[1,2,3,4,NULL,6], ',') +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_string(ARRAY[1, 2, 3, 4, NULL, 6], ',')" +== 375 +-- truncate_limit: 100 +select array_to_string(array[1,2,3,4,NULL,6], ',', '*') +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_string(ARRAY[1, 2, 3, 4, NULL, 6], ',', '*')" +== 376 +-- truncate_limit: 100 +select array_to_string(array[1,2,3,4,NULL,6], NULL) +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_string(ARRAY[1, 2, 3, 4, NULL, 6], NULL)" +== 377 +-- truncate_limit: 100 +select array_to_string(array[1,2,3,4,NULL,6], ',', NULL) +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_string(ARRAY[1, 2, 3, 4, NULL, 6], ',', NULL)" +== 378 +-- truncate_limit: 100 +select array_to_string(string_to_array('1|2|3', '|'), '|') +-- +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_string(string_to_array('1|2|3', '|'), '|')" +== 379 +-- truncate_limit: 100 +select array_length(array[1,2,3], 1) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_length(ARRAY[1, 2, 3], 1)" +== 380 +-- truncate_limit: 100 +select array_length(array[[1,2,3], [4,5,6]], 0) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_length(ARRAY[ARRAY[1, 2, 3], ARRAY[4, 5, 6]], 0)" +== 381 +-- truncate_limit: 100 +select array_length(array[[1,2,3], [4,5,6]], 1) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_length(ARRAY[ARRAY[1, 2, 3], ARRAY[4, 5, 6]], 1)" +== 382 +-- truncate_limit: 100 +select array_length(array[[1,2,3], [4,5,6]], 2) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_length(ARRAY[ARRAY[1, 2, 3], ARRAY[4, 5, 6]], 2)" +== 383 +-- truncate_limit: 100 +select array_length(array[[1,2,3], [4,5,6]], 3) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_length(ARRAY[ARRAY[1, 2, 3], ARRAY[4, 5, 6]], 3)" +== 384 +-- truncate_limit: 100 +select cardinality(NULL::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cardinality(NULL::int[])" +== 385 +-- truncate_limit: 100 +select cardinality('{}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cardinality('{}'::int[])" +== 386 +-- truncate_limit: 100 +select cardinality(array[1,2,3]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cardinality(ARRAY[1, 2, 3])" +== 387 +-- truncate_limit: 100 +select cardinality('[2:4]={5,6,7}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cardinality('[2:4]={5,6,7}'::int[])" +== 388 +-- truncate_limit: 100 +select cardinality('{{1,2}}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cardinality('{{1,2}}'::int[])" +== 389 +-- truncate_limit: 100 +select cardinality('{{1,2},{3,4},{5,6}}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cardinality('{{1,2},{3,4},{5,6}}'::int[])" +== 390 +-- truncate_limit: 100 +select cardinality('{{{1,9},{5,6}},{{2,3},{3,4}}}'::int[]) +-- +FUNCTION: name="cardinality" function="cardinality" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cardinality('{{{1,9},{5,6}},{{2,3},{3,4}}}'::int[])" +== 391 +-- truncate_limit: 100 +-- array_agg(anynonarray) +select array_agg(unique1) from (select unique1 from tenk1 where unique1 < 15 order by unique1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(unique1) FROM (SELECT unique1 FROM tenk1 WHERE unique1 < 15 ORDER BY unique1) ss" +== 392 +-- truncate_limit: 100 +select array_agg(ten) from (select ten from tenk1 where unique1 < 15 order by unique1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(ten) FROM (SELECT ten FROM tenk1 WHERE unique1 < 15 ORDER BY unique1) ss" +== 393 +-- truncate_limit: 100 +select array_agg(nullif(ten, 4)) from (select ten from tenk1 where unique1 < 15 order by unique1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(NULLIF(ten, 4)) FROM (SELECT ten FROM tenk1 WHERE unique1 < 15 ORDER BY unique1) ss" +== 394 +-- truncate_limit: 100 +select array_agg(unique1) from tenk1 where unique1 < -15 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(unique1) FROM tenk1 WHERE unique1 < -15" +== 395 +-- truncate_limit: 100 +-- array_agg(anyarray) +select array_agg(ar) + from (values ('{1,2}'::int[]), ('{3,4}'::int[])) v(ar) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(ar) FROM (VALUES ('{1,2}'::int[]), ('{3,4}'::int[])) v(ar)" +== 396 +-- truncate_limit: 100 +select array_agg(distinct ar order by ar desc) + from (select array[i / 2] from generate_series(1,10) a(i)) b(ar) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 10) a(i)) b(ar)" +== 397 +-- truncate_limit: 100 +select array_agg(ar) + from (select array_agg(array[i, i+1, i-1]) + from generate_series(1,2) a(i)) b(ar) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(ar) FROM (SELECT ... FROM generate_series(1, 2) a(i)) b(ar)" +== 398 +-- truncate_limit: 100 +select array_agg(array[i+1.2, i+1.3, i+1.4]) from generate_series(1,3) g(i) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(ARRAY[i + 1.2, i + 1.3, i + 1.4]) FROM generate_series(1, 3) g(i)" +== 399 +-- truncate_limit: 100 +select array_agg(array['Hello', i::text]) from generate_series(9,11) g(i) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(ARRAY['Hello', i::text]) FROM generate_series(9, 11) g(i)" +== 400 +-- truncate_limit: 100 +select array_agg(array[i, nullif(i, 3), i+1]) from generate_series(1,4) g(i) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(ARRAY[i, NULLIF(i, 3), i + 1]) FROM generate_series(1, 4) g(i)" +== 401 +-- truncate_limit: 100 +-- errors +select array_agg('{}'::int[]) from generate_series(1,2) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg('{}'::int[]) FROM generate_series(1, 2)" +== 402 +-- truncate_limit: 100 +select array_agg(null::int[]) from generate_series(1,2) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(NULL::int[]) FROM generate_series(1, 2)" +== 403 +-- truncate_limit: 100 +select array_agg(ar) + from (values ('{1,2}'::int[]), ('{3}'::int[])) v(ar) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(ar) FROM (VALUES ('{1,2}'::int[]), ('{3}'::int[])) v(ar)" +== 404 +-- truncate_limit: 100 +select unnest(array[1,2,3]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY[1, 2, 3])" +== 405 +-- truncate_limit: 100 +select * from unnest(array[1,2,3]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest(ARRAY[1, 2, 3])" +== 406 +-- truncate_limit: 100 +select unnest(array[1,2,3,4.5]::float8[]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY[1, 2, 3, 4.5]::float8[])" +== 407 +-- truncate_limit: 100 +select unnest(array[1,2,3,4.5]::numeric[]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY[1, 2, 3, 4.5]::numeric[])" +== 408 +-- truncate_limit: 100 +select unnest(array[1,2,3,null,4,null,null,5,6]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY[1, 2, 3, NULL, 4, NULL, NULL, 5, 6])" +== 409 +-- truncate_limit: 100 +select unnest(array[1,2,3,null,4,null,null,5,6]::text[]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY[1, 2, 3, NULL, 4, NULL, NULL, 5, 6]::text[])" +== 410 +-- truncate_limit: 100 +select abs(unnest(array[1,2,null,-3])) +-- +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT abs(unnest(ARRAY[1, 2, NULL, -3]))" +== 411 +-- truncate_limit: 100 +select array_remove(array[1,2,2,3], 2) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_remove(ARRAY[1, 2, 2, 3], 2)" +== 412 +-- truncate_limit: 100 +select array_remove(array[1,2,2,3], 5) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_remove(ARRAY[1, 2, 2, 3], 5)" +== 413 +-- truncate_limit: 100 +select array_remove(array[1,NULL,NULL,3], NULL) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_remove(ARRAY[1, NULL, NULL, 3], NULL)" +== 414 +-- truncate_limit: 100 +select array_remove(array['A','CC','D','C','RR'], 'RR') +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_remove(ARRAY['A', 'CC', 'D', 'C', 'RR'], 'RR')" +== 415 +-- truncate_limit: 100 +select array_remove(array[1.0, 2.1, 3.3], 1) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_remove(ARRAY[1.0, 2.1, 3.3], 1)" +== 416 +-- truncate_limit: 100 +select array_remove('{{1,2,2},{1,4,3}}', 2) +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_remove('{{1,2,2},{1,4,3}}', 2)" +== 417 +-- truncate_limit: 100 +-- not allowed +select array_remove(array['X','X','X'], 'X') = '{}' +-- +FUNCTION: name="array_remove" function="array_remove" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_remove(ARRAY['X', 'X', 'X'], 'X') = '{}'" +== 418 +-- truncate_limit: 100 +select array_replace(array[1,2,5,4],5,3) +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_replace(ARRAY[1, 2, 5, 4], 5, 3)" +== 419 +-- truncate_limit: 100 +select array_replace(array[1,2,5,4],5,NULL) +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_replace(ARRAY[1, 2, 5, 4], 5, NULL)" +== 420 +-- truncate_limit: 100 +select array_replace(array[1,2,NULL,4,NULL],NULL,5) +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_replace(ARRAY[1, 2, NULL, 4, NULL], NULL, 5)" +== 421 +-- truncate_limit: 100 +select array_replace(array['A','B','DD','B'],'B','CC') +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_replace(ARRAY['A', 'B', 'DD', 'B'], 'B', 'CC')" +== 422 +-- truncate_limit: 100 +select array_replace(array[1,NULL,3],NULL,NULL) +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_replace(ARRAY[1, NULL, 3], NULL, NULL)" +== 423 +-- truncate_limit: 100 +select array_replace(array['AB',NULL,'CDE'],NULL,'12') +-- +FUNCTION: name="array_replace" function="array_replace" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_replace(ARRAY['AB', NULL, 'CDE'], NULL, '12')" +== 424 +-- truncate_limit: 100 +-- array(select array-value ...) +select array(select array[i,i/2] from generate_series(1,5) i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY(SELECT ARRAY[i, i / 2] FROM generate_series(1, 5) i)" +== 425 +-- truncate_limit: 100 +select array(select array['Hello', i::text] from generate_series(9,11) i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY(SELECT ARRAY['Hello', i::text] FROM generate_series(9, 11) i)" +== 426 +-- truncate_limit: 100 +-- int2vector and oidvector should be treated as scalar types for this purpose +select pg_typeof(array(select '11 22 33'::int2vector from generate_series(1,5))) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(ARRAY(SELECT '11 22 33'::int2vector FROM generate_series(1, 5)))" +== 427 +-- truncate_limit: 100 +select array(select '11 22 33'::int2vector from generate_series(1,5)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY(SELECT '11 22 33'::int2vector FROM generate_series(1, 5))" +== 428 +-- truncate_limit: 100 +select unnest(array(select '11 22 33'::int2vector from generate_series(1,5))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY(SELECT '11 22 33'::int2vector FROM generate_series(1, 5)))" +== 429 +-- truncate_limit: 100 +select pg_typeof(array(select '11 22 33'::oidvector from generate_series(1,5))) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(ARRAY(SELECT '11 22 33'::oidvector FROM generate_series(1, 5)))" +== 430 +-- truncate_limit: 100 +select array(select '11 22 33'::oidvector from generate_series(1,5)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY(SELECT '11 22 33'::oidvector FROM generate_series(1, 5))" +== 431 +-- truncate_limit: 100 +select unnest(array(select '11 22 33'::oidvector from generate_series(1,5))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY(SELECT '11 22 33'::oidvector FROM generate_series(1, 5)))" +== 432 +-- truncate_limit: 100 +-- array[] should do the same +select pg_typeof(array['11 22 33'::int2vector]) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(ARRAY['11 22 33'::int2vector])" +== 433 +-- truncate_limit: 100 +select array['11 22 33'::int2vector] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY['11 22 33'::int2vector]" +== 434 +-- truncate_limit: 100 +select pg_typeof(unnest(array['11 22 33'::int2vector])) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(unnest(ARRAY['11 22 33'::int2vector]))" +== 435 +-- truncate_limit: 100 +select unnest(array['11 22 33'::int2vector]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY['11 22 33'::int2vector])" +== 436 +-- truncate_limit: 100 +select pg_typeof(unnest('11 22 33'::int2vector)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(unnest('11 22 33'::int2vector))" +== 437 +-- truncate_limit: 100 +select unnest('11 22 33'::int2vector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest('11 22 33'::int2vector)" +== 438 +-- truncate_limit: 100 +select pg_typeof(array['11 22 33'::oidvector]) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(ARRAY['11 22 33'::oidvector])" +== 439 +-- truncate_limit: 100 +select array['11 22 33'::oidvector] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY['11 22 33'::oidvector]" +== 440 +-- truncate_limit: 100 +select pg_typeof(unnest(array['11 22 33'::oidvector])) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(unnest(ARRAY['11 22 33'::oidvector]))" +== 441 +-- truncate_limit: 100 +select unnest(array['11 22 33'::oidvector]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY['11 22 33'::oidvector])" +== 442 +-- truncate_limit: 100 +select pg_typeof(unnest('11 22 33'::oidvector)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(unnest('11 22 33'::oidvector))" +== 443 +-- truncate_limit: 100 +select unnest('11 22 33'::oidvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest('11 22 33'::oidvector)" +== 444 +-- truncate_limit: 100 +-- Insert/update on a column that is array of composite + +create temp table t1 (f1 int8_tbl[]) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (f1 int8_tbl[])" +== 445 +-- truncate_limit: 100 +insert into t1 (f1[5].q1) values(42) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 (f1[5].q1) VALUES (42)" +== 446 +-- truncate_limit: 100 +select * from t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 447 +-- truncate_limit: 100 +update t1 set f1[5].q2 = 43 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t1 SET f1[5].q2 = 43" +== 448 +-- truncate_limit: 100 +select * from t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 449 +-- truncate_limit: 100 +-- Check that arrays of composites are safely detoasted when needed + +create temp table src (f1 text) +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE src (f1 text)" +== 450 +-- truncate_limit: 100 +insert into src + select string_agg(random()::text,'') from generate_series(1,10000) +-- +TABLE: name="src" schema="" table="src" ctx=DML +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO src SELECT string_agg(random()::text, '') FROM generate_series(1, 10000)" +== 451 +-- truncate_limit: 100 +create type textandtext as (c1 text, c2 text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE textandtext AS (c1 text, c2 text)" +== 452 +-- truncate_limit: 100 +create temp table dest (f1 textandtext[]) +-- +TABLE: name="dest" schema="" table="dest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE dest (f1 textandtext[])" +== 453 +-- truncate_limit: 100 +insert into dest select array[row(f1,f1)::textandtext] from src +-- +TABLE: name="dest" schema="" table="dest" ctx=DML +TABLE: name="src" schema="" table="src" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dest SELECT ARRAY[ROW(f1, f1)::textandtext] FROM src" +== 454 +-- truncate_limit: 100 +select length(fipshash((f1[1]).c2)) from dest +-- +TABLE: name="dest" schema="" table="dest" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(fipshash((f1[1]).c2)) FROM dest" +== 455 +-- truncate_limit: 100 +delete from src +-- +TABLE: name="src" schema="" table="src" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM src" +== 456 +-- truncate_limit: 100 +select length(fipshash((f1[1]).c2)) from dest +-- +TABLE: name="dest" schema="" table="dest" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(fipshash((f1[1]).c2)) FROM dest" +== 457 +-- truncate_limit: 100 +truncate table src +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE src" +== 458 +-- truncate_limit: 100 +drop table src +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE src" +== 459 +-- truncate_limit: 100 +select length(fipshash((f1[1]).c2)) from dest +-- +TABLE: name="dest" schema="" table="dest" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(fipshash((f1[1]).c2)) FROM dest" +== 460 +-- truncate_limit: 100 +drop table dest +-- +TABLE: name="dest" schema="" table="dest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE dest" +== 461 +-- truncate_limit: 100 +drop type textandtext +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textandtext" +== 462 +-- truncate_limit: 100 +-- Tests for polymorphic-array form of width_bucket() + +-- this exercises the varwidth and float8 code paths +SELECT + op, + width_bucket(op::numeric, ARRAY[1, 3, 5, 10.0]::numeric[]) AS wb_n1, + width_bucket(op::numeric, ARRAY[0, 5.5, 9.99]::numeric[]) AS wb_n2, + width_bucket(op::numeric, ARRAY[-6, -5, 2.0]::numeric[]) AS wb_n3, + width_bucket(op::float8, ARRAY[1, 3, 5, 10.0]::float8[]) AS wb_f1, + width_bucket(op::float8, ARRAY[0, 5.5, 9.99]::float8[]) AS wb_f2, + width_bucket(op::float8, ARRAY[-6, -5, 2.0]::float8[]) AS wb_f3 +FROM (VALUES + (-5.2), + (-0.0000000001), + (0.000000000001), + (1), + (1.99999999999999), + (2), + (2.00000000000001), + (3), + (4), + (4.5), + (5), + (5.5), + (6), + (7), + (8), + (9), + (9.99999999999999), + (10), + (10.0000000000001) +) v(op) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(op)" +== 463 +-- truncate_limit: 100 +-- ensure float8 path handles NaN properly +SELECT + op, + width_bucket(op, ARRAY[1, 3, 9, 'NaN', 'NaN']::float8[]) AS wb +FROM (VALUES + (-5.2::float8), + (4::float8), + (77::float8), + ('NaN'::float8) +) v(op) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT op, width_bucket(op, ARRAY[1, 3, 9, 'NaN', 'NaN']::float8[]) AS wb FROM (VALUES (...)) v(op)" +== 464 +-- truncate_limit: 100 +-- these exercise the generic fixed-width code path +SELECT + op, + width_bucket(op, ARRAY[1, 3, 5, 10]) AS wb_1 +FROM generate_series(0,11) as op +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT op, width_bucket(op, ARRAY[1, 3, 5, 10]) AS wb_1 FROM generate_series(0, 11) op" +== 465 +-- truncate_limit: 100 +SELECT width_bucket(now(), + array['yesterday', 'today', 'tomorrow']::timestamptz[]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(now(), ARRAY['yesterday', 'today', 'tomorrow']::timestamptz[])" +== 466 +-- truncate_limit: 100 +-- corner cases +SELECT width_bucket(5, ARRAY[3]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(5, ARRAY[3])" +== 467 +-- truncate_limit: 100 +SELECT width_bucket(5, '{}') +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(5, '{}')" +== 468 +-- truncate_limit: 100 +-- error cases +SELECT width_bucket('5'::text, ARRAY[3, 4]::integer[]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket('5'::text, ARRAY[3, 4]::int[])" +== 469 +-- truncate_limit: 100 +SELECT width_bucket(5, ARRAY[3, 4, NULL]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(5, ARRAY[3, 4, NULL])" +== 470 +-- truncate_limit: 100 +SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]]) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(5, ARRAY[ARRAY[1, 2], ARRAY[3, 4]])" +== 471 +-- truncate_limit: 100 +-- trim_array + +SELECT arr, trim_array(arr, 2) +FROM +(VALUES ('{1,2,3,4,5,6}'::bigint[]), + ('{1,2}'), + ('[10:16]={1,2,3,4,5,6,7}'), + ('[-15:-10]={1,2,3,4,5,6}'), + ('{{1,10},{2,20},{3,30},{4,40}}')) v(arr) +-- +FUNCTION: name="trim_array" function="trim_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT arr, trim_array(arr, 2) FROM (VALUES (...)) v(arr)" +== 472 +-- truncate_limit: 100 +SELECT trim_array(ARRAY[1, 2, 3], -1) +-- +FUNCTION: name="trim_array" function="trim_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_array(ARRAY[1, 2, 3], -1)" +== 473 +-- truncate_limit: 100 +-- fail +SELECT trim_array(ARRAY[1, 2, 3], 10) +-- +FUNCTION: name="trim_array" function="trim_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_array(ARRAY[1, 2, 3], 10)" +== 474 +-- truncate_limit: 100 +-- fail +SELECT trim_array(ARRAY[]::int[], 1) +-- +FUNCTION: name="trim_array" function="trim_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_array(ARRAY[]::int[], 1)" +== 475 +-- truncate_limit: 100 +-- fail + +-- array_shuffle +SELECT array_shuffle('{1,2,3,4,5,6}'::int[]) <@ '{1,2,3,4,5,6}' +-- +FUNCTION: name="array_shuffle" function="array_shuffle" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_shuffle('{1,2,3,4,5,6}'::int[]) <@ '{1,2,3,4,5,6}'" +== 476 +-- truncate_limit: 100 +SELECT array_shuffle('{1,2,3,4,5,6}'::int[]) @> '{1,2,3,4,5,6}' +-- +FUNCTION: name="array_shuffle" function="array_shuffle" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_shuffle('{1,2,3,4,5,6}'::int[]) @> '{1,2,3,4,5,6}'" +== 477 +-- truncate_limit: 100 +SELECT array_dims(array_shuffle('[-1:2][2:3]={{1,2},{3,NULL},{5,6},{7,8}}'::int[])) +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_shuffle" function="array_shuffle" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_dims(array_shuffle('[-1:2][2:3]={{1,2},{3,NULL},{5,6},{7,8}}'::int[]))" +== 478 +-- truncate_limit: 100 +SELECT array_dims(array_shuffle('{{{1,2},{3,NULL}},{{5,6},{7,8}},{{9,10},{11,12}}}'::int[])) +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_shuffle" function="array_shuffle" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_dims(array_shuffle('{{{1,2},{3,NULL}},{{5,6},{7,8}},{{9,10},{11,12}}}'::int[]))" +== 479 +-- truncate_limit: 100 +-- array_sample +SELECT array_sample('{1,2,3,4,5,6}'::int[], 3) <@ '{1,2,3,4,5,6}' +-- +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_sample('{1,2,3,4,5,6}'::int[], 3) <@ '{1,2,3,4,5,6}'" +== 480 +-- truncate_limit: 100 +SELECT array_length(array_sample('{1,2,3,4,5,6}'::int[], 3), 1) +-- +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_length(array_sample('{1,2,3,4,5,6}'::int[], 3), 1)" +== 481 +-- truncate_limit: 100 +SELECT array_dims(array_sample('[-1:2][2:3]={{1,2},{3,NULL},{5,6},{7,8}}'::int[], 3)) +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_dims(array_sample('[-1:2][2:3]={{1,2},{3,NULL},{5,6},{7,8}}'::int[], 3))" +== 482 +-- truncate_limit: 100 +SELECT array_dims(array_sample('{{{1,2},{3,NULL}},{{5,6},{7,8}},{{9,10},{11,12}}}'::int[], 2)) +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_dims(array_sample('{{{1,2},{3,NULL}},{{5,6},{7,8}},{{9,10},{11,12}}}'::int[], 2))" +== 483 +-- truncate_limit: 100 +SELECT array_sample('{1,2,3,4,5,6}'::int[], -1) +-- +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_sample('{1,2,3,4,5,6}'::int[], -1)" +== 484 +-- truncate_limit: 100 +-- fail +SELECT array_sample('{1,2,3,4,5,6}'::int[], 7) +-- +FUNCTION: name="array_sample" function="array_sample" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_sample('{1,2,3,4,5,6}'::int[], 7)" diff --git a/parser/testdata/summary_truncate/postgres_regress/async.metadata.json b/parser/testdata/summary_truncate/postgres_regress/async.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/async.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/async.test b/parser/testdata/summary_truncate/postgres_regress/async.test new file mode 100644 index 0000000..342128c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/async.test @@ -0,0 +1,82 @@ +== 001 +-- truncate_limit: 100 +|-- +-- ASYNC +|-- + +--Should work. Send a valid message via a valid channel name +SELECT pg_notify('notify_async1','sample message1') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_notify('notify_async1', 'sample message1')" +== 002 +-- truncate_limit: 100 +SELECT pg_notify('notify_async1','') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_notify('notify_async1', '')" +== 003 +-- truncate_limit: 100 +SELECT pg_notify('notify_async1',NULL) +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_notify('notify_async1', NULL)" +== 004 +-- truncate_limit: 100 +-- Should fail. Send a valid message via an invalid channel name +SELECT pg_notify('','sample message1') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_notify('', 'sample message1')" +== 005 +-- truncate_limit: 100 +SELECT pg_notify(NULL,'sample message1') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_notify(NULL, 'sample message1')" +== 006 +-- truncate_limit: 100 +SELECT pg_notify('notify_async_channel_name_too_long______________________________','sample_message1') +-- +FUNCTION: name="pg_notify" function="pg_notify" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 007 +-- truncate_limit: 100 +--Should work. Valid NOTIFY/LISTEN/UNLISTEN commands +NOTIFY notify_async2 +-- +STMT: NotifyStmt +TRUNCATED: "NOTIFY notify_async2" +== 008 +-- truncate_limit: 100 +LISTEN notify_async2 +-- +STMT: ListenStmt +TRUNCATED: "LISTEN notify_async2" +== 009 +-- truncate_limit: 100 +UNLISTEN notify_async2 +-- +STMT: UnlistenStmt +TRUNCATED: "UNLISTEN notify_async2" +== 010 +-- truncate_limit: 100 +UNLISTEN * +-- +STMT: UnlistenStmt +TRUNCATED: "UNLISTEN *" +== 011 +-- truncate_limit: 100 +-- Should return zero while there are no pending notifications. +-- src/test/isolation/specs/async-notify.spec tests for actual usage. +SELECT pg_notification_queue_usage() +-- +FUNCTION: name="pg_notification_queue_usage" function="pg_notification_queue_usage" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_notification_queue_usage()" diff --git a/parser/testdata/summary_truncate/postgres_regress/bit.metadata.json b/parser/testdata/summary_truncate/postgres_regress/bit.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/bit.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/bit.test b/parser/testdata/summary_truncate/postgres_regress/bit.test new file mode 100644 index 0000000..80fd39d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/bit.test @@ -0,0 +1,1077 @@ +== 001 +-- truncate_limit: 100 +|-- +-- BIT types +|-- + +|-- +-- Build tables for testing +|-- + +CREATE TABLE BIT_TABLE(b BIT(11)) +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bit_table (b pg_catalog.bit(11))" +== 002 +-- truncate_limit: 100 +INSERT INTO BIT_TABLE VALUES (B'10') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_table VALUES (b'10')" +== 003 +-- truncate_limit: 100 +-- too short +INSERT INTO BIT_TABLE VALUES (B'00000000000') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_table VALUES (b'00000000000')" +== 004 +-- truncate_limit: 100 +INSERT INTO BIT_TABLE VALUES (B'11011000000') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_table VALUES (b'11011000000')" +== 005 +-- truncate_limit: 100 +INSERT INTO BIT_TABLE VALUES (B'01010101010') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_table VALUES (b'01010101010')" +== 006 +-- truncate_limit: 100 +INSERT INTO BIT_TABLE VALUES (B'101011111010') +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_table VALUES (b'101011111010')" +== 007 +-- truncate_limit: 100 +-- too long +--INSERT INTO BIT_TABLE VALUES ('X554'); +--INSERT INTO BIT_TABLE VALUES ('X555'); + +SELECT * FROM BIT_TABLE +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bit_table" +== 008 +-- truncate_limit: 100 +CREATE TABLE VARBIT_TABLE(v BIT VARYING(11)) +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE varbit_table (v pg_catalog.varbit(11))" +== 009 +-- truncate_limit: 100 +INSERT INTO VARBIT_TABLE VALUES (B'') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_table VALUES (b'')" +== 010 +-- truncate_limit: 100 +INSERT INTO VARBIT_TABLE VALUES (B'0') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_table VALUES (b'0')" +== 011 +-- truncate_limit: 100 +INSERT INTO VARBIT_TABLE VALUES (B'010101') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_table VALUES (b'010101')" +== 012 +-- truncate_limit: 100 +INSERT INTO VARBIT_TABLE VALUES (B'01010101010') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_table VALUES (b'01010101010')" +== 013 +-- truncate_limit: 100 +INSERT INTO VARBIT_TABLE VALUES (B'101011111010') +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_table VALUES (b'101011111010')" +== 014 +-- truncate_limit: 100 +-- too long +--INSERT INTO VARBIT_TABLE VALUES ('X554'); +--INSERT INTO VARBIT_TABLE VALUES ('X555'); +SELECT * FROM VARBIT_TABLE +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM varbit_table" +== 015 +-- truncate_limit: 100 +-- Literals with syntax errors +SELECT b' 0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT b' 0'" +== 016 +-- truncate_limit: 100 +SELECT b'0 ' +-- +STMT: SelectStmt +TRUNCATED: "SELECT b'0 '" +== 017 +-- truncate_limit: 100 +SELECT x' 0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT x' 0'" +== 018 +-- truncate_limit: 100 +SELECT x'0 ' +-- +STMT: SelectStmt +TRUNCATED: "SELECT x'0 '" +== 019 +-- truncate_limit: 100 +-- Concatenation +SELECT v, b, (v || b) AS concat + FROM BIT_TABLE, VARBIT_TABLE + ORDER BY 3 +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT v, b, v || b AS concat FROM bit_table, varbit_table ORDER BY 3" +== 020 +-- truncate_limit: 100 +-- Length +SELECT b, length(b) AS lb + FROM BIT_TABLE +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT b, length(b) AS lb FROM bit_table" +== 021 +-- truncate_limit: 100 +SELECT v, length(v) AS lv + FROM VARBIT_TABLE +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, length(v) AS lv FROM varbit_table" +== 022 +-- truncate_limit: 100 +-- Substring +SELECT b, + SUBSTRING(b FROM 2 FOR 4) AS sub_2_4, + SUBSTRING(b FROM 7 FOR 13) AS sub_7_13, + SUBSTRING(b FROM 6) AS sub_6 + FROM BIT_TABLE +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM bit_table" +== 023 +-- truncate_limit: 100 +SELECT v, + SUBSTRING(v FROM 2 FOR 4) AS sub_2_4, + SUBSTRING(v FROM 7 FOR 13) AS sub_7_13, + SUBSTRING(v FROM 6) AS sub_6 + FROM VARBIT_TABLE +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM varbit_table" +== 024 +-- truncate_limit: 100 +-- test overflow cases +SELECT SUBSTRING('01010101'::bit(8) FROM 2 FOR 2147483646) AS "1010101" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('01010101'::pg_catalog.bit(8) FROM 2 FOR 2147483646) AS \"1010101\"" +== 025 +-- truncate_limit: 100 +SELECT SUBSTRING('01010101'::bit(8) FROM -10 FOR 2147483646) AS "01010101" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('01010101'::pg_catalog.bit(8) FROM -10 FOR 2147483646) AS \"01010101\"" +== 026 +-- truncate_limit: 100 +SELECT SUBSTRING('01010101'::bit(8) FROM -10 FOR -2147483646) AS "error" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('01010101'::pg_catalog.bit(8) FROM -10 FOR -2147483646) AS error" +== 027 +-- truncate_limit: 100 +SELECT SUBSTRING('01010101'::varbit FROM 2 FOR 2147483646) AS "1010101" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('01010101'::varbit FROM 2 FOR 2147483646) AS \"1010101\"" +== 028 +-- truncate_limit: 100 +SELECT SUBSTRING('01010101'::varbit FROM -10 FOR 2147483646) AS "01010101" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('01010101'::varbit FROM -10 FOR 2147483646) AS \"01010101\"" +== 029 +-- truncate_limit: 100 +SELECT SUBSTRING('01010101'::varbit FROM -10 FOR -2147483646) AS "error" +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('01010101'::varbit FROM -10 FOR -2147483646) AS error" +== 030 +-- truncate_limit: 100 +--- Bit operations +DROP TABLE varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE varbit_table" +== 031 +-- truncate_limit: 100 +CREATE TABLE varbit_table (a BIT VARYING(16), b BIT VARYING(16)) +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE varbit_table (a pg_catalog.varbit(16), b pg_catalog.varbit(16))" +== 032 +-- truncate_limit: 100 +COPY varbit_table FROM stdin +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY varbit_table FROM STDIN" +== 033 +-- truncate_limit: 100 +SELECT a, b, ~a AS "~ a", a & b AS "a & b", + a | b AS "a | b", a # b AS "a # b" FROM varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, ~ a AS \"~ a\", a & b AS \"a & b\", a | b AS \"a | b\", a # b AS \"a # b\" FROM varbit_table" +== 034 +-- truncate_limit: 100 +SELECT a,b,a=b AS "a>=b",a>b AS "a>b",a<>b AS "a<>b" FROM varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM varbit_table" +== 035 +-- truncate_limit: 100 +SELECT a,a<<4 AS "a<<4",b,b>>2 AS "b>>2" FROM varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, a << 4 AS \"a<<4\", b, b >> 2 AS \"b>>2\" FROM varbit_table" +== 036 +-- truncate_limit: 100 +DROP TABLE varbit_table +-- +TABLE: name="varbit_table" schema="" table="varbit_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE varbit_table" +== 037 +-- truncate_limit: 100 +--- Bit operations +DROP TABLE bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bit_table" +== 038 +-- truncate_limit: 100 +CREATE TABLE bit_table (a BIT(16), b BIT(16)) +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bit_table (a pg_catalog.bit(16), b pg_catalog.bit(16))" +== 039 +-- truncate_limit: 100 +COPY bit_table FROM stdin +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY bit_table FROM STDIN" +== 040 +-- truncate_limit: 100 +SELECT a,b,~a AS "~ a",a & b AS "a & b", + a|b AS "a | b", a # b AS "a # b" FROM bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, ~ a AS \"~ a\", a & b AS \"a & b\", a | b AS \"a | b\", a # b AS \"a # b\" FROM bit_table" +== 041 +-- truncate_limit: 100 +SELECT a,b,a=b AS "a>=b",a>b AS "a>b",a<>b AS "a<>b" FROM bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM bit_table" +== 042 +-- truncate_limit: 100 +SELECT a,a<<4 AS "a<<4",b,b>>2 AS "b>>2" FROM bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, a << 4 AS \"a<<4\", b, b >> 2 AS \"b>>2\" FROM bit_table" +== 043 +-- truncate_limit: 100 +DROP TABLE bit_table +-- +TABLE: name="bit_table" schema="" table="bit_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bit_table" +== 044 +-- truncate_limit: 100 +-- The following should fail +select B'001' & B'10' +-- +STMT: SelectStmt +TRUNCATED: "SELECT b'001' & b'10'" +== 045 +-- truncate_limit: 100 +select B'0111' | B'011' +-- +STMT: SelectStmt +TRUNCATED: "SELECT b'0111' | b'011'" +== 046 +-- truncate_limit: 100 +select B'0010' # B'011101' +-- +STMT: SelectStmt +TRUNCATED: "SELECT b'0010' # b'011101'" +== 047 +-- truncate_limit: 100 +-- More position tests, checking all the boundary cases +SELECT POSITION(B'1010' IN B'0000101') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'1010' IN b'0000101')" +== 048 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'1010' IN B'00001010') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'1010' IN b'00001010')" +== 049 +-- truncate_limit: 100 +-- 5 +SELECT POSITION(B'1010' IN B'00000101') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'1010' IN b'00000101')" +== 050 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'1010' IN B'000001010') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'1010' IN b'000001010')" +== 051 +-- truncate_limit: 100 +-- 6 + +SELECT POSITION(B'' IN B'00001010') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'' IN b'00001010')" +== 052 +-- truncate_limit: 100 +-- 1 +SELECT POSITION(B'0' IN B'') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'0' IN b'')" +== 053 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'' IN B'') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'' IN b'')" +== 054 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'101101' IN B'001011011011011000') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'101101' IN b'001011011011011000')" +== 055 +-- truncate_limit: 100 +-- 3 +SELECT POSITION(B'10110110' IN B'001011011011010') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'10110110' IN b'001011011011010')" +== 056 +-- truncate_limit: 100 +-- 3 +SELECT POSITION(B'1011011011011' IN B'001011011011011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'1011011011011' IN b'001011011011011')" +== 057 +-- truncate_limit: 100 +-- 3 +SELECT POSITION(B'1011011011011' IN B'00001011011011011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'1011011011011' IN b'00001011011011011')" +== 058 +-- truncate_limit: 100 +-- 5 + +SELECT POSITION(B'11101011' IN B'11101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'11101011' IN b'11101011')" +== 059 +-- truncate_limit: 100 +-- 1 +SELECT POSITION(B'11101011' IN B'011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'11101011' IN b'011101011')" +== 060 +-- truncate_limit: 100 +-- 2 +SELECT POSITION(B'11101011' IN B'00011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'11101011' IN b'00011101011')" +== 061 +-- truncate_limit: 100 +-- 4 +SELECT POSITION(B'11101011' IN B'0000011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'11101011' IN b'0000011101011')" +== 062 +-- truncate_limit: 100 +-- 6 + +SELECT POSITION(B'111010110' IN B'111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'111010110')" +== 063 +-- truncate_limit: 100 +-- 1 +SELECT POSITION(B'111010110' IN B'0111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'0111010110')" +== 064 +-- truncate_limit: 100 +-- 2 +SELECT POSITION(B'111010110' IN B'000111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'000111010110')" +== 065 +-- truncate_limit: 100 +-- 4 +SELECT POSITION(B'111010110' IN B'00000111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'00000111010110')" +== 066 +-- truncate_limit: 100 +-- 6 + +SELECT POSITION(B'111010110' IN B'11101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'11101011')" +== 067 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'111010110' IN B'011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'011101011')" +== 068 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'111010110' IN B'00011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'00011101011')" +== 069 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'111010110' IN B'0000011101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'0000011101011')" +== 070 +-- truncate_limit: 100 +-- 0 + +SELECT POSITION(B'111010110' IN B'111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'111010110')" +== 071 +-- truncate_limit: 100 +-- 1 +SELECT POSITION(B'111010110' IN B'0111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'0111010110')" +== 072 +-- truncate_limit: 100 +-- 2 +SELECT POSITION(B'111010110' IN B'000111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'000111010110')" +== 073 +-- truncate_limit: 100 +-- 4 +SELECT POSITION(B'111010110' IN B'00000111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'00000111010110')" +== 074 +-- truncate_limit: 100 +-- 6 + +SELECT POSITION(B'111010110' IN B'000001110101111101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'000001110101111101011')" +== 075 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'111010110' IN B'0000001110101111101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'0000001110101111101011')" +== 076 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'111010110' IN B'000000001110101111101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'000000001110101111101011')" +== 077 +-- truncate_limit: 100 +-- 0 +SELECT POSITION(B'111010110' IN B'00000000001110101111101011') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'00000000001110101111101011')" +== 078 +-- truncate_limit: 100 +-- 0 + +SELECT POSITION(B'111010110' IN B'0000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'0000011101011111010110')" +== 079 +-- truncate_limit: 100 +-- 14 +SELECT POSITION(B'111010110' IN B'00000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'00000011101011111010110')" +== 080 +-- truncate_limit: 100 +-- 15 +SELECT POSITION(B'111010110' IN B'0000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'0000000011101011111010110')" +== 081 +-- truncate_limit: 100 +-- 17 +SELECT POSITION(B'111010110' IN B'000000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'111010110' IN b'000000000011101011111010110')" +== 082 +-- truncate_limit: 100 +-- 19 + +SELECT POSITION(B'000000000011101011111010110' IN B'000000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'000000000011101011111010110' IN b'000000000011101011111010110')" +== 083 +-- truncate_limit: 100 +-- 1 +SELECT POSITION(B'00000000011101011111010110' IN B'000000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'00000000011101011111010110' IN b'000000000011101011111010110')" +== 084 +-- truncate_limit: 100 +-- 2 +SELECT POSITION(B'0000000000011101011111010110' IN B'000000000011101011111010110') +-- +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'0000000000011101011111010110' IN b'000000000011101011111010110')" +== 085 +-- truncate_limit: 100 +-- 0 + + +-- Shifting + +CREATE TABLE BIT_SHIFT_TABLE(b BIT(16)) +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bit_shift_table (b pg_catalog.bit(16))" +== 086 +-- truncate_limit: 100 +INSERT INTO BIT_SHIFT_TABLE VALUES (B'1101100000000000') +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_shift_table VALUES (b'1101100000000000')" +== 087 +-- truncate_limit: 100 +INSERT INTO BIT_SHIFT_TABLE SELECT b>>1 FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_shift_table SELECT b >> 1 FROM bit_shift_table" +== 088 +-- truncate_limit: 100 +INSERT INTO BIT_SHIFT_TABLE SELECT b>>2 FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_shift_table SELECT b >> 2 FROM bit_shift_table" +== 089 +-- truncate_limit: 100 +INSERT INTO BIT_SHIFT_TABLE SELECT b>>4 FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_shift_table SELECT b >> 4 FROM bit_shift_table" +== 090 +-- truncate_limit: 100 +INSERT INTO BIT_SHIFT_TABLE SELECT b>>8 FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DML +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bit_shift_table SELECT b >> 8 FROM bit_shift_table" +== 091 +-- truncate_limit: 100 +SELECT POSITION(B'1101' IN b), + POSITION(B'11011' IN b), + b + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'1101' IN b), POSITION(b'11011' IN b), b FROM bit_shift_table" +== 092 +-- truncate_limit: 100 +SELECT b, b >> 1 AS bsr, b << 1 AS bsl + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b, b >> 1 AS bsr, b << 1 AS bsl FROM bit_shift_table" +== 093 +-- truncate_limit: 100 +SELECT b, b >> 8 AS bsr8, b << 8 AS bsl8 + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b, b >> 8 AS bsr8, b << 8 AS bsl8 FROM bit_shift_table" +== 094 +-- truncate_limit: 100 +SELECT b::bit(15), b::bit(15) >> 1 AS bsr, b::bit(15) << 1 AS bsl + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM bit_shift_table" +== 095 +-- truncate_limit: 100 +SELECT b::bit(15), b::bit(15) >> 8 AS bsr8, b::bit(15) << 8 AS bsl8 + FROM BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM bit_shift_table" +== 096 +-- truncate_limit: 100 +CREATE TABLE VARBIT_SHIFT_TABLE(v BIT VARYING(20)) +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE varbit_shift_table (v pg_catalog.varbit(20))" +== 097 +-- truncate_limit: 100 +INSERT INTO VARBIT_SHIFT_TABLE VALUES (B'11011') +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_shift_table VALUES (b'11011')" +== 098 +-- truncate_limit: 100 +INSERT INTO VARBIT_SHIFT_TABLE SELECT CAST(v || B'0' AS BIT VARYING(6)) >>1 FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_shift_table SELECT (v || b'0')::pg_catalog.varbit(6) >> 1 FROM varbit_shift_table" +== 099 +-- truncate_limit: 100 +INSERT INTO VARBIT_SHIFT_TABLE SELECT CAST(v || B'00' AS BIT VARYING(8)) >>2 FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_shift_table SELECT ... FROM varbit_shift_table" +== 100 +-- truncate_limit: 100 +INSERT INTO VARBIT_SHIFT_TABLE SELECT CAST(v || B'0000' AS BIT VARYING(12)) >>4 FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_shift_table SELECT ... FROM varbit_shift_table" +== 101 +-- truncate_limit: 100 +INSERT INTO VARBIT_SHIFT_TABLE SELECT CAST(v || B'00000000' AS BIT VARYING(20)) >>8 FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DML +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varbit_shift_table SELECT ... FROM varbit_shift_table" +== 102 +-- truncate_limit: 100 +SELECT POSITION(B'1101' IN v), + POSITION(B'11011' IN v), + v + FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT POSITION(b'1101' IN v), POSITION(b'11011' IN v), v FROM varbit_shift_table" +== 103 +-- truncate_limit: 100 +SELECT v, v >> 1 AS vsr, v << 1 AS vsl + FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT v, v >> 1 AS vsr, v << 1 AS vsl FROM varbit_shift_table" +== 104 +-- truncate_limit: 100 +SELECT v, v >> 8 AS vsr8, v << 8 AS vsl8 + FROM VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT v, v >> 8 AS vsr8, v << 8 AS vsl8 FROM varbit_shift_table" +== 105 +-- truncate_limit: 100 +DROP TABLE BIT_SHIFT_TABLE +-- +TABLE: name="bit_shift_table" schema="" table="bit_shift_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bit_shift_table" +== 106 +-- truncate_limit: 100 +DROP TABLE VARBIT_SHIFT_TABLE +-- +TABLE: name="varbit_shift_table" schema="" table="varbit_shift_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE varbit_shift_table" +== 107 +-- truncate_limit: 100 +-- Get/Set bit +SELECT get_bit(B'0101011000100', 10) +-- +FUNCTION: name="get_bit" function="get_bit" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT get_bit(b'0101011000100', 10)" +== 108 +-- truncate_limit: 100 +SELECT set_bit(B'0101011000100100', 15, 1) +-- +FUNCTION: name="set_bit" function="set_bit" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_bit(b'0101011000100100', 15, 1)" +== 109 +-- truncate_limit: 100 +SELECT set_bit(B'0101011000100100', 16, 1) +-- +FUNCTION: name="set_bit" function="set_bit" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_bit(b'0101011000100100', 16, 1)" +== 110 +-- truncate_limit: 100 +-- fail + +-- Overlay +SELECT overlay(B'0101011100' placing '001' from 2 for 3) +-- +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT OVERLAY(b'0101011100' PLACING '001' FROM 2 FOR 3)" +== 111 +-- truncate_limit: 100 +SELECT overlay(B'0101011100' placing '101' from 6) +-- +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT overlay(b'0101011100' placing '101' from 6)" +== 112 +-- truncate_limit: 100 +SELECT overlay(B'0101011100' placing '001' from 11) +-- +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT overlay(b'0101011100' placing '001' from 11)" +== 113 +-- truncate_limit: 100 +SELECT overlay(B'0101011100' placing '001' from 20) +-- +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT overlay(b'0101011100' placing '001' from 20)" +== 114 +-- truncate_limit: 100 +-- bit_count +SELECT bit_count(B'0101011100'::bit(10)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bit_count(b'0101011100'::pg_catalog.bit(10))" +== 115 +-- truncate_limit: 100 +SELECT bit_count(B'1111111111'::bit(10)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bit_count(b'1111111111'::pg_catalog.bit(10))" +== 116 +-- truncate_limit: 100 +SELECT bit_count(repeat('0', 100)::bit(100)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bit_count(repeat('0', 100)::pg_catalog.bit(100))" +== 117 +-- truncate_limit: 100 +SELECT bit_count(repeat('1', 100)::bit(100)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bit_count(repeat('1', 100)::pg_catalog.bit(100))" +== 118 +-- truncate_limit: 100 +SELECT bit_count(repeat('01', 500)::bit(1000)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bit_count(repeat('01', 500)::pg_catalog.bit(1000))" +== 119 +-- truncate_limit: 100 +SELECT bit_count(repeat('10101', 200)::bit(1000)) +-- +FUNCTION: name="bit_count" function="bit_count" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bit_count(repeat('10101', 200)::pg_catalog.bit(1000))" +== 120 +-- truncate_limit: 100 +-- This table is intentionally left around to exercise pg_dump/pg_upgrade +CREATE TABLE bit_defaults( + b1 bit(4) DEFAULT '1001', + b2 bit(4) DEFAULT B'0101', + b3 bit varying(5) DEFAULT '1001', + b4 bit varying(5) DEFAULT B'0101' +) +-- +TABLE: name="bit_defaults" schema="" table="bit_defaults" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bit_defaults (b1 pg_catalog.bit(4) DEFAULT '1001', b2 pg_catalog.bit(4) DEFAULT b'01..." +== 121 +-- truncate_limit: 100 +INSERT INTO bit_defaults DEFAULT VALUES +-- +TABLE: name="bit_defaults" schema="" table="bit_defaults" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO bit_defaults DEFAULT VALUES" +== 122 +-- truncate_limit: 100 +TABLE bit_defaults +-- +TABLE: name="bit_defaults" schema="" table="bit_defaults" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bit_defaults" +== 123 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('01010001', 'bit(10)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('01010001', 'bit(10)')" +== 124 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('01010001', 'bit(10)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('01010001', 'bit(10)')" +== 125 +-- truncate_limit: 100 +SELECT pg_input_is_valid('01010Z01', 'bit(8)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('01010Z01', 'bit(8)')" +== 126 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('01010Z01', 'bit(8)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('01010Z01', 'bit(8)')" +== 127 +-- truncate_limit: 100 +SELECT pg_input_is_valid('x01010Z01', 'bit(32)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('x01010Z01', 'bit(32)')" +== 128 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('x01010Z01', 'bit(32)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('x01010Z01', 'bit(32)')" +== 129 +-- truncate_limit: 100 +SELECT pg_input_is_valid('01010Z01', 'varbit') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('01010Z01', 'varbit')" +== 130 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('01010Z01', 'varbit') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('01010Z01', 'varbit')" +== 131 +-- truncate_limit: 100 +SELECT pg_input_is_valid('x01010Z01', 'varbit') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('x01010Z01', 'varbit')" +== 132 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('x01010Z01', 'varbit') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('x01010Z01', 'varbit')" diff --git a/parser/testdata/summary_truncate/postgres_regress/bitmapops.metadata.json b/parser/testdata/summary_truncate/postgres_regress/bitmapops.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/bitmapops.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/bitmapops.test b/parser/testdata/summary_truncate/postgres_regress/bitmapops.test new file mode 100644 index 0000000..1f19548 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/bitmapops.test @@ -0,0 +1,97 @@ +== 001 +-- truncate_limit: 100 +-- Test bitmap AND and OR + + +-- Generate enough data that we can test the lossy bitmaps. + +-- There's 55 tuples per page in the table. 53 is just +-- below 55, so that an index scan with qual a = constant +-- will return at least one hit per page. 59 is just above +-- 55, so that an index scan with qual b = constant will return +-- hits on most but not all pages. 53 and 59 are prime, so that +-- there's a maximum number of a,b combinations in the table. +-- That allows us to test all the different combinations of +-- lossy and non-lossy pages with the minimum amount of data + +CREATE TABLE bmscantest (a int, b int, t text) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bmscantest (a int, b int, t text)" +== 002 +-- truncate_limit: 100 +INSERT INTO bmscantest + SELECT (r%53), (r%59), 'foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + FROM generate_series(1,70000) r +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bmscantest SELECT ... FROM generate_series(1, 70000) r" +== 003 +-- truncate_limit: 100 +CREATE INDEX i_bmtest_a ON bmscantest(a) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX i_bmtest_a ON bmscantest USING btree (a)" +== 004 +-- truncate_limit: 100 +CREATE INDEX i_bmtest_b ON bmscantest(b) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX i_bmtest_b ON bmscantest USING btree (b)" +== 005 +-- truncate_limit: 100 +-- We want to use bitmapscans. With default settings, the planner currently +-- chooses a bitmap scan for the queries below anyway, but let's make sure. +set enable_indexscan=false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO FALSE" +== 006 +-- truncate_limit: 100 +set enable_seqscan=false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO FALSE" +== 007 +-- truncate_limit: 100 +-- Lower work_mem to trigger use of lossy bitmaps +set work_mem = 64 +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO 64" +== 008 +-- truncate_limit: 100 +-- Test bitmap-and. +SELECT count(*) FROM bmscantest WHERE a = 1 AND b = 1 +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM bmscantest WHERE a = 1 AND b = 1" +== 009 +-- truncate_limit: 100 +-- Test bitmap-or. +SELECT count(*) FROM bmscantest WHERE a = 1 OR b = 1 +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM bmscantest WHERE a = 1 OR b = 1" +== 010 +-- truncate_limit: 100 +-- clean up +DROP TABLE bmscantest +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bmscantest" diff --git a/parser/testdata/summary_truncate/postgres_regress/boolean.metadata.json b/parser/testdata/summary_truncate/postgres_regress/boolean.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/boolean.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/boolean.test b/parser/testdata/summary_truncate/postgres_regress/boolean.test new file mode 100644 index 0000000..61109cc --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/boolean.test @@ -0,0 +1,775 @@ +== 001 +-- truncate_limit: 100 +|-- +-- BOOLEAN +|-- + +|-- +-- sanity check - if this fails go insane! +|-- +SELECT 1 AS one +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one" +== 002 +-- truncate_limit: 100 +-- ******************testing built-in type bool******************** + +-- check bool input syntax + +SELECT true AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT true AS \"true\"" +== 003 +-- truncate_limit: 100 +SELECT false AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT false AS \"false\"" +== 004 +-- truncate_limit: 100 +SELECT bool 't' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 't'::bool AS \"true\"" +== 005 +-- truncate_limit: 100 +SELECT bool ' f ' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' f '::bool AS \"false\"" +== 006 +-- truncate_limit: 100 +SELECT bool 'true' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true'::bool AS \"true\"" +== 007 +-- truncate_limit: 100 +SELECT bool 'test' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'test'::bool AS error" +== 008 +-- truncate_limit: 100 +SELECT bool 'false' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'false'::bool AS \"false\"" +== 009 +-- truncate_limit: 100 +SELECT bool 'foo' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo'::bool AS error" +== 010 +-- truncate_limit: 100 +SELECT bool 'y' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'y'::bool AS \"true\"" +== 011 +-- truncate_limit: 100 +SELECT bool 'yes' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'yes'::bool AS \"true\"" +== 012 +-- truncate_limit: 100 +SELECT bool 'yeah' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'yeah'::bool AS error" +== 013 +-- truncate_limit: 100 +SELECT bool 'n' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'n'::bool AS \"false\"" +== 014 +-- truncate_limit: 100 +SELECT bool 'no' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'no'::bool AS \"false\"" +== 015 +-- truncate_limit: 100 +SELECT bool 'nay' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nay'::bool AS error" +== 016 +-- truncate_limit: 100 +SELECT bool 'on' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'on'::bool AS \"true\"" +== 017 +-- truncate_limit: 100 +SELECT bool 'off' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'off'::bool AS \"false\"" +== 018 +-- truncate_limit: 100 +SELECT bool 'of' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'of'::bool AS \"false\"" +== 019 +-- truncate_limit: 100 +SELECT bool 'o' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'o'::bool AS error" +== 020 +-- truncate_limit: 100 +SELECT bool 'on_' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'on_'::bool AS error" +== 021 +-- truncate_limit: 100 +SELECT bool 'off_' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'off_'::bool AS error" +== 022 +-- truncate_limit: 100 +SELECT bool '1' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::bool AS \"true\"" +== 023 +-- truncate_limit: 100 +SELECT bool '11' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11'::bool AS error" +== 024 +-- truncate_limit: 100 +SELECT bool '0' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0'::bool AS \"false\"" +== 025 +-- truncate_limit: 100 +SELECT bool '000' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT '000'::bool AS error" +== 026 +-- truncate_limit: 100 +SELECT bool '' AS error +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::bool AS error" +== 027 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('true', 'bool') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('true', 'bool')" +== 028 +-- truncate_limit: 100 +SELECT pg_input_is_valid('asdf', 'bool') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('asdf', 'bool')" +== 029 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('junk', 'bool') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('junk', 'bool')" +== 030 +-- truncate_limit: 100 +-- and, or, not in qualifications + +SELECT bool 't' or bool 'f' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 't'::bool OR 'f'::bool AS \"true\"" +== 031 +-- truncate_limit: 100 +SELECT bool 't' and bool 'f' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 't'::bool AND 'f'::bool AS \"false\"" +== 032 +-- truncate_limit: 100 +SELECT not bool 'f' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT NOT 'f'::bool AS \"true\"" +== 033 +-- truncate_limit: 100 +SELECT bool 't' = bool 'f' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 't'::bool = 'f'::bool AS \"false\"" +== 034 +-- truncate_limit: 100 +SELECT bool 't' <> bool 'f' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 't'::bool <> 'f'::bool AS \"true\"" +== 035 +-- truncate_limit: 100 +SELECT bool 't' > bool 'f' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 't'::bool > 'f'::bool AS \"true\"" +== 036 +-- truncate_limit: 100 +SELECT bool 't' >= bool 'f' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 't'::bool >= 'f'::bool AS \"true\"" +== 037 +-- truncate_limit: 100 +SELECT bool 'f' < bool 't' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'f'::bool < 't'::bool AS \"true\"" +== 038 +-- truncate_limit: 100 +SELECT bool 'f' <= bool 't' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'f'::bool <= 't'::bool AS \"true\"" +== 039 +-- truncate_limit: 100 +-- explicit casts to/from text +SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'TrUe'::text::boolean AS \"true\", 'fAlse'::text::boolean AS \"false\"" +== 040 +-- truncate_limit: 100 +SELECT ' true '::text::boolean AS true, + ' FALSE'::text::boolean AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' true '::text::boolean AS \"true\", ' FALSE'::text::boolean AS \"false\"" +== 041 +-- truncate_limit: 100 +SELECT true::boolean::text AS true, false::boolean::text AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT true::boolean::text AS \"true\", false::boolean::text AS \"false\"" +== 042 +-- truncate_limit: 100 +SELECT ' tru e '::text::boolean AS invalid +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' tru e '::text::boolean AS invalid" +== 043 +-- truncate_limit: 100 +-- error +SELECT ''::text::boolean AS invalid +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::text::boolean AS invalid" +== 044 +-- truncate_limit: 100 +-- error + +CREATE TABLE BOOLTBL1 (f1 bool) +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE booltbl1 (f1 bool)" +== 045 +-- truncate_limit: 100 +INSERT INTO BOOLTBL1 (f1) VALUES (bool 't') +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl1 (f1) VALUES ('t'::bool)" +== 046 +-- truncate_limit: 100 +INSERT INTO BOOLTBL1 (f1) VALUES (bool 'True') +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl1 (f1) VALUES ('True'::bool)" +== 047 +-- truncate_limit: 100 +INSERT INTO BOOLTBL1 (f1) VALUES (bool 'true') +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl1 (f1) VALUES ('true'::bool)" +== 048 +-- truncate_limit: 100 +-- BOOLTBL1 should be full of true's at this point +SELECT BOOLTBL1.* FROM BOOLTBL1 +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.* FROM booltbl1" +== 049 +-- truncate_limit: 100 +SELECT BOOLTBL1.* + FROM BOOLTBL1 + WHERE f1 = bool 'true' +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.* FROM booltbl1 WHERE f1 = 'true'::bool" +== 050 +-- truncate_limit: 100 +SELECT BOOLTBL1.* + FROM BOOLTBL1 + WHERE f1 <> bool 'false' +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.* FROM booltbl1 WHERE f1 <> 'false'::bool" +== 051 +-- truncate_limit: 100 +SELECT BOOLTBL1.* + FROM BOOLTBL1 + WHERE booleq(bool 'false', f1) +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FUNCTION: name="booleq" function="booleq" schema="" ctx=Call +FUNCTION: name="booleq" function="booleq" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.* FROM booltbl1 WHERE booleq('false'::bool, f1)" +== 052 +-- truncate_limit: 100 +INSERT INTO BOOLTBL1 (f1) VALUES (bool 'f') +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl1 (f1) VALUES ('f'::bool)" +== 053 +-- truncate_limit: 100 +SELECT BOOLTBL1.* + FROM BOOLTBL1 + WHERE f1 = bool 'false' +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.* FROM booltbl1 WHERE f1 = 'false'::bool" +== 054 +-- truncate_limit: 100 +CREATE TABLE BOOLTBL2 (f1 bool) +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE booltbl2 (f1 bool)" +== 055 +-- truncate_limit: 100 +INSERT INTO BOOLTBL2 (f1) VALUES (bool 'f') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl2 (f1) VALUES ('f'::bool)" +== 056 +-- truncate_limit: 100 +INSERT INTO BOOLTBL2 (f1) VALUES (bool 'false') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl2 (f1) VALUES ('false'::bool)" +== 057 +-- truncate_limit: 100 +INSERT INTO BOOLTBL2 (f1) VALUES (bool 'False') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl2 (f1) VALUES ('False'::bool)" +== 058 +-- truncate_limit: 100 +INSERT INTO BOOLTBL2 (f1) VALUES (bool 'FALSE') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl2 (f1) VALUES ('FALSE'::bool)" +== 059 +-- truncate_limit: 100 +-- This is now an invalid expression +-- For pre-v6.3 this evaluated to false - thomas 1997-10-23 +INSERT INTO BOOLTBL2 (f1) + VALUES (bool 'XXX') +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl2 (f1) VALUES ('XXX'::bool)" +== 060 +-- truncate_limit: 100 +-- BOOLTBL2 should be full of false's at this point +SELECT BOOLTBL2.* FROM BOOLTBL2 +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT booltbl2.* FROM booltbl2" +== 061 +-- truncate_limit: 100 +SELECT BOOLTBL1.*, BOOLTBL2.* + FROM BOOLTBL1, BOOLTBL2 + WHERE BOOLTBL2.f1 <> BOOLTBL1.f1 +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="booltbl2" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.*, booltbl2.* FROM booltbl1, booltbl2 WHERE booltbl2.f1 <> booltbl1.f1" +== 062 +-- truncate_limit: 100 +SELECT BOOLTBL1.*, BOOLTBL2.* + FROM BOOLTBL1, BOOLTBL2 + WHERE boolne(BOOLTBL2.f1,BOOLTBL1.f1) +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FUNCTION: name="boolne" function="boolne" schema="" ctx=Call +FUNCTION: name="boolne" function="boolne" schema="" ctx=Call +FILTER: schema="" table="booltbl2" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.*, booltbl2.* FROM booltbl1, booltbl2 WHERE boolne(booltbl2.f1, booltbl1.f1)" +== 063 +-- truncate_limit: 100 +SELECT BOOLTBL1.*, BOOLTBL2.* + FROM BOOLTBL1, BOOLTBL2 + WHERE BOOLTBL2.f1 = BOOLTBL1.f1 and BOOLTBL1.f1 = bool 'false' +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="booltbl2" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.*, booltbl2.* FROM booltbl1, booltbl2 WHERE ..." +== 064 +-- truncate_limit: 100 +SELECT BOOLTBL1.*, BOOLTBL2.* + FROM BOOLTBL1, BOOLTBL2 + WHERE BOOLTBL2.f1 = BOOLTBL1.f1 or BOOLTBL1.f1 = bool 'true' + ORDER BY BOOLTBL1.f1, BOOLTBL2.f1 +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="booltbl2" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +FILTER: schema="" table="booltbl1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT booltbl1.*, booltbl2.* FROM booltbl1, booltbl2 WHERE ... ORDER BY booltbl1.f1, booltbl2.f1" +== 065 +-- truncate_limit: 100 +|-- +-- SQL syntax +-- Try all combinations to ensure that we get nothing when we expect nothing +-- - thomas 2000-01-04 +|-- + +SELECT f1 + FROM BOOLTBL1 + WHERE f1 IS TRUE +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM booltbl1 WHERE f1 IS TRUE" +== 066 +-- truncate_limit: 100 +SELECT f1 + FROM BOOLTBL1 + WHERE f1 IS NOT FALSE +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM booltbl1 WHERE f1 IS NOT FALSE" +== 067 +-- truncate_limit: 100 +SELECT f1 + FROM BOOLTBL1 + WHERE f1 IS FALSE +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM booltbl1 WHERE f1 IS FALSE" +== 068 +-- truncate_limit: 100 +SELECT f1 + FROM BOOLTBL1 + WHERE f1 IS NOT TRUE +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM booltbl1 WHERE f1 IS NOT TRUE" +== 069 +-- truncate_limit: 100 +SELECT f1 + FROM BOOLTBL2 + WHERE f1 IS TRUE +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM booltbl2 WHERE f1 IS TRUE" +== 070 +-- truncate_limit: 100 +SELECT f1 + FROM BOOLTBL2 + WHERE f1 IS NOT FALSE +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM booltbl2 WHERE f1 IS NOT FALSE" +== 071 +-- truncate_limit: 100 +SELECT f1 + FROM BOOLTBL2 + WHERE f1 IS FALSE +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM booltbl2 WHERE f1 IS FALSE" +== 072 +-- truncate_limit: 100 +SELECT f1 + FROM BOOLTBL2 + WHERE f1 IS NOT TRUE +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM booltbl2 WHERE f1 IS NOT TRUE" +== 073 +-- truncate_limit: 100 +|-- +-- Tests for BooleanTest +|-- +CREATE TABLE BOOLTBL3 (d text, b bool, o int) +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE booltbl3 (d text, b bool, o int)" +== 074 +-- truncate_limit: 100 +INSERT INTO BOOLTBL3 (d, b, o) VALUES ('true', true, 1) +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl3 (d, b, o) VALUES ('true', true, 1)" +== 075 +-- truncate_limit: 100 +INSERT INTO BOOLTBL3 (d, b, o) VALUES ('false', false, 2) +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl3 (d, b, o) VALUES ('false', false, 2)" +== 076 +-- truncate_limit: 100 +INSERT INTO BOOLTBL3 (d, b, o) VALUES ('null', null, 3) +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl3 (d, b, o) VALUES ('null', NULL, 3)" +== 077 +-- truncate_limit: 100 +SELECT + d, + b IS TRUE AS istrue, + b IS NOT TRUE AS isnottrue, + b IS FALSE AS isfalse, + b IS NOT FALSE AS isnotfalse, + b IS UNKNOWN AS isunknown, + b IS NOT UNKNOWN AS isnotunknown +FROM booltbl3 ORDER BY o +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM booltbl3 ORDER BY o" +== 078 +-- truncate_limit: 100 +-- Test to make sure short-circuiting and NULL handling is +-- correct. Use a table as source to prevent constant simplification +-- from interfering. +CREATE TABLE booltbl4(isfalse bool, istrue bool, isnul bool) +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE booltbl4 (isfalse bool, istrue bool, isnul bool)" +== 079 +-- truncate_limit: 100 +INSERT INTO booltbl4 VALUES (false, true, null) +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO booltbl4 VALUES (false, true, NULL)" +== 080 +-- truncate_limit: 100 +-- AND expression need to return null if there's any nulls and not all +-- of the value are true +SELECT istrue AND isnul AND istrue FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT istrue AND isnul AND istrue FROM booltbl4" +== 081 +-- truncate_limit: 100 +SELECT istrue AND istrue AND isnul FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT istrue AND istrue AND isnul FROM booltbl4" +== 082 +-- truncate_limit: 100 +SELECT isnul AND istrue AND istrue FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT isnul AND istrue AND istrue FROM booltbl4" +== 083 +-- truncate_limit: 100 +SELECT isfalse AND isnul AND istrue FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT isfalse AND isnul AND istrue FROM booltbl4" +== 084 +-- truncate_limit: 100 +SELECT istrue AND isfalse AND isnul FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT istrue AND isfalse AND isnul FROM booltbl4" +== 085 +-- truncate_limit: 100 +SELECT isnul AND istrue AND isfalse FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT isnul AND istrue AND isfalse FROM booltbl4" +== 086 +-- truncate_limit: 100 +-- OR expression need to return null if there's any nulls and none +-- of the value is true +SELECT isfalse OR isnul OR isfalse FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT isfalse OR isnul OR isfalse FROM booltbl4" +== 087 +-- truncate_limit: 100 +SELECT isfalse OR isfalse OR isnul FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT isfalse OR isfalse OR isnul FROM booltbl4" +== 088 +-- truncate_limit: 100 +SELECT isnul OR isfalse OR isfalse FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT isnul OR isfalse OR isfalse FROM booltbl4" +== 089 +-- truncate_limit: 100 +SELECT isfalse OR isnul OR istrue FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT isfalse OR isnul OR istrue FROM booltbl4" +== 090 +-- truncate_limit: 100 +SELECT istrue OR isfalse OR isnul FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT istrue OR isfalse OR isnul FROM booltbl4" +== 091 +-- truncate_limit: 100 +SELECT isnul OR istrue OR isfalse FROM booltbl4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT isnul OR istrue OR isfalse FROM booltbl4" +== 092 +-- truncate_limit: 100 +-- Casts +SELECT 0::boolean +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0::boolean" +== 093 +-- truncate_limit: 100 +SELECT 1::boolean +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1::boolean" +== 094 +-- truncate_limit: 100 +SELECT 2::boolean +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2::boolean" +== 095 +-- truncate_limit: 100 +|-- +-- Clean up +-- Many tables are retained by the regression test, but these do not seem +-- particularly useful so just get rid of them for now. +-- - thomas 1997-11-30 +|-- + +DROP TABLE BOOLTBL1 +-- +TABLE: name="booltbl1" schema="" table="booltbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE booltbl1" +== 096 +-- truncate_limit: 100 +DROP TABLE BOOLTBL2 +-- +TABLE: name="booltbl2" schema="" table="booltbl2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE booltbl2" +== 097 +-- truncate_limit: 100 +DROP TABLE BOOLTBL3 +-- +TABLE: name="booltbl3" schema="" table="booltbl3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE booltbl3" +== 098 +-- truncate_limit: 100 +DROP TABLE BOOLTBL4 +-- +TABLE: name="booltbl4" schema="" table="booltbl4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE booltbl4" diff --git a/parser/testdata/summary_truncate/postgres_regress/box.metadata.json b/parser/testdata/summary_truncate/postgres_regress/box.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/box.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/box.test b/parser/testdata/summary_truncate/postgres_regress/box.test new file mode 100644 index 0000000..4efa12a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/box.test @@ -0,0 +1,966 @@ +== 001 +-- truncate_limit: 100 +|-- +-- BOX +|-- + +|-- +-- box logic +-- o +-- 3 o--|X +-- | o| +-- 2 +-+-+ | +-- | | | | +-- 1 | o-+-o +-- | | +-- 0 +---+ +|-- +-- 0 1 2 3 +|-- + +-- boxes are specified by two points, given by four floats x1,y1,x2,y2 + + +CREATE TABLE BOX_TBL (f1 box) +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE box_tbl (f1 box)" +== 002 +-- truncate_limit: 100 +INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('(2.0,2.0,0.0,0.0)')" +== 003 +-- truncate_limit: 100 +INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('(1.0,1.0,3.0,3.0)')" +== 004 +-- truncate_limit: 100 +INSERT INTO BOX_TBL (f1) VALUES ('((-8, 2), (-2, -10))') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('((-8, 2), (-2, -10))')" +== 005 +-- truncate_limit: 100 +-- degenerate cases where the box is a line or a point +-- note that lines and points boxes all have zero area +INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('(2.5, 2.5, 2.5,3.5)')" +== 006 +-- truncate_limit: 100 +INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('(3.0, 3.0,3.0,3.0)')" +== 007 +-- truncate_limit: 100 +-- badly formatted box inputs +INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('(2.3, 4.5)')" +== 008 +-- truncate_limit: 100 +INSERT INTO BOX_TBL (f1) VALUES ('[1, 2, 3, 4)') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('[1, 2, 3, 4)')" +== 009 +-- truncate_limit: 100 +INSERT INTO BOX_TBL (f1) VALUES ('(1, 2, 3, 4]') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('(1, 2, 3, 4]')" +== 010 +-- truncate_limit: 100 +INSERT INTO BOX_TBL (f1) VALUES ('(1, 2, 3, 4) x') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('(1, 2, 3, 4) x')" +== 011 +-- truncate_limit: 100 +INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad') +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_tbl (f1) VALUES ('asdfasdf(ad')" +== 012 +-- truncate_limit: 100 +SELECT * FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_tbl" +== 013 +-- truncate_limit: 100 +SELECT b.*, area(b.f1) as barea + FROM BOX_TBL b +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FUNCTION: name="area" function="area" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT b.*, area(b.f1) AS barea FROM box_tbl b" +== 014 +-- truncate_limit: 100 +-- overlap +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 && box '(2.5,2.5,1.0,1.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE b.f1 && '(2.5,2.5,1.0,1.0)'::box" +== 015 +-- truncate_limit: 100 +-- left-or-overlap (x only) +SELECT b1.* + FROM BOX_TBL b1 + WHERE b1.f1 &< box '(2.0,2.0,2.5,2.5)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +FILTER: schema="" table="b1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b1.* FROM box_tbl b1 WHERE b1.f1 &< '(2.0,2.0,2.5,2.5)'::box" +== 016 +-- truncate_limit: 100 +-- right-or-overlap (x only) +SELECT b1.* + FROM BOX_TBL b1 + WHERE b1.f1 &> box '(2.0,2.0,2.5,2.5)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +FILTER: schema="" table="b1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b1.* FROM box_tbl b1 WHERE b1.f1 &> '(2.0,2.0,2.5,2.5)'::box" +== 017 +-- truncate_limit: 100 +-- left of +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 << box '(3.0,3.0,5.0,5.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE b.f1 << '(3.0,3.0,5.0,5.0)'::box" +== 018 +-- truncate_limit: 100 +-- area <= +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 <= box '(3.0,3.0,5.0,5.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE b.f1 <= '(3.0,3.0,5.0,5.0)'::box" +== 019 +-- truncate_limit: 100 +-- area < +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 < box '(3.0,3.0,5.0,5.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE b.f1 < '(3.0,3.0,5.0,5.0)'::box" +== 020 +-- truncate_limit: 100 +-- area = +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 = box '(3.0,3.0,5.0,5.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE b.f1 = '(3.0,3.0,5.0,5.0)'::box" +== 021 +-- truncate_limit: 100 +-- area > +SELECT b.f1 + FROM BOX_TBL b -- zero area + WHERE b.f1 > box '(3.5,3.0,4.5,3.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE b.f1 > '(3.5,3.0,4.5,3.0)'::box" +== 022 +-- truncate_limit: 100 +-- area >= +SELECT b.f1 + FROM BOX_TBL b -- zero area + WHERE b.f1 >= box '(3.5,3.0,4.5,3.0)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE b.f1 >= '(3.5,3.0,4.5,3.0)'::box" +== 023 +-- truncate_limit: 100 +-- right of +SELECT b.f1 + FROM BOX_TBL b + WHERE box '(3.0,3.0,5.0,5.0)' >> b.f1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE '(3.0,3.0,5.0,5.0)'::box >> b.f1" +== 024 +-- truncate_limit: 100 +-- contained in +SELECT b.f1 + FROM BOX_TBL b + WHERE b.f1 <@ box '(0,0,3,3)' +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE b.f1 <@ '(0,0,3,3)'::box" +== 025 +-- truncate_limit: 100 +-- contains +SELECT b.f1 + FROM BOX_TBL b + WHERE box '(0,0,3,3)' @> b.f1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE '(0,0,3,3)'::box @> b.f1" +== 026 +-- truncate_limit: 100 +-- box equality +SELECT b.f1 + FROM BOX_TBL b + WHERE box '(1,1,3,3)' ~= b.f1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 FROM box_tbl b WHERE '(1,1,3,3)'::box ~= b.f1" +== 027 +-- truncate_limit: 100 +-- center of box, left unary operator +SELECT @@(b1.f1) AS p + FROM BOX_TBL b1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT @@ b1.f1 AS p FROM box_tbl b1" +== 028 +-- truncate_limit: 100 +-- wholly-contained +SELECT b1.*, b2.* + FROM BOX_TBL b1, BOX_TBL b2 + WHERE b1.f1 @> b2.f1 and not b1.f1 ~= b2.f1 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +FILTER: schema="" table="b1" column="f1" +FILTER: schema="" table="b2" column="f1" +FILTER: schema="" table="b1" column="f1" +FILTER: schema="" table="b2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b1.*, b2.* FROM box_tbl b1, box_tbl b2 WHERE b1.f1 @> b2.f1 AND NOT b1.f1 ~= b2.f1" +== 029 +-- truncate_limit: 100 +SELECT height(f1), width(f1) FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="height" function="height" schema="" ctx=Call +FUNCTION: name="width" function="width" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT height(f1), width(f1) FROM box_tbl" +== 030 +-- truncate_limit: 100 +|-- +-- Test the SP-GiST index +|-- + +CREATE TEMPORARY TABLE box_temp (f1 box) +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE box_temp (f1 box)" +== 031 +-- truncate_limit: 100 +INSERT INTO box_temp + SELECT box(point(i, i), point(i * 2, i * 2)) + FROM generate_series(1, 50) AS i +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_temp SELECT box(point(i, i), point(i * 2, i * 2)) FROM generate_series(1, 50) i" +== 032 +-- truncate_limit: 100 +CREATE INDEX box_spgist ON box_temp USING spgist (f1) +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX box_spgist ON box_temp USING spgist (f1)" +== 033 +-- truncate_limit: 100 +INSERT INTO box_temp + VALUES (NULL), + ('(0,0)(0,100)'), + ('(-3,4.3333333333)(40,1)'), + ('(0,100)(0,infinity)'), + ('(-infinity,0)(0,infinity)'), + ('(-infinity,-infinity)(infinity,infinity)') +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO box_temp VALUES (...)" +== 034 +-- truncate_limit: 100 +SET enable_seqscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO FALSE" +== 035 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 << '(10,20),(30,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 << '(10,20),(30,40)'" +== 036 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 << '(10,20),(30,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 << '(10,20),(30,40)'" +== 037 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 &< '(10,4.333334),(5,100)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 &< '(10,4.333334),(5,100)'" +== 038 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &< '(10,4.333334),(5,100)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &< '(10,4.333334),(5,100)'" +== 039 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 && '(15,20),(25,30)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 && '(15,20),(25,30)'" +== 040 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 && '(15,20),(25,30)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 && '(15,20),(25,30)'" +== 041 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 &> '(40,30),(45,50)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 &> '(40,30),(45,50)'" +== 042 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &> '(40,30),(45,50)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &> '(40,30),(45,50)'" +== 043 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 >> '(30,40),(40,30)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 >> '(30,40),(40,30)'" +== 044 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 >> '(30,40),(40,30)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 >> '(30,40),(40,30)'" +== 045 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 <<| '(10,4.33334),(5,100)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 <<| '(10,4.33334),(5,100)'" +== 046 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 <<| '(10,4.33334),(5,100)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 <<| '(10,4.33334),(5,100)'" +== 047 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 &<| '(10,4.3333334),(5,1)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 &<| '(10,4.3333334),(5,1)'" +== 048 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &<| '(10,4.3333334),(5,1)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 &<| '(10,4.3333334),(5,1)'" +== 049 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 |&> '(49.99,49.99),(49.99,49.99)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 |&> '(49.99,49.99),(49.99,49.99)'" +== 050 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 |&> '(49.99,49.99),(49.99,49.99)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 |&> '(49.99,49.99),(49.99,49.99)'" +== 051 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 |>> '(37,38),(39,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 |>> '(37,38),(39,40)'" +== 052 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 |>> '(37,38),(39,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 |>> '(37,38),(39,40)'" +== 053 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 @> '(10,11),(15,16)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 @> '(10,11),(15,16)'" +== 054 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 @> '(10,11),(15,15)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 @> '(10,11),(15,15)'" +== 055 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 <@ '(10,15),(30,35)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 <@ '(10,15),(30,35)'" +== 056 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 <@ '(10,15),(30,35)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 <@ '(10,15),(30,35)'" +== 057 +-- truncate_limit: 100 +SELECT * FROM box_temp WHERE f1 ~= '(20,20),(40,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM box_temp WHERE f1 ~= '(20,20),(40,40)'" +== 058 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 ~= '(20,20),(40,40)' +-- +TABLE: name="box_temp" schema="" table="box_temp" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM box_temp WHERE f1 ~= '(20,20),(40,40)'" +== 059 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 060 +-- truncate_limit: 100 +DROP INDEX box_spgist +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX box_spgist" +== 061 +-- truncate_limit: 100 +|-- +-- Test the SP-GiST index on the larger volume of data +|-- +CREATE TABLE quad_box_tbl (id int, b box) +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quad_box_tbl (id int, b box)" +== 062 +-- truncate_limit: 100 +INSERT INTO quad_box_tbl + SELECT (x - 1) * 100 + y, box(point(x * 10, y * 10), point(x * 10 + 5, y * 10 + 5)) + FROM generate_series(1, 100) x, + generate_series(1, 100) y +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quad_box_tbl SELECT ... FROM generate_series(1, 100) x, generate_series(1, 100) y" +== 063 +-- truncate_limit: 100 +-- insert repeating data to test allTheSame +INSERT INTO quad_box_tbl + SELECT i, '((200, 300),(210, 310))' + FROM generate_series(10001, 11000) AS i +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quad_box_tbl SELECT i, '((200, 300),(210, 310))' FROM generate_series(10001, 11000) i" +== 064 +-- truncate_limit: 100 +INSERT INTO quad_box_tbl +VALUES + (11001, NULL), + (11002, NULL), + (11003, '((-infinity,-infinity),(infinity,infinity))'), + (11004, '((-infinity,100),(-infinity,500))'), + (11005, '((-infinity,-infinity),(700,infinity))') +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quad_box_tbl VALUES (...)" +== 065 +-- truncate_limit: 100 +CREATE INDEX quad_box_tbl_idx ON quad_box_tbl USING spgist(b) +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX quad_box_tbl_idx ON quad_box_tbl USING spgist (b)" +== 066 +-- truncate_limit: 100 +-- get reference results for ORDER BY distance from seq scan +SET enable_seqscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 067 +-- truncate_limit: 100 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 068 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 069 +-- truncate_limit: 100 +CREATE TABLE quad_box_tbl_ord_seq1 AS +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl +-- +TABLE: name="quad_box_tbl_ord_seq1" schema="" table="quad_box_tbl_ord_seq1" ctx=DDL +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE quad_box_tbl_ord_seq1 AS SELECT rank() OVER (ORDER BY b <-> point '123,456') AS n, ..." +== 070 +-- truncate_limit: 100 +CREATE TABLE quad_box_tbl_ord_seq2 AS +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl WHERE b <@ box '((200,300),(500,600))' +-- +TABLE: name="quad_box_tbl_ord_seq2" schema="" table="quad_box_tbl_ord_seq2" ctx=DDL +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE quad_box_tbl_ord_seq2 AS SELECT rank() OVER (ORDER BY b <-> point '123,456') AS n, ..." +== 071 +-- truncate_limit: 100 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 072 +-- truncate_limit: 100 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 073 +-- truncate_limit: 100 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 074 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b << box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b << '((100,200),(300,500))'::box" +== 075 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b &< box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b &< '((100,200),(300,500))'::box" +== 076 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b && box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b && '((100,200),(300,500))'::box" +== 077 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b &> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b &> '((100,200),(300,500))'::box" +== 078 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b >> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b >> '((100,200),(300,500))'::box" +== 079 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b >> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b >> '((100,200),(300,500))'::box" +== 080 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b <<| box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b <<| '((100,200),(300,500))'::box" +== 081 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b &<| box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b &<| '((100,200),(300,500))'::box" +== 082 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b |&> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b |&> '((100,200),(300,500))'::box" +== 083 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b |>> box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b |>> '((100,200),(300,500))'::box" +== 084 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b @> box '((201,301),(202,303))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b @> '((201,301),(202,303))'::box" +== 085 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b <@ box '((100,200),(300,500))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b <@ '((100,200),(300,500))'::box" +== 086 +-- truncate_limit: 100 +SELECT count(*) FROM quad_box_tbl WHERE b ~= box '((200,300),(205,305))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_box_tbl WHERE b ~= '((200,300),(205,305))'::box" +== 087 +-- truncate_limit: 100 +-- test ORDER BY distance +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 088 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 089 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT rank() OVER (ORDER BY b <-> point '123,456') AS n, b <-> point '123,..." +== 090 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_box_tbl_ord_idx1 AS +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl +-- +TABLE: name="quad_box_tbl_ord_idx1" schema="" table="quad_box_tbl_ord_idx1" ctx=DDL +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_box_tbl_ord_idx1 AS SELECT rank() OVER (ORDER BY b <-> point '123,45..." +== 091 +-- truncate_limit: 100 +SELECT * +FROM quad_box_tbl_ord_seq1 seq FULL JOIN quad_box_tbl_ord_idx1 idx + ON seq.n = idx.n AND seq.id = idx.id AND + (seq.dist = idx.dist OR seq.dist IS NULL AND idx.dist IS NULL) +WHERE seq.id IS NULL OR idx.id IS NULL +-- +TABLE: name="quad_box_tbl_ord_seq1" schema="" table="quad_box_tbl_ord_seq1" ctx=Select +TABLE: name="quad_box_tbl_ord_idx1" schema="" table="quad_box_tbl_ord_idx1" ctx=Select +ALIAS: "idx"="quad_box_tbl_ord_idx1" +ALIAS: "seq"="quad_box_tbl_ord_seq1" +FILTER: schema="" table="seq" column="id" +FILTER: schema="" table="idx" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_box_tbl_ord_seq1 seq FULL JOIN quad_box_tbl_ord_idx1 idx ON seq.n = idx.n AND ..." +== 092 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl WHERE b <@ box '((200,300),(500,600))' +-- +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT rank() OVER (ORDER BY b <-> point '123,456') AS n, b <-> point '123,..." +== 093 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_box_tbl_ord_idx2 AS +SELECT rank() OVER (ORDER BY b <-> point '123,456') n, b <-> point '123,456' dist, id +FROM quad_box_tbl WHERE b <@ box '((200,300),(500,600))' +-- +TABLE: name="quad_box_tbl_ord_idx2" schema="" table="quad_box_tbl_ord_idx2" ctx=DDL +TABLE: name="quad_box_tbl" schema="" table="quad_box_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_box_tbl_ord_idx2 AS SELECT rank() OVER (ORDER BY b <-> point '123,45..." +== 094 +-- truncate_limit: 100 +SELECT * +FROM quad_box_tbl_ord_seq2 seq FULL JOIN quad_box_tbl_ord_idx2 idx + ON seq.n = idx.n AND seq.id = idx.id AND + (seq.dist = idx.dist OR seq.dist IS NULL AND idx.dist IS NULL) +WHERE seq.id IS NULL OR idx.id IS NULL +-- +TABLE: name="quad_box_tbl_ord_seq2" schema="" table="quad_box_tbl_ord_seq2" ctx=Select +TABLE: name="quad_box_tbl_ord_idx2" schema="" table="quad_box_tbl_ord_idx2" ctx=Select +ALIAS: "idx"="quad_box_tbl_ord_idx2" +ALIAS: "seq"="quad_box_tbl_ord_seq2" +FILTER: schema="" table="seq" column="id" +FILTER: schema="" table="idx" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_box_tbl_ord_seq2 seq FULL JOIN quad_box_tbl_ord_idx2 idx ON seq.n = idx.n AND ..." +== 095 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 096 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 097 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 098 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('200', 'box') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('200', 'box')" +== 099 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('200', 'box') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('200', 'box')" +== 100 +-- truncate_limit: 100 +SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box')" +== 101 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('((200,300),(500, xyz))', 'box') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('((200,300),(500, xyz))', 'box')" diff --git a/parser/testdata/summary_truncate/postgres_regress/brin.metadata.json b/parser/testdata/summary_truncate/postgres_regress/brin.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/brin.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/brin.test b/parser/testdata/summary_truncate/postgres_regress/brin.test new file mode 100644 index 0000000..78ace09 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/brin.test @@ -0,0 +1,985 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE brintest (byteacol bytea, + charcol "char", + namecol name, + int8col bigint, + int2col smallint, + int4col integer, + textcol text, + oidcol oid, + tidcol tid, + float4col real, + float8col double precision, + macaddrcol macaddr, + inetcol inet, + cidrcol cidr, + bpcharcol character, + datecol date, + timecol time without time zone, + timestampcol timestamp without time zone, + timestamptzcol timestamp with time zone, + intervalcol interval, + timetzcol time with time zone, + bitcol bit(10), + varbitcol bit varying(16), + numericcol numeric, + uuidcol uuid, + int4rangecol int4range, + lsncol pg_lsn, + boxcol box +) WITH (fillfactor=10, autovacuum_enabled=off) +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brintest (byteacol bytea, charcol \"char\", namecol name, int8col bigint, int2col smal..." +== 002 +-- truncate_limit: 100 +INSERT INTO brintest SELECT + repeat(stringu1, 8)::bytea, + substr(stringu1, 1, 1)::"char", + stringu1::name, 142857 * tenthous, + thousand, + twothousand, + repeat(stringu1, 8), + unique1::oid, + format('(%s,%s)', tenthous, twenty)::tid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + inet '10.2.3.4/24' + tenthous, + cidr '10.2.3/24' + tenthous, + substr(stringu1, 1, 1)::bpchar, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20+02' + hundred * interval '15 seconds', + thousand::bit(10), + tenthous::bit(16)::varbit, + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + int4range(thousand, twothousand), + format('%s/%s%s', odd, even, tenthous)::pg_lsn, + box(point(odd, even), point(thousand, twothousand)) +FROM tenk1 ORDER BY unique2 LIMIT 100 +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest SELECT ... FROM tenk1 ORDER BY unique2 LIMIT 100" +== 003 +-- truncate_limit: 100 +-- throw in some NULL's and different values +INSERT INTO brintest (inetcol, cidrcol, int4rangecol) SELECT + inet 'fe80::6e40:8ff:fea9:8c46' + tenthous, + cidr 'fe80::6e40:8ff:fea9:8c46' + tenthous, + 'empty'::int4range +FROM tenk1 ORDER BY thousand, tenthous LIMIT 25 +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest (...) SELECT ... FROM tenk1 ORDER BY thousand, tenthous LIMIT 25" +== 004 +-- truncate_limit: 100 +CREATE INDEX brinidx ON brintest USING brin ( + byteacol, + charcol, + namecol, + int8col, + int2col, + int4col, + textcol, + oidcol, + tidcol, + float4col, + float8col, + macaddrcol, + inetcol inet_inclusion_ops, + inetcol inet_minmax_ops, + cidrcol inet_inclusion_ops, + cidrcol inet_minmax_ops, + bpcharcol, + datecol, + timecol, + timestampcol, + timestamptzcol, + intervalcol, + timetzcol, + bitcol, + varbitcol, + numericcol, + uuidcol, + int4rangecol, + lsncol, + boxcol +) with (pages_per_range = 1) +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx ON brintest USING brin (byteacol, charcol, namecol, int8col, int2col, int4co..." +== 005 +-- truncate_limit: 100 +CREATE TABLE brinopers (colname name, typ text, + op text[], value text[], matches int[], + check (cardinality(op) = cardinality(value)), + check (cardinality(op) = cardinality(matches))) +-- +TABLE: name="brinopers" schema="" table="brinopers" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brinopers (colname name, typ text, op text[], value text[], matches int[], CHECK (ca..." +== 006 +-- truncate_limit: 100 +INSERT INTO brinopers VALUES + ('byteacol', 'bytea', + '{>, >=, =, <=, <}', + '{AAAAAA, AAAAAA, BNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAA, ZZZZZZ, ZZZZZZ}', + '{100, 100, 1, 100, 100}'), + ('charcol', '"char"', + '{>, >=, =, <=, <}', + '{A, A, M, Z, Z}', + '{97, 100, 6, 100, 98}'), + ('namecol', 'name', + '{>, >=, =, <=, <}', + '{AAAAAA, AAAAAA, MAAAAA, ZZAAAA, ZZAAAA}', + '{100, 100, 2, 100, 100}'), + ('int2col', 'int2', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 999}', + '{100, 100, 1, 100, 100}'), + ('int2col', 'int4', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int2col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int2', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int4', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('int8col', 'int2', + '{>, >=}', + '{0, 0}', + '{100, 100}'), + ('int8col', 'int4', + '{>, >=}', + '{0, 0}', + '{100, 100}'), + ('int8col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 1257141600, 1428427143, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('textcol', 'text', + '{>, >=, =, <=, <}', + '{ABABAB, ABABAB, BNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAA, ZZAAAA, ZZAAAA}', + '{100, 100, 1, 100, 100}'), + ('oidcol', 'oid', + '{>, >=, =, <=, <}', + '{0, 0, 8800, 9999, 9999}', + '{100, 100, 1, 100, 100}'), + ('tidcol', 'tid', + '{>, >=, =, <=, <}', + '{"(0,0)", "(0,0)", "(8800,0)", "(9999,19)", "(9999,19)"}', + '{100, 100, 1, 100, 100}'), + ('float4col', 'float4', + '{>, >=, =, <=, <}', + '{0.0103093, 0.0103093, 1, 1, 1}', + '{100, 100, 4, 100, 96}'), + ('float4col', 'float8', + '{>, >=, =, <=, <}', + '{0.0103093, 0.0103093, 1, 1, 1}', + '{100, 100, 4, 100, 96}'), + ('float8col', 'float4', + '{>, >=, =, <=, <}', + '{0, 0, 0, 1.98, 1.98}', + '{99, 100, 1, 100, 100}'), + ('float8col', 'float8', + '{>, >=, =, <=, <}', + '{0, 0, 0, 1.98, 1.98}', + '{99, 100, 1, 100, 100}'), + ('macaddrcol', 'macaddr', + '{>, >=, =, <=, <}', + '{00:00:01:00:00:00, 00:00:01:00:00:00, 2c:00:2d:00:16:00, ff:fe:00:00:00:00, ff:fe:00:00:00:00}', + '{99, 100, 2, 100, 100}'), + ('inetcol', 'inet', + '{&&, =, <, <=, >, >=, >>=, >>, <<=, <<}', + '{10/8, 10.2.14.231/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0, 10.2.14.231/24, 10.2.14.231/25, 10.2.14.231/8, 0/0}', + '{100, 1, 100, 100, 125, 125, 2, 2, 100, 100}'), + ('inetcol', 'inet', + '{&&, >>=, <<=, =}', + '{fe80::6e40:8ff:fea9:a673/32, fe80::6e40:8ff:fea9:8c46, fe80::6e40:8ff:fea9:a673/32, fe80::6e40:8ff:fea9:8c46}', + '{25, 1, 25, 1}'), + ('inetcol', 'cidr', + '{&&, <, <=, >, >=, >>=, >>, <<=, <<}', + '{10/8, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0, 10.2.14/24, 10.2.14/25, 10/8, 0/0}', + '{100, 100, 100, 125, 125, 2, 2, 100, 100}'), + ('inetcol', 'cidr', + '{&&, >>=, <<=, =}', + '{fe80::/32, fe80::6e40:8ff:fea9:8c46, fe80::/32, fe80::6e40:8ff:fea9:8c46}', + '{25, 1, 25, 1}'), + ('cidrcol', 'inet', + '{&&, =, <, <=, >, >=, >>=, >>, <<=, <<}', + '{10/8, 10.2.14/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0, 10.2.14.231/24, 10.2.14.231/25, 10.2.14.231/8, 0/0}', + '{100, 2, 100, 100, 125, 125, 2, 2, 100, 100}'), + ('cidrcol', 'inet', + '{&&, >>=, <<=, =}', + '{fe80::6e40:8ff:fea9:a673/32, fe80::6e40:8ff:fea9:8c46, fe80::6e40:8ff:fea9:a673/32, fe80::6e40:8ff:fea9:8c46}', + '{25, 1, 25, 1}'), + ('cidrcol', 'cidr', + '{&&, =, <, <=, >, >=, >>=, >>, <<=, <<}', + '{10/8, 10.2.14/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0, 10.2.14/24, 10.2.14/25, 10/8, 0/0}', + '{100, 2, 100, 100, 125, 125, 2, 2, 100, 100}'), + ('cidrcol', 'cidr', + '{&&, >>=, <<=, =}', + '{fe80::/32, fe80::6e40:8ff:fea9:8c46, fe80::/32, fe80::6e40:8ff:fea9:8c46}', + '{25, 1, 25, 1}'), + ('bpcharcol', 'bpchar', + '{>, >=, =, <=, <}', + '{A, A, W, Z, Z}', + '{97, 100, 6, 100, 98}'), + ('datecol', 'date', + '{>, >=, =, <=, <}', + '{1995-08-15, 1995-08-15, 2009-12-01, 2022-12-30, 2022-12-30}', + '{100, 100, 1, 100, 100}'), + ('timecol', 'time', + '{>, >=, =, <=, <}', + '{01:20:30, 01:20:30, 02:28:57, 06:28:31.5, 06:28:31.5}', + '{100, 100, 1, 100, 100}'), + ('timestampcol', 'timestamp', + '{>, >=, =, <=, <}', + '{1942-07-23 03:05:09, 1942-07-23 03:05:09, 1964-03-24 19:26:45, 1984-01-20 22:42:21, 1984-01-20 22:42:21}', + '{100, 100, 1, 100, 100}'), + ('timestampcol', 'timestamptz', + '{>, >=, =, <=, <}', + '{1942-07-23 03:05:09, 1942-07-23 03:05:09, 1964-03-24 19:26:45, 1984-01-20 22:42:21, 1984-01-20 22:42:21}', + '{100, 100, 1, 100, 100}'), + ('timestamptzcol', 'timestamptz', + '{>, >=, =, <=, <}', + '{1972-10-10 03:00:00-04, 1972-10-10 03:00:00-04, 1972-10-19 09:00:00-07, 1972-11-20 19:00:00-03, 1972-11-20 19:00:00-03}', + '{100, 100, 1, 100, 100}'), + ('intervalcol', 'interval', + '{>, >=, =, <=, <}', + '{00:00:00, 00:00:00, 1 mons 13 days 12:24, 2 mons 23 days 07:48:00, 1 year}', + '{100, 100, 1, 100, 100}'), + ('timetzcol', 'timetz', + '{>, >=, =, <=, <}', + '{01:30:20+02, 01:30:20+02, 01:35:50+02, 23:55:05+02, 23:55:05+02}', + '{99, 100, 2, 100, 100}'), + ('bitcol', 'bit(10)', + '{>, >=, =, <=, <}', + '{0000000010, 0000000010, 0011011110, 1111111000, 1111111000}', + '{100, 100, 1, 100, 100}'), + ('varbitcol', 'varbit(16)', + '{>, >=, =, <=, <}', + '{0000000000000100, 0000000000000100, 0001010001100110, 1111111111111000, 1111111111111000}', + '{100, 100, 1, 100, 100}'), + ('numericcol', 'numeric', + '{>, >=, =, <=, <}', + '{0.00, 0.01, 2268164.347826086956521739130434782609, 99470151.9, 99470151.9}', + '{100, 100, 1, 100, 100}'), + ('uuidcol', 'uuid', + '{>, >=, =, <=, <}', + '{00040004-0004-0004-0004-000400040004, 00040004-0004-0004-0004-000400040004, 52225222-5222-5222-5222-522252225222, 99989998-9998-9998-9998-999899989998, 99989998-9998-9998-9998-999899989998}', + '{100, 100, 1, 100, 100}'), + ('int4rangecol', 'int4range', + '{<<, &<, &&, &>, >>, @>, <@, =, <, <=, >, >=}', + '{"[10000,)","[10000,)","(,]","[3,4)","[36,44)","(1500,1501]","[3,4)","[222,1222)","[36,44)","[43,1043)","[367,4466)","[519,)"}', + '{53, 53, 53, 53, 50, 22, 72, 1, 74, 75, 34, 21}'), + ('int4rangecol', 'int4range', + '{@>, <@, =, <=, >, >=}', + '{empty, empty, empty, empty, empty, empty}', + '{125, 72, 72, 72, 53, 125}'), + ('int4rangecol', 'int4', + '{@>}', + '{1500}', + '{22}'), + ('lsncol', 'pg_lsn', + '{>, >=, =, <=, <, IS, IS NOT}', + '{0/1200, 0/1200, 44/455222, 198/1999799, 198/1999799, NULL, NULL}', + '{100, 100, 1, 100, 100, 25, 100}'), + ('boxcol', 'point', + '{@>}', + '{"(500,43)"}', + '{11}'), + ('boxcol', 'box', + '{<<, &<, &&, &>, >>, <<|, &<|, |&>, |>>, @>, <@, ~=}', + '{"((1000,2000),(3000,4000))","((1,2),(3000,4000))","((1,2),(3000,4000))","((1,2),(3000,4000))","((1,2),(3,4))","((1000,2000),(3000,4000))","((1,2000),(3,4000))","((1000,2),(3000,4))","((1,2),(3,4))","((1,2),(300,400))","((1,2),(3000,4000))","((222,1222),(44,45))"}', + '{100, 100, 100, 99, 96, 100, 100, 99, 96, 1, 99, 1}') +-- +TABLE: name="brinopers" schema="" table="brinopers" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brinopers VALUES (...)" +== 007 +-- truncate_limit: 100 +DO $x$ +DECLARE + r record; + r2 record; + cond text; + idx_ctids tid[]; + ss_ctids tid[]; + count int; + plan_ok bool; + plan_line text; +BEGIN + FOR r IN SELECT colname, oper, typ, value[ordinality], matches[ordinality] FROM brinopers, unnest(op) WITH ORDINALITY AS oper LOOP + + -- prepare the condition + IF r.value IS NULL THEN + cond := format('%I %s %L', r.colname, r.oper, r.value); + ELSE + cond := format('%I %s %L::%s', r.colname, r.oper, r.value, r.typ); + END IF; + + -- run the query using the brin index + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Bitmap Heap Scan on brintest%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get bitmap indexscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest WHERE %s $y$, cond) + INTO idx_ctids; + + -- run the query using a seqscan + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Seq Scan on brintest%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get seqscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest WHERE %s $y$, cond) + INTO ss_ctids; + + -- make sure both return the same results + count := array_length(idx_ctids, 1); + + IF NOT (count = array_length(ss_ctids, 1) AND + idx_ctids @> ss_ctids AND + idx_ctids <@ ss_ctids) THEN + -- report the results of each scan to make the differences obvious + RAISE WARNING 'something not right in %: count %', r, count; + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest WHERE ' || cond LOOP + RAISE NOTICE 'seqscan: %', r2; + END LOOP; + + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest WHERE ' || cond LOOP + RAISE NOTICE 'bitmapscan: %', r2; + END LOOP; + END IF; + + -- make sure we found expected number of matches + IF count != r.matches THEN RAISE WARNING 'unexpected number of results % for %', count, r; END IF; + END LOOP; +END; +$x$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n\tr record;\n\tr2 record;\n\tcond text;\n\tidx_ctids tid[];\n\tss_ctids tid[];\n\tcount int;\n\t..." +== 008 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 009 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 010 +-- truncate_limit: 100 +INSERT INTO brintest SELECT + repeat(stringu1, 42)::bytea, + substr(stringu1, 1, 1)::"char", + stringu1::name, 142857 * tenthous, + thousand, + twothousand, + repeat(stringu1, 42), + unique1::oid, + format('(%s,%s)', tenthous, twenty)::tid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + inet '10.2.3.4' + tenthous, + cidr '10.2.3/24' + tenthous, + substr(stringu1, 1, 1)::bpchar, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20' + hundred * interval '15 seconds', + thousand::bit(10), + tenthous::bit(16)::varbit, + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + int4range(thousand, twothousand), + format('%s/%s%s', odd, even, tenthous)::pg_lsn, + box(point(odd, even), point(thousand, twothousand)) +FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5 +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest SELECT ... FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5" +== 011 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx', 0)" +== 012 +-- truncate_limit: 100 +VACUUM brintest +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM brintest" +== 013 +-- truncate_limit: 100 +-- force a summarization cycle in brinidx + +UPDATE brintest SET int8col = int8col * int4col +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brintest SET int8col = int8col * int4col" +== 014 +-- truncate_limit: 100 +UPDATE brintest SET textcol = '' WHERE textcol IS NOT NULL +-- +TABLE: name="brintest" schema="" table="brintest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brintest SET textcol = '' WHERE textcol IS NOT NULL" +== 015 +-- truncate_limit: 100 +-- Tests for brin_summarize_new_values +SELECT brin_summarize_new_values('brintest') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('brintest')" +== 016 +-- truncate_limit: 100 +-- error, not an index +SELECT brin_summarize_new_values('tenk1_unique1') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('tenk1_unique1')" +== 017 +-- truncate_limit: 100 +-- error, not a BRIN index +SELECT brin_summarize_new_values('brinidx') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('brinidx')" +== 018 +-- truncate_limit: 100 +-- ok, no change expected + +-- Tests for brin_desummarize_range +SELECT brin_desummarize_range('brinidx', -1) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx', -1)" +== 019 +-- truncate_limit: 100 +-- error, invalid range +SELECT brin_desummarize_range('brinidx', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx', 0)" +== 020 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx', 0)" +== 021 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx', 100000000) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx', 100000000)" +== 022 +-- truncate_limit: 100 +-- Test brin_summarize_range +CREATE TABLE brin_summarize ( + value int +) WITH (fillfactor=10, autovacuum_enabled=false) +-- +TABLE: name="brin_summarize" schema="" table="brin_summarize" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_summarize (value int) WITH (fillfactor=10, autovacuum_enabled=false)" +== 023 +-- truncate_limit: 100 +CREATE INDEX brin_summarize_idx ON brin_summarize USING brin (value) WITH (pages_per_range=2) +-- +TABLE: name="brin_summarize" schema="" table="brin_summarize" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_summarize_idx ON brin_summarize USING brin (value) WITH (pages_per_range=2)" +== 024 +-- truncate_limit: 100 +-- Fill a few pages +DO $$ +DECLARE curtid tid; +BEGIN + LOOP + INSERT INTO brin_summarize VALUES (1) RETURNING ctid INTO curtid; + EXIT WHEN curtid > tid '(2, 0)'; + END LOOP; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE curtid tid;\nBEGIN\n LOOP\n INSERT INTO brin_summarize VALUES (1) RETURNING ctid I..." +== 025 +-- truncate_limit: 100 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_idx', 0) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_idx', 0)" +== 026 +-- truncate_limit: 100 +-- nothing: already summarized +SELECT brin_summarize_range('brin_summarize_idx', 1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_idx', 1)" +== 027 +-- truncate_limit: 100 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_idx', 2) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_idx', 2)" +== 028 +-- truncate_limit: 100 +-- nothing: page doesn't exist in table +SELECT brin_summarize_range('brin_summarize_idx', 4294967295) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_idx', 4294967295)" +== 029 +-- truncate_limit: 100 +-- invalid block number values +SELECT brin_summarize_range('brin_summarize_idx', -1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_idx', -1)" +== 030 +-- truncate_limit: 100 +SELECT brin_summarize_range('brin_summarize_idx', 4294967296) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_idx', 4294967296)" +== 031 +-- truncate_limit: 100 +-- test value merging in add_value +CREATE TABLE brintest_2 (n numrange) +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brintest_2 (n numrange)" +== 032 +-- truncate_limit: 100 +CREATE INDEX brinidx_2 ON brintest_2 USING brin (n) +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_2 ON brintest_2 USING brin (n)" +== 033 +-- truncate_limit: 100 +INSERT INTO brintest_2 VALUES ('empty') +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_2 VALUES ('empty')" +== 034 +-- truncate_limit: 100 +INSERT INTO brintest_2 VALUES (numrange(0, 2^1000::numeric)) +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_2 VALUES (numrange(0, 2 ^ 1000::numeric))" +== 035 +-- truncate_limit: 100 +INSERT INTO brintest_2 VALUES ('(-1, 0)') +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_2 VALUES ('(-1, 0)')" +== 036 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx', 0)" +== 037 +-- truncate_limit: 100 +SELECT brin_summarize_range('brinidx', 0) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brinidx', 0)" +== 038 +-- truncate_limit: 100 +DROP TABLE brintest_2 +-- +TABLE: name="brintest_2" schema="" table="brintest_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brintest_2" +== 039 +-- truncate_limit: 100 +-- test brin cost estimates behave sanely based on correlation of values +CREATE TABLE brin_test (a INT, b INT) +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_test (a int, b int)" +== 040 +-- truncate_limit: 100 +INSERT INTO brin_test SELECT x/100,x%100 FROM generate_series(1,10000) x(x) +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test SELECT x / 100, x % 100 FROM generate_series(1, 10000) x(x)" +== 041 +-- truncate_limit: 100 +CREATE INDEX brin_test_a_idx ON brin_test USING brin (a) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_a_idx ON brin_test USING brin (a) WITH (pages_per_range=2)" +== 042 +-- truncate_limit: 100 +CREATE INDEX brin_test_b_idx ON brin_test USING brin (b) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_b_idx ON brin_test USING brin (b) WITH (pages_per_range=2)" +== 043 +-- truncate_limit: 100 +VACUUM ANALYZE brin_test +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) brin_test" +== 044 +-- truncate_limit: 100 +-- Ensure brin index is used when columns are perfectly correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test WHERE a = 1 +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_test WHERE a = 1" +== 045 +-- truncate_limit: 100 +-- Ensure brin index is not used when values are not correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test WHERE b = 1 +-- +TABLE: name="brin_test" schema="" table="brin_test" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_test WHERE b = 1" +== 046 +-- truncate_limit: 100 +-- make sure data are properly de-toasted in BRIN index +CREATE TABLE brintest_3 (a text, b text, c text, d text) +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brintest_3 (a text, b text, c text, d text)" +== 047 +-- truncate_limit: 100 +-- long random strings (~2000 chars each, so ~6kB for min/max on two +-- columns) to trigger toasting +WITH rand_value AS (SELECT string_agg(fipshash(i::text),'') AS val FROM generate_series(1,60) s(i)) +INSERT INTO brintest_3 +SELECT val, val, val, val FROM rand_value +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DML +CTE: "rand_value" +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH rand_value AS (...) INSERT INTO brintest_3 SELECT val, val, val, val FROM rand_value" +== 048 +-- truncate_limit: 100 +CREATE INDEX brin_test_toast_idx ON brintest_3 USING brin (b, c) +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_toast_idx ON brintest_3 USING brin (b, c)" +== 049 +-- truncate_limit: 100 +DELETE FROM brintest_3 +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM brintest_3" +== 050 +-- truncate_limit: 100 +-- We need to wait a bit for all transactions to complete, so that the +-- vacuum actually removes the TOAST rows. Creating an index concurrently +-- is a one way to achieve that, because it does exactly such wait. +CREATE INDEX CONCURRENTLY brin_test_temp_idx ON brintest_3(a) +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY brin_test_temp_idx ON brintest_3 USING btree (a)" +== 051 +-- truncate_limit: 100 +DROP INDEX brin_test_temp_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX brin_test_temp_idx" +== 052 +-- truncate_limit: 100 +-- vacuum the table, to discard TOAST data +VACUUM brintest_3 +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM brintest_3" +== 053 +-- truncate_limit: 100 +-- retry insert with a different random-looking (but deterministic) value +-- the value is different, and so should replace either min or max in the +-- brin summary +WITH rand_value AS (SELECT string_agg(fipshash((-i)::text),'') AS val FROM generate_series(1,60) s(i)) +INSERT INTO brintest_3 +SELECT val, val, val, val FROM rand_value +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DML +CTE: "rand_value" +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH rand_value AS (...) INSERT INTO brintest_3 SELECT val, val, val, val FROM rand_value" +== 054 +-- truncate_limit: 100 +-- now try some queries, accessing the brin index +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 055 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM brintest_3 WHERE b < '0' +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brintest_3 WHERE b < '0'" +== 056 +-- truncate_limit: 100 +SELECT * FROM brintest_3 WHERE b < '0' +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM brintest_3 WHERE b < '0'" +== 057 +-- truncate_limit: 100 +DROP TABLE brintest_3 +-- +TABLE: name="brintest_3" schema="" table="brintest_3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brintest_3" +== 058 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 059 +-- truncate_limit: 100 +-- test an unlogged table, mostly to get coverage of brinbuildempty +CREATE UNLOGGED TABLE brintest_unlogged (n numrange) +-- +TABLE: name="brintest_unlogged" schema="" table="brintest_unlogged" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE brintest_unlogged (n numrange)" +== 060 +-- truncate_limit: 100 +CREATE INDEX brinidx_unlogged ON brintest_unlogged USING brin (n) +-- +TABLE: name="brintest_unlogged" schema="" table="brintest_unlogged" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_unlogged ON brintest_unlogged USING brin (n)" +== 061 +-- truncate_limit: 100 +INSERT INTO brintest_unlogged VALUES (numrange(0, 2^1000::numeric)) +-- +TABLE: name="brintest_unlogged" schema="" table="brintest_unlogged" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_unlogged VALUES (numrange(0, 2 ^ 1000::numeric))" +== 062 +-- truncate_limit: 100 +DROP TABLE brintest_unlogged +-- +TABLE: name="brintest_unlogged" schema="" table="brintest_unlogged" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brintest_unlogged" +== 063 +-- truncate_limit: 100 +-- test that the insert optimization works if no rows end up inserted +CREATE TABLE brin_insert_optimization (a int) +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_insert_optimization (a int)" +== 064 +-- truncate_limit: 100 +INSERT INTO brin_insert_optimization VALUES (1) +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_insert_optimization VALUES (1)" +== 065 +-- truncate_limit: 100 +CREATE INDEX brin_insert_optimization_idx ON brin_insert_optimization USING brin (a) +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_insert_optimization_idx ON brin_insert_optimization USING brin (a)" +== 066 +-- truncate_limit: 100 +UPDATE brin_insert_optimization SET a = a +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brin_insert_optimization SET a = a" +== 067 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY brin_insert_optimization_idx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX brin_insert_optimization_idx" +== 068 +-- truncate_limit: 100 +DROP TABLE brin_insert_optimization +-- +TABLE: name="brin_insert_optimization" schema="" table="brin_insert_optimization" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_insert_optimization" diff --git a/parser/testdata/summary_truncate/postgres_regress/brin_bloom.metadata.json b/parser/testdata/summary_truncate/postgres_regress/brin_bloom.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/brin_bloom.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/brin_bloom.test b/parser/testdata/summary_truncate/postgres_regress/brin_bloom.test new file mode 100644 index 0000000..199a2e2 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/brin_bloom.test @@ -0,0 +1,654 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE brintest_bloom (byteacol bytea, + charcol "char", + namecol name, + int8col bigint, + int2col smallint, + int4col integer, + textcol text, + oidcol oid, + float4col real, + float8col double precision, + macaddrcol macaddr, + inetcol inet, + cidrcol cidr, + bpcharcol character, + datecol date, + timecol time without time zone, + timestampcol timestamp without time zone, + timestamptzcol timestamp with time zone, + intervalcol interval, + timetzcol time with time zone, + numericcol numeric, + uuidcol uuid, + lsncol pg_lsn +) WITH (fillfactor=10) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brintest_bloom (byteacol bytea, charcol \"char\", namecol name, int8col bigint, int2co..." +== 002 +-- truncate_limit: 100 +INSERT INTO brintest_bloom SELECT + repeat(stringu1, 8)::bytea, + substr(stringu1, 1, 1)::"char", + stringu1::name, 142857 * tenthous, + thousand, + twothousand, + repeat(stringu1, 8), + unique1::oid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + inet '10.2.3.4/24' + tenthous, + cidr '10.2.3/24' + tenthous, + substr(stringu1, 1, 1)::bpchar, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20+02' + hundred * interval '15 seconds', + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + format('%s/%s%s', odd, even, tenthous)::pg_lsn +FROM tenk1 ORDER BY unique2 LIMIT 100 +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_bloom SELECT ... FROM tenk1 ORDER BY unique2 LIMIT 100" +== 003 +-- truncate_limit: 100 +-- throw in some NULL's and different values +INSERT INTO brintest_bloom (inetcol, cidrcol) SELECT + inet 'fe80::6e40:8ff:fea9:8c46' + tenthous, + cidr 'fe80::6e40:8ff:fea9:8c46' + tenthous +FROM tenk1 ORDER BY thousand, tenthous LIMIT 25 +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_bloom (...) SELECT ... FROM tenk1 ORDER BY thousand, tenthous LIMIT 25" +== 004 +-- truncate_limit: 100 +-- test bloom specific index options +-- ndistinct must be >= -1.0 +CREATE INDEX brinidx_bloom ON brintest_bloom USING brin ( + byteacol bytea_bloom_ops(n_distinct_per_range = -1.1) +) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_bloom ON brintest_bloom USING brin (byteacol bytea_bloom_ops(n_distinct_per_..." +== 005 +-- truncate_limit: 100 +-- false_positive_rate must be between 0.0001 and 0.25 +CREATE INDEX brinidx_bloom ON brintest_bloom USING brin ( + byteacol bytea_bloom_ops(false_positive_rate = 0.00009) +) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_bloom ON brintest_bloom USING brin (byteacol bytea_bloom_ops(false_positive_..." +== 006 +-- truncate_limit: 100 +CREATE INDEX brinidx_bloom ON brintest_bloom USING brin ( + byteacol bytea_bloom_ops(false_positive_rate = 0.26) +) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_bloom ON brintest_bloom USING brin (byteacol bytea_bloom_ops(false_positive_..." +== 007 +-- truncate_limit: 100 +CREATE INDEX brinidx_bloom ON brintest_bloom USING brin ( + byteacol bytea_bloom_ops, + charcol char_bloom_ops, + namecol name_bloom_ops, + int8col int8_bloom_ops, + int2col int2_bloom_ops, + int4col int4_bloom_ops, + textcol text_bloom_ops, + oidcol oid_bloom_ops, + float4col float4_bloom_ops, + float8col float8_bloom_ops, + macaddrcol macaddr_bloom_ops, + inetcol inet_bloom_ops, + cidrcol inet_bloom_ops, + bpcharcol bpchar_bloom_ops, + datecol date_bloom_ops, + timecol time_bloom_ops, + timestampcol timestamp_bloom_ops, + timestamptzcol timestamptz_bloom_ops, + intervalcol interval_bloom_ops, + timetzcol timetz_bloom_ops, + numericcol numeric_bloom_ops, + uuidcol uuid_bloom_ops, + lsncol pg_lsn_bloom_ops +) with (pages_per_range = 1) +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_bloom ON brintest_bloom USING brin (byteacol bytea_bloom_ops, charcol char_b..." +== 008 +-- truncate_limit: 100 +CREATE TABLE brinopers_bloom (colname name, typ text, + op text[], value text[], matches int[], + check (cardinality(op) = cardinality(value)), + check (cardinality(op) = cardinality(matches))) +-- +TABLE: name="brinopers_bloom" schema="" table="brinopers_bloom" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brinopers_bloom (colname name, typ text, op text[], value text[], matches int[], CHE..." +== 009 +-- truncate_limit: 100 +INSERT INTO brinopers_bloom VALUES + ('byteacol', 'bytea', + '{=}', + '{BNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAA}', + '{1}'), + ('charcol', '"char"', + '{=}', + '{M}', + '{6}'), + ('namecol', 'name', + '{=}', + '{MAAAAA}', + '{2}'), + ('int2col', 'int2', + '{=}', + '{800}', + '{1}'), + ('int4col', 'int4', + '{=}', + '{800}', + '{1}'), + ('int8col', 'int8', + '{=}', + '{1257141600}', + '{1}'), + ('textcol', 'text', + '{=}', + '{BNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAABNAAAA}', + '{1}'), + ('oidcol', 'oid', + '{=}', + '{8800}', + '{1}'), + ('float4col', 'float4', + '{=}', + '{1}', + '{4}'), + ('float8col', 'float8', + '{=}', + '{0}', + '{1}'), + ('macaddrcol', 'macaddr', + '{=}', + '{2c:00:2d:00:16:00}', + '{2}'), + ('inetcol', 'inet', + '{=}', + '{10.2.14.231/24}', + '{1}'), + ('inetcol', 'cidr', + '{=}', + '{fe80::6e40:8ff:fea9:8c46}', + '{1}'), + ('cidrcol', 'inet', + '{=}', + '{10.2.14/24}', + '{2}'), + ('cidrcol', 'inet', + '{=}', + '{fe80::6e40:8ff:fea9:8c46}', + '{1}'), + ('cidrcol', 'cidr', + '{=}', + '{10.2.14/24}', + '{2}'), + ('cidrcol', 'cidr', + '{=}', + '{fe80::6e40:8ff:fea9:8c46}', + '{1}'), + ('bpcharcol', 'bpchar', + '{=}', + '{W}', + '{6}'), + ('datecol', 'date', + '{=}', + '{2009-12-01}', + '{1}'), + ('timecol', 'time', + '{=}', + '{02:28:57}', + '{1}'), + ('timestampcol', 'timestamp', + '{=}', + '{1964-03-24 19:26:45}', + '{1}'), + ('timestamptzcol', 'timestamptz', + '{=}', + '{1972-10-19 09:00:00-07}', + '{1}'), + ('intervalcol', 'interval', + '{=}', + '{1 mons 13 days 12:24}', + '{1}'), + ('timetzcol', 'timetz', + '{=}', + '{01:35:50+02}', + '{2}'), + ('numericcol', 'numeric', + '{=}', + '{2268164.347826086956521739130434782609}', + '{1}'), + ('uuidcol', 'uuid', + '{=}', + '{52225222-5222-5222-5222-522252225222}', + '{1}'), + ('lsncol', 'pg_lsn', + '{=, IS, IS NOT}', + '{44/455222, NULL, NULL}', + '{1, 25, 100}') +-- +TABLE: name="brinopers_bloom" schema="" table="brinopers_bloom" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brinopers_bloom VALUES (...)" +== 010 +-- truncate_limit: 100 +DO $x$ +DECLARE + r record; + r2 record; + cond text; + idx_ctids tid[]; + ss_ctids tid[]; + count int; + plan_ok bool; + plan_line text; +BEGIN + FOR r IN SELECT colname, oper, typ, value[ordinality], matches[ordinality] FROM brinopers_bloom, unnest(op) WITH ORDINALITY AS oper LOOP + + -- prepare the condition + IF r.value IS NULL THEN + cond := format('%I %s %L', r.colname, r.oper, r.value); + ELSE + cond := format('%I %s %L::%s', r.colname, r.oper, r.value, r.typ); + END IF; + + -- run the query using the brin index + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest_bloom WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Bitmap Heap Scan on brintest_bloom%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get bitmap indexscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest_bloom WHERE %s $y$, cond) + INTO idx_ctids; + + -- run the query using a seqscan + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest_bloom WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Seq Scan on brintest_bloom%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get seqscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest_bloom WHERE %s $y$, cond) + INTO ss_ctids; + + -- make sure both return the same results + count := array_length(idx_ctids, 1); + + IF NOT (count = array_length(ss_ctids, 1) AND + idx_ctids @> ss_ctids AND + idx_ctids <@ ss_ctids) THEN + -- report the results of each scan to make the differences obvious + RAISE WARNING 'something not right in %: count %', r, count; + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest_bloom WHERE ' || cond LOOP + RAISE NOTICE 'seqscan: %', r2; + END LOOP; + + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest_bloom WHERE ' || cond LOOP + RAISE NOTICE 'bitmapscan: %', r2; + END LOOP; + END IF; + + -- make sure we found expected number of matches + IF count != r.matches THEN RAISE WARNING 'unexpected number of results % for %', count, r; END IF; + END LOOP; +END; +$x$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n\tr record;\n\tr2 record;\n\tcond text;\n\tidx_ctids tid[];\n\tss_ctids tid[];\n\tcount int;\n\t..." +== 011 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 012 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 013 +-- truncate_limit: 100 +INSERT INTO brintest_bloom SELECT + repeat(stringu1, 42)::bytea, + substr(stringu1, 1, 1)::"char", + stringu1::name, 142857 * tenthous, + thousand, + twothousand, + repeat(stringu1, 42), + unique1::oid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + inet '10.2.3.4' + tenthous, + cidr '10.2.3/24' + tenthous, + substr(stringu1, 1, 1)::bpchar, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20' + hundred * interval '15 seconds', + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + format('%s/%s%s', odd, even, tenthous)::pg_lsn +FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5 +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_bloom SELECT ... FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5" +== 014 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx_bloom', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_bloom', 0)" +== 015 +-- truncate_limit: 100 +VACUUM brintest_bloom +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM brintest_bloom" +== 016 +-- truncate_limit: 100 +-- force a summarization cycle in brinidx + +UPDATE brintest_bloom SET int8col = int8col * int4col +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brintest_bloom SET int8col = int8col * int4col" +== 017 +-- truncate_limit: 100 +UPDATE brintest_bloom SET textcol = '' WHERE textcol IS NOT NULL +-- +TABLE: name="brintest_bloom" schema="" table="brintest_bloom" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brintest_bloom SET textcol = '' WHERE textcol IS NOT NULL" +== 018 +-- truncate_limit: 100 +-- Tests for brin_summarize_new_values +SELECT brin_summarize_new_values('brintest_bloom') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('brintest_bloom')" +== 019 +-- truncate_limit: 100 +-- error, not an index +SELECT brin_summarize_new_values('tenk1_unique1') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('tenk1_unique1')" +== 020 +-- truncate_limit: 100 +-- error, not a BRIN index +SELECT brin_summarize_new_values('brinidx_bloom') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('brinidx_bloom')" +== 021 +-- truncate_limit: 100 +-- ok, no change expected + +-- Tests for brin_desummarize_range +SELECT brin_desummarize_range('brinidx_bloom', -1) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_bloom', -1)" +== 022 +-- truncate_limit: 100 +-- error, invalid range +SELECT brin_desummarize_range('brinidx_bloom', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_bloom', 0)" +== 023 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx_bloom', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_bloom', 0)" +== 024 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx_bloom', 100000000) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_bloom', 100000000)" +== 025 +-- truncate_limit: 100 +-- Test brin_summarize_range +CREATE TABLE brin_summarize_bloom ( + value int +) WITH (fillfactor=10, autovacuum_enabled=false) +-- +TABLE: name="brin_summarize_bloom" schema="" table="brin_summarize_bloom" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_summarize_bloom (value int) WITH (fillfactor=10, autovacuum_enabled=false)" +== 026 +-- truncate_limit: 100 +CREATE INDEX brin_summarize_bloom_idx ON brin_summarize_bloom USING brin (value) WITH (pages_per_range=2) +-- +TABLE: name="brin_summarize_bloom" schema="" table="brin_summarize_bloom" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_summarize_bloom_idx ON brin_summarize_bloom USING brin (value) WITH (pages_per_..." +== 027 +-- truncate_limit: 100 +-- Fill a few pages +DO $$ +DECLARE curtid tid; +BEGIN + LOOP + INSERT INTO brin_summarize_bloom VALUES (1) RETURNING ctid INTO curtid; + EXIT WHEN curtid > tid '(2, 0)'; + END LOOP; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE curtid tid;\nBEGIN\n LOOP\n INSERT INTO brin_summarize_bloom VALUES (1) RETURNING ..." +== 028 +-- truncate_limit: 100 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_bloom_idx', 0) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_bloom_idx', 0)" +== 029 +-- truncate_limit: 100 +-- nothing: already summarized +SELECT brin_summarize_range('brin_summarize_bloom_idx', 1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_bloom_idx', 1)" +== 030 +-- truncate_limit: 100 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_bloom_idx', 2) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_bloom_idx', 2)" +== 031 +-- truncate_limit: 100 +-- nothing: page doesn't exist in table +SELECT brin_summarize_range('brin_summarize_bloom_idx', 4294967295) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_bloom_idx', 4294967295)" +== 032 +-- truncate_limit: 100 +-- invalid block number values +SELECT brin_summarize_range('brin_summarize_bloom_idx', -1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_bloom_idx', -1)" +== 033 +-- truncate_limit: 100 +SELECT brin_summarize_range('brin_summarize_bloom_idx', 4294967296) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_bloom_idx', 4294967296)" +== 034 +-- truncate_limit: 100 +-- test brin cost estimates behave sanely based on correlation of values +CREATE TABLE brin_test_bloom (a INT, b INT) +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_test_bloom (a int, b int)" +== 035 +-- truncate_limit: 100 +INSERT INTO brin_test_bloom SELECT x/100,x%100 FROM generate_series(1,10000) x(x) +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test_bloom SELECT x / 100, x % 100 FROM generate_series(1, 10000) x(x)" +== 036 +-- truncate_limit: 100 +CREATE INDEX brin_test_bloom_a_idx ON brin_test_bloom USING brin (a) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_bloom_a_idx ON brin_test_bloom USING brin (a) WITH (pages_per_range=2)" +== 037 +-- truncate_limit: 100 +CREATE INDEX brin_test_bloom_b_idx ON brin_test_bloom USING brin (b) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_bloom_b_idx ON brin_test_bloom USING brin (b) WITH (pages_per_range=2)" +== 038 +-- truncate_limit: 100 +VACUUM ANALYZE brin_test_bloom +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) brin_test_bloom" +== 039 +-- truncate_limit: 100 +-- Ensure brin index is used when columns are perfectly correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test_bloom WHERE a = 1 +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_test_bloom WHERE a = 1" +== 040 +-- truncate_limit: 100 +-- Ensure brin index is not used when values are not correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test_bloom WHERE b = 1 +-- +TABLE: name="brin_test_bloom" schema="" table="brin_test_bloom" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_test_bloom WHERE b = 1" diff --git a/parser/testdata/summary_truncate/postgres_regress/brin_multi.metadata.json b/parser/testdata/summary_truncate/postgres_regress/brin_multi.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/brin_multi.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/brin_multi.test b/parser/testdata/summary_truncate/postgres_regress/brin_multi.test new file mode 100644 index 0000000..597bcd4 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/brin_multi.test @@ -0,0 +1,1810 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE brintest_multi ( + int8col bigint, + int2col smallint, + int4col integer, + oidcol oid, + tidcol tid, + float4col real, + float8col double precision, + macaddrcol macaddr, + macaddr8col macaddr8, + inetcol inet, + cidrcol cidr, + datecol date, + timecol time without time zone, + timestampcol timestamp without time zone, + timestamptzcol timestamp with time zone, + intervalcol interval, + timetzcol time with time zone, + numericcol numeric, + uuidcol uuid, + lsncol pg_lsn +) WITH (fillfactor=10) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brintest_multi (int8col bigint, int2col smallint, int4col int, oidcol oid, tidcol ti..." +== 002 +-- truncate_limit: 100 +INSERT INTO brintest_multi SELECT + 142857 * tenthous, + thousand, + twothousand, + unique1::oid, + format('(%s,%s)', tenthous, twenty)::tid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + substr(fipshash(unique1::text), 1, 16)::macaddr8, + inet '10.2.3.4/24' + tenthous, + cidr '10.2.3/24' + tenthous, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20+02' + hundred * interval '15 seconds', + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + format('%s/%s%s', odd, even, tenthous)::pg_lsn +FROM tenk1 ORDER BY unique2 LIMIT 100 +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_multi SELECT ... FROM tenk1 ORDER BY unique2 LIMIT 100" +== 003 +-- truncate_limit: 100 +-- throw in some NULL's and different values +INSERT INTO brintest_multi (inetcol, cidrcol) SELECT + inet 'fe80::6e40:8ff:fea9:8c46' + tenthous, + cidr 'fe80::6e40:8ff:fea9:8c46' + tenthous +FROM tenk1 ORDER BY thousand, tenthous LIMIT 25 +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_multi (...) SELECT ... FROM tenk1 ORDER BY thousand, tenthous LIMIT 25" +== 004 +-- truncate_limit: 100 +-- test minmax-multi specific index options +-- number of values must be >= 16 +CREATE INDEX brinidx_multi ON brintest_multi USING brin ( + int8col int8_minmax_multi_ops(values_per_range = 7) +) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_multi ON brintest_multi USING brin (int8col int8_minmax_multi_ops(values_per..." +== 005 +-- truncate_limit: 100 +-- number of values must be <= 256 +CREATE INDEX brinidx_multi ON brintest_multi USING brin ( + int8col int8_minmax_multi_ops(values_per_range = 257) +) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_multi ON brintest_multi USING brin (int8col int8_minmax_multi_ops(values_per..." +== 006 +-- truncate_limit: 100 +-- first create an index with a single page range, to force compaction +-- due to exceeding the number of values per summary +CREATE INDEX brinidx_multi ON brintest_multi USING brin ( + int8col int8_minmax_multi_ops, + int2col int2_minmax_multi_ops, + int4col int4_minmax_multi_ops, + oidcol oid_minmax_multi_ops, + tidcol tid_minmax_multi_ops, + float4col float4_minmax_multi_ops, + float8col float8_minmax_multi_ops, + macaddrcol macaddr_minmax_multi_ops, + macaddr8col macaddr8_minmax_multi_ops, + inetcol inet_minmax_multi_ops, + cidrcol inet_minmax_multi_ops, + datecol date_minmax_multi_ops, + timecol time_minmax_multi_ops, + timestampcol timestamp_minmax_multi_ops, + timestamptzcol timestamptz_minmax_multi_ops, + intervalcol interval_minmax_multi_ops, + timetzcol timetz_minmax_multi_ops, + numericcol numeric_minmax_multi_ops, + uuidcol uuid_minmax_multi_ops, + lsncol pg_lsn_minmax_multi_ops +) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_multi ON brintest_multi USING brin (int8col int8_minmax_multi_ops, int2col i..." +== 007 +-- truncate_limit: 100 +DROP INDEX brinidx_multi +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX brinidx_multi" +== 008 +-- truncate_limit: 100 +CREATE INDEX brinidx_multi ON brintest_multi USING brin ( + int8col int8_minmax_multi_ops, + int2col int2_minmax_multi_ops, + int4col int4_minmax_multi_ops, + oidcol oid_minmax_multi_ops, + tidcol tid_minmax_multi_ops, + float4col float4_minmax_multi_ops, + float8col float8_minmax_multi_ops, + macaddrcol macaddr_minmax_multi_ops, + macaddr8col macaddr8_minmax_multi_ops, + inetcol inet_minmax_multi_ops, + cidrcol inet_minmax_multi_ops, + datecol date_minmax_multi_ops, + timecol time_minmax_multi_ops, + timestampcol timestamp_minmax_multi_ops, + timestamptzcol timestamptz_minmax_multi_ops, + intervalcol interval_minmax_multi_ops, + timetzcol timetz_minmax_multi_ops, + numericcol numeric_minmax_multi_ops, + uuidcol uuid_minmax_multi_ops, + lsncol pg_lsn_minmax_multi_ops +) with (pages_per_range = 1) +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brinidx_multi ON brintest_multi USING brin (int8col int8_minmax_multi_ops, int2col i..." +== 009 +-- truncate_limit: 100 +CREATE TABLE brinopers_multi (colname name, typ text, + op text[], value text[], matches int[], + check (cardinality(op) = cardinality(value)), + check (cardinality(op) = cardinality(matches))) +-- +TABLE: name="brinopers_multi" schema="" table="brinopers_multi" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brinopers_multi (colname name, typ text, op text[], value text[], matches int[], CHE..." +== 010 +-- truncate_limit: 100 +INSERT INTO brinopers_multi VALUES + ('int2col', 'int2', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 999}', + '{100, 100, 1, 100, 100}'), + ('int2col', 'int4', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int2col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 800, 999, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int2', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int4', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1999}', + '{100, 100, 1, 100, 100}'), + ('int4col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 800, 1999, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('int8col', 'int2', + '{>, >=}', + '{0, 0}', + '{100, 100}'), + ('int8col', 'int4', + '{>, >=}', + '{0, 0}', + '{100, 100}'), + ('int8col', 'int8', + '{>, >=, =, <=, <}', + '{0, 0, 1257141600, 1428427143, 1428427143}', + '{100, 100, 1, 100, 100}'), + ('oidcol', 'oid', + '{>, >=, =, <=, <}', + '{0, 0, 8800, 9999, 9999}', + '{100, 100, 1, 100, 100}'), + ('tidcol', 'tid', + '{>, >=, =, <=, <}', + '{"(0,0)", "(0,0)", "(8800,0)", "(9999,19)", "(9999,19)"}', + '{100, 100, 1, 100, 100}'), + ('float4col', 'float4', + '{>, >=, =, <=, <}', + '{0.0103093, 0.0103093, 1, 1, 1}', + '{100, 100, 4, 100, 96}'), + ('float4col', 'float8', + '{>, >=, =, <=, <}', + '{0.0103093, 0.0103093, 1, 1, 1}', + '{100, 100, 4, 100, 96}'), + ('float8col', 'float4', + '{>, >=, =, <=, <}', + '{0, 0, 0, 1.98, 1.98}', + '{99, 100, 1, 100, 100}'), + ('float8col', 'float8', + '{>, >=, =, <=, <}', + '{0, 0, 0, 1.98, 1.98}', + '{99, 100, 1, 100, 100}'), + ('macaddrcol', 'macaddr', + '{>, >=, =, <=, <}', + '{00:00:01:00:00:00, 00:00:01:00:00:00, 2c:00:2d:00:16:00, ff:fe:00:00:00:00, ff:fe:00:00:00:00}', + '{99, 100, 2, 100, 100}'), + ('macaddr8col', 'macaddr8', + '{>, >=, =, <=, <}', + '{b1:d1:0e:7b:af:a4:42:12, d9:35:91:bd:f7:86:0e:1e, 72:8f:20:6c:2a:01:bf:57, 23:e8:46:63:86:07:ad:cb, 13:16:8e:6a:2e:6c:84:b4}', + '{31, 17, 1, 11, 4}'), + ('inetcol', 'inet', + '{=, <, <=, >, >=}', + '{10.2.14.231/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}', + '{1, 100, 100, 125, 125}'), + ('inetcol', 'cidr', + '{<, <=, >, >=}', + '{255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}', + '{100, 100, 125, 125}'), + ('cidrcol', 'inet', + '{=, <, <=, >, >=}', + '{10.2.14/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}', + '{2, 100, 100, 125, 125}'), + ('cidrcol', 'cidr', + '{=, <, <=, >, >=}', + '{10.2.14/24, 255.255.255.255, 255.255.255.255, 0.0.0.0, 0.0.0.0}', + '{2, 100, 100, 125, 125}'), + ('datecol', 'date', + '{>, >=, =, <=, <}', + '{1995-08-15, 1995-08-15, 2009-12-01, 2022-12-30, 2022-12-30}', + '{100, 100, 1, 100, 100}'), + ('timecol', 'time', + '{>, >=, =, <=, <}', + '{01:20:30, 01:20:30, 02:28:57, 06:28:31.5, 06:28:31.5}', + '{100, 100, 1, 100, 100}'), + ('timestampcol', 'timestamp', + '{>, >=, =, <=, <}', + '{1942-07-23 03:05:09, 1942-07-23 03:05:09, 1964-03-24 19:26:45, 1984-01-20 22:42:21, 1984-01-20 22:42:21}', + '{100, 100, 1, 100, 100}'), + ('timestampcol', 'timestamptz', + '{>, >=, =, <=, <}', + '{1942-07-23 03:05:09, 1942-07-23 03:05:09, 1964-03-24 19:26:45, 1984-01-20 22:42:21, 1984-01-20 22:42:21}', + '{100, 100, 1, 100, 100}'), + ('timestamptzcol', 'timestamptz', + '{>, >=, =, <=, <}', + '{1972-10-10 03:00:00-04, 1972-10-10 03:00:00-04, 1972-10-19 09:00:00-07, 1972-11-20 19:00:00-03, 1972-11-20 19:00:00-03}', + '{100, 100, 1, 100, 100}'), + ('intervalcol', 'interval', + '{>, >=, =, <=, <}', + '{00:00:00, 00:00:00, 1 mons 13 days 12:24, 2 mons 23 days 07:48:00, 1 year}', + '{100, 100, 1, 100, 100}'), + ('timetzcol', 'timetz', + '{>, >=, =, <=, <}', + '{01:30:20+02, 01:30:20+02, 01:35:50+02, 23:55:05+02, 23:55:05+02}', + '{99, 100, 2, 100, 100}'), + ('numericcol', 'numeric', + '{>, >=, =, <=, <}', + '{0.00, 0.01, 2268164.347826086956521739130434782609, 99470151.9, 99470151.9}', + '{100, 100, 1, 100, 100}'), + ('uuidcol', 'uuid', + '{>, >=, =, <=, <}', + '{00040004-0004-0004-0004-000400040004, 00040004-0004-0004-0004-000400040004, 52225222-5222-5222-5222-522252225222, 99989998-9998-9998-9998-999899989998, 99989998-9998-9998-9998-999899989998}', + '{100, 100, 1, 100, 100}'), + ('lsncol', 'pg_lsn', + '{>, >=, =, <=, <, IS, IS NOT}', + '{0/1200, 0/1200, 44/455222, 198/1999799, 198/1999799, NULL, NULL}', + '{100, 100, 1, 100, 100, 25, 100}') +-- +TABLE: name="brinopers_multi" schema="" table="brinopers_multi" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brinopers_multi VALUES (...)" +== 011 +-- truncate_limit: 100 +DO $x$ +DECLARE + r record; + r2 record; + cond text; + idx_ctids tid[]; + ss_ctids tid[]; + count int; + plan_ok bool; + plan_line text; +BEGIN + FOR r IN SELECT colname, oper, typ, value[ordinality], matches[ordinality] FROM brinopers_multi, unnest(op) WITH ORDINALITY AS oper LOOP + + -- prepare the condition + IF r.value IS NULL THEN + cond := format('%I %s %L', r.colname, r.oper, r.value); + ELSE + cond := format('%I %s %L::%s', r.colname, r.oper, r.value, r.typ); + END IF; + + -- run the query using the brin index + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest_multi WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Bitmap Heap Scan on brintest_multi%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get bitmap indexscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest_multi WHERE %s $y$, cond) + INTO idx_ctids; + + -- run the query using a seqscan + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + + plan_ok := false; + FOR plan_line IN EXECUTE format($y$EXPLAIN SELECT array_agg(ctid) FROM brintest_multi WHERE %s $y$, cond) LOOP + IF plan_line LIKE '%Seq Scan on brintest_multi%' THEN + plan_ok := true; + END IF; + END LOOP; + IF NOT plan_ok THEN + RAISE WARNING 'did not get seqscan plan for %', r; + END IF; + + EXECUTE format($y$SELECT array_agg(ctid) FROM brintest_multi WHERE %s $y$, cond) + INTO ss_ctids; + + -- make sure both return the same results + count := array_length(idx_ctids, 1); + + IF NOT (count = array_length(ss_ctids, 1) AND + idx_ctids @> ss_ctids AND + idx_ctids <@ ss_ctids) THEN + -- report the results of each scan to make the differences obvious + RAISE WARNING 'something not right in %: count %', r, count; + SET enable_seqscan = 1; + SET enable_bitmapscan = 0; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest_multi WHERE ' || cond LOOP + RAISE NOTICE 'seqscan: %', r2; + END LOOP; + + SET enable_seqscan = 0; + SET enable_bitmapscan = 1; + FOR r2 IN EXECUTE 'SELECT ' || r.colname || ' FROM brintest_multi WHERE ' || cond LOOP + RAISE NOTICE 'bitmapscan: %', r2; + END LOOP; + END IF; + + -- make sure we found expected number of matches + IF count != r.matches THEN RAISE WARNING 'unexpected number of results % for %', count, r; END IF; + END LOOP; +END; +$x$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n\tr record;\n\tr2 record;\n\tcond text;\n\tidx_ctids tid[];\n\tss_ctids tid[];\n\tcount int;\n\t..." +== 012 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 013 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 014 +-- truncate_limit: 100 +INSERT INTO brintest_multi SELECT + 142857 * tenthous, + thousand, + twothousand, + unique1::oid, + format('(%s,%s)', tenthous, twenty)::tid, + (four + 1.0)/(hundred+1), + odd::float8 / (tenthous + 1), + format('%s:00:%s:00:%s:00', to_hex(odd), to_hex(even), to_hex(hundred))::macaddr, + substr(fipshash(unique1::text), 1, 16)::macaddr8, + inet '10.2.3.4' + tenthous, + cidr '10.2.3/24' + tenthous, + date '1995-08-15' + tenthous, + time '01:20:30' + thousand * interval '18.5 second', + timestamp '1942-07-23 03:05:09' + tenthous * interval '36.38 hours', + timestamptz '1972-10-10 03:00' + thousand * interval '1 hour', + justify_days(justify_hours(tenthous * interval '12 minutes')), + timetz '01:30:20' + hundred * interval '15 seconds', + tenthous::numeric(36,30) * fivethous * even / (hundred + 1), + format('%s%s-%s-%s-%s-%s%s%s', to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'), to_char(tenthous, 'FM0000'))::uuid, + format('%s/%s%s', odd, even, tenthous)::pg_lsn +FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5 +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DML +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="to_hex" function="to_hex" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brintest_multi SELECT ... FROM tenk1 ORDER BY unique2 LIMIT 5 OFFSET 5" +== 015 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx_multi', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_multi', 0)" +== 016 +-- truncate_limit: 100 +VACUUM brintest_multi +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM brintest_multi" +== 017 +-- truncate_limit: 100 +-- force a summarization cycle in brinidx + +-- Try inserting a values with NaN, to test distance calculation. +insert into public.brintest_multi (float4col) values (real 'nan') +-- +TABLE: name="public.brintest_multi" schema="public" table="brintest_multi" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO public.brintest_multi (float4col) VALUES ('nan'::real)" +== 018 +-- truncate_limit: 100 +insert into public.brintest_multi (float8col) values (real 'nan') +-- +TABLE: name="public.brintest_multi" schema="public" table="brintest_multi" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO public.brintest_multi (float8col) VALUES ('nan'::real)" +== 019 +-- truncate_limit: 100 +UPDATE brintest_multi SET int8col = int8col * int4col +-- +TABLE: name="brintest_multi" schema="" table="brintest_multi" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brintest_multi SET int8col = int8col * int4col" +== 020 +-- truncate_limit: 100 +-- Test handling of inet netmasks with inet_minmax_multi_ops +CREATE TABLE brin_test_inet (a inet) +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_test_inet (a inet)" +== 021 +-- truncate_limit: 100 +CREATE INDEX ON brin_test_inet USING brin (a inet_minmax_multi_ops) +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_test_inet USING brin (a inet_minmax_multi_ops)" +== 022 +-- truncate_limit: 100 +INSERT INTO brin_test_inet VALUES ('127.0.0.1/0') +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test_inet VALUES ('127.0.0.1/0')" +== 023 +-- truncate_limit: 100 +INSERT INTO brin_test_inet VALUES ('0.0.0.0/12') +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test_inet VALUES ('0.0.0.0/12')" +== 024 +-- truncate_limit: 100 +DROP TABLE brin_test_inet +-- +TABLE: name="brin_test_inet" schema="" table="brin_test_inet" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_test_inet" +== 025 +-- truncate_limit: 100 +-- Tests for brin_summarize_new_values +SELECT brin_summarize_new_values('brintest_multi') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('brintest_multi')" +== 026 +-- truncate_limit: 100 +-- error, not an index +SELECT brin_summarize_new_values('tenk1_unique1') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('tenk1_unique1')" +== 027 +-- truncate_limit: 100 +-- error, not a BRIN index +SELECT brin_summarize_new_values('brinidx_multi') +-- +FUNCTION: name="brin_summarize_new_values" function="brin_summarize_new_values" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_new_values('brinidx_multi')" +== 028 +-- truncate_limit: 100 +-- ok, no change expected + +-- Tests for brin_desummarize_range +SELECT brin_desummarize_range('brinidx_multi', -1) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_multi', -1)" +== 029 +-- truncate_limit: 100 +-- error, invalid range +SELECT brin_desummarize_range('brinidx_multi', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_multi', 0)" +== 030 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx_multi', 0) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_multi', 0)" +== 031 +-- truncate_limit: 100 +SELECT brin_desummarize_range('brinidx_multi', 100000000) +-- +FUNCTION: name="brin_desummarize_range" function="brin_desummarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_desummarize_range('brinidx_multi', 100000000)" +== 032 +-- truncate_limit: 100 +-- test building an index with many values, to force compaction of the buffer +CREATE TABLE brin_large_range (a int4) +-- +TABLE: name="brin_large_range" schema="" table="brin_large_range" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_large_range (a int4)" +== 033 +-- truncate_limit: 100 +INSERT INTO brin_large_range SELECT i FROM generate_series(1,10000) s(i) +-- +TABLE: name="brin_large_range" schema="" table="brin_large_range" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_large_range SELECT i FROM generate_series(1, 10000) s(i)" +== 034 +-- truncate_limit: 100 +CREATE INDEX brin_large_range_idx ON brin_large_range USING brin (a int4_minmax_multi_ops) +-- +TABLE: name="brin_large_range" schema="" table="brin_large_range" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_large_range_idx ON brin_large_range USING brin (a int4_minmax_multi_ops)" +== 035 +-- truncate_limit: 100 +DROP TABLE brin_large_range +-- +TABLE: name="brin_large_range" schema="" table="brin_large_range" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_large_range" +== 036 +-- truncate_limit: 100 +-- Test brin_summarize_range +CREATE TABLE brin_summarize_multi ( + value int +) WITH (fillfactor=10, autovacuum_enabled=false) +-- +TABLE: name="brin_summarize_multi" schema="" table="brin_summarize_multi" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_summarize_multi (value int) WITH (fillfactor=10, autovacuum_enabled=false)" +== 037 +-- truncate_limit: 100 +CREATE INDEX brin_summarize_multi_idx ON brin_summarize_multi USING brin (value) WITH (pages_per_range=2) +-- +TABLE: name="brin_summarize_multi" schema="" table="brin_summarize_multi" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_summarize_multi_idx ON brin_summarize_multi USING brin (value) WITH (pages_per_..." +== 038 +-- truncate_limit: 100 +-- Fill a few pages +DO $$ +DECLARE curtid tid; +BEGIN + LOOP + INSERT INTO brin_summarize_multi VALUES (1) RETURNING ctid INTO curtid; + EXIT WHEN curtid > tid '(2, 0)'; + END LOOP; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE curtid tid;\nBEGIN\n LOOP\n INSERT INTO brin_summarize_multi VALUES (1) RETURNING ..." +== 039 +-- truncate_limit: 100 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_multi_idx', 0) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_multi_idx', 0)" +== 040 +-- truncate_limit: 100 +-- nothing: already summarized +SELECT brin_summarize_range('brin_summarize_multi_idx', 1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_multi_idx', 1)" +== 041 +-- truncate_limit: 100 +-- summarize one range +SELECT brin_summarize_range('brin_summarize_multi_idx', 2) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_multi_idx', 2)" +== 042 +-- truncate_limit: 100 +-- nothing: page doesn't exist in table +SELECT brin_summarize_range('brin_summarize_multi_idx', 4294967295) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_multi_idx', 4294967295)" +== 043 +-- truncate_limit: 100 +-- invalid block number values +SELECT brin_summarize_range('brin_summarize_multi_idx', -1) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_multi_idx', -1)" +== 044 +-- truncate_limit: 100 +SELECT brin_summarize_range('brin_summarize_multi_idx', 4294967296) +-- +FUNCTION: name="brin_summarize_range" function="brin_summarize_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT brin_summarize_range('brin_summarize_multi_idx', 4294967296)" +== 045 +-- truncate_limit: 100 +-- test brin cost estimates behave sanely based on correlation of values +CREATE TABLE brin_test_multi (a INT, b INT) +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_test_multi (a int, b int)" +== 046 +-- truncate_limit: 100 +INSERT INTO brin_test_multi SELECT x/100,x%100 FROM generate_series(1,10000) x(x) +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test_multi SELECT x / 100, x % 100 FROM generate_series(1, 10000) x(x)" +== 047 +-- truncate_limit: 100 +CREATE INDEX brin_test_multi_a_idx ON brin_test_multi USING brin (a) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_multi_a_idx ON brin_test_multi USING brin (a) WITH (pages_per_range=2)" +== 048 +-- truncate_limit: 100 +CREATE INDEX brin_test_multi_b_idx ON brin_test_multi USING brin (b) WITH (pages_per_range = 2) +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_multi_b_idx ON brin_test_multi USING brin (b) WITH (pages_per_range=2)" +== 049 +-- truncate_limit: 100 +VACUUM ANALYZE brin_test_multi +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) brin_test_multi" +== 050 +-- truncate_limit: 100 +-- Ensure brin index is used when columns are perfectly correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test_multi WHERE a = 1 +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_test_multi WHERE a = 1" +== 051 +-- truncate_limit: 100 +-- Ensure brin index is not used when values are not correlated +EXPLAIN (COSTS OFF) SELECT * FROM brin_test_multi WHERE b = 1 +-- +TABLE: name="brin_test_multi" schema="" table="brin_test_multi" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_test_multi WHERE b = 1" +== 052 +-- truncate_limit: 100 +-- do some inequality tests +CREATE TABLE brin_test_multi_1 (a INT, b BIGINT) WITH (fillfactor=10) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_test_multi_1 (a int, b bigint) WITH (fillfactor=10)" +== 053 +-- truncate_limit: 100 +INSERT INTO brin_test_multi_1 +SELECT i/5 + mod(911 * i + 483, 25), + i/10 + mod(751 * i + 221, 41) + FROM generate_series(1,1000) s(i) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test_multi_1 SELECT ... FROM generate_series(1, 1000) s(i)" +== 054 +-- truncate_limit: 100 +CREATE INDEX brin_test_multi_1_idx_1 ON brin_test_multi_1 USING brin (a int4_minmax_multi_ops) WITH (pages_per_range=5) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_multi_1_idx_1 ON brin_test_multi_1 USING brin (a int4_minmax_multi_ops) WI..." +== 055 +-- truncate_limit: 100 +CREATE INDEX brin_test_multi_1_idx_2 ON brin_test_multi_1 USING brin (b int8_minmax_multi_ops) WITH (pages_per_range=5) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_multi_1_idx_2 ON brin_test_multi_1 USING brin (b int8_minmax_multi_ops) WI..." +== 056 +-- truncate_limit: 100 +SET enable_seqscan=off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 057 +-- truncate_limit: 100 +-- int: less than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a < 37 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a < 37" +== 058 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a < 113 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a < 113" +== 059 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a <= 177 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a <= 177" +== 060 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a <= 25 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a <= 25" +== 061 +-- truncate_limit: 100 +-- int: greater than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a > 120 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a > 120" +== 062 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a >= 180 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a >= 180" +== 063 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a > 71 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a > 71" +== 064 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a >= 63 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a >= 63" +== 065 +-- truncate_limit: 100 +-- int: equals +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a = 207 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a = 207" +== 066 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a = 177 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a = 177" +== 067 +-- truncate_limit: 100 +-- bigint: less than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b < 73 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b < 73" +== 068 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b <= 47 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b <= 47" +== 069 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b < 199 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b < 199" +== 070 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b <= 150 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b <= 150" +== 071 +-- truncate_limit: 100 +-- bigint: greater than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 93 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b > 93" +== 072 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 37 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b > 37" +== 073 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b >= 215 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b >= 215" +== 074 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 201 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b > 201" +== 075 +-- truncate_limit: 100 +-- bigint: equals +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b = 88 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b = 88" +== 076 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b = 103 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b = 103" +== 077 +-- truncate_limit: 100 +-- now do the same, but insert the rows with the indexes already created +-- so that we don't use the "build callback" and instead use the regular +-- approach of adding rows into existing ranges +TRUNCATE brin_test_multi_1 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE brin_test_multi_1" +== 078 +-- truncate_limit: 100 +INSERT INTO brin_test_multi_1 +SELECT i/5 + mod(911 * i + 483, 25), + i/10 + mod(751 * i + 221, 41) + FROM generate_series(1,1000) s(i) +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test_multi_1 SELECT ... FROM generate_series(1, 1000) s(i)" +== 079 +-- truncate_limit: 100 +-- int: less than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a < 37 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a < 37" +== 080 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a < 113 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a < 113" +== 081 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a <= 177 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a <= 177" +== 082 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a <= 25 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a <= 25" +== 083 +-- truncate_limit: 100 +-- int: greater than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a > 120 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a > 120" +== 084 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a >= 180 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a >= 180" +== 085 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a > 71 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a > 71" +== 086 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a >= 63 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a >= 63" +== 087 +-- truncate_limit: 100 +-- int: equals +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a = 207 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a = 207" +== 088 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE a = 177 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE a = 177" +== 089 +-- truncate_limit: 100 +-- bigint: less than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b < 73 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b < 73" +== 090 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b <= 47 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b <= 47" +== 091 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b < 199 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b < 199" +== 092 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b <= 150 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b <= 150" +== 093 +-- truncate_limit: 100 +-- bigint: greater than +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 93 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b > 93" +== 094 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 37 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b > 37" +== 095 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b >= 215 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b >= 215" +== 096 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b > 201 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b > 201" +== 097 +-- truncate_limit: 100 +-- bigint: equals +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b = 88 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b = 88" +== 098 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_1 WHERE b = 103 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_1 WHERE b = 103" +== 099 +-- truncate_limit: 100 +DROP TABLE brin_test_multi_1 +-- +TABLE: name="brin_test_multi_1" schema="" table="brin_test_multi_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_test_multi_1" +== 100 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 101 +-- truncate_limit: 100 +-- do some inequality tests for varlena data types +CREATE TABLE brin_test_multi_2 (a UUID) WITH (fillfactor=10) +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_test_multi_2 (a uuid) WITH (fillfactor=10)" +== 102 +-- truncate_limit: 100 +INSERT INTO brin_test_multi_2 +SELECT v::uuid FROM (SELECT row_number() OVER (ORDER BY v) c, v FROM (SELECT fipshash((i/13)::text) AS v FROM generate_series(1,1000) s(i)) foo) bar ORDER BY c + 25 * random() +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DML +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test_multi_2 SELECT ... FROM (SELECT ... FROM (SELECT ... FROM generate_series(1..." +== 103 +-- truncate_limit: 100 +CREATE INDEX brin_test_multi_2_idx ON brin_test_multi_2 USING brin (a uuid_minmax_multi_ops) WITH (pages_per_range=5) +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_test_multi_2_idx ON brin_test_multi_2 USING brin (a uuid_minmax_multi_ops) WITH..." +== 104 +-- truncate_limit: 100 +SET enable_seqscan=off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 105 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a < '3d914f93-48c9-cc0f-f8a7-9716700b9fcd' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a < '3d914f93-48c9-cc0f-f8a7-9716700b9fcd'" +== 106 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a > '3d914f93-48c9-cc0f-f8a7-9716700b9fcd' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a > '3d914f93-48c9-cc0f-f8a7-9716700b9fcd'" +== 107 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a <= 'f369cb89-fc62-7e66-8987-007d121ed1ea' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a <= 'f369cb89-fc62-7e66-8987-007d121ed1ea'" +== 108 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a >= 'aea92132-c4cb-eb26-3e6a-c2bf6c183b5d' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a >= 'aea92132-c4cb-eb26-3e6a-c2bf6c183b5d'" +== 109 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a = '5feceb66-ffc8-6f38-d952-786c6d696c79' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a = '5feceb66-ffc8-6f38-d952-786c6d696c79'" +== 110 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a = '86e50149-6586-6131-2a9e-0b35558d84f6' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a = '86e50149-6586-6131-2a9e-0b35558d84f6'" +== 111 +-- truncate_limit: 100 +-- now do the same, but insert the rows with the indexes already created +-- so that we don't use the "build callback" and instead use the regular +-- approach of adding rows into existing ranges + +TRUNCATE brin_test_multi_2 +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE brin_test_multi_2" +== 112 +-- truncate_limit: 100 +INSERT INTO brin_test_multi_2 +SELECT v::uuid FROM (SELECT row_number() OVER (ORDER BY v) c, v FROM (SELECT fipshash((i/13)::text) AS v FROM generate_series(1,1000) s(i)) foo) bar ORDER BY c + 25 * random() +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DML +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_test_multi_2 SELECT ... FROM (SELECT ... FROM (SELECT ... FROM generate_series(1..." +== 113 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a < '3d914f93-48c9-cc0f-f8a7-9716700b9fcd' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a < '3d914f93-48c9-cc0f-f8a7-9716700b9fcd'" +== 114 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a > '3d914f93-48c9-cc0f-f8a7-9716700b9fcd' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a > '3d914f93-48c9-cc0f-f8a7-9716700b9fcd'" +== 115 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a <= 'f369cb89-fc62-7e66-8987-007d121ed1ea' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a <= 'f369cb89-fc62-7e66-8987-007d121ed1ea'" +== 116 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a >= 'aea92132-c4cb-eb26-3e6a-c2bf6c183b5d' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a >= 'aea92132-c4cb-eb26-3e6a-c2bf6c183b5d'" +== 117 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a = '5feceb66-ffc8-6f38-d952-786c6d696c79' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a = '5feceb66-ffc8-6f38-d952-786c6d696c79'" +== 118 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_test_multi_2 WHERE a = '86e50149-6586-6131-2a9e-0b35558d84f6' +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_test_multi_2 WHERE a = '86e50149-6586-6131-2a9e-0b35558d84f6'" +== 119 +-- truncate_limit: 100 +DROP TABLE brin_test_multi_2 +-- +TABLE: name="brin_test_multi_2" schema="" table="brin_test_multi_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_test_multi_2" +== 120 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 121 +-- truncate_limit: 100 +-- test overflows during CREATE INDEX with extreme timestamp values +CREATE TABLE brin_timestamp_test(a TIMESTAMPTZ) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_timestamp_test (a timestamptz)" +== 122 +-- truncate_limit: 100 +SET datestyle TO iso +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO iso" +== 123 +-- truncate_limit: 100 +-- values close to timestamp minimum +INSERT INTO brin_timestamp_test +SELECT '4713-01-01 00:00:01 BC'::timestamptz + (i || ' seconds')::interval + FROM generate_series(1,30) s(i) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_timestamp_test SELECT ... FROM generate_series(1, 30) s(i)" +== 124 +-- truncate_limit: 100 +-- values close to timestamp maximum +INSERT INTO brin_timestamp_test +SELECT '294276-12-01 00:00:01'::timestamptz + (i || ' seconds')::interval + FROM generate_series(1,30) s(i) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_timestamp_test SELECT ... FROM generate_series(1, 30) s(i)" +== 125 +-- truncate_limit: 100 +CREATE INDEX ON brin_timestamp_test USING brin (a timestamptz_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_timestamp_test USING brin (a timestamptz_minmax_multi_ops) WITH (pages_per_r..." +== 126 +-- truncate_limit: 100 +DROP TABLE brin_timestamp_test +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_timestamp_test" +== 127 +-- truncate_limit: 100 +-- test overflows during CREATE INDEX with extreme date values +CREATE TABLE brin_date_test(a DATE) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_date_test (a date)" +== 128 +-- truncate_limit: 100 +-- insert values close to date minimum +INSERT INTO brin_date_test SELECT '4713-01-01 BC'::date + i FROM generate_series(1, 30) s(i) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_date_test SELECT '4713-01-01 BC'::date + i FROM generate_series(1, 30) s(i)" +== 129 +-- truncate_limit: 100 +-- insert values close to date minimum +INSERT INTO brin_date_test SELECT '5874897-12-01'::date + i FROM generate_series(1, 30) s(i) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_date_test SELECT '5874897-12-01'::date + i FROM generate_series(1, 30) s(i)" +== 130 +-- truncate_limit: 100 +CREATE INDEX ON brin_date_test USING brin (a date_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_date_test USING brin (a date_minmax_multi_ops) WITH (pages_per_range=1)" +== 131 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 132 +-- truncate_limit: 100 +-- make sure the ranges were built correctly and 2023-01-01 eliminates all +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_date_test WHERE a = '2023-01-01'::date +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_date_test WHERE a = '202..." +== 133 +-- truncate_limit: 100 +DROP TABLE brin_date_test +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_date_test" +== 134 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 135 +-- truncate_limit: 100 +-- test handling of infinite timestamp values +CREATE TABLE brin_timestamp_test(a TIMESTAMP) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_timestamp_test (a timestamp)" +== 136 +-- truncate_limit: 100 +INSERT INTO brin_timestamp_test VALUES ('-infinity'), ('infinity') +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_timestamp_test VALUES ('-infinity'), ('infinity')" +== 137 +-- truncate_limit: 100 +INSERT INTO brin_timestamp_test +SELECT i FROM generate_series('2000-01-01'::timestamp, '2000-02-09'::timestamp, '1 day'::interval) s(i) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_timestamp_test SELECT i FROM generate_series('2000-01-01'::timestamp, '2000-02-0..." +== 138 +-- truncate_limit: 100 +CREATE INDEX ON brin_timestamp_test USING brin (a timestamp_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_timestamp_test USING brin (a timestamp_minmax_multi_ops) WITH (pages_per_ran..." +== 139 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 140 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_timestamp_test WHERE a = '2023-01-01'::timestamp +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_timestamp_test WHERE a =..." +== 141 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_timestamp_test WHERE a = '1900-01-01'::timestamp +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_timestamp_test WHERE a =..." +== 142 +-- truncate_limit: 100 +DROP TABLE brin_timestamp_test +-- +TABLE: name="brin_timestamp_test" schema="" table="brin_timestamp_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_timestamp_test" +== 143 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 144 +-- truncate_limit: 100 +-- test handling of infinite date values +CREATE TABLE brin_date_test(a DATE) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_date_test (a date)" +== 145 +-- truncate_limit: 100 +INSERT INTO brin_date_test VALUES ('-infinity'), ('infinity') +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_date_test VALUES ('-infinity'), ('infinity')" +== 146 +-- truncate_limit: 100 +INSERT INTO brin_date_test SELECT '2000-01-01'::date + i FROM generate_series(1, 40) s(i) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_date_test SELECT '2000-01-01'::date + i FROM generate_series(1, 40) s(i)" +== 147 +-- truncate_limit: 100 +CREATE INDEX ON brin_date_test USING brin (a date_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_date_test USING brin (a date_minmax_multi_ops) WITH (pages_per_range=1)" +== 148 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 149 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_date_test WHERE a = '2023-01-01'::date +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_date_test WHERE a = '202..." +== 150 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_date_test WHERE a = '1900-01-01'::date +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_date_test WHERE a = '190..." +== 151 +-- truncate_limit: 100 +DROP TABLE brin_date_test +-- +TABLE: name="brin_date_test" schema="" table="brin_date_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_date_test" +== 152 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 153 +-- truncate_limit: 100 +RESET datestyle +-- +STMT: VariableSetStmt +TRUNCATED: "RESET datestyle" +== 154 +-- truncate_limit: 100 +-- test handling of overflow for interval values +CREATE TABLE brin_interval_test(a INTERVAL) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_interval_test (a interval)" +== 155 +-- truncate_limit: 100 +INSERT INTO brin_interval_test SELECT (i || ' years')::interval FROM generate_series(-178000000, -177999980) s(i) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_interval_test SELECT ... FROM generate_series(-178000000, -177999980) s(i)" +== 156 +-- truncate_limit: 100 +INSERT INTO brin_interval_test SELECT (i || ' years')::interval FROM generate_series( 177999980, 178000000) s(i) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_interval_test SELECT ... FROM generate_series(177999980, 178000000) s(i)" +== 157 +-- truncate_limit: 100 +CREATE INDEX ON brin_interval_test USING brin (a interval_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_interval_test USING brin (a interval_minmax_multi_ops) WITH (pages_per_range=1)" +== 158 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 159 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_interval_test WHERE a = '-30 years'::interval +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_interval_test WHERE a = ..." +== 160 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_interval_test WHERE a = '30 years'::interval +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_interval_test WHERE a = ..." +== 161 +-- truncate_limit: 100 +DROP TABLE brin_interval_test +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_interval_test" +== 162 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 163 +-- truncate_limit: 100 +-- test handling of infinite interval values +CREATE TABLE brin_interval_test(a INTERVAL) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_interval_test (a interval)" +== 164 +-- truncate_limit: 100 +INSERT INTO brin_interval_test VALUES ('-infinity'), ('infinity') +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_interval_test VALUES ('-infinity'), ('infinity')" +== 165 +-- truncate_limit: 100 +INSERT INTO brin_interval_test SELECT (i || ' days')::interval FROM generate_series(100, 140) s(i) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_interval_test SELECT (i || ' days')::interval FROM generate_series(100, 140) s(i)" +== 166 +-- truncate_limit: 100 +CREATE INDEX ON brin_interval_test USING brin (a interval_minmax_multi_ops) WITH (pages_per_range=1) +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_interval_test USING brin (a interval_minmax_multi_ops) WITH (pages_per_range=1)" +== 167 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 168 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_interval_test WHERE a = '-30 years'::interval +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_interval_test WHERE a = ..." +== 169 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) +SELECT * FROM brin_interval_test WHERE a = '30 years'::interval +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, COSTS OFF, SUMMARY OFF) SELECT * FROM brin_interval_test WHERE a = ..." +== 170 +-- truncate_limit: 100 +DROP TABLE brin_interval_test +-- +TABLE: name="brin_interval_test" schema="" table="brin_interval_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_interval_test" +== 171 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 172 +-- truncate_limit: 100 +RESET datestyle +-- +STMT: VariableSetStmt +TRUNCATED: "RESET datestyle" diff --git a/parser/testdata/summary_truncate/postgres_regress/btree_index.metadata.json b/parser/testdata/summary_truncate/postgres_regress/btree_index.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/btree_index.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/btree_index.test b/parser/testdata/summary_truncate/postgres_regress/btree_index.test new file mode 100644 index 0000000..c4e0869 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/btree_index.test @@ -0,0 +1,883 @@ +== 001 +-- truncate_limit: 100 +|-- +-- BTREE_INDEX +|-- + +-- directory paths are passed to us in environment variables + +CREATE TABLE bt_i4_heap ( + seqno int4, + random int4 +) +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bt_i4_heap (seqno int4, random int4)" +== 002 +-- truncate_limit: 100 +CREATE TABLE bt_name_heap ( + seqno name, + random int4 +) +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bt_name_heap (seqno name, random int4)" +== 003 +-- truncate_limit: 100 +CREATE TABLE bt_txt_heap ( + seqno text, + random int4 +) +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bt_txt_heap (seqno text, random int4)" +== 004 +-- truncate_limit: 100 +CREATE TABLE bt_f8_heap ( + seqno float8, + random int4 +) +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bt_f8_heap (seqno float8, random int4)" +== 005 +-- truncate_limit: 100 +COPY bt_i4_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +-- truncate_limit: 100 +COPY bt_name_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- truncate_limit: 100 +COPY bt_txt_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +-- truncate_limit: 100 +COPY bt_f8_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- truncate_limit: 100 +ANALYZE bt_i4_heap +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE bt_i4_heap" +== 010 +-- truncate_limit: 100 +ANALYZE bt_name_heap +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE bt_name_heap" +== 011 +-- truncate_limit: 100 +ANALYZE bt_txt_heap +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE bt_txt_heap" +== 012 +-- truncate_limit: 100 +ANALYZE bt_f8_heap +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE bt_f8_heap" +== 013 +-- truncate_limit: 100 +|-- +-- BTREE ascending/descending cases +|-- +-- we load int4/text from pure descending data (each key is a new +-- low key) and name/f8 from pure ascending data (each key is a new +-- high key). we had a bug where new low keys would sometimes be +-- "lost". +|-- +CREATE INDEX bt_i4_index ON bt_i4_heap USING btree (seqno int4_ops) +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX bt_i4_index ON bt_i4_heap USING btree (seqno int4_ops)" +== 014 +-- truncate_limit: 100 +CREATE INDEX bt_name_index ON bt_name_heap USING btree (seqno name_ops) +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX bt_name_index ON bt_name_heap USING btree (seqno name_ops)" +== 015 +-- truncate_limit: 100 +CREATE INDEX bt_txt_index ON bt_txt_heap USING btree (seqno text_ops) +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX bt_txt_index ON bt_txt_heap USING btree (seqno text_ops)" +== 016 +-- truncate_limit: 100 +CREATE INDEX bt_f8_index ON bt_f8_heap USING btree (seqno float8_ops) +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX bt_f8_index ON bt_f8_heap USING btree (seqno float8_ops)" +== 017 +-- truncate_limit: 100 +|-- +-- test retrieval of min/max keys for each index +|-- + +SELECT b.* + FROM bt_i4_heap b + WHERE b.seqno < 1 +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=Select +ALIAS: "b"="bt_i4_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_i4_heap b WHERE b.seqno < 1" +== 018 +-- truncate_limit: 100 +SELECT b.* + FROM bt_i4_heap b + WHERE b.seqno >= 9999 +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=Select +ALIAS: "b"="bt_i4_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_i4_heap b WHERE b.seqno >= 9999" +== 019 +-- truncate_limit: 100 +SELECT b.* + FROM bt_i4_heap b + WHERE b.seqno = 4500 +-- +TABLE: name="bt_i4_heap" schema="" table="bt_i4_heap" ctx=Select +ALIAS: "b"="bt_i4_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_i4_heap b WHERE b.seqno = 4500" +== 020 +-- truncate_limit: 100 +SELECT b.* + FROM bt_name_heap b + WHERE b.seqno < '1'::name +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=Select +ALIAS: "b"="bt_name_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_name_heap b WHERE b.seqno < '1'::name" +== 021 +-- truncate_limit: 100 +SELECT b.* + FROM bt_name_heap b + WHERE b.seqno >= '9999'::name +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=Select +ALIAS: "b"="bt_name_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_name_heap b WHERE b.seqno >= '9999'::name" +== 022 +-- truncate_limit: 100 +SELECT b.* + FROM bt_name_heap b + WHERE b.seqno = '4500'::name +-- +TABLE: name="bt_name_heap" schema="" table="bt_name_heap" ctx=Select +ALIAS: "b"="bt_name_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_name_heap b WHERE b.seqno = '4500'::name" +== 023 +-- truncate_limit: 100 +SELECT b.* + FROM bt_txt_heap b + WHERE b.seqno < '1'::text +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=Select +ALIAS: "b"="bt_txt_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_txt_heap b WHERE b.seqno < '1'::text" +== 024 +-- truncate_limit: 100 +SELECT b.* + FROM bt_txt_heap b + WHERE b.seqno >= '9999'::text +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=Select +ALIAS: "b"="bt_txt_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_txt_heap b WHERE b.seqno >= '9999'::text" +== 025 +-- truncate_limit: 100 +SELECT b.* + FROM bt_txt_heap b + WHERE b.seqno = '4500'::text +-- +TABLE: name="bt_txt_heap" schema="" table="bt_txt_heap" ctx=Select +ALIAS: "b"="bt_txt_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_txt_heap b WHERE b.seqno = '4500'::text" +== 026 +-- truncate_limit: 100 +SELECT b.* + FROM bt_f8_heap b + WHERE b.seqno < '1'::float8 +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=Select +ALIAS: "b"="bt_f8_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_f8_heap b WHERE b.seqno < '1'::float8" +== 027 +-- truncate_limit: 100 +SELECT b.* + FROM bt_f8_heap b + WHERE b.seqno >= '9999'::float8 +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=Select +ALIAS: "b"="bt_f8_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_f8_heap b WHERE b.seqno >= '9999'::float8" +== 028 +-- truncate_limit: 100 +SELECT b.* + FROM bt_f8_heap b + WHERE b.seqno = '4500'::float8 +-- +TABLE: name="bt_f8_heap" schema="" table="bt_f8_heap" ctx=Select +ALIAS: "b"="bt_f8_heap" +FILTER: schema="" table="b" column="seqno" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM bt_f8_heap b WHERE b.seqno = '4500'::float8" +== 029 +-- truncate_limit: 100 +|-- +-- Add coverage for optimization of backwards scan index descents +|-- +-- Here we expect _bt_search to descend straight to a leaf page containing a +-- non-pivot tuple with the value '47', which comes last (after 11 similar +-- non-pivot tuples). Query execution should only need to visit a single +-- leaf page here. +|-- +-- Test case relies on tenk1_hundred index having a leaf page whose high key +-- is '(48, -inf)'. We use a low cardinality index to make our test case less +-- sensitive to implementation details that may change in the future. +set enable_seqscan to false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO FALSE" +== 030 +-- truncate_limit: 100 +set enable_indexscan to true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO TRUE" +== 031 +-- truncate_limit: 100 +set enable_bitmapscan to false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO FALSE" +== 032 +-- truncate_limit: 100 +explain (costs off) +select hundred, twenty from tenk1 where hundred < 48 order by hundred desc limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT hundred, twenty FROM tenk1 WHERE hundred < 48 ORDER BY hundred DESC LI..." +== 033 +-- truncate_limit: 100 +select hundred, twenty from tenk1 where hundred < 48 order by hundred desc limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT hundred, twenty FROM tenk1 WHERE hundred < 48 ORDER BY hundred DESC LIMIT 1" +== 034 +-- truncate_limit: 100 +-- This variant of the query need only return a single tuple located to the immediate +-- right of the '(48, -inf)' high key. It also only needs to scan one single +-- leaf page (the right sibling of the page scanned by the last test case): +explain (costs off) +select hundred, twenty from tenk1 where hundred <= 48 order by hundred desc limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT hundred, twenty FROM tenk1 WHERE hundred <= 48 ORDER BY hundred DESC L..." +== 035 +-- truncate_limit: 100 +select hundred, twenty from tenk1 where hundred <= 48 order by hundred desc limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT hundred, twenty FROM tenk1 WHERE hundred <= 48 ORDER BY hundred DESC LIMIT 1" +== 036 +-- truncate_limit: 100 +|-- +-- Add coverage for ScalarArrayOp btree quals with pivot tuple constants +|-- +explain (costs off) +select distinct hundred from tenk1 where hundred in (47, 48, 72, 82) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT hundred FROM tenk1 WHERE hundred IN (47, 48, 72, 82)" +== 037 +-- truncate_limit: 100 +select distinct hundred from tenk1 where hundred in (47, 48, 72, 82) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT hundred FROM tenk1 WHERE hundred IN (47, 48, 72, 82)" +== 038 +-- truncate_limit: 100 +explain (costs off) +select distinct hundred from tenk1 where hundred in (47, 48, 72, 82) order by hundred desc +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT hundred FROM tenk1 WHERE hundred IN (47, 48, 72, 82) ORDER BY..." +== 039 +-- truncate_limit: 100 +select distinct hundred from tenk1 where hundred in (47, 48, 72, 82) order by hundred desc +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT hundred FROM tenk1 WHERE hundred IN (47, 48, 72, 82) ORDER BY hundred DESC" +== 040 +-- truncate_limit: 100 +explain (costs off) +select thousand from tenk1 where thousand in (364, 366,380) and tenthous = 200000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand FROM tenk1 WHERE thousand IN (364, 366, 380) AND tenthous = 2..." +== 041 +-- truncate_limit: 100 +select thousand from tenk1 where thousand in (364, 366,380) and tenthous = 200000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT thousand FROM tenk1 WHERE thousand IN (364, 366, 380) AND tenthous = 200000" +== 042 +-- truncate_limit: 100 +|-- +-- Check correct optimization of LIKE (special index operator support) +-- for both indexscan and bitmapscan cases +|-- + +set enable_seqscan to false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO FALSE" +== 043 +-- truncate_limit: 100 +set enable_indexscan to true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO TRUE" +== 044 +-- truncate_limit: 100 +set enable_bitmapscan to false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO FALSE" +== 045 +-- truncate_limit: 100 +explain (costs off) +select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT proname FROM pg_proc WHERE proname LIKE E'RI\\\\_FKey%del' ORDER BY 1" +== 046 +-- truncate_limit: 100 +select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +TRUNCATED: "SELECT proname FROM pg_proc WHERE proname LIKE E'RI\\\\_FKey%del' ORDER BY 1" +== 047 +-- truncate_limit: 100 +explain (costs off) +select proname from pg_proc where proname ilike '00%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT proname FROM pg_proc WHERE proname ILIKE '00%foo' ORDER BY 1" +== 048 +-- truncate_limit: 100 +select proname from pg_proc where proname ilike '00%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +TRUNCATED: "SELECT proname FROM pg_proc WHERE proname ILIKE '00%foo' ORDER BY 1" +== 049 +-- truncate_limit: 100 +explain (costs off) +select proname from pg_proc where proname ilike 'ri%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT proname FROM pg_proc WHERE proname ILIKE 'ri%foo' ORDER BY 1" +== 050 +-- truncate_limit: 100 +set enable_indexscan to false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO FALSE" +== 051 +-- truncate_limit: 100 +set enable_bitmapscan to true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO TRUE" +== 052 +-- truncate_limit: 100 +explain (costs off) +select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT proname FROM pg_proc WHERE proname LIKE E'RI\\\\_FKey%del' ORDER BY 1" +== 053 +-- truncate_limit: 100 +select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +TRUNCATED: "SELECT proname FROM pg_proc WHERE proname LIKE E'RI\\\\_FKey%del' ORDER BY 1" +== 054 +-- truncate_limit: 100 +explain (costs off) +select proname from pg_proc where proname ilike '00%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT proname FROM pg_proc WHERE proname ILIKE '00%foo' ORDER BY 1" +== 055 +-- truncate_limit: 100 +select proname from pg_proc where proname ilike '00%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +TRUNCATED: "SELECT proname FROM pg_proc WHERE proname ILIKE '00%foo' ORDER BY 1" +== 056 +-- truncate_limit: 100 +explain (costs off) +select proname from pg_proc where proname ilike 'ri%foo' order by 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT proname FROM pg_proc WHERE proname ILIKE 'ri%foo' ORDER BY 1" +== 057 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 058 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 059 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 060 +-- truncate_limit: 100 +-- Also check LIKE optimization with binary-compatible cases + +create temp table btree_bpchar (f1 text collate "C") +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE btree_bpchar (f1 text COLLATE \"C\")" +== 061 +-- truncate_limit: 100 +create index on btree_bpchar(f1 bpchar_ops) WITH (deduplicate_items=on) +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON btree_bpchar USING btree (f1 bpchar_ops) WITH (deduplicate_items=on)" +== 062 +-- truncate_limit: 100 +insert into btree_bpchar values ('foo'), ('fool'), ('bar'), ('quux') +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO btree_bpchar VALUES ('foo'), ('fool'), ('bar'), ('quux')" +== 063 +-- truncate_limit: 100 +-- doesn't match index: +explain (costs off) +select * from btree_bpchar where f1 like 'foo' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM btree_bpchar WHERE f1 LIKE 'foo'" +== 064 +-- truncate_limit: 100 +select * from btree_bpchar where f1 like 'foo' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM btree_bpchar WHERE f1 LIKE 'foo'" +== 065 +-- truncate_limit: 100 +explain (costs off) +select * from btree_bpchar where f1 like 'foo%' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM btree_bpchar WHERE f1 LIKE 'foo%'" +== 066 +-- truncate_limit: 100 +select * from btree_bpchar where f1 like 'foo%' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM btree_bpchar WHERE f1 LIKE 'foo%'" +== 067 +-- truncate_limit: 100 +-- these do match the index: +explain (costs off) +select * from btree_bpchar where f1::bpchar like 'foo' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM btree_bpchar WHERE f1::bpchar LIKE 'foo'" +== 068 +-- truncate_limit: 100 +select * from btree_bpchar where f1::bpchar like 'foo' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM btree_bpchar WHERE f1::bpchar LIKE 'foo'" +== 069 +-- truncate_limit: 100 +explain (costs off) +select * from btree_bpchar where f1::bpchar like 'foo%' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM btree_bpchar WHERE f1::bpchar LIKE 'foo%'" +== 070 +-- truncate_limit: 100 +select * from btree_bpchar where f1::bpchar like 'foo%' +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM btree_bpchar WHERE f1::bpchar LIKE 'foo%'" +== 071 +-- truncate_limit: 100 +-- get test coverage for "single value" deduplication strategy: +insert into btree_bpchar select 'foo' from generate_series(1,1500) +-- +TABLE: name="btree_bpchar" schema="" table="btree_bpchar" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO btree_bpchar SELECT 'foo' FROM generate_series(1, 1500)" +== 072 +-- truncate_limit: 100 +|-- +-- Perform unique checking, with and without the use of deduplication +|-- +CREATE TABLE dedup_unique_test_table (a int) WITH (autovacuum_enabled=false) +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dedup_unique_test_table (a int) WITH (autovacuum_enabled=false)" +== 073 +-- truncate_limit: 100 +CREATE UNIQUE INDEX dedup_unique ON dedup_unique_test_table (a) WITH (deduplicate_items=on) +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX dedup_unique ON dedup_unique_test_table USING btree (a) WITH (deduplicate_ite..." +== 074 +-- truncate_limit: 100 +CREATE UNIQUE INDEX plain_unique ON dedup_unique_test_table (a) WITH (deduplicate_items=off) +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX plain_unique ON dedup_unique_test_table USING btree (a) WITH (deduplicate_ite..." +== 075 +-- truncate_limit: 100 +-- Generate enough garbage tuples in index to ensure that even the unique index +-- with deduplication enabled has to check multiple leaf pages during unique +-- checking (at least with a BLCKSZ of 8192 or less) +DO $$ +BEGIN + FOR r IN 1..1350 LOOP + DELETE FROM dedup_unique_test_table; + INSERT INTO dedup_unique_test_table SELECT 1; + END LOOP; +END$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n FOR r IN 1..1350 LOOP\n DELETE FROM dedup_unique_test_table;\n INSERT..." +== 076 +-- truncate_limit: 100 +-- Exercise the LP_DEAD-bit-set tuple deletion code with a posting list tuple. +-- The implementation prefers deleting existing items to merging any duplicate +-- tuples into a posting list, so we need an explicit test to make sure we get +-- coverage (note that this test also assumes BLCKSZ is 8192 or less): +DROP INDEX plain_unique +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX plain_unique" +== 077 +-- truncate_limit: 100 +DELETE FROM dedup_unique_test_table WHERE a = 1 +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM dedup_unique_test_table WHERE a = 1" +== 078 +-- truncate_limit: 100 +INSERT INTO dedup_unique_test_table SELECT i FROM generate_series(0,450) i +-- +TABLE: name="dedup_unique_test_table" schema="" table="dedup_unique_test_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dedup_unique_test_table SELECT i FROM generate_series(0, 450) i" +== 079 +-- truncate_limit: 100 +|-- +-- Test B-tree fast path (cache rightmost leaf page) optimization. +|-- + +-- First create a tree that's at least three levels deep (i.e. has one level +-- between the root and leaf levels). The text inserted is long. It won't be +-- TOAST compressed because we use plain storage in the table. Only a few +-- index tuples fit on each internal page, allowing us to get a tall tree with +-- few pages. (A tall tree is required to trigger caching.) +|-- +-- The text column must be the leading column in the index, since suffix +-- truncation would otherwise truncate tuples on internal pages, leaving us +-- with a short tree. +create table btree_tall_tbl(id int4, t text) +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE btree_tall_tbl (id int4, t text)" +== 080 +-- truncate_limit: 100 +alter table btree_tall_tbl alter COLUMN t set storage plain +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE btree_tall_tbl ALTER COLUMN t SET STORAGE plain" +== 081 +-- truncate_limit: 100 +create index btree_tall_idx on btree_tall_tbl (t, id) with (fillfactor = 10) +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX btree_tall_idx ON btree_tall_tbl USING btree (t, id) WITH (fillfactor=10)" +== 082 +-- truncate_limit: 100 +insert into btree_tall_tbl select g, repeat('x', 250) +from generate_series(1, 130) g +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO btree_tall_tbl SELECT g, repeat('x', 250) FROM generate_series(1, 130) g" +== 083 +-- truncate_limit: 100 +|-- +-- Test for multilevel page deletion +|-- +CREATE TABLE delete_test_table (a bigint, b bigint, c bigint, d bigint) +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE delete_test_table (a bigint, b bigint, c bigint, d bigint)" +== 084 +-- truncate_limit: 100 +INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1,80000) i +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1, 80000) i" +== 085 +-- truncate_limit: 100 +ALTER TABLE delete_test_table ADD PRIMARY KEY (a,b,c,d) +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE delete_test_table ADD PRIMARY KEY (a, b, c, d)" +== 086 +-- truncate_limit: 100 +-- Delete most entries, and vacuum, deleting internal pages and creating "fast +-- root" +DELETE FROM delete_test_table WHERE a < 79990 +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM delete_test_table WHERE a < 79990" +== 087 +-- truncate_limit: 100 +VACUUM delete_test_table +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM delete_test_table" +== 088 +-- truncate_limit: 100 +|-- +-- Test B-tree insertion with a metapage update (XLOG_BTREE_INSERT_META +-- WAL record type). This happens when a "fast root" page is split. This +-- also creates coverage for nbtree FSM page recycling. +|-- +-- The vacuum above should've turned the leaf page into a fast root. We just +-- need to insert some rows to cause the fast root page to split. +INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1,1000) i +-- +TABLE: name="delete_test_table" schema="" table="delete_test_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO delete_test_table SELECT i, 1, 2, 3 FROM generate_series(1, 1000) i" +== 089 +-- truncate_limit: 100 +-- Test unsupported btree opclass parameters +create index on btree_tall_tbl (id int4_ops(foo=1)) +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON btree_tall_tbl USING btree (id int4_ops(foo=1))" +== 090 +-- truncate_limit: 100 +-- Test case of ALTER INDEX with abuse of column names for indexes. +-- This grammar is not officially supported, but the parser allows it. +CREATE INDEX btree_tall_idx2 ON btree_tall_tbl (id) +-- +TABLE: name="btree_tall_tbl" schema="" table="btree_tall_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX btree_tall_idx2 ON btree_tall_tbl USING btree (id)" +== 091 +-- truncate_limit: 100 +ALTER INDEX btree_tall_idx2 ALTER COLUMN id SET (n_distinct=100) +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX btree_tall_idx2 ALTER COLUMN id SET (n_distinct=100)" +== 092 +-- truncate_limit: 100 +DROP INDEX btree_tall_idx2 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX btree_tall_idx2" +== 093 +-- truncate_limit: 100 +-- Partitioned index +CREATE TABLE btree_part (id int4) PARTITION BY RANGE (id) +-- +TABLE: name="btree_part" schema="" table="btree_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE btree_part (id int4) PARTITION BY RANGE (id)" +== 094 +-- truncate_limit: 100 +CREATE INDEX btree_part_idx ON btree_part(id) +-- +TABLE: name="btree_part" schema="" table="btree_part" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX btree_part_idx ON btree_part USING btree (id)" +== 095 +-- truncate_limit: 100 +ALTER INDEX btree_part_idx ALTER COLUMN id SET (n_distinct=100) +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX btree_part_idx ALTER COLUMN id SET (n_distinct=100)" +== 096 +-- truncate_limit: 100 +DROP TABLE btree_part +-- +TABLE: name="btree_part" schema="" table="btree_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE btree_part" diff --git a/parser/testdata/summary_truncate/postgres_regress/case.metadata.json b/parser/testdata/summary_truncate/postgres_regress/case.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/case.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/case.test b/parser/testdata/summary_truncate/postgres_regress/case.test new file mode 100644 index 0000000..6853382 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/case.test @@ -0,0 +1,618 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CASE +-- Test the case statement +|-- + +CREATE TABLE CASE_TBL ( + i integer, + f double precision +) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE case_tbl (i int, f double precision)" +== 002 +-- truncate_limit: 100 +CREATE TABLE CASE2_TBL ( + i integer, + j integer +) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE case2_tbl (i int, j int)" +== 003 +-- truncate_limit: 100 +INSERT INTO CASE_TBL VALUES (1, 10.1) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case_tbl VALUES (1, 10.1)" +== 004 +-- truncate_limit: 100 +INSERT INTO CASE_TBL VALUES (2, 20.2) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case_tbl VALUES (2, 20.2)" +== 005 +-- truncate_limit: 100 +INSERT INTO CASE_TBL VALUES (3, -30.3) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case_tbl VALUES (3, -30.3)" +== 006 +-- truncate_limit: 100 +INSERT INTO CASE_TBL VALUES (4, NULL) +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case_tbl VALUES (4, NULL)" +== 007 +-- truncate_limit: 100 +INSERT INTO CASE2_TBL VALUES (1, -1) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case2_tbl VALUES (1, -1)" +== 008 +-- truncate_limit: 100 +INSERT INTO CASE2_TBL VALUES (2, -2) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case2_tbl VALUES (2, -2)" +== 009 +-- truncate_limit: 100 +INSERT INTO CASE2_TBL VALUES (3, -3) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case2_tbl VALUES (3, -3)" +== 010 +-- truncate_limit: 100 +INSERT INTO CASE2_TBL VALUES (2, -4) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case2_tbl VALUES (2, -4)" +== 011 +-- truncate_limit: 100 +INSERT INTO CASE2_TBL VALUES (1, NULL) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case2_tbl VALUES (1, NULL)" +== 012 +-- truncate_limit: 100 +INSERT INTO CASE2_TBL VALUES (NULL, -6) +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO case2_tbl VALUES (NULL, -6)" +== 013 +-- truncate_limit: 100 +|-- +-- Simplest examples without tables +|-- + +SELECT '3' AS "One", + CASE + WHEN 1 < 2 THEN 3 + END AS "Simple WHEN" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3' AS \"One\", CASE WHEN 1 < 2 THEN 3 END AS \"Simple WHEN\"" +== 014 +-- truncate_limit: 100 +SELECT '' AS "One", + CASE + WHEN 1 > 2 THEN 3 + END AS "Simple default" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '' AS \"One\", CASE WHEN 1 > 2 THEN 3 END AS \"Simple default\"" +== 015 +-- truncate_limit: 100 +SELECT '3' AS "One", + CASE + WHEN 1 < 2 THEN 3 + ELSE 4 + END AS "Simple ELSE" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3' AS \"One\", CASE WHEN 1 < 2 THEN 3 ELSE 4 END AS \"Simple ELSE\"" +== 016 +-- truncate_limit: 100 +SELECT '4' AS "One", + CASE + WHEN 1 > 2 THEN 3 + ELSE 4 + END AS "ELSE default" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4' AS \"One\", CASE WHEN 1 > 2 THEN 3 ELSE 4 END AS \"ELSE default\"" +== 017 +-- truncate_limit: 100 +SELECT '6' AS "One", + CASE + WHEN 1 > 2 THEN 3 + WHEN 4 < 5 THEN 6 + ELSE 7 + END AS "Two WHEN with default" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '6' AS \"One\", CASE WHEN 1 > 2 THEN 3 WHEN 4 < 5 THEN 6 ELSE 7 END AS \"Two WHEN with default\"" +== 018 +-- truncate_limit: 100 +SELECT '7' AS "None", + CASE WHEN random() < 0 THEN 1 + END AS "NULL on no matches" +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '7' AS \"None\", CASE WHEN random() < 0 THEN 1 END AS \"NULL on no matches\"" +== 019 +-- truncate_limit: 100 +-- Constant-expression folding shouldn't evaluate unreachable subexpressions +SELECT CASE WHEN 1=0 THEN 1/0 WHEN 1=1 THEN 1 ELSE 2/0 END +-- +STMT: SelectStmt +TRUNCATED: "SELECT CASE WHEN 1 = 0 THEN 1 / 0 WHEN 1 = 1 THEN 1 ELSE 2 / 0 END" +== 020 +-- truncate_limit: 100 +SELECT CASE 1 WHEN 0 THEN 1/0 WHEN 1 THEN 1 ELSE 2/0 END +-- +STMT: SelectStmt +TRUNCATED: "SELECT CASE 1 WHEN 0 THEN 1 / 0 WHEN 1 THEN 1 ELSE 2 / 0 END" +== 021 +-- truncate_limit: 100 +-- However we do not currently suppress folding of potentially +-- reachable subexpressions +SELECT CASE WHEN i > 100 THEN 1/0 ELSE 0 END FROM case_tbl +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT CASE WHEN i > 100 THEN 1 / 0 ELSE 0 END FROM case_tbl" +== 022 +-- truncate_limit: 100 +-- Test for cases involving untyped literals in test expression +SELECT CASE 'a' WHEN 'a' THEN 1 ELSE 2 END +-- +STMT: SelectStmt +TRUNCATED: "SELECT CASE 'a' WHEN 'a' THEN 1 ELSE 2 END" +== 023 +-- truncate_limit: 100 +|-- +-- Examples of targets involving tables +|-- + +SELECT + CASE + WHEN i >= 3 THEN i + END AS ">= 3 or Null" + FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT CASE WHEN i >= 3 THEN i END AS \">= 3 or Null\" FROM case_tbl" +== 024 +-- truncate_limit: 100 +SELECT + CASE WHEN i >= 3 THEN (i + i) + ELSE i + END AS "Simplest Math" + FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT CASE WHEN i >= 3 THEN i + i ELSE i END AS \"Simplest Math\" FROM case_tbl" +== 025 +-- truncate_limit: 100 +SELECT i AS "Value", + CASE WHEN (i < 0) THEN 'small' + WHEN (i = 0) THEN 'zero' + WHEN (i = 1) THEN 'one' + WHEN (i = 2) THEN 'two' + ELSE 'big' + END AS "Category" + FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM case_tbl" +== 026 +-- truncate_limit: 100 +SELECT + CASE WHEN ((i < 0) or (i < 0)) THEN 'small' + WHEN ((i = 0) or (i = 0)) THEN 'zero' + WHEN ((i = 1) or (i = 1)) THEN 'one' + WHEN ((i = 2) or (i = 2)) THEN 'two' + ELSE 'big' + END AS "Category" + FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM case_tbl" +== 027 +-- truncate_limit: 100 +|-- +-- Examples of qualifications involving tables +|-- + +|-- +-- NULLIF() and COALESCE() +-- Shorthand forms for typical CASE constructs +-- defined in the SQL standard. +|-- + +SELECT * FROM CASE_TBL WHERE COALESCE(f,i) = 4 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +FILTER: schema="" table="" column="f" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM case_tbl WHERE COALESCE(f, i) = 4" +== 028 +-- truncate_limit: 100 +SELECT * FROM CASE_TBL WHERE NULLIF(f,i) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +FILTER: schema="" table="" column="f" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM case_tbl WHERE (NULLIF(f, i)) = 2" +== 029 +-- truncate_limit: 100 +SELECT COALESCE(a.f, b.i, b.j) + FROM CASE_TBL a, CASE2_TBL b +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "a"="case_tbl" +ALIAS: "b"="case2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT COALESCE(a.f, b.i, b.j) FROM case_tbl a, case2_tbl b" +== 030 +-- truncate_limit: 100 +SELECT * + FROM CASE_TBL a, CASE2_TBL b + WHERE COALESCE(a.f, b.i, b.j) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "a"="case_tbl" +ALIAS: "b"="case2_tbl" +FILTER: schema="" table="a" column="f" +FILTER: schema="" table="b" column="i" +FILTER: schema="" table="b" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM case_tbl a, case2_tbl b WHERE COALESCE(a.f, b.i, b.j) = 2" +== 031 +-- truncate_limit: 100 +SELECT NULLIF(a.i,b.i) AS "NULLIF(a.i,b.i)", + NULLIF(b.i, 4) AS "NULLIF(b.i,4)" + FROM CASE_TBL a, CASE2_TBL b +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "a"="case_tbl" +ALIAS: "b"="case2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM case_tbl a, case2_tbl b" +== 032 +-- truncate_limit: 100 +SELECT * + FROM CASE_TBL a, CASE2_TBL b + WHERE COALESCE(f,b.i) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "a"="case_tbl" +ALIAS: "b"="case2_tbl" +FILTER: schema="" table="" column="f" +FILTER: schema="" table="b" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM case_tbl a, case2_tbl b WHERE COALESCE(f, b.i) = 2" +== 033 +-- truncate_limit: 100 +-- Tests for constant subexpression simplification + +explain (costs off) +SELECT * FROM CASE_TBL WHERE NULLIF(1, 2) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM case_tbl WHERE (NULLIF(1, 2)) = 2" +== 034 +-- truncate_limit: 100 +explain (costs off) +SELECT * FROM CASE_TBL WHERE NULLIF(1, 1) IS NOT NULL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM case_tbl WHERE NULLIF(1, 1) IS NOT NULL" +== 035 +-- truncate_limit: 100 +explain (costs off) +SELECT * FROM CASE_TBL WHERE NULLIF(1, null) = 2 +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM case_tbl WHERE (NULLIF(1, NULL)) = 2" +== 036 +-- truncate_limit: 100 +|-- +-- Examples of updates involving tables +|-- + +UPDATE CASE_TBL + SET i = CASE WHEN i >= 3 THEN (- i) + ELSE (2 * i) END +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE case_tbl SET i = CASE WHEN i >= 3 THEN - i ELSE 2 * i END" +== 037 +-- truncate_limit: 100 +SELECT * FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM case_tbl" +== 038 +-- truncate_limit: 100 +UPDATE CASE_TBL + SET i = CASE WHEN i >= 2 THEN (2 * i) + ELSE (3 * i) END +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE case_tbl SET i = CASE WHEN i >= 2 THEN 2 * i ELSE 3 * i END" +== 039 +-- truncate_limit: 100 +SELECT * FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM case_tbl" +== 040 +-- truncate_limit: 100 +UPDATE CASE_TBL + SET i = CASE WHEN b.i >= 2 THEN (2 * j) + ELSE (3 * j) END + FROM CASE2_TBL b + WHERE j = -CASE_TBL.i +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DML +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=Select +ALIAS: "b"="case2_tbl" +STMT: UpdateStmt +TRUNCATED: "UPDATE case_tbl SET ... = ... FROM case2_tbl b WHERE j = (- case_tbl.i)" +== 041 +-- truncate_limit: 100 +SELECT * FROM CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM case_tbl" +== 042 +-- truncate_limit: 100 +|-- +-- Nested CASE expressions +|-- + +-- This test exercises a bug caused by aliasing econtext->caseValue_isNull +-- with the isNull argument of the inner CASE's CaseExpr evaluation. After +-- evaluating the vol(null) expression in the inner CASE's second WHEN-clause, +-- the isNull flag for the case test value incorrectly became true, causing +-- the third WHEN-clause not to match. The volatile function calls are needed +-- to prevent constant-folding in the planner, which would hide the bug. + +-- Wrap this in a single transaction so the transient '=' operator doesn't +-- cause problems in concurrent sessions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 043 +-- truncate_limit: 100 +CREATE FUNCTION vol(text) returns text as + 'begin return $1; end' language plpgsql volatile +-- +FUNCTION: name="vol" function="vol" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION vol(text) RETURNS text AS $$begin return $1; end$$ LANGUAGE plpgsql VOLATILE" +== 044 +-- truncate_limit: 100 +SELECT CASE + (CASE vol('bar') + WHEN 'foo' THEN 'it was foo!' + WHEN vol(null) THEN 'null input' + WHEN 'bar' THEN 'it was bar!' END + ) + WHEN 'it was foo!' THEN 'foo recognized' + WHEN 'it was bar!' THEN 'bar recognized' + ELSE 'unrecognized' END +-- +FUNCTION: name="vol" function="vol" schema="" ctx=Call +FUNCTION: name="vol" function="vol" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 045 +-- truncate_limit: 100 +-- In this case, we can't inline the SQL function without confusing things. +CREATE DOMAIN foodomain AS text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN foodomain AS text" +== 046 +-- truncate_limit: 100 +CREATE FUNCTION volfoo(text) returns foodomain as + 'begin return $1::foodomain; end' language plpgsql volatile +-- +FUNCTION: name="volfoo" function="volfoo" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION volfoo(text) RETURNS foodomain AS $$begin return $1::foodomain; end$$ LANGUAGE pl..." +== 047 +-- truncate_limit: 100 +CREATE FUNCTION inline_eq(foodomain, foodomain) returns boolean as + 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' language sql +-- +FUNCTION: name="inline_eq" function="inline_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION inline_eq(foodomain, foodomain) RETURNS boolean AS $$SELECT CASE $2::text WHEN $1..." +== 048 +-- truncate_limit: 100 +CREATE OPERATOR = (procedure = inline_eq, + leftarg = foodomain, rightarg = foodomain) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR = (procedure = inline_eq, leftarg = foodomain, rightarg = foodomain)" +== 049 +-- truncate_limit: 100 +SELECT CASE volfoo('bar') WHEN 'foo'::foodomain THEN 'is foo' ELSE 'is not foo' END +-- +FUNCTION: name="volfoo" function="volfoo" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT CASE volfoo('bar') WHEN 'foo'::foodomain THEN 'is foo' ELSE 'is not foo' END" +== 050 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 051 +-- truncate_limit: 100 +-- Test multiple evaluation of a CASE arg that is a read/write object (#14472) +-- Wrap this in a single transaction so the transient '=' operator doesn't +-- cause problems in concurrent sessions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 052 +-- truncate_limit: 100 +CREATE DOMAIN arrdomain AS int[] +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN arrdomain AS int[]" +== 053 +-- truncate_limit: 100 +CREATE FUNCTION make_ad(int,int) returns arrdomain as + 'declare x arrdomain; + begin + x := array[$1,$2]; + return x; + end' language plpgsql volatile +-- +FUNCTION: name="make_ad" function="make_ad" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION make_ad(int, int) RETURNS arrdomain AS $$declare x arrdomain;\n begin\n x := ..." +== 054 +-- truncate_limit: 100 +CREATE FUNCTION ad_eq(arrdomain, arrdomain) returns boolean as + 'begin return array_eq($1, $2); end' language plpgsql +-- +FUNCTION: name="ad_eq" function="ad_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ad_eq(arrdomain, arrdomain) RETURNS boolean AS $$begin return array_eq($1, $2); e..." +== 055 +-- truncate_limit: 100 +CREATE OPERATOR = (procedure = ad_eq, + leftarg = arrdomain, rightarg = arrdomain) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR = (procedure = ad_eq, leftarg = arrdomain, rightarg = arrdomain)" +== 056 +-- truncate_limit: 100 +SELECT CASE make_ad(1,2) + WHEN array[2,4]::arrdomain THEN 'wrong' + WHEN array[2,5]::arrdomain THEN 'still wrong' + WHEN array[1,2]::arrdomain THEN 'right' + END +-- +FUNCTION: name="make_ad" function="make_ad" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 057 +-- truncate_limit: 100 +-- While we're here, also test handling of a NULLIF arg that is a read/write +-- object (bug #18722) + +SELECT NULLIF(make_ad(1,2), array[2,3]::arrdomain) +-- +FUNCTION: name="make_ad" function="make_ad" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT NULLIF(make_ad(1, 2), ARRAY[2, 3]::arrdomain)" +== 058 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 059 +-- truncate_limit: 100 +-- Test interaction of CASE with ArrayCoerceExpr (bug #15471) +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 060 +-- truncate_limit: 100 +CREATE TYPE casetestenum AS ENUM ('e', 'f', 'g') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE casetestenum AS ENUM ('e', 'f', 'g')" +== 061 +-- truncate_limit: 100 +SELECT + CASE 'foo'::text + WHEN 'foo' THEN ARRAY['a', 'b', 'c', 'd'] || enum_range(NULL::casetestenum)::text[] + ELSE ARRAY['x', 'y'] + END +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 062 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 063 +-- truncate_limit: 100 +|-- +-- Clean up +|-- + +DROP TABLE CASE_TBL +-- +TABLE: name="case_tbl" schema="" table="case_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE case_tbl" +== 064 +-- truncate_limit: 100 +DROP TABLE CASE2_TBL +-- +TABLE: name="case2_tbl" schema="" table="case2_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE case2_tbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/char.metadata.json b/parser/testdata/summary_truncate/postgres_regress/char.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/char.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/char.test b/parser/testdata/summary_truncate/postgres_regress/char.test new file mode 100644 index 0000000..b5eb8d8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/char.test @@ -0,0 +1,276 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CHAR +|-- + +-- Per SQL standard, CHAR means character(1), that is a varlena type +-- with a constraint restricting it to one character (not byte) + +SELECT char 'c' = char 'c' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT char 'c' = char 'c' AS \"true\"" +== 002 +-- truncate_limit: 100 +|-- +-- Build a table for testing +-- (This temporarily hides the table created in test_setup.sql) +|-- + +CREATE TEMP TABLE CHAR_TBL(f1 char) +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE char_tbl (f1 char(1))" +== 003 +-- truncate_limit: 100 +INSERT INTO CHAR_TBL (f1) VALUES ('a') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('a')" +== 004 +-- truncate_limit: 100 +INSERT INTO CHAR_TBL (f1) VALUES ('A') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('A')" +== 005 +-- truncate_limit: 100 +-- any of the following three input formats are acceptable +INSERT INTO CHAR_TBL (f1) VALUES ('1') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('1')" +== 006 +-- truncate_limit: 100 +INSERT INTO CHAR_TBL (f1) VALUES (2) +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES (2)" +== 007 +-- truncate_limit: 100 +INSERT INTO CHAR_TBL (f1) VALUES ('3') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('3')" +== 008 +-- truncate_limit: 100 +-- zero-length char +INSERT INTO CHAR_TBL (f1) VALUES ('') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('')" +== 009 +-- truncate_limit: 100 +-- try char's of greater than 1 length +INSERT INTO CHAR_TBL (f1) VALUES ('cd') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('cd')" +== 010 +-- truncate_limit: 100 +INSERT INTO CHAR_TBL (f1) VALUES ('c ') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('c ')" +== 011 +-- truncate_limit: 100 +SELECT * FROM CHAR_TBL +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM char_tbl" +== 012 +-- truncate_limit: 100 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 <> 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM char_tbl c WHERE c.f1 <> 'a'" +== 013 +-- truncate_limit: 100 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 = 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM char_tbl c WHERE c.f1 = 'a'" +== 014 +-- truncate_limit: 100 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 < 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM char_tbl c WHERE c.f1 < 'a'" +== 015 +-- truncate_limit: 100 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 <= 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM char_tbl c WHERE c.f1 <= 'a'" +== 016 +-- truncate_limit: 100 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 > 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM char_tbl c WHERE c.f1 > 'a'" +== 017 +-- truncate_limit: 100 +SELECT c.* + FROM CHAR_TBL c + WHERE c.f1 >= 'a' +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +ALIAS: "c"="char_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM char_tbl c WHERE c.f1 >= 'a'" +== 018 +-- truncate_limit: 100 +DROP TABLE CHAR_TBL +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE char_tbl" +== 019 +-- truncate_limit: 100 +|-- +-- Now test longer arrays of char +|-- +-- This char_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. +|-- + +INSERT INTO CHAR_TBL (f1) VALUES ('abcde') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('abcde')" +== 020 +-- truncate_limit: 100 +SELECT * FROM CHAR_TBL +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM char_tbl" +== 021 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('abcd ', 'char(4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('abcd ', 'char(4)')" +== 022 +-- truncate_limit: 100 +SELECT pg_input_is_valid('abcde', 'char(4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('abcde', 'char(4)')" +== 023 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('abcde', 'char(4)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('abcde', 'char(4)')" +== 024 +-- truncate_limit: 100 +|-- +-- Also test "char", which is an ad-hoc one-byte type. It can only +-- really store ASCII characters, but we allow high-bit-set characters +-- to be accessed via bytea-like escapes. +|-- + +SELECT 'a'::"char" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a'::\"char\"" +== 025 +-- truncate_limit: 100 +SELECT '\101'::"char" +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\\\\101'::\"char\"" +== 026 +-- truncate_limit: 100 +SELECT '\377'::"char" +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\\\\377'::\"char\"" +== 027 +-- truncate_limit: 100 +SELECT 'a'::"char"::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a'::\"char\"::text" +== 028 +-- truncate_limit: 100 +SELECT '\377'::"char"::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\\\\377'::\"char\"::text" +== 029 +-- truncate_limit: 100 +SELECT '\000'::"char"::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\\\\000'::\"char\"::text" +== 030 +-- truncate_limit: 100 +SELECT 'a'::text::"char" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a'::text::\"char\"" +== 031 +-- truncate_limit: 100 +SELECT '\377'::text::"char" +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\\\\377'::text::\"char\"" +== 032 +-- truncate_limit: 100 +SELECT ''::text::"char" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::text::\"char\"" diff --git a/parser/testdata/summary_truncate/postgres_regress/circle.metadata.json b/parser/testdata/summary_truncate/postgres_regress/circle.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/circle.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/circle.test b/parser/testdata/summary_truncate/postgres_regress/circle.test new file mode 100644 index 0000000..feb9c63 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/circle.test @@ -0,0 +1,202 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CIRCLE +|-- + +-- Back off displayed precision a little bit to reduce platform-to-platform +-- variation in results. +SET extra_float_digits = -1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO -1" +== 002 +-- truncate_limit: 100 +CREATE TABLE CIRCLE_TBL (f1 circle) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE circle_tbl (f1 circle)" +== 003 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('<(5,1),3>')" +== 004 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES ('((1,2),100)') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('((1,2),100)')" +== 005 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES (' 1 , 3 , 5 ') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES (' 1 , 3 , 5 ')" +== 006 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES (' ( ( 1 , 2 ) , 3 ) ') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES (' ( ( 1 , 2 ) , 3 ) ')" +== 007 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES (' ( 100 , 200 ) , 10 ') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES (' ( 100 , 200 ) , 10 ')" +== 008 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES (' < ( 100 , 1 ) , 115 > ') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES (' < ( 100 , 1 ) , 115 > ')" +== 009 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES ('<(3,5),0>') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('<(3,5),0>')" +== 010 +-- truncate_limit: 100 +-- Zero radius + +INSERT INTO CIRCLE_TBL VALUES ('<(3,5),NaN>') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('<(3,5),NaN>')" +== 011 +-- truncate_limit: 100 +-- NaN radius + +-- bad values + +INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('<(-100,0),-100>')" +== 012 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('<(100,200),10')" +== 013 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10> x') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('<(100,200),10> x')" +== 014 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('1abc,3,5')" +== 015 +-- truncate_limit: 100 +INSERT INTO CIRCLE_TBL VALUES ('(3,(1,2),3)') +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circle_tbl VALUES ('(3,(1,2),3)')" +== 016 +-- truncate_limit: 100 +SELECT * FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM circle_tbl" +== 017 +-- truncate_limit: 100 +SELECT center(f1) AS center + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="center" function="center" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT center(f1) AS center FROM circle_tbl" +== 018 +-- truncate_limit: 100 +SELECT radius(f1) AS radius + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="radius" function="radius" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT radius(f1) AS radius FROM circle_tbl" +== 019 +-- truncate_limit: 100 +SELECT diameter(f1) AS diameter + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="diameter" function="diameter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT diameter(f1) AS diameter FROM circle_tbl" +== 020 +-- truncate_limit: 100 +SELECT f1 FROM CIRCLE_TBL WHERE radius(f1) < 5 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="radius" function="radius" schema="" ctx=Call +FUNCTION: name="radius" function="radius" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM circle_tbl WHERE radius(f1) < 5" +== 021 +-- truncate_limit: 100 +SELECT f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="diameter" function="diameter" schema="" ctx=Call +FUNCTION: name="diameter" function="diameter" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM circle_tbl WHERE diameter(f1) >= 10" +== 022 +-- truncate_limit: 100 +SELECT c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance + FROM CIRCLE_TBL c1, CIRCLE_TBL c2 + WHERE (c1.f1 < c2.f1) AND ((c1.f1 <-> c2.f1) > 0) + ORDER BY distance, area(c1.f1), area(c2.f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FUNCTION: name="area" function="area" schema="" ctx=Call +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM circle_tbl c1, circle_tbl c2 WHERE ... ORDER BY distance, area(c1.f1), area(c2.f1)" diff --git a/parser/testdata/summary_truncate/postgres_regress/cluster.metadata.json b/parser/testdata/summary_truncate/postgres_regress/cluster.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/cluster.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/cluster.test b/parser/testdata/summary_truncate/postgres_regress/cluster.test new file mode 100644 index 0000000..7037c7a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/cluster.test @@ -0,0 +1,1644 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CLUSTER +|-- + +CREATE TABLE clstr_tst_s (rf_a SERIAL PRIMARY KEY, + b INT) +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstr_tst_s (rf_a serial PRIMARY KEY, b int)" +== 002 +-- truncate_limit: 100 +CREATE TABLE clstr_tst (a SERIAL PRIMARY KEY, + b INT, + c TEXT, + d TEXT, + CONSTRAINT clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstr_tst (a serial PRIMARY KEY, b int, c text, d text, CONSTRAINT clstr_tst_con FOR..." +== 003 +-- truncate_limit: 100 +CREATE INDEX clstr_tst_b ON clstr_tst (b) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clstr_tst_b ON clstr_tst USING btree (b)" +== 004 +-- truncate_limit: 100 +CREATE INDEX clstr_tst_c ON clstr_tst (c) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clstr_tst_c ON clstr_tst USING btree (c)" +== 005 +-- truncate_limit: 100 +CREATE INDEX clstr_tst_c_b ON clstr_tst (c,b) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clstr_tst_c_b ON clstr_tst USING btree (c, b)" +== 006 +-- truncate_limit: 100 +CREATE INDEX clstr_tst_b_c ON clstr_tst (b,c) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clstr_tst_b_c ON clstr_tst USING btree (b, c)" +== 007 +-- truncate_limit: 100 +INSERT INTO clstr_tst_s (b) VALUES (0) +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst_s (b) VALUES (0)" +== 008 +-- truncate_limit: 100 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s" +== 009 +-- truncate_limit: 100 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s" +== 010 +-- truncate_limit: 100 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s" +== 011 +-- truncate_limit: 100 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s" +== 012 +-- truncate_limit: 100 +INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s +-- +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=DML +TABLE: name="clstr_tst_s" schema="" table="clstr_tst_s" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst_s (b) SELECT b FROM clstr_tst_s" +== 013 +-- truncate_limit: 100 +CREATE TABLE clstr_tst_inh () INHERITS (clstr_tst) +-- +TABLE: name="clstr_tst_inh" schema="" table="clstr_tst_inh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstr_tst_inh () INHERITS (clstr_tst)" +== 014 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (11, 'once') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (11, 'once')" +== 015 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (10, 'diez') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (10, 'diez')" +== 016 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (31, 'treinta y uno')" +== 017 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (22, 'veintidos')" +== 018 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (3, 'tres') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (3, 'tres')" +== 019 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (20, 'veinte')" +== 020 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (23, 'veintitres')" +== 021 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (21, 'veintiuno')" +== 022 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (4, 'cuatro')" +== 023 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (14, 'catorce')" +== 024 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (2, 'dos') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (2, 'dos')" +== 025 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (18, 'dieciocho')" +== 026 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (27, 'veintisiete')" +== 027 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (25, 'veinticinco')" +== 028 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (13, 'trece') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (13, 'trece')" +== 029 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (28, 'veintiocho')" +== 030 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (32, 'treinta y dos')" +== 031 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (5, 'cinco')" +== 032 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (29, 'veintinueve')" +== 033 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (1, 'uno') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (1, 'uno')" +== 034 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (24, 'veinticuatro')" +== 035 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (30, 'treinta')" +== 036 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (12, 'doce') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (12, 'doce')" +== 037 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (17, 'diecisiete')" +== 038 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (9, 'nueve')" +== 039 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (19, 'diecinueve')" +== 040 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (26, 'veintiseis')" +== 041 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (15, 'quince') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (15, 'quince')" +== 042 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (7, 'siete') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (7, 'siete')" +== 043 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (16, 'dieciseis')" +== 044 +-- truncate_limit: 100 +INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho')" +== 045 +-- truncate_limit: 100 +-- This entry is needed to test that TOASTED values are copied correctly. +INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('xyzzy', 100000)) +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('xyzzy', 100000))" +== 046 +-- truncate_limit: 100 +CLUSTER clstr_tst_c ON clstr_tst +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_tst USING clstr_tst_c" +== 047 +-- truncate_limit: 100 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c, SUBSTRING(d FROM 1 FOR 30::int), length(d) FROM clstr_tst" +== 048 +-- truncate_limit: 100 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c, SUBSTRING(d FROM 1 FOR 30::int), length(d) FROM clstr_tst ORDER BY a" +== 049 +-- truncate_limit: 100 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY b +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c, SUBSTRING(d FROM 1 FOR 30::int), length(d) FROM clstr_tst ORDER BY b" +== 050 +-- truncate_limit: 100 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY c +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c, SUBSTRING(d FROM 1 FOR 30::int), length(d) FROM clstr_tst ORDER BY c" +== 051 +-- truncate_limit: 100 +-- Verify that inheritance link still works +INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table') +-- +TABLE: name="clstr_tst_inh" schema="" table="clstr_tst_inh" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table')" +== 052 +-- truncate_limit: 100 +SELECT a,b,c,substring(d for 30), length(d) from clstr_tst +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=Select +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c, SUBSTRING(d FROM 1 FOR 30::int), length(d) FROM clstr_tst" +== 053 +-- truncate_limit: 100 +-- Verify that foreign key link still works +INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail') +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail')" +== 054 +-- truncate_limit: 100 +SELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst'::regclass +ORDER BY 1 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT conname FROM pg_constraint WHERE conrelid = 'clstr_tst'::regclass ORDER BY 1" +== 055 +-- truncate_limit: 100 +SELECT relname, relkind, + EXISTS(SELECT 1 FROM pg_class WHERE oid = c.reltoastrelid) AS hastoast +FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="c" column="reltoastrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c WHERE relname LIKE 'clstr_tst%' ORDER BY relname" +== 056 +-- truncate_limit: 100 +-- Verify that indisclustered is correctly set +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pg_class_2"="pg_class" +FILTER: schema="" table="pg_class" column="oid" +FILTER: schema="" table="" column="indexrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="pg_class_2" column="oid" +FILTER: schema="" table="pg_class_2" column="relname" +FILTER: schema="" table="" column="indisclustered" +STMT: SelectStmt +TRUNCATED: "SELECT pg_class.relname FROM pg_index, pg_class, pg_class pg_class_2 WHERE ..." +== 057 +-- truncate_limit: 100 +-- Try changing indisclustered +ALTER TABLE clstr_tst CLUSTER ON clstr_tst_b_c +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE clstr_tst CLUSTER ON clstr_tst_b_c" +== 058 +-- truncate_limit: 100 +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pg_class_2"="pg_class" +FILTER: schema="" table="pg_class" column="oid" +FILTER: schema="" table="" column="indexrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="pg_class_2" column="oid" +FILTER: schema="" table="pg_class_2" column="relname" +FILTER: schema="" table="" column="indisclustered" +STMT: SelectStmt +TRUNCATED: "SELECT pg_class.relname FROM pg_index, pg_class, pg_class pg_class_2 WHERE ..." +== 059 +-- truncate_limit: 100 +-- Try turning off all clustering +ALTER TABLE clstr_tst SET WITHOUT CLUSTER +-- +TABLE: name="clstr_tst" schema="" table="clstr_tst" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE clstr_tst SET WITHOUT CLUSTER" +== 060 +-- truncate_limit: 100 +SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2 +WHERE pg_class.oid=indexrelid + AND indrelid=pg_class_2.oid + AND pg_class_2.relname = 'clstr_tst' + AND indisclustered +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pg_class_2"="pg_class" +FILTER: schema="" table="pg_class" column="oid" +FILTER: schema="" table="" column="indexrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="pg_class_2" column="oid" +FILTER: schema="" table="pg_class_2" column="relname" +FILTER: schema="" table="" column="indisclustered" +STMT: SelectStmt +TRUNCATED: "SELECT pg_class.relname FROM pg_index, pg_class, pg_class pg_class_2 WHERE ..." +== 061 +-- truncate_limit: 100 +-- Verify that toast tables are clusterable +CLUSTER pg_toast.pg_toast_826 USING pg_toast_826_index +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER pg_toast.pg_toast_826 USING pg_toast_826_index" +== 062 +-- truncate_limit: 100 +-- Verify that clustering all tables does in fact cluster the right ones +CREATE USER regress_clstr_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_clstr_user" +== 063 +-- truncate_limit: 100 +CREATE TABLE clstr_1 (a INT PRIMARY KEY) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstr_1 (a int PRIMARY KEY)" +== 064 +-- truncate_limit: 100 +CREATE TABLE clstr_2 (a INT PRIMARY KEY) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstr_2 (a int PRIMARY KEY)" +== 065 +-- truncate_limit: 100 +CREATE TABLE clstr_3 (a INT PRIMARY KEY) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstr_3 (a int PRIMARY KEY)" +== 066 +-- truncate_limit: 100 +ALTER TABLE clstr_1 OWNER TO regress_clstr_user +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE clstr_1 OWNER TO regress_clstr_user" +== 067 +-- truncate_limit: 100 +ALTER TABLE clstr_3 OWNER TO regress_clstr_user +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE clstr_3 OWNER TO regress_clstr_user" +== 068 +-- truncate_limit: 100 +GRANT SELECT ON clstr_2 TO regress_clstr_user +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON clstr_2 TO regress_clstr_user" +== 069 +-- truncate_limit: 100 +INSERT INTO clstr_1 VALUES (2) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_1 VALUES (2)" +== 070 +-- truncate_limit: 100 +INSERT INTO clstr_1 VALUES (1) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_1 VALUES (1)" +== 071 +-- truncate_limit: 100 +INSERT INTO clstr_2 VALUES (2) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_2 VALUES (2)" +== 072 +-- truncate_limit: 100 +INSERT INTO clstr_2 VALUES (1) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_2 VALUES (1)" +== 073 +-- truncate_limit: 100 +INSERT INTO clstr_3 VALUES (2) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_3 VALUES (2)" +== 074 +-- truncate_limit: 100 +INSERT INTO clstr_3 VALUES (1) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_3 VALUES (1)" +== 075 +-- truncate_limit: 100 +-- "CLUSTER " on a table that hasn't been clustered +CLUSTER clstr_2 +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_2" +== 076 +-- truncate_limit: 100 +CLUSTER clstr_1_pkey ON clstr_1 +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_1 USING clstr_1_pkey" +== 077 +-- truncate_limit: 100 +CLUSTER clstr_2 USING clstr_2_pkey +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_2 USING clstr_2_pkey" +== 078 +-- truncate_limit: 100 +SELECT * FROM clstr_1 UNION ALL + SELECT * FROM clstr_2 UNION ALL + SELECT * FROM clstr_3 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=Select +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=Select +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM clstr_1 UNION ALL SELECT * FROM clstr_2) UNION ALL SELECT * FROM clstr_3" +== 079 +-- truncate_limit: 100 +-- revert to the original state +DELETE FROM clstr_1 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM clstr_1" +== 080 +-- truncate_limit: 100 +DELETE FROM clstr_2 +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM clstr_2" +== 081 +-- truncate_limit: 100 +DELETE FROM clstr_3 +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM clstr_3" +== 082 +-- truncate_limit: 100 +INSERT INTO clstr_1 VALUES (2) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_1 VALUES (2)" +== 083 +-- truncate_limit: 100 +INSERT INTO clstr_1 VALUES (1) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_1 VALUES (1)" +== 084 +-- truncate_limit: 100 +INSERT INTO clstr_2 VALUES (2) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_2 VALUES (2)" +== 085 +-- truncate_limit: 100 +INSERT INTO clstr_2 VALUES (1) +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_2 VALUES (1)" +== 086 +-- truncate_limit: 100 +INSERT INTO clstr_3 VALUES (2) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_3 VALUES (2)" +== 087 +-- truncate_limit: 100 +INSERT INTO clstr_3 VALUES (1) +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_3 VALUES (1)" +== 088 +-- truncate_limit: 100 +-- this user can only cluster clstr_1 and clstr_3, but the latter +-- has not been clustered +SET SESSION AUTHORIZATION regress_clstr_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_clstr_user" +== 089 +-- truncate_limit: 100 +SET client_min_messages = ERROR +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO error" +== 090 +-- truncate_limit: 100 +-- order of "skipping" warnings may vary +CLUSTER +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER" +== 091 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 092 +-- truncate_limit: 100 +SELECT * FROM clstr_1 UNION ALL + SELECT * FROM clstr_2 UNION ALL + SELECT * FROM clstr_3 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=Select +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=Select +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM clstr_1 UNION ALL SELECT * FROM clstr_2) UNION ALL SELECT * FROM clstr_3" +== 093 +-- truncate_limit: 100 +-- cluster a single table using the indisclustered bit previously set +DELETE FROM clstr_1 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM clstr_1" +== 094 +-- truncate_limit: 100 +INSERT INTO clstr_1 VALUES (2) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_1 VALUES (2)" +== 095 +-- truncate_limit: 100 +INSERT INTO clstr_1 VALUES (1) +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_1 VALUES (1)" +== 096 +-- truncate_limit: 100 +CLUSTER clstr_1 +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_1" +== 097 +-- truncate_limit: 100 +SELECT * FROM clstr_1 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clstr_1" +== 098 +-- truncate_limit: 100 +-- Test MVCC-safety of cluster. There isn't much we can do to verify the +-- results with a single backend... + +CREATE TABLE clustertest (key int PRIMARY KEY) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clustertest (key int PRIMARY KEY)" +== 099 +-- truncate_limit: 100 +INSERT INTO clustertest VALUES (10) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clustertest VALUES (10)" +== 100 +-- truncate_limit: 100 +INSERT INTO clustertest VALUES (20) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clustertest VALUES (20)" +== 101 +-- truncate_limit: 100 +INSERT INTO clustertest VALUES (30) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clustertest VALUES (30)" +== 102 +-- truncate_limit: 100 +INSERT INTO clustertest VALUES (40) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clustertest VALUES (40)" +== 103 +-- truncate_limit: 100 +INSERT INTO clustertest VALUES (50) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clustertest VALUES (50)" +== 104 +-- truncate_limit: 100 +-- Use a transaction so that updates are not committed when CLUSTER sees 'em +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 105 +-- truncate_limit: 100 +-- Test update where the old row version is found first in the scan +UPDATE clustertest SET key = 100 WHERE key = 10 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE clustertest SET key = 100 WHERE key = 10" +== 106 +-- truncate_limit: 100 +-- Test update where the new row version is found first in the scan +UPDATE clustertest SET key = 35 WHERE key = 40 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE clustertest SET key = 35 WHERE key = 40" +== 107 +-- truncate_limit: 100 +-- Test longer update chain +UPDATE clustertest SET key = 60 WHERE key = 50 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE clustertest SET key = 60 WHERE key = 50" +== 108 +-- truncate_limit: 100 +UPDATE clustertest SET key = 70 WHERE key = 60 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE clustertest SET key = 70 WHERE key = 60" +== 109 +-- truncate_limit: 100 +UPDATE clustertest SET key = 80 WHERE key = 70 +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE clustertest SET key = 80 WHERE key = 70" +== 110 +-- truncate_limit: 100 +SELECT * FROM clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clustertest" +== 111 +-- truncate_limit: 100 +CLUSTER clustertest_pkey ON clustertest +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clustertest USING clustertest_pkey" +== 112 +-- truncate_limit: 100 +SELECT * FROM clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clustertest" +== 113 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 114 +-- truncate_limit: 100 +SELECT * FROM clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clustertest" +== 115 +-- truncate_limit: 100 +-- check that temp tables can be clustered +create temp table clstr_temp (col1 int primary key, col2 text) +-- +TABLE: name="clstr_temp" schema="" table="clstr_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE clstr_temp (col1 int PRIMARY KEY, col2 text)" +== 116 +-- truncate_limit: 100 +insert into clstr_temp values (2, 'two'), (1, 'one') +-- +TABLE: name="clstr_temp" schema="" table="clstr_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_temp VALUES (2, 'two'), (1, 'one')" +== 117 +-- truncate_limit: 100 +cluster clstr_temp using clstr_temp_pkey +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_temp USING clstr_temp_pkey" +== 118 +-- truncate_limit: 100 +select * from clstr_temp +-- +TABLE: name="clstr_temp" schema="" table="clstr_temp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clstr_temp" +== 119 +-- truncate_limit: 100 +drop table clstr_temp +-- +TABLE: name="clstr_temp" schema="" table="clstr_temp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clstr_temp" +== 120 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 121 +-- truncate_limit: 100 +-- check clustering an empty table +DROP TABLE clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clustertest" +== 122 +-- truncate_limit: 100 +CREATE TABLE clustertest (f1 int PRIMARY KEY) +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clustertest (f1 int PRIMARY KEY)" +== 123 +-- truncate_limit: 100 +CLUSTER clustertest USING clustertest_pkey +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clustertest USING clustertest_pkey" +== 124 +-- truncate_limit: 100 +CLUSTER clustertest +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clustertest" +== 125 +-- truncate_limit: 100 +-- Check that partitioned tables can be clustered +CREATE TABLE clstrpart (a int) PARTITION BY RANGE (a) +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstrpart (a int) PARTITION BY RANGE (a)" +== 126 +-- truncate_limit: 100 +CREATE TABLE clstrpart1 PARTITION OF clstrpart FOR VALUES FROM (1) TO (10) PARTITION BY RANGE (a) +-- +TABLE: name="clstrpart1" schema="" table="clstrpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstrpart1 PARTITION OF clstrpart FOR VALUES FROM (1) TO (10) PARTITION BY RANGE (a)" +== 127 +-- truncate_limit: 100 +CREATE TABLE clstrpart11 PARTITION OF clstrpart1 FOR VALUES FROM (1) TO (5) +-- +TABLE: name="clstrpart11" schema="" table="clstrpart11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstrpart11 PARTITION OF clstrpart1 FOR VALUES FROM (1) TO (5)" +== 128 +-- truncate_limit: 100 +CREATE TABLE clstrpart12 PARTITION OF clstrpart1 FOR VALUES FROM (5) TO (10) PARTITION BY RANGE (a) +-- +TABLE: name="clstrpart12" schema="" table="clstrpart12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstrpart12 PARTITION OF clstrpart1 FOR VALUES FROM (5) TO (10) PARTITION BY RANGE (a)" +== 129 +-- truncate_limit: 100 +CREATE TABLE clstrpart2 PARTITION OF clstrpart FOR VALUES FROM (10) TO (20) +-- +TABLE: name="clstrpart2" schema="" table="clstrpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstrpart2 PARTITION OF clstrpart FOR VALUES FROM (10) TO (20)" +== 130 +-- truncate_limit: 100 +CREATE TABLE clstrpart3 PARTITION OF clstrpart DEFAULT PARTITION BY RANGE (a) +-- +TABLE: name="clstrpart3" schema="" table="clstrpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstrpart3 PARTITION OF clstrpart DEFAULT PARTITION BY RANGE (a)" +== 131 +-- truncate_limit: 100 +CREATE TABLE clstrpart33 PARTITION OF clstrpart3 DEFAULT +-- +TABLE: name="clstrpart33" schema="" table="clstrpart33" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstrpart33 PARTITION OF clstrpart3 DEFAULT" +== 132 +-- truncate_limit: 100 +CREATE INDEX clstrpart_only_idx ON ONLY clstrpart (a) +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clstrpart_only_idx ON ONLY clstrpart USING btree (a)" +== 133 +-- truncate_limit: 100 +CLUSTER clstrpart USING clstrpart_only_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstrpart USING clstrpart_only_idx" +== 134 +-- truncate_limit: 100 +-- fails +DROP INDEX clstrpart_only_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX clstrpart_only_idx" +== 135 +-- truncate_limit: 100 +CREATE INDEX clstrpart_idx ON clstrpart (a) +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clstrpart_idx ON clstrpart USING btree (a)" +== 136 +-- truncate_limit: 100 +-- Check that clustering sets new relfilenodes: +CREATE TEMP TABLE old_cluster_info AS SELECT relname, level, relfilenode, relkind FROM pg_partition_tree('clstrpart'::regclass) AS tree JOIN pg_class c ON c.oid=tree.relid +-- +TABLE: name="old_cluster_info" schema="" table="old_cluster_info" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE old_cluster_info AS SELECT relname, level, relfilenode, relkind FROM pg_pa..." +== 137 +-- truncate_limit: 100 +CLUSTER clstrpart USING clstrpart_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstrpart USING clstrpart_idx" +== 138 +-- truncate_limit: 100 +CREATE TEMP TABLE new_cluster_info AS SELECT relname, level, relfilenode, relkind FROM pg_partition_tree('clstrpart'::regclass) AS tree JOIN pg_class c ON c.oid=tree.relid +-- +TABLE: name="new_cluster_info" schema="" table="new_cluster_info" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE new_cluster_info AS SELECT relname, level, relfilenode, relkind FROM pg_pa..." +== 139 +-- truncate_limit: 100 +SELECT relname, old.level, old.relkind, old.relfilenode = new.relfilenode FROM old_cluster_info AS old JOIN new_cluster_info AS new USING (relname) ORDER BY relname COLLATE "C" +-- +TABLE: name="old_cluster_info" schema="" table="old_cluster_info" ctx=Select +TABLE: name="new_cluster_info" schema="" table="new_cluster_info" ctx=Select +ALIAS: "new"="new_cluster_info" +ALIAS: "old"="old_cluster_info" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM old_cluster_info old JOIN new_cluster_info new USING (relname) ORDER BY relname C..." +== 140 +-- truncate_limit: 100 +-- Partitioned indexes aren't and can't be marked un/clustered: +CLUSTER clstrpart +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstrpart" +== 141 +-- truncate_limit: 100 +ALTER TABLE clstrpart SET WITHOUT CLUSTER +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE clstrpart SET WITHOUT CLUSTER" +== 142 +-- truncate_limit: 100 +ALTER TABLE clstrpart CLUSTER ON clstrpart_idx +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE clstrpart CLUSTER ON clstrpart_idx" +== 143 +-- truncate_limit: 100 +DROP TABLE clstrpart +-- +TABLE: name="clstrpart" schema="" table="clstrpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clstrpart" +== 144 +-- truncate_limit: 100 +-- Ownership of partitions is checked +CREATE TABLE ptnowner(i int unique) PARTITION BY LIST (i) +-- +TABLE: name="ptnowner" schema="" table="ptnowner" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptnowner (i int UNIQUE) PARTITION BY LIST (i)" +== 145 +-- truncate_limit: 100 +CREATE INDEX ptnowner_i_idx ON ptnowner(i) +-- +TABLE: name="ptnowner" schema="" table="ptnowner" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ptnowner_i_idx ON ptnowner USING btree (i)" +== 146 +-- truncate_limit: 100 +CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1) +-- +TABLE: name="ptnowner1" schema="" table="ptnowner1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1)" +== 147 +-- truncate_limit: 100 +CREATE ROLE regress_ptnowner +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_ptnowner" +== 148 +-- truncate_limit: 100 +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2) +-- +TABLE: name="ptnowner2" schema="" table="ptnowner2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2)" +== 149 +-- truncate_limit: 100 +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner +-- +TABLE: name="ptnowner1" schema="" table="ptnowner1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ptnowner1 OWNER TO regress_ptnowner" +== 150 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_ptnowner +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_ptnowner" +== 151 +-- truncate_limit: 100 +CLUSTER ptnowner USING ptnowner_i_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER ptnowner USING ptnowner_i_idx" +== 152 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 153 +-- truncate_limit: 100 +ALTER TABLE ptnowner OWNER TO regress_ptnowner +-- +TABLE: name="ptnowner" schema="" table="ptnowner" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ptnowner OWNER TO regress_ptnowner" +== 154 +-- truncate_limit: 100 +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid +-- +TABLE: name="ptnowner_oldnodes" schema="" table="ptnowner_oldnodes" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE ptnowner_oldnodes AS SELECT oid, relname, relfilenode FROM pg_partition_tr..." +== 155 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_ptnowner +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_ptnowner" +== 156 +-- truncate_limit: 100 +CLUSTER ptnowner USING ptnowner_i_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER ptnowner USING ptnowner_i_idx" +== 157 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 158 +-- truncate_limit: 100 +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C" +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="ptnowner_oldnodes" schema="" table="ptnowner_oldnodes" ctx=Select +ALIAS: "a"="pg_class" +ALIAS: "b"="ptnowner_oldnodes" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class a JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE \"C\"" +== 159 +-- truncate_limit: 100 +DROP TABLE ptnowner +-- +TABLE: name="ptnowner" schema="" table="ptnowner" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ptnowner" +== 160 +-- truncate_limit: 100 +DROP ROLE regress_ptnowner +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_ptnowner" +== 161 +-- truncate_limit: 100 +-- Test CLUSTER with external tuplesorting + +create table clstr_4 as select * from tenk1 +-- +TABLE: name="clstr_4" schema="" table="clstr_4" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE clstr_4 AS SELECT * FROM tenk1" +== 162 +-- truncate_limit: 100 +create index cluster_sort on clstr_4 (hundred, thousand, tenthous) +-- +TABLE: name="clstr_4" schema="" table="clstr_4" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX cluster_sort ON clstr_4 USING btree (hundred, thousand, tenthous)" +== 163 +-- truncate_limit: 100 +-- ensure we don't use the index in CLUSTER nor the checking SELECTs +set enable_indexscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 164 +-- truncate_limit: 100 +-- Use external sort: +set maintenance_work_mem = '1MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET maintenance_work_mem TO \"1MB\"" +== 165 +-- truncate_limit: 100 +cluster clstr_4 using cluster_sort +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_4 USING cluster_sort" +== 166 +-- truncate_limit: 100 +select * from +(select hundred, lag(hundred) over () as lhundred, + thousand, lag(thousand) over () as lthousand, + tenthous, lag(tenthous) over () as ltenthous from clstr_4) ss +where row(hundred, thousand, tenthous) <= row(lhundred, lthousand, ltenthous) +-- +TABLE: name="clstr_4" schema="" table="clstr_4" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="lhundred" +FILTER: schema="" table="" column="lthousand" +FILTER: schema="" table="" column="ltenthous" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM clstr_4) ss WHERE ..." +== 167 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 168 +-- truncate_limit: 100 +reset maintenance_work_mem +-- +STMT: VariableSetStmt +TRUNCATED: "RESET maintenance_work_mem" +== 169 +-- truncate_limit: 100 +-- test CLUSTER on expression index +CREATE TABLE clstr_expression(id serial primary key, a int, b text COLLATE "C") +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clstr_expression (id serial PRIMARY KEY, a int, b text COLLATE \"C\")" +== 170 +-- truncate_limit: 100 +INSERT INTO clstr_expression(a, b) SELECT g.i % 42, 'prefix'||g.i FROM generate_series(1, 133) g(i) +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clstr_expression (a, b) SELECT ... FROM generate_series(1, 133) g(i)" +== 171 +-- truncate_limit: 100 +CREATE INDEX clstr_expression_minus_a ON clstr_expression ((-a), b) +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clstr_expression_minus_a ON clstr_expression USING btree ((- a), b)" +== 172 +-- truncate_limit: 100 +CREATE INDEX clstr_expression_upper_b ON clstr_expression ((upper(b))) +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DDL +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clstr_expression_upper_b ON clstr_expression USING btree (upper(b))" +== 173 +-- truncate_limit: 100 +-- verify indexes work before cluster +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 174 +-- truncate_limit: 100 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO FALSE" +== 175 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'" +== 176 +-- truncate_limit: 100 +SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'" +== 177 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE (- a) = -3 ORDER BY - a, b" +== 178 +-- truncate_limit: 100 +SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clstr_expression WHERE (- a) = -3 ORDER BY - a, b" +== 179 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 180 +-- truncate_limit: 100 +-- and after clustering on clstr_expression_minus_a +CLUSTER clstr_expression USING clstr_expression_minus_a +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_expression USING clstr_expression_minus_a" +== 181 +-- truncate_limit: 100 +WITH rows AS + (SELECT ctid, lag(a) OVER (ORDER BY ctid) AS la, a FROM clstr_expression) +SELECT * FROM rows WHERE la < a +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +CTE: "rows" +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="la" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "WITH rows AS (SELECT ... FROM clstr_expression) SELECT * FROM rows WHERE la < a" +== 182 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 183 +-- truncate_limit: 100 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO FALSE" +== 184 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'" +== 185 +-- truncate_limit: 100 +SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'" +== 186 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE (- a) = -3 ORDER BY - a, b" +== 187 +-- truncate_limit: 100 +SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clstr_expression WHERE (- a) = -3 ORDER BY - a, b" +== 188 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 189 +-- truncate_limit: 100 +-- and after clustering on clstr_expression_upper_b +CLUSTER clstr_expression USING clstr_expression_upper_b +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER clstr_expression USING clstr_expression_upper_b" +== 190 +-- truncate_limit: 100 +WITH rows AS + (SELECT ctid, lag(b) OVER (ORDER BY ctid) AS lb, b FROM clstr_expression) +SELECT * FROM rows WHERE upper(lb) > upper(b) +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +CTE: "rows" +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="lb" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "WITH rows AS (SELECT ... FROM clstr_expression) SELECT * FROM rows WHERE upper(lb) > upper(b)" +== 191 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 192 +-- truncate_limit: 100 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO FALSE" +== 193 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'" +== 194 +-- truncate_limit: 100 +SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3' +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'" +== 195 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE (- a) = -3 ORDER BY - a, b" +== 196 +-- truncate_limit: 100 +SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM clstr_expression WHERE (- a) = -3 ORDER BY - a, b" +== 197 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 198 +-- truncate_limit: 100 +-- clean up +DROP TABLE clustertest +-- +TABLE: name="clustertest" schema="" table="clustertest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clustertest" +== 199 +-- truncate_limit: 100 +DROP TABLE clstr_1 +-- +TABLE: name="clstr_1" schema="" table="clstr_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clstr_1" +== 200 +-- truncate_limit: 100 +DROP TABLE clstr_2 +-- +TABLE: name="clstr_2" schema="" table="clstr_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clstr_2" +== 201 +-- truncate_limit: 100 +DROP TABLE clstr_3 +-- +TABLE: name="clstr_3" schema="" table="clstr_3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clstr_3" +== 202 +-- truncate_limit: 100 +DROP TABLE clstr_4 +-- +TABLE: name="clstr_4" schema="" table="clstr_4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clstr_4" +== 203 +-- truncate_limit: 100 +DROP TABLE clstr_expression +-- +TABLE: name="clstr_expression" schema="" table="clstr_expression" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE clstr_expression" +== 204 +-- truncate_limit: 100 +DROP USER regress_clstr_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_clstr_user" diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.icu.utf8.metadata.json b/parser/testdata/summary_truncate/postgres_regress/collate.icu.utf8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.icu.utf8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.icu.utf8.test b/parser/testdata/summary_truncate/postgres_regress/collate.icu.utf8.test new file mode 100644 index 0000000..c85d0b2 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.icu.utf8.test @@ -0,0 +1,3980 @@ +== 001 +-- truncate_limit: 100 +/* + * This test is for ICU collations. + */ + +/* skip test if not UTF8 server encoding or no ICU collations installed */ +SELECT getdatabaseencoding() <> 'UTF8' OR + (SELECT count(*) FROM pg_collation WHERE collprovider = 'i' AND collname <> 'unicode') = 0 + AS skip_test +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="collprovider" +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT getdatabaseencoding() <> 'UTF8' OR (SELECT ... FROM pg_collation WHERE ...) = 0 AS skip_test" +== 002 +-- truncate_limit: 100 +SET client_encoding TO UTF8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_encoding TO utf8" +== 003 +-- truncate_limit: 100 +CREATE SCHEMA collate_tests +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA collate_tests" +== 004 +-- truncate_limit: 100 +SET search_path = collate_tests +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO collate_tests" +== 005 +-- truncate_limit: 100 +CREATE TABLE collate_test1 ( + a int, + b text COLLATE "en-x-icu" NOT NULL +) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test1 (a int, b text NOT NULL COLLATE \"en-x-icu\")" +== 006 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "ja_JP.eucjp-x-icu" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int, b text COLLATE \"ja_JP.eucjp-x-icu\")" +== 007 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "foo-x-icu" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int, b text COLLATE \"foo-x-icu\")" +== 008 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int COLLATE "en-x-icu", + b text +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int COLLATE \"en-x-icu\", b text)" +== 009 +-- truncate_limit: 100 +CREATE TABLE collate_test_like ( + LIKE collate_test1 +) +-- +TABLE: name="collate_test_like" schema="" table="collate_test_like" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_like (LIKE collate_test1)" +== 010 +-- truncate_limit: 100 +CREATE TABLE collate_test2 ( + a int, + b text COLLATE "sv-x-icu" +) +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test2 (a int, b text COLLATE \"sv-x-icu\")" +== 011 +-- truncate_limit: 100 +CREATE TABLE collate_test3 ( + a int, + b text COLLATE "C" +) +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test3 (a int, b text COLLATE \"C\")" +== 012 +-- truncate_limit: 100 +INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'äbc'), (3, 'bbc'), (4, 'ABC') +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'äbc'), (3, 'bbc'), (4, 'ABC')" +== 013 +-- truncate_limit: 100 +INSERT INTO collate_test2 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test2 SELECT * FROM collate_test1" +== 014 +-- truncate_limit: 100 +INSERT INTO collate_test3 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test3 SELECT * FROM collate_test1" +== 015 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b >= 'bbc'" +== 016 +-- truncate_limit: 100 +SELECT * FROM collate_test2 WHERE b >= 'bbc' +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 WHERE b >= 'bbc'" +== 017 +-- truncate_limit: 100 +SELECT * FROM collate_test3 WHERE b >= 'bbc' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 WHERE b >= 'bbc'" +== 018 +-- truncate_limit: 100 +SELECT * FROM collate_test3 WHERE b >= 'BBC' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 WHERE b >= 'BBC'" +== 019 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc'" +== 020 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE \"C\"" +== 021 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc' COLLATE \"C\"" +== 022 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "en-x-icu" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc' COLLATE \"en-x-icu\"" +== 023 +-- truncate_limit: 100 +CREATE DOMAIN testdomain_sv AS text COLLATE "sv-x-icu" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain_sv AS text COLLATE \"sv-x-icu\"" +== 024 +-- truncate_limit: 100 +CREATE DOMAIN testdomain_i AS int COLLATE "sv-x-icu" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain_i AS int COLLATE \"sv-x-icu\"" +== 025 +-- truncate_limit: 100 +-- fails +CREATE TABLE collate_test4 ( + a int, + b testdomain_sv +) +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test4 (a int, b testdomain_sv)" +== 026 +-- truncate_limit: 100 +INSERT INTO collate_test4 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test4 SELECT * FROM collate_test1" +== 027 +-- truncate_limit: 100 +SELECT a, b FROM collate_test4 ORDER BY b +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test4 ORDER BY b" +== 028 +-- truncate_limit: 100 +CREATE TABLE collate_test5 ( + a int, + b testdomain_sv COLLATE "en-x-icu" +) +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test5 (a int, b testdomain_sv COLLATE \"en-x-icu\")" +== 029 +-- truncate_limit: 100 +INSERT INTO collate_test5 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test5 SELECT * FROM collate_test1" +== 030 +-- truncate_limit: 100 +SELECT a, b FROM collate_test5 ORDER BY b +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test5 ORDER BY b" +== 031 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY b" +== 032 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 ORDER BY b" +== 033 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test3 ORDER BY b" +== 034 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY b COLLATE \"C\"" +== 035 +-- truncate_limit: 100 +-- star expansion +SELECT * FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 ORDER BY b" +== 036 +-- truncate_limit: 100 +SELECT * FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 ORDER BY b" +== 037 +-- truncate_limit: 100 +SELECT * FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 ORDER BY b" +== 038 +-- truncate_limit: 100 +-- constant expression folding +SELECT 'bbc' COLLATE "en-x-icu" > 'äbc' COLLATE "en-x-icu" AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' COLLATE \"en-x-icu\" > 'äbc' COLLATE \"en-x-icu\" AS \"true\"" +== 039 +-- truncate_limit: 100 +SELECT 'bbc' COLLATE "sv-x-icu" > 'äbc' COLLATE "sv-x-icu" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' COLLATE \"sv-x-icu\" > 'äbc' COLLATE \"sv-x-icu\" AS \"false\"" +== 040 +-- truncate_limit: 100 +-- upper/lower + +CREATE TABLE collate_test10 ( + a int, + x text COLLATE "en-x-icu", + y text COLLATE "tr-x-icu" +) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test10 (a int, x text COLLATE \"en-x-icu\", y text COLLATE \"tr-x-icu\")" +== 041 +-- truncate_limit: 100 +INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ') +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ')" +== 042 +-- truncate_limit: 100 +SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10" +== 043 +-- truncate_limit: 100 +SELECT a, lower(x COLLATE "C"), lower(y COLLATE "C") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x COLLATE \"C\"), lower(y COLLATE \"C\") FROM collate_test10" +== 044 +-- truncate_limit: 100 +SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a" +== 045 +-- truncate_limit: 100 +-- LIKE/ILIKE + +SELECT * FROM collate_test1 WHERE b LIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE 'abc'" +== 046 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b LIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE 'abc%'" +== 047 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b LIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE '%bc%'" +== 048 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE 'abc'" +== 049 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE 'abc%'" +== 050 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE '%bc%'" +== 051 +-- truncate_limit: 100 +SELECT 'Türkiye' COLLATE "en-x-icu" ILIKE '%KI%' AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Türkiye' COLLATE \"en-x-icu\" ILIKE '%KI%' AS \"true\"" +== 052 +-- truncate_limit: 100 +SELECT 'Türkiye' COLLATE "tr-x-icu" ILIKE '%KI%' AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Türkiye' COLLATE \"tr-x-icu\" ILIKE '%KI%' AS \"false\"" +== 053 +-- truncate_limit: 100 +SELECT 'bıt' ILIKE 'BIT' COLLATE "en-x-icu" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bıt' ILIKE 'BIT' COLLATE \"en-x-icu\" AS \"false\"" +== 054 +-- truncate_limit: 100 +SELECT 'bıt' ILIKE 'BIT' COLLATE "tr-x-icu" AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bıt' ILIKE 'BIT' COLLATE \"tr-x-icu\" AS \"true\"" +== 055 +-- truncate_limit: 100 +-- The following actually exercises the selectivity estimation for ILIKE. +SELECT relname FROM pg_class WHERE relname ILIKE 'abc%' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ILIKE 'abc%'" +== 056 +-- truncate_limit: 100 +-- regular expressions + +SELECT * FROM collate_test1 WHERE b ~ '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ '^abc$'" +== 057 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~ '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ '^abc'" +== 058 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~ 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ 'bc'" +== 059 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* '^abc$'" +== 060 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* '^abc'" +== 061 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* 'bc'" +== 062 +-- truncate_limit: 100 +CREATE TABLE collate_test6 ( + a int, + b text COLLATE "en-x-icu" +) +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test6 (a int, b text COLLATE \"en-x-icu\")" +== 063 +-- truncate_limit: 100 +INSERT INTO collate_test6 VALUES (1, 'abc'), (2, 'ABC'), (3, '123'), (4, 'ab1'), + (5, 'a1!'), (6, 'a c'), (7, '!.;'), (8, ' '), + (9, 'äbç'), (10, 'ÄBÇ') +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test6 VALUES (...)" +== 064 +-- truncate_limit: 100 +SELECT b, + b ~ '^[[:alpha:]]+$' AS is_alpha, + b ~ '^[[:upper:]]+$' AS is_upper, + b ~ '^[[:lower:]]+$' AS is_lower, + b ~ '^[[:digit:]]+$' AS is_digit, + b ~ '^[[:alnum:]]+$' AS is_alnum, + b ~ '^[[:graph:]]+$' AS is_graph, + b ~ '^[[:print:]]+$' AS is_print, + b ~ '^[[:punct:]]+$' AS is_punct, + b ~ '^[[:space:]]+$' AS is_space +FROM collate_test6 +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test6" +== 065 +-- truncate_limit: 100 +SELECT 'Türkiye' COLLATE "en-x-icu" ~* 'KI' AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Türkiye' COLLATE \"en-x-icu\" ~* 'KI' AS \"true\"" +== 066 +-- truncate_limit: 100 +SELECT 'Türkiye' COLLATE "tr-x-icu" ~* 'KI' AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Türkiye' COLLATE \"tr-x-icu\" ~* 'KI' AS \"true\"" +== 067 +-- truncate_limit: 100 +-- true with ICU + +SELECT 'bıt' ~* 'BIT' COLLATE "en-x-icu" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bıt' ~* 'BIT' COLLATE \"en-x-icu\" AS \"false\"" +== 068 +-- truncate_limit: 100 +SELECT 'bıt' ~* 'BIT' COLLATE "tr-x-icu" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bıt' ~* 'BIT' COLLATE \"tr-x-icu\" AS \"false\"" +== 069 +-- truncate_limit: 100 +-- false with ICU + +-- The following actually exercises the selectivity estimation for ~*. +SELECT relname FROM pg_class WHERE relname ~* '^abc' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ~* '^abc'" +== 070 +-- truncate_limit: 100 +/* not run by default because it requires tr_TR system locale +-- to_char + +SET lc_time TO 'tr_TR'; +SELECT to_char(date '2010-04-01', 'DD TMMON YYYY'); +SELECT to_char(date '2010-04-01', 'DD TMMON YYYY' COLLATE "tr-x-icu"); +*/ + + +-- backwards parsing + +CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collview1" schema="" table="collview1" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc'" +== 071 +-- truncate_limit: 100 +CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collview2" schema="" table="collview2" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE \"C\"" +== 072 +-- truncate_limit: 100 +CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10 +-- +TABLE: name="collview3" schema="" table="collview3" ctx=DDL +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE \"C\") FROM collate_test10" +== 073 +-- truncate_limit: 100 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'collview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'collview%' ORDER BY 1" +== 074 +-- truncate_limit: 100 +-- collation propagation in various expression types + +SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test1 ORDER BY 2" +== 075 +-- truncate_limit: 100 +SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test2 ORDER BY 2" +== 076 +-- truncate_limit: 100 +SELECT a, coalesce(b, 'foo') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test3 ORDER BY 2" +== 077 +-- truncate_limit: 100 +SELECT a, lower(coalesce(x, 'foo')), lower(coalesce(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(COALESCE(x, 'foo')), lower(COALESCE(y, 'foo')) FROM collate_test10" +== 078 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test1 ORDER BY 3" +== 079 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test2 ORDER BY 3" +== 080 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test3 ORDER BY 3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test3 ORDER BY 3" +== 081 +-- truncate_limit: 100 +SELECT a, x, y, lower(greatest(x, 'foo')), lower(greatest(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, x, y, lower(GREATEST(x, 'foo')), lower(GREATEST(y, 'foo')) FROM collate_test10" +== 082 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test1 ORDER BY 2" +== 083 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test2 ORDER BY 2" +== 084 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test3 ORDER BY 2" +== 085 +-- truncate_limit: 100 +SELECT a, lower(nullif(x, 'foo')), lower(nullif(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(NULLIF(x, 'foo')), lower(NULLIF(y, 'foo')) FROM collate_test10" +== 086 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2" +== 087 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2" +== 088 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2" +== 089 +-- truncate_limit: 100 +CREATE DOMAIN testdomain AS text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain AS text" +== 090 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test1 ORDER BY 2" +== 091 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test2 ORDER BY 2" +== 092 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test3 ORDER BY 2" +== 093 +-- truncate_limit: 100 +SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2" +== 094 +-- truncate_limit: 100 +SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10" +== 095 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test1" +== 096 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test2" +== 097 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test3" +== 098 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test1" +== 099 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test2" +== 100 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test3" +== 101 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2" +== 102 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2" +== 103 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test3 WHERE a > 1 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test3 WHERE ... INTERSECT SELECT ... FROM collate_test3 WHERE ... ORDER BY 2" +== 104 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2" +== 105 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2" +== 106 +-- truncate_limit: 100 +-- fail +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3" +== 107 +-- truncate_limit: 100 +-- ok +SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2" +== 108 +-- truncate_limit: 100 +-- fail +SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b COLLATE \"C\" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2" +== 109 +-- truncate_limit: 100 +-- ok +SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2" +== 110 +-- truncate_limit: 100 +-- fail +SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2" +== 111 +-- truncate_limit: 100 +-- fail + +CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="test_u" schema="" table="test_u" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3" +== 112 +-- truncate_limit: 100 +-- fail + +-- ideally this would be a parse-time error, but for now it must be run-time: +select x < y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x < y FROM collate_test10" +== 113 +-- truncate_limit: 100 +-- fail +select x || y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x || y FROM collate_test10" +== 114 +-- truncate_limit: 100 +-- ok, because || is not collation aware +select x, y from collate_test10 order by x || y +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x, y FROM collate_test10 ORDER BY x || y" +== 115 +-- truncate_limit: 100 +-- not so ok + +-- collation mismatch between recursive and non-recursive term +WITH RECURSIVE foo(x) AS + (SELECT x FROM (VALUES('a' COLLATE "en-x-icu"),('b')) t(x) + UNION ALL + SELECT (x || 'c') COLLATE "de-x-icu" FROM foo WHERE length(x) < 10) +SELECT * FROM foo +-- +CTE: "foo" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(x) AS (...) SELECT * FROM foo" +== 116 +-- truncate_limit: 100 +-- casting + +SELECT CAST('42' AS text COLLATE "C") +-- +ERROR: syntax error at or near "COLLATE" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 117 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test1 ORDER BY 2" +== 118 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test2 ORDER BY 2" +== 119 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test3 ORDER BY 2" +== 120 +-- truncate_limit: 100 +-- propagation of collation in SQL functions (inlined and non-inlined cases) +-- and plpgsql functions too + +CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 $$ +-- +FUNCTION: name="mylt" function="mylt" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt(text, text) RETURNS boolean LANGUAGE sql AS $$ select $1 < $2 $$" +== 121 +-- truncate_limit: 100 +CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 limit 1 $$ +-- +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt_noninline(text, text) RETURNS boolean LANGUAGE sql AS $$ select $1 < $2 limi..." +== 122 +-- truncate_limit: 100 +CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql + AS $$ begin return $1 < $2; end $$ +-- +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt_plpgsql(text, text) RETURNS boolean LANGUAGE plpgsql AS $$ begin return $1 <..." +== 123 +-- truncate_limit: 100 +SELECT a.b AS a, b.b AS b, a.b < b.b AS lt, + mylt(a.b, b.b), mylt_noninline(a.b, b.b), mylt_plpgsql(a.b, b.b) +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test1 a, collate_test1 b ORDER BY a.b, b.b" +== 124 +-- truncate_limit: 100 +SELECT a.b AS a, b.b AS b, a.b < b.b COLLATE "C" AS lt, + mylt(a.b, b.b COLLATE "C"), mylt_noninline(a.b, b.b COLLATE "C"), + mylt_plpgsql(a.b, b.b COLLATE "C") +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test1 a, collate_test1 b ORDER BY a.b, b.b" +== 125 +-- truncate_limit: 100 +-- collation override in plpgsql + +CREATE FUNCTION mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt2(x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$\ndeclare\n xx text :=..." +== 126 +-- truncate_limit: 100 +SELECT mylt2('a', 'B' collate "en-x-icu") as t, mylt2('a', 'B' collate "C") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"en-x-icu\") AS t, mylt2('a', 'B' COLLATE \"C\") AS f" +== 127 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION + mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text COLLATE "POSIX" := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION mylt2(x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$\ndeclare\n ..." +== 128 +-- truncate_limit: 100 +SELECT mylt2('a', 'B') as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B') AS f" +== 129 +-- truncate_limit: 100 +SELECT mylt2('a', 'B' collate "C") as fail +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"C\") AS fail" +== 130 +-- truncate_limit: 100 +-- conflicting collations +SELECT mylt2('a', 'B' collate "POSIX") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"POSIX\") AS f" +== 131 +-- truncate_limit: 100 +-- polymorphism + +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1" +== 132 +-- truncate_limit: 100 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1" +== 133 +-- truncate_limit: 100 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1" +== 134 +-- truncate_limit: 100 +CREATE FUNCTION dup (anyelement) RETURNS anyelement + AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dup(anyelement) RETURNS anyelement AS $$select $1$$ LANGUAGE sql" +== 135 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test1 ORDER BY 2" +== 136 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test2 ORDER BY 2" +== 137 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test3 ORDER BY 2" +== 138 +-- truncate_limit: 100 +-- indexes + +CREATE INDEX collate_test1_idx1 ON collate_test1 (b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx1 ON collate_test1 USING btree (b)" +== 139 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx2 ON collate_test1 USING btree (b COLLATE \"C\")" +== 140 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx3 ON collate_test1 USING btree ((b COLLATE \"C\"))" +== 141 +-- truncate_limit: 100 +-- this is different grammatically +CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx4 ON collate_test1 USING btree (((b || 'foo') COLLATE \"POSIX\"))" +== 142 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx5 ON collate_test1 USING btree (a COLLATE \"C\")" +== 143 +-- truncate_limit: 100 +-- fail +CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx6 ON collate_test1 USING btree ((a COLLATE \"C\"))" +== 144 +-- truncate_limit: 100 +-- fail + +SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE ... ORDER BY 1" +== 145 +-- truncate_limit: 100 +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 146 +-- truncate_limit: 100 +explain (costs off) +select * from collate_test1 where b ilike 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM collate_test1 WHERE b ILIKE 'abc'" +== 147 +-- truncate_limit: 100 +select * from collate_test1 where b ilike 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE 'abc'" +== 148 +-- truncate_limit: 100 +explain (costs off) +select * from collate_test1 where b ilike 'ABC' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM collate_test1 WHERE b ILIKE 'ABC'" +== 149 +-- truncate_limit: 100 +select * from collate_test1 where b ilike 'ABC' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE 'ABC'" +== 150 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 151 +-- truncate_limit: 100 +-- schema manipulation commands + +CREATE ROLE regress_test_role +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_role" +== 152 +-- truncate_limit: 100 +CREATE SCHEMA test_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_schema" +== 153 +-- truncate_limit: 100 +-- We need to do this this way to cope with varying names for encodings: +SET client_min_messages TO WARNING +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 154 +-- truncate_limit: 100 +SET icu_validation_level = disabled +-- +STMT: VariableSetStmt +TRUNCATED: "SET icu_validation_level TO disabled" +== 155 +-- truncate_limit: 100 +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' || + quote_literal((SELECT CASE WHEN datlocprovider='i' THEN datlocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||\n quote_lite..." +== 156 +-- truncate_limit: 100 +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test0 FROM \"C\"" +== 157 +-- truncate_limit: 100 +-- fail, duplicate name +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' || + quote_literal((SELECT CASE WHEN datlocprovider='i' THEN datlocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n EXECUTE 'CREATE COLLATION test1 (provider = icu, locale = ' ||\n quote_lite..." +== 158 +-- truncate_limit: 100 +RESET icu_validation_level +-- +STMT: VariableSetStmt +TRUNCATED: "RESET icu_validation_level" +== 159 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 160 +-- truncate_limit: 100 +CREATE COLLATION test3 (provider = icu, lc_collate = 'en_US.utf8') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test3 (provider = icu, lc_collate = 'en_US.utf8')" +== 161 +-- truncate_limit: 100 +-- fail, needs "locale" +SET icu_validation_level = ERROR +-- +STMT: VariableSetStmt +TRUNCATED: "SET icu_validation_level TO error" +== 162 +-- truncate_limit: 100 +CREATE COLLATION testx (provider = icu, locale = 'nonsense-nowhere') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testx (provider = icu, locale = 'nonsense-nowhere')" +== 163 +-- truncate_limit: 100 +-- fails +CREATE COLLATION testx (provider = icu, locale = '@colStrength=primary;nonsense=yes') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testx (provider = icu, locale = '@colStrength=primary;nonsense=yes')" +== 164 +-- truncate_limit: 100 +-- fails +RESET icu_validation_level +-- +STMT: VariableSetStmt +TRUNCATED: "RESET icu_validation_level" +== 165 +-- truncate_limit: 100 +CREATE COLLATION testx (provider = icu, locale = '@colStrength=primary;nonsense=yes') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testx (provider = icu, locale = '@colStrength=primary;nonsense=yes')" +== 166 +-- truncate_limit: 100 +DROP COLLATION testx +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION testx" +== 167 +-- truncate_limit: 100 +CREATE COLLATION testx (provider = icu, locale = 'nonsense-nowhere') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testx (provider = icu, locale = 'nonsense-nowhere')" +== 168 +-- truncate_limit: 100 +DROP COLLATION testx +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION testx" +== 169 +-- truncate_limit: 100 +CREATE COLLATION test4 FROM nonsense +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test4 FROM nonsense" +== 170 +-- truncate_limit: 100 +CREATE COLLATION test5 FROM test0 +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test5 FROM test0" +== 171 +-- truncate_limit: 100 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1" +== 172 +-- truncate_limit: 100 +ALTER COLLATION test1 RENAME TO test11 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test1 RENAME TO test11" +== 173 +-- truncate_limit: 100 +ALTER COLLATION test0 RENAME TO test11 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test0 RENAME TO test11" +== 174 +-- truncate_limit: 100 +-- fail +ALTER COLLATION test1 RENAME TO test22 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test1 RENAME TO test22" +== 175 +-- truncate_limit: 100 +-- fail + +ALTER COLLATION test11 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER COLLATION test11 OWNER TO regress_test_role" +== 176 +-- truncate_limit: 100 +ALTER COLLATION test11 OWNER TO nonsense +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER COLLATION test11 OWNER TO nonsense" +== 177 +-- truncate_limit: 100 +ALTER COLLATION test11 SET SCHEMA test_schema +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER COLLATION test11 SET SCHEMA test_schema" +== 178 +-- truncate_limit: 100 +COMMENT ON COLLATION test0 IS 'US English' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLLATION test0 IS 'US English'" +== 179 +-- truncate_limit: 100 +SELECT collname, nspname, obj_description(pg_collation.oid, 'pg_collation') + FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid) + WHERE collname LIKE 'test%' + ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_collation JOIN pg_namespace ON collnamespace = pg_namespace.oid WHERE ... ORDE..." +== 180 +-- truncate_limit: 100 +DROP COLLATION test0, test_schema.test11, test5 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0, test_schema.test11, test5" +== 181 +-- truncate_limit: 100 +DROP COLLATION test0 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0" +== 182 +-- truncate_limit: 100 +-- fail +DROP COLLATION IF EXISTS test0 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION IF EXISTS test0" +== 183 +-- truncate_limit: 100 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT collname FROM pg_collation WHERE collname LIKE 'test%'" +== 184 +-- truncate_limit: 100 +DROP SCHEMA test_schema +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA test_schema" +== 185 +-- truncate_limit: 100 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role" +== 186 +-- truncate_limit: 100 +-- ALTER + +ALTER COLLATION "en-x-icu" REFRESH VERSION +-- +STMT: AlterCollationStmt +TRUNCATED: "ALTER COLLATION \"en-x-icu\" REFRESH VERSION" +== 187 +-- truncate_limit: 100 +-- also test for database while we are here +SELECT current_database() AS datname +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_database() AS datname" +== 188 +-- truncate_limit: 100 +ALTER DATABASE :"datname" REFRESH COLLATION VERSION +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 189 +-- truncate_limit: 100 +-- dependencies + +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test0 FROM \"C\"" +== 190 +-- truncate_limit: 100 +CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0) +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0)" +== 191 +-- truncate_limit: 100 +CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0" +== 192 +-- truncate_limit: 100 +CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0)" +== 193 +-- truncate_limit: 100 +CREATE VIEW collate_dep_test3 AS SELECT text 'foo' COLLATE test0 AS foo +-- +TABLE: name="collate_dep_test3" schema="" table="collate_dep_test3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collate_dep_test3 AS SELECT 'foo'::text COLLATE test0 AS foo" +== 194 +-- truncate_limit: 100 +CREATE TABLE collate_dep_test4t (a int, b text) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_dep_test4t (a int, b text)" +== 195 +-- truncate_limit: 100 +CREATE INDEX collate_dep_test4i ON collate_dep_test4t (b COLLATE test0) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_dep_test4i ON collate_dep_test4t USING btree (b COLLATE test0)" +== 196 +-- truncate_limit: 100 +DROP COLLATION test0 RESTRICT +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0" +== 197 +-- truncate_limit: 100 +-- fail +DROP COLLATION test0 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0 CASCADE" +== 198 +-- truncate_limit: 100 +DROP TABLE collate_dep_test1, collate_dep_test4t +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE collate_dep_test1, collate_dep_test4t" +== 199 +-- truncate_limit: 100 +DROP TYPE collate_dep_test2 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE collate_dep_test2" +== 200 +-- truncate_limit: 100 +-- test range types and collations + +create type textrange_c as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange_c AS RANGE (subtype = text, \"collation\" = \"C\")" +== 201 +-- truncate_limit: 100 +create type textrange_en_us as range(subtype=text, collation="en-x-icu") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange_en_us AS RANGE (subtype = text, \"collation\" = \"en-x-icu\")" +== 202 +-- truncate_limit: 100 +select textrange_c('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_c" function="textrange_c" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange_c('A', 'Z') @> 'b'::text" +== 203 +-- truncate_limit: 100 +select textrange_en_us('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_en_us" function="textrange_en_us" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange_en_us('A', 'Z') @> 'b'::text" +== 204 +-- truncate_limit: 100 +drop type textrange_c +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange_c" +== 205 +-- truncate_limit: 100 +drop type textrange_en_us +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange_en_us" +== 206 +-- truncate_limit: 100 +-- standard collations + +SELECT * FROM collate_test2 ORDER BY b COLLATE UCS_BASIC +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 ORDER BY b COLLATE ucs_basic" +== 207 +-- truncate_limit: 100 +SELECT * FROM collate_test2 ORDER BY b COLLATE UNICODE +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 ORDER BY b COLLATE unicode" +== 208 +-- truncate_limit: 100 +-- test ICU collation customization + +-- test the attributes handled by icu_set_collation_attributes() + +SET client_min_messages=WARNING +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 209 +-- truncate_limit: 100 +CREATE COLLATION testcoll_ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseL..." +== 210 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 211 +-- truncate_limit: 100 +SELECT 'aaá' > 'AAA' COLLATE "und-x-icu", 'aaá' < 'AAA' COLLATE testcoll_ignore_accents +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'aaá' > 'AAA' COLLATE \"und-x-icu\", 'aaá' < 'AAA' COLLATE testcoll_ignore_accents" +== 212 +-- truncate_limit: 100 +SET client_min_messages=WARNING +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 213 +-- truncate_limit: 100 +CREATE COLLATION testcoll_backwards (provider = icu, locale = '@colBackwards=yes') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_backwards (provider = icu, locale = '@colBackwards=yes')" +== 214 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 215 +-- truncate_limit: 100 +SELECT 'coté' < 'côte' COLLATE "und-x-icu", 'coté' > 'côte' COLLATE testcoll_backwards +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'coté' < 'côte' COLLATE \"und-x-icu\", 'coté' > 'côte' COLLATE testcoll_backwards" +== 216 +-- truncate_limit: 100 +CREATE COLLATION testcoll_lower_first (provider = icu, locale = '@colCaseFirst=lower') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_lower_first (provider = icu, locale = '@colCaseFirst=lower')" +== 217 +-- truncate_limit: 100 +CREATE COLLATION testcoll_upper_first (provider = icu, locale = '@colCaseFirst=upper') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_upper_first (provider = icu, locale = '@colCaseFirst=upper')" +== 218 +-- truncate_limit: 100 +SELECT 'aaa' < 'AAA' COLLATE testcoll_lower_first, 'aaa' > 'AAA' COLLATE testcoll_upper_first +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'aaa' < 'AAA' COLLATE testcoll_lower_first, 'aaa' > 'AAA' COLLATE testcoll_upper_first" +== 219 +-- truncate_limit: 100 +CREATE COLLATION testcoll_shifted (provider = icu, locale = '@colAlternate=shifted') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_shifted (provider = icu, locale = '@colAlternate=shifted')" +== 220 +-- truncate_limit: 100 +SELECT 'de-luge' < 'deanza' COLLATE "und-x-icu", 'de-luge' > 'deanza' COLLATE testcoll_shifted +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'de-luge' < 'deanza' COLLATE \"und-x-icu\", 'de-luge' > 'deanza' COLLATE testcoll_shifted" +== 221 +-- truncate_limit: 100 +SET client_min_messages=WARNING +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 222 +-- truncate_limit: 100 +CREATE COLLATION testcoll_numeric (provider = icu, locale = '@colNumeric=yes') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_numeric (provider = icu, locale = '@colNumeric=yes')" +== 223 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 224 +-- truncate_limit: 100 +SELECT 'A-21' > 'A-123' COLLATE "und-x-icu", 'A-21' < 'A-123' COLLATE testcoll_numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'A-21' > 'A-123' COLLATE \"und-x-icu\", 'A-21' < 'A-123' COLLATE testcoll_numeric" +== 225 +-- truncate_limit: 100 +CREATE COLLATION testcoll_error1 (provider = icu, locale = '@colNumeric=lower') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_error1 (provider = icu, locale = '@colNumeric=lower')" +== 226 +-- truncate_limit: 100 +-- test that attributes not handled by icu_set_collation_attributes() +-- (handled by ucol_open() directly) also work +CREATE COLLATION testcoll_de_phonebook (provider = icu, locale = 'de@collation=phonebook') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_de_phonebook (provider = icu, locale = 'de@collation=phonebook')" +== 227 +-- truncate_limit: 100 +SELECT 'Goldmann' < 'Götz' COLLATE "de-x-icu", 'Goldmann' > 'Götz' COLLATE testcoll_de_phonebook +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Goldmann' < 'Götz' COLLATE \"de-x-icu\", 'Goldmann' > 'Götz' COLLATE testcoll_de_phonebook" +== 228 +-- truncate_limit: 100 +-- rules + +CREATE COLLATION testcoll_rules1 (provider = icu, locale = '', rules = '&a < g') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_rules1 (provider = icu, locale = '', rules = '&a < g')" +== 229 +-- truncate_limit: 100 +CREATE TABLE test7 (a text) +-- +TABLE: name="test7" schema="" table="test7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test7 (a text)" +== 230 +-- truncate_limit: 100 +-- example from https://unicode-org.github.io/icu/userguide/collation/customization/#syntax +INSERT INTO test7 VALUES ('Abernathy'), ('apple'), ('bird'), ('Boston'), ('Graham'), ('green') +-- +TABLE: name="test7" schema="" table="test7" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test7 VALUES ('Abernathy'), ('apple'), ('bird'), ('Boston'), ('Graham'), ('green')" +== 231 +-- truncate_limit: 100 +SELECT * FROM test7 ORDER BY a COLLATE "en-x-icu" +-- +TABLE: name="test7" schema="" table="test7" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test7 ORDER BY a COLLATE \"en-x-icu\"" +== 232 +-- truncate_limit: 100 +SELECT * FROM test7 ORDER BY a COLLATE testcoll_rules1 +-- +TABLE: name="test7" schema="" table="test7" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test7 ORDER BY a COLLATE testcoll_rules1" +== 233 +-- truncate_limit: 100 +DROP TABLE test7 +-- +TABLE: name="test7" schema="" table="test7" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test7" +== 234 +-- truncate_limit: 100 +CREATE COLLATION testcoll_rulesx (provider = icu, locale = '', rules = '!!wrong!!') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testcoll_rulesx (provider = icu, locale = '', rules = '!!wrong!!')" +== 235 +-- truncate_limit: 100 +-- nondeterministic collations + +CREATE COLLATION ctest_det (provider = icu, locale = '', deterministic = true) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION ctest_det (provider = icu, locale = '', deterministic = true)" +== 236 +-- truncate_limit: 100 +CREATE COLLATION ctest_nondet (provider = icu, locale = '', deterministic = false) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION ctest_nondet (provider = icu, locale = '', deterministic = false)" +== 237 +-- truncate_limit: 100 +CREATE TABLE test6 (a int, b text) +-- +TABLE: name="test6" schema="" table="test6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test6 (a int, b text)" +== 238 +-- truncate_limit: 100 +-- same string in different normal forms +INSERT INTO test6 VALUES (1, U&'\00E4bc') +-- +TABLE: name="test6" schema="" table="test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test6 VALUES (1, 'äbc')" +== 239 +-- truncate_limit: 100 +INSERT INTO test6 VALUES (2, U&'\0061\0308bc') +-- +TABLE: name="test6" schema="" table="test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test6 VALUES (2, 'äbc')" +== 240 +-- truncate_limit: 100 +SELECT * FROM test6 +-- +TABLE: name="test6" schema="" table="test6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test6" +== 241 +-- truncate_limit: 100 +SELECT * FROM test6 WHERE b = 'äbc' COLLATE ctest_det +-- +TABLE: name="test6" schema="" table="test6" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test6 WHERE b = 'äbc' COLLATE ctest_det" +== 242 +-- truncate_limit: 100 +SELECT * FROM test6 WHERE b = 'äbc' COLLATE ctest_nondet +-- +TABLE: name="test6" schema="" table="test6" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test6 WHERE b = 'äbc' COLLATE ctest_nondet" +== 243 +-- truncate_limit: 100 +-- same with arrays +CREATE TABLE test6a (a int, b text[]) +-- +TABLE: name="test6a" schema="" table="test6a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test6a (a int, b text[])" +== 244 +-- truncate_limit: 100 +INSERT INTO test6a VALUES (1, ARRAY[U&'\00E4bc']) +-- +TABLE: name="test6a" schema="" table="test6a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test6a VALUES (1, ARRAY['äbc'])" +== 245 +-- truncate_limit: 100 +INSERT INTO test6a VALUES (2, ARRAY[U&'\0061\0308bc']) +-- +TABLE: name="test6a" schema="" table="test6a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test6a VALUES (2, ARRAY['äbc'])" +== 246 +-- truncate_limit: 100 +SELECT * FROM test6a +-- +TABLE: name="test6a" schema="" table="test6a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test6a" +== 247 +-- truncate_limit: 100 +SELECT * FROM test6a WHERE b = ARRAY['äbc'] COLLATE ctest_det +-- +TABLE: name="test6a" schema="" table="test6a" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test6a WHERE b = ARRAY['äbc'] COLLATE ctest_det" +== 248 +-- truncate_limit: 100 +SELECT * FROM test6a WHERE b = ARRAY['äbc'] COLLATE ctest_nondet +-- +TABLE: name="test6a" schema="" table="test6a" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test6a WHERE b = ARRAY['äbc'] COLLATE ctest_nondet" +== 249 +-- truncate_limit: 100 +CREATE COLLATION case_sensitive (provider = icu, locale = '') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION case_sensitive (provider = icu, locale = '')" +== 250 +-- truncate_limit: 100 +CREATE COLLATION case_insensitive (provider = icu, locale = '@colStrength=secondary', deterministic = false) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION case_insensitive (provider = icu, locale = '@colStrength=secondary', determinist..." +== 251 +-- truncate_limit: 100 +SELECT 'abc' <= 'ABC' COLLATE case_sensitive, 'abc' >= 'ABC' COLLATE case_sensitive +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'abc' <= 'ABC' COLLATE case_sensitive, 'abc' >= 'ABC' COLLATE case_sensitive" +== 252 +-- truncate_limit: 100 +SELECT 'abc' <= 'ABC' COLLATE case_insensitive, 'abc' >= 'ABC' COLLATE case_insensitive +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'abc' <= 'ABC' COLLATE case_insensitive, 'abc' >= 'ABC' COLLATE case_insensitive" +== 253 +-- truncate_limit: 100 +-- test language tags +CREATE COLLATION lt_insensitive (provider = icu, locale = 'en-u-ks-level1', deterministic = false) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION lt_insensitive (provider = icu, locale = 'en-u-ks-level1', deterministic = false)" +== 254 +-- truncate_limit: 100 +SELECT 'aBcD' COLLATE lt_insensitive = 'AbCd' COLLATE lt_insensitive +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'aBcD' COLLATE lt_insensitive = 'AbCd' COLLATE lt_insensitive" +== 255 +-- truncate_limit: 100 +CREATE COLLATION lt_upperfirst (provider = icu, locale = 'und-u-kf-upper') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION lt_upperfirst (provider = icu, locale = 'und-u-kf-upper')" +== 256 +-- truncate_limit: 100 +SELECT 'Z' COLLATE lt_upperfirst < 'z' COLLATE lt_upperfirst +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Z' COLLATE lt_upperfirst < 'z' COLLATE lt_upperfirst" +== 257 +-- truncate_limit: 100 +CREATE TABLE test1cs (x text COLLATE case_sensitive) +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test1cs (x text COLLATE case_sensitive)" +== 258 +-- truncate_limit: 100 +CREATE TABLE test2cs (x text COLLATE case_sensitive) +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test2cs (x text COLLATE case_sensitive)" +== 259 +-- truncate_limit: 100 +CREATE TABLE test3cs (x text COLLATE case_sensitive) +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test3cs (x text COLLATE case_sensitive)" +== 260 +-- truncate_limit: 100 +INSERT INTO test1cs VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1cs VALUES ('abc'), ('def'), ('ghi')" +== 261 +-- truncate_limit: 100 +INSERT INTO test2cs VALUES ('ABC'), ('ghi') +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test2cs VALUES ('ABC'), ('ghi')" +== 262 +-- truncate_limit: 100 +INSERT INTO test3cs VALUES ('abc'), ('ABC'), ('def'), ('ghi') +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test3cs VALUES ('abc'), ('ABC'), ('def'), ('ghi')" +== 263 +-- truncate_limit: 100 +SELECT x FROM test3cs WHERE x = 'abc' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3cs WHERE x = 'abc'" +== 264 +-- truncate_limit: 100 +SELECT x FROM test3cs WHERE x <> 'abc' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3cs WHERE x <> 'abc'" +== 265 +-- truncate_limit: 100 +SELECT x FROM test3cs WHERE x LIKE 'a%' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3cs WHERE x LIKE 'a%'" +== 266 +-- truncate_limit: 100 +SELECT x FROM test3cs WHERE x ILIKE 'a%' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3cs WHERE x ILIKE 'a%'" +== 267 +-- truncate_limit: 100 +SELECT x FROM test3cs WHERE x SIMILAR TO 'a%' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3cs WHERE x SIMILAR TO 'a%'" +== 268 +-- truncate_limit: 100 +SELECT x FROM test3cs WHERE x ~ 'a' +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3cs WHERE x ~ 'a'" +== 269 +-- truncate_limit: 100 +SET enable_hashagg TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 270 +-- truncate_limit: 100 +SELECT x FROM test1cs UNION SELECT x FROM test2cs ORDER BY x +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1cs UNION SELECT x FROM test2cs ORDER BY x" +== 271 +-- truncate_limit: 100 +SELECT x FROM test2cs UNION SELECT x FROM test1cs ORDER BY x +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2cs UNION SELECT x FROM test1cs ORDER BY x" +== 272 +-- truncate_limit: 100 +SELECT x FROM test1cs INTERSECT SELECT x FROM test2cs +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1cs INTERSECT SELECT x FROM test2cs" +== 273 +-- truncate_limit: 100 +SELECT x FROM test2cs INTERSECT SELECT x FROM test1cs +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2cs INTERSECT SELECT x FROM test1cs" +== 274 +-- truncate_limit: 100 +SELECT x FROM test1cs EXCEPT SELECT x FROM test2cs +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1cs EXCEPT SELECT x FROM test2cs" +== 275 +-- truncate_limit: 100 +SELECT x FROM test2cs EXCEPT SELECT x FROM test1cs +-- +TABLE: name="test2cs" schema="" table="test2cs" ctx=Select +TABLE: name="test1cs" schema="" table="test1cs" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2cs EXCEPT SELECT x FROM test1cs" +== 276 +-- truncate_limit: 100 +SELECT DISTINCT x FROM test3cs ORDER BY x +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT x FROM test3cs ORDER BY x" +== 277 +-- truncate_limit: 100 +RESET enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 278 +-- truncate_limit: 100 +SELECT count(DISTINCT x) FROM test3cs +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT x) FROM test3cs" +== 279 +-- truncate_limit: 100 +SELECT x, count(*) FROM test3cs GROUP BY x ORDER BY x +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, count(*) FROM test3cs GROUP BY x ORDER BY x" +== 280 +-- truncate_limit: 100 +SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3cs ORDER BY x +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3cs ORDER BY x" +== 281 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON test1cs (x) +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON test1cs USING btree (x)" +== 282 +-- truncate_limit: 100 +-- ok +INSERT INTO test1cs VALUES ('ABC') +-- +TABLE: name="test1cs" schema="" table="test1cs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1cs VALUES ('ABC')" +== 283 +-- truncate_limit: 100 +-- ok +CREATE UNIQUE INDEX ON test3cs (x) +-- +TABLE: name="test3cs" schema="" table="test3cs" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON test3cs USING btree (x)" +== 284 +-- truncate_limit: 100 +-- ok +SELECT string_to_array('ABC,DEF,GHI' COLLATE case_sensitive, ',', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('ABC,DEF,GHI' COLLATE case_sensitive, ',', 'abc')" +== 285 +-- truncate_limit: 100 +SELECT string_to_array('ABCDEFGHI' COLLATE case_sensitive, NULL, 'b') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('ABCDEFGHI' COLLATE case_sensitive, NULL, 'b')" +== 286 +-- truncate_limit: 100 +CREATE TABLE test1ci (x text COLLATE case_insensitive) +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test1ci (x text COLLATE case_insensitive)" +== 287 +-- truncate_limit: 100 +CREATE TABLE test2ci (x text COLLATE case_insensitive) +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test2ci (x text COLLATE case_insensitive)" +== 288 +-- truncate_limit: 100 +CREATE TABLE test3ci (x text COLLATE case_insensitive) +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test3ci (x text COLLATE case_insensitive)" +== 289 +-- truncate_limit: 100 +CREATE INDEX ON test3ci (x text_pattern_ops) +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test3ci USING btree (x text_pattern_ops)" +== 290 +-- truncate_limit: 100 +-- error +INSERT INTO test1ci VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1ci VALUES ('abc'), ('def'), ('ghi')" +== 291 +-- truncate_limit: 100 +INSERT INTO test2ci VALUES ('ABC'), ('ghi') +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test2ci VALUES ('ABC'), ('ghi')" +== 292 +-- truncate_limit: 100 +INSERT INTO test3ci VALUES ('abc'), ('ABC'), ('def'), ('ghi') +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test3ci VALUES ('abc'), ('ABC'), ('def'), ('ghi')" +== 293 +-- truncate_limit: 100 +SELECT x FROM test3ci WHERE x = 'abc' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3ci WHERE x = 'abc'" +== 294 +-- truncate_limit: 100 +SELECT x FROM test3ci WHERE x <> 'abc' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3ci WHERE x <> 'abc'" +== 295 +-- truncate_limit: 100 +SELECT x FROM test3ci WHERE x LIKE 'a%' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3ci WHERE x LIKE 'a%'" +== 296 +-- truncate_limit: 100 +SELECT x FROM test3ci WHERE x ILIKE 'a%' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3ci WHERE x ILIKE 'a%'" +== 297 +-- truncate_limit: 100 +SELECT x FROM test3ci WHERE x SIMILAR TO 'a%' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3ci WHERE x SIMILAR TO 'a%'" +== 298 +-- truncate_limit: 100 +SELECT x FROM test3ci WHERE x ~ 'a' +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3ci WHERE x ~ 'a'" +== 299 +-- truncate_limit: 100 +SELECT x FROM test1ci UNION SELECT x FROM test2ci ORDER BY x +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1ci UNION SELECT x FROM test2ci ORDER BY x" +== 300 +-- truncate_limit: 100 +SELECT x FROM test2ci UNION SELECT x FROM test1ci ORDER BY x +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2ci UNION SELECT x FROM test1ci ORDER BY x" +== 301 +-- truncate_limit: 100 +SELECT x FROM test1ci INTERSECT SELECT x FROM test2ci ORDER BY x +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1ci INTERSECT SELECT x FROM test2ci ORDER BY x" +== 302 +-- truncate_limit: 100 +SELECT x FROM test2ci INTERSECT SELECT x FROM test1ci ORDER BY x +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2ci INTERSECT SELECT x FROM test1ci ORDER BY x" +== 303 +-- truncate_limit: 100 +SELECT x FROM test1ci EXCEPT SELECT x FROM test2ci +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1ci EXCEPT SELECT x FROM test2ci" +== 304 +-- truncate_limit: 100 +SELECT x FROM test2ci EXCEPT SELECT x FROM test1ci +-- +TABLE: name="test2ci" schema="" table="test2ci" ctx=Select +TABLE: name="test1ci" schema="" table="test1ci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2ci EXCEPT SELECT x FROM test1ci" +== 305 +-- truncate_limit: 100 +SELECT DISTINCT x FROM test3ci ORDER BY x +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT x FROM test3ci ORDER BY x" +== 306 +-- truncate_limit: 100 +SELECT count(DISTINCT x) FROM test3ci +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT x) FROM test3ci" +== 307 +-- truncate_limit: 100 +SELECT x, count(*) FROM test3ci GROUP BY x ORDER BY x +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, count(*) FROM test3ci GROUP BY x ORDER BY x" +== 308 +-- truncate_limit: 100 +SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3ci ORDER BY x +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3ci ORDER BY x" +== 309 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON test1ci (x) +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON test1ci USING btree (x)" +== 310 +-- truncate_limit: 100 +-- ok +INSERT INTO test1ci VALUES ('ABC') +-- +TABLE: name="test1ci" schema="" table="test1ci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1ci VALUES ('ABC')" +== 311 +-- truncate_limit: 100 +-- error +CREATE UNIQUE INDEX ON test3ci (x) +-- +TABLE: name="test3ci" schema="" table="test3ci" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON test3ci USING btree (x)" +== 312 +-- truncate_limit: 100 +-- error +SELECT string_to_array('ABC,DEF,GHI' COLLATE case_insensitive, ',', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('ABC,DEF,GHI' COLLATE case_insensitive, ',', 'abc')" +== 313 +-- truncate_limit: 100 +SELECT string_to_array('ABCDEFGHI' COLLATE case_insensitive, NULL, 'b') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('ABCDEFGHI' COLLATE case_insensitive, NULL, 'b')" +== 314 +-- truncate_limit: 100 +-- bpchar +CREATE TABLE test1bpci (x char(3) COLLATE case_insensitive) +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test1bpci (x char(3) COLLATE case_insensitive)" +== 315 +-- truncate_limit: 100 +CREATE TABLE test2bpci (x char(3) COLLATE case_insensitive) +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test2bpci (x char(3) COLLATE case_insensitive)" +== 316 +-- truncate_limit: 100 +CREATE TABLE test3bpci (x char(3) COLLATE case_insensitive) +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test3bpci (x char(3) COLLATE case_insensitive)" +== 317 +-- truncate_limit: 100 +CREATE INDEX ON test3bpci (x bpchar_pattern_ops) +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test3bpci USING btree (x bpchar_pattern_ops)" +== 318 +-- truncate_limit: 100 +-- error +INSERT INTO test1bpci VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1bpci VALUES ('abc'), ('def'), ('ghi')" +== 319 +-- truncate_limit: 100 +INSERT INTO test2bpci VALUES ('ABC'), ('ghi') +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test2bpci VALUES ('ABC'), ('ghi')" +== 320 +-- truncate_limit: 100 +INSERT INTO test3bpci VALUES ('abc'), ('ABC'), ('def'), ('ghi') +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test3bpci VALUES ('abc'), ('ABC'), ('def'), ('ghi')" +== 321 +-- truncate_limit: 100 +SELECT x FROM test3bpci WHERE x = 'abc' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3bpci WHERE x = 'abc'" +== 322 +-- truncate_limit: 100 +SELECT x FROM test3bpci WHERE x <> 'abc' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3bpci WHERE x <> 'abc'" +== 323 +-- truncate_limit: 100 +SELECT x FROM test3bpci WHERE x LIKE 'a%' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3bpci WHERE x LIKE 'a%'" +== 324 +-- truncate_limit: 100 +SELECT x FROM test3bpci WHERE x ILIKE 'a%' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3bpci WHERE x ILIKE 'a%'" +== 325 +-- truncate_limit: 100 +SELECT x FROM test3bpci WHERE x SIMILAR TO 'a%' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.similar_to_escape" function="similar_to_escape" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3bpci WHERE x SIMILAR TO 'a%'" +== 326 +-- truncate_limit: 100 +SELECT x FROM test3bpci WHERE x ~ 'a' +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test3bpci WHERE x ~ 'a'" +== 327 +-- truncate_limit: 100 +SELECT x FROM test1bpci UNION SELECT x FROM test2bpci ORDER BY x +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1bpci UNION SELECT x FROM test2bpci ORDER BY x" +== 328 +-- truncate_limit: 100 +SELECT x FROM test2bpci UNION SELECT x FROM test1bpci ORDER BY x +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2bpci UNION SELECT x FROM test1bpci ORDER BY x" +== 329 +-- truncate_limit: 100 +SELECT x FROM test1bpci INTERSECT SELECT x FROM test2bpci ORDER BY x +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1bpci INTERSECT SELECT x FROM test2bpci ORDER BY x" +== 330 +-- truncate_limit: 100 +SELECT x FROM test2bpci INTERSECT SELECT x FROM test1bpci ORDER BY x +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2bpci INTERSECT SELECT x FROM test1bpci ORDER BY x" +== 331 +-- truncate_limit: 100 +SELECT x FROM test1bpci EXCEPT SELECT x FROM test2bpci +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test1bpci EXCEPT SELECT x FROM test2bpci" +== 332 +-- truncate_limit: 100 +SELECT x FROM test2bpci EXCEPT SELECT x FROM test1bpci +-- +TABLE: name="test2bpci" schema="" table="test2bpci" ctx=Select +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test2bpci EXCEPT SELECT x FROM test1bpci" +== 333 +-- truncate_limit: 100 +SELECT DISTINCT x FROM test3bpci ORDER BY x +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT x FROM test3bpci ORDER BY x" +== 334 +-- truncate_limit: 100 +SELECT count(DISTINCT x) FROM test3bpci +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT x) FROM test3bpci" +== 335 +-- truncate_limit: 100 +SELECT x, count(*) FROM test3bpci GROUP BY x ORDER BY x +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, count(*) FROM test3bpci GROUP BY x ORDER BY x" +== 336 +-- truncate_limit: 100 +SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3bpci ORDER BY x +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, row_number() OVER (ORDER BY x), rank() OVER (ORDER BY x) FROM test3bpci ORDER BY x" +== 337 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON test1bpci (x) +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON test1bpci USING btree (x)" +== 338 +-- truncate_limit: 100 +-- ok +INSERT INTO test1bpci VALUES ('ABC') +-- +TABLE: name="test1bpci" schema="" table="test1bpci" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1bpci VALUES ('ABC')" +== 339 +-- truncate_limit: 100 +-- error +CREATE UNIQUE INDEX ON test3bpci (x) +-- +TABLE: name="test3bpci" schema="" table="test3bpci" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON test3bpci USING btree (x)" +== 340 +-- truncate_limit: 100 +-- error +SELECT string_to_array('ABC,DEF,GHI'::char(11) COLLATE case_insensitive, ',', 'abc') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('ABC,DEF,GHI'::char(11) COLLATE case_insensitive, ',', 'abc')" +== 341 +-- truncate_limit: 100 +SELECT string_to_array('ABCDEFGHI'::char(9) COLLATE case_insensitive, NULL, 'b') +-- +FUNCTION: name="string_to_array" function="string_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_to_array('ABCDEFGHI'::char(9) COLLATE case_insensitive, NULL, 'b')" +== 342 +-- truncate_limit: 100 +-- This tests the issue described in match_pattern_prefix(). In the +-- absence of that check, the case_insensitive tests below would +-- return no rows where they should logically return one. +CREATE TABLE test4c (x text COLLATE "C") +-- +TABLE: name="test4c" schema="" table="test4c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test4c (x text COLLATE \"C\")" +== 343 +-- truncate_limit: 100 +INSERT INTO test4c VALUES ('abc') +-- +TABLE: name="test4c" schema="" table="test4c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test4c VALUES ('abc')" +== 344 +-- truncate_limit: 100 +CREATE INDEX ON test4c (x) +-- +TABLE: name="test4c" schema="" table="test4c" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test4c USING btree (x)" +== 345 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 346 +-- truncate_limit: 100 +SELECT x FROM test4c WHERE x LIKE 'ABC' COLLATE case_sensitive +-- +TABLE: name="test4c" schema="" table="test4c" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test4c WHERE x LIKE 'ABC' COLLATE case_sensitive" +== 347 +-- truncate_limit: 100 +-- ok, no rows +SELECT x FROM test4c WHERE x LIKE 'ABC%' COLLATE case_sensitive +-- +TABLE: name="test4c" schema="" table="test4c" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test4c WHERE x LIKE 'ABC%' COLLATE case_sensitive" +== 348 +-- truncate_limit: 100 +-- ok, no rows +SELECT x FROM test4c WHERE x LIKE 'ABC' COLLATE case_insensitive +-- +TABLE: name="test4c" schema="" table="test4c" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test4c WHERE x LIKE 'ABC' COLLATE case_insensitive" +== 349 +-- truncate_limit: 100 +-- error +SELECT x FROM test4c WHERE x LIKE 'ABC%' COLLATE case_insensitive +-- +TABLE: name="test4c" schema="" table="test4c" ctx=Select +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT x FROM test4c WHERE x LIKE 'ABC%' COLLATE case_insensitive" +== 350 +-- truncate_limit: 100 +-- error +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 351 +-- truncate_limit: 100 +-- Unicode special case: different variants of Greek lower case sigma. +-- A naive implementation like citext that just does lower(x) = +-- lower(y) will do the wrong thing here, because lower('Σ') is 'σ' +-- but upper('ς') is 'Σ'. +SELECT 'ὀδυσσεύς' = 'ὈΔΥΣΣΕΎΣ' COLLATE case_sensitive +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'ὀδυσσεύς' = 'ὈΔΥΣΣΕΎΣ' COLLATE case_sensitive" +== 352 +-- truncate_limit: 100 +SELECT 'ὀδυσσεύς' = 'ὈΔΥΣΣΕΎΣ' COLLATE case_insensitive +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'ὀδυσσεύς' = 'ὈΔΥΣΣΕΎΣ' COLLATE case_insensitive" +== 353 +-- truncate_limit: 100 +-- name vs. text comparison operators +SELECT relname FROM pg_class WHERE relname = 'PG_CLASS'::text COLLATE case_insensitive +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname = 'PG_CLASS'::text COLLATE case_insensitive" +== 354 +-- truncate_limit: 100 +SELECT relname FROM pg_class WHERE 'PG_CLASS'::text = relname COLLATE case_insensitive +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE 'PG_CLASS'::text = relname COLLATE case_insensitive" +== 355 +-- truncate_limit: 100 +SELECT typname FROM pg_type WHERE typname LIKE 'int_' AND typname <> 'INT2'::text + COLLATE case_insensitive ORDER BY typname +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT typname FROM pg_type WHERE ... ORDER BY typname" +== 356 +-- truncate_limit: 100 +SELECT typname FROM pg_type WHERE typname LIKE 'int_' AND 'INT2'::text <> typname + COLLATE case_insensitive ORDER BY typname +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT typname FROM pg_type WHERE ... ORDER BY typname" +== 357 +-- truncate_limit: 100 +-- test case adapted from subselect.sql +CREATE TEMP TABLE outer_text (f1 text COLLATE case_insensitive, f2 text) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE outer_text (f1 text COLLATE case_insensitive, f2 text)" +== 358 +-- truncate_limit: 100 +INSERT INTO outer_text VALUES ('a', 'a') +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_text VALUES ('a', 'a')" +== 359 +-- truncate_limit: 100 +INSERT INTO outer_text VALUES ('b', 'a') +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_text VALUES ('b', 'a')" +== 360 +-- truncate_limit: 100 +INSERT INTO outer_text VALUES ('A', NULL) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_text VALUES ('A', NULL)" +== 361 +-- truncate_limit: 100 +INSERT INTO outer_text VALUES ('B', NULL) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_text VALUES ('B', NULL)" +== 362 +-- truncate_limit: 100 +CREATE TEMP TABLE inner_text (c1 text COLLATE case_insensitive, c2 text) +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE inner_text (c1 text COLLATE case_insensitive, c2 text)" +== 363 +-- truncate_limit: 100 +INSERT INTO inner_text VALUES ('a', NULL) +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inner_text VALUES ('a', NULL)" +== 364 +-- truncate_limit: 100 +SELECT * FROM outer_text WHERE (f1, f2) NOT IN (SELECT * FROM inner_text) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM outer_text WHERE NOT (f1, f2) IN (SELECT * FROM inner_text)" +== 365 +-- truncate_limit: 100 +-- accents +SET client_min_messages=WARNING +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 366 +-- truncate_limit: 100 +CREATE COLLATION ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes', deterministic = false) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION ignore_accents (provider = icu, locale = '@colStrength=primary;colCaseLevel=yes'..." +== 367 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 368 +-- truncate_limit: 100 +CREATE TABLE test4 (a int, b text) +-- +TABLE: name="test4" schema="" table="test4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test4 (a int, b text)" +== 369 +-- truncate_limit: 100 +INSERT INTO test4 VALUES (1, 'cote'), (2, 'côte'), (3, 'coté'), (4, 'côté') +-- +TABLE: name="test4" schema="" table="test4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test4 VALUES (1, 'cote'), (2, 'côte'), (3, 'coté'), (4, 'côté')" +== 370 +-- truncate_limit: 100 +SELECT * FROM test4 WHERE b = 'cote' +-- +TABLE: name="test4" schema="" table="test4" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test4 WHERE b = 'cote'" +== 371 +-- truncate_limit: 100 +SELECT * FROM test4 WHERE b = 'cote' COLLATE ignore_accents +-- +TABLE: name="test4" schema="" table="test4" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test4 WHERE b = 'cote' COLLATE ignore_accents" +== 372 +-- truncate_limit: 100 +SELECT * FROM test4 WHERE b = 'Cote' COLLATE ignore_accents +-- +TABLE: name="test4" schema="" table="test4" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test4 WHERE b = 'Cote' COLLATE ignore_accents" +== 373 +-- truncate_limit: 100 +-- still case-sensitive +SELECT * FROM test4 WHERE b = 'Cote' COLLATE case_insensitive +-- +TABLE: name="test4" schema="" table="test4" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test4 WHERE b = 'Cote' COLLATE case_insensitive" +== 374 +-- truncate_limit: 100 +-- foreign keys (should use collation of primary key) + +-- PK is case-sensitive, FK is case-insensitive +CREATE TABLE test10pk (x text COLLATE case_sensitive PRIMARY KEY) +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test10pk (x text PRIMARY KEY COLLATE case_sensitive)" +== 375 +-- truncate_limit: 100 +INSERT INTO test10pk VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test10pk VALUES ('abc'), ('def'), ('ghi')" +== 376 +-- truncate_limit: 100 +CREATE TABLE test10fk (x text COLLATE case_insensitive REFERENCES test10pk (x) ON UPDATE CASCADE ON DELETE CASCADE) +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test10fk (x text REFERENCES test10pk (x) ON UPDATE CASCADE ON DELETE CASCADE COLLATE..." +== 377 +-- truncate_limit: 100 +INSERT INTO test10fk VALUES ('abc') +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test10fk VALUES ('abc')" +== 378 +-- truncate_limit: 100 +-- ok +INSERT INTO test10fk VALUES ('ABC') +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test10fk VALUES ('ABC')" +== 379 +-- truncate_limit: 100 +-- error +INSERT INTO test10fk VALUES ('xyz') +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test10fk VALUES ('xyz')" +== 380 +-- truncate_limit: 100 +-- error +SELECT * FROM test10pk +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test10pk" +== 381 +-- truncate_limit: 100 +SELECT * FROM test10fk +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test10fk" +== 382 +-- truncate_limit: 100 +-- restrict update even though the values are "equal" in the FK table +UPDATE test10fk SET x = 'ABC' WHERE x = 'abc' +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test10fk SET x = 'ABC' WHERE x = 'abc'" +== 383 +-- truncate_limit: 100 +-- error +SELECT * FROM test10fk +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test10fk" +== 384 +-- truncate_limit: 100 +DELETE FROM test10pk WHERE x = 'abc' +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test10pk WHERE x = 'abc'" +== 385 +-- truncate_limit: 100 +SELECT * FROM test10pk +-- +TABLE: name="test10pk" schema="" table="test10pk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test10pk" +== 386 +-- truncate_limit: 100 +SELECT * FROM test10fk +-- +TABLE: name="test10fk" schema="" table="test10fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test10fk" +== 387 +-- truncate_limit: 100 +-- PK is case-insensitive, FK is case-sensitive +CREATE TABLE test11pk (x text COLLATE case_insensitive PRIMARY KEY) +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test11pk (x text PRIMARY KEY COLLATE case_insensitive)" +== 388 +-- truncate_limit: 100 +INSERT INTO test11pk VALUES ('abc'), ('def'), ('ghi') +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test11pk VALUES ('abc'), ('def'), ('ghi')" +== 389 +-- truncate_limit: 100 +CREATE TABLE test11fk (x text COLLATE case_sensitive REFERENCES test11pk (x) ON UPDATE CASCADE ON DELETE CASCADE) +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test11fk (x text REFERENCES test11pk (x) ON UPDATE CASCADE ON DELETE CASCADE COLLATE..." +== 390 +-- truncate_limit: 100 +INSERT INTO test11fk VALUES ('abc') +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test11fk VALUES ('abc')" +== 391 +-- truncate_limit: 100 +-- ok +INSERT INTO test11fk VALUES ('ABC') +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test11fk VALUES ('ABC')" +== 392 +-- truncate_limit: 100 +-- ok +INSERT INTO test11fk VALUES ('xyz') +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test11fk VALUES ('xyz')" +== 393 +-- truncate_limit: 100 +-- error +SELECT * FROM test11pk +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test11pk" +== 394 +-- truncate_limit: 100 +SELECT * FROM test11fk +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test11fk" +== 395 +-- truncate_limit: 100 +-- cascade update even though the values are "equal" in the PK table +UPDATE test11pk SET x = 'ABC' WHERE x = 'abc' +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test11pk SET x = 'ABC' WHERE x = 'abc'" +== 396 +-- truncate_limit: 100 +SELECT * FROM test11fk +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test11fk" +== 397 +-- truncate_limit: 100 +DELETE FROM test11pk WHERE x = 'abc' +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test11pk WHERE x = 'abc'" +== 398 +-- truncate_limit: 100 +SELECT * FROM test11pk +-- +TABLE: name="test11pk" schema="" table="test11pk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test11pk" +== 399 +-- truncate_limit: 100 +SELECT * FROM test11fk +-- +TABLE: name="test11fk" schema="" table="test11fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test11fk" +== 400 +-- truncate_limit: 100 +-- partitioning +CREATE TABLE test20 (a int, b text COLLATE case_insensitive) PARTITION BY LIST (b) +-- +TABLE: name="test20" schema="" table="test20" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test20 (a int, b text COLLATE case_insensitive) PARTITION BY LIST (b)" +== 401 +-- truncate_limit: 100 +CREATE TABLE test20_1 PARTITION OF test20 FOR VALUES IN ('abc') +-- +TABLE: name="test20_1" schema="" table="test20_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test20_1 PARTITION OF test20 FOR VALUES IN ('abc')" +== 402 +-- truncate_limit: 100 +INSERT INTO test20 VALUES (1, 'abc') +-- +TABLE: name="test20" schema="" table="test20" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test20 VALUES (1, 'abc')" +== 403 +-- truncate_limit: 100 +INSERT INTO test20 VALUES (2, 'ABC') +-- +TABLE: name="test20" schema="" table="test20" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test20 VALUES (2, 'ABC')" +== 404 +-- truncate_limit: 100 +SELECT * FROM test20_1 +-- +TABLE: name="test20_1" schema="" table="test20_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test20_1" +== 405 +-- truncate_limit: 100 +CREATE TABLE test21 (a int, b text COLLATE case_insensitive) PARTITION BY RANGE (b) +-- +TABLE: name="test21" schema="" table="test21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test21 (a int, b text COLLATE case_insensitive) PARTITION BY RANGE (b)" +== 406 +-- truncate_limit: 100 +CREATE TABLE test21_1 PARTITION OF test21 FOR VALUES FROM ('ABC') TO ('DEF') +-- +TABLE: name="test21_1" schema="" table="test21_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test21_1 PARTITION OF test21 FOR VALUES FROM ('ABC') TO ('DEF')" +== 407 +-- truncate_limit: 100 +INSERT INTO test21 VALUES (1, 'abc') +-- +TABLE: name="test21" schema="" table="test21" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test21 VALUES (1, 'abc')" +== 408 +-- truncate_limit: 100 +INSERT INTO test21 VALUES (2, 'ABC') +-- +TABLE: name="test21" schema="" table="test21" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test21 VALUES (2, 'ABC')" +== 409 +-- truncate_limit: 100 +SELECT * FROM test21_1 +-- +TABLE: name="test21_1" schema="" table="test21_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test21_1" +== 410 +-- truncate_limit: 100 +CREATE TABLE test22 (a int, b text COLLATE case_sensitive) PARTITION BY HASH (b) +-- +TABLE: name="test22" schema="" table="test22" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test22 (a int, b text COLLATE case_sensitive) PARTITION BY HASH (b)" +== 411 +-- truncate_limit: 100 +CREATE TABLE test22_0 PARTITION OF test22 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test22_0" schema="" table="test22_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test22_0 PARTITION OF test22 FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 412 +-- truncate_limit: 100 +CREATE TABLE test22_1 PARTITION OF test22 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test22_1" schema="" table="test22_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test22_1 PARTITION OF test22 FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 413 +-- truncate_limit: 100 +INSERT INTO test22 VALUES (1, 'def') +-- +TABLE: name="test22" schema="" table="test22" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test22 VALUES (1, 'def')" +== 414 +-- truncate_limit: 100 +INSERT INTO test22 VALUES (2, 'DEF') +-- +TABLE: name="test22" schema="" table="test22" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test22 VALUES (2, 'DEF')" +== 415 +-- truncate_limit: 100 +-- they end up in different partitions +SELECT (SELECT count(*) FROM test22_0) = (SELECT count(*) FROM test22_1) +-- +TABLE: name="test22_0" schema="" table="test22_0" ctx=Select +TABLE: name="test22_1" schema="" table="test22_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT count(*) FROM test22_0) = (SELECT count(*) FROM test22_1)" +== 416 +-- truncate_limit: 100 +-- same with arrays +CREATE TABLE test22a (a int, b text[] COLLATE case_sensitive) PARTITION BY HASH (b) +-- +TABLE: name="test22a" schema="" table="test22a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test22a (a int, b text[] COLLATE case_sensitive) PARTITION BY HASH (b)" +== 417 +-- truncate_limit: 100 +CREATE TABLE test22a_0 PARTITION OF test22a FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test22a_0" schema="" table="test22a_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test22a_0 PARTITION OF test22a FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 418 +-- truncate_limit: 100 +CREATE TABLE test22a_1 PARTITION OF test22a FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test22a_1" schema="" table="test22a_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test22a_1 PARTITION OF test22a FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 419 +-- truncate_limit: 100 +INSERT INTO test22a VALUES (1, ARRAY['def']) +-- +TABLE: name="test22a" schema="" table="test22a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test22a VALUES (1, ARRAY['def'])" +== 420 +-- truncate_limit: 100 +INSERT INTO test22a VALUES (2, ARRAY['DEF']) +-- +TABLE: name="test22a" schema="" table="test22a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test22a VALUES (2, ARRAY['DEF'])" +== 421 +-- truncate_limit: 100 +-- they end up in different partitions +SELECT (SELECT count(*) FROM test22a_0) = (SELECT count(*) FROM test22a_1) +-- +TABLE: name="test22a_0" schema="" table="test22a_0" ctx=Select +TABLE: name="test22a_1" schema="" table="test22a_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT count(*) FROM test22a_0) = (SELECT count(*) FROM test22a_1)" +== 422 +-- truncate_limit: 100 +CREATE TABLE test23 (a int, b text COLLATE case_insensitive) PARTITION BY HASH (b) +-- +TABLE: name="test23" schema="" table="test23" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test23 (a int, b text COLLATE case_insensitive) PARTITION BY HASH (b)" +== 423 +-- truncate_limit: 100 +CREATE TABLE test23_0 PARTITION OF test23 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test23_0" schema="" table="test23_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test23_0 PARTITION OF test23 FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 424 +-- truncate_limit: 100 +CREATE TABLE test23_1 PARTITION OF test23 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test23_1" schema="" table="test23_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test23_1 PARTITION OF test23 FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 425 +-- truncate_limit: 100 +INSERT INTO test23 VALUES (1, 'def') +-- +TABLE: name="test23" schema="" table="test23" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test23 VALUES (1, 'def')" +== 426 +-- truncate_limit: 100 +INSERT INTO test23 VALUES (2, 'DEF') +-- +TABLE: name="test23" schema="" table="test23" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test23 VALUES (2, 'DEF')" +== 427 +-- truncate_limit: 100 +-- they end up in the same partition (but it's platform-dependent which one) +SELECT (SELECT count(*) FROM test23_0) <> (SELECT count(*) FROM test23_1) +-- +TABLE: name="test23_0" schema="" table="test23_0" ctx=Select +TABLE: name="test23_1" schema="" table="test23_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT count(*) FROM test23_0) <> (SELECT count(*) FROM test23_1)" +== 428 +-- truncate_limit: 100 +-- same with arrays +CREATE TABLE test23a (a int, b text[] COLLATE case_insensitive) PARTITION BY HASH (b) +-- +TABLE: name="test23a" schema="" table="test23a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test23a (a int, b text[] COLLATE case_insensitive) PARTITION BY HASH (b)" +== 429 +-- truncate_limit: 100 +CREATE TABLE test23a_0 PARTITION OF test23a FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test23a_0" schema="" table="test23a_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test23a_0 PARTITION OF test23a FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 430 +-- truncate_limit: 100 +CREATE TABLE test23a_1 PARTITION OF test23a FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test23a_1" schema="" table="test23a_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test23a_1 PARTITION OF test23a FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 431 +-- truncate_limit: 100 +INSERT INTO test23a VALUES (1, ARRAY['def']) +-- +TABLE: name="test23a" schema="" table="test23a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test23a VALUES (1, ARRAY['def'])" +== 432 +-- truncate_limit: 100 +INSERT INTO test23a VALUES (2, ARRAY['DEF']) +-- +TABLE: name="test23a" schema="" table="test23a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test23a VALUES (2, ARRAY['DEF'])" +== 433 +-- truncate_limit: 100 +-- they end up in the same partition (but it's platform-dependent which one) +SELECT (SELECT count(*) FROM test23a_0) <> (SELECT count(*) FROM test23a_1) +-- +TABLE: name="test23a_0" schema="" table="test23a_0" ctx=Select +TABLE: name="test23a_1" schema="" table="test23a_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT count(*) FROM test23a_0) <> (SELECT count(*) FROM test23a_1)" +== 434 +-- truncate_limit: 100 +CREATE TABLE test30 (a int, b char(3) COLLATE case_insensitive) PARTITION BY LIST (b) +-- +TABLE: name="test30" schema="" table="test30" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test30 (a int, b char(3) COLLATE case_insensitive) PARTITION BY LIST (b)" +== 435 +-- truncate_limit: 100 +CREATE TABLE test30_1 PARTITION OF test30 FOR VALUES IN ('abc') +-- +TABLE: name="test30_1" schema="" table="test30_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test30_1 PARTITION OF test30 FOR VALUES IN ('abc')" +== 436 +-- truncate_limit: 100 +INSERT INTO test30 VALUES (1, 'abc') +-- +TABLE: name="test30" schema="" table="test30" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test30 VALUES (1, 'abc')" +== 437 +-- truncate_limit: 100 +INSERT INTO test30 VALUES (2, 'ABC') +-- +TABLE: name="test30" schema="" table="test30" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test30 VALUES (2, 'ABC')" +== 438 +-- truncate_limit: 100 +SELECT * FROM test30_1 +-- +TABLE: name="test30_1" schema="" table="test30_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test30_1" +== 439 +-- truncate_limit: 100 +CREATE TABLE test31 (a int, b char(3) COLLATE case_insensitive) PARTITION BY RANGE (b) +-- +TABLE: name="test31" schema="" table="test31" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test31 (a int, b char(3) COLLATE case_insensitive) PARTITION BY RANGE (b)" +== 440 +-- truncate_limit: 100 +CREATE TABLE test31_1 PARTITION OF test31 FOR VALUES FROM ('ABC') TO ('DEF') +-- +TABLE: name="test31_1" schema="" table="test31_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test31_1 PARTITION OF test31 FOR VALUES FROM ('ABC') TO ('DEF')" +== 441 +-- truncate_limit: 100 +INSERT INTO test31 VALUES (1, 'abc') +-- +TABLE: name="test31" schema="" table="test31" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test31 VALUES (1, 'abc')" +== 442 +-- truncate_limit: 100 +INSERT INTO test31 VALUES (2, 'ABC') +-- +TABLE: name="test31" schema="" table="test31" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test31 VALUES (2, 'ABC')" +== 443 +-- truncate_limit: 100 +SELECT * FROM test31_1 +-- +TABLE: name="test31_1" schema="" table="test31_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test31_1" +== 444 +-- truncate_limit: 100 +CREATE TABLE test32 (a int, b char(3) COLLATE case_sensitive) PARTITION BY HASH (b) +-- +TABLE: name="test32" schema="" table="test32" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test32 (a int, b char(3) COLLATE case_sensitive) PARTITION BY HASH (b)" +== 445 +-- truncate_limit: 100 +CREATE TABLE test32_0 PARTITION OF test32 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test32_0" schema="" table="test32_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test32_0 PARTITION OF test32 FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 446 +-- truncate_limit: 100 +CREATE TABLE test32_1 PARTITION OF test32 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test32_1" schema="" table="test32_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test32_1 PARTITION OF test32 FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 447 +-- truncate_limit: 100 +INSERT INTO test32 VALUES (1, 'def') +-- +TABLE: name="test32" schema="" table="test32" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test32 VALUES (1, 'def')" +== 448 +-- truncate_limit: 100 +INSERT INTO test32 VALUES (2, 'DEF') +-- +TABLE: name="test32" schema="" table="test32" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test32 VALUES (2, 'DEF')" +== 449 +-- truncate_limit: 100 +-- they end up in different partitions +SELECT (SELECT count(*) FROM test32_0) = (SELECT count(*) FROM test32_1) +-- +TABLE: name="test32_0" schema="" table="test32_0" ctx=Select +TABLE: name="test32_1" schema="" table="test32_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT count(*) FROM test32_0) = (SELECT count(*) FROM test32_1)" +== 450 +-- truncate_limit: 100 +CREATE TABLE test33 (a int, b char(3) COLLATE case_insensitive) PARTITION BY HASH (b) +-- +TABLE: name="test33" schema="" table="test33" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test33 (a int, b char(3) COLLATE case_insensitive) PARTITION BY HASH (b)" +== 451 +-- truncate_limit: 100 +CREATE TABLE test33_0 PARTITION OF test33 FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="test33_0" schema="" table="test33_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test33_0 PARTITION OF test33 FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 452 +-- truncate_limit: 100 +CREATE TABLE test33_1 PARTITION OF test33 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="test33_1" schema="" table="test33_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test33_1 PARTITION OF test33 FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 453 +-- truncate_limit: 100 +INSERT INTO test33 VALUES (1, 'def') +-- +TABLE: name="test33" schema="" table="test33" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test33 VALUES (1, 'def')" +== 454 +-- truncate_limit: 100 +INSERT INTO test33 VALUES (2, 'DEF') +-- +TABLE: name="test33" schema="" table="test33" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test33 VALUES (2, 'DEF')" +== 455 +-- truncate_limit: 100 +-- they end up in the same partition (but it's platform-dependent which one) +SELECT (SELECT count(*) FROM test33_0) <> (SELECT count(*) FROM test33_1) +-- +TABLE: name="test33_0" schema="" table="test33_0" ctx=Select +TABLE: name="test33_1" schema="" table="test33_1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT count(*) FROM test33_0) <> (SELECT count(*) FROM test33_1)" +== 456 +-- truncate_limit: 100 +|-- +-- Bug #18568 +|-- +-- Partitionwise aggregate (full or partial) should not be used when a +-- partition key's collation doesn't match that of the GROUP BY column it is +-- matched with. +SET max_parallel_workers_per_gather TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 0" +== 457 +-- truncate_limit: 100 +SET enable_incremental_sort TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_incremental_sort TO OFF" +== 458 +-- truncate_limit: 100 +CREATE TABLE pagg_tab3 (a text, c text collate case_insensitive) PARTITION BY LIST(c collate "C") +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab3 (a text, c text COLLATE case_insensitive) PARTITION BY LIST (c COLLATE \"C\")" +== 459 +-- truncate_limit: 100 +CREATE TABLE pagg_tab3_p1 PARTITION OF pagg_tab3 FOR VALUES IN ('a', 'b') +-- +TABLE: name="pagg_tab3_p1" schema="" table="pagg_tab3_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab3_p1 PARTITION OF pagg_tab3 FOR VALUES IN ('a', 'b')" +== 460 +-- truncate_limit: 100 +CREATE TABLE pagg_tab3_p2 PARTITION OF pagg_tab3 FOR VALUES IN ('B', 'A') +-- +TABLE: name="pagg_tab3_p2" schema="" table="pagg_tab3_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab3_p2 PARTITION OF pagg_tab3 FOR VALUES IN ('B', 'A')" +== 461 +-- truncate_limit: 100 +INSERT INTO pagg_tab3 SELECT i % 4 + 1, substr('abAB', (i % 4) + 1 , 1) FROM generate_series(0, 19) i +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=DML +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pagg_tab3 SELECT ... FROM generate_series(0, 19) i" +== 462 +-- truncate_limit: 100 +ANALYZE pagg_tab3 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab3" +== 463 +-- truncate_limit: 100 +SET enable_partitionwise_aggregate TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_aggregate TO FALSE" +== 464 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT upper(c collate case_insensitive), count(c) FROM pagg_tab3 GROUP BY c collate case_insensitive ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT upper(c COLLATE case_insensitive), count(c) FROM pagg_tab3 GROUP BY c ..." +== 465 +-- truncate_limit: 100 +SELECT upper(c collate case_insensitive), count(c) FROM pagg_tab3 GROUP BY c collate case_insensitive ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab3 GROUP BY c COLLATE case_insensitive ORDER BY 1" +== 466 +-- truncate_limit: 100 +-- No "full" partitionwise aggregation allowed, though "partial" is allowed. +SET enable_partitionwise_aggregate TO true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_aggregate TO TRUE" +== 467 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT upper(c collate case_insensitive), count(c) FROM pagg_tab3 GROUP BY c collate case_insensitive ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT upper(c COLLATE case_insensitive), count(c) FROM pagg_tab3 GROUP BY c ..." +== 468 +-- truncate_limit: 100 +SELECT upper(c collate case_insensitive), count(c) FROM pagg_tab3 GROUP BY c collate case_insensitive ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab3 GROUP BY c COLLATE case_insensitive ORDER BY 1" +== 469 +-- truncate_limit: 100 +-- OK to use full partitionwise aggregate after changing the GROUP BY column's +-- collation to be the same as that of the partition key. +EXPLAIN (COSTS OFF) +SELECT c collate "C", count(c) FROM pagg_tab3 GROUP BY c collate "C" ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c COLLATE \"C\", count(c) FROM pagg_tab3 GROUP BY c COLLATE \"C\" ORDER BY 1" +== 470 +-- truncate_limit: 100 +SELECT c collate "C", count(c) FROM pagg_tab3 GROUP BY c collate "C" ORDER BY 1 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c COLLATE \"C\", count(c) FROM pagg_tab3 GROUP BY c COLLATE \"C\" ORDER BY 1" +== 471 +-- truncate_limit: 100 +-- Partitionwise join should not be allowed too when the collation used by the +-- join keys doesn't match the partition key collation. +SET enable_partitionwise_join TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_join TO FALSE" +== 472 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c G..." +== 473 +-- truncate_limit: 100 +SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE \"C\"" +== 474 +-- truncate_limit: 100 +SET enable_partitionwise_join TO true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_join TO TRUE" +== 475 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c G..." +== 476 +-- truncate_limit: 100 +SELECT t1.c, count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c GROUP BY 1 ORDER BY t1.c COLLATE \"C\"" +== 477 +-- truncate_limit: 100 +-- OK when the join clause uses the same collation as the partition key. +EXPLAIN (COSTS OFF) +SELECT t1.c COLLATE "C", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE "C" GROUP BY t1.c COLLATE "C" ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.c COLLATE \"C\", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t..." +== 478 +-- truncate_limit: 100 +SELECT t1.c COLLATE "C", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE "C" GROUP BY t1.c COLLATE "C" ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE \"C\" GROUP BY t1.c COLLATE \"..." +== 479 +-- truncate_limit: 100 +SET enable_partitionwise_join TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_join TO FALSE" +== 480 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.c COLLATE "C", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE "C" GROUP BY t1.c COLLATE "C" ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.c COLLATE \"C\", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t..." +== 481 +-- truncate_limit: 100 +SELECT t1.c COLLATE "C", count(t2.c) FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE "C" GROUP BY t1.c COLLATE "C" ORDER BY t1.c COLLATE "C" +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=Select +ALIAS: "t1"="pagg_tab3" +ALIAS: "t2"="pagg_tab3" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab3 t1 JOIN pagg_tab3 t2 ON t1.c = t2.c COLLATE \"C\" GROUP BY t1.c COLLATE \"..." +== 482 +-- truncate_limit: 100 +DROP TABLE pagg_tab3 +-- +TABLE: name="pagg_tab3" schema="" table="pagg_tab3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pagg_tab3" +== 483 +-- truncate_limit: 100 +RESET enable_partitionwise_aggregate +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_partitionwise_aggregate" +== 484 +-- truncate_limit: 100 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers_per_gather" +== 485 +-- truncate_limit: 100 +RESET enable_incremental_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_incremental_sort" +== 486 +-- truncate_limit: 100 +-- Check that DEFAULT expressions in SQL/JSON functions use the same collation +-- as the RETURNING type. Mismatched collations should raise an error. +CREATE DOMAIN d1 AS text COLLATE case_insensitive +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN d1 AS text COLLATE case_insensitive" +== 487 +-- truncate_limit: 100 +CREATE DOMAIN d2 AS text COLLATE "C" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN d2 AS text COLLATE \"C\"" +== 488 +-- truncate_limit: 100 +SELECT JSON_VALUE('{"a": "A"}', '$.a' RETURNING d1 DEFAULT ('C' COLLATE "C") COLLATE case_insensitive ON EMPTY) = 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 489 +-- truncate_limit: 100 +-- true +SELECT JSON_VALUE('{"a": "A"}', '$.a' RETURNING d1 DEFAULT 'C' ON EMPTY) = 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": \"A\"}' , '$.a' RETURNING d1 DEFAULT 'C' ON EMPTY) = 'a'" +== 490 +-- truncate_limit: 100 +-- true +SELECT JSON_VALUE('{"a": "A"}', '$.a' RETURNING d1 DEFAULT 'C'::d2 ON EMPTY) = 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": \"A\"}' , '$.a' RETURNING d1 DEFAULT 'C'::d2 ON EMPTY) = 'a'" +== 491 +-- truncate_limit: 100 +-- error +SELECT JSON_VALUE('{"a": "A"}', '$.a' RETURNING d1 DEFAULT 'C' COLLATE "C" ON EMPTY) = 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": \"A\"}' , '$.a' RETURNING d1 DEFAULT 'C' COLLATE \"C\" ON EMPTY) = 'a'" +== 492 +-- truncate_limit: 100 +-- error +SELECT JSON_VALUE('{"a": "A"}', '$.c' RETURNING d1 DEFAULT 'A' ON EMPTY) = 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": \"A\"}' , '$.c' RETURNING d1 DEFAULT 'A' ON EMPTY) = 'a'" +== 493 +-- truncate_limit: 100 +-- true +SELECT JSON_VALUE('{"a": "A"}', '$.c' RETURNING d1 DEFAULT 'A' COLLATE case_insensitive ON EMPTY) = 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 494 +-- truncate_limit: 100 +-- true +SELECT JSON_VALUE('{"a": "A"}', '$.c' RETURNING d1 DEFAULT 'A'::d2 ON EMPTY) = 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": \"A\"}' , '$.c' RETURNING d1 DEFAULT 'A'::d2 ON EMPTY) = 'a'" +== 495 +-- truncate_limit: 100 +-- error +SELECT JSON_VALUE('{"a": "A"}', '$.c' RETURNING d1 DEFAULT 'A' COLLATE "C" ON EMPTY) = 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": \"A\"}' , '$.c' RETURNING d1 DEFAULT 'A' COLLATE \"C\" ON EMPTY) = 'a'" +== 496 +-- truncate_limit: 100 +-- error +DROP DOMAIN d1, d2 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN d1, d2" +== 497 +-- truncate_limit: 100 +-- cleanup +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 498 +-- truncate_limit: 100 +SET client_min_messages TO warning +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 499 +-- truncate_limit: 100 +DROP SCHEMA collate_tests CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA collate_tests CASCADE" +== 500 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 501 +-- truncate_limit: 100 +-- leave a collation for pg_upgrade test +CREATE COLLATION coll_icu_upgrade FROM "und-x-icu" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_icu_upgrade FROM \"und-x-icu\"" diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.linux.utf8.metadata.json b/parser/testdata/summary_truncate/postgres_regress/collate.linux.utf8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.linux.utf8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.linux.utf8.test b/parser/testdata/summary_truncate/postgres_regress/collate.linux.utf8.test new file mode 100644 index 0000000..08f5914 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.linux.utf8.test @@ -0,0 +1,1673 @@ +== 001 +-- truncate_limit: 100 +/* + * This test is for Linux/glibc systems and assumes that a full set of + * locales is installed. It must be run in a database with UTF-8 encoding, + * because other encodings don't support all the characters used. + */ + +SELECT getdatabaseencoding() <> 'UTF8' OR + (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE', 'tr_TR') AND collencoding = pg_char_to_encoding('UTF8')) <> 4 OR + version() !~ 'linux-gnu' + AS skip_test +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +FUNCTION: name="pg_char_to_encoding" function="pg_char_to_encoding" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_char_to_encoding" function="pg_char_to_encoding" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +FILTER: schema="" table="" column="collencoding" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 002 +-- truncate_limit: 100 +SET client_encoding TO UTF8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_encoding TO utf8" +== 003 +-- truncate_limit: 100 +CREATE SCHEMA collate_tests +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA collate_tests" +== 004 +-- truncate_limit: 100 +SET search_path = collate_tests +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO collate_tests" +== 005 +-- truncate_limit: 100 +CREATE TABLE collate_test1 ( + a int, + b text COLLATE "en_US" NOT NULL +) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test1 (a int, b text NOT NULL COLLATE \"en_US\")" +== 006 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "ja_JP.eucjp" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int, b text COLLATE \"ja_JP.eucjp\")" +== 007 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "foo" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int, b text COLLATE foo)" +== 008 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int COLLATE "en_US", + b text +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int COLLATE \"en_US\", b text)" +== 009 +-- truncate_limit: 100 +CREATE TABLE collate_test_like ( + LIKE collate_test1 +) +-- +TABLE: name="collate_test_like" schema="" table="collate_test_like" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_like (LIKE collate_test1)" +== 010 +-- truncate_limit: 100 +CREATE TABLE collate_test2 ( + a int, + b text COLLATE "sv_SE" +) +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test2 (a int, b text COLLATE \"sv_SE\")" +== 011 +-- truncate_limit: 100 +CREATE TABLE collate_test3 ( + a int, + b text COLLATE "C" +) +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test3 (a int, b text COLLATE \"C\")" +== 012 +-- truncate_limit: 100 +INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'äbc'), (3, 'bbc'), (4, 'ABC') +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'äbc'), (3, 'bbc'), (4, 'ABC')" +== 013 +-- truncate_limit: 100 +INSERT INTO collate_test2 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test2 SELECT * FROM collate_test1" +== 014 +-- truncate_limit: 100 +INSERT INTO collate_test3 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test3 SELECT * FROM collate_test1" +== 015 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b >= 'bbc'" +== 016 +-- truncate_limit: 100 +SELECT * FROM collate_test2 WHERE b >= 'bbc' +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 WHERE b >= 'bbc'" +== 017 +-- truncate_limit: 100 +SELECT * FROM collate_test3 WHERE b >= 'bbc' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 WHERE b >= 'bbc'" +== 018 +-- truncate_limit: 100 +SELECT * FROM collate_test3 WHERE b >= 'BBC' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 WHERE b >= 'BBC'" +== 019 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc'" +== 020 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE \"C\"" +== 021 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc' COLLATE \"C\"" +== 022 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "en_US" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc' COLLATE \"en_US\"" +== 023 +-- truncate_limit: 100 +CREATE DOMAIN testdomain_sv AS text COLLATE "sv_SE" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain_sv AS text COLLATE \"sv_SE\"" +== 024 +-- truncate_limit: 100 +CREATE DOMAIN testdomain_i AS int COLLATE "sv_SE" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain_i AS int COLLATE \"sv_SE\"" +== 025 +-- truncate_limit: 100 +-- fails +CREATE TABLE collate_test4 ( + a int, + b testdomain_sv +) +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test4 (a int, b testdomain_sv)" +== 026 +-- truncate_limit: 100 +INSERT INTO collate_test4 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test4 SELECT * FROM collate_test1" +== 027 +-- truncate_limit: 100 +SELECT a, b FROM collate_test4 ORDER BY b +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test4 ORDER BY b" +== 028 +-- truncate_limit: 100 +CREATE TABLE collate_test5 ( + a int, + b testdomain_sv COLLATE "en_US" +) +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test5 (a int, b testdomain_sv COLLATE \"en_US\")" +== 029 +-- truncate_limit: 100 +INSERT INTO collate_test5 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test5 SELECT * FROM collate_test1" +== 030 +-- truncate_limit: 100 +SELECT a, b FROM collate_test5 ORDER BY b +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test5 ORDER BY b" +== 031 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY b" +== 032 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 ORDER BY b" +== 033 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test3 ORDER BY b" +== 034 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY b COLLATE \"C\"" +== 035 +-- truncate_limit: 100 +-- star expansion +SELECT * FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 ORDER BY b" +== 036 +-- truncate_limit: 100 +SELECT * FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 ORDER BY b" +== 037 +-- truncate_limit: 100 +SELECT * FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 ORDER BY b" +== 038 +-- truncate_limit: 100 +-- constant expression folding +SELECT 'bbc' COLLATE "en_US" > 'äbc' COLLATE "en_US" AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' COLLATE \"en_US\" > 'äbc' COLLATE \"en_US\" AS \"true\"" +== 039 +-- truncate_limit: 100 +SELECT 'bbc' COLLATE "sv_SE" > 'äbc' COLLATE "sv_SE" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' COLLATE \"sv_SE\" > 'äbc' COLLATE \"sv_SE\" AS \"false\"" +== 040 +-- truncate_limit: 100 +-- upper/lower + +CREATE TABLE collate_test10 ( + a int, + x text COLLATE "en_US", + y text COLLATE "tr_TR" +) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test10 (a int, x text COLLATE \"en_US\", y text COLLATE \"tr_TR\")" +== 041 +-- truncate_limit: 100 +INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ') +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ')" +== 042 +-- truncate_limit: 100 +SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10" +== 043 +-- truncate_limit: 100 +SELECT a, lower(x COLLATE "C"), lower(y COLLATE "C") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x COLLATE \"C\"), lower(y COLLATE \"C\") FROM collate_test10" +== 044 +-- truncate_limit: 100 +SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a" +== 045 +-- truncate_limit: 100 +-- LIKE/ILIKE + +SELECT * FROM collate_test1 WHERE b LIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE 'abc'" +== 046 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b LIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE 'abc%'" +== 047 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b LIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE '%bc%'" +== 048 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE 'abc'" +== 049 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE 'abc%'" +== 050 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE '%bc%'" +== 051 +-- truncate_limit: 100 +SELECT 'Türkiye' COLLATE "en_US" ILIKE '%KI%' AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Türkiye' COLLATE \"en_US\" ILIKE '%KI%' AS \"true\"" +== 052 +-- truncate_limit: 100 +SELECT 'Türkiye' COLLATE "tr_TR" ILIKE '%KI%' AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Türkiye' COLLATE \"tr_TR\" ILIKE '%KI%' AS \"false\"" +== 053 +-- truncate_limit: 100 +SELECT 'bıt' ILIKE 'BIT' COLLATE "en_US" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bıt' ILIKE 'BIT' COLLATE \"en_US\" AS \"false\"" +== 054 +-- truncate_limit: 100 +SELECT 'bıt' ILIKE 'BIT' COLLATE "tr_TR" AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bıt' ILIKE 'BIT' COLLATE \"tr_TR\" AS \"true\"" +== 055 +-- truncate_limit: 100 +-- The following actually exercises the selectivity estimation for ILIKE. +SELECT relname FROM pg_class WHERE relname ILIKE 'abc%' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ILIKE 'abc%'" +== 056 +-- truncate_limit: 100 +-- regular expressions + +SELECT * FROM collate_test1 WHERE b ~ '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ '^abc$'" +== 057 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~ '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ '^abc'" +== 058 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~ 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ 'bc'" +== 059 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* '^abc$'" +== 060 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* '^abc'" +== 061 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* 'bc'" +== 062 +-- truncate_limit: 100 +CREATE TABLE collate_test6 ( + a int, + b text COLLATE "en_US" +) +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test6 (a int, b text COLLATE \"en_US\")" +== 063 +-- truncate_limit: 100 +INSERT INTO collate_test6 VALUES (1, 'abc'), (2, 'ABC'), (3, '123'), (4, 'ab1'), + (5, 'a1!'), (6, 'a c'), (7, '!.;'), (8, ' '), + (9, 'äbç'), (10, 'ÄBÇ') +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test6 VALUES (...)" +== 064 +-- truncate_limit: 100 +SELECT b, + b ~ '^[[:alpha:]]+$' AS is_alpha, + b ~ '^[[:upper:]]+$' AS is_upper, + b ~ '^[[:lower:]]+$' AS is_lower, + b ~ '^[[:digit:]]+$' AS is_digit, + b ~ '^[[:alnum:]]+$' AS is_alnum, + b ~ '^[[:graph:]]+$' AS is_graph, + b ~ '^[[:print:]]+$' AS is_print, + b ~ '^[[:punct:]]+$' AS is_punct, + b ~ '^[[:space:]]+$' AS is_space +FROM collate_test6 +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test6" +== 065 +-- truncate_limit: 100 +SELECT 'Türkiye' COLLATE "en_US" ~* 'KI' AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Türkiye' COLLATE \"en_US\" ~* 'KI' AS \"true\"" +== 066 +-- truncate_limit: 100 +SELECT 'Türkiye' COLLATE "tr_TR" ~* 'KI' AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Türkiye' COLLATE \"tr_TR\" ~* 'KI' AS \"false\"" +== 067 +-- truncate_limit: 100 +SELECT 'bıt' ~* 'BIT' COLLATE "en_US" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bıt' ~* 'BIT' COLLATE \"en_US\" AS \"false\"" +== 068 +-- truncate_limit: 100 +SELECT 'bıt' ~* 'BIT' COLLATE "tr_TR" AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bıt' ~* 'BIT' COLLATE \"tr_TR\" AS \"true\"" +== 069 +-- truncate_limit: 100 +-- The following actually exercises the selectivity estimation for ~*. +SELECT relname FROM pg_class WHERE relname ~* '^abc' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ~* '^abc'" +== 070 +-- truncate_limit: 100 +-- to_char + +SET lc_time TO 'tr_TR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET lc_time TO \"tr_TR\"" +== 071 +-- truncate_limit: 100 +SELECT to_char(date '2010-02-01', 'DD TMMON YYYY') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2010-02-01'::date, 'DD TMMON YYYY')" +== 072 +-- truncate_limit: 100 +SELECT to_char(date '2010-02-01', 'DD TMMON YYYY' COLLATE "tr_TR") +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2010-02-01'::date, 'DD TMMON YYYY' COLLATE \"tr_TR\")" +== 073 +-- truncate_limit: 100 +SELECT to_char(date '2010-04-01', 'DD TMMON YYYY') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2010-04-01'::date, 'DD TMMON YYYY')" +== 074 +-- truncate_limit: 100 +SELECT to_char(date '2010-04-01', 'DD TMMON YYYY' COLLATE "tr_TR") +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2010-04-01'::date, 'DD TMMON YYYY' COLLATE \"tr_TR\")" +== 075 +-- truncate_limit: 100 +-- to_date + +SELECT to_date('01 ŞUB 2010', 'DD TMMON YYYY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('01 ŞUB 2010', 'DD TMMON YYYY')" +== 076 +-- truncate_limit: 100 +SELECT to_date('01 Şub 2010', 'DD TMMON YYYY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('01 Şub 2010', 'DD TMMON YYYY')" +== 077 +-- truncate_limit: 100 +SELECT to_date('1234567890ab 2010', 'TMMONTH YYYY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('1234567890ab 2010', 'TMMONTH YYYY')" +== 078 +-- truncate_limit: 100 +-- fail + + +-- backwards parsing + +CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collview1" schema="" table="collview1" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc'" +== 079 +-- truncate_limit: 100 +CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collview2" schema="" table="collview2" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE \"C\"" +== 080 +-- truncate_limit: 100 +CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "C") FROM collate_test10 +-- +TABLE: name="collview3" schema="" table="collview3" ctx=DDL +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE \"C\") FROM collate_test10" +== 081 +-- truncate_limit: 100 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'collview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'collview%' ORDER BY 1" +== 082 +-- truncate_limit: 100 +-- collation propagation in various expression types + +SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test1 ORDER BY 2" +== 083 +-- truncate_limit: 100 +SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test2 ORDER BY 2" +== 084 +-- truncate_limit: 100 +SELECT a, coalesce(b, 'foo') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test3 ORDER BY 2" +== 085 +-- truncate_limit: 100 +SELECT a, lower(coalesce(x, 'foo')), lower(coalesce(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(COALESCE(x, 'foo')), lower(COALESCE(y, 'foo')) FROM collate_test10" +== 086 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test1 ORDER BY 3" +== 087 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test2 ORDER BY 3" +== 088 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test3 ORDER BY 3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test3 ORDER BY 3" +== 089 +-- truncate_limit: 100 +SELECT a, x, y, lower(greatest(x, 'foo')), lower(greatest(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, x, y, lower(GREATEST(x, 'foo')), lower(GREATEST(y, 'foo')) FROM collate_test10" +== 090 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test1 ORDER BY 2" +== 091 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test2 ORDER BY 2" +== 092 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test3 ORDER BY 2" +== 093 +-- truncate_limit: 100 +SELECT a, lower(nullif(x, 'foo')), lower(nullif(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(NULLIF(x, 'foo')), lower(NULLIF(y, 'foo')) FROM collate_test10" +== 094 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2" +== 095 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2" +== 096 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2" +== 097 +-- truncate_limit: 100 +CREATE DOMAIN testdomain AS text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain AS text" +== 098 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test1 ORDER BY 2" +== 099 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test2 ORDER BY 2" +== 100 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test3 ORDER BY 2" +== 101 +-- truncate_limit: 100 +SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2" +== 102 +-- truncate_limit: 100 +SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10" +== 103 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test1" +== 104 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test2" +== 105 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test3" +== 106 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test1" +== 107 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test2" +== 108 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test3" +== 109 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2" +== 110 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2" +== 111 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test3 WHERE a > 1 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test3 WHERE ... INTERSECT SELECT ... FROM collate_test3 WHERE ... ORDER BY 2" +== 112 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2" +== 113 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2" +== 114 +-- truncate_limit: 100 +-- fail +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3" +== 115 +-- truncate_limit: 100 +-- ok +SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2" +== 116 +-- truncate_limit: 100 +-- fail +SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b COLLATE \"C\" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2" +== 117 +-- truncate_limit: 100 +-- ok +SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2" +== 118 +-- truncate_limit: 100 +-- fail +SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2" +== 119 +-- truncate_limit: 100 +-- fail + +CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="test_u" schema="" table="test_u" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3" +== 120 +-- truncate_limit: 100 +-- fail + +-- ideally this would be a parse-time error, but for now it must be run-time: +select x < y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x < y FROM collate_test10" +== 121 +-- truncate_limit: 100 +-- fail +select x || y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x || y FROM collate_test10" +== 122 +-- truncate_limit: 100 +-- ok, because || is not collation aware +select x, y from collate_test10 order by x || y +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x, y FROM collate_test10 ORDER BY x || y" +== 123 +-- truncate_limit: 100 +-- not so ok + +-- collation mismatch between recursive and non-recursive term +WITH RECURSIVE foo(x) AS + (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x) + UNION ALL + SELECT (x || 'c') COLLATE "de_DE" FROM foo WHERE length(x) < 10) +SELECT * FROM foo +-- +CTE: "foo" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(x) AS (...) SELECT * FROM foo" +== 124 +-- truncate_limit: 100 +-- casting + +SELECT CAST('42' AS text COLLATE "C") +-- +ERROR: syntax error at or near "COLLATE" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 125 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test1 ORDER BY 2" +== 126 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test2 ORDER BY 2" +== 127 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test3 ORDER BY 2" +== 128 +-- truncate_limit: 100 +-- propagation of collation in SQL functions (inlined and non-inlined cases) +-- and plpgsql functions too + +CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 $$ +-- +FUNCTION: name="mylt" function="mylt" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt(text, text) RETURNS boolean LANGUAGE sql AS $$ select $1 < $2 $$" +== 129 +-- truncate_limit: 100 +CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 limit 1 $$ +-- +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt_noninline(text, text) RETURNS boolean LANGUAGE sql AS $$ select $1 < $2 limi..." +== 130 +-- truncate_limit: 100 +CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql + AS $$ begin return $1 < $2; end $$ +-- +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt_plpgsql(text, text) RETURNS boolean LANGUAGE plpgsql AS $$ begin return $1 <..." +== 131 +-- truncate_limit: 100 +SELECT a.b AS a, b.b AS b, a.b < b.b AS lt, + mylt(a.b, b.b), mylt_noninline(a.b, b.b), mylt_plpgsql(a.b, b.b) +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test1 a, collate_test1 b ORDER BY a.b, b.b" +== 132 +-- truncate_limit: 100 +SELECT a.b AS a, b.b AS b, a.b < b.b COLLATE "C" AS lt, + mylt(a.b, b.b COLLATE "C"), mylt_noninline(a.b, b.b COLLATE "C"), + mylt_plpgsql(a.b, b.b COLLATE "C") +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test1 a, collate_test1 b ORDER BY a.b, b.b" +== 133 +-- truncate_limit: 100 +-- collation override in plpgsql + +CREATE FUNCTION mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt2(x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$\ndeclare\n xx text :=..." +== 134 +-- truncate_limit: 100 +SELECT mylt2('a', 'B' collate "en_US") as t, mylt2('a', 'B' collate "C") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"en_US\") AS t, mylt2('a', 'B' COLLATE \"C\") AS f" +== 135 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION + mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text COLLATE "POSIX" := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION mylt2(x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$\ndeclare\n ..." +== 136 +-- truncate_limit: 100 +SELECT mylt2('a', 'B') as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B') AS f" +== 137 +-- truncate_limit: 100 +SELECT mylt2('a', 'B' collate "C") as fail +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"C\") AS fail" +== 138 +-- truncate_limit: 100 +-- conflicting collations +SELECT mylt2('a', 'B' collate "POSIX") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"POSIX\") AS f" +== 139 +-- truncate_limit: 100 +-- polymorphism + +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1" +== 140 +-- truncate_limit: 100 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1" +== 141 +-- truncate_limit: 100 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1" +== 142 +-- truncate_limit: 100 +CREATE FUNCTION dup (anyelement) RETURNS anyelement + AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dup(anyelement) RETURNS anyelement AS $$select $1$$ LANGUAGE sql" +== 143 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test1 ORDER BY 2" +== 144 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test2 ORDER BY 2" +== 145 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test3 ORDER BY 2" +== 146 +-- truncate_limit: 100 +-- indexes + +CREATE INDEX collate_test1_idx1 ON collate_test1 (b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx1 ON collate_test1 USING btree (b)" +== 147 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx2 ON collate_test1 USING btree (b COLLATE \"C\")" +== 148 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx3 ON collate_test1 USING btree ((b COLLATE \"C\"))" +== 149 +-- truncate_limit: 100 +-- this is different grammatically +CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx4 ON collate_test1 USING btree (((b || 'foo') COLLATE \"POSIX\"))" +== 150 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx5 ON collate_test1 USING btree (a COLLATE \"C\")" +== 151 +-- truncate_limit: 100 +-- fail +CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx6 ON collate_test1 USING btree ((a COLLATE \"C\"))" +== 152 +-- truncate_limit: 100 +-- fail + +SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE ... ORDER BY 1" +== 153 +-- truncate_limit: 100 +-- schema manipulation commands + +CREATE ROLE regress_test_role +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_role" +== 154 +-- truncate_limit: 100 +CREATE SCHEMA test_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_schema" +== 155 +-- truncate_limit: 100 +-- We need to do this this way to cope with varying names for encodings: +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test0 (locale = ' || + quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n EXECUTE 'CREATE COLLATION test0 (locale = ' ||\n quote_literal((SELECT datc..." +== 156 +-- truncate_limit: 100 +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test0 FROM \"C\"" +== 157 +-- truncate_limit: 100 +-- fail, duplicate name +CREATE COLLATION IF NOT EXISTS test0 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION IF NOT EXISTS test0 FROM \"C\"" +== 158 +-- truncate_limit: 100 +-- ok, skipped +CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo')" +== 159 +-- truncate_limit: 100 +-- ok, skipped +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test1 (lc_collate = ' || + quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || + ', lc_ctype = ' || + quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||\n quote_literal((SELECT ..." +== 160 +-- truncate_limit: 100 +CREATE COLLATION test3 (lc_collate = 'en_US.utf8') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test3 (lc_collate = 'en_US.utf8')" +== 161 +-- truncate_limit: 100 +-- fail, need lc_ctype +CREATE COLLATION testx (locale = 'nonsense') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testx (locale = 'nonsense')" +== 162 +-- truncate_limit: 100 +-- fail + +CREATE COLLATION test4 FROM nonsense +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test4 FROM nonsense" +== 163 +-- truncate_limit: 100 +CREATE COLLATION test5 FROM test0 +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test5 FROM test0" +== 164 +-- truncate_limit: 100 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1" +== 165 +-- truncate_limit: 100 +ALTER COLLATION test1 RENAME TO test11 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test1 RENAME TO test11" +== 166 +-- truncate_limit: 100 +ALTER COLLATION test0 RENAME TO test11 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test0 RENAME TO test11" +== 167 +-- truncate_limit: 100 +-- fail +ALTER COLLATION test1 RENAME TO test22 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test1 RENAME TO test22" +== 168 +-- truncate_limit: 100 +-- fail + +ALTER COLLATION test11 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER COLLATION test11 OWNER TO regress_test_role" +== 169 +-- truncate_limit: 100 +ALTER COLLATION test11 OWNER TO nonsense +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER COLLATION test11 OWNER TO nonsense" +== 170 +-- truncate_limit: 100 +ALTER COLLATION test11 SET SCHEMA test_schema +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER COLLATION test11 SET SCHEMA test_schema" +== 171 +-- truncate_limit: 100 +COMMENT ON COLLATION test0 IS 'US English' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLLATION test0 IS 'US English'" +== 172 +-- truncate_limit: 100 +SELECT collname, nspname, obj_description(pg_collation.oid, 'pg_collation') + FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid) + WHERE collname LIKE 'test%' + ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_collation JOIN pg_namespace ON collnamespace = pg_namespace.oid WHERE ... ORDE..." +== 173 +-- truncate_limit: 100 +DROP COLLATION test0, test_schema.test11, test5 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0, test_schema.test11, test5" +== 174 +-- truncate_limit: 100 +DROP COLLATION test0 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0" +== 175 +-- truncate_limit: 100 +-- fail +DROP COLLATION IF EXISTS test0 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION IF EXISTS test0" +== 176 +-- truncate_limit: 100 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT collname FROM pg_collation WHERE collname LIKE 'test%'" +== 177 +-- truncate_limit: 100 +DROP SCHEMA test_schema +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA test_schema" +== 178 +-- truncate_limit: 100 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role" +== 179 +-- truncate_limit: 100 +-- ALTER + +ALTER COLLATION "en_US" REFRESH VERSION +-- +STMT: AlterCollationStmt +TRUNCATED: "ALTER COLLATION \"en_US\" REFRESH VERSION" +== 180 +-- truncate_limit: 100 +-- also test for database while we are here +SELECT current_database() AS datname +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_database() AS datname" +== 181 +-- truncate_limit: 100 +ALTER DATABASE :"datname" REFRESH COLLATION VERSION +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 182 +-- truncate_limit: 100 +-- dependencies + +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test0 FROM \"C\"" +== 183 +-- truncate_limit: 100 +CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0) +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0)" +== 184 +-- truncate_limit: 100 +CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0" +== 185 +-- truncate_limit: 100 +CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0)" +== 186 +-- truncate_limit: 100 +CREATE VIEW collate_dep_test3 AS SELECT text 'foo' COLLATE test0 AS foo +-- +TABLE: name="collate_dep_test3" schema="" table="collate_dep_test3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collate_dep_test3 AS SELECT 'foo'::text COLLATE test0 AS foo" +== 187 +-- truncate_limit: 100 +CREATE TABLE collate_dep_test4t (a int, b text) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_dep_test4t (a int, b text)" +== 188 +-- truncate_limit: 100 +CREATE INDEX collate_dep_test4i ON collate_dep_test4t (b COLLATE test0) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_dep_test4i ON collate_dep_test4t USING btree (b COLLATE test0)" +== 189 +-- truncate_limit: 100 +DROP COLLATION test0 RESTRICT +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0" +== 190 +-- truncate_limit: 100 +-- fail +DROP COLLATION test0 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0 CASCADE" +== 191 +-- truncate_limit: 100 +DROP TABLE collate_dep_test1, collate_dep_test4t +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE collate_dep_test1, collate_dep_test4t" +== 192 +-- truncate_limit: 100 +DROP TYPE collate_dep_test2 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE collate_dep_test2" +== 193 +-- truncate_limit: 100 +-- test range types and collations + +create type textrange_c as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange_c AS RANGE (subtype = text, \"collation\" = \"C\")" +== 194 +-- truncate_limit: 100 +create type textrange_en_us as range(subtype=text, collation="en_US") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange_en_us AS RANGE (subtype = text, \"collation\" = \"en_US\")" +== 195 +-- truncate_limit: 100 +select textrange_c('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_c" function="textrange_c" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange_c('A', 'Z') @> 'b'::text" +== 196 +-- truncate_limit: 100 +select textrange_en_us('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_en_us" function="textrange_en_us" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange_en_us('A', 'Z') @> 'b'::text" +== 197 +-- truncate_limit: 100 +drop type textrange_c +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange_c" +== 198 +-- truncate_limit: 100 +drop type textrange_en_us +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange_en_us" +== 199 +-- truncate_limit: 100 +-- standard collations + +SELECT * FROM collate_test2 ORDER BY b COLLATE UCS_BASIC +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 ORDER BY b COLLATE ucs_basic" +== 200 +-- truncate_limit: 100 +-- nondeterministic collations +-- (not supported with libc provider) + +CREATE COLLATION ctest_det (locale = 'en_US.utf8', deterministic = true) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION ctest_det (locale = 'en_US.utf8', deterministic = true)" +== 201 +-- truncate_limit: 100 +CREATE COLLATION ctest_nondet (locale = 'en_US.utf8', deterministic = false) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION ctest_nondet (locale = 'en_US.utf8', deterministic = false)" +== 202 +-- truncate_limit: 100 +-- cleanup +SET client_min_messages TO warning +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 203 +-- truncate_limit: 100 +DROP SCHEMA collate_tests CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA collate_tests CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.metadata.json b/parser/testdata/summary_truncate/postgres_regress/collate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.test b/parser/testdata/summary_truncate/postgres_regress/collate.test new file mode 100644 index 0000000..c3416c6 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.test @@ -0,0 +1,1198 @@ +== 001 +-- truncate_limit: 100 +/* + * This test is intended to pass on all platforms supported by Postgres. + * We can therefore only assume that the default, C, and POSIX collations + * are available --- and since the regression tests are often run in a + * C-locale database, these may well all have the same behavior. But + * fortunately, the system doesn't know that and will treat them as + * incompatible collations. It is therefore at least possible to test + * parser behaviors such as collation conflict resolution. This test will, + * however, be more revealing when run in a database with non-C locale, + * since any departure from C sorting behavior will show as a failure. + */ + +CREATE SCHEMA collate_tests +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA collate_tests" +== 002 +-- truncate_limit: 100 +SET search_path = collate_tests +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO collate_tests" +== 003 +-- truncate_limit: 100 +CREATE TABLE collate_test1 ( + a int, + b text COLLATE "C" NOT NULL +) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test1 (a int, b text NOT NULL COLLATE \"C\")" +== 004 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int COLLATE "C", + b text +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int COLLATE \"C\", b text)" +== 005 +-- truncate_limit: 100 +CREATE TABLE collate_test_like ( + LIKE collate_test1 +) +-- +TABLE: name="collate_test_like" schema="" table="collate_test_like" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_like (LIKE collate_test1)" +== 006 +-- truncate_limit: 100 +CREATE TABLE collate_test2 ( + a int, + b text COLLATE "POSIX" +) +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test2 (a int, b text COLLATE \"POSIX\")" +== 007 +-- truncate_limit: 100 +INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'Abc'), (3, 'bbc'), (4, 'ABD') +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test1 VALUES (1, 'abc'), (2, 'Abc'), (3, 'bbc'), (4, 'ABD')" +== 008 +-- truncate_limit: 100 +INSERT INTO collate_test2 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test2 SELECT * FROM collate_test1" +== 009 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'abc'" +== 010 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b >= 'abc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b >= 'abc' COLLATE \"C\"" +== 011 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'abc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'abc' COLLATE \"C\"" +== 012 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "POSIX" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc' COLLATE \"POSIX\"" +== 013 +-- truncate_limit: 100 +-- fail + +CREATE DOMAIN testdomain_p AS text COLLATE "POSIX" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain_p AS text COLLATE \"POSIX\"" +== 014 +-- truncate_limit: 100 +CREATE DOMAIN testdomain_i AS int COLLATE "POSIX" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain_i AS int COLLATE \"POSIX\"" +== 015 +-- truncate_limit: 100 +-- fail +CREATE TABLE collate_test4 ( + a int, + b testdomain_p +) +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test4 (a int, b testdomain_p)" +== 016 +-- truncate_limit: 100 +INSERT INTO collate_test4 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test4 SELECT * FROM collate_test1" +== 017 +-- truncate_limit: 100 +SELECT a, b FROM collate_test4 ORDER BY b +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test4 ORDER BY b" +== 018 +-- truncate_limit: 100 +CREATE TABLE collate_test5 ( + a int, + b testdomain_p COLLATE "C" +) +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test5 (a int, b testdomain_p COLLATE \"C\")" +== 019 +-- truncate_limit: 100 +INSERT INTO collate_test5 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test5 SELECT * FROM collate_test1" +== 020 +-- truncate_limit: 100 +SELECT a, b FROM collate_test5 ORDER BY b +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test5 ORDER BY b" +== 021 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY b" +== 022 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 ORDER BY b" +== 023 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY b COLLATE \"C\"" +== 024 +-- truncate_limit: 100 +-- star expansion +SELECT * FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 ORDER BY b" +== 025 +-- truncate_limit: 100 +SELECT * FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 ORDER BY b" +== 026 +-- truncate_limit: 100 +-- constant expression folding +SELECT 'bbc' COLLATE "C" > 'Abc' COLLATE "C" AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' COLLATE \"C\" > 'Abc' COLLATE \"C\" AS \"true\"" +== 027 +-- truncate_limit: 100 +SELECT 'bbc' COLLATE "POSIX" < 'Abc' COLLATE "POSIX" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' COLLATE \"POSIX\" < 'Abc' COLLATE \"POSIX\" AS \"false\"" +== 028 +-- truncate_limit: 100 +-- upper/lower + +CREATE TABLE collate_test10 ( + a int, + x text COLLATE "C", + y text COLLATE "POSIX" +) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test10 (a int, x text COLLATE \"C\", y text COLLATE \"POSIX\")" +== 029 +-- truncate_limit: 100 +INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ') +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test10 VALUES (1, 'hij', 'hij'), (2, 'HIJ', 'HIJ')" +== 030 +-- truncate_limit: 100 +SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x), lower(y), upper(x), upper(y), initcap(x), initcap(y) FROM collate_test10" +== 031 +-- truncate_limit: 100 +SELECT a, lower(x COLLATE "C"), lower(y COLLATE "C") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x COLLATE \"C\"), lower(y COLLATE \"C\") FROM collate_test10" +== 032 +-- truncate_limit: 100 +SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, x, y FROM collate_test10 ORDER BY lower(y), a" +== 033 +-- truncate_limit: 100 +-- backwards parsing + +CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collview1" schema="" table="collview1" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc'" +== 034 +-- truncate_limit: 100 +CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collview2" schema="" table="collview2" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE \"C\"" +== 035 +-- truncate_limit: 100 +CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE "POSIX") FROM collate_test10 +-- +TABLE: name="collview3" schema="" table="collview3" ctx=DDL +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview3 AS SELECT a, lower((x || x) COLLATE \"POSIX\") FROM collate_test10" +== 036 +-- truncate_limit: 100 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'collview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'collview%' ORDER BY 1" +== 037 +-- truncate_limit: 100 +-- collation propagation in various expression types + +SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test1 ORDER BY 2" +== 038 +-- truncate_limit: 100 +SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test2 ORDER BY 2" +== 039 +-- truncate_limit: 100 +SELECT a, lower(coalesce(x, 'foo')), lower(coalesce(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(COALESCE(x, 'foo')), lower(COALESCE(y, 'foo')) FROM collate_test10" +== 040 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test1 ORDER BY 3" +== 041 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test2 ORDER BY 3" +== 042 +-- truncate_limit: 100 +SELECT a, x, y, lower(greatest(x, 'foo')), lower(greatest(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, x, y, lower(GREATEST(x, 'foo')), lower(GREATEST(y, 'foo')) FROM collate_test10" +== 043 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test1 ORDER BY 2" +== 044 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test2 ORDER BY 2" +== 045 +-- truncate_limit: 100 +SELECT a, lower(nullif(x, 'foo')), lower(nullif(y, 'foo')) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(NULLIF(x, 'foo')), lower(NULLIF(y, 'foo')) FROM collate_test10" +== 046 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2" +== 047 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2" +== 048 +-- truncate_limit: 100 +CREATE DOMAIN testdomain AS text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain AS text" +== 049 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test1 ORDER BY 2" +== 050 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test2 ORDER BY 2" +== 051 +-- truncate_limit: 100 +SELECT a, b::testdomain_p FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain_p FROM collate_test2 ORDER BY 2" +== 052 +-- truncate_limit: 100 +SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, lower(x::testdomain), lower(y::testdomain) FROM collate_test10" +== 053 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test1" +== 054 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test2" +== 055 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test1" +== 056 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test2" +== 057 +-- truncate_limit: 100 +-- In aggregates, ORDER BY expressions don't affect aggregate's collation +SELECT string_agg(x COLLATE "C", y COLLATE "POSIX") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT string_agg(x COLLATE \"C\", y COLLATE \"POSIX\") FROM collate_test10" +== 058 +-- truncate_limit: 100 +-- fail +SELECT array_agg(x COLLATE "C" ORDER BY y COLLATE "POSIX") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(x COLLATE \"C\" ORDER BY y COLLATE \"POSIX\") FROM collate_test10" +== 059 +-- truncate_limit: 100 +SELECT array_agg(a ORDER BY x COLLATE "C", y COLLATE "POSIX") FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(a ORDER BY x COLLATE \"C\", y COLLATE \"POSIX\") FROM collate_test10" +== 060 +-- truncate_limit: 100 +SELECT array_agg(a ORDER BY x||y) FROM collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(a ORDER BY x || y) FROM collate_test10" +== 061 +-- truncate_limit: 100 +-- fail + +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2" +== 062 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2" +== 063 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test2 WHERE a > 1 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test2 WHERE ... INTERSECT SELECT ... FROM collate_test2 WHERE ... ORDER BY 2" +== 064 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 EXCEPT SELECT a, b FROM collate_test2 WHERE a < 2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 EXCEPT SELECT a, b FROM collate_test2 WHERE a < 2 ORDER BY 2" +== 065 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2 ORDER BY 2" +== 066 +-- truncate_limit: 100 +-- fail +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2" +== 067 +-- truncate_limit: 100 +-- ok +SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test2 ORDER BY 2" +== 068 +-- truncate_limit: 100 +-- fail +SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b COLLATE \"C\" FROM collate_test1 UNION SELECT a, b FROM collate_test2 ORDER BY 2" +== 069 +-- truncate_limit: 100 +-- ok +SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test2 ORDER BY 2" +== 070 +-- truncate_limit: 100 +-- fail +SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test2 ORDER BY 2" +== 071 +-- truncate_limit: 100 +-- fail + +CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2 +-- +TABLE: name="test_u" schema="" table="test_u" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test2" +== 072 +-- truncate_limit: 100 +-- fail + +-- ideally this would be a parse-time error, but for now it must be run-time: +select x < y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x < y FROM collate_test10" +== 073 +-- truncate_limit: 100 +-- fail +select x || y from collate_test10 +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x || y FROM collate_test10" +== 074 +-- truncate_limit: 100 +-- ok, because || is not collation aware +select x, y from collate_test10 order by x || y +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT x, y FROM collate_test10 ORDER BY x || y" +== 075 +-- truncate_limit: 100 +-- not so ok + +-- collation mismatch between recursive and non-recursive term +WITH RECURSIVE foo(x) AS + (SELECT x FROM (VALUES('a' COLLATE "C"),('b')) t(x) + UNION ALL + SELECT (x || 'c') COLLATE "POSIX" FROM foo WHERE length(x) < 10) +SELECT * FROM foo +-- +CTE: "foo" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(x) AS (...) SELECT * FROM foo" +== 076 +-- truncate_limit: 100 +SELECT a, b, a < b as lt FROM + (VALUES ('a', 'B'), ('A', 'b' COLLATE "C")) v(a,b) +-- +STMT: SelectStmt +TRUNCATED: "SELECT a, b, a < b AS lt FROM (VALUES ('a', 'B'), ('A', 'b' COLLATE \"C\")) v(a, b)" +== 077 +-- truncate_limit: 100 +-- collation mismatch in subselects +SELECT * FROM collate_test10 WHERE (x, y) NOT IN (SELECT y, x FROM collate_test10) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test10 WHERE NOT (x, y) IN (SELECT y, x FROM collate_test10)" +== 078 +-- truncate_limit: 100 +-- now it works with overrides +SELECT * FROM collate_test10 WHERE (x COLLATE "POSIX", y COLLATE "C") NOT IN (SELECT y, x FROM collate_test10) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test10 WHERE ..." +== 079 +-- truncate_limit: 100 +SELECT * FROM collate_test10 WHERE (x, y) NOT IN (SELECT y COLLATE "C", x COLLATE "POSIX" FROM collate_test10) +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test10 WHERE NOT (x, y) IN (SELECT ... FROM collate_test10)" +== 080 +-- truncate_limit: 100 +-- casting + +SELECT CAST('42' AS text COLLATE "C") +-- +ERROR: syntax error at or near "COLLATE" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 081 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test1 ORDER BY 2" +== 082 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test2 ORDER BY 2" +== 083 +-- truncate_limit: 100 +-- result of a SQL function + +CREATE FUNCTION vc (text) RETURNS text LANGUAGE sql + AS 'select $1::varchar' +-- +FUNCTION: name="vc" function="vc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION vc(text) RETURNS text LANGUAGE sql AS $$select $1::varchar$$" +== 084 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY a, vc(b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="vc" function="vc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY a, vc(b)" +== 085 +-- truncate_limit: 100 +-- polymorphism + +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1" +== 086 +-- truncate_limit: 100 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1" +== 087 +-- truncate_limit: 100 +CREATE FUNCTION dup (anyelement) RETURNS anyelement + AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dup(anyelement) RETURNS anyelement AS $$select $1$$ LANGUAGE sql" +== 088 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test1 ORDER BY 2" +== 089 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test2 ORDER BY 2" +== 090 +-- truncate_limit: 100 +-- indexes + +CREATE INDEX collate_test1_idx1 ON collate_test1 (b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx1 ON collate_test1 USING btree (b)" +== 091 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "POSIX") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx2 ON collate_test1 USING btree (b COLLATE \"POSIX\")" +== 092 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx3 ON collate_test1 USING btree ((b COLLATE \"POSIX\"))" +== 093 +-- truncate_limit: 100 +-- this is different grammatically +CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx4 ON collate_test1 USING btree (((b || 'foo') COLLATE \"POSIX\"))" +== 094 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "POSIX") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx5 ON collate_test1 USING btree (a COLLATE \"POSIX\")" +== 095 +-- truncate_limit: 100 +-- fail +CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx6 ON collate_test1 USING btree ((a COLLATE \"POSIX\"))" +== 096 +-- truncate_limit: 100 +-- fail + +SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE ... ORDER BY 1" +== 097 +-- truncate_limit: 100 +-- foreign keys + +-- force indexes and mergejoins to be used for FK checking queries, +-- else they might not exercise collation-dependent operators +SET enable_seqscan TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO 0" +== 098 +-- truncate_limit: 100 +SET enable_hashjoin TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO 0" +== 099 +-- truncate_limit: 100 +SET enable_nestloop TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO 0" +== 100 +-- truncate_limit: 100 +CREATE TABLE collate_test20 (f1 text COLLATE "C" PRIMARY KEY) +-- +TABLE: name="collate_test20" schema="" table="collate_test20" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test20 (f1 text PRIMARY KEY COLLATE \"C\")" +== 101 +-- truncate_limit: 100 +INSERT INTO collate_test20 VALUES ('foo'), ('bar') +-- +TABLE: name="collate_test20" schema="" table="collate_test20" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test20 VALUES ('foo'), ('bar')" +== 102 +-- truncate_limit: 100 +CREATE TABLE collate_test21 (f2 text COLLATE "POSIX" REFERENCES collate_test20) +-- +TABLE: name="collate_test21" schema="" table="collate_test21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test21 (f2 text REFERENCES collate_test20 COLLATE \"POSIX\")" +== 103 +-- truncate_limit: 100 +INSERT INTO collate_test21 VALUES ('foo'), ('bar') +-- +TABLE: name="collate_test21" schema="" table="collate_test21" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test21 VALUES ('foo'), ('bar')" +== 104 +-- truncate_limit: 100 +INSERT INTO collate_test21 VALUES ('baz') +-- +TABLE: name="collate_test21" schema="" table="collate_test21" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test21 VALUES ('baz')" +== 105 +-- truncate_limit: 100 +-- fail +CREATE TABLE collate_test22 (f2 text COLLATE "POSIX") +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test22 (f2 text COLLATE \"POSIX\")" +== 106 +-- truncate_limit: 100 +INSERT INTO collate_test22 VALUES ('foo'), ('bar'), ('baz') +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test22 VALUES ('foo'), ('bar'), ('baz')" +== 107 +-- truncate_limit: 100 +ALTER TABLE collate_test22 ADD FOREIGN KEY (f2) REFERENCES collate_test20 +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE collate_test22 ADD FOREIGN KEY (f2) REFERENCES collate_test20" +== 108 +-- truncate_limit: 100 +-- fail +DELETE FROM collate_test22 WHERE f2 = 'baz' +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM collate_test22 WHERE f2 = 'baz'" +== 109 +-- truncate_limit: 100 +ALTER TABLE collate_test22 ADD FOREIGN KEY (f2) REFERENCES collate_test20 +-- +TABLE: name="collate_test22" schema="" table="collate_test22" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE collate_test22 ADD FOREIGN KEY (f2) REFERENCES collate_test20" +== 110 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 111 +-- truncate_limit: 100 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 112 +-- truncate_limit: 100 +RESET enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 113 +-- truncate_limit: 100 +-- EXPLAIN + +EXPLAIN (COSTS OFF) + SELECT * FROM collate_test10 ORDER BY x, y +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM collate_test10 ORDER BY x, y" +== 114 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) + SELECT * FROM collate_test10 ORDER BY x DESC, y COLLATE "C" ASC NULLS FIRST +-- +TABLE: name="collate_test10" schema="" table="collate_test10" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM collate_test10 ORDER BY x DESC, y COLLATE \"C\" ASC NULLS FIRST" +== 115 +-- truncate_limit: 100 +-- CREATE/DROP COLLATION + +CREATE COLLATION builtin_c ( PROVIDER = builtin, LOCALE = "C" ) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION builtin_c (provider = builtin, locale = \"C\")" +== 116 +-- truncate_limit: 100 +SELECT b FROM collate_test1 ORDER BY b COLLATE builtin_c +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b FROM collate_test1 ORDER BY b COLLATE builtin_c" +== 117 +-- truncate_limit: 100 +CREATE COLLATION builtin2 ( PROVIDER = builtin ) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION builtin2 (provider = builtin)" +== 118 +-- truncate_limit: 100 +-- fails +CREATE COLLATION builtin2 ( PROVIDER = builtin, LOCALE = "en_US" ) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION builtin2 (provider = builtin, locale = \"en_US\")" +== 119 +-- truncate_limit: 100 +-- fails +CREATE COLLATION builtin2 ( PROVIDER = builtin, LC_CTYPE = "C", LC_COLLATE = "C" ) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION builtin2 (provider = builtin, lc_ctype = \"C\", lc_collate = \"C\")" +== 120 +-- truncate_limit: 100 +-- fails + +CREATE COLLATION mycoll1 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION mycoll1 FROM \"C\"" +== 121 +-- truncate_limit: 100 +CREATE COLLATION mycoll2 ( LC_COLLATE = "POSIX", LC_CTYPE = "POSIX" ) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION mycoll2 (lc_collate = \"POSIX\", lc_ctype = \"POSIX\")" +== 122 +-- truncate_limit: 100 +CREATE COLLATION mycoll3 FROM "default" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION mycoll3 FROM \"default\"" +== 123 +-- truncate_limit: 100 +-- intentionally unsupported + +DROP COLLATION mycoll1 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION mycoll1" +== 124 +-- truncate_limit: 100 +CREATE TABLE collate_test23 (f1 text collate mycoll2) +-- +TABLE: name="collate_test23" schema="" table="collate_test23" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test23 (f1 text COLLATE mycoll2)" +== 125 +-- truncate_limit: 100 +DROP COLLATION mycoll2 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION mycoll2" +== 126 +-- truncate_limit: 100 +-- fail + +-- invalid: non-lowercase quoted identifiers +CREATE COLLATION case_coll ("Lc_Collate" = "POSIX", "Lc_Ctype" = "POSIX") +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION case_coll (\"Lc_Collate\" = \"POSIX\", \"Lc_Ctype\" = \"POSIX\")" +== 127 +-- truncate_limit: 100 +-- 9.1 bug with useless COLLATE in an expression subject to length coercion + +CREATE TEMP TABLE vctable (f1 varchar(25)) +-- +TABLE: name="vctable" schema="" table="vctable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE vctable (f1 varchar(25))" +== 128 +-- truncate_limit: 100 +INSERT INTO vctable VALUES ('foo' COLLATE "C") +-- +TABLE: name="vctable" schema="" table="vctable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vctable VALUES ('foo' COLLATE \"C\")" +== 129 +-- truncate_limit: 100 +SELECT collation for ('foo') +-- +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT collation for ('foo')" +== 130 +-- truncate_limit: 100 +-- unknown type - null +SELECT collation for ('foo'::text) +-- +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT collation for ('foo'::text)" +== 131 +-- truncate_limit: 100 +SELECT collation for ((SELECT a FROM collate_test1 LIMIT 1)) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT collation for ((SELECT a FROM collate_test1 LIMIT 1))" +== 132 +-- truncate_limit: 100 +-- non-collatable type - error +SELECT collation for ((SELECT b FROM collate_test1 LIMIT 1)) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT collation for ((SELECT b FROM collate_test1 LIMIT 1))" +== 133 +-- truncate_limit: 100 +-- old bug with not dropping COLLATE when coercing to non-collatable type +CREATE VIEW collate_on_int AS +SELECT c1+1 AS c1p FROM + (SELECT ('4' COLLATE "C")::INT AS c1) ss +-- +TABLE: name="collate_on_int" schema="" table="collate_on_int" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collate_on_int AS SELECT c1 + 1 AS c1p FROM (SELECT '4' COLLATE \"C\"::int AS c1) ss" +== 134 +-- truncate_limit: 100 +-- Check conflicting or redundant options in CREATE COLLATION +-- LC_COLLATE +CREATE COLLATION coll_dup_chk (LC_COLLATE = "POSIX", LC_COLLATE = "NONSENSE", LC_CTYPE = "POSIX") +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (lc_collate = \"POSIX\", lc_collate = \"NONSENSE\", lc_ctype = \"POSIX\")" +== 135 +-- truncate_limit: 100 +-- LC_CTYPE +CREATE COLLATION coll_dup_chk (LC_CTYPE = "POSIX", LC_CTYPE = "NONSENSE", LC_COLLATE = "POSIX") +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (lc_ctype = \"POSIX\", lc_ctype = \"NONSENSE\", lc_collate = \"POSIX\")" +== 136 +-- truncate_limit: 100 +-- PROVIDER +CREATE COLLATION coll_dup_chk (PROVIDER = icu, PROVIDER = NONSENSE, LC_COLLATE = "POSIX", LC_CTYPE = "POSIX") +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (provider = icu, provider = nonsense, lc_collate = \"POSIX\", lc_ctyp..." +== 137 +-- truncate_limit: 100 +-- LOCALE +CREATE COLLATION case_sensitive (LOCALE = '', LOCALE = "NONSENSE") +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION case_sensitive (locale = '', locale = \"NONSENSE\")" +== 138 +-- truncate_limit: 100 +-- DETERMINISTIC +CREATE COLLATION coll_dup_chk (DETERMINISTIC = TRUE, DETERMINISTIC = NONSENSE, LOCALE = '') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (deterministic = true, deterministic = nonsense, locale = '')" +== 139 +-- truncate_limit: 100 +-- VERSION +CREATE COLLATION coll_dup_chk (VERSION = '1', VERSION = "NONSENSE", LOCALE = '') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (version = '1', version = \"NONSENSE\", locale = '')" +== 140 +-- truncate_limit: 100 +-- LOCALE conflicts with LC_COLLATE and LC_CTYPE +CREATE COLLATION coll_dup_chk (LC_COLLATE = "POSIX", LC_CTYPE = "POSIX", LOCALE = '') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (lc_collate = \"POSIX\", lc_ctype = \"POSIX\", locale = '')" +== 141 +-- truncate_limit: 100 +-- LOCALE conflicts with LC_COLLATE +CREATE COLLATION coll_dup_chk (LC_COLLATE = "POSIX", LOCALE = '') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (lc_collate = \"POSIX\", locale = '')" +== 142 +-- truncate_limit: 100 +-- LOCALE conflicts with LC_CTYPE +CREATE COLLATION coll_dup_chk (LC_CTYPE = "POSIX", LOCALE = '') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (lc_ctype = \"POSIX\", locale = '')" +== 143 +-- truncate_limit: 100 +-- FROM conflicts with any other option +CREATE COLLATION coll_dup_chk (FROM = "C", VERSION = "1") +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION coll_dup_chk (\"from\" = \"C\", version = \"1\")" +== 144 +-- truncate_limit: 100 +|-- +-- Clean up. Many of these table names will be re-used if the user is +-- trying to run any platform-specific collation tests later, so we +-- must get rid of them. +|-- +DROP SCHEMA collate_tests CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA collate_tests CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.utf8.metadata.json b/parser/testdata/summary_truncate/postgres_regress/collate.utf8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.utf8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.utf8.test b/parser/testdata/summary_truncate/postgres_regress/collate.utf8.test new file mode 100644 index 0000000..d7655dd --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.utf8.test @@ -0,0 +1,203 @@ +== 001 +-- truncate_limit: 100 +/* + * This test is for collations and character operations when using the + * builtin provider with the C.UTF-8 locale. + */ + +/* skip test if not UTF8 server encoding */ +SELECT getdatabaseencoding() <> 'UTF8' AS skip_test +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT getdatabaseencoding() <> 'UTF8' AS skip_test" +== 002 +-- truncate_limit: 100 +SET client_encoding TO UTF8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_encoding TO utf8" +== 003 +-- truncate_limit: 100 +|-- +-- Test PG_C_UTF8 +|-- + +CREATE COLLATION regress_pg_c_utf8 ( + provider = builtin, locale = 'C_UTF8') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION regress_pg_c_utf8 (provider = builtin, locale = 'C_UTF8')" +== 004 +-- truncate_limit: 100 +-- fails +CREATE COLLATION regress_pg_c_utf8 ( + provider = builtin, locale = 'C.UTF8') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION regress_pg_c_utf8 (provider = builtin, locale = 'C.UTF8')" +== 005 +-- truncate_limit: 100 +DROP COLLATION regress_pg_c_utf8 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION regress_pg_c_utf8" +== 006 +-- truncate_limit: 100 +CREATE COLLATION regress_pg_c_utf8 ( + provider = builtin, locale = 'C.UTF-8') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION regress_pg_c_utf8 (provider = builtin, locale = 'C.UTF-8')" +== 007 +-- truncate_limit: 100 +CREATE TABLE test_pg_c_utf8 ( + t TEXT COLLATE PG_C_UTF8 +) +-- +TABLE: name="test_pg_c_utf8" schema="" table="test_pg_c_utf8" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_pg_c_utf8 (t text COLLATE pg_c_utf8)" +== 008 +-- truncate_limit: 100 +INSERT INTO test_pg_c_utf8 VALUES + ('abc DEF 123abc'), + ('ábc sßs ßss DÉF'), + ('DŽxxDŽ džxxDž Džxxdž'), + ('ȺȺȺ'), + ('ⱥⱥⱥ'), + ('ⱥȺ') +-- +TABLE: name="test_pg_c_utf8" schema="" table="test_pg_c_utf8" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_pg_c_utf8 VALUES (...)" +== 009 +-- truncate_limit: 100 +SELECT + t, lower(t), initcap(t), upper(t), + length(convert_to(t, 'UTF8')) AS t_bytes, + length(convert_to(lower(t), 'UTF8')) AS lower_t_bytes, + length(convert_to(initcap(t), 'UTF8')) AS initcap_t_bytes, + length(convert_to(upper(t), 'UTF8')) AS upper_t_bytes + FROM test_pg_c_utf8 +-- +TABLE: name="test_pg_c_utf8" schema="" table="test_pg_c_utf8" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="convert_to" function="convert_to" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="convert_to" function="convert_to" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="convert_to" function="convert_to" schema="" ctx=Call +FUNCTION: name="initcap" function="initcap" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="convert_to" function="convert_to" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_pg_c_utf8" +== 010 +-- truncate_limit: 100 +DROP TABLE test_pg_c_utf8 +-- +TABLE: name="test_pg_c_utf8" schema="" table="test_pg_c_utf8" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_pg_c_utf8" +== 011 +-- truncate_limit: 100 +-- negative test: Final_Sigma not used for builtin locale C.UTF-8 +SELECT lower('ΑΣ' COLLATE PG_C_UTF8) +-- +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lower('ΑΣ' COLLATE pg_c_utf8)" +== 012 +-- truncate_limit: 100 +SELECT lower('ΑͺΣͺ' COLLATE PG_C_UTF8) +-- +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lower('ΑͺΣͺ' COLLATE pg_c_utf8)" +== 013 +-- truncate_limit: 100 +SELECT lower('Α΄Σ΄' COLLATE PG_C_UTF8) +-- +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lower('Α΄Σ΄' COLLATE pg_c_utf8)" +== 014 +-- truncate_limit: 100 +-- properties + +SELECT 'xyz' ~ '[[:alnum:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'xyz' ~ '[[:alnum:]]' COLLATE pg_c_utf8" +== 015 +-- truncate_limit: 100 +SELECT 'xyz' !~ '[[:upper:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'xyz' !~ '[[:upper:]]' COLLATE pg_c_utf8" +== 016 +-- truncate_limit: 100 +SELECT '@' !~ '[[:alnum:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '@' !~ '[[:alnum:]]' COLLATE pg_c_utf8" +== 017 +-- truncate_limit: 100 +SELECT '=' ~ '[[:punct:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '=' ~ '[[:punct:]]' COLLATE pg_c_utf8" +== 018 +-- truncate_limit: 100 +-- symbols are punctuation in posix +SELECT 'a8a' ~ '[[:digit:]]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a8a' ~ '[[:digit:]]' COLLATE pg_c_utf8" +== 019 +-- truncate_limit: 100 +SELECT '൧' !~ '\d' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '൧' !~ E'\\\\d' COLLATE pg_c_utf8" +== 020 +-- truncate_limit: 100 +-- only 0-9 considered digits in posix + +-- case mapping + +SELECT 'xYz' ~* 'XyZ' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'xYz' ~* 'XyZ' COLLATE pg_c_utf8" +== 021 +-- truncate_limit: 100 +SELECT 'xAb' ~* '[W-Y]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'xAb' ~* '[W-Y]' COLLATE pg_c_utf8" +== 022 +-- truncate_limit: 100 +SELECT 'xAb' !~* '[c-d]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'xAb' !~* '[c-d]' COLLATE pg_c_utf8" +== 023 +-- truncate_limit: 100 +SELECT 'Δ' ~* '[γ-λ]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Δ' ~* '[γ-λ]' COLLATE pg_c_utf8" +== 024 +-- truncate_limit: 100 +SELECT 'δ' ~* '[Γ-Λ]' COLLATE PG_C_UTF8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'δ' ~* '[Γ-Λ]' COLLATE pg_c_utf8" diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.windows.win1252.metadata.json b/parser/testdata/summary_truncate/postgres_regress/collate.windows.win1252.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.windows.win1252.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/collate.windows.win1252.test b/parser/testdata/summary_truncate/postgres_regress/collate.windows.win1252.test new file mode 100644 index 0000000..2a63f6b --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/collate.windows.win1252.test @@ -0,0 +1,1439 @@ +== 001 +-- truncate_limit: 100 +/* + * This test is meant to run on Windows systems that has successfully + * run pg_import_system_collations(). Also, the database must have + * WIN1252 encoding, because of the locales' own encodings. Because + * of this, some test are lost from UTF-8 version, such as Turkish + * dotted and undotted 'i'. + */ +SELECT getdatabaseencoding() <> 'WIN1252' OR + (SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE') AND collencoding = pg_char_to_encoding('WIN1252')) <> 3 OR + (version() !~ 'Visual C\+\+' AND version() !~ 'mingw32' AND version() !~ 'windows') + AS skip_test +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +FUNCTION: name="pg_char_to_encoding" function="pg_char_to_encoding" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_char_to_encoding" function="pg_char_to_encoding" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +FILTER: schema="" table="" column="collencoding" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 002 +-- truncate_limit: 100 +SET client_encoding TO WIN1252 +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_encoding TO win1252" +== 003 +-- truncate_limit: 100 +CREATE SCHEMA collate_tests +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA collate_tests" +== 004 +-- truncate_limit: 100 +SET search_path = collate_tests +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO collate_tests" +== 005 +-- truncate_limit: 100 +CREATE TABLE collate_test1 ( + a int, + b text COLLATE "en_US" NOT NULL +) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test1 (a int, b text NOT NULL COLLATE \"en_US\")" +== 006 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "ja_JP.eucjp" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int, b text COLLATE \"ja_JP.eucjp\")" +== 007 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int, + b text COLLATE "foo" +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int, b text COLLATE foo)" +== 008 +-- truncate_limit: 100 +CREATE TABLE collate_test_fail ( + a int COLLATE "en_US", + b text +) +-- +TABLE: name="collate_test_fail" schema="" table="collate_test_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_fail (a int COLLATE \"en_US\", b text)" +== 009 +-- truncate_limit: 100 +CREATE TABLE collate_test_like ( + LIKE collate_test1 +) +-- +TABLE: name="collate_test_like" schema="" table="collate_test_like" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test_like (LIKE collate_test1)" +== 010 +-- truncate_limit: 100 +CREATE TABLE collate_test2 ( + a int, + b text COLLATE "sv_SE" +) +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test2 (a int, b text COLLATE \"sv_SE\")" +== 011 +-- truncate_limit: 100 +CREATE TABLE collate_test3 ( + a int, + b text COLLATE "C" +) +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test3 (a int, b text COLLATE \"C\")" +== 012 +-- truncate_limit: 100 +INSERT INTO collate_test1 VALUES (1, 'abc'), (2, '�bc'), (3, 'bbc'), (4, 'ABC') +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test1 VALUES (1, 'abc'), (2, '�bc'), (3, 'bbc'), (4, 'ABC')" +== 013 +-- truncate_limit: 100 +INSERT INTO collate_test2 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test2 SELECT * FROM collate_test1" +== 014 +-- truncate_limit: 100 +INSERT INTO collate_test3 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test3 SELECT * FROM collate_test1" +== 015 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b >= 'bbc'" +== 016 +-- truncate_limit: 100 +SELECT * FROM collate_test2 WHERE b >= 'bbc' +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 WHERE b >= 'bbc'" +== 017 +-- truncate_limit: 100 +SELECT * FROM collate_test3 WHERE b >= 'bbc' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 WHERE b >= 'bbc'" +== 018 +-- truncate_limit: 100 +SELECT * FROM collate_test3 WHERE b >= 'BBC' +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 WHERE b >= 'BBC'" +== 019 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc'" +== 020 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b >= 'bbc' COLLATE \"C\"" +== 021 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc' COLLATE \"C\"" +== 022 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' COLLATE "en_US" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc' COLLATE \"en_US\"" +== 023 +-- truncate_limit: 100 +CREATE DOMAIN testdomain_sv AS text COLLATE "sv_SE" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain_sv AS text COLLATE \"sv_SE\"" +== 024 +-- truncate_limit: 100 +CREATE DOMAIN testdomain_i AS int COLLATE "sv_SE" +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain_i AS int COLLATE \"sv_SE\"" +== 025 +-- truncate_limit: 100 +-- fails +CREATE TABLE collate_test4 ( + a int, + b testdomain_sv +) +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test4 (a int, b testdomain_sv)" +== 026 +-- truncate_limit: 100 +INSERT INTO collate_test4 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test4 SELECT * FROM collate_test1" +== 027 +-- truncate_limit: 100 +SELECT a, b FROM collate_test4 ORDER BY b +-- +TABLE: name="collate_test4" schema="" table="collate_test4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test4 ORDER BY b" +== 028 +-- truncate_limit: 100 +CREATE TABLE collate_test5 ( + a int, + b testdomain_sv COLLATE "en_US" +) +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test5 (a int, b testdomain_sv COLLATE \"en_US\")" +== 029 +-- truncate_limit: 100 +INSERT INTO collate_test5 SELECT * FROM collate_test1 +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=DML +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test5 SELECT * FROM collate_test1" +== 030 +-- truncate_limit: 100 +SELECT a, b FROM collate_test5 ORDER BY b +-- +TABLE: name="collate_test5" schema="" table="collate_test5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test5 ORDER BY b" +== 031 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY b" +== 032 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 ORDER BY b" +== 033 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test3 ORDER BY b" +== 034 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 ORDER BY b COLLATE \"C\"" +== 035 +-- truncate_limit: 100 +-- star expansion +SELECT * FROM collate_test1 ORDER BY b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 ORDER BY b" +== 036 +-- truncate_limit: 100 +SELECT * FROM collate_test2 ORDER BY b +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test2 ORDER BY b" +== 037 +-- truncate_limit: 100 +SELECT * FROM collate_test3 ORDER BY b +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test3 ORDER BY b" +== 038 +-- truncate_limit: 100 +-- constant expression folding +SELECT 'bbc' COLLATE "en_US" > '�bc' COLLATE "en_US" AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' COLLATE \"en_US\" > '�bc' COLLATE \"en_US\" AS \"true\"" +== 039 +-- truncate_limit: 100 +SELECT 'bbc' COLLATE "sv_SE" > '�bc' COLLATE "sv_SE" AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' COLLATE \"sv_SE\" > '�bc' COLLATE \"sv_SE\" AS \"false\"" +== 040 +-- truncate_limit: 100 +-- LIKE/ILIKE + +SELECT * FROM collate_test1 WHERE b LIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE 'abc'" +== 041 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b LIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE 'abc%'" +== 042 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b LIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b LIKE '%bc%'" +== 043 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE 'abc'" +== 044 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE 'abc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE 'abc%'" +== 045 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ILIKE '%bc%' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ILIKE '%bc%'" +== 046 +-- truncate_limit: 100 +-- The following actually exercises the selectivity estimation for ILIKE. +SELECT relname FROM pg_class WHERE relname ILIKE 'abc%' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ILIKE 'abc%'" +== 047 +-- truncate_limit: 100 +-- regular expressions + +SELECT * FROM collate_test1 WHERE b ~ '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ '^abc$'" +== 048 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~ '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ '^abc'" +== 049 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~ 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~ 'bc'" +== 050 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* '^abc$' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* '^abc$'" +== 051 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* '^abc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* '^abc'" +== 052 +-- truncate_limit: 100 +SELECT * FROM collate_test1 WHERE b ~* 'bc' +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM collate_test1 WHERE b ~* 'bc'" +== 053 +-- truncate_limit: 100 +CREATE TABLE collate_test6 ( + a int, + b text COLLATE "en_US" +) +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_test6 (a int, b text COLLATE \"en_US\")" +== 054 +-- truncate_limit: 100 +INSERT INTO collate_test6 VALUES (1, 'abc'), (2, 'ABC'), (3, '123'), (4, 'ab1'), + (5, 'a1!'), (6, 'a c'), (7, '!.;'), (8, ' '), + (9, '�b�'), (10, '�B�') +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO collate_test6 VALUES (...)" +== 055 +-- truncate_limit: 100 +SELECT b, + b ~ '^[[:alpha:]]+$' AS is_alpha, + b ~ '^[[:upper:]]+$' AS is_upper, + b ~ '^[[:lower:]]+$' AS is_lower, + b ~ '^[[:digit:]]+$' AS is_digit, + b ~ '^[[:alnum:]]+$' AS is_alnum, + b ~ '^[[:graph:]]+$' AS is_graph, + b ~ '^[[:print:]]+$' AS is_print, + b ~ '^[[:punct:]]+$' AS is_punct, + b ~ '^[[:space:]]+$' AS is_space +FROM collate_test6 +-- +TABLE: name="collate_test6" schema="" table="collate_test6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test6" +== 056 +-- truncate_limit: 100 +-- The following actually exercises the selectivity estimation for ~*. +SELECT relname FROM pg_class WHERE relname ~* '^abc' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ~* '^abc'" +== 057 +-- truncate_limit: 100 +-- backwards parsing + +CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE "C" >= 'bbc' +-- +TABLE: name="collview1" schema="" table="collview1" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview1 AS SELECT * FROM collate_test1 WHERE b COLLATE \"C\" >= 'bbc'" +== 058 +-- truncate_limit: 100 +CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE "C" +-- +TABLE: name="collview2" schema="" table="collview2" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collview2 AS SELECT a, b FROM collate_test1 ORDER BY b COLLATE \"C\"" +== 059 +-- truncate_limit: 100 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'collview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'collview%' ORDER BY 1" +== 060 +-- truncate_limit: 100 +-- collation propagation in various expression types + +SELECT a, coalesce(b, 'foo') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test1 ORDER BY 2" +== 061 +-- truncate_limit: 100 +SELECT a, coalesce(b, 'foo') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test2 ORDER BY 2" +== 062 +-- truncate_limit: 100 +SELECT a, coalesce(b, 'foo') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, COALESCE(b, 'foo') FROM collate_test3 ORDER BY 2" +== 063 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test1 ORDER BY 3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test1 ORDER BY 3" +== 064 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test2 ORDER BY 3 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test2 ORDER BY 3" +== 065 +-- truncate_limit: 100 +SELECT a, b, greatest(b, 'CCC') FROM collate_test3 ORDER BY 3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GREATEST(b, 'CCC') FROM collate_test3 ORDER BY 3" +== 066 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test1 ORDER BY 2" +== 067 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test2 ORDER BY 2" +== 068 +-- truncate_limit: 100 +SELECT a, nullif(b, 'abc') FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, NULLIF(b, 'abc') FROM collate_test3 ORDER BY 2" +== 069 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test1 ORDER BY 2" +== 070 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test2 ORDER BY 2" +== 071 +-- truncate_limit: 100 +SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, CASE b WHEN 'abc' THEN 'abcd' ELSE b END FROM collate_test3 ORDER BY 2" +== 072 +-- truncate_limit: 100 +CREATE DOMAIN testdomain AS text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain AS text" +== 073 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test1 ORDER BY 2" +== 074 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test2 ORDER BY 2" +== 075 +-- truncate_limit: 100 +SELECT a, b::testdomain FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain FROM collate_test3 ORDER BY 2" +== 076 +-- truncate_limit: 100 +SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::testdomain_sv FROM collate_test3 ORDER BY 2" +== 077 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test1" +== 078 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test2" +== 079 +-- truncate_limit: 100 +SELECT min(b), max(b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(b), max(b) FROM collate_test3" +== 080 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test1" +== 081 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test2" +== 082 +-- truncate_limit: 100 +SELECT array_agg(b ORDER BY b) FROM collate_test3 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(b ORDER BY b) FROM collate_test3" +== 083 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test1 ORDER BY 2" +== 084 +-- truncate_limit: 100 +SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test2 UNION SELECT a, b FROM collate_test2 ORDER BY 2" +== 085 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 WHERE a < 4 INTERSECT SELECT a, b FROM collate_test3 WHERE a > 1 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test3 WHERE ... INTERSECT SELECT ... FROM collate_test3 WHERE ... ORDER BY 2" +== 086 +-- truncate_limit: 100 +SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test3 EXCEPT SELECT a, b FROM collate_test3 WHERE a < 2 ORDER BY 2" +== 087 +-- truncate_limit: 100 +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 ORDER BY 2" +== 088 +-- truncate_limit: 100 +-- fail +SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3" +== 089 +-- truncate_limit: 100 +-- ok +SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2" +== 090 +-- truncate_limit: 100 +-- fail +SELECT a, b COLLATE "C" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b COLLATE \"C\" FROM collate_test1 UNION SELECT a, b FROM collate_test3 ORDER BY 2" +== 091 +-- truncate_limit: 100 +-- ok +SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 INTERSECT SELECT a, b FROM collate_test3 ORDER BY 2" +== 092 +-- truncate_limit: 100 +-- fail +SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2" +== 093 +-- truncate_limit: 100 +-- fail + +CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3 +-- +TABLE: name="test_u" schema="" table="test_u" ctx=DDL +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3" +== 094 +-- truncate_limit: 100 +-- fail + +-- collation mismatch between recursive and non-recursive term +WITH RECURSIVE foo(x) AS + (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x) + UNION ALL + SELECT (x || 'c') COLLATE "de_DE" FROM foo WHERE length(x) < 10) +SELECT * FROM foo +-- +CTE: "foo" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(x) AS (...) SELECT * FROM foo" +== 095 +-- truncate_limit: 100 +-- casting + +SELECT CAST('42' AS text COLLATE "C") +-- +ERROR: syntax error at or near "COLLATE" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 096 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test1 ORDER BY 2" +== 097 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test2 ORDER BY 2" +== 098 +-- truncate_limit: 100 +SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b::varchar FROM collate_test3 ORDER BY 2" +== 099 +-- truncate_limit: 100 +-- propagation of collation in SQL functions (inlined and non-inlined cases) +-- and plpgsql functions too + +CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 $$ +-- +FUNCTION: name="mylt" function="mylt" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt(text, text) RETURNS boolean LANGUAGE sql AS $$ select $1 < $2 $$" +== 100 +-- truncate_limit: 100 +CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql + AS $$ select $1 < $2 limit 1 $$ +-- +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt_noninline(text, text) RETURNS boolean LANGUAGE sql AS $$ select $1 < $2 limi..." +== 101 +-- truncate_limit: 100 +CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql + AS $$ begin return $1 < $2; end $$ +-- +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt_plpgsql(text, text) RETURNS boolean LANGUAGE plpgsql AS $$ begin return $1 <..." +== 102 +-- truncate_limit: 100 +SELECT a.b AS a, b.b AS b, a.b < b.b AS lt, + mylt(a.b, b.b), mylt_noninline(a.b, b.b), mylt_plpgsql(a.b, b.b) +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test1 a, collate_test1 b ORDER BY a.b, b.b" +== 103 +-- truncate_limit: 100 +SELECT a.b AS a, b.b AS b, a.b < b.b COLLATE "C" AS lt, + mylt(a.b, b.b COLLATE "C"), mylt_noninline(a.b, b.b COLLATE "C"), + mylt_plpgsql(a.b, b.b COLLATE "C") +FROM collate_test1 a, collate_test1 b +ORDER BY a.b, b.b +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +ALIAS: "a"="collate_test1" +ALIAS: "b"="collate_test1" +FUNCTION: name="mylt" function="mylt" schema="" ctx=Call +FUNCTION: name="mylt_noninline" function="mylt_noninline" schema="" ctx=Call +FUNCTION: name="mylt_plpgsql" function="mylt_plpgsql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM collate_test1 a, collate_test1 b ORDER BY a.b, b.b" +== 104 +-- truncate_limit: 100 +-- collation override in plpgsql + +CREATE FUNCTION mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mylt2(x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$\ndeclare\n xx text :=..." +== 105 +-- truncate_limit: 100 +SELECT mylt2('a', 'B' collate "en_US") as t, mylt2('a', 'B' collate "C") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"en_US\") AS t, mylt2('a', 'B' COLLATE \"C\") AS f" +== 106 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION + mylt2 (x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$ +declare + xx text COLLATE "POSIX" := x; + yy text := y; +begin + return xx < yy; +end +$$ +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION mylt2(x text, y text) RETURNS boolean LANGUAGE plpgsql AS $$\ndeclare\n ..." +== 107 +-- truncate_limit: 100 +SELECT mylt2('a', 'B') as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B') AS f" +== 108 +-- truncate_limit: 100 +SELECT mylt2('a', 'B' collate "C") as fail +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"C\") AS fail" +== 109 +-- truncate_limit: 100 +-- conflicting collations +SELECT mylt2('a', 'B' collate "POSIX") as f +-- +FUNCTION: name="mylt2" function="mylt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mylt2('a', 'B' COLLATE \"POSIX\") AS f" +== 110 +-- truncate_limit: 100 +-- polymorphism + +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER BY 1" +== 111 +-- truncate_limit: 100 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1" +== 112 +-- truncate_limit: 100 +SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1" +== 113 +-- truncate_limit: 100 +CREATE FUNCTION dup (anyelement) RETURNS anyelement + AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dup(anyelement) RETURNS anyelement AS $$select $1$$ LANGUAGE sql" +== 114 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test1 ORDER BY 2 +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test1 ORDER BY 2" +== 115 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test2 ORDER BY 2 +-- +TABLE: name="collate_test2" schema="" table="collate_test2" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test2 ORDER BY 2" +== 116 +-- truncate_limit: 100 +SELECT a, dup(b) FROM collate_test3 ORDER BY 2 +-- +TABLE: name="collate_test3" schema="" table="collate_test3" ctx=Select +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, dup(b) FROM collate_test3 ORDER BY 2" +== 117 +-- truncate_limit: 100 +-- indexes + +CREATE INDEX collate_test1_idx1 ON collate_test1 (b) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx1 ON collate_test1 USING btree (b)" +== 118 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx2 ON collate_test1 (b COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx2 ON collate_test1 USING btree (b COLLATE \"C\")" +== 119 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx3 ON collate_test1 ((b COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx3 ON collate_test1 USING btree ((b COLLATE \"C\"))" +== 120 +-- truncate_limit: 100 +-- this is different grammatically +CREATE INDEX collate_test1_idx4 ON collate_test1 (((b||'foo') COLLATE "POSIX")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx4 ON collate_test1 USING btree (((b || 'foo') COLLATE \"POSIX\"))" +== 121 +-- truncate_limit: 100 +CREATE INDEX collate_test1_idx5 ON collate_test1 (a COLLATE "C") +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx5 ON collate_test1 USING btree (a COLLATE \"C\")" +== 122 +-- truncate_limit: 100 +-- fail +CREATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C")) +-- +TABLE: name="collate_test1" schema="" table="collate_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_test1_idx6 ON collate_test1 USING btree ((a COLLATE \"C\"))" +== 123 +-- truncate_limit: 100 +-- fail + +SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE ... ORDER BY 1" +== 124 +-- truncate_limit: 100 +-- schema manipulation commands + +CREATE ROLE regress_test_role +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_role" +== 125 +-- truncate_limit: 100 +CREATE SCHEMA test_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_schema" +== 126 +-- truncate_limit: 100 +-- We need to do this this way to cope with varying names for encodings: +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test0 (locale = ' || + quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n EXECUTE 'CREATE COLLATION test0 (locale = ' ||\n quote_literal((SELECT datc..." +== 127 +-- truncate_limit: 100 +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test0 FROM \"C\"" +== 128 +-- truncate_limit: 100 +-- fail, duplicate name +CREATE COLLATION IF NOT EXISTS test0 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION IF NOT EXISTS test0 FROM \"C\"" +== 129 +-- truncate_limit: 100 +-- ok, skipped +CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION IF NOT EXISTS test0 (locale = 'foo')" +== 130 +-- truncate_limit: 100 +-- ok, skipped +do $$ +BEGIN + EXECUTE 'CREATE COLLATION test1 (lc_collate = ' || + quote_literal((SELECT datcollate FROM pg_database WHERE datname = current_database())) || + ', lc_ctype = ' || + quote_literal((SELECT datctype FROM pg_database WHERE datname = current_database())) || ');'; +END +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n EXECUTE 'CREATE COLLATION test1 (lc_collate = ' ||\n quote_literal((SELECT ..." +== 131 +-- truncate_limit: 100 +CREATE COLLATION test3 (lc_collate = 'en_US.utf8') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test3 (lc_collate = 'en_US.utf8')" +== 132 +-- truncate_limit: 100 +-- fail, need lc_ctype +CREATE COLLATION testx (locale = 'nonsense') +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION testx (locale = 'nonsense')" +== 133 +-- truncate_limit: 100 +-- fail + +CREATE COLLATION test4 FROM nonsense +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test4 FROM nonsense" +== 134 +-- truncate_limit: 100 +CREATE COLLATION test5 FROM test0 +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test5 FROM test0" +== 135 +-- truncate_limit: 100 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT collname FROM pg_collation WHERE collname LIKE 'test%' ORDER BY 1" +== 136 +-- truncate_limit: 100 +ALTER COLLATION test1 RENAME TO test11 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test1 RENAME TO test11" +== 137 +-- truncate_limit: 100 +ALTER COLLATION test0 RENAME TO test11 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test0 RENAME TO test11" +== 138 +-- truncate_limit: 100 +-- fail +ALTER COLLATION test1 RENAME TO test22 +-- +STMT: RenameStmt +TRUNCATED: "ALTER COLLATION test1 RENAME TO test22" +== 139 +-- truncate_limit: 100 +-- fail + +ALTER COLLATION test11 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER COLLATION test11 OWNER TO regress_test_role" +== 140 +-- truncate_limit: 100 +ALTER COLLATION test11 OWNER TO nonsense +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER COLLATION test11 OWNER TO nonsense" +== 141 +-- truncate_limit: 100 +ALTER COLLATION test11 SET SCHEMA test_schema +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER COLLATION test11 SET SCHEMA test_schema" +== 142 +-- truncate_limit: 100 +COMMENT ON COLLATION test0 IS 'US English' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLLATION test0 IS 'US English'" +== 143 +-- truncate_limit: 100 +SELECT collname, nspname, obj_description(pg_collation.oid, 'pg_collation') + FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid) + WHERE collname LIKE 'test%' + ORDER BY 1 +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_collation JOIN pg_namespace ON collnamespace = pg_namespace.oid WHERE ... ORDE..." +== 144 +-- truncate_limit: 100 +DROP COLLATION test0, test_schema.test11, test5 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0, test_schema.test11, test5" +== 145 +-- truncate_limit: 100 +DROP COLLATION test0 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0" +== 146 +-- truncate_limit: 100 +-- fail +DROP COLLATION IF EXISTS test0 +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION IF EXISTS test0" +== 147 +-- truncate_limit: 100 +SELECT collname FROM pg_collation WHERE collname LIKE 'test%' +-- +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT collname FROM pg_collation WHERE collname LIKE 'test%'" +== 148 +-- truncate_limit: 100 +DROP SCHEMA test_schema +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA test_schema" +== 149 +-- truncate_limit: 100 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role" +== 150 +-- truncate_limit: 100 +-- ALTER + +ALTER COLLATION "en_US" REFRESH VERSION +-- +STMT: AlterCollationStmt +TRUNCATED: "ALTER COLLATION \"en_US\" REFRESH VERSION" +== 151 +-- truncate_limit: 100 +-- also test for database while we are here +SELECT current_database() AS datname +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_database() AS datname" +== 152 +-- truncate_limit: 100 +ALTER DATABASE :"datname" REFRESH COLLATION VERSION +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 153 +-- truncate_limit: 100 +-- dependencies + +CREATE COLLATION test0 FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION test0 FROM \"C\"" +== 154 +-- truncate_limit: 100 +CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0) +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_dep_test1 (a int, b text COLLATE test0)" +== 155 +-- truncate_limit: 100 +CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN collate_dep_dom1 AS text COLLATE test0" +== 156 +-- truncate_limit: 100 +CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE collate_dep_test2 AS (x int, y text COLLATE test0)" +== 157 +-- truncate_limit: 100 +CREATE VIEW collate_dep_test3 AS SELECT text 'foo' COLLATE test0 AS foo +-- +TABLE: name="collate_dep_test3" schema="" table="collate_dep_test3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW collate_dep_test3 AS SELECT 'foo'::text COLLATE test0 AS foo" +== 158 +-- truncate_limit: 100 +CREATE TABLE collate_dep_test4t (a int, b text) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE collate_dep_test4t (a int, b text)" +== 159 +-- truncate_limit: 100 +CREATE INDEX collate_dep_test4i ON collate_dep_test4t (b COLLATE test0) +-- +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX collate_dep_test4i ON collate_dep_test4t USING btree (b COLLATE test0)" +== 160 +-- truncate_limit: 100 +DROP COLLATION test0 RESTRICT +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0" +== 161 +-- truncate_limit: 100 +-- fail +DROP COLLATION test0 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION test0 CASCADE" +== 162 +-- truncate_limit: 100 +DROP TABLE collate_dep_test1, collate_dep_test4t +-- +TABLE: name="collate_dep_test1" schema="" table="collate_dep_test1" ctx=DDL +TABLE: name="collate_dep_test4t" schema="" table="collate_dep_test4t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE collate_dep_test1, collate_dep_test4t" +== 163 +-- truncate_limit: 100 +DROP TYPE collate_dep_test2 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE collate_dep_test2" +== 164 +-- truncate_limit: 100 +-- test range types and collations + +create type textrange_c as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange_c AS RANGE (subtype = text, \"collation\" = \"C\")" +== 165 +-- truncate_limit: 100 +create type textrange_en_us as range(subtype=text, collation="en_US") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange_en_us AS RANGE (subtype = text, \"collation\" = \"en_US\")" +== 166 +-- truncate_limit: 100 +select textrange_c('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_c" function="textrange_c" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange_c('A', 'Z') @> 'b'::text" +== 167 +-- truncate_limit: 100 +select textrange_en_us('A','Z') @> 'b'::text +-- +FUNCTION: name="textrange_en_us" function="textrange_en_us" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange_en_us('A', 'Z') @> 'b'::text" +== 168 +-- truncate_limit: 100 +drop type textrange_c +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange_c" +== 169 +-- truncate_limit: 100 +drop type textrange_en_us +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange_en_us" +== 170 +-- truncate_limit: 100 +-- nondeterministic collations +-- (not supported with libc provider) +do $$ +BEGIN + EXECUTE 'CREATE COLLATION ctest_det (locale = ' || + quote_literal((SELECT collcollate FROM pg_collation WHERE + collname = 'en_US')) || ', deterministic = true);'; + END +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n EXECUTE 'CREATE COLLATION ctest_det (locale = ' ||\n quote_literal((SELECT ..." +== 171 +-- truncate_limit: 100 +CREATE COLLATION ctest_nondet (locale = 'en_US', deterministic = false) +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION ctest_nondet (locale = 'en_US', deterministic = false)" +== 172 +-- truncate_limit: 100 +-- cleanup +SET client_min_messages TO warning +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 173 +-- truncate_limit: 100 +DROP SCHEMA collate_tests CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA collate_tests CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/combocid.metadata.json b/parser/testdata/summary_truncate/postgres_regress/combocid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/combocid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/combocid.test b/parser/testdata/summary_truncate/postgres_regress/combocid.test new file mode 100644 index 0000000..0c75ce5 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/combocid.test @@ -0,0 +1,463 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for some likely failure cases with combo cmin/cmax mechanism +|-- +CREATE TEMP TABLE combocidtest (foobar int) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE combocidtest (foobar int)" +== 002 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 003 +-- truncate_limit: 100 +-- a few dummy ops to push up the CommandId counter +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 004 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 005 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 006 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 007 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 008 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 009 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 010 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 011 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 012 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 013 +-- truncate_limit: 100 +INSERT INTO combocidtest VALUES (1) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest VALUES (1)" +== 014 +-- truncate_limit: 100 +INSERT INTO combocidtest VALUES (2) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest VALUES (2)" +== 015 +-- truncate_limit: 100 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 016 +-- truncate_limit: 100 +SAVEPOINT s1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT s1" +== 017 +-- truncate_limit: 100 +UPDATE combocidtest SET foobar = foobar + 10 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE combocidtest SET foobar = foobar + 10" +== 018 +-- truncate_limit: 100 +-- here we should see only updated tuples +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 019 +-- truncate_limit: 100 +ROLLBACK TO s1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT s1" +== 020 +-- truncate_limit: 100 +-- now we should see old tuples, but with combo CIDs starting at 0 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 021 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 022 +-- truncate_limit: 100 +-- combo data is not there anymore, but should still see tuples +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 023 +-- truncate_limit: 100 +-- Test combo CIDs with portals +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 024 +-- truncate_limit: 100 +INSERT INTO combocidtest VALUES (333) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest VALUES (333)" +== 025 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT ctid,cmin,* FROM combocidtest +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT ctid, cmin, * FROM combocidtest" +== 026 +-- truncate_limit: 100 +DELETE FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM combocidtest" +== 027 +-- truncate_limit: 100 +FETCH ALL FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c" +== 028 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 029 +-- truncate_limit: 100 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 030 +-- truncate_limit: 100 +-- check behavior with locked tuples +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 031 +-- truncate_limit: 100 +-- a few dummy ops to push up the CommandId counter +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 032 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 033 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 034 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 035 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 036 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 037 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 038 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 039 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 040 +-- truncate_limit: 100 +INSERT INTO combocidtest SELECT 1 LIMIT 0 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest SELECT 1 LIMIT 0" +== 041 +-- truncate_limit: 100 +INSERT INTO combocidtest VALUES (444) +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO combocidtest VALUES (444)" +== 042 +-- truncate_limit: 100 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 043 +-- truncate_limit: 100 +SAVEPOINT s1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT s1" +== 044 +-- truncate_limit: 100 +-- this doesn't affect cmin +SELECT ctid,cmin,* FROM combocidtest FOR UPDATE +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest FOR UPDATE" +== 045 +-- truncate_limit: 100 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 046 +-- truncate_limit: 100 +-- but this does +UPDATE combocidtest SET foobar = foobar + 10 +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE combocidtest SET foobar = foobar + 10" +== 047 +-- truncate_limit: 100 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 048 +-- truncate_limit: 100 +ROLLBACK TO s1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT s1" +== 049 +-- truncate_limit: 100 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 050 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 051 +-- truncate_limit: 100 +SELECT ctid,cmin,* FROM combocidtest +-- +TABLE: name="combocidtest" schema="" table="combocidtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, cmin, * FROM combocidtest" +== 052 +-- truncate_limit: 100 +-- test for bug reported in +-- CABRT9RC81YUf1=jsmWopcKJEro=VoeG2ou6sPwyOUTx_qteRsg@mail.gmail.com +CREATE TABLE IF NOT EXISTS testcase( + id int PRIMARY KEY, + balance numeric +) +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE IF NOT EXISTS testcase (id int PRIMARY KEY, balance numeric)" +== 053 +-- truncate_limit: 100 +INSERT INTO testcase VALUES (1, 0) +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testcase VALUES (1, 0)" +== 054 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 055 +-- truncate_limit: 100 +SELECT * FROM testcase WHERE testcase.id = 1 FOR UPDATE +-- +TABLE: name="testcase" schema="" table="testcase" ctx=Select +FILTER: schema="" table="testcase" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testcase WHERE testcase.id = 1 FOR UPDATE" +== 056 +-- truncate_limit: 100 +UPDATE testcase SET balance = balance + 400 WHERE id=1 +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testcase SET balance = balance + 400 WHERE id = 1" +== 057 +-- truncate_limit: 100 +SAVEPOINT subxact +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT subxact" +== 058 +-- truncate_limit: 100 +UPDATE testcase SET balance = balance - 100 WHERE id=1 +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testcase SET balance = balance - 100 WHERE id = 1" +== 059 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT subxact +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT subxact" +== 060 +-- truncate_limit: 100 +-- should return one tuple +SELECT * FROM testcase WHERE id = 1 FOR UPDATE +-- +TABLE: name="testcase" schema="" table="testcase" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testcase WHERE id = 1 FOR UPDATE" +== 061 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 062 +-- truncate_limit: 100 +DROP TABLE testcase +-- +TABLE: name="testcase" schema="" table="testcase" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testcase" diff --git a/parser/testdata/summary_truncate/postgres_regress/comments.metadata.json b/parser/testdata/summary_truncate/postgres_regress/comments.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/comments.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/comments.test b/parser/testdata/summary_truncate/postgres_regress/comments.test new file mode 100644 index 0000000..0ad170a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/comments.test @@ -0,0 +1,71 @@ +== 001 +-- truncate_limit: 100 +|-- +-- COMMENTS +|-- + +SELECT 'trailing' AS first +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'trailing' AS first" +== 002 +-- truncate_limit: 100 +-- trailing single line +SELECT /* embedded single line */ 'embedded' AS second +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'embedded' AS second" +== 003 +-- truncate_limit: 100 +SELECT /* both embedded and trailing single line */ 'both' AS third +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'both' AS third" +== 004 +-- truncate_limit: 100 +-- trailing single line + +SELECT 'before multi-line' AS fourth +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'before multi-line' AS fourth" +== 005 +-- truncate_limit: 100 +/* This is an example of SQL which should not execute: + * select 'multi-line'; + */ +SELECT 'after multi-line' AS fifth +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'after multi-line' AS fifth" +== 006 +-- truncate_limit: 100 +|-- +-- Nested comments +|-- + +/* +SELECT 'trailing' as x1; -- inside block comment +*/ + +/* This block comment surrounds a query which itself has a block comment... +SELECT /* embedded single line */ 'embedded' AS x2; +*/ + +SELECT -- continued after the following block comments... +/* Deeply nested comment. + This includes a single apostrophe to make sure we aren't decoding this part as a string. +SELECT 'deep nest' AS n1; +/* Second level of nesting... +SELECT 'deeper nest' as n2; +/* Third level of nesting... +SELECT 'deepest nest' as n3; +*/ +Hoo boy. Still two deep... +*/ +Now just one deep... +*/ +'deeply nested example' AS sixth +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'deeply nested example' AS sixth" diff --git a/parser/testdata/summary_truncate/postgres_regress/compression.metadata.json b/parser/testdata/summary_truncate/postgres_regress/compression.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/compression.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/compression.test b/parser/testdata/summary_truncate/postgres_regress/compression.test new file mode 100644 index 0000000..7400d93 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/compression.test @@ -0,0 +1,698 @@ +== 001 +-- truncate_limit: 100 +-- ensure we get stable results regardless of installation's default +SET default_toast_compression = 'pglz' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_toast_compression TO pglz" +== 002 +-- truncate_limit: 100 +-- test creating table with compression method +CREATE TABLE cmdata(f1 text COMPRESSION pglz) +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmdata (f1 text COMPRESSION pglz)" +== 003 +-- truncate_limit: 100 +CREATE INDEX idx ON cmdata(f1) +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idx ON cmdata USING btree (f1)" +== 004 +-- truncate_limit: 100 +INSERT INTO cmdata VALUES(repeat('1234567890', 1000)) +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmdata VALUES (repeat('1234567890', 1000))" +== 005 +-- truncate_limit: 100 +CREATE TABLE cmdata1(f1 TEXT COMPRESSION lz4) +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmdata1 (f1 text COMPRESSION lz4)" +== 006 +-- truncate_limit: 100 +INSERT INTO cmdata1 VALUES(repeat('1234567890', 1004)) +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmdata1 VALUES (repeat('1234567890', 1004))" +== 007 +-- truncate_limit: 100 +-- verify stored compression method in the data +SELECT pg_column_compression(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata" +== 008 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata1" +== 009 +-- truncate_limit: 100 +-- decompress data slice +SELECT SUBSTR(f1, 200, 5) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT substr(f1, 200, 5) FROM cmdata" +== 010 +-- truncate_limit: 100 +SELECT SUBSTR(f1, 2000, 50) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT substr(f1, 2000, 50) FROM cmdata1" +== 011 +-- truncate_limit: 100 +-- copy with table creation +SELECT * INTO cmmove1 FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +TABLE: name="cmmove1" schema="" table="cmmove1" ctx=DDL +STMT: SelectStmt +TRUNCATED: "SELECT * INTO cmmove1 FROM cmdata" +== 012 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmmove1 +-- +TABLE: name="cmmove1" schema="" table="cmmove1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmmove1" +== 013 +-- truncate_limit: 100 +-- copy to existing table +CREATE TABLE cmmove3(f1 text COMPRESSION pglz) +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmmove3 (f1 text COMPRESSION pglz)" +== 014 +-- truncate_limit: 100 +INSERT INTO cmmove3 SELECT * FROM cmdata +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=DML +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmmove3 SELECT * FROM cmdata" +== 015 +-- truncate_limit: 100 +INSERT INTO cmmove3 SELECT * FROM cmdata1 +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=DML +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmmove3 SELECT * FROM cmdata1" +== 016 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmmove3 +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmmove3" +== 017 +-- truncate_limit: 100 +-- test LIKE INCLUDING COMPRESSION +CREATE TABLE cmdata2 (LIKE cmdata1 INCLUDING COMPRESSION) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmdata2 (LIKE cmdata1 INCLUDING COMPRESSION)" +== 018 +-- truncate_limit: 100 +DROP TABLE cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cmdata2" +== 019 +-- truncate_limit: 100 +-- try setting compression for incompressible data type +CREATE TABLE cmdata2 (f1 int COMPRESSION pglz) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmdata2 (f1 int COMPRESSION pglz)" +== 020 +-- truncate_limit: 100 +-- update using datum from different table +CREATE TABLE cmmove2(f1 text COMPRESSION pglz) +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmmove2 (f1 text COMPRESSION pglz)" +== 021 +-- truncate_limit: 100 +INSERT INTO cmmove2 VALUES (repeat('1234567890', 1004)) +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmmove2 VALUES (repeat('1234567890', 1004))" +== 022 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmmove2 +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmmove2" +== 023 +-- truncate_limit: 100 +UPDATE cmmove2 SET f1 = cmdata1.f1 FROM cmdata1 +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=DML +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +STMT: UpdateStmt +TRUNCATED: "UPDATE cmmove2 SET f1 = cmdata1.f1 FROM cmdata1" +== 024 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmmove2 +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmmove2" +== 025 +-- truncate_limit: 100 +-- test externally stored compressed data +CREATE OR REPLACE FUNCTION large_val() RETURNS TEXT LANGUAGE SQL AS +'select array_agg(fipshash(g::text))::text from generate_series(1, 256) g' +-- +FUNCTION: name="large_val" function="large_val" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION large_val() RETURNS text LANGUAGE sql AS $$select array_agg(fipshash(g..." +== 026 +-- truncate_limit: 100 +CREATE TABLE cmdata2 (f1 text COMPRESSION pglz) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmdata2 (f1 text COMPRESSION pglz)" +== 027 +-- truncate_limit: 100 +INSERT INTO cmdata2 SELECT large_val() || repeat('a', 4000) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DML +FUNCTION: name="large_val" function="large_val" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmdata2 SELECT large_val() || repeat('a', 4000)" +== 028 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata2" +== 029 +-- truncate_limit: 100 +INSERT INTO cmdata1 SELECT large_val() || repeat('a', 4000) +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=DML +FUNCTION: name="large_val" function="large_val" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmdata1 SELECT large_val() || repeat('a', 4000)" +== 030 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata1" +== 031 +-- truncate_limit: 100 +SELECT SUBSTR(f1, 200, 5) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT substr(f1, 200, 5) FROM cmdata1" +== 032 +-- truncate_limit: 100 +SELECT SUBSTR(f1, 200, 5) FROM cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT substr(f1, 200, 5) FROM cmdata2" +== 033 +-- truncate_limit: 100 +DROP TABLE cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cmdata2" +== 034 +-- truncate_limit: 100 +--test column type update varlena/non-varlena +CREATE TABLE cmdata2 (f1 int) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmdata2 (f1 int)" +== 035 +-- truncate_limit: 100 +ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar" +== 036 +-- truncate_limit: 100 +ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::integer +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE int USING f1::int" +== 037 +-- truncate_limit: 100 +--changing column storage should not impact the compression method +--but the data should not be compressed +ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmdata2 ALTER COLUMN f1 TYPE varchar" +== 038 +-- truncate_limit: 100 +ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION pglz +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION pglz" +== 039 +-- truncate_limit: 100 +ALTER TABLE cmdata2 ALTER COLUMN f1 SET STORAGE plain +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmdata2 ALTER COLUMN f1 SET STORAGE plain" +== 040 +-- truncate_limit: 100 +INSERT INTO cmdata2 VALUES (repeat('123456789', 800)) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmdata2 VALUES (repeat('123456789', 800))" +== 041 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata2" +== 042 +-- truncate_limit: 100 +-- test compression with materialized view +CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1 +-- +TABLE: name="compressmv" schema="" table="compressmv" ctx=DDL +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW compressmv(x) AS SELECT * FROM cmdata1" +== 043 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata1" +== 044 +-- truncate_limit: 100 +SELECT pg_column_compression(x) FROM compressmv +-- +TABLE: name="compressmv" schema="" table="compressmv" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(x) FROM compressmv" +== 045 +-- truncate_limit: 100 +-- test compression with partition +CREATE TABLE cmpart(f1 text COMPRESSION lz4) PARTITION BY HASH(f1) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmpart (f1 text COMPRESSION lz4) PARTITION BY HASH (f1)" +== 046 +-- truncate_limit: 100 +CREATE TABLE cmpart1 PARTITION OF cmpart FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="cmpart1" schema="" table="cmpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmpart1 PARTITION OF cmpart FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 047 +-- truncate_limit: 100 +CREATE TABLE cmpart2(f1 text COMPRESSION pglz) +-- +TABLE: name="cmpart2" schema="" table="cmpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmpart2 (f1 text COMPRESSION pglz)" +== 048 +-- truncate_limit: 100 +ALTER TABLE cmpart ATTACH PARTITION cmpart2 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmpart ATTACH PARTITION cmpart2 FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 049 +-- truncate_limit: 100 +INSERT INTO cmpart VALUES (repeat('123456789', 1004)) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmpart VALUES (repeat('123456789', 1004))" +== 050 +-- truncate_limit: 100 +INSERT INTO cmpart VALUES (repeat('123456789', 4004)) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmpart VALUES (repeat('123456789', 4004))" +== 051 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmpart1 +-- +TABLE: name="cmpart1" schema="" table="cmpart1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmpart1" +== 052 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmpart2 +-- +TABLE: name="cmpart2" schema="" table="cmpart2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmpart2" +== 053 +-- truncate_limit: 100 +-- test compression with inheritance +CREATE TABLE cminh() INHERITS(cmdata, cmdata1) +-- +TABLE: name="cminh" schema="" table="cminh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cminh () INHERITS (cmdata, cmdata1)" +== 054 +-- truncate_limit: 100 +-- error +CREATE TABLE cminh(f1 TEXT COMPRESSION lz4) INHERITS(cmdata) +-- +TABLE: name="cminh" schema="" table="cminh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cminh (f1 text COMPRESSION lz4) INHERITS (cmdata)" +== 055 +-- truncate_limit: 100 +-- error +CREATE TABLE cmdata3(f1 text) +-- +TABLE: name="cmdata3" schema="" table="cmdata3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmdata3 (f1 text)" +== 056 +-- truncate_limit: 100 +CREATE TABLE cminh() INHERITS (cmdata, cmdata3) +-- +TABLE: name="cminh" schema="" table="cminh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cminh () INHERITS (cmdata, cmdata3)" +== 057 +-- truncate_limit: 100 +-- test default_toast_compression GUC +SET default_toast_compression = '' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_toast_compression TO ''" +== 058 +-- truncate_limit: 100 +SET default_toast_compression = 'I do not exist compression' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_toast_compression TO \"I do not exist compression\"" +== 059 +-- truncate_limit: 100 +SET default_toast_compression = 'lz4' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_toast_compression TO lz4" +== 060 +-- truncate_limit: 100 +SET default_toast_compression = 'pglz' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_toast_compression TO pglz" +== 061 +-- truncate_limit: 100 +-- test alter compression method +ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION lz4 +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmdata ALTER COLUMN f1 SET COMPRESSION lz4" +== 062 +-- truncate_limit: 100 +INSERT INTO cmdata VALUES (repeat('123456789', 4004)) +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmdata VALUES (repeat('123456789', 4004))" +== 063 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata" +== 064 +-- truncate_limit: 100 +ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION default +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmdata2 ALTER COLUMN f1 SET COMPRESSION DEFAULT" +== 065 +-- truncate_limit: 100 +-- test alter compression method for materialized views +ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4 +-- +TABLE: name="compressmv" schema="" table="compressmv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER MATERIALIZED VIEW compressmv ALTER COLUMN x SET COMPRESSION lz4" +== 066 +-- truncate_limit: 100 +-- test alter compression method for partitioned tables +ALTER TABLE cmpart1 ALTER COLUMN f1 SET COMPRESSION pglz +-- +TABLE: name="cmpart1" schema="" table="cmpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmpart1 ALTER COLUMN f1 SET COMPRESSION pglz" +== 067 +-- truncate_limit: 100 +ALTER TABLE cmpart2 ALTER COLUMN f1 SET COMPRESSION lz4 +-- +TABLE: name="cmpart2" schema="" table="cmpart2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cmpart2 ALTER COLUMN f1 SET COMPRESSION lz4" +== 068 +-- truncate_limit: 100 +-- new data should be compressed with the current compression method +INSERT INTO cmpart VALUES (repeat('123456789', 1004)) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmpart VALUES (repeat('123456789', 1004))" +== 069 +-- truncate_limit: 100 +INSERT INTO cmpart VALUES (repeat('123456789', 4004)) +-- +TABLE: name="cmpart" schema="" table="cmpart" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmpart VALUES (repeat('123456789', 4004))" +== 070 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmpart1 +-- +TABLE: name="cmpart1" schema="" table="cmpart1" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmpart1" +== 071 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmpart2 +-- +TABLE: name="cmpart2" schema="" table="cmpart2" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmpart2" +== 072 +-- truncate_limit: 100 +-- VACUUM FULL does not recompress +SELECT pg_column_compression(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata" +== 073 +-- truncate_limit: 100 +VACUUM FULL cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) cmdata" +== 074 +-- truncate_limit: 100 +SELECT pg_column_compression(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="pg_column_compression" function="pg_column_compression" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_compression(f1) FROM cmdata" +== 075 +-- truncate_limit: 100 +-- test expression index +DROP TABLE cmdata2 +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cmdata2" +== 076 +-- truncate_limit: 100 +CREATE TABLE cmdata2 (f1 TEXT COMPRESSION pglz, f2 TEXT COMPRESSION lz4) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cmdata2 (f1 text COMPRESSION pglz, f2 text COMPRESSION lz4)" +== 077 +-- truncate_limit: 100 +CREATE UNIQUE INDEX idx1 ON cmdata2 ((f1 || f2)) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX idx1 ON cmdata2 USING btree ((f1 || f2))" +== 078 +-- truncate_limit: 100 +INSERT INTO cmdata2 VALUES((SELECT array_agg(fipshash(g::TEXT))::TEXT FROM +generate_series(1, 50) g), VERSION()) +-- +TABLE: name="cmdata2" schema="" table="cmdata2" ctx=DML +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="version" function="version" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cmdata2 VALUES ((SELECT ... FROM generate_series(1, 50) g), version())" +== 079 +-- truncate_limit: 100 +-- check data is ok +SELECT length(f1) FROM cmdata +-- +TABLE: name="cmdata" schema="" table="cmdata" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(f1) FROM cmdata" +== 080 +-- truncate_limit: 100 +SELECT length(f1) FROM cmdata1 +-- +TABLE: name="cmdata1" schema="" table="cmdata1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(f1) FROM cmdata1" +== 081 +-- truncate_limit: 100 +SELECT length(f1) FROM cmmove1 +-- +TABLE: name="cmmove1" schema="" table="cmmove1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(f1) FROM cmmove1" +== 082 +-- truncate_limit: 100 +SELECT length(f1) FROM cmmove2 +-- +TABLE: name="cmmove2" schema="" table="cmmove2" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(f1) FROM cmmove2" +== 083 +-- truncate_limit: 100 +SELECT length(f1) FROM cmmove3 +-- +TABLE: name="cmmove3" schema="" table="cmmove3" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(f1) FROM cmmove3" +== 084 +-- truncate_limit: 100 +CREATE TABLE badcompresstbl (a text COMPRESSION I_Do_Not_Exist_Compression) +-- +TABLE: name="badcompresstbl" schema="" table="badcompresstbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE badcompresstbl (a text COMPRESSION i_do_not_exist_compression)" +== 085 +-- truncate_limit: 100 +-- fails +CREATE TABLE badcompresstbl (a text) +-- +TABLE: name="badcompresstbl" schema="" table="badcompresstbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE badcompresstbl (a text)" +== 086 +-- truncate_limit: 100 +ALTER TABLE badcompresstbl ALTER a SET COMPRESSION I_Do_Not_Exist_Compression +-- +TABLE: name="badcompresstbl" schema="" table="badcompresstbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE badcompresstbl ALTER COLUMN a SET COMPRESSION i_do_not_exist_compression" +== 087 +-- truncate_limit: 100 +-- fails +DROP TABLE badcompresstbl +-- +TABLE: name="badcompresstbl" schema="" table="badcompresstbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE badcompresstbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/constraints.metadata.json b/parser/testdata/summary_truncate/postgres_regress/constraints.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/constraints.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/constraints.test b/parser/testdata/summary_truncate/postgres_regress/constraints.test new file mode 100644 index 0000000..4c2034b --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/constraints.test @@ -0,0 +1,2521 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CONSTRAINTS +-- Constraints can be specified with: +-- - DEFAULT clause +-- - CHECK clauses +-- - PRIMARY KEY clauses +-- - UNIQUE clauses +-- - EXCLUDE clauses +|-- + +-- directory paths are passed to us in environment variables + +|-- +-- DEFAULT syntax +|-- + +CREATE TABLE DEFAULT_TBL (i int DEFAULT 100, + x text DEFAULT 'vadim', f float8 DEFAULT 123.456) +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_tbl (i int DEFAULT 100, x text DEFAULT 'vadim', f float8 DEFAULT 123.456)" +== 002 +-- truncate_limit: 100 +INSERT INTO DEFAULT_TBL VALUES (1, 'thomas', 57.0613) +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO default_tbl VALUES (1, 'thomas', 57.0613)" +== 003 +-- truncate_limit: 100 +INSERT INTO DEFAULT_TBL VALUES (1, 'bruce') +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO default_tbl VALUES (1, 'bruce')" +== 004 +-- truncate_limit: 100 +INSERT INTO DEFAULT_TBL (i, f) VALUES (2, 987.654) +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO default_tbl (i, f) VALUES (2, 987.654)" +== 005 +-- truncate_limit: 100 +INSERT INTO DEFAULT_TBL (x) VALUES ('marc') +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO default_tbl (x) VALUES ('marc')" +== 006 +-- truncate_limit: 100 +INSERT INTO DEFAULT_TBL VALUES (3, null, 1.0) +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO default_tbl VALUES (3, NULL, 1.0)" +== 007 +-- truncate_limit: 100 +SELECT * FROM DEFAULT_TBL +-- +TABLE: name="default_tbl" schema="" table="default_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM default_tbl" +== 008 +-- truncate_limit: 100 +CREATE SEQUENCE DEFAULT_SEQ +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE default_seq" +== 009 +-- truncate_limit: 100 +CREATE TABLE DEFAULTEXPR_TBL (i1 int DEFAULT 100 + (200-199) * 2, + i2 int DEFAULT nextval('default_seq')) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defaultexpr_tbl (i1 int DEFAULT 100 + ((200 - 199) * 2), i2 int DEFAULT nextval('def..." +== 010 +-- truncate_limit: 100 +INSERT INTO DEFAULTEXPR_TBL VALUES (-1, -2) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defaultexpr_tbl VALUES (-1, -2)" +== 011 +-- truncate_limit: 100 +INSERT INTO DEFAULTEXPR_TBL (i1) VALUES (-3) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defaultexpr_tbl (i1) VALUES (-3)" +== 012 +-- truncate_limit: 100 +INSERT INTO DEFAULTEXPR_TBL (i2) VALUES (-4) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defaultexpr_tbl (i2) VALUES (-4)" +== 013 +-- truncate_limit: 100 +INSERT INTO DEFAULTEXPR_TBL (i2) VALUES (NULL) +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defaultexpr_tbl (i2) VALUES (NULL)" +== 014 +-- truncate_limit: 100 +SELECT * FROM DEFAULTEXPR_TBL +-- +TABLE: name="defaultexpr_tbl" schema="" table="defaultexpr_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM defaultexpr_tbl" +== 015 +-- truncate_limit: 100 +-- syntax errors +-- test for extraneous comma +CREATE TABLE error_tbl (i int DEFAULT (100, )) +-- +ERROR: syntax error at or near ")" +CURSORPOS: 92 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 016 +-- truncate_limit: 100 +-- this will fail because gram.y uses b_expr not a_expr for defaults, +-- to avoid a shift/reduce conflict that arises from NOT NULL being +-- part of the column definition syntax: +CREATE TABLE error_tbl (b1 bool DEFAULT 1 IN (1, 2)) +-- +ERROR: syntax error at or near "IN" +CURSORPOS: 225 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 017 +-- truncate_limit: 100 +-- this should work, however: +CREATE TABLE error_tbl (b1 bool DEFAULT (1 IN (1, 2))) +-- +TABLE: name="error_tbl" schema="" table="error_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE error_tbl (b1 bool DEFAULT (1 IN (1, 2)))" +== 018 +-- truncate_limit: 100 +DROP TABLE error_tbl +-- +TABLE: name="error_tbl" schema="" table="error_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE error_tbl" +== 019 +-- truncate_limit: 100 +|-- +-- CHECK syntax +|-- + +CREATE TABLE CHECK_TBL (x int, + CONSTRAINT CHECK_CON CHECK (x > 3)) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE check_tbl (x int, CONSTRAINT check_con CHECK (x > 3))" +== 020 +-- truncate_limit: 100 +INSERT INTO CHECK_TBL VALUES (5) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check_tbl VALUES (5)" +== 021 +-- truncate_limit: 100 +INSERT INTO CHECK_TBL VALUES (4) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check_tbl VALUES (4)" +== 022 +-- truncate_limit: 100 +INSERT INTO CHECK_TBL VALUES (3) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check_tbl VALUES (3)" +== 023 +-- truncate_limit: 100 +INSERT INTO CHECK_TBL VALUES (2) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check_tbl VALUES (2)" +== 024 +-- truncate_limit: 100 +INSERT INTO CHECK_TBL VALUES (6) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check_tbl VALUES (6)" +== 025 +-- truncate_limit: 100 +INSERT INTO CHECK_TBL VALUES (1) +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check_tbl VALUES (1)" +== 026 +-- truncate_limit: 100 +SELECT * FROM CHECK_TBL +-- +TABLE: name="check_tbl" schema="" table="check_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_tbl" +== 027 +-- truncate_limit: 100 +CREATE SEQUENCE CHECK_SEQ +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE check_seq" +== 028 +-- truncate_limit: 100 +CREATE TABLE CHECK2_TBL (x int, y text, z int, + CONSTRAINT SEQUENCE_CON + CHECK (x > 3 and y <> 'check failed' and z < 8)) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE check2_tbl (x int, y text, z int, CONSTRAINT sequence_con CHECK (x > 3 AND y <> 'che..." +== 029 +-- truncate_limit: 100 +INSERT INTO CHECK2_TBL VALUES (4, 'check ok', -2) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check2_tbl VALUES (4, 'check ok', -2)" +== 030 +-- truncate_limit: 100 +INSERT INTO CHECK2_TBL VALUES (1, 'x check failed', -2) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check2_tbl VALUES (1, 'x check failed', -2)" +== 031 +-- truncate_limit: 100 +INSERT INTO CHECK2_TBL VALUES (5, 'z check failed', 10) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check2_tbl VALUES (5, 'z check failed', 10)" +== 032 +-- truncate_limit: 100 +INSERT INTO CHECK2_TBL VALUES (0, 'check failed', -2) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check2_tbl VALUES (0, 'check failed', -2)" +== 033 +-- truncate_limit: 100 +INSERT INTO CHECK2_TBL VALUES (6, 'check failed', 11) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check2_tbl VALUES (6, 'check failed', 11)" +== 034 +-- truncate_limit: 100 +INSERT INTO CHECK2_TBL VALUES (7, 'check ok', 7) +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO check2_tbl VALUES (7, 'check ok', 7)" +== 035 +-- truncate_limit: 100 +SELECT * from CHECK2_TBL +-- +TABLE: name="check2_tbl" schema="" table="check2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check2_tbl" +== 036 +-- truncate_limit: 100 +|-- +-- Check constraints on INSERT +|-- + +CREATE SEQUENCE INSERT_SEQ +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE insert_seq" +== 037 +-- truncate_limit: 100 +CREATE TABLE INSERT_TBL (x INT DEFAULT nextval('insert_seq'), + y TEXT DEFAULT '-NULL-', + z INT DEFAULT -1 * currval('insert_seq'), + CONSTRAINT INSERT_TBL_CON CHECK (x >= 3 AND y <> 'check failed' AND x < 8), + CHECK (x + z = 0)) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE insert_tbl (x int DEFAULT nextval('insert_seq'), y text DEFAULT '-NULL-', z int DEFA..." +== 038 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(x,z) VALUES (2, -2) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (x, z) VALUES (2, -2)" +== 039 +-- truncate_limit: 100 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_tbl" +== 040 +-- truncate_limit: 100 +SELECT 'one' AS one, nextval('insert_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'one' AS one, nextval('insert_seq')" +== 041 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y) VALUES ('Y') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y) VALUES ('Y')" +== 042 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y) VALUES ('Y') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y) VALUES ('Y')" +== 043 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(x,z) VALUES (1, -2) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (x, z) VALUES (1, -2)" +== 044 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(z,x) VALUES (-7, 7) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (z, x) VALUES (-7, 7)" +== 045 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL VALUES (5, 'check failed', -5) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl VALUES (5, 'check failed', -5)" +== 046 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL VALUES (7, '!check failed', -7) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl VALUES (7, '!check failed', -7)" +== 047 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y) VALUES ('-!NULL-')" +== 048 +-- truncate_limit: 100 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_tbl" +== 049 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y,z) VALUES ('check failed', 4) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y, z) VALUES ('check failed', 4)" +== 050 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(x,y) VALUES (5, 'check failed') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (x, y) VALUES (5, 'check failed')" +== 051 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(x,y) VALUES (5, '!check failed') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (x, y) VALUES (5, '!check failed')" +== 052 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y) VALUES ('-!NULL-') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y) VALUES ('-!NULL-')" +== 053 +-- truncate_limit: 100 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_tbl" +== 054 +-- truncate_limit: 100 +SELECT 'seven' AS one, nextval('insert_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'seven' AS one, nextval('insert_seq')" +== 055 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y) VALUES ('Y') +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y) VALUES ('Y')" +== 056 +-- truncate_limit: 100 +SELECT 'eight' AS one, currval('insert_seq') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'eight' AS one, currval('insert_seq')" +== 057 +-- truncate_limit: 100 +-- According to SQL, it is OK to insert a record that gives rise to NULL +-- constraint-condition results. Postgres used to reject this, but it +-- was wrong: +INSERT INTO INSERT_TBL VALUES (null, null, null) +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl VALUES (NULL, NULL, NULL)" +== 058 +-- truncate_limit: 100 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_tbl" +== 059 +-- truncate_limit: 100 +|-- +-- Check constraints on system columns +|-- + +CREATE TABLE SYS_COL_CHECK_TBL (city text, state text, is_capital bool, + altitude int, + CHECK (NOT (is_capital AND tableoid::regclass::text = 'sys_col_check_tbl'))) +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sys_col_check_tbl (city text, state text, is_capital bool, altitude int, CHECK (NOT ..." +== 060 +-- truncate_limit: 100 +INSERT INTO SYS_COL_CHECK_TBL VALUES ('Seattle', 'Washington', false, 100) +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sys_col_check_tbl VALUES ('Seattle', 'Washington', false, 100)" +== 061 +-- truncate_limit: 100 +INSERT INTO SYS_COL_CHECK_TBL VALUES ('Olympia', 'Washington', true, 100) +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sys_col_check_tbl VALUES ('Olympia', 'Washington', true, 100)" +== 062 +-- truncate_limit: 100 +SELECT *, tableoid::regclass::text FROM SYS_COL_CHECK_TBL +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT *, tableoid::regclass::text FROM sys_col_check_tbl" +== 063 +-- truncate_limit: 100 +DROP TABLE SYS_COL_CHECK_TBL +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sys_col_check_tbl" +== 064 +-- truncate_limit: 100 +|-- +-- Check constraints on system columns other then TableOid should return error +|-- +CREATE TABLE SYS_COL_CHECK_TBL (city text, state text, is_capital bool, + altitude int, + CHECK (NOT (is_capital AND ctid::text = 'sys_col_check_tbl'))) +-- +TABLE: name="sys_col_check_tbl" schema="" table="sys_col_check_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sys_col_check_tbl (city text, state text, is_capital bool, altitude int, CHECK (NOT ..." +== 065 +-- truncate_limit: 100 +|-- +-- Check inheritance of defaults and constraints +|-- + +CREATE TABLE INSERT_CHILD (cx INT default 42, + cy INT CHECK (cy > x)) + INHERITS (INSERT_TBL) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE insert_child (cx int DEFAULT 42, cy int CHECK (cy > x)) INHERITS (insert_tbl)" +== 066 +-- truncate_limit: 100 +INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,11) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_child (x, z, cy) VALUES (7, -7, 11)" +== 067 +-- truncate_limit: 100 +INSERT INTO INSERT_CHILD(x,z,cy) VALUES (7,-7,6) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_child (x, z, cy) VALUES (7, -7, 6)" +== 068 +-- truncate_limit: 100 +INSERT INTO INSERT_CHILD(x,z,cy) VALUES (6,-7,7) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_child (x, z, cy) VALUES (6, -7, 7)" +== 069 +-- truncate_limit: 100 +INSERT INTO INSERT_CHILD(x,y,z,cy) VALUES (6,'check failed',-6,7) +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_child (x, y, z, cy) VALUES (6, 'check failed', -6, 7)" +== 070 +-- truncate_limit: 100 +SELECT * FROM INSERT_CHILD +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_child" +== 071 +-- truncate_limit: 100 +DROP TABLE INSERT_CHILD +-- +TABLE: name="insert_child" schema="" table="insert_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE insert_child" +== 072 +-- truncate_limit: 100 +|-- +-- Check NO INHERIT type of constraints and inheritance +|-- + +CREATE TABLE ATACC1 (TEST INT + CHECK (TEST > 0) NO INHERIT) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int CHECK (test > 0) NO INHERIT)" +== 073 +-- truncate_limit: 100 +CREATE TABLE ATACC2 (TEST2 INT) INHERITS (ATACC1) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc2 (test2 int) INHERITS (atacc1)" +== 074 +-- truncate_limit: 100 +-- check constraint is not there on child +INSERT INTO ATACC2 (TEST) VALUES (-3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc2 (test) VALUES (-3)" +== 075 +-- truncate_limit: 100 +-- check constraint is there on parent +INSERT INTO ATACC1 (TEST) VALUES (-3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (-3)" +== 076 +-- truncate_limit: 100 +DROP TABLE ATACC1 CASCADE +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1 CASCADE" +== 077 +-- truncate_limit: 100 +CREATE TABLE ATACC1 (TEST INT, TEST2 INT + CHECK (TEST > 0), CHECK (TEST2 > 10) NO INHERIT) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc1 (test int, test2 int CHECK (test > 0), CHECK (test2 > 10) NO INHERIT)" +== 078 +-- truncate_limit: 100 +CREATE TABLE ATACC2 () INHERITS (ATACC1) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atacc2 () INHERITS (atacc1)" +== 079 +-- truncate_limit: 100 +-- check constraint is there on child +INSERT INTO ATACC2 (TEST) VALUES (-3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc2 (test) VALUES (-3)" +== 080 +-- truncate_limit: 100 +-- check constraint is there on parent +INSERT INTO ATACC1 (TEST) VALUES (-3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test) VALUES (-3)" +== 081 +-- truncate_limit: 100 +-- check constraint is not there on child +INSERT INTO ATACC2 (TEST2) VALUES (3) +-- +TABLE: name="atacc2" schema="" table="atacc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc2 (test2) VALUES (3)" +== 082 +-- truncate_limit: 100 +-- check constraint is there on parent +INSERT INTO ATACC1 (TEST2) VALUES (3) +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atacc1 (test2) VALUES (3)" +== 083 +-- truncate_limit: 100 +DROP TABLE ATACC1 CASCADE +-- +TABLE: name="atacc1" schema="" table="atacc1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE atacc1 CASCADE" +== 084 +-- truncate_limit: 100 +|-- +-- Check constraints on INSERT INTO +|-- + +DELETE FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM insert_tbl" +== 085 +-- truncate_limit: 100 +ALTER SEQUENCE INSERT_SEQ RESTART WITH 4 +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE insert_seq RESTART 4" +== 086 +-- truncate_limit: 100 +CREATE TEMP TABLE tmp (xd INT, yd TEXT, zd INT) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tmp (xd int, yd text, zd int)" +== 087 +-- truncate_limit: 100 +INSERT INTO tmp VALUES (null, 'Y', null) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tmp VALUES (NULL, 'Y', NULL)" +== 088 +-- truncate_limit: 100 +INSERT INTO tmp VALUES (5, '!check failed', null) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tmp VALUES (5, '!check failed', NULL)" +== 089 +-- truncate_limit: 100 +INSERT INTO tmp VALUES (null, 'try again', null) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tmp VALUES (NULL, 'try again', NULL)" +== 090 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y) select yd from tmp +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +TABLE: name="tmp" schema="" table="tmp" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y) SELECT yd FROM tmp" +== 091 +-- truncate_limit: 100 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_tbl" +== 092 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL SELECT * FROM tmp WHERE yd = 'try again' +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +TABLE: name="tmp" schema="" table="tmp" ctx=Select +FILTER: schema="" table="" column="yd" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl SELECT * FROM tmp WHERE yd = 'try again'" +== 093 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y,z) SELECT yd, -7 FROM tmp WHERE yd = 'try again' +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +TABLE: name="tmp" schema="" table="tmp" ctx=Select +FILTER: schema="" table="" column="yd" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y, z) SELECT yd, -7 FROM tmp WHERE yd = 'try again'" +== 094 +-- truncate_limit: 100 +INSERT INTO INSERT_TBL(y,z) SELECT yd, -8 FROM tmp WHERE yd = 'try again' +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +TABLE: name="tmp" schema="" table="tmp" ctx=Select +FILTER: schema="" table="" column="yd" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insert_tbl (y, z) SELECT yd, -8 FROM tmp WHERE yd = 'try again'" +== 095 +-- truncate_limit: 100 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_tbl" +== 096 +-- truncate_limit: 100 +DROP TABLE tmp +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tmp" +== 097 +-- truncate_limit: 100 +|-- +-- Check constraints on UPDATE +|-- + +UPDATE INSERT_TBL SET x = NULL WHERE x = 5 +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE insert_tbl SET x = NULL WHERE x = 5" +== 098 +-- truncate_limit: 100 +UPDATE INSERT_TBL SET x = 6 WHERE x = 6 +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE insert_tbl SET x = 6 WHERE x = 6" +== 099 +-- truncate_limit: 100 +UPDATE INSERT_TBL SET x = -z, z = -x +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE insert_tbl SET x = - z, z = - x" +== 100 +-- truncate_limit: 100 +UPDATE INSERT_TBL SET x = z, z = x +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE insert_tbl SET x = z, z = x" +== 101 +-- truncate_limit: 100 +SELECT * FROM INSERT_TBL +-- +TABLE: name="insert_tbl" schema="" table="insert_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_tbl" +== 102 +-- truncate_limit: 100 +-- DROP TABLE INSERT_TBL; + +|-- +-- Check constraints on COPY FROM +|-- + +CREATE TABLE COPY_TBL (x INT, y TEXT, z INT, + CONSTRAINT COPY_CON + CHECK (x > 3 AND y <> 'check failed' AND x < 7 )) +-- +TABLE: name="copy_tbl" schema="" table="copy_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE copy_tbl (x int, y text, z int, CONSTRAINT copy_con CHECK (x > 3 AND y <> 'check fai..." +== 103 +-- truncate_limit: 100 +COPY COPY_TBL FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 104 +-- truncate_limit: 100 +SELECT * FROM COPY_TBL +-- +TABLE: name="copy_tbl" schema="" table="copy_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM copy_tbl" +== 105 +-- truncate_limit: 100 +COPY COPY_TBL FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 106 +-- truncate_limit: 100 +SELECT * FROM COPY_TBL +-- +TABLE: name="copy_tbl" schema="" table="copy_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM copy_tbl" +== 107 +-- truncate_limit: 100 +|-- +-- Primary keys +|-- + +CREATE TABLE PRIMARY_TBL (i int PRIMARY KEY, t text) +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE primary_tbl (i int PRIMARY KEY, t text)" +== 108 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (1, 'one') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (1, 'one')" +== 109 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (2, 'two') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (2, 'two')" +== 110 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (1, 'three') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (1, 'three')" +== 111 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (4, 'three') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (4, 'three')" +== 112 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (5, 'one') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (5, 'one')" +== 113 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL (t) VALUES ('six') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl (t) VALUES ('six')" +== 114 +-- truncate_limit: 100 +SELECT * FROM PRIMARY_TBL +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM primary_tbl" +== 115 +-- truncate_limit: 100 +DROP TABLE PRIMARY_TBL +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE primary_tbl" +== 116 +-- truncate_limit: 100 +CREATE TABLE PRIMARY_TBL (i int, t text, + PRIMARY KEY(i,t)) +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE primary_tbl (i int, t text, PRIMARY KEY (i, t))" +== 117 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (1, 'one') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (1, 'one')" +== 118 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (2, 'two') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (2, 'two')" +== 119 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (1, 'three') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (1, 'three')" +== 120 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (4, 'three') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (4, 'three')" +== 121 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL VALUES (5, 'one') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl VALUES (5, 'one')" +== 122 +-- truncate_limit: 100 +INSERT INTO PRIMARY_TBL (t) VALUES ('six') +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO primary_tbl (t) VALUES ('six')" +== 123 +-- truncate_limit: 100 +SELECT * FROM PRIMARY_TBL +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM primary_tbl" +== 124 +-- truncate_limit: 100 +DROP TABLE PRIMARY_TBL +-- +TABLE: name="primary_tbl" schema="" table="primary_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE primary_tbl" +== 125 +-- truncate_limit: 100 +|-- +-- Unique keys +|-- + +CREATE TABLE UNIQUE_TBL (i int UNIQUE, t text) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unique_tbl (i int UNIQUE, t text)" +== 126 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'one')" +== 127 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (2, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (2, 'two')" +== 128 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (1, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'three')" +== 129 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (4, 'four') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (4, 'four')" +== 130 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (5, 'one')" +== 131 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL (t) VALUES ('six') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('six')" +== 132 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL (t) VALUES ('seven') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('seven')" +== 133 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (5, 'five-upsert-insert') ON CONFLICT (i) DO UPDATE SET t = 'five-upsert-update' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (5, 'five-upsert-insert') ON CONFLICT (i) DO UPDATE SET ... = ..." +== 134 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (6, 'six-upsert-insert') ON CONFLICT (i) DO UPDATE SET t = 'six-upsert-update' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (6, 'six-upsert-insert') ON CONFLICT (i) DO UPDATE SET ... = ..." +== 135 +-- truncate_limit: 100 +-- should fail +INSERT INTO UNIQUE_TBL VALUES (1, 'a'), (2, 'b'), (2, 'b') ON CONFLICT (i) DO UPDATE SET t = 'fails' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'a'), (2, 'b'), (2, 'b') ON CONFLICT (i) DO UPDATE SET t = 'fails'" +== 136 +-- truncate_limit: 100 +SELECT * FROM UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 137 +-- truncate_limit: 100 +DROP TABLE UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unique_tbl" +== 138 +-- truncate_limit: 100 +CREATE TABLE UNIQUE_TBL (i int UNIQUE NULLS NOT DISTINCT, t text) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unique_tbl (i int UNIQUE NULLS NOT DISTINCT, t text)" +== 139 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'one')" +== 140 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (2, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (2, 'two')" +== 141 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (1, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'three')" +== 142 +-- truncate_limit: 100 +-- fail +INSERT INTO UNIQUE_TBL VALUES (4, 'four') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (4, 'four')" +== 143 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (5, 'one')" +== 144 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL (t) VALUES ('six') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('six')" +== 145 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL (t) VALUES ('seven') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('seven')" +== 146 +-- truncate_limit: 100 +-- fail +INSERT INTO UNIQUE_TBL (t) VALUES ('eight') ON CONFLICT DO NOTHING +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('eight') ON CONFLICT DO NOTHING" +== 147 +-- truncate_limit: 100 +-- no-op + +SELECT * FROM UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 148 +-- truncate_limit: 100 +DROP TABLE UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unique_tbl" +== 149 +-- truncate_limit: 100 +CREATE TABLE UNIQUE_TBL (i int, t text, + UNIQUE(i,t)) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unique_tbl (i int, t text, UNIQUE (i, t))" +== 150 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'one')" +== 151 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (2, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (2, 'two')" +== 152 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (1, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'three')" +== 153 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'one')" +== 154 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (5, 'one')" +== 155 +-- truncate_limit: 100 +INSERT INTO UNIQUE_TBL (t) VALUES ('six') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('six')" +== 156 +-- truncate_limit: 100 +SELECT * FROM UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 157 +-- truncate_limit: 100 +DROP TABLE UNIQUE_TBL +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unique_tbl" +== 158 +-- truncate_limit: 100 +|-- +-- Deferrable unique constraints +|-- + +CREATE TABLE unique_tbl (i int UNIQUE DEFERRABLE, t text) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unique_tbl (i int UNIQUE DEFERRABLE, t text)" +== 159 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (0, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (0, 'one')" +== 160 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (1, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'two')" +== 161 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (2, 'tree') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (2, 'tree')" +== 162 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (3, 'four') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (3, 'four')" +== 163 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (4, 'five') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (4, 'five')" +== 164 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 165 +-- truncate_limit: 100 +-- default is immediate so this should fail right away +UPDATE unique_tbl SET i = 1 WHERE i = 0 +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE unique_tbl SET i = 1 WHERE i = 0" +== 166 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 167 +-- truncate_limit: 100 +-- check is done at end of statement, so this should succeed +UPDATE unique_tbl SET i = i+1 +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE unique_tbl SET i = i + 1" +== 168 +-- truncate_limit: 100 +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 169 +-- truncate_limit: 100 +-- explicitly defer the constraint +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 170 +-- truncate_limit: 100 +SET CONSTRAINTS unique_tbl_i_key DEFERRED +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS unique_tbl_i_key DEFERRED" +== 171 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (3, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (3, 'three')" +== 172 +-- truncate_limit: 100 +DELETE FROM unique_tbl WHERE t = 'tree' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM unique_tbl WHERE t = 'tree'" +== 173 +-- truncate_limit: 100 +-- makes constraint valid again + +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 174 +-- truncate_limit: 100 +-- should succeed + +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 175 +-- truncate_limit: 100 +-- try adding an initially deferred constraint +ALTER TABLE unique_tbl DROP CONSTRAINT unique_tbl_i_key +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE unique_tbl DROP CONSTRAINT unique_tbl_i_key" +== 176 +-- truncate_limit: 100 +ALTER TABLE unique_tbl ADD CONSTRAINT unique_tbl_i_key + UNIQUE (i) DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE unique_tbl ADD CONSTRAINT unique_tbl_i_key UNIQUE (i) DEFERRABLE INITIALLY DEFERRED" +== 177 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 178 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (1, 'five') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'five')" +== 179 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (5, 'one')" +== 180 +-- truncate_limit: 100 +UPDATE unique_tbl SET i = 4 WHERE i = 2 +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE unique_tbl SET i = 4 WHERE i = 2" +== 181 +-- truncate_limit: 100 +UPDATE unique_tbl SET i = 2 WHERE i = 4 AND t = 'four' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE unique_tbl SET i = 2 WHERE i = 4 AND t = 'four'" +== 182 +-- truncate_limit: 100 +DELETE FROM unique_tbl WHERE i = 1 AND t = 'one' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM unique_tbl WHERE i = 1 AND t = 'one'" +== 183 +-- truncate_limit: 100 +DELETE FROM unique_tbl WHERE i = 5 AND t = 'five' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM unique_tbl WHERE i = 5 AND t = 'five'" +== 184 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 185 +-- truncate_limit: 100 +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 186 +-- truncate_limit: 100 +-- should fail at commit-time +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 187 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (3, 'Three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (3, 'Three')" +== 188 +-- truncate_limit: 100 +-- should succeed for now +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 189 +-- truncate_limit: 100 +-- should fail + +-- make constraint check immediate +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 190 +-- truncate_limit: 100 +SET CONSTRAINTS ALL IMMEDIATE +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS ALL IMMEDIATE" +== 191 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (3, 'Three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (3, 'Three')" +== 192 +-- truncate_limit: 100 +-- should fail + +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 193 +-- truncate_limit: 100 +-- forced check when SET CONSTRAINTS is called +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 194 +-- truncate_limit: 100 +SET CONSTRAINTS ALL DEFERRED +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS ALL DEFERRED" +== 195 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (3, 'Three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (3, 'Three')" +== 196 +-- truncate_limit: 100 +-- should succeed for now + +SET CONSTRAINTS ALL IMMEDIATE +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS ALL IMMEDIATE" +== 197 +-- truncate_limit: 100 +-- should fail + +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 198 +-- truncate_limit: 100 +-- test deferrable UNIQUE with a partitioned table +CREATE TABLE parted_uniq_tbl (i int UNIQUE DEFERRABLE) partition by range (i) +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_uniq_tbl (i int UNIQUE DEFERRABLE) PARTITION BY RANGE (i)" +== 199 +-- truncate_limit: 100 +CREATE TABLE parted_uniq_tbl_1 PARTITION OF parted_uniq_tbl FOR VALUES FROM (0) TO (10) +-- +TABLE: name="parted_uniq_tbl_1" schema="" table="parted_uniq_tbl_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_uniq_tbl_1 PARTITION OF parted_uniq_tbl FOR VALUES FROM (0) TO (10)" +== 200 +-- truncate_limit: 100 +CREATE TABLE parted_uniq_tbl_2 PARTITION OF parted_uniq_tbl FOR VALUES FROM (20) TO (30) +-- +TABLE: name="parted_uniq_tbl_2" schema="" table="parted_uniq_tbl_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_uniq_tbl_2 PARTITION OF parted_uniq_tbl FOR VALUES FROM (20) TO (30)" +== 201 +-- truncate_limit: 100 +SELECT conname, conrelid::regclass FROM pg_constraint + WHERE conname LIKE 'parted_uniq%' ORDER BY conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conname LIKE 'parted_uniq%' ORDER BY conname" +== 202 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 203 +-- truncate_limit: 100 +INSERT INTO parted_uniq_tbl VALUES (1) +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_uniq_tbl VALUES (1)" +== 204 +-- truncate_limit: 100 +SAVEPOINT f +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT f" +== 205 +-- truncate_limit: 100 +INSERT INTO parted_uniq_tbl VALUES (1) +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_uniq_tbl VALUES (1)" +== 206 +-- truncate_limit: 100 +-- unique violation +ROLLBACK TO f +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT f" +== 207 +-- truncate_limit: 100 +SET CONSTRAINTS parted_uniq_tbl_i_key DEFERRED +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS parted_uniq_tbl_i_key DEFERRED" +== 208 +-- truncate_limit: 100 +INSERT INTO parted_uniq_tbl VALUES (1) +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_uniq_tbl VALUES (1)" +== 209 +-- truncate_limit: 100 +-- OK now, fail at commit +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 210 +-- truncate_limit: 100 +DROP TABLE parted_uniq_tbl +-- +TABLE: name="parted_uniq_tbl" schema="" table="parted_uniq_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_uniq_tbl" +== 211 +-- truncate_limit: 100 +-- test naming a constraint in a partition when a conflict exists +CREATE TABLE parted_fk_naming ( + id bigint NOT NULL default 1, + id_abc bigint, + CONSTRAINT dummy_constr FOREIGN KEY (id_abc) + REFERENCES parted_fk_naming (id), + PRIMARY KEY (id) +) +PARTITION BY LIST (id) +-- +TABLE: name="parted_fk_naming" schema="" table="parted_fk_naming" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_fk_naming (id bigint NOT NULL DEFAULT 1, id_abc bigint, CONSTRAINT dummy_cons..." +== 212 +-- truncate_limit: 100 +CREATE TABLE parted_fk_naming_1 ( + id bigint NOT NULL default 1, + id_abc bigint, + PRIMARY KEY (id), + CONSTRAINT dummy_constr CHECK (true) +) +-- +TABLE: name="parted_fk_naming_1" schema="" table="parted_fk_naming_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_fk_naming_1 (id bigint NOT NULL DEFAULT 1, id_abc bigint, PRIMARY KEY (id), C..." +== 213 +-- truncate_limit: 100 +ALTER TABLE parted_fk_naming ATTACH PARTITION parted_fk_naming_1 FOR VALUES IN ('1') +-- +TABLE: name="parted_fk_naming" schema="" table="parted_fk_naming" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_fk_naming ATTACH PARTITION parted_fk_naming_1 FOR VALUES IN ('1')" +== 214 +-- truncate_limit: 100 +SELECT conname FROM pg_constraint WHERE conrelid = 'parted_fk_naming_1'::regclass AND contype = 'f' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +FILTER: schema="" table="" column="contype" +STMT: SelectStmt +TRUNCATED: "SELECT conname FROM pg_constraint WHERE conrelid = 'parted_fk_naming_1'::regclass AND contype = 'f'" +== 215 +-- truncate_limit: 100 +DROP TABLE parted_fk_naming +-- +TABLE: name="parted_fk_naming" schema="" table="parted_fk_naming" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_fk_naming" +== 216 +-- truncate_limit: 100 +|-- +-- Test various ways to create primary keys on partitions, linked to unique +-- indexes (without constraints) on the partitioned table. Ideally these should +-- fail, but we don't dare change released behavior, so instead cope with it at +-- DETACH time. +CREATE TEMP TABLE t (a integer, b integer) PARTITION BY HASH (a, b) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t (a int, b int) PARTITION BY HASH (a, b)" +== 217 +-- truncate_limit: 100 +CREATE TEMP TABLE tp (a integer, b integer, PRIMARY KEY (a, b), UNIQUE (b, a)) +-- +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tp (a int, b int, PRIMARY KEY (a, b), UNIQUE (b, a))" +== 218 +-- truncate_limit: 100 +ALTER TABLE t ATTACH PARTITION tp FOR VALUES WITH (MODULUS 1, REMAINDER 0) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ATTACH PARTITION tp FOR VALUES WITH (MODULUS 1, REMAINDER 0)" +== 219 +-- truncate_limit: 100 +CREATE UNIQUE INDEX t_a_idx ON t (a, b) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX t_a_idx ON t USING btree (a, b)" +== 220 +-- truncate_limit: 100 +CREATE UNIQUE INDEX t_b_idx ON t (b, a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX t_b_idx ON t USING btree (b, a)" +== 221 +-- truncate_limit: 100 +ALTER INDEX t_a_idx ATTACH PARTITION tp_pkey +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX t_a_idx ATTACH PARTITION tp_pkey" +== 222 +-- truncate_limit: 100 +ALTER INDEX t_b_idx ATTACH PARTITION tp_b_a_key +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX t_b_idx ATTACH PARTITION tp_b_a_key" +== 223 +-- truncate_limit: 100 +SELECT conname, conparentid, conislocal, coninhcount + FROM pg_constraint WHERE conname IN ('tp_pkey', 'tp_b_a_key') + ORDER BY conname DESC +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conname IN ('tp_pkey', 'tp_b_a_key') ORDER BY conname DESC" +== 224 +-- truncate_limit: 100 +ALTER TABLE t DETACH PARTITION tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t DETACH PARTITION tp" +== 225 +-- truncate_limit: 100 +DROP TABLE t, tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t, tp" +== 226 +-- truncate_limit: 100 +CREATE TEMP TABLE t (a integer) PARTITION BY LIST (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t (a int) PARTITION BY LIST (a)" +== 227 +-- truncate_limit: 100 +CREATE TEMP TABLE tp (a integer PRIMARY KEY) +-- +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tp (a int PRIMARY KEY)" +== 228 +-- truncate_limit: 100 +CREATE UNIQUE INDEX t_a_idx ON t (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX t_a_idx ON t USING btree (a)" +== 229 +-- truncate_limit: 100 +ALTER TABLE t ATTACH PARTITION tp FOR VALUES IN (1) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ATTACH PARTITION tp FOR VALUES IN (1)" +== 230 +-- truncate_limit: 100 +ALTER TABLE t DETACH PARTITION tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t DETACH PARTITION tp" +== 231 +-- truncate_limit: 100 +DROP TABLE t, tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t, tp" +== 232 +-- truncate_limit: 100 +CREATE TEMP TABLE t (a integer) PARTITION BY LIST (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t (a int) PARTITION BY LIST (a)" +== 233 +-- truncate_limit: 100 +CREATE TEMP TABLE tp (a integer PRIMARY KEY) +-- +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tp (a int PRIMARY KEY)" +== 234 +-- truncate_limit: 100 +CREATE UNIQUE INDEX t_a_idx ON ONLY t (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX t_a_idx ON ONLY t USING btree (a)" +== 235 +-- truncate_limit: 100 +ALTER TABLE t ATTACH PARTITION tp FOR VALUES IN (1) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ATTACH PARTITION tp FOR VALUES IN (1)" +== 236 +-- truncate_limit: 100 +ALTER TABLE t DETACH PARTITION tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t DETACH PARTITION tp" +== 237 +-- truncate_limit: 100 +DROP TABLE t, tp +-- +TABLE: name="t" schema="" table="t" ctx=DDL +TABLE: name="tp" schema="" table="tp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t, tp" +== 238 +-- truncate_limit: 100 +CREATE TABLE regress_constr_partitioned (a integer) PARTITION BY LIST (a) +-- +TABLE: name="regress_constr_partitioned" schema="" table="regress_constr_partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE regress_constr_partitioned (a int) PARTITION BY LIST (a)" +== 239 +-- truncate_limit: 100 +CREATE TABLE regress_constr_partition1 PARTITION OF regress_constr_partitioned FOR VALUES IN (1) +-- +TABLE: name="regress_constr_partition1" schema="" table="regress_constr_partition1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE regress_constr_partition1 PARTITION OF regress_constr_partitioned FOR VALUES IN (1)" +== 240 +-- truncate_limit: 100 +ALTER TABLE regress_constr_partition1 ADD PRIMARY KEY (a) +-- +TABLE: name="regress_constr_partition1" schema="" table="regress_constr_partition1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE regress_constr_partition1 ADD PRIMARY KEY (a)" +== 241 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON regress_constr_partitioned (a) +-- +TABLE: name="regress_constr_partitioned" schema="" table="regress_constr_partitioned" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON regress_constr_partitioned USING btree (a)" +== 242 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 243 +-- truncate_limit: 100 +ALTER TABLE regress_constr_partitioned DETACH PARTITION regress_constr_partition1 +-- +TABLE: name="regress_constr_partitioned" schema="" table="regress_constr_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE regress_constr_partitioned DETACH PARTITION regress_constr_partition1" +== 244 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 245 +-- truncate_limit: 100 +-- Leave this one in funny state for pg_upgrade testing + +-- test a HOT update that invalidates the conflicting tuple. +-- the trigger should still fire and catch the violation + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 246 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (3, 'Three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (3, 'Three')" +== 247 +-- truncate_limit: 100 +-- should succeed for now +UPDATE unique_tbl SET t = 'THREE' WHERE i = 3 AND t = 'Three' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE unique_tbl SET t = 'THREE' WHERE i = 3 AND t = 'Three'" +== 248 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 249 +-- truncate_limit: 100 +-- should fail + +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 250 +-- truncate_limit: 100 +-- test a HOT update that modifies the newly inserted tuple, +-- but should succeed because we then remove the other conflicting tuple. + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 251 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES(3, 'tree') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (3, 'tree')" +== 252 +-- truncate_limit: 100 +-- should succeed for now +UPDATE unique_tbl SET t = 'threex' WHERE t = 'tree' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE unique_tbl SET t = 'threex' WHERE t = 'tree'" +== 253 +-- truncate_limit: 100 +DELETE FROM unique_tbl WHERE t = 'three' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM unique_tbl WHERE t = 'three'" +== 254 +-- truncate_limit: 100 +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 255 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 256 +-- truncate_limit: 100 +SELECT * FROM unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unique_tbl" +== 257 +-- truncate_limit: 100 +DROP TABLE unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unique_tbl" +== 258 +-- truncate_limit: 100 +|-- +-- EXCLUDE constraints +|-- + +CREATE TABLE circles ( + c1 CIRCLE, + c2 TEXT, + EXCLUDE USING gist + (c1 WITH &&, (c2::circle) WITH &&) + WHERE (circle_center(c1) <> '(0,0)') +) +-- +TABLE: name="circles" schema="" table="circles" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE circles (c1 circle, c2 text, EXCLUDE USING gist (c1 WITH &&, (c2::circle) WITH &&) W..." +== 259 +-- truncate_limit: 100 +-- these should succeed because they don't match the index predicate +INSERT INTO circles VALUES('<(0,0), 5>', '<(0,0), 5>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circles VALUES ('<(0,0), 5>', '<(0,0), 5>')" +== 260 +-- truncate_limit: 100 +INSERT INTO circles VALUES('<(0,0), 5>', '<(0,0), 4>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circles VALUES ('<(0,0), 5>', '<(0,0), 4>')" +== 261 +-- truncate_limit: 100 +-- succeed +INSERT INTO circles VALUES('<(10,10), 10>', '<(0,0), 5>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circles VALUES ('<(10,10), 10>', '<(0,0), 5>')" +== 262 +-- truncate_limit: 100 +-- fail, overlaps +INSERT INTO circles VALUES('<(20,20), 10>', '<(0,0), 4>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circles VALUES ('<(20,20), 10>', '<(0,0), 4>')" +== 263 +-- truncate_limit: 100 +-- succeed, because violation is ignored +INSERT INTO circles VALUES('<(20,20), 10>', '<(0,0), 4>') + ON CONFLICT ON CONSTRAINT circles_c1_c2_excl DO NOTHING +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circles VALUES (...) ON CONFLICT ON CONSTRAINT circles_c1_c2_excl DO NOTHING" +== 264 +-- truncate_limit: 100 +-- fail, because DO UPDATE variant requires unique index +INSERT INTO circles VALUES('<(20,20), 10>', '<(0,0), 4>') + ON CONFLICT ON CONSTRAINT circles_c1_c2_excl DO UPDATE SET c2 = EXCLUDED.c2 +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circles VALUES (...) ON CONFLICT ON CONSTRAINT circles_c1_c2_excl DO UPDATE SET ... =..." +== 265 +-- truncate_limit: 100 +-- succeed because c1 doesn't overlap +INSERT INTO circles VALUES('<(20,20), 1>', '<(0,0), 5>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circles VALUES ('<(20,20), 1>', '<(0,0), 5>')" +== 266 +-- truncate_limit: 100 +-- succeed because c2 doesn't overlap +INSERT INTO circles VALUES('<(20,20), 10>', '<(10,10), 5>') +-- +TABLE: name="circles" schema="" table="circles" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO circles VALUES ('<(20,20), 10>', '<(10,10), 5>')" +== 267 +-- truncate_limit: 100 +-- should fail on existing data without the WHERE clause +ALTER TABLE circles ADD EXCLUDE USING gist + (c1 WITH &&, (c2::circle) WITH &&) +-- +TABLE: name="circles" schema="" table="circles" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE circles ADD EXCLUDE USING gist (c1 WITH &&, (c2::circle) WITH &&)" +== 268 +-- truncate_limit: 100 +-- try reindexing an existing constraint +REINDEX INDEX circles_c1_c2_excl +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX circles_c1_c2_excl" +== 269 +-- truncate_limit: 100 +DROP TABLE circles +-- +TABLE: name="circles" schema="" table="circles" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE circles" +== 270 +-- truncate_limit: 100 +-- Check deferred exclusion constraint + +CREATE TABLE deferred_excl ( + f1 int, + f2 int, + CONSTRAINT deferred_excl_con EXCLUDE (f1 WITH =) INITIALLY DEFERRED +) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE deferred_excl (f1 int, f2 int, CONSTRAINT deferred_excl_con EXCLUDE (f1 WITH =) DEFE..." +== 271 +-- truncate_limit: 100 +INSERT INTO deferred_excl VALUES(1) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO deferred_excl VALUES (1)" +== 272 +-- truncate_limit: 100 +INSERT INTO deferred_excl VALUES(2) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO deferred_excl VALUES (2)" +== 273 +-- truncate_limit: 100 +INSERT INTO deferred_excl VALUES(1) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO deferred_excl VALUES (1)" +== 274 +-- truncate_limit: 100 +-- fail +INSERT INTO deferred_excl VALUES(1) ON CONFLICT ON CONSTRAINT deferred_excl_con DO NOTHING +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO deferred_excl VALUES (1) ON CONFLICT ON CONSTRAINT deferred_excl_con DO NOTHING" +== 275 +-- truncate_limit: 100 +-- fail +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 276 +-- truncate_limit: 100 +INSERT INTO deferred_excl VALUES(2) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO deferred_excl VALUES (2)" +== 277 +-- truncate_limit: 100 +-- no fail here +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 278 +-- truncate_limit: 100 +-- should fail here +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 279 +-- truncate_limit: 100 +INSERT INTO deferred_excl VALUES(3) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO deferred_excl VALUES (3)" +== 280 +-- truncate_limit: 100 +INSERT INTO deferred_excl VALUES(3) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO deferred_excl VALUES (3)" +== 281 +-- truncate_limit: 100 +-- no fail here +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 282 +-- truncate_limit: 100 +-- should fail here + +-- bug #13148: deferred constraint versus HOT update +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 283 +-- truncate_limit: 100 +INSERT INTO deferred_excl VALUES(2, 1) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO deferred_excl VALUES (2, 1)" +== 284 +-- truncate_limit: 100 +-- no fail here +DELETE FROM deferred_excl WHERE f1 = 2 AND f2 IS NULL +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM deferred_excl WHERE f1 = 2 AND f2 IS NULL" +== 285 +-- truncate_limit: 100 +-- remove old row +UPDATE deferred_excl SET f2 = 2 WHERE f1 = 2 +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE deferred_excl SET f2 = 2 WHERE f1 = 2" +== 286 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 287 +-- truncate_limit: 100 +-- should not fail + +SELECT * FROM deferred_excl +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM deferred_excl" +== 288 +-- truncate_limit: 100 +ALTER TABLE deferred_excl DROP CONSTRAINT deferred_excl_con +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE deferred_excl DROP CONSTRAINT deferred_excl_con" +== 289 +-- truncate_limit: 100 +-- This should fail, but worth testing because of HOT updates +UPDATE deferred_excl SET f1 = 3 +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE deferred_excl SET f1 = 3" +== 290 +-- truncate_limit: 100 +ALTER TABLE deferred_excl ADD EXCLUDE (f1 WITH =) +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE deferred_excl ADD EXCLUDE (f1 WITH =)" +== 291 +-- truncate_limit: 100 +DROP TABLE deferred_excl +-- +TABLE: name="deferred_excl" schema="" table="deferred_excl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE deferred_excl" +== 292 +-- truncate_limit: 100 +-- Comments +-- Setup a low-level role to enforce non-superuser checks. +CREATE ROLE regress_constraint_comments +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_constraint_comments" +== 293 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_constraint_comments +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_constraint_comments" +== 294 +-- truncate_limit: 100 +CREATE TABLE constraint_comments_tbl (a int CONSTRAINT the_constraint CHECK (a > 0)) +-- +TABLE: name="constraint_comments_tbl" schema="" table="constraint_comments_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE constraint_comments_tbl (a int CONSTRAINT the_constraint CHECK (a > 0))" +== 295 +-- truncate_limit: 100 +CREATE DOMAIN constraint_comments_dom AS int CONSTRAINT the_constraint CHECK (value > 0) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN constraint_comments_dom AS int CONSTRAINT the_constraint CHECK (value > 0)" +== 296 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS 'yes, the comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS 'yes, the comment'" +== 297 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS 'yes, another comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS 'yes, another comment'" +== 298 +-- truncate_limit: 100 +-- no such constraint +COMMENT ON CONSTRAINT no_constraint ON constraint_comments_tbl IS 'yes, the comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT no_constraint ON constraint_comments_tbl IS 'yes, the comment'" +== 299 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT no_constraint ON DOMAIN constraint_comments_dom IS 'yes, another comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT no_constraint ON DOMAIN constraint_comments_dom IS 'yes, another comment'" +== 300 +-- truncate_limit: 100 +-- no such table/domain +COMMENT ON CONSTRAINT the_constraint ON no_comments_tbl IS 'bad comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT the_constraint ON no_comments_tbl IS 'bad comment'" +== 301 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT the_constraint ON DOMAIN no_comments_dom IS 'another bad comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT the_constraint ON DOMAIN no_comments_dom IS 'another bad comment'" +== 302 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS NULL" +== 303 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS NULL" +== 304 +-- truncate_limit: 100 +-- unauthorized user +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 305 +-- truncate_limit: 100 +CREATE ROLE regress_constraint_comments_noaccess +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_constraint_comments_noaccess" +== 306 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_constraint_comments_noaccess +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_constraint_comments_noaccess" +== 307 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS 'no, the comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT the_constraint ON constraint_comments_tbl IS 'no, the comment'" +== 308 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS 'no, another comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT the_constraint ON DOMAIN constraint_comments_dom IS 'no, another comment'" +== 309 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 310 +-- truncate_limit: 100 +DROP TABLE constraint_comments_tbl +-- +TABLE: name="constraint_comments_tbl" schema="" table="constraint_comments_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE constraint_comments_tbl" +== 311 +-- truncate_limit: 100 +DROP DOMAIN constraint_comments_dom +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN constraint_comments_dom" +== 312 +-- truncate_limit: 100 +DROP ROLE regress_constraint_comments +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_constraint_comments" +== 313 +-- truncate_limit: 100 +DROP ROLE regress_constraint_comments_noaccess +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_constraint_comments_noaccess" +== 314 +-- truncate_limit: 100 +-- Leave some constraints for the pg_upgrade test to pick up +CREATE DOMAIN constraint_comments_dom AS int +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN constraint_comments_dom AS int" +== 315 +-- truncate_limit: 100 +ALTER DOMAIN constraint_comments_dom ADD CONSTRAINT inv_ck CHECK (value > 0) NOT VALID +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN constraint_comments_dom ADD CONSTRAINT inv_ck CHECK (value > 0) NOT VALID" +== 316 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT inv_ck ON DOMAIN constraint_comments_dom IS 'comment on invalid constraint' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT inv_ck ON DOMAIN constraint_comments_dom IS 'comment on invalid constraint'" +== 317 +-- truncate_limit: 100 +-- Create a table that exercises pg_upgrade +CREATE TABLE regress_notnull1 (a integer) +-- +TABLE: name="regress_notnull1" schema="" table="regress_notnull1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE regress_notnull1 (a int)" +== 318 +-- truncate_limit: 100 +CREATE TABLE regress_notnull2 () INHERITS (regress_notnull1) +-- +TABLE: name="regress_notnull2" schema="" table="regress_notnull2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE regress_notnull2 () INHERITS (regress_notnull1)" +== 319 +-- truncate_limit: 100 +ALTER TABLE ONLY regress_notnull2 ALTER COLUMN a SET NOT NULL +-- +TABLE: name="regress_notnull2" schema="" table="regress_notnull2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY regress_notnull2 ALTER COLUMN a SET NOT NULL" diff --git a/parser/testdata/summary_truncate/postgres_regress/conversion.metadata.json b/parser/testdata/summary_truncate/postgres_regress/conversion.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/conversion.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/conversion.test b/parser/testdata/summary_truncate/postgres_regress/conversion.test new file mode 100644 index 0000000..1e1a5fd --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/conversion.test @@ -0,0 +1,805 @@ +== 001 +-- truncate_limit: 100 +|-- +-- create user defined conversion +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION test_enc_setup() RETURNS void + AS :'regresslib', 'test_enc_setup' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 171 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +SELECT FROM test_enc_setup() +-- +FUNCTION: name="test_enc_setup" function="test_enc_setup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM test_enc_setup()" +== 003 +-- truncate_limit: 100 +CREATE FUNCTION test_enc_conversion(bytea, name, name, bool, validlen OUT int, result OUT bytea) + AS :'regresslib', 'test_enc_conversion' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 105 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +CREATE USER regress_conversion_user WITH NOCREATEDB NOCREATEROLE +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_conversion_user WITH NOCREATEDB NOCREATEROLE" +== 005 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_conversion_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_conversion_user" +== 006 +-- truncate_limit: 100 +CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 007 +-- truncate_limit: 100 +|-- +-- cannot make same name conversion in same schema +|-- +CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 008 +-- truncate_limit: 100 +|-- +-- create default conversion with qualified name +|-- +CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 009 +-- truncate_limit: 100 +|-- +-- cannot make default conversion with same schema/for_encoding/to_encoding +|-- +CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 010 +-- truncate_limit: 100 +-- test comments +COMMENT ON CONVERSION myconv_bad IS 'foo' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONVERSION myconv_bad IS 'foo'" +== 011 +-- truncate_limit: 100 +COMMENT ON CONVERSION myconv IS 'bar' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONVERSION myconv IS 'bar'" +== 012 +-- truncate_limit: 100 +COMMENT ON CONVERSION myconv IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONVERSION myconv IS NULL" +== 013 +-- truncate_limit: 100 +|-- +-- drop user defined conversion +|-- +DROP CONVERSION myconv +-- +STMT: DropStmt +TRUNCATED: "DROP CONVERSION myconv" +== 014 +-- truncate_limit: 100 +DROP CONVERSION mydef +-- +STMT: DropStmt +TRUNCATED: "DROP CONVERSION mydef" +== 015 +-- truncate_limit: 100 +|-- +-- Note: the built-in conversions are exercised in opr_sanity.sql, +-- so there's no need to do that here. +|-- +|-- +-- return to the superuser +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 016 +-- truncate_limit: 100 +DROP USER regress_conversion_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_conversion_user" +== 017 +-- truncate_limit: 100 +|-- +-- Test built-in conversion functions. +|-- + +-- Helper function to test a conversion. Uses the test_enc_conversion function +-- that was created in the create_function_0 test. +create or replace function test_conv( + input IN bytea, + src_encoding IN text, + dst_encoding IN text, + + result OUT bytea, + errorat OUT bytea, + error OUT text) +language plpgsql as +$$ +declare + validlen int; +begin + -- First try to perform the conversion with noError = false. If that errors out, + -- capture the error message, and try again with noError = true. The second call + -- should succeed and return the position of the error, return that too. + begin + select * into validlen, result from test_enc_conversion(input, src_encoding, dst_encoding, false); + errorat = NULL; + error := NULL; + exception when others then + error := sqlerrm; + select * into validlen, result from test_enc_conversion(input, src_encoding, dst_encoding, true); + errorat = substr(input, validlen + 1); + end; + return; +end; +$$ +-- +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION test_conv(IN input bytea, IN src_encoding text, IN dst_encoding text, ..." +== 018 +-- truncate_limit: 100 +|-- +-- UTF-8 +|-- +-- The description column must be unique. +CREATE TABLE utf8_verification_inputs (inbytes bytea, description text PRIMARY KEY) +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE utf8_verification_inputs (inbytes bytea, description text PRIMARY KEY)" +== 019 +-- truncate_limit: 100 +insert into utf8_verification_inputs values + ('\x66006f', 'NUL byte'), + ('\xaf', 'bare continuation'), + ('\xc5', 'missing second byte in 2-byte char'), + ('\xc080', 'smallest 2-byte overlong'), + ('\xc1bf', 'largest 2-byte overlong'), + ('\xc280', 'next 2-byte after overlongs'), + ('\xdfbf', 'largest 2-byte'), + ('\xe9af', 'missing third byte in 3-byte char'), + ('\xe08080', 'smallest 3-byte overlong'), + ('\xe09fbf', 'largest 3-byte overlong'), + ('\xe0a080', 'next 3-byte after overlong'), + ('\xed9fbf', 'last before surrogates'), + ('\xeda080', 'smallest surrogate'), + ('\xedbfbf', 'largest surrogate'), + ('\xee8080', 'next after surrogates'), + ('\xefbfbf', 'largest 3-byte'), + ('\xf1afbf', 'missing fourth byte in 4-byte char'), + ('\xf0808080', 'smallest 4-byte overlong'), + ('\xf08fbfbf', 'largest 4-byte overlong'), + ('\xf0908080', 'next 4-byte after overlong'), + ('\xf48fbfbf', 'largest 4-byte'), + ('\xf4908080', 'smallest too large'), + ('\xfa9a9a8a8a', '5-byte') +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO utf8_verification_inputs VALUES (...)" +== 020 +-- truncate_limit: 100 +-- Test UTF-8 verification slow path +select description, (test_conv(inbytes, 'utf8', 'utf8')).* from utf8_verification_inputs +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, (test_conv(inbytes, 'utf8', 'utf8')).* FROM utf8_verification_inputs" +== 021 +-- truncate_limit: 100 +-- Test UTF-8 verification with ASCII padding appended to provide +-- coverage for algorithms that work on multiple bytes at a time. +-- The error message for a sequence starting with a 4-byte lead +-- will contain all 4 bytes if they are present, so various +-- expressions below add 3 ASCII bytes to the end to ensure +-- consistent error messages. +-- The number 64 below needs to be at least the value of STRIDE_LENGTH in wchar.c. + +-- Test multibyte verification in fast path +with test_bytes as ( + select + inbytes, + description, + (test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from utf8_verification_inputs +), test_padded as ( + select + description, + (test_conv(inbytes || repeat('.', 64)::bytea, 'utf8', 'utf8')).error + from test_bytes +) +select + description, + b.error as orig_error, + p.error as error_after_padding +from test_padded p +join test_bytes b +using (description) +where p.error is distinct from b.error +order by description +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +ALIAS: "b"="test_bytes" +ALIAS: "p"="test_padded" +CTE: "test_bytes" +CTE: "test_padded" +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="p" column="error" +FILTER: schema="" table="b" column="error" +STMT: SelectStmt +TRUNCATED: "WITH test_bytes AS (...), test_padded AS (...) SELECT ... FROM test_padded p JOIN test_bytes b US..." +== 022 +-- truncate_limit: 100 +-- Test ASCII verification in fast path where incomplete +-- UTF-8 sequences fall at the end of the preceding chunk. +with test_bytes as ( + select + inbytes, + description, + (test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from utf8_verification_inputs +), test_padded as ( + select + description, + (test_conv(repeat('.', 64 - length(inbytes))::bytea || inbytes || repeat('.', 64)::bytea, 'utf8', 'utf8')).error + from test_bytes +) +select + description, + b.error as orig_error, + p.error as error_after_padding +from test_padded p +join test_bytes b +using (description) +where p.error is distinct from b.error +order by description +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +ALIAS: "b"="test_bytes" +ALIAS: "p"="test_padded" +CTE: "test_bytes" +CTE: "test_padded" +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="p" column="error" +FILTER: schema="" table="b" column="error" +STMT: SelectStmt +TRUNCATED: "WITH test_bytes AS (...), test_padded AS (...) SELECT ... FROM test_padded p JOIN test_bytes b US..." +== 023 +-- truncate_limit: 100 +-- Test cases where UTF-8 sequences within short text +-- come after the fast path returns. +with test_bytes as ( + select + inbytes, + description, + (test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from utf8_verification_inputs +), test_padded as ( + select + description, + (test_conv(repeat('.', 64)::bytea || inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from test_bytes +) +select + description, + b.error as orig_error, + p.error as error_after_padding +from test_padded p +join test_bytes b +using (description) +where p.error is distinct from b.error +order by description +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +ALIAS: "b"="test_bytes" +ALIAS: "p"="test_padded" +CTE: "test_bytes" +CTE: "test_padded" +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="p" column="error" +FILTER: schema="" table="b" column="error" +STMT: SelectStmt +TRUNCATED: "WITH test_bytes AS (...), test_padded AS (...) SELECT ... FROM test_padded p JOIN test_bytes b US..." +== 024 +-- truncate_limit: 100 +-- Test cases where incomplete UTF-8 sequences fall at the +-- end of the part checked by the fast path. +with test_bytes as ( + select + inbytes, + description, + (test_conv(inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from utf8_verification_inputs +), test_padded as ( + select + description, + (test_conv(repeat('.', 64 - length(inbytes))::bytea || inbytes || repeat('.', 3)::bytea, 'utf8', 'utf8')).error + from test_bytes +) +select + description, + b.error as orig_error, + p.error as error_after_padding +from test_padded p +join test_bytes b +using (description) +where p.error is distinct from b.error +order by description +-- +TABLE: name="utf8_verification_inputs" schema="" table="utf8_verification_inputs" ctx=Select +ALIAS: "b"="test_bytes" +ALIAS: "p"="test_padded" +CTE: "test_bytes" +CTE: "test_padded" +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="p" column="error" +FILTER: schema="" table="b" column="error" +STMT: SelectStmt +TRUNCATED: "WITH test_bytes AS (...), test_padded AS (...) SELECT ... FROM test_padded p JOIN test_bytes b US..." +== 025 +-- truncate_limit: 100 +CREATE TABLE utf8_inputs (inbytes bytea, description text) +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE utf8_inputs (inbytes bytea, description text)" +== 026 +-- truncate_limit: 100 +insert into utf8_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\xc3a4c3b6', 'valid, extra latin chars'), + ('\xd184d0bed0be', 'valid, cyrillic'), + ('\x666f6fe8b1a1', 'valid, kanji/Chinese'), + ('\xe382abe3829a', 'valid, two chars that combine to one in EUC_JIS_2004'), + ('\xe382ab', 'only first half of combined char in EUC_JIS_2004'), + ('\xe382abe382', 'incomplete combination when converted EUC_JIS_2004'), + ('\xecbd94eb81bceba6ac', 'valid, Hangul, Korean'), + ('\x666f6fefa8aa', 'valid, needs mapping function to convert to GB18030'), + ('\x66e8b1ff6f6f', 'invalid byte sequence'), + ('\x66006f', 'invalid, NUL byte'), + ('\x666f6fe8b100', 'invalid, NUL byte'), + ('\x666f6fe8b1', 'incomplete character at end') +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO utf8_inputs VALUES (...)" +== 027 +-- truncate_limit: 100 +-- Test UTF-8 verification +select description, (test_conv(inbytes, 'utf8', 'utf8')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, (test_conv(inbytes, 'utf8', 'utf8')).* FROM utf8_inputs" +== 028 +-- truncate_limit: 100 +-- Test conversions from UTF-8 +select description, inbytes, (test_conv(inbytes, 'utf8', 'euc_jis_2004')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'utf8', 'euc_jis_2004')).* FROM utf8_inputs" +== 029 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'utf8', 'latin1')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'utf8', 'latin1')).* FROM utf8_inputs" +== 030 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'utf8', 'latin2')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'utf8', 'latin2')).* FROM utf8_inputs" +== 031 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'utf8', 'latin5')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'utf8', 'latin5')).* FROM utf8_inputs" +== 032 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'utf8', 'koi8r')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'utf8', 'koi8r')).* FROM utf8_inputs" +== 033 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'utf8', 'gb18030')).* from utf8_inputs +-- +TABLE: name="utf8_inputs" schema="" table="utf8_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'utf8', 'gb18030')).* FROM utf8_inputs" +== 034 +-- truncate_limit: 100 +|-- +-- EUC_JIS_2004 +|-- +CREATE TABLE euc_jis_2004_inputs (inbytes bytea, description text) +-- +TABLE: name="euc_jis_2004_inputs" schema="" table="euc_jis_2004_inputs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE euc_jis_2004_inputs (inbytes bytea, description text)" +== 035 +-- truncate_limit: 100 +insert into euc_jis_2004_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x666f6fbedd', 'valid'), + ('\xa5f7', 'valid, translates to two UTF-8 chars '), + ('\xbeddbe', 'incomplete char '), + ('\x666f6f00bedd', 'invalid, NUL byte'), + ('\x666f6fbe00dd', 'invalid, NUL byte'), + ('\x666f6fbedd00', 'invalid, NUL byte'), + ('\xbe04', 'invalid byte sequence') +-- +TABLE: name="euc_jis_2004_inputs" schema="" table="euc_jis_2004_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO euc_jis_2004_inputs VALUES (...)" +== 036 +-- truncate_limit: 100 +-- Test EUC_JIS_2004 verification +select description, inbytes, (test_conv(inbytes, 'euc_jis_2004', 'euc_jis_2004')).* from euc_jis_2004_inputs +-- +TABLE: name="euc_jis_2004_inputs" schema="" table="euc_jis_2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM euc_jis_2004_inputs" +== 037 +-- truncate_limit: 100 +-- Test conversions from EUC_JIS_2004 +select description, inbytes, (test_conv(inbytes, 'euc_jis_2004', 'utf8')).* from euc_jis_2004_inputs +-- +TABLE: name="euc_jis_2004_inputs" schema="" table="euc_jis_2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'euc_jis_2004', 'utf8')).* FROM euc_jis_2004_inputs" +== 038 +-- truncate_limit: 100 +|-- +-- SHIFT-JIS-2004 +|-- +CREATE TABLE shiftjis2004_inputs (inbytes bytea, description text) +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE shiftjis2004_inputs (inbytes bytea, description text)" +== 039 +-- truncate_limit: 100 +insert into shiftjis2004_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x666f6f8fdb', 'valid'), + ('\x666f6f81c0', 'valid, no translation to UTF-8'), + ('\x666f6f82f5', 'valid, translates to two UTF-8 chars '), + ('\x666f6f8fdb8f', 'incomplete char '), + ('\x666f6f820a', 'incomplete char, followed by newline '), + ('\x666f6f008fdb', 'invalid, NUL byte'), + ('\x666f6f8f00db', 'invalid, NUL byte'), + ('\x666f6f8fdb00', 'invalid, NUL byte') +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shiftjis2004_inputs VALUES (...)" +== 040 +-- truncate_limit: 100 +-- Test SHIFT-JIS-2004 verification +select description, inbytes, (test_conv(inbytes, 'shiftjis2004', 'shiftjis2004')).* from shiftjis2004_inputs +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM shiftjis2004_inputs" +== 041 +-- truncate_limit: 100 +-- Test conversions from SHIFT-JIS-2004 +select description, inbytes, (test_conv(inbytes, 'shiftjis2004', 'utf8')).* from shiftjis2004_inputs +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'shiftjis2004', 'utf8')).* FROM shiftjis2004_inputs" +== 042 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'shiftjis2004', 'euc_jis_2004')).* from shiftjis2004_inputs +-- +TABLE: name="shiftjis2004_inputs" schema="" table="shiftjis2004_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM shiftjis2004_inputs" +== 043 +-- truncate_limit: 100 +|-- +-- GB18030 +|-- +CREATE TABLE gb18030_inputs (inbytes bytea, description text) +-- +TABLE: name="gb18030_inputs" schema="" table="gb18030_inputs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gb18030_inputs (inbytes bytea, description text)" +== 044 +-- truncate_limit: 100 +insert into gb18030_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x666f6fcff3', 'valid'), + ('\x666f6f8431a530', 'valid, no translation to UTF-8'), + ('\x666f6f84309c38', 'valid, translates to UTF-8 by mapping function'), + ('\x666f6f84309c', 'incomplete char '), + ('\x666f6f84309c0a', 'incomplete char, followed by newline '), + ('\x666f6f84', 'incomplete char at end'), + ('\x666f6f84309c3800', 'invalid, NUL byte'), + ('\x666f6f84309c0038', 'invalid, NUL byte') +-- +TABLE: name="gb18030_inputs" schema="" table="gb18030_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gb18030_inputs VALUES (...)" +== 045 +-- truncate_limit: 100 +-- Test GB18030 verification. Round-trip through text so the backing of the +-- bytea values is palloc, not shared_buffers. This lets Valgrind detect +-- reads past the end. +select description, inbytes, (test_conv(inbytes::text::bytea, 'gb18030', 'gb18030')).* from gb18030_inputs +-- +TABLE: name="gb18030_inputs" schema="" table="gb18030_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gb18030_inputs" +== 046 +-- truncate_limit: 100 +-- Test conversions from GB18030 +select description, inbytes, (test_conv(inbytes, 'gb18030', 'utf8')).* from gb18030_inputs +-- +TABLE: name="gb18030_inputs" schema="" table="gb18030_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'gb18030', 'utf8')).* FROM gb18030_inputs" +== 047 +-- truncate_limit: 100 +|-- +-- ISO-8859-5 +|-- +CREATE TABLE iso8859_5_inputs (inbytes bytea, description text) +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iso8859_5_inputs (inbytes bytea, description text)" +== 048 +-- truncate_limit: 100 +insert into iso8859_5_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\xe4dede', 'valid'), + ('\x00', 'invalid, NUL byte'), + ('\xe400dede', 'invalid, NUL byte'), + ('\xe4dede00', 'invalid, NUL byte') +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iso8859_5_inputs VALUES (...)" +== 049 +-- truncate_limit: 100 +-- Test ISO-8859-5 verification +select description, inbytes, (test_conv(inbytes, 'iso8859-5', 'iso8859-5')).* from iso8859_5_inputs +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'iso8859-5', 'iso8859-5')).* FROM iso8859_5_inputs" +== 050 +-- truncate_limit: 100 +-- Test conversions from ISO-8859-5 +select description, inbytes, (test_conv(inbytes, 'iso8859-5', 'utf8')).* from iso8859_5_inputs +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'iso8859-5', 'utf8')).* FROM iso8859_5_inputs" +== 051 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'iso8859-5', 'koi8r')).* from iso8859_5_inputs +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'iso8859-5', 'koi8r')).* FROM iso8859_5_inputs" +== 052 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'iso8859_5', 'mule_internal')).* from iso8859_5_inputs +-- +TABLE: name="iso8859_5_inputs" schema="" table="iso8859_5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM iso8859_5_inputs" +== 053 +-- truncate_limit: 100 +|-- +-- Big5 +|-- +CREATE TABLE big5_inputs (inbytes bytea, description text) +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE big5_inputs (inbytes bytea, description text)" +== 054 +-- truncate_limit: 100 +insert into big5_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x666f6fb648', 'valid'), + ('\x666f6fa27f', 'valid, no translation to UTF-8'), + ('\x666f6fb60048', 'invalid, NUL byte'), + ('\x666f6fb64800', 'invalid, NUL byte') +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO big5_inputs VALUES (...)" +== 055 +-- truncate_limit: 100 +-- Test Big5 verification +select description, inbytes, (test_conv(inbytes, 'big5', 'big5')).* from big5_inputs +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'big5', 'big5')).* FROM big5_inputs" +== 056 +-- truncate_limit: 100 +-- Test conversions from Big5 +select description, inbytes, (test_conv(inbytes, 'big5', 'utf8')).* from big5_inputs +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'big5', 'utf8')).* FROM big5_inputs" +== 057 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'big5', 'mule_internal')).* from big5_inputs +-- +TABLE: name="big5_inputs" schema="" table="big5_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'big5', 'mule_internal')).* FROM big5_inputs" +== 058 +-- truncate_limit: 100 +|-- +-- MULE_INTERNAL +|-- +CREATE TABLE mic_inputs (inbytes bytea, description text) +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mic_inputs (inbytes bytea, description text)" +== 059 +-- truncate_limit: 100 +insert into mic_inputs values + ('\x666f6f', 'valid, pure ASCII'), + ('\x8bc68bcf8bcf', 'valid (in KOI8R)'), + ('\x8bc68bcf8b', 'invalid,incomplete char'), + ('\x92bedd', 'valid (in SHIFT_JIS)'), + ('\x92be', 'invalid, incomplete char)'), + ('\x666f6f95a3c1', 'valid (in Big5)'), + ('\x666f6f95a3', 'invalid, incomplete char'), + ('\x9200bedd', 'invalid, NUL byte'), + ('\x92bedd00', 'invalid, NUL byte'), + ('\x8b00c68bcf8bcf', 'invalid, NUL byte') +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mic_inputs VALUES (...)" +== 060 +-- truncate_limit: 100 +-- Test MULE_INTERNAL verification +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'mule_internal')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM mic_inputs" +== 061 +-- truncate_limit: 100 +-- Test conversions from MULE_INTERNAL +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'koi8r')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'mule_internal', 'koi8r')).* FROM mic_inputs" +== 062 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'iso8859-5')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'mule_internal', 'iso8859-5')).* FROM mic_inputs" +== 063 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'sjis')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'mule_internal', 'sjis')).* FROM mic_inputs" +== 064 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'big5')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'mule_internal', 'big5')).* FROM mic_inputs" +== 065 +-- truncate_limit: 100 +select description, inbytes, (test_conv(inbytes, 'mule_internal', 'euc_jp')).* from mic_inputs +-- +TABLE: name="mic_inputs" schema="" table="mic_inputs" ctx=Select +FUNCTION: name="test_conv" function="test_conv" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT description, inbytes, (test_conv(inbytes, 'mule_internal', 'euc_jp')).* FROM mic_inputs" diff --git a/parser/testdata/summary_truncate/postgres_regress/copy.metadata.json b/parser/testdata/summary_truncate/postgres_regress/copy.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/copy.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/copy.test b/parser/testdata/summary_truncate/postgres_regress/copy.test new file mode 100644 index 0000000..092a0f8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/copy.test @@ -0,0 +1,759 @@ +== 001 +-- truncate_limit: 100 +|-- +-- COPY +|-- + +-- directory paths are passed to us in environment variables + +--- test copying in CSV mode with various styles +--- of embedded line ending characters + +create temp table copytest ( + style text, + test text, + filler int) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE copytest (style text, test text, filler int)" +== 002 +-- truncate_limit: 100 +insert into copytest values('DOS',E'abc\r\ndef',1) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copytest VALUES ('DOS', 'abc\r\ndef', 1)" +== 003 +-- truncate_limit: 100 +insert into copytest values('Unix',E'abc\ndef',2) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copytest VALUES ('Unix', 'abc\ndef', 2)" +== 004 +-- truncate_limit: 100 +insert into copytest values('Mac',E'abc\rdef',3) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copytest VALUES ('Mac', 'abc\rdef', 3)" +== 005 +-- truncate_limit: 100 +insert into copytest values(E'esc\\ape',E'a\\r\\\r\\\n\\nb',4) +-- +TABLE: name="copytest" schema="" table="copytest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copytest VALUES (E'esc\\\\ape', E'a\\\\r\\\\\r\\\\\n\\\\nb', 4)" +== 006 +-- truncate_limit: 100 +copy copytest to :'filename' csv +-- +ERROR: syntax error at or near ":" +CURSORPOS: 18 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- truncate_limit: 100 +create temp table copytest2 (like copytest) +-- +TABLE: name="copytest2" schema="" table="copytest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE copytest2 (LIKE copytest)" +== 008 +-- truncate_limit: 100 +copy copytest2 from :'filename' csv +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- truncate_limit: 100 +select * from copytest except select * from copytest2 +-- +TABLE: name="copytest" schema="" table="copytest" ctx=Select +TABLE: name="copytest2" schema="" table="copytest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM copytest EXCEPT SELECT * FROM copytest2" +== 010 +-- truncate_limit: 100 +truncate copytest2 +-- +TABLE: name="copytest2" schema="" table="copytest2" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE copytest2" +== 011 +-- truncate_limit: 100 +--- same test but with an escape char different from quote char + +copy copytest to :'filename' csv quote '''' escape E'\\' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 83 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +-- truncate_limit: 100 +copy copytest2 from :'filename' csv quote '''' escape E'\\' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 013 +-- truncate_limit: 100 +select * from copytest except select * from copytest2 +-- +TABLE: name="copytest" schema="" table="copytest" ctx=Select +TABLE: name="copytest2" schema="" table="copytest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM copytest EXCEPT SELECT * FROM copytest2" +== 014 +-- truncate_limit: 100 +-- test header line feature + +create temp table copytest3 ( + c1 int, + "col with , comma" text, + "col with "" quote" int) +-- +TABLE: name="copytest3" schema="" table="copytest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE copytest3 (c1 int, \"col with , comma\" text, \"col with \"\" quote\" int)" +== 015 +-- truncate_limit: 100 +copy copytest3 from stdin csv header +-- +TABLE: name="copytest3" schema="" table="copytest3" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copytest3 FROM STDIN CSV HEADER" +== 016 +-- truncate_limit: 100 +copy copytest3 to stdout csv header +-- +TABLE: name="copytest3" schema="" table="copytest3" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copytest3 TO STDOUT CSV HEADER" +== 017 +-- truncate_limit: 100 +create temp table copytest4 ( + c1 int, + "colname with tab: " text) +-- +TABLE: name="copytest4" schema="" table="copytest4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE copytest4 (c1 int, \"colname with tab: \t\" text)" +== 018 +-- truncate_limit: 100 +copy copytest4 from stdin (header) +-- +TABLE: name="copytest4" schema="" table="copytest4" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copytest4 FROM STDIN WITH (HEADER)" +== 019 +-- truncate_limit: 100 +copy copytest4 to stdout (header) +-- +TABLE: name="copytest4" schema="" table="copytest4" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copytest4 TO STDOUT WITH (HEADER)" +== 020 +-- truncate_limit: 100 +-- test copy from with a partitioned table +create table parted_copytest ( + a int, + b int, + c text +) partition by list (b) +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_copytest (a int, b int, c text) PARTITION BY LIST (b)" +== 021 +-- truncate_limit: 100 +create table parted_copytest_a1 (c text, b int, a int) +-- +TABLE: name="parted_copytest_a1" schema="" table="parted_copytest_a1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_copytest_a1 (c text, b int, a int)" +== 022 +-- truncate_limit: 100 +create table parted_copytest_a2 (a int, c text, b int) +-- +TABLE: name="parted_copytest_a2" schema="" table="parted_copytest_a2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_copytest_a2 (a int, c text, b int)" +== 023 +-- truncate_limit: 100 +alter table parted_copytest attach partition parted_copytest_a1 for values in(1) +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_copytest ATTACH PARTITION parted_copytest_a1 FOR VALUES IN (1)" +== 024 +-- truncate_limit: 100 +alter table parted_copytest attach partition parted_copytest_a2 for values in(2) +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_copytest ATTACH PARTITION parted_copytest_a2 FOR VALUES IN (2)" +== 025 +-- truncate_limit: 100 +-- We must insert enough rows to trigger multi-inserts. These are only +-- enabled adaptively when there are few enough partition changes. +insert into parted_copytest select x,1,'One' from generate_series(1,1000) x +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_copytest SELECT x, 1, 'One' FROM generate_series(1, 1000) x" +== 026 +-- truncate_limit: 100 +insert into parted_copytest select x,2,'Two' from generate_series(1001,1010) x +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_copytest SELECT x, 2, 'Two' FROM generate_series(1001, 1010) x" +== 027 +-- truncate_limit: 100 +insert into parted_copytest select x,1,'One' from generate_series(1011,1020) x +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_copytest SELECT x, 1, 'One' FROM generate_series(1011, 1020) x" +== 028 +-- truncate_limit: 100 +copy (select * from parted_copytest order by a) to :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 52 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 029 +-- truncate_limit: 100 +truncate parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_copytest" +== 030 +-- truncate_limit: 100 +copy parted_copytest from :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 27 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 031 +-- truncate_limit: 100 +-- Ensure COPY FREEZE errors for partitioned tables. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 032 +-- truncate_limit: 100 +truncate parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_copytest" +== 033 +-- truncate_limit: 100 +copy parted_copytest from :'filename' (freeze) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 27 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 034 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 035 +-- truncate_limit: 100 +select tableoid::regclass,count(*),sum(a) from parted_copytest +group by tableoid order by tableoid::regclass::name +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM parted_copytest GROUP BY tableoid ORDER BY tableoid::regclass::name" +== 036 +-- truncate_limit: 100 +truncate parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_copytest" +== 037 +-- truncate_limit: 100 +-- create before insert row trigger on parted_copytest_a2 +create function part_ins_func() returns trigger language plpgsql as $$ +begin + return new; +end; +$$ +-- +FUNCTION: name="part_ins_func" function="part_ins_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION part_ins_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n return new;\nend;\n$$" +== 038 +-- truncate_limit: 100 +create trigger part_ins_trig + before insert on parted_copytest_a2 + for each row + execute procedure part_ins_func() +-- +TABLE: name="parted_copytest_a2" schema="" table="parted_copytest_a2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER part_ins_trig BEFORE INSERT ON parted_copytest_a2 FOR EACH ROW EXECUTE FUNCTION pa..." +== 039 +-- truncate_limit: 100 +copy parted_copytest from :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 27 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 040 +-- truncate_limit: 100 +select tableoid::regclass,count(*),sum(a) from parted_copytest +group by tableoid order by tableoid::regclass::name +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM parted_copytest GROUP BY tableoid ORDER BY tableoid::regclass::name" +== 041 +-- truncate_limit: 100 +truncate table parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_copytest" +== 042 +-- truncate_limit: 100 +create index on parted_copytest (b) +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON parted_copytest USING btree (b)" +== 043 +-- truncate_limit: 100 +drop trigger part_ins_trig on parted_copytest_a2 +-- +TABLE: name="parted_copytest_a2" schema="" table="parted_copytest_a2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER part_ins_trig ON parted_copytest_a2" +== 044 +-- truncate_limit: 100 +copy parted_copytest from stdin +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY parted_copytest FROM STDIN" +== 045 +-- truncate_limit: 100 +-- Ensure index entries were properly added during the copy. +select * from parted_copytest where b = 1 +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted_copytest WHERE b = 1" +== 046 +-- truncate_limit: 100 +select * from parted_copytest where b = 2 +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted_copytest WHERE b = 2" +== 047 +-- truncate_limit: 100 +drop table parted_copytest +-- +TABLE: name="parted_copytest" schema="" table="parted_copytest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_copytest" +== 048 +-- truncate_limit: 100 +|-- +-- Progress reporting for COPY +|-- +create table tab_progress_reporting ( + name text, + age int4, + location point, + salary int4, + manager name +) +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tab_progress_reporting (name text, age int4, location point, salary int4, manager name)" +== 049 +-- truncate_limit: 100 +-- Add a trigger to catch and print the contents of the catalog view +-- pg_stat_progress_copy during data insertion. This allows to test +-- the validation of some progress reports for COPY FROM where the trigger +-- would fire. +create function notice_after_tab_progress_reporting() returns trigger AS +$$ +declare report record; +begin + -- The fields ignored here are the ones that may not remain + -- consistent across multiple runs. The sizes reported may differ + -- across platforms, so just check if these are strictly positive. + with progress_data as ( + select + relid::regclass::text as relname, + command, + type, + bytes_processed > 0 as has_bytes_processed, + bytes_total > 0 as has_bytes_total, + tuples_processed, + tuples_excluded + from pg_stat_progress_copy + where pid = pg_backend_pid()) + select into report (to_jsonb(r)) as value + from progress_data r; + + raise info 'progress: %', report.value::text; + return new; +end; +$$ language plpgsql +-- +FUNCTION: name="notice_after_tab_progress_reporting" function="notice_after_tab_progress_reporting" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION notice_after_tab_progress_reporting() RETURNS trigger AS $$\ndeclare report record..." +== 050 +-- truncate_limit: 100 +create trigger check_after_tab_progress_reporting + after insert on tab_progress_reporting + for each statement + execute function notice_after_tab_progress_reporting() +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER check_after_tab_progress_reporting AFTER INSERT ON tab_progress_reporting EXECUTE ..." +== 051 +-- truncate_limit: 100 +-- Generate COPY FROM report with PIPE. +copy tab_progress_reporting from stdin +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY tab_progress_reporting FROM STDIN" +== 052 +-- truncate_limit: 100 +-- Generate COPY FROM report with FILE, with some excluded tuples. +truncate tab_progress_reporting +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE tab_progress_reporting" +== 053 +-- truncate_limit: 100 +copy tab_progress_reporting from :'filename' + where (salary < 2000) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 054 +-- truncate_limit: 100 +drop trigger check_after_tab_progress_reporting on tab_progress_reporting +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER check_after_tab_progress_reporting ON tab_progress_reporting" +== 055 +-- truncate_limit: 100 +drop function notice_after_tab_progress_reporting() +-- +FUNCTION: name="notice_after_tab_progress_reporting" function="notice_after_tab_progress_reporting" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION notice_after_tab_progress_reporting()" +== 056 +-- truncate_limit: 100 +drop table tab_progress_reporting +-- +TABLE: name="tab_progress_reporting" schema="" table="tab_progress_reporting" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tab_progress_reporting" +== 057 +-- truncate_limit: 100 +-- Test header matching feature +create table header_copytest ( + a int, + b int, + c text +) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE header_copytest (a int, b int, c text)" +== 058 +-- truncate_limit: 100 +-- Make sure it works with dropped columns +alter table header_copytest drop column c +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE header_copytest DROP c" +== 059 +-- truncate_limit: 100 +alter table header_copytest add column c text +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE header_copytest ADD COLUMN c text" +== 060 +-- truncate_limit: 100 +copy header_copytest to stdout with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest TO STDOUT WITH (HEADER match)" +== 061 +-- truncate_limit: 100 +copy header_copytest from stdin with (header wrong_choice) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest FROM STDIN WITH (HEADER wrong_choice)" +== 062 +-- truncate_limit: 100 +copy header_copytest (c, a, b) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest(c, a, b) FROM STDIN WITH (HEADER match)" +== 063 +-- truncate_limit: 100 +copy header_copytest from stdin with (header match, format csv) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest FROM STDIN WITH (HEADER match, FORMAT CSV)" +== 064 +-- truncate_limit: 100 +-- errors +copy header_copytest (c, b, a) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest(c, b, a) FROM STDIN WITH (HEADER match)" +== 065 +-- truncate_limit: 100 +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest FROM STDIN WITH (HEADER match)" +== 066 +-- truncate_limit: 100 +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest FROM STDIN WITH (HEADER match)" +== 067 +-- truncate_limit: 100 +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest FROM STDIN WITH (HEADER match)" +== 068 +-- truncate_limit: 100 +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest FROM STDIN WITH (HEADER match)" +== 069 +-- truncate_limit: 100 +SELECT * FROM header_copytest ORDER BY a +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM header_copytest ORDER BY a" +== 070 +-- truncate_limit: 100 +-- Drop an extra column, in the middle of the existing set. +alter table header_copytest drop column b +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE header_copytest DROP b" +== 071 +-- truncate_limit: 100 +-- works +copy header_copytest (c, a) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest(c, a) FROM STDIN WITH (HEADER match)" +== 072 +-- truncate_limit: 100 +copy header_copytest (a, c) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest(a, c) FROM STDIN WITH (HEADER match)" +== 073 +-- truncate_limit: 100 +-- errors +copy header_copytest from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest FROM STDIN WITH (HEADER match)" +== 074 +-- truncate_limit: 100 +copy header_copytest (a, c) from stdin with (header match) +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY header_copytest(a, c) FROM STDIN WITH (HEADER match)" +== 075 +-- truncate_limit: 100 +SELECT * FROM header_copytest ORDER BY a +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM header_copytest ORDER BY a" +== 076 +-- truncate_limit: 100 +drop table header_copytest +-- +TABLE: name="header_copytest" schema="" table="header_copytest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE header_copytest" +== 077 +-- truncate_limit: 100 +-- test COPY with overlong column defaults +create temp table oversized_column_default ( + col1 varchar(5) DEFAULT 'more than 5 chars', + col2 varchar(5)) +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE oversized_column_default (col1 varchar(5) DEFAULT 'more than 5 chars', col..." +== 078 +-- truncate_limit: 100 +-- normal COPY should work +copy oversized_column_default from stdin +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY oversized_column_default FROM STDIN" +== 079 +-- truncate_limit: 100 +-- error if the column is excluded +copy oversized_column_default (col2) from stdin +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY oversized_column_default(col2) FROM STDIN" +== 080 +-- truncate_limit: 100 +-- error if the DEFAULT option is given +copy oversized_column_default from stdin (default '') +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY oversized_column_default FROM STDIN WITH (\"default\" '')" +== 081 +-- truncate_limit: 100 +drop table oversized_column_default +-- +TABLE: name="oversized_column_default" schema="" table="oversized_column_default" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE oversized_column_default" +== 082 +-- truncate_limit: 100 +|-- +-- Create partitioned table that does not allow bulk insertions, to test bugs +-- related to the reuse of BulkInsertState across partitions (only done when +-- not using bulk insert). Switching between partitions often makes it more +-- likely to encounter these bugs, so we just switch on roughly every insert +-- by having an even/odd number partition and inserting evenly distributed +-- data. +|-- +CREATE TABLE parted_si ( + id int not null, + data text not null, + -- prevent use of bulk insert by having a volatile function + rand float8 not null default random() +) +PARTITION BY LIST((id % 2)) +-- +TABLE: name="parted_si" schema="" table="parted_si" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_si (id int NOT NULL, data text NOT NULL, rand float8 NOT NULL DEFAULT random(..." +== 083 +-- truncate_limit: 100 +CREATE TABLE parted_si_p_even PARTITION OF parted_si FOR VALUES IN (0) +-- +TABLE: name="parted_si_p_even" schema="" table="parted_si_p_even" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_si_p_even PARTITION OF parted_si FOR VALUES IN (0)" +== 084 +-- truncate_limit: 100 +CREATE TABLE parted_si_p_odd PARTITION OF parted_si FOR VALUES IN (1) +-- +TABLE: name="parted_si_p_odd" schema="" table="parted_si_p_odd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_si_p_odd PARTITION OF parted_si FOR VALUES IN (1)" +== 085 +-- truncate_limit: 100 +-- Test that bulk relation extension handles reusing a single BulkInsertState +-- across partitions. Without the fix applied, this reliably reproduces +-- #18130 unless shared_buffers is extremely small (preventing any use of bulk +-- relation extension). See +-- https://postgr.es/m/18130-7a86a7356a75209d%40postgresql.org +-- https://postgr.es/m/257696.1695670946%40sss.pgh.pa.us +COPY parted_si(id, data) FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 409 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 086 +-- truncate_limit: 100 +-- An earlier bug (see commit b1ecb9b3fcf) could end up using a buffer from +-- the wrong partition. This test is *not* guaranteed to trigger that bug, but +-- does so when shared_buffers is small enough. To test if we encountered the +-- bug, check that the partition condition isn't violated. +SELECT tableoid::regclass, id % 2 = 0 is_even, count(*) from parted_si GROUP BY 1, 2 ORDER BY 1 +-- +TABLE: name="parted_si" schema="" table="parted_si" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, (id % 2) = 0 AS is_even, count(*) FROM parted_si GROUP BY 1, 2 ORDER BY 1" +== 087 +-- truncate_limit: 100 +DROP TABLE parted_si +-- +TABLE: name="parted_si" schema="" table="parted_si" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_si" diff --git a/parser/testdata/summary_truncate/postgres_regress/copy2.metadata.json b/parser/testdata/summary_truncate/postgres_regress/copy2.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/copy2.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/copy2.test b/parser/testdata/summary_truncate/postgres_regress/copy2.test new file mode 100644 index 0000000..247cf06 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/copy2.test @@ -0,0 +1,374 @@ +== 001 +-- truncate_limit: 100 +CREATE TEMP TABLE x ( + a serial, + b int, + c text not null default 'stuff', + d text, + e text +) ; + +CREATE FUNCTION fn_x_before () RETURNS TRIGGER AS ' + BEGIN + NEW.e := ''before trigger fired''::text; + return NEW; + END; +' LANGUAGE plpgsql; + +CREATE FUNCTION fn_x_after () RETURNS TRIGGER AS ' + BEGIN + UPDATE x set e=''after trigger fired'' where c=''stuff''; + return NULL; + END; +' LANGUAGE plpgsql; + +CREATE TRIGGER trg_x_after AFTER INSERT ON x +FOR EACH ROW EXECUTE PROCEDURE fn_x_after(); + +CREATE TRIGGER trg_x_before BEFORE INSERT ON x +FOR EACH ROW EXECUTE PROCEDURE fn_x_before(); + +COPY x (a, b, c, d, e) from stdin; + +COPY x (b, d) from stdin; + +COPY x (b, d) from stdin; + +COPY x (a, b, c, d, e) from stdin; + +-- non-existent column in column list: should fail +COPY x (xyz) from stdin; +COPY x from stdin; +COPY x from stdin; + +-- extra data: should fail +COPY x from stdin; + +-- various COPY options: delimiters, oids, NULL string, encoding +COPY x (b, c, d, e) from stdin delimiter ',' null 'x'; + +COPY x from stdin WITH DELIMITER AS ';' NULL AS ''; + +COPY x from stdin WITH DELIMITER AS ':' NULL AS E'\\X' ENCODING 'sql_ascii'; + +COPY x TO stdout WHERE a = 1; +COPY x from stdin WHERE a = 50004; + +COPY x from stdin WHERE a > 60003; + +COPY x from stdin WHERE f > 60003; + +-- test end of copy marker +CREATE TEMP TABLE testeoc (a text); + +COPY testeoc FROM stdin CSV; + +COPY testeoc TO stdout CSV; + +-- test handling of nonstandard null marker that violates escaping rules + +CREATE TEMP TABLE testnull(a int, b text); +INSERT INTO testnull VALUES (1, E'\\0'), (NULL, NULL); + +COPY testnull TO stdout WITH NULL AS E'\\0'; + +COPY testnull FROM stdin WITH NULL AS E'\\0'; + +SELECT * FROM testnull; + +BEGIN; +CREATE TABLE vistest (LIKE testeoc); +COPY vistest FROM stdin CSV; +COMMIT; +SELECT * FROM vistest; +BEGIN; +TRUNCATE vistest; +COPY vistest FROM stdin CSV; +SELECT * FROM vistest; +SAVEPOINT s1; +TRUNCATE vistest; +COPY vistest FROM stdin CSV; +SELECT * FROM vistest; +COMMIT; +SELECT * FROM vistest; + +BEGIN; +TRUNCATE vistest; +COPY vistest FROM stdin CSV FREEZE; +SELECT * FROM vistest; +SAVEPOINT s1; +TRUNCATE vistest; +COPY vistest FROM stdin CSV FREEZE; +SELECT * FROM vistest; +COMMIT; +SELECT * FROM vistest; + +BEGIN; +TRUNCATE vistest; +COPY vistest FROM stdin CSV FREEZE; +SELECT * FROM vistest; +COMMIT; +TRUNCATE vistest; +COPY vistest FROM stdin CSV FREEZE; +BEGIN; +TRUNCATE vistest; +SAVEPOINT s1; +COPY vistest FROM stdin CSV FREEZE; +COMMIT; +BEGIN; +INSERT INTO vistest VALUES ('z'); +SAVEPOINT s1; +TRUNCATE vistest; +ROLLBACK TO SAVEPOINT s1; +COPY vistest FROM stdin CSV FREEZE; +COMMIT; +CREATE FUNCTION truncate_in_subxact() RETURNS VOID AS +$$ +BEGIN + TRUNCATE vistest; +EXCEPTION + WHEN OTHERS THEN + INSERT INTO vistest VALUES ('subxact failure'); +END; +$$ language plpgsql; +BEGIN; +INSERT INTO vistest VALUES ('z'); +SELECT truncate_in_subxact(); +COPY vistest FROM stdin CSV FREEZE; +SELECT * FROM vistest; +COMMIT; +SELECT * FROM vistest; +-- Test FORCE_NOT_NULL and FORCE_NULL options +CREATE TEMP TABLE forcetest ( + a INT NOT NULL, + b TEXT NOT NULL, + c TEXT, + d TEXT, + e TEXT +); +-- should succeed with no effect ("b" remains an empty string, "c" remains NULL) +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL(b), FORCE_NULL(c)); +COMMIT; +SELECT b, c FROM forcetest WHERE a = 1; +-- should succeed, FORCE_NULL and FORCE_NOT_NULL can be both specified +BEGIN; +COPY forcetest (a, b, c, d) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL(c,d), FORCE_NULL(c,d)); +COMMIT; +SELECT c, d FROM forcetest WHERE a = 2; +-- should fail with not-null constraint violation +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NULL(b), FORCE_NOT_NULL(c)); +ROLLBACK; +-- should fail with "not referenced by COPY" error +BEGIN; +COPY forcetest (d, e) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL(b)); +COMMIT; +SELECT b, c FROM forcetest WHERE a = 4; +-- should succeed with effect ("b" remains an empty string) +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL *); +COMMIT; +SELECT b, c FROM forcetest WHERE a = 5; +-- should succeed with effect ("c" remains NULL) +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NULL *); +COMMIT; +SELECT b, c FROM forcetest WHERE a = 6; +-- should fail with "conflicting or redundant options" error +BEGIN; +COPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL *, FORCE_NOT_NULL(b)); +copy check_con_tbl from stdin; +select * from check_con_tbl; + +-- test with RLS enabled. +CREATE ROLE regress_rls_copy_user; +CREATE ROLE regress_rls_copy_user_colperms; +CREATE TABLE rls_t1 (a int, b int, c int); + +COPY rls_t1 (a, b, c) from stdin; + +CREATE POLICY p1 ON rls_t1 FOR SELECT USING (a % 2 = 0); +ALTER TABLE rls_t1 ENABLE ROW LEVEL SECURITY; +ALTER TABLE rls_t1 FORCE ROW LEVEL SECURITY; + +GRANT SELECT ON TABLE rls_t1 TO regress_rls_copy_user; +GRANT SELECT (a, b) ON TABLE rls_t1 TO regress_rls_copy_user_colperms; + +-- all columns +COPY rls_t1 TO stdout; +COPY rls_t1 (a, b, c) TO stdout; + +-- subset of columns +COPY rls_t1 (a) TO stdout; +COPY rls_t1 (a, b) TO stdout; + +-- column reordering +COPY rls_t1 (b, a) TO stdout; + +SET SESSION AUTHORIZATION regress_rls_copy_user; + +-- all columns +COPY rls_t1 TO stdout; +COPY rls_t1 (a, b, c) TO stdout; + +-- subset of columns +COPY rls_t1 (a) TO stdout; +COPY rls_t1 (a, b) TO stdout; + +-- column reordering +COPY rls_t1 (b, a) TO stdout; + +RESET SESSION AUTHORIZATION; + +SET SESSION AUTHORIZATION regress_rls_copy_user_colperms; + +-- attempt all columns (should fail) +COPY rls_t1 TO stdout; +COPY rls_t1 (a, b, c) TO stdout; + +-- try to copy column with no privileges (should fail) +COPY rls_t1 (c) TO stdout; + +-- subset of columns (should succeed) +COPY rls_t1 (a) TO stdout; +COPY rls_t1 (a, b) TO stdout; + +RESET SESSION AUTHORIZATION; + +-- test with INSTEAD OF INSERT trigger on a view +CREATE TABLE instead_of_insert_tbl(id serial, name text); +CREATE VIEW instead_of_insert_tbl_view AS SELECT ''::text AS str; + +COPY instead_of_insert_tbl_view FROM stdin; -- fail +test1 + +CREATE FUNCTION fun_instead_of_insert_tbl() RETURNS trigger AS $$ +BEGIN + INSERT INTO instead_of_insert_tbl (name) VALUES (NEW.str); + +SELECT * FROM instead_of_insert_tbl; + +-- Test of COPY optimization with view using INSTEAD OF INSERT +-- trigger when relation is created in the same transaction as +-- when COPY is executed. +BEGIN; +CREATE VIEW instead_of_insert_tbl_view_2 as select ''::text as str; +CREATE TRIGGER trig_instead_of_insert_tbl_view_2 + INSTEAD OF INSERT ON instead_of_insert_tbl_view_2 + FOR EACH ROW EXECUTE PROCEDURE fun_instead_of_insert_tbl(); + +COPY instead_of_insert_tbl_view_2 FROM stdin; + +SELECT * FROM instead_of_insert_tbl; +COMMIT; + +-- tests for on_error option +CREATE TABLE check_ign_err (n int, m int[], k int); +COPY check_ign_err FROM STDIN WITH (on_error stop); + +-- want context for notices + +COPY check_ign_err FROM STDIN WITH (on_error ignore, log_verbosity verbose); + +-- tests for on_error option with log_verbosity and null constraint via domain +CREATE DOMAIN dcheck_ign_err2 varchar(15) NOT NULL; +CREATE TABLE check_ign_err2 (n int, m int[], k int, l dcheck_ign_err2); +COPY check_ign_err2 FROM STDIN WITH (on_error ignore, log_verbosity verbose); + +-- reset context choice + +SELECT * FROM check_ign_err; + +SELECT * FROM check_ign_err2; + +-- test datatype error that can't be handled as soft: should fail +CREATE TABLE hard_err(foo widget); +COPY hard_err FROM STDIN WITH (on_error ignore); + +-- test missing data: should fail +COPY check_ign_err FROM STDIN WITH (on_error ignore); + +-- test extra data: should fail +COPY check_ign_err FROM STDIN WITH (on_error ignore); + +-- clean up +DROP TABLE forcetest; +DROP TABLE vistest; +DROP FUNCTION truncate_in_subxact(); +DROP TABLE x, y; +DROP TABLE rls_t1 CASCADE; +DROP ROLE regress_rls_copy_user; +DROP ROLE regress_rls_copy_user_colperms; +DROP FUNCTION fn_x_before(); +DROP FUNCTION fn_x_after(); +DROP TABLE instead_of_insert_tbl; +DROP VIEW instead_of_insert_tbl_view; +DROP VIEW instead_of_insert_tbl_view_2; +DROP FUNCTION fun_instead_of_insert_tbl(); +DROP TABLE check_ign_err; +DROP TABLE check_ign_err2; +DROP DOMAIN dcheck_ign_err2; +DROP TABLE hard_err; + +|-- +-- COPY FROM ... DEFAULT +|-- + +create temp table copy_default ( + id integer primary key, + text_value text not null default 'test', + ts_value timestamp without time zone not null default '2022-07-05' +); + +-- if DEFAULT is not specified, then the marker will be regular data +copy copy_default from stdin; + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +copy copy_default from stdin with (format csv); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +-- DEFAULT cannot be used in binary mode +copy copy_default from stdin with (format binary, default '\D'); + +copy copy_default from stdin with (format csv, default '\D'); + +-- The DEFAULT marker must be unquoted and unescaped or it's not recognized +copy copy_default from stdin with (default '\D'); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +copy copy_default from stdin with (format csv, default '\D'); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +-- successful usage of DEFAULT option in COPY +copy copy_default from stdin with (default '\D'); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +copy copy_default from stdin with (format csv, default '\D'); + +select id, text_value, ts_value from copy_default; + +truncate copy_default; + +-- DEFAULT cannot be used in COPY TO +copy (select 1 as test) TO stdout with (default '\D'); +-- +ERROR: WHERE clause not allowed with COPY TO +CURSORPOS: 1145 +FILENAME: gram.y +FUNCNAME: base_yyparse diff --git a/parser/testdata/summary_truncate/postgres_regress/copydml.metadata.json b/parser/testdata/summary_truncate/postgres_regress/copydml.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/copydml.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/copydml.test b/parser/testdata/summary_truncate/postgres_regress/copydml.test new file mode 100644 index 0000000..4bd999d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/copydml.test @@ -0,0 +1,442 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test cases for COPY (INSERT/UPDATE/DELETE) TO +|-- +create table copydml_test (id serial, t text) +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE copydml_test (id serial, t text)" +== 002 +-- truncate_limit: 100 +insert into copydml_test (t) values ('a') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copydml_test (t) VALUES ('a')" +== 003 +-- truncate_limit: 100 +insert into copydml_test (t) values ('b') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copydml_test (t) VALUES ('b')" +== 004 +-- truncate_limit: 100 +insert into copydml_test (t) values ('c') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copydml_test (t) VALUES ('c')" +== 005 +-- truncate_limit: 100 +insert into copydml_test (t) values ('d') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copydml_test (t) VALUES ('d')" +== 006 +-- truncate_limit: 100 +insert into copydml_test (t) values ('e') +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copydml_test (t) VALUES ('e')" +== 007 +-- truncate_limit: 100 +|-- +-- Test COPY (insert/update/delete ...) +|-- +copy (insert into copydml_test (t) values ('f') returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (INSERT INTO copydml_test (t) VALUES ('f') RETURNING id) TO STDOUT" +== 008 +-- truncate_limit: 100 +copy (update copydml_test set t = 'g' where t = 'f' returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (UPDATE copydml_test SET t = 'g' WHERE t = 'f' RETURNING id) TO STDOUT" +== 009 +-- truncate_limit: 100 +copy (delete from copydml_test where t = 'g' returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (DELETE FROM copydml_test WHERE t = 'g' RETURNING id) TO STDOUT" +== 010 +-- truncate_limit: 100 +|-- +-- Test \copy (insert/update/delete ...) +|-- + +-- Error cases +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (INSERT INTO copydml_test DEFAULT VALUES) TO STDOUT" +== 011 +-- truncate_limit: 100 +copy (update copydml_test set t = 'g') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (UPDATE copydml_test SET t = 'g') TO STDOUT" +== 012 +-- truncate_limit: 100 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (DELETE FROM copydml_test) TO STDOUT" +== 013 +-- truncate_limit: 100 +create rule qqq as on insert to copydml_test do instead nothing +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON INSERT TO copydml_test DO INSTEAD NOTHING" +== 014 +-- truncate_limit: 100 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (INSERT INTO copydml_test DEFAULT VALUES) TO STDOUT" +== 015 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 016 +-- truncate_limit: 100 +create rule qqq as on insert to copydml_test do also delete from copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON INSERT TO copydml_test DO DELETE FROM copydml_test" +== 017 +-- truncate_limit: 100 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (INSERT INTO copydml_test DEFAULT VALUES) TO STDOUT" +== 018 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 019 +-- truncate_limit: 100 +create rule qqq as on insert to copydml_test do instead (delete from copydml_test; delete from copydml_test) +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON INSERT TO copydml_test DO INSTEAD (DELETE FROM copydml_test; DELETE FROM co..." +== 020 +-- truncate_limit: 100 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (INSERT INTO copydml_test DEFAULT VALUES) TO STDOUT" +== 021 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 022 +-- truncate_limit: 100 +create rule qqq as on insert to copydml_test where new.t <> 'f' do instead delete from copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON INSERT TO copydml_test WHERE new.t <> 'f' DO INSTEAD DELETE FROM copydml_test" +== 023 +-- truncate_limit: 100 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (INSERT INTO copydml_test DEFAULT VALUES) TO STDOUT" +== 024 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 025 +-- truncate_limit: 100 +create rule qqq as on update to copydml_test do instead nothing +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON UPDATE TO copydml_test DO INSTEAD NOTHING" +== 026 +-- truncate_limit: 100 +copy (update copydml_test set t = 'f') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (UPDATE copydml_test SET t = 'f') TO STDOUT" +== 027 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 028 +-- truncate_limit: 100 +create rule qqq as on update to copydml_test do also delete from copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON UPDATE TO copydml_test DO DELETE FROM copydml_test" +== 029 +-- truncate_limit: 100 +copy (update copydml_test set t = 'f') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (UPDATE copydml_test SET t = 'f') TO STDOUT" +== 030 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 031 +-- truncate_limit: 100 +create rule qqq as on update to copydml_test do instead (delete from copydml_test; delete from copydml_test) +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON UPDATE TO copydml_test DO INSTEAD (DELETE FROM copydml_test; DELETE FROM co..." +== 032 +-- truncate_limit: 100 +copy (update copydml_test set t = 'f') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (UPDATE copydml_test SET t = 'f') TO STDOUT" +== 033 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 034 +-- truncate_limit: 100 +create rule qqq as on update to copydml_test where new.t <> 'f' do instead delete from copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON UPDATE TO copydml_test WHERE new.t <> 'f' DO INSTEAD DELETE FROM copydml_test" +== 035 +-- truncate_limit: 100 +copy (update copydml_test set t = 'f') to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (UPDATE copydml_test SET t = 'f') TO STDOUT" +== 036 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 037 +-- truncate_limit: 100 +create rule qqq as on delete to copydml_test do instead nothing +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON DELETE TO copydml_test DO INSTEAD NOTHING" +== 038 +-- truncate_limit: 100 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (DELETE FROM copydml_test) TO STDOUT" +== 039 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 040 +-- truncate_limit: 100 +create rule qqq as on delete to copydml_test do also insert into copydml_test default values +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON DELETE TO copydml_test DO INSERT INTO copydml_test DEFAULT VALUES" +== 041 +-- truncate_limit: 100 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (DELETE FROM copydml_test) TO STDOUT" +== 042 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 043 +-- truncate_limit: 100 +create rule qqq as on delete to copydml_test do instead (insert into copydml_test default values; insert into copydml_test default values) +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON DELETE TO copydml_test DO INSTEAD (INSERT INTO copydml_test DEFAULT VALUES;..." +== 044 +-- truncate_limit: 100 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (DELETE FROM copydml_test) TO STDOUT" +== 045 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 046 +-- truncate_limit: 100 +create rule qqq as on delete to copydml_test where old.t <> 'f' do instead insert into copydml_test default values +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON DELETE TO copydml_test WHERE ... DO INSTEAD INSERT INTO copydml_test DEFAUL..." +== 047 +-- truncate_limit: 100 +copy (delete from copydml_test) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (DELETE FROM copydml_test) TO STDOUT" +== 048 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 049 +-- truncate_limit: 100 +create rule qqq as on insert to copydml_test do instead notify copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE qqq AS ON INSERT TO copydml_test DO INSTEAD NOTIFY copydml_test" +== 050 +-- truncate_limit: 100 +copy (insert into copydml_test default values) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (INSERT INTO copydml_test DEFAULT VALUES) TO STDOUT" +== 051 +-- truncate_limit: 100 +drop rule qqq on copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE qqq ON copydml_test" +== 052 +-- truncate_limit: 100 +-- triggers +create function qqq_trig() returns trigger as $$ +begin +if tg_op in ('INSERT', 'UPDATE') then + raise notice '% % %', tg_when, tg_op, new.id; + return new; +else + raise notice '% % %', tg_when, tg_op, old.id; + return old; +end if; +end +$$ language plpgsql +-- +FUNCTION: name="qqq_trig" function="qqq_trig" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION qqq_trig() RETURNS trigger AS $$\nbegin\nif tg_op in ('INSERT', 'UPDATE') then\n ..." +== 053 +-- truncate_limit: 100 +create trigger qqqbef before insert or update or delete on copydml_test + for each row execute procedure qqq_trig() +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER qqqbef BEFORE INSERT OR DELETE OR UPDATE ON copydml_test FOR EACH ROW EXECUTE FUNC..." +== 054 +-- truncate_limit: 100 +create trigger qqqaf after insert or update or delete on copydml_test + for each row execute procedure qqq_trig() +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER qqqaf AFTER INSERT OR DELETE OR UPDATE ON copydml_test FOR EACH ROW EXECUTE FUNCTI..." +== 055 +-- truncate_limit: 100 +copy (insert into copydml_test (t) values ('f') returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (INSERT INTO copydml_test (t) VALUES ('f') RETURNING id) TO STDOUT" +== 056 +-- truncate_limit: 100 +copy (update copydml_test set t = 'g' where t = 'f' returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (UPDATE copydml_test SET t = 'g' WHERE t = 'f' RETURNING id) TO STDOUT" +== 057 +-- truncate_limit: 100 +copy (delete from copydml_test where t = 'g' returning id) to stdout +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (DELETE FROM copydml_test WHERE t = 'g' RETURNING id) TO STDOUT" +== 058 +-- truncate_limit: 100 +drop table copydml_test +-- +TABLE: name="copydml_test" schema="" table="copydml_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE copydml_test" +== 059 +-- truncate_limit: 100 +drop function qqq_trig() +-- +FUNCTION: name="qqq_trig" function="qqq_trig" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION qqq_trig()" diff --git a/parser/testdata/summary_truncate/postgres_regress/copyselect.metadata.json b/parser/testdata/summary_truncate/postgres_regress/copyselect.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/copyselect.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/copyselect.test b/parser/testdata/summary_truncate/postgres_regress/copyselect.test new file mode 100644 index 0000000..92904b4 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/copyselect.test @@ -0,0 +1,188 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test cases for COPY (select) TO +|-- +create table test1 (id serial, t text) +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test1 (id serial, t text)" +== 002 +-- truncate_limit: 100 +insert into test1 (t) values ('a') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1 (t) VALUES ('a')" +== 003 +-- truncate_limit: 100 +insert into test1 (t) values ('b') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1 (t) VALUES ('b')" +== 004 +-- truncate_limit: 100 +insert into test1 (t) values ('c') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1 (t) VALUES ('c')" +== 005 +-- truncate_limit: 100 +insert into test1 (t) values ('d') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1 (t) VALUES ('d')" +== 006 +-- truncate_limit: 100 +insert into test1 (t) values ('e') +-- +TABLE: name="test1" schema="" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test1 (t) VALUES ('e')" +== 007 +-- truncate_limit: 100 +create table test2 (id serial, t text) +-- +TABLE: name="test2" schema="" table="test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test2 (id serial, t text)" +== 008 +-- truncate_limit: 100 +insert into test2 (t) values ('A') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test2 (t) VALUES ('A')" +== 009 +-- truncate_limit: 100 +insert into test2 (t) values ('B') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test2 (t) VALUES ('B')" +== 010 +-- truncate_limit: 100 +insert into test2 (t) values ('C') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test2 (t) VALUES ('C')" +== 011 +-- truncate_limit: 100 +insert into test2 (t) values ('D') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test2 (t) VALUES ('D')" +== 012 +-- truncate_limit: 100 +insert into test2 (t) values ('E') +-- +TABLE: name="test2" schema="" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test2 (t) VALUES ('E')" +== 013 +-- truncate_limit: 100 +create view v_test1 +as select 'v_'||t from test1 +-- +TABLE: name="v_test1" schema="" table="v_test1" ctx=DDL +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v_test1 AS SELECT 'v_' || t FROM test1" +== 014 +-- truncate_limit: 100 +|-- +-- Test COPY table TO +|-- +copy test1 to stdout +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY test1 TO STDOUT" +== 015 +-- truncate_limit: 100 +|-- +-- This should fail +|-- +copy v_test1 to stdout +-- +TABLE: name="v_test1" schema="" table="v_test1" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY v_test1 TO STDOUT" +== 016 +-- truncate_limit: 100 +|-- +-- Test COPY (select) TO +|-- +copy (select t from test1 where id=1) to stdout +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +FILTER: schema="" table="" column="id" +STMT: CopyStmt +TRUNCATED: "COPY (SELECT t FROM test1 WHERE id = 1) TO STDOUT" +== 017 +-- truncate_limit: 100 +|-- +-- Test COPY (select for update) TO +|-- +copy (select t from test1 where id=3 for update) to stdout +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +FILTER: schema="" table="" column="id" +STMT: CopyStmt +TRUNCATED: "COPY (SELECT t FROM test1 WHERE id = 3 FOR UPDATE) TO STDOUT" +== 018 +-- truncate_limit: 100 +|-- +-- This should fail +|-- +copy (select t into temp test3 from test1 where id=3) to stdout +-- +TABLE: name="test1" schema="" table="test1" ctx=Select +TABLE: name="test3" schema="" table="test3" ctx=DDL +FILTER: schema="" table="" column="id" +STMT: CopyStmt +TRUNCATED: "COPY (SELECT t INTO TEMPORARY test3 FROM test1 WHERE id = 3) TO STDOUT" +== 019 +-- truncate_limit: 100 +|-- +-- This should fail +|-- +copy (select * from test1) from stdin +-- +ERROR: syntax error at or near "from" +CURSORPOS: 54 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 020 +-- truncate_limit: 100 +2 +select * from test3 +-- +ERROR: syntax error at or near "2" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 021 +-- truncate_limit: 100 +drop table test3 +-- +TABLE: name="test3" schema="" table="test3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test3" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_aggregate.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_aggregate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_aggregate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_aggregate.test b/parser/testdata/summary_truncate/postgres_regress/create_aggregate.test new file mode 100644 index 0000000..50e5b0e --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_aggregate.test @@ -0,0 +1,594 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_AGGREGATE +|-- + +-- all functions CREATEd +CREATE AGGREGATE newavg ( + sfunc = int4_avg_accum, basetype = int4, stype = _int8, + finalfunc = int8_avg, + initcond1 = '{0,0}' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE newavg (sfunc = int4_avg_accum, basetype = int4, stype = _int8, finalfunc = int8..." +== 002 +-- truncate_limit: 100 +-- test comments +COMMENT ON AGGREGATE newavg_wrong (int4) IS 'an agg comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON AGGREGATE newavg_wrong(int4) IS 'an agg comment'" +== 003 +-- truncate_limit: 100 +COMMENT ON AGGREGATE newavg (int4) IS 'an agg comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON AGGREGATE newavg(int4) IS 'an agg comment'" +== 004 +-- truncate_limit: 100 +COMMENT ON AGGREGATE newavg (int4) IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON AGGREGATE newavg(int4) IS NULL" +== 005 +-- truncate_limit: 100 +-- without finalfunc; test obsolete spellings 'sfunc1' etc +CREATE AGGREGATE newsum ( + sfunc1 = int4pl, basetype = int4, stype1 = int4, + initcond1 = '0' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE newsum (sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond1 = '0')" +== 006 +-- truncate_limit: 100 +-- zero-argument aggregate +CREATE AGGREGATE newcnt (*) ( + sfunc = int8inc, stype = int8, + initcond = '0', parallel = safe +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE newcnt (*) (sfunc = int8inc, stype = int8, initcond = '0', parallel = safe)" +== 007 +-- truncate_limit: 100 +-- old-style spelling of same (except without parallel-safe; that's too new) +CREATE AGGREGATE oldcnt ( + sfunc = int8inc, basetype = 'ANY', stype = int8, + initcond = '0' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE oldcnt (sfunc = int8inc, basetype = 'ANY', stype = int8, initcond = '0')" +== 008 +-- truncate_limit: 100 +-- aggregate that only cares about null/nonnull input +CREATE AGGREGATE newcnt ("any") ( + sfunc = int8inc_any, stype = int8, + initcond = '0' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE newcnt (\"any\") (sfunc = int8inc_any, stype = int8, initcond = '0')" +== 009 +-- truncate_limit: 100 +COMMENT ON AGGREGATE nosuchagg (*) IS 'should fail' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON AGGREGATE nosuchagg(*) IS 'should fail'" +== 010 +-- truncate_limit: 100 +COMMENT ON AGGREGATE newcnt (*) IS 'an agg(*) comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON AGGREGATE newcnt(*) IS 'an agg(*) comment'" +== 011 +-- truncate_limit: 100 +COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON AGGREGATE newcnt(\"any\") IS 'an agg(any) comment'" +== 012 +-- truncate_limit: 100 +-- multi-argument aggregate +create function sum3(int8,int8,int8) returns int8 as +'select $1 + $2 + $3' language sql strict immutable +-- +FUNCTION: name="sum3" function="sum3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sum3(int8, int8, int8) RETURNS int8 AS $$select $1 + $2 + $3$$ LANGUAGE sql RETUR..." +== 013 +-- truncate_limit: 100 +create aggregate sum2(int8,int8) ( + sfunc = sum3, stype = int8, + initcond = '0' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE sum2 (int8, int8) (sfunc = sum3, stype = int8, initcond = '0')" +== 014 +-- truncate_limit: 100 +-- multi-argument aggregates sensitive to distinct/order, strict/nonstrict +create type aggtype as (a integer, b integer, c text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE aggtype AS (a int, b int, c text)" +== 015 +-- truncate_limit: 100 +create function aggf_trans(aggtype[],integer,integer,text) returns aggtype[] +as 'select array_append($1,ROW($2,$3,$4)::aggtype)' +language sql strict immutable +-- +FUNCTION: name="aggf_trans" function="aggf_trans" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION aggf_trans(aggtype[], int, int, text) RETURNS aggtype[] AS $$select array_append(..." +== 016 +-- truncate_limit: 100 +create function aggfns_trans(aggtype[],integer,integer,text) returns aggtype[] +as 'select array_append($1,ROW($2,$3,$4)::aggtype)' +language sql immutable +-- +FUNCTION: name="aggfns_trans" function="aggfns_trans" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION aggfns_trans(aggtype[], int, int, text) RETURNS aggtype[] AS $$select array_appen..." +== 017 +-- truncate_limit: 100 +create aggregate aggfstr(integer,integer,text) ( + sfunc = aggf_trans, stype = aggtype[], + initcond = '{}' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE aggfstr (int, int, text) (sfunc = aggf_trans, stype = aggtype[], initcond = '{}')" +== 018 +-- truncate_limit: 100 +create aggregate aggfns(integer,integer,text) ( + sfunc = aggfns_trans, stype = aggtype[], sspace = 10000, + initcond = '{}' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE aggfns (int, int, text) (sfunc = aggfns_trans, stype = aggtype[], sspace = 10000..." +== 019 +-- truncate_limit: 100 +-- check error cases that would require run-time type coercion +create function least_accum(int8, int8) returns int8 language sql as + 'select least($1, $2)' +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION least_accum(int8, int8) RETURNS int8 LANGUAGE sql AS $$select least($1, $2)$$" +== 020 +-- truncate_limit: 100 +create aggregate least_agg(int4) ( + stype = int8, sfunc = least_accum +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE least_agg (int4) (stype = int8, sfunc = least_accum)" +== 021 +-- truncate_limit: 100 +-- fails + +drop function least_accum(int8, int8) +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION least_accum(int8, int8)" +== 022 +-- truncate_limit: 100 +create function least_accum(anycompatible, anycompatible) +returns anycompatible language sql as + 'select least($1, $2)' +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION least_accum(anycompatible, anycompatible) RETURNS anycompatible LANGUAGE sql AS $..." +== 023 +-- truncate_limit: 100 +create aggregate least_agg(int4) ( + stype = int8, sfunc = least_accum +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE least_agg (int4) (stype = int8, sfunc = least_accum)" +== 024 +-- truncate_limit: 100 +-- fails + +create aggregate least_agg(int8) ( + stype = int8, sfunc = least_accum +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE least_agg (int8) (stype = int8, sfunc = least_accum)" +== 025 +-- truncate_limit: 100 +drop function least_accum(anycompatible, anycompatible) cascade +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION least_accum(anycompatible, anycompatible) CASCADE" +== 026 +-- truncate_limit: 100 +-- variadic aggregates +create function least_accum(anyelement, variadic anyarray) +returns anyelement language sql as + 'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)' +-- +FUNCTION: name="least_accum" function="least_accum" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION least_accum(anyelement, VARIADIC anyarray) RETURNS anyelement LANGUAGE sql AS $$s..." +== 027 +-- truncate_limit: 100 +create aggregate least_agg(variadic items anyarray) ( + stype = anyelement, sfunc = least_accum +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE least_agg (VARIADIC items anyarray) (stype = anyelement, sfunc = least_accum)" +== 028 +-- truncate_limit: 100 +create function cleast_accum(anycompatible, variadic anycompatiblearray) +returns anycompatible language sql as + 'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)' +-- +FUNCTION: name="cleast_accum" function="cleast_accum" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION cleast_accum(anycompatible, VARIADIC anycompatiblearray) RETURNS anycompatible LA..." +== 029 +-- truncate_limit: 100 +create aggregate cleast_agg(variadic items anycompatiblearray) ( + stype = anycompatible, sfunc = cleast_accum +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE cleast_agg (VARIADIC items anycompatiblearray) (stype = anycompatible, sfunc = c..." +== 030 +-- truncate_limit: 100 +-- test ordered-set aggs using built-in support functions +create aggregate my_percentile_disc(float8 ORDER BY anyelement) ( + stype = internal, + sfunc = ordered_set_transition, + finalfunc = percentile_disc_final, + finalfunc_extra = true, + finalfunc_modify = read_write +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_percentile_disc (float8 ORDER BY anyelement) (stype = internal, sfunc = order..." +== 031 +-- truncate_limit: 100 +create aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") ( + stype = internal, + sfunc = ordered_set_transition_multi, + finalfunc = rank_final, + finalfunc_extra = true, + hypothetical +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE my_rank (VARIADIC \"any\" ORDER BY VARIADIC \"any\") (stype = internal, sfunc = orde..." +== 032 +-- truncate_limit: 100 +alter aggregate my_percentile_disc(float8 ORDER BY anyelement) + rename to test_percentile_disc +-- +STMT: RenameStmt +TRUNCATED: "ALTER AGGREGATE my_percentile_disc(float8, anyelement) RENAME TO test_percentile_disc" +== 033 +-- truncate_limit: 100 +alter aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") + rename to test_rank +-- +STMT: RenameStmt +TRUNCATED: "ALTER AGGREGATE my_rank(VARIADIC \"any\") RENAME TO test_rank" +== 034 +-- truncate_limit: 100 +-- moving-aggregate options + +CREATE AGGREGATE sumdouble (float8) +( + stype = float8, + sfunc = float8pl, + mstype = float8, + msfunc = float8pl, + minvfunc = float8mi +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE sumdouble (float8) (stype = float8, sfunc = float8pl, mstype = float8, msfunc = ..." +== 035 +-- truncate_limit: 100 +-- aggregate combine and serialization functions + +-- can't specify just one of serialfunc and deserialfunc +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + serialfunc = numeric_avg_serialize +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myavg (numeric) (stype = internal, sfunc = numeric_avg_accum, serialfunc = numer..." +== 036 +-- truncate_limit: 100 +-- serialfunc must have correct parameters +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + serialfunc = numeric_avg_deserialize, + deserialfunc = numeric_avg_deserialize +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myavg (numeric) (stype = internal, sfunc = numeric_avg_accum, serialfunc = numer..." +== 037 +-- truncate_limit: 100 +-- deserialfunc must have correct parameters +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + serialfunc = numeric_avg_serialize, + deserialfunc = numeric_avg_serialize +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myavg (numeric) (stype = internal, sfunc = numeric_avg_accum, serialfunc = numer..." +== 038 +-- truncate_limit: 100 +-- ensure combine function parameters are checked +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + serialfunc = numeric_avg_serialize, + deserialfunc = numeric_avg_deserialize, + combinefunc = int4larger +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myavg (numeric) (stype = internal, sfunc = numeric_avg_accum, serialfunc = numer..." +== 039 +-- truncate_limit: 100 +-- ensure create aggregate works. +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + finalfunc = numeric_avg, + serialfunc = numeric_avg_serialize, + deserialfunc = numeric_avg_deserialize, + combinefunc = numeric_avg_combine, + finalfunc_modify = shareable -- just to test a non-default setting +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myavg (numeric) (stype = internal, sfunc = numeric_avg_accum, finalfunc = numeri..." +== 040 +-- truncate_limit: 100 +-- Ensure all these functions made it into the catalog +SELECT aggfnoid, aggtransfn, aggcombinefn, aggtranstype::regtype, + aggserialfn, aggdeserialfn, aggfinalmodify +FROM pg_aggregate +WHERE aggfnoid = 'myavg'::REGPROC +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +FILTER: schema="" table="" column="aggfnoid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate WHERE aggfnoid = 'myavg'::regproc" +== 041 +-- truncate_limit: 100 +DROP AGGREGATE myavg (numeric) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE myavg(numeric)" +== 042 +-- truncate_limit: 100 +-- create or replace aggregate +CREATE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + finalfunc = numeric_avg +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myavg (numeric) (stype = internal, sfunc = numeric_avg_accum, finalfunc = numeri..." +== 043 +-- truncate_limit: 100 +CREATE OR REPLACE AGGREGATE myavg (numeric) +( + stype = internal, + sfunc = numeric_avg_accum, + finalfunc = numeric_avg, + serialfunc = numeric_avg_serialize, + deserialfunc = numeric_avg_deserialize, + combinefunc = numeric_avg_combine, + finalfunc_modify = shareable -- just to test a non-default setting +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OR REPLACE AGGREGATE myavg (numeric) (stype = internal, sfunc = numeric_avg_accum, finalfu..." +== 044 +-- truncate_limit: 100 +-- Ensure all these functions made it into the catalog again +SELECT aggfnoid, aggtransfn, aggcombinefn, aggtranstype::regtype, + aggserialfn, aggdeserialfn, aggfinalmodify +FROM pg_aggregate +WHERE aggfnoid = 'myavg'::REGPROC +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +FILTER: schema="" table="" column="aggfnoid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate WHERE aggfnoid = 'myavg'::regproc" +== 045 +-- truncate_limit: 100 +-- can change stype: +CREATE OR REPLACE AGGREGATE myavg (numeric) +( + stype = numeric, + sfunc = numeric_add +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OR REPLACE AGGREGATE myavg (numeric) (stype = numeric, sfunc = numeric_add)" +== 046 +-- truncate_limit: 100 +SELECT aggfnoid, aggtransfn, aggcombinefn, aggtranstype::regtype, + aggserialfn, aggdeserialfn, aggfinalmodify +FROM pg_aggregate +WHERE aggfnoid = 'myavg'::REGPROC +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +FILTER: schema="" table="" column="aggfnoid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate WHERE aggfnoid = 'myavg'::regproc" +== 047 +-- truncate_limit: 100 +-- can't change return type: +CREATE OR REPLACE AGGREGATE myavg (numeric) +( + stype = numeric, + sfunc = numeric_add, + finalfunc = numeric_out +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OR REPLACE AGGREGATE myavg (numeric) (stype = numeric, sfunc = numeric_add, finalfunc = nu..." +== 048 +-- truncate_limit: 100 +-- can't change to a different kind: +CREATE OR REPLACE AGGREGATE myavg (order by numeric) +( + stype = numeric, + sfunc = numeric_add +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OR REPLACE AGGREGATE myavg (ORDER BY numeric) (stype = numeric, sfunc = numeric_add)" +== 049 +-- truncate_limit: 100 +-- can't change plain function to aggregate: +create function sum4(int8,int8,int8,int8) returns int8 as +'select $1 + $2 + $3 + $4' language sql strict immutable +-- +FUNCTION: name="sum4" function="sum4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sum4(int8, int8, int8, int8) RETURNS int8 AS $$select $1 + $2 + $3 + $4$$ LANGUAG..." +== 050 +-- truncate_limit: 100 +CREATE OR REPLACE AGGREGATE sum3 (int8,int8,int8) +( + stype = int8, + sfunc = sum4 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OR REPLACE AGGREGATE sum3 (int8, int8, int8) (stype = int8, sfunc = sum4)" +== 051 +-- truncate_limit: 100 +drop function sum4(int8,int8,int8,int8) +-- +FUNCTION: name="sum4" function="sum4" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION sum4(int8, int8, int8, int8)" +== 052 +-- truncate_limit: 100 +DROP AGGREGATE myavg (numeric) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE myavg(numeric)" +== 053 +-- truncate_limit: 100 +-- invalid: bad parallel-safety marking +CREATE AGGREGATE mysum (int) +( + stype = int, + sfunc = int4pl, + parallel = pear +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE mysum (int) (stype = int, sfunc = int4pl, parallel = pear)" +== 054 +-- truncate_limit: 100 +-- invalid: nonstrict inverse with strict forward function + +CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS +$$ SELECT $1 - $2; $$ +LANGUAGE SQL +-- +FUNCTION: name="float8mi_n" function="float8mi_n" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS $$ SELECT $1 - $2; $$ LANGUAGE sql" +== 055 +-- truncate_limit: 100 +CREATE AGGREGATE invalidsumdouble (float8) +( + stype = float8, + sfunc = float8pl, + mstype = float8, + msfunc = float8pl, + minvfunc = float8mi_n +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE invalidsumdouble (float8) (stype = float8, sfunc = float8pl, mstype = float8, ms..." +== 056 +-- truncate_limit: 100 +-- invalid: non-matching result types + +CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS +$$ SELECT CAST($1 - $2 AS INT); $$ +LANGUAGE SQL +-- +FUNCTION: name="float8mi_int" function="float8mi_int" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS $$ SELECT CAST($1 - $2 AS INT); $$ LA..." +== 057 +-- truncate_limit: 100 +CREATE AGGREGATE wrongreturntype (float8) +( + stype = float8, + sfunc = float8pl, + mstype = float8, + msfunc = float8pl, + minvfunc = float8mi_int +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE wrongreturntype (float8) (stype = float8, sfunc = float8pl, mstype = float8, msf..." +== 058 +-- truncate_limit: 100 +-- invalid: non-lowercase quoted identifiers + +CREATE AGGREGATE case_agg ( -- old syntax + "Sfunc1" = int4pl, + "Basetype" = int4, + "Stype1" = int4, + "Initcond1" = '0', + "Parallel" = safe +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE case_agg (\"Sfunc1\" = int4pl, \"Basetype\" = int4, \"Stype1\" = int4, \"Initcond1\" = '..." +== 059 +-- truncate_limit: 100 +CREATE AGGREGATE case_agg(float8) +( + "Stype" = internal, + "Sfunc" = ordered_set_transition, + "Finalfunc" = percentile_disc_final, + "Finalfunc_extra" = true, + "Finalfunc_modify" = read_write, + "Parallel" = safe +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE case_agg (float8) (\"Stype\" = internal, \"Sfunc\" = ordered_set_transition, \"Finalf..." diff --git a/parser/testdata/summary_truncate/postgres_regress/create_am.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_am.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_am.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_am.test b/parser/testdata/summary_truncate/postgres_regress/create_am.test new file mode 100644 index 0000000..561a851 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_am.test @@ -0,0 +1,1300 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Create access method tests +|-- + +-- Make gist2 over gisthandler. In fact, it would be a synonym to gist. +CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler +-- +STMT: CreateAmStmt +TRUNCATED: "CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler" +== 002 +-- truncate_limit: 100 +-- Verify return type checks for handlers +CREATE ACCESS METHOD bogus TYPE INDEX HANDLER int4in +-- +STMT: CreateAmStmt +TRUNCATED: "CREATE ACCESS METHOD bogus TYPE INDEX HANDLER int4in" +== 003 +-- truncate_limit: 100 +CREATE ACCESS METHOD bogus TYPE INDEX HANDLER heap_tableam_handler +-- +STMT: CreateAmStmt +TRUNCATED: "CREATE ACCESS METHOD bogus TYPE INDEX HANDLER heap_tableam_handler" +== 004 +-- truncate_limit: 100 +-- Try to create gist2 index on fast_emp4000: fail because opclass doesn't exist +CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base) +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base)" +== 005 +-- truncate_limit: 100 +-- Make operator class for boxes using gist2 +CREATE OPERATOR CLASS box_ops DEFAULT + FOR TYPE box USING gist2 AS + OPERATOR 1 <<, + OPERATOR 2 &<, + OPERATOR 3 &&, + OPERATOR 4 &>, + OPERATOR 5 >>, + OPERATOR 6 ~=, + OPERATOR 7 @>, + OPERATOR 8 <@, + OPERATOR 9 &<|, + OPERATOR 10 <<|, + OPERATOR 11 |>>, + OPERATOR 12 |&>, + FUNCTION 1 gist_box_consistent(internal, box, smallint, oid, internal), + FUNCTION 2 gist_box_union(internal, internal), + -- don't need compress, decompress, or fetch functions + FUNCTION 5 gist_box_penalty(internal, internal, internal), + FUNCTION 6 gist_box_picksplit(internal, internal), + FUNCTION 7 gist_box_same(box, box, internal) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS box_ops DEFAULT FOR TYPE box USING gist2 AS OPERATOR 1 <<, OPERATOR 2 &<, O..." +== 006 +-- truncate_limit: 100 +-- Create gist2 index on fast_emp4000 +CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base) +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base)" +== 007 +-- truncate_limit: 100 +-- Now check the results from plain indexscan; temporarily drop existing +-- index grect2ind to ensure it doesn't capture the plan +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 008 +-- truncate_limit: 100 +DROP INDEX grect2ind +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX grect2ind" +== 009 +-- truncate_limit: 100 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 010 +-- truncate_limit: 100 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 011 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 012 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM fast_emp4000 WHERE home_base <@ '(200,200),(2000,1000)'::box OR..." +== 013 +-- truncate_limit: 100 +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fast_emp4000 WHERE ... ORDER BY (home_base[0])[0]" +== 014 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box" +== 015 +-- truncate_limit: 100 +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box" +== 016 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL" +== 017 +-- truncate_limit: 100 +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL" +== 018 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 019 +-- truncate_limit: 100 +-- Try to drop access method: fail because of dependent objects +DROP ACCESS METHOD gist2 +-- +STMT: DropStmt +TRUNCATED: "DROP ACCESS METHOD gist2" +== 020 +-- truncate_limit: 100 +-- Drop access method cascade +-- To prevent a (rare) deadlock against autovacuum, +-- we must lock the table that owns the index that will be dropped +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 021 +-- truncate_limit: 100 +LOCK TABLE fast_emp4000 +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE fast_emp4000" +== 022 +-- truncate_limit: 100 +DROP ACCESS METHOD gist2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP ACCESS METHOD gist2 CASCADE" +== 023 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 024 +-- truncate_limit: 100 +|-- +-- Test table access methods +|-- + +-- prevent empty values +SET default_table_access_method = '' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_table_access_method TO ''" +== 025 +-- truncate_limit: 100 +-- prevent nonexistent values +SET default_table_access_method = 'I do not exist AM' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_table_access_method TO \"I do not exist AM\"" +== 026 +-- truncate_limit: 100 +-- prevent setting it to an index AM +SET default_table_access_method = 'btree' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_table_access_method TO btree" +== 027 +-- truncate_limit: 100 +-- Create a heap2 table am handler with heapam handler +CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler +-- +STMT: CreateAmStmt +TRUNCATED: "CREATE ACCESS METHOD heap2 TYPE TABLE HANDLER heap_tableam_handler" +== 028 +-- truncate_limit: 100 +-- Verify return type checks for handlers +CREATE ACCESS METHOD bogus TYPE TABLE HANDLER int4in +-- +STMT: CreateAmStmt +TRUNCATED: "CREATE ACCESS METHOD bogus TYPE TABLE HANDLER int4in" +== 029 +-- truncate_limit: 100 +CREATE ACCESS METHOD bogus TYPE TABLE HANDLER bthandler +-- +STMT: CreateAmStmt +TRUNCATED: "CREATE ACCESS METHOD bogus TYPE TABLE HANDLER bthandler" +== 030 +-- truncate_limit: 100 +SELECT amname, amhandler, amtype FROM pg_am where amtype = 't' ORDER BY 1, 2 +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FILTER: schema="" table="" column="amtype" +STMT: SelectStmt +TRUNCATED: "SELECT amname, amhandler, amtype FROM pg_am WHERE amtype = 't' ORDER BY 1, 2" +== 031 +-- truncate_limit: 100 +-- First create tables employing the new AM using USING + +-- plain CREATE TABLE +CREATE TABLE tableam_tbl_heap2(f1 int) USING heap2 +-- +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_tbl_heap2 (f1 int) USING heap2" +== 032 +-- truncate_limit: 100 +INSERT INTO tableam_tbl_heap2 VALUES(1) +-- +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tableam_tbl_heap2 VALUES (1)" +== 033 +-- truncate_limit: 100 +SELECT f1 FROM tableam_tbl_heap2 ORDER BY f1 +-- +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM tableam_tbl_heap2 ORDER BY f1" +== 034 +-- truncate_limit: 100 +-- CREATE TABLE AS +CREATE TABLE tableam_tblas_heap2 USING heap2 AS SELECT * FROM tableam_tbl_heap2 +-- +TABLE: name="tableam_tblas_heap2" schema="" table="tableam_tblas_heap2" ctx=DDL +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE tableam_tblas_heap2 USING heap2 AS SELECT * FROM tableam_tbl_heap2" +== 035 +-- truncate_limit: 100 +SELECT f1 FROM tableam_tbl_heap2 ORDER BY f1 +-- +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM tableam_tbl_heap2 ORDER BY f1" +== 036 +-- truncate_limit: 100 +-- SELECT INTO doesn't support USING +SELECT INTO tableam_tblselectinto_heap2 USING heap2 FROM tableam_tbl_heap2 +-- +ERROR: syntax error at or near "USING" +CURSORPOS: 78 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 037 +-- truncate_limit: 100 +-- CREATE VIEW doesn't support USING +CREATE VIEW tableam_view_heap2 USING heap2 AS SELECT * FROM tableam_tbl_heap2 +-- +ERROR: syntax error at or near "USING" +CURSORPOS: 69 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 038 +-- truncate_limit: 100 +-- CREATE SEQUENCE doesn't support USING +CREATE SEQUENCE tableam_seq_heap2 USING heap2 +-- +ERROR: syntax error at or near "USING" +CURSORPOS: 76 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 039 +-- truncate_limit: 100 +-- CREATE MATERIALIZED VIEW does support USING +CREATE MATERIALIZED VIEW tableam_tblmv_heap2 USING heap2 AS SELECT * FROM tableam_tbl_heap2 +-- +TABLE: name="tableam_tblmv_heap2" schema="" table="tableam_tblmv_heap2" ctx=DDL +TABLE: name="tableam_tbl_heap2" schema="" table="tableam_tbl_heap2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW tableam_tblmv_heap2 USING heap2 AS SELECT * FROM tableam_tbl_heap2" +== 040 +-- truncate_limit: 100 +SELECT f1 FROM tableam_tblmv_heap2 ORDER BY f1 +-- +TABLE: name="tableam_tblmv_heap2" schema="" table="tableam_tblmv_heap2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM tableam_tblmv_heap2 ORDER BY f1" +== 041 +-- truncate_limit: 100 +-- CREATE TABLE .. PARTITION BY supports USING. +CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) USING heap2 +-- +TABLE: name="tableam_parted_heap2" schema="" table="tableam_parted_heap2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY LIST (a) USING heap2" +== 042 +-- truncate_limit: 100 +SELECT a.amname FROM pg_class c, pg_am a + WHERE c.relname = 'tableam_parted_heap2' AND a.oid = c.relam +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relam" +STMT: SelectStmt +TRUNCATED: "SELECT a.amname FROM pg_class c, pg_am a WHERE ..." +== 043 +-- truncate_limit: 100 +DROP TABLE tableam_parted_heap2 +-- +TABLE: name="tableam_parted_heap2" schema="" table="tableam_parted_heap2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tableam_parted_heap2" +== 044 +-- truncate_limit: 100 +CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY list (a) +-- +TABLE: name="tableam_parted_heap2" schema="" table="tableam_parted_heap2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_heap2 (a text, b int) PARTITION BY LIST (a)" +== 045 +-- truncate_limit: 100 +-- new partitions will inherit from the current default, rather the partition root +SET default_table_access_method = 'heap' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_table_access_method TO heap" +== 046 +-- truncate_limit: 100 +CREATE TABLE tableam_parted_a_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('a') +-- +TABLE: name="tableam_parted_a_heap2" schema="" table="tableam_parted_a_heap2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_a_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('a')" +== 047 +-- truncate_limit: 100 +SET default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_table_access_method TO heap2" +== 048 +-- truncate_limit: 100 +CREATE TABLE tableam_parted_b_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('b') +-- +TABLE: name="tableam_parted_b_heap2" schema="" table="tableam_parted_b_heap2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_b_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('b')" +== 049 +-- truncate_limit: 100 +RESET default_table_access_method +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_table_access_method" +== 050 +-- truncate_limit: 100 +-- but the method can be explicitly specified +CREATE TABLE tableam_parted_c_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('c') USING heap +-- +TABLE: name="tableam_parted_c_heap2" schema="" table="tableam_parted_c_heap2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_c_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('c') USING heap" +== 051 +-- truncate_limit: 100 +CREATE TABLE tableam_parted_d_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('d') USING heap2 +-- +TABLE: name="tableam_parted_d_heap2" schema="" table="tableam_parted_d_heap2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_d_heap2 PARTITION OF tableam_parted_heap2 FOR VALUES IN ('d') USING h..." +== 052 +-- truncate_limit: 100 +-- List all objects in AM +SELECT + pc.relkind, + pa.amname, + CASE WHEN relkind = 't' THEN + (SELECT 'toast for ' || relname::regclass FROM pg_class pcm WHERE pcm.reltoastrelid = pc.oid) + ELSE + relname::regclass::text + END COLLATE "C" AS relname +FROM pg_class AS pc, + pg_am AS pa +WHERE pa.oid = pc.relam + AND pa.amname = 'heap2' +ORDER BY 3, 1, 2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pa"="pg_am" +ALIAS: "pc"="pg_class" +ALIAS: "pcm"="pg_class" +FILTER: schema="" table="pa" column="oid" +FILTER: schema="" table="pc" column="relam" +FILTER: schema="" table="pa" column="amname" +FILTER: schema="" table="pcm" column="reltoastrelid" +FILTER: schema="" table="pc" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc, pg_am pa WHERE ... ORDER BY 3, 1, 2" +== 053 +-- truncate_limit: 100 +-- Show dependencies onto AM - there shouldn't be any for toast +SELECT pg_describe_object(classid,objid,objsubid) AS obj +FROM pg_depend, pg_am +WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_am.amname = 'heap2' +ORDER BY classid, objid, objsubid +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_am" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend, pg_am WHERE ... ORDER BY classid, objid, objsubid" +== 054 +-- truncate_limit: 100 +-- ALTER TABLE SET ACCESS METHOD +CREATE TABLE heaptable USING heap AS + SELECT a, repeat(a::text, 100) FROM generate_series(1,9) AS a +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE heaptable USING heap AS SELECT a, repeat(a::text, 100) FROM generate_series(1, 9) a" +== 055 +-- truncate_limit: 100 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT amname FROM pg_class c, pg_am am WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass" +== 056 +-- truncate_limit: 100 +-- Switching to heap2 adds new dependency entry to the AM. +ALTER TABLE heaptable SET ACCESS METHOD heap2 +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE heaptable SET ACCESS METHOD heap2" +== 057 +-- truncate_limit: 100 +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as objref, + deptype + FROM pg_depend + WHERE classid = 'pg_class'::regclass AND + objid = 'heaptable'::regclass + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1, 2" +== 058 +-- truncate_limit: 100 +-- Switching to heap should not have a dependency entry to the AM. +ALTER TABLE heaptable SET ACCESS METHOD heap +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE heaptable SET ACCESS METHOD heap" +== 059 +-- truncate_limit: 100 +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as objref, + deptype + FROM pg_depend + WHERE classid = 'pg_class'::regclass AND + objid = 'heaptable'::regclass + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1, 2" +== 060 +-- truncate_limit: 100 +ALTER TABLE heaptable SET ACCESS METHOD heap2 +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE heaptable SET ACCESS METHOD heap2" +== 061 +-- truncate_limit: 100 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT amname FROM pg_class c, pg_am am WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass" +== 062 +-- truncate_limit: 100 +SELECT COUNT(a), COUNT(1) FILTER(WHERE a=1) FROM heaptable +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(a), count(1) FILTER (WHERE a = 1) FROM heaptable" +== 063 +-- truncate_limit: 100 +-- DEFAULT access method +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 064 +-- truncate_limit: 100 +SET LOCAL default_table_access_method TO heap2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap2" +== 065 +-- truncate_limit: 100 +ALTER TABLE heaptable SET ACCESS METHOD DEFAULT +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE heaptable SET ACCESS METHOD DEFAULT" +== 066 +-- truncate_limit: 100 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT amname FROM pg_class c, pg_am am WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass" +== 067 +-- truncate_limit: 100 +SET LOCAL default_table_access_method TO heap +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap" +== 068 +-- truncate_limit: 100 +ALTER TABLE heaptable SET ACCESS METHOD DEFAULT +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE heaptable SET ACCESS METHOD DEFAULT" +== 069 +-- truncate_limit: 100 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT amname FROM pg_class c, pg_am am WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass" +== 070 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 071 +-- truncate_limit: 100 +-- ALTER MATERIALIZED VIEW SET ACCESS METHOD +CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT * FROM heaptable +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +TABLE: name="heaptable" schema="" table="heaptable" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT * FROM heaptable" +== 072 +-- truncate_limit: 100 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT amname FROM pg_class c, pg_am am WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass" +== 073 +-- truncate_limit: 100 +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2 +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2" +== 074 +-- truncate_limit: 100 +SELECT amname FROM pg_class c, pg_am am + WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="am" column="oid" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT amname FROM pg_class c, pg_am am WHERE c.relam = am.oid AND c.oid = 'heapmv'::regclass" +== 075 +-- truncate_limit: 100 +SELECT COUNT(a), COUNT(1) FILTER(WHERE a=1) FROM heapmv +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(a), count(1) FILTER (WHERE a = 1) FROM heapmv" +== 076 +-- truncate_limit: 100 +-- No support for multiple subcommands +ALTER TABLE heaptable SET ACCESS METHOD heap, SET ACCESS METHOD heap2 +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE heaptable SET ACCESS METHOD heap, SET ACCESS METHOD heap2" +== 077 +-- truncate_limit: 100 +ALTER TABLE heaptable SET ACCESS METHOD DEFAULT, SET ACCESS METHOD heap2 +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE heaptable SET ACCESS METHOD DEFAULT, SET ACCESS METHOD heap2" +== 078 +-- truncate_limit: 100 +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap, SET ACCESS METHOD heap2 +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap, SET ACCESS METHOD heap2" +== 079 +-- truncate_limit: 100 +DROP MATERIALIZED VIEW heapmv +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW heapmv" +== 080 +-- truncate_limit: 100 +DROP TABLE heaptable +-- +TABLE: name="heaptable" schema="" table="heaptable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE heaptable" +== 081 +-- truncate_limit: 100 +-- Partitioned table with USING +CREATE TABLE am_partitioned(x INT, y INT) PARTITION BY hash (x) USING heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned (x int, y int) PARTITION BY HASH (x) USING heap2" +== 082 +-- truncate_limit: 100 +SELECT pg_describe_object(classid, objid, objsubid) AS obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as refobj + FROM pg_depend, pg_am + WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_depend.objid = 'am_partitioned'::regclass +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_depend" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend, pg_am WHERE ..." +== 083 +-- truncate_limit: 100 +DROP TABLE am_partitioned +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE am_partitioned" +== 084 +-- truncate_limit: 100 +-- Partition hierarchies with access methods +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 085 +-- truncate_limit: 100 +SET LOCAL default_table_access_method = 'heap' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap" +== 086 +-- truncate_limit: 100 +CREATE TABLE am_partitioned(x INT, y INT) PARTITION BY hash (x) +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned (x int, y int) PARTITION BY HASH (x)" +== 087 +-- truncate_limit: 100 +-- pg_class.relam is 0, no dependency recorded between the AM and the +-- partitioned table. +SELECT relam FROM pg_class WHERE relname = 'am_partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relam FROM pg_class WHERE relname = 'am_partitioned'" +== 088 +-- truncate_limit: 100 +SELECT pg_describe_object(classid, objid, objsubid) AS obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as refobj + FROM pg_depend, pg_am + WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_depend.objid = 'am_partitioned'::regclass +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_depend" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend, pg_am WHERE ..." +== 089 +-- truncate_limit: 100 +-- New default is set, with dependency added. +ALTER TABLE am_partitioned SET ACCESS METHOD heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE am_partitioned SET ACCESS METHOD heap2" +== 090 +-- truncate_limit: 100 +SELECT a.amname FROM pg_class c, pg_am a + WHERE c.relname = 'am_partitioned' AND a.oid = c.relam +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relam" +STMT: SelectStmt +TRUNCATED: "SELECT a.amname FROM pg_class c, pg_am a WHERE c.relname = 'am_partitioned' AND a.oid = c.relam" +== 091 +-- truncate_limit: 100 +SELECT pg_describe_object(classid, objid, objsubid) AS obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as refobj + FROM pg_depend, pg_am + WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_depend.objid = 'am_partitioned'::regclass +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_depend" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend, pg_am WHERE ..." +== 092 +-- truncate_limit: 100 +-- Default is set, with dependency updated. +SET LOCAL default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap2" +== 093 +-- truncate_limit: 100 +ALTER TABLE am_partitioned SET ACCESS METHOD heap +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE am_partitioned SET ACCESS METHOD heap" +== 094 +-- truncate_limit: 100 +SELECT a.amname FROM pg_class c, pg_am a + WHERE c.relname = 'am_partitioned' AND a.oid = c.relam +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relam" +STMT: SelectStmt +TRUNCATED: "SELECT a.amname FROM pg_class c, pg_am a WHERE c.relname = 'am_partitioned' AND a.oid = c.relam" +== 095 +-- truncate_limit: 100 +-- Dependency pinned, hence removed. +SELECT pg_describe_object(classid, objid, objsubid) AS obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as refobj + FROM pg_depend, pg_am + WHERE pg_depend.refclassid = 'pg_am'::regclass + AND pg_am.oid = pg_depend.refobjid + AND pg_depend.objid = 'am_partitioned'::regclass +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="pg_depend" column="refclassid" +FILTER: schema="" table="pg_am" column="oid" +FILTER: schema="" table="pg_depend" column="refobjid" +FILTER: schema="" table="pg_depend" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend, pg_am WHERE ..." +== 096 +-- truncate_limit: 100 +-- Default and AM set in the clause are the same, relam should be set. +SET LOCAL default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap2" +== 097 +-- truncate_limit: 100 +ALTER TABLE am_partitioned SET ACCESS METHOD heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE am_partitioned SET ACCESS METHOD heap2" +== 098 +-- truncate_limit: 100 +SELECT a.amname FROM pg_class c, pg_am a + WHERE c.relname = 'am_partitioned' AND a.oid = c.relam +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relam" +STMT: SelectStmt +TRUNCATED: "SELECT a.amname FROM pg_class c, pg_am a WHERE c.relname = 'am_partitioned' AND a.oid = c.relam" +== 099 +-- truncate_limit: 100 +-- Reset to default +ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT" +== 100 +-- truncate_limit: 100 +SELECT relam FROM pg_class WHERE relname = 'am_partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relam FROM pg_class WHERE relname = 'am_partitioned'" +== 101 +-- truncate_limit: 100 +-- Upon ALTER TABLE SET ACCESS METHOD on a partitioned table, new partitions +-- will inherit the AM set. Existing partitioned are unchanged. +SELECT relam FROM pg_class WHERE relname = 'am_partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relam FROM pg_class WHERE relname = 'am_partitioned'" +== 102 +-- truncate_limit: 100 +SET LOCAL default_table_access_method = 'heap' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap" +== 103 +-- truncate_limit: 100 +CREATE TABLE am_partitioned_0 PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 0) +-- +TABLE: name="am_partitioned_0" schema="" table="am_partitioned_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned_0 PARTITION OF am_partitioned FOR VALUES WITH (MODULUS 10, REMAINDER 0)" +== 104 +-- truncate_limit: 100 +SET LOCAL default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap2" +== 105 +-- truncate_limit: 100 +CREATE TABLE am_partitioned_1 PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="am_partitioned_1" schema="" table="am_partitioned_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned_1 PARTITION OF am_partitioned FOR VALUES WITH (MODULUS 10, REMAINDER 1)" +== 106 +-- truncate_limit: 100 +SET LOCAL default_table_access_method = 'heap' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap" +== 107 +-- truncate_limit: 100 +ALTER TABLE am_partitioned SET ACCESS METHOD heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE am_partitioned SET ACCESS METHOD heap2" +== 108 +-- truncate_limit: 100 +CREATE TABLE am_partitioned_2 PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 2) +-- +TABLE: name="am_partitioned_2" schema="" table="am_partitioned_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned_2 PARTITION OF am_partitioned FOR VALUES WITH (MODULUS 10, REMAINDER 2)" +== 109 +-- truncate_limit: 100 +ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT" +== 110 +-- truncate_limit: 100 +SELECT relam FROM pg_class WHERE relname = 'am_partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relam FROM pg_class WHERE relname = 'am_partitioned'" +== 111 +-- truncate_limit: 100 +CREATE TABLE am_partitioned_3 PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 3) +-- +TABLE: name="am_partitioned_3" schema="" table="am_partitioned_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned_3 PARTITION OF am_partitioned FOR VALUES WITH (MODULUS 10, REMAINDER 3)" +== 112 +-- truncate_limit: 100 +-- Partitioned table with relam at 0 +ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE am_partitioned SET ACCESS METHOD DEFAULT" +== 113 +-- truncate_limit: 100 +CREATE TABLE am_partitioned_5p PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 5) PARTITION BY hash(y) +-- +TABLE: name="am_partitioned_5p" schema="" table="am_partitioned_5p" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned_5p PARTITION OF am_partitioned FOR VALUES WITH (MODULUS 10, REMAINDER..." +== 114 +-- truncate_limit: 100 +-- Partitions of this partitioned table inherit default AM at creation +-- time. +CREATE TABLE am_partitioned_5p1 PARTITION OF am_partitioned_5p + FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="am_partitioned_5p1" schema="" table="am_partitioned_5p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned_5p1 PARTITION OF am_partitioned_5p FOR VALUES WITH (MODULUS 10, REMAI..." +== 115 +-- truncate_limit: 100 +-- Partitioned table with relam set. +ALTER TABLE am_partitioned SET ACCESS METHOD heap2 +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE am_partitioned SET ACCESS METHOD heap2" +== 116 +-- truncate_limit: 100 +CREATE TABLE am_partitioned_6p PARTITION OF am_partitioned + FOR VALUES WITH (MODULUS 10, REMAINDER 6) PARTITION BY hash(y) +-- +TABLE: name="am_partitioned_6p" schema="" table="am_partitioned_6p" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned_6p PARTITION OF am_partitioned FOR VALUES WITH (MODULUS 10, REMAINDER..." +== 117 +-- truncate_limit: 100 +-- Partitions of this partitioned table inherit its AM. +CREATE TABLE am_partitioned_6p1 PARTITION OF am_partitioned_6p + FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="am_partitioned_6p1" schema="" table="am_partitioned_6p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE am_partitioned_6p1 PARTITION OF am_partitioned_6p FOR VALUES WITH (MODULUS 10, REMAI..." +== 118 +-- truncate_limit: 100 +SELECT c.relname, a.amname FROM pg_class c, pg_am a + WHERE c.relam = a.oid AND + c.relname LIKE 'am_partitioned%' +UNION ALL +SELECT c.relname, 'default' FROM pg_class c + WHERE c.relam = 0 + AND c.relname LIKE 'am_partitioned%' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_am" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="a" column="oid" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="c" column="relam" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c, pg_am a WHERE ... UNION ALL SELECT ... FROM pg_class c WHERE ... ORDE..." +== 119 +-- truncate_limit: 100 +DROP TABLE am_partitioned +-- +TABLE: name="am_partitioned" schema="" table="am_partitioned" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE am_partitioned" +== 120 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 121 +-- truncate_limit: 100 +-- Second, create objects in the new AM by changing the default AM +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 122 +-- truncate_limit: 100 +SET LOCAL default_table_access_method = 'heap2' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL default_table_access_method TO heap2" +== 123 +-- truncate_limit: 100 +-- following tests should all respect the default AM +CREATE TABLE tableam_tbl_heapx(f1 int) +-- +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_tbl_heapx (f1 int)" +== 124 +-- truncate_limit: 100 +CREATE TABLE tableam_tblas_heapx AS SELECT * FROM tableam_tbl_heapx +-- +TABLE: name="tableam_tblas_heapx" schema="" table="tableam_tblas_heapx" ctx=DDL +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE tableam_tblas_heapx AS SELECT * FROM tableam_tbl_heapx" +== 125 +-- truncate_limit: 100 +SELECT INTO tableam_tblselectinto_heapx FROM tableam_tbl_heapx +-- +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=Select +TABLE: name="tableam_tblselectinto_heapx" schema="" table="tableam_tblselectinto_heapx" ctx=DDL +STMT: SelectStmt +TRUNCATED: "SELECT INTO tableam_tblselectinto_heapx FROM tableam_tbl_heapx" +== 126 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW tableam_tblmv_heapx USING heap2 AS SELECT * FROM tableam_tbl_heapx +-- +TABLE: name="tableam_tblmv_heapx" schema="" table="tableam_tblmv_heapx" ctx=DDL +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW tableam_tblmv_heapx USING heap2 AS SELECT * FROM tableam_tbl_heapx" +== 127 +-- truncate_limit: 100 +CREATE TABLE tableam_parted_heapx (a text, b int) PARTITION BY list (a) +-- +TABLE: name="tableam_parted_heapx" schema="" table="tableam_parted_heapx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_heapx (a text, b int) PARTITION BY LIST (a)" +== 128 +-- truncate_limit: 100 +CREATE TABLE tableam_parted_1_heapx PARTITION OF tableam_parted_heapx FOR VALUES IN ('a', 'b') +-- +TABLE: name="tableam_parted_1_heapx" schema="" table="tableam_parted_1_heapx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_1_heapx PARTITION OF tableam_parted_heapx FOR VALUES IN ('a', 'b')" +== 129 +-- truncate_limit: 100 +-- but an explicitly set AM overrides it +CREATE TABLE tableam_parted_2_heapx PARTITION OF tableam_parted_heapx FOR VALUES IN ('c', 'd') USING heap +-- +TABLE: name="tableam_parted_2_heapx" schema="" table="tableam_parted_2_heapx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tableam_parted_2_heapx PARTITION OF tableam_parted_heapx FOR VALUES IN ('c', 'd') US..." +== 130 +-- truncate_limit: 100 +-- sequences, views and foreign servers shouldn't have an AM +CREATE VIEW tableam_view_heapx AS SELECT * FROM tableam_tbl_heapx +-- +TABLE: name="tableam_view_heapx" schema="" table="tableam_view_heapx" ctx=DDL +TABLE: name="tableam_tbl_heapx" schema="" table="tableam_tbl_heapx" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tableam_view_heapx AS SELECT * FROM tableam_tbl_heapx" +== 131 +-- truncate_limit: 100 +CREATE SEQUENCE tableam_seq_heapx +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE tableam_seq_heapx" +== 132 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER fdw_heap2 VALIDATOR postgresql_fdw_validator +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER fdw_heap2 VALIDATOR postgresql_fdw_validator" +== 133 +-- truncate_limit: 100 +CREATE SERVER fs_heap2 FOREIGN DATA WRAPPER fdw_heap2 +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER fs_heap2 FOREIGN DATA WRAPPER fdw_heap2" +== 134 +-- truncate_limit: 100 +CREATE FOREIGN table tableam_fdw_heapx () SERVER fs_heap2 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE tableam_fdw_heapx () SERVER fs_heap2" +== 135 +-- truncate_limit: 100 +-- Verify that new AM was used for tables, matviews, but not for sequences, views and fdws +SELECT + pc.relkind, + pa.amname, + CASE WHEN relkind = 't' THEN + (SELECT 'toast for ' || relname::regclass FROM pg_class pcm WHERE pcm.reltoastrelid = pc.oid) + ELSE + relname::regclass::text + END COLLATE "C" AS relname +FROM pg_class AS pc + LEFT JOIN pg_am AS pa ON (pa.oid = pc.relam) +WHERE pc.relname LIKE 'tableam_%_heapx' +ORDER BY 3, 1, 2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pa"="pg_am" +ALIAS: "pc"="pg_class" +ALIAS: "pcm"="pg_class" +FILTER: schema="" table="pc" column="relname" +FILTER: schema="" table="pcm" column="reltoastrelid" +FILTER: schema="" table="pc" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc LEFT JOIN pg_am pa ON pa.oid = pc.relam WHERE ... ORDER BY 3, 1, 2" +== 136 +-- truncate_limit: 100 +-- don't want to keep those tables, nor the default +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 137 +-- truncate_limit: 100 +-- Third, check that we can neither create a table using a nonexistent +-- AM, nor using an index AM +CREATE TABLE i_am_a_failure() USING "notempty" +-- +TABLE: name="i_am_a_failure" schema="" table="i_am_a_failure" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE i_am_a_failure () USING notempty" +== 138 +-- truncate_limit: 100 +CREATE TABLE i_am_a_failure() USING i_do_not_exist_am +-- +TABLE: name="i_am_a_failure" schema="" table="i_am_a_failure" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE i_am_a_failure () USING i_do_not_exist_am" +== 139 +-- truncate_limit: 100 +CREATE TABLE i_am_a_failure() USING "I do not exist AM" +-- +TABLE: name="i_am_a_failure" schema="" table="i_am_a_failure" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE i_am_a_failure () USING \"I do not exist AM\"" +== 140 +-- truncate_limit: 100 +CREATE TABLE i_am_a_failure() USING "btree" +-- +TABLE: name="i_am_a_failure" schema="" table="i_am_a_failure" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE i_am_a_failure () USING btree" +== 141 +-- truncate_limit: 100 +-- Other weird invalid cases that cause problems +CREATE FOREIGN TABLE fp PARTITION OF tableam_parted_a_heap2 DEFAULT SERVER x +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE fp PARTITION OF tableam_parted_a_heap2 DEFAULT SERVER x" +== 142 +-- truncate_limit: 100 +-- Drop table access method, which fails as objects depends on it +DROP ACCESS METHOD heap2 +-- +STMT: DropStmt +TRUNCATED: "DROP ACCESS METHOD heap2" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_cast.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_cast.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_cast.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_cast.test b/parser/testdata/summary_truncate/postgres_regress/create_cast.test new file mode 100644 index 0000000..25468b0 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_cast.test @@ -0,0 +1,214 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_CAST +|-- + +-- Create some types to test with +CREATE TYPE casttesttype +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE casttesttype" +== 002 +-- truncate_limit: 100 +CREATE FUNCTION casttesttype_in(cstring) + RETURNS casttesttype + AS 'textin' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="casttesttype_in" function="casttesttype_in" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION casttesttype_in(cstring) RETURNS casttesttype AS $$textin$$ LANGUAGE internal RET..." +== 003 +-- truncate_limit: 100 +CREATE FUNCTION casttesttype_out(casttesttype) + RETURNS cstring + AS 'textout' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="casttesttype_out" function="casttesttype_out" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION casttesttype_out(casttesttype) RETURNS cstring AS $$textout$$ LANGUAGE internal R..." +== 004 +-- truncate_limit: 100 +CREATE TYPE casttesttype ( + internallength = variable, + input = casttesttype_in, + output = casttesttype_out, + alignment = int4 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE casttesttype (internallength = variable, input = casttesttype_in, output = casttestty..." +== 005 +-- truncate_limit: 100 +-- a dummy function to test with +CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQL AS +$$ SELECT 1; $$ +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE sql AS $$ SELECT 1; $$" +== 006 +-- truncate_limit: 100 +SELECT casttestfunc('foo'::text) +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT casttestfunc('foo'::text)" +== 007 +-- truncate_limit: 100 +-- fails, as there's no cast + +-- Try binary coercion cast +CREATE CAST (text AS casttesttype) WITHOUT FUNCTION +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (text AS casttesttype) WITHOUT FUNCTION" +== 008 +-- truncate_limit: 100 +SELECT casttestfunc('foo'::text) +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT casttestfunc('foo'::text)" +== 009 +-- truncate_limit: 100 +-- doesn't work, as the cast is explicit +SELECT casttestfunc('foo'::text::casttesttype) +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT casttestfunc('foo'::text::casttesttype)" +== 010 +-- truncate_limit: 100 +-- should work +DROP CAST (text AS casttesttype) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST (text AS casttesttype)" +== 011 +-- truncate_limit: 100 +-- cleanup + +-- Try IMPLICIT binary coercion cast +CREATE CAST (text AS casttesttype) WITHOUT FUNCTION AS IMPLICIT +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (text AS casttesttype) WITHOUT FUNCTION AS IMPLICIT" +== 012 +-- truncate_limit: 100 +SELECT casttestfunc('foo'::text) +-- +FUNCTION: name="casttestfunc" function="casttestfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT casttestfunc('foo'::text)" +== 013 +-- truncate_limit: 100 +-- Should work now + +-- Try I/O conversion cast. +SELECT 1234::int4::casttesttype +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1234::int4::casttesttype" +== 014 +-- truncate_limit: 100 +-- No cast yet, should fail + +CREATE CAST (int4 AS casttesttype) WITH INOUT +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int4 AS casttesttype) WITH INOUT" +== 015 +-- truncate_limit: 100 +SELECT 1234::int4::casttesttype +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1234::int4::casttesttype" +== 016 +-- truncate_limit: 100 +-- Should work now + +DROP CAST (int4 AS casttesttype) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST (int4 AS casttesttype)" +== 017 +-- truncate_limit: 100 +-- Try cast with a function + +CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQL AS +$$ SELECT ('foo'::text || $1::text)::casttesttype; $$ +-- +FUNCTION: name="int4_casttesttype" function="int4_casttesttype" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE sql AS $$ SELECT ('foo'::te..." +== 018 +-- truncate_limit: 100 +CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT" +== 019 +-- truncate_limit: 100 +SELECT 1234::int4::casttesttype +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1234::int4::casttesttype" +== 020 +-- truncate_limit: 100 +-- Should work now + +DROP FUNCTION int4_casttesttype(int4) CASCADE +-- +FUNCTION: name="int4_casttesttype" function="int4_casttesttype" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION int4_casttesttype(int4) CASCADE" +== 021 +-- truncate_limit: 100 +-- Try it with a function that requires an implicit cast + +CREATE FUNCTION bar_int4_text(int4) RETURNS text LANGUAGE SQL AS +$$ SELECT ('bar'::text || $1::text); $$ +-- +FUNCTION: name="bar_int4_text" function="bar_int4_text" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bar_int4_text(int4) RETURNS text LANGUAGE sql AS $$ SELECT ('bar'::text || $1::te..." +== 022 +-- truncate_limit: 100 +CREATE CAST (int4 AS casttesttype) WITH FUNCTION bar_int4_text(int4) AS IMPLICIT +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int4 AS casttesttype) WITH FUNCTION bar_int4_text(int4) AS IMPLICIT" +== 023 +-- truncate_limit: 100 +SELECT 1234::int4::casttesttype +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1234::int4::casttesttype" +== 024 +-- truncate_limit: 100 +-- Should work now + +-- check dependencies generated for that +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_cast'::regclass AND + objid = (SELECT oid FROM pg_cast + WHERE castsource = 'int4'::regtype + AND casttarget = 'casttesttype'::regtype) +ORDER BY refclassid +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +FILTER: schema="" table="" column="castsource" +FILTER: schema="" table="" column="casttarget" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY refclassid" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_function_c.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_function_c.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_function_c.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_function_c.test b/parser/testdata/summary_truncate/postgres_regress/create_function_c.test new file mode 100644 index 0000000..8207bd8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_function_c.test @@ -0,0 +1,60 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_FUNCTION_C +|-- +-- This script used to create C functions for other scripts to use. +-- But to get rid of the ordering dependencies that caused, such +-- functions are now made either in test_setup.sql or in the specific +-- test script that needs them. All that remains here is error cases. + +-- directory path and dlsuffix are passed to us in environment variables + + +|-- +-- Check LOAD command. (The alternative of implicitly loading the library +-- is checked in many other test scripts.) +|-- +LOAD :'regresslib' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 507 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +-- Things that shouldn't work: + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C + AS 'nosuchfile' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test1(int) RETURNS int LANGUAGE c AS $$nosuchfile$$" +== 003 +-- truncate_limit: 100 +-- To produce stable regression test output, we have to filter the name +-- of the regresslib file out of the error message in this test. +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C + AS :'regresslib', 'nosuchsymbol' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 196 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +SELECT regexp_replace(:'LAST_ERROR_MESSAGE', 'file ".*"', 'file "..."') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- truncate_limit: 100 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal + AS 'nosuch' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test1(int) RETURNS int LANGUAGE internal AS $$nosuch$$" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_function_sql.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_function_sql.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_function_sql.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_function_sql.test b/parser/testdata/summary_truncate/postgres_regress/create_function_sql.test new file mode 100644 index 0000000..3f3ea95 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_function_sql.test @@ -0,0 +1,1288 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_FUNCTION_SQL +|-- +-- Assorted tests using SQL-language functions +|-- + +-- All objects made in this test are in temp_func_test schema + +CREATE USER regress_unpriv_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_unpriv_user" +== 002 +-- truncate_limit: 100 +CREATE SCHEMA temp_func_test +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA temp_func_test" +== 003 +-- truncate_limit: 100 +GRANT ALL ON SCHEMA temp_func_test TO public +-- +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON SCHEMA temp_func_test TO public" +== 004 +-- truncate_limit: 100 +SET search_path TO temp_func_test, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO temp_func_test, public" +== 005 +-- truncate_limit: 100 +|-- +-- Make sanity checks on the pg_proc entries created by CREATE FUNCTION +|-- + +|-- +-- ARGUMENT and RETURN TYPES +|-- +CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''' +-- +FUNCTION: name="functest_a_1" function="functest_a_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_a_1(text, date) RETURNS bool LANGUAGE sql AS $$SELECT $1 = 'abcd' AND $2..." +== 006 +-- truncate_limit: 100 +CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql' + AS 'SELECT $1[1]::int' +-- +FUNCTION: name="functest_a_2" function="functest_a_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_a_2(text[]) RETURNS int LANGUAGE sql AS $$SELECT $1[1]::int$$" +== 007 +-- truncate_limit: 100 +CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql' + AS 'SELECT false' +-- +FUNCTION: name="functest_a_3" function="functest_a_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_a_3() RETURNS bool LANGUAGE sql AS $$SELECT false$$" +== 008 +-- truncate_limit: 100 +SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc + WHERE oid in ('functest_A_1'::regproc, + 'functest_A_2'::regproc, + 'functest_A_3'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc WHERE ... ORDER BY proname" +== 009 +-- truncate_limit: 100 +SELECT functest_A_1('abcd', '2020-01-01') +-- +FUNCTION: name="functest_a_1" function="functest_a_1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_a_1('abcd', '2020-01-01')" +== 010 +-- truncate_limit: 100 +SELECT functest_A_2(ARRAY['1', '2', '3']) +-- +FUNCTION: name="functest_a_2" function="functest_a_2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_a_2(ARRAY['1', '2', '3'])" +== 011 +-- truncate_limit: 100 +SELECT functest_A_3() +-- +FUNCTION: name="functest_a_3" function="functest_a_3" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_a_3()" +== 012 +-- truncate_limit: 100 +|-- +-- IMMUTABLE | STABLE | VOLATILE +|-- +CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 > 0' +-- +FUNCTION: name="functest_b_1" function="functest_b_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_b_1(int) RETURNS bool LANGUAGE sql AS $$SELECT $1 > 0$$" +== 013 +-- truncate_limit: 100 +CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sql' + IMMUTABLE AS 'SELECT $1 > 0' +-- +FUNCTION: name="functest_b_2" function="functest_b_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_b_2(int) RETURNS bool LANGUAGE sql IMMUTABLE AS $$SELECT $1 > 0$$" +== 014 +-- truncate_limit: 100 +CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sql' + STABLE AS 'SELECT $1 = 0' +-- +FUNCTION: name="functest_b_3" function="functest_b_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_b_3(int) RETURNS bool LANGUAGE sql STABLE AS $$SELECT $1 = 0$$" +== 015 +-- truncate_limit: 100 +CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sql' + VOLATILE AS 'SELECT $1 < 0' +-- +FUNCTION: name="functest_b_4" function="functest_b_4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_b_4(int) RETURNS bool LANGUAGE sql VOLATILE AS $$SELECT $1 < 0$$" +== 016 +-- truncate_limit: 100 +SELECT proname, provolatile FROM pg_proc + WHERE oid in ('functest_B_1'::regproc, + 'functest_B_2'::regproc, + 'functest_B_3'::regproc, + 'functest_B_4'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, provolatile FROM pg_proc WHERE ... ORDER BY proname" +== 017 +-- truncate_limit: 100 +ALTER FUNCTION functest_B_2(int) VOLATILE +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_b_2(int) VOLATILE" +== 018 +-- truncate_limit: 100 +ALTER FUNCTION functest_B_3(int) COST 100 +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_b_3(int) COST 100" +== 019 +-- truncate_limit: 100 +-- unrelated change, no effect +SELECT proname, provolatile FROM pg_proc + WHERE oid in ('functest_B_1'::regproc, + 'functest_B_2'::regproc, + 'functest_B_3'::regproc, + 'functest_B_4'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, provolatile FROM pg_proc WHERE ... ORDER BY proname" +== 020 +-- truncate_limit: 100 +|-- +-- SECURITY DEFINER | INVOKER +|-- +CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 > 0' +-- +FUNCTION: name="functest_c_1" function="functest_c_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_c_1(int) RETURNS bool LANGUAGE sql AS $$SELECT $1 > 0$$" +== 021 +-- truncate_limit: 100 +CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql' + SECURITY DEFINER AS 'SELECT $1 = 0' +-- +FUNCTION: name="functest_c_2" function="functest_c_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_c_2(int) RETURNS bool LANGUAGE sql SECURITY DEFINER AS $$SELECT $1 = 0$$" +== 022 +-- truncate_limit: 100 +CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql' + SECURITY INVOKER AS 'SELECT $1 < 0' +-- +FUNCTION: name="functest_c_3" function="functest_c_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_c_3(int) RETURNS bool LANGUAGE sql SECURITY INVOKER AS $$SELECT $1 < 0$$" +== 023 +-- truncate_limit: 100 +SELECT proname, prosecdef FROM pg_proc + WHERE oid in ('functest_C_1'::regproc, + 'functest_C_2'::regproc, + 'functest_C_3'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, prosecdef FROM pg_proc WHERE ... ORDER BY proname" +== 024 +-- truncate_limit: 100 +ALTER FUNCTION functest_C_1(int) IMMUTABLE +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_c_1(int) IMMUTABLE" +== 025 +-- truncate_limit: 100 +-- unrelated change, no effect +ALTER FUNCTION functest_C_2(int) SECURITY INVOKER +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_c_2(int) SECURITY INVOKER" +== 026 +-- truncate_limit: 100 +ALTER FUNCTION functest_C_3(int) SECURITY DEFINER +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_c_3(int) SECURITY DEFINER" +== 027 +-- truncate_limit: 100 +SELECT proname, prosecdef FROM pg_proc + WHERE oid in ('functest_C_1'::regproc, + 'functest_C_2'::regproc, + 'functest_C_3'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, prosecdef FROM pg_proc WHERE ... ORDER BY proname" +== 028 +-- truncate_limit: 100 +|-- +-- LEAKPROOF +|-- +CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 > 100' +-- +FUNCTION: name="functest_e_1" function="functest_e_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_e_1(int) RETURNS bool LANGUAGE sql AS $$SELECT $1 > 100$$" +== 029 +-- truncate_limit: 100 +CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql' + LEAKPROOF AS 'SELECT $1 > 100' +-- +FUNCTION: name="functest_e_2" function="functest_e_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_e_2(int) RETURNS bool LANGUAGE sql LEAKPROOF AS $$SELECT $1 > 100$$" +== 030 +-- truncate_limit: 100 +SELECT proname, proleakproof FROM pg_proc + WHERE oid in ('functest_E_1'::regproc, + 'functest_E_2'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, proleakproof FROM pg_proc WHERE ... ORDER BY proname" +== 031 +-- truncate_limit: 100 +ALTER FUNCTION functest_E_1(int) LEAKPROOF +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_e_1(int) LEAKPROOF" +== 032 +-- truncate_limit: 100 +ALTER FUNCTION functest_E_2(int) STABLE +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_e_2(int) STABLE" +== 033 +-- truncate_limit: 100 +-- unrelated change, no effect +SELECT proname, proleakproof FROM pg_proc + WHERE oid in ('functest_E_1'::regproc, + 'functest_E_2'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, proleakproof FROM pg_proc WHERE ... ORDER BY proname" +== 034 +-- truncate_limit: 100 +ALTER FUNCTION functest_E_2(int) NOT LEAKPROOF +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_e_2(int) NOT LEAKPROOF" +== 035 +-- truncate_limit: 100 +-- remove leakproof attribute +SELECT proname, proleakproof FROM pg_proc + WHERE oid in ('functest_E_1'::regproc, + 'functest_E_2'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, proleakproof FROM pg_proc WHERE ... ORDER BY proname" +== 036 +-- truncate_limit: 100 +-- it takes superuser privilege to turn on leakproof, but not to turn off +ALTER FUNCTION functest_E_1(int) OWNER TO regress_unpriv_user +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FUNCTION functest_e_1(int) OWNER TO regress_unpriv_user" +== 037 +-- truncate_limit: 100 +ALTER FUNCTION functest_E_2(int) OWNER TO regress_unpriv_user +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FUNCTION functest_e_2(int) OWNER TO regress_unpriv_user" +== 038 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_unpriv_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_unpriv_user" +== 039 +-- truncate_limit: 100 +SET search_path TO temp_func_test, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO temp_func_test, public" +== 040 +-- truncate_limit: 100 +ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_e_1(int) NOT LEAKPROOF" +== 041 +-- truncate_limit: 100 +ALTER FUNCTION functest_E_2(int) LEAKPROOF +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_e_2(int) LEAKPROOF" +== 042 +-- truncate_limit: 100 +CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql' + LEAKPROOF AS 'SELECT $1 < 200' +-- +FUNCTION: name="functest_e_3" function="functest_e_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_e_3(int) RETURNS bool LANGUAGE sql LEAKPROOF AS $$SELECT $1 < 200$$" +== 043 +-- truncate_limit: 100 +-- fail + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 044 +-- truncate_limit: 100 +|-- +-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT +|-- +CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql' + AS 'SELECT $1 > 50' +-- +FUNCTION: name="functest_f_1" function="functest_f_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_f_1(int) RETURNS bool LANGUAGE sql AS $$SELECT $1 > 50$$" +== 045 +-- truncate_limit: 100 +CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql' + CALLED ON NULL INPUT AS 'SELECT $1 = 50' +-- +FUNCTION: name="functest_f_2" function="functest_f_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_f_2(int) RETURNS bool LANGUAGE sql CALLED ON NULL INPUT AS $$SELECT $1 =..." +== 046 +-- truncate_limit: 100 +CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql' + RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50' +-- +FUNCTION: name="functest_f_3" function="functest_f_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_f_3(int) RETURNS bool LANGUAGE sql RETURNS NULL ON NULL INPUT AS $$SELEC..." +== 047 +-- truncate_limit: 100 +CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql' + STRICT AS 'SELECT $1 = 50' +-- +FUNCTION: name="functest_f_4" function="functest_f_4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_f_4(int) RETURNS bool LANGUAGE sql RETURNS NULL ON NULL INPUT AS $$SELEC..." +== 048 +-- truncate_limit: 100 +SELECT proname, proisstrict FROM pg_proc + WHERE oid in ('functest_F_1'::regproc, + 'functest_F_2'::regproc, + 'functest_F_3'::regproc, + 'functest_F_4'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, proisstrict FROM pg_proc WHERE ... ORDER BY proname" +== 049 +-- truncate_limit: 100 +ALTER FUNCTION functest_F_1(int) IMMUTABLE +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_f_1(int) IMMUTABLE" +== 050 +-- truncate_limit: 100 +-- unrelated change, no effect +ALTER FUNCTION functest_F_2(int) STRICT +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_f_2(int) RETURNS NULL ON NULL INPUT" +== 051 +-- truncate_limit: 100 +ALTER FUNCTION functest_F_3(int) CALLED ON NULL INPUT +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION functest_f_3(int) CALLED ON NULL INPUT" +== 052 +-- truncate_limit: 100 +SELECT proname, proisstrict FROM pg_proc + WHERE oid in ('functest_F_1'::regproc, + 'functest_F_2'::regproc, + 'functest_F_3'::regproc, + 'functest_F_4'::regproc) ORDER BY proname +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT proname, proisstrict FROM pg_proc WHERE ... ORDER BY proname" +== 053 +-- truncate_limit: 100 +-- pg_get_functiondef tests + +SELECT pg_get_functiondef('functest_A_1'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_A_1'::regproc)" +== 054 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_B_3'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_B_3'::regproc)" +== 055 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_C_3'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_C_3'::regproc)" +== 056 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_F_2'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_F_2'::regproc)" +== 057 +-- truncate_limit: 100 +|-- +-- SQL-standard body +|-- +CREATE FUNCTION functest_S_1(a text, b date) RETURNS boolean + LANGUAGE SQL + RETURN a = 'abcd' AND b > '2001-01-01' +-- +FUNCTION: name="functest_s_1" function="functest_s_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_s_1(a text, b date) RETURNS boolean LANGUAGE sql RETURN a = 'abcd' AND b..." +== 058 +-- truncate_limit: 100 +CREATE FUNCTION functest_S_2(a text[]) RETURNS int + RETURN a[1]::int +-- +FUNCTION: name="functest_s_2" function="functest_s_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_s_2(a text[]) RETURNS int RETURN a[1]::int" +== 059 +-- truncate_limit: 100 +CREATE FUNCTION functest_S_3() RETURNS boolean + RETURN false +-- +FUNCTION: name="functest_s_3" function="functest_s_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_s_3() RETURNS boolean RETURN false" +== 060 +-- truncate_limit: 100 +CREATE FUNCTION functest_S_3a() RETURNS boolean + BEGIN ATOMIC +-- +ERROR: syntax error at end of input +CURSORPOS: 65 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 061 +-- truncate_limit: 100 +RETURN false +-- +ERROR: syntax error at or near "RETURN" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 062 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 063 +-- truncate_limit: 100 +CREATE FUNCTION functest_S_10(a text, b date) RETURNS boolean + LANGUAGE SQL + BEGIN ATOMIC + SELECT a = 'abcd' AND b > '2001-01-01' +-- +ERROR: syntax error at end of input +CURSORPOS: 143 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 064 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 065 +-- truncate_limit: 100 +CREATE FUNCTION functest_S_13() RETURNS boolean + BEGIN ATOMIC + SELECT 1 +-- +ERROR: syntax error at end of input +CURSORPOS: 82 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 066 +-- truncate_limit: 100 +SELECT false +-- +STMT: SelectStmt +TRUNCATED: "SELECT false" +== 067 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 068 +-- truncate_limit: 100 +-- check display of function arguments in sub-SELECT +CREATE TABLE functest1 (i int) +-- +TABLE: name="functest1" schema="" table="functest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE functest1 (i int)" +== 069 +-- truncate_limit: 100 +CREATE FUNCTION functest_S_16(a int, b int) RETURNS void + LANGUAGE SQL + BEGIN ATOMIC + INSERT INTO functest1 SELECT a + $2 +-- +ERROR: syntax error at end of input +CURSORPOS: 135 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 070 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 071 +-- truncate_limit: 100 +-- error: duplicate function body +CREATE FUNCTION functest_S_xxx(x int) RETURNS int + LANGUAGE SQL + AS $$ SELECT x * 2 $$ + RETURN x * 3 +-- +FUNCTION: name="functest_s_xxx" function="functest_s_xxx" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_s_xxx(x int) RETURNS int LANGUAGE sql AS $$ SELECT x * 2 $$ RETURN x * 3" +== 072 +-- truncate_limit: 100 +-- polymorphic arguments not allowed in this form +CREATE FUNCTION functest_S_xx(x anyarray) RETURNS anyelement + LANGUAGE SQL + RETURN x[1] +-- +FUNCTION: name="functest_s_xx" function="functest_s_xx" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_s_xx(x anyarray) RETURNS anyelement LANGUAGE sql RETURN x[1]" +== 073 +-- truncate_limit: 100 +-- check reporting of parse-analysis errors +CREATE FUNCTION functest_S_xx(x date) RETURNS boolean + LANGUAGE SQL + RETURN x > 1 +-- +FUNCTION: name="functest_s_xx" function="functest_s_xx" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_s_xx(x date) RETURNS boolean LANGUAGE sql RETURN x > 1" +== 074 +-- truncate_limit: 100 +-- tricky parsing +CREATE FUNCTION functest_S_15(x int) RETURNS boolean +LANGUAGE SQL +BEGIN ATOMIC + select case when x % 2 = 0 then true else false end +-- +ERROR: syntax error at end of input +CURSORPOS: 153 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 075 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 076 +-- truncate_limit: 100 +SELECT functest_S_1('abcd', '2020-01-01') +-- +FUNCTION: name="functest_s_1" function="functest_s_1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_s_1('abcd', '2020-01-01')" +== 077 +-- truncate_limit: 100 +SELECT functest_S_2(ARRAY['1', '2', '3']) +-- +FUNCTION: name="functest_s_2" function="functest_s_2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_s_2(ARRAY['1', '2', '3'])" +== 078 +-- truncate_limit: 100 +SELECT functest_S_3() +-- +FUNCTION: name="functest_s_3" function="functest_s_3" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_s_3()" +== 079 +-- truncate_limit: 100 +SELECT functest_S_10('abcd', '2020-01-01') +-- +FUNCTION: name="functest_s_10" function="functest_s_10" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_s_10('abcd', '2020-01-01')" +== 080 +-- truncate_limit: 100 +SELECT functest_S_13() +-- +FUNCTION: name="functest_s_13" function="functest_s_13" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_s_13()" +== 081 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_S_1'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_S_1'::regproc)" +== 082 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_S_2'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_S_2'::regproc)" +== 083 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_S_3'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_S_3'::regproc)" +== 084 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_S_3a'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_S_3a'::regproc)" +== 085 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_S_10'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_S_10'::regproc)" +== 086 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_S_13'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_S_13'::regproc)" +== 087 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_S_15'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_S_15'::regproc)" +== 088 +-- truncate_limit: 100 +SELECT pg_get_functiondef('functest_S_16'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('functest_S_16'::regproc)" +== 089 +-- truncate_limit: 100 +DROP TABLE functest1 CASCADE +-- +TABLE: name="functest1" schema="" table="functest1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE functest1 CASCADE" +== 090 +-- truncate_limit: 100 +-- test with views +CREATE TABLE functest3 (a int) +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE functest3 (a int)" +== 091 +-- truncate_limit: 100 +INSERT INTO functest3 VALUES (1), (2) +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO functest3 VALUES (1), (2)" +== 092 +-- truncate_limit: 100 +CREATE VIEW functestv3 AS SELECT * FROM functest3 +-- +TABLE: name="functestv3" schema="" table="functestv3" ctx=DDL +TABLE: name="functest3" schema="" table="functest3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW functestv3 AS SELECT * FROM functest3" +== 093 +-- truncate_limit: 100 +CREATE FUNCTION functest_S_14() RETURNS bigint + RETURN (SELECT count(*) FROM functestv3) +-- +FUNCTION: name="functest_s_14" function="functest_s_14" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_s_14() RETURNS bigint RETURN (SELECT count(*) FROM functestv3)" +== 094 +-- truncate_limit: 100 +SELECT functest_S_14() +-- +FUNCTION: name="functest_s_14" function="functest_s_14" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT functest_s_14()" +== 095 +-- truncate_limit: 100 +DROP TABLE functest3 CASCADE +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE functest3 CASCADE" +== 096 +-- truncate_limit: 100 +-- information_schema tests + +CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo') + RETURNS int + LANGUAGE SQL + AS 'SELECT $1 + $2' +-- +FUNCTION: name="functest_is_1" function="functest_is_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_is_1(a int, b int = 1, c text = 'foo') RETURNS int LANGUAGE sql AS $$SEL..." +== 097 +-- truncate_limit: 100 +CREATE FUNCTION functest_IS_2(out a int, b int default 1) + RETURNS int + LANGUAGE SQL + AS 'SELECT $1' +-- +FUNCTION: name="functest_is_2" function="functest_is_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_is_2(OUT a int, b int = 1) RETURNS int LANGUAGE sql AS $$SELECT $1$$" +== 098 +-- truncate_limit: 100 +CREATE FUNCTION functest_IS_3(a int default 1, out b int) + RETURNS int + LANGUAGE SQL + AS 'SELECT $1' +-- +FUNCTION: name="functest_is_3" function="functest_is_3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_is_3(a int = 1, OUT b int) RETURNS int LANGUAGE sql AS $$SELECT $1$$" +== 099 +-- truncate_limit: 100 +SELECT routine_name, ordinal_position, parameter_name, parameter_default + FROM information_schema.parameters JOIN information_schema.routines USING (specific_schema, specific_name) + WHERE routine_schema = 'temp_func_test' AND routine_name ~ '^functest_is_' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.parameters" schema="information_schema" table="parameters" ctx=Select +TABLE: name="information_schema.routines" schema="information_schema" table="routines" ctx=Select +FILTER: schema="" table="" column="routine_schema" +FILTER: schema="" table="" column="routine_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.parameters JOIN information_schema.routines USING (specific_sc..." +== 100 +-- truncate_limit: 100 +DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int) +-- +FUNCTION: name="functest_is_1" function="functest_is_1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION functest_is_1(int, int, text), functest_is_2(int), functest_is_3(int)" +== 101 +-- truncate_limit: 100 +-- routine usage views + +CREATE FUNCTION functest_IS_4a() RETURNS int LANGUAGE SQL AS 'SELECT 1' +-- +FUNCTION: name="functest_is_4a" function="functest_is_4a" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_is_4a() RETURNS int LANGUAGE sql AS $$SELECT 1$$" +== 102 +-- truncate_limit: 100 +CREATE FUNCTION functest_IS_4b(x int DEFAULT functest_IS_4a()) RETURNS int LANGUAGE SQL AS 'SELECT x' +-- +FUNCTION: name="functest_is_4b" function="functest_is_4b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_is_4b(x int = functest_is_4a()) RETURNS int LANGUAGE sql AS $$SELECT x$$" +== 103 +-- truncate_limit: 100 +CREATE SEQUENCE functest1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE functest1" +== 104 +-- truncate_limit: 100 +CREATE FUNCTION functest_IS_5(x int DEFAULT nextval('functest1')) + RETURNS int + LANGUAGE SQL + AS 'SELECT x' +-- +FUNCTION: name="functest_is_5" function="functest_is_5" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_is_5(x int = nextval('functest1')) RETURNS int LANGUAGE sql AS $$SELECT x$$" +== 105 +-- truncate_limit: 100 +CREATE FUNCTION functest_IS_6() + RETURNS int + LANGUAGE SQL + RETURN nextval('functest1') +-- +FUNCTION: name="functest_is_6" function="functest_is_6" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_is_6() RETURNS int LANGUAGE sql RETURN nextval('functest1')" +== 106 +-- truncate_limit: 100 +CREATE TABLE functest2 (a int, b int) +-- +TABLE: name="functest2" schema="" table="functest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE functest2 (a int, b int)" +== 107 +-- truncate_limit: 100 +CREATE FUNCTION functest_IS_7() + RETURNS int + LANGUAGE SQL + RETURN (SELECT count(a) FROM functest2) +-- +FUNCTION: name="functest_is_7" function="functest_is_7" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_is_7() RETURNS int LANGUAGE sql RETURN (SELECT count(a) FROM functest2)" +== 108 +-- truncate_limit: 100 +SELECT r0.routine_name, r1.routine_name + FROM information_schema.routine_routine_usage rru + JOIN information_schema.routines r0 ON r0.specific_name = rru.specific_name + JOIN information_schema.routines r1 ON r1.specific_name = rru.routine_name + WHERE r0.routine_schema = 'temp_func_test' AND + r1.routine_schema = 'temp_func_test' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.routine_routine_usage" schema="information_schema" table="routine_routine_usage" ctx=Select +TABLE: name="information_schema.routines" schema="information_schema" table="routines" ctx=Select +TABLE: name="information_schema.routines" schema="information_schema" table="routines" ctx=Select +ALIAS: "r0"="information_schema.routines" +ALIAS: "r1"="information_schema.routines" +ALIAS: "rru"="information_schema.routine_routine_usage" +FILTER: schema="" table="r0" column="routine_schema" +FILTER: schema="" table="r1" column="routine_schema" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.routine_routine_usage rru JOIN information_schema.routines r0 ..." +== 109 +-- truncate_limit: 100 +SELECT routine_name, sequence_name FROM information_schema.routine_sequence_usage + WHERE routine_schema = 'temp_func_test' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.routine_sequence_usage" schema="information_schema" table="routine_sequence_usage" ctx=Select +FILTER: schema="" table="" column="routine_schema" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.routine_sequence_usage WHERE ... ORDER BY 1, 2" +== 110 +-- truncate_limit: 100 +SELECT routine_name, table_name, column_name FROM information_schema.routine_column_usage + WHERE routine_schema = 'temp_func_test' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.routine_column_usage" schema="information_schema" table="routine_column_usage" ctx=Select +FILTER: schema="" table="" column="routine_schema" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.routine_column_usage WHERE ... ORDER BY 1, 2" +== 111 +-- truncate_limit: 100 +SELECT routine_name, table_name FROM information_schema.routine_table_usage + WHERE routine_schema = 'temp_func_test' + ORDER BY 1, 2 +-- +TABLE: name="information_schema.routine_table_usage" schema="information_schema" table="routine_table_usage" ctx=Select +FILTER: schema="" table="" column="routine_schema" +STMT: SelectStmt +TRUNCATED: "SELECT routine_name, table_name FROM information_schema.routine_table_usage WHERE ... ORDER BY 1, 2" +== 112 +-- truncate_limit: 100 +DROP FUNCTION functest_IS_4a CASCADE +-- +FUNCTION: name="functest_is_4a" function="functest_is_4a" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION functest_is_4a CASCADE" +== 113 +-- truncate_limit: 100 +DROP SEQUENCE functest1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE functest1 CASCADE" +== 114 +-- truncate_limit: 100 +DROP TABLE functest2 CASCADE +-- +TABLE: name="functest2" schema="" table="functest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE functest2 CASCADE" +== 115 +-- truncate_limit: 100 +-- overload +CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sql' + IMMUTABLE AS 'SELECT $1 > 0' +-- +FUNCTION: name="functest_b_2" function="functest_b_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_b_2(bigint) RETURNS bool LANGUAGE sql IMMUTABLE AS $$SELECT $1 > 0$$" +== 116 +-- truncate_limit: 100 +DROP FUNCTION functest_b_1 +-- +FUNCTION: name="functest_b_1" function="functest_b_1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION functest_b_1" +== 117 +-- truncate_limit: 100 +DROP FUNCTION functest_b_1 +-- +FUNCTION: name="functest_b_1" function="functest_b_1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION functest_b_1" +== 118 +-- truncate_limit: 100 +-- error, not found +DROP FUNCTION functest_b_2 +-- +FUNCTION: name="functest_b_2" function="functest_b_2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION functest_b_2" +== 119 +-- truncate_limit: 100 +-- error, ambiguous + + +-- CREATE OR REPLACE tests + +CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL AS 'SELECT $1' +-- +FUNCTION: name="functest1" function="functest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE sql AS $$SELECT $1$$" +== 120 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL WINDOW AS 'SELECT $1' +-- +FUNCTION: name="functest1" function="functest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE sql WINDOW AS $$SELECT $1$$" +== 121 +-- truncate_limit: 100 +CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQL AS 'SELECT $1' +-- +FUNCTION: name="functest1" function="functest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE sql AS $$SELECT $1$$" +== 122 +-- truncate_limit: 100 +DROP FUNCTION functest1(a int) +-- +FUNCTION: name="functest1" function="functest1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION functest1(a int)" +== 123 +-- truncate_limit: 100 +-- inlining of set-returning functions + +CREATE TABLE functest3 (a int) +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE functest3 (a int)" +== 124 +-- truncate_limit: 100 +INSERT INTO functest3 VALUES (1), (2), (3) +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO functest3 VALUES (1), (2), (3)" +== 125 +-- truncate_limit: 100 +CREATE FUNCTION functest_sri1() RETURNS SETOF int +LANGUAGE SQL +STABLE +AS ' + SELECT * FROM functest3; +' +-- +FUNCTION: name="functest_sri1" function="functest_sri1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION functest_sri1() RETURNS SETOF int LANGUAGE sql STABLE AS $$\n SELECT * FROM fun..." +== 126 +-- truncate_limit: 100 +SELECT * FROM functest_sri1() +-- +FUNCTION: name="functest_sri1" function="functest_sri1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM functest_sri1()" +== 127 +-- truncate_limit: 100 +EXPLAIN (verbose, costs off) SELECT * FROM functest_sri1() +-- +FUNCTION: name="functest_sri1" function="functest_sri1" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM functest_sri1()" +== 128 +-- truncate_limit: 100 +CREATE FUNCTION functest_sri2() RETURNS SETOF int +LANGUAGE SQL +STABLE +BEGIN ATOMIC + SELECT * FROM functest3 +-- +ERROR: syntax error at end of input +CURSORPOS: 111 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 129 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 130 +-- truncate_limit: 100 +SELECT * FROM functest_sri2() +-- +FUNCTION: name="functest_sri2" function="functest_sri2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM functest_sri2()" +== 131 +-- truncate_limit: 100 +EXPLAIN (verbose, costs off) SELECT * FROM functest_sri2() +-- +FUNCTION: name="functest_sri2" function="functest_sri2" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM functest_sri2()" +== 132 +-- truncate_limit: 100 +DROP TABLE functest3 CASCADE +-- +TABLE: name="functest3" schema="" table="functest3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE functest3 CASCADE" +== 133 +-- truncate_limit: 100 +-- Check behavior of VOID-returning SQL functions + +CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQL AS +$$ SELECT a + 1 $$ +-- +FUNCTION: name="voidtest1" function="voidtest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION voidtest1(a int) RETURNS void LANGUAGE sql AS $$ SELECT a + 1 $$" +== 134 +-- truncate_limit: 100 +SELECT voidtest1(42) +-- +FUNCTION: name="voidtest1" function="voidtest1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT voidtest1(42)" +== 135 +-- truncate_limit: 100 +CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQL AS +$$ SELECT voidtest1(a + b) $$ +-- +FUNCTION: name="voidtest2" function="voidtest2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION voidtest2(a int, b int) RETURNS void LANGUAGE sql AS $$ SELECT voidtest1(a + b) $$" +== 136 +-- truncate_limit: 100 +SELECT voidtest2(11,22) +-- +FUNCTION: name="voidtest2" function="voidtest2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT voidtest2(11, 22)" +== 137 +-- truncate_limit: 100 +-- currently, we can inline voidtest2 but not voidtest1 +EXPLAIN (verbose, costs off) SELECT voidtest2(11,22) +-- +FUNCTION: name="voidtest2" function="voidtest2" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT voidtest2(11, 22)" +== 138 +-- truncate_limit: 100 +CREATE TEMP TABLE sometable(f1 int) +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE sometable (f1 int)" +== 139 +-- truncate_limit: 100 +CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQL AS +$$ INSERT INTO sometable VALUES(a + 1) $$ +-- +FUNCTION: name="voidtest3" function="voidtest3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION voidtest3(a int) RETURNS void LANGUAGE sql AS $$ INSERT INTO sometable VALUES(a +..." +== 140 +-- truncate_limit: 100 +SELECT voidtest3(17) +-- +FUNCTION: name="voidtest3" function="voidtest3" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT voidtest3(17)" +== 141 +-- truncate_limit: 100 +CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQL AS +$$ INSERT INTO sometable VALUES(a - 1) RETURNING f1 $$ +-- +FUNCTION: name="voidtest4" function="voidtest4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION voidtest4(a int) RETURNS void LANGUAGE sql AS $$ INSERT INTO sometable VALUES(a -..." +== 142 +-- truncate_limit: 100 +SELECT voidtest4(39) +-- +FUNCTION: name="voidtest4" function="voidtest4" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT voidtest4(39)" +== 143 +-- truncate_limit: 100 +TABLE sometable +-- +TABLE: name="sometable" schema="" table="sometable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sometable" +== 144 +-- truncate_limit: 100 +CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQL AS +$$ SELECT generate_series(1, a) $$ STABLE +-- +FUNCTION: name="voidtest5" function="voidtest5" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION voidtest5(a int) RETURNS SETOF void LANGUAGE sql AS $$ SELECT generate_series(1, ..." +== 145 +-- truncate_limit: 100 +SELECT * FROM voidtest5(3) +-- +FUNCTION: name="voidtest5" function="voidtest5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM voidtest5(3)" +== 146 +-- truncate_limit: 100 +-- Regression tests for bugs: + +-- Check that arguments that are R/W expanded datums aren't corrupted by +-- multiple uses. This test knows that array_append() returns a R/W datum +-- and will modify a R/W array input in-place. We use SETOF to prevent +-- inlining of the SQL function. +CREATE FUNCTION double_append(anyarray, anyelement) RETURNS SETOF anyarray +LANGUAGE SQL IMMUTABLE AS +$$ SELECT array_append($1, $2) || array_append($1, $2) $$ +-- +FUNCTION: name="double_append" function="double_append" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION double_append(anyarray, anyelement) RETURNS SETOF anyarray LANGUAGE sql IMMUTABLE..." +== 147 +-- truncate_limit: 100 +SELECT double_append(array_append(ARRAY[q1], q2), q3) + FROM (VALUES(1,2,3), (4,5,6)) v(q1,q2,q3) +-- +FUNCTION: name="double_append" function="double_append" schema="" ctx=Call +FUNCTION: name="array_append" function="array_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT double_append(array_append(ARRAY[q1], q2), q3) FROM (VALUES (...)) v(q1, q2, q3)" +== 148 +-- truncate_limit: 100 +-- Things that shouldn't work: + +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT ''not an integer'';' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test1(int) RETURNS int LANGUAGE sql AS $$SELECT 'not an integer';$$" +== 149 +-- truncate_limit: 100 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'not even SQL' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test1(int) RETURNS int LANGUAGE sql AS $$not even SQL$$" +== 150 +-- truncate_limit: 100 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT 1, 2, 3;' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test1(int) RETURNS int LANGUAGE sql AS $$SELECT 1, 2, 3;$$" +== 151 +-- truncate_limit: 100 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'SELECT $2;' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test1(int) RETURNS int LANGUAGE sql AS $$SELECT $2;$$" +== 152 +-- truncate_limit: 100 +CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL + AS 'a', 'b' +-- +FUNCTION: name="test1" function="test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test1(int) RETURNS int LANGUAGE sql AS $$a$$, $$b$$" +== 153 +-- truncate_limit: 100 +-- Cleanup +DROP SCHEMA temp_func_test CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA temp_func_test CASCADE" +== 154 +-- truncate_limit: 100 +DROP USER regress_unpriv_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_unpriv_user" +== 155 +-- truncate_limit: 100 +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_index.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_index.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_index.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_index.test b/parser/testdata/summary_truncate/postgres_regress/create_index.test new file mode 100644 index 0000000..c19843a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_index.test @@ -0,0 +1,5129 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_INDEX +-- Create ancillary data structures (i.e. indices) +|-- + +-- directory paths are passed to us in environment variables + +|-- +-- BTREE +|-- +CREATE INDEX onek_unique1 ON onek USING btree(unique1 int4_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX onek_unique1 ON onek USING btree (unique1 int4_ops)" +== 002 +-- truncate_limit: 100 +CREATE INDEX IF NOT EXISTS onek_unique1 ON onek USING btree(unique1 int4_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX IF NOT EXISTS onek_unique1 ON onek USING btree (unique1 int4_ops)" +== 003 +-- truncate_limit: 100 +CREATE INDEX IF NOT EXISTS ON onek USING btree(unique1 int4_ops) +-- +ERROR: syntax error at or near "ON" +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +CREATE INDEX onek_unique2 ON onek USING btree(unique2 int4_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX onek_unique2 ON onek USING btree (unique2 int4_ops)" +== 005 +-- truncate_limit: 100 +CREATE INDEX onek_hundred ON onek USING btree(hundred int4_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX onek_hundred ON onek USING btree (hundred int4_ops)" +== 006 +-- truncate_limit: 100 +CREATE INDEX onek_stringu1 ON onek USING btree(stringu1 name_ops) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX onek_stringu1 ON onek USING btree (stringu1 name_ops)" +== 007 +-- truncate_limit: 100 +CREATE INDEX tenk1_unique1 ON tenk1 USING btree(unique1 int4_ops) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tenk1_unique1 ON tenk1 USING btree (unique1 int4_ops)" +== 008 +-- truncate_limit: 100 +CREATE INDEX tenk1_unique2 ON tenk1 USING btree(unique2 int4_ops) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tenk1_unique2 ON tenk1 USING btree (unique2 int4_ops)" +== 009 +-- truncate_limit: 100 +CREATE INDEX tenk1_hundred ON tenk1 USING btree(hundred int4_ops) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tenk1_hundred ON tenk1 USING btree (hundred int4_ops)" +== 010 +-- truncate_limit: 100 +CREATE INDEX tenk1_thous_tenthous ON tenk1 (thousand, tenthous) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tenk1_thous_tenthous ON tenk1 USING btree (thousand, tenthous)" +== 011 +-- truncate_limit: 100 +CREATE INDEX tenk2_unique1 ON tenk2 USING btree(unique1 int4_ops) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tenk2_unique1 ON tenk2 USING btree (unique1 int4_ops)" +== 012 +-- truncate_limit: 100 +CREATE INDEX tenk2_unique2 ON tenk2 USING btree(unique2 int4_ops) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tenk2_unique2 ON tenk2 USING btree (unique2 int4_ops)" +== 013 +-- truncate_limit: 100 +CREATE INDEX tenk2_hundred ON tenk2 USING btree(hundred int4_ops) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tenk2_hundred ON tenk2 USING btree (hundred int4_ops)" +== 014 +-- truncate_limit: 100 +CREATE INDEX rix ON road USING btree (name text_ops) +-- +TABLE: name="road" schema="" table="road" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX rix ON road USING btree (name text_ops)" +== 015 +-- truncate_limit: 100 +CREATE INDEX iix ON ihighway USING btree (name text_ops) +-- +TABLE: name="ihighway" schema="" table="ihighway" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iix ON ihighway USING btree (name text_ops)" +== 016 +-- truncate_limit: 100 +CREATE INDEX six ON shighway USING btree (name text_ops) +-- +TABLE: name="shighway" schema="" table="shighway" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX six ON shighway USING btree (name text_ops)" +== 017 +-- truncate_limit: 100 +-- test comments +COMMENT ON INDEX six_wrong IS 'bad index' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX six_wrong IS 'bad index'" +== 018 +-- truncate_limit: 100 +COMMENT ON INDEX six IS 'good index' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX six IS 'good index'" +== 019 +-- truncate_limit: 100 +COMMENT ON INDEX six IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX six IS NULL" +== 020 +-- truncate_limit: 100 +|-- +-- BTREE partial indices +|-- +CREATE INDEX onek2_u1_prtl ON onek2 USING btree(unique1 int4_ops) + where unique1 < 20 or unique1 > 980 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX onek2_u1_prtl ON onek2 USING btree (unique1 int4_ops) WHERE ..." +== 021 +-- truncate_limit: 100 +CREATE INDEX onek2_u2_prtl ON onek2 USING btree(unique2 int4_ops) + where stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX onek2_u2_prtl ON onek2 USING btree (unique2 int4_ops) WHERE stringu1 < 'B'" +== 022 +-- truncate_limit: 100 +CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops) + where onek2.stringu1 >= 'J' and onek2.stringu1 < 'K' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX onek2_stu1_prtl ON onek2 USING btree (stringu1 name_ops) WHERE ..." +== 023 +-- truncate_limit: 100 +|-- +-- GiST (rtree-equivalent opclasses only) +|-- + +CREATE TABLE slow_emp4000 ( + home_base box +) +-- +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE slow_emp4000 (home_base box)" +== 024 +-- truncate_limit: 100 +CREATE TABLE fast_emp4000 ( + home_base box +) +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fast_emp4000 (home_base box)" +== 025 +-- truncate_limit: 100 +COPY slow_emp4000 FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 026 +-- truncate_limit: 100 +INSERT INTO fast_emp4000 SELECT * FROM slow_emp4000 +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DML +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fast_emp4000 SELECT * FROM slow_emp4000" +== 027 +-- truncate_limit: 100 +ANALYZE slow_emp4000 +-- +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE slow_emp4000" +== 028 +-- truncate_limit: 100 +ANALYZE fast_emp4000 +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE fast_emp4000" +== 029 +-- truncate_limit: 100 +CREATE INDEX grect2ind ON fast_emp4000 USING gist (home_base) +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX grect2ind ON fast_emp4000 USING gist (home_base)" +== 030 +-- truncate_limit: 100 +-- we want to work with a point_tbl that includes a null +CREATE TEMP TABLE point_tbl AS SELECT * FROM public.point_tbl +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DDL +TABLE: name="public.point_tbl" schema="public" table="point_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE point_tbl AS SELECT * FROM public.point_tbl" +== 031 +-- truncate_limit: 100 +INSERT INTO POINT_TBL(f1) VALUES (NULL) +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1) VALUES (NULL)" +== 032 +-- truncate_limit: 100 +CREATE INDEX gpointind ON point_tbl USING gist (f1) +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gpointind ON point_tbl USING gist (f1)" +== 033 +-- truncate_limit: 100 +CREATE TEMP TABLE gpolygon_tbl AS + SELECT polygon(home_base) AS f1 FROM slow_emp4000 +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=DDL +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE gpolygon_tbl AS SELECT polygon(home_base) AS f1 FROM slow_emp4000" +== 034 +-- truncate_limit: 100 +INSERT INTO gpolygon_tbl VALUES ( '(1000,0,0,1000)' ) +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gpolygon_tbl VALUES ('(1000,0,0,1000)')" +== 035 +-- truncate_limit: 100 +INSERT INTO gpolygon_tbl VALUES ( '(0,1000,1000,1000)' ) +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gpolygon_tbl VALUES ('(0,1000,1000,1000)')" +== 036 +-- truncate_limit: 100 +CREATE TEMP TABLE gcircle_tbl AS + SELECT circle(home_base) AS f1 FROM slow_emp4000 +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=DDL +TABLE: name="slow_emp4000" schema="" table="slow_emp4000" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE gcircle_tbl AS SELECT circle(home_base) AS f1 FROM slow_emp4000" +== 037 +-- truncate_limit: 100 +CREATE INDEX ggpolygonind ON gpolygon_tbl USING gist (f1) +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ggpolygonind ON gpolygon_tbl USING gist (f1)" +== 038 +-- truncate_limit: 100 +CREATE INDEX ggcircleind ON gcircle_tbl USING gist (f1) +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ggcircleind ON gcircle_tbl USING gist (f1)" +== 039 +-- truncate_limit: 100 +|-- +-- Test GiST indexes +|-- + +-- get non-indexed results for comparison purposes + +SET enable_seqscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 040 +-- truncate_limit: 100 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 041 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 042 +-- truncate_limit: 100 +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fast_emp4000 WHERE ... ORDER BY (home_base[0])[0]" +== 043 +-- truncate_limit: 100 +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box" +== 044 +-- truncate_limit: 100 +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL" +== 045 +-- truncate_limit: 100 +SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon" +== 046 +-- truncate_limit: 100 +SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle" +== 047 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl WHERE f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl WHERE f1 <@ '(0,0,100,100)'::box" +== 048 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl WHERE box '(0,0,100,100)' @> f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl WHERE '(0,0,100,100)'::box @> f1" +== 049 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl WHERE f1 <@ polygon '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl WHERE f1 <@ '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)'::polygon" +== 050 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl WHERE f1 <@ circle '<(50,50),50>' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl WHERE f1 <@ '<(50,50),50>'::circle" +== 051 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)'" +== 052 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)'" +== 053 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)'" +== 054 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)'" +== 055 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)'" +== 056 +-- truncate_limit: 100 +SELECT * FROM point_tbl ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl ORDER BY f1 <-> '0,1'" +== 057 +-- truncate_limit: 100 +SELECT * FROM point_tbl WHERE f1 IS NULL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl WHERE f1 IS NULL" +== 058 +-- truncate_limit: 100 +SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1'" +== 059 +-- truncate_limit: 100 +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)'::box ORDER BY f1 <-> '0,1'" +== 060 +-- truncate_limit: 100 +SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10 +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10" +== 061 +-- truncate_limit: 100 +SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10 +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="circle_center" function="circle_center" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="radius" function="radius" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10" +== 062 +-- truncate_limit: 100 +-- Now check the results from plain indexscan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 063 +-- truncate_limit: 100 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 064 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 065 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM fast_emp4000 WHERE home_base <@ '(200,200),(2000,1000)'::box OR..." +== 066 +-- truncate_limit: 100 +SELECT * FROM fast_emp4000 + WHERE home_base <@ '(200,200),(2000,1000)'::box + ORDER BY (home_base[0])[0] +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fast_emp4000 WHERE ... ORDER BY (home_base[0])[0]" +== 067 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box" +== 068 +-- truncate_limit: 100 +SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box" +== 069 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL" +== 070 +-- truncate_limit: 100 +SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL +-- +TABLE: name="fast_emp4000" schema="" table="fast_emp4000" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="home_base" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fast_emp4000 WHERE home_base IS NULL" +== 071 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon" +== 072 +-- truncate_limit: 100 +SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon" +== 073 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle" +== 074 +-- truncate_limit: 100 +SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle" +== 075 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl WHERE f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl WHERE f1 <@ '(0,0,100,100)'::box" +== 076 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl WHERE f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl WHERE f1 <@ '(0,0,100,100)'::box" +== 077 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl WHERE box '(0,0,100,100)' @> f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl WHERE '(0,0,100,100)'::box @> f1" +== 078 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl WHERE box '(0,0,100,100)' @> f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl WHERE '(0,0,100,100)'::box @> f1" +== 079 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl WHERE f1 <@ polygon '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl WHERE f1 <@ '(0,0),(0,100),(100,100),(50,50),(..." +== 080 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl WHERE f1 <@ polygon '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl WHERE f1 <@ '(0,0),(0,100),(100,100),(50,50),(100,0),(0,0)'::polygon" +== 081 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl WHERE f1 <@ circle '<(50,50),50>' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl WHERE f1 <@ '<(50,50),50>'::circle" +== 082 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl WHERE f1 <@ circle '<(50,50),50>' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl WHERE f1 <@ '<(50,50),50>'::circle" +== 083 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)'" +== 084 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)'" +== 085 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)'" +== 086 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 >> '(0.0, 0.0)'" +== 087 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)'" +== 088 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)'" +== 089 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)'" +== 090 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 |>> '(0.0, 0.0)'" +== 091 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)'" +== 092 +-- truncate_limit: 100 +SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_tbl p WHERE p.f1 ~= '(-5, -12)'" +== 093 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM point_tbl ORDER BY f1 <-> '0,1'" +== 094 +-- truncate_limit: 100 +SELECT * FROM point_tbl ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl ORDER BY f1 <-> '0,1'" +== 095 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl WHERE f1 IS NULL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM point_tbl WHERE f1 IS NULL" +== 096 +-- truncate_limit: 100 +SELECT * FROM point_tbl WHERE f1 IS NULL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl WHERE f1 IS NULL" +== 097 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1'" +== 098 +-- truncate_limit: 100 +SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl WHERE f1 IS NOT NULL ORDER BY f1 <-> '0,1'" +== 099 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)'::box ORDER BY f1 <-> ..." +== 100 +-- truncate_limit: 100 +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)'::box ORDER BY f1 <-> '0,1'" +== 101 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10 +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10" +== 102 +-- truncate_limit: 100 +SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10 +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gpolygon_tbl ORDER BY f1 <-> '(0,0)'::point LIMIT 10" +== 103 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10 +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="circle_center" function="circle_center" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="radius" function="radius" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT circle_center(f1), round(radius(f1)) AS radius FROM gcircle_tbl ORDER ..." +== 104 +-- truncate_limit: 100 +SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10 +-- +TABLE: name="gcircle_tbl" schema="" table="gcircle_tbl" ctx=Select +FUNCTION: name="circle_center" function="circle_center" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="radius" function="radius" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10" +== 105 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT point(x,x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x,x) LIMIT 1) as c FROM generate_series(0,10,1) x +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT point(x, x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x, x) ..." +== 106 +-- truncate_limit: 100 +SELECT point(x,x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x,x) LIMIT 1) as c FROM generate_series(0,10,1) x +-- +TABLE: name="gpolygon_tbl" schema="" table="gpolygon_tbl" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(0, 10, 1) x" +== 107 +-- truncate_limit: 100 +-- Now check the results from bitmap indexscan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 108 +-- truncate_limit: 100 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 109 +-- truncate_limit: 100 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 110 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)'::box ORDER BY f1 <-> ..." +== 111 +-- truncate_limit: 100 +SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)'::box ORDER BY f1 <-> '0,1'" +== 112 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 113 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 114 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 115 +-- truncate_limit: 100 +|-- +-- GIN over int[] and text[] +|-- +-- Note: GIN currently supports only bitmap scans, not plain indexscans +|-- + +CREATE TABLE array_index_op_test ( + seqno int4, + i int4[], + t text[] +) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE array_index_op_test (seqno int4, i int4[], t text[])" +== 116 +-- truncate_limit: 100 +COPY array_index_op_test FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 31 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 117 +-- truncate_limit: 100 +ANALYZE array_index_op_test +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE array_index_op_test" +== 118 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i = '{NULL}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i = '{NULL}' ORDER BY seqno" +== 119 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i @> '{NULL}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i @> '{NULL}' ORDER BY seqno" +== 120 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i && '{NULL}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i && '{NULL}' ORDER BY seqno" +== 121 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i <@ '{NULL}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i <@ '{NULL}' ORDER BY seqno" +== 122 +-- truncate_limit: 100 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 123 +-- truncate_limit: 100 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 124 +-- truncate_limit: 100 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 125 +-- truncate_limit: 100 +CREATE INDEX intarrayidx ON array_index_op_test USING gin (i) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX intarrayidx ON array_index_op_test USING gin (i)" +== 126 +-- truncate_limit: 100 +explain (costs off) +SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno" +== 127 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno" +== 128 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i && '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i && '{32}' ORDER BY seqno" +== 129 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i @> '{17}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i @> '{17}' ORDER BY seqno" +== 130 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i && '{17}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i && '{17}' ORDER BY seqno" +== 131 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i @> '{32,17}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i @> '{32,17}' ORDER BY seqno" +== 132 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i && '{32,17}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i && '{32,17}' ORDER BY seqno" +== 133 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i <@ '{38,34,32,89}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i <@ '{38,34,32,89}' ORDER BY seqno" +== 134 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i = '{47,77}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i = '{47,77}' ORDER BY seqno" +== 135 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i = '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i = '{}' ORDER BY seqno" +== 136 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i @> '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i @> '{}' ORDER BY seqno" +== 137 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i && '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i && '{}' ORDER BY seqno" +== 138 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i <@ '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i <@ '{}' ORDER BY seqno" +== 139 +-- truncate_limit: 100 +CREATE INDEX textarrayidx ON array_index_op_test USING gin (t) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX textarrayidx ON array_index_op_test USING gin (t)" +== 140 +-- truncate_limit: 100 +explain (costs off) +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno" +== 141 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908}' ORDER BY seqno" +== 142 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAA72908}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAA72908}' ORDER BY seqno" +== 143 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAAAA646}' ORDER BY seqno" +== 144 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAAAA646}' ORDER BY seqno" +== 145 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno" +== 146 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t && '{AAAAAAAA72908,AAAAAAAAAA646}' ORDER BY seqno" +== 147 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t <@ '{AAAAAAAA72908,AAAAAAAAAAAAAAAAAAA17075,AA88409,AAAAAAAAAAAAAAAAAA36842,AAAAAAA48038,AAAAAAAAAAAAAA10611}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE ... ORDER BY seqno" +== 148 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t = '{AAAAAAAAAA646,A87088}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t = '{AAAAAAAAAA646,A87088}' ORDER BY seqno" +== 149 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t = '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t = '{}' ORDER BY seqno" +== 150 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t @> '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t @> '{}' ORDER BY seqno" +== 151 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t && '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t && '{}' ORDER BY seqno" +== 152 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t <@ '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t <@ '{}' ORDER BY seqno" +== 153 +-- truncate_limit: 100 +-- And try it with a multicolumn GIN index + +DROP INDEX intarrayidx, textarrayidx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX intarrayidx, textarrayidx" +== 154 +-- truncate_limit: 100 +CREATE INDEX botharrayidx ON array_index_op_test USING gin (i, t) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX botharrayidx ON array_index_op_test USING gin (i, t)" +== 155 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i @> '{32}' ORDER BY seqno" +== 156 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i && '{32}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i && '{32}' ORDER BY seqno" +== 157 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAA80240}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t @> '{AAAAAAA80240}' ORDER BY seqno" +== 158 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t && '{AAAAAAA80240}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t && '{AAAAAAA80240}' ORDER BY seqno" +== 159 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i @> '{32}' AND t && '{AAAAAAA80240}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i @> '{32}' AND t && '{AAAAAAA80240}' ORDER BY seqno" +== 160 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE i && '{32}' AND t @> '{AAAAAAA80240}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE i && '{32}' AND t @> '{AAAAAAA80240}' ORDER BY seqno" +== 161 +-- truncate_limit: 100 +SELECT * FROM array_index_op_test WHERE t = '{}' ORDER BY seqno +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=Select +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_index_op_test WHERE t = '{}' ORDER BY seqno" +== 162 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 163 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 164 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 165 +-- truncate_limit: 100 +|-- +-- Try a GIN index with a lot of items with same key. (GIN creates a posting +-- tree when there are enough duplicates) +|-- +CREATE TABLE array_gin_test (a int[]) +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE array_gin_test (a int[])" +== 166 +-- truncate_limit: 100 +INSERT INTO array_gin_test SELECT ARRAY[1, g%5, g] FROM generate_series(1, 10000) g +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO array_gin_test SELECT ARRAY[1, g % 5, g] FROM generate_series(1, 10000) g" +== 167 +-- truncate_limit: 100 +CREATE INDEX array_gin_test_idx ON array_gin_test USING gin (a) +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX array_gin_test_idx ON array_gin_test USING gin (a)" +== 168 +-- truncate_limit: 100 +SELECT COUNT(*) FROM array_gin_test WHERE a @> '{2}' +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM array_gin_test WHERE a @> '{2}'" +== 169 +-- truncate_limit: 100 +DROP TABLE array_gin_test +-- +TABLE: name="array_gin_test" schema="" table="array_gin_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE array_gin_test" +== 170 +-- truncate_limit: 100 +|-- +-- Test GIN index's reloptions +|-- +CREATE INDEX gin_relopts_test ON array_index_op_test USING gin (i) + WITH (FASTUPDATE=on, GIN_PENDING_LIST_LIMIT=128) +-- +TABLE: name="array_index_op_test" schema="" table="array_index_op_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gin_relopts_test ON array_index_op_test USING gin (i) WITH (fastupdate=on, gin_pendi..." +== 171 +-- truncate_limit: 100 +|-- +-- HASH +|-- +CREATE UNLOGGED TABLE unlogged_hash_table (id int4) +-- +TABLE: name="unlogged_hash_table" schema="" table="unlogged_hash_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE unlogged_hash_table (id int4)" +== 172 +-- truncate_limit: 100 +CREATE INDEX unlogged_hash_index ON unlogged_hash_table USING hash (id int4_ops) +-- +TABLE: name="unlogged_hash_table" schema="" table="unlogged_hash_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX unlogged_hash_index ON unlogged_hash_table USING hash (id int4_ops)" +== 173 +-- truncate_limit: 100 +DROP TABLE unlogged_hash_table +-- +TABLE: name="unlogged_hash_table" schema="" table="unlogged_hash_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unlogged_hash_table" +== 174 +-- truncate_limit: 100 +-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops); + +-- Test hash index build tuplesorting. Force hash tuplesort using low +-- maintenance_work_mem setting and fillfactor: +SET maintenance_work_mem = '1MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET maintenance_work_mem TO \"1MB\"" +== 175 +-- truncate_limit: 100 +CREATE INDEX hash_tuplesort_idx ON tenk1 USING hash (stringu1 name_ops) WITH (fillfactor = 10) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_tuplesort_idx ON tenk1 USING hash (stringu1 name_ops) WITH (fillfactor=10)" +== 176 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA'" +== 177 +-- truncate_limit: 100 +SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 WHERE stringu1 = 'TVAAAA'" +== 178 +-- truncate_limit: 100 +DROP INDEX hash_tuplesort_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX hash_tuplesort_idx" +== 179 +-- truncate_limit: 100 +RESET maintenance_work_mem +-- +STMT: VariableSetStmt +TRUNCATED: "RESET maintenance_work_mem" +== 180 +-- truncate_limit: 100 +|-- +-- Test unique null behavior +|-- +CREATE TABLE unique_tbl (i int, t text) +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unique_tbl (i int, t text)" +== 181 +-- truncate_limit: 100 +CREATE UNIQUE INDEX unique_idx1 ON unique_tbl (i) NULLS DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX unique_idx1 ON unique_tbl USING btree (i)" +== 182 +-- truncate_limit: 100 +CREATE UNIQUE INDEX unique_idx2 ON unique_tbl (i) NULLS NOT DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX unique_idx2 ON unique_tbl USING btree (i) NULLS NOT DISTINCT" +== 183 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (1, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (1, 'one')" +== 184 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (2, 'two') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (2, 'two')" +== 185 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (3, 'three') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (3, 'three')" +== 186 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (4, 'four') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (4, 'four')" +== 187 +-- truncate_limit: 100 +INSERT INTO unique_tbl VALUES (5, 'one') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl VALUES (5, 'one')" +== 188 +-- truncate_limit: 100 +INSERT INTO unique_tbl (t) VALUES ('six') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('six')" +== 189 +-- truncate_limit: 100 +INSERT INTO unique_tbl (t) VALUES ('seven') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('seven')" +== 190 +-- truncate_limit: 100 +-- error from unique_idx2 + +DROP INDEX unique_idx1, unique_idx2 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX unique_idx1, unique_idx2" +== 191 +-- truncate_limit: 100 +INSERT INTO unique_tbl (t) VALUES ('seven') +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unique_tbl (t) VALUES ('seven')" +== 192 +-- truncate_limit: 100 +-- build indexes on filled table +CREATE UNIQUE INDEX unique_idx3 ON unique_tbl (i) NULLS DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX unique_idx3 ON unique_tbl USING btree (i)" +== 193 +-- truncate_limit: 100 +-- ok +CREATE UNIQUE INDEX unique_idx4 ON unique_tbl (i) NULLS NOT DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX unique_idx4 ON unique_tbl USING btree (i) NULLS NOT DISTINCT" +== 194 +-- truncate_limit: 100 +-- error + +DELETE FROM unique_tbl WHERE t = 'seven' +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM unique_tbl WHERE t = 'seven'" +== 195 +-- truncate_limit: 100 +CREATE UNIQUE INDEX unique_idx4 ON unique_tbl (i) NULLS NOT DISTINCT +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX unique_idx4 ON unique_tbl USING btree (i) NULLS NOT DISTINCT" +== 196 +-- truncate_limit: 100 +-- ok now + +SELECT pg_get_indexdef('unique_idx3'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('unique_idx3'::regclass)" +== 197 +-- truncate_limit: 100 +SELECT pg_get_indexdef('unique_idx4'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('unique_idx4'::regclass)" +== 198 +-- truncate_limit: 100 +DROP TABLE unique_tbl +-- +TABLE: name="unique_tbl" schema="" table="unique_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unique_tbl" +== 199 +-- truncate_limit: 100 +|-- +-- Test functional index +|-- +CREATE TABLE func_index_heap (f1 text, f2 text) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE func_index_heap (f1 text, f2 text)" +== 200 +-- truncate_limit: 100 +CREATE UNIQUE INDEX func_index_index on func_index_heap (textcat(f1,f2)) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +FUNCTION: name="textcat" function="textcat" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX func_index_index ON func_index_heap USING btree (textcat(f1, f2))" +== 201 +-- truncate_limit: 100 +INSERT INTO func_index_heap VALUES('ABC','DEF') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('ABC', 'DEF')" +== 202 +-- truncate_limit: 100 +INSERT INTO func_index_heap VALUES('AB','CDEFG') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('AB', 'CDEFG')" +== 203 +-- truncate_limit: 100 +INSERT INTO func_index_heap VALUES('QWE','RTY') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('QWE', 'RTY')" +== 204 +-- truncate_limit: 100 +-- this should fail because of unique index: +INSERT INTO func_index_heap VALUES('ABCD', 'EF') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('ABCD', 'EF')" +== 205 +-- truncate_limit: 100 +-- but this shouldn't: +INSERT INTO func_index_heap VALUES('QWERTY') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('QWERTY')" +== 206 +-- truncate_limit: 100 +-- while we're here, see that the metadata looks sane + + +|-- +-- Same test, expressional index +|-- +DROP TABLE func_index_heap +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE func_index_heap" +== 207 +-- truncate_limit: 100 +CREATE TABLE func_index_heap (f1 text, f2 text) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE func_index_heap (f1 text, f2 text)" +== 208 +-- truncate_limit: 100 +CREATE UNIQUE INDEX func_index_index on func_index_heap ((f1 || f2) text_ops) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX func_index_index ON func_index_heap USING btree ((f1 || f2) text_ops)" +== 209 +-- truncate_limit: 100 +INSERT INTO func_index_heap VALUES('ABC','DEF') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('ABC', 'DEF')" +== 210 +-- truncate_limit: 100 +INSERT INTO func_index_heap VALUES('AB','CDEFG') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('AB', 'CDEFG')" +== 211 +-- truncate_limit: 100 +INSERT INTO func_index_heap VALUES('QWE','RTY') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('QWE', 'RTY')" +== 212 +-- truncate_limit: 100 +-- this should fail because of unique index: +INSERT INTO func_index_heap VALUES('ABCD', 'EF') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('ABCD', 'EF')" +== 213 +-- truncate_limit: 100 +-- but this shouldn't: +INSERT INTO func_index_heap VALUES('QWERTY') +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO func_index_heap VALUES ('QWERTY')" +== 214 +-- truncate_limit: 100 +-- while we're here, see that the metadata looks sane + +-- this should fail because of unsafe column type (anonymous record) +create index on func_index_heap ((f1 || f2), (row(f1, f2))) +-- +TABLE: name="func_index_heap" schema="" table="func_index_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON func_index_heap USING btree ((f1 || f2), (ROW(f1, f2)))" +== 215 +-- truncate_limit: 100 +|-- +-- Test unique index with included columns +|-- +CREATE TABLE covering_index_heap (f1 int, f2 int, f3 text) +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE covering_index_heap (f1 int, f2 int, f3 text)" +== 216 +-- truncate_limit: 100 +CREATE UNIQUE INDEX covering_index_index on covering_index_heap (f1,f2) INCLUDE(f3) +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX covering_index_index ON covering_index_heap USING btree (f1, f2) INCLUDE (f3)" +== 217 +-- truncate_limit: 100 +INSERT INTO covering_index_heap VALUES(1,1,'AAA') +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covering_index_heap VALUES (1, 1, 'AAA')" +== 218 +-- truncate_limit: 100 +INSERT INTO covering_index_heap VALUES(1,2,'AAA') +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covering_index_heap VALUES (1, 2, 'AAA')" +== 219 +-- truncate_limit: 100 +-- this should fail because of unique index on f1,f2: +INSERT INTO covering_index_heap VALUES(1,2,'BBB') +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covering_index_heap VALUES (1, 2, 'BBB')" +== 220 +-- truncate_limit: 100 +-- and this shouldn't: +INSERT INTO covering_index_heap VALUES(1,4,'AAA') +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covering_index_heap VALUES (1, 4, 'AAA')" +== 221 +-- truncate_limit: 100 +-- Try to build index on table that already contains data +CREATE UNIQUE INDEX covering_pkey on covering_index_heap (f1,f2) INCLUDE(f3) +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX covering_pkey ON covering_index_heap USING btree (f1, f2) INCLUDE (f3)" +== 222 +-- truncate_limit: 100 +-- Try to use existing covering index as primary key +ALTER TABLE covering_index_heap ADD CONSTRAINT covering_pkey PRIMARY KEY USING INDEX +covering_pkey +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE covering_index_heap ADD CONSTRAINT covering_pkey PRIMARY KEY USING INDEX covering_pkey" +== 223 +-- truncate_limit: 100 +DROP TABLE covering_index_heap +-- +TABLE: name="covering_index_heap" schema="" table="covering_index_heap" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE covering_index_heap" +== 224 +-- truncate_limit: 100 +|-- +-- Try some concurrent index builds +|-- +-- Unfortunately this only tests about half the code paths because there are +-- no concurrent updates happening to the table at the same time. + +CREATE TABLE concur_heap (f1 text, f2 text) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_heap (f1 text, f2 text)" +== 225 +-- truncate_limit: 100 +-- empty table +CREATE INDEX CONCURRENTLY concur_index1 ON concur_heap(f2,f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY concur_index1 ON concur_heap USING btree (f2, f1)" +== 226 +-- truncate_limit: 100 +CREATE INDEX CONCURRENTLY IF NOT EXISTS concur_index1 ON concur_heap(f2,f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY IF NOT EXISTS concur_index1 ON concur_heap USING btree (f2, f1)" +== 227 +-- truncate_limit: 100 +INSERT INTO concur_heap VALUES ('a','b') +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_heap VALUES ('a', 'b')" +== 228 +-- truncate_limit: 100 +INSERT INTO concur_heap VALUES ('b','b') +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_heap VALUES ('b', 'b')" +== 229 +-- truncate_limit: 100 +-- unique index +CREATE UNIQUE INDEX CONCURRENTLY concur_index2 ON concur_heap(f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX CONCURRENTLY concur_index2 ON concur_heap USING btree (f1)" +== 230 +-- truncate_limit: 100 +CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS concur_index2 ON concur_heap(f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS concur_index2 ON concur_heap USING btree (f1)" +== 231 +-- truncate_limit: 100 +-- check if constraint is set up properly to be enforced +INSERT INTO concur_heap VALUES ('b','x') +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_heap VALUES ('b', 'x')" +== 232 +-- truncate_limit: 100 +-- check if constraint is enforced properly at build time +CREATE UNIQUE INDEX CONCURRENTLY concur_index3 ON concur_heap(f2) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX CONCURRENTLY concur_index3 ON concur_heap USING btree (f2)" +== 233 +-- truncate_limit: 100 +-- test that expression indexes and partial indexes work concurrently +CREATE INDEX CONCURRENTLY concur_index4 on concur_heap(f2) WHERE f1='a' +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY concur_index4 ON concur_heap USING btree (f2) WHERE f1 = 'a'" +== 234 +-- truncate_limit: 100 +CREATE INDEX CONCURRENTLY concur_index5 on concur_heap(f2) WHERE f1='x' +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY concur_index5 ON concur_heap USING btree (f2) WHERE f1 = 'x'" +== 235 +-- truncate_limit: 100 +-- here we also check that you can default the index name +CREATE INDEX CONCURRENTLY on concur_heap((f2||f1)) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY ON concur_heap USING btree ((f2 || f1))" +== 236 +-- truncate_limit: 100 +-- You can't do a concurrent index build in a transaction +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 237 +-- truncate_limit: 100 +CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap(f1) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY concur_index7 ON concur_heap USING btree (f1)" +== 238 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 239 +-- truncate_limit: 100 +-- test where predicate is able to do a transactional update during +-- a concurrent build before switching pg_index state flags. +CREATE FUNCTION predicate_stable() RETURNS bool IMMUTABLE +LANGUAGE plpgsql AS $$ +BEGIN + EXECUTE 'SELECT txid_current()'; + RETURN true; +END; $$ +-- +FUNCTION: name="predicate_stable" function="predicate_stable" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION predicate_stable() RETURNS bool IMMUTABLE LANGUAGE plpgsql AS $$\nBEGIN\n EXECUTE ..." +== 240 +-- truncate_limit: 100 +CREATE INDEX CONCURRENTLY concur_index8 ON concur_heap (f1) + WHERE predicate_stable() +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +FUNCTION: name="predicate_stable" function="predicate_stable" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY concur_index8 ON concur_heap USING btree (f1) WHERE predicate_stable()" +== 241 +-- truncate_limit: 100 +DROP INDEX concur_index8 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX concur_index8" +== 242 +-- truncate_limit: 100 +DROP FUNCTION predicate_stable() +-- +FUNCTION: name="predicate_stable" function="predicate_stable" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION predicate_stable()" +== 243 +-- truncate_limit: 100 +-- But you can do a regular index build in a transaction +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 244 +-- truncate_limit: 100 +CREATE INDEX std_index on concur_heap(f2) +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX std_index ON concur_heap USING btree (f2)" +== 245 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 246 +-- truncate_limit: 100 +-- Failed builds are left invalid by VACUUM FULL, fixed by REINDEX +VACUUM FULL concur_heap +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) concur_heap" +== 247 +-- truncate_limit: 100 +REINDEX TABLE concur_heap +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_heap" +== 248 +-- truncate_limit: 100 +DELETE FROM concur_heap WHERE f1 = 'b' +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM concur_heap WHERE f1 = 'b'" +== 249 +-- truncate_limit: 100 +VACUUM FULL concur_heap +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) concur_heap" +== 250 +-- truncate_limit: 100 +REINDEX TABLE concur_heap +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_heap" +== 251 +-- truncate_limit: 100 +-- Temporary tables with concurrent builds and on-commit actions +-- CONCURRENTLY used with CREATE INDEX and DROP INDEX is ignored. +-- PRESERVE ROWS, the default. +CREATE TEMP TABLE concur_temp (f1 int, f2 text) + ON COMMIT PRESERVE ROWS +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE concur_temp (f1 int, f2 text) ON COMMIT PRESERVE ROWS" +== 252 +-- truncate_limit: 100 +INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar')" +== 253 +-- truncate_limit: 100 +CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp(f1) +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp USING btree (f1)" +== 254 +-- truncate_limit: 100 +DROP INDEX CONCURRENTLY concur_temp_ind +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_temp_ind" +== 255 +-- truncate_limit: 100 +DROP TABLE concur_temp +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_temp" +== 256 +-- truncate_limit: 100 +-- ON COMMIT DROP +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 257 +-- truncate_limit: 100 +CREATE TEMP TABLE concur_temp (f1 int, f2 text) + ON COMMIT DROP +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE concur_temp (f1 int, f2 text) ON COMMIT DROP" +== 258 +-- truncate_limit: 100 +INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar')" +== 259 +-- truncate_limit: 100 +-- Fails when running in a transaction. +CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp(f1) +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp USING btree (f1)" +== 260 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 261 +-- truncate_limit: 100 +-- ON COMMIT DELETE ROWS +CREATE TEMP TABLE concur_temp (f1 int, f2 text) + ON COMMIT DELETE ROWS +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE concur_temp (f1 int, f2 text) ON COMMIT DELETE ROWS" +== 262 +-- truncate_limit: 100 +INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_temp VALUES (1, 'foo'), (2, 'bar')" +== 263 +-- truncate_limit: 100 +CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp(f1) +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY concur_temp_ind ON concur_temp USING btree (f1)" +== 264 +-- truncate_limit: 100 +DROP INDEX CONCURRENTLY concur_temp_ind +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_temp_ind" +== 265 +-- truncate_limit: 100 +DROP TABLE concur_temp +-- +TABLE: name="concur_temp" schema="" table="concur_temp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_temp" +== 266 +-- truncate_limit: 100 +|-- +-- Try some concurrent index drops +|-- +DROP INDEX CONCURRENTLY "concur_index2" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_index2" +== 267 +-- truncate_limit: 100 +-- works +DROP INDEX CONCURRENTLY IF EXISTS "concur_index2" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY IF EXISTS concur_index2" +== 268 +-- truncate_limit: 100 +-- notice + +-- failures +DROP INDEX CONCURRENTLY "concur_index2", "concur_index3" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_index2, concur_index3" +== 269 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 270 +-- truncate_limit: 100 +DROP INDEX CONCURRENTLY "concur_index5" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_index5" +== 271 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 272 +-- truncate_limit: 100 +-- successes +DROP INDEX CONCURRENTLY IF EXISTS "concur_index3" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY IF EXISTS concur_index3" +== 273 +-- truncate_limit: 100 +DROP INDEX CONCURRENTLY "concur_index4" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_index4" +== 274 +-- truncate_limit: 100 +DROP INDEX CONCURRENTLY "concur_index5" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_index5" +== 275 +-- truncate_limit: 100 +DROP INDEX CONCURRENTLY "concur_index1" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_index1" +== 276 +-- truncate_limit: 100 +DROP INDEX CONCURRENTLY "concur_heap_expr_idx" +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY concur_heap_expr_idx" +== 277 +-- truncate_limit: 100 +DROP TABLE concur_heap +-- +TABLE: name="concur_heap" schema="" table="concur_heap" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_heap" +== 278 +-- truncate_limit: 100 +|-- +-- Test ADD CONSTRAINT USING INDEX +|-- + +CREATE TABLE cwi_test( a int , b varchar(10), c char) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cwi_test (a int, b varchar(10), c char(1))" +== 279 +-- truncate_limit: 100 +-- add some data so that all tests have something to work with. + +INSERT INTO cwi_test VALUES(1, 2), (3, 4), (5, 6) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cwi_test VALUES (1, 2), (3, 4), (5, 6)" +== 280 +-- truncate_limit: 100 +CREATE UNIQUE INDEX cwi_uniq_idx ON cwi_test(a , b) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX cwi_uniq_idx ON cwi_test USING btree (a, b)" +== 281 +-- truncate_limit: 100 +ALTER TABLE cwi_test ADD primary key USING INDEX cwi_uniq_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cwi_test ADD PRIMARY KEY USING INDEX cwi_uniq_idx" +== 282 +-- truncate_limit: 100 +CREATE UNIQUE INDEX cwi_uniq2_idx ON cwi_test(b , a) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX cwi_uniq2_idx ON cwi_test USING btree (b, a)" +== 283 +-- truncate_limit: 100 +ALTER TABLE cwi_test DROP CONSTRAINT cwi_uniq_idx, + ADD CONSTRAINT cwi_replaced_pkey PRIMARY KEY + USING INDEX cwi_uniq2_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cwi_test DROP CONSTRAINT cwi_uniq_idx, ADD CONSTRAINT cwi_replaced_pkey PRIMARY KEY U..." +== 284 +-- truncate_limit: 100 +DROP INDEX cwi_replaced_pkey +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX cwi_replaced_pkey" +== 285 +-- truncate_limit: 100 +-- Should fail; a constraint depends on it + +-- Check that non-default index options are rejected +CREATE UNIQUE INDEX cwi_uniq3_idx ON cwi_test(a desc) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX cwi_uniq3_idx ON cwi_test USING btree (a DESC)" +== 286 +-- truncate_limit: 100 +ALTER TABLE cwi_test ADD UNIQUE USING INDEX cwi_uniq3_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cwi_test ADD UNIQUE USING INDEX cwi_uniq3_idx" +== 287 +-- truncate_limit: 100 +-- fail +CREATE UNIQUE INDEX cwi_uniq4_idx ON cwi_test(b collate "POSIX") +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX cwi_uniq4_idx ON cwi_test USING btree (b COLLATE \"POSIX\")" +== 288 +-- truncate_limit: 100 +ALTER TABLE cwi_test ADD UNIQUE USING INDEX cwi_uniq4_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cwi_test ADD UNIQUE USING INDEX cwi_uniq4_idx" +== 289 +-- truncate_limit: 100 +-- fail + +DROP TABLE cwi_test +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cwi_test" +== 290 +-- truncate_limit: 100 +-- ADD CONSTRAINT USING INDEX is forbidden on partitioned tables +CREATE TABLE cwi_test(a int) PARTITION BY hash (a) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cwi_test (a int) PARTITION BY HASH (a)" +== 291 +-- truncate_limit: 100 +create unique index on cwi_test (a) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON cwi_test USING btree (a)" +== 292 +-- truncate_limit: 100 +alter table cwi_test add primary key using index cwi_test_a_idx +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cwi_test ADD PRIMARY KEY USING INDEX cwi_test_a_idx" +== 293 +-- truncate_limit: 100 +DROP TABLE cwi_test +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cwi_test" +== 294 +-- truncate_limit: 100 +-- PRIMARY KEY constraint cannot be backed by a NULLS NOT DISTINCT index +CREATE TABLE cwi_test(a int, b int) +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cwi_test (a int, b int)" +== 295 +-- truncate_limit: 100 +CREATE UNIQUE INDEX cwi_a_nnd ON cwi_test (a) NULLS NOT DISTINCT +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX cwi_a_nnd ON cwi_test USING btree (a) NULLS NOT DISTINCT" +== 296 +-- truncate_limit: 100 +ALTER TABLE cwi_test ADD PRIMARY KEY USING INDEX cwi_a_nnd +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cwi_test ADD PRIMARY KEY USING INDEX cwi_a_nnd" +== 297 +-- truncate_limit: 100 +DROP TABLE cwi_test +-- +TABLE: name="cwi_test" schema="" table="cwi_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cwi_test" +== 298 +-- truncate_limit: 100 +|-- +-- Check handling of indexes on system columns +|-- +CREATE TABLE syscol_table (a INT) +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE syscol_table (a int)" +== 299 +-- truncate_limit: 100 +-- System columns cannot be indexed +CREATE INDEX ON syscol_table (ctid) +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON syscol_table USING btree (ctid)" +== 300 +-- truncate_limit: 100 +-- nor used in expressions +CREATE INDEX ON syscol_table ((ctid >= '(1000,0)')) +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON syscol_table USING btree ((ctid >= '(1000,0)'))" +== 301 +-- truncate_limit: 100 +-- nor used in predicates +CREATE INDEX ON syscol_table (a) WHERE ctid >= '(1000,0)' +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON syscol_table USING btree (a) WHERE ctid >= '(1000,0)'" +== 302 +-- truncate_limit: 100 +DROP TABLE syscol_table +-- +TABLE: name="syscol_table" schema="" table="syscol_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE syscol_table" +== 303 +-- truncate_limit: 100 +|-- +-- Tests for IS NULL/IS NOT NULL with b-tree indexes +|-- + +CREATE TABLE onek_with_null AS SELECT unique1, unique2 FROM onek +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE onek_with_null AS SELECT unique1, unique2 FROM onek" +== 304 +-- truncate_limit: 100 +INSERT INTO onek_with_null (unique1,unique2) VALUES (NULL, -1), (NULL, NULL) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO onek_with_null (unique1, unique2) VALUES (NULL, -1), (NULL, NULL)" +== 305 +-- truncate_limit: 100 +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2,unique1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX onek_nulltest ON onek_with_null USING btree (unique2, unique1)" +== 306 +-- truncate_limit: 100 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 307 +-- truncate_limit: 100 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 308 +-- truncate_limit: 100 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 309 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL" +== 310 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL" +== 311 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL" +== 312 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL" +== 313 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500" +== 314 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500" +== 315 +-- truncate_limit: 100 +DROP INDEX onek_nulltest +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX onek_nulltest" +== 316 +-- truncate_limit: 100 +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2 desc,unique1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX onek_nulltest ON onek_with_null USING btree (unique2 DESC, unique1)" +== 317 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL" +== 318 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL" +== 319 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL" +== 320 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL" +== 321 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500" +== 322 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500" +== 323 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IN (-1, 0, 1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IN (-1, 0, 1)" +== 324 +-- truncate_limit: 100 +DROP INDEX onek_nulltest +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX onek_nulltest" +== 325 +-- truncate_limit: 100 +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2 desc nulls last,unique1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX onek_nulltest ON onek_with_null USING btree (unique2 DESC NULLS LAST, unique1)" +== 326 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL" +== 327 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL" +== 328 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL" +== 329 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL" +== 330 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500" +== 331 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500" +== 332 +-- truncate_limit: 100 +DROP INDEX onek_nulltest +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX onek_nulltest" +== 333 +-- truncate_limit: 100 +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2 nulls first,unique1) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX onek_nulltest ON onek_with_null USING btree (unique2 NULLS FIRST, unique1)" +== 334 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL" +== 335 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NULL" +== 336 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL" +== 337 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique2 IS NOT NULL" +== 338 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NOT NULL AND unique1 > 500" +== 339 +-- truncate_limit: 100 +SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM onek_with_null WHERE unique1 IS NULL AND unique1 > 500" +== 340 +-- truncate_limit: 100 +DROP INDEX onek_nulltest +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX onek_nulltest" +== 341 +-- truncate_limit: 100 +-- Check initial-positioning logic too + +CREATE UNIQUE INDEX onek_nulltest ON onek_with_null (unique2) +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX onek_nulltest ON onek_with_null USING btree (unique2)" +== 342 +-- truncate_limit: 100 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 343 +-- truncate_limit: 100 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 344 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 345 +-- truncate_limit: 100 +SELECT unique1, unique2 FROM onek_with_null + ORDER BY unique2 LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM onek_with_null ORDER BY unique2 LIMIT 2" +== 346 +-- truncate_limit: 100 +SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= -1 + ORDER BY unique2 LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= -1 ORDER BY unique2 LIMIT 2" +== 347 +-- truncate_limit: 100 +SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= 0 + ORDER BY unique2 LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= 0 ORDER BY unique2 LIMIT 2" +== 348 +-- truncate_limit: 100 +SELECT unique1, unique2 FROM onek_with_null + ORDER BY unique2 DESC LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM onek_with_null ORDER BY unique2 DESC LIMIT 2" +== 349 +-- truncate_limit: 100 +SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= -1 + ORDER BY unique2 DESC LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM onek_with_null WHERE unique2 >= -1 ORDER BY unique2 DESC LIMIT 2" +== 350 +-- truncate_limit: 100 +SELECT unique1, unique2 FROM onek_with_null WHERE unique2 < 999 + ORDER BY unique2 DESC LIMIT 2 +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM onek_with_null WHERE unique2 < 999 ORDER BY unique2 DESC LIMIT 2" +== 351 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 352 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 353 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 354 +-- truncate_limit: 100 +DROP TABLE onek_with_null +-- +TABLE: name="onek_with_null" schema="" table="onek_with_null" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE onek_with_null" +== 355 +-- truncate_limit: 100 +|-- +-- Check bitmap index path planning +|-- + +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 + WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR ..." +== 356 +-- truncate_limit: 100 +SELECT * FROM tenk1 + WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tenk1 WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42)" +== 357 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 + WHERE hundred = 42 AND (thousand = 42 OR thousand = 99) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 WHERE hundred = 42 AND (thousand = 42 OR thousand ..." +== 358 +-- truncate_limit: 100 +SELECT count(*) FROM tenk1 + WHERE hundred = 42 AND (thousand = 42 OR thousand = 99) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 WHERE hundred = 42 AND (thousand = 42 OR thousand = 99)" +== 359 +-- truncate_limit: 100 +|-- +-- Check behavior with duplicate index column contents +|-- + +CREATE TABLE dupindexcols AS + SELECT unique1 as id, stringu2::text as f1 FROM tenk1 +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE dupindexcols AS SELECT unique1 AS id, stringu2::text AS f1 FROM tenk1" +== 360 +-- truncate_limit: 100 +CREATE INDEX dupindexcols_i ON dupindexcols (f1, id, f1 text_pattern_ops) +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX dupindexcols_i ON dupindexcols USING btree (f1, id, f1 text_pattern_ops)" +== 361 +-- truncate_limit: 100 +ANALYZE dupindexcols +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE dupindexcols" +== 362 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) + SELECT count(*) FROM dupindexcols + WHERE f1 BETWEEN 'WA' AND 'ZZZ' and id < 1000 and f1 ~<~ 'YX' +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM dupindexcols WHERE f1 BETWEEN 'WA' AND 'ZZZ' AND id < 10..." +== 363 +-- truncate_limit: 100 +SELECT count(*) FROM dupindexcols + WHERE f1 BETWEEN 'WA' AND 'ZZZ' and id < 1000 and f1 ~<~ 'YX' +-- +TABLE: name="dupindexcols" schema="" table="dupindexcols" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM dupindexcols WHERE f1 BETWEEN 'WA' AND 'ZZZ' AND id < 1000 AND f1 ~<~ 'YX'" +== 364 +-- truncate_limit: 100 +|-- +-- Check that index scans with =ANY indexquals return rows in index order +|-- + +explain (costs off) +SELECT unique1 FROM tenk1 +WHERE unique1 IN (1,42,7) +ORDER BY unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) ORDER BY unique1" +== 365 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 +WHERE unique1 IN (1,42,7) +ORDER BY unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) ORDER BY unique1" +== 366 +-- truncate_limit: 100 +-- Non-required array scan key on "tenthous": +explain (costs off) +SELECT thousand, tenthous FROM tenk1 +WHERE thousand < 2 AND tenthous IN (1001,3000) +ORDER BY thousand +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, tenthous FROM tenk1 WHERE thousand < 2 AND tenthous IN (1001..." +== 367 +-- truncate_limit: 100 +SELECT thousand, tenthous FROM tenk1 +WHERE thousand < 2 AND tenthous IN (1001,3000) +ORDER BY thousand +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT thousand, tenthous FROM tenk1 WHERE ... ORDER BY thousand" +== 368 +-- truncate_limit: 100 +-- Non-required array scan key on "tenthous", backward scan: +explain (costs off) +SELECT thousand, tenthous FROM tenk1 +WHERE thousand < 2 AND tenthous IN (1001,3000) +ORDER BY thousand DESC, tenthous DESC +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, tenthous FROM tenk1 WHERE thousand < 2 AND tenthous IN (1001..." +== 369 +-- truncate_limit: 100 +SELECT thousand, tenthous FROM tenk1 +WHERE thousand < 2 AND tenthous IN (1001,3000) +ORDER BY thousand DESC, tenthous DESC +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT thousand, tenthous FROM tenk1 WHERE ... ORDER BY thousand DESC, tenthous DESC" +== 370 +-- truncate_limit: 100 +|-- +-- Check elimination of redundant and contradictory index quals +|-- +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = ANY('{7, 8, 9}') +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 = ANY('{7, ..." +== 371 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = ANY('{7, 8, 9}') +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 = ANY('{7, 8, 9}')" +== 372 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 = ANY('{7, 14, 22}') and unique1 = ANY('{33, 44}'::bigint[]) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 = ANY('{7, 14, 22}') AND unique1 = AN..." +== 373 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 = ANY('{7, 14, 22}') and unique1 = ANY('{33, 44}'::bigint[]) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 = ANY('{7, 14, 22}') AND unique1 = ANY('{33, 44}'::bigint[])" +== 374 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 = 1" +== 375 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 = 1" +== 376 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = 12345 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 = 12345" +== 377 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 = 12345 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 = 12345" +== 378 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 >= 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 >= 42" +== 379 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 >= 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 >= 42" +== 380 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 > 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 > 42" +== 381 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 > 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 > 42" +== 382 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 > 9996 and unique1 >= 9999 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 > 9996 AND unique1 >= 9999" +== 383 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 > 9996 and unique1 >= 9999 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 > 9996 AND unique1 >= 9999" +== 384 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 < 3 and unique1 <= 3 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 < 3 AND unique1 <= 3" +== 385 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 < 3 and unique1 <= 3 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 < 3 AND unique1 <= 3" +== 386 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 < 3 and unique1 < (-1)::bigint +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 < 3 AND unique1 < (-1)::bigint" +== 387 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 < 3 and unique1 < (-1)::bigint +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 < 3 AND unique1 < (-1)::bigint" +== 388 +-- truncate_limit: 100 +explain (costs off) +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 < (-1)::bigint +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 < (-1)::bigint" +== 389 +-- truncate_limit: 100 +SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) and unique1 < (-1)::bigint +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 WHERE unique1 IN (1, 42, 7) AND unique1 < (-1)::bigint" +== 390 +-- truncate_limit: 100 +|-- +-- Check elimination of constant-NULL subexpressions +|-- + +explain (costs off) + select * from tenk1 where (thousand, tenthous) in ((1,1001), (null,null)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 WHERE (thousand, tenthous) IN ((1, 1001), (NULL, NULL))" +== 391 +-- truncate_limit: 100 +|-- +-- Check matching of boolean index columns to WHERE conditions and sort keys +|-- + +create temp table boolindex (b bool, i int, unique(b, i), junk float) +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE boolindex (b bool, i int, UNIQUE (b, i), junk double precision)" +== 392 +-- truncate_limit: 100 +explain (costs off) + select * from boolindex order by b, i limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolindex ORDER BY b, i LIMIT 10" +== 393 +-- truncate_limit: 100 +explain (costs off) + select * from boolindex where b order by i limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolindex WHERE b ORDER BY i LIMIT 10" +== 394 +-- truncate_limit: 100 +explain (costs off) + select * from boolindex where b = true order by i desc limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolindex WHERE b = true ORDER BY i DESC LIMIT 10" +== 395 +-- truncate_limit: 100 +explain (costs off) + select * from boolindex where not b order by i limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolindex WHERE NOT b ORDER BY i LIMIT 10" +== 396 +-- truncate_limit: 100 +explain (costs off) + select * from boolindex where b is true order by i desc limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolindex WHERE b IS TRUE ORDER BY i DESC LIMIT 10" +== 397 +-- truncate_limit: 100 +explain (costs off) + select * from boolindex where b is false order by i desc limit 10 +-- +TABLE: name="boolindex" schema="" table="boolindex" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolindex WHERE b IS FALSE ORDER BY i DESC LIMIT 10" +== 398 +-- truncate_limit: 100 +|-- +-- REINDEX (VERBOSE) +|-- +CREATE TABLE reindex_verbose(id integer primary key) +-- +TABLE: name="reindex_verbose" schema="" table="reindex_verbose" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE reindex_verbose (id int PRIMARY KEY)" +== 399 +-- truncate_limit: 100 +REINDEX (VERBOSE) TABLE reindex_verbose +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (VERBOSE) TABLE reindex_verbose" +== 400 +-- truncate_limit: 100 +DROP TABLE reindex_verbose +-- +TABLE: name="reindex_verbose" schema="" table="reindex_verbose" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE reindex_verbose" +== 401 +-- truncate_limit: 100 +|-- +-- REINDEX CONCURRENTLY +|-- +CREATE TABLE concur_reindex_tab (c1 int) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_tab (c1 int)" +== 402 +-- truncate_limit: 100 +-- REINDEX +REINDEX TABLE concur_reindex_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_tab" +== 403 +-- truncate_limit: 100 +-- notice +REINDEX (CONCURRENTLY) TABLE concur_reindex_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_tab" +== 404 +-- truncate_limit: 100 +-- notice +ALTER TABLE concur_reindex_tab ADD COLUMN c2 text +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE concur_reindex_tab ADD COLUMN c2 text" +== 405 +-- truncate_limit: 100 +-- add toast index +-- Normal index with integer column +CREATE UNIQUE INDEX concur_reindex_ind1 ON concur_reindex_tab(c1) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX concur_reindex_ind1 ON concur_reindex_tab USING btree (c1)" +== 406 +-- truncate_limit: 100 +-- Normal index with text column +CREATE INDEX concur_reindex_ind2 ON concur_reindex_tab(c2) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_ind2 ON concur_reindex_tab USING btree (c2)" +== 407 +-- truncate_limit: 100 +-- UNIQUE index with expression +CREATE UNIQUE INDEX concur_reindex_ind3 ON concur_reindex_tab(abs(c1)) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX concur_reindex_ind3 ON concur_reindex_tab USING btree (abs(c1))" +== 408 +-- truncate_limit: 100 +-- Duplicate column names +CREATE INDEX concur_reindex_ind4 ON concur_reindex_tab(c1, c1, c2) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_ind4 ON concur_reindex_tab USING btree (c1, c1, c2)" +== 409 +-- truncate_limit: 100 +-- Create table for check on foreign key dependence switch with indexes swapped +ALTER TABLE concur_reindex_tab ADD PRIMARY KEY USING INDEX concur_reindex_ind1 +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE concur_reindex_tab ADD PRIMARY KEY USING INDEX concur_reindex_ind1" +== 410 +-- truncate_limit: 100 +CREATE TABLE concur_reindex_tab2 (c1 int REFERENCES concur_reindex_tab) +-- +TABLE: name="concur_reindex_tab2" schema="" table="concur_reindex_tab2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_tab2 (c1 int REFERENCES concur_reindex_tab)" +== 411 +-- truncate_limit: 100 +INSERT INTO concur_reindex_tab VALUES (1, 'a') +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_reindex_tab VALUES (1, 'a')" +== 412 +-- truncate_limit: 100 +INSERT INTO concur_reindex_tab VALUES (2, 'a') +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_reindex_tab VALUES (2, 'a')" +== 413 +-- truncate_limit: 100 +-- Reindex concurrently of exclusion constraint currently not supported +CREATE TABLE concur_reindex_tab3 (c1 int, c2 int4range, EXCLUDE USING gist (c2 WITH &&)) +-- +TABLE: name="concur_reindex_tab3" schema="" table="concur_reindex_tab3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_tab3 (c1 int, c2 int4range, EXCLUDE USING gist (c2 WITH &&))" +== 414 +-- truncate_limit: 100 +INSERT INTO concur_reindex_tab3 VALUES (3, '[1,2]') +-- +TABLE: name="concur_reindex_tab3" schema="" table="concur_reindex_tab3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_reindex_tab3 VALUES (3, '[1,2]')" +== 415 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_reindex_tab3_c2_excl +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_tab3_c2_excl" +== 416 +-- truncate_limit: 100 +-- error +REINDEX TABLE CONCURRENTLY concur_reindex_tab3 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_tab3" +== 417 +-- truncate_limit: 100 +-- succeeds with warning +INSERT INTO concur_reindex_tab3 VALUES (4, '[2,4]') +-- +TABLE: name="concur_reindex_tab3" schema="" table="concur_reindex_tab3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_reindex_tab3 VALUES (4, '[2,4]')" +== 418 +-- truncate_limit: 100 +-- Check materialized views +CREATE MATERIALIZED VIEW concur_reindex_matview AS SELECT * FROM concur_reindex_tab +-- +TABLE: name="concur_reindex_matview" schema="" table="concur_reindex_matview" ctx=DDL +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW concur_reindex_matview AS SELECT * FROM concur_reindex_tab" +== 419 +-- truncate_limit: 100 +-- Dependency lookup before and after the follow-up REINDEX commands. +-- These should remain consistent. +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid,refobjid,refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_class'::regclass AND + objid in ('concur_reindex_tab'::regclass, + 'concur_reindex_ind1'::regclass, + 'concur_reindex_ind2'::regclass, + 'concur_reindex_ind3'::regclass, + 'concur_reindex_ind4'::regclass, + 'concur_reindex_matview'::regclass) + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1, 2" +== 420 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_reindex_ind1 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_ind1" +== 421 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_tab" +== 422 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_matview +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_matview" +== 423 +-- truncate_limit: 100 +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid,refobjid,refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_class'::regclass AND + objid in ('concur_reindex_tab'::regclass, + 'concur_reindex_ind1'::regclass, + 'concur_reindex_ind2'::regclass, + 'concur_reindex_ind3'::regclass, + 'concur_reindex_ind4'::regclass, + 'concur_reindex_matview'::regclass) + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1, 2" +== 424 +-- truncate_limit: 100 +-- Check that comments are preserved +CREATE TABLE testcomment (i int) +-- +TABLE: name="testcomment" schema="" table="testcomment" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testcomment (i int)" +== 425 +-- truncate_limit: 100 +CREATE INDEX testcomment_idx1 ON testcomment (i) +-- +TABLE: name="testcomment" schema="" table="testcomment" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX testcomment_idx1 ON testcomment USING btree (i)" +== 426 +-- truncate_limit: 100 +COMMENT ON INDEX testcomment_idx1 IS 'test comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX testcomment_idx1 IS 'test comment'" +== 427 +-- truncate_limit: 100 +SELECT obj_description('testcomment_idx1'::regclass, 'pg_class') +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT obj_description('testcomment_idx1'::regclass, 'pg_class')" +== 428 +-- truncate_limit: 100 +REINDEX TABLE testcomment +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE testcomment" +== 429 +-- truncate_limit: 100 +SELECT obj_description('testcomment_idx1'::regclass, 'pg_class') +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT obj_description('testcomment_idx1'::regclass, 'pg_class')" +== 430 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY testcomment +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE testcomment" +== 431 +-- truncate_limit: 100 +SELECT obj_description('testcomment_idx1'::regclass, 'pg_class') +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT obj_description('testcomment_idx1'::regclass, 'pg_class')" +== 432 +-- truncate_limit: 100 +DROP TABLE testcomment +-- +TABLE: name="testcomment" schema="" table="testcomment" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testcomment" +== 433 +-- truncate_limit: 100 +-- Check that indisclustered updates are preserved +CREATE TABLE concur_clustered(i int) +-- +TABLE: name="concur_clustered" schema="" table="concur_clustered" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_clustered (i int)" +== 434 +-- truncate_limit: 100 +CREATE INDEX concur_clustered_i_idx ON concur_clustered(i) +-- +TABLE: name="concur_clustered" schema="" table="concur_clustered" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_clustered_i_idx ON concur_clustered USING btree (i)" +== 435 +-- truncate_limit: 100 +ALTER TABLE concur_clustered CLUSTER ON concur_clustered_i_idx +-- +TABLE: name="concur_clustered" schema="" table="concur_clustered" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE concur_clustered CLUSTER ON concur_clustered_i_idx" +== 436 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_clustered +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_clustered" +== 437 +-- truncate_limit: 100 +SELECT indexrelid::regclass, indisclustered FROM pg_index + WHERE indrelid = 'concur_clustered'::regclass +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT indexrelid::regclass, indisclustered FROM pg_index WHERE ..." +== 438 +-- truncate_limit: 100 +DROP TABLE concur_clustered +-- +TABLE: name="concur_clustered" schema="" table="concur_clustered" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_clustered" +== 439 +-- truncate_limit: 100 +-- Check that indisreplident updates are preserved. +CREATE TABLE concur_replident(i int NOT NULL) +-- +TABLE: name="concur_replident" schema="" table="concur_replident" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_replident (i int NOT NULL)" +== 440 +-- truncate_limit: 100 +CREATE UNIQUE INDEX concur_replident_i_idx ON concur_replident(i) +-- +TABLE: name="concur_replident" schema="" table="concur_replident" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX concur_replident_i_idx ON concur_replident USING btree (i)" +== 441 +-- truncate_limit: 100 +ALTER TABLE concur_replident REPLICA IDENTITY + USING INDEX concur_replident_i_idx +-- +TABLE: name="concur_replident" schema="" table="concur_replident" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE concur_replident REPLICA IDENTITY USING INDEX concur_replident_i_idx" +== 442 +-- truncate_limit: 100 +SELECT indexrelid::regclass, indisreplident FROM pg_index + WHERE indrelid = 'concur_replident'::regclass +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT indexrelid::regclass, indisreplident FROM pg_index WHERE ..." +== 443 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_replident +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_replident" +== 444 +-- truncate_limit: 100 +SELECT indexrelid::regclass, indisreplident FROM pg_index + WHERE indrelid = 'concur_replident'::regclass +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT indexrelid::regclass, indisreplident FROM pg_index WHERE ..." +== 445 +-- truncate_limit: 100 +DROP TABLE concur_replident +-- +TABLE: name="concur_replident" schema="" table="concur_replident" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_replident" +== 446 +-- truncate_limit: 100 +-- Check that opclass parameters are preserved +CREATE TABLE concur_appclass_tab(i tsvector, j tsvector, k tsvector) +-- +TABLE: name="concur_appclass_tab" schema="" table="concur_appclass_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_appclass_tab (i tsvector, j tsvector, k tsvector)" +== 447 +-- truncate_limit: 100 +CREATE INDEX concur_appclass_ind on concur_appclass_tab + USING gist (i tsvector_ops (siglen='1000'), j tsvector_ops (siglen='500')) +-- +TABLE: name="concur_appclass_tab" schema="" table="concur_appclass_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_appclass_ind ON concur_appclass_tab USING gist (i tsvector_ops(siglen='1000')..." +== 448 +-- truncate_limit: 100 +CREATE INDEX concur_appclass_ind_2 on concur_appclass_tab + USING gist (k tsvector_ops (siglen='300'), j tsvector_ops) +-- +TABLE: name="concur_appclass_tab" schema="" table="concur_appclass_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_appclass_ind_2 ON concur_appclass_tab USING gist (k tsvector_ops(siglen='300'..." +== 449 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_appclass_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_appclass_tab" +== 450 +-- truncate_limit: 100 +DROP TABLE concur_appclass_tab +-- +TABLE: name="concur_appclass_tab" schema="" table="concur_appclass_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_appclass_tab" +== 451 +-- truncate_limit: 100 +-- Partitions +-- Create some partitioned tables +CREATE TABLE concur_reindex_part (c1 int, c2 int) PARTITION BY RANGE (c1) +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_part (c1 int, c2 int) PARTITION BY RANGE (c1)" +== 452 +-- truncate_limit: 100 +CREATE TABLE concur_reindex_part_0 PARTITION OF concur_reindex_part + FOR VALUES FROM (0) TO (10) PARTITION BY list (c2) +-- +TABLE: name="concur_reindex_part_0" schema="" table="concur_reindex_part_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_part_0 PARTITION OF concur_reindex_part FOR VALUES FROM (0) TO (10) P..." +== 453 +-- truncate_limit: 100 +CREATE TABLE concur_reindex_part_0_1 PARTITION OF concur_reindex_part_0 + FOR VALUES IN (1) +-- +TABLE: name="concur_reindex_part_0_1" schema="" table="concur_reindex_part_0_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_part_0_1 PARTITION OF concur_reindex_part_0 FOR VALUES IN (1)" +== 454 +-- truncate_limit: 100 +CREATE TABLE concur_reindex_part_0_2 PARTITION OF concur_reindex_part_0 + FOR VALUES IN (2) +-- +TABLE: name="concur_reindex_part_0_2" schema="" table="concur_reindex_part_0_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_part_0_2 PARTITION OF concur_reindex_part_0 FOR VALUES IN (2)" +== 455 +-- truncate_limit: 100 +-- This partitioned table will have no partitions. +CREATE TABLE concur_reindex_part_10 PARTITION OF concur_reindex_part + FOR VALUES FROM (10) TO (20) PARTITION BY list (c2) +-- +TABLE: name="concur_reindex_part_10" schema="" table="concur_reindex_part_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_part_10 PARTITION OF concur_reindex_part FOR VALUES FROM (10) TO (20)..." +== 456 +-- truncate_limit: 100 +-- Create some partitioned indexes +CREATE INDEX concur_reindex_part_index ON ONLY concur_reindex_part (c1) +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_part_index ON ONLY concur_reindex_part USING btree (c1)" +== 457 +-- truncate_limit: 100 +CREATE INDEX concur_reindex_part_index_0 ON ONLY concur_reindex_part_0 (c1) +-- +TABLE: name="concur_reindex_part_0" schema="" table="concur_reindex_part_0" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_part_index_0 ON ONLY concur_reindex_part_0 USING btree (c1)" +== 458 +-- truncate_limit: 100 +ALTER INDEX concur_reindex_part_index ATTACH PARTITION concur_reindex_part_index_0 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX concur_reindex_part_index ATTACH PARTITION concur_reindex_part_index_0" +== 459 +-- truncate_limit: 100 +-- This partitioned index will have no partitions. +CREATE INDEX concur_reindex_part_index_10 ON ONLY concur_reindex_part_10 (c1) +-- +TABLE: name="concur_reindex_part_10" schema="" table="concur_reindex_part_10" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_part_index_10 ON ONLY concur_reindex_part_10 USING btree (c1)" +== 460 +-- truncate_limit: 100 +ALTER INDEX concur_reindex_part_index ATTACH PARTITION concur_reindex_part_index_10 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX concur_reindex_part_index ATTACH PARTITION concur_reindex_part_index_10" +== 461 +-- truncate_limit: 100 +CREATE INDEX concur_reindex_part_index_0_1 ON ONLY concur_reindex_part_0_1 (c1) +-- +TABLE: name="concur_reindex_part_0_1" schema="" table="concur_reindex_part_0_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_part_index_0_1 ON ONLY concur_reindex_part_0_1 USING btree (c1)" +== 462 +-- truncate_limit: 100 +ALTER INDEX concur_reindex_part_index_0 ATTACH PARTITION concur_reindex_part_index_0_1 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX concur_reindex_part_index_0 ATTACH PARTITION concur_reindex_part_index_0_1" +== 463 +-- truncate_limit: 100 +CREATE INDEX concur_reindex_part_index_0_2 ON ONLY concur_reindex_part_0_2 (c1) +-- +TABLE: name="concur_reindex_part_0_2" schema="" table="concur_reindex_part_0_2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_part_index_0_2 ON ONLY concur_reindex_part_0_2 USING btree (c1)" +== 464 +-- truncate_limit: 100 +ALTER INDEX concur_reindex_part_index_0 ATTACH PARTITION concur_reindex_part_index_0_2 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX concur_reindex_part_index_0 ATTACH PARTITION concur_reindex_part_index_0_2" +== 465 +-- truncate_limit: 100 +SELECT relid, parentrelid, level FROM pg_partition_tree('concur_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('concur_reindex_part_index') ORDER BY relid, level" +== 466 +-- truncate_limit: 100 +SELECT relid, parentrelid, level FROM pg_partition_tree('concur_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('concur_reindex_part_index') ORDER BY relid, level" +== 467 +-- truncate_limit: 100 +-- REINDEX should preserve dependencies of partition tree. +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid,refobjid,refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_class'::regclass AND + objid in ('concur_reindex_part'::regclass, + 'concur_reindex_part_0'::regclass, + 'concur_reindex_part_0_1'::regclass, + 'concur_reindex_part_0_2'::regclass, + 'concur_reindex_part_index'::regclass, + 'concur_reindex_part_index_0'::regclass, + 'concur_reindex_part_index_0_1'::regclass, + 'concur_reindex_part_index_0_2'::regclass) + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1, 2" +== 468 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_reindex_part_index_0_1 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_part_index_0_1" +== 469 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_reindex_part_index_0_2 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_part_index_0_2" +== 470 +-- truncate_limit: 100 +SELECT relid, parentrelid, level FROM pg_partition_tree('concur_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('concur_reindex_part_index') ORDER BY relid, level" +== 471 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_part_0_1 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_part_0_1" +== 472 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_part_0_2 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_part_0_2" +== 473 +-- truncate_limit: 100 +SELECT pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid,refobjid,refobjsubid) as objref, + deptype +FROM pg_depend +WHERE classid = 'pg_class'::regclass AND + objid in ('concur_reindex_part'::regclass, + 'concur_reindex_part_0'::regclass, + 'concur_reindex_part_0_1'::regclass, + 'concur_reindex_part_0_2'::regclass, + 'concur_reindex_part_index'::regclass, + 'concur_reindex_part_index_0'::regclass, + 'concur_reindex_part_index_0_1'::regclass, + 'concur_reindex_part_index_0_2'::regclass) + ORDER BY 1, 2 +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_depend WHERE ... ORDER BY 1, 2" +== 474 +-- truncate_limit: 100 +SELECT relid, parentrelid, level FROM pg_partition_tree('concur_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('concur_reindex_part_index') ORDER BY relid, level" +== 475 +-- truncate_limit: 100 +-- REINDEX for partitioned indexes +-- REINDEX TABLE fails for partitioned indexes +-- Top-most parent index +REINDEX TABLE concur_reindex_part_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_part_index" +== 476 +-- truncate_limit: 100 +-- error +REINDEX TABLE CONCURRENTLY concur_reindex_part_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_part_index" +== 477 +-- truncate_limit: 100 +-- error +-- Partitioned index with no leaves +REINDEX TABLE concur_reindex_part_index_10 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_part_index_10" +== 478 +-- truncate_limit: 100 +-- error +REINDEX TABLE CONCURRENTLY concur_reindex_part_index_10 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_part_index_10" +== 479 +-- truncate_limit: 100 +-- error +-- Cannot run in a transaction block +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 480 +-- truncate_limit: 100 +REINDEX INDEX concur_reindex_part_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX concur_reindex_part_index" +== 481 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 482 +-- truncate_limit: 100 +-- Helper functions to track changes of relfilenodes in a partition tree. +-- Create a table tracking the relfilenode state. +CREATE OR REPLACE FUNCTION create_relfilenode_part(relname text, indname text) + RETURNS VOID AS + $func$ + BEGIN + EXECUTE format(' + CREATE TABLE %I AS + SELECT oid, relname, relfilenode, relkind, reltoastrelid + FROM pg_class + WHERE oid IN + (SELECT relid FROM pg_partition_tree(''%I''));', + relname, indname); + END + $func$ LANGUAGE plpgsql +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION create_relfilenode_part(relname text, indname text) RETURNS void AS $$..." +== 483 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION compare_relfilenode_part(tabname text) + RETURNS TABLE (relname name, relkind "char", state text) AS + $func$ + BEGIN + RETURN QUERY EXECUTE + format( + 'SELECT b.relname, + b.relkind, + CASE WHEN a.relfilenode = b.relfilenode THEN ''relfilenode is unchanged'' + ELSE ''relfilenode has changed'' END + -- Do not join with OID here as CONCURRENTLY changes it. + FROM %I b JOIN pg_class a ON b.relname = a.relname + ORDER BY 1;', tabname); + END + $func$ LANGUAGE plpgsql +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compare_relfilenode_part(tabname text) RETURNS TABLE (relname name, re..." +== 484 +-- truncate_limit: 100 +-- Check that expected relfilenodes are changed, non-concurrent case. +SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index') +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index')" +== 485 +-- truncate_limit: 100 +REINDEX INDEX concur_reindex_part_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX concur_reindex_part_index" +== 486 +-- truncate_limit: 100 +SELECT * FROM compare_relfilenode_part('reindex_index_status') +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM compare_relfilenode_part('reindex_index_status')" +== 487 +-- truncate_limit: 100 +DROP TABLE reindex_index_status +-- +TABLE: name="reindex_index_status" schema="" table="reindex_index_status" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE reindex_index_status" +== 488 +-- truncate_limit: 100 +-- concurrent case. +SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index') +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index')" +== 489 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_reindex_part_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_part_index" +== 490 +-- truncate_limit: 100 +SELECT * FROM compare_relfilenode_part('reindex_index_status') +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM compare_relfilenode_part('reindex_index_status')" +== 491 +-- truncate_limit: 100 +DROP TABLE reindex_index_status +-- +TABLE: name="reindex_index_status" schema="" table="reindex_index_status" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE reindex_index_status" +== 492 +-- truncate_limit: 100 +-- REINDEX for partitioned tables +-- REINDEX INDEX fails for partitioned tables +-- Top-most parent +REINDEX INDEX concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX concur_reindex_part" +== 493 +-- truncate_limit: 100 +-- error +REINDEX INDEX CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_part" +== 494 +-- truncate_limit: 100 +-- error +-- Partitioned with no leaves +REINDEX INDEX concur_reindex_part_10 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX concur_reindex_part_10" +== 495 +-- truncate_limit: 100 +-- error +REINDEX INDEX CONCURRENTLY concur_reindex_part_10 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_part_10" +== 496 +-- truncate_limit: 100 +-- error +-- Cannot run in a transaction block +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 497 +-- truncate_limit: 100 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_part" +== 498 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 499 +-- truncate_limit: 100 +-- Check that expected relfilenodes are changed, non-concurrent case. +-- Note that the partition tree changes of the *indexes* need to be checked. +SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index') +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index')" +== 500 +-- truncate_limit: 100 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_part" +== 501 +-- truncate_limit: 100 +SELECT * FROM compare_relfilenode_part('reindex_index_status') +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM compare_relfilenode_part('reindex_index_status')" +== 502 +-- truncate_limit: 100 +DROP TABLE reindex_index_status +-- +TABLE: name="reindex_index_status" schema="" table="reindex_index_status" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE reindex_index_status" +== 503 +-- truncate_limit: 100 +-- concurrent case. +SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index') +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT create_relfilenode_part('reindex_index_status', 'concur_reindex_part_index')" +== 504 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_part" +== 505 +-- truncate_limit: 100 +SELECT * FROM compare_relfilenode_part('reindex_index_status') +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM compare_relfilenode_part('reindex_index_status')" +== 506 +-- truncate_limit: 100 +DROP TABLE reindex_index_status +-- +TABLE: name="reindex_index_status" schema="" table="reindex_index_status" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE reindex_index_status" +== 507 +-- truncate_limit: 100 +DROP FUNCTION create_relfilenode_part +-- +FUNCTION: name="create_relfilenode_part" function="create_relfilenode_part" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION create_relfilenode_part" +== 508 +-- truncate_limit: 100 +DROP FUNCTION compare_relfilenode_part +-- +FUNCTION: name="compare_relfilenode_part" function="compare_relfilenode_part" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION compare_relfilenode_part" +== 509 +-- truncate_limit: 100 +-- Cleanup of partition tree used for REINDEX test. +DROP TABLE concur_reindex_part +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_reindex_part" +== 510 +-- truncate_limit: 100 +-- Check errors +-- Cannot run inside a transaction block +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 511 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_tab" +== 512 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 513 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY pg_class +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE pg_class" +== 514 +-- truncate_limit: 100 +-- no catalog relation +REINDEX INDEX CONCURRENTLY pg_class_oid_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX pg_class_oid_index" +== 515 +-- truncate_limit: 100 +-- no catalog index +-- These are the toast table and index of pg_authid. +REINDEX TABLE CONCURRENTLY pg_toast.pg_toast_1260 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE pg_toast.pg_toast_1260" +== 516 +-- truncate_limit: 100 +-- no catalog toast table +REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_1260_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX pg_toast.pg_toast_1260_index" +== 517 +-- truncate_limit: 100 +-- no catalog toast index +REINDEX SYSTEM CONCURRENTLY postgres +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) SYSTEM postgres" +== 518 +-- truncate_limit: 100 +-- not allowed for SYSTEM +REINDEX (CONCURRENTLY) SYSTEM postgres +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) SYSTEM postgres" +== 519 +-- truncate_limit: 100 +-- ditto +REINDEX (CONCURRENTLY) SYSTEM +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) SYSTEM" +== 520 +-- truncate_limit: 100 +-- ditto +-- Warns about catalog relations +REINDEX SCHEMA CONCURRENTLY pg_catalog +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) SCHEMA pg_catalog" +== 521 +-- truncate_limit: 100 +-- Not the current database +REINDEX DATABASE not_current_database +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX DATABASE not_current_database" +== 522 +-- truncate_limit: 100 +-- Check the relation status, there should not be invalid indexes +DROP MATERIALIZED VIEW concur_reindex_matview +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW concur_reindex_matview" +== 523 +-- truncate_limit: 100 +DROP TABLE concur_reindex_tab, concur_reindex_tab2, concur_reindex_tab3 +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +TABLE: name="concur_reindex_tab2" schema="" table="concur_reindex_tab2" ctx=DDL +TABLE: name="concur_reindex_tab3" schema="" table="concur_reindex_tab3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_reindex_tab, concur_reindex_tab2, concur_reindex_tab3" +== 524 +-- truncate_limit: 100 +-- Check handling of invalid indexes +CREATE TABLE concur_reindex_tab4 (c1 int) +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_tab4 (c1 int)" +== 525 +-- truncate_limit: 100 +INSERT INTO concur_reindex_tab4 VALUES (1), (1), (2) +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_reindex_tab4 VALUES (1), (1), (2)" +== 526 +-- truncate_limit: 100 +-- This trick creates an invalid index. +CREATE UNIQUE INDEX CONCURRENTLY concur_reindex_ind5 ON concur_reindex_tab4 (c1) +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX CONCURRENTLY concur_reindex_ind5 ON concur_reindex_tab4 USING btree (c1)" +== 527 +-- truncate_limit: 100 +-- Reindexing concurrently this index fails with the same failure. +-- The extra index created is itself invalid, and can be dropped. +REINDEX INDEX CONCURRENTLY concur_reindex_ind5 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_ind5" +== 528 +-- truncate_limit: 100 +DROP INDEX concur_reindex_ind5_ccnew +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX concur_reindex_ind5_ccnew" +== 529 +-- truncate_limit: 100 +-- This makes the previous failure go away, so the index can become valid. +DELETE FROM concur_reindex_tab4 WHERE c1 = 1 +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM concur_reindex_tab4 WHERE c1 = 1" +== 530 +-- truncate_limit: 100 +-- The invalid index is not processed when running REINDEX TABLE. +REINDEX TABLE CONCURRENTLY concur_reindex_tab4 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_tab4" +== 531 +-- truncate_limit: 100 +-- But it is fixed with REINDEX INDEX. +REINDEX INDEX CONCURRENTLY concur_reindex_ind5 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_ind5" +== 532 +-- truncate_limit: 100 +DROP TABLE concur_reindex_tab4 +-- +TABLE: name="concur_reindex_tab4" schema="" table="concur_reindex_tab4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_reindex_tab4" +== 533 +-- truncate_limit: 100 +-- Check handling of indexes with expressions and predicates. The +-- definitions of the rebuilt indexes should match the original +-- definitions. +CREATE TABLE concur_exprs_tab (c1 int , c2 boolean) +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_exprs_tab (c1 int, c2 boolean)" +== 534 +-- truncate_limit: 100 +INSERT INTO concur_exprs_tab (c1, c2) VALUES (1369652450, FALSE), + (414515746, TRUE), + (897778963, FALSE) +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_exprs_tab (c1, c2) VALUES (...)" +== 535 +-- truncate_limit: 100 +CREATE UNIQUE INDEX concur_exprs_index_expr + ON concur_exprs_tab ((c1::text COLLATE "C")) +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX concur_exprs_index_expr ON concur_exprs_tab USING btree ((c1::text COLLATE \"C\"))" +== 536 +-- truncate_limit: 100 +CREATE UNIQUE INDEX concur_exprs_index_pred ON concur_exprs_tab (c1) + WHERE (c1::text > 500000000::text COLLATE "C") +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX concur_exprs_index_pred ON concur_exprs_tab USING btree (c1) WHERE ..." +== 537 +-- truncate_limit: 100 +CREATE UNIQUE INDEX concur_exprs_index_pred_2 + ON concur_exprs_tab ((1 / c1)) + WHERE ('-H') >= (c2::TEXT) COLLATE "C" +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX concur_exprs_index_pred_2 ON concur_exprs_tab USING btree ((1 / c1)) WHERE ..." +== 538 +-- truncate_limit: 100 +ALTER INDEX concur_exprs_index_expr ALTER COLUMN 1 SET STATISTICS 100 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX concur_exprs_index_expr ALTER COLUMN 1 SET STATISTICS 100" +== 539 +-- truncate_limit: 100 +ANALYZE concur_exprs_tab +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE concur_exprs_tab" +== 540 +-- truncate_limit: 100 +SELECT starelid::regclass, count(*) FROM pg_statistic WHERE starelid IN ( + 'concur_exprs_index_expr'::regclass, + 'concur_exprs_index_pred'::regclass, + 'concur_exprs_index_pred_2'::regclass) + GROUP BY starelid ORDER BY starelid::regclass::text +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="starelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_statistic WHERE ... GROUP BY starelid ORDER BY starelid::regclass::text" +== 541 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass)" +== 542 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass)" +== 543 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass)" +== 544 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_exprs_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_exprs_tab" +== 545 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass)" +== 546 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass)" +== 547 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass)" +== 548 +-- truncate_limit: 100 +-- ALTER TABLE recreates the indexes, which should keep their collations. +ALTER TABLE concur_exprs_tab ALTER c2 TYPE TEXT +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE concur_exprs_tab ALTER COLUMN c2 TYPE text" +== 549 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_expr'::regclass)" +== 550 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_pred'::regclass)" +== 551 +-- truncate_limit: 100 +SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef('concur_exprs_index_pred_2'::regclass)" +== 552 +-- truncate_limit: 100 +-- Statistics should remain intact. +SELECT starelid::regclass, count(*) FROM pg_statistic WHERE starelid IN ( + 'concur_exprs_index_expr'::regclass, + 'concur_exprs_index_pred'::regclass, + 'concur_exprs_index_pred_2'::regclass) + GROUP BY starelid ORDER BY starelid::regclass::text +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="starelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_statistic WHERE ... GROUP BY starelid ORDER BY starelid::regclass::text" +== 553 +-- truncate_limit: 100 +-- attstattarget should remain intact +SELECT attrelid::regclass, attnum, attstattarget + FROM pg_attribute WHERE attrelid IN ( + 'concur_exprs_index_expr'::regclass, + 'concur_exprs_index_pred'::regclass, + 'concur_exprs_index_pred_2'::regclass) + ORDER BY attrelid::regclass::text, attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE ... ORDER BY attrelid::regclass::text, attnum" +== 554 +-- truncate_limit: 100 +DROP TABLE concur_exprs_tab +-- +TABLE: name="concur_exprs_tab" schema="" table="concur_exprs_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_exprs_tab" +== 555 +-- truncate_limit: 100 +-- Temporary tables and on-commit actions, where CONCURRENTLY is ignored. +-- ON COMMIT PRESERVE ROWS, the default. +CREATE TEMP TABLE concur_temp_tab_1 (c1 int, c2 text) + ON COMMIT PRESERVE ROWS +-- +TABLE: name="concur_temp_tab_1" schema="" table="concur_temp_tab_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE concur_temp_tab_1 (c1 int, c2 text) ON COMMIT PRESERVE ROWS" +== 556 +-- truncate_limit: 100 +INSERT INTO concur_temp_tab_1 VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp_tab_1" schema="" table="concur_temp_tab_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_temp_tab_1 VALUES (1, 'foo'), (2, 'bar')" +== 557 +-- truncate_limit: 100 +CREATE INDEX concur_temp_ind_1 ON concur_temp_tab_1(c2) +-- +TABLE: name="concur_temp_tab_1" schema="" table="concur_temp_tab_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_temp_ind_1 ON concur_temp_tab_1 USING btree (c2)" +== 558 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_temp_tab_1 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_temp_tab_1" +== 559 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_temp_ind_1 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_temp_ind_1" +== 560 +-- truncate_limit: 100 +-- Still fails in transaction blocks +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 561 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_temp_ind_1 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_temp_ind_1" +== 562 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 563 +-- truncate_limit: 100 +-- ON COMMIT DELETE ROWS +CREATE TEMP TABLE concur_temp_tab_2 (c1 int, c2 text) + ON COMMIT DELETE ROWS +-- +TABLE: name="concur_temp_tab_2" schema="" table="concur_temp_tab_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE concur_temp_tab_2 (c1 int, c2 text) ON COMMIT DELETE ROWS" +== 564 +-- truncate_limit: 100 +CREATE INDEX concur_temp_ind_2 ON concur_temp_tab_2(c2) +-- +TABLE: name="concur_temp_tab_2" schema="" table="concur_temp_tab_2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_temp_ind_2 ON concur_temp_tab_2 USING btree (c2)" +== 565 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_temp_tab_2 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_temp_tab_2" +== 566 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_temp_ind_2 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_temp_ind_2" +== 567 +-- truncate_limit: 100 +-- ON COMMIT DROP +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 568 +-- truncate_limit: 100 +CREATE TEMP TABLE concur_temp_tab_3 (c1 int, c2 text) + ON COMMIT PRESERVE ROWS +-- +TABLE: name="concur_temp_tab_3" schema="" table="concur_temp_tab_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE concur_temp_tab_3 (c1 int, c2 text) ON COMMIT PRESERVE ROWS" +== 569 +-- truncate_limit: 100 +INSERT INTO concur_temp_tab_3 VALUES (1, 'foo'), (2, 'bar') +-- +TABLE: name="concur_temp_tab_3" schema="" table="concur_temp_tab_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO concur_temp_tab_3 VALUES (1, 'foo'), (2, 'bar')" +== 570 +-- truncate_limit: 100 +CREATE INDEX concur_temp_ind_3 ON concur_temp_tab_3(c2) +-- +TABLE: name="concur_temp_tab_3" schema="" table="concur_temp_tab_3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_temp_ind_3 ON concur_temp_tab_3 USING btree (c2)" +== 571 +-- truncate_limit: 100 +-- Fails when running in a transaction +REINDEX INDEX CONCURRENTLY concur_temp_ind_3 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_temp_ind_3" +== 572 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 573 +-- truncate_limit: 100 +-- REINDEX SCHEMA processes all temporary relations +CREATE TABLE reindex_temp_before AS +SELECT oid, relname, relfilenode, relkind, reltoastrelid + FROM pg_class + WHERE relname IN ('concur_temp_ind_1', 'concur_temp_ind_2') +-- +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE reindex_temp_before AS SELECT oid, relname, relfilenode, relkind, reltoastrelid FROM..." +== 574 +-- truncate_limit: 100 +SELECT pg_my_temp_schema()::regnamespace as temp_schema_name +-- +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_my_temp_schema()::regnamespace AS temp_schema_name" +== 575 +-- truncate_limit: 100 +REINDEX SCHEMA CONCURRENTLY :temp_schema_name +-- +ERROR: syntax error at or near ":" +CURSORPOS: 29 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 576 +-- truncate_limit: 100 +SELECT b.relname, + b.relkind, + CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged' + ELSE 'relfilenode has changed' END + FROM reindex_temp_before b JOIN pg_class a ON b.oid = a.oid + ORDER BY 1 +-- +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_class" +ALIAS: "b"="reindex_temp_before" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM reindex_temp_before b JOIN pg_class a ON b.oid = a.oid ORDER BY 1" +== 577 +-- truncate_limit: 100 +DROP TABLE concur_temp_tab_1, concur_temp_tab_2, reindex_temp_before +-- +TABLE: name="concur_temp_tab_1" schema="" table="concur_temp_tab_1" ctx=DDL +TABLE: name="concur_temp_tab_2" schema="" table="concur_temp_tab_2" ctx=DDL +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_temp_tab_1, concur_temp_tab_2, reindex_temp_before" +== 578 +-- truncate_limit: 100 +|-- +-- REINDEX SCHEMA +|-- +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX SCHEMA schema_to_reindex" +== 579 +-- truncate_limit: 100 +-- failure, schema does not exist +CREATE SCHEMA schema_to_reindex +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA schema_to_reindex" +== 580 +-- truncate_limit: 100 +SET search_path = 'schema_to_reindex' +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO schema_to_reindex" +== 581 +-- truncate_limit: 100 +CREATE TABLE table1(col1 SERIAL PRIMARY KEY) +-- +TABLE: name="table1" schema="" table="table1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE table1 (col1 serial PRIMARY KEY)" +== 582 +-- truncate_limit: 100 +INSERT INTO table1 SELECT generate_series(1,400) +-- +TABLE: name="table1" schema="" table="table1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO table1 SELECT generate_series(1, 400)" +== 583 +-- truncate_limit: 100 +CREATE TABLE table2(col1 SERIAL PRIMARY KEY, col2 TEXT NOT NULL) +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE table2 (col1 serial PRIMARY KEY, col2 text NOT NULL)" +== 584 +-- truncate_limit: 100 +INSERT INTO table2 SELECT generate_series(1,400), 'abc' +-- +TABLE: name="table2" schema="" table="table2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO table2 SELECT generate_series(1, 400), 'abc'" +== 585 +-- truncate_limit: 100 +CREATE INDEX ON table2(col2) +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON table2 USING btree (col2)" +== 586 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW matview AS SELECT col1 FROM table2 +-- +TABLE: name="matview" schema="" table="matview" ctx=DDL +TABLE: name="table2" schema="" table="table2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW matview AS SELECT col1 FROM table2" +== 587 +-- truncate_limit: 100 +CREATE INDEX ON matview(col1) +-- +TABLE: name="matview" schema="" table="matview" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON matview USING btree (col1)" +== 588 +-- truncate_limit: 100 +CREATE VIEW view AS SELECT col2 FROM table2 +-- +TABLE: name="view" schema="" table="view" ctx=DDL +TABLE: name="table2" schema="" table="table2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view AS SELECT col2 FROM table2" +== 589 +-- truncate_limit: 100 +CREATE TABLE reindex_before AS +SELECT oid, relname, relfilenode, relkind, reltoastrelid + FROM pg_class + where relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'schema_to_reindex') +-- +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE reindex_before AS SELECT oid, relname, relfilenode, relkind, reltoastrelid FROM pg_c..." +== 590 +-- truncate_limit: 100 +INSERT INTO reindex_before +SELECT oid, 'pg_toast_TABLE', relfilenode, relkind, reltoastrelid +FROM pg_class WHERE oid IN + (SELECT reltoastrelid FROM reindex_before WHERE reltoastrelid > 0) +-- +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=DML +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=Select +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="reltoastrelid" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO reindex_before SELECT ... FROM pg_class WHERE ..." +== 591 +-- truncate_limit: 100 +INSERT INTO reindex_before +SELECT oid, 'pg_toast_TABLE_index', relfilenode, relkind, reltoastrelid +FROM pg_class where oid in + (select indexrelid from pg_index where indrelid in + (select reltoastrelid from reindex_before where reltoastrelid > 0)) +-- +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=DML +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=Select +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="reltoastrelid" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO reindex_before SELECT ... FROM pg_class WHERE ..." +== 592 +-- truncate_limit: 100 +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX SCHEMA schema_to_reindex" +== 593 +-- truncate_limit: 100 +CREATE TABLE reindex_after AS SELECT oid, relname, relfilenode, relkind + FROM pg_class + where relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'schema_to_reindex') +-- +TABLE: name="reindex_after" schema="" table="reindex_after" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE reindex_after AS SELECT oid, relname, relfilenode, relkind FROM pg_class WHERE relna..." +== 594 +-- truncate_limit: 100 +SELECT b.relname, + b.relkind, + CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged' + ELSE 'relfilenode has changed' END + FROM reindex_before b JOIN pg_class a ON b.oid = a.oid + ORDER BY 1 +-- +TABLE: name="reindex_before" schema="" table="reindex_before" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_class" +ALIAS: "b"="reindex_before" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM reindex_before b JOIN pg_class a ON b.oid = a.oid ORDER BY 1" +== 595 +-- truncate_limit: 100 +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX SCHEMA schema_to_reindex" +== 596 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 597 +-- truncate_limit: 100 +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX SCHEMA schema_to_reindex" +== 598 +-- truncate_limit: 100 +-- failure, cannot run in a transaction +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 599 +-- truncate_limit: 100 +-- concurrently +REINDEX SCHEMA CONCURRENTLY schema_to_reindex +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) SCHEMA schema_to_reindex" +== 600 +-- truncate_limit: 100 +-- Failure for unauthorized user +CREATE ROLE regress_reindexuser NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_reindexuser WITH NOLOGIN" +== 601 +-- truncate_limit: 100 +SET SESSION ROLE regress_reindexuser +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_reindexuser" +== 602 +-- truncate_limit: 100 +REINDEX SCHEMA schema_to_reindex +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX SCHEMA schema_to_reindex" +== 603 +-- truncate_limit: 100 +-- Permission failures with toast tables and indexes (pg_authid here) +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 604 +-- truncate_limit: 100 +GRANT USAGE ON SCHEMA pg_toast TO regress_reindexuser +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON SCHEMA pg_toast TO regress_reindexuser" +== 605 +-- truncate_limit: 100 +SET SESSION ROLE regress_reindexuser +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_reindexuser" +== 606 +-- truncate_limit: 100 +REINDEX TABLE pg_toast.pg_toast_1260 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE pg_toast.pg_toast_1260" +== 607 +-- truncate_limit: 100 +REINDEX INDEX pg_toast.pg_toast_1260_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX pg_toast.pg_toast_1260_index" +== 608 +-- truncate_limit: 100 +-- Clean up +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 609 +-- truncate_limit: 100 +REVOKE USAGE ON SCHEMA pg_toast FROM regress_reindexuser +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON SCHEMA pg_toast FROM regress_reindexuser" +== 610 +-- truncate_limit: 100 +DROP ROLE regress_reindexuser +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_reindexuser" +== 611 +-- truncate_limit: 100 +DROP SCHEMA schema_to_reindex CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA schema_to_reindex CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_index_spgist.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_index_spgist.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_index_spgist.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_index_spgist.test b/parser/testdata/summary_truncate/postgres_regress/create_index_spgist.test new file mode 100644 index 0000000..712a8e7 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_index_spgist.test @@ -0,0 +1,1989 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SP-GiST index tests +|-- + +CREATE TABLE quad_point_tbl AS + SELECT point(unique1,unique2) AS p FROM tenk1 +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE quad_point_tbl AS SELECT point(unique1, unique2) AS p FROM tenk1" +== 002 +-- truncate_limit: 100 +INSERT INTO quad_point_tbl + SELECT '(333.0,400.0)'::point FROM generate_series(1,1000) +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quad_point_tbl SELECT '(333.0,400.0)'::point FROM generate_series(1, 1000)" +== 003 +-- truncate_limit: 100 +INSERT INTO quad_point_tbl VALUES (NULL), (NULL), (NULL) +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quad_point_tbl VALUES (NULL), (NULL), (NULL)" +== 004 +-- truncate_limit: 100 +CREATE INDEX sp_quad_ind ON quad_point_tbl USING spgist (p) +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX sp_quad_ind ON quad_point_tbl USING spgist (p)" +== 005 +-- truncate_limit: 100 +CREATE TABLE kd_point_tbl AS SELECT * FROM quad_point_tbl +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE kd_point_tbl AS SELECT * FROM quad_point_tbl" +== 006 +-- truncate_limit: 100 +CREATE INDEX sp_kd_ind ON kd_point_tbl USING spgist (p kd_point_ops) +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX sp_kd_ind ON kd_point_tbl USING spgist (p kd_point_ops)" +== 007 +-- truncate_limit: 100 +CREATE TABLE radix_text_tbl AS + SELECT name AS t FROM road WHERE name !~ '^[0-9]' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DDL +TABLE: name="road" schema="" table="road" ctx=Select +FILTER: schema="" table="" column="name" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE radix_text_tbl AS SELECT name AS t FROM road WHERE name !~ '^[0-9]'" +== 008 +-- truncate_limit: 100 +INSERT INTO radix_text_tbl + SELECT 'P0123456789abcdef' FROM generate_series(1,1000) +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO radix_text_tbl SELECT 'P0123456789abcdef' FROM generate_series(1, 1000)" +== 009 +-- truncate_limit: 100 +INSERT INTO radix_text_tbl VALUES ('P0123456789abcde') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO radix_text_tbl VALUES ('P0123456789abcde')" +== 010 +-- truncate_limit: 100 +INSERT INTO radix_text_tbl VALUES ('P0123456789abcdefF') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO radix_text_tbl VALUES ('P0123456789abcdefF')" +== 011 +-- truncate_limit: 100 +CREATE INDEX sp_radix_ind ON radix_text_tbl USING spgist (t) +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX sp_radix_ind ON radix_text_tbl USING spgist (t)" +== 012 +-- truncate_limit: 100 +-- get non-indexed results for comparison purposes + +SET enable_seqscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 013 +-- truncate_limit: 100 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 014 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 015 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p IS NULL" +== 016 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL" +== 017 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl" +== 018 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 019 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 020 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)'" +== 021 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)'" +== 022 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)'" +== 023 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)'" +== 024 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)'" +== 025 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_point_tbl_ord_seq1 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_point_tbl_ord_seq1 AS SELECT row_number() OVER (ORDER BY p <-> '0,0')..." +== 026 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_point_tbl_ord_seq2 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl_ord_seq2" schema="" table="quad_point_tbl_ord_seq2" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_point_tbl_ord_seq2 AS SELECT row_number() OVER (ORDER BY p <-> '0,0')..." +== 027 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_point_tbl_ord_seq3 AS +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl_ord_seq3" schema="" table="quad_point_tbl_ord_seq3" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_point_tbl_ord_seq3 AS SELECT row_number() OVER (ORDER BY p <-> '333,4..." +== 028 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef'" +== 029 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde'" +== 030 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF'" +== 031 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct '" +== 032 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct '" +== 033 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct '" +== 034 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct '" +== 035 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct '" +== 036 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St '" +== 037 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St '" +== 038 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St '" +== 039 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St '" +== 040 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St '" +== 041 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth'" +== 042 +-- truncate_limit: 100 +-- Now check the results from plain indexscan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 043 +-- truncate_limit: 100 +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 044 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 045 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p IS NULL" +== 046 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p IS NULL" +== 047 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL" +== 048 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL" +== 049 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl" +== 050 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl" +== 051 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 052 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 053 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 054 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 055 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)'" +== 056 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)'" +== 057 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)'" +== 058 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)'" +== 059 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)'" +== 060 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)'" +== 061 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)'" +== 062 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)'" +== 063 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)'" +== 064 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)'" +== 065 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT row_number() OVER (ORDER BY p <-> '0,0') AS n, p <-> '0,0' AS dist, p ..." +== 066 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_point_tbl_ord_idx1 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl_ord_idx1" schema="" table="quad_point_tbl_ord_idx1" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_point_tbl_ord_idx1 AS SELECT row_number() OVER (ORDER BY p <-> '0,0')..." +== 067 +-- truncate_limit: 100 +SELECT * FROM quad_point_tbl_ord_seq1 seq FULL JOIN quad_point_tbl_ord_idx1 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=Select +TABLE: name="quad_point_tbl_ord_idx1" schema="" table="quad_point_tbl_ord_idx1" ctx=Select +ALIAS: "idx"="quad_point_tbl_ord_idx1" +ALIAS: "seq"="quad_point_tbl_ord_seq1" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_point_tbl_ord_seq1 seq FULL JOIN quad_point_tbl_ord_idx1 idx ON seq.n = idx.n ..." +== 068 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT row_number() OVER (ORDER BY p <-> '0,0') AS n, p <-> '0,0' AS dist, p ..." +== 069 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_point_tbl_ord_idx2 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl_ord_idx2" schema="" table="quad_point_tbl_ord_idx2" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_point_tbl_ord_idx2 AS SELECT row_number() OVER (ORDER BY p <-> '0,0')..." +== 070 +-- truncate_limit: 100 +SELECT * FROM quad_point_tbl_ord_seq2 seq FULL JOIN quad_point_tbl_ord_idx2 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq2" schema="" table="quad_point_tbl_ord_seq2" ctx=Select +TABLE: name="quad_point_tbl_ord_idx2" schema="" table="quad_point_tbl_ord_idx2" ctx=Select +ALIAS: "idx"="quad_point_tbl_ord_idx2" +ALIAS: "seq"="quad_point_tbl_ord_seq2" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_point_tbl_ord_seq2 seq FULL JOIN quad_point_tbl_ord_idx2 idx ON seq.n = idx.n ..." +== 071 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT row_number() OVER (ORDER BY p <-> '333,400') AS n, p <-> '333,400' AS ..." +== 072 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_point_tbl_ord_idx3 AS +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl_ord_idx3" schema="" table="quad_point_tbl_ord_idx3" ctx=DDL +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_point_tbl_ord_idx3 AS SELECT row_number() OVER (ORDER BY p <-> '333,4..." +== 073 +-- truncate_limit: 100 +SELECT * FROM quad_point_tbl_ord_seq3 seq FULL JOIN quad_point_tbl_ord_idx3 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq3" schema="" table="quad_point_tbl_ord_seq3" ctx=Select +TABLE: name="quad_point_tbl_ord_idx3" schema="" table="quad_point_tbl_ord_idx3" ctx=Select +ALIAS: "idx"="quad_point_tbl_ord_idx3" +ALIAS: "seq"="quad_point_tbl_ord_seq3" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_point_tbl_ord_seq3 seq FULL JOIN quad_point_tbl_ord_idx3 idx ON seq.n = idx.n ..." +== 074 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 075 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 076 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 077 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 078 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)'" +== 079 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)'" +== 080 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)'" +== 081 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)'" +== 082 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)'" +== 083 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)'" +== 084 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)'" +== 085 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)'" +== 086 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)'" +== 087 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)'" +== 088 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM kd_point_tbl +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT row_number() OVER (ORDER BY p <-> '0,0') AS n, p <-> '0,0' AS dist, p ..." +== 089 +-- truncate_limit: 100 +CREATE TEMP TABLE kd_point_tbl_ord_idx1 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM kd_point_tbl +-- +TABLE: name="kd_point_tbl_ord_idx1" schema="" table="kd_point_tbl_ord_idx1" ctx=DDL +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE kd_point_tbl_ord_idx1 AS SELECT row_number() OVER (ORDER BY p <-> '0,0') A..." +== 090 +-- truncate_limit: 100 +SELECT * FROM quad_point_tbl_ord_seq1 seq FULL JOIN kd_point_tbl_ord_idx1 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=Select +TABLE: name="kd_point_tbl_ord_idx1" schema="" table="kd_point_tbl_ord_idx1" ctx=Select +ALIAS: "idx"="kd_point_tbl_ord_idx1" +ALIAS: "seq"="quad_point_tbl_ord_seq1" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_point_tbl_ord_seq1 seq FULL JOIN kd_point_tbl_ord_idx1 idx ON seq.n = idx.n WH..." +== 091 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT row_number() OVER (ORDER BY p <-> '0,0') AS n, p <-> '0,0' AS dist, p ..." +== 092 +-- truncate_limit: 100 +CREATE TEMP TABLE kd_point_tbl_ord_idx2 AS +SELECT row_number() OVER (ORDER BY p <-> '0,0') n, p <-> '0,0' dist, p +FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl_ord_idx2" schema="" table="kd_point_tbl_ord_idx2" ctx=DDL +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE kd_point_tbl_ord_idx2 AS SELECT row_number() OVER (ORDER BY p <-> '0,0') A..." +== 093 +-- truncate_limit: 100 +SELECT * FROM quad_point_tbl_ord_seq2 seq FULL JOIN kd_point_tbl_ord_idx2 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq2" schema="" table="quad_point_tbl_ord_seq2" ctx=Select +TABLE: name="kd_point_tbl_ord_idx2" schema="" table="kd_point_tbl_ord_idx2" ctx=Select +ALIAS: "idx"="kd_point_tbl_ord_idx2" +ALIAS: "seq"="quad_point_tbl_ord_seq2" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_point_tbl_ord_seq2 seq FULL JOIN kd_point_tbl_ord_idx2 idx ON seq.n = idx.n WH..." +== 094 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM kd_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT row_number() OVER (ORDER BY p <-> '333,400') AS n, p <-> '333,400' AS ..." +== 095 +-- truncate_limit: 100 +CREATE TEMP TABLE kd_point_tbl_ord_idx3 AS +SELECT row_number() OVER (ORDER BY p <-> '333,400') n, p <-> '333,400' dist, p +FROM kd_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="kd_point_tbl_ord_idx3" schema="" table="kd_point_tbl_ord_idx3" ctx=DDL +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE kd_point_tbl_ord_idx3 AS SELECT row_number() OVER (ORDER BY p <-> '333,400..." +== 096 +-- truncate_limit: 100 +SELECT * FROM quad_point_tbl_ord_seq3 seq FULL JOIN kd_point_tbl_ord_idx3 idx +ON seq.n = idx.n +WHERE seq.dist IS DISTINCT FROM idx.dist +-- +TABLE: name="quad_point_tbl_ord_seq3" schema="" table="quad_point_tbl_ord_seq3" ctx=Select +TABLE: name="kd_point_tbl_ord_idx3" schema="" table="kd_point_tbl_ord_idx3" ctx=Select +ALIAS: "idx"="kd_point_tbl_ord_idx3" +ALIAS: "seq"="quad_point_tbl_ord_seq3" +FILTER: schema="" table="seq" column="dist" +FILTER: schema="" table="idx" column="dist" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_point_tbl_ord_seq3 seq FULL JOIN kd_point_tbl_ord_idx3 idx ON seq.n = idx.n WH..." +== 097 +-- truncate_limit: 100 +-- test KNN scan with included columns +-- the distance numbers are not exactly the same across platforms +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO 0" +== 098 +-- truncate_limit: 100 +CREATE INDEX ON quad_point_tbl_ord_seq1 USING spgist(p) INCLUDE(dist) +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON quad_point_tbl_ord_seq1 USING spgist (p) INCLUDE (dist)" +== 099 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT p, dist FROM quad_point_tbl_ord_seq1 ORDER BY p <-> '0,0' LIMIT 10 +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p, dist FROM quad_point_tbl_ord_seq1 ORDER BY p <-> '0,0' LIMIT 10" +== 100 +-- truncate_limit: 100 +SELECT p, dist FROM quad_point_tbl_ord_seq1 ORDER BY p <-> '0,0' LIMIT 10 +-- +TABLE: name="quad_point_tbl_ord_seq1" schema="" table="quad_point_tbl_ord_seq1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT p, dist FROM quad_point_tbl_ord_seq1 ORDER BY p <-> '0,0' LIMIT 10" +== 101 +-- truncate_limit: 100 +RESET extra_float_digits +-- +STMT: VariableSetStmt +TRUNCATED: "RESET extra_float_digits" +== 102 +-- truncate_limit: 100 +-- check ORDER BY distance to NULL +SELECT (SELECT p FROM kd_point_tbl ORDER BY p <-> pt, p <-> '0,0' LIMIT 1) +FROM (VALUES (point '1,2'), (NULL), ('1234,5678')) pts(pt) +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) pts(pt)" +== 103 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef'" +== 104 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef'" +== 105 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde'" +== 106 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde'" +== 107 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF'" +== 108 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF'" +== 109 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec ..." +== 110 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct '" +== 111 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec ..." +== 112 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct '" +== 113 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec ..." +== 114 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct '" +== 115 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec ..." +== 116 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct '" +== 117 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec ..." +== 118 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct '" +== 119 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth ..." +== 120 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St '" +== 121 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth ..." +== 122 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St '" +== 123 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth ..." +== 124 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St '" +== 125 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth ..." +== 126 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St '" +== 127 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth ..." +== 128 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St '" +== 129 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth'" +== 130 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth'" +== 131 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth')" +== 132 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth')" +== 133 +-- truncate_limit: 100 +-- Now check the results from bitmap indexscan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 134 +-- truncate_limit: 100 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 135 +-- truncate_limit: 100 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 136 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p IS NULL" +== 137 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p IS NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p IS NULL" +== 138 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL" +== 139 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p IS NOT NULL" +== 140 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl" +== 141 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl" +== 142 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 143 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 144 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 145 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 146 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)'" +== 147 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p << '(5000, 4000)'" +== 148 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)'" +== 149 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p >> '(5000, 4000)'" +== 150 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)'" +== 151 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p <<| '(5000, 4000)'" +== 152 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)'" +== 153 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p |>> '(5000, 4000)'" +== 154 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)'" +== 155 +-- truncate_limit: 100 +SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="quad_point_tbl" schema="" table="quad_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_point_tbl WHERE p ~= '(4585, 365)'" +== 156 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 157 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p <@ box '(200,200,1000,1000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p <@ '(200,200,1000,1000)'::box" +== 158 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 159 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE box '(200,200,1000,1000)' @> p +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE '(200,200,1000,1000)'::box @> p" +== 160 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)'" +== 161 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p << '(5000, 4000)'" +== 162 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)'" +== 163 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p >> '(5000, 4000)'" +== 164 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)'" +== 165 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p <<| '(5000, 4000)'" +== 166 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)'" +== 167 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p |>> '(5000, 4000)'" +== 168 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)'" +== 169 +-- truncate_limit: 100 +SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)' +-- +TABLE: name="kd_point_tbl" schema="" table="kd_point_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM kd_point_tbl WHERE p ~= '(4585, 365)'" +== 170 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef'" +== 171 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdef'" +== 172 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde'" +== 173 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcde'" +== 174 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF'" +== 175 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'P0123456789abcdefF'" +== 176 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec ..." +== 177 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t < 'Aztec Ct '" +== 178 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec ..." +== 179 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~<~ 'Aztec Ct '" +== 180 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec ..." +== 181 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t <= 'Aztec Ct '" +== 182 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec ..." +== 183 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~<=~ 'Aztec Ct '" +== 184 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec ..." +== 185 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'Aztec Ct '" +== 186 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth ..." +== 187 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t = 'Worth St '" +== 188 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth ..." +== 189 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t >= 'Worth St '" +== 190 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth ..." +== 191 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~>=~ 'Worth St '" +== 192 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth ..." +== 193 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t > 'Worth St '" +== 194 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth ..." +== 195 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St ' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ~>~ 'Worth St '" +== 196 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth'" +== 197 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth' +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE t ^@ 'Worth'" +== 198 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth')" +== 199 +-- truncate_limit: 100 +SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth') +-- +TABLE: name="radix_text_tbl" schema="" table="radix_text_tbl" ctx=Select +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="starts_with" function="starts_with" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM radix_text_tbl WHERE starts_with(t, 'Worth')" +== 200 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 201 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 202 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_misc.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_misc.test b/parser/testdata/summary_truncate/postgres_regress/create_misc.test new file mode 100644 index 0000000..8a672f0 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_misc.test @@ -0,0 +1,764 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_MISC +|-- + +|-- +-- a is the type root +-- b and c inherit from a (one-level single inheritance) +-- d inherits from b and c (two-level multiple inheritance) +-- e inherits from c (two-level single inheritance) +-- f inherits from e (three-level single inheritance) +|-- +CREATE TABLE a_star ( + class char, + a int4 +) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE a_star (class char(1), a int4)" +== 002 +-- truncate_limit: 100 +CREATE TABLE b_star ( + b text +) INHERITS (a_star) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE b_star (b text) INHERITS (a_star)" +== 003 +-- truncate_limit: 100 +CREATE TABLE c_star ( + c name +) INHERITS (a_star) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c_star (c name) INHERITS (a_star)" +== 004 +-- truncate_limit: 100 +CREATE TABLE d_star ( + d float8 +) INHERITS (b_star, c_star) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE d_star (d float8) INHERITS (b_star, c_star)" +== 005 +-- truncate_limit: 100 +CREATE TABLE e_star ( + e int2 +) INHERITS (c_star) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE e_star (e int2) INHERITS (c_star)" +== 006 +-- truncate_limit: 100 +CREATE TABLE f_star ( + f polygon +) INHERITS (e_star) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE f_star (f polygon) INHERITS (e_star)" +== 007 +-- truncate_limit: 100 +INSERT INTO a_star (class, a) VALUES ('a', 1) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a_star (class, a) VALUES ('a', 1)" +== 008 +-- truncate_limit: 100 +INSERT INTO a_star (class, a) VALUES ('a', 2) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a_star (class, a) VALUES ('a', 2)" +== 009 +-- truncate_limit: 100 +INSERT INTO a_star (class) VALUES ('a') +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a_star (class) VALUES ('a')" +== 010 +-- truncate_limit: 100 +INSERT INTO b_star (class, a, b) VALUES ('b', 3, 'mumble'::text) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b_star (class, a, b) VALUES ('b', 3, 'mumble'::text)" +== 011 +-- truncate_limit: 100 +INSERT INTO b_star (class, a) VALUES ('b', 4) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b_star (class, a) VALUES ('b', 4)" +== 012 +-- truncate_limit: 100 +INSERT INTO b_star (class, b) VALUES ('b', 'bumble'::text) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b_star (class, b) VALUES ('b', 'bumble'::text)" +== 013 +-- truncate_limit: 100 +INSERT INTO b_star (class) VALUES ('b') +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b_star (class) VALUES ('b')" +== 014 +-- truncate_limit: 100 +INSERT INTO c_star (class, a, c) VALUES ('c', 5, 'hi mom'::name) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c_star (class, a, c) VALUES ('c', 5, 'hi mom'::name)" +== 015 +-- truncate_limit: 100 +INSERT INTO c_star (class, a) VALUES ('c', 6) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c_star (class, a) VALUES ('c', 6)" +== 016 +-- truncate_limit: 100 +INSERT INTO c_star (class, c) VALUES ('c', 'hi paul'::name) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c_star (class, c) VALUES ('c', 'hi paul'::name)" +== 017 +-- truncate_limit: 100 +INSERT INTO c_star (class) VALUES ('c') +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c_star (class) VALUES ('c')" +== 018 +-- truncate_limit: 100 +INSERT INTO d_star (class, a, b, c, d) + VALUES ('d', 7, 'grumble'::text, 'hi sunita'::name, '0.0'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, a, b, c, d) VALUES (...)" +== 019 +-- truncate_limit: 100 +INSERT INTO d_star (class, a, b, c) + VALUES ('d', 8, 'stumble'::text, 'hi koko'::name) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, a, b, c) VALUES ('d', 8, 'stumble'::text, 'hi koko'::name)" +== 020 +-- truncate_limit: 100 +INSERT INTO d_star (class, a, b, d) + VALUES ('d', 9, 'rumble'::text, '1.1'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, a, b, d) VALUES ('d', 9, 'rumble'::text, '1.1'::float8)" +== 021 +-- truncate_limit: 100 +INSERT INTO d_star (class, a, c, d) + VALUES ('d', 10, 'hi kristin'::name, '10.01'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, a, c, d) VALUES ('d', 10, 'hi kristin'::name, '10.01'::float8)" +== 022 +-- truncate_limit: 100 +INSERT INTO d_star (class, b, c, d) + VALUES ('d', 'crumble'::text, 'hi boris'::name, '100.001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, b, c, d) VALUES (...)" +== 023 +-- truncate_limit: 100 +INSERT INTO d_star (class, a, b) + VALUES ('d', 11, 'fumble'::text) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, a, b) VALUES ('d', 11, 'fumble'::text)" +== 024 +-- truncate_limit: 100 +INSERT INTO d_star (class, a, c) + VALUES ('d', 12, 'hi avi'::name) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, a, c) VALUES ('d', 12, 'hi avi'::name)" +== 025 +-- truncate_limit: 100 +INSERT INTO d_star (class, a, d) + VALUES ('d', 13, '1000.0001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, a, d) VALUES ('d', 13, '1000.0001'::float8)" +== 026 +-- truncate_limit: 100 +INSERT INTO d_star (class, b, c) + VALUES ('d', 'tumble'::text, 'hi andrew'::name) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, b, c) VALUES ('d', 'tumble'::text, 'hi andrew'::name)" +== 027 +-- truncate_limit: 100 +INSERT INTO d_star (class, b, d) + VALUES ('d', 'humble'::text, '10000.00001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, b, d) VALUES ('d', 'humble'::text, '10000.00001'::float8)" +== 028 +-- truncate_limit: 100 +INSERT INTO d_star (class, c, d) + VALUES ('d', 'hi ginger'::name, '100000.000001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, c, d) VALUES ('d', 'hi ginger'::name, '100000.000001'::float8)" +== 029 +-- truncate_limit: 100 +INSERT INTO d_star (class, a) VALUES ('d', 14) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, a) VALUES ('d', 14)" +== 030 +-- truncate_limit: 100 +INSERT INTO d_star (class, b) VALUES ('d', 'jumble'::text) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, b) VALUES ('d', 'jumble'::text)" +== 031 +-- truncate_limit: 100 +INSERT INTO d_star (class, c) VALUES ('d', 'hi jolly'::name) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, c) VALUES ('d', 'hi jolly'::name)" +== 032 +-- truncate_limit: 100 +INSERT INTO d_star (class, d) VALUES ('d', '1000000.0000001'::float8) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class, d) VALUES ('d', '1000000.0000001'::float8)" +== 033 +-- truncate_limit: 100 +INSERT INTO d_star (class) VALUES ('d') +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d_star (class) VALUES ('d')" +== 034 +-- truncate_limit: 100 +INSERT INTO e_star (class, a, c, e) + VALUES ('e', 15, 'hi carol'::name, '-1'::int2) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO e_star (class, a, c, e) VALUES ('e', 15, 'hi carol'::name, '-1'::int2)" +== 035 +-- truncate_limit: 100 +INSERT INTO e_star (class, a, c) + VALUES ('e', 16, 'hi bob'::name) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO e_star (class, a, c) VALUES ('e', 16, 'hi bob'::name)" +== 036 +-- truncate_limit: 100 +INSERT INTO e_star (class, a, e) + VALUES ('e', 17, '-2'::int2) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO e_star (class, a, e) VALUES ('e', 17, '-2'::int2)" +== 037 +-- truncate_limit: 100 +INSERT INTO e_star (class, c, e) + VALUES ('e', 'hi michelle'::name, '-3'::int2) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO e_star (class, c, e) VALUES ('e', 'hi michelle'::name, '-3'::int2)" +== 038 +-- truncate_limit: 100 +INSERT INTO e_star (class, a) + VALUES ('e', 18) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO e_star (class, a) VALUES ('e', 18)" +== 039 +-- truncate_limit: 100 +INSERT INTO e_star (class, c) + VALUES ('e', 'hi elisa'::name) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO e_star (class, c) VALUES ('e', 'hi elisa'::name)" +== 040 +-- truncate_limit: 100 +INSERT INTO e_star (class, e) + VALUES ('e', '-4'::int2) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO e_star (class, e) VALUES ('e', '-4'::int2)" +== 041 +-- truncate_limit: 100 +INSERT INTO f_star (class, a, c, e, f) + VALUES ('f', 19, 'hi claire'::name, '-5'::int2, '(1,3),(2,4)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, a, c, e, f) VALUES (...)" +== 042 +-- truncate_limit: 100 +INSERT INTO f_star (class, a, c, e) + VALUES ('f', 20, 'hi mike'::name, '-6'::int2) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, a, c, e) VALUES ('f', 20, 'hi mike'::name, '-6'::int2)" +== 043 +-- truncate_limit: 100 +INSERT INTO f_star (class, a, c, f) + VALUES ('f', 21, 'hi marcel'::name, '(11,44),(22,55),(33,66)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, a, c, f) VALUES (...)" +== 044 +-- truncate_limit: 100 +INSERT INTO f_star (class, a, e, f) + VALUES ('f', 22, '-7'::int2, '(111,555),(222,666),(333,777),(444,888)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, a, e, f) VALUES (...)" +== 045 +-- truncate_limit: 100 +INSERT INTO f_star (class, c, e, f) + VALUES ('f', 'hi keith'::name, '-8'::int2, + '(1111,3333),(2222,4444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, c, e, f) VALUES (...)" +== 046 +-- truncate_limit: 100 +INSERT INTO f_star (class, a, c) + VALUES ('f', 24, 'hi marc'::name) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, a, c) VALUES ('f', 24, 'hi marc'::name)" +== 047 +-- truncate_limit: 100 +INSERT INTO f_star (class, a, e) + VALUES ('f', 25, '-9'::int2) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, a, e) VALUES ('f', 25, '-9'::int2)" +== 048 +-- truncate_limit: 100 +INSERT INTO f_star (class, a, f) + VALUES ('f', 26, '(11111,33333),(22222,44444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, a, f) VALUES ('f', 26, '(11111,33333),(22222,44444)'::polygon)" +== 049 +-- truncate_limit: 100 +INSERT INTO f_star (class, c, e) + VALUES ('f', 'hi allison'::name, '-10'::int2) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, c, e) VALUES ('f', 'hi allison'::name, '-10'::int2)" +== 050 +-- truncate_limit: 100 +INSERT INTO f_star (class, c, f) + VALUES ('f', 'hi jeff'::name, + '(111111,333333),(222222,444444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, c, f) VALUES (...)" +== 051 +-- truncate_limit: 100 +INSERT INTO f_star (class, e, f) + VALUES ('f', '-11'::int2, '(1111111,3333333),(2222222,4444444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, e, f) VALUES (...)" +== 052 +-- truncate_limit: 100 +INSERT INTO f_star (class, a) VALUES ('f', 27) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, a) VALUES ('f', 27)" +== 053 +-- truncate_limit: 100 +INSERT INTO f_star (class, c) VALUES ('f', 'hi carl'::name) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, c) VALUES ('f', 'hi carl'::name)" +== 054 +-- truncate_limit: 100 +INSERT INTO f_star (class, e) VALUES ('f', '-12'::int2) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, e) VALUES ('f', '-12'::int2)" +== 055 +-- truncate_limit: 100 +INSERT INTO f_star (class, f) + VALUES ('f', '(11111111,33333333),(22222222,44444444)'::polygon) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class, f) VALUES ('f', '(11111111,33333333),(22222222,44444444)'::polygon)" +== 056 +-- truncate_limit: 100 +INSERT INTO f_star (class) VALUES ('f') +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO f_star (class) VALUES ('f')" +== 057 +-- truncate_limit: 100 +-- Analyze the X_star tables for better plan stability in later tests +ANALYZE a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE a_star" +== 058 +-- truncate_limit: 100 +ANALYZE b_star +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE b_star" +== 059 +-- truncate_limit: 100 +ANALYZE c_star +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE c_star" +== 060 +-- truncate_limit: 100 +ANALYZE d_star +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE d_star" +== 061 +-- truncate_limit: 100 +ANALYZE e_star +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE e_star" +== 062 +-- truncate_limit: 100 +ANALYZE f_star +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE f_star" +== 063 +-- truncate_limit: 100 +|-- +-- inheritance stress test +|-- +SELECT * FROM a_star* +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM a_star" +== 064 +-- truncate_limit: 100 +SELECT * + FROM b_star* x + WHERE x.b = text 'bumble' or x.a < 3 +-- +TABLE: name="b_star" schema="" table="b_star" ctx=Select +ALIAS: "x"="b_star" +FILTER: schema="" table="x" column="b" +FILTER: schema="" table="x" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM b_star x WHERE x.b = 'bumble'::text OR x.a < 3" +== 065 +-- truncate_limit: 100 +SELECT class, a + FROM c_star* x + WHERE x.c ~ text 'hi' +-- +TABLE: name="c_star" schema="" table="c_star" ctx=Select +ALIAS: "x"="c_star" +FILTER: schema="" table="x" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT class, a FROM c_star x WHERE x.c ~ 'hi'::text" +== 066 +-- truncate_limit: 100 +SELECT class, b, c + FROM d_star* x + WHERE x.a < 100 +-- +TABLE: name="d_star" schema="" table="d_star" ctx=Select +ALIAS: "x"="d_star" +FILTER: schema="" table="x" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT class, b, c FROM d_star x WHERE x.a < 100" +== 067 +-- truncate_limit: 100 +SELECT class, c FROM e_star* x WHERE x.c NOTNULL +-- +TABLE: name="e_star" schema="" table="e_star" ctx=Select +ALIAS: "x"="e_star" +FILTER: schema="" table="x" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT class, c FROM e_star x WHERE x.c IS NOT NULL" +== 068 +-- truncate_limit: 100 +SELECT * FROM f_star* x WHERE x.c ISNULL +-- +TABLE: name="f_star" schema="" table="f_star" ctx=Select +ALIAS: "x"="f_star" +FILTER: schema="" table="x" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM f_star x WHERE x.c IS NULL" +== 069 +-- truncate_limit: 100 +-- grouping and aggregation on inherited sets have been busted in the past... + +SELECT sum(a) FROM a_star* +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(a) FROM a_star" +== 070 +-- truncate_limit: 100 +SELECT class, sum(a) FROM a_star* GROUP BY class ORDER BY class +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT class, sum(a) FROM a_star GROUP BY class ORDER BY class" +== 071 +-- truncate_limit: 100 +ALTER TABLE f_star RENAME COLUMN f TO ff +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE f_star RENAME COLUMN f TO ff" +== 072 +-- truncate_limit: 100 +ALTER TABLE e_star* RENAME COLUMN e TO ee +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE e_star RENAME COLUMN e TO ee" +== 073 +-- truncate_limit: 100 +ALTER TABLE d_star* RENAME COLUMN d TO dd +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE d_star RENAME COLUMN d TO dd" +== 074 +-- truncate_limit: 100 +ALTER TABLE c_star* RENAME COLUMN c TO cc +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE c_star RENAME COLUMN c TO cc" +== 075 +-- truncate_limit: 100 +ALTER TABLE b_star* RENAME COLUMN b TO bb +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE b_star RENAME COLUMN b TO bb" +== 076 +-- truncate_limit: 100 +ALTER TABLE a_star* RENAME COLUMN a TO aa +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE a_star RENAME COLUMN a TO aa" +== 077 +-- truncate_limit: 100 +SELECT class, aa + FROM a_star* x + WHERE aa ISNULL +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "x"="a_star" +FILTER: schema="" table="" column="aa" +STMT: SelectStmt +TRUNCATED: "SELECT class, aa FROM a_star x WHERE aa IS NULL" +== 078 +-- truncate_limit: 100 +-- As of Postgres 7.1, ALTER implicitly recurses, +-- so this should be same as ALTER a_star* + +ALTER TABLE a_star RENAME COLUMN aa TO foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE a_star RENAME COLUMN aa TO foo" +== 079 +-- truncate_limit: 100 +SELECT class, foo + FROM a_star* x + WHERE x.foo >= 2 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "x"="a_star" +FILTER: schema="" table="x" column="foo" +STMT: SelectStmt +TRUNCATED: "SELECT class, foo FROM a_star x WHERE x.foo >= 2" +== 080 +-- truncate_limit: 100 +ALTER TABLE a_star RENAME COLUMN foo TO aa +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE a_star RENAME COLUMN foo TO aa" +== 081 +-- truncate_limit: 100 +SELECT * + from a_star* + WHERE aa < 1000 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FILTER: schema="" table="" column="aa" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM a_star WHERE aa < 1000" +== 082 +-- truncate_limit: 100 +ALTER TABLE f_star ADD COLUMN f int4 +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE f_star ADD COLUMN f int4" +== 083 +-- truncate_limit: 100 +UPDATE f_star SET f = 10 +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE f_star SET f = 10" +== 084 +-- truncate_limit: 100 +ALTER TABLE e_star* ADD COLUMN e int4 +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE e_star ADD COLUMN e int4" +== 085 +-- truncate_limit: 100 +--UPDATE e_star* SET e = 42; + +SELECT * FROM e_star* +-- +TABLE: name="e_star" schema="" table="e_star" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM e_star" +== 086 +-- truncate_limit: 100 +ALTER TABLE a_star* ADD COLUMN a text +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE a_star ADD COLUMN a text" +== 087 +-- truncate_limit: 100 +-- That ALTER TABLE should have added TOAST tables. +SELECT relname, reltoastrelid <> 0 AS has_toast_table + FROM pg_class + WHERE oid::regclass IN ('a_star', 'c_star') + ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class WHERE oid::regclass IN ('a_star', 'c_star') ORDER BY 1" +== 088 +-- truncate_limit: 100 +--UPDATE b_star* +-- SET a = text 'gazpacho' +-- WHERE aa > 4; + +SELECT class, aa, a FROM a_star* +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT class, aa, a FROM a_star" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_operator.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_operator.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_operator.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_operator.test b/parser/testdata/summary_truncate/postgres_regress/create_operator.test new file mode 100644 index 0000000..52b5429 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_operator.test @@ -0,0 +1,708 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_OPERATOR +|-- + +CREATE OPERATOR ## ( + leftarg = path, + rightarg = path, + function = path_inter, + commutator = ## +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR ## (leftarg = path, rightarg = path, function = path_inter, commutator = ##)" +== 002 +-- truncate_limit: 100 +CREATE OPERATOR @#@ ( + rightarg = int8, -- prefix + procedure = factorial +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR @#@ (rightarg = int8, procedure = factorial)" +== 003 +-- truncate_limit: 100 +CREATE OPERATOR #%# ( + leftarg = int8, -- fail, postfix is no longer supported + procedure = factorial +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #%# (leftarg = int8, procedure = factorial)" +== 004 +-- truncate_limit: 100 +-- Test operator created above +SELECT @#@ 24 +-- +STMT: SelectStmt +TRUNCATED: "SELECT @#@ 24" +== 005 +-- truncate_limit: 100 +-- Test comments +COMMENT ON OPERATOR ###### (NONE, int4) IS 'bad prefix' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON OPERATOR ######(NONE, int4) IS 'bad prefix'" +== 006 +-- truncate_limit: 100 +COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad postfix' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON OPERATOR ######(int4, NONE) IS 'bad postfix'" +== 007 +-- truncate_limit: 100 +COMMENT ON OPERATOR ###### (int4, int8) IS 'bad infix' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON OPERATOR ######(int4, int8) IS 'bad infix'" +== 008 +-- truncate_limit: 100 +-- Check that DROP on a nonexistent op behaves sanely, too +DROP OPERATOR ###### (NONE, int4) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ######(NONE, int4)" +== 009 +-- truncate_limit: 100 +DROP OPERATOR ###### (int4, NONE) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ######(int4, NONE)" +== 010 +-- truncate_limit: 100 +DROP OPERATOR ###### (int4, int8) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ######(int4, int8)" +== 011 +-- truncate_limit: 100 +-- => is disallowed as an operator name now +CREATE OPERATOR => ( + rightarg = int8, + procedure = factorial +) +-- +ERROR: syntax error at or near "=>" +CURSORPOS: 61 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +-- truncate_limit: 100 +-- lexing of <=, >=, <>, != has a number of edge cases +-- (=> is tested elsewhere) + +-- this is legal because ! is not allowed in sql ops +CREATE OPERATOR !=- ( + rightarg = int8, + procedure = factorial +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR !=- (rightarg = int8, procedure = factorial)" +== 013 +-- truncate_limit: 100 +SELECT !=- 10 +-- +STMT: SelectStmt +TRUNCATED: "SELECT !=- 10" +== 014 +-- truncate_limit: 100 +-- postfix operators don't work anymore +SELECT 10 !=- +-- +ERROR: syntax error at end of input +CURSORPOS: 54 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 015 +-- truncate_limit: 100 +-- make sure lexer returns != as <> even in edge cases +SELECT 2 !=/**/ 1, 2 !=/**/ 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 <> 1, 2 <> 2" +== 016 +-- truncate_limit: 100 +SELECT 2 !=-- comment to be removed by psql + 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 <> 1" +== 017 +-- truncate_limit: 100 +DO $$ -- use DO to protect -- from psql + declare r boolean; + begin + execute $e$ select 2 !=-- comment + 1 $e$ into r; + raise info 'r = %', r; + end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$ -- use DO to protect -- from psql\n declare r boolean;\n begin\n execute $e$ select 2 !=-..." +== 018 +-- truncate_limit: 100 +-- check that <= etc. followed by more operator characters are returned +-- as the correct token with correct precedence +SELECT true<>-1 BETWEEN 1 AND 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT true <> (-1 BETWEEN 1 AND 1)" +== 019 +-- truncate_limit: 100 +-- BETWEEN has prec. above <> but below Op +SELECT false<>/**/1 BETWEEN 1 AND 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT false <> (1 BETWEEN 1 AND 1)" +== 020 +-- truncate_limit: 100 +SELECT false<=-1 BETWEEN 1 AND 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT false <= (-1 BETWEEN 1 AND 1)" +== 021 +-- truncate_limit: 100 +SELECT false>=-1 BETWEEN 1 AND 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT false >= (-1 BETWEEN 1 AND 1)" +== 022 +-- truncate_limit: 100 +SELECT 2<=/**/3, 3>=/**/2, 2<>/**/3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 <= 3, 3 >= 2, 2 <> 3" +== 023 +-- truncate_limit: 100 +SELECT 3<=/**/2, 2>=/**/3, 2<>/**/2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 3 <= 2, 2 >= 3, 2 <> 2" +== 024 +-- truncate_limit: 100 +-- Should fail. CREATE OPERATOR requires USAGE on SCHEMA +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 025 +-- truncate_limit: 100 +CREATE ROLE regress_rol_op1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rol_op1" +== 026 +-- truncate_limit: 100 +CREATE SCHEMA schema_op1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA schema_op1" +== 027 +-- truncate_limit: 100 +GRANT USAGE ON SCHEMA schema_op1 TO PUBLIC +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON SCHEMA schema_op1 TO public" +== 028 +-- truncate_limit: 100 +REVOKE USAGE ON SCHEMA schema_op1 FROM regress_rol_op1 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON SCHEMA schema_op1 FROM regress_rol_op1" +== 029 +-- truncate_limit: 100 +SET ROLE regress_rol_op1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_op1" +== 030 +-- truncate_limit: 100 +CREATE OPERATOR schema_op1.#*# ( + rightarg = int8, + procedure = factorial +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR schema_op1.#*# (rightarg = int8, procedure = factorial)" +== 031 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 032 +-- truncate_limit: 100 +-- Should fail. SETOF type functions not allowed as argument (testing leftarg) +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 033 +-- truncate_limit: 100 +CREATE OPERATOR #*# ( + leftarg = SETOF int8, + procedure = factorial +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #*# (leftarg = SETOF int8, procedure = factorial)" +== 034 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 035 +-- truncate_limit: 100 +-- Should fail. SETOF type functions not allowed as argument (testing rightarg) +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 036 +-- truncate_limit: 100 +CREATE OPERATOR #*# ( + rightarg = SETOF int8, + procedure = factorial +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #*# (rightarg = SETOF int8, procedure = factorial)" +== 037 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 038 +-- truncate_limit: 100 +-- Should work. Sample text-book case +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 039 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean) +RETURNS boolean AS $$ + SELECT NULL::BOOLEAN; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op2" function="fn_op2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean) RETURNS boolean AS $$\n SELECT NULL::BOOLEA..." +== 040 +-- truncate_limit: 100 +CREATE OPERATOR === ( + LEFTARG = boolean, + RIGHTARG = boolean, + PROCEDURE = fn_op2, + COMMUTATOR = ===, + NEGATOR = !==, + RESTRICT = contsel, + JOIN = contjoinsel, + SORT1, SORT2, LTCMP, GTCMP, HASHES, MERGES +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (leftarg = boolean, rightarg = boolean, procedure = fn_op2, commutator = ===,..." +== 041 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 042 +-- truncate_limit: 100 +-- Should fail. Invalid attribute +CREATE OPERATOR #@%# ( + rightarg = int8, + procedure = factorial, + invalid_att = int8 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #@%# (rightarg = int8, procedure = factorial, invalid_att = int8)" +== 043 +-- truncate_limit: 100 +-- Should fail. At least rightarg should be mandatorily specified +CREATE OPERATOR #@%# ( + procedure = factorial +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #@%# (procedure = factorial)" +== 044 +-- truncate_limit: 100 +-- Should fail. Procedure should be mandatorily specified +CREATE OPERATOR #@%# ( + rightarg = int8 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #@%# (rightarg = int8)" +== 045 +-- truncate_limit: 100 +-- Should fail. CREATE OPERATOR requires USAGE on TYPE +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 046 +-- truncate_limit: 100 +CREATE ROLE regress_rol_op3 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rol_op3" +== 047 +-- truncate_limit: 100 +CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed')" +== 048 +-- truncate_limit: 100 +CREATE FUNCTION fn_op3(type_op3, int8) +RETURNS int8 AS $$ + SELECT NULL::int8; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op3" function="fn_op3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn_op3(type_op3, int8) RETURNS int8 AS $$\n SELECT NULL::int8;\n$$ LANGUAGE sql ..." +== 049 +-- truncate_limit: 100 +REVOKE USAGE ON TYPE type_op3 FROM regress_rol_op3 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE type_op3 FROM regress_rol_op3" +== 050 +-- truncate_limit: 100 +REVOKE USAGE ON TYPE type_op3 FROM PUBLIC +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE type_op3 FROM public" +== 051 +-- truncate_limit: 100 +-- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC +SET ROLE regress_rol_op3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_op3" +== 052 +-- truncate_limit: 100 +CREATE OPERATOR #*# ( + leftarg = type_op3, + rightarg = int8, + procedure = fn_op3 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #*# (leftarg = type_op3, rightarg = int8, procedure = fn_op3)" +== 053 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 054 +-- truncate_limit: 100 +-- Should fail. CREATE OPERATOR requires USAGE on TYPE (need to check separately for rightarg) +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 055 +-- truncate_limit: 100 +CREATE ROLE regress_rol_op4 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rol_op4" +== 056 +-- truncate_limit: 100 +CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed')" +== 057 +-- truncate_limit: 100 +CREATE FUNCTION fn_op4(int8, type_op4) +RETURNS int8 AS $$ + SELECT NULL::int8; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op4" function="fn_op4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn_op4(int8, type_op4) RETURNS int8 AS $$\n SELECT NULL::int8;\n$$ LANGUAGE sql ..." +== 058 +-- truncate_limit: 100 +REVOKE USAGE ON TYPE type_op4 FROM regress_rol_op4 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE type_op4 FROM regress_rol_op4" +== 059 +-- truncate_limit: 100 +REVOKE USAGE ON TYPE type_op4 FROM PUBLIC +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE type_op4 FROM public" +== 060 +-- truncate_limit: 100 +-- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC +SET ROLE regress_rol_op4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_op4" +== 061 +-- truncate_limit: 100 +CREATE OPERATOR #*# ( + leftarg = int8, + rightarg = type_op4, + procedure = fn_op4 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #*# (leftarg = int8, rightarg = type_op4, procedure = fn_op4)" +== 062 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 063 +-- truncate_limit: 100 +-- Should fail. CREATE OPERATOR requires EXECUTE on function +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 064 +-- truncate_limit: 100 +CREATE ROLE regress_rol_op5 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rol_op5" +== 065 +-- truncate_limit: 100 +CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed')" +== 066 +-- truncate_limit: 100 +CREATE FUNCTION fn_op5(int8, int8) +RETURNS int8 AS $$ + SELECT NULL::int8; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op5" function="fn_op5" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn_op5(int8, int8) RETURNS int8 AS $$\n SELECT NULL::int8;\n$$ LANGUAGE sql IMMU..." +== 067 +-- truncate_limit: 100 +REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5 +-- +FUNCTION: name="fn_op5" function="fn_op5" schema="" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE execute ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5" +== 068 +-- truncate_limit: 100 +REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC +-- +FUNCTION: name="fn_op5" function="fn_op5" schema="" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE execute ON FUNCTION fn_op5(int8, int8) FROM public" +== 069 +-- truncate_limit: 100 +-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC +SET ROLE regress_rol_op5 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_op5" +== 070 +-- truncate_limit: 100 +CREATE OPERATOR #*# ( + leftarg = int8, + rightarg = int8, + procedure = fn_op5 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #*# (leftarg = int8, rightarg = int8, procedure = fn_op5)" +== 071 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 072 +-- truncate_limit: 100 +-- Should fail. CREATE OPERATOR requires USAGE on return TYPE +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 073 +-- truncate_limit: 100 +CREATE ROLE regress_rol_op6 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rol_op6" +== 074 +-- truncate_limit: 100 +CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed')" +== 075 +-- truncate_limit: 100 +CREATE FUNCTION fn_op6(int8, int8) +RETURNS type_op6 AS $$ + SELECT NULL::type_op6; +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="fn_op6" function="fn_op6" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn_op6(int8, int8) RETURNS type_op6 AS $$\n SELECT NULL::type_op6;\n$$ LANGUAGE ..." +== 076 +-- truncate_limit: 100 +REVOKE USAGE ON TYPE type_op6 FROM regress_rol_op6 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE type_op6 FROM regress_rol_op6" +== 077 +-- truncate_limit: 100 +REVOKE USAGE ON TYPE type_op6 FROM PUBLIC +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE type_op6 FROM public" +== 078 +-- truncate_limit: 100 +-- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC +SET ROLE regress_rol_op6 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_op6" +== 079 +-- truncate_limit: 100 +CREATE OPERATOR #*# ( + leftarg = int8, + rightarg = int8, + procedure = fn_op6 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR #*# (leftarg = int8, rightarg = int8, procedure = fn_op6)" +== 080 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 081 +-- truncate_limit: 100 +-- Should fail. An operator cannot be its own negator. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 082 +-- truncate_limit: 100 +CREATE OPERATOR === ( + leftarg = integer, + rightarg = integer, + procedure = int4eq, + negator = === +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (leftarg = int, rightarg = int, procedure = int4eq, negator = ===)" +== 083 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 084 +-- truncate_limit: 100 +-- Should fail. An operator cannot be its own negator. Here we check that +-- this error is detected when replacing a shell operator. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 085 +-- truncate_limit: 100 +-- create a shell operator for ===!!! by referencing it as a commutator +CREATE OPERATOR === ( + leftarg = integer, + rightarg = integer, + procedure = int4eq, + commutator = ===!!! +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (leftarg = int, rightarg = int, procedure = int4eq, commutator = ===!!!)" +== 086 +-- truncate_limit: 100 +CREATE OPERATOR ===!!! ( + leftarg = integer, + rightarg = integer, + procedure = int4ne, + negator = ===!!! +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR ===!!! (leftarg = int, rightarg = int, procedure = int4ne, negator = ===!!!)" +== 087 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 088 +-- truncate_limit: 100 +-- test that we can't use part of an existing commutator or negator pair +-- as a commutator or negator +CREATE OPERATOR === ( + leftarg = integer, + rightarg = integer, + procedure = int4eq, + commutator = = +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (leftarg = int, rightarg = int, procedure = int4eq, commutator = =)" +== 089 +-- truncate_limit: 100 +CREATE OPERATOR === ( + leftarg = integer, + rightarg = integer, + procedure = int4eq, + negator = <> +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (leftarg = int, rightarg = int, procedure = int4eq, negator = <>)" +== 090 +-- truncate_limit: 100 +-- invalid: non-lowercase quoted identifiers +CREATE OPERATOR === +( + "Leftarg" = box, + "Rightarg" = box, + "Procedure" = area_equal_function, + "Commutator" = ===, + "Negator" = !==, + "Restrict" = area_restriction_function, + "Join" = area_join_function, + "Hashes", + "Merges" +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (\"Leftarg\" = box, \"Rightarg\" = box, \"Procedure\" = area_equal_function, \"Commu..." diff --git a/parser/testdata/summary_truncate/postgres_regress/create_procedure.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_procedure.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_procedure.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_procedure.test b/parser/testdata/summary_truncate/postgres_regress/create_procedure.test new file mode 100644 index 0000000..b3f8983 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_procedure.test @@ -0,0 +1,870 @@ +== 001 +-- truncate_limit: 100 +CALL nonexistent() +-- +FUNCTION: name="nonexistent" function="nonexistent" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL nonexistent()" +== 002 +-- truncate_limit: 100 +-- error +CALL random() +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL random()" +== 003 +-- truncate_limit: 100 +-- error + +CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQL AS $$ SELECT a $$ +-- +FUNCTION: name="cp_testfunc1" function="cp_testfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE sql AS $$ SELECT a $$" +== 004 +-- truncate_limit: 100 +CREATE TABLE cp_test (a int, b text) +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cp_test (a int, b text)" +== 005 +-- truncate_limit: 100 +CREATE PROCEDURE ptest1(x text) +LANGUAGE SQL +AS $$ +INSERT INTO cp_test VALUES (1, x); +$$ +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest1(x text) LANGUAGE sql AS $$\nINSERT INTO cp_test VALUES (1, x);\n$$" +== 006 +-- truncate_limit: 100 +SELECT pg_get_functiondef('ptest1'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('ptest1'::regproc)" +== 007 +-- truncate_limit: 100 +-- show only normal functions + +-- show only procedures + +SELECT ptest1('x') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ptest1('x')" +== 008 +-- truncate_limit: 100 +-- error +CALL ptest1('a') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest1('a')" +== 009 +-- truncate_limit: 100 +-- ok +CALL ptest1('xy' || 'zzy') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest1('xy' || 'zzy')" +== 010 +-- truncate_limit: 100 +-- ok, constant-folded arg +CALL ptest1(substring(random()::numeric(20,15)::text, 1, 1)) +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +FUNCTION: name="substring" function="substring" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest1(\"substring\"(random()::numeric(20, 15)::text, 1, 1))" +== 011 +-- truncate_limit: 100 +-- ok, volatile arg + +SELECT * FROM cp_test ORDER BY b COLLATE "C" +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cp_test ORDER BY b COLLATE \"C\"" +== 012 +-- truncate_limit: 100 +-- SQL-standard body +CREATE PROCEDURE ptest1s(x text) +LANGUAGE SQL +BEGIN ATOMIC + INSERT INTO cp_test VALUES (1, x) +-- +ERROR: syntax error at end of input +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 013 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 014 +-- truncate_limit: 100 +SELECT pg_get_functiondef('ptest1s'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('ptest1s'::regproc)" +== 015 +-- truncate_limit: 100 +CALL ptest1s('b') +-- +FUNCTION: name="ptest1s" function="ptest1s" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest1s('b')" +== 016 +-- truncate_limit: 100 +SELECT * FROM cp_test ORDER BY b COLLATE "C" +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cp_test ORDER BY b COLLATE \"C\"" +== 017 +-- truncate_limit: 100 +-- utility functions currently not supported here +CREATE PROCEDURE ptestx() +LANGUAGE SQL +BEGIN ATOMIC + CREATE TABLE x (a int) +-- +ERROR: syntax error at end of input +CURSORPOS: 127 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 018 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 019 +-- truncate_limit: 100 +CREATE PROCEDURE ptest2() +LANGUAGE SQL +AS $$ +SELECT 5; +$$ +-- +FUNCTION: name="ptest2" function="ptest2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest2() LANGUAGE sql AS $$\nSELECT 5;\n$$" +== 020 +-- truncate_limit: 100 +CALL ptest2() +-- +FUNCTION: name="ptest2" function="ptest2" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest2()" +== 021 +-- truncate_limit: 100 +-- nested CALL +TRUNCATE cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE cp_test" +== 022 +-- truncate_limit: 100 +CREATE PROCEDURE ptest3(y text) +LANGUAGE SQL +AS $$ +CALL ptest1(y); +CALL ptest1($1); +$$ +-- +FUNCTION: name="ptest3" function="ptest3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest3(y text) LANGUAGE sql AS $$\nCALL ptest1(y);\nCALL ptest1($1);\n$$" +== 023 +-- truncate_limit: 100 +CALL ptest3('b') +-- +FUNCTION: name="ptest3" function="ptest3" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest3('b')" +== 024 +-- truncate_limit: 100 +SELECT * FROM cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cp_test" +== 025 +-- truncate_limit: 100 +-- output arguments + +CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int) +LANGUAGE SQL +AS $$ +SELECT 1, 2; +$$ +-- +FUNCTION: name="ptest4a" function="ptest4a" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int) LANGUAGE sql AS $$\nSELECT 1, 2;\n$$" +== 026 +-- truncate_limit: 100 +CALL ptest4a(NULL, NULL) +-- +FUNCTION: name="ptest4a" function="ptest4a" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest4a(NULL, NULL)" +== 027 +-- truncate_limit: 100 +CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int) +LANGUAGE SQL +AS $$ +CALL ptest4a(a, b); -- error, not supported +$$ +-- +FUNCTION: name="ptest4b" function="ptest4b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int) LANGUAGE sql AS $$\nCALL ptest4a(a, b); -- err..." +== 028 +-- truncate_limit: 100 +-- we used to get confused by a single output argument that is composite +CREATE PROCEDURE ptest4c(INOUT comp int8_tbl) +LANGUAGE SQL +AS $$ +SELECT ROW(1, 2); +$$ +-- +FUNCTION: name="ptest4c" function="ptest4c" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest4c(INOUT comp int8_tbl) LANGUAGE sql AS $$\nSELECT ROW(1, 2);\n$$" +== 029 +-- truncate_limit: 100 +CALL ptest4c(NULL) +-- +FUNCTION: name="ptest4c" function="ptest4c" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest4c(NULL)" +== 030 +-- truncate_limit: 100 +DROP PROCEDURE ptest4a, ptest4c +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest4a, ptest4c" +== 031 +-- truncate_limit: 100 +-- named and default parameters + +CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int default 100) +LANGUAGE SQL +AS $$ +INSERT INTO cp_test VALUES(a, b); +INSERT INTO cp_test VALUES(c, b); +$$ +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int = 100) LANGUAGE sql AS $$\nINSERT INTO cp_..." +== 032 +-- truncate_limit: 100 +TRUNCATE cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE cp_test" +== 033 +-- truncate_limit: 100 +CALL ptest5(10, 'Hello', 20) +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest5(10, 'Hello', 20)" +== 034 +-- truncate_limit: 100 +CALL ptest5(10, 'Hello') +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest5(10, 'Hello')" +== 035 +-- truncate_limit: 100 +CALL ptest5(10, b => 'Hello') +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest5(10, b := 'Hello')" +== 036 +-- truncate_limit: 100 +CALL ptest5(b => 'Hello', a => 10) +-- +FUNCTION: name="ptest5" function="ptest5" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest5(b := 'Hello', a := 10)" +== 037 +-- truncate_limit: 100 +SELECT * FROM cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cp_test" +== 038 +-- truncate_limit: 100 +-- polymorphic types + +CREATE PROCEDURE ptest6(a int, b anyelement) +LANGUAGE SQL +AS $$ +SELECT NULL::int; +$$ +-- +FUNCTION: name="ptest6" function="ptest6" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest6(a int, b anyelement) LANGUAGE sql AS $$\nSELECT NULL::int;\n$$" +== 039 +-- truncate_limit: 100 +CALL ptest6(1, 2) +-- +FUNCTION: name="ptest6" function="ptest6" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest6(1, 2)" +== 040 +-- truncate_limit: 100 +CREATE PROCEDURE ptest6a(inout a anyelement, out b anyelement) +LANGUAGE SQL +AS $$ +SELECT $1, $1; +$$ +-- +FUNCTION: name="ptest6a" function="ptest6a" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest6a(INOUT a anyelement, OUT b anyelement) LANGUAGE sql AS $$\nSELECT $1, $1;\n$$" +== 041 +-- truncate_limit: 100 +CALL ptest6a(1, null) +-- +FUNCTION: name="ptest6a" function="ptest6a" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest6a(1, NULL)" +== 042 +-- truncate_limit: 100 +CALL ptest6a(1.1, null) +-- +FUNCTION: name="ptest6a" function="ptest6a" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest6a(1.1, NULL)" +== 043 +-- truncate_limit: 100 +CREATE PROCEDURE ptest6b(a anyelement, out b anyelement, out c anyarray) +LANGUAGE SQL +AS $$ +SELECT $1, array[$1]; +$$ +-- +FUNCTION: name="ptest6b" function="ptest6b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest6b(a anyelement, OUT b anyelement, OUT c anyarray) LANGUAGE sql AS $$\nSELEC..." +== 044 +-- truncate_limit: 100 +CALL ptest6b(1, null, null) +-- +FUNCTION: name="ptest6b" function="ptest6b" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest6b(1, NULL, NULL)" +== 045 +-- truncate_limit: 100 +CALL ptest6b(1.1, null, null) +-- +FUNCTION: name="ptest6b" function="ptest6b" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest6b(1.1, NULL, NULL)" +== 046 +-- truncate_limit: 100 +CREATE PROCEDURE ptest6c(inout a anyelement, inout b anyelement) +LANGUAGE SQL +AS $$ +SELECT $1, 1; +$$ +-- +FUNCTION: name="ptest6c" function="ptest6c" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest6c(INOUT a anyelement, INOUT b anyelement) LANGUAGE sql AS $$\nSELECT $1, 1;\n$$" +== 047 +-- truncate_limit: 100 +CALL ptest6c(1, null) +-- +FUNCTION: name="ptest6c" function="ptest6c" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest6c(1, NULL)" +== 048 +-- truncate_limit: 100 +CALL ptest6c(1.1, null) +-- +FUNCTION: name="ptest6c" function="ptest6c" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest6c(1.1, NULL)" +== 049 +-- truncate_limit: 100 +-- fails before v13 + + +-- collation assignment + +CREATE PROCEDURE ptest7(a text, b text) +LANGUAGE SQL +AS $$ +SELECT a = b; +$$ +-- +FUNCTION: name="ptest7" function="ptest7" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest7(a text, b text) LANGUAGE sql AS $$\nSELECT a = b;\n$$" +== 050 +-- truncate_limit: 100 +CALL ptest7(least('a', 'b'), 'a') +-- +FUNCTION: name="ptest7" function="ptest7" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest7(LEAST('a', 'b'), 'a')" +== 051 +-- truncate_limit: 100 +-- empty body +CREATE PROCEDURE ptest8(x text) +BEGIN ATOMIC +END +-- +FUNCTION: name="ptest8" function="ptest8" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest8(x text) BEGIN ATOMIC END" +== 052 +-- truncate_limit: 100 +SELECT pg_get_functiondef('ptest8'::regproc) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('ptest8'::regproc)" +== 053 +-- truncate_limit: 100 +CALL ptest8('') +-- +FUNCTION: name="ptest8" function="ptest8" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest8('')" +== 054 +-- truncate_limit: 100 +-- OUT parameters + +CREATE PROCEDURE ptest9(OUT a int) +LANGUAGE SQL +AS $$ +INSERT INTO cp_test VALUES (1, 'a'); +SELECT 1; +$$ +-- +FUNCTION: name="ptest9" function="ptest9" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest9(OUT a int) LANGUAGE sql AS $$\nINSERT INTO cp_test VALUES (1, 'a');\nSELECT..." +== 055 +-- truncate_limit: 100 +-- standard way to do a call: +CALL ptest9(NULL) +-- +FUNCTION: name="ptest9" function="ptest9" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest9(NULL)" +== 056 +-- truncate_limit: 100 +-- you can write an expression, but it's not evaluated +CALL ptest9(1/0) +-- +FUNCTION: name="ptest9" function="ptest9" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest9(1 / 0)" +== 057 +-- truncate_limit: 100 +-- no error +-- ... and it had better match the type of the parameter +CALL ptest9(1./0.) +-- +FUNCTION: name="ptest9" function="ptest9" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest9(1. / 0.)" +== 058 +-- truncate_limit: 100 +-- error + +-- check named-parameter matching +CREATE PROCEDURE ptest10(OUT a int, IN b int, IN c int) +LANGUAGE SQL AS $$ SELECT b - c $$ +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest10(OUT a int, IN b int, IN c int) LANGUAGE sql AS $$ SELECT b - c $$" +== 059 +-- truncate_limit: 100 +CALL ptest10(null, 7, 4) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest10(NULL, 7, 4)" +== 060 +-- truncate_limit: 100 +CALL ptest10(a => null, b => 8, c => 2) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest10(a := NULL, b := 8, c := 2)" +== 061 +-- truncate_limit: 100 +CALL ptest10(null, 7, c => 2) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest10(NULL, 7, c := 2)" +== 062 +-- truncate_limit: 100 +CALL ptest10(null, c => 4, b => 11) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest10(NULL, c := 4, b := 11)" +== 063 +-- truncate_limit: 100 +CALL ptest10(b => 8, c => 2, a => 0) +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest10(b := 8, c := 2, a := 0)" +== 064 +-- truncate_limit: 100 +CREATE PROCEDURE ptest11(a OUT int, VARIADIC b int[]) LANGUAGE SQL + AS $$ SELECT b[1] + b[2] $$ +-- +FUNCTION: name="ptest11" function="ptest11" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest11(OUT a int, VARIADIC b int[]) LANGUAGE sql AS $$ SELECT b[1] + b[2] $$" +== 065 +-- truncate_limit: 100 +CALL ptest11(null, 11, 12, 13) +-- +FUNCTION: name="ptest11" function="ptest11" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest11(NULL, 11, 12, 13)" +== 066 +-- truncate_limit: 100 +-- check resolution of ambiguous DROP commands + +CREATE PROCEDURE ptest10(IN a int, IN b int, IN c int) +LANGUAGE SQL AS $$ SELECT a + b - c $$ +-- +FUNCTION: name="ptest10" function="ptest10" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptest10(IN a int, IN b int, IN c int) LANGUAGE sql AS $$ SELECT a + b - c $$" +== 067 +-- truncate_limit: 100 +drop procedure ptest10 +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest10" +== 068 +-- truncate_limit: 100 +-- fail +drop procedure ptest10(int, int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest10(int, int, int)" +== 069 +-- truncate_limit: 100 +-- fail +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 070 +-- truncate_limit: 100 +drop procedure ptest10(out int, int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest10(OUT int, int, int)" +== 071 +-- truncate_limit: 100 +drop procedure ptest10(int, int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest10(int, int, int)" +== 072 +-- truncate_limit: 100 +-- now this would work +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 073 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 074 +-- truncate_limit: 100 +drop procedure ptest10(in int, int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest10(IN int, int, int)" +== 075 +-- truncate_limit: 100 +drop procedure ptest10(int, int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest10(int, int, int)" +== 076 +-- truncate_limit: 100 +-- now this would work +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 077 +-- truncate_limit: 100 +-- various error cases + +CALL version() +-- +FUNCTION: name="version" function="version" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL version()" +== 078 +-- truncate_limit: 100 +-- error: not a procedure +CALL sum(1) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL sum(1)" +== 079 +-- truncate_limit: 100 +-- error: not a procedure + +CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$ +-- +FUNCTION: name="ptestx" function="ptestx" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptestx() LANGUAGE sql WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$" +== 080 +-- truncate_limit: 100 +CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$ +-- +FUNCTION: name="ptestx" function="ptestx" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptestx() LANGUAGE sql RETURNS NULL ON NULL INPUT AS $$ INSERT INTO cp_test VALUE..." +== 081 +-- truncate_limit: 100 +CREATE PROCEDURE ptestx(a VARIADIC int[], b OUT int) LANGUAGE SQL + AS $$ SELECT a[1] $$ +-- +FUNCTION: name="ptestx" function="ptestx" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptestx(VARIADIC a int[], OUT b int) LANGUAGE sql AS $$ SELECT a[1] $$" +== 082 +-- truncate_limit: 100 +CREATE PROCEDURE ptestx(a int DEFAULT 42, b OUT int) LANGUAGE SQL + AS $$ SELECT a $$ +-- +FUNCTION: name="ptestx" function="ptestx" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE ptestx(a int = 42, OUT b int) LANGUAGE sql AS $$ SELECT a $$" +== 083 +-- truncate_limit: 100 +ALTER PROCEDURE ptest1(text) STRICT +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER PROCEDURE ptest1(text) RETURNS NULL ON NULL INPUT" +== 084 +-- truncate_limit: 100 +ALTER FUNCTION ptest1(text) VOLATILE +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION ptest1(text) VOLATILE" +== 085 +-- truncate_limit: 100 +-- error: not a function +ALTER PROCEDURE cp_testfunc1(int) VOLATILE +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER PROCEDURE cp_testfunc1(int) VOLATILE" +== 086 +-- truncate_limit: 100 +-- error: not a procedure +ALTER PROCEDURE nonexistent() VOLATILE +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER PROCEDURE nonexistent() VOLATILE" +== 087 +-- truncate_limit: 100 +DROP FUNCTION ptest1(text) +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION ptest1(text)" +== 088 +-- truncate_limit: 100 +-- error: not a function +DROP PROCEDURE cp_testfunc1(int) +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE cp_testfunc1(int)" +== 089 +-- truncate_limit: 100 +-- error: not a procedure +DROP PROCEDURE nonexistent() +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE nonexistent()" +== 090 +-- truncate_limit: 100 +-- privileges + +CREATE USER regress_cp_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_cp_user1" +== 091 +-- truncate_limit: 100 +GRANT INSERT ON cp_test TO regress_cp_user1 +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON cp_test TO regress_cp_user1" +== 092 +-- truncate_limit: 100 +REVOKE EXECUTE ON PROCEDURE ptest1(text) FROM PUBLIC +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE execute ON PROCEDURE ptest1(text) FROM public" +== 093 +-- truncate_limit: 100 +SET ROLE regress_cp_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_cp_user1" +== 094 +-- truncate_limit: 100 +CALL ptest1('a') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest1('a')" +== 095 +-- truncate_limit: 100 +-- error +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 096 +-- truncate_limit: 100 +GRANT EXECUTE ON PROCEDURE ptest1(text) TO regress_cp_user1 +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT execute ON PROCEDURE ptest1(text) TO regress_cp_user1" +== 097 +-- truncate_limit: 100 +SET ROLE regress_cp_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_cp_user1" +== 098 +-- truncate_limit: 100 +CALL ptest1('a') +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL ptest1('a')" +== 099 +-- truncate_limit: 100 +-- ok +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 100 +-- truncate_limit: 100 +-- ROUTINE syntax + +ALTER ROUTINE cp_testfunc1(int) RENAME TO cp_testfunc1a +-- +FUNCTION: name="cp_testfunc1" function="cp_testfunc1" schema="" ctx=DDL +FUNCTION: name="cp_testfunc1a" function="cp_testfunc1a" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER ROUTINE cp_testfunc1(int) RENAME TO cp_testfunc1a" +== 101 +-- truncate_limit: 100 +ALTER ROUTINE cp_testfunc1a RENAME TO cp_testfunc1 +-- +FUNCTION: name="cp_testfunc1a" function="cp_testfunc1a" schema="" ctx=DDL +FUNCTION: name="cp_testfunc1" function="cp_testfunc1" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER ROUTINE cp_testfunc1a RENAME TO cp_testfunc1" +== 102 +-- truncate_limit: 100 +ALTER ROUTINE ptest1(text) RENAME TO ptest1a +-- +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +FUNCTION: name="ptest1a" function="ptest1a" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER ROUTINE ptest1(text) RENAME TO ptest1a" +== 103 +-- truncate_limit: 100 +ALTER ROUTINE ptest1a RENAME TO ptest1 +-- +FUNCTION: name="ptest1a" function="ptest1a" schema="" ctx=DDL +FUNCTION: name="ptest1" function="ptest1" schema="" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER ROUTINE ptest1a RENAME TO ptest1" +== 104 +-- truncate_limit: 100 +DROP ROUTINE cp_testfunc1(int) +-- +STMT: DropStmt +TRUNCATED: "DROP ROUTINE cp_testfunc1(int)" +== 105 +-- truncate_limit: 100 +-- cleanup + +DROP PROCEDURE ptest1 +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest1" +== 106 +-- truncate_limit: 100 +DROP PROCEDURE ptest1s +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest1s" +== 107 +-- truncate_limit: 100 +DROP PROCEDURE ptest2 +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE ptest2" +== 108 +-- truncate_limit: 100 +DROP TABLE cp_test +-- +TABLE: name="cp_test" schema="" table="cp_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cp_test" +== 109 +-- truncate_limit: 100 +DROP USER regress_cp_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_cp_user1" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_role.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_role.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_role.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_role.test b/parser/testdata/summary_truncate/postgres_regress/create_role.test new file mode 100644 index 0000000..3849444 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_role.test @@ -0,0 +1,883 @@ +== 001 +-- truncate_limit: 100 +-- ok, superuser can create users with any set of privileges +CREATE ROLE regress_role_super SUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_role_super WITH SUPERUSER" +== 002 +-- truncate_limit: 100 +CREATE ROLE regress_role_admin CREATEDB CREATEROLE REPLICATION BYPASSRLS +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_role_admin WITH CREATEDB CREATEROLE REPLICATION BYPASSRLS" +== 003 +-- truncate_limit: 100 +GRANT CREATE ON DATABASE regression TO regress_role_admin WITH GRANT OPTION +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON DATABASE regression TO regress_role_admin WITH GRANT OPTION" +== 004 +-- truncate_limit: 100 +CREATE ROLE regress_role_limited_admin CREATEROLE +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_role_limited_admin WITH CREATEROLE" +== 005 +-- truncate_limit: 100 +CREATE ROLE regress_role_normal +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_role_normal" +== 006 +-- truncate_limit: 100 +-- fail, CREATEROLE user can't give away role attributes without having them +SET SESSION AUTHORIZATION regress_role_limited_admin +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_role_limited_admin" +== 007 +-- truncate_limit: 100 +CREATE ROLE regress_nosuch_superuser SUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_superuser WITH SUPERUSER" +== 008 +-- truncate_limit: 100 +CREATE ROLE regress_nosuch_replication_bypassrls REPLICATION BYPASSRLS +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_replication_bypassrls WITH REPLICATION BYPASSRLS" +== 009 +-- truncate_limit: 100 +CREATE ROLE regress_nosuch_replication REPLICATION +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_replication WITH REPLICATION" +== 010 +-- truncate_limit: 100 +CREATE ROLE regress_nosuch_bypassrls BYPASSRLS +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_bypassrls WITH BYPASSRLS" +== 011 +-- truncate_limit: 100 +CREATE ROLE regress_nosuch_createdb CREATEDB +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_createdb WITH CREATEDB" +== 012 +-- truncate_limit: 100 +-- ok, can create a role without any special attributes +CREATE ROLE regress_role_limited +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_role_limited" +== 013 +-- truncate_limit: 100 +-- fail, can't give it in any of the restricted attributes +ALTER ROLE regress_role_limited SUPERUSER +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_role_limited WITH SUPERUSER" +== 014 +-- truncate_limit: 100 +ALTER ROLE regress_role_limited REPLICATION +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_role_limited WITH REPLICATION" +== 015 +-- truncate_limit: 100 +ALTER ROLE regress_role_limited CREATEDB +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_role_limited WITH CREATEDB" +== 016 +-- truncate_limit: 100 +ALTER ROLE regress_role_limited BYPASSRLS +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_role_limited WITH BYPASSRLS" +== 017 +-- truncate_limit: 100 +DROP ROLE regress_role_limited +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_role_limited" +== 018 +-- truncate_limit: 100 +-- ok, can give away these role attributes if you have them +SET SESSION AUTHORIZATION regress_role_admin +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_role_admin" +== 019 +-- truncate_limit: 100 +CREATE ROLE regress_replication_bypassrls REPLICATION BYPASSRLS +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_replication_bypassrls WITH REPLICATION BYPASSRLS" +== 020 +-- truncate_limit: 100 +CREATE ROLE regress_replication REPLICATION +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_replication WITH REPLICATION" +== 021 +-- truncate_limit: 100 +CREATE ROLE regress_bypassrls BYPASSRLS +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_bypassrls WITH BYPASSRLS" +== 022 +-- truncate_limit: 100 +CREATE ROLE regress_createdb CREATEDB +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_createdb WITH CREATEDB" +== 023 +-- truncate_limit: 100 +-- ok, can toggle these role attributes off and on if you have them +ALTER ROLE regress_replication NOREPLICATION +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_replication WITH NOREPLICATION" +== 024 +-- truncate_limit: 100 +ALTER ROLE regress_replication REPLICATION +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_replication WITH REPLICATION" +== 025 +-- truncate_limit: 100 +ALTER ROLE regress_bypassrls NOBYPASSRLS +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_bypassrls WITH NOBYPASSRLS" +== 026 +-- truncate_limit: 100 +ALTER ROLE regress_bypassrls BYPASSRLS +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_bypassrls WITH BYPASSRLS" +== 027 +-- truncate_limit: 100 +ALTER ROLE regress_createdb NOCREATEDB +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_createdb WITH NOCREATEDB" +== 028 +-- truncate_limit: 100 +ALTER ROLE regress_createdb CREATEDB +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_createdb WITH CREATEDB" +== 029 +-- truncate_limit: 100 +-- fail, can't toggle SUPERUSER +ALTER ROLE regress_createdb SUPERUSER +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_createdb WITH SUPERUSER" +== 030 +-- truncate_limit: 100 +ALTER ROLE regress_createdb NOSUPERUSER +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_createdb WITH NOSUPERUSER" +== 031 +-- truncate_limit: 100 +-- ok, having CREATEROLE is enough to create users with these privileges +CREATE ROLE regress_createrole CREATEROLE NOINHERIT +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_createrole WITH CREATEROLE NOINHERIT" +== 032 +-- truncate_limit: 100 +GRANT CREATE ON DATABASE regression TO regress_createrole WITH GRANT OPTION +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON DATABASE regression TO regress_createrole WITH GRANT OPTION" +== 033 +-- truncate_limit: 100 +CREATE ROLE regress_login LOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_login WITH LOGIN" +== 034 +-- truncate_limit: 100 +CREATE ROLE regress_inherit INHERIT +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_inherit WITH INHERIT" +== 035 +-- truncate_limit: 100 +CREATE ROLE regress_connection_limit CONNECTION LIMIT 5 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_connection_limit WITH CONNECTION LIMIT 5" +== 036 +-- truncate_limit: 100 +CREATE ROLE regress_encrypted_password ENCRYPTED PASSWORD 'foo' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_encrypted_password WITH PASSWORD 'foo'" +== 037 +-- truncate_limit: 100 +CREATE ROLE regress_password_null PASSWORD NULL +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_password_null WITH PASSWORD NULL" +== 038 +-- truncate_limit: 100 +-- ok, backwards compatible noise words should be ignored +CREATE ROLE regress_noiseword SYSID 12345 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_noiseword WITH SYSID 12345" +== 039 +-- truncate_limit: 100 +-- fail, cannot grant membership in superuser role +CREATE ROLE regress_nosuch_super IN ROLE regress_role_super +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_super WITH IN ROLE regress_role_super" +== 040 +-- truncate_limit: 100 +-- fail, database owner cannot have members +CREATE ROLE regress_nosuch_dbowner IN ROLE pg_database_owner +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_dbowner WITH IN ROLE pg_database_owner" +== 041 +-- truncate_limit: 100 +-- ok, can grant other users into a role +CREATE ROLE regress_inroles ROLE + regress_role_super, regress_createdb, regress_createrole, regress_login, + regress_inherit, regress_connection_limit, regress_encrypted_password, regress_password_null +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_inroles WITH ROLE regress_role_super, regress_createdb, regress_createrole, r..." +== 042 +-- truncate_limit: 100 +-- fail, cannot grant a role into itself +CREATE ROLE regress_nosuch_recursive ROLE regress_nosuch_recursive +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_recursive WITH ROLE regress_nosuch_recursive" +== 043 +-- truncate_limit: 100 +-- ok, can grant other users into a role with admin option +CREATE ROLE regress_adminroles ADMIN + regress_role_super, regress_createdb, regress_createrole, regress_login, + regress_inherit, regress_connection_limit, regress_encrypted_password, regress_password_null +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_adminroles WITH ADMIN regress_role_super, regress_createdb, regress_createrol..." +== 044 +-- truncate_limit: 100 +-- fail, cannot grant a role into itself with admin option +CREATE ROLE regress_nosuch_admin_recursive ADMIN regress_nosuch_admin_recursive +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_nosuch_admin_recursive WITH ADMIN regress_nosuch_admin_recursive" +== 045 +-- truncate_limit: 100 +-- fail, regress_createrole does not have CREATEDB privilege +SET SESSION AUTHORIZATION regress_createrole +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_createrole" +== 046 +-- truncate_limit: 100 +CREATE DATABASE regress_nosuch_db +-- +STMT: CreatedbStmt +TRUNCATED: "CREATE DATABASE regress_nosuch_db" +== 047 +-- truncate_limit: 100 +-- ok, regress_createrole can create new roles +CREATE ROLE regress_plainrole +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_plainrole" +== 048 +-- truncate_limit: 100 +-- ok, roles with CREATEROLE can create new roles with it +CREATE ROLE regress_rolecreator CREATEROLE +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rolecreator WITH CREATEROLE" +== 049 +-- truncate_limit: 100 +-- ok, roles with CREATEROLE can create new roles with different role +-- attributes, including CREATEROLE +CREATE ROLE regress_hasprivs CREATEROLE LOGIN INHERIT CONNECTION LIMIT 5 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_hasprivs WITH CREATEROLE LOGIN INHERIT CONNECTION LIMIT 5" +== 050 +-- truncate_limit: 100 +-- ok, we should be able to modify a role we created +COMMENT ON ROLE regress_hasprivs IS 'some comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON ROLE regress_hasprivs IS 'some comment'" +== 051 +-- truncate_limit: 100 +ALTER ROLE regress_hasprivs RENAME TO regress_tenant +-- +STMT: RenameStmt +TRUNCATED: "ALTER ROLE regress_hasprivs RENAME TO regress_tenant" +== 052 +-- truncate_limit: 100 +ALTER ROLE regress_tenant NOINHERIT NOLOGIN CONNECTION LIMIT 7 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_tenant WITH NOINHERIT NOLOGIN CONNECTION LIMIT 7" +== 053 +-- truncate_limit: 100 +-- fail, we should be unable to modify a role we did not create +COMMENT ON ROLE regress_role_normal IS 'some comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON ROLE regress_role_normal IS 'some comment'" +== 054 +-- truncate_limit: 100 +ALTER ROLE regress_role_normal RENAME TO regress_role_abnormal +-- +STMT: RenameStmt +TRUNCATED: "ALTER ROLE regress_role_normal RENAME TO regress_role_abnormal" +== 055 +-- truncate_limit: 100 +ALTER ROLE regress_role_normal NOINHERIT NOLOGIN CONNECTION LIMIT 7 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_role_normal WITH NOINHERIT NOLOGIN CONNECTION LIMIT 7" +== 056 +-- truncate_limit: 100 +-- ok, regress_tenant can create objects within the database +SET SESSION AUTHORIZATION regress_tenant +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_tenant" +== 057 +-- truncate_limit: 100 +CREATE TABLE tenant_table (i integer) +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tenant_table (i int)" +== 058 +-- truncate_limit: 100 +CREATE INDEX tenant_idx ON tenant_table(i) +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tenant_idx ON tenant_table USING btree (i)" +== 059 +-- truncate_limit: 100 +CREATE VIEW tenant_view AS SELECT * FROM pg_catalog.pg_class +-- +TABLE: name="tenant_view" schema="" table="tenant_view" ctx=DDL +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tenant_view AS SELECT * FROM pg_catalog.pg_class" +== 060 +-- truncate_limit: 100 +REVOKE ALL PRIVILEGES ON tenant_table FROM PUBLIC +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON tenant_table FROM public" +== 061 +-- truncate_limit: 100 +-- fail, these objects belonging to regress_tenant +SET SESSION AUTHORIZATION regress_createrole +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_createrole" +== 062 +-- truncate_limit: 100 +DROP INDEX tenant_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX tenant_idx" +== 063 +-- truncate_limit: 100 +ALTER TABLE tenant_table ADD COLUMN t text +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenant_table ADD COLUMN t text" +== 064 +-- truncate_limit: 100 +DROP TABLE tenant_table +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tenant_table" +== 065 +-- truncate_limit: 100 +ALTER VIEW tenant_view OWNER TO regress_role_admin +-- +TABLE: name="tenant_view" schema="" table="tenant_view" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW tenant_view OWNER TO regress_role_admin" +== 066 +-- truncate_limit: 100 +DROP VIEW tenant_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW tenant_view" +== 067 +-- truncate_limit: 100 +-- fail, can't create objects owned as regress_tenant +CREATE SCHEMA regress_tenant_schema AUTHORIZATION regress_tenant +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_tenant_schema AUTHORIZATION regress_tenant" +== 068 +-- truncate_limit: 100 +-- fail, we don't inherit permissions from regress_tenant +REASSIGN OWNED BY regress_tenant TO regress_createrole +-- +STMT: ReassignOwnedStmt +TRUNCATED: "REASSIGN OWNED BY regress_tenant TO regress_createrole" +== 069 +-- truncate_limit: 100 +-- ok, create a role with a value for createrole_self_grant +SET createrole_self_grant = 'set, inherit' +-- +STMT: VariableSetStmt +TRUNCATED: "SET createrole_self_grant TO \"set, inherit\"" +== 070 +-- truncate_limit: 100 +CREATE ROLE regress_tenant2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_tenant2" +== 071 +-- truncate_limit: 100 +GRANT CREATE ON DATABASE regression TO regress_tenant2 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON DATABASE regression TO regress_tenant2" +== 072 +-- truncate_limit: 100 +-- ok, regress_tenant2 can create objects within the database +SET SESSION AUTHORIZATION regress_tenant2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_tenant2" +== 073 +-- truncate_limit: 100 +CREATE TABLE tenant2_table (i integer) +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tenant2_table (i int)" +== 074 +-- truncate_limit: 100 +REVOKE ALL PRIVILEGES ON tenant2_table FROM PUBLIC +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON tenant2_table FROM public" +== 075 +-- truncate_limit: 100 +-- ok, because we have SET and INHERIT on regress_tenant2 +SET SESSION AUTHORIZATION regress_createrole +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_createrole" +== 076 +-- truncate_limit: 100 +CREATE SCHEMA regress_tenant2_schema AUTHORIZATION regress_tenant2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_tenant2_schema AUTHORIZATION regress_tenant2" +== 077 +-- truncate_limit: 100 +ALTER SCHEMA regress_tenant2_schema OWNER TO regress_createrole +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SCHEMA regress_tenant2_schema OWNER TO regress_createrole" +== 078 +-- truncate_limit: 100 +ALTER TABLE tenant2_table OWNER TO regress_createrole +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenant2_table OWNER TO regress_createrole" +== 079 +-- truncate_limit: 100 +ALTER TABLE tenant2_table OWNER TO regress_tenant2 +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenant2_table OWNER TO regress_tenant2" +== 080 +-- truncate_limit: 100 +-- with SET but not INHERIT, we can give away objects but not take them +REVOKE INHERIT OPTION FOR regress_tenant2 FROM regress_createrole +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE INHERIT OPTION FOR regress_tenant2 FROM regress_createrole" +== 081 +-- truncate_limit: 100 +ALTER SCHEMA regress_tenant2_schema OWNER TO regress_tenant2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SCHEMA regress_tenant2_schema OWNER TO regress_tenant2" +== 082 +-- truncate_limit: 100 +ALTER TABLE tenant2_table OWNER TO regress_createrole +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenant2_table OWNER TO regress_createrole" +== 083 +-- truncate_limit: 100 +-- with INHERIT but not SET, we can take objects but not give them away +GRANT regress_tenant2 TO regress_createrole WITH INHERIT TRUE, SET FALSE +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_tenant2 TO regress_createrole WITH INHERIT OPTION, SET FALSE" +== 084 +-- truncate_limit: 100 +ALTER TABLE tenant2_table OWNER TO regress_createrole +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenant2_table OWNER TO regress_createrole" +== 085 +-- truncate_limit: 100 +ALTER TABLE tenant2_table OWNER TO regress_tenant2 +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenant2_table OWNER TO regress_tenant2" +== 086 +-- truncate_limit: 100 +DROP TABLE tenant2_table +-- +TABLE: name="tenant2_table" schema="" table="tenant2_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tenant2_table" +== 087 +-- truncate_limit: 100 +-- fail, CREATEROLE is not enough to create roles in privileged roles +CREATE ROLE regress_read_all_data IN ROLE pg_read_all_data +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_read_all_data WITH IN ROLE pg_read_all_data" +== 088 +-- truncate_limit: 100 +CREATE ROLE regress_write_all_data IN ROLE pg_write_all_data +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_write_all_data WITH IN ROLE pg_write_all_data" +== 089 +-- truncate_limit: 100 +CREATE ROLE regress_monitor IN ROLE pg_monitor +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_monitor WITH IN ROLE pg_monitor" +== 090 +-- truncate_limit: 100 +CREATE ROLE regress_read_all_settings IN ROLE pg_read_all_settings +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_read_all_settings WITH IN ROLE pg_read_all_settings" +== 091 +-- truncate_limit: 100 +CREATE ROLE regress_read_all_stats IN ROLE pg_read_all_stats +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_read_all_stats WITH IN ROLE pg_read_all_stats" +== 092 +-- truncate_limit: 100 +CREATE ROLE regress_stat_scan_tables IN ROLE pg_stat_scan_tables +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_stat_scan_tables WITH IN ROLE pg_stat_scan_tables" +== 093 +-- truncate_limit: 100 +CREATE ROLE regress_read_server_files IN ROLE pg_read_server_files +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_read_server_files WITH IN ROLE pg_read_server_files" +== 094 +-- truncate_limit: 100 +CREATE ROLE regress_write_server_files IN ROLE pg_write_server_files +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_write_server_files WITH IN ROLE pg_write_server_files" +== 095 +-- truncate_limit: 100 +CREATE ROLE regress_execute_server_program IN ROLE pg_execute_server_program +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_execute_server_program WITH IN ROLE pg_execute_server_program" +== 096 +-- truncate_limit: 100 +CREATE ROLE regress_signal_backend IN ROLE pg_signal_backend +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_signal_backend WITH IN ROLE pg_signal_backend" +== 097 +-- truncate_limit: 100 +-- fail, role still owns database objects +DROP ROLE regress_tenant +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_tenant" +== 098 +-- truncate_limit: 100 +-- fail, creation of these roles failed above so they do not now exist +SET SESSION AUTHORIZATION regress_role_admin +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_role_admin" +== 099 +-- truncate_limit: 100 +DROP ROLE regress_nosuch_superuser +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_nosuch_superuser" +== 100 +-- truncate_limit: 100 +DROP ROLE regress_nosuch_replication_bypassrls +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_nosuch_replication_bypassrls" +== 101 +-- truncate_limit: 100 +DROP ROLE regress_nosuch_replication +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_nosuch_replication" +== 102 +-- truncate_limit: 100 +DROP ROLE regress_nosuch_bypassrls +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_nosuch_bypassrls" +== 103 +-- truncate_limit: 100 +DROP ROLE regress_nosuch_super +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_nosuch_super" +== 104 +-- truncate_limit: 100 +DROP ROLE regress_nosuch_dbowner +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_nosuch_dbowner" +== 105 +-- truncate_limit: 100 +DROP ROLE regress_nosuch_recursive +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_nosuch_recursive" +== 106 +-- truncate_limit: 100 +DROP ROLE regress_nosuch_admin_recursive +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_nosuch_admin_recursive" +== 107 +-- truncate_limit: 100 +DROP ROLE regress_plainrole +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_plainrole" +== 108 +-- truncate_limit: 100 +-- must revoke privileges before dropping role +REVOKE CREATE ON DATABASE regression FROM regress_createrole CASCADE +-- +STMT: GrantStmt +TRUNCATED: "REVOKE create ON DATABASE regression FROM regress_createrole CASCADE" +== 109 +-- truncate_limit: 100 +-- ok, should be able to drop non-superuser roles we created +DROP ROLE regress_replication_bypassrls +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_replication_bypassrls" +== 110 +-- truncate_limit: 100 +DROP ROLE regress_replication +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_replication" +== 111 +-- truncate_limit: 100 +DROP ROLE regress_bypassrls +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_bypassrls" +== 112 +-- truncate_limit: 100 +DROP ROLE regress_createdb +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_createdb" +== 113 +-- truncate_limit: 100 +DROP ROLE regress_createrole +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_createrole" +== 114 +-- truncate_limit: 100 +DROP ROLE regress_login +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_login" +== 115 +-- truncate_limit: 100 +DROP ROLE regress_inherit +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_inherit" +== 116 +-- truncate_limit: 100 +DROP ROLE regress_connection_limit +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_connection_limit" +== 117 +-- truncate_limit: 100 +DROP ROLE regress_encrypted_password +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_encrypted_password" +== 118 +-- truncate_limit: 100 +DROP ROLE regress_password_null +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_password_null" +== 119 +-- truncate_limit: 100 +DROP ROLE regress_noiseword +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_noiseword" +== 120 +-- truncate_limit: 100 +DROP ROLE regress_inroles +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_inroles" +== 121 +-- truncate_limit: 100 +DROP ROLE regress_adminroles +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_adminroles" +== 122 +-- truncate_limit: 100 +-- fail, cannot drop ourself, nor superusers or roles we lack ADMIN for +DROP ROLE regress_role_super +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_role_super" +== 123 +-- truncate_limit: 100 +DROP ROLE regress_role_admin +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_role_admin" +== 124 +-- truncate_limit: 100 +DROP ROLE regress_rolecreator +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_rolecreator" +== 125 +-- truncate_limit: 100 +-- ok +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 126 +-- truncate_limit: 100 +REVOKE CREATE ON DATABASE regression FROM regress_role_admin CASCADE +-- +STMT: GrantStmt +TRUNCATED: "REVOKE create ON DATABASE regression FROM regress_role_admin CASCADE" +== 127 +-- truncate_limit: 100 +DROP INDEX tenant_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX tenant_idx" +== 128 +-- truncate_limit: 100 +DROP TABLE tenant_table +-- +TABLE: name="tenant_table" schema="" table="tenant_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tenant_table" +== 129 +-- truncate_limit: 100 +DROP VIEW tenant_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW tenant_view" +== 130 +-- truncate_limit: 100 +DROP SCHEMA regress_tenant2_schema +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA regress_tenant2_schema" +== 131 +-- truncate_limit: 100 +-- check for duplicated drop +DROP ROLE regress_tenant, regress_tenant +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_tenant, regress_tenant" +== 132 +-- truncate_limit: 100 +DROP ROLE regress_tenant2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_tenant2" +== 133 +-- truncate_limit: 100 +DROP ROLE regress_rolecreator +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_rolecreator" +== 134 +-- truncate_limit: 100 +DROP ROLE regress_role_admin +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_role_admin" +== 135 +-- truncate_limit: 100 +DROP ROLE regress_role_limited_admin +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_role_limited_admin" +== 136 +-- truncate_limit: 100 +DROP ROLE regress_role_super +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_role_super" +== 137 +-- truncate_limit: 100 +DROP ROLE regress_role_normal +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_role_normal" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_schema.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_schema.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_schema.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_schema.test b/parser/testdata/summary_truncate/postgres_regress/create_schema.test new file mode 100644 index 0000000..f170c01 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_schema.test @@ -0,0 +1,199 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_SCHEMA +|-- + +-- Schema creation with elements. + +CREATE ROLE regress_create_schema_role SUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_create_schema_role WITH SUPERUSER" +== 002 +-- truncate_limit: 100 +-- Cases where schema creation fails as objects are qualified with a schema +-- that does not match with what's expected. +-- This checks all the object types that include schema qualifications. +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE SEQUENCE schema_not_existing.seq +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION regress_create_schema_role CREATE SEQUENCE schema_not_existing.seq" +== 003 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE TABLE schema_not_existing.tab (id int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION regress_create_schema_role CREATE TABLE schema_not_existing.tab (id int)" +== 004 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE VIEW schema_not_existing.view AS SELECT 1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION regress_create_schema_role CREATE VIEW schema_not_existing.view AS SE..." +== 005 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE INDEX ON schema_not_existing.tab (id) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION regress_create_schema_role CREATE INDEX ON schema_not_existing.tab US..." +== 006 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab + EXECUTE FUNCTION schema_trig.no_func() +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION regress_create_schema_role CREATE TRIGGER schema_trig BEFORE INSERT O..." +== 007 +-- truncate_limit: 100 +-- Again, with a role specification and no schema names. +SET ROLE regress_create_schema_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_create_schema_role" +== 008 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE SEQUENCE schema_not_existing.seq +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION CURRENT_ROLE CREATE SEQUENCE schema_not_existing.seq" +== 009 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE TABLE schema_not_existing.tab (id int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION CURRENT_ROLE CREATE TABLE schema_not_existing.tab (id int)" +== 010 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE VIEW schema_not_existing.view AS SELECT 1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION CURRENT_ROLE CREATE VIEW schema_not_existing.view AS SELECT 1" +== 011 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE INDEX ON schema_not_existing.tab (id) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION CURRENT_ROLE CREATE INDEX ON schema_not_existing.tab USING btree (id)" +== 012 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab + EXECUTE FUNCTION schema_trig.no_func() +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION CURRENT_ROLE CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_e..." +== 013 +-- truncate_limit: 100 +-- Again, with a schema name and a role specification. +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE SEQUENCE schema_not_existing.seq +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE CREATE SEQUENCE schema_not_existing.seq" +== 014 +-- truncate_limit: 100 +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE TABLE schema_not_existing.tab (id int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE CREATE TABLE schema_not_existing.tab (i..." +== 015 +-- truncate_limit: 100 +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE VIEW schema_not_existing.view AS SELECT 1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE CREATE VIEW schema_not_existing.view AS..." +== 016 +-- truncate_limit: 100 +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE INDEX ON schema_not_existing.tab (id) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE CREATE INDEX ON schema_not_existing.tab..." +== 017 +-- truncate_limit: 100 +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE TRIGGER schema_trig BEFORE INSERT ON schema_not_existing.tab + EXECUTE FUNCTION schema_trig.no_func() +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE CREATE TRIGGER schema_trig BEFORE INSER..." +== 018 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 019 +-- truncate_limit: 100 +-- Cases where the schema creation succeeds. +-- The schema created matches the role name. +CREATE SCHEMA AUTHORIZATION regress_create_schema_role + CREATE TABLE regress_create_schema_role.tab (id int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION regress_create_schema_role CREATE TABLE regress_create_schema_role.ta..." +== 020 +-- truncate_limit: 100 +DROP SCHEMA regress_create_schema_role CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA regress_create_schema_role CASCADE" +== 021 +-- truncate_limit: 100 +-- Again, with a different role specification and no schema names. +SET ROLE regress_create_schema_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_create_schema_role" +== 022 +-- truncate_limit: 100 +CREATE SCHEMA AUTHORIZATION CURRENT_ROLE + CREATE TABLE regress_create_schema_role.tab (id int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA AUTHORIZATION CURRENT_ROLE CREATE TABLE regress_create_schema_role.tab (id int)" +== 023 +-- truncate_limit: 100 +DROP SCHEMA regress_create_schema_role CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA regress_create_schema_role CASCADE" +== 024 +-- truncate_limit: 100 +-- Again, with a schema name and a role specification. +CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE + CREATE TABLE regress_schema_1.tab (id int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_schema_1 AUTHORIZATION CURRENT_ROLE CREATE TABLE regress_schema_1.tab (id int)" +== 025 +-- truncate_limit: 100 +DROP SCHEMA regress_schema_1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA regress_schema_1 CASCADE" +== 026 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 027 +-- truncate_limit: 100 +-- Clean up +DROP ROLE regress_create_schema_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_create_schema_role" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_table.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_table.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_table.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_table.test b/parser/testdata/summary_truncate/postgres_regress/create_table.test new file mode 100644 index 0000000..3b97c76 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_table.test @@ -0,0 +1,2628 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_TABLE +|-- + +-- Error cases +CREATE TABLE unknowntab ( + u unknown -- fail +) +-- +TABLE: name="unknowntab" schema="" table="unknowntab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unknowntab (u unknown)" +== 002 +-- truncate_limit: 100 +CREATE TYPE unknown_comptype AS ( + u unknown -- fail +) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE unknown_comptype AS (u unknown)" +== 003 +-- truncate_limit: 100 +-- invalid: non-lowercase quoted reloptions identifiers +CREATE TABLE tas_case WITH ("Fillfactor" = 10) AS SELECT 1 a +-- +TABLE: name="tas_case" schema="" table="tas_case" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE tas_case WITH (\"Fillfactor\"=10) AS SELECT 1 AS a" +== 004 +-- truncate_limit: 100 +CREATE UNLOGGED TABLE unlogged1 (a int primary key) +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE unlogged1 (a int PRIMARY KEY)" +== 005 +-- truncate_limit: 100 +-- OK +CREATE TEMPORARY TABLE unlogged2 (a int primary key) +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE unlogged2 (a int PRIMARY KEY)" +== 006 +-- truncate_limit: 100 +-- OK +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class WHERE relname ~ E'^unlogged\\\\d' ORDER BY relname" +== 007 +-- truncate_limit: 100 +REINDEX INDEX unlogged1_pkey +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX unlogged1_pkey" +== 008 +-- truncate_limit: 100 +REINDEX INDEX unlogged2_pkey +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX unlogged2_pkey" +== 009 +-- truncate_limit: 100 +SELECT relname, relkind, relpersistence FROM pg_class WHERE relname ~ '^unlogged\d' ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class WHERE relname ~ E'^unlogged\\\\d' ORDER BY relname" +== 010 +-- truncate_limit: 100 +DROP TABLE unlogged2 +-- +TABLE: name="unlogged2" schema="" table="unlogged2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unlogged2" +== 011 +-- truncate_limit: 100 +INSERT INTO unlogged1 VALUES (42) +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unlogged1 VALUES (42)" +== 012 +-- truncate_limit: 100 +CREATE UNLOGGED TABLE public.unlogged2 (a int primary key) +-- +TABLE: name="public.unlogged2" schema="public" table="unlogged2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE public.unlogged2 (a int PRIMARY KEY)" +== 013 +-- truncate_limit: 100 +-- also OK +CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key) +-- +TABLE: name="pg_temp.unlogged3" schema="pg_temp" table="unlogged3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int PRIMARY KEY)" +== 014 +-- truncate_limit: 100 +-- not OK +CREATE TABLE pg_temp.implicitly_temp (a int primary key) +-- +TABLE: name="pg_temp.implicitly_temp" schema="pg_temp" table="implicitly_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pg_temp.implicitly_temp (a int PRIMARY KEY)" +== 015 +-- truncate_limit: 100 +-- OK +CREATE TEMP TABLE explicitly_temp (a int primary key) +-- +TABLE: name="explicitly_temp" schema="" table="explicitly_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE explicitly_temp (a int PRIMARY KEY)" +== 016 +-- truncate_limit: 100 +-- also OK +CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key) +-- +TABLE: name="pg_temp.doubly_temp" schema="pg_temp" table="doubly_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pg_temp.doubly_temp (a int PRIMARY KEY)" +== 017 +-- truncate_limit: 100 +-- also OK +CREATE TEMP TABLE public.temp_to_perm (a int primary key) +-- +TABLE: name="public.temp_to_perm" schema="public" table="temp_to_perm" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE public.temp_to_perm (a int PRIMARY KEY)" +== 018 +-- truncate_limit: 100 +-- not OK +DROP TABLE unlogged1, public.unlogged2 +-- +TABLE: name="unlogged1" schema="" table="unlogged1" ctx=DDL +TABLE: name="public.unlogged2" schema="public" table="unlogged2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unlogged1, public.unlogged2" +== 019 +-- truncate_limit: 100 +CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r' +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relkind" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r'" +== 020 +-- truncate_limit: 100 +CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r' +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relkind" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r'" +== 021 +-- truncate_limit: 100 +CREATE TABLE IF NOT EXISTS as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r' +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relkind" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE IF NOT EXISTS as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r'" +== 022 +-- truncate_limit: 100 +DROP TABLE as_select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE as_select1" +== 023 +-- truncate_limit: 100 +PREPARE select1 AS SELECT 1 as a +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE select1 AS SELECT 1 AS a" +== 024 +-- truncate_limit: 100 +CREATE TABLE as_select1 AS EXECUTE select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TABLE as_select1 AS EXECUTE select1" +== 025 +-- truncate_limit: 100 +CREATE TABLE as_select1 AS EXECUTE select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TABLE as_select1 AS EXECUTE select1" +== 026 +-- truncate_limit: 100 +SELECT * FROM as_select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM as_select1" +== 027 +-- truncate_limit: 100 +CREATE TABLE IF NOT EXISTS as_select1 AS EXECUTE select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TABLE IF NOT EXISTS as_select1 AS EXECUTE select1" +== 028 +-- truncate_limit: 100 +DROP TABLE as_select1 +-- +TABLE: name="as_select1" schema="" table="as_select1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE as_select1" +== 029 +-- truncate_limit: 100 +DEALLOCATE select1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE select1" +== 030 +-- truncate_limit: 100 +-- create an extra wide table to test for issues related to that +-- (temporarily hide query, to avoid the long CREATE TABLE stmt) +SELECT 'CREATE TABLE extra_wide_table(firstc text, '|| array_to_string(array_agg('c'||i||' bool'),',')||', lastc text);' +FROM generate_series(1, 1100) g(i) +INSERT INTO extra_wide_table(firstc, lastc) VALUES('first col', 'last col') +-- +ERROR: syntax error at or near "INSERT" +CURSORPOS: 287 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 031 +-- truncate_limit: 100 +SELECT firstc, lastc FROM extra_wide_table +-- +TABLE: name="extra_wide_table" schema="" table="extra_wide_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT firstc, lastc FROM extra_wide_table" +== 032 +-- truncate_limit: 100 +-- check that tables with oids cannot be created anymore +CREATE TABLE withoid() WITH OIDS +-- +ERROR: syntax error at or near "OIDS" +CURSORPOS: 86 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 033 +-- truncate_limit: 100 +CREATE TABLE withoid() WITH (oids) +-- +TABLE: name="withoid" schema="" table="withoid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE withoid () WITH (oids)" +== 034 +-- truncate_limit: 100 +CREATE TABLE withoid() WITH (oids = true) +-- +TABLE: name="withoid" schema="" table="withoid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE withoid () WITH (oids=true)" +== 035 +-- truncate_limit: 100 +-- but explicitly not adding oids is still supported +CREATE TEMP TABLE withoutoid() WITHOUT OIDS +-- +TABLE: name="withoutoid" schema="" table="withoutoid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE withoutoid ()" +== 036 +-- truncate_limit: 100 +DROP TABLE withoutoid +-- +TABLE: name="withoutoid" schema="" table="withoutoid" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE withoutoid" +== 037 +-- truncate_limit: 100 +CREATE TEMP TABLE withoutoid() WITH (oids = false) +-- +TABLE: name="withoutoid" schema="" table="withoutoid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE withoutoid () WITH (oids=false)" +== 038 +-- truncate_limit: 100 +DROP TABLE withoutoid +-- +TABLE: name="withoutoid" schema="" table="withoutoid" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE withoutoid" +== 039 +-- truncate_limit: 100 +-- temporary tables are ignored by pg_filenode_relation(). +CREATE TEMP TABLE relation_filenode_check(c1 int) +-- +TABLE: name="relation_filenode_check" schema="" table="relation_filenode_check" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE relation_filenode_check (c1 int)" +== 040 +-- truncate_limit: 100 +SELECT relpersistence, + pg_filenode_relation (reltablespace, pg_relation_filenode(oid)) + FROM pg_class + WHERE relname = 'relation_filenode_check' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_filenode_relation" function="pg_filenode_relation" schema="" ctx=Call +FUNCTION: name="pg_relation_filenode" function="pg_relation_filenode" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class WHERE relname = 'relation_filenode_check'" +== 041 +-- truncate_limit: 100 +DROP TABLE relation_filenode_check +-- +TABLE: name="relation_filenode_check" schema="" table="relation_filenode_check" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE relation_filenode_check" +== 042 +-- truncate_limit: 100 +-- check restriction with default expressions +-- invalid use of column reference in default expressions +CREATE TABLE default_expr_column (id int DEFAULT (id)) +-- +TABLE: name="default_expr_column" schema="" table="default_expr_column" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_expr_column (id int DEFAULT id)" +== 043 +-- truncate_limit: 100 +CREATE TABLE default_expr_column (id int DEFAULT (bar.id)) +-- +TABLE: name="default_expr_column" schema="" table="default_expr_column" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_expr_column (id int DEFAULT bar.id)" +== 044 +-- truncate_limit: 100 +CREATE TABLE default_expr_agg_column (id int DEFAULT (avg(id))) +-- +TABLE: name="default_expr_agg_column" schema="" table="default_expr_agg_column" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_expr_agg_column (id int DEFAULT avg(id))" +== 045 +-- truncate_limit: 100 +-- invalid column definition +CREATE TABLE default_expr_non_column (a int DEFAULT (avg(non_existent))) +-- +TABLE: name="default_expr_non_column" schema="" table="default_expr_non_column" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_expr_non_column (a int DEFAULT avg(non_existent))" +== 046 +-- truncate_limit: 100 +-- invalid use of aggregate +CREATE TABLE default_expr_agg (a int DEFAULT (avg(1))) +-- +TABLE: name="default_expr_agg" schema="" table="default_expr_agg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_expr_agg (a int DEFAULT avg(1))" +== 047 +-- truncate_limit: 100 +-- invalid use of subquery +CREATE TABLE default_expr_agg (a int DEFAULT (select 1)) +-- +TABLE: name="default_expr_agg" schema="" table="default_expr_agg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_expr_agg (a int DEFAULT (SELECT 1))" +== 048 +-- truncate_limit: 100 +-- invalid use of set-returning function +CREATE TABLE default_expr_agg (a int DEFAULT (generate_series(1,3))) +-- +TABLE: name="default_expr_agg" schema="" table="default_expr_agg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_expr_agg (a int DEFAULT generate_series(1, 3))" +== 049 +-- truncate_limit: 100 +-- Verify that subtransaction rollback restores rd_createSubid. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 050 +-- truncate_limit: 100 +CREATE TABLE remember_create_subid (c int) +-- +TABLE: name="remember_create_subid" schema="" table="remember_create_subid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE remember_create_subid (c int)" +== 051 +-- truncate_limit: 100 +SAVEPOINT q +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT q" +== 052 +-- truncate_limit: 100 +DROP TABLE remember_create_subid +-- +TABLE: name="remember_create_subid" schema="" table="remember_create_subid" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE remember_create_subid" +== 053 +-- truncate_limit: 100 +ROLLBACK TO q +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT q" +== 054 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 055 +-- truncate_limit: 100 +DROP TABLE remember_create_subid +-- +TABLE: name="remember_create_subid" schema="" table="remember_create_subid" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE remember_create_subid" +== 056 +-- truncate_limit: 100 +-- Verify that subtransaction rollback restores rd_firstRelfilenodeSubid. +CREATE TABLE remember_node_subid (c int) +-- +TABLE: name="remember_node_subid" schema="" table="remember_node_subid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE remember_node_subid (c int)" +== 057 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 058 +-- truncate_limit: 100 +ALTER TABLE remember_node_subid ALTER c TYPE bigint +-- +TABLE: name="remember_node_subid" schema="" table="remember_node_subid" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE remember_node_subid ALTER COLUMN c TYPE bigint" +== 059 +-- truncate_limit: 100 +SAVEPOINT q +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT q" +== 060 +-- truncate_limit: 100 +DROP TABLE remember_node_subid +-- +TABLE: name="remember_node_subid" schema="" table="remember_node_subid" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE remember_node_subid" +== 061 +-- truncate_limit: 100 +ROLLBACK TO q +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT q" +== 062 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 063 +-- truncate_limit: 100 +DROP TABLE remember_node_subid +-- +TABLE: name="remember_node_subid" schema="" table="remember_node_subid" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE remember_node_subid" +== 064 +-- truncate_limit: 100 +|-- +-- Partitioned tables +|-- + +-- cannot combine INHERITS and PARTITION BY (although grammar allows) +CREATE TABLE partitioned ( + a int +) INHERITS (some_table) PARTITION BY LIST (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) INHERITS (some_table) PARTITION BY LIST (a)" +== 065 +-- truncate_limit: 100 +-- cannot use more than 1 column as partition key for list partitioned table +CREATE TABLE partitioned ( + a1 int, + a2 int +) PARTITION BY LIST (a1, a2) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a1 int, a2 int) PARTITION BY LIST (a1, a2)" +== 066 +-- truncate_limit: 100 +-- fail + +-- prevent using prohibited expressions in the key +CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="retset" function="retset" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION retset(a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE sql IMMUTABLE" +== 067 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (retset(a)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) PARTITION BY RANGE ((retset(a)))" +== 068 +-- truncate_limit: 100 +DROP FUNCTION retset(int) +-- +FUNCTION: name="retset" function="retset" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION retset(int)" +== 069 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE ((avg(a))) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) PARTITION BY RANGE ((avg(a)))" +== 070 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int, + b int +) PARTITION BY RANGE ((avg(a) OVER (PARTITION BY b))) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int, b int) PARTITION BY RANGE ((avg(a) OVER (PARTITION BY b)))" +== 071 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int +) PARTITION BY LIST ((a LIKE (SELECT 1))) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) PARTITION BY LIST ((a LIKE (SELECT 1)))" +== 072 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE ((42)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) PARTITION BY RANGE ((42))" +== 073 +-- truncate_limit: 100 +CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="const_func" function="const_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION const_func() RETURNS int AS $$ SELECT 1; $$ LANGUAGE sql IMMUTABLE" +== 074 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (const_func()) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) PARTITION BY RANGE ((const_func()))" +== 075 +-- truncate_limit: 100 +DROP FUNCTION const_func() +-- +FUNCTION: name="const_func" function="const_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION const_func()" +== 076 +-- truncate_limit: 100 +-- only accept valid partitioning strategy +CREATE TABLE partitioned ( + a int +) PARTITION BY MAGIC (a) +-- +ERROR: unrecognized partitioning strategy "magic" +FILENAME: gram.y +FUNCNAME: parsePartitionStrategy +== 077 +-- truncate_limit: 100 +-- specified column must be present in the table +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (b) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) PARTITION BY RANGE (b)" +== 078 +-- truncate_limit: 100 +-- cannot use system columns in partition key +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (xmin) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) PARTITION BY RANGE (xmin)" +== 079 +-- truncate_limit: 100 +-- cannot use pseudotypes +CREATE TABLE partitioned ( + a int, + b int +) PARTITION BY RANGE (((a, b))) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int, b int) PARTITION BY RANGE (((a, b)))" +== 080 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int, + b int +) PARTITION BY RANGE (a, ('unknown')) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int, b int) PARTITION BY RANGE (a, ('unknown'))" +== 081 +-- truncate_limit: 100 +-- functions in key must be immutable +CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL +-- +FUNCTION: name="immut_func" function="immut_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION immut_func(a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE sql" +== 082 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int +) PARTITION BY RANGE (immut_func(a)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int) PARTITION BY RANGE ((immut_func(a)))" +== 083 +-- truncate_limit: 100 +DROP FUNCTION immut_func(int) +-- +FUNCTION: name="immut_func" function="immut_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION immut_func(int)" +== 084 +-- truncate_limit: 100 +-- prevent using columns of unsupported types in key (type must have a btree operator class) +CREATE TABLE partitioned ( + a point +) PARTITION BY LIST (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a point) PARTITION BY LIST (a)" +== 085 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a point +) PARTITION BY LIST (a point_ops) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a point) PARTITION BY LIST (a point_ops)" +== 086 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a point +) PARTITION BY RANGE (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a point) PARTITION BY RANGE (a)" +== 087 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a point +) PARTITION BY RANGE (a point_ops) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a point) PARTITION BY RANGE (a point_ops)" +== 088 +-- truncate_limit: 100 +-- cannot add NO INHERIT constraints to partitioned tables +CREATE TABLE partitioned ( + a int, + CONSTRAINT check_a CHECK (a > 0) NO INHERIT +) PARTITION BY RANGE (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int, CONSTRAINT check_a CHECK (a > 0) NO INHERIT) PARTITION BY RANGE (a)" +== 089 +-- truncate_limit: 100 +-- some checks after successful creation of a partitioned table +CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL +-- +FUNCTION: name="plusone" function="plusone" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION plusone(a int) RETURNS int AS $$ SELECT a+1; $$ LANGUAGE sql" +== 090 +-- truncate_limit: 100 +CREATE TABLE partitioned ( + a int, + b int, + c text, + d text +) PARTITION BY RANGE (a oid_ops, plusone(b), c collate "default", d collate "C") +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int, b int, c text, d text) PARTITION BY RANGE (a oid_ops, (plusone(b..." +== 091 +-- truncate_limit: 100 +-- check relkind +SELECT relkind FROM pg_class WHERE relname = 'partitioned' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relkind FROM pg_class WHERE relname = 'partitioned'" +== 092 +-- truncate_limit: 100 +-- prevent a function referenced in partition key from being dropped +DROP FUNCTION plusone(int) +-- +FUNCTION: name="plusone" function="plusone" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION plusone(int)" +== 093 +-- truncate_limit: 100 +-- partitioned table cannot participate in regular inheritance +CREATE TABLE partitioned2 ( + a int, + b text +) PARTITION BY RANGE ((a+1), substr(b, 1, 5)) +-- +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned2 (a int, b text) PARTITION BY RANGE ((a + 1), (substr(b, 1, 5)))" +== 094 +-- truncate_limit: 100 +CREATE TABLE fail () INHERITS (partitioned2) +-- +TABLE: name="fail" schema="" table="fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail () INHERITS (partitioned2)" +== 095 +-- truncate_limit: 100 +-- Partition key in describe output + +INSERT INTO partitioned2 VALUES (1, 'hello') +-- +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO partitioned2 VALUES (1, 'hello')" +== 096 +-- truncate_limit: 100 +CREATE TABLE part2_1 PARTITION OF partitioned2 FOR VALUES FROM (-1, 'aaaaa') TO (100, 'ccccc') +-- +TABLE: name="part2_1" schema="" table="part2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part2_1 PARTITION OF partitioned2 FOR VALUES FROM (-1, 'aaaaa') TO (100, 'ccccc')" +== 097 +-- truncate_limit: 100 +DROP TABLE partitioned, partitioned2 +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE partitioned, partitioned2" +== 098 +-- truncate_limit: 100 +-- check reference to partitioned table's rowtype in partition descriptor +create table partitioned (a int, b int) + partition by list ((row(a, b)::partitioned)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int, b int) PARTITION BY LIST ((ROW(a, b)::partitioned))" +== 099 +-- truncate_limit: 100 +create table partitioned1 + partition of partitioned for values in ('(1,2)'::partitioned) +-- +TABLE: name="partitioned1" schema="" table="partitioned1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned1 PARTITION OF partitioned FOR VALUES IN ('(1,2)'::partitioned)" +== 100 +-- truncate_limit: 100 +create table partitioned2 + partition of partitioned for values in ('(2,4)'::partitioned) +-- +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned2 PARTITION OF partitioned FOR VALUES IN ('(2,4)'::partitioned)" +== 101 +-- truncate_limit: 100 +explain (costs off) +select * from partitioned where row(a,b)::partitioned = '(1,2)'::partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM partitioned WHERE ROW(a, b)::partitioned = '(1,2)'::partitioned" +== 102 +-- truncate_limit: 100 +drop table partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE partitioned" +== 103 +-- truncate_limit: 100 +-- whole-row Var in partition key works too +create table partitioned (a int, b int) + partition by list ((partitioned)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a int, b int) PARTITION BY LIST ((partitioned))" +== 104 +-- truncate_limit: 100 +create table partitioned1 + partition of partitioned for values in ('(1,2)') +-- +TABLE: name="partitioned1" schema="" table="partitioned1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned1 PARTITION OF partitioned FOR VALUES IN ('(1,2)')" +== 105 +-- truncate_limit: 100 +create table partitioned2 + partition of partitioned for values in ('(2,4)') +-- +TABLE: name="partitioned2" schema="" table="partitioned2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned2 PARTITION OF partitioned FOR VALUES IN ('(2,4)')" +== 106 +-- truncate_limit: 100 +explain (costs off) +select * from partitioned where partitioned = '(1,2)'::partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=Select +FILTER: schema="" table="" column="partitioned" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM partitioned WHERE partitioned = '(1,2)'::partitioned" +== 107 +-- truncate_limit: 100 +drop table partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE partitioned" +== 108 +-- truncate_limit: 100 +-- check that dependencies of partition columns are handled correctly +create domain intdom1 as int +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN intdom1 AS int" +== 109 +-- truncate_limit: 100 +create table partitioned ( + a intdom1, + b text +) partition by range (a) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a intdom1, b text) PARTITION BY RANGE (a)" +== 110 +-- truncate_limit: 100 +alter table partitioned drop column a +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned DROP a" +== 111 +-- truncate_limit: 100 +-- fail + +drop domain intdom1 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN intdom1" +== 112 +-- truncate_limit: 100 +-- fail, requires cascade + +drop domain intdom1 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN intdom1 CASCADE" +== 113 +-- truncate_limit: 100 +table partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM partitioned" +== 114 +-- truncate_limit: 100 +-- gone + +-- likewise for columns used in partition expressions +create domain intdom1 as int +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN intdom1 AS int" +== 115 +-- truncate_limit: 100 +create table partitioned ( + a intdom1, + b text +) partition by range (plusone(a)) +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned (a intdom1, b text) PARTITION BY RANGE ((plusone(a)))" +== 116 +-- truncate_limit: 100 +alter table partitioned drop column a +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE partitioned DROP a" +== 117 +-- truncate_limit: 100 +-- fail + +drop domain intdom1 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN intdom1" +== 118 +-- truncate_limit: 100 +-- fail, requires cascade + +drop domain intdom1 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN intdom1 CASCADE" +== 119 +-- truncate_limit: 100 +table partitioned +-- +TABLE: name="partitioned" schema="" table="partitioned" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM partitioned" +== 120 +-- truncate_limit: 100 +-- gone + + +|-- +-- Partitions +|-- + +-- check partition bound syntax + +CREATE TABLE list_parted ( + a int +) PARTITION BY LIST (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted (a int) PARTITION BY LIST (a)" +== 121 +-- truncate_limit: 100 +CREATE TABLE part_p1 PARTITION OF list_parted FOR VALUES IN ('1') +-- +TABLE: name="part_p1" schema="" table="part_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_p1 PARTITION OF list_parted FOR VALUES IN ('1')" +== 122 +-- truncate_limit: 100 +CREATE TABLE part_p2 PARTITION OF list_parted FOR VALUES IN (2) +-- +TABLE: name="part_p2" schema="" table="part_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_p2 PARTITION OF list_parted FOR VALUES IN (2)" +== 123 +-- truncate_limit: 100 +CREATE TABLE part_p3 PARTITION OF list_parted FOR VALUES IN ((2+1)) +-- +TABLE: name="part_p3" schema="" table="part_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_p3 PARTITION OF list_parted FOR VALUES IN (2 + 1)" +== 124 +-- truncate_limit: 100 +CREATE TABLE part_null PARTITION OF list_parted FOR VALUES IN (null) +-- +TABLE: name="part_null" schema="" table="part_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_null PARTITION OF list_parted FOR VALUES IN (NULL)" +== 125 +-- truncate_limit: 100 +-- forbidden expressions for partition bound with list partitioned table +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename)" +== 126 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename.somename) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (somename.somename)" +== 127 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (a) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (a)" +== 128 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(a)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(a))" +== 129 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(somename)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(somename))" +== 130 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(1)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (sum(1))" +== 131 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((select 1)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((SELECT 1))" +== 132 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (generate_series(4, 6)) +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN (generate_series(4, 6))" +== 133 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((1+1) collate "POSIX") +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF list_parted FOR VALUES IN ((1 + 1) COLLATE \"POSIX\")" +== 134 +-- truncate_limit: 100 +-- syntax does not allow empty list of values for list partitions +CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES IN () +-- +ERROR: syntax error at or near ")" +CURSORPOS: 130 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 135 +-- truncate_limit: 100 +-- trying to specify range for list partitioned table +CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES FROM (1) TO (2) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES FROM (1) TO (2)" +== 136 +-- truncate_limit: 100 +-- trying to specify modulus and remainder for list partitioned table +CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF list_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1)" +== 137 +-- truncate_limit: 100 +-- check default partition cannot be created more than once +CREATE TABLE part_default PARTITION OF list_parted DEFAULT +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_default PARTITION OF list_parted DEFAULT" +== 138 +-- truncate_limit: 100 +CREATE TABLE fail_default_part PARTITION OF list_parted DEFAULT +-- +TABLE: name="fail_default_part" schema="" table="fail_default_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_default_part PARTITION OF list_parted DEFAULT" +== 139 +-- truncate_limit: 100 +-- specified literal can't be cast to the partition column data type +CREATE TABLE bools ( + a bool +) PARTITION BY LIST (a) +-- +TABLE: name="bools" schema="" table="bools" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bools (a bool) PARTITION BY LIST (a)" +== 140 +-- truncate_limit: 100 +CREATE TABLE bools_true PARTITION OF bools FOR VALUES IN (1) +-- +TABLE: name="bools_true" schema="" table="bools_true" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bools_true PARTITION OF bools FOR VALUES IN (1)" +== 141 +-- truncate_limit: 100 +DROP TABLE bools +-- +TABLE: name="bools" schema="" table="bools" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bools" +== 142 +-- truncate_limit: 100 +-- specified literal can be cast, and the cast might not be immutable +CREATE TABLE moneyp ( + a money +) PARTITION BY LIST (a) +-- +TABLE: name="moneyp" schema="" table="moneyp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE moneyp (a money) PARTITION BY LIST (a)" +== 143 +-- truncate_limit: 100 +CREATE TABLE moneyp_10 PARTITION OF moneyp FOR VALUES IN (10) +-- +TABLE: name="moneyp_10" schema="" table="moneyp_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE moneyp_10 PARTITION OF moneyp FOR VALUES IN (10)" +== 144 +-- truncate_limit: 100 +CREATE TABLE moneyp_11 PARTITION OF moneyp FOR VALUES IN ('11') +-- +TABLE: name="moneyp_11" schema="" table="moneyp_11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE moneyp_11 PARTITION OF moneyp FOR VALUES IN ('11')" +== 145 +-- truncate_limit: 100 +CREATE TABLE moneyp_12 PARTITION OF moneyp FOR VALUES IN (to_char(12, '99')::int) +-- +TABLE: name="moneyp_12" schema="" table="moneyp_12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE moneyp_12 PARTITION OF moneyp FOR VALUES IN (to_char(12, '99')::int)" +== 146 +-- truncate_limit: 100 +DROP TABLE moneyp +-- +TABLE: name="moneyp" schema="" table="moneyp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE moneyp" +== 147 +-- truncate_limit: 100 +-- cast is immutable +CREATE TABLE bigintp ( + a bigint +) PARTITION BY LIST (a) +-- +TABLE: name="bigintp" schema="" table="bigintp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bigintp (a bigint) PARTITION BY LIST (a)" +== 148 +-- truncate_limit: 100 +CREATE TABLE bigintp_10 PARTITION OF bigintp FOR VALUES IN (10) +-- +TABLE: name="bigintp_10" schema="" table="bigintp_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bigintp_10 PARTITION OF bigintp FOR VALUES IN (10)" +== 149 +-- truncate_limit: 100 +-- fails due to overlap: +CREATE TABLE bigintp_10_2 PARTITION OF bigintp FOR VALUES IN ('10') +-- +TABLE: name="bigintp_10_2" schema="" table="bigintp_10_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bigintp_10_2 PARTITION OF bigintp FOR VALUES IN ('10')" +== 150 +-- truncate_limit: 100 +DROP TABLE bigintp +-- +TABLE: name="bigintp" schema="" table="bigintp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bigintp" +== 151 +-- truncate_limit: 100 +CREATE TABLE range_parted ( + a date +) PARTITION BY RANGE (a) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted (a date) PARTITION BY RANGE (a)" +== 152 +-- truncate_limit: 100 +-- forbidden expressions for partition bounds with range partitioned table +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (somename) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted FOR VALUES FROM (somename) TO ('2019-..." +== 153 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (somename.somename) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted FOR VALUES FROM (somename.somename) T..." +== 154 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (a) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted FOR VALUES FROM (a) TO ('2019-01-01')" +== 155 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (max(a)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted FOR VALUES FROM (max(a)) TO ('2019-01..." +== 156 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (max(somename)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted FOR VALUES FROM (max(somename)) TO ('..." +== 157 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (max('2019-02-01'::date)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted FOR VALUES FROM (max('2019-02-01'::da..." +== 158 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM ((select 1)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted FOR VALUES FROM ((SELECT 1)) TO ('201..." +== 159 +-- truncate_limit: 100 +CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted + FOR VALUES FROM (generate_series(1, 3)) TO ('2019-01-01') +-- +TABLE: name="part_bogus_expr_fail" schema="" table="part_bogus_expr_fail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bogus_expr_fail PARTITION OF range_parted FOR VALUES FROM (generate_series(1, 3..." +== 160 +-- truncate_limit: 100 +-- trying to specify list for range partitioned table +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES IN ('a') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES IN ('a')" +== 161 +-- truncate_limit: 100 +-- trying to specify modulus and remainder for range partitioned table +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1)" +== 162 +-- truncate_limit: 100 +-- each of start and end bounds must have same number of values as the +-- length of the partition key +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('z') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('z')" +== 163 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a') TO ('z', 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM ('a') TO ('z', 1)" +== 164 +-- truncate_limit: 100 +-- cannot specify null values in range bounds +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM (null) TO (maxvalue) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES FROM (NULL) TO (maxvalue)" +== 165 +-- truncate_limit: 100 +-- trying to specify modulus and remainder for range partitioned table +CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted FOR VALUES WITH (MODULUS 10, REMAINDER 1)" +== 166 +-- truncate_limit: 100 +-- check partition bound syntax for the hash partition +CREATE TABLE hash_parted ( + a int +) PARTITION BY HASH (a) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_parted (a int) PARTITION BY HASH (a)" +== 167 +-- truncate_limit: 100 +CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 0) +-- +TABLE: name="hpart_1" schema="" table="hpart_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart_1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 0)" +== 168 +-- truncate_limit: 100 +CREATE TABLE hpart_2 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 50, REMAINDER 1) +-- +TABLE: name="hpart_2" schema="" table="hpart_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart_2 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 50, REMAINDER 1)" +== 169 +-- truncate_limit: 100 +CREATE TABLE hpart_3 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 200, REMAINDER 2) +-- +TABLE: name="hpart_3" schema="" table="hpart_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart_3 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 200, REMAINDER 2)" +== 170 +-- truncate_limit: 100 +CREATE TABLE hpart_4 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 3) +-- +TABLE: name="hpart_4" schema="" table="hpart_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart_4 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 10, REMAINDER 3)" +== 171 +-- truncate_limit: 100 +-- modulus 25 is factor of modulus of 50 but 10 is not a factor of 25. +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 25, REMAINDER 3) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 25, REMAINDER 3)" +== 172 +-- truncate_limit: 100 +-- previous modulus 50 is factor of 150 but this modulus is not a factor of next modulus 200. +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 150, REMAINDER 3) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 150, REMAINDER 3)" +== 173 +-- truncate_limit: 100 +-- overlapping remainders +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 100, REMAINDER 3) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES WITH (MODULUS 100, REMAINDER 3)" +== 174 +-- truncate_limit: 100 +-- trying to specify range for the hash partitioned table +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES FROM ('a', 1) TO ('z') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES FROM ('a', 1) TO ('z')" +== 175 +-- truncate_limit: 100 +-- trying to specify list value for the hash partitioned table +CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES IN (1000) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF hash_parted FOR VALUES IN (1000)" +== 176 +-- truncate_limit: 100 +-- trying to create default partition for the hash partitioned table +CREATE TABLE fail_default_part PARTITION OF hash_parted DEFAULT +-- +TABLE: name="fail_default_part" schema="" table="fail_default_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_default_part PARTITION OF hash_parted DEFAULT" +== 177 +-- truncate_limit: 100 +-- check if compatible with the specified parent + +-- cannot create as partition of a non-partitioned table +CREATE TABLE unparted ( + a int +) +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unparted (a int)" +== 178 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF unparted FOR VALUES IN ('a') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF unparted FOR VALUES IN ('a')" +== 179 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF unparted FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF unparted FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 180 +-- truncate_limit: 100 +DROP TABLE unparted +-- +TABLE: name="unparted" schema="" table="unparted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unparted" +== 181 +-- truncate_limit: 100 +-- cannot create a permanent rel as partition of a temp rel +CREATE TEMP TABLE temp_parted ( + a int +) PARTITION BY LIST (a) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted (a int) PARTITION BY LIST (a)" +== 182 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF temp_parted FOR VALUES IN ('a') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF temp_parted FOR VALUES IN ('a')" +== 183 +-- truncate_limit: 100 +DROP TABLE temp_parted +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_parted" +== 184 +-- truncate_limit: 100 +-- check for partition bound overlap and other invalid specifications + +CREATE TABLE list_parted2 ( + a varchar +) PARTITION BY LIST (a) +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted2 (a varchar) PARTITION BY LIST (a)" +== 185 +-- truncate_limit: 100 +CREATE TABLE part_null_z PARTITION OF list_parted2 FOR VALUES IN (null, 'z') +-- +TABLE: name="part_null_z" schema="" table="part_null_z" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_null_z PARTITION OF list_parted2 FOR VALUES IN (NULL, 'z')" +== 186 +-- truncate_limit: 100 +CREATE TABLE part_ab PARTITION OF list_parted2 FOR VALUES IN ('a', 'b') +-- +TABLE: name="part_ab" schema="" table="part_ab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ab PARTITION OF list_parted2 FOR VALUES IN ('a', 'b')" +== 187 +-- truncate_limit: 100 +CREATE TABLE list_parted2_def PARTITION OF list_parted2 DEFAULT +-- +TABLE: name="list_parted2_def" schema="" table="list_parted2_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted2_def PARTITION OF list_parted2 DEFAULT" +== 188 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN (null) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN (NULL)" +== 189 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('b', 'c') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('b', 'c')" +== 190 +-- truncate_limit: 100 +-- check default partition overlap +INSERT INTO list_parted2 VALUES('X') +-- +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted2 VALUES ('X')" +== 191 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('W', 'X', 'Y') +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF list_parted2 FOR VALUES IN ('W', 'X', 'Y')" +== 192 +-- truncate_limit: 100 +CREATE TABLE range_parted2 ( + a int +) PARTITION BY RANGE (a) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted2 (a int) PARTITION BY RANGE (a)" +== 193 +-- truncate_limit: 100 +-- trying to create range partition with empty range +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (0) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (0)" +== 194 +-- truncate_limit: 100 +-- note that the range '[1, 1)' has no elements +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (1) TO (1)" +== 195 +-- truncate_limit: 100 +CREATE TABLE part0 PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (1) +-- +TABLE: name="part0" schema="" table="part0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part0 PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (1)" +== 196 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (2) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (minvalue) TO (2)" +== 197 +-- truncate_limit: 100 +CREATE TABLE part1 PARTITION OF range_parted2 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part1 PARTITION OF range_parted2 FOR VALUES FROM (1) TO (10)" +== 198 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (-1) TO (1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (-1) TO (1)" +== 199 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (9) TO (maxvalue) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (9) TO (maxvalue)" +== 200 +-- truncate_limit: 100 +CREATE TABLE part2 PARTITION OF range_parted2 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part2 PARTITION OF range_parted2 FOR VALUES FROM (20) TO (30)" +== 201 +-- truncate_limit: 100 +CREATE TABLE part3 PARTITION OF range_parted2 FOR VALUES FROM (30) TO (40) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part3 PARTITION OF range_parted2 FOR VALUES FROM (30) TO (40)" +== 202 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (30) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (30)" +== 203 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (50) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (10) TO (50)" +== 204 +-- truncate_limit: 100 +-- Create a default partition for range partitioned table +CREATE TABLE range2_default PARTITION OF range_parted2 DEFAULT +-- +TABLE: name="range2_default" schema="" table="range2_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range2_default PARTITION OF range_parted2 DEFAULT" +== 205 +-- truncate_limit: 100 +-- More than one default partition is not allowed, so this should give error +CREATE TABLE fail_default_part PARTITION OF range_parted2 DEFAULT +-- +TABLE: name="fail_default_part" schema="" table="fail_default_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_default_part PARTITION OF range_parted2 DEFAULT" +== 206 +-- truncate_limit: 100 +-- Check if the range for default partitions overlap +INSERT INTO range_parted2 VALUES (85) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted2 VALUES (85)" +== 207 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (80) TO (90) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted2 FOR VALUES FROM (80) TO (90)" +== 208 +-- truncate_limit: 100 +CREATE TABLE part4 PARTITION OF range_parted2 FOR VALUES FROM (90) TO (100) +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part4 PARTITION OF range_parted2 FOR VALUES FROM (90) TO (100)" +== 209 +-- truncate_limit: 100 +-- now check for multi-column range partition key +CREATE TABLE range_parted3 ( + a int, + b int +) PARTITION BY RANGE (a, (b+1)) +-- +TABLE: name="range_parted3" schema="" table="range_parted3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted3 (a int, b int) PARTITION BY RANGE (a, (b + 1))" +== 210 +-- truncate_limit: 100 +CREATE TABLE part00 PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, maxvalue) +-- +TABLE: name="part00" schema="" table="part00" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part00 PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, maxvalue)" +== 211 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (0, minvalue) TO (0, 1)" +== 212 +-- truncate_limit: 100 +CREATE TABLE part10 PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, 1) +-- +TABLE: name="part10" schema="" table="part10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part10 PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, 1)" +== 213 +-- truncate_limit: 100 +CREATE TABLE part11 PARTITION OF range_parted3 FOR VALUES FROM (1, 1) TO (1, 10) +-- +TABLE: name="part11" schema="" table="part11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part11 PARTITION OF range_parted3 FOR VALUES FROM (1, 1) TO (1, 10)" +== 214 +-- truncate_limit: 100 +CREATE TABLE part12 PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, maxvalue) +-- +TABLE: name="part12" schema="" table="part12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part12 PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, maxvalue)" +== 215 +-- truncate_limit: 100 +CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, 20) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, 10) TO (1, 20)" +== 216 +-- truncate_limit: 100 +CREATE TABLE range3_default PARTITION OF range_parted3 DEFAULT +-- +TABLE: name="range3_default" schema="" table="range3_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range3_default PARTITION OF range_parted3 DEFAULT" +== 217 +-- truncate_limit: 100 +-- cannot create a partition that says column b is allowed to range +-- from -infinity to +infinity, while there exist partitions that have +-- more specific ranges +CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, maxvalue) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF range_parted3 FOR VALUES FROM (1, minvalue) TO (1, maxvalue)" +== 218 +-- truncate_limit: 100 +-- check for partition bound overlap and other invalid specifications for the hash partition +CREATE TABLE hash_parted2 ( + a varchar +) PARTITION BY HASH (a) +-- +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_parted2 (a varchar) PARTITION BY HASH (a)" +== 219 +-- truncate_limit: 100 +CREATE TABLE h2part_1 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 4, REMAINDER 2) +-- +TABLE: name="h2part_1" schema="" table="h2part_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE h2part_1 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 4, REMAINDER 2)" +== 220 +-- truncate_limit: 100 +CREATE TABLE h2part_2 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 0) +-- +TABLE: name="h2part_2" schema="" table="h2part_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE h2part_2 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 0)" +== 221 +-- truncate_limit: 100 +CREATE TABLE h2part_3 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 4) +-- +TABLE: name="h2part_3" schema="" table="h2part_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE h2part_3 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 4)" +== 222 +-- truncate_limit: 100 +CREATE TABLE h2part_4 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 5) +-- +TABLE: name="h2part_4" schema="" table="h2part_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE h2part_4 PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 5)" +== 223 +-- truncate_limit: 100 +-- overlap with part_4 +CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 224 +-- truncate_limit: 100 +-- modulus must be greater than zero +CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 0, REMAINDER 1) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 0, REMAINDER 1)" +== 225 +-- truncate_limit: 100 +-- remainder must be greater than or equal to zero and less than modulus +CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 8) +-- +TABLE: name="fail_part" schema="" table="fail_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part PARTITION OF hash_parted2 FOR VALUES WITH (MODULUS 8, REMAINDER 8)" +== 226 +-- truncate_limit: 100 +-- check schema propagation from parent + +CREATE TABLE parted ( + a text, + b int NOT NULL DEFAULT 0, + CONSTRAINT check_a CHECK (length(a) > 0) +) PARTITION BY LIST (a) +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted (a text, b int NOT NULL DEFAULT 0, CONSTRAINT check_a CHECK (length(a) > 0)) ..." +== 227 +-- truncate_limit: 100 +CREATE TABLE part_a PARTITION OF parted FOR VALUES IN ('a') +-- +TABLE: name="part_a" schema="" table="part_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_a PARTITION OF parted FOR VALUES IN ('a')" +== 228 +-- truncate_limit: 100 +-- only inherited attributes (never local ones) +SELECT attname, attislocal, attinhcount FROM pg_attribute + WHERE attrelid = 'part_a'::regclass and attnum > 0 + ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT attname, attislocal, attinhcount FROM pg_attribute WHERE ... ORDER BY attnum" +== 229 +-- truncate_limit: 100 +-- able to specify column default, column constraint, and table constraint + +-- first check the "column specified more than once" error +CREATE TABLE part_b PARTITION OF parted ( + b NOT NULL, + b DEFAULT 1, + b CHECK (b >= 0), + CONSTRAINT check_a CHECK (length(a) > 0) +) FOR VALUES IN ('b') +-- +TABLE: name="part_b" schema="" table="part_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_b PARTITION OF parted (b NOT NULL, b DEFAULT 1, b CHECK (b >= 0), CONSTRAINT ch..." +== 230 +-- truncate_limit: 100 +CREATE TABLE part_b PARTITION OF parted ( + b NOT NULL DEFAULT 1, + CONSTRAINT check_a CHECK (length(a) > 0), + CONSTRAINT check_b CHECK (b >= 0) +) FOR VALUES IN ('b') +-- +TABLE: name="part_b" schema="" table="part_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_b PARTITION OF parted (b NOT NULL DEFAULT 1, CONSTRAINT check_a CHECK (length(a..." +== 231 +-- truncate_limit: 100 +-- conislocal should be false for any merged constraints, true otherwise +SELECT conname, conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname" +== 232 +-- truncate_limit: 100 +-- Once check_b is added to the parent, it should be made non-local for part_b +ALTER TABLE parted ADD CONSTRAINT check_b CHECK (b >= 0) +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted ADD CONSTRAINT check_b CHECK (b >= 0)" +== 233 +-- truncate_limit: 100 +SELECT conname, conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname" +== 234 +-- truncate_limit: 100 +-- Neither check_a nor check_b are droppable from part_b +ALTER TABLE part_b DROP CONSTRAINT check_a +-- +TABLE: name="part_b" schema="" table="part_b" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_b DROP CONSTRAINT check_a" +== 235 +-- truncate_limit: 100 +ALTER TABLE part_b DROP CONSTRAINT check_b +-- +TABLE: name="part_b" schema="" table="part_b" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_b DROP CONSTRAINT check_b" +== 236 +-- truncate_limit: 100 +-- And dropping it from parted should leave no trace of them on part_b, unlike +-- traditional inheritance where they will be left behind, because they would +-- be local constraints. +ALTER TABLE parted DROP CONSTRAINT check_a, DROP CONSTRAINT check_b +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted DROP CONSTRAINT check_a, DROP CONSTRAINT check_b" +== 237 +-- truncate_limit: 100 +SELECT conname, conislocal, coninhcount FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'part_b'::regclass ORDER BY coninhcount DESC, conname" +== 238 +-- truncate_limit: 100 +-- specify PARTITION BY for a partition +CREATE TABLE fail_part_col_not_found PARTITION OF parted FOR VALUES IN ('c') PARTITION BY RANGE (c) +-- +TABLE: name="fail_part_col_not_found" schema="" table="fail_part_col_not_found" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fail_part_col_not_found PARTITION OF parted FOR VALUES IN ('c') PARTITION BY RANGE (c)" +== 239 +-- truncate_limit: 100 +CREATE TABLE part_c PARTITION OF parted (b WITH OPTIONS NOT NULL DEFAULT 0) FOR VALUES IN ('c') PARTITION BY RANGE ((b)) +-- +TABLE: name="part_c" schema="" table="part_c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_c PARTITION OF parted (b NOT NULL DEFAULT 0) FOR VALUES IN ('c') PARTITION BY R..." +== 240 +-- truncate_limit: 100 +-- create a level-2 partition +CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10) +-- +TABLE: name="part_c_1_10" schema="" table="part_c_1_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_c_1_10 PARTITION OF part_c FOR VALUES FROM (1) TO (10)" +== 241 +-- truncate_limit: 100 +-- check that NOT NULL and default value are inherited correctly +create table parted_notnull_inh_test (a int default 1, b int not null default 0) partition by list (a) +-- +TABLE: name="parted_notnull_inh_test" schema="" table="parted_notnull_inh_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_notnull_inh_test (a int DEFAULT 1, b int NOT NULL DEFAULT 0) PARTITION BY LIS..." +== 242 +-- truncate_limit: 100 +create table parted_notnull_inh_test1 partition of parted_notnull_inh_test (a not null, b default 1) for values in (1) +-- +TABLE: name="parted_notnull_inh_test1" schema="" table="parted_notnull_inh_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_notnull_inh_test1 PARTITION OF parted_notnull_inh_test (a NOT NULL, b DEFAULT..." +== 243 +-- truncate_limit: 100 +insert into parted_notnull_inh_test (b) values (null) +-- +TABLE: name="parted_notnull_inh_test" schema="" table="parted_notnull_inh_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_notnull_inh_test (b) VALUES (NULL)" +== 244 +-- truncate_limit: 100 +-- note that while b's default is overridden, a's default is preserved +drop table parted_notnull_inh_test +-- +TABLE: name="parted_notnull_inh_test" schema="" table="parted_notnull_inh_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_notnull_inh_test" +== 245 +-- truncate_limit: 100 +-- check that collations are assigned in partition bound expressions +create table parted_boolean_col (a bool, b text) partition by list(a) +-- +TABLE: name="parted_boolean_col" schema="" table="parted_boolean_col" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_boolean_col (a bool, b text) PARTITION BY LIST (a)" +== 246 +-- truncate_limit: 100 +create table parted_boolean_less partition of parted_boolean_col + for values in ('foo' < 'bar') +-- +TABLE: name="parted_boolean_less" schema="" table="parted_boolean_less" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_boolean_less PARTITION OF parted_boolean_col FOR VALUES IN ('foo' < 'bar')" +== 247 +-- truncate_limit: 100 +create table parted_boolean_greater partition of parted_boolean_col + for values in ('foo' > 'bar') +-- +TABLE: name="parted_boolean_greater" schema="" table="parted_boolean_greater" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_boolean_greater PARTITION OF parted_boolean_col FOR VALUES IN ('foo' > 'bar')" +== 248 +-- truncate_limit: 100 +drop table parted_boolean_col +-- +TABLE: name="parted_boolean_col" schema="" table="parted_boolean_col" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_boolean_col" +== 249 +-- truncate_limit: 100 +-- check for a conflicting COLLATE clause +create table parted_collate_must_match (a text collate "C", b text collate "C") + partition by range (a) +-- +TABLE: name="parted_collate_must_match" schema="" table="parted_collate_must_match" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_collate_must_match (a text COLLATE \"C\", b text COLLATE \"C\") PARTITION BY RANG..." +== 250 +-- truncate_limit: 100 +-- on the partition key +create table parted_collate_must_match1 partition of parted_collate_must_match + (a collate "POSIX") for values from ('a') to ('m') +-- +TABLE: name="parted_collate_must_match1" schema="" table="parted_collate_must_match1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_collate_must_match1 PARTITION OF parted_collate_must_match (a COLLATE \"POSIX\"..." +== 251 +-- truncate_limit: 100 +-- on another column +create table parted_collate_must_match2 partition of parted_collate_must_match + (b collate "POSIX") for values from ('m') to ('z') +-- +TABLE: name="parted_collate_must_match2" schema="" table="parted_collate_must_match2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_collate_must_match2 PARTITION OF parted_collate_must_match (b COLLATE \"POSIX\"..." +== 252 +-- truncate_limit: 100 +drop table parted_collate_must_match +-- +TABLE: name="parted_collate_must_match" schema="" table="parted_collate_must_match" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_collate_must_match" +== 253 +-- truncate_limit: 100 +-- check that non-matching collations for partition bound +-- expressions are coerced to the right collation + +create table test_part_coll_posix (a text) partition by range (a collate "POSIX") +-- +TABLE: name="test_part_coll_posix" schema="" table="test_part_coll_posix" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_part_coll_posix (a text) PARTITION BY RANGE (a COLLATE \"POSIX\")" +== 254 +-- truncate_limit: 100 +-- ok, collation is implicitly coerced +create table test_part_coll partition of test_part_coll_posix for values from ('a' collate "C") to ('g') +-- +TABLE: name="test_part_coll" schema="" table="test_part_coll" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_part_coll PARTITION OF test_part_coll_posix FOR VALUES FROM ('a' COLLATE \"C\") T..." +== 255 +-- truncate_limit: 100 +-- ok +create table test_part_coll2 partition of test_part_coll_posix for values from ('g') to ('m') +-- +TABLE: name="test_part_coll2" schema="" table="test_part_coll2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_part_coll2 PARTITION OF test_part_coll_posix FOR VALUES FROM ('g') TO ('m')" +== 256 +-- truncate_limit: 100 +-- ok, collation is implicitly coerced +create table test_part_coll_cast partition of test_part_coll_posix for values from (name 'm' collate "C") to ('s') +-- +TABLE: name="test_part_coll_cast" schema="" table="test_part_coll_cast" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_part_coll_cast PARTITION OF test_part_coll_posix FOR VALUES FROM ('m'::name COL..." +== 257 +-- truncate_limit: 100 +-- ok; partition collation silently overrides the default collation of type 'name' +create table test_part_coll_cast2 partition of test_part_coll_posix for values from (name 's') to ('z') +-- +TABLE: name="test_part_coll_cast2" schema="" table="test_part_coll_cast2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_part_coll_cast2 PARTITION OF test_part_coll_posix FOR VALUES FROM ('s'::name) T..." +== 258 +-- truncate_limit: 100 +drop table test_part_coll_posix +-- +TABLE: name="test_part_coll_posix" schema="" table="test_part_coll_posix" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_part_coll_posix" +== 259 +-- truncate_limit: 100 +-- Partition bound in describe output + +-- Both partition bound and partition key in describe output + +-- a level-2 partition's constraint will include the parent's expressions + +-- Show partition count in the parent's describe output +-- Tempted to include \d+ output listing partitions with bound info but +-- output could vary depending on the order in which partition oids are +-- returned. + +-- check that we get the expected partition constraints +CREATE TABLE range_parted4 (a int, b int, c int) PARTITION BY RANGE (abs(a), abs(b), c) +-- +TABLE: name="range_parted4" schema="" table="range_parted4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted4 (a int, b int, c int) PARTITION BY RANGE ((abs(a)), (abs(b)), c)" +== 260 +-- truncate_limit: 100 +CREATE TABLE unbounded_range_part PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (MAXVALUE, MAXVALUE, MAXVALUE) +-- +TABLE: name="unbounded_range_part" schema="" table="unbounded_range_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unbounded_range_part PARTITION OF range_parted4 FOR VALUES FROM (minvalue, minvalue,..." +== 261 +-- truncate_limit: 100 +DROP TABLE unbounded_range_part +-- +TABLE: name="unbounded_range_part" schema="" table="unbounded_range_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE unbounded_range_part" +== 262 +-- truncate_limit: 100 +CREATE TABLE range_parted4_1 PARTITION OF range_parted4 FOR VALUES FROM (MINVALUE, MINVALUE, MINVALUE) TO (1, MAXVALUE, MAXVALUE) +-- +TABLE: name="range_parted4_1" schema="" table="range_parted4_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted4_1 PARTITION OF range_parted4 FOR VALUES FROM (minvalue, minvalue, minv..." +== 263 +-- truncate_limit: 100 +CREATE TABLE range_parted4_2 PARTITION OF range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, MAXVALUE) +-- +TABLE: name="range_parted4_2" schema="" table="range_parted4_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted4_2 PARTITION OF range_parted4 FOR VALUES FROM (3, 4, 5) TO (6, 7, maxva..." +== 264 +-- truncate_limit: 100 +CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, MINVALUE) TO (9, MAXVALUE, MAXVALUE) +-- +TABLE: name="range_parted4_3" schema="" table="range_parted4_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, minvalue) TO (9, m..." +== 265 +-- truncate_limit: 100 +DROP TABLE range_parted4 +-- +TABLE: name="range_parted4" schema="" table="range_parted4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE range_parted4" +== 266 +-- truncate_limit: 100 +-- user-defined operator class in partition key +CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql + AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$ +-- +FUNCTION: name="my_int4_sort" function="my_int4_sort" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION my_int4_sort(int4, int4) RETURNS int LANGUAGE sql AS $$ SELECT CASE WHEN $1 = $2 ..." +== 267 +-- truncate_limit: 100 +CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS + OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4), + OPERATOR 3 = (int4,int4), OPERATOR 4 >= (int4,int4), + OPERATOR 5 > (int4,int4), FUNCTION 1 my_int4_sort(int4,int4) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS OPERATOR 1 <(int4, int4), OPERAT..." +== 268 +-- truncate_limit: 100 +CREATE TABLE partkey_t (a int4) PARTITION BY RANGE (a test_int4_ops) +-- +TABLE: name="partkey_t" schema="" table="partkey_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partkey_t (a int4) PARTITION BY RANGE (a test_int4_ops)" +== 269 +-- truncate_limit: 100 +CREATE TABLE partkey_t_1 PARTITION OF partkey_t FOR VALUES FROM (0) TO (1000) +-- +TABLE: name="partkey_t_1" schema="" table="partkey_t_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partkey_t_1 PARTITION OF partkey_t FOR VALUES FROM (0) TO (1000)" +== 270 +-- truncate_limit: 100 +INSERT INTO partkey_t VALUES (100) +-- +TABLE: name="partkey_t" schema="" table="partkey_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO partkey_t VALUES (100)" +== 271 +-- truncate_limit: 100 +INSERT INTO partkey_t VALUES (200) +-- +TABLE: name="partkey_t" schema="" table="partkey_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO partkey_t VALUES (200)" +== 272 +-- truncate_limit: 100 +-- cleanup +DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3 +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +TABLE: name="list_parted2" schema="" table="list_parted2" ctx=DDL +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +TABLE: name="range_parted3" schema="" table="range_parted3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted, list_parted, range_parted, list_parted2, range_parted2, range_parted3" +== 273 +-- truncate_limit: 100 +DROP TABLE partkey_t, hash_parted, hash_parted2 +-- +TABLE: name="partkey_t" schema="" table="partkey_t" ctx=DDL +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +TABLE: name="hash_parted2" schema="" table="hash_parted2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE partkey_t, hash_parted, hash_parted2" +== 274 +-- truncate_limit: 100 +DROP OPERATOR CLASS test_int4_ops USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS test_int4_ops USING btree" +== 275 +-- truncate_limit: 100 +DROP FUNCTION my_int4_sort(int4,int4) +-- +FUNCTION: name="my_int4_sort" function="my_int4_sort" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION my_int4_sort(int4, int4)" +== 276 +-- truncate_limit: 100 +-- comments on partitioned tables columns +CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a) +-- +TABLE: name="parted_col_comment" schema="" table="parted_col_comment" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a)" +== 277 +-- truncate_limit: 100 +COMMENT ON TABLE parted_col_comment IS 'Am partitioned table' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TABLE parted_col_comment IS 'Am partitioned table'" +== 278 +-- truncate_limit: 100 +COMMENT ON COLUMN parted_col_comment.a IS 'Partition key' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN parted_col_comment.a IS 'Partition key'" +== 279 +-- truncate_limit: 100 +SELECT obj_description('parted_col_comment'::regclass) +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT obj_description('parted_col_comment'::regclass)" +== 280 +-- truncate_limit: 100 +DROP TABLE parted_col_comment +-- +TABLE: name="parted_col_comment" schema="" table="parted_col_comment" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_col_comment" +== 281 +-- truncate_limit: 100 +-- specifying storage parameters for partitioned tables is not supported +CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a) WITH (fillfactor=100) +-- +TABLE: name="parted_col_comment" schema="" table="parted_col_comment" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a) WITH (fillfactor=100)" +== 282 +-- truncate_limit: 100 +-- list partitioning on array type column +CREATE TABLE arrlp (a int[]) PARTITION BY LIST (a) +-- +TABLE: name="arrlp" schema="" table="arrlp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE arrlp (a int[]) PARTITION BY LIST (a)" +== 283 +-- truncate_limit: 100 +CREATE TABLE arrlp12 PARTITION OF arrlp FOR VALUES IN ('{1}', '{2}') +-- +TABLE: name="arrlp12" schema="" table="arrlp12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE arrlp12 PARTITION OF arrlp FOR VALUES IN ('{1}', '{2}')" +== 284 +-- truncate_limit: 100 +DROP TABLE arrlp +-- +TABLE: name="arrlp" schema="" table="arrlp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE arrlp" +== 285 +-- truncate_limit: 100 +-- partition on boolean column +create table boolspart (a bool) partition by list (a) +-- +TABLE: name="boolspart" schema="" table="boolspart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolspart (a bool) PARTITION BY LIST (a)" +== 286 +-- truncate_limit: 100 +create table boolspart_t partition of boolspart for values in (true) +-- +TABLE: name="boolspart_t" schema="" table="boolspart_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolspart_t PARTITION OF boolspart FOR VALUES IN (true)" +== 287 +-- truncate_limit: 100 +create table boolspart_f partition of boolspart for values in (false) +-- +TABLE: name="boolspart_f" schema="" table="boolspart_f" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolspart_f PARTITION OF boolspart FOR VALUES IN (false)" +== 288 +-- truncate_limit: 100 +drop table boolspart +-- +TABLE: name="boolspart" schema="" table="boolspart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE boolspart" +== 289 +-- truncate_limit: 100 +-- partitions mixing temporary and permanent relations +create table perm_parted (a int) partition by list (a) +-- +TABLE: name="perm_parted" schema="" table="perm_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE perm_parted (a int) PARTITION BY LIST (a)" +== 290 +-- truncate_limit: 100 +create temporary table temp_parted (a int) partition by list (a) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted (a int) PARTITION BY LIST (a)" +== 291 +-- truncate_limit: 100 +create table perm_part partition of temp_parted default +-- +TABLE: name="perm_part" schema="" table="perm_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE perm_part PARTITION OF temp_parted DEFAULT" +== 292 +-- truncate_limit: 100 +-- error +create temp table temp_part partition of perm_parted default +-- +TABLE: name="temp_part" schema="" table="temp_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_part PARTITION OF perm_parted DEFAULT" +== 293 +-- truncate_limit: 100 +-- error +create temp table temp_part partition of temp_parted default +-- +TABLE: name="temp_part" schema="" table="temp_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_part PARTITION OF temp_parted DEFAULT" +== 294 +-- truncate_limit: 100 +-- ok +drop table perm_parted cascade +-- +TABLE: name="perm_parted" schema="" table="perm_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE perm_parted CASCADE" +== 295 +-- truncate_limit: 100 +drop table temp_parted cascade +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_parted CASCADE" +== 296 +-- truncate_limit: 100 +-- check that adding partitions to a table while it is being used is prevented +create table tab_part_create (a int) partition by list (a) +-- +TABLE: name="tab_part_create" schema="" table="tab_part_create" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tab_part_create (a int) PARTITION BY LIST (a)" +== 297 +-- truncate_limit: 100 +create or replace function func_part_create() returns trigger + language plpgsql as $$ + begin + execute 'create table tab_part_create_1 partition of tab_part_create for values in (1)'; + return null; + end $$ +-- +FUNCTION: name="func_part_create" function="func_part_create" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION func_part_create() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n ..." +== 298 +-- truncate_limit: 100 +create trigger trig_part_create before insert on tab_part_create + for each statement execute procedure func_part_create() +-- +TABLE: name="tab_part_create" schema="" table="tab_part_create" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_part_create BEFORE INSERT ON tab_part_create EXECUTE FUNCTION func_part_create()" +== 299 +-- truncate_limit: 100 +insert into tab_part_create values (1) +-- +TABLE: name="tab_part_create" schema="" table="tab_part_create" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tab_part_create VALUES (1)" +== 300 +-- truncate_limit: 100 +drop table tab_part_create +-- +TABLE: name="tab_part_create" schema="" table="tab_part_create" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tab_part_create" +== 301 +-- truncate_limit: 100 +drop function func_part_create() +-- +FUNCTION: name="func_part_create" function="func_part_create" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION func_part_create()" +== 302 +-- truncate_limit: 100 +-- test using a volatile expression as partition bound +create table volatile_partbound_test (partkey timestamp) partition by range (partkey) +-- +TABLE: name="volatile_partbound_test" schema="" table="volatile_partbound_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE volatile_partbound_test (partkey timestamp) PARTITION BY RANGE (partkey)" +== 303 +-- truncate_limit: 100 +create table volatile_partbound_test1 partition of volatile_partbound_test for values from (minvalue) to (current_timestamp) +-- +TABLE: name="volatile_partbound_test1" schema="" table="volatile_partbound_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE volatile_partbound_test1 PARTITION OF volatile_partbound_test FOR VALUES FROM (minva..." +== 304 +-- truncate_limit: 100 +create table volatile_partbound_test2 partition of volatile_partbound_test for values from (current_timestamp) to (maxvalue) +-- +TABLE: name="volatile_partbound_test2" schema="" table="volatile_partbound_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE volatile_partbound_test2 PARTITION OF volatile_partbound_test FOR VALUES FROM (curre..." +== 305 +-- truncate_limit: 100 +-- this should go into the partition volatile_partbound_test2 +insert into volatile_partbound_test values (current_timestamp) +-- +TABLE: name="volatile_partbound_test" schema="" table="volatile_partbound_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO volatile_partbound_test VALUES (current_timestamp)" +== 306 +-- truncate_limit: 100 +select tableoid::regclass from volatile_partbound_test +-- +TABLE: name="volatile_partbound_test" schema="" table="volatile_partbound_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass FROM volatile_partbound_test" +== 307 +-- truncate_limit: 100 +drop table volatile_partbound_test +-- +TABLE: name="volatile_partbound_test" schema="" table="volatile_partbound_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE volatile_partbound_test" +== 308 +-- truncate_limit: 100 +-- test the case where a check constraint on default partition allows +-- to avoid scanning it when adding a new partition +create table defcheck (a int, b int) partition by list (b) +-- +TABLE: name="defcheck" schema="" table="defcheck" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defcheck (a int, b int) PARTITION BY LIST (b)" +== 309 +-- truncate_limit: 100 +create table defcheck_def (a int, c int, b int) +-- +TABLE: name="defcheck_def" schema="" table="defcheck_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defcheck_def (a int, c int, b int)" +== 310 +-- truncate_limit: 100 +alter table defcheck_def drop c +-- +TABLE: name="defcheck_def" schema="" table="defcheck_def" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defcheck_def DROP c" +== 311 +-- truncate_limit: 100 +alter table defcheck attach partition defcheck_def default +-- +TABLE: name="defcheck" schema="" table="defcheck" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defcheck ATTACH PARTITION defcheck_def DEFAULT" +== 312 +-- truncate_limit: 100 +alter table defcheck_def add check (b <= 0 and b is not null) +-- +TABLE: name="defcheck_def" schema="" table="defcheck_def" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defcheck_def ADD CHECK (b <= 0 AND b IS NOT NULL)" +== 313 +-- truncate_limit: 100 +create table defcheck_1 partition of defcheck for values in (1, null) +-- +TABLE: name="defcheck_1" schema="" table="defcheck_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defcheck_1 PARTITION OF defcheck FOR VALUES IN (1, NULL)" +== 314 +-- truncate_limit: 100 +-- test that complex default partition constraints are enforced correctly +insert into defcheck_def values (0, 0) +-- +TABLE: name="defcheck_def" schema="" table="defcheck_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defcheck_def VALUES (0, 0)" +== 315 +-- truncate_limit: 100 +create table defcheck_0 partition of defcheck for values in (0) +-- +TABLE: name="defcheck_0" schema="" table="defcheck_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defcheck_0 PARTITION OF defcheck FOR VALUES IN (0)" +== 316 +-- truncate_limit: 100 +drop table defcheck +-- +TABLE: name="defcheck" schema="" table="defcheck" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE defcheck" +== 317 +-- truncate_limit: 100 +-- tests of column drop with partition tables and indexes using +-- predicates and expressions. +create table part_column_drop ( + useless_1 int, + id int, + useless_2 int, + d int, + b int, + useless_3 int +) partition by range (id) +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_column_drop (useless_1 int, id int, useless_2 int, d int, b int, useless_3 int)..." +== 318 +-- truncate_limit: 100 +alter table part_column_drop drop column useless_1 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_column_drop DROP useless_1" +== 319 +-- truncate_limit: 100 +alter table part_column_drop drop column useless_2 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_column_drop DROP useless_2" +== 320 +-- truncate_limit: 100 +alter table part_column_drop drop column useless_3 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_column_drop DROP useless_3" +== 321 +-- truncate_limit: 100 +create index part_column_drop_b_pred on part_column_drop(b) where b = 1 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX part_column_drop_b_pred ON part_column_drop USING btree (b) WHERE b = 1" +== 322 +-- truncate_limit: 100 +create index part_column_drop_b_expr on part_column_drop((b = 1)) +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX part_column_drop_b_expr ON part_column_drop USING btree ((b = 1))" +== 323 +-- truncate_limit: 100 +create index part_column_drop_d_pred on part_column_drop(d) where d = 2 +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX part_column_drop_d_pred ON part_column_drop USING btree (d) WHERE d = 2" +== 324 +-- truncate_limit: 100 +create index part_column_drop_d_expr on part_column_drop((d = 2)) +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX part_column_drop_d_expr ON part_column_drop USING btree ((d = 2))" +== 325 +-- truncate_limit: 100 +create table part_column_drop_1_10 partition of + part_column_drop for values from (1) to (10) +-- +TABLE: name="part_column_drop_1_10" schema="" table="part_column_drop_1_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_column_drop_1_10 PARTITION OF part_column_drop FOR VALUES FROM (1) TO (10)" +== 326 +-- truncate_limit: 100 +drop table part_column_drop +-- +TABLE: name="part_column_drop" schema="" table="part_column_drop" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_column_drop" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_table_like.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_table_like.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_table_like.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_table_like.test b/parser/testdata/summary_truncate/postgres_regress/create_table_like.test new file mode 100644 index 0000000..db1fa6c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_table_like.test @@ -0,0 +1,1110 @@ +== 001 +-- truncate_limit: 100 +/* Test inheritance of structure (LIKE) */ +CREATE TABLE inhx (xx text DEFAULT 'text') +-- +TABLE: name="inhx" schema="" table="inhx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhx (xx text DEFAULT 'text')" +== 002 +-- truncate_limit: 100 +/* + * Test double inheritance + * + * Ensure that defaults are NOT included unless + * INCLUDING DEFAULTS is specified + */ +CREATE TABLE ctla (aa TEXT) +-- +TABLE: name="ctla" schema="" table="ctla" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctla (aa text)" +== 003 +-- truncate_limit: 100 +CREATE TABLE ctlb (bb TEXT) INHERITS (ctla) +-- +TABLE: name="ctlb" schema="" table="ctlb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlb (bb text) INHERITS (ctla)" +== 004 +-- truncate_limit: 100 +CREATE TABLE foo (LIKE nonexistent) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE foo (LIKE nonexistent)" +== 005 +-- truncate_limit: 100 +CREATE TABLE inhe (ee text, LIKE inhx) inherits (ctlb) +-- +TABLE: name="inhe" schema="" table="inhe" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhe (ee text, LIKE inhx) INHERITS (ctlb)" +== 006 +-- truncate_limit: 100 +INSERT INTO inhe VALUES ('ee-col1', 'ee-col2', DEFAULT, 'ee-col4') +-- +TABLE: name="inhe" schema="" table="inhe" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhe VALUES ('ee-col1', 'ee-col2', DEFAULT, 'ee-col4')" +== 007 +-- truncate_limit: 100 +SELECT * FROM inhe +-- +TABLE: name="inhe" schema="" table="inhe" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inhe" +== 008 +-- truncate_limit: 100 +/* Columns aa, bb, xx value NULL, ee */ +SELECT * FROM inhx +-- +TABLE: name="inhx" schema="" table="inhx" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inhx" +== 009 +-- truncate_limit: 100 +/* Empty set since LIKE inherits structure only */ +SELECT * FROM ctlb +-- +TABLE: name="ctlb" schema="" table="ctlb" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ctlb" +== 010 +-- truncate_limit: 100 +/* Has ee entry */ +SELECT * FROM ctla +-- +TABLE: name="ctla" schema="" table="ctla" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ctla" +== 011 +-- truncate_limit: 100 +/* Has ee entry */ + +CREATE TABLE inhf (LIKE inhx, LIKE inhx) +-- +TABLE: name="inhf" schema="" table="inhf" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhf (LIKE inhx, LIKE inhx)" +== 012 +-- truncate_limit: 100 +/* Throw error */ + +CREATE TABLE inhf (LIKE inhx INCLUDING DEFAULTS INCLUDING CONSTRAINTS) +-- +TABLE: name="inhf" schema="" table="inhf" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhf (LIKE inhx INCLUDING CONSTRAINTS INCLUDING DEFAULTS)" +== 013 +-- truncate_limit: 100 +INSERT INTO inhf DEFAULT VALUES +-- +TABLE: name="inhf" schema="" table="inhf" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO inhf DEFAULT VALUES" +== 014 +-- truncate_limit: 100 +SELECT * FROM inhf +-- +TABLE: name="inhf" schema="" table="inhf" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inhf" +== 015 +-- truncate_limit: 100 +/* Single entry with value 'text' */ + +ALTER TABLE inhx add constraint foo CHECK (xx = 'text') +-- +TABLE: name="inhx" schema="" table="inhx" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inhx ADD CONSTRAINT foo CHECK (xx = 'text')" +== 016 +-- truncate_limit: 100 +ALTER TABLE inhx ADD PRIMARY KEY (xx) +-- +TABLE: name="inhx" schema="" table="inhx" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inhx ADD PRIMARY KEY (xx)" +== 017 +-- truncate_limit: 100 +CREATE TABLE inhg (LIKE inhx) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhg (LIKE inhx)" +== 018 +-- truncate_limit: 100 +/* Doesn't copy constraint */ +INSERT INTO inhg VALUES ('foo') +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg VALUES ('foo')" +== 019 +-- truncate_limit: 100 +DROP TABLE inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhg" +== 020 +-- truncate_limit: 100 +CREATE TABLE inhg (x text, LIKE inhx INCLUDING CONSTRAINTS, y text) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhg (x text, LIKE inhx INCLUDING CONSTRAINTS, y text)" +== 021 +-- truncate_limit: 100 +/* Copies constraints */ +INSERT INTO inhg VALUES ('x', 'text', 'y') +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg VALUES ('x', 'text', 'y')" +== 022 +-- truncate_limit: 100 +/* Succeeds */ +INSERT INTO inhg VALUES ('x', 'text', 'y') +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg VALUES ('x', 'text', 'y')" +== 023 +-- truncate_limit: 100 +/* Succeeds -- Unique constraints not copied */ +INSERT INTO inhg VALUES ('x', 'foo', 'y') +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg VALUES ('x', 'foo', 'y')" +== 024 +-- truncate_limit: 100 +/* fails due to constraint */ +SELECT * FROM inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inhg" +== 025 +-- truncate_limit: 100 +/* Two records with three columns in order x=x, xx=text, y=y */ +DROP TABLE inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhg" +== 026 +-- truncate_limit: 100 +CREATE TABLE test_like_id_1 (a bigint GENERATED ALWAYS AS IDENTITY, b text) +-- +TABLE: name="test_like_id_1" schema="" table="test_like_id_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_id_1 (a bigint GENERATED ALWAYS AS IDENTITY, b text)" +== 027 +-- truncate_limit: 100 +INSERT INTO test_like_id_1 (b) VALUES ('b1') +-- +TABLE: name="test_like_id_1" schema="" table="test_like_id_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_id_1 (b) VALUES ('b1')" +== 028 +-- truncate_limit: 100 +SELECT * FROM test_like_id_1 +-- +TABLE: name="test_like_id_1" schema="" table="test_like_id_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_like_id_1" +== 029 +-- truncate_limit: 100 +CREATE TABLE test_like_id_2 (LIKE test_like_id_1) +-- +TABLE: name="test_like_id_2" schema="" table="test_like_id_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_id_2 (LIKE test_like_id_1)" +== 030 +-- truncate_limit: 100 +INSERT INTO test_like_id_2 (b) VALUES ('b2') +-- +TABLE: name="test_like_id_2" schema="" table="test_like_id_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_id_2 (b) VALUES ('b2')" +== 031 +-- truncate_limit: 100 +SELECT * FROM test_like_id_2 +-- +TABLE: name="test_like_id_2" schema="" table="test_like_id_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_like_id_2" +== 032 +-- truncate_limit: 100 +-- identity was not copied +CREATE TABLE test_like_id_3 (LIKE test_like_id_1 INCLUDING IDENTITY) +-- +TABLE: name="test_like_id_3" schema="" table="test_like_id_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_id_3 (LIKE test_like_id_1 INCLUDING IDENTITY)" +== 033 +-- truncate_limit: 100 +INSERT INTO test_like_id_3 (b) VALUES ('b3') +-- +TABLE: name="test_like_id_3" schema="" table="test_like_id_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_id_3 (b) VALUES ('b3')" +== 034 +-- truncate_limit: 100 +SELECT * FROM test_like_id_3 +-- +TABLE: name="test_like_id_3" schema="" table="test_like_id_3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_like_id_3" +== 035 +-- truncate_limit: 100 +-- identity was copied and applied +DROP TABLE test_like_id_1, test_like_id_2, test_like_id_3 +-- +TABLE: name="test_like_id_1" schema="" table="test_like_id_1" ctx=DDL +TABLE: name="test_like_id_2" schema="" table="test_like_id_2" ctx=DDL +TABLE: name="test_like_id_3" schema="" table="test_like_id_3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_like_id_1, test_like_id_2, test_like_id_3" +== 036 +-- truncate_limit: 100 +CREATE TABLE test_like_gen_1 (a int, b int GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="test_like_gen_1" schema="" table="test_like_gen_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_gen_1 (a int, b int GENERATED ALWAYS AS (a * 2) STORED)" +== 037 +-- truncate_limit: 100 +INSERT INTO test_like_gen_1 (a) VALUES (1) +-- +TABLE: name="test_like_gen_1" schema="" table="test_like_gen_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_gen_1 (a) VALUES (1)" +== 038 +-- truncate_limit: 100 +SELECT * FROM test_like_gen_1 +-- +TABLE: name="test_like_gen_1" schema="" table="test_like_gen_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_like_gen_1" +== 039 +-- truncate_limit: 100 +CREATE TABLE test_like_gen_2 (LIKE test_like_gen_1) +-- +TABLE: name="test_like_gen_2" schema="" table="test_like_gen_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_gen_2 (LIKE test_like_gen_1)" +== 040 +-- truncate_limit: 100 +INSERT INTO test_like_gen_2 (a) VALUES (1) +-- +TABLE: name="test_like_gen_2" schema="" table="test_like_gen_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_gen_2 (a) VALUES (1)" +== 041 +-- truncate_limit: 100 +SELECT * FROM test_like_gen_2 +-- +TABLE: name="test_like_gen_2" schema="" table="test_like_gen_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_like_gen_2" +== 042 +-- truncate_limit: 100 +CREATE TABLE test_like_gen_3 (LIKE test_like_gen_1 INCLUDING GENERATED) +-- +TABLE: name="test_like_gen_3" schema="" table="test_like_gen_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_gen_3 (LIKE test_like_gen_1 INCLUDING GENERATED)" +== 043 +-- truncate_limit: 100 +INSERT INTO test_like_gen_3 (a) VALUES (1) +-- +TABLE: name="test_like_gen_3" schema="" table="test_like_gen_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_gen_3 (a) VALUES (1)" +== 044 +-- truncate_limit: 100 +SELECT * FROM test_like_gen_3 +-- +TABLE: name="test_like_gen_3" schema="" table="test_like_gen_3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_like_gen_3" +== 045 +-- truncate_limit: 100 +DROP TABLE test_like_gen_1, test_like_gen_2, test_like_gen_3 +-- +TABLE: name="test_like_gen_1" schema="" table="test_like_gen_1" ctx=DDL +TABLE: name="test_like_gen_2" schema="" table="test_like_gen_2" ctx=DDL +TABLE: name="test_like_gen_3" schema="" table="test_like_gen_3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_like_gen_1, test_like_gen_2, test_like_gen_3" +== 046 +-- truncate_limit: 100 +-- also test generated column with a "forward" reference (bug #16342) +CREATE TABLE test_like_4 (b int DEFAULT 42, + c int GENERATED ALWAYS AS (a * 2) STORED, + a int CHECK (a > 0)) +-- +TABLE: name="test_like_4" schema="" table="test_like_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_4 (b int DEFAULT 42, c int GENERATED ALWAYS AS (a * 2) STORED, a int CHECK..." +== 047 +-- truncate_limit: 100 +CREATE TABLE test_like_4a (LIKE test_like_4) +-- +TABLE: name="test_like_4a" schema="" table="test_like_4a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_4a (LIKE test_like_4)" +== 048 +-- truncate_limit: 100 +CREATE TABLE test_like_4b (LIKE test_like_4 INCLUDING DEFAULTS) +-- +TABLE: name="test_like_4b" schema="" table="test_like_4b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_4b (LIKE test_like_4 INCLUDING DEFAULTS)" +== 049 +-- truncate_limit: 100 +CREATE TABLE test_like_4c (LIKE test_like_4 INCLUDING GENERATED) +-- +TABLE: name="test_like_4c" schema="" table="test_like_4c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_4c (LIKE test_like_4 INCLUDING GENERATED)" +== 050 +-- truncate_limit: 100 +CREATE TABLE test_like_4d (LIKE test_like_4 INCLUDING DEFAULTS INCLUDING GENERATED) +-- +TABLE: name="test_like_4d" schema="" table="test_like_4d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_4d (LIKE test_like_4 INCLUDING DEFAULTS INCLUDING GENERATED)" +== 051 +-- truncate_limit: 100 +INSERT INTO test_like_4a (a) VALUES(11) +-- +TABLE: name="test_like_4a" schema="" table="test_like_4a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_4a (a) VALUES (11)" +== 052 +-- truncate_limit: 100 +SELECT a, b, c FROM test_like_4a +-- +TABLE: name="test_like_4a" schema="" table="test_like_4a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c FROM test_like_4a" +== 053 +-- truncate_limit: 100 +INSERT INTO test_like_4b (a) VALUES(11) +-- +TABLE: name="test_like_4b" schema="" table="test_like_4b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_4b (a) VALUES (11)" +== 054 +-- truncate_limit: 100 +SELECT a, b, c FROM test_like_4b +-- +TABLE: name="test_like_4b" schema="" table="test_like_4b" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c FROM test_like_4b" +== 055 +-- truncate_limit: 100 +INSERT INTO test_like_4c (a) VALUES(11) +-- +TABLE: name="test_like_4c" schema="" table="test_like_4c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_4c (a) VALUES (11)" +== 056 +-- truncate_limit: 100 +SELECT a, b, c FROM test_like_4c +-- +TABLE: name="test_like_4c" schema="" table="test_like_4c" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c FROM test_like_4c" +== 057 +-- truncate_limit: 100 +INSERT INTO test_like_4d (a) VALUES(11) +-- +TABLE: name="test_like_4d" schema="" table="test_like_4d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_like_4d (a) VALUES (11)" +== 058 +-- truncate_limit: 100 +SELECT a, b, c FROM test_like_4d +-- +TABLE: name="test_like_4d" schema="" table="test_like_4d" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c FROM test_like_4d" +== 059 +-- truncate_limit: 100 +-- Test renumbering of Vars when combining LIKE with inheritance +CREATE TABLE test_like_5 (x point, y point, z point) +-- +TABLE: name="test_like_5" schema="" table="test_like_5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_5 (x point, y point, z point)" +== 060 +-- truncate_limit: 100 +CREATE TABLE test_like_5x (p int CHECK (p > 0), + q int GENERATED ALWAYS AS (p * 2) STORED) +-- +TABLE: name="test_like_5x" schema="" table="test_like_5x" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_5x (p int CHECK (p > 0), q int GENERATED ALWAYS AS (p * 2) STORED)" +== 061 +-- truncate_limit: 100 +CREATE TABLE test_like_5c (LIKE test_like_4 INCLUDING ALL) + INHERITS (test_like_5, test_like_5x) +-- +TABLE: name="test_like_5c" schema="" table="test_like_5c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_5c (LIKE test_like_4 INCLUDING ALL) INHERITS (test_like_5, test_like_5x)" +== 062 +-- truncate_limit: 100 +-- Test updating of column numbers in statistics expressions (bug #18468) +CREATE TABLE test_like_6 (a int, c text, b text) +-- +TABLE: name="test_like_6" schema="" table="test_like_6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_6 (a int, c text, b text)" +== 063 +-- truncate_limit: 100 +CREATE STATISTICS ext_stat ON (a || b) FROM test_like_6 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ext_stat ON (a || b) FROM test_like_6" +== 064 +-- truncate_limit: 100 +ALTER TABLE test_like_6 DROP COLUMN c +-- +TABLE: name="test_like_6" schema="" table="test_like_6" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_like_6 DROP c" +== 065 +-- truncate_limit: 100 +CREATE TABLE test_like_6c (LIKE test_like_6 INCLUDING ALL) +-- +TABLE: name="test_like_6c" schema="" table="test_like_6c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_like_6c (LIKE test_like_6 INCLUDING ALL)" +== 066 +-- truncate_limit: 100 +DROP TABLE test_like_4, test_like_4a, test_like_4b, test_like_4c, test_like_4d +-- +TABLE: name="test_like_4" schema="" table="test_like_4" ctx=DDL +TABLE: name="test_like_4a" schema="" table="test_like_4a" ctx=DDL +TABLE: name="test_like_4b" schema="" table="test_like_4b" ctx=DDL +TABLE: name="test_like_4c" schema="" table="test_like_4c" ctx=DDL +TABLE: name="test_like_4d" schema="" table="test_like_4d" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_like_4, test_like_4a, test_like_4b, test_like_4c, test_like_4d" +== 067 +-- truncate_limit: 100 +DROP TABLE test_like_5, test_like_5x, test_like_5c +-- +TABLE: name="test_like_5" schema="" table="test_like_5" ctx=DDL +TABLE: name="test_like_5x" schema="" table="test_like_5x" ctx=DDL +TABLE: name="test_like_5c" schema="" table="test_like_5c" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_like_5, test_like_5x, test_like_5c" +== 068 +-- truncate_limit: 100 +DROP TABLE test_like_6, test_like_6c +-- +TABLE: name="test_like_6" schema="" table="test_like_6" ctx=DDL +TABLE: name="test_like_6c" schema="" table="test_like_6c" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_like_6, test_like_6c" +== 069 +-- truncate_limit: 100 +CREATE TABLE inhg (x text, LIKE inhx INCLUDING INDEXES, y text) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhg (x text, LIKE inhx INCLUDING INDEXES, y text)" +== 070 +-- truncate_limit: 100 +/* copies indexes */ +INSERT INTO inhg VALUES (5, 10) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg VALUES (5, 10)" +== 071 +-- truncate_limit: 100 +INSERT INTO inhg VALUES (20, 10) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg VALUES (20, 10)" +== 072 +-- truncate_limit: 100 +-- should fail +DROP TABLE inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhg" +== 073 +-- truncate_limit: 100 +/* Multiple primary keys creation should fail */ +CREATE TABLE inhg (x text, LIKE inhx INCLUDING INDEXES, PRIMARY KEY(x)) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhg (x text, LIKE inhx INCLUDING INDEXES, PRIMARY KEY (x))" +== 074 +-- truncate_limit: 100 +/* fails */ +CREATE TABLE inhz (xx text DEFAULT 'text', yy int UNIQUE) +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhz (xx text DEFAULT 'text', yy int UNIQUE)" +== 075 +-- truncate_limit: 100 +CREATE UNIQUE INDEX inhz_xx_idx on inhz (xx) WHERE xx <> 'test' +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX inhz_xx_idx ON inhz USING btree (xx) WHERE xx <> 'test'" +== 076 +-- truncate_limit: 100 +/* Ok to create multiple unique indexes */ +CREATE TABLE inhg (x text UNIQUE, LIKE inhz INCLUDING INDEXES) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhg (x text UNIQUE, LIKE inhz INCLUDING INDEXES)" +== 077 +-- truncate_limit: 100 +INSERT INTO inhg (xx, yy, x) VALUES ('test', 5, 10) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg (xx, yy, x) VALUES ('test', 5, 10)" +== 078 +-- truncate_limit: 100 +INSERT INTO inhg (xx, yy, x) VALUES ('test', 10, 15) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg (xx, yy, x) VALUES ('test', 10, 15)" +== 079 +-- truncate_limit: 100 +INSERT INTO inhg (xx, yy, x) VALUES ('foo', 10, 15) +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhg (xx, yy, x) VALUES ('foo', 10, 15)" +== 080 +-- truncate_limit: 100 +-- should fail +DROP TABLE inhg +-- +TABLE: name="inhg" schema="" table="inhg" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhg" +== 081 +-- truncate_limit: 100 +DROP TABLE inhz +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhz" +== 082 +-- truncate_limit: 100 +/* Use primary key imported by LIKE for self-referential FK constraint */ +CREATE TABLE inhz (x text REFERENCES inhz, LIKE inhx INCLUDING INDEXES) +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhz (x text REFERENCES inhz, LIKE inhx INCLUDING INDEXES)" +== 083 +-- truncate_limit: 100 +DROP TABLE inhz +-- +TABLE: name="inhz" schema="" table="inhz" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhz" +== 084 +-- truncate_limit: 100 +-- including storage and comments +CREATE TABLE ctlt1 (a text CHECK (length(a) > 2) PRIMARY KEY, b text) +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt1 (a text CHECK (length(a) > 2) PRIMARY KEY, b text)" +== 085 +-- truncate_limit: 100 +CREATE INDEX ctlt1_b_key ON ctlt1 (b) +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ctlt1_b_key ON ctlt1 USING btree (b)" +== 086 +-- truncate_limit: 100 +CREATE INDEX ctlt1_fnidx ON ctlt1 ((a || b)) +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ctlt1_fnidx ON ctlt1 USING btree ((a || b))" +== 087 +-- truncate_limit: 100 +CREATE STATISTICS ctlt1_a_b_stat ON a,b FROM ctlt1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ctlt1_a_b_stat ON a, b FROM ctlt1" +== 088 +-- truncate_limit: 100 +CREATE STATISTICS ctlt1_expr_stat ON (a || b) FROM ctlt1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ctlt1_expr_stat ON (a || b) FROM ctlt1" +== 089 +-- truncate_limit: 100 +COMMENT ON STATISTICS ctlt1_a_b_stat IS 'ab stats' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON STATISTICS ctlt1_a_b_stat IS 'ab stats'" +== 090 +-- truncate_limit: 100 +COMMENT ON STATISTICS ctlt1_expr_stat IS 'ab expr stats' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON STATISTICS ctlt1_expr_stat IS 'ab expr stats'" +== 091 +-- truncate_limit: 100 +COMMENT ON COLUMN ctlt1.a IS 'A' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN ctlt1.a IS 'A'" +== 092 +-- truncate_limit: 100 +COMMENT ON COLUMN ctlt1.b IS 'B' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN ctlt1.b IS 'B'" +== 093 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT ctlt1_a_check ON ctlt1 IS 't1_a_check' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT ctlt1_a_check ON ctlt1 IS 't1_a_check'" +== 094 +-- truncate_limit: 100 +COMMENT ON INDEX ctlt1_pkey IS 'index pkey' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX ctlt1_pkey IS 'index pkey'" +== 095 +-- truncate_limit: 100 +COMMENT ON INDEX ctlt1_b_key IS 'index b_key' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON INDEX ctlt1_b_key IS 'index b_key'" +== 096 +-- truncate_limit: 100 +ALTER TABLE ctlt1 ALTER COLUMN a SET STORAGE MAIN +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ctlt1 ALTER COLUMN a SET STORAGE main" +== 097 +-- truncate_limit: 100 +CREATE TABLE ctlt2 (c text) +-- +TABLE: name="ctlt2" schema="" table="ctlt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt2 (c text)" +== 098 +-- truncate_limit: 100 +ALTER TABLE ctlt2 ALTER COLUMN c SET STORAGE EXTERNAL +-- +TABLE: name="ctlt2" schema="" table="ctlt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ctlt2 ALTER COLUMN c SET STORAGE external" +== 099 +-- truncate_limit: 100 +COMMENT ON COLUMN ctlt2.c IS 'C' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN ctlt2.c IS 'C'" +== 100 +-- truncate_limit: 100 +CREATE TABLE ctlt3 (a text CHECK (length(a) < 5), c text CHECK (length(c) < 7)) +-- +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt3 (a text CHECK (length(a) < 5), c text CHECK (length(c) < 7))" +== 101 +-- truncate_limit: 100 +ALTER TABLE ctlt3 ALTER COLUMN c SET STORAGE EXTERNAL +-- +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ctlt3 ALTER COLUMN c SET STORAGE external" +== 102 +-- truncate_limit: 100 +ALTER TABLE ctlt3 ALTER COLUMN a SET STORAGE MAIN +-- +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ctlt3 ALTER COLUMN a SET STORAGE main" +== 103 +-- truncate_limit: 100 +CREATE INDEX ctlt3_fnidx ON ctlt3 ((a || c)) +-- +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ctlt3_fnidx ON ctlt3 USING btree ((a || c))" +== 104 +-- truncate_limit: 100 +COMMENT ON COLUMN ctlt3.a IS 'A3' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN ctlt3.a IS 'A3'" +== 105 +-- truncate_limit: 100 +COMMENT ON COLUMN ctlt3.c IS 'C' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN ctlt3.c IS 'C'" +== 106 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT ctlt3_a_check ON ctlt3 IS 't3_a_check' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT ctlt3_a_check ON ctlt3 IS 't3_a_check'" +== 107 +-- truncate_limit: 100 +CREATE TABLE ctlt4 (a text, c text) +-- +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt4 (a text, c text)" +== 108 +-- truncate_limit: 100 +ALTER TABLE ctlt4 ALTER COLUMN c SET STORAGE EXTERNAL +-- +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ctlt4 ALTER COLUMN c SET STORAGE external" +== 109 +-- truncate_limit: 100 +CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING STORAGE) +-- +TABLE: name="ctlt12_storage" schema="" table="ctlt12_storage" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING STORAGE)" +== 110 +-- truncate_limit: 100 +CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS) +-- +TABLE: name="ctlt12_comments" schema="" table="ctlt12_comments" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt12_comments (LIKE ctlt1 INCLUDING COMMENTS, LIKE ctlt2 INCLUDING COMMENTS)" +== 111 +-- truncate_limit: 100 +CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING COMMENTS) INHERITS (ctlt1) +-- +TABLE: name="ctlt1_inh" schema="" table="ctlt1_inh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING COMMENTS INCLUDING CONSTRAINTS) INHERITS (ctlt1)" +== 112 +-- truncate_limit: 100 +SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt1_inh'::regclass +-- +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "c"="pg_constraint" +FILTER: schema="" table="" column="classoid" +FILTER: schema="" table="" column="objoid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="c" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT description FROM pg_description, pg_constraint c WHERE ..." +== 113 +-- truncate_limit: 100 +CREATE TABLE ctlt13_inh () INHERITS (ctlt1, ctlt3) +-- +TABLE: name="ctlt13_inh" schema="" table="ctlt13_inh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt13_inh () INHERITS (ctlt1, ctlt3)" +== 114 +-- truncate_limit: 100 +CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING INDEXES INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1) +-- +TABLE: name="ctlt13_like" schema="" table="ctlt13_like" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING COMMENTS INCLUDING CONSTRAINTS INCLUDING INDEXES I..." +== 115 +-- truncate_limit: 100 +SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid AND c.conrelid = 'ctlt13_like'::regclass +-- +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "c"="pg_constraint" +FILTER: schema="" table="" column="classoid" +FILTER: schema="" table="" column="objoid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="c" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT description FROM pg_description, pg_constraint c WHERE ..." +== 116 +-- truncate_limit: 100 +CREATE TABLE ctlt_all (LIKE ctlt1 INCLUDING ALL) +-- +TABLE: name="ctlt_all" schema="" table="ctlt_all" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt_all (LIKE ctlt1 INCLUDING ALL)" +== 117 +-- truncate_limit: 100 +SELECT c.relname, objsubid, description FROM pg_description, pg_index i, pg_class c WHERE classoid = 'pg_class'::regclass AND objoid = i.indexrelid AND c.oid = i.indexrelid AND i.indrelid = 'ctlt_all'::regclass ORDER BY c.relname, objsubid +-- +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FILTER: schema="" table="" column="classoid" +FILTER: schema="" table="" column="objoid" +FILTER: schema="" table="i" column="indexrelid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="i" column="indexrelid" +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_description, pg_index i, pg_class c WHERE ... ORDER BY c.relname, objsubid" +== 118 +-- truncate_limit: 100 +SELECT s.stxname, objsubid, description FROM pg_description, pg_statistic_ext s WHERE classoid = 'pg_statistic_ext'::regclass AND objoid = s.oid AND s.stxrelid = 'ctlt_all'::regclass ORDER BY s.stxname, objsubid +-- +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="" column="classoid" +FILTER: schema="" table="" column="objoid" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="stxrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_description, pg_statistic_ext s WHERE ... ORDER BY s.stxname, objsubid" +== 119 +-- truncate_limit: 100 +CREATE TABLE inh_error1 () INHERITS (ctlt1, ctlt4) +-- +TABLE: name="inh_error1" schema="" table="inh_error1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_error1 () INHERITS (ctlt1, ctlt4)" +== 120 +-- truncate_limit: 100 +CREATE TABLE inh_error2 (LIKE ctlt4 INCLUDING STORAGE) INHERITS (ctlt1) +-- +TABLE: name="inh_error2" schema="" table="inh_error2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_error2 (LIKE ctlt4 INCLUDING STORAGE) INHERITS (ctlt1)" +== 121 +-- truncate_limit: 100 +-- Check that LIKE isn't confused by a system catalog of the same name +CREATE TABLE pg_attrdef (LIKE ctlt1 INCLUDING ALL) +-- +TABLE: name="pg_attrdef" schema="" table="pg_attrdef" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pg_attrdef (LIKE ctlt1 INCLUDING ALL)" +== 122 +-- truncate_limit: 100 +DROP TABLE public.pg_attrdef +-- +TABLE: name="public.pg_attrdef" schema="public" table="pg_attrdef" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE public.pg_attrdef" +== 123 +-- truncate_limit: 100 +-- Check that LIKE isn't confused when new table masks the old, either +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 124 +-- truncate_limit: 100 +CREATE SCHEMA ctl_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA ctl_schema" +== 125 +-- truncate_limit: 100 +SET LOCAL search_path = ctl_schema, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL search_path TO ctl_schema, public" +== 126 +-- truncate_limit: 100 +CREATE TABLE ctlt1 (LIKE ctlt1 INCLUDING ALL) +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt1 (LIKE ctlt1 INCLUDING ALL)" +== 127 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 128 +-- truncate_limit: 100 +DROP TABLE ctlt1, ctlt2, ctlt3, ctlt4, ctlt12_storage, ctlt12_comments, ctlt1_inh, ctlt13_inh, ctlt13_like, ctlt_all, ctla, ctlb CASCADE +-- +TABLE: name="ctlt1" schema="" table="ctlt1" ctx=DDL +TABLE: name="ctlt2" schema="" table="ctlt2" ctx=DDL +TABLE: name="ctlt3" schema="" table="ctlt3" ctx=DDL +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +TABLE: name="ctlt12_storage" schema="" table="ctlt12_storage" ctx=DDL +TABLE: name="ctlt12_comments" schema="" table="ctlt12_comments" ctx=DDL +TABLE: name="ctlt1_inh" schema="" table="ctlt1_inh" ctx=DDL +TABLE: name="ctlt13_inh" schema="" table="ctlt13_inh" ctx=DDL +TABLE: name="ctlt13_like" schema="" table="ctlt13_like" ctx=DDL +TABLE: name="ctlt_all" schema="" table="ctlt_all" ctx=DDL +TABLE: name="ctla" schema="" table="ctla" ctx=DDL +TABLE: name="ctlb" schema="" table="ctlb" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ctlt1, ctlt2, ctlt3, ctlt4, ctlt12_storage, ctlt12_comments, ctlt1_inh, ctlt13_inh, ct..." +== 129 +-- truncate_limit: 100 +-- LIKE must respect NO INHERIT property of constraints +CREATE TABLE noinh_con_copy (a int CHECK (a > 0) NO INHERIT) +-- +TABLE: name="noinh_con_copy" schema="" table="noinh_con_copy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE noinh_con_copy (a int CHECK (a > 0) NO INHERIT)" +== 130 +-- truncate_limit: 100 +CREATE TABLE noinh_con_copy1 (LIKE noinh_con_copy INCLUDING CONSTRAINTS) +-- +TABLE: name="noinh_con_copy1" schema="" table="noinh_con_copy1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE noinh_con_copy1 (LIKE noinh_con_copy INCLUDING CONSTRAINTS)" +== 131 +-- truncate_limit: 100 +-- fail, as partitioned tables don't allow NO INHERIT constraints +CREATE TABLE noinh_con_copy1_parted (LIKE noinh_con_copy INCLUDING ALL) + PARTITION BY LIST (a) +-- +TABLE: name="noinh_con_copy1_parted" schema="" table="noinh_con_copy1_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE noinh_con_copy1_parted (LIKE noinh_con_copy INCLUDING ALL) PARTITION BY LIST (a)" +== 132 +-- truncate_limit: 100 +DROP TABLE noinh_con_copy, noinh_con_copy1 +-- +TABLE: name="noinh_con_copy" schema="" table="noinh_con_copy" ctx=DDL +TABLE: name="noinh_con_copy1" schema="" table="noinh_con_copy1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE noinh_con_copy, noinh_con_copy1" +== 133 +-- truncate_limit: 100 +/* LIKE with other relation kinds */ + +CREATE TABLE ctlt4 (a int, b text) +-- +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt4 (a int, b text)" +== 134 +-- truncate_limit: 100 +CREATE SEQUENCE ctlseq1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE ctlseq1" +== 135 +-- truncate_limit: 100 +CREATE TABLE ctlt10 (LIKE ctlseq1) +-- +TABLE: name="ctlt10" schema="" table="ctlt10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt10 (LIKE ctlseq1)" +== 136 +-- truncate_limit: 100 +-- fail + +CREATE VIEW ctlv1 AS SELECT * FROM ctlt4 +-- +TABLE: name="ctlv1" schema="" table="ctlv1" ctx=DDL +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ctlv1 AS SELECT * FROM ctlt4" +== 137 +-- truncate_limit: 100 +CREATE TABLE ctlt11 (LIKE ctlv1) +-- +TABLE: name="ctlt11" schema="" table="ctlt11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt11 (LIKE ctlv1)" +== 138 +-- truncate_limit: 100 +CREATE TABLE ctlt11a (LIKE ctlv1 INCLUDING ALL) +-- +TABLE: name="ctlt11a" schema="" table="ctlt11a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt11a (LIKE ctlv1 INCLUDING ALL)" +== 139 +-- truncate_limit: 100 +CREATE TYPE ctlty1 AS (a int, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE ctlty1 AS (a int, b text)" +== 140 +-- truncate_limit: 100 +CREATE TABLE ctlt12 (LIKE ctlty1) +-- +TABLE: name="ctlt12" schema="" table="ctlt12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctlt12 (LIKE ctlty1)" +== 141 +-- truncate_limit: 100 +DROP SEQUENCE ctlseq1 +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE ctlseq1" +== 142 +-- truncate_limit: 100 +DROP TYPE ctlty1 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE ctlty1" +== 143 +-- truncate_limit: 100 +DROP VIEW ctlv1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW ctlv1" +== 144 +-- truncate_limit: 100 +DROP TABLE IF EXISTS ctlt4, ctlt10, ctlt11, ctlt11a, ctlt12 +-- +TABLE: name="ctlt4" schema="" table="ctlt4" ctx=DDL +TABLE: name="ctlt10" schema="" table="ctlt10" ctx=DDL +TABLE: name="ctlt11" schema="" table="ctlt11" ctx=DDL +TABLE: name="ctlt11a" schema="" table="ctlt11a" ctx=DDL +TABLE: name="ctlt12" schema="" table="ctlt12" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE IF EXISTS ctlt4, ctlt10, ctlt11, ctlt11a, ctlt12" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_type.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_type.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_type.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_type.test b/parser/testdata/summary_truncate/postgres_regress/create_type.test new file mode 100644 index 0000000..bbba180 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_type.test @@ -0,0 +1,743 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_TYPE +|-- + +-- directory path and dlsuffix are passed to us in environment variables + + +|-- +-- Test the "old style" approach of making the I/O functions first, +-- with no explicit shell type creation. +|-- +CREATE FUNCTION widget_in(cstring) + RETURNS widget + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 272 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +CREATE FUNCTION widget_out(widget) + RETURNS cstring + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 61 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +-- truncate_limit: 100 +CREATE FUNCTION int44in(cstring) + RETURNS city_budget + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +CREATE FUNCTION int44out(city_budget) + RETURNS cstring + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 64 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- truncate_limit: 100 +CREATE TYPE widget ( + internallength = 24, + input = widget_in, + output = widget_out, + typmod_in = numerictypmodin, + typmod_out = numerictypmodout, + alignment = double +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE widget (internallength = 24, input = widget_in, output = widget_out, typmod_in = nume..." +== 006 +-- truncate_limit: 100 +CREATE TYPE city_budget ( + internallength = 16, + input = int44in, + output = int44out, + element = int4, + category = 'x', -- just to verify the system will take it + preferred = true -- ditto +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE city_budget (internallength = 16, input = int44in, output = int44out, element = int4,..." +== 007 +-- truncate_limit: 100 +-- Test creation and destruction of shell types +CREATE TYPE shell +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE shell" +== 008 +-- truncate_limit: 100 +CREATE TYPE shell +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE shell" +== 009 +-- truncate_limit: 100 +-- fail, type already present +DROP TYPE shell +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE shell" +== 010 +-- truncate_limit: 100 +DROP TYPE shell +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE shell" +== 011 +-- truncate_limit: 100 +-- fail, type not exist + +-- also, let's leave one around for purposes of pg_dump testing +CREATE TYPE myshell +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE myshell" +== 012 +-- truncate_limit: 100 +|-- +-- Test type-related default values (broken in releases before PG 7.2) +|-- +-- This part of the test also exercises the "new style" approach of making +-- a shell type and then filling it in. +|-- +CREATE TYPE int42 +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE int42" +== 013 +-- truncate_limit: 100 +CREATE TYPE text_w_default +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE text_w_default" +== 014 +-- truncate_limit: 100 +-- Make dummy I/O routines using the existing internal support for int4, text +CREATE FUNCTION int42_in(cstring) + RETURNS int42 + AS 'int4in' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="int42_in" function="int42_in" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int42_in(cstring) RETURNS int42 AS $$int4in$$ LANGUAGE internal RETURNS NULL ON N..." +== 015 +-- truncate_limit: 100 +CREATE FUNCTION int42_out(int42) + RETURNS cstring + AS 'int4out' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="int42_out" function="int42_out" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int42_out(int42) RETURNS cstring AS $$int4out$$ LANGUAGE internal RETURNS NULL ON..." +== 016 +-- truncate_limit: 100 +CREATE FUNCTION text_w_default_in(cstring) + RETURNS text_w_default + AS 'textin' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="text_w_default_in" function="text_w_default_in" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION text_w_default_in(cstring) RETURNS text_w_default AS $$textin$$ LANGUAGE internal..." +== 017 +-- truncate_limit: 100 +CREATE FUNCTION text_w_default_out(text_w_default) + RETURNS cstring + AS 'textout' + LANGUAGE internal STRICT IMMUTABLE +-- +FUNCTION: name="text_w_default_out" function="text_w_default_out" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION text_w_default_out(text_w_default) RETURNS cstring AS $$textout$$ LANGUAGE intern..." +== 018 +-- truncate_limit: 100 +CREATE TYPE int42 ( + internallength = 4, + input = int42_in, + output = int42_out, + alignment = int4, + default = 42, + passedbyvalue +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE int42 (internallength = 4, input = int42_in, output = int42_out, alignment = int4, \"d..." +== 019 +-- truncate_limit: 100 +CREATE TYPE text_w_default ( + internallength = variable, + input = text_w_default_in, + output = text_w_default_out, + alignment = int4, + default = 'zippo' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE text_w_default (internallength = variable, input = text_w_default_in, output = text_w..." +== 020 +-- truncate_limit: 100 +CREATE TABLE default_test (f1 text_w_default, f2 int42) +-- +TABLE: name="default_test" schema="" table="default_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_test (f1 text_w_default, f2 int42)" +== 021 +-- truncate_limit: 100 +INSERT INTO default_test DEFAULT VALUES +-- +TABLE: name="default_test" schema="" table="default_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO default_test DEFAULT VALUES" +== 022 +-- truncate_limit: 100 +SELECT * FROM default_test +-- +TABLE: name="default_test" schema="" table="default_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM default_test" +== 023 +-- truncate_limit: 100 +-- We need a shell type to test some CREATE TYPE failure cases with +CREATE TYPE bogus_type +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE bogus_type" +== 024 +-- truncate_limit: 100 +-- invalid: non-lowercase quoted identifiers +CREATE TYPE bogus_type ( + "Internallength" = 4, + "Input" = int42_in, + "Output" = int42_out, + "Alignment" = int4, + "Default" = 42, + "Passedbyvalue" +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE bogus_type (\"Internallength\" = 4, \"Input\" = int42_in, \"Output\" = int42_out, \"Alignmen..." +== 025 +-- truncate_limit: 100 +-- invalid: input/output function incompatibility +CREATE TYPE bogus_type (INPUT = array_in, + OUTPUT = array_out, + ELEMENT = int, + INTERNALLENGTH = 32) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE bogus_type (input = array_in, output = array_out, element = int, internallength = 32)" +== 026 +-- truncate_limit: 100 +DROP TYPE bogus_type +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE bogus_type" +== 027 +-- truncate_limit: 100 +-- It no longer is possible to issue CREATE TYPE without making a shell first +CREATE TYPE bogus_type (INPUT = array_in, + OUTPUT = array_out, + ELEMENT = int, + INTERNALLENGTH = 32) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE bogus_type (input = array_in, output = array_out, element = int, internallength = 32)" +== 028 +-- truncate_limit: 100 +-- Test stand-alone composite type + +CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42)" +== 029 +-- truncate_limit: 100 +CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS ' + SELECT * FROM default_test; +' LANGUAGE SQL +-- +FUNCTION: name="get_default_test" function="get_default_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS $$\n SELECT * FROM default_t..." +== 030 +-- truncate_limit: 100 +SELECT * FROM get_default_test() +-- +FUNCTION: name="get_default_test" function="get_default_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM get_default_test()" +== 031 +-- truncate_limit: 100 +-- Test comments +COMMENT ON TYPE bad IS 'bad comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TYPE bad IS 'bad comment'" +== 032 +-- truncate_limit: 100 +COMMENT ON TYPE default_test_row IS 'good comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TYPE default_test_row IS 'good comment'" +== 033 +-- truncate_limit: 100 +COMMENT ON TYPE default_test_row IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TYPE default_test_row IS NULL" +== 034 +-- truncate_limit: 100 +COMMENT ON COLUMN default_test_row.nope IS 'bad comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN default_test_row.nope IS 'bad comment'" +== 035 +-- truncate_limit: 100 +COMMENT ON COLUMN default_test_row.f1 IS 'good comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN default_test_row.f1 IS 'good comment'" +== 036 +-- truncate_limit: 100 +COMMENT ON COLUMN default_test_row.f1 IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN default_test_row.f1 IS NULL" +== 037 +-- truncate_limit: 100 +-- Check shell type create for existing types +CREATE TYPE text_w_default +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE text_w_default" +== 038 +-- truncate_limit: 100 +-- should fail + +DROP TYPE default_test_row CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE default_test_row CASCADE" +== 039 +-- truncate_limit: 100 +DROP TABLE default_test +-- +TABLE: name="default_test" schema="" table="default_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE default_test" +== 040 +-- truncate_limit: 100 +-- Check dependencies are established when creating a new type +CREATE TYPE base_type +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE base_type" +== 041 +-- truncate_limit: 100 +CREATE FUNCTION base_fn_in(cstring) RETURNS base_type AS 'boolin' + LANGUAGE internal IMMUTABLE STRICT +-- +FUNCTION: name="base_fn_in" function="base_fn_in" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION base_fn_in(cstring) RETURNS base_type AS $$boolin$$ LANGUAGE internal IMMUTABLE R..." +== 042 +-- truncate_limit: 100 +CREATE FUNCTION base_fn_out(base_type) RETURNS cstring AS 'boolout' + LANGUAGE internal IMMUTABLE STRICT +-- +FUNCTION: name="base_fn_out" function="base_fn_out" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION base_fn_out(base_type) RETURNS cstring AS $$boolout$$ LANGUAGE internal IMMUTABLE..." +== 043 +-- truncate_limit: 100 +CREATE TYPE base_type(INPUT = base_fn_in, OUTPUT = base_fn_out) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE base_type (input = base_fn_in, output = base_fn_out)" +== 044 +-- truncate_limit: 100 +DROP FUNCTION base_fn_in(cstring) +-- +FUNCTION: name="base_fn_in" function="base_fn_in" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION base_fn_in(cstring)" +== 045 +-- truncate_limit: 100 +-- error +DROP FUNCTION base_fn_out(base_type) +-- +FUNCTION: name="base_fn_out" function="base_fn_out" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION base_fn_out(base_type)" +== 046 +-- truncate_limit: 100 +-- error +DROP TYPE base_type +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE base_type" +== 047 +-- truncate_limit: 100 +-- error +DROP TYPE base_type CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE base_type CASCADE" +== 048 +-- truncate_limit: 100 +-- Check usage of typmod with a user-defined type +-- (we have borrowed numeric's typmod functions) + +CREATE TEMP TABLE mytab (foo widget(42,13,7)) +-- +TABLE: name="mytab" schema="" table="mytab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE mytab (foo widget(42, 13, 7))" +== 049 +-- truncate_limit: 100 +-- should fail +CREATE TEMP TABLE mytab (foo widget(42,13)) +-- +TABLE: name="mytab" schema="" table="mytab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE mytab (foo widget(42, 13))" +== 050 +-- truncate_limit: 100 +SELECT format_type(atttypid,atttypmod) FROM pg_attribute +WHERE attrelid = 'mytab'::regclass AND attnum > 0 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FUNCTION: name="format_type" function="format_type" schema="" ctx=Call +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT format_type(atttypid, atttypmod) FROM pg_attribute WHERE ..." +== 051 +-- truncate_limit: 100 +-- might as well exercise the widget type while we're here +INSERT INTO mytab VALUES ('(1,2,3)'), ('(-44,5.5,12)') +-- +TABLE: name="mytab" schema="" table="mytab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mytab VALUES ('(1,2,3)'), ('(-44,5.5,12)')" +== 052 +-- truncate_limit: 100 +TABLE mytab +-- +TABLE: name="mytab" schema="" table="mytab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mytab" +== 053 +-- truncate_limit: 100 +-- and test format_type() a bit more, too +select format_type('varchar'::regtype, 42) +-- +FUNCTION: name="format_type" function="format_type" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format_type('varchar'::regtype, 42)" +== 054 +-- truncate_limit: 100 +select format_type('bpchar'::regtype, null) +-- +FUNCTION: name="format_type" function="format_type" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format_type('bpchar'::regtype, NULL)" +== 055 +-- truncate_limit: 100 +-- this behavior difference is intentional +select format_type('bpchar'::regtype, -1) +-- +FUNCTION: name="format_type" function="format_type" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format_type('bpchar'::regtype, -1)" +== 056 +-- truncate_limit: 100 +-- Test non-error-throwing APIs using widget, which still throws errors +SELECT pg_input_is_valid('(1,2,3)', 'widget') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1,2,3)', 'widget')" +== 057 +-- truncate_limit: 100 +SELECT pg_input_is_valid('(1,2)', 'widget') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1,2)', 'widget')" +== 058 +-- truncate_limit: 100 +-- hard error expected +SELECT pg_input_is_valid('{"(1,2,3)"}', 'widget[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{\"(1,2,3)\"}', 'widget[]')" +== 059 +-- truncate_limit: 100 +SELECT pg_input_is_valid('{"(1,2)"}', 'widget[]') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{\"(1,2)\"}', 'widget[]')" +== 060 +-- truncate_limit: 100 +-- hard error expected +SELECT pg_input_is_valid('("(1,2,3)")', 'mytab') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(\"(1,2,3)\")', 'mytab')" +== 061 +-- truncate_limit: 100 +SELECT pg_input_is_valid('("(1,2)")', 'mytab') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(\"(1,2)\")', 'mytab')" +== 062 +-- truncate_limit: 100 +-- hard error expected + +-- Test creation of an operator over a user-defined type + +CREATE FUNCTION pt_in_widget(point, widget) + RETURNS bool + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 149 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 063 +-- truncate_limit: 100 +CREATE OPERATOR <% ( + leftarg = point, + rightarg = widget, + procedure = pt_in_widget, + commutator = >% , + negator = >=% +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR <% (leftarg = point, rightarg = widget, procedure = pt_in_widget, commutator = >%..." +== 064 +-- truncate_limit: 100 +SELECT point '(1,2)' <% widget '(0,0,3)' AS t, + point '(1,2)' <% widget '(0,0,1)' AS f +-- +STMT: SelectStmt +TRUNCATED: "SELECT point '(1,2)' <% '(0,0,3)'::widget AS t, point '(1,2)' <% '(0,0,1)'::widget AS f" +== 065 +-- truncate_limit: 100 +-- exercise city_budget type +CREATE TABLE city ( + name name, + location box, + budget city_budget +) +-- +TABLE: name="city" schema="" table="city" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE city (name name, location box, budget city_budget)" +== 066 +-- truncate_limit: 100 +INSERT INTO city VALUES +('Podunk', '(1,2),(3,4)', '100,127,1000'), +('Gotham', '(1000,34),(1100,334)', '123456,127,-1000,6789') +-- +TABLE: name="city" schema="" table="city" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO city VALUES (...)" +== 067 +-- truncate_limit: 100 +TABLE city +-- +TABLE: name="city" schema="" table="city" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM city" +== 068 +-- truncate_limit: 100 +|-- +-- Test CREATE/ALTER TYPE using a type that's compatible with varchar, +-- so we can re-use those support functions +|-- +CREATE TYPE myvarchar +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE myvarchar" +== 069 +-- truncate_limit: 100 +CREATE FUNCTION myvarcharin(cstring, oid, integer) RETURNS myvarchar +LANGUAGE internal IMMUTABLE PARALLEL SAFE STRICT AS 'varcharin' +-- +FUNCTION: name="myvarcharin" function="myvarcharin" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myvarcharin(cstring, oid, int) RETURNS myvarchar LANGUAGE internal IMMUTABLE PARA..." +== 070 +-- truncate_limit: 100 +CREATE FUNCTION myvarcharout(myvarchar) RETURNS cstring +LANGUAGE internal IMMUTABLE PARALLEL SAFE STRICT AS 'varcharout' +-- +FUNCTION: name="myvarcharout" function="myvarcharout" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myvarcharout(myvarchar) RETURNS cstring LANGUAGE internal IMMUTABLE PARALLEL safe..." +== 071 +-- truncate_limit: 100 +CREATE FUNCTION myvarcharsend(myvarchar) RETURNS bytea +LANGUAGE internal STABLE PARALLEL SAFE STRICT AS 'varcharsend' +-- +FUNCTION: name="myvarcharsend" function="myvarcharsend" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myvarcharsend(myvarchar) RETURNS bytea LANGUAGE internal STABLE PARALLEL safe RET..." +== 072 +-- truncate_limit: 100 +CREATE FUNCTION myvarcharrecv(internal, oid, integer) RETURNS myvarchar +LANGUAGE internal STABLE PARALLEL SAFE STRICT AS 'varcharrecv' +-- +FUNCTION: name="myvarcharrecv" function="myvarcharrecv" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myvarcharrecv(internal, oid, int) RETURNS myvarchar LANGUAGE internal STABLE PARA..." +== 073 +-- truncate_limit: 100 +-- fail, it's still a shell: +ALTER TYPE myvarchar SET (storage = extended) +-- +STMT: AlterTypeStmt +TRUNCATED: "ALTER TYPE myvarchar SET (storage = extended)" +== 074 +-- truncate_limit: 100 +CREATE TYPE myvarchar ( + input = myvarcharin, + output = myvarcharout, + alignment = integer, + storage = main +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE myvarchar (input = myvarcharin, output = myvarcharout, alignment = int, storage = main)" +== 075 +-- truncate_limit: 100 +-- want to check updating of a domain over the target type, too +CREATE DOMAIN myvarchardom AS myvarchar +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN myvarchardom AS myvarchar" +== 076 +-- truncate_limit: 100 +ALTER TYPE myvarchar SET (storage = plain) +-- +STMT: AlterTypeStmt +TRUNCATED: "ALTER TYPE myvarchar SET (storage = plain)" +== 077 +-- truncate_limit: 100 +-- not allowed + +ALTER TYPE myvarchar SET (storage = extended) +-- +STMT: AlterTypeStmt +TRUNCATED: "ALTER TYPE myvarchar SET (storage = extended)" +== 078 +-- truncate_limit: 100 +ALTER TYPE myvarchar SET ( + send = myvarcharsend, + receive = myvarcharrecv, + typmod_in = varchartypmodin, + typmod_out = varchartypmodout, + -- these are bogus, but it's safe as long as we don't use the type: + analyze = ts_typanalyze, + subscript = raw_array_subscript_handler +) +-- +STMT: AlterTypeStmt +TRUNCATED: "ALTER TYPE myvarchar SET (send = myvarcharsend, receive = myvarcharrecv, typmod_in = varchartypmo..." +== 079 +-- truncate_limit: 100 +SELECT typinput, typoutput, typreceive, typsend, typmodin, typmodout, + typanalyze, typsubscript, typstorage +FROM pg_type WHERE typname = 'myvarchar' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type WHERE typname = 'myvarchar'" +== 080 +-- truncate_limit: 100 +SELECT typinput, typoutput, typreceive, typsend, typmodin, typmodout, + typanalyze, typsubscript, typstorage +FROM pg_type WHERE typname = '_myvarchar' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type WHERE typname = '_myvarchar'" +== 081 +-- truncate_limit: 100 +SELECT typinput, typoutput, typreceive, typsend, typmodin, typmodout, + typanalyze, typsubscript, typstorage +FROM pg_type WHERE typname = 'myvarchardom' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type WHERE typname = 'myvarchardom'" +== 082 +-- truncate_limit: 100 +SELECT typinput, typoutput, typreceive, typsend, typmodin, typmodout, + typanalyze, typsubscript, typstorage +FROM pg_type WHERE typname = '_myvarchardom' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type WHERE typname = '_myvarchardom'" +== 083 +-- truncate_limit: 100 +-- ensure dependencies are straight +DROP FUNCTION myvarcharsend(myvarchar) +-- +FUNCTION: name="myvarcharsend" function="myvarcharsend" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION myvarcharsend(myvarchar)" +== 084 +-- truncate_limit: 100 +-- fail +DROP TYPE myvarchar +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE myvarchar" +== 085 +-- truncate_limit: 100 +-- fail + +DROP TYPE myvarchar CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE myvarchar CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/create_view.metadata.json b/parser/testdata/summary_truncate/postgres_regress/create_view.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_view.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/create_view.test b/parser/testdata/summary_truncate/postgres_regress/create_view.test new file mode 100644 index 0000000..bc12a87 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/create_view.test @@ -0,0 +1,2924 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE_VIEW +-- Virtual class definitions +-- (this also tests the query rewrite system) +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION interpt_pp(path, path) + RETURNS point + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 238 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +CREATE TABLE real_city ( + pop int4, + cname text, + outline path +) +-- +TABLE: name="real_city" schema="" table="real_city" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE real_city (pop int4, cname text, outline path)" +== 003 +-- truncate_limit: 100 +COPY real_city FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +ANALYZE real_city +-- +TABLE: name="real_city" schema="" table="real_city" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE real_city" +== 005 +-- truncate_limit: 100 +SELECT * + INTO TABLE ramp + FROM ONLY road + WHERE name ~ '.*Ramp' +-- +TABLE: name="road" schema="" table="road" ctx=Select +TABLE: name="ramp" schema="" table="ramp" ctx=DDL +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT * INTO ramp FROM ONLY road WHERE name ~ '.*Ramp'" +== 006 +-- truncate_limit: 100 +CREATE VIEW street AS + SELECT r.name, r.thepath, c.cname AS cname + FROM ONLY road r, real_city c + WHERE c.outline ?# r.thepath +-- +TABLE: name="street" schema="" table="street" ctx=DDL +TABLE: name="road" schema="" table="road" ctx=Select +TABLE: name="real_city" schema="" table="real_city" ctx=Select +ALIAS: "c"="real_city" +ALIAS: "r"="road" +FILTER: schema="" table="c" column="outline" +FILTER: schema="" table="r" column="thepath" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW street AS SELECT r.name, r.thepath, c.cname AS cname FROM ONLY road r, real_city c WH..." +== 007 +-- truncate_limit: 100 +CREATE VIEW iexit AS + SELECT ih.name, ih.thepath, + interpt_pp(ih.thepath, r.thepath) AS exit + FROM ihighway ih, ramp r + WHERE ih.thepath ?# r.thepath +-- +TABLE: name="iexit" schema="" table="iexit" ctx=DDL +TABLE: name="ihighway" schema="" table="ihighway" ctx=Select +TABLE: name="ramp" schema="" table="ramp" ctx=Select +ALIAS: "ih"="ihighway" +ALIAS: "r"="ramp" +FUNCTION: name="interpt_pp" function="interpt_pp" schema="" ctx=Call +FILTER: schema="" table="ih" column="thepath" +FILTER: schema="" table="r" column="thepath" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW iexit AS SELECT ih.name, ih.thepath, interpt_pp(ih.thepath, r.thepath) AS exit FROM i..." +== 008 +-- truncate_limit: 100 +CREATE VIEW toyemp AS + SELECT name, age, location, 12*salary AS annualsal + FROM emp +-- +TABLE: name="toyemp" schema="" table="toyemp" ctx=DDL +TABLE: name="emp" schema="" table="emp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW toyemp AS SELECT name, age, location, 12 * salary AS annualsal FROM emp" +== 009 +-- truncate_limit: 100 +-- Test comments +COMMENT ON VIEW noview IS 'no view' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON VIEW noview IS 'no view'" +== 010 +-- truncate_limit: 100 +COMMENT ON VIEW toyemp IS 'is a view' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON VIEW toyemp IS 'is a view'" +== 011 +-- truncate_limit: 100 +COMMENT ON VIEW toyemp IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON VIEW toyemp IS NULL" +== 012 +-- truncate_limit: 100 +-- These views are left around mainly to exercise special cases in pg_dump. + +CREATE TABLE view_base_table (key int PRIMARY KEY, data varchar(20)) +-- +TABLE: name="view_base_table" schema="" table="view_base_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE view_base_table (key int PRIMARY KEY, data varchar(20))" +== 013 +-- truncate_limit: 100 +CREATE VIEW key_dependent_view AS + SELECT * FROM view_base_table GROUP BY key +-- +TABLE: name="key_dependent_view" schema="" table="key_dependent_view" ctx=DDL +TABLE: name="view_base_table" schema="" table="view_base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW key_dependent_view AS SELECT * FROM view_base_table GROUP BY key" +== 014 +-- truncate_limit: 100 +ALTER TABLE view_base_table DROP CONSTRAINT view_base_table_pkey +-- +TABLE: name="view_base_table" schema="" table="view_base_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE view_base_table DROP CONSTRAINT view_base_table_pkey" +== 015 +-- truncate_limit: 100 +-- fails + +CREATE VIEW key_dependent_view_no_cols AS + SELECT FROM view_base_table GROUP BY key HAVING length(data) > 0 +-- +TABLE: name="key_dependent_view_no_cols" schema="" table="key_dependent_view_no_cols" ctx=DDL +TABLE: name="view_base_table" schema="" table="view_base_table" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW key_dependent_view_no_cols AS SELECT FROM view_base_table GROUP BY key HAVING length(..." +== 016 +-- truncate_limit: 100 +|-- +-- CREATE OR REPLACE VIEW +|-- + +CREATE TABLE viewtest_tbl (a int, b int, c numeric(10,1), d text COLLATE "C") +-- +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE viewtest_tbl (a int, b int, c numeric(10, 1), d text COLLATE \"C\")" +== 017 +-- truncate_limit: 100 +COPY viewtest_tbl FROM stdin +-- +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY viewtest_tbl FROM STDIN" +== 018 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW viewtest AS + SELECT * FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT * FROM viewtest_tbl" +== 019 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW viewtest AS + SELECT * FROM viewtest_tbl WHERE a > 10 +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT * FROM viewtest_tbl WHERE a > 10" +== 020 +-- truncate_limit: 100 +SELECT * FROM viewtest +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM viewtest" +== 021 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b, c, d FROM viewtest_tbl WHERE a > 5 ORDER BY b DESC +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT a, b, c, d FROM viewtest_tbl WHERE a > 5 ORDER BY b DESC" +== 022 +-- truncate_limit: 100 +SELECT * FROM viewtest +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM viewtest" +== 023 +-- truncate_limit: 100 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT a FROM viewtest_tbl WHERE a <> 20 +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT a FROM viewtest_tbl WHERE a <> 20" +== 024 +-- truncate_limit: 100 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT 1, * FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT 1, * FROM viewtest_tbl" +== 025 +-- truncate_limit: 100 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b::numeric, c, d FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT a, b::numeric, c, d FROM viewtest_tbl" +== 026 +-- truncate_limit: 100 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b, c::numeric(10,2), d FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT a, b, c::numeric(10, 2), d FROM viewtest_tbl" +== 027 +-- truncate_limit: 100 +-- should fail +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b, c, d COLLATE "POSIX" FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT a, b, c, d COLLATE \"POSIX\" FROM viewtest_tbl" +== 028 +-- truncate_limit: 100 +-- should work +CREATE OR REPLACE VIEW viewtest AS + SELECT a, b, c, d, 0 AS e FROM viewtest_tbl +-- +TABLE: name="viewtest" schema="" table="viewtest" ctx=DDL +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW viewtest AS SELECT a, b, c, d, 0 AS e FROM viewtest_tbl" +== 029 +-- truncate_limit: 100 +DROP VIEW viewtest +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW viewtest" +== 030 +-- truncate_limit: 100 +DROP TABLE viewtest_tbl +-- +TABLE: name="viewtest_tbl" schema="" table="viewtest_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE viewtest_tbl" +== 031 +-- truncate_limit: 100 +-- tests for temporary views + +CREATE SCHEMA temp_view_test + CREATE TABLE base_table (a int, id int) + CREATE TABLE base_table2 (a int, id int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA temp_view_test CREATE TABLE base_table (a int, id int) CREATE TABLE base_table2 (a ..." +== 032 +-- truncate_limit: 100 +SET search_path TO temp_view_test, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO temp_view_test, public" +== 033 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE temp_table (a int, id int) +-- +TABLE: name="temp_table" schema="" table="temp_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_table (a int, id int)" +== 034 +-- truncate_limit: 100 +-- should be created in temp_view_test schema +CREATE VIEW v1 AS SELECT * FROM base_table +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v1 AS SELECT * FROM base_table" +== 035 +-- truncate_limit: 100 +-- should be created in temp object schema +CREATE VIEW v1_temp AS SELECT * FROM temp_table +-- +TABLE: name="v1_temp" schema="" table="v1_temp" ctx=DDL +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v1_temp AS SELECT * FROM temp_table" +== 036 +-- truncate_limit: 100 +-- should be created in temp object schema +CREATE TEMP VIEW v2_temp AS SELECT * FROM base_table +-- +TABLE: name="v2_temp" schema="" table="v2_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v2_temp AS SELECT * FROM base_table" +== 037 +-- truncate_limit: 100 +-- should be created in temp_views schema +CREATE VIEW temp_view_test.v2 AS SELECT * FROM base_table +-- +TABLE: name="temp_view_test.v2" schema="temp_view_test" table="v2" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW temp_view_test.v2 AS SELECT * FROM base_table" +== 038 +-- truncate_limit: 100 +-- should fail +CREATE VIEW temp_view_test.v3_temp AS SELECT * FROM temp_table +-- +TABLE: name="temp_view_test.v3_temp" schema="temp_view_test" table="v3_temp" ctx=DDL +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW temp_view_test.v3_temp AS SELECT * FROM temp_table" +== 039 +-- truncate_limit: 100 +-- should fail +CREATE SCHEMA test_view_schema + CREATE TEMP VIEW testview AS SELECT 1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_view_schema CREATE TEMPORARY VIEW testview AS SELECT 1" +== 040 +-- truncate_limit: 100 +-- joins: if any of the join relations are temporary, the view +-- should also be temporary + +-- should be non-temp +CREATE VIEW v3 AS + SELECT t1.a AS t1_a, t2.a AS t2_a + FROM base_table t1, base_table2 t2 + WHERE t1.id = t2.id +-- +TABLE: name="v3" schema="" table="v3" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +ALIAS: "t1"="base_table" +ALIAS: "t2"="base_table2" +FILTER: schema="" table="t1" column="id" +FILTER: schema="" table="t2" column="id" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v3 AS SELECT t1.a AS t1_a, t2.a AS t2_a FROM base_table t1, base_table2 t2 WHERE t1.i..." +== 041 +-- truncate_limit: 100 +-- should be temp (one join rel is temp) +CREATE VIEW v4_temp AS + SELECT t1.a AS t1_a, t2.a AS t2_a + FROM base_table t1, temp_table t2 + WHERE t1.id = t2.id +-- +TABLE: name="v4_temp" schema="" table="v4_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +ALIAS: "t1"="base_table" +ALIAS: "t2"="temp_table" +FILTER: schema="" table="t1" column="id" +FILTER: schema="" table="t2" column="id" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v4_temp AS SELECT t1.a AS t1_a, t2.a AS t2_a FROM base_table t1, temp_table t2 WHERE ..." +== 042 +-- truncate_limit: 100 +-- should be temp +CREATE VIEW v5_temp AS + SELECT t1.a AS t1_a, t2.a AS t2_a, t3.a AS t3_a + FROM base_table t1, base_table2 t2, temp_table t3 + WHERE t1.id = t2.id and t2.id = t3.id +-- +TABLE: name="v5_temp" schema="" table="v5_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +ALIAS: "t1"="base_table" +ALIAS: "t2"="base_table2" +ALIAS: "t3"="temp_table" +FILTER: schema="" table="t1" column="id" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t3" column="id" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v5_temp AS SELECT t1.a AS t1_a, t2.a AS t2_a, t3.a AS t3_a FROM base_table t1, base_t..." +== 043 +-- truncate_limit: 100 +-- subqueries +CREATE VIEW v4 AS SELECT * FROM base_table WHERE id IN (SELECT id FROM base_table2) +-- +TABLE: name="v4" schema="" table="v4" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +FILTER: schema="" table="" column="id" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v4 AS SELECT * FROM base_table WHERE id IN (SELECT id FROM base_table2)" +== 044 +-- truncate_limit: 100 +CREATE VIEW v5 AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM base_table2) t2 +-- +TABLE: name="v5" schema="" table="v5" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +ALIAS: "t1"="base_table" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v5 AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM base_table2) t2" +== 045 +-- truncate_limit: 100 +CREATE VIEW v6 AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM base_table2) +-- +TABLE: name="v6" schema="" table="v6" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v6 AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM base_table2)" +== 046 +-- truncate_limit: 100 +CREATE VIEW v7 AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM base_table2) +-- +TABLE: name="v7" schema="" table="v7" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="base_table2" schema="" table="base_table2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v7 AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM base_table2)" +== 047 +-- truncate_limit: 100 +CREATE VIEW v8 AS SELECT * FROM base_table WHERE EXISTS (SELECT 1) +-- +TABLE: name="v8" schema="" table="v8" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v8 AS SELECT * FROM base_table WHERE EXISTS (SELECT 1)" +== 048 +-- truncate_limit: 100 +CREATE VIEW v6_temp AS SELECT * FROM base_table WHERE id IN (SELECT id FROM temp_table) +-- +TABLE: name="v6_temp" schema="" table="v6_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +FILTER: schema="" table="" column="id" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v6_temp AS SELECT * FROM base_table WHERE id IN (SELECT id FROM temp_table)" +== 049 +-- truncate_limit: 100 +CREATE VIEW v7_temp AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM temp_table) t2 +-- +TABLE: name="v7_temp" schema="" table="v7_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +ALIAS: "t1"="base_table" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v7_temp AS SELECT t1.id, t2.a FROM base_table t1, (SELECT * FROM temp_table) t2" +== 050 +-- truncate_limit: 100 +CREATE VIEW v8_temp AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM temp_table) +-- +TABLE: name="v8_temp" schema="" table="v8_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v8_temp AS SELECT * FROM base_table WHERE EXISTS (SELECT 1 FROM temp_table)" +== 051 +-- truncate_limit: 100 +CREATE VIEW v9_temp AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM temp_table) +-- +TABLE: name="v9_temp" schema="" table="v9_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="temp_table" schema="" table="temp_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v9_temp AS SELECT * FROM base_table WHERE NOT EXISTS (SELECT 1 FROM temp_table)" +== 052 +-- truncate_limit: 100 +-- a view should also be temporary if it references a temporary view +CREATE VIEW v10_temp AS SELECT * FROM v7_temp +-- +TABLE: name="v10_temp" schema="" table="v10_temp" ctx=DDL +TABLE: name="v7_temp" schema="" table="v7_temp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v10_temp AS SELECT * FROM v7_temp" +== 053 +-- truncate_limit: 100 +CREATE VIEW v11_temp AS SELECT t1.id, t2.a FROM base_table t1, v10_temp t2 +-- +TABLE: name="v11_temp" schema="" table="v11_temp" ctx=DDL +TABLE: name="base_table" schema="" table="base_table" ctx=Select +TABLE: name="v10_temp" schema="" table="v10_temp" ctx=Select +ALIAS: "t1"="base_table" +ALIAS: "t2"="v10_temp" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v11_temp AS SELECT t1.id, t2.a FROM base_table t1, v10_temp t2" +== 054 +-- truncate_limit: 100 +CREATE VIEW v12_temp AS SELECT true FROM v11_temp +-- +TABLE: name="v12_temp" schema="" table="v12_temp" ctx=DDL +TABLE: name="v11_temp" schema="" table="v11_temp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v12_temp AS SELECT true FROM v11_temp" +== 055 +-- truncate_limit: 100 +-- a view should also be temporary if it references a temporary sequence +CREATE SEQUENCE seq1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq1" +== 056 +-- truncate_limit: 100 +CREATE TEMPORARY SEQUENCE seq1_temp +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE seq1_temp" +== 057 +-- truncate_limit: 100 +CREATE VIEW v9 AS SELECT seq1.is_called FROM seq1 +-- +TABLE: name="v9" schema="" table="v9" ctx=DDL +TABLE: name="seq1" schema="" table="seq1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v9 AS SELECT seq1.is_called FROM seq1" +== 058 +-- truncate_limit: 100 +CREATE VIEW v13_temp AS SELECT seq1_temp.is_called FROM seq1_temp +-- +TABLE: name="v13_temp" schema="" table="v13_temp" ctx=DDL +TABLE: name="seq1_temp" schema="" table="seq1_temp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v13_temp AS SELECT seq1_temp.is_called FROM seq1_temp" +== 059 +-- truncate_limit: 100 +SELECT relname FROM pg_class + WHERE relname LIKE 'v_' + AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'temp_view_test') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE ... ORDER BY relname" +== 060 +-- truncate_limit: 100 +SELECT relname FROM pg_class + WHERE relname LIKE 'v%' + AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE ... ORDER BY relname" +== 061 +-- truncate_limit: 100 +CREATE SCHEMA testviewschm2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA testviewschm2" +== 062 +-- truncate_limit: 100 +SET search_path TO testviewschm2, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO testviewschm2, public" +== 063 +-- truncate_limit: 100 +CREATE TABLE t1 (num int, name text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (num int, name text)" +== 064 +-- truncate_limit: 100 +CREATE TABLE t2 (num2 int, value text) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t2 (num2 int, value text)" +== 065 +-- truncate_limit: 100 +CREATE TEMP TABLE tt (num2 int, value text) +-- +TABLE: name="tt" schema="" table="tt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt (num2 int, value text)" +== 066 +-- truncate_limit: 100 +CREATE VIEW nontemp1 AS SELECT * FROM t1 CROSS JOIN t2 +-- +TABLE: name="nontemp1" schema="" table="nontemp1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW nontemp1 AS SELECT * FROM t1 CROSS JOIN t2" +== 067 +-- truncate_limit: 100 +CREATE VIEW temporal1 AS SELECT * FROM t1 CROSS JOIN tt +-- +TABLE: name="temporal1" schema="" table="temporal1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW temporal1 AS SELECT * FROM t1 CROSS JOIN tt" +== 068 +-- truncate_limit: 100 +CREATE VIEW nontemp2 AS SELECT * FROM t1 INNER JOIN t2 ON t1.num = t2.num2 +-- +TABLE: name="nontemp2" schema="" table="nontemp2" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW nontemp2 AS SELECT * FROM t1 JOIN t2 ON t1.num = t2.num2" +== 069 +-- truncate_limit: 100 +CREATE VIEW temporal2 AS SELECT * FROM t1 INNER JOIN tt ON t1.num = tt.num2 +-- +TABLE: name="temporal2" schema="" table="temporal2" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW temporal2 AS SELECT * FROM t1 JOIN tt ON t1.num = tt.num2" +== 070 +-- truncate_limit: 100 +CREATE VIEW nontemp3 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2 +-- +TABLE: name="nontemp3" schema="" table="nontemp3" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW nontemp3 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2" +== 071 +-- truncate_limit: 100 +CREATE VIEW temporal3 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2 +-- +TABLE: name="temporal3" schema="" table="temporal3" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW temporal3 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2" +== 072 +-- truncate_limit: 100 +CREATE VIEW nontemp4 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2 AND t2.value = 'xxx' +-- +TABLE: name="nontemp4" schema="" table="nontemp4" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW nontemp4 AS SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num2 AND t2.value = 'xxx'" +== 073 +-- truncate_limit: 100 +CREATE VIEW temporal4 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2 AND tt.value = 'xxx' +-- +TABLE: name="temporal4" schema="" table="temporal4" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW temporal4 AS SELECT * FROM t1 LEFT JOIN tt ON t1.num = tt.num2 AND tt.value = 'xxx'" +== 074 +-- truncate_limit: 100 +SELECT relname FROM pg_class + WHERE relname LIKE 'nontemp%' + AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'testviewschm2') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE ... ORDER BY relname" +== 075 +-- truncate_limit: 100 +SELECT relname FROM pg_class + WHERE relname LIKE 'temporal%' + AND relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname LIKE 'pg_temp%') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE ... ORDER BY relname" +== 076 +-- truncate_limit: 100 +CREATE TABLE tbl1 ( a int, b int) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl1 (a int, b int)" +== 077 +-- truncate_limit: 100 +CREATE TABLE tbl2 (c int, d int) +-- +TABLE: name="tbl2" schema="" table="tbl2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl2 (c int, d int)" +== 078 +-- truncate_limit: 100 +CREATE TABLE tbl3 (e int, f int) +-- +TABLE: name="tbl3" schema="" table="tbl3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl3 (e int, f int)" +== 079 +-- truncate_limit: 100 +CREATE TABLE tbl4 (g int, h int) +-- +TABLE: name="tbl4" schema="" table="tbl4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl4 (g int, h int)" +== 080 +-- truncate_limit: 100 +CREATE TEMP TABLE tmptbl (i int, j int) +-- +TABLE: name="tmptbl" schema="" table="tmptbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tmptbl (i int, j int)" +== 081 +-- truncate_limit: 100 +--Should be in testviewschm2 +CREATE VIEW pubview AS SELECT * FROM tbl1 WHERE tbl1.a +BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2) +AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f) +-- +TABLE: name="pubview" schema="" table="pubview" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl2" schema="" table="tbl2" ctx=Select +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +TABLE: name="tbl4" schema="" table="tbl4" ctx=Select +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +FILTER: schema="" table="tbl1" column="a" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="f" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW pubview AS SELECT * FROM tbl1 WHERE tbl1.a BETWEEN (SELECT d FROM tbl2 WHERE c = 1) A..." +== 082 +-- truncate_limit: 100 +SELECT count(*) FROM pg_class where relname = 'pubview' +AND relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname = 'testviewschm2') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_class WHERE ..." +== 083 +-- truncate_limit: 100 +--Should be in temp object schema +CREATE VIEW mytempview AS SELECT * FROM tbl1 WHERE tbl1.a +BETWEEN (SELECT d FROM tbl2 WHERE c = 1) AND (SELECT e FROM tbl3 WHERE f = 2) +AND EXISTS (SELECT g FROM tbl4 LEFT JOIN tbl3 ON tbl4.h = tbl3.f) +AND NOT EXISTS (SELECT g FROM tbl4 LEFT JOIN tmptbl ON tbl4.h = tmptbl.j) +-- +TABLE: name="mytempview" schema="" table="mytempview" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl2" schema="" table="tbl2" ctx=Select +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +TABLE: name="tbl4" schema="" table="tbl4" ctx=Select +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +TABLE: name="tbl4" schema="" table="tbl4" ctx=Select +TABLE: name="tmptbl" schema="" table="tmptbl" ctx=Select +FILTER: schema="" table="tbl1" column="a" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="f" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mytempview AS SELECT * FROM tbl1 WHERE tbl1.a BETWEEN (SELECT d FROM tbl2 WHERE c = 1..." +== 084 +-- truncate_limit: 100 +SELECT count(*) FROM pg_class where relname LIKE 'mytempview' +And relnamespace IN (SELECT OID FROM pg_namespace WHERE nspname LIKE 'pg_temp%') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_class WHERE ..." +== 085 +-- truncate_limit: 100 +|-- +-- CREATE VIEW and WITH(...) clause +|-- +CREATE VIEW mysecview1 + AS SELECT * FROM tbl1 WHERE a = 0 +-- +TABLE: name="mysecview1" schema="" table="mysecview1" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview1 AS SELECT * FROM tbl1 WHERE a = 0" +== 086 +-- truncate_limit: 100 +CREATE VIEW mysecview2 WITH (security_barrier=true) + AS SELECT * FROM tbl1 WHERE a > 0 +-- +TABLE: name="mysecview2" schema="" table="mysecview2" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview2 WITH (security_barrier=true) AS SELECT * FROM tbl1 WHERE a > 0" +== 087 +-- truncate_limit: 100 +CREATE VIEW mysecview3 WITH (security_barrier=false) + AS SELECT * FROM tbl1 WHERE a < 0 +-- +TABLE: name="mysecview3" schema="" table="mysecview3" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview3 WITH (security_barrier=false) AS SELECT * FROM tbl1 WHERE a < 0" +== 088 +-- truncate_limit: 100 +CREATE VIEW mysecview4 WITH (security_barrier) + AS SELECT * FROM tbl1 WHERE a <> 0 +-- +TABLE: name="mysecview4" schema="" table="mysecview4" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview4 WITH (security_barrier) AS SELECT * FROM tbl1 WHERE a <> 0" +== 089 +-- truncate_limit: 100 +CREATE VIEW mysecview5 WITH (security_barrier=100) -- Error + AS SELECT * FROM tbl1 WHERE a > 100 +-- +TABLE: name="mysecview5" schema="" table="mysecview5" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview5 WITH (security_barrier=100) AS SELECT * FROM tbl1 WHERE a > 100" +== 090 +-- truncate_limit: 100 +CREATE VIEW mysecview6 WITH (invalid_option) -- Error + AS SELECT * FROM tbl1 WHERE a < 100 +-- +TABLE: name="mysecview6" schema="" table="mysecview6" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview6 WITH (invalid_option) AS SELECT * FROM tbl1 WHERE a < 100" +== 091 +-- truncate_limit: 100 +CREATE VIEW mysecview7 WITH (security_invoker=true) + AS SELECT * FROM tbl1 WHERE a = 100 +-- +TABLE: name="mysecview7" schema="" table="mysecview7" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview7 WITH (security_invoker=true) AS SELECT * FROM tbl1 WHERE a = 100" +== 092 +-- truncate_limit: 100 +CREATE VIEW mysecview8 WITH (security_invoker=false, security_barrier=true) + AS SELECT * FROM tbl1 WHERE a > 100 +-- +TABLE: name="mysecview8" schema="" table="mysecview8" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview8 WITH (security_invoker=false, security_barrier=true) AS SELECT * FROM tbl1..." +== 093 +-- truncate_limit: 100 +CREATE VIEW mysecview9 WITH (security_invoker) + AS SELECT * FROM tbl1 WHERE a < 100 +-- +TABLE: name="mysecview9" schema="" table="mysecview9" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview9 WITH (security_invoker) AS SELECT * FROM tbl1 WHERE a < 100" +== 094 +-- truncate_limit: 100 +CREATE VIEW mysecview10 WITH (security_invoker=100) -- Error + AS SELECT * FROM tbl1 WHERE a <> 100 +-- +TABLE: name="mysecview10" schema="" table="mysecview10" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mysecview10 WITH (security_invoker=100) AS SELECT * FROM tbl1 WHERE a <> 100" +== 095 +-- truncate_limit: 100 +SELECT relname, relkind, reloptions FROM pg_class + WHERE oid in ('mysecview1'::regclass, 'mysecview2'::regclass, + 'mysecview3'::regclass, 'mysecview4'::regclass, + 'mysecview7'::regclass, 'mysecview8'::regclass, + 'mysecview9'::regclass) + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind, reloptions FROM pg_class WHERE ... ORDER BY relname" +== 096 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW mysecview1 + AS SELECT * FROM tbl1 WHERE a = 256 +-- +TABLE: name="mysecview1" schema="" table="mysecview1" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW mysecview1 AS SELECT * FROM tbl1 WHERE a = 256" +== 097 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW mysecview2 + AS SELECT * FROM tbl1 WHERE a > 256 +-- +TABLE: name="mysecview2" schema="" table="mysecview2" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW mysecview2 AS SELECT * FROM tbl1 WHERE a > 256" +== 098 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW mysecview3 WITH (security_barrier=true) + AS SELECT * FROM tbl1 WHERE a < 256 +-- +TABLE: name="mysecview3" schema="" table="mysecview3" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW mysecview3 WITH (security_barrier=true) AS SELECT * FROM tbl1 WHERE a < 256" +== 099 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW mysecview4 WITH (security_barrier=false) + AS SELECT * FROM tbl1 WHERE a <> 256 +-- +TABLE: name="mysecview4" schema="" table="mysecview4" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW mysecview4 WITH (security_barrier=false) AS SELECT * FROM tbl1 WHERE a <> 256" +== 100 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW mysecview7 + AS SELECT * FROM tbl1 WHERE a > 256 +-- +TABLE: name="mysecview7" schema="" table="mysecview7" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW mysecview7 AS SELECT * FROM tbl1 WHERE a > 256" +== 101 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW mysecview8 WITH (security_invoker=true) + AS SELECT * FROM tbl1 WHERE a < 256 +-- +TABLE: name="mysecview8" schema="" table="mysecview8" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW mysecview8 WITH (security_invoker=true) AS SELECT * FROM tbl1 WHERE a < 256" +== 102 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW mysecview9 WITH (security_invoker=false, security_barrier=true) + AS SELECT * FROM tbl1 WHERE a <> 256 +-- +TABLE: name="mysecview9" schema="" table="mysecview9" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW mysecview9 WITH (security_invoker=false, security_barrier=true) AS SELECT ..." +== 103 +-- truncate_limit: 100 +SELECT relname, relkind, reloptions FROM pg_class + WHERE oid in ('mysecview1'::regclass, 'mysecview2'::regclass, + 'mysecview3'::regclass, 'mysecview4'::regclass, + 'mysecview7'::regclass, 'mysecview8'::regclass, + 'mysecview9'::regclass) + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind, reloptions FROM pg_class WHERE ... ORDER BY relname" +== 104 +-- truncate_limit: 100 +-- Check that unknown literals are converted to "text" in CREATE VIEW, +-- so that we don't end up with unknown-type columns. + +CREATE VIEW unspecified_types AS + SELECT 42 as i, 42.5 as num, 'foo' as u, 'foo'::unknown as u2, null as n +-- +TABLE: name="unspecified_types" schema="" table="unspecified_types" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW unspecified_types AS SELECT 42 AS i, 42.5 AS num, 'foo' AS u, 'foo'::unknown AS u2, N..." +== 105 +-- truncate_limit: 100 +SELECT * FROM unspecified_types +-- +TABLE: name="unspecified_types" schema="" table="unspecified_types" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unspecified_types" +== 106 +-- truncate_limit: 100 +-- This test checks that proper typmods are assigned in a multi-row VALUES + +CREATE VIEW tt1 AS + SELECT * FROM ( + VALUES + ('abc'::varchar(3), '0123456789', 42, 'abcd'::varchar(4)), + ('0123456789', 'abc'::varchar(3), 42.12, 'abc'::varchar(4)) + ) vv(a,b,c,d) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt1 AS SELECT * FROM (VALUES ('abc'::varchar(3), '0123456789', 42, 'abcd'::varchar(4)..." +== 107 +-- truncate_limit: 100 +SELECT * FROM tt1 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt1" +== 108 +-- truncate_limit: 100 +SELECT a::varchar(3) FROM tt1 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a::varchar(3) FROM tt1" +== 109 +-- truncate_limit: 100 +DROP VIEW tt1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW tt1" +== 110 +-- truncate_limit: 100 +-- Test view decompilation in the face of relation renaming conflicts + +CREATE TABLE tt1 (f1 int, f2 int, f3 text) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt1 (f1 int, f2 int, f3 text)" +== 111 +-- truncate_limit: 100 +CREATE TABLE tx1 (x1 int, x2 int, x3 text) +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx1 (x1 int, x2 int, x3 text)" +== 112 +-- truncate_limit: 100 +CREATE TABLE temp_view_test.tt1 (y1 int, f2 int, f3 text) +-- +TABLE: name="temp_view_test.tt1" schema="temp_view_test" table="tt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE temp_view_test.tt1 (y1 int, f2 int, f3 text)" +== 113 +-- truncate_limit: 100 +CREATE VIEW aliased_view_1 AS + select * from tt1 + where exists (select 1 from tx1 where tt1.f1 = tx1.x1) +-- +TABLE: name="aliased_view_1" schema="" table="aliased_view_1" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=Select +TABLE: name="tx1" schema="" table="tx1" ctx=Select +FILTER: schema="" table="tt1" column="f1" +FILTER: schema="" table="tx1" column="x1" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW aliased_view_1 AS SELECT * FROM tt1 WHERE EXISTS (SELECT 1 FROM tx1 WHERE tt1.f1 = tx..." +== 114 +-- truncate_limit: 100 +CREATE VIEW aliased_view_2 AS + select * from tt1 a1 + where exists (select 1 from tx1 where a1.f1 = tx1.x1) +-- +TABLE: name="aliased_view_2" schema="" table="aliased_view_2" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=Select +TABLE: name="tx1" schema="" table="tx1" ctx=Select +ALIAS: "a1"="tt1" +FILTER: schema="" table="a1" column="f1" +FILTER: schema="" table="tx1" column="x1" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW aliased_view_2 AS SELECT * FROM tt1 a1 WHERE EXISTS (SELECT 1 FROM tx1 WHERE a1.f1 = ..." +== 115 +-- truncate_limit: 100 +CREATE VIEW aliased_view_3 AS + select * from tt1 + where exists (select 1 from tx1 a2 where tt1.f1 = a2.x1) +-- +TABLE: name="aliased_view_3" schema="" table="aliased_view_3" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=Select +TABLE: name="tx1" schema="" table="tx1" ctx=Select +ALIAS: "a2"="tx1" +FILTER: schema="" table="tt1" column="f1" +FILTER: schema="" table="a2" column="x1" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW aliased_view_3 AS SELECT * FROM tt1 WHERE EXISTS (SELECT 1 FROM tx1 a2 WHERE tt1.f1 =..." +== 116 +-- truncate_limit: 100 +CREATE VIEW aliased_view_4 AS + select * from temp_view_test.tt1 + where exists (select 1 from tt1 where temp_view_test.tt1.y1 = tt1.f1) +-- +TABLE: name="aliased_view_4" schema="" table="aliased_view_4" ctx=DDL +TABLE: name="temp_view_test.tt1" schema="temp_view_test" table="tt1" ctx=Select +TABLE: name="tt1" schema="" table="tt1" ctx=Select +FILTER: schema="temp_view_test" table="tt1" column="y1" +FILTER: schema="" table="tt1" column="f1" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW aliased_view_4 AS SELECT * FROM temp_view_test.tt1 WHERE EXISTS (SELECT 1 FROM tt1 WH..." +== 117 +-- truncate_limit: 100 +ALTER TABLE tx1 RENAME TO a1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +TABLE: name="a1" schema="" table="a1" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE tx1 RENAME TO a1" +== 118 +-- truncate_limit: 100 +ALTER TABLE tt1 RENAME TO a2 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +TABLE: name="a2" schema="" table="a2" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE tt1 RENAME TO a2" +== 119 +-- truncate_limit: 100 +ALTER TABLE a1 RENAME TO tt1 +-- +TABLE: name="a1" schema="" table="a1" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE a1 RENAME TO tt1" +== 120 +-- truncate_limit: 100 +ALTER TABLE a2 RENAME TO tx1 +-- +TABLE: name="a2" schema="" table="a2" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE a2 RENAME TO tx1" +== 121 +-- truncate_limit: 100 +ALTER TABLE tx1 SET SCHEMA temp_view_test +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE tx1 SET SCHEMA temp_view_test" +== 122 +-- truncate_limit: 100 +ALTER TABLE temp_view_test.tt1 RENAME TO tmp1 +-- +TABLE: name="temp_view_test.tt1" schema="temp_view_test" table="tt1" ctx=DDL +TABLE: name="temp_view_test.tmp1" schema="temp_view_test" table="tmp1" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE temp_view_test.tt1 RENAME TO tmp1" +== 123 +-- truncate_limit: 100 +ALTER TABLE temp_view_test.tmp1 SET SCHEMA testviewschm2 +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER TABLE temp_view_test.tmp1 SET SCHEMA testviewschm2" +== 124 +-- truncate_limit: 100 +ALTER TABLE tmp1 RENAME TO tx1 +-- +TABLE: name="tmp1" schema="" table="tmp1" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE tmp1 RENAME TO tx1" +== 125 +-- truncate_limit: 100 +-- Test correct deparsing of ORDER BY when there is an output name conflict + +create view aliased_order_by as +select x1 as x2, x2 as x1, x3 from tt1 + order by x2 +-- +TABLE: name="aliased_order_by" schema="" table="aliased_order_by" ctx=DDL +TABLE: name="tt1" schema="" table="tt1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW aliased_order_by AS SELECT x1 AS x2, x2 AS x1, x3 FROM tt1 ORDER BY x2" +== 126 +-- truncate_limit: 100 +-- this is interpreted per SQL92, so really ordering by x1 + + +alter view aliased_order_by rename column x1 to x0 +-- +STMT: RenameStmt +TRUNCATED: "ALTER VIEW aliased_order_by RENAME COLUMN x1 TO x0" +== 127 +-- truncate_limit: 100 +alter view aliased_order_by rename column x3 to x1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER VIEW aliased_order_by RENAME COLUMN x3 TO x1" +== 128 +-- truncate_limit: 100 +-- Test aliasing of joins + +create view view_of_joins as +select * from + (select * from (tbl1 cross join tbl2) same) ss, + (tbl3 cross join tbl4) same +-- +TABLE: name="view_of_joins" schema="" table="view_of_joins" ctx=DDL +TABLE: name="tbl3" schema="" table="tbl3" ctx=Select +TABLE: name="tbl4" schema="" table="tbl4" ctx=Select +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl2" schema="" table="tbl2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view_of_joins AS SELECT * FROM (SELECT * FROM (tbl1 CROSS JOIN tbl2 ) same) ss, (tbl3..." +== 129 +-- truncate_limit: 100 +create table tbl1a (a int, c int) +-- +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl1a (a int, c int)" +== 130 +-- truncate_limit: 100 +create view view_of_joins_2a as select * from tbl1 join tbl1a using (a) +-- +TABLE: name="view_of_joins_2a" schema="" table="view_of_joins_2a" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view_of_joins_2a AS SELECT * FROM tbl1 JOIN tbl1a USING (a)" +== 131 +-- truncate_limit: 100 +create view view_of_joins_2b as select * from tbl1 join tbl1a using (a) as x +-- +TABLE: name="view_of_joins_2b" schema="" table="view_of_joins_2b" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view_of_joins_2b AS SELECT * FROM tbl1 JOIN tbl1a USING (a) AS x" +== 132 +-- truncate_limit: 100 +create view view_of_joins_2c as select * from (tbl1 join tbl1a using (a)) as y +-- +TABLE: name="view_of_joins_2c" schema="" table="view_of_joins_2c" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view_of_joins_2c AS SELECT * FROM (tbl1 JOIN tbl1a USING (a) ) y" +== 133 +-- truncate_limit: 100 +create view view_of_joins_2d as select * from (tbl1 join tbl1a using (a) as x) as y +-- +TABLE: name="view_of_joins_2d" schema="" table="view_of_joins_2d" ctx=DDL +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tbl1a" schema="" table="tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view_of_joins_2d AS SELECT * FROM (tbl1 JOIN tbl1a USING (a) AS x) y" +== 134 +-- truncate_limit: 100 +select pg_get_viewdef('view_of_joins_2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('view_of_joins_2a', true)" +== 135 +-- truncate_limit: 100 +select pg_get_viewdef('view_of_joins_2b', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('view_of_joins_2b', true)" +== 136 +-- truncate_limit: 100 +select pg_get_viewdef('view_of_joins_2c', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('view_of_joins_2c', true)" +== 137 +-- truncate_limit: 100 +select pg_get_viewdef('view_of_joins_2d', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('view_of_joins_2d', true)" +== 138 +-- truncate_limit: 100 +-- Test view decompilation in the face of column addition/deletion/renaming + +create table tt2 (a int, b int, c int) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt2 (a int, b int, c int)" +== 139 +-- truncate_limit: 100 +create table tt3 (ax int8, b int2, c numeric) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt3 (ax int8, b int2, c numeric)" +== 140 +-- truncate_limit: 100 +create table tt4 (ay int, b int, q int) +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt4 (ay int, b int, q int)" +== 141 +-- truncate_limit: 100 +create view v1 as select * from tt2 natural join tt3 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v1 AS SELECT * FROM tt2 NATURAL JOIN tt3" +== 142 +-- truncate_limit: 100 +create view v1a as select * from (tt2 natural join tt3) j +-- +TABLE: name="v1a" schema="" table="v1a" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v1a AS SELECT * FROM (tt2 NATURAL JOIN tt3 ) j" +== 143 +-- truncate_limit: 100 +create view v2 as select * from tt2 join tt3 using (b,c) join tt4 using (b) +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt4" schema="" table="tt4" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v2 AS SELECT * FROM tt2 JOIN tt3 USING (b, c) JOIN tt4 USING (b)" +== 144 +-- truncate_limit: 100 +create view v2a as select * from (tt2 join tt3 using (b,c) join tt4 using (b)) j +-- +TABLE: name="v2a" schema="" table="v2a" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt4" schema="" table="tt4" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v2a AS SELECT * FROM (tt2 JOIN tt3 USING (b, c) JOIN tt4 USING (b) ) j" +== 145 +-- truncate_limit: 100 +create view v3 as select * from tt2 join tt3 using (b,c) full join tt4 using (b) +-- +TABLE: name="v3" schema="" table="v3" ctx=DDL +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt4" schema="" table="tt4" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v3 AS SELECT * FROM tt2 JOIN tt3 USING (b, c) FULL JOIN tt4 USING (b)" +== 146 +-- truncate_limit: 100 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1', true)" +== 147 +-- truncate_limit: 100 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1a', true)" +== 148 +-- truncate_limit: 100 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2', true)" +== 149 +-- truncate_limit: 100 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2a', true)" +== 150 +-- truncate_limit: 100 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v3', true)" +== 151 +-- truncate_limit: 100 +alter table tt2 add column d int +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt2 ADD COLUMN d int" +== 152 +-- truncate_limit: 100 +alter table tt2 add column e int +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt2 ADD COLUMN e int" +== 153 +-- truncate_limit: 100 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1', true)" +== 154 +-- truncate_limit: 100 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1a', true)" +== 155 +-- truncate_limit: 100 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2', true)" +== 156 +-- truncate_limit: 100 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2a', true)" +== 157 +-- truncate_limit: 100 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v3', true)" +== 158 +-- truncate_limit: 100 +alter table tt3 rename c to d +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE tt3 RENAME COLUMN c TO d" +== 159 +-- truncate_limit: 100 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1', true)" +== 160 +-- truncate_limit: 100 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1a', true)" +== 161 +-- truncate_limit: 100 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2', true)" +== 162 +-- truncate_limit: 100 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2a', true)" +== 163 +-- truncate_limit: 100 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v3', true)" +== 164 +-- truncate_limit: 100 +alter table tt3 add column c int +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt3 ADD COLUMN c int" +== 165 +-- truncate_limit: 100 +alter table tt3 add column e int +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt3 ADD COLUMN e int" +== 166 +-- truncate_limit: 100 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1', true)" +== 167 +-- truncate_limit: 100 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1a', true)" +== 168 +-- truncate_limit: 100 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2', true)" +== 169 +-- truncate_limit: 100 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2a', true)" +== 170 +-- truncate_limit: 100 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v3', true)" +== 171 +-- truncate_limit: 100 +alter table tt2 drop column d +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt2 DROP d" +== 172 +-- truncate_limit: 100 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1', true)" +== 173 +-- truncate_limit: 100 +select pg_get_viewdef('v1a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1a', true)" +== 174 +-- truncate_limit: 100 +select pg_get_viewdef('v2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2', true)" +== 175 +-- truncate_limit: 100 +select pg_get_viewdef('v2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v2a', true)" +== 176 +-- truncate_limit: 100 +select pg_get_viewdef('v3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v3', true)" +== 177 +-- truncate_limit: 100 +create table tt5 (a int, b int) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt5 (a int, b int)" +== 178 +-- truncate_limit: 100 +create table tt6 (c int, d int) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt6 (c int, d int)" +== 179 +-- truncate_limit: 100 +create view vv1 as select * from (tt5 cross join tt6) j(aa,bb,cc,dd) +-- +TABLE: name="vv1" schema="" table="vv1" ctx=DDL +TABLE: name="tt5" schema="" table="tt5" ctx=Select +TABLE: name="tt6" schema="" table="tt6" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vv1 AS SELECT * FROM (tt5 CROSS JOIN tt6 ) j(aa, bb, cc, dd)" +== 180 +-- truncate_limit: 100 +select pg_get_viewdef('vv1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv1', true)" +== 181 +-- truncate_limit: 100 +alter table tt5 add column c int +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt5 ADD COLUMN c int" +== 182 +-- truncate_limit: 100 +select pg_get_viewdef('vv1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv1', true)" +== 183 +-- truncate_limit: 100 +alter table tt5 add column cc int +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt5 ADD COLUMN cc int" +== 184 +-- truncate_limit: 100 +select pg_get_viewdef('vv1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv1', true)" +== 185 +-- truncate_limit: 100 +alter table tt5 drop column c +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt5 DROP c" +== 186 +-- truncate_limit: 100 +select pg_get_viewdef('vv1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv1', true)" +== 187 +-- truncate_limit: 100 +create view v4 as select * from v1 +-- +TABLE: name="v4" schema="" table="v4" ctx=DDL +TABLE: name="v1" schema="" table="v1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v4 AS SELECT * FROM v1" +== 188 +-- truncate_limit: 100 +alter view v1 rename column a to x +-- +STMT: RenameStmt +TRUNCATED: "ALTER VIEW v1 RENAME COLUMN a TO x" +== 189 +-- truncate_limit: 100 +select pg_get_viewdef('v1', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v1', true)" +== 190 +-- truncate_limit: 100 +select pg_get_viewdef('v4', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v4', true)" +== 191 +-- truncate_limit: 100 +-- Unnamed FULL JOIN USING is lots of fun too + +create table tt7 (x int, xx int, y int) +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt7 (x int, xx int, y int)" +== 192 +-- truncate_limit: 100 +alter table tt7 drop column xx +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7 DROP xx" +== 193 +-- truncate_limit: 100 +create table tt8 (x int, z int) +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt8 (x int, z int)" +== 194 +-- truncate_limit: 100 +create view vv2 as +select * from (values(1,2,3,4,5)) v(a,b,c,d,e) +union all +select * from tt7 full join tt8 using (x), tt8 tt8x +-- +TABLE: name="vv2" schema="" table="vv2" ctx=DDL +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +ALIAS: "tt8x"="tt8" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vv2 AS SELECT * FROM (VALUES (1, 2, 3, 4, 5)) v(a, b, c, d, e) UNION ALL SELECT * FRO..." +== 195 +-- truncate_limit: 100 +select pg_get_viewdef('vv2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv2', true)" +== 196 +-- truncate_limit: 100 +create view vv3 as +select * from (values(1,2,3,4,5,6)) v(a,b,c,x,e,f) +union all +select * from + tt7 full join tt8 using (x), + tt7 tt7x full join tt8 tt8x using (x) +-- +TABLE: name="vv3" schema="" table="vv3" ctx=DDL +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +ALIAS: "tt7x"="tt7" +ALIAS: "tt8x"="tt8" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vv3 AS SELECT * FROM (VALUES (1, 2, 3, 4, 5, 6)) v(a, b, c, x, e, f) UNION ALL SELECT..." +== 197 +-- truncate_limit: 100 +select pg_get_viewdef('vv3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv3', true)" +== 198 +-- truncate_limit: 100 +create view vv4 as +select * from (values(1,2,3,4,5,6,7)) v(a,b,c,x,e,f,g) +union all +select * from + tt7 full join tt8 using (x), + tt7 tt7x full join tt8 tt8x using (x) full join tt8 tt8y using (x) +-- +TABLE: name="vv4" schema="" table="vv4" ctx=DDL +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +TABLE: name="tt7" schema="" table="tt7" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +TABLE: name="tt8" schema="" table="tt8" ctx=Select +ALIAS: "tt7x"="tt7" +ALIAS: "tt8x"="tt8" +ALIAS: "tt8y"="tt8" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vv4 AS SELECT * FROM (VALUES (1, 2, 3, 4, 5, 6, 7)) v(a, b, c, x, e, f, g) UNION ALL ..." +== 199 +-- truncate_limit: 100 +select pg_get_viewdef('vv4', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv4', true)" +== 200 +-- truncate_limit: 100 +alter table tt7 add column zz int +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7 ADD COLUMN zz int" +== 201 +-- truncate_limit: 100 +alter table tt7 add column z int +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7 ADD COLUMN z int" +== 202 +-- truncate_limit: 100 +alter table tt7 drop column zz +-- +TABLE: name="tt7" schema="" table="tt7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7 DROP zz" +== 203 +-- truncate_limit: 100 +alter table tt8 add column z2 int +-- +TABLE: name="tt8" schema="" table="tt8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt8 ADD COLUMN z2 int" +== 204 +-- truncate_limit: 100 +select pg_get_viewdef('vv2', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv2', true)" +== 205 +-- truncate_limit: 100 +select pg_get_viewdef('vv3', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv3', true)" +== 206 +-- truncate_limit: 100 +select pg_get_viewdef('vv4', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv4', true)" +== 207 +-- truncate_limit: 100 +-- Implicit coercions in a JOIN USING create issues similar to FULL JOIN + +create table tt7a (x date, xx int, y int) +-- +TABLE: name="tt7a" schema="" table="tt7a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt7a (x date, xx int, y int)" +== 208 +-- truncate_limit: 100 +alter table tt7a drop column xx +-- +TABLE: name="tt7a" schema="" table="tt7a" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt7a DROP xx" +== 209 +-- truncate_limit: 100 +create table tt8a (x timestamptz, z int) +-- +TABLE: name="tt8a" schema="" table="tt8a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt8a (x timestamptz, z int)" +== 210 +-- truncate_limit: 100 +create view vv2a as +select * from (values(now(),2,3,now(),5)) v(a,b,c,d,e) +union all +select * from tt7a left join tt8a using (x), tt8a tt8ax +-- +TABLE: name="vv2a" schema="" table="vv2a" ctx=DDL +TABLE: name="tt7a" schema="" table="tt7a" ctx=Select +TABLE: name="tt8a" schema="" table="tt8a" ctx=Select +TABLE: name="tt8a" schema="" table="tt8a" ctx=Select +ALIAS: "tt8ax"="tt8a" +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vv2a AS SELECT * FROM (VALUES (now(), 2, 3, now(), 5)) v(a, b, c, d, e) UNION ALL SEL..." +== 211 +-- truncate_limit: 100 +select pg_get_viewdef('vv2a', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv2a', true)" +== 212 +-- truncate_limit: 100 +|-- +-- Also check dropping a column that existed when the view was made +|-- + +create table tt9 (x int, xx int, y int) +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt9 (x int, xx int, y int)" +== 213 +-- truncate_limit: 100 +create table tt10 (x int, z int) +-- +TABLE: name="tt10" schema="" table="tt10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt10 (x int, z int)" +== 214 +-- truncate_limit: 100 +create view vv5 as select x,y,z from tt9 join tt10 using(x) +-- +TABLE: name="vv5" schema="" table="vv5" ctx=DDL +TABLE: name="tt9" schema="" table="tt9" ctx=Select +TABLE: name="tt10" schema="" table="tt10" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vv5 AS SELECT x, y, z FROM tt9 JOIN tt10 USING (x)" +== 215 +-- truncate_limit: 100 +select pg_get_viewdef('vv5', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv5', true)" +== 216 +-- truncate_limit: 100 +alter table tt9 drop column xx +-- +TABLE: name="tt9" schema="" table="tt9" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt9 DROP xx" +== 217 +-- truncate_limit: 100 +select pg_get_viewdef('vv5', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv5', true)" +== 218 +-- truncate_limit: 100 +|-- +-- Another corner case is that we might add a column to a table below a +-- JOIN USING, and thereby make the USING column name ambiguous +|-- + +create table tt11 (x int, y int) +-- +TABLE: name="tt11" schema="" table="tt11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt11 (x int, y int)" +== 219 +-- truncate_limit: 100 +create table tt12 (x int, z int) +-- +TABLE: name="tt12" schema="" table="tt12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt12 (x int, z int)" +== 220 +-- truncate_limit: 100 +create table tt13 (z int, q int) +-- +TABLE: name="tt13" schema="" table="tt13" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt13 (z int, q int)" +== 221 +-- truncate_limit: 100 +create view vv6 as select x,y,z,q from + (tt11 join tt12 using(x)) join tt13 using(z) +-- +TABLE: name="vv6" schema="" table="vv6" ctx=DDL +TABLE: name="tt11" schema="" table="tt11" ctx=Select +TABLE: name="tt12" schema="" table="tt12" ctx=Select +TABLE: name="tt13" schema="" table="tt13" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vv6 AS SELECT x, y, z, q FROM tt11 JOIN tt12 USING (x) JOIN tt13 USING (z)" +== 222 +-- truncate_limit: 100 +select pg_get_viewdef('vv6', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv6', true)" +== 223 +-- truncate_limit: 100 +alter table tt11 add column z int +-- +TABLE: name="tt11" schema="" table="tt11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt11 ADD COLUMN z int" +== 224 +-- truncate_limit: 100 +select pg_get_viewdef('vv6', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vv6', true)" +== 225 +-- truncate_limit: 100 +|-- +-- Check cases involving dropped/altered columns in a function's rowtype result +|-- + +create table tt14t (f1 text, f2 text, f3 text, f4 text) +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt14t (f1 text, f2 text, f3 text, f4 text)" +== 226 +-- truncate_limit: 100 +insert into tt14t values('foo', 'bar', 'baz', '42') +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt14t VALUES ('foo', 'bar', 'baz', '42')" +== 227 +-- truncate_limit: 100 +alter table tt14t drop column f2 +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt14t DROP f2" +== 228 +-- truncate_limit: 100 +create function tt14f() returns setof tt14t as +$$ +declare + rec1 record; +begin + for rec1 in select * from tt14t + loop + return next rec1; + end loop; +end; +$$ +language plpgsql +-- +FUNCTION: name="tt14f" function="tt14f" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tt14f() RETURNS SETOF tt14t AS $$\ndeclare\n rec1 record;\nbegin\n for rec1 in ..." +== 229 +-- truncate_limit: 100 +create view tt14v as select t.* from tt14f() t +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=DDL +FUNCTION: name="tt14f" function="tt14f" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt14v AS SELECT t.* FROM tt14f() t" +== 230 +-- truncate_limit: 100 +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt14v', true)" +== 231 +-- truncate_limit: 100 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt14v" +== 232 +-- truncate_limit: 100 +alter table tt14t drop column f3 +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt14t DROP f3" +== 233 +-- truncate_limit: 100 +-- fail, view has explicit reference to f3 + +-- We used to have a bug that would allow the above to succeed, posing +-- hazards for later execution of the view. Check that the internal +-- defenses for those hazards haven't bit-rotted, in case some other +-- bug with similar symptoms emerges. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 234 +-- truncate_limit: 100 +-- destroy the dependency entry that prevents the DROP: +delete from pg_depend where + objid = (select oid from pg_rewrite + where ev_class = 'tt14v'::regclass and rulename = '_RETURN') + and refobjsubid = 3 +returning pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as ref, + deptype +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=DML +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="rulename" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM pg_depend WHERE ... RETURNING pg_describe_object(classid, objid, objsubid) AS obj, pg..." +== 235 +-- truncate_limit: 100 +-- this will now succeed: +alter table tt14t drop column f3 +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt14t DROP f3" +== 236 +-- truncate_limit: 100 +-- column f3 is still in the view, sort of ... +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt14v', true)" +== 237 +-- truncate_limit: 100 +-- ... and you can even EXPLAIN it ... +explain (verbose, costs off) select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM tt14v" +== 238 +-- truncate_limit: 100 +-- but it will fail at execution +select f1, f4 from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, f4 FROM tt14v" +== 239 +-- truncate_limit: 100 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt14v" +== 240 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 241 +-- truncate_limit: 100 +-- likewise, altering a referenced column's type is prohibited ... +alter table tt14t alter column f4 type integer using f4::integer +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt14t ALTER COLUMN f4 TYPE int USING f4::int" +== 242 +-- truncate_limit: 100 +-- fail + +-- ... but some bug might let it happen, so check defenses +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 243 +-- truncate_limit: 100 +-- destroy the dependency entry that prevents the ALTER: +delete from pg_depend where + objid = (select oid from pg_rewrite + where ev_class = 'tt14v'::regclass and rulename = '_RETURN') + and refobjsubid = 4 +returning pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as ref, + deptype +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=DML +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="rulename" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM pg_depend WHERE ... RETURNING pg_describe_object(classid, objid, objsubid) AS obj, pg..." +== 244 +-- truncate_limit: 100 +-- this will now succeed: +alter table tt14t alter column f4 type integer using f4::integer +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt14t ALTER COLUMN f4 TYPE int USING f4::int" +== 245 +-- truncate_limit: 100 +-- f4 is still in the view ... +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt14v', true)" +== 246 +-- truncate_limit: 100 +-- but will fail at execution +select f1, f3 from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, f3 FROM tt14v" +== 247 +-- truncate_limit: 100 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt14v" +== 248 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 249 +-- truncate_limit: 100 +drop view tt14v +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW tt14v" +== 250 +-- truncate_limit: 100 +create view tt14v as select t.f1, t.f4 from tt14f() t +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=DDL +FUNCTION: name="tt14f" function="tt14f" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt14v AS SELECT t.f1, t.f4 FROM tt14f() t" +== 251 +-- truncate_limit: 100 +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt14v', true)" +== 252 +-- truncate_limit: 100 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt14v" +== 253 +-- truncate_limit: 100 +alter table tt14t drop column f3 +-- +TABLE: name="tt14t" schema="" table="tt14t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tt14t DROP f3" +== 254 +-- truncate_limit: 100 +-- ok + +select pg_get_viewdef('tt14v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt14v', true)" +== 255 +-- truncate_limit: 100 +explain (verbose, costs off) select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM tt14v" +== 256 +-- truncate_limit: 100 +select * from tt14v +-- +TABLE: name="tt14v" schema="" table="tt14v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt14v" +== 257 +-- truncate_limit: 100 +-- check display of whole-row variables in some corner cases + +create type nestedcomposite as (x int8_tbl) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE nestedcomposite AS (x int8_tbl)" +== 258 +-- truncate_limit: 100 +create view tt15v as select row(i)::nestedcomposite from int8_tbl i +-- +TABLE: name="tt15v" schema="" table="tt15v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt15v AS SELECT ROW(i)::nestedcomposite FROM int8_tbl i" +== 259 +-- truncate_limit: 100 +select * from tt15v +-- +TABLE: name="tt15v" schema="" table="tt15v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt15v" +== 260 +-- truncate_limit: 100 +select pg_get_viewdef('tt15v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt15v', true)" +== 261 +-- truncate_limit: 100 +select row(i.*::int8_tbl)::nestedcomposite from int8_tbl i +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ROW(i.*::int8_tbl)::nestedcomposite FROM int8_tbl i" +== 262 +-- truncate_limit: 100 +create view tt16v as select * from int8_tbl i, lateral(values(i)) ss +-- +TABLE: name="tt16v" schema="" table="tt16v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt16v AS SELECT * FROM int8_tbl i, LATERAL (VALUES (i)) ss" +== 263 +-- truncate_limit: 100 +select * from tt16v +-- +TABLE: name="tt16v" schema="" table="tt16v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt16v" +== 264 +-- truncate_limit: 100 +select pg_get_viewdef('tt16v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt16v', true)" +== 265 +-- truncate_limit: 100 +select * from int8_tbl i, lateral(values(i.*::int8_tbl)) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl i, LATERAL (VALUES (i.*::int8_tbl)) ss" +== 266 +-- truncate_limit: 100 +create view tt17v as select * from int8_tbl i where i in (values(i)) +-- +TABLE: name="tt17v" schema="" table="tt17v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +FILTER: schema="" table="" column="i" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt17v AS SELECT * FROM int8_tbl i WHERE i IN (VALUES (i))" +== 267 +-- truncate_limit: 100 +select * from tt17v +-- +TABLE: name="tt17v" schema="" table="tt17v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt17v" +== 268 +-- truncate_limit: 100 +select pg_get_viewdef('tt17v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt17v', true)" +== 269 +-- truncate_limit: 100 +select * from int8_tbl i where i.* in (values(i.*::int8_tbl)) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl i WHERE i.* IN (VALUES (i.*::int8_tbl))" +== 270 +-- truncate_limit: 100 +create table tt15v_log(o tt15v, n tt15v, incr bool) +-- +TABLE: name="tt15v_log" schema="" table="tt15v_log" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt15v_log (o tt15v, n tt15v, incr bool)" +== 271 +-- truncate_limit: 100 +create rule updlog as on update to tt15v do also + insert into tt15v_log values(old, new, row(old,old) < row(new,new)) +-- +TABLE: name="tt15v" schema="" table="tt15v" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE updlog AS ON UPDATE TO tt15v DO INSERT INTO tt15v_log VALUES (old, new, ROW(old, old)..." +== 272 +-- truncate_limit: 100 +-- check unique-ification of overlength names + +create view tt18v as + select * from int8_tbl xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy + union all + select * from int8_tbl xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz +-- +TABLE: name="tt18v" schema="" table="tt18v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"="int8_tbl" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt18v AS SELECT * FROM int8_tbl xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..." +== 273 +-- truncate_limit: 100 +select pg_get_viewdef('tt18v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt18v', true)" +== 274 +-- truncate_limit: 100 +explain (costs off) select * from tt18v +-- +TABLE: name="tt18v" schema="" table="tt18v" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tt18v" +== 275 +-- truncate_limit: 100 +-- check display of ScalarArrayOp with a sub-select + +select 'foo'::text = any(array['abc','def','foo']::text[]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo'::text = ANY(ARRAY['abc', 'def', 'foo']::text[])" +== 276 +-- truncate_limit: 100 +select 'foo'::text = any((select array['abc','def','foo']::text[])) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo'::text = ANY (SELECT ARRAY['abc', 'def', 'foo']::text[])" +== 277 +-- truncate_limit: 100 +-- fail +select 'foo'::text = any((select array['abc','def','foo']::text[])::text[]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo'::text = ANY((SELECT ARRAY['abc', 'def', 'foo']::text[])::text[])" +== 278 +-- truncate_limit: 100 +create view tt19v as +select 'foo'::text = any(array['abc','def','foo']::text[]) c1, + 'foo'::text = any((select array['abc','def','foo']::text[])::text[]) c2 +-- +TABLE: name="tt19v" schema="" table="tt19v" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt19v AS SELECT 'foo'::text = ANY(ARRAY['abc', 'def', 'foo']::text[]) AS c1, 'foo'::t..." +== 279 +-- truncate_limit: 100 +select pg_get_viewdef('tt19v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt19v', true)" +== 280 +-- truncate_limit: 100 +-- check display of assorted RTE_FUNCTION expressions + +create view tt20v as +select * from + coalesce(1,2) as c, + collation for ('x'::text) col, + current_date as d, + localtimestamp(3) as t, + cast(1+2 as int4) as i4, + cast(1+2 as int8) as i8 +-- +TABLE: name="tt20v" schema="" table="tt20v" ctx=DDL +FUNCTION: name="pg_catalog.pg_collation_for" function="pg_collation_for" schema="pg_catalog" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt20v AS SELECT * FROM COALESCE(1, 2) c, collation for ('x'::text) col, current_date ..." +== 281 +-- truncate_limit: 100 +select pg_get_viewdef('tt20v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt20v', true)" +== 282 +-- truncate_limit: 100 +-- reverse-listing of various special function syntaxes required by SQL + +create view tt201v as +select + ('2022-12-01'::date + '1 day'::interval) at time zone 'UTC' as atz, + extract(day from now()) as extr, + (now(), '1 day'::interval) overlaps + (current_timestamp(2), '1 day'::interval) as o, + 'foo' is normalized isn, + 'foo' is nfkc normalized isnn, + normalize('foo') as n, + normalize('foo', nfkd) as nfkd, + overlay('foo' placing 'bar' from 2) as ovl, + overlay('foo' placing 'bar' from 2 for 3) as ovl2, + position('foo' in 'foobar') as p, + substring('foo' from 2 for 3) as s, + substring('foo' similar 'f' escape '#') as ss, + substring('foo' from 'oo') as ssf, -- historically-permitted abuse + trim(' ' from ' foo ') as bt, + trim(leading ' ' from ' foo ') as lt, + trim(trailing ' foo ') as rt, + trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea) as btb, + trim(leading E'\\000'::bytea from E'\\000Tom\\000'::bytea) as ltb, + trim(trailing E'\\000'::bytea from E'\\000Tom\\000'::bytea) as rtb, + CURRENT_DATE as cd, + (select * from CURRENT_DATE) as cd2, + CURRENT_TIME as ct, + (select * from CURRENT_TIME) as ct2, + CURRENT_TIME (1) as ct3, + (select * from CURRENT_TIME (1)) as ct4, + CURRENT_TIMESTAMP as ct5, + (select * from CURRENT_TIMESTAMP) as ct6, + CURRENT_TIMESTAMP (1) as ct7, + (select * from CURRENT_TIMESTAMP (1)) as ct8, + LOCALTIME as lt1, + (select * from LOCALTIME) as lt2, + LOCALTIME (1) as lt3, + (select * from LOCALTIME (1)) as lt4, + LOCALTIMESTAMP as lt5, + (select * from LOCALTIMESTAMP) as lt6, + LOCALTIMESTAMP (1) as lt7, + (select * from LOCALTIMESTAMP (1)) as lt8, + CURRENT_CATALOG as ca, + (select * from CURRENT_CATALOG) as ca2, + CURRENT_ROLE as cr, + (select * from CURRENT_ROLE) as cr2, + CURRENT_SCHEMA as cs, + (select * from CURRENT_SCHEMA) as cs2, + CURRENT_USER as cu, + (select * from CURRENT_USER) as cu2, + USER as us, + (select * from USER) as us2, + SESSION_USER seu, + (select * from SESSION_USER) as seu2, + SYSTEM_USER as su, + (select * from SYSTEM_USER) as su2 +-- +TABLE: name="tt201v" schema="" table="tt201v" ctx=DDL +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.overlay" function="overlay" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.position" function="position" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.btrim" function="btrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.ltrim" function="ltrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.rtrim" function="rtrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.btrim" function="btrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.ltrim" function="ltrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.rtrim" function="rtrim" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.system_user" function="system_user" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.system_user" function="system_user" schema="pg_catalog" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt201v AS SELECT ('2022-12-01'::date + '1 day'::interval) AT TIME ZONE 'UTC' AS atz, ..." +== 283 +-- truncate_limit: 100 +select pg_get_viewdef('tt201v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt201v', true)" +== 284 +-- truncate_limit: 100 +-- corner cases with empty join conditions + +create view tt21v as +select * from tt5 natural inner join tt6 +-- +TABLE: name="tt21v" schema="" table="tt21v" ctx=DDL +TABLE: name="tt5" schema="" table="tt5" ctx=Select +TABLE: name="tt6" schema="" table="tt6" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt21v AS SELECT * FROM tt5 NATURAL JOIN tt6" +== 285 +-- truncate_limit: 100 +select pg_get_viewdef('tt21v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt21v', true)" +== 286 +-- truncate_limit: 100 +create view tt22v as +select * from tt5 natural left join tt6 +-- +TABLE: name="tt22v" schema="" table="tt22v" ctx=DDL +TABLE: name="tt5" schema="" table="tt5" ctx=Select +TABLE: name="tt6" schema="" table="tt6" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt22v AS SELECT * FROM tt5 NATURAL LEFT JOIN tt6" +== 287 +-- truncate_limit: 100 +select pg_get_viewdef('tt22v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt22v', true)" +== 288 +-- truncate_limit: 100 +-- check handling of views with immediately-renamed columns + +create view tt23v (col_a, col_b) as +select q1 as other_name1, q2 as other_name2 from int8_tbl +union +select 42, 43 +-- +TABLE: name="tt23v" schema="" table="tt23v" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt23v (col_a, col_b) AS SELECT q1 AS other_name1, q2 AS other_name2 FROM int8_tbl UNI..." +== 289 +-- truncate_limit: 100 +select pg_get_viewdef('tt23v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt23v', true)" +== 290 +-- truncate_limit: 100 +select pg_get_ruledef(oid, true) from pg_rewrite + where ev_class = 'tt23v'::regclass and ev_type = '1' +-- +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_get_ruledef" function="pg_get_ruledef" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="ev_type" +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_ruledef(oid, true) FROM pg_rewrite WHERE ..." +== 291 +-- truncate_limit: 100 +-- test extraction of FieldSelect field names (get_name_for_var_field) + +create view tt24v as +with cte as materialized (select r from (values(1,2),(3,4)) r) +select (r).column2 as col_a, (rr).column2 as col_b from + cte join (select rr from (values(1,7),(3,8)) rr limit 2) ss + on (r).column1 = (rr).column1 +-- +TABLE: name="tt24v" schema="" table="tt24v" ctx=DDL +CTE: "cte" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt24v AS WITH cte AS MATERIALIZED (SELECT r FROM (VALUES (1, 2), (3, 4)) r) SELECT (r..." +== 292 +-- truncate_limit: 100 +select pg_get_viewdef('tt24v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt24v', true)" +== 293 +-- truncate_limit: 100 +create view tt25v as +with cte as materialized (select pg_get_keywords() k) +select (k).word from cte +-- +TABLE: name="tt25v" schema="" table="tt25v" ctx=DDL +CTE: "cte" +FUNCTION: name="pg_get_keywords" function="pg_get_keywords" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt25v AS WITH cte AS MATERIALIZED (SELECT pg_get_keywords() AS k) SELECT (k).word FRO..." +== 294 +-- truncate_limit: 100 +select pg_get_viewdef('tt25v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt25v', true)" +== 295 +-- truncate_limit: 100 +-- also check cases seen only in EXPLAIN +explain (verbose, costs off) +select * from tt24v +-- +TABLE: name="tt24v" schema="" table="tt24v" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM tt24v" +== 296 +-- truncate_limit: 100 +explain (verbose, costs off) +select (r).column2 from (select r from (values(1,2),(3,4)) r limit 1) ss +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT (r).column2 FROM (SELECT r FROM (VALUES (1, 2), (3, 4)) r LIM..." +== 297 +-- truncate_limit: 100 +-- test pretty-print parenthesization rules, and SubLink deparsing + +create view tt26v as +select x + y + z as c1, + (x * y) + z as c2, + x + (y * z) as c3, + (x + y) * z as c4, + x * (y + z) as c5, + x + (y + z) as c6, + x + (y # z) as c7, + (x > y) AND (y > z OR x > z) as c8, + (x > y) OR (y > z AND NOT (x > z)) as c9, + (x,y) <> ALL (values(1,2),(3,4)) as c10, + (x,y) <= ANY (values(1,2),(3,4)) as c11 +from (values(1,2,3)) v(x,y,z) +-- +TABLE: name="tt26v" schema="" table="tt26v" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt26v AS SELECT (x + y) + z AS c1, (x * y) + z AS c2, x + (y * z) AS c3, (x + y) * z ..." +== 298 +-- truncate_limit: 100 +select pg_get_viewdef('tt26v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('tt26v', true)" +== 299 +-- truncate_limit: 100 +-- test restriction on non-system view expansion. +create table tt27v_tbl (a int) +-- +TABLE: name="tt27v_tbl" schema="" table="tt27v_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tt27v_tbl (a int)" +== 300 +-- truncate_limit: 100 +create view tt27v as select a from tt27v_tbl +-- +TABLE: name="tt27v" schema="" table="tt27v" ctx=DDL +TABLE: name="tt27v_tbl" schema="" table="tt27v_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tt27v AS SELECT a FROM tt27v_tbl" +== 301 +-- truncate_limit: 100 +set restrict_nonsystem_relation_kind to 'view' +-- +STMT: VariableSetStmt +TRUNCATED: "SET restrict_nonsystem_relation_kind TO view" +== 302 +-- truncate_limit: 100 +select a from tt27v where a > 0 +-- +TABLE: name="tt27v" schema="" table="tt27v" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM tt27v WHERE a > 0" +== 303 +-- truncate_limit: 100 +-- Error +insert into tt27v values (1) +-- +TABLE: name="tt27v" schema="" table="tt27v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt27v VALUES (1)" +== 304 +-- truncate_limit: 100 +-- Error +select viewname from pg_views where viewname = 'tt27v' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +TRUNCATED: "SELECT viewname FROM pg_views WHERE viewname = 'tt27v'" +== 305 +-- truncate_limit: 100 +-- Ok to access a system view. +reset restrict_nonsystem_relation_kind +-- +STMT: VariableSetStmt +TRUNCATED: "RESET restrict_nonsystem_relation_kind" +== 306 +-- truncate_limit: 100 +-- clean up all the random objects we made above +DROP SCHEMA temp_view_test CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA temp_view_test CASCADE" +== 307 +-- truncate_limit: 100 +DROP SCHEMA testviewschm2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA testviewschm2 CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/database.metadata.json b/parser/testdata/summary_truncate/postgres_regress/database.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/database.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/database.test b/parser/testdata/summary_truncate/postgres_regress/database.test new file mode 100644 index 0000000..82c36b1 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/database.test @@ -0,0 +1,104 @@ +== 001 +-- truncate_limit: 100 +CREATE DATABASE regression_tbd + ENCODING utf8 LC_COLLATE "C" LC_CTYPE "C" TEMPLATE template0 +-- +STMT: CreatedbStmt +TRUNCATED: "CREATE DATABASE regression_tbd ENCODING utf8 LC_COLLATE \"C\" LC_CTYPE \"C\" TEMPLATE template0" +== 002 +-- truncate_limit: 100 +ALTER DATABASE regression_tbd RENAME TO regression_utf8 +-- +STMT: RenameStmt +TRUNCATED: "ALTER DATABASE regression_tbd RENAME TO regression_utf8" +== 003 +-- truncate_limit: 100 +ALTER DATABASE regression_utf8 SET TABLESPACE regress_tblspace +-- +STMT: AlterDatabaseStmt +TRUNCATED: "ALTER DATABASE regression_utf8 TABLESPACE regress_tblspace" +== 004 +-- truncate_limit: 100 +ALTER DATABASE regression_utf8 RESET TABLESPACE +-- +STMT: AlterDatabaseSetStmt +TRUNCATED: "ALTER DATABASE regression_utf8 RESET tablespace" +== 005 +-- truncate_limit: 100 +ALTER DATABASE regression_utf8 CONNECTION_LIMIT 123 +-- +STMT: AlterDatabaseStmt +TRUNCATED: "ALTER DATABASE regression_utf8 CONNECTION LIMIT 123" +== 006 +-- truncate_limit: 100 +-- Test PgDatabaseToastTable. Doing this with GRANT would be slow. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 007 +-- truncate_limit: 100 +UPDATE pg_database +SET datacl = array_fill(makeaclitem(10, 10, 'USAGE', false), ARRAY[5e5::int]) +WHERE datname = 'regression_utf8' +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=DML +FUNCTION: name="array_fill" function="array_fill" schema="" ctx=Call +FUNCTION: name="makeaclitem" function="makeaclitem" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE pg_database SET ... = ... WHERE datname = 'regression_utf8'" +== 008 +-- truncate_limit: 100 +-- load catcache entry, if nothing else does +ALTER DATABASE regression_utf8 RESET TABLESPACE +-- +STMT: AlterDatabaseSetStmt +TRUNCATED: "ALTER DATABASE regression_utf8 RESET tablespace" +== 009 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 010 +-- truncate_limit: 100 +CREATE ROLE regress_datdba_before +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_datdba_before" +== 011 +-- truncate_limit: 100 +CREATE ROLE regress_datdba_after +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_datdba_after" +== 012 +-- truncate_limit: 100 +ALTER DATABASE regression_utf8 OWNER TO regress_datdba_before +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER DATABASE regression_utf8 OWNER TO regress_datdba_before" +== 013 +-- truncate_limit: 100 +REASSIGN OWNED BY regress_datdba_before TO regress_datdba_after +-- +STMT: ReassignOwnedStmt +TRUNCATED: "REASSIGN OWNED BY regress_datdba_before TO regress_datdba_after" +== 014 +-- truncate_limit: 100 +DROP DATABASE regression_utf8 +-- +STMT: DropdbStmt +TRUNCATED: "DROP DATABASE regression_utf8" +== 015 +-- truncate_limit: 100 +DROP ROLE regress_datdba_before +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_datdba_before" +== 016 +-- truncate_limit: 100 +DROP ROLE regress_datdba_after +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_datdba_after" diff --git a/parser/testdata/summary_truncate/postgres_regress/date.metadata.json b/parser/testdata/summary_truncate/postgres_regress/date.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/date.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/date.test b/parser/testdata/summary_truncate/postgres_regress/date.test new file mode 100644 index 0000000..258d36e --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/date.test @@ -0,0 +1,1902 @@ +== 001 +-- truncate_limit: 100 +|-- +-- DATE +|-- + +CREATE TABLE DATE_TBL (f1 date) +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE date_tbl (f1 date)" +== 002 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1957-04-09') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1957-04-09')" +== 003 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1957-06-13') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1957-06-13')" +== 004 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1996-02-28') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1996-02-28')" +== 005 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1996-02-29') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1996-02-29')" +== 006 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1996-03-01') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1996-03-01')" +== 007 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1996-03-02') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1996-03-02')" +== 008 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1997-02-28') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1997-02-28')" +== 009 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1997-02-29') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1997-02-29')" +== 010 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1997-03-01') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1997-03-01')" +== 011 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('1997-03-02') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('1997-03-02')" +== 012 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('2000-04-01') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('2000-04-01')" +== 013 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('2000-04-02') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('2000-04-02')" +== 014 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('2000-04-03') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('2000-04-03')" +== 015 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('2038-04-08') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('2038-04-08')" +== 016 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('2039-04-09') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('2039-04-09')" +== 017 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('2040-04-10') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('2040-04-10')" +== 018 +-- truncate_limit: 100 +INSERT INTO DATE_TBL VALUES ('2040-04-10 BC') +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO date_tbl VALUES ('2040-04-10 BC')" +== 019 +-- truncate_limit: 100 +SELECT f1 FROM DATE_TBL +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM date_tbl" +== 020 +-- truncate_limit: 100 +SELECT f1 FROM DATE_TBL WHERE f1 < '2000-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM date_tbl WHERE f1 < '2000-01-01'" +== 021 +-- truncate_limit: 100 +SELECT f1 FROM DATE_TBL + WHERE f1 BETWEEN '2000-01-01' AND '2001-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM date_tbl WHERE f1 BETWEEN '2000-01-01' AND '2001-01-01'" +== 022 +-- truncate_limit: 100 +|-- +-- Check all the documented input formats +|-- +SET datestyle TO iso +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO iso" +== 023 +-- truncate_limit: 100 +-- display results in ISO + +SET datestyle TO ymd +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO ymd" +== 024 +-- truncate_limit: 100 +SELECT date 'January 8, 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'January 8, 1999'::date" +== 025 +-- truncate_limit: 100 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-08'::date" +== 026 +-- truncate_limit: 100 +SELECT date '1999-01-18' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-18'::date" +== 027 +-- truncate_limit: 100 +SELECT date '1/8/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1/8/1999'::date" +== 028 +-- truncate_limit: 100 +SELECT date '1/18/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1/18/1999'::date" +== 029 +-- truncate_limit: 100 +SELECT date '18/1/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '18/1/1999'::date" +== 030 +-- truncate_limit: 100 +SELECT date '01/02/03' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01/02/03'::date" +== 031 +-- truncate_limit: 100 +SELECT date '19990108' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '19990108'::date" +== 032 +-- truncate_limit: 100 +SELECT date '990108' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '990108'::date" +== 033 +-- truncate_limit: 100 +SELECT date '1999.008' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999.008'::date" +== 034 +-- truncate_limit: 100 +SELECT date 'J2451187' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2451187'::date" +== 035 +-- truncate_limit: 100 +SELECT date 'January 8, 99 BC' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'January 8, 99 BC'::date" +== 036 +-- truncate_limit: 100 +SELECT date '99-Jan-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-Jan-08'::date" +== 037 +-- truncate_limit: 100 +SELECT date '1999-Jan-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-Jan-08'::date" +== 038 +-- truncate_limit: 100 +SELECT date '08-Jan-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-Jan-99'::date" +== 039 +-- truncate_limit: 100 +SELECT date '08-Jan-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-Jan-1999'::date" +== 040 +-- truncate_limit: 100 +SELECT date 'Jan-08-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan-08-99'::date" +== 041 +-- truncate_limit: 100 +SELECT date 'Jan-08-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan-08-1999'::date" +== 042 +-- truncate_limit: 100 +SELECT date '99-08-Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-08-Jan'::date" +== 043 +-- truncate_limit: 100 +SELECT date '1999-08-Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-08-Jan'::date" +== 044 +-- truncate_limit: 100 +SELECT date '99 Jan 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 Jan 08'::date" +== 045 +-- truncate_limit: 100 +SELECT date '1999 Jan 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 Jan 08'::date" +== 046 +-- truncate_limit: 100 +SELECT date '08 Jan 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 Jan 99'::date" +== 047 +-- truncate_limit: 100 +SELECT date '08 Jan 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 Jan 1999'::date" +== 048 +-- truncate_limit: 100 +SELECT date 'Jan 08 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 08 99'::date" +== 049 +-- truncate_limit: 100 +SELECT date 'Jan 08 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 08 1999'::date" +== 050 +-- truncate_limit: 100 +SELECT date '99 08 Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 08 Jan'::date" +== 051 +-- truncate_limit: 100 +SELECT date '1999 08 Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 08 Jan'::date" +== 052 +-- truncate_limit: 100 +SELECT date '99-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-01-08'::date" +== 053 +-- truncate_limit: 100 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-08'::date" +== 054 +-- truncate_limit: 100 +SELECT date '08-01-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-01-99'::date" +== 055 +-- truncate_limit: 100 +SELECT date '08-01-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-01-1999'::date" +== 056 +-- truncate_limit: 100 +SELECT date '01-08-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01-08-99'::date" +== 057 +-- truncate_limit: 100 +SELECT date '01-08-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01-08-1999'::date" +== 058 +-- truncate_limit: 100 +SELECT date '99-08-01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-08-01'::date" +== 059 +-- truncate_limit: 100 +SELECT date '1999-08-01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-08-01'::date" +== 060 +-- truncate_limit: 100 +SELECT date '99 01 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 01 08'::date" +== 061 +-- truncate_limit: 100 +SELECT date '1999 01 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 01 08'::date" +== 062 +-- truncate_limit: 100 +SELECT date '08 01 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 01 99'::date" +== 063 +-- truncate_limit: 100 +SELECT date '08 01 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 01 1999'::date" +== 064 +-- truncate_limit: 100 +SELECT date '01 08 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01 08 99'::date" +== 065 +-- truncate_limit: 100 +SELECT date '01 08 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01 08 1999'::date" +== 066 +-- truncate_limit: 100 +SELECT date '99 08 01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 08 01'::date" +== 067 +-- truncate_limit: 100 +SELECT date '1999 08 01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 08 01'::date" +== 068 +-- truncate_limit: 100 +SET datestyle TO dmy +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO dmy" +== 069 +-- truncate_limit: 100 +SELECT date 'January 8, 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'January 8, 1999'::date" +== 070 +-- truncate_limit: 100 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-08'::date" +== 071 +-- truncate_limit: 100 +SELECT date '1999-01-18' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-18'::date" +== 072 +-- truncate_limit: 100 +SELECT date '1/8/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1/8/1999'::date" +== 073 +-- truncate_limit: 100 +SELECT date '1/18/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1/18/1999'::date" +== 074 +-- truncate_limit: 100 +SELECT date '18/1/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '18/1/1999'::date" +== 075 +-- truncate_limit: 100 +SELECT date '01/02/03' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01/02/03'::date" +== 076 +-- truncate_limit: 100 +SELECT date '19990108' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '19990108'::date" +== 077 +-- truncate_limit: 100 +SELECT date '990108' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '990108'::date" +== 078 +-- truncate_limit: 100 +SELECT date '1999.008' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999.008'::date" +== 079 +-- truncate_limit: 100 +SELECT date 'J2451187' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2451187'::date" +== 080 +-- truncate_limit: 100 +SELECT date 'January 8, 99 BC' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'January 8, 99 BC'::date" +== 081 +-- truncate_limit: 100 +SELECT date '99-Jan-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-Jan-08'::date" +== 082 +-- truncate_limit: 100 +SELECT date '1999-Jan-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-Jan-08'::date" +== 083 +-- truncate_limit: 100 +SELECT date '08-Jan-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-Jan-99'::date" +== 084 +-- truncate_limit: 100 +SELECT date '08-Jan-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-Jan-1999'::date" +== 085 +-- truncate_limit: 100 +SELECT date 'Jan-08-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan-08-99'::date" +== 086 +-- truncate_limit: 100 +SELECT date 'Jan-08-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan-08-1999'::date" +== 087 +-- truncate_limit: 100 +SELECT date '99-08-Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-08-Jan'::date" +== 088 +-- truncate_limit: 100 +SELECT date '1999-08-Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-08-Jan'::date" +== 089 +-- truncate_limit: 100 +SELECT date '99 Jan 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 Jan 08'::date" +== 090 +-- truncate_limit: 100 +SELECT date '1999 Jan 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 Jan 08'::date" +== 091 +-- truncate_limit: 100 +SELECT date '08 Jan 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 Jan 99'::date" +== 092 +-- truncate_limit: 100 +SELECT date '08 Jan 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 Jan 1999'::date" +== 093 +-- truncate_limit: 100 +SELECT date 'Jan 08 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 08 99'::date" +== 094 +-- truncate_limit: 100 +SELECT date 'Jan 08 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 08 1999'::date" +== 095 +-- truncate_limit: 100 +SELECT date '99 08 Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 08 Jan'::date" +== 096 +-- truncate_limit: 100 +SELECT date '1999 08 Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 08 Jan'::date" +== 097 +-- truncate_limit: 100 +SELECT date '99-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-01-08'::date" +== 098 +-- truncate_limit: 100 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-08'::date" +== 099 +-- truncate_limit: 100 +SELECT date '08-01-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-01-99'::date" +== 100 +-- truncate_limit: 100 +SELECT date '08-01-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-01-1999'::date" +== 101 +-- truncate_limit: 100 +SELECT date '01-08-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01-08-99'::date" +== 102 +-- truncate_limit: 100 +SELECT date '01-08-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01-08-1999'::date" +== 103 +-- truncate_limit: 100 +SELECT date '99-08-01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-08-01'::date" +== 104 +-- truncate_limit: 100 +SELECT date '1999-08-01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-08-01'::date" +== 105 +-- truncate_limit: 100 +SELECT date '99 01 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 01 08'::date" +== 106 +-- truncate_limit: 100 +SELECT date '1999 01 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 01 08'::date" +== 107 +-- truncate_limit: 100 +SELECT date '08 01 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 01 99'::date" +== 108 +-- truncate_limit: 100 +SELECT date '08 01 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 01 1999'::date" +== 109 +-- truncate_limit: 100 +SELECT date '01 08 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01 08 99'::date" +== 110 +-- truncate_limit: 100 +SELECT date '01 08 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01 08 1999'::date" +== 111 +-- truncate_limit: 100 +SELECT date '99 08 01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 08 01'::date" +== 112 +-- truncate_limit: 100 +SELECT date '1999 08 01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 08 01'::date" +== 113 +-- truncate_limit: 100 +SET datestyle TO mdy +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO mdy" +== 114 +-- truncate_limit: 100 +SELECT date 'January 8, 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'January 8, 1999'::date" +== 115 +-- truncate_limit: 100 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-08'::date" +== 116 +-- truncate_limit: 100 +SELECT date '1999-01-18' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-18'::date" +== 117 +-- truncate_limit: 100 +SELECT date '1/8/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1/8/1999'::date" +== 118 +-- truncate_limit: 100 +SELECT date '1/18/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1/18/1999'::date" +== 119 +-- truncate_limit: 100 +SELECT date '18/1/1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '18/1/1999'::date" +== 120 +-- truncate_limit: 100 +SELECT date '01/02/03' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01/02/03'::date" +== 121 +-- truncate_limit: 100 +SELECT date '19990108' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '19990108'::date" +== 122 +-- truncate_limit: 100 +SELECT date '990108' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '990108'::date" +== 123 +-- truncate_limit: 100 +SELECT date '1999.008' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999.008'::date" +== 124 +-- truncate_limit: 100 +SELECT date 'J2451187' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2451187'::date" +== 125 +-- truncate_limit: 100 +SELECT date 'January 8, 99 BC' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'January 8, 99 BC'::date" +== 126 +-- truncate_limit: 100 +SELECT date '99-Jan-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-Jan-08'::date" +== 127 +-- truncate_limit: 100 +SELECT date '1999-Jan-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-Jan-08'::date" +== 128 +-- truncate_limit: 100 +SELECT date '08-Jan-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-Jan-99'::date" +== 129 +-- truncate_limit: 100 +SELECT date '08-Jan-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-Jan-1999'::date" +== 130 +-- truncate_limit: 100 +SELECT date 'Jan-08-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan-08-99'::date" +== 131 +-- truncate_limit: 100 +SELECT date 'Jan-08-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan-08-1999'::date" +== 132 +-- truncate_limit: 100 +SELECT date '99-08-Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-08-Jan'::date" +== 133 +-- truncate_limit: 100 +SELECT date '1999-08-Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-08-Jan'::date" +== 134 +-- truncate_limit: 100 +SELECT date '99 Jan 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 Jan 08'::date" +== 135 +-- truncate_limit: 100 +SELECT date '1999 Jan 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 Jan 08'::date" +== 136 +-- truncate_limit: 100 +SELECT date '08 Jan 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 Jan 99'::date" +== 137 +-- truncate_limit: 100 +SELECT date '08 Jan 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 Jan 1999'::date" +== 138 +-- truncate_limit: 100 +SELECT date 'Jan 08 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 08 99'::date" +== 139 +-- truncate_limit: 100 +SELECT date 'Jan 08 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 08 1999'::date" +== 140 +-- truncate_limit: 100 +SELECT date '99 08 Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 08 Jan'::date" +== 141 +-- truncate_limit: 100 +SELECT date '1999 08 Jan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 08 Jan'::date" +== 142 +-- truncate_limit: 100 +SELECT date '99-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-01-08'::date" +== 143 +-- truncate_limit: 100 +SELECT date '1999-01-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-01-08'::date" +== 144 +-- truncate_limit: 100 +SELECT date '08-01-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-01-99'::date" +== 145 +-- truncate_limit: 100 +SELECT date '08-01-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-01-1999'::date" +== 146 +-- truncate_limit: 100 +SELECT date '01-08-99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01-08-99'::date" +== 147 +-- truncate_limit: 100 +SELECT date '01-08-1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01-08-1999'::date" +== 148 +-- truncate_limit: 100 +SELECT date '99-08-01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99-08-01'::date" +== 149 +-- truncate_limit: 100 +SELECT date '1999-08-01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-08-01'::date" +== 150 +-- truncate_limit: 100 +SELECT date '99 01 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 01 08'::date" +== 151 +-- truncate_limit: 100 +SELECT date '1999 01 08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 01 08'::date" +== 152 +-- truncate_limit: 100 +SELECT date '08 01 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 01 99'::date" +== 153 +-- truncate_limit: 100 +SELECT date '08 01 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08 01 1999'::date" +== 154 +-- truncate_limit: 100 +SELECT date '01 08 99' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01 08 99'::date" +== 155 +-- truncate_limit: 100 +SELECT date '01 08 1999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01 08 1999'::date" +== 156 +-- truncate_limit: 100 +SELECT date '99 08 01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '99 08 01'::date" +== 157 +-- truncate_limit: 100 +SELECT date '1999 08 01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999 08 01'::date" +== 158 +-- truncate_limit: 100 +-- Check upper and lower limits of date range +SELECT date '4714-11-24 BC' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-24 BC'::date" +== 159 +-- truncate_limit: 100 +SELECT date '4714-11-23 BC' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-23 BC'::date" +== 160 +-- truncate_limit: 100 +-- out of range +SELECT date '5874897-12-31' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '5874897-12-31'::date" +== 161 +-- truncate_limit: 100 +SELECT date '5874898-01-01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '5874898-01-01'::date" +== 162 +-- truncate_limit: 100 +-- out of range + +-- Test non-error-throwing API +SELECT pg_input_is_valid('now', 'date') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('now', 'date')" +== 163 +-- truncate_limit: 100 +SELECT pg_input_is_valid('garbage', 'date') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('garbage', 'date')" +== 164 +-- truncate_limit: 100 +SELECT pg_input_is_valid('6874898-01-01', 'date') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('6874898-01-01', 'date')" +== 165 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('garbage', 'date') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('garbage', 'date')" +== 166 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('6874898-01-01', 'date') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('6874898-01-01', 'date')" +== 167 +-- truncate_limit: 100 +RESET datestyle +-- +STMT: VariableSetStmt +TRUNCATED: "RESET datestyle" +== 168 +-- truncate_limit: 100 +|-- +-- Simple math +-- Leave most of it for the horology tests +|-- + +SELECT f1 - date '2000-01-01' AS "Days From 2K" FROM DATE_TBL +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 - '2000-01-01'::date AS \"Days From 2K\" FROM date_tbl" +== 169 +-- truncate_limit: 100 +SELECT f1 - date 'epoch' AS "Days From Epoch" FROM DATE_TBL +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 - 'epoch'::date AS \"Days From Epoch\" FROM date_tbl" +== 170 +-- truncate_limit: 100 +SELECT date 'yesterday' - date 'today' AS "One day" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'yesterday'::date - 'today'::date AS \"One day\"" +== 171 +-- truncate_limit: 100 +SELECT date 'today' - date 'tomorrow' AS "One day" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'today'::date - 'tomorrow'::date AS \"One day\"" +== 172 +-- truncate_limit: 100 +SELECT date 'yesterday' - date 'tomorrow' AS "Two days" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'yesterday'::date - 'tomorrow'::date AS \"Two days\"" +== 173 +-- truncate_limit: 100 +SELECT date 'tomorrow' - date 'today' AS "One day" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'tomorrow'::date - 'today'::date AS \"One day\"" +== 174 +-- truncate_limit: 100 +SELECT date 'today' - date 'yesterday' AS "One day" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'today'::date - 'yesterday'::date AS \"One day\"" +== 175 +-- truncate_limit: 100 +SELECT date 'tomorrow' - date 'yesterday' AS "Two days" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'tomorrow'::date - 'yesterday'::date AS \"Two days\"" +== 176 +-- truncate_limit: 100 +|-- +-- test extract! +|-- +SELECT f1 as "date", + date_part('year', f1) AS year, + date_part('month', f1) AS month, + date_part('day', f1) AS day, + date_part('quarter', f1) AS quarter, + date_part('decade', f1) AS decade, + date_part('century', f1) AS century, + date_part('millennium', f1) AS millennium, + date_part('isoyear', f1) AS isoyear, + date_part('week', f1) AS week, + date_part('dow', f1) AS dow, + date_part('isodow', f1) AS isodow, + date_part('doy', f1) AS doy, + date_part('julian', f1) AS julian, + date_part('epoch', f1) AS epoch + FROM date_tbl +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM date_tbl" +== 177 +-- truncate_limit: 100 +|-- +-- epoch +|-- +SELECT EXTRACT(EPOCH FROM DATE '1970-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '1970-01-01'::date)" +== 178 +-- truncate_limit: 100 +-- 0 +|-- +-- century +|-- +SELECT EXTRACT(CENTURY FROM DATE '0101-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '0101-12-31 BC'::date)" +== 179 +-- truncate_limit: 100 +-- -2 +SELECT EXTRACT(CENTURY FROM DATE '0100-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '0100-12-31 BC'::date)" +== 180 +-- truncate_limit: 100 +-- -1 +SELECT EXTRACT(CENTURY FROM DATE '0001-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '0001-12-31 BC'::date)" +== 181 +-- truncate_limit: 100 +-- -1 +SELECT EXTRACT(CENTURY FROM DATE '0001-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '0001-01-01'::date)" +== 182 +-- truncate_limit: 100 +-- 1 +SELECT EXTRACT(CENTURY FROM DATE '0001-01-01 AD') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '0001-01-01 AD'::date)" +== 183 +-- truncate_limit: 100 +-- 1 +SELECT EXTRACT(CENTURY FROM DATE '1900-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '1900-12-31'::date)" +== 184 +-- truncate_limit: 100 +-- 19 +SELECT EXTRACT(CENTURY FROM DATE '1901-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '1901-01-01'::date)" +== 185 +-- truncate_limit: 100 +-- 20 +SELECT EXTRACT(CENTURY FROM DATE '2000-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '2000-12-31'::date)" +== 186 +-- truncate_limit: 100 +-- 20 +SELECT EXTRACT(CENTURY FROM DATE '2001-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '2001-01-01'::date)" +== 187 +-- truncate_limit: 100 +-- 21 +SELECT EXTRACT(CENTURY FROM CURRENT_DATE)>=21 AS True +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM current_date) >= 21 AS \"true\"" +== 188 +-- truncate_limit: 100 +-- true +|-- +-- millennium +|-- +SELECT EXTRACT(MILLENNIUM FROM DATE '0001-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM '0001-12-31 BC'::date)" +== 189 +-- truncate_limit: 100 +-- -1 +SELECT EXTRACT(MILLENNIUM FROM DATE '0001-01-01 AD') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM '0001-01-01 AD'::date)" +== 190 +-- truncate_limit: 100 +-- 1 +SELECT EXTRACT(MILLENNIUM FROM DATE '1000-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM '1000-12-31'::date)" +== 191 +-- truncate_limit: 100 +-- 1 +SELECT EXTRACT(MILLENNIUM FROM DATE '1001-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM '1001-01-01'::date)" +== 192 +-- truncate_limit: 100 +-- 2 +SELECT EXTRACT(MILLENNIUM FROM DATE '2000-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM '2000-12-31'::date)" +== 193 +-- truncate_limit: 100 +-- 2 +SELECT EXTRACT(MILLENNIUM FROM DATE '2001-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM '2001-01-01'::date)" +== 194 +-- truncate_limit: 100 +-- 3 +-- next test to be fixed on the turn of the next millennium;-) +SELECT EXTRACT(MILLENNIUM FROM CURRENT_DATE) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM current_date)" +== 195 +-- truncate_limit: 100 +-- 3 +|-- +-- decade +|-- +SELECT EXTRACT(DECADE FROM DATE '1994-12-25') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '1994-12-25'::date)" +== 196 +-- truncate_limit: 100 +-- 199 +SELECT EXTRACT(DECADE FROM DATE '0010-01-01') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '0010-01-01'::date)" +== 197 +-- truncate_limit: 100 +-- 1 +SELECT EXTRACT(DECADE FROM DATE '0009-12-31') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '0009-12-31'::date)" +== 198 +-- truncate_limit: 100 +-- 0 +SELECT EXTRACT(DECADE FROM DATE '0001-01-01 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '0001-01-01 BC'::date)" +== 199 +-- truncate_limit: 100 +-- 0 +SELECT EXTRACT(DECADE FROM DATE '0002-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '0002-12-31 BC'::date)" +== 200 +-- truncate_limit: 100 +-- -1 +SELECT EXTRACT(DECADE FROM DATE '0011-01-01 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '0011-01-01 BC'::date)" +== 201 +-- truncate_limit: 100 +-- -1 +SELECT EXTRACT(DECADE FROM DATE '0012-12-31 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '0012-12-31 BC'::date)" +== 202 +-- truncate_limit: 100 +-- -2 +|-- +-- all possible fields +|-- +SELECT EXTRACT(MICROSECONDS FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('microseconds' FROM '2020-08-11'::date)" +== 203 +-- truncate_limit: 100 +SELECT EXTRACT(MILLISECONDS FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('milliseconds' FROM '2020-08-11'::date)" +== 204 +-- truncate_limit: 100 +SELECT EXTRACT(SECOND FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('second' FROM '2020-08-11'::date)" +== 205 +-- truncate_limit: 100 +SELECT EXTRACT(MINUTE FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('minute' FROM '2020-08-11'::date)" +== 206 +-- truncate_limit: 100 +SELECT EXTRACT(HOUR FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('hour' FROM '2020-08-11'::date)" +== 207 +-- truncate_limit: 100 +SELECT EXTRACT(DAY FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('day' FROM '2020-08-11'::date)" +== 208 +-- truncate_limit: 100 +SELECT EXTRACT(MONTH FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('month' FROM '2020-08-11'::date)" +== 209 +-- truncate_limit: 100 +SELECT EXTRACT(YEAR FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('year' FROM '2020-08-11'::date)" +== 210 +-- truncate_limit: 100 +SELECT EXTRACT(YEAR FROM DATE '2020-08-11 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('year' FROM '2020-08-11 BC'::date)" +== 211 +-- truncate_limit: 100 +SELECT EXTRACT(DECADE FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '2020-08-11'::date)" +== 212 +-- truncate_limit: 100 +SELECT EXTRACT(CENTURY FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '2020-08-11'::date)" +== 213 +-- truncate_limit: 100 +SELECT EXTRACT(MILLENNIUM FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM '2020-08-11'::date)" +== 214 +-- truncate_limit: 100 +SELECT EXTRACT(ISOYEAR FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('isoyear' FROM '2020-08-11'::date)" +== 215 +-- truncate_limit: 100 +SELECT EXTRACT(ISOYEAR FROM DATE '2020-08-11 BC') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('isoyear' FROM '2020-08-11 BC'::date)" +== 216 +-- truncate_limit: 100 +SELECT EXTRACT(QUARTER FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('quarter' FROM '2020-08-11'::date)" +== 217 +-- truncate_limit: 100 +SELECT EXTRACT(WEEK FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('week' FROM '2020-08-11'::date)" +== 218 +-- truncate_limit: 100 +SELECT EXTRACT(DOW FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('dow' FROM '2020-08-11'::date)" +== 219 +-- truncate_limit: 100 +SELECT EXTRACT(DOW FROM DATE '2020-08-16') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('dow' FROM '2020-08-16'::date)" +== 220 +-- truncate_limit: 100 +SELECT EXTRACT(ISODOW FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('isodow' FROM '2020-08-11'::date)" +== 221 +-- truncate_limit: 100 +SELECT EXTRACT(ISODOW FROM DATE '2020-08-16') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('isodow' FROM '2020-08-16'::date)" +== 222 +-- truncate_limit: 100 +SELECT EXTRACT(DOY FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('doy' FROM '2020-08-11'::date)" +== 223 +-- truncate_limit: 100 +SELECT EXTRACT(TIMEZONE FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('timezone' FROM '2020-08-11'::date)" +== 224 +-- truncate_limit: 100 +SELECT EXTRACT(TIMEZONE_M FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('timezone_m' FROM '2020-08-11'::date)" +== 225 +-- truncate_limit: 100 +SELECT EXTRACT(TIMEZONE_H FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('timezone_h' FROM '2020-08-11'::date)" +== 226 +-- truncate_limit: 100 +SELECT EXTRACT(EPOCH FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '2020-08-11'::date)" +== 227 +-- truncate_limit: 100 +SELECT EXTRACT(JULIAN FROM DATE '2020-08-11') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('julian' FROM '2020-08-11'::date)" +== 228 +-- truncate_limit: 100 +|-- +-- test trunc function! +|-- +SELECT DATE_TRUNC('MILLENNIUM', TIMESTAMP '1970-03-20 04:30:00.00000') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('MILLENNIUM', '1970-03-20 04:30:00.00000'::timestamp)" +== 229 +-- truncate_limit: 100 +-- 1001 +SELECT DATE_TRUNC('MILLENNIUM', DATE '1970-03-20') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('MILLENNIUM', '1970-03-20'::date)" +== 230 +-- truncate_limit: 100 +-- 1001-01-01 +SELECT DATE_TRUNC('CENTURY', TIMESTAMP '1970-03-20 04:30:00.00000') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('CENTURY', '1970-03-20 04:30:00.00000'::timestamp)" +== 231 +-- truncate_limit: 100 +-- 1901 +SELECT DATE_TRUNC('CENTURY', DATE '1970-03-20') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('CENTURY', '1970-03-20'::date)" +== 232 +-- truncate_limit: 100 +-- 1901 +SELECT DATE_TRUNC('CENTURY', DATE '2004-08-10') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('CENTURY', '2004-08-10'::date)" +== 233 +-- truncate_limit: 100 +-- 2001-01-01 +SELECT DATE_TRUNC('CENTURY', DATE '0002-02-04') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('CENTURY', '0002-02-04'::date)" +== 234 +-- truncate_limit: 100 +-- 0001-01-01 +SELECT DATE_TRUNC('CENTURY', DATE '0055-08-10 BC') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('CENTURY', '0055-08-10 BC'::date)" +== 235 +-- truncate_limit: 100 +-- 0100-01-01 BC +SELECT DATE_TRUNC('DECADE', DATE '1993-12-25') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('DECADE', '1993-12-25'::date)" +== 236 +-- truncate_limit: 100 +-- 1990-01-01 +SELECT DATE_TRUNC('DECADE', DATE '0004-12-25') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('DECADE', '0004-12-25'::date)" +== 237 +-- truncate_limit: 100 +-- 0001-01-01 BC +SELECT DATE_TRUNC('DECADE', DATE '0002-12-31 BC') +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('DECADE', '0002-12-31 BC'::date)" +== 238 +-- truncate_limit: 100 +-- 0011-01-01 BC +|-- +-- test infinity +|-- +select 'infinity'::date, '-infinity'::date +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::date, '-infinity'::date" +== 239 +-- truncate_limit: 100 +select 'infinity'::date > 'today'::date as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::date > 'today'::date AS t" +== 240 +-- truncate_limit: 100 +select '-infinity'::date < 'today'::date as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::date < 'today'::date AS t" +== 241 +-- truncate_limit: 100 +select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'::date) +-- +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'::date)" +== 242 +-- truncate_limit: 100 +select 'infinity'::date = '+infinity'::date as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::date = '+infinity'::date AS t" +== 243 +-- truncate_limit: 100 +|-- +-- oscillating fields from non-finite date: +|-- +SELECT EXTRACT(DAY FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('day' FROM 'infinity'::date)" +== 244 +-- truncate_limit: 100 +-- NULL +SELECT EXTRACT(DAY FROM DATE '-infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('day' FROM '-infinity'::date)" +== 245 +-- truncate_limit: 100 +-- NULL +-- all supported fields +SELECT EXTRACT(DAY FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('day' FROM 'infinity'::date)" +== 246 +-- truncate_limit: 100 +-- NULL +SELECT EXTRACT(MONTH FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('month' FROM 'infinity'::date)" +== 247 +-- truncate_limit: 100 +-- NULL +SELECT EXTRACT(QUARTER FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('quarter' FROM 'infinity'::date)" +== 248 +-- truncate_limit: 100 +-- NULL +SELECT EXTRACT(WEEK FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('week' FROM 'infinity'::date)" +== 249 +-- truncate_limit: 100 +-- NULL +SELECT EXTRACT(DOW FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('dow' FROM 'infinity'::date)" +== 250 +-- truncate_limit: 100 +-- NULL +SELECT EXTRACT(ISODOW FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('isodow' FROM 'infinity'::date)" +== 251 +-- truncate_limit: 100 +-- NULL +SELECT EXTRACT(DOY FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('doy' FROM 'infinity'::date)" +== 252 +-- truncate_limit: 100 +-- NULL +|-- +-- monotonic fields from non-finite date: +|-- +SELECT EXTRACT(EPOCH FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM 'infinity'::date)" +== 253 +-- truncate_limit: 100 +-- Infinity +SELECT EXTRACT(EPOCH FROM DATE '-infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '-infinity'::date)" +== 254 +-- truncate_limit: 100 +-- -Infinity +-- all supported fields +SELECT EXTRACT(YEAR FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('year' FROM 'infinity'::date)" +== 255 +-- truncate_limit: 100 +-- Infinity +SELECT EXTRACT(DECADE FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM 'infinity'::date)" +== 256 +-- truncate_limit: 100 +-- Infinity +SELECT EXTRACT(CENTURY FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM 'infinity'::date)" +== 257 +-- truncate_limit: 100 +-- Infinity +SELECT EXTRACT(MILLENNIUM FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millennium' FROM 'infinity'::date)" +== 258 +-- truncate_limit: 100 +-- Infinity +SELECT EXTRACT(JULIAN FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('julian' FROM 'infinity'::date)" +== 259 +-- truncate_limit: 100 +-- Infinity +SELECT EXTRACT(ISOYEAR FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('isoyear' FROM 'infinity'::date)" +== 260 +-- truncate_limit: 100 +-- Infinity +SELECT EXTRACT(EPOCH FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM 'infinity'::date)" +== 261 +-- truncate_limit: 100 +-- Infinity +|-- +-- wrong fields from non-finite date: +|-- +SELECT EXTRACT(MICROSEC FROM DATE 'infinity') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('microsec' FROM 'infinity'::date)" +== 262 +-- truncate_limit: 100 +-- error + +-- test constructors +select make_date(2013, 7, 15) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_date(2013, 7, 15)" +== 263 +-- truncate_limit: 100 +select make_date(-44, 3, 15) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_date(-44, 3, 15)" +== 264 +-- truncate_limit: 100 +select make_time(8, 20, 0.0) +-- +FUNCTION: name="make_time" function="make_time" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_time(8, 20, 0.0)" +== 265 +-- truncate_limit: 100 +-- should fail +select make_date(0, 7, 15) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_date(0, 7, 15)" +== 266 +-- truncate_limit: 100 +select make_date(2013, 2, 30) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_date(2013, 2, 30)" +== 267 +-- truncate_limit: 100 +select make_date(2013, 13, 1) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_date(2013, 13, 1)" +== 268 +-- truncate_limit: 100 +select make_date(2013, 11, -1) +-- +FUNCTION: name="make_date" function="make_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_date(2013, 11, -1)" +== 269 +-- truncate_limit: 100 +select make_time(10, 55, 100.1) +-- +FUNCTION: name="make_time" function="make_time" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_time(10, 55, 100.1)" +== 270 +-- truncate_limit: 100 +select make_time(24, 0, 2.1) +-- +FUNCTION: name="make_time" function="make_time" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_time(24, 0, 2.1)" diff --git a/parser/testdata/summary_truncate/postgres_regress/dbsize.metadata.json b/parser/testdata/summary_truncate/postgres_regress/dbsize.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/dbsize.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/dbsize.test b/parser/testdata/summary_truncate/postgres_regress/dbsize.test new file mode 100644 index 0000000..c0e201d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/dbsize.test @@ -0,0 +1,217 @@ +== 001 +-- truncate_limit: 100 +SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM + (VALUES (10::bigint), (1000::bigint), (1000000::bigint), + (1000000000::bigint), (1000000000000::bigint), + (1000000000000000::bigint)) x(size) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM (VALUES (...)) x(size)" +== 002 +-- truncate_limit: 100 +SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM + (VALUES (10::numeric), (1000::numeric), (1000000::numeric), + (1000000000::numeric), (1000000000000::numeric), + (1000000000000000::numeric), + (10.5::numeric), (1000.5::numeric), (1000000.5::numeric), + (1000000000.5::numeric), (1000000000000.5::numeric), + (1000000000000000.5::numeric)) x(size) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM (VALUES (...)) x(size)" +== 003 +-- truncate_limit: 100 +-- test where units change up +SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM + (VALUES (10239::bigint), (10240::bigint), + (10485247::bigint), (10485248::bigint), + (10736893951::bigint), (10736893952::bigint), + (10994579406847::bigint), (10994579406848::bigint), + (11258449312612351::bigint), (11258449312612352::bigint)) x(size) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM (VALUES (...)) x(size)" +== 004 +-- truncate_limit: 100 +SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM + (VALUES (10239::numeric), (10240::numeric), + (10485247::numeric), (10485248::numeric), + (10736893951::numeric), (10736893952::numeric), + (10994579406847::numeric), (10994579406848::numeric), + (11258449312612351::numeric), (11258449312612352::numeric), + (11528652096115048447::numeric), (11528652096115048448::numeric)) x(size) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size, pg_size_pretty(size), pg_size_pretty(-1 * size) FROM (VALUES (...)) x(size)" +== 005 +-- truncate_limit: 100 +-- Ensure we get the expected results when passing the extremities of bigint +SELECT pg_size_pretty('-9223372036854775808'::bigint), + pg_size_pretty('9223372036854775807'::bigint) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_pretty('-9223372036854775808'::bigint), pg_size_pretty('9223372036854775807'::bigint)" +== 006 +-- truncate_limit: 100 +-- pg_size_bytes() tests +SELECT size, pg_size_bytes(size) FROM + (VALUES ('1'), ('123bytes'), ('256 B'), ('1kB'), ('1MB'), (' 1 GB'), ('1.5 GB '), + ('1TB'), ('3000 TB'), ('1e6 MB'), ('99 PB')) x(size) +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size, pg_size_bytes(size) FROM (VALUES (...)) x(size)" +== 007 +-- truncate_limit: 100 +-- case-insensitive units are supported +SELECT size, pg_size_bytes(size) FROM + (VALUES ('1'), ('123bYteS'), ('1kb'), ('1mb'), (' 1 Gb'), ('1.5 gB '), + ('1tb'), ('3000 tb'), ('1e6 mb'), ('99 pb')) x(size) +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size, pg_size_bytes(size) FROM (VALUES (...)) x(size)" +== 008 +-- truncate_limit: 100 +-- negative numbers are supported +SELECT size, pg_size_bytes(size) FROM + (VALUES ('-1'), ('-123bytes'), ('-1kb'), ('-1mb'), (' -1 Gb'), ('-1.5 gB '), + ('-1tb'), ('-3000 TB'), ('-10e-1 MB'), ('-99 PB')) x(size) +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size, pg_size_bytes(size) FROM (VALUES (...)) x(size)" +== 009 +-- truncate_limit: 100 +-- different cases with allowed points +SELECT size, pg_size_bytes(size) FROM + (VALUES ('-1.'), ('-1.kb'), ('-1. kb'), ('-0. gb'), + ('-.1'), ('-.1kb'), ('-.1 kb'), ('-.0 gb')) x(size) +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size, pg_size_bytes(size) FROM (VALUES (...)) x(size)" +== 010 +-- truncate_limit: 100 +-- invalid inputs +SELECT pg_size_bytes('1 AB') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('1 AB')" +== 011 +-- truncate_limit: 100 +SELECT pg_size_bytes('1 AB A') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('1 AB A')" +== 012 +-- truncate_limit: 100 +SELECT pg_size_bytes('1 AB A ') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('1 AB A ')" +== 013 +-- truncate_limit: 100 +SELECT pg_size_bytes('9223372036854775807.9') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('9223372036854775807.9')" +== 014 +-- truncate_limit: 100 +SELECT pg_size_bytes('1e100') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('1e100')" +== 015 +-- truncate_limit: 100 +SELECT pg_size_bytes('1e1000000000000000000') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('1e1000000000000000000')" +== 016 +-- truncate_limit: 100 +SELECT pg_size_bytes('1 byte') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('1 byte')" +== 017 +-- truncate_limit: 100 +-- the singular "byte" is not supported +SELECT pg_size_bytes('') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('')" +== 018 +-- truncate_limit: 100 +SELECT pg_size_bytes('kb') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('kb')" +== 019 +-- truncate_limit: 100 +SELECT pg_size_bytes('..') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('..')" +== 020 +-- truncate_limit: 100 +SELECT pg_size_bytes('-.') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('-.')" +== 021 +-- truncate_limit: 100 +SELECT pg_size_bytes('-.kb') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('-.kb')" +== 022 +-- truncate_limit: 100 +SELECT pg_size_bytes('-. kb') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('-. kb')" +== 023 +-- truncate_limit: 100 +SELECT pg_size_bytes('.+912') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('.+912')" +== 024 +-- truncate_limit: 100 +SELECT pg_size_bytes('+912+ kB') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('+912+ kB')" +== 025 +-- truncate_limit: 100 +SELECT pg_size_bytes('++123 kB') +-- +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_bytes('++123 kB')" diff --git a/parser/testdata/summary_truncate/postgres_regress/delete.metadata.json b/parser/testdata/summary_truncate/postgres_regress/delete.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/delete.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/delete.test b/parser/testdata/summary_truncate/postgres_regress/delete.test new file mode 100644 index 0000000..bad2e31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/delete.test @@ -0,0 +1,86 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE delete_test ( + id SERIAL PRIMARY KEY, + a INT, + b text +) +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE delete_test (id serial PRIMARY KEY, a int, b text)" +== 002 +-- truncate_limit: 100 +INSERT INTO delete_test (a) VALUES (10) +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO delete_test (a) VALUES (10)" +== 003 +-- truncate_limit: 100 +INSERT INTO delete_test (a, b) VALUES (50, repeat('x', 10000)) +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO delete_test (a, b) VALUES (50, repeat('x', 10000))" +== 004 +-- truncate_limit: 100 +INSERT INTO delete_test (a) VALUES (100) +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO delete_test (a) VALUES (100)" +== 005 +-- truncate_limit: 100 +-- allow an alias to be specified for DELETE's target table +DELETE FROM delete_test AS dt WHERE dt.a > 75 +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +ALIAS: "dt"="delete_test" +STMT: DeleteStmt +TRUNCATED: "DELETE FROM delete_test dt WHERE dt.a > 75" +== 006 +-- truncate_limit: 100 +-- if an alias is specified, don't allow the original table name +-- to be referenced +DELETE FROM delete_test dt WHERE delete_test.a > 25 +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +ALIAS: "dt"="delete_test" +STMT: DeleteStmt +TRUNCATED: "DELETE FROM delete_test dt WHERE delete_test.a > 25" +== 007 +-- truncate_limit: 100 +SELECT id, a, char_length(b) FROM delete_test +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT id, a, char_length(b) FROM delete_test" +== 008 +-- truncate_limit: 100 +-- delete a row with a TOASTed value +DELETE FROM delete_test WHERE a > 25 +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM delete_test WHERE a > 25" +== 009 +-- truncate_limit: 100 +SELECT id, a, char_length(b) FROM delete_test +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT id, a, char_length(b) FROM delete_test" +== 010 +-- truncate_limit: 100 +DROP TABLE delete_test +-- +TABLE: name="delete_test" schema="" table="delete_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE delete_test" diff --git a/parser/testdata/summary_truncate/postgres_regress/dependency.metadata.json b/parser/testdata/summary_truncate/postgres_regress/dependency.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/dependency.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/dependency.test b/parser/testdata/summary_truncate/postgres_regress/dependency.test new file mode 100644 index 0000000..e048fed --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/dependency.test @@ -0,0 +1,426 @@ +== 001 +-- truncate_limit: 100 +|-- +-- DEPENDENCIES +|-- + +CREATE USER regress_dep_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_dep_user" +== 002 +-- truncate_limit: 100 +CREATE USER regress_dep_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_dep_user2" +== 003 +-- truncate_limit: 100 +CREATE USER regress_dep_user3 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_dep_user3" +== 004 +-- truncate_limit: 100 +CREATE GROUP regress_dep_group +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE GROUP regress_dep_group" +== 005 +-- truncate_limit: 100 +CREATE TABLE deptest (f1 serial primary key, f2 text) +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE deptest (f1 serial PRIMARY KEY, f2 text)" +== 006 +-- truncate_limit: 100 +GRANT SELECT ON TABLE deptest TO GROUP regress_dep_group +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON deptest TO regress_dep_group" +== 007 +-- truncate_limit: 100 +GRANT ALL ON TABLE deptest TO regress_dep_user, regress_dep_user2 +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON deptest TO regress_dep_user, regress_dep_user2" +== 008 +-- truncate_limit: 100 +-- can't drop neither because they have privileges somewhere +DROP USER regress_dep_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user" +== 009 +-- truncate_limit: 100 +DROP GROUP regress_dep_group +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_group" +== 010 +-- truncate_limit: 100 +-- if we revoke the privileges we can drop the group +REVOKE SELECT ON deptest FROM GROUP regress_dep_group +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE select ON deptest FROM regress_dep_group" +== 011 +-- truncate_limit: 100 +DROP GROUP regress_dep_group +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_group" +== 012 +-- truncate_limit: 100 +-- can't drop the user if we revoke the privileges partially +REVOKE SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, MAINTAIN ON deptest FROM regress_dep_user +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE select, insert, update, delete, truncate, references, maintain ON deptest FROM regress_dep..." +== 013 +-- truncate_limit: 100 +DROP USER regress_dep_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user" +== 014 +-- truncate_limit: 100 +-- now we are OK to drop him +REVOKE TRIGGER ON deptest FROM regress_dep_user +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE trigger ON deptest FROM regress_dep_user" +== 015 +-- truncate_limit: 100 +DROP USER regress_dep_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user" +== 016 +-- truncate_limit: 100 +-- we are OK too if we drop the privileges all at once +REVOKE ALL ON deptest FROM regress_dep_user2 +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON deptest FROM regress_dep_user2" +== 017 +-- truncate_limit: 100 +DROP USER regress_dep_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user2" +== 018 +-- truncate_limit: 100 +-- can't drop the owner of an object +-- the error message detail here would include a pg_toast_nnn name that +-- is not constant, so suppress it +ALTER TABLE deptest OWNER TO regress_dep_user3 +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE deptest OWNER TO regress_dep_user3" +== 019 +-- truncate_limit: 100 +DROP USER regress_dep_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user3" +== 020 +-- truncate_limit: 100 +-- if we drop the object, we can drop the user too +DROP TABLE deptest +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE deptest" +== 021 +-- truncate_limit: 100 +DROP USER regress_dep_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user3" +== 022 +-- truncate_limit: 100 +-- Test DROP OWNED +CREATE USER regress_dep_user0 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_dep_user0" +== 023 +-- truncate_limit: 100 +CREATE USER regress_dep_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_dep_user1" +== 024 +-- truncate_limit: 100 +CREATE USER regress_dep_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_dep_user2" +== 025 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_dep_user0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_dep_user0" +== 026 +-- truncate_limit: 100 +-- permission denied +DROP OWNED BY regress_dep_user1 +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_dep_user1" +== 027 +-- truncate_limit: 100 +DROP OWNED BY regress_dep_user0, regress_dep_user2 +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_dep_user0, regress_dep_user2" +== 028 +-- truncate_limit: 100 +REASSIGN OWNED BY regress_dep_user0 TO regress_dep_user1 +-- +STMT: ReassignOwnedStmt +TRUNCATED: "REASSIGN OWNED BY regress_dep_user0 TO regress_dep_user1" +== 029 +-- truncate_limit: 100 +REASSIGN OWNED BY regress_dep_user1 TO regress_dep_user0 +-- +STMT: ReassignOwnedStmt +TRUNCATED: "REASSIGN OWNED BY regress_dep_user1 TO regress_dep_user0" +== 030 +-- truncate_limit: 100 +-- this one is allowed +DROP OWNED BY regress_dep_user0 +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_dep_user0" +== 031 +-- truncate_limit: 100 +CREATE TABLE deptest1 (f1 int unique) +-- +TABLE: name="deptest1" schema="" table="deptest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE deptest1 (f1 int UNIQUE)" +== 032 +-- truncate_limit: 100 +GRANT ALL ON deptest1 TO regress_dep_user1 WITH GRANT OPTION +-- +TABLE: name="deptest1" schema="" table="deptest1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON deptest1 TO regress_dep_user1 WITH GRANT OPTION" +== 033 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_dep_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_dep_user1" +== 034 +-- truncate_limit: 100 +CREATE TABLE deptest (a serial primary key, b text) +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE deptest (a serial PRIMARY KEY, b text)" +== 035 +-- truncate_limit: 100 +GRANT ALL ON deptest1 TO regress_dep_user2 +-- +TABLE: name="deptest1" schema="" table="deptest1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON deptest1 TO regress_dep_user2" +== 036 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 037 +-- truncate_limit: 100 +DROP OWNED BY regress_dep_user1 +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_dep_user1" +== 038 +-- truncate_limit: 100 +-- all grants revoked +-- table was dropped + +-- Test REASSIGN OWNED +GRANT ALL ON deptest1 TO regress_dep_user1 +-- +TABLE: name="deptest1" schema="" table="deptest1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON deptest1 TO regress_dep_user1" +== 039 +-- truncate_limit: 100 +GRANT CREATE ON DATABASE regression TO regress_dep_user1 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON DATABASE regression TO regress_dep_user1" +== 040 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_dep_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_dep_user1" +== 041 +-- truncate_limit: 100 +CREATE SCHEMA deptest +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA deptest" +== 042 +-- truncate_limit: 100 +CREATE TABLE deptest (a serial primary key, b text) +-- +TABLE: name="deptest" schema="" table="deptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE deptest (a serial PRIMARY KEY, b text)" +== 043 +-- truncate_limit: 100 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_dep_user1 IN SCHEMA deptest + GRANT ALL ON TABLES TO regress_dep_user2 +-- +STMT: AlterDefaultPrivilegesStmt +TRUNCATED: "ALTER DEFAULT PRIVILEGES FOR ROLE regress_dep_user1 IN SCHEMA deptest GRANT ALL ON TABLES TO regr..." +== 044 +-- truncate_limit: 100 +CREATE FUNCTION deptest_func() RETURNS void LANGUAGE plpgsql + AS $$ BEGIN END; $$ +-- +FUNCTION: name="deptest_func" function="deptest_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION deptest_func() RETURNS void LANGUAGE plpgsql AS $$ BEGIN END; $$" +== 045 +-- truncate_limit: 100 +CREATE TYPE deptest_enum AS ENUM ('red') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE deptest_enum AS ENUM ('red')" +== 046 +-- truncate_limit: 100 +CREATE TYPE deptest_range AS RANGE (SUBTYPE = int4) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE deptest_range AS RANGE (subtype = int4)" +== 047 +-- truncate_limit: 100 +CREATE TABLE deptest2 (f1 int) +-- +TABLE: name="deptest2" schema="" table="deptest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE deptest2 (f1 int)" +== 048 +-- truncate_limit: 100 +-- make a serial column the hard way +CREATE SEQUENCE ss1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE ss1" +== 049 +-- truncate_limit: 100 +ALTER TABLE deptest2 ALTER f1 SET DEFAULT nextval('ss1') +-- +TABLE: name="deptest2" schema="" table="deptest2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE deptest2 ALTER COLUMN f1 SET DEFAULT nextval('ss1')" +== 050 +-- truncate_limit: 100 +ALTER SEQUENCE ss1 OWNED BY deptest2.f1 +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE ss1 OWNED BY deptest2.f1" +== 051 +-- truncate_limit: 100 +-- When reassigning ownership of a composite type, its pg_class entry +-- should match +CREATE TYPE deptest_t AS (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE deptest_t AS (a int)" +== 052 +-- truncate_limit: 100 +SELECT typowner = relowner +FROM pg_type JOIN pg_class c ON typrelid = c.oid WHERE typname = 'deptest_t' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT typowner = relowner FROM pg_type JOIN pg_class c ON typrelid = c.oid WHERE ..." +== 053 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 054 +-- truncate_limit: 100 +REASSIGN OWNED BY regress_dep_user1 TO regress_dep_user2 +-- +STMT: ReassignOwnedStmt +TRUNCATED: "REASSIGN OWNED BY regress_dep_user1 TO regress_dep_user2" +== 055 +-- truncate_limit: 100 +SELECT typowner = relowner +FROM pg_type JOIN pg_class c ON typrelid = c.oid WHERE typname = 'deptest_t' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT typowner = relowner FROM pg_type JOIN pg_class c ON typrelid = c.oid WHERE ..." +== 056 +-- truncate_limit: 100 +-- doesn't work: grant still exists +DROP USER regress_dep_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user1" +== 057 +-- truncate_limit: 100 +DROP OWNED BY regress_dep_user1 +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_dep_user1" +== 058 +-- truncate_limit: 100 +DROP USER regress_dep_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user1" +== 059 +-- truncate_limit: 100 +DROP USER regress_dep_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user2" +== 060 +-- truncate_limit: 100 +DROP OWNED BY regress_dep_user2, regress_dep_user0 +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_dep_user2, regress_dep_user0" +== 061 +-- truncate_limit: 100 +DROP USER regress_dep_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user2" +== 062 +-- truncate_limit: 100 +DROP USER regress_dep_user0 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_dep_user0" diff --git a/parser/testdata/summary_truncate/postgres_regress/domain.metadata.json b/parser/testdata/summary_truncate/postgres_regress/domain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/domain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/domain.test b/parser/testdata/summary_truncate/postgres_regress/domain.test new file mode 100644 index 0000000..020578d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/domain.test @@ -0,0 +1,2424 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test domains. +|-- + +-- Test Comment / Drop +create domain domaindroptest int4 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domaindroptest AS int4" +== 002 +-- truncate_limit: 100 +comment on domain domaindroptest is 'About to drop this..' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON DOMAIN domaindroptest IS 'About to drop this..'" +== 003 +-- truncate_limit: 100 +create domain dependenttypetest domaindroptest +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN dependenttypetest AS domaindroptest" +== 004 +-- truncate_limit: 100 +-- fail because of dependent type +drop domain domaindroptest +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domaindroptest" +== 005 +-- truncate_limit: 100 +drop domain domaindroptest cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domaindroptest CASCADE" +== 006 +-- truncate_limit: 100 +-- this should fail because already gone +drop domain domaindroptest cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domaindroptest CASCADE" +== 007 +-- truncate_limit: 100 +-- Test domain input. + +-- Note: the point of checking both INSERT and COPY FROM is that INSERT +-- exercises CoerceToDomain while COPY exercises domain_in. + +create domain domainvarchar varchar(5) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domainvarchar AS varchar(5)" +== 008 +-- truncate_limit: 100 +create domain domainnumeric numeric(8,2) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domainnumeric AS numeric(8, 2)" +== 009 +-- truncate_limit: 100 +create domain domainint4 int4 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domainint4 AS int4" +== 010 +-- truncate_limit: 100 +create domain domaintext text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domaintext AS text" +== 011 +-- truncate_limit: 100 +-- Test explicit coercions --- these should succeed (and truncate) +SELECT cast('123456' as domainvarchar) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '123456'::domainvarchar" +== 012 +-- truncate_limit: 100 +SELECT cast('12345' as domainvarchar) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345'::domainvarchar" +== 013 +-- truncate_limit: 100 +-- Test tables using domains +create table basictest + ( testint4 domainint4 + , testtext domaintext + , testvarchar domainvarchar + , testnumeric domainnumeric + ) +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE basictest (testint4 domainint4, testtext domaintext, testvarchar domainvarchar, test..." +== 014 +-- truncate_limit: 100 +INSERT INTO basictest values ('88', 'haha', 'short', '123.12') +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO basictest VALUES ('88', 'haha', 'short', '123.12')" +== 015 +-- truncate_limit: 100 +-- Good +INSERT INTO basictest values ('88', 'haha', 'short text', '123.12') +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO basictest VALUES ('88', 'haha', 'short text', '123.12')" +== 016 +-- truncate_limit: 100 +-- Bad varchar +INSERT INTO basictest values ('88', 'haha', 'short', '123.1212') +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO basictest VALUES ('88', 'haha', 'short', '123.1212')" +== 017 +-- truncate_limit: 100 +-- Truncate numeric + +-- Test copy +COPY basictest (testvarchar) FROM stdin +-- +TABLE: name="basictest" schema="" table="basictest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY basictest(testvarchar) FROM STDIN" +== 018 +-- truncate_limit: 100 +-- fail +notsoshorttext + +COPY basictest (testvarchar) FROM stdin +-- +ERROR: syntax error at or near "notsoshorttext" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 019 +-- truncate_limit: 100 +select * from basictest +-- +TABLE: name="basictest" schema="" table="basictest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM basictest" +== 020 +-- truncate_limit: 100 +-- check that domains inherit operations from base types +select testtext || testvarchar as concat, testnumeric + 42 as sum +from basictest +-- +TABLE: name="basictest" schema="" table="basictest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT testtext || testvarchar AS concat, testnumeric + 42 AS sum FROM basictest" +== 021 +-- truncate_limit: 100 +-- check that union/case/coalesce type resolution handles domains properly +select pg_typeof(coalesce(4::domainint4, 7)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(COALESCE(4::domainint4, 7))" +== 022 +-- truncate_limit: 100 +select pg_typeof(coalesce(4::domainint4, 7::domainint4)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(COALESCE(4::domainint4, 7::domainint4))" +== 023 +-- truncate_limit: 100 +drop table basictest +-- +TABLE: name="basictest" schema="" table="basictest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE basictest" +== 024 +-- truncate_limit: 100 +drop domain domainvarchar restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domainvarchar" +== 025 +-- truncate_limit: 100 +drop domain domainnumeric restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domainnumeric" +== 026 +-- truncate_limit: 100 +drop domain domainint4 restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domainint4" +== 027 +-- truncate_limit: 100 +drop domain domaintext +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domaintext" +== 028 +-- truncate_limit: 100 +-- Test non-error-throwing input + +create domain positiveint int4 check(value > 0) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN positiveint AS int4 CHECK (value > 0)" +== 029 +-- truncate_limit: 100 +create domain weirdfloat float8 check((1 / value) < 10) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN weirdfloat AS float8 CHECK ((1 / value) < 10)" +== 030 +-- truncate_limit: 100 +select pg_input_is_valid('1', 'positiveint') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1', 'positiveint')" +== 031 +-- truncate_limit: 100 +select pg_input_is_valid('junk', 'positiveint') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('junk', 'positiveint')" +== 032 +-- truncate_limit: 100 +select pg_input_is_valid('-1', 'positiveint') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('-1', 'positiveint')" +== 033 +-- truncate_limit: 100 +select * from pg_input_error_info('junk', 'positiveint') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('junk', 'positiveint')" +== 034 +-- truncate_limit: 100 +select * from pg_input_error_info('-1', 'positiveint') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('-1', 'positiveint')" +== 035 +-- truncate_limit: 100 +select * from pg_input_error_info('junk', 'weirdfloat') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('junk', 'weirdfloat')" +== 036 +-- truncate_limit: 100 +select * from pg_input_error_info('0.01', 'weirdfloat') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('0.01', 'weirdfloat')" +== 037 +-- truncate_limit: 100 +-- We currently can't trap errors raised in the CHECK expression itself +select * from pg_input_error_info('0', 'weirdfloat') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('0', 'weirdfloat')" +== 038 +-- truncate_limit: 100 +drop domain positiveint +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN positiveint" +== 039 +-- truncate_limit: 100 +drop domain weirdfloat +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN weirdfloat" +== 040 +-- truncate_limit: 100 +-- Test domains over array types + +create domain domainint4arr int4[1] +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domainint4arr AS int4[1]" +== 041 +-- truncate_limit: 100 +create domain domainchar4arr varchar(4)[2][3] +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domainchar4arr AS varchar(4)[2][3]" +== 042 +-- truncate_limit: 100 +create table domarrtest + ( testint4arr domainint4arr + , testchar4arr domainchar4arr + ) +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE domarrtest (testint4arr domainint4arr, testchar4arr domainchar4arr)" +== 043 +-- truncate_limit: 100 +INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domarrtest VALUES ('{2,2}', '{{\"a\",\"b\"},{\"c\",\"d\"}}')" +== 044 +-- truncate_limit: 100 +INSERT INTO domarrtest values ('{{2,2},{2,2}}', '{{"a","b"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domarrtest VALUES ('{{2,2},{2,2}}', '{{\"a\",\"b\"}}')" +== 045 +-- truncate_limit: 100 +INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"},{"e","f"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domarrtest VALUES ('{2,2}', '{{\"a\",\"b\"},{\"c\",\"d\"},{\"e\",\"f\"}}')" +== 046 +-- truncate_limit: 100 +INSERT INTO domarrtest values ('{2,2}', '{{"a"},{"c"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domarrtest VALUES ('{2,2}', '{{\"a\"},{\"c\"}}')" +== 047 +-- truncate_limit: 100 +INSERT INTO domarrtest values (NULL, '{{"a","b","c"},{"d","e","f"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domarrtest VALUES (NULL, '{{\"a\",\"b\",\"c\"},{\"d\",\"e\",\"f\"}}')" +== 048 +-- truncate_limit: 100 +INSERT INTO domarrtest values (NULL, '{{"toolong","b","c"},{"d","e","f"}}') +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domarrtest VALUES (NULL, '{{\"toolong\",\"b\",\"c\"},{\"d\",\"e\",\"f\"}}')" +== 049 +-- truncate_limit: 100 +INSERT INTO domarrtest (testint4arr[1], testint4arr[3]) values (11,22) +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domarrtest (testint4arr[1], testint4arr[3]) VALUES (11, 22)" +== 050 +-- truncate_limit: 100 +select * from domarrtest +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domarrtest" +== 051 +-- truncate_limit: 100 +select testint4arr[1], testchar4arr[2:2] from domarrtest +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT testint4arr[1], testchar4arr[2:2] FROM domarrtest" +== 052 +-- truncate_limit: 100 +select array_dims(testint4arr), array_dims(testchar4arr) from domarrtest +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_dims(testint4arr), array_dims(testchar4arr) FROM domarrtest" +== 053 +-- truncate_limit: 100 +COPY domarrtest FROM stdin +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY domarrtest FROM STDIN" +== 054 +-- truncate_limit: 100 +COPY domarrtest FROM stdin +-- +TABLE: name="domarrtest" schema="" table="domarrtest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY domarrtest FROM STDIN" +== 055 +-- truncate_limit: 100 +-- fail +{3,4} {qwerty,w,e} + +select * from domarrtest +-- +ERROR: syntax error at or near "{" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 056 +-- truncate_limit: 100 +COPY nulltest FROM stdin +-- +TABLE: name="nulltest" schema="" table="nulltest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY nulltest FROM STDIN" +== 057 +-- truncate_limit: 100 +--fail +a b c d \N + +-- Last row is bad +COPY nulltest FROM stdin +-- +ERROR: syntax error at or near "a" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 058 +-- truncate_limit: 100 +select * from nulltest +-- +TABLE: name="nulltest" schema="" table="nulltest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nulltest" +== 059 +-- truncate_limit: 100 +-- Test out coerced (casted) constraints +SELECT cast('1' as dnotnull) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::dnotnull" +== 060 +-- truncate_limit: 100 +SELECT cast(NULL as dnotnull) +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::dnotnull" +== 061 +-- truncate_limit: 100 +-- fail +SELECT cast(cast(NULL as dnull) as dnotnull) +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::dnull::dnotnull" +== 062 +-- truncate_limit: 100 +-- fail +SELECT cast(col4 as dnotnull) from nulltest +-- +TABLE: name="nulltest" schema="" table="nulltest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT col4::dnotnull FROM nulltest" +== 063 +-- truncate_limit: 100 +-- fail + +-- cleanup +drop table nulltest +-- +TABLE: name="nulltest" schema="" table="nulltest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE nulltest" +== 064 +-- truncate_limit: 100 +drop domain dnotnull restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN dnotnull" +== 065 +-- truncate_limit: 100 +drop domain dnull restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN dnull" +== 066 +-- truncate_limit: 100 +drop domain dcheck restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN dcheck" +== 067 +-- truncate_limit: 100 +create domain ddef1 int4 DEFAULT 3 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN ddef1 AS int4 DEFAULT 3" +== 068 +-- truncate_limit: 100 +create domain ddef2 oid DEFAULT '12' +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN ddef2 AS oid DEFAULT '12'" +== 069 +-- truncate_limit: 100 +-- Type mixing, function returns int8 +create domain ddef3 text DEFAULT 5 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN ddef3 AS text DEFAULT 5" +== 070 +-- truncate_limit: 100 +create sequence ddef4_seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE ddef4_seq" +== 071 +-- truncate_limit: 100 +create domain ddef4 int4 DEFAULT nextval('ddef4_seq') +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN ddef4 AS int4 DEFAULT nextval('ddef4_seq')" +== 072 +-- truncate_limit: 100 +create domain ddef5 numeric(8,2) NOT NULL DEFAULT '12.12' +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN ddef5 AS numeric(8, 2) NOT NULL DEFAULT '12.12'" +== 073 +-- truncate_limit: 100 +create table defaulttest + ( col1 ddef1 + , col2 ddef2 + , col3 ddef3 + , col4 ddef4 PRIMARY KEY + , col5 ddef1 NOT NULL DEFAULT NULL + , col6 ddef2 DEFAULT '88' + , col7 ddef4 DEFAULT 8000 + , col8 ddef5 + ) +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE defaulttest (col1 ddef1, col2 ddef2, col3 ddef3, col4 ddef4 PRIMARY KEY, col5 ddef1 ..." +== 074 +-- truncate_limit: 100 +insert into defaulttest(col4) values(0) +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defaulttest (col4) VALUES (0)" +== 075 +-- truncate_limit: 100 +-- fails, col5 defaults to null +alter table defaulttest alter column col5 drop default +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defaulttest ALTER COLUMN col5 DROP DEFAULT" +== 076 +-- truncate_limit: 100 +insert into defaulttest default values +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO defaulttest DEFAULT VALUES" +== 077 +-- truncate_limit: 100 +-- succeeds, inserts domain default +-- We used to treat SET DEFAULT NULL as equivalent to DROP DEFAULT; wrong +alter table defaulttest alter column col5 set default null +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defaulttest ALTER COLUMN col5 SET DEFAULT NULL" +== 078 +-- truncate_limit: 100 +insert into defaulttest(col4) values(0) +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defaulttest (col4) VALUES (0)" +== 079 +-- truncate_limit: 100 +-- fails +alter table defaulttest alter column col5 drop default +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defaulttest ALTER COLUMN col5 DROP DEFAULT" +== 080 +-- truncate_limit: 100 +insert into defaulttest default values +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO defaulttest DEFAULT VALUES" +== 081 +-- truncate_limit: 100 +insert into defaulttest default values +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO defaulttest DEFAULT VALUES" +== 082 +-- truncate_limit: 100 +-- Test defaults with copy +COPY defaulttest(col5) FROM stdin +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY defaulttest(col5) FROM STDIN" +== 083 +-- truncate_limit: 100 +select * from defaulttest +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM defaulttest" +== 084 +-- truncate_limit: 100 +drop table defaulttest cascade +-- +TABLE: name="defaulttest" schema="" table="defaulttest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE defaulttest CASCADE" +== 085 +-- truncate_limit: 100 +-- Test ALTER DOMAIN .. NOT NULL +create domain dnotnulltest integer +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN dnotnulltest AS int" +== 086 +-- truncate_limit: 100 +create table domnotnull +( col1 dnotnulltest +, col2 dnotnulltest +) +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE domnotnull (col1 dnotnulltest, col2 dnotnulltest)" +== 087 +-- truncate_limit: 100 +insert into domnotnull default values +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO domnotnull DEFAULT VALUES" +== 088 +-- truncate_limit: 100 +alter domain dnotnulltest set not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dnotnulltest SET NOT NULL" +== 089 +-- truncate_limit: 100 +-- fails + +update domnotnull set col1 = 5 +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domnotnull SET col1 = 5" +== 090 +-- truncate_limit: 100 +alter domain dnotnulltest set not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dnotnulltest SET NOT NULL" +== 091 +-- truncate_limit: 100 +-- fails + +update domnotnull set col2 = 6 +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domnotnull SET col2 = 6" +== 092 +-- truncate_limit: 100 +alter domain dnotnulltest set not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dnotnulltest SET NOT NULL" +== 093 +-- truncate_limit: 100 +update domnotnull set col1 = null +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domnotnull SET col1 = NULL" +== 094 +-- truncate_limit: 100 +-- fails + +alter domain dnotnulltest drop not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dnotnulltest DROP NOT NULL" +== 095 +-- truncate_limit: 100 +update domnotnull set col1 = null +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domnotnull SET col1 = NULL" +== 096 +-- truncate_limit: 100 +update domnotnull set col1 = 5 +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domnotnull SET col1 = 5" +== 097 +-- truncate_limit: 100 +-- these constraints can also be added and removed by name +alter domain dnotnulltest add constraint dnotnulltest_notnull not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dnotnulltest ADD CONSTRAINT dnotnulltest_notnull NOT NULL" +== 098 +-- truncate_limit: 100 +update domnotnull set col1 = null +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domnotnull SET col1 = NULL" +== 099 +-- truncate_limit: 100 +-- fails +select conname, pg_get_constraintdef(oid) from pg_constraint + where contypid = 'dnotnulltest'::regtype +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="contypid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE contypid = 'dnotnulltest'::regtype" +== 100 +-- truncate_limit: 100 +alter domain dnotnulltest drop constraint dnotnulltest_notnull +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dnotnulltest DROP CONSTRAINT dnotnulltest_notnull" +== 101 +-- truncate_limit: 100 +update domnotnull set col1 = null +-- +TABLE: name="domnotnull" schema="" table="domnotnull" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domnotnull SET col1 = NULL" +== 102 +-- truncate_limit: 100 +drop domain dnotnulltest cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN dnotnulltest CASCADE" +== 103 +-- truncate_limit: 100 +-- Test ALTER DOMAIN .. DEFAULT .. +create table domdeftest (col1 ddef1) +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE domdeftest (col1 ddef1)" +== 104 +-- truncate_limit: 100 +insert into domdeftest default values +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO domdeftest DEFAULT VALUES" +== 105 +-- truncate_limit: 100 +select * from domdeftest +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domdeftest" +== 106 +-- truncate_limit: 100 +alter domain ddef1 set default '42' +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN ddef1 SET DEFAULT '42'" +== 107 +-- truncate_limit: 100 +insert into domdeftest default values +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO domdeftest DEFAULT VALUES" +== 108 +-- truncate_limit: 100 +select * from domdeftest +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domdeftest" +== 109 +-- truncate_limit: 100 +alter domain ddef1 drop default +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN ddef1 DROP DEFAULT" +== 110 +-- truncate_limit: 100 +insert into domdeftest default values +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO domdeftest DEFAULT VALUES" +== 111 +-- truncate_limit: 100 +select * from domdeftest +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domdeftest" +== 112 +-- truncate_limit: 100 +drop table domdeftest +-- +TABLE: name="domdeftest" schema="" table="domdeftest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE domdeftest" +== 113 +-- truncate_limit: 100 +-- Test ALTER DOMAIN .. CONSTRAINT .. +create domain con as integer +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN con AS int" +== 114 +-- truncate_limit: 100 +create table domcontest (col1 con) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE domcontest (col1 con)" +== 115 +-- truncate_limit: 100 +insert into domcontest values (1) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domcontest VALUES (1)" +== 116 +-- truncate_limit: 100 +insert into domcontest values (2) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domcontest VALUES (2)" +== 117 +-- truncate_limit: 100 +alter domain con add constraint t check (VALUE < 1) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN con ADD CONSTRAINT t CHECK (value < 1)" +== 118 +-- truncate_limit: 100 +-- fails + +alter domain con add constraint t check (VALUE < 34) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN con ADD CONSTRAINT t CHECK (value < 34)" +== 119 +-- truncate_limit: 100 +alter domain con add check (VALUE > 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN con ADD CHECK (value > 0)" +== 120 +-- truncate_limit: 100 +insert into domcontest values (-5) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domcontest VALUES (-5)" +== 121 +-- truncate_limit: 100 +-- fails +insert into domcontest values (42) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domcontest VALUES (42)" +== 122 +-- truncate_limit: 100 +-- fails +insert into domcontest values (5) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domcontest VALUES (5)" +== 123 +-- truncate_limit: 100 +alter domain con drop constraint t +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN con DROP CONSTRAINT t" +== 124 +-- truncate_limit: 100 +insert into domcontest values (-5) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domcontest VALUES (-5)" +== 125 +-- truncate_limit: 100 +--fails +insert into domcontest values (42) +-- +TABLE: name="domcontest" schema="" table="domcontest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domcontest VALUES (42)" +== 126 +-- truncate_limit: 100 +alter domain con drop constraint nonexistent +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN con DROP CONSTRAINT nonexistent" +== 127 +-- truncate_limit: 100 +alter domain con drop constraint if exists nonexistent +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN con DROP CONSTRAINT IF EXISTS nonexistent" +== 128 +-- truncate_limit: 100 +-- not-null constraints +create domain connotnull integer +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN connotnull AS int" +== 129 +-- truncate_limit: 100 +create table domconnotnulltest +( col1 connotnull +, col2 connotnull +) +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE domconnotnulltest (col1 connotnull, col2 connotnull)" +== 130 +-- truncate_limit: 100 +insert into domconnotnulltest default values +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO domconnotnulltest DEFAULT VALUES" +== 131 +-- truncate_limit: 100 +alter domain connotnull add not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN connotnull ADD NOT NULL" +== 132 +-- truncate_limit: 100 +-- fails + +update domconnotnulltest set col1 = 5 +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domconnotnulltest SET col1 = 5" +== 133 +-- truncate_limit: 100 +alter domain connotnull add not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN connotnull ADD NOT NULL" +== 134 +-- truncate_limit: 100 +-- fails + +update domconnotnulltest set col2 = 6 +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domconnotnulltest SET col2 = 6" +== 135 +-- truncate_limit: 100 +alter domain connotnull add constraint constr1 not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN connotnull ADD CONSTRAINT constr1 NOT NULL" +== 136 +-- truncate_limit: 100 +select count(*) from pg_constraint where contypid = 'connotnull'::regtype and contype = 'n' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="contypid" +FILTER: schema="" table="" column="contype" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_constraint WHERE contypid = 'connotnull'::regtype AND contype = 'n'" +== 137 +-- truncate_limit: 100 +alter domain connotnull add constraint constr1bis not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN connotnull ADD CONSTRAINT constr1bis NOT NULL" +== 138 +-- truncate_limit: 100 +-- redundant +select count(*) from pg_constraint where contypid = 'connotnull'::regtype and contype = 'n' +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="contypid" +FILTER: schema="" table="" column="contype" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_constraint WHERE contypid = 'connotnull'::regtype AND contype = 'n'" +== 139 +-- truncate_limit: 100 +update domconnotnulltest set col1 = null +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domconnotnulltest SET col1 = NULL" +== 140 +-- truncate_limit: 100 +-- fails + +alter domain connotnull drop constraint constr1 +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN connotnull DROP CONSTRAINT constr1" +== 141 +-- truncate_limit: 100 +update domconnotnulltest set col1 = null +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE domconnotnulltest SET col1 = NULL" +== 142 +-- truncate_limit: 100 +drop domain connotnull cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN connotnull CASCADE" +== 143 +-- truncate_limit: 100 +drop table domconnotnulltest +-- +TABLE: name="domconnotnulltest" schema="" table="domconnotnulltest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE domconnotnulltest" +== 144 +-- truncate_limit: 100 +-- Test ALTER DOMAIN .. CONSTRAINT .. NOT VALID +create domain things AS INT +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN things AS int" +== 145 +-- truncate_limit: 100 +CREATE TABLE thethings (stuff things) +-- +TABLE: name="thethings" schema="" table="thethings" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE thethings (stuff things)" +== 146 +-- truncate_limit: 100 +INSERT INTO thethings (stuff) VALUES (55) +-- +TABLE: name="thethings" schema="" table="thethings" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO thethings (stuff) VALUES (55)" +== 147 +-- truncate_limit: 100 +ALTER DOMAIN things ADD CONSTRAINT meow CHECK (VALUE < 11) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN things ADD CONSTRAINT meow CHECK (value < 11)" +== 148 +-- truncate_limit: 100 +ALTER DOMAIN things ADD CONSTRAINT meow CHECK (VALUE < 11) NOT VALID +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN things ADD CONSTRAINT meow CHECK (value < 11) NOT VALID" +== 149 +-- truncate_limit: 100 +ALTER DOMAIN things VALIDATE CONSTRAINT meow +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN things VALIDATE CONSTRAINT meow" +== 150 +-- truncate_limit: 100 +UPDATE thethings SET stuff = 10 +-- +TABLE: name="thethings" schema="" table="thethings" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE thethings SET stuff = 10" +== 151 +-- truncate_limit: 100 +ALTER DOMAIN things VALIDATE CONSTRAINT meow +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN things VALIDATE CONSTRAINT meow" +== 152 +-- truncate_limit: 100 +-- Confirm ALTER DOMAIN with RULES. +create table domtab (col1 integer) +-- +TABLE: name="domtab" schema="" table="domtab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE domtab (col1 int)" +== 153 +-- truncate_limit: 100 +create domain dom as integer +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN dom AS int" +== 154 +-- truncate_limit: 100 +create view domview as select cast(col1 as dom) from domtab +-- +TABLE: name="domview" schema="" table="domview" ctx=DDL +TABLE: name="domtab" schema="" table="domtab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW domview AS SELECT col1::dom FROM domtab" +== 155 +-- truncate_limit: 100 +insert into domtab (col1) values (null) +-- +TABLE: name="domtab" schema="" table="domtab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domtab (col1) VALUES (NULL)" +== 156 +-- truncate_limit: 100 +insert into domtab (col1) values (5) +-- +TABLE: name="domtab" schema="" table="domtab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domtab (col1) VALUES (5)" +== 157 +-- truncate_limit: 100 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domview" +== 158 +-- truncate_limit: 100 +alter domain dom set not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dom SET NOT NULL" +== 159 +-- truncate_limit: 100 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domview" +== 160 +-- truncate_limit: 100 +-- fail + +alter domain dom drop not null +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dom DROP NOT NULL" +== 161 +-- truncate_limit: 100 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domview" +== 162 +-- truncate_limit: 100 +alter domain dom add constraint domchkgt6 check(value > 6) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dom ADD CONSTRAINT domchkgt6 CHECK (value > 6)" +== 163 +-- truncate_limit: 100 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domview" +== 164 +-- truncate_limit: 100 +--fail + +alter domain dom drop constraint domchkgt6 restrict +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN dom DROP CONSTRAINT domchkgt6" +== 165 +-- truncate_limit: 100 +select * from domview +-- +TABLE: name="domview" schema="" table="domview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM domview" +== 166 +-- truncate_limit: 100 +-- cleanup +drop domain ddef1 restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN ddef1" +== 167 +-- truncate_limit: 100 +drop domain ddef2 restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN ddef2" +== 168 +-- truncate_limit: 100 +drop domain ddef3 restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN ddef3" +== 169 +-- truncate_limit: 100 +drop domain ddef4 restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN ddef4" +== 170 +-- truncate_limit: 100 +drop domain ddef5 restrict +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN ddef5" +== 171 +-- truncate_limit: 100 +drop sequence ddef4_seq +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE ddef4_seq" +== 172 +-- truncate_limit: 100 +-- Test domains over domains +create domain vchar4 varchar(4) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN vchar4 AS varchar(4)" +== 173 +-- truncate_limit: 100 +create domain dinter vchar4 check (substring(VALUE, 1, 1) = 'x') +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN dinter AS vchar4 CHECK (\"substring\"(value, 1, 1) = 'x')" +== 174 +-- truncate_limit: 100 +create domain dtop dinter check (substring(VALUE, 2, 1) = '1') +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN dtop AS dinter CHECK (\"substring\"(value, 2, 1) = '1')" +== 175 +-- truncate_limit: 100 +select 'x123'::dtop +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'x123'::dtop" +== 176 +-- truncate_limit: 100 +select 'x1234'::dtop +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'x1234'::dtop" +== 177 +-- truncate_limit: 100 +-- explicit coercion should truncate +select 'y1234'::dtop +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'y1234'::dtop" +== 178 +-- truncate_limit: 100 +-- fail +select 'y123'::dtop +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'y123'::dtop" +== 179 +-- truncate_limit: 100 +-- fail +select 'yz23'::dtop +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'yz23'::dtop" +== 180 +-- truncate_limit: 100 +-- fail +select 'xz23'::dtop +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'xz23'::dtop" +== 181 +-- truncate_limit: 100 +-- fail + +create temp table dtest(f1 dtop) +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE dtest (f1 dtop)" +== 182 +-- truncate_limit: 100 +insert into dtest values('x123') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dtest VALUES ('x123')" +== 183 +-- truncate_limit: 100 +insert into dtest values('x1234') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dtest VALUES ('x1234')" +== 184 +-- truncate_limit: 100 +-- fail, implicit coercion +insert into dtest values('y1234') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dtest VALUES ('y1234')" +== 185 +-- truncate_limit: 100 +-- fail, implicit coercion +insert into dtest values('y123') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dtest VALUES ('y123')" +== 186 +-- truncate_limit: 100 +-- fail +insert into dtest values('yz23') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dtest VALUES ('yz23')" +== 187 +-- truncate_limit: 100 +-- fail +insert into dtest values('xz23') +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dtest VALUES ('xz23')" +== 188 +-- truncate_limit: 100 +-- fail + +drop table dtest +-- +TABLE: name="dtest" schema="" table="dtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE dtest" +== 189 +-- truncate_limit: 100 +drop domain vchar4 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN vchar4 CASCADE" +== 190 +-- truncate_limit: 100 +-- Make sure that constraints of newly-added domain columns are +-- enforced correctly, even if there's no default value for the new +-- column. Per bug #1433 +create domain str_domain as text not null +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN str_domain AS text NOT NULL" +== 191 +-- truncate_limit: 100 +create table domain_test (a int, b int) +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE domain_test (a int, b int)" +== 192 +-- truncate_limit: 100 +insert into domain_test values (1, 2) +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domain_test VALUES (1, 2)" +== 193 +-- truncate_limit: 100 +insert into domain_test values (1, 2) +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO domain_test VALUES (1, 2)" +== 194 +-- truncate_limit: 100 +-- should fail +alter table domain_test add column c str_domain +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE domain_test ADD COLUMN c str_domain" +== 195 +-- truncate_limit: 100 +create domain str_domain2 as text check (value <> 'foo') default 'foo' +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN str_domain2 AS text CHECK (value <> 'foo') DEFAULT 'foo'" +== 196 +-- truncate_limit: 100 +-- should fail +alter table domain_test add column d str_domain2 +-- +TABLE: name="domain_test" schema="" table="domain_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE domain_test ADD COLUMN d str_domain2" +== 197 +-- truncate_limit: 100 +-- Check that domain constraints on prepared statement parameters of +-- unknown type are enforced correctly. +create domain pos_int as int4 check (value > 0) not null +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN pos_int AS int4 CHECK (value > 0) NOT NULL" +== 198 +-- truncate_limit: 100 +prepare s1 as select $1::pos_int = 10 as "is_ten" +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE s1 AS SELECT $1::pos_int = 10 AS is_ten" +== 199 +-- truncate_limit: 100 +execute s1(10) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE s1(10)" +== 200 +-- truncate_limit: 100 +execute s1(0) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE s1(0)" +== 201 +-- truncate_limit: 100 +-- should fail +execute s1(NULL) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE s1(NULL)" +== 202 +-- truncate_limit: 100 +-- should fail + +-- Check that domain constraints on plpgsql function parameters, results, +-- and local variables are enforced correctly. + +create function doubledecrement(p1 pos_int) returns pos_int as $$ +declare v pos_int; +begin + return p1; +end$$ language plpgsql +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION doubledecrement(p1 pos_int) RETURNS pos_int AS $$\ndeclare v pos_int;\nbegin\n re..." +== 203 +-- truncate_limit: 100 +select doubledecrement(3) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT doubledecrement(3)" +== 204 +-- truncate_limit: 100 +-- fail because of implicit null assignment + +create or replace function doubledecrement(p1 pos_int) returns pos_int as $$ +declare v pos_int := 0; +begin + return p1; +end$$ language plpgsql +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION doubledecrement(p1 pos_int) RETURNS pos_int AS $$\ndeclare v pos_int :=..." +== 205 +-- truncate_limit: 100 +select doubledecrement(3) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT doubledecrement(3)" +== 206 +-- truncate_limit: 100 +-- fail at initialization assignment + +create or replace function doubledecrement(p1 pos_int) returns pos_int as $$ +declare v pos_int := 1; +begin + v := p1 - 1; + return v - 1; +end$$ language plpgsql +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION doubledecrement(p1 pos_int) RETURNS pos_int AS $$\ndeclare v pos_int :=..." +== 207 +-- truncate_limit: 100 +select doubledecrement(null) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT doubledecrement(NULL)" +== 208 +-- truncate_limit: 100 +-- fail before call +select doubledecrement(0) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT doubledecrement(0)" +== 209 +-- truncate_limit: 100 +-- fail before call +select doubledecrement(1) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT doubledecrement(1)" +== 210 +-- truncate_limit: 100 +-- fail at assignment to v +select doubledecrement(2) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT doubledecrement(2)" +== 211 +-- truncate_limit: 100 +-- fail at return +select doubledecrement(3) +-- +FUNCTION: name="doubledecrement" function="doubledecrement" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT doubledecrement(3)" +== 212 +-- truncate_limit: 100 +-- good + +-- Check that ALTER DOMAIN tests columns of derived types + +create domain posint as int4 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN posint AS int4" +== 213 +-- truncate_limit: 100 +-- Currently, this doesn't work for composite types, but verify it complains +create type ddtest1 as (f1 posint) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE ddtest1 AS (f1 posint)" +== 214 +-- truncate_limit: 100 +create table ddtest2(f1 ddtest1) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ddtest2 (f1 ddtest1)" +== 215 +-- truncate_limit: 100 +insert into ddtest2 values(row(-1)) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ddtest2 VALUES (ROW(-1))" +== 216 +-- truncate_limit: 100 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN posint ADD CONSTRAINT c1 CHECK (value >= 0)" +== 217 +-- truncate_limit: 100 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ddtest2" +== 218 +-- truncate_limit: 100 +-- Likewise for domains within arrays of composite +create table ddtest2(f1 ddtest1[]) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ddtest2 (f1 ddtest1[])" +== 219 +-- truncate_limit: 100 +insert into ddtest2 values('{(-1)}') +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ddtest2 VALUES ('{(-1)}')" +== 220 +-- truncate_limit: 100 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN posint ADD CONSTRAINT c1 CHECK (value >= 0)" +== 221 +-- truncate_limit: 100 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ddtest2" +== 222 +-- truncate_limit: 100 +-- Likewise for domains within domains over composite +create domain ddtest1d as ddtest1 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN ddtest1d AS ddtest1" +== 223 +-- truncate_limit: 100 +create table ddtest2(f1 ddtest1d) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ddtest2 (f1 ddtest1d)" +== 224 +-- truncate_limit: 100 +insert into ddtest2 values('(-1)') +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ddtest2 VALUES ('(-1)')" +== 225 +-- truncate_limit: 100 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN posint ADD CONSTRAINT c1 CHECK (value >= 0)" +== 226 +-- truncate_limit: 100 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ddtest2" +== 227 +-- truncate_limit: 100 +drop domain ddtest1d +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN ddtest1d" +== 228 +-- truncate_limit: 100 +-- Likewise for domains within domains over array of composite +create domain ddtest1d as ddtest1[] +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN ddtest1d AS ddtest1[]" +== 229 +-- truncate_limit: 100 +create table ddtest2(f1 ddtest1d) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ddtest2 (f1 ddtest1d)" +== 230 +-- truncate_limit: 100 +insert into ddtest2 values('{(-1)}') +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ddtest2 VALUES ('{(-1)}')" +== 231 +-- truncate_limit: 100 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN posint ADD CONSTRAINT c1 CHECK (value >= 0)" +== 232 +-- truncate_limit: 100 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ddtest2" +== 233 +-- truncate_limit: 100 +drop domain ddtest1d +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN ddtest1d" +== 234 +-- truncate_limit: 100 +-- Doesn't work for ranges, either +create type rposint as range (subtype = posint) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE rposint AS RANGE (subtype = posint)" +== 235 +-- truncate_limit: 100 +create table ddtest2(f1 rposint) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ddtest2 (f1 rposint)" +== 236 +-- truncate_limit: 100 +insert into ddtest2 values('(-1,3]') +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ddtest2 VALUES ('(-1,3]')" +== 237 +-- truncate_limit: 100 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN posint ADD CONSTRAINT c1 CHECK (value >= 0)" +== 238 +-- truncate_limit: 100 +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ddtest2" +== 239 +-- truncate_limit: 100 +drop type rposint +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE rposint" +== 240 +-- truncate_limit: 100 +alter domain posint add constraint c1 check(value >= 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN posint ADD CONSTRAINT c1 CHECK (value >= 0)" +== 241 +-- truncate_limit: 100 +create domain posint2 as posint check (value % 2 = 0) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN posint2 AS posint CHECK ((value % 2) = 0)" +== 242 +-- truncate_limit: 100 +create table ddtest2(f1 posint2) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ddtest2 (f1 posint2)" +== 243 +-- truncate_limit: 100 +insert into ddtest2 values(11) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ddtest2 VALUES (11)" +== 244 +-- truncate_limit: 100 +-- fail +insert into ddtest2 values(-2) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ddtest2 VALUES (-2)" +== 245 +-- truncate_limit: 100 +-- fail +insert into ddtest2 values(2) +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ddtest2 VALUES (2)" +== 246 +-- truncate_limit: 100 +alter domain posint add constraint c2 check(value >= 10) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN posint ADD CONSTRAINT c2 CHECK (value >= 10)" +== 247 +-- truncate_limit: 100 +-- fail +alter domain posint add constraint c2 check(value > 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN posint ADD CONSTRAINT c2 CHECK (value > 0)" +== 248 +-- truncate_limit: 100 +-- OK + +drop table ddtest2 +-- +TABLE: name="ddtest2" schema="" table="ddtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ddtest2" +== 249 +-- truncate_limit: 100 +drop type ddtest1 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE ddtest1" +== 250 +-- truncate_limit: 100 +drop domain posint cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN posint CASCADE" +== 251 +-- truncate_limit: 100 +|-- +-- Check enforcement of domain-related typmod in plpgsql (bug #5717) +|-- + +create or replace function array_elem_check(numeric) returns numeric as $$ +declare + x numeric(4,2)[1]; +begin + x[1] := $1; + return x[1]; +end$$ language plpgsql +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION array_elem_check(numeric) RETURNS numeric AS $$\ndeclare\n x numeric(4,..." +== 252 +-- truncate_limit: 100 +select array_elem_check(121.00) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_elem_check(121.00)" +== 253 +-- truncate_limit: 100 +select array_elem_check(1.23456) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_elem_check(1.23456)" +== 254 +-- truncate_limit: 100 +create domain mynums as numeric(4,2)[1] +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN mynums AS numeric(4, 2)[1]" +== 255 +-- truncate_limit: 100 +create or replace function array_elem_check(numeric) returns numeric as $$ +declare + x mynums; +begin + x[1] := $1; + return x[1]; +end$$ language plpgsql +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION array_elem_check(numeric) RETURNS numeric AS $$\ndeclare\n x mynums;\nbe..." +== 256 +-- truncate_limit: 100 +select array_elem_check(121.00) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_elem_check(121.00)" +== 257 +-- truncate_limit: 100 +select array_elem_check(1.23456) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_elem_check(1.23456)" +== 258 +-- truncate_limit: 100 +create domain mynums2 as mynums +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN mynums2 AS mynums" +== 259 +-- truncate_limit: 100 +create or replace function array_elem_check(numeric) returns numeric as $$ +declare + x mynums2; +begin + x[1] := $1; + return x[1]; +end$$ language plpgsql +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION array_elem_check(numeric) RETURNS numeric AS $$\ndeclare\n x mynums2;\nb..." +== 260 +-- truncate_limit: 100 +select array_elem_check(121.00) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_elem_check(121.00)" +== 261 +-- truncate_limit: 100 +select array_elem_check(1.23456) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_elem_check(1.23456)" +== 262 +-- truncate_limit: 100 +drop function array_elem_check(numeric) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION array_elem_check(numeric)" +== 263 +-- truncate_limit: 100 +|-- +-- Check enforcement of array-level domain constraints +|-- + +create domain orderedpair as int[2] check (value[1] < value[2]) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN orderedpair AS int[2] CHECK (value[1] < value[2])" +== 264 +-- truncate_limit: 100 +select array[1,2]::orderedpair +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, 2]::orderedpair" +== 265 +-- truncate_limit: 100 +select array[2,1]::orderedpair +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[2, 1]::orderedpair" +== 266 +-- truncate_limit: 100 +-- fail + +create temp table op (f1 orderedpair) +-- +TABLE: name="op" schema="" table="op" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE op (f1 orderedpair)" +== 267 +-- truncate_limit: 100 +insert into op values (array[1,2]) +-- +TABLE: name="op" schema="" table="op" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO op VALUES (ARRAY[1, 2])" +== 268 +-- truncate_limit: 100 +insert into op values (array[2,1]) +-- +TABLE: name="op" schema="" table="op" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO op VALUES (ARRAY[2, 1])" +== 269 +-- truncate_limit: 100 +-- fail + +update op set f1[2] = 3 +-- +TABLE: name="op" schema="" table="op" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE op SET f1[2] = 3" +== 270 +-- truncate_limit: 100 +update op set f1[2] = 0 +-- +TABLE: name="op" schema="" table="op" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE op SET f1[2] = 0" +== 271 +-- truncate_limit: 100 +-- fail +select * from op +-- +TABLE: name="op" schema="" table="op" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM op" +== 272 +-- truncate_limit: 100 +create or replace function array_elem_check(int) returns int as $$ +declare + x orderedpair := '{1,2}'; +begin + x[2] := $1; + return x[2]; +end$$ language plpgsql +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION array_elem_check(int) RETURNS int AS $$\ndeclare\n x orderedpair := '{1..." +== 273 +-- truncate_limit: 100 +select array_elem_check(3) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_elem_check(3)" +== 274 +-- truncate_limit: 100 +select array_elem_check(-1) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_elem_check(-1)" +== 275 +-- truncate_limit: 100 +drop function array_elem_check(int) +-- +FUNCTION: name="array_elem_check" function="array_elem_check" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION array_elem_check(int)" +== 276 +-- truncate_limit: 100 +|-- +-- Check enforcement of changing constraints in plpgsql +|-- + +create domain di as int +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN di AS int" +== 277 +-- truncate_limit: 100 +create function dom_check(int) returns di as $$ +declare d di; +begin + d := $1::di; + return d; +end +$$ language plpgsql immutable +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dom_check(int) RETURNS di AS $$\ndeclare d di;\nbegin\n d := $1::di;\n return d;\nen..." +== 278 +-- truncate_limit: 100 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dom_check(0)" +== 279 +-- truncate_limit: 100 +alter domain di add constraint pos check (value > 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN di ADD CONSTRAINT pos CHECK (value > 0)" +== 280 +-- truncate_limit: 100 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dom_check(0)" +== 281 +-- truncate_limit: 100 +-- fail + +alter domain di drop constraint pos +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN di DROP CONSTRAINT pos" +== 282 +-- truncate_limit: 100 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dom_check(0)" +== 283 +-- truncate_limit: 100 +-- implicit cast during assignment is a separate code path, test that too + +create or replace function dom_check(int) returns di as $$ +declare d di; +begin + d := $1; + return d; +end +$$ language plpgsql immutable +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dom_check(int) RETURNS di AS $$\ndeclare d di;\nbegin\n d := $1;\n retur..." +== 284 +-- truncate_limit: 100 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dom_check(0)" +== 285 +-- truncate_limit: 100 +alter domain di add constraint pos check (value > 0) +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN di ADD CONSTRAINT pos CHECK (value > 0)" +== 286 +-- truncate_limit: 100 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dom_check(0)" +== 287 +-- truncate_limit: 100 +-- fail + +alter domain di drop constraint pos +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN di DROP CONSTRAINT pos" +== 288 +-- truncate_limit: 100 +select dom_check(0) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dom_check(0)" +== 289 +-- truncate_limit: 100 +drop function dom_check(int) +-- +FUNCTION: name="dom_check" function="dom_check" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dom_check(int)" +== 290 +-- truncate_limit: 100 +drop domain di +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN di" +== 291 +-- truncate_limit: 100 +|-- +-- Check use of a (non-inline-able) SQL function in a domain constraint; +-- this has caused issues in the past +|-- + +create function sql_is_distinct_from(anyelement, anyelement) +returns boolean language sql +as 'select $1 is distinct from $2 limit 1' +-- +FUNCTION: name="sql_is_distinct_from" function="sql_is_distinct_from" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sql_is_distinct_from(anyelement, anyelement) RETURNS boolean LANGUAGE sql AS $$se..." +== 292 +-- truncate_limit: 100 +create domain inotnull int + check (sql_is_distinct_from(value, null)) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN inotnull AS int CHECK (sql_is_distinct_from(value, NULL))" +== 293 +-- truncate_limit: 100 +select 1::inotnull +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1::inotnull" +== 294 +-- truncate_limit: 100 +select null::inotnull +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::inotnull" +== 295 +-- truncate_limit: 100 +create table dom_table (x inotnull) +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dom_table (x inotnull)" +== 296 +-- truncate_limit: 100 +insert into dom_table values ('1') +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dom_table VALUES ('1')" +== 297 +-- truncate_limit: 100 +insert into dom_table values (1) +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dom_table VALUES (1)" +== 298 +-- truncate_limit: 100 +insert into dom_table values (null) +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dom_table VALUES (NULL)" +== 299 +-- truncate_limit: 100 +drop table dom_table +-- +TABLE: name="dom_table" schema="" table="dom_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE dom_table" +== 300 +-- truncate_limit: 100 +drop domain inotnull +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN inotnull" +== 301 +-- truncate_limit: 100 +drop function sql_is_distinct_from(anyelement, anyelement) +-- +FUNCTION: name="sql_is_distinct_from" function="sql_is_distinct_from" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION sql_is_distinct_from(anyelement, anyelement)" +== 302 +-- truncate_limit: 100 +|-- +-- Renaming +|-- + +create domain testdomain1 as int +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain1 AS int" +== 303 +-- truncate_limit: 100 +alter domain testdomain1 rename to testdomain2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER DOMAIN testdomain1 RENAME TO testdomain2" +== 304 +-- truncate_limit: 100 +alter type testdomain2 rename to testdomain3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TYPE testdomain2 RENAME TO testdomain3" +== 305 +-- truncate_limit: 100 +-- alter type also works +drop domain testdomain3 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN testdomain3" +== 306 +-- truncate_limit: 100 +|-- +-- Renaming domain constraints +|-- + +create domain testdomain1 as int constraint unsigned check (value > 0) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdomain1 AS int CONSTRAINT unsigned CHECK (value > 0)" +== 307 +-- truncate_limit: 100 +alter domain testdomain1 rename constraint unsigned to unsigned_foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER DOMAIN testdomain1 RENAME CONSTRAINT unsigned TO unsigned_foo" +== 308 +-- truncate_limit: 100 +alter domain testdomain1 drop constraint unsigned_foo +-- +STMT: AlterDomainStmt +TRUNCATED: "ALTER DOMAIN testdomain1 DROP CONSTRAINT unsigned_foo" +== 309 +-- truncate_limit: 100 +drop domain testdomain1 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN testdomain1" +== 310 +-- truncate_limit: 100 +|-- +-- Get the base type of a domain +|-- +create domain mytext as text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN mytext AS text" +== 311 +-- truncate_limit: 100 +create domain mytext_child_1 as mytext +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN mytext_child_1 AS mytext" +== 312 +-- truncate_limit: 100 +select pg_basetype('mytext'::regtype) +-- +FUNCTION: name="pg_basetype" function="pg_basetype" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_basetype('mytext'::regtype)" +== 313 +-- truncate_limit: 100 +select pg_basetype('mytext_child_1'::regtype) +-- +FUNCTION: name="pg_basetype" function="pg_basetype" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_basetype('mytext_child_1'::regtype)" +== 314 +-- truncate_limit: 100 +select pg_basetype(1) +-- +FUNCTION: name="pg_basetype" function="pg_basetype" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_basetype(1)" +== 315 +-- truncate_limit: 100 +-- expect NULL not error + +drop domain mytext cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN mytext CASCADE" +== 316 +-- truncate_limit: 100 +|-- +-- Information schema +|-- + +SELECT * FROM information_schema.column_domain_usage + WHERE domain_name IN ('con', 'dom', 'pos_int', 'things') + ORDER BY domain_name +-- +TABLE: name="information_schema.column_domain_usage" schema="information_schema" table="column_domain_usage" ctx=Select +FILTER: schema="" table="" column="domain_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.column_domain_usage WHERE ... ORDER BY domain_name" +== 317 +-- truncate_limit: 100 +SELECT * FROM information_schema.domain_constraints + WHERE domain_name IN ('con', 'dom', 'pos_int', 'things') + ORDER BY constraint_name +-- +TABLE: name="information_schema.domain_constraints" schema="information_schema" table="domain_constraints" ctx=Select +FILTER: schema="" table="" column="domain_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.domain_constraints WHERE ... ORDER BY constraint_name" +== 318 +-- truncate_limit: 100 +SELECT * FROM information_schema.domains + WHERE domain_name IN ('con', 'dom', 'pos_int', 'things') + ORDER BY domain_name +-- +TABLE: name="information_schema.domains" schema="information_schema" table="domains" ctx=Select +FILTER: schema="" table="" column="domain_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.domains WHERE ... ORDER BY domain_name" +== 319 +-- truncate_limit: 100 +SELECT * FROM information_schema.check_constraints + WHERE (constraint_schema, constraint_name) + IN (SELECT constraint_schema, constraint_name + FROM information_schema.domain_constraints + WHERE domain_name IN ('con', 'dom', 'pos_int', 'things')) + ORDER BY constraint_name +-- +TABLE: name="information_schema.check_constraints" schema="information_schema" table="check_constraints" ctx=Select +TABLE: name="information_schema.domain_constraints" schema="information_schema" table="domain_constraints" ctx=Select +FILTER: schema="" table="" column="constraint_schema" +FILTER: schema="" table="" column="constraint_name" +FILTER: schema="" table="" column="domain_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.check_constraints WHERE ... ORDER BY constraint_name" diff --git a/parser/testdata/summary_truncate/postgres_regress/drop_if_exists.metadata.json b/parser/testdata/summary_truncate/postgres_regress/drop_if_exists.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/drop_if_exists.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/drop_if_exists.test b/parser/testdata/summary_truncate/postgres_regress/drop_if_exists.test new file mode 100644 index 0000000..7e83e24 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/drop_if_exists.test @@ -0,0 +1,1072 @@ +== 001 +-- truncate_limit: 100 +|-- +-- IF EXISTS tests +|-- + +-- table (will be really dropped at the end) + +DROP TABLE test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_exists" +== 002 +-- truncate_limit: 100 +DROP TABLE IF EXISTS test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE IF EXISTS test_exists" +== 003 +-- truncate_limit: 100 +CREATE TABLE test_exists (a int, b text) +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_exists (a int, b text)" +== 004 +-- truncate_limit: 100 +-- view + +DROP VIEW test_view_exists +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW test_view_exists" +== 005 +-- truncate_limit: 100 +DROP VIEW IF EXISTS test_view_exists +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW IF EXISTS test_view_exists" +== 006 +-- truncate_limit: 100 +CREATE VIEW test_view_exists AS select * from test_exists +-- +TABLE: name="test_view_exists" schema="" table="test_view_exists" ctx=DDL +TABLE: name="test_exists" schema="" table="test_exists" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW test_view_exists AS SELECT * FROM test_exists" +== 007 +-- truncate_limit: 100 +DROP VIEW IF EXISTS test_view_exists +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW IF EXISTS test_view_exists" +== 008 +-- truncate_limit: 100 +DROP VIEW test_view_exists +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW test_view_exists" +== 009 +-- truncate_limit: 100 +-- index + +DROP INDEX test_index_exists +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX test_index_exists" +== 010 +-- truncate_limit: 100 +DROP INDEX IF EXISTS test_index_exists +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX IF EXISTS test_index_exists" +== 011 +-- truncate_limit: 100 +CREATE INDEX test_index_exists on test_exists(a) +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_index_exists ON test_exists USING btree (a)" +== 012 +-- truncate_limit: 100 +DROP INDEX IF EXISTS test_index_exists +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX IF EXISTS test_index_exists" +== 013 +-- truncate_limit: 100 +DROP INDEX test_index_exists +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX test_index_exists" +== 014 +-- truncate_limit: 100 +-- sequence + +DROP SEQUENCE test_sequence_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE test_sequence_exists" +== 015 +-- truncate_limit: 100 +DROP SEQUENCE IF EXISTS test_sequence_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE IF EXISTS test_sequence_exists" +== 016 +-- truncate_limit: 100 +CREATE SEQUENCE test_sequence_exists +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE test_sequence_exists" +== 017 +-- truncate_limit: 100 +DROP SEQUENCE IF EXISTS test_sequence_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE IF EXISTS test_sequence_exists" +== 018 +-- truncate_limit: 100 +DROP SEQUENCE test_sequence_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE test_sequence_exists" +== 019 +-- truncate_limit: 100 +-- schema + +DROP SCHEMA test_schema_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA test_schema_exists" +== 020 +-- truncate_limit: 100 +DROP SCHEMA IF EXISTS test_schema_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA IF EXISTS test_schema_exists" +== 021 +-- truncate_limit: 100 +CREATE SCHEMA test_schema_exists +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_schema_exists" +== 022 +-- truncate_limit: 100 +DROP SCHEMA IF EXISTS test_schema_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA IF EXISTS test_schema_exists" +== 023 +-- truncate_limit: 100 +DROP SCHEMA test_schema_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA test_schema_exists" +== 024 +-- truncate_limit: 100 +-- type + +DROP TYPE test_type_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE test_type_exists" +== 025 +-- truncate_limit: 100 +DROP TYPE IF EXISTS test_type_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE IF EXISTS test_type_exists" +== 026 +-- truncate_limit: 100 +CREATE type test_type_exists as (a int, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE test_type_exists AS (a int, b text)" +== 027 +-- truncate_limit: 100 +DROP TYPE IF EXISTS test_type_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE IF EXISTS test_type_exists" +== 028 +-- truncate_limit: 100 +DROP TYPE test_type_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE test_type_exists" +== 029 +-- truncate_limit: 100 +-- domain + +DROP DOMAIN test_domain_exists +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN test_domain_exists" +== 030 +-- truncate_limit: 100 +DROP DOMAIN IF EXISTS test_domain_exists +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN IF EXISTS test_domain_exists" +== 031 +-- truncate_limit: 100 +CREATE domain test_domain_exists as int not null check (value > 0) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN test_domain_exists AS int NOT NULL CHECK (value > 0)" +== 032 +-- truncate_limit: 100 +DROP DOMAIN IF EXISTS test_domain_exists +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN IF EXISTS test_domain_exists" +== 033 +-- truncate_limit: 100 +DROP DOMAIN test_domain_exists +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN test_domain_exists" +== 034 +-- truncate_limit: 100 +--- +--- role/user/group +--- + +CREATE USER regress_test_u1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_test_u1" +== 035 +-- truncate_limit: 100 +CREATE ROLE regress_test_r1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_r1" +== 036 +-- truncate_limit: 100 +CREATE GROUP regress_test_g1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE GROUP regress_test_g1" +== 037 +-- truncate_limit: 100 +DROP USER regress_test_u2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_u2" +== 038 +-- truncate_limit: 100 +DROP USER IF EXISTS regress_test_u1, regress_test_u2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_test_u1, regress_test_u2" +== 039 +-- truncate_limit: 100 +DROP USER regress_test_u1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_u1" +== 040 +-- truncate_limit: 100 +DROP ROLE regress_test_r2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_r2" +== 041 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_test_r1, regress_test_r2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_test_r1, regress_test_r2" +== 042 +-- truncate_limit: 100 +DROP ROLE regress_test_r1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_r1" +== 043 +-- truncate_limit: 100 +DROP GROUP regress_test_g2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_g2" +== 044 +-- truncate_limit: 100 +DROP GROUP IF EXISTS regress_test_g1, regress_test_g2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_test_g1, regress_test_g2" +== 045 +-- truncate_limit: 100 +DROP GROUP regress_test_g1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_g1" +== 046 +-- truncate_limit: 100 +-- collation +DROP COLLATION IF EXISTS test_collation_exists +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION IF EXISTS test_collation_exists" +== 047 +-- truncate_limit: 100 +-- conversion +DROP CONVERSION test_conversion_exists +-- +STMT: DropStmt +TRUNCATED: "DROP CONVERSION test_conversion_exists" +== 048 +-- truncate_limit: 100 +DROP CONVERSION IF EXISTS test_conversion_exists +-- +STMT: DropStmt +TRUNCATED: "DROP CONVERSION IF EXISTS test_conversion_exists" +== 049 +-- truncate_limit: 100 +CREATE CONVERSION test_conversion_exists + FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8 +-- +STMT: CreateConversionStmt +TRUNCATED: "CREATE CONVERSION test_conversion_exists FOR 'LATIN1' TO 'UTF8'FROM iso8859_1_to_utf8" +== 050 +-- truncate_limit: 100 +DROP CONVERSION test_conversion_exists +-- +STMT: DropStmt +TRUNCATED: "DROP CONVERSION test_conversion_exists" +== 051 +-- truncate_limit: 100 +-- text search parser +DROP TEXT SEARCH PARSER test_tsparser_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH PARSER test_tsparser_exists" +== 052 +-- truncate_limit: 100 +DROP TEXT SEARCH PARSER IF EXISTS test_tsparser_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH PARSER IF EXISTS test_tsparser_exists" +== 053 +-- truncate_limit: 100 +-- text search dictionary +DROP TEXT SEARCH DICTIONARY test_tsdict_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH DICTIONARY test_tsdict_exists" +== 054 +-- truncate_limit: 100 +DROP TEXT SEARCH DICTIONARY IF EXISTS test_tsdict_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH DICTIONARY IF EXISTS test_tsdict_exists" +== 055 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY test_tsdict_exists ( + Template=ispell, + DictFile=ispell_sample, + AffFile=ispell_sample +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY test_tsdict_exists (template = ispell, dictfile = ispell_sample, af..." +== 056 +-- truncate_limit: 100 +DROP TEXT SEARCH DICTIONARY test_tsdict_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH DICTIONARY test_tsdict_exists" +== 057 +-- truncate_limit: 100 +-- test search template +DROP TEXT SEARCH TEMPLATE test_tstemplate_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH TEMPLATE test_tstemplate_exists" +== 058 +-- truncate_limit: 100 +DROP TEXT SEARCH TEMPLATE IF EXISTS test_tstemplate_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH TEMPLATE IF EXISTS test_tstemplate_exists" +== 059 +-- truncate_limit: 100 +-- text search configuration +DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists" +== 060 +-- truncate_limit: 100 +DROP TEXT SEARCH CONFIGURATION IF EXISTS test_tsconfig_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH CONFIGURATION IF EXISTS test_tsconfig_exists" +== 061 +-- truncate_limit: 100 +CREATE TEXT SEARCH CONFIGURATION test_tsconfig_exists (COPY=english) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION test_tsconfig_exists (copy = english)" +== 062 +-- truncate_limit: 100 +DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists" +== 063 +-- truncate_limit: 100 +-- extension +DROP EXTENSION test_extension_exists +-- +STMT: DropStmt +TRUNCATED: "DROP EXTENSION test_extension_exists" +== 064 +-- truncate_limit: 100 +DROP EXTENSION IF EXISTS test_extension_exists +-- +STMT: DropStmt +TRUNCATED: "DROP EXTENSION IF EXISTS test_extension_exists" +== 065 +-- truncate_limit: 100 +-- functions +DROP FUNCTION test_function_exists() +-- +FUNCTION: name="test_function_exists" function="test_function_exists" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION test_function_exists()" +== 066 +-- truncate_limit: 100 +DROP FUNCTION IF EXISTS test_function_exists() +-- +FUNCTION: name="test_function_exists" function="test_function_exists" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION IF EXISTS test_function_exists()" +== 067 +-- truncate_limit: 100 +DROP FUNCTION test_function_exists(int, text, int[]) +-- +FUNCTION: name="test_function_exists" function="test_function_exists" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION test_function_exists(int, text, int[])" +== 068 +-- truncate_limit: 100 +DROP FUNCTION IF EXISTS test_function_exists(int, text, int[]) +-- +FUNCTION: name="test_function_exists" function="test_function_exists" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION IF EXISTS test_function_exists(int, text, int[])" +== 069 +-- truncate_limit: 100 +-- aggregate +DROP AGGREGATE test_aggregate_exists(*) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE test_aggregate_exists(*)" +== 070 +-- truncate_limit: 100 +DROP AGGREGATE IF EXISTS test_aggregate_exists(*) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE IF EXISTS test_aggregate_exists(*)" +== 071 +-- truncate_limit: 100 +DROP AGGREGATE test_aggregate_exists(int) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE test_aggregate_exists(int)" +== 072 +-- truncate_limit: 100 +DROP AGGREGATE IF EXISTS test_aggregate_exists(int) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE IF EXISTS test_aggregate_exists(int)" +== 073 +-- truncate_limit: 100 +-- operator +DROP OPERATOR @#@ (int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR @#@(int, int)" +== 074 +-- truncate_limit: 100 +DROP OPERATOR IF EXISTS @#@ (int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR IF EXISTS @#@(int, int)" +== 075 +-- truncate_limit: 100 +CREATE OPERATOR @#@ + (leftarg = int8, rightarg = int8, procedure = int8xor) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR @#@ (leftarg = int8, rightarg = int8, procedure = int8xor)" +== 076 +-- truncate_limit: 100 +DROP OPERATOR @#@ (int8, int8) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR @#@(int8, int8)" +== 077 +-- truncate_limit: 100 +-- language +DROP LANGUAGE test_language_exists +-- +STMT: DropStmt +TRUNCATED: "DROP LANGUAGE test_language_exists" +== 078 +-- truncate_limit: 100 +DROP LANGUAGE IF EXISTS test_language_exists +-- +STMT: DropStmt +TRUNCATED: "DROP LANGUAGE IF EXISTS test_language_exists" +== 079 +-- truncate_limit: 100 +-- cast +DROP CAST (text AS text) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST (text AS text)" +== 080 +-- truncate_limit: 100 +DROP CAST IF EXISTS (text AS text) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST IF EXISTS (text AS text)" +== 081 +-- truncate_limit: 100 +-- trigger +DROP TRIGGER test_trigger_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER test_trigger_exists ON test_exists" +== 082 +-- truncate_limit: 100 +DROP TRIGGER IF EXISTS test_trigger_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER IF EXISTS test_trigger_exists ON test_exists" +== 083 +-- truncate_limit: 100 +DROP TRIGGER test_trigger_exists ON no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER test_trigger_exists ON no_such_table" +== 084 +-- truncate_limit: 100 +DROP TRIGGER IF EXISTS test_trigger_exists ON no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER IF EXISTS test_trigger_exists ON no_such_table" +== 085 +-- truncate_limit: 100 +DROP TRIGGER test_trigger_exists ON no_such_schema.no_such_table +-- +TABLE: name="no_such_schema.no_such_table" schema="no_such_schema" table="no_such_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER test_trigger_exists ON no_such_schema.no_such_table" +== 086 +-- truncate_limit: 100 +DROP TRIGGER IF EXISTS test_trigger_exists ON no_such_schema.no_such_table +-- +TABLE: name="no_such_schema.no_such_table" schema="no_such_schema" table="no_such_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER IF EXISTS test_trigger_exists ON no_such_schema.no_such_table" +== 087 +-- truncate_limit: 100 +CREATE TRIGGER test_trigger_exists + BEFORE UPDATE ON test_exists + FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger() +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER test_trigger_exists BEFORE UPDATE ON test_exists FOR EACH ROW EXECUTE FUNCTION sup..." +== 088 +-- truncate_limit: 100 +DROP TRIGGER test_trigger_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER test_trigger_exists ON test_exists" +== 089 +-- truncate_limit: 100 +-- rule +DROP RULE test_rule_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE test_rule_exists ON test_exists" +== 090 +-- truncate_limit: 100 +DROP RULE IF EXISTS test_rule_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE IF EXISTS test_rule_exists ON test_exists" +== 091 +-- truncate_limit: 100 +DROP RULE test_rule_exists ON no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE test_rule_exists ON no_such_table" +== 092 +-- truncate_limit: 100 +DROP RULE IF EXISTS test_rule_exists ON no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE IF EXISTS test_rule_exists ON no_such_table" +== 093 +-- truncate_limit: 100 +DROP RULE test_rule_exists ON no_such_schema.no_such_table +-- +TABLE: name="no_such_schema.no_such_table" schema="no_such_schema" table="no_such_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE test_rule_exists ON no_such_schema.no_such_table" +== 094 +-- truncate_limit: 100 +DROP RULE IF EXISTS test_rule_exists ON no_such_schema.no_such_table +-- +TABLE: name="no_such_schema.no_such_table" schema="no_such_schema" table="no_such_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE IF EXISTS test_rule_exists ON no_such_schema.no_such_table" +== 095 +-- truncate_limit: 100 +CREATE RULE test_rule_exists AS ON INSERT TO test_exists + DO INSTEAD + INSERT INTO test_exists VALUES (NEW.a, NEW.b || NEW.a::text) +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE test_rule_exists AS ON INSERT TO test_exists DO INSTEAD INSERT INTO test_exists VALUE..." +== 096 +-- truncate_limit: 100 +DROP RULE test_rule_exists ON test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE test_rule_exists ON test_exists" +== 097 +-- truncate_limit: 100 +-- foreign data wrapper +DROP FOREIGN DATA WRAPPER test_fdw_exists +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER test_fdw_exists" +== 098 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER IF EXISTS test_fdw_exists +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER IF EXISTS test_fdw_exists" +== 099 +-- truncate_limit: 100 +-- foreign server +DROP SERVER test_server_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER test_server_exists" +== 100 +-- truncate_limit: 100 +DROP SERVER IF EXISTS test_server_exists +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER IF EXISTS test_server_exists" +== 101 +-- truncate_limit: 100 +-- operator class +DROP OPERATOR CLASS test_operator_class USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS test_operator_class USING btree" +== 102 +-- truncate_limit: 100 +DROP OPERATOR CLASS IF EXISTS test_operator_class USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS IF EXISTS test_operator_class USING btree" +== 103 +-- truncate_limit: 100 +DROP OPERATOR CLASS test_operator_class USING no_such_am +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS test_operator_class USING no_such_am" +== 104 +-- truncate_limit: 100 +DROP OPERATOR CLASS IF EXISTS test_operator_class USING no_such_am +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS IF EXISTS test_operator_class USING no_such_am" +== 105 +-- truncate_limit: 100 +-- operator family +DROP OPERATOR FAMILY test_operator_family USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY test_operator_family USING btree" +== 106 +-- truncate_limit: 100 +DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY IF EXISTS test_operator_family USING btree" +== 107 +-- truncate_limit: 100 +DROP OPERATOR FAMILY test_operator_family USING no_such_am +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY test_operator_family USING no_such_am" +== 108 +-- truncate_limit: 100 +DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY IF EXISTS test_operator_family USING no_such_am" +== 109 +-- truncate_limit: 100 +-- access method +DROP ACCESS METHOD no_such_am +-- +STMT: DropStmt +TRUNCATED: "DROP ACCESS METHOD no_such_am" +== 110 +-- truncate_limit: 100 +DROP ACCESS METHOD IF EXISTS no_such_am +-- +STMT: DropStmt +TRUNCATED: "DROP ACCESS METHOD IF EXISTS no_such_am" +== 111 +-- truncate_limit: 100 +-- drop the table + +DROP TABLE IF EXISTS test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE IF EXISTS test_exists" +== 112 +-- truncate_limit: 100 +DROP TABLE test_exists +-- +TABLE: name="test_exists" schema="" table="test_exists" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_exists" +== 113 +-- truncate_limit: 100 +-- be tolerant with missing schemas, types, etc + +DROP AGGREGATE IF EXISTS no_such_schema.foo(int) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE IF EXISTS no_such_schema.foo(int)" +== 114 +-- truncate_limit: 100 +DROP AGGREGATE IF EXISTS foo(no_such_type) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE IF EXISTS foo(no_such_type)" +== 115 +-- truncate_limit: 100 +DROP AGGREGATE IF EXISTS foo(no_such_schema.no_such_type) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE IF EXISTS foo(no_such_schema.no_such_type)" +== 116 +-- truncate_limit: 100 +DROP CAST IF EXISTS (INTEGER AS no_such_type2) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST IF EXISTS (int AS no_such_type2)" +== 117 +-- truncate_limit: 100 +DROP CAST IF EXISTS (no_such_type1 AS INTEGER) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST IF EXISTS (no_such_type1 AS int)" +== 118 +-- truncate_limit: 100 +DROP CAST IF EXISTS (INTEGER AS no_such_schema.bar) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST IF EXISTS (int AS no_such_schema.bar)" +== 119 +-- truncate_limit: 100 +DROP CAST IF EXISTS (no_such_schema.foo AS INTEGER) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST IF EXISTS (no_such_schema.foo AS int)" +== 120 +-- truncate_limit: 100 +DROP COLLATION IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION IF EXISTS no_such_schema.foo" +== 121 +-- truncate_limit: 100 +DROP CONVERSION IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP CONVERSION IF EXISTS no_such_schema.foo" +== 122 +-- truncate_limit: 100 +DROP DOMAIN IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN IF EXISTS no_such_schema.foo" +== 123 +-- truncate_limit: 100 +DROP FOREIGN TABLE IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE IF EXISTS no_such_schema.foo" +== 124 +-- truncate_limit: 100 +DROP FUNCTION IF EXISTS no_such_schema.foo() +-- +FUNCTION: name="no_such_schema.foo" function="foo" schema="no_such_schema" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION IF EXISTS no_such_schema.foo()" +== 125 +-- truncate_limit: 100 +DROP FUNCTION IF EXISTS foo(no_such_type) +-- +FUNCTION: name="foo" function="foo" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION IF EXISTS foo(no_such_type)" +== 126 +-- truncate_limit: 100 +DROP FUNCTION IF EXISTS foo(no_such_schema.no_such_type) +-- +FUNCTION: name="foo" function="foo" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION IF EXISTS foo(no_such_schema.no_such_type)" +== 127 +-- truncate_limit: 100 +DROP INDEX IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX IF EXISTS no_such_schema.foo" +== 128 +-- truncate_limit: 100 +DROP MATERIALIZED VIEW IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW IF EXISTS no_such_schema.foo" +== 129 +-- truncate_limit: 100 +DROP OPERATOR IF EXISTS no_such_schema.+ (int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR IF EXISTS no_such_schema.+(int, int)" +== 130 +-- truncate_limit: 100 +DROP OPERATOR IF EXISTS + (no_such_type, no_such_type) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR IF EXISTS +(no_such_type, no_such_type)" +== 131 +-- truncate_limit: 100 +DROP OPERATOR IF EXISTS + (no_such_schema.no_such_type, no_such_schema.no_such_type) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR IF EXISTS +(no_such_schema.no_such_type, no_such_schema.no_such_type)" +== 132 +-- truncate_limit: 100 +DROP OPERATOR IF EXISTS # (NONE, no_such_schema.no_such_type) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR IF EXISTS #(NONE, no_such_schema.no_such_type)" +== 133 +-- truncate_limit: 100 +DROP OPERATOR CLASS IF EXISTS no_such_schema.widget_ops USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS IF EXISTS no_such_schema.widget_ops USING btree" +== 134 +-- truncate_limit: 100 +DROP OPERATOR FAMILY IF EXISTS no_such_schema.float_ops USING btree +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR FAMILY IF EXISTS no_such_schema.float_ops USING btree" +== 135 +-- truncate_limit: 100 +DROP RULE IF EXISTS foo ON no_such_schema.bar +-- +TABLE: name="no_such_schema.bar" schema="no_such_schema" table="bar" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE IF EXISTS foo ON no_such_schema.bar" +== 136 +-- truncate_limit: 100 +DROP SEQUENCE IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE IF EXISTS no_such_schema.foo" +== 137 +-- truncate_limit: 100 +DROP TABLE IF EXISTS no_such_schema.foo +-- +TABLE: name="no_such_schema.foo" schema="no_such_schema" table="foo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE IF EXISTS no_such_schema.foo" +== 138 +-- truncate_limit: 100 +DROP TEXT SEARCH CONFIGURATION IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH CONFIGURATION IF EXISTS no_such_schema.foo" +== 139 +-- truncate_limit: 100 +DROP TEXT SEARCH DICTIONARY IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH DICTIONARY IF EXISTS no_such_schema.foo" +== 140 +-- truncate_limit: 100 +DROP TEXT SEARCH PARSER IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH PARSER IF EXISTS no_such_schema.foo" +== 141 +-- truncate_limit: 100 +DROP TEXT SEARCH TEMPLATE IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH TEMPLATE IF EXISTS no_such_schema.foo" +== 142 +-- truncate_limit: 100 +DROP TRIGGER IF EXISTS foo ON no_such_schema.bar +-- +TABLE: name="no_such_schema.bar" schema="no_such_schema" table="bar" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER IF EXISTS foo ON no_such_schema.bar" +== 143 +-- truncate_limit: 100 +DROP TYPE IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE IF EXISTS no_such_schema.foo" +== 144 +-- truncate_limit: 100 +DROP VIEW IF EXISTS no_such_schema.foo +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW IF EXISTS no_such_schema.foo" +== 145 +-- truncate_limit: 100 +-- Check we receive an ambiguous function error when there are +-- multiple matching functions. +CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ language sql +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_ambiguous_funcname(int) RETURNS int AS $$ select $1; $$ LANGUAGE sql" +== 146 +-- truncate_limit: 100 +CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ language sql +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_ambiguous_funcname(text) RETURNS text AS $$ select $1; $$ LANGUAGE sql" +== 147 +-- truncate_limit: 100 +DROP FUNCTION test_ambiguous_funcname +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION test_ambiguous_funcname" +== 148 +-- truncate_limit: 100 +DROP FUNCTION IF EXISTS test_ambiguous_funcname +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION IF EXISTS test_ambiguous_funcname" +== 149 +-- truncate_limit: 100 +-- cleanup +DROP FUNCTION test_ambiguous_funcname(int) +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION test_ambiguous_funcname(int)" +== 150 +-- truncate_limit: 100 +DROP FUNCTION test_ambiguous_funcname(text) +-- +FUNCTION: name="test_ambiguous_funcname" function="test_ambiguous_funcname" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION test_ambiguous_funcname(text)" +== 151 +-- truncate_limit: 100 +-- Likewise for procedures. +CREATE PROCEDURE test_ambiguous_procname(int) as $$ begin end; $$ language plpgsql +-- +FUNCTION: name="test_ambiguous_procname" function="test_ambiguous_procname" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE test_ambiguous_procname(int) AS $$ begin end; $$ LANGUAGE plpgsql" +== 152 +-- truncate_limit: 100 +CREATE PROCEDURE test_ambiguous_procname(text) as $$ begin end; $$ language plpgsql +-- +FUNCTION: name="test_ambiguous_procname" function="test_ambiguous_procname" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE test_ambiguous_procname(text) AS $$ begin end; $$ LANGUAGE plpgsql" +== 153 +-- truncate_limit: 100 +DROP PROCEDURE test_ambiguous_procname +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE test_ambiguous_procname" +== 154 +-- truncate_limit: 100 +DROP PROCEDURE IF EXISTS test_ambiguous_procname +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE IF EXISTS test_ambiguous_procname" +== 155 +-- truncate_limit: 100 +-- Check we get a similar error if we use ROUTINE instead of PROCEDURE. +DROP ROUTINE IF EXISTS test_ambiguous_procname +-- +STMT: DropStmt +TRUNCATED: "DROP ROUTINE IF EXISTS test_ambiguous_procname" +== 156 +-- truncate_limit: 100 +-- cleanup +DROP PROCEDURE test_ambiguous_procname(int) +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE test_ambiguous_procname(int)" +== 157 +-- truncate_limit: 100 +DROP PROCEDURE test_ambiguous_procname(text) +-- +STMT: DropStmt +TRUNCATED: "DROP PROCEDURE test_ambiguous_procname(text)" +== 158 +-- truncate_limit: 100 +-- This test checks both the functionality of 'if exists' and the syntax +-- of the drop database command. +drop database test_database_exists (force) +-- +STMT: DropdbStmt +TRUNCATED: "DROP DATABASE test_database_exists (FORCE)" +== 159 +-- truncate_limit: 100 +drop database test_database_exists with (force) +-- +STMT: DropdbStmt +TRUNCATED: "DROP DATABASE test_database_exists (FORCE)" +== 160 +-- truncate_limit: 100 +drop database if exists test_database_exists (force) +-- +STMT: DropdbStmt +TRUNCATED: "DROP DATABASE IF EXISTS test_database_exists (FORCE)" +== 161 +-- truncate_limit: 100 +drop database if exists test_database_exists with (force) +-- +STMT: DropdbStmt +TRUNCATED: "DROP DATABASE IF EXISTS test_database_exists (FORCE)" diff --git a/parser/testdata/summary_truncate/postgres_regress/drop_operator.metadata.json b/parser/testdata/summary_truncate/postgres_regress/drop_operator.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/drop_operator.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/drop_operator.test b/parser/testdata/summary_truncate/postgres_regress/drop_operator.test new file mode 100644 index 0000000..defeca5 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/drop_operator.test @@ -0,0 +1,133 @@ +== 001 +-- truncate_limit: 100 +CREATE OPERATOR === ( + PROCEDURE = int8eq, + LEFTARG = bigint, + RIGHTARG = bigint, + COMMUTATOR = === +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (procedure = int8eq, leftarg = bigint, rightarg = bigint, commutator = ===)" +== 002 +-- truncate_limit: 100 +CREATE OPERATOR !== ( + PROCEDURE = int8ne, + LEFTARG = bigint, + RIGHTARG = bigint, + NEGATOR = ===, + COMMUTATOR = !== +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR !== (procedure = int8ne, leftarg = bigint, rightarg = bigint, negator = ===, comm..." +== 003 +-- truncate_limit: 100 +DROP OPERATOR !==(bigint, bigint) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR !==(bigint, bigint)" +== 004 +-- truncate_limit: 100 +SELECT ctid, oprcom +FROM pg_catalog.pg_operator fk +WHERE oprcom != 0 AND + NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprcom) +-- +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +ALIAS: "fk"="pg_catalog.pg_operator" +ALIAS: "pk"="pg_catalog.pg_operator" +FILTER: schema="" table="" column="oprcom" +FILTER: schema="" table="pk" column="oid" +FILTER: schema="" table="fk" column="oprcom" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, oprcom FROM pg_catalog.pg_operator fk WHERE ..." +== 005 +-- truncate_limit: 100 +SELECT ctid, oprnegate +FROM pg_catalog.pg_operator fk +WHERE oprnegate != 0 AND + NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprnegate) +-- +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +ALIAS: "fk"="pg_catalog.pg_operator" +ALIAS: "pk"="pg_catalog.pg_operator" +FILTER: schema="" table="" column="oprnegate" +FILTER: schema="" table="pk" column="oid" +FILTER: schema="" table="fk" column="oprnegate" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, oprnegate FROM pg_catalog.pg_operator fk WHERE ..." +== 006 +-- truncate_limit: 100 +DROP OPERATOR ===(bigint, bigint) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ===(bigint, bigint)" +== 007 +-- truncate_limit: 100 +CREATE OPERATOR <| ( + PROCEDURE = int8lt, + LEFTARG = bigint, + RIGHTARG = bigint +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR <| (procedure = int8lt, leftarg = bigint, rightarg = bigint)" +== 008 +-- truncate_limit: 100 +CREATE OPERATOR |> ( + PROCEDURE = int8gt, + LEFTARG = bigint, + RIGHTARG = bigint, + NEGATOR = <|, + COMMUTATOR = <| +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR |> (procedure = int8gt, leftarg = bigint, rightarg = bigint, negator = <|, commut..." +== 009 +-- truncate_limit: 100 +DROP OPERATOR |>(bigint, bigint) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR |>(bigint, bigint)" +== 010 +-- truncate_limit: 100 +SELECT ctid, oprcom +FROM pg_catalog.pg_operator fk +WHERE oprcom != 0 AND + NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprcom) +-- +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +ALIAS: "fk"="pg_catalog.pg_operator" +ALIAS: "pk"="pg_catalog.pg_operator" +FILTER: schema="" table="" column="oprcom" +FILTER: schema="" table="pk" column="oid" +FILTER: schema="" table="fk" column="oprcom" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, oprcom FROM pg_catalog.pg_operator fk WHERE ..." +== 011 +-- truncate_limit: 100 +SELECT ctid, oprnegate +FROM pg_catalog.pg_operator fk +WHERE oprnegate != 0 AND + NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprnegate) +-- +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +TABLE: name="pg_catalog.pg_operator" schema="pg_catalog" table="pg_operator" ctx=Select +ALIAS: "fk"="pg_catalog.pg_operator" +ALIAS: "pk"="pg_catalog.pg_operator" +FILTER: schema="" table="" column="oprnegate" +FILTER: schema="" table="pk" column="oid" +FILTER: schema="" table="fk" column="oprnegate" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, oprnegate FROM pg_catalog.pg_operator fk WHERE ..." +== 012 +-- truncate_limit: 100 +DROP OPERATOR <|(bigint, bigint) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR <|(bigint, bigint)" diff --git a/parser/testdata/summary_truncate/postgres_regress/enum.metadata.json b/parser/testdata/summary_truncate/postgres_regress/enum.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/enum.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/enum.test b/parser/testdata/summary_truncate/postgres_regress/enum.test new file mode 100644 index 0000000..68e413c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/enum.test @@ -0,0 +1,1267 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Enum tests +|-- + +CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple')" +== 002 +-- truncate_limit: 100 +|-- +-- Did it create the right number of rows? +|-- +SELECT COUNT(*) FROM pg_enum WHERE enumtypid = 'rainbow'::regtype +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_enum WHERE enumtypid = 'rainbow'::regtype" +== 003 +-- truncate_limit: 100 +|-- +-- I/O functions +|-- +SELECT 'red'::rainbow +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'red'::rainbow" +== 004 +-- truncate_limit: 100 +SELECT 'mauve'::rainbow +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'mauve'::rainbow" +== 005 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('red', 'rainbow') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('red', 'rainbow')" +== 006 +-- truncate_limit: 100 +SELECT pg_input_is_valid('mauve', 'rainbow') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('mauve', 'rainbow')" +== 007 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('mauve', 'rainbow') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('mauve', 'rainbow')" +== 008 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info(repeat('too_long', 32), 'rainbow') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info(repeat('too_long', 32), 'rainbow')" +== 009 +-- truncate_limit: 100 +|-- +-- adding new values +|-- + +CREATE TYPE planets AS ENUM ( 'venus', 'earth', 'mars' ) +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE planets AS ENUM ('venus', 'earth', 'mars')" +== 010 +-- truncate_limit: 100 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'planets'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT enumlabel, enumsortorder FROM pg_enum WHERE enumtypid = 'planets'::regtype ORDER BY 2" +== 011 +-- truncate_limit: 100 +ALTER TYPE planets ADD VALUE 'uranus' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE 'uranus'" +== 012 +-- truncate_limit: 100 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'planets'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT enumlabel, enumsortorder FROM pg_enum WHERE enumtypid = 'planets'::regtype ORDER BY 2" +== 013 +-- truncate_limit: 100 +ALTER TYPE planets ADD VALUE 'mercury' BEFORE 'venus' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE 'mercury' BEFORE 'venus'" +== 014 +-- truncate_limit: 100 +ALTER TYPE planets ADD VALUE 'saturn' BEFORE 'uranus' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE 'saturn' BEFORE 'uranus'" +== 015 +-- truncate_limit: 100 +ALTER TYPE planets ADD VALUE 'jupiter' AFTER 'mars' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE 'jupiter' AFTER 'mars'" +== 016 +-- truncate_limit: 100 +ALTER TYPE planets ADD VALUE 'neptune' AFTER 'uranus' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE 'neptune' AFTER 'uranus'" +== 017 +-- truncate_limit: 100 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'planets'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT enumlabel, enumsortorder FROM pg_enum WHERE enumtypid = 'planets'::regtype ORDER BY 2" +== 018 +-- truncate_limit: 100 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'planets'::regtype +ORDER BY enumlabel::planets +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT enumlabel, enumsortorder FROM pg_enum WHERE ... ORDER BY enumlabel::planets" +== 019 +-- truncate_limit: 100 +-- errors for adding labels +ALTER TYPE planets ADD VALUE + 'plutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutopluto' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE 'plutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutoplutopl..." +== 020 +-- truncate_limit: 100 +ALTER TYPE planets ADD VALUE 'pluto' AFTER 'zeus' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE 'pluto' AFTER 'zeus'" +== 021 +-- truncate_limit: 100 +-- if not exists tests + +-- existing value gives error +ALTER TYPE planets ADD VALUE 'mercury' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE 'mercury'" +== 022 +-- truncate_limit: 100 +-- unless IF NOT EXISTS is specified +ALTER TYPE planets ADD VALUE IF NOT EXISTS 'mercury' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE IF NOT EXISTS 'mercury'" +== 023 +-- truncate_limit: 100 +-- should be neptune, not mercury +SELECT enum_last(NULL::planets) +-- +FUNCTION: name="enum_last" function="enum_last" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_last(NULL::planets)" +== 024 +-- truncate_limit: 100 +ALTER TYPE planets ADD VALUE IF NOT EXISTS 'pluto' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE planets ADD VALUE IF NOT EXISTS 'pluto'" +== 025 +-- truncate_limit: 100 +-- should be pluto, i.e. the new value +SELECT enum_last(NULL::planets) +-- +FUNCTION: name="enum_last" function="enum_last" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_last(NULL::planets)" +== 026 +-- truncate_limit: 100 +|-- +-- Test inserting so many values that we have to renumber +|-- + +create type insenum as enum ('L1', 'L2') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE insenum AS ENUM ('L1', 'L2')" +== 027 +-- truncate_limit: 100 +alter type insenum add value 'i1' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i1' BEFORE 'L2'" +== 028 +-- truncate_limit: 100 +alter type insenum add value 'i2' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i2' BEFORE 'L2'" +== 029 +-- truncate_limit: 100 +alter type insenum add value 'i3' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i3' BEFORE 'L2'" +== 030 +-- truncate_limit: 100 +alter type insenum add value 'i4' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i4' BEFORE 'L2'" +== 031 +-- truncate_limit: 100 +alter type insenum add value 'i5' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i5' BEFORE 'L2'" +== 032 +-- truncate_limit: 100 +alter type insenum add value 'i6' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i6' BEFORE 'L2'" +== 033 +-- truncate_limit: 100 +alter type insenum add value 'i7' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i7' BEFORE 'L2'" +== 034 +-- truncate_limit: 100 +alter type insenum add value 'i8' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i8' BEFORE 'L2'" +== 035 +-- truncate_limit: 100 +alter type insenum add value 'i9' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i9' BEFORE 'L2'" +== 036 +-- truncate_limit: 100 +alter type insenum add value 'i10' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i10' BEFORE 'L2'" +== 037 +-- truncate_limit: 100 +alter type insenum add value 'i11' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i11' BEFORE 'L2'" +== 038 +-- truncate_limit: 100 +alter type insenum add value 'i12' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i12' BEFORE 'L2'" +== 039 +-- truncate_limit: 100 +alter type insenum add value 'i13' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i13' BEFORE 'L2'" +== 040 +-- truncate_limit: 100 +alter type insenum add value 'i14' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i14' BEFORE 'L2'" +== 041 +-- truncate_limit: 100 +alter type insenum add value 'i15' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i15' BEFORE 'L2'" +== 042 +-- truncate_limit: 100 +alter type insenum add value 'i16' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i16' BEFORE 'L2'" +== 043 +-- truncate_limit: 100 +alter type insenum add value 'i17' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i17' BEFORE 'L2'" +== 044 +-- truncate_limit: 100 +alter type insenum add value 'i18' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i18' BEFORE 'L2'" +== 045 +-- truncate_limit: 100 +alter type insenum add value 'i19' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i19' BEFORE 'L2'" +== 046 +-- truncate_limit: 100 +alter type insenum add value 'i20' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i20' BEFORE 'L2'" +== 047 +-- truncate_limit: 100 +alter type insenum add value 'i21' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i21' BEFORE 'L2'" +== 048 +-- truncate_limit: 100 +alter type insenum add value 'i22' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i22' BEFORE 'L2'" +== 049 +-- truncate_limit: 100 +alter type insenum add value 'i23' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i23' BEFORE 'L2'" +== 050 +-- truncate_limit: 100 +alter type insenum add value 'i24' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i24' BEFORE 'L2'" +== 051 +-- truncate_limit: 100 +alter type insenum add value 'i25' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i25' BEFORE 'L2'" +== 052 +-- truncate_limit: 100 +alter type insenum add value 'i26' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i26' BEFORE 'L2'" +== 053 +-- truncate_limit: 100 +alter type insenum add value 'i27' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i27' BEFORE 'L2'" +== 054 +-- truncate_limit: 100 +alter type insenum add value 'i28' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i28' BEFORE 'L2'" +== 055 +-- truncate_limit: 100 +alter type insenum add value 'i29' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i29' BEFORE 'L2'" +== 056 +-- truncate_limit: 100 +alter type insenum add value 'i30' before 'L2' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE insenum ADD VALUE 'i30' BEFORE 'L2'" +== 057 +-- truncate_limit: 100 +-- The exact values of enumsortorder will now depend on the local properties +-- of float4, but in any reasonable implementation we should get at least +-- 20 splits before having to renumber; so only hide values > 20. + +SELECT enumlabel, + case when enumsortorder > 20 then null else enumsortorder end as so +FROM pg_enum +WHERE enumtypid = 'insenum'::regtype +ORDER BY enumsortorder +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_enum WHERE enumtypid = 'insenum'::regtype ORDER BY enumsortorder" +== 058 +-- truncate_limit: 100 +|-- +-- Basic table creation, row selection +|-- +CREATE TABLE enumtest (col rainbow) +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE enumtest (col rainbow)" +== 059 +-- truncate_limit: 100 +INSERT INTO enumtest values ('red'), ('orange'), ('yellow'), ('green') +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO enumtest VALUES ('red'), ('orange'), ('yellow'), ('green')" +== 060 +-- truncate_limit: 100 +COPY enumtest FROM stdin +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY enumtest FROM STDIN" +== 061 +-- truncate_limit: 100 +SELECT * FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest" +== 062 +-- truncate_limit: 100 +|-- +-- Operators, no index +|-- +SELECT * FROM enumtest WHERE col = 'orange' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col = 'orange'" +== 063 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col <> 'orange' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col <> 'orange' ORDER BY col" +== 064 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col > 'yellow' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col > 'yellow' ORDER BY col" +== 065 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col >= 'yellow' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col >= 'yellow' ORDER BY col" +== 066 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col < 'green' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col < 'green' ORDER BY col" +== 067 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col <= 'green' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col <= 'green' ORDER BY col" +== 068 +-- truncate_limit: 100 +|-- +-- Cast to/from text +|-- +SELECT 'red'::rainbow::text || 'hithere' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'red'::rainbow::text || 'hithere'" +== 069 +-- truncate_limit: 100 +SELECT 'red'::text::rainbow = 'red'::rainbow +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'red'::text::rainbow = 'red'::rainbow" +== 070 +-- truncate_limit: 100 +|-- +-- Aggregates +|-- +SELECT min(col) FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(col) FROM enumtest" +== 071 +-- truncate_limit: 100 +SELECT max(col) FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(col) FROM enumtest" +== 072 +-- truncate_limit: 100 +SELECT max(col) FROM enumtest WHERE col < 'green' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT max(col) FROM enumtest WHERE col < 'green'" +== 073 +-- truncate_limit: 100 +|-- +-- Index tests, force use of index +|-- +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 074 +-- truncate_limit: 100 +SET enable_bitmapscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 075 +-- truncate_limit: 100 +|-- +-- Btree index / opclass with the various operators +|-- +CREATE UNIQUE INDEX enumtest_btree ON enumtest USING btree (col) +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX enumtest_btree ON enumtest USING btree (col)" +== 076 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col = 'orange' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col = 'orange'" +== 077 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col <> 'orange' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col <> 'orange' ORDER BY col" +== 078 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col > 'yellow' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col > 'yellow' ORDER BY col" +== 079 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col >= 'yellow' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col >= 'yellow' ORDER BY col" +== 080 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col < 'green' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col < 'green' ORDER BY col" +== 081 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col <= 'green' ORDER BY col +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col <= 'green' ORDER BY col" +== 082 +-- truncate_limit: 100 +SELECT min(col) FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(col) FROM enumtest" +== 083 +-- truncate_limit: 100 +SELECT max(col) FROM enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(col) FROM enumtest" +== 084 +-- truncate_limit: 100 +SELECT max(col) FROM enumtest WHERE col < 'green' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT max(col) FROM enumtest WHERE col < 'green'" +== 085 +-- truncate_limit: 100 +DROP INDEX enumtest_btree +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX enumtest_btree" +== 086 +-- truncate_limit: 100 +|-- +-- Hash index / opclass with the = operator +|-- +CREATE INDEX enumtest_hash ON enumtest USING hash (col) +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX enumtest_hash ON enumtest USING hash (col)" +== 087 +-- truncate_limit: 100 +SELECT * FROM enumtest WHERE col = 'orange' +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=Select +FILTER: schema="" table="" column="col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM enumtest WHERE col = 'orange'" +== 088 +-- truncate_limit: 100 +DROP INDEX enumtest_hash +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX enumtest_hash" +== 089 +-- truncate_limit: 100 +|-- +-- End index tests +|-- +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 090 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 091 +-- truncate_limit: 100 +|-- +-- Domains over enums +|-- +CREATE DOMAIN rgb AS rainbow CHECK (VALUE IN ('red', 'green', 'blue')) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN rgb AS rainbow CHECK (value IN ('red', 'green', 'blue'))" +== 092 +-- truncate_limit: 100 +SELECT 'red'::rgb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'red'::rgb" +== 093 +-- truncate_limit: 100 +SELECT 'purple'::rgb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'purple'::rgb" +== 094 +-- truncate_limit: 100 +SELECT 'purple'::rainbow::rgb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'purple'::rainbow::rgb" +== 095 +-- truncate_limit: 100 +DROP DOMAIN rgb +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN rgb" +== 096 +-- truncate_limit: 100 +|-- +-- Arrays +|-- +SELECT '{red,green,blue}'::rainbow[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{red,green,blue}'::rainbow[]" +== 097 +-- truncate_limit: 100 +SELECT ('{red,green,blue}'::rainbow[])[2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{red,green,blue}'::rainbow[])[2]" +== 098 +-- truncate_limit: 100 +SELECT 'red' = ANY ('{red,green,blue}'::rainbow[]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'red' = ANY('{red,green,blue}'::rainbow[])" +== 099 +-- truncate_limit: 100 +SELECT 'yellow' = ANY ('{red,green,blue}'::rainbow[]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'yellow' = ANY('{red,green,blue}'::rainbow[])" +== 100 +-- truncate_limit: 100 +SELECT 'red' = ALL ('{red,green,blue}'::rainbow[]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'red' = ALL('{red,green,blue}'::rainbow[])" +== 101 +-- truncate_limit: 100 +SELECT 'red' = ALL ('{red,red}'::rainbow[]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'red' = ALL('{red,red}'::rainbow[])" +== 102 +-- truncate_limit: 100 +|-- +-- Support functions +|-- +SELECT enum_first(NULL::rainbow) +-- +FUNCTION: name="enum_first" function="enum_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_first(NULL::rainbow)" +== 103 +-- truncate_limit: 100 +SELECT enum_last('green'::rainbow) +-- +FUNCTION: name="enum_last" function="enum_last" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_last('green'::rainbow)" +== 104 +-- truncate_limit: 100 +SELECT enum_range(NULL::rainbow) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_range(NULL::rainbow)" +== 105 +-- truncate_limit: 100 +SELECT enum_range('orange'::rainbow, 'green'::rainbow) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_range('orange'::rainbow, 'green'::rainbow)" +== 106 +-- truncate_limit: 100 +SELECT enum_range(NULL, 'green'::rainbow) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_range(NULL, 'green'::rainbow)" +== 107 +-- truncate_limit: 100 +SELECT enum_range('orange'::rainbow, NULL) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_range('orange'::rainbow, NULL)" +== 108 +-- truncate_limit: 100 +SELECT enum_range(NULL::rainbow, NULL) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_range(NULL::rainbow, NULL)" +== 109 +-- truncate_limit: 100 +|-- +-- User functions, can't test perl/python etc here since may not be compiled. +|-- +CREATE FUNCTION echo_me(anyenum) RETURNS text AS $$ +BEGIN +RETURN $1::text || 'omg'; +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION echo_me(anyenum) RETURNS text AS $$\nBEGIN\nRETURN $1::text || 'omg';\nEND\n$$ LANGUA..." +== 110 +-- truncate_limit: 100 +SELECT echo_me('red'::rainbow) +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT echo_me('red'::rainbow)" +== 111 +-- truncate_limit: 100 +|-- +-- Concrete function should override generic one +|-- +CREATE FUNCTION echo_me(rainbow) RETURNS text AS $$ +BEGIN +RETURN $1::text || 'wtf'; +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION echo_me(rainbow) RETURNS text AS $$\nBEGIN\nRETURN $1::text || 'wtf';\nEND\n$$ LANGUA..." +== 112 +-- truncate_limit: 100 +SELECT echo_me('red'::rainbow) +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT echo_me('red'::rainbow)" +== 113 +-- truncate_limit: 100 +|-- +-- If we drop the original generic one, we don't have to qualify the type +-- anymore, since there's only one match +|-- +DROP FUNCTION echo_me(anyenum) +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION echo_me(anyenum)" +== 114 +-- truncate_limit: 100 +SELECT echo_me('red') +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT echo_me('red')" +== 115 +-- truncate_limit: 100 +DROP FUNCTION echo_me(rainbow) +-- +FUNCTION: name="echo_me" function="echo_me" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION echo_me(rainbow)" +== 116 +-- truncate_limit: 100 +|-- +-- RI triggers on enum types +|-- +CREATE TABLE enumtest_parent (id rainbow PRIMARY KEY) +-- +TABLE: name="enumtest_parent" schema="" table="enumtest_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE enumtest_parent (id rainbow PRIMARY KEY)" +== 117 +-- truncate_limit: 100 +CREATE TABLE enumtest_child (parent rainbow REFERENCES enumtest_parent) +-- +TABLE: name="enumtest_child" schema="" table="enumtest_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE enumtest_child (parent rainbow REFERENCES enumtest_parent)" +== 118 +-- truncate_limit: 100 +INSERT INTO enumtest_parent VALUES ('red') +-- +TABLE: name="enumtest_parent" schema="" table="enumtest_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO enumtest_parent VALUES ('red')" +== 119 +-- truncate_limit: 100 +INSERT INTO enumtest_child VALUES ('red') +-- +TABLE: name="enumtest_child" schema="" table="enumtest_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO enumtest_child VALUES ('red')" +== 120 +-- truncate_limit: 100 +INSERT INTO enumtest_child VALUES ('blue') +-- +TABLE: name="enumtest_child" schema="" table="enumtest_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO enumtest_child VALUES ('blue')" +== 121 +-- truncate_limit: 100 +-- fail +DELETE FROM enumtest_parent +-- +TABLE: name="enumtest_parent" schema="" table="enumtest_parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM enumtest_parent" +== 122 +-- truncate_limit: 100 +-- fail +|-- +-- cross-type RI should fail +|-- +CREATE TYPE bogus AS ENUM('good', 'bad', 'ugly') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE bogus AS ENUM ('good', 'bad', 'ugly')" +== 123 +-- truncate_limit: 100 +CREATE TABLE enumtest_bogus_child(parent bogus REFERENCES enumtest_parent) +-- +TABLE: name="enumtest_bogus_child" schema="" table="enumtest_bogus_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE enumtest_bogus_child (parent bogus REFERENCES enumtest_parent)" +== 124 +-- truncate_limit: 100 +DROP TYPE bogus +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE bogus" +== 125 +-- truncate_limit: 100 +-- check renaming a value +ALTER TYPE rainbow RENAME VALUE 'red' TO 'crimson' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE rainbow RENAME VALUE 'red' TO 'crimson'" +== 126 +-- truncate_limit: 100 +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'rainbow'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT enumlabel, enumsortorder FROM pg_enum WHERE enumtypid = 'rainbow'::regtype ORDER BY 2" +== 127 +-- truncate_limit: 100 +-- check that renaming a non-existent value fails +ALTER TYPE rainbow RENAME VALUE 'red' TO 'crimson' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE rainbow RENAME VALUE 'red' TO 'crimson'" +== 128 +-- truncate_limit: 100 +-- check that renaming to an existent value fails +ALTER TYPE rainbow RENAME VALUE 'blue' TO 'green' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE rainbow RENAME VALUE 'blue' TO 'green'" +== 129 +-- truncate_limit: 100 +|-- +-- check transactional behaviour of ALTER TYPE ... ADD VALUE +|-- +CREATE TYPE bogus AS ENUM('good') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE bogus AS ENUM ('good')" +== 130 +-- truncate_limit: 100 +-- check that we can add new values to existing enums in a transaction +-- but we can't use them +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 131 +-- truncate_limit: 100 +ALTER TYPE bogus ADD VALUE 'new' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE bogus ADD VALUE 'new'" +== 132 +-- truncate_limit: 100 +SAVEPOINT x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 133 +-- truncate_limit: 100 +SELECT 'new'::bogus +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'new'::bogus" +== 134 +-- truncate_limit: 100 +-- unsafe +ROLLBACK TO x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 135 +-- truncate_limit: 100 +SELECT enum_first(null::bogus) +-- +FUNCTION: name="enum_first" function="enum_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_first(NULL::bogus)" +== 136 +-- truncate_limit: 100 +-- safe +SELECT enum_last(null::bogus) +-- +FUNCTION: name="enum_last" function="enum_last" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_last(NULL::bogus)" +== 137 +-- truncate_limit: 100 +-- unsafe +ROLLBACK TO x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 138 +-- truncate_limit: 100 +SELECT enum_range(null::bogus) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_range(NULL::bogus)" +== 139 +-- truncate_limit: 100 +-- unsafe +ROLLBACK TO x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 140 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 141 +-- truncate_limit: 100 +SELECT 'new'::bogus +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'new'::bogus" +== 142 +-- truncate_limit: 100 +-- now safe +SELECT enumlabel, enumsortorder +FROM pg_enum +WHERE enumtypid = 'bogus'::regtype +ORDER BY 2 +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT enumlabel, enumsortorder FROM pg_enum WHERE enumtypid = 'bogus'::regtype ORDER BY 2" +== 143 +-- truncate_limit: 100 +-- check that we recognize the case where the enum already existed but was +-- modified in the current txn; this should not be considered safe +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 144 +-- truncate_limit: 100 +ALTER TYPE bogus RENAME TO bogon +-- +STMT: RenameStmt +TRUNCATED: "ALTER TYPE bogus RENAME TO bogon" +== 145 +-- truncate_limit: 100 +ALTER TYPE bogon ADD VALUE 'bad' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE bogon ADD VALUE 'bad'" +== 146 +-- truncate_limit: 100 +SELECT 'bad'::bogon +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bad'::bogon" +== 147 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 148 +-- truncate_limit: 100 +-- but a renamed value is safe to use later in same transaction +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 149 +-- truncate_limit: 100 +ALTER TYPE bogus RENAME VALUE 'good' to 'bad' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE bogus RENAME VALUE 'good' TO 'bad'" +== 150 +-- truncate_limit: 100 +SELECT 'bad'::bogus +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bad'::bogus" +== 151 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 152 +-- truncate_limit: 100 +DROP TYPE bogus +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE bogus" +== 153 +-- truncate_limit: 100 +-- check that values created during CREATE TYPE can be used in any case +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 154 +-- truncate_limit: 100 +CREATE TYPE bogus AS ENUM('good','bad','ugly') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE bogus AS ENUM ('good', 'bad', 'ugly')" +== 155 +-- truncate_limit: 100 +ALTER TYPE bogus RENAME TO bogon +-- +STMT: RenameStmt +TRUNCATED: "ALTER TYPE bogus RENAME TO bogon" +== 156 +-- truncate_limit: 100 +select enum_range(null::bogon) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_range(NULL::bogon)" +== 157 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 158 +-- truncate_limit: 100 +-- we must allow this usage to support pg_dump in binary upgrade mode +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 159 +-- truncate_limit: 100 +CREATE TYPE bogus AS ENUM('good') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE bogus AS ENUM ('good')" +== 160 +-- truncate_limit: 100 +ALTER TYPE bogus RENAME TO bogon +-- +STMT: RenameStmt +TRUNCATED: "ALTER TYPE bogus RENAME TO bogon" +== 161 +-- truncate_limit: 100 +ALTER TYPE bogon ADD VALUE 'bad' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE bogon ADD VALUE 'bad'" +== 162 +-- truncate_limit: 100 +ALTER TYPE bogon ADD VALUE 'ugly' +-- +STMT: AlterEnumStmt +TRUNCATED: "ALTER TYPE bogon ADD VALUE 'ugly'" +== 163 +-- truncate_limit: 100 +select enum_range(null::bogon) +-- +FUNCTION: name="enum_range" function="enum_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT enum_range(NULL::bogon)" +== 164 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 165 +-- truncate_limit: 100 +|-- +-- Cleanup +|-- +DROP TABLE enumtest_child +-- +TABLE: name="enumtest_child" schema="" table="enumtest_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE enumtest_child" +== 166 +-- truncate_limit: 100 +DROP TABLE enumtest_parent +-- +TABLE: name="enumtest_parent" schema="" table="enumtest_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE enumtest_parent" +== 167 +-- truncate_limit: 100 +DROP TABLE enumtest +-- +TABLE: name="enumtest" schema="" table="enumtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE enumtest" +== 168 +-- truncate_limit: 100 +DROP TYPE rainbow +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE rainbow" +== 169 +-- truncate_limit: 100 +|-- +-- Verify properly cleaned up +|-- +SELECT COUNT(*) FROM pg_type WHERE typname = 'rainbow' +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="typname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_type WHERE typname = 'rainbow'" +== 170 +-- truncate_limit: 100 +SELECT * FROM pg_enum WHERE NOT EXISTS + (SELECT 1 FROM pg_type WHERE pg_type.oid = enumtypid) +-- +TABLE: name="pg_enum" schema="" table="pg_enum" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +FILTER: schema="" table="pg_type" column="oid" +FILTER: schema="" table="" column="enumtypid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_enum WHERE NOT EXISTS (SELECT 1 FROM pg_type WHERE pg_type.oid = enumtypid)" diff --git a/parser/testdata/summary_truncate/postgres_regress/equivclass.metadata.json b/parser/testdata/summary_truncate/postgres_regress/equivclass.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/equivclass.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/equivclass.test b/parser/testdata/summary_truncate/postgres_regress/equivclass.test new file mode 100644 index 0000000..22fdbb4 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/equivclass.test @@ -0,0 +1,798 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for the planner's "equivalence class" mechanism +|-- + +-- One thing that's not tested well during normal querying is the logic +-- for handling "broken" ECs. This is because an EC can only become broken +-- if its underlying btree operator family doesn't include a complete set +-- of cross-type equality operators. There are not (and should not be) +-- any such families built into Postgres; so we have to hack things up +-- to create one. We do this by making two alias types that are really +-- int8 (so we need no new C code) and adding only some operators for them +-- into the standard integer_ops opfamily. + +create type int8alias1 +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE int8alias1" +== 002 +-- truncate_limit: 100 +create function int8alias1in(cstring) returns int8alias1 + strict immutable language internal as 'int8in' +-- +FUNCTION: name="int8alias1in" function="int8alias1in" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias1in(cstring) RETURNS int8alias1 RETURNS NULL ON NULL INPUT IMMUTABLE LAN..." +== 003 +-- truncate_limit: 100 +create function int8alias1out(int8alias1) returns cstring + strict immutable language internal as 'int8out' +-- +FUNCTION: name="int8alias1out" function="int8alias1out" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias1out(int8alias1) RETURNS cstring RETURNS NULL ON NULL INPUT IMMUTABLE LA..." +== 004 +-- truncate_limit: 100 +create type int8alias1 ( + input = int8alias1in, + output = int8alias1out, + like = int8 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE int8alias1 (input = int8alias1in, output = int8alias1out, \"like\" = int8)" +== 005 +-- truncate_limit: 100 +create type int8alias2 +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE int8alias2" +== 006 +-- truncate_limit: 100 +create function int8alias2in(cstring) returns int8alias2 + strict immutable language internal as 'int8in' +-- +FUNCTION: name="int8alias2in" function="int8alias2in" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias2in(cstring) RETURNS int8alias2 RETURNS NULL ON NULL INPUT IMMUTABLE LAN..." +== 007 +-- truncate_limit: 100 +create function int8alias2out(int8alias2) returns cstring + strict immutable language internal as 'int8out' +-- +FUNCTION: name="int8alias2out" function="int8alias2out" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias2out(int8alias2) RETURNS cstring RETURNS NULL ON NULL INPUT IMMUTABLE LA..." +== 008 +-- truncate_limit: 100 +create type int8alias2 ( + input = int8alias2in, + output = int8alias2out, + like = int8 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE int8alias2 (input = int8alias2in, output = int8alias2out, \"like\" = int8)" +== 009 +-- truncate_limit: 100 +create cast (int8 as int8alias1) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int8 AS int8alias1) WITHOUT FUNCTION" +== 010 +-- truncate_limit: 100 +create cast (int8 as int8alias2) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int8 AS int8alias2) WITHOUT FUNCTION" +== 011 +-- truncate_limit: 100 +create cast (int8alias1 as int8) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int8alias1 AS int8) WITHOUT FUNCTION" +== 012 +-- truncate_limit: 100 +create cast (int8alias2 as int8) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int8alias2 AS int8) WITHOUT FUNCTION" +== 013 +-- truncate_limit: 100 +create function int8alias1eq(int8alias1, int8alias1) returns bool + strict immutable language internal as 'int8eq' +-- +FUNCTION: name="int8alias1eq" function="int8alias1eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias1eq(int8alias1, int8alias1) RETURNS bool RETURNS NULL ON NULL INPUT IMMU..." +== 014 +-- truncate_limit: 100 +create operator = ( + procedure = int8alias1eq, + leftarg = int8alias1, rightarg = int8alias1, + commutator = =, + restrict = eqsel, join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR = (procedure = int8alias1eq, leftarg = int8alias1, rightarg = int8alias1, commuta..." +== 015 +-- truncate_limit: 100 +alter operator family integer_ops using btree add + operator 3 = (int8alias1, int8alias1) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY integer_ops USING btree ADD OPERATOR 3 =(int8alias1, int8alias1)" +== 016 +-- truncate_limit: 100 +create function int8alias2eq(int8alias2, int8alias2) returns bool + strict immutable language internal as 'int8eq' +-- +FUNCTION: name="int8alias2eq" function="int8alias2eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias2eq(int8alias2, int8alias2) RETURNS bool RETURNS NULL ON NULL INPUT IMMU..." +== 017 +-- truncate_limit: 100 +create operator = ( + procedure = int8alias2eq, + leftarg = int8alias2, rightarg = int8alias2, + commutator = =, + restrict = eqsel, join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR = (procedure = int8alias2eq, leftarg = int8alias2, rightarg = int8alias2, commuta..." +== 018 +-- truncate_limit: 100 +alter operator family integer_ops using btree add + operator 3 = (int8alias2, int8alias2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY integer_ops USING btree ADD OPERATOR 3 =(int8alias2, int8alias2)" +== 019 +-- truncate_limit: 100 +create function int8alias1eq(int8, int8alias1) returns bool + strict immutable language internal as 'int8eq' +-- +FUNCTION: name="int8alias1eq" function="int8alias1eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias1eq(int8, int8alias1) RETURNS bool RETURNS NULL ON NULL INPUT IMMUTABLE ..." +== 020 +-- truncate_limit: 100 +create operator = ( + procedure = int8alias1eq, + leftarg = int8, rightarg = int8alias1, + restrict = eqsel, join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR = (procedure = int8alias1eq, leftarg = int8, rightarg = int8alias1, restrict = eq..." +== 021 +-- truncate_limit: 100 +alter operator family integer_ops using btree add + operator 3 = (int8, int8alias1) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY integer_ops USING btree ADD OPERATOR 3 =(int8, int8alias1)" +== 022 +-- truncate_limit: 100 +create function int8alias1eq(int8alias1, int8alias2) returns bool + strict immutable language internal as 'int8eq' +-- +FUNCTION: name="int8alias1eq" function="int8alias1eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias1eq(int8alias1, int8alias2) RETURNS bool RETURNS NULL ON NULL INPUT IMMU..." +== 023 +-- truncate_limit: 100 +create operator = ( + procedure = int8alias1eq, + leftarg = int8alias1, rightarg = int8alias2, + restrict = eqsel, join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR = (procedure = int8alias1eq, leftarg = int8alias1, rightarg = int8alias2, restric..." +== 024 +-- truncate_limit: 100 +alter operator family integer_ops using btree add + operator 3 = (int8alias1, int8alias2) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY integer_ops USING btree ADD OPERATOR 3 =(int8alias1, int8alias2)" +== 025 +-- truncate_limit: 100 +create function int8alias1lt(int8alias1, int8alias1) returns bool + strict immutable language internal as 'int8lt' +-- +FUNCTION: name="int8alias1lt" function="int8alias1lt" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias1lt(int8alias1, int8alias1) RETURNS bool RETURNS NULL ON NULL INPUT IMMU..." +== 026 +-- truncate_limit: 100 +create operator < ( + procedure = int8alias1lt, + leftarg = int8alias1, rightarg = int8alias1 +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR < (procedure = int8alias1lt, leftarg = int8alias1, rightarg = int8alias1)" +== 027 +-- truncate_limit: 100 +alter operator family integer_ops using btree add + operator 1 < (int8alias1, int8alias1) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY integer_ops USING btree ADD OPERATOR 1 <(int8alias1, int8alias1)" +== 028 +-- truncate_limit: 100 +create function int8alias1cmp(int8, int8alias1) returns int + strict immutable language internal as 'btint8cmp' +-- +FUNCTION: name="int8alias1cmp" function="int8alias1cmp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION int8alias1cmp(int8, int8alias1) RETURNS int RETURNS NULL ON NULL INPUT IMMUTABLE ..." +== 029 +-- truncate_limit: 100 +alter operator family integer_ops using btree add + function 1 int8alias1cmp (int8, int8alias1) +-- +STMT: AlterOpFamilyStmt +TRUNCATED: "ALTER OPERATOR FAMILY integer_ops USING btree ADD FUNCTION 1 int8alias1cmp(int8, int8alias1)" +== 030 +-- truncate_limit: 100 +create table ec0 (ff int8 primary key, f1 int8, f2 int8) +-- +TABLE: name="ec0" schema="" table="ec0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ec0 (ff int8 PRIMARY KEY, f1 int8, f2 int8)" +== 031 +-- truncate_limit: 100 +create table ec1 (ff int8 primary key, f1 int8alias1, f2 int8alias2) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ec1 (ff int8 PRIMARY KEY, f1 int8alias1, f2 int8alias2)" +== 032 +-- truncate_limit: 100 +create table ec2 (xf int8 primary key, x1 int8alias1, x2 int8alias2) +-- +TABLE: name="ec2" schema="" table="ec2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ec2 (xf int8 PRIMARY KEY, x1 int8alias1, x2 int8alias2)" +== 033 +-- truncate_limit: 100 +-- for the moment we only want to look at nestloop plans +set enable_hashjoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 034 +-- truncate_limit: 100 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 035 +-- truncate_limit: 100 +|-- +-- Note that for cases where there's a missing operator, we don't care so +-- much whether the plan is ideal as that we don't fail or generate an +-- outright incorrect plan. +|-- + +explain (costs off) + select * from ec0 where ff = f1 and f1 = '42'::int8 +-- +TABLE: name="ec0" schema="" table="ec0" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec0 WHERE ff = f1 AND f1 = '42'::int8" +== 036 +-- truncate_limit: 100 +explain (costs off) + select * from ec0 where ff = f1 and f1 = '42'::int8alias1 +-- +TABLE: name="ec0" schema="" table="ec0" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec0 WHERE ff = f1 AND f1 = '42'::int8alias1" +== 037 +-- truncate_limit: 100 +explain (costs off) + select * from ec1 where ff = f1 and f1 = '42'::int8alias1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1 WHERE ff = f1 AND f1 = '42'::int8alias1" +== 038 +-- truncate_limit: 100 +explain (costs off) + select * from ec1 where ff = f1 and f1 = '42'::int8alias2 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1 WHERE ff = f1 AND f1 = '42'::int8alias2" +== 039 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, ec2 where ff = x1 and ff = '42'::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, ec2 WHERE ff = x1 AND ff = '42'::int8" +== 040 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, ec2 where ff = x1 and ff = '42'::int8alias1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, ec2 WHERE ff = x1 AND ff = '42'::int8alias1" +== 041 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, ec2 where ff = x1 and '42'::int8 = x1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="x1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, ec2 WHERE ff = x1 AND '42'::int8 = x1" +== 042 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, ec2 where ff = x1 and x1 = '42'::int8alias1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="x1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, ec2 WHERE ff = x1 AND x1 = '42'::int8alias1" +== 043 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, ec2 where ff = x1 and x1 = '42'::int8alias2 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec2" schema="" table="ec2" ctx=Select +FILTER: schema="" table="" column="ff" +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="x1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, ec2 WHERE ff = x1 AND x1 = '42'::int8alias2" +== 044 +-- truncate_limit: 100 +create unique index ec1_expr1 on ec1((ff + 1)) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ec1_expr1 ON ec1 USING btree ((ff + 1))" +== 045 +-- truncate_limit: 100 +create unique index ec1_expr2 on ec1((ff + 2 + 1)) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ec1_expr2 ON ec1 USING btree (((ff + 2) + 1))" +== 046 +-- truncate_limit: 100 +create unique index ec1_expr3 on ec1((ff + 3 + 1)) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ec1_expr3 ON ec1 USING btree (((ff + 3) + 1))" +== 047 +-- truncate_limit: 100 +create unique index ec1_expr4 on ec1((ff + 4)) +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ec1_expr4 ON ec1 USING btree ((ff + 4))" +== 048 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1 + where ss1.x = ec1.f1 and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, (SELECT ff + 1 AS x FROM (SELECT ff + 2 AS ff FROM ec1 UNI..." +== 049 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1 + where ss1.x = ec1.f1 and ec1.ff = 42::int8 and ec1.ff = ec1.f1 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ec1" column="ff" +FILTER: schema="" table="ec1" column="ff" +FILTER: schema="" table="ec1" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, (SELECT ff + 1 AS x FROM (SELECT ff + 2 AS ff FROM ec1 UNI..." +== 050 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss2 + where ss1.x = ec1.f1 and ss1.x = ss2.x and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ss2" column="x" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, (SELECT ff + 1 AS x FROM (SELECT ff + 2 AS ff FROM ec1 UNI..." +== 051 +-- truncate_limit: 100 +-- let's try that as a mergejoin +set enable_mergejoin = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO ON" +== 052 +-- truncate_limit: 100 +set enable_nestloop = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 053 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss2 + where ss1.x = ec1.f1 and ss1.x = ss2.x and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ss2" column="x" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, (SELECT ff + 1 AS x FROM (SELECT ff + 2 AS ff FROM ec1 UNI..." +== 054 +-- truncate_limit: 100 +-- check partially indexed scan +set enable_nestloop = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO ON" +== 055 +-- truncate_limit: 100 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 056 +-- truncate_limit: 100 +drop index ec1_expr3 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX ec1_expr3" +== 057 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1 + where ss1.x = ec1.f1 and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, (SELECT ff + 1 AS x FROM (SELECT ff + 2 AS ff FROM ec1 UNI..." +== 058 +-- truncate_limit: 100 +-- let's try that as a mergejoin +set enable_mergejoin = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO ON" +== 059 +-- truncate_limit: 100 +set enable_nestloop = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 060 +-- truncate_limit: 100 +explain (costs off) + select * from ec1, + (select ff + 1 as x from + (select ff + 2 as ff from ec1 + union all + select ff + 3 as ff from ec1) ss0 + union all + select ff + 4 as x from ec1) as ss1 + where ss1.x = ec1.f1 and ec1.ff = 42::int8 +-- +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +FILTER: schema="" table="ss1" column="x" +FILTER: schema="" table="ec1" column="f1" +FILTER: schema="" table="ec1" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec1, (SELECT ff + 1 AS x FROM (SELECT ff + 2 AS ff FROM ec1 UNI..." +== 061 +-- truncate_limit: 100 +-- check effects of row-level security +set enable_nestloop = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO ON" +== 062 +-- truncate_limit: 100 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 063 +-- truncate_limit: 100 +alter table ec1 enable row level security +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ec1 ENABLE ROW LEVEL SECURITY" +== 064 +-- truncate_limit: 100 +create policy p1 on ec1 using (f1 < '5'::int8alias1) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON ec1 TO public USING (f1 < '5'::int8alias1)" +== 065 +-- truncate_limit: 100 +create user regress_user_ectest +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_user_ectest" +== 066 +-- truncate_limit: 100 +grant select on ec0 to regress_user_ectest +-- +TABLE: name="ec0" schema="" table="ec0" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON ec0 TO regress_user_ectest" +== 067 +-- truncate_limit: 100 +grant select on ec1 to regress_user_ectest +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON ec1 TO regress_user_ectest" +== 068 +-- truncate_limit: 100 +-- without any RLS, we'll treat {a.ff, b.ff, 43} as an EquivalenceClass +explain (costs off) + select * from ec0 a, ec1 b + where a.ff = b.ff and a.ff = 43::bigint::int8alias1 +-- +TABLE: name="ec0" schema="" table="ec0" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +ALIAS: "a"="ec0" +ALIAS: "b"="ec1" +FILTER: schema="" table="a" column="ff" +FILTER: schema="" table="b" column="ff" +FILTER: schema="" table="a" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec0 a, ec1 b WHERE a.ff = b.ff AND a.ff = 43::bigint::int8alias1" +== 069 +-- truncate_limit: 100 +set session authorization regress_user_ectest +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_user_ectest" +== 070 +-- truncate_limit: 100 +-- with RLS active, the non-leakproof a.ff = 43 clause is not treated +-- as a suitable source for an EquivalenceClass; currently, this is true +-- even though the RLS clause has nothing to do directly with the EC +explain (costs off) + select * from ec0 a, ec1 b + where a.ff = b.ff and a.ff = 43::bigint::int8alias1 +-- +TABLE: name="ec0" schema="" table="ec0" ctx=Select +TABLE: name="ec1" schema="" table="ec1" ctx=Select +ALIAS: "a"="ec0" +ALIAS: "b"="ec1" +FILTER: schema="" table="a" column="ff" +FILTER: schema="" table="b" column="ff" +FILTER: schema="" table="a" column="ff" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ec0 a, ec1 b WHERE a.ff = b.ff AND a.ff = 43::bigint::int8alias1" +== 071 +-- truncate_limit: 100 +reset session authorization +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 072 +-- truncate_limit: 100 +revoke select on ec0 from regress_user_ectest +-- +TABLE: name="ec0" schema="" table="ec0" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE select ON ec0 FROM regress_user_ectest" +== 073 +-- truncate_limit: 100 +revoke select on ec1 from regress_user_ectest +-- +TABLE: name="ec1" schema="" table="ec1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE select ON ec1 FROM regress_user_ectest" +== 074 +-- truncate_limit: 100 +drop user regress_user_ectest +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_user_ectest" +== 075 +-- truncate_limit: 100 +-- check that X=X is converted to X IS NOT NULL when appropriate +explain (costs off) + select * from tenk1 where unique1 = unique1 and unique2 = unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 WHERE unique1 = unique1 AND unique2 = unique2" +== 076 +-- truncate_limit: 100 +-- this could be converted, but isn't at present +explain (costs off) + select * from tenk1 where unique1 = unique1 or unique2 = unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 WHERE unique1 = unique1 OR unique2 = unique2" +== 077 +-- truncate_limit: 100 +-- check that we recognize equivalence with dummy domains in the way +create temp table undername (f1 name, f2 int) +-- +TABLE: name="undername" schema="" table="undername" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE undername (f1 name, f2 int)" +== 078 +-- truncate_limit: 100 +create temp view overview as + select f1::information_schema.sql_identifier as sqli, f2 from undername +-- +TABLE: name="overview" schema="" table="overview" ctx=DDL +TABLE: name="undername" schema="" table="undername" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW overview AS SELECT f1::information_schema.sql_identifier AS sqli, f2 FROM u..." +== 079 +-- truncate_limit: 100 +explain (costs off) -- this should not require a sort + select * from overview where sqli = 'foo' order by sqli +-- +TABLE: name="overview" schema="" table="overview" ctx=Select +FILTER: schema="" table="" column="sqli" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM overview WHERE sqli = 'foo' ORDER BY sqli" diff --git a/parser/testdata/summary_truncate/postgres_regress/errors.metadata.json b/parser/testdata/summary_truncate/postgres_regress/errors.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/errors.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/errors.test b/parser/testdata/summary_truncate/postgres_regress/errors.test new file mode 100644 index 0000000..cdc361f --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/errors.test @@ -0,0 +1,795 @@ +== 001 +-- truncate_limit: 100 +|-- +-- ERRORS +|-- + +-- bad in postquel, but ok in PostgreSQL +select 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1" +== 002 +-- truncate_limit: 100 +|-- +-- UNSUPPORTED STUFF + +-- doesn't work +-- notify pg_class +|-- + +|-- +-- SELECT + +-- this used to be a syntax error, but now we allow an empty target list +select +-- +STMT: SelectStmt +TRUNCATED: "SELECT" +== 003 +-- truncate_limit: 100 +-- no such relation +select * from nonesuch +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nonesuch" +== 004 +-- truncate_limit: 100 +-- bad name in target list +select nonesuch from pg_database +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT nonesuch FROM pg_database" +== 005 +-- truncate_limit: 100 +-- empty distinct list isn't OK +select distinct from pg_database +-- +ERROR: syntax error at or near "from" +CURSORPOS: 49 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +-- truncate_limit: 100 +-- bad attribute name on lhs of operator +select * from pg_database where nonesuch = pg_database.datname +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FILTER: schema="" table="" column="nonesuch" +FILTER: schema="" table="pg_database" column="datname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_database WHERE nonesuch = pg_database.datname" +== 007 +-- truncate_limit: 100 +-- bad attribute name on rhs of operator +select * from pg_database where pg_database.datname = nonesuch +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FILTER: schema="" table="pg_database" column="datname" +FILTER: schema="" table="" column="nonesuch" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_database WHERE pg_database.datname = nonesuch" +== 008 +-- truncate_limit: 100 +-- bad attribute name in select distinct on +select distinct on (foobar) * from pg_database +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (foobar) * FROM pg_database" +== 009 +-- truncate_limit: 100 +-- grouping with FOR UPDATE +select null from pg_database group by datname for update +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT NULL FROM pg_database GROUP BY datname FOR UPDATE" +== 010 +-- truncate_limit: 100 +select null from pg_database group by grouping sets (()) for update +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT NULL FROM pg_database GROUP BY GROUPING SETS (()) FOR UPDATE" +== 011 +-- truncate_limit: 100 +|-- +-- DELETE + +-- missing relation name (this had better not wildcard!) +delete from +-- +ERROR: syntax error at end of input +CURSORPOS: 83 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +-- truncate_limit: 100 +-- no such relation +delete from nonesuch +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM nonesuch" +== 013 +-- truncate_limit: 100 +|-- +-- DROP + +-- missing relation name (this had better not wildcard!) +drop table +-- +ERROR: syntax error at end of input +CURSORPOS: 80 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 014 +-- truncate_limit: 100 +-- no such relation +drop table nonesuch +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE nonesuch" +== 015 +-- truncate_limit: 100 +|-- +-- ALTER TABLE + +-- relation renaming + +-- missing relation name +alter table rename +-- +ERROR: syntax error at end of input +CURSORPOS: 85 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 016 +-- truncate_limit: 100 +-- no such relation +alter table nonesuch rename to newnonesuch +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=DDL +TABLE: name="newnonesuch" schema="" table="newnonesuch" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE nonesuch RENAME TO newnonesuch" +== 017 +-- truncate_limit: 100 +-- no such relation +alter table nonesuch rename to stud_emp +-- +TABLE: name="nonesuch" schema="" table="nonesuch" ctx=DDL +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE nonesuch RENAME TO stud_emp" +== 018 +-- truncate_limit: 100 +-- conflict +alter table stud_emp rename to student +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +TABLE: name="student" schema="" table="student" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE stud_emp RENAME TO student" +== 019 +-- truncate_limit: 100 +-- self-conflict +alter table stud_emp rename to stud_emp +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE stud_emp RENAME TO stud_emp" +== 020 +-- truncate_limit: 100 +-- attribute renaming + +-- no such relation +alter table nonesuchrel rename column nonesuchatt to newnonesuchatt +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE nonesuchrel RENAME COLUMN nonesuchatt TO newnonesuchatt" +== 021 +-- truncate_limit: 100 +-- no such attribute +alter table emp rename column nonesuchatt to newnonesuchatt +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE emp RENAME COLUMN nonesuchatt TO newnonesuchatt" +== 022 +-- truncate_limit: 100 +-- conflict +alter table emp rename column salary to manager +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE emp RENAME COLUMN salary TO manager" +== 023 +-- truncate_limit: 100 +-- conflict +alter table emp rename column salary to ctid +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE emp RENAME COLUMN salary TO ctid" +== 024 +-- truncate_limit: 100 +|-- +-- TRANSACTION STUFF + +-- not in a xact +abort +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 025 +-- truncate_limit: 100 +-- not in a xact +end +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 026 +-- truncate_limit: 100 +|-- +-- CREATE AGGREGATE + +-- sfunc/finalfunc type disagreement +create aggregate newavg2 (sfunc = int4pl, + basetype = int4, + stype = int4, + finalfunc = int2um, + initcond = '0') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE newavg2 (sfunc = int4pl, basetype = int4, stype = int4, finalfunc = int2um, init..." +== 027 +-- truncate_limit: 100 +-- left out basetype +create aggregate newcnt1 (sfunc = int4inc, + stype = int4, + initcond = '0') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE newcnt1 (sfunc = int4inc, stype = int4, initcond = '0')" +== 028 +-- truncate_limit: 100 +|-- +-- DROP INDEX + +-- missing index name +drop index +-- +ERROR: syntax error at end of input +CURSORPOS: 51 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 029 +-- truncate_limit: 100 +-- bad index name +drop index 314159 +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 030 +-- truncate_limit: 100 +-- no such index +drop index nonesuch +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX nonesuch" +== 031 +-- truncate_limit: 100 +|-- +-- DROP AGGREGATE + +-- missing aggregate name +drop aggregate +-- +ERROR: syntax error at end of input +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 032 +-- truncate_limit: 100 +-- missing aggregate type +drop aggregate newcnt1 +-- +ERROR: syntax error at end of input +CURSORPOS: 49 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 033 +-- truncate_limit: 100 +-- bad aggregate name +drop aggregate 314159 (int) +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 034 +-- truncate_limit: 100 +-- bad aggregate type +drop aggregate newcnt (nonesuch) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE newcnt(nonesuch)" +== 035 +-- truncate_limit: 100 +-- no such aggregate +drop aggregate nonesuch (int4) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE nonesuch(int4)" +== 036 +-- truncate_limit: 100 +-- no such aggregate for type +drop aggregate newcnt (float4) +-- +STMT: DropStmt +TRUNCATED: "DROP AGGREGATE newcnt(float4)" +== 037 +-- truncate_limit: 100 +|-- +-- DROP FUNCTION + +-- missing function name +drop function () +-- +ERROR: syntax error at or near "(" +CURSORPOS: 61 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 038 +-- truncate_limit: 100 +-- bad function name +drop function 314159() +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 039 +-- truncate_limit: 100 +-- no such function +drop function nonesuch() +-- +FUNCTION: name="nonesuch" function="nonesuch" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION nonesuch()" +== 040 +-- truncate_limit: 100 +|-- +-- DROP TYPE + +-- missing type name +drop type +-- +ERROR: syntax error at end of input +CURSORPOS: 48 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 041 +-- truncate_limit: 100 +-- bad type name +drop type 314159 +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 042 +-- truncate_limit: 100 +-- no such type +drop type nonesuch +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE nonesuch" +== 043 +-- truncate_limit: 100 +|-- +-- DROP OPERATOR + +-- missing everything +drop operator +-- +ERROR: syntax error at end of input +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 044 +-- truncate_limit: 100 +-- bad operator name +drop operator equals +-- +ERROR: syntax error at end of input +CURSORPOS: 42 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 045 +-- truncate_limit: 100 +-- missing type list +drop operator === +-- +ERROR: syntax error at end of input +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 046 +-- truncate_limit: 100 +-- missing parentheses +drop operator int4, int4 +-- +ERROR: syntax error at or near "," +CURSORPOS: 42 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 047 +-- truncate_limit: 100 +-- missing operator name +drop operator (int4, int4) +-- +ERROR: syntax error at or near "(" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 048 +-- truncate_limit: 100 +-- missing type list contents +drop operator === () +-- +ERROR: syntax error at or near ")" +CURSORPOS: 50 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 049 +-- truncate_limit: 100 +-- no such operator +drop operator === (int4) +-- +ERROR: missing argument +CURSORPOS: 44 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 050 +-- truncate_limit: 100 +-- no such operator by that name +drop operator === (int4, int4) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ===(int4, int4)" +== 051 +-- truncate_limit: 100 +-- no such type1 +drop operator = (nonesuch) +-- +ERROR: missing argument +CURSORPOS: 43 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 052 +-- truncate_limit: 100 +-- no such type1 +drop operator = ( , int4) +-- +ERROR: syntax error at or near "," +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 053 +-- truncate_limit: 100 +-- no such type1 +drop operator = (nonesuch, int4) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR =(nonesuch, int4)" +== 054 +-- truncate_limit: 100 +-- no such type2 +drop operator = (int4, nonesuch) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR =(int4, nonesuch)" +== 055 +-- truncate_limit: 100 +-- no such type2 +drop operator = (int4, ) +-- +ERROR: syntax error at or near ")" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 056 +-- truncate_limit: 100 +|-- +-- DROP RULE + +-- missing rule name +drop rule +-- +ERROR: syntax error at end of input +CURSORPOS: 48 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 057 +-- truncate_limit: 100 +-- bad rule name +drop rule 314159 +-- +ERROR: syntax error at or near "314159" +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 058 +-- truncate_limit: 100 +-- no such rule +drop rule nonesuch on noplace +-- +TABLE: name="noplace" schema="" table="noplace" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE nonesuch ON noplace" +== 059 +-- truncate_limit: 100 +-- these postquel variants are no longer supported +drop tuple rule nonesuch +-- +ERROR: syntax error at or near "tuple" +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 060 +-- truncate_limit: 100 +drop instance rule nonesuch on noplace +-- +ERROR: syntax error at or near "instance" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 061 +-- truncate_limit: 100 +drop rewrite rule nonesuch +-- +ERROR: syntax error at or near "rewrite" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 062 +-- truncate_limit: 100 +|-- +-- Check that division-by-zero is properly caught. +|-- + +select 1/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0" +== 063 +-- truncate_limit: 100 +select 1::int8/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1::int8 / 0" +== 064 +-- truncate_limit: 100 +select 1/0::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0::int8" +== 065 +-- truncate_limit: 100 +select 1::int2/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1::int2 / 0" +== 066 +-- truncate_limit: 100 +select 1/0::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0::int2" +== 067 +-- truncate_limit: 100 +select 1::numeric/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1::numeric / 0" +== 068 +-- truncate_limit: 100 +select 1/0::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0::numeric" +== 069 +-- truncate_limit: 100 +select 1::float8/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1::float8 / 0" +== 070 +-- truncate_limit: 100 +select 1/0::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0::float8" +== 071 +-- truncate_limit: 100 +select 1::float4/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1::float4 / 0" +== 072 +-- truncate_limit: 100 +select 1/0::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0::float4" +== 073 +-- truncate_limit: 100 +CREATE foo +-- +ERROR: syntax error at or near "foo" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 074 +-- truncate_limit: 100 +CREATE TABLE +-- +ERROR: syntax error at end of input +CURSORPOS: 13 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 075 +-- truncate_limit: 100 +CREATE TABLE + +INSERT INTO foo VALUES(123) foo +-- +ERROR: syntax error at or near "INTO" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 076 +-- truncate_limit: 100 +INSERT INTO 123 +VALUES(123) +-- +ERROR: syntax error at or near "123" +CURSORPOS: 13 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 077 +-- truncate_limit: 100 +INSERT INTO foo +VALUES(123) 123 +-- +ERROR: syntax error at or near "123" +CURSORPOS: 29 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 078 +-- truncate_limit: 100 +-- with a tab +CREATE TABLE foo + (id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, + id3 INTEGER NOT NUL, + id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 108 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 079 +-- truncate_limit: 100 +-- long line to be truncated on the left +CREATE TABLE foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, +id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 131 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 080 +-- truncate_limit: 100 +-- long line to be truncated on the right +CREATE TABLE foo( +id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 77 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 081 +-- truncate_limit: 100 +-- long line to be truncated both ways +CREATE TABLE foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 129 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 082 +-- truncate_limit: 100 +-- long line to be truncated on the left, many lines +CREATE +TEMPORARY +TABLE +foo(id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, +id4 INT4 +UNIQUE +NOT +NULL, +id5 TEXT +UNIQUE +NOT +NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 153 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 083 +-- truncate_limit: 100 +-- long line to be truncated on the right, many lines +CREATE +TEMPORARY +TABLE +foo( +id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, id INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 99 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 084 +-- truncate_limit: 100 +-- long line to be truncated both ways, many lines +CREATE +TEMPORARY +TABLE +foo +(id +INT4 +UNIQUE NOT NULL, idx INT4 UNIQUE NOT NULL, idy INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, +idz INT4 UNIQUE NOT NULL, +idv INT4 UNIQUE NOT NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 204 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 085 +-- truncate_limit: 100 +-- more than 10 lines... +CREATE +TEMPORARY +TABLE +foo +(id +INT4 +UNIQUE +NOT +NULL +, +idm +INT4 +UNIQUE +NOT +NULL, +idx INT4 UNIQUE NOT NULL, idy INT4 UNIQUE NOT NULL, id2 TEXT NOT NULL PRIMARY KEY, id3 INTEGER NOT NUL, id4 INT4 UNIQUE NOT NULL, id5 TEXT UNIQUE NOT NULL, +idz INT4 UNIQUE NOT NULL, +idv +INT4 +UNIQUE +NOT +NULL) +-- +ERROR: syntax error at or near "NUL" +CURSORPOS: 205 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary_truncate/postgres_regress/event_trigger.metadata.json b/parser/testdata/summary_truncate/postgres_regress/event_trigger.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/event_trigger.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/event_trigger.test b/parser/testdata/summary_truncate/postgres_regress/event_trigger.test new file mode 100644 index 0000000..9a094b0 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/event_trigger.test @@ -0,0 +1,1826 @@ +== 001 +-- truncate_limit: 100 +-- should fail, return type mismatch +create event trigger regress_event_trigger + on ddl_command_start + execute procedure pg_backend_pid() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger ON ddl_command_start EXECUTE FUNCTION pg_backend_pid()" +== 002 +-- truncate_limit: 100 +-- OK +create function test_event_trigger() returns event_trigger as $$ +BEGIN + RAISE NOTICE 'test_event_trigger: % %', tg_event, tg_tag; +END +$$ language plpgsql +-- +FUNCTION: name="test_event_trigger" function="test_event_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_event_trigger() RETURNS event_trigger AS $$\nBEGIN\n RAISE NOTICE 'test_eve..." +== 003 +-- truncate_limit: 100 +-- should fail, can't call it as a plain function +SELECT test_event_trigger() +-- +FUNCTION: name="test_event_trigger" function="test_event_trigger" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_event_trigger()" +== 004 +-- truncate_limit: 100 +-- should fail, event triggers cannot have declared arguments +create function test_event_trigger_arg(name text) +returns event_trigger as $$ BEGIN RETURN 1; END $$ language plpgsql +-- +FUNCTION: name="test_event_trigger_arg" function="test_event_trigger_arg" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_event_trigger_arg(name text) RETURNS event_trigger AS $$ BEGIN RETURN 1; END..." +== 005 +-- truncate_limit: 100 +-- should fail, SQL functions cannot be event triggers +create function test_event_trigger_sql() returns event_trigger as $$ +SELECT 1 $$ language sql +-- +FUNCTION: name="test_event_trigger_sql" function="test_event_trigger_sql" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_event_trigger_sql() RETURNS event_trigger AS $$\nSELECT 1 $$ LANGUAGE sql" +== 006 +-- truncate_limit: 100 +-- should fail, no elephant_bootstrap entry point +create event trigger regress_event_trigger on elephant_bootstrap + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger ON elephant_bootstrap EXECUTE FUNCTION test_event_trig..." +== 007 +-- truncate_limit: 100 +-- OK +create event trigger regress_event_trigger on ddl_command_start + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger ON ddl_command_start EXECUTE FUNCTION test_event_trigg..." +== 008 +-- truncate_limit: 100 +-- OK +create event trigger regress_event_trigger_end on ddl_command_end + execute function test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger_end ON ddl_command_end EXECUTE FUNCTION test_event_tri..." +== 009 +-- truncate_limit: 100 +-- should fail, food is not a valid filter variable +create event trigger regress_event_trigger2 on ddl_command_start + when food in ('sandwich') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN food IN ('sandwich') EXECUT..." +== 010 +-- truncate_limit: 100 +-- should fail, sandwich is not a valid command tag +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('sandwich') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN tag IN ('sandwich') EXECUTE..." +== 011 +-- truncate_limit: 100 +-- should fail, create skunkcabbage is not a valid command tag +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('create table', 'create skunkcabbage') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN tag IN ('create table', 'cr..." +== 012 +-- truncate_limit: 100 +-- should fail, can't have event triggers on event triggers +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('DROP EVENT TRIGGER') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN tag IN ('DROP EVENT TRIGGER..." +== 013 +-- truncate_limit: 100 +-- should fail, can't have event triggers on global objects +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('CREATE ROLE') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN tag IN ('CREATE ROLE') EXEC..." +== 014 +-- truncate_limit: 100 +-- should fail, can't have event triggers on global objects +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('CREATE DATABASE') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN tag IN ('CREATE DATABASE') ..." +== 015 +-- truncate_limit: 100 +-- should fail, can't have event triggers on global objects +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('CREATE TABLESPACE') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN tag IN ('CREATE TABLESPACE'..." +== 016 +-- truncate_limit: 100 +-- should fail, can't have same filter variable twice +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('create table') and tag in ('CREATE FUNCTION') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN tag IN ('create table') AND..." +== 017 +-- truncate_limit: 100 +-- should fail, can't have arguments +create event trigger regress_event_trigger2 on ddl_command_start + execute procedure test_event_trigger('argument not allowed') +-- +ERROR: syntax error at or near "'argument not allowed'" +CURSORPOS: 143 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 018 +-- truncate_limit: 100 +-- OK +create event trigger regress_event_trigger2 on ddl_command_start + when tag in ('create table', 'CREATE FUNCTION') + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger2 ON ddl_command_start WHEN tag IN ('create table', 'CR..." +== 019 +-- truncate_limit: 100 +-- OK +comment on event trigger regress_event_trigger is 'test comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON EVENT TRIGGER regress_event_trigger IS 'test comment'" +== 020 +-- truncate_limit: 100 +-- drop as non-superuser should fail +create role regress_evt_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_evt_user" +== 021 +-- truncate_limit: 100 +set role regress_evt_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_evt_user" +== 022 +-- truncate_limit: 100 +create event trigger regress_event_trigger_noperms on ddl_command_start + execute procedure test_event_trigger() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger_noperms ON ddl_command_start EXECUTE FUNCTION test_eve..." +== 023 +-- truncate_limit: 100 +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 024 +-- truncate_limit: 100 +-- test enabling and disabling +alter event trigger regress_event_trigger disable +-- +STMT: AlterEventTrigStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger DISABLE" +== 025 +-- truncate_limit: 100 +-- fires _trigger2 and _trigger_end should fire, but not _trigger +create table event_trigger_fire1 (a int) +-- +TABLE: name="event_trigger_fire1" schema="" table="event_trigger_fire1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE event_trigger_fire1 (a int)" +== 026 +-- truncate_limit: 100 +alter event trigger regress_event_trigger enable +-- +STMT: AlterEventTrigStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger ENABLE" +== 027 +-- truncate_limit: 100 +set session_replication_role = replica +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_replication_role TO replica" +== 028 +-- truncate_limit: 100 +-- fires nothing +create table event_trigger_fire2 (a int) +-- +TABLE: name="event_trigger_fire2" schema="" table="event_trigger_fire2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE event_trigger_fire2 (a int)" +== 029 +-- truncate_limit: 100 +alter event trigger regress_event_trigger enable replica +-- +STMT: AlterEventTrigStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger ENABLE REPLICA" +== 030 +-- truncate_limit: 100 +-- fires only _trigger +create table event_trigger_fire3 (a int) +-- +TABLE: name="event_trigger_fire3" schema="" table="event_trigger_fire3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE event_trigger_fire3 (a int)" +== 031 +-- truncate_limit: 100 +alter event trigger regress_event_trigger enable always +-- +STMT: AlterEventTrigStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger ENABLE ALWAYS" +== 032 +-- truncate_limit: 100 +-- fires only _trigger +create table event_trigger_fire4 (a int) +-- +TABLE: name="event_trigger_fire4" schema="" table="event_trigger_fire4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE event_trigger_fire4 (a int)" +== 033 +-- truncate_limit: 100 +reset session_replication_role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_replication_role" +== 034 +-- truncate_limit: 100 +-- fires all three +create table event_trigger_fire5 (a int) +-- +TABLE: name="event_trigger_fire5" schema="" table="event_trigger_fire5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE event_trigger_fire5 (a int)" +== 035 +-- truncate_limit: 100 +-- non-top-level command +create function f1() returns int +language plpgsql +as $$ +begin + create table event_trigger_fire6 (a int); + return 0; +end $$ +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1() RETURNS int LANGUAGE plpgsql AS $$\nbegin\n create table event_trigger_fire6 ..." +== 036 +-- truncate_limit: 100 +select f1() +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1()" +== 037 +-- truncate_limit: 100 +-- non-top-level command +create procedure p1() +language plpgsql +as $$ +begin + create table event_trigger_fire7 (a int); +end $$ +-- +FUNCTION: name="p1" function="p1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE p1() LANGUAGE plpgsql AS $$\nbegin\n create table event_trigger_fire7 (a int);\nen..." +== 038 +-- truncate_limit: 100 +call p1() +-- +FUNCTION: name="p1" function="p1" schema="" ctx=Call +STMT: CallStmt +TRUNCATED: "CALL p1()" +== 039 +-- truncate_limit: 100 +-- clean up +alter event trigger regress_event_trigger disable +-- +STMT: AlterEventTrigStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger DISABLE" +== 040 +-- truncate_limit: 100 +drop table event_trigger_fire2, event_trigger_fire3, event_trigger_fire4, event_trigger_fire5, event_trigger_fire6, event_trigger_fire7 +-- +TABLE: name="event_trigger_fire2" schema="" table="event_trigger_fire2" ctx=DDL +TABLE: name="event_trigger_fire3" schema="" table="event_trigger_fire3" ctx=DDL +TABLE: name="event_trigger_fire4" schema="" table="event_trigger_fire4" ctx=DDL +TABLE: name="event_trigger_fire5" schema="" table="event_trigger_fire5" ctx=DDL +TABLE: name="event_trigger_fire6" schema="" table="event_trigger_fire6" ctx=DDL +TABLE: name="event_trigger_fire7" schema="" table="event_trigger_fire7" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE event_trigger_fire2, event_trigger_fire3, event_trigger_fire4, event_trigger_fire5, ev..." +== 041 +-- truncate_limit: 100 +drop routine f1(), p1() +-- +STMT: DropStmt +TRUNCATED: "DROP ROUTINE f1(), p1()" +== 042 +-- truncate_limit: 100 +-- regress_event_trigger_end should fire on these commands +grant all on table event_trigger_fire1 to public +-- +TABLE: name="event_trigger_fire1" schema="" table="event_trigger_fire1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON event_trigger_fire1 TO public" +== 043 +-- truncate_limit: 100 +comment on table event_trigger_fire1 is 'here is a comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TABLE event_trigger_fire1 IS 'here is a comment'" +== 044 +-- truncate_limit: 100 +revoke all on table event_trigger_fire1 from public +-- +TABLE: name="event_trigger_fire1" schema="" table="event_trigger_fire1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON event_trigger_fire1 FROM public" +== 045 +-- truncate_limit: 100 +drop table event_trigger_fire1 +-- +TABLE: name="event_trigger_fire1" schema="" table="event_trigger_fire1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE event_trigger_fire1" +== 046 +-- truncate_limit: 100 +create foreign data wrapper useless +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER useless" +== 047 +-- truncate_limit: 100 +create server useless_server foreign data wrapper useless +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER useless_server FOREIGN DATA WRAPPER useless" +== 048 +-- truncate_limit: 100 +create user mapping for regress_evt_user server useless_server +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR regress_evt_user SERVER useless_server" +== 049 +-- truncate_limit: 100 +alter default privileges for role regress_evt_user + revoke delete on tables from regress_evt_user +-- +STMT: AlterDefaultPrivilegesStmt +TRUNCATED: "ALTER DEFAULT PRIVILEGES FOR ROLE regress_evt_user REVOKE delete ON TABLES FROM regress_evt_user" +== 050 +-- truncate_limit: 100 +-- alter owner to non-superuser should fail +alter event trigger regress_event_trigger owner to regress_evt_user +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger OWNER TO regress_evt_user" +== 051 +-- truncate_limit: 100 +-- alter owner to superuser should work +alter role regress_evt_user superuser +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_evt_user WITH SUPERUSER" +== 052 +-- truncate_limit: 100 +alter event trigger regress_event_trigger owner to regress_evt_user +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger OWNER TO regress_evt_user" +== 053 +-- truncate_limit: 100 +-- should fail, name collision +alter event trigger regress_event_trigger rename to regress_event_trigger2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger RENAME TO regress_event_trigger2" +== 054 +-- truncate_limit: 100 +-- OK +alter event trigger regress_event_trigger rename to regress_event_trigger3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_event_trigger RENAME TO regress_event_trigger3" +== 055 +-- truncate_limit: 100 +-- should fail, doesn't exist any more +drop event trigger regress_event_trigger +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_event_trigger" +== 056 +-- truncate_limit: 100 +-- should fail, regress_evt_user owns some objects +drop role regress_evt_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_evt_user" +== 057 +-- truncate_limit: 100 +-- cleanup before next test +-- these are all OK; the second one should emit a NOTICE +drop event trigger if exists regress_event_trigger2 +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER IF EXISTS regress_event_trigger2" +== 058 +-- truncate_limit: 100 +drop event trigger if exists regress_event_trigger2 +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER IF EXISTS regress_event_trigger2" +== 059 +-- truncate_limit: 100 +drop event trigger regress_event_trigger3 +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_event_trigger3" +== 060 +-- truncate_limit: 100 +drop event trigger regress_event_trigger_end +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_event_trigger_end" +== 061 +-- truncate_limit: 100 +-- test support for dropped objects +CREATE SCHEMA schema_one authorization regress_evt_user +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA schema_one AUTHORIZATION regress_evt_user" +== 062 +-- truncate_limit: 100 +CREATE SCHEMA schema_two authorization regress_evt_user +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA schema_two AUTHORIZATION regress_evt_user" +== 063 +-- truncate_limit: 100 +CREATE SCHEMA audit_tbls authorization regress_evt_user +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA audit_tbls AUTHORIZATION regress_evt_user" +== 064 +-- truncate_limit: 100 +CREATE TEMP TABLE a_temp_tbl () +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE a_temp_tbl ()" +== 065 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_evt_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_evt_user" +== 066 +-- truncate_limit: 100 +CREATE TABLE schema_one.table_one(a int) +-- +TABLE: name="schema_one.table_one" schema="schema_one" table="table_one" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE schema_one.table_one (a int)" +== 067 +-- truncate_limit: 100 +CREATE TABLE schema_one."table two"(a int) +-- +TABLE: name="schema_one.\"table two\"" schema="schema_one" table="table two" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE schema_one.\"table two\" (a int)" +== 068 +-- truncate_limit: 100 +CREATE TABLE schema_one.table_three(a int) +-- +TABLE: name="schema_one.table_three" schema="schema_one" table="table_three" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE schema_one.table_three (a int)" +== 069 +-- truncate_limit: 100 +CREATE TABLE audit_tbls.schema_one_table_two(the_value text) +-- +TABLE: name="audit_tbls.schema_one_table_two" schema="audit_tbls" table="schema_one_table_two" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE audit_tbls.schema_one_table_two (the_value text)" +== 070 +-- truncate_limit: 100 +CREATE TABLE schema_two.table_two(a int) +-- +TABLE: name="schema_two.table_two" schema="schema_two" table="table_two" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE schema_two.table_two (a int)" +== 071 +-- truncate_limit: 100 +CREATE TABLE schema_two.table_three(a int, b text) +-- +TABLE: name="schema_two.table_three" schema="schema_two" table="table_three" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE schema_two.table_three (a int, b text)" +== 072 +-- truncate_limit: 100 +CREATE TABLE audit_tbls.schema_two_table_three(the_value text) +-- +TABLE: name="audit_tbls.schema_two_table_three" schema="audit_tbls" table="schema_two_table_three" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE audit_tbls.schema_two_table_three (the_value text)" +== 073 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION schema_two.add(int, int) RETURNS int LANGUAGE plpgsql + CALLED ON NULL INPUT + AS $$ BEGIN RETURN coalesce($1,0) + coalesce($2,0); END; $$ +-- +FUNCTION: name="schema_two.add" function="add" schema="schema_two" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION schema_two.add(int, int) RETURNS int LANGUAGE plpgsql CALLED ON NULL I..." +== 074 +-- truncate_limit: 100 +CREATE AGGREGATE schema_two.newton + (BASETYPE = int, SFUNC = schema_two.add, STYPE = int) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE schema_two.newton (basetype = int, sfunc = schema_two.add, stype = int)" +== 075 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 076 +-- truncate_limit: 100 +CREATE TABLE undroppable_objs ( + object_type text, + object_identity text +) +-- +TABLE: name="undroppable_objs" schema="" table="undroppable_objs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE undroppable_objs (object_type text, object_identity text)" +== 077 +-- truncate_limit: 100 +INSERT INTO undroppable_objs VALUES +('table', 'schema_one.table_three'), +('table', 'audit_tbls.schema_two_table_three') +-- +TABLE: name="undroppable_objs" schema="" table="undroppable_objs" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO undroppable_objs VALUES (...)" +== 078 +-- truncate_limit: 100 +CREATE TABLE dropped_objects ( + object_type text, + schema_name text, + object_name text, + object_identity text, + address_names text[], + address_args text[], + is_temporary bool, + original bool, + normal bool +) +-- +TABLE: name="dropped_objects" schema="" table="dropped_objects" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dropped_objects (object_type text, schema_name text, object_name text, object_identi..." +== 079 +-- truncate_limit: 100 +-- This tests errors raised within event triggers; the one in audit_tbls +-- uses 2nd-level recursive invocation via test_evtrig_dropped_objects(). +CREATE OR REPLACE FUNCTION undroppable() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +DECLARE + obj record; +BEGIN + PERFORM 1 FROM pg_tables WHERE tablename = 'undroppable_objs'; + IF NOT FOUND THEN + RAISE NOTICE 'table undroppable_objs not found, skipping'; + RETURN; + END IF; + FOR obj IN + SELECT * FROM pg_event_trigger_dropped_objects() JOIN + undroppable_objs USING (object_type, object_identity) + LOOP + RAISE EXCEPTION 'object % of type % cannot be dropped', + obj.object_identity, obj.object_type; + END LOOP; +END; +$$ +-- +FUNCTION: name="undroppable" function="undroppable" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION undroppable() RETURNS event_trigger LANGUAGE plpgsql AS $$\nDECLARE\n\tob..." +== 080 +-- truncate_limit: 100 +CREATE EVENT TRIGGER undroppable ON sql_drop + EXECUTE PROCEDURE undroppable() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER undroppable ON sql_drop EXECUTE FUNCTION undroppable()" +== 081 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION test_evtrig_dropped_objects() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +DECLARE + obj record; +BEGIN + FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects() + LOOP + IF obj.object_type = 'table' THEN + EXECUTE format('DROP TABLE IF EXISTS audit_tbls.%I', + format('%s_%s', obj.schema_name, obj.object_name)); + END IF; + + INSERT INTO dropped_objects + (object_type, schema_name, object_name, + object_identity, address_names, address_args, + is_temporary, original, normal) VALUES + (obj.object_type, obj.schema_name, obj.object_name, + obj.object_identity, obj.address_names, obj.address_args, + obj.is_temporary, obj.original, obj.normal); + END LOOP; +END +$$ +-- +FUNCTION: name="test_evtrig_dropped_objects" function="test_evtrig_dropped_objects" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION test_evtrig_dropped_objects() RETURNS event_trigger LANGUAGE plpgsql A..." +== 082 +-- truncate_limit: 100 +CREATE EVENT TRIGGER regress_event_trigger_drop_objects ON sql_drop + WHEN TAG IN ('drop table', 'drop function', 'drop view', + 'drop owned', 'drop schema', 'alter table') + EXECUTE PROCEDURE test_evtrig_dropped_objects() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger_drop_objects ON sql_drop WHEN tag IN ('drop table', 'd..." +== 083 +-- truncate_limit: 100 +ALTER TABLE schema_one.table_one DROP COLUMN a +-- +TABLE: name="schema_one.table_one" schema="schema_one" table="table_one" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE schema_one.table_one DROP a" +== 084 +-- truncate_limit: 100 +DROP SCHEMA schema_one, schema_two CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA schema_one, schema_two CASCADE" +== 085 +-- truncate_limit: 100 +DELETE FROM undroppable_objs WHERE object_identity = 'audit_tbls.schema_two_table_three' +-- +TABLE: name="undroppable_objs" schema="" table="undroppable_objs" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM undroppable_objs WHERE object_identity = 'audit_tbls.schema_two_table_three'" +== 086 +-- truncate_limit: 100 +DROP SCHEMA schema_one, schema_two CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA schema_one, schema_two CASCADE" +== 087 +-- truncate_limit: 100 +DELETE FROM undroppable_objs WHERE object_identity = 'schema_one.table_three' +-- +TABLE: name="undroppable_objs" schema="" table="undroppable_objs" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM undroppable_objs WHERE object_identity = 'schema_one.table_three'" +== 088 +-- truncate_limit: 100 +DROP SCHEMA schema_one, schema_two CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA schema_one, schema_two CASCADE" +== 089 +-- truncate_limit: 100 +-- exclude TOAST objects because they have unstable names +SELECT * FROM dropped_objects + WHERE schema_name IS NULL OR schema_name <> 'pg_toast' +-- +TABLE: name="dropped_objects" schema="" table="dropped_objects" ctx=Select +FILTER: schema="" table="" column="schema_name" +FILTER: schema="" table="" column="schema_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dropped_objects WHERE schema_name IS NULL OR schema_name <> 'pg_toast'" +== 090 +-- truncate_limit: 100 +DROP OWNED BY regress_evt_user +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_evt_user" +== 091 +-- truncate_limit: 100 +SELECT * FROM dropped_objects WHERE object_type = 'schema' +-- +TABLE: name="dropped_objects" schema="" table="dropped_objects" ctx=Select +FILTER: schema="" table="" column="object_type" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dropped_objects WHERE object_type = 'schema'" +== 092 +-- truncate_limit: 100 +DROP ROLE regress_evt_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_evt_user" +== 093 +-- truncate_limit: 100 +DROP EVENT TRIGGER regress_event_trigger_drop_objects +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_event_trigger_drop_objects" +== 094 +-- truncate_limit: 100 +DROP EVENT TRIGGER undroppable +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER undroppable" +== 095 +-- truncate_limit: 100 +-- Event triggers on relations. +CREATE OR REPLACE FUNCTION event_trigger_report_dropped() + RETURNS event_trigger + LANGUAGE plpgsql +AS $$ +DECLARE r record; +BEGIN + FOR r IN SELECT * from pg_event_trigger_dropped_objects() + LOOP + IF NOT r.normal AND NOT r.original THEN + CONTINUE; + END IF; + RAISE NOTICE 'NORMAL: orig=% normal=% istemp=% type=% identity=% schema=% name=% addr=% args=%', + r.original, r.normal, r.is_temporary, r.object_type, + r.object_identity, r.schema_name, r.object_name, + r.address_names, r.address_args; + END LOOP; +END; $$ +-- +FUNCTION: name="event_trigger_report_dropped" function="event_trigger_report_dropped" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION event_trigger_report_dropped() RETURNS event_trigger LANGUAGE plpgsql ..." +== 096 +-- truncate_limit: 100 +CREATE EVENT TRIGGER regress_event_trigger_report_dropped ON sql_drop + EXECUTE PROCEDURE event_trigger_report_dropped() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger_report_dropped ON sql_drop EXECUTE FUNCTION event_trig..." +== 097 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION event_trigger_report_end() + RETURNS event_trigger + LANGUAGE plpgsql +AS $$ +DECLARE r RECORD; +BEGIN + FOR r IN SELECT * FROM pg_event_trigger_ddl_commands() + LOOP + RAISE NOTICE 'END: command_tag=% type=% identity=%', + r.command_tag, r.object_type, r.object_identity; + END LOOP; +END; $$ +-- +FUNCTION: name="event_trigger_report_end" function="event_trigger_report_end" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION event_trigger_report_end() RETURNS event_trigger LANGUAGE plpgsql AS $..." +== 098 +-- truncate_limit: 100 +CREATE EVENT TRIGGER regress_event_trigger_report_end ON ddl_command_end + EXECUTE PROCEDURE event_trigger_report_end() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_event_trigger_report_end ON ddl_command_end EXECUTE FUNCTION event_t..." +== 099 +-- truncate_limit: 100 +CREATE SCHEMA evttrig + CREATE TABLE one (col_a SERIAL PRIMARY KEY, col_b text DEFAULT 'forty two', col_c SERIAL) + CREATE INDEX one_idx ON one (col_b) + CREATE TABLE two (col_c INTEGER CHECK (col_c > 0) REFERENCES one DEFAULT 42) + CREATE TABLE id (col_d int NOT NULL GENERATED ALWAYS AS IDENTITY) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA evttrig CREATE TABLE one (col_a serial PRIMARY KEY, col_b text DEFAULT 'forty two',..." +== 100 +-- truncate_limit: 100 +-- Partitioned tables with a partitioned index +CREATE TABLE evttrig.parted ( + id int PRIMARY KEY) + PARTITION BY RANGE (id) +-- +TABLE: name="evttrig.parted" schema="evttrig" table="parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE evttrig.parted (id int PRIMARY KEY) PARTITION BY RANGE (id)" +== 101 +-- truncate_limit: 100 +CREATE TABLE evttrig.part_1_10 PARTITION OF evttrig.parted (id) + FOR VALUES FROM (1) TO (10) +-- +TABLE: name="evttrig.part_1_10" schema="evttrig" table="part_1_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE evttrig.part_1_10 PARTITION OF evttrig.parted (id) FOR VALUES FROM (1) TO (10)" +== 102 +-- truncate_limit: 100 +CREATE TABLE evttrig.part_10_20 PARTITION OF evttrig.parted (id) + FOR VALUES FROM (10) TO (20) PARTITION BY RANGE (id) +-- +TABLE: name="evttrig.part_10_20" schema="evttrig" table="part_10_20" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE evttrig.part_10_20 PARTITION OF evttrig.parted (id) FOR VALUES FROM (10) TO (20) PAR..." +== 103 +-- truncate_limit: 100 +CREATE TABLE evttrig.part_10_15 PARTITION OF evttrig.part_10_20 (id) + FOR VALUES FROM (10) TO (15) +-- +TABLE: name="evttrig.part_10_15" schema="evttrig" table="part_10_15" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE evttrig.part_10_15 PARTITION OF evttrig.part_10_20 (id) FOR VALUES FROM (10) TO (15)" +== 104 +-- truncate_limit: 100 +CREATE TABLE evttrig.part_15_20 PARTITION OF evttrig.part_10_20 (id) + FOR VALUES FROM (15) TO (20) +-- +TABLE: name="evttrig.part_15_20" schema="evttrig" table="part_15_20" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE evttrig.part_15_20 PARTITION OF evttrig.part_10_20 (id) FOR VALUES FROM (15) TO (20)" +== 105 +-- truncate_limit: 100 +ALTER TABLE evttrig.two DROP COLUMN col_c +-- +TABLE: name="evttrig.two" schema="evttrig" table="two" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE evttrig.two DROP col_c" +== 106 +-- truncate_limit: 100 +ALTER TABLE evttrig.one ALTER COLUMN col_b DROP DEFAULT +-- +TABLE: name="evttrig.one" schema="evttrig" table="one" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE evttrig.one ALTER COLUMN col_b DROP DEFAULT" +== 107 +-- truncate_limit: 100 +ALTER TABLE evttrig.one DROP CONSTRAINT one_pkey +-- +TABLE: name="evttrig.one" schema="evttrig" table="one" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE evttrig.one DROP CONSTRAINT one_pkey" +== 108 +-- truncate_limit: 100 +ALTER TABLE evttrig.one DROP COLUMN col_c +-- +TABLE: name="evttrig.one" schema="evttrig" table="one" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE evttrig.one DROP col_c" +== 109 +-- truncate_limit: 100 +ALTER TABLE evttrig.id ALTER COLUMN col_d SET DATA TYPE bigint +-- +TABLE: name="evttrig.id" schema="evttrig" table="id" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE evttrig.id ALTER COLUMN col_d TYPE bigint" +== 110 +-- truncate_limit: 100 +ALTER TABLE evttrig.id ALTER COLUMN col_d DROP IDENTITY, + ALTER COLUMN col_d SET DATA TYPE int +-- +TABLE: name="evttrig.id" schema="evttrig" table="id" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE evttrig.id ALTER COLUMN col_d DROP IDENTITY, ALTER COLUMN col_d TYPE int" +== 111 +-- truncate_limit: 100 +DROP INDEX evttrig.one_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX evttrig.one_idx" +== 112 +-- truncate_limit: 100 +DROP SCHEMA evttrig CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA evttrig CASCADE" +== 113 +-- truncate_limit: 100 +DROP TABLE a_temp_tbl +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE a_temp_tbl" +== 114 +-- truncate_limit: 100 +-- check unfiltered results, too +CREATE OR REPLACE FUNCTION event_trigger_report_dropped() + RETURNS event_trigger + LANGUAGE plpgsql +AS $$ +DECLARE r record; +BEGIN + FOR r IN SELECT * from pg_event_trigger_dropped_objects() + LOOP + RAISE NOTICE 'DROP: orig=% normal=% istemp=% type=% identity=% schema=% name=% addr=% args=%', + r.original, r.normal, r.is_temporary, r.object_type, + r.object_identity, r.schema_name, r.object_name, + r.address_names, r.address_args; + END LOOP; +END; $$ +-- +FUNCTION: name="event_trigger_report_dropped" function="event_trigger_report_dropped" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION event_trigger_report_dropped() RETURNS event_trigger LANGUAGE plpgsql ..." +== 115 +-- truncate_limit: 100 +CREATE FUNCTION event_trigger_dummy_trigger() + RETURNS trigger + LANGUAGE plpgsql +AS $$ +BEGIN + RETURN new; +END; $$ +-- +FUNCTION: name="event_trigger_dummy_trigger" function="event_trigger_dummy_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION event_trigger_dummy_trigger() RETURNS trigger LANGUAGE plpgsql AS $$\nBEGIN\n RE..." +== 116 +-- truncate_limit: 100 +CREATE TABLE evtrg_nontemp_table (f1 int primary key, f2 int default 42) +-- +TABLE: name="evtrg_nontemp_table" schema="" table="evtrg_nontemp_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE evtrg_nontemp_table (f1 int PRIMARY KEY, f2 int DEFAULT 42)" +== 117 +-- truncate_limit: 100 +CREATE TRIGGER evtrg_nontemp_trig + BEFORE INSERT ON evtrg_nontemp_table + EXECUTE FUNCTION event_trigger_dummy_trigger() +-- +TABLE: name="evtrg_nontemp_table" schema="" table="evtrg_nontemp_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER evtrg_nontemp_trig BEFORE INSERT ON evtrg_nontemp_table EXECUTE FUNCTION event_tri..." +== 118 +-- truncate_limit: 100 +CREATE POLICY evtrg_nontemp_pol ON evtrg_nontemp_table USING (f2 > 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY evtrg_nontemp_pol ON evtrg_nontemp_table TO public USING (f2 > 0)" +== 119 +-- truncate_limit: 100 +DROP TABLE evtrg_nontemp_table +-- +TABLE: name="evtrg_nontemp_table" schema="" table="evtrg_nontemp_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE evtrg_nontemp_table" +== 120 +-- truncate_limit: 100 +CREATE TEMP TABLE a_temp_tbl (f1 int primary key, f2 int default 42) +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE a_temp_tbl (f1 int PRIMARY KEY, f2 int DEFAULT 42)" +== 121 +-- truncate_limit: 100 +CREATE TRIGGER a_temp_trig + BEFORE INSERT ON a_temp_tbl + EXECUTE FUNCTION event_trigger_dummy_trigger() +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a_temp_trig BEFORE INSERT ON a_temp_tbl EXECUTE FUNCTION event_trigger_dummy_trigg..." +== 122 +-- truncate_limit: 100 +CREATE POLICY a_temp_pol ON a_temp_tbl USING (f2 > 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY a_temp_pol ON a_temp_tbl TO public USING (f2 > 0)" +== 123 +-- truncate_limit: 100 +DROP TABLE a_temp_tbl +-- +TABLE: name="a_temp_tbl" schema="" table="a_temp_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE a_temp_tbl" +== 124 +-- truncate_limit: 100 +DROP FUNCTION event_trigger_dummy_trigger() +-- +FUNCTION: name="event_trigger_dummy_trigger" function="event_trigger_dummy_trigger" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION event_trigger_dummy_trigger()" +== 125 +-- truncate_limit: 100 +-- CREATE OPERATOR CLASS without FAMILY clause should report +-- both CREATE OPERATOR FAMILY and CREATE OPERATOR CLASS +CREATE OPERATOR CLASS evttrigopclass FOR TYPE int USING btree AS STORAGE int +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS evttrigopclass FOR TYPE int USING btree AS STORAGE int" +== 126 +-- truncate_limit: 100 +DROP EVENT TRIGGER regress_event_trigger_report_dropped +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_event_trigger_report_dropped" +== 127 +-- truncate_limit: 100 +DROP EVENT TRIGGER regress_event_trigger_report_end +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_event_trigger_report_end" +== 128 +-- truncate_limit: 100 +-- only allowed from within an event trigger function, should fail +select pg_event_trigger_table_rewrite_oid() +-- +FUNCTION: name="pg_event_trigger_table_rewrite_oid" function="pg_event_trigger_table_rewrite_oid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_event_trigger_table_rewrite_oid()" +== 129 +-- truncate_limit: 100 +-- test Table Rewrite Event Trigger +CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE EXCEPTION 'rewrites not allowed'; +END; +$$ +-- +FUNCTION: name="test_evtrig_no_rewrite" function="test_evtrig_no_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger LANGUAGE plpgsql AS $$\n..." +== 130 +-- truncate_limit: 100 +create event trigger no_rewrite_allowed on table_rewrite + execute procedure test_evtrig_no_rewrite() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER no_rewrite_allowed ON table_rewrite EXECUTE FUNCTION test_evtrig_no_rewrite()" +== 131 +-- truncate_limit: 100 +create table rewriteme (id serial primary key, foo float, bar timestamptz) +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rewriteme (id serial PRIMARY KEY, foo double precision, bar timestamptz)" +== 132 +-- truncate_limit: 100 +insert into rewriteme + select x * 1.001 from generate_series(1, 500) as t(x) +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rewriteme SELECT x * 1.001 FROM generate_series(1, 500) t(x)" +== 133 +-- truncate_limit: 100 +alter table rewriteme alter column foo type numeric +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rewriteme ALTER COLUMN foo TYPE numeric" +== 134 +-- truncate_limit: 100 +alter table rewriteme add column baz int default 0 +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rewriteme ADD COLUMN baz int DEFAULT 0" +== 135 +-- truncate_limit: 100 +-- test with more than one reason to rewrite a single table +CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'Table ''%'' is being rewritten (reason = %)', + pg_event_trigger_table_rewrite_oid()::regclass, + pg_event_trigger_table_rewrite_reason(); +END; +$$ +-- +FUNCTION: name="test_evtrig_no_rewrite" function="test_evtrig_no_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger LANGUAGE plpgsql AS $$\n..." +== 136 +-- truncate_limit: 100 +alter table rewriteme + add column onemore int default 0, + add column another int default -1, + alter column foo type numeric(10,4) +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rewriteme ADD COLUMN onemore int DEFAULT 0, ADD COLUMN another int DEFAULT -1, ALTER ..." +== 137 +-- truncate_limit: 100 +-- matview rewrite when changing access method +CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT 1 AS a +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW heapmv USING heap AS SELECT 1 AS a" +== 138 +-- truncate_limit: 100 +ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2 +-- +TABLE: name="heapmv" schema="" table="heapmv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER MATERIALIZED VIEW heapmv SET ACCESS METHOD heap2" +== 139 +-- truncate_limit: 100 +DROP MATERIALIZED VIEW heapmv +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW heapmv" +== 140 +-- truncate_limit: 100 +-- shouldn't trigger a table_rewrite event +alter table rewriteme alter column foo type numeric(12,4) +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rewriteme ALTER COLUMN foo TYPE numeric(12, 4)" +== 141 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 142 +-- truncate_limit: 100 +set timezone to 'UTC' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"UTC\"" +== 143 +-- truncate_limit: 100 +alter table rewriteme alter column bar type timestamp +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rewriteme ALTER COLUMN bar TYPE timestamp" +== 144 +-- truncate_limit: 100 +set timezone to '0' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"0\"" +== 145 +-- truncate_limit: 100 +alter table rewriteme alter column bar type timestamptz +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rewriteme ALTER COLUMN bar TYPE timestamptz" +== 146 +-- truncate_limit: 100 +set timezone to 'Europe/London' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"Europe/London\"" +== 147 +-- truncate_limit: 100 +alter table rewriteme alter column bar type timestamp +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rewriteme ALTER COLUMN bar TYPE timestamp" +== 148 +-- truncate_limit: 100 +-- does rewrite +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 149 +-- truncate_limit: 100 +-- typed tables are rewritten when their type changes. Don't emit table +-- name, because firing order is not stable. +CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'Table is being rewritten (reason = %)', + pg_event_trigger_table_rewrite_reason(); +END; +$$ +-- +FUNCTION: name="test_evtrig_no_rewrite" function="test_evtrig_no_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION test_evtrig_no_rewrite() RETURNS event_trigger LANGUAGE plpgsql AS $$\n..." +== 150 +-- truncate_limit: 100 +create type rewritetype as (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE rewritetype AS (a int)" +== 151 +-- truncate_limit: 100 +create table rewritemetoo1 of rewritetype +-- +TABLE: name="rewritemetoo1" schema="" table="rewritemetoo1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rewritemetoo1 OF rewritetype" +== 152 +-- truncate_limit: 100 +create table rewritemetoo2 of rewritetype +-- +TABLE: name="rewritemetoo2" schema="" table="rewritemetoo2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rewritemetoo2 OF rewritetype" +== 153 +-- truncate_limit: 100 +alter type rewritetype alter attribute a type text cascade +-- +TABLE: name="rewritetype" schema="" table="rewritetype" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE rewritetype ALTER ATTRIBUTE a TYPE text CASCADE" +== 154 +-- truncate_limit: 100 +-- but this doesn't work +create table rewritemetoo3 (a rewritetype) +-- +TABLE: name="rewritemetoo3" schema="" table="rewritemetoo3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rewritemetoo3 (a rewritetype)" +== 155 +-- truncate_limit: 100 +alter type rewritetype alter attribute a type varchar cascade +-- +TABLE: name="rewritetype" schema="" table="rewritetype" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE rewritetype ALTER ATTRIBUTE a TYPE varchar CASCADE" +== 156 +-- truncate_limit: 100 +drop table rewriteme +-- +TABLE: name="rewriteme" schema="" table="rewriteme" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rewriteme" +== 157 +-- truncate_limit: 100 +drop event trigger no_rewrite_allowed +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER no_rewrite_allowed" +== 158 +-- truncate_limit: 100 +drop function test_evtrig_no_rewrite() +-- +FUNCTION: name="test_evtrig_no_rewrite" function="test_evtrig_no_rewrite" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION test_evtrig_no_rewrite()" +== 159 +-- truncate_limit: 100 +-- Tests for REINDEX +CREATE OR REPLACE FUNCTION reindex_start_command() +RETURNS event_trigger AS $$ +BEGIN + RAISE NOTICE 'REINDEX START: % %', tg_event, tg_tag; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="reindex_start_command" function="reindex_start_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION reindex_start_command() RETURNS event_trigger AS $$\nBEGIN\n RAISE NO..." +== 160 +-- truncate_limit: 100 +CREATE EVENT TRIGGER regress_reindex_start ON ddl_command_start + WHEN TAG IN ('REINDEX') + EXECUTE PROCEDURE reindex_start_command() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_reindex_start ON ddl_command_start WHEN tag IN ('REINDEX') EXECUTE F..." +== 161 +-- truncate_limit: 100 +CREATE FUNCTION reindex_end_command() +RETURNS event_trigger AS $$ +DECLARE + obj record; +BEGIN + FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() + LOOP + RAISE NOTICE 'REINDEX END: command_tag=% type=% identity=%', + obj.command_tag, obj.object_type, obj.object_identity; + END LOOP; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="reindex_end_command" function="reindex_end_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION reindex_end_command() RETURNS event_trigger AS $$\nDECLARE\n obj record;\nBEGIN\n ..." +== 162 +-- truncate_limit: 100 +CREATE EVENT TRIGGER regress_reindex_end ON ddl_command_end + WHEN TAG IN ('REINDEX') + EXECUTE PROCEDURE reindex_end_command() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_reindex_end ON ddl_command_end WHEN tag IN ('REINDEX') EXECUTE FUNCT..." +== 163 +-- truncate_limit: 100 +-- Extra event to force the use of a snapshot. +CREATE FUNCTION reindex_end_command_snap() RETURNS EVENT_TRIGGER + AS $$ BEGIN PERFORM 1; END $$ LANGUAGE plpgsql +-- +FUNCTION: name="reindex_end_command_snap" function="reindex_end_command_snap" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION reindex_end_command_snap() RETURNS event_trigger AS $$ BEGIN PERFORM 1; END $$ LA..." +== 164 +-- truncate_limit: 100 +CREATE EVENT TRIGGER regress_reindex_end_snap ON ddl_command_end + EXECUTE FUNCTION reindex_end_command_snap() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER regress_reindex_end_snap ON ddl_command_end EXECUTE FUNCTION reindex_end_com..." +== 165 +-- truncate_limit: 100 +-- With simple relation +CREATE TABLE concur_reindex_tab (c1 int) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_tab (c1 int)" +== 166 +-- truncate_limit: 100 +CREATE INDEX concur_reindex_ind ON concur_reindex_tab (c1) +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_ind ON concur_reindex_tab USING btree (c1)" +== 167 +-- truncate_limit: 100 +-- Both start and end triggers enabled. +REINDEX INDEX concur_reindex_ind +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX concur_reindex_ind" +== 168 +-- truncate_limit: 100 +REINDEX TABLE concur_reindex_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_tab" +== 169 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_reindex_ind +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_ind" +== 170 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_tab" +== 171 +-- truncate_limit: 100 +-- with start trigger disabled. +ALTER EVENT TRIGGER regress_reindex_start DISABLE +-- +STMT: AlterEventTrigStmt +TRUNCATED: "ALTER EVENT TRIGGER regress_reindex_start DISABLE" +== 172 +-- truncate_limit: 100 +REINDEX INDEX concur_reindex_ind +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX concur_reindex_ind" +== 173 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_reindex_ind +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_ind" +== 174 +-- truncate_limit: 100 +-- without an index +DROP INDEX concur_reindex_ind +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX concur_reindex_ind" +== 175 +-- truncate_limit: 100 +REINDEX TABLE concur_reindex_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_tab" +== 176 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_tab +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_tab" +== 177 +-- truncate_limit: 100 +-- With a Schema +CREATE SCHEMA concur_reindex_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA concur_reindex_schema" +== 178 +-- truncate_limit: 100 +-- No indexes +REINDEX SCHEMA concur_reindex_schema +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX SCHEMA concur_reindex_schema" +== 179 +-- truncate_limit: 100 +REINDEX SCHEMA CONCURRENTLY concur_reindex_schema +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) SCHEMA concur_reindex_schema" +== 180 +-- truncate_limit: 100 +CREATE TABLE concur_reindex_schema.tab (a int) +-- +TABLE: name="concur_reindex_schema.tab" schema="concur_reindex_schema" table="tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_schema.tab (a int)" +== 181 +-- truncate_limit: 100 +CREATE INDEX ind ON concur_reindex_schema.tab (a) +-- +TABLE: name="concur_reindex_schema.tab" schema="concur_reindex_schema" table="tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ind ON concur_reindex_schema.tab USING btree (a)" +== 182 +-- truncate_limit: 100 +-- One index reported +REINDEX SCHEMA concur_reindex_schema +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX SCHEMA concur_reindex_schema" +== 183 +-- truncate_limit: 100 +REINDEX SCHEMA CONCURRENTLY concur_reindex_schema +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) SCHEMA concur_reindex_schema" +== 184 +-- truncate_limit: 100 +-- One table on schema but no indexes +DROP INDEX concur_reindex_schema.ind +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX concur_reindex_schema.ind" +== 185 +-- truncate_limit: 100 +REINDEX SCHEMA concur_reindex_schema +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX SCHEMA concur_reindex_schema" +== 186 +-- truncate_limit: 100 +REINDEX SCHEMA CONCURRENTLY concur_reindex_schema +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) SCHEMA concur_reindex_schema" +== 187 +-- truncate_limit: 100 +DROP SCHEMA concur_reindex_schema CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA concur_reindex_schema CASCADE" +== 188 +-- truncate_limit: 100 +-- With a partitioned table, and nothing else. +CREATE TABLE concur_reindex_part (id int) PARTITION BY RANGE (id) +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_part (id int) PARTITION BY RANGE (id)" +== 189 +-- truncate_limit: 100 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_part" +== 190 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_part" +== 191 +-- truncate_limit: 100 +-- Partition that would be reindexed, still nothing. +CREATE TABLE concur_reindex_child PARTITION OF concur_reindex_part + FOR VALUES FROM (0) TO (10) +-- +TABLE: name="concur_reindex_child" schema="" table="concur_reindex_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE concur_reindex_child PARTITION OF concur_reindex_part FOR VALUES FROM (0) TO (10)" +== 192 +-- truncate_limit: 100 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_part" +== 193 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_part" +== 194 +-- truncate_limit: 100 +-- Now add some indexes. +CREATE INDEX concur_reindex_partidx ON concur_reindex_part (id) +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX concur_reindex_partidx ON concur_reindex_part USING btree (id)" +== 195 +-- truncate_limit: 100 +REINDEX INDEX concur_reindex_partidx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX concur_reindex_partidx" +== 196 +-- truncate_limit: 100 +REINDEX INDEX CONCURRENTLY concur_reindex_partidx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX concur_reindex_partidx" +== 197 +-- truncate_limit: 100 +REINDEX TABLE concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE concur_reindex_part" +== 198 +-- truncate_limit: 100 +REINDEX TABLE CONCURRENTLY concur_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) TABLE concur_reindex_part" +== 199 +-- truncate_limit: 100 +DROP TABLE concur_reindex_part +-- +TABLE: name="concur_reindex_part" schema="" table="concur_reindex_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_reindex_part" +== 200 +-- truncate_limit: 100 +-- Clean up +DROP EVENT TRIGGER regress_reindex_start +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_reindex_start" +== 201 +-- truncate_limit: 100 +DROP EVENT TRIGGER regress_reindex_end +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_reindex_end" +== 202 +-- truncate_limit: 100 +DROP EVENT TRIGGER regress_reindex_end_snap +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER regress_reindex_end_snap" +== 203 +-- truncate_limit: 100 +DROP FUNCTION reindex_end_command() +-- +FUNCTION: name="reindex_end_command" function="reindex_end_command" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION reindex_end_command()" +== 204 +-- truncate_limit: 100 +DROP FUNCTION reindex_end_command_snap() +-- +FUNCTION: name="reindex_end_command_snap" function="reindex_end_command_snap" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION reindex_end_command_snap()" +== 205 +-- truncate_limit: 100 +DROP FUNCTION reindex_start_command() +-- +FUNCTION: name="reindex_start_command" function="reindex_start_command" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION reindex_start_command()" +== 206 +-- truncate_limit: 100 +DROP TABLE concur_reindex_tab +-- +TABLE: name="concur_reindex_tab" schema="" table="concur_reindex_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE concur_reindex_tab" +== 207 +-- truncate_limit: 100 +-- test Row Security Event Trigger +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 208 +-- truncate_limit: 100 +CREATE TABLE event_trigger_test (a integer, b text) +-- +TABLE: name="event_trigger_test" schema="" table="event_trigger_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE event_trigger_test (a int, b text)" +== 209 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION start_command() +RETURNS event_trigger AS $$ +BEGIN +RAISE NOTICE '% - ddl_command_start', tg_tag; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="start_command" function="start_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION start_command() RETURNS event_trigger AS $$\nBEGIN\nRAISE NOTICE '% - dd..." +== 210 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION end_command() +RETURNS event_trigger AS $$ +BEGIN +RAISE NOTICE '% - ddl_command_end', tg_tag; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="end_command" function="end_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION end_command() RETURNS event_trigger AS $$\nBEGIN\nRAISE NOTICE '% - ddl_..." +== 211 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION drop_sql_command() +RETURNS event_trigger AS $$ +BEGIN +RAISE NOTICE '% - sql_drop', tg_tag; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="drop_sql_command" function="drop_sql_command" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION drop_sql_command() RETURNS event_trigger AS $$\nBEGIN\nRAISE NOTICE '% -..." +== 212 +-- truncate_limit: 100 +CREATE EVENT TRIGGER start_rls_command ON ddl_command_start + WHEN TAG IN ('CREATE POLICY', 'ALTER POLICY', 'DROP POLICY') EXECUTE PROCEDURE start_command() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER start_rls_command ON ddl_command_start WHEN tag IN ('CREATE POLICY', 'ALTER ..." +== 213 +-- truncate_limit: 100 +CREATE EVENT TRIGGER end_rls_command ON ddl_command_end + WHEN TAG IN ('CREATE POLICY', 'ALTER POLICY', 'DROP POLICY') EXECUTE PROCEDURE end_command() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER end_rls_command ON ddl_command_end WHEN tag IN ('CREATE POLICY', 'ALTER POLI..." +== 214 +-- truncate_limit: 100 +CREATE EVENT TRIGGER sql_drop_command ON sql_drop + WHEN TAG IN ('DROP POLICY') EXECUTE PROCEDURE drop_sql_command() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER sql_drop_command ON sql_drop WHEN tag IN ('DROP POLICY') EXECUTE FUNCTION dr..." +== 215 +-- truncate_limit: 100 +CREATE POLICY p1 ON event_trigger_test USING (FALSE) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON event_trigger_test TO public USING (false)" +== 216 +-- truncate_limit: 100 +ALTER POLICY p1 ON event_trigger_test USING (TRUE) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY p1 ON event_trigger_test USING (true)" +== 217 +-- truncate_limit: 100 +ALTER POLICY p1 ON event_trigger_test RENAME TO p2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER POLICY p1 ON event_trigger_test RENAME TO p2" +== 218 +-- truncate_limit: 100 +DROP POLICY p2 ON event_trigger_test +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p2 ON event_trigger_test" +== 219 +-- truncate_limit: 100 +-- Check the object addresses of all the event triggers. +SELECT + e.evtname, + pg_describe_object('pg_event_trigger'::regclass, e.oid, 0) as descr, + b.type, b.object_names, b.object_args, + pg_identify_object(a.classid, a.objid, a.objsubid) as ident + FROM pg_event_trigger as e, + LATERAL pg_identify_object_as_address('pg_event_trigger'::regclass, e.oid, 0) as b, + LATERAL pg_get_object_address(b.type, b.object_names, b.object_args) as a + ORDER BY e.evtname +-- +TABLE: name="pg_event_trigger" schema="" table="pg_event_trigger" ctx=Select +ALIAS: "e"="pg_event_trigger" +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object_as_address" function="pg_identify_object_as_address" schema="" ctx=Call +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_event_trigger e, LATERAL pg_identify_object_as_address('pg_event_trigger'::reg..." +== 220 +-- truncate_limit: 100 +DROP EVENT TRIGGER start_rls_command +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER start_rls_command" +== 221 +-- truncate_limit: 100 +DROP EVENT TRIGGER end_rls_command +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER end_rls_command" +== 222 +-- truncate_limit: 100 +DROP EVENT TRIGGER sql_drop_command +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER sql_drop_command" +== 223 +-- truncate_limit: 100 +-- Check the GUC for disabling event triggers +CREATE FUNCTION test_event_trigger_guc() RETURNS event_trigger +LANGUAGE plpgsql AS $$ +DECLARE + obj record; +BEGIN + FOR obj IN SELECT * FROM pg_event_trigger_dropped_objects() + LOOP + RAISE NOTICE '% dropped %', tg_tag, obj.object_type; + END LOOP; +END; +$$ +-- +FUNCTION: name="test_event_trigger_guc" function="test_event_trigger_guc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_event_trigger_guc() RETURNS event_trigger LANGUAGE plpgsql AS $$\nDECLARE\n\tob..." +== 224 +-- truncate_limit: 100 +CREATE EVENT TRIGGER test_event_trigger_guc + ON sql_drop + WHEN TAG IN ('DROP POLICY') EXECUTE FUNCTION test_event_trigger_guc() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER test_event_trigger_guc ON sql_drop WHEN tag IN ('DROP POLICY') EXECUTE FUNCT..." +== 225 +-- truncate_limit: 100 +SET event_triggers = 'on' +-- +STMT: VariableSetStmt +TRUNCATED: "SET event_triggers TO ON" +== 226 +-- truncate_limit: 100 +CREATE POLICY pguc ON event_trigger_test USING (FALSE) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY pguc ON event_trigger_test TO public USING (false)" +== 227 +-- truncate_limit: 100 +DROP POLICY pguc ON event_trigger_test +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY pguc ON event_trigger_test" +== 228 +-- truncate_limit: 100 +CREATE POLICY pguc ON event_trigger_test USING (FALSE) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY pguc ON event_trigger_test TO public USING (false)" +== 229 +-- truncate_limit: 100 +SET event_triggers = 'off' +-- +STMT: VariableSetStmt +TRUNCATED: "SET event_triggers TO OFF" +== 230 +-- truncate_limit: 100 +DROP POLICY pguc ON event_trigger_test +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY pguc ON event_trigger_test" diff --git a/parser/testdata/summary_truncate/postgres_regress/event_trigger_login.metadata.json b/parser/testdata/summary_truncate/postgres_regress/event_trigger_login.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/event_trigger_login.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/event_trigger_login.test b/parser/testdata/summary_truncate/postgres_regress/event_trigger_login.test new file mode 100644 index 0000000..0941ee7 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/event_trigger_login.test @@ -0,0 +1,85 @@ +== 001 +-- truncate_limit: 100 +-- Login event triggers +CREATE TABLE user_logins(id serial, who text) +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE user_logins (id serial, who text)" +== 002 +-- truncate_limit: 100 +GRANT SELECT ON user_logins TO public +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON user_logins TO public" +== 003 +-- truncate_limit: 100 +CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$ +BEGIN + INSERT INTO user_logins (who) VALUES (SESSION_USER); + RAISE NOTICE 'You are welcome!'; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="on_login_proc" function="on_login_proc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION on_login_proc() RETURNS event_trigger AS $$\nBEGIN\n INSERT INTO user_logins (who)..." +== 004 +-- truncate_limit: 100 +CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE PROCEDURE on_login_proc() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER on_login_trigger ON login EXECUTE FUNCTION on_login_proc()" +== 005 +-- truncate_limit: 100 +ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS +-- +STMT: AlterEventTrigStmt +TRUNCATED: "ALTER EVENT TRIGGER on_login_trigger ENABLE ALWAYS" +== 006 +-- truncate_limit: 100 +SELECT COUNT(*) FROM user_logins +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM user_logins" +== 007 +-- truncate_limit: 100 +SELECT COUNT(*) FROM user_logins +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM user_logins" +== 008 +-- truncate_limit: 100 +-- Check dathasloginevt in system catalog +SELECT dathasloginevt FROM pg_database WHERE datname= :'DBNAME' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 97 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- truncate_limit: 100 +-- Cleanup +DROP TABLE user_logins +-- +TABLE: name="user_logins" schema="" table="user_logins" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE user_logins" +== 010 +-- truncate_limit: 100 +DROP EVENT TRIGGER on_login_trigger +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER on_login_trigger" +== 011 +-- truncate_limit: 100 +DROP FUNCTION on_login_proc() +-- +FUNCTION: name="on_login_proc" function="on_login_proc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION on_login_proc()" diff --git a/parser/testdata/summary_truncate/postgres_regress/explain.metadata.json b/parser/testdata/summary_truncate/postgres_regress/explain.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/explain.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/explain.test b/parser/testdata/summary_truncate/postgres_regress/explain.test new file mode 100644 index 0000000..05561eb --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/explain.test @@ -0,0 +1,450 @@ +== 001 +-- truncate_limit: 100 +|-- +-- EXPLAIN +|-- +-- There are many test cases elsewhere that use EXPLAIN as a vehicle for +-- checking something else (usually planner behavior). This file is +-- concerned with testing EXPLAIN in its own right. +|-- + +-- To produce stable regression test output, it's usually necessary to +-- ignore details such as exact costs or row counts. These filter +-- functions replace changeable output details with fixed strings. + +create function explain_filter(text) returns setof text +language plpgsql as +$$ +declare + ln text; +begin + for ln in execute $1 + loop + -- Replace any numeric word with just 'N' + ln := regexp_replace(ln, '-?\m\d+\M', 'N', 'g'); + -- In sort output, the above won't match units-suffixed numbers + ln := regexp_replace(ln, '\m\d+kB', 'NkB', 'g'); + -- Ignore text-mode buffers output because it varies depending + -- on the system state + CONTINUE WHEN (ln ~ ' +Buffers: .*'); + -- Ignore text-mode "Planning:" line because whether it's output + -- varies depending on the system state + CONTINUE WHEN (ln = 'Planning:'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION explain_filter(text) RETURNS SETOF text LANGUAGE plpgsql AS $$\ndeclare\n ln tex..." +== 002 +-- truncate_limit: 100 +-- To produce valid JSON output, replace numbers with "0" or "0.0" not "N" +create function explain_filter_to_json(text) returns jsonb +language plpgsql as +$$ +declare + data text := ''; + ln text; +begin + for ln in execute $1 + loop + -- Replace any numeric word with just '0' + ln := regexp_replace(ln, '\m\d+\M', '0', 'g'); + data := data || ln; + end loop; + return data::jsonb; +end; +$$ +-- +FUNCTION: name="explain_filter_to_json" function="explain_filter_to_json" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION explain_filter_to_json(text) RETURNS jsonb LANGUAGE plpgsql AS $$\ndeclare\n dat..." +== 003 +-- truncate_limit: 100 +-- Disable JIT, or we'll get different output on machines where that's been +-- forced on +set jit = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit TO OFF" +== 004 +-- truncate_limit: 100 +-- Similarly, disable track_io_timing, to avoid output differences when +-- enabled. +set track_io_timing = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET track_io_timing TO OFF" +== 005 +-- truncate_limit: 100 +-- Simple cases + +select explain_filter('explain select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain select * from int8_tbl i8')" +== 006 +-- truncate_limit: 100 +select explain_filter('explain (analyze) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (analyze) select * from int8_tbl i8')" +== 007 +-- truncate_limit: 100 +select explain_filter('explain (analyze, verbose) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (analyze, verbose) select * from int8_tbl i8')" +== 008 +-- truncate_limit: 100 +select explain_filter('explain (analyze, buffers, format text) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (analyze, buffers, format text) select * from int8_tbl i8')" +== 009 +-- truncate_limit: 100 +select explain_filter('explain (analyze, buffers, format xml) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (analyze, buffers, format xml) select * from int8_tbl i8')" +== 010 +-- truncate_limit: 100 +select explain_filter('explain (analyze, serialize, buffers, format yaml) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 011 +-- truncate_limit: 100 +select explain_filter('explain (buffers, format text) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (buffers, format text) select * from int8_tbl i8')" +== 012 +-- truncate_limit: 100 +select explain_filter('explain (buffers, format json) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (buffers, format json) select * from int8_tbl i8')" +== 013 +-- truncate_limit: 100 +-- Check output including I/O timings. These fields are conditional +-- but always set in JSON format, so check them only in this case. +set track_io_timing = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET track_io_timing TO ON" +== 014 +-- truncate_limit: 100 +select explain_filter('explain (analyze, buffers, format json) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (analyze, buffers, format json) select * from int8_tbl i8')" +== 015 +-- truncate_limit: 100 +set track_io_timing = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET track_io_timing TO OFF" +== 016 +-- truncate_limit: 100 +-- SETTINGS option +-- We have to ignore other settings that might be imposed by the environment, +-- so printing the whole Settings field unfortunately won't do. + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 017 +-- truncate_limit: 100 +set local plan_cache_mode = force_generic_plan +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL plan_cache_mode TO force_generic_plan" +== 018 +-- truncate_limit: 100 +select true as "OK" + from explain_filter('explain (settings) select * from int8_tbl i8') ln + where ln ~ '^ *Settings: .*plan_cache_mode = ''force_generic_plan''' +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +FILTER: schema="" table="" column="ln" +STMT: SelectStmt +TRUNCATED: "SELECT true AS \"OK\" FROM explain_filter('explain (settings) select * from int8_tbl i8') ln WHERE ..." +== 019 +-- truncate_limit: 100 +select explain_filter_to_json('explain (settings, format json) select * from int8_tbl i8') #> '{0,Settings,plan_cache_mode}' +-- +FUNCTION: name="explain_filter_to_json" function="explain_filter_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 020 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 021 +-- truncate_limit: 100 +-- GENERIC_PLAN option + +select explain_filter('explain (generic_plan) select unique1 from tenk1 where thousand = $1') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (generic_plan) select unique1 from tenk1 where thousand = $1')" +== 022 +-- truncate_limit: 100 +-- should fail +select explain_filter('explain (analyze, generic_plan) select unique1 from tenk1 where thousand = $1') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 023 +-- truncate_limit: 100 +-- MEMORY option +select explain_filter('explain (memory) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (memory) select * from int8_tbl i8')" +== 024 +-- truncate_limit: 100 +select explain_filter('explain (memory, analyze) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (memory, analyze) select * from int8_tbl i8')" +== 025 +-- truncate_limit: 100 +select explain_filter('explain (memory, summary, format yaml) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (memory, summary, format yaml) select * from int8_tbl i8')" +== 026 +-- truncate_limit: 100 +select explain_filter('explain (memory, analyze, format json) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (memory, analyze, format json) select * from int8_tbl i8')" +== 027 +-- truncate_limit: 100 +prepare int8_query as select * from int8_tbl i8 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE int8_query AS SELECT * FROM int8_tbl i8" +== 028 +-- truncate_limit: 100 +select explain_filter('explain (memory) execute int8_query') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (memory) execute int8_query')" +== 029 +-- truncate_limit: 100 +-- Test EXPLAIN (GENERIC_PLAN) with partition pruning +-- partitions should be pruned at plan time, based on constants, +-- but there should be no pruning based on parameter placeholders +create table gen_part ( + key1 integer not null, + key2 integer not null +) partition by list (key1) +-- +TABLE: name="gen_part" schema="" table="gen_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gen_part (key1 int NOT NULL, key2 int NOT NULL) PARTITION BY LIST (key1)" +== 030 +-- truncate_limit: 100 +create table gen_part_1 + partition of gen_part for values in (1) + partition by range (key2) +-- +TABLE: name="gen_part_1" schema="" table="gen_part_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gen_part_1 PARTITION OF gen_part FOR VALUES IN (1) PARTITION BY RANGE (key2)" +== 031 +-- truncate_limit: 100 +create table gen_part_1_1 + partition of gen_part_1 for values from (1) to (2) +-- +TABLE: name="gen_part_1_1" schema="" table="gen_part_1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gen_part_1_1 PARTITION OF gen_part_1 FOR VALUES FROM (1) TO (2)" +== 032 +-- truncate_limit: 100 +create table gen_part_1_2 + partition of gen_part_1 for values from (2) to (3) +-- +TABLE: name="gen_part_1_2" schema="" table="gen_part_1_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gen_part_1_2 PARTITION OF gen_part_1 FOR VALUES FROM (2) TO (3)" +== 033 +-- truncate_limit: 100 +create table gen_part_2 + partition of gen_part for values in (2) +-- +TABLE: name="gen_part_2" schema="" table="gen_part_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gen_part_2 PARTITION OF gen_part FOR VALUES IN (2)" +== 034 +-- truncate_limit: 100 +-- should scan gen_part_1_1 and gen_part_1_2, but not gen_part_2 +select explain_filter('explain (generic_plan) select key1, key2 from gen_part where key1 = 1 and key2 = $1') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 035 +-- truncate_limit: 100 +drop table gen_part +-- +TABLE: name="gen_part" schema="" table="gen_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gen_part" +== 036 +-- truncate_limit: 100 +|-- +-- Test production of per-worker data +|-- +-- Unfortunately, because we don't know how many worker processes we'll +-- actually get (maybe none at all), we can't examine the "Workers" output +-- in any detail. We can check that it parses correctly as JSON, and then +-- remove it from the displayed results. + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 037 +-- truncate_limit: 100 +-- encourage use of parallel plans +set parallel_setup_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 038 +-- truncate_limit: 100 +set parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 039 +-- truncate_limit: 100 +set min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 040 +-- truncate_limit: 100 +set max_parallel_workers_per_gather=4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 4" +== 041 +-- truncate_limit: 100 +select jsonb_pretty( + explain_filter_to_json('explain (analyze, verbose, buffers, format json) + select * from tenk1 order by tenthous') + -- remove "Workers" node of the Seq Scan plan node + #- '{0,Plan,Plans,0,Plans,0,Workers}' + -- remove "Workers" node of the Sort plan node + #- '{0,Plan,Plans,0,Workers}' + -- Also remove its sort-type fields, as those aren't 100% stable + #- '{0,Plan,Plans,0,Sort Method}' + #- '{0,Plan,Plans,0,Sort Space Type}' +) +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +FUNCTION: name="explain_filter_to_json" function="explain_filter_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 042 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 043 +-- truncate_limit: 100 +-- Test display of temporary objects +create temp table t1(f1 float8) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (f1 float8)" +== 044 +-- truncate_limit: 100 +create function pg_temp.mysin(float8) returns float8 language plpgsql +as 'begin return sin($1); end' +-- +FUNCTION: name="pg_temp.mysin" function="mysin" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION pg_temp.mysin(float8) RETURNS float8 LANGUAGE plpgsql AS $$begin return sin($1); ..." +== 045 +-- truncate_limit: 100 +select explain_filter('explain (verbose) select * from t1 where pg_temp.mysin(f1) < 0.5') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (verbose) select * from t1 where pg_temp.mysin(f1) < 0.5')" +== 046 +-- truncate_limit: 100 +-- Test compute_query_id +set compute_query_id = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET compute_query_id TO ON" +== 047 +-- truncate_limit: 100 +select explain_filter('explain (verbose) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (verbose) select * from int8_tbl i8')" +== 048 +-- truncate_limit: 100 +-- Test SERIALIZE option +select explain_filter('explain (analyze,serialize) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (analyze,serialize) select * from int8_tbl i8')" +== 049 +-- truncate_limit: 100 +select explain_filter('explain (analyze,serialize text,buffers,timing off) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 050 +-- truncate_limit: 100 +select explain_filter('explain (analyze,serialize binary,buffers,timing) select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_filter('explain (analyze,serialize binary,buffers,timing) select * from int8_tbl i8')" +== 051 +-- truncate_limit: 100 +-- this tests an edge case where we have no data to return +select explain_filter('explain (analyze,serialize) create temp table explain_temp as select * from int8_tbl i8') +-- +FUNCTION: name="explain_filter" function="explain_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." diff --git a/parser/testdata/summary_truncate/postgres_regress/expressions.metadata.json b/parser/testdata/summary_truncate/postgres_regress/expressions.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/expressions.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/expressions.test b/parser/testdata/summary_truncate/postgres_regress/expressions.test new file mode 100644 index 0000000..2a5aa3f --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/expressions.test @@ -0,0 +1,594 @@ +== 001 +-- truncate_limit: 100 +|-- +-- expression evaluation tests that don't fit into a more specific file +|-- + +|-- +-- Tests for SQLValueFunction +|-- + + +-- current_date (always matches because of transactional behaviour) +SELECT date(now())::text = current_date::text +-- +FUNCTION: name="date" function="date" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date(now())::text = current_date::text" +== 002 +-- truncate_limit: 100 +-- current_time / localtime +SELECT now()::timetz::text = current_time::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT now()::timetz::text = current_time::text" +== 003 +-- truncate_limit: 100 +SELECT now()::timetz(4)::text = current_time(4)::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT now()::timetz(4)::text = current_time(4)::text" +== 004 +-- truncate_limit: 100 +SELECT now()::time::text = localtime::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT now()::time::text = localtime::text" +== 005 +-- truncate_limit: 100 +SELECT now()::time(3)::text = localtime(3)::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT now()::time(3)::text = localtime(3)::text" +== 006 +-- truncate_limit: 100 +-- current_time[stamp]/ localtime[stamp] (always matches because of transactional behaviour) +SELECT current_timestamp = NOW() +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_timestamp = now()" +== 007 +-- truncate_limit: 100 +-- precision +SELECT length(current_timestamp::text) >= length(current_timestamp(0)::text) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(current_timestamp::text) >= length(current_timestamp(0)::text)" +== 008 +-- truncate_limit: 100 +-- localtimestamp +SELECT now()::timestamp::text = localtimestamp::text +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT now()::timestamp::text = localtimestamp::text" +== 009 +-- truncate_limit: 100 +-- precision overflow +SELECT current_time = current_time(7) +-- +STMT: SelectStmt +TRUNCATED: "SELECT current_time = current_time(7)" +== 010 +-- truncate_limit: 100 +SELECT current_timestamp = current_timestamp(7) +-- +STMT: SelectStmt +TRUNCATED: "SELECT current_timestamp = current_timestamp(7)" +== 011 +-- truncate_limit: 100 +SELECT localtime = localtime(7) +-- +STMT: SelectStmt +TRUNCATED: "SELECT localtime = localtime(7)" +== 012 +-- truncate_limit: 100 +SELECT localtimestamp = localtimestamp(7) +-- +STMT: SelectStmt +TRUNCATED: "SELECT localtimestamp = localtimestamp(7)" +== 013 +-- truncate_limit: 100 +-- current_role/user/user is tested in rolenames.sql + +-- current database / catalog +SELECT current_catalog = current_database() +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_catalog = current_database()" +== 014 +-- truncate_limit: 100 +-- current_schema +SELECT current_schema +-- +STMT: SelectStmt +TRUNCATED: "SELECT current_schema" +== 015 +-- truncate_limit: 100 +SET search_path = 'notme' +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO notme" +== 016 +-- truncate_limit: 100 +SELECT current_schema +-- +STMT: SelectStmt +TRUNCATED: "SELECT current_schema" +== 017 +-- truncate_limit: 100 +SET search_path = 'pg_catalog' +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO pg_catalog" +== 018 +-- truncate_limit: 100 +SELECT current_schema +-- +STMT: SelectStmt +TRUNCATED: "SELECT current_schema" +== 019 +-- truncate_limit: 100 +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 020 +-- truncate_limit: 100 +|-- +-- Test parsing of a no-op cast to a type with unspecified typmod +|-- +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 021 +-- truncate_limit: 100 +create table numeric_tbl (f1 numeric(18,3), f2 numeric) +-- +TABLE: name="numeric_tbl" schema="" table="numeric_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE numeric_tbl (f1 numeric(18, 3), f2 numeric)" +== 022 +-- truncate_limit: 100 +create view numeric_view as + select + f1, f1::numeric(16,4) as f1164, f1::numeric as f1n, + f2, f2::numeric(16,4) as f2164, f2::numeric as f2n + from numeric_tbl +-- +TABLE: name="numeric_view" schema="" table="numeric_view" ctx=DDL +TABLE: name="numeric_tbl" schema="" table="numeric_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW numeric_view AS SELECT f1, f1::numeric(16, 4) AS f1164, f1::numeric AS f1n, f2, f2::n..." +== 023 +-- truncate_limit: 100 +explain (verbose, costs off) select * from numeric_view +-- +TABLE: name="numeric_view" schema="" table="numeric_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM numeric_view" +== 024 +-- truncate_limit: 100 +-- bpchar, lacking planner support for its length coercion function, +-- could behave differently + +create table bpchar_tbl (f1 character(16) unique, f2 bpchar) +-- +TABLE: name="bpchar_tbl" schema="" table="bpchar_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bpchar_tbl (f1 char(16) UNIQUE, f2 bpchar)" +== 025 +-- truncate_limit: 100 +create view bpchar_view as + select + f1, f1::character(14) as f114, f1::bpchar as f1n, + f2, f2::character(14) as f214, f2::bpchar as f2n + from bpchar_tbl +-- +TABLE: name="bpchar_view" schema="" table="bpchar_view" ctx=DDL +TABLE: name="bpchar_tbl" schema="" table="bpchar_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW bpchar_view AS SELECT f1, f1::char(14) AS f114, f1::bpchar AS f1n, f2, f2::char(14) A..." +== 026 +-- truncate_limit: 100 +explain (verbose, costs off) select * from bpchar_view + where f1::bpchar = 'foo' +-- +TABLE: name="bpchar_view" schema="" table="bpchar_view" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM bpchar_view WHERE f1::bpchar = 'foo'" +== 027 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 028 +-- truncate_limit: 100 +|-- +-- Ordinarily, IN/NOT IN can be converted to a ScalarArrayOpExpr +-- with a suitably-chosen array type. +|-- +explain (verbose, costs off) +select random() IN (1, 4, 8.0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT random() IN (1, 4, 8.0)" +== 029 +-- truncate_limit: 100 +explain (verbose, costs off) +select random()::int IN (1, 4, 8.0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT random()::int IN (1, 4, 8.0)" +== 030 +-- truncate_limit: 100 +-- However, if there's not a common supertype for the IN elements, +-- we should instead try to produce "x = v1 OR x = v2 OR ...". +-- In most cases that'll fail for lack of all the requisite = operators, +-- but it can succeed sometimes. So this should complain about lack of +-- an = operator, not about cast failure. +select '(0,0)'::point in ('(0,0,0,0)'::box, point(0,0)) +-- +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '(0,0)'::point IN ('(0,0,0,0)'::box, point(0, 0))" +== 031 +-- truncate_limit: 100 +|-- +-- Tests for ScalarArrayOpExpr with a hashfn +|-- + +-- create a stable function so that the tests below are not +-- evaluated using the planner's constant folding. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 032 +-- truncate_limit: 100 +create function return_int_input(int) returns int as $$ +begin + return $1; +end; +$$ language plpgsql stable +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION return_int_input(int) RETURNS int AS $$\nbegin\n\treturn $1;\nend;\n$$ LANGUAGE plpgsq..." +== 033 +-- truncate_limit: 100 +create function return_text_input(text) returns text as $$ +begin + return $1; +end; +$$ language plpgsql stable +-- +FUNCTION: name="return_text_input" function="return_text_input" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION return_text_input(text) RETURNS text AS $$\nbegin\n\treturn $1;\nend;\n$$ LANGUAGE plp..." +== 034 +-- truncate_limit: 100 +select return_int_input(1) in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) IN (10, 9, 2, 8, 3, 7, 4, 6, 5, 1)" +== 035 +-- truncate_limit: 100 +select return_int_input(1) in (10, 9, 2, 8, 3, 7, 4, 6, 5, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) IN (10, 9, 2, 8, 3, 7, 4, 6, 5, NULL)" +== 036 +-- truncate_limit: 100 +select return_int_input(1) in (null, null, null, null, null, null, null, null, null, null, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) IN (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)" +== 037 +-- truncate_limit: 100 +select return_int_input(1) in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) IN (10, 9, 2, 8, 3, 7, 4, 6, 5, 1, NULL)" +== 038 +-- truncate_limit: 100 +select return_int_input(null::int) in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(NULL::int) IN (10, 9, 2, 8, 3, 7, 4, 6, 5, 1)" +== 039 +-- truncate_limit: 100 +select return_int_input(null::int) in (10, 9, 2, 8, 3, 7, 4, 6, 5, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(NULL::int) IN (10, 9, 2, 8, 3, 7, 4, 6, 5, NULL)" +== 040 +-- truncate_limit: 100 +select return_text_input('a') in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j') +-- +FUNCTION: name="return_text_input" function="return_text_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_text_input('a') IN ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')" +== 041 +-- truncate_limit: 100 +-- NOT IN +select return_int_input(1) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) NOT IN (10, 9, 2, 8, 3, 7, 4, 6, 5, 1)" +== 042 +-- truncate_limit: 100 +select return_int_input(1) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 0) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) NOT IN (10, 9, 2, 8, 3, 7, 4, 6, 5, 0)" +== 043 +-- truncate_limit: 100 +select return_int_input(1) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 2, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) NOT IN (10, 9, 2, 8, 3, 7, 4, 6, 5, 2, NULL)" +== 044 +-- truncate_limit: 100 +select return_int_input(1) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) NOT IN (10, 9, 2, 8, 3, 7, 4, 6, 5, 1, NULL)" +== 045 +-- truncate_limit: 100 +select return_int_input(1) not in (null, null, null, null, null, null, null, null, null, null, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(1) NOT IN (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)" +== 046 +-- truncate_limit: 100 +select return_int_input(null::int) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, 1) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(NULL::int) NOT IN (10, 9, 2, 8, 3, 7, 4, 6, 5, 1)" +== 047 +-- truncate_limit: 100 +select return_int_input(null::int) not in (10, 9, 2, 8, 3, 7, 4, 6, 5, null) +-- +FUNCTION: name="return_int_input" function="return_int_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_int_input(NULL::int) NOT IN (10, 9, 2, 8, 3, 7, 4, 6, 5, NULL)" +== 048 +-- truncate_limit: 100 +select return_text_input('a') not in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j') +-- +FUNCTION: name="return_text_input" function="return_text_input" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT return_text_input('a') NOT IN ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')" +== 049 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 050 +-- truncate_limit: 100 +-- Test with non-strict equality function. +-- We need to create our own type for this. + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 051 +-- truncate_limit: 100 +create type myint +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE myint" +== 052 +-- truncate_limit: 100 +create function myintin(cstring) returns myint strict immutable language + internal as 'int4in' +-- +FUNCTION: name="myintin" function="myintin" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myintin(cstring) RETURNS myint RETURNS NULL ON NULL INPUT IMMUTABLE LANGUAGE inte..." +== 053 +-- truncate_limit: 100 +create function myintout(myint) returns cstring strict immutable language + internal as 'int4out' +-- +FUNCTION: name="myintout" function="myintout" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myintout(myint) RETURNS cstring RETURNS NULL ON NULL INPUT IMMUTABLE LANGUAGE int..." +== 054 +-- truncate_limit: 100 +create function myinthash(myint) returns integer strict immutable language + internal as 'hashint4' +-- +FUNCTION: name="myinthash" function="myinthash" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myinthash(myint) RETURNS int RETURNS NULL ON NULL INPUT IMMUTABLE LANGUAGE intern..." +== 055 +-- truncate_limit: 100 +create type myint (input = myintin, output = myintout, like = int4) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE myint (input = myintin, output = myintout, \"like\" = int4)" +== 056 +-- truncate_limit: 100 +create cast (int4 as myint) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int4 AS myint) WITHOUT FUNCTION" +== 057 +-- truncate_limit: 100 +create cast (myint as int4) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (myint AS int4) WITHOUT FUNCTION" +== 058 +-- truncate_limit: 100 +create function myinteq(myint, myint) returns bool as $$ +begin + if $1 is null and $2 is null then + return true; + else + return $1::int = $2::int; + end if; +end; +$$ language plpgsql immutable +-- +FUNCTION: name="myinteq" function="myinteq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myinteq(myint, myint) RETURNS bool AS $$\nbegin\n if $1 is null and $2 is null the..." +== 059 +-- truncate_limit: 100 +create function myintne(myint, myint) returns bool as $$ +begin + return not myinteq($1, $2); +end; +$$ language plpgsql immutable +-- +FUNCTION: name="myintne" function="myintne" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myintne(myint, myint) RETURNS bool AS $$\nbegin\n return not myinteq($1, $2);\nend;..." +== 060 +-- truncate_limit: 100 +create operator = ( + leftarg = myint, + rightarg = myint, + commutator = =, + negator = <>, + procedure = myinteq, + restrict = eqsel, + join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR = (leftarg = myint, rightarg = myint, commutator = =, negator = <>, procedure = m..." +== 061 +-- truncate_limit: 100 +create operator <> ( + leftarg = myint, + rightarg = myint, + commutator = <>, + negator = =, + procedure = myintne, + restrict = eqsel, + join = eqjoinsel, + merges +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR <> (leftarg = myint, rightarg = myint, commutator = <>, negator = =, procedure = ..." +== 062 +-- truncate_limit: 100 +create operator class myint_ops +default for type myint using hash as + operator 1 = (myint, myint), + function 1 myinthash(myint) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS myint_ops DEFAULT FOR TYPE myint USING hash AS OPERATOR 1 =(myint, myint), ..." +== 063 +-- truncate_limit: 100 +create table inttest (a myint) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inttest (a myint)" +== 064 +-- truncate_limit: 100 +insert into inttest values(1::myint),(null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inttest VALUES (1::myint), (NULL)" +== 065 +-- truncate_limit: 100 +-- try an array with enough elements to cause hashing +select * from inttest where a in (1::myint,2::myint,3::myint,4::myint,5::myint,6::myint,7::myint,8::myint,9::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inttest WHERE ..." +== 066 +-- truncate_limit: 100 +select * from inttest where a not in (1::myint,2::myint,3::myint,4::myint,5::myint,6::myint,7::myint,8::myint,9::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inttest WHERE ..." +== 067 +-- truncate_limit: 100 +select * from inttest where a not in (0::myint,2::myint,3::myint,4::myint,5::myint,6::myint,7::myint,8::myint,9::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inttest WHERE ..." +== 068 +-- truncate_limit: 100 +-- ensure the result matched with the non-hashed version. We simply remove +-- some array elements so that we don't reach the hashing threshold. +select * from inttest where a in (1::myint,2::myint,3::myint,4::myint,5::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inttest WHERE a IN (1::myint, 2::myint, 3::myint, 4::myint, 5::myint, NULL)" +== 069 +-- truncate_limit: 100 +select * from inttest where a not in (1::myint,2::myint,3::myint,4::myint,5::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inttest WHERE a NOT IN (1::myint, 2::myint, 3::myint, 4::myint, 5::myint, NULL)" +== 070 +-- truncate_limit: 100 +select * from inttest where a not in (0::myint,2::myint,3::myint,4::myint,5::myint, null) +-- +TABLE: name="inttest" schema="" table="inttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inttest WHERE a NOT IN (0::myint, 2::myint, 3::myint, 4::myint, 5::myint, NULL)" +== 071 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" diff --git a/parser/testdata/summary_truncate/postgres_regress/fast_default.metadata.json b/parser/testdata/summary_truncate/postgres_regress/fast_default.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/fast_default.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/fast_default.test b/parser/testdata/summary_truncate/postgres_regress/fast_default.test new file mode 100644 index 0000000..9b304b8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/fast_default.test @@ -0,0 +1,2155 @@ +== 001 +-- truncate_limit: 100 +|-- +-- ALTER TABLE ADD COLUMN DEFAULT test +|-- + +SET search_path = fast_default +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO fast_default" +== 002 +-- truncate_limit: 100 +CREATE SCHEMA fast_default +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fast_default" +== 003 +-- truncate_limit: 100 +CREATE TABLE m(id OID) +-- +TABLE: name="m" schema="" table="m" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE m (id oid)" +== 004 +-- truncate_limit: 100 +INSERT INTO m VALUES (NULL::OID) +-- +TABLE: name="m" schema="" table="m" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO m VALUES (NULL::oid)" +== 005 +-- truncate_limit: 100 +CREATE FUNCTION set(tabname name) RETURNS VOID +AS $$ +BEGIN + UPDATE m + SET id = (SELECT c.relfilenode + FROM pg_class AS c, pg_namespace AS s + WHERE c.relname = tabname + AND c.relnamespace = s.oid + AND s.nspname = 'fast_default'); +END; +$$ LANGUAGE 'plpgsql' +-- +FUNCTION: name="set" function="set" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION set(tabname name) RETURNS void AS $$\nBEGIN\n UPDATE m\n SET id = (SELECT c.relfil..." +== 006 +-- truncate_limit: 100 +CREATE FUNCTION comp() RETURNS TEXT +AS $$ +BEGIN + RETURN (SELECT CASE + WHEN m.id = c.relfilenode THEN 'Unchanged' + ELSE 'Rewritten' + END + FROM m, pg_class AS c, pg_namespace AS s + WHERE c.relname = 't' + AND c.relnamespace = s.oid + AND s.nspname = 'fast_default'); +END; +$$ LANGUAGE 'plpgsql' +-- +FUNCTION: name="comp" function="comp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION comp() RETURNS text AS $$\nBEGIN\n RETURN (SELECT CASE\n WHEN m.id = ..." +== 007 +-- truncate_limit: 100 +CREATE FUNCTION log_rewrite() RETURNS event_trigger +LANGUAGE plpgsql as +$func$ + +declare + this_schema text; +begin + select into this_schema relnamespace::regnamespace::text + from pg_class + where oid = pg_event_trigger_table_rewrite_oid(); + if this_schema = 'fast_default' + then + RAISE NOTICE 'rewriting table % for reason %', + pg_event_trigger_table_rewrite_oid()::regclass, + pg_event_trigger_table_rewrite_reason(); + end if; +end; +$func$ +-- +FUNCTION: name="log_rewrite" function="log_rewrite" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION log_rewrite() RETURNS event_trigger LANGUAGE plpgsql AS $$\n\ndeclare\n this_schem..." +== 008 +-- truncate_limit: 100 +CREATE TABLE has_volatile AS +SELECT * FROM generate_series(1,10) id +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE has_volatile AS SELECT * FROM generate_series(1, 10) id" +== 009 +-- truncate_limit: 100 +CREATE EVENT TRIGGER has_volatile_rewrite + ON table_rewrite + EXECUTE PROCEDURE log_rewrite() +-- +STMT: CreateEventTrigStmt +TRUNCATED: "CREATE EVENT TRIGGER has_volatile_rewrite ON table_rewrite EXECUTE FUNCTION log_rewrite()" +== 010 +-- truncate_limit: 100 +-- only the last of these should trigger a rewrite +ALTER TABLE has_volatile ADD col1 int +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE has_volatile ADD COLUMN col1 int" +== 011 +-- truncate_limit: 100 +ALTER TABLE has_volatile ADD col2 int DEFAULT 1 +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE has_volatile ADD COLUMN col2 int DEFAULT 1" +== 012 +-- truncate_limit: 100 +ALTER TABLE has_volatile ADD col3 timestamptz DEFAULT current_timestamp +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE has_volatile ADD COLUMN col3 timestamptz DEFAULT current_timestamp" +== 013 +-- truncate_limit: 100 +ALTER TABLE has_volatile ADD col4 int DEFAULT (random() * 10000)::int +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE has_volatile ADD COLUMN col4 int DEFAULT ((random() * 10000)::int)" +== 014 +-- truncate_limit: 100 +-- Test a large sample of different datatypes +CREATE TABLE T(pk INT NOT NULL PRIMARY KEY, c_int INT DEFAULT 1) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (pk int NOT NULL PRIMARY KEY, c_int int DEFAULT 1)" +== 015 +-- truncate_limit: 100 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set('t')" +== 016 +-- truncate_limit: 100 +INSERT INTO T VALUES (1), (2) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1), (2)" +== 017 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_bpchar BPCHAR(5) DEFAULT 'hello', + ALTER COLUMN c_int SET DEFAULT 2 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_bpchar bpchar(5) DEFAULT 'hello', ALTER COLUMN c_int SET DEFAULT 2" +== 018 +-- truncate_limit: 100 +INSERT INTO T VALUES (3), (4) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (3), (4)" +== 019 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT 'world', + ALTER COLUMN c_bpchar SET DEFAULT 'dog' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_text text DEFAULT 'world', ALTER COLUMN c_bpchar SET DEFAULT 'dog'" +== 020 +-- truncate_limit: 100 +INSERT INTO T VALUES (5), (6) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (5), (6)" +== 021 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_date DATE DEFAULT '2016-06-02', + ALTER COLUMN c_text SET DEFAULT 'cat' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_date date DEFAULT '2016-06-02', ALTER COLUMN c_text SET DEFAULT 'cat'" +== 022 +-- truncate_limit: 100 +INSERT INTO T VALUES (7), (8) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (7), (8)" +== 023 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_timestamp TIMESTAMP DEFAULT '2016-09-01 12:00:00', + ADD COLUMN c_timestamp_null TIMESTAMP, + ALTER COLUMN c_date SET DEFAULT '2010-01-01' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_timestamp timestamp DEFAULT '2016-09-01 12:00:00', ADD COLUMN c_timest..." +== 024 +-- truncate_limit: 100 +INSERT INTO T VALUES (9), (10) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (9), (10)" +== 025 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_array TEXT[] + DEFAULT '{"This", "is", "the", "real", "world"}', + ALTER COLUMN c_timestamp SET DEFAULT '1970-12-31 11:12:13', + ALTER COLUMN c_timestamp_null SET DEFAULT '2016-09-29 12:00:00' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_array text[] DEFAULT '{\"This\", \"is\", \"the\", \"real\", \"world\"}', ALTER C..." +== 026 +-- truncate_limit: 100 +INSERT INTO T VALUES (11), (12) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (11), (12)" +== 027 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_small SMALLINT DEFAULT -5, + ADD COLUMN c_small_null SMALLINT, + ALTER COLUMN c_array + SET DEFAULT '{"This", "is", "no", "fantasy"}' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_small smallint DEFAULT -5, ADD COLUMN c_small_null smallint, ALTER COL..." +== 028 +-- truncate_limit: 100 +INSERT INTO T VALUES (13), (14) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (13), (14)" +== 029 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_big BIGINT DEFAULT 180000000000018, + ALTER COLUMN c_small SET DEFAULT 9, + ALTER COLUMN c_small_null SET DEFAULT 13 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_big bigint DEFAULT 180000000000018, ALTER COLUMN c_small SET DEFAULT 9..." +== 030 +-- truncate_limit: 100 +INSERT INTO T VALUES (15), (16) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (15), (16)" +== 031 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_num NUMERIC DEFAULT 1.00000000001, + ALTER COLUMN c_big SET DEFAULT -9999999999999999 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_num numeric DEFAULT 1.00000000001, ALTER COLUMN c_big SET DEFAULT -999..." +== 032 +-- truncate_limit: 100 +INSERT INTO T VALUES (17), (18) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (17), (18)" +== 033 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_time TIME DEFAULT '12:00:00', + ALTER COLUMN c_num SET DEFAULT 2.000000000000002 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_time time DEFAULT '12:00:00', ALTER COLUMN c_num SET DEFAULT 2.0000000..." +== 034 +-- truncate_limit: 100 +INSERT INTO T VALUES (19), (20) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (19), (20)" +== 035 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_interval INTERVAL DEFAULT '1 day', + ALTER COLUMN c_time SET DEFAULT '23:59:59' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_interval interval DEFAULT '1 day', ALTER COLUMN c_time SET DEFAULT '23..." +== 036 +-- truncate_limit: 100 +INSERT INTO T VALUES (21), (22) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (21), (22)" +== 037 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_hugetext TEXT DEFAULT repeat('abcdefg',1000), + ALTER COLUMN c_interval SET DEFAULT '3 hours' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_hugetext text DEFAULT repeat('abcdefg', 1000), ALTER COLUMN c_interval..." +== 038 +-- truncate_limit: 100 +INSERT INTO T VALUES (23), (24) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (23), (24)" +== 039 +-- truncate_limit: 100 +ALTER TABLE T ALTER COLUMN c_interval DROP DEFAULT, + ALTER COLUMN c_hugetext SET DEFAULT repeat('poiuyt', 1000) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ALTER COLUMN c_interval DROP DEFAULT, ALTER COLUMN c_hugetext SET DEFAULT repeat('p..." +== 040 +-- truncate_limit: 100 +INSERT INTO T VALUES (25), (26) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (25), (26)" +== 041 +-- truncate_limit: 100 +ALTER TABLE T ALTER COLUMN c_bpchar DROP DEFAULT, + ALTER COLUMN c_date DROP DEFAULT, + ALTER COLUMN c_text DROP DEFAULT, + ALTER COLUMN c_timestamp DROP DEFAULT, + ALTER COLUMN c_array DROP DEFAULT, + ALTER COLUMN c_small DROP DEFAULT, + ALTER COLUMN c_big DROP DEFAULT, + ALTER COLUMN c_num DROP DEFAULT, + ALTER COLUMN c_time DROP DEFAULT, + ALTER COLUMN c_hugetext DROP DEFAULT +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ALTER COLUMN c_bpchar DROP DEFAULT, ALTER COLUMN c_date DROP DEFAULT, ALTER COLUMN ..." +== 042 +-- truncate_limit: 100 +INSERT INTO T VALUES (27), (28) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (27), (28)" +== 043 +-- truncate_limit: 100 +SELECT pk, c_int, c_bpchar, c_text, c_date, c_timestamp, + c_timestamp_null, c_array, c_small, c_small_null, + c_big, c_num, c_time, c_interval, + c_hugetext = repeat('abcdefg',1000) as c_hugetext_origdef, + c_hugetext = repeat('poiuyt', 1000) as c_hugetext_newdef +FROM T ORDER BY pk +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t ORDER BY pk" +== 044 +-- truncate_limit: 100 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT comp()" +== 045 +-- truncate_limit: 100 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 046 +-- truncate_limit: 100 +-- Test expressions in the defaults +CREATE OR REPLACE FUNCTION foo(a INT) RETURNS TEXT AS $$ +DECLARE res TEXT := ''; + i INT; +BEGIN + i := 0; + WHILE (i < a) LOOP + res := res || chr(ascii('a') + i); + i := i + 1; + END LOOP; + RETURN res; +END; $$ LANGUAGE PLPGSQL STABLE +-- +FUNCTION: name="foo" function="foo" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION foo(a int) RETURNS text AS $$\nDECLARE res TEXT := '';\n i INT;\nB..." +== 047 +-- truncate_limit: 100 +CREATE TABLE T(pk INT NOT NULL PRIMARY KEY, c_int INT DEFAULT LENGTH(foo(6))) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (pk int NOT NULL PRIMARY KEY, c_int int DEFAULT length(foo(6)))" +== 048 +-- truncate_limit: 100 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set('t')" +== 049 +-- truncate_limit: 100 +INSERT INTO T VALUES (1), (2) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1), (2)" +== 050 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_bpchar BPCHAR(5) DEFAULT foo(4), + ALTER COLUMN c_int SET DEFAULT LENGTH(foo(8)) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_bpchar bpchar(5) DEFAULT foo(4), ALTER COLUMN c_int SET DEFAULT length..." +== 051 +-- truncate_limit: 100 +INSERT INTO T VALUES (3), (4) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (3), (4)" +== 052 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT foo(6), + ALTER COLUMN c_bpchar SET DEFAULT foo(3) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_text text DEFAULT foo(6), ALTER COLUMN c_bpchar SET DEFAULT foo(3)" +== 053 +-- truncate_limit: 100 +INSERT INTO T VALUES (5), (6) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (5), (6)" +== 054 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_date DATE + DEFAULT '2016-06-02'::DATE + LENGTH(foo(10)), + ALTER COLUMN c_text SET DEFAULT foo(12) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_date date DEFAULT '2016-06-02'::date + length(foo(10)), ALTER COLUMN c..." +== 055 +-- truncate_limit: 100 +INSERT INTO T VALUES (7), (8) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (7), (8)" +== 056 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_timestamp TIMESTAMP + DEFAULT '2016-09-01'::DATE + LENGTH(foo(10)), + ALTER COLUMN c_date + SET DEFAULT '2010-01-01'::DATE - LENGTH(foo(4)) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_timestamp timestamp DEFAULT '2016-09-01'::date + length(foo(10)), ALTE..." +== 057 +-- truncate_limit: 100 +INSERT INTO T VALUES (9), (10) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (9), (10)" +== 058 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_array TEXT[] + DEFAULT ('{"This", "is", "' || foo(4) || + '","the", "real", "world"}')::TEXT[], + ALTER COLUMN c_timestamp + SET DEFAULT '1970-12-31'::DATE + LENGTH(foo(30)) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_array text[] DEFAULT ((('{\"This\", \"is\", \"' || foo(4)) || '\",\"the\", \"re..." +== 059 +-- truncate_limit: 100 +INSERT INTO T VALUES (11), (12) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (11), (12)" +== 060 +-- truncate_limit: 100 +ALTER TABLE T ALTER COLUMN c_int DROP DEFAULT, + ALTER COLUMN c_array + SET DEFAULT ('{"This", "is", "' || foo(1) || + '", "fantasy"}')::text[] +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ALTER COLUMN c_int DROP DEFAULT, ALTER COLUMN c_array SET DEFAULT (('{\"This\", \"is\",..." +== 061 +-- truncate_limit: 100 +INSERT INTO T VALUES (13), (14) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (13), (14)" +== 062 +-- truncate_limit: 100 +ALTER TABLE T ALTER COLUMN c_bpchar DROP DEFAULT, + ALTER COLUMN c_date DROP DEFAULT, + ALTER COLUMN c_text DROP DEFAULT, + ALTER COLUMN c_timestamp DROP DEFAULT, + ALTER COLUMN c_array DROP DEFAULT +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ALTER COLUMN c_bpchar DROP DEFAULT, ALTER COLUMN c_date DROP DEFAULT, ALTER COLUMN ..." +== 063 +-- truncate_limit: 100 +INSERT INTO T VALUES (15), (16) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (15), (16)" +== 064 +-- truncate_limit: 100 +SELECT * FROM T +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 065 +-- truncate_limit: 100 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT comp()" +== 066 +-- truncate_limit: 100 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 067 +-- truncate_limit: 100 +-- Test domains with default value for table rewrite. +CREATE DOMAIN domain1 AS int DEFAULT 11 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domain1 AS int DEFAULT 11" +== 068 +-- truncate_limit: 100 +-- constant +CREATE DOMAIN domain2 AS int DEFAULT random(min=>10, max=>100) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domain2 AS int DEFAULT random(min := 10, max := 100)" +== 069 +-- truncate_limit: 100 +-- volatile +CREATE DOMAIN domain3 AS text DEFAULT foo(4) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domain3 AS text DEFAULT foo(4)" +== 070 +-- truncate_limit: 100 +-- stable +CREATE DOMAIN domain4 AS text[] + DEFAULT ('{"This", "is", "' || foo(4) || '","the", "real", "world"}')::TEXT[] +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN domain4 AS text[] DEFAULT ((('{\"This\", \"is\", \"' || foo(4)) || '\",\"the\", \"real\", \"wo..." +== 071 +-- truncate_limit: 100 +CREATE TABLE t2 (a domain1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t2 (a domain1)" +== 072 +-- truncate_limit: 100 +INSERT INTO t2 VALUES (1),(2) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2 VALUES (1), (2)" +== 073 +-- truncate_limit: 100 +-- no table rewrite +ALTER TABLE t2 ADD COLUMN b domain1 default 3 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t2 ADD COLUMN b domain1 DEFAULT 3" +== 074 +-- truncate_limit: 100 +SELECT attnum, attname, atthasmissing, atthasdef, attmissingval +FROM pg_attribute +WHERE attnum > 0 AND attrelid = 't2'::regclass +ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE attnum > 0 AND attrelid = 't2'::regclass ORDER BY attnum" +== 075 +-- truncate_limit: 100 +-- table rewrite should happen +ALTER TABLE t2 ADD COLUMN c domain3 default left(random()::text,3) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t2 ADD COLUMN c domain3 DEFAULT \"left\"(random()::text, 3)" +== 076 +-- truncate_limit: 100 +-- no table rewrite +ALTER TABLE t2 ADD COLUMN d domain4 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t2 ADD COLUMN d domain4" +== 077 +-- truncate_limit: 100 +SELECT attnum, attname, atthasmissing, atthasdef, attmissingval +FROM pg_attribute +WHERE attnum > 0 AND attrelid = 't2'::regclass +ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE attnum > 0 AND attrelid = 't2'::regclass ORDER BY attnum" +== 078 +-- truncate_limit: 100 +-- table rewrite should happen +ALTER TABLE t2 ADD COLUMN e domain2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t2 ADD COLUMN e domain2" +== 079 +-- truncate_limit: 100 +SELECT attnum, attname, atthasmissing, atthasdef, attmissingval +FROM pg_attribute +WHERE attnum > 0 AND attrelid = 't2'::regclass +ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attnum" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE attnum > 0 AND attrelid = 't2'::regclass ORDER BY attnum" +== 080 +-- truncate_limit: 100 +SELECT a, b, length(c) = 3 as c_ok, d, e >= 10 as e_ok FROM t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, length(c) = 3 AS c_ok, d, e >= 10 AS e_ok FROM t2" +== 081 +-- truncate_limit: 100 +DROP TABLE t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t2" +== 082 +-- truncate_limit: 100 +DROP DOMAIN domain1 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domain1" +== 083 +-- truncate_limit: 100 +DROP DOMAIN domain2 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domain2" +== 084 +-- truncate_limit: 100 +DROP DOMAIN domain3 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domain3" +== 085 +-- truncate_limit: 100 +DROP DOMAIN domain4 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN domain4" +== 086 +-- truncate_limit: 100 +DROP FUNCTION foo(INT) +-- +FUNCTION: name="foo" function="foo" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION foo(int)" +== 087 +-- truncate_limit: 100 +-- Fall back to full rewrite for volatile expressions +CREATE TABLE T(pk INT NOT NULL PRIMARY KEY) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (pk int NOT NULL PRIMARY KEY)" +== 088 +-- truncate_limit: 100 +INSERT INTO T VALUES (1) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1)" +== 089 +-- truncate_limit: 100 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set('t')" +== 090 +-- truncate_limit: 100 +-- now() is stable, because it returns the transaction timestamp +ALTER TABLE T ADD COLUMN c1 TIMESTAMP DEFAULT now() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c1 timestamp DEFAULT now()" +== 091 +-- truncate_limit: 100 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT comp()" +== 092 +-- truncate_limit: 100 +-- clock_timestamp() is volatile +ALTER TABLE T ADD COLUMN c2 TIMESTAMP DEFAULT clock_timestamp() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c2 timestamp DEFAULT clock_timestamp()" +== 093 +-- truncate_limit: 100 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT comp()" +== 094 +-- truncate_limit: 100 +-- check that we notice insertion of a volatile default argument +CREATE FUNCTION foolme(timestamptz DEFAULT clock_timestamp()) + RETURNS timestamptz + IMMUTABLE AS 'select $1' LANGUAGE sql +-- +FUNCTION: name="foolme" function="foolme" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION foolme(timestamptz = clock_timestamp()) RETURNS timestamptz IMMUTABLE AS $$select..." +== 095 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c3 timestamptz DEFAULT foolme() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c3 timestamptz DEFAULT foolme()" +== 096 +-- truncate_limit: 100 +SELECT attname, atthasmissing, attmissingval FROM pg_attribute + WHERE attrelid = 't'::regclass AND attnum > 0 + ORDER BY attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT attname, atthasmissing, attmissingval FROM pg_attribute WHERE ... ORDER BY attnum" +== 097 +-- truncate_limit: 100 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 098 +-- truncate_limit: 100 +DROP FUNCTION foolme(timestamptz) +-- +FUNCTION: name="foolme" function="foolme" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION foolme(timestamptz)" +== 099 +-- truncate_limit: 100 +-- Simple querie +CREATE TABLE T (pk INT NOT NULL PRIMARY KEY) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (pk int NOT NULL PRIMARY KEY)" +== 100 +-- truncate_limit: 100 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set('t')" +== 101 +-- truncate_limit: 100 +INSERT INTO T SELECT * FROM generate_series(1, 10) a +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t SELECT * FROM generate_series(1, 10) a" +== 102 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_bigint BIGINT NOT NULL DEFAULT -1 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_bigint bigint NOT NULL DEFAULT -1" +== 103 +-- truncate_limit: 100 +INSERT INTO T SELECT b, b - 10 FROM generate_series(11, 20) a(b) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t SELECT b, b - 10 FROM generate_series(11, 20) a(b)" +== 104 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT 'hello' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_text text DEFAULT 'hello'" +== 105 +-- truncate_limit: 100 +INSERT INTO T SELECT b, b - 10, (b + 10)::text FROM generate_series(21, 30) a(b) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t SELECT b, b - 10, (b + 10)::text FROM generate_series(21, 30) a(b)" +== 106 +-- truncate_limit: 100 +-- WHERE clause +SELECT c_bigint, c_text FROM T WHERE c_bigint = -1 LIMIT 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_bigint" +STMT: SelectStmt +TRUNCATED: "SELECT c_bigint, c_text FROM t WHERE c_bigint = -1 LIMIT 1" +== 107 +-- truncate_limit: 100 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) +SELECT c_bigint, c_text FROM T WHERE c_bigint = -1 LIMIT 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_bigint" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE TRUE, COSTS FALSE) SELECT c_bigint, c_text FROM t WHERE c_bigint = -1 LIMIT 1" +== 108 +-- truncate_limit: 100 +SELECT c_bigint, c_text FROM T WHERE c_text = 'hello' LIMIT 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_text" +STMT: SelectStmt +TRUNCATED: "SELECT c_bigint, c_text FROM t WHERE c_text = 'hello' LIMIT 1" +== 109 +-- truncate_limit: 100 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) SELECT c_bigint, c_text FROM T WHERE c_text = 'hello' LIMIT 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_text" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE TRUE, COSTS FALSE) SELECT c_bigint, c_text FROM t WHERE c_text = 'hello' LIMIT 1" +== 110 +-- truncate_limit: 100 +-- COALESCE +SELECT COALESCE(c_bigint, pk), COALESCE(c_text, pk::text) +FROM T +ORDER BY pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT COALESCE(c_bigint, pk), COALESCE(c_text, pk::text) FROM t ORDER BY pk LIMIT 10" +== 111 +-- truncate_limit: 100 +-- Aggregate function +SELECT SUM(c_bigint), MAX(c_text COLLATE "C" ), MIN(c_text COLLATE "C") FROM T +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(c_bigint), max(c_text COLLATE \"C\"), min(c_text COLLATE \"C\") FROM t" +== 112 +-- truncate_limit: 100 +-- ORDER BY +SELECT * FROM T ORDER BY c_bigint, c_text, pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t ORDER BY c_bigint, c_text, pk LIMIT 10" +== 113 +-- truncate_limit: 100 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) +SELECT * FROM T ORDER BY c_bigint, c_text, pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE TRUE, COSTS FALSE) SELECT * FROM t ORDER BY c_bigint, c_text, pk LIMIT 10" +== 114 +-- truncate_limit: 100 +-- LIMIT +SELECT * FROM T WHERE c_bigint > -1 ORDER BY c_bigint, c_text, pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_bigint" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t WHERE c_bigint > -1 ORDER BY c_bigint, c_text, pk LIMIT 10" +== 115 +-- truncate_limit: 100 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) +SELECT * FROM T WHERE c_bigint > -1 ORDER BY c_bigint, c_text, pk LIMIT 10 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_bigint" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE TRUE, COSTS FALSE) SELECT * FROM t WHERE c_bigint > -1 ORDER BY c_bigint, c_text..." +== 116 +-- truncate_limit: 100 +-- DELETE with RETURNING +DELETE FROM T WHERE pk BETWEEN 10 AND 20 RETURNING * +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t WHERE pk BETWEEN 10 AND 20 RETURNING *" +== 117 +-- truncate_limit: 100 +EXPLAIN (VERBOSE TRUE, COSTS FALSE) +DELETE FROM T WHERE pk BETWEEN 10 AND 20 RETURNING * +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (VERBOSE TRUE, COSTS FALSE) DELETE FROM t WHERE pk BETWEEN 10 AND 20 RETURNING *" +== 118 +-- truncate_limit: 100 +-- UPDATE +UPDATE T SET c_text = '"' || c_text || '"' WHERE pk < 10 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET c_text = ('\"' || c_text) || '\"' WHERE pk < 10" +== 119 +-- truncate_limit: 100 +SELECT * FROM T WHERE c_text LIKE '"%"' ORDER BY PK +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_text" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t WHERE c_text LIKE '\"%\"' ORDER BY pk" +== 120 +-- truncate_limit: 100 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT comp()" +== 121 +-- truncate_limit: 100 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 122 +-- truncate_limit: 100 +-- Combine with other DDL +CREATE TABLE T(pk INT NOT NULL PRIMARY KEY) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (pk int NOT NULL PRIMARY KEY)" +== 123 +-- truncate_limit: 100 +SELECT set('t') +-- +FUNCTION: name="set" function="set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set('t')" +== 124 +-- truncate_limit: 100 +INSERT INTO T VALUES (1), (2) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1), (2)" +== 125 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_int INT NOT NULL DEFAULT -1 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_int int NOT NULL DEFAULT -1" +== 126 +-- truncate_limit: 100 +INSERT INTO T VALUES (3), (4) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (3), (4)" +== 127 +-- truncate_limit: 100 +ALTER TABLE T ADD COLUMN c_text TEXT DEFAULT 'Hello' +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN c_text text DEFAULT 'Hello'" +== 128 +-- truncate_limit: 100 +INSERT INTO T VALUES (5), (6) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (5), (6)" +== 129 +-- truncate_limit: 100 +ALTER TABLE T ALTER COLUMN c_text SET DEFAULT 'world', + ALTER COLUMN c_int SET DEFAULT 1 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ALTER COLUMN c_text SET DEFAULT 'world', ALTER COLUMN c_int SET DEFAULT 1" +== 130 +-- truncate_limit: 100 +INSERT INTO T VALUES (7), (8) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (7), (8)" +== 131 +-- truncate_limit: 100 +SELECT * FROM T ORDER BY pk +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t ORDER BY pk" +== 132 +-- truncate_limit: 100 +-- Add an index +CREATE INDEX i ON T(c_int, c_text) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX i ON t USING btree (c_int, c_text)" +== 133 +-- truncate_limit: 100 +SELECT c_text FROM T WHERE c_int = -1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="c_int" +STMT: SelectStmt +TRUNCATED: "SELECT c_text FROM t WHERE c_int = -1" +== 134 +-- truncate_limit: 100 +SELECT comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT comp()" +== 135 +-- truncate_limit: 100 +-- query to exercise expand_tuple function +CREATE TABLE t1 AS +SELECT 1::int AS a , 2::int AS b +FROM generate_series(1,20) q +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE t1 AS SELECT 1::int AS a, 2::int AS b FROM generate_series(1, 20) q" +== 136 +-- truncate_limit: 100 +ALTER TABLE t1 ADD COLUMN c text +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t1 ADD COLUMN c text" +== 137 +-- truncate_limit: 100 +SELECT a, + stddev(cast((SELECT sum(1) FROM generate_series(1,20) x) AS float4)) + OVER (PARTITION BY a,b,c ORDER BY b) + AS z +FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1" +== 138 +-- truncate_limit: 100 +DROP TABLE T +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 139 +-- truncate_limit: 100 +-- test that we account for missing columns without defaults correctly +-- in expand_tuple, and that rows are correctly expanded for triggers + +CREATE FUNCTION test_trigger() +RETURNS trigger +LANGUAGE plpgsql +AS $$ + +begin + raise notice 'old tuple: %', to_json(OLD)::text; + if TG_OP = 'DELETE' + then + return OLD; + else + return NEW; + end if; +end; + +$$ +-- +FUNCTION: name="test_trigger" function="test_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_trigger() RETURNS trigger LANGUAGE plpgsql AS $$\n\nbegin\n raise notice 'ol..." +== 140 +-- truncate_limit: 100 +-- 2 new columns, both have defaults +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int)" +== 141 +-- truncate_limit: 100 +INSERT INTO t (a,b,c) VALUES (1,2,3) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b, c) VALUES (1, 2, 3)" +== 142 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4" +== 143 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5" +== 144 +-- truncate_limit: 100 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION test_trigger()" +== 145 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 146 +-- truncate_limit: 100 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET y = 2" +== 147 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 148 +-- truncate_limit: 100 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 149 +-- truncate_limit: 100 +-- 2 new columns, first has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int)" +== 150 +-- truncate_limit: 100 +INSERT INTO t (a,b,c) VALUES (1,2,3) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b, c) VALUES (1, 2, 3)" +== 151 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4" +== 152 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN y int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN y int" +== 153 +-- truncate_limit: 100 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION test_trigger()" +== 154 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 155 +-- truncate_limit: 100 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET y = 2" +== 156 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 157 +-- truncate_limit: 100 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 158 +-- truncate_limit: 100 +-- 2 new columns, second has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int)" +== 159 +-- truncate_limit: 100 +INSERT INTO t (a,b,c) VALUES (1,2,3) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b, c) VALUES (1, 2, 3)" +== 160 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN x int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN x int" +== 161 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5" +== 162 +-- truncate_limit: 100 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION test_trigger()" +== 163 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 164 +-- truncate_limit: 100 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET y = 2" +== 165 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 166 +-- truncate_limit: 100 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 167 +-- truncate_limit: 100 +-- 2 new columns, neither has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int)" +== 168 +-- truncate_limit: 100 +INSERT INTO t (a,b,c) VALUES (1,2,3) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b, c) VALUES (1, 2, 3)" +== 169 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN x int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN x int" +== 170 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN y int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN y int" +== 171 +-- truncate_limit: 100 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION test_trigger()" +== 172 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 173 +-- truncate_limit: 100 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET y = 2" +== 174 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 175 +-- truncate_limit: 100 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 176 +-- truncate_limit: 100 +-- same as last 4 tests but here the last original column has a NULL value +-- 2 new columns, both have defaults +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int)" +== 177 +-- truncate_limit: 100 +INSERT INTO t (a,b,c) VALUES (1,2,NULL) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b, c) VALUES (1, 2, NULL)" +== 178 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4" +== 179 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5" +== 180 +-- truncate_limit: 100 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION test_trigger()" +== 181 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 182 +-- truncate_limit: 100 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET y = 2" +== 183 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 184 +-- truncate_limit: 100 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 185 +-- truncate_limit: 100 +-- 2 new columns, first has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int)" +== 186 +-- truncate_limit: 100 +INSERT INTO t (a,b,c) VALUES (1,2,NULL) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b, c) VALUES (1, 2, NULL)" +== 187 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN x int NOT NULL DEFAULT 4" +== 188 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN y int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN y int" +== 189 +-- truncate_limit: 100 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION test_trigger()" +== 190 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 191 +-- truncate_limit: 100 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET y = 2" +== 192 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 193 +-- truncate_limit: 100 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 194 +-- truncate_limit: 100 +-- 2 new columns, second has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int)" +== 195 +-- truncate_limit: 100 +INSERT INTO t (a,b,c) VALUES (1,2,NULL) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b, c) VALUES (1, 2, NULL)" +== 196 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN x int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN x int" +== 197 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN y int NOT NULL DEFAULT 5" +== 198 +-- truncate_limit: 100 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION test_trigger()" +== 199 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 200 +-- truncate_limit: 100 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET y = 2" +== 201 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 202 +-- truncate_limit: 100 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 203 +-- truncate_limit: 100 +-- 2 new columns, neither has default +CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (id serial PRIMARY KEY, a int, b int, c int)" +== 204 +-- truncate_limit: 100 +INSERT INTO t (a,b,c) VALUES (1,2,NULL) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b, c) VALUES (1, 2, NULL)" +== 205 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN x int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN x int" +== 206 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN y int +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN y int" +== 207 +-- truncate_limit: 100 +CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE PROCEDURE test_trigger() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a BEFORE UPDATE ON t FOR EACH ROW EXECUTE FUNCTION test_trigger()" +== 208 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 209 +-- truncate_limit: 100 +UPDATE t SET y = 2 +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET y = 2" +== 210 +-- truncate_limit: 100 +SELECT * FROM t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t" +== 211 +-- truncate_limit: 100 +DROP TABLE t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 212 +-- truncate_limit: 100 +-- make sure expanded tuple has correct self pointer +-- it will be required by the RI trigger doing the cascading delete + +CREATE TABLE leader (a int PRIMARY KEY, b int) +-- +TABLE: name="leader" schema="" table="leader" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE leader (a int PRIMARY KEY, b int)" +== 213 +-- truncate_limit: 100 +CREATE TABLE follower (a int REFERENCES leader ON DELETE CASCADE, b int) +-- +TABLE: name="follower" schema="" table="follower" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE follower (a int REFERENCES leader ON DELETE CASCADE, b int)" +== 214 +-- truncate_limit: 100 +INSERT INTO leader VALUES (1, 1), (2, 2) +-- +TABLE: name="leader" schema="" table="leader" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO leader VALUES (1, 1), (2, 2)" +== 215 +-- truncate_limit: 100 +ALTER TABLE leader ADD c int +-- +TABLE: name="leader" schema="" table="leader" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE leader ADD COLUMN c int" +== 216 +-- truncate_limit: 100 +ALTER TABLE leader DROP c +-- +TABLE: name="leader" schema="" table="leader" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE leader DROP c" +== 217 +-- truncate_limit: 100 +DELETE FROM leader +-- +TABLE: name="leader" schema="" table="leader" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM leader" +== 218 +-- truncate_limit: 100 +-- check that ALTER TABLE ... ALTER TYPE does the right thing + +CREATE TABLE vtype( a integer) +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vtype (a int)" +== 219 +-- truncate_limit: 100 +INSERT INTO vtype VALUES (1) +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vtype VALUES (1)" +== 220 +-- truncate_limit: 100 +ALTER TABLE vtype ADD COLUMN b DOUBLE PRECISION DEFAULT 0.2 +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vtype ADD COLUMN b double precision DEFAULT 0.2" +== 221 +-- truncate_limit: 100 +ALTER TABLE vtype ADD COLUMN c BOOLEAN DEFAULT true +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vtype ADD COLUMN c boolean DEFAULT true" +== 222 +-- truncate_limit: 100 +SELECT * FROM vtype +-- +TABLE: name="vtype" schema="" table="vtype" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vtype" +== 223 +-- truncate_limit: 100 +ALTER TABLE vtype + ALTER b TYPE text USING b::text, + ALTER c TYPE text USING c::text +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vtype ALTER COLUMN b TYPE text USING b::text, ALTER COLUMN c TYPE text USING c::text" +== 224 +-- truncate_limit: 100 +SELECT * FROM vtype +-- +TABLE: name="vtype" schema="" table="vtype" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vtype" +== 225 +-- truncate_limit: 100 +-- also check the case that doesn't rewrite the table + +CREATE TABLE vtype2 (a int) +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vtype2 (a int)" +== 226 +-- truncate_limit: 100 +INSERT INTO vtype2 VALUES (1) +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vtype2 VALUES (1)" +== 227 +-- truncate_limit: 100 +ALTER TABLE vtype2 ADD COLUMN b varchar(10) DEFAULT 'xxx' +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vtype2 ADD COLUMN b varchar(10) DEFAULT 'xxx'" +== 228 +-- truncate_limit: 100 +ALTER TABLE vtype2 ALTER COLUMN b SET DEFAULT 'yyy' +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vtype2 ALTER COLUMN b SET DEFAULT 'yyy'" +== 229 +-- truncate_limit: 100 +INSERT INTO vtype2 VALUES (2) +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vtype2 VALUES (2)" +== 230 +-- truncate_limit: 100 +ALTER TABLE vtype2 ALTER COLUMN b TYPE varchar(20) USING b::varchar(20) +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vtype2 ALTER COLUMN b TYPE varchar(20) USING b::varchar(20)" +== 231 +-- truncate_limit: 100 +SELECT * FROM vtype2 +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vtype2" +== 232 +-- truncate_limit: 100 +-- Ensure that defaults are checked when evaluating whether HOT update +-- is possible, this was broken for a while: +-- https://postgr.es/m/20190202133521.ylauh3ckqa7colzj%40alap3.anarazel.de +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 233 +-- truncate_limit: 100 +CREATE TABLE t() +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t ()" +== 234 +-- truncate_limit: 100 +INSERT INTO t DEFAULT VALUES +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO t DEFAULT VALUES" +== 235 +-- truncate_limit: 100 +ALTER TABLE t ADD COLUMN a int DEFAULT 1 +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t ADD COLUMN a int DEFAULT 1" +== 236 +-- truncate_limit: 100 +CREATE INDEX ON t(a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON t USING btree (a)" +== 237 +-- truncate_limit: 100 +-- set column with a default 1 to NULL, due to a bug that wasn't +-- noticed has heap_getattr buggily returned NULL for default columns +UPDATE t SET a = NULL +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t SET a = NULL" +== 238 +-- truncate_limit: 100 +-- verify that index and non-index scans show the same result +SET LOCAL enable_seqscan = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO TRUE" +== 239 +-- truncate_limit: 100 +SELECT * FROM t WHERE a IS NULL +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t WHERE a IS NULL" +== 240 +-- truncate_limit: 100 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO FALSE" +== 241 +-- truncate_limit: 100 +SELECT * FROM t WHERE a IS NULL +-- +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t WHERE a IS NULL" +== 242 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 243 +-- truncate_limit: 100 +-- verify that a default set on a non-plain table doesn't set a missing +-- value on the attribute +CREATE FOREIGN DATA WRAPPER dummy +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER dummy" +== 244 +-- truncate_limit: 100 +CREATE SERVER s0 FOREIGN DATA WRAPPER dummy +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s0 FOREIGN DATA WRAPPER dummy" +== 245 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft1 (c1 integer NOT NULL) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft1 (c1 int NOT NULL) SERVER s0" +== 246 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c8 integer DEFAULT 0 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c8 int DEFAULT 0" +== 247 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10)" +== 248 +-- truncate_limit: 100 +SELECT count(*) + FROM pg_attribute + WHERE attrelid = 'ft1'::regclass AND + (attmissingval IS NOT NULL OR atthasmissing) +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attmissingval" +FILTER: schema="" table="" column="atthasmissing" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_attribute WHERE ..." +== 249 +-- truncate_limit: 100 +-- cleanup +DROP FOREIGN TABLE ft1 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE ft1" +== 250 +-- truncate_limit: 100 +DROP SERVER s0 +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s0" +== 251 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER dummy +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER dummy" +== 252 +-- truncate_limit: 100 +DROP TABLE vtype +-- +TABLE: name="vtype" schema="" table="vtype" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vtype" +== 253 +-- truncate_limit: 100 +DROP TABLE vtype2 +-- +TABLE: name="vtype2" schema="" table="vtype2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vtype2" +== 254 +-- truncate_limit: 100 +DROP TABLE follower +-- +TABLE: name="follower" schema="" table="follower" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE follower" +== 255 +-- truncate_limit: 100 +DROP TABLE leader +-- +TABLE: name="leader" schema="" table="leader" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE leader" +== 256 +-- truncate_limit: 100 +DROP FUNCTION test_trigger() +-- +FUNCTION: name="test_trigger" function="test_trigger" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION test_trigger()" +== 257 +-- truncate_limit: 100 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1" +== 258 +-- truncate_limit: 100 +DROP FUNCTION set(name) +-- +FUNCTION: name="set" function="set" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION set(name)" +== 259 +-- truncate_limit: 100 +DROP FUNCTION comp() +-- +FUNCTION: name="comp" function="comp" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION comp()" +== 260 +-- truncate_limit: 100 +DROP TABLE m +-- +TABLE: name="m" schema="" table="m" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE m" +== 261 +-- truncate_limit: 100 +DROP TABLE has_volatile +-- +TABLE: name="has_volatile" schema="" table="has_volatile" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE has_volatile" +== 262 +-- truncate_limit: 100 +DROP EVENT TRIGGER has_volatile_rewrite +-- +STMT: DropStmt +TRUNCATED: "DROP EVENT TRIGGER has_volatile_rewrite" +== 263 +-- truncate_limit: 100 +DROP FUNCTION log_rewrite +-- +FUNCTION: name="log_rewrite" function="log_rewrite" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION log_rewrite" +== 264 +-- truncate_limit: 100 +DROP SCHEMA fast_default +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fast_default" +== 265 +-- truncate_limit: 100 +-- Leave a table with an active fast default in place, for pg_upgrade testing +set search_path = public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO public" +== 266 +-- truncate_limit: 100 +create table has_fast_default(f1 int) +-- +TABLE: name="has_fast_default" schema="" table="has_fast_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE has_fast_default (f1 int)" +== 267 +-- truncate_limit: 100 +insert into has_fast_default values(1) +-- +TABLE: name="has_fast_default" schema="" table="has_fast_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO has_fast_default VALUES (1)" +== 268 +-- truncate_limit: 100 +alter table has_fast_default add column f2 int default 42 +-- +TABLE: name="has_fast_default" schema="" table="has_fast_default" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE has_fast_default ADD COLUMN f2 int DEFAULT 42" +== 269 +-- truncate_limit: 100 +table has_fast_default +-- +TABLE: name="has_fast_default" schema="" table="has_fast_default" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM has_fast_default" diff --git a/parser/testdata/summary_truncate/postgres_regress/float4.metadata.json b/parser/testdata/summary_truncate/postgres_regress/float4.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/float4.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/float4.test b/parser/testdata/summary_truncate/postgres_regress/float4.test new file mode 100644 index 0000000..b109fc8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/float4.test @@ -0,0 +1,947 @@ +== 001 +-- truncate_limit: 100 +|-- +-- FLOAT4 +|-- + +CREATE TABLE FLOAT4_TBL (f1 float4) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE float4_tbl (f1 float4)" +== 002 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES (' 0.0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES (' 0.0')" +== 003 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('1004.30 ') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('1004.30 ')" +== 004 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES (' -34.84 ') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES (' -34.84 ')" +== 005 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e+20') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('1.2345678901234e+20')" +== 006 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e-20') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('1.2345678901234e-20')" +== 007 +-- truncate_limit: 100 +-- test for over and under flow +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('10e70')" +== 008 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('-10e70')" +== 009 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('10e-70')" +== 010 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('-10e-70')" +== 011 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'::float8) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('10e70'::float8)" +== 012 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'::float8) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('-10e70'::float8)" +== 013 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'::float8) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('10e-70'::float8)" +== 014 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'::float8) +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('-10e-70'::float8)" +== 015 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e400') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('10e400')" +== 016 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e400') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('-10e400')" +== 017 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-400') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('10e-400')" +== 018 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-400') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('-10e-400')" +== 019 +-- truncate_limit: 100 +-- bad input +INSERT INTO FLOAT4_TBL(f1) VALUES ('') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('')" +== 020 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES (' ') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES (' ')" +== 021 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('xyz') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('xyz')" +== 022 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('5.0.0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('5.0.0')" +== 023 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('5 . 0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('5 . 0')" +== 024 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('5. 0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('5. 0')" +== 025 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES (' - 3.0') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES (' - 3.0')" +== 026 +-- truncate_limit: 100 +INSERT INTO FLOAT4_TBL(f1) VALUES ('123 5') +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float4_tbl (f1) VALUES ('123 5')" +== 027 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34.5', 'float4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('34.5', 'float4')" +== 028 +-- truncate_limit: 100 +SELECT pg_input_is_valid('xyz', 'float4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('xyz', 'float4')" +== 029 +-- truncate_limit: 100 +SELECT pg_input_is_valid('1e400', 'float4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1e400', 'float4')" +== 030 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1e400', 'float4') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1e400', 'float4')" +== 031 +-- truncate_limit: 100 +-- special inputs +SELECT 'NaN'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::float4" +== 032 +-- truncate_limit: 100 +SELECT 'nan'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::float4" +== 033 +-- truncate_limit: 100 +SELECT ' NAN '::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' NAN '::float4" +== 034 +-- truncate_limit: 100 +SELECT 'infinity'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::float4" +== 035 +-- truncate_limit: 100 +SELECT ' -INFINiTY '::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' -INFINiTY '::float4" +== 036 +-- truncate_limit: 100 +-- bad special inputs +SELECT 'N A N'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'N A N'::float4" +== 037 +-- truncate_limit: 100 +SELECT 'NaN x'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN x'::float4" +== 038 +-- truncate_limit: 100 +SELECT ' INFINITY x'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' INFINITY x'::float4" +== 039 +-- truncate_limit: 100 +SELECT 'Infinity'::float4 + 100.0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::float4 + 100.0" +== 040 +-- truncate_limit: 100 +SELECT 'Infinity'::float4 / 'Infinity'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::float4 / 'Infinity'::float4" +== 041 +-- truncate_limit: 100 +SELECT '42'::float4 / 'Infinity'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::float4 / 'Infinity'::float4" +== 042 +-- truncate_limit: 100 +SELECT 'nan'::float4 / 'nan'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::float4 / 'nan'::float4" +== 043 +-- truncate_limit: 100 +SELECT 'nan'::float4 / '0'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::float4 / '0'::float4" +== 044 +-- truncate_limit: 100 +SELECT 'nan'::numeric::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::numeric::float4" +== 045 +-- truncate_limit: 100 +SELECT * FROM FLOAT4_TBL +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float4_tbl" +== 046 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float4_tbl f WHERE f.f1 <> '1004.3'" +== 047 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float4_tbl f WHERE f.f1 = '1004.3'" +== 048 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1 +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float4_tbl f WHERE '1004.3' > f.f1" +== 049 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float4_tbl f WHERE f.f1 < '1004.3'" +== 050 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1 +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float4_tbl f WHERE '1004.3' >= f.f1" +== 051 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float4_tbl f WHERE f.f1 <= '1004.3'" +== 052 +-- truncate_limit: 100 +SELECT f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, f.f1 * '-10' AS x FROM float4_tbl f WHERE f.f1 > '0.0'" +== 053 +-- truncate_limit: 100 +SELECT f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, f.f1 + '-10' AS x FROM float4_tbl f WHERE f.f1 > '0.0'" +== 054 +-- truncate_limit: 100 +SELECT f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, f.f1 / '-10' AS x FROM float4_tbl f WHERE f.f1 > '0.0'" +== 055 +-- truncate_limit: 100 +SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, f.f1 - '-10' AS x FROM float4_tbl f WHERE f.f1 > '0.0'" +== 056 +-- truncate_limit: 100 +-- test divide by zero +SELECT f.f1 / '0.0' from FLOAT4_TBL f +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1 / '0.0' FROM float4_tbl f" +== 057 +-- truncate_limit: 100 +SELECT * FROM FLOAT4_TBL +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float4_tbl" +== 058 +-- truncate_limit: 100 +-- test the unary float4abs operator +SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +ALIAS: "f"="float4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, @ f.f1 AS abs_f1 FROM float4_tbl f" +== 059 +-- truncate_limit: 100 +UPDATE FLOAT4_TBL + SET f1 = FLOAT4_TBL.f1 * '-1' + WHERE FLOAT4_TBL.f1 > '0.0' +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE float4_tbl SET f1 = float4_tbl.f1 * '-1' WHERE float4_tbl.f1 > '0.0'" +== 060 +-- truncate_limit: 100 +SELECT * FROM FLOAT4_TBL +-- +TABLE: name="float4_tbl" schema="" table="float4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float4_tbl" +== 061 +-- truncate_limit: 100 +-- test edge-case coercions to integer +SELECT '32767.4'::float4::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '32767.4'::float4::int2" +== 062 +-- truncate_limit: 100 +SELECT '32767.6'::float4::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '32767.6'::float4::int2" +== 063 +-- truncate_limit: 100 +SELECT '-32768.4'::float4::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-32768.4'::float4::int2" +== 064 +-- truncate_limit: 100 +SELECT '-32768.6'::float4::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-32768.6'::float4::int2" +== 065 +-- truncate_limit: 100 +SELECT '2147483520'::float4::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483520'::float4::int4" +== 066 +-- truncate_limit: 100 +SELECT '2147483647'::float4::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647'::float4::int4" +== 067 +-- truncate_limit: 100 +SELECT '-2147483648.5'::float4::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648.5'::float4::int4" +== 068 +-- truncate_limit: 100 +SELECT '-2147483900'::float4::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483900'::float4::int4" +== 069 +-- truncate_limit: 100 +SELECT '9223369837831520256'::float4::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223369837831520256'::float4::int8" +== 070 +-- truncate_limit: 100 +SELECT '9223372036854775807'::float4::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775807'::float4::int8" +== 071 +-- truncate_limit: 100 +SELECT '-9223372036854775808.5'::float4::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808.5'::float4::int8" +== 072 +-- truncate_limit: 100 +SELECT '-9223380000000000000'::float4::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223380000000000000'::float4::int8" +== 073 +-- truncate_limit: 100 +-- Test for correct input rounding in edge cases. +-- These lists are from Paxson 1991, excluding subnormals and +-- inputs of over 9 sig. digits. + +SELECT float4send('5e-20'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('5e-20'::float4)" +== 074 +-- truncate_limit: 100 +SELECT float4send('67e14'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('67e14'::float4)" +== 075 +-- truncate_limit: 100 +SELECT float4send('985e15'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('985e15'::float4)" +== 076 +-- truncate_limit: 100 +SELECT float4send('55895e-16'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('55895e-16'::float4)" +== 077 +-- truncate_limit: 100 +SELECT float4send('7038531e-32'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('7038531e-32'::float4)" +== 078 +-- truncate_limit: 100 +SELECT float4send('702990899e-20'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('702990899e-20'::float4)" +== 079 +-- truncate_limit: 100 +SELECT float4send('3e-23'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('3e-23'::float4)" +== 080 +-- truncate_limit: 100 +SELECT float4send('57e18'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('57e18'::float4)" +== 081 +-- truncate_limit: 100 +SELECT float4send('789e-35'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('789e-35'::float4)" +== 082 +-- truncate_limit: 100 +SELECT float4send('2539e-18'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('2539e-18'::float4)" +== 083 +-- truncate_limit: 100 +SELECT float4send('76173e28'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('76173e28'::float4)" +== 084 +-- truncate_limit: 100 +SELECT float4send('887745e-11'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('887745e-11'::float4)" +== 085 +-- truncate_limit: 100 +SELECT float4send('5382571e-37'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('5382571e-37'::float4)" +== 086 +-- truncate_limit: 100 +SELECT float4send('82381273e-35'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('82381273e-35'::float4)" +== 087 +-- truncate_limit: 100 +SELECT float4send('750486563e-38'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('750486563e-38'::float4)" +== 088 +-- truncate_limit: 100 +-- Test that the smallest possible normalized input value inputs +-- correctly, either in 9-significant-digit or shortest-decimal +-- format. +|-- +-- exact val is 1.1754943508... +-- shortest val is 1.1754944000 +-- midpoint to next val is 1.1754944208... + +SELECT float4send('1.17549435e-38'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('1.17549435e-38'::float4)" +== 089 +-- truncate_limit: 100 +SELECT float4send('1.1754944e-38'::float4) +-- +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float4send('1.1754944e-38'::float4)" +== 090 +-- truncate_limit: 100 +-- test output (and round-trip safety) of various values. +-- To ensure we're testing what we think we're testing, start with +-- float values specified by bit patterns (as a useful side effect, +-- this means we'll fail on non-IEEE platforms). + +create type xfloat4 +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE xfloat4" +== 091 +-- truncate_limit: 100 +create function xfloat4in(cstring) returns xfloat4 immutable strict + language internal as 'int4in' +-- +FUNCTION: name="xfloat4in" function="xfloat4in" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION xfloat4in(cstring) RETURNS xfloat4 IMMUTABLE RETURNS NULL ON NULL INPUT LANGUAGE ..." +== 092 +-- truncate_limit: 100 +create function xfloat4out(xfloat4) returns cstring immutable strict + language internal as 'int4out' +-- +FUNCTION: name="xfloat4out" function="xfloat4out" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION xfloat4out(xfloat4) RETURNS cstring IMMUTABLE RETURNS NULL ON NULL INPUT LANGUAGE..." +== 093 +-- truncate_limit: 100 +create type xfloat4 (input = xfloat4in, output = xfloat4out, like = float4) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE xfloat4 (input = xfloat4in, output = xfloat4out, \"like\" = float4)" +== 094 +-- truncate_limit: 100 +create cast (xfloat4 as float4) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (xfloat4 AS float4) WITHOUT FUNCTION" +== 095 +-- truncate_limit: 100 +create cast (float4 as xfloat4) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (float4 AS xfloat4) WITHOUT FUNCTION" +== 096 +-- truncate_limit: 100 +create cast (xfloat4 as integer) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (xfloat4 AS int) WITHOUT FUNCTION" +== 097 +-- truncate_limit: 100 +create cast (integer as xfloat4) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int AS xfloat4) WITHOUT FUNCTION" +== 098 +-- truncate_limit: 100 +-- float4: seeeeeee emmmmmmm mmmmmmmm mmmmmmmm + +-- we don't care to assume the platform's strtod() handles subnormals +-- correctly; those are "use at your own risk". However we do test +-- subnormal outputs, since those are under our control. + +with testdata(bits) as (values + -- small subnormals + (x'00000001'), + (x'00000002'), (x'00000003'), + (x'00000010'), (x'00000011'), (x'00000100'), (x'00000101'), + (x'00004000'), (x'00004001'), (x'00080000'), (x'00080001'), + -- stress values + (x'0053c4f4'), -- 7693e-42 + (x'006c85c4'), -- 996622e-44 + (x'0041ca76'), -- 60419369e-46 + (x'004b7678'), -- 6930161142e-48 + -- taken from upstream testsuite + (x'00000007'), + (x'00424fe2'), + -- borderline between subnormal and normal + (x'007ffff0'), (x'007ffff1'), (x'007ffffe'), (x'007fffff')) +select float4send(flt) as ibits, + flt + from (select bits::integer::xfloat4::float4 as flt + from testdata + offset 0) s +-- +CTE: "testdata" +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH testdata(bits) AS (...) SELECT ... FROM (SELECT ... FROM testdata OFFSET 0) s" +== 099 +-- truncate_limit: 100 +with testdata(bits) as (values + (x'00000000'), + -- smallest normal values + (x'00800000'), (x'00800001'), (x'00800004'), (x'00800005'), + (x'00800006'), + -- small normal values chosen for short vs. long output + (x'008002f1'), (x'008002f2'), (x'008002f3'), + (x'00800e17'), (x'00800e18'), (x'00800e19'), + -- assorted values (random mantissae) + (x'01000001'), (x'01102843'), (x'01a52c98'), + (x'0219c229'), (x'02e4464d'), (x'037343c1'), (x'03a91b36'), + (x'047ada65'), (x'0496fe87'), (x'0550844f'), (x'05999da3'), + (x'060ea5e2'), (x'06e63c45'), (x'07f1e548'), (x'0fc5282b'), + (x'1f850283'), (x'2874a9d6'), + -- values around 5e-08 + (x'3356bf94'), (x'3356bf95'), (x'3356bf96'), + -- around 1e-07 + (x'33d6bf94'), (x'33d6bf95'), (x'33d6bf96'), + -- around 3e-07 .. 1e-04 + (x'34a10faf'), (x'34a10fb0'), (x'34a10fb1'), + (x'350637bc'), (x'350637bd'), (x'350637be'), + (x'35719786'), (x'35719787'), (x'35719788'), + (x'358637bc'), (x'358637bd'), (x'358637be'), + (x'36a7c5ab'), (x'36a7c5ac'), (x'36a7c5ad'), + (x'3727c5ab'), (x'3727c5ac'), (x'3727c5ad'), + -- format crossover at 1e-04 + (x'38d1b714'), (x'38d1b715'), (x'38d1b716'), + (x'38d1b717'), (x'38d1b718'), (x'38d1b719'), + (x'38d1b71a'), (x'38d1b71b'), (x'38d1b71c'), + (x'38d1b71d'), + -- + (x'38dffffe'), (x'38dfffff'), (x'38e00000'), + (x'38efffff'), (x'38f00000'), (x'38f00001'), + (x'3a83126e'), (x'3a83126f'), (x'3a831270'), + (x'3c23d709'), (x'3c23d70a'), (x'3c23d70b'), + (x'3dcccccc'), (x'3dcccccd'), (x'3dccccce'), + -- chosen to need 9 digits for 3dcccd70 + (x'3dcccd6f'), (x'3dcccd70'), (x'3dcccd71'), + -- + (x'3effffff'), (x'3f000000'), (x'3f000001'), + (x'3f333332'), (x'3f333333'), (x'3f333334'), + -- approach 1.0 with increasing numbers of 9s + (x'3f666665'), (x'3f666666'), (x'3f666667'), + (x'3f7d70a3'), (x'3f7d70a4'), (x'3f7d70a5'), + (x'3f7fbe76'), (x'3f7fbe77'), (x'3f7fbe78'), + (x'3f7ff971'), (x'3f7ff972'), (x'3f7ff973'), + (x'3f7fff57'), (x'3f7fff58'), (x'3f7fff59'), + (x'3f7fffee'), (x'3f7fffef'), + -- values very close to 1 + (x'3f7ffff0'), (x'3f7ffff1'), (x'3f7ffff2'), + (x'3f7ffff3'), (x'3f7ffff4'), (x'3f7ffff5'), + (x'3f7ffff6'), (x'3f7ffff7'), (x'3f7ffff8'), + (x'3f7ffff9'), (x'3f7ffffa'), (x'3f7ffffb'), + (x'3f7ffffc'), (x'3f7ffffd'), (x'3f7ffffe'), + (x'3f7fffff'), + (x'3f800000'), + (x'3f800001'), (x'3f800002'), (x'3f800003'), + (x'3f800004'), (x'3f800005'), (x'3f800006'), + (x'3f800007'), (x'3f800008'), (x'3f800009'), + -- values 1 to 1.1 + (x'3f80000f'), (x'3f800010'), (x'3f800011'), + (x'3f800012'), (x'3f800013'), (x'3f800014'), + (x'3f800017'), (x'3f800018'), (x'3f800019'), + (x'3f80001a'), (x'3f80001b'), (x'3f80001c'), + (x'3f800029'), (x'3f80002a'), (x'3f80002b'), + (x'3f800053'), (x'3f800054'), (x'3f800055'), + (x'3f800346'), (x'3f800347'), (x'3f800348'), + (x'3f8020c4'), (x'3f8020c5'), (x'3f8020c6'), + (x'3f8147ad'), (x'3f8147ae'), (x'3f8147af'), + (x'3f8ccccc'), (x'3f8ccccd'), (x'3f8cccce'), + -- + (x'3fc90fdb'), -- pi/2 + (x'402df854'), -- e + (x'40490fdb'), -- pi + -- + (x'409fffff'), (x'40a00000'), (x'40a00001'), + (x'40afffff'), (x'40b00000'), (x'40b00001'), + (x'411fffff'), (x'41200000'), (x'41200001'), + (x'42c7ffff'), (x'42c80000'), (x'42c80001'), + (x'4479ffff'), (x'447a0000'), (x'447a0001'), + (x'461c3fff'), (x'461c4000'), (x'461c4001'), + (x'47c34fff'), (x'47c35000'), (x'47c35001'), + (x'497423ff'), (x'49742400'), (x'49742401'), + (x'4b18967f'), (x'4b189680'), (x'4b189681'), + (x'4cbebc1f'), (x'4cbebc20'), (x'4cbebc21'), + (x'4e6e6b27'), (x'4e6e6b28'), (x'4e6e6b29'), + (x'501502f8'), (x'501502f9'), (x'501502fa'), + (x'51ba43b6'), (x'51ba43b7'), (x'51ba43b8'), + -- stress values + (x'1f6c1e4a'), -- 5e-20 + (x'59be6cea'), -- 67e14 + (x'5d5ab6c4'), -- 985e15 + (x'2cc4a9bd'), -- 55895e-16 + (x'15ae43fd'), -- 7038531e-32 + (x'2cf757ca'), -- 702990899e-20 + (x'665ba998'), -- 25933168707e13 + (x'743c3324'), -- 596428896559e20 + -- exercise fixed-point memmoves + (x'47f1205a'), + (x'4640e6ae'), + (x'449a5225'), + (x'42f6e9d5'), + (x'414587dd'), + (x'3f9e064b'), + -- these cases come from the upstream's testsuite + -- BoundaryRoundEven + (x'4c000004'), + (x'50061c46'), + (x'510006a8'), + -- ExactValueRoundEven + (x'48951f84'), + (x'45fd1840'), + -- LotsOfTrailingZeros + (x'39800000'), + (x'3b200000'), + (x'3b900000'), + (x'3bd00000'), + -- Regression + (x'63800000'), + (x'4b000000'), + (x'4b800000'), + (x'4c000001'), + (x'4c800b0d'), + (x'00d24584'), + (x'00d90b88'), + (x'45803f34'), + (x'4f9f24f7'), + (x'3a8722c3'), + (x'5c800041'), + (x'15ae43fd'), + (x'5d4cccfb'), + (x'4c800001'), + (x'57800ed8'), + (x'5f000000'), + (x'700000f0'), + (x'5f23e9ac'), + (x'5e9502f9'), + (x'5e8012b1'), + (x'3c000028'), + (x'60cde861'), + (x'03aa2a50'), + (x'43480000'), + (x'4c000000'), + -- LooksLikePow5 + (x'5D1502F9'), + (x'5D9502F9'), + (x'5E1502F9'), + -- OutputLength + (x'3f99999a'), + (x'3f9d70a4'), + (x'3f9df3b6'), + (x'3f9e0419'), + (x'3f9e0610'), + (x'3f9e064b'), + (x'3f9e0651'), + (x'03d20cfe') +) +select float4send(flt) as ibits, + flt, + flt::text::float4 as r_flt, + float4send(flt::text::float4) as obits, + float4send(flt::text::float4) = float4send(flt) as correct + from (select bits::integer::xfloat4::float4 as flt + from testdata + offset 0) s +-- +CTE: "testdata" +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +FUNCTION: name="float4send" function="float4send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH testdata(bits) AS (...) SELECT ... FROM (SELECT ... FROM testdata OFFSET 0) s" +== 100 +-- truncate_limit: 100 +-- clean up, lest opr_sanity complain +drop type xfloat4 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE xfloat4 CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/float8.metadata.json b/parser/testdata/summary_truncate/postgres_regress/float8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/float8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/float8.test b/parser/testdata/summary_truncate/postgres_regress/float8.test new file mode 100644 index 0000000..250ad66 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/float8.test @@ -0,0 +1,1511 @@ +== 001 +-- truncate_limit: 100 +|-- +-- FLOAT8 +|-- + +|-- +-- Build a table for testing +-- (This temporarily hides the table created in test_setup.sql) +|-- + +CREATE TEMP TABLE FLOAT8_TBL(f1 float8) +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE float8_tbl (f1 float8)" +== 002 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 ') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES (' 0.0 ')" +== 003 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30 ') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('1004.30 ')" +== 004 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES (' -34.84') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES (' -34.84')" +== 005 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('1.2345678901234e+200')" +== 006 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('1.2345678901234e-200')" +== 007 +-- truncate_limit: 100 +-- test for underflow and overflow handling +SELECT '10e400'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '10e400'::float8" +== 008 +-- truncate_limit: 100 +SELECT '-10e400'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-10e400'::float8" +== 009 +-- truncate_limit: 100 +SELECT '10e-400'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '10e-400'::float8" +== 010 +-- truncate_limit: 100 +SELECT '-10e-400'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-10e-400'::float8" +== 011 +-- truncate_limit: 100 +-- test smallest normalized input +SELECT float8send('2.2250738585072014E-308'::float8) +-- +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT float8send('2.2250738585072014E-308'::float8)" +== 012 +-- truncate_limit: 100 +-- bad input +INSERT INTO FLOAT8_TBL(f1) VALUES ('') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('')" +== 013 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES (' ') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES (' ')" +== 014 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('xyz')" +== 015 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('5.0.0')" +== 016 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('5 . 0')" +== 017 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('5. 0')" +== 018 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES (' - 3')" +== 019 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('123 5')" +== 020 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34.5', 'float8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('34.5', 'float8')" +== 021 +-- truncate_limit: 100 +SELECT pg_input_is_valid('xyz', 'float8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('xyz', 'float8')" +== 022 +-- truncate_limit: 100 +SELECT pg_input_is_valid('1e4000', 'float8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1e4000', 'float8')" +== 023 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1e4000', 'float8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1e4000', 'float8')" +== 024 +-- truncate_limit: 100 +-- special inputs +SELECT 'NaN'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::float8" +== 025 +-- truncate_limit: 100 +SELECT 'nan'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::float8" +== 026 +-- truncate_limit: 100 +SELECT ' NAN '::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' NAN '::float8" +== 027 +-- truncate_limit: 100 +SELECT 'infinity'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::float8" +== 028 +-- truncate_limit: 100 +SELECT ' -INFINiTY '::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' -INFINiTY '::float8" +== 029 +-- truncate_limit: 100 +-- bad special inputs +SELECT 'N A N'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'N A N'::float8" +== 030 +-- truncate_limit: 100 +SELECT 'NaN x'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN x'::float8" +== 031 +-- truncate_limit: 100 +SELECT ' INFINITY x'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' INFINITY x'::float8" +== 032 +-- truncate_limit: 100 +SELECT 'Infinity'::float8 + 100.0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::float8 + 100.0" +== 033 +-- truncate_limit: 100 +SELECT 'Infinity'::float8 / 'Infinity'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::float8 / 'Infinity'::float8" +== 034 +-- truncate_limit: 100 +SELECT '42'::float8 / 'Infinity'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::float8 / 'Infinity'::float8" +== 035 +-- truncate_limit: 100 +SELECT 'nan'::float8 / 'nan'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::float8 / 'nan'::float8" +== 036 +-- truncate_limit: 100 +SELECT 'nan'::float8 / '0'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::float8 / '0'::float8" +== 037 +-- truncate_limit: 100 +SELECT 'nan'::numeric::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::numeric::float8" +== 038 +-- truncate_limit: 100 +SELECT * FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float8_tbl" +== 039 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float8_tbl f WHERE f.f1 <> '1004.3'" +== 040 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float8_tbl f WHERE f.f1 = '1004.3'" +== 041 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float8_tbl f WHERE '1004.3' > f.f1" +== 042 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float8_tbl f WHERE f.f1 < '1004.3'" +== 043 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float8_tbl f WHERE '1004.3' >= f.f1" +== 044 +-- truncate_limit: 100 +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.* FROM float8_tbl f WHERE f.f1 <= '1004.3'" +== 045 +-- truncate_limit: 100 +SELECT f.f1, f.f1 * '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, f.f1 * '-10' AS x FROM float8_tbl f WHERE f.f1 > '0.0'" +== 046 +-- truncate_limit: 100 +SELECT f.f1, f.f1 + '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, f.f1 + '-10' AS x FROM float8_tbl f WHERE f.f1 > '0.0'" +== 047 +-- truncate_limit: 100 +SELECT f.f1, f.f1 / '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, f.f1 / '-10' AS x FROM float8_tbl f WHERE f.f1 > '0.0'" +== 048 +-- truncate_limit: 100 +SELECT f.f1, f.f1 - '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, f.f1 - '-10' AS x FROM float8_tbl f WHERE f.f1 > '0.0'" +== 049 +-- truncate_limit: 100 +SELECT f.f1 ^ '2.0' AS square_f1 + FROM FLOAT8_TBL f where f.f1 = '1004.3' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1 ^ '2.0' AS square_f1 FROM float8_tbl f WHERE f.f1 = '1004.3'" +== 050 +-- truncate_limit: 100 +-- absolute value +SELECT f.f1, @f.f1 AS abs_f1 + FROM FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, @ f.f1 AS abs_f1 FROM float8_tbl f" +== 051 +-- truncate_limit: 100 +-- truncate +SELECT f.f1, trunc(f.f1) AS trunc_f1 + FROM FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, trunc(f.f1) AS trunc_f1 FROM float8_tbl f" +== 052 +-- truncate_limit: 100 +-- round +SELECT f.f1, round(f.f1) AS round_f1 + FROM FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, round(f.f1) AS round_f1 FROM float8_tbl f" +== 053 +-- truncate_limit: 100 +-- ceil / ceiling +select ceil(f1) as ceil_f1 from float8_tbl f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="ceil" function="ceil" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ceil(f1) AS ceil_f1 FROM float8_tbl f" +== 054 +-- truncate_limit: 100 +select ceiling(f1) as ceiling_f1 from float8_tbl f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="ceiling" function="ceiling" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ceiling(f1) AS ceiling_f1 FROM float8_tbl f" +== 055 +-- truncate_limit: 100 +-- floor +select floor(f1) as floor_f1 from float8_tbl f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="floor" function="floor" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT floor(f1) AS floor_f1 FROM float8_tbl f" +== 056 +-- truncate_limit: 100 +-- sign +select sign(f1) as sign_f1 from float8_tbl f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="sign" function="sign" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sign(f1) AS sign_f1 FROM float8_tbl f" +== 057 +-- truncate_limit: 100 +-- avoid bit-exact output here because operations may not be bit-exact. +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO 0" +== 058 +-- truncate_limit: 100 +-- square root +SELECT sqrt(float8 '64') AS eight +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt('64'::float8) AS eight" +== 059 +-- truncate_limit: 100 +SELECT |/ float8 '64' AS eight +-- +STMT: SelectStmt +TRUNCATED: "SELECT |/ '64'::float8 AS eight" +== 060 +-- truncate_limit: 100 +SELECT f.f1, |/f.f1 AS sqrt_f1 + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, |/ f.f1 AS sqrt_f1 FROM float8_tbl f WHERE f.f1 > '0.0'" +== 061 +-- truncate_limit: 100 +-- power +SELECT power(float8 '144', float8 '0.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('144'::float8, '0.5'::float8)" +== 062 +-- truncate_limit: 100 +SELECT power(float8 'NaN', float8 '0.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('NaN'::float8, '0.5'::float8)" +== 063 +-- truncate_limit: 100 +SELECT power(float8 '144', float8 'NaN') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('144'::float8, 'NaN'::float8)" +== 064 +-- truncate_limit: 100 +SELECT power(float8 'NaN', float8 'NaN') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('NaN'::float8, 'NaN'::float8)" +== 065 +-- truncate_limit: 100 +SELECT power(float8 '-1', float8 'NaN') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-1'::float8, 'NaN'::float8)" +== 066 +-- truncate_limit: 100 +SELECT power(float8 '1', float8 'NaN') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('1'::float8, 'NaN'::float8)" +== 067 +-- truncate_limit: 100 +SELECT power(float8 'NaN', float8 '0') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('NaN'::float8, '0'::float8)" +== 068 +-- truncate_limit: 100 +SELECT power(float8 'inf', float8 '0') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('inf'::float8, '0'::float8)" +== 069 +-- truncate_limit: 100 +SELECT power(float8 '-inf', float8 '0') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::float8, '0'::float8)" +== 070 +-- truncate_limit: 100 +SELECT power(float8 '0', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('0'::float8, 'inf'::float8)" +== 071 +-- truncate_limit: 100 +SELECT power(float8 '0', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('0'::float8, '-inf'::float8)" +== 072 +-- truncate_limit: 100 +SELECT power(float8 '1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('1'::float8, 'inf'::float8)" +== 073 +-- truncate_limit: 100 +SELECT power(float8 '1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('1'::float8, '-inf'::float8)" +== 074 +-- truncate_limit: 100 +SELECT power(float8 '-1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-1'::float8, 'inf'::float8)" +== 075 +-- truncate_limit: 100 +SELECT power(float8 '-1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-1'::float8, '-inf'::float8)" +== 076 +-- truncate_limit: 100 +SELECT power(float8 '0.1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('0.1'::float8, 'inf'::float8)" +== 077 +-- truncate_limit: 100 +SELECT power(float8 '-0.1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-0.1'::float8, 'inf'::float8)" +== 078 +-- truncate_limit: 100 +SELECT power(float8 '1.1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('1.1'::float8, 'inf'::float8)" +== 079 +-- truncate_limit: 100 +SELECT power(float8 '-1.1', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-1.1'::float8, 'inf'::float8)" +== 080 +-- truncate_limit: 100 +SELECT power(float8 '0.1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('0.1'::float8, '-inf'::float8)" +== 081 +-- truncate_limit: 100 +SELECT power(float8 '-0.1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-0.1'::float8, '-inf'::float8)" +== 082 +-- truncate_limit: 100 +SELECT power(float8 '1.1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('1.1'::float8, '-inf'::float8)" +== 083 +-- truncate_limit: 100 +SELECT power(float8 '-1.1', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-1.1'::float8, '-inf'::float8)" +== 084 +-- truncate_limit: 100 +SELECT power(float8 'inf', float8 '-2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('inf'::float8, '-2'::float8)" +== 085 +-- truncate_limit: 100 +SELECT power(float8 'inf', float8 '2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('inf'::float8, '2'::float8)" +== 086 +-- truncate_limit: 100 +SELECT power(float8 'inf', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('inf'::float8, 'inf'::float8)" +== 087 +-- truncate_limit: 100 +SELECT power(float8 'inf', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('inf'::float8, '-inf'::float8)" +== 088 +-- truncate_limit: 100 +-- Intel's icc misoptimizes the code that controls the sign of this result, +-- even with -mp1. Pending a fix for that, only test for "is it zero". +SELECT power(float8 '-inf', float8 '-2') = '0' +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::float8, '-2'::float8) = '0'" +== 089 +-- truncate_limit: 100 +SELECT power(float8 '-inf', float8 '-3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::float8, '-3'::float8)" +== 090 +-- truncate_limit: 100 +SELECT power(float8 '-inf', float8 '2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::float8, '2'::float8)" +== 091 +-- truncate_limit: 100 +SELECT power(float8 '-inf', float8 '3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::float8, '3'::float8)" +== 092 +-- truncate_limit: 100 +SELECT power(float8 '-inf', float8 '3.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::float8, '3.5'::float8)" +== 093 +-- truncate_limit: 100 +SELECT power(float8 '-inf', float8 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::float8, 'inf'::float8)" +== 094 +-- truncate_limit: 100 +SELECT power(float8 '-inf', float8 '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::float8, '-inf'::float8)" +== 095 +-- truncate_limit: 100 +-- take exp of ln(f.f1) +SELECT f.f1, exp(ln(f.f1)) AS exp_ln_f1 + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="exp" function="exp" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, exp(ln(f.f1)) AS exp_ln_f1 FROM float8_tbl f WHERE f.f1 > '0.0'" +== 096 +-- truncate_limit: 100 +-- check edge cases for exp +SELECT exp('inf'::float8), exp('-inf'::float8), exp('nan'::float8) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +FUNCTION: name="exp" function="exp" schema="" ctx=Call +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp('inf'::float8), exp('-inf'::float8), exp('nan'::float8)" +== 097 +-- truncate_limit: 100 +-- cube root +SELECT ||/ float8 '27' AS three +-- +STMT: SelectStmt +TRUNCATED: "SELECT ||/ '27'::float8 AS three" +== 098 +-- truncate_limit: 100 +SELECT f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1, ||/ f.f1 AS cbrt_f1 FROM float8_tbl f" +== 099 +-- truncate_limit: 100 +SELECT * FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float8_tbl" +== 100 +-- truncate_limit: 100 +UPDATE FLOAT8_TBL + SET f1 = FLOAT8_TBL.f1 * '-1' + WHERE FLOAT8_TBL.f1 > '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE float8_tbl SET f1 = float8_tbl.f1 * '-1' WHERE float8_tbl.f1 > '0.0'" +== 101 +-- truncate_limit: 100 +SELECT f.f1 * '1e200' from FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1 * '1e200' FROM float8_tbl f" +== 102 +-- truncate_limit: 100 +SELECT f.f1 ^ '1e200' from FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1 ^ '1e200' FROM float8_tbl f" +== 103 +-- truncate_limit: 100 +SELECT 0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (((0 ^ 0) + (0 ^ 1)) + (0 ^ 0.0)) + (0 ^ 0.5)" +== 104 +-- truncate_limit: 100 +SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ln(f.f1) FROM float8_tbl f WHERE f.f1 = '0.0'" +== 105 +-- truncate_limit: 100 +SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FILTER: schema="" table="f" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ln(f.f1) FROM float8_tbl f WHERE f.f1 < '0.0'" +== 106 +-- truncate_limit: 100 +SELECT exp(f.f1) from FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp(f.f1) FROM float8_tbl f" +== 107 +-- truncate_limit: 100 +SELECT f.f1 / '0.0' from FLOAT8_TBL f +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "f"="float8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f.f1 / '0.0' FROM float8_tbl f" +== 108 +-- truncate_limit: 100 +SELECT * FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float8_tbl" +== 109 +-- truncate_limit: 100 +-- hyperbolic functions +-- we run these with extra_float_digits = 0 too, since different platforms +-- tend to produce results that vary in the last place. +SELECT sinh(float8 '1') +-- +FUNCTION: name="sinh" function="sinh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sinh('1'::float8)" +== 110 +-- truncate_limit: 100 +SELECT cosh(float8 '1') +-- +FUNCTION: name="cosh" function="cosh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cosh('1'::float8)" +== 111 +-- truncate_limit: 100 +SELECT tanh(float8 '1') +-- +FUNCTION: name="tanh" function="tanh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tanh('1'::float8)" +== 112 +-- truncate_limit: 100 +SELECT asinh(float8 '1') +-- +FUNCTION: name="asinh" function="asinh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT asinh('1'::float8)" +== 113 +-- truncate_limit: 100 +SELECT acosh(float8 '2') +-- +FUNCTION: name="acosh" function="acosh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT acosh('2'::float8)" +== 114 +-- truncate_limit: 100 +SELECT atanh(float8 '0.5') +-- +FUNCTION: name="atanh" function="atanh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT atanh('0.5'::float8)" +== 115 +-- truncate_limit: 100 +-- test Inf/NaN cases for hyperbolic functions +SELECT sinh(float8 'infinity') +-- +FUNCTION: name="sinh" function="sinh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sinh('infinity'::float8)" +== 116 +-- truncate_limit: 100 +SELECT sinh(float8 '-infinity') +-- +FUNCTION: name="sinh" function="sinh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sinh('-infinity'::float8)" +== 117 +-- truncate_limit: 100 +SELECT sinh(float8 'nan') +-- +FUNCTION: name="sinh" function="sinh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sinh('nan'::float8)" +== 118 +-- truncate_limit: 100 +SELECT cosh(float8 'infinity') +-- +FUNCTION: name="cosh" function="cosh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cosh('infinity'::float8)" +== 119 +-- truncate_limit: 100 +SELECT cosh(float8 '-infinity') +-- +FUNCTION: name="cosh" function="cosh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cosh('-infinity'::float8)" +== 120 +-- truncate_limit: 100 +SELECT cosh(float8 'nan') +-- +FUNCTION: name="cosh" function="cosh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cosh('nan'::float8)" +== 121 +-- truncate_limit: 100 +SELECT tanh(float8 'infinity') +-- +FUNCTION: name="tanh" function="tanh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tanh('infinity'::float8)" +== 122 +-- truncate_limit: 100 +SELECT tanh(float8 '-infinity') +-- +FUNCTION: name="tanh" function="tanh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tanh('-infinity'::float8)" +== 123 +-- truncate_limit: 100 +SELECT tanh(float8 'nan') +-- +FUNCTION: name="tanh" function="tanh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tanh('nan'::float8)" +== 124 +-- truncate_limit: 100 +SELECT asinh(float8 'infinity') +-- +FUNCTION: name="asinh" function="asinh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT asinh('infinity'::float8)" +== 125 +-- truncate_limit: 100 +SELECT asinh(float8 '-infinity') +-- +FUNCTION: name="asinh" function="asinh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT asinh('-infinity'::float8)" +== 126 +-- truncate_limit: 100 +SELECT asinh(float8 'nan') +-- +FUNCTION: name="asinh" function="asinh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT asinh('nan'::float8)" +== 127 +-- truncate_limit: 100 +-- acosh(Inf) should be Inf, but some mingw versions produce NaN, so skip test +-- SELECT acosh(float8 'infinity'); +SELECT acosh(float8 '-infinity') +-- +FUNCTION: name="acosh" function="acosh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT acosh('-infinity'::float8)" +== 128 +-- truncate_limit: 100 +SELECT acosh(float8 'nan') +-- +FUNCTION: name="acosh" function="acosh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT acosh('nan'::float8)" +== 129 +-- truncate_limit: 100 +SELECT atanh(float8 'infinity') +-- +FUNCTION: name="atanh" function="atanh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT atanh('infinity'::float8)" +== 130 +-- truncate_limit: 100 +SELECT atanh(float8 '-infinity') +-- +FUNCTION: name="atanh" function="atanh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT atanh('-infinity'::float8)" +== 131 +-- truncate_limit: 100 +SELECT atanh(float8 'nan') +-- +FUNCTION: name="atanh" function="atanh" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT atanh('nan'::float8)" +== 132 +-- truncate_limit: 100 +-- error functions +-- we run these with extra_float_digits = -1, to get consistently rounded +-- results on all platforms. +SET extra_float_digits = -1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO -1" +== 133 +-- truncate_limit: 100 +SELECT x, + erf(x), + erfc(x) +FROM (VALUES (float8 '-infinity'), + (-28), (-6), (-3.4), (-2.1), (-1.1), (-0.45), + (-1.2e-9), (-2.3e-13), (-1.2e-17), (0), + (1.2e-17), (2.3e-13), (1.2e-9), + (0.45), (1.1), (2.1), (3.4), (6), (28), + (float8 'infinity'), (float8 'nan')) AS t(x) +-- +FUNCTION: name="erf" function="erf" schema="" ctx=Call +FUNCTION: name="erfc" function="erfc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, erf(x), erfc(x) FROM (VALUES (...)) t(x)" +== 134 +-- truncate_limit: 100 +RESET extra_float_digits +-- +STMT: VariableSetStmt +TRUNCATED: "RESET extra_float_digits" +== 135 +-- truncate_limit: 100 +-- test for over- and underflow +INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('10e400')" +== 136 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('-10e400')" +== 137 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('10e-400')" +== 138 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES ('-10e-400')" +== 139 +-- truncate_limit: 100 +DROP TABLE FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE float8_tbl" +== 140 +-- truncate_limit: 100 +-- Check the float8 values exported for use by other tests + +SELECT * FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float8_tbl" +== 141 +-- truncate_limit: 100 +-- test edge-case coercions to integer +SELECT '32767.4'::float8::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '32767.4'::float8::int2" +== 142 +-- truncate_limit: 100 +SELECT '32767.6'::float8::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '32767.6'::float8::int2" +== 143 +-- truncate_limit: 100 +SELECT '-32768.4'::float8::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-32768.4'::float8::int2" +== 144 +-- truncate_limit: 100 +SELECT '-32768.6'::float8::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-32768.6'::float8::int2" +== 145 +-- truncate_limit: 100 +SELECT '2147483647.4'::float8::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647.4'::float8::int4" +== 146 +-- truncate_limit: 100 +SELECT '2147483647.6'::float8::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647.6'::float8::int4" +== 147 +-- truncate_limit: 100 +SELECT '-2147483648.4'::float8::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648.4'::float8::int4" +== 148 +-- truncate_limit: 100 +SELECT '-2147483648.6'::float8::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648.6'::float8::int4" +== 149 +-- truncate_limit: 100 +SELECT '9223372036854773760'::float8::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854773760'::float8::int8" +== 150 +-- truncate_limit: 100 +SELECT '9223372036854775807'::float8::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775807'::float8::int8" +== 151 +-- truncate_limit: 100 +SELECT '-9223372036854775808.5'::float8::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808.5'::float8::int8" +== 152 +-- truncate_limit: 100 +SELECT '-9223372036854780000'::float8::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854780000'::float8::int8" +== 153 +-- truncate_limit: 100 +-- test exact cases for trigonometric functions in degrees + +SELECT x, + sind(x), + sind(x) IN (-1,-0.5,0,0.5,1) AS sind_exact +FROM (VALUES (0), (30), (90), (150), (180), + (210), (270), (330), (360)) AS t(x) +-- +FUNCTION: name="sind" function="sind" schema="" ctx=Call +FUNCTION: name="sind" function="sind" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, sind(x), sind(x) IN (-1, -0.5, 0, 0.5, 1) AS sind_exact FROM (VALUES (...)) t(x)" +== 154 +-- truncate_limit: 100 +SELECT x, + cosd(x), + cosd(x) IN (-1,-0.5,0,0.5,1) AS cosd_exact +FROM (VALUES (0), (60), (90), (120), (180), + (240), (270), (300), (360)) AS t(x) +-- +FUNCTION: name="cosd" function="cosd" schema="" ctx=Call +FUNCTION: name="cosd" function="cosd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, cosd(x), cosd(x) IN (-1, -0.5, 0, 0.5, 1) AS cosd_exact FROM (VALUES (...)) t(x)" +== 155 +-- truncate_limit: 100 +SELECT x, + tand(x), + tand(x) IN ('-Infinity'::float8,-1,0, + 1,'Infinity'::float8) AS tand_exact, + cotd(x), + cotd(x) IN ('-Infinity'::float8,-1,0, + 1,'Infinity'::float8) AS cotd_exact +FROM (VALUES (0), (45), (90), (135), (180), + (225), (270), (315), (360)) AS t(x) +-- +FUNCTION: name="tand" function="tand" schema="" ctx=Call +FUNCTION: name="tand" function="tand" schema="" ctx=Call +FUNCTION: name="cotd" function="cotd" schema="" ctx=Call +FUNCTION: name="cotd" function="cotd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(x)" +== 156 +-- truncate_limit: 100 +SELECT x, + asind(x), + asind(x) IN (-90,-30,0,30,90) AS asind_exact, + acosd(x), + acosd(x) IN (0,60,90,120,180) AS acosd_exact +FROM (VALUES (-1), (-0.5), (0), (0.5), (1)) AS t(x) +-- +FUNCTION: name="asind" function="asind" schema="" ctx=Call +FUNCTION: name="asind" function="asind" schema="" ctx=Call +FUNCTION: name="acosd" function="acosd" schema="" ctx=Call +FUNCTION: name="acosd" function="acosd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(x)" +== 157 +-- truncate_limit: 100 +SELECT x, + atand(x), + atand(x) IN (-90,-45,0,45,90) AS atand_exact +FROM (VALUES ('-Infinity'::float8), (-1), (0), (1), + ('Infinity'::float8)) AS t(x) +-- +FUNCTION: name="atand" function="atand" schema="" ctx=Call +FUNCTION: name="atand" function="atand" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, atand(x), atand(x) IN (-90, -45, 0, 45, 90) AS atand_exact FROM (VALUES (...)) t(x)" +== 158 +-- truncate_limit: 100 +SELECT x, y, + atan2d(y, x), + atan2d(y, x) IN (-90,0,90,180) AS atan2d_exact +FROM (SELECT 10*cosd(a), 10*sind(a) + FROM generate_series(0, 360, 90) AS t(a)) AS t(x,y) +-- +FUNCTION: name="atan2d" function="atan2d" schema="" ctx=Call +FUNCTION: name="atan2d" function="atan2d" schema="" ctx=Call +FUNCTION: name="cosd" function="cosd" schema="" ctx=Call +FUNCTION: name="sind" function="sind" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(0, 360, 90) t(a)) t(x, y)" +== 159 +-- truncate_limit: 100 +|-- +-- test output (and round-trip safety) of various values. +-- To ensure we're testing what we think we're testing, start with +-- float values specified by bit patterns (as a useful side effect, +-- this means we'll fail on non-IEEE platforms). + +create type xfloat8 +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE xfloat8" +== 160 +-- truncate_limit: 100 +create function xfloat8in(cstring) returns xfloat8 immutable strict + language internal as 'int8in' +-- +FUNCTION: name="xfloat8in" function="xfloat8in" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION xfloat8in(cstring) RETURNS xfloat8 IMMUTABLE RETURNS NULL ON NULL INPUT LANGUAGE ..." +== 161 +-- truncate_limit: 100 +create function xfloat8out(xfloat8) returns cstring immutable strict + language internal as 'int8out' +-- +FUNCTION: name="xfloat8out" function="xfloat8out" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION xfloat8out(xfloat8) RETURNS cstring IMMUTABLE RETURNS NULL ON NULL INPUT LANGUAGE..." +== 162 +-- truncate_limit: 100 +create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TYPE xfloat8 (input = xfloat8in, output = xfloat8out, \"like\" = float8)" +== 163 +-- truncate_limit: 100 +create cast (xfloat8 as float8) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (xfloat8 AS float8) WITHOUT FUNCTION" +== 164 +-- truncate_limit: 100 +create cast (float8 as xfloat8) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (float8 AS xfloat8) WITHOUT FUNCTION" +== 165 +-- truncate_limit: 100 +create cast (xfloat8 as bigint) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (xfloat8 AS bigint) WITHOUT FUNCTION" +== 166 +-- truncate_limit: 100 +create cast (bigint as xfloat8) without function +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (bigint AS xfloat8) WITHOUT FUNCTION" +== 167 +-- truncate_limit: 100 +-- float8: seeeeeee eeeeeeee eeeeeeee mmmmmmmm mmmmmmmm(x4) + +-- we don't care to assume the platform's strtod() handles subnormals +-- correctly; those are "use at your own risk". However we do test +-- subnormal outputs, since those are under our control. + +with testdata(bits) as (values + -- small subnormals + (x'0000000000000001'), + (x'0000000000000002'), (x'0000000000000003'), + (x'0000000000001000'), (x'0000000100000000'), + (x'0000010000000000'), (x'0000010100000000'), + (x'0000400000000000'), (x'0000400100000000'), + (x'0000800000000000'), (x'0000800000000001'), + -- these values taken from upstream testsuite + (x'00000000000f4240'), + (x'00000000016e3600'), + (x'0000008cdcdea440'), + -- borderline between subnormal and normal + (x'000ffffffffffff0'), (x'000ffffffffffff1'), + (x'000ffffffffffffe'), (x'000fffffffffffff')) +select float8send(flt) as ibits, + flt + from (select bits::bigint::xfloat8::float8 as flt + from testdata + offset 0) s +-- +CTE: "testdata" +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH testdata(bits) AS (...) SELECT ... FROM (SELECT ... FROM testdata OFFSET 0) s" +== 168 +-- truncate_limit: 100 +-- round-trip tests + +with testdata(bits) as (values + (x'0000000000000000'), + -- smallest normal values + (x'0010000000000000'), (x'0010000000000001'), + (x'0010000000000002'), (x'0018000000000000'), + -- + (x'3ddb7cdfd9d7bdba'), (x'3ddb7cdfd9d7bdbb'), (x'3ddb7cdfd9d7bdbc'), + (x'3e112e0be826d694'), (x'3e112e0be826d695'), (x'3e112e0be826d696'), + (x'3e45798ee2308c39'), (x'3e45798ee2308c3a'), (x'3e45798ee2308c3b'), + (x'3e7ad7f29abcaf47'), (x'3e7ad7f29abcaf48'), (x'3e7ad7f29abcaf49'), + (x'3eb0c6f7a0b5ed8c'), (x'3eb0c6f7a0b5ed8d'), (x'3eb0c6f7a0b5ed8e'), + (x'3ee4f8b588e368ef'), (x'3ee4f8b588e368f0'), (x'3ee4f8b588e368f1'), + (x'3f1a36e2eb1c432c'), (x'3f1a36e2eb1c432d'), (x'3f1a36e2eb1c432e'), + (x'3f50624dd2f1a9fb'), (x'3f50624dd2f1a9fc'), (x'3f50624dd2f1a9fd'), + (x'3f847ae147ae147a'), (x'3f847ae147ae147b'), (x'3f847ae147ae147c'), + (x'3fb9999999999999'), (x'3fb999999999999a'), (x'3fb999999999999b'), + -- values very close to 1 + (x'3feffffffffffff0'), (x'3feffffffffffff1'), (x'3feffffffffffff2'), + (x'3feffffffffffff3'), (x'3feffffffffffff4'), (x'3feffffffffffff5'), + (x'3feffffffffffff6'), (x'3feffffffffffff7'), (x'3feffffffffffff8'), + (x'3feffffffffffff9'), (x'3feffffffffffffa'), (x'3feffffffffffffb'), + (x'3feffffffffffffc'), (x'3feffffffffffffd'), (x'3feffffffffffffe'), + (x'3fefffffffffffff'), + (x'3ff0000000000000'), + (x'3ff0000000000001'), (x'3ff0000000000002'), (x'3ff0000000000003'), + (x'3ff0000000000004'), (x'3ff0000000000005'), (x'3ff0000000000006'), + (x'3ff0000000000007'), (x'3ff0000000000008'), (x'3ff0000000000009'), + -- + (x'3ff921fb54442d18'), + (x'4005bf0a8b14576a'), + (x'400921fb54442d18'), + -- + (x'4023ffffffffffff'), (x'4024000000000000'), (x'4024000000000001'), + (x'4058ffffffffffff'), (x'4059000000000000'), (x'4059000000000001'), + (x'408f3fffffffffff'), (x'408f400000000000'), (x'408f400000000001'), + (x'40c387ffffffffff'), (x'40c3880000000000'), (x'40c3880000000001'), + (x'40f869ffffffffff'), (x'40f86a0000000000'), (x'40f86a0000000001'), + (x'412e847fffffffff'), (x'412e848000000000'), (x'412e848000000001'), + (x'416312cfffffffff'), (x'416312d000000000'), (x'416312d000000001'), + (x'4197d783ffffffff'), (x'4197d78400000000'), (x'4197d78400000001'), + (x'41cdcd64ffffffff'), (x'41cdcd6500000000'), (x'41cdcd6500000001'), + (x'4202a05f1fffffff'), (x'4202a05f20000000'), (x'4202a05f20000001'), + (x'42374876e7ffffff'), (x'42374876e8000000'), (x'42374876e8000001'), + (x'426d1a94a1ffffff'), (x'426d1a94a2000000'), (x'426d1a94a2000001'), + (x'42a2309ce53fffff'), (x'42a2309ce5400000'), (x'42a2309ce5400001'), + (x'42d6bcc41e8fffff'), (x'42d6bcc41e900000'), (x'42d6bcc41e900001'), + (x'430c6bf52633ffff'), (x'430c6bf526340000'), (x'430c6bf526340001'), + (x'4341c37937e07fff'), (x'4341c37937e08000'), (x'4341c37937e08001'), + (x'4376345785d89fff'), (x'4376345785d8a000'), (x'4376345785d8a001'), + (x'43abc16d674ec7ff'), (x'43abc16d674ec800'), (x'43abc16d674ec801'), + (x'43e158e460913cff'), (x'43e158e460913d00'), (x'43e158e460913d01'), + (x'4415af1d78b58c3f'), (x'4415af1d78b58c40'), (x'4415af1d78b58c41'), + (x'444b1ae4d6e2ef4f'), (x'444b1ae4d6e2ef50'), (x'444b1ae4d6e2ef51'), + (x'4480f0cf064dd591'), (x'4480f0cf064dd592'), (x'4480f0cf064dd593'), + (x'44b52d02c7e14af5'), (x'44b52d02c7e14af6'), (x'44b52d02c7e14af7'), + (x'44ea784379d99db3'), (x'44ea784379d99db4'), (x'44ea784379d99db5'), + (x'45208b2a2c280290'), (x'45208b2a2c280291'), (x'45208b2a2c280292'), + -- + (x'7feffffffffffffe'), (x'7fefffffffffffff'), + -- round to even tests (+ve) + (x'4350000000000002'), + (x'4350000000002e06'), + (x'4352000000000003'), + (x'4352000000000004'), + (x'4358000000000003'), + (x'4358000000000004'), + (x'435f000000000020'), + -- round to even tests (-ve) + (x'c350000000000002'), + (x'c350000000002e06'), + (x'c352000000000003'), + (x'c352000000000004'), + (x'c358000000000003'), + (x'c358000000000004'), + (x'c35f000000000020'), + -- exercise fixed-point memmoves + (x'42dc12218377de66'), + (x'42a674e79c5fe51f'), + (x'4271f71fb04cb74c'), + (x'423cbe991a145879'), + (x'4206fee0e1a9e061'), + (x'41d26580b487e6b4'), + (x'419d6f34540ca453'), + (x'41678c29dcd6e9dc'), + (x'4132d687e3df217d'), + (x'40fe240c9fcb68c8'), + (x'40c81cd6e63c53d3'), + (x'40934a4584fd0fdc'), + (x'405edd3c07fb4c93'), + (x'4028b0fcd32f7076'), + (x'3ff3c0ca428c59f8'), + -- these cases come from the upstream's testsuite + -- LotsOfTrailingZeros) + (x'3e60000000000000'), + -- Regression + (x'c352bd2668e077c4'), + (x'434018601510c000'), + (x'43d055dc36f24000'), + (x'43e052961c6f8000'), + (x'3ff3c0ca2a5b1d5d'), + -- LooksLikePow5 + (x'4830f0cf064dd592'), + (x'4840f0cf064dd592'), + (x'4850f0cf064dd592'), + -- OutputLength + (x'3ff3333333333333'), + (x'3ff3ae147ae147ae'), + (x'3ff3be76c8b43958'), + (x'3ff3c083126e978d'), + (x'3ff3c0c1fc8f3238'), + (x'3ff3c0c9539b8887'), + (x'3ff3c0ca2a5b1d5d'), + (x'3ff3c0ca4283de1b'), + (x'3ff3c0ca43db770a'), + (x'3ff3c0ca428abd53'), + (x'3ff3c0ca428c1d2b'), + (x'3ff3c0ca428c51f2'), + (x'3ff3c0ca428c58fc'), + (x'3ff3c0ca428c59dd'), + (x'3ff3c0ca428c59f8'), + (x'3ff3c0ca428c59fb'), + -- 32-bit chunking + (x'40112e0be8047a7d'), + (x'40112e0be815a889'), + (x'40112e0be826d695'), + (x'40112e0be83804a1'), + (x'40112e0be84932ad'), + -- MinMaxShift + (x'0040000000000000'), + (x'007fffffffffffff'), + (x'0290000000000000'), + (x'029fffffffffffff'), + (x'4350000000000000'), + (x'435fffffffffffff'), + (x'1330000000000000'), + (x'133fffffffffffff'), + (x'3a6fa7161a4d6e0c') +) +select float8send(flt) as ibits, + flt, + flt::text::float8 as r_flt, + float8send(flt::text::float8) as obits, + float8send(flt::text::float8) = float8send(flt) as correct + from (select bits::bigint::xfloat8::float8 as flt + from testdata + offset 0) s +-- +CTE: "testdata" +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +FUNCTION: name="float8send" function="float8send" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH testdata(bits) AS (...) SELECT ... FROM (SELECT ... FROM testdata OFFSET 0) s" +== 169 +-- truncate_limit: 100 +-- clean up, lest opr_sanity complain +drop type xfloat8 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE xfloat8 CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/foreign_data.metadata.json b/parser/testdata/summary_truncate/postgres_regress/foreign_data.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/foreign_data.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/foreign_data.test b/parser/testdata/summary_truncate/postgres_regress/foreign_data.test new file mode 100644 index 0000000..44c2d65 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/foreign_data.test @@ -0,0 +1,3708 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test foreign-data wrapper and server management. +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION test_fdw_handler() + RETURNS fdw_handler + AS :'regresslib', 'test_fdw_handler' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 202 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +-- Clean up in case a prior regression run failed + +-- Suppress NOTICE messages when roles don't exist +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 003 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_foreign_data_user, regress_test_role, regress_test_role2, regress_test_role_super, regress_test_indirect, regress_unprivileged_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_foreign_data_user, regress_test_role, regress_test_role2, regress_tes..." +== 004 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 005 +-- truncate_limit: 100 +CREATE ROLE regress_foreign_data_user LOGIN SUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_foreign_data_user WITH LOGIN SUPERUSER" +== 006 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION 'regress_foreign_data_user' +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_foreign_data_user" +== 007 +-- truncate_limit: 100 +CREATE ROLE regress_test_role +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_role" +== 008 +-- truncate_limit: 100 +CREATE ROLE regress_test_role2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_role2" +== 009 +-- truncate_limit: 100 +CREATE ROLE regress_test_role_super SUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_role_super WITH SUPERUSER" +== 010 +-- truncate_limit: 100 +CREATE ROLE regress_test_indirect +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_indirect" +== 011 +-- truncate_limit: 100 +CREATE ROLE regress_unprivileged_role +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_unprivileged_role" +== 012 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER dummy +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER dummy" +== 013 +-- truncate_limit: 100 +COMMENT ON FOREIGN DATA WRAPPER dummy IS 'useless' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON FOREIGN DATA WRAPPER dummy IS 'useless'" +== 014 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator" +== 015 +-- truncate_limit: 100 +-- At this point we should have 2 built-in wrappers and no servers. +SELECT fdwname, fdwhandler::regproc, fdwvalidator::regproc, fdwoptions FROM pg_foreign_data_wrapper ORDER BY 1, 2, 3 +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_foreign_data_wrapper ORDER BY 1, 2, 3" +== 016 +-- truncate_limit: 100 +SELECT srvname, srvoptions FROM pg_foreign_server +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT srvname, srvoptions FROM pg_foreign_server" +== 017 +-- truncate_limit: 100 +SELECT * FROM pg_user_mapping +-- +TABLE: name="pg_user_mapping" schema="" table="pg_user_mapping" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_user_mapping" +== 018 +-- truncate_limit: 100 +-- CREATE FOREIGN DATA WRAPPER +CREATE FOREIGN DATA WRAPPER foo VALIDATOR bar +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo VALIDATOR bar" +== 019 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN DATA WRAPPER foo +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo" +== 020 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER foo +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo" +== 021 +-- truncate_limit: 100 +-- duplicate +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo" +== 022 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1') +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1')" +== 023 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo" +== 024 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1', testing '2') +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1', testing '2')" +== 025 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1', another '2') +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo OPTIONS (testing '1', another '2')" +== 026 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo" +== 027 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 028 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER foo +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo" +== 029 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 030 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator" +== 031 +-- truncate_limit: 100 +-- HANDLER related checks +CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;' +-- +FUNCTION: name="invalid_fdw_handler" function="invalid_fdw_handler" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE sql AS $$SELECT 1;$$" +== 032 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler" +== 033 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler" +== 034 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler" +== 035 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER test_fdw +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER test_fdw" +== 036 +-- truncate_limit: 100 +-- ALTER FOREIGN DATA WRAPPER +ALTER FOREIGN DATA WRAPPER foo OPTIONS (nonexistent 'fdw') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (nonexistent 'fdw')" +== 037 +-- truncate_limit: 100 +-- ERROR + +ALTER FOREIGN DATA WRAPPER foo +-- +ERROR: syntax error at end of input +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 038 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo VALIDATOR bar +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo VALIDATOR bar" +== 039 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo NO VALIDATOR +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo NO VALIDATOR" +== 040 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (a '1', b '2') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (a '1', b '2')" +== 041 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (SET c '4') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (SET c '4')" +== 042 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OPTIONS (DROP c) +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (DROP c)" +== 043 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD x '1', DROP x) +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD x '1', DROP x)" +== 044 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (DROP a, SET b '3', ADD c '4') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (DROP a, SET b '3', ADD c '4')" +== 045 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (a '2') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (a '2')" +== 046 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (b '4') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (b '4')" +== 047 +-- truncate_limit: 100 +-- ERROR + +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 048 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD d '5') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD d '5')" +== 049 +-- truncate_limit: 100 +-- ERROR +SET ROLE regress_test_role_super +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role_super" +== 050 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD d '5') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD d '5')" +== 051 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_test_role" +== 052 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_test_role_super +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_test_role_super" +== 053 +-- truncate_limit: 100 +ALTER ROLE regress_test_role_super NOSUPERUSER +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_role_super WITH NOSUPERUSER" +== 054 +-- truncate_limit: 100 +SET ROLE regress_test_role_super +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role_super" +== 055 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD e '6') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (ADD e '6')" +== 056 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 057 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo RENAME TO foo1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo RENAME TO foo1" +== 058 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo1 RENAME TO foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo1 RENAME TO foo" +== 059 +-- truncate_limit: 100 +-- HANDLER related checks +ALTER FOREIGN DATA WRAPPER foo HANDLER invalid_fdw_handler +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo HANDLER invalid_fdw_handler" +== 060 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler HANDLER anything +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler HANDLER anything" +== 061 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo HANDLER test_fdw_handler" +== 062 +-- truncate_limit: 100 +DROP FUNCTION invalid_fdw_handler() +-- +FUNCTION: name="invalid_fdw_handler" function="invalid_fdw_handler" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION invalid_fdw_handler()" +== 063 +-- truncate_limit: 100 +-- DROP FOREIGN DATA WRAPPER +DROP FOREIGN DATA WRAPPER nonexistent +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER nonexistent" +== 064 +-- truncate_limit: 100 +-- ERROR +DROP FOREIGN DATA WRAPPER IF EXISTS nonexistent +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER IF EXISTS nonexistent" +== 065 +-- truncate_limit: 100 +DROP ROLE regress_test_role_super +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role_super" +== 066 +-- truncate_limit: 100 +-- ERROR +SET ROLE regress_test_role_super +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role_super" +== 067 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo" +== 068 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 069 +-- truncate_limit: 100 +DROP ROLE regress_test_role_super +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role_super" +== 070 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER foo +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo" +== 071 +-- truncate_limit: 100 +CREATE SERVER s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s1 FOREIGN DATA WRAPPER foo" +== 072 +-- truncate_limit: 100 +COMMENT ON SERVER s1 IS 'foreign server' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON SERVER s1 IS 'foreign server'" +== 073 +-- truncate_limit: 100 +CREATE USER MAPPING FOR current_user SERVER s1 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s1" +== 074 +-- truncate_limit: 100 +CREATE USER MAPPING FOR current_user SERVER s1 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s1" +== 075 +-- truncate_limit: 100 +-- ERROR +CREATE USER MAPPING IF NOT EXISTS FOR current_user SERVER s1 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING IF NOT EXISTS FOR CURRENT_USER SERVER s1" +== 076 +-- truncate_limit: 100 +-- NOTICE +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo" +== 077 +-- truncate_limit: 100 +-- ERROR +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 078 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER foo CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo CASCADE" +== 079 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 080 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER foo CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo CASCADE" +== 081 +-- truncate_limit: 100 +-- exercise CREATE SERVER +CREATE SERVER s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s1 FOREIGN DATA WRAPPER foo" +== 082 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN DATA WRAPPER foo OPTIONS ("test wrapper" 'true') +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foo OPTIONS (\"test wrapper\" 'true')" +== 083 +-- truncate_limit: 100 +CREATE SERVER s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s1 FOREIGN DATA WRAPPER foo" +== 084 +-- truncate_limit: 100 +CREATE SERVER s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s1 FOREIGN DATA WRAPPER foo" +== 085 +-- truncate_limit: 100 +-- ERROR +CREATE SERVER IF NOT EXISTS s1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER IF NOT EXISTS s1 FOREIGN DATA WRAPPER foo" +== 086 +-- truncate_limit: 100 +-- No ERROR, just NOTICE +CREATE SERVER s2 FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b') +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s2 FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b')" +== 087 +-- truncate_limit: 100 +CREATE SERVER s3 TYPE 'oracle' FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s3 TYPE 'oracle' FOREIGN DATA WRAPPER foo" +== 088 +-- truncate_limit: 100 +CREATE SERVER s4 TYPE 'oracle' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b') +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s4 TYPE 'oracle' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b')" +== 089 +-- truncate_limit: 100 +CREATE SERVER s5 VERSION '15.0' FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s5 VERSION '15.0' FOREIGN DATA WRAPPER foo" +== 090 +-- truncate_limit: 100 +CREATE SERVER s6 VERSION '16.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b') +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s6 VERSION '16.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b')" +== 091 +-- truncate_limit: 100 +CREATE SERVER s7 TYPE 'oracle' VERSION '17.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname 'b') +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s7 TYPE 'oracle' VERSION '17.0' FOREIGN DATA WRAPPER foo OPTIONS (host 'a', dbname ..." +== 092 +-- truncate_limit: 100 +CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (foo '1') +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (foo '1')" +== 093 +-- truncate_limit: 100 +-- ERROR +CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (host 'localhost', dbname 's8db') +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s8 FOREIGN DATA WRAPPER postgresql OPTIONS (host 'localhost', dbname 's8db')" +== 094 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 095 +-- truncate_limit: 100 +CREATE SERVER t1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER t1 FOREIGN DATA WRAPPER foo" +== 096 +-- truncate_limit: 100 +-- ERROR: no usage on FDW +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 097 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER foo TO regress_test_role" +== 098 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 099 +-- truncate_limit: 100 +CREATE SERVER t1 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER t1 FOREIGN DATA WRAPPER foo" +== 100 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 101 +-- truncate_limit: 100 +REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON FOREIGN DATA WRAPPER foo FROM regress_test_role" +== 102 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_indirect +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER foo TO regress_test_indirect" +== 103 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 104 +-- truncate_limit: 100 +CREATE SERVER t2 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER t2 FOREIGN DATA WRAPPER foo" +== 105 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 106 +-- truncate_limit: 100 +GRANT regress_test_indirect TO regress_test_role +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_test_indirect TO regress_test_role" +== 107 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 108 +-- truncate_limit: 100 +CREATE SERVER t2 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER t2 FOREIGN DATA WRAPPER foo" +== 109 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 110 +-- truncate_limit: 100 +REVOKE regress_test_indirect FROM regress_test_role +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE regress_test_indirect FROM regress_test_role" +== 111 +-- truncate_limit: 100 +-- ALTER SERVER +ALTER SERVER s0 +-- +ERROR: syntax error at end of input +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 112 +-- truncate_limit: 100 +-- ERROR +ALTER SERVER s0 OPTIONS (a '1') +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s0 OPTIONS (a '1')" +== 113 +-- truncate_limit: 100 +-- ERROR +ALTER SERVER s1 VERSION '1.0' OPTIONS (servername 's1') +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s1 VERSION '1.0' OPTIONS (servername 's1')" +== 114 +-- truncate_limit: 100 +ALTER SERVER s2 VERSION '1.1' +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s2 VERSION '1.1'" +== 115 +-- truncate_limit: 100 +ALTER SERVER s3 OPTIONS ("tns name" 'orcl', port '1521') +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s3 OPTIONS (\"tns name\" 'orcl', port '1521')" +== 116 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN SERVER s1 TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s1 TO regress_test_role" +== 117 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN SERVER s6 TO regress_test_role2 WITH GRANT OPTION +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s6 TO regress_test_role2 WITH GRANT OPTION" +== 118 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 119 +-- truncate_limit: 100 +ALTER SERVER s1 VERSION '1.1' +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s1 VERSION '1.1'" +== 120 +-- truncate_limit: 100 +-- ERROR +ALTER SERVER s1 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s1 OWNER TO regress_test_role" +== 121 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 122 +-- truncate_limit: 100 +ALTER SERVER s1 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s1 OWNER TO regress_test_role" +== 123 +-- truncate_limit: 100 +GRANT regress_test_role2 TO regress_test_role +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_test_role2 TO regress_test_role" +== 124 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 125 +-- truncate_limit: 100 +ALTER SERVER s1 VERSION '1.1' +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s1 VERSION '1.1'" +== 126 +-- truncate_limit: 100 +ALTER SERVER s1 OWNER TO regress_test_role2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s1 OWNER TO regress_test_role2" +== 127 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 128 +-- truncate_limit: 100 +ALTER SERVER s8 OPTIONS (foo '1') +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s8 OPTIONS (foo '1')" +== 129 +-- truncate_limit: 100 +-- ERROR option validation +ALTER SERVER s8 OPTIONS (connect_timeout '30', SET dbname 'db1', DROP host) +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s8 OPTIONS (connect_timeout '30', SET dbname 'db1', DROP host)" +== 130 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 131 +-- truncate_limit: 100 +ALTER SERVER s1 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s1 OWNER TO regress_test_indirect" +== 132 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 133 +-- truncate_limit: 100 +GRANT regress_test_indirect TO regress_test_role +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_test_indirect TO regress_test_role" +== 134 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 135 +-- truncate_limit: 100 +ALTER SERVER s1 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s1 OWNER TO regress_test_indirect" +== 136 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 137 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_indirect +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER foo TO regress_test_indirect" +== 138 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 139 +-- truncate_limit: 100 +ALTER SERVER s1 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s1 OWNER TO regress_test_indirect" +== 140 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 141 +-- truncate_limit: 100 +DROP ROLE regress_test_indirect +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_indirect" +== 142 +-- truncate_limit: 100 +-- ERROR + +ALTER SERVER s8 RENAME to s8new +-- +STMT: RenameStmt +TRUNCATED: "ALTER SERVER s8 RENAME TO s8new" +== 143 +-- truncate_limit: 100 +ALTER SERVER s8new RENAME to s8 +-- +STMT: RenameStmt +TRUNCATED: "ALTER SERVER s8new RENAME TO s8" +== 144 +-- truncate_limit: 100 +-- DROP SERVER +DROP SERVER nonexistent +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER nonexistent" +== 145 +-- truncate_limit: 100 +-- ERROR +DROP SERVER IF EXISTS nonexistent +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER IF EXISTS nonexistent" +== 146 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 147 +-- truncate_limit: 100 +DROP SERVER s2 +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s2" +== 148 +-- truncate_limit: 100 +-- ERROR +DROP SERVER s1 +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s1" +== 149 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 150 +-- truncate_limit: 100 +ALTER SERVER s2 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s2 OWNER TO regress_test_role" +== 151 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 152 +-- truncate_limit: 100 +DROP SERVER s2 +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s2" +== 153 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 154 +-- truncate_limit: 100 +CREATE USER MAPPING FOR current_user SERVER s3 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s3" +== 155 +-- truncate_limit: 100 +DROP SERVER s3 +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s3" +== 156 +-- truncate_limit: 100 +-- ERROR +DROP SERVER s3 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s3 CASCADE" +== 157 +-- truncate_limit: 100 +-- CREATE USER MAPPING +CREATE USER MAPPING FOR regress_test_missing_role SERVER s1 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR regress_test_missing_role SERVER s1" +== 158 +-- truncate_limit: 100 +-- ERROR +CREATE USER MAPPING FOR current_user SERVER s1 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s1" +== 159 +-- truncate_limit: 100 +-- ERROR +CREATE USER MAPPING FOR current_user SERVER s4 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s4" +== 160 +-- truncate_limit: 100 +CREATE USER MAPPING FOR user SERVER s4 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s4" +== 161 +-- truncate_limit: 100 +-- ERROR duplicate +CREATE USER MAPPING FOR public SERVER s4 OPTIONS ("this mapping" 'is public') +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR public SERVER s4 OPTIONS (\"this mapping\" 'is public')" +== 162 +-- truncate_limit: 100 +CREATE USER MAPPING FOR user SERVER s8 OPTIONS (username 'test', password 'secret') +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s8 OPTIONS (username 'test', password 'secret')" +== 163 +-- truncate_limit: 100 +-- ERROR +CREATE USER MAPPING FOR user SERVER s8 OPTIONS (user 'test', password 'secret') +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s8 OPTIONS (\"user\" 'test', password 'secret')" +== 164 +-- truncate_limit: 100 +ALTER SERVER s5 OWNER TO regress_test_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s5 OWNER TO regress_test_role" +== 165 +-- truncate_limit: 100 +ALTER SERVER s6 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s6 OWNER TO regress_test_indirect" +== 166 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 167 +-- truncate_limit: 100 +CREATE USER MAPPING FOR current_user SERVER s5 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s5" +== 168 +-- truncate_limit: 100 +CREATE USER MAPPING FOR current_user SERVER s6 OPTIONS (username 'test') +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s6 OPTIONS (username 'test')" +== 169 +-- truncate_limit: 100 +CREATE USER MAPPING FOR current_user SERVER s7 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s7" +== 170 +-- truncate_limit: 100 +-- ERROR +CREATE USER MAPPING FOR public SERVER s8 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR public SERVER s8" +== 171 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 172 +-- truncate_limit: 100 +ALTER SERVER t1 OWNER TO regress_test_indirect +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER t1 OWNER TO regress_test_indirect" +== 173 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 174 +-- truncate_limit: 100 +CREATE USER MAPPING FOR current_user SERVER t1 OPTIONS (username 'bob', password 'boo') +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER t1 OPTIONS (username 'bob', password 'boo')" +== 175 +-- truncate_limit: 100 +CREATE USER MAPPING FOR public SERVER t1 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR public SERVER t1" +== 176 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 177 +-- truncate_limit: 100 +-- ALTER USER MAPPING +ALTER USER MAPPING FOR regress_test_missing_role SERVER s4 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR regress_test_missing_role SERVER s4 OPTIONS (gotcha 'true')" +== 178 +-- truncate_limit: 100 +-- ERROR +ALTER USER MAPPING FOR user SERVER ss4 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR CURRENT_USER SERVER ss4 OPTIONS (gotcha 'true')" +== 179 +-- truncate_limit: 100 +-- ERROR +ALTER USER MAPPING FOR public SERVER s5 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR public SERVER s5 OPTIONS (gotcha 'true')" +== 180 +-- truncate_limit: 100 +-- ERROR +ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (username 'test') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR CURRENT_USER SERVER s8 OPTIONS (username 'test')" +== 181 +-- truncate_limit: 100 +-- ERROR +ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (DROP user, SET password 'public') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR CURRENT_USER SERVER s8 OPTIONS (DROP \"user\", SET password 'public')" +== 182 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 183 +-- truncate_limit: 100 +ALTER USER MAPPING FOR current_user SERVER s5 OPTIONS (ADD modified '1') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR CURRENT_USER SERVER s5 OPTIONS (ADD modified '1')" +== 184 +-- truncate_limit: 100 +ALTER USER MAPPING FOR public SERVER s4 OPTIONS (ADD modified '1') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR public SERVER s4 OPTIONS (ADD modified '1')" +== 185 +-- truncate_limit: 100 +-- ERROR +ALTER USER MAPPING FOR public SERVER t1 OPTIONS (ADD modified '1') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR public SERVER t1 OPTIONS (ADD modified '1')" +== 186 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 187 +-- truncate_limit: 100 +-- DROP USER MAPPING +DROP USER MAPPING FOR regress_test_missing_role SERVER s4 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR regress_test_missing_role SERVER s4" +== 188 +-- truncate_limit: 100 +-- ERROR +DROP USER MAPPING FOR user SERVER ss4 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR CURRENT_USER SERVER ss4" +== 189 +-- truncate_limit: 100 +DROP USER MAPPING FOR public SERVER s7 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR public SERVER s7" +== 190 +-- truncate_limit: 100 +-- ERROR +DROP USER MAPPING IF EXISTS FOR regress_test_missing_role SERVER s4 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING IF EXISTS FOR regress_test_missing_role SERVER s4" +== 191 +-- truncate_limit: 100 +DROP USER MAPPING IF EXISTS FOR user SERVER ss4 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING IF EXISTS FOR CURRENT_USER SERVER ss4" +== 192 +-- truncate_limit: 100 +DROP USER MAPPING IF EXISTS FOR public SERVER s7 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING IF EXISTS FOR public SERVER s7" +== 193 +-- truncate_limit: 100 +CREATE USER MAPPING FOR public SERVER s8 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR public SERVER s8" +== 194 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 195 +-- truncate_limit: 100 +DROP USER MAPPING FOR public SERVER s8 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR public SERVER s8" +== 196 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 197 +-- truncate_limit: 100 +DROP SERVER s7 +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s7" +== 198 +-- truncate_limit: 100 +-- CREATE FOREIGN TABLE +CREATE SCHEMA foreign_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA foreign_schema" +== 199 +-- truncate_limit: 100 +CREATE SERVER s0 FOREIGN DATA WRAPPER dummy +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s0 FOREIGN DATA WRAPPER dummy" +== 200 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft1 () +-- +ERROR: syntax error at end of input +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 201 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN TABLE ft1 () SERVER no_server +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft1 () SERVER no_server" +== 202 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN TABLE ft1 ( + c1 integer OPTIONS ("param 1" 'val1') PRIMARY KEY, + c2 text OPTIONS (param2 'val2', param3 'val3'), + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft1 (c1 int OPTIONS (\"param 1\" 'val1') PRIMARY KEY, c2 text OPTIONS (param2 ..." +== 203 +-- truncate_limit: 100 +-- ERROR +CREATE TABLE ref_table (id integer PRIMARY KEY) +-- +TABLE: name="ref_table" schema="" table="ref_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref_table (id int PRIMARY KEY)" +== 204 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft1 ( + c1 integer OPTIONS ("param 1" 'val1') REFERENCES ref_table (id), + c2 text OPTIONS (param2 'val2', param3 'val3'), + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft1 (c1 int OPTIONS (\"param 1\" 'val1') REFERENCES ref_table (id), c2 text OP..." +== 205 +-- truncate_limit: 100 +-- ERROR +DROP TABLE ref_table +-- +TABLE: name="ref_table" schema="" table="ref_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ref_table" +== 206 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft1 ( + c1 integer OPTIONS ("param 1" 'val1') NOT NULL, + c2 text OPTIONS (param2 'val2', param3 'val3'), + c3 date, + UNIQUE (c3) +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft1 (c1 int OPTIONS (\"param 1\" 'val1') NOT NULL, c2 text OPTIONS (param2 'va..." +== 207 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN TABLE ft1 ( + c1 integer OPTIONS ("param 1" 'val1') NOT NULL, + c2 text OPTIONS (param2 'val2', param3 'val3') CHECK (c2 <> ''), + c3 date, + CHECK (c3 BETWEEN '1994-01-01'::date AND '1994-01-31'::date) +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft1 (c1 int OPTIONS (\"param 1\" 'val1') NOT NULL, c2 text OPTIONS (param2 'va..." +== 208 +-- truncate_limit: 100 +COMMENT ON FOREIGN TABLE ft1 IS 'ft1' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON FOREIGN TABLE ft1 IS 'ft1'" +== 209 +-- truncate_limit: 100 +COMMENT ON COLUMN ft1.c1 IS 'ft1.c1' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN ft1.c1 IS 'ft1.c1'" +== 210 +-- truncate_limit: 100 +CREATE INDEX id_ft1_c2 ON ft1 (c2) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX id_ft1_c2 ON ft1 USING btree (c2)" +== 211 +-- truncate_limit: 100 +-- ERROR +SELECT * FROM ft1 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ft1" +== 212 +-- truncate_limit: 100 +-- ERROR +EXPLAIN SELECT * FROM ft1 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN SELECT * FROM ft1" +== 213 +-- truncate_limit: 100 +-- ERROR + +CREATE TABLE lt1 (a INT) PARTITION BY RANGE (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lt1 (a int) PARTITION BY RANGE (a)" +== 214 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft_part1 + PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part1 PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0" +== 215 +-- truncate_limit: 100 +CREATE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON lt1 USING btree (a)" +== 216 +-- truncate_limit: 100 +-- skips partition +CREATE UNIQUE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON lt1 USING btree (a)" +== 217 +-- truncate_limit: 100 +-- ERROR +ALTER TABLE lt1 ADD PRIMARY KEY (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE lt1 ADD PRIMARY KEY (a)" +== 218 +-- truncate_limit: 100 +-- ERROR +DROP TABLE lt1 +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lt1" +== 219 +-- truncate_limit: 100 +CREATE TABLE lt1 (a INT) PARTITION BY RANGE (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lt1 (a int) PARTITION BY RANGE (a)" +== 220 +-- truncate_limit: 100 +CREATE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON lt1 USING btree (a)" +== 221 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft_part1 + PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part1 PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0" +== 222 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft_part2 (a INT) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part2 (a int) SERVER s0" +== 223 +-- truncate_limit: 100 +ALTER TABLE lt1 ATTACH PARTITION ft_part2 FOR VALUES FROM (1000) TO (2000) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE lt1 ATTACH PARTITION ft_part2 FOR VALUES FROM (1000) TO (2000)" +== 224 +-- truncate_limit: 100 +DROP FOREIGN TABLE ft_part1, ft_part2 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE ft_part1, ft_part2" +== 225 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON lt1 USING btree (a)" +== 226 +-- truncate_limit: 100 +ALTER TABLE lt1 ADD PRIMARY KEY (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE lt1 ADD PRIMARY KEY (a)" +== 227 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft_part1 + PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part1 PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) SERVER s0" +== 228 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN TABLE ft_part2 (a INT NOT NULL) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part2 (a int NOT NULL) SERVER s0" +== 229 +-- truncate_limit: 100 +ALTER TABLE lt1 ATTACH PARTITION ft_part2 + FOR VALUES FROM (1000) TO (2000) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE lt1 ATTACH PARTITION ft_part2 FOR VALUES FROM (1000) TO (2000)" +== 230 +-- truncate_limit: 100 +-- ERROR +DROP TABLE lt1 +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lt1" +== 231 +-- truncate_limit: 100 +DROP FOREIGN TABLE ft_part2 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE ft_part2" +== 232 +-- truncate_limit: 100 +CREATE TABLE lt1 (a INT) PARTITION BY RANGE (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lt1 (a int) PARTITION BY RANGE (a)" +== 233 +-- truncate_limit: 100 +CREATE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON lt1 USING btree (a)" +== 234 +-- truncate_limit: 100 +CREATE TABLE lt1_part1 + PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) + PARTITION BY RANGE (a) +-- +TABLE: name="lt1_part1" schema="" table="lt1_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lt1_part1 PARTITION OF lt1 FOR VALUES FROM (0) TO (1000) PARTITION BY RANGE (a)" +== 235 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft_part_1_1 + PARTITION OF lt1_part1 FOR VALUES FROM (0) TO (100) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part_1_1 PARTITION OF lt1_part1 FOR VALUES FROM (0) TO (100) SERVER s0" +== 236 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft_part_1_2 (a INT) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part_1_2 (a int) SERVER s0" +== 237 +-- truncate_limit: 100 +ALTER TABLE lt1_part1 ATTACH PARTITION ft_part_1_2 FOR VALUES FROM (100) TO (200) +-- +TABLE: name="lt1_part1" schema="" table="lt1_part1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE lt1_part1 ATTACH PARTITION ft_part_1_2 FOR VALUES FROM (100) TO (200)" +== 238 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON lt1 USING btree (a)" +== 239 +-- truncate_limit: 100 +ALTER TABLE lt1 ADD PRIMARY KEY (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE lt1 ADD PRIMARY KEY (a)" +== 240 +-- truncate_limit: 100 +DROP FOREIGN TABLE ft_part_1_1, ft_part_1_2 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE ft_part_1_1, ft_part_1_2" +== 241 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON lt1 (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON lt1 USING btree (a)" +== 242 +-- truncate_limit: 100 +ALTER TABLE lt1 ADD PRIMARY KEY (a) +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE lt1 ADD PRIMARY KEY (a)" +== 243 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft_part_1_1 + PARTITION OF lt1_part1 FOR VALUES FROM (0) TO (100) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part_1_1 PARTITION OF lt1_part1 FOR VALUES FROM (0) TO (100) SERVER s0" +== 244 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft_part_1_2 (a INT NOT NULL) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft_part_1_2 (a int NOT NULL) SERVER s0" +== 245 +-- truncate_limit: 100 +ALTER TABLE lt1_part1 ATTACH PARTITION ft_part_1_2 FOR VALUES FROM (100) TO (200) +-- +TABLE: name="lt1_part1" schema="" table="lt1_part1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE lt1_part1 ATTACH PARTITION ft_part_1_2 FOR VALUES FROM (100) TO (200)" +== 246 +-- truncate_limit: 100 +DROP TABLE lt1 +-- +TABLE: name="lt1" schema="" table="lt1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lt1" +== 247 +-- truncate_limit: 100 +DROP FOREIGN TABLE ft_part_1_2 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE ft_part_1_2" +== 248 +-- truncate_limit: 100 +-- ALTER FOREIGN TABLE +COMMENT ON FOREIGN TABLE ft1 IS 'foreign table' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON FOREIGN TABLE ft1 IS 'foreign table'" +== 249 +-- truncate_limit: 100 +COMMENT ON FOREIGN TABLE ft1 IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON FOREIGN TABLE ft1 IS NULL" +== 250 +-- truncate_limit: 100 +COMMENT ON COLUMN ft1.c1 IS 'foreign column' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN ft1.c1 IS 'foreign column'" +== 251 +-- truncate_limit: 100 +COMMENT ON COLUMN ft1.c1 IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON COLUMN ft1.c1 IS NULL" +== 252 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c4 integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c4 int" +== 253 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c5 integer DEFAULT 0 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c5 int DEFAULT 0" +== 254 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c6 integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c6 int" +== 255 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c7 integer NOT NULL +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c7 int NOT NULL" +== 256 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c8 integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c8 int" +== 257 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c9 integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c9 int" +== 258 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c10 integer OPTIONS (p1 'v1') +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c10 int OPTIONS (p1 'v1')" +== 259 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c4 SET DEFAULT 0 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c4 SET DEFAULT 0" +== 260 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c5 DROP DEFAULT +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c5 DROP DEFAULT" +== 261 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c6 SET NOT NULL +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c6 SET NOT NULL" +== 262 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 DROP NOT NULL +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 DROP NOT NULL" +== 263 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) USING '0' +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) USING '0'" +== 264 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE char(10)" +== 265 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET DATA TYPE text +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE text" +== 266 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN xmin OPTIONS (ADD p1 'v1') +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN xmin OPTIONS (ADD p1 'v1')" +== 267 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2'), + ALTER COLUMN c8 OPTIONS (ADD p1 'v1', ADD p2 'v2') +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2') , ALTER COLUMN c8 OPTI..." +== 268 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1)" +== 269 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET STATISTICS 10000 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET STATISTICS 10000" +== 270 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET (n_distinct = 100) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 SET (n_distinct=100)" +== 271 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STATISTICS -1 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STATISTICS -1" +== 272 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STORAGE PLAIN +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET STORAGE plain" +== 273 +-- truncate_limit: 100 +-- can't change the column type if it's used elsewhere +CREATE TABLE use_ft1_column_type (x ft1) +-- +TABLE: name="use_ft1_column_type" schema="" table="use_ft1_column_type" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE use_ft1_column_type (x ft1)" +== 274 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 SET DATA TYPE integer +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE int" +== 275 +-- truncate_limit: 100 +-- ERROR +DROP TABLE use_ft1_column_type +-- +TABLE: name="use_ft1_column_type" schema="" table="use_ft1_column_type" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE use_ft1_column_type" +== 276 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD PRIMARY KEY (c7) +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD PRIMARY KEY (c7)" +== 277 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c9_check CHECK (c9 < 0) NOT VALID +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c9_check CHECK (c9 < 0) NOT VALID" +== 278 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ALTER CONSTRAINT ft1_c9_check DEFERRABLE +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ALTER CONSTRAINT ft1_c9_check DEFERRABLE" +== 279 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c9_check +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c9_check" +== 280 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 DROP CONSTRAINT no_const +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 DROP CONSTRAINT no_const" +== 281 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE ft1 DROP CONSTRAINT IF EXISTS no_const +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 DROP CONSTRAINT IF EXISTS no_const" +== 282 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 OWNER TO regress_test_role +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 OWNER TO regress_test_role" +== 283 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@') +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@')" +== 284 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 DROP COLUMN no_column +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 DROP no_column" +== 285 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE ft1 DROP COLUMN IF EXISTS no_column +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 DROP IF EXISTS no_column" +== 286 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 DROP COLUMN c9 +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 DROP c9" +== 287 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 ADD COLUMN c11 serial +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 ADD COLUMN c11 serial" +== 288 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 SET SCHEMA foreign_schema +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 SET SCHEMA foreign_schema" +== 289 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft1 SET TABLESPACE ts +-- +TABLE: name="ft1" schema="" table="ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft1 SET TABLESPACE ts" +== 290 +-- truncate_limit: 100 +-- ERROR +ALTER SEQUENCE foreign_schema.ft1_c11_seq SET SCHEMA public +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER SEQUENCE foreign_schema.ft1_c11_seq SET SCHEMA public" +== 291 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE foreign_schema.ft1 RENAME c1 TO foreign_column_1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER FOREIGN TABLE foreign_schema.ft1 RENAME COLUMN c1 TO foreign_column_1" +== 292 +-- truncate_limit: 100 +ALTER FOREIGN TABLE foreign_schema.ft1 RENAME TO foreign_table_1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER FOREIGN TABLE foreign_schema.ft1 RENAME TO foreign_table_1" +== 293 +-- truncate_limit: 100 +-- alter noexisting table +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c4 integer +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c4 int" +== 294 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c6 integer +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c6 int" +== 295 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c7 integer NOT NULL +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c7 int NOT NULL" +== 296 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c8 integer +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c8 int" +== 297 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c9 integer +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c9 int" +== 298 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c10 integer OPTIONS (p1 'v1') +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ADD COLUMN c10 int OPTIONS (p1 'v1')" +== 299 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c6 SET NOT NULL +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c6 SET NOT NULL" +== 300 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c7 DROP NOT NULL +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c7 DROP NOT NULL" +== 301 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 TYPE char(10) +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 TYPE char(10)" +== 302 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 SET DATA TYPE text +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 TYPE text" +== 303 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2'), + ALTER COLUMN c8 OPTIONS (ADD p1 'v1', ADD p2 'v2') +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c7 OPTIONS (ADD p1 'v1', ADD p2 'v2')..." +== 304 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1) +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 ALTER COLUMN c8 OPTIONS (SET p2 'V2', DROP p1)" +== 305 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP CONSTRAINT IF EXISTS no_const +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP CONSTRAINT IF EXISTS no_const" +== 306 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP CONSTRAINT ft1_c1_check +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP CONSTRAINT ft1_c1_check" +== 307 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 OWNER TO regress_test_role +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 OWNER TO regress_test_role" +== 308 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape '@') +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 OPTIONS (DROP delimiter, SET quote '~', ADD escape..." +== 309 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP COLUMN IF EXISTS no_column +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP IF EXISTS no_column" +== 310 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP COLUMN c9 +-- +TABLE: name="doesnt_exist_ft1" schema="" table="doesnt_exist_ft1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 DROP c9" +== 311 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 SET SCHEMA foreign_schema +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 SET SCHEMA foreign_schema" +== 312 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 RENAME c1 TO foreign_column_1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 RENAME COLUMN c1 TO foreign_column_1" +== 313 +-- truncate_limit: 100 +ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 RENAME TO foreign_table_1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER FOREIGN TABLE IF EXISTS doesnt_exist_ft1 RENAME TO foreign_table_1" +== 314 +-- truncate_limit: 100 +-- Information schema + +SELECT * FROM information_schema.foreign_data_wrappers ORDER BY 1, 2 +-- +TABLE: name="information_schema.foreign_data_wrappers" schema="information_schema" table="foreign_data_wrappers" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.foreign_data_wrappers ORDER BY 1, 2" +== 315 +-- truncate_limit: 100 +SELECT * FROM information_schema.foreign_data_wrapper_options ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.foreign_data_wrapper_options" schema="information_schema" table="foreign_data_wrapper_options" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.foreign_data_wrapper_options ORDER BY 1, 2, 3" +== 316 +-- truncate_limit: 100 +SELECT * FROM information_schema.foreign_servers ORDER BY 1, 2 +-- +TABLE: name="information_schema.foreign_servers" schema="information_schema" table="foreign_servers" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.foreign_servers ORDER BY 1, 2" +== 317 +-- truncate_limit: 100 +SELECT * FROM information_schema.foreign_server_options ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.foreign_server_options" schema="information_schema" table="foreign_server_options" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.foreign_server_options ORDER BY 1, 2, 3" +== 318 +-- truncate_limit: 100 +SELECT * FROM information_schema.user_mappings ORDER BY lower(authorization_identifier), 2, 3 +-- +TABLE: name="information_schema.user_mappings" schema="information_schema" table="user_mappings" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.user_mappings ORDER BY lower(authorization_identifier), 2, 3" +== 319 +-- truncate_limit: 100 +SELECT * FROM information_schema.user_mapping_options ORDER BY lower(authorization_identifier), 2, 3, 4 +-- +TABLE: name="information_schema.user_mapping_options" schema="information_schema" table="user_mapping_options" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.user_mapping_options ORDER BY lower(authorization_identifier), 2..." +== 320 +-- truncate_limit: 100 +SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5 +-- +TABLE: name="information_schema.usage_privileges" schema="information_schema" table="usage_privileges" ctx=Select +FILTER: schema="" table="" column="object_type" +FILTER: schema="" table="" column="object_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.usage_privileges WHERE ... ORDER BY 1, 2, 3, 4, 5" +== 321 +-- truncate_limit: 100 +SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5 +-- +TABLE: name="information_schema.role_usage_grants" schema="information_schema" table="role_usage_grants" ctx=Select +FILTER: schema="" table="" column="object_type" +FILTER: schema="" table="" column="object_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.role_usage_grants WHERE ... ORDER BY 1, 2, 3, 4, 5" +== 322 +-- truncate_limit: 100 +SELECT * FROM information_schema.foreign_tables ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.foreign_tables" schema="information_schema" table="foreign_tables" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.foreign_tables ORDER BY 1, 2, 3" +== 323 +-- truncate_limit: 100 +SELECT * FROM information_schema.foreign_table_options ORDER BY 1, 2, 3, 4 +-- +TABLE: name="information_schema.foreign_table_options" schema="information_schema" table="foreign_table_options" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.foreign_table_options ORDER BY 1, 2, 3, 4" +== 324 +-- truncate_limit: 100 +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 325 +-- truncate_limit: 100 +SELECT * FROM information_schema.user_mapping_options ORDER BY 1, 2, 3, 4 +-- +TABLE: name="information_schema.user_mapping_options" schema="information_schema" table="user_mapping_options" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.user_mapping_options ORDER BY 1, 2, 3, 4" +== 326 +-- truncate_limit: 100 +SELECT * FROM information_schema.usage_privileges WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5 +-- +TABLE: name="information_schema.usage_privileges" schema="information_schema" table="usage_privileges" ctx=Select +FILTER: schema="" table="" column="object_type" +FILTER: schema="" table="" column="object_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.usage_privileges WHERE ... ORDER BY 1, 2, 3, 4, 5" +== 327 +-- truncate_limit: 100 +SELECT * FROM information_schema.role_usage_grants WHERE object_type LIKE 'FOREIGN%' AND object_name IN ('s6', 'foo') ORDER BY 1, 2, 3, 4, 5 +-- +TABLE: name="information_schema.role_usage_grants" schema="information_schema" table="role_usage_grants" ctx=Select +FILTER: schema="" table="" column="object_type" +FILTER: schema="" table="" column="object_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.role_usage_grants WHERE ... ORDER BY 1, 2, 3, 4, 5" +== 328 +-- truncate_limit: 100 +DROP USER MAPPING FOR current_user SERVER t1 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR CURRENT_USER SERVER t1" +== 329 +-- truncate_limit: 100 +SET ROLE regress_test_role2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role2" +== 330 +-- truncate_limit: 100 +SELECT * FROM information_schema.user_mapping_options ORDER BY 1, 2, 3, 4 +-- +TABLE: name="information_schema.user_mapping_options" schema="information_schema" table="user_mapping_options" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.user_mapping_options ORDER BY 1, 2, 3, 4" +== 331 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 332 +-- truncate_limit: 100 +-- has_foreign_data_wrapper_privilege +SELECT has_foreign_data_wrapper_privilege('regress_test_role', + (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE') +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="fdwname" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 333 +-- truncate_limit: 100 +SELECT has_foreign_data_wrapper_privilege('regress_test_role', 'foo', 'USAGE') +-- +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_foreign_data_wrapper_privilege('regress_test_role', 'foo', 'USAGE')" +== 334 +-- truncate_limit: 100 +SELECT has_foreign_data_wrapper_privilege( + (SELECT oid FROM pg_roles WHERE rolname='regress_test_role'), + (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE') +-- +TABLE: name="pg_roles" schema="" table="pg_roles" ctx=Select +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +FILTER: schema="" table="" column="fdwname" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 335 +-- truncate_limit: 100 +SELECT has_foreign_data_wrapper_privilege( + (SELECT oid FROM pg_foreign_data_wrapper WHERE fdwname='foo'), 'USAGE') +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="fdwname" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 336 +-- truncate_limit: 100 +SELECT has_foreign_data_wrapper_privilege( + (SELECT oid FROM pg_roles WHERE rolname='regress_test_role'), 'foo', 'USAGE') +-- +TABLE: name="pg_roles" schema="" table="pg_roles" ctx=Select +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT has_foreign_data_wrapper_privilege((SELECT oid FROM pg_roles WHERE ...), 'foo', 'USAGE')" +== 337 +-- truncate_limit: 100 +SELECT has_foreign_data_wrapper_privilege('foo', 'USAGE') +-- +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_foreign_data_wrapper_privilege('foo', 'USAGE')" +== 338 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER foo TO regress_test_role" +== 339 +-- truncate_limit: 100 +SELECT has_foreign_data_wrapper_privilege('regress_test_role', 'foo', 'USAGE') +-- +FUNCTION: name="has_foreign_data_wrapper_privilege" function="has_foreign_data_wrapper_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_foreign_data_wrapper_privilege('regress_test_role', 'foo', 'USAGE')" +== 340 +-- truncate_limit: 100 +-- has_server_privilege +SELECT has_server_privilege('regress_test_role', + (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE') +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="srvname" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 341 +-- truncate_limit: 100 +SELECT has_server_privilege('regress_test_role', 's8', 'USAGE') +-- +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_server_privilege('regress_test_role', 's8', 'USAGE')" +== 342 +-- truncate_limit: 100 +SELECT has_server_privilege( + (SELECT oid FROM pg_roles WHERE rolname='regress_test_role'), + (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE') +-- +TABLE: name="pg_roles" schema="" table="pg_roles" ctx=Select +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +FILTER: schema="" table="" column="srvname" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 343 +-- truncate_limit: 100 +SELECT has_server_privilege( + (SELECT oid FROM pg_foreign_server WHERE srvname='s8'), 'USAGE') +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="srvname" +STMT: SelectStmt +TRUNCATED: "SELECT has_server_privilege((SELECT oid FROM pg_foreign_server WHERE srvname = 's8'), 'USAGE')" +== 344 +-- truncate_limit: 100 +SELECT has_server_privilege( + (SELECT oid FROM pg_roles WHERE rolname='regress_test_role'), 's8', 'USAGE') +-- +TABLE: name="pg_roles" schema="" table="pg_roles" ctx=Select +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT has_server_privilege((SELECT oid FROM pg_roles WHERE ...), 's8', 'USAGE')" +== 345 +-- truncate_limit: 100 +SELECT has_server_privilege('s8', 'USAGE') +-- +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_server_privilege('s8', 'USAGE')" +== 346 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN SERVER s8 TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s8 TO regress_test_role" +== 347 +-- truncate_limit: 100 +SELECT has_server_privilege('regress_test_role', 's8', 'USAGE') +-- +FUNCTION: name="has_server_privilege" function="has_server_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_server_privilege('regress_test_role', 's8', 'USAGE')" +== 348 +-- truncate_limit: 100 +REVOKE USAGE ON FOREIGN SERVER s8 FROM regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON FOREIGN SERVER s8 FROM regress_test_role" +== 349 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN SERVER s4 TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s4 TO regress_test_role" +== 350 +-- truncate_limit: 100 +DROP USER MAPPING FOR public SERVER s4 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR public SERVER s4" +== 351 +-- truncate_limit: 100 +ALTER SERVER s6 OPTIONS (DROP host, DROP dbname) +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s6 OPTIONS (DROP host, DROP dbname)" +== 352 +-- truncate_limit: 100 +ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (DROP username) +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (DROP username)" +== 353 +-- truncate_limit: 100 +ALTER FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator" +== 354 +-- truncate_limit: 100 +-- Privileges +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_unprivileged_role" +== 355 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER foobar +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foobar" +== 356 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OPTIONS (gotcha 'true') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (gotcha 'true')" +== 357 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_unprivileged_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OWNER TO regress_unprivileged_role" +== 358 +-- truncate_limit: 100 +-- ERROR +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo" +== 359 +-- truncate_limit: 100 +-- ERROR +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER foo TO regress_test_role" +== 360 +-- truncate_limit: 100 +-- ERROR +CREATE SERVER s9 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s9 FOREIGN DATA WRAPPER foo" +== 361 +-- truncate_limit: 100 +-- ERROR +ALTER SERVER s4 VERSION '0.5' +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s4 VERSION '0.5'" +== 362 +-- truncate_limit: 100 +-- ERROR +ALTER SERVER s4 OWNER TO regress_unprivileged_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SERVER s4 OWNER TO regress_unprivileged_role" +== 363 +-- truncate_limit: 100 +-- ERROR +DROP SERVER s4 +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s4" +== 364 +-- truncate_limit: 100 +-- ERROR +GRANT USAGE ON FOREIGN SERVER s4 TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s4 TO regress_test_role" +== 365 +-- truncate_limit: 100 +-- ERROR +CREATE USER MAPPING FOR public SERVER s4 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR public SERVER s4" +== 366 +-- truncate_limit: 100 +-- ERROR +ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (gotcha 'true')" +== 367 +-- truncate_limit: 100 +-- ERROR +DROP USER MAPPING FOR regress_test_role SERVER s6 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR regress_test_role SERVER s6" +== 368 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 369 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN DATA WRAPPER postgresql TO regress_unprivileged_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER postgresql TO regress_unprivileged_role" +== 370 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_unprivileged_role WITH GRANT OPTION +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER foo TO regress_unprivileged_role WITH GRANT OPTION" +== 371 +-- truncate_limit: 100 +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_unprivileged_role" +== 372 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER foobar +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER foobar" +== 373 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN DATA WRAPPER foo OPTIONS (gotcha 'true') +-- +STMT: AlterFdwStmt +TRUNCATED: "ALTER FOREIGN DATA WRAPPER foo OPTIONS (gotcha 'true')" +== 374 +-- truncate_limit: 100 +-- ERROR +DROP FOREIGN DATA WRAPPER foo +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo" +== 375 +-- truncate_limit: 100 +-- ERROR +GRANT USAGE ON FOREIGN DATA WRAPPER postgresql TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER postgresql TO regress_test_role" +== 376 +-- truncate_limit: 100 +-- WARNING +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER foo TO regress_test_role" +== 377 +-- truncate_limit: 100 +CREATE SERVER s9 FOREIGN DATA WRAPPER postgresql +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s9 FOREIGN DATA WRAPPER postgresql" +== 378 +-- truncate_limit: 100 +ALTER SERVER s6 VERSION '0.5' +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s6 VERSION '0.5'" +== 379 +-- truncate_limit: 100 +-- ERROR +DROP SERVER s6 +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s6" +== 380 +-- truncate_limit: 100 +-- ERROR +GRANT USAGE ON FOREIGN SERVER s6 TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s6 TO regress_test_role" +== 381 +-- truncate_limit: 100 +-- ERROR +GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s9 TO regress_test_role" +== 382 +-- truncate_limit: 100 +CREATE USER MAPPING FOR public SERVER s6 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR public SERVER s6" +== 383 +-- truncate_limit: 100 +-- ERROR +CREATE USER MAPPING FOR public SERVER s9 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR public SERVER s9" +== 384 +-- truncate_limit: 100 +ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (gotcha 'true') +-- +STMT: AlterUserMappingStmt +TRUNCATED: "ALTER USER MAPPING FOR regress_test_role SERVER s6 OPTIONS (gotcha 'true')" +== 385 +-- truncate_limit: 100 +-- ERROR +DROP USER MAPPING FOR regress_test_role SERVER s6 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR regress_test_role SERVER s6" +== 386 +-- truncate_limit: 100 +-- ERROR +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 387 +-- truncate_limit: 100 +REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM regress_unprivileged_role +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON FOREIGN DATA WRAPPER foo FROM regress_unprivileged_role" +== 388 +-- truncate_limit: 100 +-- ERROR +REVOKE USAGE ON FOREIGN DATA WRAPPER foo FROM regress_unprivileged_role CASCADE +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON FOREIGN DATA WRAPPER foo FROM regress_unprivileged_role CASCADE" +== 389 +-- truncate_limit: 100 +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_unprivileged_role" +== 390 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN DATA WRAPPER foo TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN DATA WRAPPER foo TO regress_test_role" +== 391 +-- truncate_limit: 100 +-- ERROR +CREATE SERVER s10 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s10 FOREIGN DATA WRAPPER foo" +== 392 +-- truncate_limit: 100 +-- ERROR +ALTER SERVER s9 VERSION '1.1' +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s9 VERSION '1.1'" +== 393 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s9 TO regress_test_role" +== 394 +-- truncate_limit: 100 +CREATE USER MAPPING FOR current_user SERVER s9 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s9" +== 395 +-- truncate_limit: 100 +DROP SERVER s9 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s9 CASCADE" +== 396 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 397 +-- truncate_limit: 100 +CREATE SERVER s9 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s9 FOREIGN DATA WRAPPER foo" +== 398 +-- truncate_limit: 100 +GRANT USAGE ON FOREIGN SERVER s9 TO regress_unprivileged_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s9 TO regress_unprivileged_role" +== 399 +-- truncate_limit: 100 +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_unprivileged_role" +== 400 +-- truncate_limit: 100 +ALTER SERVER s9 VERSION '1.2' +-- +STMT: AlterForeignServerStmt +TRUNCATED: "ALTER SERVER s9 VERSION '1.2'" +== 401 +-- truncate_limit: 100 +-- ERROR +GRANT USAGE ON FOREIGN SERVER s9 TO regress_test_role +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON FOREIGN SERVER s9 TO regress_test_role" +== 402 +-- truncate_limit: 100 +-- WARNING +CREATE USER MAPPING FOR current_user SERVER s9 +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR CURRENT_USER SERVER s9" +== 403 +-- truncate_limit: 100 +DROP SERVER s9 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s9 CASCADE" +== 404 +-- truncate_limit: 100 +-- ERROR + +-- Check visibility of user mapping data +SET ROLE regress_test_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_test_role" +== 405 +-- truncate_limit: 100 +CREATE SERVER s10 FOREIGN DATA WRAPPER foo +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER s10 FOREIGN DATA WRAPPER foo" +== 406 +-- truncate_limit: 100 +CREATE USER MAPPING FOR public SERVER s10 OPTIONS (user 'secret') +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR public SERVER s10 OPTIONS (\"user\" 'secret')" +== 407 +-- truncate_limit: 100 +CREATE USER MAPPING FOR regress_unprivileged_role SERVER s10 OPTIONS (user 'secret') +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR regress_unprivileged_role SERVER s10 OPTIONS (\"user\" 'secret')" +== 408 +-- truncate_limit: 100 +-- owner of server can see some option fields +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 409 +-- truncate_limit: 100 +-- superuser can see all option fields +-- unprivileged user cannot see any option field +SET ROLE regress_unprivileged_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_unprivileged_role" +== 410 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 411 +-- truncate_limit: 100 +DROP SERVER s10 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s10 CASCADE" +== 412 +-- truncate_limit: 100 +-- Triggers +CREATE FUNCTION dummy_trigger() RETURNS TRIGGER AS $$ + BEGIN + RETURN NULL; + END +$$ language plpgsql +-- +FUNCTION: name="dummy_trigger" function="dummy_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dummy_trigger() RETURNS trigger AS $$\n BEGIN\n RETURN NULL;\n END\n$$ LANGUAGE ..." +== 413 +-- truncate_limit: 100 +CREATE TRIGGER trigtest_before_stmt BEFORE INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH STATEMENT +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_before_stmt BEFORE INSERT OR DELETE OR UPDATE ON foreign_schema.foreign_t..." +== 414 +-- truncate_limit: 100 +CREATE TRIGGER trigtest_after_stmt AFTER INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH STATEMENT +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_after_stmt AFTER INSERT OR DELETE OR UPDATE ON foreign_schema.foreign_tab..." +== 415 +-- truncate_limit: 100 +CREATE TRIGGER trigtest_after_stmt_tt AFTER INSERT OR UPDATE OR DELETE -- ERROR +ON foreign_schema.foreign_table_1 +REFERENCING NEW TABLE AS new_table +FOR EACH STATEMENT +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_after_stmt_tt AFTER INSERT OR DELETE OR UPDATE ON foreign_schema.foreign_..." +== 416 +-- truncate_limit: 100 +CREATE TRIGGER trigtest_before_row BEFORE INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH ROW +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_before_row BEFORE INSERT OR DELETE OR UPDATE ON foreign_schema.foreign_ta..." +== 417 +-- truncate_limit: 100 +CREATE TRIGGER trigtest_after_row AFTER INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH ROW +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_after_row AFTER INSERT OR DELETE OR UPDATE ON foreign_schema.foreign_tabl..." +== 418 +-- truncate_limit: 100 +CREATE CONSTRAINT TRIGGER trigtest_constraint AFTER INSERT OR UPDATE OR DELETE +ON foreign_schema.foreign_table_1 +FOR EACH ROW +EXECUTE PROCEDURE dummy_trigger() +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE CONSTRAINT TRIGGER trigtest_constraint AFTER INSERT OR DELETE OR UPDATE ON foreign_schema...." +== 419 +-- truncate_limit: 100 +ALTER FOREIGN TABLE foreign_schema.foreign_table_1 + DISABLE TRIGGER trigtest_before_stmt +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE foreign_schema.foreign_table_1 DISABLE TRIGGER trigtest_before_stmt" +== 420 +-- truncate_limit: 100 +ALTER FOREIGN TABLE foreign_schema.foreign_table_1 + ENABLE TRIGGER trigtest_before_stmt +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE foreign_schema.foreign_table_1 ENABLE TRIGGER trigtest_before_stmt" +== 421 +-- truncate_limit: 100 +DROP TRIGGER trigtest_before_stmt ON foreign_schema.foreign_table_1 +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trigtest_before_stmt ON foreign_schema.foreign_table_1" +== 422 +-- truncate_limit: 100 +DROP TRIGGER trigtest_before_row ON foreign_schema.foreign_table_1 +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trigtest_before_row ON foreign_schema.foreign_table_1" +== 423 +-- truncate_limit: 100 +DROP TRIGGER trigtest_after_stmt ON foreign_schema.foreign_table_1 +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trigtest_after_stmt ON foreign_schema.foreign_table_1" +== 424 +-- truncate_limit: 100 +DROP TRIGGER trigtest_after_row ON foreign_schema.foreign_table_1 +-- +TABLE: name="foreign_schema.foreign_table_1" schema="foreign_schema" table="foreign_table_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trigtest_after_row ON foreign_schema.foreign_table_1" +== 425 +-- truncate_limit: 100 +DROP FUNCTION dummy_trigger() +-- +FUNCTION: name="dummy_trigger" function="dummy_trigger" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dummy_trigger()" +== 426 +-- truncate_limit: 100 +-- Table inheritance +CREATE TABLE fd_pt1 ( + c1 integer NOT NULL, + c2 text, + c3 date +) +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fd_pt1 (c1 int NOT NULL, c2 text, c3 date)" +== 427 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft2 () INHERITS (fd_pt1) + SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft2 () INHERITS (fd_pt1) SERVER s0 OPTIONS (delimiter ',', quote '\"', \"be qu..." +== 428 +-- truncate_limit: 100 +DROP FOREIGN TABLE ft2 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE ft2" +== 429 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft2 ( + c1 integer NOT NULL, + c2 text, + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft2 (c1 int NOT NULL, c2 text, c3 date) SERVER s0 OPTIONS (delimiter ',', qu..." +== 430 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft2 INHERIT fd_pt1 +-- +TABLE: name="ft2" schema="" table="ft2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft2 INHERIT fd_pt1" +== 431 +-- truncate_limit: 100 +CREATE TABLE ct3() INHERITS(ft2) +-- +TABLE: name="ct3" schema="" table="ct3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ct3 () INHERITS (ft2)" +== 432 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft3 ( + c1 integer NOT NULL, + c2 text, + c3 date +) INHERITS(ft2) + SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft3 (c1 int NOT NULL, c2 text, c3 date) INHERITS (ft2) SERVER s0" +== 433 +-- truncate_limit: 100 +-- add attributes recursively +ALTER TABLE fd_pt1 ADD COLUMN c4 integer +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ADD COLUMN c4 int" +== 434 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ADD COLUMN c5 integer DEFAULT 0 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ADD COLUMN c5 int DEFAULT 0" +== 435 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ADD COLUMN c6 integer +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ADD COLUMN c6 int" +== 436 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ADD COLUMN c7 integer NOT NULL +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ADD COLUMN c7 int NOT NULL" +== 437 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ADD COLUMN c8 integer +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ADD COLUMN c8 int" +== 438 +-- truncate_limit: 100 +-- alter attributes recursively +ALTER TABLE fd_pt1 ALTER COLUMN c4 SET DEFAULT 0 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c4 SET DEFAULT 0" +== 439 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c5 DROP DEFAULT +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c5 DROP DEFAULT" +== 440 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c6 SET NOT NULL +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c6 SET NOT NULL" +== 441 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c7 DROP NOT NULL +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c7 DROP NOT NULL" +== 442 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c8 TYPE char(10) USING '0' +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c8 TYPE char(10) USING '0'" +== 443 +-- truncate_limit: 100 +-- ERROR +ALTER TABLE fd_pt1 ALTER COLUMN c8 TYPE char(10) +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c8 TYPE char(10)" +== 444 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c8 SET DATA TYPE text +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c8 TYPE text" +== 445 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c1 SET STATISTICS 10000 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c1 SET STATISTICS 10000" +== 446 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c1 SET (n_distinct = 100) +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c1 SET (n_distinct=100)" +== 447 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STATISTICS -1 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STATISTICS -1" +== 448 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STORAGE EXTERNAL +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ALTER COLUMN c8 SET STORAGE external" +== 449 +-- truncate_limit: 100 +-- drop attributes recursively +ALTER TABLE fd_pt1 DROP COLUMN c4 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 DROP c4" +== 450 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 DROP COLUMN c5 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 DROP c5" +== 451 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 DROP COLUMN c6 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 DROP c6" +== 452 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 DROP COLUMN c7 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 DROP c7" +== 453 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 DROP COLUMN c8 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 DROP c8" +== 454 +-- truncate_limit: 100 +-- add constraints recursively +ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk1 CHECK (c1 > 0) NO INHERIT +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk1 CHECK (c1 > 0) NO INHERIT" +== 455 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk2 CHECK (c2 <> '') +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk2 CHECK (c2 <> '')" +== 456 +-- truncate_limit: 100 +-- connoinherit should be true for NO INHERIT constraint +SELECT relname, conname, contype, conislocal, coninhcount, connoinherit + FROM pg_class AS pc JOIN pg_constraint AS pgc ON (conrelid = pc.oid) + WHERE pc.relname = 'fd_pt1' + ORDER BY 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 457 +-- truncate_limit: 100 +-- child does not inherit NO INHERIT constraints +DROP FOREIGN TABLE ft2 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE ft2" +== 458 +-- truncate_limit: 100 +-- ERROR +DROP FOREIGN TABLE ft2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE ft2 CASCADE" +== 459 +-- truncate_limit: 100 +CREATE FOREIGN TABLE ft2 ( + c1 integer NOT NULL, + c2 text, + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE ft2 (c1 int NOT NULL, c2 text, c3 date) SERVER s0 OPTIONS (delimiter ',', qu..." +== 460 +-- truncate_limit: 100 +-- child must have parent's INHERIT constraints +ALTER FOREIGN TABLE ft2 INHERIT fd_pt1 +-- +TABLE: name="ft2" schema="" table="ft2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft2 INHERIT fd_pt1" +== 461 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE ft2 ADD CONSTRAINT fd_pt1chk2 CHECK (c2 <> '') +-- +TABLE: name="ft2" schema="" table="ft2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft2 ADD CONSTRAINT fd_pt1chk2 CHECK (c2 <> '')" +== 462 +-- truncate_limit: 100 +ALTER FOREIGN TABLE ft2 INHERIT fd_pt1 +-- +TABLE: name="ft2" schema="" table="ft2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE ft2 INHERIT fd_pt1" +== 463 +-- truncate_limit: 100 +-- child does not inherit NO INHERIT constraints + +-- drop constraints recursively +ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk1 CASCADE +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk1 CASCADE" +== 464 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk2 CASCADE +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 DROP CONSTRAINT fd_pt1chk2 CASCADE" +== 465 +-- truncate_limit: 100 +-- NOT VALID case +INSERT INTO fd_pt1 VALUES (1, 'fd_pt1'::text, '1994-01-01'::date) +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fd_pt1 VALUES (1, 'fd_pt1'::text, '1994-01-01'::date)" +== 466 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk3 CHECK (c2 <> '') NOT VALID +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 ADD CONSTRAINT fd_pt1chk3 CHECK (c2 <> '') NOT VALID" +== 467 +-- truncate_limit: 100 +-- VALIDATE CONSTRAINT need do nothing on foreign tables +ALTER TABLE fd_pt1 VALIDATE CONSTRAINT fd_pt1chk3 +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt1 VALIDATE CONSTRAINT fd_pt1chk3" +== 468 +-- truncate_limit: 100 +-- changes name of an attribute recursively +ALTER TABLE fd_pt1 RENAME COLUMN c1 TO f1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE fd_pt1 RENAME COLUMN c1 TO f1" +== 469 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 RENAME COLUMN c2 TO f2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE fd_pt1 RENAME COLUMN c2 TO f2" +== 470 +-- truncate_limit: 100 +ALTER TABLE fd_pt1 RENAME COLUMN c3 TO f3 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE fd_pt1 RENAME COLUMN c3 TO f3" +== 471 +-- truncate_limit: 100 +-- changes name of a constraint recursively +ALTER TABLE fd_pt1 RENAME CONSTRAINT fd_pt1chk3 TO f2_check +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE fd_pt1 RENAME CONSTRAINT fd_pt1chk3 TO f2_check" +== 472 +-- truncate_limit: 100 +DROP TABLE fd_pt1 CASCADE +-- +TABLE: name="fd_pt1" schema="" table="fd_pt1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fd_pt1 CASCADE" +== 473 +-- truncate_limit: 100 +-- IMPORT FOREIGN SCHEMA +IMPORT FOREIGN SCHEMA s1 FROM SERVER s9 INTO public +-- +STMT: ImportForeignSchemaStmt +TRUNCATED: "IMPORT FOREIGN SCHEMA s1 FROM SERVER s9 INTO public" +== 474 +-- truncate_limit: 100 +-- ERROR +IMPORT FOREIGN SCHEMA s1 LIMIT TO (t1) FROM SERVER s9 INTO public +-- +STMT: ImportForeignSchemaStmt +TRUNCATED: "IMPORT FOREIGN SCHEMA s1 LIMIT TO (t1) FROM SERVER s9 INTO public" +== 475 +-- truncate_limit: 100 +--ERROR +IMPORT FOREIGN SCHEMA s1 EXCEPT (t1) FROM SERVER s9 INTO public +-- +STMT: ImportForeignSchemaStmt +TRUNCATED: "IMPORT FOREIGN SCHEMA s1 EXCEPT (t1) FROM SERVER s9 INTO public" +== 476 +-- truncate_limit: 100 +-- ERROR +IMPORT FOREIGN SCHEMA s1 EXCEPT (t1, t2) FROM SERVER s9 INTO public +OPTIONS (option1 'value1', option2 'value2') +-- +STMT: ImportForeignSchemaStmt +TRUNCATED: "IMPORT FOREIGN SCHEMA s1 EXCEPT (t1, t2) FROM SERVER s9 INTO public OPTIONS (option1 'value1', op..." +== 477 +-- truncate_limit: 100 +-- ERROR + +-- DROP FOREIGN TABLE +DROP FOREIGN TABLE no_table +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE no_table" +== 478 +-- truncate_limit: 100 +-- ERROR +DROP FOREIGN TABLE IF EXISTS no_table +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE IF EXISTS no_table" +== 479 +-- truncate_limit: 100 +DROP FOREIGN TABLE foreign_schema.foreign_table_1 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE foreign_schema.foreign_table_1" +== 480 +-- truncate_limit: 100 +-- REASSIGN OWNED/DROP OWNED of foreign objects +REASSIGN OWNED BY regress_test_role TO regress_test_role2 +-- +STMT: ReassignOwnedStmt +TRUNCATED: "REASSIGN OWNED BY regress_test_role TO regress_test_role2" +== 481 +-- truncate_limit: 100 +DROP OWNED BY regress_test_role2 +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_test_role2" +== 482 +-- truncate_limit: 100 +DROP OWNED BY regress_test_role2 CASCADE +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_test_role2 CASCADE" +== 483 +-- truncate_limit: 100 +-- Foreign partition DDL stuff +CREATE TABLE fd_pt2 ( + c1 integer NOT NULL, + c2 text, + c3 date +) PARTITION BY LIST (c1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fd_pt2 (c1 int NOT NULL, c2 text, c3 date) PARTITION BY LIST (c1)" +== 484 +-- truncate_limit: 100 +CREATE FOREIGN TABLE fd_pt2_1 PARTITION OF fd_pt2 FOR VALUES IN (1) + SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE fd_pt2_1 PARTITION OF fd_pt2 FOR VALUES IN (1) SERVER s0 OPTIONS (delimiter ..." +== 485 +-- truncate_limit: 100 +-- partition cannot have additional columns +DROP FOREIGN TABLE fd_pt2_1 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE fd_pt2_1" +== 486 +-- truncate_limit: 100 +CREATE FOREIGN TABLE fd_pt2_1 ( + c1 integer NOT NULL, + c2 text, + c3 date, + c4 char +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE fd_pt2_1 (c1 int NOT NULL, c2 text, c3 date, c4 char(1)) SERVER s0 OPTIONS (..." +== 487 +-- truncate_limit: 100 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1)" +== 488 +-- truncate_limit: 100 +-- ERROR + +DROP FOREIGN TABLE fd_pt2_1 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE fd_pt2_1" +== 489 +-- truncate_limit: 100 +CREATE FOREIGN TABLE fd_pt2_1 ( + c1 integer NOT NULL, + c2 text, + c3 date +) SERVER s0 OPTIONS (delimiter ',', quote '"', "be quoted" 'value') +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE fd_pt2_1 (c1 int NOT NULL, c2 text, c3 date) SERVER s0 OPTIONS (delimiter ',..." +== 490 +-- truncate_limit: 100 +-- no attach partition validation occurs for foreign tables +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1)" +== 491 +-- truncate_limit: 100 +-- cannot add column to a partition +ALTER TABLE fd_pt2_1 ADD c4 char +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2_1 ADD COLUMN c4 char(1)" +== 492 +-- truncate_limit: 100 +-- ok to have a partition's own constraints though +ALTER TABLE fd_pt2_1 ALTER c3 SET NOT NULL +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2_1 ALTER COLUMN c3 SET NOT NULL" +== 493 +-- truncate_limit: 100 +ALTER TABLE fd_pt2_1 ADD CONSTRAINT p21chk CHECK (c2 <> '') +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2_1 ADD CONSTRAINT p21chk CHECK (c2 <> '')" +== 494 +-- truncate_limit: 100 +-- cannot drop inherited NOT NULL constraint from a partition +ALTER TABLE fd_pt2_1 ALTER c1 DROP NOT NULL +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2_1 ALTER COLUMN c1 DROP NOT NULL" +== 495 +-- truncate_limit: 100 +-- partition must have parent's constraints +ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1 +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1" +== 496 +-- truncate_limit: 100 +ALTER TABLE fd_pt2 ALTER c2 SET NOT NULL +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 ALTER COLUMN c2 SET NOT NULL" +== 497 +-- truncate_limit: 100 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1)" +== 498 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE fd_pt2_1 ALTER c2 SET NOT NULL +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE fd_pt2_1 ALTER COLUMN c2 SET NOT NULL" +== 499 +-- truncate_limit: 100 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1)" +== 500 +-- truncate_limit: 100 +ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1 +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 DETACH PARTITION fd_pt2_1" +== 501 +-- truncate_limit: 100 +ALTER TABLE fd_pt2 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0)" +== 502 +-- truncate_limit: 100 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1)" +== 503 +-- truncate_limit: 100 +-- ERROR +ALTER FOREIGN TABLE fd_pt2_1 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0) +-- +TABLE: name="fd_pt2_1" schema="" table="fd_pt2_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER FOREIGN TABLE fd_pt2_1 ADD CONSTRAINT fd_pt2chk1 CHECK (c1 > 0)" +== 504 +-- truncate_limit: 100 +ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1) +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fd_pt2 ATTACH PARTITION fd_pt2_1 FOR VALUES IN (1)" +== 505 +-- truncate_limit: 100 +DROP FOREIGN TABLE fd_pt2_1 +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE fd_pt2_1" +== 506 +-- truncate_limit: 100 +DROP TABLE fd_pt2 +-- +TABLE: name="fd_pt2" schema="" table="fd_pt2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fd_pt2" +== 507 +-- truncate_limit: 100 +-- foreign table cannot be part of partition tree made of temporary +-- relations. +CREATE TEMP TABLE temp_parted (a int) PARTITION BY LIST (a) +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted (a int) PARTITION BY LIST (a)" +== 508 +-- truncate_limit: 100 +CREATE FOREIGN TABLE foreign_part PARTITION OF temp_parted DEFAULT + SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE foreign_part PARTITION OF temp_parted DEFAULT SERVER s0" +== 509 +-- truncate_limit: 100 +-- ERROR +CREATE FOREIGN TABLE foreign_part (a int) SERVER s0 +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE foreign_part (a int) SERVER s0" +== 510 +-- truncate_limit: 100 +ALTER TABLE temp_parted ATTACH PARTITION foreign_part DEFAULT +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE temp_parted ATTACH PARTITION foreign_part DEFAULT" +== 511 +-- truncate_limit: 100 +-- ERROR +DROP FOREIGN TABLE foreign_part +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN TABLE foreign_part" +== 512 +-- truncate_limit: 100 +DROP TABLE temp_parted +-- +TABLE: name="temp_parted" schema="" table="temp_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_parted" +== 513 +-- truncate_limit: 100 +-- Cleanup +DROP SCHEMA foreign_schema CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA foreign_schema CASCADE" +== 514 +-- truncate_limit: 100 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role" +== 515 +-- truncate_limit: 100 +-- ERROR +DROP SERVER t1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER t1 CASCADE" +== 516 +-- truncate_limit: 100 +DROP USER MAPPING FOR regress_test_role SERVER s6 +-- +STMT: DropUserMappingStmt +TRUNCATED: "DROP USER MAPPING FOR regress_test_role SERVER s6" +== 517 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER foo CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER foo CASCADE" +== 518 +-- truncate_limit: 100 +DROP SERVER s8 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SERVER s8 CASCADE" +== 519 +-- truncate_limit: 100 +DROP ROLE regress_test_indirect +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_indirect" +== 520 +-- truncate_limit: 100 +DROP ROLE regress_test_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role" +== 521 +-- truncate_limit: 100 +DROP ROLE regress_unprivileged_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_unprivileged_role" +== 522 +-- truncate_limit: 100 +-- ERROR +REVOKE ALL ON FOREIGN DATA WRAPPER postgresql FROM regress_unprivileged_role +-- +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON FOREIGN DATA WRAPPER postgresql FROM regress_unprivileged_role" +== 523 +-- truncate_limit: 100 +DROP ROLE regress_unprivileged_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_unprivileged_role" +== 524 +-- truncate_limit: 100 +DROP ROLE regress_test_role2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role2" +== 525 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER postgresql CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER postgresql CASCADE" +== 526 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER dummy CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER dummy CASCADE" +== 527 +-- truncate_limit: 100 +DROP ROLE regress_foreign_data_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_foreign_data_user" +== 528 +-- truncate_limit: 100 +-- At this point we should have no wrappers, no servers, and no mappings. +SELECT fdwname, fdwhandler, fdwvalidator, fdwoptions FROM pg_foreign_data_wrapper +-- +TABLE: name="pg_foreign_data_wrapper" schema="" table="pg_foreign_data_wrapper" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT fdwname, fdwhandler, fdwvalidator, fdwoptions FROM pg_foreign_data_wrapper" +== 529 +-- truncate_limit: 100 +SELECT srvname, srvoptions FROM pg_foreign_server +-- +TABLE: name="pg_foreign_server" schema="" table="pg_foreign_server" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT srvname, srvoptions FROM pg_foreign_server" +== 530 +-- truncate_limit: 100 +SELECT * FROM pg_user_mapping +-- +TABLE: name="pg_user_mapping" schema="" table="pg_user_mapping" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_user_mapping" diff --git a/parser/testdata/summary_truncate/postgres_regress/foreign_key.metadata.json b/parser/testdata/summary_truncate/postgres_regress/foreign_key.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/foreign_key.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/foreign_key.test b/parser/testdata/summary_truncate/postgres_regress/foreign_key.test new file mode 100644 index 0000000..fac38a6 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/foreign_key.test @@ -0,0 +1,9039 @@ +== 001 +-- truncate_limit: 100 +|-- +-- FOREIGN KEY +|-- + +-- MATCH FULL +|-- +-- First test, check and cascade +|-- +CREATE TABLE PKTABLE ( ptest1 int PRIMARY KEY, ptest2 text ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int PRIMARY KEY, ptest2 text)" +== 002 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int REFERENCES PKTABLE MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE, ftest2 int ) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int REFERENCES pktable MATCH FULL ON UPDATE CASCADE ON DELETE CASCAD..." +== 003 +-- truncate_limit: 100 +-- Insert test data into PKTABLE +INSERT INTO PKTABLE VALUES (1, 'Test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 'Test1')" +== 004 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 'Test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 'Test2')" +== 005 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (3, 'Test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (3, 'Test3')" +== 006 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (4, 'Test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (4, 'Test4')" +== 007 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (5, 'Test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (5, 'Test5')" +== 008 +-- truncate_limit: 100 +-- Insert successful rows into FK TABLE +INSERT INTO FKTABLE VALUES (1, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2)" +== 009 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 3)" +== 010 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (3, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (3, 4)" +== 011 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 1)" +== 012 +-- truncate_limit: 100 +-- Insert a failed row into FK TABLE +INSERT INTO FKTABLE VALUES (100, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (100, 2)" +== 013 +-- truncate_limit: 100 +-- Check FKTABLE +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 014 +-- truncate_limit: 100 +-- Delete a row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 1" +== 015 +-- truncate_limit: 100 +-- Check FKTABLE for removal of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 016 +-- truncate_limit: 100 +-- Update a row from PK TABLE +UPDATE PKTABLE SET ptest1=1 WHERE ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest1 = 1 WHERE ptest1 = 2" +== 017 +-- truncate_limit: 100 +-- Check FKTABLE for update of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 018 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 019 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 020 +-- truncate_limit: 100 +|-- +-- check set NULL and table constraint on multiple columns +|-- +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY(ptest1, ptest2) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY (ptest1, ptest2))" +== 021 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, CONSTRAINT constrname FOREIGN KEY(ftest1, ftest2) + REFERENCES PKTABLE MATCH FULL ON DELETE SET NULL ON UPDATE SET NULL) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 int, ftest3 int, CONSTRAINT constrname FOREIGN KEY (ftes..." +== 022 +-- truncate_limit: 100 +-- Test comments +COMMENT ON CONSTRAINT constrname_wrong ON FKTABLE IS 'fk constraint comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT constrname_wrong ON fktable IS 'fk constraint comment'" +== 023 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT constrname ON FKTABLE IS 'fk constraint comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT constrname ON fktable IS 'fk constraint comment'" +== 024 +-- truncate_limit: 100 +COMMENT ON CONSTRAINT constrname ON FKTABLE IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON CONSTRAINT constrname ON fktable IS NULL" +== 025 +-- truncate_limit: 100 +-- Insert test data into PKTABLE +INSERT INTO PKTABLE VALUES (1, 2, 'Test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 2, 'Test1')" +== 026 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 3, 'Test1-2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 3, 'Test1-2')" +== 027 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 4, 'Test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 4, 'Test2')" +== 028 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (3, 6, 'Test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (3, 6, 'Test3')" +== 029 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (4, 8, 'Test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (4, 8, 'Test4')" +== 030 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (5, 10, 'Test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (5, 10, 'Test5')" +== 031 +-- truncate_limit: 100 +-- Insert successful rows into FK TABLE +INSERT INTO FKTABLE VALUES (1, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 4)" +== 032 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (1, 3, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 3, 5)" +== 033 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 4, 8) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 4, 8)" +== 034 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (3, 6, 12) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (3, 6, 12)" +== 035 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, NULL, 0) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, NULL, 0)" +== 036 +-- truncate_limit: 100 +-- Insert failed rows into FK TABLE +INSERT INTO FKTABLE VALUES (100, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (100, 2, 4)" +== 037 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 2, 4)" +== 038 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 4)" +== 039 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (1, NULL, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, NULL, 4)" +== 040 +-- truncate_limit: 100 +-- Check FKTABLE +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 041 +-- truncate_limit: 100 +-- Delete a row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=1 and ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 1 AND ptest2 = 2" +== 042 +-- truncate_limit: 100 +-- Check FKTABLE for removal of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 043 +-- truncate_limit: 100 +-- Delete another row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=5 and ptest2=10 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 5 AND ptest2 = 10" +== 044 +-- truncate_limit: 100 +-- Check FKTABLE (should be no change) +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 045 +-- truncate_limit: 100 +-- Update a row from PK TABLE +UPDATE PKTABLE SET ptest1=1 WHERE ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest1 = 1 WHERE ptest1 = 2" +== 046 +-- truncate_limit: 100 +-- Check FKTABLE for update of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 047 +-- truncate_limit: 100 +-- Check update with part of key null +UPDATE FKTABLE SET ftest1 = NULL WHERE ftest1 = 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET ftest1 = NULL WHERE ftest1 = 1" +== 048 +-- truncate_limit: 100 +-- Check update with old and new key values equal +UPDATE FKTABLE SET ftest1 = 1 WHERE ftest1 = 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET ftest1 = 1 WHERE ftest1 = 1" +== 049 +-- truncate_limit: 100 +-- Try altering the column type where foreign keys are involved +ALTER TABLE PKTABLE ALTER COLUMN ptest1 TYPE bigint +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pktable ALTER COLUMN ptest1 TYPE bigint" +== 050 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ALTER COLUMN ftest1 TYPE bigint +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ALTER COLUMN ftest1 TYPE bigint" +== 051 +-- truncate_limit: 100 +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 052 +-- truncate_limit: 100 +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 053 +-- truncate_limit: 100 +DROP TABLE PKTABLE CASCADE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable CASCADE" +== 054 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 055 +-- truncate_limit: 100 +|-- +-- check set default and table constraint on multiple columns +|-- +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY(ptest1, ptest2) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY (ptest1, ptest2))" +== 056 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int DEFAULT -1, ftest2 int DEFAULT -2, ftest3 int, CONSTRAINT constrname2 FOREIGN KEY(ftest1, ftest2) + REFERENCES PKTABLE MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET DEFAULT) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int DEFAULT -1, ftest2 int DEFAULT -2, ftest3 int, CONSTRAINT constr..." +== 057 +-- truncate_limit: 100 +-- Insert a value in PKTABLE for default +INSERT INTO PKTABLE VALUES (-1, -2, 'The Default!') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (-1, -2, 'The Default!')" +== 058 +-- truncate_limit: 100 +-- Insert test data into PKTABLE +INSERT INTO PKTABLE VALUES (1, 2, 'Test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 2, 'Test1')" +== 059 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 3, 'Test1-2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 3, 'Test1-2')" +== 060 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 4, 'Test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 4, 'Test2')" +== 061 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (3, 6, 'Test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (3, 6, 'Test3')" +== 062 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (4, 8, 'Test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (4, 8, 'Test4')" +== 063 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (5, 10, 'Test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (5, 10, 'Test5')" +== 064 +-- truncate_limit: 100 +-- Insert successful rows into FK TABLE +INSERT INTO FKTABLE VALUES (1, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 4)" +== 065 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (1, 3, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 3, 5)" +== 066 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 4, 8) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 4, 8)" +== 067 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (3, 6, 12) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (3, 6, 12)" +== 068 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, NULL, 0) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, NULL, 0)" +== 069 +-- truncate_limit: 100 +-- Insert failed rows into FK TABLE +INSERT INTO FKTABLE VALUES (100, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (100, 2, 4)" +== 070 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 2, 4)" +== 071 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 4)" +== 072 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (1, NULL, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, NULL, 4)" +== 073 +-- truncate_limit: 100 +-- Check FKTABLE +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 074 +-- truncate_limit: 100 +-- Delete a row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=1 and ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 1 AND ptest2 = 2" +== 075 +-- truncate_limit: 100 +-- Check FKTABLE to check for removal +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 076 +-- truncate_limit: 100 +-- Delete another row from PK TABLE +DELETE FROM PKTABLE WHERE ptest1=5 and ptest2=10 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 5 AND ptest2 = 10" +== 077 +-- truncate_limit: 100 +-- Check FKTABLE (should be no change) +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 078 +-- truncate_limit: 100 +-- Update a row from PK TABLE +UPDATE PKTABLE SET ptest1=1 WHERE ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest1 = 1 WHERE ptest1 = 2" +== 079 +-- truncate_limit: 100 +-- Check FKTABLE for update of matched row +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 080 +-- truncate_limit: 100 +-- this should fail for lack of CASCADE +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 081 +-- truncate_limit: 100 +DROP TABLE PKTABLE CASCADE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable CASCADE" +== 082 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 083 +-- truncate_limit: 100 +|-- +-- First test, check with no on delete or on update +|-- +CREATE TABLE PKTABLE ( ptest1 int PRIMARY KEY, ptest2 text ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int PRIMARY KEY, ptest2 text)" +== 084 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int REFERENCES PKTABLE MATCH FULL, ftest2 int ) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int REFERENCES pktable MATCH FULL, ftest2 int)" +== 085 +-- truncate_limit: 100 +-- Insert test data into PKTABLE +INSERT INTO PKTABLE VALUES (1, 'Test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 'Test1')" +== 086 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 'Test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 'Test2')" +== 087 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (3, 'Test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (3, 'Test3')" +== 088 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (4, 'Test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (4, 'Test4')" +== 089 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (5, 'Test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (5, 'Test5')" +== 090 +-- truncate_limit: 100 +-- Insert successful rows into FK TABLE +INSERT INTO FKTABLE VALUES (1, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2)" +== 091 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 3)" +== 092 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (3, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (3, 4)" +== 093 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 1)" +== 094 +-- truncate_limit: 100 +-- Insert a failed row into FK TABLE +INSERT INTO FKTABLE VALUES (100, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (100, 2)" +== 095 +-- truncate_limit: 100 +-- Check FKTABLE +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 096 +-- truncate_limit: 100 +-- Check PKTABLE +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 097 +-- truncate_limit: 100 +-- Delete a row from PK TABLE (should fail) +DELETE FROM PKTABLE WHERE ptest1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 1" +== 098 +-- truncate_limit: 100 +-- Delete a row from PK TABLE (should succeed) +DELETE FROM PKTABLE WHERE ptest1=5 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 5" +== 099 +-- truncate_limit: 100 +-- Check PKTABLE for deletes +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 100 +-- truncate_limit: 100 +-- Update a row from PK TABLE (should fail) +UPDATE PKTABLE SET ptest1=0 WHERE ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest1 = 0 WHERE ptest1 = 2" +== 101 +-- truncate_limit: 100 +-- Update a row from PK TABLE (should succeed) +UPDATE PKTABLE SET ptest1=0 WHERE ptest1=4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest1 = 0 WHERE ptest1 = 4" +== 102 +-- truncate_limit: 100 +-- Check PKTABLE for updates +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 103 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 104 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 105 +-- truncate_limit: 100 +|-- +-- Check initial check upon ALTER TABLE +|-- +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, PRIMARY KEY(ptest1, ptest2) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, PRIMARY KEY (ptest1, ptest2))" +== 106 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int ) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 int)" +== 107 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 2)" +== 108 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (1, NULL) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, NULL)" +== 109 +-- truncate_limit: 100 +ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) REFERENCES PKTABLE MATCH FULL +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD FOREIGN KEY (ftest1, ftest2) REFERENCES pktable MATCH FULL" +== 110 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 111 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 112 +-- truncate_limit: 100 +-- MATCH SIMPLE + +-- Base test restricting update/delete +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY (ptest1, ptest..." +== 113 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 FORE..." +== 114 +-- truncate_limit: 100 +-- Insert Primary Key values +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 2, 3, 'test1')" +== 115 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 3, 3, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 3, 3, 'test2')" +== 116 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 3, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 3, 4, 'test3')" +== 117 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 4, 5, 'test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 4, 5, 'test4')" +== 118 +-- truncate_limit: 100 +-- Insert Foreign Key values +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 3, 1)" +== 119 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 3, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 3, 2)" +== 120 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, NULL, 3, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, NULL, 3, 3)" +== 121 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 7, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 7, 4)" +== 122 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 3, 4, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 3, 4, 5)" +== 123 +-- truncate_limit: 100 +-- Insert a failed values +INSERT INTO FKTABLE VALUES (1, 2, 7, 6) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 7, 6)" +== 124 +-- truncate_limit: 100 +-- Show FKTABLE +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 125 +-- truncate_limit: 100 +-- Try to update something that should fail +UPDATE PKTABLE set ptest2=5 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest2 = 5 WHERE ptest2 = 2" +== 126 +-- truncate_limit: 100 +-- Try to update something that should succeed +UPDATE PKTABLE set ptest1=1 WHERE ptest2=3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest1 = 1 WHERE ptest2 = 3" +== 127 +-- truncate_limit: 100 +-- Try to delete something that should fail +DELETE FROM PKTABLE where ptest1=1 and ptest2=2 and ptest3=3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 1 AND ptest2 = 2 AND ptest3 = 3" +== 128 +-- truncate_limit: 100 +-- Try to delete something that should work +DELETE FROM PKTABLE where ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 2" +== 129 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 130 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 131 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 132 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 133 +-- truncate_limit: 100 +-- restrict with null values +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, UNIQUE(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, ptest3 int, ptest4 text, UNIQUE (ptest1, ptest2, pt..." +== 134 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE (ptest1, ptest2, ptest3)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 FORE..." +== 135 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 2, 3, 'test1')" +== 136 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 3, NULL, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 3, NULL, 'test2')" +== 137 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, NULL, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, NULL, 4, 'test3')" +== 138 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 3, 1)" +== 139 +-- truncate_limit: 100 +DELETE FROM PKTABLE WHERE ptest1 = 2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 2" +== 140 +-- truncate_limit: 100 +SELECT * FROM PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 141 +-- truncate_limit: 100 +SELECT * FROM FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 142 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 143 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 144 +-- truncate_limit: 100 +-- cascade update/delete +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY (ptest1, ptest..." +== 145 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE + ON DELETE CASCADE ON UPDATE CASCADE) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 FORE..." +== 146 +-- truncate_limit: 100 +-- Insert Primary Key values +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 2, 3, 'test1')" +== 147 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 3, 3, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 3, 3, 'test2')" +== 148 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 3, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 3, 4, 'test3')" +== 149 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 4, 5, 'test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 4, 5, 'test4')" +== 150 +-- truncate_limit: 100 +-- Insert Foreign Key values +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 3, 1)" +== 151 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 3, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 3, 2)" +== 152 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, NULL, 3, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, NULL, 3, 3)" +== 153 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 7, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 7, 4)" +== 154 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 3, 4, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 3, 4, 5)" +== 155 +-- truncate_limit: 100 +-- Insert a failed values +INSERT INTO FKTABLE VALUES (1, 2, 7, 6) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 7, 6)" +== 156 +-- truncate_limit: 100 +-- Show FKTABLE +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 157 +-- truncate_limit: 100 +-- Try to update something that will cascade +UPDATE PKTABLE set ptest2=5 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest2 = 5 WHERE ptest2 = 2" +== 158 +-- truncate_limit: 100 +-- Try to update something that should not cascade +UPDATE PKTABLE set ptest1=1 WHERE ptest2=3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest1 = 1 WHERE ptest2 = 3" +== 159 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 160 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 161 +-- truncate_limit: 100 +-- Try to delete something that should cascade +DELETE FROM PKTABLE where ptest1=1 and ptest2=5 and ptest3=3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 1 AND ptest2 = 5 AND ptest3 = 3" +== 162 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 163 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 164 +-- truncate_limit: 100 +-- Try to delete something that should not have a cascade +DELETE FROM PKTABLE where ptest1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 2" +== 165 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 166 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 167 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 168 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 169 +-- truncate_limit: 100 +-- set null update / set default delete +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY (ptest1, ptest..." +== 170 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int DEFAULT 0, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE + ON DELETE SET DEFAULT ON UPDATE SET NULL) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int DEFAULT 0, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constr..." +== 171 +-- truncate_limit: 100 +-- Insert Primary Key values +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 2, 3, 'test1')" +== 172 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 3, 3, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 3, 3, 'test2')" +== 173 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 3, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 3, 4, 'test3')" +== 174 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 4, 5, 'test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 4, 5, 'test4')" +== 175 +-- truncate_limit: 100 +-- Insert Foreign Key values +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 3, 1)" +== 176 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 3, 4, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 3, 4, 1)" +== 177 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 3, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 3, 2)" +== 178 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, NULL, 3, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, NULL, 3, 3)" +== 179 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 7, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 7, 4)" +== 180 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 3, 4, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 3, 4, 5)" +== 181 +-- truncate_limit: 100 +-- Insert a failed values +INSERT INTO FKTABLE VALUES (1, 2, 7, 6) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 7, 6)" +== 182 +-- truncate_limit: 100 +-- Show FKTABLE +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 183 +-- truncate_limit: 100 +-- Try to update something that will set null +UPDATE PKTABLE set ptest2=5 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest2 = 5 WHERE ptest2 = 2" +== 184 +-- truncate_limit: 100 +-- Try to update something that should not set null +UPDATE PKTABLE set ptest2=2 WHERE ptest2=3 and ptest1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest2 = 2 WHERE ptest2 = 3 AND ptest1 = 1" +== 185 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 186 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 187 +-- truncate_limit: 100 +-- Try to delete something that should set default +DELETE FROM PKTABLE where ptest1=2 and ptest2=3 and ptest3=4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 2 AND ptest2 = 3 AND ptest3 = 4" +== 188 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 189 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 190 +-- truncate_limit: 100 +-- Try to delete something that should not set default +DELETE FROM PKTABLE where ptest2=5 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest2 = 5" +== 191 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 192 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 193 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 194 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 195 +-- truncate_limit: 100 +-- set default update / set null delete +CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY (ptest1, ptest..." +== 196 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( ftest1 int DEFAULT 0, ftest2 int DEFAULT -1, ftest3 int DEFAULT -2, ftest4 int, CONSTRAINT constrname3 + FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE + ON DELETE SET NULL ON UPDATE SET DEFAULT) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int DEFAULT 0, ftest2 int DEFAULT -1, ftest3 int DEFAULT -2, ftest4 ..." +== 197 +-- truncate_limit: 100 +-- Insert Primary Key values +INSERT INTO PKTABLE VALUES (1, 2, 3, 'test1') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 2, 3, 'test1')" +== 198 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 3, 3, 'test2') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 3, 3, 'test2')" +== 199 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 3, 4, 'test3') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 3, 4, 'test3')" +== 200 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, 4, 5, 'test4') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, 4, 5, 'test4')" +== 201 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (2, -1, 5, 'test5') +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2, -1, 5, 'test5')" +== 202 +-- truncate_limit: 100 +-- Insert Foreign Key values +INSERT INTO FKTABLE VALUES (1, 2, 3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 3, 1)" +== 203 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 3, 4, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 3, 4, 1)" +== 204 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, 4, 5, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, 4, 5, 1)" +== 205 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 3, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 3, 2)" +== 206 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (2, NULL, 3, 3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (2, NULL, 3, 3)" +== 207 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 2, 7, 4) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 2, 7, 4)" +== 208 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES (NULL, 3, 4, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (NULL, 3, 4, 5)" +== 209 +-- truncate_limit: 100 +-- Insert a failed values +INSERT INTO FKTABLE VALUES (1, 2, 7, 6) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 2, 7, 6)" +== 210 +-- truncate_limit: 100 +-- Show FKTABLE +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 211 +-- truncate_limit: 100 +-- Try to update something that will fail +UPDATE PKTABLE set ptest2=5 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest2 = 5 WHERE ptest2 = 2" +== 212 +-- truncate_limit: 100 +-- Try to update something that will set default +UPDATE PKTABLE set ptest1=0, ptest2=-1, ptest3=-2 where ptest2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest1 = 0, ptest2 = -1, ptest3 = -2 WHERE ptest2 = 2" +== 213 +-- truncate_limit: 100 +UPDATE PKTABLE set ptest2=10 where ptest2=4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest2 = 10 WHERE ptest2 = 4" +== 214 +-- truncate_limit: 100 +-- Try to update something that should not set default +UPDATE PKTABLE set ptest2=2 WHERE ptest2=3 and ptest1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET ptest2 = 2 WHERE ptest2 = 3 AND ptest1 = 1" +== 215 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 216 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 217 +-- truncate_limit: 100 +-- Try to delete something that should set null +DELETE FROM PKTABLE where ptest1=2 and ptest2=3 and ptest3=4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest1 = 2 AND ptest2 = 3 AND ptest3 = 4" +== 218 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 219 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 220 +-- truncate_limit: 100 +-- Try to delete something that should not set null +DELETE FROM PKTABLE where ptest2=-1 and ptest3=5 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE ptest2 = -1 AND ptest3 = 5" +== 221 +-- truncate_limit: 100 +-- Show PKTABLE and FKTABLE +SELECT * from PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable" +== 222 +-- truncate_limit: 100 +SELECT * from FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable" +== 223 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 224 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 225 +-- truncate_limit: 100 +-- Test for ON DELETE SET NULL/DEFAULT (column_list); +CREATE TABLE PKTABLE (tid int, id int, PRIMARY KEY (tid, id)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (tid int, id int, PRIMARY KEY (tid, id))" +== 226 +-- truncate_limit: 100 +CREATE TABLE FKTABLE (tid int, id int, foo int, FOREIGN KEY (tid, id) REFERENCES PKTABLE ON DELETE SET NULL (bar)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (tid int, id int, foo int, FOREIGN KEY (tid, id) REFERENCES pktable ON DELET..." +== 227 +-- truncate_limit: 100 +CREATE TABLE FKTABLE (tid int, id int, foo int, FOREIGN KEY (tid, id) REFERENCES PKTABLE ON DELETE SET NULL (foo)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (tid int, id int, foo int, FOREIGN KEY (tid, id) REFERENCES pktable ON DELET..." +== 228 +-- truncate_limit: 100 +CREATE TABLE FKTABLE (tid int, id int, foo int, FOREIGN KEY (tid, foo) REFERENCES PKTABLE ON UPDATE SET NULL (foo)) +-- +ERROR: a column list with SET NULL is only supported for ON DELETE actions +CURSORPOS: 91 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 229 +-- truncate_limit: 100 +CREATE TABLE FKTABLE ( + tid int, id int, + fk_id_del_set_null int, + fk_id_del_set_default int DEFAULT 0, + FOREIGN KEY (tid, fk_id_del_set_null) REFERENCES PKTABLE ON DELETE SET NULL (fk_id_del_set_null), + -- this tests handling of duplicate entries in SET DEFAULT column list + FOREIGN KEY (tid, fk_id_del_set_default) REFERENCES PKTABLE ON DELETE SET DEFAULT (fk_id_del_set_default, fk_id_del_set_default) +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (tid int, id int, fk_id_del_set_null int, fk_id_del_set_default int DEFAULT ..." +== 230 +-- truncate_limit: 100 +SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE conrelid = 'fktable'::regclass::oid ORDER BY oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE ... ORDER BY oid" +== 231 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES (1, 0), (1, 1), (1, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (1, 0), (1, 1), (1, 2)" +== 232 +-- truncate_limit: 100 +INSERT INTO FKTABLE VALUES + (1, 1, 1, NULL), + (1, 2, NULL, 2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 1, 1, NULL), (1, 2, NULL, 2)" +== 233 +-- truncate_limit: 100 +DELETE FROM PKTABLE WHERE id = 1 OR id = 2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE id = 1 OR id = 2" +== 234 +-- truncate_limit: 100 +SELECT * FROM FKTABLE ORDER BY id +-- +TABLE: name="fktable" schema="" table="fktable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable ORDER BY id" +== 235 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 236 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 237 +-- truncate_limit: 100 +-- Test some invalid FK definitions +CREATE TABLE PKTABLE (ptest1 int PRIMARY KEY, someoid oid) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int PRIMARY KEY, someoid oid)" +== 238 +-- truncate_limit: 100 +CREATE TABLE FKTABLE_FAIL1 ( ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (ftest2) REFERENCES PKTABLE) +-- +TABLE: name="fktable_fail1" schema="" table="fktable_fail1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable_fail1 (ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (ftest2) REFERENCES pktable)" +== 239 +-- truncate_limit: 100 +CREATE TABLE FKTABLE_FAIL2 ( ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (ftest1) REFERENCES PKTABLE(ptest2)) +-- +TABLE: name="fktable_fail2" schema="" table="fktable_fail2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable_fail2 (ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (ftest1) REFERENCES pktabl..." +== 240 +-- truncate_limit: 100 +CREATE TABLE FKTABLE_FAIL3 ( ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (tableoid) REFERENCES PKTABLE(someoid)) +-- +TABLE: name="fktable_fail3" schema="" table="fktable_fail3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable_fail3 (ftest1 int, CONSTRAINT fkfail1 FOREIGN KEY (tableoid) REFERENCES pkta..." +== 241 +-- truncate_limit: 100 +CREATE TABLE FKTABLE_FAIL4 ( ftest1 oid, CONSTRAINT fkfail1 FOREIGN KEY (ftest1) REFERENCES PKTABLE(tableoid)) +-- +TABLE: name="fktable_fail4" schema="" table="fktable_fail4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable_fail4 (ftest1 oid, CONSTRAINT fkfail1 FOREIGN KEY (ftest1) REFERENCES pktabl..." +== 242 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 243 +-- truncate_limit: 100 +-- Test for referencing column number smaller than referenced constraint +CREATE TABLE PKTABLE (ptest1 int, ptest2 int, UNIQUE(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, UNIQUE (ptest1, ptest2))" +== 244 +-- truncate_limit: 100 +CREATE TABLE FKTABLE_FAIL1 (ftest1 int REFERENCES pktable(ptest1)) +-- +TABLE: name="fktable_fail1" schema="" table="fktable_fail1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable_fail1 (ftest1 int REFERENCES pktable (ptest1))" +== 245 +-- truncate_limit: 100 +DROP TABLE FKTABLE_FAIL1 +-- +TABLE: name="fktable_fail1" schema="" table="fktable_fail1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable_fail1" +== 246 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 247 +-- truncate_limit: 100 +|-- +-- Tests for mismatched types +|-- +-- Basic one column, two table setup +CREATE TABLE PKTABLE (ptest1 int PRIMARY KEY) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int PRIMARY KEY)" +== 248 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES(42) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (42)" +== 249 +-- truncate_limit: 100 +-- This next should fail, because int=inet does not exist +CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 inet REFERENCES pktable)" +== 250 +-- truncate_limit: 100 +-- This should also fail for the same reason, but here we +-- give the column name +CREATE TABLE FKTABLE (ftest1 inet REFERENCES pktable(ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 inet REFERENCES pktable (ptest1))" +== 251 +-- truncate_limit: 100 +-- This should succeed, even though they are different types, +-- because int=int8 exists and is a member of the integer opfamily +CREATE TABLE FKTABLE (ftest1 int8 REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int8 REFERENCES pktable)" +== 252 +-- truncate_limit: 100 +-- Check it actually works +INSERT INTO FKTABLE VALUES(42) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (42)" +== 253 +-- truncate_limit: 100 +-- should succeed +INSERT INTO FKTABLE VALUES(43) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (43)" +== 254 +-- truncate_limit: 100 +-- should fail +UPDATE FKTABLE SET ftest1 = ftest1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET ftest1 = ftest1" +== 255 +-- truncate_limit: 100 +-- should succeed +UPDATE FKTABLE SET ftest1 = ftest1 + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET ftest1 = ftest1 + 1" +== 256 +-- truncate_limit: 100 +-- should fail +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 257 +-- truncate_limit: 100 +-- This should fail, because we'd have to cast numeric to int which is +-- not an implicit coercion (or use numeric=numeric, but that's not part +-- of the integer opfamily) +CREATE TABLE FKTABLE (ftest1 numeric REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 numeric REFERENCES pktable)" +== 258 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 259 +-- truncate_limit: 100 +-- On the other hand, this should work because int implicitly promotes to +-- numeric, and we allow promotion on the FK side +CREATE TABLE PKTABLE (ptest1 numeric PRIMARY KEY) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 numeric PRIMARY KEY)" +== 260 +-- truncate_limit: 100 +INSERT INTO PKTABLE VALUES(42) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (42)" +== 261 +-- truncate_limit: 100 +CREATE TABLE FKTABLE (ftest1 int REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int REFERENCES pktable)" +== 262 +-- truncate_limit: 100 +-- Check it actually works +INSERT INTO FKTABLE VALUES(42) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (42)" +== 263 +-- truncate_limit: 100 +-- should succeed +INSERT INTO FKTABLE VALUES(43) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (43)" +== 264 +-- truncate_limit: 100 +-- should fail +UPDATE FKTABLE SET ftest1 = ftest1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET ftest1 = ftest1" +== 265 +-- truncate_limit: 100 +-- should succeed +UPDATE FKTABLE SET ftest1 = ftest1 + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET ftest1 = ftest1 + 1" +== 266 +-- truncate_limit: 100 +-- should fail +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 267 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 268 +-- truncate_limit: 100 +-- Two columns, two tables +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, PRIMARY KEY(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 inet, PRIMARY KEY (ptest1, ptest2))" +== 269 +-- truncate_limit: 100 +-- This should fail, because we just chose really odd types +CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 cidr, ftest2 timestamp, FOREIGN KEY (ftest1, ftest2) REFERENCES pkta..." +== 270 +-- truncate_limit: 100 +-- Again, so should this... +CREATE TABLE FKTABLE (ftest1 cidr, ftest2 timestamp, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 cidr, ftest2 timestamp, FOREIGN KEY (ftest1, ftest2) REFERENCES pkta..." +== 271 +-- truncate_limit: 100 +-- This fails because we mixed up the column ordering +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 inet, FOREIGN KEY (ftest2, ftest1) REFERENCES pktable)" +== 272 +-- truncate_limit: 100 +-- As does this... +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 inet, FOREIGN KEY (ftest2, ftest1) REFERENCES pktable (p..." +== 273 +-- truncate_limit: 100 +-- And again.. +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest2, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 inet, FOREIGN KEY (ftest1, ftest2) REFERENCES pktable (p..." +== 274 +-- truncate_limit: 100 +-- This works... +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest2, ftest1) REFERENCES pktable(ptest2, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 inet, FOREIGN KEY (ftest2, ftest1) REFERENCES pktable (p..." +== 275 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 276 +-- truncate_limit: 100 +-- As does this +CREATE TABLE FKTABLE (ftest1 int, ftest2 inet, FOREIGN KEY(ftest1, ftest2) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 inet, FOREIGN KEY (ftest1, ftest2) REFERENCES pktable (p..." +== 277 +-- truncate_limit: 100 +DROP TABLE FKTABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 278 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 279 +-- truncate_limit: 100 +-- Two columns, same table +-- Make sure this still works... +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3, +ptest4) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY (ptest1, ptes..." +== 280 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 281 +-- truncate_limit: 100 +-- And this, +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3, +ptest4) REFERENCES pktable) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY (ptest1, ptes..." +== 282 +-- truncate_limit: 100 +DROP TABLE PKTABLE +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 283 +-- truncate_limit: 100 +-- This shouldn't (mixed up columns) +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest3, +ptest4) REFERENCES pktable(ptest2, ptest1)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY (ptest1, ptes..." +== 284 +-- truncate_limit: 100 +-- Nor should this... (same reason, we have 4,3 referencing 1,2 which mismatches types +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4, +ptest3) REFERENCES pktable(ptest1, ptest2)) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY (ptest1, ptes..." +== 285 +-- truncate_limit: 100 +-- Not this one either... Same as the last one except we didn't defined the columns being referenced. +CREATE TABLE PKTABLE (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY(ptest1, ptest2), FOREIGN KEY(ptest4, +ptest3) REFERENCES pktable) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 inet, ptest3 int, ptest4 inet, PRIMARY KEY (ptest1, ptes..." +== 286 +-- truncate_limit: 100 +|-- +-- Now some cases with inheritance +-- Basic 2 table case: 1 column of matching types. +create table pktable_base (base1 int not null) +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable_base (base1 int NOT NULL)" +== 287 +-- truncate_limit: 100 +create table pktable (ptest1 int, primary key(base1), unique(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, PRIMARY KEY (base1), UNIQUE (base1, ptest1)) INHERITS (pktable_..." +== 288 +-- truncate_limit: 100 +create table fktable (ftest1 int references pktable(base1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int REFERENCES pktable (base1))" +== 289 +-- truncate_limit: 100 +-- now some ins, upd, del +insert into pktable(base1) values (1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1) VALUES (1)" +== 290 +-- truncate_limit: 100 +insert into pktable(base1) values (2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1) VALUES (2)" +== 291 +-- truncate_limit: 100 +-- let's insert a non-existent fktable value +insert into fktable(ftest1) values (3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable (ftest1) VALUES (3)" +== 292 +-- truncate_limit: 100 +-- let's make a valid row for that +insert into pktable(base1) values (3) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1) VALUES (3)" +== 293 +-- truncate_limit: 100 +insert into fktable(ftest1) values (3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable (ftest1) VALUES (3)" +== 294 +-- truncate_limit: 100 +-- let's try removing a row that should fail from pktable +delete from pktable where base1>2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE base1 > 2" +== 295 +-- truncate_limit: 100 +-- okay, let's try updating all of the base1 values to *4 +-- which should fail. +update pktable set base1=base1*4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET base1 = base1 * 4" +== 296 +-- truncate_limit: 100 +-- okay, let's try an update that should work. +update pktable set base1=base1*4 where base1<3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET base1 = base1 * 4 WHERE base1 < 3" +== 297 +-- truncate_limit: 100 +-- and a delete that should work +delete from pktable where base1>3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE base1 > 3" +== 298 +-- truncate_limit: 100 +-- cleanup +drop table fktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 299 +-- truncate_limit: 100 +delete from pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable" +== 300 +-- truncate_limit: 100 +-- Now 2 columns 2 tables, matching types +create table fktable (ftest1 int, ftest2 int, foreign key(ftest1, ftest2) references pktable(base1, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 int, FOREIGN KEY (ftest1, ftest2) REFERENCES pktable (ba..." +== 301 +-- truncate_limit: 100 +-- now some ins, upd, del +insert into pktable(base1, ptest1) values (1, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1, ptest1) VALUES (1, 1)" +== 302 +-- truncate_limit: 100 +insert into pktable(base1, ptest1) values (2, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1, ptest1) VALUES (2, 2)" +== 303 +-- truncate_limit: 100 +-- let's insert a non-existent fktable value +insert into fktable(ftest1, ftest2) values (3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable (ftest1, ftest2) VALUES (3, 1)" +== 304 +-- truncate_limit: 100 +-- let's make a valid row for that +insert into pktable(base1,ptest1) values (3, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1, ptest1) VALUES (3, 1)" +== 305 +-- truncate_limit: 100 +insert into fktable(ftest1, ftest2) values (3, 1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable (ftest1, ftest2) VALUES (3, 1)" +== 306 +-- truncate_limit: 100 +-- let's try removing a row that should fail from pktable +delete from pktable where base1>2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE base1 > 2" +== 307 +-- truncate_limit: 100 +-- okay, let's try updating all of the base1 values to *4 +-- which should fail. +update pktable set base1=base1*4 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET base1 = base1 * 4" +== 308 +-- truncate_limit: 100 +-- okay, let's try an update that should work. +update pktable set base1=base1*4 where base1<3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET base1 = base1 * 4 WHERE base1 < 3" +== 309 +-- truncate_limit: 100 +-- and a delete that should work +delete from pktable where base1>3 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE base1 > 3" +== 310 +-- truncate_limit: 100 +-- cleanup +drop table fktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable" +== 311 +-- truncate_limit: 100 +drop table pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 312 +-- truncate_limit: 100 +drop table pktable_base +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable_base" +== 313 +-- truncate_limit: 100 +-- Now we'll do one all in 1 table with 2 columns of matching types +create table pktable_base(base1 int not null, base2 int) +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable_base (base1 int NOT NULL, base2 int)" +== 314 +-- truncate_limit: 100 +create table pktable(ptest1 int, ptest2 int, primary key(base1, ptest1), foreign key(base2, ptest2) references + pktable(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 int, ptest2 int, PRIMARY KEY (base1, ptest1), FOREIGN KEY (base2, pt..." +== 315 +-- truncate_limit: 100 +insert into pktable (base1, ptest1, base2, ptest2) values (1, 1, 1, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1, ptest1, base2, ptest2) VALUES (1, 1, 1, 1)" +== 316 +-- truncate_limit: 100 +insert into pktable (base1, ptest1, base2, ptest2) values (2, 1, 1, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1, ptest1, base2, ptest2) VALUES (2, 1, 1, 1)" +== 317 +-- truncate_limit: 100 +insert into pktable (base1, ptest1, base2, ptest2) values (2, 2, 2, 1) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1, ptest1, base2, ptest2) VALUES (2, 2, 2, 1)" +== 318 +-- truncate_limit: 100 +insert into pktable (base1, ptest1, base2, ptest2) values (1, 3, 2, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1, ptest1, base2, ptest2) VALUES (1, 3, 2, 2)" +== 319 +-- truncate_limit: 100 +-- fails (3,2) isn't in base1, ptest1 +insert into pktable (base1, ptest1, base2, ptest2) values (2, 3, 3, 2) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable (base1, ptest1, base2, ptest2) VALUES (2, 3, 3, 2)" +== 320 +-- truncate_limit: 100 +-- fails (2,2) is being referenced +delete from pktable where base1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE base1 = 2" +== 321 +-- truncate_limit: 100 +-- fails (1,1) is being referenced (twice) +update pktable set base1=3 where base1=1 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET base1 = 3 WHERE base1 = 1" +== 322 +-- truncate_limit: 100 +-- this sequence of two deletes will work, since after the first there will be no (2,*) references +delete from pktable where base2=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE base2 = 2" +== 323 +-- truncate_limit: 100 +delete from pktable where base1=2 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable WHERE base1 = 2" +== 324 +-- truncate_limit: 100 +drop table pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 325 +-- truncate_limit: 100 +drop table pktable_base +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable_base" +== 326 +-- truncate_limit: 100 +-- 2 columns (2 tables), mismatched types +create table pktable_base(base1 int not null) +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable_base (base1 int NOT NULL)" +== 327 +-- truncate_limit: 100 +create table pktable(ptest1 inet, primary key(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 inet, PRIMARY KEY (base1, ptest1)) INHERITS (pktable_base)" +== 328 +-- truncate_limit: 100 +-- just generally bad types (with and without column references on the referenced table) +create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 cidr, ftest2 int[], FOREIGN KEY (ftest1, ftest2) REFERENCES pktable)" +== 329 +-- truncate_limit: 100 +create table fktable(ftest1 cidr, ftest2 int[], foreign key (ftest1, ftest2) references pktable(base1, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 cidr, ftest2 int[], FOREIGN KEY (ftest1, ftest2) REFERENCES pktable ..." +== 330 +-- truncate_limit: 100 +-- let's mix up which columns reference which +create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 inet, FOREIGN KEY (ftest2, ftest1) REFERENCES pktable)" +== 331 +-- truncate_limit: 100 +create table fktable(ftest1 int, ftest2 inet, foreign key(ftest2, ftest1) references pktable(base1, ptest1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 inet, FOREIGN KEY (ftest2, ftest1) REFERENCES pktable (b..." +== 332 +-- truncate_limit: 100 +create table fktable(ftest1 int, ftest2 inet, foreign key(ftest1, ftest2) references pktable(ptest1, base1)) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (ftest1 int, ftest2 inet, FOREIGN KEY (ftest1, ftest2) REFERENCES pktable (p..." +== 333 +-- truncate_limit: 100 +drop table pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 334 +-- truncate_limit: 100 +drop table pktable_base +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable_base" +== 335 +-- truncate_limit: 100 +-- 2 columns (1 table), mismatched types +create table pktable_base(base1 int not null, base2 int) +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable_base (base1 int NOT NULL, base2 int)" +== 336 +-- truncate_limit: 100 +create table pktable(ptest1 inet, ptest2 inet[], primary key(base1, ptest1), foreign key(base2, ptest2) references + pktable(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 inet, ptest2 inet[], PRIMARY KEY (base1, ptest1), FOREIGN KEY (base2..." +== 337 +-- truncate_limit: 100 +create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(base2, ptest2) references + pktable(ptest1, base1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 inet, ptest2 inet, PRIMARY KEY (base1, ptest1), FOREIGN KEY (base2, ..." +== 338 +-- truncate_limit: 100 +create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references + pktable(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 inet, ptest2 inet, PRIMARY KEY (base1, ptest1), FOREIGN KEY (ptest2,..." +== 339 +-- truncate_limit: 100 +create table pktable(ptest1 inet, ptest2 inet, primary key(base1, ptest1), foreign key(ptest2, base2) references + pktable(base1, ptest1)) inherits (pktable_base) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (ptest1 inet, ptest2 inet, PRIMARY KEY (base1, ptest1), FOREIGN KEY (ptest2,..." +== 340 +-- truncate_limit: 100 +drop table pktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable" +== 341 +-- truncate_limit: 100 +drop table pktable_base +-- +TABLE: name="pktable_base" schema="" table="pktable_base" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable_base" +== 342 +-- truncate_limit: 100 +|-- +-- Deferrable constraints +|-- + +-- deferrable, explicitly deferred +CREATE TABLE pktable ( + id INT4 PRIMARY KEY, + other INT4 +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (id int4 PRIMARY KEY, other int4)" +== 343 +-- truncate_limit: 100 +CREATE TABLE fktable ( + id INT4 PRIMARY KEY, + fk INT4 REFERENCES pktable DEFERRABLE +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (id int4 PRIMARY KEY, fk int4 REFERENCES pktable DEFERRABLE)" +== 344 +-- truncate_limit: 100 +-- default to immediate: should fail +INSERT INTO fktable VALUES (5, 10) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (5, 10)" +== 345 +-- truncate_limit: 100 +-- explicitly defer the constraint +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 346 +-- truncate_limit: 100 +SET CONSTRAINTS ALL DEFERRED +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS ALL DEFERRED" +== 347 +-- truncate_limit: 100 +INSERT INTO fktable VALUES (10, 15) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (10, 15)" +== 348 +-- truncate_limit: 100 +INSERT INTO pktable VALUES (15, 0) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (15, 0)" +== 349 +-- truncate_limit: 100 +-- make the FK insert valid + +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 350 +-- truncate_limit: 100 +DROP TABLE fktable, pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable, pktable" +== 351 +-- truncate_limit: 100 +-- deferrable, initially deferred +CREATE TABLE pktable ( + id INT4 PRIMARY KEY, + other INT4 +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (id int4 PRIMARY KEY, other int4)" +== 352 +-- truncate_limit: 100 +CREATE TABLE fktable ( + id INT4 PRIMARY KEY, + fk INT4 REFERENCES pktable DEFERRABLE INITIALLY DEFERRED +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (id int4 PRIMARY KEY, fk int4 REFERENCES pktable DEFERRABLE INITIALLY DEFERRED)" +== 353 +-- truncate_limit: 100 +-- default to deferred, should succeed +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 354 +-- truncate_limit: 100 +INSERT INTO fktable VALUES (100, 200) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (100, 200)" +== 355 +-- truncate_limit: 100 +INSERT INTO pktable VALUES (200, 500) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (200, 500)" +== 356 +-- truncate_limit: 100 +-- make the FK insert valid + +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 357 +-- truncate_limit: 100 +-- default to deferred, explicitly make immediate +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 358 +-- truncate_limit: 100 +SET CONSTRAINTS ALL IMMEDIATE +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS ALL IMMEDIATE" +== 359 +-- truncate_limit: 100 +-- should fail +INSERT INTO fktable VALUES (500, 1000) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (500, 1000)" +== 360 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 361 +-- truncate_limit: 100 +DROP TABLE fktable, pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable, pktable" +== 362 +-- truncate_limit: 100 +-- tricky behavior: according to SQL99, if a deferred constraint is set +-- to 'immediate' mode, it should be checked for validity *immediately*, +-- not when the current transaction commits (i.e. the mode change applies +-- retroactively) +CREATE TABLE pktable ( + id INT4 PRIMARY KEY, + other INT4 +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (id int4 PRIMARY KEY, other int4)" +== 363 +-- truncate_limit: 100 +CREATE TABLE fktable ( + id INT4 PRIMARY KEY, + fk INT4 REFERENCES pktable DEFERRABLE +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (id int4 PRIMARY KEY, fk int4 REFERENCES pktable DEFERRABLE)" +== 364 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 365 +-- truncate_limit: 100 +SET CONSTRAINTS ALL DEFERRED +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS ALL DEFERRED" +== 366 +-- truncate_limit: 100 +-- should succeed, for now +INSERT INTO fktable VALUES (1000, 2000) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1000, 2000)" +== 367 +-- truncate_limit: 100 +-- should cause transaction abort, due to preceding error +SET CONSTRAINTS ALL IMMEDIATE +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS ALL IMMEDIATE" +== 368 +-- truncate_limit: 100 +INSERT INTO pktable VALUES (2000, 3) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (2000, 3)" +== 369 +-- truncate_limit: 100 +-- too late + +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 370 +-- truncate_limit: 100 +DROP TABLE fktable, pktable +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fktable, pktable" +== 371 +-- truncate_limit: 100 +-- deferrable, initially deferred +CREATE TABLE pktable ( + id INT4 PRIMARY KEY, + other INT4 +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable (id int4 PRIMARY KEY, other int4)" +== 372 +-- truncate_limit: 100 +CREATE TABLE fktable ( + id INT4 PRIMARY KEY, + fk INT4 REFERENCES pktable DEFERRABLE INITIALLY DEFERRED +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable (id int4 PRIMARY KEY, fk int4 REFERENCES pktable DEFERRABLE INITIALLY DEFERRED)" +== 373 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 374 +-- truncate_limit: 100 +-- no error here +INSERT INTO fktable VALUES (100, 200) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (100, 200)" +== 375 +-- truncate_limit: 100 +-- error here on commit +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 376 +-- truncate_limit: 100 +DROP TABLE pktable, fktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable, fktable" +== 377 +-- truncate_limit: 100 +-- test notice about expensive referential integrity checks, +-- where the index cannot be used because of type incompatibilities. + +CREATE TEMP TABLE pktable ( + id1 INT4 PRIMARY KEY, + id2 VARCHAR(4) UNIQUE, + id3 REAL UNIQUE, + UNIQUE(id1, id2, id3) +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pktable (id1 int4 PRIMARY KEY, id2 varchar(4) UNIQUE, id3 real UNIQUE, UNI..." +== 378 +-- truncate_limit: 100 +CREATE TEMP TABLE fktable ( + x1 INT4 REFERENCES pktable(id1), + x2 VARCHAR(4) REFERENCES pktable(id2), + x3 REAL REFERENCES pktable(id3), + x4 TEXT, + x5 INT2 +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (x1 int4 REFERENCES pktable (id1), x2 varchar(4) REFERENCES pktabl..." +== 379 +-- truncate_limit: 100 +-- check individual constraints with alter table. + +-- should fail + +-- varchar does not promote to real +ALTER TABLE fktable ADD CONSTRAINT fk_2_3 +FOREIGN KEY (x2) REFERENCES pktable(id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_2_3 FOREIGN KEY (x2) REFERENCES pktable (id3)" +== 380 +-- truncate_limit: 100 +-- nor to int4 +ALTER TABLE fktable ADD CONSTRAINT fk_2_1 +FOREIGN KEY (x2) REFERENCES pktable(id1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_2_1 FOREIGN KEY (x2) REFERENCES pktable (id1)" +== 381 +-- truncate_limit: 100 +-- real does not promote to int4 +ALTER TABLE fktable ADD CONSTRAINT fk_3_1 +FOREIGN KEY (x3) REFERENCES pktable(id1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_3_1 FOREIGN KEY (x3) REFERENCES pktable (id1)" +== 382 +-- truncate_limit: 100 +-- int4 does not promote to text +ALTER TABLE fktable ADD CONSTRAINT fk_1_2 +FOREIGN KEY (x1) REFERENCES pktable(id2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_1_2 FOREIGN KEY (x1) REFERENCES pktable (id2)" +== 383 +-- truncate_limit: 100 +-- should succeed + +-- int4 promotes to real +ALTER TABLE fktable ADD CONSTRAINT fk_1_3 +FOREIGN KEY (x1) REFERENCES pktable(id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_1_3 FOREIGN KEY (x1) REFERENCES pktable (id3)" +== 384 +-- truncate_limit: 100 +-- text is compatible with varchar +ALTER TABLE fktable ADD CONSTRAINT fk_4_2 +FOREIGN KEY (x4) REFERENCES pktable(id2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_4_2 FOREIGN KEY (x4) REFERENCES pktable (id2)" +== 385 +-- truncate_limit: 100 +-- int2 is part of integer opfamily as of 8.0 +ALTER TABLE fktable ADD CONSTRAINT fk_5_1 +FOREIGN KEY (x5) REFERENCES pktable(id1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_5_1 FOREIGN KEY (x5) REFERENCES pktable (id1)" +== 386 +-- truncate_limit: 100 +-- check multikey cases, especially out-of-order column lists + +-- these should work + +ALTER TABLE fktable ADD CONSTRAINT fk_123_123 +FOREIGN KEY (x1,x2,x3) REFERENCES pktable(id1,id2,id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_123_123 FOREIGN KEY (x1, x2, x3) REFERENCES pktable (id1, i..." +== 387 +-- truncate_limit: 100 +ALTER TABLE fktable ADD CONSTRAINT fk_213_213 +FOREIGN KEY (x2,x1,x3) REFERENCES pktable(id2,id1,id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_213_213 FOREIGN KEY (x2, x1, x3) REFERENCES pktable (id2, i..." +== 388 +-- truncate_limit: 100 +ALTER TABLE fktable ADD CONSTRAINT fk_253_213 +FOREIGN KEY (x2,x5,x3) REFERENCES pktable(id2,id1,id3) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_253_213 FOREIGN KEY (x2, x5, x3) REFERENCES pktable (id2, i..." +== 389 +-- truncate_limit: 100 +-- these should fail + +ALTER TABLE fktable ADD CONSTRAINT fk_123_231 +FOREIGN KEY (x1,x2,x3) REFERENCES pktable(id2,id3,id1) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_123_231 FOREIGN KEY (x1, x2, x3) REFERENCES pktable (id2, i..." +== 390 +-- truncate_limit: 100 +ALTER TABLE fktable ADD CONSTRAINT fk_241_132 +FOREIGN KEY (x2,x4,x1) REFERENCES pktable(id1,id3,id2) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ADD CONSTRAINT fk_241_132 FOREIGN KEY (x2, x4, x1) REFERENCES pktable (id1, i..." +== 391 +-- truncate_limit: 100 +DROP TABLE pktable, fktable +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable, fktable" +== 392 +-- truncate_limit: 100 +-- test a tricky case: we can elide firing the FK check trigger during +-- an UPDATE if the UPDATE did not change the foreign key +-- field. However, we can't do this if our transaction was the one that +-- created the updated row and the trigger is deferred, since our UPDATE +-- will have invalidated the original newly-inserted tuple, and therefore +-- cause the on-INSERT RI trigger not to be fired. + +CREATE TEMP TABLE pktable ( + id int primary key, + other int +) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pktable (id int PRIMARY KEY, other int)" +== 393 +-- truncate_limit: 100 +CREATE TEMP TABLE fktable ( + id int primary key, + fk int references pktable deferrable initially deferred +) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fktable (id int PRIMARY KEY, fk int REFERENCES pktable DEFERRABLE INITIALL..." +== 394 +-- truncate_limit: 100 +INSERT INTO pktable VALUES (5, 10) +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable VALUES (5, 10)" +== 395 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 396 +-- truncate_limit: 100 +-- doesn't match PK, but no error yet +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (0, 20)" +== 397 +-- truncate_limit: 100 +-- don't change FK +UPDATE fktable SET id = id + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET id = id + 1" +== 398 +-- truncate_limit: 100 +-- should catch error from initial INSERT +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 399 +-- truncate_limit: 100 +-- check same case when insert is in a different subtransaction than update + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 400 +-- truncate_limit: 100 +-- doesn't match PK, but no error yet +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (0, 20)" +== 401 +-- truncate_limit: 100 +-- UPDATE will be in a subxact +SAVEPOINT savept1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT savept1" +== 402 +-- truncate_limit: 100 +-- don't change FK +UPDATE fktable SET id = id + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET id = id + 1" +== 403 +-- truncate_limit: 100 +-- should catch error from initial INSERT +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 404 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 405 +-- truncate_limit: 100 +-- INSERT will be in a subxact +SAVEPOINT savept1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT savept1" +== 406 +-- truncate_limit: 100 +-- doesn't match PK, but no error yet +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (0, 20)" +== 407 +-- truncate_limit: 100 +RELEASE SAVEPOINT savept1 +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE savept1" +== 408 +-- truncate_limit: 100 +-- don't change FK +UPDATE fktable SET id = id + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET id = id + 1" +== 409 +-- truncate_limit: 100 +-- should catch error from initial INSERT +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 410 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 411 +-- truncate_limit: 100 +-- doesn't match PK, but no error yet +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (0, 20)" +== 412 +-- truncate_limit: 100 +-- UPDATE will be in a subxact +SAVEPOINT savept1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT savept1" +== 413 +-- truncate_limit: 100 +-- don't change FK +UPDATE fktable SET id = id + 1 +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fktable SET id = id + 1" +== 414 +-- truncate_limit: 100 +-- Roll back the UPDATE +ROLLBACK TO savept1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT savept1" +== 415 +-- truncate_limit: 100 +-- should catch error from initial INSERT +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 416 +-- truncate_limit: 100 +|-- +-- check ALTER CONSTRAINT +|-- + +INSERT INTO fktable VALUES (1, 5) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (1, 5)" +== 417 +-- truncate_limit: 100 +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey DEFERRABLE INITIALLY IMMEDIATE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey DEFERRABLE" +== 418 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 419 +-- truncate_limit: 100 +-- doesn't match FK, should throw error now +UPDATE pktable SET id = 10 WHERE id = 5 +-- +TABLE: name="pktable" schema="" table="pktable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable SET id = 10 WHERE id = 5" +== 420 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 421 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 422 +-- truncate_limit: 100 +-- doesn't match PK, should throw error now +INSERT INTO fktable VALUES (0, 20) +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable VALUES (0, 20)" +== 423 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 424 +-- truncate_limit: 100 +-- try additional syntax +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE +-- +TABLE: name="fktable" schema="" table="fktable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey" +== 425 +-- truncate_limit: 100 +-- illegal options +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE INITIALLY DEFERRED +-- +ERROR: constraint declared INITIALLY DEFERRED must be DEFERRABLE +CURSORPOS: 88 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 426 +-- truncate_limit: 100 +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NO INHERIT +-- +ERROR: FOREIGN KEY constraints cannot be marked NO INHERIT +FILENAME: gram.y +FUNCNAME: processCASbits +== 427 +-- truncate_limit: 100 +ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT VALID +-- +ERROR: FOREIGN KEY constraints cannot be marked NOT VALID +FILENAME: gram.y +FUNCNAME: processCASbits +== 428 +-- truncate_limit: 100 +-- test order of firing of FK triggers when several RI-induced changes need to +-- be made to the same row. This was broken by subtransaction-related +-- changes in 8.0. + +CREATE TEMP TABLE users ( + id INT PRIMARY KEY, + name VARCHAR NOT NULL +) +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE users (id int PRIMARY KEY, name varchar NOT NULL)" +== 429 +-- truncate_limit: 100 +INSERT INTO users VALUES (1, 'Jozko') +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO users VALUES (1, 'Jozko')" +== 430 +-- truncate_limit: 100 +INSERT INTO users VALUES (2, 'Ferko') +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO users VALUES (2, 'Ferko')" +== 431 +-- truncate_limit: 100 +INSERT INTO users VALUES (3, 'Samko') +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO users VALUES (3, 'Samko')" +== 432 +-- truncate_limit: 100 +CREATE TEMP TABLE tasks ( + id INT PRIMARY KEY, + owner INT REFERENCES users ON UPDATE CASCADE ON DELETE SET NULL, + worker INT REFERENCES users ON UPDATE CASCADE ON DELETE SET NULL, + checked_by INT REFERENCES users ON UPDATE CASCADE ON DELETE SET NULL +) +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tasks (id int PRIMARY KEY, owner int REFERENCES users ON UPDATE CASCADE ON..." +== 433 +-- truncate_limit: 100 +INSERT INTO tasks VALUES (1,1,NULL,NULL) +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tasks VALUES (1, 1, NULL, NULL)" +== 434 +-- truncate_limit: 100 +INSERT INTO tasks VALUES (2,2,2,NULL) +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tasks VALUES (2, 2, 2, NULL)" +== 435 +-- truncate_limit: 100 +INSERT INTO tasks VALUES (3,3,3,3) +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tasks VALUES (3, 3, 3, 3)" +== 436 +-- truncate_limit: 100 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tasks" +== 437 +-- truncate_limit: 100 +UPDATE users SET id = 4 WHERE id = 3 +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE users SET id = 4 WHERE id = 3" +== 438 +-- truncate_limit: 100 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tasks" +== 439 +-- truncate_limit: 100 +DELETE FROM users WHERE id = 4 +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM users WHERE id = 4" +== 440 +-- truncate_limit: 100 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tasks" +== 441 +-- truncate_limit: 100 +-- could fail with only 2 changes to make, if row was already updated +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 442 +-- truncate_limit: 100 +UPDATE tasks set id=id WHERE id=2 +-- +TABLE: name="tasks" schema="" table="tasks" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tasks SET id = id WHERE id = 2" +== 443 +-- truncate_limit: 100 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tasks" +== 444 +-- truncate_limit: 100 +DELETE FROM users WHERE id = 2 +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM users WHERE id = 2" +== 445 +-- truncate_limit: 100 +SELECT * FROM tasks +-- +TABLE: name="tasks" schema="" table="tasks" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tasks" +== 446 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 447 +-- truncate_limit: 100 +|-- +-- Test self-referential FK with CASCADE (bug #6268) +|-- +create temp table selfref ( + a int primary key, + b int, + foreign key (b) references selfref (a) + on update cascade on delete cascade +) +-- +TABLE: name="selfref" schema="" table="selfref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE selfref (a int PRIMARY KEY, b int, FOREIGN KEY (b) REFERENCES selfref (a) ..." +== 448 +-- truncate_limit: 100 +insert into selfref (a, b) +values + (0, 0), + (1, 1) +-- +TABLE: name="selfref" schema="" table="selfref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO selfref (a, b) VALUES (0, 0), (1, 1)" +== 449 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 450 +-- truncate_limit: 100 +update selfref set a = 123 where a = 0 +-- +TABLE: name="selfref" schema="" table="selfref" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE selfref SET a = 123 WHERE a = 0" +== 451 +-- truncate_limit: 100 +select a, b from selfref +-- +TABLE: name="selfref" schema="" table="selfref" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM selfref" +== 452 +-- truncate_limit: 100 +update selfref set a = 456 where a = 123 +-- +TABLE: name="selfref" schema="" table="selfref" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE selfref SET a = 456 WHERE a = 123" +== 453 +-- truncate_limit: 100 +select a, b from selfref +-- +TABLE: name="selfref" schema="" table="selfref" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM selfref" +== 454 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 455 +-- truncate_limit: 100 +|-- +-- Test that SET DEFAULT actions recognize updates to default values +|-- +create temp table defp (f1 int primary key) +-- +TABLE: name="defp" schema="" table="defp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE defp (f1 int PRIMARY KEY)" +== 456 +-- truncate_limit: 100 +create temp table defc (f1 int default 0 + references defp on delete set default) +-- +TABLE: name="defc" schema="" table="defc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE defc (f1 int DEFAULT 0 REFERENCES defp ON DELETE SET DEFAULT)" +== 457 +-- truncate_limit: 100 +insert into defp values (0), (1), (2) +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defp VALUES (0), (1), (2)" +== 458 +-- truncate_limit: 100 +insert into defc values (2) +-- +TABLE: name="defc" schema="" table="defc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO defc VALUES (2)" +== 459 +-- truncate_limit: 100 +select * from defc +-- +TABLE: name="defc" schema="" table="defc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM defc" +== 460 +-- truncate_limit: 100 +delete from defp where f1 = 2 +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM defp WHERE f1 = 2" +== 461 +-- truncate_limit: 100 +select * from defc +-- +TABLE: name="defc" schema="" table="defc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM defc" +== 462 +-- truncate_limit: 100 +delete from defp where f1 = 0 +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM defp WHERE f1 = 0" +== 463 +-- truncate_limit: 100 +-- fail +alter table defc alter column f1 set default 1 +-- +TABLE: name="defc" schema="" table="defc" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE defc ALTER COLUMN f1 SET DEFAULT 1" +== 464 +-- truncate_limit: 100 +delete from defp where f1 = 0 +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM defp WHERE f1 = 0" +== 465 +-- truncate_limit: 100 +select * from defc +-- +TABLE: name="defc" schema="" table="defc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM defc" +== 466 +-- truncate_limit: 100 +delete from defp where f1 = 1 +-- +TABLE: name="defp" schema="" table="defp" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM defp WHERE f1 = 1" +== 467 +-- truncate_limit: 100 +-- fail + +|-- +-- Test the difference between NO ACTION and RESTRICT +|-- +create temp table pp (f1 int primary key) +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pp (f1 int PRIMARY KEY)" +== 468 +-- truncate_limit: 100 +create temp table cc (f1 int references pp on update no action on delete no action) +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE cc (f1 int REFERENCES pp)" +== 469 +-- truncate_limit: 100 +insert into pp values(12) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pp VALUES (12)" +== 470 +-- truncate_limit: 100 +insert into pp values(11) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pp VALUES (11)" +== 471 +-- truncate_limit: 100 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pp SET f1 = f1 + 1" +== 472 +-- truncate_limit: 100 +insert into cc values(13) +-- +TABLE: name="cc" schema="" table="cc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cc VALUES (13)" +== 473 +-- truncate_limit: 100 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pp SET f1 = f1 + 1" +== 474 +-- truncate_limit: 100 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pp SET f1 = f1 + 1" +== 475 +-- truncate_limit: 100 +-- fail +delete from pp where f1 = 13 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pp WHERE f1 = 13" +== 476 +-- truncate_limit: 100 +-- fail +drop table pp, cc +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp, cc" +== 477 +-- truncate_limit: 100 +create temp table pp (f1 int primary key) +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pp (f1 int PRIMARY KEY)" +== 478 +-- truncate_limit: 100 +create temp table cc (f1 int references pp on update restrict on delete restrict) +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE cc (f1 int REFERENCES pp ON UPDATE RESTRICT ON DELETE RESTRICT)" +== 479 +-- truncate_limit: 100 +insert into pp values(12) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pp VALUES (12)" +== 480 +-- truncate_limit: 100 +insert into pp values(11) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pp VALUES (11)" +== 481 +-- truncate_limit: 100 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pp SET f1 = f1 + 1" +== 482 +-- truncate_limit: 100 +insert into cc values(13) +-- +TABLE: name="cc" schema="" table="cc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cc VALUES (13)" +== 483 +-- truncate_limit: 100 +update pp set f1=f1+1 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pp SET f1 = f1 + 1" +== 484 +-- truncate_limit: 100 +-- fail +delete from pp where f1 = 13 +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pp WHERE f1 = 13" +== 485 +-- truncate_limit: 100 +-- fail +drop table pp, cc +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp, cc" +== 486 +-- truncate_limit: 100 +|-- +-- Test interaction of foreign-key optimization with rules (bug #14219) +|-- +create temp table t1 (a integer primary key, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (a int PRIMARY KEY, b text)" +== 487 +-- truncate_limit: 100 +create temp table t2 (a integer primary key, b integer references t1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t2 (a int PRIMARY KEY, b int REFERENCES t1)" +== 488 +-- truncate_limit: 100 +create rule r1 as on delete to t1 do delete from t2 where t2.b = old.a +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r1 AS ON DELETE TO t1 DO DELETE FROM t2 WHERE t2.b = old.a" +== 489 +-- truncate_limit: 100 +explain (costs off) delete from t1 where a = 1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM t1 WHERE a = 1" +== 490 +-- truncate_limit: 100 +delete from t1 where a = 1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t1 WHERE a = 1" +== 491 +-- truncate_limit: 100 +-- Test a primary key with attributes located in later attnum positions +-- compared to the fk attributes. +create table pktable2 (a int, b int, c int, d int, e int, primary key (d, e)) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable2 (a int, b int, c int, d int, e int, PRIMARY KEY (d, e))" +== 492 +-- truncate_limit: 100 +create table fktable2 (d int, e int, foreign key (d, e) references pktable2) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable2 (d int, e int, FOREIGN KEY (d, e) REFERENCES pktable2)" +== 493 +-- truncate_limit: 100 +insert into pktable2 values (1, 2, 3, 4, 5) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable2 VALUES (1, 2, 3, 4, 5)" +== 494 +-- truncate_limit: 100 +insert into fktable2 values (4, 5) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable2 VALUES (4, 5)" +== 495 +-- truncate_limit: 100 +delete from pktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable2" +== 496 +-- truncate_limit: 100 +update pktable2 set d = 5 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable2 SET d = 5" +== 497 +-- truncate_limit: 100 +drop table pktable2, fktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable2, fktable2" +== 498 +-- truncate_limit: 100 +-- Test truncation of long foreign key names +create table pktable1 (a int primary key) +-- +TABLE: name="pktable1" schema="" table="pktable1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable1 (a int PRIMARY KEY)" +== 499 +-- truncate_limit: 100 +create table pktable2 (a int, b int, primary key (a, b)) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable2 (a int, b int, PRIMARY KEY (a, b))" +== 500 +-- truncate_limit: 100 +create table fktable2 ( + a int, + b int, + very_very_long_column_name_to_exceed_63_characters int, + foreign key (very_very_long_column_name_to_exceed_63_characters) references pktable1, + foreign key (a, very_very_long_column_name_to_exceed_63_characters) references pktable2, + foreign key (a, very_very_long_column_name_to_exceed_63_characters) references pktable2 +) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable2 (a int, b int, very_very_long_column_name_to_exceed_63_characters int, FORE..." +== 501 +-- truncate_limit: 100 +select conname from pg_constraint where conrelid = 'fktable2'::regclass order by conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT conname FROM pg_constraint WHERE conrelid = 'fktable2'::regclass ORDER BY conname" +== 502 +-- truncate_limit: 100 +drop table pktable1, pktable2, fktable2 +-- +TABLE: name="pktable1" schema="" table="pktable1" ctx=DDL +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable1, pktable2, fktable2" +== 503 +-- truncate_limit: 100 +|-- +-- Test deferred FK check on a tuple deleted by a rolled-back subtransaction +|-- +create table pktable2(f1 int primary key) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable2 (f1 int PRIMARY KEY)" +== 504 +-- truncate_limit: 100 +create table fktable2(f1 int references pktable2 deferrable initially deferred) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable2 (f1 int REFERENCES pktable2 DEFERRABLE INITIALLY DEFERRED)" +== 505 +-- truncate_limit: 100 +insert into pktable2 values(1) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable2 VALUES (1)" +== 506 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 507 +-- truncate_limit: 100 +insert into fktable2 values(1) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable2 VALUES (1)" +== 508 +-- truncate_limit: 100 +savepoint x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 509 +-- truncate_limit: 100 +delete from fktable2 +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fktable2" +== 510 +-- truncate_limit: 100 +rollback to x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 511 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 512 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 513 +-- truncate_limit: 100 +insert into fktable2 values(2) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable2 VALUES (2)" +== 514 +-- truncate_limit: 100 +savepoint x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 515 +-- truncate_limit: 100 +delete from fktable2 +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fktable2" +== 516 +-- truncate_limit: 100 +rollback to x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 517 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 518 +-- truncate_limit: 100 +-- fail + +|-- +-- Test that we prevent dropping FK constraint with pending trigger events +|-- +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 519 +-- truncate_limit: 100 +insert into fktable2 values(2) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable2 VALUES (2)" +== 520 +-- truncate_limit: 100 +alter table fktable2 drop constraint fktable2_f1_fkey +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable2 DROP CONSTRAINT fktable2_f1_fkey" +== 521 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 522 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 523 +-- truncate_limit: 100 +delete from pktable2 where f1 = 1 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pktable2 WHERE f1 = 1" +== 524 +-- truncate_limit: 100 +alter table fktable2 drop constraint fktable2_f1_fkey +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fktable2 DROP CONSTRAINT fktable2_f1_fkey" +== 525 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 526 +-- truncate_limit: 100 +drop table pktable2, fktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable2, fktable2" +== 527 +-- truncate_limit: 100 +|-- +-- Test keys that "look" different but compare as equal +|-- +create table pktable2 (a float8, b float8, primary key (a, b)) +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pktable2 (a float8, b float8, PRIMARY KEY (a, b))" +== 528 +-- truncate_limit: 100 +create table fktable2 (x float8, y float8, foreign key (x, y) references pktable2 (a, b) on update cascade) +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fktable2 (x float8, y float8, FOREIGN KEY (x, y) REFERENCES pktable2 (a, b) ON UPDAT..." +== 529 +-- truncate_limit: 100 +insert into pktable2 values ('-0', '-0') +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pktable2 VALUES ('-0', '-0')" +== 530 +-- truncate_limit: 100 +insert into fktable2 values ('-0', '-0') +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fktable2 VALUES ('-0', '-0')" +== 531 +-- truncate_limit: 100 +select * from pktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable2" +== 532 +-- truncate_limit: 100 +select * from fktable2 +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable2" +== 533 +-- truncate_limit: 100 +update pktable2 set a = '0' where a = '-0' +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pktable2 SET a = '0' WHERE a = '-0'" +== 534 +-- truncate_limit: 100 +select * from pktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pktable2" +== 535 +-- truncate_limit: 100 +-- should have updated fktable2.x +select * from fktable2 +-- +TABLE: name="fktable2" schema="" table="fktable2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fktable2" +== 536 +-- truncate_limit: 100 +drop table pktable2, fktable2 +-- +TABLE: name="pktable2" schema="" table="pktable2" ctx=DDL +TABLE: name="fktable2" schema="" table="fktable2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pktable2, fktable2" +== 537 +-- truncate_limit: 100 +|-- +-- Foreign keys and partitioned tables +|-- + +-- Creation of a partitioned hierarchy with irregular definitions +CREATE TABLE fk_notpartitioned_pk (fdrop1 int, a int, fdrop2 int, b int, + PRIMARY KEY (a, b)) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_notpartitioned_pk (fdrop1 int, a int, fdrop2 int, b int, PRIMARY KEY (a, b))" +== 538 +-- truncate_limit: 100 +ALTER TABLE fk_notpartitioned_pk DROP COLUMN fdrop1, DROP COLUMN fdrop2 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_notpartitioned_pk DROP fdrop1, DROP fdrop2" +== 539 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk (b int, fdrop1 int, a int) PARTITION BY RANGE (a, b) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk (b int, fdrop1 int, a int) PARTITION BY RANGE (a, b)" +== 540 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk DROP COLUMN fdrop1 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DROP fdrop1" +== 541 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_1 (fdrop1 int, fdrop2 int, a int, fdrop3 int, b int) +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_1 (fdrop1 int, fdrop2 int, a int, fdrop3 int, b int)" +== 542 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_1 DROP COLUMN fdrop1, DROP COLUMN fdrop2, DROP COLUMN fdrop3 +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_1 DROP fdrop1, DROP fdrop2, DROP fdrop3" +== 543 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_1 FOR VALUES FROM (0,0) TO (1000,1000) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_1 FOR VALUES FROM (0, 0) TO (100..." +== 544 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk" +== 545 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_2 (b int, fdrop1 int, fdrop2 int, a int) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_2 (b int, fdrop1 int, fdrop2 int, a int)" +== 546 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_2 DROP COLUMN fdrop1, DROP COLUMN fdrop2 +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_2 DROP fdrop1, DROP fdrop2" +== 547 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES FROM (1000,1000) TO (2000,2000) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES FROM (1000, 1000) T..." +== 548 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_3 (fdrop1 int, fdrop2 int, fdrop3 int, fdrop4 int, b int, a int) + PARTITION BY HASH (a) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_3 (fdrop1 int, fdrop2 int, fdrop3 int, fdrop4 int, b int, a int) P..." +== 549 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_3 DROP COLUMN fdrop1, DROP COLUMN fdrop2, + DROP COLUMN fdrop3, DROP COLUMN fdrop4 +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_3 DROP fdrop1, DROP fdrop2, DROP fdrop3, DROP fdrop4" +== 550 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_3_0 PARTITION OF fk_partitioned_fk_3 FOR VALUES WITH (MODULUS 5, REMAINDER 0) +-- +TABLE: name="fk_partitioned_fk_3_0" schema="" table="fk_partitioned_fk_3_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_3_0 PARTITION OF fk_partitioned_fk_3 FOR VALUES WITH (MODULUS 5, R..." +== 551 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_3_1 PARTITION OF fk_partitioned_fk_3 FOR VALUES WITH (MODULUS 5, REMAINDER 1) +-- +TABLE: name="fk_partitioned_fk_3_1" schema="" table="fk_partitioned_fk_3_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_3_1 PARTITION OF fk_partitioned_fk_3 FOR VALUES WITH (MODULUS 5, R..." +== 552 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_3 + FOR VALUES FROM (2000,2000) TO (3000,3000) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_3 FOR VALUES FROM (2000, 2000) T..." +== 553 +-- truncate_limit: 100 +-- Creating a foreign key with ONLY on a partitioned table referencing +-- a non-partitioned table fails. +ALTER TABLE ONLY fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk" +== 554 +-- truncate_limit: 100 +-- Adding a NOT VALID foreign key on a partitioned table referencing +-- a non-partitioned table fails. +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk NOT VALID +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk NOT VALID" +== 555 +-- truncate_limit: 100 +-- these inserts, targeting both the partition directly as well as the +-- partitioned table, should all fail +INSERT INTO fk_partitioned_fk (a,b) VALUES (500, 501) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (500, 501)" +== 556 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_1 (a,b) VALUES (500, 501) +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_1 (a, b) VALUES (500, 501)" +== 557 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk (a,b) VALUES (1500, 1501) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (1500, 1501)" +== 558 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_2 (a,b) VALUES (1500, 1501) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_2 (a, b) VALUES (1500, 1501)" +== 559 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk (a,b) VALUES (2500, 2502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (2500, 2502)" +== 560 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_3 (a,b) VALUES (2500, 2502) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2500, 2502)" +== 561 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk (a,b) VALUES (2501, 2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (2501, 2503)" +== 562 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_3 (a,b) VALUES (2501, 2503) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2501, 2503)" +== 563 +-- truncate_limit: 100 +-- but if we insert the values that make them valid, then they work +INSERT INTO fk_notpartitioned_pk VALUES (500, 501), (1500, 1501), + (2500, 2502), (2501, 2503) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk VALUES (500, 501), (1500, 1501), (2500, 2502), (2501, 2503)" +== 564 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk (a,b) VALUES (500, 501) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (500, 501)" +== 565 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk (a,b) VALUES (1500, 1501) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (1500, 1501)" +== 566 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk (a,b) VALUES (2500, 2502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (2500, 2502)" +== 567 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk (a,b) VALUES (2501, 2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (2501, 2503)" +== 568 +-- truncate_limit: 100 +-- this update fails because there is no referenced row +UPDATE fk_partitioned_fk SET a = a + 1 WHERE a = 2501 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_partitioned_fk SET a = a + 1 WHERE a = 2501" +== 569 +-- truncate_limit: 100 +-- but we can fix it thusly: +INSERT INTO fk_notpartitioned_pk (a,b) VALUES (2502, 2503) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk (a, b) VALUES (2502, 2503)" +== 570 +-- truncate_limit: 100 +UPDATE fk_partitioned_fk SET a = a + 1 WHERE a = 2501 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_partitioned_fk SET a = a + 1 WHERE a = 2501" +== 571 +-- truncate_limit: 100 +-- these updates would leave lingering rows in the referencing table; disallow +UPDATE fk_notpartitioned_pk SET b = 502 WHERE a = 500 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_notpartitioned_pk SET b = 502 WHERE a = 500" +== 572 +-- truncate_limit: 100 +UPDATE fk_notpartitioned_pk SET b = 1502 WHERE a = 1500 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_notpartitioned_pk SET b = 1502 WHERE a = 1500" +== 573 +-- truncate_limit: 100 +UPDATE fk_notpartitioned_pk SET b = 2504 WHERE a = 2500 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_notpartitioned_pk SET b = 2504 WHERE a = 2500" +== 574 +-- truncate_limit: 100 +-- check psql behavior +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey" +== 575 +-- truncate_limit: 100 +-- done. +DROP TABLE fk_notpartitioned_pk, fk_partitioned_fk +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_notpartitioned_pk, fk_partitioned_fk" +== 576 +-- truncate_limit: 100 +-- Altering a type referenced by a foreign key needs to drop/recreate the FK. +-- Ensure that works. +CREATE TABLE fk_notpartitioned_pk (a INT, PRIMARY KEY(a), CHECK (a > 0)) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_notpartitioned_pk (a int, PRIMARY KEY (a), CHECK (a > 0))" +== 577 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk (a INT REFERENCES fk_notpartitioned_pk(a) PRIMARY KEY) PARTITION BY RANGE(a) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk (a int REFERENCES fk_notpartitioned_pk (a) PRIMARY KEY) PARTITION ..." +== 578 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_1 PARTITION OF fk_partitioned_fk FOR VALUES FROM (MINVALUE) TO (MAXVALUE) +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_1 PARTITION OF fk_partitioned_fk FOR VALUES FROM (minvalue) TO (ma..." +== 579 +-- truncate_limit: 100 +INSERT INTO fk_notpartitioned_pk VALUES (1) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk VALUES (1)" +== 580 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk VALUES (1) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk VALUES (1)" +== 581 +-- truncate_limit: 100 +ALTER TABLE fk_notpartitioned_pk ALTER COLUMN a TYPE bigint +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_notpartitioned_pk ALTER COLUMN a TYPE bigint" +== 582 +-- truncate_limit: 100 +DELETE FROM fk_notpartitioned_pk WHERE a = 1 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_notpartitioned_pk WHERE a = 1" +== 583 +-- truncate_limit: 100 +DROP TABLE fk_notpartitioned_pk, fk_partitioned_fk +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_notpartitioned_pk, fk_partitioned_fk" +== 584 +-- truncate_limit: 100 +-- Test some other exotic foreign key features: MATCH SIMPLE, ON UPDATE/DELETE +-- actions +CREATE TABLE fk_notpartitioned_pk (a int, b int, primary key (a, b)) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_notpartitioned_pk (a int, b int, PRIMARY KEY (a, b))" +== 585 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk (a int default 2501, b int default 142857) PARTITION BY LIST (a) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk (a int DEFAULT 2501, b int DEFAULT 142857) PARTITION BY LIST (a)" +== 586 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_1 PARTITION OF fk_partitioned_fk FOR VALUES IN (NULL,500,501,502) +-- +TABLE: name="fk_partitioned_fk_1" schema="" table="fk_partitioned_fk_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_1 PARTITION OF fk_partitioned_fk FOR VALUES IN (NULL, 500, 501, 502)" +== 587 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk MATCH SIMPLE + ON DELETE SET NULL ON UPDATE SET NULL +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk ON UPDATE SE..." +== 588 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_2 PARTITION OF fk_partitioned_fk FOR VALUES IN (1500,1502) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_2 PARTITION OF fk_partitioned_fk FOR VALUES IN (1500, 1502)" +== 589 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_3 (a int, b int) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_3 (a int, b int)" +== 590 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_3 FOR VALUES IN (2500,2501,2502,2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_3 FOR VALUES IN (2500, 2501, 250..." +== 591 +-- truncate_limit: 100 +-- this insert fails +INSERT INTO fk_partitioned_fk (a, b) VALUES (2502, 2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (2502, 2503)" +== 592 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503)" +== 593 +-- truncate_limit: 100 +-- but since the FK is MATCH SIMPLE, this one doesn't +INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, NULL) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, NULL)" +== 594 +-- truncate_limit: 100 +-- now create the referenced row ... +INSERT INTO fk_notpartitioned_pk VALUES (2502, 2503) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk VALUES (2502, 2503)" +== 595 +-- truncate_limit: 100 +--- and now the same insert work +INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503)" +== 596 +-- truncate_limit: 100 +-- this always works +INSERT INTO fk_partitioned_fk (a,b) VALUES (NULL, NULL) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk (a, b) VALUES (NULL, NULL)" +== 597 +-- truncate_limit: 100 +-- MATCH FULL +INSERT INTO fk_notpartitioned_pk VALUES (1, 2) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk VALUES (1, 2)" +== 598 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_full (x int, y int) PARTITION BY RANGE (x) +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_full (x int, y int) PARTITION BY RANGE (x)" +== 599 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_full_1 PARTITION OF fk_partitioned_fk_full DEFAULT +-- +TABLE: name="fk_partitioned_fk_full_1" schema="" table="fk_partitioned_fk_full_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_full_1 PARTITION OF fk_partitioned_fk_full DEFAULT" +== 600 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_full VALUES (1, NULL) +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_full VALUES (1, NULL)" +== 601 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_full ADD FOREIGN KEY (x, y) REFERENCES fk_notpartitioned_pk MATCH FULL +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_full ADD FOREIGN KEY (x, y) REFERENCES fk_notpartitioned_pk MATCH FULL" +== 602 +-- truncate_limit: 100 +-- fails +TRUNCATE fk_partitioned_fk_full +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE fk_partitioned_fk_full" +== 603 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_full ADD FOREIGN KEY (x, y) REFERENCES fk_notpartitioned_pk MATCH FULL +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_full ADD FOREIGN KEY (x, y) REFERENCES fk_notpartitioned_pk MATCH FULL" +== 604 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_full VALUES (1, NULL) +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_full VALUES (1, NULL)" +== 605 +-- truncate_limit: 100 +-- fails +DROP TABLE fk_partitioned_fk_full +-- +TABLE: name="fk_partitioned_fk_full" schema="" table="fk_partitioned_fk_full" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_partitioned_fk_full" +== 606 +-- truncate_limit: 100 +-- ON UPDATE SET NULL +SELECT tableoid::regclass, a, b FROM fk_partitioned_fk WHERE b IS NULL ORDER BY a +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, a, b FROM fk_partitioned_fk WHERE b IS NULL ORDER BY a" +== 607 +-- truncate_limit: 100 +UPDATE fk_notpartitioned_pk SET a = a + 1 WHERE a = 2502 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_notpartitioned_pk SET a = a + 1 WHERE a = 2502" +== 608 +-- truncate_limit: 100 +SELECT tableoid::regclass, a, b FROM fk_partitioned_fk WHERE b IS NULL ORDER BY a +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, a, b FROM fk_partitioned_fk WHERE b IS NULL ORDER BY a" +== 609 +-- truncate_limit: 100 +-- ON DELETE SET NULL +INSERT INTO fk_partitioned_fk VALUES (2503, 2503) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk VALUES (2503, 2503)" +== 610 +-- truncate_limit: 100 +SELECT count(*) FROM fk_partitioned_fk WHERE a IS NULL +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fk_partitioned_fk WHERE a IS NULL" +== 611 +-- truncate_limit: 100 +DELETE FROM fk_notpartitioned_pk +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_notpartitioned_pk" +== 612 +-- truncate_limit: 100 +SELECT count(*) FROM fk_partitioned_fk WHERE a IS NULL +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fk_partitioned_fk WHERE a IS NULL" +== 613 +-- truncate_limit: 100 +-- ON UPDATE/DELETE SET DEFAULT +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey" +== 614 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk + ON DELETE SET DEFAULT ON UPDATE SET DEFAULT +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk ON UPDATE SE..." +== 615 +-- truncate_limit: 100 +INSERT INTO fk_notpartitioned_pk VALUES (2502, 2503) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk VALUES (2502, 2503)" +== 616 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503) +-- +TABLE: name="fk_partitioned_fk_3" schema="" table="fk_partitioned_fk_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_3 (a, b) VALUES (2502, 2503)" +== 617 +-- truncate_limit: 100 +-- this fails, because the defaults for the referencing table are not present +-- in the referenced table: +UPDATE fk_notpartitioned_pk SET a = 1500 WHERE a = 2502 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_notpartitioned_pk SET a = 1500 WHERE a = 2502" +== 618 +-- truncate_limit: 100 +-- but inserting the row we can make it work: +INSERT INTO fk_notpartitioned_pk VALUES (2501, 142857) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk VALUES (2501, 142857)" +== 619 +-- truncate_limit: 100 +UPDATE fk_notpartitioned_pk SET a = 1500 WHERE a = 2502 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_notpartitioned_pk SET a = 1500 WHERE a = 2502" +== 620 +-- truncate_limit: 100 +SELECT * FROM fk_partitioned_fk WHERE b = 142857 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fk_partitioned_fk WHERE b = 142857" +== 621 +-- truncate_limit: 100 +-- ON DELETE SET NULL column_list +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey" +== 622 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk + ON DELETE SET NULL (a) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk ON DELETE SE..." +== 623 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 624 +-- truncate_limit: 100 +DELETE FROM fk_notpartitioned_pk WHERE b = 142857 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_notpartitioned_pk WHERE b = 142857" +== 625 +-- truncate_limit: 100 +SELECT * FROM fk_partitioned_fk WHERE a IS NOT NULL OR b IS NOT NULL ORDER BY a NULLS LAST +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fk_partitioned_fk WHERE a IS NOT NULL OR b IS NOT NULL ORDER BY a NULLS LAST" +== 626 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 627 +-- truncate_limit: 100 +-- ON DELETE SET DEFAULT column_list +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey" +== 628 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk + ON DELETE SET DEFAULT (a) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk ON DELETE SE..." +== 629 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 630 +-- truncate_limit: 100 +DELETE FROM fk_partitioned_fk +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_partitioned_fk" +== 631 +-- truncate_limit: 100 +DELETE FROM fk_notpartitioned_pk +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_notpartitioned_pk" +== 632 +-- truncate_limit: 100 +INSERT INTO fk_notpartitioned_pk VALUES (500, 100000), (2501, 100000) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk VALUES (500, 100000), (2501, 100000)" +== 633 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk VALUES (500, 100000) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk VALUES (500, 100000)" +== 634 +-- truncate_limit: 100 +DELETE FROM fk_notpartitioned_pk WHERE a = 500 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_notpartitioned_pk WHERE a = 500" +== 635 +-- truncate_limit: 100 +SELECT * FROM fk_partitioned_fk ORDER BY a +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fk_partitioned_fk ORDER BY a" +== 636 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 637 +-- truncate_limit: 100 +-- ON UPDATE/DELETE CASCADE +ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DROP CONSTRAINT fk_partitioned_fk_a_b_fkey" +== 638 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) + REFERENCES fk_notpartitioned_pk + ON DELETE CASCADE ON UPDATE CASCADE +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk ON UPDATE CA..." +== 639 +-- truncate_limit: 100 +UPDATE fk_notpartitioned_pk SET a = 2502 WHERE a = 2501 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fk_notpartitioned_pk SET a = 2502 WHERE a = 2501" +== 640 +-- truncate_limit: 100 +SELECT * FROM fk_partitioned_fk WHERE b = 142857 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fk_partitioned_fk WHERE b = 142857" +== 641 +-- truncate_limit: 100 +-- Now you see it ... +SELECT * FROM fk_partitioned_fk WHERE b = 142857 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fk_partitioned_fk WHERE b = 142857" +== 642 +-- truncate_limit: 100 +DELETE FROM fk_notpartitioned_pk WHERE b = 142857 +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_notpartitioned_pk WHERE b = 142857" +== 643 +-- truncate_limit: 100 +-- now you don't. +SELECT * FROM fk_partitioned_fk WHERE a = 142857 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fk_partitioned_fk WHERE a = 142857" +== 644 +-- truncate_limit: 100 +-- verify that DROP works +DROP TABLE fk_partitioned_fk_2 +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_partitioned_fk_2" +== 645 +-- truncate_limit: 100 +-- Test behavior of the constraint together with attaching and detaching +-- partitions. +CREATE TABLE fk_partitioned_fk_2 PARTITION OF fk_partitioned_fk FOR VALUES IN (1500,1502) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_2 PARTITION OF fk_partitioned_fk FOR VALUES IN (1500, 1502)" +== 646 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_2 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_2" +== 647 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 648 +-- truncate_limit: 100 +DROP TABLE fk_partitioned_fk +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_partitioned_fk" +== 649 +-- truncate_limit: 100 +-- constraint should still be there +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 650 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES IN (1500,1502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES IN (1500, 1502)" +== 651 +-- truncate_limit: 100 +DROP TABLE fk_partitioned_fk_2 +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_partitioned_fk_2" +== 652 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_2 (b int, c text, a int, + FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk ON UPDATE CASCADE ON DELETE CASCADE) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_2 (b int, c text, a int, FOREIGN KEY (a, b) REFERENCES fk_notparti..." +== 653 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_2 DROP COLUMN c +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_2 DROP c" +== 654 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES IN (1500,1502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES IN (1500, 1502)" +== 655 +-- truncate_limit: 100 +-- should have only one constraint +DROP TABLE fk_partitioned_fk_2 +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_partitioned_fk_2" +== 656 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_4 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk(a, b) ON UPDATE CASCADE ON DELETE CASCADE) PARTITION BY RANGE (b, a) +-- +TABLE: name="fk_partitioned_fk_4" schema="" table="fk_partitioned_fk_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_4 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_p..." +== 657 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_4_1 PARTITION OF fk_partitioned_fk_4 FOR VALUES FROM (1,1) TO (100,100) +-- +TABLE: name="fk_partitioned_fk_4_1" schema="" table="fk_partitioned_fk_4_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_4_1 PARTITION OF fk_partitioned_fk_4 FOR VALUES FROM (1, 1) TO (10..." +== 658 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_4_2 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk(a, b) ON UPDATE SET NULL) +-- +TABLE: name="fk_partitioned_fk_4_2" schema="" table="fk_partitioned_fk_4_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_4_2 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned..." +== 659 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_4 ATTACH PARTITION fk_partitioned_fk_4_2 FOR VALUES FROM (100,100) TO (1000,1000) +-- +TABLE: name="fk_partitioned_fk_4" schema="" table="fk_partitioned_fk_4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_4 ATTACH PARTITION fk_partitioned_fk_4_2 FOR VALUES FROM (100, 100)..." +== 660 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_4 FOR VALUES IN (3500,3502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_4 FOR VALUES IN (3500, 3502)" +== 661 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_4 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_4" +== 662 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_4 FOR VALUES IN (3500,3502) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_4 FOR VALUES IN (3500, 3502)" +== 663 +-- truncate_limit: 100 +-- should only have one constraint +-- this one has an FK with mismatched properties + +CREATE TABLE fk_partitioned_fk_5 (a int, b int, + FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk(a, b) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE, + FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk(a, b) MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE) + PARTITION BY RANGE (a) +-- +TABLE: name="fk_partitioned_fk_5" schema="" table="fk_partitioned_fk_5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_5 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_p..." +== 664 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_5_1 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk) +-- +TABLE: name="fk_partitioned_fk_5_1" schema="" table="fk_partitioned_fk_5_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_5_1 (a int, b int, FOREIGN KEY (a, b) REFERENCES fk_notpartitioned..." +== 665 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_5 FOR VALUES IN (4500) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_5 FOR VALUES IN (4500)" +== 666 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_5 ATTACH PARTITION fk_partitioned_fk_5_1 FOR VALUES FROM (0) TO (10) +-- +TABLE: name="fk_partitioned_fk_5" schema="" table="fk_partitioned_fk_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_5 ATTACH PARTITION fk_partitioned_fk_5_1 FOR VALUES FROM (0) TO (10)" +== 667 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_5 +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk DETACH PARTITION fk_partitioned_fk_5" +== 668 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_5 FOR VALUES IN (4500) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_5 FOR VALUES IN (4500)" +== 669 +-- truncate_limit: 100 +-- this one has two constraints, similar but not quite the one in the parent, +-- so it gets a new one +-- verify that it works to reattaching a child with multiple candidate +-- constraints +ALTER TABLE fk_partitioned_fk_5 DETACH PARTITION fk_partitioned_fk_5_1 +-- +TABLE: name="fk_partitioned_fk_5" schema="" table="fk_partitioned_fk_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_5 DETACH PARTITION fk_partitioned_fk_5_1" +== 670 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_5 ATTACH PARTITION fk_partitioned_fk_5_1 FOR VALUES FROM (0) TO (10) +-- +TABLE: name="fk_partitioned_fk_5" schema="" table="fk_partitioned_fk_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_5 ATTACH PARTITION fk_partitioned_fk_5_1 FOR VALUES FROM (0) TO (10)" +== 671 +-- truncate_limit: 100 +-- verify that attaching a table checks that the existing data satisfies the +-- constraint +CREATE TABLE fk_partitioned_fk_2 (a int, b int) PARTITION BY RANGE (b) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_2 (a int, b int) PARTITION BY RANGE (b)" +== 672 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_2_1 PARTITION OF fk_partitioned_fk_2 FOR VALUES FROM (0) TO (1000) +-- +TABLE: name="fk_partitioned_fk_2_1" schema="" table="fk_partitioned_fk_2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_2_1 PARTITION OF fk_partitioned_fk_2 FOR VALUES FROM (0) TO (1000)" +== 673 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_2_2 PARTITION OF fk_partitioned_fk_2 FOR VALUES FROM (1000) TO (2000) +-- +TABLE: name="fk_partitioned_fk_2_2" schema="" table="fk_partitioned_fk_2_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_2_2 PARTITION OF fk_partitioned_fk_2 FOR VALUES FROM (1000) TO (2000)" +== 674 +-- truncate_limit: 100 +INSERT INTO fk_partitioned_fk_2 VALUES (1600, 601), (1600, 1601) +-- +TABLE: name="fk_partitioned_fk_2" schema="" table="fk_partitioned_fk_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_partitioned_fk_2 VALUES (1600, 601), (1600, 1601)" +== 675 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 + FOR VALUES IN (1600) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES IN (1600)" +== 676 +-- truncate_limit: 100 +INSERT INTO fk_notpartitioned_pk VALUES (1600, 601), (1600, 1601) +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk VALUES (1600, 601), (1600, 1601)" +== 677 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 + FOR VALUES IN (1600) +-- +TABLE: name="fk_partitioned_fk" schema="" table="fk_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk ATTACH PARTITION fk_partitioned_fk_2 FOR VALUES IN (1600)" +== 678 +-- truncate_limit: 100 +-- leave these tables around intentionally + +-- Verify that attaching a table that's referenced by an existing FK +-- in the parent throws an error +CREATE TABLE fk_partitioned_pk_6 (a int PRIMARY KEY) +-- +TABLE: name="fk_partitioned_pk_6" schema="" table="fk_partitioned_pk_6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_pk_6 (a int PRIMARY KEY)" +== 679 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_6 (a int REFERENCES fk_partitioned_pk_6) PARTITION BY LIST (a) +-- +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_6 (a int REFERENCES fk_partitioned_pk_6) PARTITION BY LIST (a)" +== 680 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_6 ATTACH PARTITION fk_partitioned_pk_6 FOR VALUES IN (1) +-- +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_6 ATTACH PARTITION fk_partitioned_pk_6 FOR VALUES IN (1)" +== 681 +-- truncate_limit: 100 +DROP TABLE fk_partitioned_pk_6, fk_partitioned_fk_6 +-- +TABLE: name="fk_partitioned_pk_6" schema="" table="fk_partitioned_pk_6" ctx=DDL +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_partitioned_pk_6, fk_partitioned_fk_6" +== 682 +-- truncate_limit: 100 +-- This case is similar to above, but the referenced relation is one level +-- lower in the hierarchy. This one fails in a different way as the above, +-- because we don't bother to protect against this case explicitly. If the +-- current error stops happening, we'll need to add a better protection. +CREATE TABLE fk_partitioned_pk_6 (a int PRIMARY KEY) PARTITION BY list (a) +-- +TABLE: name="fk_partitioned_pk_6" schema="" table="fk_partitioned_pk_6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_pk_6 (a int PRIMARY KEY) PARTITION BY LIST (a)" +== 683 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_pk_61 PARTITION OF fk_partitioned_pk_6 FOR VALUES IN (1) +-- +TABLE: name="fk_partitioned_pk_61" schema="" table="fk_partitioned_pk_61" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_pk_61 PARTITION OF fk_partitioned_pk_6 FOR VALUES IN (1)" +== 684 +-- truncate_limit: 100 +CREATE TABLE fk_partitioned_fk_6 (a int REFERENCES fk_partitioned_pk_61) PARTITION BY LIST (a) +-- +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_partitioned_fk_6 (a int REFERENCES fk_partitioned_pk_61) PARTITION BY LIST (a)" +== 685 +-- truncate_limit: 100 +ALTER TABLE fk_partitioned_fk_6 ATTACH PARTITION fk_partitioned_pk_6 FOR VALUES IN (1) +-- +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_partitioned_fk_6 ATTACH PARTITION fk_partitioned_pk_6 FOR VALUES IN (1)" +== 686 +-- truncate_limit: 100 +DROP TABLE fk_partitioned_pk_6, fk_partitioned_fk_6 +-- +TABLE: name="fk_partitioned_pk_6" schema="" table="fk_partitioned_pk_6" ctx=DDL +TABLE: name="fk_partitioned_fk_6" schema="" table="fk_partitioned_fk_6" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk_partitioned_pk_6, fk_partitioned_fk_6" +== 687 +-- truncate_limit: 100 +-- test the case when the referenced table is owned by a different user +create role regress_other_partitioned_fk_owner +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_other_partitioned_fk_owner" +== 688 +-- truncate_limit: 100 +grant references on fk_notpartitioned_pk to regress_other_partitioned_fk_owner +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT references ON fk_notpartitioned_pk TO regress_other_partitioned_fk_owner" +== 689 +-- truncate_limit: 100 +set role regress_other_partitioned_fk_owner +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_other_partitioned_fk_owner" +== 690 +-- truncate_limit: 100 +create table other_partitioned_fk(a int, b int) partition by list (a) +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE other_partitioned_fk (a int, b int) PARTITION BY LIST (a)" +== 691 +-- truncate_limit: 100 +create table other_partitioned_fk_1 partition of other_partitioned_fk + for values in (2048) +-- +TABLE: name="other_partitioned_fk_1" schema="" table="other_partitioned_fk_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE other_partitioned_fk_1 PARTITION OF other_partitioned_fk FOR VALUES IN (2048)" +== 692 +-- truncate_limit: 100 +insert into other_partitioned_fk + select 2048, x from generate_series(1,10) x +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO other_partitioned_fk SELECT 2048, x FROM generate_series(1, 10) x" +== 693 +-- truncate_limit: 100 +-- this should fail +alter table other_partitioned_fk add foreign key (a, b) + references fk_notpartitioned_pk(a, b) +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE other_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk (a, b)" +== 694 +-- truncate_limit: 100 +-- add the missing keys and retry +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 695 +-- truncate_limit: 100 +insert into fk_notpartitioned_pk (a, b) + select 2048, x from generate_series(1,10) x +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_notpartitioned_pk (a, b) SELECT 2048, x FROM generate_series(1, 10) x" +== 696 +-- truncate_limit: 100 +set role regress_other_partitioned_fk_owner +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_other_partitioned_fk_owner" +== 697 +-- truncate_limit: 100 +alter table other_partitioned_fk add foreign key (a, b) + references fk_notpartitioned_pk(a, b) +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE other_partitioned_fk ADD FOREIGN KEY (a, b) REFERENCES fk_notpartitioned_pk (a, b)" +== 698 +-- truncate_limit: 100 +-- clean up +drop table other_partitioned_fk +-- +TABLE: name="other_partitioned_fk" schema="" table="other_partitioned_fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE other_partitioned_fk" +== 699 +-- truncate_limit: 100 +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 700 +-- truncate_limit: 100 +revoke all on fk_notpartitioned_pk from regress_other_partitioned_fk_owner +-- +TABLE: name="fk_notpartitioned_pk" schema="" table="fk_notpartitioned_pk" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON fk_notpartitioned_pk FROM regress_other_partitioned_fk_owner" +== 701 +-- truncate_limit: 100 +drop role regress_other_partitioned_fk_owner +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_other_partitioned_fk_owner" +== 702 +-- truncate_limit: 100 +|-- +-- Test self-referencing foreign key with partition. +-- This should create only one fk constraint per partition +|-- +CREATE TABLE parted_self_fk ( + id bigint NOT NULL PRIMARY KEY, + id_abc bigint, + FOREIGN KEY (id_abc) REFERENCES parted_self_fk(id) +) +PARTITION BY RANGE (id) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_self_fk (id bigint NOT NULL PRIMARY KEY, id_abc bigint, FOREIGN KEY (id_abc) ..." +== 703 +-- truncate_limit: 100 +CREATE TABLE part1_self_fk ( + id bigint NOT NULL PRIMARY KEY, + id_abc bigint +) +-- +TABLE: name="part1_self_fk" schema="" table="part1_self_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part1_self_fk (id bigint NOT NULL PRIMARY KEY, id_abc bigint)" +== 704 +-- truncate_limit: 100 +ALTER TABLE parted_self_fk ATTACH PARTITION part1_self_fk FOR VALUES FROM (0) TO (10) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_self_fk ATTACH PARTITION part1_self_fk FOR VALUES FROM (0) TO (10)" +== 705 +-- truncate_limit: 100 +CREATE TABLE part2_self_fk PARTITION OF parted_self_fk FOR VALUES FROM (10) TO (20) +-- +TABLE: name="part2_self_fk" schema="" table="part2_self_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part2_self_fk PARTITION OF parted_self_fk FOR VALUES FROM (10) TO (20)" +== 706 +-- truncate_limit: 100 +CREATE TABLE part3_self_fk ( -- a partitioned partition + id bigint NOT NULL PRIMARY KEY, + id_abc bigint +) PARTITION BY RANGE (id) +-- +TABLE: name="part3_self_fk" schema="" table="part3_self_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part3_self_fk (id bigint NOT NULL PRIMARY KEY, id_abc bigint) PARTITION BY RANGE (id)" +== 707 +-- truncate_limit: 100 +CREATE TABLE part32_self_fk PARTITION OF part3_self_fk FOR VALUES FROM (20) TO (30) +-- +TABLE: name="part32_self_fk" schema="" table="part32_self_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part32_self_fk PARTITION OF part3_self_fk FOR VALUES FROM (20) TO (30)" +== 708 +-- truncate_limit: 100 +ALTER TABLE parted_self_fk ATTACH PARTITION part3_self_fk FOR VALUES FROM (20) TO (40) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_self_fk ATTACH PARTITION part3_self_fk FOR VALUES FROM (20) TO (40)" +== 709 +-- truncate_limit: 100 +CREATE TABLE part33_self_fk ( + id bigint NOT NULL PRIMARY KEY, + id_abc bigint +) +-- +TABLE: name="part33_self_fk" schema="" table="part33_self_fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part33_self_fk (id bigint NOT NULL PRIMARY KEY, id_abc bigint)" +== 710 +-- truncate_limit: 100 +ALTER TABLE part3_self_fk ATTACH PARTITION part33_self_fk FOR VALUES FROM (30) TO (40) +-- +TABLE: name="part3_self_fk" schema="" table="part3_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part3_self_fk ATTACH PARTITION part33_self_fk FOR VALUES FROM (30) TO (40)" +== 711 +-- truncate_limit: 100 +-- verify that this constraint works +INSERT INTO parted_self_fk VALUES (1, NULL), (2, NULL), (3, NULL) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_self_fk VALUES (1, NULL), (2, NULL), (3, NULL)" +== 712 +-- truncate_limit: 100 +INSERT INTO parted_self_fk VALUES (10, 1), (11, 2), (12, 3) RETURNING tableoid::regclass +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_self_fk VALUES (10, 1), (11, 2), (12, 3) RETURNING tableoid::regclass" +== 713 +-- truncate_limit: 100 +INSERT INTO parted_self_fk VALUES (4, 5) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_self_fk VALUES (4, 5)" +== 714 +-- truncate_limit: 100 +-- error: referenced doesn't exist +DELETE FROM parted_self_fk WHERE id = 1 RETURNING * +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parted_self_fk WHERE id = 1 RETURNING *" +== 715 +-- truncate_limit: 100 +-- error: reference remains + +SELECT cr.relname, co.conname, co.convalidated, + p.conname AS conparent, p.convalidated, cf.relname AS foreignrel +FROM pg_constraint co +JOIN pg_class cr ON cr.oid = co.conrelid +LEFT JOIN pg_class cf ON cf.oid = co.confrelid +LEFT JOIN pg_constraint p ON p.oid = co.conparentid +WHERE co.contype = 'f' AND + cr.oid IN (SELECT relid FROM pg_partition_tree('parted_self_fk')) +ORDER BY cr.relname, co.conname, p.conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "cf"="pg_class" +ALIAS: "co"="pg_constraint" +ALIAS: "cr"="pg_class" +ALIAS: "p"="pg_constraint" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="co" column="contype" +FILTER: schema="" table="cr" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint co JOIN pg_class cr ON cr.oid = co.conrelid LEFT JOIN pg_class cf O..." +== 716 +-- truncate_limit: 100 +-- detach and re-attach multiple times just to ensure everything is kosher +ALTER TABLE parted_self_fk DETACH PARTITION part2_self_fk +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_self_fk DETACH PARTITION part2_self_fk" +== 717 +-- truncate_limit: 100 +INSERT INTO part2_self_fk VALUES (16, 9) +-- +TABLE: name="part2_self_fk" schema="" table="part2_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part2_self_fk VALUES (16, 9)" +== 718 +-- truncate_limit: 100 +-- error: referenced doesn't exist +DELETE FROM parted_self_fk WHERE id = 2 RETURNING * +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parted_self_fk WHERE id = 2 RETURNING *" +== 719 +-- truncate_limit: 100 +-- error: reference remains + +ALTER TABLE parted_self_fk ATTACH PARTITION part2_self_fk FOR VALUES FROM (10) TO (20) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_self_fk ATTACH PARTITION part2_self_fk FOR VALUES FROM (10) TO (20)" +== 720 +-- truncate_limit: 100 +INSERT INTO parted_self_fk VALUES (16, 9) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_self_fk VALUES (16, 9)" +== 721 +-- truncate_limit: 100 +-- error: referenced doesn't exist +DELETE FROM parted_self_fk WHERE id = 3 RETURNING * +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parted_self_fk WHERE id = 3 RETURNING *" +== 722 +-- truncate_limit: 100 +-- error: reference remains + +ALTER TABLE parted_self_fk DETACH PARTITION part2_self_fk +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_self_fk DETACH PARTITION part2_self_fk" +== 723 +-- truncate_limit: 100 +ALTER TABLE parted_self_fk ATTACH PARTITION part2_self_fk FOR VALUES FROM (10) TO (20) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_self_fk ATTACH PARTITION part2_self_fk FOR VALUES FROM (10) TO (20)" +== 724 +-- truncate_limit: 100 +ALTER TABLE parted_self_fk DETACH PARTITION part3_self_fk +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_self_fk DETACH PARTITION part3_self_fk" +== 725 +-- truncate_limit: 100 +ALTER TABLE parted_self_fk ATTACH PARTITION part3_self_fk FOR VALUES FROM (30) TO (40) +-- +TABLE: name="parted_self_fk" schema="" table="parted_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_self_fk ATTACH PARTITION part3_self_fk FOR VALUES FROM (30) TO (40)" +== 726 +-- truncate_limit: 100 +ALTER TABLE part3_self_fk DETACH PARTITION part33_self_fk +-- +TABLE: name="part3_self_fk" schema="" table="part3_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part3_self_fk DETACH PARTITION part33_self_fk" +== 727 +-- truncate_limit: 100 +ALTER TABLE part3_self_fk ATTACH PARTITION part33_self_fk FOR VALUES FROM (30) TO (40) +-- +TABLE: name="part3_self_fk" schema="" table="part3_self_fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part3_self_fk ATTACH PARTITION part33_self_fk FOR VALUES FROM (30) TO (40)" +== 728 +-- truncate_limit: 100 +SELECT cr.relname, co.conname, co.convalidated, + p.conname AS conparent, p.convalidated, cf.relname AS foreignrel +FROM pg_constraint co +JOIN pg_class cr ON cr.oid = co.conrelid +LEFT JOIN pg_class cf ON cf.oid = co.confrelid +LEFT JOIN pg_constraint p ON p.oid = co.conparentid +WHERE co.contype = 'f' AND + cr.oid IN (SELECT relid FROM pg_partition_tree('parted_self_fk')) +ORDER BY cr.relname, co.conname, p.conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "cf"="pg_class" +ALIAS: "co"="pg_constraint" +ALIAS: "cr"="pg_class" +ALIAS: "p"="pg_constraint" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="co" column="contype" +FILTER: schema="" table="cr" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint co JOIN pg_class cr ON cr.oid = co.conrelid LEFT JOIN pg_class cf O..." +== 729 +-- truncate_limit: 100 +-- Leave this table around, for pg_upgrade/pg_dump tests + + +-- Test creating a constraint at the parent that already exists in partitions. +-- There should be no duplicated constraints, and attempts to drop the +-- constraint in partitions should raise appropriate errors. +create schema fkpart0 + create table pkey (a int primary key) + create table fk_part (a int) partition by list (a) + create table fk_part_1 partition of fk_part + (foreign key (a) references fkpart0.pkey) for values in (1) + create table fk_part_23 partition of fk_part + (foreign key (a) references fkpart0.pkey) for values in (2, 3) + partition by list (a) + create table fk_part_23_2 partition of fk_part_23 for values in (2) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart0 CREATE TABLE pkey (a int PRIMARY KEY) CREATE TABLE fk_part (a int) PARTITIO..." +== 730 +-- truncate_limit: 100 +alter table fkpart0.fk_part add foreign key (a) references fkpart0.pkey +-- +TABLE: name="fkpart0.fk_part" schema="fkpart0" table="fk_part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart0.fk_part ADD FOREIGN KEY (a) REFERENCES fkpart0.pkey" +== 731 +-- truncate_limit: 100 +alter table fkpart0.fk_part_1 drop constraint fk_part_1_a_fkey +-- +TABLE: name="fkpart0.fk_part_1" schema="fkpart0" table="fk_part_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart0.fk_part_1 DROP CONSTRAINT fk_part_1_a_fkey" +== 732 +-- truncate_limit: 100 +alter table fkpart0.fk_part_23 drop constraint fk_part_23_a_fkey +-- +TABLE: name="fkpart0.fk_part_23" schema="fkpart0" table="fk_part_23" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart0.fk_part_23 DROP CONSTRAINT fk_part_23_a_fkey" +== 733 +-- truncate_limit: 100 +alter table fkpart0.fk_part_23_2 drop constraint fk_part_23_a_fkey +-- +TABLE: name="fkpart0.fk_part_23_2" schema="fkpart0" table="fk_part_23_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart0.fk_part_23_2 DROP CONSTRAINT fk_part_23_a_fkey" +== 734 +-- truncate_limit: 100 +create table fkpart0.fk_part_4 partition of fkpart0.fk_part for values in (4) +-- +TABLE: name="fkpart0.fk_part_4" schema="fkpart0" table="fk_part_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart0.fk_part_4 PARTITION OF fkpart0.fk_part FOR VALUES IN (4)" +== 735 +-- truncate_limit: 100 +alter table fkpart0.fk_part_4 drop constraint fk_part_a_fkey +-- +TABLE: name="fkpart0.fk_part_4" schema="fkpart0" table="fk_part_4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart0.fk_part_4 DROP CONSTRAINT fk_part_a_fkey" +== 736 +-- truncate_limit: 100 +create table fkpart0.fk_part_56 partition of fkpart0.fk_part + for values in (5,6) partition by list (a) +-- +TABLE: name="fkpart0.fk_part_56" schema="fkpart0" table="fk_part_56" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart0.fk_part_56 PARTITION OF fkpart0.fk_part FOR VALUES IN (5, 6) PARTITION BY LI..." +== 737 +-- truncate_limit: 100 +create table fkpart0.fk_part_56_5 partition of fkpart0.fk_part_56 + for values in (5) +-- +TABLE: name="fkpart0.fk_part_56_5" schema="fkpart0" table="fk_part_56_5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart0.fk_part_56_5 PARTITION OF fkpart0.fk_part_56 FOR VALUES IN (5)" +== 738 +-- truncate_limit: 100 +alter table fkpart0.fk_part_56 drop constraint fk_part_a_fkey +-- +TABLE: name="fkpart0.fk_part_56" schema="fkpart0" table="fk_part_56" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart0.fk_part_56 DROP CONSTRAINT fk_part_a_fkey" +== 739 +-- truncate_limit: 100 +alter table fkpart0.fk_part_56_5 drop constraint fk_part_a_fkey +-- +TABLE: name="fkpart0.fk_part_56_5" schema="fkpart0" table="fk_part_56_5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart0.fk_part_56_5 DROP CONSTRAINT fk_part_a_fkey" +== 740 +-- truncate_limit: 100 +-- verify that attaching and detaching partitions maintains the right set of +-- triggers +create schema fkpart1 + create table pkey (a int primary key) + create table fk_part (a int) partition by list (a) + create table fk_part_1 partition of fk_part for values in (1) partition by list (a) + create table fk_part_1_1 partition of fk_part_1 for values in (1) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart1 CREATE TABLE pkey (a int PRIMARY KEY) CREATE TABLE fk_part (a int) PARTITIO..." +== 741 +-- truncate_limit: 100 +alter table fkpart1.fk_part add foreign key (a) references fkpart1.pkey +-- +TABLE: name="fkpart1.fk_part" schema="fkpart1" table="fk_part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart1.fk_part ADD FOREIGN KEY (a) REFERENCES fkpart1.pkey" +== 742 +-- truncate_limit: 100 +insert into fkpart1.fk_part values (1) +-- +TABLE: name="fkpart1.fk_part" schema="fkpart1" table="fk_part" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart1.fk_part VALUES (1)" +== 743 +-- truncate_limit: 100 +-- should fail +insert into fkpart1.pkey values (1) +-- +TABLE: name="fkpart1.pkey" schema="fkpart1" table="pkey" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart1.pkey VALUES (1)" +== 744 +-- truncate_limit: 100 +insert into fkpart1.fk_part values (1) +-- +TABLE: name="fkpart1.fk_part" schema="fkpart1" table="fk_part" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart1.fk_part VALUES (1)" +== 745 +-- truncate_limit: 100 +delete from fkpart1.pkey where a = 1 +-- +TABLE: name="fkpart1.pkey" schema="fkpart1" table="pkey" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fkpart1.pkey WHERE a = 1" +== 746 +-- truncate_limit: 100 +-- should fail +alter table fkpart1.fk_part detach partition fkpart1.fk_part_1 +-- +TABLE: name="fkpart1.fk_part" schema="fkpart1" table="fk_part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart1.fk_part DETACH PARTITION fkpart1.fk_part_1" +== 747 +-- truncate_limit: 100 +create table fkpart1.fk_part_1_2 partition of fkpart1.fk_part_1 for values in (2) +-- +TABLE: name="fkpart1.fk_part_1_2" schema="fkpart1" table="fk_part_1_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart1.fk_part_1_2 PARTITION OF fkpart1.fk_part_1 FOR VALUES IN (2)" +== 748 +-- truncate_limit: 100 +insert into fkpart1.fk_part_1 values (2) +-- +TABLE: name="fkpart1.fk_part_1" schema="fkpart1" table="fk_part_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart1.fk_part_1 VALUES (2)" +== 749 +-- truncate_limit: 100 +-- should fail +delete from fkpart1.pkey where a = 1 +-- +TABLE: name="fkpart1.pkey" schema="fkpart1" table="pkey" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fkpart1.pkey WHERE a = 1" +== 750 +-- truncate_limit: 100 +-- verify that attaching and detaching partitions manipulates the inheritance +-- properties of their FK constraints correctly +create schema fkpart2 + create table pkey (a int primary key) + create table fk_part (a int, constraint fkey foreign key (a) references fkpart2.pkey) partition by list (a) + create table fk_part_1 partition of fkpart2.fk_part for values in (1) partition by list (a) + create table fk_part_1_1 (a int, constraint my_fkey foreign key (a) references fkpart2.pkey) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart2 CREATE TABLE pkey (a int PRIMARY KEY) CREATE TABLE fk_part (a int, CONSTRAI..." +== 751 +-- truncate_limit: 100 +alter table fkpart2.fk_part_1 attach partition fkpart2.fk_part_1_1 for values in (1) +-- +TABLE: name="fkpart2.fk_part_1" schema="fkpart2" table="fk_part_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart2.fk_part_1 ATTACH PARTITION fkpart2.fk_part_1_1 FOR VALUES IN (1)" +== 752 +-- truncate_limit: 100 +alter table fkpart2.fk_part_1 drop constraint fkey +-- +TABLE: name="fkpart2.fk_part_1" schema="fkpart2" table="fk_part_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart2.fk_part_1 DROP CONSTRAINT fkey" +== 753 +-- truncate_limit: 100 +-- should fail +alter table fkpart2.fk_part_1_1 drop constraint my_fkey +-- +TABLE: name="fkpart2.fk_part_1_1" schema="fkpart2" table="fk_part_1_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart2.fk_part_1_1 DROP CONSTRAINT my_fkey" +== 754 +-- truncate_limit: 100 +-- should fail +alter table fkpart2.fk_part detach partition fkpart2.fk_part_1 +-- +TABLE: name="fkpart2.fk_part" schema="fkpart2" table="fk_part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart2.fk_part DETACH PARTITION fkpart2.fk_part_1" +== 755 +-- truncate_limit: 100 +alter table fkpart2.fk_part_1 drop constraint fkey +-- +TABLE: name="fkpart2.fk_part_1" schema="fkpart2" table="fk_part_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart2.fk_part_1 DROP CONSTRAINT fkey" +== 756 +-- truncate_limit: 100 +-- ok +alter table fkpart2.fk_part_1_1 drop constraint my_fkey +-- +TABLE: name="fkpart2.fk_part_1_1" schema="fkpart2" table="fk_part_1_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart2.fk_part_1_1 DROP CONSTRAINT my_fkey" +== 757 +-- truncate_limit: 100 +-- doesn't exist + +-- verify constraint deferrability +create schema fkpart3 + create table pkey (a int primary key) + create table fk_part (a int, constraint fkey foreign key (a) references fkpart3.pkey deferrable initially immediate) partition by list (a) + create table fk_part_1 partition of fkpart3.fk_part for values in (1) partition by list (a) + create table fk_part_1_1 partition of fkpart3.fk_part_1 for values in (1) + create table fk_part_2 partition of fkpart3.fk_part for values in (2) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart3 CREATE TABLE pkey (a int PRIMARY KEY) CREATE TABLE fk_part (a int, CONSTRAI..." +== 758 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 759 +-- truncate_limit: 100 +set constraints fkpart3.fkey deferred +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS fkpart3.fkey DEFERRED" +== 760 +-- truncate_limit: 100 +insert into fkpart3.fk_part values (1) +-- +TABLE: name="fkpart3.fk_part" schema="fkpart3" table="fk_part" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart3.fk_part VALUES (1)" +== 761 +-- truncate_limit: 100 +insert into fkpart3.pkey values (1) +-- +TABLE: name="fkpart3.pkey" schema="fkpart3" table="pkey" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart3.pkey VALUES (1)" +== 762 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 763 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 764 +-- truncate_limit: 100 +set constraints fkpart3.fkey deferred +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS fkpart3.fkey DEFERRED" +== 765 +-- truncate_limit: 100 +delete from fkpart3.pkey +-- +TABLE: name="fkpart3.pkey" schema="fkpart3" table="pkey" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fkpart3.pkey" +== 766 +-- truncate_limit: 100 +delete from fkpart3.fk_part +-- +TABLE: name="fkpart3.fk_part" schema="fkpart3" table="fk_part" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fkpart3.fk_part" +== 767 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 768 +-- truncate_limit: 100 +drop schema fkpart0, fkpart1, fkpart2, fkpart3 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart0, fkpart1, fkpart2, fkpart3 CASCADE" +== 769 +-- truncate_limit: 100 +-- Test a partitioned table as referenced table. + +-- Verify basic functionality with a regular partition creation and a partition +-- with a different column layout, as well as partitions added (created and +-- attached) after creating the foreign key. +CREATE SCHEMA fkpart3 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart3" +== 770 +-- truncate_limit: 100 +SET search_path TO fkpart3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO fkpart3" +== 771 +-- truncate_limit: 100 +CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY RANGE (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY RANGE (a)" +== 772 +-- truncate_limit: 100 +CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (0) TO (1000) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (0) TO (1000)" +== 773 +-- truncate_limit: 100 +CREATE TABLE pk2 (b int, a int) +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk2 (b int, a int)" +== 774 +-- truncate_limit: 100 +ALTER TABLE pk2 DROP COLUMN b +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk2 DROP b" +== 775 +-- truncate_limit: 100 +ALTER TABLE pk2 ALTER a SET NOT NULL +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk2 ALTER COLUMN a SET NOT NULL" +== 776 +-- truncate_limit: 100 +ALTER TABLE pk ATTACH PARTITION pk2 FOR VALUES FROM (1000) TO (2000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk ATTACH PARTITION pk2 FOR VALUES FROM (1000) TO (2000)" +== 777 +-- truncate_limit: 100 +CREATE TABLE fk (a int) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk (a int) PARTITION BY RANGE (a)" +== 778 +-- truncate_limit: 100 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (0) TO (750) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (0) TO (750)" +== 779 +-- truncate_limit: 100 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk" +== 780 +-- truncate_limit: 100 +CREATE TABLE fk2 (b int, a int) +-- +TABLE: name="fk2" schema="" table="fk2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk2 (b int, a int)" +== 781 +-- truncate_limit: 100 +ALTER TABLE fk2 DROP COLUMN b +-- +TABLE: name="fk2" schema="" table="fk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk2 DROP b" +== 782 +-- truncate_limit: 100 +ALTER TABLE fk ATTACH PARTITION fk2 FOR VALUES FROM (750) TO (3500) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ATTACH PARTITION fk2 FOR VALUES FROM (750) TO (3500)" +== 783 +-- truncate_limit: 100 +CREATE TABLE pk3 PARTITION OF pk FOR VALUES FROM (2000) TO (3000) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk3 PARTITION OF pk FOR VALUES FROM (2000) TO (3000)" +== 784 +-- truncate_limit: 100 +CREATE TABLE pk4 (LIKE pk) +-- +TABLE: name="pk4" schema="" table="pk4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk4 (LIKE pk)" +== 785 +-- truncate_limit: 100 +ALTER TABLE pk ATTACH PARTITION pk4 FOR VALUES FROM (3000) TO (4000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk ATTACH PARTITION pk4 FOR VALUES FROM (3000) TO (4000)" +== 786 +-- truncate_limit: 100 +CREATE TABLE pk5 (c int, b int, a int NOT NULL) PARTITION BY RANGE (a) +-- +TABLE: name="pk5" schema="" table="pk5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk5 (c int, b int, a int NOT NULL) PARTITION BY RANGE (a)" +== 787 +-- truncate_limit: 100 +ALTER TABLE pk5 DROP COLUMN b, DROP COLUMN c +-- +TABLE: name="pk5" schema="" table="pk5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk5 DROP b, DROP c" +== 788 +-- truncate_limit: 100 +CREATE TABLE pk51 PARTITION OF pk5 FOR VALUES FROM (4000) TO (4500) +-- +TABLE: name="pk51" schema="" table="pk51" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk51 PARTITION OF pk5 FOR VALUES FROM (4000) TO (4500)" +== 789 +-- truncate_limit: 100 +CREATE TABLE pk52 PARTITION OF pk5 FOR VALUES FROM (4500) TO (5000) +-- +TABLE: name="pk52" schema="" table="pk52" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk52 PARTITION OF pk5 FOR VALUES FROM (4500) TO (5000)" +== 790 +-- truncate_limit: 100 +ALTER TABLE pk ATTACH PARTITION pk5 FOR VALUES FROM (4000) TO (5000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk ATTACH PARTITION pk5 FOR VALUES FROM (4000) TO (5000)" +== 791 +-- truncate_limit: 100 +CREATE TABLE fk3 PARTITION OF fk FOR VALUES FROM (3500) TO (5000) +-- +TABLE: name="fk3" schema="" table="fk3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk3 PARTITION OF fk FOR VALUES FROM (3500) TO (5000)" +== 792 +-- truncate_limit: 100 +-- these should fail: referenced value not present +INSERT into fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (1)" +== 793 +-- truncate_limit: 100 +INSERT into fk VALUES (1000) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (1000)" +== 794 +-- truncate_limit: 100 +INSERT into fk VALUES (2000) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (2000)" +== 795 +-- truncate_limit: 100 +INSERT into fk VALUES (3000) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (3000)" +== 796 +-- truncate_limit: 100 +INSERT into fk VALUES (4000) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (4000)" +== 797 +-- truncate_limit: 100 +INSERT into fk VALUES (4500) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (4500)" +== 798 +-- truncate_limit: 100 +-- insert into the referenced table, now they should work +INSERT into pk VALUES (1), (1000), (2000), (3000), (4000), (4500) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pk VALUES (1), (1000), (2000), (3000), (4000), (4500)" +== 799 +-- truncate_limit: 100 +INSERT into fk VALUES (1), (1000), (2000), (3000), (4000), (4500) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (1), (1000), (2000), (3000), (4000), (4500)" +== 800 +-- truncate_limit: 100 +-- should fail: referencing value present +DELETE FROM pk WHERE a = 1 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 1" +== 801 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 1000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 1000" +== 802 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 2000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 2000" +== 803 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 3000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 3000" +== 804 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 4000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 4000" +== 805 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 4500 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 4500" +== 806 +-- truncate_limit: 100 +UPDATE pk SET a = 2 WHERE a = 1 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 2 WHERE a = 1" +== 807 +-- truncate_limit: 100 +UPDATE pk SET a = 1002 WHERE a = 1000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 1002 WHERE a = 1000" +== 808 +-- truncate_limit: 100 +UPDATE pk SET a = 2002 WHERE a = 2000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 2002 WHERE a = 2000" +== 809 +-- truncate_limit: 100 +UPDATE pk SET a = 3002 WHERE a = 3000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 3002 WHERE a = 3000" +== 810 +-- truncate_limit: 100 +UPDATE pk SET a = 4002 WHERE a = 4000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 4002 WHERE a = 4000" +== 811 +-- truncate_limit: 100 +UPDATE pk SET a = 4502 WHERE a = 4500 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 4502 WHERE a = 4500" +== 812 +-- truncate_limit: 100 +-- now they should work +DELETE FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk" +== 813 +-- truncate_limit: 100 +UPDATE pk SET a = 2 WHERE a = 1 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 2 WHERE a = 1" +== 814 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 2 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 2" +== 815 +-- truncate_limit: 100 +UPDATE pk SET a = 1002 WHERE a = 1000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 1002 WHERE a = 1000" +== 816 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 1002 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 1002" +== 817 +-- truncate_limit: 100 +UPDATE pk SET a = 2002 WHERE a = 2000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 2002 WHERE a = 2000" +== 818 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 2002 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 2002" +== 819 +-- truncate_limit: 100 +UPDATE pk SET a = 3002 WHERE a = 3000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 3002 WHERE a = 3000" +== 820 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 3002 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 3002" +== 821 +-- truncate_limit: 100 +UPDATE pk SET a = 4002 WHERE a = 4000 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 4002 WHERE a = 4000" +== 822 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 4002 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 4002" +== 823 +-- truncate_limit: 100 +UPDATE pk SET a = 4502 WHERE a = 4500 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 4502 WHERE a = 4500" +== 824 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 4502 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 4502" +== 825 +-- truncate_limit: 100 +-- Also, detaching a partition that has the FK itself should work +-- https://postgr.es/m/CAAJ_b97GuPh6wQPbxQS-Zpy16Oh+0aMv-w64QcGrLhCOZZ6p+g@mail.gmail.com +CREATE TABLE ffk (a int, b int REFERENCES pk) PARTITION BY list (a) +-- +TABLE: name="ffk" schema="" table="ffk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ffk (a int, b int REFERENCES pk) PARTITION BY LIST (a)" +== 826 +-- truncate_limit: 100 +CREATE TABLE ffk1 PARTITION OF ffk FOR VALUES IN (1) +-- +TABLE: name="ffk1" schema="" table="ffk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ffk1 PARTITION OF ffk FOR VALUES IN (1)" +== 827 +-- truncate_limit: 100 +ALTER TABLE ffk1 ADD FOREIGN KEY (a) REFERENCES pk +-- +TABLE: name="ffk1" schema="" table="ffk1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ffk1 ADD FOREIGN KEY (a) REFERENCES pk" +== 828 +-- truncate_limit: 100 +ALTER TABLE ffk DETACH PARTITION ffk1 +-- +TABLE: name="ffk" schema="" table="ffk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ffk DETACH PARTITION ffk1" +== 829 +-- truncate_limit: 100 +DROP TABLE ffk, ffk1 +-- +TABLE: name="ffk" schema="" table="ffk" ctx=DDL +TABLE: name="ffk1" schema="" table="ffk1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ffk, ffk1" +== 830 +-- truncate_limit: 100 +CREATE SCHEMA fkpart4 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart4" +== 831 +-- truncate_limit: 100 +SET search_path TO fkpart4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO fkpart4" +== 832 +-- truncate_limit: 100 +-- dropping/detaching PARTITIONs is prevented if that would break +-- a foreign key's existing data +CREATE TABLE droppk (a int PRIMARY KEY) PARTITION BY RANGE (a) +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE droppk (a int PRIMARY KEY) PARTITION BY RANGE (a)" +== 833 +-- truncate_limit: 100 +CREATE TABLE droppk1 PARTITION OF droppk FOR VALUES FROM (0) TO (1000) +-- +TABLE: name="droppk1" schema="" table="droppk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE droppk1 PARTITION OF droppk FOR VALUES FROM (0) TO (1000)" +== 834 +-- truncate_limit: 100 +CREATE TABLE droppk_d PARTITION OF droppk DEFAULT +-- +TABLE: name="droppk_d" schema="" table="droppk_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE droppk_d PARTITION OF droppk DEFAULT" +== 835 +-- truncate_limit: 100 +CREATE TABLE droppk2 PARTITION OF droppk FOR VALUES FROM (1000) TO (2000) + PARTITION BY RANGE (a) +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE droppk2 PARTITION OF droppk FOR VALUES FROM (1000) TO (2000) PARTITION BY RANGE (a)" +== 836 +-- truncate_limit: 100 +CREATE TABLE droppk21 PARTITION OF droppk2 FOR VALUES FROM (1000) TO (1400) +-- +TABLE: name="droppk21" schema="" table="droppk21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE droppk21 PARTITION OF droppk2 FOR VALUES FROM (1000) TO (1400)" +== 837 +-- truncate_limit: 100 +CREATE TABLE droppk2_d PARTITION OF droppk2 DEFAULT +-- +TABLE: name="droppk2_d" schema="" table="droppk2_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE droppk2_d PARTITION OF droppk2 DEFAULT" +== 838 +-- truncate_limit: 100 +INSERT into droppk VALUES (1), (1000), (1500), (2000) +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO droppk VALUES (1), (1000), (1500), (2000)" +== 839 +-- truncate_limit: 100 +CREATE TABLE dropfk (a int REFERENCES droppk) +-- +TABLE: name="dropfk" schema="" table="dropfk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dropfk (a int REFERENCES droppk)" +== 840 +-- truncate_limit: 100 +INSERT into dropfk VALUES (1), (1000), (1500), (2000) +-- +TABLE: name="dropfk" schema="" table="dropfk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dropfk VALUES (1), (1000), (1500), (2000)" +== 841 +-- truncate_limit: 100 +-- these should all fail +ALTER TABLE droppk DETACH PARTITION droppk_d +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE droppk DETACH PARTITION droppk_d" +== 842 +-- truncate_limit: 100 +ALTER TABLE droppk2 DETACH PARTITION droppk2_d +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE droppk2 DETACH PARTITION droppk2_d" +== 843 +-- truncate_limit: 100 +ALTER TABLE droppk DETACH PARTITION droppk1 +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE droppk DETACH PARTITION droppk1" +== 844 +-- truncate_limit: 100 +ALTER TABLE droppk DETACH PARTITION droppk2 +-- +TABLE: name="droppk" schema="" table="droppk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE droppk DETACH PARTITION droppk2" +== 845 +-- truncate_limit: 100 +ALTER TABLE droppk2 DETACH PARTITION droppk21 +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE droppk2 DETACH PARTITION droppk21" +== 846 +-- truncate_limit: 100 +-- dropping partitions is disallowed +DROP TABLE droppk_d +-- +TABLE: name="droppk_d" schema="" table="droppk_d" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk_d" +== 847 +-- truncate_limit: 100 +DROP TABLE droppk2_d +-- +TABLE: name="droppk2_d" schema="" table="droppk2_d" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk2_d" +== 848 +-- truncate_limit: 100 +DROP TABLE droppk1 +-- +TABLE: name="droppk1" schema="" table="droppk1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk1" +== 849 +-- truncate_limit: 100 +DROP TABLE droppk2 +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk2" +== 850 +-- truncate_limit: 100 +DROP TABLE droppk21 +-- +TABLE: name="droppk21" schema="" table="droppk21" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk21" +== 851 +-- truncate_limit: 100 +DELETE FROM dropfk +-- +TABLE: name="dropfk" schema="" table="dropfk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM dropfk" +== 852 +-- truncate_limit: 100 +-- dropping partitions is disallowed, even when no referencing values +DROP TABLE droppk_d +-- +TABLE: name="droppk_d" schema="" table="droppk_d" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk_d" +== 853 +-- truncate_limit: 100 +DROP TABLE droppk2_d +-- +TABLE: name="droppk2_d" schema="" table="droppk2_d" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk2_d" +== 854 +-- truncate_limit: 100 +DROP TABLE droppk1 +-- +TABLE: name="droppk1" schema="" table="droppk1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk1" +== 855 +-- truncate_limit: 100 +-- but DETACH is allowed, and DROP afterwards works +ALTER TABLE droppk2 DETACH PARTITION droppk21 +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE droppk2 DETACH PARTITION droppk21" +== 856 +-- truncate_limit: 100 +DROP TABLE droppk2 +-- +TABLE: name="droppk2" schema="" table="droppk2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE droppk2" +== 857 +-- truncate_limit: 100 +-- Verify that initial constraint creation and cloning behave correctly +CREATE SCHEMA fkpart5 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart5" +== 858 +-- truncate_limit: 100 +SET search_path TO fkpart5 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO fkpart5" +== 859 +-- truncate_limit: 100 +CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY LIST (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY LIST (a)" +== 860 +-- truncate_limit: 100 +CREATE TABLE pk1 PARTITION OF pk FOR VALUES IN (1) PARTITION BY LIST (a) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk1 PARTITION OF pk FOR VALUES IN (1) PARTITION BY LIST (a)" +== 861 +-- truncate_limit: 100 +CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES IN (1) +-- +TABLE: name="pk11" schema="" table="pk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES IN (1)" +== 862 +-- truncate_limit: 100 +CREATE TABLE fk (a int) PARTITION BY LIST (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk (a int) PARTITION BY LIST (a)" +== 863 +-- truncate_limit: 100 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES IN (1) PARTITION BY LIST (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk1 PARTITION OF fk FOR VALUES IN (1) PARTITION BY LIST (a)" +== 864 +-- truncate_limit: 100 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES IN (1) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES IN (1)" +== 865 +-- truncate_limit: 100 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk" +== 866 +-- truncate_limit: 100 +CREATE TABLE pk2 PARTITION OF pk FOR VALUES IN (2) +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk2 PARTITION OF pk FOR VALUES IN (2)" +== 867 +-- truncate_limit: 100 +CREATE TABLE pk3 (a int NOT NULL) PARTITION BY LIST (a) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk3 (a int NOT NULL) PARTITION BY LIST (a)" +== 868 +-- truncate_limit: 100 +CREATE TABLE pk31 PARTITION OF pk3 FOR VALUES IN (31) +-- +TABLE: name="pk31" schema="" table="pk31" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk31 PARTITION OF pk3 FOR VALUES IN (31)" +== 869 +-- truncate_limit: 100 +CREATE TABLE pk32 (b int, a int NOT NULL) +-- +TABLE: name="pk32" schema="" table="pk32" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk32 (b int, a int NOT NULL)" +== 870 +-- truncate_limit: 100 +ALTER TABLE pk32 DROP COLUMN b +-- +TABLE: name="pk32" schema="" table="pk32" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk32 DROP b" +== 871 +-- truncate_limit: 100 +ALTER TABLE pk3 ATTACH PARTITION pk32 FOR VALUES IN (32) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk3 ATTACH PARTITION pk32 FOR VALUES IN (32)" +== 872 +-- truncate_limit: 100 +ALTER TABLE pk ATTACH PARTITION pk3 FOR VALUES IN (31, 32) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk ATTACH PARTITION pk3 FOR VALUES IN (31, 32)" +== 873 +-- truncate_limit: 100 +CREATE TABLE fk2 PARTITION OF fk FOR VALUES IN (2) +-- +TABLE: name="fk2" schema="" table="fk2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk2 PARTITION OF fk FOR VALUES IN (2)" +== 874 +-- truncate_limit: 100 +CREATE TABLE fk3 (b int, a int) +-- +TABLE: name="fk3" schema="" table="fk3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk3 (b int, a int)" +== 875 +-- truncate_limit: 100 +ALTER TABLE fk3 DROP COLUMN b +-- +TABLE: name="fk3" schema="" table="fk3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk3 DROP b" +== 876 +-- truncate_limit: 100 +ALTER TABLE fk ATTACH PARTITION fk3 FOR VALUES IN (3) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ATTACH PARTITION fk3 FOR VALUES IN (3)" +== 877 +-- truncate_limit: 100 +SELECT pg_describe_object('pg_constraint'::regclass, oid, 0), confrelid::regclass, + CASE WHEN conparentid <> 0 THEN pg_describe_object('pg_constraint'::regclass, conparentid, 0) ELSE 'TOP' END +FROM pg_catalog.pg_constraint +WHERE conrelid IN (SELECT relid FROM pg_partition_tree('fk')) +ORDER BY conrelid::regclass::text, conname +-- +TABLE: name="pg_catalog.pg_constraint" schema="pg_catalog" table="pg_constraint" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_catalog.pg_constraint WHERE ... ORDER BY conrelid::regclass::text, conname" +== 878 +-- truncate_limit: 100 +CREATE TABLE fk4 (LIKE fk) +-- +TABLE: name="fk4" schema="" table="fk4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk4 (LIKE fk)" +== 879 +-- truncate_limit: 100 +INSERT INTO fk4 VALUES (50) +-- +TABLE: name="fk4" schema="" table="fk4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk4 VALUES (50)" +== 880 +-- truncate_limit: 100 +ALTER TABLE fk ATTACH PARTITION fk4 FOR VALUES IN (50) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ATTACH PARTITION fk4 FOR VALUES IN (50)" +== 881 +-- truncate_limit: 100 +-- Verify constraint deferrability +CREATE SCHEMA fkpart9 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart9" +== 882 +-- truncate_limit: 100 +SET search_path TO fkpart9 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO fkpart9" +== 883 +-- truncate_limit: 100 +CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY LIST (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY LIST (a)" +== 884 +-- truncate_limit: 100 +CREATE TABLE pk1 PARTITION OF pk FOR VALUES IN (1, 2) PARTITION BY LIST (a) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk1 PARTITION OF pk FOR VALUES IN (1, 2) PARTITION BY LIST (a)" +== 885 +-- truncate_limit: 100 +CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES IN (1) +-- +TABLE: name="pk11" schema="" table="pk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES IN (1)" +== 886 +-- truncate_limit: 100 +CREATE TABLE pk3 PARTITION OF pk FOR VALUES IN (3) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk3 PARTITION OF pk FOR VALUES IN (3)" +== 887 +-- truncate_limit: 100 +CREATE TABLE fk (a int REFERENCES pk DEFERRABLE INITIALLY IMMEDIATE) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk (a int REFERENCES pk DEFERRABLE INITIALLY IMMEDIATE)" +== 888 +-- truncate_limit: 100 +INSERT INTO fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (1)" +== 889 +-- truncate_limit: 100 +-- should fail +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 890 +-- truncate_limit: 100 +SET CONSTRAINTS fk_a_fkey DEFERRED +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS fk_a_fkey DEFERRED" +== 891 +-- truncate_limit: 100 +INSERT INTO fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (1)" +== 892 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 893 +-- truncate_limit: 100 +-- should fail +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 894 +-- truncate_limit: 100 +SET CONSTRAINTS fk_a_fkey DEFERRED +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS fk_a_fkey DEFERRED" +== 895 +-- truncate_limit: 100 +INSERT INTO fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (1)" +== 896 +-- truncate_limit: 100 +INSERT INTO pk VALUES (1) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pk VALUES (1)" +== 897 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 898 +-- truncate_limit: 100 +-- OK +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 899 +-- truncate_limit: 100 +SET CONSTRAINTS fk_a_fkey DEFERRED +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS fk_a_fkey DEFERRED" +== 900 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 1 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 1" +== 901 +-- truncate_limit: 100 +DELETE FROM fk WHERE a = 1 +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk WHERE a = 1" +== 902 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 903 +-- truncate_limit: 100 +-- OK + +-- Verify constraint deferrability when changed by ALTER +-- Partitioned table at referencing end +CREATE TABLE pt(f1 int, f2 int, f3 int, PRIMARY KEY(f1,f2)) +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt (f1 int, f2 int, f3 int, PRIMARY KEY (f1, f2))" +== 904 +-- truncate_limit: 100 +CREATE TABLE ref(f1 int, f2 int, f3 int) + PARTITION BY list(f1) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref (f1 int, f2 int, f3 int) PARTITION BY LIST (f1)" +== 905 +-- truncate_limit: 100 +CREATE TABLE ref1 PARTITION OF ref FOR VALUES IN (1) +-- +TABLE: name="ref1" schema="" table="ref1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref1 PARTITION OF ref FOR VALUES IN (1)" +== 906 +-- truncate_limit: 100 +CREATE TABLE ref2 PARTITION OF ref FOR VALUES in (2) +-- +TABLE: name="ref2" schema="" table="ref2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref2 PARTITION OF ref FOR VALUES IN (2)" +== 907 +-- truncate_limit: 100 +ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ADD FOREIGN KEY (f1, f2) REFERENCES pt" +== 908 +-- truncate_limit: 100 +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey DEFERRABLE INITIALLY DEFERRED" +== 909 +-- truncate_limit: 100 +INSERT INTO pt VALUES(1,2,3) +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pt VALUES (1, 2, 3)" +== 910 +-- truncate_limit: 100 +INSERT INTO ref VALUES(1,2,3) +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ref VALUES (1, 2, 3)" +== 911 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 912 +-- truncate_limit: 100 +DELETE FROM pt +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pt" +== 913 +-- truncate_limit: 100 +DELETE FROM ref +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ref" +== 914 +-- truncate_limit: 100 +ABORT +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 915 +-- truncate_limit: 100 +DROP TABLE pt, ref +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pt, ref" +== 916 +-- truncate_limit: 100 +-- Multi-level partitioning at referencing end +CREATE TABLE pt(f1 int, f2 int, f3 int, PRIMARY KEY(f1,f2)) +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt (f1 int, f2 int, f3 int, PRIMARY KEY (f1, f2))" +== 917 +-- truncate_limit: 100 +CREATE TABLE ref(f1 int, f2 int, f3 int) + PARTITION BY list(f1) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref (f1 int, f2 int, f3 int) PARTITION BY LIST (f1)" +== 918 +-- truncate_limit: 100 +CREATE TABLE ref1_2 PARTITION OF ref FOR VALUES IN (1, 2) PARTITION BY list (f2) +-- +TABLE: name="ref1_2" schema="" table="ref1_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref1_2 PARTITION OF ref FOR VALUES IN (1, 2) PARTITION BY LIST (f2)" +== 919 +-- truncate_limit: 100 +CREATE TABLE ref1 PARTITION OF ref1_2 FOR VALUES IN (1) +-- +TABLE: name="ref1" schema="" table="ref1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref1 PARTITION OF ref1_2 FOR VALUES IN (1)" +== 920 +-- truncate_limit: 100 +CREATE TABLE ref2 PARTITION OF ref1_2 FOR VALUES IN (2) PARTITION BY list (f2) +-- +TABLE: name="ref2" schema="" table="ref2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref2 PARTITION OF ref1_2 FOR VALUES IN (2) PARTITION BY LIST (f2)" +== 921 +-- truncate_limit: 100 +CREATE TABLE ref22 PARTITION OF ref2 FOR VALUES IN (2) +-- +TABLE: name="ref22" schema="" table="ref22" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref22 PARTITION OF ref2 FOR VALUES IN (2)" +== 922 +-- truncate_limit: 100 +ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ADD FOREIGN KEY (f1, f2) REFERENCES pt" +== 923 +-- truncate_limit: 100 +INSERT INTO pt VALUES(1,2,3) +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pt VALUES (1, 2, 3)" +== 924 +-- truncate_limit: 100 +INSERT INTO ref VALUES(1,2,3) +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ref VALUES (1, 2, 3)" +== 925 +-- truncate_limit: 100 +ALTER TABLE ref22 ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY IMMEDIATE +-- +TABLE: name="ref22" schema="" table="ref22" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref22 ALTER CONSTRAINT ref_f1_f2_fkey DEFERRABLE" +== 926 +-- truncate_limit: 100 +-- fails +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey DEFERRABLE INITIALLY DEFERRED" +== 927 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 928 +-- truncate_limit: 100 +DELETE FROM pt +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pt" +== 929 +-- truncate_limit: 100 +DELETE FROM ref +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ref" +== 930 +-- truncate_limit: 100 +ABORT +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 931 +-- truncate_limit: 100 +DROP TABLE pt, ref +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pt, ref" +== 932 +-- truncate_limit: 100 +-- Partitioned table at referenced end +CREATE TABLE pt(f1 int, f2 int, f3 int, PRIMARY KEY(f1,f2)) + PARTITION BY LIST(f1) +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt (f1 int, f2 int, f3 int, PRIMARY KEY (f1, f2)) PARTITION BY LIST (f1)" +== 933 +-- truncate_limit: 100 +CREATE TABLE pt1 PARTITION OF pt FOR VALUES IN (1) +-- +TABLE: name="pt1" schema="" table="pt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt1 PARTITION OF pt FOR VALUES IN (1)" +== 934 +-- truncate_limit: 100 +CREATE TABLE pt2 PARTITION OF pt FOR VALUES IN (2) +-- +TABLE: name="pt2" schema="" table="pt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt2 PARTITION OF pt FOR VALUES IN (2)" +== 935 +-- truncate_limit: 100 +CREATE TABLE ref(f1 int, f2 int, f3 int) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref (f1 int, f2 int, f3 int)" +== 936 +-- truncate_limit: 100 +ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ADD FOREIGN KEY (f1, f2) REFERENCES pt" +== 937 +-- truncate_limit: 100 +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey DEFERRABLE INITIALLY DEFERRED" +== 938 +-- truncate_limit: 100 +INSERT INTO pt VALUES(1,2,3) +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pt VALUES (1, 2, 3)" +== 939 +-- truncate_limit: 100 +INSERT INTO ref VALUES(1,2,3) +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ref VALUES (1, 2, 3)" +== 940 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 941 +-- truncate_limit: 100 +DELETE FROM pt +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pt" +== 942 +-- truncate_limit: 100 +DELETE FROM ref +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ref" +== 943 +-- truncate_limit: 100 +ABORT +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 944 +-- truncate_limit: 100 +DROP TABLE pt, ref +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pt, ref" +== 945 +-- truncate_limit: 100 +-- Multi-level partitioning at referenced end +CREATE TABLE pt(f1 int, f2 int, f3 int, PRIMARY KEY(f1,f2)) + PARTITION BY LIST(f1) +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt (f1 int, f2 int, f3 int, PRIMARY KEY (f1, f2)) PARTITION BY LIST (f1)" +== 946 +-- truncate_limit: 100 +CREATE TABLE pt1_2 PARTITION OF pt FOR VALUES IN (1, 2) PARTITION BY LIST (f1) +-- +TABLE: name="pt1_2" schema="" table="pt1_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt1_2 PARTITION OF pt FOR VALUES IN (1, 2) PARTITION BY LIST (f1)" +== 947 +-- truncate_limit: 100 +CREATE TABLE pt1 PARTITION OF pt1_2 FOR VALUES IN (1) +-- +TABLE: name="pt1" schema="" table="pt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt1 PARTITION OF pt1_2 FOR VALUES IN (1)" +== 948 +-- truncate_limit: 100 +CREATE TABLE pt2 PARTITION OF pt1_2 FOR VALUES IN (2) +-- +TABLE: name="pt2" schema="" table="pt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt2 PARTITION OF pt1_2 FOR VALUES IN (2)" +== 949 +-- truncate_limit: 100 +CREATE TABLE ref(f1 int, f2 int, f3 int) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref (f1 int, f2 int, f3 int)" +== 950 +-- truncate_limit: 100 +ALTER TABLE ref ADD FOREIGN KEY(f1,f2) REFERENCES pt +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ADD FOREIGN KEY (f1, f2) REFERENCES pt" +== 951 +-- truncate_limit: 100 +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey1 + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey1 DEFERRABLE INITIALLY DEFERRED" +== 952 +-- truncate_limit: 100 +-- fails +ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey + DEFERRABLE INITIALLY DEFERRED +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ref ALTER CONSTRAINT ref_f1_f2_fkey DEFERRABLE INITIALLY DEFERRED" +== 953 +-- truncate_limit: 100 +INSERT INTO pt VALUES(1,2,3) +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pt VALUES (1, 2, 3)" +== 954 +-- truncate_limit: 100 +INSERT INTO ref VALUES(1,2,3) +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ref VALUES (1, 2, 3)" +== 955 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 956 +-- truncate_limit: 100 +DELETE FROM pt +-- +TABLE: name="pt" schema="" table="pt" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pt" +== 957 +-- truncate_limit: 100 +DELETE FROM ref +-- +TABLE: name="ref" schema="" table="ref" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ref" +== 958 +-- truncate_limit: 100 +ABORT +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 959 +-- truncate_limit: 100 +DROP TABLE pt, ref +-- +TABLE: name="pt" schema="" table="pt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pt, ref" +== 960 +-- truncate_limit: 100 +DROP SCHEMA fkpart9 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart9 CASCADE" +== 961 +-- truncate_limit: 100 +-- Verify ON UPDATE/DELETE behavior +CREATE SCHEMA fkpart6 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart6" +== 962 +-- truncate_limit: 100 +SET search_path TO fkpart6 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO fkpart6" +== 963 +-- truncate_limit: 100 +CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY RANGE (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY RANGE (a)" +== 964 +-- truncate_limit: 100 +CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a)" +== 965 +-- truncate_limit: 100 +CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES FROM (1) TO (50) +-- +TABLE: name="pk11" schema="" table="pk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES FROM (1) TO (50)" +== 966 +-- truncate_limit: 100 +CREATE TABLE pk12 PARTITION OF pk1 FOR VALUES FROM (50) TO (100) +-- +TABLE: name="pk12" schema="" table="pk12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk12 PARTITION OF pk1 FOR VALUES FROM (50) TO (100)" +== 967 +-- truncate_limit: 100 +CREATE TABLE fk (a int) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk (a int) PARTITION BY RANGE (a)" +== 968 +-- truncate_limit: 100 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a)" +== 969 +-- truncate_limit: 100 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10)" +== 970 +-- truncate_limit: 100 +CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100) +-- +TABLE: name="fk12" schema="" table="fk12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100)" +== 971 +-- truncate_limit: 100 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE CASCADE ON DELETE CASCADE +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE CASCADE ON DELETE CASCADE" +== 972 +-- truncate_limit: 100 +CREATE TABLE fk_d PARTITION OF fk DEFAULT +-- +TABLE: name="fk_d" schema="" table="fk_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_d PARTITION OF fk DEFAULT" +== 973 +-- truncate_limit: 100 +INSERT INTO pk VALUES (1) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pk VALUES (1)" +== 974 +-- truncate_limit: 100 +INSERT INTO fk VALUES (1) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (1)" +== 975 +-- truncate_limit: 100 +UPDATE pk SET a = 20 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 20" +== 976 +-- truncate_limit: 100 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM fk" +== 977 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 20 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 20" +== 978 +-- truncate_limit: 100 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM fk" +== 979 +-- truncate_limit: 100 +DROP TABLE fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk" +== 980 +-- truncate_limit: 100 +TRUNCATE TABLE pk +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE pk" +== 981 +-- truncate_limit: 100 +INSERT INTO pk VALUES (20), (50) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pk VALUES (20), (50)" +== 982 +-- truncate_limit: 100 +CREATE TABLE fk (a int) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk (a int) PARTITION BY RANGE (a)" +== 983 +-- truncate_limit: 100 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a)" +== 984 +-- truncate_limit: 100 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10)" +== 985 +-- truncate_limit: 100 +CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100) +-- +TABLE: name="fk12" schema="" table="fk12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100)" +== 986 +-- truncate_limit: 100 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE SET NULL ON DELETE SET NULL +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE SET NULL ON DELETE SET NULL" +== 987 +-- truncate_limit: 100 +CREATE TABLE fk_d PARTITION OF fk DEFAULT +-- +TABLE: name="fk_d" schema="" table="fk_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_d PARTITION OF fk DEFAULT" +== 988 +-- truncate_limit: 100 +INSERT INTO fk VALUES (20), (50) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (20), (50)" +== 989 +-- truncate_limit: 100 +UPDATE pk SET a = 21 WHERE a = 20 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 21 WHERE a = 20" +== 990 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 50 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 50" +== 991 +-- truncate_limit: 100 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM fk" +== 992 +-- truncate_limit: 100 +DROP TABLE fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk" +== 993 +-- truncate_limit: 100 +TRUNCATE TABLE pk +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE pk" +== 994 +-- truncate_limit: 100 +INSERT INTO pk VALUES (20), (30), (50) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pk VALUES (20), (30), (50)" +== 995 +-- truncate_limit: 100 +CREATE TABLE fk (id int, a int DEFAULT 50) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk (id int, a int DEFAULT 50) PARTITION BY RANGE (a)" +== 996 +-- truncate_limit: 100 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a)" +== 997 +-- truncate_limit: 100 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10)" +== 998 +-- truncate_limit: 100 +CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100) +-- +TABLE: name="fk12" schema="" table="fk12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100)" +== 999 +-- truncate_limit: 100 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE SET DEFAULT ON DELETE SET DEFAULT +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE SET DEFAULT ON DELETE SET DEFAULT" +== 1000 +-- truncate_limit: 100 +CREATE TABLE fk_d PARTITION OF fk DEFAULT +-- +TABLE: name="fk_d" schema="" table="fk_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_d PARTITION OF fk DEFAULT" +== 1001 +-- truncate_limit: 100 +INSERT INTO fk VALUES (1, 20), (2, 30) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (1, 20), (2, 30)" +== 1002 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 20 RETURNING * +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 20 RETURNING *" +== 1003 +-- truncate_limit: 100 +UPDATE pk SET a = 90 WHERE a = 30 RETURNING * +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 90 WHERE a = 30 RETURNING *" +== 1004 +-- truncate_limit: 100 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM fk" +== 1005 +-- truncate_limit: 100 +DROP TABLE fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk" +== 1006 +-- truncate_limit: 100 +TRUNCATE TABLE pk +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE pk" +== 1007 +-- truncate_limit: 100 +INSERT INTO pk VALUES (20), (30) +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pk VALUES (20), (30)" +== 1008 +-- truncate_limit: 100 +CREATE TABLE fk (a int DEFAULT 50) PARTITION BY RANGE (a) +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk (a int DEFAULT 50) PARTITION BY RANGE (a)" +== 1009 +-- truncate_limit: 100 +CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a) +-- +TABLE: name="fk1" schema="" table="fk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk1 PARTITION OF fk FOR VALUES FROM (1) TO (100) PARTITION BY RANGE (a)" +== 1010 +-- truncate_limit: 100 +CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="fk11" schema="" table="fk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk11 PARTITION OF fk1 FOR VALUES FROM (1) TO (10)" +== 1011 +-- truncate_limit: 100 +CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100) +-- +TABLE: name="fk12" schema="" table="fk12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk12 PARTITION OF fk1 FOR VALUES FROM (10) TO (100)" +== 1012 +-- truncate_limit: 100 +ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE RESTRICT ON DELETE RESTRICT +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk ADD FOREIGN KEY (a) REFERENCES pk ON UPDATE RESTRICT ON DELETE RESTRICT" +== 1013 +-- truncate_limit: 100 +CREATE TABLE fk_d PARTITION OF fk DEFAULT +-- +TABLE: name="fk_d" schema="" table="fk_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fk_d PARTITION OF fk DEFAULT" +== 1014 +-- truncate_limit: 100 +INSERT INTO fk VALUES (20), (30) +-- +TABLE: name="fk" schema="" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk VALUES (20), (30)" +== 1015 +-- truncate_limit: 100 +DELETE FROM pk WHERE a = 20 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pk WHERE a = 20" +== 1016 +-- truncate_limit: 100 +UPDATE pk SET a = 90 WHERE a = 30 +-- +TABLE: name="pk" schema="" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pk SET a = 90 WHERE a = 30" +== 1017 +-- truncate_limit: 100 +SELECT tableoid::regclass, * FROM fk +-- +TABLE: name="fk" schema="" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM fk" +== 1018 +-- truncate_limit: 100 +DROP TABLE fk +-- +TABLE: name="fk" schema="" table="fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fk" +== 1019 +-- truncate_limit: 100 +-- test for reported bug: relispartition not set +-- https://postgr.es/m/CA+HiwqHMsRtRYRWYTWavKJ8x14AFsv7bmAV46mYwnfD3vy8goQ@mail.gmail.com +CREATE SCHEMA fkpart7 + CREATE TABLE pkpart (a int) PARTITION BY LIST (a) + CREATE TABLE pkpart1 PARTITION OF pkpart FOR VALUES IN (1) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart7 CREATE TABLE pkpart (a int) PARTITION BY LIST (a) CREATE TABLE pkpart1 PART..." +== 1020 +-- truncate_limit: 100 +ALTER TABLE fkpart7.pkpart1 ADD PRIMARY KEY (a) +-- +TABLE: name="fkpart7.pkpart1" schema="fkpart7" table="pkpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart7.pkpart1 ADD PRIMARY KEY (a)" +== 1021 +-- truncate_limit: 100 +ALTER TABLE fkpart7.pkpart ADD PRIMARY KEY (a) +-- +TABLE: name="fkpart7.pkpart" schema="fkpart7" table="pkpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart7.pkpart ADD PRIMARY KEY (a)" +== 1022 +-- truncate_limit: 100 +CREATE TABLE fkpart7.fk (a int REFERENCES fkpart7.pkpart) +-- +TABLE: name="fkpart7.fk" schema="fkpart7" table="fk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart7.fk (a int REFERENCES fkpart7.pkpart)" +== 1023 +-- truncate_limit: 100 +DROP SCHEMA fkpart7 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart7 CASCADE" +== 1024 +-- truncate_limit: 100 +-- ensure we check partitions are "not used" when dropping constraints +CREATE SCHEMA fkpart8 + CREATE TABLE tbl1(f1 int PRIMARY KEY) + CREATE TABLE tbl2(f1 int REFERENCES tbl1 DEFERRABLE INITIALLY DEFERRED) PARTITION BY RANGE(f1) + CREATE TABLE tbl2_p1 PARTITION OF tbl2 FOR VALUES FROM (minvalue) TO (maxvalue) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart8 CREATE TABLE tbl1 (f1 int PRIMARY KEY) CREATE TABLE tbl2 (f1 int REFERENCES..." +== 1025 +-- truncate_limit: 100 +INSERT INTO fkpart8.tbl1 VALUES(1) +-- +TABLE: name="fkpart8.tbl1" schema="fkpart8" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart8.tbl1 VALUES (1)" +== 1026 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1027 +-- truncate_limit: 100 +INSERT INTO fkpart8.tbl2 VALUES(1) +-- +TABLE: name="fkpart8.tbl2" schema="fkpart8" table="tbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart8.tbl2 VALUES (1)" +== 1028 +-- truncate_limit: 100 +ALTER TABLE fkpart8.tbl2 DROP CONSTRAINT tbl2_f1_fkey +-- +TABLE: name="fkpart8.tbl2" schema="fkpart8" table="tbl2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart8.tbl2 DROP CONSTRAINT tbl2_f1_fkey" +== 1029 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1030 +-- truncate_limit: 100 +DROP SCHEMA fkpart8 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart8 CASCADE" +== 1031 +-- truncate_limit: 100 +-- ensure FK referencing a multi-level partitioned table are +-- enforce reference to sub-children. +CREATE SCHEMA fkpart9 + CREATE TABLE pk (a INT PRIMARY KEY) PARTITION BY RANGE (a) + CREATE TABLE fk ( + fk_a INT REFERENCES pk(a) ON DELETE CASCADE + ) + CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (30) TO (50) PARTITION BY RANGE (a) + CREATE TABLE pk11 PARTITION OF pk1 FOR VALUES FROM (30) TO (40) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart9 CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY RANGE (a) CREATE TABLE fk ..." +== 1032 +-- truncate_limit: 100 +INSERT INTO fkpart9.pk VALUES (35) +-- +TABLE: name="fkpart9.pk" schema="fkpart9" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart9.pk VALUES (35)" +== 1033 +-- truncate_limit: 100 +INSERT INTO fkpart9.fk VALUES (35) +-- +TABLE: name="fkpart9.fk" schema="fkpart9" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart9.fk VALUES (35)" +== 1034 +-- truncate_limit: 100 +DELETE FROM fkpart9.pk WHERE a=35 +-- +TABLE: name="fkpart9.pk" schema="fkpart9" table="pk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fkpart9.pk WHERE a = 35" +== 1035 +-- truncate_limit: 100 +SELECT * FROM fkpart9.pk +-- +TABLE: name="fkpart9.pk" schema="fkpart9" table="pk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fkpart9.pk" +== 1036 +-- truncate_limit: 100 +SELECT * FROM fkpart9.fk +-- +TABLE: name="fkpart9.fk" schema="fkpart9" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fkpart9.fk" +== 1037 +-- truncate_limit: 100 +DROP SCHEMA fkpart9 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart9 CASCADE" +== 1038 +-- truncate_limit: 100 +-- test that ri_Check_Pk_Match() scans the correct partition for a deferred +-- ON DELETE/UPDATE NO ACTION constraint +CREATE SCHEMA fkpart10 + CREATE TABLE tbl1(f1 int PRIMARY KEY) PARTITION BY RANGE(f1) + CREATE TABLE tbl1_p1 PARTITION OF tbl1 FOR VALUES FROM (minvalue) TO (1) + CREATE TABLE tbl1_p2 PARTITION OF tbl1 FOR VALUES FROM (1) TO (maxvalue) + CREATE TABLE tbl2(f1 int REFERENCES tbl1 DEFERRABLE INITIALLY DEFERRED) + CREATE TABLE tbl3(f1 int PRIMARY KEY) PARTITION BY RANGE(f1) + CREATE TABLE tbl3_p1 PARTITION OF tbl3 FOR VALUES FROM (minvalue) TO (1) + CREATE TABLE tbl3_p2 PARTITION OF tbl3 FOR VALUES FROM (1) TO (maxvalue) + CREATE TABLE tbl4(f1 int REFERENCES tbl3 DEFERRABLE INITIALLY DEFERRED) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart10 CREATE TABLE tbl1 (f1 int PRIMARY KEY) PARTITION BY RANGE (f1) CREATE TABL..." +== 1039 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl1 VALUES (0), (1) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl1 VALUES (0), (1)" +== 1040 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl2 VALUES (0), (1) +-- +TABLE: name="fkpart10.tbl2" schema="fkpart10" table="tbl2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl2 VALUES (0), (1)" +== 1041 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl3 VALUES (-2), (-1), (0) +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl3 VALUES (-2), (-1), (0)" +== 1042 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl4 VALUES (-2), (-1) +-- +TABLE: name="fkpart10.tbl4" schema="fkpart10" table="tbl4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl4 VALUES (-2), (-1)" +== 1043 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1044 +-- truncate_limit: 100 +DELETE FROM fkpart10.tbl1 WHERE f1 = 0 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fkpart10.tbl1 WHERE f1 = 0" +== 1045 +-- truncate_limit: 100 +UPDATE fkpart10.tbl1 SET f1 = 2 WHERE f1 = 1 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl1 SET f1 = 2 WHERE f1 = 1" +== 1046 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl1 VALUES (0), (1) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl1 VALUES (0), (1)" +== 1047 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1048 +-- truncate_limit: 100 +-- test that cross-partition updates correctly enforces the foreign key +-- restriction (specifically testing INITIALLY DEFERRED) +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1049 +-- truncate_limit: 100 +UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0" +== 1050 +-- truncate_limit: 100 +UPDATE fkpart10.tbl3 SET f1 = f1 * -1 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl3 SET f1 = f1 * -1" +== 1051 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl1 VALUES (4) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl1 VALUES (4)" +== 1052 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1053 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1054 +-- truncate_limit: 100 +UPDATE fkpart10.tbl3 SET f1 = f1 * -1 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl3 SET f1 = f1 * -1" +== 1055 +-- truncate_limit: 100 +UPDATE fkpart10.tbl3 SET f1 = f1 + 3 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl3 SET f1 = f1 + 3" +== 1056 +-- truncate_limit: 100 +UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0" +== 1057 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl1 VALUES (0) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl1 VALUES (0)" +== 1058 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1059 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1060 +-- truncate_limit: 100 +UPDATE fkpart10.tbl3 SET f1 = f1 * -1 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl3 SET f1 = f1 * -1" +== 1061 +-- truncate_limit: 100 +UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0 +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl1 SET f1 = 3 WHERE f1 = 0" +== 1062 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl1 VALUES (0) +-- +TABLE: name="fkpart10.tbl1" schema="fkpart10" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl1 VALUES (0)" +== 1063 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl3 VALUES (-2), (-1) +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl3 VALUES (-2), (-1)" +== 1064 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1065 +-- truncate_limit: 100 +-- test where the updated table now has both an IMMEDIATE and a DEFERRED +-- constraint pointing into it +CREATE TABLE fkpart10.tbl5(f1 int REFERENCES fkpart10.tbl3) +-- +TABLE: name="fkpart10.tbl5" schema="fkpart10" table="tbl5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart10.tbl5 (f1 int REFERENCES fkpart10.tbl3)" +== 1066 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl5 VALUES (-2), (-1) +-- +TABLE: name="fkpart10.tbl5" schema="fkpart10" table="tbl5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl5 VALUES (-2), (-1)" +== 1067 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1068 +-- truncate_limit: 100 +UPDATE fkpart10.tbl3 SET f1 = f1 * -3 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl3 SET f1 = f1 * -3" +== 1069 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1070 +-- truncate_limit: 100 +-- Now test where the row referenced from the table with an IMMEDIATE +-- constraint stays in place, while those referenced from the table with a +-- DEFERRED constraint don't. +DELETE FROM fkpart10.tbl5 +-- +TABLE: name="fkpart10.tbl5" schema="fkpart10" table="tbl5" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fkpart10.tbl5" +== 1071 +-- truncate_limit: 100 +INSERT INTO fkpart10.tbl5 VALUES (0) +-- +TABLE: name="fkpart10.tbl5" schema="fkpart10" table="tbl5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart10.tbl5 VALUES (0)" +== 1072 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1073 +-- truncate_limit: 100 +UPDATE fkpart10.tbl3 SET f1 = f1 * -3 +-- +TABLE: name="fkpart10.tbl3" schema="fkpart10" table="tbl3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart10.tbl3 SET f1 = f1 * -3" +== 1074 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 1075 +-- truncate_limit: 100 +DROP SCHEMA fkpart10 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart10 CASCADE" +== 1076 +-- truncate_limit: 100 +-- verify foreign keys are enforced during cross-partition updates, +-- especially on the PK side +CREATE SCHEMA fkpart11 + CREATE TABLE pk (a INT PRIMARY KEY, b text) PARTITION BY LIST (a) + CREATE TABLE fk ( + a INT, + CONSTRAINT fkey FOREIGN KEY (a) REFERENCES pk(a) ON UPDATE CASCADE ON DELETE CASCADE + ) + CREATE TABLE fk_parted ( + a INT PRIMARY KEY, + CONSTRAINT fkey FOREIGN KEY (a) REFERENCES pk(a) ON UPDATE CASCADE ON DELETE CASCADE + ) PARTITION BY LIST (a) + CREATE TABLE fk_another ( + a INT, + CONSTRAINT fkey FOREIGN KEY (a) REFERENCES fk_parted (a) ON UPDATE CASCADE ON DELETE CASCADE + ) + CREATE TABLE pk1 PARTITION OF pk FOR VALUES IN (1, 2) PARTITION BY LIST (a) + CREATE TABLE pk2 PARTITION OF pk FOR VALUES IN (3) + CREATE TABLE pk3 PARTITION OF pk FOR VALUES IN (4) + CREATE TABLE fk1 PARTITION OF fk_parted FOR VALUES IN (1, 2) + CREATE TABLE fk2 PARTITION OF fk_parted FOR VALUES IN (3) + CREATE TABLE fk3 PARTITION OF fk_parted FOR VALUES IN (4) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart11 CREATE TABLE pk (a int PRIMARY KEY, b text) PARTITION BY LIST (a) CREATE T..." +== 1077 +-- truncate_limit: 100 +CREATE TABLE fkpart11.pk11 (b text, a int NOT NULL) +-- +TABLE: name="fkpart11.pk11" schema="fkpart11" table="pk11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart11.pk11 (b text, a int NOT NULL)" +== 1078 +-- truncate_limit: 100 +ALTER TABLE fkpart11.pk1 ATTACH PARTITION fkpart11.pk11 FOR VALUES IN (1) +-- +TABLE: name="fkpart11.pk1" schema="fkpart11" table="pk1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart11.pk1 ATTACH PARTITION fkpart11.pk11 FOR VALUES IN (1)" +== 1079 +-- truncate_limit: 100 +CREATE TABLE fkpart11.pk12 (b text, c int, a int NOT NULL) +-- +TABLE: name="fkpart11.pk12" schema="fkpart11" table="pk12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart11.pk12 (b text, c int, a int NOT NULL)" +== 1080 +-- truncate_limit: 100 +ALTER TABLE fkpart11.pk12 DROP c +-- +TABLE: name="fkpart11.pk12" schema="fkpart11" table="pk12" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart11.pk12 DROP c" +== 1081 +-- truncate_limit: 100 +ALTER TABLE fkpart11.pk1 ATTACH PARTITION fkpart11.pk12 FOR VALUES IN (2) +-- +TABLE: name="fkpart11.pk1" schema="fkpart11" table="pk1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart11.pk1 ATTACH PARTITION fkpart11.pk12 FOR VALUES IN (2)" +== 1082 +-- truncate_limit: 100 +INSERT INTO fkpart11.pk VALUES (1, 'xxx'), (3, 'yyy') +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart11.pk VALUES (1, 'xxx'), (3, 'yyy')" +== 1083 +-- truncate_limit: 100 +INSERT INTO fkpart11.fk VALUES (1), (3) +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart11.fk VALUES (1), (3)" +== 1084 +-- truncate_limit: 100 +INSERT INTO fkpart11.fk_parted VALUES (1), (3) +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart11.fk_parted VALUES (1), (3)" +== 1085 +-- truncate_limit: 100 +INSERT INTO fkpart11.fk_another VALUES (1), (3) +-- +TABLE: name="fkpart11.fk_another" schema="fkpart11" table="fk_another" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart11.fk_another VALUES (1), (3)" +== 1086 +-- truncate_limit: 100 +-- moves 2 rows from one leaf partition to another, with both updates being +-- cascaded to fk and fk_parted. Updates of fk_parted, of which one is +-- cross-partition (3 -> 4), are further cascaded to fk_another. +UPDATE fkpart11.pk SET a = a + 1 RETURNING tableoid::pg_catalog.regclass, * +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart11.pk SET a = a + 1 RETURNING tableoid::pg_catalog.regclass, *" +== 1087 +-- truncate_limit: 100 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk" +== 1088 +-- truncate_limit: 100 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_parted +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_parted" +== 1089 +-- truncate_limit: 100 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_another +-- +TABLE: name="fkpart11.fk_another" schema="fkpart11" table="fk_another" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_another" +== 1090 +-- truncate_limit: 100 +-- let's try with the foreign key pointing at tables in the partition tree +-- that are not the same as the query's target table + +-- 1. foreign key pointing into a non-root ancestor +|-- +-- A cross-partition update on the root table will fail, because we currently +-- can't enforce the foreign keys pointing into a non-leaf partition +ALTER TABLE fkpart11.fk DROP CONSTRAINT fkey +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart11.fk DROP CONSTRAINT fkey" +== 1091 +-- truncate_limit: 100 +DELETE FROM fkpart11.fk WHERE a = 4 +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fkpart11.fk WHERE a = 4" +== 1092 +-- truncate_limit: 100 +ALTER TABLE fkpart11.fk ADD CONSTRAINT fkey FOREIGN KEY (a) REFERENCES fkpart11.pk1 (a) ON UPDATE CASCADE ON DELETE CASCADE +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart11.fk ADD CONSTRAINT fkey FOREIGN KEY (a) REFERENCES fkpart11.pk1 (a) ON UPDATE..." +== 1093 +-- truncate_limit: 100 +UPDATE fkpart11.pk SET a = a - 1 +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart11.pk SET a = a - 1" +== 1094 +-- truncate_limit: 100 +-- it's okay though if the non-leaf partition is updated directly +UPDATE fkpart11.pk1 SET a = a - 1 +-- +TABLE: name="fkpart11.pk1" schema="fkpart11" table="pk1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart11.pk1 SET a = a - 1" +== 1095 +-- truncate_limit: 100 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.pk +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.pk" +== 1096 +-- truncate_limit: 100 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk" +== 1097 +-- truncate_limit: 100 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_parted +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_parted" +== 1098 +-- truncate_limit: 100 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_another +-- +TABLE: name="fkpart11.fk_another" schema="fkpart11" table="fk_another" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk_another" +== 1099 +-- truncate_limit: 100 +-- 2. foreign key pointing into a single leaf partition +|-- +-- A cross-partition update that deletes from the pointed-to leaf partition +-- is allowed to succeed +ALTER TABLE fkpart11.fk DROP CONSTRAINT fkey +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart11.fk DROP CONSTRAINT fkey" +== 1100 +-- truncate_limit: 100 +ALTER TABLE fkpart11.fk ADD CONSTRAINT fkey FOREIGN KEY (a) REFERENCES fkpart11.pk11 (a) ON UPDATE CASCADE ON DELETE CASCADE +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart11.fk ADD CONSTRAINT fkey FOREIGN KEY (a) REFERENCES fkpart11.pk11 (a) ON UPDAT..." +== 1101 +-- truncate_limit: 100 +-- will delete (1) from p11 which is cascaded to fk +UPDATE fkpart11.pk SET a = a + 1 WHERE a = 1 +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart11.pk SET a = a + 1 WHERE a = 1" +== 1102 +-- truncate_limit: 100 +SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::pg_catalog.regclass, * FROM fkpart11.fk" +== 1103 +-- truncate_limit: 100 +DROP TABLE fkpart11.fk +-- +TABLE: name="fkpart11.fk" schema="fkpart11" table="fk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fkpart11.fk" +== 1104 +-- truncate_limit: 100 +-- check that regular and deferrable AR triggers on the PK tables +-- still work as expected +CREATE FUNCTION fkpart11.print_row () RETURNS TRIGGER LANGUAGE plpgsql AS $$ + BEGIN + RAISE NOTICE 'TABLE: %, OP: %, OLD: %, NEW: %', TG_RELNAME, TG_OP, OLD, NEW; + RETURN NULL; + END; +$$ +-- +FUNCTION: name="fkpart11.print_row" function="print_row" schema="fkpart11" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fkpart11.print_row() RETURNS trigger LANGUAGE plpgsql AS $$\n BEGIN\n RAISE NOT..." +== 1105 +-- truncate_limit: 100 +CREATE TRIGGER trig_upd_pk AFTER UPDATE ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_upd_pk AFTER UPDATE ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.pri..." +== 1106 +-- truncate_limit: 100 +CREATE TRIGGER trig_del_pk AFTER DELETE ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_del_pk AFTER DELETE ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.pri..." +== 1107 +-- truncate_limit: 100 +CREATE TRIGGER trig_ins_pk AFTER INSERT ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_ins_pk AFTER INSERT ON fkpart11.pk FOR EACH ROW EXECUTE FUNCTION fkpart11.pri..." +== 1108 +-- truncate_limit: 100 +CREATE CONSTRAINT TRIGGER trig_upd_fk_parted AFTER UPDATE ON fkpart11.fk_parted INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE CONSTRAINT TRIGGER trig_upd_fk_parted AFTER UPDATE ON fkpart11.fk_parted DEFERRABLE INITIA..." +== 1109 +-- truncate_limit: 100 +CREATE CONSTRAINT TRIGGER trig_del_fk_parted AFTER DELETE ON fkpart11.fk_parted INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE CONSTRAINT TRIGGER trig_del_fk_parted AFTER DELETE ON fkpart11.fk_parted DEFERRABLE INITIA..." +== 1110 +-- truncate_limit: 100 +CREATE CONSTRAINT TRIGGER trig_ins_fk_parted AFTER INSERT ON fkpart11.fk_parted INITIALLY DEFERRED FOR EACH ROW EXECUTE FUNCTION fkpart11.print_row() +-- +TABLE: name="fkpart11.fk_parted" schema="fkpart11" table="fk_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE CONSTRAINT TRIGGER trig_ins_fk_parted AFTER INSERT ON fkpart11.fk_parted DEFERRABLE INITIA..." +== 1111 +-- truncate_limit: 100 +UPDATE fkpart11.pk SET a = 3 WHERE a = 4 +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart11.pk SET a = 3 WHERE a = 4" +== 1112 +-- truncate_limit: 100 +UPDATE fkpart11.pk SET a = 1 WHERE a = 2 +-- +TABLE: name="fkpart11.pk" schema="fkpart11" table="pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart11.pk SET a = 1 WHERE a = 2" +== 1113 +-- truncate_limit: 100 +DROP SCHEMA fkpart11 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart11 CASCADE" +== 1114 +-- truncate_limit: 100 +-- When a table is attached as partition to a partitioned table that has +-- a foreign key to another partitioned table, it acquires a clone of the +-- FK. Upon detach, this clone is not removed, but instead becomes an +-- independent FK. If it then attaches to the partitioned table again, +-- the FK from the parent "takes over" ownership of the independent FK rather +-- than creating a separate one. +CREATE SCHEMA fkpart12 + CREATE TABLE fk_p ( id int, jd int, PRIMARY KEY(id, jd)) PARTITION BY list (id) + CREATE TABLE fk_p_1 PARTITION OF fk_p FOR VALUES IN (1) PARTITION BY list (jd) + CREATE TABLE fk_p_1_1 PARTITION OF fk_p_1 FOR VALUES IN (1) + CREATE TABLE fk_p_1_2 (x int, y int, jd int NOT NULL, id int NOT NULL) + CREATE TABLE fk_p_2 PARTITION OF fk_p FOR VALUES IN (2) PARTITION BY list (jd) + CREATE TABLE fk_p_2_1 PARTITION OF fk_p_2 FOR VALUES IN (1) + CREATE TABLE fk_p_2_2 PARTITION OF fk_p_2 FOR VALUES IN (2) + CREATE TABLE fk_r_1 ( p_jd int NOT NULL, x int, id int PRIMARY KEY, p_id int NOT NULL) + CREATE TABLE fk_r_2 ( id int PRIMARY KEY, p_id int NOT NULL, p_jd int NOT NULL) PARTITION BY list (id) + CREATE TABLE fk_r_2_1 PARTITION OF fk_r_2 FOR VALUES IN (2, 1) + CREATE TABLE fk_r ( id int PRIMARY KEY, p_id int NOT NULL, p_jd int NOT NULL, + FOREIGN KEY (p_id, p_jd) REFERENCES fk_p (id, jd) + ) PARTITION BY list (id) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart12 CREATE TABLE fk_p (id int, jd int, PRIMARY KEY (id, jd)) PARTITION BY LIST..." +== 1115 +-- truncate_limit: 100 +SET search_path TO fkpart12 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO fkpart12" +== 1116 +-- truncate_limit: 100 +ALTER TABLE fk_p_1_2 DROP COLUMN x, DROP COLUMN y +-- +TABLE: name="fk_p_1_2" schema="" table="fk_p_1_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_p_1_2 DROP x, DROP y" +== 1117 +-- truncate_limit: 100 +ALTER TABLE fk_p_1 ATTACH PARTITION fk_p_1_2 FOR VALUES IN (2) +-- +TABLE: name="fk_p_1" schema="" table="fk_p_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_p_1 ATTACH PARTITION fk_p_1_2 FOR VALUES IN (2)" +== 1118 +-- truncate_limit: 100 +ALTER TABLE fk_r_1 DROP COLUMN x +-- +TABLE: name="fk_r_1" schema="" table="fk_r_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r_1 DROP x" +== 1119 +-- truncate_limit: 100 +INSERT INTO fk_p VALUES (1, 1) +-- +TABLE: name="fk_p" schema="" table="fk_p" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_p VALUES (1, 1)" +== 1120 +-- truncate_limit: 100 +ALTER TABLE fk_r ATTACH PARTITION fk_r_1 FOR VALUES IN (1) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r ATTACH PARTITION fk_r_1 FOR VALUES IN (1)" +== 1121 +-- truncate_limit: 100 +ALTER TABLE fk_r ATTACH PARTITION fk_r_2 FOR VALUES IN (2) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r ATTACH PARTITION fk_r_2 FOR VALUES IN (2)" +== 1122 +-- truncate_limit: 100 +INSERT INTO fk_r VALUES (1, 1, 1) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_r VALUES (1, 1, 1)" +== 1123 +-- truncate_limit: 100 +INSERT INTO fk_r VALUES (2, 2, 1) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_r VALUES (2, 2, 1)" +== 1124 +-- truncate_limit: 100 +ALTER TABLE fk_r DETACH PARTITION fk_r_1 +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r DETACH PARTITION fk_r_1" +== 1125 +-- truncate_limit: 100 +ALTER TABLE fk_r DETACH PARTITION fk_r_2 +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r DETACH PARTITION fk_r_2" +== 1126 +-- truncate_limit: 100 +INSERT INTO fk_r_1 (id, p_id, p_jd) VALUES (2, 1, 2) +-- +TABLE: name="fk_r_1" schema="" table="fk_r_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fk_r_1 (id, p_id, p_jd) VALUES (2, 1, 2)" +== 1127 +-- truncate_limit: 100 +-- should fail +DELETE FROM fk_p +-- +TABLE: name="fk_p" schema="" table="fk_p" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_p" +== 1128 +-- truncate_limit: 100 +-- should fail + +ALTER TABLE fk_r ATTACH PARTITION fk_r_1 FOR VALUES IN (1) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r ATTACH PARTITION fk_r_1 FOR VALUES IN (1)" +== 1129 +-- truncate_limit: 100 +ALTER TABLE fk_r ATTACH PARTITION fk_r_2 FOR VALUES IN (2) +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r ATTACH PARTITION fk_r_2 FOR VALUES IN (2)" +== 1130 +-- truncate_limit: 100 +DELETE FROM fk_p +-- +TABLE: name="fk_p" schema="" table="fk_p" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM fk_p" +== 1131 +-- truncate_limit: 100 +-- should fail + +-- these should all fail +ALTER TABLE fk_r_1 DROP CONSTRAINT fk_r_p_id_p_jd_fkey +-- +TABLE: name="fk_r_1" schema="" table="fk_r_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r_1 DROP CONSTRAINT fk_r_p_id_p_jd_fkey" +== 1132 +-- truncate_limit: 100 +ALTER TABLE fk_r DROP CONSTRAINT fk_r_p_id_p_jd_fkey1 +-- +TABLE: name="fk_r" schema="" table="fk_r" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r DROP CONSTRAINT fk_r_p_id_p_jd_fkey1" +== 1133 +-- truncate_limit: 100 +ALTER TABLE fk_r_2 DROP CONSTRAINT fk_r_p_id_p_jd_fkey +-- +TABLE: name="fk_r_2" schema="" table="fk_r_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fk_r_2 DROP CONSTRAINT fk_r_p_id_p_jd_fkey" +== 1134 +-- truncate_limit: 100 +SET client_min_messages TO warning +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 1135 +-- truncate_limit: 100 +DROP SCHEMA fkpart12 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart12 CASCADE" +== 1136 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 1137 +-- truncate_limit: 100 +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 1138 +-- truncate_limit: 100 +-- Exercise the column mapping code with foreign keys. In this test we'll +-- create a partitioned table which has a partition with a dropped column and +-- check to ensure that an UPDATE cascades the changes correctly to the +-- partitioned table. +CREATE SCHEMA fkpart13 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA fkpart13" +== 1139 +-- truncate_limit: 100 +SET search_path TO fkpart13 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO fkpart13" +== 1140 +-- truncate_limit: 100 +CREATE TABLE fkpart13_t1 (a int PRIMARY KEY) +-- +TABLE: name="fkpart13_t1" schema="" table="fkpart13_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart13_t1 (a int PRIMARY KEY)" +== 1141 +-- truncate_limit: 100 +CREATE TABLE fkpart13_t2 ( + part_id int PRIMARY KEY, + column_to_drop int, + FOREIGN KEY (part_id) REFERENCES fkpart13_t1 ON UPDATE CASCADE ON DELETE CASCADE +) PARTITION BY LIST (part_id) +-- +TABLE: name="fkpart13_t2" schema="" table="fkpart13_t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart13_t2 (part_id int PRIMARY KEY, column_to_drop int, FOREIGN KEY (part_id) REFE..." +== 1142 +-- truncate_limit: 100 +CREATE TABLE fkpart13_t2_p1 PARTITION OF fkpart13_t2 FOR VALUES IN (1) +-- +TABLE: name="fkpart13_t2_p1" schema="" table="fkpart13_t2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart13_t2_p1 PARTITION OF fkpart13_t2 FOR VALUES IN (1)" +== 1143 +-- truncate_limit: 100 +-- drop the column +ALTER TABLE fkpart13_t2 DROP COLUMN column_to_drop +-- +TABLE: name="fkpart13_t2" schema="" table="fkpart13_t2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkpart13_t2 DROP column_to_drop" +== 1144 +-- truncate_limit: 100 +-- create a new partition without the dropped column +CREATE TABLE fkpart13_t2_p2 PARTITION OF fkpart13_t2 FOR VALUES IN (2) +-- +TABLE: name="fkpart13_t2_p2" schema="" table="fkpart13_t2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart13_t2_p2 PARTITION OF fkpart13_t2 FOR VALUES IN (2)" +== 1145 +-- truncate_limit: 100 +CREATE TABLE fkpart13_t3 ( + a int NOT NULL, + FOREIGN KEY (a) + REFERENCES fkpart13_t2 + ON UPDATE CASCADE ON DELETE CASCADE +) +-- +TABLE: name="fkpart13_t3" schema="" table="fkpart13_t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkpart13_t3 (a int NOT NULL, FOREIGN KEY (a) REFERENCES fkpart13_t2 ON UPDATE CASCAD..." +== 1146 +-- truncate_limit: 100 +INSERT INTO fkpart13_t1 (a) VALUES (1) +-- +TABLE: name="fkpart13_t1" schema="" table="fkpart13_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart13_t1 (a) VALUES (1)" +== 1147 +-- truncate_limit: 100 +INSERT INTO fkpart13_t2 (part_id) VALUES (1) +-- +TABLE: name="fkpart13_t2" schema="" table="fkpart13_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart13_t2 (part_id) VALUES (1)" +== 1148 +-- truncate_limit: 100 +INSERT INTO fkpart13_t3 (a) VALUES (1) +-- +TABLE: name="fkpart13_t3" schema="" table="fkpart13_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkpart13_t3 (a) VALUES (1)" +== 1149 +-- truncate_limit: 100 +-- Test a cascading update works correctly with with the dropped column +UPDATE fkpart13_t1 SET a = 2 WHERE a = 1 +-- +TABLE: name="fkpart13_t1" schema="" table="fkpart13_t1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE fkpart13_t1 SET a = 2 WHERE a = 1" +== 1150 +-- truncate_limit: 100 +SELECT tableoid::regclass,* FROM fkpart13_t2 +-- +TABLE: name="fkpart13_t2" schema="" table="fkpart13_t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM fkpart13_t2" +== 1151 +-- truncate_limit: 100 +SELECT tableoid::regclass,* FROM fkpart13_t3 +-- +TABLE: name="fkpart13_t3" schema="" table="fkpart13_t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM fkpart13_t3" +== 1152 +-- truncate_limit: 100 +-- Exercise code in ExecGetTriggerResultRel() as there's been previous issues +-- with ResultRelInfos being returned with the incorrect ri_RootResultRelInfo +WITH cte AS ( + UPDATE fkpart13_t2_p1 SET part_id = part_id +) UPDATE fkpart13_t1 SET a = 2 WHERE a = 1 +-- +TABLE: name="fkpart13_t1" schema="" table="fkpart13_t1" ctx=DML +TABLE: name="fkpart13_t2_p1" schema="" table="fkpart13_t2_p1" ctx=DML +CTE: "cte" +STMT: UpdateStmt +TRUNCATED: "WITH cte AS (UPDATE fkpart13_t2_p1 SET part_id = part_id) UPDATE fkpart13_t1 SET a = 2 WHERE a = 1" +== 1153 +-- truncate_limit: 100 +DROP SCHEMA fkpart13 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA fkpart13 CASCADE" +== 1154 +-- truncate_limit: 100 +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" diff --git a/parser/testdata/summary_truncate/postgres_regress/functional_deps.metadata.json b/parser/testdata/summary_truncate/postgres_regress/functional_deps.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/functional_deps.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/functional_deps.test b/parser/testdata/summary_truncate/postgres_regress/functional_deps.test new file mode 100644 index 0000000..e0be077 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/functional_deps.test @@ -0,0 +1,475 @@ +== 001 +-- truncate_limit: 100 +-- from http://www.depesz.com/index.php/2010/04/19/getting-unique-elements/ + +CREATE TEMP TABLE articles ( + id int CONSTRAINT articles_pkey PRIMARY KEY, + keywords text, + title text UNIQUE NOT NULL, + body text UNIQUE, + created date +) +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE articles (id int CONSTRAINT articles_pkey PRIMARY KEY, keywords text, titl..." +== 002 +-- truncate_limit: 100 +CREATE TEMP TABLE articles_in_category ( + article_id int, + category_id int, + changed date, + PRIMARY KEY (article_id, category_id) +) +-- +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE articles_in_category (article_id int, category_id int, changed date, PRIMA..." +== 003 +-- truncate_limit: 100 +-- test functional dependencies based on primary keys/unique constraints + +-- base tables + +-- group by primary key (OK) +SELECT id, keywords, title, body, created +FROM articles +GROUP BY id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id, keywords, title, body, created FROM articles GROUP BY id" +== 004 +-- truncate_limit: 100 +-- group by unique not null (fail/todo) +SELECT id, keywords, title, body, created +FROM articles +GROUP BY title +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id, keywords, title, body, created FROM articles GROUP BY title" +== 005 +-- truncate_limit: 100 +-- group by unique nullable (fail) +SELECT id, keywords, title, body, created +FROM articles +GROUP BY body +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id, keywords, title, body, created FROM articles GROUP BY body" +== 006 +-- truncate_limit: 100 +-- group by something else (fail) +SELECT id, keywords, title, body, created +FROM articles +GROUP BY keywords +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id, keywords, title, body, created FROM articles GROUP BY keywords" +== 007 +-- truncate_limit: 100 +-- multiple tables + +-- group by primary key (OK) +SELECT a.id, a.keywords, a.title, a.body, a.created +FROM articles AS a, articles_in_category AS aic +WHERE a.id = aic.article_id AND aic.category_id in (14,62,70,53,138) +GROUP BY a.id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="aic" column="article_id" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM articles a, articles_in_category aic WHERE ... GROUP BY a.id" +== 008 +-- truncate_limit: 100 +-- group by something else (fail) +SELECT a.id, a.keywords, a.title, a.body, a.created +FROM articles AS a, articles_in_category AS aic +WHERE a.id = aic.article_id AND aic.category_id in (14,62,70,53,138) +GROUP BY aic.article_id, aic.category_id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="aic" column="article_id" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM articles a, articles_in_category aic WHERE ... GROUP BY aic.article_id, aic.categ..." +== 009 +-- truncate_limit: 100 +-- JOIN syntax + +-- group by left table's primary key (OK) +SELECT a.id, a.keywords, a.title, a.body, a.created +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY a.id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM articles a JOIN articles_in_category aic ON a.id = aic.article_id WHERE ... GROUP..." +== 010 +-- truncate_limit: 100 +-- group by something else (fail) +SELECT a.id, a.keywords, a.title, a.body, a.created +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY aic.article_id, aic.category_id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM articles a JOIN articles_in_category aic ON a.id = aic.article_id WHERE ... GROUP..." +== 011 +-- truncate_limit: 100 +-- group by right table's (composite) primary key (OK) +SELECT aic.changed +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY aic.category_id, aic.article_id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM articles a JOIN articles_in_category aic ON a.id = aic.article_id WHERE ... GROUP..." +== 012 +-- truncate_limit: 100 +-- group by right table's partial primary key (fail) +SELECT aic.changed +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY aic.article_id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM articles a JOIN articles_in_category aic ON a.id = aic.article_id WHERE ... GROUP..." +== 013 +-- truncate_limit: 100 +-- example from documentation + +CREATE TEMP TABLE products (product_id int, name text, price numeric) +-- +TABLE: name="products" schema="" table="products" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE products (product_id int, name text, price numeric)" +== 014 +-- truncate_limit: 100 +CREATE TEMP TABLE sales (product_id int, units int) +-- +TABLE: name="sales" schema="" table="sales" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE sales (product_id int, units int)" +== 015 +-- truncate_limit: 100 +-- OK +SELECT product_id, p.name, (sum(s.units) * p.price) AS sales + FROM products p LEFT JOIN sales s USING (product_id) + GROUP BY product_id, p.name, p.price +-- +TABLE: name="products" schema="" table="products" ctx=Select +TABLE: name="sales" schema="" table="sales" ctx=Select +ALIAS: "p"="products" +ALIAS: "s"="sales" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM products p LEFT JOIN sales s USING (product_id) GROUP BY product_id, p.name, p.price" +== 016 +-- truncate_limit: 100 +-- fail +SELECT product_id, p.name, (sum(s.units) * p.price) AS sales + FROM products p LEFT JOIN sales s USING (product_id) + GROUP BY product_id +-- +TABLE: name="products" schema="" table="products" ctx=Select +TABLE: name="sales" schema="" table="sales" ctx=Select +ALIAS: "p"="products" +ALIAS: "s"="sales" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM products p LEFT JOIN sales s USING (product_id) GROUP BY product_id" +== 017 +-- truncate_limit: 100 +ALTER TABLE products ADD PRIMARY KEY (product_id) +-- +TABLE: name="products" schema="" table="products" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE products ADD PRIMARY KEY (product_id)" +== 018 +-- truncate_limit: 100 +-- OK now +SELECT product_id, p.name, (sum(s.units) * p.price) AS sales + FROM products p LEFT JOIN sales s USING (product_id) + GROUP BY product_id +-- +TABLE: name="products" schema="" table="products" ctx=Select +TABLE: name="sales" schema="" table="sales" ctx=Select +ALIAS: "p"="products" +ALIAS: "s"="sales" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM products p LEFT JOIN sales s USING (product_id) GROUP BY product_id" +== 019 +-- truncate_limit: 100 +-- Drupal example, http://drupal.org/node/555530 + +CREATE TEMP TABLE node ( + nid SERIAL, + vid integer NOT NULL default '0', + type varchar(32) NOT NULL default '', + title varchar(128) NOT NULL default '', + uid integer NOT NULL default '0', + status integer NOT NULL default '1', + created integer NOT NULL default '0', + -- snip + PRIMARY KEY (nid, vid) +) +-- +TABLE: name="node" schema="" table="node" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE node (nid serial, vid int NOT NULL DEFAULT '0', type varchar(32) NOT NULL ..." +== 020 +-- truncate_limit: 100 +CREATE TEMP TABLE users ( + uid integer NOT NULL default '0', + name varchar(60) NOT NULL default '', + pass varchar(32) NOT NULL default '', + -- snip + PRIMARY KEY (uid), + UNIQUE (name) +) +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE users (uid int NOT NULL DEFAULT '0', name varchar(60) NOT NULL DEFAULT '',..." +== 021 +-- truncate_limit: 100 +-- OK +SELECT u.uid, u.name FROM node n +INNER JOIN users u ON u.uid = n.uid +WHERE n.type = 'blog' AND n.status = 1 +GROUP BY u.uid, u.name +-- +TABLE: name="node" schema="" table="node" ctx=Select +TABLE: name="users" schema="" table="users" ctx=Select +ALIAS: "n"="node" +ALIAS: "u"="users" +FILTER: schema="" table="n" column="type" +FILTER: schema="" table="n" column="status" +STMT: SelectStmt +TRUNCATED: "SELECT u.uid, u.name FROM node n JOIN users u ON u.uid = n.uid WHERE ... GROUP BY u.uid, u.name" +== 022 +-- truncate_limit: 100 +-- OK +SELECT u.uid, u.name FROM node n +INNER JOIN users u ON u.uid = n.uid +WHERE n.type = 'blog' AND n.status = 1 +GROUP BY u.uid +-- +TABLE: name="node" schema="" table="node" ctx=Select +TABLE: name="users" schema="" table="users" ctx=Select +ALIAS: "n"="node" +ALIAS: "u"="users" +FILTER: schema="" table="n" column="type" +FILTER: schema="" table="n" column="status" +STMT: SelectStmt +TRUNCATED: "SELECT u.uid, u.name FROM node n JOIN users u ON u.uid = n.uid WHERE ... GROUP BY u.uid" +== 023 +-- truncate_limit: 100 +-- Check views and dependencies + +-- fail +CREATE TEMP VIEW fdv1 AS +SELECT id, keywords, title, body, created +FROM articles +GROUP BY body +-- +TABLE: name="fdv1" schema="" table="fdv1" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW fdv1 AS SELECT id, keywords, title, body, created FROM articles GROUP BY body" +== 024 +-- truncate_limit: 100 +-- OK +CREATE TEMP VIEW fdv1 AS +SELECT id, keywords, title, body, created +FROM articles +GROUP BY id +-- +TABLE: name="fdv1" schema="" table="fdv1" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW fdv1 AS SELECT id, keywords, title, body, created FROM articles GROUP BY id" +== 025 +-- truncate_limit: 100 +-- fail +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE articles DROP CONSTRAINT articles_pkey" +== 026 +-- truncate_limit: 100 +DROP VIEW fdv1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW fdv1" +== 027 +-- truncate_limit: 100 +-- multiple dependencies +CREATE TEMP VIEW fdv2 AS +SELECT a.id, a.keywords, a.title, aic.category_id, aic.changed +FROM articles AS a JOIN articles_in_category AS aic ON a.id = aic.article_id +WHERE aic.category_id in (14,62,70,53,138) +GROUP BY a.id, aic.category_id, aic.article_id +-- +TABLE: name="fdv2" schema="" table="fdv2" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=Select +ALIAS: "a"="articles" +ALIAS: "aic"="articles_in_category" +FILTER: schema="" table="aic" column="category_id" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW fdv2 AS SELECT a.id, a.keywords, a.title, aic.category_id, aic.changed FROM..." +== 028 +-- truncate_limit: 100 +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE articles DROP CONSTRAINT articles_pkey" +== 029 +-- truncate_limit: 100 +-- fail +ALTER TABLE articles_in_category DROP CONSTRAINT articles_in_category_pkey RESTRICT +-- +TABLE: name="articles_in_category" schema="" table="articles_in_category" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE articles_in_category DROP CONSTRAINT articles_in_category_pkey" +== 030 +-- truncate_limit: 100 +--fail + +DROP VIEW fdv2 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW fdv2" +== 031 +-- truncate_limit: 100 +-- nested queries + +CREATE TEMP VIEW fdv3 AS +SELECT id, keywords, title, body, created +FROM articles +GROUP BY id +UNION +SELECT id, keywords, title, body, created +FROM articles +GROUP BY id +-- +TABLE: name="fdv3" schema="" table="fdv3" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW fdv3 AS SELECT id, keywords, title, body, created FROM articles GROUP BY id..." +== 032 +-- truncate_limit: 100 +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE articles DROP CONSTRAINT articles_pkey" +== 033 +-- truncate_limit: 100 +-- fail + +DROP VIEW fdv3 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW fdv3" +== 034 +-- truncate_limit: 100 +CREATE TEMP VIEW fdv4 AS +SELECT * FROM articles WHERE title IN (SELECT title FROM articles GROUP BY id) +-- +TABLE: name="fdv4" schema="" table="fdv4" ctx=DDL +TABLE: name="articles" schema="" table="articles" ctx=Select +TABLE: name="articles" schema="" table="articles" ctx=Select +FILTER: schema="" table="" column="title" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW fdv4 AS SELECT * FROM articles WHERE title IN (SELECT title FROM articles G..." +== 035 +-- truncate_limit: 100 +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE articles DROP CONSTRAINT articles_pkey" +== 036 +-- truncate_limit: 100 +-- fail + +DROP VIEW fdv4 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW fdv4" +== 037 +-- truncate_limit: 100 +-- prepared query plans: this results in failure on reuse + +PREPARE foo AS + SELECT id, keywords, title, body, created + FROM articles + GROUP BY id +-- +TABLE: name="articles" schema="" table="articles" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE foo AS SELECT id, keywords, title, body, created FROM articles GROUP BY id" +== 038 +-- truncate_limit: 100 +EXECUTE foo +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foo" +== 039 +-- truncate_limit: 100 +ALTER TABLE articles DROP CONSTRAINT articles_pkey RESTRICT +-- +TABLE: name="articles" schema="" table="articles" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE articles DROP CONSTRAINT articles_pkey" +== 040 +-- truncate_limit: 100 +EXECUTE foo +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foo" diff --git a/parser/testdata/summary_truncate/postgres_regress/generated.metadata.json b/parser/testdata/summary_truncate/postgres_regress/generated.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/generated.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/generated.test b/parser/testdata/summary_truncate/postgres_regress/generated.test new file mode 100644 index 0000000..d389a23 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/generated.test @@ -0,0 +1,936 @@ +== 001 +-- truncate_limit: 100 +-- sanity check of system catalog +SELECT attrelid, attname, attgenerated FROM pg_attribute WHERE attgenerated NOT IN ('', 's') +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attgenerated" +STMT: SelectStmt +TRUNCATED: "SELECT attrelid, attname, attgenerated FROM pg_attribute WHERE attgenerated NOT IN ('', 's')" +== 002 +-- truncate_limit: 100 +CREATE TABLE gtest0 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (55) STORED) +-- +TABLE: name="gtest0" schema="" table="gtest0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest0 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (55) STORED)" +== 003 +-- truncate_limit: 100 +CREATE TABLE gtest1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED)" +== 004 +-- truncate_limit: 100 +SELECT table_name, column_name, column_default, is_nullable, is_generated, generation_expression FROM information_schema.columns WHERE table_name LIKE 'gtest_' ORDER BY 1, 2 +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name LIKE 'gtest_' ORDER BY 1, 2" +== 005 +-- truncate_limit: 100 +SELECT table_name, column_name, dependent_column FROM information_schema.column_column_usage ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.column_column_usage" schema="information_schema" table="column_column_usage" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.column_column_usage ORDER BY 1, 2, 3" +== 006 +-- truncate_limit: 100 +-- duplicate generated +CREATE TABLE gtest_err_1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED GENERATED ALWAYS AS (a * 3) STORED) +-- +TABLE: name="gtest_err_1" schema="" table="gtest_err_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_1 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED GENERATED A..." +== 007 +-- truncate_limit: 100 +-- references to other generated columns, including self-references +CREATE TABLE gtest_err_2a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (b * 2) STORED) +-- +TABLE: name="gtest_err_2a" schema="" table="gtest_err_2a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_2a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (b * 2) STORED)" +== 008 +-- truncate_limit: 100 +CREATE TABLE gtest_err_2b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED, c int GENERATED ALWAYS AS (b * 3) STORED) +-- +TABLE: name="gtest_err_2b" schema="" table="gtest_err_2b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_2b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) STORED, c int GEN..." +== 009 +-- truncate_limit: 100 +-- a whole-row var is a self-reference on steroids, so disallow that too +CREATE TABLE gtest_err_2c (a int PRIMARY KEY, + b int GENERATED ALWAYS AS (num_nulls(gtest_err_2c)) STORED) +-- +TABLE: name="gtest_err_2c" schema="" table="gtest_err_2c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_2c (a int PRIMARY KEY, b int GENERATED ALWAYS AS (num_nulls(gtest_err_2c))..." +== 010 +-- truncate_limit: 100 +-- invalid reference +CREATE TABLE gtest_err_3 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (c * 2) STORED) +-- +TABLE: name="gtest_err_3" schema="" table="gtest_err_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_3 (a int PRIMARY KEY, b int GENERATED ALWAYS AS (c * 2) STORED)" +== 011 +-- truncate_limit: 100 +-- generation expression must be immutable +CREATE TABLE gtest_err_4 (a int PRIMARY KEY, b double precision GENERATED ALWAYS AS (random()) STORED) +-- +TABLE: name="gtest_err_4" schema="" table="gtest_err_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_4 (a int PRIMARY KEY, b double precision GENERATED ALWAYS AS (random()) ST..." +== 012 +-- truncate_limit: 100 +-- ... but be sure that the immutability test is accurate +CREATE TABLE gtest2 (a int, b text GENERATED ALWAYS AS (a || ' sec') STORED) +-- +TABLE: name="gtest2" schema="" table="gtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest2 (a int, b text GENERATED ALWAYS AS (a || ' sec') STORED)" +== 013 +-- truncate_limit: 100 +DROP TABLE gtest2 +-- +TABLE: name="gtest2" schema="" table="gtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gtest2" +== 014 +-- truncate_limit: 100 +-- cannot have default/identity and generated +CREATE TABLE gtest_err_5a (a int PRIMARY KEY, b int DEFAULT 5 GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtest_err_5a" schema="" table="gtest_err_5a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_5a (a int PRIMARY KEY, b int DEFAULT 5 GENERATED ALWAYS AS (a * 2) STORED)" +== 015 +-- truncate_limit: 100 +CREATE TABLE gtest_err_5b (a int PRIMARY KEY, b int GENERATED ALWAYS AS identity GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtest_err_5b" schema="" table="gtest_err_5b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_5b (a int PRIMARY KEY, b int GENERATED ALWAYS AS IDENTITY GENERATED ALWAYS..." +== 016 +-- truncate_limit: 100 +-- reference to system column not allowed in generated column +-- (except tableoid, which we test below) +CREATE TABLE gtest_err_6a (a int PRIMARY KEY, b bool GENERATED ALWAYS AS (xmin <> 37) STORED) +-- +TABLE: name="gtest_err_6a" schema="" table="gtest_err_6a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_6a (a int PRIMARY KEY, b bool GENERATED ALWAYS AS (xmin <> 37) STORED)" +== 017 +-- truncate_limit: 100 +-- various prohibited constructs +CREATE TABLE gtest_err_7a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (avg(a)) STORED) +-- +TABLE: name="gtest_err_7a" schema="" table="gtest_err_7a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_7a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (avg(a)) STORED)" +== 018 +-- truncate_limit: 100 +CREATE TABLE gtest_err_7b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (row_number() OVER (ORDER BY a)) STORED) +-- +TABLE: name="gtest_err_7b" schema="" table="gtest_err_7b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_7b (a int PRIMARY KEY, b int GENERATED ALWAYS AS (row_number() OVER (ORDER..." +== 019 +-- truncate_limit: 100 +CREATE TABLE gtest_err_7c (a int PRIMARY KEY, b int GENERATED ALWAYS AS ((SELECT a)) STORED) +-- +TABLE: name="gtest_err_7c" schema="" table="gtest_err_7c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_7c (a int PRIMARY KEY, b int GENERATED ALWAYS AS ((SELECT a)) STORED)" +== 020 +-- truncate_limit: 100 +CREATE TABLE gtest_err_7d (a int PRIMARY KEY, b int GENERATED ALWAYS AS (generate_series(1, a)) STORED) +-- +TABLE: name="gtest_err_7d" schema="" table="gtest_err_7d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_err_7d (a int PRIMARY KEY, b int GENERATED ALWAYS AS (generate_series(1, a)) S..." +== 021 +-- truncate_limit: 100 +-- GENERATED BY DEFAULT not allowed +CREATE TABLE gtest_err_8 (a int PRIMARY KEY, b int GENERATED BY DEFAULT AS (a * 2) STORED) +-- +ERROR: for a generated column, GENERATED ALWAYS must be specified +CURSORPOS: 98 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 022 +-- truncate_limit: 100 +INSERT INTO gtest1 VALUES (1) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 VALUES (1)" +== 023 +-- truncate_limit: 100 +INSERT INTO gtest1 VALUES (2, DEFAULT) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 VALUES (2, DEFAULT)" +== 024 +-- truncate_limit: 100 +-- ok +INSERT INTO gtest1 VALUES (3, 33) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 VALUES (3, 33)" +== 025 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1 VALUES (3, 33), (4, 44) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 VALUES (3, 33), (4, 44)" +== 026 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1 VALUES (3, DEFAULT), (4, 44) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 VALUES (3, DEFAULT), (4, 44)" +== 027 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1 VALUES (3, 33), (4, DEFAULT) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 VALUES (3, 33), (4, DEFAULT)" +== 028 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1 VALUES (3, DEFAULT), (4, DEFAULT) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 VALUES (3, DEFAULT), (4, DEFAULT)" +== 029 +-- truncate_limit: 100 +-- ok + +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1 ORDER BY a" +== 030 +-- truncate_limit: 100 +DELETE FROM gtest1 WHERE a >= 3 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM gtest1 WHERE a >= 3" +== 031 +-- truncate_limit: 100 +UPDATE gtest1 SET b = DEFAULT WHERE a = 1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE gtest1 SET b = DEFAULT WHERE a = 1" +== 032 +-- truncate_limit: 100 +UPDATE gtest1 SET b = 11 WHERE a = 1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE gtest1 SET b = 11 WHERE a = 1" +== 033 +-- truncate_limit: 100 +-- error + +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1 ORDER BY a" +== 034 +-- truncate_limit: 100 +SELECT a, b, b * 2 AS b2 FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, b * 2 AS b2 FROM gtest1 ORDER BY a" +== 035 +-- truncate_limit: 100 +SELECT a, b FROM gtest1 WHERE b = 4 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM gtest1 WHERE b = 4 ORDER BY a" +== 036 +-- truncate_limit: 100 +-- test that overflow error happens on write +INSERT INTO gtest1 VALUES (2000000000) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 VALUES (2000000000)" +== 037 +-- truncate_limit: 100 +SELECT * FROM gtest1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1" +== 038 +-- truncate_limit: 100 +DELETE FROM gtest1 WHERE a = 2000000000 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM gtest1 WHERE a = 2000000000" +== 039 +-- truncate_limit: 100 +-- test with joins +CREATE TABLE gtestx (x int, y int) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestx (x int, y int)" +== 040 +-- truncate_limit: 100 +INSERT INTO gtestx VALUES (11, 1), (22, 2), (33, 3) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtestx VALUES (11, 1), (22, 2), (33, 3)" +== 041 +-- truncate_limit: 100 +SELECT * FROM gtestx, gtest1 WHERE gtestx.y = gtest1.a +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=Select +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +FILTER: schema="" table="gtestx" column="y" +FILTER: schema="" table="gtest1" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtestx, gtest1 WHERE gtestx.y = gtest1.a" +== 042 +-- truncate_limit: 100 +DROP TABLE gtestx +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gtestx" +== 043 +-- truncate_limit: 100 +-- test UPDATE/DELETE quals +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1 ORDER BY a" +== 044 +-- truncate_limit: 100 +UPDATE gtest1 SET a = 3 WHERE b = 4 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE gtest1 SET a = 3 WHERE b = 4" +== 045 +-- truncate_limit: 100 +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1 ORDER BY a" +== 046 +-- truncate_limit: 100 +DELETE FROM gtest1 WHERE b = 2 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM gtest1 WHERE b = 2" +== 047 +-- truncate_limit: 100 +SELECT * FROM gtest1 ORDER BY a +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1 ORDER BY a" +== 048 +-- truncate_limit: 100 +-- test MERGE +CREATE TABLE gtestm ( + id int PRIMARY KEY, + f1 int, + f2 int, + f3 int GENERATED ALWAYS AS (f1 * 2) STORED, + f4 int GENERATED ALWAYS AS (f2 * 2) STORED +) +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestm (id int PRIMARY KEY, f1 int, f2 int, f3 int GENERATED ALWAYS AS (f1 * 2) STOR..." +== 049 +-- truncate_limit: 100 +INSERT INTO gtestm VALUES (1, 5, 100) +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtestm VALUES (1, 5, 100)" +== 050 +-- truncate_limit: 100 +MERGE INTO gtestm t USING (VALUES (1, 10), (2, 20)) v(id, f1) ON t.id = v.id + WHEN MATCHED THEN UPDATE SET f1 = v.f1 + WHEN NOT MATCHED THEN INSERT VALUES (v.id, v.f1, 200) +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=DML +ALIAS: "t"="gtestm" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO gtestm t USING (VALUES (...)) v(id, f1) ON t.id = v.id WHEN MATCHED THEN UPDATE SET f1..." +== 051 +-- truncate_limit: 100 +SELECT * FROM gtestm ORDER BY id +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtestm ORDER BY id" +== 052 +-- truncate_limit: 100 +DROP TABLE gtestm +-- +TABLE: name="gtestm" schema="" table="gtestm" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gtestm" +== 053 +-- truncate_limit: 100 +-- views +CREATE VIEW gtest1v AS SELECT * FROM gtest1 +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DDL +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW gtest1v AS SELECT * FROM gtest1" +== 054 +-- truncate_limit: 100 +SELECT * FROM gtest1v +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1v" +== 055 +-- truncate_limit: 100 +INSERT INTO gtest1v VALUES (4, 8) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1v VALUES (4, 8)" +== 056 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1v VALUES (5, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1v VALUES (5, DEFAULT)" +== 057 +-- truncate_limit: 100 +-- ok +INSERT INTO gtest1v VALUES (6, 66), (7, 77) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1v VALUES (6, 66), (7, 77)" +== 058 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1v VALUES (6, DEFAULT), (7, 77) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1v VALUES (6, DEFAULT), (7, 77)" +== 059 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1v VALUES (6, 66), (7, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1v VALUES (6, 66), (7, DEFAULT)" +== 060 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1v VALUES (6, DEFAULT), (7, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1v VALUES (6, DEFAULT), (7, DEFAULT)" +== 061 +-- truncate_limit: 100 +-- ok + +ALTER VIEW gtest1v ALTER COLUMN b SET DEFAULT 100 +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW gtest1v ALTER COLUMN b SET DEFAULT 100" +== 062 +-- truncate_limit: 100 +INSERT INTO gtest1v VALUES (8, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1v VALUES (8, DEFAULT)" +== 063 +-- truncate_limit: 100 +-- error +INSERT INTO gtest1v VALUES (8, DEFAULT), (9, DEFAULT) +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1v VALUES (8, DEFAULT), (9, DEFAULT)" +== 064 +-- truncate_limit: 100 +-- error + +SELECT * FROM gtest1v +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1v" +== 065 +-- truncate_limit: 100 +DELETE FROM gtest1v WHERE a >= 5 +-- +TABLE: name="gtest1v" schema="" table="gtest1v" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM gtest1v WHERE a >= 5" +== 066 +-- truncate_limit: 100 +DROP VIEW gtest1v +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW gtest1v" +== 067 +-- truncate_limit: 100 +-- CTEs +WITH foo AS (SELECT * FROM gtest1) SELECT * FROM foo +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +CTE: "foo" +STMT: SelectStmt +TRUNCATED: "WITH foo AS (SELECT * FROM gtest1) SELECT * FROM foo" +== 068 +-- truncate_limit: 100 +-- inheritance +CREATE TABLE gtest1_1 () INHERITS (gtest1) +-- +TABLE: name="gtest1_1" schema="" table="gtest1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest1_1 () INHERITS (gtest1)" +== 069 +-- truncate_limit: 100 +SELECT * FROM gtest1_1 +-- +TABLE: name="gtest1_1" schema="" table="gtest1_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1_1" +== 070 +-- truncate_limit: 100 +INSERT INTO gtest1_1 VALUES (4) +-- +TABLE: name="gtest1_1" schema="" table="gtest1_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1_1 VALUES (4)" +== 071 +-- truncate_limit: 100 +SELECT * FROM gtest1_1 +-- +TABLE: name="gtest1_1" schema="" table="gtest1_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1_1" +== 072 +-- truncate_limit: 100 +SELECT * FROM gtest1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest1" +== 073 +-- truncate_limit: 100 +-- can't have generated column that is a child of normal column +CREATE TABLE gtest_normal (a int, b int) +-- +TABLE: name="gtest_normal" schema="" table="gtest_normal" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_normal (a int, b int)" +== 074 +-- truncate_limit: 100 +CREATE TABLE gtest_normal_child (a int, b int GENERATED ALWAYS AS (a * 2) STORED) INHERITS (gtest_normal) +-- +TABLE: name="gtest_normal_child" schema="" table="gtest_normal_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_normal_child (a int, b int GENERATED ALWAYS AS (a * 2) STORED) INHERITS (gtest..." +== 075 +-- truncate_limit: 100 +-- error +CREATE TABLE gtest_normal_child (a int, b int GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtest_normal_child" schema="" table="gtest_normal_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest_normal_child (a int, b int GENERATED ALWAYS AS (a * 2) STORED)" +== 076 +-- truncate_limit: 100 +ALTER TABLE gtest_normal_child INHERIT gtest_normal +-- +TABLE: name="gtest_normal_child" schema="" table="gtest_normal_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE gtest_normal_child INHERIT gtest_normal" +== 077 +-- truncate_limit: 100 +-- error +DROP TABLE gtest_normal, gtest_normal_child +-- +TABLE: name="gtest_normal" schema="" table="gtest_normal" ctx=DDL +TABLE: name="gtest_normal_child" schema="" table="gtest_normal_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gtest_normal, gtest_normal_child" +== 078 +-- truncate_limit: 100 +-- test inheritance mismatches between parent and child +CREATE TABLE gtestx (x int, b int DEFAULT 10) INHERITS (gtest1) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestx (x int, b int DEFAULT 10) INHERITS (gtest1)" +== 079 +-- truncate_limit: 100 +-- error +CREATE TABLE gtestx (x int, b int GENERATED ALWAYS AS IDENTITY) INHERITS (gtest1) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestx (x int, b int GENERATED ALWAYS AS IDENTITY) INHERITS (gtest1)" +== 080 +-- truncate_limit: 100 +-- error +CREATE TABLE gtestx (x int, b int GENERATED ALWAYS AS (a * 22) STORED) INHERITS (gtest1) +-- +TABLE: name="gtestx" schema="" table="gtestx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestx (x int, b int GENERATED ALWAYS AS (a * 22) STORED) INHERITS (gtest1)" +== 081 +-- truncate_limit: 100 +-- ok, overrides parent + +CREATE TABLE gtestxx_1 (a int NOT NULL, b int) +-- +TABLE: name="gtestxx_1" schema="" table="gtestxx_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestxx_1 (a int NOT NULL, b int)" +== 082 +-- truncate_limit: 100 +ALTER TABLE gtestxx_1 INHERIT gtest1 +-- +TABLE: name="gtestxx_1" schema="" table="gtestxx_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE gtestxx_1 INHERIT gtest1" +== 083 +-- truncate_limit: 100 +-- error +CREATE TABLE gtestxx_3 (a int NOT NULL, b int GENERATED ALWAYS AS (a * 2) STORED) +-- +TABLE: name="gtestxx_3" schema="" table="gtestxx_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestxx_3 (a int NOT NULL, b int GENERATED ALWAYS AS (a * 2) STORED)" +== 084 +-- truncate_limit: 100 +ALTER TABLE gtestxx_3 INHERIT gtest1 +-- +TABLE: name="gtestxx_3" schema="" table="gtestxx_3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE gtestxx_3 INHERIT gtest1" +== 085 +-- truncate_limit: 100 +-- ok +CREATE TABLE gtestxx_4 (b int GENERATED ALWAYS AS (a * 2) STORED, a int NOT NULL) +-- +TABLE: name="gtestxx_4" schema="" table="gtestxx_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestxx_4 (b int GENERATED ALWAYS AS (a * 2) STORED, a int NOT NULL)" +== 086 +-- truncate_limit: 100 +ALTER TABLE gtestxx_4 INHERIT gtest1 +-- +TABLE: name="gtestxx_4" schema="" table="gtestxx_4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE gtestxx_4 INHERIT gtest1" +== 087 +-- truncate_limit: 100 +-- ok + +-- test multiple inheritance mismatches +CREATE TABLE gtesty (x int, b int DEFAULT 55) +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtesty (x int, b int DEFAULT 55)" +== 088 +-- truncate_limit: 100 +CREATE TABLE gtest1_y () INHERITS (gtest0, gtesty) +-- +TABLE: name="gtest1_y" schema="" table="gtest1_y" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest1_y () INHERITS (gtest0, gtesty)" +== 089 +-- truncate_limit: 100 +-- error +DROP TABLE gtesty +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gtesty" +== 090 +-- truncate_limit: 100 +CREATE TABLE gtesty (x int, b int) +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtesty (x int, b int)" +== 091 +-- truncate_limit: 100 +CREATE TABLE gtest1_y () INHERITS (gtest1, gtesty) +-- +TABLE: name="gtest1_y" schema="" table="gtest1_y" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest1_y () INHERITS (gtest1, gtesty)" +== 092 +-- truncate_limit: 100 +-- error +DROP TABLE gtesty +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gtesty" +== 093 +-- truncate_limit: 100 +CREATE TABLE gtesty (x int, b int GENERATED ALWAYS AS (x * 22) STORED) +-- +TABLE: name="gtesty" schema="" table="gtesty" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtesty (x int, b int GENERATED ALWAYS AS (x * 22) STORED)" +== 094 +-- truncate_limit: 100 +CREATE TABLE gtest1_y () INHERITS (gtest1, gtesty) +-- +TABLE: name="gtest1_y" schema="" table="gtest1_y" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest1_y () INHERITS (gtest1, gtesty)" +== 095 +-- truncate_limit: 100 +-- error +CREATE TABLE gtest1_y (b int GENERATED ALWAYS AS (x + 1) STORED) INHERITS (gtest1, gtesty) +-- +TABLE: name="gtest1_y" schema="" table="gtest1_y" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest1_y (b int GENERATED ALWAYS AS (x + 1) STORED) INHERITS (gtest1, gtesty)" +== 096 +-- truncate_limit: 100 +-- ok + +-- test correct handling of GENERATED column that's only in child +CREATE TABLE gtestp (f1 int) +-- +TABLE: name="gtestp" schema="" table="gtestp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestp (f1 int)" +== 097 +-- truncate_limit: 100 +CREATE TABLE gtestc (f2 int GENERATED ALWAYS AS (f1+1) STORED) INHERITS(gtestp) +-- +TABLE: name="gtestc" schema="" table="gtestc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtestc (f2 int GENERATED ALWAYS AS (f1 + 1) STORED) INHERITS (gtestp)" +== 098 +-- truncate_limit: 100 +INSERT INTO gtestc values(42) +-- +TABLE: name="gtestc" schema="" table="gtestc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtestc VALUES (42)" +== 099 +-- truncate_limit: 100 +TABLE gtestc +-- +TABLE: name="gtestc" schema="" table="gtestc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtestc" +== 100 +-- truncate_limit: 100 +UPDATE gtestp SET f1 = f1 * 10 +-- +TABLE: name="gtestp" schema="" table="gtestp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE gtestp SET f1 = f1 * 10" +== 101 +-- truncate_limit: 100 +TABLE gtestc +-- +TABLE: name="gtestc" schema="" table="gtestc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtestc" +== 102 +-- truncate_limit: 100 +DROP TABLE gtestp CASCADE +-- +TABLE: name="gtestp" schema="" table="gtestp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gtestp CASCADE" +== 103 +-- truncate_limit: 100 +-- test stored update +CREATE TABLE gtest3 (a int, b int GENERATED ALWAYS AS (a * 3) STORED) +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest3 (a int, b int GENERATED ALWAYS AS (a * 3) STORED)" +== 104 +-- truncate_limit: 100 +INSERT INTO gtest3 (a) VALUES (1), (2), (3), (NULL) +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest3 (a) VALUES (1), (2), (3), (NULL)" +== 105 +-- truncate_limit: 100 +SELECT * FROM gtest3 ORDER BY a +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest3 ORDER BY a" +== 106 +-- truncate_limit: 100 +UPDATE gtest3 SET a = 22 WHERE a = 2 +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE gtest3 SET a = 22 WHERE a = 2" +== 107 +-- truncate_limit: 100 +SELECT * FROM gtest3 ORDER BY a +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest3 ORDER BY a" +== 108 +-- truncate_limit: 100 +CREATE TABLE gtest3a (a text, b text GENERATED ALWAYS AS (a || '+' || a) STORED) +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gtest3a (a text, b text GENERATED ALWAYS AS ((a || '+') || a) STORED)" +== 109 +-- truncate_limit: 100 +INSERT INTO gtest3a (a) VALUES ('a'), ('b'), ('c'), (NULL) +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest3a (a) VALUES ('a'), ('b'), ('c'), (NULL)" +== 110 +-- truncate_limit: 100 +SELECT * FROM gtest3a ORDER BY a +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest3a ORDER BY a" +== 111 +-- truncate_limit: 100 +UPDATE gtest3a SET a = 'bb' WHERE a = 'b' +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE gtest3a SET a = 'bb' WHERE a = 'b'" +== 112 +-- truncate_limit: 100 +SELECT * FROM gtest3a ORDER BY a +-- +TABLE: name="gtest3a" schema="" table="gtest3a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM gtest3a ORDER BY a" +== 113 +-- truncate_limit: 100 +-- COPY +TRUNCATE gtest1 +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE gtest1" +== 114 +-- truncate_limit: 100 +INSERT INTO gtest1 (a) VALUES (1), (2) +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gtest1 (a) VALUES (1), (2)" +== 115 +-- truncate_limit: 100 +COPY gtest1 TO stdout +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY gtest1 TO STDOUT" +== 116 +-- truncate_limit: 100 +COPY gtest1 (a, b) TO stdout +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY gtest1(a, b) TO STDOUT" +== 117 +-- truncate_limit: 100 +COPY gtest1 FROM stdin +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY gtest1 FROM STDIN" +== 118 +-- truncate_limit: 100 +COPY gtest1 (a, b) FROM stdin +-- +TABLE: name="gtest1" schema="" table="gtest1" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY gtest1(a, b) FROM STDIN" +== 119 +-- truncate_limit: 100 +COPY gtest3 (a, b) FROM stdin +-- +TABLE: name="gtest3" schema="" table="gtest3" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY gtest3(a, b) FROM STDIN" diff --git a/parser/testdata/summary_truncate/postgres_regress/geometry.metadata.json b/parser/testdata/summary_truncate/postgres_regress/geometry.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/geometry.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/geometry.test b/parser/testdata/summary_truncate/postgres_regress/geometry.test new file mode 100644 index 0000000..1ea7864 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/geometry.test @@ -0,0 +1,1894 @@ +== 001 +-- truncate_limit: 100 +|-- +-- GEOMETRY +|-- + +-- Back off displayed precision a little bit to reduce platform-to-platform +-- variation in results. +SET extra_float_digits TO -3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO -3" +== 002 +-- truncate_limit: 100 +|-- +-- Points +|-- + +SELECT center(f1) AS center + FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="center" function="center" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT center(f1) AS center FROM box_tbl" +== 003 +-- truncate_limit: 100 +SELECT (@@ f1) AS center + FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT @@ f1 AS center FROM box_tbl" +== 004 +-- truncate_limit: 100 +SELECT point(f1) AS center + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT point(f1) AS center FROM circle_tbl" +== 005 +-- truncate_limit: 100 +SELECT (@@ f1) AS center + FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT @@ f1 AS center FROM circle_tbl" +== 006 +-- truncate_limit: 100 +SELECT (@@ f1) AS center + FROM POLYGON_TBL + WHERE (# f1) > 2 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT @@ f1 AS center FROM polygon_tbl WHERE (# f1) > 2" +== 007 +-- truncate_limit: 100 +-- "is horizontal" function +SELECT p1.f1 + FROM POINT_TBL p1 + WHERE ishorizontal(p1.f1, point '(0,0)') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +FUNCTION: name="ishorizontal" function="ishorizontal" schema="" ctx=Call +FUNCTION: name="ishorizontal" function="ishorizontal" schema="" ctx=Call +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1 FROM point_tbl p1 WHERE ishorizontal(p1.f1, point '(0,0)')" +== 008 +-- truncate_limit: 100 +-- "is horizontal" operator +SELECT p1.f1 + FROM POINT_TBL p1 + WHERE p1.f1 ?- point '(0,0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1 FROM point_tbl p1 WHERE p1.f1 ?- point '(0,0)'" +== 009 +-- truncate_limit: 100 +-- "is vertical" function +SELECT p1.f1 + FROM POINT_TBL p1 + WHERE isvertical(p1.f1, point '(5.1,34.5)') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +FUNCTION: name="isvertical" function="isvertical" schema="" ctx=Call +FUNCTION: name="isvertical" function="isvertical" schema="" ctx=Call +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1 FROM point_tbl p1 WHERE isvertical(p1.f1, point '(5.1,34.5)')" +== 010 +-- truncate_limit: 100 +-- "is vertical" operator +SELECT p1.f1 + FROM POINT_TBL p1 + WHERE p1.f1 ?| point '(5.1,34.5)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1 FROM point_tbl p1 WHERE p1.f1 ?| point '(5.1,34.5)'" +== 011 +-- truncate_limit: 100 +-- Slope +SELECT p1.f1, p2.f1, slope(p1.f1, p2.f1) FROM POINT_TBL p1, POINT_TBL p2 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FUNCTION: name="slope" function="slope" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, slope(p1.f1, p2.f1) FROM point_tbl p1, point_tbl p2" +== 012 +-- truncate_limit: 100 +-- Add point +SELECT p1.f1, p2.f1, p1.f1 + p2.f1 FROM POINT_TBL p1, POINT_TBL p2 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 + p2.f1 FROM point_tbl p1, point_tbl p2" +== 013 +-- truncate_limit: 100 +-- Subtract point +SELECT p1.f1, p2.f1, p1.f1 - p2.f1 FROM POINT_TBL p1, POINT_TBL p2 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 - p2.f1 FROM point_tbl p1, point_tbl p2" +== 014 +-- truncate_limit: 100 +-- Multiply with point +SELECT p1.f1, p2.f1, p1.f1 * p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p1.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 * p2.f1 FROM point_tbl p1, point_tbl p2 WHERE p1.f1[0] BETWEEN 1 AND 1000" +== 015 +-- truncate_limit: 100 +-- Underflow error +SELECT p1.f1, p2.f1, p1.f1 * p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p1.f1[0] < 1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 * p2.f1 FROM point_tbl p1, point_tbl p2 WHERE p1.f1[0] < 1" +== 016 +-- truncate_limit: 100 +-- Divide by point +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM point_tbl p1, point_tbl p2 WHERE p2.f1[0] BETWEEN 1 AND 1000" +== 017 +-- truncate_limit: 100 +-- Overflow error +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1[0] > 1000 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM point_tbl p1, point_tbl p2 WHERE p2.f1[0] > 1000" +== 018 +-- truncate_limit: 100 +-- Division by 0 error +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1 ~= '(0,0)'::point +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM point_tbl p1, point_tbl p2 WHERE p2.f1 ~= '(0,0)'::point" +== 019 +-- truncate_limit: 100 +-- Distance to line +SELECT p.f1, l.s, p.f1 <-> l.s AS dist_pl, l.s <-> p.f1 AS dist_lp FROM POINT_TBL p, LINE_TBL l +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="line_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, l.s, p.f1 <-> l.s AS dist_pl, l.s <-> p.f1 AS dist_lp FROM point_tbl p, line_tbl l" +== 020 +-- truncate_limit: 100 +-- Distance to line segment +SELECT p.f1, l.s, p.f1 <-> l.s AS dist_ps, l.s <-> p.f1 AS dist_sp FROM POINT_TBL p, LSEG_TBL l +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, l.s, p.f1 <-> l.s AS dist_ps, l.s <-> p.f1 AS dist_sp FROM point_tbl p, lseg_tbl l" +== 021 +-- truncate_limit: 100 +-- Distance to box +SELECT p.f1, b.f1, p.f1 <-> b.f1 AS dist_pb, b.f1 <-> p.f1 AS dist_bp FROM POINT_TBL p, BOX_TBL b +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, b.f1, p.f1 <-> b.f1 AS dist_pb, b.f1 <-> p.f1 AS dist_bp FROM point_tbl p, box_tbl b" +== 022 +-- truncate_limit: 100 +-- Distance to path +SELECT p.f1, p1.f1, p.f1 <-> p1.f1 AS dist_ppath, p1.f1 <-> p.f1 AS dist_pathp FROM POINT_TBL p, PATH_TBL p1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "p1"="path_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM point_tbl p, path_tbl p1" +== 023 +-- truncate_limit: 100 +-- Distance to polygon +SELECT p.f1, p1.f1, p.f1 <-> p1.f1 AS dist_ppoly, p1.f1 <-> p.f1 AS dist_polyp FROM POINT_TBL p, POLYGON_TBL p1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "p1"="polygon_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM point_tbl p, polygon_tbl p1" +== 024 +-- truncate_limit: 100 +-- Construct line through two points +SELECT p1.f1, p2.f1, line(p1.f1, p2.f1) + FROM POINT_TBL p1, POINT_TBL p2 WHERE p1.f1 <> p2.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FUNCTION: name="line" function="line" schema="" ctx=Call +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, line(p1.f1, p2.f1) FROM point_tbl p1, point_tbl p2 WHERE p1.f1 <> p2.f1" +== 025 +-- truncate_limit: 100 +-- Closest point to line +SELECT p.f1, l.s, p.f1 ## l.s FROM POINT_TBL p, LINE_TBL l +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="line_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, l.s, p.f1 ## l.s FROM point_tbl p, line_tbl l" +== 026 +-- truncate_limit: 100 +-- Closest point to line segment +SELECT p.f1, l.s, p.f1 ## l.s FROM POINT_TBL p, LSEG_TBL l +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, l.s, p.f1 ## l.s FROM point_tbl p, lseg_tbl l" +== 027 +-- truncate_limit: 100 +-- Closest point to box +SELECT p.f1, b.f1, p.f1 ## b.f1 FROM POINT_TBL p, BOX_TBL b +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, b.f1, p.f1 ## b.f1 FROM point_tbl p, box_tbl b" +== 028 +-- truncate_limit: 100 +-- On line +SELECT p.f1, l.s FROM POINT_TBL p, LINE_TBL l WHERE p.f1 <@ l.s +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="line_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +FILTER: schema="" table="l" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, l.s FROM point_tbl p, line_tbl l WHERE p.f1 <@ l.s" +== 029 +-- truncate_limit: 100 +-- On line segment +SELECT p.f1, l.s FROM POINT_TBL p, LSEG_TBL l WHERE p.f1 <@ l.s +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +FILTER: schema="" table="l" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, l.s FROM point_tbl p, lseg_tbl l WHERE p.f1 <@ l.s" +== 030 +-- truncate_limit: 100 +-- On path +SELECT p.f1, p1.f1 FROM POINT_TBL p, PATH_TBL p1 WHERE p.f1 <@ p1.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "p1"="path_tbl" +FILTER: schema="" table="p" column="f1" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, p1.f1 FROM point_tbl p, path_tbl p1 WHERE p.f1 <@ p1.f1" +== 031 +-- truncate_limit: 100 +|-- +-- Lines +|-- + +-- Vertical +SELECT s FROM LINE_TBL WHERE ?| s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +FILTER: schema="" table="" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT s FROM line_tbl WHERE ?| s" +== 032 +-- truncate_limit: 100 +-- Horizontal +SELECT s FROM LINE_TBL WHERE ?- s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +FILTER: schema="" table="" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT s FROM line_tbl WHERE ?- s" +== 033 +-- truncate_limit: 100 +-- Same as line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s = l2.s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM line_tbl l1, line_tbl l2 WHERE l1.s = l2.s" +== 034 +-- truncate_limit: 100 +-- Parallel to line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?|| l2.s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM line_tbl l1, line_tbl l2 WHERE l1.s ?|| l2.s" +== 035 +-- truncate_limit: 100 +-- Perpendicular to line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?-| l2.s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM line_tbl l1, line_tbl l2 WHERE l1.s ?-| l2.s" +== 036 +-- truncate_limit: 100 +-- Distance to line +SELECT l1.s, l2.s, l1.s <-> l2.s FROM LINE_TBL l1, LINE_TBL l2 +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s, l1.s <-> l2.s FROM line_tbl l1, line_tbl l2" +== 037 +-- truncate_limit: 100 +-- Intersect with line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?# l2.s +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM line_tbl l1, line_tbl l2 WHERE l1.s ?# l2.s" +== 038 +-- truncate_limit: 100 +-- Intersect with box +SELECT l.s, b.f1 FROM LINE_TBL l, BOX_TBL b WHERE l.s ?# b.f1 +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="line_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, b.f1 FROM line_tbl l, box_tbl b WHERE l.s ?# b.f1" +== 039 +-- truncate_limit: 100 +-- Intersection point with line +SELECT l1.s, l2.s, l1.s # l2.s FROM LINE_TBL l1, LINE_TBL l2 +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l1"="line_tbl" +ALIAS: "l2"="line_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s, l1.s # l2.s FROM line_tbl l1, line_tbl l2" +== 040 +-- truncate_limit: 100 +-- Closest point to line segment +SELECT l.s, l1.s, l.s ## l1.s FROM LINE_TBL l, LSEG_TBL l1 +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l"="line_tbl" +ALIAS: "l1"="lseg_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, l1.s, l.s ## l1.s FROM line_tbl l, lseg_tbl l1" +== 041 +-- truncate_limit: 100 +|-- +-- Line segments +|-- + +-- intersection +SELECT p.f1, l.s, l.s # p.f1 AS intersection + FROM LSEG_TBL l, POINT_TBL p +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, l.s, l.s # p.f1 AS intersection FROM lseg_tbl l, point_tbl p" +== 042 +-- truncate_limit: 100 +-- Length +SELECT s, @-@ s FROM LSEG_TBL +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT s, @-@ s FROM lseg_tbl" +== 043 +-- truncate_limit: 100 +-- Vertical +SELECT s FROM LSEG_TBL WHERE ?| s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +FILTER: schema="" table="" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT s FROM lseg_tbl WHERE ?| s" +== 044 +-- truncate_limit: 100 +-- Horizontal +SELECT s FROM LSEG_TBL WHERE ?- s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +FILTER: schema="" table="" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT s FROM lseg_tbl WHERE ?- s" +== 045 +-- truncate_limit: 100 +-- Center +SELECT s, @@ s FROM LSEG_TBL +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT s, @@ s FROM lseg_tbl" +== 046 +-- truncate_limit: 100 +-- To point +SELECT s, s::point FROM LSEG_TBL +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT s, s::point FROM lseg_tbl" +== 047 +-- truncate_limit: 100 +-- Has points less than line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s < l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM lseg_tbl l1, lseg_tbl l2 WHERE l1.s < l2.s" +== 048 +-- truncate_limit: 100 +-- Has points less than or equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s <= l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM lseg_tbl l1, lseg_tbl l2 WHERE l1.s <= l2.s" +== 049 +-- truncate_limit: 100 +-- Has points equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s = l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM lseg_tbl l1, lseg_tbl l2 WHERE l1.s = l2.s" +== 050 +-- truncate_limit: 100 +-- Has points greater than or equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s >= l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM lseg_tbl l1, lseg_tbl l2 WHERE l1.s >= l2.s" +== 051 +-- truncate_limit: 100 +-- Has points greater than line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s > l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM lseg_tbl l1, lseg_tbl l2 WHERE l1.s > l2.s" +== 052 +-- truncate_limit: 100 +-- Has points not equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s != l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM lseg_tbl l1, lseg_tbl l2 WHERE l1.s <> l2.s" +== 053 +-- truncate_limit: 100 +-- Parallel with line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s ?|| l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM lseg_tbl l1, lseg_tbl l2 WHERE l1.s ?|| l2.s" +== 054 +-- truncate_limit: 100 +-- Perpendicular with line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s ?-| l2.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +FILTER: schema="" table="l1" column="s" +FILTER: schema="" table="l2" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s FROM lseg_tbl l1, lseg_tbl l2 WHERE l1.s ?-| l2.s" +== 055 +-- truncate_limit: 100 +-- Distance to line +SELECT l.s, l1.s, l.s <-> l1.s AS dist_sl, l1.s <-> l.s AS dist_ls FROM LSEG_TBL l, LINE_TBL l1 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "l1"="line_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, l1.s, l.s <-> l1.s AS dist_sl, l1.s <-> l.s AS dist_ls FROM lseg_tbl l, line_tbl l1" +== 056 +-- truncate_limit: 100 +-- Distance to line segment +SELECT l1.s, l2.s, l1.s <-> l2.s FROM LSEG_TBL l1, LSEG_TBL l2 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s, l1.s <-> l2.s FROM lseg_tbl l1, lseg_tbl l2" +== 057 +-- truncate_limit: 100 +-- Distance to box +SELECT l.s, b.f1, l.s <-> b.f1 AS dist_sb, b.f1 <-> l.s AS dist_bs FROM LSEG_TBL l, BOX_TBL b +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="lseg_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, b.f1, l.s <-> b.f1 AS dist_sb, b.f1 <-> l.s AS dist_bs FROM lseg_tbl l, box_tbl b" +== 058 +-- truncate_limit: 100 +-- Intersect with line segment +SELECT l.s, l1.s FROM LSEG_TBL l, LINE_TBL l1 WHERE l.s ?# l1.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "l1"="line_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="l1" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, l1.s FROM lseg_tbl l, line_tbl l1 WHERE l.s ?# l1.s" +== 059 +-- truncate_limit: 100 +-- Intersect with box +SELECT l.s, b.f1 FROM LSEG_TBL l, BOX_TBL b WHERE l.s ?# b.f1 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="lseg_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, b.f1 FROM lseg_tbl l, box_tbl b WHERE l.s ?# b.f1" +== 060 +-- truncate_limit: 100 +-- Intersection point with line segment +SELECT l1.s, l2.s, l1.s # l2.s FROM LSEG_TBL l1, LSEG_TBL l2 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s, l1.s # l2.s FROM lseg_tbl l1, lseg_tbl l2" +== 061 +-- truncate_limit: 100 +-- Closest point to line segment +SELECT l1.s, l2.s, l1.s ## l2.s FROM LSEG_TBL l1, LSEG_TBL l2 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +ALIAS: "l1"="lseg_tbl" +ALIAS: "l2"="lseg_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l1.s, l2.s, l1.s ## l2.s FROM lseg_tbl l1, lseg_tbl l2" +== 062 +-- truncate_limit: 100 +-- Closest point to box +SELECT l.s, b.f1, l.s ## b.f1 FROM LSEG_TBL l, BOX_TBL b +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="lseg_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, b.f1, l.s ## b.f1 FROM lseg_tbl l, box_tbl b" +== 063 +-- truncate_limit: 100 +-- On line +SELECT l.s, l1.s FROM LSEG_TBL l, LINE_TBL l1 WHERE l.s <@ l1.s +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +ALIAS: "l"="lseg_tbl" +ALIAS: "l1"="line_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="l1" column="s" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, l1.s FROM lseg_tbl l, line_tbl l1 WHERE l.s <@ l1.s" +== 064 +-- truncate_limit: 100 +-- On box +SELECT l.s, b.f1 FROM LSEG_TBL l, BOX_TBL b WHERE l.s <@ b.f1 +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "l"="lseg_tbl" +FILTER: schema="" table="l" column="s" +FILTER: schema="" table="b" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT l.s, b.f1 FROM lseg_tbl l, box_tbl b WHERE l.s <@ b.f1" +== 065 +-- truncate_limit: 100 +|-- +-- Boxes +|-- + +SELECT box(f1) AS box FROM CIRCLE_TBL +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT box(f1) AS box FROM circle_tbl" +== 066 +-- truncate_limit: 100 +-- translation +SELECT b.f1 + p.f1 AS translation + FROM BOX_TBL b, POINT_TBL p +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 + p.f1 AS translation FROM box_tbl b, point_tbl p" +== 067 +-- truncate_limit: 100 +SELECT b.f1 - p.f1 AS translation + FROM BOX_TBL b, POINT_TBL p +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1 - p.f1 AS translation FROM box_tbl b, point_tbl p" +== 068 +-- truncate_limit: 100 +-- Multiply with point +SELECT b.f1, p.f1, b.f1 * p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1, p.f1, b.f1 * p.f1 FROM box_tbl b, point_tbl p WHERE p.f1[0] BETWEEN 1 AND 1000" +== 069 +-- truncate_limit: 100 +-- Overflow error +SELECT b.f1, p.f1, b.f1 * p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] > 1000 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1, p.f1, b.f1 * p.f1 FROM box_tbl b, point_tbl p WHERE p.f1[0] > 1000" +== 070 +-- truncate_limit: 100 +-- Divide by point +SELECT b.f1, p.f1, b.f1 / p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "b"="box_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT b.f1, p.f1, b.f1 / p.f1 FROM box_tbl b, point_tbl p WHERE p.f1[0] BETWEEN 1 AND 1000" +== 071 +-- truncate_limit: 100 +-- To box +SELECT f1::box + FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1::box FROM point_tbl" +== 072 +-- truncate_limit: 100 +SELECT bound_box(a.f1, b.f1) + FROM BOX_TBL a, BOX_TBL b +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "a"="box_tbl" +ALIAS: "b"="box_tbl" +FUNCTION: name="bound_box" function="bound_box" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT bound_box(a.f1, b.f1) FROM box_tbl a, box_tbl b" +== 073 +-- truncate_limit: 100 +-- Below box +SELECT b1.f1, b2.f1, b1.f1 <^ b2.f1 FROM BOX_TBL b1, BOX_TBL b2 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT b1.f1, b2.f1, b1.f1 <^ b2.f1 FROM box_tbl b1, box_tbl b2" +== 074 +-- truncate_limit: 100 +-- Above box +SELECT b1.f1, b2.f1, b1.f1 >^ b2.f1 FROM BOX_TBL b1, BOX_TBL b2 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT b1.f1, b2.f1, b1.f1 >^ b2.f1 FROM box_tbl b1, box_tbl b2" +== 075 +-- truncate_limit: 100 +-- Intersection point with box +SELECT b1.f1, b2.f1, b1.f1 # b2.f1 FROM BOX_TBL b1, BOX_TBL b2 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT b1.f1, b2.f1, b1.f1 # b2.f1 FROM box_tbl b1, box_tbl b2" +== 076 +-- truncate_limit: 100 +-- Diagonal +SELECT f1, diagonal(f1) FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="diagonal" function="diagonal" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, diagonal(f1) FROM box_tbl" +== 077 +-- truncate_limit: 100 +-- Distance to box +SELECT b1.f1, b2.f1, b1.f1 <-> b2.f1 FROM BOX_TBL b1, BOX_TBL b2 +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +ALIAS: "b1"="box_tbl" +ALIAS: "b2"="box_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT b1.f1, b2.f1, b1.f1 <-> b2.f1 FROM box_tbl b1, box_tbl b2" +== 078 +-- truncate_limit: 100 +|-- +-- Paths +|-- + +-- Points +SELECT f1, npoints(f1) FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="npoints" function="npoints" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, npoints(f1) FROM path_tbl" +== 079 +-- truncate_limit: 100 +-- Area +SELECT f1, area(f1) FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="area" function="area" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, area(f1) FROM path_tbl" +== 080 +-- truncate_limit: 100 +-- Length +SELECT f1, @-@ f1 FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, @-@ f1 FROM path_tbl" +== 081 +-- truncate_limit: 100 +-- To polygon +SELECT f1, f1::polygon FROM PATH_TBL WHERE isclosed(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1::polygon FROM path_tbl WHERE isclosed(f1)" +== 082 +-- truncate_limit: 100 +-- Open path cannot be converted to polygon error +SELECT f1, f1::polygon FROM PATH_TBL WHERE isopen(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1::polygon FROM path_tbl WHERE isopen(f1)" +== 083 +-- truncate_limit: 100 +-- Has points less than path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 < p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM path_tbl p1, path_tbl p2 WHERE p1.f1 < p2.f1" +== 084 +-- truncate_limit: 100 +-- Has points less than or equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 <= p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM path_tbl p1, path_tbl p2 WHERE p1.f1 <= p2.f1" +== 085 +-- truncate_limit: 100 +-- Has points equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 = p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM path_tbl p1, path_tbl p2 WHERE p1.f1 = p2.f1" +== 086 +-- truncate_limit: 100 +-- Has points greater than or equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 >= p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM path_tbl p1, path_tbl p2 WHERE p1.f1 >= p2.f1" +== 087 +-- truncate_limit: 100 +-- Has points greater than path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 > p2.f1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM path_tbl p1, path_tbl p2 WHERE p1.f1 > p2.f1" +== 088 +-- truncate_limit: 100 +-- Add path +SELECT p1.f1, p2.f1, p1.f1 + p2.f1 FROM PATH_TBL p1, PATH_TBL p2 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 + p2.f1 FROM path_tbl p1, path_tbl p2" +== 089 +-- truncate_limit: 100 +-- Add point +SELECT p.f1, p1.f1, p.f1 + p1.f1 FROM PATH_TBL p, POINT_TBL p1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, p1.f1, p.f1 + p1.f1 FROM path_tbl p, point_tbl p1" +== 090 +-- truncate_limit: 100 +-- Subtract point +SELECT p.f1, p1.f1, p.f1 - p1.f1 FROM PATH_TBL p, POINT_TBL p1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, p1.f1, p.f1 - p1.f1 FROM path_tbl p, point_tbl p1" +== 091 +-- truncate_limit: 100 +-- Multiply with point +SELECT p.f1, p1.f1, p.f1 * p1.f1 FROM PATH_TBL p, POINT_TBL p1 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, p1.f1, p.f1 * p1.f1 FROM path_tbl p, point_tbl p1" +== 092 +-- truncate_limit: 100 +-- Divide by point +SELECT p.f1, p1.f1, p.f1 / p1.f1 FROM PATH_TBL p, POINT_TBL p1 WHERE p1.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, p1.f1, p.f1 / p1.f1 FROM path_tbl p, point_tbl p1 WHERE p1.f1[0] BETWEEN 1 AND 1000" +== 093 +-- truncate_limit: 100 +-- Division by 0 error +SELECT p.f1, p1.f1, p.f1 / p1.f1 FROM PATH_TBL p, POINT_TBL p1 WHERE p1.f1 ~= '(0,0)'::point +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="path_tbl" +ALIAS: "p1"="point_tbl" +FILTER: schema="" table="p1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, p1.f1, p.f1 / p1.f1 FROM path_tbl p, point_tbl p1 WHERE p1.f1 ~= '(0,0)'::point" +== 094 +-- truncate_limit: 100 +-- Distance to path +SELECT p1.f1, p2.f1, p1.f1 <-> p2.f1 FROM PATH_TBL p1, PATH_TBL p2 +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +ALIAS: "p1"="path_tbl" +ALIAS: "p2"="path_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 <-> p2.f1 FROM path_tbl p1, path_tbl p2" +== 095 +-- truncate_limit: 100 +|-- +-- Polygons +|-- + +-- containment +SELECT p.f1, poly.f1, poly.f1 @> p.f1 AS contains + FROM POLYGON_TBL poly, POINT_TBL p +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "poly"="polygon_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, poly.f1, poly.f1 @> p.f1 AS contains FROM polygon_tbl poly, point_tbl p" +== 096 +-- truncate_limit: 100 +SELECT p.f1, poly.f1, p.f1 <@ poly.f1 AS contained + FROM POLYGON_TBL poly, POINT_TBL p +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +ALIAS: "poly"="polygon_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, poly.f1, p.f1 <@ poly.f1 AS contained FROM polygon_tbl poly, point_tbl p" +== 097 +-- truncate_limit: 100 +SELECT npoints(f1) AS npoints, f1 AS polygon + FROM POLYGON_TBL +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="npoints" function="npoints" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT npoints(f1) AS npoints, f1 AS polygon FROM polygon_tbl" +== 098 +-- truncate_limit: 100 +SELECT polygon(f1) + FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polygon(f1) FROM box_tbl" +== 099 +-- truncate_limit: 100 +SELECT polygon(f1) + FROM PATH_TBL WHERE isclosed(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT polygon(f1) FROM path_tbl WHERE isclosed(f1)" +== 100 +-- truncate_limit: 100 +SELECT f1 AS open_path, polygon( pclose(f1)) AS polygon + FROM PATH_TBL + WHERE isopen(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FUNCTION: name="pclose" function="pclose" schema="" ctx=Call +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS open_path, polygon(pclose(f1)) AS polygon FROM path_tbl WHERE isopen(f1)" +== 101 +-- truncate_limit: 100 +-- To box +SELECT f1, f1::box FROM POLYGON_TBL +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1::box FROM polygon_tbl" +== 102 +-- truncate_limit: 100 +-- To path +SELECT f1, f1::path FROM POLYGON_TBL +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1::path FROM polygon_tbl" +== 103 +-- truncate_limit: 100 +-- Same as polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 ~= p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 ~= p2.f1" +== 104 +-- truncate_limit: 100 +-- Contained by polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 <@ p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 <@ p2.f1" +== 105 +-- truncate_limit: 100 +-- Contains polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 @> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 @> p2.f1" +== 106 +-- truncate_limit: 100 +-- Overlap with polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 && p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 && p2.f1" +== 107 +-- truncate_limit: 100 +-- Left of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 << p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 << p2.f1" +== 108 +-- truncate_limit: 100 +-- Overlap of left of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &< p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 &< p2.f1" +== 109 +-- truncate_limit: 100 +-- Right of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 >> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 >> p2.f1" +== 110 +-- truncate_limit: 100 +-- Overlap of right of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 &> p2.f1" +== 111 +-- truncate_limit: 100 +-- Below polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 <<| p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 <<| p2.f1" +== 112 +-- truncate_limit: 100 +-- Overlap or below polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &<| p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 &<| p2.f1" +== 113 +-- truncate_limit: 100 +-- Above polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 |>> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 |>> p2.f1" +== 114 +-- truncate_limit: 100 +-- Overlap or above polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 |&> p2.f1 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1 FROM polygon_tbl p1, polygon_tbl p2 WHERE p1.f1 |&> p2.f1" +== 115 +-- truncate_limit: 100 +-- Distance to polygon +SELECT p1.f1, p2.f1, p1.f1 <-> p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "p1"="polygon_tbl" +ALIAS: "p2"="polygon_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1, p2.f1, p1.f1 <-> p2.f1 FROM polygon_tbl p1, polygon_tbl p2" +== 116 +-- truncate_limit: 100 +|-- +-- Circles +|-- + +SELECT circle(f1, 50.0) + FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT circle(f1, 50.0) FROM point_tbl" +== 117 +-- truncate_limit: 100 +SELECT circle(f1) + FROM BOX_TBL +-- +TABLE: name="box_tbl" schema="" table="box_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT circle(f1) FROM box_tbl" +== 118 +-- truncate_limit: 100 +SELECT circle(f1) + FROM POLYGON_TBL + WHERE (# f1) >= 3 +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT circle(f1) FROM polygon_tbl WHERE (# f1) >= 3" +== 119 +-- truncate_limit: 100 +SELECT c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS distance + FROM CIRCLE_TBL c1, POINT_TBL p1 + WHERE (p1.f1 <-> c1.f1) > 0 + ORDER BY distance, area(c1.f1), p1.f1[0] +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "p1"="point_tbl" +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="c1" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM circle_tbl c1, point_tbl p1 WHERE ... ORDER BY distance, area(c1.f1), p1.f1[0]" +== 120 +-- truncate_limit: 100 +-- To polygon +SELECT f1, f1::polygon FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>' +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1::polygon FROM circle_tbl WHERE f1 >= '<(0,0),1>'" +== 121 +-- truncate_limit: 100 +-- To polygon with less points +SELECT f1, polygon(8, f1) FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>' +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, polygon(8, f1) FROM circle_tbl WHERE f1 >= '<(0,0),1>'" +== 122 +-- truncate_limit: 100 +-- Error for insufficient number of points +SELECT f1, polygon(1, f1) FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>' +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, polygon(1, f1) FROM circle_tbl WHERE f1 >= '<(0,0),1>'" +== 123 +-- truncate_limit: 100 +-- Zero radius error +SELECT f1, polygon(10, f1) FROM CIRCLE_TBL WHERE f1 < '<(0,0),1>' +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, polygon(10, f1) FROM circle_tbl WHERE f1 < '<(0,0),1>'" +== 124 +-- truncate_limit: 100 +-- Same as circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 ~= c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 ~= c2.f1" +== 125 +-- truncate_limit: 100 +-- Overlap with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 && c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 && c2.f1" +== 126 +-- truncate_limit: 100 +-- Overlap or left of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &< c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 &< c2.f1" +== 127 +-- truncate_limit: 100 +-- Left of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 << c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 << c2.f1" +== 128 +-- truncate_limit: 100 +-- Right of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 >> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 >> c2.f1" +== 129 +-- truncate_limit: 100 +-- Overlap or right of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 &> c2.f1" +== 130 +-- truncate_limit: 100 +-- Contained by circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <@ c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 <@ c2.f1" +== 131 +-- truncate_limit: 100 +-- Contain by circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 @> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 @> c2.f1" +== 132 +-- truncate_limit: 100 +-- Below circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <<| c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 <<| c2.f1" +== 133 +-- truncate_limit: 100 +-- Above circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 |>> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 |>> c2.f1" +== 134 +-- truncate_limit: 100 +-- Overlap or below circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &<| c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 &<| c2.f1" +== 135 +-- truncate_limit: 100 +-- Overlap or above circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 |&> c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 |&> c2.f1" +== 136 +-- truncate_limit: 100 +-- Area equal with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 = c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 = c2.f1" +== 137 +-- truncate_limit: 100 +-- Area not equal with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 != c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 <> c2.f1" +== 138 +-- truncate_limit: 100 +-- Area less than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 < c2.f1" +== 139 +-- truncate_limit: 100 +-- Area greater than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 > c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 > c2.f1" +== 140 +-- truncate_limit: 100 +-- Area less than or equal circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <= c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 <= c2.f1" +== 141 +-- truncate_limit: 100 +-- Area greater than or equal circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 >= c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 >= c2.f1" +== 142 +-- truncate_limit: 100 +-- Area less than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 < c2.f1" +== 143 +-- truncate_limit: 100 +-- Area greater than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +ALIAS: "c1"="circle_tbl" +ALIAS: "c2"="circle_tbl" +FILTER: schema="" table="c1" column="f1" +FILTER: schema="" table="c2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c1.f1, c2.f1 FROM circle_tbl c1, circle_tbl c2 WHERE c1.f1 < c2.f1" +== 144 +-- truncate_limit: 100 +-- Add point +SELECT c.f1, p.f1, c.f1 + p.f1 FROM CIRCLE_TBL c, POINT_TBL p +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1, p.f1, c.f1 + p.f1 FROM circle_tbl c, point_tbl p" +== 145 +-- truncate_limit: 100 +-- Subtract point +SELECT c.f1, p.f1, c.f1 - p.f1 FROM CIRCLE_TBL c, POINT_TBL p +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1, p.f1, c.f1 - p.f1 FROM circle_tbl c, point_tbl p" +== 146 +-- truncate_limit: 100 +-- Multiply with point +SELECT c.f1, p.f1, c.f1 * p.f1 FROM CIRCLE_TBL c, POINT_TBL p +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1, p.f1, c.f1 * p.f1 FROM circle_tbl c, point_tbl p" +== 147 +-- truncate_limit: 100 +-- Divide by point +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1, p.f1, c.f1 / p.f1 FROM circle_tbl c, point_tbl p WHERE p.f1[0] BETWEEN 1 AND 1000" +== 148 +-- truncate_limit: 100 +-- Overflow error +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1[0] > 1000 +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1, p.f1, c.f1 / p.f1 FROM circle_tbl c, point_tbl p WHERE p.f1[0] > 1000" +== 149 +-- truncate_limit: 100 +-- Division by 0 error +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1 ~= '(0,0)'::point +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1, p.f1, c.f1 / p.f1 FROM circle_tbl c, point_tbl p WHERE p.f1 ~= '(0,0)'::point" +== 150 +-- truncate_limit: 100 +-- Distance to polygon +SELECT c.f1, p.f1, c.f1 <-> p.f1 FROM CIRCLE_TBL c, POLYGON_TBL p +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +ALIAS: "c"="circle_tbl" +ALIAS: "p"="polygon_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1, p.f1, c.f1 <-> p.f1 FROM circle_tbl c, polygon_tbl p" +== 151 +-- truncate_limit: 100 +-- Check index behavior for circles + +CREATE INDEX gcircleind ON circle_tbl USING gist (f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gcircleind ON circle_tbl USING gist (f1)" +== 152 +-- truncate_limit: 100 +SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) + ORDER BY area(f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM circle_tbl WHERE f1 && circle(point(1, -2), 1) ORDER BY area(f1)" +== 153 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) + ORDER BY area(f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM circle_tbl WHERE f1 && circle(point(1, -2), 1) ORDER BY area(f1)" +== 154 +-- truncate_limit: 100 +SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1) + ORDER BY area(f1) +-- +TABLE: name="circle_tbl" schema="" table="circle_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="area" function="area" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM circle_tbl WHERE f1 && circle(point(1, -2), 1) ORDER BY area(f1)" +== 155 +-- truncate_limit: 100 +-- Check index behavior for polygons + +CREATE INDEX gpolygonind ON polygon_tbl USING gist (f1) +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gpolygonind ON polygon_tbl USING gist (f1)" +== 156 +-- truncate_limit: 100 +SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon + ORDER BY (poly_center(f1))[0] +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="poly_center" function="poly_center" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon ORDER BY (poly_center(f1))[0]" +== 157 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon + ORDER BY (poly_center(f1))[0] +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="poly_center" function="poly_center" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon ORDER BY..." +== 158 +-- truncate_limit: 100 +SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon + ORDER BY (poly_center(f1))[0] +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +FUNCTION: name="poly_center" function="poly_center" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon ORDER BY (poly_center(f1))[0]" +== 159 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('(1', 'circle') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1', 'circle')" +== 160 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1,', 'circle') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1,', 'circle')" +== 161 +-- truncate_limit: 100 +SELECT pg_input_is_valid('(1,2),-1', 'circle') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1,2),-1', 'circle')" +== 162 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('(1,2),-1', 'circle') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(1,2),-1', 'circle')" diff --git a/parser/testdata/summary_truncate/postgres_regress/gin.metadata.json b/parser/testdata/summary_truncate/postgres_regress/gin.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/gin.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/gin.test b/parser/testdata/summary_truncate/postgres_regress/gin.test new file mode 100644 index 0000000..8378feb --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/gin.test @@ -0,0 +1,556 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test GIN indexes. +|-- +-- There are other tests to test different GIN opclasses. This is for testing +-- GIN itself. + +-- Create and populate a test table with a GIN index. +create table gin_test_tbl(i int4[]) with (autovacuum_enabled = off) +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gin_test_tbl (i int4[]) WITH (autovacuum_enabled=off)" +== 002 +-- truncate_limit: 100 +create index gin_test_idx on gin_test_tbl using gin (i) + with (fastupdate = on, gin_pending_list_limit = 4096) +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gin_test_idx ON gin_test_tbl USING gin (i) WITH (fastupdate=on, gin_pending_list_lim..." +== 003 +-- truncate_limit: 100 +insert into gin_test_tbl select array[1, 2, g] from generate_series(1, 20000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gin_test_tbl SELECT ARRAY[1, 2, g] FROM generate_series(1, 20000) g" +== 004 +-- truncate_limit: 100 +insert into gin_test_tbl select array[1, 3, g] from generate_series(1, 1000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gin_test_tbl SELECT ARRAY[1, 3, g] FROM generate_series(1, 1000) g" +== 005 +-- truncate_limit: 100 +select gin_clean_pending_list('gin_test_idx')>10 as many +-- +FUNCTION: name="gin_clean_pending_list" function="gin_clean_pending_list" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT gin_clean_pending_list('gin_test_idx') > 10 AS many" +== 006 +-- truncate_limit: 100 +-- flush the fastupdate buffers + +insert into gin_test_tbl select array[3, 1, g] from generate_series(1, 1000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gin_test_tbl SELECT ARRAY[3, 1, g] FROM generate_series(1, 1000) g" +== 007 +-- truncate_limit: 100 +vacuum gin_test_tbl +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM gin_test_tbl" +== 008 +-- truncate_limit: 100 +-- flush the fastupdate buffers + +select gin_clean_pending_list('gin_test_idx') +-- +FUNCTION: name="gin_clean_pending_list" function="gin_clean_pending_list" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT gin_clean_pending_list('gin_test_idx')" +== 009 +-- truncate_limit: 100 +-- nothing to flush + +-- Test vacuuming +delete from gin_test_tbl where i @> array[2] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM gin_test_tbl WHERE i @> ARRAY[2]" +== 010 +-- truncate_limit: 100 +vacuum gin_test_tbl +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM gin_test_tbl" +== 011 +-- truncate_limit: 100 +-- Disable fastupdate, and do more insertions. With fastupdate enabled, most +-- insertions (by flushing the list pages) cause page splits. Without +-- fastupdate, we get more churn in the GIN data leaf pages, and exercise the +-- recompression codepaths. +alter index gin_test_idx set (fastupdate = off) +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX gin_test_idx SET (fastupdate=off)" +== 012 +-- truncate_limit: 100 +insert into gin_test_tbl select array[1, 2, g] from generate_series(1, 1000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gin_test_tbl SELECT ARRAY[1, 2, g] FROM generate_series(1, 1000) g" +== 013 +-- truncate_limit: 100 +insert into gin_test_tbl select array[1, 3, g] from generate_series(1, 1000) g +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gin_test_tbl SELECT ARRAY[1, 3, g] FROM generate_series(1, 1000) g" +== 014 +-- truncate_limit: 100 +delete from gin_test_tbl where i @> array[2] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM gin_test_tbl WHERE i @> ARRAY[2]" +== 015 +-- truncate_limit: 100 +vacuum gin_test_tbl +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM gin_test_tbl" +== 016 +-- truncate_limit: 100 +-- Test for "rare && frequent" searches +explain (costs off) +select count(*) from gin_test_tbl where i @> array[1, 999] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM gin_test_tbl WHERE i @> ARRAY[1, 999]" +== 017 +-- truncate_limit: 100 +select count(*) from gin_test_tbl where i @> array[1, 999] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM gin_test_tbl WHERE i @> ARRAY[1, 999]" +== 018 +-- truncate_limit: 100 +-- Very weak test for gin_fuzzy_search_limit +set gin_fuzzy_search_limit = 1000 +-- +STMT: VariableSetStmt +TRUNCATED: "SET gin_fuzzy_search_limit TO 1000" +== 019 +-- truncate_limit: 100 +explain (costs off) +select count(*) > 0 as ok from gin_test_tbl where i @> array[1] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) > 0 AS ok FROM gin_test_tbl WHERE i @> ARRAY[1]" +== 020 +-- truncate_limit: 100 +select count(*) > 0 as ok from gin_test_tbl where i @> array[1] +-- +TABLE: name="gin_test_tbl" schema="" table="gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM gin_test_tbl WHERE i @> ARRAY[1]" +== 021 +-- truncate_limit: 100 +reset gin_fuzzy_search_limit +-- +STMT: VariableSetStmt +TRUNCATED: "RESET gin_fuzzy_search_limit" +== 022 +-- truncate_limit: 100 +-- Test optimization of empty queries +create temp table t_gin_test_tbl(i int4[], j int4[]) +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t_gin_test_tbl (i int4[], j int4[])" +== 023 +-- truncate_limit: 100 +create index on t_gin_test_tbl using gin (i, j) +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON t_gin_test_tbl USING gin (i, j)" +== 024 +-- truncate_limit: 100 +insert into t_gin_test_tbl +values + (null, null), + ('{}', null), + ('{1}', null), + ('{1,2}', null), + (null, '{}'), + (null, '{10}'), + ('{1,2}', '{10}'), + ('{2}', '{10}'), + ('{1,3}', '{}'), + ('{1,1}', '{10}') +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t_gin_test_tbl VALUES (...)" +== 025 +-- truncate_limit: 100 +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 026 +-- truncate_limit: 100 +explain (costs off) +select * from t_gin_test_tbl where array[0] <@ i +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t_gin_test_tbl WHERE ARRAY[0] <@ i" +== 027 +-- truncate_limit: 100 +select * from t_gin_test_tbl where array[0] <@ i +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t_gin_test_tbl WHERE ARRAY[0] <@ i" +== 028 +-- truncate_limit: 100 +select * from t_gin_test_tbl where array[0] <@ i and '{}'::int4[] <@ j +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t_gin_test_tbl WHERE ARRAY[0] <@ i AND '{}'::int4[] <@ j" +== 029 +-- truncate_limit: 100 +explain (costs off) +select * from t_gin_test_tbl where i @> '{}' +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t_gin_test_tbl WHERE i @> '{}'" +== 030 +-- truncate_limit: 100 +select * from t_gin_test_tbl where i @> '{}' +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t_gin_test_tbl WHERE i @> '{}'" +== 031 +-- truncate_limit: 100 +create function explain_query_json(query_sql text) +returns table (explain_line json) +language plpgsql as +$$ +begin + set enable_seqscan = off; + set enable_bitmapscan = on; + return query execute 'EXPLAIN (ANALYZE, FORMAT json) ' || query_sql; +end; +$$ +-- +FUNCTION: name="explain_query_json" function="explain_query_json" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION explain_query_json(query_sql text) RETURNS TABLE (explain_line pg_catalog.json) L..." +== 032 +-- truncate_limit: 100 +create function execute_text_query_index(query_sql text) +returns setof text +language plpgsql +as +$$ +begin + set enable_seqscan = off; + set enable_bitmapscan = on; + return query execute query_sql; +end; +$$ +-- +FUNCTION: name="execute_text_query_index" function="execute_text_query_index" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION execute_text_query_index(query_sql text) RETURNS SETOF text LANGUAGE plpgsql AS $..." +== 033 +-- truncate_limit: 100 +create function execute_text_query_heap(query_sql text) +returns setof text +language plpgsql +as +$$ +begin + set enable_seqscan = on; + set enable_bitmapscan = off; + return query execute query_sql; +end; +$$ +-- +FUNCTION: name="execute_text_query_heap" function="execute_text_query_heap" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION execute_text_query_heap(query_sql text) RETURNS SETOF text LANGUAGE plpgsql AS $$..." +== 034 +-- truncate_limit: 100 +-- check number of rows returned by index and removed by recheck +select + query, + js->0->'Plan'->'Plans'->0->'Actual Rows' as "return by index", + js->0->'Plan'->'Rows Removed by Index Recheck' as "removed by recheck", + (res_index = res_heap) as "match" +from + (values + ($$ i @> '{}' $$), + ($$ j @> '{}' $$), + ($$ i @> '{}' and j @> '{}' $$), + ($$ i @> '{1}' $$), + ($$ i @> '{1}' and j @> '{}' $$), + ($$ i @> '{1}' and i @> '{}' and j @> '{}' $$), + ($$ j @> '{10}' $$), + ($$ j @> '{10}' and i @> '{}' $$), + ($$ j @> '{10}' and j @> '{}' and i @> '{}' $$), + ($$ i @> '{1}' and j @> '{10}' $$) + ) q(query), + lateral explain_query_json($$select * from t_gin_test_tbl where $$ || query) js, + lateral execute_text_query_index($$select string_agg((i, j)::text, ' ') from t_gin_test_tbl where $$ || query) res_index, + lateral execute_text_query_heap($$select string_agg((i, j)::text, ' ') from t_gin_test_tbl where $$ || query) res_heap +-- +FUNCTION: name="explain_query_json" function="explain_query_json" schema="" ctx=Call +FUNCTION: name="execute_text_query_index" function="execute_text_query_index" schema="" ctx=Call +FUNCTION: name="execute_text_query_heap" function="execute_text_query_heap" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) q(query), LATERAL explain_query_json('select * from t_gin_test_tbl..." +== 035 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 036 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 037 +-- truncate_limit: 100 +-- re-purpose t_gin_test_tbl to test scans involving posting trees +insert into t_gin_test_tbl select array[1, g, g/10], array[2, g, g/10] + from generate_series(1, 20000) g +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t_gin_test_tbl SELECT ... FROM generate_series(1, 20000) g" +== 038 +-- truncate_limit: 100 +select gin_clean_pending_list('t_gin_test_tbl_i_j_idx') is not null +-- +FUNCTION: name="gin_clean_pending_list" function="gin_clean_pending_list" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT gin_clean_pending_list('t_gin_test_tbl_i_j_idx') IS NOT NULL" +== 039 +-- truncate_limit: 100 +analyze t_gin_test_tbl +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t_gin_test_tbl" +== 040 +-- truncate_limit: 100 +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 041 +-- truncate_limit: 100 +set enable_bitmapscan = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 042 +-- truncate_limit: 100 +explain (costs off) +select count(*) from t_gin_test_tbl where j @> array[50] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM t_gin_test_tbl WHERE j @> ARRAY[50]" +== 043 +-- truncate_limit: 100 +select count(*) from t_gin_test_tbl where j @> array[50] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM t_gin_test_tbl WHERE j @> ARRAY[50]" +== 044 +-- truncate_limit: 100 +explain (costs off) +select count(*) from t_gin_test_tbl where j @> array[2] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM t_gin_test_tbl WHERE j @> ARRAY[2]" +== 045 +-- truncate_limit: 100 +select count(*) from t_gin_test_tbl where j @> array[2] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM t_gin_test_tbl WHERE j @> ARRAY[2]" +== 046 +-- truncate_limit: 100 +explain (costs off) +select count(*) from t_gin_test_tbl where j @> '{}'::int[] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM t_gin_test_tbl WHERE j @> '{}'::int[]" +== 047 +-- truncate_limit: 100 +select count(*) from t_gin_test_tbl where j @> '{}'::int[] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM t_gin_test_tbl WHERE j @> '{}'::int[]" +== 048 +-- truncate_limit: 100 +-- test vacuuming of posting trees +delete from t_gin_test_tbl where j @> array[2] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t_gin_test_tbl WHERE j @> ARRAY[2]" +== 049 +-- truncate_limit: 100 +vacuum t_gin_test_tbl +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM t_gin_test_tbl" +== 050 +-- truncate_limit: 100 +select count(*) from t_gin_test_tbl where j @> array[50] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM t_gin_test_tbl WHERE j @> ARRAY[50]" +== 051 +-- truncate_limit: 100 +select count(*) from t_gin_test_tbl where j @> array[2] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM t_gin_test_tbl WHERE j @> ARRAY[2]" +== 052 +-- truncate_limit: 100 +select count(*) from t_gin_test_tbl where j @> '{}'::int[] +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM t_gin_test_tbl WHERE j @> '{}'::int[]" +== 053 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 054 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 055 +-- truncate_limit: 100 +drop table t_gin_test_tbl +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t_gin_test_tbl" +== 056 +-- truncate_limit: 100 +-- test an unlogged table, mostly to get coverage of ginbuildempty +create unlogged table t_gin_test_tbl(i int4[], j int4[]) +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE t_gin_test_tbl (i int4[], j int4[])" +== 057 +-- truncate_limit: 100 +create index on t_gin_test_tbl using gin (i, j) +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON t_gin_test_tbl USING gin (i, j)" +== 058 +-- truncate_limit: 100 +insert into t_gin_test_tbl +values + (null, null), + ('{}', null), + ('{1}', '{2,3}') +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t_gin_test_tbl VALUES (NULL, NULL), ('{}', NULL), ('{1}', '{2,3}')" +== 059 +-- truncate_limit: 100 +drop table t_gin_test_tbl +-- +TABLE: name="t_gin_test_tbl" schema="" table="t_gin_test_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t_gin_test_tbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/gist.metadata.json b/parser/testdata/summary_truncate/postgres_regress/gist.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/gist.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/gist.test b/parser/testdata/summary_truncate/postgres_regress/gist.test new file mode 100644 index 0000000..a027d53 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/gist.test @@ -0,0 +1,708 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test GiST indexes. +|-- +-- There are other tests to test different GiST opclasses. This is for +-- testing GiST code itself. Vacuuming in particular. + +create table gist_point_tbl(id int4, p point) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gist_point_tbl (id int4, p point)" +== 002 +-- truncate_limit: 100 +create index gist_pointidx on gist_point_tbl using gist(p) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_pointidx ON gist_point_tbl USING gist (p)" +== 003 +-- truncate_limit: 100 +-- Verify the fillfactor and buffering options +create index gist_pointidx2 on gist_point_tbl using gist(p) with (buffering = on, fillfactor=50) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_pointidx2 ON gist_point_tbl USING gist (p) WITH (buffering=on, fillfactor=50)" +== 004 +-- truncate_limit: 100 +create index gist_pointidx3 on gist_point_tbl using gist(p) with (buffering = off) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_pointidx3 ON gist_point_tbl USING gist (p) WITH (buffering=off)" +== 005 +-- truncate_limit: 100 +create index gist_pointidx4 on gist_point_tbl using gist(p) with (buffering = auto) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_pointidx4 ON gist_point_tbl USING gist (p) WITH (buffering=auto)" +== 006 +-- truncate_limit: 100 +drop index gist_pointidx2, gist_pointidx3, gist_pointidx4 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX gist_pointidx2, gist_pointidx3, gist_pointidx4" +== 007 +-- truncate_limit: 100 +-- Make sure bad values are refused +create index gist_pointidx5 on gist_point_tbl using gist(p) with (buffering = invalid_value) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_pointidx5 ON gist_point_tbl USING gist (p) WITH (buffering=invalid_value)" +== 008 +-- truncate_limit: 100 +create index gist_pointidx5 on gist_point_tbl using gist(p) with (fillfactor=9) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_pointidx5 ON gist_point_tbl USING gist (p) WITH (fillfactor=9)" +== 009 +-- truncate_limit: 100 +create index gist_pointidx5 on gist_point_tbl using gist(p) with (fillfactor=101) +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_pointidx5 ON gist_point_tbl USING gist (p) WITH (fillfactor=101)" +== 010 +-- truncate_limit: 100 +-- Insert enough data to create a tree that's a couple of levels deep. +insert into gist_point_tbl (id, p) +select g, point(g*10, g*10) from generate_series(1, 10000) g +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gist_point_tbl (id, p) SELECT g, point(g * 10, g * 10) FROM generate_series(1, 10000) g" +== 011 +-- truncate_limit: 100 +insert into gist_point_tbl (id, p) +select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gist_point_tbl (id, p) SELECT ... FROM generate_series(1, 10000) g" +== 012 +-- truncate_limit: 100 +-- To test vacuum, delete some entries from all over the index. +delete from gist_point_tbl where id % 2 = 1 +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM gist_point_tbl WHERE (id % 2) = 1" +== 013 +-- truncate_limit: 100 +-- And also delete some concentration of values. +delete from gist_point_tbl where id > 5000 +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM gist_point_tbl WHERE id > 5000" +== 014 +-- truncate_limit: 100 +vacuum analyze gist_point_tbl +-- +TABLE: name="gist_point_tbl" schema="" table="gist_point_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) gist_point_tbl" +== 015 +-- truncate_limit: 100 +-- rebuild the index with a different fillfactor +alter index gist_pointidx SET (fillfactor = 40) +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX gist_pointidx SET (fillfactor=40)" +== 016 +-- truncate_limit: 100 +reindex index gist_pointidx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX gist_pointidx" +== 017 +-- truncate_limit: 100 +|-- +-- Test Index-only plans on GiST indexes +|-- + +create table gist_tbl (b box, p point, c circle) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE gist_tbl (b box, p point, c circle)" +== 018 +-- truncate_limit: 100 +insert into gist_tbl +select box(point(0.05*i, 0.05*i), point(0.05*i, 0.05*i)), + point(0.05*i, 0.05*i), + circle(point(0.05*i, 0.05*i), 1.0) +from generate_series(0,10000) as i +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gist_tbl SELECT ... FROM generate_series(0, 10000) i" +== 019 +-- truncate_limit: 100 +vacuum analyze gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) gist_tbl" +== 020 +-- truncate_limit: 100 +set enable_seqscan=off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 021 +-- truncate_limit: 100 +set enable_bitmapscan=off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 022 +-- truncate_limit: 100 +set enable_indexonlyscan=on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexonlyscan TO ON" +== 023 +-- truncate_limit: 100 +-- Test index-only scan with point opclass +create index gist_tbl_point_index on gist_tbl using gist (p) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_tbl_point_index ON gist_tbl USING gist (p)" +== 024 +-- truncate_limit: 100 +-- check that the planner chooses an index-only scan +explain (costs off) +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p FROM gist_tbl WHERE p <@ box(point(0, 0), point(0.5, 0.5))" +== 025 +-- truncate_limit: 100 +-- execute the same +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT p FROM gist_tbl WHERE p <@ box(point(0, 0), point(0.5, 0.5))" +== 026 +-- truncate_limit: 100 +-- Also test an index-only knn-search +explain (costs off) +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +order by p <-> point(0.201, 0.201) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p FROM gist_tbl WHERE p <@ box(point(0, 0), point(0.5, 0.5)) ORDER BY ..." +== 027 +-- truncate_limit: 100 +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +order by p <-> point(0.201, 0.201) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT p FROM gist_tbl WHERE ... ORDER BY p <-> point(0.201, 0.201)" +== 028 +-- truncate_limit: 100 +-- Check commuted case as well +explain (costs off) +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +order by point(0.101, 0.101) <-> p +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p FROM gist_tbl WHERE p <@ box(point(0, 0), point(0.5, 0.5)) ORDER BY ..." +== 029 +-- truncate_limit: 100 +select p from gist_tbl where p <@ box(point(0,0), point(0.5, 0.5)) +order by point(0.101, 0.101) <-> p +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT p FROM gist_tbl WHERE ... ORDER BY point(0.101, 0.101) <-> p" +== 030 +-- truncate_limit: 100 +-- Check case with multiple rescans (bug #14641) +explain (costs off) +select p from + (values (box(point(0,0), point(0.5,0.5))), + (box(point(0.5,0.5), point(0.75,0.75))), + (box(point(0.8,0.8), point(1.0,1.0)))) as v(bb) +cross join lateral + (select p from gist_tbl where p <@ bb order by p <-> bb[0] limit 2) ss +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +FILTER: schema="" table="" column="bb" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p FROM (VALUES (box(point(0, 0), point(0.5, 0.5))), (box(point(0.5, 0...." +== 031 +-- truncate_limit: 100 +select p from + (values (box(point(0,0), point(0.5,0.5))), + (box(point(0.5,0.5), point(0.75,0.75))), + (box(point(0.8,0.8), point(1.0,1.0)))) as v(bb) +cross join lateral + (select p from gist_tbl where p <@ bb order by p <-> bb[0] limit 2) ss +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +FILTER: schema="" table="" column="bb" +STMT: SelectStmt +TRUNCATED: "SELECT p FROM (VALUES (...)) v(bb) CROSS JOIN LATERAL (SELECT p FROM gist_tbl WHERE ... ORDER BY ..." +== 032 +-- truncate_limit: 100 +drop index gist_tbl_point_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX gist_tbl_point_index" +== 033 +-- truncate_limit: 100 +-- Test index-only scan with box opclass +create index gist_tbl_box_index on gist_tbl using gist (b) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_tbl_box_index ON gist_tbl USING gist (b)" +== 034 +-- truncate_limit: 100 +-- check that the planner chooses an index-only scan +explain (costs off) +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b FROM gist_tbl WHERE b <@ box(point(5, 5), point(6, 6))" +== 035 +-- truncate_limit: 100 +-- execute the same +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT b FROM gist_tbl WHERE b <@ box(point(5, 5), point(6, 6))" +== 036 +-- truncate_limit: 100 +-- Also test an index-only knn-search +explain (costs off) +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +order by b <-> point(5.2, 5.91) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b FROM gist_tbl WHERE b <@ box(point(5, 5), point(6, 6)) ORDER BY b <-..." +== 037 +-- truncate_limit: 100 +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +order by b <-> point(5.2, 5.91) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT b FROM gist_tbl WHERE b <@ box(point(5, 5), point(6, 6)) ORDER BY b <-> point(5.2, 5.91)" +== 038 +-- truncate_limit: 100 +-- Check commuted case as well +explain (costs off) +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +order by point(5.2, 5.91) <-> b +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b FROM gist_tbl WHERE b <@ box(point(5, 5), point(6, 6)) ORDER BY poin..." +== 039 +-- truncate_limit: 100 +select b from gist_tbl where b <@ box(point(5,5), point(6,6)) +order by point(5.2, 5.91) <-> b +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT b FROM gist_tbl WHERE b <@ box(point(5, 5), point(6, 6)) ORDER BY point(5.2, 5.91) <-> b" +== 040 +-- truncate_limit: 100 +drop index gist_tbl_box_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX gist_tbl_box_index" +== 041 +-- truncate_limit: 100 +-- Test that an index-only scan is not chosen, when the query involves the +-- circle column (the circle opclass does not support index-only scans). +create index gist_tbl_multi_index on gist_tbl using gist (p, c) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_tbl_multi_index ON gist_tbl USING gist (p, c)" +== 042 +-- truncate_limit: 100 +explain (costs off) +select p, c from gist_tbl +where p <@ box(point(5,5), point(6, 6)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p, c FROM gist_tbl WHERE p <@ box(point(5, 5), point(6, 6))" +== 043 +-- truncate_limit: 100 +-- execute the same +select b, p from gist_tbl +where b <@ box(point(4.5, 4.5), point(5.5, 5.5)) +and p <@ box(point(5,5), point(6, 6)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT b, p FROM gist_tbl WHERE ..." +== 044 +-- truncate_limit: 100 +drop index gist_tbl_multi_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX gist_tbl_multi_index" +== 045 +-- truncate_limit: 100 +-- Test that we don't try to return the value of a non-returnable +-- column in an index-only scan. (This isn't GIST-specific, but +-- it only applies to index AMs that can return some columns and not +-- others, so GIST with appropriate opclasses is a convenient test case.) +create index gist_tbl_multi_index on gist_tbl using gist (circle(p,1), p) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +FUNCTION: name="circle" function="circle" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_tbl_multi_index ON gist_tbl USING gist (circle(p, 1), p)" +== 046 +-- truncate_limit: 100 +explain (verbose, costs off) +select circle(p,1) from gist_tbl +where p <@ box(point(5, 5), point(5.3, 5.3)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT circle(p, 1) FROM gist_tbl WHERE p <@ box(point(5, 5), point(..." +== 047 +-- truncate_limit: 100 +select circle(p,1) from gist_tbl +where p <@ box(point(5, 5), point(5.3, 5.3)) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT circle(p, 1) FROM gist_tbl WHERE p <@ box(point(5, 5), point(5.3, 5.3))" +== 048 +-- truncate_limit: 100 +-- Similarly, test that index rechecks involving a non-returnable column +-- are done correctly. +explain (verbose, costs off) +select p from gist_tbl where circle(p,1) @> circle(point(0,0),0.95) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT p FROM gist_tbl WHERE circle(p, 1) @> circle(point(0, 0), 0.95)" +== 049 +-- truncate_limit: 100 +select p from gist_tbl where circle(p,1) @> circle(point(0,0),0.95) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT p FROM gist_tbl WHERE circle(p, 1) @> circle(point(0, 0), 0.95)" +== 050 +-- truncate_limit: 100 +-- Also check that use_physical_tlist doesn't trigger in such cases. +explain (verbose, costs off) +select count(*) from gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM gist_tbl" +== 051 +-- truncate_limit: 100 +select count(*) from gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM gist_tbl" +== 052 +-- truncate_limit: 100 +-- This case isn't supported, but it should at least EXPLAIN correctly. +explain (verbose, costs off) +select p from gist_tbl order by circle(p,1) <-> point(0,0) limit 1 +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT p FROM gist_tbl ORDER BY circle(p, 1) <-> point(0, 0) LIMIT 1" +== 053 +-- truncate_limit: 100 +select p from gist_tbl order by circle(p,1) <-> point(0,0) limit 1 +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=Select +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT p FROM gist_tbl ORDER BY circle(p, 1) <-> point(0, 0) LIMIT 1" +== 054 +-- truncate_limit: 100 +-- Force an index build using buffering. +create index gist_tbl_box_index_forcing_buffering on gist_tbl using gist (p) + with (buffering=on, fillfactor=50) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_tbl_box_index_forcing_buffering ON gist_tbl USING gist (p) WITH (buffering=on, ..." +== 055 +-- truncate_limit: 100 +-- Clean up +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 056 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 057 +-- truncate_limit: 100 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexonlyscan" +== 058 +-- truncate_limit: 100 +drop table gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gist_tbl" +== 059 +-- truncate_limit: 100 +-- test an unlogged table, mostly to get coverage of gistbuildempty +create unlogged table gist_tbl (b box) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE gist_tbl (b box)" +== 060 +-- truncate_limit: 100 +create index gist_tbl_box_index on gist_tbl using gist (b) +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_tbl_box_index ON gist_tbl USING gist (b)" +== 061 +-- truncate_limit: 100 +insert into gist_tbl + select box(point(0.05*i, 0.05*i)) from generate_series(0,10) as i +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gist_tbl SELECT box(point(0.05 * i, 0.05 * i)) FROM generate_series(0, 10) i" +== 062 +-- truncate_limit: 100 +drop table gist_tbl +-- +TABLE: name="gist_tbl" schema="" table="gist_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gist_tbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/groupingsets.metadata.json b/parser/testdata/summary_truncate/postgres_regress/groupingsets.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/groupingsets.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/groupingsets.test b/parser/testdata/summary_truncate/postgres_regress/groupingsets.test new file mode 100644 index 0000000..8add3f4 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/groupingsets.test @@ -0,0 +1,1749 @@ +== 001 +-- truncate_limit: 100 +|-- +-- grouping sets +|-- + +-- test data sources + +create temp view gstest1(a,b,v) + as values (1,1,10),(1,1,11),(1,2,12),(1,2,13),(1,3,14), + (2,3,15), + (3,3,16),(3,4,17), + (4,1,18),(4,1,19) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW gstest1 (a, b, v) AS VALUES (1, 1, 10), (1, 1, 11), (1, 2, 12), (1, 2, 13),..." +== 002 +-- truncate_limit: 100 +create temp table gstest2 (a integer, b integer, c integer, d integer, + e integer, f integer, g integer, h integer) +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE gstest2 (a int, b int, c int, d int, e int, f int, g int, h int)" +== 003 +-- truncate_limit: 100 +copy gstest2 from stdin +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY gstest2 FROM STDIN" +== 004 +-- truncate_limit: 100 +create temp table gstest3 (a integer, b integer, c integer, d integer) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE gstest3 (a int, b int, c int, d int)" +== 005 +-- truncate_limit: 100 +copy gstest3 from stdin +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY gstest3 FROM STDIN" +== 006 +-- truncate_limit: 100 +alter table gstest3 add primary key (a) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE gstest3 ADD PRIMARY KEY (a)" +== 007 +-- truncate_limit: 100 +create temp table gstest4(id integer, v integer, + unhashable_col bit(4), unsortable_col xid) +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE gstest4 (id int, v int, unhashable_col pg_catalog.bit(4), unsortable_col xid)" +== 008 +-- truncate_limit: 100 +insert into gstest4 +values (1,1,b'0000','1'), (2,2,b'0001','1'), + (3,4,b'0010','2'), (4,8,b'0011','2'), + (5,16,b'0000','2'), (6,32,b'0001','2'), + (7,64,b'0010','1'), (8,128,b'0011','1') +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO gstest4 VALUES (...)" +== 009 +-- truncate_limit: 100 +create temp table gstest_empty (a integer, b integer, v integer) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE gstest_empty (a int, b int, v int)" +== 010 +-- truncate_limit: 100 +create function gstest_data(v integer, out a integer, out b integer) + returns setof record + as $f$ + begin + return query select v, i from generate_series(1,3) i; + end; + $f$ language plpgsql +-- +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION gstest_data(v int, OUT a int, OUT b int) RETURNS SETOF record AS $$\n begin\n ..." +== 011 +-- truncate_limit: 100 +-- basic functionality + +set enable_hashagg = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 012 +-- truncate_limit: 100 +-- test hashing explicitly later + +-- simple rollup with multiple plain aggregates, with and without ordering +-- (and with ordering differing from grouping) + +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by rollup (a,b) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, GROUPING(a, b), sum(v), count(*), max(v) FROM gstest1 GROUP BY ROLLUP (a, b)" +== 013 +-- truncate_limit: 100 +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by rollup (a,b) order by a,b +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 GROUP BY ROLLUP (a, b) ORDER BY a, b" +== 014 +-- truncate_limit: 100 +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by rollup (a,b) order by b desc, a +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 GROUP BY ROLLUP (a, b) ORDER BY b DESC, a" +== 015 +-- truncate_limit: 100 +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by rollup (a,b) order by coalesce(a,0)+coalesce(b,0) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 GROUP BY ROLLUP (a, b) ORDER BY COALESCE(a, 0) + COALESCE(b, 0)" +== 016 +-- truncate_limit: 100 +-- various types of ordered aggs +select a, b, grouping(a,b), + array_agg(v order by v), + string_agg(v::text, ':' order by v desc), + percentile_disc(0.5) within group (order by v), + rank(1,2,12) within group (order by a,b,v) + from gstest1 group by rollup (a,b) order by a,b +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 GROUP BY ROLLUP (a, b) ORDER BY a, b" +== 017 +-- truncate_limit: 100 +-- test usage of grouped columns in direct args of aggs +select grouping(a), a, array_agg(b), + rank(a) within group (order by b nulls first), + rank(a) within group (order by b nulls last) + from (values (1,1),(1,4),(1,5),(3,1),(3,2)) v(a,b) + group by rollup (a) order by a +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a, b) GROUP BY ROLLUP (a) ORDER BY a" +== 018 +-- truncate_limit: 100 +-- nesting with window functions +select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum + from gstest2 group by rollup (a,b) order by rsum, a, b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY ROLLUP (a, b) ORDER BY rsum, a, b" +== 019 +-- truncate_limit: 100 +-- nesting with grouping sets +select sum(c) from gstest2 + group by grouping sets((), grouping sets((), grouping sets(()))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY GROUPING SETS ((), GROUPING SETS ((), GROUPING SETS (()))) ORDER..." +== 020 +-- truncate_limit: 100 +select sum(c) from gstest2 + group by grouping sets((), grouping sets((), grouping sets(((a, b))))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY GROUPING SETS ((), GROUPING SETS ((), GROUPING SETS ((a, b)))) O..." +== 021 +-- truncate_limit: 100 +select sum(c) from gstest2 + group by grouping sets(grouping sets(rollup(c), grouping sets(cube(c)))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY GROUPING SETS (GROUPING SETS (ROLLUP (c), GROUPING SETS (CUBE (c..." +== 022 +-- truncate_limit: 100 +select sum(c) from gstest2 + group by grouping sets(a, grouping sets(a, cube(b))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(c) FROM gstest2 GROUP BY GROUPING SETS (a, GROUPING SETS (a, CUBE (b))) ORDER BY 1 DESC" +== 023 +-- truncate_limit: 100 +select sum(c) from gstest2 + group by grouping sets(grouping sets((a, (b)))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(c) FROM gstest2 GROUP BY GROUPING SETS (GROUPING SETS ((a, b))) ORDER BY 1 DESC" +== 024 +-- truncate_limit: 100 +select sum(c) from gstest2 + group by grouping sets(grouping sets((a, b))) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(c) FROM gstest2 GROUP BY GROUPING SETS (GROUPING SETS ((a, b))) ORDER BY 1 DESC" +== 025 +-- truncate_limit: 100 +select sum(c) from gstest2 + group by grouping sets(grouping sets(a, grouping sets(a), a)) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY GROUPING SETS (GROUPING SETS (a, GROUPING SETS (a), a)) ORDER BY..." +== 026 +-- truncate_limit: 100 +select sum(c) from gstest2 + group by grouping sets(grouping sets(a, grouping sets(a, grouping sets(a), ((a)), a, grouping sets(a), (a)), a)) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY GROUPING SETS (GROUPING SETS (a, GROUPING SETS (a, GROUPING SETS..." +== 027 +-- truncate_limit: 100 +select sum(c) from gstest2 + group by grouping sets((a,(a,b)), grouping sets((a,(a,b)),a)) + order by 1 desc +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY GROUPING SETS ((a, (a, b)), GROUPING SETS ((a, (a, b)), a)) ORDE..." +== 028 +-- truncate_limit: 100 +-- empty input: first is 0 rows, second 1, third 3 etc. +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),a) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((a, b), a)" +== 029 +-- truncate_limit: 100 +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((a, b), ())" +== 030 +-- truncate_limit: 100 +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),(),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((a, b), (), (), ())" +== 031 +-- truncate_limit: 100 +select sum(v), count(*) from gstest_empty group by grouping sets ((),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((), (), ())" +== 032 +-- truncate_limit: 100 +-- empty input with joins tests some important code paths +select t1.a, t2.b, sum(t1.v), count(*) from gstest_empty t1, gstest_empty t2 + group by grouping sets ((t1.a,t2.b),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +ALIAS: "t1"="gstest_empty" +ALIAS: "t2"="gstest_empty" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest_empty t1, gstest_empty t2 GROUP BY GROUPING SETS ((t1.a, t2.b), ())" +== 033 +-- truncate_limit: 100 +-- simple joins, var resolution, GROUPING on join vars +select t1.a, t2.b, grouping(t1.a, t2.b), sum(t1.v), max(t2.a) + from gstest1 t1, gstest2 t2 + group by grouping sets ((t1.a, t2.b), ()) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +ALIAS: "t1"="gstest1" +ALIAS: "t2"="gstest2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 t1, gstest2 t2 GROUP BY GROUPING SETS ((t1.a, t2.b), ())" +== 034 +-- truncate_limit: 100 +select t1.a, t2.b, grouping(t1.a, t2.b), sum(t1.v), max(t2.a) + from gstest1 t1 join gstest2 t2 on (t1.a=t2.a) + group by grouping sets ((t1.a, t2.b), ()) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +ALIAS: "t1"="gstest1" +ALIAS: "t2"="gstest2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 t1 JOIN gstest2 t2 ON t1.a = t2.a GROUP BY GROUPING SETS ((t1.a, t2.b), ())" +== 035 +-- truncate_limit: 100 +select a, b, grouping(a, b), sum(t1.v), max(t2.c) + from gstest1 t1 join gstest2 t2 using (a,b) + group by grouping sets ((a, b), ()) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +ALIAS: "t1"="gstest1" +ALIAS: "t2"="gstest2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 t1 JOIN gstest2 t2 USING (a, b) GROUP BY GROUPING SETS ((a, b), ())" +== 036 +-- truncate_limit: 100 +-- check that functionally dependent cols are not nulled +select a, d, grouping(a,b,c) + from gstest3 + group by grouping sets ((a,b), (a,c)) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, d, GROUPING(a, b, c) FROM gstest3 GROUP BY GROUPING SETS ((a, b), (a, c))" +== 037 +-- truncate_limit: 100 +-- check that distinct grouping columns are kept separate +-- even if they are equal() +explain (costs off) +select g as alias1, g as alias2 + from generate_series(1,3) g + group by alias1, rollup(alias2) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT g AS alias1, g AS alias2 FROM generate_series(1, 3) g GROUP BY alias1,..." +== 038 +-- truncate_limit: 100 +select g as alias1, g as alias2 + from generate_series(1,3) g + group by alias1, rollup(alias2) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT g AS alias1, g AS alias2 FROM generate_series(1, 3) g GROUP BY alias1, ROLLUP (alias2)" +== 039 +-- truncate_limit: 100 +-- check that pulled-up subquery outputs still go to null when appropriate +select four, x + from (select four, ten, 'foo'::text as x from tenk1) as t + group by grouping sets (four, x) + having x = 'foo' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT four, x FROM (SELECT ... FROM tenk1) t GROUP BY GROUPING SETS (four, x) HAVING x = 'foo'" +== 040 +-- truncate_limit: 100 +select four, x || 'x' + from (select four, ten, 'foo'::text as x from tenk1) as t + group by grouping sets (four, x) + order by four +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT four, x || 'x' FROM (SELECT ... FROM tenk1) t GROUP BY GROUPING SETS (four, x) ORDER BY four" +== 041 +-- truncate_limit: 100 +select (x+y)*1, sum(z) + from (select 1 as x, 2 as y, 3 as z) s + group by grouping sets (x+y, x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (x + y) * 1, sum(z) FROM (SELECT 1 AS x, 2 AS y, 3 AS z) s GROUP BY GROUPING SETS (x + y, x)" +== 042 +-- truncate_limit: 100 +select x, not x as not_x, q2 from + (select *, q1 = 1 as x from int8_tbl i1) as t + group by grouping sets(x, q2) + order by x, q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM int8_tbl i1) t GROUP BY GROUPING SETS (x, q2) ORDER BY x, q2" +== 043 +-- truncate_limit: 100 +-- check qual push-down rules for a subquery with grouping sets +explain (verbose, costs off) +select * from ( + select 1 as x, q1, sum(q2) + from int8_tbl i1 + group by grouping sets(1, 2) +) ss +where x = 1 and q1 = 123 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (SELECT 1 AS x, q1, sum(q2) FROM int8_tbl i1 GROUP BY ..." +== 044 +-- truncate_limit: 100 +select * from ( + select 1 as x, q1, sum(q2) + from int8_tbl i1 + group by grouping sets(1, 2) +) ss +where x = 1 and q1 = 123 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM int8_tbl i1 GROUP BY GROUPING SETS (1, 2)) ss WHERE ..." +== 045 +-- truncate_limit: 100 +-- check handling of pulled-up SubPlan in GROUPING() argument (bug #17479) +explain (verbose, costs off) +select grouping(ss.x) +from int8_tbl i1 +cross join lateral (select (select i1.q1) as x) ss +group by ss.x +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT GROUPING(ss.x) FROM int8_tbl i1 CROSS JOIN LATERAL (SELECT (S..." +== 046 +-- truncate_limit: 100 +select grouping(ss.x) +from int8_tbl i1 +cross join lateral (select (select i1.q1) as x) ss +group by ss.x +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT GROUPING(ss.x) FROM int8_tbl i1 CROSS JOIN LATERAL (SELECT ...) ss GROUP BY ss.x" +== 047 +-- truncate_limit: 100 +explain (verbose, costs off) +select (select grouping(ss.x)) +from int8_tbl i1 +cross join lateral (select (select i1.q1) as x) ss +group by ss.x +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT (SELECT GROUPING(ss.x)) FROM int8_tbl i1 CROSS JOIN LATERAL (..." +== 048 +-- truncate_limit: 100 +select (select grouping(ss.x)) +from int8_tbl i1 +cross join lateral (select (select i1.q1) as x) ss +group by ss.x +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT GROUPING(ss.x)) FROM int8_tbl i1 CROSS JOIN LATERAL (SELECT ...) ss GROUP BY ss.x" +== 049 +-- truncate_limit: 100 +-- simple rescan tests + +select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by rollup (a,b) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v.x) FROM (VALUES (1), (2)) v(x), gstest_data(v.x) GROUP BY ROLLUP (a, b)" +== 050 +-- truncate_limit: 100 +select * + from (values (1),(2)) v(x), + lateral (select a, b, sum(v.x) from gstest_data(v.x) group by rollup (a,b)) s +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(x), LATERAL (SELECT ... FROM gstest_data(v.x) GROUP BY ROLLUP (a, ..." +== 051 +-- truncate_limit: 100 +-- min max optimization should still work with GROUP BY () +explain (costs off) + select min(unique1) from tenk1 GROUP BY () +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT min(unique1) FROM tenk1 GROUP BY ()" +== 052 +-- truncate_limit: 100 +-- Views with GROUPING SET queries +CREATE VIEW gstest_view AS select a, b, grouping(a,b), sum(c), count(*), max(c) + from gstest2 group by rollup ((a,b,c),(c,d)) +-- +TABLE: name="gstest_view" schema="" table="gstest_view" ctx=DDL +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW gstest_view AS SELECT a, b, GROUPING(a, b), sum(c), count(*), max(c) FROM gstest2 GRO..." +== 053 +-- truncate_limit: 100 +select pg_get_viewdef('gstest_view'::regclass, true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('gstest_view'::regclass, true)" +== 054 +-- truncate_limit: 100 +-- Nested queries with 3 or more levels of nesting +select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v3(e, f) GROUP BY ROLLUP (e, f)" +== 055 +-- truncate_limit: 100 +select(select (select grouping(e,f) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v3(e, f) GROUP BY ROLLUP (e, f)" +== 056 +-- truncate_limit: 100 +select(select (select grouping(c) from (values (1)) v2(c) GROUP BY c) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP(e,f) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v3(e, f) GROUP BY ROLLUP (e, f)" +== 057 +-- truncate_limit: 100 +-- Combinations of operations +select a, b, c, d from gstest2 group by rollup(a,b),grouping sets(c,d) +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c, d FROM gstest2 GROUP BY ROLLUP (a, b), GROUPING SETS (c, d)" +== 058 +-- truncate_limit: 100 +select a, b from (values (1,2),(2,3)) v(a,b) group by a,b, grouping sets(a) +-- +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM (VALUES (1, 2), (2, 3)) v(a, b) GROUP BY a, b, GROUPING SETS (a)" +== 059 +-- truncate_limit: 100 +-- Tests for chained aggregates +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a,b),(a+1,b+1),(a+2,b+2)) order by 3,6 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 GROUP BY GROUPING SETS ((a, b), (a + 1, b + 1), (a + 2, b + 2)) ORDER BY ..." +== 060 +-- truncate_limit: 100 +select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY ROLLUP((e+1),(f+1)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v3(e, f) GROUP BY ROLLUP (e + 1, f + 1)" +== 061 +-- truncate_limit: 100 +select(select (select grouping(a,b) from (values (1)) v2(c)) from (values (1,2)) v1(a,b) group by (a,b)) from (values(6,7)) v3(e,f) GROUP BY CUBE((e+1),(f+1)) ORDER BY (e+1),(f+1) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v3(e, f) GROUP BY CUBE (e + 1, f + 1) ORDER BY e + 1, f + 1" +== 062 +-- truncate_limit: 100 +select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum + from gstest2 group by cube (a,b) order by rsum, a, b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY CUBE (a, b) ORDER BY rsum, a, b" +== 063 +-- truncate_limit: 100 +select a, b, sum(c) from (values (1,1,10),(1,1,11),(1,2,12),(1,2,13),(1,3,14),(2,3,15),(3,3,16),(3,4,17),(4,1,18),(4,1,19)) v(a,b,c) group by rollup (a,b) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(c) FROM (VALUES (...)) v(a, b, c) GROUP BY ROLLUP (a, b)" +== 064 +-- truncate_limit: 100 +select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by cube (a,b) order by a,b +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v.x) FROM (VALUES (...)) v(x), gstest_data(v.x) GROUP BY CUBE (a, b) ORDER BY a, b" +== 065 +-- truncate_limit: 100 +-- Test reordering of grouping sets +explain (costs off) +select * from gstest1 group by grouping sets((a,b,v),(v)) order by v,b,a +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM gstest1 GROUP BY GROUPING SETS ((a, b, v), v) ORDER BY v, b, a" +== 066 +-- truncate_limit: 100 +-- Agg level check. This query should error out. +select (select grouping(a,b) from gstest2) from gstest2 group by a,b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT GROUPING(a, b) FROM gstest2) FROM gstest2 GROUP BY a, b" +== 067 +-- truncate_limit: 100 +--Nested queries +select a, b, sum(c), count(*) from gstest2 group by grouping sets (rollup(a,b),a) +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(c), count(*) FROM gstest2 GROUP BY GROUPING SETS (ROLLUP (a, b), a)" +== 068 +-- truncate_limit: 100 +-- HAVING queries +select ten, sum(distinct four) from onek a +group by grouping sets((ten,four),(ten)) +having exists (select 1 from onek b where sum(distinct a.four) = b.four) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="a" column="four" +FILTER: schema="" table="b" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek a GROUP BY GROUPING SETS ((ten, four), ten) HAVING EXISTS (SELECT 1 FROM one..." +== 069 +-- truncate_limit: 100 +-- Tests around pushdown of HAVING clauses, partially testing against previous bugs +select a,count(*) from gstest2 group by rollup(a) order by a +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, count(*) FROM gstest2 GROUP BY ROLLUP (a) ORDER BY a" +== 070 +-- truncate_limit: 100 +select a,count(*) from gstest2 group by rollup(a) having a is distinct from 1 order by a +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, count(*) FROM gstest2 GROUP BY ROLLUP (a) HAVING a IS DISTINCT FROM 1 ORDER BY a" +== 071 +-- truncate_limit: 100 +explain (costs off) + select a,count(*) from gstest2 group by rollup(a) having a is distinct from 1 order by a +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, count(*) FROM gstest2 GROUP BY ROLLUP (a) HAVING a IS DISTINCT FROM..." +== 072 +-- truncate_limit: 100 +select v.c, (select count(*) from gstest2 group by () having v.c) + from (values (false),(true)) v(c) order by v.c +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v.c, (SELECT ... FROM gstest2 GROUP BY () HAVING v.c) FROM (VALUES (...)) v(c) ORDER BY v.c" +== 073 +-- truncate_limit: 100 +explain (costs off) + select v.c, (select count(*) from gstest2 group by () having v.c) + from (values (false),(true)) v(c) order by v.c +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT v.c, (SELECT count(*) FROM gstest2 GROUP BY () HAVING v.c) FROM (VALUE..." +== 074 +-- truncate_limit: 100 +-- HAVING with GROUPING queries +select ten, grouping(ten) from onek +group by grouping sets(ten) having grouping(ten) >= 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek GROUP BY GROUPING SETS (ten) HAVING GROUPING(ten) >= 0 ORDER BY 2, 1" +== 075 +-- truncate_limit: 100 +select ten, grouping(ten) from onek +group by grouping sets(ten, four) having grouping(ten) > 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek GROUP BY GROUPING SETS (ten, four) HAVING GROUPING(ten) > 0 ORDER BY 2, 1" +== 076 +-- truncate_limit: 100 +select ten, grouping(ten) from onek +group by rollup(ten) having grouping(ten) > 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ten, GROUPING(ten) FROM onek GROUP BY ROLLUP (ten) HAVING GROUPING(ten) > 0 ORDER BY 2, 1" +== 077 +-- truncate_limit: 100 +select ten, grouping(ten) from onek +group by cube(ten) having grouping(ten) > 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ten, GROUPING(ten) FROM onek GROUP BY CUBE (ten) HAVING GROUPING(ten) > 0 ORDER BY 2, 1" +== 078 +-- truncate_limit: 100 +select ten, grouping(ten) from onek +group by (ten) having grouping(ten) >= 0 +order by 2,1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ten, GROUPING(ten) FROM onek GROUP BY ten HAVING GROUPING(ten) >= 0 ORDER BY 2, 1" +== 079 +-- truncate_limit: 100 +-- FILTER queries +select ten, sum(distinct four) filter (where four::text ~ '123') from onek a +group by rollup(ten) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ten, sum(DISTINCT four) FILTER (WHERE four::text ~ '123') FROM onek a GROUP BY ROLLUP (ten)" +== 080 +-- truncate_limit: 100 +-- More rescan tests +select * from (values (1),(2)) v(a) left join lateral (select v.a, four, ten, count(*) from onek group by cube(four,ten)) s on true order by v.a,four,ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(a) LEFT JOIN LATERAL (SELECT ... FROM onek GROUP BY CUBE (four, te..." +== 081 +-- truncate_limit: 100 +select array(select row(v.a,s1.*) from (select two,four, count(*) from onek group by cube(two,four) order by two,four) s1) from (values (1),(2)) v(a) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a)" +== 082 +-- truncate_limit: 100 +-- Grouping on text columns +select sum(ten) from onek group by two, rollup(four::text) order by 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(ten) FROM onek GROUP BY two, ROLLUP (four::text) ORDER BY 1" +== 083 +-- truncate_limit: 100 +select sum(ten) from onek group by rollup(four::text), two order by 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(ten) FROM onek GROUP BY ROLLUP (four::text), two ORDER BY 1" +== 084 +-- truncate_limit: 100 +-- hashing support + +set enable_hashagg = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO TRUE" +== 085 +-- truncate_limit: 100 +-- failure cases + +select count(*) from gstest4 group by rollup(unhashable_col,unsortable_col) +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM gstest4 GROUP BY ROLLUP (unhashable_col, unsortable_col)" +== 086 +-- truncate_limit: 100 +select array_agg(v order by v) from gstest4 group by grouping sets ((id,unsortable_col),(id)) +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_agg(v ORDER BY v) FROM gstest4 GROUP BY GROUPING SETS ((id, unsortable_col), id)" +== 087 +-- truncate_limit: 100 +-- simple cases + +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a),(b)) order by 3,1,2 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 GROUP BY GROUPING SETS (a, b) ORDER BY 3, 1, 2" +== 088 +-- truncate_limit: 100 +explain (costs off) select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a),(b)) order by 3,1,2 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, GROUPING(a, b), sum(v), count(*), max(v) FROM gstest1 GROUP BY G..." +== 089 +-- truncate_limit: 100 +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by cube(a,b) order by 3,1,2 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 GROUP BY CUBE (a, b) ORDER BY 3, 1, 2" +== 090 +-- truncate_limit: 100 +explain (costs off) select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by cube(a,b) order by 3,1,2 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, GROUPING(a, b), sum(v), count(*), max(v) FROM gstest1 GROUP BY C..." +== 091 +-- truncate_limit: 100 +-- shouldn't try and hash +explain (costs off) + select a, b, grouping(a,b), array_agg(v order by v) + from gstest1 group by cube(a,b) +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, GROUPING(a, b), array_agg(v ORDER BY v) FROM gstest1 GROUP BY CU..." +== 092 +-- truncate_limit: 100 +-- unsortable cases +select unsortable_col, count(*) + from gstest4 group by grouping sets ((unsortable_col),(unsortable_col)) + order by unsortable_col::text +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest4 GROUP BY GROUPING SETS (unsortable_col, unsortable_col) ORDER BY unsortab..." +== 093 +-- truncate_limit: 100 +-- mixed hashable/sortable cases +select unhashable_col, unsortable_col, + grouping(unhashable_col, unsortable_col), + count(*), sum(v) + from gstest4 group by grouping sets ((unhashable_col),(unsortable_col)) + order by 3, 5 +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest4 GROUP BY GROUPING SETS (unhashable_col, unsortable_col) ORDER BY 3, 5" +== 094 +-- truncate_limit: 100 +explain (costs off) + select unhashable_col, unsortable_col, + grouping(unhashable_col, unsortable_col), + count(*), sum(v) + from gstest4 group by grouping sets ((unhashable_col),(unsortable_col)) + order by 3,5 +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unhashable_col, unsortable_col, GROUPING(unhashable_col, unsortable_co..." +== 095 +-- truncate_limit: 100 +select unhashable_col, unsortable_col, + grouping(unhashable_col, unsortable_col), + count(*), sum(v) + from gstest4 group by grouping sets ((v,unhashable_col),(v,unsortable_col)) + order by 3,5 +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest4 GROUP BY GROUPING SETS ((v, unhashable_col), (v, unsortable_col)) ORDER B..." +== 096 +-- truncate_limit: 100 +explain (costs off) + select unhashable_col, unsortable_col, + grouping(unhashable_col, unsortable_col), + count(*), sum(v) + from gstest4 group by grouping sets ((v,unhashable_col),(v,unsortable_col)) + order by 3,5 +-- +TABLE: name="gstest4" schema="" table="gstest4" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unhashable_col, unsortable_col, GROUPING(unhashable_col, unsortable_co..." +== 097 +-- truncate_limit: 100 +-- empty input: first is 0 rows, second 1, third 3 etc. +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),a) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((a, b), a)" +== 098 +-- truncate_limit: 100 +explain (costs off) + select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),a) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((a, b..." +== 099 +-- truncate_limit: 100 +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((a, b), ())" +== 100 +-- truncate_limit: 100 +select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),(),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((a, b), (), (), ())" +== 101 +-- truncate_limit: 100 +explain (costs off) + select a, b, sum(v), count(*) from gstest_empty group by grouping sets ((a,b),(),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((a, b..." +== 102 +-- truncate_limit: 100 +select sum(v), count(*) from gstest_empty group by grouping sets ((),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((), (), ())" +== 103 +-- truncate_limit: 100 +explain (costs off) + select sum(v), count(*) from gstest_empty group by grouping sets ((),(),()) +-- +TABLE: name="gstest_empty" schema="" table="gstest_empty" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(v), count(*) FROM gstest_empty GROUP BY GROUPING SETS ((), (), ())" +== 104 +-- truncate_limit: 100 +-- check that functionally dependent cols are not nulled +select a, d, grouping(a,b,c) + from gstest3 + group by grouping sets ((a,b), (a,c)) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, d, GROUPING(a, b, c) FROM gstest3 GROUP BY GROUPING SETS ((a, b), (a, c))" +== 105 +-- truncate_limit: 100 +explain (costs off) + select a, d, grouping(a,b,c) + from gstest3 + group by grouping sets ((a,b), (a,c)) +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, d, GROUPING(a, b, c) FROM gstest3 GROUP BY GROUPING SETS ((a, b), (..." +== 106 +-- truncate_limit: 100 +-- simple rescan tests + +select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by grouping sets (a,b) + order by 1, 2, 3 +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(x), gstest_data(v.x) GROUP BY GROUPING SETS (a, b) ORDER BY 1, 2, 3" +== 107 +-- truncate_limit: 100 +explain (costs off) + select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by grouping sets (a,b) + order by 3, 1, 2 +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, sum(v.x) FROM (VALUES (1), (2)) v(x), gstest_data(v.x) GROUP BY ..." +== 108 +-- truncate_limit: 100 +select * + from (values (1),(2)) v(x), + lateral (select a, b, sum(v.x) from gstest_data(v.x) group by grouping sets (a,b)) s +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(x), LATERAL (SELECT ... FROM gstest_data(v.x) GROUP BY GROUPING SE..." +== 109 +-- truncate_limit: 100 +explain (costs off) + select * + from (values (1),(2)) v(x), + lateral (select a, b, sum(v.x) from gstest_data(v.x) group by grouping sets (a,b)) s +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (VALUES (1), (2)) v(x), LATERAL (SELECT a, b, sum(v.x) FROM gst..." +== 110 +-- truncate_limit: 100 +-- Tests for chained aggregates +select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a,b),(a+1,b+1),(a+2,b+2)) order by 3,6 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest1 GROUP BY GROUPING SETS ((a, b), (a + 1, b + 1), (a + 2, b + 2)) ORDER BY ..." +== 111 +-- truncate_limit: 100 +explain (costs off) + select a, b, grouping(a,b), sum(v), count(*), max(v) + from gstest1 group by grouping sets ((a,b),(a+1,b+1),(a+2,b+2)) order by 3,6 +-- +TABLE: name="gstest1" schema="" table="gstest1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, GROUPING(a, b), sum(v), count(*), max(v) FROM gstest1 GROUP BY G..." +== 112 +-- truncate_limit: 100 +select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum + from gstest2 group by cube (a,b) order by rsum, a, b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM gstest2 GROUP BY CUBE (a, b) ORDER BY rsum, a, b" +== 113 +-- truncate_limit: 100 +explain (costs off) + select a, b, sum(c), sum(sum(c)) over (order by a,b) as rsum + from gstest2 group by cube (a,b) order by rsum, a, b +-- +TABLE: name="gstest2" schema="" table="gstest2" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, sum(c), sum(sum(c)) OVER (ORDER BY a, b) AS rsum FROM gstest2 GR..." +== 114 +-- truncate_limit: 100 +select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by cube (a,b) order by a,b +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, sum(v.x) FROM (VALUES (...)) v(x), gstest_data(v.x) GROUP BY CUBE (a, b) ORDER BY a, b" +== 115 +-- truncate_limit: 100 +explain (costs off) + select a, b, sum(v.x) + from (values (1),(2)) v(x), gstest_data(v.x) + group by cube (a,b) order by a,b +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="gstest_data" function="gstest_data" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, sum(v.x) FROM (VALUES (1), (2)) v(x), gstest_data(v.x) GROUP BY ..." +== 116 +-- truncate_limit: 100 +-- Verify that we correctly handle the child node returning a +-- non-minimal slot, which happens if the input is pre-sorted, +-- e.g. due to an index scan. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 117 +-- truncate_limit: 100 +SET LOCAL enable_hashagg = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_hashagg TO FALSE" +== 118 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS (a,..." +== 119 +-- truncate_limit: 100 +SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS (a, b, ()) ORDER BY a, b" +== 120 +-- truncate_limit: 100 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO FALSE" +== 121 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS (a,..." +== 122 +-- truncate_limit: 100 +SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b +-- +TABLE: name="gstest3" schema="" table="gstest3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS (a, b, ()) ORDER BY a, b" +== 123 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 124 +-- truncate_limit: 100 +-- More rescan tests +select * from (values (1),(2)) v(a) left join lateral (select v.a, four, ten, count(*) from onek group by cube(four,ten)) s on true order by v.a,four,ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(a) LEFT JOIN LATERAL (SELECT ... FROM onek GROUP BY CUBE (four, te..." +== 125 +-- truncate_limit: 100 +select array(select row(v.a,s1.*) from (select two,four, count(*) from onek group by cube(two,four) order by two,four) s1) from (values (1),(2)) v(a) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a)" +== 126 +-- truncate_limit: 100 +-- Rescan logic changes when there are no empty grouping sets, so test +-- that too: +select * from (values (1),(2)) v(a) left join lateral (select v.a, four, ten, count(*) from onek group by grouping sets(four,ten)) s on true order by v.a,four,ten +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(a) LEFT JOIN LATERAL (SELECT ... FROM onek GROUP BY GROUPING SETS ..." +== 127 +-- truncate_limit: 100 +select array(select row(v.a,s1.*) from (select two,four, count(*) from onek group by grouping sets(two,four) order by two,four) s1) from (values (1),(2)) v(a) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(a)" +== 128 +-- truncate_limit: 100 +-- test the knapsack + +set enable_indexscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO FALSE" +== 129 +-- truncate_limit: 100 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET hash_mem_multiplier TO 1.0" +== 130 +-- truncate_limit: 100 +set work_mem = '64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 131 +-- truncate_limit: 100 +explain (costs off) + select unique1, + count(two), count(four), count(ten), + count(hundred), count(thousand), count(twothousand), + count(*) + from tenk1 group by grouping sets (unique1,twothousand,thousand,hundred,ten,four,two) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, count(two), count(four), count(ten), count(hundred), count(th..." +== 132 +-- truncate_limit: 100 +explain (costs off) + select unique1, + count(two), count(four), count(ten), + count(hundred), count(thousand), count(twothousand), + count(*) + from tenk1 group by grouping sets (unique1,hundred,ten,four,two) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, count(two), count(four), count(ten), count(hundred), count(th..." +== 133 +-- truncate_limit: 100 +set work_mem = '384kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"384kB\"" +== 134 +-- truncate_limit: 100 +explain (costs off) + select unique1, + count(two), count(four), count(ten), + count(hundred), count(thousand), count(twothousand), + count(*) + from tenk1 group by grouping sets (unique1,twothousand,thousand,hundred,ten,four,two) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, count(two), count(four), count(ten), count(hundred), count(th..." +== 135 +-- truncate_limit: 100 +-- check collation-sensitive matching between grouping expressions +-- (similar to a check for aggregates, but there are additional code +-- paths for GROUPING, so check again here) + +select v||'a', case grouping(v||'a') when 1 then 1 else 0 end, count(*) + from unnest(array[1,1], array['a','b']) u(i,v) + group by rollup(i, v||'a') order by 1,3 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY[1, 1], ARRAY['a', 'b']) u(i, v) GROUP BY ROLLUP (i, v || 'a') ORDER ..." +== 136 +-- truncate_limit: 100 +select v||'a', case when grouping(v||'a') = 1 then 1 else 0 end, count(*) + from unnest(array[1,1], array['a','b']) u(i,v) + group by rollup(i, v||'a') order by 1,3 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY[1, 1], ARRAY['a', 'b']) u(i, v) GROUP BY ROLLUP (i, v || 'a') ORDER ..." +== 137 +-- truncate_limit: 100 +-- Bug #16784 +create table bug_16784(i int, j int) +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bug_16784 (i int, j int)" +== 138 +-- truncate_limit: 100 +analyze bug_16784 +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE bug_16784" +== 139 +-- truncate_limit: 100 +alter table bug_16784 set (autovacuum_enabled = 'false') +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bug_16784 SET (autovacuum_enabled=false)" +== 140 +-- truncate_limit: 100 +update pg_class set reltuples = 10 where relname='bug_16784' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pg_class SET reltuples = 10 WHERE relname = 'bug_16784'" +== 141 +-- truncate_limit: 100 +insert into bug_16784 select g/10, g from generate_series(1,40) g +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bug_16784 SELECT g / 10, g FROM generate_series(1, 40) g" +== 142 +-- truncate_limit: 100 +set work_mem='64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 143 +-- truncate_limit: 100 +set enable_sort = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO FALSE" +== 144 +-- truncate_limit: 100 +select * from + (values (1),(2)) v(a), + lateral (select a, i, j, count(*) from + bug_16784 group by cube(i,j)) s + order by v.a, i, j +-- +TABLE: name="bug_16784" schema="" table="bug_16784" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(a), LATERAL (SELECT ... FROM bug_16784 GROUP BY CUBE (i, j)) s ORD..." +== 145 +-- truncate_limit: 100 +|-- +-- Compare results between plans using sorting and plans using hash +-- aggregation. Force spilling in both cases by setting work_mem low +-- and altering the statistics. +|-- + +create table gs_data_1 as +select g%1000 as g1000, g%100 as g100, g%10 as g10, g + from generate_series(0,1999) g +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE gs_data_1 AS SELECT g % 1000 AS g1000, g % 100 AS g100, g % 10 AS g10, g FROM genera..." +== 146 +-- truncate_limit: 100 +analyze gs_data_1 +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE gs_data_1" +== 147 +-- truncate_limit: 100 +alter table gs_data_1 set (autovacuum_enabled = 'false') +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE gs_data_1 SET (autovacuum_enabled=false)" +== 148 +-- truncate_limit: 100 +update pg_class set reltuples = 10 where relname='gs_data_1' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pg_class SET reltuples = 10 WHERE relname = 'gs_data_1'" +== 149 +-- truncate_limit: 100 +set work_mem='64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 150 +-- truncate_limit: 100 +-- Produce results with sorting. + +set enable_sort = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO TRUE" +== 151 +-- truncate_limit: 100 +set enable_hashagg = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 152 +-- truncate_limit: 100 +set jit_above_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO 0" +== 153 +-- truncate_limit: 100 +explain (costs off) +select g100, g10, sum(g::numeric), count(*), max(g::text) +from gs_data_1 group by cube (g1000, g100,g10) +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT g100, g10, sum(g::numeric), count(*), max(g::text) FROM gs_data_1 GROU..." +== 154 +-- truncate_limit: 100 +create table gs_group_1 as +select g100, g10, sum(g::numeric), count(*), max(g::text) +from gs_data_1 group by cube (g1000, g100,g10) +-- +TABLE: name="gs_group_1" schema="" table="gs_group_1" ctx=DDL +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE gs_group_1 AS SELECT g100, g10, sum(g::numeric), count(*), max(g::text) FROM gs_data..." +== 155 +-- truncate_limit: 100 +-- Produce results with hash aggregation. + +set enable_hashagg = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO TRUE" +== 156 +-- truncate_limit: 100 +set enable_sort = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO FALSE" +== 157 +-- truncate_limit: 100 +explain (costs off) +select g100, g10, sum(g::numeric), count(*), max(g::text) +from gs_data_1 group by cube (g1000, g100,g10) +-- +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT g100, g10, sum(g::numeric), count(*), max(g::text) FROM gs_data_1 GROU..." +== 158 +-- truncate_limit: 100 +create table gs_hash_1 as +select g100, g10, sum(g::numeric), count(*), max(g::text) +from gs_data_1 group by cube (g1000, g100,g10) +-- +TABLE: name="gs_hash_1" schema="" table="gs_hash_1" ctx=DDL +TABLE: name="gs_data_1" schema="" table="gs_data_1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE gs_hash_1 AS SELECT g100, g10, sum(g::numeric), count(*), max(g::text) FROM gs_data_..." +== 159 +-- truncate_limit: 100 +set enable_sort = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO TRUE" +== 160 +-- truncate_limit: 100 +set work_mem to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO DEFAULT" +== 161 +-- truncate_limit: 100 +set hash_mem_multiplier to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET hash_mem_multiplier TO DEFAULT" +== 162 +-- truncate_limit: 100 +-- Compare results + +(select * from gs_hash_1 except select * from gs_group_1) + union all +(select * from gs_group_1 except select * from gs_hash_1) +-- +TABLE: name="gs_hash_1" schema="" table="gs_hash_1" ctx=Select +TABLE: name="gs_group_1" schema="" table="gs_group_1" ctx=Select +TABLE: name="gs_group_1" schema="" table="gs_group_1" ctx=Select +TABLE: name="gs_hash_1" schema="" table="gs_hash_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM gs_hash_1 EXCEPT SELECT * FROM gs_group_1) UNION ALL (SELECT * FROM gs_group_1 EXC..." +== 163 +-- truncate_limit: 100 +drop table gs_group_1 +-- +TABLE: name="gs_group_1" schema="" table="gs_group_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gs_group_1" +== 164 +-- truncate_limit: 100 +drop table gs_hash_1 +-- +TABLE: name="gs_hash_1" schema="" table="gs_hash_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE gs_hash_1" +== 165 +-- truncate_limit: 100 +-- GROUP BY DISTINCT + +-- "normal" behavior... +select a, b, c +from (values (1, 2, 3), (4, null, 6), (7, 8, 9)) as t (a, b, c) +group by all rollup(a, b), rollup(a, c) +order by a, b, c +-- +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c FROM (VALUES (...)) t(a, b, c) GROUP BY ROLLUP (a, b), ROLLUP (a, c) ORDER BY a, b, c" +== 166 +-- truncate_limit: 100 +-- ...which is also the default +select a, b, c +from (values (1, 2, 3), (4, null, 6), (7, 8, 9)) as t (a, b, c) +group by rollup(a, b), rollup(a, c) +order by a, b, c +-- +STMT: SelectStmt +TRUNCATED: "SELECT a, b, c FROM (VALUES (...)) t(a, b, c) GROUP BY ROLLUP (a, b), ROLLUP (a, c) ORDER BY a, b, c" +== 167 +-- truncate_limit: 100 +-- "group by distinct" behavior... +select a, b, c +from (values (1, 2, 3), (4, null, 6), (7, 8, 9)) as t (a, b, c) +group by distinct rollup(a, b), rollup(a, c) +order by a, b, c +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(a, b, c) GROUP BY DISTINCT ROLLUP (a, b), ROLLUP (a, c) ORDER BY..." +== 168 +-- truncate_limit: 100 +-- ...which is not the same as "select distinct" +select distinct a, b, c +from (values (1, 2, 3), (4, null, 6), (7, 8, 9)) as t (a, b, c) +group by rollup(a, b), rollup(a, c) +order by a, b, c +-- +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM (VALUES (...)) t(a, b, c) GROUP BY ROLLUP (a, b), ROLLUP (a, c) O..." +== 169 +-- truncate_limit: 100 +-- test handling of outer GroupingFunc within subqueries +explain (costs off) +select (select grouping(v1)) from (values ((select 1))) v(v1) group by cube(v1) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT (SELECT GROUPING(v1)) FROM (VALUES ((SELECT 1))) v(v1) GROUP BY CUBE (v1)" +== 170 +-- truncate_limit: 100 +select (select grouping(v1)) from (values ((select 1))) v(v1) group by cube(v1) +-- +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT GROUPING(v1)) FROM (VALUES ((SELECT 1))) v(v1) GROUP BY CUBE (v1)" +== 171 +-- truncate_limit: 100 +explain (costs off) +select (select grouping(v1)) from (values ((select 1))) v(v1) group by v1 +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT (SELECT GROUPING(v1)) FROM (VALUES ((SELECT 1))) v(v1) GROUP BY v1" +== 172 +-- truncate_limit: 100 +select (select grouping(v1)) from (values ((select 1))) v(v1) group by v1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT GROUPING(v1)) FROM (VALUES ((SELECT 1))) v(v1) GROUP BY v1" diff --git a/parser/testdata/summary_truncate/postgres_regress/guc.metadata.json b/parser/testdata/summary_truncate/postgres_regress/guc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/guc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/guc.test b/parser/testdata/summary_truncate/postgres_regress/guc.test new file mode 100644 index 0000000..d09c128 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/guc.test @@ -0,0 +1,1462 @@ +== 001 +-- truncate_limit: 100 +-- pg_regress should ensure that this default value applies; however +-- we can't rely on any specific default value of vacuum_cost_delay +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 002 +-- truncate_limit: 100 +-- SET to some nondefault value +SET vacuum_cost_delay TO 40 +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO 40" +== 003 +-- truncate_limit: 100 +SET datestyle = 'ISO, YMD' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"ISO, YMD\"" +== 004 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 005 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 006 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 007 +-- truncate_limit: 100 +-- SET LOCAL has no effect outside of a transaction +SET LOCAL vacuum_cost_delay TO 50 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL vacuum_cost_delay TO 50" +== 008 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 009 +-- truncate_limit: 100 +SET LOCAL datestyle = 'SQL' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL datestyle TO \"SQL\"" +== 010 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 011 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 012 +-- truncate_limit: 100 +-- SET LOCAL within a transaction that commits +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 013 +-- truncate_limit: 100 +SET LOCAL vacuum_cost_delay TO 50 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL vacuum_cost_delay TO 50" +== 014 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 015 +-- truncate_limit: 100 +SET LOCAL datestyle = 'SQL' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL datestyle TO \"SQL\"" +== 016 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 017 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 018 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 019 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 020 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 021 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 022 +-- truncate_limit: 100 +-- SET should be reverted after ROLLBACK +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 023 +-- truncate_limit: 100 +SET vacuum_cost_delay TO 60 +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO 60" +== 024 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 025 +-- truncate_limit: 100 +SET datestyle = 'German' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"German\"" +== 026 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 027 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 028 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 029 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 030 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 031 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 032 +-- truncate_limit: 100 +-- Some tests with subtransactions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 033 +-- truncate_limit: 100 +SET vacuum_cost_delay TO 70 +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO 70" +== 034 +-- truncate_limit: 100 +SET datestyle = 'MDY' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"MDY\"" +== 035 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 036 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 037 +-- truncate_limit: 100 +SAVEPOINT first_sp +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT first_sp" +== 038 +-- truncate_limit: 100 +SET vacuum_cost_delay TO 80.1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO 80.1" +== 039 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 040 +-- truncate_limit: 100 +SET datestyle = 'German, DMY' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"German, DMY\"" +== 041 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 042 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 043 +-- truncate_limit: 100 +ROLLBACK TO first_sp +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT first_sp" +== 044 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 045 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 046 +-- truncate_limit: 100 +SAVEPOINT second_sp +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT second_sp" +== 047 +-- truncate_limit: 100 +SET vacuum_cost_delay TO '900us' +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO \"900us\"" +== 048 +-- truncate_limit: 100 +SET datestyle = 'SQL, YMD' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"SQL, YMD\"" +== 049 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 050 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 051 +-- truncate_limit: 100 +SAVEPOINT third_sp +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT third_sp" +== 052 +-- truncate_limit: 100 +SET vacuum_cost_delay TO 100 +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO 100" +== 053 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 054 +-- truncate_limit: 100 +SET datestyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"Postgres, MDY\"" +== 055 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 056 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 057 +-- truncate_limit: 100 +ROLLBACK TO third_sp +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT third_sp" +== 058 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 059 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 060 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 061 +-- truncate_limit: 100 +ROLLBACK TO second_sp +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT second_sp" +== 062 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 063 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 064 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 065 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 066 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 067 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 068 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 069 +-- truncate_limit: 100 +-- SET LOCAL with Savepoints +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 070 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 071 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 072 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 073 +-- truncate_limit: 100 +SAVEPOINT sp +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp" +== 074 +-- truncate_limit: 100 +SET LOCAL vacuum_cost_delay TO 30 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL vacuum_cost_delay TO 30" +== 075 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 076 +-- truncate_limit: 100 +SET LOCAL datestyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL datestyle TO \"Postgres, MDY\"" +== 077 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 078 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 079 +-- truncate_limit: 100 +ROLLBACK TO sp +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT sp" +== 080 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 081 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 082 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 083 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 084 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 085 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 086 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 087 +-- truncate_limit: 100 +-- SET LOCAL persists through RELEASE (which was not true in 8.0-8.2) +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 088 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 089 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 090 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 091 +-- truncate_limit: 100 +SAVEPOINT sp +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp" +== 092 +-- truncate_limit: 100 +SET LOCAL vacuum_cost_delay TO 30 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL vacuum_cost_delay TO 30" +== 093 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 094 +-- truncate_limit: 100 +SET LOCAL datestyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL datestyle TO \"Postgres, MDY\"" +== 095 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 096 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 097 +-- truncate_limit: 100 +RELEASE SAVEPOINT sp +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE sp" +== 098 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 099 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 100 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 101 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 102 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 103 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 104 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 105 +-- truncate_limit: 100 +-- SET followed by SET LOCAL +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 106 +-- truncate_limit: 100 +SET vacuum_cost_delay TO 40 +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO 40" +== 107 +-- truncate_limit: 100 +SET LOCAL vacuum_cost_delay TO 50 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL vacuum_cost_delay TO 50" +== 108 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 109 +-- truncate_limit: 100 +SET datestyle = 'ISO, DMY' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"ISO, DMY\"" +== 110 +-- truncate_limit: 100 +SET LOCAL datestyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL datestyle TO \"Postgres, MDY\"" +== 111 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 112 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 113 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 114 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 115 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 116 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 117 +-- truncate_limit: 100 +|-- +-- Test RESET. We use datestyle because the reset value is forced by +-- pg_regress, so it doesn't depend on the installation's configuration. +|-- +SET datestyle = iso, ymd +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO iso, ymd" +== 118 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 119 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 120 +-- truncate_limit: 100 +RESET datestyle +-- +STMT: VariableSetStmt +TRUNCATED: "RESET datestyle" +== 121 +-- truncate_limit: 100 +SHOW datestyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 122 +-- truncate_limit: 100 +SELECT '2006-08-13 12:34:56'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2006-08-13 12:34:56'::timestamptz" +== 123 +-- truncate_limit: 100 +-- Test some simple error cases +SET seq_page_cost TO 'NaN' +-- +STMT: VariableSetStmt +TRUNCATED: "SET seq_page_cost TO \"NaN\"" +== 124 +-- truncate_limit: 100 +SET vacuum_cost_delay TO '10s' +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO \"10s\"" +== 125 +-- truncate_limit: 100 +SET no_such_variable TO 42 +-- +STMT: VariableSetStmt +TRUNCATED: "SET no_such_variable TO 42" +== 126 +-- truncate_limit: 100 +-- Test "custom" GUCs created on the fly (which aren't really an +-- intended feature, but many people use them). +SHOW custom.my_guc +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW \"custom.my_guc\"" +== 127 +-- truncate_limit: 100 +-- error, not known yet +SET custom.my_guc = 42 +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"custom.my_guc\" TO 42" +== 128 +-- truncate_limit: 100 +SHOW custom.my_guc +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW \"custom.my_guc\"" +== 129 +-- truncate_limit: 100 +RESET custom.my_guc +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"custom.my_guc\"" +== 130 +-- truncate_limit: 100 +-- this makes it go to empty, not become unknown again +SHOW custom.my_guc +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW \"custom.my_guc\"" +== 131 +-- truncate_limit: 100 +SET custom.my.qualified.guc = 'foo' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"custom.my.qualified.guc\" TO foo" +== 132 +-- truncate_limit: 100 +SHOW custom.my.qualified.guc +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW \"custom.my.qualified.guc\"" +== 133 +-- truncate_limit: 100 +SET custom."bad-guc" = 42 +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"custom.bad-guc\" TO 42" +== 134 +-- truncate_limit: 100 +-- disallowed because -c cannot set this name +SHOW custom."bad-guc" +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW \"custom.bad-guc\"" +== 135 +-- truncate_limit: 100 +SET special."weird name" = 'foo' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"special.weird name\" TO foo" +== 136 +-- truncate_limit: 100 +-- could be allowed, but we choose not to +SHOW special."weird name" +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW \"special.weird name\"" +== 137 +-- truncate_limit: 100 +-- Check what happens when you try to set a "custom" GUC within the +-- namespace of an extension. +SET plpgsql.extra_foo_warnings = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_foo_warnings\" TO TRUE" +== 138 +-- truncate_limit: 100 +-- allowed if plpgsql is not loaded yet +LOAD 'plpgsql' +-- +STMT: LoadStmt +TRUNCATED: "LOAD 'plpgsql'" +== 139 +-- truncate_limit: 100 +-- this will throw a warning and delete the variable +SET plpgsql.extra_foo_warnings = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_foo_warnings\" TO TRUE" +== 140 +-- truncate_limit: 100 +-- now, it's an error +SHOW plpgsql.extra_foo_warnings +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW \"plpgsql.extra_foo_warnings\"" +== 141 +-- truncate_limit: 100 +|-- +-- Test DISCARD TEMP +|-- +CREATE TEMP TABLE reset_test ( data text ) ON COMMIT DELETE ROWS +-- +TABLE: name="reset_test" schema="" table="reset_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE reset_test (data text) ON COMMIT DELETE ROWS" +== 142 +-- truncate_limit: 100 +SELECT relname FROM pg_class WHERE relname = 'reset_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname = 'reset_test'" +== 143 +-- truncate_limit: 100 +DISCARD TEMP +-- +STMT: DiscardStmt +TRUNCATED: "DISCARD TEMP" +== 144 +-- truncate_limit: 100 +SELECT relname FROM pg_class WHERE relname = 'reset_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname = 'reset_test'" +== 145 +-- truncate_limit: 100 +|-- +-- Test DISCARD ALL +|-- + +-- do changes +DECLARE foo CURSOR WITH HOLD FOR SELECT 1 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo CURSOR WITH HOLD FOR SELECT 1" +== 146 +-- truncate_limit: 100 +PREPARE foo AS SELECT 1 +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE foo AS SELECT 1" +== 147 +-- truncate_limit: 100 +LISTEN foo_event +-- +STMT: ListenStmt +TRUNCATED: "LISTEN foo_event" +== 148 +-- truncate_limit: 100 +SET vacuum_cost_delay = 13 +-- +STMT: VariableSetStmt +TRUNCATED: "SET vacuum_cost_delay TO 13" +== 149 +-- truncate_limit: 100 +CREATE TEMP TABLE tmp_foo (data text) ON COMMIT DELETE ROWS +-- +TABLE: name="tmp_foo" schema="" table="tmp_foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tmp_foo (data text) ON COMMIT DELETE ROWS" +== 150 +-- truncate_limit: 100 +CREATE ROLE regress_guc_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_guc_user" +== 151 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_guc_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_guc_user" +== 152 +-- truncate_limit: 100 +-- look changes +SELECT pg_listening_channels() +-- +FUNCTION: name="pg_listening_channels" function="pg_listening_channels" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_listening_channels()" +== 153 +-- truncate_limit: 100 +SELECT name FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name FROM pg_prepared_statements" +== 154 +-- truncate_limit: 100 +SELECT name FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name FROM pg_cursors" +== 155 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 156 +-- truncate_limit: 100 +SELECT relname from pg_class where relname = 'tmp_foo' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname = 'tmp_foo'" +== 157 +-- truncate_limit: 100 +SELECT current_user = 'regress_guc_user' +-- +STMT: SelectStmt +TRUNCATED: "SELECT current_user = 'regress_guc_user'" +== 158 +-- truncate_limit: 100 +-- discard everything +DISCARD ALL +-- +STMT: DiscardStmt +TRUNCATED: "DISCARD ALL" +== 159 +-- truncate_limit: 100 +-- look again +SELECT pg_listening_channels() +-- +FUNCTION: name="pg_listening_channels" function="pg_listening_channels" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_listening_channels()" +== 160 +-- truncate_limit: 100 +SELECT name FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name FROM pg_prepared_statements" +== 161 +-- truncate_limit: 100 +SELECT name FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name FROM pg_cursors" +== 162 +-- truncate_limit: 100 +SHOW vacuum_cost_delay +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW vacuum_cost_delay" +== 163 +-- truncate_limit: 100 +SELECT relname from pg_class where relname = 'tmp_foo' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname = 'tmp_foo'" +== 164 +-- truncate_limit: 100 +SELECT current_user = 'regress_guc_user' +-- +STMT: SelectStmt +TRUNCATED: "SELECT current_user = 'regress_guc_user'" +== 165 +-- truncate_limit: 100 +DROP ROLE regress_guc_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_guc_user" +== 166 +-- truncate_limit: 100 +|-- +-- search_path should react to changes in pg_namespace +|-- + +set search_path = foo, public, not_there_initially +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO foo, public, not_there_initially" +== 167 +-- truncate_limit: 100 +select current_schemas(false) +-- +FUNCTION: name="current_schemas" function="current_schemas" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_schemas(false)" +== 168 +-- truncate_limit: 100 +create schema not_there_initially +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA not_there_initially" +== 169 +-- truncate_limit: 100 +select current_schemas(false) +-- +FUNCTION: name="current_schemas" function="current_schemas" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_schemas(false)" +== 170 +-- truncate_limit: 100 +drop schema not_there_initially +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA not_there_initially" +== 171 +-- truncate_limit: 100 +select current_schemas(false) +-- +FUNCTION: name="current_schemas" function="current_schemas" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_schemas(false)" +== 172 +-- truncate_limit: 100 +reset search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 173 +-- truncate_limit: 100 +|-- +-- Tests for function-local GUC settings +|-- + +set work_mem = '3MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"3MB\"" +== 174 +-- truncate_limit: 100 +create function report_guc(text) returns text as +$$ select current_setting($1) $$ language sql +set work_mem = '1MB' +-- +FUNCTION: name="report_guc" function="report_guc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION report_guc(text) RETURNS text AS $$ select current_setting($1) $$ LANGUAGE sql SE..." +== 175 +-- truncate_limit: 100 +select report_guc('work_mem'), current_setting('work_mem') +-- +FUNCTION: name="report_guc" function="report_guc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT report_guc('work_mem'), current_setting('work_mem')" +== 176 +-- truncate_limit: 100 +alter function report_guc(text) set work_mem = '2MB' +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION report_guc(text) SET work_mem TO \"2MB\"" +== 177 +-- truncate_limit: 100 +select report_guc('work_mem'), current_setting('work_mem') +-- +FUNCTION: name="report_guc" function="report_guc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT report_guc('work_mem'), current_setting('work_mem')" +== 178 +-- truncate_limit: 100 +alter function report_guc(text) reset all +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION report_guc(text) RESET ALL" +== 179 +-- truncate_limit: 100 +select report_guc('work_mem'), current_setting('work_mem') +-- +FUNCTION: name="report_guc" function="report_guc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT report_guc('work_mem'), current_setting('work_mem')" +== 180 +-- truncate_limit: 100 +-- SET LOCAL is restricted by a function SET option +create or replace function myfunc(int) returns text as $$ +begin + set local work_mem = '2MB'; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB' +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION myfunc(int) RETURNS text AS $$\nbegin\n set local work_mem = '2MB';\n r..." +== 181 +-- truncate_limit: 100 +select myfunc(0), current_setting('work_mem') +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myfunc(0), current_setting('work_mem')" +== 182 +-- truncate_limit: 100 +alter function myfunc(int) reset all +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION myfunc(int) RESET ALL" +== 183 +-- truncate_limit: 100 +select myfunc(0), current_setting('work_mem') +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myfunc(0), current_setting('work_mem')" +== 184 +-- truncate_limit: 100 +set work_mem = '3MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"3MB\"" +== 185 +-- truncate_limit: 100 +-- but SET isn't +create or replace function myfunc(int) returns text as $$ +begin + set work_mem = '2MB'; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB' +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION myfunc(int) RETURNS text AS $$\nbegin\n set work_mem = '2MB';\n return ..." +== 186 +-- truncate_limit: 100 +select myfunc(0), current_setting('work_mem') +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myfunc(0), current_setting('work_mem')" +== 187 +-- truncate_limit: 100 +set work_mem = '3MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"3MB\"" +== 188 +-- truncate_limit: 100 +-- it should roll back on error, though +create or replace function myfunc(int) returns text as $$ +begin + set work_mem = '2MB'; + perform 1/$1; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB' +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION myfunc(int) RETURNS text AS $$\nbegin\n set work_mem = '2MB';\n perform..." +== 189 +-- truncate_limit: 100 +select myfunc(0) +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myfunc(0)" +== 190 +-- truncate_limit: 100 +select current_setting('work_mem') +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_setting('work_mem')" +== 191 +-- truncate_limit: 100 +select myfunc(1), current_setting('work_mem') +-- +FUNCTION: name="myfunc" function="myfunc" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myfunc(1), current_setting('work_mem')" +== 192 +-- truncate_limit: 100 +-- check current_setting()'s behavior with invalid setting name + +select current_setting('nosuch.setting') +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_setting('nosuch.setting')" +== 193 +-- truncate_limit: 100 +-- FAIL +select current_setting('nosuch.setting', false) +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_setting('nosuch.setting', false)" +== 194 +-- truncate_limit: 100 +-- FAIL +select current_setting('nosuch.setting', true) is null +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_setting('nosuch.setting', true) IS NULL" +== 195 +-- truncate_limit: 100 +-- after this, all three cases should yield 'nada' +set nosuch.setting = 'nada' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"nosuch.setting\" TO nada" +== 196 +-- truncate_limit: 100 +select current_setting('nosuch.setting') +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_setting('nosuch.setting')" +== 197 +-- truncate_limit: 100 +select current_setting('nosuch.setting', false) +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_setting('nosuch.setting', false)" +== 198 +-- truncate_limit: 100 +select current_setting('nosuch.setting', true) +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_setting('nosuch.setting', true)" +== 199 +-- truncate_limit: 100 +-- Normally, CREATE FUNCTION should complain about invalid values in +-- function SET options; but not if check_function_bodies is off, +-- because that creates ordering hazards for pg_dump + +create function func_with_bad_set() returns int as $$ select 1 $$ +language sql +set default_text_search_config = no_such_config +-- +FUNCTION: name="func_with_bad_set" function="func_with_bad_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION func_with_bad_set() RETURNS int AS $$ select 1 $$ LANGUAGE sql SET default_text_s..." +== 200 +-- truncate_limit: 100 +set check_function_bodies = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET check_function_bodies TO OFF" +== 201 +-- truncate_limit: 100 +create function func_with_bad_set() returns int as $$ select 1 $$ +language sql +set default_text_search_config = no_such_config +-- +FUNCTION: name="func_with_bad_set" function="func_with_bad_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION func_with_bad_set() RETURNS int AS $$ select 1 $$ LANGUAGE sql SET default_text_s..." +== 202 +-- truncate_limit: 100 +select func_with_bad_set() +-- +FUNCTION: name="func_with_bad_set" function="func_with_bad_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT func_with_bad_set()" +== 203 +-- truncate_limit: 100 +reset check_function_bodies +-- +STMT: VariableSetStmt +TRUNCATED: "RESET check_function_bodies" +== 204 +-- truncate_limit: 100 +set default_with_oids to f +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_with_oids TO f" +== 205 +-- truncate_limit: 100 +-- Should not allow to set it to true. +set default_with_oids to t +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_with_oids TO t" +== 206 +-- truncate_limit: 100 +-- Test GUC categories and flag patterns +SELECT pg_settings_get_flags(NULL) +-- +FUNCTION: name="pg_settings_get_flags" function="pg_settings_get_flags" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_settings_get_flags(NULL)" +== 207 +-- truncate_limit: 100 +SELECT pg_settings_get_flags('does_not_exist') +-- +FUNCTION: name="pg_settings_get_flags" function="pg_settings_get_flags" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_settings_get_flags('does_not_exist')" +== 208 +-- truncate_limit: 100 +CREATE TABLE tab_settings_flags AS SELECT name, category, + 'EXPLAIN' = ANY(flags) AS explain, + 'NO_RESET' = ANY(flags) AS no_reset, + 'NO_RESET_ALL' = ANY(flags) AS no_reset_all, + 'NOT_IN_SAMPLE' = ANY(flags) AS not_in_sample, + 'RUNTIME_COMPUTED' = ANY(flags) AS runtime_computed + FROM pg_show_all_settings() AS psas, + pg_settings_get_flags(psas.name) AS flags +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=DDL +FUNCTION: name="pg_show_all_settings" function="pg_show_all_settings" schema="" ctx=Call +FUNCTION: name="pg_settings_get_flags" function="pg_settings_get_flags" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE tab_settings_flags AS SELECT name, category, 'EXPLAIN' = ANY(flags) AS explain, 'NO_..." +== 209 +-- truncate_limit: 100 +-- Developer GUCs should be flagged with GUC_NOT_IN_SAMPLE: +SELECT name FROM tab_settings_flags + WHERE category = 'Developer Options' AND NOT not_in_sample + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="category" +FILTER: schema="" table="" column="not_in_sample" +STMT: SelectStmt +TRUNCATED: "SELECT name FROM tab_settings_flags WHERE ... ORDER BY 1" +== 210 +-- truncate_limit: 100 +-- Most query-tuning GUCs are flagged as valid for EXPLAIN. +-- default_statistics_target is an exception. +SELECT name FROM tab_settings_flags + WHERE category ~ '^Query Tuning' AND NOT explain + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="category" +FILTER: schema="" table="" column="explain" +STMT: SelectStmt +TRUNCATED: "SELECT name FROM tab_settings_flags WHERE category ~ '^Query Tuning' AND NOT explain ORDER BY 1" +== 211 +-- truncate_limit: 100 +-- Runtime-computed GUCs should be part of the preset category. +SELECT name FROM tab_settings_flags + WHERE NOT category = 'Preset Options' AND runtime_computed + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="category" +FILTER: schema="" table="" column="runtime_computed" +STMT: SelectStmt +TRUNCATED: "SELECT name FROM tab_settings_flags WHERE ... ORDER BY 1" +== 212 +-- truncate_limit: 100 +-- Preset GUCs are flagged as NOT_IN_SAMPLE. +SELECT name FROM tab_settings_flags + WHERE category = 'Preset Options' AND NOT not_in_sample + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="category" +FILTER: schema="" table="" column="not_in_sample" +STMT: SelectStmt +TRUNCATED: "SELECT name FROM tab_settings_flags WHERE ... ORDER BY 1" +== 213 +-- truncate_limit: 100 +-- NO_RESET implies NO_RESET_ALL. +SELECT name FROM tab_settings_flags + WHERE no_reset AND NOT no_reset_all + ORDER BY 1 +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=Select +FILTER: schema="" table="" column="no_reset" +FILTER: schema="" table="" column="no_reset_all" +STMT: SelectStmt +TRUNCATED: "SELECT name FROM tab_settings_flags WHERE no_reset AND NOT no_reset_all ORDER BY 1" +== 214 +-- truncate_limit: 100 +DROP TABLE tab_settings_flags +-- +TABLE: name="tab_settings_flags" schema="" table="tab_settings_flags" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tab_settings_flags" diff --git a/parser/testdata/summary_truncate/postgres_regress/hash_func.metadata.json b/parser/testdata/summary_truncate/postgres_regress/hash_func.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/hash_func.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/hash_func.test b/parser/testdata/summary_truncate/postgres_regress/hash_func.test new file mode 100644 index 0000000..d4dc2df --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/hash_func.test @@ -0,0 +1,889 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test hash functions +|-- +-- When the salt is 0, the extended hash function should produce a result +-- whose low 32 bits match the standard hash function. When the salt is +-- not 0, we should get a different result. +|-- + +SELECT v as value, hashint2(v)::bit(32) as standard, + hashint2extended(v, 0)::bit(32) as extended0, + hashint2extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0::int2), (1::int2), (17::int2), (42::int2)) x(v) +WHERE hashint2(v)::bit(32) != hashint2extended(v, 0)::bit(32) + OR hashint2(v)::bit(32) = hashint2extended(v, 1)::bit(32) +-- +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FUNCTION: name="hashint2" function="hashint2" schema="" ctx=Call +FUNCTION: name="hashint2extended" function="hashint2extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 002 +-- truncate_limit: 100 +SELECT v as value, hashint4(v)::bit(32) as standard, + hashint4extended(v, 0)::bit(32) as extended0, + hashint4extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashint4(v)::bit(32) != hashint4extended(v, 0)::bit(32) + OR hashint4(v)::bit(32) = hashint4extended(v, 1)::bit(32) +-- +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FUNCTION: name="hashint4" function="hashint4" schema="" ctx=Call +FUNCTION: name="hashint4extended" function="hashint4extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 003 +-- truncate_limit: 100 +SELECT v as value, hashint8(v)::bit(32) as standard, + hashint8extended(v, 0)::bit(32) as extended0, + hashint8extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashint8(v)::bit(32) != hashint8extended(v, 0)::bit(32) + OR hashint8(v)::bit(32) = hashint8extended(v, 1)::bit(32) +-- +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FUNCTION: name="hashint8" function="hashint8" schema="" ctx=Call +FUNCTION: name="hashint8extended" function="hashint8extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 004 +-- truncate_limit: 100 +SELECT v as value, hashfloat4(v)::bit(32) as standard, + hashfloat4extended(v, 0)::bit(32) as extended0, + hashfloat4extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashfloat4(v)::bit(32) != hashfloat4extended(v, 0)::bit(32) + OR hashfloat4(v)::bit(32) = hashfloat4extended(v, 1)::bit(32) +-- +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4extended" function="hashfloat4extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 005 +-- truncate_limit: 100 +SELECT v as value, hashfloat8(v)::bit(32) as standard, + hashfloat8extended(v, 0)::bit(32) as extended0, + hashfloat8extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashfloat8(v)::bit(32) != hashfloat8extended(v, 0)::bit(32) + OR hashfloat8(v)::bit(32) = hashfloat8extended(v, 1)::bit(32) +-- +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8extended" function="hashfloat8extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 006 +-- truncate_limit: 100 +SELECT v as value, hashoid(v)::bit(32) as standard, + hashoidextended(v, 0)::bit(32) as extended0, + hashoidextended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1), (17), (42), (550273), (207112489)) x(v) +WHERE hashoid(v)::bit(32) != hashoidextended(v, 0)::bit(32) + OR hashoid(v)::bit(32) = hashoidextended(v, 1)::bit(32) +-- +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FUNCTION: name="hashoid" function="hashoid" schema="" ctx=Call +FUNCTION: name="hashoidextended" function="hashoidextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 007 +-- truncate_limit: 100 +SELECT v as value, hashchar(v)::bit(32) as standard, + hashcharextended(v, 0)::bit(32) as extended0, + hashcharextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::"char"), ('1'), ('x'), ('X'), ('p'), ('N')) x(v) +WHERE hashchar(v)::bit(32) != hashcharextended(v, 0)::bit(32) + OR hashchar(v)::bit(32) = hashcharextended(v, 1)::bit(32) +-- +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FUNCTION: name="hashchar" function="hashchar" schema="" ctx=Call +FUNCTION: name="hashcharextended" function="hashcharextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 008 +-- truncate_limit: 100 +SELECT v as value, hashname(v)::bit(32) as standard, + hashnameextended(v, 0)::bit(32) as extended0, + hashnameextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL), ('PostgreSQL'), ('eIpUEtqmY89'), ('AXKEJBTK'), + ('muop28x03'), ('yi3nm0d73')) x(v) +WHERE hashname(v)::bit(32) != hashnameextended(v, 0)::bit(32) + OR hashname(v)::bit(32) = hashnameextended(v, 1)::bit(32) +-- +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FUNCTION: name="hashname" function="hashname" schema="" ctx=Call +FUNCTION: name="hashnameextended" function="hashnameextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 009 +-- truncate_limit: 100 +SELECT v as value, hashtext(v)::bit(32) as standard, + hashtextextended(v, 0)::bit(32) as extended0, + hashtextextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL), ('PostgreSQL'), ('eIpUEtqmY89'), ('AXKEJBTK'), + ('muop28x03'), ('yi3nm0d73')) x(v) +WHERE hashtext(v)::bit(32) != hashtextextended(v, 0)::bit(32) + OR hashtext(v)::bit(32) = hashtextextended(v, 1)::bit(32) +-- +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FUNCTION: name="hashtext" function="hashtext" schema="" ctx=Call +FUNCTION: name="hashtextextended" function="hashtextextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 010 +-- truncate_limit: 100 +SELECT v as value, hashoidvector(v)::bit(32) as standard, + hashoidvectorextended(v, 0)::bit(32) as extended0, + hashoidvectorextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::oidvector), ('0 1 2 3 4'), ('17 18 19 20'), + ('42 43 42 45'), ('550273 550273 570274'), + ('207112489 207112499 21512 2155 372325 1363252')) x(v) +WHERE hashoidvector(v)::bit(32) != hashoidvectorextended(v, 0)::bit(32) + OR hashoidvector(v)::bit(32) = hashoidvectorextended(v, 1)::bit(32) +-- +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FUNCTION: name="hashoidvector" function="hashoidvector" schema="" ctx=Call +FUNCTION: name="hashoidvectorextended" function="hashoidvectorextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 011 +-- truncate_limit: 100 +SELECT v as value, hash_aclitem(v)::bit(32) as standard, + hash_aclitem_extended(v, 0)::bit(32) as extended0, + hash_aclitem_extended(v, 1)::bit(32) as extended1 +FROM (SELECT DISTINCT(relacl[1]) FROM pg_class LIMIT 10) x(v) +WHERE hash_aclitem(v)::bit(32) != hash_aclitem_extended(v, 0)::bit(32) + OR hash_aclitem(v)::bit(32) = hash_aclitem_extended(v, 1)::bit(32) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FUNCTION: name="hash_aclitem" function="hash_aclitem" schema="" ctx=Call +FUNCTION: name="hash_aclitem_extended" function="hash_aclitem_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT DISTINCT ... AS ... FROM pg_class LIMIT 10) x(v) WHERE ..." +== 012 +-- truncate_limit: 100 +SELECT v as value, hashmacaddr(v)::bit(32) as standard, + hashmacaddrextended(v, 0)::bit(32) as extended0, + hashmacaddrextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::macaddr), ('08:00:2b:01:02:04'), ('08:00:2b:01:02:04'), + ('e2:7f:51:3e:70:49'), ('d6:a9:4a:78:1c:d5'), + ('ea:29:b1:5e:1f:a5')) x(v) +WHERE hashmacaddr(v)::bit(32) != hashmacaddrextended(v, 0)::bit(32) + OR hashmacaddr(v)::bit(32) = hashmacaddrextended(v, 1)::bit(32) +-- +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FUNCTION: name="hashmacaddr" function="hashmacaddr" schema="" ctx=Call +FUNCTION: name="hashmacaddrextended" function="hashmacaddrextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 013 +-- truncate_limit: 100 +SELECT v as value, hashinet(v)::bit(32) as standard, + hashinetextended(v, 0)::bit(32) as extended0, + hashinetextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::inet), ('192.168.100.128/25'), ('192.168.100.0/8'), + ('172.168.10.126/16'), ('172.18.103.126/24'), ('192.188.13.16/32')) x(v) +WHERE hashinet(v)::bit(32) != hashinetextended(v, 0)::bit(32) + OR hashinet(v)::bit(32) = hashinetextended(v, 1)::bit(32) +-- +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FUNCTION: name="hashinet" function="hashinet" schema="" ctx=Call +FUNCTION: name="hashinetextended" function="hashinetextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 014 +-- truncate_limit: 100 +SELECT v as value, hash_numeric(v)::bit(32) as standard, + hash_numeric_extended(v, 0)::bit(32) as extended0, + hash_numeric_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (0), (1.149484958), (17.149484958), (42.149484958), + (149484958.550273), (2071124898672)) x(v) +WHERE hash_numeric(v)::bit(32) != hash_numeric_extended(v, 0)::bit(32) + OR hash_numeric(v)::bit(32) = hash_numeric_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FUNCTION: name="hash_numeric" function="hash_numeric" schema="" ctx=Call +FUNCTION: name="hash_numeric_extended" function="hash_numeric_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 015 +-- truncate_limit: 100 +SELECT v as value, hashmacaddr8(v)::bit(32) as standard, + hashmacaddr8extended(v, 0)::bit(32) as extended0, + hashmacaddr8extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::macaddr8), ('08:00:2b:01:02:04:36:49'), + ('08:00:2b:01:02:04:f0:e8'), ('e2:7f:51:3e:70:49:16:29'), + ('d6:a9:4a:78:1c:d5:47:32'), ('ea:29:b1:5e:1f:a5')) x(v) +WHERE hashmacaddr8(v)::bit(32) != hashmacaddr8extended(v, 0)::bit(32) + OR hashmacaddr8(v)::bit(32) = hashmacaddr8extended(v, 1)::bit(32) +-- +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FUNCTION: name="hashmacaddr8" function="hashmacaddr8" schema="" ctx=Call +FUNCTION: name="hashmacaddr8extended" function="hashmacaddr8extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 016 +-- truncate_limit: 100 +SELECT v as value, hash_array(v)::bit(32) as standard, + hash_array_extended(v, 0)::bit(32) as extended0, + hash_array_extended(v, 1)::bit(32) as extended1 +FROM (VALUES ('{0}'::int4[]), ('{0,1,2,3,4}'), ('{17,18,19,20}'), + ('{42,34,65,98}'), ('{550273,590027, 870273}'), + ('{207112489, 807112489}')) x(v) +WHERE hash_array(v)::bit(32) != hash_array_extended(v, 0)::bit(32) + OR hash_array(v)::bit(32) = hash_array_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 017 +-- truncate_limit: 100 +-- array hashing with non-hashable element type +SELECT v as value, hash_array(v)::bit(32) as standard +FROM (VALUES ('{101}'::varbit[])) x(v) +-- +FUNCTION: name="hash_array" function="hash_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v AS value, hash_array(v)::pg_catalog.bit(32) AS standard FROM (VALUES (...)) x(v)" +== 018 +-- truncate_limit: 100 +SELECT v as value, hash_array_extended(v, 0)::bit(32) as extended0 +FROM (VALUES ('{101}'::varbit[])) x(v) +-- +FUNCTION: name="hash_array_extended" function="hash_array_extended" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v)" +== 019 +-- truncate_limit: 100 +SELECT v as value, hashbpchar(v)::bit(32) as standard, + hashbpcharextended(v, 0)::bit(32) as extended0, + hashbpcharextended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL), ('PostgreSQL'), ('eIpUEtqmY89'), ('AXKEJBTK'), + ('muop28x03'), ('yi3nm0d73')) x(v) +WHERE hashbpchar(v)::bit(32) != hashbpcharextended(v, 0)::bit(32) + OR hashbpchar(v)::bit(32) = hashbpcharextended(v, 1)::bit(32) +-- +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FUNCTION: name="hashbpchar" function="hashbpchar" schema="" ctx=Call +FUNCTION: name="hashbpcharextended" function="hashbpcharextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 020 +-- truncate_limit: 100 +SELECT v as value, time_hash(v)::bit(32) as standard, + time_hash_extended(v, 0)::bit(32) as extended0, + time_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::time), ('11:09:59'), ('1:09:59'), ('11:59:59'), + ('7:9:59'), ('5:15:59')) x(v) +WHERE time_hash(v)::bit(32) != time_hash_extended(v, 0)::bit(32) + OR time_hash(v)::bit(32) = time_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FUNCTION: name="time_hash" function="time_hash" schema="" ctx=Call +FUNCTION: name="time_hash_extended" function="time_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 021 +-- truncate_limit: 100 +SELECT v as value, timetz_hash(v)::bit(32) as standard, + timetz_hash_extended(v, 0)::bit(32) as extended0, + timetz_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::timetz), ('00:11:52.518762-07'), ('00:11:52.51762-08'), + ('00:11:52.62-01'), ('00:11:52.62+01'), ('11:59:59+04')) x(v) +WHERE timetz_hash(v)::bit(32) != timetz_hash_extended(v, 0)::bit(32) + OR timetz_hash(v)::bit(32) = timetz_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FUNCTION: name="timetz_hash" function="timetz_hash" schema="" ctx=Call +FUNCTION: name="timetz_hash_extended" function="timetz_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 022 +-- truncate_limit: 100 +SELECT v as value, interval_hash(v)::bit(32) as standard, + interval_hash_extended(v, 0)::bit(32) as extended0, + interval_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::interval), + ('5 month 7 day 46 minutes'), ('1 year 7 day 46 minutes'), + ('1 year 7 month 20 day 46 minutes'), ('5 month'), + ('17 year 11 month 7 day 9 hours 46 minutes 5 seconds')) x(v) +WHERE interval_hash(v)::bit(32) != interval_hash_extended(v, 0)::bit(32) + OR interval_hash(v)::bit(32) = interval_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash_extended" function="interval_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 023 +-- truncate_limit: 100 +SELECT v as value, timestamp_hash(v)::bit(32) as standard, + timestamp_hash_extended(v, 0)::bit(32) as extended0, + timestamp_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::timestamp), ('2017-08-22 00:09:59.518762'), + ('2015-08-20 00:11:52.51762-08'), + ('2017-05-22 00:11:52.62-01'), + ('2013-08-22 00:11:52.62+01'), ('2013-08-22 11:59:59+04')) x(v) +WHERE timestamp_hash(v)::bit(32) != timestamp_hash_extended(v, 0)::bit(32) + OR timestamp_hash(v)::bit(32) = timestamp_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FUNCTION: name="timestamp_hash" function="timestamp_hash" schema="" ctx=Call +FUNCTION: name="timestamp_hash_extended" function="timestamp_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 024 +-- truncate_limit: 100 +SELECT v as value, uuid_hash(v)::bit(32) as standard, + uuid_hash_extended(v, 0)::bit(32) as extended0, + uuid_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::uuid), ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'), + ('5a9ba4ac-8d6f-11e7-bb31-be2e44b06b34'), + ('99c6705c-d939-461c-a3c9-1690ad64ed7b'), + ('7deed3ca-8d6f-11e7-bb31-be2e44b06b34'), + ('9ad46d4f-6f2a-4edd-aadb-745993928e1e')) x(v) +WHERE uuid_hash(v)::bit(32) != uuid_hash_extended(v, 0)::bit(32) + OR uuid_hash(v)::bit(32) = uuid_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FUNCTION: name="uuid_hash" function="uuid_hash" schema="" ctx=Call +FUNCTION: name="uuid_hash_extended" function="uuid_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 025 +-- truncate_limit: 100 +SELECT v as value, pg_lsn_hash(v)::bit(32) as standard, + pg_lsn_hash_extended(v, 0)::bit(32) as extended0, + pg_lsn_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::pg_lsn), ('16/B374D84'), ('30/B374D84'), + ('255/B374D84'), ('25/B379D90'), ('900/F37FD90')) x(v) +WHERE pg_lsn_hash(v)::bit(32) != pg_lsn_hash_extended(v, 0)::bit(32) + OR pg_lsn_hash(v)::bit(32) = pg_lsn_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash" function="pg_lsn_hash" schema="" ctx=Call +FUNCTION: name="pg_lsn_hash_extended" function="pg_lsn_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 026 +-- truncate_limit: 100 +CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy')" +== 027 +-- truncate_limit: 100 +SELECT v as value, hashenum(v)::bit(32) as standard, + hashenumextended(v, 0)::bit(32) as extended0, + hashenumextended(v, 1)::bit(32) as extended1 +FROM (VALUES ('sad'::mood), ('ok'), ('happy')) x(v) +WHERE hashenum(v)::bit(32) != hashenumextended(v, 0)::bit(32) + OR hashenum(v)::bit(32) = hashenumextended(v, 1)::bit(32) +-- +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FUNCTION: name="hashenum" function="hashenum" schema="" ctx=Call +FUNCTION: name="hashenumextended" function="hashenumextended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 028 +-- truncate_limit: 100 +DROP TYPE mood +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE mood" +== 029 +-- truncate_limit: 100 +SELECT v as value, jsonb_hash(v)::bit(32) as standard, + jsonb_hash_extended(v, 0)::bit(32) as extended0, + jsonb_hash_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (NULL::jsonb), + ('{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'), + ('{"foo": [true, "bar"], "tags": {"e": 1, "f": null}}'), + ('{"g": {"h": "value"}}')) x(v) +WHERE jsonb_hash(v)::bit(32) != jsonb_hash_extended(v, 0)::bit(32) + OR jsonb_hash(v)::bit(32) = jsonb_hash_extended(v, 1)::bit(32) +-- +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FUNCTION: name="jsonb_hash" function="jsonb_hash" schema="" ctx=Call +FUNCTION: name="jsonb_hash_extended" function="jsonb_hash_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 030 +-- truncate_limit: 100 +SELECT v as value, hash_range(v)::bit(32) as standard, + hash_range_extended(v, 0)::bit(32) as extended0, + hash_range_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (int4range(10, 20)), (int4range(23, 43)), + (int4range(5675, 550273)), + (int4range(550274, 1550274)), (int4range(1550275, 208112489))) x(v) +WHERE hash_range(v)::bit(32) != hash_range_extended(v, 0)::bit(32) + OR hash_range(v)::bit(32) = hash_range_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FUNCTION: name="hash_range" function="hash_range" schema="" ctx=Call +FUNCTION: name="hash_range_extended" function="hash_range_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 031 +-- truncate_limit: 100 +SELECT v as value, hash_multirange(v)::bit(32) as standard, + hash_multirange_extended(v, 0)::bit(32) as extended0, + hash_multirange_extended(v, 1)::bit(32) as extended1 +FROM (VALUES ('{[10,20)}'::int4multirange), ('{[23, 43]}'::int4multirange), + ('{[5675, 550273)}'::int4multirange), + ('{[550274, 1550274)}'::int4multirange), + ('{[1550275, 208112489)}'::int4multirange)) x(v) +WHERE hash_multirange(v)::bit(32) != hash_multirange_extended(v, 0)::bit(32) + OR hash_multirange(v)::bit(32) = hash_multirange_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FUNCTION: name="hash_multirange" function="hash_multirange" schema="" ctx=Call +FUNCTION: name="hash_multirange_extended" function="hash_multirange_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 032 +-- truncate_limit: 100 +CREATE TYPE hash_test_t1 AS (a int, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE hash_test_t1 AS (a int, b text)" +== 033 +-- truncate_limit: 100 +SELECT v as value, hash_record(v)::bit(32) as standard, + hash_record_extended(v, 0)::bit(32) as extended0, + hash_record_extended(v, 1)::bit(32) as extended1 +FROM (VALUES (row(1, 'aaa')::hash_test_t1, row(2, 'bbb'), row(-1, 'ccc'))) x(v) +WHERE hash_record(v)::bit(32) != hash_record_extended(v, 0)::bit(32) + OR hash_record(v)::bit(32) = hash_record_extended(v, 1)::bit(32) +-- +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +FILTER: schema="" table="" column="v" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v) WHERE ..." +== 034 +-- truncate_limit: 100 +DROP TYPE hash_test_t1 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE hash_test_t1" +== 035 +-- truncate_limit: 100 +-- record hashing with non-hashable field type +CREATE TYPE hash_test_t2 AS (a varbit, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE hash_test_t2 AS (a varbit, b text)" +== 036 +-- truncate_limit: 100 +SELECT v as value, hash_record(v)::bit(32) as standard +FROM (VALUES (row('10'::varbit, 'aaa')::hash_test_t2)) x(v) +-- +FUNCTION: name="hash_record" function="hash_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v AS value, hash_record(v)::pg_catalog.bit(32) AS standard FROM (VALUES (...)) x(v)" +== 037 +-- truncate_limit: 100 +SELECT v as value, hash_record_extended(v, 0)::bit(32) as extended0 +FROM (VALUES (row('11'::varbit, 'aaa')::hash_test_t2)) x(v) +-- +FUNCTION: name="hash_record_extended" function="hash_record_extended" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(v)" +== 038 +-- truncate_limit: 100 +DROP TYPE hash_test_t2 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE hash_test_t2" +== 039 +-- truncate_limit: 100 +|-- +-- Check special cases for specific data types +|-- +SELECT hashfloat4('0'::float4) = hashfloat4('-0'::float4) AS t +-- +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT hashfloat4('0'::float4) = hashfloat4('-0'::float4) AS t" +== 040 +-- truncate_limit: 100 +SELECT hashfloat4('NaN'::float4) = hashfloat4(-'NaN'::float4) AS t +-- +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT hashfloat4('NaN'::float4) = hashfloat4(- 'NaN'::float4) AS t" +== 041 +-- truncate_limit: 100 +SELECT hashfloat8('0'::float8) = hashfloat8('-0'::float8) AS t +-- +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT hashfloat8('0'::float8) = hashfloat8('-0'::float8) AS t" +== 042 +-- truncate_limit: 100 +SELECT hashfloat8('NaN'::float8) = hashfloat8(-'NaN'::float8) AS t +-- +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT hashfloat8('NaN'::float8) = hashfloat8(- 'NaN'::float8) AS t" +== 043 +-- truncate_limit: 100 +SELECT hashfloat4('NaN'::float4) = hashfloat8('NaN'::float8) AS t +-- +FUNCTION: name="hashfloat4" function="hashfloat4" schema="" ctx=Call +FUNCTION: name="hashfloat8" function="hashfloat8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT hashfloat4('NaN'::float4) = hashfloat8('NaN'::float8) AS t" diff --git a/parser/testdata/summary_truncate/postgres_regress/hash_index.metadata.json b/parser/testdata/summary_truncate/postgres_regress/hash_index.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/hash_index.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/hash_index.test b/parser/testdata/summary_truncate/postgres_regress/hash_index.test new file mode 100644 index 0000000..07870f0 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/hash_index.test @@ -0,0 +1,878 @@ +== 001 +-- truncate_limit: 100 +|-- +-- HASH_INDEX +|-- + +-- directory paths are passed to us in environment variables + +CREATE TABLE hash_i4_heap ( + seqno int4, + random int4 +) +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_i4_heap (seqno int4, random int4)" +== 002 +-- truncate_limit: 100 +CREATE TABLE hash_name_heap ( + seqno int4, + random name +) +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_name_heap (seqno int4, random name)" +== 003 +-- truncate_limit: 100 +CREATE TABLE hash_txt_heap ( + seqno int4, + random text +) +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_txt_heap (seqno int4, random text)" +== 004 +-- truncate_limit: 100 +CREATE TABLE hash_f8_heap ( + seqno int4, + random float8 +) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_f8_heap (seqno int4, random float8)" +== 005 +-- truncate_limit: 100 +COPY hash_i4_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +-- truncate_limit: 100 +COPY hash_name_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 26 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- truncate_limit: 100 +COPY hash_txt_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +-- truncate_limit: 100 +COPY hash_f8_heap FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- truncate_limit: 100 +-- the data in this file has a lot of duplicates in the index key +-- fields, leading to long bucket chains and lots of table expansion. +-- this is therefore a stress test of the bucket overflow code (unlike +-- the data in hash.data, which has unique index keys). +|-- +-- \set filename :abs_srcdir '/data/hashovfl.data' +-- COPY hash_ovfl_heap FROM :'filename'; + +ANALYZE hash_i4_heap +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE hash_i4_heap" +== 010 +-- truncate_limit: 100 +ANALYZE hash_name_heap +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE hash_name_heap" +== 011 +-- truncate_limit: 100 +ANALYZE hash_txt_heap +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE hash_txt_heap" +== 012 +-- truncate_limit: 100 +ANALYZE hash_f8_heap +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE hash_f8_heap" +== 013 +-- truncate_limit: 100 +CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops) +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops)" +== 014 +-- truncate_limit: 100 +CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops) +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_name_index ON hash_name_heap USING hash (random name_ops)" +== 015 +-- truncate_limit: 100 +CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops) +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops)" +== 016 +-- truncate_limit: 100 +CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops) + WITH (fillfactor=60) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops) WITH (fillfactor=60)" +== 017 +-- truncate_limit: 100 +|-- +-- Also try building functional, expressional, and partial indexes on +-- tables that already contain data. +|-- +create unique index hash_f8_index_1 on hash_f8_heap(abs(random)) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX hash_f8_index_1 ON hash_f8_heap USING btree (abs(random))" +== 018 +-- truncate_limit: 100 +create unique index hash_f8_index_2 on hash_f8_heap((seqno + 1), random) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX hash_f8_index_2 ON hash_f8_heap USING btree ((seqno + 1), random)" +== 019 +-- truncate_limit: 100 +create unique index hash_f8_index_3 on hash_f8_heap(random) where seqno > 1000 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX hash_f8_index_3 ON hash_f8_heap USING btree (random) WHERE seqno > 1000" +== 020 +-- truncate_limit: 100 +|-- +-- hash index +-- grep 843938989 hash.data +|-- +SELECT * FROM hash_i4_heap + WHERE hash_i4_heap.random = 843938989 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=Select +FILTER: schema="" table="hash_i4_heap" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_i4_heap WHERE hash_i4_heap.random = 843938989" +== 021 +-- truncate_limit: 100 +|-- +-- hash index +-- grep 66766766 hash.data +|-- +SELECT * FROM hash_i4_heap + WHERE hash_i4_heap.random = 66766766 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=Select +FILTER: schema="" table="hash_i4_heap" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_i4_heap WHERE hash_i4_heap.random = 66766766" +== 022 +-- truncate_limit: 100 +|-- +-- hash index +-- grep 1505703298 hash.data +|-- +SELECT * FROM hash_name_heap + WHERE hash_name_heap.random = '1505703298'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=Select +FILTER: schema="" table="hash_name_heap" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_name_heap WHERE hash_name_heap.random = '1505703298'::name" +== 023 +-- truncate_limit: 100 +|-- +-- hash index +-- grep 7777777 hash.data +|-- +SELECT * FROM hash_name_heap + WHERE hash_name_heap.random = '7777777'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=Select +FILTER: schema="" table="hash_name_heap" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_name_heap WHERE hash_name_heap.random = '7777777'::name" +== 024 +-- truncate_limit: 100 +|-- +-- hash index +-- grep 1351610853 hash.data +|-- +SELECT * FROM hash_txt_heap + WHERE hash_txt_heap.random = '1351610853'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=Select +FILTER: schema="" table="hash_txt_heap" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_txt_heap WHERE hash_txt_heap.random = '1351610853'::text" +== 025 +-- truncate_limit: 100 +|-- +-- hash index +-- grep 111111112222222233333333 hash.data +|-- +SELECT * FROM hash_txt_heap + WHERE hash_txt_heap.random = '111111112222222233333333'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=Select +FILTER: schema="" table="hash_txt_heap" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_txt_heap WHERE hash_txt_heap.random = '111111112222222233333333'::text" +== 026 +-- truncate_limit: 100 +|-- +-- hash index +-- grep 444705537 hash.data +|-- +SELECT * FROM hash_f8_heap + WHERE hash_f8_heap.random = '444705537'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=Select +FILTER: schema="" table="hash_f8_heap" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_f8_heap WHERE hash_f8_heap.random = '444705537'::float8" +== 027 +-- truncate_limit: 100 +|-- +-- hash index +-- grep 88888888 hash.data +|-- +SELECT * FROM hash_f8_heap + WHERE hash_f8_heap.random = '88888888'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=Select +FILTER: schema="" table="hash_f8_heap" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_f8_heap WHERE hash_f8_heap.random = '88888888'::float8" +== 028 +-- truncate_limit: 100 +|-- +-- hash index +-- grep '^90[^0-9]' hashovfl.data +|-- +-- SELECT count(*) AS i988 FROM hash_ovfl_heap +-- WHERE x = 90; + +|-- +-- hash index +-- grep '^1000[^0-9]' hashovfl.data +|-- +-- SELECT count(*) AS i0 FROM hash_ovfl_heap +-- WHERE x = 1000; + +|-- +-- HASH +|-- +UPDATE hash_i4_heap + SET random = 1 + WHERE hash_i4_heap.seqno = 1492 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_i4_heap SET random = 1 WHERE hash_i4_heap.seqno = 1492" +== 029 +-- truncate_limit: 100 +SELECT h.seqno AS i1492, h.random AS i1 + FROM hash_i4_heap h + WHERE h.random = 1 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=Select +ALIAS: "h"="hash_i4_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT h.seqno AS i1492, h.random AS i1 FROM hash_i4_heap h WHERE h.random = 1" +== 030 +-- truncate_limit: 100 +UPDATE hash_i4_heap + SET seqno = 20000 + WHERE hash_i4_heap.random = 1492795354 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_i4_heap SET seqno = 20000 WHERE hash_i4_heap.random = 1492795354" +== 031 +-- truncate_limit: 100 +SELECT h.seqno AS i20000 + FROM hash_i4_heap h + WHERE h.random = 1492795354 +-- +TABLE: name="hash_i4_heap" schema="" table="hash_i4_heap" ctx=Select +ALIAS: "h"="hash_i4_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT h.seqno AS i20000 FROM hash_i4_heap h WHERE h.random = 1492795354" +== 032 +-- truncate_limit: 100 +UPDATE hash_name_heap + SET random = '0123456789abcdef'::name + WHERE hash_name_heap.seqno = 6543 +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_name_heap SET random = '0123456789abcdef'::name WHERE hash_name_heap.seqno = 6543" +== 033 +-- truncate_limit: 100 +SELECT h.seqno AS i6543, h.random AS c0_to_f + FROM hash_name_heap h + WHERE h.random = '0123456789abcdef'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=Select +ALIAS: "h"="hash_name_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_name_heap h WHERE h.random = '0123456789abcdef'::name" +== 034 +-- truncate_limit: 100 +UPDATE hash_name_heap + SET seqno = 20000 + WHERE hash_name_heap.random = '76652222'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_name_heap SET seqno = 20000 WHERE hash_name_heap.random = '76652222'::name" +== 035 +-- truncate_limit: 100 +|-- +-- this is the row we just replaced; index scan should return zero rows +|-- +SELECT h.seqno AS emptyset + FROM hash_name_heap h + WHERE h.random = '76652222'::name +-- +TABLE: name="hash_name_heap" schema="" table="hash_name_heap" ctx=Select +ALIAS: "h"="hash_name_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT h.seqno AS emptyset FROM hash_name_heap h WHERE h.random = '76652222'::name" +== 036 +-- truncate_limit: 100 +UPDATE hash_txt_heap + SET random = '0123456789abcdefghijklmnop'::text + WHERE hash_txt_heap.seqno = 4002 +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_txt_heap SET ... = ... WHERE hash_txt_heap.seqno = 4002" +== 037 +-- truncate_limit: 100 +SELECT h.seqno AS i4002, h.random AS c0_to_p + FROM hash_txt_heap h + WHERE h.random = '0123456789abcdefghijklmnop'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=Select +ALIAS: "h"="hash_txt_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT h.seqno AS i4002, h.random AS c0_to_p FROM hash_txt_heap h WHERE ..." +== 038 +-- truncate_limit: 100 +UPDATE hash_txt_heap + SET seqno = 20000 + WHERE hash_txt_heap.random = '959363399'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_txt_heap SET seqno = 20000 WHERE hash_txt_heap.random = '959363399'::text" +== 039 +-- truncate_limit: 100 +SELECT h.seqno AS t20000 + FROM hash_txt_heap h + WHERE h.random = '959363399'::text +-- +TABLE: name="hash_txt_heap" schema="" table="hash_txt_heap" ctx=Select +ALIAS: "h"="hash_txt_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT h.seqno AS t20000 FROM hash_txt_heap h WHERE h.random = '959363399'::text" +== 040 +-- truncate_limit: 100 +UPDATE hash_f8_heap + SET random = '-1234.1234'::float8 + WHERE hash_f8_heap.seqno = 8906 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_f8_heap SET random = '-1234.1234'::float8 WHERE hash_f8_heap.seqno = 8906" +== 041 +-- truncate_limit: 100 +SELECT h.seqno AS i8096, h.random AS f1234_1234 + FROM hash_f8_heap h + WHERE h.random = '-1234.1234'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=Select +ALIAS: "h"="hash_f8_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_f8_heap h WHERE h.random = '-1234.1234'::float8" +== 042 +-- truncate_limit: 100 +UPDATE hash_f8_heap + SET seqno = 20000 + WHERE hash_f8_heap.random = '488912369'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_f8_heap SET seqno = 20000 WHERE hash_f8_heap.random = '488912369'::float8" +== 043 +-- truncate_limit: 100 +SELECT h.seqno AS f20000 + FROM hash_f8_heap h + WHERE h.random = '488912369'::float8 +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=Select +ALIAS: "h"="hash_f8_heap" +FILTER: schema="" table="h" column="random" +STMT: SelectStmt +TRUNCATED: "SELECT h.seqno AS f20000 FROM hash_f8_heap h WHERE h.random = '488912369'::float8" +== 044 +-- truncate_limit: 100 +-- UPDATE hash_ovfl_heap +-- SET x = 1000 +-- WHERE x = 90; + +-- this vacuums the index as well +-- VACUUM hash_ovfl_heap; + +-- SELECT count(*) AS i0 FROM hash_ovfl_heap +-- WHERE x = 90; + +-- SELECT count(*) AS i988 FROM hash_ovfl_heap +-- WHERE x = 1000; + +|-- +-- Cause some overflow insert and splits. +|-- +CREATE TABLE hash_split_heap (keycol INT) +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_split_heap (keycol int)" +== 045 +-- truncate_limit: 100 +INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 500) a +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 500) a" +== 046 +-- truncate_limit: 100 +CREATE INDEX hash_split_index on hash_split_heap USING HASH (keycol) +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_split_index ON hash_split_heap USING hash (keycol)" +== 047 +-- truncate_limit: 100 +INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 5000) a +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_split_heap SELECT 1 FROM generate_series(1, 5000) a" +== 048 +-- truncate_limit: 100 +-- Let's do a backward scan. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 049 +-- truncate_limit: 100 +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 050 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 051 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT * from hash_split_heap WHERE keycol = 1 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT * FROM hash_split_heap WHERE keycol = 1" +== 052 +-- truncate_limit: 100 +MOVE FORWARD ALL FROM c +-- +STMT: FetchStmt +TRUNCATED: "MOVE ALL c" +== 053 +-- truncate_limit: 100 +MOVE BACKWARD 10000 FROM c +-- +STMT: FetchStmt +TRUNCATED: "MOVE BACKWARD 10000 c" +== 054 +-- truncate_limit: 100 +MOVE BACKWARD ALL FROM c +-- +STMT: FetchStmt +TRUNCATED: "MOVE BACKWARD ALL c" +== 055 +-- truncate_limit: 100 +CLOSE c +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE c" +== 056 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 057 +-- truncate_limit: 100 +-- DELETE, INSERT, VACUUM. +DELETE FROM hash_split_heap WHERE keycol = 1 +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM hash_split_heap WHERE keycol = 1" +== 058 +-- truncate_limit: 100 +INSERT INTO hash_split_heap SELECT a/2 FROM generate_series(1, 25000) a +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_split_heap SELECT a / 2 FROM generate_series(1, 25000) a" +== 059 +-- truncate_limit: 100 +VACUUM hash_split_heap +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM hash_split_heap" +== 060 +-- truncate_limit: 100 +-- Rebuild the index using a different fillfactor +ALTER INDEX hash_split_index SET (fillfactor = 10) +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX hash_split_index SET (fillfactor=10)" +== 061 +-- truncate_limit: 100 +REINDEX INDEX hash_split_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX hash_split_index" +== 062 +-- truncate_limit: 100 +-- Clean up. +DROP TABLE hash_split_heap +-- +TABLE: name="hash_split_heap" schema="" table="hash_split_heap" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hash_split_heap" +== 063 +-- truncate_limit: 100 +-- Testcases for removing overflow pages. +CREATE TABLE hash_cleanup_heap(keycol INT) +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_cleanup_heap (keycol int)" +== 064 +-- truncate_limit: 100 +CREATE INDEX hash_cleanup_index on hash_cleanup_heap USING HASH (keycol) +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_cleanup_index ON hash_cleanup_heap USING hash (keycol)" +== 065 +-- truncate_limit: 100 +-- Insert tuples to both the primary bucket page and overflow pages. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) i" +== 066 +-- truncate_limit: 100 +-- Fill overflow pages by "dead" tuples. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 067 +-- truncate_limit: 100 +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1000) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1000) i" +== 068 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 069 +-- truncate_limit: 100 +-- Checkpoint will ensure that all hash buffers are cleaned before we try +-- to remove overflow pages. +CHECKPOINT +-- +STMT: CheckPointStmt +TRUNCATED: "CHECKPOINT" +== 070 +-- truncate_limit: 100 +-- This will squeeze the bucket and remove overflow pages. +VACUUM hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM hash_cleanup_heap" +== 071 +-- truncate_limit: 100 +TRUNCATE hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE hash_cleanup_heap" +== 072 +-- truncate_limit: 100 +-- Insert a few tuples so that the primary bucket page doesn't get full and +-- tuples can be moved to it. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 50) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 50) i" +== 073 +-- truncate_limit: 100 +-- Fill overflow pages by "dead" tuples. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 074 +-- truncate_limit: 100 +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1500) i" +== 075 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 076 +-- truncate_limit: 100 +-- And insert some tuples again. During squeeze operation, these will be moved +-- to the primary bucket allowing to test freeing intermediate overflow pages. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) i" +== 077 +-- truncate_limit: 100 +CHECKPOINT +-- +STMT: CheckPointStmt +TRUNCATED: "CHECKPOINT" +== 078 +-- truncate_limit: 100 +VACUUM hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM hash_cleanup_heap" +== 079 +-- truncate_limit: 100 +TRUNCATE hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE hash_cleanup_heap" +== 080 +-- truncate_limit: 100 +-- Insert tuples to both the primary bucket page and overflow pages. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 500) i" +== 081 +-- truncate_limit: 100 +-- Fill overflow pages by "dead" tuples. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 082 +-- truncate_limit: 100 +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1500) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 1500) i" +== 083 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 084 +-- truncate_limit: 100 +-- And insert some tuples again. During squeeze operation, these will be moved +-- to other overflow pages and also allow overflow pages filled by dead tuples +-- to be freed. Note the main purpose of this test is to test the case where +-- we don't need to move any tuple from the overflow page being freed. +INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 50) as i +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_cleanup_heap SELECT 1 FROM generate_series(1, 50) i" +== 085 +-- truncate_limit: 100 +CHECKPOINT +-- +STMT: CheckPointStmt +TRUNCATED: "CHECKPOINT" +== 086 +-- truncate_limit: 100 +VACUUM hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM hash_cleanup_heap" +== 087 +-- truncate_limit: 100 +-- Clean up. +DROP TABLE hash_cleanup_heap +-- +TABLE: name="hash_cleanup_heap" schema="" table="hash_cleanup_heap" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hash_cleanup_heap" +== 088 +-- truncate_limit: 100 +-- Index on temp table. +CREATE TEMP TABLE hash_temp_heap (x int, y int) +-- +TABLE: name="hash_temp_heap" schema="" table="hash_temp_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE hash_temp_heap (x int, y int)" +== 089 +-- truncate_limit: 100 +INSERT INTO hash_temp_heap VALUES (1,1) +-- +TABLE: name="hash_temp_heap" schema="" table="hash_temp_heap" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_temp_heap VALUES (1, 1)" +== 090 +-- truncate_limit: 100 +CREATE INDEX hash_idx ON hash_temp_heap USING hash (x) +-- +TABLE: name="hash_temp_heap" schema="" table="hash_temp_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_idx ON hash_temp_heap USING hash (x)" +== 091 +-- truncate_limit: 100 +DROP TABLE hash_temp_heap CASCADE +-- +TABLE: name="hash_temp_heap" schema="" table="hash_temp_heap" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hash_temp_heap CASCADE" +== 092 +-- truncate_limit: 100 +-- Float4 type. +CREATE TABLE hash_heap_float4 (x float4, y int) +-- +TABLE: name="hash_heap_float4" schema="" table="hash_heap_float4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_heap_float4 (x float4, y int)" +== 093 +-- truncate_limit: 100 +INSERT INTO hash_heap_float4 VALUES (1.1,1) +-- +TABLE: name="hash_heap_float4" schema="" table="hash_heap_float4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_heap_float4 VALUES (1.1, 1)" +== 094 +-- truncate_limit: 100 +CREATE INDEX hash_idx ON hash_heap_float4 USING hash (x) +-- +TABLE: name="hash_heap_float4" schema="" table="hash_heap_float4" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_idx ON hash_heap_float4 USING hash (x)" +== 095 +-- truncate_limit: 100 +DROP TABLE hash_heap_float4 CASCADE +-- +TABLE: name="hash_heap_float4" schema="" table="hash_heap_float4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hash_heap_float4 CASCADE" +== 096 +-- truncate_limit: 100 +-- Test out-of-range fillfactor values +CREATE INDEX hash_f8_index2 ON hash_f8_heap USING hash (random float8_ops) + WITH (fillfactor=9) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_f8_index2 ON hash_f8_heap USING hash (random float8_ops) WITH (fillfactor=9)" +== 097 +-- truncate_limit: 100 +CREATE INDEX hash_f8_index2 ON hash_f8_heap USING hash (random float8_ops) + WITH (fillfactor=101) +-- +TABLE: name="hash_f8_heap" schema="" table="hash_f8_heap" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_f8_index2 ON hash_f8_heap USING hash (random float8_ops) WITH (fillfactor=101)" diff --git a/parser/testdata/summary_truncate/postgres_regress/hash_part.metadata.json b/parser/testdata/summary_truncate/postgres_regress/hash_part.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/hash_part.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/hash_part.test b/parser/testdata/summary_truncate/postgres_regress/hash_part.test new file mode 100644 index 0000000..2d7412e --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/hash_part.test @@ -0,0 +1,240 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Hash partitioning. +|-- + +-- Use hand-rolled hash functions and operator classes to get predictable +-- result on different machines. See the definitions of +-- part_test_int4_ops and part_test_text_ops in test_setup.sql. + +CREATE TABLE mchash (a int, b text, c jsonb) + PARTITION BY HASH (a part_test_int4_ops, b part_test_text_ops) +-- +TABLE: name="mchash" schema="" table="mchash" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mchash (a int, b text, c jsonb) PARTITION BY HASH (a part_test_int4_ops, b part_test..." +== 002 +-- truncate_limit: 100 +CREATE TABLE mchash1 + PARTITION OF mchash FOR VALUES WITH (MODULUS 4, REMAINDER 0) +-- +TABLE: name="mchash1" schema="" table="mchash1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mchash1 PARTITION OF mchash FOR VALUES WITH (MODULUS 4, REMAINDER 0)" +== 003 +-- truncate_limit: 100 +-- invalid OID, no such table +SELECT satisfies_hash_partition(0, 4, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition(0, 4, 0, NULL)" +== 004 +-- truncate_limit: 100 +-- not partitioned +SELECT satisfies_hash_partition('tenk1'::regclass, 4, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('tenk1'::regclass, 4, 0, NULL)" +== 005 +-- truncate_limit: 100 +-- partition rather than the parent +SELECT satisfies_hash_partition('mchash1'::regclass, 4, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash1'::regclass, 4, 0, NULL)" +== 006 +-- truncate_limit: 100 +-- invalid modulus +SELECT satisfies_hash_partition('mchash'::regclass, 0, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 0, 0, NULL)" +== 007 +-- truncate_limit: 100 +-- remainder too small +SELECT satisfies_hash_partition('mchash'::regclass, 1, -1, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 1, -1, NULL)" +== 008 +-- truncate_limit: 100 +-- remainder too large +SELECT satisfies_hash_partition('mchash'::regclass, 1, 1, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 1, 1, NULL)" +== 009 +-- truncate_limit: 100 +-- modulus is null +SELECT satisfies_hash_partition('mchash'::regclass, NULL, 0, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, NULL, 0, NULL)" +== 010 +-- truncate_limit: 100 +-- remainder is null +SELECT satisfies_hash_partition('mchash'::regclass, 4, NULL, NULL) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 4, NULL, NULL)" +== 011 +-- truncate_limit: 100 +-- too many arguments +SELECT satisfies_hash_partition('mchash'::regclass, 4, 0, NULL::int, NULL::text, NULL::json) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 012 +-- truncate_limit: 100 +-- too few arguments +SELECT satisfies_hash_partition('mchash'::regclass, 3, 1, NULL::int) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 3, 1, NULL::int)" +== 013 +-- truncate_limit: 100 +-- wrong argument type +SELECT satisfies_hash_partition('mchash'::regclass, 2, 1, NULL::int, NULL::int) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 2, 1, NULL::int, NULL::int)" +== 014 +-- truncate_limit: 100 +-- ok, should be false +SELECT satisfies_hash_partition('mchash'::regclass, 4, 0, 0, ''::text) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 4, 0, 0, ''::text)" +== 015 +-- truncate_limit: 100 +-- ok, should be true +SELECT satisfies_hash_partition('mchash'::regclass, 4, 0, 2, ''::text) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 4, 0, 2, ''::text)" +== 016 +-- truncate_limit: 100 +-- argument via variadic syntax, should fail because not all partitioning +-- columns are of the correct type +SELECT satisfies_hash_partition('mchash'::regclass, 2, 1, + variadic array[1,2]::int[]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mchash'::regclass, 2, 1, VARIADIC ARRAY[1, 2]::int[])" +== 017 +-- truncate_limit: 100 +-- multiple partitioning columns of the same type +CREATE TABLE mcinthash (a int, b int, c jsonb) + PARTITION BY HASH (a part_test_int4_ops, b part_test_int4_ops) +-- +TABLE: name="mcinthash" schema="" table="mcinthash" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcinthash (a int, b int, c jsonb) PARTITION BY HASH (a part_test_int4_ops, b part_te..." +== 018 +-- truncate_limit: 100 +-- now variadic should work, should be false +SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, + variadic array[0, 0]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, VARIADIC ARRAY[0, 0])" +== 019 +-- truncate_limit: 100 +-- should be true +SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, + variadic array[0, 1]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, VARIADIC ARRAY[0, 1])" +== 020 +-- truncate_limit: 100 +-- wrong length +SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, + variadic array[]::int[]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, VARIADIC ARRAY[]::int[])" +== 021 +-- truncate_limit: 100 +-- wrong type +SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, + variadic array[now(), now()]) +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT satisfies_hash_partition('mcinthash'::regclass, 4, 0, VARIADIC ARRAY[now(), now()])" +== 022 +-- truncate_limit: 100 +-- check satisfies_hash_partition passes correct collation +create table text_hashp (a text) partition by hash (a) +-- +TABLE: name="text_hashp" schema="" table="text_hashp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE text_hashp (a text) PARTITION BY HASH (a)" +== 023 +-- truncate_limit: 100 +create table text_hashp0 partition of text_hashp for values with (modulus 2, remainder 0) +-- +TABLE: name="text_hashp0" schema="" table="text_hashp0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE text_hashp0 PARTITION OF text_hashp FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 024 +-- truncate_limit: 100 +create table text_hashp1 partition of text_hashp for values with (modulus 2, remainder 1) +-- +TABLE: name="text_hashp1" schema="" table="text_hashp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE text_hashp1 PARTITION OF text_hashp FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 025 +-- truncate_limit: 100 +-- The result here should always be true, because 'xxx' must belong to +-- one of the two defined partitions +select satisfies_hash_partition('text_hashp'::regclass, 2, 0, 'xxx'::text) OR + satisfies_hash_partition('text_hashp'::regclass, 2, 1, 'xxx'::text) AS satisfies +-- +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +FUNCTION: name="satisfies_hash_partition" function="satisfies_hash_partition" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 026 +-- truncate_limit: 100 +-- cleanup +DROP TABLE mchash +-- +TABLE: name="mchash" schema="" table="mchash" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mchash" +== 027 +-- truncate_limit: 100 +DROP TABLE mcinthash +-- +TABLE: name="mcinthash" schema="" table="mcinthash" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcinthash" +== 028 +-- truncate_limit: 100 +DROP TABLE text_hashp +-- +TABLE: name="text_hashp" schema="" table="text_hashp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE text_hashp" diff --git a/parser/testdata/summary_truncate/postgres_regress/horology.metadata.json b/parser/testdata/summary_truncate/postgres_regress/horology.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/horology.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/horology.test b/parser/testdata/summary_truncate/postgres_regress/horology.test new file mode 100644 index 0000000..24e28e5 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/horology.test @@ -0,0 +1,2771 @@ +== 001 +-- truncate_limit: 100 +|-- +-- HOROLOGY +|-- + +SHOW TimeZone +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TIME ZONE" +== 002 +-- truncate_limit: 100 +-- Many of these tests depend on the prevailing settings +SHOW DateStyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 003 +-- truncate_limit: 100 +|-- +-- Test various input formats +|-- +SELECT timestamp with time zone '20011227 040506+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20011227 040506+08'::timestamp with time zone" +== 004 +-- truncate_limit: 100 +SELECT timestamp with time zone '20011227 040506-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20011227 040506-08'::timestamp with time zone" +== 005 +-- truncate_limit: 100 +SELECT timestamp with time zone '20011227 040506.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20011227 040506.789+08'::timestamp with time zone" +== 006 +-- truncate_limit: 100 +SELECT timestamp with time zone '20011227 040506.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20011227 040506.789-08'::timestamp with time zone" +== 007 +-- truncate_limit: 100 +SELECT timestamp with time zone '20011227T040506+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20011227T040506+08'::timestamp with time zone" +== 008 +-- truncate_limit: 100 +SELECT timestamp with time zone '20011227T040506-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20011227T040506-08'::timestamp with time zone" +== 009 +-- truncate_limit: 100 +SELECT timestamp with time zone '20011227T040506.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20011227T040506.789+08'::timestamp with time zone" +== 010 +-- truncate_limit: 100 +SELECT timestamp with time zone '20011227T040506.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20011227T040506.789-08'::timestamp with time zone" +== 011 +-- truncate_limit: 100 +SELECT timestamp with time zone '2001-12-27 04:05:06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2001-12-27 04:05:06.789-08'::timestamp with time zone" +== 012 +-- truncate_limit: 100 +SELECT timestamp with time zone '2001.12.27 04:05:06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2001.12.27 04:05:06.789-08'::timestamp with time zone" +== 013 +-- truncate_limit: 100 +SELECT timestamp with time zone '2001/12/27 04:05:06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2001/12/27 04:05:06.789-08'::timestamp with time zone" +== 014 +-- truncate_limit: 100 +SELECT timestamp with time zone '12/27/2001 04:05:06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12/27/2001 04:05:06.789-08'::timestamp with time zone" +== 015 +-- truncate_limit: 100 +SELECT timestamp with time zone '2001-12-27 04:05:06.789 MET DST' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2001-12-27 04:05:06.789 MET DST'::timestamp with time zone" +== 016 +-- truncate_limit: 100 +SELECT timestamp with time zone '2001-12-27 allballs' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2001-12-27 allballs'::timestamp with time zone" +== 017 +-- truncate_limit: 100 +-- should fail in mdy mode: +SELECT timestamp with time zone '27/12/2001 04:05:06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '27/12/2001 04:05:06.789-08'::timestamp with time zone" +== 018 +-- truncate_limit: 100 +set datestyle to dmy +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO dmy" +== 019 +-- truncate_limit: 100 +SELECT timestamp with time zone '27/12/2001 04:05:06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '27/12/2001 04:05:06.789-08'::timestamp with time zone" +== 020 +-- truncate_limit: 100 +reset datestyle +-- +STMT: VariableSetStmt +TRUNCATED: "RESET datestyle" +== 021 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271+08'::timestamp with time zone" +== 022 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271-08'::timestamp with time zone" +== 023 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271.5+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271.5+08'::timestamp with time zone" +== 024 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271.5-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271.5-08'::timestamp with time zone" +== 025 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271 04:05:06+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271 04:05:06+08'::timestamp with time zone" +== 026 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271 04:05:06-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271 04:05:06-08'::timestamp with time zone" +== 027 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271T040506+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271T040506+08'::timestamp with time zone" +== 028 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271T040506-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271T040506-08'::timestamp with time zone" +== 029 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271T040506.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271T040506.789+08'::timestamp with time zone" +== 030 +-- truncate_limit: 100 +SELECT timestamp with time zone 'J2452271T040506.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271T040506.789-08'::timestamp with time zone" +== 031 +-- truncate_limit: 100 +-- German/European-style dates with periods as delimiters +SELECT timestamp with time zone '12.27.2001 04:05:06.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12.27.2001 04:05:06.789+08'::timestamp with time zone" +== 032 +-- truncate_limit: 100 +SELECT timestamp with time zone '12.27.2001 04:05:06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12.27.2001 04:05:06.789-08'::timestamp with time zone" +== 033 +-- truncate_limit: 100 +SET DateStyle = 'German' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"German\"" +== 034 +-- truncate_limit: 100 +SELECT timestamp with time zone '27.12.2001 04:05:06.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '27.12.2001 04:05:06.789+08'::timestamp with time zone" +== 035 +-- truncate_limit: 100 +SELECT timestamp with time zone '27.12.2001 04:05:06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '27.12.2001 04:05:06.789-08'::timestamp with time zone" +== 036 +-- truncate_limit: 100 +SET DateStyle = 'ISO' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"ISO\"" +== 037 +-- truncate_limit: 100 +-- As of 7.4, allow time without time zone having a time zone specified +SELECT time without time zone '040506.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '040506.789+08'::time" +== 038 +-- truncate_limit: 100 +SELECT time without time zone '040506.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '040506.789-08'::time" +== 039 +-- truncate_limit: 100 +SELECT time without time zone 'T040506.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.789+08'::time" +== 040 +-- truncate_limit: 100 +SELECT time without time zone 'T040506.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.789-08'::time" +== 041 +-- truncate_limit: 100 +SELECT time with time zone '040506.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '040506.789+08'::time with time zone" +== 042 +-- truncate_limit: 100 +SELECT time with time zone '040506.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '040506.789-08'::time with time zone" +== 043 +-- truncate_limit: 100 +SELECT time with time zone 'T040506.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.789+08'::time with time zone" +== 044 +-- truncate_limit: 100 +SELECT time with time zone 'T040506.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.789-08'::time with time zone" +== 045 +-- truncate_limit: 100 +SELECT time with time zone 'T040506.789 +08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.789 +08'::time with time zone" +== 046 +-- truncate_limit: 100 +SELECT time with time zone 'T040506.789 -08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.789 -08'::time with time zone" +== 047 +-- truncate_limit: 100 +-- time with time zone should accept a date for DST resolution purposes +SELECT time with time zone 'T040506.789 America/Los_Angeles' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.789 America/Los_Angeles'::time with time zone" +== 048 +-- truncate_limit: 100 +SELECT time with time zone '2001-12-27 T040506.789 America/Los_Angeles' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2001-12-27 T040506.789 America/Los_Angeles'::time with time zone" +== 049 +-- truncate_limit: 100 +SELECT time with time zone 'J2452271 T040506.789 America/Los_Angeles' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J2452271 T040506.789 America/Los_Angeles'::time with time zone" +== 050 +-- truncate_limit: 100 +-- Check time formats required by ISO 8601 +SELECT time without time zone '040506.07' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '040506.07'::time" +== 051 +-- truncate_limit: 100 +SELECT time without time zone '04:05:06.07' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '04:05:06.07'::time" +== 052 +-- truncate_limit: 100 +SELECT time without time zone '040506' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '040506'::time" +== 053 +-- truncate_limit: 100 +SELECT time without time zone '04:05:06' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '04:05:06'::time" +== 054 +-- truncate_limit: 100 +SELECT time without time zone '0405' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0405'::time" +== 055 +-- truncate_limit: 100 +SELECT time without time zone '04:05' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '04:05'::time" +== 056 +-- truncate_limit: 100 +SELECT time without time zone 'T040506.07' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.07'::time" +== 057 +-- truncate_limit: 100 +SELECT time without time zone 'T04:05:06.07' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T04:05:06.07'::time" +== 058 +-- truncate_limit: 100 +SELECT time without time zone 'T040506' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506'::time" +== 059 +-- truncate_limit: 100 +SELECT time without time zone 'T04:05:06' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T04:05:06'::time" +== 060 +-- truncate_limit: 100 +SELECT time without time zone 'T0405' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T0405'::time" +== 061 +-- truncate_limit: 100 +SELECT time without time zone 'T04:05' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T04:05'::time" +== 062 +-- truncate_limit: 100 +-- 8601 says "Thh" is allowed, but we intentionally reject it as too vague +SELECT time without time zone 'T04' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T04'::time" +== 063 +-- truncate_limit: 100 +SELECT time with time zone '040506.07+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '040506.07+08'::time with time zone" +== 064 +-- truncate_limit: 100 +SELECT time with time zone '04:05:06.07+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '04:05:06.07+08'::time with time zone" +== 065 +-- truncate_limit: 100 +SELECT time with time zone '040506+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '040506+08'::time with time zone" +== 066 +-- truncate_limit: 100 +SELECT time with time zone '04:05:06+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '04:05:06+08'::time with time zone" +== 067 +-- truncate_limit: 100 +SELECT time with time zone '0405+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0405+08'::time with time zone" +== 068 +-- truncate_limit: 100 +SELECT time with time zone '04:05+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '04:05+08'::time with time zone" +== 069 +-- truncate_limit: 100 +SELECT time with time zone 'T040506.07+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506.07+08'::time with time zone" +== 070 +-- truncate_limit: 100 +SELECT time with time zone 'T04:05:06.07+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T04:05:06.07+08'::time with time zone" +== 071 +-- truncate_limit: 100 +SELECT time with time zone 'T040506+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T040506+08'::time with time zone" +== 072 +-- truncate_limit: 100 +SELECT time with time zone 'T04:05:06+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T04:05:06+08'::time with time zone" +== 073 +-- truncate_limit: 100 +SELECT time with time zone 'T0405+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T0405+08'::time with time zone" +== 074 +-- truncate_limit: 100 +SELECT time with time zone 'T04:05+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T04:05+08'::time with time zone" +== 075 +-- truncate_limit: 100 +-- 8601 says "Thh" is allowed, but we intentionally reject it as too vague +SELECT time with time zone 'T04+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'T04+08'::time with time zone" +== 076 +-- truncate_limit: 100 +SET DateStyle = 'Postgres, MDY' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"Postgres, MDY\"" +== 077 +-- truncate_limit: 100 +-- Check Julian dates BC +SELECT date 'J1520447' AS "Confucius' Birthday" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J1520447'::date AS \"Confucius' Birthday\"" +== 078 +-- truncate_limit: 100 +SELECT date 'J0' AS "Julian Epoch" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J0'::date AS \"Julian Epoch\"" +== 079 +-- truncate_limit: 100 +-- test error on dangling Julian units +SELECT date '1995-08-06 J J J' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 J J J'::date" +== 080 +-- truncate_limit: 100 +SELECT date 'J J 1520447' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'J J 1520447'::date" +== 081 +-- truncate_limit: 100 +-- We used to accept this input style, but it was based on a misreading +-- of ISO8601, and it was never documented anyway +SELECT timestamp with time zone 'Y2001M12D27H04M05S06.789+08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Y2001M12D27H04M05S06.789+08'::timestamp with time zone" +== 082 +-- truncate_limit: 100 +SELECT timestamp with time zone 'Y2001M12D27H04MM05S06.789-08' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Y2001M12D27H04MM05S06.789-08'::timestamp with time zone" +== 083 +-- truncate_limit: 100 +-- conflicting fields should throw errors +SELECT date '1995-08-06 epoch' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 epoch'::date" +== 084 +-- truncate_limit: 100 +SELECT date '1995-08-06 infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 infinity'::date" +== 085 +-- truncate_limit: 100 +SELECT date '1995-08-06 -infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 -infinity'::date" +== 086 +-- truncate_limit: 100 +SELECT date 'today infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'today infinity'::date" +== 087 +-- truncate_limit: 100 +SELECT date '-infinity infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity infinity'::date" +== 088 +-- truncate_limit: 100 +SELECT timestamp '1995-08-06 epoch' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 epoch'::timestamp" +== 089 +-- truncate_limit: 100 +SELECT timestamp '1995-08-06 infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 infinity'::timestamp" +== 090 +-- truncate_limit: 100 +SELECT timestamp '1995-08-06 -infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 -infinity'::timestamp" +== 091 +-- truncate_limit: 100 +SELECT timestamp 'epoch 01:01:01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'epoch 01:01:01'::timestamp" +== 092 +-- truncate_limit: 100 +SELECT timestamp 'infinity 01:01:01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity 01:01:01'::timestamp" +== 093 +-- truncate_limit: 100 +SELECT timestamp '-infinity 01:01:01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity 01:01:01'::timestamp" +== 094 +-- truncate_limit: 100 +SELECT timestamp 'now epoch' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'now epoch'::timestamp" +== 095 +-- truncate_limit: 100 +SELECT timestamp '-infinity infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity infinity'::timestamp" +== 096 +-- truncate_limit: 100 +SELECT timestamptz '1995-08-06 epoch' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 epoch'::timestamptz" +== 097 +-- truncate_limit: 100 +SELECT timestamptz '1995-08-06 infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 infinity'::timestamptz" +== 098 +-- truncate_limit: 100 +SELECT timestamptz '1995-08-06 -infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1995-08-06 -infinity'::timestamptz" +== 099 +-- truncate_limit: 100 +SELECT timestamptz 'epoch 01:01:01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'epoch 01:01:01'::timestamptz" +== 100 +-- truncate_limit: 100 +SELECT timestamptz 'infinity 01:01:01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity 01:01:01'::timestamptz" +== 101 +-- truncate_limit: 100 +SELECT timestamptz '-infinity 01:01:01' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity 01:01:01'::timestamptz" +== 102 +-- truncate_limit: 100 +SELECT timestamptz 'now epoch' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'now epoch'::timestamptz" +== 103 +-- truncate_limit: 100 +SELECT timestamptz '-infinity infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity infinity'::timestamptz" +== 104 +-- truncate_limit: 100 +|-- +-- date, time arithmetic +|-- + +SELECT date '1981-02-03' + time '04:05:06' AS "Date + Time" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1981-02-03'::date + '04:05:06'::time AS \"Date + Time\"" +== 105 +-- truncate_limit: 100 +SELECT date '1991-02-03' + time with time zone '04:05:06 PST' AS "Date + Time PST" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1991-02-03'::date + '04:05:06 PST'::time with time zone AS \"Date + Time PST\"" +== 106 +-- truncate_limit: 100 +SELECT date '2001-02-03' + time with time zone '04:05:06 UTC' AS "Date + Time UTC" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2001-02-03'::date + '04:05:06 UTC'::time with time zone AS \"Date + Time UTC\"" +== 107 +-- truncate_limit: 100 +SELECT date '1991-02-03' + interval '2 years' AS "Add Two Years" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1991-02-03'::date + '2 years'::interval AS \"Add Two Years\"" +== 108 +-- truncate_limit: 100 +SELECT date '2001-12-13' - interval '2 years' AS "Subtract Two Years" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2001-12-13'::date - '2 years'::interval AS \"Subtract Two Years\"" +== 109 +-- truncate_limit: 100 +-- subtract time from date should not make sense; use interval instead +SELECT date '1991-02-03' - time '04:05:06' AS "Subtract Time" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1991-02-03'::date - '04:05:06'::time AS \"Subtract Time\"" +== 110 +-- truncate_limit: 100 +SELECT date '1991-02-03' - time with time zone '04:05:06 UTC' AS "Subtract Time UTC" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1991-02-03'::date - '04:05:06 UTC'::time with time zone AS \"Subtract Time UTC\"" +== 111 +-- truncate_limit: 100 +|-- +-- timestamp, interval arithmetic +|-- + +SELECT timestamp without time zone '1996-03-01' - interval '1 second' AS "Feb 29" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1996-03-01'::timestamp - '1 second'::interval AS \"Feb 29\"" +== 112 +-- truncate_limit: 100 +SELECT timestamp without time zone '1999-03-01' - interval '1 second' AS "Feb 28" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-03-01'::timestamp - '1 second'::interval AS \"Feb 28\"" +== 113 +-- truncate_limit: 100 +SELECT timestamp without time zone '2000-03-01' - interval '1 second' AS "Feb 29" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2000-03-01'::timestamp - '1 second'::interval AS \"Feb 29\"" +== 114 +-- truncate_limit: 100 +SELECT timestamp without time zone '1999-12-01' + interval '1 month - 1 second' AS "Dec 31" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-12-01'::timestamp + '1 month - 1 second'::interval AS \"Dec 31\"" +== 115 +-- truncate_limit: 100 +SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '106000000 days' AS "Feb 23, 285506" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 1, 4713 BC'::timestamp + '106000000 days'::interval AS \"Feb 23, 285506\"" +== 116 +-- truncate_limit: 100 +SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '107000000 days' AS "Jan 20, 288244" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 1, 4713 BC'::timestamp + '107000000 days'::interval AS \"Jan 20, 288244\"" +== 117 +-- truncate_limit: 100 +SELECT timestamp without time zone 'Jan 1, 4713 BC' + interval '109203489 days' AS "Dec 31, 294276" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Jan 1, 4713 BC'::timestamp + '109203489 days'::interval AS \"Dec 31, 294276\"" +== 118 +-- truncate_limit: 100 +SELECT timestamp without time zone '2000-01-01' - interval '2483590 days' AS "out of range" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2000-01-01'::timestamp - '2483590 days'::interval AS \"out of range\"" +== 119 +-- truncate_limit: 100 +SELECT timestamp without time zone '294276-12-31 23:59:59' + interval '9223372036854775807 microseconds' AS "out of range" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 120 +-- truncate_limit: 100 +SELECT timestamp without time zone '12/31/294276' - timestamp without time zone '12/23/1999' AS "106751991 Days" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12/31/294276'::timestamp - '12/23/1999'::timestamp AS \"106751991 Days\"" +== 121 +-- truncate_limit: 100 +-- Shorthand values +-- Not directly usable for regression testing since these are not constants. +-- So, just try to test parser and hope for the best - thomas 97/04/26 +SELECT (timestamp without time zone 'today' = (timestamp without time zone 'yesterday' + interval '1 day')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'today'::timestamp = ('yesterday'::timestamp + '1 day'::interval) AS \"True\"" +== 122 +-- truncate_limit: 100 +SELECT (timestamp without time zone 'today' = (timestamp without time zone 'tomorrow' - interval '1 day')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'today'::timestamp = ('tomorrow'::timestamp - '1 day'::interval) AS \"True\"" +== 123 +-- truncate_limit: 100 +SELECT (timestamp without time zone 'today 10:30' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 124 +-- truncate_limit: 100 +SELECT (timestamp without time zone '10:30 today' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 125 +-- truncate_limit: 100 +SELECT (timestamp without time zone 'tomorrow' = (timestamp without time zone 'yesterday' + interval '2 days')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'tomorrow'::timestamp = ('yesterday'::timestamp + '2 days'::interval) AS \"True\"" +== 126 +-- truncate_limit: 100 +SELECT (timestamp without time zone 'tomorrow 16:00:00' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'tomorrow 16:00:00'::timestamp = ('today'::timestamp + '1 day 16 hours'::interval) AS \"True\"" +== 127 +-- truncate_limit: 100 +SELECT (timestamp without time zone '16:00:00 tomorrow' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '16:00:00 tomorrow'::timestamp = ('today'::timestamp + '1 day 16 hours'::interval) AS \"True\"" +== 128 +-- truncate_limit: 100 +SELECT (timestamp without time zone 'yesterday 12:34:56' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 129 +-- truncate_limit: 100 +SELECT (timestamp without time zone '12:34:56 yesterday' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 130 +-- truncate_limit: 100 +SELECT (timestamp without time zone 'tomorrow' > 'now') as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'tomorrow'::timestamp > 'now' AS \"True\"" +== 131 +-- truncate_limit: 100 +-- Convert from date and time to timestamp +-- This test used to be timestamp(date,time) but no longer allowed by grammar +-- to enable support for SQL99 timestamp type syntax. +SELECT date '1994-01-01' + time '11:00' AS "Jan_01_1994_11am" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1994-01-01'::date + '11:00'::time AS \"Jan_01_1994_11am\"" +== 132 +-- truncate_limit: 100 +SELECT date '1994-01-01' + time '10:00' AS "Jan_01_1994_10am" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1994-01-01'::date + '10:00'::time AS \"Jan_01_1994_10am\"" +== 133 +-- truncate_limit: 100 +SELECT date '1994-01-01' + timetz '11:00-5' AS "Jan_01_1994_8am" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1994-01-01'::date + '11:00-5'::timetz AS \"Jan_01_1994_8am\"" +== 134 +-- truncate_limit: 100 +SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timestamptz('1994-01-01'::date, '11:00-5'::time with time zone) AS \"Jan_01_1994_8am\"" +== 135 +-- truncate_limit: 100 +SELECT d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 + '1 year'::interval AS one_year FROM timestamp_tbl" +== 136 +-- truncate_limit: 100 +SELECT d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 - '1 year'::interval AS one_year FROM timestamp_tbl" +== 137 +-- truncate_limit: 100 +SELECT timestamp with time zone '1996-03-01' - interval '1 second' AS "Feb 29" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1996-03-01'::timestamp with time zone - '1 second'::interval AS \"Feb 29\"" +== 138 +-- truncate_limit: 100 +SELECT timestamp with time zone '1999-03-01' - interval '1 second' AS "Feb 28" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-03-01'::timestamp with time zone - '1 second'::interval AS \"Feb 28\"" +== 139 +-- truncate_limit: 100 +SELECT timestamp with time zone '2000-03-01' - interval '1 second' AS "Feb 29" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2000-03-01'::timestamp with time zone - '1 second'::interval AS \"Feb 29\"" +== 140 +-- truncate_limit: 100 +SELECT timestamp with time zone '1999-12-01' + interval '1 month - 1 second' AS "Dec 31" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1999-12-01'::timestamp with time zone + '1 month - 1 second'::interval AS \"Dec 31\"" +== 141 +-- truncate_limit: 100 +SELECT timestamp with time zone '2000-01-01' - interval '2483590 days' AS "out of range" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2000-01-01'::timestamp with time zone - '2483590 days'::interval AS \"out of range\"" +== 142 +-- truncate_limit: 100 +SELECT timestamp with time zone '294276-12-31 23:59:59 UTC' + interval '9223372036854775807 microseconds' AS "out of range" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 143 +-- truncate_limit: 100 +SELECT (timestamp with time zone 'today' = (timestamp with time zone 'yesterday' + interval '1 day')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 144 +-- truncate_limit: 100 +SELECT (timestamp with time zone 'today' = (timestamp with time zone 'tomorrow' - interval '1 day')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 145 +-- truncate_limit: 100 +SELECT (timestamp with time zone 'tomorrow' = (timestamp with time zone 'yesterday' + interval '2 days')) as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 146 +-- truncate_limit: 100 +SELECT (timestamp with time zone 'tomorrow' > 'now') as "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'tomorrow'::timestamp with time zone > 'now' AS \"True\"" +== 147 +-- truncate_limit: 100 +-- timestamp with time zone, interval arithmetic around DST change +-- (just for fun, let's use an intentionally nonstandard POSIX zone spec) +SET TIME ZONE 'CST7CDT,M4.1.0,M10.5.0' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"CST7CDT,M4.1.0,M10.5.0\"" +== 148 +-- truncate_limit: 100 +SELECT timestamp with time zone '2005-04-02 12:00-07' + interval '1 day' as "Apr 3, 12:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2005-04-02 12:00-07'::timestamp with time zone + '1 day'::interval AS \"Apr 3, 12:00\"" +== 149 +-- truncate_limit: 100 +SELECT timestamp with time zone '2005-04-02 12:00-07' + interval '24 hours' as "Apr 3, 13:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2005-04-02 12:00-07'::timestamp with time zone + '24 hours'::interval AS \"Apr 3, 13:00\"" +== 150 +-- truncate_limit: 100 +SELECT timestamp with time zone '2005-04-03 12:00-06' - interval '1 day' as "Apr 2, 12:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2005-04-03 12:00-06'::timestamp with time zone - '1 day'::interval AS \"Apr 2, 12:00\"" +== 151 +-- truncate_limit: 100 +SELECT timestamp with time zone '2005-04-03 12:00-06' - interval '24 hours' as "Apr 2, 11:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2005-04-03 12:00-06'::timestamp with time zone - '24 hours'::interval AS \"Apr 2, 11:00\"" +== 152 +-- truncate_limit: 100 +RESET TIME ZONE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET timezone" +== 153 +-- truncate_limit: 100 +SELECT timestamptz(date '1994-01-01', time '11:00') AS "Jan_01_1994_10am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timestamptz('1994-01-01'::date, '11:00'::time) AS \"Jan_01_1994_10am\"" +== 154 +-- truncate_limit: 100 +SELECT timestamptz(date '1994-01-01', time '10:00') AS "Jan_01_1994_9am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timestamptz('1994-01-01'::date, '10:00'::time) AS \"Jan_01_1994_9am\"" +== 155 +-- truncate_limit: 100 +SELECT timestamptz(date '1994-01-01', time with time zone '11:00-8') AS "Jan_01_1994_11am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timestamptz('1994-01-01'::date, '11:00-8'::time with time zone) AS \"Jan_01_1994_11am\"" +== 156 +-- truncate_limit: 100 +SELECT timestamptz(date '1994-01-01', time with time zone '10:00-8') AS "Jan_01_1994_10am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timestamptz('1994-01-01'::date, '10:00-8'::time with time zone) AS \"Jan_01_1994_10am\"" +== 157 +-- truncate_limit: 100 +SELECT timestamptz(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am" +-- +FUNCTION: name="timestamptz" function="timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timestamptz('1994-01-01'::date, '11:00-5'::time with time zone) AS \"Jan_01_1994_8am\"" +== 158 +-- truncate_limit: 100 +SELECT d1 + interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 + '1 year'::interval AS one_year FROM timestamptz_tbl" +== 159 +-- truncate_limit: 100 +SELECT d1 - interval '1 year' AS one_year FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 - '1 year'::interval AS one_year FROM timestamptz_tbl" +== 160 +-- truncate_limit: 100 +|-- +-- time, interval arithmetic +|-- + +SELECT CAST(time '01:02' AS interval) AS "+01:02" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01:02'::time::interval AS \"+01:02\"" +== 161 +-- truncate_limit: 100 +SELECT CAST(interval '02:03' AS time) AS "02:03:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '02:03'::interval::time AS \"02:03:00\"" +== 162 +-- truncate_limit: 100 +SELECT CAST(interval '-02:03' AS time) AS "21:57:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-02:03'::interval::time AS \"21:57:00\"" +== 163 +-- truncate_limit: 100 +SELECT CAST(interval '-9223372022400000000 us' AS time) AS "00:00:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372022400000000 us'::interval::time AS \"00:00:00\"" +== 164 +-- truncate_limit: 100 +SELECT time '01:30' + interval '02:01' AS "03:31:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01:30'::time + '02:01'::interval AS \"03:31:00\"" +== 165 +-- truncate_limit: 100 +SELECT time '01:30' - interval '02:01' AS "23:29:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01:30'::time - '02:01'::interval AS \"23:29:00\"" +== 166 +-- truncate_limit: 100 +SELECT time '02:30' + interval '36:01' AS "14:31:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '02:30'::time + '36:01'::interval AS \"14:31:00\"" +== 167 +-- truncate_limit: 100 +SELECT time '03:30' + interval '1 month 04:01' AS "07:31:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '03:30'::time + '1 month 04:01'::interval AS \"07:31:00\"" +== 168 +-- truncate_limit: 100 +SELECT CAST(time with time zone '01:02-08' AS interval) AS "+00:01" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01:02-08'::time with time zone::interval AS \"+00:01\"" +== 169 +-- truncate_limit: 100 +SELECT CAST(interval '02:03' AS time with time zone) AS "02:03:00-08" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '02:03'::interval::time with time zone AS \"02:03:00-08\"" +== 170 +-- truncate_limit: 100 +SELECT time with time zone '01:30-08' - interval '02:01' AS "23:29:00-08" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01:30-08'::time with time zone - '02:01'::interval AS \"23:29:00-08\"" +== 171 +-- truncate_limit: 100 +SELECT time with time zone '02:30-08' + interval '36:01' AS "14:31:00-08" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '02:30-08'::time with time zone + '36:01'::interval AS \"14:31:00-08\"" +== 172 +-- truncate_limit: 100 +-- These two tests cannot be used because they default to current timezone, +-- which may be either -08 or -07 depending on the time of year. +-- SELECT time with time zone '01:30' + interval '02:01' AS "03:31:00-08"; +-- SELECT time with time zone '03:30' + interval '1 month 04:01' AS "07:31:00-08"; +-- Try the following two tests instead, as a poor substitute + +SELECT CAST(CAST(date 'today' + time with time zone '05:30' + + interval '02:01' AS time with time zone) AS time) AS "07:31:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 173 +-- truncate_limit: 100 +SELECT CAST(cast(date 'today' + time with time zone '03:30' + + interval '1 month 04:01' as timestamp without time zone) AS time) AS "07:31:00" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 174 +-- truncate_limit: 100 +SELECT t.d1 AS t, i.f1 AS i, t.d1 + i.f1 AS "add", t.d1 - i.f1 AS "subtract" + FROM TIMESTAMP_TBL t, INTERVAL_TBL i + WHERE t.d1 BETWEEN '1990-01-01' AND '2001-01-01' + AND i.f1 BETWEEN '00:00' AND '23:00' + ORDER BY 1,2 +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "i"="interval_tbl" +ALIAS: "t"="timestamp_tbl" +FILTER: schema="" table="t" column="d1" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamp_tbl t, interval_tbl i WHERE ... ORDER BY 1, 2" +== 175 +-- truncate_limit: 100 +SELECT t.f1 AS t, i.f1 AS i, t.f1 + i.f1 AS "add", t.f1 - i.f1 AS "subtract" + FROM TIME_TBL t, INTERVAL_TBL i + WHERE isfinite(i.f1) + ORDER BY 1,2 +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "i"="interval_tbl" +ALIAS: "t"="time_tbl" +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM time_tbl t, interval_tbl i WHERE isfinite(i.f1) ORDER BY 1, 2" +== 176 +-- truncate_limit: 100 +SELECT t.f1 AS t, i.f1 AS i, t.f1 + i.f1 AS "add", t.f1 - i.f1 AS "subtract" + FROM TIMETZ_TBL t, INTERVAL_TBL i + WHERE isfinite(i.f1) + ORDER BY 1,2 +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "i"="interval_tbl" +ALIAS: "t"="timetz_tbl" +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timetz_tbl t, interval_tbl i WHERE isfinite(i.f1) ORDER BY 1, 2" +== 177 +-- truncate_limit: 100 +-- SQL9x OVERLAPS operator +-- test with time zone +SELECT (timestamp with time zone '2000-11-27', timestamp with time zone '2000-11-28') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 178 +-- truncate_limit: 100 +SELECT (timestamp with time zone '2000-11-26', timestamp with time zone '2000-11-27') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 179 +-- truncate_limit: 100 +SELECT (timestamp with time zone '2000-11-27', timestamp with time zone '2000-11-28') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', interval '1 day') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 180 +-- truncate_limit: 100 +SELECT (timestamp with time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', timestamp with time zone '2000-11-30') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 181 +-- truncate_limit: 100 +SELECT (timestamp with time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp with time zone '2000-11-27', interval '12 hours') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 182 +-- truncate_limit: 100 +SELECT (timestamp with time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp with time zone '2000-11-27 12:00', interval '12 hours') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 183 +-- truncate_limit: 100 +-- test without time zone +SELECT (timestamp without time zone '2000-11-27', timestamp without time zone '2000-11-28') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 184 +-- truncate_limit: 100 +SELECT (timestamp without time zone '2000-11-26', timestamp without time zone '2000-11-27') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 185 +-- truncate_limit: 100 +SELECT (timestamp without time zone '2000-11-27', timestamp without time zone '2000-11-28') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', interval '1 day') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 186 +-- truncate_limit: 100 +SELECT (timestamp without time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', timestamp without time zone '2000-11-30') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 187 +-- truncate_limit: 100 +SELECT (timestamp without time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp without time zone '2000-11-27', interval '12 hours') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 188 +-- truncate_limit: 100 +SELECT (timestamp without time zone '2000-11-27', interval '12 hours') + OVERLAPS (timestamp without time zone '2000-11-27 12:00', interval '12 hours') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 189 +-- truncate_limit: 100 +-- test time and interval +SELECT (time '00:00', time '01:00') + OVERLAPS (time '00:30', time '01:30') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ('00:00'::time, '01:00'::time) overlaps ('00:30'::time, '01:30'::time) AS \"True\"" +== 190 +-- truncate_limit: 100 +SELECT (time '00:00', interval '1 hour') + OVERLAPS (time '00:30', interval '1 hour') AS "True" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ('00:00'::time, '1 hour'::interval) overlaps ('00:30'::time, '1 hour'::interval) AS \"True\"" +== 191 +-- truncate_limit: 100 +SELECT (time '00:00', interval '1 hour') + OVERLAPS (time '01:30', interval '1 hour') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ('00:00'::time, '1 hour'::interval) overlaps ('01:30'::time, '1 hour'::interval) AS \"False\"" +== 192 +-- truncate_limit: 100 +-- SQL99 seems to want this to be false (and we conform to the spec). +-- istm that this *should* return true, on the theory that time +-- intervals can wrap around the day boundary - thomas 2001-09-25 +SELECT (time '00:00', interval '1 hour') + OVERLAPS (time '01:30', interval '1 day') AS "False" +-- +FUNCTION: name="pg_catalog.overlaps" function="overlaps" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ('00:00'::time, '1 hour'::interval) overlaps ('01:30'::time, '1 day'::interval) AS \"False\"" +== 193 +-- truncate_limit: 100 +CREATE TABLE TEMP_TIMESTAMP (f1 timestamp with time zone) +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE temp_timestamp (f1 timestamp with time zone)" +== 194 +-- truncate_limit: 100 +-- get some candidate input values + +INSERT INTO TEMP_TIMESTAMP (f1) + SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 BETWEEN '13-jun-1957' AND '1-jan-1997' + OR d1 BETWEEN '1-jan-1999' AND '1-jan-2010' +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=DML +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +FILTER: schema="" table="" column="d1" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temp_timestamp (f1) SELECT d1 FROM timestamp_tbl WHERE ..." +== 195 +-- truncate_limit: 100 +SELECT f1 AS "timestamp" + FROM TEMP_TIMESTAMP + ORDER BY "timestamp" +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"timestamp\" FROM temp_timestamp ORDER BY \"timestamp\"" +== 196 +-- truncate_limit: 100 +SELECT d.f1 AS "timestamp", t.f1 AS "interval", d.f1 + t.f1 AS plus + FROM TEMP_TIMESTAMP d, INTERVAL_TBL t + ORDER BY plus, "timestamp", "interval" +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "d"="temp_timestamp" +ALIAS: "t"="interval_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM temp_timestamp d, interval_tbl t ORDER BY plus, \"timestamp\", \"interval\"" +== 197 +-- truncate_limit: 100 +SELECT d.f1 AS "timestamp", t.f1 AS "interval", d.f1 - t.f1 AS minus + FROM TEMP_TIMESTAMP d, INTERVAL_TBL t + ORDER BY minus, "timestamp", "interval" +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "d"="temp_timestamp" +ALIAS: "t"="interval_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM temp_timestamp d, interval_tbl t ORDER BY minus, \"timestamp\", \"interval\"" +== 198 +-- truncate_limit: 100 +SELECT d.f1 AS "timestamp", + timestamp with time zone '1980-01-06 00:00 GMT' AS gpstime_zero, + d.f1 - timestamp with time zone '1980-01-06 00:00 GMT' AS difference + FROM TEMP_TIMESTAMP d + ORDER BY difference +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +ALIAS: "d"="temp_timestamp" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM temp_timestamp d ORDER BY difference" +== 199 +-- truncate_limit: 100 +SELECT d1.f1 AS timestamp1, d2.f1 AS timestamp2, d1.f1 - d2.f1 AS difference + FROM TEMP_TIMESTAMP d1, TEMP_TIMESTAMP d2 + ORDER BY timestamp1, timestamp2, difference +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +ALIAS: "d1"="temp_timestamp" +ALIAS: "d2"="temp_timestamp" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM temp_timestamp d1, temp_timestamp d2 ORDER BY timestamp1, timestamp2, difference" +== 200 +-- truncate_limit: 100 +|-- +-- Conversions +|-- + +SELECT f1 AS "timestamp", date(f1) AS date + FROM TEMP_TIMESTAMP + WHERE f1 <> timestamp 'now' + ORDER BY date, "timestamp" +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=Select +FUNCTION: name="date" function="date" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM temp_timestamp WHERE f1 <> 'now'::timestamp ORDER BY date, \"timestamp\"" +== 201 +-- truncate_limit: 100 +DROP TABLE TEMP_TIMESTAMP +-- +TABLE: name="temp_timestamp" schema="" table="temp_timestamp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_timestamp" +== 202 +-- truncate_limit: 100 +|-- +-- Comparisons between datetime types, especially overflow cases +--- + +SELECT '2202020-10-05'::date::timestamp +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2202020-10-05'::date::timestamp" +== 203 +-- truncate_limit: 100 +-- fail +SELECT '2202020-10-05'::date > '2020-10-05'::timestamp as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2202020-10-05'::date > '2020-10-05'::timestamp AS t" +== 204 +-- truncate_limit: 100 +SELECT '2020-10-05'::timestamp > '2202020-10-05'::date as f +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2020-10-05'::timestamp > '2202020-10-05'::date AS f" +== 205 +-- truncate_limit: 100 +SELECT '2202020-10-05'::date::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2202020-10-05'::date::timestamptz" +== 206 +-- truncate_limit: 100 +-- fail +SELECT '2202020-10-05'::date > '2020-10-05'::timestamptz as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2202020-10-05'::date > '2020-10-05'::timestamptz AS t" +== 207 +-- truncate_limit: 100 +SELECT '2020-10-05'::timestamptz > '2202020-10-05'::date as f +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2020-10-05'::timestamptz > '2202020-10-05'::date AS f" +== 208 +-- truncate_limit: 100 +-- This conversion may work depending on timezone +SELECT '4714-11-24 BC'::date::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-24 BC'::date::timestamptz" +== 209 +-- truncate_limit: 100 +SET TimeZone = 'UTC-2' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"UTC-2\"" +== 210 +-- truncate_limit: 100 +SELECT '4714-11-24 BC'::date::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-24 BC'::date::timestamptz" +== 211 +-- truncate_limit: 100 +-- fail + +SELECT '4714-11-24 BC'::date < '2020-10-05'::timestamptz as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-24 BC'::date < '2020-10-05'::timestamptz AS t" +== 212 +-- truncate_limit: 100 +SELECT '2020-10-05'::timestamptz >= '4714-11-24 BC'::date as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2020-10-05'::timestamptz >= '4714-11-24 BC'::date AS t" +== 213 +-- truncate_limit: 100 +SELECT '4714-11-24 BC'::timestamp < '2020-10-05'::timestamptz as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-24 BC'::timestamp < '2020-10-05'::timestamptz AS t" +== 214 +-- truncate_limit: 100 +SELECT '2020-10-05'::timestamptz >= '4714-11-24 BC'::timestamp as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2020-10-05'::timestamptz >= '4714-11-24 BC'::timestamp AS t" +== 215 +-- truncate_limit: 100 +RESET TimeZone +-- +STMT: VariableSetStmt +TRUNCATED: "RESET timezone" +== 216 +-- truncate_limit: 100 +|-- +-- Tests for BETWEEN +|-- + +explain (costs off) +select count(*) from date_tbl + where f1 between '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM date_tbl WHERE f1 BETWEEN '1997-01-01' AND '1998-01-01'" +== 217 +-- truncate_limit: 100 +select count(*) from date_tbl + where f1 between '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM date_tbl WHERE f1 BETWEEN '1997-01-01' AND '1998-01-01'" +== 218 +-- truncate_limit: 100 +explain (costs off) +select count(*) from date_tbl + where f1 not between '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM date_tbl WHERE f1 NOT BETWEEN '1997-01-01' AND '1998-01-01'" +== 219 +-- truncate_limit: 100 +select count(*) from date_tbl + where f1 not between '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM date_tbl WHERE f1 NOT BETWEEN '1997-01-01' AND '1998-01-01'" +== 220 +-- truncate_limit: 100 +explain (costs off) +select count(*) from date_tbl + where f1 between symmetric '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM date_tbl WHERE f1 BETWEEN SYMMETRIC '1997-01-01' AND '19..." +== 221 +-- truncate_limit: 100 +select count(*) from date_tbl + where f1 between symmetric '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM date_tbl WHERE f1 BETWEEN SYMMETRIC '1997-01-01' AND '1998-01-01'" +== 222 +-- truncate_limit: 100 +explain (costs off) +select count(*) from date_tbl + where f1 not between symmetric '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM date_tbl WHERE f1 NOT BETWEEN SYMMETRIC '1997-01-01' AND..." +== 223 +-- truncate_limit: 100 +select count(*) from date_tbl + where f1 not between symmetric '1997-01-01' and '1998-01-01' +-- +TABLE: name="date_tbl" schema="" table="date_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM date_tbl WHERE f1 NOT BETWEEN SYMMETRIC '1997-01-01' AND '1998-01-01'" +== 224 +-- truncate_limit: 100 +|-- +-- Formats +|-- + +SET DateStyle TO 'US,Postgres' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"US,Postgres\"" +== 225 +-- truncate_limit: 100 +SHOW DateStyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 226 +-- truncate_limit: 100 +SELECT d1 AS us_postgres FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 AS us_postgres FROM timestamp_tbl" +== 227 +-- truncate_limit: 100 +SET DateStyle TO 'US,ISO' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"US,ISO\"" +== 228 +-- truncate_limit: 100 +SELECT d1 AS us_iso FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 AS us_iso FROM timestamp_tbl" +== 229 +-- truncate_limit: 100 +SET DateStyle TO 'US,SQL' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"US,SQL\"" +== 230 +-- truncate_limit: 100 +SHOW DateStyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 231 +-- truncate_limit: 100 +SELECT d1 AS us_sql FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 AS us_sql FROM timestamp_tbl" +== 232 +-- truncate_limit: 100 +SET DateStyle TO 'European,Postgres' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"European,Postgres\"" +== 233 +-- truncate_limit: 100 +SHOW DateStyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 234 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES('13/06/1957') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('13/06/1957')" +== 235 +-- truncate_limit: 100 +SELECT count(*) as one FROM TIMESTAMP_TBL WHERE d1 = 'Jun 13 1957' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS one FROM timestamp_tbl WHERE d1 = 'Jun 13 1957'" +== 236 +-- truncate_limit: 100 +SELECT d1 AS european_postgres FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 AS european_postgres FROM timestamp_tbl" +== 237 +-- truncate_limit: 100 +SET DateStyle TO 'European,ISO' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"European,ISO\"" +== 238 +-- truncate_limit: 100 +SHOW DateStyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 239 +-- truncate_limit: 100 +SELECT d1 AS european_iso FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 AS european_iso FROM timestamp_tbl" +== 240 +-- truncate_limit: 100 +SET DateStyle TO 'European,SQL' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"European,SQL\"" +== 241 +-- truncate_limit: 100 +SHOW DateStyle +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW datestyle" +== 242 +-- truncate_limit: 100 +SELECT d1 AS european_sql FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 AS european_sql FROM timestamp_tbl" +== 243 +-- truncate_limit: 100 +RESET DateStyle +-- +STMT: VariableSetStmt +TRUNCATED: "RESET datestyle" +== 244 +-- truncate_limit: 100 +|-- +-- to_timestamp() +|-- + +SELECT to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS')" +== 245 +-- truncate_limit: 100 +SELECT to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS')" +== 246 +-- truncate_limit: 100 +SELECT to_timestamp('2011$03!18 23_38_15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011$03!18 23_38_15', 'YYYY-MM-DD HH24:MI:SS')" +== 247 +-- truncate_limit: 100 +SELECT to_timestamp('1985 January 12', 'YYYY FMMonth DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('1985 January 12', 'YYYY FMMonth DD')" +== 248 +-- truncate_limit: 100 +SELECT to_timestamp('1985 FMMonth 12', 'YYYY "FMMonth" DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('1985 FMMonth 12', 'YYYY \"FMMonth\" DD')" +== 249 +-- truncate_limit: 100 +SELECT to_timestamp('1985 \ 12', 'YYYY \\ DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(E'1985 \\\\ 12', E'YYYY \\\\\\\\ DD')" +== 250 +-- truncate_limit: 100 +SELECT to_timestamp('My birthday-> Year: 1976, Month: May, Day: 16', + '"My birthday-> Year:" YYYY, "Month:" FMMonth, "Day:" DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 251 +-- truncate_limit: 100 +SELECT to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD')" +== 252 +-- truncate_limit: 100 +SELECT to_timestamp('15 "text between quote marks" 98 54 45', + E'HH24 "\\"text between quote marks\\"" YY MI SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 253 +-- truncate_limit: 100 +SELECT to_timestamp('05121445482000', 'MMDDHH24MISSYYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('05121445482000', 'MMDDHH24MISSYYYY')" +== 254 +-- truncate_limit: 100 +SELECT to_timestamp('2000January09Sunday', 'YYYYFMMonthDDFMDay') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000January09Sunday', 'YYYYFMMonthDDFMDay')" +== 255 +-- truncate_limit: 100 +SELECT to_timestamp('97/Feb/16', 'YYMonDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('97/Feb/16', 'YYMonDD')" +== 256 +-- truncate_limit: 100 +SELECT to_timestamp('97/Feb/16', 'YY:Mon:DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('97/Feb/16', 'YY:Mon:DD')" +== 257 +-- truncate_limit: 100 +SELECT to_timestamp('97/Feb/16', 'FXYY:Mon:DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('97/Feb/16', 'FXYY:Mon:DD')" +== 258 +-- truncate_limit: 100 +SELECT to_timestamp('97/Feb/16', 'FXYY/Mon/DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('97/Feb/16', 'FXYY/Mon/DD')" +== 259 +-- truncate_limit: 100 +SELECT to_timestamp('19971116', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('19971116', 'YYYYMMDD')" +== 260 +-- truncate_limit: 100 +SELECT to_timestamp('20000-1116', 'YYYY-MMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('20000-1116', 'YYYY-MMDD')" +== 261 +-- truncate_limit: 100 +SELECT to_timestamp('1997 AD 11 16', 'YYYY BC MM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('1997 AD 11 16', 'YYYY BC MM DD')" +== 262 +-- truncate_limit: 100 +SELECT to_timestamp('1997 BC 11 16', 'YYYY BC MM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('1997 BC 11 16', 'YYYY BC MM DD')" +== 263 +-- truncate_limit: 100 +SELECT to_timestamp('1997 A.D. 11 16', 'YYYY B.C. MM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('1997 A.D. 11 16', 'YYYY B.C. MM DD')" +== 264 +-- truncate_limit: 100 +SELECT to_timestamp('1997 B.C. 11 16', 'YYYY B.C. MM DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('1997 B.C. 11 16', 'YYYY B.C. MM DD')" +== 265 +-- truncate_limit: 100 +SELECT to_timestamp('9-1116', 'Y-MMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('9-1116', 'Y-MMDD')" +== 266 +-- truncate_limit: 100 +SELECT to_timestamp('95-1116', 'YY-MMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('95-1116', 'YY-MMDD')" +== 267 +-- truncate_limit: 100 +SELECT to_timestamp('995-1116', 'YYY-MMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('995-1116', 'YYY-MMDD')" +== 268 +-- truncate_limit: 100 +SELECT to_timestamp('2005426', 'YYYYWWD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2005426', 'YYYYWWD')" +== 269 +-- truncate_limit: 100 +SELECT to_timestamp('2005300', 'YYYYDDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2005300', 'YYYYDDD')" +== 270 +-- truncate_limit: 100 +SELECT to_timestamp('2005527', 'IYYYIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2005527', 'IYYYIWID')" +== 271 +-- truncate_limit: 100 +SELECT to_timestamp('005527', 'IYYIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('005527', 'IYYIWID')" +== 272 +-- truncate_limit: 100 +SELECT to_timestamp('05527', 'IYIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('05527', 'IYIWID')" +== 273 +-- truncate_limit: 100 +SELECT to_timestamp('5527', 'IIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('5527', 'IIWID')" +== 274 +-- truncate_limit: 100 +SELECT to_timestamp('2005364', 'IYYYIDDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2005364', 'IYYYIDDD')" +== 275 +-- truncate_limit: 100 +SELECT to_timestamp('20050302', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('20050302', 'YYYYMMDD')" +== 276 +-- truncate_limit: 100 +SELECT to_timestamp('2005 03 02', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2005 03 02', 'YYYYMMDD')" +== 277 +-- truncate_limit: 100 +SELECT to_timestamp(' 2005 03 02', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(' 2005 03 02', 'YYYYMMDD')" +== 278 +-- truncate_limit: 100 +SELECT to_timestamp(' 20050302', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(' 20050302', 'YYYYMMDD')" +== 279 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 AM', 'YYYY-MM-DD HH12:MI PM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 AM', 'YYYY-MM-DD HH12:MI PM')" +== 280 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 PM', 'YYYY-MM-DD HH12:MI PM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 PM', 'YYYY-MM-DD HH12:MI PM')" +== 281 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 A.M.', 'YYYY-MM-DD HH12:MI P.M.') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 A.M.', 'YYYY-MM-DD HH12:MI P.M.')" +== 282 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 P.M.', 'YYYY-MM-DD HH12:MI P.M.') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 P.M.', 'YYYY-MM-DD HH12:MI P.M.')" +== 283 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 +05', 'YYYY-MM-DD HH12:MI TZH') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 +05', 'YYYY-MM-DD HH12:MI TZH')" +== 284 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI TZH') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI TZH')" +== 285 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 +05:20', 'YYYY-MM-DD HH12:MI TZH:TZM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 +05:20', 'YYYY-MM-DD HH12:MI TZH:TZM')" +== 286 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 -05:20', 'YYYY-MM-DD HH12:MI TZH:TZM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 -05:20', 'YYYY-MM-DD HH12:MI TZH:TZM')" +== 287 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 20', 'YYYY-MM-DD HH12:MI TZM') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 20', 'YYYY-MM-DD HH12:MI TZM')" +== 288 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 EST', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 EST', 'YYYY-MM-DD HH12:MI TZ')" +== 289 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI TZ')" +== 290 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 +01:30', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 +01:30', 'YYYY-MM-DD HH12:MI TZ')" +== 291 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 MSK', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 MSK', 'YYYY-MM-DD HH12:MI TZ')" +== 292 +-- truncate_limit: 100 +-- dyntz +SELECT to_timestamp('2011-12-18 11:38ESTFOO24', 'YYYY-MM-DD HH12:MITZFOOSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38ESTFOO24', 'YYYY-MM-DD HH12:MITZFOOSS')" +== 293 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38-05FOO24', 'YYYY-MM-DD HH12:MITZFOOSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38-05FOO24', 'YYYY-MM-DD HH12:MITZFOOSS')" +== 294 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 JUNK', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 JUNK', 'YYYY-MM-DD HH12:MI TZ')" +== 295 +-- truncate_limit: 100 +-- error +SELECT to_timestamp('2011-12-18 11:38 ...', 'YYYY-MM-DD HH12:MI TZ') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 ...', 'YYYY-MM-DD HH12:MI TZ')" +== 296 +-- truncate_limit: 100 +-- error + +SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI OF') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 -05', 'YYYY-MM-DD HH12:MI OF')" +== 297 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 +01:30', 'YYYY-MM-DD HH12:MI OF') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 +01:30', 'YYYY-MM-DD HH12:MI OF')" +== 298 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 11:38 +xyz', 'YYYY-MM-DD HH12:MI OF') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 +xyz', 'YYYY-MM-DD HH12:MI OF')" +== 299 +-- truncate_limit: 100 +-- error +SELECT to_timestamp('2011-12-18 11:38 +01:xyz', 'YYYY-MM-DD HH12:MI OF') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 11:38 +01:xyz', 'YYYY-MM-DD HH12:MI OF')" +== 300 +-- truncate_limit: 100 +-- error + +SELECT to_timestamp('2018-11-02 12:34:56.025', 'YYYY-MM-DD HH24:MI:SS.MS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2018-11-02 12:34:56.025', 'YYYY-MM-DD HH24:MI:SS.MS')" +== 301 +-- truncate_limit: 100 +SELECT i, to_timestamp('2018-11-02 12:34:56', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 302 +-- truncate_limit: 100 +SELECT i, to_timestamp('2018-11-02 12:34:56.1', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 303 +-- truncate_limit: 100 +SELECT i, to_timestamp('2018-11-02 12:34:56.12', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 304 +-- truncate_limit: 100 +SELECT i, to_timestamp('2018-11-02 12:34:56.123', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 305 +-- truncate_limit: 100 +SELECT i, to_timestamp('2018-11-02 12:34:56.1234', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 306 +-- truncate_limit: 100 +SELECT i, to_timestamp('2018-11-02 12:34:56.12345', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 307 +-- truncate_limit: 100 +SELECT i, to_timestamp('2018-11-02 12:34:56.123456', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 308 +-- truncate_limit: 100 +SELECT i, to_timestamp('2018-11-02 12:34:56.123456789', 'YYYY-MM-DD HH24:MI:SS.FF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 309 +-- truncate_limit: 100 +SELECT i, to_timestamp('20181102123456123456', 'YYYYMMDDHH24MISSFF' || i) FROM generate_series(1, 6) i +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 6) i" +== 310 +-- truncate_limit: 100 +SELECT to_date('1 4 1902', 'Q MM YYYY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('1 4 1902', 'Q MM YYYY')" +== 311 +-- truncate_limit: 100 +-- Q is ignored +SELECT to_date('3 4 21 01', 'W MM CC YY') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('3 4 21 01', 'W MM CC YY')" +== 312 +-- truncate_limit: 100 +SELECT to_date('2458872', 'J') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2458872', 'J')" +== 313 +-- truncate_limit: 100 +|-- +-- Check handling of BC dates +|-- + +SELECT to_date('44-02-01 BC','YYYY-MM-DD BC') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('44-02-01 BC', 'YYYY-MM-DD BC')" +== 314 +-- truncate_limit: 100 +SELECT to_date('-44-02-01','YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('-44-02-01', 'YYYY-MM-DD')" +== 315 +-- truncate_limit: 100 +SELECT to_date('-44-02-01 BC','YYYY-MM-DD BC') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('-44-02-01 BC', 'YYYY-MM-DD BC')" +== 316 +-- truncate_limit: 100 +SELECT to_timestamp('44-02-01 11:12:13 BC','YYYY-MM-DD HH24:MI:SS BC') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('44-02-01 11:12:13 BC', 'YYYY-MM-DD HH24:MI:SS BC')" +== 317 +-- truncate_limit: 100 +SELECT to_timestamp('-44-02-01 11:12:13','YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('-44-02-01 11:12:13', 'YYYY-MM-DD HH24:MI:SS')" +== 318 +-- truncate_limit: 100 +SELECT to_timestamp('-44-02-01 11:12:13 BC','YYYY-MM-DD HH24:MI:SS BC') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('-44-02-01 11:12:13 BC', 'YYYY-MM-DD HH24:MI:SS BC')" +== 319 +-- truncate_limit: 100 +|-- +-- Check handling of multiple spaces in format and/or input +|-- + +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS')" +== 320 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS')" +== 321 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS')" +== 322 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS')" +== 323 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS')" +== 324 +-- truncate_limit: 100 +SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2011-12-18 23:38:15', 'YYYY-MM-DD HH24:MI:SS')" +== 325 +-- truncate_limit: 100 +SELECT to_timestamp('2000+ JUN', 'YYYY/MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000+ JUN', 'YYYY/MON')" +== 326 +-- truncate_limit: 100 +SELECT to_timestamp(' 2000 +JUN', 'YYYY/MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(' 2000 +JUN', 'YYYY/MON')" +== 327 +-- truncate_limit: 100 +SELECT to_timestamp(' 2000 +JUN', 'YYYY//MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(' 2000 +JUN', 'YYYY//MON')" +== 328 +-- truncate_limit: 100 +SELECT to_timestamp('2000 +JUN', 'YYYY//MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000 +JUN', 'YYYY//MON')" +== 329 +-- truncate_limit: 100 +SELECT to_timestamp('2000 + JUN', 'YYYY MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000 + JUN', 'YYYY MON')" +== 330 +-- truncate_limit: 100 +SELECT to_timestamp('2000 ++ JUN', 'YYYY MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000 ++ JUN', 'YYYY MON')" +== 331 +-- truncate_limit: 100 +SELECT to_timestamp('2000 + + JUN', 'YYYY MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000 + + JUN', 'YYYY MON')" +== 332 +-- truncate_limit: 100 +SELECT to_timestamp('2000 + + JUN', 'YYYY MON') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000 + + JUN', 'YYYY MON')" +== 333 +-- truncate_limit: 100 +SELECT to_timestamp('2000 -10', 'YYYY TZH') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000 -10', 'YYYY TZH')" +== 334 +-- truncate_limit: 100 +SELECT to_timestamp('2000 -10', 'YYYY TZH') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2000 -10', 'YYYY TZH')" +== 335 +-- truncate_limit: 100 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011 12 18', 'YYYY MM DD')" +== 336 +-- truncate_limit: 100 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011 12 18', 'YYYY MM DD')" +== 337 +-- truncate_limit: 100 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011 12 18', 'YYYY MM DD')" +== 338 +-- truncate_limit: 100 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011 12 18', 'YYYY MM DD')" +== 339 +-- truncate_limit: 100 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011 12 18', 'YYYY MM DD')" +== 340 +-- truncate_limit: 100 +SELECT to_date('2011 12 18', 'YYYY MM DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011 12 18', 'YYYY MM DD')" +== 341 +-- truncate_limit: 100 +SELECT to_date('2011 12 18', 'YYYYxMMxDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011 12 18', 'YYYYxMMxDD')" +== 342 +-- truncate_limit: 100 +SELECT to_date('2011x 12x 18', 'YYYYxMMxDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011x 12x 18', 'YYYYxMMxDD')" +== 343 +-- truncate_limit: 100 +SELECT to_date('2011 x12 x18', 'YYYYxMMxDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2011 x12 x18', 'YYYYxMMxDD')" +== 344 +-- truncate_limit: 100 +|-- +-- Check errors for some incorrect usages of to_timestamp() and to_date() +|-- + +-- Mixture of date conventions (ISO week and Gregorian): +SELECT to_timestamp('2005527', 'YYYYIWID') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2005527', 'YYYYIWID')" +== 345 +-- truncate_limit: 100 +-- Insufficient characters in the source string: +SELECT to_timestamp('19971', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('19971', 'YYYYMMDD')" +== 346 +-- truncate_limit: 100 +-- Insufficient digit characters for a single node: +SELECT to_timestamp('19971)24', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('19971)24', 'YYYYMMDD')" +== 347 +-- truncate_limit: 100 +-- We don't accept full-length day or month names if short form is specified: +SELECT to_timestamp('Friday 1-January-1999', 'DY DD MON YYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('Friday 1-January-1999', 'DY DD MON YYYY')" +== 348 +-- truncate_limit: 100 +SELECT to_timestamp('Fri 1-January-1999', 'DY DD MON YYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('Fri 1-January-1999', 'DY DD MON YYYY')" +== 349 +-- truncate_limit: 100 +SELECT to_timestamp('Fri 1-Jan-1999', 'DY DD MON YYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('Fri 1-Jan-1999', 'DY DD MON YYYY')" +== 350 +-- truncate_limit: 100 +-- ok + +-- Value clobbering: +SELECT to_timestamp('1997-11-Jan-16', 'YYYY-MM-Mon-DD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('1997-11-Jan-16', 'YYYY-MM-Mon-DD')" +== 351 +-- truncate_limit: 100 +-- Non-numeric input: +SELECT to_timestamp('199711xy', 'YYYYMMDD') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('199711xy', 'YYYYMMDD')" +== 352 +-- truncate_limit: 100 +-- Input that doesn't fit in an int: +SELECT to_timestamp('10000000000', 'FMYYYY') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('10000000000', 'FMYYYY')" +== 353 +-- truncate_limit: 100 +-- Out-of-range and not-quite-out-of-range fields: +SELECT to_timestamp('2016-06-13 25:00:00', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2016-06-13 25:00:00', 'YYYY-MM-DD HH24:MI:SS')" +== 354 +-- truncate_limit: 100 +SELECT to_timestamp('2016-06-13 15:60:00', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2016-06-13 15:60:00', 'YYYY-MM-DD HH24:MI:SS')" +== 355 +-- truncate_limit: 100 +SELECT to_timestamp('2016-06-13 15:50:60', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2016-06-13 15:50:60', 'YYYY-MM-DD HH24:MI:SS')" +== 356 +-- truncate_limit: 100 +SELECT to_timestamp('2016-06-13 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2016-06-13 15:50:55', 'YYYY-MM-DD HH24:MI:SS')" +== 357 +-- truncate_limit: 100 +-- ok +SELECT to_timestamp('2016-06-13 15:50:55', 'YYYY-MM-DD HH:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2016-06-13 15:50:55', 'YYYY-MM-DD HH:MI:SS')" +== 358 +-- truncate_limit: 100 +SELECT to_timestamp('2016-13-01 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2016-13-01 15:50:55', 'YYYY-MM-DD HH24:MI:SS')" +== 359 +-- truncate_limit: 100 +SELECT to_timestamp('2016-02-30 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2016-02-30 15:50:55', 'YYYY-MM-DD HH24:MI:SS')" +== 360 +-- truncate_limit: 100 +SELECT to_timestamp('2016-02-29 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2016-02-29 15:50:55', 'YYYY-MM-DD HH24:MI:SS')" +== 361 +-- truncate_limit: 100 +-- ok +SELECT to_timestamp('2015-02-29 15:50:55', 'YYYY-MM-DD HH24:MI:SS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2015-02-29 15:50:55', 'YYYY-MM-DD HH24:MI:SS')" +== 362 +-- truncate_limit: 100 +SELECT to_timestamp('2015-02-11 86000', 'YYYY-MM-DD SSSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2015-02-11 86000', 'YYYY-MM-DD SSSS')" +== 363 +-- truncate_limit: 100 +-- ok +SELECT to_timestamp('2015-02-11 86400', 'YYYY-MM-DD SSSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2015-02-11 86400', 'YYYY-MM-DD SSSS')" +== 364 +-- truncate_limit: 100 +SELECT to_timestamp('2015-02-11 86000', 'YYYY-MM-DD SSSSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2015-02-11 86000', 'YYYY-MM-DD SSSSS')" +== 365 +-- truncate_limit: 100 +-- ok +SELECT to_timestamp('2015-02-11 86400', 'YYYY-MM-DD SSSSS') +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('2015-02-11 86400', 'YYYY-MM-DD SSSSS')" +== 366 +-- truncate_limit: 100 +SELECT to_date('2016-13-10', 'YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2016-13-10', 'YYYY-MM-DD')" +== 367 +-- truncate_limit: 100 +SELECT to_date('2016-02-30', 'YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2016-02-30', 'YYYY-MM-DD')" +== 368 +-- truncate_limit: 100 +SELECT to_date('2016-02-29', 'YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2016-02-29', 'YYYY-MM-DD')" +== 369 +-- truncate_limit: 100 +-- ok +SELECT to_date('2015-02-29', 'YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2015-02-29', 'YYYY-MM-DD')" +== 370 +-- truncate_limit: 100 +SELECT to_date('2015 365', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2015 365', 'YYYY DDD')" +== 371 +-- truncate_limit: 100 +-- ok +SELECT to_date('2015 366', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2015 366', 'YYYY DDD')" +== 372 +-- truncate_limit: 100 +SELECT to_date('2016 365', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2016 365', 'YYYY DDD')" +== 373 +-- truncate_limit: 100 +-- ok +SELECT to_date('2016 366', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2016 366', 'YYYY DDD')" +== 374 +-- truncate_limit: 100 +-- ok +SELECT to_date('2016 367', 'YYYY DDD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('2016 367', 'YYYY DDD')" +== 375 +-- truncate_limit: 100 +SELECT to_date('0000-02-01','YYYY-MM-DD') +-- +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_date('0000-02-01', 'YYYY-MM-DD')" +== 376 +-- truncate_limit: 100 +-- allowed, though it shouldn't be + +-- to_char's TZ format code produces zone abbrev if known +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ')" +== 377 +-- truncate_limit: 100 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS tz') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS tz')" +== 378 +-- truncate_limit: 100 +|-- +-- Check behavior with SQL-style fixed-GMT-offset time zone (cf bug #8572) +|-- + +SET TIME ZONE 'America/New_York' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"America/New_York\"" +== 379 +-- truncate_limit: 100 +SET TIME ZONE '-1.5' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-1.5\"" +== 380 +-- truncate_limit: 100 +SHOW TIME ZONE +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TIME ZONE" +== 381 +-- truncate_limit: 100 +SELECT '2012-12-12 12:00'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2012-12-12 12:00'::timestamptz" +== 382 +-- truncate_limit: 100 +SELECT '2012-12-12 12:00 America/New_York'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2012-12-12 12:00 America/New_York'::timestamptz" +== 383 +-- truncate_limit: 100 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ')" +== 384 +-- truncate_limit: 100 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD SSSS') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD SSSS')" +== 385 +-- truncate_limit: 100 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD SSSSS') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD SSSSS')" +== 386 +-- truncate_limit: 100 +SET TIME ZONE '+2' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"+2\"" +== 387 +-- truncate_limit: 100 +SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('2012-12-12 12:00'::timestamptz, 'YYYY-MM-DD HH:MI:SS TZ')" +== 388 +-- truncate_limit: 100 +RESET TIME ZONE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET timezone" diff --git a/parser/testdata/summary_truncate/postgres_regress/identity.metadata.json b/parser/testdata/summary_truncate/postgres_regress/identity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/identity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/identity.test b/parser/testdata/summary_truncate/postgres_regress/identity.test new file mode 100644 index 0000000..df315af --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/identity.test @@ -0,0 +1,2140 @@ +== 001 +-- truncate_limit: 100 +-- sanity check of system catalog +SELECT attrelid, attname, attidentity FROM pg_attribute WHERE attidentity NOT IN ('', 'a', 'd') +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attidentity" +STMT: SelectStmt +TRUNCATED: "SELECT attrelid, attname, attidentity FROM pg_attribute WHERE attidentity NOT IN ('', 'a', 'd')" +== 002 +-- truncate_limit: 100 +CREATE TABLE itest1 (a int generated by default as identity, b text) +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest1 (a int GENERATED BY DEFAULT AS IDENTITY, b text)" +== 003 +-- truncate_limit: 100 +CREATE TABLE itest2 (a bigint generated always as identity, b text) +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest2 (a bigint GENERATED ALWAYS AS IDENTITY, b text)" +== 004 +-- truncate_limit: 100 +CREATE TABLE itest3 (a smallint generated by default as identity (start with 7 increment by 5), b text) +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest3 (a smallint GENERATED BY DEFAULT AS IDENTITY (START 7 INCREMENT 5 ), b text)" +== 005 +-- truncate_limit: 100 +ALTER TABLE itest3 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest3 ALTER a ADD GENERATED ALWAYS AS IDENTITY" +== 006 +-- truncate_limit: 100 +-- error + +SELECT table_name, column_name, column_default, is_nullable, is_identity, identity_generation, identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle FROM information_schema.columns WHERE table_name LIKE 'itest_' ORDER BY 1, 2 +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name LIKE 'itest_' ORDER BY 1, 2" +== 007 +-- truncate_limit: 100 +-- internal sequences should not be shown here +SELECT sequence_name FROM information_schema.sequences WHERE sequence_name LIKE 'itest%' +-- +TABLE: name="information_schema.sequences" schema="information_schema" table="sequences" ctx=Select +FILTER: schema="" table="" column="sequence_name" +STMT: SelectStmt +TRUNCATED: "SELECT sequence_name FROM information_schema.sequences WHERE sequence_name LIKE 'itest%'" +== 008 +-- truncate_limit: 100 +SELECT pg_get_serial_sequence('itest1', 'a') +-- +FUNCTION: name="pg_get_serial_sequence" function="pg_get_serial_sequence" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_serial_sequence('itest1', 'a')" +== 009 +-- truncate_limit: 100 +CREATE TABLE itest4 (a int, b text) +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest4 (a int, b text)" +== 010 +-- truncate_limit: 100 +ALTER TABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER a ADD GENERATED ALWAYS AS IDENTITY" +== 011 +-- truncate_limit: 100 +-- error, requires NOT NULL +ALTER TABLE itest4 ALTER COLUMN a SET NOT NULL +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER COLUMN a SET NOT NULL" +== 012 +-- truncate_limit: 100 +ALTER TABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER a ADD GENERATED ALWAYS AS IDENTITY" +== 013 +-- truncate_limit: 100 +-- ok +ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL" +== 014 +-- truncate_limit: 100 +-- error, disallowed +ALTER TABLE itest4 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER a ADD GENERATED ALWAYS AS IDENTITY" +== 015 +-- truncate_limit: 100 +-- error, already set +ALTER TABLE itest4 ALTER COLUMN b ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER b ADD GENERATED ALWAYS AS IDENTITY" +== 016 +-- truncate_limit: 100 +-- error, wrong data type + +-- for later +ALTER TABLE itest4 ALTER COLUMN b SET DEFAULT '' +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER COLUMN b SET DEFAULT ''" +== 017 +-- truncate_limit: 100 +-- invalid column type +CREATE TABLE itest_err_1 (a text generated by default as identity) +-- +TABLE: name="itest_err_1" schema="" table="itest_err_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest_err_1 (a text GENERATED BY DEFAULT AS IDENTITY)" +== 018 +-- truncate_limit: 100 +-- duplicate identity +CREATE TABLE itest_err_2 (a int generated always as identity generated by default as identity) +-- +TABLE: name="itest_err_2" schema="" table="itest_err_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest_err_2 (a int GENERATED ALWAYS AS IDENTITY GENERATED BY DEFAULT AS IDENTITY)" +== 019 +-- truncate_limit: 100 +-- cannot have default and identity +CREATE TABLE itest_err_3 (a int default 5 generated by default as identity) +-- +TABLE: name="itest_err_3" schema="" table="itest_err_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest_err_3 (a int DEFAULT 5 GENERATED BY DEFAULT AS IDENTITY)" +== 020 +-- truncate_limit: 100 +-- cannot combine serial and identity +CREATE TABLE itest_err_4 (a serial generated by default as identity) +-- +TABLE: name="itest_err_4" schema="" table="itest_err_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest_err_4 (a serial GENERATED BY DEFAULT AS IDENTITY)" +== 021 +-- truncate_limit: 100 +INSERT INTO itest1 DEFAULT VALUES +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest1 DEFAULT VALUES" +== 022 +-- truncate_limit: 100 +INSERT INTO itest1 DEFAULT VALUES +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest1 DEFAULT VALUES" +== 023 +-- truncate_limit: 100 +INSERT INTO itest2 DEFAULT VALUES +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest2 DEFAULT VALUES" +== 024 +-- truncate_limit: 100 +INSERT INTO itest2 DEFAULT VALUES +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest2 DEFAULT VALUES" +== 025 +-- truncate_limit: 100 +INSERT INTO itest3 DEFAULT VALUES +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest3 DEFAULT VALUES" +== 026 +-- truncate_limit: 100 +INSERT INTO itest3 DEFAULT VALUES +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest3 DEFAULT VALUES" +== 027 +-- truncate_limit: 100 +INSERT INTO itest4 DEFAULT VALUES +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest4 DEFAULT VALUES" +== 028 +-- truncate_limit: 100 +INSERT INTO itest4 DEFAULT VALUES +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest4 DEFAULT VALUES" +== 029 +-- truncate_limit: 100 +SELECT * FROM itest1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest1" +== 030 +-- truncate_limit: 100 +SELECT * FROM itest2 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest2" +== 031 +-- truncate_limit: 100 +SELECT * FROM itest3 +-- +TABLE: name="itest3" schema="" table="itest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest3" +== 032 +-- truncate_limit: 100 +SELECT * FROM itest4 +-- +TABLE: name="itest4" schema="" table="itest4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest4" +== 033 +-- truncate_limit: 100 +-- VALUES RTEs + +CREATE TABLE itest5 (a int generated always as identity, b text) +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest5 (a int GENERATED ALWAYS AS IDENTITY, b text)" +== 034 +-- truncate_limit: 100 +INSERT INTO itest5 VALUES (1, 'a') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 VALUES (1, 'a')" +== 035 +-- truncate_limit: 100 +-- error +INSERT INTO itest5 VALUES (DEFAULT, 'a') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 VALUES (DEFAULT, 'a')" +== 036 +-- truncate_limit: 100 +-- ok +INSERT INTO itest5 VALUES (2, 'b'), (3, 'c') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 VALUES (2, 'b'), (3, 'c')" +== 037 +-- truncate_limit: 100 +-- error +INSERT INTO itest5 VALUES (DEFAULT, 'b'), (3, 'c') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 VALUES (DEFAULT, 'b'), (3, 'c')" +== 038 +-- truncate_limit: 100 +-- error +INSERT INTO itest5 VALUES (2, 'b'), (DEFAULT, 'c') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 VALUES (2, 'b'), (DEFAULT, 'c')" +== 039 +-- truncate_limit: 100 +-- error +INSERT INTO itest5 VALUES (DEFAULT, 'b'), (DEFAULT, 'c') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 VALUES (DEFAULT, 'b'), (DEFAULT, 'c')" +== 040 +-- truncate_limit: 100 +-- ok + +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-1, 'aa') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-1, 'aa')" +== 041 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-2, 'bb'), (-3, 'cc') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-2, 'bb'), (-3, 'cc')" +== 042 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (DEFAULT, 'dd'), (-4, 'ee') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (DEFAULT, 'dd'), (-4, 'ee')" +== 043 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-5, 'ff'), (DEFAULT, 'gg') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (-5, 'ff'), (DEFAULT, 'gg')" +== 044 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (DEFAULT, 'hh'), (DEFAULT, 'ii') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING SYSTEM VALUE VALUES (DEFAULT, 'hh'), (DEFAULT, 'ii')" +== 045 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-1, 'aaa') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-1, 'aaa')" +== 046 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-2, 'bbb'), (-3, 'ccc') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-2, 'bbb'), (-3, 'ccc')" +== 047 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (DEFAULT, 'ddd'), (-4, 'eee') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING USER VALUE VALUES (DEFAULT, 'ddd'), (-4, 'eee')" +== 048 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-5, 'fff'), (DEFAULT, 'ggg') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING USER VALUE VALUES (-5, 'fff'), (DEFAULT, 'ggg')" +== 049 +-- truncate_limit: 100 +INSERT INTO itest5 OVERRIDING USER VALUE VALUES (DEFAULT, 'hhh'), (DEFAULT, 'iii') +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest5 OVERRIDING USER VALUE VALUES (DEFAULT, 'hhh'), (DEFAULT, 'iii')" +== 050 +-- truncate_limit: 100 +SELECT * FROM itest5 +-- +TABLE: name="itest5" schema="" table="itest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest5" +== 051 +-- truncate_limit: 100 +DROP TABLE itest5 +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE itest5" +== 052 +-- truncate_limit: 100 +INSERT INTO itest3 VALUES (DEFAULT, 'a') +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest3 VALUES (DEFAULT, 'a')" +== 053 +-- truncate_limit: 100 +INSERT INTO itest3 VALUES (DEFAULT, 'b'), (DEFAULT, 'c') +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest3 VALUES (DEFAULT, 'b'), (DEFAULT, 'c')" +== 054 +-- truncate_limit: 100 +SELECT * FROM itest3 +-- +TABLE: name="itest3" schema="" table="itest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest3" +== 055 +-- truncate_limit: 100 +-- OVERRIDING tests + +-- GENERATED BY DEFAULT + +-- This inserts the row as presented: +INSERT INTO itest1 VALUES (10, 'xyz') +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest1 VALUES (10, 'xyz')" +== 056 +-- truncate_limit: 100 +-- With GENERATED BY DEFAULT, OVERRIDING SYSTEM VALUE is not allowed +-- by the standard, but we allow it as a no-op, since it is of use if +-- there are multiple identity columns in a table, which is also an +-- extension. +INSERT INTO itest1 OVERRIDING SYSTEM VALUE VALUES (20, 'xyz') +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest1 OVERRIDING SYSTEM VALUE VALUES (20, 'xyz')" +== 057 +-- truncate_limit: 100 +-- This ignores the 30 and uses the sequence value instead: +INSERT INTO itest1 OVERRIDING USER VALUE VALUES (30, 'xyz') +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest1 OVERRIDING USER VALUE VALUES (30, 'xyz')" +== 058 +-- truncate_limit: 100 +SELECT * FROM itest1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest1" +== 059 +-- truncate_limit: 100 +-- GENERATED ALWAYS + +-- This is an error: +INSERT INTO itest2 VALUES (10, 'xyz') +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest2 VALUES (10, 'xyz')" +== 060 +-- truncate_limit: 100 +-- This inserts the row as presented: +INSERT INTO itest2 OVERRIDING SYSTEM VALUE VALUES (20, 'xyz') +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest2 OVERRIDING SYSTEM VALUE VALUES (20, 'xyz')" +== 061 +-- truncate_limit: 100 +-- This ignores the 30 and uses the sequence value instead: +INSERT INTO itest2 OVERRIDING USER VALUE VALUES (30, 'xyz') +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest2 OVERRIDING USER VALUE VALUES (30, 'xyz')" +== 062 +-- truncate_limit: 100 +SELECT * FROM itest2 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest2" +== 063 +-- truncate_limit: 100 +-- UPDATE tests + +-- GENERATED BY DEFAULT is not restricted. +UPDATE itest1 SET a = 101 WHERE a = 1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE itest1 SET a = 101 WHERE a = 1" +== 064 +-- truncate_limit: 100 +UPDATE itest1 SET a = DEFAULT WHERE a = 2 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE itest1 SET a = DEFAULT WHERE a = 2" +== 065 +-- truncate_limit: 100 +SELECT * FROM itest1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest1" +== 066 +-- truncate_limit: 100 +-- GENERATED ALWAYS allows only DEFAULT. +UPDATE itest2 SET a = 101 WHERE a = 1 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE itest2 SET a = 101 WHERE a = 1" +== 067 +-- truncate_limit: 100 +-- error +UPDATE itest2 SET a = DEFAULT WHERE a = 2 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE itest2 SET a = DEFAULT WHERE a = 2" +== 068 +-- truncate_limit: 100 +-- ok +SELECT * FROM itest2 +-- +TABLE: name="itest2" schema="" table="itest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest2" +== 069 +-- truncate_limit: 100 +-- COPY tests + +CREATE TABLE itest9 (a int GENERATED ALWAYS AS IDENTITY, b text, c bigint) +-- +TABLE: name="itest9" schema="" table="itest9" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest9 (a int GENERATED ALWAYS AS IDENTITY, b text, c bigint)" +== 070 +-- truncate_limit: 100 +COPY itest9 FROM stdin +-- +TABLE: name="itest9" schema="" table="itest9" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY itest9 FROM STDIN" +== 071 +-- truncate_limit: 100 +COPY itest9 (b, c) FROM stdin +-- +TABLE: name="itest9" schema="" table="itest9" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY itest9(b, c) FROM STDIN" +== 072 +-- truncate_limit: 100 +SELECT * FROM itest9 ORDER BY c +-- +TABLE: name="itest9" schema="" table="itest9" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest9 ORDER BY c" +== 073 +-- truncate_limit: 100 +-- DROP IDENTITY tests + +ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY" +== 074 +-- truncate_limit: 100 +ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY" +== 075 +-- truncate_limit: 100 +-- error +ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY IF EXISTS +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER COLUMN a DROP IDENTITY IF EXISTS" +== 076 +-- truncate_limit: 100 +-- noop + +INSERT INTO itest4 DEFAULT VALUES +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest4 DEFAULT VALUES" +== 077 +-- truncate_limit: 100 +-- fails because NOT NULL is not dropped +ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest4 ALTER COLUMN a DROP NOT NULL" +== 078 +-- truncate_limit: 100 +INSERT INTO itest4 DEFAULT VALUES +-- +TABLE: name="itest4" schema="" table="itest4" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest4 DEFAULT VALUES" +== 079 +-- truncate_limit: 100 +SELECT * FROM itest4 +-- +TABLE: name="itest4" schema="" table="itest4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest4" +== 080 +-- truncate_limit: 100 +-- check that sequence is removed +SELECT sequence_name FROM itest4_a_seq +-- +TABLE: name="itest4_a_seq" schema="" table="itest4_a_seq" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT sequence_name FROM itest4_a_seq" +== 081 +-- truncate_limit: 100 +-- test views + +CREATE TABLE itest10 (a int generated by default as identity, b text) +-- +TABLE: name="itest10" schema="" table="itest10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest10 (a int GENERATED BY DEFAULT AS IDENTITY, b text)" +== 082 +-- truncate_limit: 100 +CREATE TABLE itest11 (a int generated always as identity, b text) +-- +TABLE: name="itest11" schema="" table="itest11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest11 (a int GENERATED ALWAYS AS IDENTITY, b text)" +== 083 +-- truncate_limit: 100 +CREATE VIEW itestv10 AS SELECT * FROM itest10 +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DDL +TABLE: name="itest10" schema="" table="itest10" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW itestv10 AS SELECT * FROM itest10" +== 084 +-- truncate_limit: 100 +CREATE VIEW itestv11 AS SELECT * FROM itest11 +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DDL +TABLE: name="itest11" schema="" table="itest11" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW itestv11 AS SELECT * FROM itest11" +== 085 +-- truncate_limit: 100 +INSERT INTO itestv10 DEFAULT VALUES +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itestv10 DEFAULT VALUES" +== 086 +-- truncate_limit: 100 +INSERT INTO itestv10 DEFAULT VALUES +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itestv10 DEFAULT VALUES" +== 087 +-- truncate_limit: 100 +INSERT INTO itestv11 DEFAULT VALUES +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itestv11 DEFAULT VALUES" +== 088 +-- truncate_limit: 100 +INSERT INTO itestv11 DEFAULT VALUES +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itestv11 DEFAULT VALUES" +== 089 +-- truncate_limit: 100 +SELECT * FROM itestv10 +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itestv10" +== 090 +-- truncate_limit: 100 +SELECT * FROM itestv11 +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itestv11" +== 091 +-- truncate_limit: 100 +INSERT INTO itestv10 VALUES (10, 'xyz') +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itestv10 VALUES (10, 'xyz')" +== 092 +-- truncate_limit: 100 +INSERT INTO itestv10 OVERRIDING USER VALUE VALUES (11, 'xyz') +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itestv10 OVERRIDING USER VALUE VALUES (11, 'xyz')" +== 093 +-- truncate_limit: 100 +SELECT * FROM itestv10 +-- +TABLE: name="itestv10" schema="" table="itestv10" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itestv10" +== 094 +-- truncate_limit: 100 +INSERT INTO itestv11 VALUES (10, 'xyz') +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itestv11 VALUES (10, 'xyz')" +== 095 +-- truncate_limit: 100 +INSERT INTO itestv11 OVERRIDING SYSTEM VALUE VALUES (11, 'xyz') +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itestv11 OVERRIDING SYSTEM VALUE VALUES (11, 'xyz')" +== 096 +-- truncate_limit: 100 +SELECT * FROM itestv11 +-- +TABLE: name="itestv11" schema="" table="itestv11" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itestv11" +== 097 +-- truncate_limit: 100 +DROP VIEW itestv10, itestv11 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW itestv10, itestv11" +== 098 +-- truncate_limit: 100 +-- ADD COLUMN + +CREATE TABLE itest13 (a int) +-- +TABLE: name="itest13" schema="" table="itest13" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest13 (a int)" +== 099 +-- truncate_limit: 100 +-- add column to empty table +ALTER TABLE itest13 ADD COLUMN b int GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="itest13" schema="" table="itest13" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest13 ADD COLUMN b int GENERATED BY DEFAULT AS IDENTITY" +== 100 +-- truncate_limit: 100 +INSERT INTO itest13 VALUES (1), (2), (3) +-- +TABLE: name="itest13" schema="" table="itest13" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest13 VALUES (1), (2), (3)" +== 101 +-- truncate_limit: 100 +-- add column to populated table +ALTER TABLE itest13 ADD COLUMN c int GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="itest13" schema="" table="itest13" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest13 ADD COLUMN c int GENERATED BY DEFAULT AS IDENTITY" +== 102 +-- truncate_limit: 100 +SELECT * FROM itest13 +-- +TABLE: name="itest13" schema="" table="itest13" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest13" +== 103 +-- truncate_limit: 100 +-- various ALTER COLUMN tests + +-- fail, not allowed for identity columns +ALTER TABLE itest1 ALTER COLUMN a SET DEFAULT 1 +-- +TABLE: name="itest1" schema="" table="itest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest1 ALTER COLUMN a SET DEFAULT 1" +== 104 +-- truncate_limit: 100 +-- fail, not allowed, already has a default +CREATE TABLE itest5 (a serial, b text) +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest5 (a serial, b text)" +== 105 +-- truncate_limit: 100 +ALTER TABLE itest5 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest5" schema="" table="itest5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest5 ALTER a ADD GENERATED ALWAYS AS IDENTITY" +== 106 +-- truncate_limit: 100 +ALTER TABLE itest3 ALTER COLUMN a TYPE int +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest3 ALTER COLUMN a TYPE int" +== 107 +-- truncate_limit: 100 +SELECT seqtypid::regtype FROM pg_sequence WHERE seqrelid = 'itest3_a_seq'::regclass +-- +TABLE: name="pg_sequence" schema="" table="pg_sequence" ctx=Select +FILTER: schema="" table="" column="seqrelid" +STMT: SelectStmt +TRUNCATED: "SELECT seqtypid::regtype FROM pg_sequence WHERE seqrelid = 'itest3_a_seq'::regclass" +== 108 +-- truncate_limit: 100 +ALTER TABLE itest3 ALTER COLUMN a TYPE text +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest3 ALTER COLUMN a TYPE text" +== 109 +-- truncate_limit: 100 +-- error + +-- check that unlogged propagates to sequence +CREATE UNLOGGED TABLE itest17 (a int NOT NULL, b text) +-- +TABLE: name="itest17" schema="" table="itest17" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE itest17 (a int NOT NULL, b text)" +== 110 +-- truncate_limit: 100 +ALTER TABLE itest17 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest17" schema="" table="itest17" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest17 ALTER a ADD GENERATED ALWAYS AS IDENTITY" +== 111 +-- truncate_limit: 100 +ALTER TABLE itest17 ADD COLUMN c int GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest17" schema="" table="itest17" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest17 ADD COLUMN c int GENERATED ALWAYS AS IDENTITY" +== 112 +-- truncate_limit: 100 +CREATE TABLE itest18 (a int NOT NULL, b text) +-- +TABLE: name="itest18" schema="" table="itest18" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest18 (a int NOT NULL, b text)" +== 113 +-- truncate_limit: 100 +ALTER TABLE itest18 SET UNLOGGED, ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest18" schema="" table="itest18" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest18 SET UNLOGGED, ALTER a ADD GENERATED ALWAYS AS IDENTITY" +== 114 +-- truncate_limit: 100 +ALTER TABLE itest18 SET LOGGED +-- +TABLE: name="itest18" schema="" table="itest18" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest18 SET LOGGED" +== 115 +-- truncate_limit: 100 +ALTER TABLE itest18 SET UNLOGGED +-- +TABLE: name="itest18" schema="" table="itest18" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest18 SET UNLOGGED" +== 116 +-- truncate_limit: 100 +-- kinda silly to change property in the same command, but it should work +ALTER TABLE itest3 + ADD COLUMN c int GENERATED BY DEFAULT AS IDENTITY, + ALTER COLUMN c SET GENERATED ALWAYS +-- +TABLE: name="itest3" schema="" table="itest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest3 ADD COLUMN c int GENERATED BY DEFAULT AS IDENTITY, ALTER c SET GENERATED ALWAYS" +== 117 +-- truncate_limit: 100 +-- ALTER COLUMN ... SET + +CREATE TABLE itest6 (a int GENERATED ALWAYS AS IDENTITY, b text) +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest6 (a int GENERATED ALWAYS AS IDENTITY, b text)" +== 118 +-- truncate_limit: 100 +INSERT INTO itest6 DEFAULT VALUES +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest6 DEFAULT VALUES" +== 119 +-- truncate_limit: 100 +ALTER TABLE itest6 ALTER COLUMN a SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 100 RESTART +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest6 ALTER a SET GENERATED BY DEFAULT SET INCREMENT 2 SET START 100 RESTART" +== 120 +-- truncate_limit: 100 +INSERT INTO itest6 DEFAULT VALUES +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest6 DEFAULT VALUES" +== 121 +-- truncate_limit: 100 +INSERT INTO itest6 DEFAULT VALUES +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest6 DEFAULT VALUES" +== 122 +-- truncate_limit: 100 +SELECT * FROM itest6 +-- +TABLE: name="itest6" schema="" table="itest6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest6" +== 123 +-- truncate_limit: 100 +SELECT table_name, column_name, is_identity, identity_generation FROM information_schema.columns WHERE table_name = 'itest6' ORDER BY 1, 2 +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name = 'itest6' ORDER BY 1, 2" +== 124 +-- truncate_limit: 100 +ALTER TABLE itest6 ALTER COLUMN b SET INCREMENT BY 2 +-- +TABLE: name="itest6" schema="" table="itest6" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest6 ALTER b SET INCREMENT 2" +== 125 +-- truncate_limit: 100 +-- fail, not identity + + +-- prohibited direct modification of sequence + +ALTER SEQUENCE itest6_a_seq OWNED BY NONE +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE itest6_a_seq OWNED BY \"none\"" +== 126 +-- truncate_limit: 100 +-- inheritance + +CREATE TABLE itest7 (a int GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest7 (a int GENERATED ALWAYS AS IDENTITY)" +== 127 +-- truncate_limit: 100 +INSERT INTO itest7 DEFAULT VALUES +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest7 DEFAULT VALUES" +== 128 +-- truncate_limit: 100 +SELECT * FROM itest7 +-- +TABLE: name="itest7" schema="" table="itest7" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest7" +== 129 +-- truncate_limit: 100 +-- identity property is not inherited +CREATE TABLE itest7a (b text) INHERITS (itest7) +-- +TABLE: name="itest7a" schema="" table="itest7a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest7a (b text) INHERITS (itest7)" +== 130 +-- truncate_limit: 100 +-- make column identity in child table +CREATE TABLE itest7b (a int) +-- +TABLE: name="itest7b" schema="" table="itest7b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest7b (a int)" +== 131 +-- truncate_limit: 100 +CREATE TABLE itest7c (a int GENERATED ALWAYS AS IDENTITY) INHERITS (itest7b) +-- +TABLE: name="itest7c" schema="" table="itest7c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest7c (a int GENERATED ALWAYS AS IDENTITY) INHERITS (itest7b)" +== 132 +-- truncate_limit: 100 +INSERT INTO itest7c DEFAULT VALUES +-- +TABLE: name="itest7c" schema="" table="itest7c" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest7c DEFAULT VALUES" +== 133 +-- truncate_limit: 100 +SELECT * FROM itest7c +-- +TABLE: name="itest7c" schema="" table="itest7c" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest7c" +== 134 +-- truncate_limit: 100 +CREATE TABLE itest7d (a int not null) +-- +TABLE: name="itest7d" schema="" table="itest7d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest7d (a int NOT NULL)" +== 135 +-- truncate_limit: 100 +CREATE TABLE itest7e () INHERITS (itest7d) +-- +TABLE: name="itest7e" schema="" table="itest7e" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest7e () INHERITS (itest7d)" +== 136 +-- truncate_limit: 100 +ALTER TABLE itest7d ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest7d" schema="" table="itest7d" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest7d ALTER a ADD GENERATED ALWAYS AS IDENTITY" +== 137 +-- truncate_limit: 100 +ALTER TABLE itest7d ADD COLUMN b int GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest7d" schema="" table="itest7d" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest7d ADD COLUMN b int GENERATED ALWAYS AS IDENTITY" +== 138 +-- truncate_limit: 100 +-- error + +SELECT table_name, column_name, is_nullable, is_identity, identity_generation FROM information_schema.columns WHERE table_name LIKE 'itest7%' ORDER BY 1, 2 +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name LIKE 'itest7%' ORDER BY 1, 2" +== 139 +-- truncate_limit: 100 +-- These ALTER TABLE variants will not recurse. +ALTER TABLE itest7 ALTER COLUMN a SET GENERATED BY DEFAULT +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest7 ALTER a SET GENERATED BY DEFAULT" +== 140 +-- truncate_limit: 100 +ALTER TABLE itest7 ALTER COLUMN a RESTART +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest7 ALTER a RESTART" +== 141 +-- truncate_limit: 100 +ALTER TABLE itest7 ALTER COLUMN a DROP IDENTITY +-- +TABLE: name="itest7" schema="" table="itest7" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest7 ALTER COLUMN a DROP IDENTITY" +== 142 +-- truncate_limit: 100 +-- privileges +CREATE USER regress_identity_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_identity_user1" +== 143 +-- truncate_limit: 100 +CREATE TABLE itest8 (a int GENERATED ALWAYS AS IDENTITY, b text) +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest8 (a int GENERATED ALWAYS AS IDENTITY, b text)" +== 144 +-- truncate_limit: 100 +GRANT SELECT, INSERT ON itest8 TO regress_identity_user1 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select, insert ON itest8 TO regress_identity_user1" +== 145 +-- truncate_limit: 100 +SET ROLE regress_identity_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_identity_user1" +== 146 +-- truncate_limit: 100 +INSERT INTO itest8 DEFAULT VALUES +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO itest8 DEFAULT VALUES" +== 147 +-- truncate_limit: 100 +SELECT * FROM itest8 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest8" +== 148 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 149 +-- truncate_limit: 100 +DROP TABLE itest8 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE itest8" +== 150 +-- truncate_limit: 100 +DROP USER regress_identity_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_identity_user1" +== 151 +-- truncate_limit: 100 +-- multiple steps in ALTER TABLE +CREATE TABLE itest8 (f1 int) +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest8 (f1 int)" +== 152 +-- truncate_limit: 100 +ALTER TABLE itest8 + ADD COLUMN f2 int NOT NULL, + ALTER COLUMN f2 ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest8 ADD COLUMN f2 int NOT NULL, ALTER f2 ADD GENERATED ALWAYS AS IDENTITY" +== 153 +-- truncate_limit: 100 +ALTER TABLE itest8 + ADD COLUMN f3 int NOT NULL, + ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY, + ALTER COLUMN f3 SET GENERATED BY DEFAULT SET INCREMENT 10 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest8 ADD COLUMN f3 int NOT NULL, ALTER f3 ADD GENERATED ALWAYS AS IDENTITY, ALTER f..." +== 154 +-- truncate_limit: 100 +ALTER TABLE itest8 + ADD COLUMN f4 int +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest8 ADD COLUMN f4 int" +== 155 +-- truncate_limit: 100 +ALTER TABLE itest8 + ALTER COLUMN f4 SET NOT NULL, + ALTER COLUMN f4 ADD GENERATED ALWAYS AS IDENTITY, + ALTER COLUMN f4 SET DATA TYPE bigint +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest8 ALTER COLUMN f4 SET NOT NULL, ALTER f4 ADD GENERATED ALWAYS AS IDENTITY, ALTER..." +== 156 +-- truncate_limit: 100 +ALTER TABLE itest8 + ADD COLUMN f5 int GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest8 ADD COLUMN f5 int GENERATED ALWAYS AS IDENTITY" +== 157 +-- truncate_limit: 100 +ALTER TABLE itest8 + ALTER COLUMN f5 DROP IDENTITY, + ALTER COLUMN f5 DROP NOT NULL, + ALTER COLUMN f5 SET DATA TYPE bigint +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest8 ALTER COLUMN f5 DROP IDENTITY, ALTER COLUMN f5 DROP NOT NULL, ALTER COLUMN f5 ..." +== 158 +-- truncate_limit: 100 +INSERT INTO itest8 VALUES(0), (1) +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest8 VALUES (0), (1)" +== 159 +-- truncate_limit: 100 +-- This does not work when the table isn't empty. That's intentional, +-- since ADD GENERATED should only affect later insertions: +ALTER TABLE itest8 + ADD COLUMN f22 int NOT NULL, + ALTER COLUMN f22 ADD GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest8 ADD COLUMN f22 int NOT NULL, ALTER f22 ADD GENERATED ALWAYS AS IDENTITY" +== 160 +-- truncate_limit: 100 +TABLE itest8 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest8" +== 161 +-- truncate_limit: 100 +DROP TABLE itest8 +-- +TABLE: name="itest8" schema="" table="itest8" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE itest8" +== 162 +-- truncate_limit: 100 +-- typed tables (currently not supported) + +CREATE TYPE itest_type AS (f1 integer, f2 text, f3 bigint) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE itest_type AS (f1 int, f2 text, f3 bigint)" +== 163 +-- truncate_limit: 100 +CREATE TABLE itest12 OF itest_type (f1 WITH OPTIONS GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="itest12" schema="" table="itest12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest12 OF itest_type (f1 GENERATED ALWAYS AS IDENTITY)" +== 164 +-- truncate_limit: 100 +-- error +DROP TYPE itest_type CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE itest_type CASCADE" +== 165 +-- truncate_limit: 100 +-- table partitions + +-- partitions inherit identity column and share sequence +CREATE TABLE pitest1 (f1 date NOT NULL, f2 text, f3 bigint generated always as identity) PARTITION BY RANGE (f1) +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest1 (f1 date NOT NULL, f2 text, f3 bigint GENERATED ALWAYS AS IDENTITY) PARTITIO..." +== 166 +-- truncate_limit: 100 +-- new partition +CREATE TABLE pitest1_p1 PARTITION OF pitest1 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01') +-- +TABLE: name="pitest1_p1" schema="" table="pitest1_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest1_p1 PARTITION OF pitest1 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01')" +== 167 +-- truncate_limit: 100 +INSERT into pitest1(f1, f2) VALUES ('2016-07-2', 'from pitest1') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest1 (f1, f2) VALUES ('2016-07-2', 'from pitest1')" +== 168 +-- truncate_limit: 100 +INSERT into pitest1_p1 (f1, f2) VALUES ('2016-07-3', 'from pitest1_p1') +-- +TABLE: name="pitest1_p1" schema="" table="pitest1_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest1_p1 (f1, f2) VALUES ('2016-07-3', 'from pitest1_p1')" +== 169 +-- truncate_limit: 100 +-- attached partition +CREATE TABLE pitest1_p2 (f3 bigint, f2 text, f1 date NOT NULL) +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest1_p2 (f3 bigint, f2 text, f1 date NOT NULL)" +== 170 +-- truncate_limit: 100 +INSERT INTO pitest1_p2 (f1, f2, f3) VALUES ('2016-08-2', 'before attaching', 100) +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest1_p2 (f1, f2, f3) VALUES ('2016-08-2', 'before attaching', 100)" +== 171 +-- truncate_limit: 100 +ALTER TABLE pitest1 ATTACH PARTITION pitest1_p2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1 ATTACH PARTITION pitest1_p2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01')" +== 172 +-- truncate_limit: 100 +-- requires NOT NULL constraint +ALTER TABLE pitest1_p2 ALTER COLUMN f3 SET NOT NULL +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1_p2 ALTER COLUMN f3 SET NOT NULL" +== 173 +-- truncate_limit: 100 +ALTER TABLE pitest1 ATTACH PARTITION pitest1_p2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1 ATTACH PARTITION pitest1_p2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01')" +== 174 +-- truncate_limit: 100 +INSERT INTO pitest1_p2 (f1, f2) VALUES ('2016-08-3', 'from pitest1_p2') +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest1_p2 (f1, f2) VALUES ('2016-08-3', 'from pitest1_p2')" +== 175 +-- truncate_limit: 100 +INSERT INTO pitest1 (f1, f2) VALUES ('2016-08-4', 'from pitest1') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest1 (f1, f2) VALUES ('2016-08-4', 'from pitest1')" +== 176 +-- truncate_limit: 100 +-- LIKE INCLUDING on partition +CREATE TABLE pitest1_p1_like (LIKE pitest1_p1 INCLUDING IDENTITY) +-- +TABLE: name="pitest1_p1_like" schema="" table="pitest1_p1_like" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest1_p1_like (LIKE pitest1_p1 INCLUDING IDENTITY)" +== 177 +-- truncate_limit: 100 +INSERT into pitest1_p1_like(f1, f2) VALUES ('2016-07-2', 'from pitest1_p1_like') +-- +TABLE: name="pitest1_p1_like" schema="" table="pitest1_p1_like" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest1_p1_like (f1, f2) VALUES ('2016-07-2', 'from pitest1_p1_like')" +== 178 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest1 +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3 FROM pitest1" +== 179 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest1_p1_like +-- +TABLE: name="pitest1_p1_like" schema="" table="pitest1_p1_like" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3 FROM pitest1_p1_like" +== 180 +-- truncate_limit: 100 +ALTER TABLE pitest1 ALTER COLUMN f3 SET DATA TYPE bigint +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1 ALTER COLUMN f3 TYPE bigint" +== 181 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3, pg_typeof(f3) FROM pitest1 +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=Select +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3, pg_typeof(f3) FROM pitest1" +== 182 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3, pg_typeof(f3) FROM pitest1_p2 +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=Select +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3, pg_typeof(f3) FROM pitest1_p2" +== 183 +-- truncate_limit: 100 +-- add identity column +CREATE TABLE pitest2 (f1 date NOT NULL, f2 text) PARTITION BY RANGE (f1) +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest2 (f1 date NOT NULL, f2 text) PARTITION BY RANGE (f1)" +== 184 +-- truncate_limit: 100 +CREATE TABLE pitest2_p1 PARTITION OF pitest2 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01') +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest2_p1 PARTITION OF pitest2 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01')" +== 185 +-- truncate_limit: 100 +CREATE TABLE pitest2_p2 PARTITION OF pitest2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01') +-- +TABLE: name="pitest2_p2" schema="" table="pitest2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest2_p2 PARTITION OF pitest2 FOR VALUES FROM ('2016-08-01') TO ('2016-09-01')" +== 186 +-- truncate_limit: 100 +INSERT into pitest2(f1, f2) VALUES ('2016-07-2', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2 (f1, f2) VALUES ('2016-07-2', 'from pitest2')" +== 187 +-- truncate_limit: 100 +INSERT INTO pitest2 (f1, f2) VALUES ('2016-08-2', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2 (f1, f2) VALUES ('2016-08-2', 'from pitest2')" +== 188 +-- truncate_limit: 100 +ALTER TABLE pitest2 ADD COLUMN f3 int GENERATED ALWAYS AS IDENTITY +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest2 ADD COLUMN f3 int GENERATED ALWAYS AS IDENTITY" +== 189 +-- truncate_limit: 100 +INSERT into pitest2_p1 (f1, f2) VALUES ('2016-07-3', 'from pitest2_p1') +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2_p1 (f1, f2) VALUES ('2016-07-3', 'from pitest2_p1')" +== 190 +-- truncate_limit: 100 +INSERT INTO pitest2_p2 (f1, f2) VALUES ('2016-08-3', 'from pitest2_p2') +-- +TABLE: name="pitest2_p2" schema="" table="pitest2_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2_p2 (f1, f2) VALUES ('2016-08-3', 'from pitest2_p2')" +== 191 +-- truncate_limit: 100 +INSERT into pitest2(f1, f2) VALUES ('2016-07-4', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2 (f1, f2) VALUES ('2016-07-4', 'from pitest2')" +== 192 +-- truncate_limit: 100 +INSERT INTO pitest2 (f1, f2) VALUES ('2016-08-4', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2 (f1, f2) VALUES ('2016-08-4', 'from pitest2')" +== 193 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest2 +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3 FROM pitest2" +== 194 +-- truncate_limit: 100 +-- SET identity column +ALTER TABLE pitest2_p1 ALTER COLUMN f3 SET GENERATED BY DEFAULT +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest2_p1 ALTER f3 SET GENERATED BY DEFAULT" +== 195 +-- truncate_limit: 100 +-- fails +ALTER TABLE pitest2_p1 ALTER COLUMN f3 SET INCREMENT BY 2 +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest2_p1 ALTER f3 SET INCREMENT 2" +== 196 +-- truncate_limit: 100 +-- fails +ALTER TABLE ONLY pitest2 ALTER COLUMN f3 SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 1000 RESTART +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY pitest2 ALTER f3 SET GENERATED BY DEFAULT SET INCREMENT 2 SET START 1000 RESTART" +== 197 +-- truncate_limit: 100 +-- fails +ALTER TABLE pitest2 ALTER COLUMN f3 SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 1000 RESTART +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest2 ALTER f3 SET GENERATED BY DEFAULT SET INCREMENT 2 SET START 1000 RESTART" +== 198 +-- truncate_limit: 100 +INSERT into pitest2(f1, f2, f3) VALUES ('2016-07-5', 'from pitest2', 200) +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2 (f1, f2, f3) VALUES ('2016-07-5', 'from pitest2', 200)" +== 199 +-- truncate_limit: 100 +INSERT INTO pitest2(f1, f2) VALUES ('2016-08-5', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2 (f1, f2) VALUES ('2016-08-5', 'from pitest2')" +== 200 +-- truncate_limit: 100 +INSERT into pitest2_p1 (f1, f2) VALUES ('2016-07-6', 'from pitest2_p1') +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2_p1 (f1, f2) VALUES ('2016-07-6', 'from pitest2_p1')" +== 201 +-- truncate_limit: 100 +INSERT INTO pitest2_p2 (f1, f2, f3) VALUES ('2016-08-6', 'from pitest2_p2', 300) +-- +TABLE: name="pitest2_p2" schema="" table="pitest2_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2_p2 (f1, f2, f3) VALUES ('2016-08-6', 'from pitest2_p2', 300)" +== 202 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest2 +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3 FROM pitest2" +== 203 +-- truncate_limit: 100 +-- detaching a partition removes identity property +ALTER TABLE pitest2 DETACH PARTITION pitest2_p1 +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest2 DETACH PARTITION pitest2_p1" +== 204 +-- truncate_limit: 100 +INSERT into pitest2(f1, f2) VALUES ('2016-08-7', 'from pitest2') +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2 (f1, f2) VALUES ('2016-08-7', 'from pitest2')" +== 205 +-- truncate_limit: 100 +INSERT into pitest2_p1 (f1, f2) VALUES ('2016-07-7', 'from pitest2_p1') +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2_p1 (f1, f2) VALUES ('2016-07-7', 'from pitest2_p1')" +== 206 +-- truncate_limit: 100 +-- error +INSERT into pitest2_p1 (f1, f2, f3) VALUES ('2016-07-7', 'from pitest2_p1', 2000) +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest2_p1 (f1, f2, f3) VALUES ('2016-07-7', 'from pitest2_p1', 2000)" +== 207 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest2 +-- +TABLE: name="pitest2" schema="" table="pitest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3 FROM pitest2" +== 208 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest2_p1 +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3 FROM pitest2_p1" +== 209 +-- truncate_limit: 100 +DROP TABLE pitest2_p1 +-- +TABLE: name="pitest2_p1" schema="" table="pitest2_p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pitest2_p1" +== 210 +-- truncate_limit: 100 +-- changing a regular column to identity column in a partitioned table +CREATE TABLE pitest3 (f1 date NOT NULL, f2 text, f3 int) PARTITION BY RANGE (f1) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest3 (f1 date NOT NULL, f2 text, f3 int) PARTITION BY RANGE (f1)" +== 211 +-- truncate_limit: 100 +CREATE TABLE pitest3_p1 PARTITION OF pitest3 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01') +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest3_p1 PARTITION OF pitest3 FOR VALUES FROM ('2016-07-01') TO ('2016-08-01')" +== 212 +-- truncate_limit: 100 +INSERT into pitest3 VALUES ('2016-07-2', 'from pitest3', 1) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest3 VALUES ('2016-07-2', 'from pitest3', 1)" +== 213 +-- truncate_limit: 100 +INSERT into pitest3_p1 VALUES ('2016-07-3', 'from pitest3_p1', 2) +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest3_p1 VALUES ('2016-07-3', 'from pitest3_p1', 2)" +== 214 +-- truncate_limit: 100 +-- fails, changing only a partition not allowed +ALTER TABLE pitest3_p1 + ALTER COLUMN f3 SET NOT NULL, + ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3) +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest3_p1 ALTER COLUMN f3 SET NOT NULL, ALTER f3 ADD GENERATED ALWAYS AS IDENTITY (S..." +== 215 +-- truncate_limit: 100 +-- fails, changing only the partitioned table not allowed +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 216 +-- truncate_limit: 100 +ALTER TABLE pitest3_p1 ALTER COLUMN f3 SET NOT NULL +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest3_p1 ALTER COLUMN f3 SET NOT NULL" +== 217 +-- truncate_limit: 100 +ALTER TABLE ONLY pitest3 + ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY pitest3 ALTER f3 ADD GENERATED ALWAYS AS IDENTITY (START 3 )" +== 218 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 219 +-- truncate_limit: 100 +ALTER TABLE pitest3 + ALTER COLUMN f3 SET NOT NULL, + ALTER COLUMN f3 ADD GENERATED ALWAYS AS IDENTITY (START WITH 3) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest3 ALTER COLUMN f3 SET NOT NULL, ALTER f3 ADD GENERATED ALWAYS AS IDENTITY (STAR..." +== 220 +-- truncate_limit: 100 +INSERT into pitest3(f1, f2) VALUES ('2016-07-4', 'from pitest3') +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest3 (f1, f2) VALUES ('2016-07-4', 'from pitest3')" +== 221 +-- truncate_limit: 100 +INSERT into pitest3_p1 (f1, f2) VALUES ('2016-07-5', 'from pitest3_p1') +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest3_p1 (f1, f2) VALUES ('2016-07-5', 'from pitest3_p1')" +== 222 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest3 +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3 FROM pitest3" +== 223 +-- truncate_limit: 100 +-- changing an identity column to a non-identity column in a partitioned table +ALTER TABLE pitest3_p1 ALTER COLUMN f3 DROP IDENTITY +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest3_p1 ALTER COLUMN f3 DROP IDENTITY" +== 224 +-- truncate_limit: 100 +-- fails +ALTER TABLE ONLY pitest3 ALTER COLUMN f3 DROP IDENTITY +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY pitest3 ALTER COLUMN f3 DROP IDENTITY" +== 225 +-- truncate_limit: 100 +-- fails +ALTER TABLE pitest3 ALTER COLUMN f3 DROP IDENTITY +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest3 ALTER COLUMN f3 DROP IDENTITY" +== 226 +-- truncate_limit: 100 +INSERT into pitest3(f1, f2) VALUES ('2016-07-4', 'from pitest3') +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest3 (f1, f2) VALUES ('2016-07-4', 'from pitest3')" +== 227 +-- truncate_limit: 100 +-- fails +INSERT into pitest3_p1 (f1, f2) VALUES ('2016-07-5', 'from pitest3_p1') +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest3_p1 (f1, f2) VALUES ('2016-07-5', 'from pitest3_p1')" +== 228 +-- truncate_limit: 100 +-- fails +INSERT into pitest3(f1, f2, f3) VALUES ('2016-07-6', 'from pitest3', 5) +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest3 (f1, f2, f3) VALUES ('2016-07-6', 'from pitest3', 5)" +== 229 +-- truncate_limit: 100 +INSERT into pitest3_p1 (f1, f2, f3) VALUES ('2016-07-7', 'from pitest3_p1', 6) +-- +TABLE: name="pitest3_p1" schema="" table="pitest3_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pitest3_p1 (f1, f2, f3) VALUES ('2016-07-7', 'from pitest3_p1', 6)" +== 230 +-- truncate_limit: 100 +SELECT tableoid::regclass, f1, f2, f3 FROM pitest3 +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, f1, f2, f3 FROM pitest3" +== 231 +-- truncate_limit: 100 +-- Changing NOT NULL constraint of identity columns is not allowed +ALTER TABLE pitest1_p1 ALTER COLUMN f3 DROP NOT NULL +-- +TABLE: name="pitest1_p1" schema="" table="pitest1_p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1_p1 ALTER COLUMN f3 DROP NOT NULL" +== 232 +-- truncate_limit: 100 +ALTER TABLE pitest1 ALTER COLUMN f3 DROP NOT NULL +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1 ALTER COLUMN f3 DROP NOT NULL" +== 233 +-- truncate_limit: 100 +-- Identity columns have their own default +ALTER TABLE pitest1_p2 ALTER COLUMN f3 SET DEFAULT 10000 +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1_p2 ALTER COLUMN f3 SET DEFAULT 10000" +== 234 +-- truncate_limit: 100 +ALTER TABLE pitest1 ALTER COLUMN f3 SET DEFAULT 10000 +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1 ALTER COLUMN f3 SET DEFAULT 10000" +== 235 +-- truncate_limit: 100 +-- Adding identity to an identity column is not allowed +ALTER TABLE pitest1_p2 ALTER COLUMN f3 ADD GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="pitest1_p2" schema="" table="pitest1_p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1_p2 ALTER f3 ADD GENERATED BY DEFAULT AS IDENTITY" +== 236 +-- truncate_limit: 100 +ALTER TABLE pitest1 ALTER COLUMN f3 ADD GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1 ALTER f3 ADD GENERATED BY DEFAULT AS IDENTITY" +== 237 +-- truncate_limit: 100 +-- partitions with their own identity columns are not allowed, even if the +-- partitioned table does not have an identity column. +CREATE TABLE pitest1_pfail PARTITION OF pitest1 ( + f3 WITH OPTIONS GENERATED ALWAYS AS IDENTITY +) FOR VALUES FROM ('2016-11-01') TO ('2016-12-01') +-- +TABLE: name="pitest1_pfail" schema="" table="pitest1_pfail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest1_pfail PARTITION OF pitest1 (f3 GENERATED ALWAYS AS IDENTITY) FOR VALUES FROM..." +== 238 +-- truncate_limit: 100 +CREATE TABLE pitest_pfail PARTITION OF pitest3 ( + f3 WITH OPTIONS GENERATED ALWAYS AS IDENTITY +) FOR VALUES FROM ('2016-07-01') TO ('2016-08-01') +-- +TABLE: name="pitest_pfail" schema="" table="pitest_pfail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest_pfail PARTITION OF pitest3 (f3 GENERATED ALWAYS AS IDENTITY) FOR VALUES FROM ..." +== 239 +-- truncate_limit: 100 +CREATE TABLE pitest1_pfail (f1 date NOT NULL, f2 text, f3 bigint GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="pitest1_pfail" schema="" table="pitest1_pfail" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pitest1_pfail (f1 date NOT NULL, f2 text, f3 bigint GENERATED ALWAYS AS IDENTITY)" +== 240 +-- truncate_limit: 100 +ALTER TABLE pitest1 ATTACH PARTITION pitest1_pfail FOR VALUES FROM ('2016-11-01') TO ('2016-12-01') +-- +TABLE: name="pitest1" schema="" table="pitest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest1 ATTACH PARTITION pitest1_pfail FOR VALUES FROM ('2016-11-01') TO ('2016-12-01')" +== 241 +-- truncate_limit: 100 +ALTER TABLE pitest3 ATTACH PARTITION pitest1_pfail FOR VALUES FROM ('2016-11-01') TO ('2016-12-01') +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pitest3 ATTACH PARTITION pitest1_pfail FOR VALUES FROM ('2016-11-01') TO ('2016-12-01')" +== 242 +-- truncate_limit: 100 +DROP TABLE pitest1_pfail +-- +TABLE: name="pitest1_pfail" schema="" table="pitest1_pfail" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pitest1_pfail" +== 243 +-- truncate_limit: 100 +DROP TABLE pitest3 +-- +TABLE: name="pitest3" schema="" table="pitest3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pitest3" +== 244 +-- truncate_limit: 100 +-- test that sequence of half-dropped serial column is properly ignored + +CREATE TABLE itest14 (id serial) +-- +TABLE: name="itest14" schema="" table="itest14" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest14 (id serial)" +== 245 +-- truncate_limit: 100 +ALTER TABLE itest14 ALTER id DROP DEFAULT +-- +TABLE: name="itest14" schema="" table="itest14" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest14 ALTER COLUMN id DROP DEFAULT" +== 246 +-- truncate_limit: 100 +ALTER TABLE itest14 ALTER id ADD GENERATED BY DEFAULT AS IDENTITY +-- +TABLE: name="itest14" schema="" table="itest14" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE itest14 ALTER id ADD GENERATED BY DEFAULT AS IDENTITY" +== 247 +-- truncate_limit: 100 +INSERT INTO itest14 (id) VALUES (DEFAULT) +-- +TABLE: name="itest14" schema="" table="itest14" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO itest14 (id) VALUES (DEFAULT)" +== 248 +-- truncate_limit: 100 +-- Identity columns must be NOT NULL (cf bug #16913) + +CREATE TABLE itest15 (id integer GENERATED ALWAYS AS IDENTITY NULL) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest15 (id int GENERATED ALWAYS AS IDENTITY NULL)" +== 249 +-- truncate_limit: 100 +-- fail +CREATE TABLE itest15 (id integer NULL GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest15 (id int NULL GENERATED ALWAYS AS IDENTITY)" +== 250 +-- truncate_limit: 100 +-- fail +CREATE TABLE itest15 (id integer GENERATED ALWAYS AS IDENTITY NOT NULL) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest15 (id int GENERATED ALWAYS AS IDENTITY NOT NULL)" +== 251 +-- truncate_limit: 100 +DROP TABLE itest15 +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE itest15" +== 252 +-- truncate_limit: 100 +CREATE TABLE itest15 (id integer NOT NULL GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest15 (id int NOT NULL GENERATED ALWAYS AS IDENTITY)" +== 253 +-- truncate_limit: 100 +DROP TABLE itest15 +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE itest15" +== 254 +-- truncate_limit: 100 +-- MERGE tests +CREATE TABLE itest15 (a int GENERATED ALWAYS AS IDENTITY, b text) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest15 (a int GENERATED ALWAYS AS IDENTITY, b text)" +== 255 +-- truncate_limit: 100 +CREATE TABLE itest16 (a int GENERATED BY DEFAULT AS IDENTITY, b text) +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE itest16 (a int GENERATED BY DEFAULT AS IDENTITY, b text)" +== 256 +-- truncate_limit: 100 +MERGE INTO itest15 t +USING (SELECT 10 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DML +ALIAS: "t"="itest15" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO itest15 t USING (SELECT ...) s ON t.a = s.s_a WHEN NOT MATCHED THEN INSERT (a, b) VALU..." +== 257 +-- truncate_limit: 100 +-- Used to fail, but now it works and ignores the user supplied value +MERGE INTO itest15 t +USING (SELECT 20 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) OVERRIDING USER VALUE VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DML +ALIAS: "t"="itest15" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO itest15 t USING (SELECT ...) s ON t.a = s.s_a WHEN NOT MATCHED THEN INSERT (a, b) OVER..." +== 258 +-- truncate_limit: 100 +MERGE INTO itest15 t +USING (SELECT 30 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) OVERRIDING SYSTEM VALUE VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DML +ALIAS: "t"="itest15" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO itest15 t USING (SELECT ...) s ON t.a = s.s_a WHEN NOT MATCHED THEN INSERT (a, b) OVER..." +== 259 +-- truncate_limit: 100 +MERGE INTO itest16 t +USING (SELECT 10 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DML +ALIAS: "t"="itest16" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO itest16 t USING (SELECT ...) s ON t.a = s.s_a WHEN NOT MATCHED THEN INSERT (a, b) VALU..." +== 260 +-- truncate_limit: 100 +MERGE INTO itest16 t +USING (SELECT 20 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) OVERRIDING USER VALUE VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DML +ALIAS: "t"="itest16" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO itest16 t USING (SELECT ...) s ON t.a = s.s_a WHEN NOT MATCHED THEN INSERT (a, b) OVER..." +== 261 +-- truncate_limit: 100 +MERGE INTO itest16 t +USING (SELECT 30 AS s_a, 'inserted by merge' AS s_b) s +ON t.a = s.s_a +WHEN NOT MATCHED THEN + INSERT (a, b) OVERRIDING SYSTEM VALUE VALUES (s.s_a, s.s_b) +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DML +ALIAS: "t"="itest16" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO itest16 t USING (SELECT ...) s ON t.a = s.s_a WHEN NOT MATCHED THEN INSERT (a, b) OVER..." +== 262 +-- truncate_limit: 100 +SELECT * FROM itest15 +-- +TABLE: name="itest15" schema="" table="itest15" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest15" +== 263 +-- truncate_limit: 100 +SELECT * FROM itest16 +-- +TABLE: name="itest16" schema="" table="itest16" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM itest16" +== 264 +-- truncate_limit: 100 +DROP TABLE itest15 +-- +TABLE: name="itest15" schema="" table="itest15" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE itest15" +== 265 +-- truncate_limit: 100 +DROP TABLE itest16 +-- +TABLE: name="itest16" schema="" table="itest16" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE itest16" +== 266 +-- truncate_limit: 100 +-- For testing of pg_dump and pg_upgrade, leave behind some identity +-- sequences whose logged-ness doesn't match their owning table's. +CREATE TABLE identity_dump_logged (a INT GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="identity_dump_logged" schema="" table="identity_dump_logged" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE identity_dump_logged (a int GENERATED ALWAYS AS IDENTITY)" +== 267 +-- truncate_limit: 100 +ALTER SEQUENCE identity_dump_logged_a_seq SET UNLOGGED +-- +TABLE: name="identity_dump_logged_a_seq" schema="" table="identity_dump_logged_a_seq" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER SEQUENCE identity_dump_logged_a_seq SET UNLOGGED" +== 268 +-- truncate_limit: 100 +CREATE UNLOGGED TABLE identity_dump_unlogged (a INT GENERATED ALWAYS AS IDENTITY) +-- +TABLE: name="identity_dump_unlogged" schema="" table="identity_dump_unlogged" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE identity_dump_unlogged (a int GENERATED ALWAYS AS IDENTITY)" +== 269 +-- truncate_limit: 100 +ALTER SEQUENCE identity_dump_unlogged_a_seq SET LOGGED +-- +TABLE: name="identity_dump_unlogged_a_seq" schema="" table="identity_dump_unlogged_a_seq" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER SEQUENCE identity_dump_unlogged_a_seq SET LOGGED" +== 270 +-- truncate_limit: 100 +SELECT relname, relpersistence FROM pg_class + WHERE relname ~ '^identity_dump_' ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relpersistence FROM pg_class WHERE relname ~ '^identity_dump_' ORDER BY 1" diff --git a/parser/testdata/summary_truncate/postgres_regress/incremental_sort.metadata.json b/parser/testdata/summary_truncate/postgres_regress/incremental_sort.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/incremental_sort.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/incremental_sort.test b/parser/testdata/summary_truncate/postgres_regress/incremental_sort.test new file mode 100644 index 0000000..f3c6456 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/incremental_sort.test @@ -0,0 +1,1041 @@ +== 001 +-- truncate_limit: 100 +-- When there is a LIMIT clause, incremental sort is beneficial because +-- it only has to sort some of the groups, and not the entire table. +explain (costs off) +select * from (select * from tenk1 order by four) t order by four, ten +limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM tenk1 ORDER BY four) t ORDER BY four, ten LIMIT 1" +== 002 +-- truncate_limit: 100 +-- When work_mem is not enough to sort the entire table, incremental sort +-- may be faster if individual groups still fit into work_mem. +set work_mem to '2MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"2MB\"" +== 003 +-- truncate_limit: 100 +explain (costs off) +select * from (select * from tenk1 order by four) t order by four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM tenk1 ORDER BY four) t ORDER BY four, ten" +== 004 +-- truncate_limit: 100 +reset work_mem +-- +STMT: VariableSetStmt +TRUNCATED: "RESET work_mem" +== 005 +-- truncate_limit: 100 +create table t(a integer, b integer) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (a int, b int)" +== 006 +-- truncate_limit: 100 +create or replace function explain_analyze_without_memory(query text) +returns table (out_line text) language plpgsql +as +$$ +declare + line text; +begin + for line in + execute 'explain (analyze, costs off, summary off, timing off) ' || query + loop + out_line := regexp_replace(line, '\d+kB', 'NNkB', 'g'); + return next; + end loop; +end; +$$ +-- +FUNCTION: name="explain_analyze_without_memory" function="explain_analyze_without_memory" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION explain_analyze_without_memory(query text) RETURNS TABLE (out_line tex..." +== 007 +-- truncate_limit: 100 +create or replace function explain_analyze_inc_sort_nodes(query text) +returns jsonb language plpgsql +as +$$ +declare + elements jsonb; + element jsonb; + matching_nodes jsonb := '[]'::jsonb; +begin + execute 'explain (analyze, costs off, summary off, timing off, format ''json'') ' || query into strict elements; + while jsonb_array_length(elements) > 0 loop + element := elements->0; + elements := elements - 0; + case jsonb_typeof(element) + when 'array' then + if jsonb_array_length(element) > 0 then + elements := elements || element; + end if; + when 'object' then + if element ? 'Plan' then + elements := elements || jsonb_build_array(element->'Plan'); + element := element - 'Plan'; + else + if element ? 'Plans' then + elements := elements || jsonb_build_array(element->'Plans'); + element := element - 'Plans'; + end if; + if (element->>'Node Type')::text = 'Incremental Sort' then + matching_nodes := matching_nodes || element; + end if; + end if; + end case; + end loop; + return matching_nodes; +end; +$$ +-- +FUNCTION: name="explain_analyze_inc_sort_nodes" function="explain_analyze_inc_sort_nodes" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION explain_analyze_inc_sort_nodes(query text) RETURNS jsonb LANGUAGE plpg..." +== 008 +-- truncate_limit: 100 +create or replace function explain_analyze_inc_sort_nodes_without_memory(query text) +returns jsonb language plpgsql +as +$$ +declare + nodes jsonb := '[]'::jsonb; + node jsonb; + group_key text; + space_key text; +begin + for node in select * from jsonb_array_elements(explain_analyze_inc_sort_nodes(query)) t loop + for group_key in select unnest(array['Full-sort Groups', 'Pre-sorted Groups']::text[]) t loop + for space_key in select unnest(array['Sort Space Memory', 'Sort Space Disk']::text[]) t loop + node := jsonb_set(node, array[group_key, space_key, 'Average Sort Space Used'], '"NN"', false); + node := jsonb_set(node, array[group_key, space_key, 'Peak Sort Space Used'], '"NN"', false); + end loop; + end loop; + nodes := nodes || node; + end loop; + return nodes; +end; +$$ +-- +FUNCTION: name="explain_analyze_inc_sort_nodes_without_memory" function="explain_analyze_inc_sort_nodes_without_memory" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION explain_analyze_inc_sort_nodes_without_memory(query text) RETURNS json..." +== 009 +-- truncate_limit: 100 +create or replace function explain_analyze_inc_sort_nodes_verify_invariants(query text) +returns bool language plpgsql +as +$$ +declare + node jsonb; + group_stats jsonb; + group_key text; + space_key text; +begin + for node in select * from jsonb_array_elements(explain_analyze_inc_sort_nodes(query)) t loop + for group_key in select unnest(array['Full-sort Groups', 'Pre-sorted Groups']::text[]) t loop + group_stats := node->group_key; + for space_key in select unnest(array['Sort Space Memory', 'Sort Space Disk']::text[]) t loop + if (group_stats->space_key->'Peak Sort Space Used')::bigint < (group_stats->space_key->'Peak Sort Space Used')::bigint then + raise exception '% has invalid max space < average space', group_key; + end if; + end loop; + end loop; + end loop; + return true; +end; +$$ +-- +FUNCTION: name="explain_analyze_inc_sort_nodes_verify_invariants" function="explain_analyze_inc_sort_nodes_verify_invariants" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION explain_analyze_inc_sort_nodes_verify_invariants(query text) RETURNS b..." +== 010 +-- truncate_limit: 100 +-- A single large group tested around each mode transition point. +insert into t(a, b) select i/100 + 1, i + 1 from generate_series(0, 999) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b) SELECT (i / 100) + 1, i + 1 FROM generate_series(0, 999) n(i)" +== 011 +-- truncate_limit: 100 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t" +== 012 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 31" +== 013 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 31" +== 014 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 32" +== 015 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 32" +== 016 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 33" +== 017 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 33" +== 018 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 65" +== 019 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 65" +== 020 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 66" +== 021 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 66" +== 022 +-- truncate_limit: 100 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t" +== 023 +-- truncate_limit: 100 +-- An initial large group followed by a small group. +insert into t(a, b) select i/50 + 1, i + 1 from generate_series(0, 999) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b) SELECT (i / 50) + 1, i + 1 FROM generate_series(0, 999) n(i)" +== 024 +-- truncate_limit: 100 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t" +== 025 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 55 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 55" +== 026 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 55 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 55" +== 027 +-- truncate_limit: 100 +-- Test EXPLAIN ANALYZE with only a fullsort group. +select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 55') +-- +FUNCTION: name="explain_analyze_without_memory" function="explain_analyze_without_memory" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 028 +-- truncate_limit: 100 +select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 55')) +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +FUNCTION: name="explain_analyze_inc_sort_nodes_without_memory" function="explain_analyze_inc_sort_nodes_without_memory" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 029 +-- truncate_limit: 100 +select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 55') +-- +FUNCTION: name="explain_analyze_inc_sort_nodes_verify_invariants" function="explain_analyze_inc_sort_nodes_verify_invariants" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 030 +-- truncate_limit: 100 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t" +== 031 +-- truncate_limit: 100 +-- An initial small group followed by a large group. +insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_series(1, 1000) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b) SELECT CASE WHEN i < 5 THEN i ELSE 9 END, i FROM generate_series(1, 1000) n(i)" +== 032 +-- truncate_limit: 100 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t" +== 033 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 70 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 70" +== 034 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 70 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 70" +== 035 +-- truncate_limit: 100 +-- Checks case where we hit a group boundary at the last tuple of a batch. +-- Because the full sort state is bounded, we scan 64 tuples (the mode +-- transition point) but only retain 5. Thus when we transition modes, all +-- tuples in the full sort state have different prefix keys. +explain (costs off) select * from (select * from t order by a) s order by a, b limit 5 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 5" +== 036 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 5 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 5" +== 037 +-- truncate_limit: 100 +-- Test rescan. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 038 +-- truncate_limit: 100 +-- We force the planner to choose a plan with incremental sort on the right side +-- of a nested loop join node. That way we trigger the rescan code path. +set local enable_hashjoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_hashjoin TO OFF" +== 039 +-- truncate_limit: 100 +set local enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_mergejoin TO OFF" +== 040 +-- truncate_limit: 100 +set local enable_material = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_material TO OFF" +== 041 +-- truncate_limit: 100 +set local enable_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_sort TO OFF" +== 042 +-- truncate_limit: 100 +explain (costs off) select * from t left join (select * from (select * from t order by a) v order by a, b) s on s.a = t.a where t.a in (1, 2) +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="t" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t LEFT JOIN (SELECT * FROM (SELECT * FROM t ORDER BY a) v ORDER..." +== 043 +-- truncate_limit: 100 +select * from t left join (select * from (select * from t order by a) v order by a, b) s on s.a = t.a where t.a in (1, 2) +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +FILTER: schema="" table="t" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t LEFT JOIN (SELECT * FROM (SELECT * FROM t ORDER BY a) v ORDER BY a, b) s ON s.a =..." +== 044 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 045 +-- truncate_limit: 100 +-- Test EXPLAIN ANALYZE with both fullsort and presorted groups. +select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 70') +-- +FUNCTION: name="explain_analyze_without_memory" function="explain_analyze_without_memory" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 046 +-- truncate_limit: 100 +select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 70')) +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +FUNCTION: name="explain_analyze_inc_sort_nodes_without_memory" function="explain_analyze_inc_sort_nodes_without_memory" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 047 +-- truncate_limit: 100 +select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select * from t order by a) s order by a, b limit 70') +-- +FUNCTION: name="explain_analyze_inc_sort_nodes_verify_invariants" function="explain_analyze_inc_sort_nodes_verify_invariants" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 048 +-- truncate_limit: 100 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t" +== 049 +-- truncate_limit: 100 +-- Small groups of 10 tuples each tested around each mode transition point. +insert into t(a, b) select i / 10, i from generate_series(1, 1000) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b) SELECT i / 10, i FROM generate_series(1, 1000) n(i)" +== 050 +-- truncate_limit: 100 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t" +== 051 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 31" +== 052 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 31" +== 053 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 32" +== 054 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 32" +== 055 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 33" +== 056 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 33" +== 057 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 65" +== 058 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 65" +== 059 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 66" +== 060 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 66" +== 061 +-- truncate_limit: 100 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t" +== 062 +-- truncate_limit: 100 +-- Small groups of only 1 tuple each tested around each mode transition point. +insert into t(a, b) select i, i from generate_series(1, 1000) n(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t (a, b) SELECT i, i FROM generate_series(1, 1000) n(i)" +== 063 +-- truncate_limit: 100 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t" +== 064 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 31" +== 065 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 31 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 31" +== 066 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 32" +== 067 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 32 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 32" +== 068 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 33" +== 069 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 33 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 33" +== 070 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 65" +== 071 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 65 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 65" +== 072 +-- truncate_limit: 100 +explain (costs off) select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 66" +== 073 +-- truncate_limit: 100 +select * from (select * from t order by a) s order by a, b limit 66 +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t ORDER BY a) s ORDER BY a, b LIMIT 66" +== 074 +-- truncate_limit: 100 +delete from t +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t" +== 075 +-- truncate_limit: 100 +drop table t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 076 +-- truncate_limit: 100 +-- Incremental sort vs. parallel queries +set min_parallel_table_scan_size = '1kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO \"1kB\"" +== 077 +-- truncate_limit: 100 +set min_parallel_index_scan_size = '1kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_index_scan_size TO \"1kB\"" +== 078 +-- truncate_limit: 100 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 079 +-- truncate_limit: 100 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 080 +-- truncate_limit: 100 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 081 +-- truncate_limit: 100 +create table t (a int, b int, c int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t (a int, b int, c int)" +== 082 +-- truncate_limit: 100 +insert into t select mod(i,10),mod(i,10),i from generate_series(1,10000) s(i) +-- +TABLE: name="t" schema="" table="t" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t SELECT mod(i, 10), mod(i, 10), i FROM generate_series(1, 10000) s(i)" +== 083 +-- truncate_limit: 100 +create index on t (a) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON t USING btree (a)" +== 084 +-- truncate_limit: 100 +analyze t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t" +== 085 +-- truncate_limit: 100 +set enable_incremental_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_incremental_sort TO OFF" +== 086 +-- truncate_limit: 100 +explain (costs off) select a,b,sum(c) from t group by 1,2 order by 1,2,3 limit 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, sum(c) FROM t GROUP BY 1, 2 ORDER BY 1, 2, 3 LIMIT 1" +== 087 +-- truncate_limit: 100 +set enable_incremental_sort = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_incremental_sort TO ON" +== 088 +-- truncate_limit: 100 +explain (costs off) select a,b,sum(c) from t group by 1,2 order by 1,2,3 limit 1 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, sum(c) FROM t GROUP BY 1, 2 ORDER BY 1, 2, 3 LIMIT 1" +== 089 +-- truncate_limit: 100 +-- Incremental sort vs. set operations with varno 0 +set enable_hashagg to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 090 +-- truncate_limit: 100 +explain (costs off) select * from t union select * from t order by 1,3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t UNION SELECT * FROM t ORDER BY 1, 3" +== 091 +-- truncate_limit: 100 +-- Full sort, not just incremental sort can be pushed below a gather merge path +-- by generate_useful_gather_paths. +explain (costs off) select distinct a,b from t +-- +TABLE: name="t" schema="" table="t" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT a, b FROM t" +== 092 +-- truncate_limit: 100 +drop table t +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t" +== 093 +-- truncate_limit: 100 +-- Sort pushdown can't go below where expressions are part of the rel target. +-- In particular this is interesting for volatile expressions which have to +-- go above joins since otherwise we'll incorrectly use expression evaluations +-- across multiple rows. +set enable_hashagg=off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 094 +-- truncate_limit: 100 +set enable_seqscan=off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 095 +-- truncate_limit: 100 +set enable_incremental_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_incremental_sort TO OFF" +== 096 +-- truncate_limit: 100 +set parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 097 +-- truncate_limit: 100 +set parallel_setup_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 098 +-- truncate_limit: 100 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 099 +-- truncate_limit: 100 +set min_parallel_index_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_index_scan_size TO 0" +== 100 +-- truncate_limit: 100 +-- Parallel sort below join. +explain (costs off) select distinct sub.unique1, stringu1 +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT sub.unique1, stringu1 FROM tenk1, LATERAL (SELECT tenk1.uniqu..." +== 101 +-- truncate_limit: 100 +explain (costs off) select sub.unique1, stringu1 +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +order by 1, 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sub.unique1, stringu1 FROM tenk1, LATERAL (SELECT tenk1.unique1 FROM g..." +== 102 +-- truncate_limit: 100 +-- Parallel sort but with expression that can be safely generated at the base rel. +explain (costs off) select distinct sub.unique1, md5(stringu1) +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="md5" function="md5" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT sub.unique1, md5(stringu1) FROM tenk1, LATERAL (SELECT tenk1...." +== 103 +-- truncate_limit: 100 +explain (costs off) select sub.unique1, md5(stringu1) +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +order by 1, 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="md5" function="md5" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sub.unique1, md5(stringu1) FROM tenk1, LATERAL (SELECT tenk1.unique1 F..." +== 104 +-- truncate_limit: 100 +-- Parallel sort with an aggregate that can be safely generated in parallel, +-- but we can't sort by partial aggregate values. +explain (costs off) select count(*) +from tenk1 t1 +join tenk1 t2 on t1.unique1 = t2.unique2 +join tenk1 t3 on t2.unique1 = t3.unique1 +order by count(*) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.unique1 = t2.unique2 JOIN t..." +== 105 +-- truncate_limit: 100 +-- Parallel sort but with expression (correlated subquery) that +-- is prohibited in parallel plans. +explain (costs off) select distinct + unique1, + (select t.unique1 from tenk1 where tenk1.unique1 = t.unique1) +from tenk1 t, generate_series(1, 1000) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t"="tenk1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +FILTER: schema="" table="t" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT unique1, (SELECT t.unique1 FROM tenk1 WHERE tenk1.unique1 = t..." +== 106 +-- truncate_limit: 100 +explain (costs off) select + unique1, + (select t.unique1 from tenk1 where tenk1.unique1 = t.unique1) +from tenk1 t, generate_series(1, 1000) +order by 1, 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t"="tenk1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +FILTER: schema="" table="t" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, (SELECT t.unique1 FROM tenk1 WHERE tenk1.unique1 = t.unique1)..." +== 107 +-- truncate_limit: 100 +-- Parallel sort but with expression not available until the upper rel. +explain (costs off) select distinct sub.unique1, stringu1 || random()::text +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT sub.unique1, stringu1 || random()::text FROM tenk1, LATERAL (..." +== 108 +-- truncate_limit: 100 +explain (costs off) select sub.unique1, stringu1 || random()::text +from tenk1, lateral (select tenk1.unique1 from generate_series(1, 1000)) as sub +order by 1, 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sub.unique1, stringu1 || random()::text FROM tenk1, LATERAL (SELECT te..." +== 109 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 110 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 111 +-- truncate_limit: 100 +reset enable_incremental_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_incremental_sort" +== 112 +-- truncate_limit: 100 +reset parallel_tuple_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_tuple_cost" +== 113 +-- truncate_limit: 100 +reset parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 114 +-- truncate_limit: 100 +reset min_parallel_table_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_table_scan_size" +== 115 +-- truncate_limit: 100 +reset min_parallel_index_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_index_scan_size" +== 116 +-- truncate_limit: 100 +-- Ensure incremental sorts work for amcanorderbyop type indexes +create table point_table (a point, b int) +-- +TABLE: name="point_table" schema="" table="point_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE point_table (a point, b int)" +== 117 +-- truncate_limit: 100 +create index point_table_a_idx on point_table using gist(a) +-- +TABLE: name="point_table" schema="" table="point_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX point_table_a_idx ON point_table USING gist (a)" +== 118 +-- truncate_limit: 100 +-- Ensure we get an incremental sort plan for both of the following queries +explain (costs off) select a, b, a <-> point(5, 5) dist from point_table order by dist, b limit 1 +-- +TABLE: name="point_table" schema="" table="point_table" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, a <-> point(5, 5) AS dist FROM point_table ORDER BY dist, b LIMIT 1" +== 119 +-- truncate_limit: 100 +explain (costs off) select a, b, a <-> point(5, 5) dist from point_table order by dist, b desc limit 1 +-- +TABLE: name="point_table" schema="" table="point_table" ctx=Select +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, a <-> point(5, 5) AS dist FROM point_table ORDER BY dist, b DESC..." diff --git a/parser/testdata/summary_truncate/postgres_regress/index_including.metadata.json b/parser/testdata/summary_truncate/postgres_regress/index_including.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/index_including.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/index_including.test b/parser/testdata/summary_truncate/postgres_regress/index_including.test new file mode 100644 index 0000000..fd90ad2 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/index_including.test @@ -0,0 +1,1132 @@ +== 001 +-- truncate_limit: 100 +/* + * 1.test CREATE INDEX + * + * Deliberately avoid dropping objects in this section, to get some pg_dump + * coverage. + */ + +-- Regular index with included columns +CREATE TABLE tbl_include_reg (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_reg" schema="" table="tbl_include_reg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_include_reg (c1 int, c2 int, c3 int, c4 box)" +== 002 +-- truncate_limit: 100 +INSERT INTO tbl_include_reg SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_reg" schema="" table="tbl_include_reg" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_include_reg SELECT x, 2 * x, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 003 +-- truncate_limit: 100 +CREATE INDEX tbl_include_reg_idx ON tbl_include_reg (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_reg" schema="" table="tbl_include_reg" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbl_include_reg_idx ON tbl_include_reg USING btree (c1, c2) INCLUDE (c3, c4)" +== 004 +-- truncate_limit: 100 +-- duplicate column is pretty pointless, but we allow it anyway +CREATE INDEX ON tbl_include_reg (c1, c2) INCLUDE (c1, c3) +-- +TABLE: name="tbl_include_reg" schema="" table="tbl_include_reg" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl_include_reg USING btree (c1, c2) INCLUDE (c1, c3)" +== 005 +-- truncate_limit: 100 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_include_reg'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid WHERE ... ORDER BY c.relname" +== 006 +-- truncate_limit: 100 +-- Unique index and unique constraint +CREATE TABLE tbl_include_unique1 (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_include_unique1 (c1 int, c2 int, c3 int, c4 box)" +== 007 +-- truncate_limit: 100 +INSERT INTO tbl_include_unique1 SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_include_unique1 SELECT x, 2 * x, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 008 +-- truncate_limit: 100 +CREATE UNIQUE INDEX tbl_include_unique1_idx_unique ON tbl_include_unique1 using btree (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX tbl_include_unique1_idx_unique ON tbl_include_unique1 USING btree (c1, c2) IN..." +== 009 +-- truncate_limit: 100 +ALTER TABLE tbl_include_unique1 add UNIQUE USING INDEX tbl_include_unique1_idx_unique +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_include_unique1 ADD UNIQUE USING INDEX tbl_include_unique1_idx_unique" +== 010 +-- truncate_limit: 100 +ALTER TABLE tbl_include_unique1 add UNIQUE (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_unique1" schema="" table="tbl_include_unique1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_include_unique1 ADD UNIQUE (c1, c2) INCLUDE (c3, c4)" +== 011 +-- truncate_limit: 100 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_include_unique1'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid WHERE ... ORDER BY c.relname" +== 012 +-- truncate_limit: 100 +-- Unique index and unique constraint. Both must fail. +CREATE TABLE tbl_include_unique2 (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_unique2" schema="" table="tbl_include_unique2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_include_unique2 (c1 int, c2 int, c3 int, c4 box)" +== 013 +-- truncate_limit: 100 +INSERT INTO tbl_include_unique2 SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_unique2" schema="" table="tbl_include_unique2" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_include_unique2 SELECT 1, 2, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 014 +-- truncate_limit: 100 +CREATE UNIQUE INDEX tbl_include_unique2_idx_unique ON tbl_include_unique2 using btree (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_unique2" schema="" table="tbl_include_unique2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX tbl_include_unique2_idx_unique ON tbl_include_unique2 USING btree (c1, c2) IN..." +== 015 +-- truncate_limit: 100 +ALTER TABLE tbl_include_unique2 add UNIQUE (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_unique2" schema="" table="tbl_include_unique2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_include_unique2 ADD UNIQUE (c1, c2) INCLUDE (c3, c4)" +== 016 +-- truncate_limit: 100 +-- PK constraint +CREATE TABLE tbl_include_pk (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_pk" schema="" table="tbl_include_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_include_pk (c1 int, c2 int, c3 int, c4 box)" +== 017 +-- truncate_limit: 100 +INSERT INTO tbl_include_pk SELECT 1, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_pk" schema="" table="tbl_include_pk" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_include_pk SELECT 1, 2 * x, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 018 +-- truncate_limit: 100 +ALTER TABLE tbl_include_pk add PRIMARY KEY (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_pk" schema="" table="tbl_include_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_include_pk ADD PRIMARY KEY (c1, c2) INCLUDE (c3, c4)" +== 019 +-- truncate_limit: 100 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_include_pk'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid WHERE ... ORDER BY c.relname" +== 020 +-- truncate_limit: 100 +CREATE TABLE tbl_include_box (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_box" schema="" table="tbl_include_box" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_include_box (c1 int, c2 int, c3 int, c4 box)" +== 021 +-- truncate_limit: 100 +INSERT INTO tbl_include_box SELECT 1, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_box" schema="" table="tbl_include_box" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_include_box SELECT 1, 2 * x, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 022 +-- truncate_limit: 100 +CREATE UNIQUE INDEX tbl_include_box_idx_unique ON tbl_include_box using btree (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_box" schema="" table="tbl_include_box" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX tbl_include_box_idx_unique ON tbl_include_box USING btree (c1, c2) INCLUDE (c..." +== 023 +-- truncate_limit: 100 +ALTER TABLE tbl_include_box add PRIMARY KEY USING INDEX tbl_include_box_idx_unique +-- +TABLE: name="tbl_include_box" schema="" table="tbl_include_box" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_include_box ADD PRIMARY KEY USING INDEX tbl_include_box_idx_unique" +== 024 +-- truncate_limit: 100 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_include_box'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid WHERE ... ORDER BY c.relname" +== 025 +-- truncate_limit: 100 +-- PK constraint. Must fail. +CREATE TABLE tbl_include_box_pk (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_include_box_pk" schema="" table="tbl_include_box_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_include_box_pk (c1 int, c2 int, c3 int, c4 box)" +== 026 +-- truncate_limit: 100 +INSERT INTO tbl_include_box_pk SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_include_box_pk" schema="" table="tbl_include_box_pk" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_include_box_pk SELECT 1, 2, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 027 +-- truncate_limit: 100 +ALTER TABLE tbl_include_box_pk add PRIMARY KEY (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl_include_box_pk" schema="" table="tbl_include_box_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_include_box_pk ADD PRIMARY KEY (c1, c2) INCLUDE (c3, c4)" +== 028 +-- truncate_limit: 100 +/* + * 2. Test CREATE TABLE with constraint + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + CONSTRAINT covering UNIQUE(c1,c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, CONSTRAINT covering UNIQUE (c1, c2) INCLUDE (c3..." +== 029 +-- truncate_limit: 100 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE indrelid = 'tbl'::regclass::oid" +== 030 +-- truncate_limit: 100 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid" +== 031 +-- truncate_limit: 100 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT 1, 2, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 032 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 033 +-- truncate_limit: 100 +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + CONSTRAINT covering PRIMARY KEY(c1,c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, CONSTRAINT covering PRIMARY KEY (c1, c2) INCLUD..." +== 034 +-- truncate_limit: 100 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE indrelid = 'tbl'::regclass::oid" +== 035 +-- truncate_limit: 100 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid" +== 036 +-- truncate_limit: 100 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT 1, 2, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 037 +-- truncate_limit: 100 +INSERT INTO tbl SELECT 1, NULL, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT 1, NULL, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 038 +-- truncate_limit: 100 +INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,300) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT x, 2 * x, NULL, NULL FROM generate_series(1, 300) x" +== 039 +-- truncate_limit: 100 +explain (costs off) +select * from tbl where (c1,c2,c3) < (2,5,1) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c3" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tbl WHERE (c1, c2, c3) < (2, 5, 1)" +== 040 +-- truncate_limit: 100 +select * from tbl where (c1,c2,c3) < (2,5,1) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c3" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tbl WHERE (c1, c2, c3) < (2, 5, 1)" +== 041 +-- truncate_limit: 100 +-- row comparison that compares high key at page boundary +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 042 +-- truncate_limit: 100 +explain (costs off) +select * from tbl where (c1,c2,c3) < (262,1,1) limit 1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c3" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tbl WHERE (c1, c2, c3) < (262, 1, 1) LIMIT 1" +== 043 +-- truncate_limit: 100 +select * from tbl where (c1,c2,c3) < (262,1,1) limit 1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=Select +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c3" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tbl WHERE (c1, c2, c3) < (262, 1, 1) LIMIT 1" +== 044 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 045 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 046 +-- truncate_limit: 100 +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + UNIQUE(c1,c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, UNIQUE (c1, c2) INCLUDE (c3, c4))" +== 047 +-- truncate_limit: 100 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE indrelid = 'tbl'::regclass::oid" +== 048 +-- truncate_limit: 100 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid" +== 049 +-- truncate_limit: 100 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT 1, 2, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 050 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 051 +-- truncate_limit: 100 +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + PRIMARY KEY(c1,c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, PRIMARY KEY (c1, c2) INCLUDE (c3, c4))" +== 052 +-- truncate_limit: 100 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE indrelid = 'tbl'::regclass::oid" +== 053 +-- truncate_limit: 100 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid" +== 054 +-- truncate_limit: 100 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT 1, 2, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 055 +-- truncate_limit: 100 +INSERT INTO tbl SELECT 1, NULL, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT 1, NULL, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 056 +-- truncate_limit: 100 +INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT x, 2 * x, NULL, NULL FROM generate_series(1, 10) x" +== 057 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 058 +-- truncate_limit: 100 +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, + EXCLUDE USING btree (c1 WITH =) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, EXCLUDE (c1 WITH =) INCLUDE (c3, c4))" +== 059 +-- truncate_limit: 100 +SELECT indexrelid::regclass, indnatts, indnkeyatts, indisunique, indisprimary, indkey, indclass FROM pg_index WHERE indrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index WHERE indrelid = 'tbl'::regclass::oid" +== 060 +-- truncate_limit: 100 +SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid = 'tbl'::regclass::oid" +== 061 +-- truncate_limit: 100 +-- ensure that constraint works +INSERT INTO tbl SELECT 1, 2, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT 1, 2, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 062 +-- truncate_limit: 100 +INSERT INTO tbl SELECT x, 2*x, NULL, NULL FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT x, 2 * x, NULL, NULL FROM generate_series(1, 10) x" +== 063 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 064 +-- truncate_limit: 100 +/* + * 3.0 Test ALTER TABLE DROP COLUMN. + * Any column deletion leads to index deletion. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 int) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 int)" +== 065 +-- truncate_limit: 100 +CREATE UNIQUE INDEX tbl_idx ON tbl using btree(c1, c2, c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX tbl_idx ON tbl USING btree (c1, c2, c3, c4)" +== 066 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 067 +-- truncate_limit: 100 +ALTER TABLE tbl DROP COLUMN c3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl DROP c3" +== 068 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 069 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 070 +-- truncate_limit: 100 +/* + * 3.1 Test ALTER TABLE DROP COLUMN. + * Included column deletion leads to the index deletion, + * AS well AS key columns deletion. It's explained in documentation. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box)" +== 071 +-- truncate_limit: 100 +CREATE UNIQUE INDEX tbl_idx ON tbl using btree(c1, c2) INCLUDE(c3,c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX tbl_idx ON tbl USING btree (c1, c2) INCLUDE (c3, c4)" +== 072 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 073 +-- truncate_limit: 100 +ALTER TABLE tbl DROP COLUMN c3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl DROP c3" +== 074 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 075 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 076 +-- truncate_limit: 100 +/* + * 3.2 Test ALTER TABLE DROP COLUMN. + * Included column deletion leads to the index deletion. + * AS well AS key columns deletion. It's explained in documentation. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, UNIQUE(c1, c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, UNIQUE (c1, c2) INCLUDE (c3, c4))" +== 077 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 078 +-- truncate_limit: 100 +ALTER TABLE tbl DROP COLUMN c3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl DROP c3" +== 079 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 080 +-- truncate_limit: 100 +ALTER TABLE tbl DROP COLUMN c1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl DROP c1" +== 081 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 082 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 083 +-- truncate_limit: 100 +/* + * 3.3 Test ALTER TABLE SET STATISTICS + */ +CREATE TABLE tbl (c1 int, c2 int) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int)" +== 084 +-- truncate_limit: 100 +CREATE INDEX tbl_idx ON tbl (c1, (c1+0)) INCLUDE (c2) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbl_idx ON tbl USING btree (c1, (c1 + 0)) INCLUDE (c2)" +== 085 +-- truncate_limit: 100 +ALTER INDEX tbl_idx ALTER COLUMN 1 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX tbl_idx ALTER COLUMN 1 SET STATISTICS 1000" +== 086 +-- truncate_limit: 100 +ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX tbl_idx ALTER COLUMN 2 SET STATISTICS 1000" +== 087 +-- truncate_limit: 100 +ALTER INDEX tbl_idx ALTER COLUMN 3 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX tbl_idx ALTER COLUMN 3 SET STATISTICS 1000" +== 088 +-- truncate_limit: 100 +ALTER INDEX tbl_idx ALTER COLUMN 4 SET STATISTICS 1000 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX tbl_idx ALTER COLUMN 4 SET STATISTICS 1000" +== 089 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 090 +-- truncate_limit: 100 +/* + * 4. CREATE INDEX CONCURRENTLY + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, UNIQUE(c1, c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, UNIQUE (c1, c2) INCLUDE (c3, c4))" +== 091 +-- truncate_limit: 100 +INSERT INTO tbl SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,1000) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT x, 2 * x, 3 * x, box('4,4,4,4') FROM generate_series(1, 1000) x" +== 092 +-- truncate_limit: 100 +CREATE UNIQUE INDEX CONCURRENTLY on tbl (c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX CONCURRENTLY ON tbl USING btree (c1, c2) INCLUDE (c3, c4)" +== 093 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 094 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 095 +-- truncate_limit: 100 +/* + * 5. REINDEX + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, UNIQUE(c1, c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, UNIQUE (c1, c2) INCLUDE (c3, c4))" +== 096 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 097 +-- truncate_limit: 100 +ALTER TABLE tbl DROP COLUMN c3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl DROP c3" +== 098 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 099 +-- truncate_limit: 100 +REINDEX INDEX tbl_c1_c2_c3_c4_key +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX tbl_c1_c2_c3_c4_key" +== 100 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 101 +-- truncate_limit: 100 +ALTER TABLE tbl DROP COLUMN c1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl DROP c1" +== 102 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl' ORDER BY indexname" +== 103 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 104 +-- truncate_limit: 100 +/* + * 7. Check various AMs. All but btree, gist and spgist must fail. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 box, c4 box) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 box, c4 box)" +== 105 +-- truncate_limit: 100 +CREATE INDEX on tbl USING brin(c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl USING brin (c1, c2) INCLUDE (c3, c4)" +== 106 +-- truncate_limit: 100 +CREATE INDEX on tbl USING gist(c3) INCLUDE (c1, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl USING gist (c3) INCLUDE (c1, c4)" +== 107 +-- truncate_limit: 100 +CREATE INDEX on tbl USING spgist(c3) INCLUDE (c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl USING spgist (c3) INCLUDE (c4)" +== 108 +-- truncate_limit: 100 +CREATE INDEX on tbl USING gin(c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl USING gin (c1, c2) INCLUDE (c3, c4)" +== 109 +-- truncate_limit: 100 +CREATE INDEX on tbl USING hash(c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl USING hash (c1, c2) INCLUDE (c3, c4)" +== 110 +-- truncate_limit: 100 +CREATE INDEX on tbl USING rtree(c3) INCLUDE (c1, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl USING rtree (c3) INCLUDE (c1, c4)" +== 111 +-- truncate_limit: 100 +CREATE INDEX on tbl USING btree(c1, c2) INCLUDE (c3, c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl USING btree (c1, c2) INCLUDE (c3, c4)" +== 112 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 113 +-- truncate_limit: 100 +/* + * 8. Update, delete values in indexed table. + */ +CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box)" +== 114 +-- truncate_limit: 100 +INSERT INTO tbl SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT x, 2 * x, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 115 +-- truncate_limit: 100 +CREATE UNIQUE INDEX tbl_idx_unique ON tbl using btree(c1, c2) INCLUDE (c3,c4) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX tbl_idx_unique ON tbl USING btree (c1, c2) INCLUDE (c3, c4)" +== 116 +-- truncate_limit: 100 +UPDATE tbl SET c1 = 100 WHERE c1 = 2 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tbl SET c1 = 100 WHERE c1 = 2" +== 117 +-- truncate_limit: 100 +UPDATE tbl SET c1 = 1 WHERE c1 = 3 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tbl SET c1 = 1 WHERE c1 = 3" +== 118 +-- truncate_limit: 100 +-- should fail +UPDATE tbl SET c2 = 2 WHERE c1 = 1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tbl SET c2 = 2 WHERE c1 = 1" +== 119 +-- truncate_limit: 100 +UPDATE tbl SET c3 = 1 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tbl SET c3 = 1" +== 120 +-- truncate_limit: 100 +DELETE FROM tbl WHERE c1 = 5 OR c3 = 12 +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tbl WHERE c1 = 5 OR c3 = 12" +== 121 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 122 +-- truncate_limit: 100 +/* + * 9. Alter column type. + */ +CREATE TABLE tbl (c1 int,c2 int, c3 int, c4 box, UNIQUE(c1, c2) INCLUDE(c3,c4)) +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl (c1 int, c2 int, c3 int, c4 box, UNIQUE (c1, c2) INCLUDE (c3, c4))" +== 123 +-- truncate_limit: 100 +INSERT INTO tbl SELECT x, 2*x, 3*x, box('4,4,4,4') FROM generate_series(1,10) AS x +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl SELECT x, 2 * x, 3 * x, box('4,4,4,4') FROM generate_series(1, 10) x" +== 124 +-- truncate_limit: 100 +ALTER TABLE tbl ALTER c1 TYPE bigint +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl ALTER COLUMN c1 TYPE bigint" +== 125 +-- truncate_limit: 100 +ALTER TABLE tbl ALTER c3 TYPE bigint +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl ALTER COLUMN c3 TYPE bigint" +== 126 +-- truncate_limit: 100 +DROP TABLE tbl +-- +TABLE: name="tbl" schema="" table="tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl" +== 127 +-- truncate_limit: 100 +/* + * 10. Test coverage for names stored as cstrings in indexes + */ +CREATE TABLE nametbl (c1 int, c2 name, c3 float) +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE nametbl (c1 int, c2 name, c3 double precision)" +== 128 +-- truncate_limit: 100 +CREATE INDEX nametbl_c1_c2_idx ON nametbl (c2, c1) INCLUDE (c3) +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX nametbl_c1_c2_idx ON nametbl USING btree (c2, c1) INCLUDE (c3)" +== 129 +-- truncate_limit: 100 +INSERT INTO nametbl VALUES(1, 'two', 3.0) +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nametbl VALUES (1, 'two', 3.0)" +== 130 +-- truncate_limit: 100 +VACUUM nametbl +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM nametbl" +== 131 +-- truncate_limit: 100 +SET enable_seqscan = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO 0" +== 132 +-- truncate_limit: 100 +-- Ensure we get an index only scan plan +EXPLAIN (COSTS OFF) SELECT c2, c1, c3 FROM nametbl WHERE c2 = 'two' AND c1 = 1 +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=Select +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c2, c1, c3 FROM nametbl WHERE c2 = 'two' AND c1 = 1" +== 133 +-- truncate_limit: 100 +-- Validate the results look sane +SELECT c2, c1, c3 FROM nametbl WHERE c2 = 'two' AND c1 = 1 +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=Select +FILTER: schema="" table="" column="c2" +FILTER: schema="" table="" column="c1" +STMT: SelectStmt +TRUNCATED: "SELECT c2, c1, c3 FROM nametbl WHERE c2 = 'two' AND c1 = 1" +== 134 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 135 +-- truncate_limit: 100 +DROP TABLE nametbl +-- +TABLE: name="nametbl" schema="" table="nametbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE nametbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/index_including_gist.metadata.json b/parser/testdata/summary_truncate/postgres_regress/index_including_gist.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/index_including_gist.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/index_including_gist.test b/parser/testdata/summary_truncate/postgres_regress/index_including_gist.test new file mode 100644 index 0000000..c2b0f81 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/index_including_gist.test @@ -0,0 +1,468 @@ +== 001 +-- truncate_limit: 100 +/* + * 1.1. test CREATE INDEX with buffered build + */ + +-- Regular index with included columns +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box)" +== 002 +-- truncate_limit: 100 +-- size is chosen to exceed page size and trigger actual truncation +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,8000) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_gist SELECT ... FROM generate_series(1, 8000) x" +== 003 +-- truncate_limit: 100 +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c2,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbl_gist_idx ON tbl_gist USING gist (c4) INCLUDE (c1, c2, c3)" +== 004 +-- truncate_limit: 100 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_gist'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid WHERE ... ORDER BY c.relname" +== 005 +-- truncate_limit: 100 +SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tbl_gist WHERE c4 <@ box(point(1, 1), point(10, 10))" +== 006 +-- truncate_limit: 100 +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 007 +-- truncate_limit: 100 +EXPLAIN (costs off) SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tbl_gist WHERE c4 <@ box(point(1, 1), point(10, 10))" +== 008 +-- truncate_limit: 100 +SET enable_bitmapscan TO default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO DEFAULT" +== 009 +-- truncate_limit: 100 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl_gist" +== 010 +-- truncate_limit: 100 +/* + * 1.2. test CREATE INDEX with inserts + */ + +-- Regular index with included columns +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box)" +== 011 +-- truncate_limit: 100 +-- size is chosen to exceed page size and trigger actual truncation +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c2,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbl_gist_idx ON tbl_gist USING gist (c4) INCLUDE (c1, c2, c3)" +== 012 +-- truncate_limit: 100 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,8000) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_gist SELECT ... FROM generate_series(1, 8000) x" +== 013 +-- truncate_limit: 100 +SELECT pg_get_indexdef(i.indexrelid) +FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid +WHERE i.indrelid = 'tbl_gist'::regclass ORDER BY c.relname +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="i" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index i JOIN pg_class c ON i.indexrelid = c.oid WHERE ... ORDER BY c.relname" +== 014 +-- truncate_limit: 100 +SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tbl_gist WHERE c4 <@ box(point(1, 1), point(10, 10))" +== 015 +-- truncate_limit: 100 +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 016 +-- truncate_limit: 100 +EXPLAIN (costs off) SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tbl_gist WHERE c4 <@ box(point(1, 1), point(10, 10))" +== 017 +-- truncate_limit: 100 +SET enable_bitmapscan TO default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO DEFAULT" +== 018 +-- truncate_limit: 100 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl_gist" +== 019 +-- truncate_limit: 100 +/* + * 2. CREATE INDEX CONCURRENTLY + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box)" +== 020 +-- truncate_limit: 100 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_gist SELECT ... FROM generate_series(1, 10) x" +== 021 +-- truncate_limit: 100 +CREATE INDEX CONCURRENTLY tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c2,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY tbl_gist_idx ON tbl_gist USING gist (c4) INCLUDE (c1, c2, c3)" +== 022 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname" +== 023 +-- truncate_limit: 100 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl_gist" +== 024 +-- truncate_limit: 100 +/* + * 3. REINDEX + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box)" +== 025 +-- truncate_limit: 100 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_gist SELECT ... FROM generate_series(1, 10) x" +== 026 +-- truncate_limit: 100 +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbl_gist_idx ON tbl_gist USING gist (c4) INCLUDE (c1, c3)" +== 027 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname" +== 028 +-- truncate_limit: 100 +REINDEX INDEX tbl_gist_idx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX tbl_gist_idx" +== 029 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname" +== 030 +-- truncate_limit: 100 +ALTER TABLE tbl_gist DROP COLUMN c1 +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_gist DROP c1" +== 031 +-- truncate_limit: 100 +SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE tablename = 'tbl_gist' ORDER BY indexname" +== 032 +-- truncate_limit: 100 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl_gist" +== 033 +-- truncate_limit: 100 +/* + * 4. Update, delete values in indexed table. + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box)" +== 034 +-- truncate_limit: 100 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_gist SELECT ... FROM generate_series(1, 10) x" +== 035 +-- truncate_limit: 100 +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbl_gist_idx ON tbl_gist USING gist (c4) INCLUDE (c1, c3)" +== 036 +-- truncate_limit: 100 +UPDATE tbl_gist SET c1 = 100 WHERE c1 = 2 +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tbl_gist SET c1 = 100 WHERE c1 = 2" +== 037 +-- truncate_limit: 100 +UPDATE tbl_gist SET c1 = 1 WHERE c1 = 3 +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tbl_gist SET c1 = 1 WHERE c1 = 3" +== 038 +-- truncate_limit: 100 +DELETE FROM tbl_gist WHERE c1 = 5 OR c3 = 12 +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tbl_gist WHERE c1 = 5 OR c3 = 12" +== 039 +-- truncate_limit: 100 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl_gist" +== 040 +-- truncate_limit: 100 +/* + * 5. Alter column type. + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box)" +== 041 +-- truncate_limit: 100 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_gist SELECT ... FROM generate_series(1, 10) x" +== 042 +-- truncate_limit: 100 +CREATE INDEX tbl_gist_idx ON tbl_gist using gist (c4) INCLUDE (c1,c3) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbl_gist_idx ON tbl_gist USING gist (c4) INCLUDE (c1, c3)" +== 043 +-- truncate_limit: 100 +ALTER TABLE tbl_gist ALTER c1 TYPE bigint +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_gist ALTER COLUMN c1 TYPE bigint" +== 044 +-- truncate_limit: 100 +ALTER TABLE tbl_gist ALTER c3 TYPE bigint +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tbl_gist ALTER COLUMN c3 TYPE bigint" +== 045 +-- truncate_limit: 100 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl_gist" +== 046 +-- truncate_limit: 100 +/* + * 6. EXCLUDE constraint. + */ +CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box, EXCLUDE USING gist (c4 WITH &&) INCLUDE (c1, c2, c3)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_gist (c1 int, c2 int, c3 int, c4 box, EXCLUDE USING gist (c4 WITH &&) INCLUDE (c..." +== 047 +-- truncate_limit: 100 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(x,x+1),point(2*x,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_gist SELECT ... FROM generate_series(1, 10) x" +== 048 +-- truncate_limit: 100 +INSERT INTO tbl_gist SELECT x, 2*x, 3*x, box(point(3*x,2*x),point(3*x+1,2*x+1)) FROM generate_series(1,10) AS x +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_gist SELECT ... FROM generate_series(1, 10) x" +== 049 +-- truncate_limit: 100 +EXPLAIN (costs off) SELECT * FROM tbl_gist where c4 <@ box(point(1,1),point(10,10)) +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=Select +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FILTER: schema="" table="" column="c4" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tbl_gist WHERE c4 <@ box(point(1, 1), point(10, 10))" +== 050 +-- truncate_limit: 100 +DROP TABLE tbl_gist +-- +TABLE: name="tbl_gist" schema="" table="tbl_gist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl_gist" diff --git a/parser/testdata/summary_truncate/postgres_regress/indexing.metadata.json b/parser/testdata/summary_truncate/postgres_regress/indexing.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/indexing.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/indexing.test b/parser/testdata/summary_truncate/postgres_regress/indexing.test new file mode 100644 index 0000000..9c8892b --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/indexing.test @@ -0,0 +1,4348 @@ +== 001 +-- truncate_limit: 100 +-- Creating an index on a partitioned table makes the partitions +-- automatically get the index +create table idxpart (a int, b int, c text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, c text) PARTITION BY RANGE (a)" +== 002 +-- truncate_limit: 100 +-- relhassubclass of a partitioned index is false before creating any partition. +-- It will be set after the first partition is created. +create index idxpart_idx on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_idx ON idxpart USING btree (a)" +== 003 +-- truncate_limit: 100 +select relhassubclass from pg_class where relname = 'idxpart_idx' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relhassubclass FROM pg_class WHERE relname = 'idxpart_idx'" +== 004 +-- truncate_limit: 100 +-- Check that partitioned indexes are present in pg_indexes. +select indexdef from pg_indexes where indexname like 'idxpart_idx%' +-- +TABLE: name="pg_indexes" schema="" table="pg_indexes" ctx=Select +FILTER: schema="" table="" column="indexname" +STMT: SelectStmt +TRUNCATED: "SELECT indexdef FROM pg_indexes WHERE indexname LIKE 'idxpart_idx%'" +== 005 +-- truncate_limit: 100 +drop index idxpart_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart_idx" +== 006 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0) to (10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0) TO (10)" +== 007 +-- truncate_limit: 100 +create table idxpart2 partition of idxpart for values from (10) to (100) + partition by range (b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 PARTITION OF idxpart FOR VALUES FROM (10) TO (100) PARTITION BY RANGE (b)" +== 008 +-- truncate_limit: 100 +create table idxpart21 partition of idxpart2 for values from (0) to (100) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart21 PARTITION OF idxpart2 FOR VALUES FROM (0) TO (100)" +== 009 +-- truncate_limit: 100 +-- Even with partitions, relhassubclass should not be set if a partitioned +-- index is created only on the parent. +create index idxpart_idx on only idxpart(a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_idx ON ONLY idxpart USING btree (a)" +== 010 +-- truncate_limit: 100 +select relhassubclass from pg_class where relname = 'idxpart_idx' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relhassubclass FROM pg_class WHERE relname = 'idxpart_idx'" +== 011 +-- truncate_limit: 100 +drop index idxpart_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart_idx" +== 012 +-- truncate_limit: 100 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a)" +== 013 +-- truncate_limit: 100 +select relname, relkind, relhassubclass, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_index ix ON indexrelid = oid LEFT JOIN pg_inherits ON ix.in..." +== 014 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 015 +-- truncate_limit: 100 +-- Some unsupported features +create table idxpart (a int, b int, c text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, c text) PARTITION BY RANGE (a)" +== 016 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0) to (10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0) TO (10)" +== 017 +-- truncate_limit: 100 +create index concurrently on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY ON idxpart USING btree (a)" +== 018 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 019 +-- truncate_limit: 100 +-- Verify bugfix with query on indexed partitioned table with no partitions +-- https://postgr.es/m/20180124162006.pmapfiznhgngwtjf@alvherre.pgsql +CREATE TABLE idxpart (col1 INT) PARTITION BY RANGE (col1) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (col1 int) PARTITION BY RANGE (col1)" +== 020 +-- truncate_limit: 100 +CREATE INDEX ON idxpart (col1) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (col1)" +== 021 +-- truncate_limit: 100 +CREATE TABLE idxpart_two (col2 INT) +-- +TABLE: name="idxpart_two" schema="" table="idxpart_two" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart_two (col2 int)" +== 022 +-- truncate_limit: 100 +SELECT col2 FROM idxpart_two fk LEFT OUTER JOIN idxpart pk ON (col1 = col2) +-- +TABLE: name="idxpart_two" schema="" table="idxpart_two" ctx=Select +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +ALIAS: "fk"="idxpart_two" +ALIAS: "pk"="idxpart" +STMT: SelectStmt +TRUNCATED: "SELECT col2 FROM idxpart_two fk LEFT JOIN idxpart pk ON col1 = col2" +== 023 +-- truncate_limit: 100 +DROP table idxpart, idxpart_two +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart_two" schema="" table="idxpart_two" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart, idxpart_two" +== 024 +-- truncate_limit: 100 +-- Verify bugfix with index rewrite on ALTER TABLE / SET DATA TYPE +-- https://postgr.es/m/CAKcux6mxNCGsgATwf5CGMF8g4WSupCXicCVMeKUTuWbyxHOMsQ@mail.gmail.com +CREATE TABLE idxpart (a INT, b TEXT, c INT) PARTITION BY RANGE(a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b text, c int) PARTITION BY RANGE (a)" +== 025 +-- truncate_limit: 100 +CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (MINVALUE) TO (MAXVALUE) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (minvalue) TO (maxvalue)" +== 026 +-- truncate_limit: 100 +CREATE INDEX partidx_abc_idx ON idxpart (a, b, c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX partidx_abc_idx ON idxpart USING btree (a, b, c)" +== 027 +-- truncate_limit: 100 +INSERT INTO idxpart (a, b, c) SELECT i, i, i FROM generate_series(1, 50) i +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart (a, b, c) SELECT i, i, i FROM generate_series(1, 50) i" +== 028 +-- truncate_limit: 100 +ALTER TABLE idxpart ALTER COLUMN c TYPE numeric +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ALTER COLUMN c TYPE numeric" +== 029 +-- truncate_limit: 100 +DROP TABLE idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 030 +-- truncate_limit: 100 +-- If a table without index is attached as partition to a table with +-- an index, the index is automatically created +create table idxpart (a int, b int, c text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, c text) PARTITION BY RANGE (a)" +== 031 +-- truncate_limit: 100 +create index idxparti on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxparti ON idxpart USING btree (a)" +== 032 +-- truncate_limit: 100 +create index idxparti2 on idxpart (b, c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxparti2 ON idxpart USING btree (b, c)" +== 033 +-- truncate_limit: 100 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (LIKE idxpart)" +== 034 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (10) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (10)" +== 035 +-- truncate_limit: 100 +-- Forbid ALTER TABLE when attaching or detaching an index to a partition. +create index idxpart_c on only idxpart (c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_c ON ONLY idxpart USING btree (c)" +== 036 +-- truncate_limit: 100 +create index idxpart1_c on idxpart1 (c) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_c ON idxpart1 USING btree (c)" +== 037 +-- truncate_limit: 100 +alter table idxpart_c attach partition idxpart1_c for values from (10) to (20) +-- +TABLE: name="idxpart_c" schema="" table="idxpart_c" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart_c ATTACH PARTITION idxpart1_c FOR VALUES FROM (10) TO (20)" +== 038 +-- truncate_limit: 100 +alter index idxpart_c attach partition idxpart1_c +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_c ATTACH PARTITION idxpart1_c" +== 039 +-- truncate_limit: 100 +select relname, relpartbound from pg_class + where relname in ('idxpart_c', 'idxpart1_c') + order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relpartbound FROM pg_class WHERE ... ORDER BY relname" +== 040 +-- truncate_limit: 100 +alter table idxpart_c detach partition idxpart1_c +-- +TABLE: name="idxpart_c" schema="" table="idxpart_c" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart_c DETACH PARTITION idxpart1_c" +== 041 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 042 +-- truncate_limit: 100 +-- If a partition already has an index, don't create a duplicative one +create table idxpart (a int, b int) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int) PARTITION BY RANGE (a, b)" +== 043 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0, 0) to (10, 10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0, 0) TO (10, 10)" +== 044 +-- truncate_limit: 100 +create index on idxpart1 (a, b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree (a, b)" +== 045 +-- truncate_limit: 100 +create index on idxpart (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a, b)" +== 046 +-- truncate_limit: 100 +select relname, relkind, relhassubclass, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_index ix ON indexrelid = oid LEFT JOIN pg_inherits ON ix.in..." +== 047 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 048 +-- truncate_limit: 100 +-- DROP behavior for partitioned indexes +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int) PARTITION BY RANGE (a)" +== 049 +-- truncate_limit: 100 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a)" +== 050 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0) to (10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0) TO (10)" +== 051 +-- truncate_limit: 100 +drop index idxpart1_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart1_a_idx" +== 052 +-- truncate_limit: 100 +-- no way +drop index concurrently idxpart_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY idxpart_a_idx" +== 053 +-- truncate_limit: 100 +-- unsupported +drop index idxpart_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart_a_idx" +== 054 +-- truncate_limit: 100 +-- both indexes go away +select relname, relkind from pg_class + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart%' ORDER BY relname" +== 055 +-- truncate_limit: 100 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a)" +== 056 +-- truncate_limit: 100 +drop table idxpart1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart1" +== 057 +-- truncate_limit: 100 +-- the index on partition goes away too +select relname, relkind from pg_class + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart%' ORDER BY relname" +== 058 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 059 +-- truncate_limit: 100 +-- DROP behavior with temporary partitioned indexes +create temp table idxpart_temp (a int) partition by range (a) +-- +TABLE: name="idxpart_temp" schema="" table="idxpart_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE idxpart_temp (a int) PARTITION BY RANGE (a)" +== 060 +-- truncate_limit: 100 +create index on idxpart_temp(a) +-- +TABLE: name="idxpart_temp" schema="" table="idxpart_temp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart_temp USING btree (a)" +== 061 +-- truncate_limit: 100 +create temp table idxpart1_temp partition of idxpart_temp + for values from (0) to (10) +-- +TABLE: name="idxpart1_temp" schema="" table="idxpart1_temp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE idxpart1_temp PARTITION OF idxpart_temp FOR VALUES FROM (0) TO (10)" +== 062 +-- truncate_limit: 100 +drop index idxpart1_temp_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart1_temp_a_idx" +== 063 +-- truncate_limit: 100 +-- error +-- non-concurrent drop is enforced here, so it is a valid case. +drop index concurrently idxpart_temp_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX CONCURRENTLY idxpart_temp_a_idx" +== 064 +-- truncate_limit: 100 +select relname, relkind from pg_class + where relname like 'idxpart_temp%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart_temp%' ORDER BY relname" +== 065 +-- truncate_limit: 100 +drop table idxpart_temp +-- +TABLE: name="idxpart_temp" schema="" table="idxpart_temp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart_temp" +== 066 +-- truncate_limit: 100 +-- ALTER INDEX .. ATTACH, error cases +create table idxpart (a int, b int) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int) PARTITION BY RANGE (a, b)" +== 067 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0, 0) to (10, 10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0, 0) TO (10, 10)" +== 068 +-- truncate_limit: 100 +create index idxpart_a_b_idx on only idxpart (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_a_b_idx ON ONLY idxpart USING btree (a, b)" +== 069 +-- truncate_limit: 100 +create index idxpart1_a_b_idx on idxpart1 (a, b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_a_b_idx ON idxpart1 USING btree (a, b)" +== 070 +-- truncate_limit: 100 +create index idxpart1_tst1 on idxpart1 (b, a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_tst1 ON idxpart1 USING btree (b, a)" +== 071 +-- truncate_limit: 100 +create index idxpart1_tst2 on idxpart1 using hash (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_tst2 ON idxpart1 USING hash (a)" +== 072 +-- truncate_limit: 100 +create index idxpart1_tst3 on idxpart1 (a, b) where a > 10 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_tst3 ON idxpart1 USING btree (a, b) WHERE a > 10" +== 073 +-- truncate_limit: 100 +alter index idxpart attach partition idxpart1 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart ATTACH PARTITION idxpart1" +== 074 +-- truncate_limit: 100 +alter index idxpart_a_b_idx attach partition idxpart1 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart1" +== 075 +-- truncate_limit: 100 +alter index idxpart_a_b_idx attach partition idxpart_a_b_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart_a_b_idx" +== 076 +-- truncate_limit: 100 +alter index idxpart_a_b_idx attach partition idxpart1_b_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart1_b_idx" +== 077 +-- truncate_limit: 100 +alter index idxpart_a_b_idx attach partition idxpart1_tst1 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart1_tst1" +== 078 +-- truncate_limit: 100 +alter index idxpart_a_b_idx attach partition idxpart1_tst2 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart1_tst2" +== 079 +-- truncate_limit: 100 +alter index idxpart_a_b_idx attach partition idxpart1_tst3 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart1_tst3" +== 080 +-- truncate_limit: 100 +-- OK +alter index idxpart_a_b_idx attach partition idxpart1_a_b_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart1_a_b_idx" +== 081 +-- truncate_limit: 100 +alter index idxpart_a_b_idx attach partition idxpart1_a_b_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart1_a_b_idx" +== 082 +-- truncate_limit: 100 +-- quiet + +-- reject dupe +create index idxpart1_2_a_b on idxpart1 (a, b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_2_a_b ON idxpart1 USING btree (a, b)" +== 083 +-- truncate_limit: 100 +alter index idxpart_a_b_idx attach partition idxpart1_2_a_b +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_b_idx ATTACH PARTITION idxpart1_2_a_b" +== 084 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 085 +-- truncate_limit: 100 +-- make sure everything's gone +select indexrelid::regclass, indrelid::regclass + from pg_index where indexrelid::regclass::text like 'idxpart%' +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +TRUNCATED: "SELECT indexrelid::regclass, indrelid::regclass FROM pg_index WHERE ..." +== 086 +-- truncate_limit: 100 +-- Don't auto-attach incompatible indexes +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int) PARTITION BY RANGE (a)" +== 087 +-- truncate_limit: 100 +create table idxpart1 (a int, b int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (a int, b int)" +== 088 +-- truncate_limit: 100 +create index on idxpart1 using hash (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING hash (a)" +== 089 +-- truncate_limit: 100 +create index on idxpart1 (a) where b > 1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree (a) WHERE b > 1" +== 090 +-- truncate_limit: 100 +create index on idxpart1 ((a + 0)) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree ((a + 0))" +== 091 +-- truncate_limit: 100 +create index on idxpart1 (a, a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree (a, a)" +== 092 +-- truncate_limit: 100 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a)" +== 093 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (1000)" +== 094 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 095 +-- truncate_limit: 100 +-- If CREATE INDEX ONLY, don't create indexes on partitions; and existing +-- indexes on partitions don't change parent. ALTER INDEX ATTACH can change +-- the parent after the fact. +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int) PARTITION BY RANGE (a)" +== 096 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0) to (100) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0) TO (100)" +== 097 +-- truncate_limit: 100 +create table idxpart2 partition of idxpart for values from (100) to (1000) + partition by range (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 PARTITION OF idxpart FOR VALUES FROM (100) TO (1000) PARTITION BY RANGE (a)" +== 098 +-- truncate_limit: 100 +create table idxpart21 partition of idxpart2 for values from (100) to (200) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart21 PARTITION OF idxpart2 FOR VALUES FROM (100) TO (200)" +== 099 +-- truncate_limit: 100 +create table idxpart22 partition of idxpart2 for values from (200) to (300) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart22 PARTITION OF idxpart2 FOR VALUES FROM (200) TO (300)" +== 100 +-- truncate_limit: 100 +create index on idxpart22 (a) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart22 USING btree (a)" +== 101 +-- truncate_limit: 100 +create index on only idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON ONLY idxpart2 USING btree (a)" +== 102 +-- truncate_limit: 100 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a)" +== 103 +-- truncate_limit: 100 +-- Here we expect that idxpart1 and idxpart2 have a new index, but idxpart21 +-- does not; also, idxpart22 is not attached. +select indexrelid::regclass, indrelid::regclass, inhparent::regclass + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) +where indexrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid WHERE ......" +== 104 +-- truncate_limit: 100 +alter index idxpart2_a_idx attach partition idxpart22_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart2_a_idx ATTACH PARTITION idxpart22_a_idx" +== 105 +-- truncate_limit: 100 +select indexrelid::regclass, indrelid::regclass, inhparent::regclass + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) +where indexrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid WHERE ......" +== 106 +-- truncate_limit: 100 +-- attaching idxpart22 is not enough to set idxpart22_a_idx valid ... +alter index idxpart2_a_idx attach partition idxpart22_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart2_a_idx ATTACH PARTITION idxpart22_a_idx" +== 107 +-- truncate_limit: 100 +-- ... but this one is. +create index on idxpart21 (a) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart21 USING btree (a)" +== 108 +-- truncate_limit: 100 +alter index idxpart2_a_idx attach partition idxpart21_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart2_a_idx ATTACH PARTITION idxpart21_a_idx" +== 109 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 110 +-- truncate_limit: 100 +-- When a table is attached a partition and it already has an index, a +-- duplicate index should not get created, but rather the index becomes +-- attached to the parent's index. +create table idxpart (a int, b int, c text, d bool) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, c text, d bool) PARTITION BY RANGE (a)" +== 111 +-- truncate_limit: 100 +create index idxparti on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxparti ON idxpart USING btree (a)" +== 112 +-- truncate_limit: 100 +create index idxparti2 on idxpart (b, c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxparti2 ON idxpart USING btree (b, c)" +== 113 +-- truncate_limit: 100 +create table idxpart1 (like idxpart including indexes) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (LIKE idxpart INCLUDING INDEXES)" +== 114 +-- truncate_limit: 100 +select relname, relkind, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_index ix ON indexrelid = oid LEFT JOIN pg_inherits ON ix.in..." +== 115 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (10) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (10)" +== 116 +-- truncate_limit: 100 +select relname, relkind, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_index ix ON indexrelid = oid LEFT JOIN pg_inherits ON ix.in..." +== 117 +-- truncate_limit: 100 +-- While here, also check matching when creating an index after the fact. +create index on idxpart1 ((a+b)) where d = true +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree ((a + b)) WHERE d = true" +== 118 +-- truncate_limit: 100 +select relname, relkind, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_index ix ON indexrelid = oid LEFT JOIN pg_inherits ON ix.in..." +== 119 +-- truncate_limit: 100 +create index idxparti3 on idxpart ((a+b)) where d = true +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxparti3 ON idxpart USING btree ((a + b)) WHERE d = true" +== 120 +-- truncate_limit: 100 +select relname, relkind, inhparent::regclass + from pg_class left join pg_index ix on (indexrelid = oid) + left join pg_inherits on (ix.indexrelid = inhrelid) + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "ix"="pg_index" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_index ix ON indexrelid = oid LEFT JOIN pg_inherits ON ix.in..." +== 121 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 122 +-- truncate_limit: 100 +-- Verify that attaching an invalid index does not mark the parent index valid. +-- On the other hand, attaching a valid index marks not only its direct +-- ancestor valid, but also any indirect ancestor that was only missing the one +-- that was just made valid +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int) PARTITION BY RANGE (a)" +== 123 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (1) to (1000) partition by range (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (1) TO (1000) PARTITION BY RANGE (a)" +== 124 +-- truncate_limit: 100 +create table idxpart11 partition of idxpart1 for values from (1) to (100) +-- +TABLE: name="idxpart11" schema="" table="idxpart11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart11 PARTITION OF idxpart1 FOR VALUES FROM (1) TO (100)" +== 125 +-- truncate_limit: 100 +create index on only idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON ONLY idxpart1 USING btree (a)" +== 126 +-- truncate_limit: 100 +create index on only idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON ONLY idxpart USING btree (a)" +== 127 +-- truncate_limit: 100 +-- this results in two invalid indexes: +select relname, indisvalid from pg_class join pg_index on indexrelid = oid + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class JOIN pg_index ON indexrelid = oid WHERE ... ORDER BY relname" +== 128 +-- truncate_limit: 100 +-- idxpart1_a_idx is not valid, so idxpart_a_idx should not become valid: +alter index idxpart_a_idx attach partition idxpart1_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_idx ATTACH PARTITION idxpart1_a_idx" +== 129 +-- truncate_limit: 100 +select relname, indisvalid from pg_class join pg_index on indexrelid = oid + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class JOIN pg_index ON indexrelid = oid WHERE ... ORDER BY relname" +== 130 +-- truncate_limit: 100 +-- after creating and attaching this, both idxpart1_a_idx and idxpart_a_idx +-- should become valid +create index on idxpart11 (a) +-- +TABLE: name="idxpart11" schema="" table="idxpart11" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart11 USING btree (a)" +== 131 +-- truncate_limit: 100 +alter index idxpart1_a_idx attach partition idxpart11_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart1_a_idx ATTACH PARTITION idxpart11_a_idx" +== 132 +-- truncate_limit: 100 +select relname, indisvalid from pg_class join pg_index on indexrelid = oid + where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class JOIN pg_index ON indexrelid = oid WHERE ... ORDER BY relname" +== 133 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 134 +-- truncate_limit: 100 +-- verify dependency handling during ALTER TABLE DETACH PARTITION +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int) PARTITION BY RANGE (a)" +== 135 +-- truncate_limit: 100 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (LIKE idxpart)" +== 136 +-- truncate_limit: 100 +create index on idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree (a)" +== 137 +-- truncate_limit: 100 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a)" +== 138 +-- truncate_limit: 100 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (LIKE idxpart)" +== 139 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0000) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (1000)" +== 140 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM (1000) TO (2000)" +== 141 +-- truncate_limit: 100 +create table idxpart3 partition of idxpart for values from (2000) to (3000) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart3 PARTITION OF idxpart FOR VALUES FROM (2000) TO (3000)" +== 142 +-- truncate_limit: 100 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart%' ORDER BY relname" +== 143 +-- truncate_limit: 100 +-- a) after detaching partitions, the indexes can be dropped independently +alter table idxpart detach partition idxpart1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DETACH PARTITION idxpart1" +== 144 +-- truncate_limit: 100 +alter table idxpart detach partition idxpart2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DETACH PARTITION idxpart2" +== 145 +-- truncate_limit: 100 +alter table idxpart detach partition idxpart3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DETACH PARTITION idxpart3" +== 146 +-- truncate_limit: 100 +drop index idxpart1_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart1_a_idx" +== 147 +-- truncate_limit: 100 +drop index idxpart2_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart2_a_idx" +== 148 +-- truncate_limit: 100 +drop index idxpart3_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart3_a_idx" +== 149 +-- truncate_limit: 100 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart%' ORDER BY relname" +== 150 +-- truncate_limit: 100 +drop table idxpart, idxpart1, idxpart2, idxpart3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart, idxpart1, idxpart2, idxpart3" +== 151 +-- truncate_limit: 100 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart%' ORDER BY relname" +== 152 +-- truncate_limit: 100 +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int) PARTITION BY RANGE (a)" +== 153 +-- truncate_limit: 100 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (LIKE idxpart)" +== 154 +-- truncate_limit: 100 +create index on idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree (a)" +== 155 +-- truncate_limit: 100 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a)" +== 156 +-- truncate_limit: 100 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (LIKE idxpart)" +== 157 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0000) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (1000)" +== 158 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM (1000) TO (2000)" +== 159 +-- truncate_limit: 100 +create table idxpart3 partition of idxpart for values from (2000) to (3000) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart3 PARTITION OF idxpart FOR VALUES FROM (2000) TO (3000)" +== 160 +-- truncate_limit: 100 +-- b) after detaching, dropping the index on parent does not remove the others +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart%' ORDER BY relname" +== 161 +-- truncate_limit: 100 +alter table idxpart detach partition idxpart1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DETACH PARTITION idxpart1" +== 162 +-- truncate_limit: 100 +alter table idxpart detach partition idxpart2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DETACH PARTITION idxpart2" +== 163 +-- truncate_limit: 100 +alter table idxpart detach partition idxpart3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DETACH PARTITION idxpart3" +== 164 +-- truncate_limit: 100 +drop index idxpart_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart_a_idx" +== 165 +-- truncate_limit: 100 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart%' ORDER BY relname" +== 166 +-- truncate_limit: 100 +drop table idxpart, idxpart1, idxpart2, idxpart3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart, idxpart1, idxpart2, idxpart3" +== 167 +-- truncate_limit: 100 +select relname, relkind from pg_class where relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE relname LIKE 'idxpart%' ORDER BY relname" +== 168 +-- truncate_limit: 100 +create table idxpart (a int, b int, c int) partition by range(a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, c int) PARTITION BY RANGE (a)" +== 169 +-- truncate_limit: 100 +create index on idxpart(c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (c)" +== 170 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0) to (250) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0) TO (250)" +== 171 +-- truncate_limit: 100 +create table idxpart2 partition of idxpart for values from (250) to (500) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 PARTITION OF idxpart FOR VALUES FROM (250) TO (500)" +== 172 +-- truncate_limit: 100 +alter table idxpart detach partition idxpart2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DETACH PARTITION idxpart2" +== 173 +-- truncate_limit: 100 +alter table idxpart2 drop column c +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart2 DROP c" +== 174 +-- truncate_limit: 100 +drop table idxpart, idxpart2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart, idxpart2" +== 175 +-- truncate_limit: 100 +-- Verify that expression indexes inherit correctly +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int) PARTITION BY RANGE (a)" +== 176 +-- truncate_limit: 100 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (LIKE idxpart)" +== 177 +-- truncate_limit: 100 +create index on idxpart1 ((a + b)) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree ((a + b))" +== 178 +-- truncate_limit: 100 +create index on idxpart ((a + b)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree ((a + b))" +== 179 +-- truncate_limit: 100 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (LIKE idxpart)" +== 180 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0000) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (1000)" +== 181 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM (1000) TO (2000)" +== 182 +-- truncate_limit: 100 +create table idxpart3 partition of idxpart for values from (2000) to (3000) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart3 PARTITION OF idxpart FOR VALUES FROM (2000) TO (3000)" +== 183 +-- truncate_limit: 100 +select relname as child, inhparent::regclass as parent, pg_get_indexdef as childdef + from pg_class join pg_inherits on inhrelid = oid, + lateral pg_get_indexdef(pg_class.oid) + where relkind in ('i', 'I') and relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class JOIN pg_inherits ON inhrelid = oid, LATERAL pg_get_indexdef(pg_class.oid..." +== 184 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 185 +-- truncate_limit: 100 +-- Verify behavior for collation (mis)matches +create table idxpart (a text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a text) PARTITION BY RANGE (a)" +== 186 +-- truncate_limit: 100 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (LIKE idxpart)" +== 187 +-- truncate_limit: 100 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (LIKE idxpart)" +== 188 +-- truncate_limit: 100 +create index on idxpart2 (a collate "POSIX") +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart2 USING btree (a COLLATE \"POSIX\")" +== 189 +-- truncate_limit: 100 +create index on idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart2 USING btree (a)" +== 190 +-- truncate_limit: 100 +create index on idxpart2 (a collate "C") +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart2 USING btree (a COLLATE \"C\")" +== 191 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from ('aaa') to ('bbb') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM ('aaa') TO ('bbb')" +== 192 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from ('bbb') to ('ccc') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM ('bbb') TO ('ccc')" +== 193 +-- truncate_limit: 100 +create table idxpart3 partition of idxpart for values from ('ccc') to ('ddd') +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart3 PARTITION OF idxpart FOR VALUES FROM ('ccc') TO ('ddd')" +== 194 +-- truncate_limit: 100 +create index on idxpart (a collate "C") +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a COLLATE \"C\")" +== 195 +-- truncate_limit: 100 +create table idxpart4 partition of idxpart for values from ('ddd') to ('eee') +-- +TABLE: name="idxpart4" schema="" table="idxpart4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart4 PARTITION OF idxpart FOR VALUES FROM ('ddd') TO ('eee')" +== 196 +-- truncate_limit: 100 +select relname as child, inhparent::regclass as parent, pg_get_indexdef as childdef + from pg_class left join pg_inherits on inhrelid = oid, + lateral pg_get_indexdef(pg_class.oid) + where relkind in ('i', 'I') and relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_inherits ON inhrelid = oid, LATERAL pg_get_indexdef(pg_clas..." +== 197 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 198 +-- truncate_limit: 100 +-- Verify behavior for opclass (mis)matches +create table idxpart (a text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a text) PARTITION BY RANGE (a)" +== 199 +-- truncate_limit: 100 +create table idxpart1 (like idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (LIKE idxpart)" +== 200 +-- truncate_limit: 100 +create table idxpart2 (like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (LIKE idxpart)" +== 201 +-- truncate_limit: 100 +create index on idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart2 USING btree (a)" +== 202 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from ('aaa') to ('bbb') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM ('aaa') TO ('bbb')" +== 203 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from ('bbb') to ('ccc') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM ('bbb') TO ('ccc')" +== 204 +-- truncate_limit: 100 +create table idxpart3 partition of idxpart for values from ('ccc') to ('ddd') +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart3 PARTITION OF idxpart FOR VALUES FROM ('ccc') TO ('ddd')" +== 205 +-- truncate_limit: 100 +create index on idxpart (a text_pattern_ops) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a text_pattern_ops)" +== 206 +-- truncate_limit: 100 +create table idxpart4 partition of idxpart for values from ('ddd') to ('eee') +-- +TABLE: name="idxpart4" schema="" table="idxpart4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart4 PARTITION OF idxpart FOR VALUES FROM ('ddd') TO ('eee')" +== 207 +-- truncate_limit: 100 +-- must *not* have attached the index we created on idxpart2 +select relname as child, inhparent::regclass as parent, pg_get_indexdef as childdef + from pg_class left join pg_inherits on inhrelid = oid, + lateral pg_get_indexdef(pg_class.oid) + where relkind in ('i', 'I') and relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_inherits ON inhrelid = oid, LATERAL pg_get_indexdef(pg_clas..." +== 208 +-- truncate_limit: 100 +drop index idxpart_a_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart_a_idx" +== 209 +-- truncate_limit: 100 +create index on only idxpart (a text_pattern_ops) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON ONLY idxpart USING btree (a text_pattern_ops)" +== 210 +-- truncate_limit: 100 +-- must reject +alter index idxpart_a_idx attach partition idxpart2_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_a_idx ATTACH PARTITION idxpart2_a_idx" +== 211 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 212 +-- truncate_limit: 100 +-- Verify that attaching indexes maps attribute numbers correctly +create table idxpart (col1 int, a int, col2 int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (col1 int, a int, col2 int, b int) PARTITION BY RANGE (a)" +== 213 +-- truncate_limit: 100 +create table idxpart1 (b int, col1 int, col2 int, col3 int, a int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (b int, col1 int, col2 int, col3 int, a int)" +== 214 +-- truncate_limit: 100 +alter table idxpart drop column col1, drop column col2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DROP col1, DROP col2" +== 215 +-- truncate_limit: 100 +alter table idxpart1 drop column col1, drop column col2, drop column col3 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 DROP col1, DROP col2, DROP col3" +== 216 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (1000)" +== 217 +-- truncate_limit: 100 +create index idxpart_1_idx on only idxpart (b, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_1_idx ON ONLY idxpart USING btree (b, a)" +== 218 +-- truncate_limit: 100 +create index idxpart1_1_idx on idxpart1 (b, a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_1_idx ON idxpart1 USING btree (b, a)" +== 219 +-- truncate_limit: 100 +create index idxpart1_1b_idx on idxpart1 (b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_1b_idx ON idxpart1 USING btree (b)" +== 220 +-- truncate_limit: 100 +-- test expressions and partial-index predicate, too +create index idxpart_2_idx on only idxpart ((b + a)) where a > 1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_2_idx ON ONLY idxpart USING btree ((b + a)) WHERE a > 1" +== 221 +-- truncate_limit: 100 +create index idxpart1_2_idx on idxpart1 ((b + a)) where a > 1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_2_idx ON idxpart1 USING btree ((b + a)) WHERE a > 1" +== 222 +-- truncate_limit: 100 +create index idxpart1_2b_idx on idxpart1 ((a + b)) where a > 1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_2b_idx ON idxpart1 USING btree ((a + b)) WHERE a > 1" +== 223 +-- truncate_limit: 100 +create index idxpart1_2c_idx on idxpart1 ((b + a)) where b > 1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart1_2c_idx ON idxpart1 USING btree ((b + a)) WHERE b > 1" +== 224 +-- truncate_limit: 100 +alter index idxpart_1_idx attach partition idxpart1_1b_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_1_idx ATTACH PARTITION idxpart1_1b_idx" +== 225 +-- truncate_limit: 100 +-- fail +alter index idxpart_1_idx attach partition idxpart1_1_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_1_idx ATTACH PARTITION idxpart1_1_idx" +== 226 +-- truncate_limit: 100 +alter index idxpart_2_idx attach partition idxpart1_2b_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_2_idx ATTACH PARTITION idxpart1_2b_idx" +== 227 +-- truncate_limit: 100 +-- fail +alter index idxpart_2_idx attach partition idxpart1_2c_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_2_idx ATTACH PARTITION idxpart1_2c_idx" +== 228 +-- truncate_limit: 100 +-- fail +alter index idxpart_2_idx attach partition idxpart1_2_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_2_idx ATTACH PARTITION idxpart1_2_idx" +== 229 +-- truncate_limit: 100 +-- ok +select relname as child, inhparent::regclass as parent, pg_get_indexdef as childdef + from pg_class left join pg_inherits on inhrelid = oid, + lateral pg_get_indexdef(pg_class.oid) + where relkind in ('i', 'I') and relname like 'idxpart%' order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class LEFT JOIN pg_inherits ON inhrelid = oid, LATERAL pg_get_indexdef(pg_clas..." +== 230 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 231 +-- truncate_limit: 100 +-- Make sure the partition columns are mapped correctly +create table idxpart (a int, b int, c text) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, c text) PARTITION BY RANGE (a)" +== 232 +-- truncate_limit: 100 +create index idxparti on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxparti ON idxpart USING btree (a)" +== 233 +-- truncate_limit: 100 +create index idxparti2 on idxpart (c, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxparti2 ON idxpart USING btree (c, b)" +== 234 +-- truncate_limit: 100 +create table idxpart1 (c text, a int, b int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (c text, a int, b int)" +== 235 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (10) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (10)" +== 236 +-- truncate_limit: 100 +create table idxpart2 (c text, a int, b int) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (c text, a int, b int)" +== 237 +-- truncate_limit: 100 +create index on idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart2 USING btree (a)" +== 238 +-- truncate_limit: 100 +create index on idxpart2 (c, b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart2 USING btree (c, b)" +== 239 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from (10) to (20) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM (10) TO (20)" +== 240 +-- truncate_limit: 100 +select c.relname, pg_get_indexdef(indexrelid) + from pg_class c join pg_index i on c.oid = i.indexrelid + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid WHERE ... ORDER BY indexrelid:..." +== 241 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 242 +-- truncate_limit: 100 +-- Verify that columns are mapped correctly in expression indexes +create table idxpart (col1 int, col2 int, a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (col1 int, col2 int, a int, b int) PARTITION BY RANGE (a)" +== 243 +-- truncate_limit: 100 +create table idxpart1 (col2 int, b int, col1 int, a int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (col2 int, b int, col1 int, a int)" +== 244 +-- truncate_limit: 100 +create table idxpart2 (col1 int, col2 int, b int, a int) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (col1 int, col2 int, b int, a int)" +== 245 +-- truncate_limit: 100 +alter table idxpart drop column col1, drop column col2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DROP col1, DROP col2" +== 246 +-- truncate_limit: 100 +alter table idxpart1 drop column col1, drop column col2 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 DROP col1, DROP col2" +== 247 +-- truncate_limit: 100 +alter table idxpart2 drop column col1, drop column col2 +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart2 DROP col1, DROP col2" +== 248 +-- truncate_limit: 100 +create index on idxpart2 (abs(b)) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart2 USING btree (abs(b))" +== 249 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from (0) to (1) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM (0) TO (1)" +== 250 +-- truncate_limit: 100 +create index on idxpart (abs(b)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (abs(b))" +== 251 +-- truncate_limit: 100 +create index on idxpart ((b + 1)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree ((b + 1))" +== 252 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (1) to (2) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (1) TO (2)" +== 253 +-- truncate_limit: 100 +select c.relname, pg_get_indexdef(indexrelid) + from pg_class c join pg_index i on c.oid = i.indexrelid + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid WHERE ... ORDER BY indexrelid:..." +== 254 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 255 +-- truncate_limit: 100 +-- Verify that columns are mapped correctly for WHERE in a partial index +create table idxpart (col1 int, a int, col3 int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (col1 int, a int, col3 int, b int) PARTITION BY RANGE (a)" +== 256 +-- truncate_limit: 100 +alter table idxpart drop column col1, drop column col3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DROP col1, DROP col3" +== 257 +-- truncate_limit: 100 +create table idxpart1 (col1 int, col2 int, col3 int, col4 int, b int, a int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (col1 int, col2 int, col3 int, col4 int, b int, a int)" +== 258 +-- truncate_limit: 100 +alter table idxpart1 drop column col1, drop column col2, drop column col3, drop column col4 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 DROP col1, DROP col2, DROP col3, DROP col4" +== 259 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (1000)" +== 260 +-- truncate_limit: 100 +create table idxpart2 (col1 int, col2 int, b int, a int) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (col1 int, col2 int, b int, a int)" +== 261 +-- truncate_limit: 100 +create index on idxpart2 (a) where b > 1000 +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart2 USING btree (a) WHERE b > 1000" +== 262 +-- truncate_limit: 100 +alter table idxpart2 drop column col1, drop column col2 +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart2 DROP col1, DROP col2" +== 263 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM (1000) TO (2000)" +== 264 +-- truncate_limit: 100 +create index on idxpart (a) where b > 1000 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a) WHERE b > 1000" +== 265 +-- truncate_limit: 100 +select c.relname, pg_get_indexdef(indexrelid) + from pg_class c join pg_index i on c.oid = i.indexrelid + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid WHERE ... ORDER BY indexrelid:..." +== 266 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 267 +-- truncate_limit: 100 +-- Column number mapping: dropped columns in the partition +create table idxpart1 (drop_1 int, drop_2 int, col_keep int, drop_3 int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (drop_1 int, drop_2 int, col_keep int, drop_3 int)" +== 268 +-- truncate_limit: 100 +alter table idxpart1 drop column drop_1 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 DROP drop_1" +== 269 +-- truncate_limit: 100 +alter table idxpart1 drop column drop_2 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 DROP drop_2" +== 270 +-- truncate_limit: 100 +alter table idxpart1 drop column drop_3 +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 DROP drop_3" +== 271 +-- truncate_limit: 100 +create index on idxpart1 (col_keep) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree (col_keep)" +== 272 +-- truncate_limit: 100 +create table idxpart (col_keep int) partition by range (col_keep) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (col_keep int) PARTITION BY RANGE (col_keep)" +== 273 +-- truncate_limit: 100 +create index on idxpart (col_keep) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (col_keep)" +== 274 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (1000)" +== 275 +-- truncate_limit: 100 +select attrelid::regclass, attname, attnum from pg_attribute + where attrelid::regclass::text like 'idxpart%' and attnum > 0 + order by attrelid::regclass, attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE ... ORDER BY attrelid::regclass, attnum" +== 276 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 277 +-- truncate_limit: 100 +-- Column number mapping: dropped columns in the parent table +create table idxpart(drop_1 int, drop_2 int, col_keep int, drop_3 int) partition by range (col_keep) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (drop_1 int, drop_2 int, col_keep int, drop_3 int) PARTITION BY RANGE (col_k..." +== 278 +-- truncate_limit: 100 +alter table idxpart drop column drop_1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DROP drop_1" +== 279 +-- truncate_limit: 100 +alter table idxpart drop column drop_2 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DROP drop_2" +== 280 +-- truncate_limit: 100 +alter table idxpart drop column drop_3 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DROP drop_3" +== 281 +-- truncate_limit: 100 +create table idxpart1 (col_keep int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (col_keep int)" +== 282 +-- truncate_limit: 100 +create index on idxpart1 (col_keep) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart1 USING btree (col_keep)" +== 283 +-- truncate_limit: 100 +create index on idxpart (col_keep) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (col_keep)" +== 284 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (1000)" +== 285 +-- truncate_limit: 100 +select attrelid::regclass, attname, attnum from pg_attribute + where attrelid::regclass::text like 'idxpart%' and attnum > 0 + order by attrelid::regclass, attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE ... ORDER BY attrelid::regclass, attnum" +== 286 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 287 +-- truncate_limit: 100 +|-- +-- Constraint-related indexes +|-- + +-- Verify that it works to add primary key / unique to partitioned tables +create table idxpart (a int primary key, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int PRIMARY KEY, b int) PARTITION BY RANGE (a)" +== 288 +-- truncate_limit: 100 +-- multiple primary key on child should fail +create table failpart partition of idxpart (b primary key) for values from (0) to (100) +-- +TABLE: name="failpart" schema="" table="failpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE failpart PARTITION OF idxpart (b PRIMARY KEY) FOR VALUES FROM (0) TO (100)" +== 289 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 290 +-- truncate_limit: 100 +-- primary key on child is okay if there's no PK in the parent, though +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int) PARTITION BY RANGE (a)" +== 291 +-- truncate_limit: 100 +create table idxpart1pk partition of idxpart (a primary key) for values from (0) to (100) +-- +TABLE: name="idxpart1pk" schema="" table="idxpart1pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1pk PARTITION OF idxpart (a PRIMARY KEY) FOR VALUES FROM (0) TO (100)" +== 292 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 293 +-- truncate_limit: 100 +-- Failing to use the full partition key is not allowed +create table idxpart (a int unique, b int) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int UNIQUE, b int) PARTITION BY RANGE (a, b)" +== 294 +-- truncate_limit: 100 +create table idxpart (a int, b int unique) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int UNIQUE) PARTITION BY RANGE (a, b)" +== 295 +-- truncate_limit: 100 +create table idxpart (a int primary key, b int) partition by range (b, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int PRIMARY KEY, b int) PARTITION BY RANGE (b, a)" +== 296 +-- truncate_limit: 100 +create table idxpart (a int, b int primary key) partition by range (b, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int PRIMARY KEY) PARTITION BY RANGE (b, a)" +== 297 +-- truncate_limit: 100 +-- OK if you use them in some other order +create table idxpart (a int, b int, c text, primary key (a, b, c)) partition by range (b, c, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, c text, PRIMARY KEY (a, b, c)) PARTITION BY RANGE (b, c, a)" +== 298 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 299 +-- truncate_limit: 100 +-- OK to add an exclusion constraint if partitioning by its equal column +create table idxpart (a int4range, exclude USING GIST (a with = )) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, EXCLUDE USING gist (a WITH =)) PARTITION BY RANGE (a)" +== 300 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 301 +-- truncate_limit: 100 +-- OK more than one equal column +create table idxpart (a int4range, b int4range, exclude USING GIST (a with =, b with =)) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range, EXCLUDE USING gist (a WITH =, b WITH =)) PARTITIO..." +== 302 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 303 +-- truncate_limit: 100 +-- OK with more than one equal column: constraint is a proper superset of partition key +create table idxpart (a int4range, b int4range, exclude USING GIST (a with =, b with =)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range, EXCLUDE USING gist (a WITH =, b WITH =)) PARTITIO..." +== 304 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 305 +-- truncate_limit: 100 +-- Not OK more than one equal column: partition keys are a proper superset of constraint +create table idxpart (a int4range, b int4range, exclude USING GIST (a with = )) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range, EXCLUDE USING gist (a WITH =)) PARTITION BY RANGE..." +== 306 +-- truncate_limit: 100 +-- Not OK with just -|- +create table idxpart (a int4range, exclude USING GIST (a with -|- )) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, EXCLUDE USING gist (a WITH -|-)) PARTITION BY RANGE (a)" +== 307 +-- truncate_limit: 100 +-- OK with equals and &&, and equals is the partition key +create table idxpart (a int4range, b int4range, exclude USING GIST (a with =, b with &&)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range, EXCLUDE USING gist (a WITH =, b WITH &&)) PARTITI..." +== 308 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 309 +-- truncate_limit: 100 +-- Not OK with equals and &&, and equals is not the partition key +create table idxpart (a int4range, b int4range, c int4range, exclude USING GIST (b with =, c with &&)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range, c int4range, EXCLUDE USING gist (b WITH =, c WITH..." +== 310 +-- truncate_limit: 100 +-- OK more than one equal column and a && column +create table idxpart (a int4range, b int4range, c int4range, exclude USING GIST (a with =, b with =, c with &&)) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range, c int4range, EXCLUDE USING gist (a WITH =, b WITH..." +== 311 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 312 +-- truncate_limit: 100 +-- no expressions in partition key for PK/UNIQUE +create table idxpart (a int primary key, b int) partition by range ((b + a)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int PRIMARY KEY, b int) PARTITION BY RANGE ((b + a))" +== 313 +-- truncate_limit: 100 +create table idxpart (a int unique, b int) partition by range ((b + a)) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int UNIQUE, b int) PARTITION BY RANGE ((b + a))" +== 314 +-- truncate_limit: 100 +-- use ALTER TABLE to add a primary key +create table idxpart (a int, b int, c text) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, c text) PARTITION BY RANGE (a, b)" +== 315 +-- truncate_limit: 100 +alter table idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD PRIMARY KEY (a)" +== 316 +-- truncate_limit: 100 +-- not an incomplete one though +alter table idxpart add primary key (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD PRIMARY KEY (a, b)" +== 317 +-- truncate_limit: 100 +-- this works +create table idxpart1 partition of idxpart for values from (0, 0) to (1000, 1000) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0, 0) TO (1000, 1000)" +== 318 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 319 +-- truncate_limit: 100 +-- use ALTER TABLE to add a unique constraint +create table idxpart (a int, b int) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int) PARTITION BY RANGE (a, b)" +== 320 +-- truncate_limit: 100 +alter table idxpart add unique (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD UNIQUE (a)" +== 321 +-- truncate_limit: 100 +-- not an incomplete one though +alter table idxpart add unique (b, a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD UNIQUE (b, a)" +== 322 +-- truncate_limit: 100 +-- this works +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 323 +-- truncate_limit: 100 +-- Exclusion constraints can be added if partitioning by their equal column +create table idxpart (a int4range, b int4range) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range) PARTITION BY RANGE (a)" +== 324 +-- truncate_limit: 100 +alter table idxpart add exclude USING GIST (a with =) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD EXCLUDE USING gist (a WITH =)" +== 325 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 326 +-- truncate_limit: 100 +-- OK more than one equal column +create table idxpart (a int4range, b int4range) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range) PARTITION BY RANGE (a, b)" +== 327 +-- truncate_limit: 100 +alter table idxpart add exclude USING GIST (a with =, b with =) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD EXCLUDE USING gist (a WITH =, b WITH =)" +== 328 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 329 +-- truncate_limit: 100 +-- OK with more than one equal column: constraint is a proper superset of partition key +create table idxpart (a int4range, b int4range) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range) PARTITION BY RANGE (a)" +== 330 +-- truncate_limit: 100 +alter table idxpart add exclude USING GIST (a with =, b with =) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD EXCLUDE USING gist (a WITH =, b WITH =)" +== 331 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 332 +-- truncate_limit: 100 +-- Not OK more than one equal column: partition keys are a proper superset of constraint +create table idxpart (a int4range, b int4range) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range) PARTITION BY RANGE (a, b)" +== 333 +-- truncate_limit: 100 +alter table idxpart add exclude USING GIST (a with =) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD EXCLUDE USING gist (a WITH =)" +== 334 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 335 +-- truncate_limit: 100 +-- Not OK with just -|- +create table idxpart (a int4range, b int4range) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range) PARTITION BY RANGE (a, b)" +== 336 +-- truncate_limit: 100 +alter table idxpart add exclude USING GIST (a with -|-) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD EXCLUDE USING gist (a WITH -|-)" +== 337 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 338 +-- truncate_limit: 100 +-- OK with equals and &&, and equals is the partition key +create table idxpart (a int4range, b int4range) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range) PARTITION BY RANGE (a)" +== 339 +-- truncate_limit: 100 +alter table idxpart add exclude USING GIST (a with =, b with &&) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD EXCLUDE USING gist (a WITH =, b WITH &&)" +== 340 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 341 +-- truncate_limit: 100 +-- Not OK with equals and &&, and equals is not the partition key +create table idxpart (a int4range, b int4range, c int4range) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range, c int4range) PARTITION BY RANGE (a)" +== 342 +-- truncate_limit: 100 +alter table idxpart add exclude USING GIST (b with =, c with &&) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD EXCLUDE USING gist (b WITH =, c WITH &&)" +== 343 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 344 +-- truncate_limit: 100 +-- OK more than one equal column and a && column +create table idxpart (a int4range, b int4range, c int4range) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int4range, b int4range, c int4range) PARTITION BY RANGE (a, b)" +== 345 +-- truncate_limit: 100 +alter table idxpart add exclude USING GIST (a with =, b with =, c with &&) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD EXCLUDE USING gist (a WITH =, b WITH =, c WITH &&)" +== 346 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 347 +-- truncate_limit: 100 +-- When (sub)partitions are created, they also contain the constraint +create table idxpart (a int, b int, primary key (a, b)) partition by range (a, b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, PRIMARY KEY (a, b)) PARTITION BY RANGE (a, b)" +== 348 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (1, 1) to (10, 10) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (1, 1) TO (10, 10)" +== 349 +-- truncate_limit: 100 +create table idxpart2 partition of idxpart for values from (10, 10) to (20, 20) + partition by range (b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 PARTITION OF idxpart FOR VALUES FROM (10, 10) TO (20, 20) PARTITION BY RANG..." +== 350 +-- truncate_limit: 100 +create table idxpart21 partition of idxpart2 for values from (10) to (15) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart21 PARTITION OF idxpart2 FOR VALUES FROM (10) TO (15)" +== 351 +-- truncate_limit: 100 +create table idxpart22 partition of idxpart2 for values from (15) to (20) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart22 PARTITION OF idxpart2 FOR VALUES FROM (15) TO (20)" +== 352 +-- truncate_limit: 100 +create table idxpart3 (b int not null, a int not null) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart3 (b int NOT NULL, a int NOT NULL)" +== 353 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart3 for values from (20, 20) to (30, 30) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart3 FOR VALUES FROM (20, 20) TO (30, 30)" +== 354 +-- truncate_limit: 100 +select conname, contype, conrelid::regclass, conindid::regclass, conkey + from pg_constraint where conrelid::regclass::text like 'idxpart%' + order by conrelid::regclass::text, conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE ... ORDER BY conrelid::regclass::text, conname" +== 355 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 356 +-- truncate_limit: 100 +-- Verify that multi-layer partitioning honors the requirement that all +-- columns in the partition key must appear in primary/unique key +create table idxpart (a int, b int, primary key (a)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, PRIMARY KEY (a)) PARTITION BY RANGE (a)" +== 357 +-- truncate_limit: 100 +create table idxpart2 partition of idxpart +for values from (0) to (1000) partition by range (b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 PARTITION OF idxpart FOR VALUES FROM (0) TO (1000) PARTITION BY RANGE (b)" +== 358 +-- truncate_limit: 100 +-- fail +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 359 +-- truncate_limit: 100 +-- Ditto for the ATTACH PARTITION case +create table idxpart (a int unique, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int UNIQUE, b int) PARTITION BY RANGE (a)" +== 360 +-- truncate_limit: 100 +create table idxpart1 (a int not null, b int, unique (a, b)) + partition by range (a, b) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (a int NOT NULL, b int, UNIQUE (a, b)) PARTITION BY RANGE (a, b)" +== 361 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (1) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (1) TO (1000)" +== 362 +-- truncate_limit: 100 +DROP TABLE idxpart, idxpart1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart, idxpart1" +== 363 +-- truncate_limit: 100 +-- Multi-layer partitioning works correctly in this case: +create table idxpart (a int, b int, primary key (a, b)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, PRIMARY KEY (a, b)) PARTITION BY RANGE (a)" +== 364 +-- truncate_limit: 100 +create table idxpart2 partition of idxpart for values from (0) to (1000) partition by range (b) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 PARTITION OF idxpart FOR VALUES FROM (0) TO (1000) PARTITION BY RANGE (b)" +== 365 +-- truncate_limit: 100 +create table idxpart21 partition of idxpart2 for values from (0) to (1000) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart21 PARTITION OF idxpart2 FOR VALUES FROM (0) TO (1000)" +== 366 +-- truncate_limit: 100 +select conname, contype, conrelid::regclass, conindid::regclass, conkey + from pg_constraint where conrelid::regclass::text like 'idxpart%' + order by conname +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conrelid::regclass::text LIKE 'idxpart%' ORDER BY conname" +== 367 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 368 +-- truncate_limit: 100 +-- If a partitioned table has a unique/PK constraint, then it's not possible +-- to drop the corresponding constraint in the children; nor it's possible +-- to drop the indexes individually. Dropping the constraint in the parent +-- gets rid of the lot. +create table idxpart (i int) partition by hash (i) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (i int) PARTITION BY HASH (i)" +== 369 +-- truncate_limit: 100 +create table idxpart0 partition of idxpart (i) for values with (modulus 2, remainder 0) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart0 PARTITION OF idxpart (i) FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 370 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart (i) for values with (modulus 2, remainder 1) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart (i) FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 371 +-- truncate_limit: 100 +alter table idxpart0 add primary key(i) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart0 ADD PRIMARY KEY (i)" +== 372 +-- truncate_limit: 100 +alter table idxpart add primary key(i) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD PRIMARY KEY (i)" +== 373 +-- truncate_limit: 100 +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid LEFT JOIN..." +== 374 +-- truncate_limit: 100 +drop index idxpart0_pkey +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart0_pkey" +== 375 +-- truncate_limit: 100 +-- fail +drop index idxpart1_pkey +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart1_pkey" +== 376 +-- truncate_limit: 100 +-- fail +alter table idxpart0 drop constraint idxpart0_pkey +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart0 DROP CONSTRAINT idxpart0_pkey" +== 377 +-- truncate_limit: 100 +-- fail +alter table idxpart1 drop constraint idxpart1_pkey +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 DROP CONSTRAINT idxpart1_pkey" +== 378 +-- truncate_limit: 100 +-- fail +alter table idxpart drop constraint idxpart_pkey +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart DROP CONSTRAINT idxpart_pkey" +== 379 +-- truncate_limit: 100 +-- ok +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid LEFT JOIN..." +== 380 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 381 +-- truncate_limit: 100 +-- If the partition to be attached already has a primary key, fail if +-- it doesn't match the parent's PK. +CREATE TABLE idxpart (c1 INT PRIMARY KEY, c2 INT, c3 VARCHAR(10)) PARTITION BY RANGE(c1) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (c1 int PRIMARY KEY, c2 int, c3 varchar(10)) PARTITION BY RANGE (c1)" +== 382 +-- truncate_limit: 100 +CREATE TABLE idxpart1 (LIKE idxpart) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (LIKE idxpart)" +== 383 +-- truncate_limit: 100 +ALTER TABLE idxpart1 ADD PRIMARY KEY (c1, c2) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 ADD PRIMARY KEY (c1, c2)" +== 384 +-- truncate_limit: 100 +ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (100) TO (200) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (100) TO (200)" +== 385 +-- truncate_limit: 100 +DROP TABLE idxpart, idxpart1 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart, idxpart1" +== 386 +-- truncate_limit: 100 +-- Ditto if there is some distance between the PKs (subpartitioning) +create table idxpart (a int, b int, primary key (a)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int, PRIMARY KEY (a)) PARTITION BY RANGE (a)" +== 387 +-- truncate_limit: 100 +create table idxpart1 (a int not null, b int) partition by range (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (a int NOT NULL, b int) PARTITION BY RANGE (a)" +== 388 +-- truncate_limit: 100 +create table idxpart11 (a int not null, b int primary key) +-- +TABLE: name="idxpart11" schema="" table="idxpart11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart11 (a int NOT NULL, b int PRIMARY KEY)" +== 389 +-- truncate_limit: 100 +alter table idxpart1 attach partition idxpart11 for values from (0) to (1000) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart1 ATTACH PARTITION idxpart11 FOR VALUES FROM (0) TO (1000)" +== 390 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (0) to (10000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (0) TO (10000)" +== 391 +-- truncate_limit: 100 +drop table idxpart, idxpart1, idxpart11 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +TABLE: name="idxpart11" schema="" table="idxpart11" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart, idxpart1, idxpart11" +== 392 +-- truncate_limit: 100 +-- If a partitioned table has a constraint whose index is not valid, +-- attaching a missing partition makes it valid. +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int) PARTITION BY RANGE (a)" +== 393 +-- truncate_limit: 100 +create table idxpart0 (like idxpart) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart0 (LIKE idxpart)" +== 394 +-- truncate_limit: 100 +alter table idxpart0 add primary key (a) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart0 ADD PRIMARY KEY (a)" +== 395 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart0 for values from (0) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart0 FOR VALUES FROM (0) TO (1000)" +== 396 +-- truncate_limit: 100 +alter table only idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY idxpart ADD PRIMARY KEY (a)" +== 397 +-- truncate_limit: 100 +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid LEFT JOIN..." +== 398 +-- truncate_limit: 100 +alter index idxpart_pkey attach partition idxpart0_pkey +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_pkey ATTACH PARTITION idxpart0_pkey" +== 399 +-- truncate_limit: 100 +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid LEFT JOIN..." +== 400 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 401 +-- truncate_limit: 100 +-- Related to the above scenario: ADD PRIMARY KEY on the parent mustn't +-- automatically propagate NOT NULL to child columns. +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int) PARTITION BY RANGE (a)" +== 402 +-- truncate_limit: 100 +create table idxpart0 (like idxpart) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart0 (LIKE idxpart)" +== 403 +-- truncate_limit: 100 +alter table idxpart0 add unique (a) +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart0 ADD UNIQUE (a)" +== 404 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart0 default +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart0 DEFAULT" +== 405 +-- truncate_limit: 100 +alter table only idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY idxpart ADD PRIMARY KEY (a)" +== 406 +-- truncate_limit: 100 +-- fail, no not-null constraint +alter table idxpart0 alter column a set not null +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart0 ALTER COLUMN a SET NOT NULL" +== 407 +-- truncate_limit: 100 +alter table only idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY idxpart ADD PRIMARY KEY (a)" +== 408 +-- truncate_limit: 100 +-- now it works +alter index idxpart_pkey attach partition idxpart0_a_key +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_pkey ATTACH PARTITION idxpart0_a_key" +== 409 +-- truncate_limit: 100 +alter table idxpart0 alter column a drop not null +-- +TABLE: name="idxpart0" schema="" table="idxpart0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart0 ALTER COLUMN a DROP NOT NULL" +== 410 +-- truncate_limit: 100 +-- fail, pkey needs it +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 411 +-- truncate_limit: 100 +-- if a partition has a unique index without a constraint, does not attach +-- automatically; creates a new index instead. +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int) PARTITION BY RANGE (a)" +== 412 +-- truncate_limit: 100 +create table idxpart1 (a int not null, b int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (a int NOT NULL, b int)" +== 413 +-- truncate_limit: 100 +create unique index on idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON idxpart1 USING btree (a)" +== 414 +-- truncate_limit: 100 +alter table idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ADD PRIMARY KEY (a)" +== 415 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (1) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (1) TO (1000)" +== 416 +-- truncate_limit: 100 +select indrelid::regclass, indexrelid::regclass, inhparent::regclass, indisvalid, + conname, conislocal, coninhcount, connoinherit, convalidated + from pg_index idx left join pg_inherits inh on (idx.indexrelid = inh.inhrelid) + left join pg_constraint con on (idx.indexrelid = con.conindid) + where indrelid::regclass::text like 'idxpart%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "con"="pg_constraint" +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid LEFT JOIN..." +== 417 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 418 +-- truncate_limit: 100 +-- Can't attach an index without a corresponding constraint +create table idxpart (a int, b int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b int) PARTITION BY RANGE (a)" +== 419 +-- truncate_limit: 100 +create table idxpart1 (a int not null, b int) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 (a int NOT NULL, b int)" +== 420 +-- truncate_limit: 100 +create unique index on idxpart1 (a) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON idxpart1 USING btree (a)" +== 421 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart1 for values from (1) to (1000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart1 FOR VALUES FROM (1) TO (1000)" +== 422 +-- truncate_limit: 100 +alter table only idxpart add primary key (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY idxpart ADD PRIMARY KEY (a)" +== 423 +-- truncate_limit: 100 +alter index idxpart_pkey attach partition idxpart1_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart_pkey ATTACH PARTITION idxpart1_a_idx" +== 424 +-- truncate_limit: 100 +-- fail +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 425 +-- truncate_limit: 100 +-- Test that unique constraints are working +create table idxpart (a int, b text, primary key (a, b)) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b text, PRIMARY KEY (a, b)) PARTITION BY RANGE (a)" +== 426 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0) to (100000) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0) TO (100000)" +== 427 +-- truncate_limit: 100 +create table idxpart2 (c int, like idxpart) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 (c int, LIKE idxpart)" +== 428 +-- truncate_limit: 100 +insert into idxpart2 (c, a, b) values (42, 572814, 'inserted first') +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart2 (c, a, b) VALUES (42, 572814, 'inserted first')" +== 429 +-- truncate_limit: 100 +alter table idxpart2 drop column c +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart2 DROP c" +== 430 +-- truncate_limit: 100 +create unique index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON idxpart USING btree (a)" +== 431 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart2 for values from (100000) to (1000000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart2 FOR VALUES FROM (100000) TO (1000000)" +== 432 +-- truncate_limit: 100 +insert into idxpart values (0, 'zero'), (42, 'life'), (2^16, 'sixteen') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart VALUES (0, 'zero'), (42, 'life'), (2 ^ 16, 'sixteen')" +== 433 +-- truncate_limit: 100 +insert into idxpart select 2^g, format('two to power of %s', g) from generate_series(15, 17) g +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart SELECT 2 ^ g, format('two to power of %s', g) FROM generate_series(15, 17) g" +== 434 +-- truncate_limit: 100 +insert into idxpart values (16, 'sixteen') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart VALUES (16, 'sixteen')" +== 435 +-- truncate_limit: 100 +insert into idxpart (b, a) values ('one', 142857), ('two', 285714) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart (b, a) VALUES ('one', 142857), ('two', 285714)" +== 436 +-- truncate_limit: 100 +insert into idxpart select a * 2, b || b from idxpart where a between 2^16 and 2^19 +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart SELECT a * 2, b || b FROM idxpart WHERE a BETWEEN 2 ^ 16 AND 2 ^ 19" +== 437 +-- truncate_limit: 100 +insert into idxpart values (572814, 'five') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart VALUES (572814, 'five')" +== 438 +-- truncate_limit: 100 +insert into idxpart values (857142, 'six') +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO idxpart VALUES (857142, 'six')" +== 439 +-- truncate_limit: 100 +select tableoid::regclass, * from idxpart order by a +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM idxpart ORDER BY a" +== 440 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 441 +-- truncate_limit: 100 +-- Test some other non-btree index types +create table idxpart (a int, b text, c int[]) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int, b text, c int[]) PARTITION BY RANGE (a)" +== 442 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0) to (100000) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0) TO (100000)" +== 443 +-- truncate_limit: 100 +set enable_seqscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 444 +-- truncate_limit: 100 +create index idxpart_brin on idxpart using brin(b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_brin ON idxpart USING brin (b)" +== 445 +-- truncate_limit: 100 +explain (costs off) select * from idxpart where b = 'abcd' +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM idxpart WHERE b = 'abcd'" +== 446 +-- truncate_limit: 100 +drop index idxpart_brin +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart_brin" +== 447 +-- truncate_limit: 100 +create index idxpart_spgist on idxpart using spgist(b) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_spgist ON idxpart USING spgist (b)" +== 448 +-- truncate_limit: 100 +explain (costs off) select * from idxpart where b = 'abcd' +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM idxpart WHERE b = 'abcd'" +== 449 +-- truncate_limit: 100 +drop index idxpart_spgist +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart_spgist" +== 450 +-- truncate_limit: 100 +create index idxpart_gin on idxpart using gin(c) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX idxpart_gin ON idxpart USING gin (c)" +== 451 +-- truncate_limit: 100 +explain (costs off) select * from idxpart where c @> array[42] +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=Select +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM idxpart WHERE c @> ARRAY[42]" +== 452 +-- truncate_limit: 100 +drop index idxpart_gin +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX idxpart_gin" +== 453 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 454 +-- truncate_limit: 100 +drop table idxpart +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE idxpart" +== 455 +-- truncate_limit: 100 +-- intentionally leave some objects around +create table idxpart (a int) partition by range (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart (a int) PARTITION BY RANGE (a)" +== 456 +-- truncate_limit: 100 +create table idxpart1 partition of idxpart for values from (0) to (100) +-- +TABLE: name="idxpart1" schema="" table="idxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart1 PARTITION OF idxpart FOR VALUES FROM (0) TO (100)" +== 457 +-- truncate_limit: 100 +create table idxpart2 partition of idxpart for values from (100) to (1000) + partition by range (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart2 PARTITION OF idxpart FOR VALUES FROM (100) TO (1000) PARTITION BY RANGE (a)" +== 458 +-- truncate_limit: 100 +create table idxpart21 partition of idxpart2 for values from (100) to (200) +-- +TABLE: name="idxpart21" schema="" table="idxpart21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart21 PARTITION OF idxpart2 FOR VALUES FROM (100) TO (200)" +== 459 +-- truncate_limit: 100 +create table idxpart22 partition of idxpart2 for values from (200) to (300) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart22 PARTITION OF idxpart2 FOR VALUES FROM (200) TO (300)" +== 460 +-- truncate_limit: 100 +create index on idxpart22 (a) +-- +TABLE: name="idxpart22" schema="" table="idxpart22" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart22 USING btree (a)" +== 461 +-- truncate_limit: 100 +create index on only idxpart2 (a) +-- +TABLE: name="idxpart2" schema="" table="idxpart2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON ONLY idxpart2 USING btree (a)" +== 462 +-- truncate_limit: 100 +alter index idxpart2_a_idx attach partition idxpart22_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX idxpart2_a_idx ATTACH PARTITION idxpart22_a_idx" +== 463 +-- truncate_limit: 100 +create index on idxpart (a) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON idxpart USING btree (a)" +== 464 +-- truncate_limit: 100 +create table idxpart_another (a int, b int, primary key (a, b)) partition by range (a) +-- +TABLE: name="idxpart_another" schema="" table="idxpart_another" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart_another (a int, b int, PRIMARY KEY (a, b)) PARTITION BY RANGE (a)" +== 465 +-- truncate_limit: 100 +create table idxpart_another_1 partition of idxpart_another for values from (0) to (100) +-- +TABLE: name="idxpart_another_1" schema="" table="idxpart_another_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart_another_1 PARTITION OF idxpart_another FOR VALUES FROM (0) TO (100)" +== 466 +-- truncate_limit: 100 +create table idxpart3 (c int, b int, a int) partition by range (a) +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart3 (c int, b int, a int) PARTITION BY RANGE (a)" +== 467 +-- truncate_limit: 100 +alter table idxpart3 drop column b, drop column c +-- +TABLE: name="idxpart3" schema="" table="idxpart3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart3 DROP b, DROP c" +== 468 +-- truncate_limit: 100 +create table idxpart31 partition of idxpart3 for values from (1000) to (1200) +-- +TABLE: name="idxpart31" schema="" table="idxpart31" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart31 PARTITION OF idxpart3 FOR VALUES FROM (1000) TO (1200)" +== 469 +-- truncate_limit: 100 +create table idxpart32 partition of idxpart3 for values from (1200) to (1400) +-- +TABLE: name="idxpart32" schema="" table="idxpart32" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE idxpart32 PARTITION OF idxpart3 FOR VALUES FROM (1200) TO (1400)" +== 470 +-- truncate_limit: 100 +alter table idxpart attach partition idxpart3 for values from (1000) to (2000) +-- +TABLE: name="idxpart" schema="" table="idxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE idxpart ATTACH PARTITION idxpart3 FOR VALUES FROM (1000) TO (2000)" +== 471 +-- truncate_limit: 100 +-- More objects intentionally left behind, to verify some pg_dump/pg_upgrade +-- behavior; see https://postgr.es/m/20190321204928.GA17535@alvherre.pgsql +create schema regress_indexing +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_indexing" +== 472 +-- truncate_limit: 100 +set search_path to regress_indexing +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO regress_indexing" +== 473 +-- truncate_limit: 100 +create table pk (a int primary key) partition by range (a) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk (a int PRIMARY KEY) PARTITION BY RANGE (a)" +== 474 +-- truncate_limit: 100 +create table pk1 partition of pk for values from (0) to (1000) +-- +TABLE: name="pk1" schema="" table="pk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk1 PARTITION OF pk FOR VALUES FROM (0) TO (1000)" +== 475 +-- truncate_limit: 100 +create table pk2 (b int, a int) +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk2 (b int, a int)" +== 476 +-- truncate_limit: 100 +alter table pk2 drop column b +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk2 DROP b" +== 477 +-- truncate_limit: 100 +alter table pk2 alter a set not null +-- +TABLE: name="pk2" schema="" table="pk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk2 ALTER COLUMN a SET NOT NULL" +== 478 +-- truncate_limit: 100 +alter table pk attach partition pk2 for values from (1000) to (2000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk ATTACH PARTITION pk2 FOR VALUES FROM (1000) TO (2000)" +== 479 +-- truncate_limit: 100 +create table pk3 partition of pk for values from (2000) to (3000) +-- +TABLE: name="pk3" schema="" table="pk3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk3 PARTITION OF pk FOR VALUES FROM (2000) TO (3000)" +== 480 +-- truncate_limit: 100 +create table pk4 (like pk) +-- +TABLE: name="pk4" schema="" table="pk4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk4 (LIKE pk)" +== 481 +-- truncate_limit: 100 +alter table pk attach partition pk4 for values from (3000) to (4000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk ATTACH PARTITION pk4 FOR VALUES FROM (3000) TO (4000)" +== 482 +-- truncate_limit: 100 +create table pk5 (like pk) partition by range (a) +-- +TABLE: name="pk5" schema="" table="pk5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk5 (LIKE pk) PARTITION BY RANGE (a)" +== 483 +-- truncate_limit: 100 +create table pk51 partition of pk5 for values from (4000) to (4500) +-- +TABLE: name="pk51" schema="" table="pk51" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk51 PARTITION OF pk5 FOR VALUES FROM (4000) TO (4500)" +== 484 +-- truncate_limit: 100 +create table pk52 partition of pk5 for values from (4500) to (5000) +-- +TABLE: name="pk52" schema="" table="pk52" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pk52 PARTITION OF pk5 FOR VALUES FROM (4500) TO (5000)" +== 485 +-- truncate_limit: 100 +alter table pk attach partition pk5 for values from (4000) to (5000) +-- +TABLE: name="pk" schema="" table="pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pk ATTACH PARTITION pk5 FOR VALUES FROM (4000) TO (5000)" +== 486 +-- truncate_limit: 100 +reset search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 487 +-- truncate_limit: 100 +-- Test that covering partitioned indexes work in various cases +create table covidxpart (a int, b int) partition by list (a) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE covidxpart (a int, b int) PARTITION BY LIST (a)" +== 488 +-- truncate_limit: 100 +create unique index on covidxpart (a) include (b) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON covidxpart USING btree (a) INCLUDE (b)" +== 489 +-- truncate_limit: 100 +create table covidxpart1 partition of covidxpart for values in (1) +-- +TABLE: name="covidxpart1" schema="" table="covidxpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE covidxpart1 PARTITION OF covidxpart FOR VALUES IN (1)" +== 490 +-- truncate_limit: 100 +create table covidxpart2 partition of covidxpart for values in (2) +-- +TABLE: name="covidxpart2" schema="" table="covidxpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE covidxpart2 PARTITION OF covidxpart FOR VALUES IN (2)" +== 491 +-- truncate_limit: 100 +insert into covidxpart values (1, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covidxpart VALUES (1, 1)" +== 492 +-- truncate_limit: 100 +insert into covidxpart values (1, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covidxpart VALUES (1, 1)" +== 493 +-- truncate_limit: 100 +create table covidxpart3 (b int, c int, a int) +-- +TABLE: name="covidxpart3" schema="" table="covidxpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE covidxpart3 (b int, c int, a int)" +== 494 +-- truncate_limit: 100 +alter table covidxpart3 drop c +-- +TABLE: name="covidxpart3" schema="" table="covidxpart3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE covidxpart3 DROP c" +== 495 +-- truncate_limit: 100 +alter table covidxpart attach partition covidxpart3 for values in (3) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE covidxpart ATTACH PARTITION covidxpart3 FOR VALUES IN (3)" +== 496 +-- truncate_limit: 100 +insert into covidxpart values (3, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covidxpart VALUES (3, 1)" +== 497 +-- truncate_limit: 100 +insert into covidxpart values (3, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covidxpart VALUES (3, 1)" +== 498 +-- truncate_limit: 100 +create table covidxpart4 (b int, a int) +-- +TABLE: name="covidxpart4" schema="" table="covidxpart4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE covidxpart4 (b int, a int)" +== 499 +-- truncate_limit: 100 +create unique index on covidxpart4 (a) include (b) +-- +TABLE: name="covidxpart4" schema="" table="covidxpart4" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON covidxpart4 USING btree (a) INCLUDE (b)" +== 500 +-- truncate_limit: 100 +create unique index on covidxpart4 (a) +-- +TABLE: name="covidxpart4" schema="" table="covidxpart4" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON covidxpart4 USING btree (a)" +== 501 +-- truncate_limit: 100 +alter table covidxpart attach partition covidxpart4 for values in (4) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE covidxpart ATTACH PARTITION covidxpart4 FOR VALUES IN (4)" +== 502 +-- truncate_limit: 100 +insert into covidxpart values (4, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covidxpart VALUES (4, 1)" +== 503 +-- truncate_limit: 100 +insert into covidxpart values (4, 1) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO covidxpart VALUES (4, 1)" +== 504 +-- truncate_limit: 100 +create unique index on covidxpart (b) include (a) +-- +TABLE: name="covidxpart" schema="" table="covidxpart" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON covidxpart USING btree (b) INCLUDE (a)" +== 505 +-- truncate_limit: 100 +-- should fail + +-- check that detaching a partition also detaches the primary key constraint +create table parted_pk_detach_test (a int primary key) partition by list (a) +-- +TABLE: name="parted_pk_detach_test" schema="" table="parted_pk_detach_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_pk_detach_test (a int PRIMARY KEY) PARTITION BY LIST (a)" +== 506 +-- truncate_limit: 100 +create table parted_pk_detach_test1 partition of parted_pk_detach_test for values in (1) +-- +TABLE: name="parted_pk_detach_test1" schema="" table="parted_pk_detach_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_pk_detach_test1 PARTITION OF parted_pk_detach_test FOR VALUES IN (1)" +== 507 +-- truncate_limit: 100 +alter table parted_pk_detach_test1 drop constraint parted_pk_detach_test1_pkey +-- +TABLE: name="parted_pk_detach_test1" schema="" table="parted_pk_detach_test1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_pk_detach_test1 DROP CONSTRAINT parted_pk_detach_test1_pkey" +== 508 +-- truncate_limit: 100 +-- should fail +alter table parted_pk_detach_test detach partition parted_pk_detach_test1 +-- +TABLE: name="parted_pk_detach_test" schema="" table="parted_pk_detach_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_pk_detach_test DETACH PARTITION parted_pk_detach_test1" +== 509 +-- truncate_limit: 100 +alter table parted_pk_detach_test1 drop constraint parted_pk_detach_test1_pkey +-- +TABLE: name="parted_pk_detach_test1" schema="" table="parted_pk_detach_test1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_pk_detach_test1 DROP CONSTRAINT parted_pk_detach_test1_pkey" +== 510 +-- truncate_limit: 100 +drop table parted_pk_detach_test, parted_pk_detach_test1 +-- +TABLE: name="parted_pk_detach_test" schema="" table="parted_pk_detach_test" ctx=DDL +TABLE: name="parted_pk_detach_test1" schema="" table="parted_pk_detach_test1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_pk_detach_test, parted_pk_detach_test1" +== 511 +-- truncate_limit: 100 +create table parted_uniq_detach_test (a int unique) partition by list (a) +-- +TABLE: name="parted_uniq_detach_test" schema="" table="parted_uniq_detach_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_uniq_detach_test (a int UNIQUE) PARTITION BY LIST (a)" +== 512 +-- truncate_limit: 100 +create table parted_uniq_detach_test1 partition of parted_uniq_detach_test for values in (1) +-- +TABLE: name="parted_uniq_detach_test1" schema="" table="parted_uniq_detach_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_uniq_detach_test1 PARTITION OF parted_uniq_detach_test FOR VALUES IN (1)" +== 513 +-- truncate_limit: 100 +alter table parted_uniq_detach_test1 drop constraint parted_uniq_detach_test1_a_key +-- +TABLE: name="parted_uniq_detach_test1" schema="" table="parted_uniq_detach_test1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_uniq_detach_test1 DROP CONSTRAINT parted_uniq_detach_test1_a_key" +== 514 +-- truncate_limit: 100 +-- should fail +alter table parted_uniq_detach_test detach partition parted_uniq_detach_test1 +-- +TABLE: name="parted_uniq_detach_test" schema="" table="parted_uniq_detach_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_uniq_detach_test DETACH PARTITION parted_uniq_detach_test1" +== 515 +-- truncate_limit: 100 +alter table parted_uniq_detach_test1 drop constraint parted_uniq_detach_test1_a_key +-- +TABLE: name="parted_uniq_detach_test1" schema="" table="parted_uniq_detach_test1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_uniq_detach_test1 DROP CONSTRAINT parted_uniq_detach_test1_a_key" +== 516 +-- truncate_limit: 100 +drop table parted_uniq_detach_test, parted_uniq_detach_test1 +-- +TABLE: name="parted_uniq_detach_test" schema="" table="parted_uniq_detach_test" ctx=DDL +TABLE: name="parted_uniq_detach_test1" schema="" table="parted_uniq_detach_test1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_uniq_detach_test, parted_uniq_detach_test1" +== 517 +-- truncate_limit: 100 +-- check that dropping a column takes with it any partitioned indexes +-- depending on it. +create table parted_index_col_drop(a int, b int, c int) + partition by list (a) +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_index_col_drop (a int, b int, c int) PARTITION BY LIST (a)" +== 518 +-- truncate_limit: 100 +create table parted_index_col_drop1 partition of parted_index_col_drop + for values in (1) partition by list (a) +-- +TABLE: name="parted_index_col_drop1" schema="" table="parted_index_col_drop1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_index_col_drop1 PARTITION OF parted_index_col_drop FOR VALUES IN (1) PARTITIO..." +== 519 +-- truncate_limit: 100 +-- leave this partition without children. +create table parted_index_col_drop2 partition of parted_index_col_drop + for values in (2) partition by list (a) +-- +TABLE: name="parted_index_col_drop2" schema="" table="parted_index_col_drop2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_index_col_drop2 PARTITION OF parted_index_col_drop FOR VALUES IN (2) PARTITIO..." +== 520 +-- truncate_limit: 100 +create table parted_index_col_drop11 partition of parted_index_col_drop1 + for values in (1) +-- +TABLE: name="parted_index_col_drop11" schema="" table="parted_index_col_drop11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_index_col_drop11 PARTITION OF parted_index_col_drop1 FOR VALUES IN (1)" +== 521 +-- truncate_limit: 100 +create index on parted_index_col_drop (b) +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON parted_index_col_drop USING btree (b)" +== 522 +-- truncate_limit: 100 +create index on parted_index_col_drop (c) +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON parted_index_col_drop USING btree (c)" +== 523 +-- truncate_limit: 100 +create index on parted_index_col_drop (b, c) +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON parted_index_col_drop USING btree (b, c)" +== 524 +-- truncate_limit: 100 +alter table parted_index_col_drop drop column c +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_index_col_drop DROP c" +== 525 +-- truncate_limit: 100 +drop table parted_index_col_drop +-- +TABLE: name="parted_index_col_drop" schema="" table="parted_index_col_drop" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_index_col_drop" +== 526 +-- truncate_limit: 100 +-- Check that invalid indexes are not selected when attaching a partition. +create table parted_inval_tab (a int) partition by range (a) +-- +TABLE: name="parted_inval_tab" schema="" table="parted_inval_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_inval_tab (a int) PARTITION BY RANGE (a)" +== 527 +-- truncate_limit: 100 +create index parted_inval_idx on parted_inval_tab (a) +-- +TABLE: name="parted_inval_tab" schema="" table="parted_inval_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX parted_inval_idx ON parted_inval_tab USING btree (a)" +== 528 +-- truncate_limit: 100 +create table parted_inval_tab_1 (a int) partition by range (a) +-- +TABLE: name="parted_inval_tab_1" schema="" table="parted_inval_tab_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_inval_tab_1 (a int) PARTITION BY RANGE (a)" +== 529 +-- truncate_limit: 100 +create table parted_inval_tab_1_1 partition of parted_inval_tab_1 + for values from (0) to (10) +-- +TABLE: name="parted_inval_tab_1_1" schema="" table="parted_inval_tab_1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_inval_tab_1_1 PARTITION OF parted_inval_tab_1 FOR VALUES FROM (0) TO (10)" +== 530 +-- truncate_limit: 100 +create table parted_inval_tab_1_2 partition of parted_inval_tab_1 + for values from (10) to (20) +-- +TABLE: name="parted_inval_tab_1_2" schema="" table="parted_inval_tab_1_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_inval_tab_1_2 PARTITION OF parted_inval_tab_1 FOR VALUES FROM (10) TO (20)" +== 531 +-- truncate_limit: 100 +-- this creates an invalid index. +create index parted_inval_ixd_1 on only parted_inval_tab_1 (a) +-- +TABLE: name="parted_inval_tab_1" schema="" table="parted_inval_tab_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX parted_inval_ixd_1 ON ONLY parted_inval_tab_1 USING btree (a)" +== 532 +-- truncate_limit: 100 +-- this creates new indexes for all the partitions of parted_inval_tab_1, +-- discarding the invalid index created previously as what is chosen. +alter table parted_inval_tab attach partition parted_inval_tab_1 + for values from (1) to (100) +-- +TABLE: name="parted_inval_tab" schema="" table="parted_inval_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_inval_tab ATTACH PARTITION parted_inval_tab_1 FOR VALUES FROM (1) TO (100)" +== 533 +-- truncate_limit: 100 +select indexrelid::regclass, indisvalid, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_inval%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid WHERE ......" +== 534 +-- truncate_limit: 100 +drop table parted_inval_tab +-- +TABLE: name="parted_inval_tab" schema="" table="parted_inval_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_inval_tab" +== 535 +-- truncate_limit: 100 +-- Check setup of indisvalid across a complex partition tree on index +-- creation. If one index in a partition index is invalid, so should its +-- partitioned index. +create table parted_isvalid_tab (a int, b int) partition by range (a) +-- +TABLE: name="parted_isvalid_tab" schema="" table="parted_isvalid_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_isvalid_tab (a int, b int) PARTITION BY RANGE (a)" +== 536 +-- truncate_limit: 100 +create table parted_isvalid_tab_1 partition of parted_isvalid_tab + for values from (1) to (10) partition by range (a) +-- +TABLE: name="parted_isvalid_tab_1" schema="" table="parted_isvalid_tab_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_isvalid_tab_1 PARTITION OF parted_isvalid_tab FOR VALUES FROM (1) TO (10) PAR..." +== 537 +-- truncate_limit: 100 +create table parted_isvalid_tab_2 partition of parted_isvalid_tab + for values from (10) to (20) partition by range (a) +-- +TABLE: name="parted_isvalid_tab_2" schema="" table="parted_isvalid_tab_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_isvalid_tab_2 PARTITION OF parted_isvalid_tab FOR VALUES FROM (10) TO (20) PA..." +== 538 +-- truncate_limit: 100 +create table parted_isvalid_tab_11 partition of parted_isvalid_tab_1 + for values from (1) to (5) +-- +TABLE: name="parted_isvalid_tab_11" schema="" table="parted_isvalid_tab_11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_isvalid_tab_11 PARTITION OF parted_isvalid_tab_1 FOR VALUES FROM (1) TO (5)" +== 539 +-- truncate_limit: 100 +create table parted_isvalid_tab_12 partition of parted_isvalid_tab_1 + for values from (5) to (10) +-- +TABLE: name="parted_isvalid_tab_12" schema="" table="parted_isvalid_tab_12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_isvalid_tab_12 PARTITION OF parted_isvalid_tab_1 FOR VALUES FROM (5) TO (10)" +== 540 +-- truncate_limit: 100 +-- create an invalid index on one of the partitions. +insert into parted_isvalid_tab_11 values (1, 0) +-- +TABLE: name="parted_isvalid_tab_11" schema="" table="parted_isvalid_tab_11" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_isvalid_tab_11 VALUES (1, 0)" +== 541 +-- truncate_limit: 100 +create index concurrently parted_isvalid_idx_11 on parted_isvalid_tab_11 ((a/b)) +-- +TABLE: name="parted_isvalid_tab_11" schema="" table="parted_isvalid_tab_11" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX CONCURRENTLY parted_isvalid_idx_11 ON parted_isvalid_tab_11 USING btree ((a / b))" +== 542 +-- truncate_limit: 100 +-- The previous invalid index is selected, invalidating all the indexes up to +-- the top-most parent. +create index parted_isvalid_idx on parted_isvalid_tab ((a/b)) +-- +TABLE: name="parted_isvalid_tab" schema="" table="parted_isvalid_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX parted_isvalid_idx ON parted_isvalid_tab USING btree ((a / b))" +== 543 +-- truncate_limit: 100 +select indexrelid::regclass, indisvalid, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_isvalid%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid WHERE ......" +== 544 +-- truncate_limit: 100 +drop table parted_isvalid_tab +-- +TABLE: name="parted_isvalid_tab" schema="" table="parted_isvalid_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_isvalid_tab" +== 545 +-- truncate_limit: 100 +-- Check state of replica indexes when attaching a partition. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 546 +-- truncate_limit: 100 +create table parted_replica_tab (id int not null) partition by range (id) +-- +TABLE: name="parted_replica_tab" schema="" table="parted_replica_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_replica_tab (id int NOT NULL) PARTITION BY RANGE (id)" +== 547 +-- truncate_limit: 100 +create table parted_replica_tab_1 partition of parted_replica_tab + for values from (1) to (10) partition by range (id) +-- +TABLE: name="parted_replica_tab_1" schema="" table="parted_replica_tab_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_replica_tab_1 PARTITION OF parted_replica_tab FOR VALUES FROM (1) TO (10) PAR..." +== 548 +-- truncate_limit: 100 +create table parted_replica_tab_11 partition of parted_replica_tab_1 + for values from (1) to (5) +-- +TABLE: name="parted_replica_tab_11" schema="" table="parted_replica_tab_11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_replica_tab_11 PARTITION OF parted_replica_tab_1 FOR VALUES FROM (1) TO (5)" +== 549 +-- truncate_limit: 100 +create unique index parted_replica_idx + on only parted_replica_tab using btree (id) +-- +TABLE: name="parted_replica_tab" schema="" table="parted_replica_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX parted_replica_idx ON ONLY parted_replica_tab USING btree (id)" +== 550 +-- truncate_limit: 100 +create unique index parted_replica_idx_1 + on only parted_replica_tab_1 using btree (id) +-- +TABLE: name="parted_replica_tab_1" schema="" table="parted_replica_tab_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX parted_replica_idx_1 ON ONLY parted_replica_tab_1 USING btree (id)" +== 551 +-- truncate_limit: 100 +-- This triggers an update of pg_index.indisreplident for parted_replica_idx. +alter table only parted_replica_tab_1 replica identity + using index parted_replica_idx_1 +-- +TABLE: name="parted_replica_tab_1" schema="" table="parted_replica_tab_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parted_replica_tab_1 REPLICA IDENTITY USING INDEX parted_replica_idx_1" +== 552 +-- truncate_limit: 100 +create unique index parted_replica_idx_11 on parted_replica_tab_11 USING btree (id) +-- +TABLE: name="parted_replica_tab_11" schema="" table="parted_replica_tab_11" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX parted_replica_idx_11 ON parted_replica_tab_11 USING btree (id)" +== 553 +-- truncate_limit: 100 +select indexrelid::regclass, indisvalid, indisreplident, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_replica%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid WHERE ......" +== 554 +-- truncate_limit: 100 +-- parted_replica_idx is not valid yet here, because parted_replica_idx_1 +-- is not valid. +alter index parted_replica_idx ATTACH PARTITION parted_replica_idx_1 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX parted_replica_idx ATTACH PARTITION parted_replica_idx_1" +== 555 +-- truncate_limit: 100 +select indexrelid::regclass, indisvalid, indisreplident, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_replica%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid WHERE ......" +== 556 +-- truncate_limit: 100 +-- parted_replica_idx becomes valid here. +alter index parted_replica_idx_1 ATTACH PARTITION parted_replica_idx_11 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX parted_replica_idx_1 ATTACH PARTITION parted_replica_idx_11" +== 557 +-- truncate_limit: 100 +alter table only parted_replica_tab_1 replica identity + using index parted_replica_idx_1 +-- +TABLE: name="parted_replica_tab_1" schema="" table="parted_replica_tab_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parted_replica_tab_1 REPLICA IDENTITY USING INDEX parted_replica_idx_1" +== 558 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 559 +-- truncate_limit: 100 +select indexrelid::regclass, indisvalid, indisreplident, + indrelid::regclass, inhparent::regclass + from pg_index idx left join + pg_inherits inh on (idx.indexrelid = inh.inhrelid) + where indexrelid::regclass::text like 'parted_replica%' + order by indexrelid::regclass::text collate "C" +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "idx"="pg_index" +ALIAS: "inh"="pg_inherits" +FILTER: schema="" table="" column="indexrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_index idx LEFT JOIN pg_inherits inh ON idx.indexrelid = inh.inhrelid WHERE ......" +== 560 +-- truncate_limit: 100 +drop table parted_replica_tab +-- +TABLE: name="parted_replica_tab" schema="" table="parted_replica_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_replica_tab" diff --git a/parser/testdata/summary_truncate/postgres_regress/indirect_toast.metadata.json b/parser/testdata/summary_truncate/postgres_regress/indirect_toast.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/indirect_toast.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/indirect_toast.test b/parser/testdata/summary_truncate/postgres_regress/indirect_toast.test new file mode 100644 index 0000000..515743c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/indirect_toast.test @@ -0,0 +1,253 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for external toast datums +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION make_tuple_indirect (record) + RETURNS record + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 198 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +-- Other compression algorithms may cause the compressed data to be stored +-- inline. pglz guarantees that the data is externalized, so stick to it. +SET default_toast_compression = 'pglz' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_toast_compression TO pglz" +== 003 +-- truncate_limit: 100 +CREATE TABLE indtoasttest(descr text, cnt int DEFAULT 0, f1 text, f2 text) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE indtoasttest (descr text, cnt int DEFAULT 0, f1 text, f2 text)" +== 004 +-- truncate_limit: 100 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('two-compressed', repeat('1234567890',1000), repeat('1234567890',1000)) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO indtoasttest (descr, f1, f2) VALUES (...)" +== 005 +-- truncate_limit: 100 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('two-toasted', repeat('1234567890',30000), repeat('1234567890',50000)) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO indtoasttest (descr, f1, f2) VALUES (...)" +== 006 +-- truncate_limit: 100 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-compressed,one-null', NULL, repeat('1234567890',1000)) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO indtoasttest (descr, f1, f2) VALUES (...)" +== 007 +-- truncate_limit: 100 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-toasted,one-null', NULL, repeat('1234567890',50000)) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO indtoasttest (descr, f1, f2) VALUES (...)" +== 008 +-- truncate_limit: 100 +-- check whether indirect tuples works on the most basic level +SELECT descr, substring(make_tuple_indirect(indtoasttest)::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +FUNCTION: name="make_tuple_indirect" function="make_tuple_indirect" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT descr, \"substring\"(make_tuple_indirect(indtoasttest)::text, 1, 200) FROM indtoasttest" +== 009 +-- truncate_limit: 100 +-- modification without changing varlenas +UPDATE indtoasttest SET cnt = cnt +1 RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE indtoasttest SET cnt = cnt + 1 RETURNING \"substring\"(indtoasttest::text, 1, 200)" +== 010 +-- truncate_limit: 100 +-- modification without modifying assigned value +UPDATE indtoasttest SET cnt = cnt +1, f1 = f1 RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE indtoasttest SET cnt = cnt + 1, f1 = f1 RETURNING \"substring\"(indtoasttest::text, 1, 200)" +== 011 +-- truncate_limit: 100 +-- modification modifying, but effectively not changing +UPDATE indtoasttest SET cnt = cnt +1, f1 = f1||'' RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE indtoasttest SET ... = ... RETURNING \"substring\"(indtoasttest::text, 1, 200)" +== 012 +-- truncate_limit: 100 +UPDATE indtoasttest SET cnt = cnt +1, f1 = '-'||f1||'-' RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE indtoasttest SET ... = ... RETURNING \"substring\"(indtoasttest::text, 1, 200)" +== 013 +-- truncate_limit: 100 +SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT \"substring\"(indtoasttest::text, 1, 200) FROM indtoasttest" +== 014 +-- truncate_limit: 100 +-- check we didn't screw with main/toast tuple visibility +VACUUM FREEZE indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FREEZE) indtoasttest" +== 015 +-- truncate_limit: 100 +SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT \"substring\"(indtoasttest::text, 1, 200) FROM indtoasttest" +== 016 +-- truncate_limit: 100 +-- now create a trigger that forces all Datums to be indirect ones +CREATE FUNCTION update_using_indirect() + RETURNS trigger + LANGUAGE plpgsql AS $$ +BEGIN + NEW := make_tuple_indirect(NEW); + RETURN NEW; +END$$ +-- +FUNCTION: name="update_using_indirect" function="update_using_indirect" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION update_using_indirect() RETURNS trigger LANGUAGE plpgsql AS $$\nBEGIN\n NEW := m..." +== 017 +-- truncate_limit: 100 +CREATE TRIGGER indtoasttest_update_indirect + BEFORE INSERT OR UPDATE + ON indtoasttest + FOR EACH ROW + EXECUTE PROCEDURE update_using_indirect() +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER indtoasttest_update_indirect BEFORE INSERT OR UPDATE ON indtoasttest FOR EACH ROW ..." +== 018 +-- truncate_limit: 100 +-- modification without changing varlenas +UPDATE indtoasttest SET cnt = cnt +1 RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE indtoasttest SET cnt = cnt + 1 RETURNING \"substring\"(indtoasttest::text, 1, 200)" +== 019 +-- truncate_limit: 100 +-- modification without modifying assigned value +UPDATE indtoasttest SET cnt = cnt +1, f1 = f1 RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE indtoasttest SET cnt = cnt + 1, f1 = f1 RETURNING \"substring\"(indtoasttest::text, 1, 200)" +== 020 +-- truncate_limit: 100 +-- modification modifying, but effectively not changing +UPDATE indtoasttest SET cnt = cnt +1, f1 = f1||'' RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE indtoasttest SET ... = ... RETURNING \"substring\"(indtoasttest::text, 1, 200)" +== 021 +-- truncate_limit: 100 +UPDATE indtoasttest SET cnt = cnt +1, f1 = '-'||f1||'-' RETURNING substring(indtoasttest::text, 1, 200) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE indtoasttest SET ... = ... RETURNING \"substring\"(indtoasttest::text, 1, 200)" +== 022 +-- truncate_limit: 100 +INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-toasted,one-null, via indirect', repeat('1234567890',30000), NULL) +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO indtoasttest (descr, f1, f2) VALUES (...)" +== 023 +-- truncate_limit: 100 +SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT \"substring\"(indtoasttest::text, 1, 200) FROM indtoasttest" +== 024 +-- truncate_limit: 100 +-- check we didn't screw with main/toast tuple visibility +VACUUM FREEZE indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FREEZE) indtoasttest" +== 025 +-- truncate_limit: 100 +SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=Select +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT \"substring\"(indtoasttest::text, 1, 200) FROM indtoasttest" +== 026 +-- truncate_limit: 100 +DROP TABLE indtoasttest +-- +TABLE: name="indtoasttest" schema="" table="indtoasttest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE indtoasttest" +== 027 +-- truncate_limit: 100 +DROP FUNCTION update_using_indirect() +-- +FUNCTION: name="update_using_indirect" function="update_using_indirect" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION update_using_indirect()" +== 028 +-- truncate_limit: 100 +RESET default_toast_compression +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_toast_compression" diff --git a/parser/testdata/summary_truncate/postgres_regress/inet.metadata.json b/parser/testdata/summary_truncate/postgres_regress/inet.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/inet.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/inet.test b/parser/testdata/summary_truncate/postgres_regress/inet.test new file mode 100644 index 0000000..5b07607 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/inet.test @@ -0,0 +1,981 @@ +== 001 +-- truncate_limit: 100 +|-- +-- INET +|-- + +-- prepare the table... + +DROP TABLE INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inet_tbl" +== 002 +-- truncate_limit: 100 +CREATE TABLE INET_TBL (c cidr, i inet) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inet_tbl (c cidr, i inet)" +== 003 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.226/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('192.168.1', '192.168.1.226/24')" +== 004 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.0/26', '192.168.1.226') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('192.168.1.0/26', '192.168.1.226')" +== 005 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('192.168.1', '192.168.1.0/24')" +== 006 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.0/25') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('192.168.1', '192.168.1.0/25')" +== 007 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.255/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('192.168.1', '192.168.1.255/24')" +== 008 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1', '192.168.1.255/25') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('192.168.1', '192.168.1.255/25')" +== 009 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10', '10.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10', '10.1.2.3/8')" +== 010 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10.0.0.0', '10.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10.0.0.0', '10.1.2.3/8')" +== 011 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10.1.2.3', '10.1.2.3/32') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10.1.2.3', '10.1.2.3/32')" +== 012 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10.1.2', '10.1.2.3/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10.1.2', '10.1.2.3/24')" +== 013 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10.1', '10.1.2.3/16') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10.1', '10.1.2.3/16')" +== 014 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10', '10.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10', '10.1.2.3/8')" +== 015 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10', '11.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10', '11.1.2.3/8')" +== 016 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10', '9.1.2.3/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10', '9.1.2.3/8')" +== 017 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10:23::f1', '10:23::f1/64') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10:23::f1', '10:23::f1/64')" +== 018 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('10:23::8000/113', '10:23::ffff') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10:23::8000/113', '10:23::ffff')" +== 019 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('::ffff:1.2.3.4', '::4.3.2.1/24') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('::ffff:1.2.3.4', '::4.3.2.1/24')" +== 020 +-- truncate_limit: 100 +-- check that CIDR rejects invalid input: +INSERT INTO INET_TBL (c, i) VALUES ('192.168.1.2/30', '192.168.1.226') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('192.168.1.2/30', '192.168.1.226')" +== 021 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES ('1234::1234::1234', '::1.2.3.4') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('1234::1234::1234', '::1.2.3.4')" +== 022 +-- truncate_limit: 100 +-- check that CIDR rejects invalid input when converting from text: +INSERT INTO INET_TBL (c, i) VALUES (cidr('192.168.1.2/30'), '192.168.1.226') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +FUNCTION: name="cidr" function="cidr" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES (cidr('192.168.1.2/30'), '192.168.1.226')" +== 023 +-- truncate_limit: 100 +INSERT INTO INET_TBL (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +FUNCTION: name="cidr" function="cidr" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES (cidr('ffff:ffff:ffff:ffff::/24'), '::192.168.1.226')" +== 024 +-- truncate_limit: 100 +SELECT c AS cidr, i AS inet FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT c AS cidr, i AS inet FROM inet_tbl" +== 025 +-- truncate_limit: 100 +-- now test some support functions + +SELECT i AS inet, host(i), text(i), family(i) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="host" function="host" schema="" ctx=Call +FUNCTION: name="text" function="text" schema="" ctx=Call +FUNCTION: name="family" function="family" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i AS inet, host(i), text(i), family(i) FROM inet_tbl" +== 026 +-- truncate_limit: 100 +SELECT c AS cidr, abbrev(c) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="abbrev" function="abbrev" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c AS cidr, abbrev(c) FROM inet_tbl" +== 027 +-- truncate_limit: 100 +SELECT c AS cidr, broadcast(c), + i AS inet, broadcast(i) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="broadcast" function="broadcast" schema="" ctx=Call +FUNCTION: name="broadcast" function="broadcast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c AS cidr, broadcast(c), i AS inet, broadcast(i) FROM inet_tbl" +== 028 +-- truncate_limit: 100 +SELECT c AS cidr, network(c) AS "network(cidr)", + i AS inet, network(i) AS "network(inet)" FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="network" function="network" schema="" ctx=Call +FUNCTION: name="network" function="network" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM inet_tbl" +== 029 +-- truncate_limit: 100 +SELECT c AS cidr, masklen(c) AS "masklen(cidr)", + i AS inet, masklen(i) AS "masklen(inet)" FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM inet_tbl" +== 030 +-- truncate_limit: 100 +SELECT c AS cidr, masklen(c) AS "masklen(cidr)", + i AS inet, masklen(i) AS "masklen(inet)" FROM INET_TBL + WHERE masklen(c) <= 8 +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FUNCTION: name="masklen" function="masklen" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM inet_tbl WHERE masklen(c) <= 8" +== 031 +-- truncate_limit: 100 +SELECT c AS cidr, i AS inet FROM INET_TBL + WHERE c = i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT c AS cidr, i AS inet FROM inet_tbl WHERE c = i" +== 032 +-- truncate_limit: 100 +SELECT i, c, + i < c AS lt, i <= c AS le, i = c AS eq, + i >= c AS ge, i > c AS gt, i <> c AS ne, + i << c AS sb, i <<= c AS sbe, + i >> c AS sup, i >>= c AS spe, + i && c AS ovr + FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM inet_tbl" +== 033 +-- truncate_limit: 100 +SELECT max(i) AS max, min(i) AS min FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(i) AS max, min(i) AS min FROM inet_tbl" +== 034 +-- truncate_limit: 100 +SELECT max(c) AS max, min(c) AS min FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(c) AS max, min(c) AS min FROM inet_tbl" +== 035 +-- truncate_limit: 100 +-- check the conversion to/from text and set_netmask +SELECT set_masklen(inet(text(i)), 24) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="set_masklen" function="set_masklen" schema="" ctx=Call +FUNCTION: name="inet" function="inet" schema="" ctx=Call +FUNCTION: name="text" function="text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_masklen(inet(text(i)), 24) FROM inet_tbl" +== 036 +-- truncate_limit: 100 +-- check that btree index works correctly +CREATE INDEX inet_idx1 ON inet_tbl(i) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX inet_idx1 ON inet_tbl USING btree (i)" +== 037 +-- truncate_limit: 100 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 038 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM inet_tbl WHERE i<<'192.168.1.0/24'::cidr +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr" +== 039 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i<<'192.168.1.0/24'::cidr +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr" +== 040 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM inet_tbl WHERE i<<='192.168.1.0/24'::cidr +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM inet_tbl WHERE i <<= '192.168.1.0/24'::cidr" +== 041 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i<<='192.168.1.0/24'::cidr +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i <<= '192.168.1.0/24'::cidr" +== 042 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >>= i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >>= i" +== 043 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >>= i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >>= i" +== 044 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >> i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >> i" +== 045 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >> i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >> i" +== 046 +-- truncate_limit: 100 +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 047 +-- truncate_limit: 100 +DROP INDEX inet_idx1 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX inet_idx1" +== 048 +-- truncate_limit: 100 +-- check that gist index works correctly +CREATE INDEX inet_idx2 ON inet_tbl using gist (i inet_ops) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX inet_idx2 ON inet_tbl USING gist (i inet_ops)" +== 049 +-- truncate_limit: 100 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 050 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i" +== 051 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i <<= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i <<= '192.168.1.0/24'::cidr ORDER BY i" +== 052 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i && '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i && '192.168.1.0/24'::cidr ORDER BY i" +== 053 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i >>= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i >>= '192.168.1.0/24'::cidr ORDER BY i" +== 054 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i >> '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i >> '192.168.1.0/24'::cidr ORDER BY i" +== 055 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i < '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i < '192.168.1.0/24'::cidr ORDER BY i" +== 056 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i <= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i <= '192.168.1.0/24'::cidr ORDER BY i" +== 057 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i = '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i = '192.168.1.0/24'::cidr ORDER BY i" +== 058 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i >= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i >= '192.168.1.0/24'::cidr ORDER BY i" +== 059 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i > '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i > '192.168.1.0/24'::cidr ORDER BY i" +== 060 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i <> '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i <> '192.168.1.0/24'::cidr ORDER BY i" +== 061 +-- truncate_limit: 100 +-- test index-only scans +EXPLAIN (COSTS OFF) +SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i" +== 062 +-- truncate_limit: 100 +SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i" +== 063 +-- truncate_limit: 100 +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 064 +-- truncate_limit: 100 +DROP INDEX inet_idx2 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX inet_idx2" +== 065 +-- truncate_limit: 100 +-- check that spgist index works correctly +CREATE INDEX inet_idx3 ON inet_tbl using spgist (i) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX inet_idx3 ON inet_tbl USING spgist (i)" +== 066 +-- truncate_limit: 100 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 067 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i" +== 068 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i <<= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i <<= '192.168.1.0/24'::cidr ORDER BY i" +== 069 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i && '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i && '192.168.1.0/24'::cidr ORDER BY i" +== 070 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i >>= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i >>= '192.168.1.0/24'::cidr ORDER BY i" +== 071 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i >> '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i >> '192.168.1.0/24'::cidr ORDER BY i" +== 072 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i < '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i < '192.168.1.0/24'::cidr ORDER BY i" +== 073 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i <= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i <= '192.168.1.0/24'::cidr ORDER BY i" +== 074 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i = '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i = '192.168.1.0/24'::cidr ORDER BY i" +== 075 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i >= '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i >= '192.168.1.0/24'::cidr ORDER BY i" +== 076 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i > '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i > '192.168.1.0/24'::cidr ORDER BY i" +== 077 +-- truncate_limit: 100 +SELECT * FROM inet_tbl WHERE i <> '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inet_tbl WHERE i <> '192.168.1.0/24'::cidr ORDER BY i" +== 078 +-- truncate_limit: 100 +-- test index-only scans +EXPLAIN (COSTS OFF) +SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i" +== 079 +-- truncate_limit: 100 +SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i" +== 080 +-- truncate_limit: 100 +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 081 +-- truncate_limit: 100 +DROP INDEX inet_idx3 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX inet_idx3" +== 082 +-- truncate_limit: 100 +-- simple tests of inet boolean and arithmetic operators +SELECT i, ~i AS "~i" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT i, ~ i AS \"~i\" FROM inet_tbl" +== 083 +-- truncate_limit: 100 +SELECT i, c, i & c AS "and" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT i, c, i & c AS \"and\" FROM inet_tbl" +== 084 +-- truncate_limit: 100 +SELECT i, c, i | c AS "or" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT i, c, i | c AS \"or\" FROM inet_tbl" +== 085 +-- truncate_limit: 100 +SELECT i, i + 500 AS "i+500" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT i, i + 500 AS \"i+500\" FROM inet_tbl" +== 086 +-- truncate_limit: 100 +SELECT i, i - 500 AS "i-500" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT i, i - 500 AS \"i-500\" FROM inet_tbl" +== 087 +-- truncate_limit: 100 +SELECT i, c, i - c AS "minus" FROM inet_tbl +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT i, c, i - c AS minus FROM inet_tbl" +== 088 +-- truncate_limit: 100 +SELECT '127.0.0.1'::inet + 257 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127.0.0.1'::inet + 257" +== 089 +-- truncate_limit: 100 +SELECT ('127.0.0.1'::inet + 257) - 257 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('127.0.0.1'::inet + 257) - 257" +== 090 +-- truncate_limit: 100 +SELECT '127::1'::inet + 257 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127::1'::inet + 257" +== 091 +-- truncate_limit: 100 +SELECT ('127::1'::inet + 257) - 257 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('127::1'::inet + 257) - 257" +== 092 +-- truncate_limit: 100 +SELECT '127.0.0.2'::inet - ('127.0.0.2'::inet + 500) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127.0.0.2'::inet - ('127.0.0.2'::inet + 500)" +== 093 +-- truncate_limit: 100 +SELECT '127.0.0.2'::inet - ('127.0.0.2'::inet - 500) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127.0.0.2'::inet - ('127.0.0.2'::inet - 500)" +== 094 +-- truncate_limit: 100 +SELECT '127::2'::inet - ('127::2'::inet + 500) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127::2'::inet - ('127::2'::inet + 500)" +== 095 +-- truncate_limit: 100 +SELECT '127::2'::inet - ('127::2'::inet - 500) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127::2'::inet - ('127::2'::inet - 500)" +== 096 +-- truncate_limit: 100 +-- these should give overflow errors: +SELECT '127.0.0.1'::inet + 10000000000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127.0.0.1'::inet + 10000000000" +== 097 +-- truncate_limit: 100 +SELECT '127.0.0.1'::inet - 10000000000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127.0.0.1'::inet - 10000000000" +== 098 +-- truncate_limit: 100 +SELECT '126::1'::inet - '127::2'::inet +-- +STMT: SelectStmt +TRUNCATED: "SELECT '126::1'::inet - '127::2'::inet" +== 099 +-- truncate_limit: 100 +SELECT '127::1'::inet - '126::2'::inet +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127::1'::inet - '126::2'::inet" +== 100 +-- truncate_limit: 100 +-- but not these +SELECT '127::1'::inet + 10000000000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127::1'::inet + 10000000000" +== 101 +-- truncate_limit: 100 +SELECT '127::1'::inet - '127::2'::inet +-- +STMT: SelectStmt +TRUNCATED: "SELECT '127::1'::inet - '127::2'::inet" +== 102 +-- truncate_limit: 100 +-- insert one more row with addressed from different families +INSERT INTO INET_TBL (c, i) VALUES ('10', '10::/8') +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inet_tbl (c, i) VALUES ('10', '10::/8')" +== 103 +-- truncate_limit: 100 +-- now, this one should fail +SELECT inet_merge(c, i) FROM INET_TBL +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="inet_merge" function="inet_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT inet_merge(c, i) FROM inet_tbl" +== 104 +-- truncate_limit: 100 +-- fix it by inet_same_family() condition +SELECT inet_merge(c, i) FROM INET_TBL WHERE inet_same_family(c, i) +-- +TABLE: name="inet_tbl" schema="" table="inet_tbl" ctx=Select +FUNCTION: name="inet_same_family" function="inet_same_family" schema="" ctx=Call +FUNCTION: name="inet_merge" function="inet_merge" schema="" ctx=Call +FUNCTION: name="inet_same_family" function="inet_same_family" schema="" ctx=Call +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT inet_merge(c, i) FROM inet_tbl WHERE inet_same_family(c, i)" +== 105 +-- truncate_limit: 100 +-- Test inet sortsupport with a variety of boundary inputs: +SELECT a FROM (VALUES + ('0.0.0.0/0'::inet), + ('0.0.0.0/1'::inet), + ('0.0.0.0/32'::inet), + ('0.0.0.1/0'::inet), + ('0.0.0.1/1'::inet), + ('127.126.127.127/0'::inet), + ('127.127.127.127/0'::inet), + ('127.128.127.127/0'::inet), + ('192.168.1.0/24'::inet), + ('192.168.1.0/25'::inet), + ('192.168.1.1/23'::inet), + ('192.168.1.1/5'::inet), + ('192.168.1.1/6'::inet), + ('192.168.1.1/25'::inet), + ('192.168.1.2/25'::inet), + ('192.168.1.1/26'::inet), + ('192.168.1.2/26'::inet), + ('192.168.1.2/23'::inet), + ('192.168.1.255/5'::inet), + ('192.168.1.255/6'::inet), + ('192.168.1.3/1'::inet), + ('192.168.1.3/23'::inet), + ('192.168.1.4/0'::inet), + ('192.168.1.5/0'::inet), + ('255.0.0.0/0'::inet), + ('255.1.0.0/0'::inet), + ('255.2.0.0/0'::inet), + ('255.255.000.000/0'::inet), + ('255.255.000.000/0'::inet), + ('255.255.000.000/15'::inet), + ('255.255.000.000/16'::inet), + ('255.255.255.254/32'::inet), + ('255.255.255.000/32'::inet), + ('255.255.255.001/31'::inet), + ('255.255.255.002/31'::inet), + ('255.255.255.003/31'::inet), + ('255.255.255.003/32'::inet), + ('255.255.255.001/32'::inet), + ('255.255.255.255/0'::inet), + ('255.255.255.255/0'::inet), + ('255.255.255.255/0'::inet), + ('255.255.255.255/1'::inet), + ('255.255.255.255/16'::inet), + ('255.255.255.255/16'::inet), + ('255.255.255.255/31'::inet), + ('255.255.255.255/32'::inet), + ('255.255.255.253/32'::inet), + ('255.255.255.252/32'::inet), + ('255.3.0.0/0'::inet), + ('0000:0000:0000:0000:0000:0000:0000:0000/0'::inet), + ('0000:0000:0000:0000:0000:0000:0000:0000/128'::inet), + ('0000:0000:0000:0000:0000:0000:0000:0001/128'::inet), + ('10:23::f1/64'::inet), + ('10:23::f1/65'::inet), + ('10:23::ffff'::inet), + ('127::1'::inet), + ('127::2'::inet), + ('8000:0000:0000:0000:0000:0000:0000:0000/1'::inet), + ('::1:ffff:ffff:ffff:ffff/128'::inet), + ('::2:ffff:ffff:ffff:ffff/128'::inet), + ('::4:3:2:0/24'::inet), + ('::4:3:2:1/24'::inet), + ('::4:3:2:2/24'::inet), + ('ffff:83e7:f118:57dc:6093:6d92:689d:58cf/70'::inet), + ('ffff:84b0:4775:536e:c3ed:7116:a6d6:34f0/44'::inet), + ('ffff:8566:f84:5867:47f1:7867:d2ba:8a1a/69'::inet), + ('ffff:8883:f028:7d2:4d68:d510:7d6b:ac43/73'::inet), + ('ffff:8ae8:7c14:65b3:196:8e4a:89ae:fb30/89'::inet), + ('ffff:8dd0:646:694c:7c16:7e35:6a26:171/104'::inet), + ('ffff:8eef:cbf:700:eda3:ae32:f4b4:318b/121'::inet), + ('ffff:90e7:e744:664:a93:8efe:1f25:7663/122'::inet), + ('ffff:9597:c69c:8b24:57a:8639:ec78:6026/111'::inet), + ('ffff:9e86:79ea:f16e:df31:8e4d:7783:532e/88'::inet), + ('ffff:a0c7:82d3:24de:f762:6e1f:316d:3fb2/23'::inet), + ('ffff:fffa:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:fffb:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:fffc:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:fffd:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:fffe:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffa:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffb:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffc:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffd::/128'::inet), + ('ffff:ffff:ffff:fffd:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:fffe::/128'::inet), + ('ffff:ffff:ffff:fffe:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:ffff:4:3:2:0/24'::inet), + ('ffff:ffff:ffff:ffff:4:3:2:1/24'::inet), + ('ffff:ffff:ffff:ffff:4:3:2:2/24'::inet), + ('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/0'::inet), + ('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128'::inet) +) AS i(a) ORDER BY a +-- +STMT: SelectStmt +TRUNCATED: "SELECT a FROM (VALUES (...)) i(a) ORDER BY a" +== 106 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('1234', 'cidr') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1234', 'cidr')" +== 107 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1234', 'cidr') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1234', 'cidr')" +== 108 +-- truncate_limit: 100 +SELECT pg_input_is_valid('192.168.198.200/24', 'cidr') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('192.168.198.200/24', 'cidr')" +== 109 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('192.168.198.200/24', 'cidr') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('192.168.198.200/24', 'cidr')" +== 110 +-- truncate_limit: 100 +SELECT pg_input_is_valid('1234', 'inet') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1234', 'inet')" +== 111 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1234', 'inet') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1234', 'inet')" diff --git a/parser/testdata/summary_truncate/postgres_regress/infinite_recurse.metadata.json b/parser/testdata/summary_truncate/postgres_regress/infinite_recurse.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/infinite_recurse.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/infinite_recurse.test b/parser/testdata/summary_truncate/postgres_regress/infinite_recurse.test new file mode 100644 index 0000000..4a273ae --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/infinite_recurse.test @@ -0,0 +1,39 @@ +== 001 +-- truncate_limit: 100 +-- Check that stack depth detection mechanism works and +-- max_stack_depth is not set too high. + +create function infinite_recurse() returns int as +'select infinite_recurse()' language sql +-- +FUNCTION: name="infinite_recurse" function="infinite_recurse" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION infinite_recurse() RETURNS int AS $$select infinite_recurse()$$ LANGUAGE sql" +== 002 +-- truncate_limit: 100 +-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64 +-- signal handling that would cause this test to crash if it happened +-- to receive an sinval catchup interrupt while the stack is deep: +-- https://bugzilla.kernel.org/show_bug.cgi?id=205183 +-- It is likely to be many years before that bug disappears from all +-- production kernels, so disable this test on such platforms. +-- (We still create the function, so as not to have a cross-platform +-- difference in the end state of the regression database.) + +SELECT version() ~ 'powerpc64[^,]*-linux-gnu' + AS skip_test +-- +FUNCTION: name="version" function="version" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT version() ~ 'powerpc64[^,]*-linux-gnu' AS skip_test" +== 003 +-- truncate_limit: 100 +-- The full error report is not very stable, so we show only SQLSTATE +-- and primary error message. + + +select infinite_recurse() +-- +FUNCTION: name="infinite_recurse" function="infinite_recurse" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT infinite_recurse()" diff --git a/parser/testdata/summary_truncate/postgres_regress/inherit.metadata.json b/parser/testdata/summary_truncate/postgres_regress/inherit.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/inherit.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/inherit.test b/parser/testdata/summary_truncate/postgres_regress/inherit.test new file mode 100644 index 0000000..62bf41b --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/inherit.test @@ -0,0 +1,5537 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test inheritance features +|-- +CREATE TABLE a (aa TEXT) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE a (aa text)" +== 002 +-- truncate_limit: 100 +CREATE TABLE b (bb TEXT) INHERITS (a) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE b (bb text) INHERITS (a)" +== 003 +-- truncate_limit: 100 +CREATE TABLE c (cc TEXT) INHERITS (a) +-- +TABLE: name="c" schema="" table="c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c (cc text) INHERITS (a)" +== 004 +-- truncate_limit: 100 +CREATE TABLE d (dd TEXT) INHERITS (b,c,a) +-- +TABLE: name="d" schema="" table="d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE d (dd text) INHERITS (b, c, a)" +== 005 +-- truncate_limit: 100 +INSERT INTO a(aa) VALUES('aaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a (aa) VALUES ('aaa')" +== 006 +-- truncate_limit: 100 +INSERT INTO a(aa) VALUES('aaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a (aa) VALUES ('aaaa')" +== 007 +-- truncate_limit: 100 +INSERT INTO a(aa) VALUES('aaaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a (aa) VALUES ('aaaaa')" +== 008 +-- truncate_limit: 100 +INSERT INTO a(aa) VALUES('aaaaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a (aa) VALUES ('aaaaaa')" +== 009 +-- truncate_limit: 100 +INSERT INTO a(aa) VALUES('aaaaaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a (aa) VALUES ('aaaaaaa')" +== 010 +-- truncate_limit: 100 +INSERT INTO a(aa) VALUES('aaaaaaaa') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a (aa) VALUES ('aaaaaaaa')" +== 011 +-- truncate_limit: 100 +INSERT INTO b(aa) VALUES('bbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b (aa) VALUES ('bbb')" +== 012 +-- truncate_limit: 100 +INSERT INTO b(aa) VALUES('bbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b (aa) VALUES ('bbbb')" +== 013 +-- truncate_limit: 100 +INSERT INTO b(aa) VALUES('bbbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b (aa) VALUES ('bbbbb')" +== 014 +-- truncate_limit: 100 +INSERT INTO b(aa) VALUES('bbbbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b (aa) VALUES ('bbbbbb')" +== 015 +-- truncate_limit: 100 +INSERT INTO b(aa) VALUES('bbbbbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b (aa) VALUES ('bbbbbbb')" +== 016 +-- truncate_limit: 100 +INSERT INTO b(aa) VALUES('bbbbbbbb') +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b (aa) VALUES ('bbbbbbbb')" +== 017 +-- truncate_limit: 100 +INSERT INTO c(aa) VALUES('ccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (aa) VALUES ('ccc')" +== 018 +-- truncate_limit: 100 +INSERT INTO c(aa) VALUES('cccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (aa) VALUES ('cccc')" +== 019 +-- truncate_limit: 100 +INSERT INTO c(aa) VALUES('ccccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (aa) VALUES ('ccccc')" +== 020 +-- truncate_limit: 100 +INSERT INTO c(aa) VALUES('cccccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (aa) VALUES ('cccccc')" +== 021 +-- truncate_limit: 100 +INSERT INTO c(aa) VALUES('ccccccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (aa) VALUES ('ccccccc')" +== 022 +-- truncate_limit: 100 +INSERT INTO c(aa) VALUES('cccccccc') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (aa) VALUES ('cccccccc')" +== 023 +-- truncate_limit: 100 +INSERT INTO d(aa) VALUES('ddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d (aa) VALUES ('ddd')" +== 024 +-- truncate_limit: 100 +INSERT INTO d(aa) VALUES('dddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d (aa) VALUES ('dddd')" +== 025 +-- truncate_limit: 100 +INSERT INTO d(aa) VALUES('ddddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d (aa) VALUES ('ddddd')" +== 026 +-- truncate_limit: 100 +INSERT INTO d(aa) VALUES('dddddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d (aa) VALUES ('dddddd')" +== 027 +-- truncate_limit: 100 +INSERT INTO d(aa) VALUES('ddddddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d (aa) VALUES ('ddddddd')" +== 028 +-- truncate_limit: 100 +INSERT INTO d(aa) VALUES('dddddddd') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d (aa) VALUES ('dddddddd')" +== 029 +-- truncate_limit: 100 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM a, pg_class WHERE a.tableoid = pg_class.oid" +== 030 +-- truncate_limit: 100 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM b, pg_class WHERE b.tableoid = pg_class.oid" +== 031 +-- truncate_limit: 100 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM c, pg_class WHERE c.tableoid = pg_class.oid" +== 032 +-- truncate_limit: 100 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM d, pg_class WHERE d.tableoid = pg_class.oid" +== 033 +-- truncate_limit: 100 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM ONLY a, pg_class WHERE a.tableoid = pg_class.oid" +== 034 +-- truncate_limit: 100 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM ONLY b, pg_class WHERE b.tableoid = pg_class.oid" +== 035 +-- truncate_limit: 100 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM ONLY c, pg_class WHERE c.tableoid = pg_class.oid" +== 036 +-- truncate_limit: 100 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM ONLY d, pg_class WHERE d.tableoid = pg_class.oid" +== 037 +-- truncate_limit: 100 +UPDATE a SET aa='zzzz' WHERE aa='aaaa' +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE a SET aa = 'zzzz' WHERE aa = 'aaaa'" +== 038 +-- truncate_limit: 100 +UPDATE ONLY a SET aa='zzzzz' WHERE aa='aaaaa' +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ONLY a SET aa = 'zzzzz' WHERE aa = 'aaaaa'" +== 039 +-- truncate_limit: 100 +UPDATE b SET aa='zzz' WHERE aa='aaa' +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE b SET aa = 'zzz' WHERE aa = 'aaa'" +== 040 +-- truncate_limit: 100 +UPDATE ONLY b SET aa='zzz' WHERE aa='aaa' +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ONLY b SET aa = 'zzz' WHERE aa = 'aaa'" +== 041 +-- truncate_limit: 100 +UPDATE a SET aa='zzzzzz' WHERE aa LIKE 'aaa%' +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE a SET aa = 'zzzzzz' WHERE aa LIKE 'aaa%'" +== 042 +-- truncate_limit: 100 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM a, pg_class WHERE a.tableoid = pg_class.oid" +== 043 +-- truncate_limit: 100 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM b, pg_class WHERE b.tableoid = pg_class.oid" +== 044 +-- truncate_limit: 100 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM c, pg_class WHERE c.tableoid = pg_class.oid" +== 045 +-- truncate_limit: 100 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM d, pg_class WHERE d.tableoid = pg_class.oid" +== 046 +-- truncate_limit: 100 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM ONLY a, pg_class WHERE a.tableoid = pg_class.oid" +== 047 +-- truncate_limit: 100 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM ONLY b, pg_class WHERE b.tableoid = pg_class.oid" +== 048 +-- truncate_limit: 100 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM ONLY c, pg_class WHERE c.tableoid = pg_class.oid" +== 049 +-- truncate_limit: 100 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM ONLY d, pg_class WHERE d.tableoid = pg_class.oid" +== 050 +-- truncate_limit: 100 +UPDATE b SET aa='new' +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE b SET aa = 'new'" +== 051 +-- truncate_limit: 100 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM a, pg_class WHERE a.tableoid = pg_class.oid" +== 052 +-- truncate_limit: 100 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM b, pg_class WHERE b.tableoid = pg_class.oid" +== 053 +-- truncate_limit: 100 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM c, pg_class WHERE c.tableoid = pg_class.oid" +== 054 +-- truncate_limit: 100 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM d, pg_class WHERE d.tableoid = pg_class.oid" +== 055 +-- truncate_limit: 100 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM ONLY a, pg_class WHERE a.tableoid = pg_class.oid" +== 056 +-- truncate_limit: 100 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM ONLY b, pg_class WHERE b.tableoid = pg_class.oid" +== 057 +-- truncate_limit: 100 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM ONLY c, pg_class WHERE c.tableoid = pg_class.oid" +== 058 +-- truncate_limit: 100 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM ONLY d, pg_class WHERE d.tableoid = pg_class.oid" +== 059 +-- truncate_limit: 100 +UPDATE a SET aa='new' +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE a SET aa = 'new'" +== 060 +-- truncate_limit: 100 +DELETE FROM ONLY c WHERE aa='new' +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ONLY c WHERE aa = 'new'" +== 061 +-- truncate_limit: 100 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM a, pg_class WHERE a.tableoid = pg_class.oid" +== 062 +-- truncate_limit: 100 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM b, pg_class WHERE b.tableoid = pg_class.oid" +== 063 +-- truncate_limit: 100 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM c, pg_class WHERE c.tableoid = pg_class.oid" +== 064 +-- truncate_limit: 100 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM d, pg_class WHERE d.tableoid = pg_class.oid" +== 065 +-- truncate_limit: 100 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM ONLY a, pg_class WHERE a.tableoid = pg_class.oid" +== 066 +-- truncate_limit: 100 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM ONLY b, pg_class WHERE b.tableoid = pg_class.oid" +== 067 +-- truncate_limit: 100 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM ONLY c, pg_class WHERE c.tableoid = pg_class.oid" +== 068 +-- truncate_limit: 100 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM ONLY d, pg_class WHERE d.tableoid = pg_class.oid" +== 069 +-- truncate_limit: 100 +DELETE FROM a +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM a" +== 070 +-- truncate_limit: 100 +SELECT relname, a.* FROM a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM a, pg_class WHERE a.tableoid = pg_class.oid" +== 071 +-- truncate_limit: 100 +SELECT relname, b.* FROM b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM b, pg_class WHERE b.tableoid = pg_class.oid" +== 072 +-- truncate_limit: 100 +SELECT relname, c.* FROM c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM c, pg_class WHERE c.tableoid = pg_class.oid" +== 073 +-- truncate_limit: 100 +SELECT relname, d.* FROM d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM d, pg_class WHERE d.tableoid = pg_class.oid" +== 074 +-- truncate_limit: 100 +SELECT relname, a.* FROM ONLY a, pg_class where a.tableoid = pg_class.oid +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="a" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, a.* FROM ONLY a, pg_class WHERE a.tableoid = pg_class.oid" +== 075 +-- truncate_limit: 100 +SELECT relname, b.* FROM ONLY b, pg_class where b.tableoid = pg_class.oid +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="b" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, b.* FROM ONLY b, pg_class WHERE b.tableoid = pg_class.oid" +== 076 +-- truncate_limit: 100 +SELECT relname, c.* FROM ONLY c, pg_class where c.tableoid = pg_class.oid +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="c" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, c.* FROM ONLY c, pg_class WHERE c.tableoid = pg_class.oid" +== 077 +-- truncate_limit: 100 +SELECT relname, d.* FROM ONLY d, pg_class where d.tableoid = pg_class.oid +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="d" column="tableoid" +FILTER: schema="" table="pg_class" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname, d.* FROM ONLY d, pg_class WHERE d.tableoid = pg_class.oid" +== 078 +-- truncate_limit: 100 +-- Confirm PRIMARY KEY adds NOT NULL constraint to child table +CREATE TEMP TABLE z (b TEXT, PRIMARY KEY(aa, b)) inherits (a) +-- +TABLE: name="z" schema="" table="z" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE z (b text, PRIMARY KEY (aa, b)) INHERITS (a)" +== 079 +-- truncate_limit: 100 +INSERT INTO z VALUES (NULL, 'text') +-- +TABLE: name="z" schema="" table="z" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO z VALUES (NULL, 'text')" +== 080 +-- truncate_limit: 100 +-- should fail + +-- Check inherited UPDATE with first child excluded +create table some_tab (f1 int, f2 int, f3 int, check (f1 < 10) no inherit) +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE some_tab (f1 int, f2 int, f3 int, CHECK (f1 < 10) NO INHERIT)" +== 081 +-- truncate_limit: 100 +create table some_tab_child () inherits(some_tab) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE some_tab_child () INHERITS (some_tab)" +== 082 +-- truncate_limit: 100 +insert into some_tab_child select i, i+1, 0 from generate_series(1,1000) i +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO some_tab_child SELECT i, i + 1, 0 FROM generate_series(1, 1000) i" +== 083 +-- truncate_limit: 100 +create index on some_tab_child(f1, f2) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON some_tab_child USING btree (f1, f2)" +== 084 +-- truncate_limit: 100 +-- while at it, also check that statement-level triggers fire +create function some_tab_stmt_trig_func() returns trigger as +$$begin raise notice 'updating some_tab'; return NULL; end;$$ +language plpgsql +-- +FUNCTION: name="some_tab_stmt_trig_func" function="some_tab_stmt_trig_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION some_tab_stmt_trig_func() RETURNS trigger AS $$begin raise notice 'updating some_..." +== 085 +-- truncate_limit: 100 +create trigger some_tab_stmt_trig + before update on some_tab execute function some_tab_stmt_trig_func() +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER some_tab_stmt_trig BEFORE UPDATE ON some_tab EXECUTE FUNCTION some_tab_stmt_trig_f..." +== 086 +-- truncate_limit: 100 +explain (costs off) +update some_tab set f3 = 11 where f1 = 12 and f2 = 13 +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE some_tab SET f3 = 11 WHERE f1 = 12 AND f2 = 13" +== 087 +-- truncate_limit: 100 +update some_tab set f3 = 11 where f1 = 12 and f2 = 13 +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE some_tab SET f3 = 11 WHERE f1 = 12 AND f2 = 13" +== 088 +-- truncate_limit: 100 +drop table some_tab cascade +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE some_tab CASCADE" +== 089 +-- truncate_limit: 100 +drop function some_tab_stmt_trig_func() +-- +FUNCTION: name="some_tab_stmt_trig_func" function="some_tab_stmt_trig_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION some_tab_stmt_trig_func()" +== 090 +-- truncate_limit: 100 +-- Check inherited UPDATE with all children excluded +create table some_tab (a int, b int) +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE some_tab (a int, b int)" +== 091 +-- truncate_limit: 100 +create table some_tab_child () inherits (some_tab) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE some_tab_child () INHERITS (some_tab)" +== 092 +-- truncate_limit: 100 +insert into some_tab_child values(1,2) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO some_tab_child VALUES (1, 2)" +== 093 +-- truncate_limit: 100 +explain (verbose, costs off) +update some_tab set a = a + 1 where false +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) UPDATE some_tab SET a = a + 1 WHERE false" +== 094 +-- truncate_limit: 100 +update some_tab set a = a + 1 where false +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE some_tab SET a = a + 1 WHERE false" +== 095 +-- truncate_limit: 100 +explain (verbose, costs off) +update some_tab set a = a + 1 where false returning b, a +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) UPDATE some_tab SET a = a + 1 WHERE false RETURNING b, a" +== 096 +-- truncate_limit: 100 +update some_tab set a = a + 1 where false returning b, a +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE some_tab SET a = a + 1 WHERE false RETURNING b, a" +== 097 +-- truncate_limit: 100 +table some_tab +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM some_tab" +== 098 +-- truncate_limit: 100 +drop table some_tab cascade +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE some_tab CASCADE" +== 099 +-- truncate_limit: 100 +-- Check UPDATE with inherited target and an inherited source table +create temp table foo(f1 int, f2 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (f1 int, f2 int)" +== 100 +-- truncate_limit: 100 +create temp table foo2(f3 int) inherits (foo) +-- +TABLE: name="foo2" schema="" table="foo2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo2 (f3 int) INHERITS (foo)" +== 101 +-- truncate_limit: 100 +create temp table bar(f1 int, f2 int) +-- +TABLE: name="bar" schema="" table="bar" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE bar (f1 int, f2 int)" +== 102 +-- truncate_limit: 100 +create temp table bar2(f3 int) inherits (bar) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE bar2 (f3 int) INHERITS (bar)" +== 103 +-- truncate_limit: 100 +insert into foo values(1,1) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (1, 1)" +== 104 +-- truncate_limit: 100 +insert into foo values(3,3) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (3, 3)" +== 105 +-- truncate_limit: 100 +insert into foo2 values(2,2,2) +-- +TABLE: name="foo2" schema="" table="foo2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo2 VALUES (2, 2, 2)" +== 106 +-- truncate_limit: 100 +insert into foo2 values(3,3,3) +-- +TABLE: name="foo2" schema="" table="foo2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo2 VALUES (3, 3, 3)" +== 107 +-- truncate_limit: 100 +insert into bar values(1,1) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar VALUES (1, 1)" +== 108 +-- truncate_limit: 100 +insert into bar values(2,2) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar VALUES (2, 2)" +== 109 +-- truncate_limit: 100 +insert into bar values(3,3) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar VALUES (3, 3)" +== 110 +-- truncate_limit: 100 +insert into bar values(4,4) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar VALUES (4, 4)" +== 111 +-- truncate_limit: 100 +insert into bar2 values(1,1,1) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar2 VALUES (1, 1, 1)" +== 112 +-- truncate_limit: 100 +insert into bar2 values(2,2,2) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar2 VALUES (2, 2, 2)" +== 113 +-- truncate_limit: 100 +insert into bar2 values(3,3,3) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar2 VALUES (3, 3, 3)" +== 114 +-- truncate_limit: 100 +insert into bar2 values(4,4,4) +-- +TABLE: name="bar2" schema="" table="bar2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar2 VALUES (4, 4, 4)" +== 115 +-- truncate_limit: 100 +update bar set f2 = f2 + 100 where f1 in (select f1 from foo) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE bar SET f2 = f2 + 100 WHERE f1 IN (SELECT f1 FROM foo)" +== 116 +-- truncate_limit: 100 +select tableoid::regclass::text as relname, bar.* from bar order by 1,2 +-- +TABLE: name="bar" schema="" table="bar" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text AS relname, bar.* FROM bar ORDER BY 1, 2" +== 117 +-- truncate_limit: 100 +-- Check UPDATE with inherited target and an appendrel subquery +update bar set f2 = f2 + 100 +from + ( select f1 from foo union all select f1+3 from foo ) ss +where bar.f1 = ss.f1 +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE bar SET f2 = f2 + 100 FROM (SELECT f1 FROM foo UNION ALL SELECT ... FROM foo) ss WHERE ..." +== 118 +-- truncate_limit: 100 +select tableoid::regclass::text as relname, bar.* from bar order by 1,2 +-- +TABLE: name="bar" schema="" table="bar" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text AS relname, bar.* FROM bar ORDER BY 1, 2" +== 119 +-- truncate_limit: 100 +-- Check UPDATE with *partitioned* inherited target and an appendrel subquery +create table some_tab (a int) +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE some_tab (a int)" +== 120 +-- truncate_limit: 100 +insert into some_tab values (0) +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO some_tab VALUES (0)" +== 121 +-- truncate_limit: 100 +create table some_tab_child () inherits (some_tab) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE some_tab_child () INHERITS (some_tab)" +== 122 +-- truncate_limit: 100 +insert into some_tab_child values (1) +-- +TABLE: name="some_tab_child" schema="" table="some_tab_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO some_tab_child VALUES (1)" +== 123 +-- truncate_limit: 100 +create table parted_tab (a int, b char) partition by list (a) +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_tab (a int, b char(1)) PARTITION BY LIST (a)" +== 124 +-- truncate_limit: 100 +create table parted_tab_part1 partition of parted_tab for values in (1) +-- +TABLE: name="parted_tab_part1" schema="" table="parted_tab_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_tab_part1 PARTITION OF parted_tab FOR VALUES IN (1)" +== 125 +-- truncate_limit: 100 +create table parted_tab_part2 partition of parted_tab for values in (2) +-- +TABLE: name="parted_tab_part2" schema="" table="parted_tab_part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_tab_part2 PARTITION OF parted_tab FOR VALUES IN (2)" +== 126 +-- truncate_limit: 100 +create table parted_tab_part3 partition of parted_tab for values in (3) +-- +TABLE: name="parted_tab_part3" schema="" table="parted_tab_part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_tab_part3 PARTITION OF parted_tab FOR VALUES IN (3)" +== 127 +-- truncate_limit: 100 +insert into parted_tab values (1, 'a'), (2, 'a'), (3, 'a') +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_tab VALUES (1, 'a'), (2, 'a'), (3, 'a')" +== 128 +-- truncate_limit: 100 +update parted_tab set b = 'b' +from + (select a from some_tab union all select a+1 from some_tab) ss (a) +where parted_tab.a = ss.a +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE parted_tab SET ... = ... FROM (SELECT a FROM some_tab UNION ALL SELECT ... FROM some_tab) ..." +== 129 +-- truncate_limit: 100 +select tableoid::regclass::text as relname, parted_tab.* from parted_tab order by 1,2 +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text AS relname, parted_tab.* FROM parted_tab ORDER BY 1, 2" +== 130 +-- truncate_limit: 100 +truncate parted_tab +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_tab" +== 131 +-- truncate_limit: 100 +insert into parted_tab values (1, 'a'), (2, 'a'), (3, 'a') +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_tab VALUES (1, 'a'), (2, 'a'), (3, 'a')" +== 132 +-- truncate_limit: 100 +update parted_tab set b = 'b' +from + (select 0 from parted_tab union all select 1 from parted_tab) ss (a) +where parted_tab.a = ss.a +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=Select +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE parted_tab SET ... = ... FROM (SELECT 0 FROM parted_tab UNION ALL SELECT 1 FROM parted_tab..." +== 133 +-- truncate_limit: 100 +select tableoid::regclass::text as relname, parted_tab.* from parted_tab order by 1,2 +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text AS relname, parted_tab.* FROM parted_tab ORDER BY 1, 2" +== 134 +-- truncate_limit: 100 +-- modifies partition key, but no rows will actually be updated +explain update parted_tab set a = 2 where false +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN UPDATE parted_tab SET a = 2 WHERE false" +== 135 +-- truncate_limit: 100 +drop table parted_tab +-- +TABLE: name="parted_tab" schema="" table="parted_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_tab" +== 136 +-- truncate_limit: 100 +-- Check UPDATE with multi-level partitioned inherited target +create table mlparted_tab (a int, b char, c text) partition by list (a) +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_tab (a int, b char(1), c text) PARTITION BY LIST (a)" +== 137 +-- truncate_limit: 100 +create table mlparted_tab_part1 partition of mlparted_tab for values in (1) +-- +TABLE: name="mlparted_tab_part1" schema="" table="mlparted_tab_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_tab_part1 PARTITION OF mlparted_tab FOR VALUES IN (1)" +== 138 +-- truncate_limit: 100 +create table mlparted_tab_part2 partition of mlparted_tab for values in (2) partition by list (b) +-- +TABLE: name="mlparted_tab_part2" schema="" table="mlparted_tab_part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_tab_part2 PARTITION OF mlparted_tab FOR VALUES IN (2) PARTITION BY LIST (b)" +== 139 +-- truncate_limit: 100 +create table mlparted_tab_part3 partition of mlparted_tab for values in (3) +-- +TABLE: name="mlparted_tab_part3" schema="" table="mlparted_tab_part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_tab_part3 PARTITION OF mlparted_tab FOR VALUES IN (3)" +== 140 +-- truncate_limit: 100 +create table mlparted_tab_part2a partition of mlparted_tab_part2 for values in ('a') +-- +TABLE: name="mlparted_tab_part2a" schema="" table="mlparted_tab_part2a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_tab_part2a PARTITION OF mlparted_tab_part2 FOR VALUES IN ('a')" +== 141 +-- truncate_limit: 100 +create table mlparted_tab_part2b partition of mlparted_tab_part2 for values in ('b') +-- +TABLE: name="mlparted_tab_part2b" schema="" table="mlparted_tab_part2b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_tab_part2b PARTITION OF mlparted_tab_part2 FOR VALUES IN ('b')" +== 142 +-- truncate_limit: 100 +insert into mlparted_tab values (1, 'a'), (2, 'a'), (2, 'b'), (3, 'a') +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted_tab VALUES (1, 'a'), (2, 'a'), (2, 'b'), (3, 'a')" +== 143 +-- truncate_limit: 100 +update mlparted_tab mlp set c = 'xxx' +from + (select a from some_tab union all select a+1 from some_tab) ss (a) +where (mlp.a = ss.a and mlp.b = 'b') or mlp.a = 3 +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=DML +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +TABLE: name="some_tab" schema="" table="some_tab" ctx=Select +ALIAS: "mlp"="mlparted_tab" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE mlparted_tab mlp SET ... = ... FROM (SELECT a FROM some_tab UNION ALL SELECT ... FROM some..." +== 144 +-- truncate_limit: 100 +select tableoid::regclass::text as relname, mlparted_tab.* from mlparted_tab order by 1,2 +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text AS relname, mlparted_tab.* FROM mlparted_tab ORDER BY 1, 2" +== 145 +-- truncate_limit: 100 +drop table mlparted_tab +-- +TABLE: name="mlparted_tab" schema="" table="mlparted_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mlparted_tab" +== 146 +-- truncate_limit: 100 +drop table some_tab cascade +-- +TABLE: name="some_tab" schema="" table="some_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE some_tab CASCADE" +== 147 +-- truncate_limit: 100 +/* Test multiple inheritance of column defaults */ + +CREATE TABLE firstparent (tomorrow date default now()::date + 1) +-- +TABLE: name="firstparent" schema="" table="firstparent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE firstparent (tomorrow date DEFAULT now()::date + 1)" +== 148 +-- truncate_limit: 100 +CREATE TABLE secondparent (tomorrow date default now() :: date + 1) +-- +TABLE: name="secondparent" schema="" table="secondparent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE secondparent (tomorrow date DEFAULT now()::date + 1)" +== 149 +-- truncate_limit: 100 +CREATE TABLE jointchild () INHERITS (firstparent, secondparent) +-- +TABLE: name="jointchild" schema="" table="jointchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE jointchild () INHERITS (firstparent, secondparent)" +== 150 +-- truncate_limit: 100 +-- ok +CREATE TABLE thirdparent (tomorrow date default now()::date - 1) +-- +TABLE: name="thirdparent" schema="" table="thirdparent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE thirdparent (tomorrow date DEFAULT now()::date - 1)" +== 151 +-- truncate_limit: 100 +CREATE TABLE otherchild () INHERITS (firstparent, thirdparent) +-- +TABLE: name="otherchild" schema="" table="otherchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE otherchild () INHERITS (firstparent, thirdparent)" +== 152 +-- truncate_limit: 100 +-- not ok +CREATE TABLE otherchild (tomorrow date default now()) + INHERITS (firstparent, thirdparent) +-- +TABLE: name="otherchild" schema="" table="otherchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE otherchild (tomorrow date DEFAULT now()) INHERITS (firstparent, thirdparent)" +== 153 +-- truncate_limit: 100 +-- ok, child resolves ambiguous default + +DROP TABLE firstparent, secondparent, jointchild, thirdparent, otherchild +-- +TABLE: name="firstparent" schema="" table="firstparent" ctx=DDL +TABLE: name="secondparent" schema="" table="secondparent" ctx=DDL +TABLE: name="jointchild" schema="" table="jointchild" ctx=DDL +TABLE: name="thirdparent" schema="" table="thirdparent" ctx=DDL +TABLE: name="otherchild" schema="" table="otherchild" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE firstparent, secondparent, jointchild, thirdparent, otherchild" +== 154 +-- truncate_limit: 100 +-- Test changing the type of inherited columns +insert into d values('test','one','two','three') +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d VALUES ('test', 'one', 'two', 'three')" +== 155 +-- truncate_limit: 100 +alter table a alter column aa type integer using bit_length(aa) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE a ALTER COLUMN aa TYPE int USING bit_length(aa)" +== 156 +-- truncate_limit: 100 +select * from d +-- +TABLE: name="d" schema="" table="d" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM d" +== 157 +-- truncate_limit: 100 +-- The above verified that we can change the type of a multiply-inherited +-- column; but we should reject that if any definition was inherited from +-- an unrelated parent. +create temp table parent1(f1 int, f2 int) +-- +TABLE: name="parent1" schema="" table="parent1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parent1 (f1 int, f2 int)" +== 158 +-- truncate_limit: 100 +create temp table parent2(f1 int, f3 bigint) +-- +TABLE: name="parent2" schema="" table="parent2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parent2 (f1 int, f3 bigint)" +== 159 +-- truncate_limit: 100 +create temp table childtab(f4 int) inherits(parent1, parent2) +-- +TABLE: name="childtab" schema="" table="childtab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE childtab (f4 int) INHERITS (parent1, parent2)" +== 160 +-- truncate_limit: 100 +alter table parent1 alter column f1 type bigint +-- +TABLE: name="parent1" schema="" table="parent1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent1 ALTER COLUMN f1 TYPE bigint" +== 161 +-- truncate_limit: 100 +-- fail, conflict w/parent2 +alter table parent1 alter column f2 type bigint +-- +TABLE: name="parent1" schema="" table="parent1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent1 ALTER COLUMN f2 TYPE bigint" +== 162 +-- truncate_limit: 100 +-- ok + +-- Test non-inheritable parent constraints +create table p1(ff1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (ff1 int)" +== 163 +-- truncate_limit: 100 +alter table p1 add constraint p1chk check (ff1 > 0) no inherit +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 ADD CONSTRAINT p1chk CHECK (ff1 > 0) NO INHERIT" +== 164 +-- truncate_limit: 100 +alter table p1 add constraint p2chk check (ff1 > 10) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 ADD CONSTRAINT p2chk CHECK (ff1 > 10)" +== 165 +-- truncate_limit: 100 +-- connoinherit should be true for NO INHERIT constraint +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pgc.connoinherit from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname = 'p1' order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 166 +-- truncate_limit: 100 +-- Test that child does not inherit NO INHERIT constraints +create table c1 () inherits (p1) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 () INHERITS (p1)" +== 167 +-- truncate_limit: 100 +-- Test that child does not override inheritable constraints of the parent +create table c2 (constraint p2chk check (ff1 > 10) no inherit) inherits (p1) +-- +TABLE: name="c2" schema="" table="c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c2 (CONSTRAINT p2chk CHECK (ff1 > 10) NO INHERIT) INHERITS (p1)" +== 168 +-- truncate_limit: 100 +--fails + +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 169 +-- truncate_limit: 100 +-- Tests for casting between the rowtypes of parent and child +-- tables. See the pgsql-hackers thread beginning Dec. 4/04 +create table base (i integer) +-- +TABLE: name="base" schema="" table="base" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base (i int)" +== 170 +-- truncate_limit: 100 +create table derived () inherits (base) +-- +TABLE: name="derived" schema="" table="derived" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE derived () INHERITS (base)" +== 171 +-- truncate_limit: 100 +create table more_derived (like derived, b int) inherits (derived) +-- +TABLE: name="more_derived" schema="" table="more_derived" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE more_derived (LIKE derived, b int) INHERITS (derived)" +== 172 +-- truncate_limit: 100 +insert into derived (i) values (0) +-- +TABLE: name="derived" schema="" table="derived" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO derived (i) VALUES (0)" +== 173 +-- truncate_limit: 100 +select derived::base from derived +-- +TABLE: name="derived" schema="" table="derived" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT derived::base FROM derived" +== 174 +-- truncate_limit: 100 +select NULL::derived::base +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::derived::base" +== 175 +-- truncate_limit: 100 +-- remove redundant conversions. +explain (verbose on, costs off) select row(i, b)::more_derived::derived::base from more_derived +-- +TABLE: name="more_derived" schema="" table="more_derived" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE ON, COSTS OFF) SELECT ROW(i, b)::more_derived::derived::base FROM more_derived" +== 176 +-- truncate_limit: 100 +explain (verbose on, costs off) select (1, 2)::more_derived::derived::base +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE ON, COSTS OFF) SELECT (1, 2)::more_derived::derived::base" +== 177 +-- truncate_limit: 100 +drop table more_derived +-- +TABLE: name="more_derived" schema="" table="more_derived" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE more_derived" +== 178 +-- truncate_limit: 100 +drop table derived +-- +TABLE: name="derived" schema="" table="derived" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE derived" +== 179 +-- truncate_limit: 100 +drop table base +-- +TABLE: name="base" schema="" table="base" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base" +== 180 +-- truncate_limit: 100 +create table p1(ff1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (ff1 int)" +== 181 +-- truncate_limit: 100 +create table p2(f1 text) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p2 (f1 text)" +== 182 +-- truncate_limit: 100 +create function p2text(p2) returns text as 'select $1.f1' language sql +-- +FUNCTION: name="p2text" function="p2text" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION p2text(p2) RETURNS text AS $$select $1.f1$$ LANGUAGE sql" +== 183 +-- truncate_limit: 100 +create table c1(f3 int) inherits(p1,p2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 (f3 int) INHERITS (p1, p2)" +== 184 +-- truncate_limit: 100 +insert into c1 values(123456789, 'hi', 42) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c1 VALUES (123456789, 'hi', 42)" +== 185 +-- truncate_limit: 100 +select p2text(c1.*) from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=Select +FUNCTION: name="p2text" function="p2text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT p2text(c1.*) FROM c1" +== 186 +-- truncate_limit: 100 +drop function p2text(p2) +-- +FUNCTION: name="p2text" function="p2text" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION p2text(p2)" +== 187 +-- truncate_limit: 100 +drop table c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE c1" +== 188 +-- truncate_limit: 100 +drop table p2 +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p2" +== 189 +-- truncate_limit: 100 +drop table p1 +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1" +== 190 +-- truncate_limit: 100 +CREATE TABLE ac (aa TEXT) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ac (aa text)" +== 191 +-- truncate_limit: 100 +alter table ac add constraint ac_check check (aa is not null) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ac ADD CONSTRAINT ac_check CHECK (aa IS NOT NULL)" +== 192 +-- truncate_limit: 100 +CREATE TABLE bc (bb TEXT) INHERITS (ac) +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bc (bb text) INHERITS (ac)" +== 193 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 194 +-- truncate_limit: 100 +insert into ac (aa) values (NULL) +-- +TABLE: name="ac" schema="" table="ac" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ac (aa) VALUES (NULL)" +== 195 +-- truncate_limit: 100 +insert into bc (aa) values (NULL) +-- +TABLE: name="bc" schema="" table="bc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bc (aa) VALUES (NULL)" +== 196 +-- truncate_limit: 100 +alter table bc drop constraint ac_check +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bc DROP CONSTRAINT ac_check" +== 197 +-- truncate_limit: 100 +-- fail, disallowed +alter table ac drop constraint ac_check +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ac DROP CONSTRAINT ac_check" +== 198 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 199 +-- truncate_limit: 100 +-- try the unnamed-constraint case +alter table ac add check (aa is not null) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ac ADD CHECK (aa IS NOT NULL)" +== 200 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 201 +-- truncate_limit: 100 +insert into ac (aa) values (NULL) +-- +TABLE: name="ac" schema="" table="ac" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ac (aa) VALUES (NULL)" +== 202 +-- truncate_limit: 100 +insert into bc (aa) values (NULL) +-- +TABLE: name="bc" schema="" table="bc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bc (aa) VALUES (NULL)" +== 203 +-- truncate_limit: 100 +alter table bc drop constraint ac_aa_check +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bc DROP CONSTRAINT ac_aa_check" +== 204 +-- truncate_limit: 100 +-- fail, disallowed +alter table ac drop constraint ac_aa_check +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ac DROP CONSTRAINT ac_aa_check" +== 205 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 206 +-- truncate_limit: 100 +alter table ac add constraint ac_check check (aa is not null) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ac ADD CONSTRAINT ac_check CHECK (aa IS NOT NULL)" +== 207 +-- truncate_limit: 100 +alter table bc no inherit ac +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bc NO INHERIT ac" +== 208 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 209 +-- truncate_limit: 100 +alter table bc drop constraint ac_check +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bc DROP CONSTRAINT ac_check" +== 210 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 211 +-- truncate_limit: 100 +alter table ac drop constraint ac_check +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ac DROP CONSTRAINT ac_check" +== 212 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 213 +-- truncate_limit: 100 +drop table bc +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bc" +== 214 +-- truncate_limit: 100 +drop table ac +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ac" +== 215 +-- truncate_limit: 100 +create table ac (a int constraint check_a check (a <> 0)) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ac (a int CONSTRAINT check_a CHECK (a <> 0))" +== 216 +-- truncate_limit: 100 +create table bc (a int constraint check_a check (a <> 0), b int constraint check_b check (b <> 0)) inherits (ac) +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bc (a int CONSTRAINT check_a CHECK (a <> 0), b int CONSTRAINT check_b CHECK (b <> 0)..." +== 217 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 218 +-- truncate_limit: 100 +drop table bc +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bc" +== 219 +-- truncate_limit: 100 +drop table ac +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ac" +== 220 +-- truncate_limit: 100 +create table ac (a int constraint check_a check (a <> 0)) +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ac (a int CONSTRAINT check_a CHECK (a <> 0))" +== 221 +-- truncate_limit: 100 +create table bc (b int constraint check_b check (b <> 0)) +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bc (b int CONSTRAINT check_b CHECK (b <> 0))" +== 222 +-- truncate_limit: 100 +create table cc (c int constraint check_c check (c <> 0)) inherits (ac, bc) +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cc (c int CONSTRAINT check_c CHECK (c <> 0)) INHERITS (ac, bc)" +== 223 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 224 +-- truncate_limit: 100 +alter table cc no inherit bc +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE cc NO INHERIT bc" +== 225 +-- truncate_limit: 100 +select pc.relname, pgc.conname, pgc.contype, pgc.conislocal, pgc.coninhcount, pg_get_expr(pgc.conbin, pc.oid) as consrc from pg_class as pc inner join pg_constraint as pgc on (pgc.conrelid = pc.oid) where pc.relname in ('ac', 'bc', 'cc') order by 1,2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pgc"="pg_constraint" +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="pc" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_constraint pgc ON pgc.conrelid = pc.oid WHERE ... ORDER BY 1, 2" +== 226 +-- truncate_limit: 100 +drop table cc +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cc" +== 227 +-- truncate_limit: 100 +drop table bc +-- +TABLE: name="bc" schema="" table="bc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bc" +== 228 +-- truncate_limit: 100 +drop table ac +-- +TABLE: name="ac" schema="" table="ac" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ac" +== 229 +-- truncate_limit: 100 +create table p1(f1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int)" +== 230 +-- truncate_limit: 100 +create table p2(f2 int) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p2 (f2 int)" +== 231 +-- truncate_limit: 100 +create table c1(f3 int) inherits(p1,p2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c1 (f3 int) INHERITS (p1, p2)" +== 232 +-- truncate_limit: 100 +insert into c1 values(1,-1,2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c1 VALUES (1, -1, 2)" +== 233 +-- truncate_limit: 100 +alter table p2 add constraint cc check (f2>0) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p2 ADD CONSTRAINT cc CHECK (f2 > 0)" +== 234 +-- truncate_limit: 100 +-- fail +alter table p2 add check (f2>0) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p2 ADD CHECK (f2 > 0)" +== 235 +-- truncate_limit: 100 +-- check it without a name, too +delete from c1 +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM c1" +== 236 +-- truncate_limit: 100 +insert into c1 values(1,1,2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c1 VALUES (1, 1, 2)" +== 237 +-- truncate_limit: 100 +alter table p2 add check (f2>0) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p2 ADD CHECK (f2 > 0)" +== 238 +-- truncate_limit: 100 +insert into c1 values(1,-1,2) +-- +TABLE: name="c1" schema="" table="c1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c1 VALUES (1, -1, 2)" +== 239 +-- truncate_limit: 100 +-- fail +create table c2(f3 int) inherits(p1,p2) +-- +TABLE: name="c2" schema="" table="c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c2 (f3 int) INHERITS (p1, p2)" +== 240 +-- truncate_limit: 100 +create table c3 (f4 int) inherits(c1,c2) +-- +TABLE: name="c3" schema="" table="c3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE c3 (f4 int) INHERITS (c1, c2)" +== 241 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 242 +-- truncate_limit: 100 +drop table p2 cascade +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p2 CASCADE" +== 243 +-- truncate_limit: 100 +create table pp1 (f1 int) +-- +TABLE: name="pp1" schema="" table="pp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp1 (f1 int)" +== 244 +-- truncate_limit: 100 +create table cc1 (f2 text, f3 int) inherits (pp1) +-- +TABLE: name="cc1" schema="" table="cc1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cc1 (f2 text, f3 int) INHERITS (pp1)" +== 245 +-- truncate_limit: 100 +alter table pp1 add column a1 int check (a1 > 0) +-- +TABLE: name="pp1" schema="" table="pp1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pp1 ADD COLUMN a1 int CHECK (a1 > 0)" +== 246 +-- truncate_limit: 100 +create table cc2(f4 float) inherits(pp1,cc1) +-- +TABLE: name="cc2" schema="" table="cc2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cc2 (f4 double precision) INHERITS (pp1, cc1)" +== 247 +-- truncate_limit: 100 +alter table pp1 add column a2 int check (a2 > 0) +-- +TABLE: name="pp1" schema="" table="pp1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pp1 ADD COLUMN a2 int CHECK (a2 > 0)" +== 248 +-- truncate_limit: 100 +drop table pp1 cascade +-- +TABLE: name="pp1" schema="" table="pp1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp1 CASCADE" +== 249 +-- truncate_limit: 100 +-- Test for renaming in simple multiple inheritance +CREATE TABLE inht1 (a int, b int) +-- +TABLE: name="inht1" schema="" table="inht1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inht1 (a int, b int)" +== 250 +-- truncate_limit: 100 +CREATE TABLE inhs1 (b int, c int) +-- +TABLE: name="inhs1" schema="" table="inhs1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhs1 (b int, c int)" +== 251 +-- truncate_limit: 100 +CREATE TABLE inhts (d int) INHERITS (inht1, inhs1) +-- +TABLE: name="inhts" schema="" table="inhts" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhts (d int) INHERITS (inht1, inhs1)" +== 252 +-- truncate_limit: 100 +ALTER TABLE inht1 RENAME a TO aa +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE inht1 RENAME COLUMN a TO aa" +== 253 +-- truncate_limit: 100 +ALTER TABLE inht1 RENAME b TO bb +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE inht1 RENAME COLUMN b TO bb" +== 254 +-- truncate_limit: 100 +-- to be failed +ALTER TABLE inhts RENAME aa TO aaa +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE inhts RENAME COLUMN aa TO aaa" +== 255 +-- truncate_limit: 100 +-- to be failed +ALTER TABLE inhts RENAME d TO dd +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE inhts RENAME COLUMN d TO dd" +== 256 +-- truncate_limit: 100 +DROP TABLE inhts +-- +TABLE: name="inhts" schema="" table="inhts" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhts" +== 257 +-- truncate_limit: 100 +-- Test for adding a column to a parent table with complex inheritance +CREATE TABLE inhta () +-- +TABLE: name="inhta" schema="" table="inhta" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhta ()" +== 258 +-- truncate_limit: 100 +CREATE TABLE inhtb () INHERITS (inhta) +-- +TABLE: name="inhtb" schema="" table="inhtb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhtb () INHERITS (inhta)" +== 259 +-- truncate_limit: 100 +CREATE TABLE inhtc () INHERITS (inhtb) +-- +TABLE: name="inhtc" schema="" table="inhtc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhtc () INHERITS (inhtb)" +== 260 +-- truncate_limit: 100 +CREATE TABLE inhtd () INHERITS (inhta, inhtb, inhtc) +-- +TABLE: name="inhtd" schema="" table="inhtd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhtd () INHERITS (inhta, inhtb, inhtc)" +== 261 +-- truncate_limit: 100 +ALTER TABLE inhta ADD COLUMN i int, ADD COLUMN j bigint DEFAULT 1 +-- +TABLE: name="inhta" schema="" table="inhta" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inhta ADD COLUMN i int, ADD COLUMN j bigint DEFAULT 1" +== 262 +-- truncate_limit: 100 +DROP TABLE inhta, inhtb, inhtc, inhtd +-- +TABLE: name="inhta" schema="" table="inhta" ctx=DDL +TABLE: name="inhtb" schema="" table="inhtb" ctx=DDL +TABLE: name="inhtc" schema="" table="inhtc" ctx=DDL +TABLE: name="inhtd" schema="" table="inhtd" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhta, inhtb, inhtc, inhtd" +== 263 +-- truncate_limit: 100 +-- Test for renaming in diamond inheritance +CREATE TABLE inht2 (x int) INHERITS (inht1) +-- +TABLE: name="inht2" schema="" table="inht2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inht2 (x int) INHERITS (inht1)" +== 264 +-- truncate_limit: 100 +CREATE TABLE inht3 (y int) INHERITS (inht1) +-- +TABLE: name="inht3" schema="" table="inht3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inht3 (y int) INHERITS (inht1)" +== 265 +-- truncate_limit: 100 +CREATE TABLE inht4 (z int) INHERITS (inht2, inht3) +-- +TABLE: name="inht4" schema="" table="inht4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inht4 (z int) INHERITS (inht2, inht3)" +== 266 +-- truncate_limit: 100 +ALTER TABLE inht1 RENAME aa TO aaa +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE inht1 RENAME COLUMN aa TO aaa" +== 267 +-- truncate_limit: 100 +CREATE TABLE inhts (d int) INHERITS (inht2, inhs1) +-- +TABLE: name="inhts" schema="" table="inhts" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhts (d int) INHERITS (inht2, inhs1)" +== 268 +-- truncate_limit: 100 +ALTER TABLE inht1 RENAME aaa TO aaaa +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE inht1 RENAME COLUMN aaa TO aaaa" +== 269 +-- truncate_limit: 100 +ALTER TABLE inht1 RENAME b TO bb +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE inht1 RENAME COLUMN b TO bb" +== 270 +-- truncate_limit: 100 +-- to be failed + +WITH RECURSIVE r AS ( + SELECT 'inht1'::regclass AS inhrelid +UNION ALL + SELECT c.inhrelid FROM pg_inherits c, r WHERE r.inhrelid = c.inhparent +) +SELECT a.attrelid::regclass, a.attname, a.attinhcount, e.expected + FROM (SELECT inhrelid, count(*) AS expected FROM pg_inherits + WHERE inhparent IN (SELECT inhrelid FROM r) GROUP BY inhrelid) e + JOIN pg_attribute a ON e.inhrelid = a.attrelid WHERE NOT attislocal + ORDER BY a.attrelid::regclass::name, a.attnum +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +TABLE: name="pg_inherits" schema="" table="pg_inherits" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_inherits" +CTE: "r" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="attislocal" +FILTER: schema="" table="" column="inhparent" +FILTER: schema="" table="r" column="inhrelid" +FILTER: schema="" table="c" column="inhparent" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE r AS (...) SELECT ... FROM (SELECT ... FROM pg_inherits WHERE ... GROUP BY inhreli..." +== 271 +-- truncate_limit: 100 +DROP TABLE inht1, inhs1 CASCADE +-- +TABLE: name="inht1" schema="" table="inht1" ctx=DDL +TABLE: name="inhs1" schema="" table="inhs1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inht1, inhs1 CASCADE" +== 272 +-- truncate_limit: 100 +-- Test non-inheritable indices [UNIQUE, EXCLUDE] constraints +CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE(val1, val2)) +-- +TABLE: name="test_constraints" schema="" table="test_constraints" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_constraints (id int, val1 varchar, val2 int, UNIQUE (val1, val2))" +== 273 +-- truncate_limit: 100 +CREATE TABLE test_constraints_inh () INHERITS (test_constraints) +-- +TABLE: name="test_constraints_inh" schema="" table="test_constraints_inh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_constraints_inh () INHERITS (test_constraints)" +== 274 +-- truncate_limit: 100 +ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key +-- +TABLE: name="test_constraints" schema="" table="test_constraints" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY test_constraints DROP CONSTRAINT test_constraints_val1_val2_key" +== 275 +-- truncate_limit: 100 +DROP TABLE test_constraints_inh +-- +TABLE: name="test_constraints_inh" schema="" table="test_constraints_inh" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_constraints_inh" +== 276 +-- truncate_limit: 100 +DROP TABLE test_constraints +-- +TABLE: name="test_constraints" schema="" table="test_constraints" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_constraints" +== 277 +-- truncate_limit: 100 +CREATE TABLE test_ex_constraints ( + c circle, + EXCLUDE USING gist (c WITH &&) +) +-- +TABLE: name="test_ex_constraints" schema="" table="test_ex_constraints" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_ex_constraints (c circle, EXCLUDE USING gist (c WITH &&))" +== 278 +-- truncate_limit: 100 +CREATE TABLE test_ex_constraints_inh () INHERITS (test_ex_constraints) +-- +TABLE: name="test_ex_constraints_inh" schema="" table="test_ex_constraints_inh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_ex_constraints_inh () INHERITS (test_ex_constraints)" +== 279 +-- truncate_limit: 100 +ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl +-- +TABLE: name="test_ex_constraints" schema="" table="test_ex_constraints" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_ex_constraints DROP CONSTRAINT test_ex_constraints_c_excl" +== 280 +-- truncate_limit: 100 +DROP TABLE test_ex_constraints_inh +-- +TABLE: name="test_ex_constraints_inh" schema="" table="test_ex_constraints_inh" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_ex_constraints_inh" +== 281 +-- truncate_limit: 100 +DROP TABLE test_ex_constraints +-- +TABLE: name="test_ex_constraints" schema="" table="test_ex_constraints" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_ex_constraints" +== 282 +-- truncate_limit: 100 +-- Test non-inheritable foreign key constraints +CREATE TABLE test_primary_constraints(id int PRIMARY KEY) +-- +TABLE: name="test_primary_constraints" schema="" table="test_primary_constraints" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_primary_constraints (id int PRIMARY KEY)" +== 283 +-- truncate_limit: 100 +CREATE TABLE test_foreign_constraints(id1 int REFERENCES test_primary_constraints(id)) +-- +TABLE: name="test_foreign_constraints" schema="" table="test_foreign_constraints" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_foreign_constraints (id1 int REFERENCES test_primary_constraints (id))" +== 284 +-- truncate_limit: 100 +CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints) +-- +TABLE: name="test_foreign_constraints_inh" schema="" table="test_foreign_constraints_inh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_foreign_constraints_inh () INHERITS (test_foreign_constraints)" +== 285 +-- truncate_limit: 100 +ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey +-- +TABLE: name="test_foreign_constraints" schema="" table="test_foreign_constraints" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_foreign_constraints DROP CONSTRAINT test_foreign_constraints_id1_fkey" +== 286 +-- truncate_limit: 100 +DROP TABLE test_foreign_constraints_inh +-- +TABLE: name="test_foreign_constraints_inh" schema="" table="test_foreign_constraints_inh" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_foreign_constraints_inh" +== 287 +-- truncate_limit: 100 +DROP TABLE test_foreign_constraints +-- +TABLE: name="test_foreign_constraints" schema="" table="test_foreign_constraints" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_foreign_constraints" +== 288 +-- truncate_limit: 100 +DROP TABLE test_primary_constraints +-- +TABLE: name="test_primary_constraints" schema="" table="test_primary_constraints" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_primary_constraints" +== 289 +-- truncate_limit: 100 +-- Test foreign key behavior +create table inh_fk_1 (a int primary key) +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_fk_1 (a int PRIMARY KEY)" +== 290 +-- truncate_limit: 100 +insert into inh_fk_1 values (1), (2), (3) +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inh_fk_1 VALUES (1), (2), (3)" +== 291 +-- truncate_limit: 100 +create table inh_fk_2 (x int primary key, y int references inh_fk_1 on delete cascade) +-- +TABLE: name="inh_fk_2" schema="" table="inh_fk_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_fk_2 (x int PRIMARY KEY, y int REFERENCES inh_fk_1 ON DELETE CASCADE)" +== 292 +-- truncate_limit: 100 +insert into inh_fk_2 values (11, 1), (22, 2), (33, 3) +-- +TABLE: name="inh_fk_2" schema="" table="inh_fk_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inh_fk_2 VALUES (11, 1), (22, 2), (33, 3)" +== 293 +-- truncate_limit: 100 +create table inh_fk_2_child () inherits (inh_fk_2) +-- +TABLE: name="inh_fk_2_child" schema="" table="inh_fk_2_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_fk_2_child () INHERITS (inh_fk_2)" +== 294 +-- truncate_limit: 100 +insert into inh_fk_2_child values (111, 1), (222, 2) +-- +TABLE: name="inh_fk_2_child" schema="" table="inh_fk_2_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inh_fk_2_child VALUES (111, 1), (222, 2)" +== 295 +-- truncate_limit: 100 +delete from inh_fk_1 where a = 1 +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM inh_fk_1 WHERE a = 1" +== 296 +-- truncate_limit: 100 +select * from inh_fk_1 order by 1 +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inh_fk_1 ORDER BY 1" +== 297 +-- truncate_limit: 100 +select * from inh_fk_2 order by 1, 2 +-- +TABLE: name="inh_fk_2" schema="" table="inh_fk_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inh_fk_2 ORDER BY 1, 2" +== 298 +-- truncate_limit: 100 +drop table inh_fk_1, inh_fk_2, inh_fk_2_child +-- +TABLE: name="inh_fk_1" schema="" table="inh_fk_1" ctx=DDL +TABLE: name="inh_fk_2" schema="" table="inh_fk_2" ctx=DDL +TABLE: name="inh_fk_2_child" schema="" table="inh_fk_2_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inh_fk_1, inh_fk_2, inh_fk_2_child" +== 299 +-- truncate_limit: 100 +-- Test that parent and child CHECK constraints can be created in either order +create table p1(f1 int) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int)" +== 300 +-- truncate_limit: 100 +create table p1_c1() inherits(p1) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1_c1 () INHERITS (p1)" +== 301 +-- truncate_limit: 100 +alter table p1 add constraint inh_check_constraint1 check (f1 > 0) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 ADD CONSTRAINT inh_check_constraint1 CHECK (f1 > 0)" +== 302 +-- truncate_limit: 100 +alter table p1_c1 add constraint inh_check_constraint1 check (f1 > 0) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1_c1 ADD CONSTRAINT inh_check_constraint1 CHECK (f1 > 0)" +== 303 +-- truncate_limit: 100 +alter table p1_c1 add constraint inh_check_constraint2 check (f1 < 10) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1_c1 ADD CONSTRAINT inh_check_constraint2 CHECK (f1 < 10)" +== 304 +-- truncate_limit: 100 +alter table p1 add constraint inh_check_constraint2 check (f1 < 10) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 ADD CONSTRAINT inh_check_constraint2 CHECK (f1 < 10)" +== 305 +-- truncate_limit: 100 +select conrelid::regclass::text as relname, conname, conislocal, coninhcount +from pg_constraint where conname like 'inh\_check\_constraint%' +order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conname LIKE E'inh\\\\_check\\\\_constraint%' ORDER BY 1, 2" +== 306 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 307 +-- truncate_limit: 100 +|-- +-- Test DROP behavior of multiply-defined CHECK constraints +|-- +create table p1(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int CONSTRAINT f1_pos CHECK (f1 > 0))" +== 308 +-- truncate_limit: 100 +create table p1_c1 (f1 int constraint f1_pos CHECK (f1 > 0)) inherits (p1) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1_c1 (f1 int CONSTRAINT f1_pos CHECK (f1 > 0)) INHERITS (p1)" +== 309 +-- truncate_limit: 100 +alter table p1_c1 drop constraint f1_pos +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1_c1 DROP CONSTRAINT f1_pos" +== 310 +-- truncate_limit: 100 +alter table p1 drop constraint f1_pos +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 DROP CONSTRAINT f1_pos" +== 311 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 312 +-- truncate_limit: 100 +create table p1(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int CONSTRAINT f1_pos CHECK (f1 > 0))" +== 313 +-- truncate_limit: 100 +create table p2(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p2 (f1 int CONSTRAINT f1_pos CHECK (f1 > 0))" +== 314 +-- truncate_limit: 100 +create table p1p2_c1 (f1 int) inherits (p1, p2) +-- +TABLE: name="p1p2_c1" schema="" table="p1p2_c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1p2_c1 (f1 int) INHERITS (p1, p2)" +== 315 +-- truncate_limit: 100 +create table p1p2_c2 (f1 int constraint f1_pos CHECK (f1 > 0)) inherits (p1, p2) +-- +TABLE: name="p1p2_c2" schema="" table="p1p2_c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1p2_c2 (f1 int CONSTRAINT f1_pos CHECK (f1 > 0)) INHERITS (p1, p2)" +== 316 +-- truncate_limit: 100 +alter table p2 drop constraint f1_pos +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p2 DROP CONSTRAINT f1_pos" +== 317 +-- truncate_limit: 100 +alter table p1 drop constraint f1_pos +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 DROP CONSTRAINT f1_pos" +== 318 +-- truncate_limit: 100 +drop table p1, p2 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1, p2 CASCADE" +== 319 +-- truncate_limit: 100 +create table p1(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int CONSTRAINT f1_pos CHECK (f1 > 0))" +== 320 +-- truncate_limit: 100 +create table p1_c1() inherits (p1) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1_c1 () INHERITS (p1)" +== 321 +-- truncate_limit: 100 +create table p1_c2() inherits (p1) +-- +TABLE: name="p1_c2" schema="" table="p1_c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1_c2 () INHERITS (p1)" +== 322 +-- truncate_limit: 100 +create table p1_c1c2() inherits (p1_c1, p1_c2) +-- +TABLE: name="p1_c1c2" schema="" table="p1_c1c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1_c1c2 () INHERITS (p1_c1, p1_c2)" +== 323 +-- truncate_limit: 100 +alter table p1 drop constraint f1_pos +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 DROP CONSTRAINT f1_pos" +== 324 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 325 +-- truncate_limit: 100 +create table p1(f1 int constraint f1_pos CHECK (f1 > 0)) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1 (f1 int CONSTRAINT f1_pos CHECK (f1 > 0))" +== 326 +-- truncate_limit: 100 +create table p1_c1() inherits (p1) +-- +TABLE: name="p1_c1" schema="" table="p1_c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1_c1 () INHERITS (p1)" +== 327 +-- truncate_limit: 100 +create table p1_c2(constraint f1_pos CHECK (f1 > 0)) inherits (p1) +-- +TABLE: name="p1_c2" schema="" table="p1_c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1_c2 (CONSTRAINT f1_pos CHECK (f1 > 0)) INHERITS (p1)" +== 328 +-- truncate_limit: 100 +create table p1_c1c2() inherits (p1_c1, p1_c2, p1) +-- +TABLE: name="p1_c1c2" schema="" table="p1_c1c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE p1_c1c2 () INHERITS (p1_c1, p1_c2, p1)" +== 329 +-- truncate_limit: 100 +alter table p1_c2 drop constraint f1_pos +-- +TABLE: name="p1_c2" schema="" table="p1_c2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1_c2 DROP CONSTRAINT f1_pos" +== 330 +-- truncate_limit: 100 +alter table p1 drop constraint f1_pos +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1 DROP CONSTRAINT f1_pos" +== 331 +-- truncate_limit: 100 +alter table p1_c1c2 drop constraint f1_pos +-- +TABLE: name="p1_c1c2" schema="" table="p1_c1c2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1_c1c2 DROP CONSTRAINT f1_pos" +== 332 +-- truncate_limit: 100 +alter table p1_c2 drop constraint f1_pos +-- +TABLE: name="p1_c2" schema="" table="p1_c2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE p1_c2 DROP CONSTRAINT f1_pos" +== 333 +-- truncate_limit: 100 +drop table p1 cascade +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p1 CASCADE" +== 334 +-- truncate_limit: 100 +-- Test that a valid child can have not-valid parent, but not vice versa +create table invalid_check_con(f1 int) +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE invalid_check_con (f1 int)" +== 335 +-- truncate_limit: 100 +create table invalid_check_con_child() inherits(invalid_check_con) +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE invalid_check_con_child () INHERITS (invalid_check_con)" +== 336 +-- truncate_limit: 100 +alter table invalid_check_con_child add constraint inh_check_constraint check(f1 > 0) not valid +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE invalid_check_con_child ADD CONSTRAINT inh_check_constraint CHECK (f1 > 0) NOT VALID" +== 337 +-- truncate_limit: 100 +alter table invalid_check_con add constraint inh_check_constraint check(f1 > 0) +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE invalid_check_con ADD CONSTRAINT inh_check_constraint CHECK (f1 > 0)" +== 338 +-- truncate_limit: 100 +-- fail +alter table invalid_check_con_child drop constraint inh_check_constraint +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE invalid_check_con_child DROP CONSTRAINT inh_check_constraint" +== 339 +-- truncate_limit: 100 +insert into invalid_check_con values(0) +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO invalid_check_con VALUES (0)" +== 340 +-- truncate_limit: 100 +alter table invalid_check_con_child add constraint inh_check_constraint check(f1 > 0) +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE invalid_check_con_child ADD CONSTRAINT inh_check_constraint CHECK (f1 > 0)" +== 341 +-- truncate_limit: 100 +alter table invalid_check_con add constraint inh_check_constraint check(f1 > 0) not valid +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE invalid_check_con ADD CONSTRAINT inh_check_constraint CHECK (f1 > 0) NOT VALID" +== 342 +-- truncate_limit: 100 +insert into invalid_check_con values(0) +-- +TABLE: name="invalid_check_con" schema="" table="invalid_check_con" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO invalid_check_con VALUES (0)" +== 343 +-- truncate_limit: 100 +-- fail +insert into invalid_check_con_child values(0) +-- +TABLE: name="invalid_check_con_child" schema="" table="invalid_check_con_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO invalid_check_con_child VALUES (0)" +== 344 +-- truncate_limit: 100 +-- fail + +select conrelid::regclass::text as relname, conname, + convalidated, conislocal, coninhcount, connoinherit +from pg_constraint where conname like 'inh\_check\_constraint%' +order by 1, 2 +-- +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +FILTER: schema="" table="" column="conname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_constraint WHERE conname LIKE E'inh\\\\_check\\\\_constraint%' ORDER BY 1, 2" +== 345 +-- truncate_limit: 100 +-- We don't drop the invalid_check_con* tables, to test dump/reload with + +|-- +-- Test parameterized append plans for inheritance trees +|-- + +create temp table patest0 (id, x) as + select x, x from generate_series(0,1000) x +-- +TABLE: name="patest0" schema="" table="patest0" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE patest0(id, x) AS SELECT x, x FROM generate_series(0, 1000) x" +== 346 +-- truncate_limit: 100 +create temp table patest1() inherits (patest0) +-- +TABLE: name="patest1" schema="" table="patest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE patest1 () INHERITS (patest0)" +== 347 +-- truncate_limit: 100 +insert into patest1 + select x, x from generate_series(0,1000) x +-- +TABLE: name="patest1" schema="" table="patest1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO patest1 SELECT x, x FROM generate_series(0, 1000) x" +== 348 +-- truncate_limit: 100 +create temp table patest2() inherits (patest0) +-- +TABLE: name="patest2" schema="" table="patest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE patest2 () INHERITS (patest0)" +== 349 +-- truncate_limit: 100 +insert into patest2 + select x, x from generate_series(0,1000) x +-- +TABLE: name="patest2" schema="" table="patest2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO patest2 SELECT x, x FROM generate_series(0, 1000) x" +== 350 +-- truncate_limit: 100 +create index patest0i on patest0(id) +-- +TABLE: name="patest0" schema="" table="patest0" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX patest0i ON patest0 USING btree (id)" +== 351 +-- truncate_limit: 100 +create index patest1i on patest1(id) +-- +TABLE: name="patest1" schema="" table="patest1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX patest1i ON patest1 USING btree (id)" +== 352 +-- truncate_limit: 100 +create index patest2i on patest2(id) +-- +TABLE: name="patest2" schema="" table="patest2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX patest2i ON patest2 USING btree (id)" +== 353 +-- truncate_limit: 100 +analyze patest0 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE patest0" +== 354 +-- truncate_limit: 100 +analyze patest1 +-- +TABLE: name="patest1" schema="" table="patest1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE patest1" +== 355 +-- truncate_limit: 100 +analyze patest2 +-- +TABLE: name="patest2" schema="" table="patest2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE patest2" +== 356 +-- truncate_limit: 100 +explain (costs off) +select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM patest0 JOIN (SELECT f1 FROM int4_tbl LIMIT 1) ss ON id = f1" +== 357 +-- truncate_limit: 100 +select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM patest0 JOIN (SELECT f1 FROM int4_tbl LIMIT 1) ss ON id = f1" +== 358 +-- truncate_limit: 100 +drop index patest2i +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX patest2i" +== 359 +-- truncate_limit: 100 +explain (costs off) +select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM patest0 JOIN (SELECT f1 FROM int4_tbl LIMIT 1) ss ON id = f1" +== 360 +-- truncate_limit: 100 +select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1 +-- +TABLE: name="patest0" schema="" table="patest0" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM patest0 JOIN (SELECT f1 FROM int4_tbl LIMIT 1) ss ON id = f1" +== 361 +-- truncate_limit: 100 +drop table patest0 cascade +-- +TABLE: name="patest0" schema="" table="patest0" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE patest0 CASCADE" +== 362 +-- truncate_limit: 100 +|-- +-- Test merge-append plans for inheritance trees +|-- + +create table matest0 (id serial primary key, name text) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE matest0 (id serial PRIMARY KEY, name text)" +== 363 +-- truncate_limit: 100 +create table matest1 (id integer primary key) inherits (matest0) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE matest1 (id int PRIMARY KEY) INHERITS (matest0)" +== 364 +-- truncate_limit: 100 +create table matest2 (id integer primary key) inherits (matest0) +-- +TABLE: name="matest2" schema="" table="matest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE matest2 (id int PRIMARY KEY) INHERITS (matest0)" +== 365 +-- truncate_limit: 100 +create table matest3 (id integer primary key) inherits (matest0) +-- +TABLE: name="matest3" schema="" table="matest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE matest3 (id int PRIMARY KEY) INHERITS (matest0)" +== 366 +-- truncate_limit: 100 +create index matest0i on matest0 ((1-id)) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX matest0i ON matest0 USING btree ((1 - id))" +== 367 +-- truncate_limit: 100 +create index matest1i on matest1 ((1-id)) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX matest1i ON matest1 USING btree ((1 - id))" +== 368 +-- truncate_limit: 100 +-- create index matest2i on matest2 ((1-id)); -- intentionally missing +create index matest3i on matest3 ((1-id)) +-- +TABLE: name="matest3" schema="" table="matest3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX matest3i ON matest3 USING btree ((1 - id))" +== 369 +-- truncate_limit: 100 +insert into matest1 (name) values ('Test 1') +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO matest1 (name) VALUES ('Test 1')" +== 370 +-- truncate_limit: 100 +insert into matest1 (name) values ('Test 2') +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO matest1 (name) VALUES ('Test 2')" +== 371 +-- truncate_limit: 100 +insert into matest2 (name) values ('Test 3') +-- +TABLE: name="matest2" schema="" table="matest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO matest2 (name) VALUES ('Test 3')" +== 372 +-- truncate_limit: 100 +insert into matest2 (name) values ('Test 4') +-- +TABLE: name="matest2" schema="" table="matest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO matest2 (name) VALUES ('Test 4')" +== 373 +-- truncate_limit: 100 +insert into matest3 (name) values ('Test 5') +-- +TABLE: name="matest3" schema="" table="matest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO matest3 (name) VALUES ('Test 5')" +== 374 +-- truncate_limit: 100 +insert into matest3 (name) values ('Test 6') +-- +TABLE: name="matest3" schema="" table="matest3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO matest3 (name) VALUES ('Test 6')" +== 375 +-- truncate_limit: 100 +set enable_indexscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 376 +-- truncate_limit: 100 +-- force use of seqscan/sort, so no merge +explain (verbose, costs off) select * from matest0 order by 1-id +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM matest0 ORDER BY 1 - id" +== 377 +-- truncate_limit: 100 +select * from matest0 order by 1-id +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM matest0 ORDER BY 1 - id" +== 378 +-- truncate_limit: 100 +explain (verbose, costs off) select min(1-id) from matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT min(1 - id) FROM matest0" +== 379 +-- truncate_limit: 100 +select min(1-id) from matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(1 - id) FROM matest0" +== 380 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 381 +-- truncate_limit: 100 +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 382 +-- truncate_limit: 100 +-- plan with fewest seqscans should be merge +set enable_parallel_append = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_append TO OFF" +== 383 +-- truncate_limit: 100 +-- Don't let parallel-append interfere +explain (verbose, costs off) select * from matest0 order by 1-id +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM matest0 ORDER BY 1 - id" +== 384 +-- truncate_limit: 100 +select * from matest0 order by 1-id +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM matest0 ORDER BY 1 - id" +== 385 +-- truncate_limit: 100 +explain (verbose, costs off) select min(1-id) from matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT min(1 - id) FROM matest0" +== 386 +-- truncate_limit: 100 +select min(1-id) from matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(1 - id) FROM matest0" +== 387 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 388 +-- truncate_limit: 100 +reset enable_parallel_append +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_parallel_append" +== 389 +-- truncate_limit: 100 +explain (verbose, costs off) -- bug #18652 +select 1 - id as c from +(select id from matest3 t1 union all select id * 2 from matest3 t2) ss +order by c +-- +TABLE: name="matest3" schema="" table="matest3" ctx=Select +TABLE: name="matest3" schema="" table="matest3" ctx=Select +ALIAS: "t1"="matest3" +ALIAS: "t2"="matest3" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT 1 - id AS c FROM (SELECT id FROM matest3 t1 UNION ALL SELECT ..." +== 390 +-- truncate_limit: 100 +select 1 - id as c from +(select id from matest3 t1 union all select id * 2 from matest3 t2) ss +order by c +-- +TABLE: name="matest3" schema="" table="matest3" ctx=Select +TABLE: name="matest3" schema="" table="matest3" ctx=Select +ALIAS: "t1"="matest3" +ALIAS: "t2"="matest3" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT id FROM matest3 t1 UNION ALL SELECT ... FROM matest3 t2) ss ORDER BY c" +== 391 +-- truncate_limit: 100 +drop table matest0 cascade +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE matest0 CASCADE" +== 392 +-- truncate_limit: 100 +|-- +-- Check that use of an index with an extraneous column doesn't produce +-- a plan with extraneous sorting +|-- + +create table matest0 (a int, b int, c int, d int) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE matest0 (a int, b int, c int, d int)" +== 393 +-- truncate_limit: 100 +create table matest1 () inherits(matest0) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE matest1 () INHERITS (matest0)" +== 394 +-- truncate_limit: 100 +create index matest0i on matest0 (b, c) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX matest0i ON matest0 USING btree (b, c)" +== 395 +-- truncate_limit: 100 +create index matest1i on matest1 (b, c) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX matest1i ON matest1 USING btree (b, c)" +== 396 +-- truncate_limit: 100 +set enable_nestloop = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 397 +-- truncate_limit: 100 +-- we want a plan with two MergeAppends + +explain (costs off) +select t1.* from matest0 t1, matest0 t2 +where t1.b = t2.b and t2.c = t2.d +order by t1.b limit 10 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +TABLE: name="matest0" schema="" table="matest0" ctx=Select +ALIAS: "t1"="matest0" +ALIAS: "t2"="matest0" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t2" column="d" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM matest0 t1, matest0 t2 WHERE t1.b = t2.b AND t2.c = t2.d ORD..." +== 398 +-- truncate_limit: 100 +reset enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 399 +-- truncate_limit: 100 +drop table matest0 cascade +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE matest0 CASCADE" +== 400 +-- truncate_limit: 100 +-- Test a MergeAppend plan where one child requires a sort +create table matest0(a int primary key) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE matest0 (a int PRIMARY KEY)" +== 401 +-- truncate_limit: 100 +create table matest1() inherits (matest0) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE matest1 () INHERITS (matest0)" +== 402 +-- truncate_limit: 100 +insert into matest0 select generate_series(1, 400) +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO matest0 SELECT generate_series(1, 400)" +== 403 +-- truncate_limit: 100 +insert into matest1 select generate_series(1, 200) +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO matest1 SELECT generate_series(1, 200)" +== 404 +-- truncate_limit: 100 +analyze matest0 +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE matest0" +== 405 +-- truncate_limit: 100 +analyze matest1 +-- +TABLE: name="matest1" schema="" table="matest1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE matest1" +== 406 +-- truncate_limit: 100 +explain (costs off) +select * from matest0 where a < 100 order by a +-- +TABLE: name="matest0" schema="" table="matest0" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM matest0 WHERE a < 100 ORDER BY a" +== 407 +-- truncate_limit: 100 +drop table matest0 cascade +-- +TABLE: name="matest0" schema="" table="matest0" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE matest0 CASCADE" +== 408 +-- truncate_limit: 100 +|-- +-- Test merge-append for UNION ALL append relations +|-- + +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 409 +-- truncate_limit: 100 +set enable_indexscan = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 410 +-- truncate_limit: 100 +set enable_bitmapscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 411 +-- truncate_limit: 100 +-- Check handling of duplicated, constant, or volatile targetlist items +explain (costs off) +SELECT thousand, tenthous FROM tenk1 +UNION ALL +SELECT thousand, thousand FROM tenk1 +ORDER BY thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, tenthous FROM tenk1 UNION ALL SELECT thousand, thousand FROM..." +== 412 +-- truncate_limit: 100 +explain (costs off) +SELECT thousand, tenthous, thousand+tenthous AS x FROM tenk1 +UNION ALL +SELECT 42, 42, hundred FROM tenk1 +ORDER BY thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, tenthous, thousand + tenthous AS x FROM tenk1 UNION ALL SELE..." +== 413 +-- truncate_limit: 100 +explain (costs off) +SELECT thousand, tenthous FROM tenk1 +UNION ALL +SELECT thousand, random()::integer FROM tenk1 +ORDER BY thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, tenthous FROM tenk1 UNION ALL SELECT thousand, random()::int..." +== 414 +-- truncate_limit: 100 +-- Check min/max aggregate optimization +explain (costs off) +SELECT min(x) FROM + (SELECT unique1 AS x FROM tenk1 a + UNION ALL + SELECT unique2 AS x FROM tenk1 b) s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT min(x) FROM (SELECT unique1 AS x FROM tenk1 a UNION ALL SELECT unique2..." +== 415 +-- truncate_limit: 100 +explain (costs off) +SELECT min(y) FROM + (SELECT unique1 AS x, unique1 AS y FROM tenk1 a + UNION ALL + SELECT unique2 AS x, unique2 AS y FROM tenk1 b) s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT min(y) FROM (SELECT unique1 AS x, unique1 AS y FROM tenk1 a UNION ALL ..." +== 416 +-- truncate_limit: 100 +-- XXX planner doesn't recognize that index on unique2 is sufficiently sorted +explain (costs off) +SELECT x, y FROM + (SELECT thousand AS x, tenthous AS y FROM tenk1 a + UNION ALL + SELECT unique2 AS x, unique2 AS y FROM tenk1 b) s +ORDER BY x, y +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x, y FROM (SELECT thousand AS x, tenthous AS y FROM tenk1 a UNION ALL ..." +== 417 +-- truncate_limit: 100 +-- exercise rescan code path via a repeatedly-evaluated subquery +explain (costs off) +SELECT + ARRAY(SELECT f.i FROM ( + (SELECT d + g.i FROM generate_series(4, 30, 3) d ORDER BY 1) + UNION ALL + (SELECT d + g.i FROM generate_series(0, 30, 5) d ORDER BY 1) + ) f(i) + ORDER BY f.i LIMIT 10) +FROM generate_series(1, 3) g(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ARRAY(SELECT f.i FROM ((SELECT d + g.i FROM generate_series(4, 30, 3) ..." +== 418 +-- truncate_limit: 100 +SELECT + ARRAY(SELECT f.i FROM ( + (SELECT d + g.i FROM generate_series(4, 30, 3) d ORDER BY 1) + UNION ALL + (SELECT d + g.i FROM generate_series(0, 30, 5) d ORDER BY 1) + ) f(i) + ORDER BY f.i LIMIT 10) +FROM generate_series(1, 3) g(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 3) g(i)" +== 419 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 420 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 421 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 422 +-- truncate_limit: 100 +|-- +-- Check handling of MULTIEXPR SubPlans in inherited updates +|-- +create table inhpar(f1 int, f2 name) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhpar (f1 int, f2 name)" +== 423 +-- truncate_limit: 100 +create table inhcld(f2 name, f1 int) +-- +TABLE: name="inhcld" schema="" table="inhcld" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhcld (f2 name, f1 int)" +== 424 +-- truncate_limit: 100 +alter table inhcld inherit inhpar +-- +TABLE: name="inhcld" schema="" table="inhcld" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inhcld INHERIT inhpar" +== 425 +-- truncate_limit: 100 +insert into inhpar select x, x::text from generate_series(1,5) x +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhpar SELECT x, x::text FROM generate_series(1, 5) x" +== 426 +-- truncate_limit: 100 +insert into inhcld select x::text, x from generate_series(6,10) x +-- +TABLE: name="inhcld" schema="" table="inhcld" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhcld SELECT x::text, x FROM generate_series(6, 10) x" +== 427 +-- truncate_limit: 100 +explain (verbose, costs off) +update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit 1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="inhpar" +STMT: ExplainStmt +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) UPDATE inhpar i SET (f1, f2) = (SELECT i.f1, i.f2 || '-' FROM int4_t..." +== 428 +-- truncate_limit: 100 +update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit 1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="inhpar" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE inhpar i SET (f1, f2) = (SELECT i.f1, i.f2 || '-' FROM int4_tbl LIMIT 1)" +== 429 +-- truncate_limit: 100 +select * from inhpar +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inhpar" +== 430 +-- truncate_limit: 100 +drop table inhpar cascade +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhpar CASCADE" +== 431 +-- truncate_limit: 100 +|-- +-- And the same for partitioned cases +|-- +create table inhpar(f1 int primary key, f2 name) partition by range (f1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhpar (f1 int PRIMARY KEY, f2 name) PARTITION BY RANGE (f1)" +== 432 +-- truncate_limit: 100 +create table inhcld1(f2 name, f1 int primary key) +-- +TABLE: name="inhcld1" schema="" table="inhcld1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhcld1 (f2 name, f1 int PRIMARY KEY)" +== 433 +-- truncate_limit: 100 +create table inhcld2(f1 int primary key, f2 name) +-- +TABLE: name="inhcld2" schema="" table="inhcld2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inhcld2 (f1 int PRIMARY KEY, f2 name)" +== 434 +-- truncate_limit: 100 +alter table inhpar attach partition inhcld1 for values from (1) to (5) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inhpar ATTACH PARTITION inhcld1 FOR VALUES FROM (1) TO (5)" +== 435 +-- truncate_limit: 100 +alter table inhpar attach partition inhcld2 for values from (5) to (100) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inhpar ATTACH PARTITION inhcld2 FOR VALUES FROM (5) TO (100)" +== 436 +-- truncate_limit: 100 +insert into inhpar select x, x::text from generate_series(1,10) x +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhpar SELECT x, x::text FROM generate_series(1, 10) x" +== 437 +-- truncate_limit: 100 +explain (verbose, costs off) +update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit 1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="inhpar" +STMT: ExplainStmt +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) UPDATE inhpar i SET (f1, f2) = (SELECT i.f1, i.f2 || '-' FROM int4_t..." +== 438 +-- truncate_limit: 100 +update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit 1) +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="inhpar" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE inhpar i SET (f1, f2) = (SELECT i.f1, i.f2 || '-' FROM int4_tbl LIMIT 1)" +== 439 +-- truncate_limit: 100 +select * from inhpar +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inhpar" +== 440 +-- truncate_limit: 100 +-- Also check ON CONFLICT +insert into inhpar as i values (3), (7) on conflict (f1) + do update set (f1, f2) = (select i.f1, i.f2 || '+') +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DML +ALIAS: "i"="inhpar" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inhpar AS i VALUES (3), (7) ON CONFLICT (f1) DO UPDATE SET (f1, f2) = (SELECT ...)" +== 441 +-- truncate_limit: 100 +select * from inhpar order by f1 +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inhpar ORDER BY f1" +== 442 +-- truncate_limit: 100 +-- tuple order might be unstable here + +drop table inhpar cascade +-- +TABLE: name="inhpar" schema="" table="inhpar" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inhpar CASCADE" +== 443 +-- truncate_limit: 100 +|-- +-- Check handling of a constant-null CHECK constraint +|-- +create table cnullparent (f1 int) +-- +TABLE: name="cnullparent" schema="" table="cnullparent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cnullparent (f1 int)" +== 444 +-- truncate_limit: 100 +create table cnullchild (check (f1 = 1 or f1 = null)) inherits(cnullparent) +-- +TABLE: name="cnullchild" schema="" table="cnullchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cnullchild (CHECK (f1 = 1 OR f1 = NULL)) INHERITS (cnullparent)" +== 445 +-- truncate_limit: 100 +insert into cnullchild values(1) +-- +TABLE: name="cnullchild" schema="" table="cnullchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cnullchild VALUES (1)" +== 446 +-- truncate_limit: 100 +insert into cnullchild values(2) +-- +TABLE: name="cnullchild" schema="" table="cnullchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cnullchild VALUES (2)" +== 447 +-- truncate_limit: 100 +insert into cnullchild values(null) +-- +TABLE: name="cnullchild" schema="" table="cnullchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cnullchild VALUES (NULL)" +== 448 +-- truncate_limit: 100 +select * from cnullparent +-- +TABLE: name="cnullparent" schema="" table="cnullparent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cnullparent" +== 449 +-- truncate_limit: 100 +select * from cnullparent where f1 = 2 +-- +TABLE: name="cnullparent" schema="" table="cnullparent" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cnullparent WHERE f1 = 2" +== 450 +-- truncate_limit: 100 +drop table cnullparent cascade +-- +TABLE: name="cnullparent" schema="" table="cnullparent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cnullparent CASCADE" +== 451 +-- truncate_limit: 100 +|-- +-- Mixed ownership inheritance tree +|-- +create role regress_alice +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_alice" +== 452 +-- truncate_limit: 100 +create role regress_bob +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_bob" +== 453 +-- truncate_limit: 100 +grant all on schema public to regress_alice, regress_bob +-- +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON SCHEMA public TO regress_alice, regress_bob" +== 454 +-- truncate_limit: 100 +grant regress_alice to regress_bob +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_alice TO regress_bob" +== 455 +-- truncate_limit: 100 +set session authorization regress_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alice" +== 456 +-- truncate_limit: 100 +create table inh_parent (a int not null) +-- +TABLE: name="inh_parent" schema="" table="inh_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_parent (a int NOT NULL)" +== 457 +-- truncate_limit: 100 +set session authorization regress_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_bob" +== 458 +-- truncate_limit: 100 +create table inh_child () inherits (inh_parent) +-- +TABLE: name="inh_child" schema="" table="inh_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_child () INHERITS (inh_parent)" +== 459 +-- truncate_limit: 100 +set session authorization regress_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alice" +== 460 +-- truncate_limit: 100 +-- alice can't do this: she doesn't own inh_child +alter table inh_parent alter a drop not null +-- +TABLE: name="inh_parent" schema="" table="inh_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inh_parent ALTER COLUMN a DROP NOT NULL" +== 461 +-- truncate_limit: 100 +set session authorization regress_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_bob" +== 462 +-- truncate_limit: 100 +alter table inh_parent alter a drop not null +-- +TABLE: name="inh_parent" schema="" table="inh_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE inh_parent ALTER COLUMN a DROP NOT NULL" +== 463 +-- truncate_limit: 100 +reset session authorization +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 464 +-- truncate_limit: 100 +drop table inh_parent, inh_child +-- +TABLE: name="inh_parent" schema="" table="inh_parent" ctx=DDL +TABLE: name="inh_child" schema="" table="inh_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inh_parent, inh_child" +== 465 +-- truncate_limit: 100 +revoke all on schema public from regress_alice, regress_bob +-- +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON SCHEMA public FROM regress_alice, regress_bob" +== 466 +-- truncate_limit: 100 +drop role regress_alice, regress_bob +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_alice, regress_bob" +== 467 +-- truncate_limit: 100 +|-- +-- Check use of temporary tables with inheritance trees +|-- +create table inh_perm_parent (a1 int) +-- +TABLE: name="inh_perm_parent" schema="" table="inh_perm_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_perm_parent (a1 int)" +== 468 +-- truncate_limit: 100 +create temp table inh_temp_parent (a1 int) +-- +TABLE: name="inh_temp_parent" schema="" table="inh_temp_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE inh_temp_parent (a1 int)" +== 469 +-- truncate_limit: 100 +create temp table inh_temp_child () inherits (inh_perm_parent) +-- +TABLE: name="inh_temp_child" schema="" table="inh_temp_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE inh_temp_child () INHERITS (inh_perm_parent)" +== 470 +-- truncate_limit: 100 +-- ok +create table inh_perm_child () inherits (inh_temp_parent) +-- +TABLE: name="inh_perm_child" schema="" table="inh_perm_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_perm_child () INHERITS (inh_temp_parent)" +== 471 +-- truncate_limit: 100 +-- error +create temp table inh_temp_child_2 () inherits (inh_temp_parent) +-- +TABLE: name="inh_temp_child_2" schema="" table="inh_temp_child_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE inh_temp_child_2 () INHERITS (inh_temp_parent)" +== 472 +-- truncate_limit: 100 +-- ok +insert into inh_perm_parent values (1) +-- +TABLE: name="inh_perm_parent" schema="" table="inh_perm_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inh_perm_parent VALUES (1)" +== 473 +-- truncate_limit: 100 +insert into inh_temp_parent values (2) +-- +TABLE: name="inh_temp_parent" schema="" table="inh_temp_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inh_temp_parent VALUES (2)" +== 474 +-- truncate_limit: 100 +insert into inh_temp_child values (3) +-- +TABLE: name="inh_temp_child" schema="" table="inh_temp_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inh_temp_child VALUES (3)" +== 475 +-- truncate_limit: 100 +insert into inh_temp_child_2 values (4) +-- +TABLE: name="inh_temp_child_2" schema="" table="inh_temp_child_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inh_temp_child_2 VALUES (4)" +== 476 +-- truncate_limit: 100 +select tableoid::regclass, a1 from inh_perm_parent +-- +TABLE: name="inh_perm_parent" schema="" table="inh_perm_parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, a1 FROM inh_perm_parent" +== 477 +-- truncate_limit: 100 +select tableoid::regclass, a1 from inh_temp_parent +-- +TABLE: name="inh_temp_parent" schema="" table="inh_temp_parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, a1 FROM inh_temp_parent" +== 478 +-- truncate_limit: 100 +drop table inh_perm_parent cascade +-- +TABLE: name="inh_perm_parent" schema="" table="inh_perm_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inh_perm_parent CASCADE" +== 479 +-- truncate_limit: 100 +drop table inh_temp_parent cascade +-- +TABLE: name="inh_temp_parent" schema="" table="inh_temp_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inh_temp_parent CASCADE" +== 480 +-- truncate_limit: 100 +|-- +-- Check that constraint exclusion works correctly with partitions using +-- implicit constraints generated from the partition bound information. +|-- +create table list_parted ( + a varchar +) partition by list (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted (a varchar) PARTITION BY LIST (a)" +== 481 +-- truncate_limit: 100 +create table part_ab_cd partition of list_parted for values in ('ab', 'cd') +-- +TABLE: name="part_ab_cd" schema="" table="part_ab_cd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ab_cd PARTITION OF list_parted FOR VALUES IN ('ab', 'cd')" +== 482 +-- truncate_limit: 100 +create table part_ef_gh partition of list_parted for values in ('ef', 'gh') +-- +TABLE: name="part_ef_gh" schema="" table="part_ef_gh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ef_gh PARTITION OF list_parted FOR VALUES IN ('ef', 'gh')" +== 483 +-- truncate_limit: 100 +create table part_null_xy partition of list_parted for values in (null, 'xy') +-- +TABLE: name="part_null_xy" schema="" table="part_null_xy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_null_xy PARTITION OF list_parted FOR VALUES IN (NULL, 'xy')" +== 484 +-- truncate_limit: 100 +explain (costs off) select * from list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM list_parted" +== 485 +-- truncate_limit: 100 +explain (costs off) select * from list_parted where a is null +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM list_parted WHERE a IS NULL" +== 486 +-- truncate_limit: 100 +explain (costs off) select * from list_parted where a is not null +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM list_parted WHERE a IS NOT NULL" +== 487 +-- truncate_limit: 100 +explain (costs off) select * from list_parted where a in ('ab', 'cd', 'ef') +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM list_parted WHERE a IN ('ab', 'cd', 'ef')" +== 488 +-- truncate_limit: 100 +explain (costs off) select * from list_parted where a = 'ab' or a in (null, 'cd') +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM list_parted WHERE a = 'ab' OR a IN (NULL, 'cd')" +== 489 +-- truncate_limit: 100 +explain (costs off) select * from list_parted where a = 'ab' +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM list_parted WHERE a = 'ab'" +== 490 +-- truncate_limit: 100 +create table range_list_parted ( + a int, + b char(2) +) partition by range (a) +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_list_parted (a int, b char(2)) PARTITION BY RANGE (a)" +== 491 +-- truncate_limit: 100 +create table part_1_10 partition of range_list_parted for values from (1) to (10) partition by list (b) +-- +TABLE: name="part_1_10" schema="" table="part_1_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_1_10 PARTITION OF range_list_parted FOR VALUES FROM (1) TO (10) PARTITION BY LI..." +== 492 +-- truncate_limit: 100 +create table part_1_10_ab partition of part_1_10 for values in ('ab') +-- +TABLE: name="part_1_10_ab" schema="" table="part_1_10_ab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_1_10_ab PARTITION OF part_1_10 FOR VALUES IN ('ab')" +== 493 +-- truncate_limit: 100 +create table part_1_10_cd partition of part_1_10 for values in ('cd') +-- +TABLE: name="part_1_10_cd" schema="" table="part_1_10_cd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_1_10_cd PARTITION OF part_1_10 FOR VALUES IN ('cd')" +== 494 +-- truncate_limit: 100 +create table part_10_20 partition of range_list_parted for values from (10) to (20) partition by list (b) +-- +TABLE: name="part_10_20" schema="" table="part_10_20" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_10_20 PARTITION OF range_list_parted FOR VALUES FROM (10) TO (20) PARTITION BY ..." +== 495 +-- truncate_limit: 100 +create table part_10_20_ab partition of part_10_20 for values in ('ab') +-- +TABLE: name="part_10_20_ab" schema="" table="part_10_20_ab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_10_20_ab PARTITION OF part_10_20 FOR VALUES IN ('ab')" +== 496 +-- truncate_limit: 100 +create table part_10_20_cd partition of part_10_20 for values in ('cd') +-- +TABLE: name="part_10_20_cd" schema="" table="part_10_20_cd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_10_20_cd PARTITION OF part_10_20 FOR VALUES IN ('cd')" +== 497 +-- truncate_limit: 100 +create table part_21_30 partition of range_list_parted for values from (21) to (30) partition by list (b) +-- +TABLE: name="part_21_30" schema="" table="part_21_30" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_21_30 PARTITION OF range_list_parted FOR VALUES FROM (21) TO (30) PARTITION BY ..." +== 498 +-- truncate_limit: 100 +create table part_21_30_ab partition of part_21_30 for values in ('ab') +-- +TABLE: name="part_21_30_ab" schema="" table="part_21_30_ab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_21_30_ab PARTITION OF part_21_30 FOR VALUES IN ('ab')" +== 499 +-- truncate_limit: 100 +create table part_21_30_cd partition of part_21_30 for values in ('cd') +-- +TABLE: name="part_21_30_cd" schema="" table="part_21_30_cd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_21_30_cd PARTITION OF part_21_30 FOR VALUES IN ('cd')" +== 500 +-- truncate_limit: 100 +create table part_40_inf partition of range_list_parted for values from (40) to (maxvalue) partition by list (b) +-- +TABLE: name="part_40_inf" schema="" table="part_40_inf" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_40_inf PARTITION OF range_list_parted FOR VALUES FROM (40) TO (maxvalue) PARTIT..." +== 501 +-- truncate_limit: 100 +create table part_40_inf_ab partition of part_40_inf for values in ('ab') +-- +TABLE: name="part_40_inf_ab" schema="" table="part_40_inf_ab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_40_inf_ab PARTITION OF part_40_inf FOR VALUES IN ('ab')" +== 502 +-- truncate_limit: 100 +create table part_40_inf_cd partition of part_40_inf for values in ('cd') +-- +TABLE: name="part_40_inf_cd" schema="" table="part_40_inf_cd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_40_inf_cd PARTITION OF part_40_inf FOR VALUES IN ('cd')" +== 503 +-- truncate_limit: 100 +create table part_40_inf_null partition of part_40_inf for values in (null) +-- +TABLE: name="part_40_inf_null" schema="" table="part_40_inf_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_40_inf_null PARTITION OF part_40_inf FOR VALUES IN (NULL)" +== 504 +-- truncate_limit: 100 +explain (costs off) select * from range_list_parted +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_list_parted" +== 505 +-- truncate_limit: 100 +explain (costs off) select * from range_list_parted where a = 5 +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_list_parted WHERE a = 5" +== 506 +-- truncate_limit: 100 +explain (costs off) select * from range_list_parted where b = 'ab' +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_list_parted WHERE b = 'ab'" +== 507 +-- truncate_limit: 100 +explain (costs off) select * from range_list_parted where a between 3 and 23 and b in ('ab') +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_list_parted WHERE a BETWEEN 3 AND 23 AND b IN ('ab')" +== 508 +-- truncate_limit: 100 +/* Should select no rows because range partition key cannot be null */ +explain (costs off) select * from range_list_parted where a is null +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_list_parted WHERE a IS NULL" +== 509 +-- truncate_limit: 100 +/* Should only select rows from the null-accepting partition */ +explain (costs off) select * from range_list_parted where b is null +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_list_parted WHERE b IS NULL" +== 510 +-- truncate_limit: 100 +explain (costs off) select * from range_list_parted where a is not null and a < 67 +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_list_parted WHERE a IS NOT NULL AND a < 67" +== 511 +-- truncate_limit: 100 +explain (costs off) select * from range_list_parted where a >= 30 +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_list_parted WHERE a >= 30" +== 512 +-- truncate_limit: 100 +drop table list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE list_parted" +== 513 +-- truncate_limit: 100 +drop table range_list_parted +-- +TABLE: name="range_list_parted" schema="" table="range_list_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE range_list_parted" +== 514 +-- truncate_limit: 100 +-- check that constraint exclusion is able to cope with the partition +-- constraint emitted for multi-column range partitioned tables +create table mcrparted (a int, b int, c int) partition by range (a, abs(b), c) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted (a int, b int, c int) PARTITION BY RANGE (a, (abs(b)), c)" +== 515 +-- truncate_limit: 100 +create table mcrparted_def partition of mcrparted default +-- +TABLE: name="mcrparted_def" schema="" table="mcrparted_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted_def PARTITION OF mcrparted DEFAULT" +== 516 +-- truncate_limit: 100 +create table mcrparted0 partition of mcrparted for values from (minvalue, minvalue, minvalue) to (1, 1, 1) +-- +TABLE: name="mcrparted0" schema="" table="mcrparted0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted0 PARTITION OF mcrparted FOR VALUES FROM (minvalue, minvalue, minvalue) TO ..." +== 517 +-- truncate_limit: 100 +create table mcrparted1 partition of mcrparted for values from (1, 1, 1) to (10, 5, 10) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted1 PARTITION OF mcrparted FOR VALUES FROM (1, 1, 1) TO (10, 5, 10)" +== 518 +-- truncate_limit: 100 +create table mcrparted2 partition of mcrparted for values from (10, 5, 10) to (10, 10, 10) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted2 PARTITION OF mcrparted FOR VALUES FROM (10, 5, 10) TO (10, 10, 10)" +== 519 +-- truncate_limit: 100 +create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20, 10, 10) +-- +TABLE: name="mcrparted3" schema="" table="mcrparted3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted3 PARTITION OF mcrparted FOR VALUES FROM (11, 1, 1) TO (20, 10, 10)" +== 520 +-- truncate_limit: 100 +create table mcrparted4 partition of mcrparted for values from (20, 10, 10) to (20, 20, 20) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted4 PARTITION OF mcrparted FOR VALUES FROM (20, 10, 10) TO (20, 20, 20)" +== 521 +-- truncate_limit: 100 +create table mcrparted5 partition of mcrparted for values from (20, 20, 20) to (maxvalue, maxvalue, maxvalue) +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted5 PARTITION OF mcrparted FOR VALUES FROM (20, 20, 20) TO (maxvalue, maxvalu..." +== 522 +-- truncate_limit: 100 +explain (costs off) select * from mcrparted where a = 0 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a = 0" +== 523 +-- truncate_limit: 100 +-- scans mcrparted0, mcrparted_def +explain (costs off) select * from mcrparted where a = 10 and abs(b) < 5 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a = 10 AND abs(b) < 5" +== 524 +-- truncate_limit: 100 +-- scans mcrparted1, mcrparted_def +explain (costs off) select * from mcrparted where a = 10 and abs(b) = 5 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a = 10 AND abs(b) = 5" +== 525 +-- truncate_limit: 100 +-- scans mcrparted1, mcrparted2, mcrparted_def +explain (costs off) select * from mcrparted where abs(b) = 5 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE abs(b) = 5" +== 526 +-- truncate_limit: 100 +-- scans all partitions +explain (costs off) select * from mcrparted where a > -1 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a > -1" +== 527 +-- truncate_limit: 100 +-- scans all partitions +explain (costs off) select * from mcrparted where a = 20 and abs(b) = 10 and c > 10 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a = 20 AND abs(b) = 10 AND c > 10" +== 528 +-- truncate_limit: 100 +-- scans mcrparted4 +explain (costs off) select * from mcrparted where a = 20 and c > 20 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a = 20 AND c > 20" +== 529 +-- truncate_limit: 100 +-- scans mcrparted3, mcrparte4, mcrparte5, mcrparted_def + +-- check that partitioned table Appends cope with being referenced in +-- subplans +create table parted_minmax (a int, b varchar(16)) partition by range (a) +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_minmax (a int, b varchar(16)) PARTITION BY RANGE (a)" +== 530 +-- truncate_limit: 100 +create table parted_minmax1 partition of parted_minmax for values from (1) to (10) +-- +TABLE: name="parted_minmax1" schema="" table="parted_minmax1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_minmax1 PARTITION OF parted_minmax FOR VALUES FROM (1) TO (10)" +== 531 +-- truncate_limit: 100 +create index parted_minmax1i on parted_minmax1 (a, b) +-- +TABLE: name="parted_minmax1" schema="" table="parted_minmax1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX parted_minmax1i ON parted_minmax1 USING btree (a, b)" +== 532 +-- truncate_limit: 100 +insert into parted_minmax values (1,'12345') +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_minmax VALUES (1, '12345')" +== 533 +-- truncate_limit: 100 +explain (costs off) select min(a), max(a) from parted_minmax where b = '12345' +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT min(a), max(a) FROM parted_minmax WHERE b = '12345'" +== 534 +-- truncate_limit: 100 +select min(a), max(a) from parted_minmax where b = '12345' +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT min(a), max(a) FROM parted_minmax WHERE b = '12345'" +== 535 +-- truncate_limit: 100 +drop table parted_minmax +-- +TABLE: name="parted_minmax" schema="" table="parted_minmax" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_minmax" +== 536 +-- truncate_limit: 100 +-- Test code that uses Append nodes in place of MergeAppend when the +-- partition ordering matches the desired ordering. + +create index mcrparted_a_abs_c_idx on mcrparted (a, abs(b), c) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX mcrparted_a_abs_c_idx ON mcrparted USING btree (a, abs(b), c)" +== 537 +-- truncate_limit: 100 +-- MergeAppend must be used when a default partition exists +explain (costs off) select * from mcrparted order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted ORDER BY a, abs(b), c" +== 538 +-- truncate_limit: 100 +drop table mcrparted_def +-- +TABLE: name="mcrparted_def" schema="" table="mcrparted_def" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcrparted_def" +== 539 +-- truncate_limit: 100 +-- Append is used for a RANGE partitioned table with no default +-- and no subpartitions +explain (costs off) select * from mcrparted order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted ORDER BY a, abs(b), c" +== 540 +-- truncate_limit: 100 +-- Append is used with subpaths in reverse order with backwards index scans +explain (costs off) select * from mcrparted order by a desc, abs(b) desc, c desc +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted ORDER BY a DESC, abs(b) DESC, c DESC" +== 541 +-- truncate_limit: 100 +-- check that Append plan is used containing a MergeAppend for sub-partitions +-- that are unordered. +drop table mcrparted5 +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcrparted5" +== 542 +-- truncate_limit: 100 +create table mcrparted5 partition of mcrparted for values from (20, 20, 20) to (maxvalue, maxvalue, maxvalue) partition by list (a) +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted5 PARTITION OF mcrparted FOR VALUES FROM (20, 20, 20) TO (maxvalue, maxvalu..." +== 543 +-- truncate_limit: 100 +create table mcrparted5a partition of mcrparted5 for values in(20) +-- +TABLE: name="mcrparted5a" schema="" table="mcrparted5a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted5a PARTITION OF mcrparted5 FOR VALUES IN (20)" +== 544 +-- truncate_limit: 100 +create table mcrparted5_def partition of mcrparted5 default +-- +TABLE: name="mcrparted5_def" schema="" table="mcrparted5_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted5_def PARTITION OF mcrparted5 DEFAULT" +== 545 +-- truncate_limit: 100 +explain (costs off) select * from mcrparted order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted ORDER BY a, abs(b), c" +== 546 +-- truncate_limit: 100 +drop table mcrparted5_def +-- +TABLE: name="mcrparted5_def" schema="" table="mcrparted5_def" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcrparted5_def" +== 547 +-- truncate_limit: 100 +-- check that an Append plan is used and the sub-partitions are flattened +-- into the main Append when the sub-partition is unordered but contains +-- just a single sub-partition. +explain (costs off) select a, abs(b) from mcrparted order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, abs(b) FROM mcrparted ORDER BY a, abs(b), c" +== 548 +-- truncate_limit: 100 +-- check that Append is used when the sub-partitioned tables are pruned +-- during planning. +explain (costs off) select * from mcrparted where a < 20 order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a < 20 ORDER BY a, abs(b), c" +== 549 +-- truncate_limit: 100 +set enable_bitmapscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 550 +-- truncate_limit: 100 +set enable_sort to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO OFF" +== 551 +-- truncate_limit: 100 +create table mclparted (a int) partition by list(a) +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mclparted (a int) PARTITION BY LIST (a)" +== 552 +-- truncate_limit: 100 +create table mclparted1 partition of mclparted for values in(1) +-- +TABLE: name="mclparted1" schema="" table="mclparted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mclparted1 PARTITION OF mclparted FOR VALUES IN (1)" +== 553 +-- truncate_limit: 100 +create table mclparted2 partition of mclparted for values in(2) +-- +TABLE: name="mclparted2" schema="" table="mclparted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mclparted2 PARTITION OF mclparted FOR VALUES IN (2)" +== 554 +-- truncate_limit: 100 +create index on mclparted (a) +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON mclparted USING btree (a)" +== 555 +-- truncate_limit: 100 +-- Ensure an Append is used for a list partition with an order by. +explain (costs off) select * from mclparted order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted ORDER BY a" +== 556 +-- truncate_limit: 100 +-- Ensure a MergeAppend is used when a partition exists with interleaved +-- datums in the partition bound. +create table mclparted3_5 partition of mclparted for values in(3,5) +-- +TABLE: name="mclparted3_5" schema="" table="mclparted3_5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mclparted3_5 PARTITION OF mclparted FOR VALUES IN (3, 5)" +== 557 +-- truncate_limit: 100 +create table mclparted4 partition of mclparted for values in(4) +-- +TABLE: name="mclparted4" schema="" table="mclparted4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mclparted4 PARTITION OF mclparted FOR VALUES IN (4)" +== 558 +-- truncate_limit: 100 +explain (costs off) select * from mclparted order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted ORDER BY a" +== 559 +-- truncate_limit: 100 +explain (costs off) select * from mclparted where a in(3,4,5) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted WHERE a IN (3, 4, 5) ORDER BY a" +== 560 +-- truncate_limit: 100 +-- Introduce a NULL and DEFAULT partition so we can test more complex cases +create table mclparted_null partition of mclparted for values in(null) +-- +TABLE: name="mclparted_null" schema="" table="mclparted_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mclparted_null PARTITION OF mclparted FOR VALUES IN (NULL)" +== 561 +-- truncate_limit: 100 +create table mclparted_def partition of mclparted default +-- +TABLE: name="mclparted_def" schema="" table="mclparted_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mclparted_def PARTITION OF mclparted DEFAULT" +== 562 +-- truncate_limit: 100 +-- Append can be used providing we don't scan the interleaved partition +explain (costs off) select * from mclparted where a in(1,2,4) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted WHERE a IN (1, 2, 4) ORDER BY a" +== 563 +-- truncate_limit: 100 +explain (costs off) select * from mclparted where a in(1,2,4) or a is null order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted WHERE a IN (1, 2, 4) OR a IS NULL ORDER BY a" +== 564 +-- truncate_limit: 100 +-- Test a more complex case where the NULL partition allows some other value +drop table mclparted_null +-- +TABLE: name="mclparted_null" schema="" table="mclparted_null" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mclparted_null" +== 565 +-- truncate_limit: 100 +create table mclparted_0_null partition of mclparted for values in(0,null) +-- +TABLE: name="mclparted_0_null" schema="" table="mclparted_0_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mclparted_0_null PARTITION OF mclparted FOR VALUES IN (0, NULL)" +== 566 +-- truncate_limit: 100 +-- Ensure MergeAppend is used since 0 and NULLs are in the same partition. +explain (costs off) select * from mclparted where a in(1,2,4) or a is null order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted WHERE a IN (1, 2, 4) OR a IS NULL ORDER BY a" +== 567 +-- truncate_limit: 100 +explain (costs off) select * from mclparted where a in(0,1,2,4) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted WHERE a IN (0, 1, 2, 4) ORDER BY a" +== 568 +-- truncate_limit: 100 +-- Ensure Append is used when the null partition is pruned +explain (costs off) select * from mclparted where a in(1,2,4) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted WHERE a IN (1, 2, 4) ORDER BY a" +== 569 +-- truncate_limit: 100 +-- Ensure MergeAppend is used when the default partition is not pruned +explain (costs off) select * from mclparted where a in(1,2,4,100) order by a +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mclparted WHERE a IN (1, 2, 4, 100) ORDER BY a" +== 570 +-- truncate_limit: 100 +drop table mclparted +-- +TABLE: name="mclparted" schema="" table="mclparted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mclparted" +== 571 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 572 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 573 +-- truncate_limit: 100 +-- Ensure subplans which don't have a path with the correct pathkeys get +-- sorted correctly. +drop index mcrparted_a_abs_c_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX mcrparted_a_abs_c_idx" +== 574 +-- truncate_limit: 100 +create index on mcrparted1 (a, abs(b), c) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON mcrparted1 USING btree (a, abs(b), c)" +== 575 +-- truncate_limit: 100 +create index on mcrparted2 (a, abs(b), c) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON mcrparted2 USING btree (a, abs(b), c)" +== 576 +-- truncate_limit: 100 +create index on mcrparted3 (a, abs(b), c) +-- +TABLE: name="mcrparted3" schema="" table="mcrparted3" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON mcrparted3 USING btree (a, abs(b), c)" +== 577 +-- truncate_limit: 100 +create index on mcrparted4 (a, abs(b), c) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON mcrparted4 USING btree (a, abs(b), c)" +== 578 +-- truncate_limit: 100 +explain (costs off) select * from mcrparted where a < 20 order by a, abs(b), c limit 1 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a < 20 ORDER BY a, abs(b), c LIMIT 1" +== 579 +-- truncate_limit: 100 +set enable_bitmapscan = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO 0" +== 580 +-- truncate_limit: 100 +-- Ensure Append node can be used when the partition is ordered by some +-- pathkeys which were deemed redundant. +explain (costs off) select * from mcrparted where a = 10 order by a, abs(b), c +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mcrparted WHERE a = 10 ORDER BY a, abs(b), c" +== 581 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 582 +-- truncate_limit: 100 +drop table mcrparted +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcrparted" +== 583 +-- truncate_limit: 100 +-- Ensure LIST partitions allow an Append to be used instead of a MergeAppend +create table bool_lp (b bool) partition by list(b) +-- +TABLE: name="bool_lp" schema="" table="bool_lp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bool_lp (b bool) PARTITION BY LIST (b)" +== 584 +-- truncate_limit: 100 +create table bool_lp_true partition of bool_lp for values in(true) +-- +TABLE: name="bool_lp_true" schema="" table="bool_lp_true" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bool_lp_true PARTITION OF bool_lp FOR VALUES IN (true)" +== 585 +-- truncate_limit: 100 +create table bool_lp_false partition of bool_lp for values in(false) +-- +TABLE: name="bool_lp_false" schema="" table="bool_lp_false" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bool_lp_false PARTITION OF bool_lp FOR VALUES IN (false)" +== 586 +-- truncate_limit: 100 +create index on bool_lp (b) +-- +TABLE: name="bool_lp" schema="" table="bool_lp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON bool_lp USING btree (b)" +== 587 +-- truncate_limit: 100 +explain (costs off) select * from bool_lp order by b +-- +TABLE: name="bool_lp" schema="" table="bool_lp" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM bool_lp ORDER BY b" +== 588 +-- truncate_limit: 100 +drop table bool_lp +-- +TABLE: name="bool_lp" schema="" table="bool_lp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bool_lp" +== 589 +-- truncate_limit: 100 +-- Ensure const bool quals can be properly detected as redundant +create table bool_rp (b bool, a int) partition by range(b,a) +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bool_rp (b bool, a int) PARTITION BY RANGE (b, a)" +== 590 +-- truncate_limit: 100 +create table bool_rp_false_1k partition of bool_rp for values from (false,0) to (false,1000) +-- +TABLE: name="bool_rp_false_1k" schema="" table="bool_rp_false_1k" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bool_rp_false_1k PARTITION OF bool_rp FOR VALUES FROM (false, 0) TO (false, 1000)" +== 591 +-- truncate_limit: 100 +create table bool_rp_true_1k partition of bool_rp for values from (true,0) to (true,1000) +-- +TABLE: name="bool_rp_true_1k" schema="" table="bool_rp_true_1k" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bool_rp_true_1k PARTITION OF bool_rp FOR VALUES FROM (true, 0) TO (true, 1000)" +== 592 +-- truncate_limit: 100 +create table bool_rp_false_2k partition of bool_rp for values from (false,1000) to (false,2000) +-- +TABLE: name="bool_rp_false_2k" schema="" table="bool_rp_false_2k" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bool_rp_false_2k PARTITION OF bool_rp FOR VALUES FROM (false, 1000) TO (false, 2000)" +== 593 +-- truncate_limit: 100 +create table bool_rp_true_2k partition of bool_rp for values from (true,1000) to (true,2000) +-- +TABLE: name="bool_rp_true_2k" schema="" table="bool_rp_true_2k" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bool_rp_true_2k PARTITION OF bool_rp FOR VALUES FROM (true, 1000) TO (true, 2000)" +== 594 +-- truncate_limit: 100 +create index on bool_rp (b,a) +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON bool_rp USING btree (b, a)" +== 595 +-- truncate_limit: 100 +explain (costs off) select * from bool_rp where b = true order by b,a +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM bool_rp WHERE b = true ORDER BY b, a" +== 596 +-- truncate_limit: 100 +explain (costs off) select * from bool_rp where b = false order by b,a +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM bool_rp WHERE b = false ORDER BY b, a" +== 597 +-- truncate_limit: 100 +explain (costs off) select * from bool_rp where b = true order by a +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM bool_rp WHERE b = true ORDER BY a" +== 598 +-- truncate_limit: 100 +explain (costs off) select * from bool_rp where b = false order by a +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM bool_rp WHERE b = false ORDER BY a" +== 599 +-- truncate_limit: 100 +drop table bool_rp +-- +TABLE: name="bool_rp" schema="" table="bool_rp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bool_rp" +== 600 +-- truncate_limit: 100 +-- Ensure an Append scan is chosen when the partition order is a subset of +-- the required order. +create table range_parted (a int, b int, c int) partition by range(a, b) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted (a int, b int, c int) PARTITION BY RANGE (a, b)" +== 601 +-- truncate_limit: 100 +create table range_parted1 partition of range_parted for values from (0,0) to (10,10) +-- +TABLE: name="range_parted1" schema="" table="range_parted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted1 PARTITION OF range_parted FOR VALUES FROM (0, 0) TO (10, 10)" +== 602 +-- truncate_limit: 100 +create table range_parted2 partition of range_parted for values from (10,10) to (20,20) +-- +TABLE: name="range_parted2" schema="" table="range_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted2 PARTITION OF range_parted FOR VALUES FROM (10, 10) TO (20, 20)" +== 603 +-- truncate_limit: 100 +create index on range_parted (a,b,c) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON range_parted USING btree (a, b, c)" +== 604 +-- truncate_limit: 100 +explain (costs off) select * from range_parted order by a,b,c +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_parted ORDER BY a, b, c" +== 605 +-- truncate_limit: 100 +explain (costs off) select * from range_parted order by a desc,b desc,c desc +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM range_parted ORDER BY a DESC, b DESC, c DESC" +== 606 +-- truncate_limit: 100 +drop table range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE range_parted" +== 607 +-- truncate_limit: 100 +-- Check that we allow access to a child table's statistics when the user +-- has permissions only for the parent table. +create table permtest_parent (a int, b text, c text) partition by list (a) +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE permtest_parent (a int, b text, c text) PARTITION BY LIST (a)" +== 608 +-- truncate_limit: 100 +create table permtest_child (b text, c text, a int) partition by list (b) +-- +TABLE: name="permtest_child" schema="" table="permtest_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE permtest_child (b text, c text, a int) PARTITION BY LIST (b)" +== 609 +-- truncate_limit: 100 +create table permtest_grandchild (c text, b text, a int) +-- +TABLE: name="permtest_grandchild" schema="" table="permtest_grandchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE permtest_grandchild (c text, b text, a int)" +== 610 +-- truncate_limit: 100 +alter table permtest_child attach partition permtest_grandchild for values in ('a') +-- +TABLE: name="permtest_child" schema="" table="permtest_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE permtest_child ATTACH PARTITION permtest_grandchild FOR VALUES IN ('a')" +== 611 +-- truncate_limit: 100 +alter table permtest_parent attach partition permtest_child for values in (1) +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE permtest_parent ATTACH PARTITION permtest_child FOR VALUES IN (1)" +== 612 +-- truncate_limit: 100 +create index on permtest_parent (left(c, 3)) +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +FUNCTION: name="left" function="left" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON permtest_parent USING btree (\"left\"(c, 3))" +== 613 +-- truncate_limit: 100 +insert into permtest_parent + select 1, 'a', left(fipshash(i::text), 5) from generate_series(0, 100) i +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DML +FUNCTION: name="left" function="left" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO permtest_parent SELECT ... FROM generate_series(0, 100) i" +== 614 +-- truncate_limit: 100 +analyze permtest_parent +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE permtest_parent" +== 615 +-- truncate_limit: 100 +create role regress_no_child_access +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_no_child_access" +== 616 +-- truncate_limit: 100 +revoke all on permtest_grandchild from regress_no_child_access +-- +TABLE: name="permtest_grandchild" schema="" table="permtest_grandchild" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON permtest_grandchild FROM regress_no_child_access" +== 617 +-- truncate_limit: 100 +grant select on permtest_parent to regress_no_child_access +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON permtest_parent TO regress_no_child_access" +== 618 +-- truncate_limit: 100 +set session authorization regress_no_child_access +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_no_child_access" +== 619 +-- truncate_limit: 100 +-- without stats access, these queries would produce hash join plans: +explain (costs off) + select * from permtest_parent p1 inner join permtest_parent p2 + on p1.a = p2.a and p1.c ~ 'a1$' +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +ALIAS: "p1"="permtest_parent" +ALIAS: "p2"="permtest_parent" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM permtest_parent p1 JOIN permtest_parent p2 ON p1.a = p2.a AND p..." +== 620 +-- truncate_limit: 100 +explain (costs off) + select * from permtest_parent p1 inner join permtest_parent p2 + on p1.a = p2.a and left(p1.c, 3) ~ 'a1$' +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +ALIAS: "p1"="permtest_parent" +ALIAS: "p2"="permtest_parent" +FUNCTION: name="left" function="left" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM permtest_parent p1 JOIN permtest_parent p2 ON p1.a = p2.a AND \"..." +== 621 +-- truncate_limit: 100 +reset session authorization +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 622 +-- truncate_limit: 100 +revoke all on permtest_parent from regress_no_child_access +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON permtest_parent FROM regress_no_child_access" +== 623 +-- truncate_limit: 100 +grant select(a,c) on permtest_parent to regress_no_child_access +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (a, c) ON permtest_parent TO regress_no_child_access" +== 624 +-- truncate_limit: 100 +set session authorization regress_no_child_access +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_no_child_access" +== 625 +-- truncate_limit: 100 +explain (costs off) + select p2.a, p1.c from permtest_parent p1 inner join permtest_parent p2 + on p1.a = p2.a and p1.c ~ 'a1$' +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +ALIAS: "p1"="permtest_parent" +ALIAS: "p2"="permtest_parent" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p2.a, p1.c FROM permtest_parent p1 JOIN permtest_parent p2 ON p1.a = p..." +== 626 +-- truncate_limit: 100 +-- we will not have access to the expression index's stats here: +explain (costs off) + select p2.a, p1.c from permtest_parent p1 inner join permtest_parent p2 + on p1.a = p2.a and left(p1.c, 3) ~ 'a1$' +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=Select +ALIAS: "p1"="permtest_parent" +ALIAS: "p2"="permtest_parent" +FUNCTION: name="left" function="left" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p2.a, p1.c FROM permtest_parent p1 JOIN permtest_parent p2 ON p1.a = p..." +== 627 +-- truncate_limit: 100 +reset session authorization +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 628 +-- truncate_limit: 100 +revoke all on permtest_parent from regress_no_child_access +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON permtest_parent FROM regress_no_child_access" +== 629 +-- truncate_limit: 100 +drop role regress_no_child_access +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_no_child_access" +== 630 +-- truncate_limit: 100 +drop table permtest_parent +-- +TABLE: name="permtest_parent" schema="" table="permtest_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE permtest_parent" +== 631 +-- truncate_limit: 100 +-- Verify that constraint errors across partition root / child are +-- handled correctly (Bug #16293) +CREATE TABLE errtst_parent ( + partid int not null, + shdata int not null, + data int NOT NULL DEFAULT 0, + CONSTRAINT shdata_small CHECK(shdata < 3) +) PARTITION BY RANGE (partid) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE errtst_parent (partid int NOT NULL, shdata int NOT NULL, data int NOT NULL DEFAULT 0..." +== 632 +-- truncate_limit: 100 +-- fast defaults lead to attribute mapping being used in one +-- direction, but not the other +CREATE TABLE errtst_child_fastdef ( + partid int not null, + shdata int not null, + CONSTRAINT shdata_small CHECK(shdata < 3) +) +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE errtst_child_fastdef (partid int NOT NULL, shdata int NOT NULL, CONSTRAINT shdata_sm..." +== 633 +-- truncate_limit: 100 +-- no remapping in either direction necessary +CREATE TABLE errtst_child_plaindef ( + partid int not null, + shdata int not null, + data int NOT NULL DEFAULT 0, + CONSTRAINT shdata_small CHECK(shdata < 3), + CHECK(data < 10) +) +-- +TABLE: name="errtst_child_plaindef" schema="" table="errtst_child_plaindef" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE errtst_child_plaindef (partid int NOT NULL, shdata int NOT NULL, data int NOT NULL D..." +== 634 +-- truncate_limit: 100 +-- remapping in both direction +CREATE TABLE errtst_child_reorder ( + data int NOT NULL DEFAULT 0, + shdata int not null, + partid int not null, + CONSTRAINT shdata_small CHECK(shdata < 3), + CHECK(data < 10) +) +-- +TABLE: name="errtst_child_reorder" schema="" table="errtst_child_reorder" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE errtst_child_reorder (data int NOT NULL DEFAULT 0, shdata int NOT NULL, partid int N..." +== 635 +-- truncate_limit: 100 +ALTER TABLE errtst_child_fastdef ADD COLUMN data int NOT NULL DEFAULT 0 +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE errtst_child_fastdef ADD COLUMN data int NOT NULL DEFAULT 0" +== 636 +-- truncate_limit: 100 +ALTER TABLE errtst_child_fastdef ADD CONSTRAINT errtest_child_fastdef_data_check CHECK (data < 10) +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE errtst_child_fastdef ADD CONSTRAINT errtest_child_fastdef_data_check CHECK (data < 10)" +== 637 +-- truncate_limit: 100 +ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_fastdef FOR VALUES FROM (0) TO (10) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_fastdef FOR VALUES FROM (0) TO (10)" +== 638 +-- truncate_limit: 100 +ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_plaindef FOR VALUES FROM (10) TO (20) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_plaindef FOR VALUES FROM (10) TO (20)" +== 639 +-- truncate_limit: 100 +ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_reorder FOR VALUES FROM (20) TO (30) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE errtst_parent ATTACH PARTITION errtst_child_reorder FOR VALUES FROM (20) TO (30)" +== 640 +-- truncate_limit: 100 +-- insert without child check constraint error +INSERT INTO errtst_parent(partid, shdata, data) VALUES ( '0', '1', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('0', '1', '5')" +== 641 +-- truncate_limit: 100 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('10', '1', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('10', '1', '5')" +== 642 +-- truncate_limit: 100 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('20', '1', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('20', '1', '5')" +== 643 +-- truncate_limit: 100 +-- insert with child check constraint error +INSERT INTO errtst_parent(partid, shdata, data) VALUES ( '0', '1', '10') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('0', '1', '10')" +== 644 +-- truncate_limit: 100 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('10', '1', '10') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('10', '1', '10')" +== 645 +-- truncate_limit: 100 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('20', '1', '10') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('20', '1', '10')" +== 646 +-- truncate_limit: 100 +-- insert with child not null constraint error +INSERT INTO errtst_parent(partid, shdata, data) VALUES ( '0', '1', NULL) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('0', '1', NULL)" +== 647 +-- truncate_limit: 100 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('10', '1', NULL) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('10', '1', NULL)" +== 648 +-- truncate_limit: 100 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('20', '1', NULL) +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('20', '1', NULL)" +== 649 +-- truncate_limit: 100 +-- insert with shared check constraint error +INSERT INTO errtst_parent(partid, shdata, data) VALUES ( '0', '5', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('0', '5', '5')" +== 650 +-- truncate_limit: 100 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('10', '5', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('10', '5', '5')" +== 651 +-- truncate_limit: 100 +INSERT INTO errtst_parent(partid, shdata, data) VALUES ('20', '5', '5') +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO errtst_parent (partid, shdata, data) VALUES ('20', '5', '5')" +== 652 +-- truncate_limit: 100 +-- within partition update without child check constraint violation +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 653 +-- truncate_limit: 100 +UPDATE errtst_parent SET data = data + 1 WHERE partid = 0 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET data = data + 1 WHERE partid = 0" +== 654 +-- truncate_limit: 100 +UPDATE errtst_parent SET data = data + 1 WHERE partid = 10 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET data = data + 1 WHERE partid = 10" +== 655 +-- truncate_limit: 100 +UPDATE errtst_parent SET data = data + 1 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET data = data + 1 WHERE partid = 20" +== 656 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 657 +-- truncate_limit: 100 +-- within partition update with child check constraint violation +UPDATE errtst_parent SET data = data + 10 WHERE partid = 0 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET data = data + 10 WHERE partid = 0" +== 658 +-- truncate_limit: 100 +UPDATE errtst_parent SET data = data + 10 WHERE partid = 10 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET data = data + 10 WHERE partid = 10" +== 659 +-- truncate_limit: 100 +UPDATE errtst_parent SET data = data + 10 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET data = data + 10 WHERE partid = 20" +== 660 +-- truncate_limit: 100 +-- direct leaf partition update, without partition id violation +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 661 +-- truncate_limit: 100 +UPDATE errtst_child_fastdef SET partid = 1 WHERE partid = 0 +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_child_fastdef SET partid = 1 WHERE partid = 0" +== 662 +-- truncate_limit: 100 +UPDATE errtst_child_plaindef SET partid = 11 WHERE partid = 10 +-- +TABLE: name="errtst_child_plaindef" schema="" table="errtst_child_plaindef" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_child_plaindef SET partid = 11 WHERE partid = 10" +== 663 +-- truncate_limit: 100 +UPDATE errtst_child_reorder SET partid = 21 WHERE partid = 20 +-- +TABLE: name="errtst_child_reorder" schema="" table="errtst_child_reorder" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_child_reorder SET partid = 21 WHERE partid = 20" +== 664 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 665 +-- truncate_limit: 100 +-- direct leaf partition update, with partition id violation +UPDATE errtst_child_fastdef SET partid = partid + 10 WHERE partid = 0 +-- +TABLE: name="errtst_child_fastdef" schema="" table="errtst_child_fastdef" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_child_fastdef SET partid = partid + 10 WHERE partid = 0" +== 666 +-- truncate_limit: 100 +UPDATE errtst_child_plaindef SET partid = partid + 10 WHERE partid = 10 +-- +TABLE: name="errtst_child_plaindef" schema="" table="errtst_child_plaindef" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_child_plaindef SET partid = partid + 10 WHERE partid = 10" +== 667 +-- truncate_limit: 100 +UPDATE errtst_child_reorder SET partid = partid + 10 WHERE partid = 20 +-- +TABLE: name="errtst_child_reorder" schema="" table="errtst_child_reorder" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_child_reorder SET partid = partid + 10 WHERE partid = 20" +== 668 +-- truncate_limit: 100 +-- partition move, without child check constraint violation +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 669 +-- truncate_limit: 100 +UPDATE errtst_parent SET partid = 10, data = data + 1 WHERE partid = 0 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET partid = 10, data = data + 1 WHERE partid = 0" +== 670 +-- truncate_limit: 100 +UPDATE errtst_parent SET partid = 20, data = data + 1 WHERE partid = 10 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET partid = 20, data = data + 1 WHERE partid = 10" +== 671 +-- truncate_limit: 100 +UPDATE errtst_parent SET partid = 0, data = data + 1 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET partid = 0, data = data + 1 WHERE partid = 20" +== 672 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 673 +-- truncate_limit: 100 +-- partition move, with child check constraint violation +UPDATE errtst_parent SET partid = 10, data = data + 10 WHERE partid = 0 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET partid = 10, data = data + 10 WHERE partid = 0" +== 674 +-- truncate_limit: 100 +UPDATE errtst_parent SET partid = 20, data = data + 10 WHERE partid = 10 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET partid = 20, data = data + 10 WHERE partid = 10" +== 675 +-- truncate_limit: 100 +UPDATE errtst_parent SET partid = 0, data = data + 10 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET partid = 0, data = data + 10 WHERE partid = 20" +== 676 +-- truncate_limit: 100 +-- partition move, without target partition +UPDATE errtst_parent SET partid = 30, data = data + 10 WHERE partid = 20 +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE errtst_parent SET partid = 30, data = data + 10 WHERE partid = 20" +== 677 +-- truncate_limit: 100 +DROP TABLE errtst_parent +-- +TABLE: name="errtst_parent" schema="" table="errtst_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE errtst_parent" diff --git a/parser/testdata/summary_truncate/postgres_regress/init_privs.metadata.json b/parser/testdata/summary_truncate/postgres_regress/init_privs.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/init_privs.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/init_privs.test b/parser/testdata/summary_truncate/postgres_regress/init_privs.test new file mode 100644 index 0000000..83186f2 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/init_privs.test @@ -0,0 +1,33 @@ +== 001 +-- truncate_limit: 100 +-- Test initial privileges + +-- There should always be some initial privileges, set up by initdb +SELECT count(*) > 0 FROM pg_init_privs +-- +TABLE: name="pg_init_privs" schema="" table="pg_init_privs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 FROM pg_init_privs" +== 002 +-- truncate_limit: 100 +-- Intentionally include some non-initial privs for pg_dump to dump out +GRANT SELECT ON pg_proc TO CURRENT_USER +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON pg_proc TO CURRENT_USER" +== 003 +-- truncate_limit: 100 +GRANT SELECT (prosrc) ON pg_proc TO CURRENT_USER +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (prosrc) ON pg_proc TO CURRENT_USER" +== 004 +-- truncate_limit: 100 +GRANT SELECT (rolname, rolsuper) ON pg_authid TO CURRENT_USER +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (rolname, rolsuper) ON pg_authid TO CURRENT_USER" diff --git a/parser/testdata/summary_truncate/postgres_regress/insert.metadata.json b/parser/testdata/summary_truncate/postgres_regress/insert.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/insert.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/insert.test b/parser/testdata/summary_truncate/postgres_regress/insert.test new file mode 100644 index 0000000..ff7dc9c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/insert.test @@ -0,0 +1,3071 @@ +== 001 +-- truncate_limit: 100 +|-- +-- insert with DEFAULT in the target_list +|-- +create table inserttest (col1 int4, col2 int4 NOT NULL, col3 text default 'testing') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttest (col1 int4, col2 int4 NOT NULL, col3 text DEFAULT 'testing')" +== 002 +-- truncate_limit: 100 +insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (col1, col2, col3) VALUES (DEFAULT, DEFAULT, DEFAULT)" +== 003 +-- truncate_limit: 100 +insert into inserttest (col2, col3) values (3, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (col2, col3) VALUES (3, DEFAULT)" +== 004 +-- truncate_limit: 100 +insert into inserttest (col1, col2, col3) values (DEFAULT, 5, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (col1, col2, col3) VALUES (DEFAULT, 5, DEFAULT)" +== 005 +-- truncate_limit: 100 +insert into inserttest values (DEFAULT, 5, 'test') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest VALUES (DEFAULT, 5, 'test')" +== 006 +-- truncate_limit: 100 +insert into inserttest values (DEFAULT, 7) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest VALUES (DEFAULT, 7)" +== 007 +-- truncate_limit: 100 +select * from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inserttest" +== 008 +-- truncate_limit: 100 +|-- +-- insert with similar expression / target_list values (all fail) +|-- +insert into inserttest (col1, col2, col3) values (DEFAULT, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (col1, col2, col3) VALUES (DEFAULT, DEFAULT)" +== 009 +-- truncate_limit: 100 +insert into inserttest (col1, col2, col3) values (1, 2) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (col1, col2, col3) VALUES (1, 2)" +== 010 +-- truncate_limit: 100 +insert into inserttest (col1) values (1, 2) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (col1) VALUES (1, 2)" +== 011 +-- truncate_limit: 100 +insert into inserttest (col1) values (DEFAULT, DEFAULT) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (col1) VALUES (DEFAULT, DEFAULT)" +== 012 +-- truncate_limit: 100 +select * from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inserttest" +== 013 +-- truncate_limit: 100 +|-- +-- VALUES test +|-- +insert into inserttest values(10, 20, '40'), (-1, 2, DEFAULT), + ((select 2), (select i from (values(3)) as foo (i)), 'values are fun!') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest VALUES (...)" +== 014 +-- truncate_limit: 100 +select * from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inserttest" +== 015 +-- truncate_limit: 100 +|-- +-- TOASTed value test +|-- +insert into inserttest values(30, 50, repeat('x', 10000)) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest VALUES (30, 50, repeat('x', 10000))" +== 016 +-- truncate_limit: 100 +select col1, col2, char_length(col3) from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT col1, col2, char_length(col3) FROM inserttest" +== 017 +-- truncate_limit: 100 +drop table inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttest" +== 018 +-- truncate_limit: 100 +|-- +-- tuple larger than fillfactor +|-- +CREATE TABLE large_tuple_test (a int, b text) WITH (fillfactor = 10) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE large_tuple_test (a int, b text) WITH (fillfactor=10)" +== 019 +-- truncate_limit: 100 +ALTER TABLE large_tuple_test ALTER COLUMN b SET STORAGE plain +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE large_tuple_test ALTER COLUMN b SET STORAGE plain" +== 020 +-- truncate_limit: 100 +-- create page w/ free space in range [nearlyEmptyFreeSpace, MaxHeapTupleSize) +INSERT INTO large_tuple_test (select 1, NULL) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO large_tuple_test SELECT 1, NULL" +== 021 +-- truncate_limit: 100 +-- should still fit on the page +INSERT INTO large_tuple_test (select 2, repeat('a', 1000)) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO large_tuple_test SELECT 2, repeat('a', 1000)" +== 022 +-- truncate_limit: 100 +SELECT pg_size_pretty(pg_relation_size('large_tuple_test'::regclass, 'main')) +-- +FUNCTION: name="pg_size_pretty" function="pg_size_pretty" schema="" ctx=Call +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_size_pretty(pg_relation_size('large_tuple_test'::regclass, 'main'))" +== 023 +-- truncate_limit: 100 +-- add small record to the second page +INSERT INTO large_tuple_test (select 3, NULL) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO large_tuple_test SELECT 3, NULL" +== 024 +-- truncate_limit: 100 +-- now this tuple won't fit on the second page, but the insert should +-- still succeed by extending the relation +INSERT INTO large_tuple_test (select 4, repeat('a', 8126)) +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO large_tuple_test SELECT 4, repeat('a', 8126)" +== 025 +-- truncate_limit: 100 +DROP TABLE large_tuple_test +-- +TABLE: name="large_tuple_test" schema="" table="large_tuple_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE large_tuple_test" +== 026 +-- truncate_limit: 100 +|-- +-- check indirection (field/array assignment), cf bug #14265 +|-- +-- these tests are aware that transformInsertStmt has 3 separate code paths +|-- + +create type insert_test_type as (if1 int, if2 text[]) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE insert_test_type AS (if1 int, if2 text[])" +== 027 +-- truncate_limit: 100 +create table inserttest (f1 int, f2 int[], + f3 insert_test_type, f4 insert_test_type[]) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttest (f1 int, f2 int[], f3 insert_test_type, f4 insert_test_type[])" +== 028 +-- truncate_limit: 100 +insert into inserttest (f2[1], f2[2]) values (1,2) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f2[1], f2[2]) VALUES (1, 2)" +== 029 +-- truncate_limit: 100 +insert into inserttest (f2[1], f2[2]) values (3,4), (5,6) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f2[1], f2[2]) VALUES (3, 4), (5, 6)" +== 030 +-- truncate_limit: 100 +insert into inserttest (f2[1], f2[2]) select 7,8 +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f2[1], f2[2]) SELECT 7, 8" +== 031 +-- truncate_limit: 100 +insert into inserttest (f2[1], f2[2]) values (1,default) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f2[1], f2[2]) VALUES (1, DEFAULT)" +== 032 +-- truncate_limit: 100 +-- not supported + +insert into inserttest (f3.if1, f3.if2) values (1,array['foo']) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f3.if1, f3.if2) VALUES (1, ARRAY['foo'])" +== 033 +-- truncate_limit: 100 +insert into inserttest (f3.if1, f3.if2) values (1,'{foo}'), (2,'{bar}') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f3.if1, f3.if2) VALUES (1, '{foo}'), (2, '{bar}')" +== 034 +-- truncate_limit: 100 +insert into inserttest (f3.if1, f3.if2) select 3, '{baz,quux}' +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f3.if1, f3.if2) SELECT 3, '{baz,quux}'" +== 035 +-- truncate_limit: 100 +insert into inserttest (f3.if1, f3.if2) values (1,default) +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f3.if1, f3.if2) VALUES (1, DEFAULT)" +== 036 +-- truncate_limit: 100 +-- not supported + +insert into inserttest (f3.if2[1], f3.if2[2]) values ('foo', 'bar') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f3.if2[1], f3.if2[2]) VALUES ('foo', 'bar')" +== 037 +-- truncate_limit: 100 +insert into inserttest (f3.if2[1], f3.if2[2]) values ('foo', 'bar'), ('baz', 'quux') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f3.if2[1], f3.if2[2]) VALUES ('foo', 'bar'), ('baz', 'quux')" +== 038 +-- truncate_limit: 100 +insert into inserttest (f3.if2[1], f3.if2[2]) select 'bear', 'beer' +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f3.if2[1], f3.if2[2]) SELECT 'bear', 'beer'" +== 039 +-- truncate_limit: 100 +insert into inserttest (f4[1].if2[1], f4[1].if2[2]) values ('foo', 'bar') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f4[1].if2[1], f4[1].if2[2]) VALUES ('foo', 'bar')" +== 040 +-- truncate_limit: 100 +insert into inserttest (f4[1].if2[1], f4[1].if2[2]) values ('foo', 'bar'), ('baz', 'quux') +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f4[1].if2[1], f4[1].if2[2]) VALUES ('foo', 'bar'), ('baz', 'quux')" +== 041 +-- truncate_limit: 100 +insert into inserttest (f4[1].if2[1], f4[1].if2[2]) select 'bear', 'beer' +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttest (f4[1].if2[1], f4[1].if2[2]) SELECT 'bear', 'beer'" +== 042 +-- truncate_limit: 100 +select * from inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inserttest" +== 043 +-- truncate_limit: 100 +-- also check reverse-listing +create table inserttest2 (f1 bigint, f2 text) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttest2 (f1 bigint, f2 text)" +== 044 +-- truncate_limit: 100 +create rule irule1 as on insert to inserttest2 do also + insert into inserttest (f3.if2[1], f3.if2[2]) + values (new.f1,new.f2) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE irule1 AS ON INSERT TO inserttest2 DO INSERT INTO inserttest (f3.if2[1], f3.if2[2]) V..." +== 045 +-- truncate_limit: 100 +create rule irule2 as on insert to inserttest2 do also + insert into inserttest (f4[1].if1, f4[1].if2[2]) + values (1,'fool'),(new.f1,new.f2) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE irule2 AS ON INSERT TO inserttest2 DO INSERT INTO inserttest (f4[1].if1, f4[1].if2[2]..." +== 046 +-- truncate_limit: 100 +create rule irule3 as on insert to inserttest2 do also + insert into inserttest (f4[1].if1, f4[1].if2[2]) + select new.f1, new.f2 +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE irule3 AS ON INSERT TO inserttest2 DO INSERT INTO inserttest (f4[1].if1, f4[1].if2[2]..." +== 047 +-- truncate_limit: 100 +drop table inserttest2 +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttest2" +== 048 +-- truncate_limit: 100 +drop table inserttest +-- +TABLE: name="inserttest" schema="" table="inserttest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttest" +== 049 +-- truncate_limit: 100 +-- Make the same tests with domains over the array and composite fields + +create domain insert_pos_ints as int[] check (value[1] > 0) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN insert_pos_ints AS int[] CHECK (value[1] > 0)" +== 050 +-- truncate_limit: 100 +create domain insert_test_domain as insert_test_type + check ((value).if2[1] is not null) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN insert_test_domain AS insert_test_type CHECK ((value).if2[1] IS NOT NULL)" +== 051 +-- truncate_limit: 100 +create table inserttesta (f1 int, f2 insert_pos_ints) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttesta (f1 int, f2 insert_pos_ints)" +== 052 +-- truncate_limit: 100 +create table inserttestb (f3 insert_test_domain, f4 insert_test_domain[]) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttestb (f3 insert_test_domain, f4 insert_test_domain[])" +== 053 +-- truncate_limit: 100 +insert into inserttesta (f2[1], f2[2]) values (1,2) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f2[1], f2[2]) VALUES (1, 2)" +== 054 +-- truncate_limit: 100 +insert into inserttesta (f2[1], f2[2]) values (3,4), (5,6) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f2[1], f2[2]) VALUES (3, 4), (5, 6)" +== 055 +-- truncate_limit: 100 +insert into inserttesta (f2[1], f2[2]) select 7,8 +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f2[1], f2[2]) SELECT 7, 8" +== 056 +-- truncate_limit: 100 +insert into inserttesta (f2[1], f2[2]) values (1,default) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f2[1], f2[2]) VALUES (1, DEFAULT)" +== 057 +-- truncate_limit: 100 +-- not supported +insert into inserttesta (f2[1], f2[2]) values (0,2) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f2[1], f2[2]) VALUES (0, 2)" +== 058 +-- truncate_limit: 100 +insert into inserttesta (f2[1], f2[2]) values (3,4), (0,6) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f2[1], f2[2]) VALUES (3, 4), (0, 6)" +== 059 +-- truncate_limit: 100 +insert into inserttesta (f2[1], f2[2]) select 0,8 +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f2[1], f2[2]) SELECT 0, 8" +== 060 +-- truncate_limit: 100 +insert into inserttestb (f3.if1, f3.if2) values (1,array['foo']) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if1, f3.if2) VALUES (1, ARRAY['foo'])" +== 061 +-- truncate_limit: 100 +insert into inserttestb (f3.if1, f3.if2) values (1,'{foo}'), (2,'{bar}') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if1, f3.if2) VALUES (1, '{foo}'), (2, '{bar}')" +== 062 +-- truncate_limit: 100 +insert into inserttestb (f3.if1, f3.if2) select 3, '{baz,quux}' +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if1, f3.if2) SELECT 3, '{baz,quux}'" +== 063 +-- truncate_limit: 100 +insert into inserttestb (f3.if1, f3.if2) values (1,default) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if1, f3.if2) VALUES (1, DEFAULT)" +== 064 +-- truncate_limit: 100 +-- not supported +insert into inserttestb (f3.if1, f3.if2) values (1,array[null]) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if1, f3.if2) VALUES (1, ARRAY[NULL])" +== 065 +-- truncate_limit: 100 +insert into inserttestb (f3.if1, f3.if2) values (1,'{null}'), (2,'{bar}') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if1, f3.if2) VALUES (1, '{null}'), (2, '{bar}')" +== 066 +-- truncate_limit: 100 +insert into inserttestb (f3.if1, f3.if2) select 3, '{null,quux}' +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if1, f3.if2) SELECT 3, '{null,quux}'" +== 067 +-- truncate_limit: 100 +insert into inserttestb (f3.if2[1], f3.if2[2]) values ('foo', 'bar') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if2[1], f3.if2[2]) VALUES ('foo', 'bar')" +== 068 +-- truncate_limit: 100 +insert into inserttestb (f3.if2[1], f3.if2[2]) values ('foo', 'bar'), ('baz', 'quux') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if2[1], f3.if2[2]) VALUES ('foo', 'bar'), ('baz', 'quux')" +== 069 +-- truncate_limit: 100 +insert into inserttestb (f3.if2[1], f3.if2[2]) select 'bear', 'beer' +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3.if2[1], f3.if2[2]) SELECT 'bear', 'beer'" +== 070 +-- truncate_limit: 100 +insert into inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) values (row(1,'{x}'), 'foo', 'bar') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) VALUES (ROW(1, '{x}'), 'foo', 'bar')" +== 071 +-- truncate_limit: 100 +insert into inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) values (row(1,'{x}'), 'foo', 'bar'), (row(2,'{y}'), 'baz', 'quux') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) VALUES (...)" +== 072 +-- truncate_limit: 100 +insert into inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) select row(1,'{x}')::insert_test_domain, 'bear', 'beer' +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f3, f4[1].if2[1], f4[1].if2[2]) SELECT ..." +== 073 +-- truncate_limit: 100 +select * from inserttesta +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inserttesta" +== 074 +-- truncate_limit: 100 +select * from inserttestb +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inserttestb" +== 075 +-- truncate_limit: 100 +-- also check reverse-listing +create table inserttest2 (f1 bigint, f2 text) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttest2 (f1 bigint, f2 text)" +== 076 +-- truncate_limit: 100 +create rule irule1 as on insert to inserttest2 do also + insert into inserttestb (f3.if2[1], f3.if2[2]) + values (new.f1,new.f2) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE irule1 AS ON INSERT TO inserttest2 DO INSERT INTO inserttestb (f3.if2[1], f3.if2[2]) ..." +== 077 +-- truncate_limit: 100 +create rule irule2 as on insert to inserttest2 do also + insert into inserttestb (f4[1].if1, f4[1].if2[2]) + values (1,'fool'),(new.f1,new.f2) +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE irule2 AS ON INSERT TO inserttest2 DO INSERT INTO inserttestb (f4[1].if1, f4[1].if2[2..." +== 078 +-- truncate_limit: 100 +create rule irule3 as on insert to inserttest2 do also + insert into inserttestb (f4[1].if1, f4[1].if2[2]) + select new.f1, new.f2 +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE irule3 AS ON INSERT TO inserttest2 DO INSERT INTO inserttestb (f4[1].if1, f4[1].if2[2..." +== 079 +-- truncate_limit: 100 +drop table inserttest2 +-- +TABLE: name="inserttest2" schema="" table="inserttest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttest2" +== 080 +-- truncate_limit: 100 +drop table inserttesta +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttesta" +== 081 +-- truncate_limit: 100 +drop table inserttestb +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttestb" +== 082 +-- truncate_limit: 100 +drop domain insert_pos_ints +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN insert_pos_ints" +== 083 +-- truncate_limit: 100 +drop domain insert_test_domain +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN insert_test_domain" +== 084 +-- truncate_limit: 100 +-- Verify that multiple inserts to subfields of a domain-over-container +-- check the domain constraints only on the finished value + +create domain insert_nnarray as int[] + check (value[1] is not null and value[2] is not null) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN insert_nnarray AS int[] CHECK (value[1] IS NOT NULL AND value[2] IS NOT NULL)" +== 085 +-- truncate_limit: 100 +create domain insert_test_domain as insert_test_type + check ((value).if1 is not null and (value).if2 is not null) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN insert_test_domain AS insert_test_type CHECK ((value).if1 IS NOT NULL AND (value).i..." +== 086 +-- truncate_limit: 100 +create table inserttesta (f1 insert_nnarray) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttesta (f1 insert_nnarray)" +== 087 +-- truncate_limit: 100 +insert into inserttesta (f1[1]) values (1) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f1[1]) VALUES (1)" +== 088 +-- truncate_limit: 100 +-- fail +insert into inserttesta (f1[1], f1[2]) values (1, 2) +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttesta (f1[1], f1[2]) VALUES (1, 2)" +== 089 +-- truncate_limit: 100 +create table inserttestb (f1 insert_test_domain) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttestb (f1 insert_test_domain)" +== 090 +-- truncate_limit: 100 +insert into inserttestb (f1.if1) values (1) +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f1.if1) VALUES (1)" +== 091 +-- truncate_limit: 100 +-- fail +insert into inserttestb (f1.if1, f1.if2) values (1, '{foo}') +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inserttestb (f1.if1, f1.if2) VALUES (1, '{foo}')" +== 092 +-- truncate_limit: 100 +drop table inserttesta +-- +TABLE: name="inserttesta" schema="" table="inserttesta" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttesta" +== 093 +-- truncate_limit: 100 +drop table inserttestb +-- +TABLE: name="inserttestb" schema="" table="inserttestb" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttestb" +== 094 +-- truncate_limit: 100 +drop domain insert_nnarray +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN insert_nnarray" +== 095 +-- truncate_limit: 100 +drop type insert_test_type cascade +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE insert_test_type CASCADE" +== 096 +-- truncate_limit: 100 +-- direct partition inserts should check partition bound constraint +create table range_parted ( + a text, + b int +) partition by range (a, (b+0)) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted (a text, b int) PARTITION BY RANGE (a, (b + 0))" +== 097 +-- truncate_limit: 100 +-- no partitions, so fail +insert into range_parted values ('a', 11) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('a', 11)" +== 098 +-- truncate_limit: 100 +create table part1 partition of range_parted for values from ('a', 1) to ('a', 10) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part1 PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('a', 10)" +== 099 +-- truncate_limit: 100 +create table part2 partition of range_parted for values from ('a', 10) to ('a', 20) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part2 PARTITION OF range_parted FOR VALUES FROM ('a', 10) TO ('a', 20)" +== 100 +-- truncate_limit: 100 +create table part3 partition of range_parted for values from ('b', 1) to ('b', 10) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part3 PARTITION OF range_parted FOR VALUES FROM ('b', 1) TO ('b', 10)" +== 101 +-- truncate_limit: 100 +create table part4 partition of range_parted for values from ('b', 10) to ('b', 20) +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part4 PARTITION OF range_parted FOR VALUES FROM ('b', 10) TO ('b', 20)" +== 102 +-- truncate_limit: 100 +-- fail +insert into part1 values ('a', 11) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part1 VALUES ('a', 11)" +== 103 +-- truncate_limit: 100 +insert into part1 values ('b', 1) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part1 VALUES ('b', 1)" +== 104 +-- truncate_limit: 100 +-- ok +insert into part1 values ('a', 1) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part1 VALUES ('a', 1)" +== 105 +-- truncate_limit: 100 +-- fail +insert into part4 values ('b', 21) +-- +TABLE: name="part4" schema="" table="part4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part4 VALUES ('b', 21)" +== 106 +-- truncate_limit: 100 +insert into part4 values ('a', 10) +-- +TABLE: name="part4" schema="" table="part4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part4 VALUES ('a', 10)" +== 107 +-- truncate_limit: 100 +-- ok +insert into part4 values ('b', 10) +-- +TABLE: name="part4" schema="" table="part4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part4 VALUES ('b', 10)" +== 108 +-- truncate_limit: 100 +-- fail (partition key a has a NOT NULL constraint) +insert into part1 values (null) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part1 VALUES (NULL)" +== 109 +-- truncate_limit: 100 +-- fail (expression key (b+0) cannot be null either) +insert into part1 values (1) +-- +TABLE: name="part1" schema="" table="part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part1 VALUES (1)" +== 110 +-- truncate_limit: 100 +create table list_parted ( + a text, + b int +) partition by list (lower(a)) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted (a text, b int) PARTITION BY LIST ((lower(a)))" +== 111 +-- truncate_limit: 100 +create table part_aa_bb partition of list_parted FOR VALUES IN ('aa', 'bb') +-- +TABLE: name="part_aa_bb" schema="" table="part_aa_bb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_aa_bb PARTITION OF list_parted FOR VALUES IN ('aa', 'bb')" +== 112 +-- truncate_limit: 100 +create table part_cc_dd partition of list_parted FOR VALUES IN ('cc', 'dd') +-- +TABLE: name="part_cc_dd" schema="" table="part_cc_dd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_cc_dd PARTITION OF list_parted FOR VALUES IN ('cc', 'dd')" +== 113 +-- truncate_limit: 100 +create table part_null partition of list_parted FOR VALUES IN (null) +-- +TABLE: name="part_null" schema="" table="part_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_null PARTITION OF list_parted FOR VALUES IN (NULL)" +== 114 +-- truncate_limit: 100 +-- fail +insert into part_aa_bb values ('cc', 1) +-- +TABLE: name="part_aa_bb" schema="" table="part_aa_bb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_aa_bb VALUES ('cc', 1)" +== 115 +-- truncate_limit: 100 +insert into part_aa_bb values ('AAa', 1) +-- +TABLE: name="part_aa_bb" schema="" table="part_aa_bb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_aa_bb VALUES ('AAa', 1)" +== 116 +-- truncate_limit: 100 +insert into part_aa_bb values (null) +-- +TABLE: name="part_aa_bb" schema="" table="part_aa_bb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_aa_bb VALUES (NULL)" +== 117 +-- truncate_limit: 100 +-- ok +insert into part_cc_dd values ('cC', 1) +-- +TABLE: name="part_cc_dd" schema="" table="part_cc_dd" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_cc_dd VALUES ('cC', 1)" +== 118 +-- truncate_limit: 100 +insert into part_null values (null, 0) +-- +TABLE: name="part_null" schema="" table="part_null" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_null VALUES (NULL, 0)" +== 119 +-- truncate_limit: 100 +-- check in case of multi-level partitioned table +create table part_ee_ff partition of list_parted for values in ('ee', 'ff') partition by range (b) +-- +TABLE: name="part_ee_ff" schema="" table="part_ee_ff" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ee_ff PARTITION OF list_parted FOR VALUES IN ('ee', 'ff') PARTITION BY RANGE (b)" +== 120 +-- truncate_limit: 100 +create table part_ee_ff1 partition of part_ee_ff for values from (1) to (10) +-- +TABLE: name="part_ee_ff1" schema="" table="part_ee_ff1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ee_ff1 PARTITION OF part_ee_ff FOR VALUES FROM (1) TO (10)" +== 121 +-- truncate_limit: 100 +create table part_ee_ff2 partition of part_ee_ff for values from (10) to (20) +-- +TABLE: name="part_ee_ff2" schema="" table="part_ee_ff2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ee_ff2 PARTITION OF part_ee_ff FOR VALUES FROM (10) TO (20)" +== 122 +-- truncate_limit: 100 +-- test default partition +create table part_default partition of list_parted default +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_default PARTITION OF list_parted DEFAULT" +== 123 +-- truncate_limit: 100 +-- Negative test: a row, which would fit in other partition, does not fit +-- default partition, even when inserted directly +insert into part_default values ('aa', 2) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default VALUES ('aa', 2)" +== 124 +-- truncate_limit: 100 +insert into part_default values (null, 2) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default VALUES (NULL, 2)" +== 125 +-- truncate_limit: 100 +-- ok +insert into part_default values ('Zz', 2) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default VALUES ('Zz', 2)" +== 126 +-- truncate_limit: 100 +-- test if default partition works as expected for multi-level partitioned +-- table as well as when default partition itself is further partitioned +drop table part_default +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_default" +== 127 +-- truncate_limit: 100 +create table part_xx_yy partition of list_parted for values in ('xx', 'yy') partition by list (a) +-- +TABLE: name="part_xx_yy" schema="" table="part_xx_yy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_xx_yy PARTITION OF list_parted FOR VALUES IN ('xx', 'yy') PARTITION BY LIST (a)" +== 128 +-- truncate_limit: 100 +create table part_xx_yy_p1 partition of part_xx_yy for values in ('xx') +-- +TABLE: name="part_xx_yy_p1" schema="" table="part_xx_yy_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_xx_yy_p1 PARTITION OF part_xx_yy FOR VALUES IN ('xx')" +== 129 +-- truncate_limit: 100 +create table part_xx_yy_defpart partition of part_xx_yy default +-- +TABLE: name="part_xx_yy_defpart" schema="" table="part_xx_yy_defpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_xx_yy_defpart PARTITION OF part_xx_yy DEFAULT" +== 130 +-- truncate_limit: 100 +create table part_default partition of list_parted default partition by range(b) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_default PARTITION OF list_parted DEFAULT PARTITION BY RANGE (b)" +== 131 +-- truncate_limit: 100 +create table part_default_p1 partition of part_default for values from (20) to (30) +-- +TABLE: name="part_default_p1" schema="" table="part_default_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_default_p1 PARTITION OF part_default FOR VALUES FROM (20) TO (30)" +== 132 +-- truncate_limit: 100 +create table part_default_p2 partition of part_default for values from (30) to (40) +-- +TABLE: name="part_default_p2" schema="" table="part_default_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_default_p2 PARTITION OF part_default FOR VALUES FROM (30) TO (40)" +== 133 +-- truncate_limit: 100 +-- fail +insert into part_ee_ff1 values ('EE', 11) +-- +TABLE: name="part_ee_ff1" schema="" table="part_ee_ff1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_ee_ff1 VALUES ('EE', 11)" +== 134 +-- truncate_limit: 100 +insert into part_default_p2 values ('gg', 43) +-- +TABLE: name="part_default_p2" schema="" table="part_default_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default_p2 VALUES ('gg', 43)" +== 135 +-- truncate_limit: 100 +-- fail (even the parent's, ie, part_ee_ff's partition constraint applies) +insert into part_ee_ff1 values ('cc', 1) +-- +TABLE: name="part_ee_ff1" schema="" table="part_ee_ff1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_ee_ff1 VALUES ('cc', 1)" +== 136 +-- truncate_limit: 100 +insert into part_default values ('gg', 43) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default VALUES ('gg', 43)" +== 137 +-- truncate_limit: 100 +-- ok +insert into part_ee_ff1 values ('ff', 1) +-- +TABLE: name="part_ee_ff1" schema="" table="part_ee_ff1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_ee_ff1 VALUES ('ff', 1)" +== 138 +-- truncate_limit: 100 +insert into part_ee_ff2 values ('ff', 11) +-- +TABLE: name="part_ee_ff2" schema="" table="part_ee_ff2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_ee_ff2 VALUES ('ff', 11)" +== 139 +-- truncate_limit: 100 +insert into part_default_p1 values ('cd', 25) +-- +TABLE: name="part_default_p1" schema="" table="part_default_p1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default_p1 VALUES ('cd', 25)" +== 140 +-- truncate_limit: 100 +insert into part_default_p2 values ('de', 35) +-- +TABLE: name="part_default_p2" schema="" table="part_default_p2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default_p2 VALUES ('de', 35)" +== 141 +-- truncate_limit: 100 +insert into list_parted values ('ab', 21) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES ('ab', 21)" +== 142 +-- truncate_limit: 100 +insert into list_parted values ('xx', 1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES ('xx', 1)" +== 143 +-- truncate_limit: 100 +insert into list_parted values ('yy', 2) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES ('yy', 2)" +== 144 +-- truncate_limit: 100 +select tableoid::regclass, * from list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM list_parted" +== 145 +-- truncate_limit: 100 +-- Check tuple routing for partitioned tables + +-- fail +insert into range_parted values ('a', 0) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('a', 0)" +== 146 +-- truncate_limit: 100 +-- ok +insert into range_parted values ('a', 1) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('a', 1)" +== 147 +-- truncate_limit: 100 +insert into range_parted values ('a', 10) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('a', 10)" +== 148 +-- truncate_limit: 100 +-- fail +insert into range_parted values ('a', 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('a', 20)" +== 149 +-- truncate_limit: 100 +-- ok +insert into range_parted values ('b', 1) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('b', 1)" +== 150 +-- truncate_limit: 100 +insert into range_parted values ('b', 10) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('b', 10)" +== 151 +-- truncate_limit: 100 +-- fail (partition key (b+0) is null) +insert into range_parted values ('a') +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('a')" +== 152 +-- truncate_limit: 100 +-- Check default partition +create table part_def partition of range_parted default +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_def PARTITION OF range_parted DEFAULT" +== 153 +-- truncate_limit: 100 +-- fail +insert into part_def values ('b', 10) +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_def VALUES ('b', 10)" +== 154 +-- truncate_limit: 100 +-- ok +insert into part_def values ('c', 10) +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_def VALUES ('c', 10)" +== 155 +-- truncate_limit: 100 +insert into range_parted values (null, null) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES (NULL, NULL)" +== 156 +-- truncate_limit: 100 +insert into range_parted values ('a', null) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('a', NULL)" +== 157 +-- truncate_limit: 100 +insert into range_parted values (null, 19) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES (NULL, 19)" +== 158 +-- truncate_limit: 100 +insert into range_parted values ('b', 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('b', 20)" +== 159 +-- truncate_limit: 100 +select tableoid::regclass, * from range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM range_parted" +== 160 +-- truncate_limit: 100 +-- ok +insert into list_parted values (null, 1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES (NULL, 1)" +== 161 +-- truncate_limit: 100 +insert into list_parted (a) values ('aA') +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted (a) VALUES ('aA')" +== 162 +-- truncate_limit: 100 +-- fail (partition of part_ee_ff not found in both cases) +insert into list_parted values ('EE', 0) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES ('EE', 0)" +== 163 +-- truncate_limit: 100 +insert into part_ee_ff values ('EE', 0) +-- +TABLE: name="part_ee_ff" schema="" table="part_ee_ff" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_ee_ff VALUES ('EE', 0)" +== 164 +-- truncate_limit: 100 +-- ok +insert into list_parted values ('EE', 1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES ('EE', 1)" +== 165 +-- truncate_limit: 100 +insert into part_ee_ff values ('EE', 10) +-- +TABLE: name="part_ee_ff" schema="" table="part_ee_ff" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_ee_ff VALUES ('EE', 10)" +== 166 +-- truncate_limit: 100 +select tableoid::regclass, * from list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM list_parted" +== 167 +-- truncate_limit: 100 +-- some more tests to exercise tuple-routing with multi-level partitioning +create table part_gg partition of list_parted for values in ('gg') partition by range (b) +-- +TABLE: name="part_gg" schema="" table="part_gg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_gg PARTITION OF list_parted FOR VALUES IN ('gg') PARTITION BY RANGE (b)" +== 168 +-- truncate_limit: 100 +create table part_gg1 partition of part_gg for values from (minvalue) to (1) +-- +TABLE: name="part_gg1" schema="" table="part_gg1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_gg1 PARTITION OF part_gg FOR VALUES FROM (minvalue) TO (1)" +== 169 +-- truncate_limit: 100 +create table part_gg2 partition of part_gg for values from (1) to (10) partition by range (b) +-- +TABLE: name="part_gg2" schema="" table="part_gg2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_gg2 PARTITION OF part_gg FOR VALUES FROM (1) TO (10) PARTITION BY RANGE (b)" +== 170 +-- truncate_limit: 100 +create table part_gg2_1 partition of part_gg2 for values from (1) to (5) +-- +TABLE: name="part_gg2_1" schema="" table="part_gg2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_gg2_1 PARTITION OF part_gg2 FOR VALUES FROM (1) TO (5)" +== 171 +-- truncate_limit: 100 +create table part_gg2_2 partition of part_gg2 for values from (5) to (10) +-- +TABLE: name="part_gg2_2" schema="" table="part_gg2_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_gg2_2 PARTITION OF part_gg2 FOR VALUES FROM (5) TO (10)" +== 172 +-- truncate_limit: 100 +create table part_ee_ff3 partition of part_ee_ff for values from (20) to (30) partition by range (b) +-- +TABLE: name="part_ee_ff3" schema="" table="part_ee_ff3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ee_ff3 PARTITION OF part_ee_ff FOR VALUES FROM (20) TO (30) PARTITION BY RANGE (b)" +== 173 +-- truncate_limit: 100 +create table part_ee_ff3_1 partition of part_ee_ff3 for values from (20) to (25) +-- +TABLE: name="part_ee_ff3_1" schema="" table="part_ee_ff3_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ee_ff3_1 PARTITION OF part_ee_ff3 FOR VALUES FROM (20) TO (25)" +== 174 +-- truncate_limit: 100 +create table part_ee_ff3_2 partition of part_ee_ff3 for values from (25) to (30) +-- +TABLE: name="part_ee_ff3_2" schema="" table="part_ee_ff3_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_ee_ff3_2 PARTITION OF part_ee_ff3 FOR VALUES FROM (25) TO (30)" +== 175 +-- truncate_limit: 100 +truncate list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE list_parted" +== 176 +-- truncate_limit: 100 +insert into list_parted values ('aa'), ('cc') +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES ('aa'), ('cc')" +== 177 +-- truncate_limit: 100 +insert into list_parted select 'Ff', s.a from generate_series(1, 29) s(a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted SELECT 'Ff', s.a FROM generate_series(1, 29) s(a)" +== 178 +-- truncate_limit: 100 +insert into list_parted select 'gg', s.a from generate_series(1, 9) s(a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted SELECT 'gg', s.a FROM generate_series(1, 9) s(a)" +== 179 +-- truncate_limit: 100 +insert into list_parted (b) values (1) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted (b) VALUES (1)" +== 180 +-- truncate_limit: 100 +select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_parted group by 1, 2 order by 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM list_parted GROUP BY 1, 2 ORDER BY 1" +== 181 +-- truncate_limit: 100 +-- direct partition inserts should check hash partition bound constraint + +create table hash_parted ( + a int +) partition by hash (a part_test_int4_ops) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_parted (a int) PARTITION BY HASH (a part_test_int4_ops)" +== 182 +-- truncate_limit: 100 +create table hpart0 partition of hash_parted for values with (modulus 4, remainder 0) +-- +TABLE: name="hpart0" schema="" table="hpart0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart0 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 4, REMAINDER 0)" +== 183 +-- truncate_limit: 100 +create table hpart1 partition of hash_parted for values with (modulus 4, remainder 1) +-- +TABLE: name="hpart1" schema="" table="hpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 4, REMAINDER 1)" +== 184 +-- truncate_limit: 100 +create table hpart2 partition of hash_parted for values with (modulus 4, remainder 2) +-- +TABLE: name="hpart2" schema="" table="hpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart2 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 4, REMAINDER 2)" +== 185 +-- truncate_limit: 100 +create table hpart3 partition of hash_parted for values with (modulus 4, remainder 3) +-- +TABLE: name="hpart3" schema="" table="hpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart3 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 4, REMAINDER 3)" +== 186 +-- truncate_limit: 100 +insert into hash_parted values(generate_series(1,10)) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hash_parted VALUES (generate_series(1, 10))" +== 187 +-- truncate_limit: 100 +-- direct insert of values divisible by 4 - ok; +insert into hpart0 values(12),(16) +-- +TABLE: name="hpart0" schema="" table="hpart0" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hpart0 VALUES (12), (16)" +== 188 +-- truncate_limit: 100 +-- fail; +insert into hpart0 values(11) +-- +TABLE: name="hpart0" schema="" table="hpart0" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hpart0 VALUES (11)" +== 189 +-- truncate_limit: 100 +-- 11 % 4 -> 3 remainder i.e. valid data for hpart3 partition +insert into hpart3 values(11) +-- +TABLE: name="hpart3" schema="" table="hpart3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hpart3 VALUES (11)" +== 190 +-- truncate_limit: 100 +-- view data +select tableoid::regclass as part, a, a%4 as "remainder = a % 4" +from hash_parted order by part +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass AS part, a, a % 4 AS \"remainder = a % 4\" FROM hash_parted ORDER BY part" +== 191 +-- truncate_limit: 100 +-- test \d+ output on a table which has both partitioned and unpartitioned +-- partitions + +-- cleanup +drop table range_parted, list_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE range_parted, list_parted" +== 192 +-- truncate_limit: 100 +drop table hash_parted +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hash_parted" +== 193 +-- truncate_limit: 100 +-- test that a default partition added as the first partition accepts any value +-- including null +create table list_parted (a int) partition by list (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted (a int) PARTITION BY LIST (a)" +== 194 +-- truncate_limit: 100 +create table part_default partition of list_parted default +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_default PARTITION OF list_parted DEFAULT" +== 195 +-- truncate_limit: 100 +insert into part_default values (null) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default VALUES (NULL)" +== 196 +-- truncate_limit: 100 +insert into part_default values (1) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default VALUES (1)" +== 197 +-- truncate_limit: 100 +insert into part_default values (-1) +-- +TABLE: name="part_default" schema="" table="part_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_default VALUES (-1)" +== 198 +-- truncate_limit: 100 +select tableoid::regclass, a from list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, a FROM list_parted" +== 199 +-- truncate_limit: 100 +-- cleanup +drop table list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE list_parted" +== 200 +-- truncate_limit: 100 +-- more tests for certain multi-level partitioning scenarios +create table mlparted (a int, b int) partition by range (a, b) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted (a int, b int) PARTITION BY RANGE (a, b)" +== 201 +-- truncate_limit: 100 +create table mlparted1 (b int not null, a int not null) partition by range ((b+0)) +-- +TABLE: name="mlparted1" schema="" table="mlparted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted1 (b int NOT NULL, a int NOT NULL) PARTITION BY RANGE ((b + 0))" +== 202 +-- truncate_limit: 100 +create table mlparted11 (like mlparted1) +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted11 (LIKE mlparted1)" +== 203 +-- truncate_limit: 100 +alter table mlparted11 drop a +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted11 DROP a" +== 204 +-- truncate_limit: 100 +alter table mlparted11 add a int +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted11 ADD COLUMN a int" +== 205 +-- truncate_limit: 100 +alter table mlparted11 drop a +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted11 DROP a" +== 206 +-- truncate_limit: 100 +alter table mlparted11 add a int not null +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted11 ADD COLUMN a int NOT NULL" +== 207 +-- truncate_limit: 100 +-- attnum for key attribute 'a' is different in mlparted, mlparted1, and mlparted11 +select attrelid::regclass, attname, attnum +from pg_attribute +where attname = 'a' + and (attrelid = 'mlparted'::regclass + or attrelid = 'mlparted1'::regclass + or attrelid = 'mlparted11'::regclass) +order by attrelid::regclass::text +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +FILTER: schema="" table="" column="attname" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="" column="attrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_attribute WHERE ... ORDER BY attrelid::regclass::text" +== 208 +-- truncate_limit: 100 +alter table mlparted1 attach partition mlparted11 for values from (2) to (5) +-- +TABLE: name="mlparted1" schema="" table="mlparted1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted1 ATTACH PARTITION mlparted11 FOR VALUES FROM (2) TO (5)" +== 209 +-- truncate_limit: 100 +alter table mlparted attach partition mlparted1 for values from (1, 2) to (1, 10) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ATTACH PARTITION mlparted1 FOR VALUES FROM (1, 2) TO (1, 10)" +== 210 +-- truncate_limit: 100 +-- check that "(1, 2)" is correctly routed to mlparted11. +insert into mlparted values (1, 2) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 2)" +== 211 +-- truncate_limit: 100 +select tableoid::regclass, * from mlparted +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM mlparted" +== 212 +-- truncate_limit: 100 +-- check that proper message is shown after failure to route through mlparted1 +insert into mlparted (a, b) values (1, 5) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted (a, b) VALUES (1, 5)" +== 213 +-- truncate_limit: 100 +truncate mlparted +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mlparted" +== 214 +-- truncate_limit: 100 +alter table mlparted add constraint check_b check (b = 3) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ADD CONSTRAINT check_b CHECK (b = 3)" +== 215 +-- truncate_limit: 100 +-- have a BR trigger modify the row such that the check_b is violated +create function mlparted11_trig_fn() +returns trigger AS +$$ +begin + NEW.b := 4; + return NEW; +end; +$$ +language plpgsql +-- +FUNCTION: name="mlparted11_trig_fn" function="mlparted11_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mlparted11_trig_fn() RETURNS trigger AS $$\nbegin\n NEW.b := 4;\n return NEW;\nend;..." +== 216 +-- truncate_limit: 100 +create trigger mlparted11_trig before insert ON mlparted11 + for each row execute procedure mlparted11_trig_fn() +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER mlparted11_trig BEFORE INSERT ON mlparted11 FOR EACH ROW EXECUTE FUNCTION mlparted..." +== 217 +-- truncate_limit: 100 +-- check that the correct row is shown when constraint check_b fails after +-- "(1, 2)" is routed to mlparted11 (actually "(1, 4)" would be shown due +-- to the BR trigger mlparted11_trig_fn) +insert into mlparted values (1, 2) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 2)" +== 218 +-- truncate_limit: 100 +drop trigger mlparted11_trig on mlparted11 +-- +TABLE: name="mlparted11" schema="" table="mlparted11" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER mlparted11_trig ON mlparted11" +== 219 +-- truncate_limit: 100 +drop function mlparted11_trig_fn() +-- +FUNCTION: name="mlparted11_trig_fn" function="mlparted11_trig_fn" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION mlparted11_trig_fn()" +== 220 +-- truncate_limit: 100 +-- check that inserting into an internal partition successfully results in +-- checking its partition constraint before inserting into the leaf partition +-- selected by tuple-routing +insert into mlparted1 (a, b) values (2, 3) +-- +TABLE: name="mlparted1" schema="" table="mlparted1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted1 (a, b) VALUES (2, 3)" +== 221 +-- truncate_limit: 100 +-- check routing error through a list partitioned table when the key is null +create table lparted_nonullpart (a int, b char) partition by list (b) +-- +TABLE: name="lparted_nonullpart" schema="" table="lparted_nonullpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lparted_nonullpart (a int, b char(1)) PARTITION BY LIST (b)" +== 222 +-- truncate_limit: 100 +create table lparted_nonullpart_a partition of lparted_nonullpart for values in ('a') +-- +TABLE: name="lparted_nonullpart_a" schema="" table="lparted_nonullpart_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lparted_nonullpart_a PARTITION OF lparted_nonullpart FOR VALUES IN ('a')" +== 223 +-- truncate_limit: 100 +insert into lparted_nonullpart values (1) +-- +TABLE: name="lparted_nonullpart" schema="" table="lparted_nonullpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lparted_nonullpart VALUES (1)" +== 224 +-- truncate_limit: 100 +drop table lparted_nonullpart +-- +TABLE: name="lparted_nonullpart" schema="" table="lparted_nonullpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lparted_nonullpart" +== 225 +-- truncate_limit: 100 +-- check that RETURNING works correctly with tuple-routing +alter table mlparted drop constraint check_b +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted DROP CONSTRAINT check_b" +== 226 +-- truncate_limit: 100 +create table mlparted12 partition of mlparted1 for values from (5) to (10) +-- +TABLE: name="mlparted12" schema="" table="mlparted12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted12 PARTITION OF mlparted1 FOR VALUES FROM (5) TO (10)" +== 227 +-- truncate_limit: 100 +create table mlparted2 (b int not null, a int not null) +-- +TABLE: name="mlparted2" schema="" table="mlparted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted2 (b int NOT NULL, a int NOT NULL)" +== 228 +-- truncate_limit: 100 +alter table mlparted attach partition mlparted2 for values from (1, 10) to (1, 20) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ATTACH PARTITION mlparted2 FOR VALUES FROM (1, 10) TO (1, 20)" +== 229 +-- truncate_limit: 100 +create table mlparted3 partition of mlparted for values from (1, 20) to (1, 30) +-- +TABLE: name="mlparted3" schema="" table="mlparted3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted3 PARTITION OF mlparted FOR VALUES FROM (1, 20) TO (1, 30)" +== 230 +-- truncate_limit: 100 +create table mlparted4 (like mlparted) +-- +TABLE: name="mlparted4" schema="" table="mlparted4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted4 (LIKE mlparted)" +== 231 +-- truncate_limit: 100 +alter table mlparted4 drop a +-- +TABLE: name="mlparted4" schema="" table="mlparted4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted4 DROP a" +== 232 +-- truncate_limit: 100 +alter table mlparted4 add a int not null +-- +TABLE: name="mlparted4" schema="" table="mlparted4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted4 ADD COLUMN a int NOT NULL" +== 233 +-- truncate_limit: 100 +alter table mlparted attach partition mlparted4 for values from (1, 30) to (1, 40) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ATTACH PARTITION mlparted4 FOR VALUES FROM (1, 30) TO (1, 40)" +== 234 +-- truncate_limit: 100 +with ins (a, b, c) as + (insert into mlparted (b, a) select s.a, 1 from generate_series(2, 39) s(a) returning tableoid::regclass, *) + select a, b, min(c), max(c) from ins group by a, b order by 1 +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +CTE: "ins" +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH ins(a, b, c) AS (...) SELECT a, b, min(c), max(c) FROM ins GROUP BY a, b ORDER BY 1" +== 235 +-- truncate_limit: 100 +alter table mlparted add c text +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ADD COLUMN c text" +== 236 +-- truncate_limit: 100 +create table mlparted5 (c text, a int not null, b int not null) partition by list (c) +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted5 (c text, a int NOT NULL, b int NOT NULL) PARTITION BY LIST (c)" +== 237 +-- truncate_limit: 100 +create table mlparted5a (a int not null, c text, b int not null) +-- +TABLE: name="mlparted5a" schema="" table="mlparted5a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted5a (a int NOT NULL, c text, b int NOT NULL)" +== 238 +-- truncate_limit: 100 +alter table mlparted5 attach partition mlparted5a for values in ('a') +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted5 ATTACH PARTITION mlparted5a FOR VALUES IN ('a')" +== 239 +-- truncate_limit: 100 +alter table mlparted attach partition mlparted5 for values from (1, 40) to (1, 50) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ATTACH PARTITION mlparted5 FOR VALUES FROM (1, 40) TO (1, 50)" +== 240 +-- truncate_limit: 100 +alter table mlparted add constraint check_b check (a = 1 and b < 45) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ADD CONSTRAINT check_b CHECK (a = 1 AND b < 45)" +== 241 +-- truncate_limit: 100 +insert into mlparted values (1, 45, 'a') +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 45, 'a')" +== 242 +-- truncate_limit: 100 +create function mlparted5abrtrig_func() returns trigger as $$ begin new.c = 'b'; return new; end; $$ language plpgsql +-- +FUNCTION: name="mlparted5abrtrig_func" function="mlparted5abrtrig_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mlparted5abrtrig_func() RETURNS trigger AS $$ begin new.c = 'b'; return new; end;..." +== 243 +-- truncate_limit: 100 +create trigger mlparted5abrtrig before insert on mlparted5a for each row execute procedure mlparted5abrtrig_func() +-- +TABLE: name="mlparted5a" schema="" table="mlparted5a" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER mlparted5abrtrig BEFORE INSERT ON mlparted5a FOR EACH ROW EXECUTE FUNCTION mlparte..." +== 244 +-- truncate_limit: 100 +insert into mlparted5 (a, b, c) values (1, 40, 'a') +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted5 (a, b, c) VALUES (1, 40, 'a')" +== 245 +-- truncate_limit: 100 +drop table mlparted5 +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mlparted5" +== 246 +-- truncate_limit: 100 +alter table mlparted drop constraint check_b +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted DROP CONSTRAINT check_b" +== 247 +-- truncate_limit: 100 +-- Check multi-level default partition +create table mlparted_def partition of mlparted default partition by range(a) +-- +TABLE: name="mlparted_def" schema="" table="mlparted_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_def PARTITION OF mlparted DEFAULT PARTITION BY RANGE (a)" +== 248 +-- truncate_limit: 100 +create table mlparted_def1 partition of mlparted_def for values from (40) to (50) +-- +TABLE: name="mlparted_def1" schema="" table="mlparted_def1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_def1 PARTITION OF mlparted_def FOR VALUES FROM (40) TO (50)" +== 249 +-- truncate_limit: 100 +create table mlparted_def2 partition of mlparted_def for values from (50) to (60) +-- +TABLE: name="mlparted_def2" schema="" table="mlparted_def2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_def2 PARTITION OF mlparted_def FOR VALUES FROM (50) TO (60)" +== 250 +-- truncate_limit: 100 +insert into mlparted values (40, 100) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (40, 100)" +== 251 +-- truncate_limit: 100 +insert into mlparted_def1 values (42, 100) +-- +TABLE: name="mlparted_def1" schema="" table="mlparted_def1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted_def1 VALUES (42, 100)" +== 252 +-- truncate_limit: 100 +insert into mlparted_def2 values (54, 50) +-- +TABLE: name="mlparted_def2" schema="" table="mlparted_def2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted_def2 VALUES (54, 50)" +== 253 +-- truncate_limit: 100 +-- fail +insert into mlparted values (70, 100) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (70, 100)" +== 254 +-- truncate_limit: 100 +insert into mlparted_def1 values (52, 50) +-- +TABLE: name="mlparted_def1" schema="" table="mlparted_def1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted_def1 VALUES (52, 50)" +== 255 +-- truncate_limit: 100 +insert into mlparted_def2 values (34, 50) +-- +TABLE: name="mlparted_def2" schema="" table="mlparted_def2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted_def2 VALUES (34, 50)" +== 256 +-- truncate_limit: 100 +-- ok +create table mlparted_defd partition of mlparted_def default +-- +TABLE: name="mlparted_defd" schema="" table="mlparted_defd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted_defd PARTITION OF mlparted_def DEFAULT" +== 257 +-- truncate_limit: 100 +insert into mlparted values (70, 100) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (70, 100)" +== 258 +-- truncate_limit: 100 +select tableoid::regclass, * from mlparted_def +-- +TABLE: name="mlparted_def" schema="" table="mlparted_def" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM mlparted_def" +== 259 +-- truncate_limit: 100 +-- Check multi-level tuple routing with attributes dropped from the +-- top-most parent. First remove the last attribute. +alter table mlparted add d int, add e int +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ADD COLUMN d int, ADD COLUMN e int" +== 260 +-- truncate_limit: 100 +alter table mlparted drop e +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted DROP e" +== 261 +-- truncate_limit: 100 +create table mlparted5 partition of mlparted + for values from (1, 40) to (1, 50) partition by range (c) +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted5 PARTITION OF mlparted FOR VALUES FROM (1, 40) TO (1, 50) PARTITION BY RANG..." +== 262 +-- truncate_limit: 100 +create table mlparted5_ab partition of mlparted5 + for values from ('a') to ('c') partition by list (c) +-- +TABLE: name="mlparted5_ab" schema="" table="mlparted5_ab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted5_ab PARTITION OF mlparted5 FOR VALUES FROM ('a') TO ('c') PARTITION BY LIST..." +== 263 +-- truncate_limit: 100 +-- This partitioned table should remain with no partitions. +create table mlparted5_cd partition of mlparted5 + for values from ('c') to ('e') partition by list (c) +-- +TABLE: name="mlparted5_cd" schema="" table="mlparted5_cd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted5_cd PARTITION OF mlparted5 FOR VALUES FROM ('c') TO ('e') PARTITION BY LIST..." +== 264 +-- truncate_limit: 100 +create table mlparted5_a partition of mlparted5_ab for values in ('a') +-- +TABLE: name="mlparted5_a" schema="" table="mlparted5_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted5_a PARTITION OF mlparted5_ab FOR VALUES IN ('a')" +== 265 +-- truncate_limit: 100 +create table mlparted5_b (d int, b int, c text, a int) +-- +TABLE: name="mlparted5_b" schema="" table="mlparted5_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mlparted5_b (d int, b int, c text, a int)" +== 266 +-- truncate_limit: 100 +alter table mlparted5_ab attach partition mlparted5_b for values in ('b') +-- +TABLE: name="mlparted5_ab" schema="" table="mlparted5_ab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted5_ab ATTACH PARTITION mlparted5_b FOR VALUES IN ('b')" +== 267 +-- truncate_limit: 100 +truncate mlparted +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mlparted" +== 268 +-- truncate_limit: 100 +insert into mlparted values (1, 2, 'a', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 2, 'a', 1)" +== 269 +-- truncate_limit: 100 +insert into mlparted values (1, 40, 'a', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 40, 'a', 1)" +== 270 +-- truncate_limit: 100 +-- goes to mlparted5_a +insert into mlparted values (1, 45, 'b', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 45, 'b', 1)" +== 271 +-- truncate_limit: 100 +-- goes to mlparted5_b +insert into mlparted values (1, 45, 'c', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 45, 'c', 1)" +== 272 +-- truncate_limit: 100 +-- goes to mlparted5_cd, fails +insert into mlparted values (1, 45, 'f', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 45, 'f', 1)" +== 273 +-- truncate_limit: 100 +-- goes to mlparted5, fails +select tableoid::regclass, * from mlparted order by a, b, c, d +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM mlparted ORDER BY a, b, c, d" +== 274 +-- truncate_limit: 100 +alter table mlparted drop d +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted DROP d" +== 275 +-- truncate_limit: 100 +truncate mlparted +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mlparted" +== 276 +-- truncate_limit: 100 +-- Remove the before last attribute. +alter table mlparted add e int, add d int +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted ADD COLUMN e int, ADD COLUMN d int" +== 277 +-- truncate_limit: 100 +alter table mlparted drop e +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted DROP e" +== 278 +-- truncate_limit: 100 +insert into mlparted values (1, 2, 'a', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 2, 'a', 1)" +== 279 +-- truncate_limit: 100 +insert into mlparted values (1, 40, 'a', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 40, 'a', 1)" +== 280 +-- truncate_limit: 100 +-- goes to mlparted5_a +insert into mlparted values (1, 45, 'b', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 45, 'b', 1)" +== 281 +-- truncate_limit: 100 +-- goes to mlparted5_b +insert into mlparted values (1, 45, 'c', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 45, 'c', 1)" +== 282 +-- truncate_limit: 100 +-- goes to mlparted5_cd, fails +insert into mlparted values (1, 45, 'f', 1) +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mlparted VALUES (1, 45, 'f', 1)" +== 283 +-- truncate_limit: 100 +-- goes to mlparted5, fails +select tableoid::regclass, * from mlparted order by a, b, c, d +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM mlparted ORDER BY a, b, c, d" +== 284 +-- truncate_limit: 100 +alter table mlparted drop d +-- +TABLE: name="mlparted" schema="" table="mlparted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mlparted DROP d" +== 285 +-- truncate_limit: 100 +drop table mlparted5 +-- +TABLE: name="mlparted5" schema="" table="mlparted5" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mlparted5" +== 286 +-- truncate_limit: 100 +-- check that message shown after failure to find a partition shows the +-- appropriate key description (or none) in various situations +create table key_desc (a int, b int) partition by list ((a+0)) +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE key_desc (a int, b int) PARTITION BY LIST ((a + 0))" +== 287 +-- truncate_limit: 100 +create table key_desc_1 partition of key_desc for values in (1) partition by range (b) +-- +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE key_desc_1 PARTITION OF key_desc FOR VALUES IN (1) PARTITION BY RANGE (b)" +== 288 +-- truncate_limit: 100 +create user regress_insert_other_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_insert_other_user" +== 289 +-- truncate_limit: 100 +grant select (a) on key_desc_1 to regress_insert_other_user +-- +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (a) ON key_desc_1 TO regress_insert_other_user" +== 290 +-- truncate_limit: 100 +grant insert on key_desc to regress_insert_other_user +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON key_desc TO regress_insert_other_user" +== 291 +-- truncate_limit: 100 +set role regress_insert_other_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_insert_other_user" +== 292 +-- truncate_limit: 100 +-- no key description is shown +insert into key_desc values (1, 1) +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO key_desc VALUES (1, 1)" +== 293 +-- truncate_limit: 100 +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 294 +-- truncate_limit: 100 +grant select (b) on key_desc_1 to regress_insert_other_user +-- +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (b) ON key_desc_1 TO regress_insert_other_user" +== 295 +-- truncate_limit: 100 +set role regress_insert_other_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_insert_other_user" +== 296 +-- truncate_limit: 100 +-- key description (b)=(1) is now shown +insert into key_desc values (1, 1) +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO key_desc VALUES (1, 1)" +== 297 +-- truncate_limit: 100 +-- key description is not shown if key contains expression +insert into key_desc values (2, 1) +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO key_desc VALUES (2, 1)" +== 298 +-- truncate_limit: 100 +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 299 +-- truncate_limit: 100 +revoke all on key_desc from regress_insert_other_user +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON key_desc FROM regress_insert_other_user" +== 300 +-- truncate_limit: 100 +revoke all on key_desc_1 from regress_insert_other_user +-- +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON key_desc_1 FROM regress_insert_other_user" +== 301 +-- truncate_limit: 100 +drop role regress_insert_other_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_insert_other_user" +== 302 +-- truncate_limit: 100 +drop table key_desc, key_desc_1 +-- +TABLE: name="key_desc" schema="" table="key_desc" ctx=DDL +TABLE: name="key_desc_1" schema="" table="key_desc_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE key_desc, key_desc_1" +== 303 +-- truncate_limit: 100 +-- test minvalue/maxvalue restrictions +create table mcrparted (a int, b int, c int) partition by range (a, abs(b), c) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted (a int, b int, c int) PARTITION BY RANGE (a, (abs(b)), c)" +== 304 +-- truncate_limit: 100 +create table mcrparted0 partition of mcrparted for values from (minvalue, 0, 0) to (1, maxvalue, maxvalue) +-- +TABLE: name="mcrparted0" schema="" table="mcrparted0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted0 PARTITION OF mcrparted FOR VALUES FROM (minvalue, 0, 0) TO (1, maxvalue, ..." +== 305 +-- truncate_limit: 100 +create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue) to (10, maxvalue, minvalue) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted2 PARTITION OF mcrparted FOR VALUES FROM (10, 6, minvalue) TO (10, maxvalue..." +== 306 +-- truncate_limit: 100 +create table mcrparted4 partition of mcrparted for values from (21, minvalue, 0) to (30, 20, minvalue) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted4 PARTITION OF mcrparted FOR VALUES FROM (21, minvalue, 0) TO (30, 20, minv..." +== 307 +-- truncate_limit: 100 +-- check multi-column range partitioning expression enforces the same +-- constraint as what tuple-routing would determine it to be +create table mcrparted0 partition of mcrparted for values from (minvalue, minvalue, minvalue) to (1, maxvalue, maxvalue) +-- +TABLE: name="mcrparted0" schema="" table="mcrparted0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted0 PARTITION OF mcrparted FOR VALUES FROM (minvalue, minvalue, minvalue) TO ..." +== 308 +-- truncate_limit: 100 +create table mcrparted1 partition of mcrparted for values from (2, 1, minvalue) to (10, 5, 10) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted1 PARTITION OF mcrparted FOR VALUES FROM (2, 1, minvalue) TO (10, 5, 10)" +== 309 +-- truncate_limit: 100 +create table mcrparted2 partition of mcrparted for values from (10, 6, minvalue) to (10, maxvalue, maxvalue) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted2 PARTITION OF mcrparted FOR VALUES FROM (10, 6, minvalue) TO (10, maxvalue..." +== 310 +-- truncate_limit: 100 +create table mcrparted3 partition of mcrparted for values from (11, 1, 1) to (20, 10, 10) +-- +TABLE: name="mcrparted3" schema="" table="mcrparted3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted3 PARTITION OF mcrparted FOR VALUES FROM (11, 1, 1) TO (20, 10, 10)" +== 311 +-- truncate_limit: 100 +create table mcrparted4 partition of mcrparted for values from (21, minvalue, minvalue) to (30, 20, maxvalue) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted4 PARTITION OF mcrparted FOR VALUES FROM (21, minvalue, minvalue) TO (30, 2..." +== 312 +-- truncate_limit: 100 +create table mcrparted5 partition of mcrparted for values from (30, 21, 20) to (maxvalue, maxvalue, maxvalue) +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted5 PARTITION OF mcrparted FOR VALUES FROM (30, 21, 20) TO (maxvalue, maxvalu..." +== 313 +-- truncate_limit: 100 +-- null not allowed in range partition +insert into mcrparted values (null, null, null) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (NULL, NULL, NULL)" +== 314 +-- truncate_limit: 100 +-- routed to mcrparted0 +insert into mcrparted values (0, 1, 1) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (0, 1, 1)" +== 315 +-- truncate_limit: 100 +insert into mcrparted0 values (0, 1, 1) +-- +TABLE: name="mcrparted0" schema="" table="mcrparted0" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted0 VALUES (0, 1, 1)" +== 316 +-- truncate_limit: 100 +-- routed to mcparted1 +insert into mcrparted values (9, 1000, 1) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (9, 1000, 1)" +== 317 +-- truncate_limit: 100 +insert into mcrparted1 values (9, 1000, 1) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted1 VALUES (9, 1000, 1)" +== 318 +-- truncate_limit: 100 +insert into mcrparted values (10, 5, -1) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (10, 5, -1)" +== 319 +-- truncate_limit: 100 +insert into mcrparted1 values (10, 5, -1) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted1 VALUES (10, 5, -1)" +== 320 +-- truncate_limit: 100 +insert into mcrparted values (2, 1, 0) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (2, 1, 0)" +== 321 +-- truncate_limit: 100 +insert into mcrparted1 values (2, 1, 0) +-- +TABLE: name="mcrparted1" schema="" table="mcrparted1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted1 VALUES (2, 1, 0)" +== 322 +-- truncate_limit: 100 +-- routed to mcparted2 +insert into mcrparted values (10, 6, 1000) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (10, 6, 1000)" +== 323 +-- truncate_limit: 100 +insert into mcrparted2 values (10, 6, 1000) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted2 VALUES (10, 6, 1000)" +== 324 +-- truncate_limit: 100 +insert into mcrparted values (10, 1000, 1000) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (10, 1000, 1000)" +== 325 +-- truncate_limit: 100 +insert into mcrparted2 values (10, 1000, 1000) +-- +TABLE: name="mcrparted2" schema="" table="mcrparted2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted2 VALUES (10, 1000, 1000)" +== 326 +-- truncate_limit: 100 +-- no partition exists, nor does mcrparted3 accept it +insert into mcrparted values (11, 1, -1) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (11, 1, -1)" +== 327 +-- truncate_limit: 100 +insert into mcrparted3 values (11, 1, -1) +-- +TABLE: name="mcrparted3" schema="" table="mcrparted3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted3 VALUES (11, 1, -1)" +== 328 +-- truncate_limit: 100 +-- routed to mcrparted5 +insert into mcrparted values (30, 21, 20) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (30, 21, 20)" +== 329 +-- truncate_limit: 100 +insert into mcrparted5 values (30, 21, 20) +-- +TABLE: name="mcrparted5" schema="" table="mcrparted5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted5 VALUES (30, 21, 20)" +== 330 +-- truncate_limit: 100 +insert into mcrparted4 values (30, 21, 20) +-- +TABLE: name="mcrparted4" schema="" table="mcrparted4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted4 VALUES (30, 21, 20)" +== 331 +-- truncate_limit: 100 +-- error + +-- check rows +select tableoid::regclass::text, * from mcrparted order by 1 +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text, * FROM mcrparted ORDER BY 1" +== 332 +-- truncate_limit: 100 +-- cleanup +drop table mcrparted +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcrparted" +== 333 +-- truncate_limit: 100 +-- check that a BR constraint can't make partition contain violating rows +create table brtrigpartcon (a int, b text) partition by list (a) +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brtrigpartcon (a int, b text) PARTITION BY LIST (a)" +== 334 +-- truncate_limit: 100 +create table brtrigpartcon1 partition of brtrigpartcon for values in (1) +-- +TABLE: name="brtrigpartcon1" schema="" table="brtrigpartcon1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brtrigpartcon1 PARTITION OF brtrigpartcon FOR VALUES IN (1)" +== 335 +-- truncate_limit: 100 +create or replace function brtrigpartcon1trigf() returns trigger as $$begin new.a := 2; return new; end$$ language plpgsql +-- +FUNCTION: name="brtrigpartcon1trigf" function="brtrigpartcon1trigf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION brtrigpartcon1trigf() RETURNS trigger AS $$begin new.a := 2; return ne..." +== 336 +-- truncate_limit: 100 +create trigger brtrigpartcon1trig before insert on brtrigpartcon1 for each row execute procedure brtrigpartcon1trigf() +-- +TABLE: name="brtrigpartcon1" schema="" table="brtrigpartcon1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER brtrigpartcon1trig BEFORE INSERT ON brtrigpartcon1 FOR EACH ROW EXECUTE FUNCTION b..." +== 337 +-- truncate_limit: 100 +insert into brtrigpartcon values (1, 'hi there') +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brtrigpartcon VALUES (1, 'hi there')" +== 338 +-- truncate_limit: 100 +insert into brtrigpartcon1 values (1, 'hi there') +-- +TABLE: name="brtrigpartcon1" schema="" table="brtrigpartcon1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brtrigpartcon1 VALUES (1, 'hi there')" +== 339 +-- truncate_limit: 100 +-- check that the message shows the appropriate column description in a +-- situation where the partitioned table is not the primary ModifyTable node +create table inserttest3 (f1 text default 'foo', f2 text default 'bar', f3 int) +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inserttest3 (f1 text DEFAULT 'foo', f2 text DEFAULT 'bar', f3 int)" +== 340 +-- truncate_limit: 100 +create role regress_coldesc_role +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_coldesc_role" +== 341 +-- truncate_limit: 100 +grant insert on inserttest3 to regress_coldesc_role +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON inserttest3 TO regress_coldesc_role" +== 342 +-- truncate_limit: 100 +grant insert on brtrigpartcon to regress_coldesc_role +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON brtrigpartcon TO regress_coldesc_role" +== 343 +-- truncate_limit: 100 +revoke select on brtrigpartcon from regress_coldesc_role +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE select ON brtrigpartcon FROM regress_coldesc_role" +== 344 +-- truncate_limit: 100 +set role regress_coldesc_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_coldesc_role" +== 345 +-- truncate_limit: 100 +with result as (insert into brtrigpartcon values (1, 'hi there') returning 1) + insert into inserttest3 (f3) select * from result +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DML +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DML +CTE: "result" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH result AS (...) INSERT INTO inserttest3 (f3) SELECT * FROM result" +== 346 +-- truncate_limit: 100 +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 347 +-- truncate_limit: 100 +-- cleanup +revoke all on inserttest3 from regress_coldesc_role +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON inserttest3 FROM regress_coldesc_role" +== 348 +-- truncate_limit: 100 +revoke all on brtrigpartcon from regress_coldesc_role +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON brtrigpartcon FROM regress_coldesc_role" +== 349 +-- truncate_limit: 100 +drop role regress_coldesc_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_coldesc_role" +== 350 +-- truncate_limit: 100 +drop table inserttest3 +-- +TABLE: name="inserttest3" schema="" table="inserttest3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inserttest3" +== 351 +-- truncate_limit: 100 +drop table brtrigpartcon +-- +TABLE: name="brtrigpartcon" schema="" table="brtrigpartcon" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brtrigpartcon" +== 352 +-- truncate_limit: 100 +drop function brtrigpartcon1trigf() +-- +FUNCTION: name="brtrigpartcon1trigf" function="brtrigpartcon1trigf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION brtrigpartcon1trigf()" +== 353 +-- truncate_limit: 100 +-- check that "do nothing" BR triggers work with tuple-routing +create table donothingbrtrig_test (a int, b text) partition by list (a) +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE donothingbrtrig_test (a int, b text) PARTITION BY LIST (a)" +== 354 +-- truncate_limit: 100 +create table donothingbrtrig_test1 (b text, a int) +-- +TABLE: name="donothingbrtrig_test1" schema="" table="donothingbrtrig_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE donothingbrtrig_test1 (b text, a int)" +== 355 +-- truncate_limit: 100 +create table donothingbrtrig_test2 (c text, b text, a int) +-- +TABLE: name="donothingbrtrig_test2" schema="" table="donothingbrtrig_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE donothingbrtrig_test2 (c text, b text, a int)" +== 356 +-- truncate_limit: 100 +alter table donothingbrtrig_test2 drop column c +-- +TABLE: name="donothingbrtrig_test2" schema="" table="donothingbrtrig_test2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE donothingbrtrig_test2 DROP c" +== 357 +-- truncate_limit: 100 +create or replace function donothingbrtrig_func() returns trigger as $$begin raise notice 'b: %', new.b; return NULL; end$$ language plpgsql +-- +FUNCTION: name="donothingbrtrig_func" function="donothingbrtrig_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION donothingbrtrig_func() RETURNS trigger AS $$begin raise notice 'b: %',..." +== 358 +-- truncate_limit: 100 +create trigger donothingbrtrig1 before insert on donothingbrtrig_test1 for each row execute procedure donothingbrtrig_func() +-- +TABLE: name="donothingbrtrig_test1" schema="" table="donothingbrtrig_test1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER donothingbrtrig1 BEFORE INSERT ON donothingbrtrig_test1 FOR EACH ROW EXECUTE FUNCT..." +== 359 +-- truncate_limit: 100 +create trigger donothingbrtrig2 before insert on donothingbrtrig_test2 for each row execute procedure donothingbrtrig_func() +-- +TABLE: name="donothingbrtrig_test2" schema="" table="donothingbrtrig_test2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER donothingbrtrig2 BEFORE INSERT ON donothingbrtrig_test2 FOR EACH ROW EXECUTE FUNCT..." +== 360 +-- truncate_limit: 100 +alter table donothingbrtrig_test attach partition donothingbrtrig_test1 for values in (1) +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE donothingbrtrig_test ATTACH PARTITION donothingbrtrig_test1 FOR VALUES IN (1)" +== 361 +-- truncate_limit: 100 +alter table donothingbrtrig_test attach partition donothingbrtrig_test2 for values in (2) +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE donothingbrtrig_test ATTACH PARTITION donothingbrtrig_test2 FOR VALUES IN (2)" +== 362 +-- truncate_limit: 100 +insert into donothingbrtrig_test values (1, 'foo'), (2, 'bar') +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO donothingbrtrig_test VALUES (1, 'foo'), (2, 'bar')" +== 363 +-- truncate_limit: 100 +copy donothingbrtrig_test from stdout +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY donothingbrtrig_test FROM STDIN" +== 364 +-- truncate_limit: 100 +1 baz +2 qux +select tableoid::regclass, * from donothingbrtrig_test +-- +ERROR: syntax error at or near "1" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 365 +-- truncate_limit: 100 +-- cleanup +drop table donothingbrtrig_test +-- +TABLE: name="donothingbrtrig_test" schema="" table="donothingbrtrig_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE donothingbrtrig_test" +== 366 +-- truncate_limit: 100 +drop function donothingbrtrig_func() +-- +FUNCTION: name="donothingbrtrig_func" function="donothingbrtrig_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION donothingbrtrig_func()" +== 367 +-- truncate_limit: 100 +-- check multi-column range partitioning with minvalue/maxvalue constraints +create table mcrparted (a text, b int) partition by range(a, b) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted (a text, b int) PARTITION BY RANGE (a, b)" +== 368 +-- truncate_limit: 100 +create table mcrparted1_lt_b partition of mcrparted for values from (minvalue, minvalue) to ('b', minvalue) +-- +TABLE: name="mcrparted1_lt_b" schema="" table="mcrparted1_lt_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted1_lt_b PARTITION OF mcrparted FOR VALUES FROM (minvalue, minvalue) TO ('b',..." +== 369 +-- truncate_limit: 100 +create table mcrparted2_b partition of mcrparted for values from ('b', minvalue) to ('c', minvalue) +-- +TABLE: name="mcrparted2_b" schema="" table="mcrparted2_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted2_b PARTITION OF mcrparted FOR VALUES FROM ('b', minvalue) TO ('c', minvalue)" +== 370 +-- truncate_limit: 100 +create table mcrparted3_c_to_common partition of mcrparted for values from ('c', minvalue) to ('common', minvalue) +-- +TABLE: name="mcrparted3_c_to_common" schema="" table="mcrparted3_c_to_common" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted3_c_to_common PARTITION OF mcrparted FOR VALUES FROM ('c', minvalue) TO ('c..." +== 371 +-- truncate_limit: 100 +create table mcrparted4_common_lt_0 partition of mcrparted for values from ('common', minvalue) to ('common', 0) +-- +TABLE: name="mcrparted4_common_lt_0" schema="" table="mcrparted4_common_lt_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted4_common_lt_0 PARTITION OF mcrparted FOR VALUES FROM ('common', minvalue) T..." +== 372 +-- truncate_limit: 100 +create table mcrparted5_common_0_to_10 partition of mcrparted for values from ('common', 0) to ('common', 10) +-- +TABLE: name="mcrparted5_common_0_to_10" schema="" table="mcrparted5_common_0_to_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted5_common_0_to_10 PARTITION OF mcrparted FOR VALUES FROM ('common', 0) TO ('..." +== 373 +-- truncate_limit: 100 +create table mcrparted6_common_ge_10 partition of mcrparted for values from ('common', 10) to ('common', maxvalue) +-- +TABLE: name="mcrparted6_common_ge_10" schema="" table="mcrparted6_common_ge_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted6_common_ge_10 PARTITION OF mcrparted FOR VALUES FROM ('common', 10) TO ('c..." +== 374 +-- truncate_limit: 100 +create table mcrparted7_gt_common_lt_d partition of mcrparted for values from ('common', maxvalue) to ('d', minvalue) +-- +TABLE: name="mcrparted7_gt_common_lt_d" schema="" table="mcrparted7_gt_common_lt_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted7_gt_common_lt_d PARTITION OF mcrparted FOR VALUES FROM ('common', maxvalue..." +== 375 +-- truncate_limit: 100 +create table mcrparted8_ge_d partition of mcrparted for values from ('d', minvalue) to (maxvalue, maxvalue) +-- +TABLE: name="mcrparted8_ge_d" schema="" table="mcrparted8_ge_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcrparted8_ge_d PARTITION OF mcrparted FOR VALUES FROM ('d', minvalue) TO (maxvalue,..." +== 376 +-- truncate_limit: 100 +insert into mcrparted values ('aaa', 0), ('b', 0), ('bz', 10), ('c', -10), + ('comm', -10), ('common', -10), ('common', 0), ('common', 10), + ('commons', 0), ('d', -10), ('e', 0) +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcrparted VALUES (...)" +== 377 +-- truncate_limit: 100 +select tableoid::regclass, * from mcrparted order by a, b +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM mcrparted ORDER BY a, b" +== 378 +-- truncate_limit: 100 +drop table mcrparted +-- +TABLE: name="mcrparted" schema="" table="mcrparted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcrparted" +== 379 +-- truncate_limit: 100 +-- check that wholerow vars in the RETURNING list work with partitioned tables +create table returningwrtest (a int) partition by list (a) +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE returningwrtest (a int) PARTITION BY LIST (a)" +== 380 +-- truncate_limit: 100 +create table returningwrtest1 partition of returningwrtest for values in (1) +-- +TABLE: name="returningwrtest1" schema="" table="returningwrtest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE returningwrtest1 PARTITION OF returningwrtest FOR VALUES IN (1)" +== 381 +-- truncate_limit: 100 +insert into returningwrtest values (1) returning returningwrtest +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO returningwrtest VALUES (1) RETURNING returningwrtest" +== 382 +-- truncate_limit: 100 +-- check also that the wholerow vars in RETURNING list are converted as needed +alter table returningwrtest add b text +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE returningwrtest ADD COLUMN b text" +== 383 +-- truncate_limit: 100 +create table returningwrtest2 (b text, c int, a int) +-- +TABLE: name="returningwrtest2" schema="" table="returningwrtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE returningwrtest2 (b text, c int, a int)" +== 384 +-- truncate_limit: 100 +alter table returningwrtest2 drop c +-- +TABLE: name="returningwrtest2" schema="" table="returningwrtest2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE returningwrtest2 DROP c" +== 385 +-- truncate_limit: 100 +alter table returningwrtest attach partition returningwrtest2 for values in (2) +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE returningwrtest ATTACH PARTITION returningwrtest2 FOR VALUES IN (2)" +== 386 +-- truncate_limit: 100 +insert into returningwrtest values (2, 'foo') returning returningwrtest +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO returningwrtest VALUES (2, 'foo') RETURNING returningwrtest" +== 387 +-- truncate_limit: 100 +drop table returningwrtest +-- +TABLE: name="returningwrtest" schema="" table="returningwrtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE returningwrtest" diff --git a/parser/testdata/summary_truncate/postgres_regress/insert_conflict.metadata.json b/parser/testdata/summary_truncate/postgres_regress/insert_conflict.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/insert_conflict.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/insert_conflict.test b/parser/testdata/summary_truncate/postgres_regress/insert_conflict.test new file mode 100644 index 0000000..bb8930a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/insert_conflict.test @@ -0,0 +1,2205 @@ +== 001 +-- truncate_limit: 100 +|-- +-- insert...on conflict do unique index inference +|-- +create table insertconflicttest(key int4, fruit text) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE insertconflicttest (key int4, fruit text)" +== 002 +-- truncate_limit: 100 +-- These things should work through a view, as well +create view insertconflictview as select * from insertconflicttest +-- +TABLE: name="insertconflictview" schema="" table="insertconflictview" ctx=DDL +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW insertconflictview AS SELECT * FROM insertconflicttest" +== 003 +-- truncate_limit: 100 +|-- +-- Test unique index inference with operator class specifications and +-- named collations +|-- +create unique index op_index_key on insertconflicttest(key, fruit text_pattern_ops) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX op_index_key ON insertconflicttest USING btree (key, fruit text_pattern_ops)" +== 004 +-- truncate_limit: 100 +create unique index collation_index_key on insertconflicttest(key, fruit collate "C") +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX collation_index_key ON insertconflicttest USING btree (key, fruit COLLATE \"C\")" +== 005 +-- truncate_limit: 100 +create unique index both_index_key on insertconflicttest(key, fruit collate "C" text_pattern_ops) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX both_index_key ON insertconflicttest USING btree (key, fruit COLLATE \"C\" text..." +== 006 +-- truncate_limit: 100 +create unique index both_index_expr_key on insertconflicttest(key, lower(fruit) collate "C" text_pattern_ops) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX both_index_expr_key ON insertconflicttest USING btree (key, lower(fruit) COLL..." +== 007 +-- truncate_limit: 100 +-- fails +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (key) DO N..." +== 008 +-- truncate_limit: 100 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (fruit) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (fruit) DO..." +== 009 +-- truncate_limit: 100 +-- succeeds +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (key, frui..." +== 010 +-- truncate_limit: 100 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (fruit, key, fruit, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (fruit, ke..." +== 011 +-- truncate_limit: 100 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit), key, lower(fruit), key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (lower(fru..." +== 012 +-- truncate_limit: 100 +explain (costs off) insert into insertconflictview values(0, 'Crowberry') on conflict (lower(fruit), key, lower(fruit), key) do nothing +-- +TABLE: name="insertconflictview" schema="" table="insertconflictview" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflictview VALUES (0, 'Crowberry') ON CONFLICT (lower(fru..." +== 013 +-- truncate_limit: 100 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit) do update set fruit = excluded.fruit + where exists (select 1 from insertconflicttest ii where ii.key = excluded.key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=Select +ALIAS: "ii"="insertconflicttest" +FILTER: schema="" table="ii" column="key" +FILTER: schema="" table="excluded" column="key" +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (key, frui..." +== 014 +-- truncate_limit: 100 +-- Neither collation nor operator class specifications are required -- +-- supplying them merely *limits* matches to indexes with matching opclasses +-- used for relevant indexes +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit text_pattern_ops) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (key, frui..." +== 015 +-- truncate_limit: 100 +-- Okay, arbitrates using both index where text_pattern_ops opclass does and +-- does not appear. +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit collate "C") do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (key, frui..." +== 016 +-- truncate_limit: 100 +-- Okay, but only accepts the single index where both opclass and collation are +-- specified +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (fruit collate "C" text_pattern_ops, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (fruit COL..." +== 017 +-- truncate_limit: 100 +-- Okay, but only accepts the single index where both opclass and collation are +-- specified (plus expression variant) +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit) collate "C", key, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (lower(fru..." +== 018 +-- truncate_limit: 100 +-- Attribute appears twice, while not all attributes/expressions on attributes +-- appearing within index definition match in terms of both opclass and +-- collation. +|-- +-- Works because every attribute in inference specification needs to be +-- satisfied once or more by cataloged index attribute, and as always when an +-- attribute in the cataloged definition has a non-default opclass/collation, +-- it still satisfied some inference attribute lacking any particular +-- opclass/collation specification. +|-- +-- The implementation is liberal in accepting inference specifications on the +-- assumption that multiple inferred unique indexes will prevent problematic +-- cases. It rolls with unique indexes where attributes redundantly appear +-- multiple times, too (which is not tested here). +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (fruit, key, fruit text_pattern_ops, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (fruit, ke..." +== 019 +-- truncate_limit: 100 +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit) collate "C" text_pattern_ops, key, key) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (lower(fru..." +== 020 +-- truncate_limit: 100 +drop index op_index_key +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX op_index_key" +== 021 +-- truncate_limit: 100 +drop index collation_index_key +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX collation_index_key" +== 022 +-- truncate_limit: 100 +drop index both_index_key +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX both_index_key" +== 023 +-- truncate_limit: 100 +drop index both_index_expr_key +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX both_index_expr_key" +== 024 +-- truncate_limit: 100 +|-- +-- Make sure that cross matching of attribute opclass/collation does not occur +|-- +create unique index cross_match on insertconflicttest(lower(fruit) collate "C", upper(fruit) text_pattern_ops) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX cross_match ON insertconflicttest USING btree (lower(fruit) COLLATE \"C\", uppe..." +== 025 +-- truncate_limit: 100 +-- fails: +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit) text_pattern_ops, upper(fruit) collate "C") do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (lower(fru..." +== 026 +-- truncate_limit: 100 +-- works: +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (lower(fruit) collate "C", upper(fruit) text_pattern_ops) do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (lower(fru..." +== 027 +-- truncate_limit: 100 +drop index cross_match +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX cross_match" +== 028 +-- truncate_limit: 100 +|-- +-- Single key tests +|-- +create unique index key_index on insertconflicttest(key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX key_index ON insertconflicttest USING btree (key)" +== 029 +-- truncate_limit: 100 +|-- +-- Explain tests +|-- +explain (costs off) insert into insertconflicttest values (0, 'Bilberry') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Bilberry') ON CONFLICT (key) DO UP..." +== 030 +-- truncate_limit: 100 +-- Should display qual actually attributable to internal sequential scan: +explain (costs off) insert into insertconflicttest values (0, 'Bilberry') on conflict (key) do update set fruit = excluded.fruit where insertconflicttest.fruit != 'Cawesh' +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Bilberry') ON CONFLICT (key) DO UP..." +== 031 +-- truncate_limit: 100 +-- With EXCLUDED.* expression in scan node: +explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on conflict (key) do update set fruit = excluded.fruit where excluded.fruit != 'Elderberry' +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (0, 'Crowberry') ON CONFLICT (key) DO U..." +== 032 +-- truncate_limit: 100 +-- Does the same, but JSON format shows "Conflict Arbiter Index" as JSON array: +explain (costs off, format json) insert into insertconflicttest values (0, 'Bilberry') on conflict (key) do update set fruit = excluded.fruit where insertconflicttest.fruit != 'Lime' returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, FORMAT \"json\") INSERT INTO insertconflicttest VALUES (0, 'Bilberry') ON CONFL..." +== 033 +-- truncate_limit: 100 +-- Fails (no unique index inference specification, required for do update variant): +insert into insertconflicttest values (1, 'Apple') on conflict do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (1, 'Apple') ON CONFLICT DO UPDATE SET fruit = excluded.fruit" +== 034 +-- truncate_limit: 100 +-- inference succeeds: +insert into insertconflicttest values (1, 'Apple') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (1, 'Apple') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 035 +-- truncate_limit: 100 +insert into insertconflicttest values (2, 'Orange') on conflict (key, key, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key, key, key) DO UPDATE SET ... = ..." +== 036 +-- truncate_limit: 100 +-- Succeed, since multi-assignment does not involve subquery: +insert into insertconflicttest +values (1, 'Apple'), (2, 'Orange') +on conflict (key) do update set (fruit, key) = (excluded.fruit, excluded.key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ..." +== 037 +-- truncate_limit: 100 +-- Give good diagnostic message when EXCLUDED.* spuriously referenced from +-- RETURNING: +insert into insertconflicttest values (1, 'Apple') on conflict (key) do update set fruit = excluded.fruit RETURNING excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... RETURNING e..." +== 038 +-- truncate_limit: 100 +-- Only suggest
.* column when inference element misspelled: +insert into insertconflicttest values (1, 'Apple') on conflict (keyy) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (1, 'Apple') ON CONFLICT (keyy) DO UPDATE SET ... = ..." +== 039 +-- truncate_limit: 100 +-- Have useful HINT for EXCLUDED.* RTE within UPDATE: +insert into insertconflicttest values (1, 'Apple') on conflict (key) do update set fruit = excluded.fruitt +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (1, 'Apple') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 040 +-- truncate_limit: 100 +-- inference fails: +insert into insertconflicttest values (3, 'Kiwi') on conflict (key, fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (3, 'Kiwi') ON CONFLICT (key, fruit) DO UPDATE SET ... = ..." +== 041 +-- truncate_limit: 100 +insert into insertconflicttest values (4, 'Mango') on conflict (fruit, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (4, 'Mango') ON CONFLICT (fruit, key) DO UPDATE SET ... = ..." +== 042 +-- truncate_limit: 100 +insert into insertconflicttest values (5, 'Lemon') on conflict (fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (5, 'Lemon') ON CONFLICT (fruit) DO UPDATE SET ... = ..." +== 043 +-- truncate_limit: 100 +insert into insertconflicttest values (6, 'Passionfruit') on conflict (lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (lower(fruit)) DO UPDATE SET ... = ..." +== 044 +-- truncate_limit: 100 +-- Check the target relation can be aliased +insert into insertconflicttest AS ict values (6, 'Passionfruit') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "ict"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest AS ict VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ..." +== 045 +-- truncate_limit: 100 +-- ok, no reference to target table +insert into insertconflicttest AS ict values (6, 'Passionfruit') on conflict (key) do update set fruit = ict.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "ict"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest AS ict VALUES (...) ON CONFLICT (key) DO UPDATE SET fruit = ict.fruit" +== 046 +-- truncate_limit: 100 +-- ok, alias +insert into insertconflicttest AS ict values (6, 'Passionfruit') on conflict (key) do update set fruit = insertconflicttest.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "ict"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest AS ict VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ..." +== 047 +-- truncate_limit: 100 +-- error, references aliased away name + +-- Check helpful hint when qualifying set column with target table +insert into insertconflicttest values (3, 'Kiwi') on conflict (key, fruit) do update set insertconflicttest.fruit = 'Mango' +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (3, 'Kiwi') ON CONFLICT (key, fruit) DO UPDATE SET ... = ..." +== 048 +-- truncate_limit: 100 +drop index key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX key_index" +== 049 +-- truncate_limit: 100 +|-- +-- Composite key tests +|-- +create unique index comp_key_index on insertconflicttest(key, fruit) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX comp_key_index ON insertconflicttest USING btree (key, fruit)" +== 050 +-- truncate_limit: 100 +-- inference succeeds: +insert into insertconflicttest values (7, 'Raspberry') on conflict (key, fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key, fruit) DO UPDATE SET ... = ..." +== 051 +-- truncate_limit: 100 +insert into insertconflicttest values (8, 'Lime') on conflict (fruit, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (8, 'Lime') ON CONFLICT (fruit, key) DO UPDATE SET ... = ..." +== 052 +-- truncate_limit: 100 +-- inference fails: +insert into insertconflicttest values (9, 'Banana') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (9, 'Banana') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 053 +-- truncate_limit: 100 +insert into insertconflicttest values (10, 'Blueberry') on conflict (key, key, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key, key, key) DO UPDATE SET ... = ..." +== 054 +-- truncate_limit: 100 +insert into insertconflicttest values (11, 'Cherry') on conflict (key, lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key, lower(fruit)) DO UPDATE SET ... = ..." +== 055 +-- truncate_limit: 100 +insert into insertconflicttest values (12, 'Date') on conflict (lower(fruit), key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (lower(fruit), key) DO UPDATE SET ... = ..." +== 056 +-- truncate_limit: 100 +drop index comp_key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX comp_key_index" +== 057 +-- truncate_limit: 100 +|-- +-- Partial index tests, no inference predicate specified +|-- +create unique index part_comp_key_index on insertconflicttest(key, fruit) where key < 5 +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX part_comp_key_index ON insertconflicttest USING btree (key, fruit) WHERE key < 5" +== 058 +-- truncate_limit: 100 +create unique index expr_part_comp_key_index on insertconflicttest(key, lower(fruit)) where key < 5 +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX expr_part_comp_key_index ON insertconflicttest USING btree (key, lower(fruit)..." +== 059 +-- truncate_limit: 100 +-- inference fails: +insert into insertconflicttest values (13, 'Grape') on conflict (key, fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (13, 'Grape') ON CONFLICT (key, fruit) DO UPDATE SET ... = ..." +== 060 +-- truncate_limit: 100 +insert into insertconflicttest values (14, 'Raisin') on conflict (fruit, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (fruit, key) DO UPDATE SET ... = ..." +== 061 +-- truncate_limit: 100 +insert into insertconflicttest values (15, 'Cranberry') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (15, 'Cranberry') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 062 +-- truncate_limit: 100 +insert into insertconflicttest values (16, 'Melon') on conflict (key, key, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key, key, key) DO UPDATE SET ... = ..." +== 063 +-- truncate_limit: 100 +insert into insertconflicttest values (17, 'Mulberry') on conflict (key, lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key, lower(fruit)) DO UPDATE SET ... = ..." +== 064 +-- truncate_limit: 100 +insert into insertconflicttest values (18, 'Pineapple') on conflict (lower(fruit), key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (lower(fruit), key) DO UPDATE SET ... = ..." +== 065 +-- truncate_limit: 100 +drop index part_comp_key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX part_comp_key_index" +== 066 +-- truncate_limit: 100 +drop index expr_part_comp_key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX expr_part_comp_key_index" +== 067 +-- truncate_limit: 100 +|-- +-- Expression index tests +|-- +create unique index expr_key_index on insertconflicttest(lower(fruit)) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX expr_key_index ON insertconflicttest USING btree (lower(fruit))" +== 068 +-- truncate_limit: 100 +-- inference succeeds: +insert into insertconflicttest values (20, 'Quince') on conflict (lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (lower(fruit)) DO UPDATE SET ... = ..." +== 069 +-- truncate_limit: 100 +insert into insertconflicttest values (21, 'Pomegranate') on conflict (lower(fruit), lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (lower(fruit), lower(fruit)) DO UPDATE SE..." +== 070 +-- truncate_limit: 100 +-- inference fails: +insert into insertconflicttest values (22, 'Apricot') on conflict (upper(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (upper(fruit)) DO UPDATE SET ... = ..." +== 071 +-- truncate_limit: 100 +insert into insertconflicttest values (23, 'Blackberry') on conflict (fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (23, 'Blackberry') ON CONFLICT (fruit) DO UPDATE SET ... = ..." +== 072 +-- truncate_limit: 100 +drop index expr_key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX expr_key_index" +== 073 +-- truncate_limit: 100 +|-- +-- Expression index tests (with regular column) +|-- +create unique index expr_comp_key_index on insertconflicttest(key, lower(fruit)) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX expr_comp_key_index ON insertconflicttest USING btree (key, lower(fruit))" +== 074 +-- truncate_limit: 100 +create unique index tricky_expr_comp_key_index on insertconflicttest(key, lower(fruit), upper(fruit)) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX tricky_expr_comp_key_index ON insertconflicttest USING btree (key, lower(frui..." +== 075 +-- truncate_limit: 100 +-- inference succeeds: +insert into insertconflicttest values (24, 'Plum') on conflict (key, lower(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key, lower(fruit)) DO UPDATE SET ... = ..." +== 076 +-- truncate_limit: 100 +insert into insertconflicttest values (25, 'Peach') on conflict (lower(fruit), key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (lower(fruit), key) DO UPDATE SET ... = ..." +== 077 +-- truncate_limit: 100 +-- Should not infer "tricky_expr_comp_key_index" index: +explain (costs off) insert into insertconflicttest values (26, 'Fig') on conflict (lower(fruit), key, lower(fruit), key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest VALUES (26, 'Fig') ON CONFLICT (lower(fruit), ..." +== 078 +-- truncate_limit: 100 +-- inference fails: +insert into insertconflicttest values (27, 'Prune') on conflict (key, upper(fruit)) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key, upper(fruit)) DO UPDATE SET ... = ..." +== 079 +-- truncate_limit: 100 +insert into insertconflicttest values (28, 'Redcurrant') on conflict (fruit, key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (fruit, key) DO UPDATE SET ... = ..." +== 080 +-- truncate_limit: 100 +insert into insertconflicttest values (29, 'Nectarine') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (29, 'Nectarine') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 081 +-- truncate_limit: 100 +drop index expr_comp_key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX expr_comp_key_index" +== 082 +-- truncate_limit: 100 +drop index tricky_expr_comp_key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX tricky_expr_comp_key_index" +== 083 +-- truncate_limit: 100 +|-- +-- Non-spurious duplicate violation tests +|-- +create unique index key_index on insertconflicttest(key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX key_index ON insertconflicttest USING btree (key)" +== 084 +-- truncate_limit: 100 +create unique index fruit_index on insertconflicttest(fruit) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX fruit_index ON insertconflicttest USING btree (fruit)" +== 085 +-- truncate_limit: 100 +-- succeeds, since UPDATE happens to update "fruit" to existing value: +insert into insertconflicttest values (26, 'Fig') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (26, 'Fig') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 086 +-- truncate_limit: 100 +-- fails, since UPDATE is to row with key value 26, and we're updating "fruit" +-- to a value that happens to exist in another row ('peach'): +insert into insertconflicttest values (26, 'Peach') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (26, 'Peach') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 087 +-- truncate_limit: 100 +-- succeeds, since "key" isn't repeated/referenced in UPDATE, and "fruit" +-- arbitrates that statement updates existing "Fig" row: +insert into insertconflicttest values (25, 'Fig') on conflict (fruit) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (25, 'Fig') ON CONFLICT (fruit) DO UPDATE SET ... = ..." +== 088 +-- truncate_limit: 100 +drop index key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX key_index" +== 089 +-- truncate_limit: 100 +drop index fruit_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX fruit_index" +== 090 +-- truncate_limit: 100 +|-- +-- Test partial unique index inference +|-- +create unique index partial_key_index on insertconflicttest(key) where fruit like '%berry' +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX partial_key_index ON insertconflicttest USING btree (key) WHERE ..." +== 091 +-- truncate_limit: 100 +-- Succeeds +insert into insertconflicttest values (23, 'Blackberry') on conflict (key) where fruit like '%berry' do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (key) WHERE ... DO UPDATE SET ... = ..." +== 092 +-- truncate_limit: 100 +insert into insertconflicttest as t values (23, 'Blackberry') on conflict (key) where fruit like '%berry' and t.fruit = 'inconsequential' do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "t"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest AS t VALUES (23, 'Blackberry') ON CONFLICT (key) WHERE ... DO NOTHING" +== 093 +-- truncate_limit: 100 +insert into insertconflictview as t values (23, 'Blackberry') on conflict (key) where fruit like '%berry' and t.fruit = 'inconsequential' do nothing +-- +TABLE: name="insertconflictview" schema="" table="insertconflictview" ctx=DML +ALIAS: "t"="insertconflictview" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflictview AS t VALUES (23, 'Blackberry') ON CONFLICT (key) WHERE ... DO NOTHING" +== 094 +-- truncate_limit: 100 +-- fails +insert into insertconflicttest values (23, 'Blackberry') on conflict (key) do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (23, 'Blackberry') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 095 +-- truncate_limit: 100 +insert into insertconflicttest values (23, 'Blackberry') on conflict (key) where fruit like '%berry' or fruit = 'consequential' do nothing +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (23, 'Blackberry') ON CONFLICT (key) WHERE ... DO NOTHING" +== 096 +-- truncate_limit: 100 +insert into insertconflicttest values (23, 'Blackberry') on conflict (fruit) where fruit like '%berry' do update set fruit = excluded.fruit +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest VALUES (...) ON CONFLICT (fruit) WHERE ... DO UPDATE SET ... = ..." +== 097 +-- truncate_limit: 100 +drop index partial_key_index +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX partial_key_index" +== 098 +-- truncate_limit: 100 +|-- +-- Test that wholerow references to ON CONFLICT's EXCLUDED work +|-- +create unique index plain on insertconflicttest(key) +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX plain ON insertconflicttest USING btree (key)" +== 099 +-- truncate_limit: 100 +-- Succeeds, updates existing row: +insert into insertconflicttest as i values (23, 'Jackfruit') on conflict (key) do update set fruit = excluded.fruit + where i.* != excluded.* returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest AS i VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... WHERE ..." +== 100 +-- truncate_limit: 100 +-- No update this time, though: +insert into insertconflicttest as i values (23, 'Jackfruit') on conflict (key) do update set fruit = excluded.fruit + where i.* != excluded.* returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest AS i VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... WHERE ..." +== 101 +-- truncate_limit: 100 +-- Predicate changed to require match rather than non-match, so updates once more: +insert into insertconflicttest as i values (23, 'Jackfruit') on conflict (key) do update set fruit = excluded.fruit + where i.* = excluded.* returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest AS i VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... WHERE ..." +== 102 +-- truncate_limit: 100 +-- Assign: +insert into insertconflicttest as i values (23, 'Avocado') on conflict (key) do update set fruit = excluded.*::text + returning * +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflicttest AS i VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... RETURN..." +== 103 +-- truncate_limit: 100 +-- deparse whole row var in WHERE and SET clauses: +explain (costs off) insert into insertconflicttest as i values (23, 'Avocado') on conflict (key) do update set fruit = excluded.fruit where excluded.* is null +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest AS i VALUES (23, 'Avocado') ON CONFLICT (key) ..." +== 104 +-- truncate_limit: 100 +explain (costs off) insert into insertconflicttest as i values (23, 'Avocado') on conflict (key) do update set fruit = excluded.*::text +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DML +ALIAS: "i"="insertconflicttest" +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO insertconflicttest AS i VALUES (23, 'Avocado') ON CONFLICT (key) ..." +== 105 +-- truncate_limit: 100 +drop index plain +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX plain" +== 106 +-- truncate_limit: 100 +-- Cleanup +drop view insertconflictview +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW insertconflictview" +== 107 +-- truncate_limit: 100 +drop table insertconflicttest +-- +TABLE: name="insertconflicttest" schema="" table="insertconflicttest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE insertconflicttest" +== 108 +-- truncate_limit: 100 +|-- +-- Verify that EXCLUDED does not allow system column references. These +-- do not make sense because EXCLUDED isn't an already stored tuple +-- (and thus doesn't have a ctid etc). +|-- +create table syscolconflicttest(key int4, data text) +-- +TABLE: name="syscolconflicttest" schema="" table="syscolconflicttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE syscolconflicttest (key int4, data text)" +== 109 +-- truncate_limit: 100 +insert into syscolconflicttest values (1) +-- +TABLE: name="syscolconflicttest" schema="" table="syscolconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO syscolconflicttest VALUES (1)" +== 110 +-- truncate_limit: 100 +insert into syscolconflicttest values (1) on conflict (key) do update set data = excluded.ctid::text +-- +TABLE: name="syscolconflicttest" schema="" table="syscolconflicttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO syscolconflicttest VALUES (1) ON CONFLICT (key) DO UPDATE SET data = excluded.ctid::text" +== 111 +-- truncate_limit: 100 +drop table syscolconflicttest +-- +TABLE: name="syscolconflicttest" schema="" table="syscolconflicttest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE syscolconflicttest" +== 112 +-- truncate_limit: 100 +|-- +-- Previous tests all managed to not test any expressions requiring +-- planner preprocessing ... +|-- +create table insertconflict (a bigint, b bigint) +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE insertconflict (a bigint, b bigint)" +== 113 +-- truncate_limit: 100 +create unique index insertconflicti1 on insertconflict(coalesce(a, 0)) +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX insertconflicti1 ON insertconflict USING btree (COALESCE(a, 0))" +== 114 +-- truncate_limit: 100 +create unique index insertconflicti2 on insertconflict(b) + where coalesce(a, 1) > 0 +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX insertconflicti2 ON insertconflict USING btree (b) WHERE COALESCE(a, 1) > 0" +== 115 +-- truncate_limit: 100 +insert into insertconflict values (1, 2) +on conflict (coalesce(a, 0)) do nothing +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflict VALUES (1, 2) ON CONFLICT (COALESCE(a, 0)) DO NOTHING" +== 116 +-- truncate_limit: 100 +insert into insertconflict values (1, 2) +on conflict (b) where coalesce(a, 1) > 0 do nothing +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflict VALUES (1, 2) ON CONFLICT (b) WHERE COALESCE(a, 1) > 0 DO NOTHING" +== 117 +-- truncate_limit: 100 +insert into insertconflict values (1, 2) +on conflict (b) where coalesce(a, 1) > 1 do nothing +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflict VALUES (1, 2) ON CONFLICT (b) WHERE COALESCE(a, 1) > 1 DO NOTHING" +== 118 +-- truncate_limit: 100 +drop table insertconflict +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE insertconflict" +== 119 +-- truncate_limit: 100 +|-- +-- test insertion through view +|-- + +create table insertconflict (f1 int primary key, f2 text) +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE insertconflict (f1 int PRIMARY KEY, f2 text)" +== 120 +-- truncate_limit: 100 +create view insertconflictv as + select * from insertconflict with cascaded check option +-- +TABLE: name="insertconflictv" schema="" table="insertconflictv" ctx=DDL +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW insertconflictv AS SELECT * FROM insertconflict WITH CHECK OPTION" +== 121 +-- truncate_limit: 100 +insert into insertconflictv values (1,'foo') + on conflict (f1) do update set f2 = excluded.f2 +-- +TABLE: name="insertconflictv" schema="" table="insertconflictv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflictv VALUES (1, 'foo') ON CONFLICT (f1) DO UPDATE SET f2 = excluded.f2" +== 122 +-- truncate_limit: 100 +select * from insertconflict +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insertconflict" +== 123 +-- truncate_limit: 100 +insert into insertconflictv values (1,'bar') + on conflict (f1) do update set f2 = excluded.f2 +-- +TABLE: name="insertconflictv" schema="" table="insertconflictv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO insertconflictv VALUES (1, 'bar') ON CONFLICT (f1) DO UPDATE SET f2 = excluded.f2" +== 124 +-- truncate_limit: 100 +select * from insertconflict +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insertconflict" +== 125 +-- truncate_limit: 100 +drop view insertconflictv +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW insertconflictv" +== 126 +-- truncate_limit: 100 +drop table insertconflict +-- +TABLE: name="insertconflict" schema="" table="insertconflict" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE insertconflict" +== 127 +-- truncate_limit: 100 +-- ****************************************************************** +-- * * +-- * Test inheritance (example taken from tutorial) * +-- * * +-- ****************************************************************** +create table cities ( + name text, + population float8, + altitude int -- (in ft) +) +-- +TABLE: name="cities" schema="" table="cities" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cities (name text, population float8, altitude int)" +== 128 +-- truncate_limit: 100 +create table capitals ( + state char(2) +) inherits (cities) +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE capitals (state char(2)) INHERITS (cities)" +== 129 +-- truncate_limit: 100 +-- Create unique indexes. Due to a general limitation of inheritance, +-- uniqueness is only enforced per-relation. Unique index inference +-- specification will do the right thing, though. +create unique index cities_names_unique on cities (name) +-- +TABLE: name="cities" schema="" table="cities" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX cities_names_unique ON cities USING btree (name)" +== 130 +-- truncate_limit: 100 +create unique index capitals_names_unique on capitals (name) +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX capitals_names_unique ON capitals USING btree (name)" +== 131 +-- truncate_limit: 100 +-- prepopulate the tables. +insert into cities values ('San Francisco', 7.24E+5, 63) +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cities VALUES ('San Francisco', 7.24E+5, 63)" +== 132 +-- truncate_limit: 100 +insert into cities values ('Las Vegas', 2.583E+5, 2174) +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cities VALUES ('Las Vegas', 2.583E+5, 2174)" +== 133 +-- truncate_limit: 100 +insert into cities values ('Mariposa', 1200, 1953) +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cities VALUES ('Mariposa', 1200, 1953)" +== 134 +-- truncate_limit: 100 +insert into capitals values ('Sacramento', 3.694E+5, 30, 'CA') +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO capitals VALUES ('Sacramento', 3.694E+5, 30, 'CA')" +== 135 +-- truncate_limit: 100 +insert into capitals values ('Madison', 1.913E+5, 845, 'WI') +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO capitals VALUES ('Madison', 1.913E+5, 845, 'WI')" +== 136 +-- truncate_limit: 100 +-- Tests proper for inheritance: +select * from capitals +-- +TABLE: name="capitals" schema="" table="capitals" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM capitals" +== 137 +-- truncate_limit: 100 +-- Succeeds: +insert into cities values ('Las Vegas', 2.583E+5, 2174) on conflict do nothing +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cities VALUES ('Las Vegas', 2.583E+5, 2174) ON CONFLICT DO NOTHING" +== 138 +-- truncate_limit: 100 +insert into capitals values ('Sacramento', 4664.E+5, 30, 'CA') on conflict (name) do update set population = excluded.population +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO capitals VALUES (...) ON CONFLICT (name) DO UPDATE SET population = excluded.population" +== 139 +-- truncate_limit: 100 +-- Wrong "Sacramento", so do nothing: +insert into capitals values ('Sacramento', 50, 2267, 'NE') on conflict (name) do nothing +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO capitals VALUES ('Sacramento', 50, 2267, 'NE') ON CONFLICT (name) DO NOTHING" +== 140 +-- truncate_limit: 100 +select * from capitals +-- +TABLE: name="capitals" schema="" table="capitals" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM capitals" +== 141 +-- truncate_limit: 100 +insert into cities values ('Las Vegas', 5.83E+5, 2001) on conflict (name) do update set population = excluded.population, altitude = excluded.altitude +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cities VALUES ('Las Vegas', 5.83E+5, 2001) ON CONFLICT (name) DO UPDATE SET ... = ..." +== 142 +-- truncate_limit: 100 +select tableoid::regclass, * from cities +-- +TABLE: name="cities" schema="" table="cities" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM cities" +== 143 +-- truncate_limit: 100 +insert into capitals values ('Las Vegas', 5.83E+5, 2222, 'NV') on conflict (name) do update set population = excluded.population +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO capitals VALUES (...) ON CONFLICT (name) DO UPDATE SET population = excluded.population" +== 144 +-- truncate_limit: 100 +-- Capitals will contain new capital, Las Vegas: +select * from capitals +-- +TABLE: name="capitals" schema="" table="capitals" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM capitals" +== 145 +-- truncate_limit: 100 +-- Cities contains two instances of "Las Vegas", since unique constraints don't +-- work across inheritance: +select tableoid::regclass, * from cities +-- +TABLE: name="cities" schema="" table="cities" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM cities" +== 146 +-- truncate_limit: 100 +-- This only affects "cities" version of "Las Vegas": +insert into cities values ('Las Vegas', 5.86E+5, 2223) on conflict (name) do update set population = excluded.population, altitude = excluded.altitude +-- +TABLE: name="cities" schema="" table="cities" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cities VALUES ('Las Vegas', 5.86E+5, 2223) ON CONFLICT (name) DO UPDATE SET ... = ..." +== 147 +-- truncate_limit: 100 +select tableoid::regclass, * from cities +-- +TABLE: name="cities" schema="" table="cities" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM cities" +== 148 +-- truncate_limit: 100 +-- clean up +drop table capitals +-- +TABLE: name="capitals" schema="" table="capitals" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE capitals" +== 149 +-- truncate_limit: 100 +drop table cities +-- +TABLE: name="cities" schema="" table="cities" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cities" +== 150 +-- truncate_limit: 100 +-- Make sure a table named excluded is handled properly +create table excluded(key int primary key, data text) +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE excluded (key int PRIMARY KEY, data text)" +== 151 +-- truncate_limit: 100 +insert into excluded values(1, '1') +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO excluded VALUES (1, '1')" +== 152 +-- truncate_limit: 100 +-- error, ambiguous +insert into excluded values(1, '2') on conflict (key) do update set data = excluded.data RETURNING * +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO excluded VALUES (1, '2') ON CONFLICT (key) DO UPDATE SET ... = ... RETURNING *" +== 153 +-- truncate_limit: 100 +-- ok, aliased +insert into excluded AS target values(1, '2') on conflict (key) do update set data = excluded.data RETURNING * +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +ALIAS: "target"="excluded" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO excluded AS target VALUES (1, '2') ON CONFLICT (key) DO UPDATE SET ... = ... RETURNING *" +== 154 +-- truncate_limit: 100 +-- ok, aliased +insert into excluded AS target values(1, '2') on conflict (key) do update set data = target.data RETURNING * +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +ALIAS: "target"="excluded" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO excluded AS target VALUES (1, '2') ON CONFLICT (key) DO UPDATE SET ... = ... RETURNING *" +== 155 +-- truncate_limit: 100 +-- make sure excluded isn't a problem in returning clause +insert into excluded values(1, '2') on conflict (key) do update set data = 3 RETURNING excluded.* +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO excluded VALUES (1, '2') ON CONFLICT (key) DO UPDATE SET data = 3 RETURNING excluded.*" +== 156 +-- truncate_limit: 100 +-- clean up +drop table excluded +-- +TABLE: name="excluded" schema="" table="excluded" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE excluded" +== 157 +-- truncate_limit: 100 +-- check that references to columns after dropped columns are handled correctly +create table dropcol(key int primary key, drop1 int, keep1 text, drop2 numeric, keep2 float) +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dropcol (key int PRIMARY KEY, drop1 int, keep1 text, drop2 numeric, keep2 double pre..." +== 158 +-- truncate_limit: 100 +insert into dropcol(key, drop1, keep1, drop2, keep2) values(1, 1, '1', '1', 1) +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dropcol (key, drop1, keep1, drop2, keep2) VALUES (1, 1, '1', '1', 1)" +== 159 +-- truncate_limit: 100 +-- set using excluded +insert into dropcol(key, drop1, keep1, drop2, keep2) values(1, 2, '2', '2', 2) on conflict(key) + do update set drop1 = excluded.drop1, keep1 = excluded.keep1, drop2 = excluded.drop2, keep2 = excluded.keep2 + where excluded.drop1 is not null and excluded.keep1 is not null and excluded.drop2 is not null and excluded.keep2 is not null + and dropcol.drop1 is not null and dropcol.keep1 is not null and dropcol.drop2 is not null and dropcol.keep2 is not null + returning * +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dropcol (...) VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... WHERE ... RETURN..." +== 160 +-- truncate_limit: 100 +-- set using existing table +insert into dropcol(key, drop1, keep1, drop2, keep2) values(1, 3, '3', '3', 3) on conflict(key) + do update set drop1 = dropcol.drop1, keep1 = dropcol.keep1, drop2 = dropcol.drop2, keep2 = dropcol.keep2 + returning * +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dropcol (...) VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... RETURNING *" +== 161 +-- truncate_limit: 100 +alter table dropcol drop column drop1, drop column drop2 +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE dropcol DROP drop1, DROP drop2" +== 162 +-- truncate_limit: 100 +-- set using excluded +insert into dropcol(key, keep1, keep2) values(1, '4', 4) on conflict(key) + do update set keep1 = excluded.keep1, keep2 = excluded.keep2 + where excluded.keep1 is not null and excluded.keep2 is not null + and dropcol.keep1 is not null and dropcol.keep2 is not null + returning * +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dropcol (...) VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... WHERE ... RETURN..." +== 163 +-- truncate_limit: 100 +-- set using existing table +insert into dropcol(key, keep1, keep2) values(1, '5', 5) on conflict(key) + do update set keep1 = dropcol.keep1, keep2 = dropcol.keep2 + returning * +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO dropcol (...) VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... RETURNING *" +== 164 +-- truncate_limit: 100 +DROP TABLE dropcol +-- +TABLE: name="dropcol" schema="" table="dropcol" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE dropcol" +== 165 +-- truncate_limit: 100 +-- check handling of regular btree constraint along with gist constraint + +create table twoconstraints (f1 int unique, f2 box, + exclude using gist(f2 with &&)) +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE twoconstraints (f1 int UNIQUE, f2 box, EXCLUDE USING gist (f2 WITH &&))" +== 166 +-- truncate_limit: 100 +insert into twoconstraints values(1, '((0,0),(1,1))') +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO twoconstraints VALUES (1, '((0,0),(1,1))')" +== 167 +-- truncate_limit: 100 +insert into twoconstraints values(1, '((2,2),(3,3))') +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO twoconstraints VALUES (1, '((2,2),(3,3))')" +== 168 +-- truncate_limit: 100 +-- fail on f1 +insert into twoconstraints values(2, '((0,0),(1,2))') +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO twoconstraints VALUES (2, '((0,0),(1,2))')" +== 169 +-- truncate_limit: 100 +-- fail on f2 +insert into twoconstraints values(2, '((0,0),(1,2))') + on conflict on constraint twoconstraints_f1_key do nothing +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO twoconstraints VALUES (...) ON CONFLICT ON CONSTRAINT twoconstraints_f1_key DO NOTHING" +== 170 +-- truncate_limit: 100 +-- fail on f2 +insert into twoconstraints values(2, '((0,0),(1,2))') + on conflict on constraint twoconstraints_f2_excl do nothing +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO twoconstraints VALUES (...) ON CONFLICT ON CONSTRAINT twoconstraints_f2_excl DO NOTHING" +== 171 +-- truncate_limit: 100 +-- do nothing +select * from twoconstraints +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM twoconstraints" +== 172 +-- truncate_limit: 100 +drop table twoconstraints +-- +TABLE: name="twoconstraints" schema="" table="twoconstraints" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE twoconstraints" +== 173 +-- truncate_limit: 100 +-- check handling of self-conflicts at various isolation levels + +create table selfconflict (f1 int primary key, f2 int) +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE selfconflict (f1 int PRIMARY KEY, f2 int)" +== 174 +-- truncate_limit: 100 +begin transaction isolation level read committed +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL READ COMMITTED" +== 175 +-- truncate_limit: 100 +insert into selfconflict values (1,1), (1,2) on conflict do nothing +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO selfconflict VALUES (1, 1), (1, 2) ON CONFLICT DO NOTHING" +== 176 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 177 +-- truncate_limit: 100 +begin transaction isolation level repeatable read +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL REPEATABLE READ" +== 178 +-- truncate_limit: 100 +insert into selfconflict values (2,1), (2,2) on conflict do nothing +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO selfconflict VALUES (2, 1), (2, 2) ON CONFLICT DO NOTHING" +== 179 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 180 +-- truncate_limit: 100 +begin transaction isolation level serializable +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 181 +-- truncate_limit: 100 +insert into selfconflict values (3,1), (3,2) on conflict do nothing +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO selfconflict VALUES (3, 1), (3, 2) ON CONFLICT DO NOTHING" +== 182 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 183 +-- truncate_limit: 100 +begin transaction isolation level read committed +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL READ COMMITTED" +== 184 +-- truncate_limit: 100 +insert into selfconflict values (4,1), (4,2) on conflict(f1) do update set f2 = 0 +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO selfconflict VALUES (4, 1), (4, 2) ON CONFLICT (f1) DO UPDATE SET f2 = 0" +== 185 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 186 +-- truncate_limit: 100 +begin transaction isolation level repeatable read +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL REPEATABLE READ" +== 187 +-- truncate_limit: 100 +insert into selfconflict values (5,1), (5,2) on conflict(f1) do update set f2 = 0 +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO selfconflict VALUES (5, 1), (5, 2) ON CONFLICT (f1) DO UPDATE SET f2 = 0" +== 188 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 189 +-- truncate_limit: 100 +begin transaction isolation level serializable +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 190 +-- truncate_limit: 100 +insert into selfconflict values (6,1), (6,2) on conflict(f1) do update set f2 = 0 +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO selfconflict VALUES (6, 1), (6, 2) ON CONFLICT (f1) DO UPDATE SET f2 = 0" +== 191 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 192 +-- truncate_limit: 100 +select * from selfconflict +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM selfconflict" +== 193 +-- truncate_limit: 100 +drop table selfconflict +-- +TABLE: name="selfconflict" schema="" table="selfconflict" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE selfconflict" +== 194 +-- truncate_limit: 100 +-- check ON CONFLICT handling with partitioned tables +create table parted_conflict_test (a int unique, b char) partition by list (a) +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_test (a int UNIQUE, b char(1)) PARTITION BY LIST (a)" +== 195 +-- truncate_limit: 100 +create table parted_conflict_test_1 partition of parted_conflict_test (b unique) for values in (1, 2) +-- +TABLE: name="parted_conflict_test_1" schema="" table="parted_conflict_test_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_test_1 PARTITION OF parted_conflict_test (b UNIQUE) FOR VALUES IN (1..." +== 196 +-- truncate_limit: 100 +-- no indexes required here +insert into parted_conflict_test values (1, 'a') on conflict do nothing +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test VALUES (1, 'a') ON CONFLICT DO NOTHING" +== 197 +-- truncate_limit: 100 +-- index on a required, which does exist in parent +insert into parted_conflict_test values (1, 'a') on conflict (a) do nothing +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test VALUES (1, 'a') ON CONFLICT (a) DO NOTHING" +== 198 +-- truncate_limit: 100 +insert into parted_conflict_test values (1, 'a') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test VALUES (1, 'a') ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 199 +-- truncate_limit: 100 +-- targeting partition directly will work +insert into parted_conflict_test_1 values (1, 'a') on conflict (a) do nothing +-- +TABLE: name="parted_conflict_test_1" schema="" table="parted_conflict_test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test_1 VALUES (1, 'a') ON CONFLICT (a) DO NOTHING" +== 200 +-- truncate_limit: 100 +insert into parted_conflict_test_1 values (1, 'b') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test_1" schema="" table="parted_conflict_test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test_1 VALUES (1, 'b') ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 201 +-- truncate_limit: 100 +-- index on b required, which doesn't exist in parent +insert into parted_conflict_test values (2, 'b') on conflict (b) do update set a = excluded.a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test VALUES (2, 'b') ON CONFLICT (b) DO UPDATE SET a = excluded.a" +== 202 +-- truncate_limit: 100 +-- targeting partition directly will work +insert into parted_conflict_test_1 values (2, 'b') on conflict (b) do update set a = excluded.a +-- +TABLE: name="parted_conflict_test_1" schema="" table="parted_conflict_test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test_1 VALUES (2, 'b') ON CONFLICT (b) DO UPDATE SET a = excluded.a" +== 203 +-- truncate_limit: 100 +-- should see (2, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted_conflict_test ORDER BY a" +== 204 +-- truncate_limit: 100 +-- now check that DO UPDATE works correctly for target partition with +-- different attribute numbers +create table parted_conflict_test_2 (b char, a int unique) +-- +TABLE: name="parted_conflict_test_2" schema="" table="parted_conflict_test_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_test_2 (b char(1), a int UNIQUE)" +== 205 +-- truncate_limit: 100 +alter table parted_conflict_test attach partition parted_conflict_test_2 for values in (3) +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_conflict_test ATTACH PARTITION parted_conflict_test_2 FOR VALUES IN (3)" +== 206 +-- truncate_limit: 100 +truncate parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_conflict_test" +== 207 +-- truncate_limit: 100 +insert into parted_conflict_test values (3, 'a') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test VALUES (3, 'a') ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 208 +-- truncate_limit: 100 +insert into parted_conflict_test values (3, 'b') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test VALUES (3, 'b') ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 209 +-- truncate_limit: 100 +-- should see (3, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted_conflict_test ORDER BY a" +== 210 +-- truncate_limit: 100 +-- case where parent will have a dropped column, but the partition won't +alter table parted_conflict_test drop b, add b char +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_conflict_test DROP b, ADD COLUMN b char(1)" +== 211 +-- truncate_limit: 100 +create table parted_conflict_test_3 partition of parted_conflict_test for values in (4) +-- +TABLE: name="parted_conflict_test_3" schema="" table="parted_conflict_test_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_test_3 PARTITION OF parted_conflict_test FOR VALUES IN (4)" +== 212 +-- truncate_limit: 100 +truncate parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_conflict_test" +== 213 +-- truncate_limit: 100 +insert into parted_conflict_test (a, b) values (4, 'a') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test (a, b) VALUES (4, 'a') ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 214 +-- truncate_limit: 100 +insert into parted_conflict_test (a, b) values (4, 'b') on conflict (a) do update set b = excluded.b where parted_conflict_test.b = 'a' +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test (...) VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... WHERE..." +== 215 +-- truncate_limit: 100 +-- should see (4, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted_conflict_test ORDER BY a" +== 216 +-- truncate_limit: 100 +-- case with multi-level partitioning +create table parted_conflict_test_4 partition of parted_conflict_test for values in (5) partition by list (a) +-- +TABLE: name="parted_conflict_test_4" schema="" table="parted_conflict_test_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_test_4 PARTITION OF parted_conflict_test FOR VALUES IN (5) PARTITION..." +== 217 +-- truncate_limit: 100 +create table parted_conflict_test_4_1 partition of parted_conflict_test_4 for values in (5) +-- +TABLE: name="parted_conflict_test_4_1" schema="" table="parted_conflict_test_4_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_test_4_1 PARTITION OF parted_conflict_test_4 FOR VALUES IN (5)" +== 218 +-- truncate_limit: 100 +truncate parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_conflict_test" +== 219 +-- truncate_limit: 100 +insert into parted_conflict_test (a, b) values (5, 'a') on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test (a, b) VALUES (5, 'a') ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 220 +-- truncate_limit: 100 +insert into parted_conflict_test (a, b) values (5, 'b') on conflict (a) do update set b = excluded.b where parted_conflict_test.b = 'a' +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test (...) VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... WHERE..." +== 221 +-- truncate_limit: 100 +-- should see (5, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted_conflict_test ORDER BY a" +== 222 +-- truncate_limit: 100 +-- test with multiple rows +truncate parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_conflict_test" +== 223 +-- truncate_limit: 100 +insert into parted_conflict_test (a, b) values (1, 'a'), (2, 'a'), (4, 'a') on conflict (a) do update set b = excluded.b where excluded.b = 'b' +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test (...) VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... WHERE..." +== 224 +-- truncate_limit: 100 +insert into parted_conflict_test (a, b) values (1, 'b'), (2, 'c'), (4, 'b') on conflict (a) do update set b = excluded.b where excluded.b = 'b' +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_test (...) VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... WHERE..." +== 225 +-- truncate_limit: 100 +-- should see (1, 'b'), (2, 'a'), (4, 'b') +select * from parted_conflict_test order by a +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted_conflict_test ORDER BY a" +== 226 +-- truncate_limit: 100 +drop table parted_conflict_test +-- +TABLE: name="parted_conflict_test" schema="" table="parted_conflict_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_conflict_test" +== 227 +-- truncate_limit: 100 +-- test behavior of inserting a conflicting tuple into an intermediate +-- partitioning level +create table parted_conflict (a int primary key, b text) partition by range (a) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict (a int PRIMARY KEY, b text) PARTITION BY RANGE (a)" +== 228 +-- truncate_limit: 100 +create table parted_conflict_1 partition of parted_conflict for values from (0) to (1000) partition by range (a) +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_1 PARTITION OF parted_conflict FOR VALUES FROM (0) TO (1000) PARTITI..." +== 229 +-- truncate_limit: 100 +create table parted_conflict_1_1 partition of parted_conflict_1 for values from (0) to (500) +-- +TABLE: name="parted_conflict_1_1" schema="" table="parted_conflict_1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_1_1 PARTITION OF parted_conflict_1 FOR VALUES FROM (0) TO (500)" +== 230 +-- truncate_limit: 100 +insert into parted_conflict values (40, 'forty') +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict VALUES (40, 'forty')" +== 231 +-- truncate_limit: 100 +insert into parted_conflict_1 values (40, 'cuarenta') + on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_1 VALUES (40, 'cuarenta') ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 232 +-- truncate_limit: 100 +drop table parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_conflict" +== 233 +-- truncate_limit: 100 +-- same thing, but this time try to use an index that's created not in the +-- partition +create table parted_conflict (a int, b text) partition by range (a) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict (a int, b text) PARTITION BY RANGE (a)" +== 234 +-- truncate_limit: 100 +create table parted_conflict_1 partition of parted_conflict for values from (0) to (1000) partition by range (a) +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_1 PARTITION OF parted_conflict FOR VALUES FROM (0) TO (1000) PARTITI..." +== 235 +-- truncate_limit: 100 +create table parted_conflict_1_1 partition of parted_conflict_1 for values from (0) to (500) +-- +TABLE: name="parted_conflict_1_1" schema="" table="parted_conflict_1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_1_1 PARTITION OF parted_conflict_1 FOR VALUES FROM (0) TO (500)" +== 236 +-- truncate_limit: 100 +create unique index on only parted_conflict_1 (a) +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON ONLY parted_conflict_1 USING btree (a)" +== 237 +-- truncate_limit: 100 +create unique index on only parted_conflict (a) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON ONLY parted_conflict USING btree (a)" +== 238 +-- truncate_limit: 100 +alter index parted_conflict_a_idx attach partition parted_conflict_1_a_idx +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX parted_conflict_a_idx ATTACH PARTITION parted_conflict_1_a_idx" +== 239 +-- truncate_limit: 100 +insert into parted_conflict values (40, 'forty') +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict VALUES (40, 'forty')" +== 240 +-- truncate_limit: 100 +insert into parted_conflict_1 values (40, 'cuarenta') + on conflict (a) do update set b = excluded.b +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict_1 VALUES (40, 'cuarenta') ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 241 +-- truncate_limit: 100 +drop table parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_conflict" +== 242 +-- truncate_limit: 100 +-- test whole-row Vars in ON CONFLICT expressions +create table parted_conflict (a int, b text, c int) partition by range (a) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict (a int, b text, c int) PARTITION BY RANGE (a)" +== 243 +-- truncate_limit: 100 +create table parted_conflict_1 (drp text, c int, a int, b text) +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_conflict_1 (drp text, c int, a int, b text)" +== 244 +-- truncate_limit: 100 +alter table parted_conflict_1 drop column drp +-- +TABLE: name="parted_conflict_1" schema="" table="parted_conflict_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_conflict_1 DROP drp" +== 245 +-- truncate_limit: 100 +create unique index on parted_conflict (a, b) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON parted_conflict USING btree (a, b)" +== 246 +-- truncate_limit: 100 +alter table parted_conflict attach partition parted_conflict_1 for values from (0) to (1000) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_conflict ATTACH PARTITION parted_conflict_1 FOR VALUES FROM (0) TO (1000)" +== 247 +-- truncate_limit: 100 +truncate parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_conflict" +== 248 +-- truncate_limit: 100 +insert into parted_conflict values (50, 'cincuenta', 1) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict VALUES (50, 'cincuenta', 1)" +== 249 +-- truncate_limit: 100 +insert into parted_conflict values (50, 'cincuenta', 2) + on conflict (a, b) do update set (a, b, c) = row(excluded.*) + where parted_conflict = (50, text 'cincuenta', 1) and + excluded = (50, text 'cincuenta', 2) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict VALUES (...) ON CONFLICT (a, b) DO UPDATE SET ... = ... WHERE ..." +== 250 +-- truncate_limit: 100 +-- should see (50, 'cincuenta', 2) +select * from parted_conflict order by a +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted_conflict ORDER BY a" +== 251 +-- truncate_limit: 100 +-- test with statement level triggers +create or replace function parted_conflict_update_func() returns trigger as $$ +declare + r record; +begin + for r in select * from inserted loop + raise notice 'a = %, b = %, c = %', r.a, r.b, r.c; + end loop; + return new; +end; +$$ language plpgsql +-- +FUNCTION: name="parted_conflict_update_func" function="parted_conflict_update_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION parted_conflict_update_func() RETURNS trigger AS $$\ndeclare\n r reco..." +== 252 +-- truncate_limit: 100 +create trigger parted_conflict_update + after update on parted_conflict + referencing new table as inserted + for each statement + execute procedure parted_conflict_update_func() +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_conflict_update AFTER UPDATE ON parted_conflict REFERENCING NEW TABLE inser..." +== 253 +-- truncate_limit: 100 +truncate parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted_conflict" +== 254 +-- truncate_limit: 100 +insert into parted_conflict values (0, 'cero', 1) +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict VALUES (0, 'cero', 1)" +== 255 +-- truncate_limit: 100 +insert into parted_conflict values(0, 'cero', 1) + on conflict (a,b) do update set c = parted_conflict.c + 1 +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_conflict VALUES (0, 'cero', 1) ON CONFLICT (a, b) DO UPDATE SET ... = ..." +== 256 +-- truncate_limit: 100 +drop table parted_conflict +-- +TABLE: name="parted_conflict" schema="" table="parted_conflict" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_conflict" +== 257 +-- truncate_limit: 100 +drop function parted_conflict_update_func() +-- +FUNCTION: name="parted_conflict_update_func" function="parted_conflict_update_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION parted_conflict_update_func()" diff --git a/parser/testdata/summary_truncate/postgres_regress/int2.metadata.json b/parser/testdata/summary_truncate/postgres_regress/int2.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/int2.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/int2.test b/parser/testdata/summary_truncate/postgres_regress/int2.test new file mode 100644 index 0000000..0e5bf38 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/int2.test @@ -0,0 +1,590 @@ +== 001 +-- truncate_limit: 100 +|-- +-- INT2 +|-- + +-- int2_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. + +INSERT INTO INT2_TBL(f1) VALUES ('34.5') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES ('34.5')" +== 002 +-- truncate_limit: 100 +INSERT INTO INT2_TBL(f1) VALUES ('100000') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES ('100000')" +== 003 +-- truncate_limit: 100 +INSERT INTO INT2_TBL(f1) VALUES ('asdf') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES ('asdf')" +== 004 +-- truncate_limit: 100 +INSERT INTO INT2_TBL(f1) VALUES (' ') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES (' ')" +== 005 +-- truncate_limit: 100 +INSERT INTO INT2_TBL(f1) VALUES ('- 1234') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES ('- 1234')" +== 006 +-- truncate_limit: 100 +INSERT INTO INT2_TBL(f1) VALUES ('4 444') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES ('4 444')" +== 007 +-- truncate_limit: 100 +INSERT INTO INT2_TBL(f1) VALUES ('123 dt') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES ('123 dt')" +== 008 +-- truncate_limit: 100 +INSERT INTO INT2_TBL(f1) VALUES ('') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES ('')" +== 009 +-- truncate_limit: 100 +SELECT * FROM INT2_TBL +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int2_tbl" +== 010 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34', 'int2') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('34', 'int2')" +== 011 +-- truncate_limit: 100 +SELECT pg_input_is_valid('asdf', 'int2') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('asdf', 'int2')" +== 012 +-- truncate_limit: 100 +SELECT pg_input_is_valid('50000', 'int2') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('50000', 'int2')" +== 013 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('50000', 'int2') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('50000', 'int2')" +== 014 +-- truncate_limit: 100 +-- While we're here, check int2vector as well +SELECT pg_input_is_valid(' 1 3 5 ', 'int2vector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid(' 1 3 5 ', 'int2vector')" +== 015 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1 asdf', 'int2vector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1 asdf', 'int2vector')" +== 016 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('50000', 'int2vector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('50000', 'int2vector')" +== 017 +-- truncate_limit: 100 +SELECT * FROM INT2_TBL AS f(a, b) +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "f"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int2_tbl f(a, b)" +== 018 +-- truncate_limit: 100 +SELECT * FROM (TABLE int2_tbl) AS s (a, b) +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM int2_tbl) s(a, b)" +== 019 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 <> int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 <> '0'::int2" +== 020 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 <> int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 <> '0'::int4" +== 021 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 = int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 = '0'::int2" +== 022 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 = int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 = '0'::int4" +== 023 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 < int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 < '0'::int2" +== 024 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 < int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 < '0'::int4" +== 025 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 <= int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 <= '0'::int2" +== 026 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 <= int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 <= '0'::int4" +== 027 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 > int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 > '0'::int2" +== 028 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 > int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 > '0'::int4" +== 029 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 >= int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 >= '0'::int2" +== 030 +-- truncate_limit: 100 +SELECT i.* FROM INT2_TBL i WHERE i.f1 >= int4 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE i.f1 >= '0'::int4" +== 031 +-- truncate_limit: 100 +-- positive odds +SELECT i.* FROM INT2_TBL i WHERE (i.f1 % int2 '2') = int2 '1' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE (i.f1 % '2'::int2) = '1'::int2" +== 032 +-- truncate_limit: 100 +-- any evens +SELECT i.* FROM INT2_TBL i WHERE (i.f1 % int4 '2') = int2 '0' +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int2_tbl i WHERE (i.f1 % '2'::int4) = '0'::int2" +== 033 +-- truncate_limit: 100 +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 * '2'::int2 AS x FROM int2_tbl i" +== 034 +-- truncate_limit: 100 +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT2_TBL i +WHERE abs(f1) < 16384 +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 * '2'::int2 AS x FROM int2_tbl i WHERE abs(f1) < 16384" +== 035 +-- truncate_limit: 100 +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 * '2'::int4 AS x FROM int2_tbl i" +== 036 +-- truncate_limit: 100 +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 + '2'::int2 AS x FROM int2_tbl i" +== 037 +-- truncate_limit: 100 +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT2_TBL i +WHERE f1 < 32766 +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 + '2'::int2 AS x FROM int2_tbl i WHERE f1 < 32766" +== 038 +-- truncate_limit: 100 +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 + '2'::int4 AS x FROM int2_tbl i" +== 039 +-- truncate_limit: 100 +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 - '2'::int2 AS x FROM int2_tbl i" +== 040 +-- truncate_limit: 100 +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT2_TBL i +WHERE f1 > -32767 +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 - '2'::int2 AS x FROM int2_tbl i WHERE f1 > -32767" +== 041 +-- truncate_limit: 100 +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 - '2'::int4 AS x FROM int2_tbl i" +== 042 +-- truncate_limit: 100 +SELECT i.f1, i.f1 / int2 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 / '2'::int2 AS x FROM int2_tbl i" +== 043 +-- truncate_limit: 100 +SELECT i.f1, i.f1 / int4 '2' AS x FROM INT2_TBL i +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 / '2'::int4 AS x FROM int2_tbl i" +== 044 +-- truncate_limit: 100 +-- corner cases +SELECT (-1::int2<<15)::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT ((- 1::int2) << 15)::text" +== 045 +-- truncate_limit: 100 +SELECT ((-1::int2<<15)+1::int2)::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT (((- 1::int2) << 15) + 1::int2)::text" +== 046 +-- truncate_limit: 100 +-- check sane handling of INT16_MIN overflow cases +SELECT (-32768)::int2 * (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-32768)::int2 * (-1)::int2" +== 047 +-- truncate_limit: 100 +SELECT (-32768)::int2 / (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-32768)::int2 / (-1)::int2" +== 048 +-- truncate_limit: 100 +SELECT (-32768)::int2 % (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-32768)::int2 % (-1)::int2" +== 049 +-- truncate_limit: 100 +-- check rounding when casting from float +SELECT x, x::int2 AS int2_value +FROM (VALUES (-2.5::float8), + (-1.5::float8), + (-0.5::float8), + (0.0::float8), + (0.5::float8), + (1.5::float8), + (2.5::float8)) t(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x, x::int2 AS int2_value FROM (VALUES (...)) t(x)" +== 050 +-- truncate_limit: 100 +-- check rounding when casting from numeric +SELECT x, x::int2 AS int2_value +FROM (VALUES (-2.5::numeric), + (-1.5::numeric), + (-0.5::numeric), + (0.0::numeric), + (0.5::numeric), + (1.5::numeric), + (2.5::numeric)) t(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x, x::int2 AS int2_value FROM (VALUES (...)) t(x)" +== 051 +-- truncate_limit: 100 +-- non-decimal literals + +SELECT int2 '0b100101' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b100101'::int2" +== 052 +-- truncate_limit: 100 +SELECT int2 '0o273' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o273'::int2" +== 053 +-- truncate_limit: 100 +SELECT int2 '0x42F' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x42F'::int2" +== 054 +-- truncate_limit: 100 +SELECT int2 '0b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b'::int2" +== 055 +-- truncate_limit: 100 +SELECT int2 '0o' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o'::int2" +== 056 +-- truncate_limit: 100 +SELECT int2 '0x' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x'::int2" +== 057 +-- truncate_limit: 100 +-- cases near overflow +SELECT int2 '0b111111111111111' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b111111111111111'::int2" +== 058 +-- truncate_limit: 100 +SELECT int2 '0b1000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b1000000000000000'::int2" +== 059 +-- truncate_limit: 100 +SELECT int2 '0o77777' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o77777'::int2" +== 060 +-- truncate_limit: 100 +SELECT int2 '0o100000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o100000'::int2" +== 061 +-- truncate_limit: 100 +SELECT int2 '0x7FFF' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x7FFF'::int2" +== 062 +-- truncate_limit: 100 +SELECT int2 '0x8000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x8000'::int2" +== 063 +-- truncate_limit: 100 +SELECT int2 '-0b1000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0b1000000000000000'::int2" +== 064 +-- truncate_limit: 100 +SELECT int2 '-0b1000000000000001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0b1000000000000001'::int2" +== 065 +-- truncate_limit: 100 +SELECT int2 '-0o100000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0o100000'::int2" +== 066 +-- truncate_limit: 100 +SELECT int2 '-0o100001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0o100001'::int2" +== 067 +-- truncate_limit: 100 +SELECT int2 '-0x8000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0x8000'::int2" +== 068 +-- truncate_limit: 100 +SELECT int2 '-0x8001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0x8001'::int2" +== 069 +-- truncate_limit: 100 +-- underscores + +SELECT int2 '1_000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000'::int2" +== 070 +-- truncate_limit: 100 +SELECT int2 '1_2_3' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_2_3'::int2" +== 071 +-- truncate_limit: 100 +SELECT int2 '0xE_FF' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0xE_FF'::int2" +== 072 +-- truncate_limit: 100 +SELECT int2 '0o2_73' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o2_73'::int2" +== 073 +-- truncate_limit: 100 +SELECT int2 '0b_10_0101' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b_10_0101'::int2" +== 074 +-- truncate_limit: 100 +-- error cases +SELECT int2 '_100' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '_100'::int2" +== 075 +-- truncate_limit: 100 +SELECT int2 '100_' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100_'::int2" +== 076 +-- truncate_limit: 100 +SELECT int2 '10__000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '10__000'::int2" diff --git a/parser/testdata/summary_truncate/postgres_regress/int4.metadata.json b/parser/testdata/summary_truncate/postgres_regress/int4.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/int4.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/int4.test b/parser/testdata/summary_truncate/postgres_regress/int4.test new file mode 100644 index 0000000..b6babbb --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/int4.test @@ -0,0 +1,744 @@ +== 001 +-- truncate_limit: 100 +|-- +-- INT4 +|-- + +-- int4_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. + +INSERT INTO INT4_TBL(f1) VALUES ('34.5') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES ('34.5')" +== 002 +-- truncate_limit: 100 +INSERT INTO INT4_TBL(f1) VALUES ('1000000000000') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES ('1000000000000')" +== 003 +-- truncate_limit: 100 +INSERT INTO INT4_TBL(f1) VALUES ('asdf') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES ('asdf')" +== 004 +-- truncate_limit: 100 +INSERT INTO INT4_TBL(f1) VALUES (' ') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES (' ')" +== 005 +-- truncate_limit: 100 +INSERT INTO INT4_TBL(f1) VALUES (' asdf ') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES (' asdf ')" +== 006 +-- truncate_limit: 100 +INSERT INTO INT4_TBL(f1) VALUES ('- 1234') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES ('- 1234')" +== 007 +-- truncate_limit: 100 +INSERT INTO INT4_TBL(f1) VALUES ('123 5') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES ('123 5')" +== 008 +-- truncate_limit: 100 +INSERT INTO INT4_TBL(f1) VALUES ('') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES ('')" +== 009 +-- truncate_limit: 100 +SELECT * FROM INT4_TBL +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl" +== 010 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34', 'int4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('34', 'int4')" +== 011 +-- truncate_limit: 100 +SELECT pg_input_is_valid('asdf', 'int4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('asdf', 'int4')" +== 012 +-- truncate_limit: 100 +SELECT pg_input_is_valid('1000000000000', 'int4') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1000000000000', 'int4')" +== 013 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1000000000000', 'int4') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1000000000000', 'int4')" +== 014 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 <> '0'::int2" +== 015 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 <> '0'::int4" +== 016 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 = int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 = '0'::int2" +== 017 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 = int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 = '0'::int4" +== 018 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 < int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 < '0'::int2" +== 019 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 < int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 < '0'::int4" +== 020 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 <= '0'::int2" +== 021 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 <= '0'::int4" +== 022 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 > int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 > '0'::int2" +== 023 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 > int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 > '0'::int4" +== 024 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 >= '0'::int2" +== 025 +-- truncate_limit: 100 +SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE i.f1 >= '0'::int4" +== 026 +-- truncate_limit: 100 +-- positive odds +SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE (i.f1 % '2'::int2) = '1'::int2" +== 027 +-- truncate_limit: 100 +-- any evens +SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0' +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="i" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.* FROM int4_tbl i WHERE (i.f1 % '2'::int4) = '0'::int2" +== 028 +-- truncate_limit: 100 +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 * '2'::int2 AS x FROM int4_tbl i" +== 029 +-- truncate_limit: 100 +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i +WHERE abs(f1) < 1073741824 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 * '2'::int2 AS x FROM int4_tbl i WHERE abs(f1) < 1073741824" +== 030 +-- truncate_limit: 100 +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 * '2'::int4 AS x FROM int4_tbl i" +== 031 +-- truncate_limit: 100 +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i +WHERE abs(f1) < 1073741824 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 * '2'::int4 AS x FROM int4_tbl i WHERE abs(f1) < 1073741824" +== 032 +-- truncate_limit: 100 +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 + '2'::int2 AS x FROM int4_tbl i" +== 033 +-- truncate_limit: 100 +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i +WHERE f1 < 2147483646 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 + '2'::int2 AS x FROM int4_tbl i WHERE f1 < 2147483646" +== 034 +-- truncate_limit: 100 +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 + '2'::int4 AS x FROM int4_tbl i" +== 035 +-- truncate_limit: 100 +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i +WHERE f1 < 2147483646 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 + '2'::int4 AS x FROM int4_tbl i WHERE f1 < 2147483646" +== 036 +-- truncate_limit: 100 +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 - '2'::int2 AS x FROM int4_tbl i" +== 037 +-- truncate_limit: 100 +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i +WHERE f1 > -2147483647 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 - '2'::int2 AS x FROM int4_tbl i WHERE f1 > -2147483647" +== 038 +-- truncate_limit: 100 +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 - '2'::int4 AS x FROM int4_tbl i" +== 039 +-- truncate_limit: 100 +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i +WHERE f1 > -2147483647 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 - '2'::int4 AS x FROM int4_tbl i WHERE f1 > -2147483647" +== 040 +-- truncate_limit: 100 +SELECT i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 / '2'::int2 AS x FROM int4_tbl i" +== 041 +-- truncate_limit: 100 +SELECT i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT i.f1, i.f1 / '2'::int4 AS x FROM int4_tbl i" +== 042 +-- truncate_limit: 100 +|-- +-- more complex expressions +|-- + +-- variations on unary minus parsing +SELECT -2+3 AS one +-- +STMT: SelectStmt +TRUNCATED: "SELECT -2 + 3 AS one" +== 043 +-- truncate_limit: 100 +SELECT 4-2 AS two +-- +STMT: SelectStmt +TRUNCATED: "SELECT 4 - 2 AS two" +== 044 +-- truncate_limit: 100 +SELECT 2- -1 AS three +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 - -1 AS three" +== 045 +-- truncate_limit: 100 +SELECT 2 - -2 AS four +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 - -2 AS four" +== 046 +-- truncate_limit: 100 +SELECT int2 '2' * int2 '2' = int2 '16' / int2 '4' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('2'::int2 * '2'::int2) = ('16'::int2 / '4'::int2) AS \"true\"" +== 047 +-- truncate_limit: 100 +SELECT int4 '2' * int2 '2' = int2 '16' / int4 '4' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('2'::int4 * '2'::int2) = ('16'::int2 / '4'::int4) AS \"true\"" +== 048 +-- truncate_limit: 100 +SELECT int2 '2' * int4 '2' = int4 '16' / int2 '4' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('2'::int2 * '2'::int4) = ('16'::int4 / '4'::int2) AS \"true\"" +== 049 +-- truncate_limit: 100 +SELECT int4 '1000' < int4 '999' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1000'::int4 < '999'::int4 AS \"false\"" +== 050 +-- truncate_limit: 100 +SELECT 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 AS ten +-- +STMT: SelectStmt +TRUNCATED: "SELECT ((((((((1 + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1 AS ten" +== 051 +-- truncate_limit: 100 +SELECT 2 + 2 / 2 AS three +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 + (2 / 2) AS three" +== 052 +-- truncate_limit: 100 +SELECT (2 + 2) / 2 AS two +-- +STMT: SelectStmt +TRUNCATED: "SELECT (2 + 2) / 2 AS two" +== 053 +-- truncate_limit: 100 +-- corner case +SELECT (-1::int4<<31)::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT ((- 1::int4) << 31)::text" +== 054 +-- truncate_limit: 100 +SELECT ((-1::int4<<31)+1)::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT (((- 1::int4) << 31) + 1)::text" +== 055 +-- truncate_limit: 100 +-- check sane handling of INT_MIN overflow cases +SELECT (-2147483648)::int4 * (-1)::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-2147483648)::int4 * (-1)::int4" +== 056 +-- truncate_limit: 100 +SELECT (-2147483648)::int4 / (-1)::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-2147483648)::int4 / (-1)::int4" +== 057 +-- truncate_limit: 100 +SELECT (-2147483648)::int4 % (-1)::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-2147483648)::int4 % (-1)::int4" +== 058 +-- truncate_limit: 100 +SELECT (-2147483648)::int4 * (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-2147483648)::int4 * (-1)::int2" +== 059 +-- truncate_limit: 100 +SELECT (-2147483648)::int4 / (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-2147483648)::int4 / (-1)::int2" +== 060 +-- truncate_limit: 100 +SELECT (-2147483648)::int4 % (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-2147483648)::int4 % (-1)::int2" +== 061 +-- truncate_limit: 100 +-- check rounding when casting from float +SELECT x, x::int4 AS int4_value +FROM (VALUES (-2.5::float8), + (-1.5::float8), + (-0.5::float8), + (0.0::float8), + (0.5::float8), + (1.5::float8), + (2.5::float8)) t(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x, x::int4 AS int4_value FROM (VALUES (...)) t(x)" +== 062 +-- truncate_limit: 100 +-- check rounding when casting from numeric +SELECT x, x::int4 AS int4_value +FROM (VALUES (-2.5::numeric), + (-1.5::numeric), + (-0.5::numeric), + (0.0::numeric), + (0.5::numeric), + (1.5::numeric), + (2.5::numeric)) t(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x, x::int4 AS int4_value FROM (VALUES (...)) t(x)" +== 063 +-- truncate_limit: 100 +-- test gcd() +SELECT a, b, gcd(a, b), gcd(a, -b), gcd(b, a), gcd(-b, a) +FROM (VALUES (0::int4, 0::int4), + (0::int4, 6410818::int4), + (61866666::int4, 6410818::int4), + (-61866666::int4, 6410818::int4), + ((-2147483648)::int4, 1::int4), + ((-2147483648)::int4, 2147483647::int4), + ((-2147483648)::int4, 1073741824::int4)) AS v(a, b) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, gcd(a, b), gcd(a, - b), gcd(b, a), gcd(- b, a) FROM (VALUES (...)) v(a, b)" +== 064 +-- truncate_limit: 100 +SELECT gcd((-2147483648)::int4, 0::int4) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT gcd((-2147483648)::int4, 0::int4)" +== 065 +-- truncate_limit: 100 +-- overflow +SELECT gcd((-2147483648)::int4, (-2147483648)::int4) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT gcd((-2147483648)::int4, (-2147483648)::int4)" +== 066 +-- truncate_limit: 100 +-- overflow + +-- test lcm() +SELECT a, b, lcm(a, b), lcm(a, -b), lcm(b, a), lcm(-b, a) +FROM (VALUES (0::int4, 0::int4), + (0::int4, 42::int4), + (42::int4, 42::int4), + (330::int4, 462::int4), + (-330::int4, 462::int4), + ((-2147483648)::int4, 0::int4)) AS v(a, b) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, lcm(a, b), lcm(a, - b), lcm(b, a), lcm(- b, a) FROM (VALUES (...)) v(a, b)" +== 067 +-- truncate_limit: 100 +SELECT lcm((-2147483648)::int4, 1::int4) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lcm((-2147483648)::int4, 1::int4)" +== 068 +-- truncate_limit: 100 +-- overflow +SELECT lcm(2147483647::int4, 2147483646::int4) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lcm(2147483647::int4, 2147483646::int4)" +== 069 +-- truncate_limit: 100 +-- overflow + + +-- non-decimal literals + +SELECT int4 '0b100101' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b100101'::int4" +== 070 +-- truncate_limit: 100 +SELECT int4 '0o273' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o273'::int4" +== 071 +-- truncate_limit: 100 +SELECT int4 '0x42F' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x42F'::int4" +== 072 +-- truncate_limit: 100 +SELECT int4 '0b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b'::int4" +== 073 +-- truncate_limit: 100 +SELECT int4 '0o' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o'::int4" +== 074 +-- truncate_limit: 100 +SELECT int4 '0x' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x'::int4" +== 075 +-- truncate_limit: 100 +-- cases near overflow +SELECT int4 '0b1111111111111111111111111111111' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b1111111111111111111111111111111'::int4" +== 076 +-- truncate_limit: 100 +SELECT int4 '0b10000000000000000000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b10000000000000000000000000000000'::int4" +== 077 +-- truncate_limit: 100 +SELECT int4 '0o17777777777' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o17777777777'::int4" +== 078 +-- truncate_limit: 100 +SELECT int4 '0o20000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o20000000000'::int4" +== 079 +-- truncate_limit: 100 +SELECT int4 '0x7FFFFFFF' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x7FFFFFFF'::int4" +== 080 +-- truncate_limit: 100 +SELECT int4 '0x80000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x80000000'::int4" +== 081 +-- truncate_limit: 100 +SELECT int4 '-0b10000000000000000000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0b10000000000000000000000000000000'::int4" +== 082 +-- truncate_limit: 100 +SELECT int4 '-0b10000000000000000000000000000001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0b10000000000000000000000000000001'::int4" +== 083 +-- truncate_limit: 100 +SELECT int4 '-0o20000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0o20000000000'::int4" +== 084 +-- truncate_limit: 100 +SELECT int4 '-0o20000000001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0o20000000001'::int4" +== 085 +-- truncate_limit: 100 +SELECT int4 '-0x80000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0x80000000'::int4" +== 086 +-- truncate_limit: 100 +SELECT int4 '-0x80000001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0x80000001'::int4" +== 087 +-- truncate_limit: 100 +-- underscores + +SELECT int4 '1_000_000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000_000'::int4" +== 088 +-- truncate_limit: 100 +SELECT int4 '1_2_3' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_2_3'::int4" +== 089 +-- truncate_limit: 100 +SELECT int4 '0x1EEE_FFFF' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x1EEE_FFFF'::int4" +== 090 +-- truncate_limit: 100 +SELECT int4 '0o2_73' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o2_73'::int4" +== 091 +-- truncate_limit: 100 +SELECT int4 '0b_10_0101' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b_10_0101'::int4" +== 092 +-- truncate_limit: 100 +-- error cases +SELECT int4 '_100' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '_100'::int4" +== 093 +-- truncate_limit: 100 +SELECT int4 '100_' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100_'::int4" +== 094 +-- truncate_limit: 100 +SELECT int4 '100__000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100__000'::int4" diff --git a/parser/testdata/summary_truncate/postgres_regress/int8.metadata.json b/parser/testdata/summary_truncate/postgres_regress/int8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/int8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/int8.test b/parser/testdata/summary_truncate/postgres_regress/int8.test new file mode 100644 index 0000000..1d76a66 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/int8.test @@ -0,0 +1,1255 @@ +== 001 +-- truncate_limit: 100 +|-- +-- INT8 +-- Test int8 64-bit integers. +|-- + +-- int8_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. + +INSERT INTO INT8_TBL(q1) VALUES (' ') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int8_tbl (q1) VALUES (' ')" +== 002 +-- truncate_limit: 100 +INSERT INTO INT8_TBL(q1) VALUES ('xxx') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int8_tbl (q1) VALUES ('xxx')" +== 003 +-- truncate_limit: 100 +INSERT INTO INT8_TBL(q1) VALUES ('3908203590239580293850293850329485') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int8_tbl (q1) VALUES ('3908203590239580293850293850329485')" +== 004 +-- truncate_limit: 100 +INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340329840934') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int8_tbl (q1) VALUES ('-1204982019841029840928340329840934')" +== 005 +-- truncate_limit: 100 +INSERT INTO INT8_TBL(q1) VALUES ('- 123') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int8_tbl (q1) VALUES ('- 123')" +== 006 +-- truncate_limit: 100 +INSERT INTO INT8_TBL(q1) VALUES (' 345 5') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int8_tbl (q1) VALUES (' 345 5')" +== 007 +-- truncate_limit: 100 +INSERT INTO INT8_TBL(q1) VALUES ('') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int8_tbl (q1) VALUES ('')" +== 008 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl" +== 009 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34', 'int8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('34', 'int8')" +== 010 +-- truncate_limit: 100 +SELECT pg_input_is_valid('asdf', 'int8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('asdf', 'int8')" +== 011 +-- truncate_limit: 100 +SELECT pg_input_is_valid('10000000000000000000', 'int8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('10000000000000000000', 'int8')" +== 012 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('10000000000000000000', 'int8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('10000000000000000000', 'int8')" +== 013 +-- truncate_limit: 100 +-- int8/int8 cmp +SELECT * FROM INT8_TBL WHERE q2 = 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 = 4567890123456789" +== 014 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 <> 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 <> 4567890123456789" +== 015 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 < 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 < 4567890123456789" +== 016 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 > 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 > 4567890123456789" +== 017 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 <= 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 <= 4567890123456789" +== 018 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 >= 4567890123456789 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 >= 4567890123456789" +== 019 +-- truncate_limit: 100 +-- int8/int4 cmp +SELECT * FROM INT8_TBL WHERE q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 = 456" +== 020 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 <> 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 <> 456" +== 021 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 < 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 < 456" +== 022 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 > 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 > 456" +== 023 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 <= 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 <= 456" +== 024 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 >= 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 >= 456" +== 025 +-- truncate_limit: 100 +-- int4/int8 cmp +SELECT * FROM INT8_TBL WHERE 123 = q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE 123 = q1" +== 026 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE 123 <> q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE 123 <> q1" +== 027 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE 123 < q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE 123 < q1" +== 028 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE 123 > q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE 123 > q1" +== 029 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE 123 <= q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE 123 <= q1" +== 030 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE 123 >= q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE 123 >= q1" +== 031 +-- truncate_limit: 100 +-- int8/int2 cmp +SELECT * FROM INT8_TBL WHERE q2 = '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 = '456'::int2" +== 032 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 <> '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 <> '456'::int2" +== 033 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 < '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 < '456'::int2" +== 034 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 > '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 > '456'::int2" +== 035 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 <= '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 <= '456'::int2" +== 036 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE q2 >= '456'::int2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q2 >= '456'::int2" +== 037 +-- truncate_limit: 100 +-- int2/int8 cmp +SELECT * FROM INT8_TBL WHERE '123'::int2 = q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE '123'::int2 = q1" +== 038 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE '123'::int2 <> q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE '123'::int2 <> q1" +== 039 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE '123'::int2 < q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE '123'::int2 < q1" +== 040 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE '123'::int2 > q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE '123'::int2 > q1" +== 041 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE '123'::int2 <= q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE '123'::int2 <= q1" +== 042 +-- truncate_limit: 100 +SELECT * FROM INT8_TBL WHERE '123'::int2 >= q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE '123'::int2 >= q1" +== 043 +-- truncate_limit: 100 +SELECT q1 AS plus, -q1 AS minus FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 AS plus, - q1 AS minus FROM int8_tbl" +== 044 +-- truncate_limit: 100 +SELECT q1, q2, q1 + q2 AS plus FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1, q2, q1 + q2 AS plus FROM int8_tbl" +== 045 +-- truncate_limit: 100 +SELECT q1, q2, q1 - q2 AS minus FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1, q2, q1 - q2 AS minus FROM int8_tbl" +== 046 +-- truncate_limit: 100 +SELECT q1, q2, q1 * q2 AS multiply FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1, q2, q1 * q2 AS multiply FROM int8_tbl" +== 047 +-- truncate_limit: 100 +SELECT q1, q2, q1 * q2 AS multiply FROM INT8_TBL + WHERE q1 < 1000 or (q2 > 0 and q2 < 1000) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT q1, q2, q1 * q2 AS multiply FROM int8_tbl WHERE q1 < 1000 OR (q2 > 0 AND q2 < 1000)" +== 048 +-- truncate_limit: 100 +SELECT q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM int8_tbl" +== 049 +-- truncate_limit: 100 +SELECT q1, float8(q1) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="float8" function="float8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT q1, float8(q1) FROM int8_tbl" +== 050 +-- truncate_limit: 100 +SELECT q2, float8(q2) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="float8" function="float8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT q2, float8(q2) FROM int8_tbl" +== 051 +-- truncate_limit: 100 +SELECT 37 + q1 AS plus4 FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 37 + q1 AS plus4 FROM int8_tbl" +== 052 +-- truncate_limit: 100 +SELECT 37 - q1 AS minus4 FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 37 - q1 AS minus4 FROM int8_tbl" +== 053 +-- truncate_limit: 100 +SELECT 2 * q1 AS "twice int4" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 2 * q1 AS \"twice int4\" FROM int8_tbl" +== 054 +-- truncate_limit: 100 +SELECT q1 * 2 AS "twice int4" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 * 2 AS \"twice int4\" FROM int8_tbl" +== 055 +-- truncate_limit: 100 +-- int8 op int4 +SELECT q1 + 42::int4 AS "8plus4", q1 - 42::int4 AS "8minus4", q1 * 42::int4 AS "8mul4", q1 / 42::int4 AS "8div4" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl" +== 056 +-- truncate_limit: 100 +-- int4 op int8 +SELECT 246::int4 + q1 AS "4plus8", 246::int4 - q1 AS "4minus8", 246::int4 * q1 AS "4mul8", 246::int4 / q1 AS "4div8" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl" +== 057 +-- truncate_limit: 100 +-- int8 op int2 +SELECT q1 + 42::int2 AS "8plus2", q1 - 42::int2 AS "8minus2", q1 * 42::int2 AS "8mul2", q1 / 42::int2 AS "8div2" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl" +== 058 +-- truncate_limit: 100 +-- int2 op int8 +SELECT 246::int2 + q1 AS "2plus8", 246::int2 - q1 AS "2minus8", 246::int2 * q1 AS "2mul8", 246::int2 / q1 AS "2div8" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl" +== 059 +-- truncate_limit: 100 +SELECT q2, abs(q2) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT q2, abs(q2) FROM int8_tbl" +== 060 +-- truncate_limit: 100 +SELECT min(q1), min(q2) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(q1), min(q2) FROM int8_tbl" +== 061 +-- truncate_limit: 100 +SELECT max(q1), max(q2) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(q1), max(q2) FROM int8_tbl" +== 062 +-- truncate_limit: 100 +-- TO_CHAR() +|-- +SELECT to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') + FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') FROM int8_tbl" +== 063 +-- truncate_limit: 100 +SELECT to_char(q1, '9G999G999G999G999G999D999G999'), to_char(q2, '9,999,999,999,999,999.999,999') + FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl" +== 064 +-- truncate_limit: 100 +SELECT to_char( (q1 * -1), '9999999999999999PR'), to_char( (q2 * -1), '9999999999999999.999PR') + FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl" +== 065 +-- truncate_limit: 100 +SELECT to_char( (q1 * -1), '9999999999999999S'), to_char( (q2 * -1), 'S9999999999999999') + FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q1 * -1, '9999999999999999S'), to_char(q2 * -1, 'S9999999999999999') FROM int8_tbl" +== 066 +-- truncate_limit: 100 +SELECT to_char(q2, 'MI9999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'MI9999999999999999') FROM int8_tbl" +== 067 +-- truncate_limit: 100 +SELECT to_char(q2, 'FMS9999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'FMS9999999999999999') FROM int8_tbl" +== 068 +-- truncate_limit: 100 +SELECT to_char(q2, 'FM9999999999999999THPR') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'FM9999999999999999THPR') FROM int8_tbl" +== 069 +-- truncate_limit: 100 +SELECT to_char(q2, 'SG9999999999999999th') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'SG9999999999999999th') FROM int8_tbl" +== 070 +-- truncate_limit: 100 +SELECT to_char(q2, '0999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, '0999999999999999') FROM int8_tbl" +== 071 +-- truncate_limit: 100 +SELECT to_char(q2, 'S0999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'S0999999999999999') FROM int8_tbl" +== 072 +-- truncate_limit: 100 +SELECT to_char(q2, 'FM0999999999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'FM0999999999999999') FROM int8_tbl" +== 073 +-- truncate_limit: 100 +SELECT to_char(q2, 'FM9999999999999999.000') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'FM9999999999999999.000') FROM int8_tbl" +== 074 +-- truncate_limit: 100 +SELECT to_char(q2, 'L9999999999999999.000') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'L9999999999999999.000') FROM int8_tbl" +== 075 +-- truncate_limit: 100 +SELECT to_char(q2, 'FM9999999999999999.999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'FM9999999999999999.999') FROM int8_tbl" +== 076 +-- truncate_limit: 100 +SELECT to_char(q2, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9') FROM int8_tbl" +== 077 +-- truncate_limit: 100 +SELECT to_char(q2, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl" +== 078 +-- truncate_limit: 100 +SELECT to_char(q2, '999999SG9999999999') FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(q2, '999999SG9999999999') FROM int8_tbl" +== 079 +-- truncate_limit: 100 +-- check min/max values and overflow behavior + +select '-9223372036854775808'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808'::int8" +== 080 +-- truncate_limit: 100 +select '-9223372036854775809'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775809'::int8" +== 081 +-- truncate_limit: 100 +select '9223372036854775807'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775807'::int8" +== 082 +-- truncate_limit: 100 +select '9223372036854775808'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775808'::int8" +== 083 +-- truncate_limit: 100 +select -('-9223372036854775807'::int8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-9223372036854775807'::int8" +== 084 +-- truncate_limit: 100 +select -('-9223372036854775808'::int8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-9223372036854775808'::int8" +== 085 +-- truncate_limit: 100 +select 0::int8 - '-9223372036854775808'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0::int8 - '-9223372036854775808'::int8" +== 086 +-- truncate_limit: 100 +select '9223372036854775800'::int8 + '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 + '9223372036854775800'::int8" +== 087 +-- truncate_limit: 100 +select '-9223372036854775800'::int8 + '-9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775800'::int8 + '-9223372036854775800'::int8" +== 088 +-- truncate_limit: 100 +select '9223372036854775800'::int8 - '-9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 - '-9223372036854775800'::int8" +== 089 +-- truncate_limit: 100 +select '-9223372036854775800'::int8 - '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775800'::int8 - '9223372036854775800'::int8" +== 090 +-- truncate_limit: 100 +select '9223372036854775800'::int8 * '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 * '9223372036854775800'::int8" +== 091 +-- truncate_limit: 100 +select '9223372036854775800'::int8 / '0'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 / '0'::int8" +== 092 +-- truncate_limit: 100 +select '9223372036854775800'::int8 % '0'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 % '0'::int8" +== 093 +-- truncate_limit: 100 +select abs('-9223372036854775808'::int8) +-- +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT abs('-9223372036854775808'::int8)" +== 094 +-- truncate_limit: 100 +select '9223372036854775800'::int8 + '100'::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 + '100'::int4" +== 095 +-- truncate_limit: 100 +select '-9223372036854775800'::int8 - '100'::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775800'::int8 - '100'::int4" +== 096 +-- truncate_limit: 100 +select '9223372036854775800'::int8 * '100'::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 * '100'::int4" +== 097 +-- truncate_limit: 100 +select '100'::int4 + '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100'::int4 + '9223372036854775800'::int8" +== 098 +-- truncate_limit: 100 +select '-100'::int4 - '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-100'::int4 - '9223372036854775800'::int8" +== 099 +-- truncate_limit: 100 +select '100'::int4 * '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100'::int4 * '9223372036854775800'::int8" +== 100 +-- truncate_limit: 100 +select '9223372036854775800'::int8 + '100'::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 + '100'::int2" +== 101 +-- truncate_limit: 100 +select '-9223372036854775800'::int8 - '100'::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775800'::int8 - '100'::int2" +== 102 +-- truncate_limit: 100 +select '9223372036854775800'::int8 * '100'::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775800'::int8 * '100'::int2" +== 103 +-- truncate_limit: 100 +select '-9223372036854775808'::int8 / '0'::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808'::int8 / '0'::int2" +== 104 +-- truncate_limit: 100 +select '100'::int2 + '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100'::int2 + '9223372036854775800'::int8" +== 105 +-- truncate_limit: 100 +select '-100'::int2 - '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-100'::int2 - '9223372036854775800'::int8" +== 106 +-- truncate_limit: 100 +select '100'::int2 * '9223372036854775800'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100'::int2 * '9223372036854775800'::int8" +== 107 +-- truncate_limit: 100 +select '100'::int2 / '0'::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100'::int2 / '0'::int8" +== 108 +-- truncate_limit: 100 +SELECT CAST(q1 AS int4) FROM int8_tbl WHERE q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT q1::int4 FROM int8_tbl WHERE q2 = 456" +== 109 +-- truncate_limit: 100 +SELECT CAST(q1 AS int4) FROM int8_tbl WHERE q2 <> 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT q1::int4 FROM int8_tbl WHERE q2 <> 456" +== 110 +-- truncate_limit: 100 +SELECT CAST(q1 AS int2) FROM int8_tbl WHERE q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT q1::int2 FROM int8_tbl WHERE q2 = 456" +== 111 +-- truncate_limit: 100 +SELECT CAST(q1 AS int2) FROM int8_tbl WHERE q2 <> 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT q1::int2 FROM int8_tbl WHERE q2 <> 456" +== 112 +-- truncate_limit: 100 +SELECT CAST('42'::int2 AS int8), CAST('-37'::int2 AS int8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::int2::int8, '-37'::int2::int8" +== 113 +-- truncate_limit: 100 +SELECT CAST(q1 AS float4), CAST(q2 AS float8) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1::float4, q2::float8 FROM int8_tbl" +== 114 +-- truncate_limit: 100 +SELECT CAST('36854775807.0'::float4 AS int8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '36854775807.0'::float4::int8" +== 115 +-- truncate_limit: 100 +SELECT CAST('922337203685477580700.0'::float8 AS int8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '922337203685477580700.0'::float8::int8" +== 116 +-- truncate_limit: 100 +SELECT CAST(q1 AS oid) FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1::oid FROM int8_tbl" +== 117 +-- truncate_limit: 100 +SELECT oid::int8 FROM pg_class WHERE relname = 'pg_class' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT oid::int8 FROM pg_class WHERE relname = 'pg_class'" +== 118 +-- truncate_limit: 100 +-- bit operations + +SELECT q1, q2, q1 & q2 AS "and", q1 | q2 AS "or", q1 # q2 AS "xor", ~q1 AS "not" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1, q2, q1 & q2 AS \"and\", q1 | q2 AS \"or\", q1 # q2 AS xor, ~ q1 AS \"not\" FROM int8_tbl" +== 119 +-- truncate_limit: 100 +SELECT q1, q1 << 2 AS "shl", q1 >> 3 AS "shr" FROM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1, q1 << 2 AS shl, q1 >> 3 AS shr FROM int8_tbl" +== 120 +-- truncate_limit: 100 +-- generate_series + +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8)" +== 121 +-- truncate_limit: 100 +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 0) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 0)" +== 122 +-- truncate_limit: 100 +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 2) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 2)" +== 123 +-- truncate_limit: 100 +-- corner case +SELECT (-1::int8<<63)::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT ((- 1::int8) << 63)::text" +== 124 +-- truncate_limit: 100 +SELECT ((-1::int8<<63)+1)::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT (((- 1::int8) << 63) + 1)::text" +== 125 +-- truncate_limit: 100 +-- check sane handling of INT64_MIN overflow cases +SELECT (-9223372036854775808)::int8 * (-1)::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 * (-1)::int8" +== 126 +-- truncate_limit: 100 +SELECT (-9223372036854775808)::int8 / (-1)::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 / (-1)::int8" +== 127 +-- truncate_limit: 100 +SELECT (-9223372036854775808)::int8 % (-1)::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 % (-1)::int8" +== 128 +-- truncate_limit: 100 +SELECT (-9223372036854775808)::int8 * (-1)::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 * (-1)::int4" +== 129 +-- truncate_limit: 100 +SELECT (-9223372036854775808)::int8 / (-1)::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 / (-1)::int4" +== 130 +-- truncate_limit: 100 +SELECT (-9223372036854775808)::int8 % (-1)::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 % (-1)::int4" +== 131 +-- truncate_limit: 100 +SELECT (-9223372036854775808)::int8 * (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 * (-1)::int2" +== 132 +-- truncate_limit: 100 +SELECT (-9223372036854775808)::int8 / (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 / (-1)::int2" +== 133 +-- truncate_limit: 100 +SELECT (-9223372036854775808)::int8 % (-1)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808)::int8 % (-1)::int2" +== 134 +-- truncate_limit: 100 +-- check rounding when casting from float +SELECT x, x::int8 AS int8_value +FROM (VALUES (-2.5::float8), + (-1.5::float8), + (-0.5::float8), + (0.0::float8), + (0.5::float8), + (1.5::float8), + (2.5::float8)) t(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x, x::int8 AS int8_value FROM (VALUES (...)) t(x)" +== 135 +-- truncate_limit: 100 +-- check rounding when casting from numeric +SELECT x, x::int8 AS int8_value +FROM (VALUES (-2.5::numeric), + (-1.5::numeric), + (-0.5::numeric), + (0.0::numeric), + (0.5::numeric), + (1.5::numeric), + (2.5::numeric)) t(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x, x::int8 AS int8_value FROM (VALUES (...)) t(x)" +== 136 +-- truncate_limit: 100 +-- test gcd() +SELECT a, b, gcd(a, b), gcd(a, -b), gcd(b, a), gcd(-b, a) +FROM (VALUES (0::int8, 0::int8), + (0::int8, 29893644334::int8), + (288484263558::int8, 29893644334::int8), + (-288484263558::int8, 29893644334::int8), + ((-9223372036854775808)::int8, 1::int8), + ((-9223372036854775808)::int8, 9223372036854775807::int8), + ((-9223372036854775808)::int8, 4611686018427387904::int8)) AS v(a, b) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, gcd(a, b), gcd(a, - b), gcd(b, a), gcd(- b, a) FROM (VALUES (...)) v(a, b)" +== 137 +-- truncate_limit: 100 +SELECT gcd((-9223372036854775808)::int8, 0::int8) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT gcd((-9223372036854775808)::int8, 0::int8)" +== 138 +-- truncate_limit: 100 +-- overflow +SELECT gcd((-9223372036854775808)::int8, (-9223372036854775808)::int8) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT gcd((-9223372036854775808)::int8, (-9223372036854775808)::int8)" +== 139 +-- truncate_limit: 100 +-- overflow + +-- test lcm() +SELECT a, b, lcm(a, b), lcm(a, -b), lcm(b, a), lcm(-b, a) +FROM (VALUES (0::int8, 0::int8), + (0::int8, 29893644334::int8), + (29893644334::int8, 29893644334::int8), + (288484263558::int8, 29893644334::int8), + (-288484263558::int8, 29893644334::int8), + ((-9223372036854775808)::int8, 0::int8)) AS v(a, b) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, lcm(a, b), lcm(a, - b), lcm(b, a), lcm(- b, a) FROM (VALUES (...)) v(a, b)" +== 140 +-- truncate_limit: 100 +SELECT lcm((-9223372036854775808)::int8, 1::int8) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lcm((-9223372036854775808)::int8, 1::int8)" +== 141 +-- truncate_limit: 100 +-- overflow +SELECT lcm(9223372036854775807::int8, 9223372036854775806::int8) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lcm((9223372036854775807)::int8, (9223372036854775806)::int8)" +== 142 +-- truncate_limit: 100 +-- overflow + + +-- non-decimal literals + +SELECT int8 '0b100101' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b100101'::int8" +== 143 +-- truncate_limit: 100 +SELECT int8 '0o273' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o273'::int8" +== 144 +-- truncate_limit: 100 +SELECT int8 '0x42F' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x42F'::int8" +== 145 +-- truncate_limit: 100 +SELECT int8 '0b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b'::int8" +== 146 +-- truncate_limit: 100 +SELECT int8 '0o' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o'::int8" +== 147 +-- truncate_limit: 100 +SELECT int8 '0x' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x'::int8" +== 148 +-- truncate_limit: 100 +-- cases near overflow +SELECT int8 '0b111111111111111111111111111111111111111111111111111111111111111' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b111111111111111111111111111111111111111111111111111111111111111'::int8" +== 149 +-- truncate_limit: 100 +SELECT int8 '0b1000000000000000000000000000000000000000000000000000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b1000000000000000000000000000000000000000000000000000000000000000'::int8" +== 150 +-- truncate_limit: 100 +SELECT int8 '0o777777777777777777777' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o777777777777777777777'::int8" +== 151 +-- truncate_limit: 100 +SELECT int8 '0o1000000000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o1000000000000000000000'::int8" +== 152 +-- truncate_limit: 100 +SELECT int8 '0x7FFFFFFFFFFFFFFF' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x7FFFFFFFFFFFFFFF'::int8" +== 153 +-- truncate_limit: 100 +SELECT int8 '0x8000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x8000000000000000'::int8" +== 154 +-- truncate_limit: 100 +SELECT int8 '-0b1000000000000000000000000000000000000000000000000000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0b1000000000000000000000000000000000000000000000000000000000000000'::int8" +== 155 +-- truncate_limit: 100 +SELECT int8 '-0b1000000000000000000000000000000000000000000000000000000000000001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0b1000000000000000000000000000000000000000000000000000000000000001'::int8" +== 156 +-- truncate_limit: 100 +SELECT int8 '-0o1000000000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0o1000000000000000000000'::int8" +== 157 +-- truncate_limit: 100 +SELECT int8 '-0o1000000000000000000001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0o1000000000000000000001'::int8" +== 158 +-- truncate_limit: 100 +SELECT int8 '-0x8000000000000000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0x8000000000000000'::int8" +== 159 +-- truncate_limit: 100 +SELECT int8 '-0x8000000000000001' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0x8000000000000001'::int8" +== 160 +-- truncate_limit: 100 +-- underscores + +SELECT int8 '1_000_000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000_000'::int8" +== 161 +-- truncate_limit: 100 +SELECT int8 '1_2_3' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_2_3'::int8" +== 162 +-- truncate_limit: 100 +SELECT int8 '0x1EEE_FFFF' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x1EEE_FFFF'::int8" +== 163 +-- truncate_limit: 100 +SELECT int8 '0o2_73' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o2_73'::int8" +== 164 +-- truncate_limit: 100 +SELECT int8 '0b_10_0101' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b_10_0101'::int8" +== 165 +-- truncate_limit: 100 +-- error cases +SELECT int8 '_100' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '_100'::int8" +== 166 +-- truncate_limit: 100 +SELECT int8 '100_' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100_'::int8" +== 167 +-- truncate_limit: 100 +SELECT int8 '100__000' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100__000'::int8" diff --git a/parser/testdata/summary_truncate/postgres_regress/interval.metadata.json b/parser/testdata/summary_truncate/postgres_regress/interval.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/interval.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/interval.test b/parser/testdata/summary_truncate/postgres_regress/interval.test new file mode 100644 index 0000000..4eddddb --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/interval.test @@ -0,0 +1,3138 @@ +== 001 +-- truncate_limit: 100 +|-- +-- INTERVAL +|-- + +SET DATESTYLE = 'ISO' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"ISO\"" +== 002 +-- truncate_limit: 100 +SET IntervalStyle to postgres +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO postgres" +== 003 +-- truncate_limit: 100 +-- check acceptance of "time zone style" +SELECT INTERVAL '01:00' AS "One hour" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01:00'::interval AS \"One hour\"" +== 004 +-- truncate_limit: 100 +SELECT INTERVAL '+02:00' AS "Two hours" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '+02:00'::interval AS \"Two hours\"" +== 005 +-- truncate_limit: 100 +SELECT INTERVAL '-08:00' AS "Eight hours" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-08:00'::interval AS \"Eight hours\"" +== 006 +-- truncate_limit: 100 +SELECT INTERVAL '-1 +02:03' AS "22 hours ago..." +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1 +02:03'::interval AS \"22 hours ago...\"" +== 007 +-- truncate_limit: 100 +SELECT INTERVAL '-1 days +02:03' AS "22 hours ago..." +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1 days +02:03'::interval AS \"22 hours ago...\"" +== 008 +-- truncate_limit: 100 +SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.5 weeks'::interval AS \"Ten days twelve hours\"" +== 009 +-- truncate_limit: 100 +SELECT INTERVAL '1.5 months' AS "One month 15 days" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.5 months'::interval AS \"One month 15 days\"" +== 010 +-- truncate_limit: 100 +SELECT INTERVAL '10 years -11 month -12 days +13:14' AS "9 years..." +-- +STMT: SelectStmt +TRUNCATED: "SELECT '10 years -11 month -12 days +13:14'::interval AS \"9 years...\"" +== 011 +-- truncate_limit: 100 +SELECT INTERVAL 'infinity' AS "eternity" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::interval AS eternity" +== 012 +-- truncate_limit: 100 +SELECT INTERVAL '-infinity' AS "beginning of time" +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::interval AS \"beginning of time\"" +== 013 +-- truncate_limit: 100 +CREATE TABLE INTERVAL_TBL (f1 interval) +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE interval_tbl (f1 interval)" +== 014 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 1 minute') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('@ 1 minute')" +== 015 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 5 hour') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('@ 5 hour')" +== 016 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 10 day') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('@ 10 day')" +== 017 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 34 year') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('@ 34 year')" +== 018 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 3 months') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('@ 3 months')" +== 019 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 14 seconds ago') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('@ 14 seconds ago')" +== 020 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('1 day 2 hours 3 minutes 4 seconds') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('1 day 2 hours 3 minutes 4 seconds')" +== 021 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('6 years') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('6 years')" +== 022 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('5 months')" +== 023 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months 12 hours') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('5 months 12 hours')" +== 024 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('infinity') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('infinity')" +== 025 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('-infinity') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('-infinity')" +== 026 +-- truncate_limit: 100 +-- badly formatted interval +INSERT INTO INTERVAL_TBL (f1) VALUES ('badly formatted interval') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('badly formatted interval')" +== 027 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 30 eons ago') +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl (f1) VALUES ('@ 30 eons ago')" +== 028 +-- truncate_limit: 100 +-- Test non-error-throwing API +SELECT pg_input_is_valid('1.5 weeks', 'interval') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1.5 weeks', 'interval')" +== 029 +-- truncate_limit: 100 +SELECT pg_input_is_valid('garbage', 'interval') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('garbage', 'interval')" +== 030 +-- truncate_limit: 100 +SELECT pg_input_is_valid('@ 30 eons ago', 'interval') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('@ 30 eons ago', 'interval')" +== 031 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('garbage', 'interval') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('garbage', 'interval')" +== 032 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('@ 30 eons ago', 'interval') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('@ 30 eons ago', 'interval')" +== 033 +-- truncate_limit: 100 +-- test interval operators + +SELECT * FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM interval_tbl" +== 034 +-- truncate_limit: 100 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 <> interval '@ 10 days' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM interval_tbl WHERE interval_tbl.f1 <> '@ 10 days'::interval" +== 035 +-- truncate_limit: 100 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 <= interval '@ 5 hours' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM interval_tbl WHERE interval_tbl.f1 <= '@ 5 hours'::interval" +== 036 +-- truncate_limit: 100 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 < interval '@ 1 day' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM interval_tbl WHERE interval_tbl.f1 < '@ 1 day'::interval" +== 037 +-- truncate_limit: 100 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 = interval '@ 34 years' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM interval_tbl WHERE interval_tbl.f1 = '@ 34 years'::interval" +== 038 +-- truncate_limit: 100 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 >= interval '@ 1 month' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM interval_tbl WHERE interval_tbl.f1 >= '@ 1 month'::interval" +== 039 +-- truncate_limit: 100 +SELECT * FROM INTERVAL_TBL + WHERE INTERVAL_TBL.f1 > interval '@ 3 seconds ago' +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FILTER: schema="" table="interval_tbl" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM interval_tbl WHERE interval_tbl.f1 > '@ 3 seconds ago'::interval" +== 040 +-- truncate_limit: 100 +SELECT r1.*, r2.* + FROM INTERVAL_TBL r1, INTERVAL_TBL r2 + WHERE r1.f1 > r2.f1 + ORDER BY r1.f1, r2.f1 +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +ALIAS: "r1"="interval_tbl" +ALIAS: "r2"="interval_tbl" +FILTER: schema="" table="r1" column="f1" +FILTER: schema="" table="r2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT r1.*, r2.* FROM interval_tbl r1, interval_tbl r2 WHERE r1.f1 > r2.f1 ORDER BY r1.f1, r2.f1" +== 041 +-- truncate_limit: 100 +-- test unary minus + +SELECT f1, -f1 FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, - f1 FROM interval_tbl" +== 042 +-- truncate_limit: 100 +SELECT -('-2147483648 months'::interval) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-2147483648 months'::interval" +== 043 +-- truncate_limit: 100 +-- should fail +SELECT -('-2147483647 months'::interval) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-2147483647 months'::interval" +== 044 +-- truncate_limit: 100 +-- ok +SELECT -('-2147483648 days'::interval) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-2147483648 days'::interval" +== 045 +-- truncate_limit: 100 +-- should fail +SELECT -('-2147483647 days'::interval) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-2147483647 days'::interval" +== 046 +-- truncate_limit: 100 +-- ok +SELECT -('-9223372036854775808 us'::interval) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-9223372036854775808 us'::interval" +== 047 +-- truncate_limit: 100 +-- should fail +SELECT -('-9223372036854775807 us'::interval) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-9223372036854775807 us'::interval" +== 048 +-- truncate_limit: 100 +-- ok +SELECT -('-2147483647 months -2147483647 days -9223372036854775807 us'::interval) +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-2147483647 months -2147483647 days -9223372036854775807 us'::interval" +== 049 +-- truncate_limit: 100 +-- should fail + +-- Test intervals that are large enough to overflow 64 bits in comparisons +CREATE TEMP TABLE INTERVAL_TBL_OF (f1 interval) +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE interval_tbl_of (f1 interval)" +== 050 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL_OF (f1) VALUES + ('2147483647 days 2147483647 months'), + ('2147483647 days -2147483648 months'), + ('1 year'), + ('-2147483648 days 2147483647 months'), + ('-2147483648 days -2147483648 months') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl_of (f1) VALUES (...)" +== 051 +-- truncate_limit: 100 +-- these should fail as out-of-range +INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('2147483648 days') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl_of (f1) VALUES ('2147483648 days')" +== 052 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('-2147483649 days') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl_of (f1) VALUES ('-2147483649 days')" +== 053 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('2147483647 years') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl_of (f1) VALUES ('2147483647 years')" +== 054 +-- truncate_limit: 100 +INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('-2147483648 years') +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO interval_tbl_of (f1) VALUES ('-2147483648 years')" +== 055 +-- truncate_limit: 100 +-- Test edge-case overflow detection in interval multiplication +select extract(epoch from '256 microseconds'::interval * (2^55)::float8) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '256 microseconds'::interval * (2 ^ 55)::float8)" +== 056 +-- truncate_limit: 100 +SELECT r1.*, r2.* + FROM INTERVAL_TBL_OF r1, INTERVAL_TBL_OF r2 + WHERE r1.f1 > r2.f1 + ORDER BY r1.f1, r2.f1 +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +ALIAS: "r1"="interval_tbl_of" +ALIAS: "r2"="interval_tbl_of" +FILTER: schema="" table="r1" column="f1" +FILTER: schema="" table="r2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT r1.*, r2.* FROM interval_tbl_of r1, interval_tbl_of r2 WHERE ... ORDER BY r1.f1, r2.f1" +== 057 +-- truncate_limit: 100 +CREATE INDEX ON INTERVAL_TBL_OF USING btree (f1) +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON interval_tbl_of USING btree (f1)" +== 058 +-- truncate_limit: 100 +SET enable_seqscan TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO FALSE" +== 059 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT f1 FROM INTERVAL_TBL_OF r1 ORDER BY f1 +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +ALIAS: "r1"="interval_tbl_of" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT f1 FROM interval_tbl_of r1 ORDER BY f1" +== 060 +-- truncate_limit: 100 +SELECT f1 FROM INTERVAL_TBL_OF r1 ORDER BY f1 +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +ALIAS: "r1"="interval_tbl_of" +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM interval_tbl_of r1 ORDER BY f1" +== 061 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 062 +-- truncate_limit: 100 +-- subtracting about-to-overflow values should result in 0 +SELECT f1 - f1 FROM INTERVAL_TBL_OF +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 - f1 FROM interval_tbl_of" +== 063 +-- truncate_limit: 100 +DROP TABLE INTERVAL_TBL_OF +-- +TABLE: name="interval_tbl_of" schema="" table="interval_tbl_of" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE interval_tbl_of" +== 064 +-- truncate_limit: 100 +-- Test multiplication and division with intervals. +-- Floating point arithmetic rounding errors can lead to unexpected results, +-- though the code attempts to do the right thing and round up to days and +-- minutes to avoid results such as '3 days 24:00 hours' or '14:20:60'. +-- Note that it is expected for some day components to be greater than 29 and +-- some time components be greater than 23:59:59 due to how intervals are +-- stored internally. + +CREATE TABLE INTERVAL_MULDIV_TBL (span interval) +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE interval_muldiv_tbl (span interval)" +== 065 +-- truncate_limit: 100 +COPY INTERVAL_MULDIV_TBL FROM STDIN +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY interval_muldiv_tbl FROM STDIN" +== 066 +-- truncate_limit: 100 +SELECT span * 0.3 AS product +FROM INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT span * 0.3 AS product FROM interval_muldiv_tbl" +== 067 +-- truncate_limit: 100 +SELECT span * 8.2 AS product +FROM INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT span * 8.2 AS product FROM interval_muldiv_tbl" +== 068 +-- truncate_limit: 100 +SELECT span / 10 AS quotient +FROM INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT span / 10 AS quotient FROM interval_muldiv_tbl" +== 069 +-- truncate_limit: 100 +SELECT span / 100 AS quotient +FROM INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT span / 100 AS quotient FROM interval_muldiv_tbl" +== 070 +-- truncate_limit: 100 +DROP TABLE INTERVAL_MULDIV_TBL +-- +TABLE: name="interval_muldiv_tbl" schema="" table="interval_muldiv_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE interval_muldiv_tbl" +== 071 +-- truncate_limit: 100 +SET DATESTYLE = 'postgres' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO postgres" +== 072 +-- truncate_limit: 100 +SET IntervalStyle to postgres_verbose +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO postgres_verbose" +== 073 +-- truncate_limit: 100 +SELECT * FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM interval_tbl" +== 074 +-- truncate_limit: 100 +-- multiplication and division overflow test cases +SELECT '3000000 months'::interval * 1000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3000000 months'::interval * 1000" +== 075 +-- truncate_limit: 100 +SELECT '3000000 months'::interval / 0.001 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3000000 months'::interval / 0.001" +== 076 +-- truncate_limit: 100 +SELECT '3000000 days'::interval * 1000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3000000 days'::interval * 1000" +== 077 +-- truncate_limit: 100 +SELECT '3000000 days'::interval / 0.001 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3000000 days'::interval / 0.001" +== 078 +-- truncate_limit: 100 +SELECT '1 month 2146410 days'::interval * 1000.5002 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 month 2146410 days'::interval * 1000.5002" +== 079 +-- truncate_limit: 100 +SELECT '4611686018427387904 usec'::interval / 0.1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4611686018427387904 usec'::interval / 0.1" +== 080 +-- truncate_limit: 100 +-- test avg(interval), which is somewhat fragile since people have been +-- known to change the allowed input syntax for type interval without +-- updating pg_aggregate.agginitval + +select avg(f1) from interval_tbl where isfinite(f1) +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT avg(f1) FROM interval_tbl WHERE isfinite(f1)" +== 081 +-- truncate_limit: 100 +-- test long interval input +select '4 millenniums 5 centuries 4 decades 1 year 4 months 4 days 17 minutes 31 seconds'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4 millenniums 5 centuries 4 decades 1 year 4 months 4 days 17 minutes 31 seconds'::interval" +== 082 +-- truncate_limit: 100 +-- test long interval output +-- Note: the actual maximum length of the interval output is longer, +-- but we need the test to work for both integer and floating-point +-- timestamps. +select '100000000y 10mon -1000000000d -100000h -10min -10.000001s ago'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100000000y 10mon -1000000000d -100000h -10min -10.000001s ago'::interval" +== 083 +-- truncate_limit: 100 +-- test justify_hours() and justify_days() + +SELECT justify_hours(interval '6 months 3 days 52 hours 3 minutes 2 seconds') as "6 mons 5 days 4 hours 3 mins 2 seconds" +-- +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 084 +-- truncate_limit: 100 +SELECT justify_days(interval '6 months 36 days 5 hours 4 minutes 3 seconds') as "7 mons 6 days 5 hours 4 mins 3 seconds" +-- +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 085 +-- truncate_limit: 100 +SELECT justify_hours(interval '2147483647 days 24 hrs') +-- +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_hours('2147483647 days 24 hrs'::interval)" +== 086 +-- truncate_limit: 100 +SELECT justify_days(interval '2147483647 months 30 days') +-- +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_days('2147483647 months 30 days'::interval)" +== 087 +-- truncate_limit: 100 +-- test justify_interval() + +SELECT justify_interval(interval '1 month -1 hour') as "1 month -1 hour" +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('1 month -1 hour'::interval) AS \"1 month -1 hour\"" +== 088 +-- truncate_limit: 100 +SELECT justify_interval(interval '2147483647 days 24 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('2147483647 days 24 hrs'::interval)" +== 089 +-- truncate_limit: 100 +SELECT justify_interval(interval '-2147483648 days -24 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('-2147483648 days -24 hrs'::interval)" +== 090 +-- truncate_limit: 100 +SELECT justify_interval(interval '2147483647 months 30 days') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('2147483647 months 30 days'::interval)" +== 091 +-- truncate_limit: 100 +SELECT justify_interval(interval '-2147483648 months -30 days') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('-2147483648 months -30 days'::interval)" +== 092 +-- truncate_limit: 100 +SELECT justify_interval(interval '2147483647 months 30 days -24 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('2147483647 months 30 days -24 hrs'::interval)" +== 093 +-- truncate_limit: 100 +SELECT justify_interval(interval '-2147483648 months -30 days 24 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('-2147483648 months -30 days 24 hrs'::interval)" +== 094 +-- truncate_limit: 100 +SELECT justify_interval(interval '2147483647 months -30 days 1440 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('2147483647 months -30 days 1440 hrs'::interval)" +== 095 +-- truncate_limit: 100 +SELECT justify_interval(interval '-2147483648 months 30 days -1440 hrs') +-- +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT justify_interval('-2147483648 months 30 days -1440 hrs'::interval)" +== 096 +-- truncate_limit: 100 +-- test fractional second input, and detection of duplicate units +SET DATESTYLE = 'ISO' +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO \"ISO\"" +== 097 +-- truncate_limit: 100 +SET IntervalStyle TO postgres +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO postgres" +== 098 +-- truncate_limit: 100 +SELECT '1 millisecond'::interval, '1 microsecond'::interval, + '500 seconds 99 milliseconds 51 microseconds'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 099 +-- truncate_limit: 100 +SELECT '3 days 5 milliseconds'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3 days 5 milliseconds'::interval" +== 100 +-- truncate_limit: 100 +SELECT '1 second 2 seconds'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 second 2 seconds'::interval" +== 101 +-- truncate_limit: 100 +-- error +SELECT '10 milliseconds 20 milliseconds'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT '10 milliseconds 20 milliseconds'::interval" +== 102 +-- truncate_limit: 100 +-- error +SELECT '5.5 seconds 3 milliseconds'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT '5.5 seconds 3 milliseconds'::interval" +== 103 +-- truncate_limit: 100 +-- error +SELECT '1:20:05 5 microseconds'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1:20:05 5 microseconds'::interval" +== 104 +-- truncate_limit: 100 +-- error +SELECT '1 day 1 day'::interval +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 day 1 day'::interval" +== 105 +-- truncate_limit: 100 +-- error +SELECT interval '1-2' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1-2'::interval" +== 106 +-- truncate_limit: 100 +-- SQL year-month literal +SELECT interval '999' second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '999'::interval second" +== 107 +-- truncate_limit: 100 +-- oversize leading field is ok +SELECT interval '999' minute +-- +STMT: SelectStmt +TRUNCATED: "SELECT '999'::interval minute" +== 108 +-- truncate_limit: 100 +SELECT interval '999' hour +-- +STMT: SelectStmt +TRUNCATED: "SELECT '999'::interval hour" +== 109 +-- truncate_limit: 100 +SELECT interval '999' day +-- +STMT: SelectStmt +TRUNCATED: "SELECT '999'::interval day" +== 110 +-- truncate_limit: 100 +SELECT interval '999' month +-- +STMT: SelectStmt +TRUNCATED: "SELECT '999'::interval month" +== 111 +-- truncate_limit: 100 +-- test SQL-spec syntaxes for restricted field sets +SELECT interval '1' year +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::interval year" +== 112 +-- truncate_limit: 100 +SELECT interval '2' month +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2'::interval month" +== 113 +-- truncate_limit: 100 +SELECT interval '3' day +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3'::interval day" +== 114 +-- truncate_limit: 100 +SELECT interval '4' hour +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4'::interval hour" +== 115 +-- truncate_limit: 100 +SELECT interval '5' minute +-- +STMT: SelectStmt +TRUNCATED: "SELECT '5'::interval minute" +== 116 +-- truncate_limit: 100 +SELECT interval '6' second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '6'::interval second" +== 117 +-- truncate_limit: 100 +SELECT interval '1' year to month +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::interval year to month" +== 118 +-- truncate_limit: 100 +SELECT interval '1-2' year to month +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1-2'::interval year to month" +== 119 +-- truncate_limit: 100 +SELECT interval '1 2' day to hour +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2'::interval day to hour" +== 120 +-- truncate_limit: 100 +SELECT interval '1 2:03' day to hour +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03'::interval day to hour" +== 121 +-- truncate_limit: 100 +SELECT interval '1 2:03:04' day to hour +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04'::interval day to hour" +== 122 +-- truncate_limit: 100 +SELECT interval '1 2' day to minute +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2'::interval day to minute" +== 123 +-- truncate_limit: 100 +SELECT interval '1 2:03' day to minute +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03'::interval day to minute" +== 124 +-- truncate_limit: 100 +SELECT interval '1 2:03:04' day to minute +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04'::interval day to minute" +== 125 +-- truncate_limit: 100 +SELECT interval '1 2' day to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2'::interval day to second" +== 126 +-- truncate_limit: 100 +SELECT interval '1 2:03' day to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03'::interval day to second" +== 127 +-- truncate_limit: 100 +SELECT interval '1 2:03:04' day to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04'::interval day to second" +== 128 +-- truncate_limit: 100 +SELECT interval '1 2' hour to minute +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2'::interval hour to minute" +== 129 +-- truncate_limit: 100 +SELECT interval '1 2:03' hour to minute +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03'::interval hour to minute" +== 130 +-- truncate_limit: 100 +SELECT interval '1 2:03:04' hour to minute +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04'::interval hour to minute" +== 131 +-- truncate_limit: 100 +SELECT interval '1 2' hour to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2'::interval hour to second" +== 132 +-- truncate_limit: 100 +SELECT interval '1 2:03' hour to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03'::interval hour to second" +== 133 +-- truncate_limit: 100 +SELECT interval '1 2:03:04' hour to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04'::interval hour to second" +== 134 +-- truncate_limit: 100 +SELECT interval '1 2' minute to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2'::interval minute to second" +== 135 +-- truncate_limit: 100 +SELECT interval '1 2:03' minute to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03'::interval minute to second" +== 136 +-- truncate_limit: 100 +SELECT interval '1 2:03:04' minute to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04'::interval minute to second" +== 137 +-- truncate_limit: 100 +SELECT interval '1 +2:03' minute to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 +2:03'::interval minute to second" +== 138 +-- truncate_limit: 100 +SELECT interval '1 +2:03:04' minute to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 +2:03:04'::interval minute to second" +== 139 +-- truncate_limit: 100 +SELECT interval '1 -2:03' minute to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 -2:03'::interval minute to second" +== 140 +-- truncate_limit: 100 +SELECT interval '1 -2:03:04' minute to second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 -2:03:04'::interval minute to second" +== 141 +-- truncate_limit: 100 +SELECT interval '123 11' day to hour +-- +STMT: SelectStmt +TRUNCATED: "SELECT '123 11'::interval day to hour" +== 142 +-- truncate_limit: 100 +-- ok +SELECT interval '123 11' day +-- +STMT: SelectStmt +TRUNCATED: "SELECT '123 11'::interval day" +== 143 +-- truncate_limit: 100 +-- not ok +SELECT interval '123 11' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '123 11'::interval" +== 144 +-- truncate_limit: 100 +-- not ok, too ambiguous +SELECT interval '123 2:03 -2:04' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '123 2:03 -2:04'::interval" +== 145 +-- truncate_limit: 100 +-- not ok, redundant hh:mm fields + +-- test syntaxes for restricted precision +SELECT interval(0) '1 day 01:23:45.6789' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 day 01:23:45.6789'::interval(0)" +== 146 +-- truncate_limit: 100 +SELECT interval(2) '1 day 01:23:45.6789' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 day 01:23:45.6789'::interval(2)" +== 147 +-- truncate_limit: 100 +SELECT interval '12:34.5678' minute to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:34.5678'::interval minute to second(2)" +== 148 +-- truncate_limit: 100 +-- per SQL spec +SELECT interval '1.234' second +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.234'::interval second" +== 149 +-- truncate_limit: 100 +SELECT interval '1.234' second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.234'::interval second(2)" +== 150 +-- truncate_limit: 100 +SELECT interval '1 2.345' day to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2.345'::interval day to second(2)" +== 151 +-- truncate_limit: 100 +SELECT interval '1 2:03' day to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03'::interval day to second(2)" +== 152 +-- truncate_limit: 100 +SELECT interval '1 2:03.4567' day to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03.4567'::interval day to second(2)" +== 153 +-- truncate_limit: 100 +SELECT interval '1 2:03:04.5678' day to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04.5678'::interval day to second(2)" +== 154 +-- truncate_limit: 100 +SELECT interval '1 2.345' hour to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2.345'::interval hour to second(2)" +== 155 +-- truncate_limit: 100 +SELECT interval '1 2:03.45678' hour to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03.45678'::interval hour to second(2)" +== 156 +-- truncate_limit: 100 +SELECT interval '1 2:03:04.5678' hour to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04.5678'::interval hour to second(2)" +== 157 +-- truncate_limit: 100 +SELECT interval '1 2.3456' minute to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2.3456'::interval minute to second(2)" +== 158 +-- truncate_limit: 100 +SELECT interval '1 2:03.5678' minute to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03.5678'::interval minute to second(2)" +== 159 +-- truncate_limit: 100 +SELECT interval '1 2:03:04.5678' minute to second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2:03:04.5678'::interval minute to second(2)" +== 160 +-- truncate_limit: 100 +SELECT interval '2562047788:00:54.775807' second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2562047788:00:54.775807'::interval second(2)" +== 161 +-- truncate_limit: 100 +-- out of range +SELECT interval '-2562047788:00:54.775807' second(2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2562047788:00:54.775807'::interval second(2)" +== 162 +-- truncate_limit: 100 +-- out of range + +-- test casting to restricted precision (bug #14479) +SELECT f1, f1::INTERVAL DAY TO MINUTE AS "minutes", + (f1 + INTERVAL '1 month')::INTERVAL MONTH::INTERVAL YEAR AS "years" + FROM interval_tbl +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM interval_tbl" +== 163 +-- truncate_limit: 100 +-- test inputting and outputting SQL standard interval literals +SET IntervalStyle TO sql_standard +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO sql_standard" +== 164 +-- truncate_limit: 100 +SELECT interval '0' AS "zero", + interval '1-2' year to month AS "year-month", + interval '1 2:03:04' day to second AS "day-time", + - interval '1-2' AS "negative year-month", + - interval '1 2:03:04' AS "negative day-time" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 165 +-- truncate_limit: 100 +-- test input of some not-quite-standard interval values in the sql style +SET IntervalStyle TO postgres +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO postgres" +== 166 +-- truncate_limit: 100 +SELECT interval '+1 -1:00:00', + interval '-1 +1:00:00', + interval '+1-2 -3 +4:05:06.789', + interval '-1-2 +3 -4:05:06.789' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 167 +-- truncate_limit: 100 +-- cases that trigger sign-matching rules in the sql style +SELECT interval '-23 hours 45 min 12.34 sec', + interval '-1 day 23 hours 45 min 12.34 sec', + interval '-1 year 2 months 1 day 23 hours 45 min 12.34 sec', + interval '-1 year 2 months 1 day 23 hours 45 min +12.34 sec' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 168 +-- truncate_limit: 100 +-- test output of couple non-standard interval values in the sql style +SET IntervalStyle TO sql_standard +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO sql_standard" +== 169 +-- truncate_limit: 100 +SELECT interval '1 day -1 hours', + interval '-1 days +1 hours', + interval '1 years 2 months -3 days 4 hours 5 minutes 6.789 seconds', + - interval '1 years 2 months -3 days 4 hours 5 minutes 6.789 seconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 170 +-- truncate_limit: 100 +-- cases that trigger sign-matching rules in the sql style +SELECT interval '-23 hours 45 min 12.34 sec', + interval '-1 day 23 hours 45 min 12.34 sec', + interval '-1 year 2 months 1 day 23 hours 45 min 12.34 sec', + interval '-1 year 2 months 1 day 23 hours 45 min +12.34 sec' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 171 +-- truncate_limit: 100 +-- edge case for sign-matching rules +SELECT interval '' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::interval" +== 172 +-- truncate_limit: 100 +-- error + +-- test outputting iso8601 intervals +SET IntervalStyle to iso_8601 +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO iso_8601" +== 173 +-- truncate_limit: 100 +select interval '0' AS "zero", + interval '1-2' AS "a year 2 months", + interval '1 2:03:04' AS "a bit over a day", + interval '2:03:04.45679' AS "a bit over 2 hours", + (interval '1-2' + interval '3 4:05:06.7') AS "all fields", + (interval '1-2' - interval '3 4:05:06.7') AS "mixed sign", + (- interval '1-2' + interval '3 4:05:06.7') AS "negative" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 174 +-- truncate_limit: 100 +-- test inputting ISO 8601 4.4.2.1 "Format With Time Unit Designators" +SET IntervalStyle to sql_standard +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO sql_standard" +== 175 +-- truncate_limit: 100 +select interval 'P0Y' AS "zero", + interval 'P1Y2M' AS "a year 2 months", + interval 'P1W' AS "a week", + interval 'P1DT2H3M4S' AS "a bit over a day", + interval 'P1Y2M3DT4H5M6.7S' AS "all fields", + interval 'P-1Y-2M-3DT-4H-5M-6.7S' AS "negative", + interval 'PT-0.1S' AS "fractional second" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 176 +-- truncate_limit: 100 +-- test inputting ISO 8601 4.4.2.2 "Alternative Format" +SET IntervalStyle to postgres +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO postgres" +== 177 +-- truncate_limit: 100 +select interval 'P00021015T103020' AS "ISO8601 Basic Format", + interval 'P0002-10-15T10:30:20' AS "ISO8601 Extended Format" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 178 +-- truncate_limit: 100 +-- Make sure optional ISO8601 alternative format fields are optional. +select interval 'P0002' AS "year only", + interval 'P0002-10' AS "year month", + interval 'P0002-10-15' AS "year month day", + interval 'P0002T1S' AS "year only plus time", + interval 'P0002-10T1S' AS "year month plus time", + interval 'P0002-10-15T1S' AS "year month day plus time", + interval 'PT10' AS "hour only", + interval 'PT10:30' AS "hour minute" +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 179 +-- truncate_limit: 100 +-- Check handling of fractional fields in ISO8601 format. +select interval 'P1Y0M3DT4H5M6S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P1Y0M3DT4H5M6S'::interval" +== 180 +-- truncate_limit: 100 +select interval 'P1.0Y0M3DT4H5M6S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P1.0Y0M3DT4H5M6S'::interval" +== 181 +-- truncate_limit: 100 +select interval 'P1.1Y0M3DT4H5M6S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P1.1Y0M3DT4H5M6S'::interval" +== 182 +-- truncate_limit: 100 +select interval 'P1.Y0M3DT4H5M6S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P1.Y0M3DT4H5M6S'::interval" +== 183 +-- truncate_limit: 100 +select interval 'P.1Y0M3DT4H5M6S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P.1Y0M3DT4H5M6S'::interval" +== 184 +-- truncate_limit: 100 +select interval 'P10.5e4Y' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P10.5e4Y'::interval" +== 185 +-- truncate_limit: 100 +-- not per spec, but we've historically taken it +select interval 'P.Y0M3DT4H5M6S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P.Y0M3DT4H5M6S'::interval" +== 186 +-- truncate_limit: 100 +-- error + +-- test a couple rounding cases that changed since 8.3 w/ HAVE_INT64_TIMESTAMP. +SET IntervalStyle to postgres_verbose +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO postgres_verbose" +== 187 +-- truncate_limit: 100 +select interval '-10 mons -3 days +03:55:06.70' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-10 mons -3 days +03:55:06.70'::interval" +== 188 +-- truncate_limit: 100 +select interval '1 year 2 mons 3 days 04:05:06.699999' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 year 2 mons 3 days 04:05:06.699999'::interval" +== 189 +-- truncate_limit: 100 +select interval '0:0:0.7', interval '@ 0.70 secs', interval '0.7 seconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0:0:0.7'::interval, '@ 0.70 secs'::interval, '0.7 seconds'::interval" +== 190 +-- truncate_limit: 100 +-- test time fields using entire 64 bit microseconds range +select interval '2562047788.01521550194 hours' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2562047788.01521550194 hours'::interval" +== 191 +-- truncate_limit: 100 +select interval '-2562047788.01521550222 hours' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2562047788.01521550222 hours'::interval" +== 192 +-- truncate_limit: 100 +select interval '153722867280.912930117 minutes' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '153722867280.912930117 minutes'::interval" +== 193 +-- truncate_limit: 100 +select interval '-153722867280.912930133 minutes' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-153722867280.912930133 minutes'::interval" +== 194 +-- truncate_limit: 100 +select interval '9223372036854.775807 seconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854.775807 seconds'::interval" +== 195 +-- truncate_limit: 100 +select interval '-9223372036854.775808 seconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854.775808 seconds'::interval" +== 196 +-- truncate_limit: 100 +select interval '9223372036854775.807 milliseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775.807 milliseconds'::interval" +== 197 +-- truncate_limit: 100 +select interval '-9223372036854775.808 milliseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775.808 milliseconds'::interval" +== 198 +-- truncate_limit: 100 +select interval '9223372036854775807 microseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775807 microseconds'::interval" +== 199 +-- truncate_limit: 100 +select interval '-9223372036854775808 microseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808 microseconds'::interval" +== 200 +-- truncate_limit: 100 +select interval 'PT2562047788H54.775807S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT2562047788H54.775807S'::interval" +== 201 +-- truncate_limit: 100 +select interval 'PT-2562047788H-54.775808S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT-2562047788H-54.775808S'::interval" +== 202 +-- truncate_limit: 100 +select interval 'PT2562047788:00:54.775807' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT2562047788:00:54.775807'::interval" +== 203 +-- truncate_limit: 100 +select interval 'PT2562047788.0152155019444' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT2562047788.0152155019444'::interval" +== 204 +-- truncate_limit: 100 +select interval 'PT-2562047788.0152155022222' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT-2562047788.0152155022222'::interval" +== 205 +-- truncate_limit: 100 +-- overflow each date/time field +select interval '2147483648 years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483648 years'::interval" +== 206 +-- truncate_limit: 100 +select interval '-2147483649 years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483649 years'::interval" +== 207 +-- truncate_limit: 100 +select interval '2147483648 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483648 months'::interval" +== 208 +-- truncate_limit: 100 +select interval '-2147483649 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483649 months'::interval" +== 209 +-- truncate_limit: 100 +select interval '2147483648 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483648 days'::interval" +== 210 +-- truncate_limit: 100 +select interval '-2147483649 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483649 days'::interval" +== 211 +-- truncate_limit: 100 +select interval '2562047789 hours' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2562047789 hours'::interval" +== 212 +-- truncate_limit: 100 +select interval '-2562047789 hours' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2562047789 hours'::interval" +== 213 +-- truncate_limit: 100 +select interval '153722867281 minutes' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '153722867281 minutes'::interval" +== 214 +-- truncate_limit: 100 +select interval '-153722867281 minutes' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-153722867281 minutes'::interval" +== 215 +-- truncate_limit: 100 +select interval '9223372036855 seconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036855 seconds'::interval" +== 216 +-- truncate_limit: 100 +select interval '-9223372036855 seconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036855 seconds'::interval" +== 217 +-- truncate_limit: 100 +select interval '9223372036854777 millisecond' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854777 millisecond'::interval" +== 218 +-- truncate_limit: 100 +select interval '-9223372036854777 millisecond' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854777 millisecond'::interval" +== 219 +-- truncate_limit: 100 +select interval '9223372036854775808 microsecond' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775808 microsecond'::interval" +== 220 +-- truncate_limit: 100 +select interval '-9223372036854775809 microsecond' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775809 microsecond'::interval" +== 221 +-- truncate_limit: 100 +select interval 'P2147483648' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P2147483648'::interval" +== 222 +-- truncate_limit: 100 +select interval 'P-2147483649' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-2147483649'::interval" +== 223 +-- truncate_limit: 100 +select interval 'P1-2147483647-2147483647' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P1-2147483647-2147483647'::interval" +== 224 +-- truncate_limit: 100 +select interval 'PT2562047789' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT2562047789'::interval" +== 225 +-- truncate_limit: 100 +select interval 'PT-2562047789' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT-2562047789'::interval" +== 226 +-- truncate_limit: 100 +-- overflow with date/time unit aliases +select interval '2147483647 weeks' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 weeks'::interval" +== 227 +-- truncate_limit: 100 +select interval '-2147483648 weeks' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 weeks'::interval" +== 228 +-- truncate_limit: 100 +select interval '2147483647 decades' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 decades'::interval" +== 229 +-- truncate_limit: 100 +select interval '-2147483648 decades' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 decades'::interval" +== 230 +-- truncate_limit: 100 +select interval '2147483647 centuries' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 centuries'::interval" +== 231 +-- truncate_limit: 100 +select interval '-2147483648 centuries' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 centuries'::interval" +== 232 +-- truncate_limit: 100 +select interval '2147483647 millennium' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 millennium'::interval" +== 233 +-- truncate_limit: 100 +select interval '-2147483648 millennium' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 millennium'::interval" +== 234 +-- truncate_limit: 100 +select interval '1 week 2147483647 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 week 2147483647 days'::interval" +== 235 +-- truncate_limit: 100 +select interval '-1 week -2147483648 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1 week -2147483648 days'::interval" +== 236 +-- truncate_limit: 100 +select interval '2147483647 days 1 week' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 days 1 week'::interval" +== 237 +-- truncate_limit: 100 +select interval '-2147483648 days -1 week' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 days -1 week'::interval" +== 238 +-- truncate_limit: 100 +select interval 'P1W2147483647D' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P1W2147483647D'::interval" +== 239 +-- truncate_limit: 100 +select interval 'P-1W-2147483648D' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-1W-2147483648D'::interval" +== 240 +-- truncate_limit: 100 +select interval 'P2147483647D1W' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P2147483647D1W'::interval" +== 241 +-- truncate_limit: 100 +select interval 'P-2147483648D-1W' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-2147483648D-1W'::interval" +== 242 +-- truncate_limit: 100 +select interval '1 decade 2147483647 years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 decade 2147483647 years'::interval" +== 243 +-- truncate_limit: 100 +select interval '1 century 2147483647 years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 century 2147483647 years'::interval" +== 244 +-- truncate_limit: 100 +select interval '1 millennium 2147483647 years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 millennium 2147483647 years'::interval" +== 245 +-- truncate_limit: 100 +select interval '-1 decade -2147483648 years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1 decade -2147483648 years'::interval" +== 246 +-- truncate_limit: 100 +select interval '-1 century -2147483648 years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1 century -2147483648 years'::interval" +== 247 +-- truncate_limit: 100 +select interval '-1 millennium -2147483648 years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1 millennium -2147483648 years'::interval" +== 248 +-- truncate_limit: 100 +select interval '2147483647 years 1 decade' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 years 1 decade'::interval" +== 249 +-- truncate_limit: 100 +select interval '2147483647 years 1 century' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 years 1 century'::interval" +== 250 +-- truncate_limit: 100 +select interval '2147483647 years 1 millennium' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 years 1 millennium'::interval" +== 251 +-- truncate_limit: 100 +select interval '-2147483648 years -1 decade' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 years -1 decade'::interval" +== 252 +-- truncate_limit: 100 +select interval '-2147483648 years -1 century' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 years -1 century'::interval" +== 253 +-- truncate_limit: 100 +select interval '-2147483648 years -1 millennium' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 years -1 millennium'::interval" +== 254 +-- truncate_limit: 100 +-- overflowing with fractional fields - postgres format +select interval '0.1 millennium 2147483647 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 millennium 2147483647 months'::interval" +== 255 +-- truncate_limit: 100 +select interval '0.1 centuries 2147483647 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 centuries 2147483647 months'::interval" +== 256 +-- truncate_limit: 100 +select interval '0.1 decades 2147483647 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 decades 2147483647 months'::interval" +== 257 +-- truncate_limit: 100 +select interval '0.1 yrs 2147483647 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 yrs 2147483647 months'::interval" +== 258 +-- truncate_limit: 100 +select interval '-0.1 millennium -2147483648 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.1 millennium -2147483648 months'::interval" +== 259 +-- truncate_limit: 100 +select interval '-0.1 centuries -2147483648 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.1 centuries -2147483648 months'::interval" +== 260 +-- truncate_limit: 100 +select interval '-0.1 decades -2147483648 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.1 decades -2147483648 months'::interval" +== 261 +-- truncate_limit: 100 +select interval '-0.1 yrs -2147483648 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.1 yrs -2147483648 months'::interval" +== 262 +-- truncate_limit: 100 +select interval '2147483647 months 0.1 millennium' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 months 0.1 millennium'::interval" +== 263 +-- truncate_limit: 100 +select interval '2147483647 months 0.1 centuries' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 months 0.1 centuries'::interval" +== 264 +-- truncate_limit: 100 +select interval '2147483647 months 0.1 decades' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 months 0.1 decades'::interval" +== 265 +-- truncate_limit: 100 +select interval '2147483647 months 0.1 yrs' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 months 0.1 yrs'::interval" +== 266 +-- truncate_limit: 100 +select interval '-2147483648 months -0.1 millennium' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 months -0.1 millennium'::interval" +== 267 +-- truncate_limit: 100 +select interval '-2147483648 months -0.1 centuries' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 months -0.1 centuries'::interval" +== 268 +-- truncate_limit: 100 +select interval '-2147483648 months -0.1 decades' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 months -0.1 decades'::interval" +== 269 +-- truncate_limit: 100 +select interval '-2147483648 months -0.1 yrs' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 months -0.1 yrs'::interval" +== 270 +-- truncate_limit: 100 +select interval '0.1 months 2147483647 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 months 2147483647 days'::interval" +== 271 +-- truncate_limit: 100 +select interval '-0.1 months -2147483648 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.1 months -2147483648 days'::interval" +== 272 +-- truncate_limit: 100 +select interval '2147483647 days 0.1 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 days 0.1 months'::interval" +== 273 +-- truncate_limit: 100 +select interval '-2147483648 days -0.1 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 days -0.1 months'::interval" +== 274 +-- truncate_limit: 100 +select interval '0.5 weeks 2147483647 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.5 weeks 2147483647 days'::interval" +== 275 +-- truncate_limit: 100 +select interval '-0.5 weeks -2147483648 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.5 weeks -2147483648 days'::interval" +== 276 +-- truncate_limit: 100 +select interval '2147483647 days 0.5 weeks' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 days 0.5 weeks'::interval" +== 277 +-- truncate_limit: 100 +select interval '-2147483648 days -0.5 weeks' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 days -0.5 weeks'::interval" +== 278 +-- truncate_limit: 100 +select interval '0.01 months 9223372036854775807 microseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.01 months 9223372036854775807 microseconds'::interval" +== 279 +-- truncate_limit: 100 +select interval '-0.01 months -9223372036854775808 microseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.01 months -9223372036854775808 microseconds'::interval" +== 280 +-- truncate_limit: 100 +select interval '9223372036854775807 microseconds 0.01 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775807 microseconds 0.01 months'::interval" +== 281 +-- truncate_limit: 100 +select interval '-9223372036854775808 microseconds -0.01 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808 microseconds -0.01 months'::interval" +== 282 +-- truncate_limit: 100 +select interval '0.1 weeks 9223372036854775807 microseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 weeks 9223372036854775807 microseconds'::interval" +== 283 +-- truncate_limit: 100 +select interval '-0.1 weeks -9223372036854775808 microseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.1 weeks -9223372036854775808 microseconds'::interval" +== 284 +-- truncate_limit: 100 +select interval '9223372036854775807 microseconds 0.1 weeks' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775807 microseconds 0.1 weeks'::interval" +== 285 +-- truncate_limit: 100 +select interval '-9223372036854775808 microseconds -0.1 weeks' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808 microseconds -0.1 weeks'::interval" +== 286 +-- truncate_limit: 100 +select interval '0.1 days 9223372036854775807 microseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 days 9223372036854775807 microseconds'::interval" +== 287 +-- truncate_limit: 100 +select interval '-0.1 days -9223372036854775808 microseconds' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-0.1 days -9223372036854775808 microseconds'::interval" +== 288 +-- truncate_limit: 100 +select interval '9223372036854775807 microseconds 0.1 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775807 microseconds 0.1 days'::interval" +== 289 +-- truncate_limit: 100 +select interval '-9223372036854775808 microseconds -0.1 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808 microseconds -0.1 days'::interval" +== 290 +-- truncate_limit: 100 +-- overflowing with fractional fields - ISO8601 format +select interval 'P0.1Y2147483647M' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P0.1Y2147483647M'::interval" +== 291 +-- truncate_limit: 100 +select interval 'P-0.1Y-2147483648M' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-0.1Y-2147483648M'::interval" +== 292 +-- truncate_limit: 100 +select interval 'P2147483647M0.1Y' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P2147483647M0.1Y'::interval" +== 293 +-- truncate_limit: 100 +select interval 'P-2147483648M-0.1Y' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-2147483648M-0.1Y'::interval" +== 294 +-- truncate_limit: 100 +select interval 'P0.1M2147483647D' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P0.1M2147483647D'::interval" +== 295 +-- truncate_limit: 100 +select interval 'P-0.1M-2147483648D' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-0.1M-2147483648D'::interval" +== 296 +-- truncate_limit: 100 +select interval 'P2147483647D0.1M' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P2147483647D0.1M'::interval" +== 297 +-- truncate_limit: 100 +select interval 'P-2147483648D-0.1M' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-2147483648D-0.1M'::interval" +== 298 +-- truncate_limit: 100 +select interval 'P0.5W2147483647D' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P0.5W2147483647D'::interval" +== 299 +-- truncate_limit: 100 +select interval 'P-0.5W-2147483648D' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-0.5W-2147483648D'::interval" +== 300 +-- truncate_limit: 100 +select interval 'P2147483647D0.5W' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P2147483647D0.5W'::interval" +== 301 +-- truncate_limit: 100 +select interval 'P-2147483648D-0.5W' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-2147483648D-0.5W'::interval" +== 302 +-- truncate_limit: 100 +select interval 'P0.01MT2562047788H54.775807S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P0.01MT2562047788H54.775807S'::interval" +== 303 +-- truncate_limit: 100 +select interval 'P-0.01MT-2562047788H-54.775808S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-0.01MT-2562047788H-54.775808S'::interval" +== 304 +-- truncate_limit: 100 +select interval 'P0.1DT2562047788H54.775807S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P0.1DT2562047788H54.775807S'::interval" +== 305 +-- truncate_limit: 100 +select interval 'P-0.1DT-2562047788H-54.775808S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P-0.1DT-2562047788H-54.775808S'::interval" +== 306 +-- truncate_limit: 100 +select interval 'PT2562047788.1H54.775807S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT2562047788.1H54.775807S'::interval" +== 307 +-- truncate_limit: 100 +select interval 'PT-2562047788.1H-54.775808S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT-2562047788.1H-54.775808S'::interval" +== 308 +-- truncate_limit: 100 +select interval 'PT2562047788H0.1M54.775807S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT2562047788H0.1M54.775807S'::interval" +== 309 +-- truncate_limit: 100 +select interval 'PT-2562047788H-0.1M-54.775808S' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT-2562047788H-0.1M-54.775808S'::interval" +== 310 +-- truncate_limit: 100 +-- overflowing with fractional fields - ISO8601 alternative format +select interval 'P0.1-2147483647-00' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P0.1-2147483647-00'::interval" +== 311 +-- truncate_limit: 100 +select interval 'P00-0.1-2147483647' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P00-0.1-2147483647'::interval" +== 312 +-- truncate_limit: 100 +select interval 'P00-0.01-00T2562047788:00:54.775807' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P00-0.01-00T2562047788:00:54.775807'::interval" +== 313 +-- truncate_limit: 100 +select interval 'P00-00-0.1T2562047788:00:54.775807' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'P00-00-0.1T2562047788:00:54.775807'::interval" +== 314 +-- truncate_limit: 100 +select interval 'PT2562047788.1:00:54.775807' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT2562047788.1:00:54.775807'::interval" +== 315 +-- truncate_limit: 100 +select interval 'PT2562047788:01.:54.775807' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'PT2562047788:01.:54.775807'::interval" +== 316 +-- truncate_limit: 100 +-- overflowing with fractional fields - SQL standard format +select interval '0.1 2562047788:0:54.775807' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 2562047788:0:54.775807'::interval" +== 317 +-- truncate_limit: 100 +select interval '0.1 2562047788:0:54.775808 ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1 2562047788:0:54.775808 ago'::interval" +== 318 +-- truncate_limit: 100 +select interval '2562047788.1:0:54.775807' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2562047788.1:0:54.775807'::interval" +== 319 +-- truncate_limit: 100 +select interval '2562047788.1:0:54.775808 ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2562047788.1:0:54.775808 ago'::interval" +== 320 +-- truncate_limit: 100 +select interval '2562047788:0.1:54.775807' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2562047788:0.1:54.775807'::interval" +== 321 +-- truncate_limit: 100 +select interval '2562047788:0.1:54.775808 ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2562047788:0.1:54.775808 ago'::interval" +== 322 +-- truncate_limit: 100 +-- overflowing using AGO with INT_MIN +select interval '-2147483648 months ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 months ago'::interval" +== 323 +-- truncate_limit: 100 +select interval '-2147483648 days ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 days ago'::interval" +== 324 +-- truncate_limit: 100 +select interval '-9223372036854775808 microseconds ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808 microseconds ago'::interval" +== 325 +-- truncate_limit: 100 +select interval '-2147483648 months -2147483648 days -9223372036854775808 microseconds ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 months -2147483648 days -9223372036854775808 microseconds ago'::interval" +== 326 +-- truncate_limit: 100 +-- overflowing using make_interval +select make_interval(years := 178956971) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(years := 178956971)" +== 327 +-- truncate_limit: 100 +select make_interval(years := -178956971) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(years := -178956971)" +== 328 +-- truncate_limit: 100 +select make_interval(years := 1, months := 2147483647) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(years := 1, months := 2147483647)" +== 329 +-- truncate_limit: 100 +select make_interval(years := -1, months := -2147483648) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(years := -1, months := -2147483648)" +== 330 +-- truncate_limit: 100 +select make_interval(weeks := 306783379) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(weeks := 306783379)" +== 331 +-- truncate_limit: 100 +select make_interval(weeks := -306783379) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(weeks := -306783379)" +== 332 +-- truncate_limit: 100 +select make_interval(weeks := 1, days := 2147483647) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(weeks := 1, days := 2147483647)" +== 333 +-- truncate_limit: 100 +select make_interval(weeks := -1, days := -2147483648) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(weeks := -1, days := -2147483648)" +== 334 +-- truncate_limit: 100 +select make_interval(secs := 1e308) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(secs := 1e308)" +== 335 +-- truncate_limit: 100 +select make_interval(secs := 1e18) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(secs := 1e18)" +== 336 +-- truncate_limit: 100 +select make_interval(secs := -1e18) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(secs := -1e18)" +== 337 +-- truncate_limit: 100 +select make_interval(mins := 1, secs := 9223372036800.0) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(mins := 1, secs := 9223372036800.0)" +== 338 +-- truncate_limit: 100 +select make_interval(mins := -1, secs := -9223372036800.0) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(mins := -1, secs := -9223372036800.0)" +== 339 +-- truncate_limit: 100 +-- test that INT_MIN number is formatted properly +SET IntervalStyle to postgres +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO postgres" +== 340 +-- truncate_limit: 100 +select interval '-2147483647 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483647 months -2147483648 days -9223372036854775808 us'::interval" +== 341 +-- truncate_limit: 100 +SET IntervalStyle to sql_standard +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO sql_standard" +== 342 +-- truncate_limit: 100 +select interval '-2147483647 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483647 months -2147483648 days -9223372036854775808 us'::interval" +== 343 +-- truncate_limit: 100 +SET IntervalStyle to iso_8601 +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO iso_8601" +== 344 +-- truncate_limit: 100 +select interval '-2147483647 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483647 months -2147483648 days -9223372036854775808 us'::interval" +== 345 +-- truncate_limit: 100 +SET IntervalStyle to postgres_verbose +-- +STMT: VariableSetStmt +TRUNCATED: "SET intervalstyle TO postgres_verbose" +== 346 +-- truncate_limit: 100 +select interval '-2147483647 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483647 months -2147483648 days -9223372036854775808 us'::interval" +== 347 +-- truncate_limit: 100 +-- check that '30 days' equals '1 month' according to the hash function +select '30 days'::interval = '1 month'::interval as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT '30 days'::interval = '1 month'::interval AS t" +== 348 +-- truncate_limit: 100 +select interval_hash('30 days'::interval) = interval_hash('1 month'::interval) as t +-- +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +FUNCTION: name="interval_hash" function="interval_hash" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT interval_hash('30 days'::interval) = interval_hash('1 month'::interval) AS t" +== 349 +-- truncate_limit: 100 +-- numeric constructor +select make_interval(years := 2) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(years := 2)" +== 350 +-- truncate_limit: 100 +select make_interval(years := 1, months := 6) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(years := 1, months := 6)" +== 351 +-- truncate_limit: 100 +select make_interval(years := 1, months := -1, weeks := 5, days := -7, hours := 25, mins := -180) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(years := 1, months := -1, weeks := 5, days := -7, hours := 25, mins := -180)" +== 352 +-- truncate_limit: 100 +select make_interval() = make_interval(years := 0, months := 0, weeks := 0, days := 0, mins := 0, secs := 0.0) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 353 +-- truncate_limit: 100 +select make_interval(hours := -2, mins := -10, secs := -25.3) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(hours := -2, mins := -10, secs := -25.3)" +== 354 +-- truncate_limit: 100 +select make_interval(years := 'inf'::float::int) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(years := 'inf'::double precision::int)" +== 355 +-- truncate_limit: 100 +select make_interval(months := 'NaN'::float::int) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(months := 'NaN'::double precision::int)" +== 356 +-- truncate_limit: 100 +select make_interval(secs := 'inf') +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(secs := 'inf')" +== 357 +-- truncate_limit: 100 +select make_interval(secs := 'NaN') +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(secs := 'NaN')" +== 358 +-- truncate_limit: 100 +select make_interval(secs := 7e12) +-- +FUNCTION: name="make_interval" function="make_interval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_interval(secs := 7e12)" +== 359 +-- truncate_limit: 100 +|-- +-- test EXTRACT +|-- +SELECT f1, + EXTRACT(MICROSECOND FROM f1) AS MICROSECOND, + EXTRACT(MILLISECOND FROM f1) AS MILLISECOND, + EXTRACT(SECOND FROM f1) AS SECOND, + EXTRACT(MINUTE FROM f1) AS MINUTE, + EXTRACT(HOUR FROM f1) AS HOUR, + EXTRACT(DAY FROM f1) AS DAY, + EXTRACT(MONTH FROM f1) AS MONTH, + EXTRACT(QUARTER FROM f1) AS QUARTER, + EXTRACT(YEAR FROM f1) AS YEAR, + EXTRACT(DECADE FROM f1) AS DECADE, + EXTRACT(CENTURY FROM f1) AS CENTURY, + EXTRACT(MILLENNIUM FROM f1) AS MILLENNIUM, + EXTRACT(EPOCH FROM f1) AS EPOCH + FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM interval_tbl" +== 360 +-- truncate_limit: 100 +SELECT EXTRACT(FORTNIGHT FROM INTERVAL '2 days') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('fortnight' FROM '2 days'::interval)" +== 361 +-- truncate_limit: 100 +-- error +SELECT EXTRACT(TIMEZONE FROM INTERVAL '2 days') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('timezone' FROM '2 days'::interval)" +== 362 +-- truncate_limit: 100 +-- error + +SELECT EXTRACT(DECADE FROM INTERVAL '100 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '100 y'::interval)" +== 363 +-- truncate_limit: 100 +SELECT EXTRACT(DECADE FROM INTERVAL '99 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '99 y'::interval)" +== 364 +-- truncate_limit: 100 +SELECT EXTRACT(DECADE FROM INTERVAL '-99 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '-99 y'::interval)" +== 365 +-- truncate_limit: 100 +SELECT EXTRACT(DECADE FROM INTERVAL '-100 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('decade' FROM '-100 y'::interval)" +== 366 +-- truncate_limit: 100 +SELECT EXTRACT(CENTURY FROM INTERVAL '100 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '100 y'::interval)" +== 367 +-- truncate_limit: 100 +SELECT EXTRACT(CENTURY FROM INTERVAL '99 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '99 y'::interval)" +== 368 +-- truncate_limit: 100 +SELECT EXTRACT(CENTURY FROM INTERVAL '-99 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '-99 y'::interval)" +== 369 +-- truncate_limit: 100 +SELECT EXTRACT(CENTURY FROM INTERVAL '-100 y') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('century' FROM '-100 y'::interval)" +== 370 +-- truncate_limit: 100 +-- date_part implementation is mostly the same as extract, so only +-- test a few cases for additional coverage. +SELECT f1, + date_part('microsecond', f1) AS microsecond, + date_part('millisecond', f1) AS millisecond, + date_part('second', f1) AS second, + date_part('epoch', f1) AS epoch + FROM INTERVAL_TBL +-- +TABLE: name="interval_tbl" schema="" table="interval_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM interval_tbl" +== 371 +-- truncate_limit: 100 +-- internal overflow test case +SELECT extract(epoch from interval '1000000000 days') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '1000000000 days'::interval)" +== 372 +-- truncate_limit: 100 +|-- +-- test infinite intervals +|-- + +-- largest finite intervals +SELECT interval '-2147483648 months -2147483648 days -9223372036854775807 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 months -2147483648 days -9223372036854775807 us'::interval" +== 373 +-- truncate_limit: 100 +SELECT interval '2147483647 months 2147483647 days 9223372036854775806 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 months 2147483647 days 9223372036854775806 us'::interval" +== 374 +-- truncate_limit: 100 +-- infinite intervals +SELECT interval '-2147483648 months -2147483648 days -9223372036854775808 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-2147483648 months -2147483648 days -9223372036854775808 us'::interval" +== 375 +-- truncate_limit: 100 +SELECT interval '2147483647 months 2147483647 days 9223372036854775807 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2147483647 months 2147483647 days 9223372036854775807 us'::interval" +== 376 +-- truncate_limit: 100 +CREATE TABLE INFINITE_INTERVAL_TBL (i interval) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE infinite_interval_tbl (i interval)" +== 377 +-- truncate_limit: 100 +INSERT INTO INFINITE_INTERVAL_TBL VALUES ('infinity'), ('-infinity'), ('1 year 2 days 3 hours') +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO infinite_interval_tbl VALUES ('infinity'), ('-infinity'), ('1 year 2 days 3 hours')" +== 378 +-- truncate_limit: 100 +SELECT i, isfinite(i) FROM INFINITE_INTERVAL_TBL +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i, isfinite(i) FROM infinite_interval_tbl" +== 379 +-- truncate_limit: 100 +-- test basic arithmetic +CREATE FUNCTION eval(expr text) +RETURNS text AS +$$ +DECLARE + result text; +BEGIN + EXECUTE 'select '||expr INTO result; + RETURN result; +EXCEPTION WHEN OTHERS THEN + RETURN SQLERRM; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="eval" function="eval" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION eval(expr text) RETURNS text AS $$\nDECLARE\n result text;\nBEGIN\n EXECUTE 'select..." +== 380 +-- truncate_limit: 100 +SELECT d AS date, i AS interval, + eval(format('date %L + interval %L', d, i)) AS plus, + eval(format('date %L - interval %L', d, i)) AS minus +FROM (VALUES (date '-infinity'), + (date '1995-08-06'), + (date 'infinity')) AS t1(d), + (VALUES (interval '-infinity'), + (interval 'infinity')) AS t2(i) +-- +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t1(d), (VALUES (...)) t2(i)" +== 381 +-- truncate_limit: 100 +SELECT i1 AS interval1, i2 AS interval2, + eval(format('interval %L + interval %L', i1, i2)) AS plus, + eval(format('interval %L - interval %L', i1, i2)) AS minus +FROM (VALUES (interval '-infinity'), + (interval '2 months'), + (interval 'infinity')) AS t1(i1), + (VALUES (interval '-infinity'), + (interval '10 days'), + (interval 'infinity')) AS t2(i2) +-- +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t1(i1), (VALUES (...)) t2(i2)" +== 382 +-- truncate_limit: 100 +SELECT interval '2147483646 months 2147483646 days 9223372036854775806 us' + interval '1 month 1 day 1 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 383 +-- truncate_limit: 100 +SELECT interval '-2147483647 months -2147483647 days -9223372036854775807 us' + interval '-1 month -1 day -1 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 384 +-- truncate_limit: 100 +SELECT interval '2147483646 months 2147483646 days 9223372036854775806 us' - interval '-1 month -1 day -1 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 385 +-- truncate_limit: 100 +SELECT interval '-2147483647 months -2147483647 days -9223372036854775807 us' - interval '1 month 1 day 1 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 386 +-- truncate_limit: 100 +SELECT t AS timestamp, i AS interval, + eval(format('timestamp %L + interval %L', t, i)) AS plus, + eval(format('timestamp %L - interval %L', t, i)) AS minus +FROM (VALUES (timestamp '-infinity'), + (timestamp '1995-08-06 12:30:15'), + (timestamp 'infinity')) AS t1(t), + (VALUES (interval '-infinity'), + (interval 'infinity')) AS t2(i) +-- +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t1(t), (VALUES (...)) t2(i)" +== 387 +-- truncate_limit: 100 +SELECT t AT TIME ZONE 'GMT' AS timestamptz, i AS interval, + eval(format('timestamptz %L + interval %L', t, i)) AS plus, + eval(format('timestamptz %L - interval %L', t, i)) AS minus +FROM (VALUES (timestamptz '-infinity'), + (timestamptz '1995-08-06 12:30:15 GMT'), + (timestamptz 'infinity')) AS t1(t), + (VALUES (interval '-infinity'), + (interval 'infinity')) AS t2(i) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="eval" function="eval" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t1(t), (VALUES (...)) t2(i)" +== 388 +-- truncate_limit: 100 +-- time +/- infinite interval not supported +SELECT time '11:27:42' + interval 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11:27:42'::time + 'infinity'::interval" +== 389 +-- truncate_limit: 100 +SELECT time '11:27:42' + interval '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11:27:42'::time + '-infinity'::interval" +== 390 +-- truncate_limit: 100 +SELECT time '11:27:42' - interval 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11:27:42'::time - 'infinity'::interval" +== 391 +-- truncate_limit: 100 +SELECT time '11:27:42' - interval '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11:27:42'::time - '-infinity'::interval" +== 392 +-- truncate_limit: 100 +SELECT timetz '11:27:42' + interval 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11:27:42'::timetz + 'infinity'::interval" +== 393 +-- truncate_limit: 100 +SELECT timetz '11:27:42' + interval '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11:27:42'::timetz + '-infinity'::interval" +== 394 +-- truncate_limit: 100 +SELECT timetz '11:27:42' - interval 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11:27:42'::timetz - 'infinity'::interval" +== 395 +-- truncate_limit: 100 +SELECT timetz '11:27:42' - interval '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '11:27:42'::timetz - '-infinity'::interval" +== 396 +-- truncate_limit: 100 +SELECT lhst.i lhs, + rhst.i rhs, + lhst.i < rhst.i AS lt, + lhst.i <= rhst.i AS le, + lhst.i = rhst.i AS eq, + lhst.i > rhst.i AS gt, + lhst.i >= rhst.i AS ge, + lhst.i <> rhst.i AS ne + FROM INFINITE_INTERVAL_TBL lhst CROSS JOIN INFINITE_INTERVAL_TBL rhst + WHERE NOT isfinite(lhst.i) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +ALIAS: "lhst"="infinite_interval_tbl" +ALIAS: "rhst"="infinite_interval_tbl" +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="lhst" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM infinite_interval_tbl lhst CROSS JOIN infinite_interval_tbl rhst WHERE ..." +== 397 +-- truncate_limit: 100 +SELECT i AS interval, + -i AS um, + i * 2.0 AS mul, + i * -2.0 AS mul_neg, + i * 'infinity' AS mul_inf, + i * '-infinity' AS mul_inf_neg, + i / 3.0 AS div, + i / -3.0 AS div_neg + FROM INFINITE_INTERVAL_TBL + WHERE NOT isfinite(i) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM infinite_interval_tbl WHERE NOT isfinite(i)" +== 398 +-- truncate_limit: 100 +SELECT -interval '-2147483647 months -2147483647 days -9223372036854775807 us' +-- +STMT: SelectStmt +TRUNCATED: "SELECT - '-2147483647 months -2147483647 days -9223372036854775807 us'::interval" +== 399 +-- truncate_limit: 100 +SELECT interval 'infinity' * 'nan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::interval * 'nan'" +== 400 +-- truncate_limit: 100 +SELECT interval '-infinity' * 'nan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::interval * 'nan'" +== 401 +-- truncate_limit: 100 +SELECT interval '-1073741824 months -1073741824 days -4611686018427387904 us' * 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1073741824 months -1073741824 days -4611686018427387904 us'::interval * 2" +== 402 +-- truncate_limit: 100 +SELECT interval 'infinity' * 0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::interval * 0" +== 403 +-- truncate_limit: 100 +SELECT interval '-infinity' * 0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::interval * 0" +== 404 +-- truncate_limit: 100 +SELECT interval '0 days' * 'infinity'::float +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0 days'::interval * 'infinity'::double precision" +== 405 +-- truncate_limit: 100 +SELECT interval '0 days' * '-infinity'::float +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0 days'::interval * '-infinity'::double precision" +== 406 +-- truncate_limit: 100 +SELECT interval '5 days' * 'infinity'::float +-- +STMT: SelectStmt +TRUNCATED: "SELECT '5 days'::interval * 'infinity'::double precision" +== 407 +-- truncate_limit: 100 +SELECT interval '5 days' * '-infinity'::float +-- +STMT: SelectStmt +TRUNCATED: "SELECT '5 days'::interval * '-infinity'::double precision" +== 408 +-- truncate_limit: 100 +SELECT interval 'infinity' / 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::interval / 'infinity'" +== 409 +-- truncate_limit: 100 +SELECT interval 'infinity' / '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::interval / '-infinity'" +== 410 +-- truncate_limit: 100 +SELECT interval 'infinity' / 'nan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::interval / 'nan'" +== 411 +-- truncate_limit: 100 +SELECT interval '-infinity' / 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::interval / 'infinity'" +== 412 +-- truncate_limit: 100 +SELECT interval '-infinity' / '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::interval / '-infinity'" +== 413 +-- truncate_limit: 100 +SELECT interval '-infinity' / 'nan' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::interval / 'nan'" +== 414 +-- truncate_limit: 100 +SELECT interval '-1073741824 months -1073741824 days -4611686018427387904 us' / 0.5 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1073741824 months -1073741824 days -4611686018427387904 us'::interval / 0.5" +== 415 +-- truncate_limit: 100 +SELECT date_bin('infinity', timestamp '2001-02-16 20:38:40', timestamp '2001-02-16 20:05:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('infinity', '2001-02-16 20:38:40'::timestamp, '2001-02-16 20:05:00'::timestamp)" +== 416 +-- truncate_limit: 100 +SELECT date_bin('-infinity', timestamp '2001-02-16 20:38:40', timestamp '2001-02-16 20:05:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('-infinity', '2001-02-16 20:38:40'::timestamp, '2001-02-16 20:05:00'::timestamp)" +== 417 +-- truncate_limit: 100 +SELECT i AS interval, date_trunc('hour', i) + FROM INFINITE_INTERVAL_TBL + WHERE NOT isfinite(i) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT i AS \"interval\", date_trunc('hour', i) FROM infinite_interval_tbl WHERE NOT isfinite(i)" +== 418 +-- truncate_limit: 100 +SELECT i AS interval, justify_days(i), justify_hours(i), justify_interval(i) + FROM INFINITE_INTERVAL_TBL + WHERE NOT isfinite(i) +-- +TABLE: name="infinite_interval_tbl" schema="" table="infinite_interval_tbl" ctx=Select +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FUNCTION: name="justify_days" function="justify_days" schema="" ctx=Call +FUNCTION: name="justify_hours" function="justify_hours" schema="" ctx=Call +FUNCTION: name="justify_interval" function="justify_interval" schema="" ctx=Call +FUNCTION: name="isfinite" function="isfinite" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM infinite_interval_tbl WHERE NOT isfinite(i)" +== 419 +-- truncate_limit: 100 +SELECT timezone('infinity'::interval, '1995-08-06 12:12:12'::timestamp) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timezone('infinity'::interval, '1995-08-06 12:12:12'::timestamp)" +== 420 +-- truncate_limit: 100 +SELECT timezone('-infinity'::interval, '1995-08-06 12:12:12'::timestamp) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timezone('-infinity'::interval, '1995-08-06 12:12:12'::timestamp)" +== 421 +-- truncate_limit: 100 +SELECT timezone('infinity'::interval, '1995-08-06 12:12:12'::timestamptz) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timezone('infinity'::interval, '1995-08-06 12:12:12'::timestamptz)" +== 422 +-- truncate_limit: 100 +SELECT timezone('-infinity'::interval, '1995-08-06 12:12:12'::timestamptz) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timezone('-infinity'::interval, '1995-08-06 12:12:12'::timestamptz)" +== 423 +-- truncate_limit: 100 +SELECT timezone('infinity'::interval, '12:12:12'::time) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timezone('infinity'::interval, '12:12:12'::time)" +== 424 +-- truncate_limit: 100 +SELECT timezone('-infinity'::interval, '12:12:12'::time) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timezone('-infinity'::interval, '12:12:12'::time)" +== 425 +-- truncate_limit: 100 +SELECT timezone('infinity'::interval, '12:12:12'::timetz) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timezone('infinity'::interval, '12:12:12'::timetz)" +== 426 +-- truncate_limit: 100 +SELECT timezone('-infinity'::interval, '12:12:12'::timetz) +-- +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT timezone('-infinity'::interval, '12:12:12'::timetz)" +== 427 +-- truncate_limit: 100 +SELECT 'infinity'::interval::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::interval::time" +== 428 +-- truncate_limit: 100 +SELECT '-infinity'::interval::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::interval::time" +== 429 +-- truncate_limit: 100 +SELECT to_char('infinity'::interval, 'YYYY') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('infinity'::interval, 'YYYY')" +== 430 +-- truncate_limit: 100 +SELECT to_char('-infinity'::interval, 'YYYY') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('-infinity'::interval, 'YYYY')" +== 431 +-- truncate_limit: 100 +-- "ago" can only appear once at the end of an interval. +SELECT INTERVAL '42 days 2 seconds ago ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42 days 2 seconds ago ago'::interval" +== 432 +-- truncate_limit: 100 +SELECT INTERVAL '2 minutes ago 5 days' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2 minutes ago 5 days'::interval" +== 433 +-- truncate_limit: 100 +-- consecutive and dangling units are not allowed. +SELECT INTERVAL 'hour 5 months' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'hour 5 months'::interval" +== 434 +-- truncate_limit: 100 +SELECT INTERVAL '1 year months days 5 hours' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 year months days 5 hours'::interval" +== 435 +-- truncate_limit: 100 +-- unacceptable reserved words in interval. Only "infinity", "+infinity" and +-- "-infinity" are allowed. +SELECT INTERVAL 'now' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'now'::interval" +== 436 +-- truncate_limit: 100 +SELECT INTERVAL 'today' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'today'::interval" +== 437 +-- truncate_limit: 100 +SELECT INTERVAL 'tomorrow' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'tomorrow'::interval" +== 438 +-- truncate_limit: 100 +SELECT INTERVAL 'allballs' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'allballs'::interval" +== 439 +-- truncate_limit: 100 +SELECT INTERVAL 'epoch' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'epoch'::interval" +== 440 +-- truncate_limit: 100 +SELECT INTERVAL 'yesterday' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'yesterday'::interval" +== 441 +-- truncate_limit: 100 +-- infinity specification should be the only thing +SELECT INTERVAL 'infinity years' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity years'::interval" +== 442 +-- truncate_limit: 100 +SELECT INTERVAL 'infinity ago' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity ago'::interval" +== 443 +-- truncate_limit: 100 +SELECT INTERVAL '+infinity -infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '+infinity -infinity'::interval" diff --git a/parser/testdata/summary_truncate/postgres_regress/join.metadata.json b/parser/testdata/summary_truncate/postgres_regress/join.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/join.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/join.test b/parser/testdata/summary_truncate/postgres_regress/join.test new file mode 100644 index 0000000..1d38db8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/join.test @@ -0,0 +1,8796 @@ +== 001 +-- truncate_limit: 100 +|-- +-- JOIN +-- Test JOIN clauses +|-- + +CREATE TABLE J1_TBL ( + i integer, + j integer, + t text +) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE j1_tbl (i int, j int, t text)" +== 002 +-- truncate_limit: 100 +CREATE TABLE J2_TBL ( + i integer, + k integer +) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE j2_tbl (i int, k int)" +== 003 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (1, 4, 'one') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (1, 4, 'one')" +== 004 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (2, 3, 'two') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (2, 3, 'two')" +== 005 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (3, 2, 'three') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (3, 2, 'three')" +== 006 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (4, 1, 'four') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (4, 1, 'four')" +== 007 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (5, 0, 'five') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (5, 0, 'five')" +== 008 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (6, 6, 'six') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (6, 6, 'six')" +== 009 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (7, 7, 'seven') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (7, 7, 'seven')" +== 010 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (8, 8, 'eight') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (8, 8, 'eight')" +== 011 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (0, NULL, 'zero') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (0, NULL, 'zero')" +== 012 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (NULL, NULL, 'null') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (NULL, NULL, 'null')" +== 013 +-- truncate_limit: 100 +INSERT INTO J1_TBL VALUES (NULL, 0, 'zero') +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1_tbl VALUES (NULL, 0, 'zero')" +== 014 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (1, -1) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (1, -1)" +== 015 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (2, 2) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (2, 2)" +== 016 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (3, -3) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (3, -3)" +== 017 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (2, 4) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (2, 4)" +== 018 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (5, -5) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (5, -5)" +== 019 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (5, -5) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (5, -5)" +== 020 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (0, NULL) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (0, NULL)" +== 021 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (NULL, NULL) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (NULL, NULL)" +== 022 +-- truncate_limit: 100 +INSERT INTO J2_TBL VALUES (NULL, 0) +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2_tbl VALUES (NULL, 0)" +== 023 +-- truncate_limit: 100 +-- useful in some tests below +create temp table onerow() +-- +TABLE: name="onerow" schema="" table="onerow" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE onerow ()" +== 024 +-- truncate_limit: 100 +insert into onerow default values +-- +TABLE: name="onerow" schema="" table="onerow" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO onerow DEFAULT VALUES" +== 025 +-- truncate_limit: 100 +analyze onerow +-- +TABLE: name="onerow" schema="" table="onerow" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE onerow" +== 026 +-- truncate_limit: 100 +|-- +-- CORRELATION NAMES +-- Make sure that table/column aliases are supported +-- before diving into more complex join syntax. +|-- + +SELECT * + FROM J1_TBL AS tx +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +ALIAS: "tx"="j1_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl tx" +== 027 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL tx +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +ALIAS: "tx"="j1_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl tx" +== 028 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL AS t1 (a, b, c) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl t1(a, b, c)" +== 029 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL t1 (a, b, c) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl t1(a, b, c)" +== 030 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl t1(a, b, c), j2_tbl t2(d, e)" +== 031 +-- truncate_limit: 100 +SELECT t1.a, t2.e + FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e) + WHERE t1.a = t2.d +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="d" +STMT: SelectStmt +TRUNCATED: "SELECT t1.a, t2.e FROM j1_tbl t1(a, b, c), j2_tbl t2(d, e) WHERE t1.a = t2.d" +== 032 +-- truncate_limit: 100 +|-- +-- CROSS JOIN +-- Qualifications are not allowed on cross joins, +-- which degenerate into a standard unqualified inner join. +|-- + +SELECT * + FROM J1_TBL CROSS JOIN J2_TBL +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl CROSS JOIN j2_tbl" +== 033 +-- truncate_limit: 100 +-- ambiguous column +SELECT i, k, t + FROM J1_TBL CROSS JOIN J2_TBL +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT i, k, t FROM j1_tbl CROSS JOIN j2_tbl" +== 034 +-- truncate_limit: 100 +-- resolve previous ambiguity by specifying the table name +SELECT t1.i, k, t + FROM J1_TBL t1 CROSS JOIN J2_TBL t2 +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT t1.i, k, t FROM j1_tbl t1 CROSS JOIN j2_tbl t2" +== 035 +-- truncate_limit: 100 +SELECT ii, tt, kk + FROM (J1_TBL CROSS JOIN J2_TBL) + AS tx (ii, jj, tt, ii2, kk) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ii, tt, kk FROM (j1_tbl CROSS JOIN j2_tbl ) tx(ii, jj, tt, ii2, kk)" +== 036 +-- truncate_limit: 100 +SELECT tx.ii, tx.jj, tx.kk + FROM (J1_TBL t1 (a, b, c) CROSS JOIN J2_TBL t2 (d, e)) + AS tx (ii, jj, tt, ii2, kk) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (j1_tbl t1(a, b, c) CROSS JOIN j2_tbl t2(d, e) ) tx(ii, jj, tt, ii2, kk)" +== 037 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL CROSS JOIN J2_TBL a CROSS JOIN J2_TBL b +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "a"="j2_tbl" +ALIAS: "b"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl CROSS JOIN j2_tbl a CROSS JOIN j2_tbl b" +== 038 +-- truncate_limit: 100 +|-- +|-- +-- Inner joins (equi-joins) +|-- +|-- + +|-- +-- Inner joins (equi-joins) with USING clause +-- The USING syntax changes the shape of the resulting table +-- by including a column in the USING clause only once in the result. +|-- + +-- Inner equi-join on specified column +SELECT * + FROM J1_TBL INNER JOIN J2_TBL USING (i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl USING (i)" +== 039 +-- truncate_limit: 100 +-- Same as above, slightly different syntax +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl USING (i)" +== 040 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, d) USING (a) + ORDER BY a, d +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl t1(a, b, c) JOIN j2_tbl t2(a, d) USING (a) ORDER BY a, d" +== 041 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, b) USING (b) + ORDER BY b, t1.a +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl t1(a, b, c) JOIN j2_tbl t2(a, b) USING (b) ORDER BY b, t1.a" +== 042 +-- truncate_limit: 100 +-- test join using aliases +SELECT * FROM J1_TBL JOIN J2_TBL USING (i) WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl USING (i) WHERE j1_tbl.t = 'one'" +== 043 +-- truncate_limit: 100 +-- ok +SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl USING (i) AS x WHERE j1_tbl.t = 'one'" +== 044 +-- truncate_limit: 100 +-- ok +SELECT * FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (j1_tbl JOIN j2_tbl USING (i) ) x WHERE j1_tbl.t = 'one'" +== 045 +-- truncate_limit: 100 +-- error +SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i = 1 +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="x" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl USING (i) AS x WHERE x.i = 1" +== 046 +-- truncate_limit: 100 +-- ok +SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="x" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl USING (i) AS x WHERE x.t = 'one'" +== 047 +-- truncate_limit: 100 +-- error +SELECT * FROM (J1_TBL JOIN J2_TBL USING (i) AS x) AS xx WHERE x.i = 1 +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="x" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (j1_tbl JOIN j2_tbl USING (i) AS x) xx WHERE x.i = 1" +== 048 +-- truncate_limit: 100 +-- error (XXX could use better hint) +SELECT * FROM J1_TBL a1 JOIN J2_TBL a2 USING (i) AS a1 +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "a1"="j1_tbl" +ALIAS: "a2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl a1 JOIN j2_tbl a2 USING (i) AS a1" +== 049 +-- truncate_limit: 100 +-- error +SELECT x.* FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT x.* FROM j1_tbl JOIN j2_tbl USING (i) AS x WHERE j1_tbl.t = 'one'" +== 050 +-- truncate_limit: 100 +SELECT ROW(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT ROW(x.*) FROM j1_tbl JOIN j2_tbl USING (i) AS x WHERE j1_tbl.t = 'one'" +== 051 +-- truncate_limit: 100 +SELECT row_to_json(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="j1_tbl" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(x.*) FROM j1_tbl JOIN j2_tbl USING (i) AS x WHERE j1_tbl.t = 'one'" +== 052 +-- truncate_limit: 100 +|-- +-- NATURAL JOIN +-- Inner equi-join on all columns with the same name +|-- + +SELECT * + FROM J1_TBL NATURAL JOIN J2_TBL +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl NATURAL JOIN j2_tbl" +== 053 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (a, d) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl t1(a, b, c) NATURAL JOIN j2_tbl t2(a, d)" +== 054 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (d, a) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl t1(a, b, c) NATURAL JOIN j2_tbl t2(d, a)" +== 055 +-- truncate_limit: 100 +-- mismatch number of columns +-- currently, Postgres will fill in with underlying names +SELECT * + FROM J1_TBL t1 (a, b) NATURAL JOIN J2_TBL t2 (a) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +ALIAS: "t1"="j1_tbl" +ALIAS: "t2"="j2_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl t1(a, b) NATURAL JOIN j2_tbl t2(a)" +== 056 +-- truncate_limit: 100 +|-- +-- Inner joins (equi-joins) +|-- + +SELECT * + FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl ON j1_tbl.i = j2_tbl.i" +== 057 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.k) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl ON j1_tbl.i = j2_tbl.k" +== 058 +-- truncate_limit: 100 +|-- +-- Non-equi-joins +|-- + +SELECT * + FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i <= J2_TBL.k) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl JOIN j2_tbl ON j1_tbl.i <= j2_tbl.k" +== 059 +-- truncate_limit: 100 +|-- +-- Outer joins +-- Note that OUTER is a noise word +|-- + +SELECT * + FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i) + ORDER BY i, k, t +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl LEFT JOIN j2_tbl USING (i) ORDER BY i, k, t" +== 060 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL LEFT JOIN J2_TBL USING (i) + ORDER BY i, k, t +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl LEFT JOIN j2_tbl USING (i) ORDER BY i, k, t" +== 061 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL RIGHT OUTER JOIN J2_TBL USING (i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl RIGHT JOIN j2_tbl USING (i)" +== 062 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL RIGHT JOIN J2_TBL USING (i) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl RIGHT JOIN j2_tbl USING (i)" +== 063 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL FULL OUTER JOIN J2_TBL USING (i) + ORDER BY i, k, t +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl FULL JOIN j2_tbl USING (i) ORDER BY i, k, t" +== 064 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL FULL JOIN J2_TBL USING (i) + ORDER BY i, k, t +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl FULL JOIN j2_tbl USING (i) ORDER BY i, k, t" +== 065 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (k = 1) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="" column="k" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl LEFT JOIN j2_tbl USING (i) WHERE k = 1" +== 066 +-- truncate_limit: 100 +SELECT * + FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (i = 1) +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl LEFT JOIN j2_tbl USING (i) WHERE i = 1" +== 067 +-- truncate_limit: 100 +|-- +-- semijoin selectivity for <> +|-- +explain (costs off) +select * from int4_tbl i4, tenk1 a +where exists(select * from tenk1 b + where a.twothousand = b.twothousand and a.fivethous <> b.fivethous) + and i4.f1 = a.tenthous +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "i4"="int4_tbl" +FILTER: schema="" table="a" column="twothousand" +FILTER: schema="" table="b" column="twothousand" +FILTER: schema="" table="a" column="fivethous" +FILTER: schema="" table="b" column="fivethous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl i4, tenk1 a WHERE EXISTS (SELECT * FROM tenk1 b WHERE ..." +== 068 +-- truncate_limit: 100 +|-- +-- More complicated constructs +|-- + +|-- +-- Multiway full join +|-- + +CREATE TABLE t1 (name TEXT, n INTEGER) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (name text, n int)" +== 069 +-- truncate_limit: 100 +CREATE TABLE t2 (name TEXT, n INTEGER) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t2 (name text, n int)" +== 070 +-- truncate_limit: 100 +CREATE TABLE t3 (name TEXT, n INTEGER) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t3 (name text, n int)" +== 071 +-- truncate_limit: 100 +INSERT INTO t1 VALUES ( 'bb', 11 ) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 VALUES ('bb', 11)" +== 072 +-- truncate_limit: 100 +INSERT INTO t2 VALUES ( 'bb', 12 ) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2 VALUES ('bb', 12)" +== 073 +-- truncate_limit: 100 +INSERT INTO t2 VALUES ( 'cc', 22 ) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2 VALUES ('cc', 22)" +== 074 +-- truncate_limit: 100 +INSERT INTO t2 VALUES ( 'ee', 42 ) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2 VALUES ('ee', 42)" +== 075 +-- truncate_limit: 100 +INSERT INTO t3 VALUES ( 'bb', 13 ) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t3 VALUES ('bb', 13)" +== 076 +-- truncate_limit: 100 +INSERT INTO t3 VALUES ( 'cc', 23 ) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t3 VALUES ('cc', 23)" +== 077 +-- truncate_limit: 100 +INSERT INTO t3 VALUES ( 'dd', 33 ) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t3 VALUES ('dd', 33)" +== 078 +-- truncate_limit: 100 +SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name)" +== 079 +-- truncate_limit: 100 +|-- +-- Test interactions of join syntax and subqueries +|-- + +-- Basic cases (we expect planner to pull up the subquery here) +SELECT * FROM +(SELECT * FROM t2) as s2 +INNER JOIN +(SELECT * FROM t3) s3 +USING (name) +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t2) s2 JOIN (SELECT * FROM t3) s3 USING (name)" +== 080 +-- truncate_limit: 100 +SELECT * FROM +(SELECT * FROM t2) as s2 +LEFT JOIN +(SELECT * FROM t3) s3 +USING (name) +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t2) s2 LEFT JOIN (SELECT * FROM t3) s3 USING (name)" +== 081 +-- truncate_limit: 100 +SELECT * FROM +(SELECT * FROM t2) as s2 +FULL JOIN +(SELECT * FROM t3) s3 +USING (name) +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t2) s2 FULL JOIN (SELECT * FROM t3) s3 USING (name)" +== 082 +-- truncate_limit: 100 +-- Cases with non-nullable expressions in subquery results; +-- make sure these go to null as expected +SELECT * FROM +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL INNER JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM t2) s2 NATURAL JOIN (SELECT name, n AS s3_n, 3 AS s3_2 FROM t3) s3" +== 083 +-- truncate_limit: 100 +SELECT * FROM +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL LEFT JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM t2) s2 NATURAL LEFT JOIN (SELECT ... FROM t3) s3" +== 084 +-- truncate_limit: 100 +SELECT * FROM +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL FULL JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM t2) s2 NATURAL FULL JOIN (SELECT ... FROM t3) s3" +== 085 +-- truncate_limit: 100 +SELECT * FROM +(SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1 +NATURAL INNER JOIN +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL INNER JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM t1) s1 NATURAL JOIN (SELECT ... FROM t2) s2 NATURAL JOIN (SELECT ...." +== 086 +-- truncate_limit: 100 +SELECT * FROM +(SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1 +NATURAL FULL JOIN +(SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 +NATURAL FULL JOIN +(SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM t1) s1 NATURAL FULL JOIN (SELECT ... FROM t2) s2 NATURAL FULL JOIN..." +== 087 +-- truncate_limit: 100 +SELECT * FROM +(SELECT name, n as s1_n FROM t1) as s1 +NATURAL FULL JOIN + (SELECT * FROM + (SELECT name, n as s2_n FROM t2) as s2 + NATURAL FULL JOIN + (SELECT name, n as s3_n FROM t3) as s3 + ) ss2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM t1) s1 NATURAL FULL JOIN (SELECT * FROM (SELECT ... FROM t2) s2 NA..." +== 088 +-- truncate_limit: 100 +SELECT * FROM +(SELECT name, n as s1_n FROM t1) as s1 +NATURAL FULL JOIN + (SELECT * FROM + (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2 + NATURAL FULL JOIN + (SELECT name, n as s3_n FROM t3) as s3 + ) ss2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM t1) s1 NATURAL FULL JOIN (SELECT * FROM (SELECT ... FROM t2) s2 NA..." +== 089 +-- truncate_limit: 100 +-- Constants as join keys can also be problematic +SELECT * FROM + (SELECT name, n as s1_n FROM t1) as s1 +FULL JOIN + (SELECT name, 2 as s2_n FROM t2) as s2 +ON (s1_n = s2_n) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM t1) s1 FULL JOIN (SELECT name, 2 AS s2_n FROM t2) s2 ON s1_n = s2_n" +== 090 +-- truncate_limit: 100 +-- Test for propagation of nullability constraints into sub-joins + +create temp table x (x1 int, x2 int) +-- +TABLE: name="x" schema="" table="x" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE x (x1 int, x2 int)" +== 091 +-- truncate_limit: 100 +insert into x values (1,11) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO x VALUES (1, 11)" +== 092 +-- truncate_limit: 100 +insert into x values (2,22) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO x VALUES (2, 22)" +== 093 +-- truncate_limit: 100 +insert into x values (3,null) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO x VALUES (3, NULL)" +== 094 +-- truncate_limit: 100 +insert into x values (4,44) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO x VALUES (4, 44)" +== 095 +-- truncate_limit: 100 +insert into x values (5,null) +-- +TABLE: name="x" schema="" table="x" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO x VALUES (5, NULL)" +== 096 +-- truncate_limit: 100 +create temp table y (y1 int, y2 int) +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE y (y1 int, y2 int)" +== 097 +-- truncate_limit: 100 +insert into y values (1,111) +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y VALUES (1, 111)" +== 098 +-- truncate_limit: 100 +insert into y values (2,222) +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y VALUES (2, 222)" +== 099 +-- truncate_limit: 100 +insert into y values (3,333) +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y VALUES (3, 333)" +== 100 +-- truncate_limit: 100 +insert into y values (4,null) +-- +TABLE: name="y" schema="" table="y" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y VALUES (4, NULL)" +== 101 +-- truncate_limit: 100 +select * from x +-- +TABLE: name="x" schema="" table="x" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x" +== 102 +-- truncate_limit: 100 +select * from y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 103 +-- truncate_limit: 100 +select * from x left join y on (x1 = y1 and x2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 AND x2 IS NOT NULL" +== 104 +-- truncate_limit: 100 +select * from x left join y on (x1 = y1 and y2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 AND y2 IS NOT NULL" +== 105 +-- truncate_limit: 100 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 LEFT JOIN x xx(xx1, xx2) ON x1 = xx1" +== 106 +-- truncate_limit: 100 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1 and x2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 LEFT JOIN x xx(xx1, xx2) ON x1 = xx1 AND x2 IS NOT NULL" +== 107 +-- truncate_limit: 100 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1 and y2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 LEFT JOIN x xx(xx1, xx2) ON x1 = xx1 AND y2 IS NOT NULL" +== 108 +-- truncate_limit: 100 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1 and xx2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 LEFT JOIN x xx(xx1, xx2) ON x1 = xx1 AND xx2 IS NOT NULL" +== 109 +-- truncate_limit: 100 +-- these should NOT give the same answers as above +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1) where (x2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +FILTER: schema="" table="" column="x2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 LEFT JOIN x xx(xx1, xx2) ON x1 = xx1 WHERE x2 IS NOT NULL" +== 110 +-- truncate_limit: 100 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1) where (y2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +FILTER: schema="" table="" column="y2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 LEFT JOIN x xx(xx1, xx2) ON x1 = xx1 WHERE y2 IS NOT NULL" +== 111 +-- truncate_limit: 100 +select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2) +on (x1 = xx1) where (xx2 is not null) +-- +TABLE: name="x" schema="" table="x" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="x" schema="" table="x" ctx=Select +ALIAS: "xx"="x" +FILTER: schema="" table="" column="xx2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x LEFT JOIN y ON x1 = y1 LEFT JOIN x xx(xx1, xx2) ON x1 = xx1 WHERE xx2 IS NOT NULL" +== 112 +-- truncate_limit: 100 +|-- +-- regression test: check for bug with propagation of implied equality +-- to outside an IN +|-- +select count(*) from tenk1 a where unique1 in + (select unique1 from tenk1 b join tenk1 c using (unique1) + where b.unique2 = 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 a WHERE ..." +== 113 +-- truncate_limit: 100 +|-- +-- regression test: check for failure to generate a plan with multiple +-- degenerate IN clauses +|-- +select count(*) from tenk1 x where + x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and + x.unique1 = 0 and + x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "aa"="int4_tbl" +ALIAS: "b"="float8_tbl" +ALIAS: "bb"="float8_tbl" +ALIAS: "x"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="unique1" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="aa" column="f1" +FILTER: schema="" table="bb" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 x WHERE ..." +== 114 +-- truncate_limit: 100 +-- try that with GEQO too +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 115 +-- truncate_limit: 100 +set geqo = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET geqo TO ON" +== 116 +-- truncate_limit: 100 +set geqo_threshold = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET geqo_threshold TO 2" +== 117 +-- truncate_limit: 100 +select count(*) from tenk1 x where + x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and + x.unique1 = 0 and + x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "aa"="int4_tbl" +ALIAS: "b"="float8_tbl" +ALIAS: "bb"="float8_tbl" +ALIAS: "x"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="unique1" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="aa" column="f1" +FILTER: schema="" table="bb" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 x WHERE ..." +== 118 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 119 +-- truncate_limit: 100 +|-- +-- regression test: be sure we cope with proven-dummy append rels +|-- +explain (costs off) +select aa, bb, unique1, unique1 + from tenk1 right join b_star on aa = unique1 + where bb < bb and bb is null +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="b_star" schema="" table="b_star" ctx=Select +FILTER: schema="" table="" column="bb" +FILTER: schema="" table="" column="bb" +FILTER: schema="" table="" column="bb" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT aa, bb, unique1, unique1 FROM tenk1 RIGHT JOIN b_star ON aa = unique1 ..." +== 120 +-- truncate_limit: 100 +select aa, bb, unique1, unique1 + from tenk1 right join b_star on aa = unique1 + where bb < bb and bb is null +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="b_star" schema="" table="b_star" ctx=Select +FILTER: schema="" table="" column="bb" +FILTER: schema="" table="" column="bb" +FILTER: schema="" table="" column="bb" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 RIGHT JOIN b_star ON aa = unique1 WHERE bb < bb AND bb IS NULL" +== 121 +-- truncate_limit: 100 +|-- +-- regression test: check handling of empty-FROM subquery underneath outer join +|-- +explain (costs off) +select * from int8_tbl i1 left join (int8_tbl i2 join + (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2 +order by 1, 2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +ALIAS: "i2"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl i1 LEFT JOIN (int8_tbl i2 JOIN (SELECT 123 AS x) ss ON..." +== 122 +-- truncate_limit: 100 +select * from int8_tbl i1 left join (int8_tbl i2 join + (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2 +order by 1, 2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i1"="int8_tbl" +ALIAS: "i2"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl i1 LEFT JOIN (int8_tbl i2 JOIN (SELECT ...) ss ON i2.q1 = x) ON i1.q2 = i2..." +== 123 +-- truncate_limit: 100 +|-- +-- regression test: check a case where join_clause_is_movable_into() +-- used to give an imprecise result, causing an assertion failure +|-- +select count(*) +from + (select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2 + from tenk1 t1 + left join tenk1 t2 on t1.unique1 = t2.unique1 + join tenk1 t3 on t1.unique2 = t3.unique2) ss, + tenk1 t4, + tenk1 t5 +where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +ALIAS: "t4"="tenk1" +ALIAS: "t5"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t4" column="thousand" +FILTER: schema="" table="t5" column="unique1" +FILTER: schema="" table="ss" column="x1" +FILTER: schema="" table="t4" column="tenthous" +FILTER: schema="" table="ss" column="x2" +FILTER: schema="" table="t5" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM tenk1 t1 LEFT JOIN tenk1 t2 ON t1.unique1 = t2.unique1 JOIN tenk..." +== 124 +-- truncate_limit: 100 +|-- +-- regression test: check a case where we formerly missed including an EC +-- enforcement clause because it was expected to be handled at scan level +|-- +explain (costs off) +select a.f1, b.f1, t.thousand, t.tenthous from + tenk1 t, + (select sum(f1)+1 as f1 from int4_tbl i4a) a, + (select sum(f1) as f1 from int4_tbl i4b) b +where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4a"="int4_tbl" +ALIAS: "i4b"="int4_tbl" +ALIAS: "t"="tenk1" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="t" column="thousand" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="t" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.f1, b.f1, t.thousand, t.tenthous FROM tenk1 t, (SELECT sum(f1) + 1 A..." +== 125 +-- truncate_limit: 100 +select a.f1, b.f1, t.thousand, t.tenthous from + tenk1 t, + (select sum(f1)+1 as f1 from int4_tbl i4a) a, + (select sum(f1) as f1 from int4_tbl i4b) b +where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4a"="int4_tbl" +ALIAS: "i4b"="int4_tbl" +ALIAS: "t"="tenk1" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="t" column="thousand" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="a" column="f1" +FILTER: schema="" table="b" column="f1" +FILTER: schema="" table="t" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t, (SELECT ... FROM int4_tbl i4a) a, (SELECT ... FROM int4_tbl i4b) b WHERE..." +== 126 +-- truncate_limit: 100 +|-- +-- checks for correct handling of quals in multiway outer joins +|-- +explain (costs off) +select t1.f1 +from int4_tbl t1, int4_tbl t2 + left join int4_tbl t3 on t3.f1 > 0 + left join int4_tbl t4 on t3.f1 > 1 +where t4.f1 is null +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +FILTER: schema="" table="t4" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.f1 FROM int4_tbl t1, int4_tbl t2 LEFT JOIN int4_tbl t3 ON t3.f1 > 0..." +== 127 +-- truncate_limit: 100 +select t1.f1 +from int4_tbl t1, int4_tbl t2 + left join int4_tbl t3 on t3.f1 > 0 + left join int4_tbl t4 on t3.f1 > 1 +where t4.f1 is null +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +FILTER: schema="" table="t4" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int4_tbl t1, int4_tbl t2 LEFT JOIN int4_tbl t3 ON t3.f1 > 0 LEFT JOIN int4_tbl t4..." +== 128 +-- truncate_limit: 100 +explain (costs off) +select * +from int4_tbl t1 left join int4_tbl t2 on true + left join int4_tbl t3 on t2.f1 > 0 + left join int4_tbl t4 on t3.f1 > 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl t1 LEFT JOIN int4_tbl t2 ON true LEFT JOIN int4_tbl t3..." +== 129 +-- truncate_limit: 100 +explain (costs off) +select * from onek t1 + left join onek t2 on t1.unique1 = t2.unique1 + left join onek t3 on t2.unique1 != t3.unique1 + left join onek t4 on t3.unique1 = t4.unique1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="onek" +ALIAS: "t3"="onek" +ALIAS: "t4"="onek" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM onek t1 LEFT JOIN onek t2 ON t1.unique1 = t2.unique1 LEFT JOIN ..." +== 130 +-- truncate_limit: 100 +explain (costs off) +select * from int4_tbl t1 + left join (select now() from int4_tbl t2 + left join int4_tbl t3 on t2.f1 = t3.f1 + left join int4_tbl t4 on t3.f1 = t4.f1) s on true + inner join int4_tbl t5 on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +ALIAS: "t5"="int4_tbl" +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl t1 LEFT JOIN (SELECT now() FROM int4_tbl t2 LEFT JOIN ..." +== 131 +-- truncate_limit: 100 +explain (costs off) +select * from int4_tbl t1 + left join int4_tbl t2 on true + left join int4_tbl t3 on true + left join int4_tbl t4 on t2.f1 = t3.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl t1 LEFT JOIN int4_tbl t2 ON true LEFT JOIN int4_tbl t3..." +== 132 +-- truncate_limit: 100 +explain (costs off) +select * from int4_tbl t1 + left join int4_tbl t2 on true + left join int4_tbl t3 on t2.f1 = t3.f1 + left join int4_tbl t4 on t3.f1 != t4.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl t1 LEFT JOIN int4_tbl t2 ON true LEFT JOIN int4_tbl t3..." +== 133 +-- truncate_limit: 100 +explain (costs off) +select * from int4_tbl t1 + left join (int4_tbl t2 left join int4_tbl t3 on t2.f1 > 0) on t2.f1 > 1 + left join int4_tbl t4 on t2.f1 > 2 and t3.f1 > 3 +where t1.f1 = coalesce(t2.f1, 1) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="t2" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl t1 LEFT JOIN (int4_tbl t2 LEFT JOIN int4_tbl t3 ON t2...." +== 134 +-- truncate_limit: 100 +explain (costs off) +select * from int4_tbl t1 + left join ((select t2.f1 from int4_tbl t2 + left join int4_tbl t3 on t2.f1 > 0 + where t3.f1 is null) s + left join tenk1 t4 on s.f1 > 1) + on s.f1 = t1.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="tenk1" +FILTER: schema="" table="t3" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl t1 LEFT JOIN ((SELECT t2.f1 FROM int4_tbl t2 LEFT JOIN..." +== 135 +-- truncate_limit: 100 +explain (costs off) +select * from int4_tbl t1 + left join ((select t2.f1 from int4_tbl t2 + left join int4_tbl t3 on t2.f1 > 0 + where t2.f1 <> coalesce(t3.f1, -1)) s + left join tenk1 t4 on s.f1 > 1) + on s.f1 = t1.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="tenk1" +FILTER: schema="" table="t2" column="f1" +FILTER: schema="" table="t3" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl t1 LEFT JOIN ((SELECT t2.f1 FROM int4_tbl t2 LEFT JOIN..." +== 136 +-- truncate_limit: 100 +explain (costs off) +select * from onek t1 + left join onek t2 on t1.unique1 = t2.unique1 + left join onek t3 on t2.unique1 = t3.unique1 + left join onek t4 on t3.unique1 = t4.unique1 and t2.unique2 = t4.unique2 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="onek" +ALIAS: "t3"="onek" +ALIAS: "t4"="onek" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM onek t1 LEFT JOIN onek t2 ON t1.unique1 = t2.unique1 LEFT JOIN ..." +== 137 +-- truncate_limit: 100 +explain (costs off) +select * from int8_tbl t1 left join + (int8_tbl t2 left join int8_tbl t3 full join int8_tbl t4 on false on false) + left join int8_tbl t5 on t2.q1 = t5.q1 +on t2.q2 = 123 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +ALIAS: "t4"="int8_tbl" +ALIAS: "t5"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN (int8_tbl t2 LEFT JOIN (int8_tbl t3 FULL ..." +== 138 +-- truncate_limit: 100 +explain (costs off) +select * from int8_tbl t1 + left join int8_tbl t2 on true + left join lateral + (select * from int8_tbl t3 where t3.q1 = t2.q1 offset 0) s + on t2.q1 = 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="t3" column="q1" +FILTER: schema="" table="t2" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN int8_tbl t2 ON true LEFT JOIN LATERAL (SE..." +== 139 +-- truncate_limit: 100 +explain (costs off) +select * from int8_tbl t1 + left join int8_tbl t2 on true + left join lateral + (select * from generate_series(t2.q1, 100)) s + on t2.q1 = 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN int8_tbl t2 ON true LEFT JOIN LATERAL (SE..." +== 140 +-- truncate_limit: 100 +explain (costs off) +select * from int8_tbl t1 + left join int8_tbl t2 on true + left join lateral + (select t2.q1 from int8_tbl t3) s + on t2.q1 = 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN int8_tbl t2 ON true LEFT JOIN LATERAL (SE..." +== 141 +-- truncate_limit: 100 +explain (costs off) +select * from onek t1 + left join onek t2 on true + left join lateral + (select * from onek t3 where t3.two = t2.two offset 0) s + on t2.unique1 = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="onek" +ALIAS: "t3"="onek" +FILTER: schema="" table="t3" column="two" +FILTER: schema="" table="t2" column="two" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM onek t1 LEFT JOIN onek t2 ON true LEFT JOIN LATERAL (SELECT * F..." +== 142 +-- truncate_limit: 100 +|-- +-- check a case where we formerly got confused by conflicting sort orders +-- in redundant merge join path keys +|-- +explain (costs off) +select * from + j1_tbl full join + (select * from j2_tbl order by j2_tbl.i desc, j2_tbl.k asc) j2_tbl + on j1_tbl.i = j2_tbl.i and j1_tbl.i = j2_tbl.k +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM j1_tbl FULL JOIN (SELECT * FROM j2_tbl ORDER BY j2_tbl.i DESC, ..." +== 143 +-- truncate_limit: 100 +select * from + j1_tbl full join + (select * from j2_tbl order by j2_tbl.i desc, j2_tbl.k asc) j2_tbl + on j1_tbl.i = j2_tbl.i and j1_tbl.i = j2_tbl.k +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=Select +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1_tbl FULL JOIN (SELECT * FROM j2_tbl ORDER BY j2_tbl.i DESC, j2_tbl.k ASC) j2_tbl..." +== 144 +-- truncate_limit: 100 +|-- +-- a different check for handling of redundant sort keys in merge joins +|-- +explain (costs off) +select count(*) from + (select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x + left join + (select * from tenk1 y order by y.unique2) y + on x.thousand = y.unique2 and x.twothousand = y.hundred and x.fivethous = y.unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="tenk1" +ALIAS: "y"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM (SELECT * FROM tenk1 x ORDER BY x.thousand, x.twothousan..." +== 145 +-- truncate_limit: 100 +select count(*) from + (select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x + left join + (select * from tenk1 y order by y.unique2) y + on x.thousand = y.unique2 and x.twothousand = y.hundred and x.fivethous = y.unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="tenk1" +ALIAS: "y"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM tenk1 x ORDER BY x.thousand, x.twothousand, x.fivethous) x LEFT JO..." +== 146 +-- truncate_limit: 100 +set enable_hashjoin = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO 0" +== 147 +-- truncate_limit: 100 +set enable_nestloop = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO 0" +== 148 +-- truncate_limit: 100 +set enable_hashagg = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO 0" +== 149 +-- truncate_limit: 100 +|-- +-- Check that we use the pathkeys from a prefix of the group by / order by +-- clause for the join pathkeys when that prefix covers all join quals. We +-- expect this to lead to an incremental sort for the group by / order by. +|-- +explain (costs off) +select x.thousand, x.twothousand, count(*) +from tenk1 x inner join tenk1 y on x.thousand = y.thousand +group by x.thousand, x.twothousand +order by x.thousand desc, x.twothousand +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="tenk1" +ALIAS: "y"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x.thousand, x.twothousand, count(*) FROM tenk1 x JOIN tenk1 y ON x.tho..." +== 150 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 151 +-- truncate_limit: 100 +reset enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 152 +-- truncate_limit: 100 +reset enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 153 +-- truncate_limit: 100 +|-- +-- Clean up +|-- + +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1" +== 154 +-- truncate_limit: 100 +DROP TABLE t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t2" +== 155 +-- truncate_limit: 100 +DROP TABLE t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t3" +== 156 +-- truncate_limit: 100 +DROP TABLE J1_TBL +-- +TABLE: name="j1_tbl" schema="" table="j1_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j1_tbl" +== 157 +-- truncate_limit: 100 +DROP TABLE J2_TBL +-- +TABLE: name="j2_tbl" schema="" table="j2_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j2_tbl" +== 158 +-- truncate_limit: 100 +-- Both DELETE and UPDATE allow the specification of additional tables +-- to "join" against to determine which rows should be modified. + +CREATE TEMP TABLE t1 (a int, b int) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (a int, b int)" +== 159 +-- truncate_limit: 100 +CREATE TEMP TABLE t2 (a int, b int) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t2 (a int, b int)" +== 160 +-- truncate_limit: 100 +CREATE TEMP TABLE t3 (x int, y int) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t3 (x int, y int)" +== 161 +-- truncate_limit: 100 +INSERT INTO t1 VALUES (5, 10) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 VALUES (5, 10)" +== 162 +-- truncate_limit: 100 +INSERT INTO t1 VALUES (15, 20) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 VALUES (15, 20)" +== 163 +-- truncate_limit: 100 +INSERT INTO t1 VALUES (100, 100) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 VALUES (100, 100)" +== 164 +-- truncate_limit: 100 +INSERT INTO t1 VALUES (200, 1000) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 VALUES (200, 1000)" +== 165 +-- truncate_limit: 100 +INSERT INTO t2 VALUES (200, 2000) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2 VALUES (200, 2000)" +== 166 +-- truncate_limit: 100 +INSERT INTO t3 VALUES (5, 20) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t3 VALUES (5, 20)" +== 167 +-- truncate_limit: 100 +INSERT INTO t3 VALUES (6, 7) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t3 VALUES (6, 7)" +== 168 +-- truncate_limit: 100 +INSERT INTO t3 VALUES (7, 8) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t3 VALUES (7, 8)" +== 169 +-- truncate_limit: 100 +INSERT INTO t3 VALUES (500, 100) +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t3 VALUES (500, 100)" +== 170 +-- truncate_limit: 100 +DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +ALIAS: "table1"="t1" +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a" +== 171 +-- truncate_limit: 100 +SELECT * FROM t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t3" +== 172 +-- truncate_limit: 100 +DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a" +== 173 +-- truncate_limit: 100 +SELECT * FROM t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t3" +== 174 +-- truncate_limit: 100 +DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y +-- +TABLE: name="t3" schema="" table="t3" ctx=DML +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "t3_other"="t3" +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y" +== 175 +-- truncate_limit: 100 +SELECT * FROM t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t3" +== 176 +-- truncate_limit: 100 +-- Test join against inheritance tree + +create temp table t2a () inherits (t2) +-- +TABLE: name="t2a" schema="" table="t2a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t2a () INHERITS (t2)" +== 177 +-- truncate_limit: 100 +insert into t2a values (200, 2001) +-- +TABLE: name="t2a" schema="" table="t2a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2a VALUES (200, 2001)" +== 178 +-- truncate_limit: 100 +select * from t1 left join t2 on (t1.a = t2.a) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a" +== 179 +-- truncate_limit: 100 +-- Test matching of column name with wrong alias + +select t1.x from t1 join t3 on (t1.a = t3.x) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT t1.x FROM t1 JOIN t3 ON t1.a = t3.x" +== 180 +-- truncate_limit: 100 +-- Test matching of locking clause with wrong alias + +select t1.*, t2.*, unnamed_join.* from + t1 join t2 on (t1.a = t2.a), t3 as unnamed_join + for update of unnamed_join +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 JOIN t2 ON t1.a = t2.a, t3 unnamed_join FOR UPDATE OF unnamed_join" +== 181 +-- truncate_limit: 100 +select foo.*, unnamed_join.* from + t1 join t2 using (a) as foo, t3 as unnamed_join + for update of unnamed_join +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 JOIN t2 USING (a) AS foo, t3 unnamed_join FOR UPDATE OF unnamed_join" +== 182 +-- truncate_limit: 100 +select foo.*, unnamed_join.* from + t1 join t2 using (a) as foo, t3 as unnamed_join + for update of foo +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +TRUNCATED: "SELECT foo.*, unnamed_join.* FROM t1 JOIN t2 USING (a) AS foo, t3 unnamed_join FOR UPDATE OF foo" +== 183 +-- truncate_limit: 100 +select bar.*, unnamed_join.* from + (t1 join t2 using (a) as foo) as bar, t3 as unnamed_join + for update of foo +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (t1 JOIN t2 USING (a) AS foo) bar, t3 unnamed_join FOR UPDATE OF foo" +== 184 +-- truncate_limit: 100 +select bar.*, unnamed_join.* from + (t1 join t2 using (a) as foo) as bar, t3 as unnamed_join + for update of bar +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "unnamed_join"="t3" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (t1 JOIN t2 USING (a) AS foo) bar, t3 unnamed_join FOR UPDATE OF bar" +== 185 +-- truncate_limit: 100 +|-- +-- regression test for 8.1 merge right join bug +|-- + +CREATE TEMP TABLE tt1 ( tt1_id int4, joincol int4 ) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt1 (tt1_id int4, joincol int4)" +== 186 +-- truncate_limit: 100 +INSERT INTO tt1 VALUES (1, 11) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt1 VALUES (1, 11)" +== 187 +-- truncate_limit: 100 +INSERT INTO tt1 VALUES (2, NULL) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt1 VALUES (2, NULL)" +== 188 +-- truncate_limit: 100 +CREATE TEMP TABLE tt2 ( tt2_id int4, joincol int4 ) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt2 (tt2_id int4, joincol int4)" +== 189 +-- truncate_limit: 100 +INSERT INTO tt2 VALUES (21, 11) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt2 VALUES (21, 11)" +== 190 +-- truncate_limit: 100 +INSERT INTO tt2 VALUES (22, 11) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt2 VALUES (22, 11)" +== 191 +-- truncate_limit: 100 +set enable_hashjoin to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 192 +-- truncate_limit: 100 +set enable_nestloop to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 193 +-- truncate_limit: 100 +-- these should give the same results + +select tt1.*, tt2.* from tt1 left join tt2 on tt1.joincol = tt2.joincol +-- +TABLE: name="tt1" schema="" table="tt1" ctx=Select +TABLE: name="tt2" schema="" table="tt2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tt1.*, tt2.* FROM tt1 LEFT JOIN tt2 ON tt1.joincol = tt2.joincol" +== 194 +-- truncate_limit: 100 +select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol +-- +TABLE: name="tt2" schema="" table="tt2" ctx=Select +TABLE: name="tt1" schema="" table="tt1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tt1.*, tt2.* FROM tt2 RIGHT JOIN tt1 ON tt1.joincol = tt2.joincol" +== 195 +-- truncate_limit: 100 +reset enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 196 +-- truncate_limit: 100 +reset enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 197 +-- truncate_limit: 100 +|-- +-- regression test for bug #18522 (merge-right-anti-join in inner_unique cases) +|-- + +create temp table tbl_ra(a int unique, b int) +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tbl_ra (a int UNIQUE, b int)" +== 198 +-- truncate_limit: 100 +insert into tbl_ra select i, i%100 from generate_series(1,1000)i +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl_ra SELECT i, i % 100 FROM generate_series(1, 1000) i" +== 199 +-- truncate_limit: 100 +create index on tbl_ra (b) +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tbl_ra USING btree (b)" +== 200 +-- truncate_limit: 100 +analyze tbl_ra +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE tbl_ra" +== 201 +-- truncate_limit: 100 +set enable_hashjoin to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 202 +-- truncate_limit: 100 +set enable_nestloop to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 203 +-- truncate_limit: 100 +-- ensure we get a merge right anti join +explain (costs off) +select * from tbl_ra t1 +where not exists (select 1 from tbl_ra t2 where t2.b = t1.a) and t1.b < 2 +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=Select +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=Select +ALIAS: "t1"="tbl_ra" +ALIAS: "t2"="tbl_ra" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tbl_ra t1 WHERE NOT EXISTS (SELECT 1 FROM tbl_ra t2 WHERE t2.b ..." +== 204 +-- truncate_limit: 100 +-- and check we get the expected results +select * from tbl_ra t1 +where not exists (select 1 from tbl_ra t2 where t2.b = t1.a) and t1.b < 2 +-- +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=Select +TABLE: name="tbl_ra" schema="" table="tbl_ra" ctx=Select +ALIAS: "t1"="tbl_ra" +ALIAS: "t2"="tbl_ra" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tbl_ra t1 WHERE NOT EXISTS (SELECT 1 FROM tbl_ra t2 WHERE t2.b = t1.a) AND t1.b < 2" +== 205 +-- truncate_limit: 100 +reset enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 206 +-- truncate_limit: 100 +reset enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 207 +-- truncate_limit: 100 +|-- +-- regression test for bug #13908 (hash join with skew tuples & nbatch increase) +|-- + +set work_mem to '64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 208 +-- truncate_limit: 100 +set enable_mergejoin to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 209 +-- truncate_limit: 100 +set enable_memoize to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_memoize TO OFF" +== 210 +-- truncate_limit: 100 +explain (costs off) +select count(*) from tenk1 a, tenk1 b + where a.hundred = b.thousand and (b.fivethous % 10) < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="hundred" +FILTER: schema="" table="b" column="thousand" +FILTER: schema="" table="b" column="fivethous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 a, tenk1 b WHERE a.hundred = b.thousand AND (b.fiv..." +== 211 +-- truncate_limit: 100 +select count(*) from tenk1 a, tenk1 b + where a.hundred = b.thousand and (b.fivethous % 10) < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="hundred" +FILTER: schema="" table="b" column="thousand" +FILTER: schema="" table="b" column="fivethous" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 a, tenk1 b WHERE a.hundred = b.thousand AND (b.fivethous % 10) < 10" +== 212 +-- truncate_limit: 100 +reset work_mem +-- +STMT: VariableSetStmt +TRUNCATED: "RESET work_mem" +== 213 +-- truncate_limit: 100 +reset enable_mergejoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_mergejoin" +== 214 +-- truncate_limit: 100 +reset enable_memoize +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_memoize" +== 215 +-- truncate_limit: 100 +|-- +-- regression test for 8.2 bug with improper re-ordering of left joins +|-- + +create temp table tt3(f1 int, f2 text) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt3 (f1 int, f2 text)" +== 216 +-- truncate_limit: 100 +insert into tt3 select x, repeat('xyzzy', 100) from generate_series(1,10000) x +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt3 SELECT x, repeat('xyzzy', 100) FROM generate_series(1, 10000) x" +== 217 +-- truncate_limit: 100 +analyze tt3 +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE tt3" +== 218 +-- truncate_limit: 100 +create temp table tt4(f1 int) +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt4 (f1 int)" +== 219 +-- truncate_limit: 100 +insert into tt4 values (0),(1),(9999) +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt4 VALUES (0), (1), (9999)" +== 220 +-- truncate_limit: 100 +analyze tt4 +-- +TABLE: name="tt4" schema="" table="tt4" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE tt4" +== 221 +-- truncate_limit: 100 +set enable_nestloop to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 222 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT a.f1 +FROM tt4 a +LEFT JOIN ( + SELECT b.f1 + FROM tt3 b LEFT JOIN tt3 c ON (b.f1 = c.f1) + WHERE COALESCE(c.f1, 0) = 0 +) AS d ON (a.f1 = d.f1) +WHERE COALESCE(d.f1, 0) = 0 +ORDER BY 1 +-- +TABLE: name="tt4" schema="" table="tt4" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +ALIAS: "a"="tt4" +ALIAS: "b"="tt3" +ALIAS: "c"="tt3" +FILTER: schema="" table="d" column="f1" +FILTER: schema="" table="c" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.f1 FROM tt4 a LEFT JOIN (SELECT b.f1 FROM tt3 b LEFT JOIN tt3 c ON b..." +== 223 +-- truncate_limit: 100 +SELECT a.f1 +FROM tt4 a +LEFT JOIN ( + SELECT b.f1 + FROM tt3 b LEFT JOIN tt3 c ON (b.f1 = c.f1) + WHERE COALESCE(c.f1, 0) = 0 +) AS d ON (a.f1 = d.f1) +WHERE COALESCE(d.f1, 0) = 0 +ORDER BY 1 +-- +TABLE: name="tt4" schema="" table="tt4" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +TABLE: name="tt3" schema="" table="tt3" ctx=Select +ALIAS: "a"="tt4" +ALIAS: "b"="tt3" +ALIAS: "c"="tt3" +FILTER: schema="" table="d" column="f1" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tt4 a LEFT JOIN (SELECT ... FROM tt3 b LEFT JOIN tt3 c ON b.f1 = c.f1 WHERE ...) ..." +== 224 +-- truncate_limit: 100 +reset enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 225 +-- truncate_limit: 100 +|-- +-- basic semijoin and antijoin recognition tests +|-- + +explain (costs off) +select a.* from tenk1 a +where unique1 in (select unique2 from tenk1 b) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.* FROM tenk1 a WHERE unique1 IN (SELECT unique2 FROM tenk1 b)" +== 226 +-- truncate_limit: 100 +-- sadly, this is not an antijoin +explain (costs off) +select a.* from tenk1 a +where unique1 not in (select unique2 from tenk1 b) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.* FROM tenk1 a WHERE NOT unique1 IN (SELECT unique2 FROM tenk1 b)" +== 227 +-- truncate_limit: 100 +explain (costs off) +select a.* from tenk1 a +where exists (select 1 from tenk1 b where a.unique1 = b.unique2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.* FROM tenk1 a WHERE EXISTS (SELECT 1 FROM tenk1 b WHERE a.unique1 =..." +== 228 +-- truncate_limit: 100 +explain (costs off) +select a.* from tenk1 a +where not exists (select 1 from tenk1 b where a.unique1 = b.unique2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.* FROM tenk1 a WHERE NOT EXISTS (SELECT 1 FROM tenk1 b WHERE a.uniqu..." +== 229 +-- truncate_limit: 100 +explain (costs off) +select a.* from tenk1 a left join tenk1 b on a.unique1 = b.unique2 +where b.unique2 is null +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.* FROM tenk1 a LEFT JOIN tenk1 b ON a.unique1 = b.unique2 WHERE b.un..." +== 230 +-- truncate_limit: 100 +|-- +-- regression test for proper handling of outer joins within antijoins +|-- + +create temp table tt4x(c1 int, c2 int, c3 int) +-- +TABLE: name="tt4x" schema="" table="tt4x" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt4x (c1 int, c2 int, c3 int)" +== 231 +-- truncate_limit: 100 +explain (costs off) +select * from tt4x t1 +where not exists ( + select 1 from tt4x t2 + left join tt4x t3 on t2.c3 = t3.c1 + left join ( select t5.c1 as c1 + from tt4x t4 left join tt4x t5 on t4.c2 = t5.c1 + ) a1 on t3.c2 = a1.c1 + where t1.c1 = t2.c2 +) +-- +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +TABLE: name="tt4x" schema="" table="tt4x" ctx=Select +ALIAS: "t1"="tt4x" +ALIAS: "t2"="tt4x" +ALIAS: "t3"="tt4x" +ALIAS: "t4"="tt4x" +ALIAS: "t5"="tt4x" +FILTER: schema="" table="t1" column="c1" +FILTER: schema="" table="t2" column="c2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tt4x t1 WHERE NOT EXISTS (SELECT 1 FROM tt4x t2 LEFT JOIN tt4x ..." +== 232 +-- truncate_limit: 100 +|-- +-- regression test for problems of the sort depicted in bug #3494 +|-- + +create temp table tt5(f1 int, f2 int) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt5 (f1 int, f2 int)" +== 233 +-- truncate_limit: 100 +create temp table tt6(f1 int, f2 int) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt6 (f1 int, f2 int)" +== 234 +-- truncate_limit: 100 +insert into tt5 values(1, 10) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt5 VALUES (1, 10)" +== 235 +-- truncate_limit: 100 +insert into tt5 values(1, 11) +-- +TABLE: name="tt5" schema="" table="tt5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt5 VALUES (1, 11)" +== 236 +-- truncate_limit: 100 +insert into tt6 values(1, 9) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt6 VALUES (1, 9)" +== 237 +-- truncate_limit: 100 +insert into tt6 values(1, 2) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt6 VALUES (1, 2)" +== 238 +-- truncate_limit: 100 +insert into tt6 values(2, 9) +-- +TABLE: name="tt6" schema="" table="tt6" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt6 VALUES (2, 9)" +== 239 +-- truncate_limit: 100 +select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2 +-- +TABLE: name="tt5" schema="" table="tt5" ctx=Select +TABLE: name="tt6" schema="" table="tt6" ctx=Select +FILTER: schema="" table="tt5" column="f1" +FILTER: schema="" table="tt6" column="f1" +FILTER: schema="" table="tt5" column="f1" +FILTER: schema="" table="tt5" column="f2" +FILTER: schema="" table="tt6" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt5, tt6 WHERE tt5.f1 = tt6.f1 AND tt5.f1 = (tt5.f2 - tt6.f2)" +== 240 +-- truncate_limit: 100 +|-- +-- regression test for problems of the sort depicted in bug #3588 +|-- + +create temp table xx (pkxx int) +-- +TABLE: name="xx" schema="" table="xx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE xx (pkxx int)" +== 241 +-- truncate_limit: 100 +create temp table yy (pkyy int, pkxx int) +-- +TABLE: name="yy" schema="" table="yy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE yy (pkyy int, pkxx int)" +== 242 +-- truncate_limit: 100 +insert into xx values (1) +-- +TABLE: name="xx" schema="" table="xx" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xx VALUES (1)" +== 243 +-- truncate_limit: 100 +insert into xx values (2) +-- +TABLE: name="xx" schema="" table="xx" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xx VALUES (2)" +== 244 +-- truncate_limit: 100 +insert into xx values (3) +-- +TABLE: name="xx" schema="" table="xx" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xx VALUES (3)" +== 245 +-- truncate_limit: 100 +insert into yy values (101, 1) +-- +TABLE: name="yy" schema="" table="yy" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO yy VALUES (101, 1)" +== 246 +-- truncate_limit: 100 +insert into yy values (201, 2) +-- +TABLE: name="yy" schema="" table="yy" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO yy VALUES (201, 2)" +== 247 +-- truncate_limit: 100 +insert into yy values (301, NULL) +-- +TABLE: name="yy" schema="" table="yy" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO yy VALUES (301, NULL)" +== 248 +-- truncate_limit: 100 +select yy.pkyy as yy_pkyy, yy.pkxx as yy_pkxx, yya.pkyy as yya_pkyy, + xxa.pkxx as xxa_pkxx, xxb.pkxx as xxb_pkxx +from yy + left join (SELECT * FROM yy where pkyy = 101) as yya ON yy.pkyy = yya.pkyy + left join xx xxa on yya.pkxx = xxa.pkxx + left join xx xxb on coalesce (xxa.pkxx, 1) = xxb.pkxx +-- +TABLE: name="yy" schema="" table="yy" ctx=Select +TABLE: name="xx" schema="" table="xx" ctx=Select +TABLE: name="xx" schema="" table="xx" ctx=Select +TABLE: name="yy" schema="" table="yy" ctx=Select +ALIAS: "xxa"="xx" +ALIAS: "xxb"="xx" +FILTER: schema="" table="" column="pkyy" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM yy LEFT JOIN (SELECT * FROM yy WHERE ...) yya ON yy.pkyy = yya.pkyy LEFT JOIN xx ..." +== 249 +-- truncate_limit: 100 +|-- +-- regression test for improper pushing of constants across outer-join clauses +-- (as seen in early 8.2.x releases) +|-- + +create temp table zt1 (f1 int primary key) +-- +TABLE: name="zt1" schema="" table="zt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE zt1 (f1 int PRIMARY KEY)" +== 250 +-- truncate_limit: 100 +create temp table zt2 (f2 int primary key) +-- +TABLE: name="zt2" schema="" table="zt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE zt2 (f2 int PRIMARY KEY)" +== 251 +-- truncate_limit: 100 +create temp table zt3 (f3 int primary key) +-- +TABLE: name="zt3" schema="" table="zt3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE zt3 (f3 int PRIMARY KEY)" +== 252 +-- truncate_limit: 100 +insert into zt1 values(53) +-- +TABLE: name="zt1" schema="" table="zt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO zt1 VALUES (53)" +== 253 +-- truncate_limit: 100 +insert into zt2 values(53) +-- +TABLE: name="zt2" schema="" table="zt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO zt2 VALUES (53)" +== 254 +-- truncate_limit: 100 +select * from + zt2 left join zt3 on (f2 = f3) + left join zt1 on (f3 = f1) +where f2 = 53 +-- +TABLE: name="zt2" schema="" table="zt2" ctx=Select +TABLE: name="zt3" schema="" table="zt3" ctx=Select +TABLE: name="zt1" schema="" table="zt1" ctx=Select +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM zt2 LEFT JOIN zt3 ON f2 = f3 LEFT JOIN zt1 ON f3 = f1 WHERE f2 = 53" +== 255 +-- truncate_limit: 100 +create temp view zv1 as select *,'dummy'::text AS junk from zt1 +-- +TABLE: name="zv1" schema="" table="zv1" ctx=DDL +TABLE: name="zt1" schema="" table="zt1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW zv1 AS SELECT *, 'dummy'::text AS junk FROM zt1" +== 256 +-- truncate_limit: 100 +select * from + zt2 left join zt3 on (f2 = f3) + left join zv1 on (f3 = f1) +where f2 = 53 +-- +TABLE: name="zt2" schema="" table="zt2" ctx=Select +TABLE: name="zt3" schema="" table="zt3" ctx=Select +TABLE: name="zv1" schema="" table="zv1" ctx=Select +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM zt2 LEFT JOIN zt3 ON f2 = f3 LEFT JOIN zv1 ON f3 = f1 WHERE f2 = 53" +== 257 +-- truncate_limit: 100 +|-- +-- regression test for improper extraction of OR indexqual conditions +-- (as seen in early 8.3.x releases) +|-- + +select a.unique2, a.ten, b.tenthous, b.unique2, b.hundred +from tenk1 a left join tenk1 b on a.unique2 = b.tenthous +where a.unique1 = 42 and + ((b.unique2 is null and a.ten = 2) or b.hundred = 3) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +FILTER: schema="" table="a" column="ten" +FILTER: schema="" table="b" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 a LEFT JOIN tenk1 b ON a.unique2 = b.tenthous WHERE ..." +== 258 +-- truncate_limit: 100 +|-- +-- test proper positioning of one-time quals in EXISTS (8.4devel bug) +|-- +prepare foo(bool) as + select count(*) from tenk1 a left join tenk1 b + on (a.unique2 = b.unique1 and exists + (select 1 from tenk1 c where c.thousand = b.unique2 and $1)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="c" column="thousand" +FILTER: schema="" table="b" column="unique2" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE foo(bool) AS SELECT count(*) FROM tenk1 a LEFT JOIN tenk1 b ON a.unique2 = b.unique1 AND ..." +== 259 +-- truncate_limit: 100 +execute foo(true) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foo(true)" +== 260 +-- truncate_limit: 100 +execute foo(false) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foo(false)" +== 261 +-- truncate_limit: 100 +|-- +-- test for sane behavior with noncanonical merge clauses, per bug #4926 +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 262 +-- truncate_limit: 100 +set enable_mergejoin = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO 1" +== 263 +-- truncate_limit: 100 +set enable_hashjoin = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO 0" +== 264 +-- truncate_limit: 100 +set enable_nestloop = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO 0" +== 265 +-- truncate_limit: 100 +create temp table a (i integer) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE a (i int)" +== 266 +-- truncate_limit: 100 +create temp table b (x integer, y integer) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE b (x int, y int)" +== 267 +-- truncate_limit: 100 +select * from a left join b on i = x and i = y and x = i +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM a LEFT JOIN b ON i = x AND i = y AND x = i" +== 268 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 269 +-- truncate_limit: 100 +|-- +-- test handling of merge clauses using record_ops +|-- +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 270 +-- truncate_limit: 100 +create type mycomptype as (id int, v bigint) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE mycomptype AS (id int, v bigint)" +== 271 +-- truncate_limit: 100 +create temp table tidv (idv mycomptype) +-- +TABLE: name="tidv" schema="" table="tidv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tidv (idv mycomptype)" +== 272 +-- truncate_limit: 100 +create index on tidv (idv) +-- +TABLE: name="tidv" schema="" table="tidv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON tidv USING btree (idv)" +== 273 +-- truncate_limit: 100 +explain (costs off) +select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv +-- +TABLE: name="tidv" schema="" table="tidv" ctx=Select +TABLE: name="tidv" schema="" table="tidv" ctx=Select +ALIAS: "a"="tidv" +ALIAS: "b"="tidv" +FILTER: schema="" table="a" column="idv" +FILTER: schema="" table="b" column="idv" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.idv, b.idv FROM tidv a, tidv b WHERE a.idv = b.idv" +== 274 +-- truncate_limit: 100 +set enable_mergejoin = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO 0" +== 275 +-- truncate_limit: 100 +set enable_hashjoin = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO 0" +== 276 +-- truncate_limit: 100 +explain (costs off) +select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv +-- +TABLE: name="tidv" schema="" table="tidv" ctx=Select +TABLE: name="tidv" schema="" table="tidv" ctx=Select +ALIAS: "a"="tidv" +ALIAS: "b"="tidv" +FILTER: schema="" table="a" column="idv" +FILTER: schema="" table="b" column="idv" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.idv, b.idv FROM tidv a, tidv b WHERE a.idv = b.idv" +== 277 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 278 +-- truncate_limit: 100 +|-- +-- test NULL behavior of whole-row Vars, per bug #5025 +|-- +select t1.q2, count(t2.*) +from int8_tbl t1 left join int8_tbl t2 on (t1.q2 = t2.q1) +group by t1.q2 order by 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl t1 LEFT JOIN int8_tbl t2 ON t1.q2 = t2.q1 GROUP BY t1.q2 ORDER BY 1" +== 279 +-- truncate_limit: 100 +select t1.q2, count(t2.*) +from int8_tbl t1 left join (select * from int8_tbl) t2 on (t1.q2 = t2.q1) +group by t1.q2 order by 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl t1 LEFT JOIN (SELECT * FROM int8_tbl) t2 ON t1.q2 = t2.q1 GROUP BY t1.q2..." +== 280 +-- truncate_limit: 100 +select t1.q2, count(t2.*) +from int8_tbl t1 left join (select * from int8_tbl offset 0) t2 on (t1.q2 = t2.q1) +group by t1.q2 order by 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl t1 LEFT JOIN (SELECT * FROM int8_tbl OFFSET 0) t2 ON t1.q2 = t2.q1 GROUP..." +== 281 +-- truncate_limit: 100 +select t1.q2, count(t2.*) +from int8_tbl t1 left join + (select q1, case when q2=1 then 1 else q2 end as q2 from int8_tbl) t2 + on (t1.q2 = t2.q1) +group by t1.q2 order by 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl t1 LEFT JOIN (SELECT ... FROM int8_tbl) t2 ON t1.q2 = t2.q1 GROUP BY t1...." +== 282 +-- truncate_limit: 100 +|-- +-- test incorrect failure to NULL pulled-up subexpressions +|-- +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 283 +-- truncate_limit: 100 +create temp table a ( + code char not null, + constraint a_pk primary key (code) +) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE a (code char(1) NOT NULL, CONSTRAINT a_pk PRIMARY KEY (code))" +== 284 +-- truncate_limit: 100 +create temp table b ( + a char not null, + num integer not null, + constraint b_pk primary key (a, num) +) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE b (a char(1) NOT NULL, num int NOT NULL, CONSTRAINT b_pk PRIMARY KEY (a, n..." +== 285 +-- truncate_limit: 100 +create temp table c ( + name char not null, + a char, + constraint c_pk primary key (name) +) +-- +TABLE: name="c" schema="" table="c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE c (name char(1) NOT NULL, a char(1), CONSTRAINT c_pk PRIMARY KEY (name))" +== 286 +-- truncate_limit: 100 +insert into a (code) values ('p') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a (code) VALUES ('p')" +== 287 +-- truncate_limit: 100 +insert into a (code) values ('q') +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a (code) VALUES ('q')" +== 288 +-- truncate_limit: 100 +insert into b (a, num) values ('p', 1) +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b (a, num) VALUES ('p', 1)" +== 289 +-- truncate_limit: 100 +insert into b (a, num) values ('p', 2) +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b (a, num) VALUES ('p', 2)" +== 290 +-- truncate_limit: 100 +insert into c (name, a) values ('A', 'p') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (name, a) VALUES ('A', 'p')" +== 291 +-- truncate_limit: 100 +insert into c (name, a) values ('B', 'q') +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (name, a) VALUES ('B', 'q')" +== 292 +-- truncate_limit: 100 +insert into c (name, a) values ('C', null) +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c (name, a) VALUES ('C', NULL)" +== 293 +-- truncate_limit: 100 +select c.name, ss.code, ss.b_cnt, ss.const +from c left join + (select a.code, coalesce(b_grp.cnt, 0) as b_cnt, -1 as const + from a left join + (select count(1) as cnt, b.a from b group by b.a) as b_grp + on a.code = b_grp.a + ) as ss + on (c.a = ss.code) +order by c.name +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM c LEFT JOIN (SELECT ... FROM a LEFT JOIN (SELECT ... FROM b GROUP BY b.a) b_grp O..." +== 294 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 295 +-- truncate_limit: 100 +|-- +-- test incorrect handling of placeholders that only appear in targetlists, +-- per bug #6154 +|-- +SELECT * FROM +( SELECT 1 as key1 ) sub1 +LEFT JOIN +( SELECT sub3.key3, sub4.value2, COALESCE(sub4.value2, 66) as value3 FROM + ( SELECT 1 as key3 ) sub3 + LEFT JOIN + ( SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2 FROM + ( SELECT 1 as key5 ) sub5 + LEFT JOIN + ( SELECT 2 as key6, 42 as value1 ) sub6 + ON sub5.key5 = sub6.key6 + ) sub4 + ON sub4.key5 = sub3.key3 +) sub2 +ON sub1.key1 = sub2.key3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ...) sub1 LEFT JOIN (SELECT ... FROM (SELECT ...) sub3 LEFT JOIN (SELECT ....." +== 296 +-- truncate_limit: 100 +-- test the path using join aliases, too +SELECT * FROM +( SELECT 1 as key1 ) sub1 +LEFT JOIN +( SELECT sub3.key3, value2, COALESCE(value2, 66) as value3 FROM + ( SELECT 1 as key3 ) sub3 + LEFT JOIN + ( SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2 FROM + ( SELECT 1 as key5 ) sub5 + LEFT JOIN + ( SELECT 2 as key6, 42 as value1 ) sub6 + ON sub5.key5 = sub6.key6 + ) sub4 + ON sub4.key5 = sub3.key3 +) sub2 +ON sub1.key1 = sub2.key3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ...) sub1 LEFT JOIN (SELECT ... FROM (SELECT ...) sub3 LEFT JOIN (SELECT ....." +== 297 +-- truncate_limit: 100 +|-- +-- test case where a PlaceHolderVar is used as a nestloop parameter +|-- + +EXPLAIN (COSTS OFF) +SELECT qq, unique1 + FROM + ( SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a ) AS ss1 + FULL OUTER JOIN + ( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2 + USING (qq) + INNER JOIN tenk1 c ON qq = unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT qq, unique1 FROM (SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a) ss1 FU..." +== 298 +-- truncate_limit: 100 +SELECT qq, unique1 + FROM + ( SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a ) AS ss1 + FULL OUTER JOIN + ( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2 + USING (qq) + INNER JOIN tenk1 c ON qq = unique2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="tenk1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM int8_tbl a) ss1 FULL JOIN (SELECT ... FROM int8_tbl b) ss2 USING..." +== 299 +-- truncate_limit: 100 +|-- +-- nested nestloops can require nested PlaceHolderVars +|-- + +create temp table nt1 ( + id int primary key, + a1 boolean, + a2 boolean +) +-- +TABLE: name="nt1" schema="" table="nt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE nt1 (id int PRIMARY KEY, a1 boolean, a2 boolean)" +== 300 +-- truncate_limit: 100 +create temp table nt2 ( + id int primary key, + nt1_id int, + b1 boolean, + b2 boolean, + foreign key (nt1_id) references nt1(id) +) +-- +TABLE: name="nt2" schema="" table="nt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE nt2 (id int PRIMARY KEY, nt1_id int, b1 boolean, b2 boolean, FOREIGN KEY (..." +== 301 +-- truncate_limit: 100 +create temp table nt3 ( + id int primary key, + nt2_id int, + c1 boolean, + foreign key (nt2_id) references nt2(id) +) +-- +TABLE: name="nt3" schema="" table="nt3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE nt3 (id int PRIMARY KEY, nt2_id int, c1 boolean, FOREIGN KEY (nt2_id) REFE..." +== 302 +-- truncate_limit: 100 +insert into nt1 values (1,true,true) +-- +TABLE: name="nt1" schema="" table="nt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt1 VALUES (1, true, true)" +== 303 +-- truncate_limit: 100 +insert into nt1 values (2,true,false) +-- +TABLE: name="nt1" schema="" table="nt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt1 VALUES (2, true, false)" +== 304 +-- truncate_limit: 100 +insert into nt1 values (3,false,false) +-- +TABLE: name="nt1" schema="" table="nt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt1 VALUES (3, false, false)" +== 305 +-- truncate_limit: 100 +insert into nt2 values (1,1,true,true) +-- +TABLE: name="nt2" schema="" table="nt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt2 VALUES (1, 1, true, true)" +== 306 +-- truncate_limit: 100 +insert into nt2 values (2,2,true,false) +-- +TABLE: name="nt2" schema="" table="nt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt2 VALUES (2, 2, true, false)" +== 307 +-- truncate_limit: 100 +insert into nt2 values (3,3,false,false) +-- +TABLE: name="nt2" schema="" table="nt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt2 VALUES (3, 3, false, false)" +== 308 +-- truncate_limit: 100 +insert into nt3 values (1,1,true) +-- +TABLE: name="nt3" schema="" table="nt3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt3 VALUES (1, 1, true)" +== 309 +-- truncate_limit: 100 +insert into nt3 values (2,2,false) +-- +TABLE: name="nt3" schema="" table="nt3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt3 VALUES (2, 2, false)" +== 310 +-- truncate_limit: 100 +insert into nt3 values (3,3,true) +-- +TABLE: name="nt3" schema="" table="nt3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nt3 VALUES (3, 3, true)" +== 311 +-- truncate_limit: 100 +explain (costs off) +select nt3.id +from nt3 as nt3 + left join + (select nt2.*, (nt2.b1 and ss1.a3) AS b3 + from nt2 as nt2 + left join + (select nt1.*, (nt1.id is not null) as a3 from nt1) as ss1 + on ss1.id = nt2.nt1_id + ) as ss2 + on ss2.id = nt3.nt2_id +where nt3.id = 1 and ss2.b3 +-- +TABLE: name="nt3" schema="" table="nt3" ctx=Select +TABLE: name="nt2" schema="" table="nt2" ctx=Select +TABLE: name="nt1" schema="" table="nt1" ctx=Select +ALIAS: "nt2"="nt2" +ALIAS: "nt3"="nt3" +FILTER: schema="" table="nt3" column="id" +FILTER: schema="" table="ss2" column="b3" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT nt3.id FROM nt3 nt3 LEFT JOIN (SELECT nt2.*, nt2.b1 AND ss1.a3 AS b3 F..." +== 312 +-- truncate_limit: 100 +select nt3.id +from nt3 as nt3 + left join + (select nt2.*, (nt2.b1 and ss1.a3) AS b3 + from nt2 as nt2 + left join + (select nt1.*, (nt1.id is not null) as a3 from nt1) as ss1 + on ss1.id = nt2.nt1_id + ) as ss2 + on ss2.id = nt3.nt2_id +where nt3.id = 1 and ss2.b3 +-- +TABLE: name="nt3" schema="" table="nt3" ctx=Select +TABLE: name="nt2" schema="" table="nt2" ctx=Select +TABLE: name="nt1" schema="" table="nt1" ctx=Select +ALIAS: "nt2"="nt2" +ALIAS: "nt3"="nt3" +FILTER: schema="" table="nt3" column="id" +FILTER: schema="" table="ss2" column="b3" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM nt3 nt3 LEFT JOIN (SELECT ... FROM nt2 nt2 LEFT JOIN (SELECT ... FROM nt1) ss1 ON..." +== 313 +-- truncate_limit: 100 +|-- +-- test case where a PlaceHolderVar is propagated into a subquery +|-- + +explain (costs off) +select * from + int8_tbl t1 left join + (select q1 as x, 42 as y from int8_tbl t2) ss + on t1.q2 = ss.x +where + 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1) +order by 1,2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="ss" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN (SELECT q1 AS x, 42 AS y FROM int8_tbl t2..." +== 314 +-- truncate_limit: 100 +select * from + int8_tbl t1 left join + (select q1 as x, 42 as y from int8_tbl t2) ss + on t1.q2 = ss.x +where + 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1) +order by 1,2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="ss" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl t1 LEFT JOIN (SELECT ... FROM int8_tbl t2) ss ON t1.q2 = ss.x WHERE ... OR..." +== 315 +-- truncate_limit: 100 +|-- +-- variant where a PlaceHolderVar is needed at a join, but not above the join +|-- + +explain (costs off) +select * from + int4_tbl as i41, + lateral + (select 1 as x from + (select i41.f1 as lat, + i42.f1 as loc from + int8_tbl as i81, int4_tbl as i42) as ss1 + right join int4_tbl as i43 on (i43.f1 > 1) + where ss1.loc = ss1.lat) as ss2 +where i41.f1 > 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i41"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i43"="int4_tbl" +ALIAS: "i81"="int8_tbl" +FILTER: schema="" table="i41" column="f1" +FILTER: schema="" table="ss1" column="loc" +FILTER: schema="" table="ss1" column="lat" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl i41, LATERAL (SELECT 1 AS x FROM (SELECT i41.f1 AS lat..." +== 316 +-- truncate_limit: 100 +select * from + int4_tbl as i41, + lateral + (select 1 as x from + (select i41.f1 as lat, + i42.f1 as loc from + int8_tbl as i81, int4_tbl as i42) as ss1 + right join int4_tbl as i43 on (i43.f1 > 1) + where ss1.loc = ss1.lat) as ss2 +where i41.f1 > 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i41"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i43"="int4_tbl" +ALIAS: "i81"="int8_tbl" +FILTER: schema="" table="i41" column="f1" +FILTER: schema="" table="ss1" column="loc" +FILTER: schema="" table="ss1" column="lat" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl i41, LATERAL (SELECT ... FROM (SELECT ... FROM int8_tbl i81, int4_tbl i42)..." +== 317 +-- truncate_limit: 100 +|-- +-- test the corner cases FULL JOIN ON TRUE and FULL JOIN ON FALSE +|-- +select * from int4_tbl a full join int4_tbl b on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl a FULL JOIN int4_tbl b ON true" +== 318 +-- truncate_limit: 100 +select * from int4_tbl a full join int4_tbl b on false +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl a FULL JOIN int4_tbl b ON false" +== 319 +-- truncate_limit: 100 +|-- +-- test for ability to use a cartesian join when necessary +|-- + +create temp table q1 as select 1 as q1 +-- +TABLE: name="q1" schema="" table="q1" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE q1 AS SELECT 1 AS q1" +== 320 +-- truncate_limit: 100 +create temp table q2 as select 0 as q2 +-- +TABLE: name="q2" schema="" table="q2" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE q2 AS SELECT 0 AS q2" +== 321 +-- truncate_limit: 100 +analyze q1 +-- +TABLE: name="q1" schema="" table="q1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE q1" +== 322 +-- truncate_limit: 100 +analyze q2 +-- +TABLE: name="q2" schema="" table="q2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE q2" +== 323 +-- truncate_limit: 100 +explain (costs off) +select * from + tenk1 join int4_tbl on f1 = twothousand, + q1, q2 +where q1 = thousand or q2 = thousand +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +TABLE: name="q2" schema="" table="q2" ctx=Select +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 JOIN int4_tbl ON f1 = twothousand, q1, q2 WHERE q1 = thou..." +== 324 +-- truncate_limit: 100 +explain (costs off) +select * from + tenk1 join int4_tbl on f1 = twothousand, + q1, q2 +where thousand = (q1 + q2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +TABLE: name="q2" schema="" table="q2" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 JOIN int4_tbl ON f1 = twothousand, q1, q2 WHERE thousand ..." +== 325 +-- truncate_limit: 100 +|-- +-- test ability to generate a suitable plan for a star-schema query +|-- + +explain (costs off) +select * from + tenk1, int8_tbl a, int8_tbl b +where thousand = a.q1 and tenthous = b.q1 and a.q2 = 1 and b.q2 = 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="a" column="q1" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="b" column="q1" +FILTER: schema="" table="a" column="q2" +FILTER: schema="" table="b" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1, int8_tbl a, int8_tbl b WHERE thousand = a.q1 AND tenthou..." +== 326 +-- truncate_limit: 100 +|-- +-- test a corner case in which we shouldn't apply the star-schema optimization +|-- + +explain (costs off) +select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from + tenk1 t1 + inner join int4_tbl i1 + left join (select v1.x2, v2.y1, 11 AS d1 + from (select 1,0 from onerow) v1(x1,x2) + left join (select 3,1 from onerow) v2(y1,y2) + on v1.x1 = v2.y2) subq1 + on (i1.f1 = subq1.x2) + on (t1.unique2 = subq1.d1) + left join tenk1 t2 + on (subq1.y1 = t2.unique1) +where t1.unique2 < 42 and t1.stringu1 > t2.stringu2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="t1" column="unique2" +FILTER: schema="" table="t1" column="stringu1" +FILTER: schema="" table="t2" column="stringu2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 FROM tenk1 t1 JOIN (i..." +== 327 +-- truncate_limit: 100 +select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from + tenk1 t1 + inner join int4_tbl i1 + left join (select v1.x2, v2.y1, 11 AS d1 + from (select 1,0 from onerow) v1(x1,x2) + left join (select 3,1 from onerow) v2(y1,y2) + on v1.x1 = v2.y2) subq1 + on (i1.f1 = subq1.x2) + on (t1.unique2 = subq1.d1) + left join tenk1 t2 + on (subq1.y1 = t2.unique1) +where t1.unique2 < 42 and t1.stringu1 > t2.stringu2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="t1" column="unique2" +FILTER: schema="" table="t1" column="stringu1" +FILTER: schema="" table="t2" column="stringu2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t1 JOIN (int4_tbl i1 LEFT JOIN (SELECT ... FROM (SELECT ... FROM onerow) v1..." +== 328 +-- truncate_limit: 100 +-- variant that isn't quite a star-schema case + +select ss1.d1 from + tenk1 as t1 + inner join tenk1 as t2 + on t1.tenthous = t2.ten + inner join + int8_tbl as i8 + left join int4_tbl as i4 + inner join (select 64::information_schema.cardinal_number as d1 + from tenk1 t3, + lateral (select abs(t3.unique1) + random()) ss0(x) + where t3.fivethous < 0) as ss1 + on i4.f1 = ss1.d1 + on i8.q1 = i4.f1 + on t1.tenthous = ss1.d1 +where t1.unique1 < i4.f1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="i4" column="f1" +FILTER: schema="" table="t3" column="fivethous" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t1 JOIN tenk1 t2 ON t1.tenthous = t2.ten JOIN (int8_tbl i8 LEFT JOIN (int4_..." +== 329 +-- truncate_limit: 100 +-- this variant is foldable by the remove-useless-RESULT-RTEs code + +explain (costs off) +select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from + tenk1 t1 + inner join int4_tbl i1 + left join (select v1.x2, v2.y1, 11 AS d1 + from (values(1,0)) v1(x1,x2) + left join (values(3,1)) v2(y1,y2) + on v1.x1 = v2.y2) subq1 + on (i1.f1 = subq1.x2) + on (t1.unique2 = subq1.d1) + left join tenk1 t2 + on (subq1.y1 = t2.unique1) +where t1.unique2 < 42 and t1.stringu1 > t2.stringu2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="t1" column="unique2" +FILTER: schema="" table="t1" column="stringu1" +FILTER: schema="" table="t2" column="stringu2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 FROM tenk1 t1 JOIN (i..." +== 330 +-- truncate_limit: 100 +select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from + tenk1 t1 + inner join int4_tbl i1 + left join (select v1.x2, v2.y1, 11 AS d1 + from (values(1,0)) v1(x1,x2) + left join (values(3,1)) v2(y1,y2) + on v1.x1 = v2.y2) subq1 + on (i1.f1 = subq1.x2) + on (t1.unique2 = subq1.d1) + left join tenk1 t2 + on (subq1.y1 = t2.unique1) +where t1.unique2 < 42 and t1.stringu1 > t2.stringu2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="t1" column="unique2" +FILTER: schema="" table="t1" column="stringu1" +FILTER: schema="" table="t2" column="stringu2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t1 JOIN (int4_tbl i1 LEFT JOIN (SELECT ... FROM (VALUES (...)) v1(x1, x2) L..." +== 331 +-- truncate_limit: 100 +-- Here's a variant that we can't fold too aggressively, though, +-- or we end up with noplace to evaluate the lateral PHV +explain (verbose, costs off) +select * from + (select 1 as x) ss1 left join (select 2 as y) ss2 on (true), + lateral (select ss2.y as z limit 1) ss3 +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (SELECT 1 AS x) ss1 LEFT JOIN (SELECT 2 AS y) ss2 ON t..." +== 332 +-- truncate_limit: 100 +select * from + (select 1 as x) ss1 left join (select 2 as y) ss2 on (true), + lateral (select ss2.y as z limit 1) ss3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ...) ss1 LEFT JOIN (SELECT ...) ss2 ON true, LATERAL (SELECT ... LIMIT 1) ss3" +== 333 +-- truncate_limit: 100 +-- Test proper handling of appendrel PHVs during useless-RTE removal +explain (costs off) +select * from + (select 0 as z) as t1 + left join + (select true as a) as t2 + on true, + lateral (select true as b + union all + select a as b) as t3 +where b +-- +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT 0 AS z) t1 LEFT JOIN (SELECT true AS a) t2 ON true, LAT..." +== 334 +-- truncate_limit: 100 +select * from + (select 0 as z) as t1 + left join + (select true as a) as t2 + on true, + lateral (select true as b + union all + select a as b) as t3 +where b +-- +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ...) t1 LEFT JOIN (SELECT ...) t2 ON true, LATERAL (SELECT ... UNION ALL SE..." +== 335 +-- truncate_limit: 100 +-- Test PHV in a semijoin qual, which confused useless-RTE removal (bug #17700) +explain (verbose, costs off) +with ctetable as not materialized ( select 1 as f1 ) +select * from ctetable c1 +where f1 in ( select c3.f1 from ctetable c2 full join ctetable c3 on true ) +-- +ALIAS: "c1"="ctetable" +ALIAS: "c2"="ctetable" +ALIAS: "c3"="ctetable" +CTE: "ctetable" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH ctetable AS NOT MATERIALIZED (SELECT 1 AS f1) SELECT * FROM cte..." +== 336 +-- truncate_limit: 100 +with ctetable as not materialized ( select 1 as f1 ) +select * from ctetable c1 +where f1 in ( select c3.f1 from ctetable c2 full join ctetable c3 on true ) +-- +ALIAS: "c1"="ctetable" +ALIAS: "c2"="ctetable" +ALIAS: "c3"="ctetable" +CTE: "ctetable" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "WITH ctetable AS NOT MATERIALIZED (...) SELECT * FROM ctetable c1 WHERE ..." +== 337 +-- truncate_limit: 100 +-- Test PHV that winds up in a Result node, despite having nonempty nullingrels +explain (verbose, costs off) +select table_catalog, table_name +from int4_tbl t1 + inner join (int8_tbl t2 + left join information_schema.column_udt_usage on null) + on null +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="information_schema.column_udt_usage" schema="information_schema" table="column_udt_usage" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT table_catalog, table_name FROM int4_tbl t1 JOIN (int8_tbl t2 ..." +== 338 +-- truncate_limit: 100 +-- Test handling of qual pushdown to appendrel members with non-Var outputs +explain (verbose, costs off) +select * from int4_tbl left join ( + select text 'foo' union all select text 'bar' +) ss(x) on true +where ss.x is null +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="ss" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int4_tbl LEFT JOIN (SELECT 'foo'::text UNION ALL SELEC..." +== 339 +-- truncate_limit: 100 +|-- +-- test inlining of immutable functions +|-- +create function f_immutable_int4(i integer) returns integer as +$$ begin return i; end; $$ language plpgsql immutable +-- +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f_immutable_int4(i int) RETURNS int AS $$ begin return i; end; $$ LANGUAGE plpgsq..." +== 340 +-- truncate_limit: 100 +-- check optimization of function scan with join +explain (costs off) +select unique1 from tenk1, (select * from f_immutable_int4(1) x) x +where x = unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1, (SELECT * FROM f_immutable_int4(1) x) x WHERE x = ..." +== 341 +-- truncate_limit: 100 +explain (verbose, costs off) +select unique1, x.* +from tenk1, (select *, random() from f_immutable_int4(1) x) x +where x = unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT unique1, x.* FROM tenk1, (SELECT *, random() FROM f_immutable..." +== 342 +-- truncate_limit: 100 +explain (costs off) +select unique1 from tenk1, f_immutable_int4(1) x where x = unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1, f_immutable_int4(1) x WHERE x = unique1" +== 343 +-- truncate_limit: 100 +explain (costs off) +select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1, LATERAL f_immutable_int4(1) x WHERE x = unique1" +== 344 +-- truncate_limit: 100 +explain (costs off) +select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1, LATERAL f_immutable_int4(1) x WHERE x IN (SELECT 17)" +== 345 +-- truncate_limit: 100 +explain (costs off) +select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, x FROM tenk1 JOIN f_immutable_int4(1) x ON unique1 = x" +== 346 +-- truncate_limit: 100 +explain (costs off) +select unique1, x from tenk1 left join f_immutable_int4(1) x on unique1 = x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, x FROM tenk1 LEFT JOIN f_immutable_int4(1) x ON unique1 = x" +== 347 +-- truncate_limit: 100 +explain (costs off) +select unique1, x from tenk1 right join f_immutable_int4(1) x on unique1 = x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, x FROM tenk1 RIGHT JOIN f_immutable_int4(1) x ON unique1 = x" +== 348 +-- truncate_limit: 100 +explain (costs off) +select unique1, x from tenk1 full join f_immutable_int4(1) x on unique1 = x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, x FROM tenk1 FULL JOIN f_immutable_int4(1) x ON unique1 = x" +== 349 +-- truncate_limit: 100 +-- check that pullup of a const function allows further const-folding +explain (costs off) +select unique1 from tenk1, f_immutable_int4(1) x where x = 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1, f_immutable_int4(1) x WHERE x = 42" +== 350 +-- truncate_limit: 100 +-- test inlining of immutable functions with PlaceHolderVars +explain (costs off) +select nt3.id +from nt3 as nt3 + left join + (select nt2.*, (nt2.b1 or i4 = 42) AS b3 + from nt2 as nt2 + left join + f_immutable_int4(0) i4 + on i4 = nt2.nt1_id + ) as ss2 + on ss2.id = nt3.nt2_id +where nt3.id = 1 and ss2.b3 +-- +TABLE: name="nt3" schema="" table="nt3" ctx=Select +TABLE: name="nt2" schema="" table="nt2" ctx=Select +ALIAS: "nt2"="nt2" +ALIAS: "nt3"="nt3" +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=Call +FILTER: schema="" table="nt3" column="id" +FILTER: schema="" table="ss2" column="b3" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT nt3.id FROM nt3 nt3 LEFT JOIN (SELECT nt2.*, nt2.b1 OR i4 = 42 AS b3 F..." +== 351 +-- truncate_limit: 100 +drop function f_immutable_int4(int) +-- +FUNCTION: name="f_immutable_int4" function="f_immutable_int4" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f_immutable_int4(int)" +== 352 +-- truncate_limit: 100 +-- test inlining when function returns composite + +create function mki8(bigint, bigint) returns int8_tbl as +$$select row($1,$2)::int8_tbl$$ language sql +-- +FUNCTION: name="mki8" function="mki8" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mki8(bigint, bigint) RETURNS int8_tbl AS $$select row($1,$2)::int8_tbl$$ LANGUAGE..." +== 353 +-- truncate_limit: 100 +create function mki4(int) returns int4_tbl as +$$select row($1)::int4_tbl$$ language sql +-- +FUNCTION: name="mki4" function="mki4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mki4(int) RETURNS int4_tbl AS $$select row($1)::int4_tbl$$ LANGUAGE sql" +== 354 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from mki8(1,2) +-- +FUNCTION: name="mki8" function="mki8" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM mki8(1, 2)" +== 355 +-- truncate_limit: 100 +select * from mki8(1,2) +-- +FUNCTION: name="mki8" function="mki8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mki8(1, 2)" +== 356 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from mki4(42) +-- +FUNCTION: name="mki4" function="mki4" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM mki4(42)" +== 357 +-- truncate_limit: 100 +select * from mki4(42) +-- +FUNCTION: name="mki4" function="mki4" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mki4(42)" +== 358 +-- truncate_limit: 100 +drop function mki8(bigint, bigint) +-- +FUNCTION: name="mki8" function="mki8" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION mki8(bigint, bigint)" +== 359 +-- truncate_limit: 100 +drop function mki4(int) +-- +FUNCTION: name="mki4" function="mki4" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION mki4(int)" +== 360 +-- truncate_limit: 100 +-- test const-folding of a whole-row Var into a per-field Var +-- (need to inline a function to reach this case, else parser does it) +create function f_field_select(t onek) returns int4 as +$$ select t.unique2; $$ language sql immutable +-- +FUNCTION: name="f_field_select" function="f_field_select" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f_field_select(t onek) RETURNS int4 AS $$ select t.unique2; $$ LANGUAGE sql IMMUT..." +== 361 +-- truncate_limit: 100 +explain (verbose, costs off) +select (t2.*).unique1, f_field_select(t2) from tenk1 t1 + left join onek t2 on t1.unique1 = t2.unique1 + left join int8_tbl t3 on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="onek" +ALIAS: "t3"="int8_tbl" +FUNCTION: name="f_field_select" function="f_field_select" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT (t2.*).unique1, f_field_select(t2) FROM tenk1 t1 LEFT JOIN on..." +== 362 +-- truncate_limit: 100 +drop function f_field_select(t onek) +-- +FUNCTION: name="f_field_select" function="f_field_select" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f_field_select(t onek)" +== 363 +-- truncate_limit: 100 +|-- +-- test extraction of restriction OR clauses from join OR clause +-- (we used to only do this for indexable clauses) +|-- + +explain (costs off) +select * from tenk1 a join tenk1 b on + (a.unique1 = 1 and b.unique1 = 2) or (a.unique2 = 3 and b.hundred = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a JOIN tenk1 b ON (a.unique1 = 1 AND b.unique1 = 2) OR (a..." +== 364 +-- truncate_limit: 100 +explain (costs off) +select * from tenk1 a join tenk1 b on + (a.unique1 = 1 and b.unique1 = 2) or (a.unique2 = 3 and b.ten = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a JOIN tenk1 b ON (a.unique1 = 1 AND b.unique1 = 2) OR (a..." +== 365 +-- truncate_limit: 100 +explain (costs off) +select * from tenk1 a join tenk1 b on + (a.unique1 = 1 and b.unique1 = 2) or + ((a.unique2 = 3 or a.unique2 = 7) and b.hundred = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a JOIN tenk1 b ON (a.unique1 = 1 AND b.unique1 = 2) OR ((..." +== 366 +-- truncate_limit: 100 +|-- +-- test placement of movable quals in a parameterized join tree +|-- + +explain (costs off) +select * from tenk1 t1 left join + (tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2) + on t1.hundred = t2.hundred and t1.ten = t3.ten +where t1.unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FILTER: schema="" table="t1" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 t1 LEFT JOIN (tenk1 t2 JOIN tenk1 t3 ON t2.thousand = t3...." +== 367 +-- truncate_limit: 100 +explain (costs off) +select * from tenk1 t1 left join + (tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2) + on t1.hundred = t2.hundred and t1.ten + t2.ten = t3.ten +where t1.unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FILTER: schema="" table="t1" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 t1 LEFT JOIN (tenk1 t2 JOIN tenk1 t3 ON t2.thousand = t3...." +== 368 +-- truncate_limit: 100 +explain (costs off) +select count(*) from + tenk1 a join tenk1 b on a.unique1 = b.unique2 + left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand + join int4_tbl on b.thousand = f1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique2 LEFT JOIN ..." +== 369 +-- truncate_limit: 100 +select count(*) from + tenk1 a join tenk1 b on a.unique1 = b.unique2 + left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand + join int4_tbl on b.thousand = f1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique2 LEFT JOIN tenk1 c ON a.unique2 = b...." +== 370 +-- truncate_limit: 100 +explain (costs off) +select b.unique1 from + tenk1 a join tenk1 b on a.unique1 = b.unique2 + left join tenk1 c on b.unique1 = 42 and c.thousand = a.thousand + join int4_tbl i1 on b.thousand = f1 + right join int4_tbl i2 on i2.f1 = b.tenthous + order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b.unique1 FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique2 LEFT JOIN..." +== 371 +-- truncate_limit: 100 +select b.unique1 from + tenk1 a join tenk1 b on a.unique1 = b.unique2 + left join tenk1 c on b.unique1 = 42 and c.thousand = a.thousand + join int4_tbl i1 on b.thousand = f1 + right join int4_tbl i2 on i2.f1 = b.tenthous + order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique2 LEFT JOIN tenk1 c ON b.unique1 = 42..." +== 372 +-- truncate_limit: 100 +explain (costs off) +select * from +( + select unique1, q1, coalesce(unique1, -1) + q1 as fault + from int8_tbl left join tenk1 on (q2 = unique2) +) ss +where fault = 122 +order by fault +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="fault" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT unique1, q1, COALESCE(unique1, -1) + q1 AS fault FROM i..." +== 373 +-- truncate_limit: 100 +select * from +( + select unique1, q1, coalesce(unique1, -1) + q1 as fault + from int8_tbl left join tenk1 on (q2 = unique2) +) ss +where fault = 122 +order by fault +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="fault" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM int8_tbl LEFT JOIN tenk1 ON q2 = unique2) ss WHERE ... ORDER BY fault" +== 374 +-- truncate_limit: 100 +explain (costs off) +select * from +(values (1, array[10,20]), (2, array[20,30])) as v1(v1x,v1ys) +left join (values (1, 10), (2, 20)) as v2(v2x,v2y) on v2x = v1x +left join unnest(v1ys) as u1(u1y) on u1y = v2y +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (VALUES (1, ARRAY[10, 20]), (2, ARRAY[20, 30])) v1(v1x, v1ys) L..." +== 375 +-- truncate_limit: 100 +select * from +(values (1, array[10,20]), (2, array[20,30])) as v1(v1x,v1ys) +left join (values (1, 10), (2, 20)) as v2(v2x,v2y) on v2x = v1x +left join unnest(v1ys) as u1(u1y) on u1y = v2y +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v1(v1x, v1ys) LEFT JOIN (VALUES (...)) v2(v2x, v2y) ON v2x = v1x LEF..." +== 376 +-- truncate_limit: 100 +|-- +-- test handling of potential equivalence clauses above outer joins +|-- + +explain (costs off) +select q1, unique2, thousand, hundred + from int8_tbl a left join tenk1 b on q1 = unique2 + where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT q1, unique2, thousand, hundred FROM int8_tbl a LEFT JOIN tenk1 b ON q1..." +== 377 +-- truncate_limit: 100 +select q1, unique2, thousand, hundred + from int8_tbl a left join tenk1 b on q1 = unique2 + where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT q1, unique2, thousand, hundred FROM int8_tbl a LEFT JOIN tenk1 b ON q1 = unique2 WHERE ..." +== 378 +-- truncate_limit: 100 +explain (costs off) +select f1, unique2, case when unique2 is null then f1 else 0 end + from int4_tbl a left join tenk1 b on f1 = unique2 + where (case when unique2 is null then f1 else 0 end) = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT f1, unique2, CASE WHEN unique2 IS NULL THEN f1 ELSE 0 END FROM int4_tb..." +== 379 +-- truncate_limit: 100 +select f1, unique2, case when unique2 is null then f1 else 0 end + from int4_tbl a left join tenk1 b on f1 = unique2 + where (case when unique2 is null then f1 else 0 end) = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int4_tbl a LEFT JOIN tenk1 b ON f1 = unique2 WHERE ..." +== 380 +-- truncate_limit: 100 +|-- +-- another case with equivalence clauses above outer joins (bug #8591) +|-- + +explain (costs off) +select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand) + from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand) + where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FILTER: schema="" table="a" column="unique2" +FILTER: schema="" table="b" column="twothousand" +FILTER: schema="" table="a" column="twothousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.unique1, b.unique1, c.unique1, COALESCE(b.twothousand, a.twothousand..." +== 381 +-- truncate_limit: 100 +select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand) + from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand) + where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +FILTER: schema="" table="a" column="unique2" +FILTER: schema="" table="b" column="twothousand" +FILTER: schema="" table="a" column="twothousand" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 a LEFT JOIN tenk1 b ON b.thousand = a.unique1 LEFT JOIN tenk1 c ON c.unique..." +== 382 +-- truncate_limit: 100 +-- related case + +explain (costs off) +select * from int8_tbl t1 left join int8_tbl t2 on t1.q2 = t2.q1, + lateral (select * from int8_tbl t3 where t2.q1 = t2.q2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="t2" column="q1" +FILTER: schema="" table="t2" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN int8_tbl t2 ON t1.q2 = t2.q1, LATERAL (SE..." +== 383 +-- truncate_limit: 100 +select * from int8_tbl t1 left join int8_tbl t2 on t1.q2 = t2.q1, + lateral (select * from int8_tbl t3 where t2.q1 = t2.q2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FILTER: schema="" table="t2" column="q1" +FILTER: schema="" table="t2" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl t1 LEFT JOIN int8_tbl t2 ON t1.q2 = t2.q1, LATERAL (SELECT * FROM int8_tbl..." +== 384 +-- truncate_limit: 100 +|-- +-- check handling of join aliases when flattening multiple levels of subquery +|-- + +explain (verbose, costs off) +select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from + (values (0),(1)) foo1(join_key) +left join + (select join_key, bug_field from + (select ss1.join_key, ss1.bug_field from + (select f1 as join_key, 666 as bug_field from int4_tbl i1) ss1 + ) foo2 + left join + (select unique2 as join_key from tenk1 i2) ss2 + using (join_key) + ) foo3 +using (join_key) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT foo1.join_key AS foo1_id, foo3.join_key AS foo3_id, bug_field..." +== 385 +-- truncate_limit: 100 +select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from + (values (0),(1)) foo1(join_key) +left join + (select join_key, bug_field from + (select ss1.join_key, ss1.bug_field from + (select f1 as join_key, 666 as bug_field from int4_tbl i1) ss1 + ) foo2 + left join + (select unique2 as join_key from tenk1 i2) ss2 + using (join_key) + ) foo3 +using (join_key) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="tenk1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) foo1(join_key) LEFT JOIN (SELECT ... FROM (SELECT ... FROM (SELECT..." +== 386 +-- truncate_limit: 100 +|-- +-- check handling of a variable-free join alias +|-- +explain (verbose, costs off) +select * from +int4_tbl i0 left join +( (select *, 123 as x from int4_tbl i1) ss1 + left join + (select *, q2 as x from int8_tbl i2) ss2 + using (x) +) ss0 +on (i0.f1 = ss0.f1) +order by i0.f1, x +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i0"="int4_tbl" +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int4_tbl i0 LEFT JOIN ((SELECT *, 123 AS x FROM int4_t..." +== 387 +-- truncate_limit: 100 +select * from +int4_tbl i0 left join +( (select *, 123 as x from int4_tbl i1) ss1 + left join + (select *, q2 as x from int8_tbl i2) ss2 + using (x) +) ss0 +on (i0.f1 = ss0.f1) +order by i0.f1, x +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i0"="int4_tbl" +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl i0 LEFT JOIN ((SELECT ... FROM int4_tbl i1) ss1 LEFT JOIN (SELECT ... FROM..." +== 388 +-- truncate_limit: 100 +|-- +-- test successful handling of nested outer joins with degenerate join quals +|-- + +explain (verbose, costs off) +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.* FROM text_tbl t1 LEFT JOIN ((SELECT *, '***'::text AS d1..." +== 389 +-- truncate_limit: 100 +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM text_tbl t1 LEFT JOIN ((SELECT ... FROM int8_tbl i8b1) b1 LEFT JOIN (int8_tbl i8 ..." +== 390 +-- truncate_limit: 100 +explain (verbose, costs off) +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i4b2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.* FROM text_tbl t1 LEFT JOIN ((SELECT *, '***'::text AS d1..." +== 391 +-- truncate_limit: 100 +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i4b2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM text_tbl t1 LEFT JOIN ((SELECT ... FROM int8_tbl i8b1) b1 LEFT JOIN (int8_tbl i8 ..." +== 392 +-- truncate_limit: 100 +explain (verbose, costs off) +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2 + where q1 = f1) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i4b2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.* FROM text_tbl t1 LEFT JOIN ((SELECT *, '***'::text AS d1..." +== 393 +-- truncate_limit: 100 +select t1.* from + text_tbl t1 + left join (select *, '***'::text as d1 from int8_tbl i8b1) b1 + left join int8_tbl i8 + left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2 + where q1 = f1) b2 + on (i8.q1 = b2.q1) + on (b2.d2 = b1.q2) + on (t1.f1 = b1.d1) + left join int4_tbl i4 + on (i8.q2 = i4.f1) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i4b2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "i8b1"="int8_tbl" +ALIAS: "i8b2"="int8_tbl" +ALIAS: "t1"="text_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM text_tbl t1 LEFT JOIN ((SELECT ... FROM int8_tbl i8b1) b1 LEFT JOIN (int8_tbl i8 ..." +== 394 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from + text_tbl t1 + inner join int8_tbl i8 + on i8.q2 = 456 + right join text_tbl t2 + on t1.f1 = 'doh!' + left join int4_tbl i4 + on i8.q1 = i4.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM text_tbl t1 JOIN int8_tbl i8 ON i8.q2 = 456 RIGHT JOIN..." +== 395 +-- truncate_limit: 100 +select * from + text_tbl t1 + inner join int8_tbl i8 + on i8.q2 = 456 + right join text_tbl t2 + on t1.f1 = 'doh!' + left join int4_tbl i4 + on i8.q1 = i4.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM text_tbl t1 JOIN int8_tbl i8 ON i8.q2 = 456 RIGHT JOIN text_tbl t2 ON t1.f1 = 'doh!..." +== 396 +-- truncate_limit: 100 +-- check handling of a variable-free qual for a non-commutable outer join +explain (costs off) +select nspname +from (select 1 as x) ss1 +left join +( select n.nspname, c.relname + from pg_class c left join pg_namespace n on n.oid = c.relnamespace + where c.relkind = 'r' +) ss2 on false +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "n"="pg_namespace" +FILTER: schema="" table="c" column="relkind" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT nspname FROM (SELECT 1 AS x) ss1 LEFT JOIN (SELECT n.nspname, c.relnam..." +== 397 +-- truncate_limit: 100 +-- check handling of apparently-commutable outer joins with non-commutable +-- joins between them +explain (costs off) +select 1 from + int4_tbl i4 + left join int8_tbl i8 on i4.f1 is not null + left join (select 1 as a) ss1 on null + join int4_tbl i42 on ss1.a is null or i8.q1 <> i8.q2 + right join (select 2 as b) ss2 + on ss2.b < i4.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM int4_tbl i4 LEFT JOIN int8_tbl i8 ON i4.f1 IS NOT NULL LEFT JOI..." +== 398 +-- truncate_limit: 100 +|-- +-- test for appropriate join order in the presence of lateral references +|-- + +explain (verbose, costs off) +select * from + text_tbl t1 + left join int8_tbl i8 + on i8.q2 = 123, + lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss +where t1.f1 = ss.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="ss" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM text_tbl t1 LEFT JOIN int8_tbl i8 ON i8.q2 = 123, LATE..." +== 399 +-- truncate_limit: 100 +select * from + text_tbl t1 + left join int8_tbl i8 + on i8.q2 = 123, + lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss +where t1.f1 = ss.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="ss" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM text_tbl t1 LEFT JOIN int8_tbl i8 ON i8.q2 = 123, LATERAL (SELECT ... FROM text_tbl..." +== 400 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from + text_tbl t1 + left join int8_tbl i8 + on i8.q2 = 123, + lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss1, + lateral (select ss1.* from text_tbl t3 limit 1) as ss2 +where t1.f1 = ss2.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +ALIAS: "t3"="text_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="ss2" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM text_tbl t1 LEFT JOIN int8_tbl i8 ON i8.q2 = 123, LATE..." +== 401 +-- truncate_limit: 100 +select * from + text_tbl t1 + left join int8_tbl i8 + on i8.q2 = 123, + lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss1, + lateral (select ss1.* from text_tbl t3 limit 1) as ss2 +where t1.f1 = ss2.f1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="text_tbl" +ALIAS: "t2"="text_tbl" +ALIAS: "t3"="text_tbl" +FILTER: schema="" table="t1" column="f1" +FILTER: schema="" table="ss2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM text_tbl t1 LEFT JOIN int8_tbl i8 ON i8.q2 = 123, LATERAL (SELECT ... FROM text_tbl..." +== 402 +-- truncate_limit: 100 +explain (verbose, costs off) +select 1 from + text_tbl as tt1 + inner join text_tbl as tt2 on (tt1.f1 = 'foo') + left join text_tbl as tt3 on (tt3.f1 = 'foo') + left join text_tbl as tt4 on (tt3.f1 = tt4.f1), + lateral (select tt4.f1 as c0 from text_tbl as tt5 limit 1) as ss1 +where tt1.f1 = ss1.c0 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "tt1"="text_tbl" +ALIAS: "tt2"="text_tbl" +ALIAS: "tt3"="text_tbl" +ALIAS: "tt4"="text_tbl" +ALIAS: "tt5"="text_tbl" +FILTER: schema="" table="tt1" column="f1" +FILTER: schema="" table="ss1" column="c0" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT 1 FROM text_tbl tt1 JOIN text_tbl tt2 ON tt1.f1 = 'foo' LEFT ..." +== 403 +-- truncate_limit: 100 +select 1 from + text_tbl as tt1 + inner join text_tbl as tt2 on (tt1.f1 = 'foo') + left join text_tbl as tt3 on (tt3.f1 = 'foo') + left join text_tbl as tt4 on (tt3.f1 = tt4.f1), + lateral (select tt4.f1 as c0 from text_tbl as tt5 limit 1) as ss1 +where tt1.f1 = ss1.c0 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "tt1"="text_tbl" +ALIAS: "tt2"="text_tbl" +ALIAS: "tt3"="text_tbl" +ALIAS: "tt4"="text_tbl" +ALIAS: "tt5"="text_tbl" +FILTER: schema="" table="tt1" column="f1" +FILTER: schema="" table="ss1" column="c0" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM text_tbl tt1 JOIN text_tbl tt2 ON tt1.f1 = 'foo' LEFT JOIN text_tbl tt3 ON tt3.f1 =..." +== 404 +-- truncate_limit: 100 +explain (verbose, costs off) +select 1 from + int4_tbl as i4 + inner join + ((select 42 as n from int4_tbl x1 left join int8_tbl x2 on f1 = q1) as ss1 + right join (select 1 as z) as ss2 on true) + on false, + lateral (select i4.f1, ss1.n from int8_tbl as i8 limit 1) as ss3 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "x1"="int4_tbl" +ALIAS: "x2"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT 1 FROM int4_tbl i4 JOIN ((SELECT 42 AS n FROM int4_tbl x1 LEF..." +== 405 +-- truncate_limit: 100 +select 1 from + int4_tbl as i4 + inner join + ((select 42 as n from int4_tbl x1 left join int8_tbl x2 on f1 = q1) as ss1 + right join (select 1 as z) as ss2 on true) + on false, + lateral (select i4.f1, ss1.n from int8_tbl as i8 limit 1) as ss3 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "x1"="int4_tbl" +ALIAS: "x2"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM int4_tbl i4 JOIN ((SELECT ... FROM int4_tbl x1 LEFT JOIN int8_tbl x2 ON f1 = q1) ss..." +== 406 +-- truncate_limit: 100 +|-- +-- check a case where we formerly generated invalid parameterized paths +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 407 +-- truncate_limit: 100 +create temp table t (a int unique) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t (a int UNIQUE)" +== 408 +-- truncate_limit: 100 +explain (costs off) +select 1 from t t1 + join lateral (select t1.a from (select 1) foo offset 0) as s1 on true + join + (select 1 from t t2 + inner join (t t3 + left join (t t4 left join t t5 on t4.a = 1) + on t3.a = t4.a) + on false + where t3.a = coalesce(t5.a,1)) as s2 + on true +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +ALIAS: "t4"="t" +ALIAS: "t5"="t" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t5" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM t t1 JOIN LATERAL (SELECT t1.a FROM (SELECT 1) foo OFFSET 0) s1..." +== 409 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 410 +-- truncate_limit: 100 +|-- +-- check a case in which a PlaceHolderVar forces join order +|-- + +explain (verbose, costs off) +select ss2.* from + int4_tbl i41 + left join int8_tbl i8 + join (select i42.f1 as c1, i43.f1 as c2, 42 as c3 + from int4_tbl i42, int4_tbl i43) ss1 + on i8.q1 = ss1.c2 + on i41.f1 = ss1.c1, + lateral (select i41.*, i8.*, ss1.* from text_tbl limit 1) ss2 +where ss1.c2 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i41"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i43"="int4_tbl" +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="ss1" column="c2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT ss2.* FROM int4_tbl i41 LEFT JOIN (int8_tbl i8 JOIN (SELECT i..." +== 411 +-- truncate_limit: 100 +select ss2.* from + int4_tbl i41 + left join int8_tbl i8 + join (select i42.f1 as c1, i43.f1 as c2, 42 as c3 + from int4_tbl i42, int4_tbl i43) ss1 + on i8.q1 = ss1.c2 + on i41.f1 = ss1.c1, + lateral (select i41.*, i8.*, ss1.* from text_tbl limit 1) ss2 +where ss1.c2 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +ALIAS: "i41"="int4_tbl" +ALIAS: "i42"="int4_tbl" +ALIAS: "i43"="int4_tbl" +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="ss1" column="c2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int4_tbl i41 LEFT JOIN (int8_tbl i8 JOIN (SELECT ... FROM int4_tbl i42, int4_tbl ..." +== 412 +-- truncate_limit: 100 +|-- +-- test successful handling of full join underneath left join (bug #14105) +|-- + +explain (costs off) +select * from + (select 1 as id) as xx + left join + (tenk1 as a1 full join (select 1 as id) as yy on (a1.unique1 = yy.id)) + on (xx.id = coalesce(yy.id)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a1"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT 1 AS id) xx LEFT JOIN (tenk1 a1 FULL JOIN (SELECT 1 AS ..." +== 413 +-- truncate_limit: 100 +select * from + (select 1 as id) as xx + left join + (tenk1 as a1 full join (select 1 as id) as yy on (a1.unique1 = yy.id)) + on (xx.id = coalesce(yy.id)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a1"="tenk1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ...) xx LEFT JOIN (tenk1 a1 FULL JOIN (SELECT ...) yy ON a1.unique1 = yy.id..." +== 414 +-- truncate_limit: 100 +|-- +-- test ability to push constants through outer join clauses +|-- + +explain (costs off) + select * from int4_tbl a left join tenk1 b on f1 = unique2 where f1 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl a LEFT JOIN tenk1 b ON f1 = unique2 WHERE f1 = 0" +== 415 +-- truncate_limit: 100 +explain (costs off) + select * from tenk1 a full join tenk1 b using(unique2) where unique2 = 42 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a FULL JOIN tenk1 b USING (unique2) WHERE unique2 = 42" +== 416 +-- truncate_limit: 100 +|-- +-- test that quals attached to an outer join have correct semantics, +-- specifically that they don't re-use expressions computed below the join; +-- we force a mergejoin so that coalesce(b.q1, 1) appears as a join input +|-- + +set enable_hashjoin to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 417 +-- truncate_limit: 100 +set enable_nestloop to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 418 +-- truncate_limit: 100 +explain (verbose, costs off) + select a.q2, b.q1 + from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1) + where coalesce(b.q1, 1) > 0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="b" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT a.q2, b.q1 FROM int8_tbl a LEFT JOIN int8_tbl b ON a.q2 = COA..." +== 419 +-- truncate_limit: 100 +select a.q2, b.q1 + from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1) + where coalesce(b.q1, 1) > 0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="b" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT a.q2, b.q1 FROM int8_tbl a LEFT JOIN int8_tbl b ON a.q2 = COALESCE(b.q1, 1) WHERE ..." +== 420 +-- truncate_limit: 100 +reset enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 421 +-- truncate_limit: 100 +reset enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 422 +-- truncate_limit: 100 +|-- +-- test join strength reduction with a SubPlan providing the proof +|-- + +explain (costs off) +select a.unique1, b.unique2 + from onek a left join onek b on a.unique1 = b.unique2 + where (b.unique2, random() > 0) = any (select q1, random() > 0 from int8_tbl c where c.q1 < b.unique1) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +ALIAS: "c"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="b" column="unique2" +FILTER: schema="" table="c" column="q1" +FILTER: schema="" table="b" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.unique1, b.unique2 FROM onek a LEFT JOIN onek b ON a.unique1 = b.uni..." +== 423 +-- truncate_limit: 100 +select a.unique1, b.unique2 + from onek a left join onek b on a.unique1 = b.unique2 + where (b.unique2, random() > 0) = any (select q1, random() > 0 from int8_tbl c where c.q1 < b.unique1) +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +ALIAS: "c"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="b" column="unique2" +FILTER: schema="" table="c" column="q1" +FILTER: schema="" table="b" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT a.unique1, b.unique2 FROM onek a LEFT JOIN onek b ON a.unique1 = b.unique2 WHERE ..." +== 424 +-- truncate_limit: 100 +|-- +-- test full-join strength reduction +|-- + +explain (costs off) +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where a.unique1 = 42 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="a" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.unique1, b.unique2 FROM onek a FULL JOIN onek b ON a.unique1 = b.uni..." +== 425 +-- truncate_limit: 100 +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where a.unique1 = 42 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="a" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek a FULL JOIN onek b ON a.unique1 = b.unique2 WHERE a.unique1 = 42" +== 426 +-- truncate_limit: 100 +explain (costs off) +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where b.unique2 = 43 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.unique1, b.unique2 FROM onek a FULL JOIN onek b ON a.unique1 = b.uni..." +== 427 +-- truncate_limit: 100 +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where b.unique2 = 43 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="b" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek a FULL JOIN onek b ON a.unique1 = b.unique2 WHERE b.unique2 = 43" +== 428 +-- truncate_limit: 100 +explain (costs off) +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where a.unique1 = 42 and b.unique2 = 42 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.unique1, b.unique2 FROM onek a FULL JOIN onek b ON a.unique1 = b.uni..." +== 429 +-- truncate_limit: 100 +select a.unique1, b.unique2 + from onek a full join onek b on a.unique1 = b.unique2 + where a.unique1 = 42 and b.unique2 = 42 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "a"="onek" +ALIAS: "b"="onek" +FILTER: schema="" table="a" column="unique1" +FILTER: schema="" table="b" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT a.unique1, b.unique2 FROM onek a FULL JOIN onek b ON a.unique1 = b.unique2 WHERE ..." +== 430 +-- truncate_limit: 100 +|-- +-- test result-RTE removal underneath a full join +|-- + +explain (costs off) +select * from + (select * from int8_tbl i81 join (values(123,2)) v(v1,v2) on q2=v1) ss1 +full join + (select * from (values(456,2)) w(v1,v2) join int8_tbl i82 on q2=v1) ss2 +on true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM int8_tbl i81 JOIN (VALUES (123, 2)) v(v1, v2) ON..." +== 431 +-- truncate_limit: 100 +select * from + (select * from int8_tbl i81 join (values(123,2)) v(v1,v2) on q2=v1) ss1 +full join + (select * from (values(456,2)) w(v1,v2) join int8_tbl i82 on q2=v1) ss2 +on true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM int8_tbl i81 JOIN (VALUES (...)) v(v1, v2) ON q2 = v1) ss1 FULL JOIN..." +== 432 +-- truncate_limit: 100 +|-- +-- test join removal +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 433 +-- truncate_limit: 100 +CREATE TEMP TABLE a (id int PRIMARY KEY, b_id int) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE a (id int PRIMARY KEY, b_id int)" +== 434 +-- truncate_limit: 100 +CREATE TEMP TABLE b (id int PRIMARY KEY, c_id int) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE b (id int PRIMARY KEY, c_id int)" +== 435 +-- truncate_limit: 100 +CREATE TEMP TABLE c (id int PRIMARY KEY) +-- +TABLE: name="c" schema="" table="c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE c (id int PRIMARY KEY)" +== 436 +-- truncate_limit: 100 +CREATE TEMP TABLE d (a int, b int) +-- +TABLE: name="d" schema="" table="d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE d (a int, b int)" +== 437 +-- truncate_limit: 100 +INSERT INTO a VALUES (0, 0), (1, NULL) +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a VALUES (0, 0), (1, NULL)" +== 438 +-- truncate_limit: 100 +INSERT INTO b VALUES (0, 0), (1, NULL) +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b VALUES (0, 0), (1, NULL)" +== 439 +-- truncate_limit: 100 +INSERT INTO c VALUES (0), (1) +-- +TABLE: name="c" schema="" table="c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO c VALUES (0), (1)" +== 440 +-- truncate_limit: 100 +INSERT INTO d VALUES (1,3), (2,2), (3,1) +-- +TABLE: name="d" schema="" table="d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO d VALUES (1, 3), (2, 2), (3, 1)" +== 441 +-- truncate_limit: 100 +-- all three cases should be optimizable into a simple seqscan +explain (costs off) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id" +== 442 +-- truncate_limit: 100 +explain (costs off) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="c" schema="" table="c" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id" +== 443 +-- truncate_limit: 100 +explain (costs off) + SELECT a.* FROM a LEFT JOIN (b left join c on b.c_id = c.id) + ON (a.b_id = b.id) +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="c" schema="" table="c" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.* FROM a LEFT JOIN (b LEFT JOIN c ON b.c_id = c.id) ON a.b_id = b.id" +== 444 +-- truncate_limit: 100 +-- check optimization of outer join within another special join +explain (costs off) +select id from a where id in ( + select b.id from b left join c on b.id = c.id +) +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="c" schema="" table="c" ctx=Select +FILTER: schema="" table="" column="id" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT id FROM a WHERE id IN (SELECT b.id FROM b LEFT JOIN c ON b.id = c.id)" +== 445 +-- truncate_limit: 100 +-- check optimization with oddly-nested outer joins +explain (costs off) +select a1.id from + (a a1 left join a a2 on true) + left join + (a a3 left join a a4 on a3.id = a4.id) + on a2.id = a3.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "a1"="a" +ALIAS: "a2"="a" +ALIAS: "a3"="a" +ALIAS: "a4"="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a1.id FROM a a1 LEFT JOIN a a2 ON true LEFT JOIN (a a3 LEFT JOIN a a4 ..." +== 446 +-- truncate_limit: 100 +explain (costs off) +select a1.id from + (a a1 left join a a2 on a1.id = a2.id) + left join + (a a3 left join a a4 on a3.id = a4.id) + on a2.id = a3.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "a1"="a" +ALIAS: "a2"="a" +ALIAS: "a3"="a" +ALIAS: "a4"="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a1.id FROM a a1 LEFT JOIN a a2 ON a1.id = a2.id LEFT JOIN (a a3 LEFT J..." +== 447 +-- truncate_limit: 100 +explain (costs off) +select 1 from a t1 + left join a t2 on true + inner join a t3 on true + left join a t4 on t2.id = t4.id and t2.id = t3.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "t1"="a" +ALIAS: "t2"="a" +ALIAS: "t3"="a" +ALIAS: "t4"="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM a t1 LEFT JOIN a t2 ON true JOIN a t3 ON true LEFT JOIN a t4 ON..." +== 448 +-- truncate_limit: 100 +-- another example (bug #17781) +explain (costs off) +select ss1.f1 +from int4_tbl as t1 + left join (int4_tbl as t2 + right join int4_tbl as t3 on null + left join (int4_tbl as t4 + right join int8_tbl as t5 on null) + on t2.f1 = t4.f1 + left join ((select null as f1 from int4_tbl as t6) as ss1 + inner join int8_tbl as t7 on null) + on t5.q1 = t7.q2) + on false +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +ALIAS: "t5"="int8_tbl" +ALIAS: "t6"="int4_tbl" +ALIAS: "t7"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ss1.f1 FROM int4_tbl t1 LEFT JOIN (int4_tbl t2 RIGHT JOIN int4_tbl t3 ..." +== 449 +-- truncate_limit: 100 +-- variant with Var rather than PHV coming from t6 +explain (costs off) +select ss1.f1 +from int4_tbl as t1 + left join (int4_tbl as t2 + right join int4_tbl as t3 on null + left join (int4_tbl as t4 + right join int8_tbl as t5 on null) + on t2.f1 = t4.f1 + left join ((select f1 from int4_tbl as t6) as ss1 + inner join int8_tbl as t7 on null) + on t5.q1 = t7.q2) + on false +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +ALIAS: "t5"="int8_tbl" +ALIAS: "t6"="int4_tbl" +ALIAS: "t7"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ss1.f1 FROM int4_tbl t1 LEFT JOIN (int4_tbl t2 RIGHT JOIN int4_tbl t3 ..." +== 450 +-- truncate_limit: 100 +-- per further discussion of bug #17781 +explain (costs off) +select ss1.x +from (select f1/2 as x from int4_tbl i4 left join a on a.id = i4.f1) ss1 + right join int8_tbl i8 on true +where current_user is not null +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ss1.x FROM (SELECT f1 / 2 AS x FROM int4_tbl i4 LEFT JOIN a ON a.id = ..." +== 451 +-- truncate_limit: 100 +-- this is to add a Result node + +-- and further discussion of bug #17781 +explain (costs off) +select * +from int8_tbl t1 + left join (int8_tbl t2 left join onek t3 on t2.q1 > t3.unique1) + on t1.q2 = t2.q2 + left join onek t4 + on t2.q2 < t3.unique2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="onek" +ALIAS: "t4"="onek" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN (int8_tbl t2 LEFT JOIN onek t3 ON t2.q1 >..." +== 452 +-- truncate_limit: 100 +-- More tests of correct placement of pseudoconstant quals + +-- simple constant-false condition +explain (costs off) +select * from int8_tbl t1 left join + (int8_tbl t2 inner join int8_tbl t3 on false + left join int8_tbl t4 on t2.q2 = t4.q2) +on t1.q1 = t2.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +ALIAS: "t4"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN (int8_tbl t2 JOIN int8_tbl t3 ON false LE..." +== 453 +-- truncate_limit: 100 +-- deduce constant-false from an EquivalenceClass +explain (costs off) +select * from int8_tbl t1 left join + (int8_tbl t2 inner join int8_tbl t3 on (t2.q1-t3.q2) = 0 and (t2.q1-t3.q2) = 1 + left join int8_tbl t4 on t2.q2 = t4.q2) +on t1.q1 = t2.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +ALIAS: "t4"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl t1 LEFT JOIN (int8_tbl t2 JOIN int8_tbl t3 ON (t2.q1 -..." +== 454 +-- truncate_limit: 100 +-- pseudoconstant based on an outer-level Param +explain (costs off) +select exists( + select * from int8_tbl t1 left join + (int8_tbl t2 inner join int8_tbl t3 on x0.f1 = 1 + left join int8_tbl t4 on t2.q2 = t4.q2) + on t1.q1 = t2.q1 +) from int4_tbl x0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +ALIAS: "t4"="int8_tbl" +ALIAS: "x0"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT EXISTS (SELECT * FROM int8_tbl t1 LEFT JOIN (int8_tbl t2 JOIN int8_tbl..." +== 455 +-- truncate_limit: 100 +-- check that join removal works for a left join when joining a subquery +-- that is guaranteed to be unique by its GROUP BY clause +explain (costs off) +select d.* from d left join (select * from b group by b.id, b.c_id) s + on d.a = s.id and d.b = s.c_id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT d.* FROM d LEFT JOIN (SELECT * FROM b GROUP BY b.id, b.c_id) s ON d.a ..." +== 456 +-- truncate_limit: 100 +-- similarly, but keying off a DISTINCT clause +explain (costs off) +select d.* from d left join (select distinct * from b) s + on d.a = s.id and d.b = s.c_id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT d.* FROM d LEFT JOIN (SELECT DISTINCT * FROM b) s ON d.a = s.id AND d...." +== 457 +-- truncate_limit: 100 +-- join removal is not possible when the GROUP BY contains a column that is +-- not in the join condition. (Note: as of 9.6, we notice that b.id is a +-- primary key and so drop b.c_id from the GROUP BY of the resulting plan; +-- but this happens too late for join removal in the outer plan level.) +explain (costs off) +select d.* from d left join (select * from b group by b.id, b.c_id) s + on d.a = s.id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT d.* FROM d LEFT JOIN (SELECT * FROM b GROUP BY b.id, b.c_id) s ON d.a ..." +== 458 +-- truncate_limit: 100 +-- similarly, but keying off a DISTINCT clause +explain (costs off) +select d.* from d left join (select distinct * from b) s + on d.a = s.id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT d.* FROM d LEFT JOIN (SELECT DISTINCT * FROM b) s ON d.a = s.id" +== 459 +-- truncate_limit: 100 +-- join removal is not possible here +explain (costs off) +select 1 from a t1 + left join (a t2 left join a t3 on t2.id = 1) on t2.id = 1 +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +ALIAS: "t1"="a" +ALIAS: "t2"="a" +ALIAS: "t3"="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM a t1 LEFT JOIN (a t2 LEFT JOIN a t3 ON t2.id = 1) ON t2.id = 1" +== 460 +-- truncate_limit: 100 +-- check join removal works when uniqueness of the join condition is enforced +-- by a UNION +explain (costs off) +select d.* from d left join (select id from a union select id from b) s + on d.a = s.id +-- +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT d.* FROM d LEFT JOIN (SELECT id FROM a UNION SELECT id FROM b) s ON d...." +== 461 +-- truncate_limit: 100 +-- check join removal with a cross-type comparison operator +explain (costs off) +select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4 + on i8.q1 = i4.f1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT i8.* FROM int8_tbl i8 LEFT JOIN (SELECT f1 FROM int4_tbl GROUP BY f1) ..." +== 462 +-- truncate_limit: 100 +-- check join removal with lateral references +explain (costs off) +select 1 from (select a.id FROM a left join b on a.b_id = b.id) q, + lateral generate_series(1, q.id) gs(i) where q.id = gs.i +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="q" column="id" +FILTER: schema="" table="gs" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM (SELECT a.id FROM a LEFT JOIN b ON a.b_id = b.id) q, LATERAL ge..." +== 463 +-- truncate_limit: 100 +-- check join removal within RHS of an outer join +explain (costs off) +select c.id, ss.a from c + left join (select d.a from onerow, d left join b on d.a = b.id) ss + on c.id = ss.a +-- +TABLE: name="c" schema="" table="c" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +TABLE: name="d" schema="" table="d" ctx=Select +TABLE: name="b" schema="" table="b" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c.id, ss.a FROM c LEFT JOIN (SELECT d.a FROM onerow, d LEFT JOIN b ON ..." +== 464 +-- truncate_limit: 100 +CREATE TEMP TABLE parted_b (id int PRIMARY KEY) partition by range(id) +-- +TABLE: name="parted_b" schema="" table="parted_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parted_b (id int PRIMARY KEY) PARTITION BY RANGE (id)" +== 465 +-- truncate_limit: 100 +CREATE TEMP TABLE parted_b1 partition of parted_b for values from (0) to (10) +-- +TABLE: name="parted_b1" schema="" table="parted_b1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parted_b1 PARTITION OF parted_b FOR VALUES FROM (0) TO (10)" +== 466 +-- truncate_limit: 100 +-- test join removals on a partitioned table +explain (costs off) +select a.* from a left join parted_b pb on a.b_id = pb.id +-- +TABLE: name="a" schema="" table="a" ctx=Select +TABLE: name="parted_b" schema="" table="parted_b" ctx=Select +ALIAS: "pb"="parted_b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.* FROM a LEFT JOIN parted_b pb ON a.b_id = pb.id" +== 467 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 468 +-- truncate_limit: 100 +create temp table parent (k int primary key, pd int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parent (k int PRIMARY KEY, pd int)" +== 469 +-- truncate_limit: 100 +create temp table child (k int unique, cd int) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE child (k int UNIQUE, cd int)" +== 470 +-- truncate_limit: 100 +insert into parent values (1, 10), (2, 20), (3, 30) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES (1, 10), (2, 20), (3, 30)" +== 471 +-- truncate_limit: 100 +insert into child values (1, 100), (4, 400) +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child VALUES (1, 100), (4, 400)" +== 472 +-- truncate_limit: 100 +-- this case is optimizable +select p.* from parent p left join child c on (p.k = c.k) +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM parent p LEFT JOIN child c ON p.k = c.k" +== 473 +-- truncate_limit: 100 +explain (costs off) + select p.* from parent p left join child c on (p.k = c.k) +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p.* FROM parent p LEFT JOIN child c ON p.k = c.k" +== 474 +-- truncate_limit: 100 +-- this case is not +select p.*, linked from parent p + left join (select c.*, true as linked from child c) as ss + on (p.k = ss.k) +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +STMT: SelectStmt +TRUNCATED: "SELECT p.*, linked FROM parent p LEFT JOIN (SELECT ... FROM child c) ss ON p.k = ss.k" +== 475 +-- truncate_limit: 100 +explain (costs off) + select p.*, linked from parent p + left join (select c.*, true as linked from child c) as ss + on (p.k = ss.k) +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p.*, linked FROM parent p LEFT JOIN (SELECT c.*, true AS linked FROM c..." +== 476 +-- truncate_limit: 100 +-- check for a 9.0rc1 bug: join removal breaks pseudoconstant qual handling +select p.* from + parent p left join child c on (p.k = c.k) + where p.k = 1 and p.k = 2 +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +FILTER: schema="" table="p" column="k" +FILTER: schema="" table="p" column="k" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM parent p LEFT JOIN child c ON p.k = c.k WHERE p.k = 1 AND p.k = 2" +== 477 +-- truncate_limit: 100 +explain (costs off) +select p.* from + parent p left join child c on (p.k = c.k) + where p.k = 1 and p.k = 2 +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +FILTER: schema="" table="p" column="k" +FILTER: schema="" table="p" column="k" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p.* FROM parent p LEFT JOIN child c ON p.k = c.k WHERE p.k = 1 AND p.k..." +== 478 +-- truncate_limit: 100 +select p.* from + (parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k + where p.k = 1 and p.k = 2 +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +TABLE: name="parent" schema="" table="parent" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +ALIAS: "x"="parent" +FILTER: schema="" table="p" column="k" +FILTER: schema="" table="p" column="k" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM parent p LEFT JOIN child c ON p.k = c.k JOIN parent x ON p.k = x.k WHERE ..." +== 479 +-- truncate_limit: 100 +explain (costs off) +select p.* from + (parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k + where p.k = 1 and p.k = 2 +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +TABLE: name="child" schema="" table="child" ctx=Select +TABLE: name="parent" schema="" table="parent" ctx=Select +ALIAS: "c"="child" +ALIAS: "p"="parent" +ALIAS: "x"="parent" +FILTER: schema="" table="p" column="k" +FILTER: schema="" table="p" column="k" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT p.* FROM parent p LEFT JOIN child c ON p.k = c.k JOIN parent x ON p.k ..." +== 480 +-- truncate_limit: 100 +-- bug 5255: this is not optimizable by join removal +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 481 +-- truncate_limit: 100 +CREATE TEMP TABLE a (id int PRIMARY KEY) +-- +TABLE: name="a" schema="" table="a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE a (id int PRIMARY KEY)" +== 482 +-- truncate_limit: 100 +CREATE TEMP TABLE b (id int PRIMARY KEY, a_id int) +-- +TABLE: name="b" schema="" table="b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE b (id int PRIMARY KEY, a_id int)" +== 483 +-- truncate_limit: 100 +INSERT INTO a VALUES (0), (1) +-- +TABLE: name="a" schema="" table="a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO a VALUES (0), (1)" +== 484 +-- truncate_limit: 100 +INSERT INTO b VALUES (0, 0), (1, NULL) +-- +TABLE: name="b" schema="" table="b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b VALUES (0, 0), (1, NULL)" +== 485 +-- truncate_limit: 100 +SELECT * FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0) +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="a" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM b LEFT JOIN a ON b.a_id = a.id WHERE a.id IS NULL OR a.id > 0" +== 486 +-- truncate_limit: 100 +SELECT b.* FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0) +-- +TABLE: name="b" schema="" table="b" ctx=Select +TABLE: name="a" schema="" table="a" ctx=Select +FILTER: schema="" table="a" column="id" +FILTER: schema="" table="a" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT b.* FROM b LEFT JOIN a ON b.a_id = a.id WHERE a.id IS NULL OR a.id > 0" +== 487 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 488 +-- truncate_limit: 100 +-- another join removal bug: this is not optimizable, either +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 489 +-- truncate_limit: 100 +create temp table innertab (id int8 primary key, dat1 int8) +-- +TABLE: name="innertab" schema="" table="innertab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE innertab (id int8 PRIMARY KEY, dat1 int8)" +== 490 +-- truncate_limit: 100 +insert into innertab values(123, 42) +-- +TABLE: name="innertab" schema="" table="innertab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO innertab VALUES (123, 42)" +== 491 +-- truncate_limit: 100 +SELECT * FROM + (SELECT 1 AS x) ss1 + LEFT JOIN + (SELECT q1, q2, COALESCE(dat1, q1) AS y + FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss2 + ON true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="innertab" schema="" table="innertab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ...) ss1 LEFT JOIN (SELECT ... FROM int8_tbl LEFT JOIN innertab ON q2 = id)..." +== 492 +-- truncate_limit: 100 +-- join removal bug #17769: can't remove if there's a pushed-down reference +EXPLAIN (COSTS OFF) +SELECT q2 FROM + (SELECT * + FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss + WHERE COALESCE(dat1, 0) = q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="innertab" schema="" table="innertab" ctx=Select +FILTER: schema="" table="" column="dat1" +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT q2 FROM (SELECT * FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss WHER..." +== 493 +-- truncate_limit: 100 +-- join removal bug #17773: otherwise-removable PHV appears in a qual condition +EXPLAIN (VERBOSE, COSTS OFF) +SELECT q2 FROM + (SELECT q2, 'constant'::text AS x + FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss + RIGHT JOIN int4_tbl ON NULL + WHERE x >= x +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="innertab" schema="" table="innertab" ctx=Select +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT q2 FROM (SELECT q2, 'constant'::text AS x FROM int8_tbl LEFT ..." +== 494 +-- truncate_limit: 100 +-- join removal bug #17786: check that OR conditions are cleaned up +EXPLAIN (COSTS OFF) +SELECT f1, x +FROM int4_tbl + JOIN ((SELECT 42 AS x FROM int8_tbl LEFT JOIN innertab ON q1 = id) AS ss1 + RIGHT JOIN tenk1 ON NULL) + ON tenk1.unique1 = ss1.x OR tenk1.unique2 = ss1.x +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="innertab" schema="" table="innertab" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT f1, x FROM int4_tbl JOIN ((SELECT 42 AS x FROM int8_tbl LEFT JOIN inne..." +== 495 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 496 +-- truncate_limit: 100 +-- another join removal bug: we must clean up correctly when removing a PHV +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 497 +-- truncate_limit: 100 +create temp table uniquetbl (f1 text unique) +-- +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE uniquetbl (f1 text UNIQUE)" +== 498 +-- truncate_limit: 100 +explain (costs off) +select t1.* from + uniquetbl as t1 + left join (select *, '***'::text as d1 from uniquetbl) t2 + on t1.f1 = t2.f1 + left join uniquetbl t3 + on t2.d1 = t3.f1 +-- +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +ALIAS: "t1"="uniquetbl" +ALIAS: "t3"="uniquetbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM uniquetbl t1 LEFT JOIN (SELECT *, '***'::text AS d1 FROM uni..." +== 499 +-- truncate_limit: 100 +explain (costs off) +select t0.* +from + text_tbl t0 + left join + (select case t1.ten when 0 then 'doh!'::text else null::text end as case1, + t1.stringu2 + from tenk1 t1 + join int4_tbl i4 ON i4.f1 = t1.unique2 + left join uniquetbl u1 ON u1.f1 = t1.string4) ss + on t0.f1 = ss.case1 +where ss.stringu2 !~* ss.case1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "t0"="text_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "u1"="uniquetbl" +FILTER: schema="" table="ss" column="stringu2" +FILTER: schema="" table="ss" column="case1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t0.* FROM text_tbl t0 LEFT JOIN (SELECT CASE t1.ten WHEN 0 THEN 'doh!'..." +== 500 +-- truncate_limit: 100 +select t0.* +from + text_tbl t0 + left join + (select case t1.ten when 0 then 'doh!'::text else null::text end as case1, + t1.stringu2 + from tenk1 t1 + join int4_tbl i4 ON i4.f1 = t1.unique2 + left join uniquetbl u1 ON u1.f1 = t1.string4) ss + on t0.f1 = ss.case1 +where ss.stringu2 !~* ss.case1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="uniquetbl" schema="" table="uniquetbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "t0"="text_tbl" +ALIAS: "t1"="tenk1" +ALIAS: "u1"="uniquetbl" +FILTER: schema="" table="ss" column="stringu2" +FILTER: schema="" table="ss" column="case1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM text_tbl t0 LEFT JOIN (SELECT ... FROM tenk1 t1 JOIN int4_tbl i4 ON i4.f1 = t1.un..." +== 501 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 502 +-- truncate_limit: 100 +-- another join removal bug: we must clean up EquivalenceClasses too +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 503 +-- truncate_limit: 100 +create temp table t (a int unique) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t (a int UNIQUE)" +== 504 +-- truncate_limit: 100 +insert into t values (1) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1)" +== 505 +-- truncate_limit: 100 +explain (costs off) +select 1 +from t t1 + left join (select 2 as c + from t t2 left join t t3 on t2.a = t3.a) s + on true +where t1.a = s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM t t1 LEFT JOIN (SELECT 2 AS c FROM t t2 LEFT JOIN t t3 ON t2.a ..." +== 506 +-- truncate_limit: 100 +select 1 +from t t1 + left join (select 2 as c + from t t2 left join t t3 on t2.a = t3.a) s + on true +where t1.a = s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="s" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM t t1 LEFT JOIN (SELECT ... FROM t t2 LEFT JOIN t t3 ON t2.a = t3.a) s ON true WHERE..." +== 507 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 508 +-- truncate_limit: 100 +-- test cases where we can remove a join, but not a PHV computed at it +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 509 +-- truncate_limit: 100 +create temp table t (a int unique, b int) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t (a int UNIQUE, b int)" +== 510 +-- truncate_limit: 100 +insert into t values (1,1), (2,2) +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1, 1), (2, 2)" +== 511 +-- truncate_limit: 100 +explain (costs off) +select 1 +from t t1 + left join (select t2.a, 1 as c + from t t2 left join t t3 on t2.a = t3.a) s + on true + left join t t4 on true +where s.a < s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +ALIAS: "t4"="t" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM t t1 LEFT JOIN (SELECT t2.a, 1 AS c FROM t t2 LEFT JOIN t t3 ON..." +== 512 +-- truncate_limit: 100 +explain (costs off) +select t1.a, s.* +from t t1 + left join lateral (select t2.a, coalesce(t1.a, 1) as c + from t t2 left join t t3 on t2.a = t3.a) s + on true + left join t t4 on true +where s.a < s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +ALIAS: "t4"="t" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, s.* FROM t t1 LEFT JOIN LATERAL (SELECT t2.a, COALESCE(t1.a, 1) ..." +== 513 +-- truncate_limit: 100 +select t1.a, s.* +from t t1 + left join lateral (select t2.a, coalesce(t1.a, 1) as c + from t t2 left join t t3 on t2.a = t3.a) s + on true + left join t t4 on true +where s.a < s.c +-- +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +TABLE: name="t" schema="" table="t" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +ALIAS: "t3"="t" +ALIAS: "t4"="t" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t t1 LEFT JOIN LATERAL (SELECT ... FROM t t2 LEFT JOIN t t3 ON t2.a = t3.a) s ON ..." +== 514 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 515 +-- truncate_limit: 100 +-- test case to expose miscomputation of required relid set for a PHV +explain (verbose, costs off) +select i8.*, ss.v, t.unique2 + from int8_tbl i8 + left join int4_tbl i4 on i4.f1 = 1 + left join lateral (select i4.f1 + 1 as v) as ss on true + left join tenk1 t on t.unique2 = ss.v +where q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="tenk1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT i8.*, ss.v, t.unique2 FROM int8_tbl i8 LEFT JOIN int4_tbl i4 ..." +== 516 +-- truncate_limit: 100 +select i8.*, ss.v, t.unique2 + from int8_tbl i8 + left join int4_tbl i4 on i4.f1 = 1 + left join lateral (select i4.f1 + 1 as v) as ss on true + left join tenk1 t on t.unique2 = ss.v +where q2 = 456 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="tenk1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl i8 LEFT JOIN int4_tbl i4 ON i4.f1 = 1 LEFT JOIN LATERAL (SELECT ...) ss ..." +== 517 +-- truncate_limit: 100 +-- and check a related issue where we miscompute required relids for +-- a PHV that's been translated to a child rel +create temp table parttbl (a integer primary key) partition by range (a) +-- +TABLE: name="parttbl" schema="" table="parttbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parttbl (a int PRIMARY KEY) PARTITION BY RANGE (a)" +== 518 +-- truncate_limit: 100 +create temp table parttbl1 partition of parttbl for values from (1) to (100) +-- +TABLE: name="parttbl1" schema="" table="parttbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parttbl1 PARTITION OF parttbl FOR VALUES FROM (1) TO (100)" +== 519 +-- truncate_limit: 100 +insert into parttbl values (11), (12) +-- +TABLE: name="parttbl" schema="" table="parttbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parttbl VALUES (11), (12)" +== 520 +-- truncate_limit: 100 +explain (costs off) +select * from + (select *, 12 as phv from parttbl) as ss + right join int4_tbl on true +where ss.a = ss.phv and f1 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="parttbl" schema="" table="parttbl" ctx=Select +FILTER: schema="" table="ss" column="a" +FILTER: schema="" table="ss" column="phv" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT *, 12 AS phv FROM parttbl) ss RIGHT JOIN int4_tbl ON tr..." +== 521 +-- truncate_limit: 100 +select * from + (select *, 12 as phv from parttbl) as ss + right join int4_tbl on true +where ss.a = ss.phv and f1 = 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="parttbl" schema="" table="parttbl" ctx=Select +FILTER: schema="" table="ss" column="a" +FILTER: schema="" table="ss" column="phv" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM parttbl) ss RIGHT JOIN int4_tbl ON true WHERE ..." +== 522 +-- truncate_limit: 100 +-- bug #8444: we've historically allowed duplicate aliases within aliased JOINs + +select * from + int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = f1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "x"="int4_tbl" +ALIAS: "y"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl x JOIN (int4_tbl x CROSS JOIN int4_tbl y ) j ON q1 = f1" +== 523 +-- truncate_limit: 100 +-- error +select * from + int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = y.f1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "x"="int4_tbl" +ALIAS: "y"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl x JOIN (int4_tbl x CROSS JOIN int4_tbl y ) j ON q1 = y.f1" +== 524 +-- truncate_limit: 100 +-- error +select * from + int8_tbl x join (int4_tbl x cross join int4_tbl y(ff)) j on q1 = f1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "x"="int4_tbl" +ALIAS: "y"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl x JOIN (int4_tbl x CROSS JOIN int4_tbl y(ff) ) j ON q1 = f1" +== 525 +-- truncate_limit: 100 +-- ok + +|-- +-- Test hints given on incorrect column references are useful +|-- + +select t1.uunique1 from + tenk1 t1 join tenk2 t2 on t1.two = t2.two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: SelectStmt +TRUNCATED: "SELECT t1.uunique1 FROM tenk1 t1 JOIN tenk2 t2 ON t1.two = t2.two" +== 526 +-- truncate_limit: 100 +-- error, prefer "t1" suggestion +select t2.uunique1 from + tenk1 t1 join tenk2 t2 on t1.two = t2.two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: SelectStmt +TRUNCATED: "SELECT t2.uunique1 FROM tenk1 t1 JOIN tenk2 t2 ON t1.two = t2.two" +== 527 +-- truncate_limit: 100 +-- error, prefer "t2" suggestion +select uunique1 from + tenk1 t1 join tenk2 t2 on t1.two = t2.two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: SelectStmt +TRUNCATED: "SELECT uunique1 FROM tenk1 t1 JOIN tenk2 t2 ON t1.two = t2.two" +== 528 +-- truncate_limit: 100 +-- error, suggest both at once +select ctid from + tenk1 t1 join tenk2 t2 on t1.two = t2.two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tenk1 t1 JOIN tenk2 t2 ON t1.two = t2.two" +== 529 +-- truncate_limit: 100 +-- error, need qualification + +|-- +-- Take care to reference the correct RTE +|-- + +select atts.relid::regclass, s.* from pg_stats s join + pg_attribute a on s.attname = a.attname and s.tablename = + a.attrelid::regclass::text join (select unnest(indkey) attnum, + indexrelid from pg_index i) atts on atts.attnum = a.attnum where + schemaname != 'pg_catalog' +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "i"="pg_index" +ALIAS: "s"="pg_stats" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stats s JOIN pg_attribute a ON s.attname = a.attname AND s.tablename = a.attre..." +== 530 +-- truncate_limit: 100 +-- Test bug in rangetable flattening +explain (verbose, costs off) +select 1 from + (select * from int8_tbl where q1 <> (select 42) offset 0) ss +where false +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT 1 FROM (SELECT * FROM int8_tbl WHERE q1 <> (SELECT 42) OFFSET..." +== 531 +-- truncate_limit: 100 +|-- +-- Test LATERAL +|-- + +select unique2, x.* +from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="a" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique2, x.* FROM tenk1 a, LATERAL (SELECT * FROM int4_tbl b WHERE f1 = a.unique1) x" +== 532 +-- truncate_limit: 100 +explain (costs off) + select unique2, x.* + from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="a" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2, x.* FROM tenk1 a, LATERAL (SELECT * FROM int4_tbl b WHERE f1 ..." +== 533 +-- truncate_limit: 100 +select unique2, x.* +from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique2, x.* FROM int4_tbl x, LATERAL (SELECT unique2 FROM tenk1 WHERE f1 = unique1) ss" +== 534 +-- truncate_limit: 100 +explain (costs off) + select unique2, x.* + from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2, x.* FROM int4_tbl x, LATERAL (SELECT unique2 FROM tenk1 WHERE..." +== 535 +-- truncate_limit: 100 +explain (costs off) + select unique2, x.* + from int4_tbl x cross join lateral (select unique2 from tenk1 where f1 = unique1) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2, x.* FROM int4_tbl x CROSS JOIN LATERAL (SELECT unique2 FROM t..." +== 536 +-- truncate_limit: 100 +select unique2, x.* +from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique2, x.* FROM int4_tbl x LEFT JOIN LATERAL (SELECT ... FROM tenk1 WHERE ...) ss ON true" +== 537 +-- truncate_limit: 100 +explain (costs off) + select unique2, x.* + from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "x"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2, x.* FROM int4_tbl x LEFT JOIN LATERAL (SELECT unique1, unique..." +== 538 +-- truncate_limit: 100 +-- check scoping of lateral versus parent references +-- the first of these should return int8_tbl.q2, the second int8_tbl.q1 +select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT *, (SELECT r FROM (SELECT q1 AS q2) x, (SELECT q2 AS r) y) FROM int8_tbl" +== 539 +-- truncate_limit: 100 +select *, (select r from (select q1 as q2) x, lateral (select q2 as r) y) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT *, (SELECT r FROM (SELECT q1 AS q2) x, LATERAL (SELECT q2 AS r) y) FROM int8_tbl" +== 540 +-- truncate_limit: 100 +-- lateral with function in FROM +select count(*) from tenk1 a, lateral generate_series(1,two) g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 a, LATERAL generate_series(1, two) g" +== 541 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1 a, lateral generate_series(1,two) g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 a, LATERAL generate_series(1, two) g" +== 542 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1 a cross join lateral generate_series(1,two) g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 a CROSS JOIN LATERAL generate_series(1, two) g" +== 543 +-- truncate_limit: 100 +-- don't need the explicit LATERAL keyword for functions +explain (costs off) + select count(*) from tenk1 a, generate_series(1,two) g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 a, generate_series(1, two) g" +== 544 +-- truncate_limit: 100 +-- lateral with UNION ALL subselect +explain (costs off) + select * from generate_series(100,200) g, + lateral (select * from int8_tbl a where g = q1 union all + select * from int8_tbl b where g = q2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="g" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="g" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM generate_series(100, 200) g, LATERAL (SELECT * FROM int8_tbl a ..." +== 545 +-- truncate_limit: 100 +select * from generate_series(100,200) g, + lateral (select * from int8_tbl a where g = q1 union all + select * from int8_tbl b where g = q2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="g" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="g" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(100, 200) g, LATERAL (SELECT * FROM int8_tbl a WHERE ... UNION ALL ..." +== 546 +-- truncate_limit: 100 +-- lateral with VALUES +explain (costs off) + select count(*) from tenk1 a, + tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 a, tenk1 b JOIN LATERAL (VALUES (a.unique1)) ss(x)..." +== 547 +-- truncate_limit: 100 +select count(*) from tenk1 a, + tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 a, tenk1 b JOIN LATERAL (VALUES (a.unique1)) ss(x) ON b.unique2 = ss.x" +== 548 +-- truncate_limit: 100 +-- lateral with VALUES, no flattening possible +explain (costs off) + select count(*) from tenk1 a, + tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 a, tenk1 b JOIN LATERAL (VALUES (a.unique1), (-1))..." +== 549 +-- truncate_limit: 100 +select count(*) from tenk1 a, + tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 a, tenk1 b JOIN LATERAL (VALUES (...)) ss(x) ON b.unique2 = ss.x" +== 550 +-- truncate_limit: 100 +-- lateral injecting a strange outer join condition +explain (costs off) + select * from int8_tbl a, + int8_tbl x left join lateral (select a.q1 from int4_tbl y) ss(z) + on x.q2 = ss.z + order by a.q1, a.q2, x.q1, x.q2, ss.z +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "x"="int8_tbl" +ALIAS: "y"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl a, int8_tbl x LEFT JOIN LATERAL (SELECT a.q1 FROM int4..." +== 551 +-- truncate_limit: 100 +select * from int8_tbl a, + int8_tbl x left join lateral (select a.q1 from int4_tbl y) ss(z) + on x.q2 = ss.z + order by a.q1, a.q2, x.q1, x.q2, ss.z +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "x"="int8_tbl" +ALIAS: "y"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl a, int8_tbl x LEFT JOIN LATERAL (SELECT ... FROM int4_tbl y) ss(z) ON x.q2..." +== 552 +-- truncate_limit: 100 +-- lateral reference to a join alias variable +select * from (select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1, + lateral (select x) ss2(y) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM int4_tbl) ss1 JOIN int4_tbl i4 ON x = f1, LATERAL (SELECT x) ss2(y)" +== 553 +-- truncate_limit: 100 +select * from (select f1 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1, + lateral (values(x)) ss2(y) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM int4_tbl) ss1 JOIN int4_tbl i4 ON x = f1, LATERAL (VALUES (x)) ss2(y)" +== 554 +-- truncate_limit: 100 +select * from ((select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1) j, + lateral (select x) ss2(y) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ((SELECT ... FROM int4_tbl) ss1 JOIN int4_tbl i4 ON x = f1 ) j, LATERAL (SELECT x) ..." +== 555 +-- truncate_limit: 100 +-- lateral references requiring pullup +select * from (values(1)) x(lb), + lateral generate_series(lb,4) x4 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1)) x(lb), LATERAL generate_series(lb, 4) x4" +== 556 +-- truncate_limit: 100 +select * from (select f1/1000000000 from int4_tbl) x(lb), + lateral generate_series(lb,4) x4 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT f1 / 1000000000 FROM int4_tbl) x(lb), LATERAL generate_series(lb, 4) x4" +== 557 +-- truncate_limit: 100 +select * from (values(1)) x(lb), + lateral (values(lb)) y(lbcopy) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1)) x(lb), LATERAL (VALUES (lb)) y(lbcopy)" +== 558 +-- truncate_limit: 100 +select * from (values(1)) x(lb), + lateral (select lb from int4_tbl) y(lbcopy) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1)) x(lb), LATERAL (SELECT lb FROM int4_tbl) y(lbcopy)" +== 559 +-- truncate_limit: 100 +select * from + int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1, + lateral (values(x.q1,y.q1,y.q2)) v(xq1,yq1,yq2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl x LEFT JOIN (SELECT ... FROM int8_tbl) y ON x.q2 = y.q1, LATERAL (VALUES (..." +== 560 +-- truncate_limit: 100 +select * from + int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1, + lateral (select x.q1,y.q1,y.q2) v(xq1,yq1,yq2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl x LEFT JOIN (SELECT ... FROM int8_tbl) y ON x.q2 = y.q1, LATERAL (SELECT ...." +== 561 +-- truncate_limit: 100 +select x.* from + int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1, + lateral (select x.q1,y.q1,y.q2) v(xq1,yq1,yq2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT x.* FROM int8_tbl x LEFT JOIN (SELECT ... FROM int8_tbl) y ON x.q2 = y.q1, LATERAL (SELECT..." +== 562 +-- truncate_limit: 100 +select v.* from + (int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1) + left join int4_tbl z on z.f1 = x.q2, + lateral (select x.q1,y.q1 union all select x.q2,y.q2) v(vx,vy) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +ALIAS: "z"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT v.* FROM int8_tbl x LEFT JOIN (SELECT ... FROM int8_tbl) y ON x.q2 = y.q1 LEFT JOIN int4_t..." +== 563 +-- truncate_limit: 100 +select v.* from + (int8_tbl x left join (select q1,(select coalesce(q2,0)) q2 from int8_tbl) y on x.q2 = y.q1) + left join int4_tbl z on z.f1 = x.q2, + lateral (select x.q1,y.q1 union all select x.q2,y.q2) v(vx,vy) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "x"="int8_tbl" +ALIAS: "z"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT v.* FROM int8_tbl x LEFT JOIN (SELECT ... FROM int8_tbl) y ON x.q2 = y.q1 LEFT JOIN int4_t..." +== 564 +-- truncate_limit: 100 +select v.* from + (int8_tbl x left join (select q1,(select coalesce(q2,0)) q2 from int8_tbl) y on x.q2 = y.q1) + left join int4_tbl z on z.f1 = x.q2, + lateral (select x.q1,y.q1 from onerow union all select x.q2,y.q2 from onerow) v(vx,vy) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +TABLE: name="onerow" schema="" table="onerow" ctx=Select +ALIAS: "x"="int8_tbl" +ALIAS: "z"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT v.* FROM int8_tbl x LEFT JOIN (SELECT ... FROM int8_tbl) y ON x.q2 = y.q1 LEFT JOIN int4_t..." +== 565 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from + int8_tbl a left join + lateral (select *, a.q2 as x from int8_tbl b) ss on a.q2 = ss.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int8_tbl a LEFT JOIN LATERAL (SELECT *, a.q2 AS x FROM..." +== 566 +-- truncate_limit: 100 +select * from + int8_tbl a left join + lateral (select *, a.q2 as x from int8_tbl b) ss on a.q2 = ss.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl a LEFT JOIN LATERAL (SELECT *, a.q2 AS x FROM int8_tbl b) ss ON a.q2 = ss.q1" +== 567 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from + int8_tbl a left join + lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int8_tbl a LEFT JOIN LATERAL (SELECT *, COALESCE(a.q2,..." +== 568 +-- truncate_limit: 100 +select * from + int8_tbl a left join + lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl a LEFT JOIN LATERAL (SELECT ... FROM int8_tbl b) ss ON a.q2 = ss.q1" +== 569 +-- truncate_limit: 100 +-- lateral can result in join conditions appearing below their +-- real semantic level +explain (verbose, costs off) +select * from int4_tbl i left join + lateral (select * from int2_tbl j where i.f1 = j.f1) k on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "j"="int2_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="j" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int4_tbl i LEFT JOIN LATERAL (SELECT * FROM int2_tbl j..." +== 570 +-- truncate_limit: 100 +select * from int4_tbl i left join + lateral (select * from int2_tbl j where i.f1 = j.f1) k on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "j"="int2_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="j" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl i LEFT JOIN LATERAL (SELECT * FROM int2_tbl j WHERE i.f1 = j.f1) k ON true" +== 571 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from int4_tbl i left join + lateral (select coalesce(i) from int2_tbl j where i.f1 = j.f1) k on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "j"="int2_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="j" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int4_tbl i LEFT JOIN LATERAL (SELECT COALESCE(i) FROM ..." +== 572 +-- truncate_limit: 100 +select * from int4_tbl i left join + lateral (select coalesce(i) from int2_tbl j where i.f1 = j.f1) k on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "j"="int2_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="j" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl i LEFT JOIN LATERAL (SELECT ... FROM int2_tbl j WHERE i.f1 = j.f1) k ON true" +== 573 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from int4_tbl a, + lateral ( + select * from int4_tbl b left join int8_tbl c on (b.f1 = q1 and a.f1 = q2) + ) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +ALIAS: "c"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int4_tbl a, LATERAL (SELECT * FROM int4_tbl b LEFT JOI..." +== 574 +-- truncate_limit: 100 +select * from int4_tbl a, + lateral ( + select * from int4_tbl b left join int8_tbl c on (b.f1 = q1 and a.f1 = q2) + ) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +ALIAS: "c"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl a, LATERAL (SELECT * FROM int4_tbl b LEFT JOIN int8_tbl c ON b.f1 = q1 AND..." +== 575 +-- truncate_limit: 100 +-- lateral reference in a PlaceHolderVar evaluated at join level +explain (verbose, costs off) +select * from + int8_tbl a left join lateral + (select b.q1 as bq1, c.q1 as cq1, least(a.q1,b.q1,c.q1) from + int8_tbl b cross join int8_tbl c) ss + on a.q2 = ss.bq1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int8_tbl a LEFT JOIN LATERAL (SELECT b.q1 AS bq1, c.q1..." +== 576 +-- truncate_limit: 100 +select * from + int8_tbl a left join lateral + (select b.q1 as bq1, c.q1 as cq1, least(a.q1,b.q1,c.q1) from + int8_tbl b cross join int8_tbl c) ss + on a.q2 = ss.bq1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl a LEFT JOIN LATERAL (SELECT ... FROM int8_tbl b CROSS JOIN int8_tbl c) ss ..." +== 577 +-- truncate_limit: 100 +-- case requiring nested PlaceHolderVars +explain (verbose, costs off) +select * from + int8_tbl c left join ( + int8_tbl a left join (select q1, coalesce(q2,42) as x from int8_tbl b) ss1 + on a.q2 = ss1.q1 + cross join + lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2 + ) on c.q2 = ss2.q1, + lateral (select ss2.y offset 0) ss3 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "c"="int8_tbl" +ALIAS: "d"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int8_tbl c LEFT JOIN (int8_tbl a LEFT JOIN (SELECT q1,..." +== 578 +-- truncate_limit: 100 +-- another case requiring nested PlaceHolderVars +explain (verbose, costs off) +select * from + (select 0 as val0) as ss0 + left join (select 1 as val) as ss1 on true + left join lateral (select ss1.val as val_filtered where false) as ss2 on true +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (SELECT 0 AS val0) ss0 LEFT JOIN (SELECT 1 AS val) ss1..." +== 579 +-- truncate_limit: 100 +select * from + (select 0 as val0) as ss0 + left join (select 1 as val) as ss1 on true + left join lateral (select ss1.val as val_filtered where false) as ss2 on true +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ...) ss0 LEFT JOIN (SELECT ...) ss1 ON true LEFT JOIN LATERAL (SELECT ... W..." +== 580 +-- truncate_limit: 100 +-- case that breaks the old ph_may_need optimization +explain (verbose, costs off) +select c.*,a.*,ss1.q1,ss2.q1,ss3.* from + int8_tbl c left join ( + int8_tbl a left join + (select q1, coalesce(q2,f1) as x from int8_tbl b, int4_tbl b2 + where q1 < f1) ss1 + on a.q2 = ss1.q1 + cross join + lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2 + ) on c.q2 = ss2.q1, + lateral (select * from int4_tbl i where ss2.y > f1) ss3 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +ALIAS: "b2"="int4_tbl" +ALIAS: "c"="int8_tbl" +ALIAS: "d"="int8_tbl" +ALIAS: "i"="int4_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="ss2" column="y" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT c.*, a.*, ss1.q1, ss2.q1, ss3.* FROM int8_tbl c LEFT JOIN (in..." +== 581 +-- truncate_limit: 100 +-- check processing of postponed quals (bug #9041) +explain (verbose, costs off) +select * from + (select 1 as x offset 0) x cross join (select 2 as y offset 0) y + left join lateral ( + select * from (select 3 as z offset 0) z where z.z = x.x + ) zz on zz.z = y.y +-- +FILTER: schema="" table="z" column="z" +FILTER: schema="" table="x" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (SELECT 1 AS x OFFSET 0) x CROSS JOIN (SELECT 2 AS y O..." +== 582 +-- truncate_limit: 100 +-- a new postponed-quals issue (bug #17768) +explain (costs off) +select * from int4_tbl t1, + lateral (select * from int4_tbl t2 inner join int4_tbl t3 on t1.f1 = 1 + inner join (int4_tbl t4 left join int4_tbl t5 on true) on true) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "t1"="int4_tbl" +ALIAS: "t2"="int4_tbl" +ALIAS: "t3"="int4_tbl" +ALIAS: "t4"="int4_tbl" +ALIAS: "t5"="int4_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl t1, LATERAL (SELECT * FROM int4_tbl t2 JOIN int4_tbl t..." +== 583 +-- truncate_limit: 100 +-- check dummy rels with lateral references (bug #15694) +explain (verbose, costs off) +select * from int8_tbl i8 left join lateral + (select *, i8.q2 from int4_tbl where false) ss on true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int8_tbl i8 LEFT JOIN LATERAL (SELECT *, i8.q2 FROM in..." +== 584 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from int8_tbl i8 left join lateral + (select *, i8.q2 from int4_tbl i1, int4_tbl i2 where false) ss on true +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i1"="int4_tbl" +ALIAS: "i2"="int4_tbl" +ALIAS: "i8"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int8_tbl i8 LEFT JOIN LATERAL (SELECT *, i8.q2 FROM in..." +== 585 +-- truncate_limit: 100 +-- check handling of nested appendrels inside LATERAL +select * from + ((select 2 as v) union all (select 3 as v)) as q1 + cross join lateral + ((select * from + ((select 4 as v) union all (select 5 as v)) as q3) + union all + (select q1.v) + ) as q2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... UNION ALL SELECT ...) q1 CROSS JOIN LATERAL (SELECT * FROM (SELECT ... ..." +== 586 +-- truncate_limit: 100 +-- check the number of columns specified +SELECT * FROM (int8_tbl i cross join int4_tbl j) ss(a,b,c,d) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +ALIAS: "j"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (int8_tbl i CROSS JOIN int4_tbl j ) ss(a, b, c, d)" +== 587 +-- truncate_limit: 100 +-- check we don't try to do a unique-ified semijoin with LATERAL +explain (verbose, costs off) +select * from + (values (0,9998), (1,1000)) v(id,x), + lateral (select f1 from int4_tbl + where f1 = any (select unique1 from tenk1 + where unique2 = v.x offset 0)) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="v" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (VALUES (0, 9998), (1, 1000)) v(id, x), LATERAL (SELEC..." +== 588 +-- truncate_limit: 100 +select * from + (values (0,9998), (1,1000)) v(id,x), + lateral (select f1 from int4_tbl + where f1 = any (select unique1 from tenk1 + where unique2 = v.x offset 0)) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="v" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (0, 9998), (1, 1000)) v(id, x), LATERAL (SELECT f1 FROM int4_tbl WHERE ...) ss" +== 589 +-- truncate_limit: 100 +-- check proper extParam/allParam handling (this isn't exactly a LATERAL issue, +-- but we can make the test case much more compact with LATERAL) +explain (verbose, costs off) +select * from (values (0), (1)) v(id), +lateral (select * from int8_tbl t1, + lateral (select * from + (select * from int8_tbl t2 + where (q1, random() > 0) = any (select q2, random() > 0 from int8_tbl t3 + where q2 = (select greatest(t1.q1,t2.q2)) + and (select v.id=0)) offset 0) ss2) ss + where t1.q1 = ss.q2) ss0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="t1" column="q1" +FILTER: schema="" table="ss" column="q2" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (VALUES (0), (1)) v(id), LATERAL (SELECT * FROM int8_t..." +== 590 +-- truncate_limit: 100 +select * from (values (0), (1)) v(id), +lateral (select * from int8_tbl t1, + lateral (select * from + (select * from int8_tbl t2 + where (q1, random() > 0) = any (select q2, random() > 0 from int8_tbl t3 + where q2 = (select greatest(t1.q1,t2.q2)) + and (select v.id=0)) offset 0) ss2) ss + where t1.q1 = ss.q2) ss0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="t1" column="q1" +FILTER: schema="" table="ss" column="q2" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(id), LATERAL (SELECT * FROM int8_tbl t1, LATERAL (SELECT * FROM (S..." +== 591 +-- truncate_limit: 100 +-- test some error cases where LATERAL should have been used but wasn't +select f1,g from int4_tbl a, (select f1 as g) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f1, g FROM int4_tbl a, (SELECT f1 AS g) ss" +== 592 +-- truncate_limit: 100 +select f1,g from int4_tbl a, (select a.f1 as g) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f1, g FROM int4_tbl a, (SELECT a.f1 AS g) ss" +== 593 +-- truncate_limit: 100 +select f1,g from int4_tbl a cross join (select f1 as g) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f1, g FROM int4_tbl a CROSS JOIN (SELECT f1 AS g) ss" +== 594 +-- truncate_limit: 100 +select f1,g from int4_tbl a cross join (select a.f1 as g) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT f1, g FROM int4_tbl a CROSS JOIN (SELECT a.f1 AS g) ss" +== 595 +-- truncate_limit: 100 +-- SQL:2008 says the left table is in scope but illegal to access here +select f1,g from int4_tbl a right join lateral generate_series(0, a.f1) g on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, g FROM int4_tbl a RIGHT JOIN LATERAL generate_series(0, a.f1) g ON true" +== 596 +-- truncate_limit: 100 +select f1,g from int4_tbl a full join lateral generate_series(0, a.f1) g on true +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, g FROM int4_tbl a FULL JOIN LATERAL generate_series(0, a.f1) g ON true" +== 597 +-- truncate_limit: 100 +-- check we complain about ambiguous table references +select * from + int8_tbl x cross join (int4_tbl x cross join lateral (select x.f1) ss) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "x"="int4_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl x CROSS JOIN (int4_tbl x CROSS JOIN LATERAL (SELECT x.f1) ss)" +== 598 +-- truncate_limit: 100 +-- LATERAL can be used to put an aggregate into the FROM clause of its query +select 1 from tenk1 a, lateral (select max(a.unique1) from int4_tbl b) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="int4_tbl" +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM tenk1 a, LATERAL (SELECT max(a.unique1) FROM int4_tbl b) ss" +== 599 +-- truncate_limit: 100 +-- check behavior of LATERAL in UPDATE/DELETE + +create temp table xx1 as select f1 as x1, -f1 as x2 from int4_tbl +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DDL +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE xx1 AS SELECT f1 AS x1, - f1 AS x2 FROM int4_tbl" +== 600 +-- truncate_limit: 100 +-- error, can't do this: +update xx1 set x2 = f1 from (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE xx1 SET x2 = f1 FROM (SELECT * FROM int4_tbl WHERE f1 = x1) ss" +== 601 +-- truncate_limit: 100 +update xx1 set x2 = f1 from (select * from int4_tbl where f1 = xx1.x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="xx1" column="x1" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE xx1 SET x2 = f1 FROM (SELECT * FROM int4_tbl WHERE f1 = xx1.x1) ss" +== 602 +-- truncate_limit: 100 +-- can't do it even with LATERAL: +update xx1 set x2 = f1 from lateral (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE xx1 SET x2 = f1 FROM LATERAL (SELECT * FROM int4_tbl WHERE f1 = x1) ss" +== 603 +-- truncate_limit: 100 +-- we might in future allow something like this, but for now it's an error: +update xx1 set x2 = f1 from xx1, lateral (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="xx1" schema="" table="xx1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE xx1 SET x2 = f1 FROM xx1, LATERAL (SELECT * FROM int4_tbl WHERE f1 = x1) ss" +== 604 +-- truncate_limit: 100 +-- also errors: +delete from xx1 using (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM xx1 USING (SELECT * FROM int4_tbl WHERE f1 = x1) ss" +== 605 +-- truncate_limit: 100 +delete from xx1 using (select * from int4_tbl where f1 = xx1.x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="xx1" column="x1" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM xx1 USING (SELECT * FROM int4_tbl WHERE f1 = xx1.x1) ss" +== 606 +-- truncate_limit: 100 +delete from xx1 using lateral (select * from int4_tbl where f1 = x1) ss +-- +TABLE: name="xx1" schema="" table="xx1" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="x1" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM xx1 USING LATERAL (SELECT * FROM int4_tbl WHERE f1 = x1) ss" +== 607 +-- truncate_limit: 100 +|-- +-- test LATERAL reference propagation down a multi-level inheritance hierarchy +-- produced for a multi-level partitioned table hierarchy. +|-- +create table join_pt1 (a int, b int, c varchar) partition by range(a) +-- +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE join_pt1 (a int, b int, c varchar) PARTITION BY RANGE (a)" +== 608 +-- truncate_limit: 100 +create table join_pt1p1 partition of join_pt1 for values from (0) to (100) partition by range(b) +-- +TABLE: name="join_pt1p1" schema="" table="join_pt1p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE join_pt1p1 PARTITION OF join_pt1 FOR VALUES FROM (0) TO (100) PARTITION BY RANGE (b)" +== 609 +-- truncate_limit: 100 +create table join_pt1p2 partition of join_pt1 for values from (100) to (200) +-- +TABLE: name="join_pt1p2" schema="" table="join_pt1p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE join_pt1p2 PARTITION OF join_pt1 FOR VALUES FROM (100) TO (200)" +== 610 +-- truncate_limit: 100 +create table join_pt1p1p1 partition of join_pt1p1 for values from (0) to (100) +-- +TABLE: name="join_pt1p1p1" schema="" table="join_pt1p1p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE join_pt1p1p1 PARTITION OF join_pt1p1 FOR VALUES FROM (0) TO (100)" +== 611 +-- truncate_limit: 100 +insert into join_pt1 values (1, 1, 'x'), (101, 101, 'y') +-- +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO join_pt1 VALUES (1, 1, 'x'), (101, 101, 'y')" +== 612 +-- truncate_limit: 100 +create table join_ut1 (a int, b int, c varchar) +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE join_ut1 (a int, b int, c varchar)" +== 613 +-- truncate_limit: 100 +insert into join_ut1 values (101, 101, 'y'), (2, 2, 'z') +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO join_ut1 VALUES (101, 101, 'y'), (2, 2, 'z')" +== 614 +-- truncate_limit: 100 +explain (verbose, costs off) +select t1.b, ss.phv from join_ut1 t1 left join lateral + (select t2.a as t2a, t3.a t3a, least(t1.a, t2.a, t3.a) phv + from join_pt1 t2 join join_ut1 t3 on t2.a = t3.b) ss + on t1.a = ss.t2a order by t1.a +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=Select +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=Select +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=Select +ALIAS: "t1"="join_ut1" +ALIAS: "t2"="join_pt1" +ALIAS: "t3"="join_ut1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.b, ss.phv FROM join_ut1 t1 LEFT JOIN LATERAL (SELECT t2.a ..." +== 615 +-- truncate_limit: 100 +select t1.b, ss.phv from join_ut1 t1 left join lateral + (select t2.a as t2a, t3.a t3a, least(t1.a, t2.a, t3.a) phv + from join_pt1 t2 join join_ut1 t3 on t2.a = t3.b) ss + on t1.a = ss.t2a order by t1.a +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=Select +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=Select +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=Select +ALIAS: "t1"="join_ut1" +ALIAS: "t2"="join_pt1" +ALIAS: "t3"="join_ut1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM join_ut1 t1 LEFT JOIN LATERAL (SELECT ... FROM join_pt1 t2 JOIN join_ut1 t3 ON t2..." +== 616 +-- truncate_limit: 100 +drop table join_pt1 +-- +TABLE: name="join_pt1" schema="" table="join_pt1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE join_pt1" +== 617 +-- truncate_limit: 100 +drop table join_ut1 +-- +TABLE: name="join_ut1" schema="" table="join_ut1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE join_ut1" +== 618 +-- truncate_limit: 100 +|-- +-- test estimation behavior with multi-column foreign key and constant qual +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 619 +-- truncate_limit: 100 +create table fkest (x integer, x10 integer, x10b integer, x100 integer) +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkest (x int, x10 int, x10b int, x100 int)" +== 620 +-- truncate_limit: 100 +insert into fkest select x, x/10, x/10, x/100 from generate_series(1,1000) x +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkest SELECT x, x / 10, x / 10, x / 100 FROM generate_series(1, 1000) x" +== 621 +-- truncate_limit: 100 +create unique index on fkest(x, x10, x100) +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON fkest USING btree (x, x10, x100)" +== 622 +-- truncate_limit: 100 +analyze fkest +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE fkest" +== 623 +-- truncate_limit: 100 +explain (costs off) +select * from fkest f1 + join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100) + join fkest f3 on f1.x = f3.x + where f1.x100 = 2 +-- +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest" schema="" table="fkest" ctx=Select +ALIAS: "f1"="fkest" +ALIAS: "f2"="fkest" +ALIAS: "f3"="fkest" +FILTER: schema="" table="f1" column="x100" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM fkest f1 JOIN fkest f2 ON f1.x = f2.x AND f1.x10 = f2.x10b AND ..." +== 624 +-- truncate_limit: 100 +alter table fkest add constraint fk + foreign key (x, x10b, x100) references fkest (x, x10, x100) +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkest ADD CONSTRAINT fk FOREIGN KEY (x, x10b, x100) REFERENCES fkest (x, x10, x100)" +== 625 +-- truncate_limit: 100 +explain (costs off) +select * from fkest f1 + join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100) + join fkest f3 on f1.x = f3.x + where f1.x100 = 2 +-- +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest" schema="" table="fkest" ctx=Select +ALIAS: "f1"="fkest" +ALIAS: "f2"="fkest" +ALIAS: "f3"="fkest" +FILTER: schema="" table="f1" column="x100" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM fkest f1 JOIN fkest f2 ON f1.x = f2.x AND f1.x10 = f2.x10b AND ..." +== 626 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 627 +-- truncate_limit: 100 +|-- +-- test that foreign key join estimation performs sanely for outer joins +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 628 +-- truncate_limit: 100 +create table fkest (a int, b int, c int unique, primary key(a,b)) +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkest (a int, b int, c int UNIQUE, PRIMARY KEY (a, b))" +== 629 +-- truncate_limit: 100 +create table fkest1 (a int, b int, primary key(a,b)) +-- +TABLE: name="fkest1" schema="" table="fkest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkest1 (a int, b int, PRIMARY KEY (a, b))" +== 630 +-- truncate_limit: 100 +insert into fkest select x/10, x%10, x from generate_series(1,1000) x +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkest SELECT x / 10, x % 10, x FROM generate_series(1, 1000) x" +== 631 +-- truncate_limit: 100 +insert into fkest1 select x/10, x%10 from generate_series(1,1000) x +-- +TABLE: name="fkest1" schema="" table="fkest1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkest1 SELECT x / 10, x % 10 FROM generate_series(1, 1000) x" +== 632 +-- truncate_limit: 100 +alter table fkest1 + add constraint fkest1_a_b_fkey foreign key (a,b) references fkest +-- +TABLE: name="fkest1" schema="" table="fkest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fkest1 ADD CONSTRAINT fkest1_a_b_fkey FOREIGN KEY (a, b) REFERENCES fkest" +== 633 +-- truncate_limit: 100 +analyze fkest +-- +TABLE: name="fkest" schema="" table="fkest" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE fkest" +== 634 +-- truncate_limit: 100 +analyze fkest1 +-- +TABLE: name="fkest1" schema="" table="fkest1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE fkest1" +== 635 +-- truncate_limit: 100 +explain (costs off) +select * +from fkest f + left join fkest1 f1 on f.a = f1.a and f.b = f1.b + left join fkest1 f2 on f.a = f2.a and f.b = f2.b + left join fkest1 f3 on f.a = f3.a and f.b = f3.b +where f.c = 1 +-- +TABLE: name="fkest" schema="" table="fkest" ctx=Select +TABLE: name="fkest1" schema="" table="fkest1" ctx=Select +TABLE: name="fkest1" schema="" table="fkest1" ctx=Select +TABLE: name="fkest1" schema="" table="fkest1" ctx=Select +ALIAS: "f"="fkest" +ALIAS: "f1"="fkest1" +ALIAS: "f2"="fkest1" +ALIAS: "f3"="fkest1" +FILTER: schema="" table="f" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM fkest f LEFT JOIN fkest1 f1 ON f.a = f1.a AND f.b = f1.b LEFT J..." +== 636 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 637 +-- truncate_limit: 100 +|-- +-- test planner's ability to mark joins as unique +|-- + +create table j1 (id int primary key) +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE j1 (id int PRIMARY KEY)" +== 638 +-- truncate_limit: 100 +create table j2 (id int primary key) +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE j2 (id int PRIMARY KEY)" +== 639 +-- truncate_limit: 100 +create table j3 (id int) +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE j3 (id int)" +== 640 +-- truncate_limit: 100 +insert into j1 values(1),(2),(3) +-- +TABLE: name="j1" schema="" table="j1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1 VALUES (1), (2), (3)" +== 641 +-- truncate_limit: 100 +insert into j2 values(1),(2),(3) +-- +TABLE: name="j2" schema="" table="j2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2 VALUES (1), (2), (3)" +== 642 +-- truncate_limit: 100 +insert into j3 values(1),(1) +-- +TABLE: name="j3" schema="" table="j3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j3 VALUES (1), (1)" +== 643 +-- truncate_limit: 100 +analyze j1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE j1" +== 644 +-- truncate_limit: 100 +analyze j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE j2" +== 645 +-- truncate_limit: 100 +analyze j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE j3" +== 646 +-- truncate_limit: 100 +-- ensure join is properly marked as unique +explain (verbose, costs off) +select * from j1 inner join j2 on j1.id = j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id = j2.id" +== 647 +-- truncate_limit: 100 +-- ensure join is not unique when not an equi-join +explain (verbose, costs off) +select * from j1 inner join j2 on j1.id > j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id > j2.id" +== 648 +-- truncate_limit: 100 +-- ensure non-unique rel is not chosen as inner +explain (verbose, costs off) +select * from j1 inner join j3 on j1.id = j3.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j3" schema="" table="j3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN j3 ON j1.id = j3.id" +== 649 +-- truncate_limit: 100 +-- ensure left join is marked as unique +explain (verbose, costs off) +select * from j1 left join j2 on j1.id = j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 LEFT JOIN j2 ON j1.id = j2.id" +== 650 +-- truncate_limit: 100 +-- ensure right join is marked as unique +explain (verbose, costs off) +select * from j1 right join j2 on j1.id = j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 RIGHT JOIN j2 ON j1.id = j2.id" +== 651 +-- truncate_limit: 100 +-- ensure full join is marked as unique +explain (verbose, costs off) +select * from j1 full join j2 on j1.id = j2.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 FULL JOIN j2 ON j1.id = j2.id" +== 652 +-- truncate_limit: 100 +-- a clauseless (cross) join can't be unique +explain (verbose, costs off) +select * from j1 cross join j2 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 CROSS JOIN j2" +== 653 +-- truncate_limit: 100 +-- ensure a natural join is marked as unique +explain (verbose, costs off) +select * from j1 natural join j2 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 NATURAL JOIN j2" +== 654 +-- truncate_limit: 100 +-- ensure a distinct clause allows the inner to become unique +explain (verbose, costs off) +select * from j1 +inner join (select distinct id from j3) j3 on j1.id = j3.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j3" schema="" table="j3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN (SELECT DISTINCT id FROM j3) j3 ON j1.id = j3.id" +== 655 +-- truncate_limit: 100 +-- ensure group by clause allows the inner to become unique +explain (verbose, costs off) +select * from j1 +inner join (select id from j3 group by id) j3 on j1.id = j3.id +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j3" schema="" table="j3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN (SELECT id FROM j3 GROUP BY id) j3 ON j1.id = ..." +== 656 +-- truncate_limit: 100 +drop table j1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j1" +== 657 +-- truncate_limit: 100 +drop table j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j2" +== 658 +-- truncate_limit: 100 +drop table j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j3" +== 659 +-- truncate_limit: 100 +-- test more complex permutations of unique joins + +create table j1 (id1 int, id2 int, primary key(id1,id2)) +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE j1 (id1 int, id2 int, PRIMARY KEY (id1, id2))" +== 660 +-- truncate_limit: 100 +create table j2 (id1 int, id2 int, primary key(id1,id2)) +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE j2 (id1 int, id2 int, PRIMARY KEY (id1, id2))" +== 661 +-- truncate_limit: 100 +create table j3 (id1 int, id2 int, primary key(id1,id2)) +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE j3 (id1 int, id2 int, PRIMARY KEY (id1, id2))" +== 662 +-- truncate_limit: 100 +insert into j1 values(1,1),(1,2) +-- +TABLE: name="j1" schema="" table="j1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j1 VALUES (1, 1), (1, 2)" +== 663 +-- truncate_limit: 100 +insert into j2 values(1,1) +-- +TABLE: name="j2" schema="" table="j2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2 VALUES (1, 1)" +== 664 +-- truncate_limit: 100 +insert into j3 values(1,1) +-- +TABLE: name="j3" schema="" table="j3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j3 VALUES (1, 1)" +== 665 +-- truncate_limit: 100 +analyze j1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE j1" +== 666 +-- truncate_limit: 100 +analyze j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE j2" +== 667 +-- truncate_limit: 100 +analyze j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE j3" +== 668 +-- truncate_limit: 100 +-- ensure there's no unique join when not all columns which are part of the +-- unique index are seen in the join clause +explain (verbose, costs off) +select * from j1 +inner join j2 on j1.id1 = j2.id1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1" +== 669 +-- truncate_limit: 100 +-- ensure proper unique detection with multiple join quals +explain (verbose, costs off) +select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1 AND j1.id2 = j2.id2" +== 670 +-- truncate_limit: 100 +-- ensure we don't detect the join to be unique when quals are not part of the +-- join condition +explain (verbose, costs off) +select * from j1 +inner join j2 on j1.id1 = j2.id1 where j1.id2 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1 WHERE j1.id2 = 1" +== 671 +-- truncate_limit: 100 +-- as above, but for left joins. +explain (verbose, costs off) +select * from j1 +left join j2 on j1.id1 = j2.id1 where j1.id2 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 LEFT JOIN j2 ON j1.id1 = j2.id1 WHERE j1.id2 = 1" +== 672 +-- truncate_limit: 100 +create unique index j1_id2_idx on j1(id2) where id2 is not null +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX j1_id2_idx ON j1 USING btree (id2) WHERE id2 IS NOT NULL" +== 673 +-- truncate_limit: 100 +-- ensure we don't use a partial unique index as unique proofs +explain (verbose, costs off) +select * from j1 +inner join j2 on j1.id2 = j2.id2 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id2 = j2.id2" +== 674 +-- truncate_limit: 100 +drop index j1_id2_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX j1_id2_idx" +== 675 +-- truncate_limit: 100 +-- validate logic in merge joins which skips mark and restore. +-- it should only do this if all quals which were used to detect the unique +-- are present as join quals, and not plain quals. +set enable_nestloop to 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO 0" +== 676 +-- truncate_limit: 100 +set enable_hashjoin to 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO 0" +== 677 +-- truncate_limit: 100 +set enable_sort to 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO 0" +== 678 +-- truncate_limit: 100 +-- create indexes that will be preferred over the PKs to perform the join +create index j1_id1_idx on j1 (id1) where id1 % 1000 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX j1_id1_idx ON j1 USING btree (id1) WHERE (id1 % 1000) = 1" +== 679 +-- truncate_limit: 100 +create index j2_id1_idx on j2 (id1) where id1 % 1000 = 1 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX j2_id1_idx ON j2 USING btree (id1) WHERE (id1 % 1000) = 1" +== 680 +-- truncate_limit: 100 +-- need an additional row in j2, if we want j2_id1_idx to be preferred +insert into j2 values(1,2) +-- +TABLE: name="j2" schema="" table="j2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO j2 VALUES (1, 2)" +== 681 +-- truncate_limit: 100 +analyze j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE j2" +== 682 +-- truncate_limit: 100 +explain (costs off) select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1 AND j1.id2 = j2.id2 WHERE (j1.id1..." +== 683 +-- truncate_limit: 100 +select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1 AND j1.id2 = j2.id2 WHERE ..." +== 684 +-- truncate_limit: 100 +-- Exercise array keys mark/restore B-Tree code +explain (costs off) select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]) +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1 AND j1.id2 = j2.id2 WHERE (j1.id1..." +== 685 +-- truncate_limit: 100 +select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]) +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1 AND j1.id2 = j2.id2 WHERE ..." +== 686 +-- truncate_limit: 100 +-- Exercise array keys "find extreme element" B-Tree code +explain (costs off) select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]) +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1 AND j1.id2 = j2.id2 WHERE (j1.id1..." +== 687 +-- truncate_limit: 100 +select * from j1 +inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 +where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]) +-- +TABLE: name="j1" schema="" table="j1" ctx=Select +TABLE: name="j2" schema="" table="j2" ctx=Select +FILTER: schema="" table="j1" column="id1" +FILTER: schema="" table="j2" column="id1" +FILTER: schema="" table="j2" column="id1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM j1 JOIN j2 ON j1.id1 = j2.id1 AND j1.id2 = j2.id2 WHERE ..." +== 688 +-- truncate_limit: 100 +reset enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 689 +-- truncate_limit: 100 +reset enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 690 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 691 +-- truncate_limit: 100 +drop table j1 +-- +TABLE: name="j1" schema="" table="j1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j1" +== 692 +-- truncate_limit: 100 +drop table j2 +-- +TABLE: name="j2" schema="" table="j2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j2" +== 693 +-- truncate_limit: 100 +drop table j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j3" +== 694 +-- truncate_limit: 100 +-- check that semijoin inner is not seen as unique for a portion of the outerrel +explain (verbose, costs off) +select t1.unique1, t2.hundred +from onek t1, tenk1 t2 +where exists (select 1 from tenk1 t3 + where t3.thousand = t1.unique1 and t3.tenthous = t2.hundred) + and t1.unique1 < 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="tenk1" +ALIAS: "t3"="tenk1" +FILTER: schema="" table="t3" column="thousand" +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t3" column="tenthous" +FILTER: schema="" table="t2" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.unique1, t2.hundred FROM onek t1, tenk1 t2 WHERE EXISTS (S..." +== 695 +-- truncate_limit: 100 +-- ... unless it actually is unique +create table j3 as select unique1, tenthous from onek +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE j3 AS SELECT unique1, tenthous FROM onek" +== 696 +-- truncate_limit: 100 +vacuum analyze j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) j3" +== 697 +-- truncate_limit: 100 +create unique index on j3(unique1, tenthous) +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON j3 USING btree (unique1, tenthous)" +== 698 +-- truncate_limit: 100 +explain (verbose, costs off) +select t1.unique1, t2.hundred +from onek t1, tenk1 t2 +where exists (select 1 from j3 + where j3.unique1 = t1.unique1 and j3.tenthous = t2.hundred) + and t1.unique1 < 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="j3" schema="" table="j3" ctx=Select +ALIAS: "t1"="onek" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="j3" column="unique1" +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="j3" column="tenthous" +FILTER: schema="" table="t2" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.unique1, t2.hundred FROM onek t1, tenk1 t2 WHERE EXISTS (S..." +== 699 +-- truncate_limit: 100 +drop table j3 +-- +TABLE: name="j3" schema="" table="j3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE j3" +== 700 +-- truncate_limit: 100 +-- Exercise the "skip fetch" Bitmap Heap Scan optimization when candidate +-- tuples are discarded. This may occur when: +-- 1. A join doesn't require all inner tuples to be scanned for each outer +-- tuple, and +-- 2. The inner side is scanned using a bitmap heap scan, and +-- 3. The bitmap heap scan is eligible for the "skip fetch" optimization. +-- This optimization is usable when no data from the underlying table is +-- needed. Use a temp table so it is only visible to this backend and +-- vacuum may reliably mark all blocks in the table all visible in the +-- visibility map. +CREATE TEMP TABLE skip_fetch (a INT, b INT) WITH (fillfactor=10) +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE skip_fetch (a int, b int) WITH (fillfactor=10)" +== 701 +-- truncate_limit: 100 +INSERT INTO skip_fetch SELECT i % 3, i FROM generate_series(0,30) i +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO skip_fetch SELECT i % 3, i FROM generate_series(0, 30) i" +== 702 +-- truncate_limit: 100 +CREATE INDEX ON skip_fetch(a) +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON skip_fetch USING btree (a)" +== 703 +-- truncate_limit: 100 +VACUUM (ANALYZE) skip_fetch +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) skip_fetch" +== 704 +-- truncate_limit: 100 +SET enable_indexonlyscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexonlyscan TO OFF" +== 705 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 706 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a FROM skip_fetch t1 LEFT JOIN skip_fetch t2 ON t2.a = 1 WHERE t2.a IS NULL +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=Select +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=Select +ALIAS: "t1"="skip_fetch" +ALIAS: "t2"="skip_fetch" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a FROM skip_fetch t1 LEFT JOIN skip_fetch t2 ON t2.a = 1 WHERE t2.a..." +== 707 +-- truncate_limit: 100 +SELECT t1.a FROM skip_fetch t1 LEFT JOIN skip_fetch t2 ON t2.a = 1 WHERE t2.a IS NULL +-- +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=Select +TABLE: name="skip_fetch" schema="" table="skip_fetch" ctx=Select +ALIAS: "t1"="skip_fetch" +ALIAS: "t2"="skip_fetch" +FILTER: schema="" table="t2" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT t1.a FROM skip_fetch t1 LEFT JOIN skip_fetch t2 ON t2.a = 1 WHERE t2.a IS NULL" +== 708 +-- truncate_limit: 100 +RESET enable_indexonlyscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexonlyscan" +== 709 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 710 +-- truncate_limit: 100 +-- Test that we do not account for nullingrels when looking up statistics +CREATE TABLE group_tbl (a INT, b INT) +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE group_tbl (a int, b int)" +== 711 +-- truncate_limit: 100 +INSERT INTO group_tbl SELECT 1, 1 +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO group_tbl SELECT 1, 1" +== 712 +-- truncate_limit: 100 +CREATE STATISTICS group_tbl_stat (ndistinct) ON a, b FROM group_tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS group_tbl_stat (ndistinct) ON a, b FROM group_tbl" +== 713 +-- truncate_limit: 100 +ANALYZE group_tbl +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE group_tbl" +== 714 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT 1 FROM group_tbl t1 + LEFT JOIN (SELECT a c1, COALESCE(a) c2 FROM group_tbl t2) s ON TRUE +GROUP BY s.c1, s.c2 +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=Select +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=Select +ALIAS: "t1"="group_tbl" +ALIAS: "t2"="group_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM group_tbl t1 LEFT JOIN (SELECT a AS c1, COALESCE(a) AS c2 FROM ..." +== 715 +-- truncate_limit: 100 +DROP TABLE group_tbl +-- +TABLE: name="group_tbl" schema="" table="group_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE group_tbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/join_hash.metadata.json b/parser/testdata/summary_truncate/postgres_regress/join_hash.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/join_hash.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/join_hash.test b/parser/testdata/summary_truncate/postgres_regress/join_hash.test new file mode 100644 index 0000000..f631d4b --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/join_hash.test @@ -0,0 +1,2370 @@ +== 001 +-- truncate_limit: 100 +|-- +-- exercises for the hash join code +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 002 +-- truncate_limit: 100 +set local min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL min_parallel_table_scan_size TO 0" +== 003 +-- truncate_limit: 100 +set local parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL parallel_setup_cost TO 0" +== 004 +-- truncate_limit: 100 +set local enable_hashjoin = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_hashjoin TO ON" +== 005 +-- truncate_limit: 100 +-- Extract bucket and batch counts from an explain analyze plan. In +-- general we can't make assertions about how many batches (or +-- buckets) will be required because it can vary, but we can in some +-- special cases and we can check for growth. +create or replace function find_hash(node json) +returns json language plpgsql +as +$$ +declare + x json; + child json; +begin + if node->>'Node Type' = 'Hash' then + return node; + else + for child in select json_array_elements(node->'Plans') + loop + x := find_hash(child); + if x is not null then + return x; + end if; + end loop; + return null; + end if; +end; +$$ +-- +FUNCTION: name="find_hash" function="find_hash" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION find_hash(node pg_catalog.json) RETURNS pg_catalog.json LANGUAGE plpgs..." +== 006 +-- truncate_limit: 100 +create or replace function hash_join_batches(query text) +returns table (original int, final int) language plpgsql +as +$$ +declare + whole_plan json; + hash_node json; +begin + for whole_plan in + execute 'explain (analyze, format ''json'') ' || query + loop + hash_node := find_hash(json_extract_path(whole_plan, '0', 'Plan')); + original := hash_node->>'Original Hash Batches'; + final := hash_node->>'Hash Batches'; + return next; + end loop; +end; +$$ +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION hash_join_batches(query text) RETURNS TABLE (original int, final int) ..." +== 007 +-- truncate_limit: 100 +-- Make a simple relation with well distributed keys and correctly +-- estimated size. +create table simple as + select generate_series(1, 20000) AS id, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +-- +TABLE: name="simple" schema="" table="simple" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE simple AS SELECT generate_series(1, 20000) AS id, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'" +== 008 +-- truncate_limit: 100 +alter table simple set (parallel_workers = 2) +-- +TABLE: name="simple" schema="" table="simple" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE simple SET (parallel_workers=2)" +== 009 +-- truncate_limit: 100 +analyze simple +-- +TABLE: name="simple" schema="" table="simple" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE simple" +== 010 +-- truncate_limit: 100 +-- Make a relation whose size we will under-estimate. We want stats +-- to say 1000 rows, but actually there are 20,000 rows. +create table bigger_than_it_looks as + select generate_series(1, 20000) as id, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +-- +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE bigger_than_it_looks AS SELECT generate_series(1, 20000) AS id, 'aaaaaaaaaaaaaaaaaaa..." +== 011 +-- truncate_limit: 100 +alter table bigger_than_it_looks set (autovacuum_enabled = 'false') +-- +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bigger_than_it_looks SET (autovacuum_enabled=false)" +== 012 +-- truncate_limit: 100 +alter table bigger_than_it_looks set (parallel_workers = 2) +-- +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE bigger_than_it_looks SET (parallel_workers=2)" +== 013 +-- truncate_limit: 100 +analyze bigger_than_it_looks +-- +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE bigger_than_it_looks" +== 014 +-- truncate_limit: 100 +update pg_class set reltuples = 1000 where relname = 'bigger_than_it_looks' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pg_class SET reltuples = 1000 WHERE relname = 'bigger_than_it_looks'" +== 015 +-- truncate_limit: 100 +-- Make a relation whose size we underestimate and that also has a +-- kind of skew that breaks our batching scheme. We want stats to say +-- 2 rows, but actually there are 20,000 rows with the same key. +create table extremely_skewed (id int, t text) +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE extremely_skewed (id int, t text)" +== 016 +-- truncate_limit: 100 +alter table extremely_skewed set (autovacuum_enabled = 'false') +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE extremely_skewed SET (autovacuum_enabled=false)" +== 017 +-- truncate_limit: 100 +alter table extremely_skewed set (parallel_workers = 2) +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE extremely_skewed SET (parallel_workers=2)" +== 018 +-- truncate_limit: 100 +analyze extremely_skewed +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE extremely_skewed" +== 019 +-- truncate_limit: 100 +insert into extremely_skewed + select 42 as id, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + from generate_series(1, 20000) +-- +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO extremely_skewed SELECT ... FROM generate_series(1, 20000)" +== 020 +-- truncate_limit: 100 +update pg_class + set reltuples = 2, relpages = pg_relation_size('extremely_skewed') / 8192 + where relname = 'extremely_skewed' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE pg_class SET ... = ... WHERE relname = 'extremely_skewed'" +== 021 +-- truncate_limit: 100 +-- Make a relation with a couple of enormous tuples. +create table wide as select generate_series(1, 2) as id, rpad('', 320000, 'x') as t +-- +TABLE: name="wide" schema="" table="wide" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="rpad" function="rpad" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE wide AS SELECT generate_series(1, 2) AS id, rpad('', 320000, 'x') AS t" +== 022 +-- truncate_limit: 100 +alter table wide set (parallel_workers = 2) +-- +TABLE: name="wide" schema="" table="wide" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE wide SET (parallel_workers=2)" +== 023 +-- truncate_limit: 100 +-- The "optimal" case: the hash table fits in memory; we plan for 1 +-- batch, we stick to that number, and peak memory usage stays within +-- our work_mem budget + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 024 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 0" +== 025 +-- truncate_limit: 100 +set local work_mem = '4MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"4MB\"" +== 026 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 027 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 028 +-- truncate_limit: 100 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 029 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from simple r join simple s using (id);\n')" +== 030 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 031 +-- truncate_limit: 100 +-- parallel with parallel-oblivious hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 032 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 033 +-- truncate_limit: 100 +set local work_mem = '4MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"4MB\"" +== 034 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 035 +-- truncate_limit: 100 +set local enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_parallel_hash TO OFF" +== 036 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 037 +-- truncate_limit: 100 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 038 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from simple r join simple s using (id);\n')" +== 039 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 040 +-- truncate_limit: 100 +-- parallel with parallel-aware hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 041 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 042 +-- truncate_limit: 100 +set local work_mem = '4MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"4MB\"" +== 043 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 044 +-- truncate_limit: 100 +set local enable_parallel_hash = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_parallel_hash TO ON" +== 045 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 046 +-- truncate_limit: 100 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 047 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from simple r join simple s using (id);\n')" +== 048 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 049 +-- truncate_limit: 100 +-- The "good" case: batches required, but we plan the right number; we +-- plan for some number of batches, and we stick to that number, and +-- peak memory usage says within our work_mem budget + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 050 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 0" +== 051 +-- truncate_limit: 100 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"128kB\"" +== 052 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 053 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 054 +-- truncate_limit: 100 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 055 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from simple r join simple s using (id);\n')" +== 056 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 057 +-- truncate_limit: 100 +-- parallel with parallel-oblivious hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 058 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 059 +-- truncate_limit: 100 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"128kB\"" +== 060 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 061 +-- truncate_limit: 100 +set local enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_parallel_hash TO OFF" +== 062 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 063 +-- truncate_limit: 100 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 064 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from simple r join simple s using (id);\n')" +== 065 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 066 +-- truncate_limit: 100 +-- parallel with parallel-aware hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 067 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 068 +-- truncate_limit: 100 +set local work_mem = '192kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"192kB\"" +== 069 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 070 +-- truncate_limit: 100 +set local enable_parallel_hash = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_parallel_hash TO ON" +== 071 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 072 +-- truncate_limit: 100 +select count(*) from simple r join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN simple s USING (id)" +== 073 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from simple r join simple s using (id);\n')" +== 074 +-- truncate_limit: 100 +-- parallel full multi-batch hash join +select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r FULL JOIN simple s USING (id)" +== 075 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 076 +-- truncate_limit: 100 +-- The "bad" case: during execution we need to increase number of +-- batches; in this case we plan for 1 batch, and increase at least a +-- couple of times, and peak memory usage stays within our work_mem +-- budget + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 077 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 0" +== 078 +-- truncate_limit: 100 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"128kB\"" +== 079 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 080 +-- truncate_limit: 100 +explain (costs off) + select count(*) FROM simple r JOIN bigger_than_it_looks s USING (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN bigger_than_it_looks s USING (id)" +== 081 +-- truncate_limit: 100 +select count(*) FROM simple r JOIN bigger_than_it_looks s USING (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN bigger_than_it_looks s USING (id)" +== 082 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) FROM simple r JOIN bigger_than_it_looks s USING (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) FROM simple r JOIN bigger_than_it_looks s U..." +== 083 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 084 +-- truncate_limit: 100 +-- parallel with parallel-oblivious hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 085 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 086 +-- truncate_limit: 100 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"128kB\"" +== 087 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 088 +-- truncate_limit: 100 +set local enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_parallel_hash TO OFF" +== 089 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join bigger_than_it_looks s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN bigger_than_it_looks s USING (id)" +== 090 +-- truncate_limit: 100 +select count(*) from simple r join bigger_than_it_looks s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN bigger_than_it_looks s USING (id)" +== 091 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join bigger_than_it_looks s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from simple r join bigger_than_it_looks s u..." +== 092 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 093 +-- truncate_limit: 100 +-- parallel with parallel-aware hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 094 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 1" +== 095 +-- truncate_limit: 100 +set local work_mem = '192kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"192kB\"" +== 096 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 097 +-- truncate_limit: 100 +set local enable_parallel_hash = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_parallel_hash TO ON" +== 098 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join bigger_than_it_looks s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN bigger_than_it_looks s USING (id)" +== 099 +-- truncate_limit: 100 +select count(*) from simple r join bigger_than_it_looks s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="bigger_than_it_looks" schema="" table="bigger_than_it_looks" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="bigger_than_it_looks" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN bigger_than_it_looks s USING (id)" +== 100 +-- truncate_limit: 100 +select original > 1 as initially_multibatch, final > original as increased_batches + from hash_join_batches( +$$ + select count(*) from simple r join bigger_than_it_looks s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from simple r join bigger_than_it_looks s u..." +== 101 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 102 +-- truncate_limit: 100 +-- The "ugly" case: increasing the number of batches during execution +-- doesn't help, so stop trying to fit in work_mem and hope for the +-- best; in this case we plan for 1 batch, increases just once and +-- then stop increasing because that didn't help at all, so we blow +-- right through the work_mem budget and hope for the best... + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 103 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 0" +== 104 +-- truncate_limit: 100 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"128kB\"" +== 105 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 106 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN extremely_skewed s USING (id)" +== 107 +-- truncate_limit: 100 +select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN extremely_skewed s USING (id)" +== 108 +-- truncate_limit: 100 +select * from hash_join_batches( +$$ + select count(*) from simple r join extremely_skewed s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_join_batches('\n select count(*) from simple r join extremely_skewed s using (..." +== 109 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 110 +-- truncate_limit: 100 +-- parallel with parallel-oblivious hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 111 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 112 +-- truncate_limit: 100 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"128kB\"" +== 113 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 114 +-- truncate_limit: 100 +set local enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_parallel_hash TO OFF" +== 115 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN extremely_skewed s USING (id)" +== 116 +-- truncate_limit: 100 +select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN extremely_skewed s USING (id)" +== 117 +-- truncate_limit: 100 +select * from hash_join_batches( +$$ + select count(*) from simple r join extremely_skewed s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_join_batches('\n select count(*) from simple r join extremely_skewed s using (..." +== 118 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 119 +-- truncate_limit: 100 +-- parallel with parallel-aware hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 120 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 1" +== 121 +-- truncate_limit: 100 +set local work_mem = '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"128kB\"" +== 122 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 123 +-- truncate_limit: 100 +set local enable_parallel_hash = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_parallel_hash TO ON" +== 124 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r JOIN extremely_skewed s USING (id)" +== 125 +-- truncate_limit: 100 +select count(*) from simple r join extremely_skewed s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="extremely_skewed" schema="" table="extremely_skewed" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="extremely_skewed" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r JOIN extremely_skewed s USING (id)" +== 126 +-- truncate_limit: 100 +select * from hash_join_batches( +$$ + select count(*) from simple r join extremely_skewed s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_join_batches('\n select count(*) from simple r join extremely_skewed s using (..." +== 127 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 128 +-- truncate_limit: 100 +-- A couple of other hash join tests unrelated to work_mem management. + +-- Check that EXPLAIN ANALYZE has data even if the leader doesn't participate +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 129 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 130 +-- truncate_limit: 100 +set local work_mem = '4MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"4MB\"" +== 131 +-- truncate_limit: 100 +set local hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL hash_mem_multiplier TO 1.0" +== 132 +-- truncate_limit: 100 +set local parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL parallel_leader_participation TO OFF" +== 133 +-- truncate_limit: 100 +select * from hash_join_batches( +$$ + select count(*) from simple r join simple s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hash_join_batches('\n select count(*) from simple r join simple s using (id);\n')" +== 134 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 135 +-- truncate_limit: 100 +-- Exercise rescans. We'll turn off parallel_leader_participation so +-- that we can check that instrumentation comes back correctly. + +create table join_foo as select generate_series(1, 3) as id, 'xxxxx'::text as t +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE join_foo AS SELECT generate_series(1, 3) AS id, 'xxxxx'::text AS t" +== 136 +-- truncate_limit: 100 +alter table join_foo set (parallel_workers = 0) +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE join_foo SET (parallel_workers=0)" +== 137 +-- truncate_limit: 100 +create table join_bar as select generate_series(1, 10000) as id, 'xxxxx'::text as t +-- +TABLE: name="join_bar" schema="" table="join_bar" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE join_bar AS SELECT generate_series(1, 10000) AS id, 'xxxxx'::text AS t" +== 138 +-- truncate_limit: 100 +alter table join_bar set (parallel_workers = 2) +-- +TABLE: name="join_bar" schema="" table="join_bar" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE join_bar SET (parallel_workers=2)" +== 139 +-- truncate_limit: 100 +-- multi-batch with rescan, parallel-oblivious +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 140 +-- truncate_limit: 100 +set enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO OFF" +== 141 +-- truncate_limit: 100 +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO OFF" +== 142 +-- truncate_limit: 100 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 143 +-- truncate_limit: 100 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 144 +-- truncate_limit: 100 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 145 +-- truncate_limit: 100 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 146 +-- truncate_limit: 100 +set enable_material = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_material TO OFF" +== 147 +-- truncate_limit: 100 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 148 +-- truncate_limit: 100 +set work_mem = '64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 149 +-- truncate_limit: 100 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET hash_mem_multiplier TO 1.0" +== 150 +-- truncate_limit: 100 +explain (costs off) + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM join_foo LEFT JOIN (SELECT b1.id, b1.t FROM join_bar b1 ..." +== 151 +-- truncate_limit: 100 +select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM join_foo LEFT JOIN (SELECT ... FROM join_bar b1 JOIN join_bar b2 USING (id)) ss O..." +== 152 +-- truncate_limit: 100 +select final > 1 as multibatch + from hash_join_batches( +$$ + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from join_foo\n left join (select b1.id, ..." +== 153 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 154 +-- truncate_limit: 100 +-- single-batch with rescan, parallel-oblivious +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 155 +-- truncate_limit: 100 +set enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO OFF" +== 156 +-- truncate_limit: 100 +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO OFF" +== 157 +-- truncate_limit: 100 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 158 +-- truncate_limit: 100 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 159 +-- truncate_limit: 100 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 160 +-- truncate_limit: 100 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 161 +-- truncate_limit: 100 +set enable_material = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_material TO OFF" +== 162 +-- truncate_limit: 100 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 163 +-- truncate_limit: 100 +set work_mem = '4MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"4MB\"" +== 164 +-- truncate_limit: 100 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET hash_mem_multiplier TO 1.0" +== 165 +-- truncate_limit: 100 +explain (costs off) + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM join_foo LEFT JOIN (SELECT b1.id, b1.t FROM join_bar b1 ..." +== 166 +-- truncate_limit: 100 +select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM join_foo LEFT JOIN (SELECT ... FROM join_bar b1 JOIN join_bar b2 USING (id)) ss O..." +== 167 +-- truncate_limit: 100 +select final > 1 as multibatch + from hash_join_batches( +$$ + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from join_foo\n left join (select b1.id, ..." +== 168 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 169 +-- truncate_limit: 100 +-- multi-batch with rescan, parallel-aware +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 170 +-- truncate_limit: 100 +set enable_parallel_hash = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO ON" +== 171 +-- truncate_limit: 100 +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO OFF" +== 172 +-- truncate_limit: 100 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 173 +-- truncate_limit: 100 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 174 +-- truncate_limit: 100 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 175 +-- truncate_limit: 100 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 176 +-- truncate_limit: 100 +set enable_material = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_material TO OFF" +== 177 +-- truncate_limit: 100 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 178 +-- truncate_limit: 100 +set work_mem = '64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 179 +-- truncate_limit: 100 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET hash_mem_multiplier TO 1.0" +== 180 +-- truncate_limit: 100 +explain (costs off) + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM join_foo LEFT JOIN (SELECT b1.id, b1.t FROM join_bar b1 ..." +== 181 +-- truncate_limit: 100 +select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM join_foo LEFT JOIN (SELECT ... FROM join_bar b1 JOIN join_bar b2 USING (id)) ss O..." +== 182 +-- truncate_limit: 100 +select final > 1 as multibatch + from hash_join_batches( +$$ + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from join_foo\n left join (select b1.id, ..." +== 183 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 184 +-- truncate_limit: 100 +-- single-batch with rescan, parallel-aware +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 185 +-- truncate_limit: 100 +set enable_parallel_hash = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO ON" +== 186 +-- truncate_limit: 100 +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO OFF" +== 187 +-- truncate_limit: 100 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 188 +-- truncate_limit: 100 +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 189 +-- truncate_limit: 100 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 190 +-- truncate_limit: 100 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 191 +-- truncate_limit: 100 +set enable_material = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_material TO OFF" +== 192 +-- truncate_limit: 100 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 193 +-- truncate_limit: 100 +set work_mem = '4MB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"4MB\"" +== 194 +-- truncate_limit: 100 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET hash_mem_multiplier TO 1.0" +== 195 +-- truncate_limit: 100 +explain (costs off) + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM join_foo LEFT JOIN (SELECT b1.id, b1.t FROM join_bar b1 ..." +== 196 +-- truncate_limit: 100 +select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1 +-- +TABLE: name="join_foo" schema="" table="join_foo" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +TABLE: name="join_bar" schema="" table="join_bar" ctx=Select +ALIAS: "b1"="join_bar" +ALIAS: "b2"="join_bar" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM join_foo LEFT JOIN (SELECT ... FROM join_bar b1 JOIN join_bar b2 USING (id)) ss O..." +== 197 +-- truncate_limit: 100 +select final > 1 as multibatch + from hash_join_batches( +$$ + select count(*) from join_foo + left join (select b1.id, b1.t from join_bar b1 join join_bar b2 using (id)) ss + on join_foo.id < ss.id + 1 and join_foo.id > ss.id - 1; +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select count(*) from join_foo\n left join (select b1.id, ..." +== 198 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 199 +-- truncate_limit: 100 +-- A full outer join where every record is matched. + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 200 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 0" +== 201 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r FULL JOIN simple s USING (id)" +== 202 +-- truncate_limit: 100 +select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r FULL JOIN simple s USING (id)" +== 203 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 204 +-- truncate_limit: 100 +-- parallelism not possible with parallel-oblivious full hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 205 +-- truncate_limit: 100 +set enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO OFF" +== 206 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 207 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r FULL JOIN simple s USING (id)" +== 208 +-- truncate_limit: 100 +select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r FULL JOIN simple s USING (id)" +== 209 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 210 +-- truncate_limit: 100 +-- parallelism is possible with parallel-aware full hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 211 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 212 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r FULL JOIN simple s USING (id)" +== 213 +-- truncate_limit: 100 +select count(*) from simple r full outer join simple s using (id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r FULL JOIN simple s USING (id)" +== 214 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 215 +-- truncate_limit: 100 +-- A full outer join where every record is not matched. + +-- non-parallel +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 216 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 0" +== 217 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r FULL JOIN simple s ON r.id = (0 - s.id)" +== 218 +-- truncate_limit: 100 +select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r FULL JOIN simple s ON r.id = (0 - s.id)" +== 219 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 220 +-- truncate_limit: 100 +-- parallelism not possible with parallel-oblivious full hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 221 +-- truncate_limit: 100 +set enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO OFF" +== 222 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 223 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r FULL JOIN simple s ON r.id = (0 - s.id)" +== 224 +-- truncate_limit: 100 +select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r FULL JOIN simple s ON r.id = (0 - s.id)" +== 225 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 226 +-- truncate_limit: 100 +-- parallelism is possible with parallel-aware full hash join +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 227 +-- truncate_limit: 100 +set local max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 2" +== 228 +-- truncate_limit: 100 +explain (costs off) + select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM simple r FULL JOIN simple s ON r.id = (0 - s.id)" +== 229 +-- truncate_limit: 100 +select count(*) from simple r full outer join simple s on (r.id = 0 - s.id) +-- +TABLE: name="simple" schema="" table="simple" ctx=Select +TABLE: name="simple" schema="" table="simple" ctx=Select +ALIAS: "r"="simple" +ALIAS: "s"="simple" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM simple r FULL JOIN simple s ON r.id = (0 - s.id)" +== 230 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 231 +-- truncate_limit: 100 +-- exercise special code paths for huge tuples (note use of non-strict +-- expression and left join required to get the detoasted tuple into +-- the hash table) + +-- parallel with parallel-aware hash join (hits ExecParallelHashLoadTuple and +-- sts_puttuple oversized tuple cases because it's multi-batch) +savepoint settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 232 +-- truncate_limit: 100 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 233 +-- truncate_limit: 100 +set enable_parallel_hash = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO ON" +== 234 +-- truncate_limit: 100 +set work_mem = '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"128kB\"" +== 235 +-- truncate_limit: 100 +set hash_mem_multiplier = 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET hash_mem_multiplier TO 1.0" +== 236 +-- truncate_limit: 100 +explain (costs off) + select length(max(s.t)) + from wide left join (select id, coalesce(t, '') || '' as t from wide) s using (id) +-- +TABLE: name="wide" schema="" table="wide" ctx=Select +TABLE: name="wide" schema="" table="wide" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT length(max(s.t)) FROM wide LEFT JOIN (SELECT id, COALESCE(t, '') || ''..." +== 237 +-- truncate_limit: 100 +select length(max(s.t)) +from wide left join (select id, coalesce(t, '') || '' as t from wide) s using (id) +-- +TABLE: name="wide" schema="" table="wide" ctx=Select +TABLE: name="wide" schema="" table="wide" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(max(s.t)) FROM wide LEFT JOIN (SELECT ... FROM wide) s USING (id)" +== 238 +-- truncate_limit: 100 +select final > 1 as multibatch + from hash_join_batches( +$$ + select length(max(s.t)) + from wide left join (select id, coalesce(t, '') || '' as t from wide) s using (id); +$$) +-- +FUNCTION: name="hash_join_batches" function="hash_join_batches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hash_join_batches('\n select length(max(s.t))\n from wide left join (select id, c..." +== 239 +-- truncate_limit: 100 +rollback to settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 240 +-- truncate_limit: 100 +-- Hash join reuses the HOT status bit to indicate match status. This can only +-- be guaranteed to produce correct results if all the hash join tuple match +-- bits are reset before reuse. This is done upon loading them into the +-- hashtable. +SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 241 +-- truncate_limit: 100 +SET enable_parallel_hash = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO ON" +== 242 +-- truncate_limit: 100 +SET min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 243 +-- truncate_limit: 100 +SET parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 244 +-- truncate_limit: 100 +SET parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 245 +-- truncate_limit: 100 +CREATE TABLE hjtest_matchbits_t1(id int) +-- +TABLE: name="hjtest_matchbits_t1" schema="" table="hjtest_matchbits_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hjtest_matchbits_t1 (id int)" +== 246 +-- truncate_limit: 100 +CREATE TABLE hjtest_matchbits_t2(id int) +-- +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hjtest_matchbits_t2 (id int)" +== 247 +-- truncate_limit: 100 +INSERT INTO hjtest_matchbits_t1 VALUES (1) +-- +TABLE: name="hjtest_matchbits_t1" schema="" table="hjtest_matchbits_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_matchbits_t1 VALUES (1)" +== 248 +-- truncate_limit: 100 +INSERT INTO hjtest_matchbits_t2 VALUES (2) +-- +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_matchbits_t2 VALUES (2)" +== 249 +-- truncate_limit: 100 +-- Update should create a HOT tuple. If this status bit isn't cleared, we won't +-- correctly emit the NULL-extended unmatching tuple in full hash join. +UPDATE hjtest_matchbits_t2 set id = 2 +-- +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hjtest_matchbits_t2 SET id = 2" +== 250 +-- truncate_limit: 100 +SELECT * FROM hjtest_matchbits_t1 t1 FULL JOIN hjtest_matchbits_t2 t2 ON t1.id = t2.id + ORDER BY t1.id +-- +TABLE: name="hjtest_matchbits_t1" schema="" table="hjtest_matchbits_t1" ctx=Select +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=Select +ALIAS: "t1"="hjtest_matchbits_t1" +ALIAS: "t2"="hjtest_matchbits_t2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hjtest_matchbits_t1 t1 FULL JOIN hjtest_matchbits_t2 t2 ON t1.id = t2.id ORDER BY t..." +== 251 +-- truncate_limit: 100 +-- Test serial full hash join. +-- Resetting parallel_setup_cost should force a serial plan. +-- Just to be safe, however, set enable_parallel_hash to off, as parallel full +-- hash joins are only supported with shared hashtables. +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 252 +-- truncate_limit: 100 +SET enable_parallel_hash = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_hash TO OFF" +== 253 +-- truncate_limit: 100 +SELECT * FROM hjtest_matchbits_t1 t1 FULL JOIN hjtest_matchbits_t2 t2 ON t1.id = t2.id +-- +TABLE: name="hjtest_matchbits_t1" schema="" table="hjtest_matchbits_t1" ctx=Select +TABLE: name="hjtest_matchbits_t2" schema="" table="hjtest_matchbits_t2" ctx=Select +ALIAS: "t1"="hjtest_matchbits_t1" +ALIAS: "t2"="hjtest_matchbits_t2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hjtest_matchbits_t1 t1 FULL JOIN hjtest_matchbits_t2 t2 ON t1.id = t2.id" +== 254 +-- truncate_limit: 100 +ROLLBACK TO settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 255 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 256 +-- truncate_limit: 100 +-- Verify that hash key expressions reference the correct +-- nodes. Hashjoin's hashkeys need to reference its outer plan, Hash's +-- need to reference Hash's outer plan (which is below HashJoin's +-- inner plan). It's not trivial to verify that the references are +-- correct (we don't display the hashkeys themselves), but if the +-- hashkeys contain subplan references, those will be displayed. Force +-- subplans to appear just about everywhere. +|-- +-- Bug report: +-- https://www.postgresql.org/message-id/CAPpHfdvGVegF_TKKRiBrSmatJL2dR9uwFCuR%2BteQ_8tEXU8mxg%40mail.gmail.com +|-- +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 257 +-- truncate_limit: 100 +SET LOCAL enable_sort = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_sort TO OFF" +== 258 +-- truncate_limit: 100 +-- avoid mergejoins +SET LOCAL from_collapse_limit = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL from_collapse_limit TO 1" +== 259 +-- truncate_limit: 100 +-- allows easy changing of join order + +CREATE TABLE hjtest_1 (a text, b int, id int, c bool) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hjtest_1 (a text, b int, id int, c bool)" +== 260 +-- truncate_limit: 100 +CREATE TABLE hjtest_2 (a bool, id int, b text, c int) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hjtest_2 (a bool, id int, b text, c int)" +== 261 +-- truncate_limit: 100 +INSERT INTO hjtest_1(a, b, id, c) VALUES ('text', 2, 1, false) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_1 (a, b, id, c) VALUES ('text', 2, 1, false)" +== 262 +-- truncate_limit: 100 +-- matches +INSERT INTO hjtest_1(a, b, id, c) VALUES ('text', 1, 2, false) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_1 (a, b, id, c) VALUES ('text', 1, 2, false)" +== 263 +-- truncate_limit: 100 +-- fails id join condition +INSERT INTO hjtest_1(a, b, id, c) VALUES ('text', 20, 1, false) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_1 (a, b, id, c) VALUES ('text', 20, 1, false)" +== 264 +-- truncate_limit: 100 +-- fails < 50 +INSERT INTO hjtest_1(a, b, id, c) VALUES ('text', 1, 1, false) +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_1 (a, b, id, c) VALUES ('text', 1, 1, false)" +== 265 +-- truncate_limit: 100 +-- fails (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 1, 'another', 2) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_2 (a, id, b, c) VALUES (true, 1, 'another', 2)" +== 266 +-- truncate_limit: 100 +-- matches +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 3, 'another', 7) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_2 (a, id, b, c) VALUES (true, 3, 'another', 7)" +== 267 +-- truncate_limit: 100 +-- fails id join condition +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 1, 'another', 90) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_2 (a, id, b, c) VALUES (true, 1, 'another', 90)" +== 268 +-- truncate_limit: 100 +-- fails < 55 +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 1, 'another', 3) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_2 (a, id, b, c) VALUES (true, 1, 'another', 3)" +== 269 +-- truncate_limit: 100 +-- fails (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) +INSERT INTO hjtest_2(a, id, b, c) VALUES (true, 1, 'text', 1) +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hjtest_2 (a, id, b, c) VALUES (true, 1, 'text', 1)" +== 270 +-- truncate_limit: 100 +-- fails hjtest_1.a <> hjtest_2.b; + +EXPLAIN (COSTS OFF, VERBOSE) +SELECT hjtest_1.a a1, hjtest_2.a a2,hjtest_1.tableoid::regclass t1, hjtest_2.tableoid::regclass t2 +FROM hjtest_1, hjtest_2 +WHERE + hjtest_1.id = (SELECT 1 WHERE hjtest_2.id = 1) + AND (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + AND (SELECT hjtest_1.b * 5) < 50 + AND (SELECT hjtest_2.c * 5) < 55 + AND hjtest_1.a <> hjtest_2.b +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=Select +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=Select +FILTER: schema="" table="hjtest_1" column="id" +FILTER: schema="" table="hjtest_2" column="id" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT hjtest_1.a AS a1, hjtest_2.a AS a2, hjtest_1.tableoid::regcla..." +== 271 +-- truncate_limit: 100 +SELECT hjtest_1.a a1, hjtest_2.a a2,hjtest_1.tableoid::regclass t1, hjtest_2.tableoid::regclass t2 +FROM hjtest_1, hjtest_2 +WHERE + hjtest_1.id = (SELECT 1 WHERE hjtest_2.id = 1) + AND (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + AND (SELECT hjtest_1.b * 5) < 50 + AND (SELECT hjtest_2.c * 5) < 55 + AND hjtest_1.a <> hjtest_2.b +-- +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=Select +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=Select +FILTER: schema="" table="hjtest_1" column="id" +FILTER: schema="" table="hjtest_2" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hjtest_1, hjtest_2 WHERE ..." +== 272 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF, VERBOSE) +SELECT hjtest_1.a a1, hjtest_2.a a2,hjtest_1.tableoid::regclass t1, hjtest_2.tableoid::regclass t2 +FROM hjtest_2, hjtest_1 +WHERE + hjtest_1.id = (SELECT 1 WHERE hjtest_2.id = 1) + AND (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + AND (SELECT hjtest_1.b * 5) < 50 + AND (SELECT hjtest_2.c * 5) < 55 + AND hjtest_1.a <> hjtest_2.b +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=Select +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=Select +FILTER: schema="" table="hjtest_1" column="id" +FILTER: schema="" table="hjtest_2" column="id" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT hjtest_1.a AS a1, hjtest_2.a AS a2, hjtest_1.tableoid::regcla..." +== 273 +-- truncate_limit: 100 +SELECT hjtest_1.a a1, hjtest_2.a a2,hjtest_1.tableoid::regclass t1, hjtest_2.tableoid::regclass t2 +FROM hjtest_2, hjtest_1 +WHERE + hjtest_1.id = (SELECT 1 WHERE hjtest_2.id = 1) + AND (SELECT hjtest_1.b * 5) = (SELECT hjtest_2.c*5) + AND (SELECT hjtest_1.b * 5) < 50 + AND (SELECT hjtest_2.c * 5) < 55 + AND hjtest_1.a <> hjtest_2.b +-- +TABLE: name="hjtest_2" schema="" table="hjtest_2" ctx=Select +TABLE: name="hjtest_1" schema="" table="hjtest_1" ctx=Select +FILTER: schema="" table="hjtest_1" column="id" +FILTER: schema="" table="hjtest_2" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM hjtest_2, hjtest_1 WHERE ..." +== 274 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 275 +-- truncate_limit: 100 +-- Verify that we behave sanely when the inner hash keys contain parameters +-- (that is, outer or lateral references). This situation has to defeat +-- re-use of the inner hash table across rescans. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 276 +-- truncate_limit: 100 +set local enable_hashjoin = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_hashjoin TO ON" +== 277 +-- truncate_limit: 100 +explain (costs off) +select i8.q2, ss.* from +int8_tbl i8, +lateral (select t1.fivethous, i4.f1 from tenk1 t1 join int4_tbl i4 + on t1.fivethous = i4.f1+i8.q2 order by 1,2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="tenk1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT i8.q2, ss.* FROM int8_tbl i8, LATERAL (SELECT t1.fivethous, i4.f1 FROM..." +== 278 +-- truncate_limit: 100 +select i8.q2, ss.* from +int8_tbl i8, +lateral (select t1.fivethous, i4.f1 from tenk1 t1 join int4_tbl i4 + on t1.fivethous = i4.f1+i8.q2 order by 1,2) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +ALIAS: "i8"="int8_tbl" +ALIAS: "t1"="tenk1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl i8, LATERAL (SELECT ... FROM tenk1 t1 JOIN int4_tbl i4 ON t1.fivethous =..." +== 279 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" diff --git a/parser/testdata/summary_truncate/postgres_regress/json.metadata.json b/parser/testdata/summary_truncate/postgres_regress/json.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/json.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/json.test b/parser/testdata/summary_truncate/postgres_regress/json.test new file mode 100644 index 0000000..051c7d4 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/json.test @@ -0,0 +1,3486 @@ +== 001 +-- truncate_limit: 100 +-- Strings. +SELECT '""'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"\"'::pg_catalog.json" +== 002 +-- truncate_limit: 100 +-- OK. +SELECT $$''$$::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''''''::pg_catalog.json" +== 003 +-- truncate_limit: 100 +-- ERROR, single quotes are not allowed +SELECT '"abc"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"abc\"'::pg_catalog.json" +== 004 +-- truncate_limit: 100 +-- OK +SELECT '"abc'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"abc'::pg_catalog.json" +== 005 +-- truncate_limit: 100 +-- ERROR, quotes not closed +SELECT '"abc +def"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"abc\ndef\"'::pg_catalog.json" +== 006 +-- truncate_limit: 100 +-- ERROR, unescaped newline in string constant +SELECT '"\n\"\\"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\n\\\\\"\\\\\\\\\"'::pg_catalog.json" +== 007 +-- truncate_limit: 100 +-- OK, legal escapes +SELECT '"\v"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\v\"'::pg_catalog.json" +== 008 +-- truncate_limit: 100 +-- ERROR, not a valid JSON escape + +-- Check fast path for longer strings (at least 16 bytes long) +SELECT ('"'||repeat('.', 12)||'abc"')::json +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (('\"' || repeat('.', 12)) || 'abc\"')::pg_catalog.json" +== 009 +-- truncate_limit: 100 +-- OK +SELECT ('"'||repeat('.', 12)||'abc\n"')::json +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (('\"' || repeat('.', 12)) || E'abc\\\\n\"')::pg_catalog.json" +== 010 +-- truncate_limit: 100 +-- OK, legal escapes + +-- see json_encoding test for input with unicode escapes + +-- Numbers. +SELECT '1'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::pg_catalog.json" +== 011 +-- truncate_limit: 100 +-- OK +SELECT '0'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0'::pg_catalog.json" +== 012 +-- truncate_limit: 100 +-- OK +SELECT '01'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01'::pg_catalog.json" +== 013 +-- truncate_limit: 100 +-- ERROR, not valid according to JSON spec +SELECT '0.1'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1'::pg_catalog.json" +== 014 +-- truncate_limit: 100 +-- OK +SELECT '9223372036854775808'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775808'::pg_catalog.json" +== 015 +-- truncate_limit: 100 +-- OK, even though it's too large for int8 +SELECT '1e100'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1e100'::pg_catalog.json" +== 016 +-- truncate_limit: 100 +-- OK +SELECT '1.3e100'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.3e100'::pg_catalog.json" +== 017 +-- truncate_limit: 100 +-- OK +SELECT '1f2'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1f2'::pg_catalog.json" +== 018 +-- truncate_limit: 100 +-- ERROR +SELECT '0.x1'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.x1'::pg_catalog.json" +== 019 +-- truncate_limit: 100 +-- ERROR +SELECT '1.3ex100'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.3ex100'::pg_catalog.json" +== 020 +-- truncate_limit: 100 +-- ERROR + +-- Arrays. +SELECT '[]'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::pg_catalog.json" +== 021 +-- truncate_limit: 100 +-- OK +SELECT '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 022 +-- truncate_limit: 100 +-- OK +SELECT '[1,2]'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2]'::pg_catalog.json" +== 023 +-- truncate_limit: 100 +-- OK +SELECT '[1,2,]'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,]'::pg_catalog.json" +== 024 +-- truncate_limit: 100 +-- ERROR, trailing comma +SELECT '[1,2'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2'::pg_catalog.json" +== 025 +-- truncate_limit: 100 +-- ERROR, no closing bracket +SELECT '[1,[2]'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,[2]'::pg_catalog.json" +== 026 +-- truncate_limit: 100 +-- ERROR, no closing bracket + +-- Objects. +SELECT '{}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::pg_catalog.json" +== 027 +-- truncate_limit: 100 +-- OK +SELECT '{"abc"}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\"}'::pg_catalog.json" +== 028 +-- truncate_limit: 100 +-- ERROR, no value +SELECT '{"abc":1}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\":1}'::pg_catalog.json" +== 029 +-- truncate_limit: 100 +-- OK +SELECT '{1:"abc"}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{1:\"abc\"}'::pg_catalog.json" +== 030 +-- truncate_limit: 100 +-- ERROR, keys must be strings +SELECT '{"abc",1}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\",1}'::pg_catalog.json" +== 031 +-- truncate_limit: 100 +-- ERROR, wrong separator +SELECT '{"abc"=1}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\"=1}'::pg_catalog.json" +== 032 +-- truncate_limit: 100 +-- ERROR, totally wrong separator +SELECT '{"abc"::1}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\"::1}'::pg_catalog.json" +== 033 +-- truncate_limit: 100 +-- ERROR, another wrong separator +SELECT '{"abc":1,"def":2,"ghi":[3,4],"hij":{"klm":5,"nop":[6]}}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\":1,\"def\":2,\"ghi\":[3,4],\"hij\":{\"klm\":5,\"nop\":[6]}}'::pg_catalog.json" +== 034 +-- truncate_limit: 100 +-- OK +SELECT '{"abc":1:2}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\":1:2}'::pg_catalog.json" +== 035 +-- truncate_limit: 100 +-- ERROR, colon in wrong spot +SELECT '{"abc":1,3}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\":1,3}'::pg_catalog.json" +== 036 +-- truncate_limit: 100 +-- ERROR, no value + +-- Recursion. +SET max_stack_depth = '100kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_stack_depth TO \"100kB\"" +== 037 +-- truncate_limit: 100 +SELECT repeat('[', 10000)::json +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT repeat('[', 10000)::pg_catalog.json" +== 038 +-- truncate_limit: 100 +SELECT repeat('{"a":', 10000)::json +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT repeat('{\"a\":', 10000)::pg_catalog.json" +== 039 +-- truncate_limit: 100 +RESET max_stack_depth +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_stack_depth" +== 040 +-- truncate_limit: 100 +-- Miscellaneous stuff. +SELECT 'true'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true'::pg_catalog.json" +== 041 +-- truncate_limit: 100 +-- OK +SELECT 'false'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'false'::pg_catalog.json" +== 042 +-- truncate_limit: 100 +-- OK +SELECT 'null'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'null'::pg_catalog.json" +== 043 +-- truncate_limit: 100 +-- OK +SELECT ' true '::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' true '::pg_catalog.json" +== 044 +-- truncate_limit: 100 +-- OK, even with extra whitespace +SELECT 'true false'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true false'::pg_catalog.json" +== 045 +-- truncate_limit: 100 +-- ERROR, too many values +SELECT 'true, false'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true, false'::pg_catalog.json" +== 046 +-- truncate_limit: 100 +-- ERROR, too many values +SELECT 'truf'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'truf'::pg_catalog.json" +== 047 +-- truncate_limit: 100 +-- ERROR, not a keyword +SELECT 'trues'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'trues'::pg_catalog.json" +== 048 +-- truncate_limit: 100 +-- ERROR, not a keyword +SELECT ''::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::pg_catalog.json" +== 049 +-- truncate_limit: 100 +-- ERROR, no value +SELECT ' '::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' '::pg_catalog.json" +== 050 +-- truncate_limit: 100 +-- ERROR, no value + +-- Multi-line JSON input to check ERROR reporting +SELECT '{ + "one": 1, + "two":"two", + "three": + true}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\n\t\t\"one\": 1,\n\t\t\"two\":\"two\",\n\t\t\"three\":\n\t\ttrue}'::pg_catalog.json" +== 051 +-- truncate_limit: 100 +-- OK +SELECT '{ + "one": 1, + "two":,"two", -- ERROR extraneous comma before field "two" + "three": + true}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 052 +-- truncate_limit: 100 +SELECT '{ + "one": 1, + "two":"two", + "averyveryveryveryveryveryveryveryveryverylongfieldname":}'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 053 +-- truncate_limit: 100 +-- ERROR missing value for last field + +-- test non-error-throwing input +select pg_input_is_valid('{"a":true}', 'json') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{\"a\":true}', 'json')" +== 054 +-- truncate_limit: 100 +select pg_input_is_valid('{"a":true', 'json') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{\"a\":true', 'json')" +== 055 +-- truncate_limit: 100 +select * from pg_input_error_info('{"a":true', 'json') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{\"a\":true', 'json')" +== 056 +-- truncate_limit: 100 +--constructors +-- array_to_json + +SELECT array_to_json(array(select 1 as a)) +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_json(ARRAY(SELECT 1 AS a))" +== 057 +-- truncate_limit: 100 +SELECT array_to_json(array_agg(q),false) from (select x as b, x * 2 as c from generate_series(1,3) x) q +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_json(array_agg(q), false) FROM (SELECT ... FROM generate_series(1, 3) x) q" +== 058 +-- truncate_limit: 100 +SELECT array_to_json(array_agg(q),true) from (select x as b, x * 2 as c from generate_series(1,3) x) q +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_json(array_agg(q), true) FROM (SELECT ... FROM generate_series(1, 3) x) q" +== 059 +-- truncate_limit: 100 +SELECT array_to_json(array_agg(q),false) + FROM ( SELECT $$a$$ || x AS b, y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 2) x, generate_series(4, 5) y) q" +== 060 +-- truncate_limit: 100 +SELECT array_to_json(array_agg(x),false) from generate_series(5,10) x +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_json(array_agg(x), false) FROM generate_series(5, 10) x" +== 061 +-- truncate_limit: 100 +SELECT array_to_json('{{1,5},{99,100}}'::int[]) +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_json('{{1,5},{99,100}}'::int[])" +== 062 +-- truncate_limit: 100 +-- row_to_json +SELECT row_to_json(row(1,'foo')) +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(ROW(1, 'foo'))" +== 063 +-- truncate_limit: 100 +SELECT row_to_json(q) +FROM (SELECT $$a$$ || x AS b, + y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q) FROM (SELECT ... FROM generate_series(1, 2) x, generate_series(4, 5) y) q" +== 064 +-- truncate_limit: 100 +SELECT row_to_json(q,true) +FROM (SELECT $$a$$ || x AS b, + y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 2) x, generate_series(4, 5) y) q" +== 065 +-- truncate_limit: 100 +CREATE TEMP TABLE rows AS +SELECT x, 'txt' || x as y +FROM generate_series(1,3) AS x +-- +TABLE: name="rows" schema="" table="rows" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE rows AS SELECT x, 'txt' || x AS y FROM generate_series(1, 3) x" +== 066 +-- truncate_limit: 100 +SELECT row_to_json(q,true) +FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q, true) FROM rows q" +== 067 +-- truncate_limit: 100 +SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),false) +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(ROW((SELECT array_agg(x) AS d FROM generate_series(5, 10) x)), false)" +== 068 +-- truncate_limit: 100 +-- anyarray column + +analyze rows +-- +TABLE: name="rows" schema="" table="rows" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE rows" +== 069 +-- truncate_limit: 100 +select attname, to_json(histogram_bounds) histogram_bounds +from pg_stats +where tablename = 'rows' and + schemaname = pg_my_temp_schema()::regnamespace::text +order by 1 +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +FILTER: schema="" table="" column="tablename" +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +TRUNCATED: "SELECT attname, to_json(histogram_bounds) AS histogram_bounds FROM pg_stats WHERE ... ORDER BY 1" +== 070 +-- truncate_limit: 100 +-- to_json, timestamps + +select to_json(timestamp '2014-05-28 12:22:35.614298') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('2014-05-28 12:22:35.614298'::timestamp)" +== 071 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 072 +-- truncate_limit: 100 +SET LOCAL TIME ZONE 10.5 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO 10.5" +== 073 +-- truncate_limit: 100 +select to_json(timestamptz '2014-05-28 12:22:35.614298-04') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('2014-05-28 12:22:35.614298-04'::timestamptz)" +== 074 +-- truncate_limit: 100 +SET LOCAL TIME ZONE -8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO -8" +== 075 +-- truncate_limit: 100 +select to_json(timestamptz '2014-05-28 12:22:35.614298-04') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('2014-05-28 12:22:35.614298-04'::timestamptz)" +== 076 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 077 +-- truncate_limit: 100 +select to_json(date '2014-05-28') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('2014-05-28'::date)" +== 078 +-- truncate_limit: 100 +select to_json(date 'Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('Infinity'::date)" +== 079 +-- truncate_limit: 100 +select to_json(date '-Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('-Infinity'::date)" +== 080 +-- truncate_limit: 100 +select to_json(timestamp 'Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('Infinity'::timestamp)" +== 081 +-- truncate_limit: 100 +select to_json(timestamp '-Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('-Infinity'::timestamp)" +== 082 +-- truncate_limit: 100 +select to_json(timestamptz 'Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('Infinity'::timestamptz)" +== 083 +-- truncate_limit: 100 +select to_json(timestamptz '-Infinity') +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_json('-Infinity'::timestamptz)" +== 084 +-- truncate_limit: 100 +--json_agg + +SELECT json_agg(q) + FROM ( SELECT $$a$$ || x AS b, y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="json_agg" function="json_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_agg(q) FROM (SELECT ... FROM generate_series(1, 2) x, generate_series(4, 5) y) q" +== 085 +-- truncate_limit: 100 +SELECT json_agg(q ORDER BY x, y) + FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="json_agg" function="json_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_agg(q ORDER BY x, y) FROM rows q" +== 086 +-- truncate_limit: 100 +UPDATE rows SET x = NULL WHERE x = 1 +-- +TABLE: name="rows" schema="" table="rows" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rows SET x = NULL WHERE x = 1" +== 087 +-- truncate_limit: 100 +SELECT json_agg(q ORDER BY x NULLS FIRST, y) + FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="json_agg" function="json_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_agg(q ORDER BY x NULLS FIRST, y) FROM rows q" +== 088 +-- truncate_limit: 100 +-- non-numeric output +SELECT row_to_json(q) +FROM (SELECT 'NaN'::float8 AS "float8field") q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q) FROM (SELECT 'NaN'::float8 AS float8field) q" +== 089 +-- truncate_limit: 100 +SELECT row_to_json(q) +FROM (SELECT 'Infinity'::float8 AS "float8field") q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q) FROM (SELECT 'Infinity'::float8 AS float8field) q" +== 090 +-- truncate_limit: 100 +SELECT row_to_json(q) +FROM (SELECT '-Infinity'::float8 AS "float8field") q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q) FROM (SELECT '-Infinity'::float8 AS float8field) q" +== 091 +-- truncate_limit: 100 +-- json input +SELECT row_to_json(q) +FROM (SELECT '{"a":1,"b": [2,3,4,"d","e","f"],"c":{"p":1,"q":2}}'::json AS "jsonfield") q +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q) FROM (SELECT ...) q" +== 092 +-- truncate_limit: 100 +-- json extraction functions + +CREATE TEMP TABLE test_json ( + json_type text, + test_json json +) +-- +TABLE: name="test_json" schema="" table="test_json" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_json (json_type text, test_json pg_catalog.json)" +== 093 +-- truncate_limit: 100 +INSERT INTO test_json VALUES +('scalar','"a scalar"'), +('array','["zero", "one","two",null,"four","five", [1,2,3],{"f1":9}]'), +('object','{"field1":"val1","field2":"val2","field3":null, "field4": 4, "field5": [1,2,3], "field6": {"f1":9}}') +-- +TABLE: name="test_json" schema="" table="test_json" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_json VALUES (...)" +== 094 +-- truncate_limit: 100 +SELECT test_json -> 'x' +FROM test_json +WHERE json_type = 'scalar' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'x' FROM test_json WHERE json_type = 'scalar'" +== 095 +-- truncate_limit: 100 +SELECT test_json -> 'x' +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'x' FROM test_json WHERE json_type = 'array'" +== 096 +-- truncate_limit: 100 +SELECT test_json -> 'x' +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'x' FROM test_json WHERE json_type = 'object'" +== 097 +-- truncate_limit: 100 +SELECT test_json->'field2' +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'field2' FROM test_json WHERE json_type = 'object'" +== 098 +-- truncate_limit: 100 +SELECT test_json->>'field2' +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field2' FROM test_json WHERE json_type = 'object'" +== 099 +-- truncate_limit: 100 +SELECT test_json -> 2 +FROM test_json +WHERE json_type = 'scalar' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 2 FROM test_json WHERE json_type = 'scalar'" +== 100 +-- truncate_limit: 100 +SELECT test_json -> 2 +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 2 FROM test_json WHERE json_type = 'array'" +== 101 +-- truncate_limit: 100 +SELECT test_json -> -1 +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> -1 FROM test_json WHERE json_type = 'array'" +== 102 +-- truncate_limit: 100 +SELECT test_json -> 2 +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 2 FROM test_json WHERE json_type = 'object'" +== 103 +-- truncate_limit: 100 +SELECT test_json->>2 +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 2 FROM test_json WHERE json_type = 'array'" +== 104 +-- truncate_limit: 100 +SELECT test_json ->> 6 FROM test_json WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 6 FROM test_json WHERE json_type = 'array'" +== 105 +-- truncate_limit: 100 +SELECT test_json ->> 7 FROM test_json WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 7 FROM test_json WHERE json_type = 'array'" +== 106 +-- truncate_limit: 100 +SELECT test_json ->> 'field4' FROM test_json WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field4' FROM test_json WHERE json_type = 'object'" +== 107 +-- truncate_limit: 100 +SELECT test_json ->> 'field5' FROM test_json WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field5' FROM test_json WHERE json_type = 'object'" +== 108 +-- truncate_limit: 100 +SELECT test_json ->> 'field6' FROM test_json WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field6' FROM test_json WHERE json_type = 'object'" +== 109 +-- truncate_limit: 100 +SELECT json_object_keys(test_json) +FROM test_json +WHERE json_type = 'scalar' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FUNCTION: name="json_object_keys" function="json_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT json_object_keys(test_json) FROM test_json WHERE json_type = 'scalar'" +== 110 +-- truncate_limit: 100 +SELECT json_object_keys(test_json) +FROM test_json +WHERE json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FUNCTION: name="json_object_keys" function="json_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT json_object_keys(test_json) FROM test_json WHERE json_type = 'array'" +== 111 +-- truncate_limit: 100 +SELECT json_object_keys(test_json) +FROM test_json +WHERE json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FUNCTION: name="json_object_keys" function="json_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT json_object_keys(test_json) FROM test_json WHERE json_type = 'object'" +== 112 +-- truncate_limit: 100 +-- test extending object_keys resultset - initial resultset size is 256 + +select count(*) from + (select json_object_keys(json_object(array_agg(g))) + from (select unnest(array['f'||n,n::text])as g + from generate_series(1,300) as n) x ) y +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="json_object_keys" function="json_object_keys" schema="" ctx=Call +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT ... FROM (SELECT ... FROM generate_series(1, 300) n) x) y" +== 113 +-- truncate_limit: 100 +-- nulls + +select (test_json->'field3') is null as expect_false +from test_json +where json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'field3' IS NULL AS expect_false FROM test_json WHERE json_type = 'object'" +== 114 +-- truncate_limit: 100 +select (test_json->>'field3') is null as expect_true +from test_json +where json_type = 'object' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field3' IS NULL AS expect_true FROM test_json WHERE json_type = 'object'" +== 115 +-- truncate_limit: 100 +select (test_json->3) is null as expect_false +from test_json +where json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 3 IS NULL AS expect_false FROM test_json WHERE json_type = 'array'" +== 116 +-- truncate_limit: 100 +select (test_json->>3) is null as expect_true +from test_json +where json_type = 'array' +-- +TABLE: name="test_json" schema="" table="test_json" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 3 IS NULL AS expect_true FROM test_json WHERE json_type = 'array'" +== 117 +-- truncate_limit: 100 +-- corner cases + +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> null::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json -> NULL::text" +== 118 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> null::int +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json -> NULL::int" +== 119 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json -> 1" +== 120 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> -1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json -> -1" +== 121 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json -> 'z'" +== 122 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> '' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json -> ''" +== 123 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json -> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json -> 1" +== 124 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json -> 3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json -> 3" +== 125 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json -> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json -> 'z'" +== 126 +-- truncate_limit: 100 +select '{"a": "c", "b": null}'::json -> 'b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": \"c\", \"b\": null}'::pg_catalog.json -> 'b'" +== 127 +-- truncate_limit: 100 +select '"foo"'::json -> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::pg_catalog.json -> 1" +== 128 +-- truncate_limit: 100 +select '"foo"'::json -> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::pg_catalog.json -> 'z'" +== 129 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> null::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json ->> NULL::text" +== 130 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> null::int +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json ->> NULL::int" +== 131 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json ->> 1" +== 132 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json ->> 'z'" +== 133 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json ->> '' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json ->> ''" +== 134 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json ->> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json ->> 1" +== 135 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json ->> 3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json ->> 3" +== 136 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json ->> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json ->> 'z'" +== 137 +-- truncate_limit: 100 +select '{"a": "c", "b": null}'::json ->> 'b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": \"c\", \"b\": null}'::pg_catalog.json ->> 'b'" +== 138 +-- truncate_limit: 100 +select '"foo"'::json ->> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::pg_catalog.json ->> 1" +== 139 +-- truncate_limit: 100 +select '"foo"'::json ->> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::pg_catalog.json ->> 'z'" +== 140 +-- truncate_limit: 100 +-- array length + +SELECT json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]') +-- +FUNCTION: name="json_array_length" function="json_array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_array_length('[1,2,3,{\"f1\":1,\"f2\":[5,6]},4]')" +== 141 +-- truncate_limit: 100 +SELECT json_array_length('[]') +-- +FUNCTION: name="json_array_length" function="json_array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_array_length('[]')" +== 142 +-- truncate_limit: 100 +SELECT json_array_length('{"f1":1,"f2":[5,6]}') +-- +FUNCTION: name="json_array_length" function="json_array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_array_length('{\"f1\":1,\"f2\":[5,6]}')" +== 143 +-- truncate_limit: 100 +SELECT json_array_length('4') +-- +FUNCTION: name="json_array_length" function="json_array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_array_length('4')" +== 144 +-- truncate_limit: 100 +-- each + +select json_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null}') +-- +FUNCTION: name="json_each" function="json_each" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_each('{\"f1\":[1,2,3],\"f2\":{\"f3\":1},\"f4\":null}')" +== 145 +-- truncate_limit: 100 +select * from json_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q +-- +FUNCTION: name="json_each" function="json_each" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_each('{\"f1\":[1,2,3],\"f2\":{\"f3\":1},\"f4\":null,\"f5\":99,\"f6\":\"stringy\"}') q" +== 146 +-- truncate_limit: 100 +select json_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":"null"}') +-- +FUNCTION: name="json_each_text" function="json_each_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_each_text('{\"f1\":[1,2,3],\"f2\":{\"f3\":1},\"f4\":null,\"f5\":\"null\"}')" +== 147 +-- truncate_limit: 100 +select * from json_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q +-- +FUNCTION: name="json_each_text" function="json_each_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_each_text('{\"f1\":[1,2,3],\"f2\":{\"f3\":1},\"f4\":null,\"f5\":99,\"f6\":\"stringy\"}') q" +== 148 +-- truncate_limit: 100 +-- extract_path, extract_path_as_text + +select json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6') +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path('{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f4', 'f6')" +== 149 +-- truncate_limit: 100 +select json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2') +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path('{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2')" +== 150 +-- truncate_limit: 100 +select json_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text) +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path('{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2', 0::text)" +== 151 +-- truncate_limit: 100 +select json_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text) +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path('{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2', 1::text)" +== 152 +-- truncate_limit: 100 +select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6') +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path_text('{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f4', 'f6')" +== 153 +-- truncate_limit: 100 +select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2') +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path_text('{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2')" +== 154 +-- truncate_limit: 100 +select json_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text) +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path_text('{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2', 0::text)" +== 155 +-- truncate_limit: 100 +select json_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text) +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path_text('{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2', 1::text)" +== 156 +-- truncate_limit: 100 +-- extract_path nulls + +select json_extract_path('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') is null as expect_false +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 157 +-- truncate_limit: 100 +select json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') is null as expect_true +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 158 +-- truncate_limit: 100 +select json_extract_path('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') is null as expect_false +-- +FUNCTION: name="json_extract_path" function="json_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path('{\"f2\":{\"f3\":1},\"f4\":[0,1,2,null]}', 'f4', '3') IS NULL AS expect_false" +== 159 +-- truncate_limit: 100 +select json_extract_path_text('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') is null as expect_true +-- +FUNCTION: name="json_extract_path_text" function="json_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_extract_path_text('{\"f2\":{\"f3\":1},\"f4\":[0,1,2,null]}', 'f4', '3') IS NULL AS expect_true" +== 160 +-- truncate_limit: 100 +-- extract_path operators + +select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f4','f6'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::pg_catalog.json #> ARRAY['f4', 'f6']" +== 161 +-- truncate_limit: 100 +select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::pg_catalog.json #> ARRAY['f2']" +== 162 +-- truncate_limit: 100 +select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','0'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::pg_catalog.json #> ARRAY['f2', '0']" +== 163 +-- truncate_limit: 100 +select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>array['f2','1'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::pg_catalog.json #> ARRAY['f2', '1']" +== 164 +-- truncate_limit: 100 +select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f4','f6'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::pg_catalog.json #>> ARRAY['f4', 'f6']" +== 165 +-- truncate_limit: 100 +select '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::pg_catalog.json #>> ARRAY['f2']" +== 166 +-- truncate_limit: 100 +select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','0'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::pg_catalog.json #>> ARRAY['f2', '0']" +== 167 +-- truncate_limit: 100 +select '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::json#>>array['f2','1'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::pg_catalog.json #>> ARRAY['f2', '1']" +== 168 +-- truncate_limit: 100 +-- corner cases for same +select '{"a": {"b":{"c": "foo"}}}'::json #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #> '{}'" +== 169 +-- truncate_limit: 100 +select '[1,2,3]'::json #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::pg_catalog.json #> '{}'" +== 170 +-- truncate_limit: 100 +select '"foo"'::json #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::pg_catalog.json #> '{}'" +== 171 +-- truncate_limit: 100 +select '42'::json #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::pg_catalog.json #> '{}'" +== 172 +-- truncate_limit: 100 +select 'null'::json #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'null'::pg_catalog.json #> '{}'" +== 173 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #> ARRAY['a']" +== 174 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', null] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #> ARRAY['a', NULL]" +== 175 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a', ''] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #> ARRAY['a', '']" +== 176 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #> ARRAY['a', 'b']" +== 177 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b','c'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #> ARRAY['a', 'b', 'c']" +== 178 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','b','c','d'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #> ARRAY['a', 'b', 'c', 'd']" +== 179 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #> array['a','z','c'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #> ARRAY['a', 'z', 'c']" +== 180 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json #> array['a','1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json #> ARRAY['a', '1', 'b']" +== 181 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json #> array['a','z','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json #> ARRAY['a', 'z', 'b']" +== 182 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json #> array['1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json #> ARRAY['1', 'b']" +== 183 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json #> array['z','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json #> ARRAY['z', 'b']" +== 184 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": null}]'::json #> array['1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": null}]'::pg_catalog.json #> ARRAY['1', 'b']" +== 185 +-- truncate_limit: 100 +select '"foo"'::json #> array['z'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::pg_catalog.json #> ARRAY['z']" +== 186 +-- truncate_limit: 100 +select '42'::json #> array['f2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::pg_catalog.json #> ARRAY['f2']" +== 187 +-- truncate_limit: 100 +select '42'::json #> array['0'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::pg_catalog.json #> ARRAY['0']" +== 188 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #>> '{}'" +== 189 +-- truncate_limit: 100 +select '[1,2,3]'::json #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::pg_catalog.json #>> '{}'" +== 190 +-- truncate_limit: 100 +select '"foo"'::json #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::pg_catalog.json #>> '{}'" +== 191 +-- truncate_limit: 100 +select '42'::json #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::pg_catalog.json #>> '{}'" +== 192 +-- truncate_limit: 100 +select 'null'::json #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'null'::pg_catalog.json #>> '{}'" +== 193 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #>> ARRAY['a']" +== 194 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a', null] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #>> ARRAY['a', NULL]" +== 195 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a', ''] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #>> ARRAY['a', '']" +== 196 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #>> ARRAY['a', 'b']" +== 197 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a','b','c'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #>> ARRAY['a', 'b', 'c']" +== 198 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a','b','c','d'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #>> ARRAY['a', 'b', 'c', 'd']" +== 199 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::json #>> array['a','z','c'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::pg_catalog.json #>> ARRAY['a', 'z', 'c']" +== 200 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json #>> array['a','1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json #>> ARRAY['a', '1', 'b']" +== 201 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json #>> array['a','z','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::pg_catalog.json #>> ARRAY['a', 'z', 'b']" +== 202 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json #>> array['1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json #>> ARRAY['1', 'b']" +== 203 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::json #>> array['z','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::pg_catalog.json #>> ARRAY['z', 'b']" +== 204 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": null}]'::json #>> array['1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": null}]'::pg_catalog.json #>> ARRAY['1', 'b']" +== 205 +-- truncate_limit: 100 +select '"foo"'::json #>> array['z'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::pg_catalog.json #>> ARRAY['z']" +== 206 +-- truncate_limit: 100 +select '42'::json #>> array['f2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::pg_catalog.json #>> ARRAY['f2']" +== 207 +-- truncate_limit: 100 +select '42'::json #>> array['0'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::pg_catalog.json #>> ARRAY['0']" +== 208 +-- truncate_limit: 100 +-- array_elements + +select json_array_elements('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') +-- +FUNCTION: name="json_array_elements" function="json_array_elements" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_array_elements('[1,true,[1,[2,3]],null,{\"f1\":1,\"f2\":[7,8,9]},false,\"stringy\"]')" +== 209 +-- truncate_limit: 100 +select * from json_array_elements('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') q +-- +FUNCTION: name="json_array_elements" function="json_array_elements" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_array_elements('[1,true,[1,[2,3]],null,{\"f1\":1,\"f2\":[7,8,9]},false,\"stringy\"]') q" +== 210 +-- truncate_limit: 100 +select json_array_elements_text('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') +-- +FUNCTION: name="json_array_elements_text" function="json_array_elements_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_array_elements_text('[1,true,[1,[2,3]],null,{\"f1\":1,\"f2\":[7,8,9]},false,\"stringy\"]')" +== 211 +-- truncate_limit: 100 +select * from json_array_elements_text('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') q +-- +FUNCTION: name="json_array_elements_text" function="json_array_elements_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_array_elements_text('[1,true,[1,[2,3]],null,{\"f1\":1,\"f2\":[7,8,9]},false,\"strin..." +== 212 +-- truncate_limit: 100 +-- populate_record +create type jpop as (a text, b int, c timestamp) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jpop AS (a text, b int, c timestamp)" +== 213 +-- truncate_limit: 100 +CREATE DOMAIN js_int_not_null AS int NOT NULL +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN js_int_not_null AS int NOT NULL" +== 214 +-- truncate_limit: 100 +CREATE DOMAIN js_int_array_1d AS int[] CHECK(array_length(VALUE, 1) = 3) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN js_int_array_1d AS int[] CHECK (array_length(value, 1) = 3)" +== 215 +-- truncate_limit: 100 +CREATE DOMAIN js_int_array_2d AS int[][] CHECK(array_length(VALUE, 2) = 3) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN js_int_array_2d AS int[][] CHECK (array_length(value, 2) = 3)" +== 216 +-- truncate_limit: 100 +create type j_unordered_pair as (x int, y int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE j_unordered_pair AS (x int, y int)" +== 217 +-- truncate_limit: 100 +create domain j_ordered_pair as j_unordered_pair check((value).x <= (value).y) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN j_ordered_pair AS j_unordered_pair CHECK ((value).x <= (value).y)" +== 218 +-- truncate_limit: 100 +CREATE TYPE jsrec AS ( + i int, + ia _int4, + ia1 int[], + ia2 int[][], + ia3 int[][][], + ia1d js_int_array_1d, + ia2d js_int_array_2d, + t text, + ta text[], + c char(10), + ca char(10)[], + ts timestamp, + js json, + jsb jsonb, + jsa json[], + rec jpop, + reca jpop[] +) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsrec AS (i int, ia _int4, ia1 int[], ia2 int[][], ia3 int[][][], ia1d js_int_array_1..." +== 219 +-- truncate_limit: 100 +CREATE TYPE jsrec_i_not_null AS ( + i js_int_not_null +) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsrec_i_not_null AS (i js_int_not_null)" +== 220 +-- truncate_limit: 100 +select * from json_populate_record(null::jpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(NULL::jpop, '{\"a\":\"blurfl\",\"x\":43.2}') q" +== 221 +-- truncate_limit: 100 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jpop, '{\"a\":\"blurfl\",\"x\":4..." +== 222 +-- truncate_limit: 100 +select * from json_populate_record(null::jpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(NULL::jpop, '{\"a\":\"blurfl\",\"x\":43.2}') q" +== 223 +-- truncate_limit: 100 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jpop, '{\"a\":\"blurfl\",\"x\":4..." +== 224 +-- truncate_limit: 100 +select * from json_populate_record(null::jpop,'{"a":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(NULL::jpop, '{\"a\":[100,200,false],\"x\":43.2}') q" +== 225 +-- truncate_limit: 100 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{"a":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jpop, '{\"a\":[100,200,false..." +== 226 +-- truncate_limit: 100 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{"c":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jpop, '{\"c\":[100,200,false..." +== 227 +-- truncate_limit: 100 +select * from json_populate_record(row('x',3,'2012-12-31 15:30:56')::jpop,'{}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jpop, '{}') q" +== 228 +-- truncate_limit: 100 +SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{"x": 43.2}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{\"x\": 43.2}') q" +== 229 +-- truncate_limit: 100 +SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{"i": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{\"i\": null}') q" +== 230 +-- truncate_limit: 100 +SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{"i": 12345}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i FROM json_populate_record(NULL::jsrec_i_not_null, '{\"i\": 12345}') q" +== 231 +-- truncate_limit: 100 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM json_populate_record(NULL::jsrec, '{\"ia\": null}') q" +== 232 +-- truncate_limit: 100 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM json_populate_record(NULL::jsrec, '{\"ia\": 123}') q" +== 233 +-- truncate_limit: 100 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM json_populate_record(NULL::jsrec, '{\"ia\": [1, \"2\", null, 4]}') q" +== 234 +-- truncate_limit: 100 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": [[1, 2], [3, 4]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM json_populate_record(NULL::jsrec, '{\"ia\": [[1, 2], [3, 4]]}') q" +== 235 +-- truncate_limit: 100 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": [[1], 2]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM json_populate_record(NULL::jsrec, '{\"ia\": [[1], 2]}') q" +== 236 +-- truncate_limit: 100 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": [[1], [2, 3]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM json_populate_record(NULL::jsrec, '{\"ia\": [[1], [2, 3]]}') q" +== 237 +-- truncate_limit: 100 +SELECT ia FROM json_populate_record(NULL::jsrec, '{"ia": "{1,2,3}"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM json_populate_record(NULL::jsrec, '{\"ia\": \"{1,2,3}\"}') q" +== 238 +-- truncate_limit: 100 +SELECT ia1 FROM json_populate_record(NULL::jsrec, '{"ia1": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1 FROM json_populate_record(NULL::jsrec, '{\"ia1\": null}') q" +== 239 +-- truncate_limit: 100 +SELECT ia1 FROM json_populate_record(NULL::jsrec, '{"ia1": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1 FROM json_populate_record(NULL::jsrec, '{\"ia1\": 123}') q" +== 240 +-- truncate_limit: 100 +SELECT ia1 FROM json_populate_record(NULL::jsrec, '{"ia1": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1 FROM json_populate_record(NULL::jsrec, '{\"ia1\": [1, \"2\", null, 4]}') q" +== 241 +-- truncate_limit: 100 +SELECT ia1 FROM json_populate_record(NULL::jsrec, '{"ia1": [[1, 2, 3]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1 FROM json_populate_record(NULL::jsrec, '{\"ia1\": [[1, 2, 3]]}') q" +== 242 +-- truncate_limit: 100 +SELECT ia1d FROM json_populate_record(NULL::jsrec, '{"ia1d": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1d FROM json_populate_record(NULL::jsrec, '{\"ia1d\": null}') q" +== 243 +-- truncate_limit: 100 +SELECT ia1d FROM json_populate_record(NULL::jsrec, '{"ia1d": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1d FROM json_populate_record(NULL::jsrec, '{\"ia1d\": 123}') q" +== 244 +-- truncate_limit: 100 +SELECT ia1d FROM json_populate_record(NULL::jsrec, '{"ia1d": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1d FROM json_populate_record(NULL::jsrec, '{\"ia1d\": [1, \"2\", null, 4]}') q" +== 245 +-- truncate_limit: 100 +SELECT ia1d FROM json_populate_record(NULL::jsrec, '{"ia1d": [1, "2", null]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1d FROM json_populate_record(NULL::jsrec, '{\"ia1d\": [1, \"2\", null]}') q" +== 246 +-- truncate_limit: 100 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM json_populate_record(NULL::jsrec, '{\"ia2\": [1, \"2\", null, 4]}') q" +== 247 +-- truncate_limit: 100 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [[1, 2], [null, 4]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM json_populate_record(NULL::jsrec, '{\"ia2\": [[1, 2], [null, 4]]}') q" +== 248 +-- truncate_limit: 100 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [[], []]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM json_populate_record(NULL::jsrec, '{\"ia2\": [[], []]}') q" +== 249 +-- truncate_limit: 100 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [[1, 2], [3]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM json_populate_record(NULL::jsrec, '{\"ia2\": [[1, 2], [3]]}') q" +== 250 +-- truncate_limit: 100 +SELECT ia2 FROM json_populate_record(NULL::jsrec, '{"ia2": [[1, 2], 3, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM json_populate_record(NULL::jsrec, '{\"ia2\": [[1, 2], 3, 4]}') q" +== 251 +-- truncate_limit: 100 +SELECT ia2d FROM json_populate_record(NULL::jsrec, '{"ia2d": [[1, "2"], [null, 4]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2d FROM json_populate_record(NULL::jsrec, '{\"ia2d\": [[1, \"2\"], [null, 4]]}') q" +== 252 +-- truncate_limit: 100 +SELECT ia2d FROM json_populate_record(NULL::jsrec, '{"ia2d": [[1, "2", 3], [null, 5, 6]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2d FROM json_populate_record(NULL::jsrec, '{\"ia2d\": [[1, \"2\", 3], [null, 5, 6]]}') q" +== 253 +-- truncate_limit: 100 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM json_populate_record(NULL::jsrec, '{\"ia3\": [1, \"2\", null, 4]}') q" +== 254 +-- truncate_limit: 100 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [[1, 2], [null, 4]]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM json_populate_record(NULL::jsrec, '{\"ia3\": [[1, 2], [null, 4]]}') q" +== 255 +-- truncate_limit: 100 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [ [[], []], [[], []], [[], []] ]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM json_populate_record(NULL::jsrec, '{\"ia3\": [ [[], []], [[], []], [[], []] ]}') q" +== 256 +-- truncate_limit: 100 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [ [[1, 2]], [[3, 4]] ]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM json_populate_record(NULL::jsrec, '{\"ia3\": [ [[1, 2]], [[3, 4]] ]}') q" +== 257 +-- truncate_limit: 100 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM json_populate_record(NULL::jsrec, '{\"ia3\": [ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]..." +== 258 +-- truncate_limit: 100 +SELECT ia3 FROM json_populate_record(NULL::jsrec, '{"ia3": [ [[1, 2], [3, 4]], [[5, 6], [7, 8], [9, 10]] ]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM json_populate_record(NULL::jsrec, '{\"ia3\": [ [[1, 2], [3, 4]], [[5, 6], [7, 8], [..." +== 259 +-- truncate_limit: 100 +SELECT ta FROM json_populate_record(NULL::jsrec, '{"ta": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ta FROM json_populate_record(NULL::jsrec, '{\"ta\": null}') q" +== 260 +-- truncate_limit: 100 +SELECT ta FROM json_populate_record(NULL::jsrec, '{"ta": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ta FROM json_populate_record(NULL::jsrec, '{\"ta\": 123}') q" +== 261 +-- truncate_limit: 100 +SELECT ta FROM json_populate_record(NULL::jsrec, '{"ta": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ta FROM json_populate_record(NULL::jsrec, '{\"ta\": [1, \"2\", null, 4]}') q" +== 262 +-- truncate_limit: 100 +SELECT ta FROM json_populate_record(NULL::jsrec, '{"ta": [[1, 2, 3], {"k": "v"}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ta FROM json_populate_record(NULL::jsrec, '{\"ta\": [[1, 2, 3], {\"k\": \"v\"}]}') q" +== 263 +-- truncate_limit: 100 +SELECT c FROM json_populate_record(NULL::jsrec, '{"c": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c FROM json_populate_record(NULL::jsrec, '{\"c\": null}') q" +== 264 +-- truncate_limit: 100 +SELECT c FROM json_populate_record(NULL::jsrec, '{"c": "aaa"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c FROM json_populate_record(NULL::jsrec, '{\"c\": \"aaa\"}') q" +== 265 +-- truncate_limit: 100 +SELECT c FROM json_populate_record(NULL::jsrec, '{"c": "aaaaaaaaaa"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c FROM json_populate_record(NULL::jsrec, '{\"c\": \"aaaaaaaaaa\"}') q" +== 266 +-- truncate_limit: 100 +SELECT c FROM json_populate_record(NULL::jsrec, '{"c": "aaaaaaaaaaaaa"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c FROM json_populate_record(NULL::jsrec, '{\"c\": \"aaaaaaaaaaaaa\"}') q" +== 267 +-- truncate_limit: 100 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM json_populate_record(NULL::jsrec, '{\"ca\": null}') q" +== 268 +-- truncate_limit: 100 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM json_populate_record(NULL::jsrec, '{\"ca\": 123}') q" +== 269 +-- truncate_limit: 100 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM json_populate_record(NULL::jsrec, '{\"ca\": [1, \"2\", null, 4]}') q" +== 270 +-- truncate_limit: 100 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": ["aaaaaaaaaaaaaaaa"]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM json_populate_record(NULL::jsrec, '{\"ca\": [\"aaaaaaaaaaaaaaaa\"]}') q" +== 271 +-- truncate_limit: 100 +SELECT ca FROM json_populate_record(NULL::jsrec, '{"ca": [[1, 2, 3], {"k": "v"}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM json_populate_record(NULL::jsrec, '{\"ca\": [[1, 2, 3], {\"k\": \"v\"}]}') q" +== 272 +-- truncate_limit: 100 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM json_populate_record(NULL::jsrec, '{\"js\": null}') q" +== 273 +-- truncate_limit: 100 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": true}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM json_populate_record(NULL::jsrec, '{\"js\": true}') q" +== 274 +-- truncate_limit: 100 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": 123.45}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM json_populate_record(NULL::jsrec, '{\"js\": 123.45}') q" +== 275 +-- truncate_limit: 100 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": "123.45"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM json_populate_record(NULL::jsrec, '{\"js\": \"123.45\"}') q" +== 276 +-- truncate_limit: 100 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": "abc"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM json_populate_record(NULL::jsrec, '{\"js\": \"abc\"}') q" +== 277 +-- truncate_limit: 100 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": [123, "123", null, {"key": "value"}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM json_populate_record(NULL::jsrec, '{\"js\": [123, \"123\", null, {\"key\": \"value\"}]}') q" +== 278 +-- truncate_limit: 100 +SELECT js FROM json_populate_record(NULL::jsrec, '{"js": {"a": "bbb", "b": null, "c": 123.45}}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM json_populate_record(NULL::jsrec, '{\"js\": {\"a\": \"bbb\", \"b\": null, \"c\": 123.45}}') q" +== 279 +-- truncate_limit: 100 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM json_populate_record(NULL::jsrec, '{\"jsb\": null}') q" +== 280 +-- truncate_limit: 100 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": true}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM json_populate_record(NULL::jsrec, '{\"jsb\": true}') q" +== 281 +-- truncate_limit: 100 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": 123.45}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM json_populate_record(NULL::jsrec, '{\"jsb\": 123.45}') q" +== 282 +-- truncate_limit: 100 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": "123.45"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM json_populate_record(NULL::jsrec, '{\"jsb\": \"123.45\"}') q" +== 283 +-- truncate_limit: 100 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": "abc"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM json_populate_record(NULL::jsrec, '{\"jsb\": \"abc\"}') q" +== 284 +-- truncate_limit: 100 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": [123, "123", null, {"key": "value"}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM json_populate_record(NULL::jsrec, '{\"jsb\": [123, \"123\", null, {\"key\": \"value\"}]}') q" +== 285 +-- truncate_limit: 100 +SELECT jsb FROM json_populate_record(NULL::jsrec, '{"jsb": {"a": "bbb", "b": null, "c": 123.45}}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM json_populate_record(NULL::jsrec, '{\"jsb\": {\"a\": \"bbb\", \"b\": null, \"c\": 123.45}}') q" +== 286 +-- truncate_limit: 100 +SELECT jsa FROM json_populate_record(NULL::jsrec, '{"jsa": null}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsa FROM json_populate_record(NULL::jsrec, '{\"jsa\": null}') q" +== 287 +-- truncate_limit: 100 +SELECT jsa FROM json_populate_record(NULL::jsrec, '{"jsa": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsa FROM json_populate_record(NULL::jsrec, '{\"jsa\": 123}') q" +== 288 +-- truncate_limit: 100 +SELECT jsa FROM json_populate_record(NULL::jsrec, '{"jsa": [1, "2", null, 4]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsa FROM json_populate_record(NULL::jsrec, '{\"jsa\": [1, \"2\", null, 4]}') q" +== 289 +-- truncate_limit: 100 +SELECT jsa FROM json_populate_record(NULL::jsrec, '{"jsa": ["aaa", null, [1, 2, "3", {}], { "k" : "v" }]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsa FROM json_populate_record(NULL::jsrec, '{\"jsa\": [\"aaa\", null, [1, 2, \"3\", {}], { \"k\" :..." +== 290 +-- truncate_limit: 100 +SELECT rec FROM json_populate_record(NULL::jsrec, '{"rec": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM json_populate_record(NULL::jsrec, '{\"rec\": 123}') q" +== 291 +-- truncate_limit: 100 +SELECT rec FROM json_populate_record(NULL::jsrec, '{"rec": [1, 2]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM json_populate_record(NULL::jsrec, '{\"rec\": [1, 2]}') q" +== 292 +-- truncate_limit: 100 +SELECT rec FROM json_populate_record(NULL::jsrec, '{"rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM json_populate_record(NULL::jsrec, '{\"rec\": {\"a\": \"abc\", \"c\": \"01.02.2003\", \"x\": 4..." +== 293 +-- truncate_limit: 100 +SELECT rec FROM json_populate_record(NULL::jsrec, '{"rec": "(abc,42,01.02.2003)"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM json_populate_record(NULL::jsrec, '{\"rec\": \"(abc,42,01.02.2003)\"}') q" +== 294 +-- truncate_limit: 100 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": 123}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reca FROM json_populate_record(NULL::jsrec, '{\"reca\": 123}') q" +== 295 +-- truncate_limit: 100 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": [1, 2]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reca FROM json_populate_record(NULL::jsrec, '{\"reca\": [1, 2]}') q" +== 296 +-- truncate_limit: 100 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": [{"a": "abc", "b": 456}, null, {"c": "01.02.2003", "x": 43.2}]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM json_populate_record(NULL::jsrec, '{\"reca\": [{\"a\": \"abc\", \"b\": 456}, null, {\"c\": ..." +== 297 +-- truncate_limit: 100 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": ["(abc,42,01.02.2003)"]}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reca FROM json_populate_record(NULL::jsrec, '{\"reca\": [\"(abc,42,01.02.2003)\"]}') q" +== 298 +-- truncate_limit: 100 +SELECT reca FROM json_populate_record(NULL::jsrec, '{"reca": "{\"(abc,42,01.02.2003)\"}"}') q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reca FROM json_populate_record(NULL::jsrec, E'{\"reca\": \"{\\\\\"(abc,42,01.02.2003)\\\\\"}\"}') q" +== 299 +-- truncate_limit: 100 +SELECT rec FROM json_populate_record( + row(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, + row('x',3,'2012-12-31 15:30:56')::jpop,NULL)::jsrec, + '{"rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}}' +) q +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM json_populate_record(ROW(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NU..." +== 300 +-- truncate_limit: 100 +-- anonymous record type +SELECT json_populate_record(null::record, '{"x": 0, "y": 1}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_record(NULL::record, '{\"x\": 0, \"y\": 1}')" +== 301 +-- truncate_limit: 100 +SELECT json_populate_record(row(1,2), '{"f1": 0, "f2": 1}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_record(ROW(1, 2), '{\"f1\": 0, \"f2\": 1}')" +== 302 +-- truncate_limit: 100 +SELECT * FROM + json_populate_record(null::record, '{"x": 776}') AS (x int, y int) +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_record(NULL::record, '{\"x\": 776}') AS (x int, y int)" +== 303 +-- truncate_limit: 100 +-- composite domain +SELECT json_populate_record(null::j_ordered_pair, '{"x": 0, "y": 1}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_record(NULL::j_ordered_pair, '{\"x\": 0, \"y\": 1}')" +== 304 +-- truncate_limit: 100 +SELECT json_populate_record(row(1,2)::j_ordered_pair, '{"x": 0}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_record(ROW(1, 2)::j_ordered_pair, '{\"x\": 0}')" +== 305 +-- truncate_limit: 100 +SELECT json_populate_record(row(1,2)::j_ordered_pair, '{"x": 1, "y": 0}') +-- +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_record(ROW(1, 2)::j_ordered_pair, '{\"x\": 1, \"y\": 0}')" +== 306 +-- truncate_limit: 100 +-- populate_recordset + +select * from json_populate_recordset(null::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(NULL::jpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":3,\"c\":\"2012-01-2..." +== 307 +-- truncate_limit: 100 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW('def', 99, NULL)::jpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":..." +== 308 +-- truncate_limit: 100 +select * from json_populate_recordset(null::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(NULL::jpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":3,\"c\":\"2012-01-2..." +== 309 +-- truncate_limit: 100 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW('def', 99, NULL)::jpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":..." +== 310 +-- truncate_limit: 100 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW('def', 99, NULL)::jpop, '[{\"a\":[100,200,300],\"x\":43.2},..." +== 311 +-- truncate_limit: 100 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"c":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW('def', 99, NULL)::jpop, '[{\"c\":[100,200,300],\"x\":43.2},..." +== 312 +-- truncate_limit: 100 +create type jpop2 as (a int, b json, c int, d int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jpop2 AS (a int, b pg_catalog.json, c int, d int)" +== 313 +-- truncate_limit: 100 +select * from json_populate_recordset(null::jpop2, '[{"a":2,"c":3,"b":{"z":4},"d":6}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(NULL::jpop2, '[{\"a\":2,\"c\":3,\"b\":{\"z\":4},\"d\":6}]') q" +== 314 +-- truncate_limit: 100 +select * from json_populate_recordset(null::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(NULL::jpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":3,\"c\":\"2012-01-2..." +== 315 +-- truncate_limit: 100 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW('def', 99, NULL)::jpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":..." +== 316 +-- truncate_limit: 100 +select * from json_populate_recordset(row('def',99,null)::jpop,'[{"a":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW('def', 99, NULL)::jpop, '[{\"a\":[100,200,300],\"x\":43.2},..." +== 317 +-- truncate_limit: 100 +-- anonymous record type +SELECT json_populate_recordset(null::record, '[{"x": 0, "y": 1}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_recordset(NULL::record, '[{\"x\": 0, \"y\": 1}]')" +== 318 +-- truncate_limit: 100 +SELECT json_populate_recordset(row(1,2), '[{"f1": 0, "f2": 1}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_recordset(ROW(1, 2), '[{\"f1\": 0, \"f2\": 1}]')" +== 319 +-- truncate_limit: 100 +SELECT i, json_populate_recordset(row(i,50), '[{"f1":"42"},{"f2":"43"}]') +FROM (VALUES (1),(2)) v(i) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i, json_populate_recordset(ROW(i, 50), '[{\"f1\":\"42\"},{\"f2\":\"43\"}]') FROM (VALUES (...)) v(i)" +== 320 +-- truncate_limit: 100 +SELECT * FROM + json_populate_recordset(null::record, '[{"x": 776}]') AS (x int, y int) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(NULL::record, '[{\"x\": 776}]') AS (x int, y int)" +== 321 +-- truncate_limit: 100 +-- empty array is a corner case +SELECT json_populate_recordset(null::record, '[]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_recordset(NULL::record, '[]')" +== 322 +-- truncate_limit: 100 +SELECT json_populate_recordset(row(1,2), '[]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_recordset(ROW(1, 2), '[]')" +== 323 +-- truncate_limit: 100 +SELECT * FROM json_populate_recordset(NULL::jpop,'[]') q +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(NULL::jpop, '[]') q" +== 324 +-- truncate_limit: 100 +SELECT * FROM + json_populate_recordset(null::record, '[]') AS (x int, y int) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(NULL::record, '[]') AS (x int, y int)" +== 325 +-- truncate_limit: 100 +-- composite domain +SELECT json_populate_recordset(null::j_ordered_pair, '[{"x": 0, "y": 1}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_recordset(NULL::j_ordered_pair, '[{\"x\": 0, \"y\": 1}]')" +== 326 +-- truncate_limit: 100 +SELECT json_populate_recordset(row(1,2)::j_ordered_pair, '[{"x": 0}, {"y": 3}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_recordset(ROW(1, 2)::j_ordered_pair, '[{\"x\": 0}, {\"y\": 3}]')" +== 327 +-- truncate_limit: 100 +SELECT json_populate_recordset(row(1,2)::j_ordered_pair, '[{"x": 1, "y": 0}]') +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_populate_recordset(ROW(1, 2)::j_ordered_pair, '[{\"x\": 1, \"y\": 0}]')" +== 328 +-- truncate_limit: 100 +-- negative cases where the wrong record type is supplied +select * from json_populate_recordset(row(0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW(0::int), '[{\"a\":\"1\",\"b\":\"2\"},{\"a\":\"3\"}]') q (a text, b ..." +== 329 +-- truncate_limit: 100 +select * from json_populate_recordset(row(0::int,0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW(0::int, 0::int), '[{\"a\":\"1\",\"b\":\"2\"},{\"a\":\"3\"}]') q (a ..." +== 330 +-- truncate_limit: 100 +select * from json_populate_recordset(row(0::int,0::int,0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW(0::int, 0::int, 0::int), '[{\"a\":\"1\",\"b\":\"2\"},{\"a\":\"3\"}]..." +== 331 +-- truncate_limit: 100 +select * from json_populate_recordset(row(1000000000::int,50::int),'[{"b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="json_populate_recordset" function="json_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_populate_recordset(ROW(1000000000::int, 50::int), '[{\"b\":\"2\"},{\"a\":\"3\"}]') q (..." +== 332 +-- truncate_limit: 100 +-- test type info caching in json_populate_record() +CREATE TEMP TABLE jspoptest (js json) +-- +TABLE: name="jspoptest" schema="" table="jspoptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE jspoptest (js pg_catalog.json)" +== 333 +-- truncate_limit: 100 +INSERT INTO jspoptest +SELECT '{ + "jsa": [1, "2", null, 4], + "rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}, + "reca": [{"a": "abc", "b": 456}, null, {"c": "01.02.2003", "x": 43.2}] +}'::json +FROM generate_series(1, 3) +-- +TABLE: name="jspoptest" schema="" table="jspoptest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO jspoptest SELECT ... FROM generate_series(1, 3)" +== 334 +-- truncate_limit: 100 +SELECT (json_populate_record(NULL::jsrec, js)).* FROM jspoptest +-- +TABLE: name="jspoptest" schema="" table="jspoptest" ctx=Select +FUNCTION: name="json_populate_record" function="json_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (json_populate_record(NULL::jsrec, js)).* FROM jspoptest" +== 335 +-- truncate_limit: 100 +DROP TYPE jsrec +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE jsrec" +== 336 +-- truncate_limit: 100 +DROP TYPE jsrec_i_not_null +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE jsrec_i_not_null" +== 337 +-- truncate_limit: 100 +DROP DOMAIN js_int_not_null +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN js_int_not_null" +== 338 +-- truncate_limit: 100 +DROP DOMAIN js_int_array_1d +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN js_int_array_1d" +== 339 +-- truncate_limit: 100 +DROP DOMAIN js_int_array_2d +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN js_int_array_2d" +== 340 +-- truncate_limit: 100 +DROP DOMAIN j_ordered_pair +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN j_ordered_pair" +== 341 +-- truncate_limit: 100 +DROP TYPE j_unordered_pair +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE j_unordered_pair" +== 342 +-- truncate_limit: 100 +--json_typeof() function +select value, json_typeof(value) + from (values (json '123.4'), + (json '-1'), + (json '"foo"'), + (json 'true'), + (json 'false'), + (json 'null'), + (json '[1, 2, 3]'), + (json '[]'), + (json '{"x":"foo", "y":123}'), + (json '{}'), + (NULL::json)) + as data(value) +-- +FUNCTION: name="json_typeof" function="json_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT value, json_typeof(value) FROM (VALUES (...)) data(value)" +== 343 +-- truncate_limit: 100 +-- json_build_array, json_build_object, json_object_agg + +SELECT json_build_array('a',1,'b',1.2,'c',true,'d',null,'e',json '{"x": 3, "y": [1,2,3]}') +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 344 +-- truncate_limit: 100 +SELECT json_build_array('a', NULL) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array('a', NULL)" +== 345 +-- truncate_limit: 100 +-- ok +SELECT json_build_array(VARIADIC NULL::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array(VARIADIC NULL::text[])" +== 346 +-- truncate_limit: 100 +-- ok +SELECT json_build_array(VARIADIC '{}'::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array(VARIADIC '{}'::text[])" +== 347 +-- truncate_limit: 100 +-- ok +SELECT json_build_array(VARIADIC '{a,b,c}'::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array(VARIADIC '{a,b,c}'::text[])" +== 348 +-- truncate_limit: 100 +-- ok +SELECT json_build_array(VARIADIC ARRAY['a', NULL]::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array(VARIADIC ARRAY['a', NULL]::text[])" +== 349 +-- truncate_limit: 100 +-- ok +SELECT json_build_array(VARIADIC '{1,2,3,4}'::text[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array(VARIADIC '{1,2,3,4}'::text[])" +== 350 +-- truncate_limit: 100 +-- ok +SELECT json_build_array(VARIADIC '{1,2,3,4}'::int[]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array(VARIADIC '{1,2,3,4}'::int[])" +== 351 +-- truncate_limit: 100 +-- ok +SELECT json_build_array(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][]) +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][])" +== 352 +-- truncate_limit: 100 +-- ok + +SELECT json_build_object('a',1,'b',1.2,'c',true,'d',null,'e',json '{"x": 3, "y": [1,2,3]}') +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 353 +-- truncate_limit: 100 +SELECT json_build_object( + 'a', json_build_object('b',false,'c',99), + 'd', json_build_object('e',array[9,8,7]::int[], + 'f', (select row_to_json(r) from ( select relkind, oid::regclass as name from pg_class where relname = 'pg_class') r))) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 354 +-- truncate_limit: 100 +SELECT json_build_object('{a,b,c}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object('{a,b,c}'::text[])" +== 355 +-- truncate_limit: 100 +-- error +SELECT json_build_object('{a,b,c}'::text[], '{d,e,f}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object('{a,b,c}'::text[], '{d,e,f}'::text[])" +== 356 +-- truncate_limit: 100 +-- error, key cannot be array +SELECT json_build_object('a', 'b', 'c') +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object('a', 'b', 'c')" +== 357 +-- truncate_limit: 100 +-- error +SELECT json_build_object(NULL, 'a') +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(NULL, 'a')" +== 358 +-- truncate_limit: 100 +-- error, key cannot be NULL +SELECT json_build_object('a', NULL) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object('a', NULL)" +== 359 +-- truncate_limit: 100 +-- ok +SELECT json_build_object(VARIADIC NULL::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(VARIADIC NULL::text[])" +== 360 +-- truncate_limit: 100 +-- ok +SELECT json_build_object(VARIADIC '{}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(VARIADIC '{}'::text[])" +== 361 +-- truncate_limit: 100 +-- ok +SELECT json_build_object(VARIADIC '{a,b,c}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(VARIADIC '{a,b,c}'::text[])" +== 362 +-- truncate_limit: 100 +-- error +SELECT json_build_object(VARIADIC ARRAY['a', NULL]::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(VARIADIC ARRAY['a', NULL]::text[])" +== 363 +-- truncate_limit: 100 +-- ok +SELECT json_build_object(VARIADIC ARRAY[NULL, 'a']::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(VARIADIC ARRAY[NULL, 'a']::text[])" +== 364 +-- truncate_limit: 100 +-- error, key cannot be NULL +SELECT json_build_object(VARIADIC '{1,2,3,4}'::text[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(VARIADIC '{1,2,3,4}'::text[])" +== 365 +-- truncate_limit: 100 +-- ok +SELECT json_build_object(VARIADIC '{1,2,3,4}'::int[]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(VARIADIC '{1,2,3,4}'::int[])" +== 366 +-- truncate_limit: 100 +-- ok +SELECT json_build_object(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][]) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][])" +== 367 +-- truncate_limit: 100 +-- ok + +-- empty objects/arrays +SELECT json_build_array() +-- +FUNCTION: name="json_build_array" function="json_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_array()" +== 368 +-- truncate_limit: 100 +SELECT json_build_object() +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object()" +== 369 +-- truncate_limit: 100 +-- make sure keys are quoted +SELECT json_build_object(1,2) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(1, 2)" +== 370 +-- truncate_limit: 100 +-- keys must be scalar and not null +SELECT json_build_object(null,2) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(NULL, 2)" +== 371 +-- truncate_limit: 100 +SELECT json_build_object(r,2) FROM (SELECT 1 AS a, 2 AS b) r +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object(r, 2) FROM (SELECT 1 AS a, 2 AS b) r" +== 372 +-- truncate_limit: 100 +SELECT json_build_object(json '{"a":1,"b":2}', 3) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object('{\"a\":1,\"b\":2}'::pg_catalog.json, 3)" +== 373 +-- truncate_limit: 100 +SELECT json_build_object('{1,2,3}'::int[], 3) +-- +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_build_object('{1,2,3}'::int[], 3)" +== 374 +-- truncate_limit: 100 +CREATE TEMP TABLE foo (serial_num int, name text, type text) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (serial_num int, name text, type text)" +== 375 +-- truncate_limit: 100 +INSERT INTO foo VALUES (847001,'t15','GE1043') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (847001, 't15', 'GE1043')" +== 376 +-- truncate_limit: 100 +INSERT INTO foo VALUES (847002,'t16','GE1043') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (847002, 't16', 'GE1043')" +== 377 +-- truncate_limit: 100 +INSERT INTO foo VALUES (847003,'sub-alpha','GESS90') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (847003, 'sub-alpha', 'GESS90')" +== 378 +-- truncate_limit: 100 +SELECT json_build_object('turbines',json_object_agg(serial_num,json_build_object('name',name,'type',type))) +FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +FUNCTION: name="json_object_agg" function="json_object_agg" schema="" ctx=Call +FUNCTION: name="json_build_object" function="json_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM foo" +== 379 +-- truncate_limit: 100 +SELECT json_object_agg(name, type) FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="json_object_agg" function="json_object_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_object_agg(name, type) FROM foo" +== 380 +-- truncate_limit: 100 +INSERT INTO foo VALUES (999999, NULL, 'bar') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (999999, NULL, 'bar')" +== 381 +-- truncate_limit: 100 +SELECT json_object_agg(name, type) FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="json_object_agg" function="json_object_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_object_agg(name, type) FROM foo" +== 382 +-- truncate_limit: 100 +-- json_object + +-- empty object, one dimension +SELECT json_object('{}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{}')" +== 383 +-- truncate_limit: 100 +-- empty object, two dimensions +SELECT json_object('{}', '{}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{}', '{}')" +== 384 +-- truncate_limit: 100 +-- one dimension +SELECT json_object('{a,1,b,2,3,NULL,"d e f","a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{a,1,b,2,3,NULL,\"d e f\",\"a b c\"}')" +== 385 +-- truncate_limit: 100 +-- same but with two dimensions +SELECT json_object('{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{{a,1},{b,2},{3,NULL},{\"d e f\",\"a b c\"}}')" +== 386 +-- truncate_limit: 100 +-- odd number error +SELECT json_object('{a,b,c}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{a,b,c}')" +== 387 +-- truncate_limit: 100 +-- one column error +SELECT json_object('{{a},{b}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{{a},{b}}')" +== 388 +-- truncate_limit: 100 +-- too many columns error +SELECT json_object('{{a,b,c},{b,c,d}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{{a,b,c},{b,c,d}}')" +== 389 +-- truncate_limit: 100 +-- too many dimensions error +SELECT json_object('{{{a,b},{c,d}},{{b,c},{d,e}}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{{{a,b},{c,d}},{{b,c},{d,e}}}')" +== 390 +-- truncate_limit: 100 +--two argument form of json_object + +select json_object('{a,b,c,"d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{a,b,c,\"d e f\"}', '{1,2,3,\"a b c\"}')" +== 391 +-- truncate_limit: 100 +-- too many dimensions +SELECT json_object('{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}', '{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 392 +-- truncate_limit: 100 +-- mismatched dimensions + +select json_object('{a,b,c,"d e f",g}','{1,2,3,"a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{a,b,c,\"d e f\",g}', '{1,2,3,\"a b c\"}')" +== 393 +-- truncate_limit: 100 +select json_object('{a,b,c,"d e f"}','{1,2,3,"a b c",g}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{a,b,c,\"d e f\"}', '{1,2,3,\"a b c\",g}')" +== 394 +-- truncate_limit: 100 +-- null key error + +select json_object('{a,b,NULL,"d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{a,b,NULL,\"d e f\"}', '{1,2,3,\"a b c\"}')" +== 395 +-- truncate_limit: 100 +-- empty key is allowed + +select json_object('{a,b,"","d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="pg_catalog.json_object" function="json_object" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.\"json_object\"('{a,b,\"\",\"d e f\"}', '{1,2,3,\"a b c\"}')" +== 396 +-- truncate_limit: 100 +-- json_object_agg_unique requires unique keys +select json_object_agg_unique(mod(i,100), i) from generate_series(0, 199) i +-- +FUNCTION: name="json_object_agg_unique" function="json_object_agg_unique" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_object_agg_unique(mod(i, 100), i) FROM generate_series(0, 199) i" +== 397 +-- truncate_limit: 100 +-- json_to_record and json_to_recordset + +select * from json_to_record('{"a":1,"b":"foo","c":"bar"}') + as x(a int, b text, d text) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"a\":1,\"b\":\"foo\",\"c\":\"bar\"}') x (a int, b text, d text)" +== 398 +-- truncate_limit: 100 +select * from json_to_recordset('[{"a":1,"b":"foo","d":false},{"a":2,"b":"bar","c":true}]') + as x(a int, b text, c boolean) +-- +FUNCTION: name="json_to_recordset" function="json_to_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_recordset('[{\"a\":1,\"b\":\"foo\",\"d\":false},{\"a\":2,\"b\":\"bar\",\"c\":true}]') x (a ..." +== 399 +-- truncate_limit: 100 +select * from json_to_recordset('[{"a":1,"b":{"d":"foo"},"c":true},{"a":2,"c":false,"b":{"d":"bar"}}]') + as x(a int, b json, c boolean) +-- +FUNCTION: name="json_to_recordset" function="json_to_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_recordset('[{\"a\":1,\"b\":{\"d\":\"foo\"},\"c\":true},{\"a\":2,\"c\":false,\"b\":{\"d\":\"bar..." +== 400 +-- truncate_limit: 100 +select *, c is null as c_is_null +from json_to_record('{"a":1, "b":{"c":16, "d":2}, "x":8, "ca": ["1 2", 3], "ia": [[1,2],[3,4]], "r": {"a": "aaa", "b": 123}}'::json) + as t(a int, b json, c text, x int, ca char(5)[], ia int[][], r jpop) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM json_to_record('{\"a\":1, \"b\":{\"c\":16, \"d\":2}, \"x\":8, \"ca\": [\"1 2\", 3], \"ia\": [[1,2..." +== 401 +-- truncate_limit: 100 +select *, c is null as c_is_null +from json_to_recordset('[{"a":1, "b":{"c":16, "d":2}, "x":8}]'::json) + as t(a int, b json, c text, x int) +-- +FUNCTION: name="json_to_recordset" function="json_to_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM json_to_recordset('[{\"a\":1, \"b\":{\"c\":16, \"d\":2}, \"x\":8}]'::pg_catalog.json) t (a ..." +== 402 +-- truncate_limit: 100 +select * from json_to_record('{"ia": null}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia\": null}') x (ia _int4)" +== 403 +-- truncate_limit: 100 +select * from json_to_record('{"ia": 123}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia\": 123}') x (ia _int4)" +== 404 +-- truncate_limit: 100 +select * from json_to_record('{"ia": [1, "2", null, 4]}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia\": [1, \"2\", null, 4]}') x (ia _int4)" +== 405 +-- truncate_limit: 100 +select * from json_to_record('{"ia": [[1, 2], [3, 4]]}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia\": [[1, 2], [3, 4]]}') x (ia _int4)" +== 406 +-- truncate_limit: 100 +select * from json_to_record('{"ia": [[1], 2]}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia\": [[1], 2]}') x (ia _int4)" +== 407 +-- truncate_limit: 100 +select * from json_to_record('{"ia": [[1], [2, 3]]}') as x(ia _int4) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia\": [[1], [2, 3]]}') x (ia _int4)" +== 408 +-- truncate_limit: 100 +select * from json_to_record('{"ia2": [1, 2, 3]}') as x(ia2 int[][]) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia2\": [1, 2, 3]}') x (ia2 int[][])" +== 409 +-- truncate_limit: 100 +select * from json_to_record('{"ia2": [[1, 2], [3, 4]]}') as x(ia2 int4[][]) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia2\": [[1, 2], [3, 4]]}') x (ia2 int4[][])" +== 410 +-- truncate_limit: 100 +select * from json_to_record('{"ia2": [[[1], [2], [3]]]}') as x(ia2 int4[][]) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"ia2\": [[[1], [2], [3]]]}') x (ia2 int4[][])" +== 411 +-- truncate_limit: 100 +select * from json_to_record('{"out": {"key": 1}}') as x(out json) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"out\": {\"key\": 1}}') x (\"out\" pg_catalog.json)" +== 412 +-- truncate_limit: 100 +select * from json_to_record('{"out": [{"key": 1}]}') as x(out json) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"out\": [{\"key\": 1}]}') x (\"out\" pg_catalog.json)" +== 413 +-- truncate_limit: 100 +select * from json_to_record('{"out": "{\"key\": 1}"}') as x(out json) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record(E'{\"out\": \"{\\\\\"key\\\\\": 1}\"}') x (\"out\" pg_catalog.json)" +== 414 +-- truncate_limit: 100 +select * from json_to_record('{"out": {"key": 1}}') as x(out jsonb) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"out\": {\"key\": 1}}') x (\"out\" jsonb)" +== 415 +-- truncate_limit: 100 +select * from json_to_record('{"out": [{"key": 1}]}') as x(out jsonb) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record('{\"out\": [{\"key\": 1}]}') x (\"out\" jsonb)" +== 416 +-- truncate_limit: 100 +select * from json_to_record('{"out": "{\"key\": 1}"}') as x(out jsonb) +-- +FUNCTION: name="json_to_record" function="json_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_to_record(E'{\"out\": \"{\\\\\"key\\\\\": 1}\"}') x (\"out\" jsonb)" +== 417 +-- truncate_limit: 100 +-- json_strip_nulls + +select json_strip_nulls(null) +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_strip_nulls(NULL)" +== 418 +-- truncate_limit: 100 +select json_strip_nulls('1') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_strip_nulls('1')" +== 419 +-- truncate_limit: 100 +select json_strip_nulls('"a string"') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_strip_nulls('\"a string\"')" +== 420 +-- truncate_limit: 100 +select json_strip_nulls('null') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_strip_nulls('null')" +== 421 +-- truncate_limit: 100 +select json_strip_nulls('[1,2,null,3,4]') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_strip_nulls('[1,2,null,3,4]')" +== 422 +-- truncate_limit: 100 +select json_strip_nulls('{"a":1,"b":null,"c":[2,null,3],"d":{"e":4,"f":null}}') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_strip_nulls('{\"a\":1,\"b\":null,\"c\":[2,null,3],\"d\":{\"e\":4,\"f\":null}}')" +== 423 +-- truncate_limit: 100 +select json_strip_nulls('[1,{"a":1,"b":null,"c":2},3]') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_strip_nulls('[1,{\"a\":1,\"b\":null,\"c\":2},3]')" +== 424 +-- truncate_limit: 100 +-- an empty object is not null and should not be stripped +select json_strip_nulls('{"a": {"b": null, "c": null}, "d": {} }') +-- +FUNCTION: name="json_strip_nulls" function="json_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_strip_nulls('{\"a\": {\"b\": null, \"c\": null}, \"d\": {} }')" +== 425 +-- truncate_limit: 100 +-- json to tsvector +select to_tsvector('{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 426 +-- truncate_limit: 100 +-- json to tsvector with config +select to_tsvector('simple', '{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 427 +-- truncate_limit: 100 +-- json to tsvector with stop words +select to_tsvector('english', '{"a": "aaa in bbb ddd ccc", "b": ["the eee fff ggg"], "c": {"d": "hhh. iii"}}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 428 +-- truncate_limit: 100 +-- json to tsvector with numeric values +select to_tsvector('english', '{"a": "aaa in bbb ddd ccc", "b": 123, "c": 456}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('english', '{\"a\": \"aaa in bbb ddd ccc\", \"b\": 123, \"c\": 456}'::pg_catalog.json)" +== 429 +-- truncate_limit: 100 +-- json_to_tsvector +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 430 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"key"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 431 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"string"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 432 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"numeric"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 433 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"boolean"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 434 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '["string", "numeric"]') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 435 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 436 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"key"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 437 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"string"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 438 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"numeric"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 439 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '"boolean"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 440 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '["string", "numeric"]') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 441 +-- truncate_limit: 100 +-- to_tsvector corner cases +select to_tsvector('""'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('\"\"'::pg_catalog.json)" +== 442 +-- truncate_limit: 100 +select to_tsvector('{}'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('{}'::pg_catalog.json)" +== 443 +-- truncate_limit: 100 +select to_tsvector('[]'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('[]'::pg_catalog.json)" +== 444 +-- truncate_limit: 100 +select to_tsvector('null'::json) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('null'::pg_catalog.json)" +== 445 +-- truncate_limit: 100 +-- json_to_tsvector corner cases +select json_to_tsvector('""'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_to_tsvector('\"\"'::pg_catalog.json, '\"all\"')" +== 446 +-- truncate_limit: 100 +select json_to_tsvector('{}'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_to_tsvector('{}'::pg_catalog.json, '\"all\"')" +== 447 +-- truncate_limit: 100 +select json_to_tsvector('[]'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_to_tsvector('[]'::pg_catalog.json, '\"all\"')" +== 448 +-- truncate_limit: 100 +select json_to_tsvector('null'::json, '"all"') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT json_to_tsvector('null'::pg_catalog.json, '\"all\"')" +== 449 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '""') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 450 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '{}') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 451 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '[]') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 452 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, 'null') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 453 +-- truncate_limit: 100 +select json_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::json, '["all", null]') +-- +FUNCTION: name="json_to_tsvector" function="json_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 454 +-- truncate_limit: 100 +-- ts_headline for json +select ts_headline('{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::json, tsquery('bbb & ddd & hhh')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 455 +-- truncate_limit: 100 +select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc ddd fff"}, "d": ["ggg hhh", "iii jjj"]}'::json, tsquery('bbb & ddd & hhh')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 456 +-- truncate_limit: 100 +select ts_headline('{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::json, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 457 +-- truncate_limit: 100 +select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::json, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 458 +-- truncate_limit: 100 +-- corner cases for ts_headline with json +select ts_headline('null'::json, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('null'::pg_catalog.json, tsquery('aaa & bbb'))" +== 459 +-- truncate_limit: 100 +select ts_headline('{}'::json, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('{}'::pg_catalog.json, tsquery('aaa & bbb'))" +== 460 +-- truncate_limit: 100 +select ts_headline('[]'::json, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('[]'::pg_catalog.json, tsquery('aaa & bbb'))" diff --git a/parser/testdata/summary_truncate/postgres_regress/json_encoding.metadata.json b/parser/testdata/summary_truncate/postgres_regress/json_encoding.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/json_encoding.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/json_encoding.test b/parser/testdata/summary_truncate/postgres_regress/json_encoding.test new file mode 100644 index 0000000..8462576 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/json_encoding.test @@ -0,0 +1,319 @@ +== 001 +-- truncate_limit: 100 +|-- +-- encoding-sensitive tests for json and jsonb +|-- + +-- We provide expected-results files for UTF8 (json_encoding.out) +-- and for SQL_ASCII (json_encoding_1.out). Skip otherwise. +SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') + AS skip_test +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test" +== 002 +-- truncate_limit: 100 +SELECT getdatabaseencoding() +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT getdatabaseencoding()" +== 003 +-- truncate_limit: 100 +-- just to label the results files + +-- first json + +-- basic unicode input +SELECT '"\u"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u\"'::pg_catalog.json" +== 004 +-- truncate_limit: 100 +-- ERROR, incomplete escape +SELECT '"\u00"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u00\"'::pg_catalog.json" +== 005 +-- truncate_limit: 100 +-- ERROR, incomplete escape +SELECT '"\u000g"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u000g\"'::pg_catalog.json" +== 006 +-- truncate_limit: 100 +-- ERROR, g is not a hex digit +SELECT '"\u0000"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u0000\"'::pg_catalog.json" +== 007 +-- truncate_limit: 100 +-- OK, legal escape +SELECT '"\uaBcD"'::json +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\uaBcD\"'::pg_catalog.json" +== 008 +-- truncate_limit: 100 +-- OK, uppercase and lower case both OK + +-- handling of unicode surrogate pairs + +select json '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a' as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ud83d\\\\ude04\\\\ud83d\\\\udc36\" }'::pg_catalog.json -> 'a' AS correct_in_utf8" +== 009 +-- truncate_limit: 100 +select json '{ "a": "\ud83d\ud83d" }' -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ud83d\\\\ud83d\" }'::pg_catalog.json -> 'a'" +== 010 +-- truncate_limit: 100 +-- 2 high surrogates in a row +select json '{ "a": "\ude04\ud83d" }' -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ude04\\\\ud83d\" }'::pg_catalog.json -> 'a'" +== 011 +-- truncate_limit: 100 +-- surrogates in wrong order +select json '{ "a": "\ud83dX" }' -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ud83dX\" }'::pg_catalog.json -> 'a'" +== 012 +-- truncate_limit: 100 +-- orphan high surrogate +select json '{ "a": "\ude04X" }' -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ude04X\" }'::pg_catalog.json -> 'a'" +== 013 +-- truncate_limit: 100 +-- orphan low surrogate + +--handling of simple unicode escapes + +select json '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"the Copyright \\\\u00a9 sign\" }'::pg_catalog.json AS correct_in_utf8" +== 014 +-- truncate_limit: 100 +select json '{ "a": "dollar \u0024 character" }' as correct_everywhere +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"dollar \\\\u0024 character\" }'::pg_catalog.json AS correct_everywhere" +== 015 +-- truncate_limit: 100 +select json '{ "a": "dollar \\u0024 character" }' as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"dollar \\\\\\\\u0024 character\" }'::pg_catalog.json AS not_an_escape" +== 016 +-- truncate_limit: 100 +select json '{ "a": "null \u0000 escape" }' as not_unescaped +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"null \\\\u0000 escape\" }'::pg_catalog.json AS not_unescaped" +== 017 +-- truncate_limit: 100 +select json '{ "a": "null \\u0000 escape" }' as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"null \\\\\\\\u0000 escape\" }'::pg_catalog.json AS not_an_escape" +== 018 +-- truncate_limit: 100 +select json '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"the Copyright \\\\u00a9 sign\" }'::pg_catalog.json ->> 'a' AS correct_in_utf8" +== 019 +-- truncate_limit: 100 +select json '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"dollar \\\\u0024 character\" }'::pg_catalog.json ->> 'a' AS correct_everywhere" +== 020 +-- truncate_limit: 100 +select json '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"dollar \\\\\\\\u0024 character\" }'::pg_catalog.json ->> 'a' AS not_an_escape" +== 021 +-- truncate_limit: 100 +select json '{ "a": "null \u0000 escape" }' ->> 'a' as fails +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"null \\\\u0000 escape\" }'::pg_catalog.json ->> 'a' AS fails" +== 022 +-- truncate_limit: 100 +select json '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"null \\\\\\\\u0000 escape\" }'::pg_catalog.json ->> 'a' AS not_an_escape" +== 023 +-- truncate_limit: 100 +-- then jsonb + +-- basic unicode input +SELECT '"\u"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u\"'::jsonb" +== 024 +-- truncate_limit: 100 +-- ERROR, incomplete escape +SELECT '"\u00"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u00\"'::jsonb" +== 025 +-- truncate_limit: 100 +-- ERROR, incomplete escape +SELECT '"\u000g"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u000g\"'::jsonb" +== 026 +-- truncate_limit: 100 +-- ERROR, g is not a hex digit +SELECT '"\u0045"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u0045\"'::jsonb" +== 027 +-- truncate_limit: 100 +-- OK, legal escape +SELECT '"\u0000"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u0000\"'::jsonb" +== 028 +-- truncate_limit: 100 +-- ERROR, we don't support U+0000 +-- use octet_length here so we don't get an odd unicode char in the +-- output +SELECT octet_length('"\uaBcD"'::jsonb::text) +-- +FUNCTION: name="octet_length" function="octet_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT octet_length(E'\"\\\\uaBcD\"'::jsonb::text)" +== 029 +-- truncate_limit: 100 +-- OK, uppercase and lower case both OK + +-- handling of unicode surrogate pairs + +SELECT octet_length((jsonb '{ "a": "\ud83d\ude04\ud83d\udc36" }' -> 'a')::text) AS correct_in_utf8 +-- +FUNCTION: name="octet_length" function="octet_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 030 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "\ud83d\ud83d" }' -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ud83d\\\\ud83d\" }'::jsonb -> 'a'" +== 031 +-- truncate_limit: 100 +-- 2 high surrogates in a row +SELECT jsonb '{ "a": "\ude04\ud83d" }' -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ude04\\\\ud83d\" }'::jsonb -> 'a'" +== 032 +-- truncate_limit: 100 +-- surrogates in wrong order +SELECT jsonb '{ "a": "\ud83dX" }' -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ud83dX\" }'::jsonb -> 'a'" +== 033 +-- truncate_limit: 100 +-- orphan high surrogate +SELECT jsonb '{ "a": "\ude04X" }' -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"\\\\ude04X\" }'::jsonb -> 'a'" +== 034 +-- truncate_limit: 100 +-- orphan low surrogate + +-- handling of simple unicode escapes + +SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"the Copyright \\\\u00a9 sign\" }'::jsonb AS correct_in_utf8" +== 035 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "dollar \u0024 character" }' as correct_everywhere +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"dollar \\\\u0024 character\" }'::jsonb AS correct_everywhere" +== 036 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "dollar \\u0024 character" }' as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"dollar \\\\\\\\u0024 character\" }'::jsonb AS not_an_escape" +== 037 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "null \u0000 escape" }' as fails +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"null \\\\u0000 escape\" }'::jsonb AS fails" +== 038 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "null \\u0000 escape" }' as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"null \\\\\\\\u0000 escape\" }'::jsonb AS not_an_escape" +== 039 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "the Copyright \u00a9 sign" }' ->> 'a' as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"the Copyright \\\\u00a9 sign\" }'::jsonb ->> 'a' AS correct_in_utf8" +== 040 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "dollar \u0024 character" }' ->> 'a' as correct_everywhere +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"dollar \\\\u0024 character\" }'::jsonb ->> 'a' AS correct_everywhere" +== 041 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "dollar \\u0024 character" }' ->> 'a' as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"dollar \\\\\\\\u0024 character\" }'::jsonb ->> 'a' AS not_an_escape" +== 042 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "null \u0000 escape" }' ->> 'a' as fails +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"null \\\\u0000 escape\" }'::jsonb ->> 'a' AS fails" +== 043 +-- truncate_limit: 100 +SELECT jsonb '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{ \"a\": \"null \\\\\\\\u0000 escape\" }'::jsonb ->> 'a' AS not_an_escape" +== 044 +-- truncate_limit: 100 +-- soft error for input-time failure + +select * from pg_input_error_info('{ "a": "\ud83d\ude04\ud83d\udc36" }', 'jsonb') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info(E'{ \"a\": \"\\\\ud83d\\\\ude04\\\\ud83d\\\\udc36\" }', 'jsonb')" diff --git a/parser/testdata/summary_truncate/postgres_regress/jsonb.metadata.json b/parser/testdata/summary_truncate/postgres_regress/jsonb.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/jsonb.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/jsonb.test b/parser/testdata/summary_truncate/postgres_regress/jsonb.test new file mode 100644 index 0000000..8ae12a4 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/jsonb.test @@ -0,0 +1,7703 @@ +== 001 +-- truncate_limit: 100 +-- directory paths are passed to us in environment variables + +CREATE TABLE testjsonb ( + j jsonb +) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testjsonb (j jsonb)" +== 002 +-- truncate_limit: 100 +COPY testjsonb FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +-- truncate_limit: 100 +-- Strings. +SELECT '""'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"\"'::jsonb" +== 004 +-- truncate_limit: 100 +-- OK. +SELECT $$''$$::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''''''::jsonb" +== 005 +-- truncate_limit: 100 +-- ERROR, single quotes are not allowed +SELECT '"abc"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"abc\"'::jsonb" +== 006 +-- truncate_limit: 100 +-- OK +SELECT '"abc'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"abc'::jsonb" +== 007 +-- truncate_limit: 100 +-- ERROR, quotes not closed +SELECT '"abc +def"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"abc\ndef\"'::jsonb" +== 008 +-- truncate_limit: 100 +-- ERROR, unescaped newline in string constant +SELECT '"\n\"\\"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\n\\\\\"\\\\\\\\\"'::jsonb" +== 009 +-- truncate_limit: 100 +-- OK, legal escapes +SELECT '"\v"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\v\"'::jsonb" +== 010 +-- truncate_limit: 100 +-- ERROR, not a valid JSON escape +-- see json_encoding test for input with unicode escapes + +-- Numbers. +SELECT '1'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::jsonb" +== 011 +-- truncate_limit: 100 +-- OK +SELECT '0'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0'::jsonb" +== 012 +-- truncate_limit: 100 +-- OK +SELECT '01'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '01'::jsonb" +== 013 +-- truncate_limit: 100 +-- ERROR, not valid according to JSON spec +SELECT '0.1'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.1'::jsonb" +== 014 +-- truncate_limit: 100 +-- OK +SELECT '9223372036854775808'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775808'::jsonb" +== 015 +-- truncate_limit: 100 +-- OK, even though it's too large for int8 +SELECT '1e100'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1e100'::jsonb" +== 016 +-- truncate_limit: 100 +-- OK +SELECT '1.3e100'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.3e100'::jsonb" +== 017 +-- truncate_limit: 100 +-- OK +SELECT '1f2'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1f2'::jsonb" +== 018 +-- truncate_limit: 100 +-- ERROR +SELECT '0.x1'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.x1'::jsonb" +== 019 +-- truncate_limit: 100 +-- ERROR +SELECT '1.3ex100'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.3ex100'::jsonb" +== 020 +-- truncate_limit: 100 +-- ERROR + +-- Arrays. +SELECT '[]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb" +== 021 +-- truncate_limit: 100 +-- OK +SELECT '[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 022 +-- truncate_limit: 100 +-- OK +SELECT '[1,2]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2]'::jsonb" +== 023 +-- truncate_limit: 100 +-- OK +SELECT '[1,2,]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,]'::jsonb" +== 024 +-- truncate_limit: 100 +-- ERROR, trailing comma +SELECT '[1,2'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2'::jsonb" +== 025 +-- truncate_limit: 100 +-- ERROR, no closing bracket +SELECT '[1,[2]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,[2]'::jsonb" +== 026 +-- truncate_limit: 100 +-- ERROR, no closing bracket + +-- Objects. +SELECT '{}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb" +== 027 +-- truncate_limit: 100 +-- OK +SELECT '{"abc"}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\"}'::jsonb" +== 028 +-- truncate_limit: 100 +-- ERROR, no value +SELECT '{"abc":1}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\":1}'::jsonb" +== 029 +-- truncate_limit: 100 +-- OK +SELECT '{1:"abc"}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{1:\"abc\"}'::jsonb" +== 030 +-- truncate_limit: 100 +-- ERROR, keys must be strings +SELECT '{"abc",1}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\",1}'::jsonb" +== 031 +-- truncate_limit: 100 +-- ERROR, wrong separator +SELECT '{"abc"=1}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\"=1}'::jsonb" +== 032 +-- truncate_limit: 100 +-- ERROR, totally wrong separator +SELECT '{"abc"::1}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\"::1}'::jsonb" +== 033 +-- truncate_limit: 100 +-- ERROR, another wrong separator +SELECT '{"abc":1,"def":2,"ghi":[3,4],"hij":{"klm":5,"nop":[6]}}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\":1,\"def\":2,\"ghi\":[3,4],\"hij\":{\"klm\":5,\"nop\":[6]}}'::jsonb" +== 034 +-- truncate_limit: 100 +-- OK +SELECT '{"abc":1:2}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\":1:2}'::jsonb" +== 035 +-- truncate_limit: 100 +-- ERROR, colon in wrong spot +SELECT '{"abc":1,3}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"abc\":1,3}'::jsonb" +== 036 +-- truncate_limit: 100 +-- ERROR, no value + +-- Recursion. +SET max_stack_depth = '100kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_stack_depth TO \"100kB\"" +== 037 +-- truncate_limit: 100 +SELECT repeat('[', 10000)::jsonb +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT repeat('[', 10000)::jsonb" +== 038 +-- truncate_limit: 100 +SELECT repeat('{"a":', 10000)::jsonb +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT repeat('{\"a\":', 10000)::jsonb" +== 039 +-- truncate_limit: 100 +RESET max_stack_depth +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_stack_depth" +== 040 +-- truncate_limit: 100 +-- Miscellaneous stuff. +SELECT 'true'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true'::jsonb" +== 041 +-- truncate_limit: 100 +-- OK +SELECT 'false'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'false'::jsonb" +== 042 +-- truncate_limit: 100 +-- OK +SELECT 'null'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'null'::jsonb" +== 043 +-- truncate_limit: 100 +-- OK +SELECT ' true '::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' true '::jsonb" +== 044 +-- truncate_limit: 100 +-- OK, even with extra whitespace +SELECT 'true false'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true false'::jsonb" +== 045 +-- truncate_limit: 100 +-- ERROR, too many values +SELECT 'true, false'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true, false'::jsonb" +== 046 +-- truncate_limit: 100 +-- ERROR, too many values +SELECT 'truf'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'truf'::jsonb" +== 047 +-- truncate_limit: 100 +-- ERROR, not a keyword +SELECT 'trues'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'trues'::jsonb" +== 048 +-- truncate_limit: 100 +-- ERROR, not a keyword +SELECT ''::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::jsonb" +== 049 +-- truncate_limit: 100 +-- ERROR, no value +SELECT ' '::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' '::jsonb" +== 050 +-- truncate_limit: 100 +-- ERROR, no value + +-- Multi-line JSON input to check ERROR reporting +SELECT '{ + "one": 1, + "two":"two", + "three": + true}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\n\t\t\"one\": 1,\n\t\t\"two\":\"two\",\n\t\t\"three\":\n\t\ttrue}'::jsonb" +== 051 +-- truncate_limit: 100 +-- OK +SELECT '{ + "one": 1, + "two":,"two", -- ERROR extraneous comma before field "two" + "three": + true}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 052 +-- truncate_limit: 100 +SELECT '{ + "one": 1, + "two":"two", + "averyveryveryveryveryveryveryveryveryverylongfieldname":}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 053 +-- truncate_limit: 100 +-- ERROR missing value for last field + +-- test non-error-throwing input +select pg_input_is_valid('{"a":true}', 'jsonb') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{\"a\":true}', 'jsonb')" +== 054 +-- truncate_limit: 100 +select pg_input_is_valid('{"a":true', 'jsonb') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{\"a\":true', 'jsonb')" +== 055 +-- truncate_limit: 100 +select * from pg_input_error_info('{"a":true', 'jsonb') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{\"a\":true', 'jsonb')" +== 056 +-- truncate_limit: 100 +select * from pg_input_error_info('{"a":1e1000000}', 'jsonb') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{\"a\":1e1000000}', 'jsonb')" +== 057 +-- truncate_limit: 100 +-- make sure jsonb is passed through json generators without being escaped +SELECT array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']) +-- +FUNCTION: name="array_to_json" function="array_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_json(ARRAY['{\"a\":1}'::jsonb, '{\"b\":[2,3]}'::jsonb])" +== 058 +-- truncate_limit: 100 +-- anyarray column + +CREATE TEMP TABLE rows AS +SELECT x, 'txt' || x as y +FROM generate_series(1,3) AS x +-- +TABLE: name="rows" schema="" table="rows" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE rows AS SELECT x, 'txt' || x AS y FROM generate_series(1, 3) x" +== 059 +-- truncate_limit: 100 +analyze rows +-- +TABLE: name="rows" schema="" table="rows" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE rows" +== 060 +-- truncate_limit: 100 +select attname, to_jsonb(histogram_bounds) histogram_bounds +from pg_stats +where tablename = 'rows' and + schemaname = pg_my_temp_schema()::regnamespace::text +order by 1 +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +FUNCTION: name="pg_my_temp_schema" function="pg_my_temp_schema" schema="" ctx=Call +FILTER: schema="" table="" column="tablename" +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +TRUNCATED: "SELECT attname, to_jsonb(histogram_bounds) AS histogram_bounds FROM pg_stats WHERE ... ORDER BY 1" +== 061 +-- truncate_limit: 100 +-- to_jsonb, timestamps + +select to_jsonb(timestamp '2014-05-28 12:22:35.614298') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('2014-05-28 12:22:35.614298'::timestamp)" +== 062 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 063 +-- truncate_limit: 100 +SET LOCAL TIME ZONE 10.5 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO 10.5" +== 064 +-- truncate_limit: 100 +select to_jsonb(timestamptz '2014-05-28 12:22:35.614298-04') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('2014-05-28 12:22:35.614298-04'::timestamptz)" +== 065 +-- truncate_limit: 100 +SET LOCAL TIME ZONE -8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO -8" +== 066 +-- truncate_limit: 100 +select to_jsonb(timestamptz '2014-05-28 12:22:35.614298-04') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('2014-05-28 12:22:35.614298-04'::timestamptz)" +== 067 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 068 +-- truncate_limit: 100 +select to_jsonb(date '2014-05-28') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('2014-05-28'::date)" +== 069 +-- truncate_limit: 100 +select to_jsonb(date 'Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('Infinity'::date)" +== 070 +-- truncate_limit: 100 +select to_jsonb(date '-Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('-Infinity'::date)" +== 071 +-- truncate_limit: 100 +select to_jsonb(timestamp 'Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('Infinity'::timestamp)" +== 072 +-- truncate_limit: 100 +select to_jsonb(timestamp '-Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('-Infinity'::timestamp)" +== 073 +-- truncate_limit: 100 +select to_jsonb(timestamptz 'Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('Infinity'::timestamptz)" +== 074 +-- truncate_limit: 100 +select to_jsonb(timestamptz '-Infinity') +-- +FUNCTION: name="to_jsonb" function="to_jsonb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_jsonb('-Infinity'::timestamptz)" +== 075 +-- truncate_limit: 100 +--jsonb_agg + +SELECT jsonb_agg(q) + FROM ( SELECT $$a$$ || x AS b, y AS c, + ARRAY[ROW(x.*,ARRAY[1,2,3]), + ROW(y.*,ARRAY[4,5,6])] AS z + FROM generate_series(1,2) x, + generate_series(4,5) y) q +-- +FUNCTION: name="jsonb_agg" function="jsonb_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_agg(q) FROM (SELECT ... FROM generate_series(1, 2) x, generate_series(4, 5) y) q" +== 076 +-- truncate_limit: 100 +SELECT jsonb_agg(q ORDER BY x, y) + FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="jsonb_agg" function="jsonb_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_agg(q ORDER BY x, y) FROM rows q" +== 077 +-- truncate_limit: 100 +UPDATE rows SET x = NULL WHERE x = 1 +-- +TABLE: name="rows" schema="" table="rows" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rows SET x = NULL WHERE x = 1" +== 078 +-- truncate_limit: 100 +SELECT jsonb_agg(q ORDER BY x NULLS FIRST, y) + FROM rows q +-- +TABLE: name="rows" schema="" table="rows" ctx=Select +ALIAS: "q"="rows" +FUNCTION: name="jsonb_agg" function="jsonb_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_agg(q ORDER BY x NULLS FIRST, y) FROM rows q" +== 079 +-- truncate_limit: 100 +-- jsonb extraction functions +CREATE TEMP TABLE test_jsonb ( + json_type text, + test_json jsonb +) +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_jsonb (json_type text, test_json jsonb)" +== 080 +-- truncate_limit: 100 +INSERT INTO test_jsonb VALUES +('scalar','"a scalar"'), +('array','["zero", "one","two",null,"four","five", [1,2,3],{"f1":9}]'), +('object','{"field1":"val1","field2":"val2","field3":null, "field4": 4, "field5": [1,2,3], "field6": {"f1":9}}') +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb VALUES (...)" +== 081 +-- truncate_limit: 100 +SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'scalar'" +== 082 +-- truncate_limit: 100 +SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'array'" +== 083 +-- truncate_limit: 100 +SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'x' FROM test_jsonb WHERE json_type = 'object'" +== 084 +-- truncate_limit: 100 +SELECT test_json -> 'field2' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'field2' FROM test_jsonb WHERE json_type = 'object'" +== 085 +-- truncate_limit: 100 +SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'scalar'" +== 086 +-- truncate_limit: 100 +SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'array'" +== 087 +-- truncate_limit: 100 +SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field2' FROM test_jsonb WHERE json_type = 'object'" +== 088 +-- truncate_limit: 100 +SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'scalar'" +== 089 +-- truncate_limit: 100 +SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'array'" +== 090 +-- truncate_limit: 100 +SELECT test_json -> 9 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 9 FROM test_jsonb WHERE json_type = 'array'" +== 091 +-- truncate_limit: 100 +SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 2 FROM test_jsonb WHERE json_type = 'object'" +== 092 +-- truncate_limit: 100 +SELECT test_json ->> 6 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 6 FROM test_jsonb WHERE json_type = 'array'" +== 093 +-- truncate_limit: 100 +SELECT test_json ->> 7 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 7 FROM test_jsonb WHERE json_type = 'array'" +== 094 +-- truncate_limit: 100 +SELECT test_json ->> 'field4' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field4' FROM test_jsonb WHERE json_type = 'object'" +== 095 +-- truncate_limit: 100 +SELECT test_json ->> 'field5' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field5' FROM test_jsonb WHERE json_type = 'object'" +== 096 +-- truncate_limit: 100 +SELECT test_json ->> 'field6' FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field6' FROM test_jsonb WHERE json_type = 'object'" +== 097 +-- truncate_limit: 100 +SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'scalar'" +== 098 +-- truncate_limit: 100 +SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'array'" +== 099 +-- truncate_limit: 100 +SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 2 FROM test_jsonb WHERE json_type = 'object'" +== 100 +-- truncate_limit: 100 +SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'scalar' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FUNCTION: name="jsonb_object_keys" function="jsonb_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'scalar'" +== 101 +-- truncate_limit: 100 +SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FUNCTION: name="jsonb_object_keys" function="jsonb_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'array'" +== 102 +-- truncate_limit: 100 +SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FUNCTION: name="jsonb_object_keys" function="jsonb_object_keys" schema="" ctx=Call +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object_keys(test_json) FROM test_jsonb WHERE json_type = 'object'" +== 103 +-- truncate_limit: 100 +-- nulls +SELECT (test_json->'field3') IS NULL AS expect_false FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 'field3' IS NULL AS expect_false FROM test_jsonb WHERE json_type = 'object'" +== 104 +-- truncate_limit: 100 +SELECT (test_json->>'field3') IS NULL AS expect_true FROM test_jsonb WHERE json_type = 'object' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 'field3' IS NULL AS expect_true FROM test_jsonb WHERE json_type = 'object'" +== 105 +-- truncate_limit: 100 +SELECT (test_json->3) IS NULL AS expect_false FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json -> 3 IS NULL AS expect_false FROM test_jsonb WHERE json_type = 'array'" +== 106 +-- truncate_limit: 100 +SELECT (test_json->>3) IS NULL AS expect_true FROM test_jsonb WHERE json_type = 'array' +-- +TABLE: name="test_jsonb" schema="" table="test_jsonb" ctx=Select +FILTER: schema="" table="" column="json_type" +STMT: SelectStmt +TRUNCATED: "SELECT test_json ->> 3 IS NULL AS expect_true FROM test_jsonb WHERE json_type = 'array'" +== 107 +-- truncate_limit: 100 +-- corner cases +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> null::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb -> NULL::text" +== 108 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> null::int +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb -> NULL::int" +== 109 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb -> 1" +== 110 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb -> 'z'" +== 111 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb -> '' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb -> ''" +== 112 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb -> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb -> 1" +== 113 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb -> 3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb -> 3" +== 114 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb -> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb -> 'z'" +== 115 +-- truncate_limit: 100 +select '{"a": "c", "b": null}'::jsonb -> 'b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": \"c\", \"b\": null}'::jsonb -> 'b'" +== 116 +-- truncate_limit: 100 +select '"foo"'::jsonb -> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::jsonb -> 1" +== 117 +-- truncate_limit: 100 +select '"foo"'::jsonb -> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::jsonb -> 'z'" +== 118 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> null::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb ->> NULL::text" +== 119 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> null::int +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb ->> NULL::int" +== 120 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb ->> 1" +== 121 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb ->> 'z'" +== 122 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb ->> '' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb ->> ''" +== 123 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb ->> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb ->> 1" +== 124 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb ->> 3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb ->> 3" +== 125 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb ->> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb ->> 'z'" +== 126 +-- truncate_limit: 100 +select '{"a": "c", "b": null}'::jsonb ->> 'b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": \"c\", \"b\": null}'::jsonb ->> 'b'" +== 127 +-- truncate_limit: 100 +select '"foo"'::jsonb ->> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::jsonb ->> 1" +== 128 +-- truncate_limit: 100 +select '"foo"'::jsonb ->> 'z' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::jsonb ->> 'z'" +== 129 +-- truncate_limit: 100 +-- equality and inequality +SELECT '{"x":"y"}'::jsonb = '{"x":"y"}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"x\":\"y\"}'::jsonb = '{\"x\":\"y\"}'::jsonb" +== 130 +-- truncate_limit: 100 +SELECT '{"x":"y"}'::jsonb = '{"x":"z"}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"x\":\"y\"}'::jsonb = '{\"x\":\"z\"}'::jsonb" +== 131 +-- truncate_limit: 100 +SELECT '{"x":"y"}'::jsonb <> '{"x":"y"}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"x\":\"y\"}'::jsonb <> '{\"x\":\"y\"}'::jsonb" +== 132 +-- truncate_limit: 100 +SELECT '{"x":"y"}'::jsonb <> '{"x":"z"}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"x\":\"y\"}'::jsonb <> '{\"x\":\"z\"}'::jsonb" +== 133 +-- truncate_limit: 100 +-- containment +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b"}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contains('{\"a\":\"b\", \"b\":1, \"c\":null}', '{\"a\":\"b\"}')" +== 134 +-- truncate_limit: 100 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b", "c":null}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contains('{\"a\":\"b\", \"b\":1, \"c\":null}', '{\"a\":\"b\", \"c\":null}')" +== 135 +-- truncate_limit: 100 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b", "g":null}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contains('{\"a\":\"b\", \"b\":1, \"c\":null}', '{\"a\":\"b\", \"g\":null}')" +== 136 +-- truncate_limit: 100 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"g":null}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contains('{\"a\":\"b\", \"b\":1, \"c\":null}', '{\"g\":null}')" +== 137 +-- truncate_limit: 100 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"c"}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contains('{\"a\":\"b\", \"b\":1, \"c\":null}', '{\"a\":\"c\"}')" +== 138 +-- truncate_limit: 100 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b"}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contains('{\"a\":\"b\", \"b\":1, \"c\":null}', '{\"a\":\"b\"}')" +== 139 +-- truncate_limit: 100 +SELECT jsonb_contains('{"a":"b", "b":1, "c":null}', '{"a":"b", "c":"q"}') +-- +FUNCTION: name="jsonb_contains" function="jsonb_contains" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contains('{\"a\":\"b\", \"b\":1, \"c\":null}', '{\"a\":\"b\", \"c\":\"q\"}')" +== 140 +-- truncate_limit: 100 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"b\":1, \"c\":null}'::jsonb @> '{\"a\":\"b\"}'" +== 141 +-- truncate_limit: 100 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"b\":1, \"c\":null}'::jsonb @> '{\"a\":\"b\", \"c\":null}'" +== 142 +-- truncate_limit: 100 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "g":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"b\":1, \"c\":null}'::jsonb @> '{\"a\":\"b\", \"g\":null}'" +== 143 +-- truncate_limit: 100 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"g":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"b\":1, \"c\":null}'::jsonb @> '{\"g\":null}'" +== 144 +-- truncate_limit: 100 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"c"}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"b\":1, \"c\":null}'::jsonb @> '{\"a\":\"c\"}'" +== 145 +-- truncate_limit: 100 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b"}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"b\":1, \"c\":null}'::jsonb @> '{\"a\":\"b\"}'" +== 146 +-- truncate_limit: 100 +SELECT '{"a":"b", "b":1, "c":null}'::jsonb @> '{"a":"b", "c":"q"}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"b\":1, \"c\":null}'::jsonb @> '{\"a\":\"b\", \"c\":\"q\"}'" +== 147 +-- truncate_limit: 100 +SELECT '[1,2]'::jsonb @> '[1,2,2]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2]'::jsonb @> '[1,2,2]'::jsonb" +== 148 +-- truncate_limit: 100 +SELECT '[1,1,2]'::jsonb @> '[1,2,2]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,1,2]'::jsonb @> '[1,2,2]'::jsonb" +== 149 +-- truncate_limit: 100 +SELECT '[[1,2]]'::jsonb @> '[[1,2,2]]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[[1,2]]'::jsonb @> '[[1,2,2]]'::jsonb" +== 150 +-- truncate_limit: 100 +SELECT '[1,2,2]'::jsonb <@ '[1,2]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,2]'::jsonb <@ '[1,2]'::jsonb" +== 151 +-- truncate_limit: 100 +SELECT '[1,2,2]'::jsonb <@ '[1,1,2]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,2]'::jsonb <@ '[1,1,2]'::jsonb" +== 152 +-- truncate_limit: 100 +SELECT '[[1,2,2]]'::jsonb <@ '[[1,2]]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[[1,2,2]]'::jsonb <@ '[[1,2]]'::jsonb" +== 153 +-- truncate_limit: 100 +SELECT jsonb_contained('{"a":"b"}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contained('{\"a\":\"b\"}', '{\"a\":\"b\", \"b\":1, \"c\":null}')" +== 154 +-- truncate_limit: 100 +SELECT jsonb_contained('{"a":"b", "c":null}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contained('{\"a\":\"b\", \"c\":null}', '{\"a\":\"b\", \"b\":1, \"c\":null}')" +== 155 +-- truncate_limit: 100 +SELECT jsonb_contained('{"a":"b", "g":null}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contained('{\"a\":\"b\", \"g\":null}', '{\"a\":\"b\", \"b\":1, \"c\":null}')" +== 156 +-- truncate_limit: 100 +SELECT jsonb_contained('{"g":null}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contained('{\"g\":null}', '{\"a\":\"b\", \"b\":1, \"c\":null}')" +== 157 +-- truncate_limit: 100 +SELECT jsonb_contained('{"a":"c"}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contained('{\"a\":\"c\"}', '{\"a\":\"b\", \"b\":1, \"c\":null}')" +== 158 +-- truncate_limit: 100 +SELECT jsonb_contained('{"a":"b"}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contained('{\"a\":\"b\"}', '{\"a\":\"b\", \"b\":1, \"c\":null}')" +== 159 +-- truncate_limit: 100 +SELECT jsonb_contained('{"a":"b", "c":"q"}', '{"a":"b", "b":1, "c":null}') +-- +FUNCTION: name="jsonb_contained" function="jsonb_contained" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_contained('{\"a\":\"b\", \"c\":\"q\"}', '{\"a\":\"b\", \"b\":1, \"c\":null}')" +== 160 +-- truncate_limit: 100 +SELECT '{"a":"b"}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\"}'::jsonb <@ '{\"a\":\"b\", \"b\":1, \"c\":null}'" +== 161 +-- truncate_limit: 100 +SELECT '{"a":"b", "c":null}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"c\":null}'::jsonb <@ '{\"a\":\"b\", \"b\":1, \"c\":null}'" +== 162 +-- truncate_limit: 100 +SELECT '{"a":"b", "g":null}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"g\":null}'::jsonb <@ '{\"a\":\"b\", \"b\":1, \"c\":null}'" +== 163 +-- truncate_limit: 100 +SELECT '{"g":null}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"g\":null}'::jsonb <@ '{\"a\":\"b\", \"b\":1, \"c\":null}'" +== 164 +-- truncate_limit: 100 +SELECT '{"a":"c"}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"c\"}'::jsonb <@ '{\"a\":\"b\", \"b\":1, \"c\":null}'" +== 165 +-- truncate_limit: 100 +SELECT '{"a":"b"}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\"}'::jsonb <@ '{\"a\":\"b\", \"b\":1, \"c\":null}'" +== 166 +-- truncate_limit: 100 +SELECT '{"a":"b", "c":"q"}'::jsonb <@ '{"a":"b", "b":1, "c":null}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\", \"c\":\"q\"}'::jsonb <@ '{\"a\":\"b\", \"b\":1, \"c\":null}'" +== 167 +-- truncate_limit: 100 +-- Raw scalar may contain another raw scalar, array may contain a raw scalar +SELECT '[5]'::jsonb @> '[5]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[5]'::jsonb @> '[5]'" +== 168 +-- truncate_limit: 100 +SELECT '5'::jsonb @> '5' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '5'::jsonb @> '5'" +== 169 +-- truncate_limit: 100 +SELECT '[5]'::jsonb @> '5' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[5]'::jsonb @> '5'" +== 170 +-- truncate_limit: 100 +-- But a raw scalar cannot contain an array +SELECT '5'::jsonb @> '[5]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '5'::jsonb @> '[5]'" +== 171 +-- truncate_limit: 100 +-- In general, one thing should always contain itself. Test array containment: +SELECT '["9", ["7", "3"], 1]'::jsonb @> '["9", ["7", "3"], 1]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"9\", [\"7\", \"3\"], 1]'::jsonb @> '[\"9\", [\"7\", \"3\"], 1]'::jsonb" +== 172 +-- truncate_limit: 100 +SELECT '["9", ["7", "3"], ["1"]]'::jsonb @> '["9", ["7", "3"], ["1"]]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"9\", [\"7\", \"3\"], [\"1\"]]'::jsonb @> '[\"9\", [\"7\", \"3\"], [\"1\"]]'::jsonb" +== 173 +-- truncate_limit: 100 +-- array containment string matching confusion bug +SELECT '{ "name": "Bob", "tags": [ "enim", "qui"]}'::jsonb @> '{"tags":["qu"]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{ \"name\": \"Bob\", \"tags\": [ \"enim\", \"qui\"]}'::jsonb @> '{\"tags\":[\"qu\"]}'" +== 174 +-- truncate_limit: 100 +-- array length +SELECT jsonb_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]') +-- +FUNCTION: name="jsonb_array_length" function="jsonb_array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_array_length('[1,2,3,{\"f1\":1,\"f2\":[5,6]},4]')" +== 175 +-- truncate_limit: 100 +SELECT jsonb_array_length('[]') +-- +FUNCTION: name="jsonb_array_length" function="jsonb_array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_array_length('[]')" +== 176 +-- truncate_limit: 100 +SELECT jsonb_array_length('{"f1":1,"f2":[5,6]}') +-- +FUNCTION: name="jsonb_array_length" function="jsonb_array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_array_length('{\"f1\":1,\"f2\":[5,6]}')" +== 177 +-- truncate_limit: 100 +SELECT jsonb_array_length('4') +-- +FUNCTION: name="jsonb_array_length" function="jsonb_array_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_array_length('4')" +== 178 +-- truncate_limit: 100 +-- each +SELECT jsonb_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null}') +-- +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_each('{\"f1\":[1,2,3],\"f2\":{\"f3\":1},\"f4\":null}')" +== 179 +-- truncate_limit: 100 +SELECT jsonb_each('{"a":{"b":"c","c":"b","1":"first"},"b":[1,2],"c":"cc","1":"first","n":null}'::jsonb) AS q +-- +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 180 +-- truncate_limit: 100 +SELECT * FROM jsonb_each('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q +-- +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_each('{\"f1\":[1,2,3],\"f2\":{\"f3\":1},\"f4\":null,\"f5\":99,\"f6\":\"stringy\"}') q" +== 181 +-- truncate_limit: 100 +SELECT * FROM jsonb_each('{"a":{"b":"c","c":"b","1":"first"},"b":[1,2],"c":"cc","1":"first","n":null}'::jsonb) AS q +-- +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_each('{\"a\":{\"b\":\"c\",\"c\":\"b\",\"1\":\"first\"},\"b\":[1,2],\"c\":\"cc\",\"1\":\"first\",\"n\":n..." +== 182 +-- truncate_limit: 100 +SELECT jsonb_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":"null"}') +-- +FUNCTION: name="jsonb_each_text" function="jsonb_each_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_each_text('{\"f1\":[1,2,3],\"f2\":{\"f3\":1},\"f4\":null,\"f5\":\"null\"}')" +== 183 +-- truncate_limit: 100 +SELECT jsonb_each_text('{"a":{"b":"c","c":"b","1":"first"},"b":[1,2],"c":"cc","1":"first","n":null}'::jsonb) AS q +-- +FUNCTION: name="jsonb_each_text" function="jsonb_each_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 184 +-- truncate_limit: 100 +SELECT * FROM jsonb_each_text('{"f1":[1,2,3],"f2":{"f3":1},"f4":null,"f5":99,"f6":"stringy"}') q +-- +FUNCTION: name="jsonb_each_text" function="jsonb_each_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_each_text('{\"f1\":[1,2,3],\"f2\":{\"f3\":1},\"f4\":null,\"f5\":99,\"f6\":\"stringy\"}') q" +== 185 +-- truncate_limit: 100 +SELECT * FROM jsonb_each_text('{"a":{"b":"c","c":"b","1":"first"},"b":[1,2],"c":"cc","1":"first","n":null}'::jsonb) AS q +-- +FUNCTION: name="jsonb_each_text" function="jsonb_each_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_each_text('{\"a\":{\"b\":\"c\",\"c\":\"b\",\"1\":\"first\"},\"b\":[1,2],\"c\":\"cc\",\"1\":\"first\",..." +== 186 +-- truncate_limit: 100 +-- exists +SELECT jsonb_exists('{"a":null, "b":"qq"}', 'a') +-- +FUNCTION: name="jsonb_exists" function="jsonb_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists('{\"a\":null, \"b\":\"qq\"}', 'a')" +== 187 +-- truncate_limit: 100 +SELECT jsonb_exists('{"a":null, "b":"qq"}', 'b') +-- +FUNCTION: name="jsonb_exists" function="jsonb_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists('{\"a\":null, \"b\":\"qq\"}', 'b')" +== 188 +-- truncate_limit: 100 +SELECT jsonb_exists('{"a":null, "b":"qq"}', 'c') +-- +FUNCTION: name="jsonb_exists" function="jsonb_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists('{\"a\":null, \"b\":\"qq\"}', 'c')" +== 189 +-- truncate_limit: 100 +SELECT jsonb_exists('{"a":"null", "b":"qq"}', 'a') +-- +FUNCTION: name="jsonb_exists" function="jsonb_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists('{\"a\":\"null\", \"b\":\"qq\"}', 'a')" +== 190 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ? 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ? 'a'" +== 191 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ? 'b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ? 'b'" +== 192 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ? 'c' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ? 'c'" +== 193 +-- truncate_limit: 100 +SELECT jsonb '{"a":"null", "b":"qq"}' ? 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"null\", \"b\":\"qq\"}'::jsonb ? 'a'" +== 194 +-- truncate_limit: 100 +-- array exists - array elements should behave as keys +SELECT count(*) from testjsonb WHERE j->'array' ? 'bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE (j -> 'array') ? 'bar'" +== 195 +-- truncate_limit: 100 +-- type sensitive array exists - should return no rows (since "exists" only +-- matches strings that are either object keys or array elements) +SELECT count(*) from testjsonb WHERE j->'array' ? '5'::text +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE (j -> 'array') ? '5'::text" +== 196 +-- truncate_limit: 100 +-- However, a raw scalar is *contained* within the array +SELECT count(*) from testjsonb WHERE j->'array' @> '5'::jsonb +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE (j -> 'array') @> '5'::jsonb" +== 197 +-- truncate_limit: 100 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['a','b']) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_any('{\"a\":null, \"b\":\"qq\"}', ARRAY['a', 'b'])" +== 198 +-- truncate_limit: 100 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['b','a']) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_any('{\"a\":null, \"b\":\"qq\"}', ARRAY['b', 'a'])" +== 199 +-- truncate_limit: 100 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['c','a']) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_any('{\"a\":null, \"b\":\"qq\"}', ARRAY['c', 'a'])" +== 200 +-- truncate_limit: 100 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', ARRAY['c','d']) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_any('{\"a\":null, \"b\":\"qq\"}', ARRAY['c', 'd'])" +== 201 +-- truncate_limit: 100 +SELECT jsonb_exists_any('{"a":null, "b":"qq"}', '{}'::text[]) +-- +FUNCTION: name="jsonb_exists_any" function="jsonb_exists_any" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_any('{\"a\":null, \"b\":\"qq\"}', '{}'::text[])" +== 202 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?| ARRAY['a','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?| ARRAY['a', 'b']" +== 203 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?| ARRAY['b','a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?| ARRAY['b', 'a']" +== 204 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?| ARRAY['c','a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?| ARRAY['c', 'a']" +== 205 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?| ARRAY['c','d'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?| ARRAY['c', 'd']" +== 206 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?| '{}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?| '{}'::text[]" +== 207 +-- truncate_limit: 100 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', ARRAY['a','b']) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_all('{\"a\":null, \"b\":\"qq\"}', ARRAY['a', 'b'])" +== 208 +-- truncate_limit: 100 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', ARRAY['b','a']) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_all('{\"a\":null, \"b\":\"qq\"}', ARRAY['b', 'a'])" +== 209 +-- truncate_limit: 100 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', ARRAY['c','a']) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_all('{\"a\":null, \"b\":\"qq\"}', ARRAY['c', 'a'])" +== 210 +-- truncate_limit: 100 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', ARRAY['c','d']) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_all('{\"a\":null, \"b\":\"qq\"}', ARRAY['c', 'd'])" +== 211 +-- truncate_limit: 100 +SELECT jsonb_exists_all('{"a":null, "b":"qq"}', '{}'::text[]) +-- +FUNCTION: name="jsonb_exists_all" function="jsonb_exists_all" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_exists_all('{\"a\":null, \"b\":\"qq\"}', '{}'::text[])" +== 212 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['a','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?& ARRAY['a', 'b']" +== 213 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['b','a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?& ARRAY['b', 'a']" +== 214 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['c','a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?& ARRAY['c', 'a']" +== 215 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['c','d'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?& ARRAY['c', 'd']" +== 216 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?& ARRAY['a','a', 'b', 'b', 'b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?& ARRAY['a', 'a', 'b', 'b', 'b']" +== 217 +-- truncate_limit: 100 +SELECT jsonb '{"a":null, "b":"qq"}' ?& '{}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null, \"b\":\"qq\"}'::jsonb ?& '{}'::text[]" +== 218 +-- truncate_limit: 100 +-- typeof +SELECT jsonb_typeof('{}') AS object +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('{}') AS object" +== 219 +-- truncate_limit: 100 +SELECT jsonb_typeof('{"c":3,"p":"o"}') AS object +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('{\"c\":3,\"p\":\"o\"}') AS object" +== 220 +-- truncate_limit: 100 +SELECT jsonb_typeof('[]') AS array +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('[]') AS \"array\"" +== 221 +-- truncate_limit: 100 +SELECT jsonb_typeof('["a", 1]') AS array +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('[\"a\", 1]') AS \"array\"" +== 222 +-- truncate_limit: 100 +SELECT jsonb_typeof('null') AS "null" +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('null') AS \"null\"" +== 223 +-- truncate_limit: 100 +SELECT jsonb_typeof('1') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('1') AS number" +== 224 +-- truncate_limit: 100 +SELECT jsonb_typeof('-1') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('-1') AS number" +== 225 +-- truncate_limit: 100 +SELECT jsonb_typeof('1.0') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('1.0') AS number" +== 226 +-- truncate_limit: 100 +SELECT jsonb_typeof('1e2') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('1e2') AS number" +== 227 +-- truncate_limit: 100 +SELECT jsonb_typeof('-1.0') AS number +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('-1.0') AS number" +== 228 +-- truncate_limit: 100 +SELECT jsonb_typeof('true') AS boolean +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('true') AS \"boolean\"" +== 229 +-- truncate_limit: 100 +SELECT jsonb_typeof('false') AS boolean +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('false') AS \"boolean\"" +== 230 +-- truncate_limit: 100 +SELECT jsonb_typeof('"hello"') AS string +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('\"hello\"') AS string" +== 231 +-- truncate_limit: 100 +SELECT jsonb_typeof('"true"') AS string +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('\"true\"') AS string" +== 232 +-- truncate_limit: 100 +SELECT jsonb_typeof('"1.0"') AS string +-- +FUNCTION: name="jsonb_typeof" function="jsonb_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_typeof('\"1.0\"') AS string" +== 233 +-- truncate_limit: 100 +-- jsonb_build_array, jsonb_build_object, jsonb_object_agg + +SELECT jsonb_build_array('a',1,'b',1.2,'c',true,'d',null,'e',json '{"x": 3, "y": [1,2,3]}') +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 234 +-- truncate_limit: 100 +SELECT jsonb_build_array('a', NULL) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array('a', NULL)" +== 235 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_array(VARIADIC NULL::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array(VARIADIC NULL::text[])" +== 236 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_array(VARIADIC '{}'::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array(VARIADIC '{}'::text[])" +== 237 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_array(VARIADIC '{a,b,c}'::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array(VARIADIC '{a,b,c}'::text[])" +== 238 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_array(VARIADIC ARRAY['a', NULL]::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array(VARIADIC ARRAY['a', NULL]::text[])" +== 239 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_array(VARIADIC '{1,2,3,4}'::text[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array(VARIADIC '{1,2,3,4}'::text[])" +== 240 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_array(VARIADIC '{1,2,3,4}'::int[]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array(VARIADIC '{1,2,3,4}'::int[])" +== 241 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_array(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][]) +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][])" +== 242 +-- truncate_limit: 100 +-- ok + +SELECT jsonb_build_object('a',1,'b',1.2,'c',true,'d',null,'e',json '{"x": 3, "y": [1,2,3]}') +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 243 +-- truncate_limit: 100 +SELECT jsonb_build_object( + 'a', jsonb_build_object('b',false,'c',99), + 'd', jsonb_build_object('e',array[9,8,7]::int[], + 'f', (select row_to_json(r) from ( select relkind, oid::regclass as name from pg_class where relname = 'pg_class') r))) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 244 +-- truncate_limit: 100 +SELECT jsonb_build_object('{a,b,c}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object('{a,b,c}'::text[])" +== 245 +-- truncate_limit: 100 +-- error +SELECT jsonb_build_object('{a,b,c}'::text[], '{d,e,f}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object('{a,b,c}'::text[], '{d,e,f}'::text[])" +== 246 +-- truncate_limit: 100 +-- error, key cannot be array +SELECT jsonb_build_object('a', 'b', 'c') +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object('a', 'b', 'c')" +== 247 +-- truncate_limit: 100 +-- error +SELECT jsonb_build_object(NULL, 'a') +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(NULL, 'a')" +== 248 +-- truncate_limit: 100 +-- error, key cannot be NULL +SELECT jsonb_build_object('a', NULL) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object('a', NULL)" +== 249 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_object(VARIADIC NULL::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(VARIADIC NULL::text[])" +== 250 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_object(VARIADIC '{}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(VARIADIC '{}'::text[])" +== 251 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_object(VARIADIC '{a,b,c}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(VARIADIC '{a,b,c}'::text[])" +== 252 +-- truncate_limit: 100 +-- error +SELECT jsonb_build_object(VARIADIC ARRAY['a', NULL]::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(VARIADIC ARRAY['a', NULL]::text[])" +== 253 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_object(VARIADIC ARRAY[NULL, 'a']::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(VARIADIC ARRAY[NULL, 'a']::text[])" +== 254 +-- truncate_limit: 100 +-- error, key cannot be NULL +SELECT jsonb_build_object(VARIADIC '{1,2,3,4}'::text[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(VARIADIC '{1,2,3,4}'::text[])" +== 255 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_object(VARIADIC '{1,2,3,4}'::int[]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(VARIADIC '{1,2,3,4}'::int[])" +== 256 +-- truncate_limit: 100 +-- ok +SELECT jsonb_build_object(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][]) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(VARIADIC '{{1,4},{2,5},{3,6}}'::int[][])" +== 257 +-- truncate_limit: 100 +-- ok + +-- empty objects/arrays +SELECT jsonb_build_array() +-- +FUNCTION: name="jsonb_build_array" function="jsonb_build_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_array()" +== 258 +-- truncate_limit: 100 +SELECT jsonb_build_object() +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object()" +== 259 +-- truncate_limit: 100 +-- make sure keys are quoted +SELECT jsonb_build_object(1,2) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(1, 2)" +== 260 +-- truncate_limit: 100 +-- keys must be scalar and not null +SELECT jsonb_build_object(null,2) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(NULL, 2)" +== 261 +-- truncate_limit: 100 +SELECT jsonb_build_object(r,2) FROM (SELECT 1 AS a, 2 AS b) r +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object(r, 2) FROM (SELECT 1 AS a, 2 AS b) r" +== 262 +-- truncate_limit: 100 +SELECT jsonb_build_object(json '{"a":1,"b":2}', 3) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object('{\"a\":1,\"b\":2}'::pg_catalog.json, 3)" +== 263 +-- truncate_limit: 100 +SELECT jsonb_build_object('{1,2,3}'::int[], 3) +-- +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_build_object('{1,2,3}'::int[], 3)" +== 264 +-- truncate_limit: 100 +-- handling of NULL values +SELECT jsonb_object_agg(1, NULL::jsonb) +-- +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object_agg(1, NULL::jsonb)" +== 265 +-- truncate_limit: 100 +SELECT jsonb_object_agg(NULL, '{"a":1}') +-- +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object_agg(NULL, '{\"a\":1}')" +== 266 +-- truncate_limit: 100 +CREATE TEMP TABLE foo (serial_num int, name text, type text) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (serial_num int, name text, type text)" +== 267 +-- truncate_limit: 100 +INSERT INTO foo VALUES (847001,'t15','GE1043') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (847001, 't15', 'GE1043')" +== 268 +-- truncate_limit: 100 +INSERT INTO foo VALUES (847002,'t16','GE1043') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (847002, 't16', 'GE1043')" +== 269 +-- truncate_limit: 100 +INSERT INTO foo VALUES (847003,'sub-alpha','GESS90') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (847003, 'sub-alpha', 'GESS90')" +== 270 +-- truncate_limit: 100 +SELECT jsonb_build_object('turbines',jsonb_object_agg(serial_num,jsonb_build_object('name',name,'type',type))) +FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM foo" +== 271 +-- truncate_limit: 100 +SELECT jsonb_object_agg(name, type) FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object_agg(name, type) FROM foo" +== 272 +-- truncate_limit: 100 +INSERT INTO foo VALUES (999999, NULL, 'bar') +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (999999, NULL, 'bar')" +== 273 +-- truncate_limit: 100 +SELECT jsonb_object_agg(name, type) FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object_agg(name, type) FROM foo" +== 274 +-- truncate_limit: 100 +-- edge case for parser +SELECT jsonb_object_agg(DISTINCT 'a', 'abc') +-- +FUNCTION: name="jsonb_object_agg" function="jsonb_object_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object_agg(DISTINCT 'a', 'abc')" +== 275 +-- truncate_limit: 100 +-- jsonb_object + +-- empty object, one dimension +SELECT jsonb_object('{}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{}')" +== 276 +-- truncate_limit: 100 +-- empty object, two dimensions +SELECT jsonb_object('{}', '{}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{}', '{}')" +== 277 +-- truncate_limit: 100 +-- one dimension +SELECT jsonb_object('{a,1,b,2,3,NULL,"d e f","a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{a,1,b,2,3,NULL,\"d e f\",\"a b c\"}')" +== 278 +-- truncate_limit: 100 +-- same but with two dimensions +SELECT jsonb_object('{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{{a,1},{b,2},{3,NULL},{\"d e f\",\"a b c\"}}')" +== 279 +-- truncate_limit: 100 +-- odd number error +SELECT jsonb_object('{a,b,c}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{a,b,c}')" +== 280 +-- truncate_limit: 100 +-- one column error +SELECT jsonb_object('{{a},{b}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{{a},{b}}')" +== 281 +-- truncate_limit: 100 +-- too many columns error +SELECT jsonb_object('{{a,b,c},{b,c,d}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{{a,b,c},{b,c,d}}')" +== 282 +-- truncate_limit: 100 +-- too many dimensions error +SELECT jsonb_object('{{{a,b},{c,d}},{{b,c},{d,e}}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{{{a,b},{c,d}},{{b,c},{d,e}}}')" +== 283 +-- truncate_limit: 100 +--two argument form of jsonb_object + +select jsonb_object('{a,b,c,"d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{a,b,c,\"d e f\"}', '{1,2,3,\"a b c\"}')" +== 284 +-- truncate_limit: 100 +-- too many dimensions +SELECT jsonb_object('{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}', '{{a,1},{b,2},{3,NULL},{"d e f","a b c"}}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 285 +-- truncate_limit: 100 +-- mismatched dimensions + +select jsonb_object('{a,b,c,"d e f",g}','{1,2,3,"a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{a,b,c,\"d e f\",g}', '{1,2,3,\"a b c\"}')" +== 286 +-- truncate_limit: 100 +select jsonb_object('{a,b,c,"d e f"}','{1,2,3,"a b c",g}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{a,b,c,\"d e f\"}', '{1,2,3,\"a b c\",g}')" +== 287 +-- truncate_limit: 100 +-- null key error + +select jsonb_object('{a,b,NULL,"d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{a,b,NULL,\"d e f\"}', '{1,2,3,\"a b c\"}')" +== 288 +-- truncate_limit: 100 +-- empty key is allowed + +select jsonb_object('{a,b,"","d e f"}','{1,2,3,"a b c"}') +-- +FUNCTION: name="jsonb_object" function="jsonb_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_object('{a,b,\"\",\"d e f\"}', '{1,2,3,\"a b c\"}')" +== 289 +-- truncate_limit: 100 +-- extract_path, extract_path_as_text +SELECT jsonb_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6') +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path('{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f4', 'f6')" +== 290 +-- truncate_limit: 100 +SELECT jsonb_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2') +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path('{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2')" +== 291 +-- truncate_limit: 100 +SELECT jsonb_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text) +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path('{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2', 0::text)" +== 292 +-- truncate_limit: 100 +SELECT jsonb_extract_path('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text) +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path('{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2', 1::text)" +== 293 +-- truncate_limit: 100 +SELECT jsonb_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f4','f6') +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path_text('{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f4', 'f6')" +== 294 +-- truncate_limit: 100 +SELECT jsonb_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}','f2') +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path_text('{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2')" +== 295 +-- truncate_limit: 100 +SELECT jsonb_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',0::text) +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path_text('{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2', 0::text)" +== 296 +-- truncate_limit: 100 +SELECT jsonb_extract_path_text('{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}','f2',1::text) +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path_text('{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}', 'f2', 1::text)" +== 297 +-- truncate_limit: 100 +-- extract_path nulls +SELECT jsonb_extract_path('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') IS NULL AS expect_false +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 298 +-- truncate_limit: 100 +SELECT jsonb_extract_path_text('{"f2":{"f3":1},"f4":{"f5":null,"f6":"stringy"}}','f4','f5') IS NULL AS expect_true +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 299 +-- truncate_limit: 100 +SELECT jsonb_extract_path('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') IS NULL AS expect_false +-- +FUNCTION: name="jsonb_extract_path" function="jsonb_extract_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_extract_path('{\"f2\":{\"f3\":1},\"f4\":[0,1,2,null]}', 'f4', '3') IS NULL AS expect_false" +== 300 +-- truncate_limit: 100 +SELECT jsonb_extract_path_text('{"f2":{"f3":1},"f4":[0,1,2,null]}','f4','3') IS NULL AS expect_true +-- +FUNCTION: name="jsonb_extract_path_text" function="jsonb_extract_path_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 301 +-- truncate_limit: 100 +-- extract_path operators +SELECT '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>array['f4','f6'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::jsonb #> ARRAY['f4', 'f6']" +== 302 +-- truncate_limit: 100 +SELECT '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>array['f2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::jsonb #> ARRAY['f2']" +== 303 +-- truncate_limit: 100 +SELECT '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>array['f2','0'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::jsonb #> ARRAY['f2', '0']" +== 304 +-- truncate_limit: 100 +SELECT '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>array['f2','1'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::jsonb #> ARRAY['f2', '1']" +== 305 +-- truncate_limit: 100 +SELECT '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>>array['f4','f6'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::jsonb #>> ARRAY['f4', 'f6']" +== 306 +-- truncate_limit: 100 +SELECT '{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>>array['f2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":{\"f3\":1},\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::jsonb #>> ARRAY['f2']" +== 307 +-- truncate_limit: 100 +SELECT '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>>array['f2','0'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::jsonb #>> ARRAY['f2', '0']" +== 308 +-- truncate_limit: 100 +SELECT '{"f2":["f3",1],"f4":{"f5":99,"f6":"stringy"}}'::jsonb#>>array['f2','1'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"f2\":[\"f3\",1],\"f4\":{\"f5\":99,\"f6\":\"stringy\"}}'::jsonb #>> ARRAY['f2', '1']" +== 309 +-- truncate_limit: 100 +-- corner cases for same +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #> '{}'" +== 310 +-- truncate_limit: 100 +select '[1,2,3]'::jsonb #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::jsonb #> '{}'" +== 311 +-- truncate_limit: 100 +select '"foo"'::jsonb #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::jsonb #> '{}'" +== 312 +-- truncate_limit: 100 +select '42'::jsonb #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::jsonb #> '{}'" +== 313 +-- truncate_limit: 100 +select 'null'::jsonb #> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'null'::jsonb #> '{}'" +== 314 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #> ARRAY['a']" +== 315 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a', null] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #> ARRAY['a', NULL]" +== 316 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a', ''] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #> ARRAY['a', '']" +== 317 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #> ARRAY['a', 'b']" +== 318 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a','b','c'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #> ARRAY['a', 'b', 'c']" +== 319 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a','b','c','d'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #> ARRAY['a', 'b', 'c', 'd']" +== 320 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #> array['a','z','c'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #> ARRAY['a', 'z', 'c']" +== 321 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb #> array['a','1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb #> ARRAY['a', '1', 'b']" +== 322 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb #> array['a','z','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb #> ARRAY['a', 'z', 'b']" +== 323 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb #> array['1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb #> ARRAY['1', 'b']" +== 324 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb #> array['z','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb #> ARRAY['z', 'b']" +== 325 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": null}]'::jsonb #> array['1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": null}]'::jsonb #> ARRAY['1', 'b']" +== 326 +-- truncate_limit: 100 +select '"foo"'::jsonb #> array['z'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::jsonb #> ARRAY['z']" +== 327 +-- truncate_limit: 100 +select '42'::jsonb #> array['f2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::jsonb #> ARRAY['f2']" +== 328 +-- truncate_limit: 100 +select '42'::jsonb #> array['0'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::jsonb #> ARRAY['0']" +== 329 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #>> '{}'" +== 330 +-- truncate_limit: 100 +select '[1,2,3]'::jsonb #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::jsonb #>> '{}'" +== 331 +-- truncate_limit: 100 +select '"foo"'::jsonb #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::jsonb #>> '{}'" +== 332 +-- truncate_limit: 100 +select '42'::jsonb #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::jsonb #>> '{}'" +== 333 +-- truncate_limit: 100 +select 'null'::jsonb #>> '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'null'::jsonb #>> '{}'" +== 334 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #>> ARRAY['a']" +== 335 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a', null] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #>> ARRAY['a', NULL]" +== 336 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a', ''] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #>> ARRAY['a', '']" +== 337 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #>> ARRAY['a', 'b']" +== 338 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a','b','c'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #>> ARRAY['a', 'b', 'c']" +== 339 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a','b','c','d'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #>> ARRAY['a', 'b', 'c', 'd']" +== 340 +-- truncate_limit: 100 +select '{"a": {"b":{"c": "foo"}}}'::jsonb #>> array['a','z','c'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\":{\"c\": \"foo\"}}}'::jsonb #>> ARRAY['a', 'z', 'c']" +== 341 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb #>> array['a','1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb #>> ARRAY['a', '1', 'b']" +== 342 +-- truncate_limit: 100 +select '{"a": [{"b": "c"}, {"b": "cc"}]}'::jsonb #>> array['a','z','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [{\"b\": \"c\"}, {\"b\": \"cc\"}]}'::jsonb #>> ARRAY['a', 'z', 'b']" +== 343 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb #>> array['1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb #>> ARRAY['1', 'b']" +== 344 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": "cc"}]'::jsonb #>> array['z','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": \"cc\"}]'::jsonb #>> ARRAY['z', 'b']" +== 345 +-- truncate_limit: 100 +select '[{"b": "c"}, {"b": null}]'::jsonb #>> array['1','b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"b\": \"c\"}, {\"b\": null}]'::jsonb #>> ARRAY['1', 'b']" +== 346 +-- truncate_limit: 100 +select '"foo"'::jsonb #>> array['z'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"foo\"'::jsonb #>> ARRAY['z']" +== 347 +-- truncate_limit: 100 +select '42'::jsonb #>> array['f2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::jsonb #>> ARRAY['f2']" +== 348 +-- truncate_limit: 100 +select '42'::jsonb #>> array['0'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::jsonb #>> ARRAY['0']" +== 349 +-- truncate_limit: 100 +-- array_elements +SELECT jsonb_array_elements('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false]') +-- +FUNCTION: name="jsonb_array_elements" function="jsonb_array_elements" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_array_elements('[1,true,[1,[2,3]],null,{\"f1\":1,\"f2\":[7,8,9]},false]')" +== 350 +-- truncate_limit: 100 +SELECT * FROM jsonb_array_elements('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false]') q +-- +FUNCTION: name="jsonb_array_elements" function="jsonb_array_elements" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_array_elements('[1,true,[1,[2,3]],null,{\"f1\":1,\"f2\":[7,8,9]},false]') q" +== 351 +-- truncate_limit: 100 +SELECT jsonb_array_elements_text('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') +-- +FUNCTION: name="jsonb_array_elements_text" function="jsonb_array_elements_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_array_elements_text('[1,true,[1,[2,3]],null,{\"f1\":1,\"f2\":[7,8,9]},false,\"stringy\"]')" +== 352 +-- truncate_limit: 100 +SELECT * FROM jsonb_array_elements_text('[1,true,[1,[2,3]],null,{"f1":1,"f2":[7,8,9]},false,"stringy"]') q +-- +FUNCTION: name="jsonb_array_elements_text" function="jsonb_array_elements_text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_array_elements_text('[1,true,[1,[2,3]],null,{\"f1\":1,\"f2\":[7,8,9]},false,\"stri..." +== 353 +-- truncate_limit: 100 +-- populate_record +CREATE TYPE jbpop AS (a text, b int, c timestamp) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jbpop AS (a text, b int, c timestamp)" +== 354 +-- truncate_limit: 100 +CREATE DOMAIN jsb_int_not_null AS int NOT NULL +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN jsb_int_not_null AS int NOT NULL" +== 355 +-- truncate_limit: 100 +CREATE DOMAIN jsb_int_array_1d AS int[] CHECK(array_length(VALUE, 1) = 3) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN jsb_int_array_1d AS int[] CHECK (array_length(value, 1) = 3)" +== 356 +-- truncate_limit: 100 +CREATE DOMAIN jsb_int_array_2d AS int[][] CHECK(array_length(VALUE, 2) = 3) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN jsb_int_array_2d AS int[][] CHECK (array_length(value, 2) = 3)" +== 357 +-- truncate_limit: 100 +create type jb_unordered_pair as (x int, y int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jb_unordered_pair AS (x int, y int)" +== 358 +-- truncate_limit: 100 +create domain jb_ordered_pair as jb_unordered_pair check((value).x <= (value).y) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN jb_ordered_pair AS jb_unordered_pair CHECK ((value).x <= (value).y)" +== 359 +-- truncate_limit: 100 +CREATE TYPE jsbrec AS ( + i int, + ia _int4, + ia1 int[], + ia2 int[][], + ia3 int[][][], + ia1d jsb_int_array_1d, + ia2d jsb_int_array_2d, + t text, + ta text[], + c char(10), + ca char(10)[], + ts timestamp, + js json, + jsb jsonb, + jsa json[], + rec jbpop, + reca jbpop[] +) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsbrec AS (i int, ia _int4, ia1 int[], ia2 int[][], ia3 int[][][], ia1d jsb_int_array..." +== 360 +-- truncate_limit: 100 +CREATE TYPE jsbrec_i_not_null AS ( + i jsb_int_not_null +) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsbrec_i_not_null AS (i jsb_int_not_null)" +== 361 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_record(NULL::jbpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jbpop, '{\"a\":\"blurfl\",\"x\":43.2}') q" +== 362 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jbpop, '{\"a\":\"blurfl\",\"x\"..." +== 363 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_record(NULL::jbpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jbpop, '{\"a\":\"blurfl\",\"x\":43.2}') q" +== 364 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop,'{"a":"blurfl","x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jbpop, '{\"a\":\"blurfl\",\"x\"..." +== 365 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_record(NULL::jbpop,'{"a":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jbpop, '{\"a\":[100,200,false],\"x\":43.2}') q" +== 366 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop,'{"a":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jbpop, '{\"a\":[100,200,fal..." +== 367 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop,'{"c":[100,200,false],"x":43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jbpop, '{\"c\":[100,200,fal..." +== 368 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_record(row('x',3,'2012-12-31 15:30:56')::jbpop, '{}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(ROW('x', 3, '2012-12-31 15:30:56')::jbpop, '{}') q" +== 369 +-- truncate_limit: 100 +SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{"x": 43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{\"x\": 43.2}') q" +== 370 +-- truncate_limit: 100 +SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{"i": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{\"i\": null}') q" +== 371 +-- truncate_limit: 100 +SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{"i": 12345}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i FROM jsonb_populate_record(NULL::jsbrec_i_not_null, '{\"i\": 12345}') q" +== 372 +-- truncate_limit: 100 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{\"ia\": null}') q" +== 373 +-- truncate_limit: 100 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{\"ia\": 123}') q" +== 374 +-- truncate_limit: 100 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{\"ia\": [1, \"2\", null, 4]}') q" +== 375 +-- truncate_limit: 100 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": [[1, 2], [3, 4]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{\"ia\": [[1, 2], [3, 4]]}') q" +== 376 +-- truncate_limit: 100 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": [[1], 2]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{\"ia\": [[1], 2]}') q" +== 377 +-- truncate_limit: 100 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": [[1], [2, 3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{\"ia\": [[1], [2, 3]]}') q" +== 378 +-- truncate_limit: 100 +SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{"ia": "{1,2,3}"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia FROM jsonb_populate_record(NULL::jsbrec, '{\"ia\": \"{1,2,3}\"}') q" +== 379 +-- truncate_limit: 100 +SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{"ia1": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia1\": null}') q" +== 380 +-- truncate_limit: 100 +SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{"ia1": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia1\": 123}') q" +== 381 +-- truncate_limit: 100 +SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{"ia1": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia1\": [1, \"2\", null, 4]}') q" +== 382 +-- truncate_limit: 100 +SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{"ia1": [[1, 2, 3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia1\": [[1, 2, 3]]}') q" +== 383 +-- truncate_limit: 100 +SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{"ia1d": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{\"ia1d\": null}') q" +== 384 +-- truncate_limit: 100 +SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{"ia1d": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{\"ia1d\": 123}') q" +== 385 +-- truncate_limit: 100 +SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{"ia1d": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{\"ia1d\": [1, \"2\", null, 4]}') q" +== 386 +-- truncate_limit: 100 +SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{"ia1d": [1, "2", null]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia1d FROM jsonb_populate_record(NULL::jsbrec, '{\"ia1d\": [1, \"2\", null]}') q" +== 387 +-- truncate_limit: 100 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia2\": [1, \"2\", null, 4]}') q" +== 388 +-- truncate_limit: 100 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [[1, 2], [null, 4]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia2\": [[1, 2], [null, 4]]}') q" +== 389 +-- truncate_limit: 100 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [[], []]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia2\": [[], []]}') q" +== 390 +-- truncate_limit: 100 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [[1, 2], [3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia2\": [[1, 2], [3]]}') q" +== 391 +-- truncate_limit: 100 +SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{"ia2": [[1, 2], 3, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia2\": [[1, 2], 3, 4]}') q" +== 392 +-- truncate_limit: 100 +SELECT ia2d FROM jsonb_populate_record(NULL::jsbrec, '{"ia2d": [[1, "2"], [null, 4]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2d FROM jsonb_populate_record(NULL::jsbrec, '{\"ia2d\": [[1, \"2\"], [null, 4]]}') q" +== 393 +-- truncate_limit: 100 +SELECT ia2d FROM jsonb_populate_record(NULL::jsbrec, '{"ia2d": [[1, "2", 3], [null, 5, 6]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia2d FROM jsonb_populate_record(NULL::jsbrec, '{\"ia2d\": [[1, \"2\", 3], [null, 5, 6]]}') q" +== 394 +-- truncate_limit: 100 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia3\": [1, \"2\", null, 4]}') q" +== 395 +-- truncate_limit: 100 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [[1, 2], [null, 4]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia3\": [[1, 2], [null, 4]]}') q" +== 396 +-- truncate_limit: 100 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [ [[], []], [[], []], [[], []] ]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia3\": [ [[], []], [[], []], [[], []] ]}') q" +== 397 +-- truncate_limit: 100 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [ [[1, 2]], [[3, 4]] ]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia3\": [ [[1, 2]], [[3, 4]] ]}') q" +== 398 +-- truncate_limit: 100 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia3\": [ [[1, 2], [3, 4]], [[5, 6], [7, 8]]..." +== 399 +-- truncate_limit: 100 +SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{"ia3": [ [[1, 2], [3, 4]], [[5, 6], [7, 8], [9, 10]] ]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ia3 FROM jsonb_populate_record(NULL::jsbrec, '{\"ia3\": [ [[1, 2], [3, 4]], [[5, 6], [7, 8],..." +== 400 +-- truncate_limit: 100 +SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{"ta": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{\"ta\": null}') q" +== 401 +-- truncate_limit: 100 +SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{"ta": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{\"ta\": 123}') q" +== 402 +-- truncate_limit: 100 +SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{"ta": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{\"ta\": [1, \"2\", null, 4]}') q" +== 403 +-- truncate_limit: 100 +SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{"ta": [[1, 2, 3], {"k": "v"}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ta FROM jsonb_populate_record(NULL::jsbrec, '{\"ta\": [[1, 2, 3], {\"k\": \"v\"}]}') q" +== 404 +-- truncate_limit: 100 +SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{"c": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{\"c\": null}') q" +== 405 +-- truncate_limit: 100 +SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{"c": "aaa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{\"c\": \"aaa\"}') q" +== 406 +-- truncate_limit: 100 +SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{"c": "aaaaaaaaaa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{\"c\": \"aaaaaaaaaa\"}') q" +== 407 +-- truncate_limit: 100 +SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{"c": "aaaaaaaaaaaaa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c FROM jsonb_populate_record(NULL::jsbrec, '{\"c\": \"aaaaaaaaaaaaa\"}') q" +== 408 +-- truncate_limit: 100 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{\"ca\": null}') q" +== 409 +-- truncate_limit: 100 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{\"ca\": 123}') q" +== 410 +-- truncate_limit: 100 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{\"ca\": [1, \"2\", null, 4]}') q" +== 411 +-- truncate_limit: 100 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": ["aaaaaaaaaaaaaaaa"]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{\"ca\": [\"aaaaaaaaaaaaaaaa\"]}') q" +== 412 +-- truncate_limit: 100 +SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{"ca": [[1, 2, 3], {"k": "v"}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ca FROM jsonb_populate_record(NULL::jsbrec, '{\"ca\": [[1, 2, 3], {\"k\": \"v\"}]}') q" +== 413 +-- truncate_limit: 100 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{\"js\": null}') q" +== 414 +-- truncate_limit: 100 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": true}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{\"js\": true}') q" +== 415 +-- truncate_limit: 100 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": 123.45}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{\"js\": 123.45}') q" +== 416 +-- truncate_limit: 100 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": "123.45"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{\"js\": \"123.45\"}') q" +== 417 +-- truncate_limit: 100 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": "abc"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{\"js\": \"abc\"}') q" +== 418 +-- truncate_limit: 100 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": [123, "123", null, {"key": "value"}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{\"js\": [123, \"123\", null, {\"key\": \"value\"}]}') q" +== 419 +-- truncate_limit: 100 +SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{"js": {"a": "bbb", "b": null, "c": 123.45}}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT js FROM jsonb_populate_record(NULL::jsbrec, '{\"js\": {\"a\": \"bbb\", \"b\": null, \"c\": 123.45}}') q" +== 420 +-- truncate_limit: 100 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{\"jsb\": null}') q" +== 421 +-- truncate_limit: 100 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": true}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{\"jsb\": true}') q" +== 422 +-- truncate_limit: 100 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": 123.45}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{\"jsb\": 123.45}') q" +== 423 +-- truncate_limit: 100 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": "123.45"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{\"jsb\": \"123.45\"}') q" +== 424 +-- truncate_limit: 100 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": "abc"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{\"jsb\": \"abc\"}') q" +== 425 +-- truncate_limit: 100 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": [123, "123", null, {"key": "value"}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{\"jsb\": [123, \"123\", null, {\"key\": \"value\"}]..." +== 426 +-- truncate_limit: 100 +SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{"jsb": {"a": "bbb", "b": null, "c": 123.45}}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsb FROM jsonb_populate_record(NULL::jsbrec, '{\"jsb\": {\"a\": \"bbb\", \"b\": null, \"c\": 123.45}..." +== 427 +-- truncate_limit: 100 +SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{"jsa": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{\"jsa\": null}') q" +== 428 +-- truncate_limit: 100 +SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{"jsa": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{\"jsa\": 123}') q" +== 429 +-- truncate_limit: 100 +SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{"jsa": [1, "2", null, 4]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{\"jsa\": [1, \"2\", null, 4]}') q" +== 430 +-- truncate_limit: 100 +SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{"jsa": ["aaa", null, [1, 2, "3", {}], { "k" : "v" }]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsa FROM jsonb_populate_record(NULL::jsbrec, '{\"jsa\": [\"aaa\", null, [1, 2, \"3\", {}], { \"k\"..." +== 431 +-- truncate_limit: 100 +SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{"rec": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{\"rec\": 123}') q" +== 432 +-- truncate_limit: 100 +SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{"rec": [1, 2]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{\"rec\": [1, 2]}') q" +== 433 +-- truncate_limit: 100 +SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{"rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{\"rec\": {\"a\": \"abc\", \"c\": \"01.02.2003\", \"x\":..." +== 434 +-- truncate_limit: 100 +SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{"rec": "(abc,42,01.02.2003)"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM jsonb_populate_record(NULL::jsbrec, '{\"rec\": \"(abc,42,01.02.2003)\"}') q" +== 435 +-- truncate_limit: 100 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": 123}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{\"reca\": 123}') q" +== 436 +-- truncate_limit: 100 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": [1, 2]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{\"reca\": [1, 2]}') q" +== 437 +-- truncate_limit: 100 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": [{"a": "abc", "b": 456}, null, {"c": "01.02.2003", "x": 43.2}]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM jsonb_populate_record(NULL::jsbrec, '{\"reca\": [{\"a\": \"abc\", \"b\": 456}, null, {\"c\"..." +== 438 +-- truncate_limit: 100 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": ["(abc,42,01.02.2003)"]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{\"reca\": [\"(abc,42,01.02.2003)\"]}') q" +== 439 +-- truncate_limit: 100 +SELECT reca FROM jsonb_populate_record(NULL::jsbrec, '{"reca": "{\"(abc,42,01.02.2003)\"}"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reca FROM jsonb_populate_record(NULL::jsbrec, E'{\"reca\": \"{\\\\\"(abc,42,01.02.2003)\\\\\"}\"}') q" +== 440 +-- truncate_limit: 100 +SELECT rec FROM jsonb_populate_record( + row(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, + row('x',3,'2012-12-31 15:30:56')::jbpop,NULL)::jsbrec, + '{"rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}}' +) q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rec FROM jsonb_populate_record(ROW(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, N..." +== 441 +-- truncate_limit: 100 +-- Tests to check soft-error support for populate_record_field() + +-- populate_scalar() +create type jsb_char2 as (a char(2)) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsb_char2 AS (a char(2))" +== 442 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_char2, '{"a": "aaa"}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_char2, '{\"a\": \"aaa\"}')" +== 443 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_char2, '{"a": "aaa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_char2, '{\"a\": \"aaa\"}') q" +== 444 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_char2, '{"a": "aa"}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_char2, '{\"a\": \"aa\"}')" +== 445 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_char2, '{"a": "aa"}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_char2, '{\"a\": \"aa\"}') q" +== 446 +-- truncate_limit: 100 +-- populate_array() +create type jsb_ia as (a int[]) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsb_ia AS (a int[])" +== 447 +-- truncate_limit: 100 +create type jsb_ia2 as (a int[][]) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsb_ia2 AS (a int[][])" +== 448 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_ia, '{"a": 43.2}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_ia, '{\"a\": 43.2}')" +== 449 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_ia, '{"a": 43.2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_ia, '{\"a\": 43.2}') q" +== 450 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_ia, '{"a": [1, 2]}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_ia, '{\"a\": [1, 2]}')" +== 451 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_ia, '{"a": [1, 2]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_ia, '{\"a\": [1, 2]}') q" +== 452 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_ia2, '{"a": [[1], [2, 3]]}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_ia2, '{\"a\": [[1], [2, 3]]}')" +== 453 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_ia2, '{"a": [[1], [2, 3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_ia2, '{\"a\": [[1], [2, 3]]}') q" +== 454 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_ia2, '{"a": [[1, 0], [2, 3]]}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_ia2, '{\"a\": [[1, 0], [2, 3]]}')" +== 455 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_ia2, '{"a": [[1, 0], [2, 3]]}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_ia2, '{\"a\": [[1, 0], [2, 3]]}') q" +== 456 +-- truncate_limit: 100 +-- populate_domain() +create domain jsb_i_not_null as int not null +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN jsb_i_not_null AS int NOT NULL" +== 457 +-- truncate_limit: 100 +create domain jsb_i_gt_1 as int check (value > 1) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN jsb_i_gt_1 AS int CHECK (value > 1)" +== 458 +-- truncate_limit: 100 +create type jsb_i_not_null_rec as (a jsb_i_not_null) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsb_i_not_null_rec AS (a jsb_i_not_null)" +== 459 +-- truncate_limit: 100 +create type jsb_i_gt_1_rec as (a jsb_i_gt_1) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE jsb_i_gt_1_rec AS (a jsb_i_gt_1)" +== 460 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_i_not_null_rec, '{"a": null}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_i_not_null_rec, '{\"a\": null}')" +== 461 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_i_not_null_rec, '{"a": null}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_i_not_null_rec, '{\"a\": null}') q" +== 462 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_i_not_null_rec, '{"a": 1}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_i_not_null_rec, '{\"a\": 1}')" +== 463 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_i_not_null_rec, '{"a": 1}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_i_not_null_rec, '{\"a\": 1}') q" +== 464 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_i_gt_1_rec, '{"a": 1}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_i_gt_1_rec, '{\"a\": 1}')" +== 465 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_i_gt_1_rec, '{"a": 1}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_i_gt_1_rec, '{\"a\": 1}') q" +== 466 +-- truncate_limit: 100 +select jsonb_populate_record_valid(NULL::jsb_i_gt_1_rec, '{"a": 2}') +-- +FUNCTION: name="jsonb_populate_record_valid" function="jsonb_populate_record_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record_valid(NULL::jsb_i_gt_1_rec, '{\"a\": 2}')" +== 467 +-- truncate_limit: 100 +select * from jsonb_populate_record(NULL::jsb_i_gt_1_rec, '{"a": 2}') q +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::jsb_i_gt_1_rec, '{\"a\": 2}') q" +== 468 +-- truncate_limit: 100 +drop type jsb_ia, jsb_ia2, jsb_char2, jsb_i_not_null_rec, jsb_i_gt_1_rec +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE jsb_ia, jsb_ia2, jsb_char2, jsb_i_not_null_rec, jsb_i_gt_1_rec" +== 469 +-- truncate_limit: 100 +drop domain jsb_i_not_null, jsb_i_gt_1 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN jsb_i_not_null, jsb_i_gt_1" +== 470 +-- truncate_limit: 100 +-- anonymous record type +SELECT jsonb_populate_record(null::record, '{"x": 0, "y": 1}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record(NULL::record, '{\"x\": 0, \"y\": 1}')" +== 471 +-- truncate_limit: 100 +SELECT jsonb_populate_record(row(1,2), '{"f1": 0, "f2": 1}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record(ROW(1, 2), '{\"f1\": 0, \"f2\": 1}')" +== 472 +-- truncate_limit: 100 +SELECT * FROM + jsonb_populate_record(null::record, '{"x": 776}') AS (x int, y int) +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_record(NULL::record, '{\"x\": 776}') AS (x int, y int)" +== 473 +-- truncate_limit: 100 +-- composite domain +SELECT jsonb_populate_record(null::jb_ordered_pair, '{"x": 0, "y": 1}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record(NULL::jb_ordered_pair, '{\"x\": 0, \"y\": 1}')" +== 474 +-- truncate_limit: 100 +SELECT jsonb_populate_record(row(1,2)::jb_ordered_pair, '{"x": 0}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record(ROW(1, 2)::jb_ordered_pair, '{\"x\": 0}')" +== 475 +-- truncate_limit: 100 +SELECT jsonb_populate_record(row(1,2)::jb_ordered_pair, '{"x": 1, "y": 0}') +-- +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_record(ROW(1, 2)::jb_ordered_pair, '{\"x\": 1, \"y\": 0}')" +== 476 +-- truncate_limit: 100 +-- populate_recordset +SELECT * FROM jsonb_populate_recordset(NULL::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(NULL::jbpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":3,\"c\":\"2012-01..." +== 477 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW('def', 99, NULL)::jbpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b..." +== 478 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(NULL::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(NULL::jbpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":3,\"c\":\"2012-01..." +== 479 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW('def', 99, NULL)::jbpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b..." +== 480 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW('def', 99, NULL)::jbpop, '[{\"a\":[100,200,300],\"x\":43.2..." +== 481 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"c":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW('def', 99, NULL)::jbpop, '[{\"c\":[100,200,300],\"x\":43.2..." +== 482 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(NULL::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(NULL::jbpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b\":3,\"c\":\"2012-01..." +== 483 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":"blurfl","x":43.2},{"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW('def', 99, NULL)::jbpop, '[{\"a\":\"blurfl\",\"x\":43.2},{\"b..." +== 484 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(row('def',99,NULL)::jbpop,'[{"a":[100,200,300],"x":43.2},{"a":{"z":true},"b":3,"c":"2012-01-20 10:42:53"}]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW('def', 99, NULL)::jbpop, '[{\"a\":[100,200,300],\"x\":43.2..." +== 485 +-- truncate_limit: 100 +-- anonymous record type +SELECT jsonb_populate_recordset(null::record, '[{"x": 0, "y": 1}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_recordset(NULL::record, '[{\"x\": 0, \"y\": 1}]')" +== 486 +-- truncate_limit: 100 +SELECT jsonb_populate_recordset(row(1,2), '[{"f1": 0, "f2": 1}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_recordset(ROW(1, 2), '[{\"f1\": 0, \"f2\": 1}]')" +== 487 +-- truncate_limit: 100 +SELECT i, jsonb_populate_recordset(row(i,50), '[{"f1":"42"},{"f2":"43"}]') +FROM (VALUES (1),(2)) v(i) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i, jsonb_populate_recordset(ROW(i, 50), '[{\"f1\":\"42\"},{\"f2\":\"43\"}]') FROM (VALUES (...)) v(i)" +== 488 +-- truncate_limit: 100 +SELECT * FROM + jsonb_populate_recordset(null::record, '[{"x": 776}]') AS (x int, y int) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(NULL::record, '[{\"x\": 776}]') AS (x int, y int)" +== 489 +-- truncate_limit: 100 +-- empty array is a corner case +SELECT jsonb_populate_recordset(null::record, '[]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_recordset(NULL::record, '[]')" +== 490 +-- truncate_limit: 100 +SELECT jsonb_populate_recordset(row(1,2), '[]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_recordset(ROW(1, 2), '[]')" +== 491 +-- truncate_limit: 100 +SELECT * FROM jsonb_populate_recordset(NULL::jbpop,'[]') q +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(NULL::jbpop, '[]') q" +== 492 +-- truncate_limit: 100 +SELECT * FROM + jsonb_populate_recordset(null::record, '[]') AS (x int, y int) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(NULL::record, '[]') AS (x int, y int)" +== 493 +-- truncate_limit: 100 +-- composite domain +SELECT jsonb_populate_recordset(null::jb_ordered_pair, '[{"x": 0, "y": 1}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_recordset(NULL::jb_ordered_pair, '[{\"x\": 0, \"y\": 1}]')" +== 494 +-- truncate_limit: 100 +SELECT jsonb_populate_recordset(row(1,2)::jb_ordered_pair, '[{"x": 0}, {"y": 3}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_recordset(ROW(1, 2)::jb_ordered_pair, '[{\"x\": 0}, {\"y\": 3}]')" +== 495 +-- truncate_limit: 100 +SELECT jsonb_populate_recordset(row(1,2)::jb_ordered_pair, '[{"x": 1, "y": 0}]') +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_populate_recordset(ROW(1, 2)::jb_ordered_pair, '[{\"x\": 1, \"y\": 0}]')" +== 496 +-- truncate_limit: 100 +-- negative cases where the wrong record type is supplied +select * from jsonb_populate_recordset(row(0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW(0::int), '[{\"a\":\"1\",\"b\":\"2\"},{\"a\":\"3\"}]') q (a text, b..." +== 497 +-- truncate_limit: 100 +select * from jsonb_populate_recordset(row(0::int,0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW(0::int, 0::int), '[{\"a\":\"1\",\"b\":\"2\"},{\"a\":\"3\"}]') q (a..." +== 498 +-- truncate_limit: 100 +select * from jsonb_populate_recordset(row(0::int,0::int,0::int),'[{"a":"1","b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW(0::int, 0::int, 0::int), '[{\"a\":\"1\",\"b\":\"2\"},{\"a\":\"3\"}..." +== 499 +-- truncate_limit: 100 +select * from jsonb_populate_recordset(row(1000000000::int,50::int),'[{"b":"2"},{"a":"3"}]') q (a text, b text) +-- +FUNCTION: name="jsonb_populate_recordset" function="jsonb_populate_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_populate_recordset(ROW(1000000000::int, 50::int), '[{\"b\":\"2\"},{\"a\":\"3\"}]') q ..." +== 500 +-- truncate_limit: 100 +-- jsonb_to_record and jsonb_to_recordset + +select * from jsonb_to_record('{"a":1,"b":"foo","c":"bar"}') + as x(a int, b text, d text) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"a\":1,\"b\":\"foo\",\"c\":\"bar\"}') x (a int, b text, d text)" +== 501 +-- truncate_limit: 100 +select * from jsonb_to_recordset('[{"a":1,"b":"foo","d":false},{"a":2,"b":"bar","c":true}]') + as x(a int, b text, c boolean) +-- +FUNCTION: name="jsonb_to_recordset" function="jsonb_to_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_recordset('[{\"a\":1,\"b\":\"foo\",\"d\":false},{\"a\":2,\"b\":\"bar\",\"c\":true}]') x (a..." +== 502 +-- truncate_limit: 100 +select *, c is null as c_is_null +from jsonb_to_record('{"a":1, "b":{"c":16, "d":2}, "x":8, "ca": ["1 2", 3], "ia": [[1,2],[3,4]], "r": {"a": "aaa", "b": 123}}'::jsonb) + as t(a int, b jsonb, c text, x int, ca char(5)[], ia int[][], r jbpop) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM jsonb_to_record('{\"a\":1, \"b\":{\"c\":16, \"d\":2}, \"x\":8, \"ca\": [\"1 2\", 3], \"ia\": [[1,..." +== 503 +-- truncate_limit: 100 +select *, c is null as c_is_null +from jsonb_to_recordset('[{"a":1, "b":{"c":16, "d":2}, "x":8}]'::jsonb) + as t(a int, b jsonb, c text, x int) +-- +FUNCTION: name="jsonb_to_recordset" function="jsonb_to_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM jsonb_to_recordset('[{\"a\":1, \"b\":{\"c\":16, \"d\":2}, \"x\":8}]'::jsonb) t (a int, b js..." +== 504 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia": null}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia\": null}') x (ia _int4)" +== 505 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia": 123}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia\": 123}') x (ia _int4)" +== 506 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia": [1, "2", null, 4]}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia\": [1, \"2\", null, 4]}') x (ia _int4)" +== 507 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia": [[1, 2], [3, 4]]}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia\": [[1, 2], [3, 4]]}') x (ia _int4)" +== 508 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia": [[1], 2]}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia\": [[1], 2]}') x (ia _int4)" +== 509 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia": [[1], [2, 3]]}') as x(ia _int4) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia\": [[1], [2, 3]]}') x (ia _int4)" +== 510 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia2": [1, 2, 3]}') as x(ia2 int[][]) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia2\": [1, 2, 3]}') x (ia2 int[][])" +== 511 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia2": [[1, 2], [3, 4]]}') as x(ia2 int4[][]) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia2\": [[1, 2], [3, 4]]}') x (ia2 int4[][])" +== 512 +-- truncate_limit: 100 +select * from jsonb_to_record('{"ia2": [[[1], [2], [3]]]}') as x(ia2 int4[][]) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"ia2\": [[[1], [2], [3]]]}') x (ia2 int4[][])" +== 513 +-- truncate_limit: 100 +select * from jsonb_to_record('{"out": {"key": 1}}') as x(out json) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"out\": {\"key\": 1}}') x (\"out\" pg_catalog.json)" +== 514 +-- truncate_limit: 100 +select * from jsonb_to_record('{"out": [{"key": 1}]}') as x(out json) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"out\": [{\"key\": 1}]}') x (\"out\" pg_catalog.json)" +== 515 +-- truncate_limit: 100 +select * from jsonb_to_record('{"out": "{\"key\": 1}"}') as x(out json) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record(E'{\"out\": \"{\\\\\"key\\\\\": 1}\"}') x (\"out\" pg_catalog.json)" +== 516 +-- truncate_limit: 100 +select * from jsonb_to_record('{"out": {"key": 1}}') as x(out jsonb) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"out\": {\"key\": 1}}') x (\"out\" jsonb)" +== 517 +-- truncate_limit: 100 +select * from jsonb_to_record('{"out": [{"key": 1}]}') as x(out jsonb) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record('{\"out\": [{\"key\": 1}]}') x (\"out\" jsonb)" +== 518 +-- truncate_limit: 100 +select * from jsonb_to_record('{"out": "{\"key\": 1}"}') as x(out jsonb) +-- +FUNCTION: name="jsonb_to_record" function="jsonb_to_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_to_record(E'{\"out\": \"{\\\\\"key\\\\\": 1}\"}') x (\"out\" jsonb)" +== 519 +-- truncate_limit: 100 +-- test type info caching in jsonb_populate_record() +CREATE TEMP TABLE jsbpoptest (js jsonb) +-- +TABLE: name="jsbpoptest" schema="" table="jsbpoptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE jsbpoptest (js jsonb)" +== 520 +-- truncate_limit: 100 +INSERT INTO jsbpoptest +SELECT '{ + "jsa": [1, "2", null, 4], + "rec": {"a": "abc", "c": "01.02.2003", "x": 43.2}, + "reca": [{"a": "abc", "b": 456}, null, {"c": "01.02.2003", "x": 43.2}] +}'::jsonb +FROM generate_series(1, 3) +-- +TABLE: name="jsbpoptest" schema="" table="jsbpoptest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO jsbpoptest SELECT ... FROM generate_series(1, 3)" +== 521 +-- truncate_limit: 100 +SELECT (jsonb_populate_record(NULL::jsbrec, js)).* FROM jsbpoptest +-- +TABLE: name="jsbpoptest" schema="" table="jsbpoptest" ctx=Select +FUNCTION: name="jsonb_populate_record" function="jsonb_populate_record" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (jsonb_populate_record(NULL::jsbrec, js)).* FROM jsbpoptest" +== 522 +-- truncate_limit: 100 +DROP TYPE jsbrec +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE jsbrec" +== 523 +-- truncate_limit: 100 +DROP TYPE jsbrec_i_not_null +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE jsbrec_i_not_null" +== 524 +-- truncate_limit: 100 +DROP DOMAIN jsb_int_not_null +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN jsb_int_not_null" +== 525 +-- truncate_limit: 100 +DROP DOMAIN jsb_int_array_1d +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN jsb_int_array_1d" +== 526 +-- truncate_limit: 100 +DROP DOMAIN jsb_int_array_2d +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN jsb_int_array_2d" +== 527 +-- truncate_limit: 100 +DROP DOMAIN jb_ordered_pair +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN jb_ordered_pair" +== 528 +-- truncate_limit: 100 +DROP TYPE jb_unordered_pair +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE jb_unordered_pair" +== 529 +-- truncate_limit: 100 +-- indexing +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":null}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":null}'" +== 530 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC"}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":\"CC\"}'" +== 531 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC", "public":true}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":\"CC\", \"public\":true}'" +== 532 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"age\":25}'" +== 533 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25.0}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"age\":25.0}'" +== 534 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j ? 'public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j ? 'public'" +== 535 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j ? 'bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j ? 'bar'" +== 536 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j ?| ARRAY['public','disabled'] +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j ?| ARRAY['public', 'disabled']" +== 537 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j ?& ARRAY['public','disabled'] +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j ?& ARRAY['public', 'disabled']" +== 538 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null'" +== 539 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '"CC" == $.wait' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '\"CC\" == $.wait'" +== 540 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == "CC" && true == $.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == \"CC\" && true == $.public'" +== 541 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25'" +== 542 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0'" +== 543 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)'" +== 544 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public)'" +== 545 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.bar)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.bar)'" +== 546 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) || exists($.disabled)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) || exists($.disabled)'" +== 547 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) && exists($.disabled)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) && exists($.disabled)'" +== 548 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)'" +== 549 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? ("CC" == @)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (\"CC\" == @)'" +== 550 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == "CC" && true == @.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == \"CC\" && true == @.public)'" +== 551 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)'" +== 552 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)'" +== 553 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$'" +== 554 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.public'" +== 555 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.bar'" +== 556 +-- truncate_limit: 100 +CREATE INDEX jidx ON testjsonb USING gin (j) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX jidx ON testjsonb USING gin (j)" +== 557 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 558 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":null}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":null}'" +== 559 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC"}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":\"CC\"}'" +== 560 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC", "public":true}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":\"CC\", \"public\":true}'" +== 561 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"age\":25}'" +== 562 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25.0}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"age\":25.0}'" +== 563 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"array":["foo"]}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"array\":[\"foo\"]}'" +== 564 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"array":["bar"]}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"array\":[\"bar\"]}'" +== 565 +-- truncate_limit: 100 +-- exercise GIN_SEARCH_MODE_ALL +SELECT count(*) FROM testjsonb WHERE j @> '{}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{}'" +== 566 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j ? 'public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j ? 'public'" +== 567 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j ? 'bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j ? 'bar'" +== 568 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j ?| ARRAY['public','disabled'] +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j ?| ARRAY['public', 'disabled']" +== 569 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j ?& ARRAY['public','disabled'] +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j ?& ARRAY['public', 'disabled']" +== 570 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null'" +== 571 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null'" +== 572 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.wait == null))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.wait == null))'" +== 573 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.wait ? (@ == null))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.wait ? (@ == null))'" +== 574 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '"CC" == $.wait' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '\"CC\" == $.wait'" +== 575 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == "CC" && true == $.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == \"CC\" && true == $.public'" +== 576 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25'" +== 577 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0'" +== 578 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == "foo"' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == \"foo\"'" +== 579 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == "bar"' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == \"bar\"'" +== 580 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.array[*] == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.array[*] == \"bar\"))'" +== 581 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array ? (@[*] == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array ? (@[*] == \"bar\"))'" +== 582 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array[*] ? (@ == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array[*] ? (@ == \"bar\"))'" +== 583 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)'" +== 584 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public)'" +== 585 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.bar)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.bar)'" +== 586 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) || exists($.disabled)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) || exists($.disabled)'" +== 587 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) && exists($.disabled)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.public) && exists($.disabled)'" +== 588 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)'" +== 589 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)'" +== 590 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? ("CC" == @)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (\"CC\" == @)'" +== 591 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == "CC" && true == @.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == \"CC\" && true == @.public)'" +== 592 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)'" +== 593 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)'" +== 594 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.array[*] == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.array[*] == \"bar\")'" +== 595 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.array ? (@[*] == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.array ? (@[*] == \"bar\")'" +== 596 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.array[*] ? (@ == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.array[*] ? (@ == \"bar\")'" +== 597 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$'" +== 598 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.public'" +== 599 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.bar'" +== 600 +-- truncate_limit: 100 +-- array exists - array elements should behave as keys (for GIN index scans too) +CREATE INDEX jidx_array ON testjsonb USING gin((j->'array')) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX jidx_array ON testjsonb USING gin ((j -> 'array'))" +== 601 +-- truncate_limit: 100 +SELECT count(*) from testjsonb WHERE j->'array' ? 'bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE (j -> 'array') ? 'bar'" +== 602 +-- truncate_limit: 100 +-- type sensitive array exists - should return no rows (since "exists" only +-- matches strings that are either object keys or array elements) +SELECT count(*) from testjsonb WHERE j->'array' ? '5'::text +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE (j -> 'array') ? '5'::text" +== 603 +-- truncate_limit: 100 +-- However, a raw scalar is *contained* within the array +SELECT count(*) from testjsonb WHERE j->'array' @> '5'::jsonb +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE (j -> 'array') @> '5'::jsonb" +== 604 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 605 +-- truncate_limit: 100 +SELECT count(*) FROM (SELECT (jsonb_each(j)).key FROM testjsonb) AS wow +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT (jsonb_each(j)).key FROM testjsonb) wow" +== 606 +-- truncate_limit: 100 +SELECT key, count(*) FROM (SELECT (jsonb_each(j)).key FROM testjsonb) AS wow GROUP BY key ORDER BY count DESC, key +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="jsonb_each" function="jsonb_each" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT key, count(*) FROM (SELECT ... FROM testjsonb) wow GROUP BY key ORDER BY count DESC, key" +== 607 +-- truncate_limit: 100 +-- sort/hash +SELECT count(distinct j) FROM testjsonb +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT j) FROM testjsonb" +== 608 +-- truncate_limit: 100 +SET enable_hashagg = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 609 +-- truncate_limit: 100 +SELECT count(*) FROM (SELECT j FROM (SELECT * FROM testjsonb UNION ALL SELECT * FROM testjsonb) js GROUP BY j) js2 +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT j FROM (SELECT * FROM testjsonb UNION ALL SELECT * FROM testjsonb) js GRO..." +== 610 +-- truncate_limit: 100 +SET enable_hashagg = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO ON" +== 611 +-- truncate_limit: 100 +SET enable_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO OFF" +== 612 +-- truncate_limit: 100 +SELECT count(*) FROM (SELECT j FROM (SELECT * FROM testjsonb UNION ALL SELECT * FROM testjsonb) js GROUP BY j) js2 +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT j FROM (SELECT * FROM testjsonb UNION ALL SELECT * FROM testjsonb) js GRO..." +== 613 +-- truncate_limit: 100 +SELECT distinct * FROM (values (jsonb '{}' || ''::text),('{}')) v(j) +-- +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT * FROM (VALUES ('{}'::jsonb || ''::text), ('{}')) v(j)" +== 614 +-- truncate_limit: 100 +SET enable_sort = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO ON" +== 615 +-- truncate_limit: 100 +RESET enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 616 +-- truncate_limit: 100 +RESET enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 617 +-- truncate_limit: 100 +DROP INDEX jidx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX jidx" +== 618 +-- truncate_limit: 100 +DROP INDEX jidx_array +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX jidx_array" +== 619 +-- truncate_limit: 100 +-- btree +CREATE INDEX jidx ON testjsonb USING btree (j) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX jidx ON testjsonb USING btree (j)" +== 620 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 621 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j > '{"p":1}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j > '{\"p\":1}'" +== 622 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j = '{"pos":98, "line":371, "node":"CBA", "indexed":true}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j = '{\"pos\":98, \"line\":371, \"node\":\"CBA\", \"indexed\":true}'" +== 623 +-- truncate_limit: 100 +--gin path opclass +DROP INDEX jidx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX jidx" +== 624 +-- truncate_limit: 100 +CREATE INDEX jidx ON testjsonb USING gin (j jsonb_path_ops) +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX jidx ON testjsonb USING gin (j jsonb_path_ops)" +== 625 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 626 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":null}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":null}'" +== 627 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC"}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":\"CC\"}'" +== 628 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"wait":"CC", "public":true}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"wait\":\"CC\", \"public\":true}'" +== 629 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"age\":25}'" +== 630 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @> '{"age":25.0}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{\"age\":25.0}'" +== 631 +-- truncate_limit: 100 +-- exercise GIN_SEARCH_MODE_ALL +SELECT count(*) FROM testjsonb WHERE j @> '{}' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @> '{}'" +== 632 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == null'" +== 633 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.wait == null))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.wait == null))'" +== 634 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.wait ? (@ == null))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.wait ? (@ == null))'" +== 635 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '"CC" == $.wait' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '\"CC\" == $.wait'" +== 636 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == "CC" && true == $.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.wait == \"CC\" && true == $.public'" +== 637 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25'" +== 638 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.age == 25.0'" +== 639 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == "foo"' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == \"foo\"'" +== 640 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == "bar"' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ '$.array[*] == \"bar\"'" +== 641 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.array[*] == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($ ? (@.array[*] == \"bar\"))'" +== 642 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array ? (@[*] == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array ? (@[*] == \"bar\"))'" +== 643 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array[*] ? (@ == "bar"))' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($.array[*] ? (@ == \"bar\"))'" +== 644 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @@ 'exists($)'" +== 645 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)'" +== 646 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (@ == null)'" +== 647 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? ("CC" == @)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.wait ? (\"CC\" == @)'" +== 648 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == "CC" && true == @.public)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.wait == \"CC\" && true == @.public)'" +== 649 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.age ? (@ == 25)'" +== 650 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.age == 25.0)'" +== 651 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.array[*] == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$ ? (@.array[*] == \"bar\")'" +== 652 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.array ? (@[*] == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.array ? (@[*] == \"bar\")'" +== 653 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.array[*] ? (@ == "bar")' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.array[*] ? (@ == \"bar\")'" +== 654 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$'" +== 655 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.public' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.public'" +== 656 +-- truncate_limit: 100 +SELECT count(*) FROM testjsonb WHERE j @? '$.bar' +-- +TABLE: name="testjsonb" schema="" table="testjsonb" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testjsonb WHERE j @? '$.bar'" +== 657 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 658 +-- truncate_limit: 100 +DROP INDEX jidx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX jidx" +== 659 +-- truncate_limit: 100 +-- nested tests +SELECT '{"ff":{"a":12,"b":16}}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"ff\":{\"a\":12,\"b\":16}}'::jsonb" +== 660 +-- truncate_limit: 100 +SELECT '{"ff":{"a":12,"b":16},"qq":123}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"ff\":{\"a\":12,\"b\":16},\"qq\":123}'::jsonb" +== 661 +-- truncate_limit: 100 +SELECT '{"aa":["a","aaa"],"qq":{"a":12,"b":16,"c":["c1","c2"],"d":{"d1":"d1","d2":"d2","d1":"d3"}}}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 662 +-- truncate_limit: 100 +SELECT '{"aa":["a","aaa"],"qq":{"a":"12","b":"16","c":["c1","c2"],"d":{"d1":"d1","d2":"d2"}}}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 663 +-- truncate_limit: 100 +SELECT '{"aa":["a","aaa"],"qq":{"a":"12","b":"16","c":["c1","c2",["c3"],{"c4":4}],"d":{"d1":"d1","d2":"d2"}}}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 664 +-- truncate_limit: 100 +SELECT '{"ff":["a","aaa"]}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"ff\":[\"a\",\"aaa\"]}'::jsonb" +== 665 +-- truncate_limit: 100 +SELECT + '{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb -> 'ff', + '{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb -> 'qq', + ('{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb -> 'Y') IS NULL AS f, + ('{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb ->> 'Y') IS NULL AS t, + '{"ff":{"a":12,"b":16},"qq":123,"x":[1,2],"Y":null}'::jsonb -> 'x' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 666 +-- truncate_limit: 100 +-- nested containment +SELECT '{"a":[1,2],"c":"b"}'::jsonb @> '{"a":[1,2]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[1,2],\"c\":\"b\"}'::jsonb @> '{\"a\":[1,2]}'" +== 667 +-- truncate_limit: 100 +SELECT '{"a":[2,1],"c":"b"}'::jsonb @> '{"a":[1,2]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[2,1],\"c\":\"b\"}'::jsonb @> '{\"a\":[1,2]}'" +== 668 +-- truncate_limit: 100 +SELECT '{"a":{"1":2},"c":"b"}'::jsonb @> '{"a":[1,2]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":{\"1\":2},\"c\":\"b\"}'::jsonb @> '{\"a\":[1,2]}'" +== 669 +-- truncate_limit: 100 +SELECT '{"a":{"2":1},"c":"b"}'::jsonb @> '{"a":[1,2]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":{\"2\":1},\"c\":\"b\"}'::jsonb @> '{\"a\":[1,2]}'" +== 670 +-- truncate_limit: 100 +SELECT '{"a":{"1":2},"c":"b"}'::jsonb @> '{"a":{"1":2}}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":{\"1\":2},\"c\":\"b\"}'::jsonb @> '{\"a\":{\"1\":2}}'" +== 671 +-- truncate_limit: 100 +SELECT '{"a":{"2":1},"c":"b"}'::jsonb @> '{"a":{"1":2}}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":{\"2\":1},\"c\":\"b\"}'::jsonb @> '{\"a\":{\"1\":2}}'" +== 672 +-- truncate_limit: 100 +SELECT '["a","b"]'::jsonb @> '["a","b","c","b"]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\"]'::jsonb @> '[\"a\",\"b\",\"c\",\"b\"]'" +== 673 +-- truncate_limit: 100 +SELECT '["a","b","c","b"]'::jsonb @> '["a","b"]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",\"b\"]'::jsonb @> '[\"a\",\"b\"]'" +== 674 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2]]'::jsonb @> '["a",[1,2]]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2]]'::jsonb @> '[\"a\",[1,2]]'" +== 675 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2]]'::jsonb @> '["b",[1,2]]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2]]'::jsonb @> '[\"b\",[1,2]]'" +== 676 +-- truncate_limit: 100 +SELECT '{"a":[1,2],"c":"b"}'::jsonb @> '{"a":[1]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[1,2],\"c\":\"b\"}'::jsonb @> '{\"a\":[1]}'" +== 677 +-- truncate_limit: 100 +SELECT '{"a":[1,2],"c":"b"}'::jsonb @> '{"a":[2]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[1,2],\"c\":\"b\"}'::jsonb @> '{\"a\":[2]}'" +== 678 +-- truncate_limit: 100 +SELECT '{"a":[1,2],"c":"b"}'::jsonb @> '{"a":[3]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[1,2],\"c\":\"b\"}'::jsonb @> '{\"a\":[3]}'" +== 679 +-- truncate_limit: 100 +SELECT '{"a":[1,2,{"c":3,"x":4}],"c":"b"}'::jsonb @> '{"a":[{"c":3}]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[1,2,{\"c\":3,\"x\":4}],\"c\":\"b\"}'::jsonb @> '{\"a\":[{\"c\":3}]}'" +== 680 +-- truncate_limit: 100 +SELECT '{"a":[1,2,{"c":3,"x":4}],"c":"b"}'::jsonb @> '{"a":[{"x":4}]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[1,2,{\"c\":3,\"x\":4}],\"c\":\"b\"}'::jsonb @> '{\"a\":[{\"x\":4}]}'" +== 681 +-- truncate_limit: 100 +SELECT '{"a":[1,2,{"c":3,"x":4}],"c":"b"}'::jsonb @> '{"a":[{"x":4},3]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[1,2,{\"c\":3,\"x\":4}],\"c\":\"b\"}'::jsonb @> '{\"a\":[{\"x\":4},3]}'" +== 682 +-- truncate_limit: 100 +SELECT '{"a":[1,2,{"c":3,"x":4}],"c":"b"}'::jsonb @> '{"a":[{"x":4},1]}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":[1,2,{\"c\":3,\"x\":4}],\"c\":\"b\"}'::jsonb @> '{\"a\":[{\"x\":4},1]}'" +== 683 +-- truncate_limit: 100 +-- check some corner cases for indexed nested containment (bug #13756) +create temp table nestjsonb (j jsonb) +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE nestjsonb (j jsonb)" +== 684 +-- truncate_limit: 100 +insert into nestjsonb (j) values ('{"a":[["b",{"x":1}],["b",{"x":2}]],"c":3}') +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nestjsonb (j) VALUES ('{\"a\":[[\"b\",{\"x\":1}],[\"b\",{\"x\":2}]],\"c\":3}')" +== 685 +-- truncate_limit: 100 +insert into nestjsonb (j) values ('[[14,2,3]]') +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nestjsonb (j) VALUES ('[[14,2,3]]')" +== 686 +-- truncate_limit: 100 +insert into nestjsonb (j) values ('[1,[14,2,3]]') +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nestjsonb (j) VALUES ('[1,[14,2,3]]')" +== 687 +-- truncate_limit: 100 +create index on nestjsonb using gin(j jsonb_path_ops) +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON nestjsonb USING gin (j jsonb_path_ops)" +== 688 +-- truncate_limit: 100 +set enable_seqscan = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 689 +-- truncate_limit: 100 +set enable_bitmapscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 690 +-- truncate_limit: 100 +select * from nestjsonb where j @> '{"a":[[{"x":2}]]}'::jsonb +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nestjsonb WHERE j @> '{\"a\":[[{\"x\":2}]]}'::jsonb" +== 691 +-- truncate_limit: 100 +select * from nestjsonb where j @> '{"c":3}' +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nestjsonb WHERE j @> '{\"c\":3}'" +== 692 +-- truncate_limit: 100 +select * from nestjsonb where j @> '[[14]]' +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nestjsonb WHERE j @> '[[14]]'" +== 693 +-- truncate_limit: 100 +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 694 +-- truncate_limit: 100 +set enable_bitmapscan = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 695 +-- truncate_limit: 100 +select * from nestjsonb where j @> '{"a":[[{"x":2}]]}'::jsonb +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nestjsonb WHERE j @> '{\"a\":[[{\"x\":2}]]}'::jsonb" +== 696 +-- truncate_limit: 100 +select * from nestjsonb where j @> '{"c":3}' +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nestjsonb WHERE j @> '{\"c\":3}'" +== 697 +-- truncate_limit: 100 +select * from nestjsonb where j @> '[[14]]' +-- +TABLE: name="nestjsonb" schema="" table="nestjsonb" ctx=Select +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nestjsonb WHERE j @> '[[14]]'" +== 698 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 699 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 700 +-- truncate_limit: 100 +-- nested object field / array index lookup +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'n' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb -> 'n'" +== 701 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb -> 'a'" +== 702 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb -> 'b'" +== 703 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'c' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb -> 'c'" +== 704 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'd' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb -> 'd'" +== 705 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'd' -> '1' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb -> 'd') -> '1'" +== 706 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 'e' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb -> 'e'" +== 707 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb -> 0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb -> 0" +== 708 +-- truncate_limit: 100 +--expecting error + +SELECT '["a","b","c",[1,2],null]'::jsonb -> 0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> 0" +== 709 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> 1" +== 710 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> 2" +== 711 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> 3" +== 712 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 3 -> 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> 3) -> 1" +== 713 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> 4" +== 714 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> 5 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> 5" +== 715 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> -1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> -1" +== 716 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> -5 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> -5" +== 717 +-- truncate_limit: 100 +SELECT '["a","b","c",[1,2],null]'::jsonb -> -6 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\",[1,2],null]'::jsonb -> -6" +== 718 +-- truncate_limit: 100 +--nested path extraction +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{0}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{0}'" +== 719 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{a}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{a}'" +== 720 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{c}'" +== 721 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,0}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{c,0}'" +== 722 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,1}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{c,1}'" +== 723 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,2}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{c,2}'" +== 724 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,3}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{c,3}'" +== 725 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,-1}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{c,-1}'" +== 726 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,-3}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{c,-3}'" +== 727 +-- truncate_limit: 100 +SELECT '{"a":"b","c":[1,2,3]}'::jsonb #> '{c,-4}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\",\"c\":[1,2,3]}'::jsonb #> '{c,-4}'" +== 728 +-- truncate_limit: 100 +SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{0}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[0,1,2,[3,4],{\"5\":\"five\"}]'::jsonb #> '{0}'" +== 729 +-- truncate_limit: 100 +SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{3}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[0,1,2,[3,4],{\"5\":\"five\"}]'::jsonb #> '{3}'" +== 730 +-- truncate_limit: 100 +SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{4}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[0,1,2,[3,4],{\"5\":\"five\"}]'::jsonb #> '{4}'" +== 731 +-- truncate_limit: 100 +SELECT '[0,1,2,[3,4],{"5":"five"}]'::jsonb #> '{4,5}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[0,1,2,[3,4],{\"5\":\"five\"}]'::jsonb #> '{4,5}'" +== 732 +-- truncate_limit: 100 +--nested exists +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'n' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb ? 'n'" +== 733 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb ? 'a'" +== 734 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb ? 'b'" +== 735 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'c' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb ? 'c'" +== 736 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'd' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb ? 'd'" +== 737 +-- truncate_limit: 100 +SELECT '{"n":null,"a":1,"b":[1,2],"c":{"1":2},"d":{"1":[2,3]}}'::jsonb ? 'e' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null,\"a\":1,\"b\":[1,2],\"c\":{\"1\":2},\"d\":{\"1\":[2,3]}}'::jsonb ? 'e'" +== 738 +-- truncate_limit: 100 +-- jsonb_strip_nulls + +select jsonb_strip_nulls(null) +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_strip_nulls(NULL)" +== 739 +-- truncate_limit: 100 +select jsonb_strip_nulls('1') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_strip_nulls('1')" +== 740 +-- truncate_limit: 100 +select jsonb_strip_nulls('"a string"') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_strip_nulls('\"a string\"')" +== 741 +-- truncate_limit: 100 +select jsonb_strip_nulls('null') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_strip_nulls('null')" +== 742 +-- truncate_limit: 100 +select jsonb_strip_nulls('[1,2,null,3,4]') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_strip_nulls('[1,2,null,3,4]')" +== 743 +-- truncate_limit: 100 +select jsonb_strip_nulls('{"a":1,"b":null,"c":[2,null,3],"d":{"e":4,"f":null}}') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_strip_nulls('{\"a\":1,\"b\":null,\"c\":[2,null,3],\"d\":{\"e\":4,\"f\":null}}')" +== 744 +-- truncate_limit: 100 +select jsonb_strip_nulls('[1,{"a":1,"b":null,"c":2},3]') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_strip_nulls('[1,{\"a\":1,\"b\":null,\"c\":2},3]')" +== 745 +-- truncate_limit: 100 +-- an empty object is not null and should not be stripped +select jsonb_strip_nulls('{"a": {"b": null, "c": null}, "d": {} }') +-- +FUNCTION: name="jsonb_strip_nulls" function="jsonb_strip_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_strip_nulls('{\"a\": {\"b\": null, \"c\": null}, \"d\": {} }')" +== 746 +-- truncate_limit: 100 +select jsonb_pretty('{"a": "test", "b": [1, 2, 3], "c": "test3", "d":{"dd": "test4", "dd2":{"ddd": "test5"}}}') +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 747 +-- truncate_limit: 100 +select jsonb_pretty('[{"f1":1,"f2":null},2,null,[[{"x":true},6,7],8],3]') +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_pretty('[{\"f1\":1,\"f2\":null},2,null,[[{\"x\":true},6,7],8],3]')" +== 748 +-- truncate_limit: 100 +select jsonb_pretty('{"a":["b", "c"], "d": {"e":"f"}}') +-- +FUNCTION: name="jsonb_pretty" function="jsonb_pretty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_pretty('{\"a\":[\"b\", \"c\"], \"d\": {\"e\":\"f\"}}')" +== 749 +-- truncate_limit: 100 +select jsonb_concat('{"d": "test", "a": [1, 2]}', '{"g": "test2", "c": {"c1":1, "c2":2}}') +-- +FUNCTION: name="jsonb_concat" function="jsonb_concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_concat('{\"d\": \"test\", \"a\": [1, 2]}', '{\"g\": \"test2\", \"c\": {\"c1\":1, \"c2\":2}}')" +== 750 +-- truncate_limit: 100 +select '{"aa":1 , "b":2, "cq":3}'::jsonb || '{"cq":"l", "b":"g", "fg":false}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"aa\":1 , \"b\":2, \"cq\":3}'::jsonb || '{\"cq\":\"l\", \"b\":\"g\", \"fg\":false}'" +== 751 +-- truncate_limit: 100 +select '{"aa":1 , "b":2, "cq":3}'::jsonb || '{"aq":"l"}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"aa\":1 , \"b\":2, \"cq\":3}'::jsonb || '{\"aq\":\"l\"}'" +== 752 +-- truncate_limit: 100 +select '{"aa":1 , "b":2, "cq":3}'::jsonb || '{"aa":"l"}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"aa\":1 , \"b\":2, \"cq\":3}'::jsonb || '{\"aa\":\"l\"}'" +== 753 +-- truncate_limit: 100 +select '{"aa":1 , "b":2, "cq":3}'::jsonb || '{}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"aa\":1 , \"b\":2, \"cq\":3}'::jsonb || '{}'" +== 754 +-- truncate_limit: 100 +select '["a", "b"]'::jsonb || '["c"]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\", \"b\"]'::jsonb || '[\"c\"]'" +== 755 +-- truncate_limit: 100 +select '["a", "b"]'::jsonb || '["c", "d"]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\", \"b\"]'::jsonb || '[\"c\", \"d\"]'" +== 756 +-- truncate_limit: 100 +select '["c"]' || '["a", "b"]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"c\"]' || '[\"a\", \"b\"]'::jsonb" +== 757 +-- truncate_limit: 100 +select '["a", "b"]'::jsonb || '"c"' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\", \"b\"]'::jsonb || '\"c\"'" +== 758 +-- truncate_limit: 100 +select '"c"' || '["a", "b"]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"c\"' || '[\"a\", \"b\"]'::jsonb" +== 759 +-- truncate_limit: 100 +select '[]'::jsonb || '["a"]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb || '[\"a\"]'::jsonb" +== 760 +-- truncate_limit: 100 +select '[]'::jsonb || '"a"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb || '\"a\"'::jsonb" +== 761 +-- truncate_limit: 100 +select '"b"'::jsonb || '"a"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"b\"'::jsonb || '\"a\"'::jsonb" +== 762 +-- truncate_limit: 100 +select '{}'::jsonb || '{"a":"b"}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb || '{\"a\":\"b\"}'::jsonb" +== 763 +-- truncate_limit: 100 +select '[]'::jsonb || '{"a":"b"}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb || '{\"a\":\"b\"}'::jsonb" +== 764 +-- truncate_limit: 100 +select '{"a":"b"}'::jsonb || '[]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":\"b\"}'::jsonb || '[]'::jsonb" +== 765 +-- truncate_limit: 100 +select '"a"'::jsonb || '{"a":1}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"a\"'::jsonb || '{\"a\":1}'" +== 766 +-- truncate_limit: 100 +select '{"a":1}' || '"a"'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":1}' || '\"a\"'::jsonb" +== 767 +-- truncate_limit: 100 +select '[3]'::jsonb || '{}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[3]'::jsonb || '{}'::jsonb" +== 768 +-- truncate_limit: 100 +select '3'::jsonb || '[]'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3'::jsonb || '[]'::jsonb" +== 769 +-- truncate_limit: 100 +select '3'::jsonb || '4'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3'::jsonb || '4'::jsonb" +== 770 +-- truncate_limit: 100 +select '3'::jsonb || '{}'::jsonb +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3'::jsonb || '{}'::jsonb" +== 771 +-- truncate_limit: 100 +select '["a", "b"]'::jsonb || '{"c":1}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\", \"b\"]'::jsonb || '{\"c\":1}'" +== 772 +-- truncate_limit: 100 +select '{"c": 1}'::jsonb || '["a", "b"]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": 1}'::jsonb || '[\"a\", \"b\"]'" +== 773 +-- truncate_limit: 100 +select '{}'::jsonb || '{"cq":"l", "b":"g", "fg":false}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb || '{\"cq\":\"l\", \"b\":\"g\", \"fg\":false}'" +== 774 +-- truncate_limit: 100 +select pg_column_size('{}'::jsonb || '{}'::jsonb) = pg_column_size('{}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_column_size('{}'::jsonb || '{}'::jsonb) = pg_column_size('{}'::jsonb)" +== 775 +-- truncate_limit: 100 +select pg_column_size('{"aa":1}'::jsonb || '{"b":2}'::jsonb) = pg_column_size('{"aa":1, "b":2}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 776 +-- truncate_limit: 100 +select pg_column_size('{"aa":1, "b":2}'::jsonb || '{}'::jsonb) = pg_column_size('{"aa":1, "b":2}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 777 +-- truncate_limit: 100 +select pg_column_size('{}'::jsonb || '{"aa":1, "b":2}'::jsonb) = pg_column_size('{"aa":1, "b":2}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 778 +-- truncate_limit: 100 +select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'a') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_delete('{\"a\":1 , \"b\":2, \"c\":3}'::jsonb, 'a')" +== 779 +-- truncate_limit: 100 +select jsonb_delete('{"a":null , "b":2, "c":3}'::jsonb, 'a') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_delete('{\"a\":null , \"b\":2, \"c\":3}'::jsonb, 'a')" +== 780 +-- truncate_limit: 100 +select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'b') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_delete('{\"a\":1 , \"b\":2, \"c\":3}'::jsonb, 'b')" +== 781 +-- truncate_limit: 100 +select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'c') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_delete('{\"a\":1 , \"b\":2, \"c\":3}'::jsonb, 'c')" +== 782 +-- truncate_limit: 100 +select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'd') +-- +FUNCTION: name="jsonb_delete" function="jsonb_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_delete('{\"a\":1 , \"b\":2, \"c\":3}'::jsonb, 'd')" +== 783 +-- truncate_limit: 100 +select '{"a":1 , "b":2, "c":3}'::jsonb - 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":1 , \"b\":2, \"c\":3}'::jsonb - 'a'" +== 784 +-- truncate_limit: 100 +select '{"a":null , "b":2, "c":3}'::jsonb - 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":null , \"b\":2, \"c\":3}'::jsonb - 'a'" +== 785 +-- truncate_limit: 100 +select '{"a":1 , "b":2, "c":3}'::jsonb - 'b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":1 , \"b\":2, \"c\":3}'::jsonb - 'b'" +== 786 +-- truncate_limit: 100 +select '{"a":1 , "b":2, "c":3}'::jsonb - 'c' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":1 , \"b\":2, \"c\":3}'::jsonb - 'c'" +== 787 +-- truncate_limit: 100 +select '{"a":1 , "b":2, "c":3}'::jsonb - 'd' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":1 , \"b\":2, \"c\":3}'::jsonb - 'd'" +== 788 +-- truncate_limit: 100 +select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b') = pg_column_size('{"a":1, "b":2}'::jsonb) +-- +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +FUNCTION: name="pg_column_size" function="pg_column_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 789 +-- truncate_limit: 100 +select '["a","b","c"]'::jsonb - 3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\"]'::jsonb - 3" +== 790 +-- truncate_limit: 100 +select '["a","b","c"]'::jsonb - 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\"]'::jsonb - 2" +== 791 +-- truncate_limit: 100 +select '["a","b","c"]'::jsonb - 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\"]'::jsonb - 1" +== 792 +-- truncate_limit: 100 +select '["a","b","c"]'::jsonb - 0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\"]'::jsonb - 0" +== 793 +-- truncate_limit: 100 +select '["a","b","c"]'::jsonb - -1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\"]'::jsonb - -1" +== 794 +-- truncate_limit: 100 +select '["a","b","c"]'::jsonb - -2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\"]'::jsonb - -2" +== 795 +-- truncate_limit: 100 +select '["a","b","c"]'::jsonb - -3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\"]'::jsonb - -3" +== 796 +-- truncate_limit: 100 +select '["a","b","c"]'::jsonb - -4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"a\",\"b\",\"c\"]'::jsonb - -4" +== 797 +-- truncate_limit: 100 +select '{"a":1 , "b":2, "c":3}'::jsonb - '{b}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":1 , \"b\":2, \"c\":3}'::jsonb - '{b}'::text[]" +== 798 +-- truncate_limit: 100 +select '{"a":1 , "b":2, "c":3}'::jsonb - '{c,b}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":1 , \"b\":2, \"c\":3}'::jsonb - '{c,b}'::text[]" +== 799 +-- truncate_limit: 100 +select '{"a":1 , "b":2, "c":3}'::jsonb - '{}'::text[] +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\":1 , \"b\":2, \"c\":3}'::jsonb - '{}'::text[]" +== 800 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{n}', '[1,2,3]') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 801 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '[1,2,3]') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 802 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{d,1,0}', '[1,2,3]') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 803 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{d,NULL,0}', '[1,2,3]') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 804 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{n}', '{"1": 2}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 805 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '{"1": 2}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 806 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{d,1,0}', '{"1": 2}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 807 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{d,NULL,0}', '{"1": 2}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 808 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '"test"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 809 +-- truncate_limit: 100 +select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '{"f": "test"}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 810 +-- truncate_limit: 100 +select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}') +-- +FUNCTION: name="jsonb_delete_path" function="jsonb_delete_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_delete_path('{\"n\":null, \"a\":1, \"b\":[1,2], \"c\":{\"1\":2}, \"d\":{\"1\":[2,3]}}', '{n}')" +== 811 +-- truncate_limit: 100 +select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}') +-- +FUNCTION: name="jsonb_delete_path" function="jsonb_delete_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_delete_path('{\"n\":null, \"a\":1, \"b\":[1,2], \"c\":{\"1\":2}, \"d\":{\"1\":[2,3]}}', '{b,-1}')" +== 812 +-- truncate_limit: 100 +select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}') +-- +FUNCTION: name="jsonb_delete_path" function="jsonb_delete_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_delete_path('{\"n\":null, \"a\":1, \"b\":[1,2], \"c\":{\"1\":2}, \"d\":{\"1\":[2,3]}}', '{d,1,0}')" +== 813 +-- truncate_limit: 100 +select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{n}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null, \"a\":1, \"b\":[1,2], \"c\":{\"1\":2}, \"d\":{\"1\":[2,3]}}'::jsonb #- '{n}'" +== 814 +-- truncate_limit: 100 +select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null, \"a\":1, \"b\":[1,2], \"c\":{\"1\":2}, \"d\":{\"1\":[2,3]}}'::jsonb #- '{b,-1}'" +== 815 +-- truncate_limit: 100 +select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1e}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null, \"a\":1, \"b\":[1,2], \"c\":{\"1\":2}, \"d\":{\"1\":[2,3]}}'::jsonb #- '{b,-1e}'" +== 816 +-- truncate_limit: 100 +-- invalid array subscript +select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{d,1,0}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"n\":null, \"a\":1, \"b\":[1,2], \"c\":{\"1\":2}, \"d\":{\"1\":[2,3]}}'::jsonb #- '{d,1,0}'" +== 817 +-- truncate_limit: 100 +-- empty structure and error conditions for delete and replace + +select '"a"'::jsonb - 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"a\"'::jsonb - 'a'" +== 818 +-- truncate_limit: 100 +-- error +select '{}'::jsonb - 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb - 'a'" +== 819 +-- truncate_limit: 100 +select '[]'::jsonb - 'a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb - 'a'" +== 820 +-- truncate_limit: 100 +select '"a"'::jsonb - 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"a\"'::jsonb - 1" +== 821 +-- truncate_limit: 100 +-- error +select '{}'::jsonb - 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb - 1" +== 822 +-- truncate_limit: 100 +-- error +select '[]'::jsonb - 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb - 1" +== 823 +-- truncate_limit: 100 +select '"a"'::jsonb #- '{a}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"a\"'::jsonb #- '{a}'" +== 824 +-- truncate_limit: 100 +-- error +select '{}'::jsonb #- '{a}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb #- '{a}'" +== 825 +-- truncate_limit: 100 +select '[]'::jsonb #- '{a}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb #- '{a}'" +== 826 +-- truncate_limit: 100 +select jsonb_set('"a"','{a}','"b"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('\"a\"', '{a}', '\"b\"')" +== 827 +-- truncate_limit: 100 +--error +select jsonb_set('{}','{a}','"b"', false) +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{}', '{a}', '\"b\"', false)" +== 828 +-- truncate_limit: 100 +select jsonb_set('[]','{1}','"b"', false) +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('[]', '{1}', '\"b\"', false)" +== 829 +-- truncate_limit: 100 +select jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0}','[2,3,4]', false) +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('[{\"f1\":1,\"f2\":null},2,null,3]', '{0}', '[2,3,4]', false)" +== 830 +-- truncate_limit: 100 +-- jsonb_set adding instead of replacing + +-- prepend to array +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,-33}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\":1,\"b\":[0,1,2],\"c\":{\"d\":4}}', '{b,-33}', '{\"foo\":123}')" +== 831 +-- truncate_limit: 100 +-- append to array +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,33}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\":1,\"b\":[0,1,2],\"c\":{\"d\":4}}', '{b,33}', '{\"foo\":123}')" +== 832 +-- truncate_limit: 100 +-- check nesting levels addition +select jsonb_set('{"a":1,"b":[4,5,[0,1,2],6,7],"c":{"d":4}}','{b,2,33}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\":1,\"b\":[4,5,[0,1,2],6,7],\"c\":{\"d\":4}}', '{b,2,33}', '{\"foo\":123}')" +== 833 +-- truncate_limit: 100 +-- add new key +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{c,e}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\":1,\"b\":[0,1,2],\"c\":{\"d\":4}}', '{c,e}', '{\"foo\":123}')" +== 834 +-- truncate_limit: 100 +-- adding doesn't do anything if elements before last aren't present +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{x,-33}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\":1,\"b\":[0,1,2],\"c\":{\"d\":4}}', '{x,-33}', '{\"foo\":123}')" +== 835 +-- truncate_limit: 100 +select jsonb_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{x,y}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\":1,\"b\":[0,1,2],\"c\":{\"d\":4}}', '{x,y}', '{\"foo\":123}')" +== 836 +-- truncate_limit: 100 +-- add to empty object +select jsonb_set('{}','{x}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{}', '{x}', '{\"foo\":123}')" +== 837 +-- truncate_limit: 100 +--add to empty array +select jsonb_set('[]','{0}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('[]', '{0}', '{\"foo\":123}')" +== 838 +-- truncate_limit: 100 +select jsonb_set('[]','{99}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('[]', '{99}', '{\"foo\":123}')" +== 839 +-- truncate_limit: 100 +select jsonb_set('[]','{-99}','{"foo":123}') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('[]', '{-99}', '{\"foo\":123}')" +== 840 +-- truncate_limit: 100 +select jsonb_set('{"a": [1, 2, 3]}', '{a, non_integer}', '"new_value"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\": [1, 2, 3]}', '{a, non_integer}', '\"new_value\"')" +== 841 +-- truncate_limit: 100 +select jsonb_set('{"a": {"b": [1, 2, 3]}}', '{a, b, non_integer}', '"new_value"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\": {\"b\": [1, 2, 3]}}', '{a, b, non_integer}', '\"new_value\"')" +== 842 +-- truncate_limit: 100 +select jsonb_set('{"a": {"b": [1, 2, 3]}}', '{a, b, NULL}', '"new_value"') +-- +FUNCTION: name="jsonb_set" function="jsonb_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set('{\"a\": {\"b\": [1, 2, 3]}}', '{a, b, NULL}', '\"new_value\"')" +== 843 +-- truncate_limit: 100 +-- jsonb_set_lax + + +-- pass though non nulls to jsonb_set +select jsonb_set_lax('{"a":1,"b":2}','{b}','5') +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set_lax('{\"a\":1,\"b\":2}', '{b}', '5')" +== 844 +-- truncate_limit: 100 +select jsonb_set_lax('{"a":1,"b":2}','{d}','6', true) +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set_lax('{\"a\":1,\"b\":2}', '{d}', '6', true)" +== 845 +-- truncate_limit: 100 +-- using the default treatment +select jsonb_set_lax('{"a":1,"b":2}','{b}',null) +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set_lax('{\"a\":1,\"b\":2}', '{b}', NULL)" +== 846 +-- truncate_limit: 100 +select jsonb_set_lax('{"a":1,"b":2}','{d}',null,true) +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set_lax('{\"a\":1,\"b\":2}', '{d}', NULL, true)" +== 847 +-- truncate_limit: 100 +-- errors +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, true, null) +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set_lax('{\"a\":1,\"b\":2}', '{b}', NULL, true, NULL)" +== 848 +-- truncate_limit: 100 +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, true, 'no_such_treatment') +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_set_lax('{\"a\":1,\"b\":2}', '{b}', NULL, true, 'no_such_treatment')" +== 849 +-- truncate_limit: 100 +-- explicit treatments +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, null_value_treatment => 'raise_exception') as raise_exception +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 850 +-- truncate_limit: 100 +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, null_value_treatment => 'return_target') as return_target +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 851 +-- truncate_limit: 100 +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, null_value_treatment => 'delete_key') as delete_key +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 852 +-- truncate_limit: 100 +select jsonb_set_lax('{"a":1,"b":2}', '{b}', null, null_value_treatment => 'use_json_null') as use_json_null +-- +FUNCTION: name="jsonb_set_lax" function="jsonb_set_lax" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 853 +-- truncate_limit: 100 +-- jsonb_insert +select jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 1}', '\"new_value\"')" +== 854 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 1}', '\"new_value\"', true)" +== 855 +-- truncate_limit: 100 +select jsonb_insert('{"a": {"b": {"c": [0, 1, "test1", "test2"]}}}', '{a, b, c, 2}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": {\"b\": {\"c\": [0, 1, \"test1\", \"test2\"]}}}', '{a, b, c, 2}', '\"new_value\"')" +== 856 +-- truncate_limit: 100 +select jsonb_insert('{"a": {"b": {"c": [0, 1, "test1", "test2"]}}}', '{a, b, c, 2}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 857 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '{"b": "value"}') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 1}', '{\"b\": \"value\"}')" +== 858 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '["value1", "value2"]') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 1}', '[\"value1\", \"value2\"]')" +== 859 +-- truncate_limit: 100 +-- edge cases +select jsonb_insert('{"a": [0,1,2]}', '{a, 0}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 0}', '\"new_value\"')" +== 860 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, 0}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 0}', '\"new_value\"', true)" +== 861 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, 2}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 2}', '\"new_value\"')" +== 862 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, 2}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 2}', '\"new_value\"', true)" +== 863 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, -1}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, -1}', '\"new_value\"')" +== 864 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, -1}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, -1}', '\"new_value\"', true)" +== 865 +-- truncate_limit: 100 +select jsonb_insert('[]', '{1}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('[]', '{1}', '\"new_value\"')" +== 866 +-- truncate_limit: 100 +select jsonb_insert('[]', '{1}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('[]', '{1}', '\"new_value\"', true)" +== 867 +-- truncate_limit: 100 +select jsonb_insert('{"a": []}', '{a, 1}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": []}', '{a, 1}', '\"new_value\"')" +== 868 +-- truncate_limit: 100 +select jsonb_insert('{"a": []}', '{a, 1}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": []}', '{a, 1}', '\"new_value\"', true)" +== 869 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, 10}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, 10}', '\"new_value\"')" +== 870 +-- truncate_limit: 100 +select jsonb_insert('{"a": [0,1,2]}', '{a, -10}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": [0,1,2]}', '{a, -10}', '\"new_value\"')" +== 871 +-- truncate_limit: 100 +-- jsonb_insert should be able to insert new value for objects, but not to replace +select jsonb_insert('{"a": {"b": "value"}}', '{a, c}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": {\"b\": \"value\"}}', '{a, c}', '\"new_value\"')" +== 872 +-- truncate_limit: 100 +select jsonb_insert('{"a": {"b": "value"}}', '{a, c}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": {\"b\": \"value\"}}', '{a, c}', '\"new_value\"', true)" +== 873 +-- truncate_limit: 100 +select jsonb_insert('{"a": {"b": "value"}}', '{a, b}', '"new_value"') +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": {\"b\": \"value\"}}', '{a, b}', '\"new_value\"')" +== 874 +-- truncate_limit: 100 +select jsonb_insert('{"a": {"b": "value"}}', '{a, b}', '"new_value"', true) +-- +FUNCTION: name="jsonb_insert" function="jsonb_insert" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_insert('{\"a\": {\"b\": \"value\"}}', '{a, b}', '\"new_value\"', true)" +== 875 +-- truncate_limit: 100 +-- jsonb subscript +select ('123'::jsonb)['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('123'::jsonb)['a']" +== 876 +-- truncate_limit: 100 +select ('123'::jsonb)[0] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('123'::jsonb)[0]" +== 877 +-- truncate_limit: 100 +select ('123'::jsonb)[NULL] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('123'::jsonb)[NULL]" +== 878 +-- truncate_limit: 100 +select ('{"a": 1}'::jsonb)['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1}'::jsonb)['a']" +== 879 +-- truncate_limit: 100 +select ('{"a": 1}'::jsonb)[0] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1}'::jsonb)[0]" +== 880 +-- truncate_limit: 100 +select ('{"a": 1}'::jsonb)['not_exist'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1}'::jsonb)['not_exist']" +== 881 +-- truncate_limit: 100 +select ('{"a": 1}'::jsonb)[NULL] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1}'::jsonb)[NULL]" +== 882 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)['a']" +== 883 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[0] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[0]" +== 884 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)['1'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)['1']" +== 885 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[1.0] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[1.0]" +== 886 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[2]" +== 887 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[3] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[3]" +== 888 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[-2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[-2]" +== 889 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[1]['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[1]['a']" +== 890 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[1][0] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[1][0]" +== 891 +-- truncate_limit: 100 +select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb)['b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1, \"b\": \"c\", \"d\": [1, 2, 3]}'::jsonb)['b']" +== 892 +-- truncate_limit: 100 +select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb)['d'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1, \"b\": \"c\", \"d\": [1, 2, 3]}'::jsonb)['d']" +== 893 +-- truncate_limit: 100 +select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb)['d'][1] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1, \"b\": \"c\", \"d\": [1, 2, 3]}'::jsonb)['d'][1]" +== 894 +-- truncate_limit: 100 +select ('{"a": 1, "b": "c", "d": [1, 2, 3]}'::jsonb)['d']['a'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1, \"b\": \"c\", \"d\": [1, 2, 3]}'::jsonb)['d']['a']" +== 895 +-- truncate_limit: 100 +select ('{"a": {"a1": {"a2": "aaa"}}, "b": "bbb", "c": "ccc"}'::jsonb)['a']['a1'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": {\"a1\": {\"a2\": \"aaa\"}}, \"b\": \"bbb\", \"c\": \"ccc\"}'::jsonb)['a']['a1']" +== 896 +-- truncate_limit: 100 +select ('{"a": {"a1": {"a2": "aaa"}}, "b": "bbb", "c": "ccc"}'::jsonb)['a']['a1']['a2'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": {\"a1\": {\"a2\": \"aaa\"}}, \"b\": \"bbb\", \"c\": \"ccc\"}'::jsonb)['a']['a1']['a2']" +== 897 +-- truncate_limit: 100 +select ('{"a": {"a1": {"a2": "aaa"}}, "b": "bbb", "c": "ccc"}'::jsonb)['a']['a1']['a2']['a3'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": {\"a1\": {\"a2\": \"aaa\"}}, \"b\": \"bbb\", \"c\": \"ccc\"}'::jsonb)['a']['a1']['a2']['a3']" +== 898 +-- truncate_limit: 100 +select ('{"a": ["a1", {"b1": ["aaa", "bbb", "ccc"]}], "b": "bb"}'::jsonb)['a'][1]['b1'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": [\"a1\", {\"b1\": [\"aaa\", \"bbb\", \"ccc\"]}], \"b\": \"bb\"}'::jsonb)['a'][1]['b1']" +== 899 +-- truncate_limit: 100 +select ('{"a": ["a1", {"b1": ["aaa", "bbb", "ccc"]}], "b": "bb"}'::jsonb)['a'][1]['b1'][2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": [\"a1\", {\"b1\": [\"aaa\", \"bbb\", \"ccc\"]}], \"b\": \"bb\"}'::jsonb)['a'][1]['b1'][2]" +== 900 +-- truncate_limit: 100 +-- slices are not supported +select ('{"a": 1}'::jsonb)['a':'b'] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('{\"a\": 1}'::jsonb)['a':'b']" +== 901 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[1:2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[1:2]" +== 902 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[:2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[:2]" +== 903 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[1:] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[1:]" +== 904 +-- truncate_limit: 100 +select ('[1, "2", null]'::jsonb)[:] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ('[1, \"2\", null]'::jsonb)[:]" +== 905 +-- truncate_limit: 100 +create TEMP TABLE test_jsonb_subscript ( + id int, + test_json jsonb +) +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_jsonb_subscript (id int, test_json jsonb)" +== 906 +-- truncate_limit: 100 +insert into test_jsonb_subscript values +(1, '{}'), -- empty jsonb +(2, '{"key": "value"}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{}'), (2, '{\"key\": \"value\"}')" +== 907 +-- truncate_limit: 100 +-- jsonb with data + +-- update empty jsonb +update test_jsonb_subscript set test_json['a'] = '1' where id = 1 +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'] = '1' WHERE id = 1" +== 908 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 909 +-- truncate_limit: 100 +-- update jsonb with some data +update test_jsonb_subscript set test_json['a'] = '1' where id = 2 +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'] = '1' WHERE id = 2" +== 910 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 911 +-- truncate_limit: 100 +-- replace jsonb +update test_jsonb_subscript set test_json['a'] = '"test"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'] = '\"test\"'" +== 912 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 913 +-- truncate_limit: 100 +-- replace by object +update test_jsonb_subscript set test_json['a'] = '{"b": 1}'::jsonb +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'] = '{\"b\": 1}'::jsonb" +== 914 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 915 +-- truncate_limit: 100 +-- replace by array +update test_jsonb_subscript set test_json['a'] = '[1, 2, 3]'::jsonb +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'] = '[1, 2, 3]'::jsonb" +== 916 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 917 +-- truncate_limit: 100 +-- use jsonb subscription in where clause +select * from test_jsonb_subscript where test_json['key'] = '"value"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FILTER: schema="" table="" column="test_json" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript WHERE test_json['key'] = '\"value\"'" +== 918 +-- truncate_limit: 100 +select * from test_jsonb_subscript where test_json['key_doesnt_exists'] = '"value"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FILTER: schema="" table="" column="test_json" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript WHERE test_json['key_doesnt_exists'] = '\"value\"'" +== 919 +-- truncate_limit: 100 +select * from test_jsonb_subscript where test_json['key'] = '"wrong_value"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FILTER: schema="" table="" column="test_json" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript WHERE test_json['key'] = '\"wrong_value\"'" +== 920 +-- truncate_limit: 100 +-- NULL +update test_jsonb_subscript set test_json[NULL] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[NULL] = '1'" +== 921 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['another_key'] = NULL +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['another_key'] = NULL" +== 922 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 923 +-- truncate_limit: 100 +-- NULL as jsonb source +insert into test_jsonb_subscript values (3, NULL) +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (3, NULL)" +== 924 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'] = '1' where id = 3 +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'] = '1' WHERE id = 3" +== 925 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 926 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json = NULL where id = 3 +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json = NULL WHERE id = 3" +== 927 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[0] = '1'" +== 928 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 929 +-- truncate_limit: 100 +-- Fill the gaps logic +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 930 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '[0]') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '[0]')" +== 931 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[5] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[5] = '1'" +== 932 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 933 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[-4] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[-4] = '1'" +== 934 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 935 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[-8] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[-8] = '1'" +== 936 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 937 +-- truncate_limit: 100 +-- keep consistent values position +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 938 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '[]') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '[]')" +== 939 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[5] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[5] = '1'" +== 940 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 941 +-- truncate_limit: 100 +-- create the whole path +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 942 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{}')" +== 943 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'][0]['b'][0]['c'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'][0]['b'][0]['c'] = '1'" +== 944 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 945 +-- truncate_limit: 100 +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 946 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{}')" +== 947 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'][2]['b'][2]['c'][2] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'][2]['b'][2]['c'][2] = '1'" +== 948 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 949 +-- truncate_limit: 100 +-- create the whole path with already existing keys +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 950 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{"b": 1}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{\"b\": 1}')" +== 951 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'][0] = '2' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'][0] = '2'" +== 952 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 953 +-- truncate_limit: 100 +-- the start jsonb is an object, first subscript is treated as a key +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 954 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{}')" +== 955 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[0]['a'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[0]['a'] = '1'" +== 956 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 957 +-- truncate_limit: 100 +-- the start jsonb is an array +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 958 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '[]') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '[]')" +== 959 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[0]['a'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[0]['a'] = '1'" +== 960 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[2]['b'] = '2' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[2]['b'] = '2'" +== 961 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 962 +-- truncate_limit: 100 +-- overwriting an existing path +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 963 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{}')" +== 964 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a']['b'][1] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a']['b'][1] = '1'" +== 965 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a']['b'][10] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a']['b'][10] = '1'" +== 966 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 967 +-- truncate_limit: 100 +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 968 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '[]') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '[]')" +== 969 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[0][0][0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[0][0][0] = '1'" +== 970 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[0][0][1] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[0][0][1] = '1'" +== 971 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 972 +-- truncate_limit: 100 +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 973 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{}')" +== 974 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a']['b'][10] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a']['b'][10] = '1'" +== 975 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'][10][10] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'][10][10] = '1'" +== 976 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 977 +-- truncate_limit: 100 +-- an empty sub element + +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 978 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{"a": {}}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{\"a\": {}}')" +== 979 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a']['b']['c'][2] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a']['b']['c'][2] = '1'" +== 980 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 981 +-- truncate_limit: 100 +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 982 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{"a": []}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{\"a\": []}')" +== 983 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'][1]['c'][2] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'][1]['c'][2] = '1'" +== 984 +-- truncate_limit: 100 +select * from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 985 +-- truncate_limit: 100 +-- trying replace assuming a composite object, but it's an element or a value + +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 986 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, '{"a": 1}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, '{\"a\": 1}')" +== 987 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a']['b'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a']['b'] = '1'" +== 988 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a']['b']['c'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a']['b']['c'] = '1'" +== 989 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'][0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'][0] = '1'" +== 990 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'][0]['c'] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'][0]['c'] = '1'" +== 991 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json['a'][0][0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json['a'][0][0] = '1'" +== 992 +-- truncate_limit: 100 +-- trying replace assuming a composite object, but it's a raw scalar + +delete from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM test_jsonb_subscript" +== 993 +-- truncate_limit: 100 +insert into test_jsonb_subscript values (1, 'null') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES (1, 'null')" +== 994 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[0] = '1'" +== 995 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[0][0] = '1' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[0][0] = '1'" +== 996 +-- truncate_limit: 100 +-- try some things with short-header and toasted subscript values + +drop table test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_jsonb_subscript" +== 997 +-- truncate_limit: 100 +create temp table test_jsonb_subscript ( + id text, + test_json jsonb +) +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_jsonb_subscript (id text, test_json jsonb)" +== 998 +-- truncate_limit: 100 +insert into test_jsonb_subscript values('foo', '{"foo": "bar"}') +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript VALUES ('foo', '{\"foo\": \"bar\"}')" +== 999 +-- truncate_limit: 100 +insert into test_jsonb_subscript + select s, ('{"' || s || '": "bar"}')::jsonb from repeat('xyzzy', 500) s +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_subscript SELECT ... FROM repeat('xyzzy', 500) s" +== 1000 +-- truncate_limit: 100 +select length(id), test_json[id] from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(id), test_json[id] FROM test_jsonb_subscript" +== 1001 +-- truncate_limit: 100 +update test_jsonb_subscript set test_json[id] = '"baz"' +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_jsonb_subscript SET test_json[id] = '\"baz\"'" +== 1002 +-- truncate_limit: 100 +select length(id), test_json[id] from test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(id), test_json[id] FROM test_jsonb_subscript" +== 1003 +-- truncate_limit: 100 +table test_jsonb_subscript +-- +TABLE: name="test_jsonb_subscript" schema="" table="test_jsonb_subscript" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_jsonb_subscript" +== 1004 +-- truncate_limit: 100 +-- jsonb to tsvector +select to_tsvector('{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('{\"a\": \"aaa bbb ddd ccc\", \"b\": [\"eee fff ggg\"], \"c\": {\"d\": \"hhh iii\"}}'::jsonb)" +== 1005 +-- truncate_limit: 100 +-- jsonb to tsvector with config +select to_tsvector('simple', '{"a": "aaa bbb ddd ccc", "b": ["eee fff ggg"], "c": {"d": "hhh iii"}}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1006 +-- truncate_limit: 100 +-- jsonb to tsvector with stop words +select to_tsvector('english', '{"a": "aaa in bbb ddd ccc", "b": ["the eee fff ggg"], "c": {"d": "hhh. iii"}}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1007 +-- truncate_limit: 100 +-- jsonb to tsvector with numeric values +select to_tsvector('english', '{"a": "aaa in bbb ddd ccc", "b": 123, "c": 456}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('english', '{\"a\": \"aaa in bbb ddd ccc\", \"b\": 123, \"c\": 456}'::jsonb)" +== 1008 +-- truncate_limit: 100 +-- jsonb_to_tsvector +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1009 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"key"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1010 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"string"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1011 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"numeric"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1012 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"boolean"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1013 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '["string", "numeric"]') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1014 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1015 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"key"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1016 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"string"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1017 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"numeric"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1018 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '"boolean"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1019 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '["string", "numeric"]') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1020 +-- truncate_limit: 100 +-- to_tsvector corner cases +select to_tsvector('""'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('\"\"'::jsonb)" +== 1021 +-- truncate_limit: 100 +select to_tsvector('{}'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('{}'::jsonb)" +== 1022 +-- truncate_limit: 100 +select to_tsvector('[]'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('[]'::jsonb)" +== 1023 +-- truncate_limit: 100 +select to_tsvector('null'::jsonb) +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('null'::jsonb)" +== 1024 +-- truncate_limit: 100 +-- jsonb_to_tsvector corner cases +select jsonb_to_tsvector('""'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_to_tsvector('\"\"'::jsonb, '\"all\"')" +== 1025 +-- truncate_limit: 100 +select jsonb_to_tsvector('{}'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_to_tsvector('{}'::jsonb, '\"all\"')" +== 1026 +-- truncate_limit: 100 +select jsonb_to_tsvector('[]'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_to_tsvector('[]'::jsonb, '\"all\"')" +== 1027 +-- truncate_limit: 100 +select jsonb_to_tsvector('null'::jsonb, '"all"') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_to_tsvector('null'::jsonb, '\"all\"')" +== 1028 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '""') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1029 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '{}') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1030 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '[]') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1031 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, 'null') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1032 +-- truncate_limit: 100 +select jsonb_to_tsvector('english', '{"a": "aaa in bbb", "b": 123, "c": 456, "d": true, "f": false, "g": null}'::jsonb, '["all", null]') +-- +FUNCTION: name="jsonb_to_tsvector" function="jsonb_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1033 +-- truncate_limit: 100 +-- ts_headline for jsonb +select ts_headline('{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::jsonb, tsquery('bbb & ddd & hhh')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1034 +-- truncate_limit: 100 +select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc ddd fff"}, "d": ["ggg hhh", "iii jjj"]}'::jsonb, tsquery('bbb & ddd & hhh')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1035 +-- truncate_limit: 100 +select ts_headline('{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::jsonb, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1036 +-- truncate_limit: 100 +select ts_headline('english', '{"a": "aaa bbb", "b": {"c": "ccc ddd fff", "c1": "ccc1 ddd1"}, "d": ["ggg hhh", "iii jjj"]}'::jsonb, tsquery('bbb & ddd & hhh'), 'StartSel = <, StopSel = >') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 1037 +-- truncate_limit: 100 +-- corner cases for ts_headline with jsonb +select ts_headline('null'::jsonb, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('null'::jsonb, tsquery('aaa & bbb'))" +== 1038 +-- truncate_limit: 100 +select ts_headline('{}'::jsonb, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('{}'::jsonb, tsquery('aaa & bbb'))" +== 1039 +-- truncate_limit: 100 +select ts_headline('[]'::jsonb, tsquery('aaa & bbb')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="tsquery" function="tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('[]'::jsonb, tsquery('aaa & bbb'))" +== 1040 +-- truncate_limit: 100 +-- casts +select 'true'::jsonb::bool +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true'::jsonb::bool" +== 1041 +-- truncate_limit: 100 +select '[]'::jsonb::bool +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb::bool" +== 1042 +-- truncate_limit: 100 +select '1.0'::jsonb::float +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.0'::jsonb::double precision" +== 1043 +-- truncate_limit: 100 +select '[1.0]'::jsonb::float +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1.0]'::jsonb::double precision" +== 1044 +-- truncate_limit: 100 +select '12345'::jsonb::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345'::jsonb::int4" +== 1045 +-- truncate_limit: 100 +select '"hello"'::jsonb::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"hello\"'::jsonb::int4" +== 1046 +-- truncate_limit: 100 +select '12345'::jsonb::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345'::jsonb::numeric" +== 1047 +-- truncate_limit: 100 +select '{}'::jsonb::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb::numeric" +== 1048 +-- truncate_limit: 100 +select '12345.05'::jsonb::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.05'::jsonb::numeric" +== 1049 +-- truncate_limit: 100 +select '12345.05'::jsonb::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.05'::jsonb::float4" +== 1050 +-- truncate_limit: 100 +select '12345.05'::jsonb::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.05'::jsonb::float8" +== 1051 +-- truncate_limit: 100 +select '12345.05'::jsonb::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.05'::jsonb::int2" +== 1052 +-- truncate_limit: 100 +select '12345.05'::jsonb::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.05'::jsonb::int4" +== 1053 +-- truncate_limit: 100 +select '12345.05'::jsonb::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.05'::jsonb::int8" +== 1054 +-- truncate_limit: 100 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.0000000000000000000000000000000000000000000005'::jsonb::numeric" +== 1055 +-- truncate_limit: 100 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.0000000000000000000000000000000000000000000005'::jsonb::float4" +== 1056 +-- truncate_limit: 100 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.0000000000000000000000000000000000000000000005'::jsonb::float8" +== 1057 +-- truncate_limit: 100 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.0000000000000000000000000000000000000000000005'::jsonb::int2" +== 1058 +-- truncate_limit: 100 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.0000000000000000000000000000000000000000000005'::jsonb::int4" +== 1059 +-- truncate_limit: 100 +select '12345.0000000000000000000000000000000000000000000005'::jsonb::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345.0000000000000000000000000000000000000000000005'::jsonb::int8" diff --git a/parser/testdata/summary_truncate/postgres_regress/jsonb_jsonpath.metadata.json b/parser/testdata/summary_truncate/postgres_regress/jsonb_jsonpath.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/jsonb_jsonpath.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/jsonb_jsonpath.test b/parser/testdata/summary_truncate/postgres_regress/jsonb_jsonpath.test new file mode 100644 index 0000000..75d5fb7 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/jsonb_jsonpath.test @@ -0,0 +1,5897 @@ +== 001 +-- truncate_limit: 100 +select jsonb '{"a": 12}' @? '$' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 12}'::jsonb @? '$'" +== 002 +-- truncate_limit: 100 +select jsonb '{"a": 12}' @? '1' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 12}'::jsonb @? '1'" +== 003 +-- truncate_limit: 100 +select jsonb '{"a": 12}' @? '$.a.b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 12}'::jsonb @? '$.a.b'" +== 004 +-- truncate_limit: 100 +select jsonb '{"a": 12}' @? '$.b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 12}'::jsonb @? '$.b'" +== 005 +-- truncate_limit: 100 +select jsonb '{"a": 12}' @? '$.a + 2' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 12}'::jsonb @? '$.a + 2'" +== 006 +-- truncate_limit: 100 +select jsonb '{"a": 12}' @? '$.b + 2' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 12}'::jsonb @? '$.b + 2'" +== 007 +-- truncate_limit: 100 +select jsonb '{"a": {"a": 12}}' @? '$.a.a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"a\": 12}}'::jsonb @? '$.a.a'" +== 008 +-- truncate_limit: 100 +select jsonb '{"a": {"a": 12}}' @? '$.*.a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"a\": 12}}'::jsonb @? '$.*.a'" +== 009 +-- truncate_limit: 100 +select jsonb '{"b": {"a": 12}}' @? '$.*.a' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"b\": {\"a\": 12}}'::jsonb @? '$.*.a'" +== 010 +-- truncate_limit: 100 +select jsonb '{"b": {"a": 12}}' @? '$.*.b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"b\": {\"a\": 12}}'::jsonb @? '$.*.b'" +== 011 +-- truncate_limit: 100 +select jsonb '{"b": {"a": 12}}' @? 'strict $.*.b' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"b\": {\"a\": 12}}'::jsonb @? 'strict $.*.b'" +== 012 +-- truncate_limit: 100 +select jsonb '{}' @? '$.*' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb @? '$.*'" +== 013 +-- truncate_limit: 100 +select jsonb '{"a": 1}' @? '$.*' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 1}'::jsonb @? '$.*'" +== 014 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{1}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? 'lax $.**{1}'" +== 015 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{2}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? 'lax $.**{2}'" +== 016 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? 'lax $.**{3}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? 'lax $.**{3}'" +== 017 +-- truncate_limit: 100 +select jsonb '[]' @? '$[*]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb @? '$[*]'" +== 018 +-- truncate_limit: 100 +select jsonb '[1]' @? '$[*]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? '$[*]'" +== 019 +-- truncate_limit: 100 +select jsonb '[1]' @? '$[1]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? '$[1]'" +== 020 +-- truncate_limit: 100 +select jsonb '[1]' @? 'strict $[1]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? 'strict $[1]'" +== 021 +-- truncate_limit: 100 +select jsonb_path_query('[1]', 'strict $[1]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1]', 'strict $[1]')" +== 022 +-- truncate_limit: 100 +select jsonb_path_query('[1]', 'strict $[1]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1]', 'strict $[1]', silent := true)" +== 023 +-- truncate_limit: 100 +select jsonb '[1]' @? 'lax $[10000000000000000]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? 'lax $[10000000000000000]'" +== 024 +-- truncate_limit: 100 +select jsonb '[1]' @? 'strict $[10000000000000000]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? 'strict $[10000000000000000]'" +== 025 +-- truncate_limit: 100 +select jsonb_path_query('[1]', 'lax $[10000000000000000]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1]', 'lax $[10000000000000000]')" +== 026 +-- truncate_limit: 100 +select jsonb_path_query('[1]', 'strict $[10000000000000000]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1]', 'strict $[10000000000000000]')" +== 027 +-- truncate_limit: 100 +select jsonb '[1]' @? '$[0]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? '$[0]'" +== 028 +-- truncate_limit: 100 +select jsonb '[1]' @? '$[0.3]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? '$[0.3]'" +== 029 +-- truncate_limit: 100 +select jsonb '[1]' @? '$[0.5]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? '$[0.5]'" +== 030 +-- truncate_limit: 100 +select jsonb '[1]' @? '$[0.9]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? '$[0.9]'" +== 031 +-- truncate_limit: 100 +select jsonb '[1]' @? '$[1.2]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? '$[1.2]'" +== 032 +-- truncate_limit: 100 +select jsonb '[1]' @? 'strict $[1.2]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1]'::jsonb @? 'strict $[1.2]'" +== 033 +-- truncate_limit: 100 +select jsonb '{"a": [1,2,3], "b": [3,4,5]}' @? '$ ? (@.a[*] > @.b[*])' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [1,2,3], \"b\": [3,4,5]}'::jsonb @? '$ ? (@.a[*] > @.b[*])'" +== 034 +-- truncate_limit: 100 +select jsonb '{"a": [1,2,3], "b": [3,4,5]}' @? '$ ? (@.a[*] >= @.b[*])' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [1,2,3], \"b\": [3,4,5]}'::jsonb @? '$ ? (@.a[*] >= @.b[*])'" +== 035 +-- truncate_limit: 100 +select jsonb '{"a": [1,2,3], "b": [3,4,"5"]}' @? '$ ? (@.a[*] >= @.b[*])' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [1,2,3], \"b\": [3,4,\"5\"]}'::jsonb @? '$ ? (@.a[*] >= @.b[*])'" +== 036 +-- truncate_limit: 100 +select jsonb '{"a": [1,2,3], "b": [3,4,"5"]}' @? 'strict $ ? (@.a[*] >= @.b[*])' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [1,2,3], \"b\": [3,4,\"5\"]}'::jsonb @? 'strict $ ? (@.a[*] >= @.b[*])'" +== 037 +-- truncate_limit: 100 +select jsonb '{"a": [1,2,3], "b": [3,4,null]}' @? '$ ? (@.a[*] >= @.b[*])' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": [1,2,3], \"b\": [3,4,null]}'::jsonb @? '$ ? (@.a[*] >= @.b[*])'" +== 038 +-- truncate_limit: 100 +select jsonb '1' @? '$ ? ((@ == "1") is unknown)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::jsonb @? '$ ? ((@ == \"1\") is unknown)'" +== 039 +-- truncate_limit: 100 +select jsonb '1' @? '$ ? ((@ == 1) is unknown)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::jsonb @? '$ ? ((@ == 1) is unknown)'" +== 040 +-- truncate_limit: 100 +select jsonb '[{"a": 1}, {"a": 2}]' @? '$[0 to 1] ? (@.a > 1)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"a\": 1}, {\"a\": 2}]'::jsonb @? '$[0 to 1] ? (@.a > 1)'" +== 041 +-- truncate_limit: 100 +select jsonb_path_exists('[{"a": 1}, {"a": 2}, 3]', 'lax $[*].a', silent => false) +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_exists('[{\"a\": 1}, {\"a\": 2}, 3]', 'lax $[*].a', silent := false)" +== 042 +-- truncate_limit: 100 +select jsonb_path_exists('[{"a": 1}, {"a": 2}, 3]', 'lax $[*].a', silent => true) +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_exists('[{\"a\": 1}, {\"a\": 2}, 3]', 'lax $[*].a', silent := true)" +== 043 +-- truncate_limit: 100 +select jsonb_path_exists('[{"a": 1}, {"a": 2}, 3]', 'strict $[*].a', silent => false) +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_exists('[{\"a\": 1}, {\"a\": 2}, 3]', 'strict $[*].a', silent := false)" +== 044 +-- truncate_limit: 100 +select jsonb_path_exists('[{"a": 1}, {"a": 2}, 3]', 'strict $[*].a', silent => true) +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_exists('[{\"a\": 1}, {\"a\": 2}, 3]', 'strict $[*].a', silent := true)" +== 045 +-- truncate_limit: 100 +select jsonb_path_query('1', 'lax $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'lax $.a')" +== 046 +-- truncate_limit: 100 +select jsonb_path_query('1', 'strict $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'strict $.a')" +== 047 +-- truncate_limit: 100 +select jsonb_path_query('1', 'strict $.*') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'strict $.*')" +== 048 +-- truncate_limit: 100 +select jsonb_path_query('1', 'strict $.a', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'strict $.a', silent := true)" +== 049 +-- truncate_limit: 100 +select jsonb_path_query('1', 'strict $.*', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'strict $.*', silent := true)" +== 050 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'lax $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'lax $.a')" +== 051 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.a')" +== 052 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.a', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.a', silent := true)" +== 053 +-- truncate_limit: 100 +select jsonb_path_query('{}', 'lax $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', 'lax $.a')" +== 054 +-- truncate_limit: 100 +select jsonb_path_query('{}', 'strict $.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', 'strict $.a')" +== 055 +-- truncate_limit: 100 +select jsonb_path_query('{}', 'strict $.a', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', 'strict $.a', silent := true)" +== 056 +-- truncate_limit: 100 +select jsonb_path_query('1', 'strict $[1]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'strict $[1]')" +== 057 +-- truncate_limit: 100 +select jsonb_path_query('1', 'strict $[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'strict $[*]')" +== 058 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $[1]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $[1]')" +== 059 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $["a"]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $[\"a\"]')" +== 060 +-- truncate_limit: 100 +select jsonb_path_query('1', 'strict $[1]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'strict $[1]', silent := true)" +== 061 +-- truncate_limit: 100 +select jsonb_path_query('1', 'strict $[*]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'strict $[*]', silent := true)" +== 062 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $[1]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $[1]', silent := true)" +== 063 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $["a"]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $[\"a\"]', silent := true)" +== 064 +-- truncate_limit: 100 +select jsonb_path_query('{"a": 12, "b": {"a": 13}}', '$.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": 12, \"b\": {\"a\": 13}}', '$.a')" +== 065 +-- truncate_limit: 100 +select jsonb_path_query('{"a": 12, "b": {"a": 13}}', '$.b') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": 12, \"b\": {\"a\": 13}}', '$.b')" +== 066 +-- truncate_limit: 100 +select jsonb_path_query('{"a": 12, "b": {"a": 13}}', '$.*') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": 12, \"b\": {\"a\": 13}}', '$.*')" +== 067 +-- truncate_limit: 100 +select jsonb_path_query('{"a": 12, "b": {"a": 13}}', 'lax $.*.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": 12, \"b\": {\"a\": 13}}', 'lax $.*.a')" +== 068 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[*].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}]', 'lax $[*].a')" +== 069 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[*].*') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}]', 'lax $[*].*')" +== 070 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[0].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}]', 'lax $[0].a')" +== 071 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[1].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}]', 'lax $[1].a')" +== 072 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[2].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}]', 'lax $[2].a')" +== 073 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[0,1].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}]', 'lax $[0,1].a')" +== 074 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[0 to 10].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}]', 'lax $[0 to 10].a')" +== 075 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}]', 'lax $[0 to 10 / 0].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}]', 'lax $[0 to 10 / 0].a')" +== 076 +-- truncate_limit: 100 +select jsonb_path_query('[12, {"a": 13}, {"b": 14}, "ccc", true]', '$[2.5 - 1 to $.size() - 2]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[12, {\"a\": 13}, {\"b\": 14}, \"ccc\", true]', '$[2.5 - 1 to $.size() - 2]')" +== 077 +-- truncate_limit: 100 +select jsonb_path_query('1', 'lax $[0]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'lax $[0]')" +== 078 +-- truncate_limit: 100 +select jsonb_path_query('1', 'lax $[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', 'lax $[*]')" +== 079 +-- truncate_limit: 100 +select jsonb_path_query('[1]', 'lax $[0]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1]', 'lax $[0]')" +== 080 +-- truncate_limit: 100 +select jsonb_path_query('[1]', 'lax $[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1]', 'lax $[*]')" +== 081 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,3]', 'lax $[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,3]', 'lax $[*]')" +== 082 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,3]', 'strict $[*].a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,3]', 'strict $[*].a')" +== 083 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,3]', 'strict $[*].a', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,3]', 'strict $[*].a', silent := true)" +== 084 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$[last]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$[last]')" +== 085 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$[last ? (exists(last))]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$[last ? (exists(last))]')" +== 086 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $[last]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $[last]')" +== 087 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $[last]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $[last]', silent := true)" +== 088 +-- truncate_limit: 100 +select jsonb_path_query('[1]', '$[last]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1]', '$[last]')" +== 089 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,3]', '$[last]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,3]', '$[last]')" +== 090 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,3]', '$[last - 1]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,3]', '$[last - 1]')" +== 091 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,3]', '$[last ? (@.type() == "number")]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,3]', '$[last ? (@.type() == \"number\")]')" +== 092 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,3]', '$[last ? (@.type() == "string")]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,3]', '$[last ? (@.type() == \"string\")]')" +== 093 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,3]', '$[last ? (@.type() == "string")]', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,3]', '$[last ? (@.type() == \"string\")]', silent := true)" +== 094 +-- truncate_limit: 100 +select * from jsonb_path_query('{"a": 10}', '$') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('{\"a\": 10}', '$')" +== 095 +-- truncate_limit: 100 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('{\"a\": 10}', '$ ? (@.a < $value)')" +== 096 +-- truncate_limit: 100 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)', '1') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('{\"a\": 10}', '$ ? (@.a < $value)', '1')" +== 097 +-- truncate_limit: 100 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)', '[{"value" : 13}]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('{\"a\": 10}', '$ ? (@.a < $value)', '[{\"value\" : 13}]')" +== 098 +-- truncate_limit: 100 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)', '{"value" : 13}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('{\"a\": 10}', '$ ? (@.a < $value)', '{\"value\" : 13}')" +== 099 +-- truncate_limit: 100 +select * from jsonb_path_query('{"a": 10}', '$ ? (@.a < $value)', '{"value" : 8}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('{\"a\": 10}', '$ ? (@.a < $value)', '{\"value\" : 8}')" +== 100 +-- truncate_limit: 100 +select * from jsonb_path_query('{"a": 10}', '$.a ? (@ < $value)', '{"value" : 13}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('{\"a\": 10}', '$.a ? (@ < $value)', '{\"value\" : 13}')" +== 101 +-- truncate_limit: 100 +select * from jsonb_path_query('[10,11,12,13,14,15]', '$[*] ? (@ < $value)', '{"value" : 13}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[10,11,12,13,14,15]', '$[*] ? (@ < $value)', '{\"value\" : 13}')" +== 102 +-- truncate_limit: 100 +select * from jsonb_path_query('[10,11,12,13,14,15]', '$[0,1] ? (@ < $x.value)', '{"x": {"value" : 13}}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[10,11,12,13,14,15]', '$[0,1] ? (@ < $x.value)', '{\"x\": {\"value\" ..." +== 103 +-- truncate_limit: 100 +select * from jsonb_path_query('[10,11,12,13,14,15]', '$[0 to 2] ? (@ < $value)', '{"value" : 15}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[10,11,12,13,14,15]', '$[0 to 2] ? (@ < $value)', '{\"value\" : 15}')" +== 104 +-- truncate_limit: 100 +select * from jsonb_path_query('[1,"1",2,"2",null]', '$[*] ? (@ == "1")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[1,\"1\",2,\"2\",null]', '$[*] ? (@ == \"1\")')" +== 105 +-- truncate_limit: 100 +select * from jsonb_path_query('[1,"1",2,"2",null]', '$[*] ? (@ == $value)', '{"value" : "1"}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[1,\"1\",2,\"2\",null]', '$[*] ? (@ == $value)', '{\"value\" : \"1\"}')" +== 106 +-- truncate_limit: 100 +select * from jsonb_path_query('[1,"1",2,"2",null]', '$[*] ? (@ == $value)', '{"value" : null}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[1,\"1\",2,\"2\",null]', '$[*] ? (@ == $value)', '{\"value\" : null}')" +== 107 +-- truncate_limit: 100 +select * from jsonb_path_query('[1, "2", null]', '$[*] ? (@ != null)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[1, \"2\", null]', '$[*] ? (@ != null)')" +== 108 +-- truncate_limit: 100 +select * from jsonb_path_query('[1, "2", null]', '$[*] ? (@ == null)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[1, \"2\", null]', '$[*] ? (@ == null)')" +== 109 +-- truncate_limit: 100 +select * from jsonb_path_query('{}', '$ ? (@ == @)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('{}', '$ ? (@ == @)')" +== 110 +-- truncate_limit: 100 +select * from jsonb_path_query('[]', 'strict $ ? (@ == @)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM jsonb_path_query('[]', 'strict $ ? (@ == @)')" +== 111 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**')" +== 112 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{0}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{0}')" +== 113 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{0 to last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{0 to last}')" +== 114 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{1}')" +== 115 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1 to last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{1 to last}')" +== 116 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{2}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{2}')" +== 117 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{2 to last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{2 to last}')" +== 118 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{3 to last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{3 to last}')" +== 119 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{last}') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{last}')" +== 120 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**.b ? (@ > 0)')" +== 121 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{0}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{0}.b ? (@ > 0)')" +== 122 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{1}.b ? (@ > 0)')" +== 123 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{0 to last}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{0 to last}.b ? (@ > 0)')" +== 124 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1 to last}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{1 to last}.b ? (@ > 0)')" +== 125 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"b": 1}}', 'lax $.**{1 to 2}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"b\": 1}}', 'lax $.**{1 to 2}.b ? (@ > 0)')" +== 126 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"c\": {\"b\": 1}}}', 'lax $.**.b ? (@ > 0)')" +== 127 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{0}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"c\": {\"b\": 1}}}', 'lax $.**{0}.b ? (@ > 0)')" +== 128 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{1}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"c\": {\"b\": 1}}}', 'lax $.**{1}.b ? (@ > 0)')" +== 129 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{0 to last}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"c\": {\"b\": 1}}}', 'lax $.**{0 to last}.b ? (@ > 0)')" +== 130 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{1 to last}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"c\": {\"b\": 1}}}', 'lax $.**{1 to last}.b ? (@ > 0)')" +== 131 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{1 to 2}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"c\": {\"b\": 1}}}', 'lax $.**{1 to 2}.b ? (@ > 0)')" +== 132 +-- truncate_limit: 100 +select jsonb_path_query('{"a": {"c": {"b": 1}}}', 'lax $.**{2 to 3}.b ? (@ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": {\"c\": {\"b\": 1}}}', 'lax $.**{2 to 3}.b ? (@ > 0)')" +== 133 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? '$.**.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? '$.**.b ? ( @ > 0)'" +== 134 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? '$.**{0}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? '$.**{0}.b ? ( @ > 0)'" +== 135 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? '$.**{1}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? '$.**{1}.b ? ( @ > 0)'" +== 136 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? '$.**{0 to last}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? '$.**{0 to last}.b ? ( @ > 0)'" +== 137 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? '$.**{1 to last}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? '$.**{1 to last}.b ? ( @ > 0)'" +== 138 +-- truncate_limit: 100 +select jsonb '{"a": {"b": 1}}' @? '$.**{1 to 2}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"b\": 1}}'::jsonb @? '$.**{1 to 2}.b ? ( @ > 0)'" +== 139 +-- truncate_limit: 100 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"c\": {\"b\": 1}}}'::jsonb @? '$.**.b ? ( @ > 0)'" +== 140 +-- truncate_limit: 100 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{0}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"c\": {\"b\": 1}}}'::jsonb @? '$.**{0}.b ? ( @ > 0)'" +== 141 +-- truncate_limit: 100 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"c\": {\"b\": 1}}}'::jsonb @? '$.**{1}.b ? ( @ > 0)'" +== 142 +-- truncate_limit: 100 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{0 to last}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"c\": {\"b\": 1}}}'::jsonb @? '$.**{0 to last}.b ? ( @ > 0)'" +== 143 +-- truncate_limit: 100 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1 to last}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"c\": {\"b\": 1}}}'::jsonb @? '$.**{1 to last}.b ? ( @ > 0)'" +== 144 +-- truncate_limit: 100 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{1 to 2}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"c\": {\"b\": 1}}}'::jsonb @? '$.**{1 to 2}.b ? ( @ > 0)'" +== 145 +-- truncate_limit: 100 +select jsonb '{"a": {"c": {"b": 1}}}' @? '$.**{2 to 3}.b ? ( @ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": {\"c\": {\"b\": 1}}}'::jsonb @? '$.**{2 to 3}.b ? ( @ > 0)'" +== 146 +-- truncate_limit: 100 +select jsonb_path_query('{"g": {"x": 2}}', '$.g ? (exists (@.x))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"g\": {\"x\": 2}}', '$.g ? (exists (@.x))')" +== 147 +-- truncate_limit: 100 +select jsonb_path_query('{"g": {"x": 2}}', '$.g ? (exists (@.y))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"g\": {\"x\": 2}}', '$.g ? (exists (@.y))')" +== 148 +-- truncate_limit: 100 +select jsonb_path_query('{"g": {"x": 2}}', '$.g ? (exists (@.x ? (@ >= 2) ))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"g\": {\"x\": 2}}', '$.g ? (exists (@.x ? (@ >= 2) ))')" +== 149 +-- truncate_limit: 100 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'lax $.g ? (exists (@.x))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"g\": [{\"x\": 2}, {\"y\": 3}]}', 'lax $.g ? (exists (@.x))')" +== 150 +-- truncate_limit: 100 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'lax $.g ? (exists (@.x + "3"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"g\": [{\"x\": 2}, {\"y\": 3}]}', 'lax $.g ? (exists (@.x + \"3\"))')" +== 151 +-- truncate_limit: 100 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'lax $.g ? ((exists (@.x + "3")) is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 152 +-- truncate_limit: 100 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'strict $.g[*] ? (exists (@.x))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"g\": [{\"x\": 2}, {\"y\": 3}]}', 'strict $.g[*] ? (exists (@.x))')" +== 153 +-- truncate_limit: 100 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'strict $.g[*] ? ((exists (@.x)) is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 154 +-- truncate_limit: 100 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'strict $.g ? (exists (@[*].x))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"g\": [{\"x\": 2}, {\"y\": 3}]}', 'strict $.g ? (exists (@[*].x))')" +== 155 +-- truncate_limit: 100 +select jsonb_path_query('{"g": [{"x": 2}, {"y": 3}]}', 'strict $.g ? ((exists (@[*].x)) is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 156 +-- truncate_limit: 100 +--test ternary logic +select + x, y, + jsonb_path_query( + '[true, false, null]', + '$[*] ? (@ == true && ($x == true && $y == true) || + @ == false && !($x == true && $y == true) || + @ == null && ($x == true && $y == true) is unknown)', + jsonb_build_object('x', x, 'y', y) + ) as "x && y" +from + (values (jsonb 'true'), ('false'), ('"null"')) x(x), + (values (jsonb 'true'), ('false'), ('"null"')) y(y) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(x), (VALUES (...)) y(y)" +== 157 +-- truncate_limit: 100 +select + x, y, + jsonb_path_query( + '[true, false, null]', + '$[*] ? (@ == true && ($x == true || $y == true) || + @ == false && !($x == true || $y == true) || + @ == null && ($x == true || $y == true) is unknown)', + jsonb_build_object('x', x, 'y', y) + ) as "x || y" +from + (values (jsonb 'true'), ('false'), ('"null"')) x(x), + (values (jsonb 'true'), ('false'), ('"null"')) y(y) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) x(x), (VALUES (...)) y(y)" +== 158 +-- truncate_limit: 100 +select jsonb '{"a": 1, "b":1}' @? '$ ? (@.a == @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 1, \"b\":1}'::jsonb @? '$ ? (@.a == @.b)'" +== 159 +-- truncate_limit: 100 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$ ? (@.a == @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": 1, \"b\":1}}'::jsonb @? '$ ? (@.a == @.b)'" +== 160 +-- truncate_limit: 100 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.c ? (@.a == @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": 1, \"b\":1}}'::jsonb @? '$.c ? (@.a == @.b)'" +== 161 +-- truncate_limit: 100 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.c ? ($.c.a == @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": 1, \"b\":1}}'::jsonb @? '$.c ? ($.c.a == @.b)'" +== 162 +-- truncate_limit: 100 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.* ? (@.a == @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": 1, \"b\":1}}'::jsonb @? '$.* ? (@.a == @.b)'" +== 163 +-- truncate_limit: 100 +select jsonb '{"a": 1, "b":1}' @? '$.** ? (@.a == @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 1, \"b\":1}'::jsonb @? '$.** ? (@.a == @.b)'" +== 164 +-- truncate_limit: 100 +select jsonb '{"c": {"a": 1, "b":1}}' @? '$.** ? (@.a == @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": 1, \"b\":1}}'::jsonb @? '$.** ? (@.a == @.b)'" +== 165 +-- truncate_limit: 100 +select jsonb_path_query('{"c": {"a": 2, "b":1}}', '$.** ? (@.a == 1 + 1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"c\": {\"a\": 2, \"b\":1}}', '$.** ? (@.a == 1 + 1)')" +== 166 +-- truncate_limit: 100 +select jsonb_path_query('{"c": {"a": 2, "b":1}}', '$.** ? (@.a == (1 + 1))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"c\": {\"a\": 2, \"b\":1}}', '$.** ? (@.a == (1 + 1))')" +== 167 +-- truncate_limit: 100 +select jsonb_path_query('{"c": {"a": 2, "b":1}}', '$.** ? (@.a == @.b + 1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"c\": {\"a\": 2, \"b\":1}}', '$.** ? (@.a == @.b + 1)')" +== 168 +-- truncate_limit: 100 +select jsonb_path_query('{"c": {"a": 2, "b":1}}', '$.** ? (@.a == (@.b + 1))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"c\": {\"a\": 2, \"b\":1}}', '$.** ? (@.a == (@.b + 1))')" +== 169 +-- truncate_limit: 100 +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == - 1)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": -1, \"b\":1}}'::jsonb @? '$.** ? (@.a == - 1)'" +== 170 +-- truncate_limit: 100 +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == -1)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": -1, \"b\":1}}'::jsonb @? '$.** ? (@.a == -1)'" +== 171 +-- truncate_limit: 100 +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == -@.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": -1, \"b\":1}}'::jsonb @? '$.** ? (@.a == -@.b)'" +== 172 +-- truncate_limit: 100 +select jsonb '{"c": {"a": -1, "b":1}}' @? '$.** ? (@.a == - @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": -1, \"b\":1}}'::jsonb @? '$.** ? (@.a == - @.b)'" +== 173 +-- truncate_limit: 100 +select jsonb '{"c": {"a": 0, "b":1}}' @? '$.** ? (@.a == 1 - @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": 0, \"b\":1}}'::jsonb @? '$.** ? (@.a == 1 - @.b)'" +== 174 +-- truncate_limit: 100 +select jsonb '{"c": {"a": 2, "b":1}}' @? '$.** ? (@.a == 1 - - @.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": 2, \"b\":1}}'::jsonb @? '$.** ? (@.a == 1 - - @.b)'" +== 175 +-- truncate_limit: 100 +select jsonb '{"c": {"a": 0, "b":1}}' @? '$.** ? (@.a == 1 - +@.b)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"c\": {\"a\": 0, \"b\":1}}'::jsonb @? '$.** ? (@.a == 1 - +@.b)'" +== 176 +-- truncate_limit: 100 +select jsonb '[1,2,3]' @? '$ ? (+@[*] > +2)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::jsonb @? '$ ? (+@[*] > +2)'" +== 177 +-- truncate_limit: 100 +select jsonb '[1,2,3]' @? '$ ? (+@[*] > +3)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::jsonb @? '$ ? (+@[*] > +3)'" +== 178 +-- truncate_limit: 100 +select jsonb '[1,2,3]' @? '$ ? (-@[*] < -2)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::jsonb @? '$ ? (-@[*] < -2)'" +== 179 +-- truncate_limit: 100 +select jsonb '[1,2,3]' @? '$ ? (-@[*] < -3)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::jsonb @? '$ ? (-@[*] < -3)'" +== 180 +-- truncate_limit: 100 +select jsonb '1' @? '$ ? ($ > 0)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::jsonb @? '$ ? ($ > 0)'" +== 181 +-- truncate_limit: 100 +-- arithmetic errors +select jsonb_path_query('[1,2,0,3]', '$[*] ? (2 / @ > 0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,0,3]', '$[*] ? (2 / @ > 0)')" +== 182 +-- truncate_limit: 100 +select jsonb_path_query('[1,2,0,3]', '$[*] ? ((2 / @ > 0) is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,2,0,3]', '$[*] ? ((2 / @ > 0) is unknown)')" +== 183 +-- truncate_limit: 100 +select jsonb_path_query('0', '1 / $') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('0', '1 / $')" +== 184 +-- truncate_limit: 100 +select jsonb_path_query('0', '1 / $ + 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('0', '1 / $ + 2')" +== 185 +-- truncate_limit: 100 +select jsonb_path_query('0', '-(3 + 1 % $)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('0', '-(3 + 1 % $)')" +== 186 +-- truncate_limit: 100 +select jsonb_path_query('1', '$ + "2"') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$ + \"2\"')" +== 187 +-- truncate_limit: 100 +select jsonb_path_query('[1, 2]', '3 * $') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1, 2]', '3 * $')" +== 188 +-- truncate_limit: 100 +select jsonb_path_query('"a"', '-$') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"a\"', '-$')" +== 189 +-- truncate_limit: 100 +select jsonb_path_query('[1,"2",3]', '+$') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,\"2\",3]', '+$')" +== 190 +-- truncate_limit: 100 +select jsonb_path_query('1', '$ + "2"', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$ + \"2\"', silent := true)" +== 191 +-- truncate_limit: 100 +select jsonb_path_query('[1, 2]', '3 * $', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1, 2]', '3 * $', silent := true)" +== 192 +-- truncate_limit: 100 +select jsonb_path_query('"a"', '-$', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"a\"', '-$', silent := true)" +== 193 +-- truncate_limit: 100 +select jsonb_path_query('[1,"2",3]', '+$', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,\"2\",3]', '+$', silent := true)" +== 194 +-- truncate_limit: 100 +select jsonb '["1",2,0,3]' @? '-$[*]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"1\",2,0,3]'::jsonb @? '-$[*]'" +== 195 +-- truncate_limit: 100 +select jsonb '[1,"2",0,3]' @? '-$[*]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,\"2\",0,3]'::jsonb @? '-$[*]'" +== 196 +-- truncate_limit: 100 +select jsonb '["1",2,0,3]' @? 'strict -$[*]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"1\",2,0,3]'::jsonb @? 'strict -$[*]'" +== 197 +-- truncate_limit: 100 +select jsonb '[1,"2",0,3]' @? 'strict -$[*]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,\"2\",0,3]'::jsonb @? 'strict -$[*]'" +== 198 +-- truncate_limit: 100 +-- unwrapping of operator arguments in lax mode +select jsonb_path_query('{"a": [2]}', 'lax $.a * 3') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": [2]}', 'lax $.a * 3')" +== 199 +-- truncate_limit: 100 +select jsonb_path_query('{"a": [2]}', 'lax $.a + 3') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": [2]}', 'lax $.a + 3')" +== 200 +-- truncate_limit: 100 +select jsonb_path_query('{"a": [2, 3, 4]}', 'lax -$.a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": [2, 3, 4]}', 'lax -$.a')" +== 201 +-- truncate_limit: 100 +-- should fail +select jsonb_path_query('{"a": [1, 2]}', 'lax $.a * 3') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": [1, 2]}', 'lax $.a * 3')" +== 202 +-- truncate_limit: 100 +select jsonb_path_query('{"a": [1, 2]}', 'lax $.a * 3', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": [1, 2]}', 'lax $.a * 3', silent := true)" +== 203 +-- truncate_limit: 100 +-- extension: boolean expressions +select jsonb_path_query('2', '$ > 1') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('2', '$ > 1')" +== 204 +-- truncate_limit: 100 +select jsonb_path_query('2', '$ <= 1') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('2', '$ <= 1')" +== 205 +-- truncate_limit: 100 +select jsonb_path_query('2', '$ == "2"') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('2', '$ == \"2\"')" +== 206 +-- truncate_limit: 100 +select jsonb '2' @? '$ == "2"' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2'::jsonb @? '$ == \"2\"'" +== 207 +-- truncate_limit: 100 +select jsonb '2' @@ '$ > 1' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2'::jsonb @@ '$ > 1'" +== 208 +-- truncate_limit: 100 +select jsonb '2' @@ '$ <= 1' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2'::jsonb @@ '$ <= 1'" +== 209 +-- truncate_limit: 100 +select jsonb '2' @@ '$ == "2"' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2'::jsonb @@ '$ == \"2\"'" +== 210 +-- truncate_limit: 100 +select jsonb '2' @@ '1' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2'::jsonb @@ '1'" +== 211 +-- truncate_limit: 100 +select jsonb '{}' @@ '$' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::jsonb @@ '$'" +== 212 +-- truncate_limit: 100 +select jsonb '[]' @@ '$' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb @@ '$'" +== 213 +-- truncate_limit: 100 +select jsonb '[1,2,3]' @@ '$[*]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[1,2,3]'::jsonb @@ '$[*]'" +== 214 +-- truncate_limit: 100 +select jsonb '[]' @@ '$[*]' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::jsonb @@ '$[*]'" +== 215 +-- truncate_limit: 100 +select jsonb_path_match('[[1, true], [2, false]]', 'strict $[*] ? (@[0] > $x) [1]', '{"x": 1}') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[[1, true], [2, false]]', 'strict $[*] ? (@[0] > $x) [1]', '{\"x\": 1}')" +== 216 +-- truncate_limit: 100 +select jsonb_path_match('[[1, true], [2, false]]', 'strict $[*] ? (@[0] < $x) [1]', '{"x": 2}') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[[1, true], [2, false]]', 'strict $[*] ? (@[0] < $x) [1]', '{\"x\": 2}')" +== 217 +-- truncate_limit: 100 +select jsonb_path_match('[{"a": 1}, {"a": 2}, 3]', 'lax exists($[*].a)', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[{\"a\": 1}, {\"a\": 2}, 3]', 'lax exists($[*].a)', silent := false)" +== 218 +-- truncate_limit: 100 +select jsonb_path_match('[{"a": 1}, {"a": 2}, 3]', 'lax exists($[*].a)', silent => true) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[{\"a\": 1}, {\"a\": 2}, 3]', 'lax exists($[*].a)', silent := true)" +== 219 +-- truncate_limit: 100 +select jsonb_path_match('[{"a": 1}, {"a": 2}, 3]', 'strict exists($[*].a)', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[{\"a\": 1}, {\"a\": 2}, 3]', 'strict exists($[*].a)', silent := false)" +== 220 +-- truncate_limit: 100 +select jsonb_path_match('[{"a": 1}, {"a": 2}, 3]', 'strict exists($[*].a)', silent => true) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[{\"a\": 1}, {\"a\": 2}, 3]', 'strict exists($[*].a)', silent := true)" +== 221 +-- truncate_limit: 100 +select jsonb_path_query('[null,1,true,"a",[],{}]', '$.type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[null,1,true,\"a\",[],{}]', '$.type()')" +== 222 +-- truncate_limit: 100 +select jsonb_path_query('[null,1,true,"a",[],{}]', 'lax $.type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[null,1,true,\"a\",[],{}]', 'lax $.type()')" +== 223 +-- truncate_limit: 100 +select jsonb_path_query('[null,1,true,"a",[],{}]', '$[*].type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[null,1,true,\"a\",[],{}]', '$[*].type()')" +== 224 +-- truncate_limit: 100 +select jsonb_path_query('null', 'null.type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', 'null.type()')" +== 225 +-- truncate_limit: 100 +select jsonb_path_query('null', 'true.type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', 'true.type()')" +== 226 +-- truncate_limit: 100 +select jsonb_path_query('null', '(123).type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '(123).type()')" +== 227 +-- truncate_limit: 100 +select jsonb_path_query('null', '"123".type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '\"123\".type()')" +== 228 +-- truncate_limit: 100 +select jsonb_path_query('{"a": 2}', '($.a - 5).abs() + 10') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": 2}', '($.a - 5).abs() + 10')" +== 229 +-- truncate_limit: 100 +select jsonb_path_query('{"a": 2.5}', '-($.a * $.a).floor() % 4.3') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": 2.5}', '-($.a * $.a).floor() % 4.3')" +== 230 +-- truncate_limit: 100 +select jsonb_path_query('[1, 2, 3]', '($[*] > 2) ? (@ == true)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1, 2, 3]', '($[*] > 2) ? (@ == true)')" +== 231 +-- truncate_limit: 100 +select jsonb_path_query('[1, 2, 3]', '($[*] > 3).type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1, 2, 3]', '($[*] > 3).type()')" +== 232 +-- truncate_limit: 100 +select jsonb_path_query('[1, 2, 3]', '($[*].a > 3).type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1, 2, 3]', '($[*].a > 3).type()')" +== 233 +-- truncate_limit: 100 +select jsonb_path_query('[1, 2, 3]', 'strict ($[*].a > 3).type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1, 2, 3]', 'strict ($[*].a > 3).type()')" +== 234 +-- truncate_limit: 100 +select jsonb_path_query('[1,null,true,"11",[],[1],[1,2,3],{},{"a":1,"b":2}]', 'strict $[*].size()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,null,true,\"11\",[],[1],[1,2,3],{},{\"a\":1,\"b\":2}]', 'strict $[*].size()')" +== 235 +-- truncate_limit: 100 +select jsonb_path_query('[1,null,true,"11",[],[1],[1,2,3],{},{"a":1,"b":2}]', 'strict $[*].size()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 236 +-- truncate_limit: 100 +select jsonb_path_query('[1,null,true,"11",[],[1],[1,2,3],{},{"a":1,"b":2}]', 'lax $[*].size()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[1,null,true,\"11\",[],[1],[1,2,3],{},{\"a\":1,\"b\":2}]', 'lax $[*].size()')" +== 237 +-- truncate_limit: 100 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].abs()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].abs()')" +== 238 +-- truncate_limit: 100 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].floor()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].floor()')" +== 239 +-- truncate_limit: 100 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling()')" +== 240 +-- truncate_limit: 100 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling().abs()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling().abs()')" +== 241 +-- truncate_limit: 100 +select jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling().abs().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[0, 1, -2, -3.4, 5.6]', '$[*].ceiling().abs().type()')" +== 242 +-- truncate_limit: 100 +select jsonb_path_query('[{},1]', '$[*].keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{},1]', '$[*].keyvalue()')" +== 243 +-- truncate_limit: 100 +select jsonb_path_query('[{},1]', '$[*].keyvalue()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{},1]', '$[*].keyvalue()', silent := true)" +== 244 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.keyvalue()')" +== 245 +-- truncate_limit: 100 +select jsonb_path_query('{"a": 1, "b": [1, 2], "c": {"a": "bbb"}}', '$.keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{\"a\": 1, \"b\": [1, 2], \"c\": {\"a\": \"bbb\"}}', '$.keyvalue()')" +== 246 +-- truncate_limit: 100 +select jsonb_path_query('[{"a": 1, "b": [1, 2]}, {"c": {"a": "bbb"}}]', '$[*].keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{\"a\": 1, \"b\": [1, 2]}, {\"c\": {\"a\": \"bbb\"}}]', '$[*].keyvalue()')" +== 247 +-- truncate_limit: 100 +select jsonb_path_query('[{"a": 1, "b": [1, 2]}, {"c": {"a": "bbb"}}]', 'strict $.keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{\"a\": 1, \"b\": [1, 2]}, {\"c\": {\"a\": \"bbb\"}}]', 'strict $.keyvalue()')" +== 248 +-- truncate_limit: 100 +select jsonb_path_query('[{"a": 1, "b": [1, 2]}, {"c": {"a": "bbb"}}]', 'lax $.keyvalue()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{\"a\": 1, \"b\": [1, 2]}, {\"c\": {\"a\": \"bbb\"}}]', 'lax $.keyvalue()')" +== 249 +-- truncate_limit: 100 +select jsonb_path_query('[{"a": 1, "b": [1, 2]}, {"c": {"a": "bbb"}}]', 'strict $.keyvalue().a') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{\"a\": 1, \"b\": [1, 2]}, {\"c\": {\"a\": \"bbb\"}}]', 'strict $.keyvalue().a')" +== 250 +-- truncate_limit: 100 +select jsonb '{"a": 1, "b": [1, 2]}' @? 'lax $.keyvalue()' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 1, \"b\": [1, 2]}'::jsonb @? 'lax $.keyvalue()'" +== 251 +-- truncate_limit: 100 +select jsonb '{"a": 1, "b": [1, 2]}' @? 'lax $.keyvalue().key' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{\"a\": 1, \"b\": [1, 2]}'::jsonb @? 'lax $.keyvalue().key'" +== 252 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.double()')" +== 253 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.double()')" +== 254 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.double()', silent := true)" +== 255 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.double()', silent := true)" +== 256 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.double()')" +== 257 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.double()')" +== 258 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.double()')" +== 259 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.double()', silent := true)" +== 260 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.double()', silent := true)" +== 261 +-- truncate_limit: 100 +select jsonb_path_query('1.23', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.23', '$.double()')" +== 262 +-- truncate_limit: 100 +select jsonb_path_query('"1.23"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23\"', '$.double()')" +== 263 +-- truncate_limit: 100 +select jsonb_path_query('"1.23aaa"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23aaa\"', '$.double()')" +== 264 +-- truncate_limit: 100 +select jsonb_path_query('1e1000', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1e1000', '$.double()')" +== 265 +-- truncate_limit: 100 +select jsonb_path_query('"nan"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"nan\"', '$.double()')" +== 266 +-- truncate_limit: 100 +select jsonb_path_query('"NaN"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"NaN\"', '$.double()')" +== 267 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.double()')" +== 268 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.double()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.double()')" +== 269 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.double()', silent := true)" +== 270 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.double()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.double()', silent := true)" +== 271 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.abs()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.abs()')" +== 272 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.floor()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.floor()')" +== 273 +-- truncate_limit: 100 +select jsonb_path_query('"1.2"', '$.ceiling()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.2\"', '$.ceiling()')" +== 274 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.abs()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.abs()', silent := true)" +== 275 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.floor()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.floor()', silent := true)" +== 276 +-- truncate_limit: 100 +select jsonb_path_query('"1.2"', '$.ceiling()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.2\"', '$.ceiling()', silent := true)" +== 277 +-- truncate_limit: 100 +select jsonb_path_query('["", "a", "abc", "abcabc"]', '$[*] ? (@ starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[\"\", \"a\", \"abc\", \"abcabc\"]', '$[*] ? (@ starts with \"abc\")')" +== 278 +-- truncate_limit: 100 +select jsonb_path_query('["", "a", "abc", "abcabc"]', 'strict $ ? (@[*] starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[\"\", \"a\", \"abc\", \"abcabc\"]', 'strict $ ? (@[*] starts with \"abc\")')" +== 279 +-- truncate_limit: 100 +select jsonb_path_query('["", "a", "abd", "abdabc"]', 'strict $ ? (@[*] starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[\"\", \"a\", \"abd\", \"abdabc\"]', 'strict $ ? (@[*] starts with \"abc\")')" +== 280 +-- truncate_limit: 100 +select jsonb_path_query('["abc", "abcabc", null, 1]', 'strict $ ? (@[*] starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[\"abc\", \"abcabc\", null, 1]', 'strict $ ? (@[*] starts with \"abc\")')" +== 281 +-- truncate_limit: 100 +select jsonb_path_query('["abc", "abcabc", null, 1]', 'strict $ ? ((@[*] starts with "abc") is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 282 +-- truncate_limit: 100 +select jsonb_path_query('[[null, 1, "abc", "abcabc"]]', 'lax $ ? (@[*] starts with "abc")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[[null, 1, \"abc\", \"abcabc\"]]', 'lax $ ? (@[*] starts with \"abc\")')" +== 283 +-- truncate_limit: 100 +select jsonb_path_query('[[null, 1, "abd", "abdabc"]]', 'lax $ ? ((@[*] starts with "abc") is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 284 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "abd", "abdabc"]', 'lax $[*] ? ((@ starts with "abc") is unknown)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 285 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "abc", "abd", "aBdC", "abdacb", "babc", "adc\nabc", "ab\nadc"]', 'lax $[*] ? (@ like_regex "^ab.*c")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 286 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "abc", "abd", "aBdC", "abdacb", "babc", "adc\nabc", "ab\nadc"]', 'lax $[*] ? (@ like_regex "^ab.*c" flag "i")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 287 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "abc", "abd", "aBdC", "abdacb", "babc", "adc\nabc", "ab\nadc"]', 'lax $[*] ? (@ like_regex "^ab.*c" flag "m")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 288 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "abc", "abd", "aBdC", "abdacb", "babc", "adc\nabc", "ab\nadc"]', 'lax $[*] ? (@ like_regex "^ab.*c" flag "s")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 289 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "a\\b" flag "q")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 290 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "a\\b" flag "")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 291 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "^a\\b$" flag "q")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 292 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "^a\\B$" flag "q")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 293 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "^a\\B$" flag "iq")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 294 +-- truncate_limit: 100 +select jsonb_path_query('[null, 1, "a\b", "a\\b", "^a\\b$"]', 'lax $[*] ? (@ like_regex "^a\\b$" flag "")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 295 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.datetime()')" +== 296 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.datetime()')" +== 297 +-- truncate_limit: 100 +select jsonb_path_query('1', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$.datetime()')" +== 298 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.datetime()')" +== 299 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.datetime()')" +== 300 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.datetime()')" +== 301 +-- truncate_limit: 100 +select jsonb_path_query('"bogus"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"bogus\"', '$.datetime()')" +== 302 +-- truncate_limit: 100 +select jsonb_path_query('"12:34"', '$.datetime("aaa")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34\"', '$.datetime(\"aaa\")')" +== 303 +-- truncate_limit: 100 +select jsonb_path_query('"aaaa"', '$.datetime("HH24")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"aaaa\"', '$.datetime(\"HH24\")')" +== 304 +-- truncate_limit: 100 +select jsonb '"10-03-2017"' @? '$.datetime("dd-mm-yyyy")' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"10-03-2017\"'::jsonb @? '$.datetime(\"dd-mm-yyyy\")'" +== 305 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017"', '$.datetime("dd-mm-yyyy")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017\"', '$.datetime(\"dd-mm-yyyy\")')" +== 306 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017"', '$.datetime("dd-mm-yyyy").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017\"', '$.datetime(\"dd-mm-yyyy\").type()')" +== 307 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34\"', '$.datetime(\"dd-mm-yyyy\")')" +== 308 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34\"', '$.datetime(\"dd-mm-yyyy\").type()')" +== 309 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34"', ' $.datetime("dd-mm-yyyy HH24:MI").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34\"', ' $.datetime(\"dd-mm-yyyy HH24:MI\").type()')" +== 310 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 +05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 311 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.datetime("HH24:MI:SS").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.datetime(\"HH24:MI:SS\").type()')" +== 312 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56 +05:20"', '$.datetime("HH24:MI:SS TZH:TZM").type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56 +05:20\"', '$.datetime(\"HH24:MI:SS TZH:TZM\").type()')" +== 313 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017T12:34:56"', '$.datetime("dd-mm-yyyy\"T\"HH24:MI:SS")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017T12:34:56\"', E'$.datetime(\"dd-mm-yyyy\\\\\"T\\\\\"HH24:MI:SS\")')" +== 314 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017t12:34:56"', '$.datetime("dd-mm-yyyy\"T\"HH24:MI:SS")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017t12:34:56\"', E'$.datetime(\"dd-mm-yyyy\\\\\"T\\\\\"HH24:MI:SS\")')" +== 315 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34:56"', '$.datetime("dd-mm-yyyy\"T\"HH24:MI:SS")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34:56\"', E'$.datetime(\"dd-mm-yyyy\\\\\"T\\\\\"HH24:MI:SS\")')" +== 316 +-- truncate_limit: 100 +-- Test .bigint() +select jsonb_path_query('null', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.bigint()')" +== 317 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.bigint()')" +== 318 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.bigint()', silent := true)" +== 319 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.bigint()', silent := true)" +== 320 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.bigint()')" +== 321 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.bigint()')" +== 322 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.bigint()')" +== 323 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.bigint()', silent := true)" +== 324 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.bigint()', silent := true)" +== 325 +-- truncate_limit: 100 +select jsonb_path_query('"1.23"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23\"', '$.bigint()')" +== 326 +-- truncate_limit: 100 +select jsonb_path_query('"1.23aaa"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23aaa\"', '$.bigint()')" +== 327 +-- truncate_limit: 100 +select jsonb_path_query('1e1000', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1e1000', '$.bigint()')" +== 328 +-- truncate_limit: 100 +select jsonb_path_query('"nan"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"nan\"', '$.bigint()')" +== 329 +-- truncate_limit: 100 +select jsonb_path_query('"NaN"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"NaN\"', '$.bigint()')" +== 330 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.bigint()')" +== 331 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.bigint()')" +== 332 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.bigint()', silent := true)" +== 333 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.bigint()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.bigint()', silent := true)" +== 334 +-- truncate_limit: 100 +select jsonb_path_query('123', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('123', '$.bigint()')" +== 335 +-- truncate_limit: 100 +select jsonb_path_query('"123"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"123\"', '$.bigint()')" +== 336 +-- truncate_limit: 100 +select jsonb_path_query('1.23', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.23', '$.bigint()')" +== 337 +-- truncate_limit: 100 +select jsonb_path_query('1.83', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.83', '$.bigint()')" +== 338 +-- truncate_limit: 100 +select jsonb_path_query('1234567890123', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234567890123', '$.bigint()')" +== 339 +-- truncate_limit: 100 +select jsonb_path_query('"1234567890123"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1234567890123\"', '$.bigint()')" +== 340 +-- truncate_limit: 100 +select jsonb_path_query('12345678901234567890', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345678901234567890', '$.bigint()')" +== 341 +-- truncate_limit: 100 +select jsonb_path_query('"12345678901234567890"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12345678901234567890\"', '$.bigint()')" +== 342 +-- truncate_limit: 100 +select jsonb_path_query('"+123"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"+123\"', '$.bigint()')" +== 343 +-- truncate_limit: 100 +select jsonb_path_query('-123', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('-123', '$.bigint()')" +== 344 +-- truncate_limit: 100 +select jsonb_path_query('"-123"', '$.bigint()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-123\"', '$.bigint()')" +== 345 +-- truncate_limit: 100 +select jsonb_path_query('123', '$.bigint() * 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('123', '$.bigint() * 2')" +== 346 +-- truncate_limit: 100 +-- Test .boolean() +select jsonb_path_query('null', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.boolean()')" +== 347 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.boolean()', silent := true)" +== 348 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.boolean()')" +== 349 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.boolean()')" +== 350 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.boolean()')" +== 351 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.boolean()', silent := true)" +== 352 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.boolean()', silent := true)" +== 353 +-- truncate_limit: 100 +select jsonb_path_query('1.23', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.23', '$.boolean()')" +== 354 +-- truncate_limit: 100 +select jsonb_path_query('"1.23"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23\"', '$.boolean()')" +== 355 +-- truncate_limit: 100 +select jsonb_path_query('"1.23aaa"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23aaa\"', '$.boolean()')" +== 356 +-- truncate_limit: 100 +select jsonb_path_query('1e1000', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1e1000', '$.boolean()')" +== 357 +-- truncate_limit: 100 +select jsonb_path_query('"nan"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"nan\"', '$.boolean()')" +== 358 +-- truncate_limit: 100 +select jsonb_path_query('"NaN"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"NaN\"', '$.boolean()')" +== 359 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.boolean()')" +== 360 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.boolean()')" +== 361 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.boolean()', silent := true)" +== 362 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.boolean()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.boolean()', silent := true)" +== 363 +-- truncate_limit: 100 +select jsonb_path_query('"100"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"100\"', '$.boolean()')" +== 364 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.boolean()')" +== 365 +-- truncate_limit: 100 +select jsonb_path_query('false', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('false', '$.boolean()')" +== 366 +-- truncate_limit: 100 +select jsonb_path_query('1', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$.boolean()')" +== 367 +-- truncate_limit: 100 +select jsonb_path_query('0', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('0', '$.boolean()')" +== 368 +-- truncate_limit: 100 +select jsonb_path_query('-1', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('-1', '$.boolean()')" +== 369 +-- truncate_limit: 100 +select jsonb_path_query('100', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('100', '$.boolean()')" +== 370 +-- truncate_limit: 100 +select jsonb_path_query('"1"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1\"', '$.boolean()')" +== 371 +-- truncate_limit: 100 +select jsonb_path_query('"0"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"0\"', '$.boolean()')" +== 372 +-- truncate_limit: 100 +select jsonb_path_query('"true"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"true\"', '$.boolean()')" +== 373 +-- truncate_limit: 100 +select jsonb_path_query('"false"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"false\"', '$.boolean()')" +== 374 +-- truncate_limit: 100 +select jsonb_path_query('"TRUE"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"TRUE\"', '$.boolean()')" +== 375 +-- truncate_limit: 100 +select jsonb_path_query('"FALSE"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"FALSE\"', '$.boolean()')" +== 376 +-- truncate_limit: 100 +select jsonb_path_query('"yes"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"yes\"', '$.boolean()')" +== 377 +-- truncate_limit: 100 +select jsonb_path_query('"NO"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"NO\"', '$.boolean()')" +== 378 +-- truncate_limit: 100 +select jsonb_path_query('"T"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"T\"', '$.boolean()')" +== 379 +-- truncate_limit: 100 +select jsonb_path_query('"f"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"f\"', '$.boolean()')" +== 380 +-- truncate_limit: 100 +select jsonb_path_query('"y"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"y\"', '$.boolean()')" +== 381 +-- truncate_limit: 100 +select jsonb_path_query('"N"', '$.boolean()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"N\"', '$.boolean()')" +== 382 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.boolean().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.boolean().type()')" +== 383 +-- truncate_limit: 100 +select jsonb_path_query('123', '$.boolean().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('123', '$.boolean().type()')" +== 384 +-- truncate_limit: 100 +select jsonb_path_query('"Yes"', '$.boolean().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"Yes\"', '$.boolean().type()')" +== 385 +-- truncate_limit: 100 +select jsonb_path_query_array('[1, "yes", false]', '$[*].boolean()') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_array('[1, \"yes\", false]', '$[*].boolean()')" +== 386 +-- truncate_limit: 100 +-- Test .date() +select jsonb_path_query('null', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.date()')" +== 387 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.date()')" +== 388 +-- truncate_limit: 100 +select jsonb_path_query('1', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$.date()')" +== 389 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.date()')" +== 390 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.date()')" +== 391 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.date()')" +== 392 +-- truncate_limit: 100 +select jsonb_path_query('"bogus"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"bogus\"', '$.date()')" +== 393 +-- truncate_limit: 100 +select jsonb '"2023-08-15"' @? '$.date()' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"2023-08-15\"'::jsonb @? '$.date()'" +== 394 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15\"', '$.date()')" +== 395 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15"', '$.date().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15\"', '$.date().type()')" +== 396 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.date()')" +== 397 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56 +05:30"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56 +05:30\"', '$.date()')" +== 398 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.date()')" +== 399 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.date()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.date()')" +== 400 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.date()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56 +05:30\"', '$.date()')" +== 401 +-- truncate_limit: 100 +-- should work + +select jsonb_path_query('"2023-08-15"', '$.date(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15\"', '$.date(2)')" +== 402 +-- truncate_limit: 100 +-- Test .decimal() +select jsonb_path_query('null', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.decimal()')" +== 403 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.decimal()')" +== 404 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.decimal()', silent := true)" +== 405 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.decimal()', silent := true)" +== 406 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.decimal()')" +== 407 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.decimal()')" +== 408 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.decimal()')" +== 409 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.decimal()', silent := true)" +== 410 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.decimal()', silent := true)" +== 411 +-- truncate_limit: 100 +select jsonb_path_query('1.23', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.23', '$.decimal()')" +== 412 +-- truncate_limit: 100 +select jsonb_path_query('"1.23"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23\"', '$.decimal()')" +== 413 +-- truncate_limit: 100 +select jsonb_path_query('"1.23aaa"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23aaa\"', '$.decimal()')" +== 414 +-- truncate_limit: 100 +select jsonb_path_query('1e1000', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1e1000', '$.decimal()')" +== 415 +-- truncate_limit: 100 +select jsonb_path_query('"nan"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"nan\"', '$.decimal()')" +== 416 +-- truncate_limit: 100 +select jsonb_path_query('"NaN"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"NaN\"', '$.decimal()')" +== 417 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.decimal()')" +== 418 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.decimal()')" +== 419 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.decimal()', silent := true)" +== 420 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.decimal()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.decimal()', silent := true)" +== 421 +-- truncate_limit: 100 +select jsonb_path_query('123', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('123', '$.decimal()')" +== 422 +-- truncate_limit: 100 +select jsonb_path_query('"123"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"123\"', '$.decimal()')" +== 423 +-- truncate_limit: 100 +select jsonb_path_query('12345678901234567890', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345678901234567890', '$.decimal()')" +== 424 +-- truncate_limit: 100 +select jsonb_path_query('"12345678901234567890"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12345678901234567890\"', '$.decimal()')" +== 425 +-- truncate_limit: 100 +select jsonb_path_query('"+12.3"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"+12.3\"', '$.decimal()')" +== 426 +-- truncate_limit: 100 +select jsonb_path_query('-12.3', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('-12.3', '$.decimal()')" +== 427 +-- truncate_limit: 100 +select jsonb_path_query('"-12.3"', '$.decimal()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-12.3\"', '$.decimal()')" +== 428 +-- truncate_limit: 100 +select jsonb_path_query('12.3', '$.decimal() * 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12.3', '$.decimal() * 2')" +== 429 +-- truncate_limit: 100 +select jsonb_path_query('12345.678', '$.decimal(6, 1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345.678', '$.decimal(6, 1)')" +== 430 +-- truncate_limit: 100 +select jsonb_path_query('12345.678', '$.decimal(6, 2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345.678', '$.decimal(6, 2)')" +== 431 +-- truncate_limit: 100 +select jsonb_path_query('1234.5678', '$.decimal(6, 2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234.5678', '$.decimal(6, 2)')" +== 432 +-- truncate_limit: 100 +select jsonb_path_query('12345.678', '$.decimal(4, 6)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345.678', '$.decimal(4, 6)')" +== 433 +-- truncate_limit: 100 +select jsonb_path_query('12345.678', '$.decimal(0, 6)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345.678', '$.decimal(0, 6)')" +== 434 +-- truncate_limit: 100 +select jsonb_path_query('12345.678', '$.decimal(1001, 6)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345.678', '$.decimal(1001, 6)')" +== 435 +-- truncate_limit: 100 +select jsonb_path_query('1234.5678', '$.decimal(+6, +2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234.5678', '$.decimal(+6, +2)')" +== 436 +-- truncate_limit: 100 +select jsonb_path_query('1234.5678', '$.decimal(+6, -2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234.5678', '$.decimal(+6, -2)')" +== 437 +-- truncate_limit: 100 +select jsonb_path_query('1234.5678', '$.decimal(-6, +2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234.5678', '$.decimal(-6, +2)')" +== 438 +-- truncate_limit: 100 +select jsonb_path_query('1234.5678', '$.decimal(6, -1001)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234.5678', '$.decimal(6, -1001)')" +== 439 +-- truncate_limit: 100 +select jsonb_path_query('1234.5678', '$.decimal(6, 1001)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234.5678', '$.decimal(6, 1001)')" +== 440 +-- truncate_limit: 100 +select jsonb_path_query('-1234.5678', '$.decimal(+6, -2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('-1234.5678', '$.decimal(+6, -2)')" +== 441 +-- truncate_limit: 100 +select jsonb_path_query('0.0123456', '$.decimal(1,2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('0.0123456', '$.decimal(1,2)')" +== 442 +-- truncate_limit: 100 +select jsonb_path_query('0.0012345', '$.decimal(2,4)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('0.0012345', '$.decimal(2,4)')" +== 443 +-- truncate_limit: 100 +select jsonb_path_query('-0.00123456', '$.decimal(2,-4)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('-0.00123456', '$.decimal(2,-4)')" +== 444 +-- truncate_limit: 100 +select jsonb_path_query('12.3', '$.decimal(12345678901,1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12.3', '$.decimal(12345678901,1)')" +== 445 +-- truncate_limit: 100 +select jsonb_path_query('12.3', '$.decimal(1,12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12.3', '$.decimal(1,12345678901)')" +== 446 +-- truncate_limit: 100 +-- Test .integer() +select jsonb_path_query('null', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.integer()')" +== 447 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.integer()')" +== 448 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.integer()', silent := true)" +== 449 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.integer()', silent := true)" +== 450 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.integer()')" +== 451 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.integer()')" +== 452 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.integer()')" +== 453 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.integer()', silent := true)" +== 454 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.integer()', silent := true)" +== 455 +-- truncate_limit: 100 +select jsonb_path_query('"1.23"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23\"', '$.integer()')" +== 456 +-- truncate_limit: 100 +select jsonb_path_query('"1.23aaa"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23aaa\"', '$.integer()')" +== 457 +-- truncate_limit: 100 +select jsonb_path_query('1e1000', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1e1000', '$.integer()')" +== 458 +-- truncate_limit: 100 +select jsonb_path_query('"nan"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"nan\"', '$.integer()')" +== 459 +-- truncate_limit: 100 +select jsonb_path_query('"NaN"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"NaN\"', '$.integer()')" +== 460 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.integer()')" +== 461 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.integer()')" +== 462 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.integer()', silent := true)" +== 463 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.integer()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.integer()', silent := true)" +== 464 +-- truncate_limit: 100 +select jsonb_path_query('123', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('123', '$.integer()')" +== 465 +-- truncate_limit: 100 +select jsonb_path_query('"123"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"123\"', '$.integer()')" +== 466 +-- truncate_limit: 100 +select jsonb_path_query('1.23', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.23', '$.integer()')" +== 467 +-- truncate_limit: 100 +select jsonb_path_query('1.83', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.83', '$.integer()')" +== 468 +-- truncate_limit: 100 +select jsonb_path_query('12345678901', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345678901', '$.integer()')" +== 469 +-- truncate_limit: 100 +select jsonb_path_query('"12345678901"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12345678901\"', '$.integer()')" +== 470 +-- truncate_limit: 100 +select jsonb_path_query('"+123"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"+123\"', '$.integer()')" +== 471 +-- truncate_limit: 100 +select jsonb_path_query('-123', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('-123', '$.integer()')" +== 472 +-- truncate_limit: 100 +select jsonb_path_query('"-123"', '$.integer()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-123\"', '$.integer()')" +== 473 +-- truncate_limit: 100 +select jsonb_path_query('123', '$.integer() * 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('123', '$.integer() * 2')" +== 474 +-- truncate_limit: 100 +-- Test .number() +select jsonb_path_query('null', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.number()')" +== 475 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.number()')" +== 476 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.number()', silent := true)" +== 477 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.number()', silent := true)" +== 478 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.number()')" +== 479 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.number()')" +== 480 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.number()')" +== 481 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.number()', silent := true)" +== 482 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.number()', silent := true)" +== 483 +-- truncate_limit: 100 +select jsonb_path_query('1.23', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.23', '$.number()')" +== 484 +-- truncate_limit: 100 +select jsonb_path_query('"1.23"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23\"', '$.number()')" +== 485 +-- truncate_limit: 100 +select jsonb_path_query('"1.23aaa"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23aaa\"', '$.number()')" +== 486 +-- truncate_limit: 100 +select jsonb_path_query('1e1000', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1e1000', '$.number()')" +== 487 +-- truncate_limit: 100 +select jsonb_path_query('"nan"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"nan\"', '$.number()')" +== 488 +-- truncate_limit: 100 +select jsonb_path_query('"NaN"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"NaN\"', '$.number()')" +== 489 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.number()')" +== 490 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.number()')" +== 491 +-- truncate_limit: 100 +select jsonb_path_query('"inf"', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"inf\"', '$.number()', silent := true)" +== 492 +-- truncate_limit: 100 +select jsonb_path_query('"-inf"', '$.number()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-inf\"', '$.number()', silent := true)" +== 493 +-- truncate_limit: 100 +select jsonb_path_query('123', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('123', '$.number()')" +== 494 +-- truncate_limit: 100 +select jsonb_path_query('"123"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"123\"', '$.number()')" +== 495 +-- truncate_limit: 100 +select jsonb_path_query('12345678901234567890', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12345678901234567890', '$.number()')" +== 496 +-- truncate_limit: 100 +select jsonb_path_query('"12345678901234567890"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12345678901234567890\"', '$.number()')" +== 497 +-- truncate_limit: 100 +select jsonb_path_query('"+12.3"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"+12.3\"', '$.number()')" +== 498 +-- truncate_limit: 100 +select jsonb_path_query('-12.3', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('-12.3', '$.number()')" +== 499 +-- truncate_limit: 100 +select jsonb_path_query('"-12.3"', '$.number()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"-12.3\"', '$.number()')" +== 500 +-- truncate_limit: 100 +select jsonb_path_query('12.3', '$.number() * 2') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('12.3', '$.number() * 2')" +== 501 +-- truncate_limit: 100 +-- Test .string() +select jsonb_path_query('null', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.string()')" +== 502 +-- truncate_limit: 100 +select jsonb_path_query('null', '$.string()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.string()', silent := true)" +== 503 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.string()')" +== 504 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.string()')" +== 505 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.string()')" +== 506 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.string()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.string()', silent := true)" +== 507 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.string()', silent => true) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.string()', silent := true)" +== 508 +-- truncate_limit: 100 +select jsonb_path_query('1.23', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1.23', '$.string()')" +== 509 +-- truncate_limit: 100 +select jsonb_path_query('"1.23"', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23\"', '$.string()')" +== 510 +-- truncate_limit: 100 +select jsonb_path_query('"1.23aaa"', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"1.23aaa\"', '$.string()')" +== 511 +-- truncate_limit: 100 +select jsonb_path_query('1234', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234', '$.string()')" +== 512 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.string()')" +== 513 +-- truncate_limit: 100 +select jsonb_path_query('1234', '$.string().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1234', '$.string().type()')" +== 514 +-- truncate_limit: 100 +select jsonb_path_query('[2, true]', '$.string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[2, true]', '$.string()')" +== 515 +-- truncate_limit: 100 +select jsonb_path_query_array('[1.23, "yes", false]', '$[*].string()') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_array('[1.23, \"yes\", false]', '$[*].string()')" +== 516 +-- truncate_limit: 100 +select jsonb_path_query_array('[1.23, "yes", false]', '$[*].string().type()') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_array('[1.23, \"yes\", false]', '$[*].string().type()')" +== 517 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +5:30\"', '$.timestamp().string()')" +== 518 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56 +5:30\"', '$.timestamp().string()')" +== 519 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp_tz().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.timestamp_tz().string()')" +== 520 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56"', '$.timestamp_tz().string()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56\"', '$.timestamp_tz().string()')" +== 521 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp_tz().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +5:30\"', '$.timestamp_tz().string()')" +== 522 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.timestamp().string()')" +== 523 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56 +5:30"', '$.time_tz().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56 +5:30\"', '$.time_tz().string()')" +== 524 +-- truncate_limit: 100 +-- this timetz usage will absorb the UTC offset of the current timezone setting +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 525 +-- truncate_limit: 100 +set local timezone = 'UTC-10' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO \"UTC-10\"" +== 526 +-- truncate_limit: 100 +select jsonb_path_query_tz('"12:34:56"', '$.time_tz().string()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"12:34:56\"', '$.time_tz().string()')" +== 527 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 528 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.time().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.time().string()')" +== 529 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15"', '$.date().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15\"', '$.date().string()')" +== 530 +-- truncate_limit: 100 +-- .string() does not react to timezone or datestyle +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 531 +-- truncate_limit: 100 +set local timezone = 'UTC' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO \"UTC\"" +== 532 +-- truncate_limit: 100 +set local datestyle = 'German' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL datestyle TO \"German\"" +== 533 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp_tz().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +5:30\"', '$.timestamp_tz().string()')" +== 534 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp().string()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.timestamp().string()')" +== 535 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 536 +-- truncate_limit: 100 +-- Test .time() +select jsonb_path_query('null', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.time()')" +== 537 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.time()')" +== 538 +-- truncate_limit: 100 +select jsonb_path_query('1', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$.time()')" +== 539 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.time()')" +== 540 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.time()')" +== 541 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.time()')" +== 542 +-- truncate_limit: 100 +select jsonb_path_query('"bogus"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"bogus\"', '$.time()')" +== 543 +-- truncate_limit: 100 +select jsonb '"12:34:56"' @? '$.time()' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"12:34:56\"'::jsonb @? '$.time()'" +== 544 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.time()')" +== 545 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.time().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.time().type()')" +== 546 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15\"', '$.time()')" +== 547 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56 +05:30\"', '$.time()')" +== 548 +-- truncate_limit: 100 +select jsonb_path_query_tz('"12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"12:34:56 +05:30\"', '$.time()')" +== 549 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.time()')" +== 550 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789"', '$.time(-1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789\"', '$.time(-1)')" +== 551 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789"', '$.time(2.0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789\"', '$.time(2.0)')" +== 552 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789"', '$.time(12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789\"', '$.time(12345678901)')" +== 553 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789"', '$.time(0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789\"', '$.time(0)')" +== 554 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789"', '$.time(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789\"', '$.time(2)')" +== 555 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789"', '$.time(5)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789\"', '$.time(5)')" +== 556 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789"', '$.time(10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789\"', '$.time(10)')" +== 557 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789012"', '$.time(8)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789012\"', '$.time(8)')" +== 558 +-- truncate_limit: 100 +-- Test .time_tz() +select jsonb_path_query('null', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.time_tz()')" +== 559 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.time_tz()')" +== 560 +-- truncate_limit: 100 +select jsonb_path_query('1', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$.time_tz()')" +== 561 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.time_tz()')" +== 562 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.time_tz()')" +== 563 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.time_tz()')" +== 564 +-- truncate_limit: 100 +select jsonb_path_query('"bogus"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"bogus\"', '$.time_tz()')" +== 565 +-- truncate_limit: 100 +select jsonb '"12:34:56 +05:30"' @? '$.time_tz()' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"12:34:56 +05:30\"'::jsonb @? '$.time_tz()'" +== 566 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56 +05:30"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56 +05:30\"', '$.time_tz()')" +== 567 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56 +05:30"', '$.time_tz().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56 +05:30\"', '$.time_tz().type()')" +== 568 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15\"', '$.time_tz()')" +== 569 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.time_tz()')" +== 570 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(-1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789 +05:30\"', '$.time_tz(-1)')" +== 571 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(2.0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789 +05:30\"', '$.time_tz(2.0)')" +== 572 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789 +05:30\"', '$.time_tz(12345678901)')" +== 573 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789 +05:30\"', '$.time_tz(0)')" +== 574 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789 +05:30\"', '$.time_tz(2)')" +== 575 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(5)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789 +05:30\"', '$.time_tz(5)')" +== 576 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789 +05:30"', '$.time_tz(10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789 +05:30\"', '$.time_tz(10)')" +== 577 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56.789012 +05:30"', '$.time_tz(8)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56.789012 +05:30\"', '$.time_tz(8)')" +== 578 +-- truncate_limit: 100 +-- Test .timestamp() +select jsonb_path_query('null', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.timestamp()')" +== 579 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.timestamp()')" +== 580 +-- truncate_limit: 100 +select jsonb_path_query('1', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$.timestamp()')" +== 581 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.timestamp()')" +== 582 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.timestamp()')" +== 583 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.timestamp()')" +== 584 +-- truncate_limit: 100 +select jsonb_path_query('"bogus"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"bogus\"', '$.timestamp()')" +== 585 +-- truncate_limit: 100 +select jsonb '"2023-08-15 12:34:56"' @? '$.timestamp()' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"2023-08-15 12:34:56\"'::jsonb @? '$.timestamp()'" +== 586 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.timestamp()')" +== 587 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.timestamp().type()')" +== 588 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15\"', '$.timestamp()')" +== 589 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.timestamp()')" +== 590 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56 +05:30\"', '$.timestamp()')" +== 591 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(-1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789\"', '$.timestamp(-1)')" +== 592 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(2.0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789\"', '$.timestamp(2.0)')" +== 593 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789\"', '$.timestamp(12345678901)')" +== 594 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789\"', '$.timestamp(0)')" +== 595 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789\"', '$.timestamp(2)')" +== 596 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(5)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789\"', '$.timestamp(5)')" +== 597 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789"', '$.timestamp(10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789\"', '$.timestamp(10)')" +== 598 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789012"', '$.timestamp(8)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789012\"', '$.timestamp(8)')" +== 599 +-- truncate_limit: 100 +-- Test .timestamp_tz() +select jsonb_path_query('null', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('null', '$.timestamp_tz()')" +== 600 +-- truncate_limit: 100 +select jsonb_path_query('true', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('true', '$.timestamp_tz()')" +== 601 +-- truncate_limit: 100 +select jsonb_path_query('1', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('1', '$.timestamp_tz()')" +== 602 +-- truncate_limit: 100 +select jsonb_path_query('[]', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', '$.timestamp_tz()')" +== 603 +-- truncate_limit: 100 +select jsonb_path_query('[]', 'strict $.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[]', 'strict $.timestamp_tz()')" +== 604 +-- truncate_limit: 100 +select jsonb_path_query('{}', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('{}', '$.timestamp_tz()')" +== 605 +-- truncate_limit: 100 +select jsonb_path_query('"bogus"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"bogus\"', '$.timestamp_tz()')" +== 606 +-- truncate_limit: 100 +select jsonb '"2023-08-15 12:34:56 +05:30"' @? '$.timestamp_tz()' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"2023-08-15 12:34:56 +05:30\"'::jsonb @? '$.timestamp_tz()'" +== 607 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp_tz()')" +== 608 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp_tz().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp_tz().type()')" +== 609 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15\"', '$.timestamp_tz()')" +== 610 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15\"', '$.timestamp_tz()')" +== 611 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.timestamp_tz()')" +== 612 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56 +05:30"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56 +05:30\"', '$.timestamp_tz()')" +== 613 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(-1)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789 +05:30\"', '$.timestamp_tz(-1)')" +== 614 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(2.0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789 +05:30\"', '$.timestamp_tz(2.0)')" +== 615 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(12345678901)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789 +05:30\"', '$.timestamp_tz(12345678901)')" +== 616 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(0)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789 +05:30\"', '$.timestamp_tz(0)')" +== 617 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(2)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789 +05:30\"', '$.timestamp_tz(2)')" +== 618 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(5)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789 +05:30\"', '$.timestamp_tz(5)')" +== 619 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789 +05:30"', '$.timestamp_tz(10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789 +05:30\"', '$.timestamp_tz(10)')" +== 620 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56.789012 +05:30"', '$.timestamp_tz(8)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56.789012 +05:30\"', '$.timestamp_tz(8)')" +== 621 +-- truncate_limit: 100 +set time zone '+00' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"+00\"" +== 622 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.time()')" +== 623 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56 +05:30\"', '$.time()')" +== 624 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.time_tz()')" +== 625 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.time_tz()')" +== 626 +-- truncate_limit: 100 +select jsonb_path_query_tz('"12:34:56"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"12:34:56\"', '$.time_tz()')" +== 627 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp()')" +== 628 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp()')" +== 629 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.timestamp_tz()')" +== 630 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56\"', '$.timestamp_tz()')" +== 631 +-- truncate_limit: 100 +-- should work + +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy HH24:MI")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34\"', '$.datetime(\"dd-mm-yyyy HH24:MI\")')" +== 632 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH\")')" +== 633 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 +05"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34 +05\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH\")')" +== 634 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 -05"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34 -05\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH\")')" +== 635 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 +05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34 +05:20\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH:TZM\")')" +== 636 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 -05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34 -05:20\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH:TZM\")')" +== 637 +-- truncate_limit: 100 +select jsonb_path_query('"12:34"', '$.datetime("HH24:MI")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34\"', '$.datetime(\"HH24:MI\")')" +== 638 +-- truncate_limit: 100 +select jsonb_path_query('"12:34"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34\"', '$.datetime(\"HH24:MI TZH\")')" +== 639 +-- truncate_limit: 100 +select jsonb_path_query('"12:34 +05"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34 +05\"', '$.datetime(\"HH24:MI TZH\")')" +== 640 +-- truncate_limit: 100 +select jsonb_path_query('"12:34 -05"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34 -05\"', '$.datetime(\"HH24:MI TZH\")')" +== 641 +-- truncate_limit: 100 +select jsonb_path_query('"12:34 +05:20"', '$.datetime("HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34 +05:20\"', '$.datetime(\"HH24:MI TZH:TZM\")')" +== 642 +-- truncate_limit: 100 +select jsonb_path_query('"12:34 -05:20"', '$.datetime("HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34 -05:20\"', '$.datetime(\"HH24:MI TZH:TZM\")')" +== 643 +-- truncate_limit: 100 +set time zone '+10' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"+10\"" +== 644 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.time()')" +== 645 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56 +05:30\"', '$.time()')" +== 646 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.time_tz()')" +== 647 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp()')" +== 648 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp()')" +== 649 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56\"', '$.timestamp_tz()')" +== 650 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56\"', '$.timestamp_tz()')" +== 651 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp_tz()')" +== 652 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy HH24:MI")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34\"', '$.datetime(\"dd-mm-yyyy HH24:MI\")')" +== 653 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH\")')" +== 654 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 +05"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34 +05\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH\")')" +== 655 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 -05"', '$.datetime("dd-mm-yyyy HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34 -05\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH\")')" +== 656 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 +05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34 +05:20\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH:TZM\")')" +== 657 +-- truncate_limit: 100 +select jsonb_path_query('"10-03-2017 12:34 -05:20"', '$.datetime("dd-mm-yyyy HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"10-03-2017 12:34 -05:20\"', '$.datetime(\"dd-mm-yyyy HH24:MI TZH:TZM\")')" +== 658 +-- truncate_limit: 100 +select jsonb_path_query('"12:34"', '$.datetime("HH24:MI")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34\"', '$.datetime(\"HH24:MI\")')" +== 659 +-- truncate_limit: 100 +select jsonb_path_query('"12:34"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34\"', '$.datetime(\"HH24:MI TZH\")')" +== 660 +-- truncate_limit: 100 +select jsonb_path_query('"12:34 +05"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34 +05\"', '$.datetime(\"HH24:MI TZH\")')" +== 661 +-- truncate_limit: 100 +select jsonb_path_query('"12:34 -05"', '$.datetime("HH24:MI TZH")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34 -05\"', '$.datetime(\"HH24:MI TZH\")')" +== 662 +-- truncate_limit: 100 +select jsonb_path_query('"12:34 +05:20"', '$.datetime("HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34 +05:20\"', '$.datetime(\"HH24:MI TZH:TZM\")')" +== 663 +-- truncate_limit: 100 +select jsonb_path_query('"12:34 -05:20"', '$.datetime("HH24:MI TZH:TZM")') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34 -05:20\"', '$.datetime(\"HH24:MI TZH:TZM\")')" +== 664 +-- truncate_limit: 100 +set time zone default +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO DEFAULT" +== 665 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.time()')" +== 666 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.time()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56 +05:30\"', '$.time()')" +== 667 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.time_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.time_tz()')" +== 668 +-- truncate_limit: 100 +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp()')" +== 669 +-- truncate_limit: 100 +select jsonb_path_query_tz('"2023-08-15 12:34:56 +05:30"', '$.timestamp()') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_tz('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp()')" +== 670 +-- truncate_limit: 100 +-- should work +select jsonb_path_query('"2023-08-15 12:34:56 +05:30"', '$.timestamp_tz()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2023-08-15 12:34:56 +05:30\"', '$.timestamp_tz()')" +== 671 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10\"', '$.datetime().type()')" +== 672 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10\"', '$.datetime()')" +== 673 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10 12:34:56"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10 12:34:56\"', '$.datetime().type()')" +== 674 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10 12:34:56"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10 12:34:56\"', '$.datetime()')" +== 675 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10 12:34:56+3"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10 12:34:56+3\"', '$.datetime().type()')" +== 676 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10 12:34:56+3"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10 12:34:56+3\"', '$.datetime()')" +== 677 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10 12:34:56+3:10"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10 12:34:56+3:10\"', '$.datetime().type()')" +== 678 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10 12:34:56+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10 12:34:56+3:10\"', '$.datetime()')" +== 679 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10T12:34:56+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10T12:34:56+3:10\"', '$.datetime()')" +== 680 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10t12:34:56+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10t12:34:56+3:10\"', '$.datetime()')" +== 681 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10 12:34:56.789+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10 12:34:56.789+3:10\"', '$.datetime()')" +== 682 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10T12:34:56.789+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10T12:34:56.789+3:10\"', '$.datetime()')" +== 683 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10t12:34:56.789+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10t12:34:56.789+3:10\"', '$.datetime()')" +== 684 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10T12:34:56.789EST"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10T12:34:56.789EST\"', '$.datetime()')" +== 685 +-- truncate_limit: 100 +select jsonb_path_query('"2017-03-10T12:34:56.789Z"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"2017-03-10T12:34:56.789Z\"', '$.datetime()')" +== 686 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.datetime().type()')" +== 687 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56\"', '$.datetime()')" +== 688 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56+3"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56+3\"', '$.datetime().type()')" +== 689 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56+3"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56+3\"', '$.datetime()')" +== 690 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56+3:10"', '$.datetime().type()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56+3:10\"', '$.datetime().type()')" +== 691 +-- truncate_limit: 100 +select jsonb_path_query('"12:34:56+3:10"', '$.datetime()') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('\"12:34:56+3:10\"', '$.datetime()')" +== 692 +-- truncate_limit: 100 +set time zone '+00' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"+00\"" +== 693 +-- truncate_limit: 100 +-- date comparison +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ == "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 694 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ >= "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 695 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ < "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 696 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ == "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 697 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ >= "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 698 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "12:34:56", "01:02:03+04", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ < "10.03.2017".datetime("dd.mm.yyyy"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 699 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ == "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 700 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ >= "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 701 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].datetime() ? (@ < "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 702 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ == "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 703 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ >= "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 704 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ < "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 705 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ == "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 706 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ >= "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 707 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10", "2017-03-11", "2017-03-09", "2017-03-10 00:00:00", "2017-03-10 12:34:56", "2017-03-10 01:02:03+04", "2017-03-10 03:00:00+03"]', + '$[*].date() ? (@ < "2017-03-10".date())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 708 +-- truncate_limit: 100 +-- time comparison +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ == "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 709 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ >= "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 710 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ < "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 711 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ == "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 712 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ >= "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 713 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ < "12:35".datetime("HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 714 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ == "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 715 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ >= "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 716 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].datetime() ? (@ < "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 717 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ == "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 718 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ >= "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 719 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ < "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 720 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00.123", "12:35:00.123", "12:36:00.1123", "12:35:00.1123+00", "12:35:00.123+01", "13:35:00.123+01", "2017-03-10 12:35:00.1", "2017-03-10 12:35:00.123+01"]', + '$[*].time(2) ? (@ >= "12:35:00.123".time(2))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 721 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ == "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 722 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ >= "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 723 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00", "12:35:00", "12:36:00", "12:35:00+00", "12:35:00+01", "13:35:00+01", "2017-03-10 12:35:00", "2017-03-10 12:35:00+01"]', + '$[*].time() ? (@ < "12:35:00".time())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 724 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00.123", "12:35:00.123", "12:36:00.1123", "12:35:00.1123+00", "12:35:00.123+01", "13:35:00.123+01", "2017-03-10 12:35:00.1", "2017-03-10 12:35:00.123+01"]', + '$[*].time(2) ? (@ >= "12:35:00.123".time(2))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 725 +-- truncate_limit: 100 +-- timetz comparison +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ == "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 726 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ >= "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 727 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ < "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 728 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ == "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 729 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ >= "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 730 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10", "2017-03-10 12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ < "12:35 +1".datetime("HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 731 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ == "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 732 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ >= "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 733 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].datetime() ? (@ < "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 734 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ == "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 735 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ >= "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 736 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ < "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 737 +-- truncate_limit: 100 +select jsonb_path_query( + '["12:34:00.123+01", "12:35:00.123+01", "12:36:00.1123+01", "12:35:00.1123+02", "12:35:00.123-02", "10:35:00.123", "11:35:00.1", "12:35:00.123", "2017-03-10 12:35:00.123 +1"]', + '$[*].time_tz(2) ? (@ >= "12:35:00.123 +1".time_tz(2))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 738 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ == "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 739 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ >= "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 740 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00+01", "12:35:00+01", "12:36:00+01", "12:35:00+02", "12:35:00-02", "10:35:00", "11:35:00", "12:35:00", "2017-03-10 12:35:00 +1"]', + '$[*].time_tz() ? (@ < "12:35:00 +1".time_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 741 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["12:34:00.123+01", "12:35:00.123+01", "12:36:00.1123+01", "12:35:00.1123+02", "12:35:00.123-02", "10:35:00.123", "11:35:00.1", "12:35:00.123", "2017-03-10 12:35:00.123 +1"]', + '$[*].time_tz(2) ? (@ >= "12:35:00.123 +1".time_tz(2))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 742 +-- truncate_limit: 100 +-- timestamp comparison +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ == "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 743 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ >= "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 744 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ < "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 745 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ == "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 746 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ >= "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 747 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ < "10.03.2017 12:35".datetime("dd.mm.yyyy HH24:MI"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 748 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ == "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 749 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ >= "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 750 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ < "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 751 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ == "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 752 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ >= "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 753 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ < "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 754 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00.123", "2017-03-10 12:35:00.123", "2017-03-10 12:36:00.1123", "2017-03-10 12:35:00.1123+01", "2017-03-10 13:35:00.123+01", "2017-03-10 12:35:00.1-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp(2) ? (@ >= "2017-03-10 12:35:00.123".timestamp(2))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 755 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ == "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 756 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ >= "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 757 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00", "2017-03-10 12:35:00", "2017-03-10 12:36:00", "2017-03-10 12:35:00+01", "2017-03-10 13:35:00+01", "2017-03-10 12:35:00-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp() ? (@ < "2017-03-10 12:35:00".timestamp())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 758 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00.123", "2017-03-10 12:35:00.123", "2017-03-10 12:36:00.1123", "2017-03-10 12:35:00.1123+01", "2017-03-10 13:35:00.123+01", "2017-03-10 12:35:00.1-01", "2017-03-10", "2017-03-11"]', + '$[*].timestamp(2) ? (@ >= "2017-03-10 12:35:00.123".timestamp(2))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 759 +-- truncate_limit: 100 +-- timestamptz comparison +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ == "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 760 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ >= "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 761 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ < "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 762 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ == "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 763 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ >= "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 764 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11", "12:34:56", "12:34:56+01"]', + '$[*].datetime() ? (@ < "10.03.2017 12:35 +1".datetime("dd.mm.yyyy HH24:MI TZH"))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 765 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ == "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 766 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ >= "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 767 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].datetime() ? (@ < "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 768 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ == "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 769 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ >= "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 770 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ < "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 771 +-- truncate_limit: 100 +select jsonb_path_query( + '["2017-03-10 12:34:00.123+01", "2017-03-10 12:35:00.123+01", "2017-03-10 12:36:00.1123+01", "2017-03-10 12:35:00.1123+02", "2017-03-10 12:35:00.123-02", "2017-03-10 10:35:00.123", "2017-03-10 11:35:00.1", "2017-03-10 12:35:00.123", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz(2) ? (@ >= "2017-03-10 12:35:00.123 +1".timestamp_tz(2))') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 772 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ == "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 773 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ >= "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 774 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00+01", "2017-03-10 12:35:00+01", "2017-03-10 12:36:00+01", "2017-03-10 12:35:00+02", "2017-03-10 12:35:00-02", "2017-03-10 10:35:00", "2017-03-10 11:35:00", "2017-03-10 12:35:00", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz() ? (@ < "2017-03-10 12:35:00 +1".timestamp_tz())') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 775 +-- truncate_limit: 100 +select jsonb_path_query_tz( + '["2017-03-10 12:34:00.123+01", "2017-03-10 12:35:00.123+01", "2017-03-10 12:36:00.1123+01", "2017-03-10 12:35:00.1123+02", "2017-03-10 12:35:00.123-02", "2017-03-10 10:35:00.123", "2017-03-10 11:35:00.1", "2017-03-10 12:35:00.123", "2017-03-10", "2017-03-11"]', + '$[*].timestamp_tz(2) ? (@ >= "2017-03-10 12:35:00.123 +1".timestamp_tz(2))') +-- +FUNCTION: name="jsonb_path_query_tz" function="jsonb_path_query_tz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 776 +-- truncate_limit: 100 +-- overflow during comparison +select jsonb_path_query('"1000000-01-01"', '$.datetime() > "2020-01-01 12:00:00".datetime()'::jsonpath) +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 777 +-- truncate_limit: 100 +set time zone default +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO DEFAULT" +== 778 +-- truncate_limit: 100 +-- jsonpath operators + +SELECT jsonb_path_query('[{"a": 1}, {"a": 2}]', '$[*]') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{\"a\": 1}, {\"a\": 2}]', '$[*]')" +== 779 +-- truncate_limit: 100 +SELECT jsonb_path_query('[{"a": 1}, {"a": 2}]', '$[*] ? (@.a > 10)') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{\"a\": 1}, {\"a\": 2}]', '$[*] ? (@.a > 10)')" +== 780 +-- truncate_limit: 100 +SELECT jsonb_path_query('[{"a": 1}]', '$undefined_var') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{\"a\": 1}]', '$undefined_var')" +== 781 +-- truncate_limit: 100 +SELECT jsonb_path_query('[{"a": 1}]', 'false') +-- +FUNCTION: name="jsonb_path_query" function="jsonb_path_query" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query('[{\"a\": 1}]', 'false')" +== 782 +-- truncate_limit: 100 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}, {}]', 'strict $[*].a') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_array('[{\"a\": 1}, {\"a\": 2}, {}]', 'strict $[*].a')" +== 783 +-- truncate_limit: 100 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}]', '$[*].a') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_array('[{\"a\": 1}, {\"a\": 2}]', '$[*].a')" +== 784 +-- truncate_limit: 100 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ == 1)') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_array('[{\"a\": 1}, {\"a\": 2}]', '$[*].a ? (@ == 1)')" +== 785 +-- truncate_limit: 100 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ > 10)') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_array('[{\"a\": 1}, {\"a\": 2}]', '$[*].a ? (@ > 10)')" +== 786 +-- truncate_limit: 100 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].a ? (@ > $min && @ < $max)', vars => '{"min": 1, "max": 4}') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 787 +-- truncate_limit: 100 +SELECT jsonb_path_query_array('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].a ? (@ > $min && @ < $max)', vars => '{"min": 3, "max": 4}') +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 788 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {}]', 'strict $[*].a') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_first('[{\"a\": 1}, {\"a\": 2}, {}]', 'strict $[*].a')" +== 789 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {}]', 'strict $[*].a', silent => true) +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_first('[{\"a\": 1}, {\"a\": 2}, {}]', 'strict $[*].a', silent := true)" +== 790 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}]', '$[*].a') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_first('[{\"a\": 1}, {\"a\": 2}]', '$[*].a')" +== 791 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ == 1)') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_first('[{\"a\": 1}, {\"a\": 2}]', '$[*].a ? (@ == 1)')" +== 792 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ > 10)') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_first('[{\"a\": 1}, {\"a\": 2}]', '$[*].a ? (@ > 10)')" +== 793 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].a ? (@ > $min && @ < $max)', vars => '{"min": 1, "max": 4}') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 794 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].a ? (@ > $min && @ < $max)', vars => '{"min": 3, "max": 4}') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 795 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}]', '$undefined_var') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_first('[{\"a\": 1}]', '$undefined_var')" +== 796 +-- truncate_limit: 100 +SELECT jsonb_path_query_first('[{"a": 1}]', 'false') +-- +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_query_first('[{\"a\": 1}]', 'false')" +== 797 +-- truncate_limit: 100 +SELECT jsonb '[{"a": 1}, {"a": 2}]' @? '$[*].a ? (@ > 1)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"a\": 1}, {\"a\": 2}]'::jsonb @? '$[*].a ? (@ > 1)'" +== 798 +-- truncate_limit: 100 +SELECT jsonb '[{"a": 1}, {"a": 2}]' @? '$[*] ? (@.a > 2)' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"a\": 1}, {\"a\": 2}]'::jsonb @? '$[*] ? (@.a > 2)'" +== 799 +-- truncate_limit: 100 +SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ > 1)') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_exists('[{\"a\": 1}, {\"a\": 2}]', '$[*].a ? (@ > 1)')" +== 800 +-- truncate_limit: 100 +SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*] ? (@.a > $min && @.a < $max)', vars => '{"min": 1, "max": 4}') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 801 +-- truncate_limit: 100 +SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*] ? (@.a > $min && @.a < $max)', vars => '{"min": 3, "max": 4}') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 802 +-- truncate_limit: 100 +SELECT jsonb_path_exists('[{"a": 1}]', '$undefined_var') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_exists('[{\"a\": 1}]', '$undefined_var')" +== 803 +-- truncate_limit: 100 +SELECT jsonb_path_exists('[{"a": 1}]', 'false') +-- +FUNCTION: name="jsonb_path_exists" function="jsonb_path_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_exists('[{\"a\": 1}]', 'false')" +== 804 +-- truncate_limit: 100 +SELECT jsonb_path_match('true', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('true', '$', silent := false)" +== 805 +-- truncate_limit: 100 +SELECT jsonb_path_match('false', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('false', '$', silent := false)" +== 806 +-- truncate_limit: 100 +SELECT jsonb_path_match('null', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('null', '$', silent := false)" +== 807 +-- truncate_limit: 100 +SELECT jsonb_path_match('1', '$', silent => true) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('1', '$', silent := true)" +== 808 +-- truncate_limit: 100 +SELECT jsonb_path_match('1', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('1', '$', silent := false)" +== 809 +-- truncate_limit: 100 +SELECT jsonb_path_match('"a"', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('\"a\"', '$', silent := false)" +== 810 +-- truncate_limit: 100 +SELECT jsonb_path_match('{}', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('{}', '$', silent := false)" +== 811 +-- truncate_limit: 100 +SELECT jsonb_path_match('[true]', '$', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[true]', '$', silent := false)" +== 812 +-- truncate_limit: 100 +SELECT jsonb_path_match('{}', 'lax $.a', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('{}', 'lax $.a', silent := false)" +== 813 +-- truncate_limit: 100 +SELECT jsonb_path_match('{}', 'strict $.a', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('{}', 'strict $.a', silent := false)" +== 814 +-- truncate_limit: 100 +SELECT jsonb_path_match('{}', 'strict $.a', silent => true) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('{}', 'strict $.a', silent := true)" +== 815 +-- truncate_limit: 100 +SELECT jsonb_path_match('[true, true]', '$[*]', silent => false) +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[true, true]', '$[*]', silent := false)" +== 816 +-- truncate_limit: 100 +SELECT jsonb '[{"a": 1}, {"a": 2}]' @@ '$[*].a > 1' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"a\": 1}, {\"a\": 2}]'::jsonb @@ '$[*].a > 1'" +== 817 +-- truncate_limit: 100 +SELECT jsonb '[{"a": 1}, {"a": 2}]' @@ '$[*].a > 2' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[{\"a\": 1}, {\"a\": 2}]'::jsonb @@ '$[*].a > 2'" +== 818 +-- truncate_limit: 100 +SELECT jsonb_path_match('[{"a": 1}, {"a": 2}]', '$[*].a > 1') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[{\"a\": 1}, {\"a\": 2}]', '$[*].a > 1')" +== 819 +-- truncate_limit: 100 +SELECT jsonb_path_match('[{"a": 1}]', '$undefined_var') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[{\"a\": 1}]', '$undefined_var')" +== 820 +-- truncate_limit: 100 +SELECT jsonb_path_match('[{"a": 1}]', 'false') +-- +FUNCTION: name="jsonb_path_match" function="jsonb_path_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT jsonb_path_match('[{\"a\": 1}]', 'false')" +== 821 +-- truncate_limit: 100 +-- test string comparison (Unicode codepoint collation) +WITH str(j, num) AS +( + SELECT jsonb_build_object('s', s), num + FROM unnest('{"", "a", "ab", "abc", "abcd", "b", "A", "AB", "ABC", "ABc", "ABcD", "B"}'::text[]) WITH ORDINALITY AS a(s, num) +) +SELECT + s1.j, s2.j, + jsonb_path_query_first(s1.j, '$.s < $s', vars => s2.j) lt, + jsonb_path_query_first(s1.j, '$.s <= $s', vars => s2.j) le, + jsonb_path_query_first(s1.j, '$.s == $s', vars => s2.j) eq, + jsonb_path_query_first(s1.j, '$.s >= $s', vars => s2.j) ge, + jsonb_path_query_first(s1.j, '$.s > $s', vars => s2.j) gt +FROM str s1, str s2 +ORDER BY s1.num, s2.num +-- +ALIAS: "s1"="str" +ALIAS: "s2"="str" +CTE: "str" +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_path_query_first" function="jsonb_path_query_first" schema="" ctx=Call +FUNCTION: name="jsonb_build_object" function="jsonb_build_object" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH str(j, num) AS (...) SELECT ... FROM str s1, str s2 ORDER BY s1.num, s2.num" diff --git a/parser/testdata/summary_truncate/postgres_regress/jsonpath.metadata.json b/parser/testdata/summary_truncate/postgres_regress/jsonpath.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/jsonpath.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/jsonpath.test b/parser/testdata/summary_truncate/postgres_regress/jsonpath.test new file mode 100644 index 0000000..0ef912a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/jsonpath.test @@ -0,0 +1,1371 @@ +== 001 +-- truncate_limit: 100 +--jsonpath io + +select ''::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::jsonpath" +== 002 +-- truncate_limit: 100 +select '$'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$'::jsonpath" +== 003 +-- truncate_limit: 100 +select 'strict $'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'strict $'::jsonpath" +== 004 +-- truncate_limit: 100 +select 'lax $'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'lax $'::jsonpath" +== 005 +-- truncate_limit: 100 +select '$.a'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a'::jsonpath" +== 006 +-- truncate_limit: 100 +select '$.a.v'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.v'::jsonpath" +== 007 +-- truncate_limit: 100 +select '$.a.*'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.*'::jsonpath" +== 008 +-- truncate_limit: 100 +select '$.*[*]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.*[*]'::jsonpath" +== 009 +-- truncate_limit: 100 +select '$.a[*]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a[*]'::jsonpath" +== 010 +-- truncate_limit: 100 +select '$.a[*][*]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a[*][*]'::jsonpath" +== 011 +-- truncate_limit: 100 +select '$[*]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$[*]'::jsonpath" +== 012 +-- truncate_limit: 100 +select '$[0]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$[0]'::jsonpath" +== 013 +-- truncate_limit: 100 +select '$[*][0]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$[*][0]'::jsonpath" +== 014 +-- truncate_limit: 100 +select '$[*].a'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$[*].a'::jsonpath" +== 015 +-- truncate_limit: 100 +select '$[*][0].a.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$[*][0].a.b'::jsonpath" +== 016 +-- truncate_limit: 100 +select '$.a.**.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.**.b'::jsonpath" +== 017 +-- truncate_limit: 100 +select '$.a.**{2}.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.**{2}.b'::jsonpath" +== 018 +-- truncate_limit: 100 +select '$.a.**{2 to 2}.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.**{2 to 2}.b'::jsonpath" +== 019 +-- truncate_limit: 100 +select '$.a.**{2 to 5}.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.**{2 to 5}.b'::jsonpath" +== 020 +-- truncate_limit: 100 +select '$.a.**{0 to 5}.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.**{0 to 5}.b'::jsonpath" +== 021 +-- truncate_limit: 100 +select '$.a.**{5 to last}.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.**{5 to last}.b'::jsonpath" +== 022 +-- truncate_limit: 100 +select '$.a.**{last}.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.**{last}.b'::jsonpath" +== 023 +-- truncate_limit: 100 +select '$.a.**{last to 5}.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a.**{last to 5}.b'::jsonpath" +== 024 +-- truncate_limit: 100 +select '$+1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$+1'::jsonpath" +== 025 +-- truncate_limit: 100 +select '$-1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$-1'::jsonpath" +== 026 +-- truncate_limit: 100 +select '$--+1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$--+1'::jsonpath" +== 027 +-- truncate_limit: 100 +select '$.a/+-1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a/+-1'::jsonpath" +== 028 +-- truncate_limit: 100 +select '1 * 2 + 4 % -3 != false'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 * 2 + 4 % -3 != false'::jsonpath" +== 029 +-- truncate_limit: 100 +select '"\b\f\r\n\t\v\"\''\\"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\b\\\\f\\\\r\\\\n\\\\t\\\\v\\\\\"\\\\''\\\\\\\\\"'::jsonpath" +== 030 +-- truncate_limit: 100 +select '"\x50\u0067\u{53}\u{051}\u{00004C}"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\x50\\\\u0067\\\\u{53}\\\\u{051}\\\\u{00004C}\"'::jsonpath" +== 031 +-- truncate_limit: 100 +select '$.foo\x50\u0067\u{53}\u{051}\u{00004C}\t\"bar'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.foo\\\\x50\\\\u0067\\\\u{53}\\\\u{051}\\\\u{00004C}\\\\t\\\\\"bar'::jsonpath" +== 032 +-- truncate_limit: 100 +select '"\z"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\z\"'::jsonpath" +== 033 +-- truncate_limit: 100 +-- unrecognized escape is just the literal char + +select '$.g ? ($.a == 1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? ($.a == 1)'::jsonpath" +== 034 +-- truncate_limit: 100 +select '$.g ? (@ == 1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@ == 1)'::jsonpath" +== 035 +-- truncate_limit: 100 +select '$.g ? (@.a == 1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@.a == 1)'::jsonpath" +== 036 +-- truncate_limit: 100 +select '$.g ? (@.a == 1 || @.a == 4)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@.a == 1 || @.a == 4)'::jsonpath" +== 037 +-- truncate_limit: 100 +select '$.g ? (@.a == 1 && @.a == 4)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@.a == 1 && @.a == 4)'::jsonpath" +== 038 +-- truncate_limit: 100 +select '$.g ? (@.a == 1 || @.a == 4 && @.b == 7)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@.a == 1 || @.a == 4 && @.b == 7)'::jsonpath" +== 039 +-- truncate_limit: 100 +select '$.g ? (@.a == 1 || !(@.a == 4) && @.b == 7)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@.a == 1 || !(@.a == 4) && @.b == 7)'::jsonpath" +== 040 +-- truncate_limit: 100 +select '$.g ? (@.a == 1 || !(@.x >= 123 || @.a == 4) && @.b == 7)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@.a == 1 || !(@.x >= 123 || @.a == 4) && @.b == 7)'::jsonpath" +== 041 +-- truncate_limit: 100 +select '$.g ? (@.x >= @[*]?(@.a > "abc"))'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@.x >= @[*]?(@.a > \"abc\"))'::jsonpath" +== 042 +-- truncate_limit: 100 +select '$.g ? ((@.x >= 123 || @.a == 4) is unknown)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? ((@.x >= 123 || @.a == 4) is unknown)'::jsonpath" +== 043 +-- truncate_limit: 100 +select '$.g ? (exists (@.x))'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (exists (@.x))'::jsonpath" +== 044 +-- truncate_limit: 100 +select '$.g ? (exists (@.x ? (@ == 14)))'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (exists (@.x ? (@ == 14)))'::jsonpath" +== 045 +-- truncate_limit: 100 +select '$.g ? ((@.x >= 123 || @.a == 4) && exists (@.x ? (@ == 14)))'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? ((@.x >= 123 || @.a == 4) && exists (@.x ? (@ == 14)))'::jsonpath" +== 046 +-- truncate_limit: 100 +select '$.g ? (+@.x >= +-(+@.a + 2))'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (+@.x >= +-(+@.a + 2))'::jsonpath" +== 047 +-- truncate_limit: 100 +select '$a'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$a'::jsonpath" +== 048 +-- truncate_limit: 100 +select '$a.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$a.b'::jsonpath" +== 049 +-- truncate_limit: 100 +select '$a[*]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$a[*]'::jsonpath" +== 050 +-- truncate_limit: 100 +select '$.g ? (@.zip == $zip)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.g ? (@.zip == $zip)'::jsonpath" +== 051 +-- truncate_limit: 100 +select '$.a[1,2, 3 to 16]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a[1,2, 3 to 16]'::jsonpath" +== 052 +-- truncate_limit: 100 +select '$.a[$a + 1, ($b[*]) to -($[0] * 2)]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a[$a + 1, ($b[*]) to -($[0] * 2)]'::jsonpath" +== 053 +-- truncate_limit: 100 +select '$.a[$.a.size() - 3]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.a[$.a.size() - 3]'::jsonpath" +== 054 +-- truncate_limit: 100 +select 'last'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'last'::jsonpath" +== 055 +-- truncate_limit: 100 +select '"last"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"last\"'::jsonpath" +== 056 +-- truncate_limit: 100 +select '$.last'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.last'::jsonpath" +== 057 +-- truncate_limit: 100 +select '$ ? (last > 0)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (last > 0)'::jsonpath" +== 058 +-- truncate_limit: 100 +select '$[last]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$[last]'::jsonpath" +== 059 +-- truncate_limit: 100 +select '$[$[0] ? (last > 0)]'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$[$[0] ? (last > 0)]'::jsonpath" +== 060 +-- truncate_limit: 100 +select 'null.type()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'null.type()'::jsonpath" +== 061 +-- truncate_limit: 100 +select '1.type()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.type()'::jsonpath" +== 062 +-- truncate_limit: 100 +select '(1).type()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1).type()'::jsonpath" +== 063 +-- truncate_limit: 100 +select '1.2.type()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.2.type()'::jsonpath" +== 064 +-- truncate_limit: 100 +select '"aaa".type()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '\"aaa\".type()'::jsonpath" +== 065 +-- truncate_limit: 100 +select 'true.type()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'true.type()'::jsonpath" +== 066 +-- truncate_limit: 100 +select '$.double().floor().ceiling().abs()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.double().floor().ceiling().abs()'::jsonpath" +== 067 +-- truncate_limit: 100 +select '$.keyvalue().key'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.keyvalue().key'::jsonpath" +== 068 +-- truncate_limit: 100 +select '$.datetime()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.datetime()'::jsonpath" +== 069 +-- truncate_limit: 100 +select '$.datetime("datetime template")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.datetime(\"datetime template\")'::jsonpath" +== 070 +-- truncate_limit: 100 +select '$.bigint().integer().number().decimal()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.bigint().integer().number().decimal()'::jsonpath" +== 071 +-- truncate_limit: 100 +select '$.boolean()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.boolean()'::jsonpath" +== 072 +-- truncate_limit: 100 +select '$.date()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.date()'::jsonpath" +== 073 +-- truncate_limit: 100 +select '$.decimal(4,2)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.decimal(4,2)'::jsonpath" +== 074 +-- truncate_limit: 100 +select '$.string()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.string()'::jsonpath" +== 075 +-- truncate_limit: 100 +select '$.time()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.time()'::jsonpath" +== 076 +-- truncate_limit: 100 +select '$.time(6)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.time(6)'::jsonpath" +== 077 +-- truncate_limit: 100 +select '$.time_tz()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.time_tz()'::jsonpath" +== 078 +-- truncate_limit: 100 +select '$.time_tz(4)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.time_tz(4)'::jsonpath" +== 079 +-- truncate_limit: 100 +select '$.timestamp()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.timestamp()'::jsonpath" +== 080 +-- truncate_limit: 100 +select '$.timestamp(2)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.timestamp(2)'::jsonpath" +== 081 +-- truncate_limit: 100 +select '$.timestamp_tz()'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.timestamp_tz()'::jsonpath" +== 082 +-- truncate_limit: 100 +select '$.timestamp_tz(0)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$.timestamp_tz(0)'::jsonpath" +== 083 +-- truncate_limit: 100 +select '$ ? (@ starts with "abc")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ starts with \"abc\")'::jsonpath" +== 084 +-- truncate_limit: 100 +select '$ ? (@ starts with $var)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ starts with $var)'::jsonpath" +== 085 +-- truncate_limit: 100 +select '$ ? (@ like_regex "(invalid pattern")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"(invalid pattern\")'::jsonpath" +== 086 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\")'::jsonpath" +== 087 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"\")'::jsonpath" +== 088 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "i")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"i\")'::jsonpath" +== 089 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "is")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"is\")'::jsonpath" +== 090 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "isim")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"isim\")'::jsonpath" +== 091 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "xsms")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"xsms\")'::jsonpath" +== 092 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "q")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"q\")'::jsonpath" +== 093 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "iq")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"iq\")'::jsonpath" +== 094 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "smixq")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"smixq\")'::jsonpath" +== 095 +-- truncate_limit: 100 +select '$ ? (@ like_regex "pattern" flag "a")'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@ like_regex \"pattern\" flag \"a\")'::jsonpath" +== 096 +-- truncate_limit: 100 +select '$ < 1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ < 1'::jsonpath" +== 097 +-- truncate_limit: 100 +select '($ < 1) || $.a.b <= $x'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '($ < 1) || $.a.b <= $x'::jsonpath" +== 098 +-- truncate_limit: 100 +select '@ + 1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '@ + 1'::jsonpath" +== 099 +-- truncate_limit: 100 +select '($).a.b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '($).a.b'::jsonpath" +== 100 +-- truncate_limit: 100 +select '($.a.b).c.d'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '($.a.b).c.d'::jsonpath" +== 101 +-- truncate_limit: 100 +select '($.a.b + -$.x.y).c.d'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '($.a.b + -$.x.y).c.d'::jsonpath" +== 102 +-- truncate_limit: 100 +select '(-+$.a.b).c.d'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(-+$.a.b).c.d'::jsonpath" +== 103 +-- truncate_limit: 100 +select '1 + ($.a.b + 2).c.d'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 + ($.a.b + 2).c.d'::jsonpath" +== 104 +-- truncate_limit: 100 +select '1 + ($.a.b > 2).c.d'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 + ($.a.b > 2).c.d'::jsonpath" +== 105 +-- truncate_limit: 100 +select '($)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '($)'::jsonpath" +== 106 +-- truncate_limit: 100 +select '(($))'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(($))'::jsonpath" +== 107 +-- truncate_limit: 100 +select '((($ + 1)).a + ((2)).b ? ((((@ > 1)) || (exists(@.c)))))'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '((($ + 1)).a + ((2)).b ? ((((@ > 1)) || (exists(@.c)))))'::jsonpath" +== 108 +-- truncate_limit: 100 +select '$ ? (@.a < 1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 1)'::jsonpath" +== 109 +-- truncate_limit: 100 +select '$ ? (@.a < -1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -1)'::jsonpath" +== 110 +-- truncate_limit: 100 +select '$ ? (@.a < +1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +1)'::jsonpath" +== 111 +-- truncate_limit: 100 +select '$ ? (@.a < .1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < .1)'::jsonpath" +== 112 +-- truncate_limit: 100 +select '$ ? (@.a < -.1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -.1)'::jsonpath" +== 113 +-- truncate_limit: 100 +select '$ ? (@.a < +.1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +.1)'::jsonpath" +== 114 +-- truncate_limit: 100 +select '$ ? (@.a < 0.1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 0.1)'::jsonpath" +== 115 +-- truncate_limit: 100 +select '$ ? (@.a < -0.1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -0.1)'::jsonpath" +== 116 +-- truncate_limit: 100 +select '$ ? (@.a < +0.1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +0.1)'::jsonpath" +== 117 +-- truncate_limit: 100 +select '$ ? (@.a < 10.1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 10.1)'::jsonpath" +== 118 +-- truncate_limit: 100 +select '$ ? (@.a < -10.1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -10.1)'::jsonpath" +== 119 +-- truncate_limit: 100 +select '$ ? (@.a < +10.1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +10.1)'::jsonpath" +== 120 +-- truncate_limit: 100 +select '$ ? (@.a < 1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 1e1)'::jsonpath" +== 121 +-- truncate_limit: 100 +select '$ ? (@.a < -1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -1e1)'::jsonpath" +== 122 +-- truncate_limit: 100 +select '$ ? (@.a < +1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +1e1)'::jsonpath" +== 123 +-- truncate_limit: 100 +select '$ ? (@.a < .1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < .1e1)'::jsonpath" +== 124 +-- truncate_limit: 100 +select '$ ? (@.a < -.1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -.1e1)'::jsonpath" +== 125 +-- truncate_limit: 100 +select '$ ? (@.a < +.1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +.1e1)'::jsonpath" +== 126 +-- truncate_limit: 100 +select '$ ? (@.a < 0.1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 0.1e1)'::jsonpath" +== 127 +-- truncate_limit: 100 +select '$ ? (@.a < -0.1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -0.1e1)'::jsonpath" +== 128 +-- truncate_limit: 100 +select '$ ? (@.a < +0.1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +0.1e1)'::jsonpath" +== 129 +-- truncate_limit: 100 +select '$ ? (@.a < 10.1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 10.1e1)'::jsonpath" +== 130 +-- truncate_limit: 100 +select '$ ? (@.a < -10.1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -10.1e1)'::jsonpath" +== 131 +-- truncate_limit: 100 +select '$ ? (@.a < +10.1e1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +10.1e1)'::jsonpath" +== 132 +-- truncate_limit: 100 +select '$ ? (@.a < 1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 1e-1)'::jsonpath" +== 133 +-- truncate_limit: 100 +select '$ ? (@.a < -1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -1e-1)'::jsonpath" +== 134 +-- truncate_limit: 100 +select '$ ? (@.a < +1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +1e-1)'::jsonpath" +== 135 +-- truncate_limit: 100 +select '$ ? (@.a < .1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < .1e-1)'::jsonpath" +== 136 +-- truncate_limit: 100 +select '$ ? (@.a < -.1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -.1e-1)'::jsonpath" +== 137 +-- truncate_limit: 100 +select '$ ? (@.a < +.1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +.1e-1)'::jsonpath" +== 138 +-- truncate_limit: 100 +select '$ ? (@.a < 0.1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 0.1e-1)'::jsonpath" +== 139 +-- truncate_limit: 100 +select '$ ? (@.a < -0.1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -0.1e-1)'::jsonpath" +== 140 +-- truncate_limit: 100 +select '$ ? (@.a < +0.1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +0.1e-1)'::jsonpath" +== 141 +-- truncate_limit: 100 +select '$ ? (@.a < 10.1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 10.1e-1)'::jsonpath" +== 142 +-- truncate_limit: 100 +select '$ ? (@.a < -10.1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -10.1e-1)'::jsonpath" +== 143 +-- truncate_limit: 100 +select '$ ? (@.a < +10.1e-1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +10.1e-1)'::jsonpath" +== 144 +-- truncate_limit: 100 +select '$ ? (@.a < 1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 1e+1)'::jsonpath" +== 145 +-- truncate_limit: 100 +select '$ ? (@.a < -1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -1e+1)'::jsonpath" +== 146 +-- truncate_limit: 100 +select '$ ? (@.a < +1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +1e+1)'::jsonpath" +== 147 +-- truncate_limit: 100 +select '$ ? (@.a < .1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < .1e+1)'::jsonpath" +== 148 +-- truncate_limit: 100 +select '$ ? (@.a < -.1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -.1e+1)'::jsonpath" +== 149 +-- truncate_limit: 100 +select '$ ? (@.a < +.1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +.1e+1)'::jsonpath" +== 150 +-- truncate_limit: 100 +select '$ ? (@.a < 0.1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 0.1e+1)'::jsonpath" +== 151 +-- truncate_limit: 100 +select '$ ? (@.a < -0.1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -0.1e+1)'::jsonpath" +== 152 +-- truncate_limit: 100 +select '$ ? (@.a < +0.1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +0.1e+1)'::jsonpath" +== 153 +-- truncate_limit: 100 +select '$ ? (@.a < 10.1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < 10.1e+1)'::jsonpath" +== 154 +-- truncate_limit: 100 +select '$ ? (@.a < -10.1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < -10.1e+1)'::jsonpath" +== 155 +-- truncate_limit: 100 +select '$ ? (@.a < +10.1e+1)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '$ ? (@.a < +10.1e+1)'::jsonpath" +== 156 +-- truncate_limit: 100 +-- numeric literals + +select '0'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0'::jsonpath" +== 157 +-- truncate_limit: 100 +select '00'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '00'::jsonpath" +== 158 +-- truncate_limit: 100 +select '0755'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0755'::jsonpath" +== 159 +-- truncate_limit: 100 +select '0.0'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.0'::jsonpath" +== 160 +-- truncate_limit: 100 +select '0.000'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.000'::jsonpath" +== 161 +-- truncate_limit: 100 +select '0.000e1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.000e1'::jsonpath" +== 162 +-- truncate_limit: 100 +select '0.000e2'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.000e2'::jsonpath" +== 163 +-- truncate_limit: 100 +select '0.000e3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.000e3'::jsonpath" +== 164 +-- truncate_limit: 100 +select '0.0010'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.0010'::jsonpath" +== 165 +-- truncate_limit: 100 +select '0.0010e-1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.0010e-1'::jsonpath" +== 166 +-- truncate_limit: 100 +select '0.0010e+1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.0010e+1'::jsonpath" +== 167 +-- truncate_limit: 100 +select '0.0010e+2'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0.0010e+2'::jsonpath" +== 168 +-- truncate_limit: 100 +select '.001'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '.001'::jsonpath" +== 169 +-- truncate_limit: 100 +select '.001e1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '.001e1'::jsonpath" +== 170 +-- truncate_limit: 100 +select '1.'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.'::jsonpath" +== 171 +-- truncate_limit: 100 +select '1.e1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.e1'::jsonpath" +== 172 +-- truncate_limit: 100 +select '1a'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1a'::jsonpath" +== 173 +-- truncate_limit: 100 +select '1e'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1e'::jsonpath" +== 174 +-- truncate_limit: 100 +select '1.e'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.e'::jsonpath" +== 175 +-- truncate_limit: 100 +select '1.2a'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.2a'::jsonpath" +== 176 +-- truncate_limit: 100 +select '1.2e'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.2e'::jsonpath" +== 177 +-- truncate_limit: 100 +select '1.2.e'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.2.e'::jsonpath" +== 178 +-- truncate_limit: 100 +select '(1.2).e'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1.2).e'::jsonpath" +== 179 +-- truncate_limit: 100 +select '1e3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1e3'::jsonpath" +== 180 +-- truncate_limit: 100 +select '1.e3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.e3'::jsonpath" +== 181 +-- truncate_limit: 100 +select '1.e3.e'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.e3.e'::jsonpath" +== 182 +-- truncate_limit: 100 +select '1.e3.e4'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.e3.e4'::jsonpath" +== 183 +-- truncate_limit: 100 +select '1.2e3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.2e3'::jsonpath" +== 184 +-- truncate_limit: 100 +select '1.2e3a'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.2e3a'::jsonpath" +== 185 +-- truncate_limit: 100 +select '1.2.e3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1.2.e3'::jsonpath" +== 186 +-- truncate_limit: 100 +select '(1.2).e3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1.2).e3'::jsonpath" +== 187 +-- truncate_limit: 100 +select '1..e'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1..e'::jsonpath" +== 188 +-- truncate_limit: 100 +select '1..e3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1..e3'::jsonpath" +== 189 +-- truncate_limit: 100 +select '(1.).e'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1.).e'::jsonpath" +== 190 +-- truncate_limit: 100 +select '(1.).e3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1.).e3'::jsonpath" +== 191 +-- truncate_limit: 100 +select '1?(2>3)'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1?(2>3)'::jsonpath" +== 192 +-- truncate_limit: 100 +-- nondecimal +select '0b100101'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b100101'::jsonpath" +== 193 +-- truncate_limit: 100 +select '0o273'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o273'::jsonpath" +== 194 +-- truncate_limit: 100 +select '0x42F'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x42F'::jsonpath" +== 195 +-- truncate_limit: 100 +-- error cases +select '0b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b'::jsonpath" +== 196 +-- truncate_limit: 100 +select '1b'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1b'::jsonpath" +== 197 +-- truncate_limit: 100 +select '0b0x'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b0x'::jsonpath" +== 198 +-- truncate_limit: 100 +select '0o'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o'::jsonpath" +== 199 +-- truncate_limit: 100 +select '1o'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1o'::jsonpath" +== 200 +-- truncate_limit: 100 +select '0o0x'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o0x'::jsonpath" +== 201 +-- truncate_limit: 100 +select '0x'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x'::jsonpath" +== 202 +-- truncate_limit: 100 +select '1x'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1x'::jsonpath" +== 203 +-- truncate_limit: 100 +select '0x0y'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x0y'::jsonpath" +== 204 +-- truncate_limit: 100 +-- underscores +select '1_000_000'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000_000'::jsonpath" +== 205 +-- truncate_limit: 100 +select '1_2_3'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_2_3'::jsonpath" +== 206 +-- truncate_limit: 100 +select '0x1EEE_FFFF'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x1EEE_FFFF'::jsonpath" +== 207 +-- truncate_limit: 100 +select '0o2_73'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o2_73'::jsonpath" +== 208 +-- truncate_limit: 100 +select '0b10_0101'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b10_0101'::jsonpath" +== 209 +-- truncate_limit: 100 +select '1_000.000_005'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000.000_005'::jsonpath" +== 210 +-- truncate_limit: 100 +select '1_000.'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000.'::jsonpath" +== 211 +-- truncate_limit: 100 +select '.000_005'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '.000_005'::jsonpath" +== 212 +-- truncate_limit: 100 +select '1_000.5e0_1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000.5e0_1'::jsonpath" +== 213 +-- truncate_limit: 100 +-- error cases +select '_100'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '_100'::jsonpath" +== 214 +-- truncate_limit: 100 +select '100_'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100_'::jsonpath" +== 215 +-- truncate_limit: 100 +select '100__000'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '100__000'::jsonpath" +== 216 +-- truncate_limit: 100 +select '_1_000.5'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '_1_000.5'::jsonpath" +== 217 +-- truncate_limit: 100 +select '1_000_.5'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000_.5'::jsonpath" +== 218 +-- truncate_limit: 100 +select '1_000._5'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000._5'::jsonpath" +== 219 +-- truncate_limit: 100 +select '1_000.5_'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000.5_'::jsonpath" +== 220 +-- truncate_limit: 100 +select '1_000.5e_1'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1_000.5e_1'::jsonpath" +== 221 +-- truncate_limit: 100 +-- underscore after prefix not allowed in JavaScript (but allowed in SQL) +select '0b_10_0101'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0b_10_0101'::jsonpath" +== 222 +-- truncate_limit: 100 +select '0o_273'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0o_273'::jsonpath" +== 223 +-- truncate_limit: 100 +select '0x_42F'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0x_42F'::jsonpath" +== 224 +-- truncate_limit: 100 +-- test non-error-throwing API + +SELECT str as jsonpath, + pg_input_is_valid(str,'jsonpath') as ok, + errinfo.sql_error_code, + errinfo.message, + errinfo.detail, + errinfo.hint +FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text, + '$ ? (@ like_regex "pattern" flag "a")', + '@ + 1', + '00', + '1a']) str, + LATERAL pg_input_error_info(str, 'jsonpath') as errinfo +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY['$ ? (@ like_regex \"pattern\" flag \"smixq\")'::text, '$ ? (@ like_rege..." diff --git a/parser/testdata/summary_truncate/postgres_regress/jsonpath_encoding.metadata.json b/parser/testdata/summary_truncate/postgres_regress/jsonpath_encoding.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/jsonpath_encoding.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/jsonpath_encoding.test b/parser/testdata/summary_truncate/postgres_regress/jsonpath_encoding.test new file mode 100644 index 0000000..e9069c5 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/jsonpath_encoding.test @@ -0,0 +1,235 @@ +== 001 +-- truncate_limit: 100 +|-- +-- encoding-sensitive tests for jsonpath +|-- + +-- We provide expected-results files for UTF8 (jsonpath_encoding.out) +-- and for SQL_ASCII (jsonpath_encoding_1.out). Skip otherwise. +SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') + AS skip_test +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT getdatabaseencoding() NOT IN ('UTF8', 'SQL_ASCII') AS skip_test" +== 002 +-- truncate_limit: 100 +SELECT getdatabaseencoding() +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT getdatabaseencoding()" +== 003 +-- truncate_limit: 100 +-- just to label the results files + +-- checks for double-quoted values + +-- basic unicode input +SELECT '"\u"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u\"'::jsonpath" +== 004 +-- truncate_limit: 100 +-- ERROR, incomplete escape +SELECT '"\u00"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u00\"'::jsonpath" +== 005 +-- truncate_limit: 100 +-- ERROR, incomplete escape +SELECT '"\u000g"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u000g\"'::jsonpath" +== 006 +-- truncate_limit: 100 +-- ERROR, g is not a hex digit +SELECT '"\u0000"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\u0000\"'::jsonpath" +== 007 +-- truncate_limit: 100 +-- OK, legal escape +SELECT '"\uaBcD"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\uaBcD\"'::jsonpath" +== 008 +-- truncate_limit: 100 +-- OK, uppercase and lower case both OK + +-- handling of unicode surrogate pairs +select '"\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\ud83d\\\\ude04\\\\ud83d\\\\udc36\"'::jsonpath AS correct_in_utf8" +== 009 +-- truncate_limit: 100 +select '"\ud83d\ud83d"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\ud83d\\\\ud83d\"'::jsonpath" +== 010 +-- truncate_limit: 100 +-- 2 high surrogates in a row +select '"\ude04\ud83d"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\ude04\\\\ud83d\"'::jsonpath" +== 011 +-- truncate_limit: 100 +-- surrogates in wrong order +select '"\ud83dX"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\ud83dX\"'::jsonpath" +== 012 +-- truncate_limit: 100 +-- orphan high surrogate +select '"\ude04X"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"\\\\ude04X\"'::jsonpath" +== 013 +-- truncate_limit: 100 +-- orphan low surrogate + +--handling of simple unicode escapes +select '"the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"the Copyright \\\\u00a9 sign\"'::jsonpath AS correct_in_utf8" +== 014 +-- truncate_limit: 100 +select '"dollar \u0024 character"'::jsonpath as correct_everywhere +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"dollar \\\\u0024 character\"'::jsonpath AS correct_everywhere" +== 015 +-- truncate_limit: 100 +select '"dollar \\u0024 character"'::jsonpath as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"dollar \\\\\\\\u0024 character\"'::jsonpath AS not_an_escape" +== 016 +-- truncate_limit: 100 +select '"null \u0000 escape"'::jsonpath as not_unescaped +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"null \\\\u0000 escape\"'::jsonpath AS not_unescaped" +== 017 +-- truncate_limit: 100 +select '"null \\u0000 escape"'::jsonpath as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\"null \\\\\\\\u0000 escape\"'::jsonpath AS not_an_escape" +== 018 +-- truncate_limit: 100 +-- checks for quoted key names + +-- basic unicode input +SELECT '$."\u"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\u\"'::jsonpath" +== 019 +-- truncate_limit: 100 +-- ERROR, incomplete escape +SELECT '$."\u00"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\u00\"'::jsonpath" +== 020 +-- truncate_limit: 100 +-- ERROR, incomplete escape +SELECT '$."\u000g"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\u000g\"'::jsonpath" +== 021 +-- truncate_limit: 100 +-- ERROR, g is not a hex digit +SELECT '$."\u0000"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\u0000\"'::jsonpath" +== 022 +-- truncate_limit: 100 +-- OK, legal escape +SELECT '$."\uaBcD"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\uaBcD\"'::jsonpath" +== 023 +-- truncate_limit: 100 +-- OK, uppercase and lower case both OK + +-- handling of unicode surrogate pairs +select '$."\ud83d\ude04\ud83d\udc36"'::jsonpath as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\ud83d\\\\ude04\\\\ud83d\\\\udc36\"'::jsonpath AS correct_in_utf8" +== 024 +-- truncate_limit: 100 +select '$."\ud83d\ud83d"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\ud83d\\\\ud83d\"'::jsonpath" +== 025 +-- truncate_limit: 100 +-- 2 high surrogates in a row +select '$."\ude04\ud83d"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\ude04\\\\ud83d\"'::jsonpath" +== 026 +-- truncate_limit: 100 +-- surrogates in wrong order +select '$."\ud83dX"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\ud83dX\"'::jsonpath" +== 027 +-- truncate_limit: 100 +-- orphan high surrogate +select '$."\ude04X"'::jsonpath +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"\\\\ude04X\"'::jsonpath" +== 028 +-- truncate_limit: 100 +-- orphan low surrogate + +--handling of simple unicode escapes +select '$."the Copyright \u00a9 sign"'::jsonpath as correct_in_utf8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"the Copyright \\\\u00a9 sign\"'::jsonpath AS correct_in_utf8" +== 029 +-- truncate_limit: 100 +select '$."dollar \u0024 character"'::jsonpath as correct_everywhere +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"dollar \\\\u0024 character\"'::jsonpath AS correct_everywhere" +== 030 +-- truncate_limit: 100 +select '$."dollar \\u0024 character"'::jsonpath as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"dollar \\\\\\\\u0024 character\"'::jsonpath AS not_an_escape" +== 031 +-- truncate_limit: 100 +select '$."null \u0000 escape"'::jsonpath as not_unescaped +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"null \\\\u0000 escape\"'::jsonpath AS not_unescaped" +== 032 +-- truncate_limit: 100 +select '$."null \\u0000 escape"'::jsonpath as not_an_escape +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'$.\"null \\\\\\\\u0000 escape\"'::jsonpath AS not_an_escape" diff --git a/parser/testdata/summary_truncate/postgres_regress/largeobject.metadata.json b/parser/testdata/summary_truncate/postgres_regress/largeobject.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/largeobject.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/largeobject.test b/parser/testdata/summary_truncate/postgres_regress/largeobject.test new file mode 100644 index 0000000..e16546b --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/largeobject.test @@ -0,0 +1,996 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test large object support +|-- + +-- directory paths are passed to us in environment variables + +-- ensure consistent test output regardless of the default bytea format +SET bytea_output TO escape +-- +STMT: VariableSetStmt +TRUNCATED: "SET bytea_output TO escape" +== 002 +-- truncate_limit: 100 +-- Test ALTER LARGE OBJECT OWNER +CREATE ROLE regress_lo_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_lo_user" +== 003 +-- truncate_limit: 100 +SELECT lo_create(42) +-- +FUNCTION: name="lo_create" function="lo_create" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_create(42)" +== 004 +-- truncate_limit: 100 +ALTER LARGE OBJECT 42 OWNER TO regress_lo_user +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER LARGE OBJECT 42 OWNER TO regress_lo_user" +== 005 +-- truncate_limit: 100 +-- Test GRANT, COMMENT as non-superuser +SET SESSION AUTHORIZATION regress_lo_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_lo_user" +== 006 +-- truncate_limit: 100 +GRANT SELECT ON LARGE OBJECT 42 TO public +-- +STMT: GrantStmt +TRUNCATED: "GRANT select ON LARGE OBJECT 42 TO public" +== 007 +-- truncate_limit: 100 +COMMENT ON LARGE OBJECT 42 IS 'the ultimate answer' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON LARGE OBJECT 42 IS 'the ultimate answer'" +== 008 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 009 +-- truncate_limit: 100 +-- Test psql's \lo_list et al (we assume no other LOs exist yet) + +-- Load a file +CREATE TABLE lotest_stash_values (loid oid, fd integer) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lotest_stash_values (loid oid, fd int)" +== 010 +-- truncate_limit: 100 +-- lo_creat(mode integer) returns oid +-- The mode arg to lo_creat is unused, some vestigal holdover from ancient times +-- returns the large object id +INSERT INTO lotest_stash_values (loid) SELECT lo_creat(42) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_creat" function="lo_creat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lotest_stash_values (loid) SELECT lo_creat(42)" +== 011 +-- truncate_limit: 100 +-- NOTE: large objects require transactions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 012 +-- truncate_limit: 100 +-- lo_open(lobjId oid, mode integer) returns integer +-- The mode parameter to lo_open uses two constants: +-- INV_WRITE = 0x20000 +-- INV_READ = 0x40000 +-- The return value is a file descriptor-like value which remains valid for the +-- transaction. +UPDATE lotest_stash_values SET fd = lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE lotest_stash_values SET fd = lo_open(loid, (x'20000' | x'40000')::int)" +== 013 +-- truncate_limit: 100 +-- loread/lowrite names are wonky, different from other functions which are lo_* +-- lowrite(fd integer, data bytea) returns integer +-- the integer is the number of bytes written +SELECT lowrite(fd, ' +I wandered lonely as a cloud +That floats on high o''er vales and hills, +When all at once I saw a crowd, +A host, of golden daffodils; +Beside the lake, beneath the trees, +Fluttering and dancing in the breeze. + +Continuous as the stars that shine +And twinkle on the milky way, +They stretched in never-ending line +Along the margin of a bay: +Ten thousand saw I at a glance, +Tossing their heads in sprightly dance. + +The waves beside them danced; but they +Out-did the sparkling waves in glee: +A poet could not but be gay, +In such a jocund company: +I gazed--and gazed--but little thought +What wealth the show to me had brought: + +For oft, when on my couch I lie +In vacant or in pensive mood, +They flash upon that inward eye +Which is the bliss of solitude; +And then my heart with pleasure fills, +And dances with the daffodils. + + -- William Wordsworth +') FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM lotest_stash_values" +== 014 +-- truncate_limit: 100 +-- lo_close(fd integer) returns integer +-- return value is 0 for success, or <0 for error (actually only -1, but...) +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_close(fd) FROM lotest_stash_values" +== 015 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 016 +-- truncate_limit: 100 +-- Copy to another large object. +-- Note: we intentionally don't remove the object created here; +-- it's left behind to help test pg_dump. + +SELECT lo_from_bytea(0, lo_get(loid)) AS newloid FROM lotest_stash_values + +-- Add a comment to it, as well, for pg_dump/pg_upgrade testing. +COMMENT ON LARGE OBJECT :newloid IS 'I Wandered Lonely as a Cloud' +-- +ERROR: syntax error at or near "ON" +CURSORPOS: 289 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 017 +-- truncate_limit: 100 +-- Read out a portion +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 018 +-- truncate_limit: 100 +UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE lotest_stash_values SET fd = lo_open(loid, (x'20000' | x'40000')::int)" +== 019 +-- truncate_limit: 100 +-- lo_lseek(fd integer, offset integer, whence integer) returns integer +-- offset is in bytes, whence is one of three values: +-- SEEK_SET (= 0) meaning relative to beginning +-- SEEK_CUR (= 1) meaning relative to current position +-- SEEK_END (= 2) meaning relative to end (offset better be negative) +-- returns current position in file +SELECT lo_lseek(fd, 104, 0) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, 104, 0) FROM lotest_stash_values" +== 020 +-- truncate_limit: 100 +-- loread/lowrite names are wonky, different from other functions which are lo_* +-- loread(fd integer, len integer) returns bytea +SELECT loread(fd, 28) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT loread(fd, 28) FROM lotest_stash_values" +== 021 +-- truncate_limit: 100 +SELECT lo_lseek(fd, -19, 1) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, -19, 1) FROM lotest_stash_values" +== 022 +-- truncate_limit: 100 +SELECT lowrite(fd, 'n') FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lowrite(fd, 'n') FROM lotest_stash_values" +== 023 +-- truncate_limit: 100 +SELECT lo_tell(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell" function="lo_tell" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_tell(fd) FROM lotest_stash_values" +== 024 +-- truncate_limit: 100 +SELECT lo_lseek(fd, -744, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, -744, 2) FROM lotest_stash_values" +== 025 +-- truncate_limit: 100 +SELECT loread(fd, 28) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT loread(fd, 28) FROM lotest_stash_values" +== 026 +-- truncate_limit: 100 +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_close(fd) FROM lotest_stash_values" +== 027 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 028 +-- truncate_limit: 100 +-- Test resource management +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 029 +-- truncate_limit: 100 +SELECT lo_open(loid, x'40000'::int) from lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_open(loid, x'40000'::int) FROM lotest_stash_values" +== 030 +-- truncate_limit: 100 +ABORT +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 031 +-- truncate_limit: 100 +DO :'dobody' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 4 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 032 +-- truncate_limit: 100 +-- Test truncation. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 033 +-- truncate_limit: 100 +UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE lotest_stash_values SET fd = lo_open(loid, (x'20000' | x'40000')::int)" +== 034 +-- truncate_limit: 100 +SELECT lo_truncate(fd, 11) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate" function="lo_truncate" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_truncate(fd, 11) FROM lotest_stash_values" +== 035 +-- truncate_limit: 100 +SELECT loread(fd, 15) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT loread(fd, 15) FROM lotest_stash_values" +== 036 +-- truncate_limit: 100 +SELECT lo_truncate(fd, 10000) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate" function="lo_truncate" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_truncate(fd, 10000) FROM lotest_stash_values" +== 037 +-- truncate_limit: 100 +SELECT loread(fd, 10) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT loread(fd, 10) FROM lotest_stash_values" +== 038 +-- truncate_limit: 100 +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values" +== 039 +-- truncate_limit: 100 +SELECT lo_tell(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell" function="lo_tell" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_tell(fd) FROM lotest_stash_values" +== 040 +-- truncate_limit: 100 +SELECT lo_truncate(fd, 5000) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate" function="lo_truncate" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_truncate(fd, 5000) FROM lotest_stash_values" +== 041 +-- truncate_limit: 100 +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values" +== 042 +-- truncate_limit: 100 +SELECT lo_tell(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell" function="lo_tell" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_tell(fd) FROM lotest_stash_values" +== 043 +-- truncate_limit: 100 +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_close(fd) FROM lotest_stash_values" +== 044 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 045 +-- truncate_limit: 100 +-- Test 64-bit large object functions. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 046 +-- truncate_limit: 100 +UPDATE lotest_stash_values SET fd = lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE lotest_stash_values SET fd = lo_open(loid, (x'20000' | x'40000')::int)" +== 047 +-- truncate_limit: 100 +SELECT lo_lseek64(fd, 4294967296, 0) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek64" function="lo_lseek64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek64(fd, 4294967296, 0) FROM lotest_stash_values" +== 048 +-- truncate_limit: 100 +SELECT lowrite(fd, 'offset:4GB') FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lowrite(fd, 'offset:4GB') FROM lotest_stash_values" +== 049 +-- truncate_limit: 100 +SELECT lo_tell64(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell64" function="lo_tell64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_tell64(fd) FROM lotest_stash_values" +== 050 +-- truncate_limit: 100 +SELECT lo_lseek64(fd, -10, 1) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek64" function="lo_lseek64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek64(fd, -10, 1) FROM lotest_stash_values" +== 051 +-- truncate_limit: 100 +SELECT lo_tell64(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell64" function="lo_tell64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_tell64(fd) FROM lotest_stash_values" +== 052 +-- truncate_limit: 100 +SELECT loread(fd, 10) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT loread(fd, 10) FROM lotest_stash_values" +== 053 +-- truncate_limit: 100 +SELECT lo_truncate64(fd, 5000000000) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate64" function="lo_truncate64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_truncate64(fd, 5000000000) FROM lotest_stash_values" +== 054 +-- truncate_limit: 100 +SELECT lo_lseek64(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek64" function="lo_lseek64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek64(fd, 0, 2) FROM lotest_stash_values" +== 055 +-- truncate_limit: 100 +SELECT lo_tell64(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell64" function="lo_tell64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_tell64(fd) FROM lotest_stash_values" +== 056 +-- truncate_limit: 100 +SELECT lo_truncate64(fd, 3000000000) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_truncate64" function="lo_truncate64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_truncate64(fd, 3000000000) FROM lotest_stash_values" +== 057 +-- truncate_limit: 100 +SELECT lo_lseek64(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek64" function="lo_lseek64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek64(fd, 0, 2) FROM lotest_stash_values" +== 058 +-- truncate_limit: 100 +SELECT lo_tell64(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell64" function="lo_tell64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_tell64(fd) FROM lotest_stash_values" +== 059 +-- truncate_limit: 100 +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_close(fd) FROM lotest_stash_values" +== 060 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 061 +-- truncate_limit: 100 +-- lo_unlink(lobjId oid) returns integer +-- return value appears to always be 1 +SELECT lo_unlink(loid) from lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_unlink" function="lo_unlink" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_unlink(loid) FROM lotest_stash_values" +== 062 +-- truncate_limit: 100 +TRUNCATE lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE lotest_stash_values" +== 063 +-- truncate_limit: 100 +INSERT INTO lotest_stash_values (loid) SELECT lo_import(:'filename') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 064 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 065 +-- truncate_limit: 100 +UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)) +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DML +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE lotest_stash_values SET fd = lo_open(loid, (x'20000' | x'40000')::int)" +== 066 +-- truncate_limit: 100 +-- verify length of large object +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values" +== 067 +-- truncate_limit: 100 +-- with the default BLCKSZ, LOBLKSIZE = 2048, so this positions us for a block +-- edge case +SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values" +== 068 +-- truncate_limit: 100 +-- this should get half of the value from page 0 and half from page 1 of the +-- large object +SELECT loread(fd, 36) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT loread(fd, 36) FROM lotest_stash_values" +== 069 +-- truncate_limit: 100 +SELECT lo_tell(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_tell" function="lo_tell" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_tell(fd) FROM lotest_stash_values" +== 070 +-- truncate_limit: 100 +SELECT lo_lseek(fd, -26, 1) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, -26, 1) FROM lotest_stash_values" +== 071 +-- truncate_limit: 100 +SELECT lowrite(fd, 'abcdefghijklmnop') FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lowrite(fd, 'abcdefghijklmnop') FROM lotest_stash_values" +== 072 +-- truncate_limit: 100 +SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_lseek" function="lo_lseek" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values" +== 073 +-- truncate_limit: 100 +SELECT loread(fd, 36) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="loread" function="loread" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT loread(fd, 36) FROM lotest_stash_values" +== 074 +-- truncate_limit: 100 +SELECT lo_close(fd) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_close" function="lo_close" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_close(fd) FROM lotest_stash_values" +== 075 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 076 +-- truncate_limit: 100 +SELECT lo_export(loid, :'filename') FROM lotest_stash_values +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 077 +-- truncate_limit: 100 +-- just make sure \lo_export does not barf + +-- This is a hack to test that export/import are reversible +-- This uses knowledge about the inner workings of large object mechanism +-- which should not be used outside it. This makes it a HACK +SELECT pageno, data FROM pg_largeobject WHERE loid = (SELECT loid from lotest_stash_values) +EXCEPT +SELECT pageno, data FROM pg_largeobject WHERE loid = :newloid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 393 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 078 +-- truncate_limit: 100 +SELECT lo_unlink(loid) FROM lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=Select +FUNCTION: name="lo_unlink" function="lo_unlink" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_unlink(loid) FROM lotest_stash_values" +== 079 +-- truncate_limit: 100 +TRUNCATE lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE lotest_stash_values" +== 080 +-- truncate_limit: 100 +SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2 + +SELECT fipshash(lo_get(:newloid_1)) = fipshash(lo_get(:newloid_2)) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 081 +-- truncate_limit: 100 +SELECT lo_get(:newloid_1, 0, 20) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 082 +-- truncate_limit: 100 +SELECT lo_get(:newloid_1, 10, 20) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 083 +-- truncate_limit: 100 +SELECT lo_put(:newloid_1, 5, decode('afafafaf', 'hex')) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 084 +-- truncate_limit: 100 +SELECT lo_get(:newloid_1, 0, 20) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 085 +-- truncate_limit: 100 +SELECT lo_put(:newloid_1, 4294967310, 'foo') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 086 +-- truncate_limit: 100 +SELECT lo_get(:newloid_1) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 087 +-- truncate_limit: 100 +SELECT lo_get(:newloid_1, 4294967294, 100) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 088 +-- truncate_limit: 100 +-- This object is left in the database for pg_dump test purposes +SELECT lo_from_bytea(0, E'\\xdeadbeef') AS newloid + +SET bytea_output TO hex +-- +ERROR: syntax error at or near "SET" +CURSORPOS: 118 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 089 +-- truncate_limit: 100 +SELECT lo_get(:newloid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 090 +-- truncate_limit: 100 +-- Create one more object that we leave behind for testing pg_dump/pg_upgrade; +-- this one intentionally has an OID in the system range +SELECT lo_create(2121) +-- +FUNCTION: name="lo_create" function="lo_create" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_create(2121)" +== 091 +-- truncate_limit: 100 +COMMENT ON LARGE OBJECT 2121 IS 'testing comments' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON LARGE OBJECT 2121 IS 'testing comments'" +== 092 +-- truncate_limit: 100 +-- Test writes on large objects in read-only transactions +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 093 +-- truncate_limit: 100 +-- INV_READ ... ok +SELECT lo_open(2121, x'40000'::int) +-- +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_open(2121, x'40000'::int)" +== 094 +-- truncate_limit: 100 +-- INV_WRITE ... error +SELECT lo_open(2121, x'20000'::int) +-- +FUNCTION: name="lo_open" function="lo_open" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_open(2121, x'20000'::int)" +== 095 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 096 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 097 +-- truncate_limit: 100 +SELECT lo_create(42) +-- +FUNCTION: name="lo_create" function="lo_create" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_create(42)" +== 098 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 099 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 100 +-- truncate_limit: 100 +SELECT lo_creat(42) +-- +FUNCTION: name="lo_creat" function="lo_creat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_creat(42)" +== 101 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 102 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 103 +-- truncate_limit: 100 +SELECT lo_unlink(42) +-- +FUNCTION: name="lo_unlink" function="lo_unlink" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_unlink(42)" +== 104 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 105 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 106 +-- truncate_limit: 100 +SELECT lowrite(42, 'x') +-- +FUNCTION: name="lowrite" function="lowrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lowrite(42, 'x')" +== 107 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 108 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 109 +-- truncate_limit: 100 +SELECT lo_import(:'filename') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 18 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 110 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 111 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 112 +-- truncate_limit: 100 +SELECT lo_truncate(42, 0) +-- +FUNCTION: name="lo_truncate" function="lo_truncate" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_truncate(42, 0)" +== 113 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 114 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 115 +-- truncate_limit: 100 +SELECT lo_truncate64(42, 0) +-- +FUNCTION: name="lo_truncate64" function="lo_truncate64" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_truncate64(42, 0)" +== 116 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 117 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 118 +-- truncate_limit: 100 +SELECT lo_from_bytea(0, 'x') +-- +FUNCTION: name="lo_from_bytea" function="lo_from_bytea" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_from_bytea(0, 'x')" +== 119 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 120 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 121 +-- truncate_limit: 100 +SELECT lo_put(42, 0, 'x') +-- +FUNCTION: name="lo_put" function="lo_put" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lo_put(42, 0, 'x')" +== 122 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 123 +-- truncate_limit: 100 +-- Clean up +DROP TABLE lotest_stash_values +-- +TABLE: name="lotest_stash_values" schema="" table="lotest_stash_values" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lotest_stash_values" +== 124 +-- truncate_limit: 100 +DROP ROLE regress_lo_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_lo_user" diff --git a/parser/testdata/summary_truncate/postgres_regress/limit.metadata.json b/parser/testdata/summary_truncate/postgres_regress/limit.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/limit.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/limit.test b/parser/testdata/summary_truncate/postgres_regress/limit.test new file mode 100644 index 0000000..60320e4 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/limit.test @@ -0,0 +1,667 @@ +== 001 +-- truncate_limit: 100 +|-- +-- LIMIT +-- Check the LIMIT/OFFSET feature of SELECT +|-- + +SELECT ''::text AS two, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 50 + ORDER BY unique1 LIMIT 2 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE unique1 > 50 ORDER BY unique1 LIMIT 2" +== 002 +-- truncate_limit: 100 +SELECT ''::text AS five, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 60 + ORDER BY unique1 LIMIT 5 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE unique1 > 60 ORDER BY unique1 LIMIT 5" +== 003 +-- truncate_limit: 100 +SELECT ''::text AS two, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 60 AND unique1 < 63 + ORDER BY unique1 LIMIT 5 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE unique1 > 60 AND unique1 < 63 ORDER BY unique1 LIMIT 5" +== 004 +-- truncate_limit: 100 +SELECT ''::text AS three, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 100 + ORDER BY unique1 LIMIT 3 OFFSET 20 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE unique1 > 100 ORDER BY unique1 LIMIT 3 OFFSET 20" +== 005 +-- truncate_limit: 100 +SELECT ''::text AS zero, unique1, unique2, stringu1 + FROM onek WHERE unique1 < 50 + ORDER BY unique1 DESC LIMIT 8 OFFSET 99 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE unique1 < 50 ORDER BY unique1 DESC LIMIT 8 OFFSET 99" +== 006 +-- truncate_limit: 100 +SELECT ''::text AS eleven, unique1, unique2, stringu1 + FROM onek WHERE unique1 < 50 + ORDER BY unique1 DESC LIMIT 20 OFFSET 39 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE unique1 < 50 ORDER BY unique1 DESC LIMIT 20 OFFSET 39" +== 007 +-- truncate_limit: 100 +SELECT ''::text AS ten, unique1, unique2, stringu1 + FROM onek + ORDER BY unique1 OFFSET 990 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ''::text AS ten, unique1, unique2, stringu1 FROM onek ORDER BY unique1 OFFSET 990" +== 008 +-- truncate_limit: 100 +SELECT ''::text AS five, unique1, unique2, stringu1 + FROM onek + ORDER BY unique1 OFFSET 990 LIMIT 5 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ''::text AS five, unique1, unique2, stringu1 FROM onek ORDER BY unique1 LIMIT 5 OFFSET 990" +== 009 +-- truncate_limit: 100 +SELECT ''::text AS five, unique1, unique2, stringu1 + FROM onek + ORDER BY unique1 LIMIT 5 OFFSET 900 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ''::text AS five, unique1, unique2, stringu1 FROM onek ORDER BY unique1 LIMIT 5 OFFSET 900" +== 010 +-- truncate_limit: 100 +-- Test null limit and offset. The planner would discard a simple null +-- constant, so to ensure executor is exercised, do this: +select * from int8_tbl limit (case when random() < 0.5 then null::bigint end) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl LIMIT CASE WHEN random() < 0.5 THEN NULL::bigint END" +== 011 +-- truncate_limit: 100 +select * from int8_tbl offset (case when random() < 0.5 then null::bigint end) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl OFFSET CASE WHEN random() < 0.5 THEN NULL::bigint END" +== 012 +-- truncate_limit: 100 +-- Test assorted cases involving backwards fetch from a LIMIT plan node +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 013 +-- truncate_limit: 100 +declare c1 cursor for select * from int8_tbl limit 10 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM int8_tbl LIMIT 10" +== 014 +-- truncate_limit: 100 +fetch all in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c1" +== 015 +-- truncate_limit: 100 +fetch 1 in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 016 +-- truncate_limit: 100 +fetch backward 1 in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c1" +== 017 +-- truncate_limit: 100 +fetch backward all in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c1" +== 018 +-- truncate_limit: 100 +fetch backward 1 in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c1" +== 019 +-- truncate_limit: 100 +fetch all in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c1" +== 020 +-- truncate_limit: 100 +declare c2 cursor for select * from int8_tbl limit 3 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c2 CURSOR FOR SELECT * FROM int8_tbl LIMIT 3" +== 021 +-- truncate_limit: 100 +fetch all in c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c2" +== 022 +-- truncate_limit: 100 +fetch 1 in c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c2" +== 023 +-- truncate_limit: 100 +fetch backward 1 in c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c2" +== 024 +-- truncate_limit: 100 +fetch backward all in c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c2" +== 025 +-- truncate_limit: 100 +fetch backward 1 in c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c2" +== 026 +-- truncate_limit: 100 +fetch all in c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c2" +== 027 +-- truncate_limit: 100 +declare c3 cursor for select * from int8_tbl offset 3 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c3 CURSOR FOR SELECT * FROM int8_tbl OFFSET 3" +== 028 +-- truncate_limit: 100 +fetch all in c3 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c3" +== 029 +-- truncate_limit: 100 +fetch 1 in c3 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c3" +== 030 +-- truncate_limit: 100 +fetch backward 1 in c3 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c3" +== 031 +-- truncate_limit: 100 +fetch backward all in c3 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c3" +== 032 +-- truncate_limit: 100 +fetch backward 1 in c3 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c3" +== 033 +-- truncate_limit: 100 +fetch all in c3 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c3" +== 034 +-- truncate_limit: 100 +declare c4 cursor for select * from int8_tbl offset 10 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c4 CURSOR FOR SELECT * FROM int8_tbl OFFSET 10" +== 035 +-- truncate_limit: 100 +fetch all in c4 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c4" +== 036 +-- truncate_limit: 100 +fetch 1 in c4 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c4" +== 037 +-- truncate_limit: 100 +fetch backward 1 in c4 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c4" +== 038 +-- truncate_limit: 100 +fetch backward all in c4 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c4" +== 039 +-- truncate_limit: 100 +fetch backward 1 in c4 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c4" +== 040 +-- truncate_limit: 100 +fetch all in c4 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c4" +== 041 +-- truncate_limit: 100 +declare c5 cursor for select * from int8_tbl order by q1 fetch first 2 rows with ties +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c5 CURSOR FOR SELECT * FROM int8_tbl ORDER BY q1 FETCH FIRST 2 ROWS WITH TIES" +== 042 +-- truncate_limit: 100 +fetch all in c5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c5" +== 043 +-- truncate_limit: 100 +fetch 1 in c5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c5" +== 044 +-- truncate_limit: 100 +fetch backward 1 in c5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c5" +== 045 +-- truncate_limit: 100 +fetch backward 1 in c5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c5" +== 046 +-- truncate_limit: 100 +fetch all in c5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c5" +== 047 +-- truncate_limit: 100 +fetch backward all in c5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c5" +== 048 +-- truncate_limit: 100 +fetch all in c5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c5" +== 049 +-- truncate_limit: 100 +fetch backward all in c5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c5" +== 050 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 051 +-- truncate_limit: 100 +-- Stress test for variable LIMIT in conjunction with bounded-heap sorting + +SELECT + (SELECT n + FROM (VALUES (1)) AS x, + (SELECT n FROM generate_series(1,10) AS n + ORDER BY n LIMIT 1 OFFSET s-1) AS y) AS z + FROM generate_series(1,10) AS s +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 10) s" +== 052 +-- truncate_limit: 100 +|-- +-- Test behavior of volatile and set-returning functions in conjunction +-- with ORDER BY and LIMIT. +|-- + +create temp sequence testseq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE testseq" +== 053 +-- truncate_limit: 100 +explain (verbose, costs off) +select unique1, unique2, nextval('testseq') + from tenk1 order by unique2 limit 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT unique1, unique2, nextval('testseq') FROM tenk1 ORDER BY uniq..." +== 054 +-- truncate_limit: 100 +select unique1, unique2, nextval('testseq') + from tenk1 order by unique2 limit 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2, nextval('testseq') FROM tenk1 ORDER BY unique2 LIMIT 10" +== 055 +-- truncate_limit: 100 +select currval('testseq') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currval('testseq')" +== 056 +-- truncate_limit: 100 +explain (verbose, costs off) +select unique1, unique2, nextval('testseq') + from tenk1 order by tenthous limit 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT unique1, unique2, nextval('testseq') FROM tenk1 ORDER BY tent..." +== 057 +-- truncate_limit: 100 +select unique1, unique2, nextval('testseq') + from tenk1 order by tenthous limit 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2, nextval('testseq') FROM tenk1 ORDER BY tenthous LIMIT 10" +== 058 +-- truncate_limit: 100 +select currval('testseq') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currval('testseq')" +== 059 +-- truncate_limit: 100 +explain (verbose, costs off) +select unique1, unique2, generate_series(1,10) + from tenk1 order by unique2 limit 7 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT unique1, unique2, generate_series(1, 10) FROM tenk1 ORDER BY ..." +== 060 +-- truncate_limit: 100 +select unique1, unique2, generate_series(1,10) + from tenk1 order by unique2 limit 7 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2, generate_series(1, 10) FROM tenk1 ORDER BY unique2 LIMIT 7" +== 061 +-- truncate_limit: 100 +explain (verbose, costs off) +select unique1, unique2, generate_series(1,10) + from tenk1 order by tenthous limit 7 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT unique1, unique2, generate_series(1, 10) FROM tenk1 ORDER BY ..." +== 062 +-- truncate_limit: 100 +select unique1, unique2, generate_series(1,10) + from tenk1 order by tenthous limit 7 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2, generate_series(1, 10) FROM tenk1 ORDER BY tenthous LIMIT 7" +== 063 +-- truncate_limit: 100 +-- use of random() is to keep planner from folding the expressions together +explain (verbose, costs off) +select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT generate_series(0, 2) AS s1, generate_series((random() * .1):..." +== 064 +-- truncate_limit: 100 +select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(0, 2) AS s1, generate_series((random() * .1)::int, 2) AS s2" +== 065 +-- truncate_limit: 100 +explain (verbose, costs off) +select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 +order by s2 desc +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT generate_series(0, 2) AS s1, generate_series((random() * .1):..." +== 066 +-- truncate_limit: 100 +select generate_series(0,2) as s1, generate_series((random()*.1)::int,2) as s2 +order by s2 desc +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(0, 2) AS s1, generate_series((random() * .1)::int, 2) AS s2 ORDER BY s2 DESC" +== 067 +-- truncate_limit: 100 +-- test for failure to set all aggregates' aggtranstype +explain (verbose, costs off) +select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 + from tenk1 group by thousand order by thousand limit 3 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT sum(tenthous) AS s1, sum(tenthous) + (random() * 0) AS s2 FRO..." +== 068 +-- truncate_limit: 100 +select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 + from tenk1 group by thousand order by thousand limit 3 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 GROUP BY thousand ORDER BY thousand LIMIT 3" +== 069 +-- truncate_limit: 100 +|-- +-- FETCH FIRST +-- Check the WITH TIES clause +|-- + +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 2 ROW WITH TIES +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT thousand FROM onek WHERE thousand < 5 ORDER BY thousand FETCH FIRST 2 ROWS WITH TIES" +== 070 +-- truncate_limit: 100 +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST ROWS WITH TIES +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT thousand FROM onek WHERE thousand < 5 ORDER BY thousand FETCH FIRST 1 ROWS WITH TIES" +== 071 +-- truncate_limit: 100 +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 1 ROW WITH TIES +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT thousand FROM onek WHERE thousand < 5 ORDER BY thousand FETCH FIRST 1 ROWS WITH TIES" +== 072 +-- truncate_limit: 100 +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 2 ROW ONLY +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT thousand FROM onek WHERE thousand < 5 ORDER BY thousand LIMIT 2" +== 073 +-- truncate_limit: 100 +-- SKIP LOCKED and WITH TIES are incompatible +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 1 ROW WITH TIES FOR UPDATE SKIP LOCKED +-- +ERROR: SKIP LOCKED and WITH TIES options cannot be used together +FILENAME: gram.y +FUNCNAME: insertSelectOptions +== 074 +-- truncate_limit: 100 +-- should fail +SELECT ''::text AS two, unique1, unique2, stringu1 + FROM onek WHERE unique1 > 50 + FETCH FIRST 2 ROW WITH TIES +-- +ERROR: WITH TIES cannot be specified without ORDER BY clause +FILENAME: gram.y +FUNCNAME: insertSelectOptions +== 075 +-- truncate_limit: 100 +-- test ruleutils +CREATE VIEW limit_thousand_v_1 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST 5 ROWS WITH TIES OFFSET 10 +-- +TABLE: name="limit_thousand_v_1" schema="" table="limit_thousand_v_1" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW limit_thousand_v_1 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousan..." +== 076 +-- truncate_limit: 100 +CREATE VIEW limit_thousand_v_2 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand OFFSET 10 FETCH FIRST 5 ROWS ONLY +-- +TABLE: name="limit_thousand_v_2" schema="" table="limit_thousand_v_2" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW limit_thousand_v_2 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousan..." +== 077 +-- truncate_limit: 100 +CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST NULL ROWS WITH TIES +-- +TABLE: name="limit_thousand_v_3" schema="" table="limit_thousand_v_3" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousan..." +== 078 +-- truncate_limit: 100 +-- fails +CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST (NULL+1) ROWS WITH TIES +-- +TABLE: name="limit_thousand_v_3" schema="" table="limit_thousand_v_3" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousan..." +== 079 +-- truncate_limit: 100 +CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST (5::bigint) ROWS WITH TIES +-- +TABLE: name="limit_thousand_v_4" schema="" table="limit_thousand_v_4" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousan..." +== 080 +-- truncate_limit: 100 +CREATE VIEW limit_thousand_v_5 AS SELECT thousand FROM onek WHERE thousand < 995 + ORDER BY thousand FETCH FIRST NULL ROWS ONLY +-- +TABLE: name="limit_thousand_v_5" schema="" table="limit_thousand_v_5" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="thousand" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW limit_thousand_v_5 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousan..." diff --git a/parser/testdata/summary_truncate/postgres_regress/line.metadata.json b/parser/testdata/summary_truncate/postgres_regress/line.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/line.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/line.test b/parser/testdata/summary_truncate/postgres_regress/line.test new file mode 100644 index 0000000..61f7138 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/line.test @@ -0,0 +1,282 @@ +== 001 +-- truncate_limit: 100 +|-- +-- LINE +-- Infinite lines +|-- + +--DROP TABLE LINE_TBL; +CREATE TABLE LINE_TBL (s line) +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE line_tbl (s line)" +== 002 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('{0,-1,5}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{0,-1,5}')" +== 003 +-- truncate_limit: 100 +-- A == 0 +INSERT INTO LINE_TBL VALUES ('{1,0,5}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{1,0,5}')" +== 004 +-- truncate_limit: 100 +-- B == 0 +INSERT INTO LINE_TBL VALUES ('{0,3,0}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{0,3,0}')" +== 005 +-- truncate_limit: 100 +-- A == C == 0 +INSERT INTO LINE_TBL VALUES (' (0,0), (6,6)') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES (' (0,0), (6,6)')" +== 006 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('10,-10 ,-5,-4') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('10,-10 ,-5,-4')" +== 007 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('[-1e6,2e2,3e5, -4e1]') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('[-1e6,2e2,3e5, -4e1]')" +== 008 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('{3,NaN,5}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{3,NaN,5}')" +== 009 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('{NaN,NaN,NaN}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{NaN,NaN,NaN}')" +== 010 +-- truncate_limit: 100 +-- horizontal +INSERT INTO LINE_TBL VALUES ('[(1,3),(2,3)]') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('[(1,3),(2,3)]')" +== 011 +-- truncate_limit: 100 +-- vertical +INSERT INTO LINE_TBL VALUES (line(point '(3,1)', point '(3,2)')) +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +FUNCTION: name="line" function="line" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES (line( point '(3,1)', point '(3,2)'))" +== 012 +-- truncate_limit: 100 +-- bad values for parser testing +INSERT INTO LINE_TBL VALUES ('{}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{}')" +== 013 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('{0') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{0')" +== 014 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('{0,0}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{0,0}')" +== 015 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('{0,0,1') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{0,0,1')" +== 016 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('{0,0,1}') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{0,0,1}')" +== 017 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('{0,0,1} x') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('{0,0,1} x')" +== 018 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('(3asdf,2 ,3,4r2)') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('(3asdf,2 ,3,4r2)')" +== 019 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('[1,2,3, 4') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('[1,2,3, 4')" +== 020 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('[(,2),(3,4)]') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('[(,2),(3,4)]')" +== 021 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('[(1,2),(3,4)') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('[(1,2),(3,4)')" +== 022 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES ('[(1,2),(1,2)]') +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES ('[(1,2),(1,2)]')" +== 023 +-- truncate_limit: 100 +INSERT INTO LINE_TBL VALUES (line(point '(1,0)', point '(1,0)')) +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=DML +FUNCTION: name="line" function="line" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO line_tbl VALUES (line( point '(1,0)', point '(1,0)'))" +== 024 +-- truncate_limit: 100 +select * from LINE_TBL +-- +TABLE: name="line_tbl" schema="" table="line_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM line_tbl" +== 025 +-- truncate_limit: 100 +select '{nan, 1, nan}'::line = '{nan, 1, nan}'::line as true, + '{nan, 1, nan}'::line = '{nan, 2, nan}'::line as false +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 026 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('{1, 1}', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{1, 1}', 'line')" +== 027 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('{1, 1}', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{1, 1}', 'line')" +== 028 +-- truncate_limit: 100 +SELECT pg_input_is_valid('{0, 0, 0}', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{0, 0, 0}', 'line')" +== 029 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('{0, 0, 0}', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{0, 0, 0}', 'line')" +== 030 +-- truncate_limit: 100 +SELECT pg_input_is_valid('{1, 1, a}', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{1, 1, a}', 'line')" +== 031 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('{1, 1, a}', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{1, 1, a}', 'line')" +== 032 +-- truncate_limit: 100 +SELECT pg_input_is_valid('{1, 1, 1e400}', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{1, 1, 1e400}', 'line')" +== 033 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('{1, 1, 1e400}', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{1, 1, 1e400}', 'line')" +== 034 +-- truncate_limit: 100 +SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line')" +== 035 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('(1, 1), (1, 1e400)', 'line') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(1, 1), (1, 1e400)', 'line')" diff --git a/parser/testdata/summary_truncate/postgres_regress/lock.metadata.json b/parser/testdata/summary_truncate/postgres_regress/lock.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/lock.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/lock.test b/parser/testdata/summary_truncate/postgres_regress/lock.test new file mode 100644 index 0000000..b197969 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/lock.test @@ -0,0 +1,986 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test the LOCK statement +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +-- Setup +CREATE SCHEMA lock_schema1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA lock_schema1" +== 002 +-- truncate_limit: 100 +SET search_path = lock_schema1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO lock_schema1" +== 003 +-- truncate_limit: 100 +CREATE TABLE lock_tbl1 (a BIGINT) +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lock_tbl1 (a bigint)" +== 004 +-- truncate_limit: 100 +CREATE TABLE lock_tbl1a (a BIGINT) +-- +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lock_tbl1a (a bigint)" +== 005 +-- truncate_limit: 100 +CREATE VIEW lock_view1 AS SELECT * FROM lock_tbl1 +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW lock_view1 AS SELECT * FROM lock_tbl1" +== 006 +-- truncate_limit: 100 +CREATE VIEW lock_view2(a,b) AS SELECT * FROM lock_tbl1, lock_tbl1a +-- +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW lock_view2 (a, b) AS SELECT * FROM lock_tbl1, lock_tbl1a" +== 007 +-- truncate_limit: 100 +CREATE VIEW lock_view3 AS SELECT * from lock_view2 +-- +TABLE: name="lock_view3" schema="" table="lock_view3" ctx=DDL +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW lock_view3 AS SELECT * FROM lock_view2" +== 008 +-- truncate_limit: 100 +CREATE VIEW lock_view4 AS SELECT (select a from lock_tbl1a limit 1) from lock_tbl1 +-- +TABLE: name="lock_view4" schema="" table="lock_view4" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW lock_view4 AS SELECT (SELECT a FROM lock_tbl1a LIMIT 1) FROM lock_tbl1" +== 009 +-- truncate_limit: 100 +CREATE VIEW lock_view5 AS SELECT * from lock_tbl1 where a in (select * from lock_tbl1a) +-- +TABLE: name="lock_view5" schema="" table="lock_view5" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW lock_view5 AS SELECT * FROM lock_tbl1 WHERE a IN (SELECT * FROM lock_tbl1a)" +== 010 +-- truncate_limit: 100 +CREATE VIEW lock_view6 AS SELECT * from (select * from lock_tbl1) sub +-- +TABLE: name="lock_view6" schema="" table="lock_view6" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW lock_view6 AS SELECT * FROM (SELECT * FROM lock_tbl1) sub" +== 011 +-- truncate_limit: 100 +CREATE ROLE regress_rol_lock1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rol_lock1" +== 012 +-- truncate_limit: 100 +ALTER ROLE regress_rol_lock1 SET search_path = lock_schema1 +-- +STMT: AlterRoleSetStmt +TRUNCATED: "ALTER ROLE regress_rol_lock1 SET search_path TO lock_schema1" +== 013 +-- truncate_limit: 100 +GRANT USAGE ON SCHEMA lock_schema1 TO regress_rol_lock1 +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON SCHEMA lock_schema1 TO regress_rol_lock1" +== 014 +-- truncate_limit: 100 +-- Try all valid lock options; also try omitting the optional TABLE keyword. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 015 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE" +== 016 +-- truncate_limit: 100 +LOCK lock_tbl1 IN ROW SHARE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN ROW SHARE MODE" +== 017 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE" +== 018 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE" +== 019 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN SHARE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN SHARE MODE" +== 020 +-- truncate_limit: 100 +LOCK lock_tbl1 IN SHARE ROW EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN SHARE ROW EXCLUSIVE MODE" +== 021 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE" +== 022 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1" +== 023 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 024 +-- truncate_limit: 100 +-- Try using NOWAIT along with valid options. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 025 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN ACCESS SHARE MODE NOWAIT" +== 026 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN ROW SHARE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN ROW SHARE MODE NOWAIT" +== 027 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN ROW EXCLUSIVE MODE NOWAIT" +== 028 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN SHARE UPDATE EXCLUSIVE MODE NOWAIT" +== 029 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN SHARE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN SHARE MODE NOWAIT" +== 030 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN SHARE ROW EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN SHARE ROW EXCLUSIVE MODE NOWAIT" +== 031 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 IN EXCLUSIVE MODE NOWAIT" +== 032 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 IN ACCESS EXCLUSIVE MODE NOWAIT +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1 NOWAIT" +== 033 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 034 +-- truncate_limit: 100 +-- Verify that we can lock views. +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 035 +-- truncate_limit: 100 +LOCK TABLE lock_view1 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view1 IN EXCLUSIVE MODE" +== 036 +-- truncate_limit: 100 +-- lock_view1 and lock_tbl1 are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_locks l, pg_class c WHERE ... ORDER BY relname" +== 037 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 038 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 039 +-- truncate_limit: 100 +LOCK TABLE lock_view2 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view2 IN EXCLUSIVE MODE" +== 040 +-- truncate_limit: 100 +-- lock_view1, lock_tbl1, and lock_tbl1a are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_locks l, pg_class c WHERE ... ORDER BY relname" +== 041 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 042 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 043 +-- truncate_limit: 100 +LOCK TABLE lock_view3 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view3" schema="" table="lock_view3" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view3 IN EXCLUSIVE MODE" +== 044 +-- truncate_limit: 100 +-- lock_view3, lock_view2, lock_tbl1, and lock_tbl1a are locked recursively. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_locks l, pg_class c WHERE ... ORDER BY relname" +== 045 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 046 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 047 +-- truncate_limit: 100 +LOCK TABLE lock_view4 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view4" schema="" table="lock_view4" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view4 IN EXCLUSIVE MODE" +== 048 +-- truncate_limit: 100 +-- lock_view4, lock_tbl1, and lock_tbl1a are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_locks l, pg_class c WHERE ... ORDER BY relname" +== 049 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 050 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 051 +-- truncate_limit: 100 +LOCK TABLE lock_view5 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view5" schema="" table="lock_view5" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view5 IN EXCLUSIVE MODE" +== 052 +-- truncate_limit: 100 +-- lock_view5, lock_tbl1, and lock_tbl1a are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_locks l, pg_class c WHERE ... ORDER BY relname" +== 053 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 054 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 055 +-- truncate_limit: 100 +LOCK TABLE lock_view6 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view6" schema="" table="lock_view6" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view6 IN EXCLUSIVE MODE" +== 056 +-- truncate_limit: 100 +-- lock_view6 an lock_tbl1 are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'ExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_locks l, pg_class c WHERE ... ORDER BY relname" +== 057 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 058 +-- truncate_limit: 100 +-- Verify that we cope with infinite recursion in view definitions. +CREATE OR REPLACE VIEW lock_view2 AS SELECT * from lock_view3 +-- +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=DDL +TABLE: name="lock_view3" schema="" table="lock_view3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW lock_view2 AS SELECT * FROM lock_view3" +== 059 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 060 +-- truncate_limit: 100 +LOCK TABLE lock_view2 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view2 IN EXCLUSIVE MODE" +== 061 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 062 +-- truncate_limit: 100 +CREATE VIEW lock_view7 AS SELECT * from lock_view2 +-- +TABLE: name="lock_view7" schema="" table="lock_view7" ctx=DDL +TABLE: name="lock_view2" schema="" table="lock_view2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW lock_view7 AS SELECT * FROM lock_view2" +== 063 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 064 +-- truncate_limit: 100 +LOCK TABLE lock_view7 IN EXCLUSIVE MODE +-- +TABLE: name="lock_view7" schema="" table="lock_view7" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view7 IN EXCLUSIVE MODE" +== 065 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 066 +-- truncate_limit: 100 +-- Verify that we can lock a table with inheritance children. +CREATE TABLE lock_tbl2 (b BIGINT) INHERITS (lock_tbl1) +-- +TABLE: name="lock_tbl2" schema="" table="lock_tbl2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lock_tbl2 (b bigint) INHERITS (lock_tbl1)" +== 067 +-- truncate_limit: 100 +CREATE TABLE lock_tbl3 () INHERITS (lock_tbl2) +-- +TABLE: name="lock_tbl3" schema="" table="lock_tbl3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lock_tbl3 () INHERITS (lock_tbl2)" +== 068 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 069 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 * IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1" +== 070 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 071 +-- truncate_limit: 100 +-- Child tables are locked without granting explicit permission to do so as +-- long as we have permission to lock the parent. +GRANT UPDATE ON TABLE lock_tbl1 TO regress_rol_lock1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON lock_tbl1 TO regress_rol_lock1" +== 072 +-- truncate_limit: 100 +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_lock1" +== 073 +-- truncate_limit: 100 +-- fail when child locked directly +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 074 +-- truncate_limit: 100 +LOCK TABLE lock_tbl2 +-- +TABLE: name="lock_tbl2" schema="" table="lock_tbl2" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl2" +== 075 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 076 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 077 +-- truncate_limit: 100 +LOCK TABLE lock_tbl1 * IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_tbl1" +== 078 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 079 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 080 +-- truncate_limit: 100 +LOCK TABLE ONLY lock_tbl1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE ONLY lock_tbl1" +== 081 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 082 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 083 +-- truncate_limit: 100 +REVOKE UPDATE ON TABLE lock_tbl1 FROM regress_rol_lock1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE update ON lock_tbl1 FROM regress_rol_lock1" +== 084 +-- truncate_limit: 100 +-- Tables referred to by views are locked without explicit permission to do so +-- as long as we have permission to lock the view itself. +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_lock1" +== 085 +-- truncate_limit: 100 +-- fail without permissions on the view +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 086 +-- truncate_limit: 100 +LOCK TABLE lock_view1 +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view1" +== 087 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 088 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 089 +-- truncate_limit: 100 +GRANT UPDATE ON TABLE lock_view1 TO regress_rol_lock1 +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON lock_view1 TO regress_rol_lock1" +== 090 +-- truncate_limit: 100 +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_lock1" +== 091 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 092 +-- truncate_limit: 100 +LOCK TABLE lock_view1 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view1" +== 093 +-- truncate_limit: 100 +-- lock_view1 and lock_tbl1 (plus children lock_tbl2 and lock_tbl3) are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'AccessExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_locks l, pg_class c WHERE ... ORDER BY relname" +== 094 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 095 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 096 +-- truncate_limit: 100 +REVOKE UPDATE ON TABLE lock_view1 FROM regress_rol_lock1 +-- +TABLE: name="lock_view1" schema="" table="lock_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE update ON lock_view1 FROM regress_rol_lock1" +== 097 +-- truncate_limit: 100 +-- Tables referred to by security invoker views require explicit permission to +-- be locked. +CREATE VIEW lock_view8 WITH (security_invoker) AS SELECT * FROM lock_tbl1 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW lock_view8 WITH (security_invoker) AS SELECT * FROM lock_tbl1" +== 098 +-- truncate_limit: 100 +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_lock1" +== 099 +-- truncate_limit: 100 +-- fail without permissions on the view +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 100 +-- truncate_limit: 100 +LOCK TABLE lock_view8 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view8" +== 101 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 102 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 103 +-- truncate_limit: 100 +GRANT UPDATE ON TABLE lock_view8 TO regress_rol_lock1 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON lock_view8 TO regress_rol_lock1" +== 104 +-- truncate_limit: 100 +SET ROLE regress_rol_lock1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rol_lock1" +== 105 +-- truncate_limit: 100 +-- fail without permissions on the table referenced by the view +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 106 +-- truncate_limit: 100 +LOCK TABLE lock_view8 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view8" +== 107 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 108 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 109 +-- truncate_limit: 100 +GRANT UPDATE ON TABLE lock_tbl1 TO regress_rol_lock1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON lock_tbl1 TO regress_rol_lock1" +== 110 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 111 +-- truncate_limit: 100 +LOCK TABLE lock_view8 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE lock_view8" +== 112 +-- truncate_limit: 100 +-- lock_view8 and lock_tbl1 (plus children lock_tbl2 and lock_tbl3) are locked. +select relname from pg_locks l, pg_class c + where l.relation = c.oid and relname like '%lock_%' and mode = 'AccessExclusiveLock' + order by relname +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "l"="pg_locks" +FILTER: schema="" table="l" column="relation" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_locks l, pg_class c WHERE ... ORDER BY relname" +== 113 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 114 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 115 +-- truncate_limit: 100 +REVOKE UPDATE ON TABLE lock_view8 FROM regress_rol_lock1 +-- +TABLE: name="lock_view8" schema="" table="lock_view8" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE update ON lock_view8 FROM regress_rol_lock1" +== 116 +-- truncate_limit: 100 +|-- +-- Clean up +|-- +DROP VIEW lock_view8 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW lock_view8" +== 117 +-- truncate_limit: 100 +DROP VIEW lock_view7 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW lock_view7" +== 118 +-- truncate_limit: 100 +DROP VIEW lock_view6 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW lock_view6" +== 119 +-- truncate_limit: 100 +DROP VIEW lock_view5 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW lock_view5" +== 120 +-- truncate_limit: 100 +DROP VIEW lock_view4 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW lock_view4" +== 121 +-- truncate_limit: 100 +DROP VIEW lock_view3 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW lock_view3 CASCADE" +== 122 +-- truncate_limit: 100 +DROP VIEW lock_view1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW lock_view1" +== 123 +-- truncate_limit: 100 +DROP TABLE lock_tbl3 +-- +TABLE: name="lock_tbl3" schema="" table="lock_tbl3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lock_tbl3" +== 124 +-- truncate_limit: 100 +DROP TABLE lock_tbl2 +-- +TABLE: name="lock_tbl2" schema="" table="lock_tbl2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lock_tbl2" +== 125 +-- truncate_limit: 100 +DROP TABLE lock_tbl1 +-- +TABLE: name="lock_tbl1" schema="" table="lock_tbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lock_tbl1" +== 126 +-- truncate_limit: 100 +DROP TABLE lock_tbl1a +-- +TABLE: name="lock_tbl1a" schema="" table="lock_tbl1a" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lock_tbl1a" +== 127 +-- truncate_limit: 100 +DROP SCHEMA lock_schema1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA lock_schema1 CASCADE" +== 128 +-- truncate_limit: 100 +DROP ROLE regress_rol_lock1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_rol_lock1" +== 129 +-- truncate_limit: 100 +-- atomic ops tests +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 130 +-- truncate_limit: 100 +CREATE FUNCTION test_atomic_ops() + RETURNS bool + AS :'regresslib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 59 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 131 +-- truncate_limit: 100 +SELECT test_atomic_ops() +-- +FUNCTION: name="test_atomic_ops" function="test_atomic_ops" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_atomic_ops()" diff --git a/parser/testdata/summary_truncate/postgres_regress/lseg.metadata.json b/parser/testdata/summary_truncate/postgres_regress/lseg.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/lseg.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/lseg.test b/parser/testdata/summary_truncate/postgres_regress/lseg.test new file mode 100644 index 0000000..e7be2ec --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/lseg.test @@ -0,0 +1,139 @@ +== 001 +-- truncate_limit: 100 +|-- +-- LSEG +-- Line segments +|-- + +--DROP TABLE LSEG_TBL; +CREATE TABLE LSEG_TBL (s lseg) +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lseg_tbl (s lseg)" +== 002 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('[(1,2),(3,4)]')" +== 003 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES ('(0,0),(6,6)') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('(0,0),(6,6)')" +== 004 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES ('10,-10 ,-3,-4') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('10,-10 ,-3,-4')" +== 005 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES ('[-1e6,2e2,3e5, -4e1]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('[-1e6,2e2,3e5, -4e1]')" +== 006 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES (lseg(point(11, 22), point(33,44))) +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +FUNCTION: name="lseg" function="lseg" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES (lseg(point(11, 22), point(33, 44)))" +== 007 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES ('[(-10,2),(-10,3)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('[(-10,2),(-10,3)]')" +== 008 +-- truncate_limit: 100 +-- vertical +INSERT INTO LSEG_TBL VALUES ('[(0,-20),(30,-20)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('[(0,-20),(30,-20)]')" +== 009 +-- truncate_limit: 100 +-- horizontal +INSERT INTO LSEG_TBL VALUES ('[(NaN,1),(NaN,90)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('[(NaN,1),(NaN,90)]')" +== 010 +-- truncate_limit: 100 +-- NaN + +-- bad values for parser testing +INSERT INTO LSEG_TBL VALUES ('(3asdf,2 ,3,4r2)') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('(3asdf,2 ,3,4r2)')" +== 011 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES ('[1,2,3, 4') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('[1,2,3, 4')" +== 012 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('[(,2),(3,4)]')" +== 013 +-- truncate_limit: 100 +INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)') +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lseg_tbl VALUES ('[(1,2),(3,4)')" +== 014 +-- truncate_limit: 100 +select * from LSEG_TBL +-- +TABLE: name="lseg_tbl" schema="" table="lseg_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM lseg_tbl" +== 015 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('[(1,2),(3)]', 'lseg') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('[(1,2),(3)]', 'lseg')" +== 016 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'lseg') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'lseg')" diff --git a/parser/testdata/summary_truncate/postgres_regress/macaddr.metadata.json b/parser/testdata/summary_truncate/postgres_regress/macaddr.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/macaddr.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/macaddr.test b/parser/testdata/summary_truncate/postgres_regress/macaddr.test new file mode 100644 index 0000000..9a866fc --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/macaddr.test @@ -0,0 +1,285 @@ +== 001 +-- truncate_limit: 100 +|-- +-- macaddr +|-- + +CREATE TABLE macaddr_data (a int, b macaddr) +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE macaddr_data (a int, b macaddr)" +== 002 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (1, '08:00:2b:01:02:03') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (1, '08:00:2b:01:02:03')" +== 003 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (2, '08-00-2b-01-02-03') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (2, '08-00-2b-01-02-03')" +== 004 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (3, '08002b:010203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (3, '08002b:010203')" +== 005 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (4, '08002b-010203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (4, '08002b-010203')" +== 006 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (5, '0800.2b01.0203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (5, '0800.2b01.0203')" +== 007 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (6, '0800-2b01-0203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (6, '0800-2b01-0203')" +== 008 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (7, '08002b010203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (7, '08002b010203')" +== 009 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (8, '0800:2b01:0203') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (8, '0800:2b01:0203')" +== 010 +-- truncate_limit: 100 +-- invalid +INSERT INTO macaddr_data VALUES (9, 'not even close') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (9, 'not even close')" +== 011 +-- truncate_limit: 100 +-- invalid + +INSERT INTO macaddr_data VALUES (10, '08:00:2b:01:02:04') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (10, '08:00:2b:01:02:04')" +== 012 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (11, '08:00:2b:01:02:02') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (11, '08:00:2b:01:02:02')" +== 013 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (12, '08:00:2a:01:02:03') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (12, '08:00:2a:01:02:03')" +== 014 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (13, '08:00:2c:01:02:03') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (13, '08:00:2c:01:02:03')" +== 015 +-- truncate_limit: 100 +INSERT INTO macaddr_data VALUES (14, '08:00:2a:01:02:04') +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr_data VALUES (14, '08:00:2a:01:02:04')" +== 016 +-- truncate_limit: 100 +SELECT * FROM macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM macaddr_data" +== 017 +-- truncate_limit: 100 +CREATE INDEX macaddr_data_btree ON macaddr_data USING btree (b) +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX macaddr_data_btree ON macaddr_data USING btree (b)" +== 018 +-- truncate_limit: 100 +CREATE INDEX macaddr_data_hash ON macaddr_data USING hash (b) +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX macaddr_data_hash ON macaddr_data USING hash (b)" +== 019 +-- truncate_limit: 100 +SELECT a, b, trunc(b) FROM macaddr_data ORDER BY 2, 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, trunc(b) FROM macaddr_data ORDER BY 2, 1" +== 020 +-- truncate_limit: 100 +SELECT b < '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b < '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1" +== 021 +-- truncate_limit: 100 +-- true +SELECT b > '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b > '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1" +== 022 +-- truncate_limit: 100 +-- false +SELECT b > '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b > '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1" +== 023 +-- truncate_limit: 100 +-- false +SELECT b <= '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b <= '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1" +== 024 +-- truncate_limit: 100 +-- true +SELECT b >= '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b >= '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1" +== 025 +-- truncate_limit: 100 +-- false +SELECT b = '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b = '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1" +== 026 +-- truncate_limit: 100 +-- true +SELECT b <> '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b <> '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1" +== 027 +-- truncate_limit: 100 +-- true +SELECT b <> '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1 +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b <> '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1" +== 028 +-- truncate_limit: 100 +-- false + +SELECT ~b FROM macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ~ b FROM macaddr_data" +== 029 +-- truncate_limit: 100 +SELECT b & '00:00:00:ff:ff:ff' FROM macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b & '00:00:00:ff:ff:ff' FROM macaddr_data" +== 030 +-- truncate_limit: 100 +SELECT b | '01:02:03:04:05:06' FROM macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b | '01:02:03:04:05:06' FROM macaddr_data" +== 031 +-- truncate_limit: 100 +DROP TABLE macaddr_data +-- +TABLE: name="macaddr_data" schema="" table="macaddr_data" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE macaddr_data" +== 032 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('08:00:2b:01:02:ZZ', 'macaddr') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('08:00:2b:01:02:ZZ', 'macaddr')" +== 033 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('08:00:2b:01:02:ZZ', 'macaddr') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('08:00:2b:01:02:ZZ', 'macaddr')" +== 034 +-- truncate_limit: 100 +SELECT pg_input_is_valid('08:00:2b:01:02:', 'macaddr') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('08:00:2b:01:02:', 'macaddr')" +== 035 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('08:00:2b:01:02:', 'macaddr') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('08:00:2b:01:02:', 'macaddr')" diff --git a/parser/testdata/summary_truncate/postgres_regress/macaddr8.metadata.json b/parser/testdata/summary_truncate/postgres_regress/macaddr8.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/macaddr8.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/macaddr8.test b/parser/testdata/summary_truncate/postgres_regress/macaddr8.test new file mode 100644 index 0000000..ed76ca3 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/macaddr8.test @@ -0,0 +1,560 @@ +== 001 +-- truncate_limit: 100 +|-- +-- macaddr8 +|-- + +-- test various cases of valid and invalid input +-- valid +SELECT '08:00:2b:01:02:03 '::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00:2b:01:02:03 '::macaddr8" +== 002 +-- truncate_limit: 100 +SELECT ' 08:00:2b:01:02:03 '::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' 08:00:2b:01:02:03 '::macaddr8" +== 003 +-- truncate_limit: 100 +SELECT ' 08:00:2b:01:02:03'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' 08:00:2b:01:02:03'::macaddr8" +== 004 +-- truncate_limit: 100 +SELECT '08:00:2b:01:02:03:04:05 '::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00:2b:01:02:03:04:05 '::macaddr8" +== 005 +-- truncate_limit: 100 +SELECT ' 08:00:2b:01:02:03:04:05 '::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' 08:00:2b:01:02:03:04:05 '::macaddr8" +== 006 +-- truncate_limit: 100 +SELECT ' 08:00:2b:01:02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' 08:00:2b:01:02:03:04:05'::macaddr8" +== 007 +-- truncate_limit: 100 +SELECT '123 08:00:2b:01:02:03'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '123 08:00:2b:01:02:03'::macaddr8" +== 008 +-- truncate_limit: 100 +-- invalid +SELECT '08:00:2b:01:02:03 123'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00:2b:01:02:03 123'::macaddr8" +== 009 +-- truncate_limit: 100 +-- invalid +SELECT '123 08:00:2b:01:02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '123 08:00:2b:01:02:03:04:05'::macaddr8" +== 010 +-- truncate_limit: 100 +-- invalid +SELECT '08:00:2b:01:02:03:04:05 123'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00:2b:01:02:03:04:05 123'::macaddr8" +== 011 +-- truncate_limit: 100 +-- invalid +SELECT '08:00:2b:01:02:03:04:05:06:07'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00:2b:01:02:03:04:05:06:07'::macaddr8" +== 012 +-- truncate_limit: 100 +-- invalid +SELECT '08-00-2b-01-02-03-04-05-06-07'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08-00-2b-01-02-03-04-05-06-07'::macaddr8" +== 013 +-- truncate_limit: 100 +-- invalid +SELECT '08002b:01020304050607'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08002b:01020304050607'::macaddr8" +== 014 +-- truncate_limit: 100 +-- invalid +SELECT '08002b01020304050607'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08002b01020304050607'::macaddr8" +== 015 +-- truncate_limit: 100 +-- invalid +SELECT '0z002b0102030405'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0z002b0102030405'::macaddr8" +== 016 +-- truncate_limit: 100 +-- invalid +SELECT '08002b010203xyza'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08002b010203xyza'::macaddr8" +== 017 +-- truncate_limit: 100 +-- invalid + +SELECT '08:00-2b:01:02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00-2b:01:02:03:04:05'::macaddr8" +== 018 +-- truncate_limit: 100 +-- invalid +SELECT '08:00-2b:01:02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00-2b:01:02:03:04:05'::macaddr8" +== 019 +-- truncate_limit: 100 +-- invalid +SELECT '08:00:2b:01.02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00:2b:01.02:03:04:05'::macaddr8" +== 020 +-- truncate_limit: 100 +-- invalid +SELECT '08:00:2b:01.02:03:04:05'::macaddr8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '08:00:2b:01.02:03:04:05'::macaddr8" +== 021 +-- truncate_limit: 100 +-- invalid + +-- test converting a MAC address to modified EUI-64 for inclusion +-- in an ipv6 address +SELECT macaddr8_set7bit('00:08:2b:01:02:03'::macaddr8) +-- +FUNCTION: name="macaddr8_set7bit" function="macaddr8_set7bit" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT macaddr8_set7bit('00:08:2b:01:02:03'::macaddr8)" +== 022 +-- truncate_limit: 100 +CREATE TABLE macaddr8_data (a int, b macaddr8) +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE macaddr8_data (a int, b macaddr8)" +== 023 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (1, '08:00:2b:01:02:03') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (1, '08:00:2b:01:02:03')" +== 024 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (2, '08-00-2b-01-02-03') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (2, '08-00-2b-01-02-03')" +== 025 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (3, '08002b:010203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (3, '08002b:010203')" +== 026 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (4, '08002b-010203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (4, '08002b-010203')" +== 027 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (5, '0800.2b01.0203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (5, '0800.2b01.0203')" +== 028 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (6, '0800-2b01-0203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (6, '0800-2b01-0203')" +== 029 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (7, '08002b010203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (7, '08002b010203')" +== 030 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (8, '0800:2b01:0203') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (8, '0800:2b01:0203')" +== 031 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (9, 'not even close') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (9, 'not even close')" +== 032 +-- truncate_limit: 100 +-- invalid + +INSERT INTO macaddr8_data VALUES (10, '08:00:2b:01:02:04') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (10, '08:00:2b:01:02:04')" +== 033 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (11, '08:00:2b:01:02:02') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (11, '08:00:2b:01:02:02')" +== 034 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (12, '08:00:2a:01:02:03') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (12, '08:00:2a:01:02:03')" +== 035 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (13, '08:00:2c:01:02:03') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (13, '08:00:2c:01:02:03')" +== 036 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (14, '08:00:2a:01:02:04') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (14, '08:00:2a:01:02:04')" +== 037 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (15, '08:00:2b:01:02:03:04:05') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (15, '08:00:2b:01:02:03:04:05')" +== 038 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (16, '08-00-2b-01-02-03-04-05') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (16, '08-00-2b-01-02-03-04-05')" +== 039 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (17, '08002b:0102030405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (17, '08002b:0102030405')" +== 040 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (18, '08002b-0102030405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (18, '08002b-0102030405')" +== 041 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (19, '0800.2b01.0203.0405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (19, '0800.2b01.0203.0405')" +== 042 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (20, '08002b01:02030405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (20, '08002b01:02030405')" +== 043 +-- truncate_limit: 100 +INSERT INTO macaddr8_data VALUES (21, '08002b0102030405') +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO macaddr8_data VALUES (21, '08002b0102030405')" +== 044 +-- truncate_limit: 100 +SELECT * FROM macaddr8_data ORDER BY 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM macaddr8_data ORDER BY 1" +== 045 +-- truncate_limit: 100 +CREATE INDEX macaddr8_data_btree ON macaddr8_data USING btree (b) +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX macaddr8_data_btree ON macaddr8_data USING btree (b)" +== 046 +-- truncate_limit: 100 +CREATE INDEX macaddr8_data_hash ON macaddr8_data USING hash (b) +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX macaddr8_data_hash ON macaddr8_data USING hash (b)" +== 047 +-- truncate_limit: 100 +SELECT a, b, trunc(b) FROM macaddr8_data ORDER BY 2, 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, trunc(b) FROM macaddr8_data ORDER BY 2, 1" +== 048 +-- truncate_limit: 100 +SELECT b < '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b < '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1" +== 049 +-- truncate_limit: 100 +-- true +SELECT b > '08:00:2b:ff:fe:01:02:04' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b > '08:00:2b:ff:fe:01:02:04' FROM macaddr8_data WHERE a = 1" +== 050 +-- truncate_limit: 100 +-- false +SELECT b > '08:00:2b:ff:fe:01:02:03' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b > '08:00:2b:ff:fe:01:02:03' FROM macaddr8_data WHERE a = 1" +== 051 +-- truncate_limit: 100 +-- false +SELECT b::macaddr <= '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b::macaddr <= '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1" +== 052 +-- truncate_limit: 100 +-- true +SELECT b::macaddr >= '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b::macaddr >= '08:00:2b:01:02:04' FROM macaddr8_data WHERE a = 1" +== 053 +-- truncate_limit: 100 +-- false +SELECT b = '08:00:2b:ff:fe:01:02:03' FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b = '08:00:2b:ff:fe:01:02:03' FROM macaddr8_data WHERE a = 1" +== 054 +-- truncate_limit: 100 +-- true +SELECT b::macaddr <> '08:00:2b:01:02:04'::macaddr FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b::macaddr <> '08:00:2b:01:02:04'::macaddr FROM macaddr8_data WHERE a = 1" +== 055 +-- truncate_limit: 100 +-- true +SELECT b::macaddr <> '08:00:2b:01:02:03'::macaddr FROM macaddr8_data WHERE a = 1 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b::macaddr <> '08:00:2b:01:02:03'::macaddr FROM macaddr8_data WHERE a = 1" +== 056 +-- truncate_limit: 100 +-- false + +SELECT b < '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b < '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15" +== 057 +-- truncate_limit: 100 +-- true +SELECT b > '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b > '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15" +== 058 +-- truncate_limit: 100 +-- false +SELECT b > '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b > '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15" +== 059 +-- truncate_limit: 100 +-- false +SELECT b <= '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b <= '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15" +== 060 +-- truncate_limit: 100 +-- true +SELECT b >= '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b >= '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15" +== 061 +-- truncate_limit: 100 +-- false +SELECT b = '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b = '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15" +== 062 +-- truncate_limit: 100 +-- true +SELECT b <> '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b <> '08:00:2b:01:02:03:04:06' FROM macaddr8_data WHERE a = 15" +== 063 +-- truncate_limit: 100 +-- true +SELECT b <> '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15 +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT b <> '08:00:2b:01:02:03:04:05' FROM macaddr8_data WHERE a = 15" +== 064 +-- truncate_limit: 100 +-- false + +SELECT ~b FROM macaddr8_data +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ~ b FROM macaddr8_data" +== 065 +-- truncate_limit: 100 +SELECT b & '00:00:00:ff:ff:ff' FROM macaddr8_data +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b & '00:00:00:ff:ff:ff' FROM macaddr8_data" +== 066 +-- truncate_limit: 100 +SELECT b | '01:02:03:04:05:06' FROM macaddr8_data +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b | '01:02:03:04:05:06' FROM macaddr8_data" +== 067 +-- truncate_limit: 100 +DROP TABLE macaddr8_data +-- +TABLE: name="macaddr8_data" schema="" table="macaddr8_data" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE macaddr8_data" +== 068 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('08:00:2b:01:02:03:04:ZZ', 'macaddr8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('08:00:2b:01:02:03:04:ZZ', 'macaddr8')" +== 069 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:ZZ', 'macaddr8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:ZZ', 'macaddr8')" +== 070 +-- truncate_limit: 100 +SELECT pg_input_is_valid('08:00:2b:01:02:03:04:', 'macaddr8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('08:00:2b:01:02:03:04:', 'macaddr8')" +== 071 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:', 'macaddr8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:', 'macaddr8')" diff --git a/parser/testdata/summary_truncate/postgres_regress/maintain_every.metadata.json b/parser/testdata/summary_truncate/postgres_regress/maintain_every.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/maintain_every.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/maintain_every.test b/parser/testdata/summary_truncate/postgres_regress/maintain_every.test new file mode 100644 index 0000000..1a061c6 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/maintain_every.test @@ -0,0 +1,118 @@ +== 001 +-- truncate_limit: 100 +-- Test maintenance commands that visit every eligible relation. Run as a +-- non-superuser, to skip other users' tables. + +CREATE ROLE regress_maintain +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_maintain" +== 002 +-- truncate_limit: 100 +SET ROLE regress_maintain +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_maintain" +== 003 +-- truncate_limit: 100 +-- Test database-wide ANALYZE ("use_own_xacts" mode) setting relhassubclass=f +-- for non-partitioning inheritance, w/ ON COMMIT DELETE ROWS building an +-- empty index. +CREATE TEMP TABLE past_inh_db_other () +-- +TABLE: name="past_inh_db_other" schema="" table="past_inh_db_other" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE past_inh_db_other ()" +== 004 +-- truncate_limit: 100 +-- need 2 tables for "use_own_xacts" +CREATE TEMP TABLE past_inh_db_parent () ON COMMIT DELETE ROWS +-- +TABLE: name="past_inh_db_parent" schema="" table="past_inh_db_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE past_inh_db_parent () ON COMMIT DELETE ROWS" +== 005 +-- truncate_limit: 100 +CREATE TEMP TABLE past_inh_db_child () INHERITS (past_inh_db_parent) +-- +TABLE: name="past_inh_db_child" schema="" table="past_inh_db_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE past_inh_db_child () INHERITS (past_inh_db_parent)" +== 006 +-- truncate_limit: 100 +CREATE INDEX ON past_inh_db_parent ((1)) +-- +TABLE: name="past_inh_db_parent" schema="" table="past_inh_db_parent" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON past_inh_db_parent USING btree ((1))" +== 007 +-- truncate_limit: 100 +ANALYZE past_inh_db_parent +-- +TABLE: name="past_inh_db_parent" schema="" table="past_inh_db_parent" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE past_inh_db_parent" +== 008 +-- truncate_limit: 100 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_inh_db_parent'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltuples, relhassubclass FROM pg_class WHERE oid = 'past_inh_db_parent'::regclass" +== 009 +-- truncate_limit: 100 +DROP TABLE past_inh_db_child +-- +TABLE: name="past_inh_db_child" schema="" table="past_inh_db_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE past_inh_db_child" +== 010 +-- truncate_limit: 100 +SET client_min_messages = error +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO error" +== 011 +-- truncate_limit: 100 +-- hide WARNINGs for other users' tables +ANALYZE +-- +STMT: VacuumStmt +TRUNCATED: "ANALYZE" +== 012 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 013 +-- truncate_limit: 100 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_inh_db_parent'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltuples, relhassubclass FROM pg_class WHERE oid = 'past_inh_db_parent'::regclass" +== 014 +-- truncate_limit: 100 +DROP TABLE past_inh_db_parent, past_inh_db_other +-- +TABLE: name="past_inh_db_parent" schema="" table="past_inh_db_parent" ctx=DDL +TABLE: name="past_inh_db_other" schema="" table="past_inh_db_other" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE past_inh_db_parent, past_inh_db_other" +== 015 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 016 +-- truncate_limit: 100 +DROP ROLE regress_maintain +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_maintain" diff --git a/parser/testdata/summary_truncate/postgres_regress/matview.metadata.json b/parser/testdata/summary_truncate/postgres_regress/matview.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/matview.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/matview.test b/parser/testdata/summary_truncate/postgres_regress/matview.test new file mode 100644 index 0000000..3aada45 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/matview.test @@ -0,0 +1,1474 @@ +== 001 +-- truncate_limit: 100 +-- create a table to use as a basis for views and materialized views in various combinations +CREATE TABLE mvtest_t (id int NOT NULL PRIMARY KEY, type text NOT NULL, amt numeric NOT NULL) +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mvtest_t (id int NOT NULL PRIMARY KEY, type text NOT NULL, amt numeric NOT NULL)" +== 002 +-- truncate_limit: 100 +INSERT INTO mvtest_t VALUES + (1, 'x', 2), + (2, 'x', 3), + (3, 'y', 5), + (4, 'y', 7), + (5, 'z', 11) +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mvtest_t VALUES (1, 'x', 2), (2, 'x', 3), (3, 'y', 5), (4, 'y', 7), (5, 'z', 11)" +== 003 +-- truncate_limit: 100 +-- we want a view based on the table, too, since views present additional challenges +CREATE VIEW mvtest_tv AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type +-- +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=DDL +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mvtest_tv AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type" +== 004 +-- truncate_limit: 100 +SELECT * FROM mvtest_tv ORDER BY type +-- +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tv ORDER BY type" +== 005 +-- truncate_limit: 100 +-- create a materialized view with no data, and confirm correct behavior +EXPLAIN (costs off) + CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type WITH NO DATA +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mv..." +== 006 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type WITH NO DATA +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_tm AS SELECT type, sum(amt) AS totamt FROM mvtest_t GROUP BY type..." +== 007 +-- truncate_limit: 100 +SELECT relispopulated FROM pg_class WHERE oid = 'mvtest_tm'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relispopulated FROM pg_class WHERE oid = 'mvtest_tm'::regclass" +== 008 +-- truncate_limit: 100 +SELECT * FROM mvtest_tm ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tm ORDER BY type" +== 009 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_tm +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_tm" +== 010 +-- truncate_limit: 100 +SELECT relispopulated FROM pg_class WHERE oid = 'mvtest_tm'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relispopulated FROM pg_class WHERE oid = 'mvtest_tm'::regclass" +== 011 +-- truncate_limit: 100 +CREATE UNIQUE INDEX mvtest_tm_type ON mvtest_tm (type) +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX mvtest_tm_type ON mvtest_tm USING btree (type)" +== 012 +-- truncate_limit: 100 +SELECT * FROM mvtest_tm ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tm ORDER BY type" +== 013 +-- truncate_limit: 100 +-- create various views +EXPLAIN (costs off) + CREATE MATERIALIZED VIEW mvtest_tvm AS SELECT * FROM mvtest_tv ORDER BY type +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=DDL +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) CREATE MATERIALIZED VIEW mvtest_tvm AS SELECT * FROM mvtest_tv ORDER BY type" +== 014 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_tvm AS SELECT * FROM mvtest_tv ORDER BY type +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=DDL +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_tvm AS SELECT * FROM mvtest_tv ORDER BY type" +== 015 +-- truncate_limit: 100 +SELECT * FROM mvtest_tvm +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tvm" +== 016 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_tmm AS SELECT sum(totamt) AS grandtot FROM mvtest_tm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=DDL +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_tmm AS SELECT sum(totamt) AS grandtot FROM mvtest_tm" +== 017 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_tvmm AS SELECT sum(totamt) AS grandtot FROM mvtest_tvm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_tvmm AS SELECT sum(totamt) AS grandtot FROM mvtest_tvm" +== 018 +-- truncate_limit: 100 +CREATE UNIQUE INDEX mvtest_tvmm_expr ON mvtest_tvmm ((grandtot > 0)) +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX mvtest_tvmm_expr ON mvtest_tvmm USING btree ((grandtot > 0))" +== 019 +-- truncate_limit: 100 +CREATE UNIQUE INDEX mvtest_tvmm_pred ON mvtest_tvmm (grandtot) WHERE grandtot < 0 +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX mvtest_tvmm_pred ON mvtest_tvmm USING btree (grandtot) WHERE grandtot < 0" +== 020 +-- truncate_limit: 100 +CREATE VIEW mvtest_tvv AS SELECT sum(totamt) AS grandtot FROM mvtest_tv +-- +TABLE: name="mvtest_tvv" schema="" table="mvtest_tvv" ctx=DDL +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mvtest_tvv AS SELECT sum(totamt) AS grandtot FROM mvtest_tv" +== 021 +-- truncate_limit: 100 +EXPLAIN (costs off) + CREATE MATERIALIZED VIEW mvtest_tvvm AS SELECT * FROM mvtest_tvv +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=DDL +TABLE: name="mvtest_tvv" schema="" table="mvtest_tvv" ctx=Select +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) CREATE MATERIALIZED VIEW mvtest_tvvm AS SELECT * FROM mvtest_tvv" +== 022 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_tvvm AS SELECT * FROM mvtest_tvv +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=DDL +TABLE: name="mvtest_tvv" schema="" table="mvtest_tvv" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_tvvm AS SELECT * FROM mvtest_tvv" +== 023 +-- truncate_limit: 100 +CREATE VIEW mvtest_tvvmv AS SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvmv" schema="" table="mvtest_tvvmv" ctx=DDL +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mvtest_tvvmv AS SELECT * FROM mvtest_tvvm" +== 024 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_bb AS SELECT * FROM mvtest_tvvmv +-- +TABLE: name="mvtest_bb" schema="" table="mvtest_bb" ctx=DDL +TABLE: name="mvtest_tvvmv" schema="" table="mvtest_tvvmv" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_bb AS SELECT * FROM mvtest_tvvmv" +== 025 +-- truncate_limit: 100 +CREATE INDEX mvtest_aa ON mvtest_bb (grandtot) +-- +TABLE: name="mvtest_bb" schema="" table="mvtest_bb" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX mvtest_aa ON mvtest_bb USING btree (grandtot)" +== 026 +-- truncate_limit: 100 +-- check that plans seem reasonable + +-- test schema behavior +CREATE SCHEMA mvtest_mvschema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA mvtest_mvschema" +== 027 +-- truncate_limit: 100 +ALTER MATERIALIZED VIEW mvtest_tvm SET SCHEMA mvtest_mvschema +-- +STMT: AlterObjectSchemaStmt +TRUNCATED: "ALTER MATERIALIZED VIEW mvtest_tvm SET SCHEMA mvtest_mvschema" +== 028 +-- truncate_limit: 100 +SET search_path = mvtest_mvschema, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO mvtest_mvschema, public" +== 029 +-- truncate_limit: 100 +-- modify the underlying table data +INSERT INTO mvtest_t VALUES (6, 'z', 13) +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mvtest_t VALUES (6, 'z', 13)" +== 030 +-- truncate_limit: 100 +-- confirm pre- and post-refresh contents of fairly simple materialized views +SELECT * FROM mvtest_tm ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tm ORDER BY type" +== 031 +-- truncate_limit: 100 +SELECT * FROM mvtest_tvm ORDER BY type +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tvm ORDER BY type" +== 032 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tm +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tm" +== 033 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_tvm +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_tvm" +== 034 +-- truncate_limit: 100 +SELECT * FROM mvtest_tm ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tm ORDER BY type" +== 035 +-- truncate_limit: 100 +SELECT * FROM mvtest_tvm ORDER BY type +-- +TABLE: name="mvtest_tvm" schema="" table="mvtest_tvm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tvm ORDER BY type" +== 036 +-- truncate_limit: 100 +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 037 +-- truncate_limit: 100 +-- confirm pre- and post-refresh contents of nested materialized views +EXPLAIN (costs off) + SELECT * FROM mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mvtest_tmm" +== 038 +-- truncate_limit: 100 +EXPLAIN (costs off) + SELECT * FROM mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mvtest_tvmm" +== 039 +-- truncate_limit: 100 +EXPLAIN (costs off) + SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mvtest_tvvm" +== 040 +-- truncate_limit: 100 +SELECT * FROM mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tmm" +== 041 +-- truncate_limit: 100 +SELECT * FROM mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tvmm" +== 042 +-- truncate_limit: 100 +SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tvvm" +== 043 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_tmm" +== 044 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tvmm" +== 045 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_tvmm" +== 046 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_tvvm" +== 047 +-- truncate_limit: 100 +EXPLAIN (costs off) + SELECT * FROM mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mvtest_tmm" +== 048 +-- truncate_limit: 100 +EXPLAIN (costs off) + SELECT * FROM mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mvtest_tvmm" +== 049 +-- truncate_limit: 100 +EXPLAIN (costs off) + SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mvtest_tvvm" +== 050 +-- truncate_limit: 100 +SELECT * FROM mvtest_tmm +-- +TABLE: name="mvtest_tmm" schema="" table="mvtest_tmm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tmm" +== 051 +-- truncate_limit: 100 +SELECT * FROM mvtest_tvmm +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tvmm" +== 052 +-- truncate_limit: 100 +SELECT * FROM mvtest_tvvm +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tvvm" +== 053 +-- truncate_limit: 100 +-- test diemv when the mv does not exist +DROP MATERIALIZED VIEW IF EXISTS no_such_mv +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW IF EXISTS no_such_mv" +== 054 +-- truncate_limit: 100 +-- make sure invalid combination of options is prohibited +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tvmm WITH NO DATA +-- +TABLE: name="mvtest_tvmm" schema="" table="mvtest_tvmm" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tvmm WITH NO DATA" +== 055 +-- truncate_limit: 100 +-- no tuple locks on materialized views +SELECT * FROM mvtest_tvvm FOR SHARE +-- +TABLE: name="mvtest_tvvm" schema="" table="mvtest_tvvm" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_tvvm FOR SHARE" +== 056 +-- truncate_limit: 100 +-- test join of mv and view +SELECT type, m.totamt AS mtot, v.totamt AS vtot FROM mvtest_tm m LEFT JOIN mvtest_tv v USING (type) ORDER BY type +-- +TABLE: name="mvtest_tm" schema="" table="mvtest_tm" ctx=Select +TABLE: name="mvtest_tv" schema="" table="mvtest_tv" ctx=Select +ALIAS: "m"="mvtest_tm" +ALIAS: "v"="mvtest_tv" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM mvtest_tm m LEFT JOIN mvtest_tv v USING (type) ORDER BY type" +== 057 +-- truncate_limit: 100 +-- make sure that dependencies are reported properly when they block the drop +DROP TABLE mvtest_t +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mvtest_t" +== 058 +-- truncate_limit: 100 +-- make sure dependencies are dropped and reported +-- and make sure that transactional behavior is correct on rollback +-- incidentally leaving some interesting materialized views for pg_dump testing +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 059 +-- truncate_limit: 100 +DROP TABLE mvtest_t CASCADE +-- +TABLE: name="mvtest_t" schema="" table="mvtest_t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mvtest_t CASCADE" +== 060 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 061 +-- truncate_limit: 100 +-- some additional tests not using base tables +CREATE VIEW mvtest_vt1 AS SELECT 1 moo +-- +TABLE: name="mvtest_vt1" schema="" table="mvtest_vt1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mvtest_vt1 AS SELECT 1 AS moo" +== 062 +-- truncate_limit: 100 +CREATE VIEW mvtest_vt2 AS SELECT moo, 2*moo FROM mvtest_vt1 UNION ALL SELECT moo, 3*moo FROM mvtest_vt1 +-- +TABLE: name="mvtest_vt2" schema="" table="mvtest_vt2" ctx=DDL +TABLE: name="mvtest_vt1" schema="" table="mvtest_vt1" ctx=Select +TABLE: name="mvtest_vt1" schema="" table="mvtest_vt1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW mvtest_vt2 AS SELECT moo, 2 * moo FROM mvtest_vt1 UNION ALL SELECT moo, 3 * moo FROM ..." +== 063 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mv_test2 AS SELECT moo, 2*moo FROM mvtest_vt2 UNION ALL SELECT moo, 3*moo FROM mvtest_vt2 +-- +TABLE: name="mv_test2" schema="" table="mv_test2" ctx=DDL +TABLE: name="mvtest_vt2" schema="" table="mvtest_vt2" ctx=Select +TABLE: name="mvtest_vt2" schema="" table="mvtest_vt2" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mv_test2 AS SELECT moo, 2 * moo FROM mvtest_vt2 UNION ALL SELECT moo, 3 ..." +== 064 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mv_test3 AS SELECT * FROM mv_test2 WHERE moo = 12345 +-- +TABLE: name="mv_test3" schema="" table="mv_test3" ctx=DDL +TABLE: name="mv_test2" schema="" table="mv_test2" ctx=Select +FILTER: schema="" table="" column="moo" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mv_test3 AS SELECT * FROM mv_test2 WHERE moo = 12345" +== 065 +-- truncate_limit: 100 +SELECT relispopulated FROM pg_class WHERE oid = 'mv_test3'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relispopulated FROM pg_class WHERE oid = 'mv_test3'::regclass" +== 066 +-- truncate_limit: 100 +DROP VIEW mvtest_vt1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW mvtest_vt1 CASCADE" +== 067 +-- truncate_limit: 100 +-- test that duplicate values on unique index prevent refresh +CREATE TABLE mvtest_foo(a, b) AS VALUES(1, 10) +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE mvtest_foo(a, b) AS VALUES (1, 10)" +== 068 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_mv AS SELECT * FROM mvtest_foo +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv AS SELECT * FROM mvtest_foo" +== 069 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON mvtest_mv(a) +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON mvtest_mv USING btree (a)" +== 070 +-- truncate_limit: 100 +INSERT INTO mvtest_foo SELECT * FROM mvtest_foo +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DML +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mvtest_foo SELECT * FROM mvtest_foo" +== 071 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_mv +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_mv" +== 072 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv" +== 073 +-- truncate_limit: 100 +DROP TABLE mvtest_foo CASCADE +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mvtest_foo CASCADE" +== 074 +-- truncate_limit: 100 +-- make sure that all columns covered by unique indexes works +CREATE TABLE mvtest_foo(a, b, c) AS VALUES(1, 2, 3) +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE mvtest_foo(a, b, c) AS VALUES (1, 2, 3)" +== 075 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_mv AS SELECT * FROM mvtest_foo +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv AS SELECT * FROM mvtest_foo" +== 076 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON mvtest_mv (a) +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON mvtest_mv USING btree (a)" +== 077 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON mvtest_mv (b) +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON mvtest_mv USING btree (b)" +== 078 +-- truncate_limit: 100 +CREATE UNIQUE INDEX on mvtest_mv (c) +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON mvtest_mv USING btree (c)" +== 079 +-- truncate_limit: 100 +INSERT INTO mvtest_foo VALUES(2, 3, 4) +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mvtest_foo VALUES (2, 3, 4)" +== 080 +-- truncate_limit: 100 +INSERT INTO mvtest_foo VALUES(3, 4, 5) +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mvtest_foo VALUES (3, 4, 5)" +== 081 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_mv +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_mv" +== 082 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv +-- +TABLE: name="mvtest_mv" schema="" table="mvtest_mv" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv" +== 083 +-- truncate_limit: 100 +DROP TABLE mvtest_foo CASCADE +-- +TABLE: name="mvtest_foo" schema="" table="mvtest_foo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mvtest_foo CASCADE" +== 084 +-- truncate_limit: 100 +-- allow subquery to reference unpopulated matview if WITH NO DATA is specified +CREATE MATERIALIZED VIEW mvtest_mv1 AS SELECT 1 AS col1 WITH NO DATA +-- +TABLE: name="mvtest_mv1" schema="" table="mvtest_mv1" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv1 AS SELECT 1 AS col1 WITH NO DATA" +== 085 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_mv2 AS SELECT * FROM mvtest_mv1 + WHERE col1 = (SELECT LEAST(col1) FROM mvtest_mv1) WITH NO DATA +-- +TABLE: name="mvtest_mv2" schema="" table="mvtest_mv2" ctx=DDL +TABLE: name="mvtest_mv1" schema="" table="mvtest_mv1" ctx=Select +TABLE: name="mvtest_mv1" schema="" table="mvtest_mv1" ctx=Select +FILTER: schema="" table="" column="col1" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv2 AS SELECT * FROM mvtest_mv1 WHERE col1 = (SELECT LEAST(col1) ..." +== 086 +-- truncate_limit: 100 +DROP MATERIALIZED VIEW mvtest_mv1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW mvtest_mv1 CASCADE" +== 087 +-- truncate_limit: 100 +-- make sure that types with unusual equality tests work +CREATE TABLE mvtest_boxes (id serial primary key, b box) +-- +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mvtest_boxes (id serial PRIMARY KEY, b box)" +== 088 +-- truncate_limit: 100 +INSERT INTO mvtest_boxes (b) VALUES + ('(32,32),(31,31)'), + ('(2.0000004,2.0000004),(1,1)'), + ('(1.9999996,1.9999996),(1,1)') +-- +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mvtest_boxes (b) VALUES (...)" +== 089 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_boxmv AS SELECT * FROM mvtest_boxes +-- +TABLE: name="mvtest_boxmv" schema="" table="mvtest_boxmv" ctx=DDL +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_boxmv AS SELECT * FROM mvtest_boxes" +== 090 +-- truncate_limit: 100 +CREATE UNIQUE INDEX mvtest_boxmv_id ON mvtest_boxmv (id) +-- +TABLE: name="mvtest_boxmv" schema="" table="mvtest_boxmv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX mvtest_boxmv_id ON mvtest_boxmv USING btree (id)" +== 091 +-- truncate_limit: 100 +UPDATE mvtest_boxes SET b = '(2,2),(1,1)' WHERE id = 2 +-- +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE mvtest_boxes SET b = '(2,2),(1,1)' WHERE id = 2" +== 092 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_boxmv +-- +TABLE: name="mvtest_boxmv" schema="" table="mvtest_boxmv" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_boxmv" +== 093 +-- truncate_limit: 100 +SELECT * FROM mvtest_boxmv ORDER BY id +-- +TABLE: name="mvtest_boxmv" schema="" table="mvtest_boxmv" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_boxmv ORDER BY id" +== 094 +-- truncate_limit: 100 +DROP TABLE mvtest_boxes CASCADE +-- +TABLE: name="mvtest_boxes" schema="" table="mvtest_boxes" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mvtest_boxes CASCADE" +== 095 +-- truncate_limit: 100 +-- make sure that column names are handled correctly +CREATE TABLE mvtest_v (i int, j int) +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mvtest_v (i int, j int)" +== 096 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_mv_v (ii, jj, kk) AS SELECT i, j FROM mvtest_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_v(ii, jj, kk) AS SELECT i, j FROM mvtest_v" +== 097 +-- truncate_limit: 100 +-- error +CREATE MATERIALIZED VIEW mvtest_mv_v (ii, jj) AS SELECT i, j FROM mvtest_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_v(ii, jj) AS SELECT i, j FROM mvtest_v" +== 098 +-- truncate_limit: 100 +-- ok +CREATE MATERIALIZED VIEW mvtest_mv_v_2 (ii) AS SELECT i, j FROM mvtest_v +-- +TABLE: name="mvtest_mv_v_2" schema="" table="mvtest_mv_v_2" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_v_2(ii) AS SELECT i, j FROM mvtest_v" +== 099 +-- truncate_limit: 100 +-- ok +CREATE MATERIALIZED VIEW mvtest_mv_v_3 (ii, jj, kk) AS SELECT i, j FROM mvtest_v WITH NO DATA +-- +TABLE: name="mvtest_mv_v_3" schema="" table="mvtest_mv_v_3" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_v_3(ii, jj, kk) AS SELECT i, j FROM mvtest_v WITH NO DATA" +== 100 +-- truncate_limit: 100 +-- error +CREATE MATERIALIZED VIEW mvtest_mv_v_3 (ii, jj) AS SELECT i, j FROM mvtest_v WITH NO DATA +-- +TABLE: name="mvtest_mv_v_3" schema="" table="mvtest_mv_v_3" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_v_3(ii, jj) AS SELECT i, j FROM mvtest_v WITH NO DATA" +== 101 +-- truncate_limit: 100 +-- ok +CREATE MATERIALIZED VIEW mvtest_mv_v_4 (ii) AS SELECT i, j FROM mvtest_v WITH NO DATA +-- +TABLE: name="mvtest_mv_v_4" schema="" table="mvtest_mv_v_4" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_v_4(ii) AS SELECT i, j FROM mvtest_v WITH NO DATA" +== 102 +-- truncate_limit: 100 +-- ok +ALTER TABLE mvtest_v RENAME COLUMN i TO x +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE mvtest_v RENAME COLUMN i TO x" +== 103 +-- truncate_limit: 100 +INSERT INTO mvtest_v values (1, 2) +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mvtest_v VALUES (1, 2)" +== 104 +-- truncate_limit: 100 +CREATE UNIQUE INDEX mvtest_mv_v_ii ON mvtest_mv_v (ii) +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX mvtest_mv_v_ii ON mvtest_mv_v USING btree (ii)" +== 105 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_mv_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_mv_v" +== 106 +-- truncate_limit: 100 +UPDATE mvtest_v SET j = 3 WHERE x = 1 +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE mvtest_v SET j = 3 WHERE x = 1" +== 107 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv_v" +== 108 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_mv_v_2 +-- +TABLE: name="mvtest_mv_v_2" schema="" table="mvtest_mv_v_2" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_mv_v_2" +== 109 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_mv_v_3 +-- +TABLE: name="mvtest_mv_v_3" schema="" table="mvtest_mv_v_3" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_mv_v_3" +== 110 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_mv_v_4 +-- +TABLE: name="mvtest_mv_v_4" schema="" table="mvtest_mv_v_4" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_mv_v_4" +== 111 +-- truncate_limit: 100 +SELECT * FROM mvtest_v +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_v" +== 112 +-- truncate_limit: 100 +SELECT * FROM mvtest_mv_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_mv_v" +== 113 +-- truncate_limit: 100 +SELECT * FROM mvtest_mv_v_2 +-- +TABLE: name="mvtest_mv_v_2" schema="" table="mvtest_mv_v_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_mv_v_2" +== 114 +-- truncate_limit: 100 +SELECT * FROM mvtest_mv_v_3 +-- +TABLE: name="mvtest_mv_v_3" schema="" table="mvtest_mv_v_3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_mv_v_3" +== 115 +-- truncate_limit: 100 +SELECT * FROM mvtest_mv_v_4 +-- +TABLE: name="mvtest_mv_v_4" schema="" table="mvtest_mv_v_4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_mv_v_4" +== 116 +-- truncate_limit: 100 +DROP TABLE mvtest_v CASCADE +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mvtest_v CASCADE" +== 117 +-- truncate_limit: 100 +-- Check that unknown literals are converted to "text" in CREATE MATVIEW, +-- so that we don't end up with unknown-type columns. +CREATE MATERIALIZED VIEW mv_unspecified_types AS + SELECT 42 as i, 42.5 as num, 'foo' as u, 'foo'::unknown as u2, null as n +-- +TABLE: name="mv_unspecified_types" schema="" table="mv_unspecified_types" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mv_unspecified_types AS SELECT 42 AS i, 42.5 AS num, 'foo' AS u, 'foo'::..." +== 118 +-- truncate_limit: 100 +SELECT * FROM mv_unspecified_types +-- +TABLE: name="mv_unspecified_types" schema="" table="mv_unspecified_types" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mv_unspecified_types" +== 119 +-- truncate_limit: 100 +DROP MATERIALIZED VIEW mv_unspecified_types +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW mv_unspecified_types" +== 120 +-- truncate_limit: 100 +-- make sure that create WITH NO DATA does not plan the query (bug #13907) +create materialized view mvtest_error as select 1/0 as x +-- +TABLE: name="mvtest_error" schema="" table="mvtest_error" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_error AS SELECT 1 / 0 AS x" +== 121 +-- truncate_limit: 100 +-- fail +create materialized view mvtest_error as select 1/0 as x with no data +-- +TABLE: name="mvtest_error" schema="" table="mvtest_error" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_error AS SELECT 1 / 0 AS x WITH NO DATA" +== 122 +-- truncate_limit: 100 +refresh materialized view mvtest_error +-- +TABLE: name="mvtest_error" schema="" table="mvtest_error" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_error" +== 123 +-- truncate_limit: 100 +-- fail here +drop materialized view mvtest_error +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW mvtest_error" +== 124 +-- truncate_limit: 100 +-- make sure that matview rows can be referenced as source rows (bug #9398) +CREATE TABLE mvtest_v AS SELECT generate_series(1,10) AS a +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE mvtest_v AS SELECT generate_series(1, 10) AS a" +== 125 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_mv_v AS SELECT a FROM mvtest_v WHERE a <= 5 +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=DDL +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +FILTER: schema="" table="" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_v AS SELECT a FROM mvtest_v WHERE a <= 5" +== 126 +-- truncate_limit: 100 +DELETE FROM mvtest_v WHERE EXISTS ( SELECT * FROM mvtest_mv_v WHERE mvtest_mv_v.a = mvtest_v.a ) +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DML +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=Select +FILTER: schema="" table="mvtest_mv_v" column="a" +FILTER: schema="" table="mvtest_v" column="a" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM mvtest_v WHERE EXISTS (SELECT * FROM mvtest_mv_v WHERE mvtest_mv_v.a = mvtest_v.a)" +== 127 +-- truncate_limit: 100 +SELECT * FROM mvtest_v +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_v" +== 128 +-- truncate_limit: 100 +SELECT * FROM mvtest_mv_v +-- +TABLE: name="mvtest_mv_v" schema="" table="mvtest_mv_v" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest_mv_v" +== 129 +-- truncate_limit: 100 +DROP TABLE mvtest_v CASCADE +-- +TABLE: name="mvtest_v" schema="" table="mvtest_v" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mvtest_v CASCADE" +== 130 +-- truncate_limit: 100 +-- make sure running as superuser works when MV owned by another role (bug #11208) +CREATE ROLE regress_user_mvtest +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_user_mvtest" +== 131 +-- truncate_limit: 100 +SET ROLE regress_user_mvtest +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_user_mvtest" +== 132 +-- truncate_limit: 100 +-- this test case also checks for ambiguity in the queries issued by +-- refresh_by_match_merge(), by choosing column names that intentionally +-- duplicate all the aliases used in those queries +CREATE TABLE mvtest_foo_data AS SELECT i, + i+1 AS tid, + fipshash(random()::text) AS mv, + fipshash(random()::text) AS newdata, + fipshash(random()::text) AS newdata2, + fipshash(random()::text) AS diff + FROM generate_series(1, 10) i +-- +TABLE: name="mvtest_foo_data" schema="" table="mvtest_foo_data" ctx=DDL +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE mvtest_foo_data AS SELECT i, i + 1 AS tid, fipshash(random()::text) AS mv, fipshash(..." +== 133 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +TABLE: name="mvtest_foo_data" schema="" table="mvtest_foo_data" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data" +== 134 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +TABLE: name="mvtest_foo_data" schema="" table="mvtest_foo_data" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mvtest_mv_foo AS SELECT * FROM mvtest_foo_data" +== 135 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW IF NOT EXISTS mvtest_mv_foo AS SELECT * FROM mvtest_foo_data +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +TABLE: name="mvtest_foo_data" schema="" table="mvtest_foo_data" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW IF NOT EXISTS mvtest_mv_foo AS SELECT * FROM mvtest_foo_data" +== 136 +-- truncate_limit: 100 +CREATE UNIQUE INDEX ON mvtest_mv_foo (i) +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON mvtest_mv_foo USING btree (i)" +== 137 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 138 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW mvtest_mv_foo +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW mvtest_mv_foo" +== 139 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv_foo +-- +TABLE: name="mvtest_mv_foo" schema="" table="mvtest_mv_foo" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_mv_foo" +== 140 +-- truncate_limit: 100 +DROP OWNED BY regress_user_mvtest CASCADE +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_user_mvtest CASCADE" +== 141 +-- truncate_limit: 100 +DROP ROLE regress_user_mvtest +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_user_mvtest" +== 142 +-- truncate_limit: 100 +-- Concurrent refresh requires a unique index on the materialized +-- view. Test what happens if it's dropped during the refresh. +SET search_path = mvtest_mvschema, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO mvtest_mvschema, public" +== 143 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION mvtest_drop_the_index() + RETURNS bool AS $$ +BEGIN + EXECUTE 'DROP INDEX IF EXISTS mvtest_mvschema.mvtest_drop_idx'; + RETURN true; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="mvtest_drop_the_index" function="mvtest_drop_the_index" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION mvtest_drop_the_index() RETURNS bool AS $$\nBEGIN\n EXECUTE 'DROP INDEX..." +== 144 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW drop_idx_matview AS + SELECT 1 as i WHERE mvtest_drop_the_index() +-- +TABLE: name="drop_idx_matview" schema="" table="drop_idx_matview" ctx=DDL +FUNCTION: name="mvtest_drop_the_index" function="mvtest_drop_the_index" schema="" ctx=Call +FUNCTION: name="mvtest_drop_the_index" function="mvtest_drop_the_index" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW drop_idx_matview AS SELECT 1 AS i WHERE mvtest_drop_the_index()" +== 145 +-- truncate_limit: 100 +CREATE UNIQUE INDEX mvtest_drop_idx ON drop_idx_matview (i) +-- +TABLE: name="drop_idx_matview" schema="" table="drop_idx_matview" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX mvtest_drop_idx ON drop_idx_matview USING btree (i)" +== 146 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW CONCURRENTLY drop_idx_matview +-- +TABLE: name="drop_idx_matview" schema="" table="drop_idx_matview" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY drop_idx_matview" +== 147 +-- truncate_limit: 100 +DROP MATERIALIZED VIEW drop_idx_matview +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW drop_idx_matview" +== 148 +-- truncate_limit: 100 +-- clean up +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 149 +-- truncate_limit: 100 +-- make sure that create WITH NO DATA works via SPI +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 150 +-- truncate_limit: 100 +CREATE FUNCTION mvtest_func() + RETURNS void AS $$ +BEGIN + CREATE MATERIALIZED VIEW mvtest1 AS SELECT 1 AS x; + CREATE MATERIALIZED VIEW mvtest2 AS SELECT 1 AS x WITH NO DATA; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="mvtest_func" function="mvtest_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mvtest_func() RETURNS void AS $$\nBEGIN\n CREATE MATERIALIZED VIEW mvtest1 AS SELE..." +== 151 +-- truncate_limit: 100 +SELECT mvtest_func() +-- +FUNCTION: name="mvtest_func" function="mvtest_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mvtest_func()" +== 152 +-- truncate_limit: 100 +SELECT * FROM mvtest1 +-- +TABLE: name="mvtest1" schema="" table="mvtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest1" +== 153 +-- truncate_limit: 100 +SELECT * FROM mvtest2 +-- +TABLE: name="mvtest2" schema="" table="mvtest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mvtest2" +== 154 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 155 +-- truncate_limit: 100 +-- INSERT privileges if relation owner is not allowed to insert. +CREATE SCHEMA matview_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA matview_schema" +== 156 +-- truncate_limit: 100 +CREATE USER regress_matview_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_matview_user" +== 157 +-- truncate_limit: 100 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_matview_user + REVOKE INSERT ON TABLES FROM regress_matview_user +-- +STMT: AlterDefaultPrivilegesStmt +TRUNCATED: "ALTER DEFAULT PRIVILEGES FOR ROLE regress_matview_user REVOKE insert ON TABLES FROM regress_matvi..." +== 158 +-- truncate_limit: 100 +GRANT ALL ON SCHEMA matview_schema TO public +-- +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON SCHEMA matview_schema TO public" +== 159 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_matview_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_matview_user" +== 160 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW matview_schema.mv_withdata1 (a) AS + SELECT generate_series(1, 10) WITH DATA +-- +TABLE: name="matview_schema.mv_withdata1" schema="matview_schema" table="mv_withdata1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW matview_schema.mv_withdata1(a) AS SELECT generate_series(1, 10)" +== 161 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW matview_schema.mv_withdata2 (a) AS + SELECT generate_series(1, 10) WITH DATA +-- +TABLE: name="matview_schema.mv_withdata2" schema="matview_schema" table="mv_withdata2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE MATERIALIZED VIEW matview_schema.mv_..." +== 162 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW matview_schema.mv_withdata2 +-- +TABLE: name="matview_schema.mv_withdata2" schema="matview_schema" table="mv_withdata2" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW matview_schema.mv_withdata2" +== 163 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW matview_schema.mv_nodata1 (a) AS + SELECT generate_series(1, 10) WITH NO DATA +-- +TABLE: name="matview_schema.mv_nodata1" schema="matview_schema" table="mv_nodata1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW matview_schema.mv_nodata1(a) AS SELECT generate_series(1, 10) WITH NO DATA" +== 164 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW matview_schema.mv_nodata2 (a) AS + SELECT generate_series(1, 10) WITH NO DATA +-- +TABLE: name="matview_schema.mv_nodata2" schema="matview_schema" table="mv_nodata2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE MATERIALIZED VIEW matview_schema.mv_..." +== 165 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW matview_schema.mv_nodata2 +-- +TABLE: name="matview_schema.mv_nodata2" schema="matview_schema" table="mv_nodata2" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW matview_schema.mv_nodata2" +== 166 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 167 +-- truncate_limit: 100 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_matview_user + GRANT INSERT ON TABLES TO regress_matview_user +-- +STMT: AlterDefaultPrivilegesStmt +TRUNCATED: "ALTER DEFAULT PRIVILEGES FOR ROLE regress_matview_user GRANT insert ON TABLES TO regress_matview_..." +== 168 +-- truncate_limit: 100 +DROP SCHEMA matview_schema CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA matview_schema CASCADE" +== 169 +-- truncate_limit: 100 +DROP USER regress_matview_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_matview_user" +== 170 +-- truncate_limit: 100 +-- CREATE MATERIALIZED VIEW ... IF NOT EXISTS +CREATE MATERIALIZED VIEW matview_ine_tab AS SELECT 1 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW matview_ine_tab AS SELECT 1" +== 171 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW matview_ine_tab AS SELECT 1 / 0 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW matview_ine_tab AS SELECT 1 / 0" +== 172 +-- truncate_limit: 100 +-- error +CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS + SELECT 1 / 0 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS SELECT 1 / 0" +== 173 +-- truncate_limit: 100 +-- ok +CREATE MATERIALIZED VIEW matview_ine_tab AS + SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW matview_ine_tab AS SELECT 1 / 0 WITH NO DATA" +== 174 +-- truncate_limit: 100 +-- error +CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS + SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS SELECT 1 / 0 WITH NO DATA" +== 175 +-- truncate_limit: 100 +-- ok +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW matview_ine_tab AS + SELECT 1 / 0 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE MATERIALIZED VIEW matview_ine_tab AS..." +== 176 +-- truncate_limit: 100 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS + SELECT 1 / 0 +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE MATERIALIZED VIEW IF NOT EXISTS matv..." +== 177 +-- truncate_limit: 100 +-- ok +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW matview_ine_tab AS + SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE MATERIALIZED VIEW matview_ine_tab AS..." +== 178 +-- truncate_limit: 100 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE MATERIALIZED VIEW IF NOT EXISTS matview_ine_tab AS + SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="matview_ine_tab" schema="" table="matview_ine_tab" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE MATERIALIZED VIEW IF NOT EXISTS matv..." +== 179 +-- truncate_limit: 100 +-- ok +DROP MATERIALIZED VIEW matview_ine_tab +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW matview_ine_tab" diff --git a/parser/testdata/summary_truncate/postgres_regress/md5.metadata.json b/parser/testdata/summary_truncate/postgres_regress/md5.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/md5.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/md5.test b/parser/testdata/summary_truncate/postgres_regress/md5.test new file mode 100644 index 0000000..3bee282 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/md5.test @@ -0,0 +1,107 @@ +== 001 +-- truncate_limit: 100 +|-- +-- MD5 test suite - from IETF RFC 1321 +-- (see: https://www.rfc-editor.org/rfc/rfc1321) +|-- + +-- (The md5() function will error in OpenSSL FIPS mode. By keeping +-- this test in a separate file, it is easier to manage variant +-- results.) + +select md5('') = 'd41d8cd98f00b204e9800998ecf8427e' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('') = 'd41d8cd98f00b204e9800998ecf8427e' AS \"TRUE\"" +== 002 +-- truncate_limit: 100 +select md5('a') = '0cc175b9c0f1b6a831c399e269772661' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('a') = '0cc175b9c0f1b6a831c399e269772661' AS \"TRUE\"" +== 003 +-- truncate_limit: 100 +select md5('abc') = '900150983cd24fb0d6963f7d28e17f72' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('abc') = '900150983cd24fb0d6963f7d28e17f72' AS \"TRUE\"" +== 004 +-- truncate_limit: 100 +select md5('message digest') = 'f96b697d7cb7938d525a2f31aaf161d0' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('message digest') = 'f96b697d7cb7938d525a2f31aaf161d0' AS \"TRUE\"" +== 005 +-- truncate_limit: 100 +select md5('abcdefghijklmnopqrstuvwxyz') = 'c3fcd3d76192e4007dfb496cca67e13b' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('abcdefghijklmnopqrstuvwxyz') = 'c3fcd3d76192e4007dfb496cca67e13b' AS \"TRUE\"" +== 006 +-- truncate_limit: 100 +select md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') = 'd174ab98d277d9f5a5611c2c9f419d9f' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 007 +-- truncate_limit: 100 +select md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890') = '57edf4a22be3c955ac49da2e2107b67a' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 008 +-- truncate_limit: 100 +select md5(''::bytea) = 'd41d8cd98f00b204e9800998ecf8427e' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5(''::bytea) = 'd41d8cd98f00b204e9800998ecf8427e' AS \"TRUE\"" +== 009 +-- truncate_limit: 100 +select md5('a'::bytea) = '0cc175b9c0f1b6a831c399e269772661' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('a'::bytea) = '0cc175b9c0f1b6a831c399e269772661' AS \"TRUE\"" +== 010 +-- truncate_limit: 100 +select md5('abc'::bytea) = '900150983cd24fb0d6963f7d28e17f72' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('abc'::bytea) = '900150983cd24fb0d6963f7d28e17f72' AS \"TRUE\"" +== 011 +-- truncate_limit: 100 +select md5('message digest'::bytea) = 'f96b697d7cb7938d525a2f31aaf161d0' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('message digest'::bytea) = 'f96b697d7cb7938d525a2f31aaf161d0' AS \"TRUE\"" +== 012 +-- truncate_limit: 100 +select md5('abcdefghijklmnopqrstuvwxyz'::bytea) = 'c3fcd3d76192e4007dfb496cca67e13b' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT md5('abcdefghijklmnopqrstuvwxyz'::bytea) = 'c3fcd3d76192e4007dfb496cca67e13b' AS \"TRUE\"" +== 013 +-- truncate_limit: 100 +select md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'::bytea) = 'd174ab98d277d9f5a5611c2c9f419d9f' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 014 +-- truncate_limit: 100 +select md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890'::bytea) = '57edf4a22be3c955ac49da2e2107b67a' AS "TRUE" +-- +FUNCTION: name="md5" function="md5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." diff --git a/parser/testdata/summary_truncate/postgres_regress/memoize.metadata.json b/parser/testdata/summary_truncate/postgres_regress/memoize.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/memoize.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/memoize.test b/parser/testdata/summary_truncate/postgres_regress/memoize.test new file mode 100644 index 0000000..3fc49ae --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/memoize.test @@ -0,0 +1,648 @@ +== 001 +-- truncate_limit: 100 +-- Perform tests on the Memoize node. + +-- The cache hits/misses/evictions from the Memoize node can vary between +-- machines. Let's just replace the number with an 'N'. In order to allow us +-- to perform validation when the measure was zero, we replace a zero value +-- with "Zero". All other numbers are replaced with 'N'. +create function explain_memoize(query text, hide_hitmiss bool) returns setof text +language plpgsql as +$$ +declare + ln text; +begin + for ln in + execute format('explain (analyze, costs off, summary off, timing off) %s', + query) + loop + if hide_hitmiss = true then + ln := regexp_replace(ln, 'Hits: 0', 'Hits: Zero'); + ln := regexp_replace(ln, 'Hits: \d+', 'Hits: N'); + ln := regexp_replace(ln, 'Misses: 0', 'Misses: Zero'); + ln := regexp_replace(ln, 'Misses: \d+', 'Misses: N'); + end if; + ln := regexp_replace(ln, 'Evictions: 0', 'Evictions: Zero'); + ln := regexp_replace(ln, 'Evictions: \d+', 'Evictions: N'); + ln := regexp_replace(ln, 'Memory Usage: \d+', 'Memory Usage: N'); + ln := regexp_replace(ln, 'Heap Fetches: \d+', 'Heap Fetches: N'); + ln := regexp_replace(ln, 'loops=\d+', 'loops=N'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION explain_memoize(query text, hide_hitmiss bool) RETURNS SETOF text LANGUAGE plpgsq..." +== 002 +-- truncate_limit: 100 +-- Ensure we get a memoize node on the inner side of the nested loop +SET enable_hashjoin TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 003 +-- truncate_limit: 100 +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 004 +-- truncate_limit: 100 +SELECT explain_memoize(' +SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1 +INNER JOIN tenk1 t2 ON t1.unique1 = t2.twenty +WHERE t2.unique1 < 1000;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 005 +-- truncate_limit: 100 +-- And check we get the expected results. +SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1 +INNER JOIN tenk1 t2 ON t1.unique1 = t2.twenty +WHERE t2.unique1 < 1000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t1 JOIN tenk1 t2 ON t1.unique1 = t2.twenty WHERE t2.unique1 < 1000" +== 006 +-- truncate_limit: 100 +-- Try with LATERAL joins +SELECT explain_memoize(' +SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1, +LATERAL (SELECT t2.unique1 FROM tenk1 t2 + WHERE t1.twenty = t2.unique1 OFFSET 0) t2 +WHERE t1.unique1 < 1000;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 007 +-- truncate_limit: 100 +-- And check we get the expected results. +SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1, +LATERAL (SELECT t2.unique1 FROM tenk1 t2 + WHERE t1.twenty = t2.unique1 OFFSET 0) t2 +WHERE t1.unique1 < 1000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t1, LATERAL (SELECT ... FROM tenk1 t2 WHERE ... OFFSET 0) t2 WHERE ..." +== 008 +-- truncate_limit: 100 +-- Try with LATERAL joins +SELECT explain_memoize(' +SELECT COUNT(*),AVG(t2.t1two) FROM tenk1 t1 LEFT JOIN +LATERAL ( + SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 4 OFFSET 0 +) t2 +ON t1.two = t2.two +WHERE t1.unique1 < 10;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 009 +-- truncate_limit: 100 +-- And check we get the expected results. +SELECT COUNT(*),AVG(t2.t1two) FROM tenk1 t1 LEFT JOIN +LATERAL ( + SELECT t1.two as t1two, * FROM tenk1 t2 WHERE t2.unique1 < 4 OFFSET 0 +) t2 +ON t1.two = t2.two +WHERE t1.unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t1 LEFT JOIN LATERAL (SELECT ... FROM tenk1 t2 WHERE ... OFFSET 0) t2 ON t1..." +== 010 +-- truncate_limit: 100 +SET enable_mergejoin TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 011 +-- truncate_limit: 100 +-- Test for varlena datatype with expr evaluation +CREATE TABLE expr_key (x numeric, t text) +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE expr_key (x numeric, t text)" +== 012 +-- truncate_limit: 100 +INSERT INTO expr_key (x, t) +SELECT d1::numeric, d1::text FROM ( + SELECT round((d / pi())::numeric, 7) AS d1 FROM generate_series(1, 20) AS d +) t +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DML +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="pi" function="pi" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO expr_key (x, t) SELECT ... FROM (SELECT ... FROM generate_series(1, 20) d) t" +== 013 +-- truncate_limit: 100 +-- duplicate rows so we get some cache hits +INSERT INTO expr_key SELECT * FROM expr_key +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DML +TABLE: name="expr_key" schema="" table="expr_key" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO expr_key SELECT * FROM expr_key" +== 014 +-- truncate_limit: 100 +CREATE INDEX expr_key_idx_x_t ON expr_key (x, t) +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX expr_key_idx_x_t ON expr_key USING btree (x, t)" +== 015 +-- truncate_limit: 100 +VACUUM ANALYZE expr_key +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) expr_key" +== 016 +-- truncate_limit: 100 +-- Ensure we get we get a cache miss and hit for each of the 20 distinct values +SELECT explain_memoize(' +SELECT * FROM expr_key t1 INNER JOIN expr_key t2 +ON t1.x = t2.t::numeric AND t1.t::numeric = t2.x;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 017 +-- truncate_limit: 100 +DROP TABLE expr_key +-- +TABLE: name="expr_key" schema="" table="expr_key" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE expr_key" +== 018 +-- truncate_limit: 100 +-- Reduce work_mem and hash_mem_multiplier so that we see some cache evictions +SET work_mem TO '64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 019 +-- truncate_limit: 100 +SET hash_mem_multiplier TO 1.0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET hash_mem_multiplier TO 1.0" +== 020 +-- truncate_limit: 100 +-- Ensure we get some evictions. We're unable to validate the hits and misses +-- here as the number of entries that fit in the cache at once will vary +-- between different machines. +SELECT explain_memoize(' +SELECT COUNT(*),AVG(t1.unique1) FROM tenk1 t1 +INNER JOIN tenk1 t2 ON t1.unique1 = t2.thousand +WHERE t2.unique1 < 1200;', true) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 021 +-- truncate_limit: 100 +CREATE TABLE flt (f float) +-- +TABLE: name="flt" schema="" table="flt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE flt (f double precision)" +== 022 +-- truncate_limit: 100 +CREATE INDEX flt_f_idx ON flt (f) +-- +TABLE: name="flt" schema="" table="flt" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX flt_f_idx ON flt USING btree (f)" +== 023 +-- truncate_limit: 100 +INSERT INTO flt VALUES('-0.0'::float),('+0.0'::float) +-- +TABLE: name="flt" schema="" table="flt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO flt VALUES ('-0.0'::double precision), ('+0.0'::double precision)" +== 024 +-- truncate_limit: 100 +ANALYZE flt +-- +TABLE: name="flt" schema="" table="flt" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE flt" +== 025 +-- truncate_limit: 100 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 026 +-- truncate_limit: 100 +-- Ensure memoize operates in logical mode +SELECT explain_memoize(' +SELECT * FROM flt f1 INNER JOIN flt f2 ON f1.f = f2.f;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_memoize('\nSELECT * FROM flt f1 INNER JOIN flt f2 ON f1.f = f2.f;', false)" +== 027 +-- truncate_limit: 100 +-- Ensure memoize operates in binary mode +SELECT explain_memoize(' +SELECT * FROM flt f1 INNER JOIN flt f2 ON f1.f >= f2.f;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_memoize('\nSELECT * FROM flt f1 INNER JOIN flt f2 ON f1.f >= f2.f;', false)" +== 028 +-- truncate_limit: 100 +DROP TABLE flt +-- +TABLE: name="flt" schema="" table="flt" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE flt" +== 029 +-- truncate_limit: 100 +-- Exercise Memoize in binary mode with a large fixed width type and a +-- varlena type. +CREATE TABLE strtest (n name, t text) +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE strtest (n name, t text)" +== 030 +-- truncate_limit: 100 +CREATE INDEX strtest_n_idx ON strtest (n) +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX strtest_n_idx ON strtest USING btree (n)" +== 031 +-- truncate_limit: 100 +CREATE INDEX strtest_t_idx ON strtest (t) +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX strtest_t_idx ON strtest USING btree (t)" +== 032 +-- truncate_limit: 100 +INSERT INTO strtest VALUES('one','one'),('two','two'),('three',repeat(fipshash('three'),100)) +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO strtest VALUES ('one', 'one'), ('two', 'two'), ('three', repeat(fipshash('three'), 100))" +== 033 +-- truncate_limit: 100 +-- duplicate rows so we get some cache hits +INSERT INTO strtest SELECT * FROM strtest +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DML +TABLE: name="strtest" schema="" table="strtest" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO strtest SELECT * FROM strtest" +== 034 +-- truncate_limit: 100 +ANALYZE strtest +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE strtest" +== 035 +-- truncate_limit: 100 +-- Ensure we get 3 hits and 3 misses +SELECT explain_memoize(' +SELECT * FROM strtest s1 INNER JOIN strtest s2 ON s1.n >= s2.n;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_memoize('\nSELECT * FROM strtest s1 INNER JOIN strtest s2 ON s1.n >= s2.n;', false)" +== 036 +-- truncate_limit: 100 +-- Ensure we get 3 hits and 3 misses +SELECT explain_memoize(' +SELECT * FROM strtest s1 INNER JOIN strtest s2 ON s1.t >= s2.t;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_memoize('\nSELECT * FROM strtest s1 INNER JOIN strtest s2 ON s1.t >= s2.t;', false)" +== 037 +-- truncate_limit: 100 +DROP TABLE strtest +-- +TABLE: name="strtest" schema="" table="strtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE strtest" +== 038 +-- truncate_limit: 100 +-- Ensure memoize works with partitionwise join +SET enable_partitionwise_join TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_join TO ON" +== 039 +-- truncate_limit: 100 +CREATE TABLE prt (a int) PARTITION BY RANGE(a) +-- +TABLE: name="prt" schema="" table="prt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt (a int) PARTITION BY RANGE (a)" +== 040 +-- truncate_limit: 100 +CREATE TABLE prt_p1 PARTITION OF prt FOR VALUES FROM (0) TO (10) +-- +TABLE: name="prt_p1" schema="" table="prt_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt_p1 PARTITION OF prt FOR VALUES FROM (0) TO (10)" +== 041 +-- truncate_limit: 100 +CREATE TABLE prt_p2 PARTITION OF prt FOR VALUES FROM (10) TO (20) +-- +TABLE: name="prt_p2" schema="" table="prt_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt_p2 PARTITION OF prt FOR VALUES FROM (10) TO (20)" +== 042 +-- truncate_limit: 100 +INSERT INTO prt VALUES (0), (0), (0), (0) +-- +TABLE: name="prt" schema="" table="prt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt VALUES (0), (0), (0), (0)" +== 043 +-- truncate_limit: 100 +INSERT INTO prt VALUES (10), (10), (10), (10) +-- +TABLE: name="prt" schema="" table="prt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt VALUES (10), (10), (10), (10)" +== 044 +-- truncate_limit: 100 +CREATE INDEX iprt_p1_a ON prt_p1 (a) +-- +TABLE: name="prt_p1" schema="" table="prt_p1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt_p1_a ON prt_p1 USING btree (a)" +== 045 +-- truncate_limit: 100 +CREATE INDEX iprt_p2_a ON prt_p2 (a) +-- +TABLE: name="prt_p2" schema="" table="prt_p2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt_p2_a ON prt_p2 USING btree (a)" +== 046 +-- truncate_limit: 100 +ANALYZE prt +-- +TABLE: name="prt" schema="" table="prt" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt" +== 047 +-- truncate_limit: 100 +SELECT explain_memoize(' +SELECT * FROM prt t1 INNER JOIN prt t2 ON t1.a = t2.a;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_memoize('\nSELECT * FROM prt t1 INNER JOIN prt t2 ON t1.a = t2.a;', false)" +== 048 +-- truncate_limit: 100 +-- Ensure memoize works with parameterized union-all Append path +SET enable_partitionwise_join TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_join TO OFF" +== 049 +-- truncate_limit: 100 +SELECT explain_memoize(' +SELECT * FROM prt_p1 t1 INNER JOIN +(SELECT * FROM prt_p1 UNION ALL SELECT * FROM prt_p2) t2 +ON t1.a = t2.a;', false) +-- +FUNCTION: name="explain_memoize" function="explain_memoize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 050 +-- truncate_limit: 100 +DROP TABLE prt +-- +TABLE: name="prt" schema="" table="prt" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt" +== 051 +-- truncate_limit: 100 +RESET enable_partitionwise_join +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_partitionwise_join" +== 052 +-- truncate_limit: 100 +-- Exercise Memoize code that flushes the cache when a parameter changes which +-- is not part of the cache key. + +-- Ensure we get a Memoize plan +EXPLAIN (COSTS OFF) +SELECT unique1 FROM tenk1 t0 +WHERE unique1 < 3 + AND EXISTS ( + SELECT 1 FROM tenk1 t1 + INNER JOIN tenk1 t2 ON t1.unique1 = t2.hundred + WHERE t0.ten = t1.twenty AND t0.two <> t2.four OFFSET 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t0"="tenk1" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="t0" column="ten" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t0" column="two" +FILTER: schema="" table="t2" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 t0 WHERE unique1 < 3 AND EXISTS (SELECT 1 FROM tenk..." +== 053 +-- truncate_limit: 100 +-- Ensure the above query returns the correct result +SELECT unique1 FROM tenk1 t0 +WHERE unique1 < 3 + AND EXISTS ( + SELECT 1 FROM tenk1 t1 + INNER JOIN tenk1 t2 ON t1.unique1 = t2.hundred + WHERE t0.ten = t1.twenty AND t0.two <> t2.four OFFSET 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t0"="tenk1" +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="t0" column="ten" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t0" column="two" +FILTER: schema="" table="t2" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 t0 WHERE ..." +== 054 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 055 +-- truncate_limit: 100 +RESET enable_mergejoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_mergejoin" +== 056 +-- truncate_limit: 100 +RESET work_mem +-- +STMT: VariableSetStmt +TRUNCATED: "RESET work_mem" +== 057 +-- truncate_limit: 100 +RESET hash_mem_multiplier +-- +STMT: VariableSetStmt +TRUNCATED: "RESET hash_mem_multiplier" +== 058 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 059 +-- truncate_limit: 100 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 060 +-- truncate_limit: 100 +-- Test parallel plans with Memoize +SET min_parallel_table_scan_size TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 061 +-- truncate_limit: 100 +SET parallel_setup_cost TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 062 +-- truncate_limit: 100 +SET parallel_tuple_cost TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 063 +-- truncate_limit: 100 +SET max_parallel_workers_per_gather TO 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 064 +-- truncate_limit: 100 +-- Ensure we get a parallel plan. +EXPLAIN (COSTS OFF) +SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1, +LATERAL (SELECT t2.unique1 FROM tenk1 t2 WHERE t1.twenty = t2.unique1) t2 +WHERE t1.unique1 < 1000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t2" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*), avg(t2.unique1) FROM tenk1 t1, LATERAL (SELECT t2.unique1 FR..." +== 065 +-- truncate_limit: 100 +-- And ensure the parallel plan gives us the correct results. +SELECT COUNT(*),AVG(t2.unique1) FROM tenk1 t1, +LATERAL (SELECT t2.unique1 FROM tenk1 t2 WHERE t1.twenty = t2.unique1) t2 +WHERE t1.unique1 < 1000 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="unique1" +FILTER: schema="" table="t1" column="twenty" +FILTER: schema="" table="t2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t1, LATERAL (SELECT ... FROM tenk1 t2 WHERE ...) t2 WHERE t1.unique1 < 1000" +== 066 +-- truncate_limit: 100 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers_per_gather" +== 067 +-- truncate_limit: 100 +RESET parallel_tuple_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_tuple_cost" +== 068 +-- truncate_limit: 100 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 069 +-- truncate_limit: 100 +RESET min_parallel_table_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_table_scan_size" diff --git a/parser/testdata/summary_truncate/postgres_regress/merge.metadata.json b/parser/testdata/summary_truncate/postgres_regress/merge.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/merge.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/merge.test b/parser/testdata/summary_truncate/postgres_regress/merge.test new file mode 100644 index 0000000..fad8862 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/merge.test @@ -0,0 +1,5210 @@ +== 001 +-- truncate_limit: 100 +|-- +-- MERGE +|-- + +CREATE USER regress_merge_privs +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_merge_privs" +== 002 +-- truncate_limit: 100 +CREATE USER regress_merge_no_privs +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_merge_no_privs" +== 003 +-- truncate_limit: 100 +CREATE USER regress_merge_none +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_merge_none" +== 004 +-- truncate_limit: 100 +DROP TABLE IF EXISTS target +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE IF EXISTS target" +== 005 +-- truncate_limit: 100 +DROP TABLE IF EXISTS source +-- +TABLE: name="source" schema="" table="source" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE IF EXISTS source" +== 006 +-- truncate_limit: 100 +CREATE TABLE target (tid integer, balance integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE target (tid int, balance int) WITH (autovacuum_enabled=off)" +== 007 +-- truncate_limit: 100 +CREATE TABLE source (sid integer, delta integer) -- no index + WITH (autovacuum_enabled=off) +-- +TABLE: name="source" schema="" table="source" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE source (sid int, delta int) WITH (autovacuum_enabled=off)" +== 008 +-- truncate_limit: 100 +INSERT INTO target VALUES (1, 10) +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO target VALUES (1, 10)" +== 009 +-- truncate_limit: 100 +INSERT INTO target VALUES (2, 20) +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO target VALUES (2, 20)" +== 010 +-- truncate_limit: 100 +INSERT INTO target VALUES (3, 30) +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO target VALUES (3, 30)" +== 011 +-- truncate_limit: 100 +SELECT t.ctid is not null as matched, t.*, s.* FROM source s FULL OUTER JOIN target t ON s.sid = t.tid ORDER BY t.tid, s.sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +TABLE: name="target" schema="" table="target" ctx=Select +ALIAS: "s"="source" +ALIAS: "t"="target" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM source s FULL JOIN target t ON s.sid = t.tid ORDER BY t.tid, s.sid" +== 012 +-- truncate_limit: 100 +ALTER TABLE target OWNER TO regress_merge_privs +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE target OWNER TO regress_merge_privs" +== 013 +-- truncate_limit: 100 +ALTER TABLE source OWNER TO regress_merge_privs +-- +TABLE: name="source" schema="" table="source" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE source OWNER TO regress_merge_privs" +== 014 +-- truncate_limit: 100 +CREATE TABLE target2 (tid integer, balance integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="target2" schema="" table="target2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE target2 (tid int, balance int) WITH (autovacuum_enabled=off)" +== 015 +-- truncate_limit: 100 +CREATE TABLE source2 (sid integer, delta integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="source2" schema="" table="source2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE source2 (sid int, delta int) WITH (autovacuum_enabled=off)" +== 016 +-- truncate_limit: 100 +ALTER TABLE target2 OWNER TO regress_merge_no_privs +-- +TABLE: name="target2" schema="" table="target2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE target2 OWNER TO regress_merge_no_privs" +== 017 +-- truncate_limit: 100 +ALTER TABLE source2 OWNER TO regress_merge_no_privs +-- +TABLE: name="source2" schema="" table="source2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE source2 OWNER TO regress_merge_no_privs" +== 018 +-- truncate_limit: 100 +GRANT INSERT ON target TO regress_merge_no_privs +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON target TO regress_merge_no_privs" +== 019 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_merge_privs +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_merge_privs" +== 020 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: ExplainStmt +STMT: MergeStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN DELETE" +== 021 +-- truncate_limit: 100 +|-- +-- Errors +|-- +MERGE INTO target t RANDOMWORD +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +ERROR: syntax error at or near "RANDOMWORD" +CURSORPOS: 37 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 022 +-- truncate_limit: 100 +-- MATCHED/INSERT error +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + INSERT DEFAULT VALUES +-- +ERROR: syntax error at or near "INSERT" +CURSORPOS: 99 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 023 +-- truncate_limit: 100 +-- NOT MATCHED BY SOURCE/INSERT error +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED BY SOURCE THEN + INSERT DEFAULT VALUES +-- +ERROR: syntax error at or near "INSERT" +CURSORPOS: 127 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 024 +-- truncate_limit: 100 +-- incorrectly specifying INTO target +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT INTO target DEFAULT VALUES +-- +ERROR: syntax error at or near "INTO" +CURSORPOS: 124 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 025 +-- truncate_limit: 100 +-- Multiple VALUES clause +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (1,1), (2,2) +-- +ERROR: syntax error at or near "," +CURSORPOS: 124 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 026 +-- truncate_limit: 100 +-- SELECT query for INSERT +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT SELECT (1, 1) +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 113 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 027 +-- truncate_limit: 100 +-- NOT MATCHED/UPDATE +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + UPDATE SET balance = 0 +-- +ERROR: syntax error at or near "UPDATE" +CURSORPOS: 101 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 028 +-- truncate_limit: 100 +-- NOT MATCHED BY TARGET/UPDATE +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED BY TARGET THEN + UPDATE SET balance = 0 +-- +ERROR: syntax error at or near "UPDATE" +CURSORPOS: 121 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 029 +-- truncate_limit: 100 +-- UPDATE tablename +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE target SET balance = 0 +-- +ERROR: syntax error at or near "target" +CURSORPOS: 102 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 030 +-- truncate_limit: 100 +-- source and target names the same +MERGE INTO target +USING target +ON tid = tid +WHEN MATCHED THEN DO NOTHING +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO target USING target ON tid = tid WHEN MATCHED THEN DO NOTHING" +== 031 +-- truncate_limit: 100 +-- used in a CTE without RETURNING +WITH foo AS ( + MERGE INTO target USING source ON (true) + WHEN MATCHED THEN DELETE +) SELECT * FROM foo +-- +TABLE: name="target" schema="" table="target" ctx=DML +CTE: "foo" +STMT: SelectStmt +STMT: MergeStmt +TRUNCATED: "WITH foo AS (MERGE INTO target USING source ON true WHEN MATCHED THEN DELETE) SELECT * FROM foo" +== 032 +-- truncate_limit: 100 +-- used in COPY without RETURNING +COPY ( + MERGE INTO target USING source ON (true) + WHEN MATCHED THEN DELETE +) TO stdout +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: CopyStmt +TRUNCATED: "COPY (MERGE INTO target USING source ON true WHEN MATCHED THEN DELETE) TO STDOUT" +== 033 +-- truncate_limit: 100 +-- unsupported relation types +-- materialized view +CREATE MATERIALIZED VIEW mv AS SELECT * FROM target +-- +TABLE: name="mv" schema="" table="mv" ctx=DDL +TABLE: name="target" schema="" table="target" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mv AS SELECT * FROM target" +== 034 +-- truncate_limit: 100 +MERGE INTO mv t +USING source s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="mv" schema="" table="mv" ctx=DML +ALIAS: "t"="mv" +STMT: MergeStmt +TRUNCATED: "MERGE INTO mv t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT DEFAULT VALUES" +== 035 +-- truncate_limit: 100 +DROP MATERIALIZED VIEW mv +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW mv" +== 036 +-- truncate_limit: 100 +-- permissions + +SET SESSION AUTHORIZATION regress_merge_none +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_merge_none" +== 037 +-- truncate_limit: 100 +MERGE INTO target +USING (SELECT 1) +ON true +WHEN MATCHED THEN + DO NOTHING +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO target USING (SELECT 1) ON true WHEN MATCHED THEN DO NOTHING" +== 038 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_merge_privs +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_merge_privs" +== 039 +-- truncate_limit: 100 +MERGE INTO target +USING source2 +ON target.tid = source2.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO target USING source2 ON target.tid = source2.sid WHEN MATCHED THEN UPDATE SET balance = 0" +== 040 +-- truncate_limit: 100 +GRANT INSERT ON target TO regress_merge_no_privs +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON target TO regress_merge_no_privs" +== 041 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_merge_no_privs +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_merge_no_privs" +== 042 +-- truncate_limit: 100 +MERGE INTO target +USING source2 +ON target.tid = source2.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO target USING source2 ON target.tid = source2.sid WHEN MATCHED THEN UPDATE SET balance = 0" +== 043 +-- truncate_limit: 100 +GRANT UPDATE ON target2 TO regress_merge_privs +-- +TABLE: name="target2" schema="" table="target2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON target2 TO regress_merge_privs" +== 044 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_merge_privs +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_merge_privs" +== 045 +-- truncate_limit: 100 +MERGE INTO target2 +USING source +ON target2.tid = source.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target2" schema="" table="target2" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO target2 USING source ON target2.tid = source.sid WHEN MATCHED THEN DELETE" +== 046 +-- truncate_limit: 100 +MERGE INTO target2 +USING source +ON target2.tid = source.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="target2" schema="" table="target2" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO target2 USING source ON target2.tid = source.sid WHEN NOT MATCHED THEN INSERT DEFAULT ..." +== 047 +-- truncate_limit: 100 +-- check if the target can be accessed from source relation subquery; we should +-- not be able to do so +MERGE INTO target t +USING (SELECT * FROM source WHERE t.tid > sid) s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="source" schema="" table="source" ctx=Select +ALIAS: "t"="target" +FILTER: schema="" table="t" column="tid" +FILTER: schema="" table="" column="sid" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO target t USING (SELECT * FROM source WHERE ...) s ON t.tid = s.sid WHEN NOT MATCHED TH..." +== 048 +-- truncate_limit: 100 +|-- +-- initial tests +|-- +-- zero rows in source has no effect +MERGE INTO target +USING source +ON target.tid = source.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO target USING source ON target.tid = source.sid WHEN MATCHED THEN UPDATE SET balance = 0" +== 049 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET balance = 0" +== 050 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN DELETE" +== 051 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 052 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT DEFAULT VALUES" +== 053 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 054 +-- truncate_limit: 100 +-- insert some non-matching source rows to work from +INSERT INTO source VALUES (4, 40) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (4, 40)" +== 055 +-- truncate_limit: 100 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM source ORDER BY sid" +== 056 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 057 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + DO NOTHING +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN DO NOTHING" +== 058 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET balance = 0" +== 059 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN DELETE" +== 060 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 061 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT DEFAULT VALUES +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT DEFAULT VALUES" +== 062 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 063 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 064 +-- truncate_limit: 100 +-- DELETE/INSERT not matched by source/target +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 065 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED BY SOURCE THEN + DELETE +WHEN NOT MATCHED BY TARGET THEN + INSERT VALUES (s.sid, s.delta) +RETURNING merge_action(), t.* +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED BY SOURCE THEN DELETE WHEN N..." +== 066 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 067 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 068 +-- truncate_limit: 100 +-- index plans +INSERT INTO target SELECT generate_series(1000,2500), 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO target SELECT generate_series(1000, 2500), 0" +== 069 +-- truncate_limit: 100 +ALTER TABLE target ADD PRIMARY KEY (tid) +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE target ADD PRIMARY KEY (tid)" +== 070 +-- truncate_limit: 100 +ANALYZE target +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE target" +== 071 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: ExplainStmt +STMT: MergeStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE ..." +== 072 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: ExplainStmt +STMT: MergeStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN DELETE" +== 073 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (4, NULL) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: ExplainStmt +STMT: MergeStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INS..." +== 074 +-- truncate_limit: 100 +DELETE FROM target WHERE tid > 100 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM target WHERE tid > 100" +== 075 +-- truncate_limit: 100 +ANALYZE target +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE target" +== 076 +-- truncate_limit: 100 +-- insert some matching source rows to work from +INSERT INTO source VALUES (2, 5) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (2, 5)" +== 077 +-- truncate_limit: 100 +INSERT INTO source VALUES (3, 20) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (3, 20)" +== 078 +-- truncate_limit: 100 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM source ORDER BY sid" +== 079 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 080 +-- truncate_limit: 100 +-- equivalent of an UPDATE join +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 081 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET balance = 0" +== 082 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 083 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 084 +-- truncate_limit: 100 +-- equivalent of a DELETE join +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 085 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN DELETE" +== 086 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 087 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 088 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 089 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DO NOTHING +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN DO NOTHING" +== 090 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 091 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 092 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 093 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (4, NULL) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT VALUES (4, NULL)" +== 094 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 095 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 096 +-- truncate_limit: 100 +-- duplicate source row causes multiple target row update ERROR +INSERT INTO source VALUES (2, 5) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (2, 5)" +== 097 +-- truncate_limit: 100 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM source ORDER BY sid" +== 098 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 099 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 100 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET balance = 0" +== 101 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 102 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 103 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN DELETE" +== 104 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 105 +-- truncate_limit: 100 +-- remove duplicate MATCHED data from source data +DELETE FROM source WHERE sid = 2 +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM source WHERE sid = 2" +== 106 +-- truncate_limit: 100 +INSERT INTO source VALUES (2, 5) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (2, 5)" +== 107 +-- truncate_limit: 100 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM source ORDER BY sid" +== 108 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 109 +-- truncate_limit: 100 +-- duplicate source row on INSERT should fail because of target_pkey +INSERT INTO source VALUES (4, 40) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (4, 40)" +== 110 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 111 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (4, NULL) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT VALUES (4, NULL)" +== 112 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 113 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 114 +-- truncate_limit: 100 +-- remove duplicate NOT MATCHED data from source data +DELETE FROM source WHERE sid = 4 +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM source WHERE sid = 4" +== 115 +-- truncate_limit: 100 +INSERT INTO source VALUES (4, 40) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (4, 40)" +== 116 +-- truncate_limit: 100 +SELECT * FROM source ORDER BY sid +-- +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM source ORDER BY sid" +== 117 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 118 +-- truncate_limit: 100 +-- remove constraints +alter table target drop CONSTRAINT target_pkey +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE target DROP CONSTRAINT target_pkey" +== 119 +-- truncate_limit: 100 +alter table target alter column tid drop not null +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE target ALTER COLUMN tid DROP NOT NULL" +== 120 +-- truncate_limit: 100 +-- multiple actions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 121 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (4, 4) +WHEN MATCHED THEN + UPDATE SET balance = 0 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT VALUES (4, 4) WH..." +== 122 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 123 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 124 +-- truncate_limit: 100 +-- should be equivalent +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 125 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = 0 +WHEN NOT MATCHED THEN + INSERT VALUES (4, 4) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET balance = 0 WHEN..." +== 126 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 127 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 128 +-- truncate_limit: 100 +-- column references +-- do a simple equivalent of an UPDATE join +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 129 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = t.balance + s.delta +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET balance = t.bala..." +== 130 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 131 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 132 +-- truncate_limit: 100 +-- do a simple equivalent of an INSERT SELECT +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 133 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT VALUES (s.sid, s..." +== 134 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 135 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 136 +-- truncate_limit: 100 +-- and again with duplicate source rows +INSERT INTO source VALUES (5, 50) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (5, 50)" +== 137 +-- truncate_limit: 100 +INSERT INTO source VALUES (5, 50) +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO source VALUES (5, 50)" +== 138 +-- truncate_limit: 100 +-- do a simple equivalent of an INSERT SELECT +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 139 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT VALUES (s.sid, s..." +== 140 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 141 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 142 +-- truncate_limit: 100 +-- removing duplicate source rows +DELETE FROM source WHERE sid = 5 +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM source WHERE sid = 5" +== 143 +-- truncate_limit: 100 +-- and again with explicitly identified column list +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 144 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT (tid, balance) V..." +== 145 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 146 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 147 +-- truncate_limit: 100 +-- and again with a subtle error: referring to non-existent target row for NOT MATCHED +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (t.tid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT (tid, balance) V..." +== 148 +-- truncate_limit: 100 +-- and again with a constant ON clause +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 149 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON (SELECT true) +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (t.tid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO target t USING source s ON (SELECT ...) WHEN NOT MATCHED THEN INSERT (tid, balance) VA..." +== 150 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 151 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 152 +-- truncate_limit: 100 +-- now the classic UPSERT +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 153 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = t.balance + s.delta +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET balance = t.bala..." +== 154 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 155 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 156 +-- truncate_limit: 100 +-- unreachable WHEN clause should ERROR +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 157 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED THEN /* Terminal WHEN clause for MATCHED */ + DELETE +WHEN MATCHED THEN + UPDATE SET balance = t.balance - s.delta +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED THEN DELETE WHEN MATCHED THEN UP..." +== 158 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 159 +-- truncate_limit: 100 +-- conditional WHEN clause +CREATE TABLE wq_target (tid integer not null, balance integer DEFAULT -1) + WITH (autovacuum_enabled=off) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE wq_target (tid int NOT NULL, balance int DEFAULT -1) WITH (autovacuum_enabled=off)" +== 160 +-- truncate_limit: 100 +CREATE TABLE wq_source (balance integer, sid integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="wq_source" schema="" table="wq_source" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE wq_source (balance int, sid int) WITH (autovacuum_enabled=off)" +== 161 +-- truncate_limit: 100 +INSERT INTO wq_source (sid, balance) VALUES (1, 100) +-- +TABLE: name="wq_source" schema="" table="wq_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wq_source (sid, balance) VALUES (1, 100)" +== 162 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 163 +-- truncate_limit: 100 +-- try a simple INSERT with default values first +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT (tid) VALU..." +== 164 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 165 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 166 +-- truncate_limit: 100 +-- this time with a FALSE condition +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND FALSE THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN NOT MATCHED AND false THEN INSERT ..." +== 167 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 168 +-- truncate_limit: 100 +-- this time with an actual condition which returns false +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND s.balance <> 100 THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN NOT MATCHED AND s.balance <> 100 T..." +== 169 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 170 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 171 +-- truncate_limit: 100 +-- and now with a condition which returns true +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND s.balance = 100 THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN NOT MATCHED AND s.balance = 100 TH..." +== 172 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 173 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 174 +-- truncate_limit: 100 +-- conditions in the NOT MATCHED clause can only refer to source columns +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 175 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND t.balance = 100 THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN NOT MATCHED AND t.balance = 100 TH..." +== 176 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 177 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 178 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED AND s.balance = 100 THEN + INSERT (tid) VALUES (s.sid) +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN NOT MATCHED AND s.balance = 100 TH..." +== 179 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 180 +-- truncate_limit: 100 +-- conditions in NOT MATCHED BY SOURCE clause can only refer to target columns +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED BY SOURCE AND s.balance = 100 THEN + DELETE +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN NOT MATCHED BY SOURCE AND s.balanc..." +== 181 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN NOT MATCHED BY SOURCE AND t.balance = 100 THEN + DELETE +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN NOT MATCHED BY SOURCE AND t.balanc..." +== 182 +-- truncate_limit: 100 +-- conditions in MATCHED clause can refer to both source and target +SELECT * FROM wq_source +-- +TABLE: name="wq_source" schema="" table="wq_source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_source" +== 183 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND s.balance = 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND s.balance = 100 THEN U..." +== 184 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 185 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t.balance = 100 THEN U..." +== 186 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 187 +-- truncate_limit: 100 +-- check if AND works +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 99 AND s.balance > 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t.balance = 99 AND s.b..." +== 188 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 189 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 99 AND s.balance = 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t.balance = 99 AND s.b..." +== 190 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 191 +-- truncate_limit: 100 +-- check if OR works +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 99 OR s.balance > 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t.balance = 99 OR s.ba..." +== 192 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 193 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance = 199 OR s.balance > 100 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t.balance = 199 OR s.b..." +== 194 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 195 +-- truncate_limit: 100 +-- check source-side whole-row references +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 196 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON (t.tid = s.sid) +WHEN matched and t = s or t.tid = s.sid THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t = s OR t.tid = s.sid..." +== 197 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 198 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 199 +-- truncate_limit: 100 +-- check if subqueries work in the conditions? +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.balance > (SELECT max(balance) FROM target) THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +TABLE: name="target" schema="" table="target" ctx=Select +ALIAS: "t"="wq_target" +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t.balance > (SELECT ....." +== 200 +-- truncate_limit: 100 +-- check if we can access system columns in the conditions +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.xmin = t.xmax THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t.xmin = t.xmax THEN U..." +== 201 +-- truncate_limit: 100 +MERGE INTO wq_target t +USING wq_source s ON t.tid = s.sid +WHEN MATCHED AND t.tableoid >= 0 THEN + UPDATE SET balance = t.balance + s.balance +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DML +ALIAS: "t"="wq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO wq_target t USING wq_source s ON t.tid = s.sid WHEN MATCHED AND t.tableoid >= 0 THEN U..." +== 202 +-- truncate_limit: 100 +SELECT * FROM wq_target +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wq_target" +== 203 +-- truncate_limit: 100 +DROP TABLE wq_target, wq_source +-- +TABLE: name="wq_target" schema="" table="wq_target" ctx=DDL +TABLE: name="wq_source" schema="" table="wq_source" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE wq_target, wq_source" +== 204 +-- truncate_limit: 100 +-- test triggers +create or replace function merge_trigfunc () returns trigger +language plpgsql as +$$ +DECLARE + line text; +BEGIN + SELECT INTO line format('%s %s %s trigger%s', + TG_WHEN, TG_OP, TG_LEVEL, CASE + WHEN TG_OP = 'INSERT' AND TG_LEVEL = 'ROW' + THEN format(' row: %s', NEW) + WHEN TG_OP = 'UPDATE' AND TG_LEVEL = 'ROW' + THEN format(' row: %s -> %s', OLD, NEW) + WHEN TG_OP = 'DELETE' AND TG_LEVEL = 'ROW' + THEN format(' row: %s', OLD) + END); + + RAISE NOTICE '%', line; + IF (TG_WHEN = 'BEFORE' AND TG_LEVEL = 'ROW') THEN + IF (TG_OP = 'DELETE') THEN + RETURN OLD; + ELSE + RETURN NEW; + END IF; + ELSE + RETURN NULL; + END IF; +END; +$$ +-- +FUNCTION: name="merge_trigfunc" function="merge_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION merge_trigfunc() RETURNS trigger LANGUAGE plpgsql AS $$\nDECLARE\n\tline ..." +== 205 +-- truncate_limit: 100 +CREATE TRIGGER merge_bsi BEFORE INSERT ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_bsi BEFORE INSERT ON target EXECUTE FUNCTION merge_trigfunc()" +== 206 +-- truncate_limit: 100 +CREATE TRIGGER merge_bsu BEFORE UPDATE ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_bsu BEFORE UPDATE ON target EXECUTE FUNCTION merge_trigfunc()" +== 207 +-- truncate_limit: 100 +CREATE TRIGGER merge_bsd BEFORE DELETE ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_bsd BEFORE DELETE ON target EXECUTE FUNCTION merge_trigfunc()" +== 208 +-- truncate_limit: 100 +CREATE TRIGGER merge_asi AFTER INSERT ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_asi AFTER INSERT ON target EXECUTE FUNCTION merge_trigfunc()" +== 209 +-- truncate_limit: 100 +CREATE TRIGGER merge_asu AFTER UPDATE ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_asu AFTER UPDATE ON target EXECUTE FUNCTION merge_trigfunc()" +== 210 +-- truncate_limit: 100 +CREATE TRIGGER merge_asd AFTER DELETE ON target FOR EACH STATEMENT EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_asd AFTER DELETE ON target EXECUTE FUNCTION merge_trigfunc()" +== 211 +-- truncate_limit: 100 +CREATE TRIGGER merge_bri BEFORE INSERT ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_bri BEFORE INSERT ON target FOR EACH ROW EXECUTE FUNCTION merge_trigfunc()" +== 212 +-- truncate_limit: 100 +CREATE TRIGGER merge_bru BEFORE UPDATE ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_bru BEFORE UPDATE ON target FOR EACH ROW EXECUTE FUNCTION merge_trigfunc()" +== 213 +-- truncate_limit: 100 +CREATE TRIGGER merge_brd BEFORE DELETE ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_brd BEFORE DELETE ON target FOR EACH ROW EXECUTE FUNCTION merge_trigfunc()" +== 214 +-- truncate_limit: 100 +CREATE TRIGGER merge_ari AFTER INSERT ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_ari AFTER INSERT ON target FOR EACH ROW EXECUTE FUNCTION merge_trigfunc()" +== 215 +-- truncate_limit: 100 +CREATE TRIGGER merge_aru AFTER UPDATE ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_aru AFTER UPDATE ON target FOR EACH ROW EXECUTE FUNCTION merge_trigfunc()" +== 216 +-- truncate_limit: 100 +CREATE TRIGGER merge_ard AFTER DELETE ON target FOR EACH ROW EXECUTE PROCEDURE merge_trigfunc () +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_ard AFTER DELETE ON target FOR EACH ROW EXECUTE FUNCTION merge_trigfunc()" +== 217 +-- truncate_limit: 100 +-- now the classic UPSERT, with a DELETE +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 218 +-- truncate_limit: 100 +UPDATE target SET balance = 0 WHERE tid = 3 +-- +TABLE: name="target" schema="" table="target" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE target SET balance = 0 WHERE tid = 3" +== 219 +-- truncate_limit: 100 +--EXPLAIN (ANALYZE ON, COSTS OFF, SUMMARY OFF, TIMING OFF) +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED AND t.balance > s.delta THEN + UPDATE SET balance = t.balance - s.delta +WHEN MATCHED THEN + DELETE +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED AND t.balance > s.delta THEN UPD..." +== 220 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 221 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 222 +-- truncate_limit: 100 +-- UPSERT with UPDATE/DELETE when not matched by source +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 223 +-- truncate_limit: 100 +DELETE FROM SOURCE WHERE sid = 2 +-- +TABLE: name="source" schema="" table="source" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM source WHERE sid = 2" +== 224 +-- truncate_limit: 100 +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED AND t.balance > s.delta THEN + UPDATE SET balance = t.balance - s.delta +WHEN MATCHED THEN + UPDATE SET balance = 0 +WHEN NOT MATCHED THEN + INSERT VALUES (s.sid, s.delta) +WHEN NOT MATCHED BY SOURCE AND tid = 1 THEN + UPDATE SET balance = 0 +WHEN NOT MATCHED BY SOURCE THEN + DELETE +RETURNING merge_action(), t.* +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t USING source s ON t.tid = s.sid WHEN MATCHED AND t.balance > s.delta THEN UPD..." +== 225 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 226 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 227 +-- truncate_limit: 100 +-- Test behavior of triggers that turn UPDATE/DELETE into no-ops +create or replace function skip_merge_op() returns trigger +language plpgsql as +$$ +BEGIN + RETURN NULL; +END; +$$ +-- +FUNCTION: name="skip_merge_op" function="skip_merge_op" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION skip_merge_op() RETURNS trigger LANGUAGE plpgsql AS $$\nBEGIN\n\tRETURN N..." +== 228 +-- truncate_limit: 100 +SELECT * FROM target full outer join source on (sid = tid) +-- +TABLE: name="target" schema="" table="target" ctx=Select +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target FULL JOIN source ON sid = tid" +== 229 +-- truncate_limit: 100 +create trigger merge_skip BEFORE INSERT OR UPDATE or DELETE + ON target FOR EACH ROW EXECUTE FUNCTION skip_merge_op() +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_skip BEFORE INSERT OR DELETE OR UPDATE ON target FOR EACH ROW EXECUTE FUNCTI..." +== 230 +-- truncate_limit: 100 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED AND s.sid = 3 THEN UPDATE SET balance = t.balance + s.delta +WHEN MATCHED THEN DELETE +WHEN NOT MATCHED THEN INSERT VALUES (sid, delta); +IF FOUND THEN + RAISE NOTICE 'Found'; +ELSE + RAISE NOTICE 'Not found'; +END IF; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n result integer;\nBEGIN\nMERGE INTO target t\nUSING source AS s\nON t.tid = s.sid\nWHEN..." +== 231 +-- truncate_limit: 100 +SELECT * FROM target FULL OUTER JOIN source ON (sid = tid) +-- +TABLE: name="target" schema="" table="target" ctx=Select +TABLE: name="source" schema="" table="source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target FULL JOIN source ON sid = tid" +== 232 +-- truncate_limit: 100 +DROP TRIGGER merge_skip ON target +-- +TABLE: name="target" schema="" table="target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER merge_skip ON target" +== 233 +-- truncate_limit: 100 +DROP FUNCTION skip_merge_op() +-- +FUNCTION: name="skip_merge_op" function="skip_merge_op" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION skip_merge_op()" +== 234 +-- truncate_limit: 100 +-- test from PL/pgSQL +-- make sure MERGE INTO isn't interpreted to mean returning variables like SELECT INTO +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 235 +-- truncate_limit: 100 +DO LANGUAGE plpgsql $$ +BEGIN +MERGE INTO target t +USING source AS s +ON t.tid = s.sid +WHEN MATCHED AND t.balance > s.delta THEN + UPDATE SET balance = t.balance - s.delta; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO LANGUAGE plpgsql $$\nBEGIN\nMERGE INTO target t\nUSING source AS s\nON t.tid = s.sid\nWHEN MATCHED ..." +== 236 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 237 +-- truncate_limit: 100 +--source constants +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 238 +-- truncate_limit: 100 +MERGE INTO target t +USING (SELECT 9 AS sid, 57 AS delta) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO target t USING (SELECT ...) s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT (tid, bala..." +== 239 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 240 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 241 +-- truncate_limit: 100 +--source query +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 242 +-- truncate_limit: 100 +MERGE INTO target t +USING (SELECT sid, delta FROM source WHERE delta > 0) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="source" schema="" table="source" ctx=Select +ALIAS: "t"="target" +FILTER: schema="" table="" column="delta" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO target t USING (SELECT ... FROM source WHERE ...) s ON t.tid = s.sid WHEN NOT MATCHED ..." +== 243 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 244 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 245 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 246 +-- truncate_limit: 100 +MERGE INTO target t +USING (SELECT sid, delta as newname FROM source WHERE delta > 0) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.newname) +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="source" schema="" table="source" ctx=Select +ALIAS: "t"="target" +FILTER: schema="" table="" column="delta" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO target t USING (SELECT ... FROM source WHERE ...) s ON t.tid = s.sid WHEN NOT MATCHED ..." +== 247 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 248 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 249 +-- truncate_limit: 100 +--self-merge +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 250 +-- truncate_limit: 100 +MERGE INTO target t1 +USING target t2 +ON t1.tid = t2.tid +WHEN MATCHED THEN + UPDATE SET balance = t1.balance + t2.balance +WHEN NOT MATCHED THEN + INSERT VALUES (t2.tid, t2.balance) +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t1"="target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO target t1 USING target t2 ON t1.tid = t2.tid WHEN MATCHED THEN UPDATE SET balance = t1..." +== 251 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 252 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 253 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 254 +-- truncate_limit: 100 +MERGE INTO target t +USING (SELECT tid as sid, balance as delta FROM target WHERE balance > 0) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="target" schema="" table="target" ctx=Select +ALIAS: "t"="target" +FILTER: schema="" table="" column="balance" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO target t USING (SELECT ... FROM target WHERE ...) s ON t.tid = s.sid WHEN NOT MATCHED ..." +== 255 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 256 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 257 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 258 +-- truncate_limit: 100 +MERGE INTO target t +USING +(SELECT sid, max(delta) AS delta + FROM source + GROUP BY sid + HAVING count(*) = 1 + ORDER BY sid ASC) AS s +ON t.tid = s.sid +WHEN NOT MATCHED THEN + INSERT (tid, balance) VALUES (s.sid, s.delta) +-- +TABLE: name="target" schema="" table="target" ctx=DML +TABLE: name="source" schema="" table="source" ctx=Select +ALIAS: "t"="target" +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO target t USING (SELECT ... FROM source GROUP BY sid HAVING count(*) = 1 ORDER BY sid A..." +== 259 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 260 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 261 +-- truncate_limit: 100 +-- plpgsql parameters and results +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 262 +-- truncate_limit: 100 +CREATE FUNCTION merge_func (p_id integer, p_bal integer) +RETURNS INTEGER +LANGUAGE plpgsql +AS $$ +DECLARE + result integer; +BEGIN +MERGE INTO target t +USING (SELECT p_id AS sid) AS s +ON t.tid = s.sid +WHEN MATCHED THEN + UPDATE SET balance = t.balance - p_bal; +IF FOUND THEN + GET DIAGNOSTICS result := ROW_COUNT; +END IF; +RETURN result; +END; +$$ +-- +FUNCTION: name="merge_func" function="merge_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION merge_func(p_id int, p_bal int) RETURNS int LANGUAGE plpgsql AS $$\nDECLARE\n resul..." +== 263 +-- truncate_limit: 100 +SELECT merge_func(3, 4) +-- +FUNCTION: name="merge_func" function="merge_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT merge_func(3, 4)" +== 264 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 265 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 266 +-- truncate_limit: 100 +-- PREPARE +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 267 +-- truncate_limit: 100 +prepare foom as merge into target t using (select 1 as sid) s on (t.tid = s.sid) when matched then update set balance = 1 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: PrepareStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "PREPARE foom AS MERGE INTO target t USING (SELECT 1 AS sid) s ON t.tid = s.sid WHEN MATCHED THEN ..." +== 268 +-- truncate_limit: 100 +execute foom +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foom" +== 269 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 270 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 271 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 272 +-- truncate_limit: 100 +PREPARE foom2 (integer, integer) AS +MERGE INTO target t +USING (SELECT 1) s +ON t.tid = $1 +WHEN MATCHED THEN +UPDATE SET balance = $2 +-- +TABLE: name="target" schema="" table="target" ctx=DML +ALIAS: "t"="target" +STMT: PrepareStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "PREPARE foom2(int, int) AS MERGE INTO target t USING (SELECT 1) s ON t.tid = $1 WHEN MATCHED THEN..." +== 273 +-- truncate_limit: 100 +--EXPLAIN (ANALYZE ON, COSTS OFF, SUMMARY OFF, TIMING OFF) +execute foom2 (1, 1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foom2(1, 1)" +== 274 +-- truncate_limit: 100 +SELECT * FROM target ORDER BY tid +-- +TABLE: name="target" schema="" table="target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM target ORDER BY tid" +== 275 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 276 +-- truncate_limit: 100 +-- subqueries in source relation + +CREATE TABLE sq_target (tid integer NOT NULL, balance integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sq_target (tid int NOT NULL, balance int) WITH (autovacuum_enabled=off)" +== 277 +-- truncate_limit: 100 +CREATE TABLE sq_source (delta integer, sid integer, balance integer DEFAULT 0) + WITH (autovacuum_enabled=off) +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sq_source (delta int, sid int, balance int DEFAULT 0) WITH (autovacuum_enabled=off)" +== 278 +-- truncate_limit: 100 +INSERT INTO sq_target(tid, balance) VALUES (1,100), (2,200), (3,300) +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sq_target (tid, balance) VALUES (1, 100), (2, 200), (3, 300)" +== 279 +-- truncate_limit: 100 +INSERT INTO sq_source(sid, delta) VALUES (1,10), (2,20), (4,40) +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sq_source (sid, delta) VALUES (1, 10), (2, 20), (4, 40)" +== 280 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 281 +-- truncate_limit: 100 +MERGE INTO sq_target t +USING (SELECT * FROM sq_source) s +ON tid = sid +WHEN MATCHED AND t.balance > delta THEN + UPDATE SET balance = t.balance + delta +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_source" schema="" table="sq_source" ctx=Select +ALIAS: "t"="sq_target" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO sq_target t USING (SELECT * FROM sq_source) s ON tid = sid WHEN MATCHED AND t.balance ..." +== 282 +-- truncate_limit: 100 +SELECT * FROM sq_target +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_target" +== 283 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 284 +-- truncate_limit: 100 +-- try a view +CREATE VIEW v AS SELECT * FROM sq_source WHERE sid < 2 +-- +TABLE: name="v" schema="" table="v" ctx=DDL +TABLE: name="sq_source" schema="" table="sq_source" ctx=Select +FILTER: schema="" table="" column="sid" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v AS SELECT * FROM sq_source WHERE sid < 2" +== 285 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 286 +-- truncate_limit: 100 +MERGE INTO sq_target +USING v +ON tid = sid +WHEN MATCHED THEN + UPDATE SET balance = v.balance + delta +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO sq_target USING v ON tid = sid WHEN MATCHED THEN UPDATE SET balance = v.balance + delta" +== 287 +-- truncate_limit: 100 +SELECT * FROM sq_target +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_target" +== 288 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 289 +-- truncate_limit: 100 +-- ambiguous reference to a column +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 290 +-- truncate_limit: 100 +MERGE INTO sq_target +USING v +ON tid = sid +WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = balance + delta +WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) +WHEN MATCHED AND tid < 2 THEN + DELETE +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO sq_target USING v ON tid = sid WHEN MATCHED AND tid >= 2 THEN UPDATE SET balance = bal..." +== 291 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 292 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 293 +-- truncate_limit: 100 +INSERT INTO sq_source (sid, balance, delta) VALUES (-1, -1, -10) +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sq_source (sid, balance, delta) VALUES (-1, -1, -10)" +== 294 +-- truncate_limit: 100 +MERGE INTO sq_target t +USING v +ON tid = sid +WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta +WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) +WHEN MATCHED AND tid < 2 THEN + DELETE +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +ALIAS: "t"="sq_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO sq_target t USING v ON tid = sid WHEN MATCHED AND tid >= 2 THEN UPDATE SET balance = t..." +== 295 +-- truncate_limit: 100 +SELECT * FROM sq_target +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_target" +== 296 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 297 +-- truncate_limit: 100 +-- CTEs +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 298 +-- truncate_limit: 100 +INSERT INTO sq_source (sid, balance, delta) VALUES (-1, -1, -10) +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sq_source (sid, balance, delta) VALUES (-1, -1, -10)" +== 299 +-- truncate_limit: 100 +WITH targq AS ( + SELECT * FROM v +) +MERGE INTO sq_target t +USING v +ON tid = sid +WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta +WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) +WHEN MATCHED AND tid < 2 THEN + DELETE +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="v" schema="" table="v" ctx=Select +ALIAS: "t"="sq_target" +CTE: "targq" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "WITH targq AS (...) MERGE INTO sq_target t USING v ON tid = sid WHEN MATCHED AND tid >= 2 THEN UP..." +== 300 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 301 +-- truncate_limit: 100 +-- RETURNING +SELECT * FROM sq_source ORDER BY sid +-- +TABLE: name="sq_source" schema="" table="sq_source" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_source ORDER BY sid" +== 302 +-- truncate_limit: 100 +SELECT * FROM sq_target ORDER BY tid +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_target ORDER BY tid" +== 303 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 304 +-- truncate_limit: 100 +CREATE TABLE merge_actions(action text, abbrev text) +-- +TABLE: name="merge_actions" schema="" table="merge_actions" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE merge_actions (action text, abbrev text)" +== 305 +-- truncate_limit: 100 +INSERT INTO merge_actions VALUES ('INSERT', 'ins'), ('UPDATE', 'upd'), ('DELETE', 'del') +-- +TABLE: name="merge_actions" schema="" table="merge_actions" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO merge_actions VALUES ('INSERT', 'ins'), ('UPDATE', 'upd'), ('DELETE', 'del')" +== 306 +-- truncate_limit: 100 +MERGE INTO sq_target t +USING sq_source s +ON tid = sid +WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta +WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) +WHEN MATCHED AND tid < 2 THEN + DELETE +RETURNING (SELECT abbrev FROM merge_actions + WHERE action = merge_action()) AS action, + t.*, + CASE merge_action() + WHEN 'INSERT' THEN 'Inserted '||t + WHEN 'UPDATE' THEN 'Added '||delta||' to balance' + WHEN 'DELETE' THEN 'Removed '||t + END AS description +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="merge_actions" schema="" table="merge_actions" ctx=Select +ALIAS: "t"="sq_target" +FILTER: schema="" table="" column="action" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO sq_target t USING sq_source s ON tid = sid WHEN MATCHED AND tid >= 2 THEN UPDATE SET b..." +== 307 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 308 +-- truncate_limit: 100 +-- error when using merge_action() outside MERGE +SELECT merge_action() FROM sq_target +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT merge_action() FROM sq_target" +== 309 +-- truncate_limit: 100 +UPDATE sq_target SET balance = balance + 1 RETURNING merge_action() +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE sq_target SET balance = balance + 1 RETURNING merge_action()" +== 310 +-- truncate_limit: 100 +-- RETURNING in CTEs +CREATE TABLE sq_target_merge_log (tid integer NOT NULL, last_change text) +-- +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sq_target_merge_log (tid int NOT NULL, last_change text)" +== 311 +-- truncate_limit: 100 +INSERT INTO sq_target_merge_log VALUES (1, 'Original value') +-- +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sq_target_merge_log VALUES (1, 'Original value')" +== 312 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 313 +-- truncate_limit: 100 +WITH m AS ( + MERGE INTO sq_target t + USING sq_source s + ON tid = sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action() AS action, t.*, + CASE merge_action() + WHEN 'INSERT' THEN 'Inserted '||t + WHEN 'UPDATE' THEN 'Added '||delta||' to balance' + WHEN 'DELETE' THEN 'Removed '||t + END AS description +), m2 AS ( + MERGE INTO sq_target_merge_log l + USING m + ON l.tid = m.tid + WHEN MATCHED THEN + UPDATE SET last_change = description + WHEN NOT MATCHED THEN + INSERT VALUES (m.tid, description) + RETURNING action, merge_action() AS log_action, l.* +) +SELECT * FROM m2 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=DML +ALIAS: "l"="sq_target_merge_log" +ALIAS: "t"="sq_target" +CTE: "m" +CTE: "m2" +STMT: SelectStmt +STMT: MergeStmt +TRUNCATED: "WITH m AS (...), m2 AS (...) SELECT * FROM m2" +== 314 +-- truncate_limit: 100 +SELECT * FROM sq_target_merge_log ORDER BY tid +-- +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_target_merge_log ORDER BY tid" +== 315 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 316 +-- truncate_limit: 100 +-- COPY (MERGE ... RETURNING) TO ... +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 317 +-- truncate_limit: 100 +COPY ( + MERGE INTO sq_target t + USING sq_source s + ON tid = sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action(), t.* +) TO stdout +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +ALIAS: "t"="sq_target" +STMT: CopyStmt +TRUNCATED: "COPY (MERGE INTO sq_target t USING sq_source s ON tid = sid WHEN MATCHED AND tid >= 2 THEN UPDATE..." +== 318 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 319 +-- truncate_limit: 100 +-- SQL function with MERGE ... RETURNING +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 320 +-- truncate_limit: 100 +CREATE FUNCTION merge_into_sq_target(sid int, balance int, delta int, + OUT action text, OUT tid int, OUT new_balance int) +LANGUAGE sql AS +$$ + MERGE INTO sq_target t + USING (VALUES ($1, $2, $3)) AS v(sid, balance, delta) + ON tid = v.sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + v.delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (v.balance + v.delta, v.sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action(), t.*; +$$ +-- +FUNCTION: name="merge_into_sq_target" function="merge_into_sq_target" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION merge_into_sq_target(sid int, balance int, delta int, OUT action text, OUT tid in..." +== 321 +-- truncate_limit: 100 +SELECT m.* +FROM (VALUES (1, 0, 0), (3, 0, 20), (4, 100, 10)) AS v(sid, balance, delta), +LATERAL (SELECT action, tid, new_balance FROM merge_into_sq_target(sid, balance, delta)) m +-- +FUNCTION: name="merge_into_sq_target" function="merge_into_sq_target" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT m.* FROM (VALUES (...)) v(sid, balance, delta), LATERAL (SELECT ... FROM merge_into_sq_tar..." +== 322 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 323 +-- truncate_limit: 100 +-- SQL SRF with MERGE ... RETURNING +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 324 +-- truncate_limit: 100 +CREATE FUNCTION merge_sq_source_into_sq_target() +RETURNS TABLE (action text, tid int, balance int) +LANGUAGE sql AS +$$ + MERGE INTO sq_target t + USING sq_source s + ON tid = sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (balance + delta, sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action(), t.*; +$$ +-- +FUNCTION: name="merge_sq_source_into_sq_target" function="merge_sq_source_into_sq_target" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION merge_sq_source_into_sq_target() RETURNS TABLE (action text, tid int, balance int..." +== 325 +-- truncate_limit: 100 +SELECT * FROM merge_sq_source_into_sq_target() +-- +FUNCTION: name="merge_sq_source_into_sq_target" function="merge_sq_source_into_sq_target" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM merge_sq_source_into_sq_target()" +== 326 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 327 +-- truncate_limit: 100 +-- PL/pgSQL function with MERGE ... RETURNING ... INTO +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 328 +-- truncate_limit: 100 +CREATE FUNCTION merge_into_sq_target(sid int, balance int, delta int, + OUT r_action text, OUT r_tid int, OUT r_balance int) +LANGUAGE plpgsql AS +$$ +BEGIN + MERGE INTO sq_target t + USING (VALUES ($1, $2, $3)) AS v(sid, balance, delta) + ON tid = v.sid + WHEN MATCHED AND tid >= 2 THEN + UPDATE SET balance = t.balance + v.delta + WHEN NOT MATCHED THEN + INSERT (balance, tid) VALUES (v.balance + v.delta, v.sid) + WHEN MATCHED AND tid < 2 THEN + DELETE + RETURNING merge_action(), t.* INTO r_action, r_tid, r_balance; +END; +$$ +-- +FUNCTION: name="merge_into_sq_target" function="merge_into_sq_target" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION merge_into_sq_target(sid int, balance int, delta int, OUT r_action text, OUT r_ti..." +== 329 +-- truncate_limit: 100 +SELECT m.* +FROM (VALUES (1, 0, 0), (3, 0, 20), (4, 100, 10)) AS v(sid, balance, delta), +LATERAL (SELECT r_action, r_tid, r_balance FROM merge_into_sq_target(sid, balance, delta)) m +-- +FUNCTION: name="merge_into_sq_target" function="merge_into_sq_target" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT m.* FROM (VALUES (...)) v(sid, balance, delta), LATERAL (SELECT ... FROM merge_into_sq_tar..." +== 330 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 331 +-- truncate_limit: 100 +-- EXPLAIN +CREATE TABLE ex_mtarget (a int, b int) + WITH (autovacuum_enabled=off) +-- +TABLE: name="ex_mtarget" schema="" table="ex_mtarget" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ex_mtarget (a int, b int) WITH (autovacuum_enabled=off)" +== 332 +-- truncate_limit: 100 +CREATE TABLE ex_msource (a int, b int) + WITH (autovacuum_enabled=off) +-- +TABLE: name="ex_msource" schema="" table="ex_msource" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ex_msource (a int, b int) WITH (autovacuum_enabled=off)" +== 333 +-- truncate_limit: 100 +INSERT INTO ex_mtarget SELECT i, i*10 FROM generate_series(1,100,2) i +-- +TABLE: name="ex_mtarget" schema="" table="ex_mtarget" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ex_mtarget SELECT i, i * 10 FROM generate_series(1, 100, 2) i" +== 334 +-- truncate_limit: 100 +INSERT INTO ex_msource SELECT i, i*10 FROM generate_series(1,100,1) i +-- +TABLE: name="ex_msource" schema="" table="ex_msource" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ex_msource SELECT i, i * 10 FROM generate_series(1, 100, 1) i" +== 335 +-- truncate_limit: 100 +CREATE FUNCTION explain_merge(query text) RETURNS SETOF text +LANGUAGE plpgsql AS +$$ +DECLARE ln text; +BEGIN + FOR ln IN + EXECUTE 'explain (analyze, timing off, summary off, costs off) ' || + query + LOOP + ln := regexp_replace(ln, '(Memory( Usage)?|Buckets|Batches): \S*', '\1: xxx', 'g'); + RETURN NEXT ln; + END LOOP; +END; +$$ +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION explain_merge(query text) RETURNS SETOF text LANGUAGE plpgsql AS $$\nDECLARE ln te..." +== 336 +-- truncate_limit: 100 +-- only updates +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN MATCHED THEN + UPDATE SET b = t.b + 1') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 337 +-- truncate_limit: 100 +-- only updates to selected tuples +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN MATCHED AND t.a < 10 THEN + UPDATE SET b = t.b + 1') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 338 +-- truncate_limit: 100 +-- updates + deletes +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN MATCHED AND t.a < 10 THEN + UPDATE SET b = t.b + 1 +WHEN MATCHED AND t.a >= 10 AND t.a <= 20 THEN + DELETE') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 339 +-- truncate_limit: 100 +-- only inserts +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN NOT MATCHED AND s.a < 10 THEN + INSERT VALUES (a, b)') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 340 +-- truncate_limit: 100 +-- all three +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN MATCHED AND t.a < 10 THEN + UPDATE SET b = t.b + 1 +WHEN MATCHED AND t.a >= 30 AND t.a <= 40 THEN + DELETE +WHEN NOT MATCHED AND s.a < 20 THEN + INSERT VALUES (a, b)') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 341 +-- truncate_limit: 100 +-- not matched by source +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN NOT MATCHED BY SOURCE and t.a < 10 THEN + DELETE') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 342 +-- truncate_limit: 100 +-- not matched by source and target +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a +WHEN NOT MATCHED BY SOURCE AND t.a < 10 THEN + DELETE +WHEN NOT MATCHED BY TARGET AND s.a < 20 THEN + INSERT VALUES (a, b)') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 343 +-- truncate_limit: 100 +-- nothing +SELECT explain_merge(' +MERGE INTO ex_mtarget t USING ex_msource s ON t.a = s.a AND t.a < -1000 +WHEN MATCHED AND t.a < 10 THEN + DO NOTHING') +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 344 +-- truncate_limit: 100 +DROP TABLE ex_msource, ex_mtarget +-- +TABLE: name="ex_msource" schema="" table="ex_msource" ctx=DDL +TABLE: name="ex_mtarget" schema="" table="ex_mtarget" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ex_msource, ex_mtarget" +== 345 +-- truncate_limit: 100 +DROP FUNCTION explain_merge(text) +-- +FUNCTION: name="explain_merge" function="explain_merge" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION explain_merge(text)" +== 346 +-- truncate_limit: 100 +-- EXPLAIN SubPlans and InitPlans +CREATE TABLE src (a int, b int, c int, d int) +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE src (a int, b int, c int, d int)" +== 347 +-- truncate_limit: 100 +CREATE TABLE tgt (a int, b int, c int, d int) +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tgt (a int, b int, c int, d int)" +== 348 +-- truncate_limit: 100 +CREATE TABLE ref (ab int, cd int) +-- +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref (ab int, cd int)" +== 349 +-- truncate_limit: 100 +EXPLAIN (verbose, costs off) +MERGE INTO tgt t +USING (SELECT *, (SELECT count(*) FROM ref r + WHERE r.ab = s.a + s.b + AND r.cd = s.c - s.d) cnt + FROM src s) s +ON t.a = s.a AND t.b < s.cnt +WHEN MATCHED AND t.c > s.cnt THEN + UPDATE SET (b, c) = (SELECT s.b, s.cnt) +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DML +TABLE: name="src" schema="" table="src" ctx=Select +TABLE: name="ref" schema="" table="ref" ctx=Select +ALIAS: "r"="ref" +ALIAS: "s"="src" +ALIAS: "t"="tgt" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="r" column="ab" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="b" +FILTER: schema="" table="r" column="cd" +FILTER: schema="" table="s" column="c" +FILTER: schema="" table="s" column="d" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) MERGE INTO tgt t USING (SELECT *, (SELECT count(*) FROM ref r WHERE ..." +== 350 +-- truncate_limit: 100 +DROP TABLE src, tgt, ref +-- +TABLE: name="src" schema="" table="src" ctx=DDL +TABLE: name="tgt" schema="" table="tgt" ctx=DDL +TABLE: name="ref" schema="" table="ref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE src, tgt, ref" +== 351 +-- truncate_limit: 100 +-- Subqueries +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 352 +-- truncate_limit: 100 +MERGE INTO sq_target t +USING v +ON tid = sid +WHEN MATCHED THEN + UPDATE SET balance = (SELECT count(*) FROM sq_target) +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +ALIAS: "t"="sq_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO sq_target t USING v ON tid = sid WHEN MATCHED THEN UPDATE SET balance = (SELECT ... FR..." +== 353 +-- truncate_limit: 100 +SELECT * FROM sq_target WHERE tid = 1 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +FILTER: schema="" table="" column="tid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_target WHERE tid = 1" +== 354 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 355 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 356 +-- truncate_limit: 100 +MERGE INTO sq_target t +USING v +ON tid = sid +WHEN MATCHED AND (SELECT count(*) > 0 FROM sq_target) THEN + UPDATE SET balance = 42 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +ALIAS: "t"="sq_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO sq_target t USING v ON tid = sid WHEN MATCHED AND (SELECT ... FROM sq_target) THEN UPD..." +== 357 +-- truncate_limit: 100 +SELECT * FROM sq_target WHERE tid = 1 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +FILTER: schema="" table="" column="tid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_target WHERE tid = 1" +== 358 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 359 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 360 +-- truncate_limit: 100 +MERGE INTO sq_target t +USING v +ON tid = sid AND (SELECT count(*) > 0 FROM sq_target) +WHEN MATCHED THEN + UPDATE SET balance = 42 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DML +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +ALIAS: "t"="sq_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO sq_target t USING v ON tid = sid AND (SELECT ... FROM sq_target) WHEN MATCHED THEN UPD..." +== 361 +-- truncate_limit: 100 +SELECT * FROM sq_target WHERE tid = 1 +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=Select +FILTER: schema="" table="" column="tid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sq_target WHERE tid = 1" +== 362 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 363 +-- truncate_limit: 100 +DROP TABLE sq_target, sq_target_merge_log, sq_source CASCADE +-- +TABLE: name="sq_target" schema="" table="sq_target" ctx=DDL +TABLE: name="sq_target_merge_log" schema="" table="sq_target_merge_log" ctx=DDL +TABLE: name="sq_source" schema="" table="sq_source" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sq_target, sq_target_merge_log, sq_source CASCADE" +== 364 +-- truncate_limit: 100 +CREATE TABLE pa_target (tid integer, balance float, val text) + PARTITION BY LIST (tid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pa_target (tid int, balance double precision, val text) PARTITION BY LIST (tid)" +== 365 +-- truncate_limit: 100 +CREATE TABLE part1 PARTITION OF pa_target FOR VALUES IN (1,4) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part1 PARTITION OF pa_target FOR VALUES IN (1, 4) WITH (autovacuum_enabled=off)" +== 366 +-- truncate_limit: 100 +CREATE TABLE part2 PARTITION OF pa_target FOR VALUES IN (2,5,6) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part2 PARTITION OF pa_target FOR VALUES IN (2, 5, 6) WITH (autovacuum_enabled=off)" +== 367 +-- truncate_limit: 100 +CREATE TABLE part3 PARTITION OF pa_target FOR VALUES IN (3,8,9) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part3 PARTITION OF pa_target FOR VALUES IN (3, 8, 9) WITH (autovacuum_enabled=off)" +== 368 +-- truncate_limit: 100 +CREATE TABLE part4 PARTITION OF pa_target DEFAULT + WITH (autovacuum_enabled=off) +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part4 PARTITION OF pa_target DEFAULT WITH (autovacuum_enabled=off)" +== 369 +-- truncate_limit: 100 +CREATE TABLE pa_source (sid integer, delta float) +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pa_source (sid int, delta double precision)" +== 370 +-- truncate_limit: 100 +-- insert many rows to the source table +INSERT INTO pa_source SELECT id, id * 10 FROM generate_series(1,14) AS id +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pa_source SELECT id, id * 10 FROM generate_series(1, 14) id" +== 371 +-- truncate_limit: 100 +-- insert a few rows in the target table (odd numbered tid) +INSERT INTO pa_target SELECT id, id * 100, 'initial' FROM generate_series(1,15,2) AS id +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pa_target SELECT id, id * 100, 'initial' FROM generate_series(1, 15, 2) id" +== 372 +-- truncate_limit: 100 +-- try simple MERGE +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 373 +-- truncate_limit: 100 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source' +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET balance = ..." +== 374 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 375 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 376 +-- truncate_limit: 100 +-- same with a constant qual +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 377 +-- truncate_limit: 100 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid AND tid = 1 + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source' +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid AND tid = 1 WHEN MATCHED THEN UPDATE SE..." +== 378 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 379 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 380 +-- truncate_limit: 100 +-- try updating the partition key column +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 381 +-- truncate_limit: 100 +CREATE FUNCTION merge_func() RETURNS integer LANGUAGE plpgsql AS $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET tid = 1, val = val || ' not matched by source'; +IF FOUND THEN + GET DIAGNOSTICS result := ROW_COUNT; +END IF; +RETURN result; +END; +$$ +-- +FUNCTION: name="merge_func" function="merge_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION merge_func() RETURNS int LANGUAGE plpgsql AS $$\nDECLARE\n result integer;\nBEGIN\nM..." +== 382 +-- truncate_limit: 100 +SELECT merge_func() +-- +FUNCTION: name="merge_func" function="merge_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT merge_func()" +== 383 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 384 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 385 +-- truncate_limit: 100 +-- update partition key to partition not initially scanned +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 386 +-- truncate_limit: 100 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid AND t.tid = 1 + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + RETURNING merge_action(), t.* +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid AND t.tid = 1 WHEN MATCHED THEN UPDATE ..." +== 387 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid" +== 388 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 389 +-- truncate_limit: 100 +-- bug #18871: ExecInitPartitionInfo()'s handling of DO NOTHING actions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 390 +-- truncate_limit: 100 +TRUNCATE pa_target +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE pa_target" +== 391 +-- truncate_limit: 100 +MERGE INTO pa_target t + USING (VALUES (10, 100)) AS s(sid, delta) + ON t.tid = s.sid + WHEN NOT MATCHED THEN + INSERT VALUES (1, 10, 'inserted by merge') + WHEN MATCHED THEN + DO NOTHING +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO pa_target t USING (VALUES (...)) s(sid, delta) ON t.tid = s.sid WHEN NOT MATCHED THEN ..." +== 392 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 393 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 394 +-- truncate_limit: 100 +DROP TABLE pa_target CASCADE +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pa_target CASCADE" +== 395 +-- truncate_limit: 100 +-- The target table is partitioned in the same way, but this time by attaching +-- partitions which have columns in different order, dropped columns etc. +CREATE TABLE pa_target (tid integer, balance float, val text) + PARTITION BY LIST (tid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pa_target (tid int, balance double precision, val text) PARTITION BY LIST (tid)" +== 396 +-- truncate_limit: 100 +CREATE TABLE part1 (tid integer, balance float, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part1" schema="" table="part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part1 (tid int, balance double precision, val text) WITH (autovacuum_enabled=off)" +== 397 +-- truncate_limit: 100 +CREATE TABLE part2 (balance float, tid integer, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part2" schema="" table="part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part2 (balance double precision, tid int, val text) WITH (autovacuum_enabled=off)" +== 398 +-- truncate_limit: 100 +CREATE TABLE part3 (tid integer, balance float, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part3" schema="" table="part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part3 (tid int, balance double precision, val text) WITH (autovacuum_enabled=off)" +== 399 +-- truncate_limit: 100 +CREATE TABLE part4 (extraid text, tid integer, balance float, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part4 (extraid text, tid int, balance double precision, val text) WITH (autovacuum_e..." +== 400 +-- truncate_limit: 100 +ALTER TABLE part4 DROP COLUMN extraid +-- +TABLE: name="part4" schema="" table="part4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part4 DROP extraid" +== 401 +-- truncate_limit: 100 +ALTER TABLE pa_target ATTACH PARTITION part1 FOR VALUES IN (1,4) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pa_target ATTACH PARTITION part1 FOR VALUES IN (1, 4)" +== 402 +-- truncate_limit: 100 +ALTER TABLE pa_target ATTACH PARTITION part2 FOR VALUES IN (2,5,6) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pa_target ATTACH PARTITION part2 FOR VALUES IN (2, 5, 6)" +== 403 +-- truncate_limit: 100 +ALTER TABLE pa_target ATTACH PARTITION part3 FOR VALUES IN (3,8,9) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pa_target ATTACH PARTITION part3 FOR VALUES IN (3, 8, 9)" +== 404 +-- truncate_limit: 100 +ALTER TABLE pa_target ATTACH PARTITION part4 DEFAULT +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pa_target ATTACH PARTITION part4 DEFAULT" +== 405 +-- truncate_limit: 100 +-- insert a few rows in the target table (odd numbered tid) +INSERT INTO pa_target SELECT id, id * 100, 'initial' FROM generate_series(1,15,2) AS id +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pa_target SELECT id, id * 100, 'initial' FROM generate_series(1, 15, 2) id" +== 406 +-- truncate_limit: 100 +-- try simple MERGE +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 407 +-- truncate_limit: 100 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source'; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n result integer;\nBEGIN\nMERGE INTO pa_target t\n USING pa_source s\n ON t.tid = s.s..." +== 408 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 409 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 410 +-- truncate_limit: 100 +-- same with a constant qual +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 411 +-- truncate_limit: 100 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid AND tid IN (1, 5) + WHEN MATCHED AND tid % 5 = 0 THEN DELETE + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source' +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid AND tid IN (1, 5) WHEN MATCHED AND (tid..." +== 412 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 413 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 414 +-- truncate_limit: 100 +-- try updating the partition key column +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 415 +-- truncate_limit: 100 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET tid = 1, val = val || ' not matched by source'; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n result integer;\nBEGIN\nMERGE INTO pa_target t\n USING pa_source s\n ON t.tid = s.s..." +== 416 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 417 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 418 +-- truncate_limit: 100 +-- as above, but blocked by BEFORE DELETE ROW trigger +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 419 +-- truncate_limit: 100 +CREATE FUNCTION trig_fn() RETURNS trigger LANGUAGE plpgsql AS + $$ BEGIN RETURN NULL; END; $$ +-- +FUNCTION: name="trig_fn" function="trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trig_fn() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RETURN NULL; END; $$" +== 420 +-- truncate_limit: 100 +CREATE TRIGGER del_trig BEFORE DELETE ON pa_target + FOR EACH ROW EXECUTE PROCEDURE trig_fn() +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER del_trig BEFORE DELETE ON pa_target FOR EACH ROW EXECUTE FUNCTION trig_fn()" +== 421 +-- truncate_limit: 100 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source'; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n result integer;\nBEGIN\nMERGE INTO pa_target t\n USING pa_source s\n ON t.tid = s.s..." +== 422 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 423 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 424 +-- truncate_limit: 100 +-- as above, but blocked by BEFORE INSERT ROW trigger +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 425 +-- truncate_limit: 100 +CREATE FUNCTION trig_fn() RETURNS trigger LANGUAGE plpgsql AS + $$ BEGIN RETURN NULL; END; $$ +-- +FUNCTION: name="trig_fn" function="trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trig_fn() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RETURN NULL; END; $$" +== 426 +-- truncate_limit: 100 +CREATE TRIGGER ins_trig BEFORE INSERT ON pa_target + FOR EACH ROW EXECUTE PROCEDURE trig_fn() +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER ins_trig BEFORE INSERT ON pa_target FOR EACH ROW EXECUTE FUNCTION trig_fn()" +== 427 +-- truncate_limit: 100 +DO $$ +DECLARE + result integer; +BEGIN +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET tid = tid + 1, balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (sid, delta, 'inserted by merge') + WHEN NOT MATCHED BY SOURCE THEN + UPDATE SET val = val || ' not matched by source'; +GET DIAGNOSTICS result := ROW_COUNT; +RAISE NOTICE 'ROW_COUNT = %', result; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n result integer;\nBEGIN\nMERGE INTO pa_target t\n USING pa_source s\n ON t.tid = s.s..." +== 428 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid, val +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid, val" +== 429 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 430 +-- truncate_limit: 100 +-- test RLS enforcement +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 431 +-- truncate_limit: 100 +ALTER TABLE pa_target ENABLE ROW LEVEL SECURITY +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pa_target ENABLE ROW LEVEL SECURITY" +== 432 +-- truncate_limit: 100 +ALTER TABLE pa_target FORCE ROW LEVEL SECURITY +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pa_target FORCE ROW LEVEL SECURITY" +== 433 +-- truncate_limit: 100 +CREATE POLICY pa_target_pol ON pa_target USING (tid != 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY pa_target_pol ON pa_target TO public USING (tid <> 0)" +== 434 +-- truncate_limit: 100 +MERGE INTO pa_target t + USING pa_source s + ON t.tid = s.sid AND t.tid IN (1,2,3,4) + WHEN MATCHED THEN + UPDATE SET tid = tid - 1 +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid AND t.tid IN (1, 2, 3, 4) WHEN MATCHED ..." +== 435 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 436 +-- truncate_limit: 100 +DROP TABLE pa_source +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pa_source" +== 437 +-- truncate_limit: 100 +DROP TABLE pa_target CASCADE +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pa_target CASCADE" +== 438 +-- truncate_limit: 100 +-- Sub-partitioning +CREATE TABLE pa_target (logts timestamp, tid integer, balance float, val text) + PARTITION BY RANGE (logts) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pa_target (logts timestamp, tid int, balance double precision, val text) PARTITION B..." +== 439 +-- truncate_limit: 100 +CREATE TABLE part_m01 PARTITION OF pa_target + FOR VALUES FROM ('2017-01-01') TO ('2017-02-01') + PARTITION BY LIST (tid) +-- +TABLE: name="part_m01" schema="" table="part_m01" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_m01 PARTITION OF pa_target FOR VALUES FROM ('2017-01-01') TO ('2017-02-01') PAR..." +== 440 +-- truncate_limit: 100 +CREATE TABLE part_m01_odd PARTITION OF part_m01 + FOR VALUES IN (1,3,5,7,9) WITH (autovacuum_enabled=off) +-- +TABLE: name="part_m01_odd" schema="" table="part_m01_odd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_m01_odd PARTITION OF part_m01 FOR VALUES IN (1, 3, 5, 7, 9) WITH (autovacuum_en..." +== 441 +-- truncate_limit: 100 +CREATE TABLE part_m01_even PARTITION OF part_m01 + FOR VALUES IN (2,4,6,8) WITH (autovacuum_enabled=off) +-- +TABLE: name="part_m01_even" schema="" table="part_m01_even" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_m01_even PARTITION OF part_m01 FOR VALUES IN (2, 4, 6, 8) WITH (autovacuum_enab..." +== 442 +-- truncate_limit: 100 +CREATE TABLE part_m02 PARTITION OF pa_target + FOR VALUES FROM ('2017-02-01') TO ('2017-03-01') + PARTITION BY LIST (tid) +-- +TABLE: name="part_m02" schema="" table="part_m02" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_m02 PARTITION OF pa_target FOR VALUES FROM ('2017-02-01') TO ('2017-03-01') PAR..." +== 443 +-- truncate_limit: 100 +CREATE TABLE part_m02_odd PARTITION OF part_m02 + FOR VALUES IN (1,3,5,7,9) WITH (autovacuum_enabled=off) +-- +TABLE: name="part_m02_odd" schema="" table="part_m02_odd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_m02_odd PARTITION OF part_m02 FOR VALUES IN (1, 3, 5, 7, 9) WITH (autovacuum_en..." +== 444 +-- truncate_limit: 100 +CREATE TABLE part_m02_even PARTITION OF part_m02 + FOR VALUES IN (2,4,6,8) WITH (autovacuum_enabled=off) +-- +TABLE: name="part_m02_even" schema="" table="part_m02_even" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_m02_even PARTITION OF part_m02 FOR VALUES IN (2, 4, 6, 8) WITH (autovacuum_enab..." +== 445 +-- truncate_limit: 100 +CREATE TABLE pa_source (sid integer, delta float) + WITH (autovacuum_enabled=off) +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pa_source (sid int, delta double precision) WITH (autovacuum_enabled=off)" +== 446 +-- truncate_limit: 100 +-- insert many rows to the source table +INSERT INTO pa_source SELECT id, id * 10 FROM generate_series(1,14) AS id +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pa_source SELECT id, id * 10 FROM generate_series(1, 14) id" +== 447 +-- truncate_limit: 100 +-- insert a few rows in the target table (odd numbered tid) +INSERT INTO pa_target SELECT '2017-01-31', id, id * 100, 'initial' FROM generate_series(1,9,3) AS id +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pa_target SELECT '2017-01-31', id, id * 100, 'initial' FROM generate_series(1, 9, 3) id" +== 448 +-- truncate_limit: 100 +INSERT INTO pa_target SELECT '2017-02-28', id, id * 100, 'initial' FROM generate_series(2,9,3) AS id +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pa_target SELECT '2017-02-28', id, id * 100, 'initial' FROM generate_series(2, 9, 3) id" +== 449 +-- truncate_limit: 100 +-- try simple MERGE +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 450 +-- truncate_limit: 100 +MERGE INTO pa_target t + USING (SELECT '2017-01-15' AS slogts, * FROM pa_source WHERE sid < 10) s + ON t.tid = s.sid + WHEN MATCHED THEN + UPDATE SET balance = balance + delta, val = val || ' updated by merge' + WHEN NOT MATCHED THEN + INSERT VALUES (slogts::timestamp, sid, delta, 'inserted by merge') + RETURNING merge_action(), t.* +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +TABLE: name="pa_source" schema="" table="pa_source" ctx=Select +ALIAS: "t"="pa_target" +FILTER: schema="" table="" column="sid" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO pa_target t USING (SELECT ... FROM pa_source WHERE ...) s ON t.tid = s.sid WHEN MATCHE..." +== 451 +-- truncate_limit: 100 +SELECT * FROM pa_target ORDER BY tid +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target ORDER BY tid" +== 452 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 453 +-- truncate_limit: 100 +DROP TABLE pa_source +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pa_source" +== 454 +-- truncate_limit: 100 +DROP TABLE pa_target CASCADE +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pa_target CASCADE" +== 455 +-- truncate_limit: 100 +-- Partitioned table with primary key + +CREATE TABLE pa_target (tid integer PRIMARY KEY) PARTITION BY LIST (tid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pa_target (tid int PRIMARY KEY) PARTITION BY LIST (tid)" +== 456 +-- truncate_limit: 100 +CREATE TABLE pa_targetp PARTITION OF pa_target DEFAULT +-- +TABLE: name="pa_targetp" schema="" table="pa_targetp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pa_targetp PARTITION OF pa_target DEFAULT" +== 457 +-- truncate_limit: 100 +CREATE TABLE pa_source (sid integer) +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pa_source (sid int)" +== 458 +-- truncate_limit: 100 +INSERT INTO pa_source VALUES (1), (2) +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pa_source VALUES (1), (2)" +== 459 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid + WHEN NOT MATCHED THEN INSERT VALUES (s.sid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: ExplainStmt +STMT: MergeStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid WHEN NOT M..." +== 460 +-- truncate_limit: 100 +MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid + WHEN NOT MATCHED THEN INSERT VALUES (s.sid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT VALUES (s...." +== 461 +-- truncate_limit: 100 +TABLE pa_target +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pa_target" +== 462 +-- truncate_limit: 100 +-- Partition-less partitioned table +-- (the bug we are checking for appeared only if table had partitions before) + +DROP TABLE pa_targetp +-- +TABLE: name="pa_targetp" schema="" table="pa_targetp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pa_targetp" +== 463 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid + WHEN NOT MATCHED THEN INSERT VALUES (s.sid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: ExplainStmt +STMT: MergeStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid WHEN NOT M..." +== 464 +-- truncate_limit: 100 +MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid + WHEN NOT MATCHED THEN INSERT VALUES (s.sid) +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DML +ALIAS: "t"="pa_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO pa_target t USING pa_source s ON t.tid = s.sid WHEN NOT MATCHED THEN INSERT VALUES (s...." +== 465 +-- truncate_limit: 100 +DROP TABLE pa_source +-- +TABLE: name="pa_source" schema="" table="pa_source" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pa_source" +== 466 +-- truncate_limit: 100 +DROP TABLE pa_target CASCADE +-- +TABLE: name="pa_target" schema="" table="pa_target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pa_target CASCADE" +== 467 +-- truncate_limit: 100 +-- some complex joins on the source side + +CREATE TABLE cj_target (tid integer, balance float, val text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cj_target (tid int, balance double precision, val text) WITH (autovacuum_enabled=off)" +== 468 +-- truncate_limit: 100 +CREATE TABLE cj_source1 (sid1 integer, scat integer, delta integer) + WITH (autovacuum_enabled=off) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cj_source1 (sid1 int, scat int, delta int) WITH (autovacuum_enabled=off)" +== 469 +-- truncate_limit: 100 +CREATE TABLE cj_source2 (sid2 integer, sval text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cj_source2 (sid2 int, sval text) WITH (autovacuum_enabled=off)" +== 470 +-- truncate_limit: 100 +INSERT INTO cj_source1 VALUES (1, 10, 100) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cj_source1 VALUES (1, 10, 100)" +== 471 +-- truncate_limit: 100 +INSERT INTO cj_source1 VALUES (1, 20, 200) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cj_source1 VALUES (1, 20, 200)" +== 472 +-- truncate_limit: 100 +INSERT INTO cj_source1 VALUES (2, 20, 300) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cj_source1 VALUES (2, 20, 300)" +== 473 +-- truncate_limit: 100 +INSERT INTO cj_source1 VALUES (3, 10, 400) +-- +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cj_source1 VALUES (3, 10, 400)" +== 474 +-- truncate_limit: 100 +INSERT INTO cj_source2 VALUES (1, 'initial source2') +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cj_source2 VALUES (1, 'initial source2')" +== 475 +-- truncate_limit: 100 +INSERT INTO cj_source2 VALUES (2, 'initial source2') +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cj_source2 VALUES (2, 'initial source2')" +== 476 +-- truncate_limit: 100 +INSERT INTO cj_source2 VALUES (3, 'initial source2') +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cj_source2 VALUES (3, 'initial source2')" +== 477 +-- truncate_limit: 100 +-- source relation is an unaliased join +MERGE INTO cj_target t +USING cj_source1 s1 + INNER JOIN cj_source2 s2 ON sid1 = sid2 +ON t.tid = sid1 +WHEN NOT MATCHED THEN + INSERT VALUES (sid1, delta, sval) +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO cj_target t USING cj_source1 s1 JOIN cj_source2 s2 ON sid1 = sid2 ON t.tid = sid1 WHEN..." +== 478 +-- truncate_limit: 100 +-- try accessing columns from either side of the source join +MERGE INTO cj_target t +USING cj_source2 s2 + INNER JOIN cj_source1 s1 ON sid1 = sid2 AND scat = 20 +ON t.tid = sid1 +WHEN NOT MATCHED THEN + INSERT VALUES (sid2, delta, sval) +WHEN MATCHED THEN + DELETE +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO cj_target t USING cj_source2 s2 JOIN cj_source1 s1 ON sid1 = sid2 AND scat = 20 ON t.t..." +== 479 +-- truncate_limit: 100 +-- some simple expressions in INSERT targetlist +MERGE INTO cj_target t +USING cj_source2 s2 + INNER JOIN cj_source1 s1 ON sid1 = sid2 +ON t.tid = sid1 +WHEN NOT MATCHED THEN + INSERT VALUES (sid2, delta + scat, sval) +WHEN MATCHED THEN + UPDATE SET val = val || ' updated by merge' +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO cj_target t USING cj_source2 s2 JOIN cj_source1 s1 ON sid1 = sid2 ON t.tid = sid1 WHEN..." +== 480 +-- truncate_limit: 100 +MERGE INTO cj_target t +USING cj_source2 s2 + INNER JOIN cj_source1 s1 ON sid1 = sid2 AND scat = 20 +ON t.tid = sid1 +WHEN MATCHED THEN + UPDATE SET val = val || ' ' || delta::text +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO cj_target t USING cj_source2 s2 JOIN cj_source1 s1 ON sid1 = sid2 AND scat = 20 ON t.t..." +== 481 +-- truncate_limit: 100 +SELECT * FROM cj_target +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cj_target" +== 482 +-- truncate_limit: 100 +-- try it with an outer join and PlaceHolderVar +MERGE INTO cj_target t +USING (SELECT *, 'join input'::text AS phv FROM cj_source1) fj + FULL JOIN cj_source2 fj2 ON fj.scat = fj2.sid2 * 10 +ON t.tid = fj.scat +WHEN NOT MATCHED THEN + INSERT (tid, balance, val) VALUES (fj.scat, fj.delta, fj.phv) +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=Select +ALIAS: "t"="cj_target" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO cj_target t USING (SELECT ... FROM cj_source1) fj FULL JOIN cj_source2 fj2 ON fj.scat ..." +== 483 +-- truncate_limit: 100 +SELECT * FROM cj_target +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cj_target" +== 484 +-- truncate_limit: 100 +ALTER TABLE cj_source1 RENAME COLUMN sid1 TO sid +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE cj_source1 RENAME COLUMN sid1 TO sid" +== 485 +-- truncate_limit: 100 +ALTER TABLE cj_source2 RENAME COLUMN sid2 TO sid +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE cj_source2 RENAME COLUMN sid2 TO sid" +== 486 +-- truncate_limit: 100 +TRUNCATE cj_target +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE cj_target" +== 487 +-- truncate_limit: 100 +MERGE INTO cj_target t +USING cj_source1 s1 + INNER JOIN cj_source2 s2 ON s1.sid = s2.sid +ON t.tid = s1.sid +WHEN NOT MATCHED THEN + INSERT VALUES (s2.sid, delta, sval) +-- +TABLE: name="cj_target" schema="" table="cj_target" ctx=DML +ALIAS: "t"="cj_target" +STMT: MergeStmt +TRUNCATED: "MERGE INTO cj_target t USING cj_source1 s1 JOIN cj_source2 s2 ON s1.sid = s2.sid ON t.tid = s1.si..." +== 488 +-- truncate_limit: 100 +DROP TABLE cj_source2, cj_source1, cj_target +-- +TABLE: name="cj_source2" schema="" table="cj_source2" ctx=DDL +TABLE: name="cj_source1" schema="" table="cj_source1" ctx=DDL +TABLE: name="cj_target" schema="" table="cj_target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cj_source2, cj_source1, cj_target" +== 489 +-- truncate_limit: 100 +-- Function scans +CREATE TABLE fs_target (a int, b int, c text) + WITH (autovacuum_enabled=off) +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fs_target (a int, b int, c text) WITH (autovacuum_enabled=off)" +== 490 +-- truncate_limit: 100 +MERGE INTO fs_target t +USING generate_series(1,100,1) AS id +ON t.a = id +WHEN MATCHED THEN + UPDATE SET b = b + id +WHEN NOT MATCHED THEN + INSERT VALUES (id, -1) +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=DML +ALIAS: "t"="fs_target" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +TRUNCATED: "MERGE INTO fs_target t USING generate_series(1, 100, 1) id ON t.a = id WHEN MATCHED THEN UPDATE S..." +== 491 +-- truncate_limit: 100 +MERGE INTO fs_target t +USING generate_series(1,100,2) AS id +ON t.a = id +WHEN MATCHED THEN + UPDATE SET b = b + id, c = 'updated '|| id.*::text +WHEN NOT MATCHED THEN + INSERT VALUES (id, -1, 'inserted ' || id.*::text) +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=DML +ALIAS: "t"="fs_target" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +TRUNCATED: "MERGE INTO fs_target t USING generate_series(1, 100, 2) id ON t.a = id WHEN MATCHED THEN UPDATE S..." +== 492 +-- truncate_limit: 100 +SELECT count(*) FROM fs_target +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM fs_target" +== 493 +-- truncate_limit: 100 +DROP TABLE fs_target +-- +TABLE: name="fs_target" schema="" table="fs_target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fs_target" +== 494 +-- truncate_limit: 100 +-- SERIALIZABLE test +-- handled in isolation tests + +-- Inheritance-based partitioning +CREATE TABLE measurement ( + city_id int not null, + logdate date not null, + peaktemp int, + unitsales int +) WITH (autovacuum_enabled=off) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE measurement (city_id int NOT NULL, logdate date NOT NULL, peaktemp int, unitsales in..." +== 495 +-- truncate_limit: 100 +CREATE TABLE measurement_y2006m02 ( + CHECK ( logdate >= DATE '2006-02-01' AND logdate < DATE '2006-03-01' ) +) INHERITS (measurement) WITH (autovacuum_enabled=off) +-- +TABLE: name="measurement_y2006m02" schema="" table="measurement_y2006m02" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE measurement_y2006m02 (CHECK (logdate >= '2006-02-01'::date AND logdate < '2006-03-01..." +== 496 +-- truncate_limit: 100 +CREATE TABLE measurement_y2006m03 ( + CHECK ( logdate >= DATE '2006-03-01' AND logdate < DATE '2006-04-01' ) +) INHERITS (measurement) WITH (autovacuum_enabled=off) +-- +TABLE: name="measurement_y2006m03" schema="" table="measurement_y2006m03" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE measurement_y2006m03 (CHECK (logdate >= '2006-03-01'::date AND logdate < '2006-04-01..." +== 497 +-- truncate_limit: 100 +CREATE TABLE measurement_y2007m01 ( + filler text, + peaktemp int, + logdate date not null, + city_id int not null, + unitsales int + CHECK ( logdate >= DATE '2007-01-01' AND logdate < DATE '2007-02-01') +) WITH (autovacuum_enabled=off) +-- +TABLE: name="measurement_y2007m01" schema="" table="measurement_y2007m01" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE measurement_y2007m01 (filler text, peaktemp int, logdate date NOT NULL, city_id int ..." +== 498 +-- truncate_limit: 100 +ALTER TABLE measurement_y2007m01 DROP COLUMN filler +-- +TABLE: name="measurement_y2007m01" schema="" table="measurement_y2007m01" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE measurement_y2007m01 DROP filler" +== 499 +-- truncate_limit: 100 +ALTER TABLE measurement_y2007m01 INHERIT measurement +-- +TABLE: name="measurement_y2007m01" schema="" table="measurement_y2007m01" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE measurement_y2007m01 INHERIT measurement" +== 500 +-- truncate_limit: 100 +INSERT INTO measurement VALUES (0, '2005-07-21', 5, 15) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO measurement VALUES (0, '2005-07-21', 5, 15)" +== 501 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION measurement_insert_trigger() +RETURNS TRIGGER AS $$ +BEGIN + IF ( NEW.logdate >= DATE '2006-02-01' AND + NEW.logdate < DATE '2006-03-01' ) THEN + INSERT INTO measurement_y2006m02 VALUES (NEW.*); + ELSIF ( NEW.logdate >= DATE '2006-03-01' AND + NEW.logdate < DATE '2006-04-01' ) THEN + INSERT INTO measurement_y2006m03 VALUES (NEW.*); + ELSIF ( NEW.logdate >= DATE '2007-01-01' AND + NEW.logdate < DATE '2007-02-01' ) THEN + INSERT INTO measurement_y2007m01 (city_id, logdate, peaktemp, unitsales) + VALUES (NEW.*); + ELSE + RAISE EXCEPTION 'Date out of range. Fix the measurement_insert_trigger() function!'; + END IF; + RETURN NULL; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="measurement_insert_trigger" function="measurement_insert_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION measurement_insert_trigger() RETURNS trigger AS $$\nBEGIN\n IF ( NEW...." +== 502 +-- truncate_limit: 100 +CREATE TRIGGER insert_measurement_trigger + BEFORE INSERT ON measurement + FOR EACH ROW EXECUTE PROCEDURE measurement_insert_trigger() +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER insert_measurement_trigger BEFORE INSERT ON measurement FOR EACH ROW EXECUTE FUNCT..." +== 503 +-- truncate_limit: 100 +INSERT INTO measurement VALUES (1, '2006-02-10', 35, 10) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO measurement VALUES (1, '2006-02-10', 35, 10)" +== 504 +-- truncate_limit: 100 +INSERT INTO measurement VALUES (1, '2006-02-16', 45, 20) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO measurement VALUES (1, '2006-02-16', 45, 20)" +== 505 +-- truncate_limit: 100 +INSERT INTO measurement VALUES (1, '2006-03-17', 25, 10) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO measurement VALUES (1, '2006-03-17', 25, 10)" +== 506 +-- truncate_limit: 100 +INSERT INTO measurement VALUES (1, '2006-03-27', 15, 40) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO measurement VALUES (1, '2006-03-27', 15, 40)" +== 507 +-- truncate_limit: 100 +INSERT INTO measurement VALUES (1, '2007-01-15', 10, 10) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO measurement VALUES (1, '2007-01-15', 10, 10)" +== 508 +-- truncate_limit: 100 +INSERT INTO measurement VALUES (1, '2007-01-17', 10, 10) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO measurement VALUES (1, '2007-01-17', 10, 10)" +== 509 +-- truncate_limit: 100 +SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate" +== 510 +-- truncate_limit: 100 +CREATE TABLE new_measurement (LIKE measurement) WITH (autovacuum_enabled=off) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE new_measurement (LIKE measurement) WITH (autovacuum_enabled=off)" +== 511 +-- truncate_limit: 100 +INSERT INTO new_measurement VALUES (0, '2005-07-21', 25, 20) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO new_measurement VALUES (0, '2005-07-21', 25, 20)" +== 512 +-- truncate_limit: 100 +INSERT INTO new_measurement VALUES (1, '2006-03-01', 20, 10) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO new_measurement VALUES (1, '2006-03-01', 20, 10)" +== 513 +-- truncate_limit: 100 +INSERT INTO new_measurement VALUES (1, '2006-02-16', 50, 10) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO new_measurement VALUES (1, '2006-02-16', 50, 10)" +== 514 +-- truncate_limit: 100 +INSERT INTO new_measurement VALUES (2, '2006-02-10', 20, 20) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO new_measurement VALUES (2, '2006-02-10', 20, 20)" +== 515 +-- truncate_limit: 100 +INSERT INTO new_measurement VALUES (1, '2006-03-27', NULL, NULL) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO new_measurement VALUES (1, '2006-03-27', NULL, NULL)" +== 516 +-- truncate_limit: 100 +INSERT INTO new_measurement VALUES (1, '2007-01-17', NULL, NULL) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO new_measurement VALUES (1, '2007-01-17', NULL, NULL)" +== 517 +-- truncate_limit: 100 +INSERT INTO new_measurement VALUES (1, '2007-01-15', 5, NULL) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO new_measurement VALUES (1, '2007-01-15', 5, NULL)" +== 518 +-- truncate_limit: 100 +INSERT INTO new_measurement VALUES (1, '2007-01-16', 10, 10) +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO new_measurement VALUES (1, '2007-01-16', 10, 10)" +== 519 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 520 +-- truncate_limit: 100 +MERGE INTO ONLY measurement m + USING new_measurement nm ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN MATCHED AND nm.peaktemp IS NULL THEN DELETE +WHEN MATCHED THEN UPDATE + SET peaktemp = greatest(m.peaktemp, nm.peaktemp), + unitsales = m.unitsales + coalesce(nm.unitsales, 0) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id, logdate, peaktemp, unitsales) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +TRUNCATED: "MERGE INTO ONLY measurement m USING new_measurement nm ON m.city_id = nm.city_id AND m.logdate = ..." +== 521 +-- truncate_limit: 100 +SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate, peaktemp +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate, peaktemp" +== 522 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 523 +-- truncate_limit: 100 +MERGE into measurement m + USING new_measurement nm ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN MATCHED AND nm.peaktemp IS NULL THEN DELETE +WHEN MATCHED THEN UPDATE + SET peaktemp = greatest(m.peaktemp, nm.peaktemp), + unitsales = m.unitsales + coalesce(nm.unitsales, 0) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id, logdate, peaktemp, unitsales) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +TRUNCATED: "MERGE INTO measurement m USING new_measurement nm ON m.city_id = nm.city_id AND m.logdate = nm.lo..." +== 524 +-- truncate_limit: 100 +SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM measurement ORDER BY city_id, logdate" +== 525 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 526 +-- truncate_limit: 100 +MERGE INTO new_measurement nm + USING ONLY measurement m ON + (nm.city_id = m.city_id and nm.logdate=m.logdate) +WHEN MATCHED THEN DELETE +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +ALIAS: "nm"="new_measurement" +STMT: MergeStmt +TRUNCATED: "MERGE INTO new_measurement nm USING ONLY measurement m ON nm.city_id = m.city_id AND nm.logdate =..." +== 527 +-- truncate_limit: 100 +SELECT * FROM new_measurement ORDER BY city_id, logdate +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM new_measurement ORDER BY city_id, logdate" +== 528 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 529 +-- truncate_limit: 100 +MERGE INTO new_measurement nm + USING measurement m ON + (nm.city_id = m.city_id and nm.logdate=m.logdate) +WHEN MATCHED THEN DELETE +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DML +ALIAS: "nm"="new_measurement" +STMT: MergeStmt +TRUNCATED: "MERGE INTO new_measurement nm USING measurement m ON nm.city_id = m.city_id AND nm.logdate = m.lo..." +== 530 +-- truncate_limit: 100 +SELECT * FROM new_measurement ORDER BY city_id, logdate +-- +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM new_measurement ORDER BY city_id, logdate" +== 531 +-- truncate_limit: 100 +-- MERGE into inheritance root table +DROP TRIGGER insert_measurement_trigger ON measurement +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER insert_measurement_trigger ON measurement" +== 532 +-- truncate_limit: 100 +ALTER TABLE measurement ADD CONSTRAINT mcheck CHECK (city_id = 0) NO INHERIT +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE measurement ADD CONSTRAINT mcheck CHECK (city_id = 0) NO INHERIT" +== 533 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +MERGE INTO measurement m + USING (VALUES (1, '01-17-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, 25, 100) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO measurement m USING (VALUES (1, '01-17-2007'::date)) nm(city_id, l..." +== 534 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 535 +-- truncate_limit: 100 +MERGE INTO measurement m + USING (VALUES (1, '01-17-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, 25, 100) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO measurement m USING (VALUES (...)) nm(city_id, logdate) ON m.city_id = nm.city_id AND ..." +== 536 +-- truncate_limit: 100 +SELECT * FROM ONLY measurement ORDER BY city_id, logdate +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY measurement ORDER BY city_id, logdate" +== 537 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 538 +-- truncate_limit: 100 +ALTER TABLE measurement ENABLE ROW LEVEL SECURITY +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE measurement ENABLE ROW LEVEL SECURITY" +== 539 +-- truncate_limit: 100 +ALTER TABLE measurement FORCE ROW LEVEL SECURITY +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE measurement FORCE ROW LEVEL SECURITY" +== 540 +-- truncate_limit: 100 +CREATE POLICY measurement_p ON measurement USING (peaktemp IS NOT NULL) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY measurement_p ON measurement TO public USING (peaktemp IS NOT NULL)" +== 541 +-- truncate_limit: 100 +MERGE INTO measurement m + USING (VALUES (1, '01-17-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, NULL, 100) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO measurement m USING (VALUES (...)) nm(city_id, logdate) ON m.city_id = nm.city_id AND ..." +== 542 +-- truncate_limit: 100 +-- should fail + +MERGE INTO measurement m + USING (VALUES (1, '01-17-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, 25, 100) +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO measurement m USING (VALUES (...)) nm(city_id, logdate) ON m.city_id = nm.city_id AND ..." +== 543 +-- truncate_limit: 100 +-- ok +SELECT * FROM ONLY measurement ORDER BY city_id, logdate +-- +TABLE: name="measurement" schema="" table="measurement" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY measurement ORDER BY city_id, logdate" +== 544 +-- truncate_limit: 100 +MERGE INTO measurement m + USING (VALUES (1, '01-18-2007'::date)) nm(city_id, logdate) ON + (m.city_id = nm.city_id and m.logdate=nm.logdate) +WHEN NOT MATCHED THEN INSERT + (city_id, logdate, peaktemp, unitsales) + VALUES (city_id - 1, logdate, 25, 200) +RETURNING merge_action(), m.* +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DML +ALIAS: "m"="measurement" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO measurement m USING (VALUES (...)) nm(city_id, logdate) ON m.city_id = nm.city_id AND ..." +== 545 +-- truncate_limit: 100 +DROP TABLE measurement, new_measurement CASCADE +-- +TABLE: name="measurement" schema="" table="measurement" ctx=DDL +TABLE: name="new_measurement" schema="" table="new_measurement" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE measurement, new_measurement CASCADE" +== 546 +-- truncate_limit: 100 +DROP FUNCTION measurement_insert_trigger() +-- +FUNCTION: name="measurement_insert_trigger" function="measurement_insert_trigger" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION measurement_insert_trigger()" +== 547 +-- truncate_limit: 100 +|-- +-- test non-strict join clause +|-- +CREATE TABLE src (a int, b text) +-- +TABLE: name="src" schema="" table="src" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE src (a int, b text)" +== 548 +-- truncate_limit: 100 +INSERT INTO src VALUES (1, 'src row') +-- +TABLE: name="src" schema="" table="src" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO src VALUES (1, 'src row')" +== 549 +-- truncate_limit: 100 +CREATE TABLE tgt (a int, b text) +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tgt (a int, b text)" +== 550 +-- truncate_limit: 100 +INSERT INTO tgt VALUES (NULL, 'tgt row') +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tgt VALUES (NULL, 'tgt row')" +== 551 +-- truncate_limit: 100 +MERGE INTO tgt USING src ON tgt.a IS NOT DISTINCT FROM src.a + WHEN MATCHED THEN UPDATE SET a = src.a, b = src.b + WHEN NOT MATCHED BY SOURCE THEN DELETE + RETURNING merge_action(), src.*, tgt.* +-- +TABLE: name="tgt" schema="" table="tgt" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO tgt USING src ON tgt.a IS NOT DISTINCT FROM src.a WHEN MATCHED THEN UPDATE SET a = src..." +== 552 +-- truncate_limit: 100 +SELECT * FROM tgt +-- +TABLE: name="tgt" schema="" table="tgt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tgt" +== 553 +-- truncate_limit: 100 +DROP TABLE src, tgt +-- +TABLE: name="src" schema="" table="src" ctx=DDL +TABLE: name="tgt" schema="" table="tgt" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE src, tgt" +== 554 +-- truncate_limit: 100 +|-- +-- test for bug #18634 (wrong varnullingrels error) +|-- +CREATE TABLE bug18634t (a int, b int, c text) +-- +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bug18634t (a int, b int, c text)" +== 555 +-- truncate_limit: 100 +INSERT INTO bug18634t VALUES(1, 10, 'tgt1'), (2, 20, 'tgt2') +-- +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bug18634t VALUES (1, 10, 'tgt1'), (2, 20, 'tgt2')" +== 556 +-- truncate_limit: 100 +CREATE VIEW bug18634v AS + SELECT * FROM bug18634t WHERE EXISTS (SELECT 1 FROM bug18634t) +-- +TABLE: name="bug18634v" schema="" table="bug18634v" ctx=DDL +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=Select +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW bug18634v AS SELECT * FROM bug18634t WHERE EXISTS (SELECT 1 FROM bug18634t)" +== 557 +-- truncate_limit: 100 +CREATE TABLE bug18634s (a int, b int, c text) +-- +TABLE: name="bug18634s" schema="" table="bug18634s" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bug18634s (a int, b int, c text)" +== 558 +-- truncate_limit: 100 +INSERT INTO bug18634s VALUES (1, 2, 'src1') +-- +TABLE: name="bug18634s" schema="" table="bug18634s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bug18634s VALUES (1, 2, 'src1')" +== 559 +-- truncate_limit: 100 +MERGE INTO bug18634v t USING bug18634s s ON s.a = t.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED BY SOURCE THEN DELETE + RETURNING merge_action(), s.c, t.* +-- +TABLE: name="bug18634v" schema="" table="bug18634v" ctx=DML +ALIAS: "t"="bug18634v" +STMT: MergeStmt +TRUNCATED: "MERGE INTO bug18634v t USING bug18634s s ON s.a = t.a WHEN MATCHED THEN UPDATE SET b = s.b WHEN N..." +== 560 +-- truncate_limit: 100 +SELECT * FROM bug18634t +-- +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bug18634t" +== 561 +-- truncate_limit: 100 +DROP TABLE bug18634t CASCADE +-- +TABLE: name="bug18634t" schema="" table="bug18634t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bug18634t CASCADE" +== 562 +-- truncate_limit: 100 +DROP TABLE bug18634s +-- +TABLE: name="bug18634s" schema="" table="bug18634s" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bug18634s" +== 563 +-- truncate_limit: 100 +-- prepare + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 564 +-- truncate_limit: 100 +-- try a system catalog +MERGE INTO pg_class c +USING (SELECT 'pg_depend'::regclass AS oid) AS j +ON j.oid = c.oid +WHEN MATCHED THEN + UPDATE SET reltuples = reltuples + 1 +RETURNING j.oid +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DML +ALIAS: "c"="pg_class" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO pg_class c USING (SELECT ...) j ON j.oid = c.oid WHEN MATCHED THEN UPDATE SET reltuple..." +== 565 +-- truncate_limit: 100 +CREATE VIEW classv AS SELECT * FROM pg_class +-- +TABLE: name="classv" schema="" table="classv" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW classv AS SELECT * FROM pg_class" +== 566 +-- truncate_limit: 100 +MERGE INTO classv c +USING pg_namespace n +ON n.oid = c.relnamespace +WHEN MATCHED AND c.oid = 'pg_depend'::regclass THEN + UPDATE SET reltuples = reltuples - 1 +RETURNING c.oid +-- +TABLE: name="classv" schema="" table="classv" ctx=DML +ALIAS: "c"="classv" +STMT: MergeStmt +TRUNCATED: "MERGE INTO classv c USING pg_namespace n ON n.oid = c.relnamespace WHEN MATCHED AND c.oid = 'pg_d..." +== 567 +-- truncate_limit: 100 +DROP TABLE target, target2 +-- +TABLE: name="target" schema="" table="target" ctx=DDL +TABLE: name="target2" schema="" table="target2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE target, target2" +== 568 +-- truncate_limit: 100 +DROP TABLE source, source2 +-- +TABLE: name="source" schema="" table="source" ctx=DDL +TABLE: name="source2" schema="" table="source2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE source, source2" +== 569 +-- truncate_limit: 100 +DROP FUNCTION merge_trigfunc() +-- +FUNCTION: name="merge_trigfunc" function="merge_trigfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION merge_trigfunc()" +== 570 +-- truncate_limit: 100 +DROP USER regress_merge_privs +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_merge_privs" +== 571 +-- truncate_limit: 100 +DROP USER regress_merge_no_privs +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_merge_no_privs" +== 572 +-- truncate_limit: 100 +DROP USER regress_merge_none +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_merge_none" diff --git a/parser/testdata/summary_truncate/postgres_regress/misc.metadata.json b/parser/testdata/summary_truncate/postgres_regress/misc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/misc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/misc.test b/parser/testdata/summary_truncate/postgres_regress/misc.test new file mode 100644 index 0000000..05c7f05 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/misc.test @@ -0,0 +1,636 @@ +== 001 +-- truncate_limit: 100 +|-- +-- MISC +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION overpaid(emp) + RETURNS bool + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 144 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +CREATE FUNCTION reverse_name(name) + RETURNS name + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 58 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +-- truncate_limit: 100 +|-- +-- BTREE +|-- +UPDATE onek + SET unique1 = onek.unique1 + 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE onek SET unique1 = onek.unique1 + 1" +== 004 +-- truncate_limit: 100 +UPDATE onek + SET unique1 = onek.unique1 - 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE onek SET unique1 = onek.unique1 - 1" +== 005 +-- truncate_limit: 100 +|-- +-- BTREE partial +|-- +-- UPDATE onek2 +-- SET unique1 = onek2.unique1 + 1; + +--UPDATE onek2 +-- SET unique1 = onek2.unique1 - 1; + +|-- +-- BTREE shutting out non-functional updates +|-- +-- the following two tests seem to take a long time on some +-- systems. This non-func update stuff needs to be examined +-- more closely. - jolly (2/22/96) +|-- +SELECT two, stringu1, ten, string4 + INTO TABLE tmp + FROM onek +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: SelectStmt +TRUNCATED: "SELECT two, stringu1, ten, string4 INTO tmp FROM onek" +== 006 +-- truncate_limit: 100 +UPDATE tmp + SET stringu1 = reverse_name(onek.stringu1) + FROM onek + WHERE onek.stringu1 = 'JBAAAA' and + onek.stringu1 = tmp.stringu1 +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +TABLE: name="onek" schema="" table="onek" ctx=Select +FUNCTION: name="reverse_name" function="reverse_name" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE tmp SET stringu1 = reverse_name(onek.stringu1) FROM onek WHERE ..." +== 007 +-- truncate_limit: 100 +UPDATE tmp + SET stringu1 = reverse_name(onek2.stringu1) + FROM onek2 + WHERE onek2.stringu1 = 'JCAAAA' and + onek2.stringu1 = tmp.stringu1 +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DML +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FUNCTION: name="reverse_name" function="reverse_name" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE tmp SET stringu1 = reverse_name(onek2.stringu1) FROM onek2 WHERE ..." +== 008 +-- truncate_limit: 100 +DROP TABLE tmp +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tmp" +== 009 +-- truncate_limit: 100 +--UPDATE person* +-- SET age = age + 1; + +--UPDATE person* +-- SET age = age + 3 +-- WHERE name = 'linda'; + +|-- +-- copy +|-- +COPY onek TO :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 138 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 010 +-- truncate_limit: 100 +CREATE TEMP TABLE onek_copy (LIKE onek) +-- +TABLE: name="onek_copy" schema="" table="onek_copy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE onek_copy (LIKE onek)" +== 011 +-- truncate_limit: 100 +COPY onek_copy FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +-- truncate_limit: 100 +SELECT * FROM onek EXCEPT ALL SELECT * FROM onek_copy +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek_copy" schema="" table="onek_copy" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM onek EXCEPT ALL SELECT * FROM onek_copy" +== 013 +-- truncate_limit: 100 +SELECT * FROM onek_copy EXCEPT ALL SELECT * FROM onek +-- +TABLE: name="onek_copy" schema="" table="onek_copy" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM onek_copy EXCEPT ALL SELECT * FROM onek" +== 014 +-- truncate_limit: 100 +COPY BINARY stud_emp TO :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 015 +-- truncate_limit: 100 +CREATE TEMP TABLE stud_emp_copy (LIKE stud_emp) +-- +TABLE: name="stud_emp_copy" schema="" table="stud_emp_copy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE stud_emp_copy (LIKE stud_emp)" +== 016 +-- truncate_limit: 100 +COPY BINARY stud_emp_copy FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 017 +-- truncate_limit: 100 +SELECT * FROM stud_emp_copy +-- +TABLE: name="stud_emp_copy" schema="" table="stud_emp_copy" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM stud_emp_copy" +== 018 +-- truncate_limit: 100 +|-- +-- test data for postquel functions +|-- + +CREATE TABLE hobbies_r ( + name text, + person text +) +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hobbies_r (name text, person text)" +== 019 +-- truncate_limit: 100 +CREATE TABLE equipment_r ( + name text, + hobby text +) +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE equipment_r (name text, hobby text)" +== 020 +-- truncate_limit: 100 +INSERT INTO hobbies_r (name, person) + SELECT 'posthacking', p.name + FROM person* p + WHERE p.name = 'mike' or p.name = 'jeff' +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=DML +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FILTER: schema="" table="p" column="name" +FILTER: schema="" table="p" column="name" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hobbies_r (name, person) SELECT 'posthacking', p.name FROM person p WHERE ..." +== 021 +-- truncate_limit: 100 +INSERT INTO hobbies_r (name, person) + SELECT 'basketball', p.name + FROM person p + WHERE p.name = 'joe' or p.name = 'sally' +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=DML +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FILTER: schema="" table="p" column="name" +FILTER: schema="" table="p" column="name" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hobbies_r (name, person) SELECT 'basketball', p.name FROM person p WHERE ..." +== 022 +-- truncate_limit: 100 +INSERT INTO hobbies_r (name) VALUES ('skywalking') +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hobbies_r (name) VALUES ('skywalking')" +== 023 +-- truncate_limit: 100 +INSERT INTO equipment_r (name, hobby) VALUES ('advil', 'posthacking') +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO equipment_r (name, hobby) VALUES ('advil', 'posthacking')" +== 024 +-- truncate_limit: 100 +INSERT INTO equipment_r (name, hobby) VALUES ('peet''s coffee', 'posthacking') +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO equipment_r (name, hobby) VALUES ('peet''s coffee', 'posthacking')" +== 025 +-- truncate_limit: 100 +INSERT INTO equipment_r (name, hobby) VALUES ('hightops', 'basketball') +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO equipment_r (name, hobby) VALUES ('hightops', 'basketball')" +== 026 +-- truncate_limit: 100 +INSERT INTO equipment_r (name, hobby) VALUES ('guts', 'skywalking') +-- +TABLE: name="equipment_r" schema="" table="equipment_r" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO equipment_r (name, hobby) VALUES ('guts', 'skywalking')" +== 027 +-- truncate_limit: 100 +|-- +-- postquel functions +|-- + +CREATE FUNCTION hobbies(person) + RETURNS setof hobbies_r + AS 'select * from hobbies_r where person = $1.name' + LANGUAGE SQL +-- +FUNCTION: name="hobbies" function="hobbies" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION hobbies(person) RETURNS SETOF hobbies_r AS $$select * from hobbies_r where person..." +== 028 +-- truncate_limit: 100 +CREATE FUNCTION hobby_construct(text, text) + RETURNS hobbies_r + AS 'select $1 as name, $2 as hobby' + LANGUAGE SQL +-- +FUNCTION: name="hobby_construct" function="hobby_construct" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION hobby_construct(text, text) RETURNS hobbies_r AS $$select $1 as name, $2 as hobby..." +== 029 +-- truncate_limit: 100 +CREATE FUNCTION hobby_construct_named(name text, hobby text) + RETURNS hobbies_r + AS 'select name, hobby' + LANGUAGE SQL +-- +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION hobby_construct_named(name text, hobby text) RETURNS hobbies_r AS $$select name, ..." +== 030 +-- truncate_limit: 100 +CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE) + RETURNS hobbies_r.person%TYPE + AS 'select person from hobbies_r where name = $1' + LANGUAGE SQL +-- +FUNCTION: name="hobbies_by_name" function="hobbies_by_name" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION hobbies_by_name(hobbies_r.name%type) RETURNS hobbies_r.person%type AS $$select pe..." +== 031 +-- truncate_limit: 100 +CREATE FUNCTION equipment(hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where hobby = $1.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment" function="equipment" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION equipment(hobbies_r) RETURNS SETOF equipment_r AS $$select * from equipment_r whe..." +== 032 +-- truncate_limit: 100 +CREATE FUNCTION equipment_named(hobby hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where equipment_r.hobby = equipment_named.hobby.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named" function="equipment_named" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION equipment_named(hobby hobbies_r) RETURNS SETOF equipment_r AS $$select * from equ..." +== 033 +-- truncate_limit: 100 +CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where hobby = equipment_named_ambiguous_1a.hobby.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_1a" function="equipment_named_ambiguous_1a" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r) RETURNS SETOF equipment_r AS $$sele..." +== 034 +-- truncate_limit: 100 +CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where equipment_r.hobby = hobby.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_1b" function="equipment_named_ambiguous_1b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r) RETURNS SETOF equipment_r AS $$sele..." +== 035 +-- truncate_limit: 100 +CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r) + RETURNS setof equipment_r + AS 'select * from equipment_r where hobby = hobby.name' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_1c" function="equipment_named_ambiguous_1c" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r) RETURNS SETOF equipment_r AS $$sele..." +== 036 +-- truncate_limit: 100 +CREATE FUNCTION equipment_named_ambiguous_2a(hobby text) + RETURNS setof equipment_r + AS 'select * from equipment_r where hobby = equipment_named_ambiguous_2a.hobby' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_2a" function="equipment_named_ambiguous_2a" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION equipment_named_ambiguous_2a(hobby text) RETURNS SETOF equipment_r AS $$select * ..." +== 037 +-- truncate_limit: 100 +CREATE FUNCTION equipment_named_ambiguous_2b(hobby text) + RETURNS setof equipment_r + AS 'select * from equipment_r where equipment_r.hobby = hobby' + LANGUAGE SQL +-- +FUNCTION: name="equipment_named_ambiguous_2b" function="equipment_named_ambiguous_2b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION equipment_named_ambiguous_2b(hobby text) RETURNS SETOF equipment_r AS $$select * ..." +== 038 +-- truncate_limit: 100 +|-- +-- mike does post_hacking, +-- joe and sally play basketball, and +-- everyone else does nothing. +|-- +SELECT p.name, name(p.hobbies) FROM ONLY person p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT p.name, name(p.hobbies) FROM ONLY person p" +== 039 +-- truncate_limit: 100 +|-- +-- as above, but jeff also does post_hacking. +|-- +SELECT p.name, name(p.hobbies) FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT p.name, name(p.hobbies) FROM person p" +== 040 +-- truncate_limit: 100 +|-- +-- the next two queries demonstrate how functions generate bogus duplicates. +-- this is a "feature" .. +|-- +SELECT DISTINCT hobbies_r.name, name(hobbies_r.equipment) FROM hobbies_r + ORDER BY 1,2 +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=Select +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT hobbies_r.name, name(hobbies_r.equipment) FROM hobbies_r ORDER BY 1, 2" +== 041 +-- truncate_limit: 100 +SELECT hobbies_r.name, (hobbies_r.equipment).name FROM hobbies_r +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT hobbies_r.name, (hobbies_r.equipment).name FROM hobbies_r" +== 042 +-- truncate_limit: 100 +|-- +-- mike needs advil and peet's coffee, +-- joe and sally need hightops, and +-- everyone else is fine. +|-- +SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM ONLY person p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM ONLY person p" +== 043 +-- truncate_limit: 100 +|-- +-- as above, but jeff needs advil and peet's coffee as well. +|-- +SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM person p" +== 044 +-- truncate_limit: 100 +|-- +-- just like the last two, but make sure that the target list fixup and +-- unflattening is being done correctly. +|-- +SELECT name(equipment(p.hobbies)), p.name, name(p.hobbies) FROM ONLY person p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment(p.hobbies)), p.name, name(p.hobbies) FROM ONLY person p" +== 045 +-- truncate_limit: 100 +SELECT (p.hobbies).equipment.name, p.name, name(p.hobbies) FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (p.hobbies).equipment.name, p.name, name(p.hobbies) FROM person p" +== 046 +-- truncate_limit: 100 +SELECT (p.hobbies).equipment.name, name(p.hobbies), p.name FROM ONLY person p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (p.hobbies).equipment.name, name(p.hobbies), p.name FROM ONLY person p" +== 047 +-- truncate_limit: 100 +SELECT name(equipment(p.hobbies)), name(p.hobbies), p.name FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +FUNCTION: name="name" function="name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment(p.hobbies)), name(p.hobbies), p.name FROM person p" +== 048 +-- truncate_limit: 100 +SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +FUNCTION: name="hobby_construct" function="hobby_construct" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment(hobby_construct('skywalking'::text, 'mer'::text)))" +== 049 +-- truncate_limit: 100 +SELECT name(equipment(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment(hobby_construct_named('skywalking'::text, 'mer'::text)))" +== 050 +-- truncate_limit: 100 +SELECT name(equipment_named(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named" function="equipment_named" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment_named(hobby_construct_named('skywalking'::text, 'mer'::text)))" +== 051 +-- truncate_limit: 100 +SELECT name(equipment_named_ambiguous_1a(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_1a" function="equipment_named_ambiguous_1a" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment_named_ambiguous_1a(hobby_construct_named('skywalking'::text, 'mer'::text)))" +== 052 +-- truncate_limit: 100 +SELECT name(equipment_named_ambiguous_1b(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_1b" function="equipment_named_ambiguous_1b" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment_named_ambiguous_1b(hobby_construct_named('skywalking'::text, 'mer'::text)))" +== 053 +-- truncate_limit: 100 +SELECT name(equipment_named_ambiguous_1c(hobby_construct_named(text 'skywalking', text 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_1c" function="equipment_named_ambiguous_1c" schema="" ctx=Call +FUNCTION: name="hobby_construct_named" function="hobby_construct_named" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment_named_ambiguous_1c(hobby_construct_named('skywalking'::text, 'mer'::text)))" +== 054 +-- truncate_limit: 100 +SELECT name(equipment_named_ambiguous_2a(text 'skywalking')) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_2a" function="equipment_named_ambiguous_2a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment_named_ambiguous_2a('skywalking'::text))" +== 055 +-- truncate_limit: 100 +SELECT name(equipment_named_ambiguous_2b(text 'skywalking')) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment_named_ambiguous_2b" function="equipment_named_ambiguous_2b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment_named_ambiguous_2b('skywalking'::text))" +== 056 +-- truncate_limit: 100 +SELECT hobbies_by_name('basketball') +-- +FUNCTION: name="hobbies_by_name" function="hobbies_by_name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT hobbies_by_name('basketball')" +== 057 +-- truncate_limit: 100 +SELECT name, overpaid(emp.*) FROM emp +-- +TABLE: name="emp" schema="" table="emp" ctx=Select +FUNCTION: name="overpaid" function="overpaid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name, overpaid(emp.*) FROM emp" +== 058 +-- truncate_limit: 100 +|-- +-- Try a few cases with SQL-spec row constructor expressions +|-- +SELECT * FROM equipment(ROW('skywalking', 'mer')) +-- +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM equipment(ROW('skywalking', 'mer'))" +== 059 +-- truncate_limit: 100 +SELECT name(equipment(ROW('skywalking', 'mer'))) +-- +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT name(equipment(ROW('skywalking', 'mer')))" +== 060 +-- truncate_limit: 100 +SELECT *, name(equipment(h.*)) FROM hobbies_r h +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=Select +ALIAS: "h"="hobbies_r" +FUNCTION: name="name" function="name" schema="" ctx=Call +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, name(equipment(h.*)) FROM hobbies_r h" +== 061 +-- truncate_limit: 100 +SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h +-- +TABLE: name="hobbies_r" schema="" table="hobbies_r" ctx=Select +ALIAS: "h"="hobbies_r" +FUNCTION: name="equipment" function="equipment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, (equipment(h.*::hobbies_r)).name FROM hobbies_r h" diff --git a/parser/testdata/summary_truncate/postgres_regress/misc_functions.metadata.json b/parser/testdata/summary_truncate/postgres_regress/misc_functions.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/misc_functions.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/misc_functions.test b/parser/testdata/summary_truncate/postgres_regress/misc_functions.test new file mode 100644 index 0000000..8105691 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/misc_functions.test @@ -0,0 +1,1011 @@ +== 001 +-- truncate_limit: 100 +-- directory paths and dlsuffix are passed to us in environment variables + + +|-- +-- num_nulls() +|-- + +SELECT num_nonnulls(NULL) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(NULL)" +== 002 +-- truncate_limit: 100 +SELECT num_nonnulls('1') +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls('1')" +== 003 +-- truncate_limit: 100 +SELECT num_nonnulls(NULL::text) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(NULL::text)" +== 004 +-- truncate_limit: 100 +SELECT num_nonnulls(NULL::text, NULL::int) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(NULL::text, NULL::int)" +== 005 +-- truncate_limit: 100 +SELECT num_nonnulls(1, 2, NULL::text, NULL::point, '', int8 '9', 1.0 / NULL) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(1, 2, NULL::text, NULL::point, '', '9'::int8, 1.0 / NULL)" +== 006 +-- truncate_limit: 100 +SELECT num_nonnulls(VARIADIC '{1,2,NULL,3}'::int[]) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(VARIADIC '{1,2,NULL,3}'::int[])" +== 007 +-- truncate_limit: 100 +SELECT num_nonnulls(VARIADIC '{"1","2","3","4"}'::text[]) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(VARIADIC '{\"1\",\"2\",\"3\",\"4\"}'::text[])" +== 008 +-- truncate_limit: 100 +SELECT num_nonnulls(VARIADIC ARRAY(SELECT CASE WHEN i <> 40 THEN i END FROM generate_series(1, 100) i)) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(VARIADIC ARRAY(SELECT ... FROM generate_series(1, 100) i))" +== 009 +-- truncate_limit: 100 +SELECT num_nulls(NULL) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(NULL)" +== 010 +-- truncate_limit: 100 +SELECT num_nulls('1') +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls('1')" +== 011 +-- truncate_limit: 100 +SELECT num_nulls(NULL::text) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(NULL::text)" +== 012 +-- truncate_limit: 100 +SELECT num_nulls(NULL::text, NULL::int) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(NULL::text, NULL::int)" +== 013 +-- truncate_limit: 100 +SELECT num_nulls(1, 2, NULL::text, NULL::point, '', int8 '9', 1.0 / NULL) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(1, 2, NULL::text, NULL::point, '', '9'::int8, 1.0 / NULL)" +== 014 +-- truncate_limit: 100 +SELECT num_nulls(VARIADIC '{1,2,NULL,3}'::int[]) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(VARIADIC '{1,2,NULL,3}'::int[])" +== 015 +-- truncate_limit: 100 +SELECT num_nulls(VARIADIC '{"1","2","3","4"}'::text[]) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(VARIADIC '{\"1\",\"2\",\"3\",\"4\"}'::text[])" +== 016 +-- truncate_limit: 100 +SELECT num_nulls(VARIADIC ARRAY(SELECT CASE WHEN i <> 40 THEN i END FROM generate_series(1, 100) i)) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(VARIADIC ARRAY(SELECT CASE WHEN i <> 40 THEN i END FROM generate_series(1, 100) i))" +== 017 +-- truncate_limit: 100 +-- special cases +SELECT num_nonnulls(VARIADIC NULL::text[]) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(VARIADIC NULL::text[])" +== 018 +-- truncate_limit: 100 +SELECT num_nonnulls(VARIADIC '{}'::int[]) +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls(VARIADIC '{}'::int[])" +== 019 +-- truncate_limit: 100 +SELECT num_nulls(VARIADIC NULL::text[]) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(VARIADIC NULL::text[])" +== 020 +-- truncate_limit: 100 +SELECT num_nulls(VARIADIC '{}'::int[]) +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls(VARIADIC '{}'::int[])" +== 021 +-- truncate_limit: 100 +-- should fail, one or more arguments is required +SELECT num_nonnulls() +-- +FUNCTION: name="num_nonnulls" function="num_nonnulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nonnulls()" +== 022 +-- truncate_limit: 100 +SELECT num_nulls() +-- +FUNCTION: name="num_nulls" function="num_nulls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT num_nulls()" +== 023 +-- truncate_limit: 100 +|-- +-- canonicalize_path() +|-- + +CREATE FUNCTION test_canonicalize_path(text) + RETURNS text + AS :'regresslib' + LANGUAGE C STRICT IMMUTABLE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 98 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 024 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/')" +== 025 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/./abc/def/') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/./abc/def/')" +== 026 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/./../abc/def') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/./../abc/def')" +== 027 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/./../../abc/def/') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/./../../abc/def/')" +== 028 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/abc/.././def/ghi') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/abc/.././def/ghi')" +== 029 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/abc/./../def/ghi//') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/abc/./../def/ghi//')" +== 030 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/abc/def/../..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/abc/def/../..')" +== 031 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/abc/def/../../..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/abc/def/../../..')" +== 032 +-- truncate_limit: 100 +SELECT test_canonicalize_path('/abc/def/../../../../ghi/jkl') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('/abc/def/../../../../ghi/jkl')" +== 033 +-- truncate_limit: 100 +SELECT test_canonicalize_path('.') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('.')" +== 034 +-- truncate_limit: 100 +SELECT test_canonicalize_path('./') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('./')" +== 035 +-- truncate_limit: 100 +SELECT test_canonicalize_path('./abc/..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('./abc/..')" +== 036 +-- truncate_limit: 100 +SELECT test_canonicalize_path('abc/../') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('abc/../')" +== 037 +-- truncate_limit: 100 +SELECT test_canonicalize_path('abc/../def') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('abc/../def')" +== 038 +-- truncate_limit: 100 +SELECT test_canonicalize_path('..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('..')" +== 039 +-- truncate_limit: 100 +SELECT test_canonicalize_path('../abc/def') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('../abc/def')" +== 040 +-- truncate_limit: 100 +SELECT test_canonicalize_path('../abc/..') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('../abc/..')" +== 041 +-- truncate_limit: 100 +SELECT test_canonicalize_path('../abc/../def') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('../abc/../def')" +== 042 +-- truncate_limit: 100 +SELECT test_canonicalize_path('../abc/../../def/ghi') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('../abc/../../def/ghi')" +== 043 +-- truncate_limit: 100 +SELECT test_canonicalize_path('./abc/./def/.') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('./abc/./def/.')" +== 044 +-- truncate_limit: 100 +SELECT test_canonicalize_path('./abc/././def/.') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('./abc/././def/.')" +== 045 +-- truncate_limit: 100 +SELECT test_canonicalize_path('./abc/./def/.././ghi/../../../jkl/mno') +-- +FUNCTION: name="test_canonicalize_path" function="test_canonicalize_path" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_canonicalize_path('./abc/./def/.././ghi/../../../jkl/mno')" +== 046 +-- truncate_limit: 100 +|-- +-- pg_log_backend_memory_contexts() +|-- +-- Memory contexts are logged and they are not returned to the function. +-- Furthermore, their contents can vary depending on the timing. However, +-- we can at least verify that the code doesn't fail, and that the +-- permissions are set properly. +|-- + +SELECT pg_log_backend_memory_contexts(pg_backend_pid()) +-- +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_log_backend_memory_contexts(pg_backend_pid())" +== 047 +-- truncate_limit: 100 +SELECT pg_log_backend_memory_contexts(pid) FROM pg_stat_activity + WHERE backend_type = 'checkpointer' +-- +TABLE: name="pg_stat_activity" schema="" table="pg_stat_activity" ctx=Select +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=Call +FILTER: schema="" table="" column="backend_type" +STMT: SelectStmt +TRUNCATED: "SELECT pg_log_backend_memory_contexts(pid) FROM pg_stat_activity WHERE backend_type = 'checkpointer'" +== 048 +-- truncate_limit: 100 +CREATE ROLE regress_log_memory +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_log_memory" +== 049 +-- truncate_limit: 100 +SELECT has_function_privilege('regress_log_memory', + 'pg_log_backend_memory_contexts(integer)', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 050 +-- truncate_limit: 100 +-- no + +GRANT EXECUTE ON FUNCTION pg_log_backend_memory_contexts(integer) + TO regress_log_memory +-- +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT execute ON FUNCTION pg_log_backend_memory_contexts(int) TO regress_log_memory" +== 051 +-- truncate_limit: 100 +SELECT has_function_privilege('regress_log_memory', + 'pg_log_backend_memory_contexts(integer)', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 052 +-- truncate_limit: 100 +-- yes + +SET ROLE regress_log_memory +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_log_memory" +== 053 +-- truncate_limit: 100 +SELECT pg_log_backend_memory_contexts(pg_backend_pid()) +-- +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_log_backend_memory_contexts(pg_backend_pid())" +== 054 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 055 +-- truncate_limit: 100 +REVOKE EXECUTE ON FUNCTION pg_log_backend_memory_contexts(integer) + FROM regress_log_memory +-- +FUNCTION: name="pg_log_backend_memory_contexts" function="pg_log_backend_memory_contexts" schema="" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE execute ON FUNCTION pg_log_backend_memory_contexts(int) FROM regress_log_memory" +== 056 +-- truncate_limit: 100 +DROP ROLE regress_log_memory +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_log_memory" +== 057 +-- truncate_limit: 100 +|-- +-- Test some built-in SRFs +|-- +-- The outputs of these are variable, so we can't just print their results +-- directly, but we can at least verify that the code doesn't fail. +|-- +select setting as segsize +from pg_settings where name = 'wal_segment_size' + +select count(*) > 0 as ok from pg_ls_waldir() +-- +ERROR: syntax error at or near "select" +CURSORPOS: 256 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 058 +-- truncate_limit: 100 +-- Test ProjectSet as well as FunctionScan +select count(*) > 0 as ok from (select pg_ls_waldir()) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_waldir" function="pg_ls_waldir" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM (SELECT pg_ls_waldir()) ss" +== 059 +-- truncate_limit: 100 +-- Test not-run-to-completion cases. +select * from pg_ls_waldir() limit 0 +-- +FUNCTION: name="pg_ls_waldir" function="pg_ls_waldir" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_ls_waldir() LIMIT 0" +== 060 +-- truncate_limit: 100 +select count(*) > 0 as ok from (select * from pg_ls_waldir() limit 1) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_waldir" function="pg_ls_waldir" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM (SELECT * FROM pg_ls_waldir() LIMIT 1) ss" +== 061 +-- truncate_limit: 100 +select (w).size = :segsize as ok +from (select pg_ls_waldir() w) ss where length((w).name) = 24 limit 1 +-- +ERROR: syntax error at or near ":" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 062 +-- truncate_limit: 100 +select count(*) >= 0 as ok from pg_ls_archive_statusdir() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_archive_statusdir" function="pg_ls_archive_statusdir" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) >= 0 AS ok FROM pg_ls_archive_statusdir()" +== 063 +-- truncate_limit: 100 +-- pg_read_file() +select length(pg_read_file('postmaster.pid')) > 20 +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(pg_read_file('postmaster.pid')) > 20" +== 064 +-- truncate_limit: 100 +select length(pg_read_file('postmaster.pid', 1, 20)) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(pg_read_file('postmaster.pid', 1, 20))" +== 065 +-- truncate_limit: 100 +-- Test missing_ok +select pg_read_file('does not exist') +-- +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_read_file('does not exist')" +== 066 +-- truncate_limit: 100 +-- error +select pg_read_file('does not exist', true) IS NULL +-- +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_read_file('does not exist', true) IS NULL" +== 067 +-- truncate_limit: 100 +-- ok +-- Test invalid argument +select pg_read_file('does not exist', 0, -1) +-- +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_read_file('does not exist', 0, -1)" +== 068 +-- truncate_limit: 100 +-- error +select pg_read_file('does not exist', 0, -1, true) +-- +FUNCTION: name="pg_read_file" function="pg_read_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_read_file('does not exist', 0, -1, true)" +== 069 +-- truncate_limit: 100 +-- error + +-- pg_read_binary_file() +select length(pg_read_binary_file('postmaster.pid')) > 20 +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(pg_read_binary_file('postmaster.pid')) > 20" +== 070 +-- truncate_limit: 100 +select length(pg_read_binary_file('postmaster.pid', 1, 20)) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(pg_read_binary_file('postmaster.pid', 1, 20))" +== 071 +-- truncate_limit: 100 +-- Test missing_ok +select pg_read_binary_file('does not exist') +-- +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_read_binary_file('does not exist')" +== 072 +-- truncate_limit: 100 +-- error +select pg_read_binary_file('does not exist', true) IS NULL +-- +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_read_binary_file('does not exist', true) IS NULL" +== 073 +-- truncate_limit: 100 +-- ok +-- Test invalid argument +select pg_read_binary_file('does not exist', 0, -1) +-- +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_read_binary_file('does not exist', 0, -1)" +== 074 +-- truncate_limit: 100 +-- error +select pg_read_binary_file('does not exist', 0, -1, true) +-- +FUNCTION: name="pg_read_binary_file" function="pg_read_binary_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_read_binary_file('does not exist', 0, -1, true)" +== 075 +-- truncate_limit: 100 +-- error + +-- pg_stat_file() +select size > 20, isdir from pg_stat_file('postmaster.pid') +-- +FUNCTION: name="pg_stat_file" function="pg_stat_file" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT size > 20, isdir FROM pg_stat_file('postmaster.pid')" +== 076 +-- truncate_limit: 100 +-- pg_ls_dir() +select * from (select pg_ls_dir('.') a) a where a = 'base' limit 1 +-- +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT pg_ls_dir('.') AS a) a WHERE a = 'base' LIMIT 1" +== 077 +-- truncate_limit: 100 +-- Test missing_ok (second argument) +select pg_ls_dir('does not exist', false, false) +-- +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_ls_dir('does not exist', false, false)" +== 078 +-- truncate_limit: 100 +-- error +select pg_ls_dir('does not exist', true, false) +-- +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_ls_dir('does not exist', true, false)" +== 079 +-- truncate_limit: 100 +-- ok +-- Test include_dot_dirs (third argument) +select count(*) = 1 as dot_found + from pg_ls_dir('.', false, true) as ls where ls = '.' +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +FILTER: schema="" table="" column="ls" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) = 1 AS dot_found FROM pg_ls_dir('.', false, true) ls WHERE ls = '.'" +== 080 +-- truncate_limit: 100 +select count(*) = 1 as dot_found + from pg_ls_dir('.', false, false) as ls where ls = '.' +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_ls_dir" function="pg_ls_dir" schema="" ctx=Call +FILTER: schema="" table="" column="ls" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) = 1 AS dot_found FROM pg_ls_dir('.', false, false) ls WHERE ls = '.'" +== 081 +-- truncate_limit: 100 +-- pg_timezone_names() +select * from (select (pg_timezone_names()).name) ptn where name='UTC' limit 1 +-- +FUNCTION: name="pg_timezone_names" function="pg_timezone_names" schema="" ctx=Call +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT (pg_timezone_names()).name) ptn WHERE name = 'UTC' LIMIT 1" +== 082 +-- truncate_limit: 100 +-- pg_tablespace_databases() +select count(*) > 0 from + (select pg_tablespace_databases(oid) as pts from pg_tablespace + where spcname = 'pg_default') pts + join pg_database db on pts.pts = db.oid +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "db"="pg_database" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_tablespace_databases" function="pg_tablespace_databases" schema="" ctx=Call +FILTER: schema="" table="" column="spcname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM pg_tablespace WHERE ...) pts JOIN pg_database db ON pts.pts = db..." +== 083 +-- truncate_limit: 100 +|-- +-- Test replication slot directory functions +|-- +CREATE ROLE regress_slot_dir_funcs +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_slot_dir_funcs" +== 084 +-- truncate_limit: 100 +-- Not available by default. +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_logicalsnapdir()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_function_privilege('regress_slot_dir_funcs', 'pg_ls_logicalsnapdir()', 'EXECUTE')" +== 085 +-- truncate_limit: 100 +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_logicalmapdir()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_function_privilege('regress_slot_dir_funcs', 'pg_ls_logicalmapdir()', 'EXECUTE')" +== 086 +-- truncate_limit: 100 +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_replslotdir(text)', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_function_privilege('regress_slot_dir_funcs', 'pg_ls_replslotdir(text)', 'EXECUTE')" +== 087 +-- truncate_limit: 100 +GRANT pg_monitor TO regress_slot_dir_funcs +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT pg_monitor TO regress_slot_dir_funcs" +== 088 +-- truncate_limit: 100 +-- Role is now part of pg_monitor, so these are available. +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_logicalsnapdir()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_function_privilege('regress_slot_dir_funcs', 'pg_ls_logicalsnapdir()', 'EXECUTE')" +== 089 +-- truncate_limit: 100 +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_logicalmapdir()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_function_privilege('regress_slot_dir_funcs', 'pg_ls_logicalmapdir()', 'EXECUTE')" +== 090 +-- truncate_limit: 100 +SELECT has_function_privilege('regress_slot_dir_funcs', + 'pg_ls_replslotdir(text)', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_function_privilege('regress_slot_dir_funcs', 'pg_ls_replslotdir(text)', 'EXECUTE')" +== 091 +-- truncate_limit: 100 +DROP ROLE regress_slot_dir_funcs +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_slot_dir_funcs" +== 092 +-- truncate_limit: 100 +|-- +-- Test adding a support function to a subject function +|-- + +CREATE FUNCTION my_int_eq(int, int) RETURNS bool + LANGUAGE internal STRICT IMMUTABLE PARALLEL SAFE + AS $$int4eq$$ +-- +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION my_int_eq(int, int) RETURNS bool LANGUAGE internal RETURNS NULL ON NULL INPUT IMM..." +== 093 +-- truncate_limit: 100 +-- By default, planner does not think that's selective +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique1 +WHERE my_int_eq(a.unique2, 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=Call +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=Call +FILTER: schema="" table="a" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique1 WHERE my_int_eq(a..." +== 094 +-- truncate_limit: 100 +-- With support function that knows it's int4eq, we get a different plan +CREATE FUNCTION test_support_func(internal) + RETURNS internal + AS :'regresslib', 'test_support_func' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 146 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 095 +-- truncate_limit: 100 +ALTER FUNCTION my_int_eq(int, int) SUPPORT test_support_func +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION my_int_eq(int, int) SUPPORT test_support_func" +== 096 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique1 +WHERE my_int_eq(a.unique2, 42) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=Call +FUNCTION: name="my_int_eq" function="my_int_eq" schema="" ctx=Call +FILTER: schema="" table="a" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a JOIN tenk1 b ON a.unique1 = b.unique1 WHERE my_int_eq(a..." +== 097 +-- truncate_limit: 100 +-- Also test non-default rowcount estimate +CREATE FUNCTION my_gen_series(int, int) RETURNS SETOF integer + LANGUAGE internal STRICT IMMUTABLE PARALLEL SAFE + AS $$generate_series_int4$$ + SUPPORT test_support_func +-- +FUNCTION: name="my_gen_series" function="my_gen_series" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION my_gen_series(int, int) RETURNS SETOF int LANGUAGE internal RETURNS NULL ON NULL ..." +== 098 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 a JOIN my_gen_series(1,1000) g ON a.unique1 = g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="my_gen_series" function="my_gen_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a JOIN my_gen_series(1, 1000) g ON a.unique1 = g" +== 099 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM tenk1 a JOIN my_gen_series(1,10) g ON a.unique1 = g +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +FUNCTION: name="my_gen_series" function="my_gen_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a JOIN my_gen_series(1, 10) g ON a.unique1 = g" +== 100 +-- truncate_limit: 100 +-- Test functions for control data +SELECT count(*) > 0 AS ok FROM pg_control_checkpoint() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_control_checkpoint" function="pg_control_checkpoint" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM pg_control_checkpoint()" +== 101 +-- truncate_limit: 100 +SELECT count(*) > 0 AS ok FROM pg_control_init() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_control_init" function="pg_control_init" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM pg_control_init()" +== 102 +-- truncate_limit: 100 +SELECT count(*) > 0 AS ok FROM pg_control_recovery() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_control_recovery" function="pg_control_recovery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM pg_control_recovery()" +== 103 +-- truncate_limit: 100 +SELECT count(*) > 0 AS ok FROM pg_control_system() +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_control_system" function="pg_control_system" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM pg_control_system()" +== 104 +-- truncate_limit: 100 +-- pg_split_walfile_name, pg_walfile_name & pg_walfile_name_offset +SELECT * FROM pg_split_walfile_name(NULL) +-- +FUNCTION: name="pg_split_walfile_name" function="pg_split_walfile_name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_split_walfile_name(NULL)" +== 105 +-- truncate_limit: 100 +SELECT * FROM pg_split_walfile_name('invalid') +-- +FUNCTION: name="pg_split_walfile_name" function="pg_split_walfile_name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_split_walfile_name('invalid')" +== 106 +-- truncate_limit: 100 +SELECT segment_number > 0 AS ok_segment_number, timeline_id + FROM pg_split_walfile_name('000000010000000100000000') +-- +FUNCTION: name="pg_split_walfile_name" function="pg_split_walfile_name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_split_walfile_name('000000010000000100000000')" +== 107 +-- truncate_limit: 100 +SELECT segment_number > 0 AS ok_segment_number, timeline_id + FROM pg_split_walfile_name('ffffffFF00000001000000af') +-- +FUNCTION: name="pg_split_walfile_name" function="pg_split_walfile_name" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_split_walfile_name('ffffffFF00000001000000af')" +== 108 +-- truncate_limit: 100 +SELECT setting::int8 AS segment_size +FROM pg_settings +WHERE name = 'wal_segment_size' +SELECT segment_number, file_offset +FROM pg_walfile_name_offset('0/0'::pg_lsn + :segment_size), + pg_split_walfile_name(file_name) +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 87 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 109 +-- truncate_limit: 100 +SELECT segment_number, file_offset +FROM pg_walfile_name_offset('0/0'::pg_lsn + :segment_size + 1), + pg_split_walfile_name(file_name) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 80 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 110 +-- truncate_limit: 100 +SELECT segment_number, file_offset = :segment_size - 1 +FROM pg_walfile_name_offset('0/0'::pg_lsn + :segment_size - 1), + pg_split_walfile_name(file_name) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 38 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 111 +-- truncate_limit: 100 +-- pg_current_logfile +CREATE ROLE regress_current_logfile +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_current_logfile" +== 112 +-- truncate_limit: 100 +-- not available by default +SELECT has_function_privilege('regress_current_logfile', + 'pg_current_logfile()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_function_privilege('regress_current_logfile', 'pg_current_logfile()', 'EXECUTE')" +== 113 +-- truncate_limit: 100 +GRANT pg_monitor TO regress_current_logfile +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT pg_monitor TO regress_current_logfile" +== 114 +-- truncate_limit: 100 +-- role has privileges of pg_monitor and can execute the function +SELECT has_function_privilege('regress_current_logfile', + 'pg_current_logfile()', 'EXECUTE') +-- +FUNCTION: name="has_function_privilege" function="has_function_privilege" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT has_function_privilege('regress_current_logfile', 'pg_current_logfile()', 'EXECUTE')" +== 115 +-- truncate_limit: 100 +DROP ROLE regress_current_logfile +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_current_logfile" +== 116 +-- truncate_limit: 100 +-- pg_column_toast_chunk_id +CREATE TABLE test_chunk_id (a TEXT, b TEXT STORAGE EXTERNAL) +-- +TABLE: name="test_chunk_id" schema="" table="test_chunk_id" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_chunk_id (a text, b text STORAGE external)" +== 117 +-- truncate_limit: 100 +INSERT INTO test_chunk_id VALUES ('x', repeat('x', 8192)) +-- +TABLE: name="test_chunk_id" schema="" table="test_chunk_id" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_chunk_id VALUES ('x', repeat('x', 8192))" +== 118 +-- truncate_limit: 100 +SELECT t.relname AS toastrel FROM pg_class c + LEFT JOIN pg_class t ON c.reltoastrelid = t.oid + WHERE c.relname = 'test_chunk_id' +SELECT pg_column_toast_chunk_id(a) IS NULL, + pg_column_toast_chunk_id(b) IN (SELECT chunk_id FROM pg_toast.:toastrel) + FROM test_chunk_id +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 132 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 119 +-- truncate_limit: 100 +DROP TABLE test_chunk_id +-- +TABLE: name="test_chunk_id" schema="" table="test_chunk_id" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_chunk_id" diff --git a/parser/testdata/summary_truncate/postgres_regress/misc_sanity.metadata.json b/parser/testdata/summary_truncate/postgres_regress/misc_sanity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/misc_sanity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/misc_sanity.test b/parser/testdata/summary_truncate/postgres_regress/misc_sanity.test new file mode 100644 index 0000000..95573e8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/misc_sanity.test @@ -0,0 +1,128 @@ +== 001 +-- truncate_limit: 100 +|-- +-- MISC_SANITY +-- Sanity checks for common errors in making system tables that don't fit +-- comfortably into either opr_sanity or type_sanity. +|-- +-- Every test failure in this file should be closely inspected. +-- The description of the failing test should be read carefully before +-- adjusting the expected output. In most cases, the queries should +-- not find *any* matching entries. +|-- +-- NB: run this test early, because some later tests create bogus entries. + + +-- **************** pg_depend **************** + +-- Look for illegal values in pg_depend fields. + +SELECT * +FROM pg_depend as d1 +WHERE refclassid = 0 OR refobjid = 0 OR + classid = 0 OR objid = 0 OR + deptype NOT IN ('a', 'e', 'i', 'n', 'x', 'P', 'S') +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=Select +ALIAS: "d1"="pg_depend" +FILTER: schema="" table="" column="refclassid" +FILTER: schema="" table="" column="refobjid" +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +FILTER: schema="" table="" column="deptype" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_depend d1 WHERE ..." +== 002 +-- truncate_limit: 100 +-- **************** pg_shdepend **************** + +-- Look for illegal values in pg_shdepend fields. + +SELECT * +FROM pg_shdepend as d1 +WHERE refclassid = 0 OR refobjid = 0 OR + classid = 0 OR objid = 0 OR + deptype NOT IN ('a', 'i', 'o', 'r', 't') +-- +TABLE: name="pg_shdepend" schema="" table="pg_shdepend" ctx=Select +ALIAS: "d1"="pg_shdepend" +FILTER: schema="" table="" column="refclassid" +FILTER: schema="" table="" column="refobjid" +FILTER: schema="" table="" column="classid" +FILTER: schema="" table="" column="objid" +FILTER: schema="" table="" column="deptype" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_shdepend d1 WHERE ..." +== 003 +-- truncate_limit: 100 +-- **************** pg_class **************** + +-- Look for system tables with varlena columns but no toast table. All +-- system tables with toastable columns should have toast tables, with +-- the following exceptions: +-- 1. pg_class, pg_attribute, and pg_index, due to fear of recursive +-- dependencies as toast tables depend on them. +-- 2. pg_largeobject and pg_largeobject_metadata. Large object catalogs +-- and toast tables are mutually exclusive and large object data is handled +-- as user data by pg_upgrade, which would cause failures. + +SELECT relname, attname, atttypid::regtype +FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid +WHERE c.oid < 16384 AND + reltoastrelid = 0 AND + relkind = 'r' AND + attstorage != 'p' +ORDER BY 1, 2 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="reltoastrelid" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="attstorage" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid WHERE ... ORDER BY 1, 2" +== 004 +-- truncate_limit: 100 +-- system catalogs without primary keys +|-- +-- Current exceptions: +-- * pg_depend, pg_shdepend don't have a unique key +SELECT relname +FROM pg_class +WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'r' + AND pg_class.oid NOT IN (SELECT indrelid FROM pg_index WHERE indisprimary) +ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="pg_class" column="oid" +FILTER: schema="" table="" column="indisprimary" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE ... ORDER BY 1" +== 005 +-- truncate_limit: 100 +-- system catalog unique indexes not wrapped in a constraint +-- (There should be none.) +SELECT relname +FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid +WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'i' + AND i.indisunique + AND c.oid NOT IN (SELECT conindid FROM pg_constraint) +ORDER BY 1 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="i" column="indisunique" +FILTER: schema="" table="c" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid WHERE ... ORDER BY 1" diff --git a/parser/testdata/summary_truncate/postgres_regress/money.metadata.json b/parser/testdata/summary_truncate/postgres_regress/money.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/money.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/money.test b/parser/testdata/summary_truncate/postgres_regress/money.test new file mode 100644 index 0000000..00d4342 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/money.test @@ -0,0 +1,743 @@ +== 001 +-- truncate_limit: 100 +|-- +-- MONEY +|-- +-- Note that we assume lc_monetary has been set to C. +|-- + +CREATE TABLE money_data (m money) +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE money_data (m money)" +== 002 +-- truncate_limit: 100 +INSERT INTO money_data VALUES ('123') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO money_data VALUES ('123')" +== 003 +-- truncate_limit: 100 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM money_data" +== 004 +-- truncate_limit: 100 +SELECT m + '123' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m + '123' FROM money_data" +== 005 +-- truncate_limit: 100 +SELECT m + '123.45' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m + '123.45' FROM money_data" +== 006 +-- truncate_limit: 100 +SELECT m - '123.45' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m - '123.45' FROM money_data" +== 007 +-- truncate_limit: 100 +SELECT m / '2'::money FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m / '2'::money FROM money_data" +== 008 +-- truncate_limit: 100 +SELECT m * 2 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m * 2 FROM money_data" +== 009 +-- truncate_limit: 100 +SELECT 2 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 2 * m FROM money_data" +== 010 +-- truncate_limit: 100 +SELECT m / 2 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m / 2 FROM money_data" +== 011 +-- truncate_limit: 100 +SELECT m * 2::int2 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m * 2::int2 FROM money_data" +== 012 +-- truncate_limit: 100 +SELECT 2::int2 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 2::int2 * m FROM money_data" +== 013 +-- truncate_limit: 100 +SELECT m / 2::int2 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m / 2::int2 FROM money_data" +== 014 +-- truncate_limit: 100 +SELECT m * 2::int8 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m * 2::int8 FROM money_data" +== 015 +-- truncate_limit: 100 +SELECT 2::int8 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 2::int8 * m FROM money_data" +== 016 +-- truncate_limit: 100 +SELECT m / 2::int8 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m / 2::int8 FROM money_data" +== 017 +-- truncate_limit: 100 +SELECT m * 2::float8 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m * 2::float8 FROM money_data" +== 018 +-- truncate_limit: 100 +SELECT 2::float8 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 2::float8 * m FROM money_data" +== 019 +-- truncate_limit: 100 +SELECT m / 2::float8 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m / 2::float8 FROM money_data" +== 020 +-- truncate_limit: 100 +SELECT m * 2::float4 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m * 2::float4 FROM money_data" +== 021 +-- truncate_limit: 100 +SELECT 2::float4 * m FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 2::float4 * m FROM money_data" +== 022 +-- truncate_limit: 100 +SELECT m / 2::float4 FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m / 2::float4 FROM money_data" +== 023 +-- truncate_limit: 100 +-- All true +SELECT m = '$123.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m = '$123.00' FROM money_data" +== 024 +-- truncate_limit: 100 +SELECT m != '$124.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m <> '$124.00' FROM money_data" +== 025 +-- truncate_limit: 100 +SELECT m <= '$123.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m <= '$123.00' FROM money_data" +== 026 +-- truncate_limit: 100 +SELECT m >= '$123.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m >= '$123.00' FROM money_data" +== 027 +-- truncate_limit: 100 +SELECT m < '$124.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m < '$124.00' FROM money_data" +== 028 +-- truncate_limit: 100 +SELECT m > '$122.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m > '$122.00' FROM money_data" +== 029 +-- truncate_limit: 100 +-- All false +SELECT m = '$123.01' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m = '$123.01' FROM money_data" +== 030 +-- truncate_limit: 100 +SELECT m != '$123.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m <> '$123.00' FROM money_data" +== 031 +-- truncate_limit: 100 +SELECT m <= '$122.99' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m <= '$122.99' FROM money_data" +== 032 +-- truncate_limit: 100 +SELECT m >= '$123.01' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m >= '$123.01' FROM money_data" +== 033 +-- truncate_limit: 100 +SELECT m > '$124.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m > '$124.00' FROM money_data" +== 034 +-- truncate_limit: 100 +SELECT m < '$122.00' FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT m < '$122.00' FROM money_data" +== 035 +-- truncate_limit: 100 +SELECT cashlarger(m, '$124.00') FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +FUNCTION: name="cashlarger" function="cashlarger" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cashlarger(m, '$124.00') FROM money_data" +== 036 +-- truncate_limit: 100 +SELECT cashsmaller(m, '$124.00') FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +FUNCTION: name="cashsmaller" function="cashsmaller" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cashsmaller(m, '$124.00') FROM money_data" +== 037 +-- truncate_limit: 100 +SELECT cash_words(m) FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +FUNCTION: name="cash_words" function="cash_words" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cash_words(m) FROM money_data" +== 038 +-- truncate_limit: 100 +SELECT cash_words(m + '1.23') FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +FUNCTION: name="cash_words" function="cash_words" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cash_words(m + '1.23') FROM money_data" +== 039 +-- truncate_limit: 100 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM money_data" +== 040 +-- truncate_limit: 100 +INSERT INTO money_data VALUES ('$123.45') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO money_data VALUES ('$123.45')" +== 041 +-- truncate_limit: 100 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM money_data" +== 042 +-- truncate_limit: 100 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM money_data" +== 043 +-- truncate_limit: 100 +INSERT INTO money_data VALUES ('$123.451') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO money_data VALUES ('$123.451')" +== 044 +-- truncate_limit: 100 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM money_data" +== 045 +-- truncate_limit: 100 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM money_data" +== 046 +-- truncate_limit: 100 +INSERT INTO money_data VALUES ('$123.454') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO money_data VALUES ('$123.454')" +== 047 +-- truncate_limit: 100 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM money_data" +== 048 +-- truncate_limit: 100 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM money_data" +== 049 +-- truncate_limit: 100 +INSERT INTO money_data VALUES ('$123.455') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO money_data VALUES ('$123.455')" +== 050 +-- truncate_limit: 100 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM money_data" +== 051 +-- truncate_limit: 100 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM money_data" +== 052 +-- truncate_limit: 100 +INSERT INTO money_data VALUES ('$123.456') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO money_data VALUES ('$123.456')" +== 053 +-- truncate_limit: 100 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM money_data" +== 054 +-- truncate_limit: 100 +DELETE FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM money_data" +== 055 +-- truncate_limit: 100 +INSERT INTO money_data VALUES ('$123.459') +-- +TABLE: name="money_data" schema="" table="money_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO money_data VALUES ('$123.459')" +== 056 +-- truncate_limit: 100 +SELECT * FROM money_data +-- +TABLE: name="money_data" schema="" table="money_data" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM money_data" +== 057 +-- truncate_limit: 100 +-- input checks +SELECT '1234567890'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1234567890'::money" +== 058 +-- truncate_limit: 100 +SELECT '12345678901234567'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345678901234567'::money" +== 059 +-- truncate_limit: 100 +SELECT '123456789012345678'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '123456789012345678'::money" +== 060 +-- truncate_limit: 100 +SELECT '9223372036854775807'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '9223372036854775807'::money" +== 061 +-- truncate_limit: 100 +SELECT '-12345'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-12345'::money" +== 062 +-- truncate_limit: 100 +SELECT '-1234567890'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1234567890'::money" +== 063 +-- truncate_limit: 100 +SELECT '-12345678901234567'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-12345678901234567'::money" +== 064 +-- truncate_limit: 100 +SELECT '-123456789012345678'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-123456789012345678'::money" +== 065 +-- truncate_limit: 100 +SELECT '-9223372036854775808'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-9223372036854775808'::money" +== 066 +-- truncate_limit: 100 +-- special characters +SELECT '(1)'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1)'::money" +== 067 +-- truncate_limit: 100 +SELECT '($123,456.78)'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '($123,456.78)'::money" +== 068 +-- truncate_limit: 100 +-- test non-error-throwing API +SELECT pg_input_is_valid('\x0001', 'money') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid(E'\\\\x0001', 'money')" +== 069 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('\x0001', 'money') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info(E'\\\\x0001', 'money')" +== 070 +-- truncate_limit: 100 +SELECT pg_input_is_valid('192233720368547758.07', 'money') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('192233720368547758.07', 'money')" +== 071 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('192233720368547758.07', 'money') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('192233720368547758.07', 'money')" +== 072 +-- truncate_limit: 100 +-- documented minimums and maximums +SELECT '-92233720368547758.08'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-92233720368547758.08'::money" +== 073 +-- truncate_limit: 100 +SELECT '92233720368547758.07'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '92233720368547758.07'::money" +== 074 +-- truncate_limit: 100 +SELECT '-92233720368547758.09'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-92233720368547758.09'::money" +== 075 +-- truncate_limit: 100 +SELECT '92233720368547758.08'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '92233720368547758.08'::money" +== 076 +-- truncate_limit: 100 +-- rounding +SELECT '-92233720368547758.085'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-92233720368547758.085'::money" +== 077 +-- truncate_limit: 100 +SELECT '92233720368547758.075'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '92233720368547758.075'::money" +== 078 +-- truncate_limit: 100 +-- rounding vs. truncation in division +SELECT '878.08'::money / 11::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '878.08'::money / 11::float8" +== 079 +-- truncate_limit: 100 +SELECT '878.08'::money / 11::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '878.08'::money / 11::float4" +== 080 +-- truncate_limit: 100 +SELECT '878.08'::money / 11::bigint +-- +STMT: SelectStmt +TRUNCATED: "SELECT '878.08'::money / 11::bigint" +== 081 +-- truncate_limit: 100 +SELECT '878.08'::money / 11::int +-- +STMT: SelectStmt +TRUNCATED: "SELECT '878.08'::money / 11::int" +== 082 +-- truncate_limit: 100 +SELECT '878.08'::money / 11::smallint +-- +STMT: SelectStmt +TRUNCATED: "SELECT '878.08'::money / 11::smallint" +== 083 +-- truncate_limit: 100 +-- check for precision loss in division +SELECT '90000000000000099.00'::money / 10::bigint +-- +STMT: SelectStmt +TRUNCATED: "SELECT '90000000000000099.00'::money / 10::bigint" +== 084 +-- truncate_limit: 100 +SELECT '90000000000000099.00'::money / 10::int +-- +STMT: SelectStmt +TRUNCATED: "SELECT '90000000000000099.00'::money / 10::int" +== 085 +-- truncate_limit: 100 +SELECT '90000000000000099.00'::money / 10::smallint +-- +STMT: SelectStmt +TRUNCATED: "SELECT '90000000000000099.00'::money / 10::smallint" +== 086 +-- truncate_limit: 100 +-- Cast int4/int8/numeric to money +SELECT 1234567890::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1234567890::money" +== 087 +-- truncate_limit: 100 +SELECT 12345678901234567::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (12345678901234567)::money" +== 088 +-- truncate_limit: 100 +SELECT (-12345)::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-12345)::money" +== 089 +-- truncate_limit: 100 +SELECT (-1234567890)::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-1234567890)::money" +== 090 +-- truncate_limit: 100 +SELECT (-12345678901234567)::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-12345678901234567)::money" +== 091 +-- truncate_limit: 100 +SELECT 1234567890::int4::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1234567890::int4::money" +== 092 +-- truncate_limit: 100 +SELECT 12345678901234567::int8::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (12345678901234567)::int8::money" +== 093 +-- truncate_limit: 100 +SELECT 12345678901234567::numeric::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (12345678901234567)::numeric::money" +== 094 +-- truncate_limit: 100 +SELECT (-1234567890)::int4::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-1234567890)::int4::money" +== 095 +-- truncate_limit: 100 +SELECT (-12345678901234567)::int8::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-12345678901234567)::int8::money" +== 096 +-- truncate_limit: 100 +SELECT (-12345678901234567)::numeric::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-12345678901234567)::numeric::money" +== 097 +-- truncate_limit: 100 +-- Cast from money to numeric +SELECT '12345678901234567'::money::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12345678901234567'::money::numeric" +== 098 +-- truncate_limit: 100 +SELECT '-12345678901234567'::money::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-12345678901234567'::money::numeric" +== 099 +-- truncate_limit: 100 +SELECT '92233720368547758.07'::money::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '92233720368547758.07'::money::numeric" +== 100 +-- truncate_limit: 100 +SELECT '-92233720368547758.08'::money::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-92233720368547758.08'::money::numeric" +== 101 +-- truncate_limit: 100 +-- overflow checks +SELECT '92233720368547758.07'::money + '0.01'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '92233720368547758.07'::money + '0.01'::money" +== 102 +-- truncate_limit: 100 +SELECT '-92233720368547758.08'::money - '0.01'::money +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-92233720368547758.08'::money - '0.01'::money" +== 103 +-- truncate_limit: 100 +SELECT '92233720368547758.07'::money * 2::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '92233720368547758.07'::money * 2::float8" +== 104 +-- truncate_limit: 100 +SELECT '-1'::money / 1.175494e-38::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-1'::money / (1.175494e-38)::float4" +== 105 +-- truncate_limit: 100 +SELECT '92233720368547758.07'::money * 2::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '92233720368547758.07'::money * 2::int4" +== 106 +-- truncate_limit: 100 +SELECT '1'::money / 0::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::money / 0::int2" +== 107 +-- truncate_limit: 100 +SELECT '42'::money * 'inf'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::money * 'inf'::float8" +== 108 +-- truncate_limit: 100 +SELECT '42'::money * '-inf'::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::money * '-inf'::float8" +== 109 +-- truncate_limit: 100 +SELECT '42'::money * 'nan'::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::money * 'nan'::float4" diff --git a/parser/testdata/summary_truncate/postgres_regress/multirangetypes.metadata.json b/parser/testdata/summary_truncate/postgres_regress/multirangetypes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/multirangetypes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/multirangetypes.test b/parser/testdata/summary_truncate/postgres_regress/multirangetypes.test new file mode 100644 index 0000000..016032c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/multirangetypes.test @@ -0,0 +1,5296 @@ +== 001 +-- truncate_limit: 100 +-- Tests for multirange data types. + +|-- +-- test input parser +|-- + +-- negative tests; should fail +select ''::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::textmultirange" +== 002 +-- truncate_limit: 100 +select '{,}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{,}'::textmultirange" +== 003 +-- truncate_limit: 100 +select '{(,)}.'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(,)}.'::textmultirange" +== 004 +-- truncate_limit: 100 +select '{[a,c),}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,c),}'::textmultirange" +== 005 +-- truncate_limit: 100 +select '{,[a,c)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{,[a,c)}'::textmultirange" +== 006 +-- truncate_limit: 100 +select '{-[a,z)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{-[a,z)}'::textmultirange" +== 007 +-- truncate_limit: 100 +select '{[a,z) - }'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,z) - }'::textmultirange" +== 008 +-- truncate_limit: 100 +select '{(",a)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(\",a)}'::textmultirange" +== 009 +-- truncate_limit: 100 +select '{(,,a)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(,,a)}'::textmultirange" +== 010 +-- truncate_limit: 100 +select '{(),a)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(),a)}'::textmultirange" +== 011 +-- truncate_limit: 100 +select '{(a,))}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(a,))}'::textmultirange" +== 012 +-- truncate_limit: 100 +select '{(],a)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(],a)}'::textmultirange" +== 013 +-- truncate_limit: 100 +select '{(a,])}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(a,])}'::textmultirange" +== 014 +-- truncate_limit: 100 +select '{[z,a]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[z,a]}'::textmultirange" +== 015 +-- truncate_limit: 100 +-- should succeed +select '{}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{}'::textmultirange" +== 016 +-- truncate_limit: 100 +select ' {} '::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' {} '::textmultirange" +== 017 +-- truncate_limit: 100 +select ' { empty, empty } '::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' { empty, empty } '::textmultirange" +== 018 +-- truncate_limit: 100 +select ' {( " a " " a ", " z " " z " ) }'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' {( \" a \" \" a \", \" z \" \" z \" ) }'::textmultirange" +== 019 +-- truncate_limit: 100 +select textrange('\\\\', repeat('a', 200))::textmultirange +-- +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange(E'\\\\\\\\\\\\\\\\', repeat('a', 200))::textmultirange" +== 020 +-- truncate_limit: 100 +select '{(,z)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(,z)}'::textmultirange" +== 021 +-- truncate_limit: 100 +select '{(a,)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(a,)}'::textmultirange" +== 022 +-- truncate_limit: 100 +select '{[,z]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[,z]}'::textmultirange" +== 023 +-- truncate_limit: 100 +select '{[a,]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,]}'::textmultirange" +== 024 +-- truncate_limit: 100 +select '{(,)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(,)}'::textmultirange" +== 025 +-- truncate_limit: 100 +select '{[ , ]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[ , ]}'::textmultirange" +== 026 +-- truncate_limit: 100 +select '{["",""]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[\"\",\"\"]}'::textmultirange" +== 027 +-- truncate_limit: 100 +select '{[",",","]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[\",\",\",\"]}'::textmultirange" +== 028 +-- truncate_limit: 100 +select '{["\\","\\"]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{[\"\\\\\\\\\",\"\\\\\\\\\"]}'::textmultirange" +== 029 +-- truncate_limit: 100 +select '{["""","\""]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{[\"\"\"\",\"\\\\\"\"]}'::textmultirange" +== 030 +-- truncate_limit: 100 +select '{(\\,a)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'{(\\\\\\\\,a)}'::textmultirange" +== 031 +-- truncate_limit: 100 +select '{((,z)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{((,z)}'::textmultirange" +== 032 +-- truncate_limit: 100 +select '{([,z)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{([,z)}'::textmultirange" +== 033 +-- truncate_limit: 100 +select '{(!,()}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(!,()}'::textmultirange" +== 034 +-- truncate_limit: 100 +select '{(!,[)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(!,[)}'::textmultirange" +== 035 +-- truncate_limit: 100 +select '{[a,a]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,a]}'::textmultirange" +== 036 +-- truncate_limit: 100 +select '{[a,a],[a,b]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,a],[a,b]}'::textmultirange" +== 037 +-- truncate_limit: 100 +select '{[a,b), [b,e]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,b), [b,e]}'::textmultirange" +== 038 +-- truncate_limit: 100 +select '{[a,d), [b,f]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,d), [b,f]}'::textmultirange" +== 039 +-- truncate_limit: 100 +select '{[a,a],[b,b]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,a],[b,b]}'::textmultirange" +== 040 +-- truncate_limit: 100 +-- without canonicalization, we can't join these: +select '{[a,a], [b,b]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,a], [b,b]}'::textmultirange" +== 041 +-- truncate_limit: 100 +-- with canonicalization, we can join these: +select '{[1,2], [3,4]}'::int4multirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,2], [3,4]}'::int4multirange" +== 042 +-- truncate_limit: 100 +select '{[a,a], [b,b], [c,c]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,a], [b,b], [c,c]}'::textmultirange" +== 043 +-- truncate_limit: 100 +select '{[a,d], [b,e]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,d], [b,e]}'::textmultirange" +== 044 +-- truncate_limit: 100 +select '{[a,d), [d,e)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,d), [d,e)}'::textmultirange" +== 045 +-- truncate_limit: 100 +-- these are allowed but normalize to empty: +select '{[a,a)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[a,a)}'::textmultirange" +== 046 +-- truncate_limit: 100 +select '{(a,a]}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(a,a]}'::textmultirange" +== 047 +-- truncate_limit: 100 +select '{(a,a)}'::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(a,a)}'::textmultirange" +== 048 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +select pg_input_is_valid('{[1,2], [4,5]}', 'int4multirange') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{[1,2], [4,5]}', 'int4multirange')" +== 049 +-- truncate_limit: 100 +select pg_input_is_valid('{[1,2], [4,5]', 'int4multirange') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{[1,2], [4,5]', 'int4multirange')" +== 050 +-- truncate_limit: 100 +select * from pg_input_error_info('{[1,2], [4,5]', 'int4multirange') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{[1,2], [4,5]', 'int4multirange')" +== 051 +-- truncate_limit: 100 +select pg_input_is_valid('{[1,2], [4,zed]}', 'int4multirange') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('{[1,2], [4,zed]}', 'int4multirange')" +== 052 +-- truncate_limit: 100 +select * from pg_input_error_info('{[1,2], [4,zed]}', 'int4multirange') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('{[1,2], [4,zed]}', 'int4multirange')" +== 053 +-- truncate_limit: 100 +|-- +-- test the constructor +--- +select textmultirange() +-- +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textmultirange()" +== 054 +-- truncate_limit: 100 +select textmultirange(textrange('a', 'c')) +-- +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textmultirange(textrange('a', 'c'))" +== 055 +-- truncate_limit: 100 +select textmultirange(textrange('a', 'c'), textrange('f', 'g')) +-- +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textmultirange(textrange('a', 'c'), textrange('f', 'g'))" +== 056 +-- truncate_limit: 100 +select textmultirange(textrange('\\\\', repeat('a', 200)), textrange('c', 'd')) +-- +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textmultirange(textrange(E'\\\\\\\\\\\\\\\\', repeat('a', 200)), textrange('c', 'd'))" +== 057 +-- truncate_limit: 100 +|-- +-- test casts, both a built-in range type and a user-defined one: +|-- +select 'empty'::int4range::int4multirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::int4range::int4multirange" +== 058 +-- truncate_limit: 100 +select int4range(1, 3)::int4multirange +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4range(1, 3)::int4multirange" +== 059 +-- truncate_limit: 100 +select int4range(1, null)::int4multirange +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4range(1, NULL)::int4multirange" +== 060 +-- truncate_limit: 100 +select int4range(null, null)::int4multirange +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4range(NULL, NULL)::int4multirange" +== 061 +-- truncate_limit: 100 +select 'empty'::textrange::textmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::textrange::textmultirange" +== 062 +-- truncate_limit: 100 +select textrange('a', 'c')::textmultirange +-- +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange('a', 'c')::textmultirange" +== 063 +-- truncate_limit: 100 +select textrange('a', null)::textmultirange +-- +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange('a', NULL)::textmultirange" +== 064 +-- truncate_limit: 100 +select textrange(null, null)::textmultirange +-- +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange(NULL, NULL)::textmultirange" +== 065 +-- truncate_limit: 100 +|-- +-- test unnest(multirange) function +|-- +select unnest(int4multirange(int4range('5', '6'), int4range('1', '2'))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(int4multirange(int4range('5', '6'), int4range('1', '2')))" +== 066 +-- truncate_limit: 100 +select unnest(textmultirange(textrange('a', 'b'), textrange('d', 'e'))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(textmultirange(textrange('a', 'b'), textrange('d', 'e')))" +== 067 +-- truncate_limit: 100 +select unnest(textmultirange(textrange('\\\\', repeat('a', 200)), textrange('c', 'd'))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="textmultirange" function="textmultirange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(textmultirange(textrange(E'\\\\\\\\\\\\\\\\', repeat('a', 200)), textrange('c', 'd')))" +== 068 +-- truncate_limit: 100 +|-- +-- create some test data and test the operators +|-- + +CREATE TABLE nummultirange_test (nmr NUMMULTIRANGE) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE nummultirange_test (nmr nummultirange)" +== 069 +-- truncate_limit: 100 +CREATE INDEX nummultirange_test_btree ON nummultirange_test(nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX nummultirange_test_btree ON nummultirange_test USING btree (nmr)" +== 070 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES('{}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES ('{}')" +== 071 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES('{[,)}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES ('{[,)}')" +== 072 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES('{[3,]}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES ('{[3,]}')" +== 073 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES('{[,), [3,]}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES ('{[,), [3,]}')" +== 074 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES('{[, 5)}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES ('{[, 5)}')" +== 075 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES(nummultirange()) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES (nummultirange())" +== 076 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES(nummultirange(variadic '{}'::numrange[])) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES (nummultirange(VARIADIC '{}'::numrange[]))" +== 077 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES(nummultirange(numrange(1.1, 2.2))) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES (nummultirange(numrange(1.1, 2.2)))" +== 078 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES('{empty}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES ('{empty}')" +== 079 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES(nummultirange(numrange(1.7, 1.7, '[]'), numrange(1.7, 1.9))) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES (nummultirange(numrange(1.7, 1.7, '[]'), numrange(1.7, 1.9)))" +== 080 +-- truncate_limit: 100 +INSERT INTO nummultirange_test VALUES(nummultirange(numrange(1.7, 1.7, '[]'), numrange(1.9, 2.1))) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test VALUES (nummultirange(numrange(1.7, 1.7, '[]'), numrange(1.9, 2.1)))" +== 081 +-- truncate_limit: 100 +SELECT nmr, isempty(nmr), lower(nmr), upper(nmr) FROM nummultirange_test ORDER BY nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="isempty" function="isempty" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nmr, isempty(nmr), lower(nmr), upper(nmr) FROM nummultirange_test ORDER BY nmr" +== 082 +-- truncate_limit: 100 +SELECT nmr, lower_inc(nmr), lower_inf(nmr), upper_inc(nmr), upper_inf(nmr) FROM nummultirange_test ORDER BY nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="lower_inc" function="lower_inc" schema="" ctx=Call +FUNCTION: name="lower_inf" function="lower_inf" schema="" ctx=Call +FUNCTION: name="upper_inc" function="upper_inc" schema="" ctx=Call +FUNCTION: name="upper_inf" function="upper_inf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM nummultirange_test ORDER BY nmr" +== 083 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr = '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr = '{}'" +== 084 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr = '{(,5)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr = '{(,5)}'" +== 085 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr = '{[3,)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr = '{[3,)}'" +== 086 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr = '{[1.7,1.7]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr = '{[1.7,1.7]}'" +== 087 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr = '{[1.7,1.7],[1.9,2.1)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr = '{[1.7,1.7],[1.9,2.1)}'" +== 088 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr < '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr < '{}'" +== 089 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr < '{[-1000.0, -1000.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr < '{[-1000.0, -1000.0]}'" +== 090 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr < '{[0.0, 1.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr < '{[0.0, 1.0]}'" +== 091 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr < '{[1000.0, 1001.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr < '{[1000.0, 1001.0]}'" +== 092 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr <= '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr <= '{}'" +== 093 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr <= '{[3,)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr <= '{[3,)}'" +== 094 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr >= '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr >= '{}'" +== 095 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr >= '{[3,)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr >= '{[3,)}'" +== 096 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr > '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr > '{}'" +== 097 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr > '{[-1000.0, -1000.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr > '{[-1000.0, -1000.0]}'" +== 098 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr > '{[0.0, 1.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr > '{[0.0, 1.0]}'" +== 099 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr > '{[1000.0, 1001.0]}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr > '{[1000.0, 1001.0]}'" +== 100 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr <> '{}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr <> '{}'" +== 101 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr <> '{(,5)}' +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr <> '{(,5)}'" +== 102 +-- truncate_limit: 100 +select nummultirange(numrange(2.0, 1.0)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(2.0, 1.0))" +== 103 +-- truncate_limit: 100 +select nummultirange(numrange(5.0, 6.0), numrange(1.0, 2.0)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(5.0, 6.0), numrange(1.0, 2.0))" +== 104 +-- truncate_limit: 100 +analyze nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE nummultirange_test" +== 105 +-- truncate_limit: 100 +-- overlaps +SELECT * FROM nummultirange_test WHERE range_overlaps_multirange(numrange(4.0, 4.2), nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_overlaps_multirange" function="range_overlaps_multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="range_overlaps_multirange" function="range_overlaps_multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE range_overlaps_multirange(numrange(4.0, 4.2), nmr)" +== 106 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE numrange(4.0, 4.2) && nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE numrange(4.0, 4.2) && nmr" +== 107 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE multirange_overlaps_range(nmr, numrange(4.0, 4.2)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_overlaps_range" function="multirange_overlaps_range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="multirange_overlaps_range" function="multirange_overlaps_range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE multirange_overlaps_range(nmr, numrange(4.0, 4.2))" +== 108 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr && numrange(4.0, 4.2) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr && numrange(4.0, 4.2)" +== 109 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE multirange_overlaps_multirange(nmr, nummultirange(numrange(4.0, 4.2), numrange(6.0, 7.0))) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_overlaps_multirange" function="multirange_overlaps_multirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="multirange_overlaps_multirange" function="multirange_overlaps_multirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE ..." +== 110 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(4.0, 4.2), numrange(6.0, 7.0)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(4.0, 4.2), numrange(6.0, 7.0))" +== 111 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(6.0, 7.0)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(6.0, 7.0))" +== 112 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(6.0, 7.0), numrange(8.0, 9.0)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr && nummultirange(numrange(6.0, 7.0), numrange(8.0, 9.0))" +== 113 +-- truncate_limit: 100 +-- mr contains x +SELECT * FROM nummultirange_test WHERE multirange_contains_elem(nmr, 4.0) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_contains_elem" function="multirange_contains_elem" schema="" ctx=Call +FUNCTION: name="multirange_contains_elem" function="multirange_contains_elem" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE multirange_contains_elem(nmr, 4.0)" +== 114 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr @> 4.0 +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr @> 4.0" +== 115 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE multirange_contains_range(nmr, numrange(4.0, 4.2)) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_contains_range" function="multirange_contains_range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="multirange_contains_range" function="multirange_contains_range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE multirange_contains_range(nmr, numrange(4.0, 4.2))" +== 116 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr @> numrange(4.0, 4.2) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr @> numrange(4.0, 4.2)" +== 117 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE multirange_contains_multirange(nmr, '{[4.0,4.2), [6.0, 8.0)}') +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_contains_multirange" function="multirange_contains_multirange" schema="" ctx=Call +FUNCTION: name="multirange_contains_multirange" function="multirange_contains_multirange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE ..." +== 118 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE nmr @> '{[4.0,4.2), [6.0, 8.0)}'::nummultirange +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE nmr @> '{[4.0,4.2), [6.0, 8.0)}'::nummultirange" +== 119 +-- truncate_limit: 100 +-- x is contained by mr +SELECT * FROM nummultirange_test WHERE elem_contained_by_multirange(4.0, nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="elem_contained_by_multirange" function="elem_contained_by_multirange" schema="" ctx=Call +FUNCTION: name="elem_contained_by_multirange" function="elem_contained_by_multirange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE elem_contained_by_multirange(4.0, nmr)" +== 120 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE 4.0 <@ nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE 4.0 <@ nmr" +== 121 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE range_contained_by_multirange(numrange(4.0, 4.2), nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_contained_by_multirange" function="range_contained_by_multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="range_contained_by_multirange" function="range_contained_by_multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE range_contained_by_multirange(numrange(4.0, 4.2), nmr)" +== 122 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE numrange(4.0, 4.2) <@ nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE numrange(4.0, 4.2) <@ nmr" +== 123 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE multirange_contained_by_multirange('{[4.0,4.2), [6.0, 8.0)}', nmr) +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="multirange_contained_by_multirange" function="multirange_contained_by_multirange" schema="" ctx=Call +FUNCTION: name="multirange_contained_by_multirange" function="multirange_contained_by_multirange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE ..." +== 124 +-- truncate_limit: 100 +SELECT * FROM nummultirange_test WHERE '{[4.0,4.2), [6.0, 8.0)}'::nummultirange <@ nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test WHERE '{[4.0,4.2), [6.0, 8.0)}'::nummultirange <@ nmr" +== 125 +-- truncate_limit: 100 +-- overlaps +SELECT 'empty'::numrange && nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange && nummultirange()" +== 126 +-- truncate_limit: 100 +SELECT 'empty'::numrange && nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange && nummultirange(numrange(1, 2))" +== 127 +-- truncate_limit: 100 +SELECT nummultirange() && 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() && 'empty'::numrange" +== 128 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) && 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) && 'empty'::numrange" +== 129 +-- truncate_limit: 100 +SELECT nummultirange() && nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() && nummultirange()" +== 130 +-- truncate_limit: 100 +SELECT nummultirange() && nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() && nummultirange(numrange(1, 2))" +== 131 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) && nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) && nummultirange()" +== 132 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) && nummultirange(numrange(1,2), numrange(7,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) && nummultirange(numrange(1, 2), numrange(7, 8))" +== 133 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(7,8)) && nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(7, 8)) && nummultirange(numrange(3, 4))" +== 134 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) && nummultirange(numrange(1,2), numrange(3.5,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) && nummultirange(numrange(1, 2), numrange(3.5, 8))" +== 135 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(3.5,8)) && numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(3.5, 8)) && numrange(3, 4)" +== 136 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(3.5,8)) && nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(3.5, 8)) && nummultirange(numrange(3, 4))" +== 137 +-- truncate_limit: 100 +select '{(10,20),(30,40),(50,60)}'::nummultirange && '(42,92)'::numrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(10,20),(30,40),(50,60)}'::nummultirange && '(42,92)'::numrange" +== 138 +-- truncate_limit: 100 +-- contains +SELECT nummultirange() @> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() @> nummultirange()" +== 139 +-- truncate_limit: 100 +SELECT nummultirange() @> 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() @> 'empty'::numrange" +== 140 +-- truncate_limit: 100 +SELECT nummultirange(numrange(null,null)) @> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(NULL, NULL)) @> numrange(1, 2)" +== 141 +-- truncate_limit: 100 +SELECT nummultirange(numrange(null,null)) @> numrange(null,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(NULL, NULL)) @> numrange(NULL, 2)" +== 142 +-- truncate_limit: 100 +SELECT nummultirange(numrange(null,null)) @> numrange(2,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(NULL, NULL)) @> numrange(2, NULL)" +== 143 +-- truncate_limit: 100 +SELECT nummultirange(numrange(null,5)) @> numrange(null,3) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(NULL, 5)) @> numrange(NULL, 3)" +== 144 +-- truncate_limit: 100 +SELECT nummultirange(numrange(null,5)) @> numrange(null,8) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(NULL, 5)) @> numrange(NULL, 8)" +== 145 +-- truncate_limit: 100 +SELECT nummultirange(numrange(5,null)) @> numrange(8,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(5, NULL)) @> numrange(8, NULL)" +== 146 +-- truncate_limit: 100 +SELECT nummultirange(numrange(5,null)) @> numrange(3,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(5, NULL)) @> numrange(3, NULL)" +== 147 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5)) @> numrange(8,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5)) @> numrange(8, 9)" +== 148 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5)) @> numrange(3,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5)) @> numrange(3, 9)" +== 149 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5)) @> numrange(1,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5)) @> numrange(1, 4)" +== 150 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5)) @> numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5)) @> numrange(1, 5)" +== 151 +-- truncate_limit: 100 +SELECT nummultirange(numrange(-4,-2), numrange(1,5)) @> numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(-4, -2), numrange(1, 5)) @> numrange(1, 5)" +== 152 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5), numrange(8,9)) @> numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5), numrange(8, 9)) @> numrange(1, 5)" +== 153 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5), numrange(8,9)) @> numrange(6,7) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5), numrange(8, 9)) @> numrange(6, 7)" +== 154 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5), numrange(6,9)) @> numrange(6,7) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5), numrange(6, 9)) @> numrange(6, 7)" +== 155 +-- truncate_limit: 100 +SELECT '{[1,5)}'::nummultirange @> '{[1,5)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5)}'::nummultirange @> '{[1,5)}'" +== 156 +-- truncate_limit: 100 +SELECT '{[-4,-2), [1,5)}'::nummultirange @> '{[1,5)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[-4,-2), [1,5)}'::nummultirange @> '{[1,5)}'" +== 157 +-- truncate_limit: 100 +SELECT '{[1,5), [8,9)}'::nummultirange @> '{[1,5)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5), [8,9)}'::nummultirange @> '{[1,5)}'" +== 158 +-- truncate_limit: 100 +SELECT '{[1,5), [8,9)}'::nummultirange @> '{[6,7)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5), [8,9)}'::nummultirange @> '{[6,7)}'" +== 159 +-- truncate_limit: 100 +SELECT '{[1,5), [6,9)}'::nummultirange @> '{[6,7)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5), [6,9)}'::nummultirange @> '{[6,7)}'" +== 160 +-- truncate_limit: 100 +select '{(10,20),(30,40),(50,60)}'::nummultirange @> '(52,56)'::numrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(10,20),(30,40),(50,60)}'::nummultirange @> '(52,56)'::numrange" +== 161 +-- truncate_limit: 100 +SELECT numrange(null,null) @> nummultirange(numrange(1,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(NULL, NULL) @> nummultirange(numrange(1, 2))" +== 162 +-- truncate_limit: 100 +SELECT numrange(null,null) @> nummultirange(numrange(null,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(NULL, NULL) @> nummultirange(numrange(NULL, 2))" +== 163 +-- truncate_limit: 100 +SELECT numrange(null,null) @> nummultirange(numrange(2,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(NULL, NULL) @> nummultirange(numrange(2, NULL))" +== 164 +-- truncate_limit: 100 +SELECT numrange(null,5) @> nummultirange(numrange(null,3)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(NULL, 5) @> nummultirange(numrange(NULL, 3))" +== 165 +-- truncate_limit: 100 +SELECT numrange(null,5) @> nummultirange(numrange(null,8)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(NULL, 5) @> nummultirange(numrange(NULL, 8))" +== 166 +-- truncate_limit: 100 +SELECT numrange(5,null) @> nummultirange(numrange(8,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(5, NULL) @> nummultirange(numrange(8, NULL))" +== 167 +-- truncate_limit: 100 +SELECT numrange(5,null) @> nummultirange(numrange(3,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(5, NULL) @> nummultirange(numrange(3, NULL))" +== 168 +-- truncate_limit: 100 +SELECT numrange(1,5) @> nummultirange(numrange(8,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 5) @> nummultirange(numrange(8, 9))" +== 169 +-- truncate_limit: 100 +SELECT numrange(1,5) @> nummultirange(numrange(3,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 5) @> nummultirange(numrange(3, 9))" +== 170 +-- truncate_limit: 100 +SELECT numrange(1,5) @> nummultirange(numrange(1,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 5) @> nummultirange(numrange(1, 4))" +== 171 +-- truncate_limit: 100 +SELECT numrange(1,5) @> nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 5) @> nummultirange(numrange(1, 5))" +== 172 +-- truncate_limit: 100 +SELECT numrange(1,9) @> nummultirange(numrange(-4,-2), numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 9) @> nummultirange(numrange(-4, -2), numrange(1, 5))" +== 173 +-- truncate_limit: 100 +SELECT numrange(1,9) @> nummultirange(numrange(1,5), numrange(8,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 9) @> nummultirange(numrange(1, 5), numrange(8, 9))" +== 174 +-- truncate_limit: 100 +SELECT numrange(1,9) @> nummultirange(numrange(1,5), numrange(6,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 9) @> nummultirange(numrange(1, 5), numrange(6, 9))" +== 175 +-- truncate_limit: 100 +SELECT numrange(1,9) @> nummultirange(numrange(1,5), numrange(6,10)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 9) @> nummultirange(numrange(1, 5), numrange(6, 10))" +== 176 +-- truncate_limit: 100 +SELECT '{[1,9)}' @> '{[1,5)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,9)}' @> '{[1,5)}'::nummultirange" +== 177 +-- truncate_limit: 100 +SELECT '{[1,9)}' @> '{[-4,-2), [1,5)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,9)}' @> '{[-4,-2), [1,5)}'::nummultirange" +== 178 +-- truncate_limit: 100 +SELECT '{[1,9)}' @> '{[1,5), [8,9)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,9)}' @> '{[1,5), [8,9)}'::nummultirange" +== 179 +-- truncate_limit: 100 +SELECT '{[1,9)}' @> '{[1,5), [6,9)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,9)}' @> '{[1,5), [6,9)}'::nummultirange" +== 180 +-- truncate_limit: 100 +SELECT '{[1,9)}' @> '{[1,5), [6,10)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,9)}' @> '{[1,5), [6,10)}'::nummultirange" +== 181 +-- truncate_limit: 100 +-- is contained by +SELECT nummultirange() <@ nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() <@ nummultirange()" +== 182 +-- truncate_limit: 100 +SELECT 'empty'::numrange <@ nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange <@ nummultirange()" +== 183 +-- truncate_limit: 100 +SELECT numrange(1,2) <@ nummultirange(numrange(null,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) <@ nummultirange(numrange(NULL, NULL))" +== 184 +-- truncate_limit: 100 +SELECT numrange(null,2) <@ nummultirange(numrange(null,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(NULL, 2) <@ nummultirange(numrange(NULL, NULL))" +== 185 +-- truncate_limit: 100 +SELECT numrange(2,null) <@ nummultirange(numrange(null,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(2, NULL) <@ nummultirange(numrange(NULL, NULL))" +== 186 +-- truncate_limit: 100 +SELECT numrange(null,3) <@ nummultirange(numrange(null,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(NULL, 3) <@ nummultirange(numrange(NULL, 5))" +== 187 +-- truncate_limit: 100 +SELECT numrange(null,8) <@ nummultirange(numrange(null,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(NULL, 8) <@ nummultirange(numrange(NULL, 5))" +== 188 +-- truncate_limit: 100 +SELECT numrange(8,null) <@ nummultirange(numrange(5,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(8, NULL) <@ nummultirange(numrange(5, NULL))" +== 189 +-- truncate_limit: 100 +SELECT numrange(3,null) <@ nummultirange(numrange(5,null)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, NULL) <@ nummultirange(numrange(5, NULL))" +== 190 +-- truncate_limit: 100 +SELECT numrange(8,9) <@ nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(8, 9) <@ nummultirange(numrange(1, 5))" +== 191 +-- truncate_limit: 100 +SELECT numrange(3,9) <@ nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 9) <@ nummultirange(numrange(1, 5))" +== 192 +-- truncate_limit: 100 +SELECT numrange(1,4) <@ nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 4) <@ nummultirange(numrange(1, 5))" +== 193 +-- truncate_limit: 100 +SELECT numrange(1,5) <@ nummultirange(numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 5) <@ nummultirange(numrange(1, 5))" +== 194 +-- truncate_limit: 100 +SELECT numrange(1,5) <@ nummultirange(numrange(-4,-2), numrange(1,5)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 5) <@ nummultirange(numrange(-4, -2), numrange(1, 5))" +== 195 +-- truncate_limit: 100 +SELECT numrange(1,5) <@ nummultirange(numrange(1,5), numrange(8,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 5) <@ nummultirange(numrange(1, 5), numrange(8, 9))" +== 196 +-- truncate_limit: 100 +SELECT numrange(6,7) <@ nummultirange(numrange(1,5), numrange(8,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(6, 7) <@ nummultirange(numrange(1, 5), numrange(8, 9))" +== 197 +-- truncate_limit: 100 +SELECT numrange(6,7) <@ nummultirange(numrange(1,5), numrange(6,9)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(6, 7) <@ nummultirange(numrange(1, 5), numrange(6, 9))" +== 198 +-- truncate_limit: 100 +SELECT '{[1,5)}' <@ '{[1,5)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5)}' <@ '{[1,5)}'::nummultirange" +== 199 +-- truncate_limit: 100 +SELECT '{[1,5)}' <@ '{[-4,-2), [1,5)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5)}' <@ '{[-4,-2), [1,5)}'::nummultirange" +== 200 +-- truncate_limit: 100 +SELECT '{[1,5)}' <@ '{[1,5), [8,9)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5)}' <@ '{[1,5), [8,9)}'::nummultirange" +== 201 +-- truncate_limit: 100 +SELECT '{[6,7)}' <@ '{[1,5), [8,9)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[6,7)}' <@ '{[1,5), [8,9)}'::nummultirange" +== 202 +-- truncate_limit: 100 +SELECT '{[6,7)}' <@ '{[1,5), [6,9)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[6,7)}' <@ '{[1,5), [6,9)}'::nummultirange" +== 203 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) <@ numrange(null,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) <@ numrange(NULL, NULL)" +== 204 +-- truncate_limit: 100 +SELECT nummultirange(numrange(null,2)) <@ numrange(null,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(NULL, 2)) <@ numrange(NULL, NULL)" +== 205 +-- truncate_limit: 100 +SELECT nummultirange(numrange(2,null)) <@ numrange(null,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(2, NULL)) <@ numrange(NULL, NULL)" +== 206 +-- truncate_limit: 100 +SELECT nummultirange(numrange(null,3)) <@ numrange(null,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(NULL, 3)) <@ numrange(NULL, 5)" +== 207 +-- truncate_limit: 100 +SELECT nummultirange(numrange(null,8)) <@ numrange(null,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(NULL, 8)) <@ numrange(NULL, 5)" +== 208 +-- truncate_limit: 100 +SELECT nummultirange(numrange(8,null)) <@ numrange(5,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(8, NULL)) <@ numrange(5, NULL)" +== 209 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,null)) <@ numrange(5,null) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, NULL)) <@ numrange(5, NULL)" +== 210 +-- truncate_limit: 100 +SELECT nummultirange(numrange(8,9)) <@ numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(8, 9)) <@ numrange(1, 5)" +== 211 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,9)) <@ numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 9)) <@ numrange(1, 5)" +== 212 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,4)) <@ numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 4)) <@ numrange(1, 5)" +== 213 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5)) <@ numrange(1,5) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5)) <@ numrange(1, 5)" +== 214 +-- truncate_limit: 100 +SELECT nummultirange(numrange(-4,-2), numrange(1,5)) <@ numrange(1,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(-4, -2), numrange(1, 5)) <@ numrange(1, 9)" +== 215 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5), numrange(8,9)) <@ numrange(1,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5), numrange(8, 9)) <@ numrange(1, 9)" +== 216 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5), numrange(6,9)) <@ numrange(1,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5), numrange(6, 9)) <@ numrange(1, 9)" +== 217 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,5), numrange(6,10)) <@ numrange(1,9) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 5), numrange(6, 10)) <@ numrange(1, 9)" +== 218 +-- truncate_limit: 100 +SELECT '{[1,5)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5)}'::nummultirange <@ '{[1,9)}'" +== 219 +-- truncate_limit: 100 +SELECT '{[-4,-2), [1,5)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[-4,-2), [1,5)}'::nummultirange <@ '{[1,9)}'" +== 220 +-- truncate_limit: 100 +SELECT '{[1,5), [8,9)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5), [8,9)}'::nummultirange <@ '{[1,9)}'" +== 221 +-- truncate_limit: 100 +SELECT '{[1,5), [6,9)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5), [6,9)}'::nummultirange <@ '{[1,9)}'" +== 222 +-- truncate_limit: 100 +SELECT '{[1,5), [6,10)}'::nummultirange <@ '{[1,9)}' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,5), [6,10)}'::nummultirange <@ '{[1,9)}'" +== 223 +-- truncate_limit: 100 +-- overleft +SELECT 'empty'::numrange &< nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange &< nummultirange()" +== 224 +-- truncate_limit: 100 +SELECT 'empty'::numrange &< nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange &< nummultirange(numrange(1, 2))" +== 225 +-- truncate_limit: 100 +SELECT nummultirange() &< 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() &< 'empty'::numrange" +== 226 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) &< 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) &< 'empty'::numrange" +== 227 +-- truncate_limit: 100 +SELECT nummultirange() &< nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() &< nummultirange()" +== 228 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) &< nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) &< nummultirange()" +== 229 +-- truncate_limit: 100 +SELECT nummultirange() &< nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() &< nummultirange(numrange(1, 2))" +== 230 +-- truncate_limit: 100 +SELECT numrange(6,7) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(6, 7) &< nummultirange(numrange(3, 4))" +== 231 +-- truncate_limit: 100 +SELECT numrange(1,2) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) &< nummultirange(numrange(3, 4))" +== 232 +-- truncate_limit: 100 +SELECT numrange(1,4) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 4) &< nummultirange(numrange(3, 4))" +== 233 +-- truncate_limit: 100 +SELECT numrange(1,6) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 6) &< nummultirange(numrange(3, 4))" +== 234 +-- truncate_limit: 100 +SELECT numrange(3.5,6) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3.5, 6) &< nummultirange(numrange(3, 4))" +== 235 +-- truncate_limit: 100 +SELECT nummultirange(numrange(6,7)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(6, 7)) &< numrange(3, 4)" +== 236 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) &< numrange(3, 4)" +== 237 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,4)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 4)) &< numrange(3, 4)" +== 238 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,6)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 6)) &< numrange(3, 4)" +== 239 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3.5,6)) &< numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3.5, 6)) &< numrange(3, 4)" +== 240 +-- truncate_limit: 100 +SELECT nummultirange(numrange(6,7)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(6, 7)) &< nummultirange(numrange(3, 4))" +== 241 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) &< nummultirange(numrange(3, 4))" +== 242 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,4)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 4)) &< nummultirange(numrange(3, 4))" +== 243 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,6)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 6)) &< nummultirange(numrange(3, 4))" +== 244 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3.5,6)) &< nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3.5, 6)) &< nummultirange(numrange(3, 4))" +== 245 +-- truncate_limit: 100 +-- overright +SELECT nummultirange() &> 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() &> 'empty'::numrange" +== 246 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) &> 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) &> 'empty'::numrange" +== 247 +-- truncate_limit: 100 +SELECT 'empty'::numrange &> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange &> nummultirange()" +== 248 +-- truncate_limit: 100 +SELECT 'empty'::numrange &> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange &> nummultirange(numrange(1, 2))" +== 249 +-- truncate_limit: 100 +SELECT nummultirange() &> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() &> nummultirange()" +== 250 +-- truncate_limit: 100 +SELECT nummultirange() &> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() &> nummultirange(numrange(1, 2))" +== 251 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) &> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) &> nummultirange()" +== 252 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> numrange(6,7) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> numrange(6, 7)" +== 253 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> numrange(1, 2)" +== 254 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> numrange(1,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> numrange(1, 4)" +== 255 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> numrange(1,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> numrange(1, 6)" +== 256 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> numrange(3.5,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> numrange(3.5, 6)" +== 257 +-- truncate_limit: 100 +SELECT numrange(3,4) &> nummultirange(numrange(6,7)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 4) &> nummultirange(numrange(6, 7))" +== 258 +-- truncate_limit: 100 +SELECT numrange(3,4) &> nummultirange(numrange(1,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 4) &> nummultirange(numrange(1, 2))" +== 259 +-- truncate_limit: 100 +SELECT numrange(3,4) &> nummultirange(numrange(1,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 4) &> nummultirange(numrange(1, 4))" +== 260 +-- truncate_limit: 100 +SELECT numrange(3,4) &> nummultirange(numrange(1,6)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 4) &> nummultirange(numrange(1, 6))" +== 261 +-- truncate_limit: 100 +SELECT numrange(3,4) &> nummultirange(numrange(3.5,6)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 4) &> nummultirange(numrange(3.5, 6))" +== 262 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(6,7)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> nummultirange(numrange(6, 7))" +== 263 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> nummultirange(numrange(1, 2))" +== 264 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(1,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> nummultirange(numrange(1, 4))" +== 265 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(1,6)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> nummultirange(numrange(1, 6))" +== 266 +-- truncate_limit: 100 +SELECT nummultirange(numrange(3,4)) &> nummultirange(numrange(3.5,6)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) &> nummultirange(numrange(3.5, 6))" +== 267 +-- truncate_limit: 100 +-- meets +SELECT 'empty'::numrange -|- nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange -|- nummultirange()" +== 268 +-- truncate_limit: 100 +SELECT 'empty'::numrange -|- nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange -|- nummultirange(numrange(1, 2))" +== 269 +-- truncate_limit: 100 +SELECT nummultirange() -|- 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() -|- 'empty'::numrange" +== 270 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) -|- 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) -|- 'empty'::numrange" +== 271 +-- truncate_limit: 100 +SELECT nummultirange() -|- nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() -|- nummultirange()" +== 272 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) -|- nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) -|- nummultirange()" +== 273 +-- truncate_limit: 100 +SELECT nummultirange() -|- nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() -|- nummultirange(numrange(1, 2))" +== 274 +-- truncate_limit: 100 +SELECT numrange(1,2) -|- nummultirange(numrange(2,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) -|- nummultirange(numrange(2, 4))" +== 275 +-- truncate_limit: 100 +SELECT numrange(1,2) -|- nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) -|- nummultirange(numrange(3, 4))" +== 276 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) -|- numrange(2,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) -|- numrange(2, 4)" +== 277 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) -|- numrange(3,4) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) -|- numrange(3, 4)" +== 278 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) -|- nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) -|- nummultirange(numrange(2, 4))" +== 279 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) -|- nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) -|- nummultirange(numrange(3, 4))" +== 280 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(5,6)) -|- nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(5, 6)) -|- nummultirange(numrange(3, 4))" +== 281 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(5,6)) -|- nummultirange(numrange(6,7)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(5, 6)) -|- nummultirange(numrange(6, 7))" +== 282 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(5,6)) -|- nummultirange(numrange(8,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(5, 6)) -|- nummultirange(numrange(8, 9))" +== 283 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) -|- nummultirange(numrange(2,4), numrange(6,7)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) -|- nummultirange(numrange(2, 4), numrange(6, 7))" +== 284 +-- truncate_limit: 100 +-- strictly left +select 'empty'::numrange << nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange << nummultirange()" +== 285 +-- truncate_limit: 100 +select numrange(1,2) << nummultirange() +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) << nummultirange()" +== 286 +-- truncate_limit: 100 +select numrange(1,2) << nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) << nummultirange(numrange(3, 4))" +== 287 +-- truncate_limit: 100 +select numrange(1,2) << nummultirange(numrange(0,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) << nummultirange(numrange(0, 4))" +== 288 +-- truncate_limit: 100 +select numrange(1,2) << nummultirange(numrange(0,4), numrange(7,8)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) << nummultirange(numrange(0, 4), numrange(7, 8))" +== 289 +-- truncate_limit: 100 +select nummultirange() << 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() << 'empty'::numrange" +== 290 +-- truncate_limit: 100 +select nummultirange() << numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() << numrange(1, 2)" +== 291 +-- truncate_limit: 100 +select nummultirange(numrange(3,4)) << numrange(3,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) << numrange(3, 6)" +== 292 +-- truncate_limit: 100 +select nummultirange(numrange(0,2)) << numrange(3,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(0, 2)) << numrange(3, 6)" +== 293 +-- truncate_limit: 100 +select nummultirange(numrange(0,2), numrange(7,8)) << numrange(3,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(0, 2), numrange(7, 8)) << numrange(3, 6)" +== 294 +-- truncate_limit: 100 +select nummultirange(numrange(-4,-2), numrange(0,2)) << numrange(3,6) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(-4, -2), numrange(0, 2)) << numrange(3, 6)" +== 295 +-- truncate_limit: 100 +select nummultirange() << nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() << nummultirange()" +== 296 +-- truncate_limit: 100 +select nummultirange() << nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() << nummultirange(numrange(1, 2))" +== 297 +-- truncate_limit: 100 +select nummultirange(numrange(1,2)) << nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) << nummultirange()" +== 298 +-- truncate_limit: 100 +select nummultirange(numrange(1,2)) << nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) << nummultirange(numrange(1, 2))" +== 299 +-- truncate_limit: 100 +select nummultirange(numrange(1,2)) << nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) << nummultirange(numrange(3, 4))" +== 300 +-- truncate_limit: 100 +select nummultirange(numrange(1,2)) << nummultirange(numrange(3,4), numrange(7,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) << nummultirange(numrange(3, 4), numrange(7, 8))" +== 301 +-- truncate_limit: 100 +select nummultirange(numrange(1,2), numrange(4,5)) << nummultirange(numrange(3,4), numrange(7,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 302 +-- truncate_limit: 100 +-- strictly right +select nummultirange() >> 'empty'::numrange +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() >> 'empty'::numrange" +== 303 +-- truncate_limit: 100 +select nummultirange() >> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() >> numrange(1, 2)" +== 304 +-- truncate_limit: 100 +select nummultirange(numrange(3,4)) >> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) >> numrange(1, 2)" +== 305 +-- truncate_limit: 100 +select nummultirange(numrange(0,4)) >> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(0, 4)) >> numrange(1, 2)" +== 306 +-- truncate_limit: 100 +select nummultirange(numrange(0,4), numrange(7,8)) >> numrange(1,2) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(0, 4), numrange(7, 8)) >> numrange(1, 2)" +== 307 +-- truncate_limit: 100 +select 'empty'::numrange >> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'empty'::numrange >> nummultirange()" +== 308 +-- truncate_limit: 100 +select numrange(1,2) >> nummultirange() +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1, 2) >> nummultirange()" +== 309 +-- truncate_limit: 100 +select numrange(3,6) >> nummultirange(numrange(3,4)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 6) >> nummultirange(numrange(3, 4))" +== 310 +-- truncate_limit: 100 +select numrange(3,6) >> nummultirange(numrange(0,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 6) >> nummultirange(numrange(0, 2))" +== 311 +-- truncate_limit: 100 +select numrange(3,6) >> nummultirange(numrange(0,2), numrange(7,8)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 6) >> nummultirange(numrange(0, 2), numrange(7, 8))" +== 312 +-- truncate_limit: 100 +select numrange(3,6) >> nummultirange(numrange(-4,-2), numrange(0,2)) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3, 6) >> nummultirange(numrange(-4, -2), numrange(0, 2))" +== 313 +-- truncate_limit: 100 +select nummultirange() >> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() >> nummultirange()" +== 314 +-- truncate_limit: 100 +select nummultirange(numrange(1,2)) >> nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) >> nummultirange()" +== 315 +-- truncate_limit: 100 +select nummultirange() >> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() >> nummultirange(numrange(1, 2))" +== 316 +-- truncate_limit: 100 +select nummultirange(numrange(1,2)) >> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) >> nummultirange(numrange(1, 2))" +== 317 +-- truncate_limit: 100 +select nummultirange(numrange(3,4)) >> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4)) >> nummultirange(numrange(1, 2))" +== 318 +-- truncate_limit: 100 +select nummultirange(numrange(3,4), numrange(7,8)) >> nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(3, 4), numrange(7, 8)) >> nummultirange(numrange(1, 2))" +== 319 +-- truncate_limit: 100 +select nummultirange(numrange(3,4), numrange(7,8)) >> nummultirange(numrange(1,2), numrange(4,5)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 320 +-- truncate_limit: 100 +-- union +SELECT nummultirange() + nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() + nummultirange()" +== 321 +-- truncate_limit: 100 +SELECT nummultirange() + nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() + nummultirange(numrange(1, 2))" +== 322 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) + nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) + nummultirange()" +== 323 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) + nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) + nummultirange(numrange(1, 2))" +== 324 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) + nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) + nummultirange(numrange(2, 4))" +== 325 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) + nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) + nummultirange(numrange(3, 4))" +== 326 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) + nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(4, 5)) + nummultirange(numrange(2, 4))" +== 327 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) + nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(4, 5)) + nummultirange(numrange(3, 4))" +== 328 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) + nummultirange(numrange(0,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(4, 5)) + nummultirange(numrange(0, 9))" +== 329 +-- truncate_limit: 100 +-- merge +SELECT range_merge(nummultirange()) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_merge(nummultirange())" +== 330 +-- truncate_limit: 100 +SELECT range_merge(nummultirange(numrange(1,2))) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_merge(nummultirange(numrange(1, 2)))" +== 331 +-- truncate_limit: 100 +SELECT range_merge(nummultirange(numrange(1,2), numrange(7,8))) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_merge(nummultirange(numrange(1, 2), numrange(7, 8)))" +== 332 +-- truncate_limit: 100 +-- minus +SELECT nummultirange() - nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() - nummultirange()" +== 333 +-- truncate_limit: 100 +SELECT nummultirange() - nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() - nummultirange(numrange(1, 2))" +== 334 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) - nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) - nummultirange()" +== 335 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(3,4)) - nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(3, 4)) - nummultirange()" +== 336 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) - nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) - nummultirange(numrange(1, 2))" +== 337 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) - nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) - nummultirange(numrange(2, 4))" +== 338 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) - nummultirange(numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) - nummultirange(numrange(3, 4))" +== 339 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,4)) - nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 4)) - nummultirange(numrange(1, 2))" +== 340 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,4)) - nummultirange(numrange(2,3)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 4)) - nummultirange(numrange(2, 3))" +== 341 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,4)) - nummultirange(numrange(0,8)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 4)) - nummultirange(numrange(0, 8))" +== 342 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,4)) - nummultirange(numrange(0,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 4)) - nummultirange(numrange(0, 2))" +== 343 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,8)) - nummultirange(numrange(0,2), numrange(3,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 8)) - nummultirange(numrange(0, 2), numrange(3, 4))" +== 344 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,8)) - nummultirange(numrange(2,3), numrange(5,null)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 8)) - nummultirange(numrange(2, 3), numrange(5, NULL))" +== 345 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(-2,0)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(4, 5)) - nummultirange(numrange(-2, 0))" +== 346 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(2,4)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(4, 5)) - nummultirange(numrange(2, 4))" +== 347 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(3,5)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(4, 5)) - nummultirange(numrange(3, 5))" +== 348 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(0,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(4, 5)) - nummultirange(numrange(0, 9))" +== 349 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,3), numrange(4,5)) - nummultirange(numrange(2,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 3), numrange(4, 5)) - nummultirange(numrange(2, 9))" +== 350 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(8,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2), numrange(4, 5)) - nummultirange(numrange(8, 9))" +== 351 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2), numrange(4,5)) - nummultirange(numrange(-2,0), numrange(8,9)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 352 +-- truncate_limit: 100 +-- intersection +SELECT nummultirange() * nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() * nummultirange()" +== 353 +-- truncate_limit: 100 +SELECT nummultirange() * nummultirange(numrange(1,2)) +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange() * nummultirange(numrange(1, 2))" +== 354 +-- truncate_limit: 100 +SELECT nummultirange(numrange(1,2)) * nummultirange() +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nummultirange(numrange(1, 2)) * nummultirange()" +== 355 +-- truncate_limit: 100 +SELECT '{[1,3)}'::nummultirange * '{[1,5)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,3)}'::nummultirange * '{[1,5)}'::nummultirange" +== 356 +-- truncate_limit: 100 +SELECT '{[1,3)}'::nummultirange * '{[0,5)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,3)}'::nummultirange * '{[0,5)}'::nummultirange" +== 357 +-- truncate_limit: 100 +SELECT '{[1,3)}'::nummultirange * '{[0,2)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,3)}'::nummultirange * '{[0,2)}'::nummultirange" +== 358 +-- truncate_limit: 100 +SELECT '{[1,3)}'::nummultirange * '{[2,5)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,3)}'::nummultirange * '{[2,5)}'::nummultirange" +== 359 +-- truncate_limit: 100 +SELECT '{[1,4)}'::nummultirange * '{[2,3)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,4)}'::nummultirange * '{[2,3)}'::nummultirange" +== 360 +-- truncate_limit: 100 +SELECT '{[1,4)}'::nummultirange * '{[0,2), [3,5)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,4)}'::nummultirange * '{[0,2), [3,5)}'::nummultirange" +== 361 +-- truncate_limit: 100 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,8), [9,12)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,8), [9,12)}'::nummultirange" +== 362 +-- truncate_limit: 100 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[9,12)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,4), [7,10)}'::nummultirange * '{[9,12)}'::nummultirange" +== 363 +-- truncate_limit: 100 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[-5,-4), [5,6), [9,12)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,4), [7,10)}'::nummultirange * '{[-5,-4), [5,6), [9,12)}'::nummultirange" +== 364 +-- truncate_limit: 100 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,2), [3,8), [9,12)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,2), [3,8), [9,12)}'::nummultirange" +== 365 +-- truncate_limit: 100 +SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,2), [3,8), [9,12)}'::nummultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[1,4), [7,10)}'::nummultirange * '{[0,2), [3,8), [9,12)}'::nummultirange" +== 366 +-- truncate_limit: 100 +-- test GiST index +create table test_multirange_gist(mr int4multirange) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_multirange_gist (mr int4multirange)" +== 367 +-- truncate_limit: 100 +insert into test_multirange_gist select int4multirange(int4range(g, g+10),int4range(g+20, g+30),int4range(g+40, g+50)) from generate_series(1,2000) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_multirange_gist SELECT ... FROM generate_series(1, 2000) g" +== 368 +-- truncate_limit: 100 +insert into test_multirange_gist select '{}'::int4multirange from generate_series(1,500) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_multirange_gist SELECT '{}'::int4multirange FROM generate_series(1, 500) g" +== 369 +-- truncate_limit: 100 +insert into test_multirange_gist select int4multirange(int4range(g, g+10000)) from generate_series(1,1000) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_multirange_gist SELECT ... FROM generate_series(1, 1000) g" +== 370 +-- truncate_limit: 100 +insert into test_multirange_gist select int4multirange(int4range(NULL, g*10, '(]'), int4range(g*10, g*20, '(]')) from generate_series(1,100) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_multirange_gist SELECT ... FROM generate_series(1, 100) g" +== 371 +-- truncate_limit: 100 +insert into test_multirange_gist select int4multirange(int4range(g*10, g*20, '(]'), int4range(g*20, NULL, '(]')) from generate_series(1,100) g +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DML +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_multirange_gist SELECT ... FROM generate_series(1, 100) g" +== 372 +-- truncate_limit: 100 +create index test_mulrirange_gist_idx on test_multirange_gist using gist (mr) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_mulrirange_gist_idx ON test_multirange_gist USING gist (mr)" +== 373 +-- truncate_limit: 100 +-- test statistics and selectivity estimation as well +|-- +-- We don't check the accuracy of selectivity estimation, but at least check +-- it doesn't fall. +analyze test_multirange_gist +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE test_multirange_gist" +== 374 +-- truncate_limit: 100 +-- first, verify non-indexed results +SET enable_seqscan = t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO t" +== 375 +-- truncate_limit: 100 +SET enable_indexscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO f" +== 376 +-- truncate_limit: 100 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO f" +== 377 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr = '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr = '{}'::int4multirange" +== 378 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> 'empty'::int4range" +== 379 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr && 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr && 'empty'::int4range" +== 380 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr <@ 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr <@ 'empty'::int4range" +== 381 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr << 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr << 'empty'::int4range" +== 382 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr >> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr >> 'empty'::int4range" +== 383 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &< 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &< 'empty'::int4range" +== 384 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &> 'empty'::int4range" +== 385 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr -|- 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr -|- 'empty'::int4range" +== 386 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> '{}'::int4multirange" +== 387 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> '{}'::int4multirange" +== 388 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr && '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr && '{}'::int4multirange" +== 389 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr <@ '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr <@ '{}'::int4multirange" +== 390 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr << '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr << '{}'::int4multirange" +== 391 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr >> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr >> '{}'::int4multirange" +== 392 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &< '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &< '{}'::int4multirange" +== 393 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &> '{}'::int4multirange" +== 394 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr -|- '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr -|- '{}'::int4multirange" +== 395 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr = int4multirange(int4range(10,20), int4range(30,40), int4range(50,60)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 396 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> 10 +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> 10" +== 397 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> int4range(10,20) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> int4range(10, 20)" +== 398 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr && int4range(10,20) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr && int4range(10, 20)" +== 399 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr <@ int4range(10,50) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr <@ int4range(10, 50)" +== 400 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr << int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr << int4range(100, 500)" +== 401 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr >> int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr >> int4range(100, 500)" +== 402 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &< int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &< int4range(100, 500)" +== 403 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &> int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &> int4range(100, 500)" +== 404 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr -|- int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr -|- int4range(100, 500)" +== 405 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> '{}'::int4multirange" +== 406 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 407 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr && '{(10,20),(30,40),(50,60)}'::int4multirange" +== 408 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr <@ '{(10,30),(40,60),(70,90)}'::int4multirange" +== 409 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 410 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 411 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 412 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 413 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 414 +-- truncate_limit: 100 +-- now check same queries using index +SET enable_seqscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO f" +== 415 +-- truncate_limit: 100 +SET enable_indexscan = t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO t" +== 416 +-- truncate_limit: 100 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO f" +== 417 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr = '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr = '{}'::int4multirange" +== 418 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> 'empty'::int4range" +== 419 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr && 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr && 'empty'::int4range" +== 420 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr <@ 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr <@ 'empty'::int4range" +== 421 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr << 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr << 'empty'::int4range" +== 422 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr >> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr >> 'empty'::int4range" +== 423 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &< 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &< 'empty'::int4range" +== 424 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &> 'empty'::int4range" +== 425 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr -|- 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr -|- 'empty'::int4range" +== 426 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> '{}'::int4multirange" +== 427 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> '{}'::int4multirange" +== 428 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr && '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr && '{}'::int4multirange" +== 429 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr <@ '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr <@ '{}'::int4multirange" +== 430 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr << '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr << '{}'::int4multirange" +== 431 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr >> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr >> '{}'::int4multirange" +== 432 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &< '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &< '{}'::int4multirange" +== 433 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &> '{}'::int4multirange" +== 434 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr -|- '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr -|- '{}'::int4multirange" +== 435 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> 'empty'::int4range +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> 'empty'::int4range" +== 436 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr = int4multirange(int4range(10,20), int4range(30,40), int4range(50,60)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 437 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> 10 +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> 10" +== 438 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> int4range(10,20) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> int4range(10, 20)" +== 439 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr && int4range(10,20) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr && int4range(10, 20)" +== 440 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr <@ int4range(10,50) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr <@ int4range(10, 50)" +== 441 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr << int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr << int4range(100, 500)" +== 442 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr >> int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr >> int4range(100, 500)" +== 443 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &< int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &< int4range(100, 500)" +== 444 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &> int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr &> int4range(100, 500)" +== 445 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr -|- int4range(100,500) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr -|- int4range(100, 500)" +== 446 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> '{}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr @> '{}'::int4multirange" +== 447 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 448 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr && '{(10,20),(30,40),(50,60)}'::int4multirange" +== 449 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE mr <@ '{(10,30),(40,60),(70,90)}'::int4multirange" +== 450 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 451 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 452 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 453 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 454 +-- truncate_limit: 100 +select count(*) from test_multirange_gist where mr -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="mr" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_multirange_gist WHERE ..." +== 455 +-- truncate_limit: 100 +drop table test_multirange_gist +-- +TABLE: name="test_multirange_gist" schema="" table="test_multirange_gist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_multirange_gist" +== 456 +-- truncate_limit: 100 +|-- +-- range_agg function +|-- +create table reservations ( room_id integer not null, booked_during daterange ) +-- +TABLE: name="reservations" schema="" table="reservations" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE reservations (room_id int NOT NULL, booked_during daterange)" +== 457 +-- truncate_limit: 100 +insert into reservations values +-- 1: has a meets and a gap +(1, daterange('2018-07-01', '2018-07-07')), +(1, daterange('2018-07-07', '2018-07-14')), +(1, daterange('2018-07-20', '2018-07-22')), +-- 2: just a single row +(2, daterange('2018-07-01', '2018-07-03')), +-- 3: one null range +(3, NULL), +-- 4: two null ranges +(4, NULL), +(4, NULL), +-- 5: a null range and a non-null range +(5, NULL), +(5, daterange('2018-07-01', '2018-07-03')), +-- 6: has overlap +(6, daterange('2018-07-01', '2018-07-07')), +(6, daterange('2018-07-05', '2018-07-10')), +-- 7: two ranges that meet: no gap or overlap +(7, daterange('2018-07-01', '2018-07-07')), +(7, daterange('2018-07-07', '2018-07-14')), +-- 8: an empty range +(8, 'empty'::daterange) +-- +TABLE: name="reservations" schema="" table="reservations" ctx=DML +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO reservations VALUES (...)" +== 458 +-- truncate_limit: 100 +SELECT room_id, range_agg(booked_during) +FROM reservations +GROUP BY room_id +ORDER BY room_id +-- +TABLE: name="reservations" schema="" table="reservations" ctx=Select +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT room_id, range_agg(booked_during) FROM reservations GROUP BY room_id ORDER BY room_id" +== 459 +-- truncate_limit: 100 +-- range_agg on a custom range type too +SELECT range_agg(r) +FROM (VALUES + ('[a,c]'::textrange), + ('[b,b]'::textrange), + ('[c,f]'::textrange), + ('[g,h)'::textrange), + ('[h,j)'::textrange) + ) t(r) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(r) FROM (VALUES (...)) t(r)" +== 460 +-- truncate_limit: 100 +-- range_agg with multirange inputs +select range_agg(nmr) from nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM nummultirange_test" +== 461 +-- truncate_limit: 100 +select range_agg(nmr) from nummultirange_test where false +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM nummultirange_test WHERE false" +== 462 +-- truncate_limit: 100 +select range_agg(null::nummultirange) from nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(NULL::nummultirange) FROM nummultirange_test" +== 463 +-- truncate_limit: 100 +select range_agg(nmr) from (values ('{}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM (VALUES ('{}'::nummultirange)) t(nmr)" +== 464 +-- truncate_limit: 100 +select range_agg(nmr) from (values ('{}'::nummultirange), ('{}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM (VALUES ('{}'::nummultirange), ('{}'::nummultirange)) t(nmr)" +== 465 +-- truncate_limit: 100 +select range_agg(nmr) from (values ('{[1,2]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM (VALUES ('{[1,2]}'::nummultirange)) t(nmr)" +== 466 +-- truncate_limit: 100 +select range_agg(nmr) from (values ('{[1,2], [5,6]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM (VALUES ('{[1,2], [5,6]}'::nummultirange)) t(nmr)" +== 467 +-- truncate_limit: 100 +select range_agg(nmr) from (values ('{[1,2], [2,3]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM (VALUES ('{[1,2], [2,3]}'::nummultirange)) t(nmr)" +== 468 +-- truncate_limit: 100 +select range_agg(nmr) from (values ('{[1,2]}'::nummultirange), ('{[5,6]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM (VALUES ('{[1,2]}'::nummultirange), ('{[5,6]}'::nummultirange)) t(nmr)" +== 469 +-- truncate_limit: 100 +select range_agg(nmr) from (values ('{[1,2]}'::nummultirange), ('{[2,3]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_agg" function="range_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_agg(nmr) FROM (VALUES ('{[1,2]}'::nummultirange), ('{[2,3]}'::nummultirange)) t(nmr)" +== 470 +-- truncate_limit: 100 +|-- +-- range_intersect_agg function +|-- +select range_intersect_agg(nmr) from nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM nummultirange_test" +== 471 +-- truncate_limit: 100 +select range_intersect_agg(nmr) from nummultirange_test where false +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM nummultirange_test WHERE false" +== 472 +-- truncate_limit: 100 +select range_intersect_agg(null::nummultirange) from nummultirange_test +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(NULL::nummultirange) FROM nummultirange_test" +== 473 +-- truncate_limit: 100 +select range_intersect_agg(nmr) from (values ('{[1,3]}'::nummultirange), ('{[6,12]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM (VALUES (...)) t(nmr)" +== 474 +-- truncate_limit: 100 +select range_intersect_agg(nmr) from (values ('{[1,6]}'::nummultirange), ('{[3,12]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM (VALUES (...)) t(nmr)" +== 475 +-- truncate_limit: 100 +select range_intersect_agg(nmr) from (values ('{[1,6], [10,12]}'::nummultirange), ('{[4,14]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM (VALUES (...)) t(nmr)" +== 476 +-- truncate_limit: 100 +-- test with just one input: +select range_intersect_agg(nmr) from (values ('{}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM (VALUES ('{}'::nummultirange)) t(nmr)" +== 477 +-- truncate_limit: 100 +select range_intersect_agg(nmr) from (values ('{[1,2]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM (VALUES ('{[1,2]}'::nummultirange)) t(nmr)" +== 478 +-- truncate_limit: 100 +select range_intersect_agg(nmr) from (values ('{[1,6], [10,12]}'::nummultirange)) t(nmr) +-- +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM (VALUES ('{[1,6], [10,12]}'::nummultirange)) t(nmr)" +== 479 +-- truncate_limit: 100 +select range_intersect_agg(nmr) from nummultirange_test where nmr @> 4.0 +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nmr) FROM nummultirange_test WHERE nmr @> 4.0" +== 480 +-- truncate_limit: 100 +create table nummultirange_test2(nmr nummultirange) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE nummultirange_test2 (nmr nummultirange)" +== 481 +-- truncate_limit: 100 +create index nummultirange_test2_hash_idx on nummultirange_test2 using hash (nmr) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX nummultirange_test2_hash_idx ON nummultirange_test2 USING hash (nmr)" +== 482 +-- truncate_limit: 100 +INSERT INTO nummultirange_test2 VALUES('{[, 5)}') +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test2 VALUES ('{[, 5)}')" +== 483 +-- truncate_limit: 100 +INSERT INTO nummultirange_test2 VALUES(nummultirange(numrange(1.1, 2.2))) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test2 VALUES (nummultirange(numrange(1.1, 2.2)))" +== 484 +-- truncate_limit: 100 +INSERT INTO nummultirange_test2 VALUES(nummultirange(numrange(1.1, 2.2))) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test2 VALUES (nummultirange(numrange(1.1, 2.2)))" +== 485 +-- truncate_limit: 100 +INSERT INTO nummultirange_test2 VALUES(nummultirange(numrange(1.1, 2.2,'()'))) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test2 VALUES (nummultirange(numrange(1.1, 2.2, '()')))" +== 486 +-- truncate_limit: 100 +INSERT INTO nummultirange_test2 VALUES('{}') +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO nummultirange_test2 VALUES ('{}')" +== 487 +-- truncate_limit: 100 +select * from nummultirange_test2 where nmr = '{}' +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test2 WHERE nmr = '{}'" +== 488 +-- truncate_limit: 100 +select * from nummultirange_test2 where nmr = nummultirange(numrange(1.1, 2.2)) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test2 WHERE nmr = nummultirange(numrange(1.1, 2.2))" +== 489 +-- truncate_limit: 100 +select * from nummultirange_test2 where nmr = nummultirange(numrange(1.1, 2.3)) +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nmr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test2 WHERE nmr = nummultirange(numrange(1.1, 2.3))" +== 490 +-- truncate_limit: 100 +set enable_nestloop=t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO t" +== 491 +-- truncate_limit: 100 +set enable_hashjoin=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO f" +== 492 +-- truncate_limit: 100 +set enable_mergejoin=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO f" +== 493 +-- truncate_limit: 100 +select * from nummultirange_test natural join nummultirange_test2 order by nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test NATURAL JOIN nummultirange_test2 ORDER BY nmr" +== 494 +-- truncate_limit: 100 +set enable_nestloop=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO f" +== 495 +-- truncate_limit: 100 +set enable_hashjoin=t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO t" +== 496 +-- truncate_limit: 100 +set enable_mergejoin=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO f" +== 497 +-- truncate_limit: 100 +select * from nummultirange_test natural join nummultirange_test2 order by nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test NATURAL JOIN nummultirange_test2 ORDER BY nmr" +== 498 +-- truncate_limit: 100 +set enable_nestloop=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO f" +== 499 +-- truncate_limit: 100 +set enable_hashjoin=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO f" +== 500 +-- truncate_limit: 100 +set enable_mergejoin=t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO t" +== 501 +-- truncate_limit: 100 +select * from nummultirange_test natural join nummultirange_test2 order by nmr +-- +TABLE: name="nummultirange_test" schema="" table="nummultirange_test" ctx=Select +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nummultirange_test NATURAL JOIN nummultirange_test2 ORDER BY nmr" +== 502 +-- truncate_limit: 100 +set enable_nestloop to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO DEFAULT" +== 503 +-- truncate_limit: 100 +set enable_hashjoin to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO DEFAULT" +== 504 +-- truncate_limit: 100 +set enable_mergejoin to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO DEFAULT" +== 505 +-- truncate_limit: 100 +DROP TABLE nummultirange_test2 +-- +TABLE: name="nummultirange_test2" schema="" table="nummultirange_test2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE nummultirange_test2" +== 506 +-- truncate_limit: 100 +|-- +-- Test user-defined multirange of floats +|-- + +select '{[123.001, 5.e9)}'::float8multirange @> 888.882::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[123.001, 5.e9)}'::float8multirange @> (888.882)::float8" +== 507 +-- truncate_limit: 100 +create table float8multirange_test(f8mr float8multirange, i int) +-- +TABLE: name="float8multirange_test" schema="" table="float8multirange_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE float8multirange_test (f8mr float8multirange, i int)" +== 508 +-- truncate_limit: 100 +insert into float8multirange_test values(float8multirange(float8range(-100.00007, '1.111113e9')), 42) +-- +TABLE: name="float8multirange_test" schema="" table="float8multirange_test" ctx=DML +FUNCTION: name="float8multirange" function="float8multirange" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8multirange_test VALUES (...)" +== 509 +-- truncate_limit: 100 +select * from float8multirange_test +-- +TABLE: name="float8multirange_test" schema="" table="float8multirange_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float8multirange_test" +== 510 +-- truncate_limit: 100 +drop table float8multirange_test +-- +TABLE: name="float8multirange_test" schema="" table="float8multirange_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE float8multirange_test" +== 511 +-- truncate_limit: 100 +|-- +-- Test multirange types over domains +|-- + +create domain mydomain as int4 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN mydomain AS int4" +== 512 +-- truncate_limit: 100 +create type mydomainrange as range(subtype=mydomain) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE mydomainrange AS RANGE (subtype = mydomain)" +== 513 +-- truncate_limit: 100 +select '{[4,50)}'::mydomainmultirange @> 7::mydomain +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[4,50)}'::mydomainmultirange @> 7::mydomain" +== 514 +-- truncate_limit: 100 +drop domain mydomain cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN mydomain CASCADE" +== 515 +-- truncate_limit: 100 +|-- +-- Test domains over multirange types +|-- + +create domain restrictedmultirange as int4multirange check (upper(value) < 10) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN restrictedmultirange AS int4multirange CHECK (upper(value) < 10)" +== 516 +-- truncate_limit: 100 +select '{[4,5)}'::restrictedmultirange @> 7 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[4,5)}'::restrictedmultirange @> 7" +== 517 +-- truncate_limit: 100 +select '{[4,50)}'::restrictedmultirange @> 7 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{[4,50)}'::restrictedmultirange @> 7" +== 518 +-- truncate_limit: 100 +-- should fail +drop domain restrictedmultirange +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN restrictedmultirange" +== 519 +-- truncate_limit: 100 +--- +-- Check automatic naming of multiranges +--- + +create type intr as range(subtype=int) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE intr AS RANGE (subtype = int)" +== 520 +-- truncate_limit: 100 +select intr_multirange(intr(1,10)) +-- +FUNCTION: name="intr_multirange" function="intr_multirange" schema="" ctx=Call +FUNCTION: name="intr" function="intr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT intr_multirange(intr(1, 10))" +== 521 +-- truncate_limit: 100 +drop type intr +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE intr" +== 522 +-- truncate_limit: 100 +create type intmultirange as (x int, y int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE intmultirange AS (x int, y int)" +== 523 +-- truncate_limit: 100 +create type intrange as range(subtype=int) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE intrange AS RANGE (subtype = int)" +== 524 +-- truncate_limit: 100 +-- should fail +drop type intmultirange +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE intmultirange" +== 525 +-- truncate_limit: 100 +create type intr_multirange as (x int, y int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE intr_multirange AS (x int, y int)" +== 526 +-- truncate_limit: 100 +create type intr as range(subtype=int) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE intr AS RANGE (subtype = int)" +== 527 +-- truncate_limit: 100 +-- should fail +drop type intr_multirange +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE intr_multirange" +== 528 +-- truncate_limit: 100 +|-- +-- Test multiple multirange types over the same subtype and manual naming of +-- the multirange type. +|-- + +-- should fail +create type textrange1 as range(subtype=text, multirange_type_name=int, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange1 AS RANGE (subtype = text, multirange_type_name = int, \"collation\" = \"C\")" +== 529 +-- truncate_limit: 100 +-- should pass +create type textrange1 as range(subtype=text, multirange_type_name=multirange_of_text, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange1 AS RANGE (subtype = text, multirange_type_name = multirange_of_text, \"coll..." +== 530 +-- truncate_limit: 100 +-- should pass, because existing _textrange1 is automatically renamed +create type textrange2 as range(subtype=text, multirange_type_name=_textrange1, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange2 AS RANGE (subtype = text, multirange_type_name = _textrange1, \"collation\" ..." +== 531 +-- truncate_limit: 100 +select multirange_of_text(textrange2('a','Z')) +-- +FUNCTION: name="multirange_of_text" function="multirange_of_text" schema="" ctx=Call +FUNCTION: name="textrange2" function="textrange2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT multirange_of_text(textrange2('a', 'Z'))" +== 532 +-- truncate_limit: 100 +-- should fail +select multirange_of_text(textrange1('a','Z')) @> 'b'::text +-- +FUNCTION: name="multirange_of_text" function="multirange_of_text" schema="" ctx=Call +FUNCTION: name="textrange1" function="textrange1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT multirange_of_text(textrange1('a', 'Z')) @> 'b'::text" +== 533 +-- truncate_limit: 100 +select unnest(multirange_of_text(textrange1('a','b'), textrange1('d','e'))) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="multirange_of_text" function="multirange_of_text" schema="" ctx=Call +FUNCTION: name="textrange1" function="textrange1" schema="" ctx=Call +FUNCTION: name="textrange1" function="textrange1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(multirange_of_text(textrange1('a', 'b'), textrange1('d', 'e')))" +== 534 +-- truncate_limit: 100 +select _textrange1(textrange2('a','z')) @> 'b'::text +-- +FUNCTION: name="_textrange1" function="_textrange1" schema="" ctx=Call +FUNCTION: name="textrange2" function="textrange2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT _textrange1(textrange2('a', 'z')) @> 'b'::text" +== 535 +-- truncate_limit: 100 +drop type textrange1 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange1" +== 536 +-- truncate_limit: 100 +drop type textrange2 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange2" +== 537 +-- truncate_limit: 100 +|-- +-- Multiranges don't have their own ownership or permissions. +|-- +create type textrange1 as range(subtype=text, multirange_type_name=multitextrange1, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange1 AS RANGE (subtype = text, multirange_type_name = multitextrange1, \"collati..." +== 538 +-- truncate_limit: 100 +create role regress_multirange_owner +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_multirange_owner" +== 539 +-- truncate_limit: 100 +alter type multitextrange1 owner to regress_multirange_owner +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TYPE multitextrange1 OWNER TO regress_multirange_owner" +== 540 +-- truncate_limit: 100 +-- fail +alter type textrange1 owner to regress_multirange_owner +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TYPE textrange1 OWNER TO regress_multirange_owner" +== 541 +-- truncate_limit: 100 +set role regress_multirange_owner +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_multirange_owner" +== 542 +-- truncate_limit: 100 +revoke usage on type multitextrange1 from public +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE multitextrange1 FROM public" +== 543 +-- truncate_limit: 100 +-- fail +revoke usage on type textrange1 from public +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE textrange1 FROM public" +== 544 +-- truncate_limit: 100 +create temp table test1(f1 multitextrange1[]) +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test1 (f1 multitextrange1[])" +== 545 +-- truncate_limit: 100 +revoke usage on type textrange1 from regress_multirange_owner +-- +STMT: GrantStmt +TRUNCATED: "REVOKE usage ON TYPE textrange1 FROM regress_multirange_owner" +== 546 +-- truncate_limit: 100 +create temp table test2(f1 multitextrange1[]) +-- +TABLE: name="test2" schema="" table="test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test2 (f1 multitextrange1[])" +== 547 +-- truncate_limit: 100 +-- fail + +drop table test1 +-- +TABLE: name="test1" schema="" table="test1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test1" +== 548 +-- truncate_limit: 100 +drop type textrange1 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange1" +== 549 +-- truncate_limit: 100 +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 550 +-- truncate_limit: 100 +drop role regress_multirange_owner +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_multirange_owner" +== 551 +-- truncate_limit: 100 +|-- +-- Test polymorphic type system +|-- + +create function anyarray_anymultirange_func(a anyarray, r anymultirange) + returns anyelement as 'select $1[1] + lower($2);' language sql +-- +FUNCTION: name="anyarray_anymultirange_func" function="anyarray_anymultirange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyarray_anymultirange_func(a anyarray, r anymultirange) RETURNS anyelement AS $$..." +== 552 +-- truncate_limit: 100 +select anyarray_anymultirange_func(ARRAY[1,2], int4multirange(int4range(10,20))) +-- +FUNCTION: name="anyarray_anymultirange_func" function="anyarray_anymultirange_func" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anyarray_anymultirange_func(ARRAY[1, 2], int4multirange(int4range(10, 20)))" +== 553 +-- truncate_limit: 100 +-- should fail +select anyarray_anymultirange_func(ARRAY[1,2], nummultirange(numrange(10,20))) +-- +FUNCTION: name="anyarray_anymultirange_func" function="anyarray_anymultirange_func" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anyarray_anymultirange_func(ARRAY[1, 2], nummultirange(numrange(10, 20)))" +== 554 +-- truncate_limit: 100 +drop function anyarray_anymultirange_func(anyarray, anymultirange) +-- +FUNCTION: name="anyarray_anymultirange_func" function="anyarray_anymultirange_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyarray_anymultirange_func(anyarray, anymultirange)" +== 555 +-- truncate_limit: 100 +-- should fail +create function bogus_func(anyelement) + returns anymultirange as 'select int4multirange(int4range(1,10))' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bogus_func(anyelement) RETURNS anymultirange AS $$select int4multirange(int4range..." +== 556 +-- truncate_limit: 100 +-- should fail +create function bogus_func(int) + returns anymultirange as 'select int4multirange(int4range(1,10))' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bogus_func(int) RETURNS anymultirange AS $$select int4multirange(int4range(1,10))..." +== 557 +-- truncate_limit: 100 +create function range_add_bounds(anymultirange) + returns anyelement as 'select lower($1) + upper($1)' language sql +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION range_add_bounds(anymultirange) RETURNS anyelement AS $$select lower($1) + upper(..." +== 558 +-- truncate_limit: 100 +select range_add_bounds(int4multirange(int4range(1, 17))) +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_add_bounds(int4multirange(int4range(1, 17)))" +== 559 +-- truncate_limit: 100 +select range_add_bounds(nummultirange(numrange(1.0001, 123.123))) +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_add_bounds(nummultirange(numrange(1.0001, 123.123)))" +== 560 +-- truncate_limit: 100 +create function multirangetypes_sql(q anymultirange, b anyarray, out c anyelement) + as $$ select upper($1) + $2[1] $$ + language sql +-- +FUNCTION: name="multirangetypes_sql" function="multirangetypes_sql" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION multirangetypes_sql(q anymultirange, b anyarray, OUT c anyelement) AS $$ select u..." +== 561 +-- truncate_limit: 100 +select multirangetypes_sql(int4multirange(int4range(1,10)), ARRAY[2,20]) +-- +FUNCTION: name="multirangetypes_sql" function="multirangetypes_sql" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT multirangetypes_sql(int4multirange(int4range(1, 10)), ARRAY[2, 20])" +== 562 +-- truncate_limit: 100 +select multirangetypes_sql(nummultirange(numrange(1,10)), ARRAY[2,20]) +-- +FUNCTION: name="multirangetypes_sql" function="multirangetypes_sql" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT multirangetypes_sql(nummultirange(numrange(1, 10)), ARRAY[2, 20])" +== 563 +-- truncate_limit: 100 +-- match failure + +create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange) + returns anycompatible as 'select $1[1] + lower($2);' language sql +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompa..." +== 564 +-- truncate_limit: 100 +select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20))) +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anycompatiblearray_anycompatiblemultirange_func(ARRAY[1, 2], multirange(int4range(10, 20)))" +== 565 +-- truncate_limit: 100 +select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(numrange(10,20))) +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anycompatiblearray_anycompatiblemultirange_func(ARRAY[1, 2], multirange(numrange(10, 20)))" +== 566 +-- truncate_limit: 100 +-- should fail +select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1.1,2], multirange(int4range(10,20))) +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anycompatiblearray_anycompatiblemultirange_func(ARRAY[1.1, 2], multirange(int4range(10, 20)))" +== 567 +-- truncate_limit: 100 +drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange) +-- +FUNCTION: name="anycompatiblearray_anycompatiblemultirange_func" function="anycompatiblearray_anycompatiblemultirange_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemu..." +== 568 +-- truncate_limit: 100 +create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange) + returns anycompatible as 'select lower($1) + lower($2);' language sql +-- +FUNCTION: name="anycompatiblerange_anycompatiblemultirange_func" function="anycompatiblerange_anycompatiblemultirange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompa..." +== 569 +-- truncate_limit: 100 +select anycompatiblerange_anycompatiblemultirange_func(int4range(1,2), multirange(int4range(10,20))) +-- +FUNCTION: name="anycompatiblerange_anycompatiblemultirange_func" function="anycompatiblerange_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 570 +-- truncate_limit: 100 +-- should fail +select anycompatiblerange_anycompatiblemultirange_func(numrange(1,2), multirange(int4range(10,20))) +-- +FUNCTION: name="anycompatiblerange_anycompatiblemultirange_func" function="anycompatiblerange_anycompatiblemultirange_func" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 571 +-- truncate_limit: 100 +drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange, anycompatiblemultirange) +-- +FUNCTION: name="anycompatiblerange_anycompatiblemultirange_func" function="anycompatiblerange_anycompatiblemultirange_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange, anycompatiblemu..." +== 572 +-- truncate_limit: 100 +-- should fail +create function bogus_func(anycompatible) + returns anycompatiblerange as 'select int4range(1,10)' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bogus_func(anycompatible) RETURNS anycompatiblerange AS $$select int4range(1,10)$..." +== 573 +-- truncate_limit: 100 +|-- +-- Arrays of multiranges +|-- + +select ARRAY[nummultirange(numrange(1.1, 1.2)), nummultirange(numrange(12.3, 155.5))] +-- +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="nummultirange" function="nummultirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[nummultirange(numrange(1.1, 1.2)), nummultirange(numrange(12.3, 155.5))]" +== 574 +-- truncate_limit: 100 +create table i8mr_array (f1 int, f2 int8multirange[]) +-- +TABLE: name="i8mr_array" schema="" table="i8mr_array" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE i8mr_array (f1 int, f2 int8multirange[])" +== 575 +-- truncate_limit: 100 +insert into i8mr_array values (42, array[int8multirange(int8range(1,10)), int8multirange(int8range(2,20))]) +-- +TABLE: name="i8mr_array" schema="" table="i8mr_array" ctx=DML +FUNCTION: name="int8multirange" function="int8multirange" schema="" ctx=Call +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +FUNCTION: name="int8multirange" function="int8multirange" schema="" ctx=Call +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO i8mr_array VALUES (...)" +== 576 +-- truncate_limit: 100 +select * from i8mr_array +-- +TABLE: name="i8mr_array" schema="" table="i8mr_array" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM i8mr_array" +== 577 +-- truncate_limit: 100 +drop table i8mr_array +-- +TABLE: name="i8mr_array" schema="" table="i8mr_array" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE i8mr_array" +== 578 +-- truncate_limit: 100 +|-- +-- Multiranges of arrays +|-- + +select arraymultirange(arrayrange(ARRAY[1,2], ARRAY[2,1])) +-- +FUNCTION: name="arraymultirange" function="arraymultirange" schema="" ctx=Call +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT arraymultirange(arrayrange(ARRAY[1, 2], ARRAY[2, 1]))" +== 579 +-- truncate_limit: 100 +select arraymultirange(arrayrange(ARRAY[2,1], ARRAY[1,2])) +-- +FUNCTION: name="arraymultirange" function="arraymultirange" schema="" ctx=Call +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT arraymultirange(arrayrange(ARRAY[2, 1], ARRAY[1, 2]))" +== 580 +-- truncate_limit: 100 +-- fail + +select array[1,1] <@ arraymultirange(arrayrange(array[1,2], array[2,1])) +-- +FUNCTION: name="arraymultirange" function="arraymultirange" schema="" ctx=Call +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, 1] <@ arraymultirange(arrayrange(ARRAY[1, 2], ARRAY[2, 1]))" +== 581 +-- truncate_limit: 100 +select array[1,3] <@ arraymultirange(arrayrange(array[1,2], array[2,1])) +-- +FUNCTION: name="arraymultirange" function="arraymultirange" schema="" ctx=Call +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, 3] <@ arraymultirange(arrayrange(ARRAY[1, 2], ARRAY[2, 1]))" +== 582 +-- truncate_limit: 100 +|-- +-- Ranges of composites +|-- + +create type two_ints as (a int, b int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE two_ints AS (a int, b int)" +== 583 +-- truncate_limit: 100 +create type two_ints_range as range (subtype = two_ints) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE two_ints_range AS RANGE (subtype = two_ints)" +== 584 +-- truncate_limit: 100 +-- with debug_parallel_query on, this exercises tqueue.c's range remapping +select *, row_to_json(upper(t)) as u from + (values (two_ints_multirange(two_ints_range(row(1,2), row(3,4)))), + (two_ints_multirange(two_ints_range(row(5,6), row(7,8))))) v(t) +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="two_ints_multirange" function="two_ints_multirange" schema="" ctx=Call +FUNCTION: name="two_ints_range" function="two_ints_range" schema="" ctx=Call +FUNCTION: name="two_ints_multirange" function="two_ints_multirange" schema="" ctx=Call +FUNCTION: name="two_ints_range" function="two_ints_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, row_to_json(upper(t)) AS u FROM (VALUES (...)) v(t)" +== 585 +-- truncate_limit: 100 +drop type two_ints cascade +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE two_ints CASCADE" +== 586 +-- truncate_limit: 100 +|-- +-- Check behavior when subtype lacks a hash function +|-- + +set enable_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO OFF" +== 587 +-- truncate_limit: 100 +-- try to make it pick a hash setop implementation + +select '{(01,10)}'::varbitmultirange except select '{(10,11)}'::varbitmultirange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{(01,10)}'::varbitmultirange EXCEPT SELECT '{(10,11)}'::varbitmultirange" +== 588 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 589 +-- truncate_limit: 100 +|-- +-- OUT/INOUT/TABLE functions +|-- + +-- infer anymultirange from anymultirange +create function mr_outparam_succeed(i anymultirange, out r anymultirange, out t text) + as $$ select $1, 'foo'::text $$ language sql +-- +FUNCTION: name="mr_outparam_succeed" function="mr_outparam_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_outparam_succeed(i anymultirange, OUT r anymultirange, OUT t text) AS $$ selec..." +== 590 +-- truncate_limit: 100 +select * from mr_outparam_succeed(int4multirange(int4range(1,2))) +-- +FUNCTION: name="mr_outparam_succeed" function="mr_outparam_succeed" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mr_outparam_succeed(int4multirange(int4range(1, 2)))" +== 591 +-- truncate_limit: 100 +-- infer anyarray from anymultirange +create function mr_outparam_succeed2(i anymultirange, out r anyarray, out t text) + as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql +-- +FUNCTION: name="mr_outparam_succeed2" function="mr_outparam_succeed2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_outparam_succeed2(i anymultirange, OUT r anyarray, OUT t text) AS $$ select AR..." +== 592 +-- truncate_limit: 100 +select * from mr_outparam_succeed2(int4multirange(int4range(1,2))) +-- +FUNCTION: name="mr_outparam_succeed2" function="mr_outparam_succeed2" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mr_outparam_succeed2(int4multirange(int4range(1, 2)))" +== 593 +-- truncate_limit: 100 +-- infer anyrange from anymultirange +create function mr_outparam_succeed3(i anymultirange, out r anyrange, out t text) + as $$ select range_merge($1), 'foo'::text $$ language sql +-- +FUNCTION: name="mr_outparam_succeed3" function="mr_outparam_succeed3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_outparam_succeed3(i anymultirange, OUT r anyrange, OUT t text) AS $$ select ra..." +== 594 +-- truncate_limit: 100 +select * from mr_outparam_succeed3(int4multirange(int4range(1,2))) +-- +FUNCTION: name="mr_outparam_succeed3" function="mr_outparam_succeed3" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mr_outparam_succeed3(int4multirange(int4range(1, 2)))" +== 595 +-- truncate_limit: 100 +-- infer anymultirange from anyrange +create function mr_outparam_succeed4(i anyrange, out r anymultirange, out t text) + as $$ select multirange($1), 'foo'::text $$ language sql +-- +FUNCTION: name="mr_outparam_succeed4" function="mr_outparam_succeed4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_outparam_succeed4(i anyrange, OUT r anymultirange, OUT t text) AS $$ select mu..." +== 596 +-- truncate_limit: 100 +select * from mr_outparam_succeed4(int4range(1,2)) +-- +FUNCTION: name="mr_outparam_succeed4" function="mr_outparam_succeed4" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mr_outparam_succeed4(int4range(1, 2))" +== 597 +-- truncate_limit: 100 +-- infer anyelement from anymultirange +create function mr_inoutparam_succeed(out i anyelement, inout r anymultirange) + as $$ select upper($1), $1 $$ language sql +-- +FUNCTION: name="mr_inoutparam_succeed" function="mr_inoutparam_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_inoutparam_succeed(OUT i anyelement, INOUT r anymultirange) AS $$ select upper..." +== 598 +-- truncate_limit: 100 +select * from mr_inoutparam_succeed(int4multirange(int4range(1,2))) +-- +FUNCTION: name="mr_inoutparam_succeed" function="mr_inoutparam_succeed" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mr_inoutparam_succeed(int4multirange(int4range(1, 2)))" +== 599 +-- truncate_limit: 100 +-- infer anyelement+anymultirange from anyelement+anymultirange +create function mr_table_succeed(i anyelement, r anymultirange) returns table(i anyelement, r anymultirange) + as $$ select $1, $2 $$ language sql +-- +FUNCTION: name="mr_table_succeed" function="mr_table_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_table_succeed(i anyelement, r anymultirange) RETURNS TABLE (i anyelement, r an..." +== 600 +-- truncate_limit: 100 +select * from mr_table_succeed(123, int4multirange(int4range(1,11))) +-- +FUNCTION: name="mr_table_succeed" function="mr_table_succeed" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM mr_table_succeed(123, int4multirange(int4range(1, 11)))" +== 601 +-- truncate_limit: 100 +-- use anymultirange in plpgsql +create function mr_polymorphic(i anyrange) returns anymultirange + as $$ begin return multirange($1); end; $$ language plpgsql +-- +FUNCTION: name="mr_polymorphic" function="mr_polymorphic" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_polymorphic(i anyrange) RETURNS anymultirange AS $$ begin return multirange($1..." +== 602 +-- truncate_limit: 100 +select mr_polymorphic(int4range(1, 4)) +-- +FUNCTION: name="mr_polymorphic" function="mr_polymorphic" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mr_polymorphic(int4range(1, 4))" +== 603 +-- truncate_limit: 100 +-- should fail +create function mr_outparam_fail(i anyelement, out r anymultirange, out t text) + as $$ select '[1,10]', 'foo' $$ language sql +-- +FUNCTION: name="mr_outparam_fail" function="mr_outparam_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_outparam_fail(i anyelement, OUT r anymultirange, OUT t text) AS $$ select '[1,..." +== 604 +-- truncate_limit: 100 +--should fail +create function mr_inoutparam_fail(inout i anyelement, out r anymultirange) + as $$ select $1, '[1,10]' $$ language sql +-- +FUNCTION: name="mr_inoutparam_fail" function="mr_inoutparam_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_inoutparam_fail(INOUT i anyelement, OUT r anymultirange) AS $$ select $1, '[1,..." +== 605 +-- truncate_limit: 100 +--should fail +create function mr_table_fail(i anyelement) returns table(i anyelement, r anymultirange) + as $$ select $1, '[1,10]' $$ language sql +-- +FUNCTION: name="mr_table_fail" function="mr_table_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mr_table_fail(i anyelement) RETURNS TABLE (i anyelement, r anymultirange) AS $$ s..." diff --git a/parser/testdata/summary_truncate/postgres_regress/mvcc.metadata.json b/parser/testdata/summary_truncate/postgres_regress/mvcc.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/mvcc.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/mvcc.test b/parser/testdata/summary_truncate/postgres_regress/mvcc.test new file mode 100644 index 0000000..600c577 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/mvcc.test @@ -0,0 +1,100 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Verify that index scans encountering dead rows produced by an +-- aborted subtransaction of the current transaction can utilize the +-- kill_prior_tuple optimization +|-- +-- NB: The table size is currently *not* expected to stay the same, we +-- don't have logic to trigger opportunistic pruning in cases like +-- this. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 002 +-- truncate_limit: 100 +SET LOCAL enable_seqscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO FALSE" +== 003 +-- truncate_limit: 100 +SET LOCAL enable_indexonlyscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexonlyscan TO FALSE" +== 004 +-- truncate_limit: 100 +SET LOCAL enable_bitmapscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_bitmapscan TO FALSE" +== 005 +-- truncate_limit: 100 +-- Can't easily use a unique index, since dead tuples can be found +-- independent of the kill_prior_tuples optimization. +CREATE TABLE clean_aborted_self(key int, data text) +-- +TABLE: name="clean_aborted_self" schema="" table="clean_aborted_self" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE clean_aborted_self (key int, data text)" +== 006 +-- truncate_limit: 100 +CREATE INDEX clean_aborted_self_key ON clean_aborted_self(key) +-- +TABLE: name="clean_aborted_self" schema="" table="clean_aborted_self" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX clean_aborted_self_key ON clean_aborted_self USING btree (key)" +== 007 +-- truncate_limit: 100 +INSERT INTO clean_aborted_self (key, data) VALUES (-1, 'just to allocate metapage') +-- +TABLE: name="clean_aborted_self" schema="" table="clean_aborted_self" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO clean_aborted_self (key, data) VALUES (-1, 'just to allocate metapage')" +== 008 +-- truncate_limit: 100 +-- save index size from before the changes, for comparison +SELECT pg_relation_size('clean_aborted_self_key') AS clean_aborted_self_key_before +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_relation_size('clean_aborted_self_key') AS clean_aborted_self_key_before" +== 009 +-- truncate_limit: 100 +DO $$ +BEGIN + -- iterate often enough to see index growth even on larger-than-default page sizes + FOR i IN 1..100 LOOP + BEGIN + -- perform index scan over all the inserted keys to get them to be seen as dead + IF EXISTS(SELECT * FROM clean_aborted_self WHERE key > 0 AND key < 100) THEN + RAISE data_corrupted USING MESSAGE = 'these rows should not exist'; + END IF; + INSERT INTO clean_aborted_self SELECT g.i, 'rolling back in a sec' FROM generate_series(1, 100) g(i); + -- just some error that's not normally thrown + RAISE reading_sql_data_not_permitted USING MESSAGE = 'round and round again'; + EXCEPTION WHEN reading_sql_data_not_permitted THEN END; + END LOOP; +END;$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n -- iterate often enough to see index growth even on larger-than-default page size..." +== 010 +-- truncate_limit: 100 +-- show sizes only if they differ +SELECT :clean_aborted_self_key_before AS size_before, pg_relation_size('clean_aborted_self_key') size_after +WHERE :clean_aborted_self_key_before != pg_relation_size('clean_aborted_self_key') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 42 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 011 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" diff --git a/parser/testdata/summary_truncate/postgres_regress/name.metadata.json b/parser/testdata/summary_truncate/postgres_regress/name.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/name.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/name.test b/parser/testdata/summary_truncate/postgres_regress/name.test new file mode 100644 index 0000000..2caa6bc --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/name.test @@ -0,0 +1,330 @@ +== 001 +-- truncate_limit: 100 +|-- +-- NAME +-- all inputs are silently truncated at NAMEDATALEN-1 (63) characters +|-- + +-- fixed-length by reference +SELECT name 'name string' = name 'name string' AS "True" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'name string'::name = 'name string'::name AS \"True\"" +== 002 +-- truncate_limit: 100 +SELECT name 'name string' = name 'name string ' AS "False" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'name string'::name = 'name string '::name AS \"False\"" +== 003 +-- truncate_limit: 100 +|-- +|-- +|-- + +CREATE TABLE NAME_TBL(f1 name) +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE name_tbl (f1 name)" +== 004 +-- truncate_limit: 100 +INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO name_tbl (f1) VALUES (...)" +== 005 +-- truncate_limit: 100 +INSERT INTO NAME_TBL(f1) VALUES ('1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqr') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO name_tbl (f1) VALUES (...)" +== 006 +-- truncate_limit: 100 +INSERT INTO NAME_TBL(f1) VALUES ('asdfghjkl;') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO name_tbl (f1) VALUES ('asdfghjkl;')" +== 007 +-- truncate_limit: 100 +INSERT INTO NAME_TBL(f1) VALUES ('343f%2a') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO name_tbl (f1) VALUES ('343f%2a')" +== 008 +-- truncate_limit: 100 +INSERT INTO NAME_TBL(f1) VALUES ('d34aaasdf') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO name_tbl (f1) VALUES ('d34aaasdf')" +== 009 +-- truncate_limit: 100 +INSERT INTO NAME_TBL(f1) VALUES ('') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO name_tbl (f1) VALUES ('')" +== 010 +-- truncate_limit: 100 +INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ') +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO name_tbl (f1) VALUES (...)" +== 011 +-- truncate_limit: 100 +SELECT * FROM NAME_TBL +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM name_tbl" +== 012 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 <> '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE ..." +== 013 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE ..." +== 014 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 < '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE ..." +== 015 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 <= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE ..." +== 016 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 > '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE ..." +== 017 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 >= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE ..." +== 018 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE c.f1 ~ '.*'" +== 019 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 !~ '.*' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE c.f1 !~ '.*'" +== 020 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '[0-9]' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE c.f1 ~ '[0-9]'" +== 021 +-- truncate_limit: 100 +SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*asdf.*' +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=Select +ALIAS: "c"="name_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.f1 FROM name_tbl c WHERE c.f1 ~ '.*asdf.*'" +== 022 +-- truncate_limit: 100 +DROP TABLE NAME_TBL +-- +TABLE: name="name_tbl" schema="" table="name_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE name_tbl" +== 023 +-- truncate_limit: 100 +DO $$ +DECLARE r text[]; +BEGIN + r := parse_ident('Schemax.Tabley'); + RAISE NOTICE '%', format('%I.%I', r[1], r[2]); + r := parse_ident('"SchemaX"."TableY"'); + RAISE NOTICE '%', format('%I.%I', r[1], r[2]); +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE r text[];\nBEGIN\n r := parse_ident('Schemax.Tabley');\n RAISE NOTICE '%', format('%..." +== 024 +-- truncate_limit: 100 +SELECT parse_ident('foo.boo') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('foo.boo')" +== 025 +-- truncate_limit: 100 +SELECT parse_ident('foo.boo[]') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('foo.boo[]')" +== 026 +-- truncate_limit: 100 +-- should fail +SELECT parse_ident('foo.boo[]', strict => false) +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('foo.boo[]', strict := false)" +== 027 +-- truncate_limit: 100 +-- ok + +-- should fail +SELECT parse_ident(' ') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident(' ')" +== 028 +-- truncate_limit: 100 +SELECT parse_ident(' .aaa') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident(' .aaa')" +== 029 +-- truncate_limit: 100 +SELECT parse_ident(' aaa . ') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident(' aaa . ')" +== 030 +-- truncate_limit: 100 +SELECT parse_ident('aaa.a%b') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('aaa.a%b')" +== 031 +-- truncate_limit: 100 +SELECT parse_ident(E'X\rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('X\rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')" +== 032 +-- truncate_limit: 100 +SELECT length(a[1]), length(a[2]) from parse_ident('"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy') as a +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM parse_ident('\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..." +== 033 +-- truncate_limit: 100 +SELECT parse_ident(' first . " second " ." third ". " ' || repeat('x',66) || '"') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident((' first . \" second \" .\" third \". \" ' || repeat('x', 66)) || '\"')" +== 034 +-- truncate_limit: 100 +SELECT parse_ident(' first . " second " ." third ". " ' || repeat('x',66) || '"')::name[] +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident((' first . \" second \" .\" third \". \" ' || repeat('x', 66)) || '\"')::name[]" +== 035 +-- truncate_limit: 100 +SELECT parse_ident(E'"c".X XXXX\002XXXXXX') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('\"c\".X XXXX\x02XXXXXX')" +== 036 +-- truncate_limit: 100 +SELECT parse_ident('1020') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('1020')" +== 037 +-- truncate_limit: 100 +SELECT parse_ident('10.20') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('10.20')" +== 038 +-- truncate_limit: 100 +SELECT parse_ident('.') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('.')" +== 039 +-- truncate_limit: 100 +SELECT parse_ident('.1020') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('.1020')" +== 040 +-- truncate_limit: 100 +SELECT parse_ident('xxx.1020') +-- +FUNCTION: name="parse_ident" function="parse_ident" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT parse_ident('xxx.1020')" diff --git a/parser/testdata/summary_truncate/postgres_regress/namespace.metadata.json b/parser/testdata/summary_truncate/postgres_regress/namespace.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/namespace.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/namespace.test b/parser/testdata/summary_truncate/postgres_regress/namespace.test new file mode 100644 index 0000000..aa02241 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/namespace.test @@ -0,0 +1,332 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Regression tests for schemas (namespaces) +|-- + +-- set the whitespace-only search_path to test that the +-- GUC list syntax is preserved during a schema creation +SELECT pg_catalog.set_config('search_path', ' ', false) +-- +FUNCTION: name="pg_catalog.set_config" function="set_config" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.set_config('search_path', ' ', false)" +== 002 +-- truncate_limit: 100 +CREATE SCHEMA test_ns_schema_1 + CREATE UNIQUE INDEX abc_a_idx ON abc (a) + + CREATE VIEW abc_view AS + SELECT a+1 AS a, b+1 AS b FROM abc + + CREATE TABLE abc ( + a serial, + b int UNIQUE + ) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_ns_schema_1 CREATE UNIQUE INDEX abc_a_idx ON abc USING btree (a) CREATE VIEW a..." +== 003 +-- truncate_limit: 100 +-- verify that the correct search_path restored on abort +SET search_path to public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO public" +== 004 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 005 +-- truncate_limit: 100 +SET search_path to public, test_ns_schema_1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO public, test_ns_schema_1" +== 006 +-- truncate_limit: 100 +CREATE SCHEMA test_ns_schema_2 + CREATE VIEW abc_view AS SELECT c FROM abc +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_ns_schema_2 CREATE VIEW abc_view AS SELECT c FROM abc" +== 007 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 008 +-- truncate_limit: 100 +SHOW search_path +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW search_path" +== 009 +-- truncate_limit: 100 +-- verify that the correct search_path preserved +-- after creating the schema and on commit +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 010 +-- truncate_limit: 100 +SET search_path to public, test_ns_schema_1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO public, test_ns_schema_1" +== 011 +-- truncate_limit: 100 +CREATE SCHEMA test_ns_schema_2 + CREATE VIEW abc_view AS SELECT a FROM abc +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_ns_schema_2 CREATE VIEW abc_view AS SELECT a FROM abc" +== 012 +-- truncate_limit: 100 +SHOW search_path +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW search_path" +== 013 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 014 +-- truncate_limit: 100 +SHOW search_path +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW search_path" +== 015 +-- truncate_limit: 100 +DROP SCHEMA test_ns_schema_2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA test_ns_schema_2 CASCADE" +== 016 +-- truncate_limit: 100 +-- verify that the objects were created +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_1') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_class WHERE relnamespace = (SELECT oid FROM pg_namespace WHERE ...)" +== 017 +-- truncate_limit: 100 +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES +-- +TABLE: name="test_ns_schema_1.abc" schema="test_ns_schema_1" table="abc" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO test_ns_schema_1.abc DEFAULT VALUES" +== 018 +-- truncate_limit: 100 +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES +-- +TABLE: name="test_ns_schema_1.abc" schema="test_ns_schema_1" table="abc" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO test_ns_schema_1.abc DEFAULT VALUES" +== 019 +-- truncate_limit: 100 +INSERT INTO test_ns_schema_1.abc DEFAULT VALUES +-- +TABLE: name="test_ns_schema_1.abc" schema="test_ns_schema_1" table="abc" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO test_ns_schema_1.abc DEFAULT VALUES" +== 020 +-- truncate_limit: 100 +SELECT * FROM test_ns_schema_1.abc +-- +TABLE: name="test_ns_schema_1.abc" schema="test_ns_schema_1" table="abc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_ns_schema_1.abc" +== 021 +-- truncate_limit: 100 +SELECT * FROM test_ns_schema_1.abc_view +-- +TABLE: name="test_ns_schema_1.abc_view" schema="test_ns_schema_1" table="abc_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_ns_schema_1.abc_view" +== 022 +-- truncate_limit: 100 +ALTER SCHEMA test_ns_schema_1 RENAME TO test_ns_schema_renamed +-- +STMT: RenameStmt +TRUNCATED: "ALTER SCHEMA test_ns_schema_1 RENAME TO test_ns_schema_renamed" +== 023 +-- truncate_limit: 100 +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_1') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_class WHERE relnamespace = (SELECT oid FROM pg_namespace WHERE ...)" +== 024 +-- truncate_limit: 100 +-- test IF NOT EXISTS cases +CREATE SCHEMA test_ns_schema_renamed +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_ns_schema_renamed" +== 025 +-- truncate_limit: 100 +-- fail, already exists +CREATE SCHEMA IF NOT EXISTS test_ns_schema_renamed +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA IF NOT EXISTS test_ns_schema_renamed" +== 026 +-- truncate_limit: 100 +-- ok with notice +CREATE SCHEMA IF NOT EXISTS test_ns_schema_renamed -- fail, disallowed + CREATE TABLE abc ( + a serial, + b int UNIQUE + ) +-- +ERROR: CREATE SCHEMA IF NOT EXISTS cannot include schema elements +CURSORPOS: 97 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 027 +-- truncate_limit: 100 +DROP SCHEMA test_ns_schema_renamed CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA test_ns_schema_renamed CASCADE" +== 028 +-- truncate_limit: 100 +-- verify that the objects were dropped +SELECT COUNT(*) FROM pg_class WHERE relnamespace = + (SELECT oid FROM pg_namespace WHERE nspname = 'test_ns_schema_renamed') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relnamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_class WHERE relnamespace = (SELECT oid FROM pg_namespace WHERE ...)" +== 029 +-- truncate_limit: 100 +|-- +-- Verify that search_path is set to a safe value during maintenance +-- commands. +|-- + +CREATE SCHEMA test_maint_search_path +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA test_maint_search_path" +== 030 +-- truncate_limit: 100 +SET search_path = test_maint_search_path +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO test_maint_search_path" +== 031 +-- truncate_limit: 100 +CREATE FUNCTION fn(INT) RETURNS INT IMMUTABLE LANGUAGE plpgsql AS $$ + BEGIN + RAISE NOTICE 'current search_path: %', current_setting('search_path'); + RETURN $1; + END; +$$ +-- +FUNCTION: name="fn" function="fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fn(int) RETURNS int IMMUTABLE LANGUAGE plpgsql AS $$\n BEGIN\n RAISE NOTICE 'cu..." +== 032 +-- truncate_limit: 100 +CREATE TABLE test_maint(i INT) +-- +TABLE: name="test_maint" schema="" table="test_maint" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_maint (i int)" +== 033 +-- truncate_limit: 100 +INSERT INTO test_maint VALUES (1), (2) +-- +TABLE: name="test_maint" schema="" table="test_maint" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_maint VALUES (1), (2)" +== 034 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW test_maint_mv AS SELECT fn(i) FROM test_maint +-- +TABLE: name="test_maint_mv" schema="" table="test_maint_mv" ctx=DDL +TABLE: name="test_maint" schema="" table="test_maint" ctx=Select +FUNCTION: name="fn" function="fn" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW test_maint_mv AS SELECT fn(i) FROM test_maint" +== 035 +-- truncate_limit: 100 +-- the following commands should see search_path as pg_catalog, pg_temp + +CREATE INDEX test_maint_idx ON test_maint_search_path.test_maint (fn(i)) +-- +TABLE: name="test_maint_search_path.test_maint" schema="test_maint_search_path" table="test_maint" ctx=DDL +FUNCTION: name="fn" function="fn" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_maint_idx ON test_maint_search_path.test_maint USING btree (fn(i))" +== 036 +-- truncate_limit: 100 +REINDEX TABLE test_maint_search_path.test_maint +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX TABLE test_maint_search_path.test_maint" +== 037 +-- truncate_limit: 100 +ANALYZE test_maint_search_path.test_maint +-- +TABLE: name="test_maint_search_path.test_maint" schema="test_maint_search_path" table="test_maint" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE test_maint_search_path.test_maint" +== 038 +-- truncate_limit: 100 +VACUUM FULL test_maint_search_path.test_maint +-- +TABLE: name="test_maint_search_path.test_maint" schema="test_maint_search_path" table="test_maint" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) test_maint_search_path.test_maint" +== 039 +-- truncate_limit: 100 +CLUSTER test_maint_search_path.test_maint USING test_maint_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER test_maint_search_path.test_maint USING test_maint_idx" +== 040 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW test_maint_search_path.test_maint_mv +-- +TABLE: name="test_maint_search_path.test_maint_mv" schema="test_maint_search_path" table="test_maint_mv" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW test_maint_search_path.test_maint_mv" +== 041 +-- truncate_limit: 100 +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 042 +-- truncate_limit: 100 +DROP SCHEMA test_maint_search_path CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA test_maint_search_path CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/numeric.metadata.json b/parser/testdata/summary_truncate/postgres_regress/numeric.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/numeric.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/numeric.test b/parser/testdata/summary_truncate/postgres_regress/numeric.test new file mode 100644 index 0000000..21f629a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/numeric.test @@ -0,0 +1,8275 @@ +== 001 +-- truncate_limit: 100 +|-- +-- NUMERIC +|-- + +CREATE TABLE num_data (id int4, val numeric(210,10)) +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_data (id int4, val numeric(210, 10))" +== 002 +-- truncate_limit: 100 +CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(210, 10))" +== 003 +-- truncate_limit: 100 +CREATE TABLE num_exp_sub (id1 int4, id2 int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_sub (id1 int4, id2 int4, expected numeric(210, 10))" +== 004 +-- truncate_limit: 100 +CREATE TABLE num_exp_div (id1 int4, id2 int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_div (id1 int4, id2 int4, expected numeric(210, 10))" +== 005 +-- truncate_limit: 100 +CREATE TABLE num_exp_mul (id1 int4, id2 int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_mul (id1 int4, id2 int4, expected numeric(210, 10))" +== 006 +-- truncate_limit: 100 +CREATE TABLE num_exp_sqrt (id int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_sqrt (id int4, expected numeric(210, 10))" +== 007 +-- truncate_limit: 100 +CREATE TABLE num_exp_ln (id int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_ln (id int4, expected numeric(210, 10))" +== 008 +-- truncate_limit: 100 +CREATE TABLE num_exp_log10 (id int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_log10 (id int4, expected numeric(210, 10))" +== 009 +-- truncate_limit: 100 +CREATE TABLE num_exp_power_10_ln (id int4, expected numeric(210,10)) +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_power_10_ln (id int4, expected numeric(210, 10))" +== 010 +-- truncate_limit: 100 +CREATE TABLE num_result (id1 int4, id2 int4, result numeric(210,10)) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_result (id1 int4, id2 int4, result numeric(210, 10))" +== 011 +-- truncate_limit: 100 +-- ****************************** +-- * The following EXPECTED results are computed by bc(1) +-- * with a scale of 200 +-- ****************************** + +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 012 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,0,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 0, '0')" +== 013 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,0,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 0, '0')" +== 014 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 0, '0')" +== 015 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 0, 'NaN')" +== 016 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,1,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 1, '0')" +== 017 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,1,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 1, '0')" +== 018 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 1, '0')" +== 019 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 1, 'NaN')" +== 020 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,2,'-34338492.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 2, '-34338492.215397047')" +== 021 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,2,'34338492.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 2, '34338492.215397047')" +== 022 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,2,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 2, '0')" +== 023 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,2,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 2, '0')" +== 024 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,3,'4.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 3, '4.31')" +== 025 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,3,'-4.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 3, '-4.31')" +== 026 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,3,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 3, '0')" +== 027 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,3,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 3, '0')" +== 028 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,4,'7799461.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 4, '7799461.4119')" +== 029 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,4,'-7799461.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 4, '-7799461.4119')" +== 030 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,4,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 4, '0')" +== 031 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,4,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 4, '0')" +== 032 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,5,'16397.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 5, '16397.038491')" +== 033 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,5,'-16397.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 5, '-16397.038491')" +== 034 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,5,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 5, '0')" +== 035 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,5,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 5, '0')" +== 036 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,6,'93901.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 6, '93901.57763026')" +== 037 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,6,'-93901.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 6, '-93901.57763026')" +== 038 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,6,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 6, '0')" +== 039 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,6,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 6, '0')" +== 040 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,7,'-83028485') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 7, '-83028485')" +== 041 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,7,'83028485') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 7, '83028485')" +== 042 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,7,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 7, '0')" +== 043 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,7,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 7, '0')" +== 044 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,8,'74881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 8, '74881')" +== 045 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,8,'-74881') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 8, '-74881')" +== 046 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,8,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 8, '0')" +== 047 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,8,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 8, '0')" +== 048 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,9,'-24926804.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 9, '-24926804.045047420')" +== 049 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,9,'24926804.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 9, '24926804.045047420')" +== 050 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,9,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 9, '0')" +== 051 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,9,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 9, '0')" +== 052 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,0,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 0, '0')" +== 053 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,0,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 0, '0')" +== 054 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 0, '0')" +== 055 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 0, 'NaN')" +== 056 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,1,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 1, '0')" +== 057 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,1,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 1, '0')" +== 058 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 1, '0')" +== 059 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 1, 'NaN')" +== 060 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,2,'-34338492.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 2, '-34338492.215397047')" +== 061 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,2,'34338492.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 2, '34338492.215397047')" +== 062 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,2,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 2, '0')" +== 063 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,2,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 2, '0')" +== 064 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,3,'4.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 3, '4.31')" +== 065 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,3,'-4.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 3, '-4.31')" +== 066 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,3,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 3, '0')" +== 067 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,3,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 3, '0')" +== 068 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,4,'7799461.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 4, '7799461.4119')" +== 069 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,4,'-7799461.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 4, '-7799461.4119')" +== 070 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,4,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 4, '0')" +== 071 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,4,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 4, '0')" +== 072 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,5,'16397.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 5, '16397.038491')" +== 073 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,5,'-16397.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 5, '-16397.038491')" +== 074 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,5,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 5, '0')" +== 075 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,5,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 5, '0')" +== 076 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,6,'93901.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 6, '93901.57763026')" +== 077 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,6,'-93901.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 6, '-93901.57763026')" +== 078 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,6,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 6, '0')" +== 079 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,6,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 6, '0')" +== 080 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,7,'-83028485') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 7, '-83028485')" +== 081 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,7,'83028485') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 7, '83028485')" +== 082 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,7,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 7, '0')" +== 083 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,7,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 7, '0')" +== 084 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,8,'74881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 8, '74881')" +== 085 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,8,'-74881') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 8, '-74881')" +== 086 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,8,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 8, '0')" +== 087 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,8,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 8, '0')" +== 088 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,9,'-24926804.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (1, 9, '-24926804.045047420')" +== 089 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,9,'24926804.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 9, '24926804.045047420')" +== 090 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,9,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 9, '0')" +== 091 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,9,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 9, '0')" +== 092 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,0,'-34338492.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 0, '-34338492.215397047')" +== 093 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,0,'-34338492.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 0, '-34338492.215397047')" +== 094 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 0, '0')" +== 095 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 0, 'NaN')" +== 096 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,1,'-34338492.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 1, '-34338492.215397047')" +== 097 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,1,'-34338492.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 1, '-34338492.215397047')" +== 098 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 1, '0')" +== 099 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 1, 'NaN')" +== 100 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,2,'-68676984.430794094') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 2, '-68676984.430794094')" +== 101 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,2,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 2, '0')" +== 102 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,2,'1179132047626883.596862135856320209') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 2, '1179132047626883.596862135856320209')" +== 103 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,2,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 2, '1.00000000000000000000')" +== 104 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,3,'-34338487.905397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 3, '-34338487.905397047')" +== 105 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,3,'-34338496.525397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 3, '-34338496.525397047')" +== 106 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,3,'-147998901.44836127257') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 3, '-147998901.44836127257')" +== 107 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,3,'-7967167.56737750510440835266') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 3, '-7967167.56737750510440835266')" +== 108 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,4,'-26539030.803497047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 4, '-26539030.803497047')" +== 109 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,4,'-42137953.627297047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 4, '-42137953.627297047')" +== 110 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,4,'-267821744976817.8111137106593') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 4, '-267821744976817.8111137106593')" +== 111 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,4,'-4.40267480046830116685') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 4, '-4.40267480046830116685')" +== 112 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,5,'-34322095.176906047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 5, '-34322095.176906047')" +== 113 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,5,'-34354889.253888047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 5, '-34354889.253888047')" +== 114 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,5,'-563049578578.769242506736077') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 5, '-563049578578.769242506736077')" +== 115 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,5,'-2094.18866914563535496429') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 5, '-2094.18866914563535496429')" +== 116 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,6,'-34244590.637766787') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 6, '-34244590.637766787')" +== 117 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,6,'-34432393.793027307') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 6, '-34432393.793027307')" +== 118 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,6,'-3224438592470.18449811926184222') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 6, '-3224438592470.18449811926184222')" +== 119 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,6,'-365.68599891479766440940') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 6, '-365.68599891479766440940')" +== 120 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,7,'-117366977.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 7, '-117366977.215397047')" +== 121 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,7,'48689992.784602953') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 7, '48689992.784602953')" +== 122 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,7,'2851072985828710.485883795') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 7, '2851072985828710.485883795')" +== 123 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,7,'.41357483778485235518') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 7, '.41357483778485235518')" +== 124 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,8,'-34263611.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 8, '-34263611.215397047')" +== 125 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,8,'-34413373.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 8, '-34413373.215397047')" +== 126 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,8,'-2571300635581.146276407') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 8, '-2571300635581.146276407')" +== 127 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,8,'-458.57416721727870888476') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 8, '-458.57416721727870888476')" +== 128 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,9,'-59265296.260444467') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (2, 9, '-59265296.260444467')" +== 129 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,9,'-9411688.170349627') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 9, '-9411688.170349627')" +== 130 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,9,'855948866655588.453741509242968740') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 9, '855948866655588.453741509242968740')" +== 131 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,9,'1.37757299946438931811') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 9, '1.37757299946438931811')" +== 132 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,0,'4.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 0, '4.31')" +== 133 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,0,'4.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 0, '4.31')" +== 134 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 0, '0')" +== 135 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 0, 'NaN')" +== 136 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,1,'4.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 1, '4.31')" +== 137 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,1,'4.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 1, '4.31')" +== 138 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 1, '0')" +== 139 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 1, 'NaN')" +== 140 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,2,'-34338487.905397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 2, '-34338487.905397047')" +== 141 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,2,'34338496.525397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 2, '34338496.525397047')" +== 142 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,2,'-147998901.44836127257') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 2, '-147998901.44836127257')" +== 143 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,2,'-.00000012551512084352') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 2, '-.00000012551512084352')" +== 144 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,3,'8.62') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 3, '8.62')" +== 145 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,3,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 3, '0')" +== 146 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,3,'18.5761') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 3, '18.5761')" +== 147 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,3,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 3, '1.00000000000000000000')" +== 148 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,4,'7799465.7219') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 4, '7799465.7219')" +== 149 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,4,'-7799457.1019') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 4, '-7799457.1019')" +== 150 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,4,'33615678.685289') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 4, '33615678.685289')" +== 151 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,4,'.00000055260225961552') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 4, '.00000055260225961552')" +== 152 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,5,'16401.348491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 5, '16401.348491')" +== 153 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,5,'-16392.728491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 5, '-16392.728491')" +== 154 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,5,'70671.23589621') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 5, '70671.23589621')" +== 155 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,5,'.00026285234387695504') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 5, '.00026285234387695504')" +== 156 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,6,'93905.88763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 6, '93905.88763026')" +== 157 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,6,'-93897.26763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 6, '-93897.26763026')" +== 158 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,6,'404715.7995864206') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 6, '404715.7995864206')" +== 159 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,6,'.00004589912234457595') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 6, '.00004589912234457595')" +== 160 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,7,'-83028480.69') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 7, '-83028480.69')" +== 161 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,7,'83028489.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 7, '83028489.31')" +== 162 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,7,'-357852770.35') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 7, '-357852770.35')" +== 163 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,7,'-.00000005190989574240') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 7, '-.00000005190989574240')" +== 164 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,8,'74885.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 8, '74885.31')" +== 165 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,8,'-74876.69') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 8, '-74876.69')" +== 166 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,8,'322737.11') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 8, '322737.11')" +== 167 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,8,'.00005755799201399553') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 8, '.00005755799201399553')" +== 168 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,9,'-24926799.735047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (3, 9, '-24926799.735047420')" +== 169 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,9,'24926808.355047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 9, '24926808.355047420')" +== 170 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,9,'-107434525.43415438020') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 9, '-107434525.43415438020')" +== 171 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,9,'-.00000017290624149854') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 9, '-.00000017290624149854')" +== 172 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,0,'7799461.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 0, '7799461.4119')" +== 173 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,0,'7799461.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 0, '7799461.4119')" +== 174 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 0, '0')" +== 175 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 0, 'NaN')" +== 176 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,1,'7799461.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 1, '7799461.4119')" +== 177 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,1,'7799461.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 1, '7799461.4119')" +== 178 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 1, '0')" +== 179 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 1, 'NaN')" +== 180 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,2,'-26539030.803497047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 2, '-26539030.803497047')" +== 181 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,2,'42137953.627297047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 2, '42137953.627297047')" +== 182 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,2,'-267821744976817.8111137106593') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 2, '-267821744976817.8111137106593')" +== 183 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,2,'-.22713465002993920385') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 2, '-.22713465002993920385')" +== 184 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,3,'7799465.7219') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 3, '7799465.7219')" +== 185 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,3,'7799457.1019') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 3, '7799457.1019')" +== 186 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,3,'33615678.685289') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 3, '33615678.685289')" +== 187 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,3,'1809619.81714617169373549883') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 3, '1809619.81714617169373549883')" +== 188 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,4,'15598922.8238') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 4, '15598922.8238')" +== 189 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,4,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 4, '0')" +== 190 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,4,'60831598315717.14146161') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 4, '60831598315717.14146161')" +== 191 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,4,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 4, '1.00000000000000000000')" +== 192 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,5,'7815858.450391') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 5, '7815858.450391')" +== 193 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,5,'7783064.373409') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 5, '7783064.373409')" +== 194 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,5,'127888068979.9935054429') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 5, '127888068979.9935054429')" +== 195 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,5,'475.66281046305802686061') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 5, '475.66281046305802686061')" +== 196 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,6,'7893362.98953026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 6, '7893362.98953026')" +== 197 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,6,'7705559.83426974') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 6, '7705559.83426974')" +== 198 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,6,'732381731243.745115764094') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 6, '732381731243.745115764094')" +== 199 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,6,'83.05996138436129499606') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 6, '83.05996138436129499606')" +== 200 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,7,'-75229023.5881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 7, '-75229023.5881')" +== 201 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,7,'90827946.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 7, '90827946.4119')" +== 202 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,7,'-647577464846017.9715') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 7, '-647577464846017.9715')" +== 203 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,7,'-.09393717604145131637') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 7, '-.09393717604145131637')" +== 204 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,8,'7874342.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 8, '7874342.4119')" +== 205 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,8,'7724580.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 8, '7724580.4119')" +== 206 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,8,'584031469984.4839') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 8, '584031469984.4839')" +== 207 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,8,'104.15808298366741897143') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 8, '104.15808298366741897143')" +== 208 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,9,'-17127342.633147420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (4, 9, '-17127342.633147420')" +== 209 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,9,'32726265.456947420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 9, '32726265.456947420')" +== 210 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,9,'-194415646271340.1815956522980') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 9, '-194415646271340.1815956522980')" +== 211 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,9,'-.31289456112403769409') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 9, '-.31289456112403769409')" +== 212 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,0,'16397.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 0, '16397.038491')" +== 213 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,0,'16397.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 0, '16397.038491')" +== 214 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 0, '0')" +== 215 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 0, 'NaN')" +== 216 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,1,'16397.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 1, '16397.038491')" +== 217 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,1,'16397.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 1, '16397.038491')" +== 218 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 1, '0')" +== 219 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 1, 'NaN')" +== 220 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,2,'-34322095.176906047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 2, '-34322095.176906047')" +== 221 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,2,'34354889.253888047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 2, '34354889.253888047')" +== 222 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,2,'-563049578578.769242506736077') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 2, '-563049578578.769242506736077')" +== 223 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,2,'-.00047751189505192446') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 2, '-.00047751189505192446')" +== 224 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,3,'16401.348491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 3, '16401.348491')" +== 225 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,3,'16392.728491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 3, '16392.728491')" +== 226 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,3,'70671.23589621') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 3, '70671.23589621')" +== 227 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,3,'3804.41728329466357308584') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 3, '3804.41728329466357308584')" +== 228 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,4,'7815858.450391') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 4, '7815858.450391')" +== 229 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,4,'-7783064.373409') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 4, '-7783064.373409')" +== 230 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,4,'127888068979.9935054429') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 4, '127888068979.9935054429')" +== 231 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,4,'.00210232958726897192') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 4, '.00210232958726897192')" +== 232 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,5,'32794.076982') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 5, '32794.076982')" +== 233 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,5,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 5, '0')" +== 234 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,5,'268862871.275335557081') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 5, '268862871.275335557081')" +== 235 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,5,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 5, '1.00000000000000000000')" +== 236 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,6,'110298.61612126') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 6, '110298.61612126')" +== 237 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,6,'-77504.53913926') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 6, '-77504.53913926')" +== 238 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,6,'1539707782.76899778633766') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 6, '1539707782.76899778633766')" +== 239 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,6,'.17461941433576102689') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 6, '.17461941433576102689')" +== 240 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,7,'-83012087.961509') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 7, '-83012087.961509')" +== 241 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,7,'83044882.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 7, '83044882.038491')" +== 242 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,7,'-1361421264394.416135') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 7, '-1361421264394.416135')" +== 243 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,7,'-.00019748690453643710') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 7, '-.00019748690453643710')" +== 244 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,8,'91278.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 8, '91278.038491')" +== 245 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,8,'-58483.961509') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 8, '-58483.961509')" +== 246 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,8,'1227826639.244571') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 8, '1227826639.244571')" +== 247 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,8,'.21897461960978085228') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 8, '.21897461960978085228')" +== 248 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,9,'-24910407.006556420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (5, 9, '-24910407.006556420')" +== 249 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,9,'24943201.083538420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 9, '24943201.083538420')" +== 250 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,9,'-408725765384.257043660243220') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 9, '-408725765384.257043660243220')" +== 251 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,9,'-.00065780749354660427') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 9, '-.00065780749354660427')" +== 252 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,0,'93901.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 0, '93901.57763026')" +== 253 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,0,'93901.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 0, '93901.57763026')" +== 254 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 0, '0')" +== 255 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 0, 'NaN')" +== 256 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,1,'93901.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 1, '93901.57763026')" +== 257 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,1,'93901.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 1, '93901.57763026')" +== 258 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 1, '0')" +== 259 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 1, 'NaN')" +== 260 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,2,'-34244590.637766787') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 2, '-34244590.637766787')" +== 261 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,2,'34432393.793027307') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 2, '34432393.793027307')" +== 262 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,2,'-3224438592470.18449811926184222') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 2, '-3224438592470.18449811926184222')" +== 263 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,2,'-.00273458651128995823') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 2, '-.00273458651128995823')" +== 264 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,3,'93905.88763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 3, '93905.88763026')" +== 265 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,3,'93897.26763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 3, '93897.26763026')" +== 266 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,3,'404715.7995864206') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 3, '404715.7995864206')" +== 267 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,3,'21786.90896293735498839907') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 3, '21786.90896293735498839907')" +== 268 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,4,'7893362.98953026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 4, '7893362.98953026')" +== 269 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,4,'-7705559.83426974') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 4, '-7705559.83426974')" +== 270 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,4,'732381731243.745115764094') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 4, '732381731243.745115764094')" +== 271 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,4,'.01203949512295682469') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 4, '.01203949512295682469')" +== 272 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,5,'110298.61612126') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 5, '110298.61612126')" +== 273 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,5,'77504.53913926') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 5, '77504.53913926')" +== 274 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,5,'1539707782.76899778633766') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 5, '1539707782.76899778633766')" +== 275 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,5,'5.72674008674192359679') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 5, '5.72674008674192359679')" +== 276 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,6,'187803.15526052') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 6, '187803.15526052')" +== 277 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,6,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 6, '0')" +== 278 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,6,'8817506281.4517452372676676') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 6, '8817506281.4517452372676676')" +== 279 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,6,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 6, '1.00000000000000000000')" +== 280 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,7,'-82934583.42236974') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 7, '-82934583.42236974')" +== 281 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,7,'83122386.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 7, '83122386.57763026')" +== 282 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,7,'-7796505729750.37795610') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 7, '-7796505729750.37795610')" +== 283 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,7,'-.00113095617281538980') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 7, '-.00113095617281538980')" +== 284 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,8,'168782.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 8, '168782.57763026')" +== 285 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,8,'19020.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 8, '19020.57763026')" +== 286 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,8,'7031444034.53149906') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 8, '7031444034.53149906')" +== 287 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,8,'1.25401073209839612184') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 8, '1.25401073209839612184')" +== 288 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,9,'-24832902.467417160') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (6, 9, '-24832902.467417160')" +== 289 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,9,'25020705.622677680') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 9, '25020705.622677680')" +== 290 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,9,'-2340666225110.29929521292692920') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 9, '-2340666225110.29929521292692920')" +== 291 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,9,'-.00376709254265256789') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 9, '-.00376709254265256789')" +== 292 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,0,'-83028485') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 0, '-83028485')" +== 293 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,0,'-83028485') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 0, '-83028485')" +== 294 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 0, '0')" +== 295 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 0, 'NaN')" +== 296 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,1,'-83028485') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 1, '-83028485')" +== 297 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,1,'-83028485') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 1, '-83028485')" +== 298 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 1, '0')" +== 299 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 1, 'NaN')" +== 300 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,2,'-117366977.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 2, '-117366977.215397047')" +== 301 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,2,'-48689992.784602953') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 2, '-48689992.784602953')" +== 302 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,2,'2851072985828710.485883795') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 2, '2851072985828710.485883795')" +== 303 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,2,'2.41794207151503385700') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 2, '2.41794207151503385700')" +== 304 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,3,'-83028480.69') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 3, '-83028480.69')" +== 305 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,3,'-83028489.31') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 3, '-83028489.31')" +== 306 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,3,'-357852770.35') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 3, '-357852770.35')" +== 307 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,3,'-19264149.65197215777262180974') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 3, '-19264149.65197215777262180974')" +== 308 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,4,'-75229023.5881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 4, '-75229023.5881')" +== 309 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,4,'-90827946.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 4, '-90827946.4119')" +== 310 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,4,'-647577464846017.9715') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 4, '-647577464846017.9715')" +== 311 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,4,'-10.64541262725136247686') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 4, '-10.64541262725136247686')" +== 312 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,5,'-83012087.961509') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 5, '-83012087.961509')" +== 313 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,5,'-83044882.038491') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 5, '-83044882.038491')" +== 314 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,5,'-1361421264394.416135') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 5, '-1361421264394.416135')" +== 315 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,5,'-5063.62688881730941836574') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 5, '-5063.62688881730941836574')" +== 316 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,6,'-82934583.42236974') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 6, '-82934583.42236974')" +== 317 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,6,'-83122386.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 6, '-83122386.57763026')" +== 318 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,6,'-7796505729750.37795610') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 6, '-7796505729750.37795610')" +== 319 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,6,'-884.20756174009028770294') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 6, '-884.20756174009028770294')" +== 320 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,7,'-166056970') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 7, '-166056970')" +== 321 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,7,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 7, '0')" +== 322 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,7,'6893729321395225') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 7, '6893729321395225')" +== 323 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,7,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 7, '1.00000000000000000000')" +== 324 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,8,'-82953604') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 8, '-82953604')" +== 325 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,8,'-83103366') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 8, '-83103366')" +== 326 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,8,'-6217255985285') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 8, '-6217255985285')" +== 327 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,8,'-1108.80577182462841041118') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 8, '-1108.80577182462841041118')" +== 328 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,9,'-107955289.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 9, '-107955289.045047420')" +== 329 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,9,'-58101680.954952580') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 9, '-58101680.954952580')" +== 330 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,9,'2069634775752159.035758700') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 9, '2069634775752159.035758700')" +== 331 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,9,'3.33089171198810413382') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 9, '3.33089171198810413382')" +== 332 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,0,'74881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 0, '74881')" +== 333 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,0,'74881') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 0, '74881')" +== 334 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 0, '0')" +== 335 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 0, 'NaN')" +== 336 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,1,'74881') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 1, '74881')" +== 337 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,1,'74881') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 1, '74881')" +== 338 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 1, '0')" +== 339 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 1, 'NaN')" +== 340 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,2,'-34263611.215397047') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 2, '-34263611.215397047')" +== 341 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,2,'34413373.215397047') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 2, '34413373.215397047')" +== 342 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,2,'-2571300635581.146276407') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 2, '-2571300635581.146276407')" +== 343 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,2,'-.00218067233500788615') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 2, '-.00218067233500788615')" +== 344 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,3,'74885.31') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 3, '74885.31')" +== 345 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,3,'74876.69') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 3, '74876.69')" +== 346 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,3,'322737.11') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 3, '322737.11')" +== 347 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,3,'17373.78190255220417633410') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 3, '17373.78190255220417633410')" +== 348 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,4,'7874342.4119') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 4, '7874342.4119')" +== 349 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,4,'-7724580.4119') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 4, '-7724580.4119')" +== 350 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,4,'584031469984.4839') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 4, '584031469984.4839')" +== 351 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,4,'.00960079113741758956') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 4, '.00960079113741758956')" +== 352 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,5,'91278.038491') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 5, '91278.038491')" +== 353 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,5,'58483.961509') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 5, '58483.961509')" +== 354 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,5,'1227826639.244571') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 5, '1227826639.244571')" +== 355 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,5,'4.56673929509287019456') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 5, '4.56673929509287019456')" +== 356 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,6,'168782.57763026') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 6, '168782.57763026')" +== 357 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,6,'-19020.57763026') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 6, '-19020.57763026')" +== 358 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,6,'7031444034.53149906') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 6, '7031444034.53149906')" +== 359 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,6,'.79744134113322314424') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 6, '.79744134113322314424')" +== 360 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,7,'-82953604') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 7, '-82953604')" +== 361 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,7,'83103366') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 7, '83103366')" +== 362 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,7,'-6217255985285') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 7, '-6217255985285')" +== 363 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,7,'-.00090187120721280172') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 7, '-.00090187120721280172')" +== 364 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,8,'149762') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 8, '149762')" +== 365 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,8,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 8, '0')" +== 366 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,8,'5607164161') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 8, '5607164161')" +== 367 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,8,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 8, '1.00000000000000000000')" +== 368 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,9,'-24851923.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (8, 9, '-24851923.045047420')" +== 369 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,9,'25001685.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 9, '25001685.045047420')" +== 370 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,9,'-1866544013697.195857020') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 9, '-1866544013697.195857020')" +== 371 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,9,'-.00300403532938582735') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 9, '-.00300403532938582735')" +== 372 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,0,'-24926804.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 0, '-24926804.045047420')" +== 373 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,0,'-24926804.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 0, '-24926804.045047420')" +== 374 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 0, '0')" +== 375 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 0, 'NaN')" +== 376 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,1,'-24926804.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 1, '-24926804.045047420')" +== 377 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,1,'-24926804.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 1, '-24926804.045047420')" +== 378 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 1, '0')" +== 379 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,1,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 1, 'NaN')" +== 380 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,2,'-59265296.260444467') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 2, '-59265296.260444467')" +== 381 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,2,'9411688.170349627') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 2, '9411688.170349627')" +== 382 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,2,'855948866655588.453741509242968740') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 2, '855948866655588.453741509242968740')" +== 383 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,2,'.72591434384152961526') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 2, '.72591434384152961526')" +== 384 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,3,'-24926799.735047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 3, '-24926799.735047420')" +== 385 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,3,'-24926808.355047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 3, '-24926808.355047420')" +== 386 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,3,'-107434525.43415438020') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 3, '-107434525.43415438020')" +== 387 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,3,'-5783481.21694835730858468677') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 3, '-5783481.21694835730858468677')" +== 388 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,4,'-17127342.633147420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 4, '-17127342.633147420')" +== 389 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,4,'-32726265.456947420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 4, '-32726265.456947420')" +== 390 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,4,'-194415646271340.1815956522980') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 4, '-194415646271340.1815956522980')" +== 391 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,4,'-3.19596478892958416484') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 4, '-3.19596478892958416484')" +== 392 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,5,'-24910407.006556420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 5, '-24910407.006556420')" +== 393 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,5,'-24943201.083538420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 5, '-24943201.083538420')" +== 394 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,5,'-408725765384.257043660243220') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 5, '-408725765384.257043660243220')" +== 395 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,5,'-1520.20159364322004505807') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 5, '-1520.20159364322004505807')" +== 396 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,6,'-24832902.467417160') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 6, '-24832902.467417160')" +== 397 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,6,'-25020705.622677680') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 6, '-25020705.622677680')" +== 398 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,6,'-2340666225110.29929521292692920') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 6, '-2340666225110.29929521292692920')" +== 399 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,6,'-265.45671195426965751280') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 6, '-265.45671195426965751280')" +== 400 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,7,'-107955289.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 7, '-107955289.045047420')" +== 401 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,7,'58101680.954952580') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 7, '58101680.954952580')" +== 402 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,7,'2069634775752159.035758700') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 7, '2069634775752159.035758700')" +== 403 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,7,'.30021990699995814689') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 7, '.30021990699995814689')" +== 404 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,8,'-24851923.045047420') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 8, '-24851923.045047420')" +== 405 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,8,'-25001685.045047420') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 8, '-25001685.045047420')" +== 406 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,8,'-1866544013697.195857020') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 8, '-1866544013697.195857020')" +== 407 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,8,'-332.88556569820675471748') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 8, '-332.88556569820675471748')" +== 408 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,9,'-49853608.090094840') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (9, 9, '-49853608.090094840')" +== 409 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,9,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 9, '0')" +== 410 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,9,'621345559900192.420120630048656400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 9, '621345559900192.420120630048656400')" +== 411 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,9,'1.00000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 9, '1.00000000000000000000')" +== 412 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 413 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 414 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (0,'0') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (0, '0')" +== 415 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (1,'0') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (1, '0')" +== 416 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (2,'5859.90547836712524903505') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (2, '5859.90547836712524903505')" +== 417 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (3,'2.07605394920266944396') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (3, '2.07605394920266944396')" +== 418 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (4,'2792.75158435189147418923') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (4, '2792.75158435189147418923')" +== 419 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (5,'128.05092147657509145473') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (5, '128.05092147657509145473')" +== 420 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (6,'306.43364311096782703406') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (6, '306.43364311096782703406')" +== 421 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (7,'9111.99676251039939975230') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (7, '9111.99676251039939975230')" +== 422 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (8,'273.64392922189960397542') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (8, '273.64392922189960397542')" +== 423 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (9,'4992.67503899937593364766') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (9, '4992.67503899937593364766')" +== 424 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 425 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 426 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (0,'NaN') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (0, 'NaN')" +== 427 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (1,'NaN') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (1, 'NaN')" +== 428 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (2,'17.35177750493897715514') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (2, '17.35177750493897715514')" +== 429 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (3,'1.46093790411565641971') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (3, '1.46093790411565641971')" +== 430 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (4,'15.86956523951936572464') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (4, '15.86956523951936572464')" +== 431 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (5,'9.70485601768871834038') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (5, '9.70485601768871834038')" +== 432 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (6,'11.45000246622944403127') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (6, '11.45000246622944403127')" +== 433 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (7,'18.23469429965478772991') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (7, '18.23469429965478772991')" +== 434 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (8,'11.22365546576315513668') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (8, '11.22365546576315513668')" +== 435 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (9,'17.03145425013166006962') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (9, '17.03145425013166006962')" +== 436 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 437 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 438 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (0,'NaN') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (0, 'NaN')" +== 439 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (1,'NaN') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (1, 'NaN')" +== 440 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (2,'7.53578122160797276459') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (2, '7.53578122160797276459')" +== 441 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (3,'.63447727016073160075') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (3, '.63447727016073160075')" +== 442 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (4,'6.89206461372691743345') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (4, '6.89206461372691743345')" +== 443 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (5,'4.21476541614777768626') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (5, '4.21476541614777768626')" +== 444 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (6,'4.97267288886207207671') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (6, '4.97267288886207207671')" +== 445 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (7,'7.91922711353275546914') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (7, '7.91922711353275546914')" +== 446 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (8,'4.87437163556421004138') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (8, '4.87437163556421004138')" +== 447 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (9,'7.39666659961986567059') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (9, '7.39666659961986567059')" +== 448 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 449 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 450 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (0,'NaN') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (0, 'NaN')" +== 451 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (1,'NaN') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (1, 'NaN')" +== 452 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (2,'224790267919917955.13261618583642653184') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (2, '224790267919917955.13261618583642653184')" +== 453 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (3,'28.90266599445155957393') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (3, '28.90266599445155957393')" +== 454 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (4,'7405685069594999.07733999469386277636') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (4, '7405685069594999.07733999469386277636')" +== 455 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (5,'5068226527.32127265408584640098') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (5, '5068226527.32127265408584640098')" +== 456 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (6,'281839893606.99372343357047819067') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (6, '281839893606.99372343357047819067')" +== 457 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (7,'1716699575118597095.42330819910640247627') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (7, '1716699575118597095.42330819910640247627')" +== 458 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (8,'167361463828.07491320069016125952') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (8, '167361463828.07491320069016125952')" +== 459 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (9,'107511333880052007.04141124673540337457') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (9, '107511333880052007.04141124673540337457')" +== 460 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 461 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 462 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (0, '0') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (0, '0')" +== 463 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (1, '0') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (1, '0')" +== 464 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (2, '-34338492.215397047') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (2, '-34338492.215397047')" +== 465 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (3, '4.31') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (3, '4.31')" +== 466 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (4, '7799461.4119') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (4, '7799461.4119')" +== 467 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (5, '16397.038491') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (5, '16397.038491')" +== 468 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (6, '93901.57763026') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (6, '93901.57763026')" +== 469 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (7, '-83028485') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (7, '-83028485')" +== 470 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (8, '74881') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (8, '74881')" +== 471 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (9, '-24926804.045047420') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (9, '-24926804.045047420')" +== 472 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 473 +-- truncate_limit: 100 +-- ****************************** +-- * Create indices for faster checks +-- ****************************** + +CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add (id1, id2) +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add USING btree (id1, id2)" +== 474 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub (id1, id2) +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub USING btree (id1, id2)" +== 475 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div (id1, id2) +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div USING btree (id1, id2)" +== 476 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul (id1, id2) +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul USING btree (id1, id2)" +== 477 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt (id) +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt USING btree (id)" +== 478 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln (id) +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln USING btree (id)" +== 479 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 (id) +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 USING btree (id)" +== 480 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln (id) +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln USING btree (id)" +== 481 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_add +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_add" +== 482 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_sub +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_sub" +== 483 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_div +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_div" +== 484 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_mul +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_mul" +== 485 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_sqrt +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_sqrt" +== 486 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_ln +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_ln" +== 487 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_log10 +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_log10" +== 488 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_power_10_ln +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_power_10_ln" +== 489 +-- truncate_limit: 100 +-- ****************************** +-- * Now check the behaviour of the NUMERIC type +-- ****************************** + +-- ****************************** +-- * Addition check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 490 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val FROM num_data t1, num_data t2" +== 491 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_add" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.id2, t1.result, t2.expected FROM num_result t1, num_exp_add t2 WHERE ..." +== 492 +-- truncate_limit: 100 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 493 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) FROM num_data t1, num_data t2" +== 494 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 10) as expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 10) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_add" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_result t1, num_exp_add t2 WHERE ..." +== 495 +-- truncate_limit: 100 +-- ****************************** +-- * Subtraction check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 496 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val FROM num_data t1, num_data t2" +== 497 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sub" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.id2, t1.result, t2.expected FROM num_result t1, num_exp_sub t2 WHERE ..." +== 498 +-- truncate_limit: 100 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 499 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) FROM num_data t1, num_data t2" +== 500 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 40) + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 40) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sub" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_result t1, num_exp_sub t2 WHERE ..." +== 501 +-- truncate_limit: 100 +-- ****************************** +-- * Multiply check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 502 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val FROM num_data t1, num_data t2" +== 503 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_mul" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.id2, t1.result, t2.expected FROM num_result t1, num_exp_mul t2 WHERE ..." +== 504 +-- truncate_limit: 100 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 505 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) FROM num_data t1, num_data t2" +== 506 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 30) as expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 30) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_mul" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_result t1, num_exp_mul t2 WHERE ..." +== 507 +-- truncate_limit: 100 +-- ****************************** +-- * Division check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 508 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val / t2.val + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FILTER: schema="" table="t2" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT ... FROM num_data t1, num_data t2 WHERE t2.val <> '0.0'" +== 509 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_div" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.id2, t1.result, t2.expected FROM num_result t1, num_exp_div t2 WHERE ..." +== 510 +-- truncate_limit: 100 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 511 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val / t2.val, 80) + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t2" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT ... FROM num_data t1, num_data t2 WHERE t2.val <> '0.0'" +== 512 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 80) as expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 80) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_div" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_result t1, num_exp_div t2 WHERE ..." +== 513 +-- truncate_limit: 100 +-- ****************************** +-- * Square root check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 514 +-- truncate_limit: 100 +INSERT INTO num_result SELECT id, 0, SQRT(ABS(val)) + FROM num_data +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT id, 0, sqrt(abs(val)) FROM num_data" +== 515 +-- truncate_limit: 100 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_sqrt t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sqrt" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.result, t2.expected FROM num_result t1, num_exp_sqrt t2 WHERE ..." +== 516 +-- truncate_limit: 100 +-- ****************************** +-- * Natural logarithm check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 517 +-- truncate_limit: 100 +INSERT INTO num_result SELECT id, 0, LN(ABS(val)) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT id, 0, ln(abs(val)) FROM num_data WHERE val <> '0.0'" +== 518 +-- truncate_limit: 100 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_ln" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.result, t2.expected FROM num_result t1, num_exp_ln t2 WHERE ..." +== 519 +-- truncate_limit: 100 +-- ****************************** +-- * Logarithm base 10 check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 520 +-- truncate_limit: 100 +INSERT INTO num_result SELECT id, 0, LOG(numeric '10', ABS(val)) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT id, 0, log('10'::numeric, abs(val)) FROM num_data WHERE val <> '0.0'" +== 521 +-- truncate_limit: 100 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_log10 t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_log10" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.result, t2.expected FROM num_result t1, num_exp_log10 t2 WHERE ..." +== 522 +-- truncate_limit: 100 +-- ****************************** +-- * POWER(10, LN(value)) check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 523 +-- truncate_limit: 100 +INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200)))) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="power" function="power" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT ... FROM num_data WHERE val <> '0.0'" +== 524 +-- truncate_limit: 100 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_power_10_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_power_10_ln" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.result, t2.expected FROM num_result t1, num_exp_power_10_ln t2 WHERE ..." +== 525 +-- truncate_limit: 100 +-- ****************************** +-- * Check behavior with Inf and NaN inputs. It's easiest to handle these +-- * separately from the num_data framework used above, because some input +-- * combinations will throw errors. +-- ****************************** + +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('inf'),('-inf'),('nan')) +SELECT x1, x2, + x1 + x2 AS sum, + x1 - x2 AS diff, + x1 * x2 AS prod +FROM v AS v1(x1), v AS v2(x2) +-- +ALIAS: "v1"="v" +ALIAS: "v2"="v" +CTE: "v" +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (...) SELECT ... FROM v v1(x1), v v2(x2)" +== 526 +-- truncate_limit: 100 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('inf'),('-inf'),('nan')) +SELECT x1, x2, + x1 / x2 AS quot, + x1 % x2 AS mod, + div(x1, x2) AS div +FROM v AS v1(x1), v AS v2(x2) WHERE x2 != 0 +-- +ALIAS: "v1"="v" +ALIAS: "v2"="v" +CTE: "v" +FUNCTION: name="div" function="div" schema="" ctx=Call +FILTER: schema="" table="" column="x2" +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (...) SELECT ... FROM v v1(x1), v v2(x2) WHERE x2 <> 0" +== 527 +-- truncate_limit: 100 +SELECT 'inf'::numeric / '0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'inf'::numeric / '0'" +== 528 +-- truncate_limit: 100 +SELECT '-inf'::numeric / '0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-inf'::numeric / '0'" +== 529 +-- truncate_limit: 100 +SELECT 'nan'::numeric / '0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::numeric / '0'" +== 530 +-- truncate_limit: 100 +SELECT '0'::numeric / '0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0'::numeric / '0'" +== 531 +-- truncate_limit: 100 +SELECT 'inf'::numeric % '0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'inf'::numeric % '0'" +== 532 +-- truncate_limit: 100 +SELECT '-inf'::numeric % '0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-inf'::numeric % '0'" +== 533 +-- truncate_limit: 100 +SELECT 'nan'::numeric % '0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'nan'::numeric % '0'" +== 534 +-- truncate_limit: 100 +SELECT '0'::numeric % '0' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0'::numeric % '0'" +== 535 +-- truncate_limit: 100 +SELECT div('inf'::numeric, '0') +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT div('inf'::numeric, '0')" +== 536 +-- truncate_limit: 100 +SELECT div('-inf'::numeric, '0') +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT div('-inf'::numeric, '0')" +== 537 +-- truncate_limit: 100 +SELECT div('nan'::numeric, '0') +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT div('nan'::numeric, '0')" +== 538 +-- truncate_limit: 100 +SELECT div('0'::numeric, '0') +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT div('0'::numeric, '0')" +== 539 +-- truncate_limit: 100 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('inf'),('-inf'),('nan')) +SELECT x, -x as minusx, abs(x), floor(x), ceil(x), sign(x), numeric_inc(x) as inc +FROM v +-- +CTE: "v" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="floor" function="floor" schema="" ctx=Call +FUNCTION: name="ceil" function="ceil" schema="" ctx=Call +FUNCTION: name="sign" function="sign" schema="" ctx=Call +FUNCTION: name="numeric_inc" function="numeric_inc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (...) SELECT ... FROM v" +== 540 +-- truncate_limit: 100 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('inf'),('-inf'),('nan')) +SELECT x, round(x), round(x,1) as round1, trunc(x), trunc(x,1) as trunc1 +FROM v +-- +CTE: "v" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (...) SELECT x, round(x), round(x, 1) AS round1, trunc(x), trunc(x, 1) AS trunc1 FROM v" +== 541 +-- truncate_limit: 100 +-- the large values fall into the numeric abbreviation code's maximal classes +WITH v(x) AS + (VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('1e340'),('-1e340'), + ('inf'),('-inf'),('nan'), + ('inf'),('-inf'),('nan')) +SELECT substring(x::text, 1, 32) +FROM v ORDER BY x +-- +CTE: "v" +FUNCTION: name="substring" function="substring" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (VALUES (...)) SELECT \"substring\"(x::text, 1, 32) FROM v ORDER BY x" +== 542 +-- truncate_limit: 100 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('4.2'),('inf'),('nan')) +SELECT x, sqrt(x) +FROM v +-- +CTE: "v" +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (VALUES ('0'::numeric), ('1'), ('4.2'), ('inf'), ('nan')) SELECT x, sqrt(x) FROM v" +== 543 +-- truncate_limit: 100 +SELECT sqrt('-1'::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt('-1'::numeric)" +== 544 +-- truncate_limit: 100 +SELECT sqrt('-inf'::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt('-inf'::numeric)" +== 545 +-- truncate_limit: 100 +WITH v(x) AS + (VALUES('1'::numeric),('4.2'),('inf'),('nan')) +SELECT x, + log(x), + log10(x), + ln(x) +FROM v +-- +CTE: "v" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log10" function="log10" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (VALUES (...)) SELECT x, log(x), log10(x), ln(x) FROM v" +== 546 +-- truncate_limit: 100 +SELECT ln('0'::numeric) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln('0'::numeric)" +== 547 +-- truncate_limit: 100 +SELECT ln('-1'::numeric) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln('-1'::numeric)" +== 548 +-- truncate_limit: 100 +SELECT ln('-inf'::numeric) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln('-inf'::numeric)" +== 549 +-- truncate_limit: 100 +WITH v(x) AS + (VALUES('2'::numeric),('4.2'),('inf'),('nan')) +SELECT x1, x2, + log(x1, x2) +FROM v AS v1(x1), v AS v2(x2) +-- +ALIAS: "v1"="v" +ALIAS: "v2"="v" +CTE: "v" +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (VALUES (...)) SELECT x1, x2, log(x1, x2) FROM v v1(x1), v v2(x2)" +== 550 +-- truncate_limit: 100 +SELECT log('0'::numeric, '10') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log('0'::numeric, '10')" +== 551 +-- truncate_limit: 100 +SELECT log('10'::numeric, '0') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log('10'::numeric, '0')" +== 552 +-- truncate_limit: 100 +SELECT log('-inf'::numeric, '10') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log('-inf'::numeric, '10')" +== 553 +-- truncate_limit: 100 +SELECT log('10'::numeric, '-inf') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log('10'::numeric, '-inf')" +== 554 +-- truncate_limit: 100 +SELECT log('inf'::numeric, '0') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log('inf'::numeric, '0')" +== 555 +-- truncate_limit: 100 +SELECT log('inf'::numeric, '-inf') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log('inf'::numeric, '-inf')" +== 556 +-- truncate_limit: 100 +SELECT log('-inf'::numeric, 'inf') +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log('-inf'::numeric, 'inf')" +== 557 +-- truncate_limit: 100 +WITH v(x) AS + (VALUES('0'::numeric),('1'),('2'),('4.2'),('inf'),('nan')) +SELECT x1, x2, + power(x1, x2) +FROM v AS v1(x1), v AS v2(x2) WHERE x1 != 0 OR x2 >= 0 +-- +ALIAS: "v1"="v" +ALIAS: "v2"="v" +CTE: "v" +FUNCTION: name="power" function="power" schema="" ctx=Call +FILTER: schema="" table="" column="x1" +FILTER: schema="" table="" column="x2" +STMT: SelectStmt +TRUNCATED: "WITH v(x) AS (...) SELECT x1, x2, power(x1, x2) FROM v v1(x1), v v2(x2) WHERE x1 <> 0 OR x2 >= 0" +== 558 +-- truncate_limit: 100 +SELECT power('0'::numeric, '-1') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('0'::numeric, '-1')" +== 559 +-- truncate_limit: 100 +SELECT power('0'::numeric, '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('0'::numeric, '-inf')" +== 560 +-- truncate_limit: 100 +SELECT power('-1'::numeric, 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-1'::numeric, 'inf')" +== 561 +-- truncate_limit: 100 +SELECT power('-2'::numeric, '3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-2'::numeric, '3')" +== 562 +-- truncate_limit: 100 +SELECT power('-2'::numeric, '3.3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-2'::numeric, '3.3')" +== 563 +-- truncate_limit: 100 +SELECT power('-2'::numeric, '-1') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-2'::numeric, '-1')" +== 564 +-- truncate_limit: 100 +SELECT power('-2'::numeric, '-1.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-2'::numeric, '-1.5')" +== 565 +-- truncate_limit: 100 +SELECT power('-2'::numeric, 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-2'::numeric, 'inf')" +== 566 +-- truncate_limit: 100 +SELECT power('-2'::numeric, '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-2'::numeric, '-inf')" +== 567 +-- truncate_limit: 100 +SELECT power('inf'::numeric, '-2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('inf'::numeric, '-2')" +== 568 +-- truncate_limit: 100 +SELECT power('inf'::numeric, '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('inf'::numeric, '-inf')" +== 569 +-- truncate_limit: 100 +SELECT power('-inf'::numeric, '2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::numeric, '2')" +== 570 +-- truncate_limit: 100 +SELECT power('-inf'::numeric, '3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::numeric, '3')" +== 571 +-- truncate_limit: 100 +SELECT power('-inf'::numeric, '4.5') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::numeric, '4.5')" +== 572 +-- truncate_limit: 100 +SELECT power('-inf'::numeric, '-2') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::numeric, '-2')" +== 573 +-- truncate_limit: 100 +SELECT power('-inf'::numeric, '-3') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::numeric, '-3')" +== 574 +-- truncate_limit: 100 +SELECT power('-inf'::numeric, '0') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::numeric, '0')" +== 575 +-- truncate_limit: 100 +SELECT power('-inf'::numeric, 'inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::numeric, 'inf')" +== 576 +-- truncate_limit: 100 +SELECT power('-inf'::numeric, '-inf') +-- +FUNCTION: name="power" function="power" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT power('-inf'::numeric, '-inf')" +== 577 +-- truncate_limit: 100 +-- ****************************** +-- * miscellaneous checks for things that have been broken in the past... +-- ****************************** +-- numeric AVG used to fail on some platforms +SELECT AVG(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(val) FROM num_data" +== 578 +-- truncate_limit: 100 +SELECT MAX(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(val) FROM num_data" +== 579 +-- truncate_limit: 100 +SELECT MIN(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(val) FROM num_data" +== 580 +-- truncate_limit: 100 +SELECT STDDEV(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stddev(val) FROM num_data" +== 581 +-- truncate_limit: 100 +SELECT VARIANCE(val) FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT variance(val) FROM num_data" +== 582 +-- truncate_limit: 100 +-- Check for appropriate rounding and overflow +CREATE TABLE fract_only (id int, val numeric(4,4)) +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fract_only (id int, val numeric(4, 4))" +== 583 +-- truncate_limit: 100 +INSERT INTO fract_only VALUES (1, '0.0') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (1, '0.0')" +== 584 +-- truncate_limit: 100 +INSERT INTO fract_only VALUES (2, '0.1') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (2, '0.1')" +== 585 +-- truncate_limit: 100 +INSERT INTO fract_only VALUES (3, '1.0') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (3, '1.0')" +== 586 +-- truncate_limit: 100 +-- should fail +INSERT INTO fract_only VALUES (4, '-0.9999') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (4, '-0.9999')" +== 587 +-- truncate_limit: 100 +INSERT INTO fract_only VALUES (5, '0.99994') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (5, '0.99994')" +== 588 +-- truncate_limit: 100 +INSERT INTO fract_only VALUES (6, '0.99995') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (6, '0.99995')" +== 589 +-- truncate_limit: 100 +-- should fail +INSERT INTO fract_only VALUES (7, '0.00001') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (7, '0.00001')" +== 590 +-- truncate_limit: 100 +INSERT INTO fract_only VALUES (8, '0.00017') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (8, '0.00017')" +== 591 +-- truncate_limit: 100 +INSERT INTO fract_only VALUES (9, 'NaN') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (9, 'NaN')" +== 592 +-- truncate_limit: 100 +INSERT INTO fract_only VALUES (10, 'Inf') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (10, 'Inf')" +== 593 +-- truncate_limit: 100 +-- should fail +INSERT INTO fract_only VALUES (11, '-Inf') +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_only VALUES (11, '-Inf')" +== 594 +-- truncate_limit: 100 +-- should fail +SELECT * FROM fract_only +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fract_only" +== 595 +-- truncate_limit: 100 +DROP TABLE fract_only +-- +TABLE: name="fract_only" schema="" table="fract_only" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fract_only" +== 596 +-- truncate_limit: 100 +-- Check conversion to integers +SELECT (-9223372036854775808.5)::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808.5)::int8" +== 597 +-- truncate_limit: 100 +-- should fail +SELECT (-9223372036854775808.4)::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-9223372036854775808.4)::int8" +== 598 +-- truncate_limit: 100 +-- ok +SELECT 9223372036854775807.4::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (9223372036854775807.4)::int8" +== 599 +-- truncate_limit: 100 +-- ok +SELECT 9223372036854775807.5::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (9223372036854775807.5)::int8" +== 600 +-- truncate_limit: 100 +-- should fail +SELECT (-2147483648.5)::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-2147483648.5)::int4" +== 601 +-- truncate_limit: 100 +-- should fail +SELECT (-2147483648.4)::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-2147483648.4)::int4" +== 602 +-- truncate_limit: 100 +-- ok +SELECT 2147483647.4::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (2147483647.4)::int4" +== 603 +-- truncate_limit: 100 +-- ok +SELECT 2147483647.5::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (2147483647.5)::int4" +== 604 +-- truncate_limit: 100 +-- should fail +SELECT (-32768.5)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-32768.5)::int2" +== 605 +-- truncate_limit: 100 +-- should fail +SELECT (-32768.4)::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (-32768.4)::int2" +== 606 +-- truncate_limit: 100 +-- ok +SELECT 32767.4::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (32767.4)::int2" +== 607 +-- truncate_limit: 100 +-- ok +SELECT 32767.5::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (32767.5)::int2" +== 608 +-- truncate_limit: 100 +-- should fail + +-- Check inf/nan conversion behavior +SELECT 'NaN'::float8::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::float8::numeric" +== 609 +-- truncate_limit: 100 +SELECT 'Infinity'::float8::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::float8::numeric" +== 610 +-- truncate_limit: 100 +SELECT '-Infinity'::float8::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-Infinity'::float8::numeric" +== 611 +-- truncate_limit: 100 +SELECT 'NaN'::numeric::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::numeric::float8" +== 612 +-- truncate_limit: 100 +SELECT 'Infinity'::numeric::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::numeric::float8" +== 613 +-- truncate_limit: 100 +SELECT '-Infinity'::numeric::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-Infinity'::numeric::float8" +== 614 +-- truncate_limit: 100 +SELECT 'NaN'::float4::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::float4::numeric" +== 615 +-- truncate_limit: 100 +SELECT 'Infinity'::float4::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::float4::numeric" +== 616 +-- truncate_limit: 100 +SELECT '-Infinity'::float4::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-Infinity'::float4::numeric" +== 617 +-- truncate_limit: 100 +SELECT 'NaN'::numeric::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::numeric::float4" +== 618 +-- truncate_limit: 100 +SELECT 'Infinity'::numeric::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::numeric::float4" +== 619 +-- truncate_limit: 100 +SELECT '-Infinity'::numeric::float4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-Infinity'::numeric::float4" +== 620 +-- truncate_limit: 100 +SELECT '42'::int2::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '42'::int2::numeric" +== 621 +-- truncate_limit: 100 +SELECT 'NaN'::numeric::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::numeric::int2" +== 622 +-- truncate_limit: 100 +SELECT 'Infinity'::numeric::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::numeric::int2" +== 623 +-- truncate_limit: 100 +SELECT '-Infinity'::numeric::int2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-Infinity'::numeric::int2" +== 624 +-- truncate_limit: 100 +SELECT 'NaN'::numeric::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::numeric::int4" +== 625 +-- truncate_limit: 100 +SELECT 'Infinity'::numeric::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::numeric::int4" +== 626 +-- truncate_limit: 100 +SELECT '-Infinity'::numeric::int4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-Infinity'::numeric::int4" +== 627 +-- truncate_limit: 100 +SELECT 'NaN'::numeric::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::numeric::int8" +== 628 +-- truncate_limit: 100 +SELECT 'Infinity'::numeric::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Infinity'::numeric::int8" +== 629 +-- truncate_limit: 100 +SELECT '-Infinity'::numeric::int8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-Infinity'::numeric::int8" +== 630 +-- truncate_limit: 100 +-- Simple check that ceil(), floor(), and round() work correctly +CREATE TABLE ceil_floor_round (a numeric) +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ceil_floor_round (a numeric)" +== 631 +-- truncate_limit: 100 +INSERT INTO ceil_floor_round VALUES ('-5.5') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ceil_floor_round VALUES ('-5.5')" +== 632 +-- truncate_limit: 100 +INSERT INTO ceil_floor_round VALUES ('-5.499999') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ceil_floor_round VALUES ('-5.499999')" +== 633 +-- truncate_limit: 100 +INSERT INTO ceil_floor_round VALUES ('9.5') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ceil_floor_round VALUES ('9.5')" +== 634 +-- truncate_limit: 100 +INSERT INTO ceil_floor_round VALUES ('9.4999999') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ceil_floor_round VALUES ('9.4999999')" +== 635 +-- truncate_limit: 100 +INSERT INTO ceil_floor_round VALUES ('0.0') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ceil_floor_round VALUES ('0.0')" +== 636 +-- truncate_limit: 100 +INSERT INTO ceil_floor_round VALUES ('0.0000001') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ceil_floor_round VALUES ('0.0000001')" +== 637 +-- truncate_limit: 100 +INSERT INTO ceil_floor_round VALUES ('-0.000001') +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ceil_floor_round VALUES ('-0.000001')" +== 638 +-- truncate_limit: 100 +SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=Select +FUNCTION: name="ceil" function="ceil" schema="" ctx=Call +FUNCTION: name="ceiling" function="ceiling" schema="" ctx=Call +FUNCTION: name="floor" function="floor" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round" +== 639 +-- truncate_limit: 100 +DROP TABLE ceil_floor_round +-- +TABLE: name="ceil_floor_round" schema="" table="ceil_floor_round" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ceil_floor_round" +== 640 +-- truncate_limit: 100 +-- Check rounding, it should round ties away from zero. +SELECT i as pow, + round((-2.5 * 10 ^ i)::numeric, -i), + round((-1.5 * 10 ^ i)::numeric, -i), + round((-0.5 * 10 ^ i)::numeric, -i), + round((0.5 * 10 ^ i)::numeric, -i), + round((1.5 * 10 ^ i)::numeric, -i), + round((2.5 * 10 ^ i)::numeric, -i) +FROM generate_series(-5,5) AS t(i) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(-5, 5) t(i)" +== 641 +-- truncate_limit: 100 +-- Check limits of rounding before the decimal point +SELECT round(4.4e131071, -131071) = 4e131071 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(4.4e131071, -131071) = 4e131071" +== 642 +-- truncate_limit: 100 +SELECT round(4.5e131071, -131071) = 5e131071 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(4.5e131071, -131071) = 5e131071" +== 643 +-- truncate_limit: 100 +SELECT round(4.5e131071, -131072) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(4.5e131071, -131072)" +== 644 +-- truncate_limit: 100 +-- loses all digits +SELECT round(5.5e131071, -131072) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(5.5e131071, -131072)" +== 645 +-- truncate_limit: 100 +-- rounds up and overflows +SELECT round(5.5e131071, -131073) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(5.5e131071, -131073)" +== 646 +-- truncate_limit: 100 +-- loses all digits +SELECT round(5.5e131071, -1000000) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(5.5e131071, -1000000)" +== 647 +-- truncate_limit: 100 +-- loses all digits + +-- Check limits of rounding after the decimal point +SELECT round(5e-16383, 1000000) = 5e-16383 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(5e-16383, 1000000) = 5e-16383" +== 648 +-- truncate_limit: 100 +SELECT round(5e-16383, 16383) = 5e-16383 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(5e-16383, 16383) = 5e-16383" +== 649 +-- truncate_limit: 100 +SELECT round(5e-16383, 16382) = 1e-16382 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(5e-16383, 16382) = 1e-16382" +== 650 +-- truncate_limit: 100 +SELECT round(5e-16383, 16381) = 0 +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(5e-16383, 16381) = 0" +== 651 +-- truncate_limit: 100 +-- Check limits of trunc() before the decimal point +SELECT trunc(9.9e131071, -131071) = 9e131071 +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trunc(9.9e131071, -131071) = 9e131071" +== 652 +-- truncate_limit: 100 +SELECT trunc(9.9e131071, -131072) +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trunc(9.9e131071, -131072)" +== 653 +-- truncate_limit: 100 +-- loses all digits +SELECT trunc(9.9e131071, -131073) +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trunc(9.9e131071, -131073)" +== 654 +-- truncate_limit: 100 +-- loses all digits +SELECT trunc(9.9e131071, -1000000) +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trunc(9.9e131071, -1000000)" +== 655 +-- truncate_limit: 100 +-- loses all digits + +-- Check limits of trunc() after the decimal point +SELECT trunc(5e-16383, 1000000) = 5e-16383 +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trunc(5e-16383, 1000000) = 5e-16383" +== 656 +-- truncate_limit: 100 +SELECT trunc(5e-16383, 16383) = 5e-16383 +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trunc(5e-16383, 16383) = 5e-16383" +== 657 +-- truncate_limit: 100 +SELECT trunc(5e-16383, 16382) = 0 +-- +FUNCTION: name="trunc" function="trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trunc(5e-16383, 16382) = 0" +== 658 +-- truncate_limit: 100 +-- Testing for width_bucket(). For convenience, we test both the +-- numeric and float8 versions of the function in this file. + +-- errors +SELECT width_bucket(5.0, 3.0, 4.0, 0) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(5.0, 3.0, 4.0, 0)" +== 659 +-- truncate_limit: 100 +SELECT width_bucket(5.0, 3.0, 4.0, -5) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(5.0, 3.0, 4.0, -5)" +== 660 +-- truncate_limit: 100 +SELECT width_bucket(3.5, 3.0, 3.0, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(3.5, 3.0, 3.0, 888)" +== 661 +-- truncate_limit: 100 +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, 0) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket((5.0)::float8, (3.0)::float8, (4.0)::float8, 0)" +== 662 +-- truncate_limit: 100 +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, -5) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket((5.0)::float8, (3.0)::float8, (4.0)::float8, -5)" +== 663 +-- truncate_limit: 100 +SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket((3.5)::float8, (3.0)::float8, (3.0)::float8, 888)" +== 664 +-- truncate_limit: 100 +SELECT width_bucket('NaN', 3.0, 4.0, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket('NaN', 3.0, 4.0, 888)" +== 665 +-- truncate_limit: 100 +SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(0::float8, 'NaN', (4.0)::float8, 888)" +== 666 +-- truncate_limit: 100 +SELECT width_bucket(2.0, 3.0, '-inf', 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(2.0, 3.0, '-inf', 888)" +== 667 +-- truncate_limit: 100 +SELECT width_bucket(0::float8, '-inf', 4.0::float8, 888) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(0::float8, '-inf', (4.0)::float8, 888)" +== 668 +-- truncate_limit: 100 +-- normal operation +CREATE TABLE width_bucket_test (operand_num numeric, operand_f8 float8) +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE width_bucket_test (operand_num numeric, operand_f8 float8)" +== 669 +-- truncate_limit: 100 +COPY width_bucket_test (operand_num) FROM stdin +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY width_bucket_test(operand_num) FROM STDIN" +== 670 +-- truncate_limit: 100 +UPDATE width_bucket_test SET operand_f8 = operand_num::float8 +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE width_bucket_test SET operand_f8 = operand_num::float8" +== 671 +-- truncate_limit: 100 +SELECT + operand_num, + width_bucket(operand_num, 0, 10, 5) AS wb_1, + width_bucket(operand_f8, 0, 10, 5) AS wb_1f, + width_bucket(operand_num, 10, 0, 5) AS wb_2, + width_bucket(operand_f8, 10, 0, 5) AS wb_2f, + width_bucket(operand_num, 2, 8, 4) AS wb_3, + width_bucket(operand_f8, 2, 8, 4) AS wb_3f, + width_bucket(operand_num, 5.0, 5.5, 20) AS wb_4, + width_bucket(operand_f8, 5.0, 5.5, 20) AS wb_4f, + width_bucket(operand_num, -25, 25, 10) AS wb_5, + width_bucket(operand_f8, -25, 25, 10) AS wb_5f + FROM width_bucket_test +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=Select +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM width_bucket_test" +== 672 +-- truncate_limit: 100 +-- Check positive and negative infinity: we require +-- finite bucket bounds, but allow an infinite operand +SELECT width_bucket(0.0::numeric, 'Infinity'::numeric, 5, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket((0.0)::numeric, 'Infinity'::numeric, 5, 10)" +== 673 +-- truncate_limit: 100 +-- error +SELECT width_bucket(0.0::numeric, 5, '-Infinity'::numeric, 20) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket((0.0)::numeric, 5, '-Infinity'::numeric, 20)" +== 674 +-- truncate_limit: 100 +-- error +SELECT width_bucket('Infinity'::numeric, 1, 10, 10), + width_bucket('-Infinity'::numeric, 1, 10, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket('Infinity'::numeric, 1, 10, 10), width_bucket('-Infinity'::numeric, 1, 10, 10)" +== 675 +-- truncate_limit: 100 +SELECT width_bucket(0.0::float8, 'Infinity'::float8, 5, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket((0.0)::float8, 'Infinity'::float8, 5, 10)" +== 676 +-- truncate_limit: 100 +-- error +SELECT width_bucket(0.0::float8, 5, '-Infinity'::float8, 20) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket((0.0)::float8, 5, '-Infinity'::float8, 20)" +== 677 +-- truncate_limit: 100 +-- error +SELECT width_bucket('Infinity'::float8, 1, 10, 10), + width_bucket('-Infinity'::float8, 1, 10, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket('Infinity'::float8, 1, 10, 10), width_bucket('-Infinity'::float8, 1, 10, 10)" +== 678 +-- truncate_limit: 100 +DROP TABLE width_bucket_test +-- +TABLE: name="width_bucket_test" schema="" table="width_bucket_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE width_bucket_test" +== 679 +-- truncate_limit: 100 +-- Simple test for roundoff error when results should be exact +SELECT x, width_bucket(x::float8, 10, 100, 9) as flt, + width_bucket(x::numeric, 10, 100, 9) as num +FROM generate_series(0, 110, 10) x +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(0, 110, 10) x" +== 680 +-- truncate_limit: 100 +SELECT x, width_bucket(x::float8, 100, 10, 9) as flt, + width_bucket(x::numeric, 100, 10, 9) as num +FROM generate_series(0, 110, 10) x +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(0, 110, 10) x" +== 681 +-- truncate_limit: 100 +-- Another roundoff-error hazard +SELECT width_bucket(0, -1e100::numeric, 1, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(0, - (1e100)::numeric, 1, 10)" +== 682 +-- truncate_limit: 100 +SELECT width_bucket(0, -1e100::float8, 1, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(0, - (1e100)::float8, 1, 10)" +== 683 +-- truncate_limit: 100 +SELECT width_bucket(1, 1e100::numeric, 0, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(1, (1e100)::numeric, 0, 10)" +== 684 +-- truncate_limit: 100 +SELECT width_bucket(1, 1e100::float8, 0, 10) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(1, (1e100)::float8, 0, 10)" +== 685 +-- truncate_limit: 100 +-- Check cases that could trigger overflow or underflow within the calculation +SELECT oper, low, high, cnt, width_bucket(oper, low, high, cnt) +FROM + (SELECT 1.797e+308::float8 AS big, 5e-324::float8 AS tiny) as v, + LATERAL (VALUES + (10.5::float8, -big, big, 1), + (10.5::float8, -big, big, 2), + (10.5::float8, -big, big, 3), + (big / 4, -big / 2, big / 2, 10), + (10.5::float8, big, -big, 1), + (10.5::float8, big, -big, 2), + (10.5::float8, big, -big, 3), + (big / 4, big / 2, -big / 2, 10), + (0, 0, tiny, 4), + (tiny, 0, tiny, 4), + (0, 0, 1, 2147483647), + (1, 1, 0, 2147483647) + ) as sample(oper, low, high, cnt) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ...) v, LATERAL (VALUES (...)) sample(oper, low, high, cnt)" +== 686 +-- truncate_limit: 100 +-- These fail because the result would be out of int32 range: +SELECT width_bucket(1::float8, 0, 1, 2147483647) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(1::float8, 0, 1, 2147483647)" +== 687 +-- truncate_limit: 100 +SELECT width_bucket(0::float8, 1, 0, 2147483647) +-- +FUNCTION: name="width_bucket" function="width_bucket" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT width_bucket(0::float8, 1, 0, 2147483647)" +== 688 +-- truncate_limit: 100 +|-- +-- TO_CHAR() +|-- +SELECT to_char(val, '9G999G999G999G999G999') + FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, '9G999G999G999G999G999') FROM num_data" +== 689 +-- truncate_limit: 100 +SELECT to_char(val, '9G999G999G999G999G999D999G999G999G999G999') + FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, '9G999G999G999G999G999D999G999G999G999G999') FROM num_data" +== 690 +-- truncate_limit: 100 +SELECT to_char(val, '9999999999999999.999999999999999PR') + FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, '9999999999999999.999999999999999PR') FROM num_data" +== 691 +-- truncate_limit: 100 +SELECT to_char(val, '9999999999999999.999999999999999S') + FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, '9999999999999999.999999999999999S') FROM num_data" +== 692 +-- truncate_limit: 100 +SELECT to_char(val, 'MI9999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'MI9999999999999999.999999999999999') FROM num_data" +== 693 +-- truncate_limit: 100 +SELECT to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data" +== 694 +-- truncate_limit: 100 +SELECT to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data" +== 695 +-- truncate_limit: 100 +SELECT to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data" +== 696 +-- truncate_limit: 100 +SELECT to_char(val, '0999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, '0999999999999999.999999999999999') FROM num_data" +== 697 +-- truncate_limit: 100 +SELECT to_char(val, 'S0999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'S0999999999999999.999999999999999') FROM num_data" +== 698 +-- truncate_limit: 100 +SELECT to_char(val, 'FM0999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FM0999999999999999.999999999999999') FROM num_data" +== 699 +-- truncate_limit: 100 +SELECT to_char(val, 'FM9999999999999999.099999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FM9999999999999999.099999999999999') FROM num_data" +== 700 +-- truncate_limit: 100 +SELECT to_char(val, 'FM9999999999990999.990999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FM9999999999990999.990999999999999') FROM num_data" +== 701 +-- truncate_limit: 100 +SELECT to_char(val, 'FM0999999999999999.999909999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FM0999999999999999.999909999999999') FROM num_data" +== 702 +-- truncate_limit: 100 +SELECT to_char(val, 'FM9999999990999999.099999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FM9999999990999999.099999999999999') FROM num_data" +== 703 +-- truncate_limit: 100 +SELECT to_char(val, 'L9999999999999999.099999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'L9999999999999999.099999999999999') FROM num_data" +== 704 +-- truncate_limit: 100 +SELECT to_char(val, 'FM9999999999999999.99999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FM9999999999999999.99999999999999') FROM num_data" +== 705 +-- truncate_limit: 100 +SELECT to_char(val, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_data" +== 706 +-- truncate_limit: 100 +SELECT to_char(val, 'FMS 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_data" +== 707 +-- truncate_limit: 100 +SELECT to_char(val, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_data" +== 708 +-- truncate_limit: 100 +SELECT to_char(val, '999999SG9999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, '999999SG9999999999') FROM num_data" +== 709 +-- truncate_limit: 100 +SELECT to_char(val, 'FM9999999999999999.999999999999999') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, 'FM9999999999999999.999999999999999') FROM num_data" +== 710 +-- truncate_limit: 100 +SELECT to_char(val, '9.999EEEE') FROM num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(val, '9.999EEEE') FROM num_data" +== 711 +-- truncate_limit: 100 +WITH v(val) AS + (VALUES('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan')) +SELECT val, + to_char(val, '9.999EEEE') as numeric, + to_char(val::float8, '9.999EEEE') as float8, + to_char(val::float4, '9.999EEEE') as float4 +FROM v +-- +CTE: "v" +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(val) AS (...) SELECT ... FROM v" +== 712 +-- truncate_limit: 100 +WITH v(exp) AS + (VALUES(-16379),(-16378),(-1234),(-789),(-45),(-5),(-4),(-3),(-2),(-1),(0), + (1),(2),(3),(4),(5),(38),(275),(2345),(45678),(131070),(131071)) +SELECT exp, + to_char(('1.2345e'||exp)::numeric, '9.999EEEE') as numeric +FROM v +-- +CTE: "v" +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(exp) AS (...) SELECT ... FROM v" +== 713 +-- truncate_limit: 100 +WITH v(val) AS + (VALUES('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan')) +SELECT val, + to_char(val, 'MI9999999999.99') as numeric, + to_char(val::float8, 'MI9999999999.99') as float8, + to_char(val::float4, 'MI9999999999.99') as float4 +FROM v +-- +CTE: "v" +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(val) AS (...) SELECT ... FROM v" +== 714 +-- truncate_limit: 100 +WITH v(val) AS + (VALUES('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan')) +SELECT val, + to_char(val, 'MI99.99') as numeric, + to_char(val::float8, 'MI99.99') as float8, + to_char(val::float4, 'MI99.99') as float4 +FROM v +-- +CTE: "v" +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH v(val) AS (...) SELECT ... FROM v" +== 715 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'FM999.9') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, 'FM999.9')" +== 716 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'FM999.') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, 'FM999.')" +== 717 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'FM999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, 'FM999')" +== 718 +-- truncate_limit: 100 +SELECT to_char('12345678901'::float8, 'FM9999999999D9999900000000000000000') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('12345678901'::float8, 'FM9999999999D9999900000000000000000')" +== 719 +-- truncate_limit: 100 +-- Check parsing of literal text in a format string +SELECT to_char('100'::numeric, 'foo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, 'foo999')" +== 720 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f\oo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, E'f\\\\oo999')" +== 721 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f\\oo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, E'f\\\\\\\\oo999')" +== 722 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f\"oo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, E'f\\\\\"oo999')" +== 723 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f\\"oo999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, E'f\\\\\\\\\"oo999')" +== 724 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f"ool"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, 'f\"ool\"999')" +== 725 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f"\ool"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, E'f\"\\\\ool\"999')" +== 726 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f"\\ool"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, E'f\"\\\\\\\\ool\"999')" +== 727 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f"ool\"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, E'f\"ool\\\\\"999')" +== 728 +-- truncate_limit: 100 +SELECT to_char('100'::numeric, 'f"ool\\"999') +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char('100'::numeric, E'f\"ool\\\\\\\\\"999')" +== 729 +-- truncate_limit: 100 +-- TO_NUMBER() +|-- +SET lc_numeric = 'C' +-- +STMT: VariableSetStmt +TRUNCATED: "SET lc_numeric TO \"C\"" +== 730 +-- truncate_limit: 100 +SELECT to_number('-34,338,492', '99G999G999') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('-34,338,492', '99G999G999')" +== 731 +-- truncate_limit: 100 +SELECT to_number('-34,338,492.654,878', '99G999G999D999G999') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('-34,338,492.654,878', '99G999G999D999G999')" +== 732 +-- truncate_limit: 100 +SELECT to_number('<564646.654564>', '999999.999999PR') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('<564646.654564>', '999999.999999PR')" +== 733 +-- truncate_limit: 100 +SELECT to_number('0.00001-', '9.999999S') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('0.00001-', '9.999999S')" +== 734 +-- truncate_limit: 100 +SELECT to_number('5.01-', 'FM9.999999S') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('5.01-', 'FM9.999999S')" +== 735 +-- truncate_limit: 100 +SELECT to_number('5.01-', 'FM9.999999MI') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('5.01-', 'FM9.999999MI')" +== 736 +-- truncate_limit: 100 +SELECT to_number('5 4 4 4 4 8 . 7 8', '9 9 9 9 9 9 . 9 9') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('5 4 4 4 4 8 . 7 8', '9 9 9 9 9 9 . 9 9')" +== 737 +-- truncate_limit: 100 +SELECT to_number('.01', 'FM9.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('.01', 'FM9.99')" +== 738 +-- truncate_limit: 100 +SELECT to_number('.0', '99999999.99999999') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('.0', '99999999.99999999')" +== 739 +-- truncate_limit: 100 +SELECT to_number('0', '99.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('0', '99.99')" +== 740 +-- truncate_limit: 100 +SELECT to_number('.-01', 'S99.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('.-01', 'S99.99')" +== 741 +-- truncate_limit: 100 +SELECT to_number('.01-', '99.99S') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('.01-', '99.99S')" +== 742 +-- truncate_limit: 100 +SELECT to_number(' . 0 1-', ' 9 9 . 9 9 S') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number(' . 0 1-', ' 9 9 . 9 9 S')" +== 743 +-- truncate_limit: 100 +SELECT to_number('34,50','999,99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('34,50', '999,99')" +== 744 +-- truncate_limit: 100 +SELECT to_number('123,000','999G') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('123,000', '999G')" +== 745 +-- truncate_limit: 100 +SELECT to_number('123456','999G999') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('123456', '999G999')" +== 746 +-- truncate_limit: 100 +SELECT to_number('$1234.56','L9,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('$1234.56', 'L9,999.99')" +== 747 +-- truncate_limit: 100 +SELECT to_number('$1234.56','L99,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('$1234.56', 'L99,999.99')" +== 748 +-- truncate_limit: 100 +SELECT to_number('$1,234.56','L99,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('$1,234.56', 'L99,999.99')" +== 749 +-- truncate_limit: 100 +SELECT to_number('1234.56','L99,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('1234.56', 'L99,999.99')" +== 750 +-- truncate_limit: 100 +SELECT to_number('1,234.56','L99,999.99') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('1,234.56', 'L99,999.99')" +== 751 +-- truncate_limit: 100 +SELECT to_number('42nd', '99th') +-- +FUNCTION: name="to_number" function="to_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_number('42nd', '99th')" +== 752 +-- truncate_limit: 100 +RESET lc_numeric +-- +STMT: VariableSetStmt +TRUNCATED: "RESET lc_numeric" +== 753 +-- truncate_limit: 100 +|-- +-- Input syntax +|-- + +CREATE TABLE num_input_test (n1 numeric) +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_input_test (n1 numeric)" +== 754 +-- truncate_limit: 100 +-- good inputs +INSERT INTO num_input_test(n1) VALUES (' 123') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' 123')" +== 755 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' 3245874 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' 3245874 ')" +== 756 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' -93853') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' -93853')" +== 757 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('555.50') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('555.50')" +== 758 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('-555.50') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('-555.50')" +== 759 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('NaN ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('NaN ')" +== 760 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' nan') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' nan')" +== 761 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' inf ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' inf ')" +== 762 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' +inf ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' +inf ')" +== 763 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' -inf ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' -inf ')" +== 764 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' Infinity ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' Infinity ')" +== 765 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' +inFinity ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' +inFinity ')" +== 766 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' -INFINITY ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' -INFINITY ')" +== 767 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('12_000_000_000') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('12_000_000_000')" +== 768 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('12_000.123_456') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('12_000.123_456')" +== 769 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('23_000_000_000e-1_0') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('23_000_000_000e-1_0')" +== 770 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('.000_000_000_123e1_0') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('.000_000_000_123e1_0')" +== 771 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('.000_000_000_123e+1_1') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('.000_000_000_123e+1_1')" +== 772 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0b10001110111100111100001001010') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0b10001110111100111100001001010')" +== 773 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' -0B_1010_1011_0101_0100_1010_1001_1000_1100_1110_1011_0001_1111_0000_1010_1101_0010 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (...)" +== 774 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' +0o112402761777 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' +0o112402761777 ')" +== 775 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('-0O0012_5524_5230_6334_3167_0261') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('-0O0012_5524_5230_6334_3167_0261')" +== 776 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('-0x0000000000000000000000000deadbeef') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('-0x0000000000000000000000000deadbeef')" +== 777 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' 0X_30b1_F33a_6DF0_bD4E_64DF_9BdA_7D15 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' 0X_30b1_F33a_6DF0_bD4E_64DF_9BdA_7D15 ')" +== 778 +-- truncate_limit: 100 +-- bad inputs +INSERT INTO num_input_test(n1) VALUES (' ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' ')" +== 779 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' 1234 %') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' 1234 %')" +== 780 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('xyz') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('xyz')" +== 781 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('- 1234') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('- 1234')" +== 782 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('5 . 0') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('5 . 0')" +== 783 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('5. 0 ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('5. 0 ')" +== 784 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('')" +== 785 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES (' N aN ') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES (' N aN ')" +== 786 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('+NaN') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('+NaN')" +== 787 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('-NaN') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('-NaN')" +== 788 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('+ infinity') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('+ infinity')" +== 789 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('_123') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('_123')" +== 790 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('123_') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('123_')" +== 791 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('12__34') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('12__34')" +== 792 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('123_.456') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('123_.456')" +== 793 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('123._456') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('123._456')" +== 794 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('1.2e_34') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('1.2e_34')" +== 795 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('1.2e34_') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('1.2e34_')" +== 796 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('1.2e3__4') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('1.2e3__4')" +== 797 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0b1112') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0b1112')" +== 798 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0c1112') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0c1112')" +== 799 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0o12345678') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0o12345678')" +== 800 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0x1eg') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0x1eg')" +== 801 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0x12.34') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0x12.34')" +== 802 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0x__1234') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0x__1234')" +== 803 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0x1234_') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0x1234_')" +== 804 +-- truncate_limit: 100 +INSERT INTO num_input_test(n1) VALUES ('0x12__34') +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_input_test (n1) VALUES ('0x12__34')" +== 805 +-- truncate_limit: 100 +SELECT * FROM num_input_test +-- +TABLE: name="num_input_test" schema="" table="num_input_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM num_input_test" +== 806 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('34.5', 'numeric') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('34.5', 'numeric')" +== 807 +-- truncate_limit: 100 +SELECT pg_input_is_valid('34xyz', 'numeric') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('34xyz', 'numeric')" +== 808 +-- truncate_limit: 100 +SELECT pg_input_is_valid('1e400000', 'numeric') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1e400000', 'numeric')" +== 809 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1e400000', 'numeric') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1e400000', 'numeric')" +== 810 +-- truncate_limit: 100 +SELECT pg_input_is_valid('1234.567', 'numeric(8,4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1234.567', 'numeric(8,4)')" +== 811 +-- truncate_limit: 100 +SELECT pg_input_is_valid('1234.567', 'numeric(7,4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1234.567', 'numeric(7,4)')" +== 812 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1234.567', 'numeric(7,4)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1234.567', 'numeric(7,4)')" +== 813 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('0x1234.567', 'numeric') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('0x1234.567', 'numeric')" +== 814 +-- truncate_limit: 100 +|-- +-- Test precision and scale typemods +|-- + +CREATE TABLE num_typemod_test ( + millions numeric(3, -6), + thousands numeric(3, -3), + units numeric(3, 0), + thousandths numeric(3, 3), + millionths numeric(3, 6) +) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_typemod_test (millions numeric(3, -6), thousands numeric(3, -3), units numeric(3..." +== 815 +-- truncate_limit: 100 +-- rounding of valid inputs +INSERT INTO num_typemod_test VALUES (123456, 123, 0.123, 0.000123, 0.000000123) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES (123456, 123, 0.123, 0.000123, 0.000000123)" +== 816 +-- truncate_limit: 100 +INSERT INTO num_typemod_test VALUES (654321, 654, 0.654, 0.000654, 0.000000654) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES (654321, 654, 0.654, 0.000654, 0.000000654)" +== 817 +-- truncate_limit: 100 +INSERT INTO num_typemod_test VALUES (2345678, 2345, 2.345, 0.002345, 0.000002345) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES (2345678, 2345, 2.345, 0.002345, 0.000002345)" +== 818 +-- truncate_limit: 100 +INSERT INTO num_typemod_test VALUES (7654321, 7654, 7.654, 0.007654, 0.000007654) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES (7654321, 7654, 7.654, 0.007654, 0.000007654)" +== 819 +-- truncate_limit: 100 +INSERT INTO num_typemod_test VALUES (12345678, 12345, 12.345, 0.012345, 0.000012345) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES (12345678, 12345, 12.345, 0.012345, 0.000012345)" +== 820 +-- truncate_limit: 100 +INSERT INTO num_typemod_test VALUES (87654321, 87654, 87.654, 0.087654, 0.000087654) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES (87654321, 87654, 87.654, 0.087654, 0.000087654)" +== 821 +-- truncate_limit: 100 +INSERT INTO num_typemod_test VALUES (123456789, 123456, 123.456, 0.123456, 0.000123456) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES (123456789, 123456, 123.456, 0.123456, 0.000123456)" +== 822 +-- truncate_limit: 100 +INSERT INTO num_typemod_test VALUES (987654321, 987654, 987.654, 0.987654, 0.000987654) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES (987654321, 987654, 987.654, 0.987654, 0.000987654)" +== 823 +-- truncate_limit: 100 +INSERT INTO num_typemod_test VALUES ('NaN', 'NaN', 'NaN', 'NaN', 'NaN') +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test VALUES ('NaN', 'NaN', 'NaN', 'NaN', 'NaN')" +== 824 +-- truncate_limit: 100 +SELECT scale(millions), * FROM num_typemod_test ORDER BY millions +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=Select +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(millions), * FROM num_typemod_test ORDER BY millions" +== 825 +-- truncate_limit: 100 +-- invalid inputs +INSERT INTO num_typemod_test (millions) VALUES ('inf') +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test (millions) VALUES ('inf')" +== 826 +-- truncate_limit: 100 +INSERT INTO num_typemod_test (millions) VALUES (999500000) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test (millions) VALUES (999500000)" +== 827 +-- truncate_limit: 100 +INSERT INTO num_typemod_test (thousands) VALUES (999500) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test (thousands) VALUES (999500)" +== 828 +-- truncate_limit: 100 +INSERT INTO num_typemod_test (units) VALUES (999.5) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test (units) VALUES (999.5)" +== 829 +-- truncate_limit: 100 +INSERT INTO num_typemod_test (thousandths) VALUES (0.9995) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test (thousandths) VALUES (0.9995)" +== 830 +-- truncate_limit: 100 +INSERT INTO num_typemod_test (millionths) VALUES (0.0009995) +-- +TABLE: name="num_typemod_test" schema="" table="num_typemod_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_typemod_test (millionths) VALUES (0.0009995)" +== 831 +-- truncate_limit: 100 +|-- +-- Test some corner cases for multiplication +|-- + +select 4790999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 832 +-- truncate_limit: 100 +select 4789999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 833 +-- truncate_limit: 100 +select 4770999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 834 +-- truncate_limit: 100 +select 4769999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 835 +-- truncate_limit: 100 +select trim_scale((0.1 - 2e-16383) * (0.1 - 3e-16383)) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale((0.1 - 2e-16383) * (0.1 - 3e-16383))" +== 836 +-- truncate_limit: 100 +|-- +-- Test some corner cases for division +|-- + +select 999999999999999999999::numeric/1000000000000000000000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (999999999999999999999)::numeric / 1000000000000000000000" +== 837 +-- truncate_limit: 100 +select div(999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT div((999999999999999999999)::numeric, 1000000000000000000000)" +== 838 +-- truncate_limit: 100 +select mod(999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="mod" function="mod" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mod((999999999999999999999)::numeric, 1000000000000000000000)" +== 839 +-- truncate_limit: 100 +select div(-9999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT div(- (9999999999999999999999)::numeric, 1000000000000000000000)" +== 840 +-- truncate_limit: 100 +select mod(-9999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="mod" function="mod" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mod(- (9999999999999999999999)::numeric, 1000000000000000000000)" +== 841 +-- truncate_limit: 100 +select div(-9999999999999999999999::numeric,1000000000000000000000)*1000000000000000000000 + mod(-9999999999999999999999::numeric,1000000000000000000000) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 842 +-- truncate_limit: 100 +select mod (70.0,70) +-- +FUNCTION: name="mod" function="mod" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mod(70.0, 70)" +== 843 +-- truncate_limit: 100 +select div (70.0,70) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT div(70.0, 70)" +== 844 +-- truncate_limit: 100 +select 70.0 / 70 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 70.0 / 70" +== 845 +-- truncate_limit: 100 +select 12345678901234567890 % 123 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 12345678901234567890 % 123" +== 846 +-- truncate_limit: 100 +select 12345678901234567890 / 123 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 12345678901234567890 / 123" +== 847 +-- truncate_limit: 100 +select div(12345678901234567890, 123) +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT div(12345678901234567890, 123)" +== 848 +-- truncate_limit: 100 +select div(12345678901234567890, 123) * 123 + 12345678901234567890 % 123 +-- +FUNCTION: name="div" function="div" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (div(12345678901234567890, 123) * 123) + (12345678901234567890 % 123)" +== 849 +-- truncate_limit: 100 +|-- +-- Test some corner cases for square root +|-- + +select sqrt(1.000000000000003::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt((1.000000000000003)::numeric)" +== 850 +-- truncate_limit: 100 +select sqrt(1.000000000000004::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt((1.000000000000004)::numeric)" +== 851 +-- truncate_limit: 100 +select sqrt(96627521408608.56340355805::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt((96627521408608.56340355805)::numeric)" +== 852 +-- truncate_limit: 100 +select sqrt(96627521408608.56340355806::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt((96627521408608.56340355806)::numeric)" +== 853 +-- truncate_limit: 100 +select sqrt(515549506212297735.073688290367::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt((515549506212297735.073688290367)::numeric)" +== 854 +-- truncate_limit: 100 +select sqrt(515549506212297735.073688290368::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt((515549506212297735.073688290368)::numeric)" +== 855 +-- truncate_limit: 100 +select sqrt(8015491789940783531003294973900306::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt((8015491789940783531003294973900306)::numeric)" +== 856 +-- truncate_limit: 100 +select sqrt(8015491789940783531003294973900307::numeric) +-- +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sqrt((8015491789940783531003294973900307)::numeric)" +== 857 +-- truncate_limit: 100 +|-- +-- Test code path for raising to integer powers +|-- + +select 10.0 ^ -2147483648 as rounds_to_zero +-- +STMT: SelectStmt +TRUNCATED: "SELECT 10.0 ^ -2147483648 AS rounds_to_zero" +== 858 +-- truncate_limit: 100 +select 10.0 ^ -2147483647 as rounds_to_zero +-- +STMT: SelectStmt +TRUNCATED: "SELECT 10.0 ^ -2147483647 AS rounds_to_zero" +== 859 +-- truncate_limit: 100 +select 10.0 ^ 2147483647 as overflows +-- +STMT: SelectStmt +TRUNCATED: "SELECT 10.0 ^ 2147483647 AS overflows" +== 860 +-- truncate_limit: 100 +select 117743296169.0 ^ 1000000000 as overflows +-- +STMT: SelectStmt +TRUNCATED: "SELECT 117743296169.0 ^ 1000000000 AS overflows" +== 861 +-- truncate_limit: 100 +-- cases that used to return inaccurate results +select 3.789 ^ 21.0000000000000000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 3.789 ^ 21.0000000000000000" +== 862 +-- truncate_limit: 100 +select 3.789 ^ 35.0000000000000000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 3.789 ^ 35.0000000000000000" +== 863 +-- truncate_limit: 100 +select 1.2 ^ 345 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1.2 ^ 345" +== 864 +-- truncate_limit: 100 +select 0.12 ^ (-20) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0.12 ^ -20" +== 865 +-- truncate_limit: 100 +select 1.000000000123 ^ (-2147483648) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1.000000000123 ^ -2147483648" +== 866 +-- truncate_limit: 100 +select coalesce(nullif(0.9999999999 ^ 23300000000000, 0), 0) as rounds_to_zero +-- +STMT: SelectStmt +TRUNCATED: "SELECT COALESCE(NULLIF(0.9999999999 ^ 23300000000000, 0), 0) AS rounds_to_zero" +== 867 +-- truncate_limit: 100 +select round(((1 - 1.500012345678e-1000) ^ 1.45e1003) * 1e1000) +-- +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(((1 - 1.500012345678e-1000) ^ 1.45e1003) * 1e1000)" +== 868 +-- truncate_limit: 100 +-- cases that used to error out +select 0.12 ^ (-25) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0.12 ^ -25" +== 869 +-- truncate_limit: 100 +select 0.5678 ^ (-85) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0.5678 ^ -85" +== 870 +-- truncate_limit: 100 +select coalesce(nullif(0.9999999999 ^ 70000000000000, 0), 0) as underflows +-- +STMT: SelectStmt +TRUNCATED: "SELECT COALESCE(NULLIF(0.9999999999 ^ 70000000000000, 0), 0) AS underflows" +== 871 +-- truncate_limit: 100 +-- negative base to integer powers +select (-1.0) ^ 2147483646 +-- +STMT: SelectStmt +TRUNCATED: "SELECT -1.0 ^ 2147483646" +== 872 +-- truncate_limit: 100 +select (-1.0) ^ 2147483647 +-- +STMT: SelectStmt +TRUNCATED: "SELECT -1.0 ^ 2147483647" +== 873 +-- truncate_limit: 100 +select (-1.0) ^ 2147483648 +-- +STMT: SelectStmt +TRUNCATED: "SELECT -1.0 ^ 2147483648" +== 874 +-- truncate_limit: 100 +select (-1.0) ^ 1000000000000000 +-- +STMT: SelectStmt +TRUNCATED: "SELECT -1.0 ^ 1000000000000000" +== 875 +-- truncate_limit: 100 +select (-1.0) ^ 1000000000000001 +-- +STMT: SelectStmt +TRUNCATED: "SELECT -1.0 ^ 1000000000000001" +== 876 +-- truncate_limit: 100 +-- integer powers of 10 +select n, 10.0 ^ n as "10^n", (10.0 ^ n) * (10.0 ^ (-n)) = 1 as ok +from generate_series(-20, 20) n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(-20, 20) n" +== 877 +-- truncate_limit: 100 +|-- +-- Tests for raising to non-integer powers +|-- + +-- special cases +select 0.0 ^ 0.0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0.0 ^ 0.0" +== 878 +-- truncate_limit: 100 +select (-12.34) ^ 0.0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT -12.34 ^ 0.0" +== 879 +-- truncate_limit: 100 +select 12.34 ^ 0.0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 12.34 ^ 0.0" +== 880 +-- truncate_limit: 100 +select 0.0 ^ 12.34 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0.0 ^ 12.34" +== 881 +-- truncate_limit: 100 +-- NaNs +select 'NaN'::numeric ^ 'NaN'::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::numeric ^ 'NaN'::numeric" +== 882 +-- truncate_limit: 100 +select 'NaN'::numeric ^ 0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::numeric ^ 0" +== 883 +-- truncate_limit: 100 +select 'NaN'::numeric ^ 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'NaN'::numeric ^ 1" +== 884 +-- truncate_limit: 100 +select 0 ^ 'NaN'::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0 ^ 'NaN'::numeric" +== 885 +-- truncate_limit: 100 +select 1 ^ 'NaN'::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 ^ 'NaN'::numeric" +== 886 +-- truncate_limit: 100 +-- invalid inputs +select 0.0 ^ (-12.34) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0.0 ^ -12.34" +== 887 +-- truncate_limit: 100 +select (-12.34) ^ 1.2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT -12.34 ^ 1.2" +== 888 +-- truncate_limit: 100 +-- cases that used to generate inaccurate results +select 32.1 ^ 9.8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 32.1 ^ 9.8" +== 889 +-- truncate_limit: 100 +select 32.1 ^ (-9.8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 32.1 ^ -9.8" +== 890 +-- truncate_limit: 100 +select 12.3 ^ 45.6 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 12.3 ^ 45.6" +== 891 +-- truncate_limit: 100 +select 12.3 ^ (-45.6) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 12.3 ^ -45.6" +== 892 +-- truncate_limit: 100 +-- big test +select 1.234 ^ 5678 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1.234 ^ 5678" +== 893 +-- truncate_limit: 100 +|-- +-- Tests for EXP() +|-- + +-- special cases +select exp(0.0) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp(0.0)" +== 894 +-- truncate_limit: 100 +select exp(1.0) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp(1.0)" +== 895 +-- truncate_limit: 100 +select exp(1.0::numeric(71,70)) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp((1.0)::numeric(71, 70))" +== 896 +-- truncate_limit: 100 +select exp('nan'::numeric) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp('nan'::numeric)" +== 897 +-- truncate_limit: 100 +select exp('inf'::numeric) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp('inf'::numeric)" +== 898 +-- truncate_limit: 100 +select exp('-inf'::numeric) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp('-inf'::numeric)" +== 899 +-- truncate_limit: 100 +select coalesce(nullif(exp(-5000::numeric), 0), 0) as rounds_to_zero +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT COALESCE(NULLIF(exp(- 5000::numeric), 0), 0) AS rounds_to_zero" +== 900 +-- truncate_limit: 100 +select coalesce(nullif(exp(-10000::numeric), 0), 0) as underflows +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT COALESCE(NULLIF(exp(- 10000::numeric), 0), 0) AS underflows" +== 901 +-- truncate_limit: 100 +-- cases that used to generate inaccurate results +select exp(32.999) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp(32.999)" +== 902 +-- truncate_limit: 100 +select exp(-32.999) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp(-32.999)" +== 903 +-- truncate_limit: 100 +select exp(123.456) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp(123.456)" +== 904 +-- truncate_limit: 100 +select exp(-123.456) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp(-123.456)" +== 905 +-- truncate_limit: 100 +-- big test +select exp(1234.5678) +-- +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exp(1234.5678)" +== 906 +-- truncate_limit: 100 +|-- +-- Tests for generate_series +|-- +select * from generate_series(0.0::numeric, 4.0::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series((0.0)::numeric, (4.0)::numeric)" +== 907 +-- truncate_limit: 100 +select * from generate_series(0.1::numeric, 4.0::numeric, 1.3::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series((0.1)::numeric, (4.0)::numeric, (1.3)::numeric)" +== 908 +-- truncate_limit: 100 +select * from generate_series(4.0::numeric, -1.5::numeric, -2.2::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series((4.0)::numeric, - (1.5)::numeric, - (2.2)::numeric)" +== 909 +-- truncate_limit: 100 +-- Trigger errors +select * from generate_series(-100::numeric, 100::numeric, 0::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(- 100::numeric, 100::numeric, 0::numeric)" +== 910 +-- truncate_limit: 100 +select * from generate_series(-100::numeric, 100::numeric, 'nan'::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(- 100::numeric, 100::numeric, 'nan'::numeric)" +== 911 +-- truncate_limit: 100 +select * from generate_series('nan'::numeric, 100::numeric, 10::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('nan'::numeric, 100::numeric, 10::numeric)" +== 912 +-- truncate_limit: 100 +select * from generate_series(0::numeric, 'nan'::numeric, 10::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(0::numeric, 'nan'::numeric, 10::numeric)" +== 913 +-- truncate_limit: 100 +select * from generate_series('inf'::numeric, 'inf'::numeric, 10::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('inf'::numeric, 'inf'::numeric, 10::numeric)" +== 914 +-- truncate_limit: 100 +select * from generate_series(0::numeric, 'inf'::numeric, 10::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(0::numeric, 'inf'::numeric, 10::numeric)" +== 915 +-- truncate_limit: 100 +select * from generate_series(0::numeric, '42'::numeric, '-inf'::numeric) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(0::numeric, '42'::numeric, '-inf'::numeric)" +== 916 +-- truncate_limit: 100 +-- Checks maximum, output is truncated +select (i / (10::numeric ^ 131071))::numeric(1,0) + from generate_series(6 * (10::numeric ^ 131071), + 9 * (10::numeric ^ 131071), + 10::numeric ^ 131071) as a(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(6 * (10::numeric ^ 131071), 9 * (10::numeric ^ 131071), 10::numer..." +== 917 +-- truncate_limit: 100 +-- Check usage with variables +select * from generate_series(1::numeric, 3::numeric) i, generate_series(i,3) j +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(1::numeric, 3::numeric) i, generate_series(i, 3) j" +== 918 +-- truncate_limit: 100 +select * from generate_series(1::numeric, 3::numeric) i, generate_series(1,i) j +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(1::numeric, 3::numeric) i, generate_series(1, i) j" +== 919 +-- truncate_limit: 100 +select * from generate_series(1::numeric, 3::numeric) i, generate_series(1,5,i) j +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(1::numeric, 3::numeric) i, generate_series(1, 5, i) j" +== 920 +-- truncate_limit: 100 +|-- +-- Tests for LN() +|-- + +-- Invalid inputs +select ln(-12.34) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(-12.34)" +== 921 +-- truncate_limit: 100 +select ln(0.0) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(0.0)" +== 922 +-- truncate_limit: 100 +-- Some random tests +select ln(1.2345678e-28) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(1.2345678e-28)" +== 923 +-- truncate_limit: 100 +select ln(0.0456789) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(0.0456789)" +== 924 +-- truncate_limit: 100 +select ln(0.349873948359354029493948309745709580730482050975) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(0.349873948359354029493948309745709580730482050975)" +== 925 +-- truncate_limit: 100 +select ln(0.99949452) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(0.99949452)" +== 926 +-- truncate_limit: 100 +select ln(1.00049687395) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(1.00049687395)" +== 927 +-- truncate_limit: 100 +select ln(1234.567890123456789) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(1234.567890123456789)" +== 928 +-- truncate_limit: 100 +select ln(5.80397490724e5) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(5.80397490724e5)" +== 929 +-- truncate_limit: 100 +select ln(9.342536355e34) +-- +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ln(9.342536355e34)" +== 930 +-- truncate_limit: 100 +|-- +-- Tests for LOG() (base 10) +|-- + +-- invalid inputs +select log(-12.34) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(-12.34)" +== 931 +-- truncate_limit: 100 +select log(0.0) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(0.0)" +== 932 +-- truncate_limit: 100 +-- some random tests +select log(1.234567e-89) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(1.234567e-89)" +== 933 +-- truncate_limit: 100 +select log(3.4634998359873254962349856073435545) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(3.4634998359873254962349856073435545)" +== 934 +-- truncate_limit: 100 +select log(9.999999999999999999) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(9.999999999999999999)" +== 935 +-- truncate_limit: 100 +select log(10.00000000000000000) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(10.00000000000000000)" +== 936 +-- truncate_limit: 100 +select log(10.00000000000000001) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(10.00000000000000001)" +== 937 +-- truncate_limit: 100 +select log(590489.45235237) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(590489.45235237)" +== 938 +-- truncate_limit: 100 +|-- +-- Tests for LOG() (arbitrary base) +|-- + +-- invalid inputs +select log(-12.34, 56.78) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(-12.34, 56.78)" +== 939 +-- truncate_limit: 100 +select log(-12.34, -56.78) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(-12.34, -56.78)" +== 940 +-- truncate_limit: 100 +select log(12.34, -56.78) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(12.34, -56.78)" +== 941 +-- truncate_limit: 100 +select log(0.0, 12.34) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(0.0, 12.34)" +== 942 +-- truncate_limit: 100 +select log(12.34, 0.0) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(12.34, 0.0)" +== 943 +-- truncate_limit: 100 +select log(1.0, 12.34) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(1.0, 12.34)" +== 944 +-- truncate_limit: 100 +-- some random tests +select log(1.23e-89, 6.4689e45) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(1.23e-89, 6.4689e45)" +== 945 +-- truncate_limit: 100 +select log(0.99923, 4.58934e34) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(0.99923, 4.58934e34)" +== 946 +-- truncate_limit: 100 +select log(1.000016, 8.452010e18) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(1.000016, 8.452010e18)" +== 947 +-- truncate_limit: 100 +select log(3.1954752e47, 9.4792021e-73) +-- +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT log(3.1954752e47, 9.4792021e-73)" +== 948 +-- truncate_limit: 100 +|-- +-- Tests for scale() +|-- + +select scale(numeric 'NaN') +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale('NaN'::numeric)" +== 949 +-- truncate_limit: 100 +select scale(numeric 'inf') +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale('inf'::numeric)" +== 950 +-- truncate_limit: 100 +select scale(NULL::numeric) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(NULL::numeric)" +== 951 +-- truncate_limit: 100 +select scale(1.12) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(1.12)" +== 952 +-- truncate_limit: 100 +select scale(0) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(0)" +== 953 +-- truncate_limit: 100 +select scale(0.00) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(0.00)" +== 954 +-- truncate_limit: 100 +select scale(1.12345) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(1.12345)" +== 955 +-- truncate_limit: 100 +select scale(110123.12475871856128) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(110123.12475871856128)" +== 956 +-- truncate_limit: 100 +select scale(-1123.12471856128) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(-1123.12471856128)" +== 957 +-- truncate_limit: 100 +select scale(-13.000000000000000) +-- +FUNCTION: name="scale" function="scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT scale(-13.000000000000000)" +== 958 +-- truncate_limit: 100 +|-- +-- Tests for min_scale() +|-- + +select min_scale(numeric 'NaN') is NULL +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale('NaN'::numeric) IS NULL" +== 959 +-- truncate_limit: 100 +-- should be true +select min_scale(numeric 'inf') is NULL +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale('inf'::numeric) IS NULL" +== 960 +-- truncate_limit: 100 +-- should be true +select min_scale(0) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(0)" +== 961 +-- truncate_limit: 100 +-- no digits +select min_scale(0.00) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(0.00)" +== 962 +-- truncate_limit: 100 +-- no digits again +select min_scale(1.0) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(1.0)" +== 963 +-- truncate_limit: 100 +-- no scale +select min_scale(1.1) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(1.1)" +== 964 +-- truncate_limit: 100 +-- scale 1 +select min_scale(1.12) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(1.12)" +== 965 +-- truncate_limit: 100 +-- scale 2 +select min_scale(1.123) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(1.123)" +== 966 +-- truncate_limit: 100 +-- scale 3 +select min_scale(1.1234) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(1.1234)" +== 967 +-- truncate_limit: 100 +-- scale 4, filled digit +select min_scale(1.12345) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(1.12345)" +== 968 +-- truncate_limit: 100 +-- scale 5, 2 NDIGITS +select min_scale(1.1000) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(1.1000)" +== 969 +-- truncate_limit: 100 +-- 1 pos in NDIGITS +select min_scale(1e100) +-- +FUNCTION: name="min_scale" function="min_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min_scale(1e100)" +== 970 +-- truncate_limit: 100 +-- very big number + +|-- +-- Tests for trim_scale() +|-- + +select trim_scale(numeric 'NaN') +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale('NaN'::numeric)" +== 971 +-- truncate_limit: 100 +select trim_scale(numeric 'inf') +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale('inf'::numeric)" +== 972 +-- truncate_limit: 100 +select trim_scale(1.120) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(1.120)" +== 973 +-- truncate_limit: 100 +select trim_scale(0) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(0)" +== 974 +-- truncate_limit: 100 +select trim_scale(0.00) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(0.00)" +== 975 +-- truncate_limit: 100 +select trim_scale(1.1234500) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(1.1234500)" +== 976 +-- truncate_limit: 100 +select trim_scale(110123.12475871856128000) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(110123.12475871856128000)" +== 977 +-- truncate_limit: 100 +select trim_scale(-1123.124718561280000000) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(-1123.124718561280000000)" +== 978 +-- truncate_limit: 100 +select trim_scale(-13.00000000000000000000) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(-13.00000000000000000000)" +== 979 +-- truncate_limit: 100 +select trim_scale(1e100) +-- +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(1e100)" +== 980 +-- truncate_limit: 100 +|-- +-- Tests for SUM() +|-- + +-- cases that need carry propagation +SELECT SUM(9999::numeric) FROM generate_series(1, 100000) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(9999::numeric) FROM generate_series(1, 100000)" +== 981 +-- truncate_limit: 100 +SELECT SUM((-9999)::numeric) FROM generate_series(1, 100000) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum((-9999)::numeric) FROM generate_series(1, 100000)" +== 982 +-- truncate_limit: 100 +|-- +-- Tests for VARIANCE() +|-- +CREATE TABLE num_variance (a numeric) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_variance (a numeric)" +== 983 +-- truncate_limit: 100 +INSERT INTO num_variance VALUES (0) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_variance VALUES (0)" +== 984 +-- truncate_limit: 100 +INSERT INTO num_variance VALUES (3e-500) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_variance VALUES (3e-500)" +== 985 +-- truncate_limit: 100 +INSERT INTO num_variance VALUES (-3e-500) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_variance VALUES (-3e-500)" +== 986 +-- truncate_limit: 100 +INSERT INTO num_variance VALUES (4e-500 - 1e-16383) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_variance VALUES (4e-500 - 1e-16383)" +== 987 +-- truncate_limit: 100 +INSERT INTO num_variance VALUES (-4e-500 + 1e-16383) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_variance VALUES (-4e-500 + 1e-16383)" +== 988 +-- truncate_limit: 100 +-- variance is just under 12.5e-1000 and so should round down to 12e-1000 +SELECT trim_scale(variance(a) * 1e1000) FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=Select +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(variance(a) * 1e1000) FROM num_variance" +== 989 +-- truncate_limit: 100 +-- check that parallel execution produces the same result +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 990 +-- truncate_limit: 100 +ALTER TABLE num_variance SET (parallel_workers = 4) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE num_variance SET (parallel_workers=4)" +== 991 +-- truncate_limit: 100 +SET LOCAL parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL parallel_setup_cost TO 0" +== 992 +-- truncate_limit: 100 +SET LOCAL max_parallel_workers_per_gather = 4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 4" +== 993 +-- truncate_limit: 100 +SELECT trim_scale(variance(a) * 1e1000) FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=Select +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT trim_scale(variance(a) * 1e1000) FROM num_variance" +== 994 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 995 +-- truncate_limit: 100 +-- case where sum of squares would overflow but variance does not +DELETE FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_variance" +== 996 +-- truncate_limit: 100 +INSERT INTO num_variance SELECT 9e131071 + x FROM generate_series(1, 5) x +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_variance SELECT 9e131071 + x FROM generate_series(1, 5) x" +== 997 +-- truncate_limit: 100 +SELECT variance(a) FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT variance(a) FROM num_variance" +== 998 +-- truncate_limit: 100 +-- check that parallel execution produces the same result +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 999 +-- truncate_limit: 100 +ALTER TABLE num_variance SET (parallel_workers = 4) +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE num_variance SET (parallel_workers=4)" +== 1000 +-- truncate_limit: 100 +SET LOCAL parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL parallel_setup_cost TO 0" +== 1001 +-- truncate_limit: 100 +SET LOCAL max_parallel_workers_per_gather = 4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL max_parallel_workers_per_gather TO 4" +== 1002 +-- truncate_limit: 100 +SELECT variance(a) FROM num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=Select +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT variance(a) FROM num_variance" +== 1003 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 1004 +-- truncate_limit: 100 +DROP TABLE num_variance +-- +TABLE: name="num_variance" schema="" table="num_variance" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_variance" +== 1005 +-- truncate_limit: 100 +|-- +-- Tests for GCD() +|-- +SELECT a, b, gcd(a, b), gcd(a, -b), gcd(-b, a), gcd(-b, -a) +FROM (VALUES (0::numeric, 0::numeric), + (0::numeric, numeric 'NaN'), + (0::numeric, 46375::numeric), + (433125::numeric, 46375::numeric), + (43312.5::numeric, 4637.5::numeric), + (4331.250::numeric, 463.75000::numeric), + ('inf', '0'), + ('inf', '42'), + ('inf', 'inf') + ) AS v(a, b) +-- +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +FUNCTION: name="gcd" function="gcd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, gcd(a, b), gcd(a, - b), gcd(- b, a), gcd(- b, - a) FROM (VALUES (...)) v(a, b)" +== 1006 +-- truncate_limit: 100 +|-- +-- Tests for LCM() +|-- +SELECT a,b, lcm(a, b), lcm(a, -b), lcm(-b, a), lcm(-b, -a) +FROM (VALUES (0::numeric, 0::numeric), + (0::numeric, numeric 'NaN'), + (0::numeric, 13272::numeric), + (13272::numeric, 13272::numeric), + (423282::numeric, 13272::numeric), + (42328.2::numeric, 1327.2::numeric), + (4232.820::numeric, 132.72000::numeric), + ('inf', '0'), + ('inf', '42'), + ('inf', 'inf') + ) AS v(a, b) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, lcm(a, b), lcm(a, - b), lcm(- b, a), lcm(- b, - a) FROM (VALUES (...)) v(a, b)" +== 1007 +-- truncate_limit: 100 +SELECT lcm(9999 * (10::numeric)^131068 + (10::numeric^131068 - 1), 2) +-- +FUNCTION: name="lcm" function="lcm" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lcm((9999 * (10::numeric ^ 131068)) + ((10::numeric ^ 131068) - 1), 2)" +== 1008 +-- truncate_limit: 100 +-- overflow + +|-- +-- Tests for factorial +|-- +SELECT factorial(4) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT factorial(4)" +== 1009 +-- truncate_limit: 100 +SELECT factorial(15) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT factorial(15)" +== 1010 +-- truncate_limit: 100 +SELECT factorial(100000) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT factorial(100000)" +== 1011 +-- truncate_limit: 100 +SELECT factorial(0) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT factorial(0)" +== 1012 +-- truncate_limit: 100 +SELECT factorial(-4) +-- +FUNCTION: name="factorial" function="factorial" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT factorial(-4)" +== 1013 +-- truncate_limit: 100 +|-- +-- Tests for pg_lsn() +|-- +SELECT pg_lsn(23783416::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_lsn(23783416::numeric)" +== 1014 +-- truncate_limit: 100 +SELECT pg_lsn(0::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_lsn(0::numeric)" +== 1015 +-- truncate_limit: 100 +SELECT pg_lsn(18446744073709551615::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_lsn((18446744073709551615)::numeric)" +== 1016 +-- truncate_limit: 100 +SELECT pg_lsn(-1::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_lsn(- 1::numeric)" +== 1017 +-- truncate_limit: 100 +SELECT pg_lsn(18446744073709551616::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_lsn((18446744073709551616)::numeric)" +== 1018 +-- truncate_limit: 100 +SELECT pg_lsn('NaN'::numeric) +-- +FUNCTION: name="pg_lsn" function="pg_lsn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_lsn('NaN'::numeric)" diff --git a/parser/testdata/summary_truncate/postgres_regress/numeric_big.metadata.json b/parser/testdata/summary_truncate/postgres_regress/numeric_big.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/numeric_big.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/numeric_big.test b/parser/testdata/summary_truncate/postgres_regress/numeric_big.test new file mode 100644 index 0000000..dc6c96c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/numeric_big.test @@ -0,0 +1,5284 @@ +== 001 +-- truncate_limit: 100 +-- ****************************** +-- * Test suite for the Postgres NUMERIC data type +-- ****************************** + +-- Must drop tables created by short numeric test. +DROP TABLE num_data +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_data" +== 002 +-- truncate_limit: 100 +DROP TABLE num_exp_add +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_exp_add" +== 003 +-- truncate_limit: 100 +DROP TABLE num_exp_sub +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_exp_sub" +== 004 +-- truncate_limit: 100 +DROP TABLE num_exp_div +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_exp_div" +== 005 +-- truncate_limit: 100 +DROP TABLE num_exp_mul +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_exp_mul" +== 006 +-- truncate_limit: 100 +DROP TABLE num_exp_sqrt +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_exp_sqrt" +== 007 +-- truncate_limit: 100 +DROP TABLE num_exp_ln +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_exp_ln" +== 008 +-- truncate_limit: 100 +DROP TABLE num_exp_log10 +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_exp_log10" +== 009 +-- truncate_limit: 100 +DROP TABLE num_exp_power_10_ln +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_exp_power_10_ln" +== 010 +-- truncate_limit: 100 +DROP TABLE num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE num_result" +== 011 +-- truncate_limit: 100 +CREATE TABLE num_data (id int4, val numeric(1000,800)) +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_data (id int4, val numeric(1000, 800))" +== 012 +-- truncate_limit: 100 +CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(1000, 800))" +== 013 +-- truncate_limit: 100 +CREATE TABLE num_exp_sub (id1 int4, id2 int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_sub (id1 int4, id2 int4, expected numeric(1000, 800))" +== 014 +-- truncate_limit: 100 +CREATE TABLE num_exp_div (id1 int4, id2 int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_div (id1 int4, id2 int4, expected numeric(1000, 800))" +== 015 +-- truncate_limit: 100 +CREATE TABLE num_exp_mul (id1 int4, id2 int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_mul (id1 int4, id2 int4, expected numeric(1000, 800))" +== 016 +-- truncate_limit: 100 +CREATE TABLE num_exp_sqrt (id int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_sqrt (id int4, expected numeric(1000, 800))" +== 017 +-- truncate_limit: 100 +CREATE TABLE num_exp_ln (id int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_ln (id int4, expected numeric(1000, 800))" +== 018 +-- truncate_limit: 100 +CREATE TABLE num_exp_log10 (id int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_log10 (id int4, expected numeric(1000, 800))" +== 019 +-- truncate_limit: 100 +CREATE TABLE num_exp_power_10_ln (id int4, expected numeric(1000,800)) +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_exp_power_10_ln (id int4, expected numeric(1000, 800))" +== 020 +-- truncate_limit: 100 +CREATE TABLE num_result (id1 int4, id2 int4, result numeric(1000,800)) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE num_result (id1 int4, id2 int4, result numeric(1000, 800))" +== 021 +-- truncate_limit: 100 +-- ****************************** +-- * The following EXPECTED results are computed by bc(1) +-- * with a scale of 1000 +-- ****************************** + +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 022 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,0,'0') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 0, '0')" +== 023 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,0,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 0, '0')" +== 024 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 0, '0')" +== 025 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 0, 'NaN')" +== 026 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,1,'85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 027 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,1,'-85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 028 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,1,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 1, '0')" +== 029 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,1,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 1, '0')" +== 030 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,2,'-994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 031 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,2,'994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 032 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,2,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 2, '0')" +== 033 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,2,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 2, '0')" +== 034 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,3,'-60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 035 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,3,'60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 036 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,3,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 3, '0')" +== 037 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,3,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 3, '0')" +== 038 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,4,'5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 039 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,4,'-5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 040 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,4,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 4, '0')" +== 041 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,4,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 4, '0')" +== 042 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,5,'-652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 043 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,5,'652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 044 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,5,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 5, '0')" +== 045 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,5,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 5, '0')" +== 046 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,6,'.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 047 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,6,'-.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 048 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,6,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 6, '0')" +== 049 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,6,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 6, '0')" +== 050 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,7,'-818934540071845742') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (0, 7, '-818934540071845742')" +== 051 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,7,'818934540071845742') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (0, 7, '818934540071845742')" +== 052 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,7,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 7, '0')" +== 053 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,7,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 7, '0')" +== 054 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,8,'8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 055 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,8,'-8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 056 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,8,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 8, '0')" +== 057 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,8,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 8, '0')" +== 058 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (0,9,'54863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 059 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (0,9,'-54863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 060 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (0,9,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (0, 9, '0')" +== 061 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (0,9,'0') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (0, 9, '0')" +== 062 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,0,'85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 063 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,0,'85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 064 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (1, 0, '0')" +== 065 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (1, 0, 'NaN')" +== 066 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,1,'170486.79080049955252152479695727201571965474311716541919780029226071455736587237347615553466832461907447637054203186991790701615551214692555785671028648640897898741246882118067609728317430043806625387779037980513762118868084887015059202190301421555269486602797852927777567694581746398790609996101506730430853942556475840126871131898407356048450541232591147357021858041662012293323494543567675306406079659294204054863522259037763051870433216859794083051717080761509518250300466106939998045710070') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 067 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,1,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (1, 1, '0')" +== 068 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,1,'7266436459.363324713115467666113895787027372854351303425444968800459979742082292257107107767894843498525848597439323325297125474674300428669958003640228730876886174255457103020291514229439701871032118057857763809224712818579091741996335014138185389554630910658876423205103697147288306070059640369158894028731728589073730895396494400175420670713113234800826523252075036892246807434088405522834549449664122407363485486902219500109237667016524913027290777216477989904700729228025571098410870506256758678625928245828210775042611512394316804583459576285681159178280400209217948833631961377519855502763611693070238579591463373484424582723121059964236704135695706864890193388054537703767833595331866551990460050750959493829603581882430597105627056085260296454181999581594565113210481151487049158699087454047624433576922179904629') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 069 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,1,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 070 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,2,'-994877526002806872754342148663997.64812998474240514147207095573950146764154822009863493316394610578375247334825932838513167168342610420582834742950389452212867974756590355021495169819086060202117180229196935525386766373096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 071 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,2,'994877526002806872754342148834484.43893048429492666626902822775522112238466538551783273345620682034111834572173548391979999630250058057637037929942180153828419189449146140692523818459983958943364062347264545253704196416903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 072 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,2,'-84806738323879544552397401815149740513.8505875535743013876823142649666132764556588225959336097903898464616542203793600590311980154402068027051522932586050753865288419084437796768749509032177577451738712965496693249429231838833655025794915864261585848007162358912070811805298210095333433397862313304655108809804359760907473898420016370058274978588765092161529583480924554820756527238472641797198545539410039895140087686344382628317530286295498797849942258314364503000942821309916954725689781458590617068629906894951122301020797266469357701283289275708774593896770378558232444454118891917258610753077932026885574920166837998049508644891327208474213193224700658584824407382455480657734911543930195324144216374573825') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 073 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,2,'-.000000000000000000000000000085682300757901809257711279577127388124986344391495296640171942990079130291883279872719240502687189411421655284515420074848478500192127657883342858267913417679786356766341637336955924836847768457039175660279784295612167899455618405343686908907695358239088351870495830739180518509859269437015797489301844593920484927630172344269378248455657186218762679357609204333669024237648538465053048724383898528808961206696787294681884412485427843796696788390072124570957047672341581447744981862017791206857428430183366004980966398716823512288330174863890117558744630102020144500158878244146399686532935435591262767487823942606452349972401012308378888947381934278131785907155692007064636085000405504866631011593239041758448995933095907216863744502344014999804306234830774259496097549717476344048') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 074 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,3,'-60302029489319384367663884408085672236.83687099063256754698860828386302509843815398979402006244388708674093244201278399438376682321121138429850885935540924586964982855913223221441591310211730902799041126800414795030815514254713522692405212716783388698431088814919226444677188004928663343696636297536500970117716818423689175692808344185016908913828066250587407384563498516598672584120143890364303296142744031320345312431817858545326010704685255237541162931904446804064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 075 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,3,'60302029489319384367663884408085842723.62767149018508907178556555587874475318127115521321786273614780129829831438626014991843514783028586066905089122532715288580534070605779007112619958852628801540288008918482404759132944298520148080184250697297150817299173701934285646867489426483932830299434150464278537812298564822479785688909850915447762856384542090714278516461905872647123125352735037721325154184406043613668806975385533851732090363979459292404685190942209855935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 076 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,3,'-5140349743195574373979577554212527512597024.162480344833040409158673429491690439298506850052285119390701002577176786023622062742050099464897084793357329597395417632908812044304066963549928478520702505283307379218587635434673128958824348493758429380623577527186462464399974242800361134191519694694139153279582776168995426125926314513926640766117733774558011741611075336271613675760116784769700605008122422944290652448956922432960815546502965310676913079866511016221573557684245901002643719965652152439520727383305120298495304784052489867651462175349450610643411043707261107569691076730261762793560088893354750383257372118118753366377402045596735023445172252225346164608897913115394905485106225627590643805003075069931177395059698550161546962768768895596088478488887530518018212441345360153523733317120037436403475909117998647781920105313938836144009539683') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 077 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,3,'-.000000000000000000000000000000001413607404628860353773457807436398753936801768769045711604884548436548520368932184112069166807060840219636509423284498981041814526856251281381511288768719259120481595036745286884246627534964287523188738499223075292690431699417313258943941279343383979626641848305343592679057491670166887054819766294147341982669243114259272404203080347707713358471397866402657818267495050115642987782080912962056565478445923456884713049272637646637760989004917643369240372476411912794578381690666695711891846833983534126217706309741885844723208036219144146342212915129560758201609824034610223907791643110990898577049488934294259106725414517181607988173722432655731491050637087261030314548853334338835938120502930424813699221083197863303458179445322810087784892821862085562891180364134284641396475') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 078 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,4,'5329378275943663322300488.64471790965256505869684245785528331091076155554650629138833809683459634328609777839510066435612911583108717191216693735823717997111970662575497378762952496582183738308720094529950793570383580785385569873278068217936841324404119828637880370718028782103860007754579779716996004352284614661690063919125301052941328989181561787543541920734755989452320799185700078241880935083616978140555713297241612718277766918005268951861880490889884082730841740604517529391011862694381726143520658746305661338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 079 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,4,'-5329378275943663322130001.85391741010004353389988518583956365616764439012730849109607738227723047091262162286043233973705463946054514004224903034208166782419414876904468730122054597840936856190652484801633363526576955397606531892764306099068756437389060626447578949162759295501062154826802212022414257953494004665588557188694447110384853149054690655645134564686305448219729651828678220200218922790293483596988037990835533058983562863141746692824117439019450865871047657552800448629502344444081260036580660700595591338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 080 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,4,'454294299613767152878025320780.534199313974295807138790763501115780294529340799108297697573066187975311338382917022391830256203305238757334106943821060545424417350991354829668286194840925251162479496893943917530660694097932059166013476064988623431110002057735318529554555260199417935495388243829261809007709919225000608711536928171687251088217591210419208480251102484043683131687013687838713055660405381318396419588727500715930145098362997142075433472039319292466570912777345841400769387321465602989947078951135489852486382469990409873227894248208197179481868230244584527040573428134962626267135732247029762468417273891700661832893497067151409134724061246612631376075173287264787886064622106855886785805818642123776489793586531950438285720668411465570116161790343538663297713926678759640594912243360541590368666922379919514826022141331900181') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 081 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,4,'.000000000000000000015994998100440878014888861029956505927201309704413242103407885948184870841766875212766910686894450511886242468216220470061916924303252919423028993720180330014505454865704155281502763018913215741264982350384245753394656021401865680441649920273268554396350483440173848850052788410943178207336328451359951614056237100465802151856198860908371340425459435127133071447273887829397881221098443685586506647314622864702873235212396755866459409263439958011711379929751157260020133239574261188528305921244365838405372320186907437842180388704854605498842516581811515413843298370501194935797268161171428747542997504369133579105180311662221854071962295818264211400101689450830279979372422749150894553349570063000769685274875561760334738424509532610467832951796852051505383374693614022043010735004494395190') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 082 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,5,'-652670387.03916046850422757312745971450663862747133703839829692066597367760104802542475264601221776157515632293978442027199108085723617181683235487266149426304575903892721468296143475297345699313102262188759506518376019936160961709578829069446312051432780603656651983414612264636232727512091101057374054475214114364113300402823059519499217878746766275164739724770556122895799337810694888119810524986616938847385753562624139431982468828696587199570410008890188532132652095915565323400735066310142303225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 083 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,5,'652840873.82996096805674909792441698652235828221445420381749472095823439215841389779822880154688608619423079931032645214190898787339168396375791272937178074945473802633968350414211085025663129356908887576538544498889782055029046596593888271636613472988050090259449836342389832330814473910881711053475561205644968306669776242949930651397625234795216816397330872127577980937461350104018382663378200293023018506679957617487661691020231880567020416430204091941905612894161614165865789507675064355852373225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 084 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,5,'-55643106304872.575994253221940844841058071061962511162776681458310912066379595519265546225338405882027547140476045378015935579066580347282075024392379464189067155567624835346798806677988850250198082355055954078446421075165109896091047534711081616362392995575466807084807876544560268050611445006601394735810211678919646667455478469014906335433468365011768049600750224822391684377238242162320161552720449713229523135506671063115436813348612986916614320012995541575293478341408982118538094438068036422562665160411591652618670802973618768526197813319204816293073794413317669922144705633308090832805914096147659820167569140291210526520361556881576175809360614782817717579318298657744021133210954279487777567785280633309576696708168342539425395482429923273623865667723482418178781573723597156804085501875735112311466228778929147929') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 085 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,5,'-.000130590057635351941758745900947472461593749814351229292370661147301124533787181489468804246182606762727711479707901680546780430454163647774077629503207962424213266902732555945190365467801995495570282501722505521485829885605904543846887348545254658726343578684749830307120625129857380290225370772763609458975555029415082569247186899112975387051141777417911244576134390940441209829852154391377911942082738699481875795620569383196133124499983396562167632007454221121465745085962247988140942672429187053671899537331280701003778040796615094903602095098880716919238394057384949891444700347825726273725378453454782330181608182747900774711384845635284701538541452235224216112380245660177463043471814071809869894647262285332580556739424040615194137651616350340752691170045698234853734471923738591898290468792787543896') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 086 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,6,'85243.44233732197133191329295927531563604777955507322414928382967007765263923984471408038635831036097817458527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 087 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,6,'85243.34846317758118961150399799670008360696356209219504851646259063690472663252876207514831001425809630178527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 088 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,6,'4001.075404054519813215296429095020391062109905613738157927030437221793757373268325953178030040276107574363822832168160758728653712686313134828282109532831190239521843808940611025488601517574653932032236616573457735900045655665690517797280666732780030171712864961531623060353548802466577910774711998056232872212688464691036260746751992072745518373073825852119460094113694393273456369345499434994672730920070410547163082189385645712866100999708173472360864669110044660667614583576570496399103026286828660558854973376227247132815728164629722965145778698957093136175449225024685874279280018547740') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 089 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,6,'1816120.848909727306817960620941575637231136442992819290405125420545200026620306446043740992108329883383706060582482495616151605111275635501481354526017831484915013545483361715432312183101964395505340188909970344423950565285639911521082834494088840596716495422427543520536844348040681236845850482165744696068209384509064196671206362539077218412355776790921130042376467606683622970728503408501481791356294886150690067651815776445750760428874351556866105285911902433352126498951242195408782804314174041618879250740246352525074791310920062276490422853700893340860452528740673590486626464460321410814395342850270921486724297414692313177440726749004398703147904603937755702369682956482832074779404350351752662820773690162594400557957241676636030332988289683112176900913522668426137377289536793838959751008646843014106876005') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 090 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,7,'-818934540071760498.60459975022373923760152136399214017262844141729040109985386964272131706381326192223266583769046276181472898406504104649192224392653722107164485675679551050629376558940966195135841284978096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 091 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,7,'818934540071930985.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 092 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,7,'-69808760806266041400340.70700818693892852138813934414383886494691670042143650609934777814995087699409404201920249076407981012095999320858479644760715204999741683528746097757549835956359129287002171391961763797857794730120426599135099619822532290339000466211195776337667123320942107370731349851576864242697412616810236323676004067839744992733887503405311090677026008324895177587064547630828026123718296429295638934384446325302964896473296829265805737112709269803814942537657996725913938408781715328945194948010970') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 093 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,7,'-.000000000000104090609479936344103210175655521317012597986331111866307697262848964666360492361638117930801818899121383806224630563676018240181412174154250663423230239912527388431901852952893943812666142740182651125508583527237123596541789628675379232473721293630968882045044077795828674268595016625198802475186587918019739056755398151182369187670251750080227679555002307777300392769289647975058449905106584837938556260801229545589323224752038795423164214112897202147313792076165011373139219134850954217300915326944185918762838321705825423789073869940092569940135329697980600082436317664012683589681419530904283106912171330819469065141821685734295058255484933744156717782754922568796985634397878149984177882018261742637463462647452140104146195353696596211873925359508622779658904411330975862442989437933211964821') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 094 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,8,'8497071467.03603749330791582407836434318377133169438097066269854720538319012928851657498035372443556191720308219530866834905045144302106406146277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 095 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,8,'-8496900980.24523699375539429928140707116805167695126380524350074691312247557192264420150419818976723729812860582476663647913254442686555191453722107164485675679551050629376558940966195135841284978096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 096 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,8,'724311956372274.0135050255361637906710330203036651743488213007179039756514944640108625580172737414192938789413338554327986697518463087452612658955180411327002900979574347739956600177846996063741787205122007268468674386396156638261992679442768654367111433834151087792255469957061758837789341439211010331332174981459471333376067541234901538285101103690622656631026001337239036711179989456674399137008584021283568040818388709554256523118702728176420022080138548890713013682480239784198421500241995499841675772793497485550923152267616622892846304530712344886979674416990935007952941652591352603797627920865960622077762568060903908151958000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 097 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,8,'.000010032191786198542900505683562217892317481076466949299850809276743457759270150820565375820388277409258249926696079166209409657808406245382887790534127749833677458375931047385994887406206232330491317602830654688957983804698568410728278089250379255157030886262396950539100566975000094268415749476738358914633948867977798590927055566888255636132486899287919515638902721543629183577900872078173883974905921239149419877613723476347774771230668479296621531969573505480695490386225866950545725121902534610730154727385072738079149623798073810167706094070842646222833137345669922898403368997676634709281456818189049718956207208697021706186341405575300648248555331280690778367620868775005181264547924615247991795542738868003191757946979714250339430363902549866892041102771965653407197094250270379367437342632741280710') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 098 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (1,9,'54948723.74225051983134098996071145685528795757427462111901537365053896571438476055974853245403475510333627298551845046116291696445177112567064282766115207407461565363967417615506303416694032848457927390574251904212425813072768882213388082765916956736282110801611726537663292922699021333445658549608928179155685881583228490235606377831724593358583903616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 099 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (1,9,'-54778236.95145002027881946516375418483956830283115745569981757335827825115701888818627237691936643048426179661497641859124500994829625897874508497095086558766563666622720535497438693688376602804651302002795213923698663694204683995198328880575615535181012624198813873609885725228117274934655048553507421448724831939026752650108735245933317237310133362383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 100 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (1,9,'4676749348240.390309875431213992853550297086049749814750492488995108783145961719774217441193547534210468967573344456866203963659951312519988497979489304488948342258375915152429008993288817366720647491166024151209542534474867042837694499222928509320280684557676243780452100132238968233413333851595648146954975713386711764268506890884764704949969602122157394714663532141060559896359465918874990769222345665160127552795532197771168442486088776803398878354288847069602460071745966589164282641033852314335279121191855487126430176047553895892632834940595958394834437871886013513058514896870683979585091413977173250824451205330441299000850618134248917380244749589254309567551846327349592529960432446947239714236828401206843011440433362544797025114476612133622499094287321570559088587999417440664282418005102546343020409520421747216') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 101 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (1,9,'.001553736563217204408368240901181555234014339476186598647410198373122572205209277343865051610898136462487966496673511261433286284257044548634547569923035899634327495195510767312478861719221916387940027268721306540663743713345337497285507595251328382906111997524508729275471287648008479480805967901972481289402930660848950039779707354469389216931774094174326513465502460315792834278614886136688161679443873815113442220055827192996984074129528034845339130162104547166079591654852164993577408422015514100323825529286511720963047269483211930770803479398243069649400360625259869765138545866815758888670363356947311319523139395191102286838888146829667276592755438606664644975648828848738708349790766370694194763606850690923803984129157519048493985198591771429264967247245289970213262206709011468289046840862597010969') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 102 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,0,'-994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 103 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,0,'-994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 104 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (2, 0, '0')" +== 105 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (2, 0, 'NaN')" +== 106 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,1,'-994877526002806872754342148663997.64812998474240514147207095573950146764154822009863493316394610578375247334825932838513167168342610420582834742950389452212867974756590355021495169819086060202117180229196935525386766373096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 107 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,1,'-994877526002806872754342148834484.43893048429492666626902822775522112238466538551783273345620682034111834572173548391979999630250058057637037929942180153828419189449146140692523818459983958943364062347264545253704196416903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 108 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,1,'-84806738323879544552397401815149740513.8505875535743013876823142649666132764556588225959336097903898464616542203793600590311980154402068027051522932586050753865288419084437796768749509032177577451738712965496693249429231838833655025794915864261585848007162358912070811805298210095333433397862313304655108809804359760907473898420016370058274978588765092161529583480924554820756527238472641797198545539410039895140087686344382628317530286295498797849942258314364503000942821309916954725689781458590617068629906894951122301020797266469357701283289275708774593896770378558232444454118891917258610753077932026885574920166837998049508644891327208474213193224700658584824407382455480657734911543930195324144216374573825') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 109 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,1,'-11671021799770914903865020509.301561107153561058074179843542446420696517132461554451075945807420674211966679216615407057626541711186781735967334896541890595771915856783008831770988426637435694856170266346306640678577376310547806764332837625966429200996250687908930748245035578756314083608655163891041399241377675534416837659335561005203219889972336214863417948542956735403991871098341470996860469878038840964359144637726669728240650066795729910649523281308716277906908340457162235831526838308777581569974551673352306004330423694524256415657620427590352277556907586751621496248973165690360552007637570957980230685679819820147036159174977086193494572117089582758015847544798464543446227632367713941117001423437766840744488426025388612316819120660814681298624293065972395923651314350558006567251033289878238407790871784676348196394482477767774') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 110 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,2,'-1989755052005613745508684297498482.08706046903733180774109918349472259002621360561646766662015292612487081906999481230493166798592668478219872672892569606041287164205736495714018988279070019145481242576461480779090962790') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 111 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,2,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (2, 2, '0')" +== 112 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,2,'989781291745465665243281323944996915810556285052564220274237162526.1617859904902612197894543199389468971679632139059029459520163585971122643624316475417489000981872666677202334180945949860058384424993911721081868337499377890298636260338063268639283065887210924895929155083478140340889209440025415565915964293989840603863813531303253038823629712989041722072693449251635519992922148998556112923060331794396659338057474019846675262291146025') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 113 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,2,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 114 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,3,'-60303024366845387174536638750234506721.2758014749274942132576365116182462208228193753118527959000939070820507877345194783035668195137119648748792386548310474079340204536236936213411512867171486174240518914767934028451971067161683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 115 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,3,'60301034611793381560791130065937008239.1887410058901624055165373281235236307966057696953851292799409809571799686645246659986351515277852800926805119259053513475211488115663286642009614039264484259692394657121785950542874788161683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 116 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,3,'59993133911282372667149627097418449223835595194300848703012380022306762.154418449236691515146061305380465061074531890529497774836941002526095632166401249277270674802626154774328055399254982998368191676630276960361274433270795772477146870294928855773172789856196219950097157391050424577381777627004101100872747943673762087675405200265837631665464736842180920496158545887039337399558993437594084473932658319914390365451919627956823980800124880375978662052111797881386060353490432427832058851094210488804887183034572364751639107535041308434932952695103493677600969712634416241541391613699710826602011076372592299807609658979777598672141389319098817824624950794758296679318319299142035') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 117 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,3,'.000016498242835741013709859217005931279826178662180173096568520102488480129191427472581644597420895622947234184547373944996197105916093347103336318249582032230903680989710242610024298937774441533502282949127537125997753002819456724709929935850697744632904111143787011103837624936502324835260843148595669524694347566421203164808527739207590986975750648112133699756328511947175496694080071202064255118777680958612315513441989609682655431197367166056616661045712867189326408877133865572680407329449150282415810958772293869902662884761202424695742898573841869524376684740249281181605067345203479719345061595919652192297531638467223956758315591610733251562492794891852151639643060692698365496208796638230566761231611376199140556503620471090364900792180618741355091923808605890415081571900697282725022629812561702118') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 118 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,4,'-994877520673428596810678826533995.79421257464236160757218576989993781147390382997132644206786872350652200243563770552469933194637146474528320738725486418004701192337175478117026439697031462361180324038544450723753402846519731908503949116978812841497201119103409772457270340059605961197538918709309004130294868847110690336360689446090125918336908930881873778405661757289469281163974774492810850778950071063044769131228124355961427111369335109426492177657001035045332525699055300921341010989742896430768506909949340276549373661076950964959025967328861569387160956730002517417236732463510495205173523163676450203614971844583064927040066684531931069310935516821795449174271052747559395296525950219449541557191520903507653089998307641491381797101485104546410643') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 119 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,4,'-994877531332185148698005470964486.29284789439497020016891341359478477855230977564514122455228420261834881663435710678023233603955522003691551934167083188036585971868561017596992548582038556784300918537917030055337559943480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 120 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,4,'-5302078674303935968062773235453828254014583744527466365136.236414807326868572353809920518232561005161225922028750078608989965741402418802255050636954800114792425419735155504035469350521800895164087027043476055514245942961100610551646034472084954313670284875310691807937254054948742125729353864014122131419164449567115006621212424805182687707372956385102095255735458593389920872596796806885847543910224476727171570873698525606016990229936284811067826588349092841322512643043008589065847223683467371925773023109720951609815041012521485326120380123169545818055967455575736140138663815073081494226676896278654189873597341203197903408668523514375373841493189836809506003729379742035629498519683885268256481104619815130659628225053833297766479068686119691010593208135616363994230674606991733148502293102108193522604968743948323130517040609601859735899914987426089053869350663') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 121 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,4,'-186677971.517539861245390308778107722315862721823627804195528485535806132067679059453022306691281662574091826898288146790399178357754908901382135796783067563944022498807930452234032896817601590728156392188660701355670595952594500812333935362955625137944589981298793332621503315902294100258945995827423279442031218510259915311555745581797315793010762585658196457363672908315687720174516274528662385172326028870945153551774300419158584379602045442200523311437013776079979639415633358878239012925000523542907592866797199229858272764668664323316251874027468128770456766875866492004650352654523634716923150212263912760225390093339729495231675627059805624175587380165509763048913150826017167286786277908970769297060278191518730887417202276531151575412404467497036737825989088867451153485938272367300939127313445244028528055624') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 122 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,5,'-994877526002806872754342801504871.47809095279915423939648794226185974985600242391612965412218049794216637114648812993201775787765690351615479957141288239552036371132381627958673244764559862836085530643408020551049895730005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 123 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,5,'-994877526002806872754341495993610.60896951623817756834461124123286284017021118170033801249797242818270444792350668237291391010826978126604392715751281366489250793073354867755345743514510156309395711933053460228041067059994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 124 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,5,'649411906691138274293985410502516861224852.2323455192714410716272307781034189160865613770320102043319541634113746032638191509585045862973333645830298922352816245477556264222094036953195419857712804755170632292914187367964994214922001758104594052499795564860466055599417895782179851297585155129541589802249540436678824225950907268084876110445460948679383611117263673106597132046331719468816839434908155684738864149955129235751738204036443603521478609787295079710078973503970964790273461142497259987849074597264522099648376356902360358310245001183020992360260836105404118742418040965190000718736837422434593694808973939805954329718232693154128543253581495885789333274488461716809104532693754070810202831113003978085636579574171344721710232931261731022478029314435363413498991740750878099825781577297965642009156858479681236085226911858782115') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 125 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,5,'1524119409495532727030986.638577103454261465522025182901477334004986357902177024959076085490119358611626688213654669281670407680244740174673394111775678935383154847014211641601227316639834450258566053805263858706381900273201146454036688771735398324537667996974210741719621449948660517037619359095556637235980122706739013220201060795557114248610410815988952748489854367480813823114296393315170621979351958306734282429929421779129764262568942699813166237466796852578307944635545174715298176546980314973426586923195248536376403319094417073026382024413817222396402299695717290716014320518777088811749776114378145110676170242861393274018655137797545194817703831240390631723050378397773341835222892981773205967439339460305257986693600088957772328044922955990976285151896366292514128607363007421484320868718566256882080399264346243272770200676') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 126 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,6,'-994877526002806872754342148749240.99659316232359475297606895243958507460511031229368344962653674268847910587702140353344168594152240599109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 127 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,6,'-994877526002806872754342148749241.09046730671373705476503023105513751542110329332278421699361618343639171319297340877148998204440427879109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 128 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,6,'-46696638263247522384986521136500.479312417066793299922708112595886608370451213741279484136907754744903470430131032928908162742687359367826808123516519335458861613010646992354378739165872253762686683966945711430182491860196341344982195078000259063231136011430995647812149294224699587849791008794261026932467933475782780') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 129 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,6,'-21195986018643887410662481595901800.342199657994285865579781485758715114242459388977583220756870314514884887803267837816669111279417861218648323488364513921592045485003563036021370174294475403630933854767386355037781881144701319212711655881277140183173924089814927297045029394618083349813549439341772734606115369911736164723942330187830605893993276674913563980890459604886172701331890746621222114280438198802989678877404376001410627722336243835841751052795437979198996482216031399073597399901975686733315751292369326904428230195579137225651689857057115970784985439417129044974524632220457594191305254649113470116960582543784928547885740020507755033347968928034294570497118410435615856155184563329718831512839630769097935523279881940380220955993456451396417879773380305142918906742431812580562496634831735169817705720949712410595406012323294829461') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 130 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,7,'-994877526002807691688882220594983.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 131 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,7,'-994877526002806053819802076903499.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 132 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,7,'814739569184924399102711674444306584731316176345067.39834031417849342571224916231092924046722938910652929295271097903377854123984307101079073134405782275535446337229706620713104545454319555885847481531722101704765783025789147453570970090') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 133 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,7,'1214843772391778.127361407585140553741220126410637250571020684739034685508176000812180032686291124045768750332493129822580347351032145964983629059968936201592138368806173099130176852606440296388856520582890650384142745607345709716826703676313341953999327129144154152914234659001555055379537780751567782847296067128932113870102563522810980359433259696591977617184951677390423898232135100000764121508662830515405980450892222598485287609657612482190264517684867291774820716746063133066053446257163185646067618679478975882247893469409405379034723543061767846895135644429012095930584952053545016706315299076691015196261253199176743281648949731423486208098120903720124071047872917636988241710583721537777321338769039241700203546247947405745989053846970910400831817998342969657501678430211657755864160072525313889413731419647001970593') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 134 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,8,'-994877526002806872754333651763017.40289299098701084219066388457144979069028441485513418625082363021182982914675513019536443438529749838106171095037135009526312783302868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 135 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,8,'-994877526002806872754350645735464.68416747805032096555043529892327279933592919076133348036932929591304098992323968210956723360062918640113701577855434596514974380902868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 136 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,8,'-8453460632655529853033389979024265783461224.3195241893307807116624750282852146303290708492834695194274289713076935297734670940696121761483641291930931061232942894577813178566088927221374036301485916497770984757492912292002695944367308880163698595015497307574177176409203214324418237020500352652934909632442547242092296504047310806151851207329042221920888326000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 137 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,8,'-117085929036205907700251.219065234073336548829793284434494573185718678644093751558890746941383215425734761534822966779511801033216479269605150574332107020180872343673157350081102818832254463561564431056604957702984438484261858890324442581609284935850435611342611117035589511568432559140282381526487115307554496353616929034919886387903446436924514812698404129456069856633480965357915969548215985452939172313964007318881987188665231550330515412104367728617802960792164260429920719961650164518261501571220901151359208484337831586551714193024143212288426326740373893030225940355268499071669300664200888186064836443459131985786957267268845966279576380786883200277187591448294590370986026461176853573555996139940001165172158855197070946665074838360933025833716166930231164328918316437195201546383664484983447934244744303265471044295601062898') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 138 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (2,9,'-994877526002806872754342093885760.69667996446358567630831677089993316481039076439881735980566785462673358516198695146576524119916430759085192883825888457383242076882081857926408611052522393579396644731758241837010163568445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 139 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (2,9,'-994877526002806872754342203612721.39038050457374613143278241259478942521582284121765030681448507149813723390800786083916642678676237719134679789066681148658045087323654637787610377226547625566084597844703238942080799221554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 140 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (2,9,'-54582443595378013373024060492546032003692.4875677735896411267274323339692558458420972958075073392126734000341372096298914875892612108329218081214550050039133117695428196702128258481789017059073444323729583900855712795086447886053552786449313809589992185978097430132940882612817775035217244553616977182049775786664446683332098226841743818600819221587510039430478859412452506872131851471967577741190323481953867845129745440745526578327709351120432530702446916035797432129052518980799424635406993848916727957825620638983706180841278402925286540375225365057191075559133035') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 141 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (2,9,'-18133693300409132895168796.074616314168631402221003009151140409826855230810646429042722071403306917323628118792142878282108022292754325022530103525285999179488507720688317761243448898240836430183645778132937666952111134601563043980164547020295727057908447220163534134835130866457657964382363853570827467081988390359191484798677813656413640874450449802233520570178139244957518604566383671867773821069602665918688868868894979351219381089954104823746091972754649316823714354000113723793845707472924569647945844436702275724514171940901057842455729977729388911537391920702753167125695758365521631000334183494148229356487592577177344247694925635113222720411958290166668659311154664393442690740373285505786584987609789805525300762074682544164213490532272590665630428583216403362629445153016404037983825555019274338559686335405719430737559715778') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 142 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,0,'-60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 143 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,0,'-60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 144 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (3, 0, '0')" +== 145 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (3, 0, 'NaN')" +== 146 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,1,'-60302029489319384367663884408085672236.83687099063256754698860828386302509843815398979402006244388708674093244201278399438376682321121138429850885935540924586964982855913223221441591310211730902799041126800414795030815514254713522692405212716783388698431088814919226444677188004928663343696636297536500970117716818423689175692808344185016908913828066250587407384563498516598672584120143890364303296142744031320345312431817858545326010704685255237541162931904446804064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 147 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,1,'-60302029489319384367663884408085842723.62767149018508907178556555587874475318127115521321786273614780129829831438626014991843514783028586066905089122532715288580534070605779007112619958852628801540288008918482404759132944298520148080184250697297150817299173701934285646867489426483932830299434150464278537812298564822479785688909850915447762856384542090714278516461905872647123125352735037721325154184406043613668806975385533851732090363979459292404685190942209855935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 148 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,1,'-5140349743195574373979577554212527512597024.162480344833040409158673429491690439298506850052285119390701002577176786023622062742050099464897084793357329597395417632908812044304066963549928478520702505283307379218587635434673128958824348493758429380623577527186462464399974242800361134191519694694139153279582776168995426125926314513926640766117733774558011741611075336271613675760116784769700605008122422944290652448956922432960815546502965310676913079866511016221573557684245901002643719965652152439520727383305120298495304784052489867651462175349450610643411043707261107569691076730261762793560088893354750383257372118118753366377402045596735023445172252225346164608897913115394905485106225627590643805003075069931177395059698550161546962768768895596088478488887530518018212441345360153523733317120037436403475909117998647781920105313938836144009539683') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 149 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,1,'-707409990019504668223608170643582.082425157530076679823177950190511141917761066423266390864536360056345386873500583953954967225431526056199231768143978526582904071798714789552447782850723926323452633811653766838064983821149041415149067433978085927687765773012158659685363079191901396502099956189371719135315616249471739677995520904113581848295732911534266040260836644379296158092198514963023001686666281725991605685524015227112003429486755206848316731257322742428352116058878710728614841247581716185886403744830796740424927494009978599974431617064012221450054532987372285996679180090592706458366967534834069977644215413076082570497451654516268857039718730203921980307096740864747006176117071983875364434497517026142488015705391255750729200497229031250705777282987863242056223584453312226818451807347197583925624299372040413470456696588043062815') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 150 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,2,'-60303024366845387174536638750234506721.2758014749274942132576365116182462208228193753118527959000939070820507877345194783035668195137119648748792386548310474079340204536236936213411512867171486174240518914767934028451971067161683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 151 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,2,'-60301034611793381560791130065937008239.1887410058901624055165373281235236307966057696953851292799409809571799686645246659986351515277852800926805119259053513475211488115663286642009614039264484259692394657121785950542874788161683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 152 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,2,'59993133911282372667149627097418449223835595194300848703012380022306762.154418449236691515146061305380465061074531890529497774836941002526095632166401249277270674802626154774328055399254982998368191676630276960361274433270795772477146870294928855773172789856196219950097157391050424577381777627004101100872747943673762087675405200265837631665464736842180920496158545887039337399558993437594084473932658319914390365451919627956823980800124880375978662052111797881386060353490432427832058851094210488804887183034572364751639107535041308434932952695103493677600969712634416241541391613699710826602011076372592299807609658979777598672141389319098817824624950794758296679318319299142035') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 153 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,2,'60612.515523995516156897729403721504966784736064970538891936016753206905080265887046037910122269129293912171105589512464185386239562077778499936203155976336284324712221812806801062157592930664021782540155687632208890794166119782594464410498356083266087045927038416810562596141871858142749062925965665039981381277808608946877852933015970874447235220989360704166270479475802673572039541121473138382812420076284458769543418652217394352637294823914346726065145538710933281768776286965107974980550163605068693568717671571780028113969794125200592691656568731359981803586296135840575095063824258761205175762907549288801963550628589530419118771779395037240198270853609924445368393952404606326559485235840170339343865253618184271158932135392539396160392488927771488269959497352568205940636180870805982484030168838833607478593') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 154 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,3,'-120604058978638768735327768816171514960.4645424808176566187741738397417698516194251450072379251800348880392307563990441443022019710414972449675597505807363987554551692651900222855421126906435970433932913571889719978994845855323367077258946341408053951573026251685351209154467743141259617399607044800077950793001538324616896138171819510046467177021260834130168590102540438924579570947287892808562845032715007493401411940720339239705810106866471452994584812284665666') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 155 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,3,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (3, 3, '0')" +== 156 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,3,'3636334760530744652235488357607657374520053530993537920755375319352615385278.023608692512217812784472508939511216316773023870624171279878340621219698109986095090336065266376220109007718694455520948311677863167090936408887147442375455695868593092154861636486745490748828207939155392396090682312136290864359484540126174821846208064763823279315343506148025281475729723686566174395516982893064510403581479746673749128344955124070957545815390178764940816628194640888255387443237798761377617383817511745005525149990207764725040109364671749403389999498572538135588695345112358160274671918953118753964073105250116426665508214894805722798842017943220605600452911496071424281587802689830031742105619630787641205011894680546049982654601956546154572720177337696285354350903475239411654436042931409507429892682706228354459580412759920815932840348933425754970917910500027837428631661182510071352138858') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 157 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,3,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 158 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,4,'-60302029489314054989387940744763542234.98295358053252401308872309802346144227050959966671157134780970446370197110016237152333448347415674483796371931316021552756816073493808344537122580089676304958104270609762310229182150728136567294798680824019082599362332377530165818229609055765904048195574142709698758095302560470195171027219786996322461803443213101532716728918363951912367135900414238535625075942525108530051828834829820554490477645701692374399416239080329365045332525699055300921341010989742896430768506909949340276549373661076950964959025967328861569387160956730002517417236732463510495205173523163676450203614971844583064927040066684531931069310935516821795449174271052747559395296525950219449541557191520903507653089998307641491381797101485104546410643') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 159 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,4,'-60302029489324713745939828071407972725.48158890028513260568545074171830840934891554534052635383222518357552878529888177277886748756734050012959603126757618322788700853025193884017088688974683399381224865109134889560766307825097103477790782590061456916367930139323346273315068375646692125800496305291080749834712822775973790354498408104142209966769395239768969172107040437333428573572464689550003374384624966403962290572373571842567623422963022155546431883766327294954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 160 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,4,'-321372325955692885069615337209737469749246561535004445508427591.072860243358366933071485495726715620133686420023451450292996945184959542770492705998350644739298629407567812798540119555932604687814429669592481327761428042980782672136901602006622227365754036664912989085940235439697789102358431343119457114603363936544931303133371137532006899162833369543279729021228901466728220729625107362063321334489394782322741444425117731922691457341543446841167138481424319752111748042440994701571955325673470021626946676976482516292402239416632497972073915818846704053624707839813514171497746804751780741682011937606462260710753056669269928580460921188286249923152921382198282201761171043384698319895970192114563900025573490442674225227682235790590616707857188385274186584856872573669591460447105688151281208238908470285147895678001948902280493477604361481216667716971590499226735103039') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 161 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,4,'-11315021446594.877643290091276308982961654569173523687151347727612592478433578066762912541361898899908505997444632820107356713116459078630334224890355872486337973552333755378190316811715776951317058334754704988120078733912131691682869448731717816749620336196719541702138949084375907248656748314375183301372633028246109596775255074617515860012417935744433243071057057560464360663978361945666099558526069794464437818864063206829678640156992474597480916575712563493776637239091589972373682399519931569163592317107392231951775499293572134702843085474656152913351183535194499521618027894129537558509428098859715020703897463518891082573242502356303078754574312965093639182648263511466558336912294702019648266054331227425119096294871153811412169351624751542166779635702042223762951850816568617453355571302500885410532963789364822647') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 162 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,5,'-60302029489319384367663884408738513110.66683195868931664491302527038538338065260819361151478340212147889934633981101279593065290940544218360883531149731823374304151252289014494378769385157204705433009477214625880056478643611622410268943757215673170753460135411513114716313801477916713433956086133878890802448531292334570886746283905390661877220497842493537338035961123751393889400517474762491881277080205381424363695095196058838349029211365212855028824622924678684631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 163 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,5,'-60302029489319384367663884407433001849.79771052212833997386114856935638647096681695139572314177791340913988441658803134837154906163605506135872443908341816501241365674229987734175441883907154998906319658504271319733469814941611260503645706198407368762270127105340397375230875953495882740039984314121888705481484090911598074635434289709802794549714765847764347865064280637851906308955404165593747173246944693509650424312007333558709071857299501674917023499921977975368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 164 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,5,'39362489275784146262776411377472433635883331946.794473520543457442955620133347015506556162839462623905489255080102447195050109095701660164272430316804466254467810714209179752718730906325952685817112992943656292503112803950215110778476301809440329937774061163668461957943313261962261081942055908935814323069621279128270849852239727888939033546870208376394878842958202403235309372240005941467570230067124830916866857395233038346727879951123599893174252558078732888910139309038957525961212820831321973219557165558911222848692996406741318948607549825343491479728117062814094258484536263158005174429922237853707635743736923521032098496725445243775790161216159399180889906705265012270270348146530113428221072591696851818281866095288773371414866822270689959827332258348570976075184933893434327278299820594014788148344260948638847457822697682605612771344335201258128') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 165 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,5,'92380711368470856513514428781.033155715252174277753317877861994356621252232374386687048394529670637693505779282500567256835271428113529026462111032257747830329068594622091282098767000694818101994264352932243278144124687156236926607422077479412495979777588932692081795130282128890441931602671468684153168580234070246201722180460130467506344034452687371838907269162119534950946217165384250603250357360223255177692065141037447374172264943732616165429783010079281851748804739433821308362193703012671569249508710820679009084891198169587484117171861141580870066764275087111843275285564262902405980617569581840831518012986031156042600391943605532635833608358301306456966765206853910579231447150839538731157206153540873916893579943906851149770881336811951119112558311734171557608362620988555075663589827484854016702489324791126228380209309587206299') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 166 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,6,'-60302029489319384367663884408085757480.1853341682137571584926062805631087054017160819890685789064777236456590745415460695320768374693076860837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 167 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,6,'-60302029489319384367663884408085757480.2792083126038994602815675591786611462177090630181693462735571643935716818574980747701251335721895588837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 168 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,6,'-2830400711649493468815157129316992649.40542786074520931471973065281957756940496588853021620372179463538053123396140685749478530925306163968207226329985017644835203709485594362663495728106061878665324856417118064730721101615473194292620972173690618491026470353143141125614124440035267592258385099934706896692953497971326605145704135723011753705907329979207428661473172503098296622281647255008204864404416199384701720347319806375450632245634238172654086373193251877533131784268854289406126119630708578053354762596511353053106459297339360827562281168219966099848212') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 169 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,6,'-1284742031601444539630782308463065726620.121021225455596762466053504195700643301310745151565435123335541550963124666304408503436412726848834604336377169205828654564329888653766451656774534718709065521243637375270687684572524302099749018591530352756390467862377335526634920857924031482455373589053524922608255779040656019538392173139295812160325688504210040741075388404155144782519528791757450256668977268409265390016721724966592135644698341754332845002439113523127047593325646484654291494607100188094186116001064043796216982681807318598789324900462932294782971663150070521334398542559480877366424630693734132836518604260869235580641521264976411493166969530737254118968281271908306432918913600567757535151861421384835424322504855607676315840963696944683182767935565256136130185809101891760917733694553800748568697830680328155128016670099315391685422333') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 170 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,7,'-60302029489319384368482818948157603222.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 171 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,7,'-60302029489319384366844949868013911738.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 172 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,7,'49383414785234649002982046297226894664526726187218771083.0993243619030008310875293647868815940421844461627295157812843657782639833900543200310573708100000958929315945039020410482966753145208427035917753919085618457760620513481628641658765820294863970581642745379331727722585319163262763708386199720411053619449096019862596221607526610103408936214184850115071874430846697061554769773328338028749631552202705583855831155461651414320570061181212214810086436100771547030013079997847086') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 173 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,7,'73634737013325927185.787791148221519354461791539553527545166847382784629235192342551464898036004011575416717008403527685470842765455409054592207142526523023201841973047779202013398235864494503216973882479116841765663948294836180515686647139678530220909072497288527276378202532400736141014848907023234659020093073127450778982904578906877634654521825977382116752537063128793631412296206704078569268566614023846282524151679028060869175439188773864994186109445961525301841201265289707928211114515861536069733921800160245586536759625418951427346236213019358749196674633237197452976517130405065120577692737021174118093373953642724512531935525024447977867020930500433287279183436509990047372809400167546185096048971157700858970777301410692908939206693154161335335755844997198191427289546263182822280127912118140820265025555165337881999926') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 174 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,8,'-60302029489319384367663884399588771256.5916339968771732477072012126949734214868901845505193155307646111690097978112797961939995859130827784737422228762767014427842766445950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 175 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,8,'-60302029489319384367663884416582743703.8729084839404833710669726270467964301325349604567186096492702768702209585877643481082023851284144664938175277044596973126708926205950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 176 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,8,'-512385513828318260570283740065493064477880918352.732624553690077857674083796435724202494963885926573907185100543184828131859183999195040110586155435203949963570735841632689374488877298209082579317039061893012560130258753218955057387206477423088065663401594359617882154814262843273526859406265633827109554791772242178864873774889091687515990672487380368975556580539271333144212685871370972163560839446696514092637412587953506052848750866803569213269271165856310101244342151576488190595936869490659700946174362872797854591188391982770203203644172999264143929484089237665313698600170041324566984832357000400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 177 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,8,'-7096872691348467943606706217.907270287823269424282176534343841939501231816905820949045946136373255017076943323578903040918266385724756894003692978391468202345397178445216069294845721607024056189567609414049207292919519881725733381453217071918292453682942046440563446278374996563501512335133749731529362537349288419883140401056747081065947774593869673146309163791076953204291951821124894409171722911526435445719071769008713367057971351892550570642991097981458696464929009464411568672010548002196406312721789582428747564855324072212842315229302959908665089850886951261233852165624100634055045684536311382452553544676139507899503993644452161529145849579200003677255968757773363970434791501820320494192909660871475590637419913907191608957830524390049664686282439567943053924245852983990958276537000732363895444894582579142752920882750130052682') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 178 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (3,9,'-60302029489319384367663884408030893999.8854209703537480818248540990234567956069965340942024890856088355839135538265116174644003927269495876835324407641642359213535695803871472434650475144516723617632059130297610134243891145006222068960999879308472500422640481972089756410157246974765071949782242392661524488959954348903412713930092273629207697480131360047867213863018127928853922173643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 179 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (3,9,'-60302029489319384367663884408140620960.5791215104639085369493197407183130560124286109130354360944260524553172025725325268378015783145476572840273098165721628341015996848028750420770651761919246816300854441592109844750954710317145008297946462099581451150385769713261452744310496166494545449824802407416426304041583975713483424241727236417259479541129474082301376239522310995725648773643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 180 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (3,9,'-3308379209762459471107480259839508279070920437.883503980178028214343751083865562028455061662673132221930429904398963590401793045470444301883103141901787466923883803951815572606105617157736442670792467625964359169270739534412932791178258858918086886061702512427989129732248215348301444245772127142869263635282888226326427510486246184233225114523636171202034558843515894542952126988613018789833835507734620046994907453602573865012044120483116345444810078666601100257620969379968264504287700045822481492526688635364586344704730579892342786173395802035361824932075736340405960099542224953439044947229246847140957298841482874444906129049023002897135347878048572628834749795298712449864571996898774444932083319581439741625832405434317985988163261591679157437224404970927012111196724239860528859217322132733404472897289') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 181 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (3,9,'-1099128766678422054524173986658.839339966689456265703816212189145237878729886466041806078542573981227645802109969871638687985985845489422516004202630099080709709893022100481258818112345013009059633421290241583864468453396484606925071369550998772875840640325758308835852391176503689677263605949075815552026731067384737231681068134099746550363063940273625924224721503126912810251607546172009765059506591787282558727077669973711491157840340631805422942099954647016059576777054339588421998882440726473698513560202030309804089250300097589174314677765341104767702983421063649104691583044460507666600260994707192787133590502137391691330098102374713996115782701417107878938473243874299874872852713499024851414757892169376458916467621226859152075901273014182163212783658933754507272478777304254191033562324994395916168496097385872331012258027431094381') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 182 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,0,'5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 183 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,0,'5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 184 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (4, 0, '0')" +== 185 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (4, 0, 'NaN')" +== 186 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,1,'5329378275943663322300488.64471790965256505869684245785528331091076155554650629138833809683459634328609777839510066435612911583108717191216693735823717997111970662575497378762952496582183738308720094529950793570383580785385569873278068217936841324404119828637880370718028782103860007754579779716996004352284614661690063919125301052941328989181561787543541920734755989452320799185700078241880935083616978140555713297241612718277766918005268951861880490889884082730841740604517529391011862694381726143520658746305661338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 187 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,1,'5329378275943663322130001.85391741010004353389988518583956365616764439012730849109607738227723047091262162286043233973705463946054514004224903034208166782419414876904468730122054597840936856190652484801633363526576955397606531892764306099068756437389060626447578949162759295501062154826802212022414257953494004665588557188694447110384853149054690655645134564686305448219729651828678220200218922790293483596988037990835533058983562863141746692824117439019450865871047657552800448629502344444081260036580660700595591338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 188 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,1,'454294299613767152878025320780.534199313974295807138790763501115780294529340799108297697573066187975311338382917022391830256203305238757334106943821060545424417350991354829668286194840925251162479496893943917530660694097932059166013476064988623431110002057735318529554555260199417935495388243829261809007709919225000608711536928171687251088217591210419208480251102484043683131687013687838713055660405381318396419588727500715930145098362997142075433472039319292466570912777345841400769387321465602989947078951135489852486382469990409873227894248208197179481868230244584527040573428134962626267135732247029762468417273891700661832893497067151409134724061246612631376075173287264787886064622106855886785805818642123776489793586531950438285720668411465570116161790343538663297713926678759640594912243360541590368666922379919514826022141331900181') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 189 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,1,'62519544780217042176.800424689664850775296526267109332647921183817056683200043718160298562843864918741523494444361916531159341418970534833628106062976341639276761669219281771109561175175033739624472497927501467465456946098280878993371659461957361369508794842102784763955539708800574418468150309301129490186416766691183270872711413796386178009615777589066235359283212636467980113350635181915492452697347977967985810294150853782607014649150457138118264698071689065469752702524632313088938504181640435324554007553994564705401249228914199354821595855823113730697333390936834057091883654016371107974899726642500486005445063301647520527084320363513388355471718583708935211830796440056542408492723718088396437530207347815505844074508948817594746824098278470533148171941442049323578854023683167934569551595335539887777638716651319134577441') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 190 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,2,'-994877520673428596810678826533995.79421257464236160757218576989993781147390382997132644206786872350652200243563770552469933194637146474528320738725486418004701192337175478117026439697031462361180324038544450723753402846519731908503949116978812841497201119103409772457270340059605961197538918709309004130294868847110690336360689446090125918336908930881873778405661757289469281163974774492810850778950071063044769131228124355961427111369335109426492177657001035045332525699055300921341010989742896430768506909949340276549373661076950964959025967328861569387160956730002517417236732463510495205173523163676450203614971844583064927040066684531931069310935516821795449174271052747559395296525950219449541557191520903507653089998307641491381797101485104546410643') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 191 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,2,'994877531332185148698005470964486.29284789439497020016891341359478477855230977564514122455228420261834881663435710678023233603955522003691551934167083188036585971868561017596992548582038556784300918537917030055337559943480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 192 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,2,'-5302078674303935968062773235453828254014583744527466365136.236414807326868572353809920518232561005161225922028750078608989965741402418802255050636954800114792425419735155504035469350521800895164087027043476055514245942961100610551646034472084954313670284875310691807937254054948742125729353864014122131419164449567115006621212424805182687707372956385102095255735458593389920872596796806885847543910224476727171570873698525606016990229936284811067826588349092841322512643043008589065847223683467371925773023109720951609815041012521485326120380123169545818055967455575736140138663815073081494226676896278654189873597341203197903408668523514375373841493189836809506003729379742035629498519683885268256481104619815130659628225053833297766479068686119691010593208135616363994230674606991733148502293102108193522604968743948323130517040609601859735899914987426089053869350663') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 193 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,2,'-.000000005356818439105666775800262590702859770599410113087721172791624002387236505438218124867814437523686300450045582100868990117124343222534568799037421944272316277130975314766456260710406160143182498931595199129228915695802952695510723443157825968340043198200740606202264287904755124946591110599335909404657109057432686191440989434662797205973563889238804413861126260401987949920244286377128599413927273444061572120561496904543200956508673923547626768641271397088562966176629018606103663605145666976048261236691866387601532424530473754175270500777679603569715192364542901360534980926452487443629100484491344001509360344122933911316486556042277769848194790964257060927912344609376571637126617813506411190014141992988288983968823792971270853369317867326071952900448455162898476163801382836761898292684175721846') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 194 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,3,'-60302029489314054989387940744763542234.98295358053252401308872309802346144227050959966671157134780970446370197110016237152333448347415674483796371931316021552756816073493808344537122580089676304958104270609762310229182150728136567294798680824019082599362332377530165818229609055765904048195574142709698758095302560470195171027219786996322461803443213101532716728918363951912367135900414238535625075942525108530051828834829820554490477645701692374399416239080329365045332525699055300921341010989742896430768506909949340276549373661076950964959025967328861569387160956730002517417236732463510495205173523163676450203614971844583064927040066684531931069310935516821795449174271052747559395296525950219449541557191520903507653089998307641491381797101485104546410643') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 195 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,3,'60302029489324713745939828071407972725.48158890028513260568545074171830840934891554534052635383222518357552878529888177277886748756734050012959603126757618322788700853025193884017088688974683399381224865109134889560766307825097103477790782590061456916367930139323346273315068375646692125800496305291080749834712822775973790354498408104142209966769395239768969172107040437333428573572464689550003374384624966403962290572373571842567623422963022155546431883766327294954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 196 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,3,'-321372325955692885069615337209737469749246561535004445508427591.072860243358366933071485495726715620133686420023451450292996945184959542770492705998350644739298629407567812798540119555932604687814429669592481327761428042980782672136901602006622227365754036664912989085940235439697789102358431343119457114603363936544931303133371137532006899162833369543279729021228901466728220729625107362063321334489394782322741444425117731922691457341543446841167138481424319752111748042440994701571955325673470021626946676976482516292402239416632497972073915818846704053624707839813514171497746804751780741682011937606462260710753056669269928580460921188286249923152921382198282201761171043384698319895970192114563900025573490442674225227682235790590616707857188385274186584856872573669591460447105688151281208238908470285147895678001948902280493477604361481216667716971590499226735103039') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 197 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,3,'-.000000000000088378091435340426596348183959201660680284222502095357746364378698792730669202270228092348823133529449019715406417264278615046537007844589547485282959556860316942508808911542109265489435572674031608663747132688980867386885961271358592278360097086532747883342438036287136994589308551796702164612609710942175900921197001888540314760352113821737014875886635147123114456910985089625906448913621495025509697742196814421833448856595853403450682101743559369637786458968714240975228615283970739279506239628546165569688434254286341567486905374255702980370754235630955328837646999003123103831262789115646588779721625156078607919060762857866951417867378220773543985422722165221371084387943737083254760594128718841665355053236168688218864433967871311858292181233490194833547273501436630325295640020916257836404') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 198 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,4,'10658756551887326644430490.49863531975260859259672764369484696707840594567381478248441547911182681419871940125553300409318375529163231195441596770031884779531385539479966108885007094423120594499372579331584157096960536182992101766042374317005597761793180455085459319880788077604922162581381991739410262305778619327278621107819748163326182138236252443188676485421061437672050451014378298442099857873910461737543751288077145777261329781147015644685997929909334948601889398157317978020514207138462986180101319446901252677846098070081948065342276861225678086539994965165526535072979009589652953672647099592770056310833870145919866630936137861378128966356409101651457894504881209406948099561100916885616958192984693820003384717017236405797029790907178714') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 199 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,4,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (4, 4, '0')" +== 200 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,4,'28402272808100253242547006276715304015308580784958.804614276533085644370816876160290159450291717634111299841065255625515058118012211808741402904995080624675460593676923639082981788732031193774047612589113654423166826140872334380708795266307037944059108148612979119729408762532396036043629484049508789880964586236575769826806092391573178899640321403656891487586452524427223891405519836671312830183895761747460911777623703557946796784873885800089025388390522992806365773290733075927321101736155663727528284512100509273076328103465333687228713897893434161293693971954442699482857938492961830350598789444266860160794913830991304996676299650460125000959751177037694425217989910261807246272771711816326991282202653917488360776928533800529297474279497910326579608191975246060946079639658615178160271122713225105861574160788280907842327681375920919676063500116492292319') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 201 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,4,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 202 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,5,'5329378275943662669459614.81475694159581596077242547133292502869630735172901157043010370467618244548786897684821457816189831652076071977025794948484549600736179389638319303817478693948215387894509009504287664213474693208847025374388286162907794727810231557001266897729978691844410171412189947386181530441402903608214502713480332746271552746231631136145916685939539173054989927058122097304419584979598595477177513004218594211597809300517607260841648610322863666300637648662611916496850248528515936635845594390453288113296413254893687029540384176335735114863908372780241463999450547422213639667099644505472777149095004849805371205203850993689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 203 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,5,'5329378275943663974970875.68387837815679263182430217236192193838209859394480321205431177443564436871085042440731842593128543877087159218415801821547335178795206149841646805067528400474905206604863569827296492883485842974145076391654088154097803033982948898084192422150809385760511991169192044353228731864375715719064118394339415417054629392004621307042759799481522264617060523956256201137680272894311866260366238283858551565663520480629408383844349319586471282301251749494706061523663958609947049544255725056447964564549684815188261035801892684889942971676086592385285071073528462167439314005547455087297279161738865296114495425732286867689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 204 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,5,'-3478781676337858247983014311182511.567538638808357215203593479841446379226774481291286361639429856698999485760647422501864626078375852610019829111004807806660731243672830787729048847342063218718651165150612717759770504648306347926061960607388621011846314969634048226452709389995594961695723139571002939804473057725442880410434039783304583526414509590532906062732322732569475349107437896717416548237633532805602064623969799081086996320156575550896200848758685986331692388099427314008504506503745527468550106879602399030419569897808150076298414568875477195447656904373310322813412927463518325927626891046356679526447117311923853482118502868148386882363449163182892615259995945992014431502761210899772725227648729095696228388558331052524469604046072203605897109629560683446827492904111565278516043939137760721315953500281379039771826554155511347152') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 205 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,5,'-8164430956184510.184223536017248184022252663660196916321116266103608317725855237211273642694947892658721606226082017525816544904635887836163201565923338826779819876742736219975639586566502584026349778499211535661173597356253186281116862244165796632756909578140184577853088376334255860281874385669242675881761388233070861374295536603371778669602656670852115614651462552069294889723058758969660566508798011830996965570446030123780674316363670374970480994905368006454513642480180066435609577311074332150098288374616437489163254821095377348025470309665651059603665062887597814064136313866690824972464351274062540825405003954064175728198182815347642172934453828192850870808373638597839434504241236228591053696481146252072190903430582534862988719805163692697482513169856291048966811374872266165034373412719593685881972700171726777938') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 206 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,6,'5329378275943663322215245.29625473207137544719284446115519970394719946335145777492574745992986971075733570324679065009803281404581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 207 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,6,'5329378275943663322215245.20238058768123314540388318253964726313120648232235700755866801918195710344138369800874235399515094124581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 208 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,6,'250145412892811547138949.592621291590152419206270097656346630226508074074623894951308487425470437268130465956063593951784820669318897182831355375451719125809800516979013437732298382708070979871283132689492336823087794373113039154669229889503700598930220858275174342776478898670277868700384853696009897221747924643343353942154528501454689084608965009561564638167714973711022212547096732831847202912862290958304510651828842182545311077713664465815992616213663619529378061133917572474298028065850515876361609671565914027186063801852554353160801534696062207299890867876199323530337336273950892723090754719547285920090419070001019943385293110663922226230169381423410428577990604776655422105400452217085311617728003688836185608912367677734364834577573255789160419371322775733777518997638403409000055707558465286469808848200141192627396502735') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 209 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,6,'113543048739697485358574290.758354267447744932153707340542459183720907885610125346262898114677742971240785031722334497858930434531517077525413654346644836353208132641713415396062580605566225794048569430676355036264762949452090151450855446984773994337170590068740235544320694721909983307239491151139099779296496785240814600627140543144068640768857707110930453204162312973998304574796413938461971472337040811785231390930046688391955000749644938061585377150632133417156866197053052425576957646564943278156977176976876921235395711611898108821587442609611001702344783440618040704066809035404237786023075676374788819144406909313755996914145273176359246052899650387182222905558751208368173052381982668563471143298720677965028880626152749773712037769548408324298835212547215352657271696665387200792785056233953536347605130973626194099064678842085') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 210 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,7,'5329377457009123250369503.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 211 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,7,'5329379094878203394060987.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 212 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,7,'-4364411947278810125327066890819882483326918.05664098958260550284395870948992407314161088028674246708928421994893923699743452802989464864039994566042797942433140378990308345483670828497915478397481687305406460330009319949623844175096007381662809083363069100235985794575399268709260901964834244796150883807308976949196661411035264619638771824190014274817662519438658481432363824187693821267613212631153175155634316128036152465184903927860719447693468054624663668062006049759837326188252927823612718163916100588143128358998656306593393889422386501730237442526450419990376323903182669190482615734972147533221144682538647497701130447816148459762464395194383090936159579764712919396391813914821973715879062992249315474841639591907249142779103650773383644785606333916967894') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 213 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,7,'-6507697.520580964829176145824902679560705744817573189143227837387224410616222039115571544850095278317993922427931439719549137387753697989249394347047436951117850128104928719365703899136632100669607126357491484781141296021264049762417528697619931558728863308905257358126654378784709213859234056696519305650316810797382293500878834933984458810656133463638442959750083607649924453935287420620424368291770694630751828333903156364366745210911640207075765008558904788350844410055253643515389003711759818446776538393914018427075074171758415188027562645239606914126802490579848138218395145734902830046359100742374008993296019987093605275289913663224324033923096998194326249508491872193747944673057257521552387923218450155737056841633810711295424578984452176016198348344913655301417872189073133147510027427530833694019910340299') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 214 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,8,'5329378275943671819201468.88995490340795935797824952902333498786202536079000703830146057240651898748760197658486790165425772165585380839129948178510273188565692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 215 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,8,'5329378275943654825229021.60868041634464923461847811467151197921638058488380774418295490670530782671111742467066510243892603363577850356311648591521611590965692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 216 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,8,'45283653791262997781451381354094822.762732909505051438036873220502792213670540454778361182993875916509061144859281577740137081988678361247725064336120451090222456518107029158304937620179032477664627949959143233370320432203497828243297406462513350790251761540074946469824444452248386782451723637769289822576372357189700319768797708375563651655860093365309717823602754924352327588945034832436331911584742966378275504545736896430718939807674966738116698454215555860047859161126694019895490767779791933882712567492115664113775047192011252893773389940988533801360010782816196288710063568554147458866942816721046004257953642508395867837127678980002737669139369781058046396738606563716339660654364541530532834806205571191828994250708412638796240377704994928921528330863683630622922959130920715261879547446054261914770022377059156125037157979236658010950') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 217 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,8,'627208063620965.397582272040628872773601055303353339700043792111288801181637510303989399395425313995651311362368773096988861977687484912995632130587762386590996099363383976320342247076516604162469063709298438133327434461462906199160715395064249299615054970359309619951777972710299484596875999967582794277241285253106817446259313281064844416249524876385699646393555435017820686376877981018047574348711991428666249794623006175739581915209218834701034964043360823844816042368184094857692062884223864639972005010863342567608351008172649209459933114800143792514183138995700133608613158857147417653998048890116531052767737435620558349226865105888201598712435680481803901906613772821370519525404423549161696526405320391828194356063547089626322474164332505209233143121068245585662919687001395119229263995765376465304715643388771609446') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 218 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (4,9,'5329378275943663377078725.59616792993138452386059664269485161374191901124632386474661634799161523147237015531446709484039091244606359050341194730653343894986479159670583937529516163204904273806158788218327396375034882788180783796976731912141525319602448709213495905899041406302673881364465504945113279286939663215197485367850132991968081639290297033476859158044889351836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 219 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (4,9,'5329378275943663267351764.90246738982122406873613100099999535333648693442749091773779913112021158272634924594106590925279284284556872145100402039378540884544906379809382171355490931218216320693213791113256760721925653394811317969065642404864072442190731745871963413981746671302248281216916486794296983018838956112081135739969615171358100498945955409711817327376172085836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 220 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (4,9,'292388240303165948041827159734686.255558469787242316676287235194652580157149226950109397295920730296960145548003120827363226435916209781396711693581454960342091452830648929118261388933297036933167543189308061917640517578583521401267417187854611829815212778183983326568586118831109538377828156118900313778053576483381085207892754728937946691892849474364477434665960112125254104966566712906532318984871145605839506991591027939136026602051635433295687547552796828217859648186757719639965988287173297286034098497871707197092627676226053609131138590878743560287292934815277894463305001278326023708395571840850120055316276256138004565442099731931051413153564744766098053176049414330146267604802971221161572130161432525297614616942172815141372973870720928125699420370428856022295499447755488148545048400795053604349570217878099721865670458104653570360') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 221 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (4,9,'97138902640718538.241246716463110895614166618530828908023040947887095196830690221211560526562522274118188963051412359798837957512805692731972838989047910709158995922699598619854907969493232150042212406549916252602794415099066259707018021422154933830674786488990033885447289593742424717170197810316367637885248684134204152352748803532396210051700193575105804898183523770153431536054848843504020390623875664696278263569145547515663340450903772852615789980257449146000410036925975898331113013857953289990299253584950458042598491897496393582249411290555264437893099880371008957017323366523688894303458743415715114628052487518110654201696604914159777300997374156315186315524817636714210119873791848535246674326877611945112249137224923201544452904111118569299934059002046318394345055859769572070097973298522564724884895879226870720839') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 222 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,0,'-652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 223 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,0,'-652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 224 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (5, 0, '0')" +== 225 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (5, 0, 'NaN')" +== 226 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,1,'-652670387.03916046850422757312745971450663862747133703839829692066597367760104802542475264601221776157515632293978442027199108085723617181683235487266149426304575903892721468296143475297345699313102262188759506518376019936160961709578829069446312051432780603656651983414612264636232727512091101057374054475214114364113300402823059519499217878746766275164739724770556122895799337810694888119810524986616938847385753562624139431982468828696587199570410008890188532132652095915565323400735066310142303225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 227 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,1,'-652840873.82996096805674909792441698652235828221445420381749472095823439215841389779822880154688608619423079931032645214190898787339168396375791272937178074945473802633968350414211085025663129356908887576538544498889782055029046596593888271636613472988050090259449836342389832330814473910881711053475561205644968306669776242949930651397625234795216816397330872127577980937461350104018382663378200293023018506679957617487661691020231880567020416430204091941905612894161614165865789507675064355852373225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 228 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,1,'-55643106304872.575994253221940844841058071061962511162776681458310912066379595519265546225338405882027547140476045378015935579066580347282075024392379464189067155567624835346798806677988850250198082355055954078446421075165109896091047534711081616362392995575466807084807876544560268050611445006601394735810211678919646667455478469014906335433468365011768049600750224822391684377238242162320161552720449713229523135506671063115436813348612986916614320012995541575293478341408982118538094438068036422562665160411591652618670802973618768526197813319204816293073794413317669922144705633308090832805914096147659820167569140291210526520361556881576175809360614782817717579318298657744021133210954279487777567785280633309576696708168342539425395482429923273623865667723482418178781573723597156804085501875735112311466228778929147929') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 229 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,1,'-7657.550797567691019915353529993301413746369700087741672762343206271266232635965032053368224472333368713006346867984576168784127503674579531243603836945595880917241997606783133673324236134063757452734295148763280059050480246827193380861494669624151921824660313516974440913733511526807313019192263170823268678149435664224184903925632177789052038092611394447709922076676981043877747276056677801802695466205531230350209787298926245402046182150996849906836743231861317120171583577624262765589605263477198809166390259128339127005924586833372241946051704497188891325715185091060185547236923494393813210904033520844572880475265306843414506359253445517738473745552980984097762509546161690823646176501838559393690565709795724159196133663168004773260451322595899506776323262195323943138344537866088159583331807728944620284996') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 230 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,2,'-994877526002806872754342801504871.47809095279915423939648794226185974985600242391612965412218049794216637114648812993201775787765690351615479957141288239552036371132381627958673244764559862836085530643408020551049895730005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 231 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,2,'994877526002806872754341495993610.60896951623817756834461124123286284017021118170033801249797242818270444792350668237291391010826978126604392715751281366489250793073354867755345743514510156309395711933053460228041067059994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 232 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,2,'649411906691138274293985410502516861224852.2323455192714410716272307781034189160865613770320102043319541634113746032638191509585045862973333645830298922352816245477556264222094036953195419857712804755170632292914187367964994214922001758104594052499795564860466055599417895782179851297585155129541589802249540436678824225950907268084876110445460948679383611117263673106597132046331719468816839434908155684738864149955129235751738204036443603521478609787295079710078973503970964790273461142497259987849074597264522099648376356902360358310245001183020992360260836105404118742418040965190000718736837422434593694808973939805954329718232693154128543253581495885789333274488461716809104532693754070810202831113003978085636579574171344721710232931261731022478029314435363413498991740750878099825781577297965642009156858479681236085226911858782115') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 233 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,2,'.000000000000000000000000656116570506105776235076334177868550033347254561166417969910286926369599900073757929714260350320362090452092025380232792749476245042480546813848702351830607516880397305138543526307608094143028291193163613755680419049060162928958489964834941920423432354996040147818253087783193280640282263490705632002572757216731766513434035163528102590524432221718194164133959630768718395847710529339782880381264265894322494716854757290930538739000043383104085867828258790010654331660516512156519838978751447311068903958136482041673109857552178367614498426226323001399275980281507353231821022591045797658991388304873240910526149138339658220844723880158150606035181559877351791752701872877147074033569061408920725522180134133183999181370354585872214368766629114773129541658653693832843354053701079334077') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 234 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,3,'-60302029489319384367663884408738513110.66683195868931664491302527038538338065260819361151478340212147889934633981101279593065290940544218360883531149731823374304151252289014494378769385157204705433009477214625880056478643611622410268943757215673170753460135411513114716313801477916713433956086133878890802448531292334570886746283905390661877220497842493537338035961123751393889400517474762491881277080205381424363695095196058838349029211365212855028824622924678684631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 235 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,3,'60302029489319384367663884407433001849.79771052212833997386114856935638647096681695139572314177791340913988441658803134837154906163605506135872443908341816501241365674229987734175441883907154998906319658504271319733469814941611260503645706198407368762270127105340397375230875953495882740039984314121888705481484090911598074635434289709802794549714765847764347865064280637851906308955404165593747173246944693509650424312007333558709071857299501674917023499921977975368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 236 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,3,'39362489275784146262776411377472433635883331946.794473520543457442955620133347015506556162839462623905489255080102447195050109095701660164272430316804466254467810714209179752718730906325952685817112992943656292503112803950215110778476301809440329937774061163668461957943313261962261081942055908935814323069621279128270849852239727888939033546870208376394878842958202403235309372240005941467570230067124830916866857395233038346727879951123599893174252558078732888910139309038957525961212820831321973219557165558911222848692996406741318948607549825343491479728117062814094258484536263158005174429922237853707635743736923521032098496725445243775790161216159399180889906705265012270270348146530113428221072591696851818281866095288773371414866822270689959827332258348570976075184933893434327278299820594014788148344260948638847457822697682605612771344335201258128') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 237 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,3,'.000000000000000000000000000010824770508763323320533297369674519056450544793568147911931789010432012750062661590994728968589403602468229106206242395792957238667714358401601098858606386995096923432407249369639633268143022787987190106724545750803196130511146323174462918572423414631798141263222875752767731279138952850500369328934959764805948568471324562210715908420467881411844098258193571194910997918428786213948547748701831331312040839544355427357749520227124858111324859160114175254197992204974033767300989488517391063188153561391320190653403747521648794370679322504188364455328709488846777004202196382575648619395139553279192346251133156445942281048959845827006761160755031086836046398020850814350246219929303018051720203943879538087954853996826539712240458022307680912400297508925714946398031304516583939283') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 238 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,4,'5329378275943662669459614.81475694159581596077242547133292502869630735172901157043010370467618244548786897684821457816189831652076071977025794948484549600736179389638319303817478693948215387894509009504287664213474693208847025374388286162907794727810231557001266897729978691844410171412189947386181530441402903608214502713480332746271552746231631136145916685939539173054989927058122097304419584979598595477177513004218594211597809300517607260841648610322863666300637648662611916496850248528515936635845594390453288113296413254893687029540384176335735114863908372780241463999450547422213639667099644505472777149095004849805371205203850993689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 239 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,4,'-5329378275943663974970875.68387837815679263182430217236192193838209859394480321205431177443564436871085042440731842593128543877087159218415801821547335178795206149841646805067528400474905206604863569827296492883485842974145076391654088154097803033982948898084192422150809385760511991169192044353228731864375715719064118394339415417054629392004621307042759799481522264617060523956256201137680272894311866260366238283858551565663520480629408383844349319586471282301251749494706061523663958609947049544255725056447964564549684815188261035801892684889942971676086592385285071073528462167439314005547455087297279161738865296114495425732286867689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 240 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,4,'-3478781676337858247983014311182511.567538638808357215203593479841446379226774481291286361639429856698999485760647422501864626078375852610019829111004807806660731243672830787729048847342063218718651165150612717759770504648306347926061960607388621011846314969634048226452709389995594961695723139571002939804473057725442880410434039783304583526414509590532906062732322732569475349107437896717416548237633532805602064623969799081086996320156575550896200848758685986331692388099427314008504506503745527468550106879602399030419569897808150076298414568875477195447656904373310322813412927463518325927626891046356679526447117311923853482118502868148386882363449163182892615259995945992014431502761210899772725227648729095696228388558331052524469604046072203605897109629560683446827492904111565278516043939137760721315953500281379039771826554155511347152') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 241 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,4,'-.000000000000000122482510461124748279475400009367345900846466958806966807399903713411658400733717078392550780910604704603123670767210550800752620037863340961255721285160854785449315208955654408132775022766783343331151895973970395232686910362226184006990485313002943710214511418310741271074710741339586430026286272098156531835438969774325517509155992092194349661122678547097423264670055720422496527272118788005921590521726691666219504214087867030003203385360001614199656989667055583749577099440092378355805901262289841168751608673297446473709956390142112843400255748161809121986096092991616144443486023218404881798896685413932215981950393130292001833627899480153863300557853617312991880655905907971211246077450786084079040513198340644157868678782195341316027563717617074364438885981635394382733697473265872796207') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 242 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,5,'-1305511260.86912143656097667105187670102899690968579124221579164162420806975946192322298144755910384776938712225011087241390006873062785578059026760203327501250049706526689818710354560323008828670011149765298051017265801991190008306172717341082925524420830693916101819757002096967047201422972812110849615680859082670783076645772990170896843113541983091562070596898134103833260687914713270783188725279639957354065711180111801123002700709263607616000614100832094145026813710081431112908410130665994676451253271560294574006261508508554207856812178219605043607074077914745225674338447810581824502012643860446309124220528435874') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 243 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,5,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (5, 5, '0')" +== 244 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,5,'426089913064020811.057708378200224487694731586862745370027417544052374884336177893807736467646454486029424673621605232432043672119510371547153895504456723242262639262542904151307250842477327375961936454637964429999741717244285121019840463692418987118402683746281993192269229200465080358289645050337976214115902915692028162689089167194843185708212911364017271332623359100711545479273675423617018342297822477514128997410642005300368966199980354369928371655155437291469427189561877718971914040675572136507472590254222870537216617260612835805368361975725573009455402822669103118872235140158440342063571894152305875004532651814592458133460160514384171804043127771746596286988679698684698755896736275307574630777027620558428909546664763675431701332632828281070572045822129984625797185173815273651376003614106277727279230096226977335510') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 245 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,5,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 246 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,6,'-652755630.38762364608541718463145771120672223443489913059334543712856431450577465795351472116052777583325262472505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 247 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,6,'-652755630.48149779047555948642041898982227467525089211162244620449564375525368726526946672639857607193613449752505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 248 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,6,'-30638438.151446159804025029882398388155309149089870990062944469684482366692824338098201222171115395923414887930224163525189097571163687285244255335505387733673499447610577050114902372990462064696637481657064525319516004273769831260452832960893174173254560250804003884280384718123289136453955482855362019158401218620018346500189769819687260476334734259702665316562988639223597110627626759216850014150105605927773639897638043177685498804811787888811168524202700283461266793154726325540776914500415140842975457394524215869103737379109516024460317825645645301237375972914247141703084877141866316168268901439172491577729880760950895760711857112463508064820414904611059588717092145484656103798852859978690742216940980929562068') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 249 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,6,'-13907037655.047994416383638650569341223199042786813441967582376077478024677494832069402897226848055043557486983268019376307288565911231748501636517992289743940159005664424461285010295150828744259113760652210086696250085454819340987566229400805422509198052317518991183515696724846560872057916862620762789778660622787735923967096950195583369113574365386627110408307941105082873469072519133330718161987781080307947247163619814890462416622144825161521790673339279047700672881113718394727610096366361422482794458375587355933614201638489194194834709433413694420512869179976485096875057742460003147602405353823942488343056906912173170809084207937229591627643451380735179767199816663168139837088183577975769442341678933576388936845704303859241320794255052627716474860113993958556604381707826493168941926878481079724185426298004604') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 250 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,7,'-818934540724601372.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 251 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,7,'818934539419090111.56543928171951166447406164948550154515710437889210417918789596512026903838850927622044807611530643887494456379304996563468607210970486619898336249374975146736655090644822719838495585664994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 252 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,7,'534564131989234694540350103.27821462973515555648644772098605028371173048154132108733819196629002548296868548691993248746628993380136454426833349407578676005545111508293942736555269938962058196496152360848131645787941032968937794930046928523006455386861100809286408671908320322523368135203881520526880998279355848280412933152306299256343179622513731096363088094541514890135766460631462465021694553063366717467560655272004461368865264059368514271105464855575429914212085797297268595943955105608543373940035636033207568676745293499106348500559628723682588033431457023964317090780615020801564861497990103549650624438425421690193862533733474254') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 253 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,7,'.000000000797079129642393611556079160915147221153735075943759104977169600937534508973732991117540626046659124172765761873705978811124901421049332579161931652390647472911517923131800238903184679028518657818755558526885018755394697157094867449047655737107085020874974955627907737126958129710597811740696534189608639914753884882702680512272194316887744972931453458445314561564591875764930680945589486999586667912816485821717403892703364322658245615895415781719033810595358092343690359557942948213374234065052300866661453767599465059289920067095083062096458980564265691295895672503728815182981118876144075942348853666085714846210822847053889733510154276933759200630639642310562242207518883342516103725757482864105340008709446643820864294556778969997115586027866760708448174502158738150605938364482719960251612464993') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 254 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,8,'7844230593.20607652525116672615394735666141304947992676684520382624714879797087461877675155217754947572297228288498221620714146356962938009770486619898336249374975146736655090644822719838495585664994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 255 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,8,'-9149741854.07519796181214339720582405769040995916571800906099546787135686773033654199973299973665332349235940513509308862104153230025723587829513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 256 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,8,'-5546455599206321494.0676583421119904300307105296377723816472192007866147764761501865875232824814135783697976183493106885436876081315217834621720906478074798596116645640251460842350553806256223963023430631066024389364515688765194373161385579258482225808660340732705687558150699172147896486727530192499184101617379930846663835628510376484675411350654979679181852179924386290069790336316958202582966248703889464308649631486542724072047294216362186036638115240070658004553260251510288423749333873893917690832829128021808383128393431810674177390352413548658782609064839524756041501835115152819802758773711821322162752064589750295542985780512921839490040396053737870038534216948323935020460307350020911362024271167085905714873548388570602799432705061561572854498075600') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 257 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,8,'-.076822018213756690975099471985461347542955923191183223634407380481978143225129486622351714276452369661632980197282261508936298649901018470846144321441236073683990324039849865750139470288565622579952182053792815638469841531577235191276257498209844422440366423136595067535337374223115507557306455001792362506235886189722508617024948653046102060677266555476719102193278190540414934812073355995577639986512222998268934000209944414236509139290657402937840986061987219441410741189615344050459067454369371094189930607834375561948483494321255500497786795636801854613881105643003358210407867114145806225724880370339074242480071595684502491827709175732777776915682786771730423733673667248186336046898260378049328204094804755195626798951644386924178161926128482002518979482630732440619051262620098544265763306253807191182') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 258 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (5,9,'-597892150.08771044822540810796370552966707032464017958269847934730769542644402913723848026909285133109089452632480800168074607090893991283808726990171062867538012237270000932798704781608969096508450960185964292594677356241956277714380500188870696516251767979457838109804726539408115452577436052503866633026489282425086547752714324273565900641436632912781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 259 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (5,9,'-707619110.78141098833556856308817117136192658504561165951731229431651264331543278598450117846625251667849259592530287073315399782168794294250299770032264633712037469256688885911649778714039732161560189579333758422588445749233730591792217152212229008169062714458263709952275557558931748845536759606982982654369800245696528893058665897330942472105350178781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 260 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (5,9,'-35812445701642379.972368737320206275515144213236752803936806738624588812089615098329765811617509505790110909629109400553415312470540217508070421816878544125783329593128638405659896184248784794258084116406472768709113030915308410565617764394827427154923321461158387012978726512246146545834669665093228316853342805604075936530371665576147966721599968786161939347726656168798065647411457701453987215491345496003650288850096338695703984042549594979897253521041581573388369367579323607093487743440894765114619634001789457486407909224339065748496715380572175183589195611952939575073075140094901024063428239223964510824958346570603142906309198033196987949067156046076497974760641964978711558209708743776024313916111738542765749928287600981397080809041007714387564206594515733287925008053261840295560398311905155157989225181164097547541') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 261 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (5,9,'-11.897816658873986795664687519069203701902563457968097729876034796143085813450454323128600602495745166997629078984618283588337379184733369491549230343315369634754204412939757136108898254582353378508832611703989221079986765793923635928759179573599208612516427628403686659479459867527627014558600521732194240404211484706621458983727740143568799713006127585168144158660566534382037451913967363675002134687952374080694449905223371627606557311710348820900963340884001770733452314715448053233208783321215998063958966729954113843581448912079950334969908657535514847005768455377990262943747367245613296497099716892292154137652893990339292671106003657659470243633112063075297194691349631518467702876183897580432003030164590920118726657290102377710611324297862045849839571689192181090062958059281673245670440852080202548743') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 262 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,0,'.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 263 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,0,'.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 264 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (6, 0, '0')" +== 265 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (6, 0, 'NaN')" +== 266 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,1,'85243.44233732197133191329295927531563604777955507322414928382967007765263923984471408038635831036097817458527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 267 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,1,'-85243.34846317758118961150399799670008360696356209219504851646259063690472663252876207514831001425809630178527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 268 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,1,'4001.075404054519813215296429095020391062109905613738157927030437221793757373268325953178030040276107574363822832168160758728653712686313134828282109532831190239521843808940611025488601517574653932032236616573457735900045655665690517797280666732780030171712864961531623060353548802466577910774711998056232872212688464691036260746751992072745518373073825852119460094113694393273456369345499434994672730920070410547163082189385645712866100999708173472360864669110044660667614583576570496399103026286828660558854973376227247132815728164629722965145778698957093136175449225024685874279280018547740') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 269 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,1,'.000000550624150700285432940805295709861455424264970126953321538967550091614148982212874391026630805836518138806917934859138493583812313778188030836027246840794439412443826640206464415527687555214009725107630387889854278497875708390050387195108441635824296563108288712340902423706104029452615686971019125750530034798026103476074158922893374911891438688457439945897348811702908216883650280617098402133628688982793791562476980709924382381505517834196446365877784931355599480881104446907801805570471686295270927836995181422963320376948188855989986414581755633425437161760674162177776773597848142496583128607548351599750592863590334617838124741567654525843413232313914310487355539260264225486180000012813397807525203822863232682089295055713257835007742845010741137213301116647610033909062369843750685396196342928455') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 270 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,2,'-994877526002806872754342148749240.99659316232359475297606895243958507460511031229368344962653674268847910587702140353344168594152240599109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 271 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,2,'994877526002806872754342148749241.09046730671373705476503023105513751542110329332278421699361618343639171319297340877148998204440427879109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 272 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,2,'-46696638263247522384986521136500.479312417066793299922708112595886608370451213741279484136907754744903470430131032928908162742687359367826808123516519335458861613010646992354378739165872253762686683966945711430182491860196341344982195078000259063231136011430995647812149294224699587849791008794261026932467933475782780') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 273 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,2,'-.000000000000000000000000000000000047178744084866106587600962473825168237820701199970144691815329658682341685812472535816245052671243808078367856957579485152424914481414614360809698177236664771558713606961423658442962083541733004775309314926918118528217478256885324362912426275407382550929085958089798861918760121727491366034496581249711153289495601712583077918760003840368008056353090552282274780428335438032908213783490070198414584291402513547386013689752310173492320159738977752795528725029134841933604057954874523842273790958618375118974623107241366036640538085329921129023905888674299774726871808862832797230915933851225308164365269753526489223540580759951230801125605963901491073619448437890841032149898629231552019804656219062534881074125995130202820302133432951999011667568746004715268323913437054078537') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 274 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,3,'-60302029489319384367663884408085757480.1853341682137571584926062805631087054017160819890685789064777236456590745415460695320768374693076860837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 275 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,3,'60302029489319384367663884408085757480.2792083126038994602815675591786611462177090630181693462735571643935716818574980747701251335721895588837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 276 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,3,'-2830400711649493468815157129316992649.40542786074520931471973065281957756940496588853021620372179463538053123396140685749478530925306163968207226329985017644835203709485594362663495728106061878665324856417118064730721101615473194292620972173690618491026470353143141125614124440035267592258385099934706896692953497971326605145704135723011753705907329979207428661473172503098296622281647255008204864404416199384701720347319806375450632245634238172654086373193251877533131784268854289406126119630708578053354762596511353053106459297339360827562281168219966099848212') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 277 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,3,'-.000000000000000000000000000000000000000778366376597400971124059102619954214055884926284646546105035591052258074563706355894551049631537984053410850060739107742208523938741961208742831871056600773325053133977559789796700130019975964192371715826863472981072974742704091801166438465082519558956925444635729210849210496466189037623555622901738570979273502405907969114110345815802999687171113749364073269902319653450479463404003706147915064100959774312307195946966281098140229199529866429134937742584938255441169541436021827079647129394362379406256722903991353136733939395366152312959281905058592776286736536360235356737359904478313225848562436632109470589310799000750518904145312512621838935796912993778920622238202744037977772169066929474233952081158212174549695244127987299282384885288897893503991509410567351494') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 278 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,4,'5329378275943663322215245.29625473207137544719284446115519970394719946335145777492574745992986971075733570324679065009803281404581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 279 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,4,'-5329378275943663322215245.20238058768123314540388318253964726313120648232235700755866801918195710344138369800874235399515094124581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 280 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,4,'250145412892811547138949.592621291590152419206270097656346630226508074074623894951308487425470437268130465956063593951784820669318897182831355375451719125809800516979013437732298382708070979871283132689492336823087794373113039154669229889503700598930220858275174342776478898670277868700384853696009897221747924643343353942154528501454689084608965009561564638167714973711022212547096732831847202912862290958304510651828842182545311077713664465815992616213663619529378061133917572474298028065850515876361609671565914027186063801852554353160801534696062207299890867876199323530337336273950892723090754719547285920090419070001019943385293110663922226230169381423410428577990604776655422105400452217085311617728003688836185608912367677734364834577573255789160419371322775733777518997638403409000055707558465286469808848200141192627396502735') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 281 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,4,'.000000000000000000000000008807232244507937251856465017967626593430084223212999583902527587737263981869382895220711835510154989851222501080395520249593128253795609198666884523792646863341248402687314509176781281863891589925961900674092953408613128961234166906173266411035009516545964362406728942021813644419154548354247112601793685146960840364604115937119024575638240439041250900118977183124605578660115160551830946251713350556181960983267689939549506518185340972020820080460565392359379680036788592213479105831301723237102710863182596413567756605711230290883888612188805367801369264231165178487334557824054205160222371548005742602736713668548450400926514169967213301919971189065307721110805424950794015852531342286935114651278691214233054575660712537044810163930633456573860895791198853393107188289695511873068') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 282 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,5,'-652755630.38762364608541718463145771120672223443489913059334543712856431450577465795351472116052777583325262472505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 283 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,5,'652755630.48149779047555948642041898982227467525089211162244620449564375525368726526946672639857607193613449752505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 284 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,5,'-30638438.151446159804025029882398388155309149089870990062944469684482366692824338098201222171115395923414887930224163525189097571163687285244255335505387733673499447610577050114902372990462064696637481657064525319516004273769831260452832960893174173254560250804003884280384718123289136453955482855362019158401218620018346500189769819687260476334734259702665316562988639223597110627626759216850014150105605927773639897638043177685498804811787888811168524202700283461266793154726325540776914500415140842975457394524215869103737379109516024460317825645645301237375972914247141703084877141866316168268901439172491577729880760950895760711857112463508064820414904611059588717092145484656103798852859978690742216940980929562068') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 285 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,5,'-.000000000071906039575366987930696117572143566208825430801491864851999044659045681114433294052065377679745375399878664822361548237094424148992770296383642432040129230180142339557437679166815114510467763288057917694948929009212876391059413439647163295629904270262780935228234994930653489111444964446097124407804311494588517082748514970905563707392765567625639455978464081409330528324962333492925267647686759704415549221137291475247571296491073010175087298752769122449499990102435819414671847617062560524758344361194566796343756743243766853291113852464023843527189221162680613675369708907935197867458588904367993736363321133720345058432019986643353417257503619558797249295232894674255060861358071309619524800424087896023710729815248847792174290644245138831518072176198607255346603270853333176255533974364728342822') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 286 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,6,'.0938741443901423017889612786155524408159929810291007673670794407479126073159520052380482961028818728') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 287 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,6,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (6, 6, '0')" +== 288 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,6,'.00220308874624532134736695825088747995945783791378828770826401323533973395137378460250799184832278118133622563295093909508983301127615815865216895482784469538070133388154961402881325731054433770884496') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 289 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,6,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 290 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,7,'-818934540071845741.9530629278049288491055193606922237795920035094854496163164602796260436963420239973809758519485590636') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 291 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,7,'818934540071845742.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 292 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,7,'-38438389630389612.0042045464692275627184627672063157323631169405883031379129843031477339360597564128205768842448328088') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 293 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,7,'-.000000000000000000057314803440765029050667129936880528769333499793237773980613524885506515999851858649385968476426313207429914995755091541422893944525222307473169425244462149015717526718376299808423552027796204632286454853167559026787019718806449038446612978917236245943248168920696452018925986743620392955122431521581268518101342690974749463089739042586011924590503136498488946387508310209984849243014542648765897536338824721211252335866349509669538308454367849024503312249951727948786393404944555844863805495937835281927012430439403132382055464307180153473189842433614777883826783689904293115204700185380661601223693428304020047393499702811581067120117405280772944184877279069842269329959037186324135435468322336398566440055479142909170224780318371473684868152271947368867666706912563225912012901437076773416') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 294 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,8,'8496986223.68757431572672621257436634648368772473081887846765003074279255322456188404621827857612554765910678041003765241409149793494330798800') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 295 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,8,'-8496986223.59370017133658391078540506786813528391482589743854926337571311247664927673026627333807725155622490761003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 296 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,8,'398823655.819545574205652791249227663407026876411660299394659390409794761643751582473390322547798567169668246138880832642141417531427935520467563318363116897177899262525720710134129529640376020947774470933902793259531840625444267816319963200') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 297 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,8,'.000000000005523967081937952184172713994498918048454262874017009201501812494019618863622631634736130436187167745347383745890248619882896153083428308074678908731005176810208100004498415662458272149380846809398637385270265351808328466537502823071145089961996689711299405627596294988646826454676198092260759424935699382655736524042353938814268760468122584678267125994645166955751211397353140569987758938572953312303398024147927938612934833827734142292697389251052485981023756760420972614486278837214553818521196182883489483756785207650821722660455451660719560529693418375773124813290305501923899840247103166971466167032437598057958226806335324315214908788839919408525748236713611579486768218564733151121028172253396652755590051310396973181595992981076269789287489208817712754098019817792758730835341151711523474207') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 298 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (6,9,'54863480.39378734225015137845671346015520435061071252892396685718794832880965812803098645730572474084523997120024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 299 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (6,9,'-54863480.29991319786000907666775218153965190979471954789486608982086888806174552071503445206767644474235809840024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 300 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (6,9,'2575131.137912978352131546639620215541477987701194164886305951830806120142596646541302305984776928560906754259789485960991272272782091464270104432109904222200473616116525297615725803495463468272171161659654385929185160689572943852767523792651123455283534072794326647404332228203001469884016996499768656263775233430922446983838511590562929268821678518640501686017030536100955531423152839988008496919169395159653034847677470665418765966542111749439412') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 301 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (6,9,'.000000000855524875533453524582534418967571681572635027972658867593464437484123442242521660317156546196609749230372398872487667521984251509483676665788527375343148382604836976332389890799079878151841905152004537926201190193814594954194044560537664560344224646197027029681984683465852110060077865421064400958821808374370779297676624123638191407441015008434084079839721156870032377372497814037418047056438760664237367081226979226606227037631073946209105678283624370820396871058367779887709720661001099338250009251834581804647326512873792849059661525874160414378459696930831877643599421297749483849526695657467708603491876916749718079725746259119898269814551222336219537198318796277931946529242436502235147453584237994498566122973953203597470078105606906752099294162422474758048436539653041606499637623370030079916') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 302 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,0,'-818934540071845742') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 0, '-818934540071845742')" +== 303 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,0,'-818934540071845742') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 0, '-818934540071845742')" +== 304 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 0, '0')" +== 305 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (7, 0, 'NaN')" +== 306 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,1,'-818934540071760498.60459975022373923760152136399214017262844141729040109985386964272131706381326192223266583769046276181472898406504104649192224392653722107164485675679551050629376558940966195135841284978096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 307 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,1,'-818934540071930985.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 308 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,1,'-69808760806266041400340.70700818693892852138813934414383886494691670042143650609934777814995087699409404201920249076407981012095999320858479644760715204999741683528746097757549835956359129287002171391961763797857794730120426599135099619822532290339000466211195776337667123320942107370731349851576864242697412616810236323676004067839744992733887503405311090677026008324895177587064547630828026123718296429295638934384446325302964896473296829265805737112709269803814942537657996725913938408781715328945194948010970') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 309 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,1,'-9607014551997.140858001442365669993007297071681832468350855627077185145567261170534005832165603932891201648027598773639089125980996652005412450490063683624648655909636499261774535015914730479401090227915382926027949990128880284298688443593909017437720828163877690126019616194376778317148693270900349151496295698078575648169637635898560612738481294674167553369445426793073304518646116539082953755973571046622684332425840412198776081251646424875405772676893185726872613804612566569794177506268399878105117763696990094108960076591684779180089885283939385808214239337829666227427148603057941899878123459708920227867371285837642561064461118016739395972994827327543594846953341750907541716807985738518071480209106185726125017342997283356926976052909493074301401955202616191210810331245427141945840542129607439703255628683506772979') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 310 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,2,'-994877526002807691688882220594983.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 311 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,2,'994877526002806053819802076903499.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 312 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,2,'814739569184924399102711674444306584731316176345067.39834031417849342571224916231092924046722938910652929295271097903377854123984307101079073134405782275535446337229706620713104545454319555885847481531722101704765783025789147453570970090') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 313 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,2,'.000000000000000823151110229758332661330617426417726331211894330147399760458555778324097596176117291103184653828305857999638466183347321835058943563347767579219763002258622507889760416640758842509635599414768344140175277742935564567127659688612699366182158030839083982896107176174766408199870924563237827899202849733606842856491701660599599211106794572237923985121475458446997860253437578966578617985764298513928307852082168209458400544457824307270777530312648199364084272310536024283945598340590403612752287693234647719354745060851129534452514828239800716088248915975054881011343555492596002595181046121935660176097475159074973635534016835214952415720717896518544064238656360099884889450237541254761746029507300068198731306211736696956568648033834554273602524147075895460874922913883751452403825099444642503437') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 314 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,3,'-60302029489319384368482818948157603222.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 315 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,3,'60302029489319384366844949868013911738.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 316 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,3,'49383414785234649002982046297226894664526726187218771083.0993243619030008310875293647868815940421844461627295157812843657782639833900543200310573708100000958929315945039020410482966753145208427035917753919085618457760620513481628641658765820294863970581642745379331727722585319163262763708386199720411053619449096019862596221607526610103408936214184850115071874430846697061554769773328338028749631552202705583855831155461651414320570061181212214810086436100771547030013079997847086') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 317 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,3,'.000000000000000000013580546907080371873577430837141172674171921610919544849037647398734065712983603204704663262116138799357430947986241590690589753181299773842880079777640016786921825609617596862828930939366173224366864448436461306602680780407912534492687474933386043505172346330210659476505435994582446405414027199938970759003336829722057241708213838318628292667946636226143164221380503228191376939596663443230082698085439531600756771639601022064620204571458766303985028143400866776954225590745596639602613498355332049777798367675438365442468743270334407716567057368347458892075084694158566383133325959042076573734408841629149903649365079563374278550978052491499304166424686842598833319515705663176855033865872333988551611996194856472662292344160194821687681312501127516922809221030420253714666026321243515830') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 318 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,4,'5329377457009123250369503.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 319 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,4,'-5329379094878203394060987.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 320 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,4,'-4364411947278810125327066890819882483326918.05664098958260550284395870948992407314161088028674246708928421994893923699743452802989464864039994566042797942433140378990308345483670828497915478397481687305406460330009319949623844175096007381662809083363069100235985794575399268709260901964834244796150883807308976949196661411035264619638771824190014274817662519438658481432363824187693821267613212631153175155634316128036152465184903927860719447693468054624663668062006049759837326188252927823612718163916100588143128358998656306593393889422386501730237442526450419990376323903182669190482615734972147533221144682538647497701130447816148459762464395194383090936159579764712919396391813914821973715879062992249315474841639591907249142779103650773383644785606333916967894') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 321 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,4,'-.000000153664179510102140733858340480800294287837601105047285453457000254577644933901525444082336054243749405512900867540483190494113677173628646221933766421338612376123824684592850465460156248403574333545090544920568230979754949827013129083778435107488003838746926270955224758508832133483591156567868631938590248213604979638895901933775098150684618378235712437137852195098700137765601802898366867034641606131280434771339920637353140131159441790904703083143627590062236537714415872864218260252838432414759890832271190606933534662897006726154587341385852258168335058931957995901987808602365467861573344491265289043037273815504867254228957776127752540924854546837197432384563153608878864912196453587628891285275067452280357349897203095502806923463147414086919014592380804424300739713935051357374227246098303140106') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 322 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,5,'-818934540724601372.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 323 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,5,'-818934539419090111.56543928171951166447406164948550154515710437889210417918789596512026903838850927622044807611530643887494456379304996563468607210970486619898336249374975146736655090644822719838495585664994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 324 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,5,'534564131989234694540350103.27821462973515555648644772098605028371173048154132108733819196629002548296868548691993248746628993380136454426833349407578676005545111508293942736555269938962058196496152360848131645787941032968937794930046928523006455386861100809286408671908320322523368135203881520526880998279355848280412933152306299256343179622513731096363088094541514890135766460631462465021694553063366717467560655272004461368865264059368514271105464855575429914212085797297268595943955105608543373940035636033207568676745293499106348500559628723682588033431457023964317090780615020801564861497990103549650624438425421690193862533733474254') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 325 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,5,'1254580584.048971438599349046867230181719371038956756285986415773300837165755558702217197735811549684202279755101552533605390208155708695952004683670878589028717509749282693444655857296902117478518511492735290086040573521482737598395369632843374456793385511847676556826348943588519880411018079886373631771830925920986588708409208527042927229627786932908015502292313887561198156623702404977221789649731458241770690830680067801377815840764873662400590343236662968218256211697981048576328148435241545372543075051594952109757428031762469834781538302930957095080167901199455226976113347018972534334210416375400979738414416582588689496706548495076287263281908191770792203069614447622517839588243746755480572371988630084226963919158931419126724681617069720048557166545204944250492282054791996953359013543036918134163144772567093') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 326 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,6,'-818934540071845741.9530629278049288491055193606922237795920035094854496163164602796260436963420239973809758519485590636') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 327 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,6,'-818934540071845742.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 328 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,6,'-38438389630389612.0042045464692275627184627672063157323631169405883031379129843031477339360597564128205768842448328088') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 329 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,6,'-17447499423661151023.558342555162228919125358089491573318627107322332520978657843895009110781773496490472817700487707134216424855867015781267287628022535529641238372370292374146871103236048507252055787621394728096799222976387108688980537900309311204203302960751747509648304056939321473462375648710590981564101023812800603438271190184064874290215309040519813024962909469701968804925443161094255632624090623433640078421818321246597728308302979223833487133268472455479442002005374793705431817866798804822885690193667521606781156962792120052947767160957903073698536973292205899421787948529970837601521657406211962967291912148632072929662185840265855612193255596825032457033402506154930851214421895488796227471490998190312007513478459049382774782886773158311656817014322925167278223360446454868236479549745612973293185989975394307678926') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 330 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,7,'-1637869080143691484') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (7, 7, '-1637869080143691484')" +== 331 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,7,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (7, 7, '0')" +== 332 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,7,'670653780922685519356619170643530564') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (7, 7, '670653780922685519356619170643530564')" +== 333 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,7,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 334 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,8,'-818934531574859518.35936275646834493832011429282408849567717761204690035294074716714939441961175772404289860039233415598996234758590850206505669201200') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 335 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,8,'-818934548568831965.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 336 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,8,'-6958475505053954666339703437.48985528725312694198056665033448258303533387675711770743843194274181580881296671866212320171337132096489224277825857521033238709600') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 337 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,8,'-96379412.478435590945480884955616049873645089637121682284625533034225619945532704111492738646389632607594293500930307222576571876059094206480673293295865214240456906965855425738072430281475736130342229749511650392658808510082775031098547507966544723255869156056349218776847523349173551313282283869146710349521487706884633419341568648959204688757523312579312713453540395840470692533267158388401676533369105590789036132185107859069994833345453200014884023709597817280132465224778002071890368479648934317322270613208789859930618055792958996389145963056607200020526949699302565905917600478429628844015684879886549766473809801710003649193772354147104446894109928903223843036925147624639466770660174828940577089095480826473544099693433597812637069287644606693066736302793687011165899362920686114156254982709172925265118077531') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 338 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (7,9,'-818934540016982261.65314972994491977243776717915257186979728396159058352649559139156429817562698954531329940720620096519975256547379603654362598494779213610069399116912987384006656023443527501447464682173445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 339 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (7,9,'-818934540126709222.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 340 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (7,9,'-44929599044588573810654775.83678007633232843418115790847152455559258007804727916986432256198687661496804050903769496933400455947645400628259699874770581538122521805603947464462448454681701547899144129061961394870320463199545502030106801911915987309444301341575451240764927967432593181449618816978119423290767783843864768557371257918447461479570164065303599994081990686') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 341 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (7,9,'-14926769772.797708334489652004325241753714626257641081061212878627972973992233480868793527325656854681817156284203427388055525855608883067129036717726368707982450450575794623567027457808927082390474261155500697096284790656757163047499531247323702909360444831707029353441147768321257650234732286165724178549576948957405037843360446785505536809409054071975214796532504678683693402401018726571884721963641317944453797513145055081061680091585467186975354801535734149952115333241283186621720677488342266420359417174224757781125498130120775969091933838082305123652811689513300403051544682523761263183781206840940347226802620226164265210810994106136738030959199259066517106713585343004140573604437146025585149934286364795122716971496775012412420105368351774715982565252533025207453326002101655121126631180162560463548157187175671') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 342 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,0,'8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 343 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,0,'8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 344 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (8, 0, '0')" +== 345 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (8, 0, 'NaN')" +== 346 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,1,'8497071467.03603749330791582407836434318377133169438097066269854720538319012928851657498035372443556191720308219530866834905045144302106406146277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 347 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,1,'8496900980.24523699375539429928140707116805167695126380524350074691312247557192264420150419818976723729812860582476663647913254442686555191453722107164485675679551050629376558940966195135841284978096687306110481009743118940565957556492470398904849289222365256698601073536111216152709126800604695001949246634784573028721762079936564434050796321975774729383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 348 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,1,'724311956372274.0135050255361637906710330203036651743488213007179039756514944640108625580172737414192938789413338554327986697518463087452612658955180411327002900979574347739956600177846996063741787205122007268468674386396156638261992679442768654367111433834151087792255469957061758837789341439211010331332174981459471333376067541234901538285101103690622656631026001337239036711179989456674399137008584021283568040818388709554256523118702728176420022080138548890713013682480239784198421500241995499841675772793497485550923152267616622892846304530712344886979674416990935007952941652591352603797627920865960622077762568060903908151958000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 349 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,1,'99679.115123747637190903598543851248555278745675862923884476564848911494649941770503156134872464666625927195645517181131678518619856156844072856993813601495176097972982587061507650426363887871820112714099226501603733968262566093655417466145183587899155614471697804006772915054739361437054029183182533671508695646413074668188590846200362324428338974890534273352188276373478524543505805545661569395314989170104140776362043880099775594658817242753124957385625811310332354760117110779649164022618274859298031549851269619167173746259018497289174255201452265070501056913033329291819570027877856677145579673495987354805150868813877928857472561883332547900866904764950837506993759536410161752469488392566682723027340638271076406246129989851281210810196699482980833204884400423019400653089825859983062096326294783573417554749') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 350 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,2,'-994877526002806872754333651763017.40289299098701084219066388457144979069028441485513418625082363021182982914675513019536443438529749838106171095037135009526312783302868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 351 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,2,'994877526002806872754350645735464.68416747805032096555043529892327279933592919076133348036932929591304098992323968210956723360062918640113701577855434596514974380902868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 352 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,2,'-8453460632655529853033389979024265783461224.3195241893307807116624750282852146303290708492834695194274289713076935297734670940696121761483641291930931061232942894577813178566088927221374036301485916497770984757492912292002695944367308880163698595015497307574177176409203214324418237020500352652934909632442547242092296504047310806151851207329042221920888326000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 353 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,2,'-.000000000000000000000008540735921314463871578184793632135730756619558669911183806487803411545406462244216408739432325839683804021466133071768612386706692296158696852363349481716813410857655324486448455846562309041306880675446880859847445987588059144788756984750993583865748280824370754934966494724951583311563735533173023858438364336214213295786266815116844775733072416507474834701984381586060478606371028156925222726225495235702395502085206072985373035972506738983640539009567237336002073370431753469632428303255926718930619221521257726366850472572830063284204851204189447233044832163423057501488364913539948261528280564870049935369825245920984413480757133585498984374354957754078525161296201228031555280486615145365039415418251448980923331334883673792135893857917681235883506783408111446970710546686739582471') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 354 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,3,'-60302029489319384367663884399588771256.5916339968771732477072012126949734214868901845505193155307646111690097978112797961939995859130827784737422228762767014427842766445950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 355 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,3,'60302029489319384367663884416582743703.8729084839404833710669726270467964301325349604567186096492702768702209585877643481082023851284144664938175277044596973126708926205950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 356 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,3,'-512385513828318260570283740065493064477880918352.732624553690077857674083796435724202494963885926573907185100543184828131859183999195040110586155435203949963570735841632689374488877298209082579317039061893012560130258753218955057387206477423088065663401594359617882154814262843273526859406265633827109554791772242178864873774889091687515990672487380368975556580539271333144212685871370972163560839446696514092637412587953506052848750866803569213269271165856310101244342151576488190595936869490659700946174362872797854591188391982770203203644172999264143929484089237665313698600170041324566984832357000400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 357 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,3,'-.000000000000000000000000000140907135225782279761112255989433531718277338909398600029580768021365259747075253760824424092983497958717844671162530550507041138147836569244869107757945370200122955794509365120853536859837243314494576053441804831018954867623755033888264275704547752628348151132333655667171970175829826792355986148522268067032057293494927558322394395160508723637192234110428953945018965078022622950949911124494740703606109543716688008516750321047603009424529696862953094999450658951089435460411028678817795100630449046993274191915359520936265372754315076684798942557329584282177053819106884196674660057281227248874819417305259132106690385871316407455034281900110779740008476645291647094776093567400422266906817555937149628005629880142615126571231411138926043531449659320501743591992888328328980526602') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 358 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,4,'5329378275943671819201468.88995490340795935797824952902333498786202536079000703830146057240651898748760197658486790165425772165585380839129948178510273188565692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 359 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,4,'-5329378275943654825229021.60868041634464923461847811467151197921638058488380774418295490670530782671111742467066510243892603363577850356311648591521611590965692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 360 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,4,'45283653791262997781451381354094822.762732909505051438036873220502792213670540454778361182993875916509061144859281577740137081988678361247725064336120451090222456518107029158304937620179032477664627949959143233370320432203497828243297406462513350790251761540074946469824444452248386782451723637769289822576372357189700319768797708375563651655860093365309717823602754924352327588945034832436331911584742966378275504545736896430718939807674966738116698454215555860047859161126694019895490767779791933882712567492115664113775047192011252893773389940988533801360010782816196288710063568554147458866942816721046004257953642508395867837127678980002737669139369781058046396738606563716339660654364541530532834806205571191828994250708412638796240377704994928921528330863683630622922959130920715261879547446054261914770022377059156125037157979236658010950') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 361 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,4,'.000000000000001594367257057971052149628499448029056279649281098852958322409409919964709324200796473211884339143791758566019217634542932882694487712398244322522748736692741288668885362384266615527166964187404128216235057387796054457728789109537338988453837993084016408244895452291151218602815057669592284587317035387004942691671916981967449109983992675125005085762403043329820872839739877674121174083273716295673230993049263574856197011389828478636779342320299895806297835595427859271617831720398457416685435560152182883615601663820189195644140652141180949257192740185075408019971747810015931542757445763460947106918998459997631117642552273815713467150465548031203738878873114842844016176922502916339025283749846225376341878386377192605865913018132981323065698049618379727531925408677611856682983907951667054819') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 362 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,5,'7844230593.20607652525116672615394735666141304947992676684520382624714879797087461877675155217754947572297228288498221620714146356962938009770486619898336249374975146736655090644822719838495585664994425117350974491367099004404995846913641329458537237789584653041949090121498951516476399288513593944575192159570458664608461677113504914551578443229008454218964701550932948083369656042643364608405637360180021322967144409944099438498649645368196191999692949583952927486593144959284443545794934667002661774373364219852712996869245745722896071593910890197478196462961042627387162830776094709087748993678069776845437889735782063') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 363 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,5,'9149741854.07519796181214339720582405769040995916571800906099546787135686773033654199973299973665332349235940513509308862104153230025723587829513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 364 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,5,'-5546455599206321494.0676583421119904300307105296377723816472192007866147764761501865875232824814135783697976183493106885436876081315217834621720906478074798596116645640251460842350553806256223963023430631066024389364515688765194373161385579258482225808660340732705687558150699172147896486727530192499184101617379930846663835628510376484675411350654979679181852179924386290069790336316958202582966248703889464308649631486542724072047294216362186036638115240070658004553260251510288423749333873893917690832829128021808383128393431810674177390352413548658782609064839524756041501835115152819802758773711821322162752064589750295542985780512921839490040396053737870038534216948323935020460307350020911362024271167085905714873548388570602799432705061561572854498075600') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 365 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,5,'-13.017101389051085341042057308965769356145255575582875626848796382322826525772114256699384710400140437710569924703769685567402446691691210934185000959063158239023412379691360587119206695513775971704926722817528818197919265145207032750407924774510773427697188520818450702875142190949766251178733262143962213111236591970766836685919581025629742334704854852196126735685421250263035895756028805974153787560164935038227108975229771590754808331856162035119882347418116049174638416621093907738608991987582465865527947015457540650512339263071898410531735438556948115098562123055444965056347091625748703503220861221718449714020622377233272042277814766996198081939221253025243417993701684007826177845003391944496774674489538520354606358872276671998045196738090133576377830721671972381371985771591052597345572374064920279182') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 366 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,6,'8496986223.68757431572672621257436634648368772473081887846765003074279255322456188404621827857612554765910678041003765241409149793494330798800') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 367 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,6,'8496986223.59370017133658391078540506786813528391482589743854926337571311247664927673026627333807725155622490761003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 368 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,6,'398823655.819545574205652791249227663407026876411660299394659390409794761643751582473390322547798567169668246138880832642141417531427935520467563318363116897177899262525720710134129529640376020947774470933902793259531840625444267816319963200') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 369 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,6,'181029319177.110996740664566780784253502559986936959009611748146099327460471609593148344991059106574612143724330935988823134137686051475120980257829276671900076859337187540608483895641504622910361858962883971613675309676443079313179200981488761707281247447120551917205792352229666049191991270809865110506639390610910481490688182068719005593641339338678014189749279508731647492051879768743158839680867283217578754666643688259810863605002821607490100820241093473083445658378988069593782353275713240897038366242558466047071334385431080003439842348547427066389352198560236731403235927478177780757802759046212921140424771887928786549573201311120885052685761195784207710933764480136690216943336587118385525047554334029388869436622866247240903231799829259264158812528305210833683370536416861544931420820452512390255774498188962903') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 370 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,7,'-818934531574859518.35936275646834493832011429282408849567717761204690035294074716714939441961175772404289860039233415598996234758590850206505669201200') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 371 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,7,'818934548568831965.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 372 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,7,'-6958475505053954666339703437.48985528725312694198056665033448258303533387675711770743843194274181580881296671866212320171337132096489224277825857521033238709600') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 373 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,7,'-.000000010375659845651632013446652385870617923988120764298690164486716047614260682259722116360931978511176121353975789418625836899338225571166376573732227571704071000348895791547943896682585450808398324252224265156214259224488248639550967292466343168350213394398101712526534464002532408445204630441167137710565437434313424987517531891145368203998329086865151248833625645567863740298397742783405267970015165358620026813812552194344790169289440822038223606218360105618852154152168496637886434061050281055613760360200323363465925493033734895631921307644481639236601187225135325401868178006133838932915485272554505684060229409404902185944047523033315868230944723282246159741659387362889777495094736963530708159604929268812778894177095572578862150793098548829744006499229853198046828954650334595737117597239208825268') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 374 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,8,'16993972447.28127448706331012335977141435182300864564477590619929411850566570121116077648455191420279921533168802007530482818299586988661597600') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 375 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,8,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (8, 8, '0')" +== 376 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,8,'72198774884738777393.8687539247642452953425155400068591498151280875559609979248583367700231031634872342122563819478919600402159024059794279536786611373504966204744811722007869415559012475160471227957857756325962941799428857291371597146319816910515366298862558849452235442246081440000') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 377 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,8,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 378 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (8,9,'8551849703.98748751358673528924211852802333963452553842636251612056366144128630740476125273064380199240146487881028508694029546139131732304020786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 379 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (8,9,'8442122743.29378697347657483411765288632848337412010634954368317355484422441490375601523182127040080681386680920979021788788753447856929293579213610069399116912987384006656023443527501447464682173445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 380 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (8,9,'466174236688165594.9218054325256670866060556227711696100465581464881295978997280335378678072434776702952026828137140986670189756965420183565968027969700090735690246176791371115610886533930223141650377886909408268207750238603105232560663571044993507074695683027062426288270199495225881785499139012931143826099668999261931834700467395442768201666740663642498098541516326470052372008385656719236306238735524802875519713512894448940917708118676095378518264553310312628830009314653641136566040400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 381 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (8,9,'154.875085756903716715488911525453064308758123952566428258639786597308109810869086867746263482721081985848551254298524280231489145092826397833394044637104667137816928932471315095067524966582810436282901424423215992139000153713476369887383242289102867530775908269805285313842050961754114751975054515055089553180717444020378611767296609130477264722612784088270193199394531972594028420402254831778715196248487757266330454269044609134602570688339750190391651801546906342796660819535014295618246236706572780627362908121159003488810140236665846928586992082180006454824311789091323774002510945263351862712964422865623934112293184149374573706760114682326698881257123280119140924775171374360283137569618025005229268057970275164869735173660958715166148344076027212231446680947914004346760896298312286730627916684448923824769') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 382 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,0,'54863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 383 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,0,'54863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 384 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,0,'0') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (9, 0, '0')" +== 385 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,0,'NaN') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (9, 0, 'NaN')" +== 386 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,1,'54948723.74225051983134098996071145685528795757427462111901537365053896571438476055974853245403475510333627298551845046116291696445177112567064282766115207407461565363967417615506303416694032848457927390574251904212425813072768882213388082765916956736282110801611726537663292922699021333445658549608928179155685881583228490235606377831724593358583903616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 387 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,1,'54778236.95145002027881946516375418483956830283115745569981757335827825115701888818627237691936643048426179661497641859124500994829625897874508497095086558766563666622720535497438693688376602804651302002795213923698663694204683995198328880575615535181012624198813873609885725228117274934655048553507421448724831939026752650108735245933317237310133362383704426321489070979168993853338252728216162346796960170352897972568238870481118474064783391570102958474141459619245240874849766946530000977144965') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 388 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,1,'4676749348240.390309875431213992853550297086049749814750492488995108783145961719774217441193547534210468967573344456866203963659951312519988497979489304488948342258375915152429008993288817366720647491166024151209542534474867042837694499222928509320280684557676243780452100132238968233413333851595648146954975713386711764268506890884764704949969602122157394714663532141060559896359465918874990769222345665160127552795532197771168442486088776803398878354288847069602460071745966589164282641033852314335279121191855487126430176047553895892632834940595958394834437871886013513058514896870683979585091413977173250824451205330441299000850618134248917380244749589254309567551846327349592529960432446947239714236828401206843011440433362544797025114476612133622499094287321570559088587999417440664282418005102546343020409520421747216') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 389 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,1,'643.609749344751131516972294140174556703217311736700045690413622699888869645595256683013323517984528456698303984909359393772036036540901870537096836621035845014213031549051156299974682317824766457362427063305495772666640279328909129870227828460705733995380145417663304348663705694070309475835826101153850359826502235923289787750107778906593010060115662191620280031872002110849782776325630424918493602259707267214006217268630948545349980430128422952869610116216278256812581821942763705098526140427280008360043829906543029486315209818099697988089748683904695870401517598840185535891464842870210715421728852789815860153472208176465166954851895457846723102438114697692610933532992841803219018495137378534010155991355251803548866919409031477821173935696065078362044927492034445482457329200246282082707380974745411383781') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 390 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,2,'-994877526002806872754342093885760.69667996446358567630831677089993316481039076439881735980566785462673358516198695146576524119916430759085192883825888457383242076882081857926408611052522393579396644731758241837010163568445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 391 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,2,'994877526002806872754342203612721.39038050457374613143278241259478942521582284121765030681448507149813723390800786083916642678676237719134679789066681148658045087323654637787610377226547625566084597844703238942080799221554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 392 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,2,'-54582443595378013373024060492546032003692.4875677735896411267274323339692558458420972958075073392126734000341372096298914875892612108329218081214550050039133117695428196702128258481789017059073444323729583900855712795086447886053552786449313809589992185978097430132940882612817775035217244553616977182049775786664446683332098226841743818600819221587510039430478859412452506872131851471967577741190323481953867845129745440745526578327709351120432530702446916035797432129052518980799424635406993848916727957825620638983706180841278402925286540375225365057191075559133035') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 393 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,2,'-.000000000000000000000000055145964114074763360265614481666934002579974728749248345352023099030383962250681574081874554842623852433135871821620640200582985140388676650602814646133317791813938390695683843848260103199745295436998313216878337673674660966362155480524935736646623766057029148471463569162153009963312016563281545776175277904913263614668092319707343286073000287493274965714031678784835459999763925833141049057636632430975424499618419962303087175237320046300285962065818926167792812657620724550768858763098967149546312995222223400007044549870620849992226072041407997925405957501929449911416474388622107825120486594723448780503829317691081601820425151593487431389373265285594626753418140874747955925763163132984655078996173911578832035721963554569605730262976354029623260224710106409129114204296314733036') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 394 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,3,'-60302029489319384367663884408030893999.8854209703537480818248540990234567956069965340942024890856088355839135538265116174644003927269495876835324407641642359213535695803871472434650475144516723617632059130297610134243891145006222068960999879308472500422640481972089756410157246974765071949782242392661524488959954348903412713930092273629207697480131360047867213863018127928853922173643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 395 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,3,'60302029489319384367663884408140620960.5791215104639085369493197407183130560124286109130354360944260524553172025725325268378015783145476572840273098165721628341015996848028750420770651761919246816300854441592109844750954710317145008297946462099581451150385769713261452744310496166494545449824802407416426304041583975713483424241727236417259479541129474082301376239522310995725648773643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 396 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,3,'-3308379209762459471107480259839508279070920437.883503980178028214343751083865562028455061662673132221930429904398963590401793045470444301883103141901787466923883803951815572606105617157736442670792467625964359169270739534412932791178258858918086886061702512427989129732248215348301444245772127142869263635282888226326427510486246184233225114523636171202034558843515894542952126988613018789833835507734620046994907453602573865012044120483116345444810078666601100257620969379968264504287700045822481492526688635364586344704730579892342786173395802035361824932075736340405960099542224953439044947229246847140957298841482874444906129049023002897135347878048572628834749795298712449864571996898774444932083319581439741625832405434317985988163261591679157437224404970927012111196724239860528859217322132733404472897289') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 397 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,3,'-.000000000000000000000000000000909811507365065002714756487495210579371808512079908127938523896001746219475805196061435010714649189975968123072269549018826343830061696154665503565341929634172463095299662727352635590451263034658630449260378893723785917860125051787451512267088404686342938118993621396641623525252649748977992770709930435013456855344203854749977414354164157192885125263071636468941596567220391082793700307461350484216679632552883058303710297475827456761138832914743429330069022439380297715971317819244718196187172770061156794130040674050533617155253444764036426045091327368023602807193742585178432544430741520636125146531502042579276206322507516332917325631822606079220413965396706334639331097621824106950192993127113903265025719013680733760540930122186345919977470628988674677630636632053583144327') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 398 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,4,'5329378275943663377078725.59616792993138452386059664269485161374191901124632386474661634799161523147237015531446709484039091244606359050341194730653343894986479159670583937529516163204904273806158788218327396375034882788180783796976731912141525319602448709213495905899041406302673881364465504945113279286939663215197485367850132991968081639290297033476859158044889351836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 399 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,4,'-5329378275943663267351764.90246738982122406873613100099999535333648693442749091773779913112021158272634924594106590925279284284556872145100402039378540884544906379809382171355490931218216320693213791113256760721925653394811317969065642404864072442190731745871963413981746671302248281216916486794296983018838956112081135739969615171358100498945955409711817327376172085836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 400 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,4,'292388240303165948041827159734686.255558469787242316676287235194652580157149226950109397295920730296960145548003120827363226435916209781396711693581454960342091452830648929118261388933297036933167543189308061917640517578583521401267417187854611829815212778183983326568586118831109538377828156118900313778053576483381085207892754728937946691892849474364477434665960112125254104966566712906532318984871145605839506991591027939136026602051635433295687547552796828217859648186757719639965988287173297286034098497871707197092627676226053609131138590878743560287292934815277894463305001278326023708395571840850120055316276256138004565442099731931051413153564744766098053176049414330146267604802971221161572130161432525297614616942172815141372973870720928125699420370428856022295499447755488148545048400795053604349570217878099721865670458104653570360') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 401 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,4,'.000000000000000010294536718194523982241053267404812827031741197656209184880073175960433631103885281961037127283726462743623757855378209281373475473018922090781553213750339001555832360656399849031527008437303091226051008068950896796359518673740801770866360774945096397034708173365378527676779736929035450380795854046109380272505550244458858231227568118355064007614608452292270378691774826689216790090661497154742954386244856792006376222923780801296832612827123778915598893970651480451509706836620045721191411824060983487064555397842027454385628620582036592315345973096405447742002746762099231557054678593446667904250189208490698468539396733604833688133512716508825505666644390119877423938820483653319376926639295680552194966870285838815705038244628263602997511842285889300557188773128635554621378148419364876651') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 402 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,5,'-597892150.08771044822540810796370552966707032464017958269847934730769542644402913723848026909285133109089452632480800168074607090893991283808726990171062867538012237270000932798704781608969096508450960185964292594677356241956277714380500188870696516251767979457838109804726539408115452577436052503866633026489282425086547752714324273565900641436632912781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 403 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,5,'707619110.78141098833556856308817117136192658504561165951731229431651264331543278598450117846625251667849259592530287073315399782168794294250299770032264633712037469256688885911649778714039732161560189579333758422588445749233730591792217152212229008169062714458263709952275557558931748845536759606982982654369800245696528893058665897330942472105350178781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 404 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,5,'-35812445701642379.972368737320206275515144213236752803936806738624588812089615098329765811617509505790110909629109400553415312470540217508070421816878544125783329593128638405659896184248784794258084116406472768709113030915308410565617764394827427154923321461158387012978726512246146545834669665093228316853342805604075936530371665576147966721599968786161939347726656168798065647411457701453987215491345496003650288850096338695703984042549594979897253521041581573388369367579323607093487743440894765114619634001789457486407909224339065748496715380572175183589195611952939575073075140094901024063428239223964510824958346570603142906309198033196987949067156046076497974760641964978711558209708743776024313916111738542765749928287600981397080809041007714387564206594515733287925008053261840295560398311905155157989225181164097547541') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 405 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,5,'-.084049034261605466896663277055600903951276881294745183935726262038673990196778002490449355450474227878560465916800470848046625257516764244432096856845087412397406701521972651300484716852035267197801389708234913163750232707469240634303111868882057393120649919262424619226282082184091177505826009374043368623853156698509808569378758387708910629731005691079770517679511879694426434724918004419953301426679939010592502325130576915399009756468717124460489039474155719834555522581553817856854607844133431854471292027873672356863673617090151801474016666978499651970627896504709551656249007718965259502928591648533670568214972768900993459927860068104745163979267716597907297073374689384723943955361288974065531322408839914599555769945298758102515352082822617428033648130099822033393662643586331479103933840387663729387') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 406 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,6,'54863480.39378734225015137845671346015520435061071252892396685718794832880965812803098645730572474084523997120024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 407 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,6,'54863480.29991319786000907666775218153965190979471954789486608982086888806174552071503445206767644474235809840024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 408 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,6,'2575131.137912978352131546639620215541477987701194164886305951830806120142596646541302305984776928560906754259789485960991272272782091464270104432109904222200473616116525297615725803495463468272171161659654385929185160689572943852767523792651123455283534072794326647404332228203001469884016996499768656263775233430922446983838511590562929268821678518640501686017030536100955531423152839988008496919169395159653034847677470665418765966542111749439412') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 409 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,6,'1168873084.346566233232746391559830634361431940000227460271861554316197556566224118756340501278103405856646766537018954185964066240457859194626558143313125824412559635129130086906976028635444060218797992547370132082916380788496584864016645155338102476357490305222392452114945853620686975383081427840791892729407194179236897452655907829255937027286698570784397487382242990326347080472574546312522326038419753951437799831430690304084087684303035538181812523230890783372773953961677974396907303758903934808035747944477277528267001070234880092255363221274303820343225415479126819937070570562654065195009839593938440374000473302075568746771126391307584779249330981594640387657042725725493800876630516005713789705652827210295338592985225924959199657729900181287069808881130884115897407246324220524401243575641227725030779990490') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 410 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,7,'-818934540016982261.65314972994491977243776717915257186979728396159058352649559139156429817562698954531329940720620096519975256547379603654362598494779213610069399116912987384006656023443527501447464682173445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 411 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,7,'818934540126709222.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 412 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,7,'-44929599044588573810654775.83678007633232843418115790847152455559258007804727916986432256198687661496804050903769496933400455947645400628259699874770581538122521805603947464462448454681701547899144129061961394870320463199545502030106801911915987309444301341575451240764927967432593181449618816978119423290767783843864768557371257918447461479570164065303599994081990686') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 413 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,7,'-.000000000066993731076524206362744068866774567920404984046399050881532938231826344009126898802592302273719505485084766150904380671495128604515800845609713368334606489445184535043833069145643553083555507533900955661105251251918425885537513359541698046533092111969478225528665278023069818968531644884466229545497943710817187632203193468836772459599856856811131193744272314519908999458320275710240994009061040198159739169960258978462113813370513611735006229733329565083659159456172425715216475781507996483885669437855000029758892126410922067202159414570164537031153818197618428471046051340835826664787585016361564969663413176434498159140395476980277574789931364078570781760777773379636490084338326576889857824344578398580499610233575273027387501809967324874264742269453420400624883982643066864175851881870402856698') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 414 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,8,'8551849703.98748751358673528924211852802333963452553842636251612056366144128630740476125273064380199240146487881028508694029546139131732304020786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 415 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,8,'-8442122743.29378697347657483411765288632848337412010634954368317355484422441490375601523182127040080681386680920979021788788753447856929293579213610069399116912987384006656023443527501447464682173445385303315267086044455246361273561294141518329233754041352632499787199926225490924591851865949646448441825186059741089695009429827829188117479084665641367') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (...)" +== 416 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,8,'466174236688165594.9218054325256670866060556227711696100465581464881295978997280335378678072434776702952026828137140986670189756965420183565968027969700090735690246176791371115610886533930223141650377886909408268207750238603105232560663571044993507074695683027062426288270199495225881785499139012931143826099668999261931834700467395442768201666740663642498098541516326470052372008385656719236306238735524802875519713512894448940917708118676095378518264553310312628830009314653641136566040400') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 417 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,8,'.006456816440893715330247418029019114736889626790871612141686117271826070935285769018710680035004320626745647926106882508048159628931624522666638442625219959259156539178378186912871506893482633695438850964052285542425753626455183282159259999492971992739484319464700978750304962671213318202670228197968646486740006148091321740497272644910882302412140576608739962605210964504469426861972705740810533465451230811358870068391007718532021526225893542801514255726272411690175555142385382688220121052891017808391607717500701760375927811435030512071347521837090721052128992926357375527600337655573639413811262412492632491693179011503973930804928749370652038245414768103001067902012962988384812280453070895781287237746786414435546976395632454474312533482077585837153357017362048554313154580576238549196250793055676215164') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 418 +-- truncate_limit: 100 +INSERT INTO num_exp_add VALUES (9,9,'109726960.69370054011016045512446564169485626040543207681883294700881721687140364874602090937340118558759806960049486905240792691274803010441572779861201766174025231986687953112944997105070635653109229393369465827911089507277452877411716963341532491917294735000425600147549018150816296268100707103116349627880517820609981140344341623765041830668717266') +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_add VALUES (...)" +== 419 +-- truncate_limit: 100 +INSERT INTO num_exp_sub VALUES (9,9,'0') +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sub VALUES (9, 9, '0')" +== 420 +-- truncate_limit: 100 +INSERT INTO num_exp_mul VALUES (9,9,'3010001475769225.8286280957637941018500905354415197182850820227163907782811814730309044010416886791014702373809932926301368137684091094408663914110947072451332976891128659038142954192986392936981664792370678656287232795203974766040821110221158579481177539669363513848425151485663431478439528936592701070340012569297177488556353760756495238304538439278682066056721729656193616571456456325016960870401748115848423105783116854283646624807603476682295234280408938557209608025246638166902335016025467565869375885610813662767004038102486303756741615124814580306266901273803721191779461890468156043551004644728343579032524687612403663816107770451694666844862368101122025340182510019516924578414085461628689') +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_mul VALUES (...)" +== 421 +-- truncate_limit: 100 +INSERT INTO num_exp_div VALUES (9,9,'1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000') +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_div VALUES (...)" +== 422 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 423 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 424 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (0,'0') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (0, '0')" +== 425 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (1,'291.964716019333021494947753821238960905461614737525349376826064492714634914263808902604580614735501799528494357560837535773816469841426747889103714048646989532842972129124080559131220979335403729022278994440514872845756198274805589586120535745968205107562348427941379641465378272611453955517402598409789621997041856848783989993820946766177453801729783316269310186191833995557234577548740940419224137195404391193633808203715191863638616433190672511651125299379882126530500870287424768024674231651229908224729856278167033444719242144302972892419034855417126978468296581589282861879645409909873113678361180607775255758820910366926076380306290306477790931129670172989289536405788838857428768869345763784112862591549008321546447442552533919976570125718481191724503352619626562352280522949665158335559389298720990302071') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 426 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (2,'31541679188064906.712574384704440356216787857626740375004266523720148374188511622980520374202725176835435173058936870163875556102907654264048353814040480579464700545975346621546520503928314632418705230212623378642743044255181848913683862360044189531298446109955034944189751302497670367665492719604026161836224535961347218522748523360100432275693829501972749859329753224444694962089604095212784768854310289429208671271394086829270986183171968944659703708706544668326267327938226750760690620258967209626420981505237183055363540806281098871221581265173394406715458619627534396065960117454160969749739483126059760636526242783235685190739315590041294766649891987044641492234243404608847939002062827210734973778130441825067858641461599799772535304379732674727995848518807202053316225824685704785148921785964036119338754973714515974054') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 427 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (3,'7765438138915239878.949520541017683429203286303188179443533225547096446554008374834292278237558244698868300666061834105683999048386497322007336816482648302911579331582895326423063492240235074387242190187374869842856897538718280497895072291181675294000739548676781615025944675912072664211455701112700937190832332966000160156597821149428032612782336278939437593991008833233156511435294360065004167893309428565243314846456225604669764879344135321428948841659419438769652686215993544390780212859309497190065178705035652106614050448518931820975038314187040226298661787490226917902356569717171481159691409131778764973037046501816919243659681416263730519167614043077472097520207347950292377914586524327206547377189493301153212000966249655331053184913579513686655963686155890934436604123384536027235444923674128269748280097789270784333442') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 428 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (4,'2308544622905.016172868282330339228589083058636874526727829838244942341440716909466939214393597311710652963849541394758298277969240038668406494621950956862959196896847352631445328917063551082418729435554972200530109505384839391233286173517804321019323644218483570886304028175359854335870835404627608254205407525763332087823548640923282031978903399118139052814618531713327991857575390136755426466065839913887477577516426991104516201265995293600539957187007068885368699949673989051443005684755994465547159213587471972139403333249259808344536605314911144950465968669770276463111776581675944967401948957460097365849699783091843609965345747287667911324039374314413430490112443463386381631812537639503425989372084906324702158112088898424705684574998783112519152403201231176840068666882123684602080460378627639651465436618032671756') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 429 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (5,'25549.082770905117529972076915050747181125832857399138345044265535151111965091602789684342996759657333588444489085160336703294705499665424408218434077722506748278242942379566431768762487954917389137120540138359870652558814224523699917122023018717544160579704907452934297025088008618627873220397030397424422097405152321366495319708580932627092620533785271831833326130796638935296720064431288560292191928489034307645738331451165431755179025359993690642194334018457793169983249853388987495489562746304107188105521296156525984787815685365255240654972150342496329030279439124533240114879332406941960563154881888172285475336782757262639979527682925214971861707635327995621436598536743180180978457735632181738067997521785965451385630326464388080990200265186437768409003553910194212076755448477164192901658547251079126833187') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 430 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (6,'.216649653115510782473161631235601739254284877523828136703593069337209747459679979369185882839688430004369697316986054374456779366220242645866798278985273820408495361607183119980716020227424205519727777568954933592987351750339481522149106749713967143685591960510946511796062486795368200503801097611436787402191532618456991115230272084771674098613479989808680789347124789253499967359190605681912854639520917409710307182238065185749856554472717209097115325999946728168357936779767099041518574001682560265549916593333117469681763348860131760281253987626822958726920016922608371657319505153308390495179319529587670415367205193280809809356733443291197315823747505896510820272670040485083775482983378341120809542502350385555577946098824446199419354197416933858522419312733314383889554606932774046771497129486979593226') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 431 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (7,'904950020.759072496304165474991957396337281699986101765045213964054286624338102141970514306010139529492299343393832200631760194440206005974547202512275476562767685193838576516154915404389465528270010938533075930081897392863141132529694804621418663424569202655893682412466871297412964570322984865326770090075582481194532433411398133265643849129084449161396724635797324126396071308557057830046688990212282866035593809633839882468628249964862932050189148498591642162462777480125024786829078066012617362076651920045684345679767223337287825546294839320770903419463644110383560050404456170063805115223954191445548226706113970164823214416171441655706141596091717118495955441099867737827763335880891937222647408575142200256804313345924443344596462585960919126827045197885802122062165934504665811115031150357820196176799560314653') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 432 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (8,'92179.098626752893864900181023972781406074846653380680747862421481598042923358730531575438403865501429843141967819802251116774924400485954931201776260931315313253827346015775662310076094882239170765060649024538403329505426563390044695320714825481746233901773893996663258170360232639353378395244461670781152793416950717050461856097473105730100523010642696332151571372764781034028324977128554099993021459338419164426784774496292405945103200724413639660488309795423335142455569853549710795692020963174011003447023610692365550245567840477105794884132665155376243735213346877116105595296043532605899184658904822980397411096930267453332143879534914237169761039374689145860503772331147367757318826885494994339695470190886515765452545019167989882527248872835783707554463866334705735781549392895480816605355996057201589681125') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 433 +-- truncate_limit: 100 +INSERT INTO num_exp_sqrt VALUES (9,'7406.988615277484686670011157489572203134420118818648711986549881046321377798441006745317356200279801348355202517703531020643333388857073977704009782384103170022716610432579974132111487533733493986910583223121269323909760573942980360508642443245341392335557152177332615977623338526935953706604224108508582338123915133189529507760875123300397933931420500010248194253078118618381590347297853307090813639981736227771834732256867579490224181748450683295253634852775448770576585177080941820456051588076218688792321741398867304684922665590162004919486643750098085197190000638539994723704724550600891137853975703823903659121582583388450687255538838161486019214242094423895463814933532217776443473765708693285683261505695170847285063013324823850724236845500162436661946026097459146424122412596018946436589967013641971183281') +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_sqrt VALUES (...)" +== 434 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 435 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 436 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (0,'NaN') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (0, 'NaN')" +== 437 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (1,'11.353265918833698201334218522735144514838241118349715803442713722607336732214173255618762341321138898556011520430414052782971985419141860417968593746833898952016980791997105866598425597066404919489902082738711038276194174786383758877067916049129476352925010880025206629976454341252818402788928939407784629386362069592202090897264194883276572978998896242281239126931595483958092059051047739223830394259082355969005503976135238921488192773135287876801394308064862257453262299764712613486466254696464150007113953810688169396432889052881763511661127351872408811370081346456019961324265446884877073712053408327408917588393884214304220369626106333713688792094943405258431214313197283237071070354654837081449831786573831004911008790533179001070424813584405346221388686999574752038655226138085374176702005198770598232862') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 438 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (2,'75.980172429959420723484178622920965327708652620924912610122049843800380131746381968266727388919414524075492921510147435877107720844487333947572033626887969846858337336557672107987074468763307953130616555202495401302128216460637786993535376622372745654109623249396257174895352222213037880060756992073605135503615371392439827458529942230210514752764526895030759481226199720092008002458654297737883219558685499445394647863430593136350562417924068100891680398878483362058595716232013516337079804607378041880078724811071904523716775991447489914128580100888252698281559809224785596795038122963619830942475652745611551345360922016753939774272970008770647516790944335173711498988149783075646985898883858697162003144539047532603946093022417842140993960433780913606807466518632121884254341907122163281927271483110212890483') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 439 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (3,'86.992429107491709045555322727377654177072455841678650084144967727028762699430180506209786297136121512625728883607972513154010138109866327600596617277403558404624813332464431424791338402731178416819791932126837396086742033973404980654712734845137075562739300866280737071167943367603243180515859476717635339619107593771719314284984269343476343816253634799874584843436046260962736006310389088154751401911743739429257286834178656182340416539923956100441369280015412718483971113838923221170027312390404790743389872757674342133486652087007983701950040432125562287337697971646750563062524010514537132255605131615248097901911480464339325353279118429890601202554448469387179349495284716473293965884844451619766312048304583068386805927433174443889441171878078987788018564357316138422561213329104267180509029624308926098065') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 440 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (4,'56.935276817066740776567329017240462885579486075188456418197311631774373422196025180114152248099799048545382060930401786002025479108787121595516444894009593031141335985913019897883627990503003577804436730367402618412514152465206336556967419434371593632864308139215157721913158949066717186782560422199668568894551013785702491365073449320535603830475158258853167712460432995074161536886421366716995573365924430692151761737886552457036412140640821310927642146210426044265504978418405684030862182425702683702307323138985481047994648222224089112998195621687911787785594701557252468626097576375468916953563766801336922479861708649876362257086586679701715813254414915314296890025577780265459584203893089574567331742100451277992780400302806430264717887468808962517029442262560742822875484362427192693300423729233467613910') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 441 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (5,'20.296713391219923821414834924710998522858242536565236229645868008008504475111229451635162536658197320282791428572861452713483981402773630985812066048575864982038046409484905688236579134672910905547858248343712686247795669280482288748331949478864729205285910525962001251260319741279139167559906461672936902355959755164523720443059989357054368460911050707727029320725144824995614445423492687177126412520389766864793826362309254124276325522276592246655562770110024099522184080118637524912964002223613671995639705240767929562023556724031894855094820328152633412077228479168557819219970917880393852962560319397442566813746504969336443969816954424715197797253670026862362130664772772977978222813915593329422557592316429203293264572088112274848838446633519530653849595288125585730314673691986554304725866754516304420665') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 442 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (6,'-3.058947463851998053084898503420969773173569760507671013593014983772013099601022840164736581595033399273677583253456908293015637115395777673836877852797643436458673662566205707359569792482081945396989472318998080581824382006377064185813936544714612287417301161454496258176319380348780934551188852900784476213986897306897793456700682073399936398243222895442594762628402487110466705108765286617060826203345783502301472192906817785365563881556293576463515218574477264521950513789471494214626744754200844840310516235570475410854073969787604451971790833680742315518808178608136598148628107328076871698598743664423452623124027059698038466681488746505289551548778131621576387262707147068500249466398507704796800459013580425992071957391417767257856002976954566094297724379688683375704613872658653366052459242767328235849') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 443 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (7,'41.246780548917246608934265057073076900048579756649769602488660179351587788197892095257027979113051775079905924990472069951828742350559917110289416201523653941731339141666097617614477426376799479821365070373247490598890520285155435501242427296281987676879064510605563522117334502131946383957407685328562874307957108543536378261847119286989184256009392692140821396916222386573424618796707564187152459973446833193743614720624765332006827171872712331032607870580880807058576154429597725560836582655488602546786785520452359711161305828045237044625934404295366273012300148250900116489718279757540843657039519736455668388572899273464839528462223812926410544976290646668870192676914370659142463304861500879195867873346447316374869974900582948166687948531910220128160490935170837209017355954301127162240133341813847180541') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 444 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (8,'22.862977375646110045361670561177818139082238721442691850491173190000619222046296383571431877856442345505931635735363450488731186880557789439424987680284612480261693386095598289519783790826332183796775862215503493910816035128476952347072320869461206895223935484838130924268616681347949695029657753251443811448783435000569829291535036468240771401957519222523032235686030017496209956550934543164421459898155836108824017735809352580723262896259290484291175350770265895317482371895188221452083719817251845416195168686335127805092334984596224320638378502008767433534450949989322562311171685891891122105437154553106840103473941148230953978989145470651955269817951560544095229079088083494695756914405635176899994279484466773598435268700064279990885608144109747858515514066444373797446449729058958270758597627587968112958') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 445 +-- truncate_limit: 100 +INSERT INTO num_exp_ln VALUES (9,'17.820358481980064387183481028572263407130633079314879566896470101569251997264841660326428805413719418277889123643557369421967068805165885825106611310020187894256310674762734896979157570968168599492401269694048046876387337971177513661006711375440365724346137980004810780215236524986274043416621637509807126148966029923572853117418545426960105154053049098579812135003711132897895016476695223444397389521434633067499404903493027304737402519428197015899833229473322655155458942323004249812974150129789653469524573801259946118454333405580647485894435301530550214095993989552176497867244278699359917247910082169086524111229983698975613609318418313798992088206507831757327320958918656453341769110558376097374227592021075267882222057385413453949580066342977546145482215220982989992069525148522710254796105001938615214263') +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_ln VALUES (...)" +== 446 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 447 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 448 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (0,'NaN') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (0, 'NaN')" +== 449 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (1,'4.930660740129727276654889314296515979425461685461970306647398411855044094312185293195497201658739777714943974003690119189101973212927970410047992001003936259467465542044528955416040460487922970233600641954269411521809500203864460110903973264337093883907933081597350982496469748131390809569321256206859934619579029279954574676601709408712255490686948453752571699579252140062805776361984468580258289509013081691778727372026090522694670379557247829136504595898935235926069699309392675806881162434168418505908116911054206058735257796918687777716036307205415038158583184624809880157060625643069601549803887864772092583549388533013233603450097615537162442973385137488450178790573546382354482351187412256794374383453695483855501587939419102008302408157959291557415763034668013452188944554607063362933134950906875499201') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 450 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (2,'32.997769620388965086774969704518222090258389987679691893351902336370051104718852164011301929506188893338106627980171059175447833290713847317665944354651476245003161501753612545484635275306181777040447675475670149066399611203341262105766118892586541910243351018829302798733989560900125591073082441126709911019648451232244139674063434385451279378543163944005973452562993913383659295688375546058256196254319767218634546732685705517341998116744642480938405113447415486950667007645850519659606476727681944251201236366198374488204017630268083077471516734133869728427050843306716313813724061560369884508660845630727190444623729815564381063131729592825825486515070406390371638817503915214206586939112681762984038333298146999891250107667687034785493312416966635780188163871680959873288697497561452228182734430749066579749') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 451 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (3,'37.780331928743475574895606142114739140772838801045013007323050327909196792739138159615327729728110344767302636436234256468332011934881494997184865617793179255006442447189720642997935223133982347184994174261506212652322213673745795726283311685835974151422721233207287206894148660531800622455957268888702309499182978182878524951883775154983702898237404558813230370364953160102391101897560104513279410610948028599674950811462114131673380477843456965645417025376374320207504913806546872166094337441573669261285052323206348035827948287081776955945081345131570610652073053464020209215624179904586956137079321655773178387441622685682721151900601340680061607114354850640946256225260430676099781727317540719923791064452012925902993317349390523278687089530234444415688602090547516647302454865526291471706301790881694022223') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 452 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (4,'24.726676547286224970759328746582840552419566534667446425423046931401641497155587075591229106937829957279943690528061985864558314570189069764367933957499905044566413640017549478921384160584906257607957223101377816440084188042395098536074479064548620374152344954289432050971466476174493306432228880930006524504974367146536665170956555486181410864034862861231267121149652317599303804477688621597163730470970207231328339082779056152481480926452142005969020950341307977091850953883445808399574256295803245530993204179747743812544604144379381347499056545148243304041538981954204310612049423688645476667184129189153715486929216331980316967699254518020077226689317148303152585009031597809279387172427408557115400021035692880631275593381822805377317270568779655383061987766693697518921188619814204902583361096973421134004') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 453 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (5,'8.814750626578650238811431417807018895270298639823442501111235973209197727215795256506525221092818797578008152140054383421240180435087611869193019443372556081555311825248667278358330916098378127100899126895012782320751838528480712942601038190627182482614147263228588284866661508052724762701223357327343090598060805245853527435948381893458352744679795853650453594546267600486696643924152372736774331080527157374379043696696647158270918245668579680394279565181670004245143555617589138267976417280970718829942998800499312890580011246294669585429723974582350357991472101919333996770115834067969654217063942059882195268353998096891812525364797586486311202350700339609637274043915687880562465121559531284337603363356183320193656553931871200575467929714875483123706358278876389849119105053294688326141759401230994901405') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 454 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (6,'-1.328484003982869642690619298690906747763234110040562640557173509402512757735587333095924652711056556491908059708986413635120656426593745303715671199761364516107844087845783714418487426723538440387069985879601248897538855843115404484229652166941838283489828419407478748732927617251897244190697443966424660881366993754577233476597163021768156814527570512834684713730559883782625870597080940193303268818336816535968869931456641949301731046034660616615392129109391145214470757259042172416816936479713743188047425796931722546185493217275537303458837771965375448968719169174136287532752370175863826715450565025635651343928205805494319778539652563499901671319955144823432132740582617949774638538594081514904904341299199113721131520557004571803778698005652464301037962272085633628653321081368256925971558076970172779715') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 455 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (7,'17.913249188669140643510654105014358282516966474257460687880559542190804665566625978925406311113121982595279826214959603627387555578965653325278444455875162277940655989601428868642914577248262147833499137348602966573601719040813549936948178463592211685237720748377879836890106515699728652218324794927458352954247096536337594789471529493944292143186953509162522579060020018226817623648563806559917579317916242706559131476179714031602207057714677845347616752450567251644277767418397621490301286115159509360375419599968738067461569666699939732107480135216621373057421990702923042287910730395998082514702629760389192370666675364405730936537832803383367187639209534697198515928978064543150195911463663617683085348965065679311986715357338675515370634753254774665197233934933271954463040729779956682570415317734489164385') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 456 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (8,'9.929264914121995501917993119394933531225401243275938207624866270551448544301376913376130982251708700134720886862945040266148728213253651323129942781577143957084726727561987639140151337848818195806259935747329665025823709044567138449084349729747202164413995795609659711723455165142329822773177102845804114214340046404641970845707372809306219463962664551623665322610139794354769767829380018857313559373283673392337954610346290037758389035140213224696023751541663171574697035012610534455189013755134090933979479069288110010954211669067225249755249337768792642303351914884187159646984708862430789018895140670365476746734456807215043628059581947593694929159076346249490593187993386780521089745819640214783614157516171005086731241769146397577246387886107367648843380733370112546792442909347322732196805316614555689762') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 457 +-- truncate_limit: 100 +INSERT INTO num_exp_log10 VALUES (9,'7.739283354261751283625223433456284905560931805428759681411970457812279544250432389511382263439324085689734710188041049046660480575958686859942980599595036769090747781359217248301544587434077376812293034848418204834388504169166350770257248896025815531248627658465029806509131631454856186387892627989218208026727504548130018922325585619738185507999433763118148418722504204066578294826264005398891049629199412773138457218976050467479292777172717500219850781664314597312411301296201533610562886229900497272268364496763758868455934979903774531992886483396489868888731578355541611359130188566524240259770918423445785338175040098706500034487703124623745259139247432324145633151895802637182446905097253961951018926565652497920605819785424451050191604602898777804133717341512568151920576684198443843944721398831404081859') +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_log10 VALUES (...)" +== 458 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 459 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 460 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (0,'NaN') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (0, 'NaN')" +== 461 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (1,'225561990715.277245515991117670624124484084762557459065170589803293759247930753528436379932442146759103295277479258327642314622036941865221478746258727236601688778946696303277607709407496616423493315166963938393760548678730128692212077086588682984700837334554241405763691119669847463520746595280034536307041368063462023793177898200220207765205127584303464304601759554817607633012272490650155253979182893585119965271975927569080191838676053084168631217591768468344106219831174026139608715965691941366334940196517120885214887008671956523579678156919416435031020452971977153991139145404842034138317592877675821045409772456977018293365238179815614004574330200783530118851005077771478448804470170641452481992602803877112958872108069738434946694089025321283178188028224338756015337492913115267362635647236447601252924834642796058') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 462 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (2,'9553718264533556311125292459627965006385666643531070061102266984368939757379.536714147420215784125170401370065894858487440153494392538261078415409784085960333028254155527328359894197540839556987826344995348426293585457768226283066583722499658006242709930685932246087653832230889613022921575445199055131152661556678809191264086381976922223866204038615136758192929883317207903579770917317641181652055458721731297347443662717939116561947785705140374908203404860090658919334137955075887697259604047657534191202566335372150375993361370075961180728155127447781364264047857624746079509591666068708743260905728661917791822925979235918475633100283148558978385583805341715868143937062092264994833222352433299015979561976964779350640064096690062929265992966564232453102431600199173711947391200249130712039686700111791790265309426741120465259677894665532560198051256215915373145226284270408649736509') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 463 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (3,'982718444846268846508445482774217796844461660819285525931206164100817251856409365450682.362683768066405322653747385034480250394145008573806022660379219602846285813744865438912887625784087005970975437905783802114553690522787857272953842288090141945268495451006273685577260054069522075046955466204804067271437138871789034722069934693546671607506851844248427950939791205412350536883779850165603116191193657054604569586553874805856647223849267039531773072343908345333155562072887754900969504551717514980465801806565999410206735831440712124661645970935112535081991606671600328471264697018198676317466846450405861359235297846597981143547119390922405594115478086038680663368675222949247096131378724350715530605691796680604309063173515781378545860473572389718345696107553363715518601596249508215455106779522851210398208919496668879040223859884166805448827948087400426315425231119801173387715922086154065273') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 464 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (4,'861542720105376650266753999919217194383259935058507531116.774511336660822591851369622743235084609149542494189385785321912210129989390054947787009383210009523204976629456268332186620016067379702483800883493431423160815760933380418976582725913410929214462739708321325884209636272001805871036779154087677637129248122540412937033791526383240502286607736226090213753913654673523613612439527815137888202973659987501649474772884055648603290154867585312925699571949539600328906295652872654314913539778815035321695215634102441494403825526533235061083947035338872599854931230001361227174477274708230470794066733245241594719912710139298949856243576688344051439047966427547889756037265151798639614843866387316916203238068277912991427278268083231579195846744438643659745041780103653332041031419793815914447232121937821142169172566753399257291244398531365781832297786941359729799400') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 465 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (5,'198021976607570296508.271597639984889464620426933601643322058775615235389194561064983706229795978402690473201671702614911129095149240715527556855309177671128442458698638704394974473956869419481315262823632891676087912529523219333012290621046361106033860210270638559271706082115529424772192777643046125905852037759566224116373416253787241195450409652089019290072319861181399387753223422998872180810295299831487867222464355713552301775702554189470264147325049133532522718679336524769566984150923939420759804463781082299907043016120177416779442865059261387111806785876531152192378576258351599534512031062777609734092707165605364139201322351960602280089186180302246827234844736393745487324460438448807241887783263546165171099497316415863122023114646876909575845860402164818094500541234974716577550807551946414081410743197768993152975501') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 466 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (6,'.000873076977206566818052116526263730226812004454463281371489634779519089200224205946321120805055212090024554381349223642352209212670470260295303361873760972918129853308169576675500721645609379420329169271088810484607337679253503247351324049221970104335289487989027621978310506220905131150125321713385148268584530413680037620544212746920563790371941626294733473967065607791756894237438288480748407449237446113996117912144587258434808327522518688617394025018756570740098795745692805352377041347367240475846033282850136270250633825482156304826383360291164928049344226886150285595932088884965511963310715773499733217615863523253012606066583814112265708693122563204149232245895551314975524172504103194858904869273185785182598234060315036187756490539352752560361560286717869643902435677448962235275054804452967413005') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 467 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (7,'176514565873872717825163931126806100435750.096278384530154766967061948052237623936423931849868926020451465515367348890410352640552194499619062823622476972850692557798609619250753020363520533767813563613425606228355802781302735485038377521515850536680425059519814786118919994914180918228654298075183514200191737597656810036850772127169441661576862538643715648802139886576391427423689320082366572297580054381937437005879583216745596935643579262248665490169331304003204939561361718554509909313409421397022626924406091551900222555950699170864234411017062042057683304265485826061096835531732950909546314722726990314852356462874701181085379772134121978510387397276859318242238150439474660772561390798432890789762504242822787017140808209820627435991445529404692793744568204608385843245177656436105160780897472099970336514833257055017279707999437302548655364559') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 468 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (8,'72941951052009383458167.300747500436981484566111756088702608000390737594784514635592222758882092500858797317505303492923829092720870826490477962201959426813271424853341826896270963213736922458746003100613943600855942721319226948714369219316345322636075285343544788982588956431405042577296229122673590336976893594798942025893296105815818487227300314490440902574022885833779324177053242170024559675073866612316965636832258283516275906085642459351367507561963945012828379111856700009391438637054015804558386733558956649061672420804826896303889067785497738203077050774825608647969196321506624991188638449047860249367840775936911749905927108478444112230174584693363226143549933224252679398881354887872642908328737917862751077365602631600279486028043329404269490375935308156815477700961014566228692743960491745353377403533037122586797765130') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 469 +-- truncate_limit: 100 +INSERT INTO num_exp_power_10_ln VALUES (9,'661239032819374816.097553651299556484820492272269662685578275493609248662925676004753503494252951243895572437264999063878330704584509915845096232798927524470286655554736724913758600775591269525423912692080421094644542553026831758426157681271572808657664918053119324646138457659418857926209701677786068580819823633713337632456905824562235373422309621872998037966404189020165296080436871220718574009921789858751384547836431858428729570977259373272041837411903005303672798845573379758630607982213326716018594073712340609488043353995410508475153538231445235003980586600882223782814368245305160648543466496726973755388826656879616734762068443462618454921858705377028522664844761719759342490380417060255776725333319537746890406213693117052223545525717132695297770810635066731941724108167146710297146989770382041617889670713111888375717') +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_exp_power_10_ln VALUES (...)" +== 470 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 471 +-- truncate_limit: 100 +BEGIN TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 472 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (0, '0') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (0, '0')" +== 473 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (1, '85243.39540024977626076239847863600785982737155858270959890014613035727868293618673807776733416230953723818527101593495895350807775607346277892835514324320448949370623441059033804864158715021903312693889518990256881059434042443507529601095150710777634743301398926463888783847290873199395304998050753365215426971278237920063435565949203678024225270616295573678510929020831006146661747271783837653203039829647102027431761129518881525935216608429897041525858540380754759125150233053469999022855035') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (...)" +== 474 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (2, '-994877526002806872754342148749241.04353023451866590387054959174736129501310680280823383331007646306243540953499740615246583399296334239109936336446284803020643582102868247857009494139535009572740621288230740389545481395') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (...)" +== 475 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (3, '-60302029489319384367663884408085757480.2322712404088283093870869198708849258097125725036189625900174440196153781995220721511009855207486224837798752903681993777275846325950111427710563453217985216966456785944859989497422927661683538629473170704026975786513125842675604577233871570629808699803522400038975396500769162308448069085909755023233588510630417065084295051270219462289785473643946404281422516357503746700705970360169619852905053433235726497292406142332833') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (...)" +== 476 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (4, '5329378275943663322215245.24931765987630429629836382184742348353920297283690739124220773955591340709935970062776650204659187764581615597720798385015942389765692769739983054442503547211560297249686289665792078548480268091496050883021187158502798880896590227542729659940394038802461081290690995869705131152889309663639310553909874081663091069118126221594338242710530718836025225507189149221049928936955230868771875644038572888630664890573507822342998964954667474300944699078658989010257103569231493090050659723450626338923049035040974032671138430612839043269997482582763267536489504794826476836323549796385028155416935072959933315468068930689064483178204550825728947252440604703474049780550458442808479096492346910001692358508618202898514895453589357') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (...)" +== 477 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (5, '-652755630.43456071828048833552593835051449845484289562110789582081210403487973096161149072377955192388469356112505543620695003436531392789029513380101663750625024853263344909355177280161504414335005574882649025508632900995595004153086358670541462762210415346958050909878501048483523600711486406055424807840429541335391538322886495085448421556770991545781035298449067051916630343957356635391594362639819978677032855590055900561501350354631803808000307050416047072513406855040715556454205065332997338225626635780147287003130754254277103928406089109802521803537038957372612837169223905290912251006321930223154562110264217937') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (...)" +== 478 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (6, '0.0469370721950711508944806393077762204079964905145503836835397203739563036579760026190241480514409364') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (...)" +== 479 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (7, '-818934540071845742') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (7, '-818934540071845742')" +== 480 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (8, '8496986223.64063724353165506167988570717591150432282238795309964705925283285060558038824227595710139960766584401003765241409149793494330798800') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (...)" +== 481 +-- truncate_limit: 100 +INSERT INTO num_data VALUES (9, '054863480.34685027005508022756223282084742813020271603840941647350440860843570182437301045468670059279379903480024743452620396345637401505220786389930600883087012615993343976556472498552535317826554614696684732913955544753638726438705858481670766245958647367500212800073774509075408148134050353551558174813940258910304990570172170811882520915334358633') +-- +TABLE: name="num_data" schema="" table="num_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_data VALUES (...)" +== 482 +-- truncate_limit: 100 +COMMIT TRANSACTION +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 483 +-- truncate_limit: 100 +-- ****************************** +-- * Create indices for faster checks +-- ****************************** + +CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add (id1, id2) +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add USING btree (id1, id2)" +== 484 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub (id1, id2) +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub USING btree (id1, id2)" +== 485 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div (id1, id2) +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div USING btree (id1, id2)" +== 486 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul (id1, id2) +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul USING btree (id1, id2)" +== 487 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt (id) +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt USING btree (id)" +== 488 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln (id) +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln USING btree (id)" +== 489 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 (id) +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 USING btree (id)" +== 490 +-- truncate_limit: 100 +CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln (id) +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln USING btree (id)" +== 491 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_add +-- +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_add" +== 492 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_sub +-- +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_sub" +== 493 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_div +-- +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_div" +== 494 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_mul +-- +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_mul" +== 495 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_sqrt +-- +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_sqrt" +== 496 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_ln +-- +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_ln" +== 497 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_log10 +-- +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_log10" +== 498 +-- truncate_limit: 100 +VACUUM ANALYZE num_exp_power_10_ln +-- +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) num_exp_power_10_ln" +== 499 +-- truncate_limit: 100 +-- ****************************** +-- * Now check the behaviour of the NUMERIC type +-- ****************************** + +-- ****************************** +-- * Addition check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 500 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val FROM num_data t1, num_data t2" +== 501 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_add" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.id2, t1.result, t2.expected FROM num_result t1, num_exp_add t2 WHERE ..." +== 502 +-- truncate_limit: 100 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 503 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) FROM num_data t1, num_data t2" +== 504 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 10) as expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 10) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_add" schema="" table="num_exp_add" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_add" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_result t1, num_exp_add t2 WHERE ..." +== 505 +-- truncate_limit: 100 +-- ****************************** +-- * Subtraction check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 506 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val FROM num_data t1, num_data t2" +== 507 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sub" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.id2, t1.result, t2.expected FROM num_result t1, num_exp_sub t2 WHERE ..." +== 508 +-- truncate_limit: 100 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 509 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) FROM num_data t1, num_data t2" +== 510 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 40) + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 40) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sub" schema="" table="num_exp_sub" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sub" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_result t1, num_exp_sub t2 WHERE ..." +== 511 +-- truncate_limit: 100 +-- ****************************** +-- * Multiply check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 512 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val FROM num_data t1, num_data t2" +== 513 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_mul" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.id2, t1.result, t2.expected FROM num_result t1, num_exp_mul t2 WHERE ..." +== 514 +-- truncate_limit: 100 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 515 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) + FROM num_data t1, num_data t2 +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) FROM num_data t1, num_data t2" +== 516 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 30) as expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 30) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_mul" schema="" table="num_exp_mul" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_mul" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_result t1, num_exp_mul t2 WHERE ..." +== 517 +-- truncate_limit: 100 +-- ****************************** +-- * Division check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 518 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, t1.val / t2.val + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FILTER: schema="" table="t2" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT ... FROM num_data t1, num_data t2 WHERE t2.val <> '0.0'" +== 519 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_div" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.id2, t1.result, t2.expected FROM num_result t1, num_exp_div t2 WHERE ..." +== 520 +-- truncate_limit: 100 +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 521 +-- truncate_limit: 100 +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val / t2.val, 80) + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +TABLE: name="num_data" schema="" table="num_data" ctx=Select +ALIAS: "t1"="num_data" +ALIAS: "t2"="num_data" +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t2" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT ... FROM num_data t1, num_data t2 WHERE t2.val <> '0.0'" +== 522 +-- truncate_limit: 100 +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 80) as expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 80) +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_div" schema="" table="num_exp_div" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_div" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id1" +FILTER: schema="" table="t1" column="id2" +FILTER: schema="" table="t2" column="id2" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM num_result t1, num_exp_div t2 WHERE ..." +== 523 +-- truncate_limit: 100 +-- ****************************** +-- * Square root check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 524 +-- truncate_limit: 100 +INSERT INTO num_result SELECT id, 0, SQRT(ABS(val)) + FROM num_data +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="sqrt" function="sqrt" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT id, 0, sqrt(abs(val)) FROM num_data" +== 525 +-- truncate_limit: 100 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_sqrt t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_sqrt" schema="" table="num_exp_sqrt" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_sqrt" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.result, t2.expected FROM num_result t1, num_exp_sqrt t2 WHERE ..." +== 526 +-- truncate_limit: 100 +-- ****************************** +-- * Natural logarithm check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 527 +-- truncate_limit: 100 +INSERT INTO num_result SELECT id, 0, LN(ABS(val)) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT id, 0, ln(abs(val)) FROM num_data WHERE val <> '0.0'" +== 528 +-- truncate_limit: 100 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_ln" schema="" table="num_exp_ln" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_ln" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.result, t2.expected FROM num_result t1, num_exp_ln t2 WHERE ..." +== 529 +-- truncate_limit: 100 +-- ****************************** +-- * Logarithm base 10 check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 530 +-- truncate_limit: 100 +INSERT INTO num_result SELECT id, 0, LOG('10'::numeric, ABS(val)) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT id, 0, log('10'::numeric, abs(val)) FROM num_data WHERE val <> '0.0'" +== 531 +-- truncate_limit: 100 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_log10 t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_log10" schema="" table="num_exp_log10" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_log10" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.result, t2.expected FROM num_result t1, num_exp_log10 t2 WHERE ..." +== 532 +-- truncate_limit: 100 +-- ****************************** +-- * POW(10, LN(value)) check +-- ****************************** +DELETE FROM num_result +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM num_result" +== 533 +-- truncate_limit: 100 +INSERT INTO num_result SELECT id, 0, POW(numeric '10', LN(ABS(round(val,1000)))) + FROM num_data + WHERE val != '0.0' +-- +TABLE: name="num_result" schema="" table="num_result" ctx=DML +TABLE: name="num_data" schema="" table="num_data" ctx=Select +FUNCTION: name="pow" function="pow" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FILTER: schema="" table="" column="val" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO num_result SELECT ... FROM num_data WHERE val <> '0.0'" +== 534 +-- truncate_limit: 100 +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_power_10_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected +-- +TABLE: name="num_result" schema="" table="num_result" ctx=Select +TABLE: name="num_exp_power_10_ln" schema="" table="num_exp_power_10_ln" ctx=Select +ALIAS: "t1"="num_result" +ALIAS: "t2"="num_exp_power_10_ln" +FILTER: schema="" table="t1" column="id1" +FILTER: schema="" table="t2" column="id" +FILTER: schema="" table="t1" column="result" +FILTER: schema="" table="t2" column="expected" +STMT: SelectStmt +TRUNCATED: "SELECT t1.id1, t1.result, t2.expected FROM num_result t1, num_exp_power_10_ln t2 WHERE ..." +== 535 +-- truncate_limit: 100 +|-- +-- Test code path for raising to integer powers +|-- + +-- base less than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of POW(): +|-- +-- for p in {-20..20} +-- do +-- b="0.084738" +-- r=$(bc -ql <<< "scale=500 ; $b^$p" | head -n 1) +-- echo "($b, $p, $r)," +-- done + +WITH t(b, p, bc_result) AS (VALUES +(0.084738, -20, 2744326694304960114888.785913), +(0.084738, -19, 232548755422013710215.445941), +(0.084738, -18, 19705716436950597776.236458), +(0.084738, -17, 1669822999434319754.362725), +(0.084738, -16, 141497461326065387.345189), +(0.084738, -15, 11990211877848128.792857), +(0.084738, -14, 1016026574105094.737649), +(0.084738, -13, 86096059836517.517879), +(0.084738, -12, 7295607918426.821430), +(0.084738, -11, 618215223791.651994), +(0.084738, -10, 52386321633.657007), +(0.084738, -9, 4439112122.5928274), +(0.084738, -8, 376161483.04427101), +(0.084738, -7, 31875171.750205437), +(0.084738, -6, 2701038.3037689083), +(0.084738, -5, 228880.58378476975), +(0.084738, -4, 19394.882908753819), +(0.084738, -3, 1643.4835879219811), +(0.084738, -2, 139.26551227333284), +(0.084738, -1, 11.801080979017678), +(0.084738, 0, 1), +(0.084738, 1, .084738), +(0.084738, 2, .007180528644), +(0.084738, 3, .000608463636235272), +(0.084738, 4, .00005155999160730448), +(0.084738, 5, .000004369090568819767), +(0.084738, 6, .0000003702279966206494), +(0.084738, 7, .00000003137237997764059), +(0.084738, 8, .000000002658432734545308), +(0.084738, 9, .0000000002252702730599003), +(0.084738, 10, .00000000001908895239854983), +(0.084738, 11, .000000000001617559648348316), +(0.084738, 12, .0000000000001370687694817396), +(0.084738, 13, .00000000000001161493338834365), +(0.084738, 14, .0000000000000009842262254614642), +(0.084738, 15, .00000000000000008340136189315355), +(0.084738, 16, .000000000000000007067264604102046), +(0.084738, 17, .0000000000000000005988658680223991), +(0.084738, 18, .00000000000000000005074669592448206), +(0.084738, 19, .000000000000000000004300173519248761), +(0.084738, 20, .0000000000000000000003643881036741015)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH t(b, p, bc_result) AS (...) SELECT ... FROM t" +== 536 +-- truncate_limit: 100 +-- base greater than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of POW(): +|-- +-- for p in {-20..20} +-- do +-- b="37.821637" +-- r=$(bc -ql <<< "scale=500 ; $b^$p" | head -n 1) +-- echo "($b, $p, $r)," +-- done + +WITH t(b, p, bc_result) AS (VALUES +(37.821637, -20, .00000000000000000000000000000002787363175065101), +(37.821637, -19, .000000000000000000000000000001054226381944797), +(37.821637, -18, .00000000000000000000000000003987256753373947), +(37.821637, -17, .000000000000000000000000001508045775519079), +(37.821637, -16, .00000000000000000000000005703675990106610), +(37.821637, -15, .000000000000000000000002157223628634278), +(37.821637, -14, .00000000000000000000008158972901002847), +(37.821637, -13, .000000000000000000003085857113545666), +(37.821637, -12, .0000000000000000001167121675823920), +(37.821637, -11, .000000000000000004414245235784397), +(37.821637, -10, .0000000000000001669539809368169), +(37.821637, -9, .000000000000006314472862697207), +(37.821637, -8, .0000000000002388237004592846), +(37.821637, -7, .000000000009032703305767796), +(37.821637, -6, .0000000003416316255594496), +(37.821637, -5, .00000001292106732962942), +(37.821637, -4, .0000004886959181938034), +(37.821637, -3, .00001848327962130773), +(37.821637, -2, .0006990678924065984), +(37.821637, -1, .02643989206495742), +(37.821637, 0, 1), +(37.821637, 1, 37.821637), +(37.821637, 2, 1430.476225359769), +(37.821637, 3, 54102.952532687378), +(37.821637, 4, 2046262.2313195326), +(37.821637, 5, 77392987.319777394), +(37.821637, 6, 2927129472.7542235), +(37.821637, 7, 110708828370.511632), +(37.821637, 8, 4187189119324.792454), +(37.821637, 9, 158366346921451.985294), +(37.821637, 10, 5989674486279224.500736), +(37.821637, 11, 226539294168214309.708325), +(37.821637, 12, 8568086950266418559.993831), +(37.821637, 13, 324059074417413536066.149409), +(37.821637, 14, 12256444679171401239980.310926), +(37.821637, 15, 463558801566202198479885.206986), +(37.821637, 16, 17532552720991931019508170.100286), +(37.821637, 17, 663109844696719094948877928.067252), +(37.821637, 18, 25079899837245684700124994552.671731), +(37.821637, 19, 948562867640665366544581398598.127577), +(37.821637, 20, 35876200451584291931921101974730.690104)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH t(b, p, bc_result) AS (...) SELECT ... FROM t" +== 537 +-- truncate_limit: 100 +|-- +-- Tests for raising to non-integer powers +|-- + +-- base less than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of POW(): +|-- +-- for n in {-20..20} +-- do +-- b="0.06933247" +-- p="$n.342987" +-- r=$(bc -ql <<< "scale=500 ; e($p*l($b))" | head -n 1) +-- echo "($b, $p, $r)," +-- done + +WITH t(b, p, bc_result) AS (VALUES +(0.06933247, -20.342987, 379149253615977128356318.39406340), +(0.06933247, -19.342987, 26287354251852125772450.59436685), +(0.06933247, -18.342987, 1822567200045909954554.65766042), +(0.06933247, -17.342987, 126363085720167050546.86216560), +(0.06933247, -16.342987, 8761064849800910427.02880469), +(0.06933247, -15.342987, 607426265866876128.15466179), +(0.06933247, -14.342987, 42114363355427213.14899924), +(0.06933247, -13.342987, 2919892833909256.59283660), +(0.06933247, -12.342987, 202443382310228.51544515), +(0.06933247, -11.342987, 14035899730722.44924025), +(0.06933247, -10.342987, 973143597003.32229028), +(0.06933247, -9.342987, 67470449244.92493259), +(0.06933247, -8.342987, 4677892898.16028054), +(0.06933247, -7.342987, 324329869.02491071), +(0.06933247, -6.342987, 22486590.914273551), +(0.06933247, -5.342987, 1559050.8899661435), +(0.06933247, -4.342987, 108092.84905705095), +(0.06933247, -3.342987, 7494.3442144625131), +(0.06933247, -2.342987, 519.60139541889576), +(0.06933247, -1.342987, 36.025248159838727), +(0.06933247, 0.342987, .40036522320023350), +(0.06933247, 1.342987, .02775830982657349), +(0.06933247, 2.342987, .001924552183301612), +(0.06933247, 3.342987, .0001334339565121935), +(0.06933247, 4.342987, .000009251305786862961), +(0.06933247, 5.342987, .0000006414158809285026), +(0.06933247, 6.342987, .00000004447094732199898), +(0.06933247, 7.342987, .000000003083280621074075), +(0.06933247, 8.342987, .0000000002137714611621997), +(0.06933247, 9.342987, .00000000001482130341788437), +(0.06933247, 10.342987, .000000000001027597574581366), +(0.06933247, 11.342987, .00000000000007124587801173530), +(0.06933247, 12.342987, .000000000000004939652699872298), +(0.06933247, 13.342987, .0000000000000003424783226243151), +(0.06933247, 14.342987, .00000000000000002374486802900065), +(0.06933247, 15.342987, .000000000000000001646290350274646), +(0.06933247, 16.342987, .0000000000000000001141413763217064), +(0.06933247, 17.342987, .000000000000000000007913703549583420), +(0.06933247, 18.342987, .0000000000000000000005486766139403860), +(0.06933247, 19.342987, .00000000000000000000003804110487572339), +(0.06933247, 20.342987, .000000000000000000000002637483762562946)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH t(b, p, bc_result) AS (...) SELECT ... FROM t" +== 538 +-- truncate_limit: 100 +-- base greater than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of POW(): +|-- +-- for n in {-20..20} +-- do +-- b="27.234987" +-- p="$n.230957" +-- r=$(bc -ql <<< "scale=500 ; e($p*l($b))" | head -n 1) +-- echo "($b, $p, $r)," +-- done + +WITH t(b, p, bc_result) AS (VALUES +(27.234987, -20.230957, .000000000000000000000000000009247064512095633), +(27.234987, -19.230957, .0000000000000000000000000002518436817750859), +(27.234987, -18.230957, .000000000000000000000000006858959399176602), +(27.234987, -17.230957, .0000000000000000000000001868036700701026), +(27.234987, -16.230957, .000000000000000000000005087595525911532), +(27.234987, -15.230957, .0000000000000000000001385605980094587), +(27.234987, -14.230957, .000000000000000000003773696085499835), +(27.234987, -13.230957, .0000000000000000001027765638305389), +(27.234987, -12.230957, .000000000000000002799118379829397), +(27.234987, -11.230957, .00000000000000007623395268611469), +(27.234987, -10.230957, .000000000000002076230710364949), +(27.234987, -9.230957, .00000000000005654611640579014), +(27.234987, -8.230957, .000000000001540032745212181), +(27.234987, -7.230957, .00000000004194277179542807), +(27.234987, -6.230957, .000000001142310844592450), +(27.234987, -5.230957, .00000003111082100243440), +(27.234987, -4.230957, .0000008473028055606278), +(27.234987, -3.230957, .00002307628089450723), +(27.234987, -2.230957, .0006284822101702527), +(27.234987, -1.230957, .01711670482371810), +(27.234987, 0.230957, 2.1451253063142300), +(27.234987, 1.230957, 58.422459830839071), +(27.234987, 2.230957, 1591.1349340009243), +(27.234987, 3.230957, 43334.539242761031), +(27.234987, 4.230957, 1180215.6129275865), +(27.234987, 5.230957, 32143156.875279851), +(27.234987, 6.230957, 875418459.63720737), +(27.234987, 7.230957, 23842010367.779367), +(27.234987, 8.230957, 649336842420.336290), +(27.234987, 9.230957, 17684680461938.907402), +(27.234987, 10.230957, 481642042480060.137900), +(27.234987, 11.230957, 13117514765597885.614921), +(27.234987, 12.230957, 357255344113366461.949871), +(27.234987, 13.230957, 9729844652608062117.440722), +(27.234987, 14.230957, 264992192625800087863.690528), +(27.234987, 15.230957, 7217058921265161257566.469315), +(27.234987, 16.230957, 196556505898890690402726.443417), +(27.234987, 17.230957, 5353213882921711267539279.451015), +(27.234987, 18.230957, 145794710509592328389185797.837767), +(27.234987, 19.230957, 3970717045397510438979206144.696206), +(27.234987, 20.230957, 108142427112079606637962972621.121293)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH t(b, p, bc_result) AS (...) SELECT ... FROM t" +== 539 +-- truncate_limit: 100 +-- Inputs close to overflow +|-- +-- bc(1) results computed with a scale of 2700 and truncated to 4 decimal +-- places. + +WITH t(b, p, bc_result) AS (VALUES +(0.12, -2829.8369, 58463948950011752465280493160293790845494328939320966633018493248607815580903065923369555885857984675501574162389726507612128133630191173383130639968378879506624785786843501848666498440326970769604109017960864573408272864266102690849952650095786874354625921641729880352858506454246180842452983243549491658464046163869265572232996388827878976066830374513768599285647145439771472435206769249126377164951470622827631950210853282324510655982757098065657709137845327135766013147354253426364240746381620690117663724329288646510198895137275207992825719846135857839292915100523542874885080351683587865157015032404901182924720371819942957083390475846809517968191151435281268695782594904484795360890092607679215675240583291240729468370895035823777914792823688291214492607109455017754453939895630226174304357121900605689015734289765672740769194115142607443713769825894380064727556869268488695795705030158832909348803019429370973064732712469794182891757241046263341655894972953512257981661670321890336672832647028099324621932563236459127918144141230217523147304565594514812518826936144181257723061181656522095236928347413997136815409159361412494284201481609684892562646522086577634100783077813105675590737823924220663206479031113753135119759722725207724879578900186075841393115040465401462266086907464970054073340036852442184414587772177753008511913377364966775792477387717262694468450099866775550614257191941835797445874557362115814601886902749237439492398087966544817154173072811937702110580330775581851211123491341435883319798273456296794954514173820352334127081705706502510709179711510240917772628308487366740741280043704807717608366220401933596364641284631036907635403895053036499618723044314773148779735006542501244942039455169872946018271985844759209768927953340447524637670938413827595013338859796135512187473850161303598087634723542727044978083220970836296653305188470017342167913572166172051819741354902582606590658382067039498769674611071582171914886494269818475850690414812481252963932223686078322390396586222238852602472958831686564971334200490182175112490433364675164900946902818404704835106260174052265784055642968397240262737313737007322288203637798365320295080314524864099419556398713380156353062937736280885716820226469419928595465390700629307079710611273715705695938635644841913194091407807776191951797748706106000922803167645881087385311847268311361092838264814899353459146959869764278464187826798546290981492648723002412475976344071283321798061003719251864595518596639432393032991023409676558943539937377229130132816883146259468718344018277257037013406135980469482324577407154032999045733141275895.3432), +(1.2, 32908.8896, 58463467728170833376633133695001863276259293590926929026251227859007891876739460057725441400966420577009060860805883032969522911803372870882799865787473726926215148161529632590083389287080925059682489116446754279752928005457087175157581627230586554364417068189211136840990661174760199073702207450133797324318403866058202372178813998850887986769280847189341565507156189065295823921162851958925352114220880236114784962150135485415106748467247897246441194126125699204912883449386043559785865023459356275014504597646990160571664166410683323036984805434677654413174177920726210827006973855410386789516533036723888687725436216478665958434776205940192130053647653715221076841771578099896259902368829351569726536927952661429685419815305418450230567773264738536471211804481206474781470237730069753206249915908804615495060673071058534441654604668770343616386612119048579369195201590008082689834456232255266932976831478404670192731621439902738547169253818323045451045749609624500171633897705543164388470746657118050314064066768449450440405619135824055131398727045420324382226572368236570500391463795989258779677208133531636928003546809249007993065200108076924439703799231711400266122025052209803513232429907231051873161206025860851056337427740362763618748092029386371493898291580557004812947013231371383576580415676519066503391905962989205397824064923920045371823949776899815750413244195402085917098964452866825666226141169411712884994564949174271056284898570445214367063763956186792886147126466387576513166370247576466566827375268334148320298849218878848928271566491769458471357076035396330179659440244425914213309776100351793665960978678576150833311810944729586040624059867137538839913141142139636023129691775489034134511666020819676247950267220131499463010350308195762769192775344260909521732256844149916046793599150786757764962585268686580124987490115873389726527572428003433405659445349155536369077209682951123806333170190998931670309088422483075609203671527331975811507450670132060984691061148836994322505371265263690017938762760088575875666254883673433331627055180154954694693433502522592907190906966067656027637884202418119121728966267936832338377284832958974299187166554160783467156478554899314000348357280306042140481751668215838656488457943830180819301102535170705017482946779698265096226184239631924271857062033454725540956591929965181603262502135610768915716020374362368495244256420143645126927013882334008435586481691725030031204304273292938132599127402133470745819213047706793887965197191137237066440328777206799072470374264316425913530947082957300047105685634407092811630672103242089966046839626911122.7149)) +SELECT b, p, bc_result, b^p AS power, b^p - bc_result AS diff FROM t +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH t(b, p, bc_result) AS (...) SELECT ... FROM t" +== 540 +-- truncate_limit: 100 +|-- +-- Tests for EXP() +|-- + +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of EXP(): +|-- +-- for n in {-20..20} +-- do +-- x="$n.29837" +-- r=$(bc -ql <<< "scale=500 ; e($x)" | head -n 1) +-- echo "($x, $r)," +-- done + +WITH t(x, bc_result) AS (VALUES +(-20.29837, .000000001529431101152222), +(-19.29837, .000000004157424770142192), +(-18.29837, .00000001130105220586304), +(-17.29837, .00000003071944485366452), +(-16.29837, .00000008350410872606600), +(-15.29837, .0000002269877013517336), +(-14.29837, .0000006170165438681061), +(-13.29837, .000001677224859055276), +(-12.29837, .000004559169856609741), +(-11.29837, .00001239310857408049), +(-10.29837, .00003368796183504298), +(-9.29837, .00009157337449401917), +(-8.29837, .0002489222398577673), +(-7.29837, .0006766408013046928), +(-6.29837, .001839300394580514), +(-5.29837, .004999736839665763), +(-4.29837, .01359069379834070), +(-3.29837, .03694333598818056), +(-2.29837, .1004223988993283), +(-1.29837, .2729763820983097), +(0.29837, 1.3476603299656679), +(1.29837, 3.6633205858807959), +(2.29837, 9.9579377804197108), +(3.29837, 27.068481317440698), +(4.29837, 73.579760889182206), +(5.29837, 200.01052696742555), +(6.29837, 543.68498095607070), +(7.29837, 1477.8890041389891), +(8.29837, 4017.3188244304487), +(9.29837, 10920.204759575742), +(10.29837, 29684.194161006717), +(11.29837, 80690.005580314652), +(12.29837, 219338.17590722828), +(13.29837, 596222.97785597218), +(14.29837, 1620702.0864156289), +(15.29837, 4405525.0308492653), +(16.29837, 11975458.636179032), +(17.29837, 32552671.598188404), +(18.29837, 88487335.673150406), +(19.29837, 240533516.60908059), +(20.29837, 653837887.33381570)) +SELECT x, bc_result, exp(x), exp(x)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="exp" function="exp" schema="" ctx=Call +FUNCTION: name="exp" function="exp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT x, bc_result, exp(x), exp(x) - bc_result AS diff FROM t" +== 541 +-- truncate_limit: 100 +|-- +-- Tests for LN() +|-- + +-- input very small +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(10^-$p)" | head -n 1) +-- echo "('1.0e-$p', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e-1', -2.3025850929940457), +('1.0e-2', -4.6051701859880914), +('1.0e-3', -6.9077552789821371), +('1.0e-4', -9.2103403719761827), +('1.0e-5', -11.512925464970228), +('1.0e-6', -13.815510557964274), +('1.0e-7', -16.118095650958320), +('1.0e-8', -18.420680743952365), +('1.0e-9', -20.723265836946411), +('1.0e-10', -23.025850929940457), +('1.0e-11', -25.328436022934503), +('1.0e-12', -27.631021115928548), +('1.0e-13', -29.933606208922594), +('1.0e-14', -32.236191301916640), +('1.0e-15', -34.5387763949106853), +('1.0e-16', -36.84136148790473094), +('1.0e-17', -39.143946580898776628), +('1.0e-18', -41.4465316738928223123), +('1.0e-19', -43.74911676688686799634), +('1.0e-20', -46.051701859880913680360), +('1.0e-21', -48.3542869528749593643778), +('1.0e-22', -50.65687204586900504839581), +('1.0e-23', -52.959457138863050732413803), +('1.0e-24', -55.2620422318570964164317949), +('1.0e-25', -57.56462732485114210044978637), +('1.0e-26', -59.867212417845187784467777822), +('1.0e-27', -62.1697975108392334684857692765), +('1.0e-28', -64.47238260383327915250376073116), +('1.0e-29', -66.774967696827324836521752185847), +('1.0e-30', -69.0775527898213705205397436405309), +('1.0e-31', -71.38013788281541620455773509521529), +('1.0e-32', -73.682722975809461888575726549899655), +('1.0e-33', -75.9853080688035075725937180045840189), +('1.0e-34', -78.28789316179755325661170945926838306), +('1.0e-35', -80.590478254791598940629700913952747266), +('1.0e-36', -82.8930633477856446246476923686371114736), +('1.0e-37', -85.19564844077969030866568382332147568124), +('1.0e-38', -87.498233533773735992683675278005839888842), +('1.0e-39', -89.8008186267677816767016667326902040964430), +('1.0e-40', -92.10340371976182736071965818737456830404406)) +SELECT x, bc_result, ln(x::numeric), ln(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" +== 542 +-- truncate_limit: 100 +-- input very close to but smaller than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(1-10^-$p)" | head -n 1) +-- echo "('1.0e-$p', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e-1', -.10536051565782630), +('1.0e-2', -.010050335853501441), +('1.0e-3', -.0010005003335835335), +('1.0e-4', -.00010000500033335834), +('1.0e-5', -.000010000050000333336), +('1.0e-6', -.0000010000005000003333), +('1.0e-7', -.00000010000000500000033), +('1.0e-8', -.000000010000000050000000), +('1.0e-9', -.0000000010000000005000000), +('1.0e-10', -.00000000010000000000500000), +('1.0e-11', -.000000000010000000000050000), +('1.0e-12', -.0000000000010000000000005000), +('1.0e-13', -.00000000000010000000000000500), +('1.0e-14', -.000000000000010000000000000050), +('1.0e-15', -.0000000000000010000000000000005), +('1.0e-16', -.00000000000000010000000000000001), +('1.0e-17', -.000000000000000010000000000000000), +('1.0e-18', -.0000000000000000010000000000000000), +('1.0e-19', -.00000000000000000010000000000000000), +('1.0e-20', -.000000000000000000010000000000000000), +('1.0e-21', -.0000000000000000000010000000000000000), +('1.0e-22', -.00000000000000000000010000000000000000), +('1.0e-23', -.000000000000000000000010000000000000000), +('1.0e-24', -.0000000000000000000000010000000000000000), +('1.0e-25', -.00000000000000000000000010000000000000000), +('1.0e-26', -.000000000000000000000000010000000000000000), +('1.0e-27', -.0000000000000000000000000010000000000000000), +('1.0e-28', -.00000000000000000000000000010000000000000000), +('1.0e-29', -.000000000000000000000000000010000000000000000), +('1.0e-30', -.0000000000000000000000000000010000000000000000), +('1.0e-31', -.00000000000000000000000000000010000000000000000), +('1.0e-32', -.000000000000000000000000000000010000000000000000), +('1.0e-33', -.0000000000000000000000000000000010000000000000000), +('1.0e-34', -.00000000000000000000000000000000010000000000000000), +('1.0e-35', -.000000000000000000000000000000000010000000000000000), +('1.0e-36', -.0000000000000000000000000000000000010000000000000000), +('1.0e-37', -.00000000000000000000000000000000000010000000000000000), +('1.0e-38', -.000000000000000000000000000000000000010000000000000000), +('1.0e-39', -.0000000000000000000000000000000000000010000000000000000), +('1.0e-40', -.00000000000000000000000000000000000000010000000000000000)) +SELECT '1-'||x, bc_result, ln(1.0-x::numeric), ln(1.0-x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" +== 543 +-- truncate_limit: 100 +-- input very close to but larger than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(1+10^-$p)" | head -n 1) +-- echo "('1.0e-$p', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e-1', .09531017980432486), +('1.0e-2', .009950330853168083), +('1.0e-3', .0009995003330835332), +('1.0e-4', .00009999500033330834), +('1.0e-5', .000009999950000333331), +('1.0e-6', .0000009999995000003333), +('1.0e-7', .00000009999999500000033), +('1.0e-8', .000000009999999950000000), +('1.0e-9', .0000000009999999995000000), +('1.0e-10', .00000000009999999999500000), +('1.0e-11', .000000000009999999999950000), +('1.0e-12', .0000000000009999999999995000), +('1.0e-13', .00000000000009999999999999500), +('1.0e-14', .000000000000009999999999999950), +('1.0e-15', .0000000000000009999999999999995), +('1.0e-16', .00000000000000010000000000000000), +('1.0e-17', .000000000000000010000000000000000), +('1.0e-18', .0000000000000000010000000000000000), +('1.0e-19', .00000000000000000010000000000000000), +('1.0e-20', .000000000000000000010000000000000000), +('1.0e-21', .0000000000000000000010000000000000000), +('1.0e-22', .00000000000000000000010000000000000000), +('1.0e-23', .000000000000000000000010000000000000000), +('1.0e-24', .0000000000000000000000010000000000000000), +('1.0e-25', .00000000000000000000000010000000000000000), +('1.0e-26', .000000000000000000000000010000000000000000), +('1.0e-27', .0000000000000000000000000010000000000000000), +('1.0e-28', .00000000000000000000000000010000000000000000), +('1.0e-29', .000000000000000000000000000010000000000000000), +('1.0e-30', .0000000000000000000000000000010000000000000000), +('1.0e-31', .00000000000000000000000000000010000000000000000), +('1.0e-32', .000000000000000000000000000000010000000000000000), +('1.0e-33', .0000000000000000000000000000000010000000000000000), +('1.0e-34', .00000000000000000000000000000000010000000000000000), +('1.0e-35', .000000000000000000000000000000000010000000000000000), +('1.0e-36', .0000000000000000000000000000000000010000000000000000), +('1.0e-37', .00000000000000000000000000000000000010000000000000000), +('1.0e-38', .000000000000000000000000000000000000010000000000000000), +('1.0e-39', .0000000000000000000000000000000000000010000000000000000), +('1.0e-40', .00000000000000000000000000000000000000010000000000000000)) +SELECT '1+'||x, bc_result, ln(1.0+x::numeric), ln(1.0+x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" +== 544 +-- truncate_limit: 100 +-- input very large +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(10^$p)" | head -n 1) +-- echo "('1.0e$p', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e1', 2.3025850929940457), +('1.0e2', 4.6051701859880914), +('1.0e3', 6.9077552789821371), +('1.0e4', 9.2103403719761827), +('1.0e5', 11.512925464970228), +('1.0e6', 13.815510557964274), +('1.0e7', 16.118095650958320), +('1.0e8', 18.420680743952365), +('1.0e9', 20.723265836946411), +('1.0e10', 23.025850929940457), +('1.0e11', 25.328436022934503), +('1.0e12', 27.631021115928548), +('1.0e13', 29.933606208922594), +('1.0e14', 32.236191301916640), +('1.0e15', 34.538776394910685), +('1.0e16', 36.841361487904731), +('1.0e17', 39.143946580898777), +('1.0e18', 41.446531673892822), +('1.0e19', 43.749116766886868), +('1.0e20', 46.051701859880914), +('1.0e21', 48.354286952874959), +('1.0e22', 50.656872045869005), +('1.0e23', 52.959457138863051), +('1.0e24', 55.262042231857096), +('1.0e25', 57.564627324851142), +('1.0e26', 59.867212417845188), +('1.0e27', 62.169797510839233), +('1.0e28', 64.472382603833279), +('1.0e29', 66.774967696827325), +('1.0e30', 69.077552789821371), +('1.0e31', 71.380137882815416), +('1.0e32', 73.682722975809462), +('1.0e33', 75.985308068803508), +('1.0e34', 78.287893161797553), +('1.0e35', 80.590478254791599), +('1.0e36', 82.893063347785645), +('1.0e37', 85.195648440779690), +('1.0e38', 87.498233533773736), +('1.0e39', 89.800818626767782), +('1.0e40', 92.103403719761827)) +SELECT x, bc_result, ln(x::numeric), ln(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" +== 545 +-- truncate_limit: 100 +-- input huge +|-- +-- bc(1) results computed with a scale of 1000 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..10} +-- do +-- l=$(bc -ql <<< "scale=1000 ; l(10^${p}00)" | head -n 1) +-- echo "('1.0e${p}00', $l)," +-- done + +WITH t(x, bc_result) AS (VALUES +('1.0e100', 230.25850929940457), +('1.0e200', 460.51701859880914), +('1.0e300', 690.77552789821371), +('1.0e400', 921.03403719761827), +('1.0e500', 1151.2925464970228), +('1.0e600', 1381.5510557964274), +('1.0e700', 1611.8095650958320), +('1.0e800', 1842.0680743952365), +('1.0e900', 2072.3265836946411), +('1.0e1000', 2302.5850929940457)) +SELECT x, bc_result, ln(x::numeric), ln(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="ln" function="ln" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" +== 546 +-- truncate_limit: 100 +-- inputs with 1000 decimal places +|-- +-- bc(1) results computed with a scale of 2000 and rounded to 1000 decimal +-- places + +WITH t(x, bc_result) AS (VALUES +(484990182159328900690402236933516249572671683638747490717351807610531884491845416923860371219625151551889257298200816555016472471293780254009492949585031653913930735918829139712249577547959394351523545901788627247613322896296041868431769047433229466634098452564756860190085118463828382895145244362033728480588969626012192733802377468089120757046364393407262957242230928854711898925295251902007136232994524624903257456111389508582206404271734668422903183500589303866613158037169610592539145461637447957948521714058034772237111009429638870236361143304703683377693378577075353794118557951847394763531830696578809001981568860219578880229402696449243344235099860421846016326538272155937175661905904288335499593232232926636205909086901191153907183842087577811871344870731324067822883041265129394268082883745408414994.8967939438561591657171240282983703914075472645212002662497023142663831371447287624846942598424990784971781730103682951722370983277124599054059027055336437808366784501932987082321905202623642371063626378290734289114618092750984153422293450048717769065428713836637664433167768445609659527458911187829232316677137895259433038764404970599325009178297626038331436654541552998098529141205301472138026818453893127265938030066392881979113522757891639646670670272542401773230506961559808927249585675430838495658225557294666522469887436551840596777627408780618586500922973500018513068499587683746133637919751545157547095670767246977244726331271787622126889459658539988980096764323712767863722912919120929339399753431689512753214200090670880647731689804555417871258907716687575767185444541243606329768784843125926070743277339790277626515824924290352180761378846035233155198504033292692893297993698953705472933411199778880561376633444249703838589180474329586470353212010427945060694794274109764269805332803290229, + 1864.3702986939570026328504202935192533137907736189919154633800554877738455118081651650863235106905871352085850240570561347180517240105510505203972860921397909573687877993477806728098306202020229409548306695695574102950949468160529713610952021974630774784174851619325758380143625473386495586347322798415543385655090746985183329114860118551572428921774322172798724455202876781611633419444058398798142214904998877857425038669920064728855823072107227506485770367799671977282350083029452784747350395161797215115525867416898416360638482342253129160308632504217096916335590470843180746834864303790913372081974355613359678634194879425862536147988835528973291020680020540866655622823550861337486588647231688134992810403147262346312159819432914207194632564009749236609081399504118359354620598232725290537215007867979331582119891661859015726276335168158288396939655310210558566592649049602925182137256134162660116182293851038854455437841571331011002023088829768308520393956515509475418031437505751407687618234418262), +(87190145885430429849953615409019208993240447426362428988181639909267773304254748257120061524000254226856815085523676417146197197996896030672521334101413071112068202429835905642444187493717977611730127126387257253646790849384975208460867137315507010888782632024640844766297185244443116696943912406389670302370461137850160539373600494054874979342373255280815156048999900951842673141766630630919020492255966628630634124452614590400422133958133100159154995520080124736657520969784129924799670552560034302960877087853678350801769339861812435411200669026902417951572668727488315537985378304242438181615160041688723201917323705450185975141141262578884689500612295576288125956289035673242989906973367691922065122033180281670221390667818909912035903387888639331486823729897326624516015340.0330856710565117793999512551468220085711713631167607285185762046751452975325645379302403715842570486302993296501788672462090620871511446272026693318239212657949496275318383141403236705902077406660768573015707706831878445598837931116223956945944726162551477136715847593742032488181481888084716920605114101902724395659898621880016853548602514706686907951229872573180602614761229992106144727082722940736406782659562775289407005631298246624198606031298081220736931229256511054595028182057216042683060059115371651410352645266000330509331097811566633211452233019461903115970558624057877018778178814946285827512359903934291318219271464841957435711594154280905473802599888081783098187210283997106131616471807951265003903143099667366508222327805543948921694362089860577380749774036318574113007382111997454202845559941557812813566442364810680529092880773126707073967537693927177460459341763934709686530005721141046645111784404932103241501569571235364365556796422998363930810983452790309019295181282099408260156, + 1793.5767085750017553306932533574391150814202249805881581227430032600579405884415934520704053351781361105595296647510475380766428668443641914861849764330704062323054023252886955844207807229267936432730818329225450152491146839618683772020068682795388746108876393249306737841247788224204701299467519965182171772253974884845661168860422489046657965359832930382114760565628765599962013955588754803194908990025689040598990346417563277021386852342928910383706995866844541160576254266641602065102228267316550706943783591722246885978355472097314691737807509436806788803362444745551013400341861820755594413819894154786253014501454443272120342005711761286524843010157182464200556865694401941794983935172457481497909987740544409272349152397774548604845897687504977786762391359552407068124283290504752932824699865504970420939586707791994870941813718246825616335675307740641350673558328821461530563823677144691877374809441673507467507447891562257806191361453045937798278733402269265623588493124129181374135958668436774), +(93936642222690597390233191619858485419795942047468396309991947772747208870873993801669373075421461116465960407843923269693395211616591453397070258466704654943689268224479477016161636938138334729982904232438440955361656138189836032891825113139184685132178764873033678116450665758561650355252211196676137179184043639278410827092182700922151290703747496962700158844772453483316974221113826173404445159281421213715669245417896170368554410830320000019029956317336703559699859949692222685614036912057150632902650913831404804982509990655560731349634628713944739168096272097122388116038119844786988276635032016787352796502360718569977397214936366251320294621522016.6483354941025384161536675750898007896744690911429670830432784905421638721478353275821072200938900938046264210604940707974410950770029535636602548377806284157951164875821446035013896786653932045182167021839184824627082391478016195098055107001433336586881395912782883663046617432598969149948351689103230162742769845955320418573803127107923535948653168889411316007796459064267436246637115946581149511513369842911210359447262641996566147462977170742544980481275049898092152042927981394239266559286915303786701737610786594006685748456635797125029722684151298695274097006242412384086302106763844070230264910503179385988626477852818174114043927841085089058972074427820150462261941575665882880501074676800316585217150509780489224388148722603385921057007086785238310735038314861960410473809826927329368597558806004392175746233568789445929554890241140656324160187253042639339549705859147930476532359840809944163908006480881926041259363654863689570520534301207043189181147254153307163555433328278834311658232337, + 1510.4332713542154696529645934345554302578243896764921637693542962119938599884313210100957753316832762996428481801312323020427109678979117469716796746760060470871840325255146954580681101106876674367471955788143763250819168311353856748872452260808797135108102729064040463343792765872545182299889360257515315869180266759715933989413256377582681707188367254513700731642913479683031478361835565783219287780434673712341147656477670848734998849030451414278832848680301511646182446524915091598080243532068451726548537866633622180283865668708517173065893429240665300584705585310049892047293928733753369421499719516009692095913169665213597158441636480707309244604139865130782756488091268094213446272360006907802989573582755585110277620911226015342778471352130366770729972784317323917141031824334355639769512749560550167491709646539950725523461943580211843652293561678342656010571108219244870234329176123205423872844099992204896411752620881541000940129833754169391528449211839693800724450201835161044717173715867437)) +SELECT trim_scale(ln(x::numeric)-bc_result) AS diff FROM t +-- +CTE: "t" +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +FUNCTION: name="ln" function="ln" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (VALUES (...)) SELECT trim_scale(ln(x::numeric) - bc_result) AS diff FROM t" +== 547 +-- truncate_limit: 100 +|-- +-- Tests for LOG() (base 10) +|-- + +-- input very small, exact result known +WITH t(x) AS (SELECT '1e-'||n FROM generate_series(1, 100) g(n)) +SELECT x, log(x::numeric) FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x) AS (SELECT '1e-' || n FROM generate_series(1, 100) g(n)) SELECT x, log(x::numeric) FROM t" +== 548 +-- truncate_limit: 100 +-- input very small, non-exact results +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..50..7} +-- do +-- for d in {9..1..3} +-- do +-- l=$(bc -ql <<< "scale=500 ; l($d*10^-$p) / l(10)" | head -n 1) +-- echo "('${d}.0e-$p', $l)," +-- done +-- done + +WITH t(x, bc_result) AS (VALUES +('9.0e-1', -.04575749056067513), +('6.0e-1', -.2218487496163564), +('3.0e-1', -.5228787452803376), +('9.0e-8', -7.045757490560675), +('6.0e-8', -7.221848749616356), +('3.0e-8', -7.522878745280338), +('9.0e-15', -14.0457574905606751), +('6.0e-15', -14.2218487496163564), +('3.0e-15', -14.5228787452803376), +('9.0e-22', -21.04575749056067512540994), +('6.0e-22', -21.22184874961635636749123), +('3.0e-22', -21.52287874528033756270497), +('9.0e-29', -28.045757490560675125409944193490), +('6.0e-29', -28.221848749616356367491233202020), +('3.0e-29', -28.522878745280337562704972096745), +('9.0e-36', -35.0457574905606751254099441934897693816), +('6.0e-36', -35.2218487496163563674912332020203916640), +('3.0e-36', -35.5228787452803375627049720967448846908), +('9.0e-43', -42.04575749056067512540994419348976938159974227), +('6.0e-43', -42.22184874961635636749123320202039166403168125), +('3.0e-43', -42.52287874528033756270497209674488469079987114), +('9.0e-50', -49.045757490560675125409944193489769381599742271618608), +('6.0e-50', -49.221848749616356367491233202020391664031681254347196), +('3.0e-50', -49.522878745280337562704972096744884690799871135809304)) +SELECT x, bc_result, log(x::numeric), log(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" +== 549 +-- truncate_limit: 100 +-- input very close to but smaller than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40..7} +-- do +-- for d in {9..1..3} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(1-$d*10^-$p) / l(10)" | head -n 1) +-- echo "('${d}.0e-$p', $l)," +-- done +-- done + +WITH t(x, bc_result) AS (VALUES +('9.0e-1', -1.0000000000000000), +('6.0e-1', -.3979400086720376), +('3.0e-1', -.1549019599857432), +('9.0e-8', -.000000039086505130185422), +('6.0e-8', -.000000026057669695925208), +('3.0e-8', -.000000013028834652530076), +('9.0e-15', -.0000000000000039086503371292840), +('6.0e-15', -.0000000000000026057668914195188), +('3.0e-15', -.0000000000000013028834457097574), +('9.0e-22', -.00000000000000000000039086503371292664), +('6.0e-22', -.00000000000000000000026057668914195110), +('3.0e-22', -.00000000000000000000013028834457097555), +('9.0e-29', -.000000000000000000000000000039086503371292664), +('6.0e-29', -.000000000000000000000000000026057668914195110), +('3.0e-29', -.000000000000000000000000000013028834457097555), +('9.0e-36', -.0000000000000000000000000000000000039086503371292664), +('6.0e-36', -.0000000000000000000000000000000000026057668914195110), +('3.0e-36', -.0000000000000000000000000000000000013028834457097555)) +SELECT '1-'||x, bc_result, log(1.0-x::numeric), log(1.0-x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" +== 550 +-- truncate_limit: 100 +-- input very close to but larger than 1 +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {1..40..7} +-- do +-- for d in {9..1..3} +-- do +-- l=$(bc -ql <<< "scale=500 ; l(1+$d*10^-$p) / l(10)" | head -n 1) +-- echo "('${d}.0e-$p', $l)," +-- done +-- done + +WITH t(x, bc_result) AS (VALUES +('9.0e-1', .2787536009528290), +('6.0e-1', .2041199826559248), +('3.0e-1', .1139433523068368), +('9.0e-8', .000000039086501612400118), +('6.0e-8', .000000026057668132465074), +('3.0e-8', .000000013028834261665042), +('9.0e-15', .0000000000000039086503371292489), +('6.0e-15', .0000000000000026057668914195031), +('3.0e-15', .0000000000000013028834457097535), +('9.0e-22', .00000000000000000000039086503371292664), +('6.0e-22', .00000000000000000000026057668914195110), +('3.0e-22', .00000000000000000000013028834457097555), +('9.0e-29', .000000000000000000000000000039086503371292664), +('6.0e-29', .000000000000000000000000000026057668914195110), +('3.0e-29', .000000000000000000000000000013028834457097555), +('9.0e-36', .0000000000000000000000000000000000039086503371292664), +('6.0e-36', .0000000000000000000000000000000000026057668914195110), +('3.0e-36', .0000000000000000000000000000000000013028834457097555)) +SELECT '1+'||x, bc_result, log(1.0+x::numeric), log(1.0+x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" +== 551 +-- truncate_limit: 100 +-- input very large, exact result known +WITH t(x) AS (SELECT '1e'||n FROM generate_series(1, 100) g(n)) +SELECT x, log(x::numeric) FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x) AS (SELECT '1e' || n FROM generate_series(1, 100) g(n)) SELECT x, log(x::numeric) FROM t" +== 552 +-- truncate_limit: 100 +-- input very large, non-exact results +|-- +-- bc(1) results computed with a scale of 500 and truncated using the script +-- below, and then rounded by hand to match the precision of LN(): +|-- +-- for p in {10..50..7} +-- do +-- for d in {2..9..3} +-- do +-- l=$(bc -ql <<< "scale=500 ; l($d*10^$p) / l(10)" | head -n 1) +-- echo "('${d}.0e$p', $l)," +-- done +-- done + +WITH t(x, bc_result) AS (VALUES +('2.0e10', 10.301029995663981), +('5.0e10', 10.698970004336019), +('8.0e10', 10.903089986991944), +('2.0e17', 17.301029995663981), +('5.0e17', 17.698970004336019), +('8.0e17', 17.903089986991944), +('2.0e24', 24.301029995663981), +('5.0e24', 24.698970004336019), +('8.0e24', 24.903089986991944), +('2.0e31', 31.301029995663981), +('5.0e31', 31.698970004336019), +('8.0e31', 31.903089986991944), +('2.0e38', 38.301029995663981), +('5.0e38', 38.698970004336019), +('8.0e38', 38.903089986991944), +('2.0e45', 45.30102999566398), +('5.0e45', 45.69897000433602), +('8.0e45', 45.90308998699194)) +SELECT x, bc_result, log(x::numeric), log(x::numeric)-bc_result AS diff FROM t +-- +CTE: "t" +FUNCTION: name="log" function="log" schema="" ctx=Call +FUNCTION: name="log" function="log" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH t(x, bc_result) AS (...) SELECT ... FROM t" diff --git a/parser/testdata/summary_truncate/postgres_regress/numerology.metadata.json b/parser/testdata/summary_truncate/postgres_regress/numerology.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/numerology.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/numerology.test b/parser/testdata/summary_truncate/postgres_regress/numerology.test new file mode 100644 index 0000000..a9585ea --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/numerology.test @@ -0,0 +1,201 @@ +== 001 +-- truncate_limit: 100 +|-- +-- NUMEROLOGY +-- Test various combinations of numeric types and functions. +|-- + + +|-- +-- numeric literals +|-- + +SELECT 0b100101; +SELECT 0o273; +SELECT 0x42F; + +-- cases near int4 overflow +SELECT 0b1111111111111111111111111111111; +SELECT 0b10000000000000000000000000000000; +SELECT 0o17777777777; +SELECT 0o20000000000; +SELECT 0x7FFFFFFF; +SELECT 0x80000000; + +SELECT -0b10000000000000000000000000000000; +SELECT -0b10000000000000000000000000000001; +SELECT -0o20000000000; +SELECT -0o20000000001; +SELECT -0x80000000; +SELECT -0x80000001; + +-- cases near int8 overflow +SELECT 0b111111111111111111111111111111111111111111111111111111111111111; +SELECT 0b1000000000000000000000000000000000000000000000000000000000000000; +SELECT 0o777777777777777777777; +SELECT 0o1000000000000000000000; +SELECT 0x7FFFFFFFFFFFFFFF; +SELECT 0x8000000000000000; + +SELECT -0b1000000000000000000000000000000000000000000000000000000000000000; +SELECT -0b1000000000000000000000000000000000000000000000000000000000000001; +SELECT -0o1000000000000000000000; +SELECT -0o1000000000000000000001; +SELECT -0x8000000000000000; +SELECT -0x8000000000000001; + +-- error cases +SELECT 123abc; +SELECT 0x0o; +SELECT 0.a; +SELECT 0.0a; +SELECT .0a; +SELECT 0.0e1a; +SELECT 0.0e; +SELECT 0.0e+a; +PREPARE p1 AS SELECT $1a; + +SELECT 0b; +SELECT 1b; +SELECT 0b0x; + +SELECT 0o; +SELECT 1o; +SELECT 0o0x; + +SELECT 0x; +SELECT 1x; +SELECT 0x0y; + +-- underscores +SELECT 1_000_000; +SELECT 1_2_3; +SELECT 0x1EEE_FFFF; +SELECT 0o2_73; +SELECT 0b_10_0101; + +SELECT 1_000.000_005; +SELECT 1_000.; +SELECT .000_005; +SELECT 1_000.5e0_1; + +DO $$ +DECLARE + i int; +BEGIN + FOR i IN 1_001..1_003 LOOP + RAISE NOTICE 'i = %', i; + END LOOP; +END $$; + +-- error cases +SELECT _100; +SELECT 100_; +SELECT 100__000; + +SELECT _1_000.5; +SELECT 1_000_.5; +SELECT 1_000._5; +SELECT 1_000.5_; +SELECT 1_000.5e_1; + +PREPARE p1 AS SELECT $0_1; + +|-- +-- Test implicit type conversions +-- This fails for Postgres v6.1 (and earlier?) +-- so let's try explicit conversions for now - tgl 97/05/07 +|-- + +CREATE TABLE TEMP_FLOAT (f1 FLOAT8); + +INSERT INTO TEMP_FLOAT (f1) + SELECT float8(f1) FROM INT4_TBL; + +INSERT INTO TEMP_FLOAT (f1) + SELECT float8(f1) FROM INT2_TBL; + +SELECT f1 FROM TEMP_FLOAT + ORDER BY f1; + +-- int4 + +CREATE TABLE TEMP_INT4 (f1 INT4); + +INSERT INTO TEMP_INT4 (f1) + SELECT int4(f1) FROM FLOAT8_TBL + WHERE (f1 > -2147483647) AND (f1 < 2147483647); + +INSERT INTO TEMP_INT4 (f1) + SELECT int4(f1) FROM INT2_TBL; + +SELECT f1 FROM TEMP_INT4 + ORDER BY f1; + +-- int2 + +CREATE TABLE TEMP_INT2 (f1 INT2); + +INSERT INTO TEMP_INT2 (f1) + SELECT int2(f1) FROM FLOAT8_TBL + WHERE (f1 >= -32767) AND (f1 <= 32767); + +INSERT INTO TEMP_INT2 (f1) + SELECT int2(f1) FROM INT4_TBL + WHERE (f1 >= -32767) AND (f1 <= 32767); + +SELECT f1 FROM TEMP_INT2 + ORDER BY f1; + +|-- +-- Group-by combinations +|-- + +CREATE TABLE TEMP_GROUP (f1 INT4, f2 INT4, f3 FLOAT8); + +INSERT INTO TEMP_GROUP + SELECT 1, (- i.f1), (- f.f1) + FROM INT4_TBL i, FLOAT8_TBL f; + +INSERT INTO TEMP_GROUP + SELECT 2, i.f1, f.f1 + FROM INT4_TBL i, FLOAT8_TBL f; + +SELECT DISTINCT f1 AS two FROM TEMP_GROUP ORDER BY 1; + +SELECT f1 AS two, max(f3) AS max_float, min(f3) as min_float + FROM TEMP_GROUP + GROUP BY f1 + ORDER BY two, max_float, min_float; + +-- GROUP BY a result column name is not legal per SQL92, but we accept it +-- anyway (if the name is not the name of any column exposed by FROM). +SELECT f1 AS two, max(f3) AS max_float, min(f3) AS min_float + FROM TEMP_GROUP + GROUP BY two + ORDER BY two, max_float, min_float; + +SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1 + FROM TEMP_GROUP + GROUP BY f1 + ORDER BY two, min_minus_1; + +SELECT f1 AS two, + max(f2) + min(f2) AS max_plus_min, + min(f3) - 1 AS min_minus_1 + FROM TEMP_GROUP + GROUP BY f1 + ORDER BY two, min_minus_1; + +DROP TABLE TEMP_INT2; + +DROP TABLE TEMP_INT4; + +DROP TABLE TEMP_FLOAT; + +DROP TABLE TEMP_GROUP; +-- +ERROR: trailing junk after numeric literal at or near "123abc" +CURSORPOS: 1124 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary_truncate/postgres_regress/object_address.metadata.json b/parser/testdata/summary_truncate/postgres_regress/object_address.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/object_address.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/object_address.test b/parser/testdata/summary_truncate/postgres_regress/object_address.test new file mode 100644 index 0000000..1a96a25 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/object_address.test @@ -0,0 +1,741 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test for pg_get_object_address +|-- + +-- Clean up in case a prior regression run failed +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 002 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_addr_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_addr_user" +== 003 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 004 +-- truncate_limit: 100 +CREATE USER regress_addr_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_addr_user" +== 005 +-- truncate_limit: 100 +-- Test generic object addressing/identification functions +CREATE SCHEMA addr_nsp +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA addr_nsp" +== 006 +-- truncate_limit: 100 +SET search_path TO 'addr_nsp' +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO addr_nsp" +== 007 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER addr_fdw +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER addr_fdw" +== 008 +-- truncate_limit: 100 +CREATE SERVER addr_fserv FOREIGN DATA WRAPPER addr_fdw +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER addr_fserv FOREIGN DATA WRAPPER addr_fdw" +== 009 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY addr_ts_dict (template=simple) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY addr_ts_dict (template = simple)" +== 010 +-- truncate_limit: 100 +CREATE TEXT SEARCH CONFIGURATION addr_ts_conf (copy=english) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION addr_ts_conf (copy = english)" +== 011 +-- truncate_limit: 100 +CREATE TEXT SEARCH TEMPLATE addr_ts_temp (lexize=dsimple_lexize) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH TEMPLATE addr_ts_temp (lexize = dsimple_lexize)" +== 012 +-- truncate_limit: 100 +CREATE TEXT SEARCH PARSER addr_ts_prs + (start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH PARSER addr_ts_prs (start = prsd_start, gettoken = prsd_nexttoken, \"end\" = prs..." +== 013 +-- truncate_limit: 100 +CREATE TABLE addr_nsp.gentable ( + a serial primary key CONSTRAINT a_chk CHECK (a > 0), + b text DEFAULT 'hello' +) +-- +TABLE: name="addr_nsp.gentable" schema="addr_nsp" table="gentable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE addr_nsp.gentable (a serial PRIMARY KEY CONSTRAINT a_chk CHECK (a > 0), b text DEFAU..." +== 014 +-- truncate_limit: 100 +CREATE TABLE addr_nsp.parttable ( + a int PRIMARY KEY +) PARTITION BY RANGE (a) +-- +TABLE: name="addr_nsp.parttable" schema="addr_nsp" table="parttable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE addr_nsp.parttable (a int PRIMARY KEY) PARTITION BY RANGE (a)" +== 015 +-- truncate_limit: 100 +CREATE VIEW addr_nsp.genview AS SELECT * from addr_nsp.gentable +-- +TABLE: name="addr_nsp.genview" schema="addr_nsp" table="genview" ctx=DDL +TABLE: name="addr_nsp.gentable" schema="addr_nsp" table="gentable" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW addr_nsp.genview AS SELECT * FROM addr_nsp.gentable" +== 016 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW addr_nsp.genmatview AS SELECT * FROM addr_nsp.gentable +-- +TABLE: name="addr_nsp.genmatview" schema="addr_nsp" table="genmatview" ctx=DDL +TABLE: name="addr_nsp.gentable" schema="addr_nsp" table="gentable" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW addr_nsp.genmatview AS SELECT * FROM addr_nsp.gentable" +== 017 +-- truncate_limit: 100 +CREATE TYPE addr_nsp.gencomptype AS (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE addr_nsp.gencomptype AS (a int)" +== 018 +-- truncate_limit: 100 +CREATE TYPE addr_nsp.genenum AS ENUM ('one', 'two') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE addr_nsp.genenum AS ENUM ('one', 'two')" +== 019 +-- truncate_limit: 100 +CREATE FOREIGN TABLE addr_nsp.genftable (a int) SERVER addr_fserv +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE addr_nsp.genftable (a int) SERVER addr_fserv" +== 020 +-- truncate_limit: 100 +CREATE AGGREGATE addr_nsp.genaggr(int4) (sfunc = int4pl, stype = int4) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE addr_nsp.genaggr (int4) (sfunc = int4pl, stype = int4)" +== 021 +-- truncate_limit: 100 +CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0)" +== 022 +-- truncate_limit: 100 +CREATE FUNCTION addr_nsp.trig() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN END; $$ +-- +FUNCTION: name="addr_nsp.trig" function="trig" schema="addr_nsp" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION addr_nsp.trig() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN END; $$" +== 023 +-- truncate_limit: 100 +CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE PROCEDURE addr_nsp.trig() +-- +TABLE: name="addr_nsp.gentable" schema="addr_nsp" table="gentable" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE FUNCTION addr_nsp.trig()" +== 024 +-- truncate_limit: 100 +CREATE POLICY genpol ON addr_nsp.gentable +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY genpol ON addr_nsp.gentable TO public" +== 025 +-- truncate_limit: 100 +CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQL AS $$ $$ +-- +FUNCTION: name="addr_nsp.proc" function="proc" schema="addr_nsp" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE sql AS $$ $$" +== 026 +-- truncate_limit: 100 +CREATE SERVER "integer" FOREIGN DATA WRAPPER addr_fdw +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER \"integer\" FOREIGN DATA WRAPPER addr_fdw" +== 027 +-- truncate_limit: 100 +CREATE USER MAPPING FOR regress_addr_user SERVER "integer" +-- +STMT: CreateUserMappingStmt +TRUNCATED: "CREATE USER MAPPING FOR regress_addr_user SERVER \"integer\"" +== 028 +-- truncate_limit: 100 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regress_addr_user +-- +STMT: AlterDefaultPrivilegesStmt +TRUNCATED: "ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regre..." +== 029 +-- truncate_limit: 100 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM regress_addr_user +-- +STMT: AlterDefaultPrivilegesStmt +TRUNCATED: "ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE delete ON TABLES FROM regress_addr_user" +== 030 +-- truncate_limit: 100 +-- this transform would be quite unsafe to leave lying around, +-- except that the SQL language pays no attention to transforms: +CREATE TRANSFORM FOR int LANGUAGE SQL ( + FROM SQL WITH FUNCTION prsd_lextype(internal), + TO SQL WITH FUNCTION int4recv(internal)) +-- +STMT: CreateTransformStmt +TRUNCATED: "CREATE TRANSFORM FOR int LANGUAGE sql (FROM SQL WITH FUNCTION prsd_lextype(internal), TO SQL WITH..." +== 031 +-- truncate_limit: 100 +-- suppress warning that depends on wal_level +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 032 +-- truncate_limit: 100 +CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION addr_pub FOR TABLE addr_nsp.gentable" +== 033 +-- truncate_limit: 100 +CREATE PUBLICATION addr_pub_schema FOR TABLES IN SCHEMA addr_nsp +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION addr_pub_schema FOR TABLES IN SCHEMA addr_nsp" +== 034 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 035 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_addr_sub CONNECTION '' PUBLICATION bar WITH (connect = false, slot_name = NONE) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_addr_sub CONNECTION '' PUBLICATION bar WITH (connect = false, slot_na..." +== 036 +-- truncate_limit: 100 +CREATE STATISTICS addr_nsp.gentable_stat ON a, b FROM addr_nsp.gentable +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS addr_nsp.gentable_stat ON a, b FROM addr_nsp.gentable" +== 037 +-- truncate_limit: 100 +-- test some error cases +SELECT pg_get_object_address('stone', '{}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('stone', '{}', '{}')" +== 038 +-- truncate_limit: 100 +SELECT pg_get_object_address('table', '{}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('table', '{}', '{}')" +== 039 +-- truncate_limit: 100 +SELECT pg_get_object_address('table', '{NULL}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('table', '{NULL}', '{}')" +== 040 +-- truncate_limit: 100 +-- unrecognized object types +DO $$ +DECLARE + objtype text; +BEGIN + FOR objtype IN VALUES ('toast table'), ('index column'), ('sequence column'), + ('toast table column'), ('view column'), ('materialized view column') + LOOP + BEGIN + PERFORM pg_get_object_address(objtype, '{one}', '{}'); + EXCEPTION WHEN invalid_parameter_value THEN + RAISE WARNING 'error for %: %', objtype, sqlerrm; + END; + END LOOP; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n objtype text;\nBEGIN\n FOR objtype IN VALUES ('toast table'), ('index column')..." +== 041 +-- truncate_limit: 100 +-- miscellaneous other errors +select * from pg_get_object_address('operator of access method', '{btree,integer_ops,1}', '{int4,bool}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_get_object_address('operator of access method', '{btree,integer_ops,1}', '{int4,..." +== 042 +-- truncate_limit: 100 +select * from pg_get_object_address('operator of access method', '{btree,integer_ops,99}', '{int4,int4}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_get_object_address('operator of access method', '{btree,integer_ops,99}', '{int4..." +== 043 +-- truncate_limit: 100 +select * from pg_get_object_address('function of access method', '{btree,integer_ops,1}', '{int4,bool}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_get_object_address('function of access method', '{btree,integer_ops,1}', '{int4,..." +== 044 +-- truncate_limit: 100 +select * from pg_get_object_address('function of access method', '{btree,integer_ops,99}', '{int4,int4}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_get_object_address('function of access method', '{btree,integer_ops,99}', '{int4..." +== 045 +-- truncate_limit: 100 +DO $$ +DECLARE + objtype text; + names text[]; + args text[]; +BEGIN + FOR objtype IN VALUES + ('table'), ('index'), ('sequence'), ('view'), + ('materialized view'), ('foreign table'), + ('table column'), ('foreign table column'), + ('aggregate'), ('function'), ('procedure'), ('type'), ('cast'), + ('table constraint'), ('domain constraint'), ('conversion'), ('default value'), + ('operator'), ('operator class'), ('operator family'), ('rule'), ('trigger'), + ('text search parser'), ('text search dictionary'), + ('text search template'), ('text search configuration'), + ('policy'), ('user mapping'), ('default acl'), ('transform'), + ('operator of access method'), ('function of access method'), + ('publication namespace'), ('publication relation') + LOOP + FOR names IN VALUES ('{eins}'), ('{addr_nsp, zwei}'), ('{eins, zwei, drei}') + LOOP + FOR args IN VALUES ('{}'), ('{integer}') + LOOP + BEGIN + PERFORM pg_get_object_address(objtype, names, args); + EXCEPTION WHEN OTHERS THEN + RAISE WARNING 'error for %,%,%: %', objtype, names, args, sqlerrm; + END; + END LOOP; + END LOOP; + END LOOP; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n objtype text;\n names text[];\n args text[];\nBEGIN\n FOR objtype IN ..." +== 046 +-- truncate_limit: 100 +-- these object types cannot be qualified names +SELECT pg_get_object_address('language', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('language', '{one}', '{}')" +== 047 +-- truncate_limit: 100 +SELECT pg_get_object_address('language', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('language', '{one,two}', '{}')" +== 048 +-- truncate_limit: 100 +SELECT pg_get_object_address('large object', '{123}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('large object', '{123}', '{}')" +== 049 +-- truncate_limit: 100 +SELECT pg_get_object_address('large object', '{123,456}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('large object', '{123,456}', '{}')" +== 050 +-- truncate_limit: 100 +SELECT pg_get_object_address('large object', '{blargh}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('large object', '{blargh}', '{}')" +== 051 +-- truncate_limit: 100 +SELECT pg_get_object_address('schema', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('schema', '{one}', '{}')" +== 052 +-- truncate_limit: 100 +SELECT pg_get_object_address('schema', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('schema', '{one,two}', '{}')" +== 053 +-- truncate_limit: 100 +SELECT pg_get_object_address('role', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('role', '{one}', '{}')" +== 054 +-- truncate_limit: 100 +SELECT pg_get_object_address('role', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('role', '{one,two}', '{}')" +== 055 +-- truncate_limit: 100 +SELECT pg_get_object_address('database', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('database', '{one}', '{}')" +== 056 +-- truncate_limit: 100 +SELECT pg_get_object_address('database', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('database', '{one,two}', '{}')" +== 057 +-- truncate_limit: 100 +SELECT pg_get_object_address('tablespace', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('tablespace', '{one}', '{}')" +== 058 +-- truncate_limit: 100 +SELECT pg_get_object_address('tablespace', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('tablespace', '{one,two}', '{}')" +== 059 +-- truncate_limit: 100 +SELECT pg_get_object_address('foreign-data wrapper', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('foreign-data wrapper', '{one}', '{}')" +== 060 +-- truncate_limit: 100 +SELECT pg_get_object_address('foreign-data wrapper', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('foreign-data wrapper', '{one,two}', '{}')" +== 061 +-- truncate_limit: 100 +SELECT pg_get_object_address('server', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('server', '{one}', '{}')" +== 062 +-- truncate_limit: 100 +SELECT pg_get_object_address('server', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('server', '{one,two}', '{}')" +== 063 +-- truncate_limit: 100 +SELECT pg_get_object_address('extension', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('extension', '{one}', '{}')" +== 064 +-- truncate_limit: 100 +SELECT pg_get_object_address('extension', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('extension', '{one,two}', '{}')" +== 065 +-- truncate_limit: 100 +SELECT pg_get_object_address('event trigger', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('event trigger', '{one}', '{}')" +== 066 +-- truncate_limit: 100 +SELECT pg_get_object_address('event trigger', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('event trigger', '{one,two}', '{}')" +== 067 +-- truncate_limit: 100 +SELECT pg_get_object_address('access method', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('access method', '{one}', '{}')" +== 068 +-- truncate_limit: 100 +SELECT pg_get_object_address('access method', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('access method', '{one,two}', '{}')" +== 069 +-- truncate_limit: 100 +SELECT pg_get_object_address('publication', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('publication', '{one}', '{}')" +== 070 +-- truncate_limit: 100 +SELECT pg_get_object_address('publication', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('publication', '{one,two}', '{}')" +== 071 +-- truncate_limit: 100 +SELECT pg_get_object_address('subscription', '{one}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('subscription', '{one}', '{}')" +== 072 +-- truncate_limit: 100 +SELECT pg_get_object_address('subscription', '{one,two}', '{}') +-- +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_object_address('subscription', '{one,two}', '{}')" +== 073 +-- truncate_limit: 100 +-- Make sure that NULL handling is correct. + +-- Temporarily disable fancy output, so as future additions never create +-- a large amount of diffs. + +-- test successful cases +WITH objects (type, name, args) AS (VALUES + ('table', '{addr_nsp, gentable}'::text[], '{}'::text[]), + ('table', '{addr_nsp, parttable}'::text[], '{}'::text[]), + ('index', '{addr_nsp, gentable_pkey}', '{}'), + ('index', '{addr_nsp, parttable_pkey}', '{}'), + ('sequence', '{addr_nsp, gentable_a_seq}', '{}'), + -- toast table + ('view', '{addr_nsp, genview}', '{}'), + ('materialized view', '{addr_nsp, genmatview}', '{}'), + ('foreign table', '{addr_nsp, genftable}', '{}'), + ('table column', '{addr_nsp, gentable, b}', '{}'), + ('foreign table column', '{addr_nsp, genftable, a}', '{}'), + ('aggregate', '{addr_nsp, genaggr}', '{int4}'), + ('function', '{pg_catalog, pg_identify_object}', '{pg_catalog.oid, pg_catalog.oid, int4}'), + ('procedure', '{addr_nsp, proc}', '{int4}'), + ('type', '{pg_catalog._int4}', '{}'), + ('type', '{addr_nsp.gendomain}', '{}'), + ('type', '{addr_nsp.gencomptype}', '{}'), + ('type', '{addr_nsp.genenum}', '{}'), + ('cast', '{int8}', '{int4}'), + ('collation', '{default}', '{}'), + ('table constraint', '{addr_nsp, gentable, a_chk}', '{}'), + ('domain constraint', '{addr_nsp.gendomain}', '{domconstr}'), + ('conversion', '{pg_catalog, koi8_r_to_mic}', '{}'), + ('default value', '{addr_nsp, gentable, b}', '{}'), + ('language', '{plpgsql}', '{}'), + -- large object + ('operator', '{+}', '{int4, int4}'), + ('operator class', '{btree, int4_ops}', '{}'), + ('operator family', '{btree, integer_ops}', '{}'), + ('operator of access method', '{btree,integer_ops,1}', '{integer,integer}'), + ('function of access method', '{btree,integer_ops,2}', '{integer,integer}'), + ('rule', '{addr_nsp, genview, _RETURN}', '{}'), + ('trigger', '{addr_nsp, gentable, t}', '{}'), + ('schema', '{addr_nsp}', '{}'), + ('text search parser', '{addr_ts_prs}', '{}'), + ('text search dictionary', '{addr_ts_dict}', '{}'), + ('text search template', '{addr_ts_temp}', '{}'), + ('text search configuration', '{addr_ts_conf}', '{}'), + ('role', '{regress_addr_user}', '{}'), + -- database + -- tablespace + ('foreign-data wrapper', '{addr_fdw}', '{}'), + ('server', '{addr_fserv}', '{}'), + ('user mapping', '{regress_addr_user}', '{integer}'), + ('default acl', '{regress_addr_user,public}', '{r}'), + ('default acl', '{regress_addr_user}', '{r}'), + -- extension + -- event trigger + ('policy', '{addr_nsp, gentable, genpol}', '{}'), + ('transform', '{int}', '{sql}'), + ('access method', '{btree}', '{}'), + ('publication', '{addr_pub}', '{}'), + ('publication namespace', '{addr_nsp}', '{addr_pub_schema}'), + ('publication relation', '{addr_nsp, gentable}', '{addr_pub}'), + ('subscription', '{regress_addr_sub}', '{}'), + ('statistics object', '{addr_nsp, gentable_stat}', '{}') + ) +SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*, + -- test roundtrip through pg_identify_object_as_address + ROW(pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)) = + ROW(pg_identify_object(addr2.classid, addr2.objid, addr2.objsubid)) AS roundtrip +FROM objects, + pg_get_object_address(type, name, args) AS addr1, + pg_identify_object_as_address(classid, objid, objsubid) AS ioa (typ, nms, args), + pg_get_object_address(typ, nms, ioa.args) AS addr2 +ORDER BY addr1.classid, addr1.objid, addr1.objsubid +-- +CTE: "objects" +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +FUNCTION: name="pg_identify_object_as_address" function="pg_identify_object_as_address" schema="" ctx=Call +FUNCTION: name="pg_get_object_address" function="pg_get_object_address" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH objects(type, name, args) AS (...) SELECT ... FROM objects, pg_get_object_address(type, name..." +== 074 +-- truncate_limit: 100 +--- +--- Cleanup resources +--- +DROP FOREIGN DATA WRAPPER addr_fdw CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER addr_fdw CASCADE" +== 075 +-- truncate_limit: 100 +DROP PUBLICATION addr_pub +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION addr_pub" +== 076 +-- truncate_limit: 100 +DROP PUBLICATION addr_pub_schema +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION addr_pub_schema" +== 077 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_addr_sub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_addr_sub" +== 078 +-- truncate_limit: 100 +DROP SCHEMA addr_nsp CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA addr_nsp CASCADE" +== 079 +-- truncate_limit: 100 +DROP OWNED BY regress_addr_user +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_addr_user" +== 080 +-- truncate_limit: 100 +DROP USER regress_addr_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_addr_user" +== 081 +-- truncate_limit: 100 +|-- +-- Checks for invalid objects +|-- + +-- Keep this list in the same order as getObjectIdentityParts() +-- in objectaddress.c. +WITH objects (classid, objid, objsubid) AS (VALUES + ('pg_class'::regclass, 0, 0), -- no relation + ('pg_class'::regclass, 'pg_class'::regclass, 100), -- no column for relation + ('pg_proc'::regclass, 0, 0), -- no function + ('pg_type'::regclass, 0, 0), -- no type + ('pg_cast'::regclass, 0, 0), -- no cast + ('pg_collation'::regclass, 0, 0), -- no collation + ('pg_constraint'::regclass, 0, 0), -- no constraint + ('pg_conversion'::regclass, 0, 0), -- no conversion + ('pg_attrdef'::regclass, 0, 0), -- no default attribute + ('pg_language'::regclass, 0, 0), -- no language + ('pg_largeobject'::regclass, 0, 0), -- no large object, no error + ('pg_operator'::regclass, 0, 0), -- no operator + ('pg_opclass'::regclass, 0, 0), -- no opclass, no need to check for no access method + ('pg_opfamily'::regclass, 0, 0), -- no opfamily + ('pg_am'::regclass, 0, 0), -- no access method + ('pg_amop'::regclass, 0, 0), -- no AM operator + ('pg_amproc'::regclass, 0, 0), -- no AM proc + ('pg_rewrite'::regclass, 0, 0), -- no rewrite + ('pg_trigger'::regclass, 0, 0), -- no trigger + ('pg_namespace'::regclass, 0, 0), -- no schema + ('pg_statistic_ext'::regclass, 0, 0), -- no statistics + ('pg_ts_parser'::regclass, 0, 0), -- no TS parser + ('pg_ts_dict'::regclass, 0, 0), -- no TS dictionary + ('pg_ts_template'::regclass, 0, 0), -- no TS template + ('pg_ts_config'::regclass, 0, 0), -- no TS configuration + ('pg_authid'::regclass, 0, 0), -- no role + ('pg_auth_members'::regclass, 0, 0), -- no role membership + ('pg_database'::regclass, 0, 0), -- no database + ('pg_tablespace'::regclass, 0, 0), -- no tablespace + ('pg_foreign_data_wrapper'::regclass, 0, 0), -- no FDW + ('pg_foreign_server'::regclass, 0, 0), -- no server + ('pg_user_mapping'::regclass, 0, 0), -- no user mapping + ('pg_default_acl'::regclass, 0, 0), -- no default ACL + ('pg_extension'::regclass, 0, 0), -- no extension + ('pg_event_trigger'::regclass, 0, 0), -- no event trigger + ('pg_parameter_acl'::regclass, 0, 0), -- no parameter ACL + ('pg_policy'::regclass, 0, 0), -- no policy + ('pg_publication'::regclass, 0, 0), -- no publication + ('pg_publication_namespace'::regclass, 0, 0), -- no publication namespace + ('pg_publication_rel'::regclass, 0, 0), -- no publication relation + ('pg_subscription'::regclass, 0, 0), -- no subscription + ('pg_transform'::regclass, 0, 0) -- no transformation + ) +SELECT ROW(pg_identify_object(objects.classid, objects.objid, objects.objsubid)) + AS ident, + ROW(pg_identify_object_as_address(objects.classid, objects.objid, objects.objsubid)) + AS addr, + pg_describe_object(objects.classid, objects.objid, objects.objsubid) + AS descr +FROM objects +ORDER BY objects.classid, objects.objid, objects.objsubid +-- +CTE: "objects" +FUNCTION: name="pg_identify_object" function="pg_identify_object" schema="" ctx=Call +FUNCTION: name="pg_identify_object_as_address" function="pg_identify_object_as_address" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH objects(classid, objid, objsubid) AS (...) SELECT ... FROM objects ORDER BY objects.classid,..." diff --git a/parser/testdata/summary_truncate/postgres_regress/oid.metadata.json b/parser/testdata/summary_truncate/postgres_regress/oid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/oid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/oid.test b/parser/testdata/summary_truncate/postgres_regress/oid.test new file mode 100644 index 0000000..be0324e --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/oid.test @@ -0,0 +1,297 @@ +== 001 +-- truncate_limit: 100 +|-- +-- OID +|-- + +CREATE TABLE OID_TBL(f1 oid) +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE oid_tbl (f1 oid)" +== 002 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('1234') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('1234')" +== 003 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('1235') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('1235')" +== 004 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('987') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('987')" +== 005 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('-1040') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('-1040')" +== 006 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('99999999') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('99999999')" +== 007 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('5 ') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('5 ')" +== 008 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES (' 10 ') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES (' 10 ')" +== 009 +-- truncate_limit: 100 +-- leading/trailing hard tab is also allowed +INSERT INTO OID_TBL(f1) VALUES (' 15 ') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('\t 15 \t ')" +== 010 +-- truncate_limit: 100 +-- bad inputs +INSERT INTO OID_TBL(f1) VALUES ('') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('')" +== 011 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES (' ') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES (' ')" +== 012 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('asdfasd') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('asdfasd')" +== 013 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('99asdfasd') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('99asdfasd')" +== 014 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('5 d') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('5 d')" +== 015 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES (' 5d') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES (' 5d')" +== 016 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('5 5') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('5 5')" +== 017 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES (' - 500') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES (' - 500')" +== 018 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('32958209582039852935') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('32958209582039852935')" +== 019 +-- truncate_limit: 100 +INSERT INTO OID_TBL(f1) VALUES ('-23582358720398502385') +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO oid_tbl (f1) VALUES ('-23582358720398502385')" +== 020 +-- truncate_limit: 100 +SELECT * FROM OID_TBL +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM oid_tbl" +== 021 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('1234', 'oid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1234', 'oid')" +== 022 +-- truncate_limit: 100 +SELECT pg_input_is_valid('01XYZ', 'oid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('01XYZ', 'oid')" +== 023 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('01XYZ', 'oid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('01XYZ', 'oid')" +== 024 +-- truncate_limit: 100 +SELECT pg_input_is_valid('9999999999', 'oid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('9999999999', 'oid')" +== 025 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('9999999999', 'oid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('9999999999', 'oid')" +== 026 +-- truncate_limit: 100 +-- While we're here, check oidvector as well +SELECT pg_input_is_valid(' 1 2 4 ', 'oidvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid(' 1 2 4 ', 'oidvector')" +== 027 +-- truncate_limit: 100 +SELECT pg_input_is_valid('01 01XYZ', 'oidvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('01 01XYZ', 'oidvector')" +== 028 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('01 01XYZ', 'oidvector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('01 01XYZ', 'oidvector')" +== 029 +-- truncate_limit: 100 +SELECT pg_input_is_valid('01 9999999999', 'oidvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('01 9999999999', 'oidvector')" +== 030 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('01 9999999999', 'oidvector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('01 9999999999', 'oidvector')" +== 031 +-- truncate_limit: 100 +SELECT o.* FROM OID_TBL o WHERE o.f1 = 1234 +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT o.* FROM oid_tbl o WHERE o.f1 = 1234" +== 032 +-- truncate_limit: 100 +SELECT o.* FROM OID_TBL o WHERE o.f1 <> '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT o.* FROM oid_tbl o WHERE o.f1 <> '1234'" +== 033 +-- truncate_limit: 100 +SELECT o.* FROM OID_TBL o WHERE o.f1 <= '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT o.* FROM oid_tbl o WHERE o.f1 <= '1234'" +== 034 +-- truncate_limit: 100 +SELECT o.* FROM OID_TBL o WHERE o.f1 < '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT o.* FROM oid_tbl o WHERE o.f1 < '1234'" +== 035 +-- truncate_limit: 100 +SELECT o.* FROM OID_TBL o WHERE o.f1 >= '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT o.* FROM oid_tbl o WHERE o.f1 >= '1234'" +== 036 +-- truncate_limit: 100 +SELECT o.* FROM OID_TBL o WHERE o.f1 > '1234' +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=Select +ALIAS: "o"="oid_tbl" +FILTER: schema="" table="o" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT o.* FROM oid_tbl o WHERE o.f1 > '1234'" +== 037 +-- truncate_limit: 100 +DROP TABLE OID_TBL +-- +TABLE: name="oid_tbl" schema="" table="oid_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE oid_tbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/oidjoins.metadata.json b/parser/testdata/summary_truncate/postgres_regress/oidjoins.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/oidjoins.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/oidjoins.test b/parser/testdata/summary_truncate/postgres_regress/oidjoins.test new file mode 100644 index 0000000..e8bba2a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/oidjoins.test @@ -0,0 +1,54 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Verify system catalog foreign key relationships +|-- +DO $doblock$ +declare + fk record; + nkeys integer; + cmd text; + err record; +begin + for fk in select * from pg_get_catalog_foreign_keys() + loop + raise notice 'checking % % => % %', + fk.fktable, fk.fkcols, fk.pktable, fk.pkcols; + nkeys := array_length(fk.fkcols, 1); + cmd := 'SELECT ctid'; + for i in 1 .. nkeys loop + cmd := cmd || ', ' || quote_ident(fk.fkcols[i]); + end loop; + if fk.is_array then + cmd := cmd || ' FROM (SELECT ctid'; + for i in 1 .. nkeys-1 loop + cmd := cmd || ', ' || quote_ident(fk.fkcols[i]); + end loop; + cmd := cmd || ', unnest(' || quote_ident(fk.fkcols[nkeys]); + cmd := cmd || ') as ' || quote_ident(fk.fkcols[nkeys]); + cmd := cmd || ' FROM ' || fk.fktable::text || ') fk WHERE '; + else + cmd := cmd || ' FROM ' || fk.fktable::text || ' fk WHERE '; + end if; + if fk.is_opt then + for i in 1 .. nkeys loop + cmd := cmd || quote_ident(fk.fkcols[i]) || ' != 0 AND '; + end loop; + end if; + cmd := cmd || 'NOT EXISTS(SELECT 1 FROM ' || fk.pktable::text || ' pk WHERE '; + for i in 1 .. nkeys loop + if i > 1 then cmd := cmd || ' AND '; end if; + cmd := cmd || 'pk.' || quote_ident(fk.pkcols[i]); + cmd := cmd || ' = fk.' || quote_ident(fk.fkcols[i]); + end loop; + cmd := cmd || ')'; + -- raise notice 'cmd = %', cmd; + for err in execute cmd loop + raise warning 'FK VIOLATION IN %(%): %', fk.fktable, fk.fkcols, err; + end loop; + end loop; +end +$doblock$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare\n fk record;\n nkeys integer;\n cmd text;\n err record;\nbegin\n for fk in select * ..." diff --git a/parser/testdata/summary_truncate/postgres_regress/opr_sanity.metadata.json b/parser/testdata/summary_truncate/postgres_regress/opr_sanity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/opr_sanity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/opr_sanity.test b/parser/testdata/summary_truncate/postgres_regress/opr_sanity.test new file mode 100644 index 0000000..e3c6866 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/opr_sanity.test @@ -0,0 +1,3449 @@ +== 001 +-- truncate_limit: 100 +|-- +-- OPR_SANITY +-- Sanity checks for common errors in making operator/procedure system tables: +-- pg_operator, pg_proc, pg_cast, pg_conversion, pg_aggregate, pg_am, +-- pg_amop, pg_amproc, pg_opclass, pg_opfamily, pg_index. +|-- +-- Every test failure in this file should be closely inspected. +-- The description of the failing test should be read carefully before +-- adjusting the expected output. In most cases, the queries should +-- not find *any* matching entries. +|-- +-- NB: we assume the oidjoins test will have caught any dangling links, +-- that is OID or REGPROC fields that are not zero and do not match some +-- row in the linked-to table. However, if we want to enforce that a link +-- field can't be 0, we have to check it here. +|-- +-- NB: run this test earlier than the create_operator test, because +-- that test creates some bogus operators... + + +-- **************** pg_proc **************** + +-- Look for illegal values in pg_proc fields. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prolang = 0 OR p1.prorettype = 0 OR + p1.pronargs < 0 OR + p1.pronargdefaults < 0 OR + p1.pronargdefaults > p1.pronargs OR + array_lower(p1.proargtypes, 1) != 0 OR + array_upper(p1.proargtypes, 1) != p1.pronargs-1 OR + 0::oid = ANY (p1.proargtypes) OR + procost <= 0 OR + CASE WHEN proretset THEN prorows <= 0 ELSE prorows != 0 END OR + prokind NOT IN ('f', 'a', 'w', 'p') OR + provolatile NOT IN ('i', 's', 'v') OR + proparallel NOT IN ('s', 'r', 'u') +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="pronargdefaults" +FILTER: schema="" table="p1" column="pronargdefaults" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="" column="procost" +FILTER: schema="" table="" column="proretset" +FILTER: schema="" table="" column="prorows" +FILTER: schema="" table="" column="prorows" +FILTER: schema="" table="" column="prokind" +FILTER: schema="" table="" column="provolatile" +FILTER: schema="" table="" column="proparallel" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 002 +-- truncate_limit: 100 +-- prosrc should never be null; it can be empty only if prosqlbody isn't null +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE prosrc IS NULL +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prosrc" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE prosrc IS NULL" +== 003 +-- truncate_limit: 100 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE (prosrc = '' OR prosrc = '-') AND prosqlbody IS NULL +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prosrc" +FILTER: schema="" table="" column="prosrc" +FILTER: schema="" table="" column="prosqlbody" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE (prosrc = '' OR prosrc = '-') AND prosqlbody IS NULL" +== 004 +-- truncate_limit: 100 +-- proretset should only be set for normal functions +SELECT p1.oid, p1.proname +FROM pg_proc AS p1 +WHERE proretset AND prokind != 'f' +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="proretset" +FILTER: schema="" table="" column="prokind" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE proretset AND prokind <> 'f'" +== 005 +-- truncate_limit: 100 +-- currently, no built-in functions should be SECURITY DEFINER; +-- this might change in future, but there will probably never be many. +SELECT p1.oid, p1.proname +FROM pg_proc AS p1 +WHERE prosecdef +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prosecdef" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE prosecdef ORDER BY 1" +== 006 +-- truncate_limit: 100 +-- pronargdefaults should be 0 iff proargdefaults is null +SELECT p1.oid, p1.proname +FROM pg_proc AS p1 +WHERE (pronargdefaults <> 0) != (proargdefaults IS NOT NULL) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="pronargdefaults" +FILTER: schema="" table="" column="proargdefaults" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 007 +-- truncate_limit: 100 +-- probin should be non-empty for C functions, null everywhere else +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE prolang = 13 AND (probin IS NULL OR probin = '' OR probin = '-') +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prolang" +FILTER: schema="" table="" column="probin" +FILTER: schema="" table="" column="probin" +FILTER: schema="" table="" column="probin" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 008 +-- truncate_limit: 100 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE prolang != 13 AND probin IS NOT NULL +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="prolang" +FILTER: schema="" table="" column="probin" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE prolang <> 13 AND probin IS NOT NULL" +== 009 +-- truncate_limit: 100 +-- Look for conflicting proc definitions (same names and input datatypes). +-- (This test should be dead code now that we have the unique index +-- pg_proc_proname_args_nsp_index, but I'll leave it in anyway.) + +SELECT p1.oid, p1.proname, p2.oid, p2.proname +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.proname = p2.proname AND + p1.pronargs = p2.pronargs AND + p1.proargtypes = p2.proargtypes +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="proname" +FILTER: schema="" table="p2" column="proname" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p2" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname, p2.oid, p2.proname FROM pg_proc p1, pg_proc p2 WHERE ..." +== 010 +-- truncate_limit: 100 +-- Considering only built-in procs (prolang = 12), look for multiple uses +-- of the same internal function (ie, matching prosrc fields). It's OK to +-- have several entries with different pronames for the same internal function, +-- but conflicts in the number of arguments and other critical items should +-- be complained of. (We don't check data types here; see next query.) +-- Note: ignore aggregate functions here, since they all point to the same +-- dummy built-in function. + +SELECT p1.oid, p1.proname, p2.oid, p2.proname +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid < p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + (p1.prokind != 'a' OR p2.prokind != 'a') AND + (p1.prolang != p2.prolang OR + p1.prokind != p2.prokind OR + p1.prosecdef != p2.prosecdef OR + p1.proleakproof != p2.proleakproof OR + p1.proisstrict != p2.proisstrict OR + p1.proretset != p2.proretset OR + p1.provolatile != p2.provolatile OR + p1.pronargs != p2.pronargs) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prosecdef" +FILTER: schema="" table="p2" column="prosecdef" +FILTER: schema="" table="p1" column="proleakproof" +FILTER: schema="" table="p2" column="proleakproof" +FILTER: schema="" table="p1" column="proisstrict" +FILTER: schema="" table="p2" column="proisstrict" +FILTER: schema="" table="p1" column="proretset" +FILTER: schema="" table="p2" column="proretset" +FILTER: schema="" table="p1" column="provolatile" +FILTER: schema="" table="p2" column="provolatile" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p2" column="pronargs" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname, p2.oid, p2.proname FROM pg_proc p1, pg_proc p2 WHERE ..." +== 011 +-- truncate_limit: 100 +-- Look for uses of different type OIDs in the argument/result type fields +-- for different aliases of the same built-in function. +-- This indicates that the types are being presumed to be binary-equivalent, +-- or that the built-in function is prepared to deal with different types. +-- That's not wrong, necessarily, but we make lists of all the types being +-- so treated. Note that the expected output of this part of the test will +-- need to be modified whenever new pairs of types are made binary-equivalent, +-- or when new polymorphic built-in functions are added! +-- Note: ignore aggregate functions here, since they all point to the same +-- dummy built-in function. Likewise, ignore range and multirange constructor +-- functions. + +SELECT DISTINCT p1.prorettype::regtype, p2.prorettype::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + p1.prosrc NOT LIKE E'range\\_constructor_' AND + p2.prosrc NOT LIKE E'range\\_constructor_' AND + p1.prosrc NOT LIKE E'multirange\\_constructor_' AND + p2.prosrc NOT LIKE E'multirange\\_constructor_' AND + (p1.prorettype < p2.prorettype) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p2" column="prorettype" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 012 +-- truncate_limit: 100 +SELECT DISTINCT p1.proargtypes[0]::regtype, p2.proargtypes[0]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + p1.prosrc NOT LIKE E'range\\_constructor_' AND + p2.prosrc NOT LIKE E'range\\_constructor_' AND + p1.prosrc NOT LIKE E'multirange\\_constructor_' AND + p2.prosrc NOT LIKE E'multirange\\_constructor_' AND + (p1.proargtypes[0] < p2.proargtypes[0]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 013 +-- truncate_limit: 100 +SELECT DISTINCT p1.proargtypes[1]::regtype, p2.proargtypes[1]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + p1.prosrc NOT LIKE E'range\\_constructor_' AND + p2.prosrc NOT LIKE E'range\\_constructor_' AND + p1.prosrc NOT LIKE E'multirange\\_constructor_' AND + p2.prosrc NOT LIKE E'multirange\\_constructor_' AND + (p1.proargtypes[1] < p2.proargtypes[1]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 014 +-- truncate_limit: 100 +SELECT DISTINCT p1.proargtypes[2]::regtype, p2.proargtypes[2]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[2] < p2.proargtypes[2]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 015 +-- truncate_limit: 100 +SELECT DISTINCT p1.proargtypes[3]::regtype, p2.proargtypes[3]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[3] < p2.proargtypes[3]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 016 +-- truncate_limit: 100 +SELECT DISTINCT p1.proargtypes[4]::regtype, p2.proargtypes[4]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[4] < p2.proargtypes[4]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 017 +-- truncate_limit: 100 +SELECT DISTINCT p1.proargtypes[5]::regtype, p2.proargtypes[5]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[5] < p2.proargtypes[5]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 018 +-- truncate_limit: 100 +SELECT DISTINCT p1.proargtypes[6]::regtype, p2.proargtypes[6]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[6] < p2.proargtypes[6]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 019 +-- truncate_limit: 100 +SELECT DISTINCT p1.proargtypes[7]::regtype, p2.proargtypes[7]::regtype +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid != p2.oid AND + p1.prosrc = p2.prosrc AND + p1.prolang = 12 AND p2.prolang = 12 AND + p1.prokind != 'a' AND p2.prokind != 'a' AND + (p1.proargtypes[7] < p2.proargtypes[7]) +ORDER BY 1, 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosrc" +FILTER: schema="" table="p2" column="prosrc" +FILTER: schema="" table="p1" column="prolang" +FILTER: schema="" table="p2" column="prolang" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1, 2" +== 020 +-- truncate_limit: 100 +-- Look for functions that return type "internal" and do not have any +-- "internal" argument. Such a function would be a security hole since +-- it might be used to call an internal function from an SQL command. +-- As of 7.3 this query should find only internal_in, which is safe because +-- it always throws an error when called. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype = 'internal'::regtype AND NOT + 'internal'::regtype = ANY (p1.proargtypes) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 021 +-- truncate_limit: 100 +-- Look for functions that return a polymorphic type and do not have any +-- polymorphic argument. Calls of such functions would be unresolvable +-- at parse time. As of 9.6 this query should find only some input functions +-- and GiST support functions associated with these pseudotypes. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype IN + ('anyelement'::regtype, 'anyarray'::regtype, 'anynonarray'::regtype, + 'anyenum'::regtype) + AND NOT + ('anyelement'::regtype = ANY (p1.proargtypes) OR + 'anyarray'::regtype = ANY (p1.proargtypes) OR + 'anynonarray'::regtype = ANY (p1.proargtypes) OR + 'anyenum'::regtype = ANY (p1.proargtypes) OR + 'anyrange'::regtype = ANY (p1.proargtypes) OR + 'anymultirange'::regtype = ANY (p1.proargtypes)) +ORDER BY 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ... ORDER BY 2" +== 022 +-- truncate_limit: 100 +-- anyrange and anymultirange are tighter than the rest, can only resolve +-- from each other + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype IN ('anyrange'::regtype, 'anymultirange'::regtype) + AND NOT + ('anyrange'::regtype = ANY (p1.proargtypes) OR + 'anymultirange'::regtype = ANY (p1.proargtypes)) +ORDER BY 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ... ORDER BY 2" +== 023 +-- truncate_limit: 100 +-- similarly for the anycompatible family + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype IN + ('anycompatible'::regtype, 'anycompatiblearray'::regtype, + 'anycompatiblenonarray'::regtype) + AND NOT + ('anycompatible'::regtype = ANY (p1.proargtypes) OR + 'anycompatiblearray'::regtype = ANY (p1.proargtypes) OR + 'anycompatiblenonarray'::regtype = ANY (p1.proargtypes) OR + 'anycompatiblerange'::regtype = ANY (p1.proargtypes)) +ORDER BY 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ... ORDER BY 2" +== 024 +-- truncate_limit: 100 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype = 'anycompatiblerange'::regtype + AND NOT + 'anycompatiblerange'::regtype = ANY (p1.proargtypes) +ORDER BY 2 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ... ORDER BY 2" +== 025 +-- truncate_limit: 100 +-- Look for functions that accept cstring and are neither datatype input +-- functions nor encoding conversion functions. It's almost never a good +-- idea to use cstring input for a function meant to be called from SQL; +-- text should be used instead, because cstring lacks suitable casts. +-- As of 9.6 this query should find only cstring_out and cstring_send. +-- However, we must manually exclude shell_in, which might or might not be +-- rejected by the EXISTS clause depending on whether there are currently +-- any shell types. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE 'cstring'::regtype = ANY (p1.proargtypes) + AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typinput = p1.oid) + AND NOT EXISTS(SELECT 1 FROM pg_conversion WHERE conproc = p1.oid) + AND p1.oid != 'shell_in(cstring)'::regprocedure +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="" column="conproc" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ... ORDER BY 1" +== 026 +-- truncate_limit: 100 +-- Likewise, look for functions that return cstring and aren't datatype output +-- functions nor typmod output functions. +-- As of 9.6 this query should find only cstring_in and cstring_recv. +-- However, we must manually exclude shell_out. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE p1.prorettype = 'cstring'::regtype + AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typoutput = p1.oid) + AND NOT EXISTS(SELECT 1 FROM pg_type WHERE typmodout = p1.oid) + AND p1.oid != 'shell_out(void)'::regprocedure +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="" column="typoutput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="" column="typmodout" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ... ORDER BY 1" +== 027 +-- truncate_limit: 100 +-- Check for length inconsistencies between the various argument-info arrays. + +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proallargtypes IS NOT NULL AND + array_length(proallargtypes,1) < array_length(proargtypes,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 028 +-- truncate_limit: 100 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proargmodes IS NOT NULL AND + array_length(proargmodes,1) < array_length(proargtypes,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 029 +-- truncate_limit: 100 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proargnames IS NOT NULL AND + array_length(proargnames,1) < array_length(proargtypes,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proargnames" +FILTER: schema="" table="" column="proargnames" +FILTER: schema="" table="" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 030 +-- truncate_limit: 100 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proallargtypes IS NOT NULL AND proargmodes IS NOT NULL AND + array_length(proallargtypes,1) <> array_length(proargmodes,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargmodes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 031 +-- truncate_limit: 100 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proallargtypes IS NOT NULL AND proargnames IS NOT NULL AND + array_length(proallargtypes,1) <> array_length(proargnames,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargnames" +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargnames" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 032 +-- truncate_limit: 100 +SELECT p1.oid, p1.proname +FROM pg_proc as p1 +WHERE proargmodes IS NOT NULL AND proargnames IS NOT NULL AND + array_length(proargmodes,1) <> array_length(proargnames,1) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargnames" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargnames" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE ..." +== 033 +-- truncate_limit: 100 +-- Check that proallargtypes matches proargtypes +SELECT p1.oid, p1.proname, p1.proargtypes, p1.proallargtypes, p1.proargmodes +FROM pg_proc as p1 +WHERE proallargtypes IS NOT NULL AND + ARRAY(SELECT unnest(proargtypes)) <> + ARRAY(SELECT proallargtypes[i] + FROM generate_series(1, array_length(proallargtypes, 1)) g(i) + WHERE proargmodes IS NULL OR proargmodes[i] IN ('i', 'b', 'v')) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="proallargtypes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_proc p1 WHERE ..." +== 034 +-- truncate_limit: 100 +-- Check for type of the variadic array parameter's elements. +-- provariadic should be ANYOID if the type of the last element is ANYOID, +-- ANYELEMENTOID if the type of the last element is ANYARRAYOID, +-- ANYCOMPATIBLEOID if the type of the last element is ANYCOMPATIBLEARRAYOID, +-- and otherwise the element type corresponding to the array type. + +SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[] +FROM pg_proc +WHERE provariadic != 0 +AND case proargtypes[array_length(proargtypes, 1)-1] + WHEN '"any"'::regtype THEN '"any"'::regtype + WHEN 'anyarray'::regtype THEN 'anyelement'::regtype + WHEN 'anycompatiblearray'::regtype THEN 'anycompatible'::regtype + ELSE (SELECT t.oid + FROM pg_type t + WHERE t.typarray = proargtypes[array_length(proargtypes, 1)-1]) + END != provariadic +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t"="pg_type" +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FUNCTION: name="array_length" function="array_length" schema="" ctx=Call +FILTER: schema="" table="" column="provariadic" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="t" column="typarray" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[] FROM pg_proc WHERE ..." +== 035 +-- truncate_limit: 100 +-- Check that all and only those functions with a variadic type have +-- a variadic argument. +SELECT oid::regprocedure, proargmodes, provariadic +FROM pg_proc +WHERE (proargmodes IS NOT NULL AND 'v' = any(proargmodes)) + IS DISTINCT FROM + (provariadic != 0) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="proargmodes" +FILTER: schema="" table="" column="provariadic" +STMT: SelectStmt +TRUNCATED: "SELECT oid::regprocedure, proargmodes, provariadic FROM pg_proc WHERE ..." +== 036 +-- truncate_limit: 100 +-- Check for prosupport functions with the wrong signature +SELECT p1.oid, p1.proname, p2.oid, p2.proname +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p2.oid = p1.prosupport AND + (p2.prorettype != 'internal'::regtype OR p2.proretset OR p2.pronargs != 1 + OR p2.proargtypes[0] != 'internal'::regtype) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="prosupport" +FILTER: schema="" table="p2" column="prorettype" +FILTER: schema="" table="p2" column="proretset" +FILTER: schema="" table="p2" column="pronargs" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname, p2.oid, p2.proname FROM pg_proc p1, pg_proc p2 WHERE ..." +== 037 +-- truncate_limit: 100 +-- Insist that all built-in pg_proc entries have descriptions +SELECT p1.oid, p1.proname +FROM pg_proc as p1 LEFT JOIN pg_description as d + ON p1.tableoid = d.classoid and p1.oid = d.objoid and d.objsubid = 0 +WHERE d.classoid IS NULL AND p1.oid <= 9999 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +ALIAS: "d"="pg_description" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="d" column="classoid" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_proc p1 LEFT JOIN pg_description d ON p1.tableoid = d.classoid AND p1.oid = d...." +== 038 +-- truncate_limit: 100 +-- List of built-in leakproof functions +|-- +-- Leakproof functions should only be added after carefully +-- scrutinizing all possibly executed codepaths for possible +-- information leaks. Don't add functions here unless you know what a +-- leakproof function is. If unsure, don't mark it as such. + +-- temporarily disable fancy output, so catalog changes create less diff noise + +SELECT p1.oid::regprocedure +FROM pg_proc p1 JOIN pg_namespace pn + ON pronamespace = pn.oid +WHERE nspname = 'pg_catalog' AND proleakproof +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "pn"="pg_namespace" +FILTER: schema="" table="" column="nspname" +FILTER: schema="" table="" column="proleakproof" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_proc p1 JOIN pg_namespace pn ON pronamespace = pn.oid WHERE ... ORDER BY 1" +== 039 +-- truncate_limit: 100 +-- restore normal output mode + +-- List of functions used by libpq's fe-lobj.c +|-- +-- If the output of this query changes, you probably broke libpq. +-- lo_initialize() assumes that there will be at most one match for +-- each listed name. +select proname, oid from pg_catalog.pg_proc +where proname in ( + 'lo_open', + 'lo_close', + 'lo_creat', + 'lo_create', + 'lo_unlink', + 'lo_lseek', + 'lo_lseek64', + 'lo_tell', + 'lo_tell64', + 'lo_truncate', + 'lo_truncate64', + 'loread', + 'lowrite') +and pronamespace = (select oid from pg_catalog.pg_namespace + where nspname = 'pg_catalog') +order by 1 +-- +TABLE: name="pg_catalog.pg_proc" schema="pg_catalog" table="pg_proc" ctx=Select +TABLE: name="pg_catalog.pg_namespace" schema="pg_catalog" table="pg_namespace" ctx=Select +FILTER: schema="" table="" column="proname" +FILTER: schema="" table="" column="pronamespace" +FILTER: schema="" table="" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT proname, oid FROM pg_catalog.pg_proc WHERE ... ORDER BY 1" +== 040 +-- truncate_limit: 100 +-- Check that all immutable functions are marked parallel safe +SELECT p1.oid, p1.proname +FROM pg_proc AS p1 +WHERE provolatile = 'i' AND proparallel = 'u' +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="" column="provolatile" +FILTER: schema="" table="" column="proparallel" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid, p1.proname FROM pg_proc p1 WHERE provolatile = 'i' AND proparallel = 'u'" +== 041 +-- truncate_limit: 100 +-- **************** pg_cast **************** + +-- Catch bogus values in pg_cast columns (other than cases detected by +-- oidjoins test). + +SELECT * +FROM pg_cast c +WHERE castsource = 0 OR casttarget = 0 OR castcontext NOT IN ('e', 'a', 'i') + OR castmethod NOT IN ('f', 'b' ,'i') +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +ALIAS: "c"="pg_cast" +FILTER: schema="" table="" column="castsource" +FILTER: schema="" table="" column="casttarget" +FILTER: schema="" table="" column="castcontext" +FILTER: schema="" table="" column="castmethod" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_cast c WHERE ..." +== 042 +-- truncate_limit: 100 +-- Check that castfunc is nonzero only for cast methods that need a function, +-- and zero otherwise + +SELECT * +FROM pg_cast c +WHERE (castmethod = 'f' AND castfunc = 0) + OR (castmethod IN ('b', 'i') AND castfunc <> 0) +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +ALIAS: "c"="pg_cast" +FILTER: schema="" table="" column="castmethod" +FILTER: schema="" table="" column="castfunc" +FILTER: schema="" table="" column="castmethod" +FILTER: schema="" table="" column="castfunc" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_cast c WHERE ..." +== 043 +-- truncate_limit: 100 +-- Look for casts to/from the same type that aren't length coercion functions. +-- (We assume they are length coercions if they take multiple arguments.) +-- Such entries are not necessarily harmful, but they are useless. + +SELECT * +FROM pg_cast c +WHERE castsource = casttarget AND castfunc = 0 +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +ALIAS: "c"="pg_cast" +FILTER: schema="" table="" column="castsource" +FILTER: schema="" table="" column="casttarget" +FILTER: schema="" table="" column="castfunc" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_cast c WHERE castsource = casttarget AND castfunc = 0" +== 044 +-- truncate_limit: 100 +SELECT c.* +FROM pg_cast c, pg_proc p +WHERE c.castfunc = p.oid AND p.pronargs < 2 AND castsource = casttarget +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "c"="pg_cast" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="c" column="castfunc" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="" column="castsource" +FILTER: schema="" table="" column="casttarget" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM pg_cast c, pg_proc p WHERE ..." +== 045 +-- truncate_limit: 100 +-- Look for cast functions that don't have the right signature. The +-- argument and result types in pg_proc must be the same as, or binary +-- compatible with, what it says in pg_cast. +-- As a special case, we allow casts from CHAR(n) that use functions +-- declared to take TEXT. This does not pass the binary-coercibility test +-- because CHAR(n)-to-TEXT normally invokes rtrim(). However, the results +-- are the same, so long as the function is one that ignores trailing blanks. + +SELECT c.* +FROM pg_cast c, pg_proc p +WHERE c.castfunc = p.oid AND + (p.pronargs < 1 OR p.pronargs > 3 + OR NOT (binary_coercible(c.castsource, p.proargtypes[0]) + OR (c.castsource = 'character'::regtype AND + p.proargtypes[0] = 'text'::regtype)) + OR NOT binary_coercible(p.prorettype, c.casttarget)) +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "c"="pg_cast" +ALIAS: "p"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="c" column="castfunc" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="c" column="castsource" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="c" column="castsource" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="c" column="casttarget" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM pg_cast c, pg_proc p WHERE ..." +== 046 +-- truncate_limit: 100 +SELECT c.* +FROM pg_cast c, pg_proc p +WHERE c.castfunc = p.oid AND + ((p.pronargs > 1 AND p.proargtypes[1] != 'int4'::regtype) OR + (p.pronargs > 2 AND p.proargtypes[2] != 'bool'::regtype)) +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "c"="pg_cast" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="c" column="castfunc" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM pg_cast c, pg_proc p WHERE ..." +== 047 +-- truncate_limit: 100 +-- Look for binary compatible casts that do not have the reverse +-- direction registered as well, or where the reverse direction is not +-- also binary compatible. This is legal, but usually not intended. + +-- As of 7.4, this finds the casts from text and varchar to bpchar, because +-- those are binary-compatible while the reverse way goes through rtrim(). + +-- As of 8.2, this finds the cast from cidr to inet, because that is a +-- trivial binary coercion while the other way goes through inet_to_cidr(). + +-- As of 8.3, this finds the casts from xml to text, varchar, and bpchar, +-- because those are binary-compatible while the reverse goes through +-- texttoxml(), which does an XML syntax check. + +-- As of 9.1, this finds the cast from pg_node_tree to text, which we +-- intentionally do not provide a reverse pathway for. + +SELECT castsource::regtype, casttarget::regtype, castfunc, castcontext +FROM pg_cast c +WHERE c.castmethod = 'b' AND + NOT EXISTS (SELECT 1 FROM pg_cast k + WHERE k.castmethod = 'b' AND + k.castsource = c.casttarget AND + k.casttarget = c.castsource) +-- +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +TABLE: name="pg_cast" schema="" table="pg_cast" ctx=Select +ALIAS: "c"="pg_cast" +ALIAS: "k"="pg_cast" +FILTER: schema="" table="c" column="castmethod" +FILTER: schema="" table="k" column="castmethod" +FILTER: schema="" table="k" column="castsource" +FILTER: schema="" table="c" column="casttarget" +FILTER: schema="" table="k" column="casttarget" +FILTER: schema="" table="c" column="castsource" +STMT: SelectStmt +TRUNCATED: "SELECT castsource::regtype, casttarget::regtype, castfunc, castcontext FROM pg_cast c WHERE ..." +== 048 +-- truncate_limit: 100 +-- **************** pg_conversion **************** + +-- Look for illegal values in pg_conversion fields. + +SELECT c.oid, c.conname +FROM pg_conversion as c +WHERE c.conproc = 0 OR + pg_encoding_to_char(conforencoding) = '' OR + pg_encoding_to_char(contoencoding) = '' +-- +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +ALIAS: "c"="pg_conversion" +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FILTER: schema="" table="c" column="conproc" +FILTER: schema="" table="" column="conforencoding" +FILTER: schema="" table="" column="contoencoding" +STMT: SelectStmt +TRUNCATED: "SELECT c.oid, c.conname FROM pg_conversion c WHERE ..." +== 049 +-- truncate_limit: 100 +-- Look for conprocs that don't have the expected signature. + +SELECT p.oid, p.proname, c.oid, c.conname +FROM pg_proc p, pg_conversion c +WHERE p.oid = c.conproc AND + (p.prorettype != 'int4'::regtype OR p.proretset OR + p.pronargs != 6 OR + p.proargtypes[0] != 'int4'::regtype OR + p.proargtypes[1] != 'int4'::regtype OR + p.proargtypes[2] != 'cstring'::regtype OR + p.proargtypes[3] != 'internal'::regtype OR + p.proargtypes[4] != 'int4'::regtype OR + p.proargtypes[5] != 'bool'::regtype) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +ALIAS: "c"="pg_conversion" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="c" column="conproc" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="proretset" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p.oid, p.proname, c.oid, c.conname FROM pg_proc p, pg_conversion c WHERE ..." +== 050 +-- truncate_limit: 100 +-- Check for conprocs that don't perform the specific conversion that +-- pg_conversion alleges they do, by trying to invoke each conversion +-- on some simple ASCII data. (The conproc should throw an error if +-- it doesn't accept the encodings that are passed to it.) +-- Unfortunately, we can't test non-default conprocs this way, because +-- there is no way to ask convert() to invoke them, and we cannot call +-- them directly from SQL. But there are no non-default built-in +-- conversions anyway. +-- (Similarly, this doesn't cope with any search path issues.) + +SELECT c.oid, c.conname +FROM pg_conversion as c +WHERE condefault AND + convert('ABC'::bytea, pg_encoding_to_char(conforencoding), + pg_encoding_to_char(contoencoding)) != 'ABC' +-- +TABLE: name="pg_conversion" schema="" table="pg_conversion" ctx=Select +ALIAS: "c"="pg_conversion" +FUNCTION: name="convert" function="convert" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="convert" function="convert" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FUNCTION: name="pg_encoding_to_char" function="pg_encoding_to_char" schema="" ctx=Call +FILTER: schema="" table="" column="condefault" +FILTER: schema="" table="" column="conforencoding" +FILTER: schema="" table="" column="contoencoding" +STMT: SelectStmt +TRUNCATED: "SELECT c.oid, c.conname FROM pg_conversion c WHERE ..." +== 051 +-- truncate_limit: 100 +-- **************** pg_operator **************** + +-- Look for illegal values in pg_operator fields. + +SELECT o1.oid, o1.oprname +FROM pg_operator as o1 +WHERE (o1.oprkind != 'b' AND o1.oprkind != 'l') OR + o1.oprresult = 0 OR o1.oprcode = 0 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o1" column="oprcode" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname FROM pg_operator o1 WHERE ..." +== 052 +-- truncate_limit: 100 +-- Look for missing or unwanted operand types + +SELECT o1.oid, o1.oprname +FROM pg_operator as o1 +WHERE (o1.oprleft = 0 and o1.oprkind != 'l') OR + (o1.oprleft != 0 and o1.oprkind = 'l') OR + o1.oprright = 0 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname FROM pg_operator o1 WHERE ..." +== 053 +-- truncate_limit: 100 +-- Look for conflicting operator definitions (same names and input datatypes). + +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2 +WHERE o1.oid != o2.oid AND + o1.oprname = o2.oprname AND + o1.oprkind = o2.oprkind AND + o1.oprleft = o2.oprleft AND + o1.oprright = o2.oprright +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprname" +FILTER: schema="" table="o2" column="oprname" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o2" column="oprkind" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o2" column="oprleft" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="o2" column="oprright" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode FROM pg_operator o1, pg_operator o2 WHERE ..." +== 054 +-- truncate_limit: 100 +-- Look for commutative operators that don't commute. +-- DEFINITIONAL NOTE: If A.oprcom = B, then x A y has the same result as y B x. +-- We expect that B will always say that B.oprcom = A as well; that's not +-- inherently essential, but it would be inefficient not to mark it so. + +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2 +WHERE o1.oprcom = o2.oid AND + (o1.oprkind != 'b' OR + o1.oprleft != o2.oprright OR + o1.oprright != o2.oprleft OR + o1.oprresult != o2.oprresult OR + o1.oid != o2.oprcom) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprcom" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o2" column="oprright" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="o2" column="oprleft" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o2" column="oprresult" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o2" column="oprcom" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode FROM pg_operator o1, pg_operator o2 WHERE ..." +== 055 +-- truncate_limit: 100 +-- Look for negatory operators that don't agree. +-- DEFINITIONAL NOTE: If A.oprnegate = B, then both A and B must yield +-- boolean results, and (x A y) == ! (x B y), or the equivalent for +-- single-operand operators. +-- We expect that B will always say that B.oprnegate = A as well; that's not +-- inherently essential, but it would be inefficient not to mark it so. +-- Also, A and B had better not be the same operator. + +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2 +WHERE o1.oprnegate = o2.oid AND + (o1.oprkind != o2.oprkind OR + o1.oprleft != o2.oprleft OR + o1.oprright != o2.oprright OR + o1.oprresult != 'bool'::regtype OR + o2.oprresult != 'bool'::regtype OR + o1.oid != o2.oprnegate OR + o1.oid = o2.oid) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprnegate" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o2" column="oprkind" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="o2" column="oprleft" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="o2" column="oprright" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o2" column="oprresult" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o2" column="oprnegate" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o2" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode FROM pg_operator o1, pg_operator o2 WHERE ..." +== 056 +-- truncate_limit: 100 +-- Make a list of the names of operators that are claimed to be commutator +-- pairs. This list will grow over time, but before accepting a new entry +-- make sure you didn't link the wrong operators. + +SELECT DISTINCT o1.oprname AS op1, o2.oprname AS op2 +FROM pg_operator o1, pg_operator o2 +WHERE o1.oprcom = o2.oid AND o1.oprname <= o2.oprname +ORDER BY 1, 2 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprcom" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprname" +FILTER: schema="" table="o2" column="oprname" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_operator o1, pg_operator o2 WHERE ... ORDER BY 1, 2" +== 057 +-- truncate_limit: 100 +-- Likewise for negator pairs. + +SELECT DISTINCT o1.oprname AS op1, o2.oprname AS op2 +FROM pg_operator o1, pg_operator o2 +WHERE o1.oprnegate = o2.oid AND o1.oprname <= o2.oprname +ORDER BY 1, 2 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprnegate" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprname" +FILTER: schema="" table="o2" column="oprname" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_operator o1, pg_operator o2 WHERE ... ORDER BY 1, 2" +== 058 +-- truncate_limit: 100 +-- A mergejoinable or hashjoinable operator must be binary, must return +-- boolean, and must have a commutator (itself, unless it's a cross-type +-- operator). + +SELECT o1.oid, o1.oprname FROM pg_operator AS o1 +WHERE (o1.oprcanmerge OR o1.oprcanhash) AND NOT + (o1.oprkind = 'b' AND o1.oprresult = 'bool'::regtype AND o1.oprcom != 0) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprcanmerge" +FILTER: schema="" table="o1" column="oprcanhash" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o1" column="oprcom" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname FROM pg_operator o1 WHERE ..." +== 059 +-- truncate_limit: 100 +-- What's more, the commutator had better be mergejoinable/hashjoinable too. + +SELECT o1.oid, o1.oprname, o2.oid, o2.oprname +FROM pg_operator AS o1, pg_operator AS o2 +WHERE o1.oprcom = o2.oid AND + (o1.oprcanmerge != o2.oprcanmerge OR + o1.oprcanhash != o2.oprcanhash) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +FILTER: schema="" table="o1" column="oprcom" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="o1" column="oprcanmerge" +FILTER: schema="" table="o2" column="oprcanmerge" +FILTER: schema="" table="o1" column="oprcanhash" +FILTER: schema="" table="o2" column="oprcanhash" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname, o2.oid, o2.oprname FROM pg_operator o1, pg_operator o2 WHERE ..." +== 060 +-- truncate_limit: 100 +-- Mergejoinable operators should appear as equality members of btree index +-- opfamilies. + +SELECT o1.oid, o1.oprname +FROM pg_operator AS o1 +WHERE o1.oprcanmerge AND NOT EXISTS + (SELECT 1 FROM pg_amop + WHERE amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') AND + amopopr = o1.oid AND amopstrategy = 3) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprcanmerge" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname FROM pg_operator o1 WHERE ..." +== 061 +-- truncate_limit: 100 +-- And the converse. + +SELECT o1.oid, o1.oprname, p.amopfamily +FROM pg_operator AS o1, pg_amop p +WHERE amopopr = o1.oid + AND amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') + AND amopstrategy = 3 + AND NOT o1.oprcanmerge +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p"="pg_amop" +FILTER: schema="" table="" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname, p.amopfamily FROM pg_operator o1, pg_amop p WHERE ..." +== 062 +-- truncate_limit: 100 +-- Hashable operators should appear as members of hash index opfamilies. + +SELECT o1.oid, o1.oprname +FROM pg_operator AS o1 +WHERE o1.oprcanhash AND NOT EXISTS + (SELECT 1 FROM pg_amop + WHERE amopmethod = (SELECT oid FROM pg_am WHERE amname = 'hash') AND + amopopr = o1.oid AND amopstrategy = 1) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="o1" column="oprcanhash" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname FROM pg_operator o1 WHERE ..." +== 063 +-- truncate_limit: 100 +-- And the converse. + +SELECT o1.oid, o1.oprname, p.amopfamily +FROM pg_operator AS o1, pg_amop p +WHERE amopopr = o1.oid + AND amopmethod = (SELECT oid FROM pg_am WHERE amname = 'hash') + AND NOT o1.oprcanhash +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p"="pg_amop" +FILTER: schema="" table="" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname, p.amopfamily FROM pg_operator o1, pg_amop p WHERE ..." +== 064 +-- truncate_limit: 100 +-- Check that each operator defined in pg_operator matches its oprcode entry +-- in pg_proc. Easiest to do this separately for each oprkind. + +SELECT o1.oid, o1.oprname, p1.oid, p1.proname +FROM pg_operator AS o1, pg_proc AS p1 +WHERE o1.oprcode = p1.oid AND + o1.oprkind = 'b' AND + (p1.pronargs != 2 + OR NOT binary_coercible(p1.prorettype, o1.oprresult) + OR NOT binary_coercible(o1.oprleft, p1.proargtypes[0]) + OR NOT binary_coercible(o1.oprright, p1.proargtypes[1])) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o1" column="oprleft" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname, p1.oid, p1.proname FROM pg_operator o1, pg_proc p1 WHERE ..." +== 065 +-- truncate_limit: 100 +SELECT o1.oid, o1.oprname, p1.oid, p1.proname +FROM pg_operator AS o1, pg_proc AS p1 +WHERE o1.oprcode = p1.oid AND + o1.oprkind = 'l' AND + (p1.pronargs != 1 + OR NOT binary_coercible(p1.prorettype, o1.oprresult) + OR NOT binary_coercible(o1.oprright, p1.proargtypes[0]) + OR o1.oprleft != 0) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="o1" column="oprright" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="o1" column="oprleft" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname, p1.oid, p1.proname FROM pg_operator o1, pg_proc p1 WHERE ..." +== 066 +-- truncate_limit: 100 +-- If the operator is mergejoinable or hashjoinable, its underlying function +-- should not be volatile. + +SELECT o1.oid, o1.oprname, p1.oid, p1.proname +FROM pg_operator AS o1, pg_proc AS p1 +WHERE o1.oprcode = p1.oid AND + (o1.oprcanmerge OR o1.oprcanhash) AND + p1.provolatile = 'v' +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprcanmerge" +FILTER: schema="" table="o1" column="oprcanhash" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname, p1.oid, p1.proname FROM pg_operator o1, pg_proc p1 WHERE ..." +== 067 +-- truncate_limit: 100 +-- If oprrest is set, the operator must return boolean, +-- and it must link to a proc with the right signature +-- to be a restriction selectivity estimator. +-- The proc signature we want is: float8 proc(internal, oid, internal, int4) + +SELECT o1.oid, o1.oprname, p2.oid, p2.proname +FROM pg_operator AS o1, pg_proc AS p2 +WHERE o1.oprrest = p2.oid AND + (o1.oprresult != 'bool'::regtype OR + p2.prorettype != 'float8'::regtype OR p2.proretset OR + p2.pronargs != 4 OR + p2.proargtypes[0] != 'internal'::regtype OR + p2.proargtypes[1] != 'oid'::regtype OR + p2.proargtypes[2] != 'internal'::regtype OR + p2.proargtypes[3] != 'int4'::regtype) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="o1" column="oprrest" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="p2" column="prorettype" +FILTER: schema="" table="p2" column="proretset" +FILTER: schema="" table="p2" column="pronargs" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname, p2.oid, p2.proname FROM pg_operator o1, pg_proc p2 WHERE ..." +== 068 +-- truncate_limit: 100 +-- If oprjoin is set, the operator must be a binary boolean op, +-- and it must link to a proc with the right signature +-- to be a join selectivity estimator. +-- The proc signature we want is: float8 proc(internal, oid, internal, int2, internal) +-- (Note: the old signature with only 4 args is still allowed, but no core +-- estimator should be using it.) + +SELECT o1.oid, o1.oprname, p2.oid, p2.proname +FROM pg_operator AS o1, pg_proc AS p2 +WHERE o1.oprjoin = p2.oid AND + (o1.oprkind != 'b' OR o1.oprresult != 'bool'::regtype OR + p2.prorettype != 'float8'::regtype OR p2.proretset OR + p2.pronargs != 5 OR + p2.proargtypes[0] != 'internal'::regtype OR + p2.proargtypes[1] != 'oid'::regtype OR + p2.proargtypes[2] != 'internal'::regtype OR + p2.proargtypes[3] != 'int2'::regtype OR + p2.proargtypes[4] != 'internal'::regtype) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="o1" column="oprjoin" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="o1" column="oprkind" +FILTER: schema="" table="o1" column="oprresult" +FILTER: schema="" table="p2" column="prorettype" +FILTER: schema="" table="p2" column="proretset" +FILTER: schema="" table="p2" column="pronargs" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT o1.oid, o1.oprname, p2.oid, p2.proname FROM pg_operator o1, pg_proc p2 WHERE ..." +== 069 +-- truncate_limit: 100 +-- Insist that all built-in pg_operator entries have descriptions +SELECT o1.oid, o1.oprname +FROM pg_operator as o1 LEFT JOIN pg_description as d + ON o1.tableoid = d.classoid and o1.oid = d.objoid and d.objsubid = 0 +WHERE d.classoid IS NULL AND o1.oid <= 9999 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +ALIAS: "d"="pg_description" +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="d" column="classoid" +FILTER: schema="" table="o1" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_operator o1 LEFT JOIN pg_description d ON o1.tableoid = d.classoid AND o1.oid ..." +== 070 +-- truncate_limit: 100 +-- Check that operators' underlying functions have suitable comments, +-- namely 'implementation of XXX operator'. (Note: it's not necessary to +-- put such comments into pg_proc.dat; initdb will generate them as needed.) +-- In some cases involving legacy names for operators, there are multiple +-- operators referencing the same pg_proc entry, so ignore operators whose +-- comments say they are deprecated. +-- We also have a few functions that are both operator support and meant to +-- be called directly; those should have comments matching their operator. +WITH funcdescs AS ( + SELECT p.oid as p_oid, proname, o.oid as o_oid, + pd.description as prodesc, + 'implementation of ' || oprname || ' operator' as expecteddesc, + od.description as oprdesc + FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid + LEFT JOIN pg_description pd ON + (pd.objoid = p.oid and pd.classoid = p.tableoid and pd.objsubid = 0) + LEFT JOIN pg_description od ON + (od.objoid = o.oid and od.classoid = o.tableoid and od.objsubid = 0) + WHERE o.oid <= 9999 +) +SELECT * FROM funcdescs + WHERE prodesc IS DISTINCT FROM expecteddesc + AND oprdesc NOT LIKE 'deprecated%' + AND prodesc IS DISTINCT FROM oprdesc +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +ALIAS: "o"="pg_operator" +ALIAS: "od"="pg_description" +ALIAS: "p"="pg_proc" +ALIAS: "pd"="pg_description" +CTE: "funcdescs" +FILTER: schema="" table="" column="prodesc" +FILTER: schema="" table="" column="expecteddesc" +FILTER: schema="" table="" column="oprdesc" +FILTER: schema="" table="" column="prodesc" +FILTER: schema="" table="" column="oprdesc" +FILTER: schema="" table="o" column="oid" +STMT: SelectStmt +TRUNCATED: "WITH funcdescs AS (...) SELECT * FROM funcdescs WHERE ..." +== 071 +-- truncate_limit: 100 +-- Show all the operator-implementation functions that have their own +-- comments. This should happen only in cases where the function and +-- operator syntaxes are both documented at the user level. +-- This should be a pretty short list; it's mostly legacy cases. +WITH funcdescs AS ( + SELECT p.oid as p_oid, proname, o.oid as o_oid, + pd.description as prodesc, + 'implementation of ' || oprname || ' operator' as expecteddesc, + od.description as oprdesc + FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid + LEFT JOIN pg_description pd ON + (pd.objoid = p.oid and pd.classoid = p.tableoid and pd.objsubid = 0) + LEFT JOIN pg_description od ON + (od.objoid = o.oid and od.classoid = o.tableoid and od.objsubid = 0) + WHERE o.oid <= 9999 +) +SELECT p_oid, proname, prodesc FROM funcdescs + WHERE prodesc IS DISTINCT FROM expecteddesc + AND oprdesc NOT LIKE 'deprecated%' +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +TABLE: name="pg_description" schema="" table="pg_description" ctx=Select +ALIAS: "o"="pg_operator" +ALIAS: "od"="pg_description" +ALIAS: "p"="pg_proc" +ALIAS: "pd"="pg_description" +CTE: "funcdescs" +FILTER: schema="" table="" column="prodesc" +FILTER: schema="" table="" column="expecteddesc" +FILTER: schema="" table="" column="oprdesc" +FILTER: schema="" table="o" column="oid" +STMT: SelectStmt +TRUNCATED: "WITH funcdescs AS (...) SELECT p_oid, proname, prodesc FROM funcdescs WHERE ... ORDER BY 1" +== 072 +-- truncate_limit: 100 +-- Operators that are commutator pairs should have identical volatility +-- and leakproofness markings on their implementation functions. +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2, pg_proc AS p1, pg_proc AS p2 +WHERE o1.oprcom = o2.oid AND p1.oid = o1.oprcode AND p2.oid = o2.oprcode AND + (p1.provolatile != p2.provolatile OR + p1.proleakproof != p2.proleakproof) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="o1" column="oprcom" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="o2" column="oprcode" +FILTER: schema="" table="p1" column="provolatile" +FILTER: schema="" table="p2" column="provolatile" +FILTER: schema="" table="p1" column="proleakproof" +FILTER: schema="" table="p2" column="proleakproof" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_operator o1, pg_operator o2, pg_proc p1, pg_proc p2 WHERE ..." +== 073 +-- truncate_limit: 100 +-- Likewise for negator pairs. +SELECT o1.oid, o1.oprcode, o2.oid, o2.oprcode +FROM pg_operator AS o1, pg_operator AS o2, pg_proc AS p1, pg_proc AS p2 +WHERE o1.oprnegate = o2.oid AND p1.oid = o1.oprcode AND p2.oid = o2.oprcode AND + (p1.provolatile != p2.provolatile OR + p1.proleakproof != p2.proleakproof) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "o1"="pg_operator" +ALIAS: "o2"="pg_operator" +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FILTER: schema="" table="o1" column="oprnegate" +FILTER: schema="" table="o2" column="oid" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="o2" column="oprcode" +FILTER: schema="" table="p1" column="provolatile" +FILTER: schema="" table="p2" column="provolatile" +FILTER: schema="" table="p1" column="proleakproof" +FILTER: schema="" table="p2" column="proleakproof" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_operator o1, pg_operator o2, pg_proc p1, pg_proc p2 WHERE ..." +== 074 +-- truncate_limit: 100 +-- Btree comparison operators' functions should have the same volatility +-- and leakproofness markings as the associated comparison support function. +SELECT pp.oid::regprocedure as proc, pp.provolatile as vp, pp.proleakproof as lp, + po.oid::regprocedure as opr, po.provolatile as vo, po.proleakproof as lo +FROM pg_proc pp, pg_proc po, pg_operator o, pg_amproc ap, pg_amop ao +WHERE pp.oid = ap.amproc AND po.oid = o.oprcode AND o.oid = ao.amopopr AND + ao.amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') AND + ao.amopfamily = ap.amprocfamily AND + ao.amoplefttype = ap.amproclefttype AND + ao.amoprighttype = ap.amprocrighttype AND + ap.amprocnum = 1 AND + (pp.provolatile != po.provolatile OR + pp.proleakproof != po.proleakproof) +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "ao"="pg_amop" +ALIAS: "ap"="pg_amproc" +ALIAS: "o"="pg_operator" +ALIAS: "po"="pg_proc" +ALIAS: "pp"="pg_proc" +FILTER: schema="" table="pp" column="oid" +FILTER: schema="" table="ap" column="amproc" +FILTER: schema="" table="po" column="oid" +FILTER: schema="" table="o" column="oprcode" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="ao" column="amopopr" +FILTER: schema="" table="ao" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_proc pp, pg_proc po, pg_operator o, pg_amproc ap, pg_amop ao WHERE ... ORDER BY 1" +== 075 +-- truncate_limit: 100 +-- **************** pg_aggregate **************** + +-- Look for illegal values in pg_aggregate fields. + +SELECT ctid, aggfnoid::oid +FROM pg_aggregate as a +WHERE aggfnoid = 0 OR aggtransfn = 0 OR + aggkind NOT IN ('n', 'o', 'h') OR + aggnumdirectargs < 0 OR + (aggkind = 'n' AND aggnumdirectargs > 0) OR + aggfinalmodify NOT IN ('r', 's', 'w') OR + aggmfinalmodify NOT IN ('r', 's', 'w') OR + aggtranstype = 0 OR aggtransspace < 0 OR aggmtransspace < 0 +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +FILTER: schema="" table="" column="aggfnoid" +FILTER: schema="" table="" column="aggtransfn" +FILTER: schema="" table="" column="aggkind" +FILTER: schema="" table="" column="aggnumdirectargs" +FILTER: schema="" table="" column="aggkind" +FILTER: schema="" table="" column="aggnumdirectargs" +FILTER: schema="" table="" column="aggfinalmodify" +FILTER: schema="" table="" column="aggmfinalmodify" +FILTER: schema="" table="" column="aggtranstype" +FILTER: schema="" table="" column="aggtransspace" +FILTER: schema="" table="" column="aggmtransspace" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, aggfnoid::oid FROM pg_aggregate a WHERE ..." +== 076 +-- truncate_limit: 100 +-- Make sure the matching pg_proc entry is sensible, too. + +SELECT a.aggfnoid::oid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggfnoid = p.oid AND + (p.prokind != 'a' OR p.proretset OR p.pronargs < a.aggnumdirectargs) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="prokind" +FILTER: schema="" table="p" column="proretset" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid::oid, p.proname FROM pg_aggregate a, pg_proc p WHERE ..." +== 077 +-- truncate_limit: 100 +-- Make sure there are no prokind = PROKIND_AGGREGATE pg_proc entries without matches. + +SELECT oid, proname +FROM pg_proc as p +WHERE p.prokind = 'a' AND + NOT EXISTS (SELECT 1 FROM pg_aggregate a WHERE a.aggfnoid = p.oid) +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="p" column="prokind" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT oid, proname FROM pg_proc p WHERE ..." +== 078 +-- truncate_limit: 100 +-- If there is no finalfn then the output type must be the transtype. + +SELECT a.aggfnoid::oid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggfnoid = p.oid AND + a.aggfinalfn = 0 AND p.prorettype != a.aggtranstype +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggfinalfn" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="a" column="aggtranstype" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid::oid, p.proname FROM pg_aggregate a, pg_proc p WHERE ..." +== 079 +-- truncate_limit: 100 +-- Cross-check transfn against its entry in pg_proc. +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggtransfn = ptr.oid AND + (ptr.proretset + OR NOT (ptr.pronargs = + CASE WHEN a.aggkind = 'n' THEN p.pronargs + 1 + ELSE greatest(p.pronargs - a.aggnumdirectargs, 1) + 1 END) + OR NOT binary_coercible(ptr.prorettype, a.aggtranstype) + OR NOT binary_coercible(a.aggtranstype, ptr.proargtypes[0]) + OR (p.pronargs > 0 AND + NOT binary_coercible(p.proargtypes[0], ptr.proargtypes[1])) + OR (p.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[1], ptr.proargtypes[2])) + OR (p.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[2], ptr.proargtypes[3])) + OR (p.pronargs > 3 AND + NOT binary_coercible(p.proargtypes[3], ptr.proargtypes[4])) + -- we could carry the check further, but 4 args is enough for now + OR (p.pronargs > 4) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proretset" +FILTER: schema="" table="ptr" column="pronargs" +FILTER: schema="" table="a" column="aggkind" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="ptr" column="prorettype" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_proc p, pg_proc ptr WHERE ..." +== 080 +-- truncate_limit: 100 +-- Cross-check finalfn (if present) against its entry in pg_proc. + +SELECT a.aggfnoid::oid, p.proname, pfn.oid, pfn.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS pfn +WHERE a.aggfnoid = p.oid AND + a.aggfinalfn = pfn.oid AND + (pfn.proretset OR + NOT binary_coercible(pfn.prorettype, p.prorettype) OR + NOT binary_coercible(a.aggtranstype, pfn.proargtypes[0]) OR + CASE WHEN a.aggfinalextra THEN pfn.pronargs != p.pronargs + 1 + ELSE pfn.pronargs != a.aggnumdirectargs + 1 END + OR (pfn.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[0], pfn.proargtypes[1])) + OR (pfn.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[1], pfn.proargtypes[2])) + OR (pfn.pronargs > 3 AND + NOT binary_coercible(p.proargtypes[2], pfn.proargtypes[3])) + -- we could carry the check further, but 4 args is enough for now + OR (pfn.pronargs > 4) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "pfn"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggfinalfn" +FILTER: schema="" table="pfn" column="oid" +FILTER: schema="" table="pfn" column="proretset" +FILTER: schema="" table="pfn" column="prorettype" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="a" column="aggfinalextra" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_proc p, pg_proc pfn WHERE ..." +== 081 +-- truncate_limit: 100 +-- If transfn is strict then either initval should be non-NULL, or +-- input type should match transtype so that the first non-null input +-- can be assigned as the state value. + +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggtransfn = ptr.oid AND ptr.proisstrict AND + a.agginitval IS NULL AND + NOT binary_coercible(p.proargtypes[0], a.aggtranstype) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proisstrict" +FILTER: schema="" table="a" column="agginitval" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="a" column="aggtranstype" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_proc p, pg_proc ptr WHERE ..." +== 082 +-- truncate_limit: 100 +-- Check for inconsistent specifications of moving-aggregate columns. + +SELECT ctid, aggfnoid::oid +FROM pg_aggregate as a +WHERE aggmtranstype != 0 AND + (aggmtransfn = 0 OR aggminvtransfn = 0) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +FILTER: schema="" table="" column="aggmtranstype" +FILTER: schema="" table="" column="aggmtransfn" +FILTER: schema="" table="" column="aggminvtransfn" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, aggfnoid::oid FROM pg_aggregate a WHERE ..." +== 083 +-- truncate_limit: 100 +SELECT ctid, aggfnoid::oid +FROM pg_aggregate as a +WHERE aggmtranstype = 0 AND + (aggmtransfn != 0 OR aggminvtransfn != 0 OR aggmfinalfn != 0 OR + aggmtransspace != 0 OR aggminitval IS NOT NULL) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +FILTER: schema="" table="" column="aggmtranstype" +FILTER: schema="" table="" column="aggmtransfn" +FILTER: schema="" table="" column="aggminvtransfn" +FILTER: schema="" table="" column="aggmfinalfn" +FILTER: schema="" table="" column="aggmtransspace" +FILTER: schema="" table="" column="aggminitval" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, aggfnoid::oid FROM pg_aggregate a WHERE ..." +== 084 +-- truncate_limit: 100 +-- If there is no mfinalfn then the output type must be the mtranstype. + +SELECT a.aggfnoid::oid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggfnoid = p.oid AND + a.aggmtransfn != 0 AND + a.aggmfinalfn = 0 AND p.prorettype != a.aggmtranstype +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmtransfn" +FILTER: schema="" table="a" column="aggmfinalfn" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="a" column="aggmtranstype" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid::oid, p.proname FROM pg_aggregate a, pg_proc p WHERE ..." +== 085 +-- truncate_limit: 100 +-- Cross-check mtransfn (if present) against its entry in pg_proc. +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggmtransfn = ptr.oid AND + (ptr.proretset + OR NOT (ptr.pronargs = + CASE WHEN a.aggkind = 'n' THEN p.pronargs + 1 + ELSE greatest(p.pronargs - a.aggnumdirectargs, 1) + 1 END) + OR NOT binary_coercible(ptr.prorettype, a.aggmtranstype) + OR NOT binary_coercible(a.aggmtranstype, ptr.proargtypes[0]) + OR (p.pronargs > 0 AND + NOT binary_coercible(p.proargtypes[0], ptr.proargtypes[1])) + OR (p.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[1], ptr.proargtypes[2])) + OR (p.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[2], ptr.proargtypes[3])) + -- we could carry the check further, but 3 args is enough for now + OR (p.pronargs > 3) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proretset" +FILTER: schema="" table="ptr" column="pronargs" +FILTER: schema="" table="a" column="aggkind" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="ptr" column="prorettype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_proc p, pg_proc ptr WHERE ..." +== 086 +-- truncate_limit: 100 +-- Cross-check minvtransfn (if present) against its entry in pg_proc. +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggminvtransfn = ptr.oid AND + (ptr.proretset + OR NOT (ptr.pronargs = + CASE WHEN a.aggkind = 'n' THEN p.pronargs + 1 + ELSE greatest(p.pronargs - a.aggnumdirectargs, 1) + 1 END) + OR NOT binary_coercible(ptr.prorettype, a.aggmtranstype) + OR NOT binary_coercible(a.aggmtranstype, ptr.proargtypes[0]) + OR (p.pronargs > 0 AND + NOT binary_coercible(p.proargtypes[0], ptr.proargtypes[1])) + OR (p.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[1], ptr.proargtypes[2])) + OR (p.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[2], ptr.proargtypes[3])) + -- we could carry the check further, but 3 args is enough for now + OR (p.pronargs > 3) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggminvtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proretset" +FILTER: schema="" table="ptr" column="pronargs" +FILTER: schema="" table="a" column="aggkind" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="ptr" column="prorettype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="ptr" column="proargtypes" +FILTER: schema="" table="p" column="pronargs" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_proc p, pg_proc ptr WHERE ..." +== 087 +-- truncate_limit: 100 +-- Cross-check mfinalfn (if present) against its entry in pg_proc. + +SELECT a.aggfnoid::oid, p.proname, pfn.oid, pfn.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS pfn +WHERE a.aggfnoid = p.oid AND + a.aggmfinalfn = pfn.oid AND + (pfn.proretset OR + NOT binary_coercible(pfn.prorettype, p.prorettype) OR + NOT binary_coercible(a.aggmtranstype, pfn.proargtypes[0]) OR + CASE WHEN a.aggmfinalextra THEN pfn.pronargs != p.pronargs + 1 + ELSE pfn.pronargs != a.aggnumdirectargs + 1 END + OR (pfn.pronargs > 1 AND + NOT binary_coercible(p.proargtypes[0], pfn.proargtypes[1])) + OR (pfn.pronargs > 2 AND + NOT binary_coercible(p.proargtypes[1], pfn.proargtypes[2])) + OR (pfn.pronargs > 3 AND + NOT binary_coercible(p.proargtypes[2], pfn.proargtypes[3])) + -- we could carry the check further, but 4 args is enough for now + OR (pfn.pronargs > 4) + ) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "pfn"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmfinalfn" +FILTER: schema="" table="pfn" column="oid" +FILTER: schema="" table="pfn" column="proretset" +FILTER: schema="" table="pfn" column="prorettype" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="a" column="aggmtranstype" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="a" column="aggmfinalextra" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="a" column="aggnumdirectargs" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="pfn" column="proargtypes" +FILTER: schema="" table="pfn" column="pronargs" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_proc p, pg_proc pfn WHERE ..." +== 088 +-- truncate_limit: 100 +-- If mtransfn is strict then either minitval should be non-NULL, or +-- input type should match mtranstype so that the first non-null input +-- can be assigned as the state value. + +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr +WHERE a.aggfnoid = p.oid AND + a.aggmtransfn = ptr.oid AND ptr.proisstrict AND + a.aggminitval IS NULL AND + NOT binary_coercible(p.proargtypes[0], a.aggmtranstype) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="ptr" column="proisstrict" +FILTER: schema="" table="a" column="aggminitval" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="a" column="aggmtranstype" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_proc p, pg_proc ptr WHERE ..." +== 089 +-- truncate_limit: 100 +-- mtransfn and minvtransfn should have same strictness setting. + +SELECT a.aggfnoid::oid, p.proname, ptr.oid, ptr.proname, iptr.oid, iptr.proname +FROM pg_aggregate AS a, pg_proc AS p, pg_proc AS ptr, pg_proc AS iptr +WHERE a.aggfnoid = p.oid AND + a.aggmtransfn = ptr.oid AND + a.aggminvtransfn = iptr.oid AND + ptr.proisstrict != iptr.proisstrict +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "iptr"="pg_proc" +ALIAS: "p"="pg_proc" +ALIAS: "ptr"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggmtransfn" +FILTER: schema="" table="ptr" column="oid" +FILTER: schema="" table="a" column="aggminvtransfn" +FILTER: schema="" table="iptr" column="oid" +FILTER: schema="" table="ptr" column="proisstrict" +FILTER: schema="" table="iptr" column="proisstrict" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_proc p, pg_proc ptr, pg_proc iptr WHERE ..." +== 090 +-- truncate_limit: 100 +-- Check that all combine functions have signature +-- combine(transtype, transtype) returns transtype + +SELECT a.aggfnoid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggcombinefn = p.oid AND + (p.pronargs != 2 OR + p.prorettype != p.proargtypes[0] OR + p.prorettype != p.proargtypes[1] OR + NOT binary_coercible(a.aggtranstype, p.proargtypes[0])) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="aggcombinefn" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="p" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid, p.proname FROM pg_aggregate a, pg_proc p WHERE ..." +== 091 +-- truncate_limit: 100 +-- Check that no combine function for an INTERNAL transtype is strict. + +SELECT a.aggfnoid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggcombinefn = p.oid AND + a.aggtranstype = 'internal'::regtype AND p.proisstrict +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggcombinefn" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggtranstype" +FILTER: schema="" table="p" column="proisstrict" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid, p.proname FROM pg_aggregate a, pg_proc p WHERE ..." +== 092 +-- truncate_limit: 100 +-- serialize/deserialize functions should be specified only for aggregates +-- with transtype internal and a combine function, and we should have both +-- or neither of them. + +SELECT aggfnoid, aggtranstype, aggserialfn, aggdeserialfn +FROM pg_aggregate +WHERE (aggserialfn != 0 OR aggdeserialfn != 0) + AND (aggtranstype != 'internal'::regtype OR aggcombinefn = 0 OR + aggserialfn = 0 OR aggdeserialfn = 0) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +FILTER: schema="" table="" column="aggserialfn" +FILTER: schema="" table="" column="aggdeserialfn" +FILTER: schema="" table="" column="aggtranstype" +FILTER: schema="" table="" column="aggcombinefn" +FILTER: schema="" table="" column="aggserialfn" +FILTER: schema="" table="" column="aggdeserialfn" +STMT: SelectStmt +TRUNCATED: "SELECT aggfnoid, aggtranstype, aggserialfn, aggdeserialfn FROM pg_aggregate WHERE ..." +== 093 +-- truncate_limit: 100 +-- Check that all serialization functions have signature +-- serialize(internal) returns bytea +-- Also insist that they be strict; it's wasteful to run them on NULLs. + +SELECT a.aggfnoid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggserialfn = p.oid AND + (p.prorettype != 'bytea'::regtype OR p.pronargs != 1 OR + p.proargtypes[0] != 'internal'::regtype OR + NOT p.proisstrict) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggserialfn" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proisstrict" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid, p.proname FROM pg_aggregate a, pg_proc p WHERE ..." +== 094 +-- truncate_limit: 100 +-- Check that all deserialization functions have signature +-- deserialize(bytea, internal) returns internal +-- Also insist that they be strict; it's wasteful to run them on NULLs. + +SELECT a.aggfnoid, p.proname +FROM pg_aggregate as a, pg_proc as p +WHERE a.aggdeserialfn = p.oid AND + (p.prorettype != 'internal'::regtype OR p.pronargs != 2 OR + p.proargtypes[0] != 'bytea'::regtype OR + p.proargtypes[1] != 'internal'::regtype OR + NOT p.proisstrict) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggdeserialfn" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="p" column="prorettype" +FILTER: schema="" table="p" column="pronargs" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="p" column="proisstrict" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid, p.proname FROM pg_aggregate a, pg_proc p WHERE ..." +== 095 +-- truncate_limit: 100 +-- Check that aggregates which have the same transition function also have +-- the same combine, serialization, and deserialization functions. +-- While that isn't strictly necessary, it's fishy if they don't. + +SELECT a.aggfnoid, a.aggcombinefn, a.aggserialfn, a.aggdeserialfn, + b.aggfnoid, b.aggcombinefn, b.aggserialfn, b.aggdeserialfn +FROM + pg_aggregate a, pg_aggregate b +WHERE + a.aggfnoid < b.aggfnoid AND a.aggtransfn = b.aggtransfn AND + (a.aggcombinefn != b.aggcombinefn OR a.aggserialfn != b.aggserialfn + OR a.aggdeserialfn != b.aggdeserialfn) +-- +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "b"="pg_aggregate" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="b" column="aggfnoid" +FILTER: schema="" table="a" column="aggtransfn" +FILTER: schema="" table="b" column="aggtransfn" +FILTER: schema="" table="a" column="aggcombinefn" +FILTER: schema="" table="b" column="aggcombinefn" +FILTER: schema="" table="a" column="aggserialfn" +FILTER: schema="" table="b" column="aggserialfn" +FILTER: schema="" table="a" column="aggdeserialfn" +FILTER: schema="" table="b" column="aggdeserialfn" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_aggregate a, pg_aggregate b WHERE ..." +== 096 +-- truncate_limit: 100 +-- Cross-check aggsortop (if present) against pg_operator. +-- We expect to find entries for bool_and, bool_or, every, max, and min. + +SELECT DISTINCT proname, oprname +FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p +WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid +ORDER BY 1, 2 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "o"="pg_operator" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggsortop" +FILTER: schema="" table="o" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_operator o, pg_aggregate a, pg_proc p WHERE ... ORDER BY 1, 2" +== 097 +-- truncate_limit: 100 +-- Check datatypes match + +SELECT a.aggfnoid::oid, o.oid +FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p +WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid AND + (oprkind != 'b' OR oprresult != 'boolean'::regtype + OR oprleft != p.proargtypes[0] OR oprright != p.proargtypes[0]) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "o"="pg_operator" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggsortop" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="" column="oprkind" +FILTER: schema="" table="" column="oprresult" +FILTER: schema="" table="" column="oprleft" +FILTER: schema="" table="p" column="proargtypes" +FILTER: schema="" table="" column="oprright" +FILTER: schema="" table="p" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid::oid, o.oid FROM pg_operator o, pg_aggregate a, pg_proc p WHERE ..." +== 098 +-- truncate_limit: 100 +-- Check operator is a suitable btree opfamily member + +SELECT a.aggfnoid::oid, o.oid +FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p +WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid AND + NOT EXISTS(SELECT 1 FROM pg_amop + WHERE amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') + AND amopopr = o.oid + AND amoplefttype = o.oprleft + AND amoprighttype = o.oprright) +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "o"="pg_operator" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggsortop" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT a.aggfnoid::oid, o.oid FROM pg_operator o, pg_aggregate a, pg_proc p WHERE ..." +== 099 +-- truncate_limit: 100 +-- Check correspondence of btree strategies and names + +SELECT DISTINCT proname, oprname, amopstrategy +FROM pg_operator AS o, pg_aggregate AS a, pg_proc AS p, + pg_amop as ao +WHERE a.aggfnoid = p.oid AND a.aggsortop = o.oid AND + amopopr = o.oid AND + amopmethod = (SELECT oid FROM pg_am WHERE amname = 'btree') +ORDER BY 1, 2 +-- +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "ao"="pg_amop" +ALIAS: "o"="pg_operator" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="a" column="aggfnoid" +FILTER: schema="" table="p" column="oid" +FILTER: schema="" table="a" column="aggsortop" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="" column="amopopr" +FILTER: schema="" table="o" column="oid" +FILTER: schema="" table="" column="amopmethod" +FILTER: schema="" table="" column="amname" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_operator o, pg_aggregate a, pg_proc p, pg_amop ao WHERE ... OR..." +== 100 +-- truncate_limit: 100 +-- Check that there are not aggregates with the same name and different +-- numbers of arguments. While not technically wrong, we have a project policy +-- to avoid this because it opens the door for confusion in connection with +-- ORDER BY: novices frequently put the ORDER BY in the wrong place. +-- See the fate of the single-argument form of string_agg() for history. +-- (Note: we don't forbid users from creating such aggregates; the policy is +-- just to think twice before creating built-in aggregates like this.) +-- The only aggregates that should show up here are count(x) and count(*). + +SELECT p1.oid::regprocedure, p2.oid::regprocedure +FROM pg_proc AS p1, pg_proc AS p2 +WHERE p1.oid < p2.oid AND p1.proname = p2.proname AND + p1.prokind = 'a' AND p2.prokind = 'a' AND + array_dims(p1.proargtypes) != array_dims(p2.proargtypes) +ORDER BY 1 +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="proname" +FILTER: schema="" table="p2" column="proname" +FILTER: schema="" table="p1" column="prokind" +FILTER: schema="" table="p2" column="prokind" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p2" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT p1.oid::regprocedure, p2.oid::regprocedure FROM pg_proc p1, pg_proc p2 WHERE ... ORDER BY 1" +== 101 +-- truncate_limit: 100 +-- For the same reason, built-in aggregates with default arguments are no good. + +SELECT oid, proname +FROM pg_proc AS p +WHERE prokind = 'a' AND proargdefaults IS NOT NULL +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p"="pg_proc" +FILTER: schema="" table="" column="prokind" +FILTER: schema="" table="" column="proargdefaults" +STMT: SelectStmt +TRUNCATED: "SELECT oid, proname FROM pg_proc p WHERE prokind = 'a' AND proargdefaults IS NOT NULL" +== 102 +-- truncate_limit: 100 +-- For the same reason, we avoid creating built-in variadic aggregates, except +-- that variadic ordered-set aggregates are OK (since they have special syntax +-- that is not subject to the misplaced ORDER BY issue). + +SELECT p.oid, proname +FROM pg_proc AS p JOIN pg_aggregate AS a ON a.aggfnoid = p.oid +WHERE prokind = 'a' AND provariadic != 0 AND a.aggkind = 'n' +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_aggregate" schema="" table="pg_aggregate" ctx=Select +ALIAS: "a"="pg_aggregate" +ALIAS: "p"="pg_proc" +FILTER: schema="" table="" column="prokind" +FILTER: schema="" table="" column="provariadic" +FILTER: schema="" table="a" column="aggkind" +STMT: SelectStmt +TRUNCATED: "SELECT p.oid, proname FROM pg_proc p JOIN pg_aggregate a ON a.aggfnoid = p.oid WHERE ..." +== 103 +-- truncate_limit: 100 +-- **************** pg_opfamily **************** + +-- Look for illegal values in pg_opfamily fields + +SELECT f.oid +FROM pg_opfamily as f +WHERE f.opfmethod = 0 OR f.opfnamespace = 0 +-- +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +ALIAS: "f"="pg_opfamily" +FILTER: schema="" table="f" column="opfmethod" +FILTER: schema="" table="f" column="opfnamespace" +STMT: SelectStmt +TRUNCATED: "SELECT f.oid FROM pg_opfamily f WHERE f.opfmethod = 0 OR f.opfnamespace = 0" +== 104 +-- truncate_limit: 100 +-- Look for opfamilies having no opclasses. While most validation of +-- opfamilies is now handled by AM-specific amvalidate functions, that's +-- driven from pg_opclass entries below, so an empty opfamily would not +-- get noticed. + +SELECT oid, opfname FROM pg_opfamily f +WHERE NOT EXISTS (SELECT 1 FROM pg_opclass WHERE opcfamily = f.oid) +-- +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +ALIAS: "f"="pg_opfamily" +FILTER: schema="" table="" column="opcfamily" +FILTER: schema="" table="f" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT oid, opfname FROM pg_opfamily f WHERE NOT EXISTS (SELECT 1 FROM pg_opclass WHERE ...)" +== 105 +-- truncate_limit: 100 +-- **************** pg_opclass **************** + +-- Look for illegal values in pg_opclass fields + +SELECT c1.oid +FROM pg_opclass AS c1 +WHERE c1.opcmethod = 0 OR c1.opcnamespace = 0 OR c1.opcfamily = 0 + OR c1.opcintype = 0 +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +ALIAS: "c1"="pg_opclass" +FILTER: schema="" table="c1" column="opcmethod" +FILTER: schema="" table="c1" column="opcnamespace" +FILTER: schema="" table="c1" column="opcfamily" +FILTER: schema="" table="c1" column="opcintype" +STMT: SelectStmt +TRUNCATED: "SELECT c1.oid FROM pg_opclass c1 WHERE ..." +== 106 +-- truncate_limit: 100 +-- opcmethod must match owning opfamily's opfmethod + +SELECT c1.oid, f1.oid +FROM pg_opclass AS c1, pg_opfamily AS f1 +WHERE c1.opcfamily = f1.oid AND c1.opcmethod != f1.opfmethod +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +ALIAS: "c1"="pg_opclass" +ALIAS: "f1"="pg_opfamily" +FILTER: schema="" table="c1" column="opcfamily" +FILTER: schema="" table="f1" column="oid" +FILTER: schema="" table="c1" column="opcmethod" +FILTER: schema="" table="f1" column="opfmethod" +STMT: SelectStmt +TRUNCATED: "SELECT c1.oid, f1.oid FROM pg_opclass c1, pg_opfamily f1 WHERE ..." +== 107 +-- truncate_limit: 100 +-- There should not be multiple entries in pg_opclass with opcdefault true +-- and the same opcmethod/opcintype combination. + +SELECT c1.oid, c2.oid +FROM pg_opclass AS c1, pg_opclass AS c2 +WHERE c1.oid != c2.oid AND + c1.opcmethod = c2.opcmethod AND c1.opcintype = c2.opcintype AND + c1.opcdefault AND c2.opcdefault +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +ALIAS: "c1"="pg_opclass" +ALIAS: "c2"="pg_opclass" +FILTER: schema="" table="c1" column="oid" +FILTER: schema="" table="c2" column="oid" +FILTER: schema="" table="c1" column="opcmethod" +FILTER: schema="" table="c2" column="opcmethod" +FILTER: schema="" table="c1" column="opcintype" +FILTER: schema="" table="c2" column="opcintype" +FILTER: schema="" table="c1" column="opcdefault" +FILTER: schema="" table="c2" column="opcdefault" +STMT: SelectStmt +TRUNCATED: "SELECT c1.oid, c2.oid FROM pg_opclass c1, pg_opclass c2 WHERE ..." +== 108 +-- truncate_limit: 100 +-- Ask access methods to validate opclasses +-- (this replaces a lot of SQL-level checks that used to be done in this file) + +SELECT oid, opcname FROM pg_opclass WHERE NOT amvalidate(oid) +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +FUNCTION: name="amvalidate" function="amvalidate" schema="" ctx=Call +FUNCTION: name="amvalidate" function="amvalidate" schema="" ctx=Call +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT oid, opcname FROM pg_opclass WHERE NOT amvalidate(oid)" +== 109 +-- truncate_limit: 100 +-- **************** pg_am **************** + +-- Look for illegal values in pg_am fields + +SELECT a1.oid, a1.amname +FROM pg_am AS a1 +WHERE a1.amhandler = 0 +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "a1"="pg_am" +FILTER: schema="" table="a1" column="amhandler" +STMT: SelectStmt +TRUNCATED: "SELECT a1.oid, a1.amname FROM pg_am a1 WHERE a1.amhandler = 0" +== 110 +-- truncate_limit: 100 +-- Check for index amhandler functions with the wrong signature + +SELECT a1.oid, a1.amname, p1.oid, p1.proname +FROM pg_am AS a1, pg_proc AS p1 +WHERE p1.oid = a1.amhandler AND a1.amtype = 'i' AND + (p1.prorettype != 'index_am_handler'::regtype + OR p1.proretset + OR p1.pronargs != 1 + OR p1.proargtypes[0] != 'internal'::regtype) +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_am" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amhandler" +FILTER: schema="" table="a1" column="amtype" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT a1.oid, a1.amname, p1.oid, p1.proname FROM pg_am a1, pg_proc p1 WHERE ..." +== 111 +-- truncate_limit: 100 +-- Check for table amhandler functions with the wrong signature + +SELECT a1.oid, a1.amname, p1.oid, p1.proname +FROM pg_am AS a1, pg_proc AS p1 +WHERE p1.oid = a1.amhandler AND a1.amtype = 't' AND + (p1.prorettype != 'table_am_handler'::regtype + OR p1.proretset + OR p1.pronargs != 1 + OR p1.proargtypes[0] != 'internal'::regtype) +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_am" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amhandler" +FILTER: schema="" table="a1" column="amtype" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT a1.oid, a1.amname, p1.oid, p1.proname FROM pg_am a1, pg_proc p1 WHERE ..." +== 112 +-- truncate_limit: 100 +-- **************** pg_amop **************** + +-- Look for illegal values in pg_amop fields + +SELECT a1.amopfamily, a1.amopstrategy +FROM pg_amop as a1 +WHERE a1.amopfamily = 0 OR a1.amoplefttype = 0 OR a1.amoprighttype = 0 + OR a1.amopopr = 0 OR a1.amopmethod = 0 OR a1.amopstrategy < 1 +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +ALIAS: "a1"="pg_amop" +FILTER: schema="" table="a1" column="amopfamily" +FILTER: schema="" table="a1" column="amoplefttype" +FILTER: schema="" table="a1" column="amoprighttype" +FILTER: schema="" table="a1" column="amopopr" +FILTER: schema="" table="a1" column="amopmethod" +FILTER: schema="" table="a1" column="amopstrategy" +STMT: SelectStmt +TRUNCATED: "SELECT a1.amopfamily, a1.amopstrategy FROM pg_amop a1 WHERE ..." +== 113 +-- truncate_limit: 100 +SELECT a1.amopfamily, a1.amopstrategy +FROM pg_amop as a1 +WHERE NOT ((a1.amoppurpose = 's' AND a1.amopsortfamily = 0) OR + (a1.amoppurpose = 'o' AND a1.amopsortfamily <> 0)) +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +ALIAS: "a1"="pg_amop" +FILTER: schema="" table="a1" column="amoppurpose" +FILTER: schema="" table="a1" column="amopsortfamily" +FILTER: schema="" table="a1" column="amoppurpose" +FILTER: schema="" table="a1" column="amopsortfamily" +STMT: SelectStmt +TRUNCATED: "SELECT a1.amopfamily, a1.amopstrategy FROM pg_amop a1 WHERE ..." +== 114 +-- truncate_limit: 100 +-- amopmethod must match owning opfamily's opfmethod + +SELECT a1.oid, f1.oid +FROM pg_amop AS a1, pg_opfamily AS f1 +WHERE a1.amopfamily = f1.oid AND a1.amopmethod != f1.opfmethod +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "f1"="pg_opfamily" +FILTER: schema="" table="a1" column="amopfamily" +FILTER: schema="" table="f1" column="oid" +FILTER: schema="" table="a1" column="amopmethod" +FILTER: schema="" table="f1" column="opfmethod" +STMT: SelectStmt +TRUNCATED: "SELECT a1.oid, f1.oid FROM pg_amop a1, pg_opfamily f1 WHERE ..." +== 115 +-- truncate_limit: 100 +-- Make a list of all the distinct operator names being used in particular +-- strategy slots. This is a bit hokey, since the list might need to change +-- in future releases, but it's an effective way of spotting mistakes such as +-- swapping two operators within a family. + +SELECT DISTINCT amopmethod, amopstrategy, oprname +FROM pg_amop a1 LEFT JOIN pg_operator o1 ON amopopr = o1.oid +ORDER BY 1, 2, 3 +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "o1"="pg_operator" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM pg_amop a1 LEFT JOIN pg_operator o1 ON amopopr = o1.oid ORDER BY ..." +== 116 +-- truncate_limit: 100 +-- Check that all opclass search operators have selectivity estimators. +-- This is not absolutely required, but it seems a reasonable thing +-- to insist on for all standard datatypes. + +SELECT a1.amopfamily, a1.amopopr, o1.oid, o1.oprname +FROM pg_amop AS a1, pg_operator AS o1 +WHERE a1.amopopr = o1.oid AND a1.amoppurpose = 's' AND + (o1.oprrest = 0 OR o1.oprjoin = 0) +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "o1"="pg_operator" +FILTER: schema="" table="a1" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="a1" column="amoppurpose" +FILTER: schema="" table="o1" column="oprrest" +FILTER: schema="" table="o1" column="oprjoin" +STMT: SelectStmt +TRUNCATED: "SELECT a1.amopfamily, a1.amopopr, o1.oid, o1.oprname FROM pg_amop a1, pg_operator o1 WHERE ..." +== 117 +-- truncate_limit: 100 +-- Check that each opclass in an opfamily has associated operators, that is +-- ones whose oprleft matches opcintype (possibly by coercion). + +SELECT c1.opcname, c1.opcfamily +FROM pg_opclass AS c1 +WHERE NOT EXISTS(SELECT 1 FROM pg_amop AS a1 + WHERE a1.amopfamily = c1.opcfamily + AND binary_coercible(c1.opcintype, a1.amoplefttype)) +-- +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "c1"="pg_opclass" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a1" column="amopfamily" +FILTER: schema="" table="c1" column="opcfamily" +FILTER: schema="" table="c1" column="opcintype" +FILTER: schema="" table="a1" column="amoplefttype" +STMT: SelectStmt +TRUNCATED: "SELECT c1.opcname, c1.opcfamily FROM pg_opclass c1 WHERE ..." +== 118 +-- truncate_limit: 100 +-- Check that each operator listed in pg_amop has an associated opclass, +-- that is one whose opcintype matches oprleft (possibly by coercion). +-- Otherwise the operator is useless because it cannot be matched to an index. +-- (In principle it could be useful to list such operators in multiple-datatype +-- btree opfamilies, but in practice you'd expect there to be an opclass for +-- every datatype the family knows about.) + +SELECT a1.amopfamily, a1.amopstrategy, a1.amopopr +FROM pg_amop AS a1 +WHERE NOT EXISTS(SELECT 1 FROM pg_opclass AS c1 + WHERE c1.opcfamily = a1.amopfamily + AND binary_coercible(c1.opcintype, a1.amoplefttype)) +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "c1"="pg_opclass" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="c1" column="opcfamily" +FILTER: schema="" table="a1" column="amopfamily" +FILTER: schema="" table="c1" column="opcintype" +FILTER: schema="" table="a1" column="amoplefttype" +STMT: SelectStmt +TRUNCATED: "SELECT a1.amopfamily, a1.amopstrategy, a1.amopopr FROM pg_amop a1 WHERE ..." +== 119 +-- truncate_limit: 100 +-- Operators that are primary members of opclasses must be immutable (else +-- it suggests that the index ordering isn't fixed). Operators that are +-- cross-type members need only be stable, since they are just shorthands +-- for index probe queries. + +SELECT a1.amopfamily, a1.amopopr, o1.oprname, p1.prosrc +FROM pg_amop AS a1, pg_operator AS o1, pg_proc AS p1 +WHERE a1.amopopr = o1.oid AND o1.oprcode = p1.oid AND + a1.amoplefttype = a1.amoprighttype AND + p1.provolatile != 'i' +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="a1" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amoplefttype" +FILTER: schema="" table="a1" column="amoprighttype" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_amop a1, pg_operator o1, pg_proc p1 WHERE ..." +== 120 +-- truncate_limit: 100 +SELECT a1.amopfamily, a1.amopopr, o1.oprname, p1.prosrc +FROM pg_amop AS a1, pg_operator AS o1, pg_proc AS p1 +WHERE a1.amopopr = o1.oid AND o1.oprcode = p1.oid AND + a1.amoplefttype != a1.amoprighttype AND + p1.provolatile = 'v' +-- +TABLE: name="pg_amop" schema="" table="pg_amop" ctx=Select +TABLE: name="pg_operator" schema="" table="pg_operator" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_amop" +ALIAS: "o1"="pg_operator" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="a1" column="amopopr" +FILTER: schema="" table="o1" column="oid" +FILTER: schema="" table="o1" column="oprcode" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amoplefttype" +FILTER: schema="" table="a1" column="amoprighttype" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_amop a1, pg_operator o1, pg_proc p1 WHERE ..." +== 121 +-- truncate_limit: 100 +-- **************** pg_amproc **************** + +-- Look for illegal values in pg_amproc fields + +SELECT a1.amprocfamily, a1.amprocnum +FROM pg_amproc as a1 +WHERE a1.amprocfamily = 0 OR a1.amproclefttype = 0 OR a1.amprocrighttype = 0 + OR a1.amprocnum < 0 OR a1.amproc = 0 +-- +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +ALIAS: "a1"="pg_amproc" +FILTER: schema="" table="a1" column="amprocfamily" +FILTER: schema="" table="a1" column="amproclefttype" +FILTER: schema="" table="a1" column="amprocrighttype" +FILTER: schema="" table="a1" column="amprocnum" +FILTER: schema="" table="a1" column="amproc" +STMT: SelectStmt +TRUNCATED: "SELECT a1.amprocfamily, a1.amprocnum FROM pg_amproc a1 WHERE ..." +== 122 +-- truncate_limit: 100 +-- Support routines that are primary members of opfamilies must be immutable +-- (else it suggests that the index ordering isn't fixed). But cross-type +-- members need only be stable, since they are just shorthands +-- for index probe queries. + +SELECT a1.amprocfamily, a1.amproc, p1.prosrc +FROM pg_amproc AS a1, pg_proc AS p1 +WHERE a1.amproc = p1.oid AND + a1.amproclefttype = a1.amprocrighttype AND + p1.provolatile != 'i' +-- +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_amproc" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="a1" column="amproc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amproclefttype" +FILTER: schema="" table="a1" column="amprocrighttype" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT a1.amprocfamily, a1.amproc, p1.prosrc FROM pg_amproc a1, pg_proc p1 WHERE ..." +== 123 +-- truncate_limit: 100 +SELECT a1.amprocfamily, a1.amproc, p1.prosrc +FROM pg_amproc AS a1, pg_proc AS p1 +WHERE a1.amproc = p1.oid AND + a1.amproclefttype != a1.amprocrighttype AND + p1.provolatile = 'v' +-- +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "a1"="pg_amproc" +ALIAS: "p1"="pg_proc" +FILTER: schema="" table="a1" column="amproc" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="a1" column="amproclefttype" +FILTER: schema="" table="a1" column="amprocrighttype" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT a1.amprocfamily, a1.amproc, p1.prosrc FROM pg_amproc a1, pg_proc p1 WHERE ..." +== 124 +-- truncate_limit: 100 +-- Almost all of the core distribution's Btree opclasses can use one of the +-- two generic "equalimage" functions as their support function 4. Look for +-- opclasses that don't allow deduplication unconditionally here. +|-- +-- Newly added Btree opclasses don't have to support deduplication. It will +-- usually be trivial to add support, though. Note that the expected output +-- of this part of the test will need to be updated when a new opclass cannot +-- support deduplication (by using btequalimage). +SELECT amp.amproc::regproc AS proc, opf.opfname AS opfamily_name, + opc.opcname AS opclass_name, opc.opcintype::regtype AS opcintype +FROM pg_am AS am +JOIN pg_opclass AS opc ON opc.opcmethod = am.oid +JOIN pg_opfamily AS opf ON opc.opcfamily = opf.oid +LEFT JOIN pg_amproc AS amp ON amp.amprocfamily = opf.oid AND + amp.amproclefttype = opc.opcintype AND amp.amprocnum = 4 +WHERE am.amname = 'btree' AND + amp.amproc IS DISTINCT FROM 'btequalimage'::regproc +ORDER BY 1, 2, 3 +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_opfamily" schema="" table="pg_opfamily" ctx=Select +TABLE: name="pg_amproc" schema="" table="pg_amproc" ctx=Select +ALIAS: "am"="pg_am" +ALIAS: "amp"="pg_amproc" +ALIAS: "opc"="pg_opclass" +ALIAS: "opf"="pg_opfamily" +FILTER: schema="" table="am" column="amname" +FILTER: schema="" table="amp" column="amproc" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_am am JOIN pg_opclass opc ON opc.opcmethod = am.oid JOIN pg_opfamily opf ON op..." +== 125 +-- truncate_limit: 100 +-- **************** pg_index **************** + +-- Look for illegal values in pg_index fields. + +SELECT indexrelid, indrelid +FROM pg_index +WHERE indexrelid = 0 OR indrelid = 0 OR + indnatts <= 0 OR indnatts > 32 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FILTER: schema="" table="" column="indexrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indnatts" +STMT: SelectStmt +TRUNCATED: "SELECT indexrelid, indrelid FROM pg_index WHERE ..." +== 126 +-- truncate_limit: 100 +-- oidvector and int2vector fields should be of length indnatts. + +SELECT indexrelid, indrelid +FROM pg_index +WHERE array_lower(indkey, 1) != 0 OR array_upper(indkey, 1) != indnatts-1 OR + array_lower(indclass, 1) != 0 OR array_upper(indclass, 1) != indnatts-1 OR + array_lower(indcollation, 1) != 0 OR array_upper(indcollation, 1) != indnatts-1 OR + array_lower(indoption, 1) != 0 OR array_upper(indoption, 1) != indnatts-1 +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_lower" function="array_lower" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FILTER: schema="" table="" column="indkey" +FILTER: schema="" table="" column="indkey" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indclass" +FILTER: schema="" table="" column="indclass" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indcollation" +FILTER: schema="" table="" column="indcollation" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indoption" +FILTER: schema="" table="" column="indoption" +FILTER: schema="" table="" column="indnatts" +STMT: SelectStmt +TRUNCATED: "SELECT indexrelid, indrelid FROM pg_index WHERE ..." +== 127 +-- truncate_limit: 100 +-- Check that opclasses and collations match the underlying columns. +-- (As written, this test ignores expression indexes.) + +SELECT indexrelid::regclass, indrelid::regclass, attname, atttypid::regtype, opcname +FROM (SELECT indexrelid, indrelid, unnest(indkey) as ikey, + unnest(indclass) as iclass, unnest(indcollation) as icoll + FROM pg_index) ss, + pg_attribute a, + pg_opclass opc +WHERE a.attrelid = indrelid AND a.attnum = ikey AND opc.oid = iclass AND + (NOT binary_coercible(atttypid, opcintype) OR icoll != attcollation) +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "opc"="pg_opclass" +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="binary_coercible" function="binary_coercible" schema="" ctx=Call +FILTER: schema="" table="a" column="attrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="a" column="attnum" +FILTER: schema="" table="" column="ikey" +FILTER: schema="" table="opc" column="oid" +FILTER: schema="" table="" column="iclass" +FILTER: schema="" table="" column="atttypid" +FILTER: schema="" table="" column="opcintype" +FILTER: schema="" table="" column="icoll" +FILTER: schema="" table="" column="attcollation" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM pg_index) ss, pg_attribute a, pg_opclass opc WHERE ..." +== 128 +-- truncate_limit: 100 +-- For system catalogs, be even tighter: nearly all indexes should be +-- exact type matches not binary-coercible matches. At this writing +-- the only exception is an OID index on a regproc column. + +SELECT indexrelid::regclass, indrelid::regclass, attname, atttypid::regtype, opcname +FROM (SELECT indexrelid, indrelid, unnest(indkey) as ikey, + unnest(indclass) as iclass, unnest(indcollation) as icoll + FROM pg_index + WHERE indrelid < 16384) ss, + pg_attribute a, + pg_opclass opc +WHERE a.attrelid = indrelid AND a.attnum = ikey AND opc.oid = iclass AND + (opcintype != atttypid OR icoll != attcollation) +ORDER BY 1 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "opc"="pg_opclass" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="a" column="attrelid" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="a" column="attnum" +FILTER: schema="" table="" column="ikey" +FILTER: schema="" table="opc" column="oid" +FILTER: schema="" table="" column="iclass" +FILTER: schema="" table="" column="opcintype" +FILTER: schema="" table="" column="atttypid" +FILTER: schema="" table="" column="icoll" +FILTER: schema="" table="" column="attcollation" +FILTER: schema="" table="" column="indrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM pg_index WHERE ...) ss, pg_attribute a, pg_opclass opc WHERE ......" +== 129 +-- truncate_limit: 100 +-- Check for system catalogs with collation-sensitive ordering. This is not +-- a representational error in pg_index, but simply wrong catalog design. +-- It's bad because we expect to be able to clone template0 and assign the +-- copy a different database collation. It would especially not work for +-- shared catalogs. + +SELECT relname, attname, attcollation +FROM pg_class c, pg_attribute a +WHERE c.oid = attrelid AND c.oid < 16384 AND + c.relkind != 'v' AND -- we don't care about columns in views + attcollation != 0 AND + attcollation != (SELECT oid FROM pg_collation WHERE collname = 'C') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="attrelid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="c" column="relkind" +FILTER: schema="" table="" column="attcollation" +FILTER: schema="" table="" column="attcollation" +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, attname, attcollation FROM pg_class c, pg_attribute a WHERE ..." +== 130 +-- truncate_limit: 100 +-- Double-check that collation-sensitive indexes have "C" collation, too. + +SELECT indexrelid::regclass, indrelid::regclass, iclass, icoll +FROM (SELECT indexrelid, indrelid, + unnest(indclass) as iclass, unnest(indcollation) as icoll + FROM pg_index + WHERE indrelid < 16384) ss +WHERE icoll != 0 AND + icoll != (SELECT oid FROM pg_collation WHERE collname = 'C') +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +TABLE: name="pg_collation" schema="" table="pg_collation" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="" column="icoll" +FILTER: schema="" table="" column="icoll" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="collname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM pg_index WHERE ...) ss WHERE ..." diff --git a/parser/testdata/summary_truncate/postgres_regress/partition_aggregate.metadata.json b/parser/testdata/summary_truncate/postgres_regress/partition_aggregate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/partition_aggregate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/partition_aggregate.test b/parser/testdata/summary_truncate/postgres_regress/partition_aggregate.test new file mode 100644 index 0000000..5f69390 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/partition_aggregate.test @@ -0,0 +1,1402 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PARTITION_AGGREGATE +-- Test partitionwise aggregation on partitioned tables +|-- +-- Note: to ensure plan stability, it's a good idea to make the partitions of +-- any one partitioned table in this test all have different numbers of rows. +|-- + +-- Enable partitionwise aggregate, which by default is disabled. +SET enable_partitionwise_aggregate TO true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_aggregate TO TRUE" +== 002 +-- truncate_limit: 100 +-- Enable partitionwise join, which by default is disabled. +SET enable_partitionwise_join TO true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_join TO TRUE" +== 003 +-- truncate_limit: 100 +-- Disable parallel plans. +SET max_parallel_workers_per_gather TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 0" +== 004 +-- truncate_limit: 100 +-- Disable incremental sort, which can influence selected plans due to fuzz factor. +SET enable_incremental_sort TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_incremental_sort TO OFF" +== 005 +-- truncate_limit: 100 +|-- +-- Tests for list partitioned tables. +|-- +CREATE TABLE pagg_tab (a int, b int, c text, d int) PARTITION BY LIST(c) +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab (a int, b int, c text, d int) PARTITION BY LIST (c)" +== 006 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_p1 PARTITION OF pagg_tab FOR VALUES IN ('0000', '0001', '0002', '0003', '0004') +-- +TABLE: name="pagg_tab_p1" schema="" table="pagg_tab_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_p1 PARTITION OF pagg_tab FOR VALUES IN ('0000', '0001', '0002', '0003', '00..." +== 007 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_p2 PARTITION OF pagg_tab FOR VALUES IN ('0005', '0006', '0007', '0008') +-- +TABLE: name="pagg_tab_p2" schema="" table="pagg_tab_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_p2 PARTITION OF pagg_tab FOR VALUES IN ('0005', '0006', '0007', '0008')" +== 008 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_p3 PARTITION OF pagg_tab FOR VALUES IN ('0009', '0010', '0011') +-- +TABLE: name="pagg_tab_p3" schema="" table="pagg_tab_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_p3 PARTITION OF pagg_tab FOR VALUES IN ('0009', '0010', '0011')" +== 009 +-- truncate_limit: 100 +INSERT INTO pagg_tab SELECT i % 20, i % 30, to_char(i % 12, 'FM0000'), i % 30 FROM generate_series(0, 2999) i +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pagg_tab SELECT ... FROM generate_series(0, 2999) i" +== 010 +-- truncate_limit: 100 +ANALYZE pagg_tab +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab" +== 011 +-- truncate_limit: 100 +-- When GROUP BY clause matches; full aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT c, sum(a), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY c HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c, sum(a), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY c H..." +== 012 +-- truncate_limit: 100 +SELECT c, sum(a), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY c HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab GROUP BY c HAVING avg(d) < 15 ORDER BY 1, 2, 3" +== 013 +-- truncate_limit: 100 +-- When GROUP BY clause does not match; partial aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY a HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY a H..." +== 014 +-- truncate_limit: 100 +SELECT a, sum(b), avg(b), count(*), min(a), max(b) FROM pagg_tab GROUP BY a HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab GROUP BY a HAVING avg(d) < 15 ORDER BY 1, 2, 3" +== 015 +-- truncate_limit: 100 +-- Check with multiple columns in GROUP BY +EXPLAIN (COSTS OFF) +SELECT a, c, count(*) FROM pagg_tab GROUP BY a, c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, c, count(*) FROM pagg_tab GROUP BY a, c" +== 016 +-- truncate_limit: 100 +-- Check with multiple columns in GROUP BY, order in GROUP BY is reversed +EXPLAIN (COSTS OFF) +SELECT a, c, count(*) FROM pagg_tab GROUP BY c, a +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, c, count(*) FROM pagg_tab GROUP BY c, a" +== 017 +-- truncate_limit: 100 +-- Check with multiple columns in GROUP BY, order in target-list is reversed +EXPLAIN (COSTS OFF) +SELECT c, a, count(*) FROM pagg_tab GROUP BY a, c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c, a, count(*) FROM pagg_tab GROUP BY a, c" +== 018 +-- truncate_limit: 100 +-- Test when input relation for grouping is dummy +EXPLAIN (COSTS OFF) +SELECT c, sum(a) FROM pagg_tab WHERE 1 = 2 GROUP BY c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c, sum(a) FROM pagg_tab WHERE 1 = 2 GROUP BY c" +== 019 +-- truncate_limit: 100 +SELECT c, sum(a) FROM pagg_tab WHERE 1 = 2 GROUP BY c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c, sum(a) FROM pagg_tab WHERE 1 = 2 GROUP BY c" +== 020 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT c, sum(a) FROM pagg_tab WHERE c = 'x' GROUP BY c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c, sum(a) FROM pagg_tab WHERE c = 'x' GROUP BY c" +== 021 +-- truncate_limit: 100 +SELECT c, sum(a) FROM pagg_tab WHERE c = 'x' GROUP BY c +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT c, sum(a) FROM pagg_tab WHERE c = 'x' GROUP BY c" +== 022 +-- truncate_limit: 100 +-- Test GroupAggregate paths by disabling hash aggregates. +SET enable_hashagg TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 023 +-- truncate_limit: 100 +-- When GROUP BY clause matches full aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT c, sum(a), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c, sum(a), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 1..." +== 024 +-- truncate_limit: 100 +SELECT c, sum(a), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c, sum(a), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3" +== 025 +-- truncate_limit: 100 +-- When GROUP BY clause does not match; partial aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 1..." +== 026 +-- truncate_limit: 100 +SELECT a, sum(b), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, sum(b), avg(b), count(*) FROM pagg_tab GROUP BY 1 HAVING avg(d) < 15 ORDER BY 1, 2, 3" +== 027 +-- truncate_limit: 100 +-- Test partitionwise grouping without any aggregates +EXPLAIN (COSTS OFF) +SELECT c FROM pagg_tab GROUP BY c ORDER BY 1 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c FROM pagg_tab GROUP BY c ORDER BY 1" +== 028 +-- truncate_limit: 100 +SELECT c FROM pagg_tab GROUP BY c ORDER BY 1 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT c FROM pagg_tab GROUP BY c ORDER BY 1" +== 029 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT a FROM pagg_tab WHERE a < 3 GROUP BY a ORDER BY 1 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a FROM pagg_tab WHERE a < 3 GROUP BY a ORDER BY 1" +== 030 +-- truncate_limit: 100 +SELECT a FROM pagg_tab WHERE a < 3 GROUP BY a ORDER BY 1 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM pagg_tab WHERE a < 3 GROUP BY a ORDER BY 1" +== 031 +-- truncate_limit: 100 +RESET enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 032 +-- truncate_limit: 100 +-- ROLLUP, partitionwise aggregation does not apply +EXPLAIN (COSTS OFF) +SELECT c, sum(a) FROM pagg_tab GROUP BY rollup(c) ORDER BY 1, 2 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c, sum(a) FROM pagg_tab GROUP BY ROLLUP (c) ORDER BY 1, 2" +== 033 +-- truncate_limit: 100 +-- ORDERED SET within the aggregate. +-- Full aggregation; since all the rows that belong to the same group come +-- from the same partition, having an ORDER BY within the aggregate doesn't +-- make any difference. +EXPLAIN (COSTS OFF) +SELECT c, sum(b order by a) FROM pagg_tab GROUP BY c ORDER BY 1, 2 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT c, sum(b ORDER BY a) FROM pagg_tab GROUP BY c ORDER BY 1, 2" +== 034 +-- truncate_limit: 100 +-- Since GROUP BY clause does not match with PARTITION KEY; we need to do +-- partial aggregation. However, ORDERED SET are not partial safe and thus +-- partitionwise aggregation plan is not generated. +EXPLAIN (COSTS OFF) +SELECT a, sum(b order by a) FROM pagg_tab GROUP BY a ORDER BY 1, 2 +-- +TABLE: name="pagg_tab" schema="" table="pagg_tab" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b ORDER BY a) FROM pagg_tab GROUP BY a ORDER BY 1, 2" +== 035 +-- truncate_limit: 100 +-- JOIN query + +CREATE TABLE pagg_tab1(x int, y int) PARTITION BY RANGE(x) +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab1 (x int, y int) PARTITION BY RANGE (x)" +== 036 +-- truncate_limit: 100 +CREATE TABLE pagg_tab1_p1 PARTITION OF pagg_tab1 FOR VALUES FROM (0) TO (10) +-- +TABLE: name="pagg_tab1_p1" schema="" table="pagg_tab1_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab1_p1 PARTITION OF pagg_tab1 FOR VALUES FROM (0) TO (10)" +== 037 +-- truncate_limit: 100 +CREATE TABLE pagg_tab1_p2 PARTITION OF pagg_tab1 FOR VALUES FROM (10) TO (20) +-- +TABLE: name="pagg_tab1_p2" schema="" table="pagg_tab1_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab1_p2 PARTITION OF pagg_tab1 FOR VALUES FROM (10) TO (20)" +== 038 +-- truncate_limit: 100 +CREATE TABLE pagg_tab1_p3 PARTITION OF pagg_tab1 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="pagg_tab1_p3" schema="" table="pagg_tab1_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab1_p3 PARTITION OF pagg_tab1 FOR VALUES FROM (20) TO (30)" +== 039 +-- truncate_limit: 100 +CREATE TABLE pagg_tab2(x int, y int) PARTITION BY RANGE(y) +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab2 (x int, y int) PARTITION BY RANGE (y)" +== 040 +-- truncate_limit: 100 +CREATE TABLE pagg_tab2_p1 PARTITION OF pagg_tab2 FOR VALUES FROM (0) TO (10) +-- +TABLE: name="pagg_tab2_p1" schema="" table="pagg_tab2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab2_p1 PARTITION OF pagg_tab2 FOR VALUES FROM (0) TO (10)" +== 041 +-- truncate_limit: 100 +CREATE TABLE pagg_tab2_p2 PARTITION OF pagg_tab2 FOR VALUES FROM (10) TO (20) +-- +TABLE: name="pagg_tab2_p2" schema="" table="pagg_tab2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab2_p2 PARTITION OF pagg_tab2 FOR VALUES FROM (10) TO (20)" +== 042 +-- truncate_limit: 100 +CREATE TABLE pagg_tab2_p3 PARTITION OF pagg_tab2 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="pagg_tab2_p3" schema="" table="pagg_tab2_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab2_p3 PARTITION OF pagg_tab2 FOR VALUES FROM (20) TO (30)" +== 043 +-- truncate_limit: 100 +INSERT INTO pagg_tab1 SELECT i % 30, i % 20 FROM generate_series(0, 299, 2) i +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pagg_tab1 SELECT i % 30, i % 20 FROM generate_series(0, 299, 2) i" +== 044 +-- truncate_limit: 100 +INSERT INTO pagg_tab2 SELECT i % 20, i % 30 FROM generate_series(0, 299, 3) i +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pagg_tab2 SELECT i % 20, i % 30 FROM generate_series(0, 299, 3) i" +== 045 +-- truncate_limit: 100 +ANALYZE pagg_tab1 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab1" +== 046 +-- truncate_limit: 100 +ANALYZE pagg_tab2 +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab2" +== 047 +-- truncate_limit: 100 +-- When GROUP BY clause matches; full aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT t1.x, sum(t1.y), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.x, sum(t1.y), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x =..." +== 048 +-- truncate_limit: 100 +SELECT t1.x, sum(t1.y), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3" +== 049 +-- truncate_limit: 100 +-- Check with whole-row reference; partitionwise aggregation does not apply +EXPLAIN (COSTS OFF) +SELECT t1.x, sum(t1.y), count(t1) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.x, sum(t1.y), count(t1) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x ..." +== 050 +-- truncate_limit: 100 +SELECT t1.x, sum(t1.y), count(t1) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.x ORDER BY 1, 2, 3" +== 051 +-- truncate_limit: 100 +-- GROUP BY having other matching key +EXPLAIN (COSTS OFF) +SELECT t2.y, sum(t1.y), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t2.y ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t2.y, sum(t1.y), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x =..." +== 052 +-- truncate_limit: 100 +-- When GROUP BY clause does not match; partial aggregation is performed for each partition. +-- Also test GroupAggregate paths by disabling hash aggregates. +SET enable_hashagg TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 053 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.y, sum(t1.x), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.y HAVING avg(t1.x) > 10 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.y, sum(t1.x), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x =..." +== 054 +-- truncate_limit: 100 +SELECT t1.y, sum(t1.x), count(*) FROM pagg_tab1 t1, pagg_tab2 t2 WHERE t1.x = t2.y GROUP BY t1.y HAVING avg(t1.x) > 10 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "t1"="pagg_tab1" +ALIAS: "t2"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="x" +FILTER: schema="" table="t2" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab1 t1, pagg_tab2 t2 WHERE ... GROUP BY t1.y HAVING avg(t1.x) > 10 ORDER BY..." +== 055 +-- truncate_limit: 100 +RESET enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 056 +-- truncate_limit: 100 +-- Check with LEFT/RIGHT/FULL OUTER JOINs which produces NULL values for +-- aggregation + +-- LEFT JOIN, should produce partial partitionwise aggregation plan as +-- GROUP BY is on nullable column +EXPLAIN (COSTS OFF) +SELECT b.y, sum(a.y) FROM pagg_tab1 a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b.y, sum(a.y) FROM pagg_tab1 a LEFT JOIN pagg_tab2 b ON a.x = b.y GROU..." +== 057 +-- truncate_limit: 100 +SELECT b.y, sum(a.y) FROM pagg_tab1 a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab1 a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST" +== 058 +-- truncate_limit: 100 +-- RIGHT JOIN, should produce full partitionwise aggregation plan as +-- GROUP BY is on non-nullable column +EXPLAIN (COSTS OFF) +SELECT b.y, sum(a.y) FROM pagg_tab1 a RIGHT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b.y, sum(a.y) FROM pagg_tab1 a RIGHT JOIN pagg_tab2 b ON a.x = b.y GRO..." +== 059 +-- truncate_limit: 100 +SELECT b.y, sum(a.y) FROM pagg_tab1 a RIGHT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab1 a RIGHT JOIN pagg_tab2 b ON a.x = b.y GROUP BY b.y ORDER BY 1 NULLS LAST" +== 060 +-- truncate_limit: 100 +-- FULL JOIN, should produce partial partitionwise aggregation plan as +-- GROUP BY is on nullable column +EXPLAIN (COSTS OFF) +SELECT a.x, sum(b.x) FROM pagg_tab1 a FULL OUTER JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.x, sum(b.x) FROM pagg_tab1 a FULL JOIN pagg_tab2 b ON a.x = b.y GROU..." +== 061 +-- truncate_limit: 100 +SELECT a.x, sum(b.x) FROM pagg_tab1 a FULL OUTER JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x ORDER BY 1 NULLS LAST +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +ALIAS: "a"="pagg_tab1" +ALIAS: "b"="pagg_tab2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab1 a FULL JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x ORDER BY 1 NULLS LAST" +== 062 +-- truncate_limit: 100 +-- LEFT JOIN, with dummy relation on right side, ideally +-- should produce full partitionwise aggregation plan as GROUP BY is on +-- non-nullable columns. +-- But right now we are unable to do partitionwise join in this case. +EXPLAIN (COSTS OFF) +SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a LEFT JOIN (SELECT * FROM pagg_tab2 WHERE y > 10) b ON a.x = b.y WHERE a.x > 5 or b.y < 20 GROUP BY a.x, b.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="x" +FILTER: schema="" table="b" column="y" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a LEFT ..." +== 063 +-- truncate_limit: 100 +SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a LEFT JOIN (SELECT * FROM pagg_tab2 WHERE y > 10) b ON a.x = b.y WHERE a.x > 5 or b.y < 20 GROUP BY a.x, b.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="x" +FILTER: schema="" table="b" column="y" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM pagg_tab1 WHERE ...) a LEFT JOIN (SELECT * FROM pagg_tab2 WHERE ....." +== 064 +-- truncate_limit: 100 +-- FULL JOIN, with dummy relations on both sides, ideally +-- should produce partial partitionwise aggregation plan as GROUP BY is on +-- nullable columns. +-- But right now we are unable to do partitionwise join in this case. +EXPLAIN (COSTS OFF) +SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a FULL JOIN (SELECT * FROM pagg_tab2 WHERE y > 10) b ON a.x = b.y WHERE a.x > 5 or b.y < 20 GROUP BY a.x, b.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="x" +FILTER: schema="" table="b" column="y" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a FULL ..." +== 065 +-- truncate_limit: 100 +SELECT a.x, b.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x < 20) a FULL JOIN (SELECT * FROM pagg_tab2 WHERE y > 10) b ON a.x = b.y WHERE a.x > 5 or b.y < 20 GROUP BY a.x, b.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="a" column="x" +FILTER: schema="" table="b" column="y" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM pagg_tab1 WHERE ...) a FULL JOIN (SELECT * FROM pagg_tab2 WHERE ....." +== 066 +-- truncate_limit: 100 +-- Empty join relation because of empty outer side, no partitionwise agg plan +EXPLAIN (COSTS OFF) +SELECT a.x, a.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x = 1 AND x = 2) a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x, a.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +ALIAS: "b"="pagg_tab2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a.x, a.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x = 1 AND x = 2..." +== 067 +-- truncate_limit: 100 +SELECT a.x, a.y, count(*) FROM (SELECT * FROM pagg_tab1 WHERE x = 1 AND x = 2) a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY a.x, a.y ORDER BY 1, 2 +-- +TABLE: name="pagg_tab2" schema="" table="pagg_tab2" ctx=Select +TABLE: name="pagg_tab1" schema="" table="pagg_tab1" ctx=Select +ALIAS: "b"="pagg_tab2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM pagg_tab1 WHERE ...) a LEFT JOIN pagg_tab2 b ON a.x = b.y GROUP BY..." +== 068 +-- truncate_limit: 100 +-- Partition by multiple columns + +CREATE TABLE pagg_tab_m (a int, b int, c int) PARTITION BY RANGE(a, ((a+b)/2)) +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_m (a int, b int, c int) PARTITION BY RANGE (a, ((a + b) / 2))" +== 069 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_m_p1 PARTITION OF pagg_tab_m FOR VALUES FROM (0, 0) TO (12, 12) +-- +TABLE: name="pagg_tab_m_p1" schema="" table="pagg_tab_m_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_m_p1 PARTITION OF pagg_tab_m FOR VALUES FROM (0, 0) TO (12, 12)" +== 070 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_m_p2 PARTITION OF pagg_tab_m FOR VALUES FROM (12, 12) TO (22, 22) +-- +TABLE: name="pagg_tab_m_p2" schema="" table="pagg_tab_m_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_m_p2 PARTITION OF pagg_tab_m FOR VALUES FROM (12, 12) TO (22, 22)" +== 071 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_m_p3 PARTITION OF pagg_tab_m FOR VALUES FROM (22, 22) TO (30, 30) +-- +TABLE: name="pagg_tab_m_p3" schema="" table="pagg_tab_m_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_m_p3 PARTITION OF pagg_tab_m FOR VALUES FROM (22, 22) TO (30, 30)" +== 072 +-- truncate_limit: 100 +INSERT INTO pagg_tab_m SELECT i % 30, i % 40, i % 50 FROM generate_series(0, 2999) i +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pagg_tab_m SELECT i % 30, i % 40, i % 50 FROM generate_series(0, 2999) i" +== 073 +-- truncate_limit: 100 +ANALYZE pagg_tab_m +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab_m" +== 074 +-- truncate_limit: 100 +-- Partial aggregation as GROUP BY clause does not match with PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a HAVING avg(c) < 22 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a HAVING avg(c) <..." +== 075 +-- truncate_limit: 100 +SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a HAVING avg(c) < 22 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a HAVING avg(c) < 22 ORDER BY 1, 2, 3" +== 076 +-- truncate_limit: 100 +-- Full aggregation as GROUP BY clause matches with PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a, (a+b)/2 HAVING sum(b) < 50 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a, (a + b) / 2 HA..." +== 077 +-- truncate_limit: 100 +SELECT a, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY a, (a+b)/2 HAVING sum(b) < 50 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab_m GROUP BY a, (a + b) / 2 HAVING sum(b) < 50 ORDER BY 1, 2, 3" +== 078 +-- truncate_limit: 100 +-- Full aggregation as PARTITION KEY is part of GROUP BY clause +EXPLAIN (COSTS OFF) +SELECT a, c, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY (a+b)/2, 2, 1 HAVING sum(b) = 50 AND avg(c) > 25 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, c, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY (a + b) / 2, 2..." +== 079 +-- truncate_limit: 100 +SELECT a, c, sum(b), avg(c), count(*) FROM pagg_tab_m GROUP BY (a+b)/2, 2, 1 HAVING sum(b) = 50 AND avg(c) > 25 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_m" schema="" table="pagg_tab_m" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab_m GROUP BY (a + b) / 2, 2, 1 HAVING sum(b) = 50 AND avg(c) > 25 ORDER BY..." +== 080 +-- truncate_limit: 100 +-- Test with multi-level partitioning scheme + +CREATE TABLE pagg_tab_ml (a int, b int, c text) PARTITION BY RANGE(a) +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_ml (a int, b int, c text) PARTITION BY RANGE (a)" +== 081 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_ml_p1 PARTITION OF pagg_tab_ml FOR VALUES FROM (0) TO (12) +-- +TABLE: name="pagg_tab_ml_p1" schema="" table="pagg_tab_ml_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_ml_p1 PARTITION OF pagg_tab_ml FOR VALUES FROM (0) TO (12)" +== 082 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_ml_p2 PARTITION OF pagg_tab_ml FOR VALUES FROM (12) TO (20) PARTITION BY LIST (c) +-- +TABLE: name="pagg_tab_ml_p2" schema="" table="pagg_tab_ml_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_ml_p2 PARTITION OF pagg_tab_ml FOR VALUES FROM (12) TO (20) PARTITION BY LI..." +== 083 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_ml_p2_s1 PARTITION OF pagg_tab_ml_p2 FOR VALUES IN ('0000', '0001', '0002') +-- +TABLE: name="pagg_tab_ml_p2_s1" schema="" table="pagg_tab_ml_p2_s1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_ml_p2_s1 PARTITION OF pagg_tab_ml_p2 FOR VALUES IN ('0000', '0001', '0002')" +== 084 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_ml_p2_s2 PARTITION OF pagg_tab_ml_p2 FOR VALUES IN ('0003') +-- +TABLE: name="pagg_tab_ml_p2_s2" schema="" table="pagg_tab_ml_p2_s2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_ml_p2_s2 PARTITION OF pagg_tab_ml_p2 FOR VALUES IN ('0003')" +== 085 +-- truncate_limit: 100 +-- This level of partitioning has different column positions than the parent +CREATE TABLE pagg_tab_ml_p3(b int, c text, a int) PARTITION BY RANGE (b) +-- +TABLE: name="pagg_tab_ml_p3" schema="" table="pagg_tab_ml_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_ml_p3 (b int, c text, a int) PARTITION BY RANGE (b)" +== 086 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_ml_p3_s1(c text, a int, b int) +-- +TABLE: name="pagg_tab_ml_p3_s1" schema="" table="pagg_tab_ml_p3_s1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_ml_p3_s1 (c text, a int, b int)" +== 087 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_ml_p3_s2 PARTITION OF pagg_tab_ml_p3 FOR VALUES FROM (7) TO (10) +-- +TABLE: name="pagg_tab_ml_p3_s2" schema="" table="pagg_tab_ml_p3_s2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_ml_p3_s2 PARTITION OF pagg_tab_ml_p3 FOR VALUES FROM (7) TO (10)" +== 088 +-- truncate_limit: 100 +ALTER TABLE pagg_tab_ml_p3 ATTACH PARTITION pagg_tab_ml_p3_s1 FOR VALUES FROM (0) TO (7) +-- +TABLE: name="pagg_tab_ml_p3" schema="" table="pagg_tab_ml_p3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pagg_tab_ml_p3 ATTACH PARTITION pagg_tab_ml_p3_s1 FOR VALUES FROM (0) TO (7)" +== 089 +-- truncate_limit: 100 +ALTER TABLE pagg_tab_ml ATTACH PARTITION pagg_tab_ml_p3 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pagg_tab_ml ATTACH PARTITION pagg_tab_ml_p3 FOR VALUES FROM (20) TO (30)" +== 090 +-- truncate_limit: 100 +INSERT INTO pagg_tab_ml SELECT i % 30, i % 10, to_char(i % 4, 'FM0000') FROM generate_series(0, 29999) i +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pagg_tab_ml SELECT ... FROM generate_series(0, 29999) i" +== 091 +-- truncate_limit: 100 +ANALYZE pagg_tab_ml +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab_ml" +== 092 +-- truncate_limit: 100 +-- For Parallel Append +SET max_parallel_workers_per_gather TO 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 093 +-- truncate_limit: 100 +SET parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 094 +-- truncate_limit: 100 +-- Full aggregation at level 1 as GROUP BY clause matches with PARTITION KEY +-- for level 1 only. For subpartitions, GROUP BY clause does not match with +-- PARTITION KEY, but still we do not see a partial aggregation as array_agg() +-- is not partial agg safe. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), array_agg(distinct c), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), array_agg(DISTINCT c), count(*) FROM pagg_tab_ml GROUP BY a..." +== 095 +-- truncate_limit: 100 +SELECT a, sum(b), array_agg(distinct c), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3" +== 096 +-- truncate_limit: 100 +-- Without ORDER BY clause, to test Gather at top-most path +EXPLAIN (COSTS OFF) +SELECT a, sum(b), array_agg(distinct c), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), array_agg(DISTINCT c), count(*) FROM pagg_tab_ml GROUP BY a..." +== 097 +-- truncate_limit: 100 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 098 +-- truncate_limit: 100 +-- Full aggregation at level 1 as GROUP BY clause matches with PARTITION KEY +-- for level 1 only. For subpartitions, GROUP BY clause does not match with +-- PARTITION KEY, thus we will have a partial aggregation for them. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDE..." +== 099 +-- truncate_limit: 100 +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3" +== 100 +-- truncate_limit: 100 +-- Partial aggregation at all levels as GROUP BY clause does not match with +-- PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b ORDER BY 1, 2, 3" +== 101 +-- truncate_limit: 100 +SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b HAVING avg(a) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b HAVING avg(a) < 15 ORDER BY 1, 2, 3" +== 102 +-- truncate_limit: 100 +-- Full aggregation at all levels as GROUP BY clause matches with PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > ..." +== 103 +-- truncate_limit: 100 +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3" +== 104 +-- truncate_limit: 100 +-- Parallelism within partitionwise aggregates + +SET min_parallel_table_scan_size TO '8kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO \"8kB\"" +== 105 +-- truncate_limit: 100 +SET parallel_setup_cost TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 106 +-- truncate_limit: 100 +-- Full aggregation at level 1 as GROUP BY clause matches with PARTITION KEY +-- for level 1 only. For subpartitions, GROUP BY clause does not match with +-- PARTITION KEY, thus we will have a partial aggregation for them. +EXPLAIN (COSTS OFF) +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDE..." +== 107 +-- truncate_limit: 100 +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a HAVING avg(b) < 3 ORDER BY 1, 2, 3" +== 108 +-- truncate_limit: 100 +-- Partial aggregation at all levels as GROUP BY clause does not match with +-- PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b ORDER BY 1, 2, 3" +== 109 +-- truncate_limit: 100 +SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b HAVING avg(a) < 15 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT b, sum(a), count(*) FROM pagg_tab_ml GROUP BY b HAVING avg(a) < 15 ORDER BY 1, 2, 3" +== 110 +-- truncate_limit: 100 +-- Full aggregation at all levels as GROUP BY clause matches with PARTITION KEY +EXPLAIN (COSTS OFF) +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > ..." +== 111 +-- truncate_limit: 100 +SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_ml" schema="" table="pagg_tab_ml" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, sum(b), count(*) FROM pagg_tab_ml GROUP BY a, b, c HAVING avg(b) > 7 ORDER BY 1, 2, 3" +== 112 +-- truncate_limit: 100 +-- Parallelism within partitionwise aggregates (single level) + +-- Add few parallel setup cost, so that we will see a plan which gathers +-- partially created paths even for full aggregation and sticks a single Gather +-- followed by finalization step. +-- Without this, the cost of doing partial aggregation + Gather + finalization +-- for each partition and then Append over it turns out to be same and this +-- wins as we add it first. This parallel_setup_cost plays a vital role in +-- costing such plans. +SET parallel_setup_cost TO 10 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 10" +== 113 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_para(x int, y int) PARTITION BY RANGE(x) +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_para (x int, y int) PARTITION BY RANGE (x)" +== 114 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_para_p1 PARTITION OF pagg_tab_para FOR VALUES FROM (0) TO (12) +-- +TABLE: name="pagg_tab_para_p1" schema="" table="pagg_tab_para_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_para_p1 PARTITION OF pagg_tab_para FOR VALUES FROM (0) TO (12)" +== 115 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_para_p2 PARTITION OF pagg_tab_para FOR VALUES FROM (12) TO (22) +-- +TABLE: name="pagg_tab_para_p2" schema="" table="pagg_tab_para_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_para_p2 PARTITION OF pagg_tab_para FOR VALUES FROM (12) TO (22)" +== 116 +-- truncate_limit: 100 +CREATE TABLE pagg_tab_para_p3 PARTITION OF pagg_tab_para FOR VALUES FROM (22) TO (30) +-- +TABLE: name="pagg_tab_para_p3" schema="" table="pagg_tab_para_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pagg_tab_para_p3 PARTITION OF pagg_tab_para FOR VALUES FROM (22) TO (30)" +== 117 +-- truncate_limit: 100 +INSERT INTO pagg_tab_para SELECT i % 30, i % 20 FROM generate_series(0, 29999) i +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pagg_tab_para SELECT i % 30, i % 20 FROM generate_series(0, 29999) i" +== 118 +-- truncate_limit: 100 +ANALYZE pagg_tab_para +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab_para" +== 119 +-- truncate_limit: 100 +-- When GROUP BY clause matches; full aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y..." +== 120 +-- truncate_limit: 100 +SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3" +== 121 +-- truncate_limit: 100 +-- When GROUP BY clause does not match; partial aggregation is performed for each partition. +EXPLAIN (COSTS OFF) +SELECT y, sum(x), avg(x), count(*) FROM pagg_tab_para GROUP BY y HAVING avg(x) < 12 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT y, sum(x), avg(x), count(*) FROM pagg_tab_para GROUP BY y HAVING avg(x..." +== 122 +-- truncate_limit: 100 +SELECT y, sum(x), avg(x), count(*) FROM pagg_tab_para GROUP BY y HAVING avg(x) < 12 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT y, sum(x), avg(x), count(*) FROM pagg_tab_para GROUP BY y HAVING avg(x) < 12 ORDER BY 1, 2, 3" +== 123 +-- truncate_limit: 100 +-- Test when parent can produce parallel paths but not any (or some) of its children +-- (Use one more aggregate to tilt the cost estimates for the plan we want) +ALTER TABLE pagg_tab_para_p1 SET (parallel_workers = 0) +-- +TABLE: name="pagg_tab_para_p1" schema="" table="pagg_tab_para_p1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pagg_tab_para_p1 SET (parallel_workers=0)" +== 124 +-- truncate_limit: 100 +ALTER TABLE pagg_tab_para_p3 SET (parallel_workers = 0) +-- +TABLE: name="pagg_tab_para_p3" schema="" table="pagg_tab_para_p3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pagg_tab_para_p3 SET (parallel_workers=0)" +== 125 +-- truncate_limit: 100 +ANALYZE pagg_tab_para +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab_para" +== 126 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT x, sum(y), avg(y), sum(x+y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x, sum(y), avg(y), sum(x + y), count(*) FROM pagg_tab_para GROUP BY x ..." +== 127 +-- truncate_limit: 100 +SELECT x, sum(y), avg(y), sum(x+y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3" +== 128 +-- truncate_limit: 100 +ALTER TABLE pagg_tab_para_p2 SET (parallel_workers = 0) +-- +TABLE: name="pagg_tab_para_p2" schema="" table="pagg_tab_para_p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pagg_tab_para_p2 SET (parallel_workers=0)" +== 129 +-- truncate_limit: 100 +ANALYZE pagg_tab_para +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pagg_tab_para" +== 130 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT x, sum(y), avg(y), sum(x+y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x, sum(y), avg(y), sum(x + y), count(*) FROM pagg_tab_para GROUP BY x ..." +== 131 +-- truncate_limit: 100 +SELECT x, sum(y), avg(y), sum(x+y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3" +== 132 +-- truncate_limit: 100 +-- Reset parallelism parameters to get partitionwise aggregation plan. +RESET min_parallel_table_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_table_scan_size" +== 133 +-- truncate_limit: 100 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 134 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y..." +== 135 +-- truncate_limit: 100 +SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3 +-- +TABLE: name="pagg_tab_para" schema="" table="pagg_tab_para" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, sum(y), avg(y), count(*) FROM pagg_tab_para GROUP BY x HAVING avg(y) < 7 ORDER BY 1, 2, 3" diff --git a/parser/testdata/summary_truncate/postgres_regress/partition_info.metadata.json b/parser/testdata/summary_truncate/postgres_regress/partition_info.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/partition_info.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/partition_info.test b/parser/testdata/summary_truncate/postgres_regress/partition_info.test new file mode 100644 index 0000000..fec655c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/partition_info.test @@ -0,0 +1,571 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for functions providing information about partitions +|-- +SELECT * FROM pg_partition_tree(NULL) +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_tree(NULL)" +== 002 +-- truncate_limit: 100 +SELECT * FROM pg_partition_tree(0) +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_tree(0)" +== 003 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors(NULL) +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors(NULL)" +== 004 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors(0) +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors(0)" +== 005 +-- truncate_limit: 100 +SELECT pg_partition_root(NULL) +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root(NULL)" +== 006 +-- truncate_limit: 100 +SELECT pg_partition_root(0) +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root(0)" +== 007 +-- truncate_limit: 100 +-- Test table partition trees +CREATE TABLE ptif_test (a int, b int) PARTITION BY range (a) +-- +TABLE: name="ptif_test" schema="" table="ptif_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_test (a int, b int) PARTITION BY RANGE (a)" +== 008 +-- truncate_limit: 100 +CREATE TABLE ptif_test0 PARTITION OF ptif_test + FOR VALUES FROM (minvalue) TO (0) PARTITION BY list (b) +-- +TABLE: name="ptif_test0" schema="" table="ptif_test0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_test0 PARTITION OF ptif_test FOR VALUES FROM (minvalue) TO (0) PARTITION BY LIS..." +== 009 +-- truncate_limit: 100 +CREATE TABLE ptif_test01 PARTITION OF ptif_test0 FOR VALUES IN (1) +-- +TABLE: name="ptif_test01" schema="" table="ptif_test01" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_test01 PARTITION OF ptif_test0 FOR VALUES IN (1)" +== 010 +-- truncate_limit: 100 +CREATE TABLE ptif_test1 PARTITION OF ptif_test + FOR VALUES FROM (0) TO (100) PARTITION BY list (b) +-- +TABLE: name="ptif_test1" schema="" table="ptif_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_test1 PARTITION OF ptif_test FOR VALUES FROM (0) TO (100) PARTITION BY LIST (b)" +== 011 +-- truncate_limit: 100 +CREATE TABLE ptif_test11 PARTITION OF ptif_test1 FOR VALUES IN (1) +-- +TABLE: name="ptif_test11" schema="" table="ptif_test11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_test11 PARTITION OF ptif_test1 FOR VALUES IN (1)" +== 012 +-- truncate_limit: 100 +CREATE TABLE ptif_test2 PARTITION OF ptif_test + FOR VALUES FROM (100) TO (200) +-- +TABLE: name="ptif_test2" schema="" table="ptif_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_test2 PARTITION OF ptif_test FOR VALUES FROM (100) TO (200)" +== 013 +-- truncate_limit: 100 +-- This partitioned table should remain with no partitions. +CREATE TABLE ptif_test3 PARTITION OF ptif_test + FOR VALUES FROM (200) TO (maxvalue) PARTITION BY list (b) +-- +TABLE: name="ptif_test3" schema="" table="ptif_test3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_test3 PARTITION OF ptif_test FOR VALUES FROM (200) TO (maxvalue) PARTITION BY L..." +== 014 +-- truncate_limit: 100 +-- Test pg_partition_root for tables +SELECT pg_partition_root('ptif_test') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test')" +== 015 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_test0') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test0')" +== 016 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_test01') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test01')" +== 017 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_test3') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test3')" +== 018 +-- truncate_limit: 100 +-- Test index partition tree +CREATE INDEX ptif_test_index ON ONLY ptif_test (a) +-- +TABLE: name="ptif_test" schema="" table="ptif_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ptif_test_index ON ONLY ptif_test USING btree (a)" +== 019 +-- truncate_limit: 100 +CREATE INDEX ptif_test0_index ON ONLY ptif_test0 (a) +-- +TABLE: name="ptif_test0" schema="" table="ptif_test0" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ptif_test0_index ON ONLY ptif_test0 USING btree (a)" +== 020 +-- truncate_limit: 100 +ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test0_index +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test0_index" +== 021 +-- truncate_limit: 100 +CREATE INDEX ptif_test01_index ON ptif_test01 (a) +-- +TABLE: name="ptif_test01" schema="" table="ptif_test01" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ptif_test01_index ON ptif_test01 USING btree (a)" +== 022 +-- truncate_limit: 100 +ALTER INDEX ptif_test0_index ATTACH PARTITION ptif_test01_index +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX ptif_test0_index ATTACH PARTITION ptif_test01_index" +== 023 +-- truncate_limit: 100 +CREATE INDEX ptif_test1_index ON ONLY ptif_test1 (a) +-- +TABLE: name="ptif_test1" schema="" table="ptif_test1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ptif_test1_index ON ONLY ptif_test1 USING btree (a)" +== 024 +-- truncate_limit: 100 +ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test1_index +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test1_index" +== 025 +-- truncate_limit: 100 +CREATE INDEX ptif_test11_index ON ptif_test11 (a) +-- +TABLE: name="ptif_test11" schema="" table="ptif_test11" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ptif_test11_index ON ptif_test11 USING btree (a)" +== 026 +-- truncate_limit: 100 +ALTER INDEX ptif_test1_index ATTACH PARTITION ptif_test11_index +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX ptif_test1_index ATTACH PARTITION ptif_test11_index" +== 027 +-- truncate_limit: 100 +CREATE INDEX ptif_test2_index ON ptif_test2 (a) +-- +TABLE: name="ptif_test2" schema="" table="ptif_test2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ptif_test2_index ON ptif_test2 USING btree (a)" +== 028 +-- truncate_limit: 100 +ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test2_index +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test2_index" +== 029 +-- truncate_limit: 100 +CREATE INDEX ptif_test3_index ON ptif_test3 (a) +-- +TABLE: name="ptif_test3" schema="" table="ptif_test3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ptif_test3_index ON ptif_test3 USING btree (a)" +== 030 +-- truncate_limit: 100 +ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test3_index +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX ptif_test_index ATTACH PARTITION ptif_test3_index" +== 031 +-- truncate_limit: 100 +-- Test pg_partition_root for indexes +SELECT pg_partition_root('ptif_test_index') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test_index')" +== 032 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_test0_index') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test0_index')" +== 033 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_test01_index') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test01_index')" +== 034 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_test3_index') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test3_index')" +== 035 +-- truncate_limit: 100 +-- List all tables members of the tree +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT relid, parentrelid, level, isleaf FROM pg_partition_tree('ptif_test')" +== 036 +-- truncate_limit: 100 +-- List tables from an intermediate level +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test0') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('ptif_test0') p JOIN pg_class c ON p.relid = c.oid" +== 037 +-- truncate_limit: 100 +-- List from leaf table +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test01') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('ptif_test01') p JOIN pg_class c ON p.relid = c.oid" +== 038 +-- truncate_limit: 100 +-- List from partitioned table with no partitions +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test3') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('ptif_test3') p JOIN pg_class c ON p.relid = c.oid" +== 039 +-- truncate_limit: 100 +-- List all ancestors of root and leaf tables +SELECT * FROM pg_partition_ancestors('ptif_test01') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_test01')" +== 040 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors('ptif_test') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_test')" +== 041 +-- truncate_limit: 100 +-- List all members using pg_partition_root with leaf table reference +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree(pg_partition_root('ptif_test01')) p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree(pg_partition_root('ptif_test01')) p JOIN pg_class c ON p.relid ..." +== 042 +-- truncate_limit: 100 +-- List all indexes members of the tree +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test_index') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT relid, parentrelid, level, isleaf FROM pg_partition_tree('ptif_test_index')" +== 043 +-- truncate_limit: 100 +-- List indexes from an intermediate level +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test0_index') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('ptif_test0_index') p JOIN pg_class c ON p.relid = c.oid" +== 044 +-- truncate_limit: 100 +-- List from leaf index +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test01_index') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('ptif_test01_index') p JOIN pg_class c ON p.relid = c.oid" +== 045 +-- truncate_limit: 100 +-- List from partitioned index with no partitions +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_test3_index') p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('ptif_test3_index') p JOIN pg_class c ON p.relid = c.oid" +== 046 +-- truncate_limit: 100 +-- List all members using pg_partition_root with leaf index reference +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree(pg_partition_root('ptif_test01_index')) p + JOIN pg_class c ON (p.relid = c.oid) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree(pg_partition_root('ptif_test01_index')) p JOIN pg_class c ON p...." +== 047 +-- truncate_limit: 100 +-- List all ancestors of root and leaf indexes +SELECT * FROM pg_partition_ancestors('ptif_test01_index') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_test01_index')" +== 048 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors('ptif_test_index') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_test_index')" +== 049 +-- truncate_limit: 100 +DROP TABLE ptif_test +-- +TABLE: name="ptif_test" schema="" table="ptif_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ptif_test" +== 050 +-- truncate_limit: 100 +-- Table that is not part of any partition tree is not listed. +CREATE TABLE ptif_normal_table(a int) +-- +TABLE: name="ptif_normal_table" schema="" table="ptif_normal_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_normal_table (a int)" +== 051 +-- truncate_limit: 100 +SELECT relid, parentrelid, level, isleaf + FROM pg_partition_tree('ptif_normal_table') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT relid, parentrelid, level, isleaf FROM pg_partition_tree('ptif_normal_table')" +== 052 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors('ptif_normal_table') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_normal_table')" +== 053 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_normal_table') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_normal_table')" +== 054 +-- truncate_limit: 100 +DROP TABLE ptif_normal_table +-- +TABLE: name="ptif_normal_table" schema="" table="ptif_normal_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ptif_normal_table" +== 055 +-- truncate_limit: 100 +-- Various partitioning-related functions return empty/NULL if passed relations +-- of types that cannot be part of a partition tree; for example, views, +-- materialized views, legacy inheritance children or parents, etc. +CREATE VIEW ptif_test_view AS SELECT 1 +-- +TABLE: name="ptif_test_view" schema="" table="ptif_test_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ptif_test_view AS SELECT 1" +== 056 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW ptif_test_matview AS SELECT 1 +-- +TABLE: name="ptif_test_matview" schema="" table="ptif_test_matview" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW ptif_test_matview AS SELECT 1" +== 057 +-- truncate_limit: 100 +CREATE TABLE ptif_li_parent () +-- +TABLE: name="ptif_li_parent" schema="" table="ptif_li_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_li_parent ()" +== 058 +-- truncate_limit: 100 +CREATE TABLE ptif_li_child () INHERITS (ptif_li_parent) +-- +TABLE: name="ptif_li_child" schema="" table="ptif_li_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ptif_li_child () INHERITS (ptif_li_parent)" +== 059 +-- truncate_limit: 100 +SELECT * FROM pg_partition_tree('ptif_test_view') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_tree('ptif_test_view')" +== 060 +-- truncate_limit: 100 +SELECT * FROM pg_partition_tree('ptif_test_matview') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_tree('ptif_test_matview')" +== 061 +-- truncate_limit: 100 +SELECT * FROM pg_partition_tree('ptif_li_parent') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_tree('ptif_li_parent')" +== 062 +-- truncate_limit: 100 +SELECT * FROM pg_partition_tree('ptif_li_child') +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_tree('ptif_li_child')" +== 063 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors('ptif_test_view') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_test_view')" +== 064 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors('ptif_test_matview') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_test_matview')" +== 065 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors('ptif_li_parent') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_li_parent')" +== 066 +-- truncate_limit: 100 +SELECT * FROM pg_partition_ancestors('ptif_li_child') +-- +FUNCTION: name="pg_partition_ancestors" function="pg_partition_ancestors" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_partition_ancestors('ptif_li_child')" +== 067 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_test_view') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test_view')" +== 068 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_test_matview') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_test_matview')" +== 069 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_li_parent') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_li_parent')" +== 070 +-- truncate_limit: 100 +SELECT pg_partition_root('ptif_li_child') +-- +FUNCTION: name="pg_partition_root" function="pg_partition_root" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_partition_root('ptif_li_child')" +== 071 +-- truncate_limit: 100 +DROP VIEW ptif_test_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW ptif_test_view" +== 072 +-- truncate_limit: 100 +DROP MATERIALIZED VIEW ptif_test_matview +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW ptif_test_matview" +== 073 +-- truncate_limit: 100 +DROP TABLE ptif_li_parent, ptif_li_child +-- +TABLE: name="ptif_li_parent" schema="" table="ptif_li_parent" ctx=DDL +TABLE: name="ptif_li_child" schema="" table="ptif_li_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ptif_li_parent, ptif_li_child" diff --git a/parser/testdata/summary_truncate/postgres_regress/partition_join.metadata.json b/parser/testdata/summary_truncate/postgres_regress/partition_join.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/partition_join.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/partition_join.test b/parser/testdata/summary_truncate/postgres_regress/partition_join.test new file mode 100644 index 0000000..4052a50 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/partition_join.test @@ -0,0 +1,6115 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PARTITION_JOIN +-- Test partitionwise join between partitioned tables +|-- + +-- Enable partitionwise join, which by default is disabled. +SET enable_partitionwise_join to true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_join TO TRUE" +== 002 +-- truncate_limit: 100 +|-- +-- partitioned by a single column +|-- +CREATE TABLE prt1 (a int, b int, c varchar) PARTITION BY RANGE(a) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1 (a int, b int, c varchar) PARTITION BY RANGE (a)" +== 003 +-- truncate_limit: 100 +CREATE TABLE prt1_p1 PARTITION OF prt1 FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt1_p1" schema="" table="prt1_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_p1 PARTITION OF prt1 FOR VALUES FROM (0) TO (250)" +== 004 +-- truncate_limit: 100 +CREATE TABLE prt1_p3 PARTITION OF prt1 FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt1_p3" schema="" table="prt1_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_p3 PARTITION OF prt1 FOR VALUES FROM (500) TO (600)" +== 005 +-- truncate_limit: 100 +CREATE TABLE prt1_p2 PARTITION OF prt1 FOR VALUES FROM (250) TO (500) +-- +TABLE: name="prt1_p2" schema="" table="prt1_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_p2 PARTITION OF prt1 FOR VALUES FROM (250) TO (500)" +== 006 +-- truncate_limit: 100 +INSERT INTO prt1 SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(0, 599) i WHERE i % 2 = 0 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt1 SELECT ... FROM generate_series(0, 599) i WHERE (i % 2) = 0" +== 007 +-- truncate_limit: 100 +CREATE INDEX iprt1_p1_a on prt1_p1(a) +-- +TABLE: name="prt1_p1" schema="" table="prt1_p1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt1_p1_a ON prt1_p1 USING btree (a)" +== 008 +-- truncate_limit: 100 +CREATE INDEX iprt1_p2_a on prt1_p2(a) +-- +TABLE: name="prt1_p2" schema="" table="prt1_p2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt1_p2_a ON prt1_p2 USING btree (a)" +== 009 +-- truncate_limit: 100 +CREATE INDEX iprt1_p3_a on prt1_p3(a) +-- +TABLE: name="prt1_p3" schema="" table="prt1_p3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt1_p3_a ON prt1_p3 USING btree (a)" +== 010 +-- truncate_limit: 100 +ANALYZE prt1 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1" +== 011 +-- truncate_limit: 100 +CREATE TABLE prt2 (a int, b int, c varchar) PARTITION BY RANGE(b) +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2 (a int, b int, c varchar) PARTITION BY RANGE (b)" +== 012 +-- truncate_limit: 100 +CREATE TABLE prt2_p1 PARTITION OF prt2 FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt2_p1" schema="" table="prt2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_p1 PARTITION OF prt2 FOR VALUES FROM (0) TO (250)" +== 013 +-- truncate_limit: 100 +CREATE TABLE prt2_p2 PARTITION OF prt2 FOR VALUES FROM (250) TO (500) +-- +TABLE: name="prt2_p2" schema="" table="prt2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_p2 PARTITION OF prt2 FOR VALUES FROM (250) TO (500)" +== 014 +-- truncate_limit: 100 +CREATE TABLE prt2_p3 PARTITION OF prt2 FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt2_p3" schema="" table="prt2_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_p3 PARTITION OF prt2 FOR VALUES FROM (500) TO (600)" +== 015 +-- truncate_limit: 100 +INSERT INTO prt2 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(0, 599) i WHERE i % 3 = 0 +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2 SELECT ... FROM generate_series(0, 599) i WHERE (i % 3) = 0" +== 016 +-- truncate_limit: 100 +CREATE INDEX iprt2_p1_b on prt2_p1(b) +-- +TABLE: name="prt2_p1" schema="" table="prt2_p1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt2_p1_b ON prt2_p1 USING btree (b)" +== 017 +-- truncate_limit: 100 +CREATE INDEX iprt2_p2_b on prt2_p2(b) +-- +TABLE: name="prt2_p2" schema="" table="prt2_p2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt2_p2_b ON prt2_p2 USING btree (b)" +== 018 +-- truncate_limit: 100 +CREATE INDEX iprt2_p3_b on prt2_p3(b) +-- +TABLE: name="prt2_p3" schema="" table="prt2_p3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt2_p3_b ON prt2_p3 USING btree (b)" +== 019 +-- truncate_limit: 100 +ANALYZE prt2 +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2" +== 020 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1...." +== 021 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE ... ORDER BY t1.a, t2.b" +== 022 +-- truncate_limit: 100 +-- left outer join, 3-way +EXPLAIN (COSTS OFF) +SELECT COUNT(*) FROM prt1 t1 + LEFT JOIN prt1 t2 ON t1.a = t2.a + LEFT JOIN prt1 t3 ON t2.a = t3.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM prt1 t1 LEFT JOIN prt1 t2 ON t1.a = t2.a LEFT JOIN prt1 ..." +== 023 +-- truncate_limit: 100 +SELECT COUNT(*) FROM prt1 t1 + LEFT JOIN prt1 t2 ON t1.a = t2.a + LEFT JOIN prt1 t3 ON t2.a = t3.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM prt1 t1 LEFT JOIN prt1 t2 ON t1.a = t2.a LEFT JOIN prt1 t3 ON t2.a = t3.a" +== 024 +-- truncate_limit: 100 +-- left outer join, with whole-row reference; partitionwise join does not apply +EXPLAIN (COSTS OFF) +SELECT t1, t2 FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1, t2 FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b WHERE t1.b = 0 OR..." +== 025 +-- truncate_limit: 100 +SELECT t1, t2 FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1, t2 FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b" +== 026 +-- truncate_limit: 100 +-- right outer join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b ..." +== 027 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t2" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1 t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b WHERE t2.a = 0 ORDER BY t1.a, t2.b" +== 028 +-- truncate_limit: 100 +-- full outer join, with placeholder vars +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 50 phv, * FROM prt1 WHERE prt1.b = 0) t1 FULL JOIN (SELECT 75 phv, * FROM prt2 WHERE prt2.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1" column="b" +FILTER: schema="" table="prt2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 50 AS phv, * FROM prt1 WHERE prt1...." +== 029 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 50 phv, * FROM prt1 WHERE prt1.b = 0) t1 FULL JOIN (SELECT 75 phv, * FROM prt2 WHERE prt2.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1" column="b" +FILTER: schema="" table="prt2" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM prt1 WHERE ...) t1 FULL JOIN (SELECT ... FROM prt2 WHERE ...) t2..." +== 030 +-- truncate_limit: 100 +-- Join with pruned partitions from joining relations +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.a < 450 AND t2.b > 250 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1...." +== 031 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.a < 450 AND t2.b > 250 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE ... ORDER BY t1.a, t2.b" +== 032 +-- truncate_limit: 100 +-- Currently we can't do partitioned join if nullable-side partitions are pruned +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT..." +== 033 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM prt1 WHERE ...) t1 LEFT JOIN (SELECT * FROM prt2 WHERE ...) t2 ON ..." +== 034 +-- truncate_limit: 100 +-- Currently we can't do partitioned join if nullable-side partitions are pruned +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 FULL JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 OR t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 FULL..." +== 035 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a < 450) t1 FULL JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 OR t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM prt1 WHERE ...) t1 FULL JOIN (SELECT * FROM prt2 WHERE ...) t2 ON ..." +== 036 +-- truncate_limit: 100 +-- Semi-join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t2.b FROM prt2 t2 WHERE t2.a = 0) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t2.b FROM prt2 t2 WHERE t2.a =..." +== 037 +-- truncate_limit: 100 +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t2.b FROM prt2 t2 WHERE t2.a = 0) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM prt1 t1 WHERE ... ORDER BY t1.a" +== 038 +-- truncate_limit: 100 +-- Anti-join with aggregates +EXPLAIN (COSTS OFF) +SELECT sum(t1.a), avg(t1.a), sum(t1.b), avg(t1.b) FROM prt1 t1 WHERE NOT EXISTS (SELECT 1 FROM prt2 t2 WHERE t1.a = t2.b) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(t1.a), avg(t1.a), sum(t1.b), avg(t1.b) FROM prt1 t1 WHERE NOT EXIS..." +== 039 +-- truncate_limit: 100 +SELECT sum(t1.a), avg(t1.a), sum(t1.b), avg(t1.b) FROM prt1 t1 WHERE NOT EXISTS (SELECT 1 FROM prt2 t2 WHERE t1.a = t2.b) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT sum(t1.a), avg(t1.a), sum(t1.b), avg(t1.b) FROM prt1 t1 WHERE ..." +== 040 +-- truncate_limit: 100 +-- lateral reference +EXPLAIN (COSTS OFF) +SELECT * FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t3.a AS t3a, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss + ON t1.a = ss.t2a WHERE t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM prt1 t1 LEFT JOIN LATERAL (SELECT t2.a AS t2a, t3.a AS t3a, LEA..." +== 041 +-- truncate_limit: 100 +SELECT * FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t3.a AS t3a, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss + ON t1.a = ss.t2a WHERE t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM prt1 t1 LEFT JOIN LATERAL (SELECT ... FROM prt1 t2 JOIN prt2 t3 ON t2.a = t3.b) ss ..." +== 042 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, ss.t2a, ss.t2c FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t3.a AS t3a, t2.b t2b, t2.c t2c, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss + ON t1.c = ss.t2c WHERE (t1.b + coalesce(ss.t2b, 0)) = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="ss" column="t2b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, ss.t2a, ss.t2c FROM prt1 t1 LEFT JOIN LATERAL (SELECT t2.a AS t2..." +== 043 +-- truncate_limit: 100 +SELECT t1.a, ss.t2a, ss.t2c FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t3.a AS t3a, t2.b t2b, t2.c t2c, least(t1.a,t2.a,t3.a) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss + ON t1.c = ss.t2c WHERE (t1.b + coalesce(ss.t2b, 0)) = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="ss" column="t2b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1 t1 LEFT JOIN LATERAL (SELECT ... FROM prt1 t2 JOIN prt2 t3 ON t2.a = t3.b) s..." +== 044 +-- truncate_limit: 100 +-- lateral reference in sample scan +EXPLAIN (COSTS OFF) +SELECT * FROM prt1 t1 JOIN LATERAL + (SELECT * FROM prt1 t2 TABLESAMPLE SYSTEM (t1.a) REPEATABLE(t1.b)) s + ON t1.a = s.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM prt1 t1 JOIN LATERAL (SELECT * FROM prt1 t2 TABLESAMPLE system(..." +== 045 +-- truncate_limit: 100 +-- lateral reference in scan's restriction clauses +EXPLAIN (COSTS OFF) +SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2 t2) s + ON t1.a = s.b WHERE s.t1b = s.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL (SELECT t1.b AS t1b, t2.* FROM..." +== 046 +-- truncate_limit: 100 +SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2 t2) s + ON t1.a = s.b WHERE s.t1b = s.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL (SELECT ... FROM prt2 t2) s ON t1.a = s.b WHERE ..." +== 047 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2 t2) s + ON t1.a = s.b WHERE s.t1b = s.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL (SELECT t1.b AS t1b, t2.* FROM..." +== 048 +-- truncate_limit: 100 +SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2 t2) s + ON t1.a = s.b WHERE s.t1b = s.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM prt1 t1 LEFT JOIN LATERAL (SELECT ... FROM prt2 t2) s ON t1.a = s.b WHERE ..." +== 049 +-- truncate_limit: 100 +-- bug with inadequate sort key representation +SET enable_partitionwise_aggregate TO true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_aggregate TO TRUE" +== 050 +-- truncate_limit: 100 +SET enable_hashjoin TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO FALSE" +== 051 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT a, b FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) + WHERE a BETWEEN 490 AND 510 + GROUP BY 1, 2 ORDER BY 1, 2 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "p2"="prt2" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b FROM prt1 FULL JOIN prt2 p2(b, a, c) USING (a, b) WHERE a BETWEEN..." +== 052 +-- truncate_limit: 100 +SELECT a, b FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) + WHERE a BETWEEN 490 AND 510 + GROUP BY 1, 2 ORDER BY 1, 2 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "p2"="prt2" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM prt1 FULL JOIN prt2 p2(b, a, c) USING (a, b) WHERE ... GROUP BY 1, 2 ORDER BY 1, 2" +== 053 +-- truncate_limit: 100 +RESET enable_partitionwise_aggregate +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_partitionwise_aggregate" +== 054 +-- truncate_limit: 100 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 055 +-- truncate_limit: 100 +-- bug in freeing the SpecialJoinInfo of a child-join +EXPLAIN (COSTS OFF) +SELECT * FROM prt1 t1 JOIN prt1 t2 ON t1.a = t2.a WHERE t1.a IN (SELECT a FROM prt1 t3) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt1" +ALIAS: "t3"="prt1" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM prt1 t1 JOIN prt1 t2 ON t1.a = t2.a WHERE t1.a IN (SELECT a FRO..." +== 056 +-- truncate_limit: 100 +|-- +-- partitioned by expression +|-- +CREATE TABLE prt1_e (a int, b int, c int) PARTITION BY RANGE(((a + b)/2)) +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_e (a int, b int, c int) PARTITION BY RANGE (((a + b) / 2))" +== 057 +-- truncate_limit: 100 +CREATE TABLE prt1_e_p1 PARTITION OF prt1_e FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt1_e_p1" schema="" table="prt1_e_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_e_p1 PARTITION OF prt1_e FOR VALUES FROM (0) TO (250)" +== 058 +-- truncate_limit: 100 +CREATE TABLE prt1_e_p2 PARTITION OF prt1_e FOR VALUES FROM (250) TO (500) +-- +TABLE: name="prt1_e_p2" schema="" table="prt1_e_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_e_p2 PARTITION OF prt1_e FOR VALUES FROM (250) TO (500)" +== 059 +-- truncate_limit: 100 +CREATE TABLE prt1_e_p3 PARTITION OF prt1_e FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt1_e_p3" schema="" table="prt1_e_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_e_p3 PARTITION OF prt1_e FOR VALUES FROM (500) TO (600)" +== 060 +-- truncate_limit: 100 +INSERT INTO prt1_e SELECT i, i, i % 25 FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt1_e SELECT i, i, i % 25 FROM generate_series(0, 599, 2) i" +== 061 +-- truncate_limit: 100 +CREATE INDEX iprt1_e_p1_ab2 on prt1_e_p1(((a+b)/2)) +-- +TABLE: name="prt1_e_p1" schema="" table="prt1_e_p1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt1_e_p1_ab2 ON prt1_e_p1 USING btree (((a + b) / 2))" +== 062 +-- truncate_limit: 100 +CREATE INDEX iprt1_e_p2_ab2 on prt1_e_p2(((a+b)/2)) +-- +TABLE: name="prt1_e_p2" schema="" table="prt1_e_p2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt1_e_p2_ab2 ON prt1_e_p2 USING btree (((a + b) / 2))" +== 063 +-- truncate_limit: 100 +CREATE INDEX iprt1_e_p3_ab2 on prt1_e_p3(((a+b)/2)) +-- +TABLE: name="prt1_e_p3" schema="" table="prt1_e_p3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX iprt1_e_p3_ab2 ON prt1_e_p3 USING btree (((a + b) / 2))" +== 064 +-- truncate_limit: 100 +ANALYZE prt1_e +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_e" +== 065 +-- truncate_limit: 100 +CREATE TABLE prt2_e (a int, b int, c int) PARTITION BY RANGE(((b + a)/2)) +-- +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_e (a int, b int, c int) PARTITION BY RANGE (((b + a) / 2))" +== 066 +-- truncate_limit: 100 +CREATE TABLE prt2_e_p1 PARTITION OF prt2_e FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt2_e_p1" schema="" table="prt2_e_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_e_p1 PARTITION OF prt2_e FOR VALUES FROM (0) TO (250)" +== 067 +-- truncate_limit: 100 +CREATE TABLE prt2_e_p2 PARTITION OF prt2_e FOR VALUES FROM (250) TO (500) +-- +TABLE: name="prt2_e_p2" schema="" table="prt2_e_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_e_p2 PARTITION OF prt2_e FOR VALUES FROM (250) TO (500)" +== 068 +-- truncate_limit: 100 +CREATE TABLE prt2_e_p3 PARTITION OF prt2_e FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt2_e_p3" schema="" table="prt2_e_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_e_p3 PARTITION OF prt2_e FOR VALUES FROM (500) TO (600)" +== 069 +-- truncate_limit: 100 +INSERT INTO prt2_e SELECT i, i, i % 25 FROM generate_series(0, 599, 3) i +-- +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_e SELECT i, i, i % 25 FROM generate_series(0, 599, 3) i" +== 070 +-- truncate_limit: 100 +ANALYZE prt2_e +-- +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_e" +== 071 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_e t1, prt2_e t2 WHERE (t1.a + t1.b)/2 = (t2.b + t2.a)/2 AND t1.c = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=Select +ALIAS: "t1"="prt1_e" +ALIAS: "t2"="prt2_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_e t1, prt2_e t2 WHERE ((t1.a + t1.b) ..." +== 072 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_e t1, prt2_e t2 WHERE (t1.a + t1.b)/2 = (t2.b + t2.a)/2 AND t1.c = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +TABLE: name="prt2_e" schema="" table="prt2_e" ctx=Select +ALIAS: "t1"="prt1_e" +ALIAS: "t2"="prt2_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_e t1, prt2_e t2 WHERE ... ORDER BY t1.a, t2.b" +== 073 +-- truncate_limit: 100 +|-- +-- N-way join +|-- +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_e t3 WHERE t1.a = t2.b AND t1.a = (t3.a + t3.b)/2 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t3" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_..." +== 074 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_e t3 WHERE t1.a = t2.b AND t1.a = (t3.a + t3.b)/2 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t3" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1 t1, prt2 t2, prt1_e t3 WHERE ... ORDER BY t1.a, t2.b" +== 075 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) LEFT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t1.b = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1 LEFT JOIN prt2 ..." +== 076 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) LEFT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t1.b = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b LEFT JOIN prt1_e t3 ON t1.a = ((t3.a + t..." +== 077 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t3" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1 LEFT JOIN prt2 ..." +== 078 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t3" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b RIGHT JOIN prt1_e t3 ON t1.a = ((t3.a + ..." +== 079 +-- truncate_limit: 100 +|-- +-- 3-way full join +|-- +EXPLAIN (COSTS OFF) +SELECT COUNT(*) FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) FULL JOIN prt2 p3(b,a,c) USING (a, b) + WHERE a BETWEEN 490 AND 510 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "p2"="prt2" +ALIAS: "p3"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM prt1 FULL JOIN prt2 p2(b, a, c) USING (a, b) FULL JOIN p..." +== 080 +-- truncate_limit: 100 +SELECT COUNT(*) FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) FULL JOIN prt2 p3(b,a,c) USING (a, b) + WHERE a BETWEEN 490 AND 510 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "p2"="prt2" +ALIAS: "p3"="prt2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1 FULL JOIN prt2 p2(b, a, c) USING (a, b) FULL JOIN prt2 p3(b, a, c) USING (a,..." +== 081 +-- truncate_limit: 100 +|-- +-- 4-way full join +|-- +EXPLAIN (COSTS OFF) +SELECT COUNT(*) FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) FULL JOIN prt2 p3(b,a,c) USING (a, b) FULL JOIN prt1 p4 (a,b,c) USING (a, b) + WHERE a BETWEEN 490 AND 510 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "p2"="prt2" +ALIAS: "p3"="prt2" +ALIAS: "p4"="prt1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM prt1 FULL JOIN prt2 p2(b, a, c) USING (a, b) FULL JOIN p..." +== 082 +-- truncate_limit: 100 +SELECT COUNT(*) FROM prt1 FULL JOIN prt2 p2(b,a,c) USING(a,b) FULL JOIN prt2 p3(b,a,c) USING (a, b) FULL JOIN prt1 p4 (a,b,c) USING (a, b) + WHERE a BETWEEN 490 AND 510 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "p2"="prt2" +ALIAS: "p3"="prt2" +ALIAS: "p4"="prt1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1 FULL JOIN prt2 p2(b, a, c) USING (a, b) FULL JOIN prt2 p3(b, a, c) USING (a,..." +== 083 +-- truncate_limit: 100 +-- Cases with non-nullable expressions in subquery results; +-- make sure these go to null as expected +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.phv, t2.b, t2.phv, t3.a + t3.b, t3.phv FROM ((SELECT 50 phv, * FROM prt1 WHERE prt1.b = 0) t1 FULL JOIN (SELECT 75 phv, * FROM prt2 WHERE prt2.a = 0) t2 ON (t1.a = t2.b)) FULL JOIN (SELECT 50 phv, * FROM prt1_e WHERE prt1_e.c = 0) t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t1.a = t1.phv OR t2.b = t2.phv OR (t3.a + t3.b)/2 = t3.phv ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t3" column="b" +FILTER: schema="" table="t3" column="phv" +FILTER: schema="" table="prt1" column="b" +FILTER: schema="" table="prt2" column="a" +FILTER: schema="" table="prt1_e" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.phv, t2.b, t2.phv, t3.a + t3.b, t3.phv FROM (SELECT 50 AS phv..." +== 084 +-- truncate_limit: 100 +SELECT t1.a, t1.phv, t2.b, t2.phv, t3.a + t3.b, t3.phv FROM ((SELECT 50 phv, * FROM prt1 WHERE prt1.b = 0) t1 FULL JOIN (SELECT 75 phv, * FROM prt2 WHERE prt2.a = 0) t2 ON (t1.a = t2.b)) FULL JOIN (SELECT 50 phv, * FROM prt1_e WHERE prt1_e.c = 0) t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t1.a = t1.phv OR t2.b = t2.phv OR (t3.a + t3.b)/2 = t3.phv ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="t3" column="b" +FILTER: schema="" table="t3" column="phv" +FILTER: schema="" table="prt1" column="b" +FILTER: schema="" table="prt2" column="a" +FILTER: schema="" table="prt1_e" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM prt1 WHERE ...) t1 FULL JOIN (SELECT ... FROM prt2 WHERE ...) t2..." +== 085 +-- truncate_limit: 100 +-- Semi-join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 WHERE t1.a = 0 AND t1.b = (t2.a + t2.b)/2) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt2" +ALIAS: "t2"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 W..." +== 086 +-- truncate_limit: 100 +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 WHERE t1.a = 0 AND t1.b = (t2.a + t2.b)/2) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt2" +ALIAS: "t2"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM prt1 t1 WHERE ... ORDER BY t1.a" +== 087 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b I..." +== 088 +-- truncate_limit: 100 +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM prt1 t1 WHERE ... ORDER BY t1.a" +== 089 +-- truncate_limit: 100 +-- test merge joins +SET enable_hashjoin TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 090 +-- truncate_limit: 100 +SET enable_nestloop TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 091 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b I..." +== 092 +-- truncate_limit: 100 +SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1_e" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM prt1 t1 WHERE ... ORDER BY t1.a" +== 093 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t3" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1 LEFT JOIN prt2 ..." +== 094 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1_e" schema="" table="prt1_e" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1_e" +FILTER: schema="" table="t3" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b RIGHT JOIN prt1_e t3 ON t1.a = ((t3.a + ..." +== 095 +-- truncate_limit: 100 +-- MergeAppend on nullable column +-- This should generate a partitionwise join, but currently fails to +EXPLAIN (COSTS OFF) +SELECT t1.a, t2.b FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t2.b FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELEC..." +== 096 +-- truncate_limit: 100 +SELECT t1.a, t2.b FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM prt1 WHERE ...) t1 LEFT JOIN (SELECT * FROM prt2 WHERE ...) t2 ON ..." +== 097 +-- truncate_limit: 100 +-- merge join when expression with whole-row reference needs to be sorted; +-- partitionwise join does not apply +EXPLAIN (COSTS OFF) +SELECT t1.a, t2.b FROM prt1 t1, prt2 t2 WHERE t1::text = t2::text AND t1.a = t2.b ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="" column="t1" +FILTER: schema="" table="" column="t2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t2.b FROM prt1 t1, prt2 t2 WHERE t1::text = t2::text AND t1.a = ..." +== 098 +-- truncate_limit: 100 +SELECT t1.a, t2.b FROM prt1 t1, prt2 t2 WHERE t1::text = t2::text AND t1.a = t2.b ORDER BY t1.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="" column="t1" +FILTER: schema="" table="" column="t2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.a, t2.b FROM prt1 t1, prt2 t2 WHERE t1::text = t2::text AND t1.a = t2.b ORDER BY t1.a" +== 099 +-- truncate_limit: 100 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 100 +-- truncate_limit: 100 +RESET enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 101 +-- truncate_limit: 100 +|-- +-- partitioned by multiple columns +|-- +CREATE TABLE prt1_m (a int, b int, c int) PARTITION BY RANGE(a, ((a + b)/2)) +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_m (a int, b int, c int) PARTITION BY RANGE (a, ((a + b) / 2))" +== 102 +-- truncate_limit: 100 +CREATE TABLE prt1_m_p1 PARTITION OF prt1_m FOR VALUES FROM (0, 0) TO (250, 250) +-- +TABLE: name="prt1_m_p1" schema="" table="prt1_m_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_m_p1 PARTITION OF prt1_m FOR VALUES FROM (0, 0) TO (250, 250)" +== 103 +-- truncate_limit: 100 +CREATE TABLE prt1_m_p2 PARTITION OF prt1_m FOR VALUES FROM (250, 250) TO (500, 500) +-- +TABLE: name="prt1_m_p2" schema="" table="prt1_m_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_m_p2 PARTITION OF prt1_m FOR VALUES FROM (250, 250) TO (500, 500)" +== 104 +-- truncate_limit: 100 +CREATE TABLE prt1_m_p3 PARTITION OF prt1_m FOR VALUES FROM (500, 500) TO (600, 600) +-- +TABLE: name="prt1_m_p3" schema="" table="prt1_m_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_m_p3 PARTITION OF prt1_m FOR VALUES FROM (500, 500) TO (600, 600)" +== 105 +-- truncate_limit: 100 +INSERT INTO prt1_m SELECT i, i, i % 25 FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt1_m SELECT i, i, i % 25 FROM generate_series(0, 599, 2) i" +== 106 +-- truncate_limit: 100 +ANALYZE prt1_m +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_m" +== 107 +-- truncate_limit: 100 +CREATE TABLE prt2_m (a int, b int, c int) PARTITION BY RANGE(((b + a)/2), b) +-- +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_m (a int, b int, c int) PARTITION BY RANGE (((b + a) / 2), b)" +== 108 +-- truncate_limit: 100 +CREATE TABLE prt2_m_p1 PARTITION OF prt2_m FOR VALUES FROM (0, 0) TO (250, 250) +-- +TABLE: name="prt2_m_p1" schema="" table="prt2_m_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_m_p1 PARTITION OF prt2_m FOR VALUES FROM (0, 0) TO (250, 250)" +== 109 +-- truncate_limit: 100 +CREATE TABLE prt2_m_p2 PARTITION OF prt2_m FOR VALUES FROM (250, 250) TO (500, 500) +-- +TABLE: name="prt2_m_p2" schema="" table="prt2_m_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_m_p2 PARTITION OF prt2_m FOR VALUES FROM (250, 250) TO (500, 500)" +== 110 +-- truncate_limit: 100 +CREATE TABLE prt2_m_p3 PARTITION OF prt2_m FOR VALUES FROM (500, 500) TO (600, 600) +-- +TABLE: name="prt2_m_p3" schema="" table="prt2_m_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_m_p3 PARTITION OF prt2_m FOR VALUES FROM (500, 500) TO (600, 600)" +== 111 +-- truncate_limit: 100 +INSERT INTO prt2_m SELECT i, i, i % 25 FROM generate_series(0, 599, 3) i +-- +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_m SELECT i, i, i % 25 FROM generate_series(0, 599, 3) i" +== 112 +-- truncate_limit: 100 +ANALYZE prt2_m +-- +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_m" +== 113 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_m WHERE prt1_m.c = 0) t1 FULL JOIN (SELECT * FROM prt2_m WHERE prt2_m.c = 0) t2 ON (t1.a = (t2.b + t2.a)/2 AND t2.b = (t1.a + t1.b)/2) ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +FILTER: schema="" table="prt1_m" column="c" +FILTER: schema="" table="prt2_m" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_m WHERE prt1_m.c = 0) ..." +== 114 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_m WHERE prt1_m.c = 0) t1 FULL JOIN (SELECT * FROM prt2_m WHERE prt2_m.c = 0) t2 ON (t1.a = (t2.b + t2.a)/2 AND t2.b = (t1.a + t1.b)/2) ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +FILTER: schema="" table="prt1_m" column="c" +FILTER: schema="" table="prt2_m" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM prt1_m WHERE ...) t1 FULL JOIN (SELECT * FROM prt2_m WHERE ...) t2..." +== 115 +-- truncate_limit: 100 +|-- +-- tests for list partitioned tables. +|-- +CREATE TABLE plt1 (a int, b int, c text) PARTITION BY LIST(c) +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1 (a int, b int, c text) PARTITION BY LIST (c)" +== 116 +-- truncate_limit: 100 +CREATE TABLE plt1_p1 PARTITION OF plt1 FOR VALUES IN ('0000', '0003', '0004', '0010') +-- +TABLE: name="plt1_p1" schema="" table="plt1_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_p1 PARTITION OF plt1 FOR VALUES IN ('0000', '0003', '0004', '0010')" +== 117 +-- truncate_limit: 100 +CREATE TABLE plt1_p2 PARTITION OF plt1 FOR VALUES IN ('0001', '0005', '0002', '0009') +-- +TABLE: name="plt1_p2" schema="" table="plt1_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_p2 PARTITION OF plt1 FOR VALUES IN ('0001', '0005', '0002', '0009')" +== 118 +-- truncate_limit: 100 +CREATE TABLE plt1_p3 PARTITION OF plt1 FOR VALUES IN ('0006', '0007', '0008', '0011') +-- +TABLE: name="plt1_p3" schema="" table="plt1_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_p3 PARTITION OF plt1 FOR VALUES IN ('0006', '0007', '0008', '0011')" +== 119 +-- truncate_limit: 100 +INSERT INTO plt1 SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1 SELECT i, i, to_char(i / 50, 'FM0000') FROM generate_series(0, 599, 2) i" +== 120 +-- truncate_limit: 100 +ANALYZE plt1 +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1" +== 121 +-- truncate_limit: 100 +CREATE TABLE plt2 (a int, b int, c text) PARTITION BY LIST(c) +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2 (a int, b int, c text) PARTITION BY LIST (c)" +== 122 +-- truncate_limit: 100 +CREATE TABLE plt2_p1 PARTITION OF plt2 FOR VALUES IN ('0000', '0003', '0004', '0010') +-- +TABLE: name="plt2_p1" schema="" table="plt2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_p1 PARTITION OF plt2 FOR VALUES IN ('0000', '0003', '0004', '0010')" +== 123 +-- truncate_limit: 100 +CREATE TABLE plt2_p2 PARTITION OF plt2 FOR VALUES IN ('0001', '0005', '0002', '0009') +-- +TABLE: name="plt2_p2" schema="" table="plt2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_p2 PARTITION OF plt2 FOR VALUES IN ('0001', '0005', '0002', '0009')" +== 124 +-- truncate_limit: 100 +CREATE TABLE plt2_p3 PARTITION OF plt2 FOR VALUES IN ('0006', '0007', '0008', '0011') +-- +TABLE: name="plt2_p3" schema="" table="plt2_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_p3 PARTITION OF plt2 FOR VALUES IN ('0006', '0007', '0008', '0011')" +== 125 +-- truncate_limit: 100 +INSERT INTO plt2 SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 3) i +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2 SELECT i, i, to_char(i / 50, 'FM0000') FROM generate_series(0, 599, 3) i" +== 126 +-- truncate_limit: 100 +ANALYZE plt2 +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2" +== 127 +-- truncate_limit: 100 +|-- +-- list partitioned by expression +|-- +CREATE TABLE plt1_e (a int, b int, c text) PARTITION BY LIST(ltrim(c, 'A')) +-- +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_e (a int, b int, c text) PARTITION BY LIST ((ltrim(c, 'A')))" +== 128 +-- truncate_limit: 100 +CREATE TABLE plt1_e_p1 PARTITION OF plt1_e FOR VALUES IN ('0000', '0003', '0004', '0010') +-- +TABLE: name="plt1_e_p1" schema="" table="plt1_e_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_e_p1 PARTITION OF plt1_e FOR VALUES IN ('0000', '0003', '0004', '0010')" +== 129 +-- truncate_limit: 100 +CREATE TABLE plt1_e_p2 PARTITION OF plt1_e FOR VALUES IN ('0001', '0005', '0002', '0009') +-- +TABLE: name="plt1_e_p2" schema="" table="plt1_e_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_e_p2 PARTITION OF plt1_e FOR VALUES IN ('0001', '0005', '0002', '0009')" +== 130 +-- truncate_limit: 100 +CREATE TABLE plt1_e_p3 PARTITION OF plt1_e FOR VALUES IN ('0006', '0007', '0008', '0011') +-- +TABLE: name="plt1_e_p3" schema="" table="plt1_e_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_e_p3 PARTITION OF plt1_e FOR VALUES IN ('0006', '0007', '0008', '0011')" +== 131 +-- truncate_limit: 100 +INSERT INTO plt1_e SELECT i, i, 'A' || to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1_e SELECT i, i, 'A' || to_char(i / 50, 'FM0000') FROM generate_series(0, 599, 2) i" +== 132 +-- truncate_limit: 100 +ANALYZE plt1_e +-- +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1_e" +== 133 +-- truncate_limit: 100 +-- test partition matching with N-way join +EXPLAIN (COSTS OFF) +SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1, plt2 t2, plt1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c +-- +TABLE: name="plt1" schema="" table="plt1" ctx=Select +TABLE: name="plt2" schema="" table="plt2" ctx=Select +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=Select +ALIAS: "t1"="plt1" +ALIAS: "t2"="plt2" +ALIAS: "t3"="plt1_e" +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t3" column="c" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1,..." +== 134 +-- truncate_limit: 100 +SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1, plt2 t2, plt1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c +-- +TABLE: name="plt1" schema="" table="plt1" ctx=Select +TABLE: name="plt2" schema="" table="plt2" ctx=Select +TABLE: name="plt1_e" schema="" table="plt1_e" ctx=Select +ALIAS: "t1"="plt1" +ALIAS: "t2"="plt2" +ALIAS: "t3"="plt1_e" +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t3" column="c" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1 t1, plt2 t2, plt1_e t3 WHERE ... GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2..." +== 135 +-- truncate_limit: 100 +-- joins where one of the relations is proven empty +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.a = 1 AND t1.a = 2 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1...." +== 136 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2) t1 LEFT JOIN prt2 t2 ON t1.a = t2.b +-- +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t2"="prt2" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2)..." +== 137 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2) t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b, prt1 t3 WHERE t2.b = t3.a +-- +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t2"="prt2" +ALIAS: "t3"="prt1" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t3" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2)..." +== 138 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2) t1 FULL JOIN prt2 t2 ON t1.a = t2.b WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt2" schema="" table="prt2" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t2"="prt2" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1 WHERE a = 1 AND a = 2)..." +== 139 +-- truncate_limit: 100 +|-- +-- tests for hash partitioned tables. +|-- +CREATE TABLE pht1 (a int, b int, c text) PARTITION BY HASH(c) +-- +TABLE: name="pht1" schema="" table="pht1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht1 (a int, b int, c text) PARTITION BY HASH (c)" +== 140 +-- truncate_limit: 100 +CREATE TABLE pht1_p1 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 0) +-- +TABLE: name="pht1_p1" schema="" table="pht1_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht1_p1 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 0)" +== 141 +-- truncate_limit: 100 +CREATE TABLE pht1_p2 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 1) +-- +TABLE: name="pht1_p2" schema="" table="pht1_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht1_p2 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 1)" +== 142 +-- truncate_limit: 100 +CREATE TABLE pht1_p3 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 2) +-- +TABLE: name="pht1_p3" schema="" table="pht1_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht1_p3 PARTITION OF pht1 FOR VALUES WITH (MODULUS 3, REMAINDER 2)" +== 143 +-- truncate_limit: 100 +INSERT INTO pht1 SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="pht1" schema="" table="pht1" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pht1 SELECT i, i, to_char(i / 50, 'FM0000') FROM generate_series(0, 599, 2) i" +== 144 +-- truncate_limit: 100 +ANALYZE pht1 +-- +TABLE: name="pht1" schema="" table="pht1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pht1" +== 145 +-- truncate_limit: 100 +CREATE TABLE pht2 (a int, b int, c text) PARTITION BY HASH(c) +-- +TABLE: name="pht2" schema="" table="pht2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht2 (a int, b int, c text) PARTITION BY HASH (c)" +== 146 +-- truncate_limit: 100 +CREATE TABLE pht2_p1 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 0) +-- +TABLE: name="pht2_p1" schema="" table="pht2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht2_p1 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 0)" +== 147 +-- truncate_limit: 100 +CREATE TABLE pht2_p2 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 1) +-- +TABLE: name="pht2_p2" schema="" table="pht2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht2_p2 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 1)" +== 148 +-- truncate_limit: 100 +CREATE TABLE pht2_p3 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 2) +-- +TABLE: name="pht2_p3" schema="" table="pht2_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht2_p3 PARTITION OF pht2 FOR VALUES WITH (MODULUS 3, REMAINDER 2)" +== 149 +-- truncate_limit: 100 +INSERT INTO pht2 SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 3) i +-- +TABLE: name="pht2" schema="" table="pht2" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pht2 SELECT i, i, to_char(i / 50, 'FM0000') FROM generate_series(0, 599, 3) i" +== 150 +-- truncate_limit: 100 +ANALYZE pht2 +-- +TABLE: name="pht2" schema="" table="pht2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pht2" +== 151 +-- truncate_limit: 100 +|-- +-- hash partitioned by expression +|-- +CREATE TABLE pht1_e (a int, b int, c text) PARTITION BY HASH(ltrim(c, 'A')) +-- +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht1_e (a int, b int, c text) PARTITION BY HASH ((ltrim(c, 'A')))" +== 152 +-- truncate_limit: 100 +CREATE TABLE pht1_e_p1 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 0) +-- +TABLE: name="pht1_e_p1" schema="" table="pht1_e_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht1_e_p1 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 0)" +== 153 +-- truncate_limit: 100 +CREATE TABLE pht1_e_p2 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 1) +-- +TABLE: name="pht1_e_p2" schema="" table="pht1_e_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht1_e_p2 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 1)" +== 154 +-- truncate_limit: 100 +CREATE TABLE pht1_e_p3 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 2) +-- +TABLE: name="pht1_e_p3" schema="" table="pht1_e_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pht1_e_p3 PARTITION OF pht1_e FOR VALUES WITH (MODULUS 3, REMAINDER 2)" +== 155 +-- truncate_limit: 100 +INSERT INTO pht1_e SELECT i, i, 'A' || to_char(i/50, 'FM0000') FROM generate_series(0, 299, 2) i +-- +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pht1_e SELECT i, i, 'A' || to_char(i / 50, 'FM0000') FROM generate_series(0, 299, 2) i" +== 156 +-- truncate_limit: 100 +ANALYZE pht1_e +-- +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pht1_e" +== 157 +-- truncate_limit: 100 +-- test partition matching with N-way join +EXPLAIN (COSTS OFF) +SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1, pht2 t2, pht1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c +-- +TABLE: name="pht1" schema="" table="pht1" ctx=Select +TABLE: name="pht2" schema="" table="pht2" ctx=Select +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=Select +ALIAS: "t1"="pht1" +ALIAS: "t2"="pht2" +ALIAS: "t3"="pht1_e" +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t3" column="c" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1,..." +== 158 +-- truncate_limit: 100 +SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1, pht2 t2, pht1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c +-- +TABLE: name="pht1" schema="" table="pht1" ctx=Select +TABLE: name="pht2" schema="" table="pht2" ctx=Select +TABLE: name="pht1_e" schema="" table="pht1_e" ctx=Select +ALIAS: "t1"="pht1" +ALIAS: "t2"="pht2" +ALIAS: "t3"="pht1_e" +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="ltrim" function="ltrim" schema="" ctx=Call +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t3" column="c" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pht1 t1, pht2 t2, pht1_e t3 WHERE ... GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2..." +== 159 +-- truncate_limit: 100 +-- test default partition behavior for range +ALTER TABLE prt1 DETACH PARTITION prt1_p3 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt1 DETACH PARTITION prt1_p3" +== 160 +-- truncate_limit: 100 +ALTER TABLE prt1 ATTACH PARTITION prt1_p3 DEFAULT +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt1 ATTACH PARTITION prt1_p3 DEFAULT" +== 161 +-- truncate_limit: 100 +ANALYZE prt1 +-- +TABLE: name="prt1" schema="" table="prt1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1" +== 162 +-- truncate_limit: 100 +ALTER TABLE prt2 DETACH PARTITION prt2_p3 +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt2 DETACH PARTITION prt2_p3" +== 163 +-- truncate_limit: 100 +ALTER TABLE prt2 ATTACH PARTITION prt2_p3 DEFAULT +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt2 ATTACH PARTITION prt2_p3 DEFAULT" +== 164 +-- truncate_limit: 100 +ANALYZE prt2 +-- +TABLE: name="prt2" schema="" table="prt2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2" +== 165 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.b AND t1...." +== 166 +-- truncate_limit: 100 +-- test default partition behavior for list +ALTER TABLE plt1 DETACH PARTITION plt1_p3 +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt1 DETACH PARTITION plt1_p3" +== 167 +-- truncate_limit: 100 +ALTER TABLE plt1 ATTACH PARTITION plt1_p3 DEFAULT +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt1 ATTACH PARTITION plt1_p3 DEFAULT" +== 168 +-- truncate_limit: 100 +ANALYZE plt1 +-- +TABLE: name="plt1" schema="" table="plt1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1" +== 169 +-- truncate_limit: 100 +ALTER TABLE plt2 DETACH PARTITION plt2_p3 +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2 DETACH PARTITION plt2_p3" +== 170 +-- truncate_limit: 100 +ALTER TABLE plt2 ATTACH PARTITION plt2_p3 DEFAULT +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2 ATTACH PARTITION plt2_p3 DEFAULT" +== 171 +-- truncate_limit: 100 +ANALYZE plt2 +-- +TABLE: name="plt2" schema="" table="plt2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2" +== 172 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT avg(t1.a), avg(t2.b), t1.c, t2.c FROM plt1 t1 RIGHT JOIN plt2 t2 ON t1.c = t2.c WHERE t1.a % 25 = 0 GROUP BY t1.c, t2.c ORDER BY t1.c, t2.c +-- +TABLE: name="plt1" schema="" table="plt1" ctx=Select +TABLE: name="plt2" schema="" table="plt2" ctx=Select +ALIAS: "t1"="plt1" +ALIAS: "t2"="plt2" +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT avg(t1.a), avg(t2.b), t1.c, t2.c FROM plt1 t1 RIGHT JOIN plt2 t2 ON t1..." +== 173 +-- truncate_limit: 100 +|-- +-- multiple levels of partitioning +|-- +CREATE TABLE prt1_l (a int, b int, c varchar) PARTITION BY RANGE(a) +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_l (a int, b int, c varchar) PARTITION BY RANGE (a)" +== 174 +-- truncate_limit: 100 +CREATE TABLE prt1_l_p1 PARTITION OF prt1_l FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt1_l_p1" schema="" table="prt1_l_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_l_p1 PARTITION OF prt1_l FOR VALUES FROM (0) TO (250)" +== 175 +-- truncate_limit: 100 +CREATE TABLE prt1_l_p2 PARTITION OF prt1_l FOR VALUES FROM (250) TO (500) PARTITION BY LIST (c) +-- +TABLE: name="prt1_l_p2" schema="" table="prt1_l_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_l_p2 PARTITION OF prt1_l FOR VALUES FROM (250) TO (500) PARTITION BY LIST (c)" +== 176 +-- truncate_limit: 100 +CREATE TABLE prt1_l_p2_p1 PARTITION OF prt1_l_p2 FOR VALUES IN ('0000', '0001') +-- +TABLE: name="prt1_l_p2_p1" schema="" table="prt1_l_p2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_l_p2_p1 PARTITION OF prt1_l_p2 FOR VALUES IN ('0000', '0001')" +== 177 +-- truncate_limit: 100 +CREATE TABLE prt1_l_p2_p2 PARTITION OF prt1_l_p2 FOR VALUES IN ('0002', '0003') +-- +TABLE: name="prt1_l_p2_p2" schema="" table="prt1_l_p2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_l_p2_p2 PARTITION OF prt1_l_p2 FOR VALUES IN ('0002', '0003')" +== 178 +-- truncate_limit: 100 +CREATE TABLE prt1_l_p3 PARTITION OF prt1_l FOR VALUES FROM (500) TO (600) PARTITION BY RANGE (b) +-- +TABLE: name="prt1_l_p3" schema="" table="prt1_l_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_l_p3 PARTITION OF prt1_l FOR VALUES FROM (500) TO (600) PARTITION BY RANGE (b)" +== 179 +-- truncate_limit: 100 +CREATE TABLE prt1_l_p3_p1 PARTITION OF prt1_l_p3 FOR VALUES FROM (0) TO (13) +-- +TABLE: name="prt1_l_p3_p1" schema="" table="prt1_l_p3_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_l_p3_p1 PARTITION OF prt1_l_p3 FOR VALUES FROM (0) TO (13)" +== 180 +-- truncate_limit: 100 +CREATE TABLE prt1_l_p3_p2 PARTITION OF prt1_l_p3 FOR VALUES FROM (13) TO (25) +-- +TABLE: name="prt1_l_p3_p2" schema="" table="prt1_l_p3_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_l_p3_p2 PARTITION OF prt1_l_p3 FOR VALUES FROM (13) TO (25)" +== 181 +-- truncate_limit: 100 +INSERT INTO prt1_l SELECT i, i % 25, to_char(i % 4, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt1_l SELECT i, i % 25, to_char(i % 4, 'FM0000') FROM generate_series(0, 599, 2) i" +== 182 +-- truncate_limit: 100 +ANALYZE prt1_l +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_l" +== 183 +-- truncate_limit: 100 +CREATE TABLE prt2_l (a int, b int, c varchar) PARTITION BY RANGE(b) +-- +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_l (a int, b int, c varchar) PARTITION BY RANGE (b)" +== 184 +-- truncate_limit: 100 +CREATE TABLE prt2_l_p1 PARTITION OF prt2_l FOR VALUES FROM (0) TO (250) +-- +TABLE: name="prt2_l_p1" schema="" table="prt2_l_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_l_p1 PARTITION OF prt2_l FOR VALUES FROM (0) TO (250)" +== 185 +-- truncate_limit: 100 +CREATE TABLE prt2_l_p2 PARTITION OF prt2_l FOR VALUES FROM (250) TO (500) PARTITION BY LIST (c) +-- +TABLE: name="prt2_l_p2" schema="" table="prt2_l_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_l_p2 PARTITION OF prt2_l FOR VALUES FROM (250) TO (500) PARTITION BY LIST (c)" +== 186 +-- truncate_limit: 100 +CREATE TABLE prt2_l_p2_p1 PARTITION OF prt2_l_p2 FOR VALUES IN ('0000', '0001') +-- +TABLE: name="prt2_l_p2_p1" schema="" table="prt2_l_p2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_l_p2_p1 PARTITION OF prt2_l_p2 FOR VALUES IN ('0000', '0001')" +== 187 +-- truncate_limit: 100 +CREATE TABLE prt2_l_p2_p2 PARTITION OF prt2_l_p2 FOR VALUES IN ('0002', '0003') +-- +TABLE: name="prt2_l_p2_p2" schema="" table="prt2_l_p2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_l_p2_p2 PARTITION OF prt2_l_p2 FOR VALUES IN ('0002', '0003')" +== 188 +-- truncate_limit: 100 +CREATE TABLE prt2_l_p3 PARTITION OF prt2_l FOR VALUES FROM (500) TO (600) PARTITION BY RANGE (a) +-- +TABLE: name="prt2_l_p3" schema="" table="prt2_l_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_l_p3 PARTITION OF prt2_l FOR VALUES FROM (500) TO (600) PARTITION BY RANGE (a)" +== 189 +-- truncate_limit: 100 +CREATE TABLE prt2_l_p3_p1 PARTITION OF prt2_l_p3 FOR VALUES FROM (0) TO (13) +-- +TABLE: name="prt2_l_p3_p1" schema="" table="prt2_l_p3_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_l_p3_p1 PARTITION OF prt2_l_p3 FOR VALUES FROM (0) TO (13)" +== 190 +-- truncate_limit: 100 +CREATE TABLE prt2_l_p3_p2 PARTITION OF prt2_l_p3 FOR VALUES FROM (13) TO (25) +-- +TABLE: name="prt2_l_p3_p2" schema="" table="prt2_l_p3_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_l_p3_p2 PARTITION OF prt2_l_p3 FOR VALUES FROM (13) TO (25)" +== 191 +-- truncate_limit: 100 +INSERT INTO prt2_l SELECT i % 25, i, to_char(i % 4, 'FM0000') FROM generate_series(0, 599, 3) i +-- +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_l SELECT i % 25, i, to_char(i % 4, 'FM0000') FROM generate_series(0, 599, 3) i" +== 192 +-- truncate_limit: 100 +ANALYZE prt2_l +-- +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_l" +== 193 +-- truncate_limit: 100 +-- inner join, qual covering only top-level partitions +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1, prt2_l t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1, prt2_l t2 WHERE t1.a = t2.b AND..." +== 194 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1, prt2_l t2 WHERE t1.a = t2.b AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1, prt2_l t2 WHERE ... ORDER BY t1.a, t2.b" +== 195 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 LEFT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 LEFT JOIN prt2_l t2 ON t1.a = t2..." +== 196 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 LEFT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_l t1 LEFT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE ... ORDER BY t..." +== 197 +-- truncate_limit: 100 +-- right join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 RIGHT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 RIGHT JOIN prt2_l t2 ON t1.a = t..." +== 198 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_l t1 RIGHT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE t2.a = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="t2" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_l t1 RIGHT JOIN prt2_l t2 ON t1.a = t2.b AND t1.c = t2.c WHERE ... ORDER BY ..." +== 199 +-- truncate_limit: 100 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1 FULL JOIN (SELECT * FROM prt2_l WHERE prt2_l.a = 0) t2 ON (t1.a = t2.b AND t1.c = t2.c) ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +FILTER: schema="" table="prt1_l" column="b" +FILTER: schema="" table="prt2_l" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) ..." +== 200 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1 FULL JOIN (SELECT * FROM prt2_l WHERE prt2_l.a = 0) t2 ON (t1.a = t2.b AND t1.c = t2.c) ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +FILTER: schema="" table="prt1_l" column="b" +FILTER: schema="" table="prt2_l" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM prt1_l WHERE ...) t1 FULL JOIN (SELECT * FROM prt2_l WHERE ...) t2..." +== 201 +-- truncate_limit: 100 +-- lateral partitionwise join +EXPLAIN (COSTS OFF) +SELECT * FROM prt1_l t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t2.c AS t2c, t2.b AS t2b, t3.b AS t3b, least(t1.a,t2.a,t3.b) FROM prt1_l t2 JOIN prt2_l t3 ON (t2.a = t3.b AND t2.c = t3.c)) ss + ON t1.a = ss.t2a AND t1.c = ss.t2c WHERE t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt1_l" +ALIAS: "t3"="prt2_l" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM prt1_l t1 LEFT JOIN LATERAL (SELECT t2.a AS t2a, t2.c AS t2c, t..." +== 202 +-- truncate_limit: 100 +SELECT * FROM prt1_l t1 LEFT JOIN LATERAL + (SELECT t2.a AS t2a, t2.c AS t2c, t2.b AS t2b, t3.b AS t3b, least(t1.a,t2.a,t3.b) FROM prt1_l t2 JOIN prt2_l t3 ON (t2.a = t3.b AND t2.c = t3.c)) ss + ON t1.a = ss.t2a AND t1.c = ss.t2c WHERE t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt1_l" +ALIAS: "t3"="prt2_l" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM prt1_l t1 LEFT JOIN LATERAL (SELECT ... FROM prt1_l t2 JOIN prt2_l t3 ON t2.a = t3...." +== 203 +-- truncate_limit: 100 +-- partitionwise join with lateral reference in sample scan +EXPLAIN (COSTS OFF) +SELECT * FROM prt1_l t1 JOIN LATERAL + (SELECT * FROM prt1_l t2 TABLESAMPLE SYSTEM (t1.a) REPEATABLE(t1.b)) s + ON t1.a = s.a AND t1.b = s.b AND t1.c = s.c +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt1_l" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM prt1_l t1 JOIN LATERAL (SELECT * FROM prt1_l t2 TABLESAMPLE sys..." +== 204 +-- truncate_limit: 100 +-- partitionwise join with lateral reference in scan's restriction clauses +EXPLAIN (COSTS OFF) +SELECT COUNT(*) FROM prt1_l t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2_l t2) s + ON t1.a = s.b AND t1.b = s.a AND t1.c = s.c + WHERE s.t1b = s.a +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM prt1_l t1 LEFT JOIN LATERAL (SELECT t1.b AS t1b, t2.* FR..." +== 205 +-- truncate_limit: 100 +SELECT COUNT(*) FROM prt1_l t1 LEFT JOIN LATERAL + (SELECT t1.b AS t1b, t2.* FROM prt2_l t2) s + ON t1.a = s.b AND t1.b = s.a AND t1.c = s.c + WHERE s.t1b = s.a +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +ALIAS: "t1"="prt1_l" +ALIAS: "t2"="prt2_l" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="s" column="t1b" +FILTER: schema="" table="s" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_l t1 LEFT JOIN LATERAL (SELECT ... FROM prt2_l t2) s ON t1.a = s.b AND t1.b ..." +== 206 +-- truncate_limit: 100 +-- join with one side empty +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE a = 1 AND a = 2) t1 RIGHT JOIN prt2_l t2 ON t1.a = t2.b AND t1.b = t2.a AND t1.c = t2.c +-- +TABLE: name="prt2_l" schema="" table="prt2_l" ctx=Select +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=Select +ALIAS: "t2"="prt2_l" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE a = 1 AND a = ..." +== 207 +-- truncate_limit: 100 +-- Test case to verify proper handling of subqueries in a partitioned delete. +-- The weird-looking lateral join is just there to force creation of a +-- nestloop parameter within the subquery, which exposes the problem if the +-- planner fails to make multiple copies of the subquery as appropriate. +EXPLAIN (COSTS OFF) +DELETE FROM prt1_l +WHERE EXISTS ( + SELECT 1 + FROM int4_tbl, + LATERAL (SELECT int4_tbl.f1 FROM int8_tbl LIMIT 2) ss + WHERE prt1_l.c IS NULL) +-- +TABLE: name="prt1_l" schema="" table="prt1_l" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="prt1_l" column="c" +STMT: ExplainStmt +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM prt1_l WHERE EXISTS (SELECT 1 FROM int4_tbl, LATERAL (SELECT int4..." +== 208 +-- truncate_limit: 100 +|-- +-- negative testcases +|-- +CREATE TABLE prt1_n (a int, b int, c varchar) PARTITION BY RANGE(c) +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_n (a int, b int, c varchar) PARTITION BY RANGE (c)" +== 209 +-- truncate_limit: 100 +CREATE TABLE prt1_n_p1 PARTITION OF prt1_n FOR VALUES FROM ('0000') TO ('0250') +-- +TABLE: name="prt1_n_p1" schema="" table="prt1_n_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_n_p1 PARTITION OF prt1_n FOR VALUES FROM ('0000') TO ('0250')" +== 210 +-- truncate_limit: 100 +CREATE TABLE prt1_n_p2 PARTITION OF prt1_n FOR VALUES FROM ('0250') TO ('0500') +-- +TABLE: name="prt1_n_p2" schema="" table="prt1_n_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_n_p2 PARTITION OF prt1_n FOR VALUES FROM ('0250') TO ('0500')" +== 211 +-- truncate_limit: 100 +INSERT INTO prt1_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 499, 2) i +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt1_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 499, 2) i" +== 212 +-- truncate_limit: 100 +ANALYZE prt1_n +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_n" +== 213 +-- truncate_limit: 100 +CREATE TABLE prt2_n (a int, b int, c text) PARTITION BY LIST(c) +-- +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_n (a int, b int, c text) PARTITION BY LIST (c)" +== 214 +-- truncate_limit: 100 +CREATE TABLE prt2_n_p1 PARTITION OF prt2_n FOR VALUES IN ('0000', '0003', '0004', '0010', '0006', '0007') +-- +TABLE: name="prt2_n_p1" schema="" table="prt2_n_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_n_p1 PARTITION OF prt2_n FOR VALUES IN ('0000', '0003', '0004', '0010', '0006',..." +== 215 +-- truncate_limit: 100 +CREATE TABLE prt2_n_p2 PARTITION OF prt2_n FOR VALUES IN ('0001', '0005', '0002', '0009', '0008', '0011') +-- +TABLE: name="prt2_n_p2" schema="" table="prt2_n_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_n_p2 PARTITION OF prt2_n FOR VALUES IN ('0001', '0005', '0002', '0009', '0008',..." +== 216 +-- truncate_limit: 100 +INSERT INTO prt2_n SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_n SELECT i, i, to_char(i / 50, 'FM0000') FROM generate_series(0, 599, 2) i" +== 217 +-- truncate_limit: 100 +ANALYZE prt2_n +-- +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_n" +== 218 +-- truncate_limit: 100 +CREATE TABLE prt3_n (a int, b int, c text) PARTITION BY LIST(c) +-- +TABLE: name="prt3_n" schema="" table="prt3_n" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt3_n (a int, b int, c text) PARTITION BY LIST (c)" +== 219 +-- truncate_limit: 100 +CREATE TABLE prt3_n_p1 PARTITION OF prt3_n FOR VALUES IN ('0000', '0004', '0006', '0007') +-- +TABLE: name="prt3_n_p1" schema="" table="prt3_n_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt3_n_p1 PARTITION OF prt3_n FOR VALUES IN ('0000', '0004', '0006', '0007')" +== 220 +-- truncate_limit: 100 +CREATE TABLE prt3_n_p2 PARTITION OF prt3_n FOR VALUES IN ('0001', '0002', '0008', '0010') +-- +TABLE: name="prt3_n_p2" schema="" table="prt3_n_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt3_n_p2 PARTITION OF prt3_n FOR VALUES IN ('0001', '0002', '0008', '0010')" +== 221 +-- truncate_limit: 100 +CREATE TABLE prt3_n_p3 PARTITION OF prt3_n FOR VALUES IN ('0003', '0005', '0009', '0011') +-- +TABLE: name="prt3_n_p3" schema="" table="prt3_n_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt3_n_p3 PARTITION OF prt3_n FOR VALUES IN ('0003', '0005', '0009', '0011')" +== 222 +-- truncate_limit: 100 +INSERT INTO prt2_n SELECT i, i, to_char(i/50, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_n SELECT i, i, to_char(i / 50, 'FM0000') FROM generate_series(0, 599, 2) i" +== 223 +-- truncate_limit: 100 +ANALYZE prt3_n +-- +TABLE: name="prt3_n" schema="" table="prt3_n" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt3_n" +== 224 +-- truncate_limit: 100 +CREATE TABLE prt4_n (a int, b int, c text) PARTITION BY RANGE(a) +-- +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt4_n (a int, b int, c text) PARTITION BY RANGE (a)" +== 225 +-- truncate_limit: 100 +CREATE TABLE prt4_n_p1 PARTITION OF prt4_n FOR VALUES FROM (0) TO (300) +-- +TABLE: name="prt4_n_p1" schema="" table="prt4_n_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt4_n_p1 PARTITION OF prt4_n FOR VALUES FROM (0) TO (300)" +== 226 +-- truncate_limit: 100 +CREATE TABLE prt4_n_p2 PARTITION OF prt4_n FOR VALUES FROM (300) TO (500) +-- +TABLE: name="prt4_n_p2" schema="" table="prt4_n_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt4_n_p2 PARTITION OF prt4_n FOR VALUES FROM (300) TO (500)" +== 227 +-- truncate_limit: 100 +CREATE TABLE prt4_n_p3 PARTITION OF prt4_n FOR VALUES FROM (500) TO (600) +-- +TABLE: name="prt4_n_p3" schema="" table="prt4_n_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt4_n_p3 PARTITION OF prt4_n FOR VALUES FROM (500) TO (600)" +== 228 +-- truncate_limit: 100 +INSERT INTO prt4_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 599, 2) i +-- +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt4_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 599, 2) i" +== 229 +-- truncate_limit: 100 +ANALYZE prt4_n +-- +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt4_n" +== 230 +-- truncate_limit: 100 +-- partitionwise join can not be applied if the partition ranges differ +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2 WHERE t1.a = t2.a +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt4_n" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2 WHERE t1.a = t2.a" +== 231 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2, prt2 t3 WHERE t1.a = t2.a and t1.a = t3.b +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt4_n" schema="" table="prt4_n" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt4_n" +ALIAS: "t3"="prt2" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t3" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2, prt2 t3 WHERE t1.a = t..." +== 232 +-- truncate_limit: 100 +-- partitionwise join can not be applied if there are no equi-join conditions +-- between partition keys +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON (t1.a < t2.b) +-- +TABLE: name="prt1" schema="" table="prt1" ctx=Select +TABLE: name="prt2" schema="" table="prt2" ctx=Select +ALIAS: "t1"="prt1" +ALIAS: "t2"="prt2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON t1.a < t2.b" +== 233 +-- truncate_limit: 100 +-- equi-join with join condition on partial keys does not qualify for +-- partitionwise join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1, prt2_m t2 WHERE t1.a = (t2.b + t2.a)/2 +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +ALIAS: "t1"="prt1_m" +ALIAS: "t2"="prt2_m" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1, prt2_m t2 WHERE t1.a = ((t2.b +..." +== 234 +-- truncate_limit: 100 +-- equi-join between out-of-order partition key columns does not qualify for +-- partitionwise join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.a = t2.b +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +ALIAS: "t1"="prt1_m" +ALIAS: "t2"="prt2_m" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.a = t2.b" +== 235 +-- truncate_limit: 100 +-- equi-join between non-key columns does not qualify for partitionwise join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.c = t2.c +-- +TABLE: name="prt1_m" schema="" table="prt1_m" ctx=Select +TABLE: name="prt2_m" schema="" table="prt2_m" ctx=Select +ALIAS: "t1"="prt1_m" +ALIAS: "t2"="prt2_m" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.c = t2.c" +== 236 +-- truncate_limit: 100 +-- partitionwise join can not be applied for a join between list and range +-- partitioned tables +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 LEFT JOIN prt2_n t2 ON (t1.c = t2.c) +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=Select +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=Select +ALIAS: "t1"="prt1_n" +ALIAS: "t2"="prt2_n" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 LEFT JOIN prt2_n t2 ON t1.c = t2.c" +== 237 +-- truncate_limit: 100 +-- partitionwise join can not be applied between tables with different +-- partition lists +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 JOIN prt2_n t2 ON (t1.c = t2.c) JOIN plt1 t3 ON (t1.c = t3.c) +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=Select +TABLE: name="prt2_n" schema="" table="prt2_n" ctx=Select +TABLE: name="plt1" schema="" table="plt1" ctx=Select +ALIAS: "t1"="prt1_n" +ALIAS: "t2"="prt2_n" +ALIAS: "t3"="plt1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 JOIN prt2_n t2 ON t1.c = t2.c JO..." +== 238 +-- truncate_limit: 100 +-- partitionwise join can not be applied for a join between key column and +-- non-key column +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 FULL JOIN prt1 t2 ON (t1.c = t2.c) +-- +TABLE: name="prt1_n" schema="" table="prt1_n" ctx=Select +TABLE: name="prt1" schema="" table="prt1" ctx=Select +ALIAS: "t1"="prt1_n" +ALIAS: "t2"="prt1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 FULL JOIN prt1 t2 ON t1.c = t2.c" +== 239 +-- truncate_limit: 100 +|-- +-- Test some other plan types in a partitionwise join (unfortunately, +-- we need larger tables to get the planner to choose these plan types) +|-- +create temp table prtx1 (a integer, b integer, c integer) + partition by range (a) +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE prtx1 (a int, b int, c int) PARTITION BY RANGE (a)" +== 240 +-- truncate_limit: 100 +create temp table prtx1_1 partition of prtx1 for values from (1) to (11) +-- +TABLE: name="prtx1_1" schema="" table="prtx1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE prtx1_1 PARTITION OF prtx1 FOR VALUES FROM (1) TO (11)" +== 241 +-- truncate_limit: 100 +create temp table prtx1_2 partition of prtx1 for values from (11) to (21) +-- +TABLE: name="prtx1_2" schema="" table="prtx1_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE prtx1_2 PARTITION OF prtx1 FOR VALUES FROM (11) TO (21)" +== 242 +-- truncate_limit: 100 +create temp table prtx1_3 partition of prtx1 for values from (21) to (31) +-- +TABLE: name="prtx1_3" schema="" table="prtx1_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE prtx1_3 PARTITION OF prtx1 FOR VALUES FROM (21) TO (31)" +== 243 +-- truncate_limit: 100 +create temp table prtx2 (a integer, b integer, c integer) + partition by range (a) +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE prtx2 (a int, b int, c int) PARTITION BY RANGE (a)" +== 244 +-- truncate_limit: 100 +create temp table prtx2_1 partition of prtx2 for values from (1) to (11) +-- +TABLE: name="prtx2_1" schema="" table="prtx2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE prtx2_1 PARTITION OF prtx2 FOR VALUES FROM (1) TO (11)" +== 245 +-- truncate_limit: 100 +create temp table prtx2_2 partition of prtx2 for values from (11) to (21) +-- +TABLE: name="prtx2_2" schema="" table="prtx2_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE prtx2_2 PARTITION OF prtx2 FOR VALUES FROM (11) TO (21)" +== 246 +-- truncate_limit: 100 +create temp table prtx2_3 partition of prtx2 for values from (21) to (31) +-- +TABLE: name="prtx2_3" schema="" table="prtx2_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE prtx2_3 PARTITION OF prtx2 FOR VALUES FROM (21) TO (31)" +== 247 +-- truncate_limit: 100 +insert into prtx1 select 1 + i%30, i, i + from generate_series(1,1000) i +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prtx1 SELECT 1 + (i % 30), i, i FROM generate_series(1, 1000) i" +== 248 +-- truncate_limit: 100 +insert into prtx2 select 1 + i%30, i, i + from generate_series(1,500) i, generate_series(1,10) j +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prtx2 SELECT 1 + (i % 30), i, i FROM generate_series(1, 500) i, generate_series(1, 10) j" +== 249 +-- truncate_limit: 100 +create index on prtx2 (b) +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON prtx2 USING btree (b)" +== 250 +-- truncate_limit: 100 +create index on prtx2 (c) +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON prtx2 USING btree (c)" +== 251 +-- truncate_limit: 100 +analyze prtx1 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prtx1" +== 252 +-- truncate_limit: 100 +analyze prtx2 +-- +TABLE: name="prtx2" schema="" table="prtx2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prtx2" +== 253 +-- truncate_limit: 100 +explain (costs off) +select * from prtx1 +where not exists (select 1 from prtx2 + where prtx2.a=prtx1.a and prtx2.b=prtx1.b and prtx2.c=123) + and a<20 and c=120 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=Select +TABLE: name="prtx2" schema="" table="prtx2" ctx=Select +FILTER: schema="" table="prtx2" column="a" +FILTER: schema="" table="prtx1" column="a" +FILTER: schema="" table="prtx2" column="b" +FILTER: schema="" table="prtx1" column="b" +FILTER: schema="" table="prtx2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM prtx1 WHERE NOT EXISTS (SELECT 1 FROM prtx2 WHERE prtx2.a = prt..." +== 254 +-- truncate_limit: 100 +select * from prtx1 +where not exists (select 1 from prtx2 + where prtx2.a=prtx1.a and prtx2.b=prtx1.b and prtx2.c=123) + and a<20 and c=120 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=Select +TABLE: name="prtx2" schema="" table="prtx2" ctx=Select +FILTER: schema="" table="prtx2" column="a" +FILTER: schema="" table="prtx1" column="a" +FILTER: schema="" table="prtx2" column="b" +FILTER: schema="" table="prtx1" column="b" +FILTER: schema="" table="prtx2" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM prtx1 WHERE NOT EXISTS (SELECT 1 FROM prtx2 WHERE ...) AND a < 20 AND c = 120" +== 255 +-- truncate_limit: 100 +explain (costs off) +select * from prtx1 +where not exists (select 1 from prtx2 + where prtx2.a=prtx1.a and (prtx2.b=prtx1.b+1 or prtx2.c=99)) + and a<20 and c=91 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=Select +TABLE: name="prtx2" schema="" table="prtx2" ctx=Select +FILTER: schema="" table="prtx2" column="a" +FILTER: schema="" table="prtx1" column="a" +FILTER: schema="" table="prtx2" column="b" +FILTER: schema="" table="prtx1" column="b" +FILTER: schema="" table="prtx2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM prtx1 WHERE NOT EXISTS (SELECT 1 FROM prtx2 WHERE prtx2.a = prt..." +== 256 +-- truncate_limit: 100 +select * from prtx1 +where not exists (select 1 from prtx2 + where prtx2.a=prtx1.a and (prtx2.b=prtx1.b+1 or prtx2.c=99)) + and a<20 and c=91 +-- +TABLE: name="prtx1" schema="" table="prtx1" ctx=Select +TABLE: name="prtx2" schema="" table="prtx2" ctx=Select +FILTER: schema="" table="prtx2" column="a" +FILTER: schema="" table="prtx1" column="a" +FILTER: schema="" table="prtx2" column="b" +FILTER: schema="" table="prtx1" column="b" +FILTER: schema="" table="prtx2" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM prtx1 WHERE NOT EXISTS (SELECT 1 FROM prtx2 WHERE ...) AND a < 20 AND c = 91" +== 257 +-- truncate_limit: 100 +|-- +-- Test advanced partition-matching algorithm for partitioned join +|-- + +-- Tests for range-partitioned tables +CREATE TABLE prt1_adv (a int, b int, c varchar) PARTITION BY RANGE (a) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv (a int, b int, c varchar) PARTITION BY RANGE (a)" +== 258 +-- truncate_limit: 100 +CREATE TABLE prt1_adv_p1 PARTITION OF prt1_adv FOR VALUES FROM (100) TO (200) +-- +TABLE: name="prt1_adv_p1" schema="" table="prt1_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv_p1 PARTITION OF prt1_adv FOR VALUES FROM (100) TO (200)" +== 259 +-- truncate_limit: 100 +CREATE TABLE prt1_adv_p2 PARTITION OF prt1_adv FOR VALUES FROM (200) TO (300) +-- +TABLE: name="prt1_adv_p2" schema="" table="prt1_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv_p2 PARTITION OF prt1_adv FOR VALUES FROM (200) TO (300)" +== 260 +-- truncate_limit: 100 +CREATE TABLE prt1_adv_p3 PARTITION OF prt1_adv FOR VALUES FROM (300) TO (400) +-- +TABLE: name="prt1_adv_p3" schema="" table="prt1_adv_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv_p3 PARTITION OF prt1_adv FOR VALUES FROM (300) TO (400)" +== 261 +-- truncate_limit: 100 +CREATE INDEX prt1_adv_a_idx ON prt1_adv (a) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX prt1_adv_a_idx ON prt1_adv USING btree (a)" +== 262 +-- truncate_limit: 100 +INSERT INTO prt1_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(100, 399) i +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt1_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(100, 399) i" +== 263 +-- truncate_limit: 100 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_adv" +== 264 +-- truncate_limit: 100 +CREATE TABLE prt2_adv (a int, b int, c varchar) PARTITION BY RANGE (b) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv (a int, b int, c varchar) PARTITION BY RANGE (b)" +== 265 +-- truncate_limit: 100 +CREATE TABLE prt2_adv_p1 PARTITION OF prt2_adv FOR VALUES FROM (100) TO (150) +-- +TABLE: name="prt2_adv_p1" schema="" table="prt2_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_p1 PARTITION OF prt2_adv FOR VALUES FROM (100) TO (150)" +== 266 +-- truncate_limit: 100 +CREATE TABLE prt2_adv_p2 PARTITION OF prt2_adv FOR VALUES FROM (200) TO (300) +-- +TABLE: name="prt2_adv_p2" schema="" table="prt2_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_p2 PARTITION OF prt2_adv FOR VALUES FROM (200) TO (300)" +== 267 +-- truncate_limit: 100 +CREATE TABLE prt2_adv_p3 PARTITION OF prt2_adv FOR VALUES FROM (350) TO (500) +-- +TABLE: name="prt2_adv_p3" schema="" table="prt2_adv_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_p3 PARTITION OF prt2_adv FOR VALUES FROM (350) TO (500)" +== 268 +-- truncate_limit: 100 +CREATE INDEX prt2_adv_b_idx ON prt2_adv (b) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX prt2_adv_b_idx ON prt2_adv USING btree (b)" +== 269 +-- truncate_limit: 100 +INSERT INTO prt2_adv_p1 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(100, 149) i +-- +TABLE: name="prt2_adv_p1" schema="" table="prt2_adv_p1" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_adv_p1 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(100, 149) i" +== 270 +-- truncate_limit: 100 +INSERT INTO prt2_adv_p2 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(200, 299) i +-- +TABLE: name="prt2_adv_p2" schema="" table="prt2_adv_p2" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_adv_p2 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(200, 299) i" +== 271 +-- truncate_limit: 100 +INSERT INTO prt2_adv_p3 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(350, 499) i +-- +TABLE: name="prt2_adv_p3" schema="" table="prt2_adv_p3" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_adv_p3 SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(350, 499) i" +== 272 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 273 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2...." +== 274 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b" +== 275 +-- truncate_limit: 100 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1..." +== 276 +-- truncate_limit: 100 +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM prt1_adv t1 WHERE ... ORDER BY t1.a" +== 277 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON t1.a ..." +== 278 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b" +== 279 +-- truncate_limit: 100 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHER..." +== 280 +-- truncate_limit: 100 +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM prt1_adv t1 WHERE ... ORDER BY t1.a" +== 281 +-- truncate_limit: 100 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 phv, * FROM prt1_adv WHERE prt1_adv.b = 0) t1 FULL JOIN (SELECT 425 phv, * FROM prt2_adv WHERE prt2_adv.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1_adv" column="b" +FILTER: schema="" table="prt2_adv" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 AS phv, * FROM prt1_adv WHERE ..." +== 282 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 phv, * FROM prt1_adv WHERE prt1_adv.b = 0) t1 FULL JOIN (SELECT 425 phv, * FROM prt2_adv WHERE prt2_adv.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1_adv" column="b" +FILTER: schema="" table="prt2_adv" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM prt1_adv WHERE ...) t1 FULL JOIN (SELECT ... FROM prt2_adv WHERE..." +== 283 +-- truncate_limit: 100 +-- Test cases where one side has an extra partition +CREATE TABLE prt2_adv_extra PARTITION OF prt2_adv FOR VALUES FROM (500) TO (MAXVALUE) +-- +TABLE: name="prt2_adv_extra" schema="" table="prt2_adv_extra" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_extra PARTITION OF prt2_adv FOR VALUES FROM (500) TO (maxvalue)" +== 284 +-- truncate_limit: 100 +INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(500, 599) i +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(500, 599) i" +== 285 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 286 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2...." +== 287 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b" +== 288 +-- truncate_limit: 100 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1..." +== 289 +-- truncate_limit: 100 +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM prt1_adv t1 WHERE ... ORDER BY t1.a" +== 290 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON t1.a ..." +== 291 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b" +== 292 +-- truncate_limit: 100 +-- left join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.b, t1.c, t2.a, t2.c FROM prt2_adv t1 LEFT JOIN prt1_adv t2 ON (t1.b = t2.a) WHERE t1.a = 0 ORDER BY t1.b, t2.a +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +ALIAS: "t1"="prt2_adv" +ALIAS: "t2"="prt1_adv" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.b, t1.c, t2.a, t2.c FROM prt2_adv t1 LEFT JOIN prt1_adv t2 ON t1.b ..." +== 293 +-- truncate_limit: 100 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHER..." +== 294 +-- truncate_limit: 100 +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM prt1_adv t1 WHERE ... ORDER BY t1.a" +== 295 +-- truncate_limit: 100 +-- anti join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt2_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt1_adv t2 WHERE t1.b = t2.a) AND t1.a = 0 ORDER BY t1.b +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +ALIAS: "t1"="prt2_adv" +ALIAS: "t2"="prt1_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt2_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt1_adv t2 WHER..." +== 296 +-- truncate_limit: 100 +-- full join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 phv, * FROM prt1_adv WHERE prt1_adv.b = 0) t1 FULL JOIN (SELECT 425 phv, * FROM prt2_adv WHERE prt2_adv.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1_adv" column="b" +FILTER: schema="" table="prt2_adv" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 AS phv, * FROM prt1_adv WHERE ..." +== 297 +-- truncate_limit: 100 +-- 3-way join where not every pair of relations can do partitioned join +EXPLAIN (COSTS OFF) +SELECT t1.b, t1.c, t2.a, t2.c, t3.a, t3.c FROM prt2_adv t1 LEFT JOIN prt1_adv t2 ON (t1.b = t2.a) INNER JOIN prt1_adv t3 ON (t1.b = t3.a) WHERE t1.a = 0 ORDER BY t1.b, t2.a, t3.a +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +ALIAS: "t1"="prt2_adv" +ALIAS: "t2"="prt1_adv" +ALIAS: "t3"="prt1_adv" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.b, t1.c, t2.a, t2.c, t3.a, t3.c FROM prt2_adv t1 LEFT JOIN prt1_adv..." +== 298 +-- truncate_limit: 100 +SELECT t1.b, t1.c, t2.a, t2.c, t3.a, t3.c FROM prt2_adv t1 LEFT JOIN prt1_adv t2 ON (t1.b = t2.a) INNER JOIN prt1_adv t3 ON (t1.b = t3.a) WHERE t1.a = 0 ORDER BY t1.b, t2.a, t3.a +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +ALIAS: "t1"="prt2_adv" +ALIAS: "t2"="prt1_adv" +ALIAS: "t3"="prt1_adv" +FILTER: schema="" table="t1" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt2_adv t1 LEFT JOIN prt1_adv t2 ON t1.b = t2.a JOIN prt1_adv t3 ON t1.b = t3.a ..." +== 299 +-- truncate_limit: 100 +DROP TABLE prt2_adv_extra +-- +TABLE: name="prt2_adv_extra" schema="" table="prt2_adv_extra" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt2_adv_extra" +== 300 +-- truncate_limit: 100 +-- Test cases where a partition on one side matches multiple partitions on +-- the other side; we currently can't do partitioned join in such cases +ALTER TABLE prt2_adv DETACH PARTITION prt2_adv_p3 +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt2_adv DETACH PARTITION prt2_adv_p3" +== 301 +-- truncate_limit: 100 +-- Split prt2_adv_p3 into two partitions so that prt1_adv_p3 matches both +CREATE TABLE prt2_adv_p3_1 PARTITION OF prt2_adv FOR VALUES FROM (350) TO (375) +-- +TABLE: name="prt2_adv_p3_1" schema="" table="prt2_adv_p3_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_p3_1 PARTITION OF prt2_adv FOR VALUES FROM (350) TO (375)" +== 302 +-- truncate_limit: 100 +CREATE TABLE prt2_adv_p3_2 PARTITION OF prt2_adv FOR VALUES FROM (375) TO (500) +-- +TABLE: name="prt2_adv_p3_2" schema="" table="prt2_adv_p3_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_p3_2 PARTITION OF prt2_adv FOR VALUES FROM (375) TO (500)" +== 303 +-- truncate_limit: 100 +INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(350, 499) i +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(350, 499) i" +== 304 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 305 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2...." +== 306 +-- truncate_limit: 100 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1_adv t1 WHERE EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1..." +== 307 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON t1.a ..." +== 308 +-- truncate_limit: 100 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHERE t1.a = t2.b) AND t1.b = 0 ORDER BY t1.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM prt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM prt2_adv t2 WHER..." +== 309 +-- truncate_limit: 100 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 phv, * FROM prt1_adv WHERE prt1_adv.b = 0) t1 FULL JOIN (SELECT 425 phv, * FROM prt2_adv WHERE prt2_adv.a = 0) t2 ON (t1.a = t2.b) WHERE t1.phv = t1.a OR t2.phv = t2.b ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +FILTER: schema="" table="t1" column="phv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="phv" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="prt1_adv" column="b" +FILTER: schema="" table="prt2_adv" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT 175 AS phv, * FROM prt1_adv WHERE ..." +== 310 +-- truncate_limit: 100 +DROP TABLE prt2_adv_p3_1 +-- +TABLE: name="prt2_adv_p3_1" schema="" table="prt2_adv_p3_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt2_adv_p3_1" +== 311 +-- truncate_limit: 100 +DROP TABLE prt2_adv_p3_2 +-- +TABLE: name="prt2_adv_p3_2" schema="" table="prt2_adv_p3_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt2_adv_p3_2" +== 312 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 313 +-- truncate_limit: 100 +-- Test default partitions +ALTER TABLE prt1_adv DETACH PARTITION prt1_adv_p1 +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt1_adv DETACH PARTITION prt1_adv_p1" +== 314 +-- truncate_limit: 100 +-- Change prt1_adv_p1 to the default partition +ALTER TABLE prt1_adv ATTACH PARTITION prt1_adv_p1 DEFAULT +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt1_adv ATTACH PARTITION prt1_adv_p1 DEFAULT" +== 315 +-- truncate_limit: 100 +ALTER TABLE prt1_adv DETACH PARTITION prt1_adv_p3 +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt1_adv DETACH PARTITION prt1_adv_p3" +== 316 +-- truncate_limit: 100 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_adv" +== 317 +-- truncate_limit: 100 +-- We can do partitioned join even if only one of relations has the default +-- partition +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2...." +== 318 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b" +== 319 +-- truncate_limit: 100 +-- Restore prt1_adv_p3 +ALTER TABLE prt1_adv ATTACH PARTITION prt1_adv_p3 FOR VALUES FROM (300) TO (400) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt1_adv ATTACH PARTITION prt1_adv_p3 FOR VALUES FROM (300) TO (400)" +== 320 +-- truncate_limit: 100 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_adv" +== 321 +-- truncate_limit: 100 +-- Restore prt2_adv_p3 +ALTER TABLE prt2_adv ATTACH PARTITION prt2_adv_p3 FOR VALUES FROM (350) TO (500) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt2_adv ATTACH PARTITION prt2_adv_p3 FOR VALUES FROM (350) TO (500)" +== 322 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 323 +-- truncate_limit: 100 +-- Partitioned join can't be applied because the default partition of prt1_adv +-- matches prt2_adv_p1 and prt2_adv_p3 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2...." +== 324 +-- truncate_limit: 100 +ALTER TABLE prt2_adv DETACH PARTITION prt2_adv_p3 +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt2_adv DETACH PARTITION prt2_adv_p3" +== 325 +-- truncate_limit: 100 +-- Change prt2_adv_p3 to the default partition +ALTER TABLE prt2_adv ATTACH PARTITION prt2_adv_p3 DEFAULT +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE prt2_adv ATTACH PARTITION prt2_adv_p3 DEFAULT" +== 326 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 327 +-- truncate_limit: 100 +-- Partitioned join can't be applied because the default partition of prt1_adv +-- matches prt2_adv_p1 and prt2_adv_p3 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2...." +== 328 +-- truncate_limit: 100 +DROP TABLE prt1_adv_p3 +-- +TABLE: name="prt1_adv_p3" schema="" table="prt1_adv_p3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt1_adv_p3" +== 329 +-- truncate_limit: 100 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_adv" +== 330 +-- truncate_limit: 100 +DROP TABLE prt2_adv_p3 +-- +TABLE: name="prt2_adv_p3" schema="" table="prt2_adv_p3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt2_adv_p3" +== 331 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 332 +-- truncate_limit: 100 +CREATE TABLE prt3_adv (a int, b int, c varchar) PARTITION BY RANGE (a) +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt3_adv (a int, b int, c varchar) PARTITION BY RANGE (a)" +== 333 +-- truncate_limit: 100 +CREATE TABLE prt3_adv_p1 PARTITION OF prt3_adv FOR VALUES FROM (200) TO (300) +-- +TABLE: name="prt3_adv_p1" schema="" table="prt3_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt3_adv_p1 PARTITION OF prt3_adv FOR VALUES FROM (200) TO (300)" +== 334 +-- truncate_limit: 100 +CREATE TABLE prt3_adv_p2 PARTITION OF prt3_adv FOR VALUES FROM (300) TO (400) +-- +TABLE: name="prt3_adv_p2" schema="" table="prt3_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt3_adv_p2 PARTITION OF prt3_adv FOR VALUES FROM (300) TO (400)" +== 335 +-- truncate_limit: 100 +CREATE INDEX prt3_adv_a_idx ON prt3_adv (a) +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX prt3_adv_a_idx ON prt3_adv USING btree (a)" +== 336 +-- truncate_limit: 100 +INSERT INTO prt3_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(200, 399) i +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt3_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(200, 399) i" +== 337 +-- truncate_limit: 100 +ANALYZE prt3_adv +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt3_adv" +== 338 +-- truncate_limit: 100 +-- 3-way join to test the default partition of a join relation +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c, t3.a, t3.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) LEFT JOIN prt3_adv t3 ON (t1.a = t3.a) WHERE t1.b = 0 ORDER BY t1.a, t2.b, t3.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +ALIAS: "t3"="prt3_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c, t3.a, t3.c FROM prt1_adv t1 LEFT JOIN prt2_adv..." +== 339 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c, t3.a, t3.c FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON (t1.a = t2.b) LEFT JOIN prt3_adv t3 ON (t1.a = t3.a) WHERE t1.b = 0 ORDER BY t1.a, t2.b, t3.a +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +ALIAS: "t3"="prt3_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_adv t1 LEFT JOIN prt2_adv t2 ON t1.a = t2.b LEFT JOIN prt3_adv t3 ON t1.a = ..." +== 340 +-- truncate_limit: 100 +DROP TABLE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt1_adv" +== 341 +-- truncate_limit: 100 +DROP TABLE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt2_adv" +== 342 +-- truncate_limit: 100 +DROP TABLE prt3_adv +-- +TABLE: name="prt3_adv" schema="" table="prt3_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt3_adv" +== 343 +-- truncate_limit: 100 +-- Test interaction of partitioned join with partition pruning +CREATE TABLE prt1_adv (a int, b int, c varchar) PARTITION BY RANGE (a) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv (a int, b int, c varchar) PARTITION BY RANGE (a)" +== 344 +-- truncate_limit: 100 +CREATE TABLE prt1_adv_p1 PARTITION OF prt1_adv FOR VALUES FROM (100) TO (200) +-- +TABLE: name="prt1_adv_p1" schema="" table="prt1_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv_p1 PARTITION OF prt1_adv FOR VALUES FROM (100) TO (200)" +== 345 +-- truncate_limit: 100 +CREATE TABLE prt1_adv_p2 PARTITION OF prt1_adv FOR VALUES FROM (200) TO (300) +-- +TABLE: name="prt1_adv_p2" schema="" table="prt1_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv_p2 PARTITION OF prt1_adv FOR VALUES FROM (200) TO (300)" +== 346 +-- truncate_limit: 100 +CREATE TABLE prt1_adv_p3 PARTITION OF prt1_adv FOR VALUES FROM (300) TO (400) +-- +TABLE: name="prt1_adv_p3" schema="" table="prt1_adv_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv_p3 PARTITION OF prt1_adv FOR VALUES FROM (300) TO (400)" +== 347 +-- truncate_limit: 100 +CREATE INDEX prt1_adv_a_idx ON prt1_adv (a) +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX prt1_adv_a_idx ON prt1_adv USING btree (a)" +== 348 +-- truncate_limit: 100 +INSERT INTO prt1_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(100, 399) i +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt1_adv SELECT i, i % 25, to_char(i, 'FM0000') FROM generate_series(100, 399) i" +== 349 +-- truncate_limit: 100 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_adv" +== 350 +-- truncate_limit: 100 +CREATE TABLE prt2_adv (a int, b int, c varchar) PARTITION BY RANGE (b) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv (a int, b int, c varchar) PARTITION BY RANGE (b)" +== 351 +-- truncate_limit: 100 +CREATE TABLE prt2_adv_p1 PARTITION OF prt2_adv FOR VALUES FROM (100) TO (200) +-- +TABLE: name="prt2_adv_p1" schema="" table="prt2_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_p1 PARTITION OF prt2_adv FOR VALUES FROM (100) TO (200)" +== 352 +-- truncate_limit: 100 +CREATE TABLE prt2_adv_p2 PARTITION OF prt2_adv FOR VALUES FROM (200) TO (400) +-- +TABLE: name="prt2_adv_p2" schema="" table="prt2_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_p2 PARTITION OF prt2_adv FOR VALUES FROM (200) TO (400)" +== 353 +-- truncate_limit: 100 +CREATE INDEX prt2_adv_b_idx ON prt2_adv (b) +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX prt2_adv_b_idx ON prt2_adv USING btree (b)" +== 354 +-- truncate_limit: 100 +INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(100, 399) i +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO prt2_adv SELECT i % 25, i, to_char(i, 'FM0000') FROM generate_series(100, 399) i" +== 355 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 356 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.a < 300 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2...." +== 357 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.a < 300 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2.b WHERE ... ORDER BY t1.a, t2.b" +== 358 +-- truncate_limit: 100 +DROP TABLE prt1_adv_p3 +-- +TABLE: name="prt1_adv_p3" schema="" table="prt1_adv_p3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt1_adv_p3" +== 359 +-- truncate_limit: 100 +CREATE TABLE prt1_adv_default PARTITION OF prt1_adv DEFAULT +-- +TABLE: name="prt1_adv_default" schema="" table="prt1_adv_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt1_adv_default PARTITION OF prt1_adv DEFAULT" +== 360 +-- truncate_limit: 100 +ANALYZE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt1_adv" +== 361 +-- truncate_limit: 100 +CREATE TABLE prt2_adv_default PARTITION OF prt2_adv DEFAULT +-- +TABLE: name="prt2_adv_default" schema="" table="prt2_adv_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE prt2_adv_default PARTITION OF prt2_adv DEFAULT" +== 362 +-- truncate_limit: 100 +ANALYZE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE prt2_adv" +== 363 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.a >= 100 AND t1.a < 300 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2...." +== 364 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_adv t1 INNER JOIN prt2_adv t2 ON (t1.a = t2.b) WHERE t1.a >= 100 AND t1.a < 300 AND t1.b = 0 ORDER BY t1.a, t2.b +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=Select +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=Select +ALIAS: "t1"="prt1_adv" +ALIAS: "t2"="prt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM prt1_adv t1 JOIN prt2_adv t2 ON t1.a = t2.b WHERE ... ORDER BY t1.a, t2.b" +== 365 +-- truncate_limit: 100 +DROP TABLE prt1_adv +-- +TABLE: name="prt1_adv" schema="" table="prt1_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt1_adv" +== 366 +-- truncate_limit: 100 +DROP TABLE prt2_adv +-- +TABLE: name="prt2_adv" schema="" table="prt2_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prt2_adv" +== 367 +-- truncate_limit: 100 +-- Tests for list-partitioned tables +CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c)" +== 368 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0001', '0003') +-- +TABLE: name="plt1_adv_p1" schema="" table="plt1_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0001', '0003')" +== 369 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt1_adv_p2" schema="" table="plt1_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0004', '0006')" +== 370 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p3 PARTITION OF plt1_adv FOR VALUES IN ('0008', '0009') +-- +TABLE: name="plt1_adv_p3" schema="" table="plt1_adv_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p3 PARTITION OF plt1_adv FOR VALUES IN ('0008', '0009')" +== 371 +-- truncate_limit: 100 +INSERT INTO plt1_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9)" +== 372 +-- truncate_limit: 100 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1_adv" +== 373 +-- truncate_limit: 100 +CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c)" +== 374 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0002', '0003') +-- +TABLE: name="plt2_adv_p1" schema="" table="plt2_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0002', '0003')" +== 375 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt2_adv_p2" schema="" table="plt2_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN ('0004', '0006')" +== 376 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p3 PARTITION OF plt2_adv FOR VALUES IN ('0007', '0009') +-- +TABLE: name="plt2_adv_p3" schema="" table="plt2_adv_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p3 PARTITION OF plt2_adv FOR VALUES IN ('0007', '0009')" +== 377 +-- truncate_limit: 100 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9)" +== 378 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 379 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 380 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 381 +-- truncate_limit: 100 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1..." +== 382 +-- truncate_limit: 100 +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM plt1_adv t1 WHERE ... ORDER BY t1.a" +== 383 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a ..." +== 384 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 385 +-- truncate_limit: 100 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHER..." +== 386 +-- truncate_limit: 100 +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM plt1_adv t1 WHERE ... ORDER BY t1.a" +== 387 +-- truncate_limit: 100 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a ..." +== 388 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 389 +-- truncate_limit: 100 +-- Test cases where one side has an extra partition +CREATE TABLE plt2_adv_extra PARTITION OF plt2_adv FOR VALUES IN ('0000') +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_extra PARTITION OF plt2_adv FOR VALUES IN ('0000')" +== 390 +-- truncate_limit: 100 +INSERT INTO plt2_adv_extra VALUES (0, 0, '0000') +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv_extra VALUES (0, 0, '0000')" +== 391 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 392 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 393 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 394 +-- truncate_limit: 100 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1..." +== 395 +-- truncate_limit: 100 +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM plt1_adv t1 WHERE ... ORDER BY t1.a" +== 396 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a ..." +== 397 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 398 +-- truncate_limit: 100 +-- left join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt2_adv t1 LEFT JOIN plt1_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +ALIAS: "t1"="plt2_adv" +ALIAS: "t2"="plt1_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt2_adv t1 LEFT JOIN plt1_adv t2 ON t1.a ..." +== 399 +-- truncate_limit: 100 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHER..." +== 400 +-- truncate_limit: 100 +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM plt1_adv t1 WHERE ... ORDER BY t1.a" +== 401 +-- truncate_limit: 100 +-- anti join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt2_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt1_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +ALIAS: "t1"="plt2_adv" +ALIAS: "t2"="plt1_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt2_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt1_adv t2 WHER..." +== 402 +-- truncate_limit: 100 +-- full join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a ..." +== 403 +-- truncate_limit: 100 +DROP TABLE plt2_adv_extra +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_extra" +== 404 +-- truncate_limit: 100 +-- Test cases where a partition on one side matches multiple partitions on +-- the other side; we currently can't do partitioned join in such cases +ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2 +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2" +== 405 +-- truncate_limit: 100 +-- Split plt2_adv_p2 into two partitions so that plt1_adv_p2 matches both +CREATE TABLE plt2_adv_p2_1 PARTITION OF plt2_adv FOR VALUES IN ('0004') +-- +TABLE: name="plt2_adv_p2_1" schema="" table="plt2_adv_p2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p2_1 PARTITION OF plt2_adv FOR VALUES IN ('0004')" +== 406 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p2_2 PARTITION OF plt2_adv FOR VALUES IN ('0006') +-- +TABLE: name="plt2_adv_p2_2" schema="" table="plt2_adv_p2_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p2_2 PARTITION OF plt2_adv FOR VALUES IN ('0006')" +== 407 +-- truncate_limit: 100 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (4, 6) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (4, 6)" +== 408 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 409 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 410 +-- truncate_limit: 100 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1..." +== 411 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a ..." +== 412 +-- truncate_limit: 100 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHER..." +== 413 +-- truncate_limit: 100 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a ..." +== 414 +-- truncate_limit: 100 +DROP TABLE plt2_adv_p2_1 +-- +TABLE: name="plt2_adv_p2_1" schema="" table="plt2_adv_p2_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_p2_1" +== 415 +-- truncate_limit: 100 +DROP TABLE plt2_adv_p2_2 +-- +TABLE: name="plt2_adv_p2_2" schema="" table="plt2_adv_p2_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_p2_2" +== 416 +-- truncate_limit: 100 +-- Restore plt2_adv_p2 +ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2 FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2 FOR VALUES IN ('0004', '0006')" +== 417 +-- truncate_limit: 100 +-- Test NULL partitions +ALTER TABLE plt1_adv DETACH PARTITION plt1_adv_p1 +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt1_adv DETACH PARTITION plt1_adv_p1" +== 418 +-- truncate_limit: 100 +-- Change plt1_adv_p1 to the NULL partition +CREATE TABLE plt1_adv_p1_null PARTITION OF plt1_adv FOR VALUES IN (NULL, '0001', '0003') +-- +TABLE: name="plt1_adv_p1_null" schema="" table="plt1_adv_p1_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p1_null PARTITION OF plt1_adv FOR VALUES IN (NULL, '0001', '0003')" +== 419 +-- truncate_limit: 100 +INSERT INTO plt1_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3)" +== 420 +-- truncate_limit: 100 +INSERT INTO plt1_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1_adv VALUES (-1, -1, NULL)" +== 421 +-- truncate_limit: 100 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1_adv" +== 422 +-- truncate_limit: 100 +ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p3 +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p3" +== 423 +-- truncate_limit: 100 +-- Change plt2_adv_p3 to the NULL partition +CREATE TABLE plt2_adv_p3_null PARTITION OF plt2_adv FOR VALUES IN (NULL, '0007', '0009') +-- +TABLE: name="plt2_adv_p3_null" schema="" table="plt2_adv_p3_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p3_null PARTITION OF plt2_adv FOR VALUES IN (NULL, '0007', '0009')" +== 424 +-- truncate_limit: 100 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (7, 9) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (7, 9)" +== 425 +-- truncate_limit: 100 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv VALUES (-1, -1, NULL)" +== 426 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 427 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 428 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 429 +-- truncate_limit: 100 +-- semi join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1..." +== 430 +-- truncate_limit: 100 +SELECT t1.* FROM plt1_adv t1 WHERE EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM plt1_adv t1 WHERE ... ORDER BY t1.a" +== 431 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a ..." +== 432 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 433 +-- truncate_limit: 100 +-- anti join +EXPLAIN (COSTS OFF) +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHER..." +== 434 +-- truncate_limit: 100 +SELECT t1.* FROM plt1_adv t1 WHERE NOT EXISTS (SELECT 1 FROM plt2_adv t2 WHERE t1.a = t2.a AND t1.c = t2.c) AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t2" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT t1.* FROM plt1_adv t1 WHERE ... ORDER BY t1.a" +== 435 +-- truncate_limit: 100 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a ..." +== 436 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 437 +-- truncate_limit: 100 +DROP TABLE plt1_adv_p1_null +-- +TABLE: name="plt1_adv_p1_null" schema="" table="plt1_adv_p1_null" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt1_adv_p1_null" +== 438 +-- truncate_limit: 100 +-- Restore plt1_adv_p1 +ALTER TABLE plt1_adv ATTACH PARTITION plt1_adv_p1 FOR VALUES IN ('0001', '0003') +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt1_adv ATTACH PARTITION plt1_adv_p1 FOR VALUES IN ('0001', '0003')" +== 439 +-- truncate_limit: 100 +-- Add to plt1_adv the extra NULL partition containing only NULL values as the +-- key values +CREATE TABLE plt1_adv_extra PARTITION OF plt1_adv FOR VALUES IN (NULL) +-- +TABLE: name="plt1_adv_extra" schema="" table="plt1_adv_extra" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_extra PARTITION OF plt1_adv FOR VALUES IN (NULL)" +== 440 +-- truncate_limit: 100 +INSERT INTO plt1_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1_adv VALUES (-1, -1, NULL)" +== 441 +-- truncate_limit: 100 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1_adv" +== 442 +-- truncate_limit: 100 +DROP TABLE plt2_adv_p3_null +-- +TABLE: name="plt2_adv_p3_null" schema="" table="plt2_adv_p3_null" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_p3_null" +== 443 +-- truncate_limit: 100 +-- Restore plt2_adv_p3 +ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p3 FOR VALUES IN ('0007', '0009') +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p3 FOR VALUES IN ('0007', '0009')" +== 444 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 445 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 446 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 447 +-- truncate_limit: 100 +-- left join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a ..." +== 448 +-- truncate_limit: 100 +-- full join; currently we can't do partitioned join if there are no matched +-- partitions on the nullable side +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a ..." +== 449 +-- truncate_limit: 100 +-- Add to plt2_adv the extra NULL partition containing only NULL values as the +-- key values +CREATE TABLE plt2_adv_extra PARTITION OF plt2_adv FOR VALUES IN (NULL) +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_extra PARTITION OF plt2_adv FOR VALUES IN (NULL)" +== 450 +-- truncate_limit: 100 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv VALUES (-1, -1, NULL)" +== 451 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 452 +-- truncate_limit: 100 +-- inner join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 453 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 454 +-- truncate_limit: 100 +-- left join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a ..." +== 455 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 456 +-- truncate_limit: 100 +-- full join +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a ..." +== 457 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE coalesce(t1.b, 0) < 10 AND coalesce(t2.b, 0) < 10 ORDER BY t1.a, t2.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 FULL JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 458 +-- truncate_limit: 100 +-- 3-way join to test the NULL partition of a join relation +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt1_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt1_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv..." +== 459 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt1_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt1_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c LEFT JOIN plt1_a..." +== 460 +-- truncate_limit: 100 +DROP TABLE plt1_adv_extra +-- +TABLE: name="plt1_adv_extra" schema="" table="plt1_adv_extra" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt1_adv_extra" +== 461 +-- truncate_limit: 100 +DROP TABLE plt2_adv_extra +-- +TABLE: name="plt2_adv_extra" schema="" table="plt2_adv_extra" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_extra" +== 462 +-- truncate_limit: 100 +-- Test default partitions +ALTER TABLE plt1_adv DETACH PARTITION plt1_adv_p1 +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt1_adv DETACH PARTITION plt1_adv_p1" +== 463 +-- truncate_limit: 100 +-- Change plt1_adv_p1 to the default partition +ALTER TABLE plt1_adv ATTACH PARTITION plt1_adv_p1 DEFAULT +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt1_adv ATTACH PARTITION plt1_adv_p1 DEFAULT" +== 464 +-- truncate_limit: 100 +DROP TABLE plt1_adv_p3 +-- +TABLE: name="plt1_adv_p3" schema="" table="plt1_adv_p3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt1_adv_p3" +== 465 +-- truncate_limit: 100 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1_adv" +== 466 +-- truncate_limit: 100 +DROP TABLE plt2_adv_p3 +-- +TABLE: name="plt2_adv_p3" schema="" table="plt2_adv_p3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_p3" +== 467 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 468 +-- truncate_limit: 100 +-- We can do partitioned join even if only one of relations has the default +-- partition +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 469 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 470 +-- truncate_limit: 100 +ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2 +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2" +== 471 +-- truncate_limit: 100 +-- Change plt2_adv_p2 to contain '0005' in addition to '0004' and '0006' as +-- the key values +CREATE TABLE plt2_adv_p2_ext PARTITION OF plt2_adv FOR VALUES IN ('0004', '0005', '0006') +-- +TABLE: name="plt2_adv_p2_ext" schema="" table="plt2_adv_p2_ext" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p2_ext PARTITION OF plt2_adv FOR VALUES IN ('0004', '0005', '0006')" +== 472 +-- truncate_limit: 100 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (4, 5, 6) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (4, 5, 6)" +== 473 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 474 +-- truncate_limit: 100 +-- Partitioned join can't be applied because the default partition of plt1_adv +-- matches plt2_adv_p1 and plt2_adv_p2_ext +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 475 +-- truncate_limit: 100 +ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2_ext +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2_adv DETACH PARTITION plt2_adv_p2_ext" +== 476 +-- truncate_limit: 100 +-- Change plt2_adv_p2_ext to the default partition +ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2_ext DEFAULT +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2_ext DEFAULT" +== 477 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 478 +-- truncate_limit: 100 +-- Partitioned join can't be applied because the default partition of plt1_adv +-- matches plt2_adv_p1 and plt2_adv_p2_ext +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 479 +-- truncate_limit: 100 +DROP TABLE plt2_adv_p2_ext +-- +TABLE: name="plt2_adv_p2_ext" schema="" table="plt2_adv_p2_ext" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_p2_ext" +== 480 +-- truncate_limit: 100 +-- Restore plt2_adv_p2 +ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2 FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE plt2_adv ATTACH PARTITION plt2_adv_p2 FOR VALUES IN ('0004', '0006')" +== 481 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 482 +-- truncate_limit: 100 +CREATE TABLE plt3_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt3_adv (a int, b int, c text) PARTITION BY LIST (c)" +== 483 +-- truncate_limit: 100 +CREATE TABLE plt3_adv_p1 PARTITION OF plt3_adv FOR VALUES IN ('0004', '0006') +-- +TABLE: name="plt3_adv_p1" schema="" table="plt3_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt3_adv_p1 PARTITION OF plt3_adv FOR VALUES IN ('0004', '0006')" +== 484 +-- truncate_limit: 100 +CREATE TABLE plt3_adv_p2 PARTITION OF plt3_adv FOR VALUES IN ('0007', '0009') +-- +TABLE: name="plt3_adv_p2" schema="" table="plt3_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt3_adv_p2 PARTITION OF plt3_adv FOR VALUES IN ('0007', '0009')" +== 485 +-- truncate_limit: 100 +INSERT INTO plt3_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (4, 6, 7, 9) +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt3_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (4, 6, 7, 9)" +== 486 +-- truncate_limit: 100 +ANALYZE plt3_adv +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt3_adv" +== 487 +-- truncate_limit: 100 +-- 3-way join to test the default partition of a join relation +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt3_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt3_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv..." +== 488 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt3_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt3_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c LEFT JOIN plt3_a..." +== 489 +-- truncate_limit: 100 +-- Test cases where one side has the default partition while the other side +-- has the NULL partition +DROP TABLE plt2_adv_p1 +-- +TABLE: name="plt2_adv_p1" schema="" table="plt2_adv_p1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_p1" +== 490 +-- truncate_limit: 100 +-- Add the NULL partition to plt2_adv +CREATE TABLE plt2_adv_p1_null PARTITION OF plt2_adv FOR VALUES IN (NULL, '0001', '0003') +-- +TABLE: name="plt2_adv_p1_null" schema="" table="plt2_adv_p1_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p1_null PARTITION OF plt2_adv FOR VALUES IN (NULL, '0001', '0003')" +== 491 +-- truncate_limit: 100 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (1, 3)" +== 492 +-- truncate_limit: 100 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv VALUES (-1, -1, NULL)" +== 493 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 494 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 495 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 496 +-- truncate_limit: 100 +DROP TABLE plt2_adv_p1_null +-- +TABLE: name="plt2_adv_p1_null" schema="" table="plt2_adv_p1_null" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv_p1_null" +== 497 +-- truncate_limit: 100 +-- Add the NULL partition that contains only NULL values as the key values +CREATE TABLE plt2_adv_p1_null PARTITION OF plt2_adv FOR VALUES IN (NULL) +-- +TABLE: name="plt2_adv_p1_null" schema="" table="plt2_adv_p1_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p1_null PARTITION OF plt2_adv FOR VALUES IN (NULL)" +== 498 +-- truncate_limit: 100 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv VALUES (-1, -1, NULL)" +== 499 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 500 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 501 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 502 +-- truncate_limit: 100 +DROP TABLE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt1_adv" +== 503 +-- truncate_limit: 100 +DROP TABLE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv" +== 504 +-- truncate_limit: 100 +DROP TABLE plt3_adv +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt3_adv" +== 505 +-- truncate_limit: 100 +-- Test interaction of partitioned join with partition pruning +CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c)" +== 506 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0001') +-- +TABLE: name="plt1_adv_p1" schema="" table="plt1_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0001')" +== 507 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0002') +-- +TABLE: name="plt1_adv_p2" schema="" table="plt1_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0002')" +== 508 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p3 PARTITION OF plt1_adv FOR VALUES IN ('0003') +-- +TABLE: name="plt1_adv_p3" schema="" table="plt1_adv_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p3 PARTITION OF plt1_adv FOR VALUES IN ('0003')" +== 509 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p4 PARTITION OF plt1_adv FOR VALUES IN (NULL, '0004', '0005') +-- +TABLE: name="plt1_adv_p4" schema="" table="plt1_adv_p4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p4 PARTITION OF plt1_adv FOR VALUES IN (NULL, '0004', '0005')" +== 510 +-- truncate_limit: 100 +INSERT INTO plt1_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 2, 3, 4, 5) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (1, 2, 3, 4, 5)" +== 511 +-- truncate_limit: 100 +INSERT INTO plt1_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1_adv VALUES (-1, -1, NULL)" +== 512 +-- truncate_limit: 100 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1_adv" +== 513 +-- truncate_limit: 100 +CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c)" +== 514 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0001', '0002') +-- +TABLE: name="plt2_adv_p1" schema="" table="plt2_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0001', '0002')" +== 515 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN (NULL) +-- +TABLE: name="plt2_adv_p2" schema="" table="plt2_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN (NULL)" +== 516 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p3 PARTITION OF plt2_adv FOR VALUES IN ('0003') +-- +TABLE: name="plt2_adv_p3" schema="" table="plt2_adv_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p3 PARTITION OF plt2_adv FOR VALUES IN ('0003')" +== 517 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p4 PARTITION OF plt2_adv FOR VALUES IN ('0004', '0005') +-- +TABLE: name="plt2_adv_p4" schema="" table="plt2_adv_p4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p4 PARTITION OF plt2_adv FOR VALUES IN ('0004', '0005')" +== 518 +-- truncate_limit: 100 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 10, 'FM0000') FROM generate_series(1, 299) i WHERE i % 10 IN (1, 2, 3, 4, 5) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv SELECT ... FROM generate_series(1, 299) i WHERE i % 10 IN (1, 2, 3, 4, 5)" +== 519 +-- truncate_limit: 100 +INSERT INTO plt2_adv VALUES (-1, -1, NULL) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv VALUES (-1, -1, NULL)" +== 520 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 521 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IN ('0003', '0004', '0005') AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 522 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IN ('0003', '0004', '0005') AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 523 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IS NULL AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a ..." +== 524 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IS NULL AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 525 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_default PARTITION OF plt1_adv DEFAULT +-- +TABLE: name="plt1_adv_default" schema="" table="plt1_adv_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_default PARTITION OF plt1_adv DEFAULT" +== 526 +-- truncate_limit: 100 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1_adv" +== 527 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_default PARTITION OF plt2_adv DEFAULT +-- +TABLE: name="plt2_adv_default" schema="" table="plt2_adv_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_default PARTITION OF plt2_adv DEFAULT" +== 528 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 529 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IN ('0003', '0004', '0005') AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2...." +== 530 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 INNER JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IN ('0003', '0004', '0005') AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a" +== 531 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IS NULL AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a ..." +== 532 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE t1.c IS NULL AND t1.b < 10 ORDER BY t1.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +FILTER: schema="" table="t1" column="c" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER ..." +== 533 +-- truncate_limit: 100 +DROP TABLE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt1_adv" +== 534 +-- truncate_limit: 100 +DROP TABLE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv" +== 535 +-- truncate_limit: 100 +-- Test the process_outer_partition() code path +CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv (a int, b int, c text) PARTITION BY LIST (c)" +== 536 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0000', '0001', '0002') +-- +TABLE: name="plt1_adv_p1" schema="" table="plt1_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p1 PARTITION OF plt1_adv FOR VALUES IN ('0000', '0001', '0002')" +== 537 +-- truncate_limit: 100 +CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0003', '0004') +-- +TABLE: name="plt1_adv_p2" schema="" table="plt1_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt1_adv_p2 PARTITION OF plt1_adv FOR VALUES IN ('0003', '0004')" +== 538 +-- truncate_limit: 100 +INSERT INTO plt1_adv SELECT i, i, to_char(i % 5, 'FM0000') FROM generate_series(0, 24) i +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt1_adv SELECT i, i, to_char(i % 5, 'FM0000') FROM generate_series(0, 24) i" +== 539 +-- truncate_limit: 100 +ANALYZE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt1_adv" +== 540 +-- truncate_limit: 100 +CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv (a int, b int, c text) PARTITION BY LIST (c)" +== 541 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0002') +-- +TABLE: name="plt2_adv_p1" schema="" table="plt2_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p1 PARTITION OF plt2_adv FOR VALUES IN ('0002')" +== 542 +-- truncate_limit: 100 +CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN ('0003', '0004') +-- +TABLE: name="plt2_adv_p2" schema="" table="plt2_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt2_adv_p2 PARTITION OF plt2_adv FOR VALUES IN ('0003', '0004')" +== 543 +-- truncate_limit: 100 +INSERT INTO plt2_adv SELECT i, i, to_char(i % 5, 'FM0000') FROM generate_series(0, 24) i WHERE i % 5 IN (2, 3, 4) +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt2_adv SELECT ... FROM generate_series(0, 24) i WHERE i % 5 IN (2, 3, 4)" +== 544 +-- truncate_limit: 100 +ANALYZE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt2_adv" +== 545 +-- truncate_limit: 100 +CREATE TABLE plt3_adv (a int, b int, c text) PARTITION BY LIST (c) +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt3_adv (a int, b int, c text) PARTITION BY LIST (c)" +== 546 +-- truncate_limit: 100 +CREATE TABLE plt3_adv_p1 PARTITION OF plt3_adv FOR VALUES IN ('0001') +-- +TABLE: name="plt3_adv_p1" schema="" table="plt3_adv_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt3_adv_p1 PARTITION OF plt3_adv FOR VALUES IN ('0001')" +== 547 +-- truncate_limit: 100 +CREATE TABLE plt3_adv_p2 PARTITION OF plt3_adv FOR VALUES IN ('0003', '0004') +-- +TABLE: name="plt3_adv_p2" schema="" table="plt3_adv_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE plt3_adv_p2 PARTITION OF plt3_adv FOR VALUES IN ('0003', '0004')" +== 548 +-- truncate_limit: 100 +INSERT INTO plt3_adv SELECT i, i, to_char(i % 5, 'FM0000') FROM generate_series(0, 24) i WHERE i % 5 IN (1, 3, 4) +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO plt3_adv SELECT ... FROM generate_series(0, 24) i WHERE i % 5 IN (1, 3, 4)" +== 549 +-- truncate_limit: 100 +ANALYZE plt3_adv +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE plt3_adv" +== 550 +-- truncate_limit: 100 +-- This tests that when merging partitions from plt1_adv and plt2_adv in +-- merge_list_bounds(), process_outer_partition() returns an already-assigned +-- merged partition when re-called with plt1_adv_p1 for the second list value +-- '0001' of that partition +EXPLAIN (COSTS OFF) +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM (plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.c = t2.c)) FULL JOIN plt3_adv t3 ON (t1.c = t3.c) WHERE coalesce(t1.a, 0) % 5 != 3 AND coalesce(t1.a, 0) % 5 != 4 ORDER BY t1.c, t1.a, t2.a, t3.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt3_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv..." +== 551 +-- truncate_limit: 100 +SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM (plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.c = t2.c)) FULL JOIN plt3_adv t3 ON (t1.c = t3.c) WHERE coalesce(t1.a, 0) % 5 != 3 AND coalesce(t1.a, 0) % 5 != 4 ORDER BY t1.c, t1.a, t2.a, t3.a +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=Select +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=Select +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=Select +ALIAS: "t1"="plt1_adv" +ALIAS: "t2"="plt2_adv" +ALIAS: "t3"="plt3_adv" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t1" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON t1.c = t2.c FULL JOIN plt3_adv t3 ON t1.c = ..." +== 552 +-- truncate_limit: 100 +DROP TABLE plt1_adv +-- +TABLE: name="plt1_adv" schema="" table="plt1_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt1_adv" +== 553 +-- truncate_limit: 100 +DROP TABLE plt2_adv +-- +TABLE: name="plt2_adv" schema="" table="plt2_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt2_adv" +== 554 +-- truncate_limit: 100 +DROP TABLE plt3_adv +-- +TABLE: name="plt3_adv" schema="" table="plt3_adv" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE plt3_adv" +== 555 +-- truncate_limit: 100 +-- Tests for multi-level partitioned tables +CREATE TABLE alpha (a double precision, b int, c text) PARTITION BY RANGE (a) +-- +TABLE: name="alpha" schema="" table="alpha" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha (a double precision, b int, c text) PARTITION BY RANGE (a)" +== 556 +-- truncate_limit: 100 +CREATE TABLE alpha_neg PARTITION OF alpha FOR VALUES FROM ('-Infinity') TO (0) PARTITION BY RANGE (b) +-- +TABLE: name="alpha_neg" schema="" table="alpha_neg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha_neg PARTITION OF alpha FOR VALUES FROM ('-Infinity') TO (0) PARTITION BY RANGE..." +== 557 +-- truncate_limit: 100 +CREATE TABLE alpha_pos PARTITION OF alpha FOR VALUES FROM (0) TO (10.0) PARTITION BY LIST (c) +-- +TABLE: name="alpha_pos" schema="" table="alpha_pos" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha_pos PARTITION OF alpha FOR VALUES FROM (0) TO (10.0) PARTITION BY LIST (c)" +== 558 +-- truncate_limit: 100 +CREATE TABLE alpha_neg_p1 PARTITION OF alpha_neg FOR VALUES FROM (100) TO (200) +-- +TABLE: name="alpha_neg_p1" schema="" table="alpha_neg_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha_neg_p1 PARTITION OF alpha_neg FOR VALUES FROM (100) TO (200)" +== 559 +-- truncate_limit: 100 +CREATE TABLE alpha_neg_p2 PARTITION OF alpha_neg FOR VALUES FROM (200) TO (300) +-- +TABLE: name="alpha_neg_p2" schema="" table="alpha_neg_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha_neg_p2 PARTITION OF alpha_neg FOR VALUES FROM (200) TO (300)" +== 560 +-- truncate_limit: 100 +CREATE TABLE alpha_neg_p3 PARTITION OF alpha_neg FOR VALUES FROM (300) TO (400) +-- +TABLE: name="alpha_neg_p3" schema="" table="alpha_neg_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha_neg_p3 PARTITION OF alpha_neg FOR VALUES FROM (300) TO (400)" +== 561 +-- truncate_limit: 100 +CREATE TABLE alpha_pos_p1 PARTITION OF alpha_pos FOR VALUES IN ('0001', '0003') +-- +TABLE: name="alpha_pos_p1" schema="" table="alpha_pos_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha_pos_p1 PARTITION OF alpha_pos FOR VALUES IN ('0001', '0003')" +== 562 +-- truncate_limit: 100 +CREATE TABLE alpha_pos_p2 PARTITION OF alpha_pos FOR VALUES IN ('0004', '0006') +-- +TABLE: name="alpha_pos_p2" schema="" table="alpha_pos_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha_pos_p2 PARTITION OF alpha_pos FOR VALUES IN ('0004', '0006')" +== 563 +-- truncate_limit: 100 +CREATE TABLE alpha_pos_p3 PARTITION OF alpha_pos FOR VALUES IN ('0008', '0009') +-- +TABLE: name="alpha_pos_p3" schema="" table="alpha_pos_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alpha_pos_p3 PARTITION OF alpha_pos FOR VALUES IN ('0008', '0009')" +== 564 +-- truncate_limit: 100 +INSERT INTO alpha_neg SELECT -1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(100, 399) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9) +-- +TABLE: name="alpha_neg" schema="" table="alpha_neg" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alpha_neg SELECT ... FROM generate_series(100, 399) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9)" +== 565 +-- truncate_limit: 100 +INSERT INTO alpha_pos SELECT 1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(100, 399) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9) +-- +TABLE: name="alpha_pos" schema="" table="alpha_pos" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alpha_pos SELECT ... FROM generate_series(100, 399) i WHERE i % 10 IN (1, 3, 4, 6, 8, 9)" +== 566 +-- truncate_limit: 100 +ANALYZE alpha +-- +TABLE: name="alpha" schema="" table="alpha" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE alpha" +== 567 +-- truncate_limit: 100 +CREATE TABLE beta (a double precision, b int, c text) PARTITION BY RANGE (a) +-- +TABLE: name="beta" schema="" table="beta" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta (a double precision, b int, c text) PARTITION BY RANGE (a)" +== 568 +-- truncate_limit: 100 +CREATE TABLE beta_neg PARTITION OF beta FOR VALUES FROM (-10.0) TO (0) PARTITION BY RANGE (b) +-- +TABLE: name="beta_neg" schema="" table="beta_neg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta_neg PARTITION OF beta FOR VALUES FROM (-10.0) TO (0) PARTITION BY RANGE (b)" +== 569 +-- truncate_limit: 100 +CREATE TABLE beta_pos PARTITION OF beta FOR VALUES FROM (0) TO ('Infinity') PARTITION BY LIST (c) +-- +TABLE: name="beta_pos" schema="" table="beta_pos" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta_pos PARTITION OF beta FOR VALUES FROM (0) TO ('Infinity') PARTITION BY LIST (c)" +== 570 +-- truncate_limit: 100 +CREATE TABLE beta_neg_p1 PARTITION OF beta_neg FOR VALUES FROM (100) TO (150) +-- +TABLE: name="beta_neg_p1" schema="" table="beta_neg_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta_neg_p1 PARTITION OF beta_neg FOR VALUES FROM (100) TO (150)" +== 571 +-- truncate_limit: 100 +CREATE TABLE beta_neg_p2 PARTITION OF beta_neg FOR VALUES FROM (200) TO (300) +-- +TABLE: name="beta_neg_p2" schema="" table="beta_neg_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta_neg_p2 PARTITION OF beta_neg FOR VALUES FROM (200) TO (300)" +== 572 +-- truncate_limit: 100 +CREATE TABLE beta_neg_p3 PARTITION OF beta_neg FOR VALUES FROM (350) TO (500) +-- +TABLE: name="beta_neg_p3" schema="" table="beta_neg_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta_neg_p3 PARTITION OF beta_neg FOR VALUES FROM (350) TO (500)" +== 573 +-- truncate_limit: 100 +CREATE TABLE beta_pos_p1 PARTITION OF beta_pos FOR VALUES IN ('0002', '0003') +-- +TABLE: name="beta_pos_p1" schema="" table="beta_pos_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta_pos_p1 PARTITION OF beta_pos FOR VALUES IN ('0002', '0003')" +== 574 +-- truncate_limit: 100 +CREATE TABLE beta_pos_p2 PARTITION OF beta_pos FOR VALUES IN ('0004', '0006') +-- +TABLE: name="beta_pos_p2" schema="" table="beta_pos_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta_pos_p2 PARTITION OF beta_pos FOR VALUES IN ('0004', '0006')" +== 575 +-- truncate_limit: 100 +CREATE TABLE beta_pos_p3 PARTITION OF beta_pos FOR VALUES IN ('0007', '0009') +-- +TABLE: name="beta_pos_p3" schema="" table="beta_pos_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE beta_pos_p3 PARTITION OF beta_pos FOR VALUES IN ('0007', '0009')" +== 576 +-- truncate_limit: 100 +INSERT INTO beta_neg SELECT -1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(100, 149) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_neg" schema="" table="beta_neg" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO beta_neg SELECT ... FROM generate_series(100, 149) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9)" +== 577 +-- truncate_limit: 100 +INSERT INTO beta_neg SELECT -1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(200, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_neg" schema="" table="beta_neg" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO beta_neg SELECT ... FROM generate_series(200, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9)" +== 578 +-- truncate_limit: 100 +INSERT INTO beta_neg SELECT -1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(350, 499) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_neg" schema="" table="beta_neg" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO beta_neg SELECT ... FROM generate_series(350, 499) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9)" +== 579 +-- truncate_limit: 100 +INSERT INTO beta_pos SELECT 1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(100, 149) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_pos" schema="" table="beta_pos" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO beta_pos SELECT ... FROM generate_series(100, 149) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9)" +== 580 +-- truncate_limit: 100 +INSERT INTO beta_pos SELECT 1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(200, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_pos" schema="" table="beta_pos" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO beta_pos SELECT ... FROM generate_series(200, 299) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9)" +== 581 +-- truncate_limit: 100 +INSERT INTO beta_pos SELECT 1.0, i, to_char(i % 10, 'FM0000') FROM generate_series(350, 499) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9) +-- +TABLE: name="beta_pos" schema="" table="beta_pos" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO beta_pos SELECT ... FROM generate_series(350, 499) i WHERE i % 10 IN (2, 3, 4, 6, 7, 9)" +== 582 +-- truncate_limit: 100 +ANALYZE beta +-- +TABLE: name="beta" schema="" table="beta" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE beta" +== 583 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.b = t2.b) WHERE t1.b >= 125 AND t1.b < 225 ORDER BY t1.a, t1.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.*, t2.* FROM alpha t1 JOIN beta t2 ON t1.a = t2.a AND t1.b = t2.b W..." +== 584 +-- truncate_limit: 100 +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.b = t2.b) WHERE t1.b >= 125 AND t1.b < 225 ORDER BY t1.a, t1.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM alpha t1 JOIN beta t2 ON t1.a = t2.a AND t1.b = t2.b WHERE ... ORDER BY t1.a, t1.b" +== 585 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE ((t1.b >= 100 AND t1.b < 110) OR (t1.b >= 200 AND t1.b < 210)) AND ((t2.b >= 100 AND t2.b < 110) OR (t2.b >= 200 AND t2.b < 210)) AND t1.c IN ('0004', '0009') ORDER BY t1.a, t1.b, t2.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.*, t2.* FROM alpha t1 JOIN beta t2 ON t1.a = t2.a AND t1.c = t2.c W..." +== 586 +-- truncate_limit: 100 +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.c = t2.c) WHERE ((t1.b >= 100 AND t1.b < 110) OR (t1.b >= 200 AND t1.b < 210)) AND ((t2.b >= 100 AND t2.b < 110) OR (t2.b >= 200 AND t2.b < 210)) AND t1.c IN ('0004', '0009') ORDER BY t1.a, t1.b, t2.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM alpha t1 JOIN beta t2 ON t1.a = t2.a AND t1.c = t2.c WHERE ... ORDER BY t1.a, t1...." +== 587 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.b = t2.b AND t1.c = t2.c) WHERE ((t1.b >= 100 AND t1.b < 110) OR (t1.b >= 200 AND t1.b < 210)) AND ((t2.b >= 100 AND t2.b < 110) OR (t2.b >= 200 AND t2.b < 210)) AND t1.c IN ('0004', '0009') ORDER BY t1.a, t1.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.*, t2.* FROM alpha t1 JOIN beta t2 ON t1.a = t2.a AND t1.b = t2.b A..." +== 588 +-- truncate_limit: 100 +SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.b = t2.b AND t1.c = t2.c) WHERE ((t1.b >= 100 AND t1.b < 110) OR (t1.b >= 200 AND t1.b < 210)) AND ((t2.b >= 100 AND t2.b < 110) OR (t2.b >= 200 AND t2.b < 210)) AND t1.c IN ('0004', '0009') ORDER BY t1.a, t1.b +-- +TABLE: name="alpha" schema="" table="alpha" ctx=Select +TABLE: name="beta" schema="" table="beta" ctx=Select +ALIAS: "t1"="alpha" +ALIAS: "t2"="beta" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t1" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM alpha t1 JOIN beta t2 ON t1.a = t2.a AND t1.b = t2.b AND t1.c = t2.c WHERE ... OR..." +== 589 +-- truncate_limit: 100 +-- partitionwise join with fractional paths +CREATE TABLE fract_t (id BIGINT, PRIMARY KEY (id)) PARTITION BY RANGE (id) +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fract_t (id bigint, PRIMARY KEY (id)) PARTITION BY RANGE (id)" +== 590 +-- truncate_limit: 100 +CREATE TABLE fract_t0 PARTITION OF fract_t FOR VALUES FROM ('0') TO ('1000') +-- +TABLE: name="fract_t0" schema="" table="fract_t0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fract_t0 PARTITION OF fract_t FOR VALUES FROM ('0') TO ('1000')" +== 591 +-- truncate_limit: 100 +CREATE TABLE fract_t1 PARTITION OF fract_t FOR VALUES FROM ('1000') TO ('2000') +-- +TABLE: name="fract_t1" schema="" table="fract_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fract_t1 PARTITION OF fract_t FOR VALUES FROM ('1000') TO ('2000')" +== 592 +-- truncate_limit: 100 +-- insert data +INSERT INTO fract_t (id) (SELECT generate_series(0, 1999)) +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fract_t (id) SELECT generate_series(0, 1999)" +== 593 +-- truncate_limit: 100 +ANALYZE fract_t +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE fract_t" +== 594 +-- truncate_limit: 100 +-- verify plan; nested index only scans +SET max_parallel_workers_per_gather = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 0" +== 595 +-- truncate_limit: 100 +SET enable_partitionwise_join = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partitionwise_join TO ON" +== 596 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id ASC LIMIT 10 +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=Select +TABLE: name="fract_t" schema="" table="fract_t" ctx=Select +ALIAS: "x"="fract_t" +ALIAS: "y"="fract_t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id..." +== 597 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id DESC LIMIT 10 +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=Select +TABLE: name="fract_t" schema="" table="fract_t" ctx=Select +ALIAS: "x"="fract_t" +ALIAS: "y"="fract_t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id..." +== 598 +-- truncate_limit: 100 +-- cleanup +DROP TABLE fract_t +-- +TABLE: name="fract_t" schema="" table="fract_t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fract_t" +== 599 +-- truncate_limit: 100 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers_per_gather" +== 600 +-- truncate_limit: 100 +RESET enable_partitionwise_join +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_partitionwise_join" diff --git a/parser/testdata/summary_truncate/postgres_regress/partition_prune.metadata.json b/parser/testdata/summary_truncate/postgres_regress/partition_prune.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/partition_prune.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/partition_prune.test b/parser/testdata/summary_truncate/postgres_regress/partition_prune.test new file mode 100644 index 0000000..13b75fe --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/partition_prune.test @@ -0,0 +1,6029 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test partitioning planner code +|-- + +-- Force generic plans to be used for all prepared statements in this file. +set plan_cache_mode = force_generic_plan +-- +STMT: VariableSetStmt +TRUNCATED: "SET plan_cache_mode TO force_generic_plan" +== 002 +-- truncate_limit: 100 +create table lp (a char) partition by list (a) +-- +TABLE: name="lp" schema="" table="lp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lp (a char(1)) PARTITION BY LIST (a)" +== 003 +-- truncate_limit: 100 +create table lp_default partition of lp default +-- +TABLE: name="lp_default" schema="" table="lp_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lp_default PARTITION OF lp DEFAULT" +== 004 +-- truncate_limit: 100 +create table lp_ef partition of lp for values in ('e', 'f') +-- +TABLE: name="lp_ef" schema="" table="lp_ef" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lp_ef PARTITION OF lp FOR VALUES IN ('e', 'f')" +== 005 +-- truncate_limit: 100 +create table lp_ad partition of lp for values in ('a', 'd') +-- +TABLE: name="lp_ad" schema="" table="lp_ad" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lp_ad PARTITION OF lp FOR VALUES IN ('a', 'd')" +== 006 +-- truncate_limit: 100 +create table lp_bc partition of lp for values in ('b', 'c') +-- +TABLE: name="lp_bc" schema="" table="lp_bc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lp_bc PARTITION OF lp FOR VALUES IN ('b', 'c')" +== 007 +-- truncate_limit: 100 +create table lp_g partition of lp for values in ('g') +-- +TABLE: name="lp_g" schema="" table="lp_g" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lp_g PARTITION OF lp FOR VALUES IN ('g')" +== 008 +-- truncate_limit: 100 +create table lp_null partition of lp for values in (null) +-- +TABLE: name="lp_null" schema="" table="lp_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lp_null PARTITION OF lp FOR VALUES IN (NULL)" +== 009 +-- truncate_limit: 100 +explain (costs off) select * from lp +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp" +== 010 +-- truncate_limit: 100 +explain (costs off) select * from lp where a > 'a' and a < 'd' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a > 'a' AND a < 'd'" +== 011 +-- truncate_limit: 100 +explain (costs off) select * from lp where a > 'a' and a <= 'd' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a > 'a' AND a <= 'd'" +== 012 +-- truncate_limit: 100 +explain (costs off) select * from lp where a = 'a' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a = 'a'" +== 013 +-- truncate_limit: 100 +explain (costs off) select * from lp where 'a' = a +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE 'a' = a" +== 014 +-- truncate_limit: 100 +/* commuted */ +explain (costs off) select * from lp where a is not null +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a IS NOT NULL" +== 015 +-- truncate_limit: 100 +explain (costs off) select * from lp where a is null +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a IS NULL" +== 016 +-- truncate_limit: 100 +explain (costs off) select * from lp where a = 'a' or a = 'c' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a = 'a' OR a = 'c'" +== 017 +-- truncate_limit: 100 +explain (costs off) select * from lp where a is not null and (a = 'a' or a = 'c') +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a IS NOT NULL AND (a = 'a' OR a = 'c')" +== 018 +-- truncate_limit: 100 +explain (costs off) select * from lp where a <> 'g' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a <> 'g'" +== 019 +-- truncate_limit: 100 +explain (costs off) select * from lp where a <> 'a' and a <> 'd' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a <> 'a' AND a <> 'd'" +== 020 +-- truncate_limit: 100 +explain (costs off) select * from lp where a not in ('a', 'd') +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a NOT IN ('a', 'd')" +== 021 +-- truncate_limit: 100 +-- collation matches the partitioning collation, pruning works +create table coll_pruning (a text collate "C") partition by list (a) +-- +TABLE: name="coll_pruning" schema="" table="coll_pruning" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coll_pruning (a text COLLATE \"C\") PARTITION BY LIST (a)" +== 022 +-- truncate_limit: 100 +create table coll_pruning_a partition of coll_pruning for values in ('a') +-- +TABLE: name="coll_pruning_a" schema="" table="coll_pruning_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coll_pruning_a PARTITION OF coll_pruning FOR VALUES IN ('a')" +== 023 +-- truncate_limit: 100 +create table coll_pruning_b partition of coll_pruning for values in ('b') +-- +TABLE: name="coll_pruning_b" schema="" table="coll_pruning_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coll_pruning_b PARTITION OF coll_pruning FOR VALUES IN ('b')" +== 024 +-- truncate_limit: 100 +create table coll_pruning_def partition of coll_pruning default +-- +TABLE: name="coll_pruning_def" schema="" table="coll_pruning_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coll_pruning_def PARTITION OF coll_pruning DEFAULT" +== 025 +-- truncate_limit: 100 +explain (costs off) select * from coll_pruning where a collate "C" = 'a' collate "C" +-- +TABLE: name="coll_pruning" schema="" table="coll_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coll_pruning WHERE a COLLATE \"C\" = 'a' COLLATE \"C\"" +== 026 +-- truncate_limit: 100 +-- collation doesn't match the partitioning collation, no pruning occurs +explain (costs off) select * from coll_pruning where a collate "POSIX" = 'a' collate "POSIX" +-- +TABLE: name="coll_pruning" schema="" table="coll_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coll_pruning WHERE a COLLATE \"POSIX\" = 'a' COLLATE \"POSIX\"" +== 027 +-- truncate_limit: 100 +create table rlp (a int, b varchar) partition by range (a) +-- +TABLE: name="rlp" schema="" table="rlp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp (a int, b varchar) PARTITION BY RANGE (a)" +== 028 +-- truncate_limit: 100 +create table rlp_default partition of rlp default partition by list (a) +-- +TABLE: name="rlp_default" schema="" table="rlp_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp_default PARTITION OF rlp DEFAULT PARTITION BY LIST (a)" +== 029 +-- truncate_limit: 100 +create table rlp_default_default partition of rlp_default default +-- +TABLE: name="rlp_default_default" schema="" table="rlp_default_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp_default_default PARTITION OF rlp_default DEFAULT" +== 030 +-- truncate_limit: 100 +create table rlp_default_10 partition of rlp_default for values in (10) +-- +TABLE: name="rlp_default_10" schema="" table="rlp_default_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp_default_10 PARTITION OF rlp_default FOR VALUES IN (10)" +== 031 +-- truncate_limit: 100 +create table rlp_default_30 partition of rlp_default for values in (30) +-- +TABLE: name="rlp_default_30" schema="" table="rlp_default_30" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp_default_30 PARTITION OF rlp_default FOR VALUES IN (30)" +== 032 +-- truncate_limit: 100 +create table rlp_default_null partition of rlp_default for values in (null) +-- +TABLE: name="rlp_default_null" schema="" table="rlp_default_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp_default_null PARTITION OF rlp_default FOR VALUES IN (NULL)" +== 033 +-- truncate_limit: 100 +create table rlp1 partition of rlp for values from (minvalue) to (1) +-- +TABLE: name="rlp1" schema="" table="rlp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp1 PARTITION OF rlp FOR VALUES FROM (minvalue) TO (1)" +== 034 +-- truncate_limit: 100 +create table rlp2 partition of rlp for values from (1) to (10) +-- +TABLE: name="rlp2" schema="" table="rlp2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp2 PARTITION OF rlp FOR VALUES FROM (1) TO (10)" +== 035 +-- truncate_limit: 100 +create table rlp3 (b varchar, a int) partition by list (b varchar_ops) +-- +TABLE: name="rlp3" schema="" table="rlp3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp3 (b varchar, a int) PARTITION BY LIST (b varchar_ops)" +== 036 +-- truncate_limit: 100 +create table rlp3_default partition of rlp3 default +-- +TABLE: name="rlp3_default" schema="" table="rlp3_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp3_default PARTITION OF rlp3 DEFAULT" +== 037 +-- truncate_limit: 100 +create table rlp3abcd partition of rlp3 for values in ('ab', 'cd') +-- +TABLE: name="rlp3abcd" schema="" table="rlp3abcd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp3abcd PARTITION OF rlp3 FOR VALUES IN ('ab', 'cd')" +== 038 +-- truncate_limit: 100 +create table rlp3efgh partition of rlp3 for values in ('ef', 'gh') +-- +TABLE: name="rlp3efgh" schema="" table="rlp3efgh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp3efgh PARTITION OF rlp3 FOR VALUES IN ('ef', 'gh')" +== 039 +-- truncate_limit: 100 +create table rlp3nullxy partition of rlp3 for values in (null, 'xy') +-- +TABLE: name="rlp3nullxy" schema="" table="rlp3nullxy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp3nullxy PARTITION OF rlp3 FOR VALUES IN (NULL, 'xy')" +== 040 +-- truncate_limit: 100 +alter table rlp attach partition rlp3 for values from (15) to (20) +-- +TABLE: name="rlp" schema="" table="rlp" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rlp ATTACH PARTITION rlp3 FOR VALUES FROM (15) TO (20)" +== 041 +-- truncate_limit: 100 +create table rlp4 partition of rlp for values from (20) to (30) partition by range (a) +-- +TABLE: name="rlp4" schema="" table="rlp4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp4 PARTITION OF rlp FOR VALUES FROM (20) TO (30) PARTITION BY RANGE (a)" +== 042 +-- truncate_limit: 100 +create table rlp4_default partition of rlp4 default +-- +TABLE: name="rlp4_default" schema="" table="rlp4_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp4_default PARTITION OF rlp4 DEFAULT" +== 043 +-- truncate_limit: 100 +create table rlp4_1 partition of rlp4 for values from (20) to (25) +-- +TABLE: name="rlp4_1" schema="" table="rlp4_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp4_1 PARTITION OF rlp4 FOR VALUES FROM (20) TO (25)" +== 044 +-- truncate_limit: 100 +create table rlp4_2 partition of rlp4 for values from (25) to (29) +-- +TABLE: name="rlp4_2" schema="" table="rlp4_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp4_2 PARTITION OF rlp4 FOR VALUES FROM (25) TO (29)" +== 045 +-- truncate_limit: 100 +create table rlp5 partition of rlp for values from (31) to (maxvalue) partition by range (a) +-- +TABLE: name="rlp5" schema="" table="rlp5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp5 PARTITION OF rlp FOR VALUES FROM (31) TO (maxvalue) PARTITION BY RANGE (a)" +== 046 +-- truncate_limit: 100 +create table rlp5_default partition of rlp5 default +-- +TABLE: name="rlp5_default" schema="" table="rlp5_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp5_default PARTITION OF rlp5 DEFAULT" +== 047 +-- truncate_limit: 100 +create table rlp5_1 partition of rlp5 for values from (31) to (40) +-- +TABLE: name="rlp5_1" schema="" table="rlp5_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rlp5_1 PARTITION OF rlp5 FOR VALUES FROM (31) TO (40)" +== 048 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a < 1 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a < 1" +== 049 +-- truncate_limit: 100 +explain (costs off) select * from rlp where 1 > a +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE 1 > a" +== 050 +-- truncate_limit: 100 +/* commuted */ +explain (costs off) select * from rlp where a <= 1 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a <= 1" +== 051 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 1 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 1" +== 052 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 1::bigint +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 1::bigint" +== 053 +-- truncate_limit: 100 +/* same as above */ +explain (costs off) select * from rlp where a = 1::numeric +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 1::numeric" +== 054 +-- truncate_limit: 100 +/* no pruning */ +explain (costs off) select * from rlp where a <= 10 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a <= 10" +== 055 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a > 10 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a > 10" +== 056 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a < 15 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a < 15" +== 057 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a <= 15 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a <= 15" +== 058 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a > 15 and b = 'ab' +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a > 15 AND b = 'ab'" +== 059 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 16 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 16" +== 060 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 16 and b in ('not', 'in', 'here') +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 16 AND b IN ('not', 'in', 'here')" +== 061 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 16 and b < 'ab' +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 16 AND b < 'ab'" +== 062 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 16 and b <= 'ab' +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 16 AND b <= 'ab'" +== 063 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 16 and b is null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 16 AND b IS NULL" +== 064 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 16 and b is not null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 16 AND b IS NOT NULL" +== 065 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a is null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a IS NULL" +== 066 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a is not null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a IS NOT NULL" +== 067 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a > 30 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a > 30" +== 068 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 30 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 30" +== 069 +-- truncate_limit: 100 +/* only default is scanned */ +explain (costs off) select * from rlp where a <= 31 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a <= 31" +== 070 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 1 or a = 7 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 1 OR a = 7" +== 071 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 1 or b = 'ab' +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 1 OR b = 'ab'" +== 072 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a > 20 and a < 27 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a > 20 AND a < 27" +== 073 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a = 29 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 29" +== 074 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a >= 29 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a >= 29" +== 075 +-- truncate_limit: 100 +explain (costs off) select * from rlp where a < 1 or (a > 20 and a < 25) +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a < 1 OR (a > 20 AND a < 25)" +== 076 +-- truncate_limit: 100 +-- where clause contradicts sub-partition's constraint +explain (costs off) select * from rlp where a = 20 or a = 40 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 20 OR a = 40" +== 077 +-- truncate_limit: 100 +explain (costs off) select * from rlp3 where a = 20 +-- +TABLE: name="rlp3" schema="" table="rlp3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp3 WHERE a = 20" +== 078 +-- truncate_limit: 100 +/* empty */ + +-- redundant clauses are eliminated +explain (costs off) select * from rlp where a > 1 and a = 10 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a > 1 AND a = 10" +== 079 +-- truncate_limit: 100 +/* only default */ +explain (costs off) select * from rlp where a > 1 and a >=15 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a > 1 AND a >= 15" +== 080 +-- truncate_limit: 100 +/* rlp3 onwards, including default */ +explain (costs off) select * from rlp where a = 1 and a = 3 +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 1 AND a = 3" +== 081 +-- truncate_limit: 100 +/* empty */ +explain (costs off) select * from rlp where (a = 1 and a = 3) or (a > 1 and a = 15) +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE (a = 1 AND a = 3) OR (a > 1 AND a = 15)" +== 082 +-- truncate_limit: 100 +-- multi-column keys +create table mc3p (a int, b int, c int) partition by range (a, abs(b), c) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p (a int, b int, c int) PARTITION BY RANGE (a, (abs(b)), c)" +== 083 +-- truncate_limit: 100 +create table mc3p_default partition of mc3p default +-- +TABLE: name="mc3p_default" schema="" table="mc3p_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p_default PARTITION OF mc3p DEFAULT" +== 084 +-- truncate_limit: 100 +create table mc3p0 partition of mc3p for values from (minvalue, minvalue, minvalue) to (1, 1, 1) +-- +TABLE: name="mc3p0" schema="" table="mc3p0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p0 PARTITION OF mc3p FOR VALUES FROM (minvalue, minvalue, minvalue) TO (1, 1, 1)" +== 085 +-- truncate_limit: 100 +create table mc3p1 partition of mc3p for values from (1, 1, 1) to (10, 5, 10) +-- +TABLE: name="mc3p1" schema="" table="mc3p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p1 PARTITION OF mc3p FOR VALUES FROM (1, 1, 1) TO (10, 5, 10)" +== 086 +-- truncate_limit: 100 +create table mc3p2 partition of mc3p for values from (10, 5, 10) to (10, 10, 10) +-- +TABLE: name="mc3p2" schema="" table="mc3p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p2 PARTITION OF mc3p FOR VALUES FROM (10, 5, 10) TO (10, 10, 10)" +== 087 +-- truncate_limit: 100 +create table mc3p3 partition of mc3p for values from (10, 10, 10) to (10, 10, 20) +-- +TABLE: name="mc3p3" schema="" table="mc3p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p3 PARTITION OF mc3p FOR VALUES FROM (10, 10, 10) TO (10, 10, 20)" +== 088 +-- truncate_limit: 100 +create table mc3p4 partition of mc3p for values from (10, 10, 20) to (10, maxvalue, maxvalue) +-- +TABLE: name="mc3p4" schema="" table="mc3p4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p4 PARTITION OF mc3p FOR VALUES FROM (10, 10, 20) TO (10, maxvalue, maxvalue)" +== 089 +-- truncate_limit: 100 +create table mc3p5 partition of mc3p for values from (11, 1, 1) to (20, 10, 10) +-- +TABLE: name="mc3p5" schema="" table="mc3p5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p5 PARTITION OF mc3p FOR VALUES FROM (11, 1, 1) TO (20, 10, 10)" +== 090 +-- truncate_limit: 100 +create table mc3p6 partition of mc3p for values from (20, 10, 10) to (20, 20, 20) +-- +TABLE: name="mc3p6" schema="" table="mc3p6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p6 PARTITION OF mc3p FOR VALUES FROM (20, 10, 10) TO (20, 20, 20)" +== 091 +-- truncate_limit: 100 +create table mc3p7 partition of mc3p for values from (20, 20, 20) to (maxvalue, maxvalue, maxvalue) +-- +TABLE: name="mc3p7" schema="" table="mc3p7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p7 PARTITION OF mc3p FOR VALUES FROM (20, 20, 20) TO (maxvalue, maxvalue, maxvalue)" +== 092 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a = 1" +== 093 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a = 1 and abs(b) < 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a = 1 AND abs(b) < 1" +== 094 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a = 1 and abs(b) = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a = 1 AND abs(b) = 1" +== 095 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a = 1 and abs(b) = 1 and c < 8 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a = 1 AND abs(b) = 1 AND c < 8" +== 096 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a = 10 and abs(b) between 5 and 35 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a = 10 AND abs(b) BETWEEN 5 AND 35" +== 097 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a > 10 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a > 10" +== 098 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a >= 10 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a >= 10" +== 099 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a < 10 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a < 10" +== 100 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a <= 10 and abs(b) < 10 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a <= 10 AND abs(b) < 10" +== 101 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a = 11 and abs(b) = 0 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a = 11 AND abs(b) = 0" +== 102 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a = 20 and abs(b) = 10 and c = 100 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a = 20 AND abs(b) = 10 AND c = 100" +== 103 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a > 20 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a > 20" +== 104 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a >= 20 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a >= 20" +== 105 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1 and c = 1) or (a = 10 and abs(b) = 5 and c = 10) or (a > 11 and a < 20) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE (a = 1 AND abs(b) = 1 AND c = 1) OR (a = 10 AND abs(..." +== 106 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1 and c = 1) or (a = 10 and abs(b) = 5 and c = 10) or (a > 11 and a < 20) or a < 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE (a = 1 AND abs(b) = 1 AND c = 1) OR (a = 10 AND abs(..." +== 107 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1 and c = 1) or (a = 10 and abs(b) = 5 and c = 10) or (a > 11 and a < 20) or a < 1 or a = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE (a = 1 AND abs(b) = 1 AND c = 1) OR (a = 10 AND abs(..." +== 108 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where a = 1 or abs(b) = 1 or c = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE a = 1 OR abs(b) = 1 OR c = 1" +== 109 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1) or (a = 10 and abs(b) = 10) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE (a = 1 AND abs(b) = 1) OR (a = 10 AND abs(b) = 10)" +== 110 +-- truncate_limit: 100 +explain (costs off) select * from mc3p where (a = 1 and abs(b) = 1) or (a = 10 and abs(b) = 9) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc3p WHERE (a = 1 AND abs(b) = 1) OR (a = 10 AND abs(b) = 9)" +== 111 +-- truncate_limit: 100 +-- a simpler multi-column keys case +create table mc2p (a int, b int) partition by range (a, b) +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc2p (a int, b int) PARTITION BY RANGE (a, b)" +== 112 +-- truncate_limit: 100 +create table mc2p_default partition of mc2p default +-- +TABLE: name="mc2p_default" schema="" table="mc2p_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc2p_default PARTITION OF mc2p DEFAULT" +== 113 +-- truncate_limit: 100 +create table mc2p0 partition of mc2p for values from (minvalue, minvalue) to (1, minvalue) +-- +TABLE: name="mc2p0" schema="" table="mc2p0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc2p0 PARTITION OF mc2p FOR VALUES FROM (minvalue, minvalue) TO (1, minvalue)" +== 114 +-- truncate_limit: 100 +create table mc2p1 partition of mc2p for values from (1, minvalue) to (1, 1) +-- +TABLE: name="mc2p1" schema="" table="mc2p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc2p1 PARTITION OF mc2p FOR VALUES FROM (1, minvalue) TO (1, 1)" +== 115 +-- truncate_limit: 100 +create table mc2p2 partition of mc2p for values from (1, 1) to (2, minvalue) +-- +TABLE: name="mc2p2" schema="" table="mc2p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc2p2 PARTITION OF mc2p FOR VALUES FROM (1, 1) TO (2, minvalue)" +== 116 +-- truncate_limit: 100 +create table mc2p3 partition of mc2p for values from (2, minvalue) to (2, 1) +-- +TABLE: name="mc2p3" schema="" table="mc2p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc2p3 PARTITION OF mc2p FOR VALUES FROM (2, minvalue) TO (2, 1)" +== 117 +-- truncate_limit: 100 +create table mc2p4 partition of mc2p for values from (2, 1) to (2, maxvalue) +-- +TABLE: name="mc2p4" schema="" table="mc2p4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc2p4 PARTITION OF mc2p FOR VALUES FROM (2, 1) TO (2, maxvalue)" +== 118 +-- truncate_limit: 100 +create table mc2p5 partition of mc2p for values from (2, maxvalue) to (maxvalue, maxvalue) +-- +TABLE: name="mc2p5" schema="" table="mc2p5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc2p5 PARTITION OF mc2p FOR VALUES FROM (2, maxvalue) TO (maxvalue, maxvalue)" +== 119 +-- truncate_limit: 100 +explain (costs off) select * from mc2p where a < 2 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE a < 2" +== 120 +-- truncate_limit: 100 +explain (costs off) select * from mc2p where a = 2 and b < 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE a = 2 AND b < 1" +== 121 +-- truncate_limit: 100 +explain (costs off) select * from mc2p where a > 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE a > 1" +== 122 +-- truncate_limit: 100 +explain (costs off) select * from mc2p where a = 1 and b > 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE a = 1 AND b > 1" +== 123 +-- truncate_limit: 100 +-- all partitions but the default one should be pruned +explain (costs off) select * from mc2p where a = 1 and b is null +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE a = 1 AND b IS NULL" +== 124 +-- truncate_limit: 100 +explain (costs off) select * from mc2p where a is null and b is null +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE a IS NULL AND b IS NULL" +== 125 +-- truncate_limit: 100 +explain (costs off) select * from mc2p where a is null and b = 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE a IS NULL AND b = 1" +== 126 +-- truncate_limit: 100 +explain (costs off) select * from mc2p where a is null +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE a IS NULL" +== 127 +-- truncate_limit: 100 +explain (costs off) select * from mc2p where b is null +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p WHERE b IS NULL" +== 128 +-- truncate_limit: 100 +-- boolean partitioning +create table boolpart (a bool) partition by list (a) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolpart (a bool) PARTITION BY LIST (a)" +== 129 +-- truncate_limit: 100 +create table boolpart_default partition of boolpart default +-- +TABLE: name="boolpart_default" schema="" table="boolpart_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolpart_default PARTITION OF boolpart DEFAULT" +== 130 +-- truncate_limit: 100 +create table boolpart_t partition of boolpart for values in ('true') +-- +TABLE: name="boolpart_t" schema="" table="boolpart_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolpart_t PARTITION OF boolpart FOR VALUES IN ('true')" +== 131 +-- truncate_limit: 100 +create table boolpart_f partition of boolpart for values in ('false') +-- +TABLE: name="boolpart_f" schema="" table="boolpart_f" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolpart_f PARTITION OF boolpart FOR VALUES IN ('false')" +== 132 +-- truncate_limit: 100 +insert into boolpart values (true), (false), (null) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO boolpart VALUES (true), (false), (NULL)" +== 133 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a in (true, false) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IN (true, false)" +== 134 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a = false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a = false" +== 135 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where not a = false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE NOT a = false" +== 136 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is true or a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS TRUE OR a IS NOT TRUE" +== 137 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS NOT TRUE" +== 138 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is not true and a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS NOT TRUE AND a IS NOT FALSE" +== 139 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS UNKNOWN" +== 140 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is not unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS NOT UNKNOWN" +== 141 +-- truncate_limit: 100 +select * from boolpart where a in (true, false) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IN (true, false)" +== 142 +-- truncate_limit: 100 +select * from boolpart where a = false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a = false" +== 143 +-- truncate_limit: 100 +select * from boolpart where not a = false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE NOT a = false" +== 144 +-- truncate_limit: 100 +select * from boolpart where a is true or a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS TRUE OR a IS NOT TRUE" +== 145 +-- truncate_limit: 100 +select * from boolpart where a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS NOT TRUE" +== 146 +-- truncate_limit: 100 +select * from boolpart where a is not true and a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS NOT TRUE AND a IS NOT FALSE" +== 147 +-- truncate_limit: 100 +select * from boolpart where a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS UNKNOWN" +== 148 +-- truncate_limit: 100 +select * from boolpart where a is not unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS NOT UNKNOWN" +== 149 +-- truncate_limit: 100 +-- try some other permutations with a NULL partition instead of a DEFAULT +delete from boolpart where a is null +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM boolpart WHERE a IS NULL" +== 150 +-- truncate_limit: 100 +create table boolpart_null partition of boolpart for values in (null) +-- +TABLE: name="boolpart_null" schema="" table="boolpart_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolpart_null PARTITION OF boolpart FOR VALUES IN (NULL)" +== 151 +-- truncate_limit: 100 +insert into boolpart values(null) +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO boolpart VALUES (NULL)" +== 152 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS NOT TRUE" +== 153 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is not true and a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS NOT TRUE AND a IS NOT FALSE" +== 154 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS NOT FALSE" +== 155 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is not unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS NOT UNKNOWN" +== 156 +-- truncate_limit: 100 +select * from boolpart where a is not true +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS NOT TRUE" +== 157 +-- truncate_limit: 100 +select * from boolpart where a is not true and a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS NOT TRUE AND a IS NOT FALSE" +== 158 +-- truncate_limit: 100 +select * from boolpart where a is not false +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS NOT FALSE" +== 159 +-- truncate_limit: 100 +select * from boolpart where a is not unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM boolpart WHERE a IS NOT UNKNOWN" +== 160 +-- truncate_limit: 100 +-- check that all partitions are pruned when faced with conflicting clauses +explain (costs off) select * from boolpart where a is not unknown and a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS NOT UNKNOWN AND a IS UNKNOWN" +== 161 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is false and a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS FALSE AND a IS UNKNOWN" +== 162 +-- truncate_limit: 100 +explain (costs off) select * from boolpart where a is true and a is unknown +-- +TABLE: name="boolpart" schema="" table="boolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolpart WHERE a IS TRUE AND a IS UNKNOWN" +== 163 +-- truncate_limit: 100 +-- inverse boolean partitioning - a seemingly unlikely design, but we've got +-- code for it, so we'd better test it. +create table iboolpart (a bool) partition by list ((not a)) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iboolpart (a bool) PARTITION BY LIST ((NOT a))" +== 164 +-- truncate_limit: 100 +create table iboolpart_default partition of iboolpart default +-- +TABLE: name="iboolpart_default" schema="" table="iboolpart_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iboolpart_default PARTITION OF iboolpart DEFAULT" +== 165 +-- truncate_limit: 100 +create table iboolpart_f partition of iboolpart for values in ('true') +-- +TABLE: name="iboolpart_f" schema="" table="iboolpart_f" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iboolpart_f PARTITION OF iboolpart FOR VALUES IN ('true')" +== 166 +-- truncate_limit: 100 +create table iboolpart_t partition of iboolpart for values in ('false') +-- +TABLE: name="iboolpart_t" schema="" table="iboolpart_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iboolpart_t PARTITION OF iboolpart FOR VALUES IN ('false')" +== 167 +-- truncate_limit: 100 +insert into iboolpart values (true), (false), (null) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iboolpart VALUES (true), (false), (NULL)" +== 168 +-- truncate_limit: 100 +explain (costs off) select * from iboolpart where a in (true, false) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM iboolpart WHERE a IN (true, false)" +== 169 +-- truncate_limit: 100 +explain (costs off) select * from iboolpart where a = false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM iboolpart WHERE a = false" +== 170 +-- truncate_limit: 100 +explain (costs off) select * from iboolpart where not a = false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM iboolpart WHERE NOT a = false" +== 171 +-- truncate_limit: 100 +explain (costs off) select * from iboolpart where a is true or a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM iboolpart WHERE a IS TRUE OR a IS NOT TRUE" +== 172 +-- truncate_limit: 100 +explain (costs off) select * from iboolpart where a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM iboolpart WHERE a IS NOT TRUE" +== 173 +-- truncate_limit: 100 +explain (costs off) select * from iboolpart where a is not true and a is not false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM iboolpart WHERE a IS NOT TRUE AND a IS NOT FALSE" +== 174 +-- truncate_limit: 100 +explain (costs off) select * from iboolpart where a is unknown +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM iboolpart WHERE a IS UNKNOWN" +== 175 +-- truncate_limit: 100 +explain (costs off) select * from iboolpart where a is not unknown +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM iboolpart WHERE a IS NOT UNKNOWN" +== 176 +-- truncate_limit: 100 +select * from iboolpart where a in (true, false) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IN (true, false)" +== 177 +-- truncate_limit: 100 +select * from iboolpart where a = false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a = false" +== 178 +-- truncate_limit: 100 +select * from iboolpart where not a = false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE NOT a = false" +== 179 +-- truncate_limit: 100 +select * from iboolpart where a is true or a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IS TRUE OR a IS NOT TRUE" +== 180 +-- truncate_limit: 100 +select * from iboolpart where a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IS NOT TRUE" +== 181 +-- truncate_limit: 100 +select * from iboolpart where a is not true and a is not false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IS NOT TRUE AND a IS NOT FALSE" +== 182 +-- truncate_limit: 100 +select * from iboolpart where a is unknown +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IS UNKNOWN" +== 183 +-- truncate_limit: 100 +select * from iboolpart where a is not unknown +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IS NOT UNKNOWN" +== 184 +-- truncate_limit: 100 +-- Try some other permutations with a NULL partition instead of a DEFAULT +delete from iboolpart where a is null +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM iboolpart WHERE a IS NULL" +== 185 +-- truncate_limit: 100 +create table iboolpart_null partition of iboolpart for values in (null) +-- +TABLE: name="iboolpart_null" schema="" table="iboolpart_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iboolpart_null PARTITION OF iboolpart FOR VALUES IN (NULL)" +== 186 +-- truncate_limit: 100 +insert into iboolpart values(null) +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iboolpart VALUES (NULL)" +== 187 +-- truncate_limit: 100 +-- Pruning shouldn't take place for these. Just check the result is correct +select * from iboolpart where a is not true +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IS NOT TRUE" +== 188 +-- truncate_limit: 100 +select * from iboolpart where a is not true and a is not false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IS NOT TRUE AND a IS NOT FALSE" +== 189 +-- truncate_limit: 100 +select * from iboolpart where a is not false +-- +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM iboolpart WHERE a IS NOT FALSE" +== 190 +-- truncate_limit: 100 +create table boolrangep (a bool, b bool, c int) partition by range (a,b,c) +-- +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolrangep (a bool, b bool, c int) PARTITION BY RANGE (a, b, c)" +== 191 +-- truncate_limit: 100 +create table boolrangep_tf partition of boolrangep for values from ('true', 'false', 0) to ('true', 'false', 100) +-- +TABLE: name="boolrangep_tf" schema="" table="boolrangep_tf" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolrangep_tf PARTITION OF boolrangep FOR VALUES FROM ('true', 'false', 0) TO ('true..." +== 192 +-- truncate_limit: 100 +create table boolrangep_ft partition of boolrangep for values from ('false', 'true', 0) to ('false', 'true', 100) +-- +TABLE: name="boolrangep_ft" schema="" table="boolrangep_ft" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolrangep_ft PARTITION OF boolrangep FOR VALUES FROM ('false', 'true', 0) TO ('fals..." +== 193 +-- truncate_limit: 100 +create table boolrangep_ff1 partition of boolrangep for values from ('false', 'false', 0) to ('false', 'false', 50) +-- +TABLE: name="boolrangep_ff1" schema="" table="boolrangep_ff1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolrangep_ff1 PARTITION OF boolrangep FOR VALUES FROM ('false', 'false', 0) TO ('fa..." +== 194 +-- truncate_limit: 100 +create table boolrangep_ff2 partition of boolrangep for values from ('false', 'false', 50) to ('false', 'false', 100) +-- +TABLE: name="boolrangep_ff2" schema="" table="boolrangep_ff2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolrangep_ff2 PARTITION OF boolrangep FOR VALUES FROM ('false', 'false', 50) TO ('f..." +== 195 +-- truncate_limit: 100 +create table boolrangep_null partition of boolrangep default +-- +TABLE: name="boolrangep_null" schema="" table="boolrangep_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolrangep_null PARTITION OF boolrangep DEFAULT" +== 196 +-- truncate_limit: 100 +-- try a more complex case that's been known to trip up pruning in the past +explain (costs off) select * from boolrangep where not a and not b and c = 25 +-- +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolrangep WHERE NOT a AND NOT b AND c = 25" +== 197 +-- truncate_limit: 100 +-- ensure we prune boolrangep_tf +explain (costs off) select * from boolrangep where a is not true and not b and c = 25 +-- +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolrangep WHERE a IS NOT TRUE AND NOT b AND c = 25" +== 198 +-- truncate_limit: 100 +-- ensure we prune everything apart from boolrangep_tf and boolrangep_null +explain (costs off) select * from boolrangep where a is not false and not b and c = 25 +-- +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM boolrangep WHERE a IS NOT FALSE AND NOT b AND c = 25" +== 199 +-- truncate_limit: 100 +-- test scalar-to-array operators +create table coercepart (a varchar) partition by list (a) +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coercepart (a varchar) PARTITION BY LIST (a)" +== 200 +-- truncate_limit: 100 +create table coercepart_ab partition of coercepart for values in ('ab') +-- +TABLE: name="coercepart_ab" schema="" table="coercepart_ab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coercepart_ab PARTITION OF coercepart FOR VALUES IN ('ab')" +== 201 +-- truncate_limit: 100 +create table coercepart_bc partition of coercepart for values in ('bc') +-- +TABLE: name="coercepart_bc" schema="" table="coercepart_bc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coercepart_bc PARTITION OF coercepart FOR VALUES IN ('bc')" +== 202 +-- truncate_limit: 100 +create table coercepart_cd partition of coercepart for values in ('cd') +-- +TABLE: name="coercepart_cd" schema="" table="coercepart_cd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coercepart_cd PARTITION OF coercepart FOR VALUES IN ('cd')" +== 203 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a in ('ab', to_char(125, '999')) +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a IN ('ab', to_char(125, '999'))" +== 204 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a ~ any ('{ab}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a ~ ANY('{ab}')" +== 205 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a !~ all ('{ab}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a !~ ALL('{ab}')" +== 206 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a ~ any ('{ab,bc}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a ~ ANY('{ab,bc}')" +== 207 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a !~ all ('{ab,bc}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a !~ ALL('{ab,bc}')" +== 208 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a = any ('{ab,bc}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a = ANY('{ab,bc}')" +== 209 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a = any ('{ab,null}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a = ANY('{ab,null}')" +== 210 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a = any (null::text[]) +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a = ANY(NULL::text[])" +== 211 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a = all ('{ab}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a = ALL('{ab}')" +== 212 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a = all ('{ab,bc}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a = ALL('{ab,bc}')" +== 213 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a = all ('{ab,null}') +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a = ALL('{ab,null}')" +== 214 +-- truncate_limit: 100 +explain (costs off) select * from coercepart where a = all (null::text[]) +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coercepart WHERE a = ALL(NULL::text[])" +== 215 +-- truncate_limit: 100 +drop table coercepart +-- +TABLE: name="coercepart" schema="" table="coercepart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE coercepart" +== 216 +-- truncate_limit: 100 +CREATE TABLE part (a INT, b INT) PARTITION BY LIST (a) +-- +TABLE: name="part" schema="" table="part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part (a int, b int) PARTITION BY LIST (a)" +== 217 +-- truncate_limit: 100 +CREATE TABLE part_p1 PARTITION OF part FOR VALUES IN (-2,-1,0,1,2) +-- +TABLE: name="part_p1" schema="" table="part_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_p1 PARTITION OF part FOR VALUES IN (-2, -1, 0, 1, 2)" +== 218 +-- truncate_limit: 100 +CREATE TABLE part_p2 PARTITION OF part DEFAULT PARTITION BY RANGE(a) +-- +TABLE: name="part_p2" schema="" table="part_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_p2 PARTITION OF part DEFAULT PARTITION BY RANGE (a)" +== 219 +-- truncate_limit: 100 +CREATE TABLE part_p2_p1 PARTITION OF part_p2 DEFAULT +-- +TABLE: name="part_p2_p1" schema="" table="part_p2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_p2_p1 PARTITION OF part_p2 DEFAULT" +== 220 +-- truncate_limit: 100 +CREATE TABLE part_rev (b INT, c INT, a INT) +-- +TABLE: name="part_rev" schema="" table="part_rev" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_rev (b int, c int, a int)" +== 221 +-- truncate_limit: 100 +ALTER TABLE part ATTACH PARTITION part_rev FOR VALUES IN (3) +-- +TABLE: name="part" schema="" table="part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part ATTACH PARTITION part_rev FOR VALUES IN (3)" +== 222 +-- truncate_limit: 100 +-- fail +ALTER TABLE part_rev DROP COLUMN c +-- +TABLE: name="part_rev" schema="" table="part_rev" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_rev DROP c" +== 223 +-- truncate_limit: 100 +ALTER TABLE part ATTACH PARTITION part_rev FOR VALUES IN (3) +-- +TABLE: name="part" schema="" table="part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part ATTACH PARTITION part_rev FOR VALUES IN (3)" +== 224 +-- truncate_limit: 100 +-- now it's ok +INSERT INTO part VALUES (-1,-1), (1,1), (2,NULL), (NULL,-2),(NULL,NULL) +-- +TABLE: name="part" schema="" table="part" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part VALUES (-1, -1), (1, 1), (2, NULL), (NULL, -2), (NULL, NULL)" +== 225 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT tableoid::regclass as part, a, b FROM part WHERE a IS NULL ORDER BY 1, 2, 3 +-- +TABLE: name="part" schema="" table="part" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT tableoid::regclass AS part, a, b FROM part WHERE a IS NULL ORDER BY 1,..." +== 226 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM part p(x) ORDER BY x +-- +TABLE: name="part" schema="" table="part" ctx=Select +ALIAS: "p"="part" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM part p(x) ORDER BY x" +== 227 +-- truncate_limit: 100 +|-- +-- some more cases +|-- + +|-- +-- pruning for partitioned table appearing inside a sub-query +|-- +-- pruning won't work for mc3p, because some keys are Params +explain (costs off) select * from mc2p t1, lateral (select count(*) from mc3p t2 where t2.a = t1.b and abs(t2.b) = 1 and t2.c = 1) s where t1.a = 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +ALIAS: "t1"="mc2p" +ALIAS: "t2"="mc3p" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p t1, LATERAL (SELECT count(*) FROM mc3p t2 WHERE t2.a = t1...." +== 228 +-- truncate_limit: 100 +-- pruning should work fine, because values for a prefix of keys (a, b) are +-- available +explain (costs off) select * from mc2p t1, lateral (select count(*) from mc3p t2 where t2.c = t1.b and abs(t2.b) = 1 and t2.a = 1) s where t1.a = 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +ALIAS: "t1"="mc2p" +ALIAS: "t2"="mc3p" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="c" +FILTER: schema="" table="t1" column="b" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p t1, LATERAL (SELECT count(*) FROM mc3p t2 WHERE t2.c = t1...." +== 229 +-- truncate_limit: 100 +-- also here, because values for all keys are provided +explain (costs off) select * from mc2p t1, lateral (select count(*) from mc3p t2 where t2.a = 1 and abs(t2.b) = 1 and t2.c = 1) s where t1.a = 1 +-- +TABLE: name="mc2p" schema="" table="mc2p" ctx=Select +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +ALIAS: "t1"="mc2p" +ALIAS: "t2"="mc3p" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t2" column="a" +FILTER: schema="" table="t2" column="b" +FILTER: schema="" table="t2" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM mc2p t1, LATERAL (SELECT count(*) FROM mc3p t2 WHERE t2.a = 1 A..." +== 230 +-- truncate_limit: 100 +|-- +-- pruning with clauses containing <> operator +|-- + +-- doesn't prune range partitions +create table rp (a int) partition by range (a) +-- +TABLE: name="rp" schema="" table="rp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp (a int) PARTITION BY RANGE (a)" +== 231 +-- truncate_limit: 100 +create table rp0 partition of rp for values from (minvalue) to (1) +-- +TABLE: name="rp0" schema="" table="rp0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp0 PARTITION OF rp FOR VALUES FROM (minvalue) TO (1)" +== 232 +-- truncate_limit: 100 +create table rp1 partition of rp for values from (1) to (2) +-- +TABLE: name="rp1" schema="" table="rp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp1 PARTITION OF rp FOR VALUES FROM (1) TO (2)" +== 233 +-- truncate_limit: 100 +create table rp2 partition of rp for values from (2) to (maxvalue) +-- +TABLE: name="rp2" schema="" table="rp2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp2 PARTITION OF rp FOR VALUES FROM (2) TO (maxvalue)" +== 234 +-- truncate_limit: 100 +explain (costs off) select * from rp where a <> 1 +-- +TABLE: name="rp" schema="" table="rp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rp WHERE a <> 1" +== 235 +-- truncate_limit: 100 +explain (costs off) select * from rp where a <> 1 and a <> 2 +-- +TABLE: name="rp" schema="" table="rp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rp WHERE a <> 1 AND a <> 2" +== 236 +-- truncate_limit: 100 +-- null partition should be eliminated due to strict <> clause. +explain (costs off) select * from lp where a <> 'a' +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a <> 'a'" +== 237 +-- truncate_limit: 100 +-- ensure we detect contradictions in clauses; a can't be NULL and NOT NULL. +explain (costs off) select * from lp where a <> 'a' and a is null +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE a <> 'a' AND a IS NULL" +== 238 +-- truncate_limit: 100 +explain (costs off) select * from lp where (a <> 'a' and a <> 'd') or a is null +-- +TABLE: name="lp" schema="" table="lp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lp WHERE (a <> 'a' AND a <> 'd') OR a IS NULL" +== 239 +-- truncate_limit: 100 +-- check that it also works for a partitioned table that's not root, +-- which in this case are partitions of rlp that are themselves +-- list-partitioned on b +explain (costs off) select * from rlp where a = 15 and b <> 'ab' and b <> 'cd' and b <> 'xy' and b is not null +-- +TABLE: name="rlp" schema="" table="rlp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rlp WHERE a = 15 AND b <> 'ab' AND b <> 'cd' AND b <> 'xy' AND ..." +== 240 +-- truncate_limit: 100 +|-- +-- different collations for different keys with same expression +|-- +create table coll_pruning_multi (a text) partition by range (substr(a, 1) collate "POSIX", substr(a, 1) collate "C") +-- +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coll_pruning_multi (a text) PARTITION BY RANGE ((substr(a, 1)) COLLATE \"POSIX\", (sub..." +== 241 +-- truncate_limit: 100 +create table coll_pruning_multi1 partition of coll_pruning_multi for values from ('a', 'a') to ('a', 'e') +-- +TABLE: name="coll_pruning_multi1" schema="" table="coll_pruning_multi1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coll_pruning_multi1 PARTITION OF coll_pruning_multi FOR VALUES FROM ('a', 'a') TO ('..." +== 242 +-- truncate_limit: 100 +create table coll_pruning_multi2 partition of coll_pruning_multi for values from ('a', 'e') to ('a', 'z') +-- +TABLE: name="coll_pruning_multi2" schema="" table="coll_pruning_multi2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coll_pruning_multi2 PARTITION OF coll_pruning_multi FOR VALUES FROM ('a', 'e') TO ('..." +== 243 +-- truncate_limit: 100 +create table coll_pruning_multi3 partition of coll_pruning_multi for values from ('b', 'a') to ('b', 'e') +-- +TABLE: name="coll_pruning_multi3" schema="" table="coll_pruning_multi3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE coll_pruning_multi3 PARTITION OF coll_pruning_multi FOR VALUES FROM ('b', 'a') TO ('..." +== 244 +-- truncate_limit: 100 +-- no pruning, because no value for the leading key +explain (costs off) select * from coll_pruning_multi where substr(a, 1) = 'e' collate "C" +-- +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coll_pruning_multi WHERE substr(a, 1) = 'e' COLLATE \"C\"" +== 245 +-- truncate_limit: 100 +-- pruning, with a value provided for the leading key +explain (costs off) select * from coll_pruning_multi where substr(a, 1) = 'a' collate "POSIX" +-- +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coll_pruning_multi WHERE substr(a, 1) = 'a' COLLATE \"POSIX\"" +== 246 +-- truncate_limit: 100 +-- pruning, with values provided for both keys +explain (costs off) select * from coll_pruning_multi where substr(a, 1) = 'e' collate "C" and substr(a, 1) = 'a' collate "POSIX" +-- +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM coll_pruning_multi WHERE substr(a, 1) = 'e' COLLATE \"C\" AND sub..." +== 247 +-- truncate_limit: 100 +|-- +-- LIKE operators don't prune +|-- +create table like_op_noprune (a text) partition by list (a) +-- +TABLE: name="like_op_noprune" schema="" table="like_op_noprune" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE like_op_noprune (a text) PARTITION BY LIST (a)" +== 248 +-- truncate_limit: 100 +create table like_op_noprune1 partition of like_op_noprune for values in ('ABC') +-- +TABLE: name="like_op_noprune1" schema="" table="like_op_noprune1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE like_op_noprune1 PARTITION OF like_op_noprune FOR VALUES IN ('ABC')" +== 249 +-- truncate_limit: 100 +create table like_op_noprune2 partition of like_op_noprune for values in ('BCD') +-- +TABLE: name="like_op_noprune2" schema="" table="like_op_noprune2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE like_op_noprune2 PARTITION OF like_op_noprune FOR VALUES IN ('BCD')" +== 250 +-- truncate_limit: 100 +explain (costs off) select * from like_op_noprune where a like '%BC' +-- +TABLE: name="like_op_noprune" schema="" table="like_op_noprune" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM like_op_noprune WHERE a LIKE '%BC'" +== 251 +-- truncate_limit: 100 +|-- +-- tests wherein clause value requires a cross-type comparison function +|-- +create table lparted_by_int2 (a smallint) partition by list (a) +-- +TABLE: name="lparted_by_int2" schema="" table="lparted_by_int2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lparted_by_int2 (a smallint) PARTITION BY LIST (a)" +== 252 +-- truncate_limit: 100 +create table lparted_by_int2_1 partition of lparted_by_int2 for values in (1) +-- +TABLE: name="lparted_by_int2_1" schema="" table="lparted_by_int2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lparted_by_int2_1 PARTITION OF lparted_by_int2 FOR VALUES IN (1)" +== 253 +-- truncate_limit: 100 +create table lparted_by_int2_16384 partition of lparted_by_int2 for values in (16384) +-- +TABLE: name="lparted_by_int2_16384" schema="" table="lparted_by_int2_16384" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lparted_by_int2_16384 PARTITION OF lparted_by_int2 FOR VALUES IN (16384)" +== 254 +-- truncate_limit: 100 +explain (costs off) select * from lparted_by_int2 where a = 100_000_000_000_000 +-- +TABLE: name="lparted_by_int2" schema="" table="lparted_by_int2" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM lparted_by_int2 WHERE a = 100_000_000_000_000" +== 255 +-- truncate_limit: 100 +create table rparted_by_int2 (a smallint) partition by range (a) +-- +TABLE: name="rparted_by_int2" schema="" table="rparted_by_int2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rparted_by_int2 (a smallint) PARTITION BY RANGE (a)" +== 256 +-- truncate_limit: 100 +create table rparted_by_int2_1 partition of rparted_by_int2 for values from (1) to (10) +-- +TABLE: name="rparted_by_int2_1" schema="" table="rparted_by_int2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rparted_by_int2_1 PARTITION OF rparted_by_int2 FOR VALUES FROM (1) TO (10)" +== 257 +-- truncate_limit: 100 +create table rparted_by_int2_16384 partition of rparted_by_int2 for values from (10) to (16384) +-- +TABLE: name="rparted_by_int2_16384" schema="" table="rparted_by_int2_16384" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rparted_by_int2_16384 PARTITION OF rparted_by_int2 FOR VALUES FROM (10) TO (16384)" +== 258 +-- truncate_limit: 100 +-- all partitions pruned +explain (costs off) select * from rparted_by_int2 where a > 100_000_000_000_000 +-- +TABLE: name="rparted_by_int2" schema="" table="rparted_by_int2" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rparted_by_int2 WHERE a > 100_000_000_000_000" +== 259 +-- truncate_limit: 100 +create table rparted_by_int2_maxvalue partition of rparted_by_int2 for values from (16384) to (maxvalue) +-- +TABLE: name="rparted_by_int2_maxvalue" schema="" table="rparted_by_int2_maxvalue" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rparted_by_int2_maxvalue PARTITION OF rparted_by_int2 FOR VALUES FROM (16384) TO (ma..." +== 260 +-- truncate_limit: 100 +-- all partitions but rparted_by_int2_maxvalue pruned +explain (costs off) select * from rparted_by_int2 where a > 100_000_000_000_000 +-- +TABLE: name="rparted_by_int2" schema="" table="rparted_by_int2" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rparted_by_int2 WHERE a > 100_000_000_000_000" +== 261 +-- truncate_limit: 100 +drop table lp, coll_pruning, rlp, mc3p, mc2p, boolpart, iboolpart, boolrangep, rp, coll_pruning_multi, like_op_noprune, lparted_by_int2, rparted_by_int2 +-- +TABLE: name="lp" schema="" table="lp" ctx=DDL +TABLE: name="coll_pruning" schema="" table="coll_pruning" ctx=DDL +TABLE: name="rlp" schema="" table="rlp" ctx=DDL +TABLE: name="mc3p" schema="" table="mc3p" ctx=DDL +TABLE: name="mc2p" schema="" table="mc2p" ctx=DDL +TABLE: name="boolpart" schema="" table="boolpart" ctx=DDL +TABLE: name="iboolpart" schema="" table="iboolpart" ctx=DDL +TABLE: name="boolrangep" schema="" table="boolrangep" ctx=DDL +TABLE: name="rp" schema="" table="rp" ctx=DDL +TABLE: name="coll_pruning_multi" schema="" table="coll_pruning_multi" ctx=DDL +TABLE: name="like_op_noprune" schema="" table="like_op_noprune" ctx=DDL +TABLE: name="lparted_by_int2" schema="" table="lparted_by_int2" ctx=DDL +TABLE: name="rparted_by_int2" schema="" table="rparted_by_int2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE lp, coll_pruning, rlp, mc3p, mc2p, boolpart, iboolpart, boolrangep, rp, coll_pruning_m..." +== 262 +-- truncate_limit: 100 +-- check that AlternativeSubPlan within a pruning expression gets cleaned up + +create table asptab (id int primary key) partition by range (id) +-- +TABLE: name="asptab" schema="" table="asptab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE asptab (id int PRIMARY KEY) PARTITION BY RANGE (id)" +== 263 +-- truncate_limit: 100 +create table asptab0 partition of asptab for values from (0) to (1) +-- +TABLE: name="asptab0" schema="" table="asptab0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE asptab0 PARTITION OF asptab FOR VALUES FROM (0) TO (1)" +== 264 +-- truncate_limit: 100 +create table asptab1 partition of asptab for values from (1) to (2) +-- +TABLE: name="asptab1" schema="" table="asptab1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE asptab1 PARTITION OF asptab FOR VALUES FROM (1) TO (2)" +== 265 +-- truncate_limit: 100 +explain (costs off) +select * from + (select exists (select 1 from int4_tbl tinner where f1 = touter.f1) as b + from int4_tbl touter) ss, + asptab +where asptab.id > ss.b::int +-- +TABLE: name="asptab" schema="" table="asptab" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "tinner"="int4_tbl" +ALIAS: "touter"="int4_tbl" +FILTER: schema="" table="asptab" column="id" +FILTER: schema="" table="ss" column="b" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="touter" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT EXISTS (SELECT 1 FROM int4_tbl tinner WHERE f1 = touter..." +== 266 +-- truncate_limit: 100 +drop table asptab +-- +TABLE: name="asptab" schema="" table="asptab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE asptab" +== 267 +-- truncate_limit: 100 +|-- +-- Test Partition pruning for HASH partitioning +|-- +-- Use hand-rolled hash functions and operator classes to get predictable +-- result on different machines. See the definitions of +-- part_test_int4_ops and part_test_text_ops in test_setup.sql. +|-- + +create table hp (a int, b text, c int) + partition by hash (a part_test_int4_ops, b part_test_text_ops) +-- +TABLE: name="hp" schema="" table="hp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp (a int, b text, c int) PARTITION BY HASH (a part_test_int4_ops, b part_test_text_..." +== 268 +-- truncate_limit: 100 +create table hp0 partition of hp for values with (modulus 4, remainder 0) +-- +TABLE: name="hp0" schema="" table="hp0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp0 PARTITION OF hp FOR VALUES WITH (MODULUS 4, REMAINDER 0)" +== 269 +-- truncate_limit: 100 +create table hp3 partition of hp for values with (modulus 4, remainder 3) +-- +TABLE: name="hp3" schema="" table="hp3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp3 PARTITION OF hp FOR VALUES WITH (MODULUS 4, REMAINDER 3)" +== 270 +-- truncate_limit: 100 +create table hp1 partition of hp for values with (modulus 4, remainder 1) +-- +TABLE: name="hp1" schema="" table="hp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp1 PARTITION OF hp FOR VALUES WITH (MODULUS 4, REMAINDER 1)" +== 271 +-- truncate_limit: 100 +create table hp2 partition of hp for values with (modulus 4, remainder 2) +-- +TABLE: name="hp2" schema="" table="hp2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp2 PARTITION OF hp FOR VALUES WITH (MODULUS 4, REMAINDER 2)" +== 272 +-- truncate_limit: 100 +insert into hp values (null, null, 0) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hp VALUES (NULL, NULL, 0)" +== 273 +-- truncate_limit: 100 +insert into hp values (1, null, 1) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hp VALUES (1, NULL, 1)" +== 274 +-- truncate_limit: 100 +insert into hp values (1, 'xxx', 2) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hp VALUES (1, 'xxx', 2)" +== 275 +-- truncate_limit: 100 +insert into hp values (null, 'xxx', 3) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hp VALUES (NULL, 'xxx', 3)" +== 276 +-- truncate_limit: 100 +insert into hp values (2, 'xxx', 4) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hp VALUES (2, 'xxx', 4)" +== 277 +-- truncate_limit: 100 +insert into hp values (1, 'abcde', 5) +-- +TABLE: name="hp" schema="" table="hp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hp VALUES (1, 'abcde', 5)" +== 278 +-- truncate_limit: 100 +select tableoid::regclass, * from hp order by c +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM hp ORDER BY c" +== 279 +-- truncate_limit: 100 +-- partial keys won't prune, nor would non-equality conditions +explain (costs off) select * from hp where a = 1 +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a = 1" +== 280 +-- truncate_limit: 100 +explain (costs off) select * from hp where b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE b = 'xxx'" +== 281 +-- truncate_limit: 100 +explain (costs off) select * from hp where a is null +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a IS NULL" +== 282 +-- truncate_limit: 100 +explain (costs off) select * from hp where b is null +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE b IS NULL" +== 283 +-- truncate_limit: 100 +explain (costs off) select * from hp where a < 1 and b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a < 1 AND b = 'xxx'" +== 284 +-- truncate_limit: 100 +explain (costs off) select * from hp where a <> 1 and b = 'yyy' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a <> 1 AND b = 'yyy'" +== 285 +-- truncate_limit: 100 +explain (costs off) select * from hp where a <> 1 and b <> 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a <> 1 AND b <> 'xxx'" +== 286 +-- truncate_limit: 100 +-- pruning should work if either a value or a IS NULL clause is provided for +-- each of the keys +explain (costs off) select * from hp where a is null and b is null +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a IS NULL AND b IS NULL" +== 287 +-- truncate_limit: 100 +explain (costs off) select * from hp where a = 1 and b is null +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a = 1 AND b IS NULL" +== 288 +-- truncate_limit: 100 +explain (costs off) select * from hp where a = 1 and b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a = 1 AND b = 'xxx'" +== 289 +-- truncate_limit: 100 +explain (costs off) select * from hp where a is null and b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a IS NULL AND b = 'xxx'" +== 290 +-- truncate_limit: 100 +explain (costs off) select * from hp where a = 2 and b = 'xxx' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a = 2 AND b = 'xxx'" +== 291 +-- truncate_limit: 100 +explain (costs off) select * from hp where a = 1 and b = 'abcde' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a = 1 AND b = 'abcde'" +== 292 +-- truncate_limit: 100 +explain (costs off) select * from hp where (a = 1 and b = 'abcde') or (a = 2 and b = 'xxx') or (a is null and b is null) +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE (a = 1 AND b = 'abcde') OR (a = 2 AND b = 'xxx') OR (a..." +== 293 +-- truncate_limit: 100 +-- test pruning when not all the partitions exist +drop table hp1 +-- +TABLE: name="hp1" schema="" table="hp1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hp1" +== 294 +-- truncate_limit: 100 +drop table hp3 +-- +TABLE: name="hp3" schema="" table="hp3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hp3" +== 295 +-- truncate_limit: 100 +explain (costs off) select * from hp where a = 1 and b = 'abcde' +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a = 1 AND b = 'abcde'" +== 296 +-- truncate_limit: 100 +explain (costs off) select * from hp where a = 1 and b = 'abcde' and + (c = 2 or c = 3) +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a = 1 AND b = 'abcde' AND (c = 2 OR c = 3)" +== 297 +-- truncate_limit: 100 +drop table hp2 +-- +TABLE: name="hp2" schema="" table="hp2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hp2" +== 298 +-- truncate_limit: 100 +explain (costs off) select * from hp where a = 1 and b = 'abcde' and + (c = 2 or c = 3) +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp WHERE a = 1 AND b = 'abcde' AND (c = 2 OR c = 3)" +== 299 +-- truncate_limit: 100 +|-- +-- Test runtime partition pruning +|-- +create table ab (a int not null, b int not null) partition by list (a) +-- +TABLE: name="ab" schema="" table="ab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab (a int NOT NULL, b int NOT NULL) PARTITION BY LIST (a)" +== 300 +-- truncate_limit: 100 +create table ab_a2 partition of ab for values in(2) partition by list (b) +-- +TABLE: name="ab_a2" schema="" table="ab_a2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a2 PARTITION OF ab FOR VALUES IN (2) PARTITION BY LIST (b)" +== 301 +-- truncate_limit: 100 +create table ab_a2_b1 partition of ab_a2 for values in (1) +-- +TABLE: name="ab_a2_b1" schema="" table="ab_a2_b1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a2_b1 PARTITION OF ab_a2 FOR VALUES IN (1)" +== 302 +-- truncate_limit: 100 +create table ab_a2_b2 partition of ab_a2 for values in (2) +-- +TABLE: name="ab_a2_b2" schema="" table="ab_a2_b2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a2_b2 PARTITION OF ab_a2 FOR VALUES IN (2)" +== 303 +-- truncate_limit: 100 +create table ab_a2_b3 partition of ab_a2 for values in (3) +-- +TABLE: name="ab_a2_b3" schema="" table="ab_a2_b3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a2_b3 PARTITION OF ab_a2 FOR VALUES IN (3)" +== 304 +-- truncate_limit: 100 +create table ab_a1 partition of ab for values in(1) partition by list (b) +-- +TABLE: name="ab_a1" schema="" table="ab_a1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a1 PARTITION OF ab FOR VALUES IN (1) PARTITION BY LIST (b)" +== 305 +-- truncate_limit: 100 +create table ab_a1_b1 partition of ab_a1 for values in (1) +-- +TABLE: name="ab_a1_b1" schema="" table="ab_a1_b1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a1_b1 PARTITION OF ab_a1 FOR VALUES IN (1)" +== 306 +-- truncate_limit: 100 +create table ab_a1_b2 partition of ab_a1 for values in (2) +-- +TABLE: name="ab_a1_b2" schema="" table="ab_a1_b2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a1_b2 PARTITION OF ab_a1 FOR VALUES IN (2)" +== 307 +-- truncate_limit: 100 +create table ab_a1_b3 partition of ab_a1 for values in (3) +-- +TABLE: name="ab_a1_b3" schema="" table="ab_a1_b3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a1_b3 PARTITION OF ab_a1 FOR VALUES IN (3)" +== 308 +-- truncate_limit: 100 +create table ab_a3 partition of ab for values in(3) partition by list (b) +-- +TABLE: name="ab_a3" schema="" table="ab_a3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a3 PARTITION OF ab FOR VALUES IN (3) PARTITION BY LIST (b)" +== 309 +-- truncate_limit: 100 +create table ab_a3_b1 partition of ab_a3 for values in (1) +-- +TABLE: name="ab_a3_b1" schema="" table="ab_a3_b1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a3_b1 PARTITION OF ab_a3 FOR VALUES IN (1)" +== 310 +-- truncate_limit: 100 +create table ab_a3_b2 partition of ab_a3 for values in (2) +-- +TABLE: name="ab_a3_b2" schema="" table="ab_a3_b2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a3_b2 PARTITION OF ab_a3 FOR VALUES IN (2)" +== 311 +-- truncate_limit: 100 +create table ab_a3_b3 partition of ab_a3 for values in (3) +-- +TABLE: name="ab_a3_b3" schema="" table="ab_a3_b3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab_a3_b3 PARTITION OF ab_a3 FOR VALUES IN (3)" +== 312 +-- truncate_limit: 100 +-- Disallow index only scans as concurrent transactions may stop visibility +-- bits being set causing "Heap Fetches" to be unstable in the EXPLAIN ANALYZE +-- output. +set enable_indexonlyscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexonlyscan TO OFF" +== 313 +-- truncate_limit: 100 +prepare ab_q1 (int, int, int) as +select * from ab where a between $1 and $2 and b <= $3 +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ab_q1(int, int, int) AS SELECT * FROM ab WHERE a BETWEEN $1 AND $2 AND b <= $3" +== 314 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute ab_q1 (2, 2, 3) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ab_q1(2, 2, 3)" +== 315 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute ab_q1 (1, 2, 3) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ab_q1(1, 2, 3)" +== 316 +-- truncate_limit: 100 +deallocate ab_q1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ab_q1" +== 317 +-- truncate_limit: 100 +-- Runtime pruning after optimizer pruning +prepare ab_q1 (int, int) as +select a from ab where a between $1 and $2 and b < 3 +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ab_q1(int, int) AS SELECT a FROM ab WHERE a BETWEEN $1 AND $2 AND b < 3" +== 318 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute ab_q1 (2, 2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ab_q1(2, 2)" +== 319 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute ab_q1 (2, 4) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ab_q1(2, 4)" +== 320 +-- truncate_limit: 100 +-- Ensure a mix of PARAM_EXTERN and PARAM_EXEC Params work together at +-- different levels of partitioning. +prepare ab_q2 (int, int) as +select a from ab where a between $1 and $2 and b < (select 3) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ab_q2(int, int) AS SELECT a FROM ab WHERE a BETWEEN $1 AND $2 AND b < (SELECT 3)" +== 321 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute ab_q2 (2, 2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ab_q2(2, 2)" +== 322 +-- truncate_limit: 100 +-- As above, but swap the PARAM_EXEC Param to the first partition level +prepare ab_q3 (int, int) as +select a from ab where b between $1 and $2 and a < (select 3) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ab_q3(int, int) AS SELECT a FROM ab WHERE b BETWEEN $1 AND $2 AND a < (SELECT 3)" +== 323 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute ab_q3 (2, 2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ab_q3(2, 2)" +== 324 +-- truncate_limit: 100 +|-- +-- Test runtime pruning with hash partitioned tables +|-- + +-- recreate partitions dropped above +create table hp1 partition of hp for values with (modulus 4, remainder 1) +-- +TABLE: name="hp1" schema="" table="hp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp1 PARTITION OF hp FOR VALUES WITH (MODULUS 4, REMAINDER 1)" +== 325 +-- truncate_limit: 100 +create table hp2 partition of hp for values with (modulus 4, remainder 2) +-- +TABLE: name="hp2" schema="" table="hp2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp2 PARTITION OF hp FOR VALUES WITH (MODULUS 4, REMAINDER 2)" +== 326 +-- truncate_limit: 100 +create table hp3 partition of hp for values with (modulus 4, remainder 3) +-- +TABLE: name="hp3" schema="" table="hp3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp3 PARTITION OF hp FOR VALUES WITH (MODULUS 4, REMAINDER 3)" +== 327 +-- truncate_limit: 100 +-- Ensure we correctly prune unneeded partitions when there is an IS NULL qual +prepare hp_q1 (text) as +select * from hp where a is null and b = $1 +-- +TABLE: name="hp" schema="" table="hp" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE hp_q1(text) AS SELECT * FROM hp WHERE a IS NULL AND b = $1" +== 328 +-- truncate_limit: 100 +explain (costs off) execute hp_q1('xxx') +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE hp_q1('xxx')" +== 329 +-- truncate_limit: 100 +deallocate hp_q1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE hp_q1" +== 330 +-- truncate_limit: 100 +drop table hp +-- +TABLE: name="hp" schema="" table="hp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hp" +== 331 +-- truncate_limit: 100 +-- Test a backwards Append scan +create table list_part (a int) partition by list (a) +-- +TABLE: name="list_part" schema="" table="list_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_part (a int) PARTITION BY LIST (a)" +== 332 +-- truncate_limit: 100 +create table list_part1 partition of list_part for values in (1) +-- +TABLE: name="list_part1" schema="" table="list_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_part1 PARTITION OF list_part FOR VALUES IN (1)" +== 333 +-- truncate_limit: 100 +create table list_part2 partition of list_part for values in (2) +-- +TABLE: name="list_part2" schema="" table="list_part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_part2 PARTITION OF list_part FOR VALUES IN (2)" +== 334 +-- truncate_limit: 100 +create table list_part3 partition of list_part for values in (3) +-- +TABLE: name="list_part3" schema="" table="list_part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_part3 PARTITION OF list_part FOR VALUES IN (3)" +== 335 +-- truncate_limit: 100 +create table list_part4 partition of list_part for values in (4) +-- +TABLE: name="list_part4" schema="" table="list_part4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_part4 PARTITION OF list_part FOR VALUES IN (4)" +== 336 +-- truncate_limit: 100 +insert into list_part select generate_series(1,4) +-- +TABLE: name="list_part" schema="" table="list_part" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_part SELECT generate_series(1, 4)" +== 337 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 338 +-- truncate_limit: 100 +-- Don't select an actual value out of the table as the order of the Append's +-- subnodes may not be stable. +declare cur SCROLL CURSOR for select 1 from list_part where a > (select 1) and a < (select 4) +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE cur SCROLL CURSOR FOR SELECT 1 FROM list_part WHERE a > (SELECT 1) AND a < (SELECT 4)" +== 339 +-- truncate_limit: 100 +-- move beyond the final row +move 3 from cur +-- +STMT: FetchStmt +TRUNCATED: "MOVE FORWARD 3 cur" +== 340 +-- truncate_limit: 100 +-- Ensure we get two rows. +fetch backward all from cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL cur" +== 341 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 342 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 343 +-- truncate_limit: 100 +-- Test run-time pruning using stable functions +create function list_part_fn(int) returns int as $$ begin return $1; end;$$ language plpgsql stable +-- +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION list_part_fn(int) RETURNS int AS $$ begin return $1; end;$$ LANGUAGE plpgsql STABLE" +== 344 +-- truncate_limit: 100 +-- Ensure pruning works using a stable function containing no Vars +explain (analyze, costs off, summary off, timing off) select * from list_part where a = list_part_fn(1) +-- +TABLE: name="list_part" schema="" table="list_part" ctx=Select +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM list_part WHERE a = list_part..." +== 345 +-- truncate_limit: 100 +-- Ensure pruning does not take place when the function has a Var parameter +explain (analyze, costs off, summary off, timing off) select * from list_part where a = list_part_fn(a) +-- +TABLE: name="list_part" schema="" table="list_part" ctx=Select +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM list_part WHERE a = list_part..." +== 346 +-- truncate_limit: 100 +-- Ensure pruning does not take place when the expression contains a Var. +explain (analyze, costs off, summary off, timing off) select * from list_part where a = list_part_fn(1) + a +-- +TABLE: name="list_part" schema="" table="list_part" ctx=Select +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FUNCTION: name="list_part_fn" function="list_part_fn" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM list_part WHERE a = (list_par..." +== 347 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 348 +-- truncate_limit: 100 +drop table list_part +-- +TABLE: name="list_part" schema="" table="list_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE list_part" +== 349 +-- truncate_limit: 100 +-- Parallel append + +-- Parallel queries won't necessarily get as many workers as the planner +-- asked for. This affects not only the "Workers Launched:" field of EXPLAIN +-- results, but also row counts and loop counts for parallel scans, Gathers, +-- and everything in between. This function filters out the values we can't +-- rely on to be stable. +-- This removes enough info that you might wonder why bother with EXPLAIN +-- ANALYZE at all. The answer is that we need to see '(never executed)' +-- notations because that's the only way to verify runtime pruning. +create function explain_parallel_append(text) returns setof text +language plpgsql as +$$ +declare + ln text; +begin + for ln in + execute format('explain (analyze, costs off, summary off, timing off) %s', + $1) + loop + ln := regexp_replace(ln, 'Workers Launched: \d+', 'Workers Launched: N'); + ln := regexp_replace(ln, 'actual rows=\d+ loops=\d+', 'actual rows=N loops=N'); + ln := regexp_replace(ln, 'Rows Removed by Filter: \d+', 'Rows Removed by Filter: N'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION explain_parallel_append(text) RETURNS SETOF text LANGUAGE plpgsql AS $$\ndeclare\n ..." +== 350 +-- truncate_limit: 100 +prepare ab_q4 (int, int) as +select avg(a) from ab where a between $1 and $2 and b < 4 +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ab_q4(int, int) AS SELECT avg(a) FROM ab WHERE a BETWEEN $1 AND $2 AND b < 4" +== 351 +-- truncate_limit: 100 +-- Encourage use of parallel plans +set parallel_setup_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 352 +-- truncate_limit: 100 +set parallel_tuple_cost = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 353 +-- truncate_limit: 100 +set min_parallel_table_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 354 +-- truncate_limit: 100 +set max_parallel_workers_per_gather = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 355 +-- truncate_limit: 100 +select explain_parallel_append('execute ab_q4 (2, 2)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_parallel_append('execute ab_q4 (2, 2)')" +== 356 +-- truncate_limit: 100 +-- Test run-time pruning with IN lists. +prepare ab_q5 (int, int, int) as +select avg(a) from ab where a in($1,$2,$3) and b < 4 +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ab_q5(int, int, int) AS SELECT avg(a) FROM ab WHERE a IN ($1, $2, $3) AND b < 4" +== 357 +-- truncate_limit: 100 +select explain_parallel_append('execute ab_q5 (1, 1, 1)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_parallel_append('execute ab_q5 (1, 1, 1)')" +== 358 +-- truncate_limit: 100 +select explain_parallel_append('execute ab_q5 (2, 3, 3)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_parallel_append('execute ab_q5 (2, 3, 3)')" +== 359 +-- truncate_limit: 100 +-- Try some params whose values do not belong to any partition. +select explain_parallel_append('execute ab_q5 (33, 44, 55)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_parallel_append('execute ab_q5 (33, 44, 55)')" +== 360 +-- truncate_limit: 100 +-- Test Parallel Append with PARAM_EXEC Params +select explain_parallel_append('select count(*) from ab where (a = (select 1) or a = (select 3)) and b = 2') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 361 +-- truncate_limit: 100 +-- Test pruning during parallel nested loop query +create table lprt_a (a int not null) +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE lprt_a (a int NOT NULL)" +== 362 +-- truncate_limit: 100 +-- Insert some values we won't find in ab +insert into lprt_a select 0 from generate_series(1,100) +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lprt_a SELECT 0 FROM generate_series(1, 100)" +== 363 +-- truncate_limit: 100 +-- and insert some values that we should find. +insert into lprt_a values(1),(1) +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lprt_a VALUES (1), (1)" +== 364 +-- truncate_limit: 100 +analyze lprt_a +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE lprt_a" +== 365 +-- truncate_limit: 100 +create index ab_a2_b1_a_idx on ab_a2_b1 (a) +-- +TABLE: name="ab_a2_b1" schema="" table="ab_a2_b1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a2_b1_a_idx ON ab_a2_b1 USING btree (a)" +== 366 +-- truncate_limit: 100 +create index ab_a2_b2_a_idx on ab_a2_b2 (a) +-- +TABLE: name="ab_a2_b2" schema="" table="ab_a2_b2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a2_b2_a_idx ON ab_a2_b2 USING btree (a)" +== 367 +-- truncate_limit: 100 +create index ab_a2_b3_a_idx on ab_a2_b3 (a) +-- +TABLE: name="ab_a2_b3" schema="" table="ab_a2_b3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a2_b3_a_idx ON ab_a2_b3 USING btree (a)" +== 368 +-- truncate_limit: 100 +create index ab_a1_b1_a_idx on ab_a1_b1 (a) +-- +TABLE: name="ab_a1_b1" schema="" table="ab_a1_b1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a1_b1_a_idx ON ab_a1_b1 USING btree (a)" +== 369 +-- truncate_limit: 100 +create index ab_a1_b2_a_idx on ab_a1_b2 (a) +-- +TABLE: name="ab_a1_b2" schema="" table="ab_a1_b2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a1_b2_a_idx ON ab_a1_b2 USING btree (a)" +== 370 +-- truncate_limit: 100 +create index ab_a1_b3_a_idx on ab_a1_b3 (a) +-- +TABLE: name="ab_a1_b3" schema="" table="ab_a1_b3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a1_b3_a_idx ON ab_a1_b3 USING btree (a)" +== 371 +-- truncate_limit: 100 +create index ab_a3_b1_a_idx on ab_a3_b1 (a) +-- +TABLE: name="ab_a3_b1" schema="" table="ab_a3_b1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a3_b1_a_idx ON ab_a3_b1 USING btree (a)" +== 372 +-- truncate_limit: 100 +create index ab_a3_b2_a_idx on ab_a3_b2 (a) +-- +TABLE: name="ab_a3_b2" schema="" table="ab_a3_b2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a3_b2_a_idx ON ab_a3_b2 USING btree (a)" +== 373 +-- truncate_limit: 100 +create index ab_a3_b3_a_idx on ab_a3_b3 (a) +-- +TABLE: name="ab_a3_b3" schema="" table="ab_a3_b3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ab_a3_b3_a_idx ON ab_a3_b3 USING btree (a)" +== 374 +-- truncate_limit: 100 +set enable_hashjoin = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO 0" +== 375 +-- truncate_limit: 100 +set enable_mergejoin = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO 0" +== 376 +-- truncate_limit: 100 +set enable_memoize = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_memoize TO 0" +== 377 +-- truncate_limit: 100 +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(0, 0, 1)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 378 +-- truncate_limit: 100 +-- Ensure the same partitions are pruned when we make the nested loop +-- parameter an Expr rather than a plain Param. +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a + 0 where a.a in(0, 0, 1)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 379 +-- truncate_limit: 100 +insert into lprt_a values(3),(3) +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO lprt_a VALUES (3), (3)" +== 380 +-- truncate_limit: 100 +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 3)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 381 +-- truncate_limit: 100 +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 0)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 382 +-- truncate_limit: 100 +delete from lprt_a where a = 1 +-- +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM lprt_a WHERE a = 1" +== 383 +-- truncate_limit: 100 +select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 0)') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 384 +-- truncate_limit: 100 +reset enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 385 +-- truncate_limit: 100 +reset enable_mergejoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_mergejoin" +== 386 +-- truncate_limit: 100 +reset enable_memoize +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_memoize" +== 387 +-- truncate_limit: 100 +reset parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 388 +-- truncate_limit: 100 +reset parallel_tuple_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_tuple_cost" +== 389 +-- truncate_limit: 100 +reset min_parallel_table_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_table_scan_size" +== 390 +-- truncate_limit: 100 +reset max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers_per_gather" +== 391 +-- truncate_limit: 100 +-- Test run-time partition pruning with an initplan +explain (analyze, costs off, summary off, timing off) +select * from ab where a = (select max(a) from lprt_a) and b = (select max(a)-1 from lprt_a) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=Select +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM ab WHERE a = (SELECT max(a) F..." +== 392 +-- truncate_limit: 100 +-- Test run-time partition pruning with UNION ALL parents +explain (analyze, costs off, summary off, timing off) +select * from (select * from ab where a = 1 union all select * from ab) ab where b = (select 1) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM (SELECT * FROM ab WHERE a = 1..." +== 393 +-- truncate_limit: 100 +-- A case containing a UNION ALL with a non-partitioned child. +explain (analyze, costs off, summary off, timing off) +select * from (select * from ab where a = 1 union all (values(10,5)) union all select * from ab) ab where b = (select 1) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM ((SELECT * FROM ab WHERE a = ..." +== 394 +-- truncate_limit: 100 +-- Another UNION ALL test, but containing a mix of exec init and exec run-time pruning. +create table xy_1 (x int, y int) +-- +TABLE: name="xy_1" schema="" table="xy_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE xy_1 (x int, y int)" +== 395 +-- truncate_limit: 100 +insert into xy_1 values(100,-10) +-- +TABLE: name="xy_1" schema="" table="xy_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xy_1 VALUES (100, -10)" +== 396 +-- truncate_limit: 100 +set enable_bitmapscan = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO 0" +== 397 +-- truncate_limit: 100 +set enable_indexscan = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO 0" +== 398 +-- truncate_limit: 100 +prepare ab_q6 as +select * from ( + select tableoid::regclass,a,b from ab +union all + select tableoid::regclass,x,y from xy_1 +union all + select tableoid::regclass,a,b from ab +) ab where a = $1 and b = (select -10) +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +TABLE: name="xy_1" schema="" table="xy_1" ctx=Select +TABLE: name="ab" schema="" table="ab" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ab_q6 AS SELECT * FROM ((SELECT tableoid::regclass, a, b FROM ab UNION ALL SELECT tableoi..." +== 399 +-- truncate_limit: 100 +-- Ensure the xy_1 subplan is not pruned. +explain (analyze, costs off, summary off, timing off) execute ab_q6(1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ab_q6(1)" +== 400 +-- truncate_limit: 100 +-- Ensure we see just the xy_1 row. +execute ab_q6(100) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE ab_q6(100)" +== 401 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 402 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 403 +-- truncate_limit: 100 +deallocate ab_q1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ab_q1" +== 404 +-- truncate_limit: 100 +deallocate ab_q2 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ab_q2" +== 405 +-- truncate_limit: 100 +deallocate ab_q3 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ab_q3" +== 406 +-- truncate_limit: 100 +deallocate ab_q4 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ab_q4" +== 407 +-- truncate_limit: 100 +deallocate ab_q5 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ab_q5" +== 408 +-- truncate_limit: 100 +deallocate ab_q6 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ab_q6" +== 409 +-- truncate_limit: 100 +-- UPDATE on a partition subtree has been seen to have problems. +insert into ab values (1,2) +-- +TABLE: name="ab" schema="" table="ab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ab VALUES (1, 2)" +== 410 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +update ab_a1 set b = 3 from ab where ab.a = 1 and ab.a = ab_a1.a +-- +TABLE: name="ab_a1" schema="" table="ab_a1" ctx=DML +TABLE: name="ab" schema="" table="ab" ctx=Select +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) UPDATE ab_a1 SET b = 3 FROM ab WHERE ab.a =..." +== 411 +-- truncate_limit: 100 +table ab +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ab" +== 412 +-- truncate_limit: 100 +-- Test UPDATE where source relation has run-time pruning enabled +truncate ab +-- +TABLE: name="ab" schema="" table="ab" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE ab" +== 413 +-- truncate_limit: 100 +insert into ab values (1, 1), (1, 2), (1, 3), (2, 1) +-- +TABLE: name="ab" schema="" table="ab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ab VALUES (1, 1), (1, 2), (1, 3), (2, 1)" +== 414 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +update ab_a1 set b = 3 from ab_a2 where ab_a2.b = (select 1) +-- +TABLE: name="ab_a1" schema="" table="ab_a1" ctx=DML +TABLE: name="ab_a2" schema="" table="ab_a2" ctx=Select +STMT: ExplainStmt +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) UPDATE ab_a1 SET b = 3 FROM ab_a2 WHERE ab_..." +== 415 +-- truncate_limit: 100 +select tableoid::regclass, * from ab +-- +TABLE: name="ab" schema="" table="ab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM ab" +== 416 +-- truncate_limit: 100 +drop table ab, lprt_a +-- +TABLE: name="ab" schema="" table="ab" ctx=DDL +TABLE: name="lprt_a" schema="" table="lprt_a" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ab, lprt_a" +== 417 +-- truncate_limit: 100 +-- Join +create table tbl1(col1 int) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl1 (col1 int)" +== 418 +-- truncate_limit: 100 +insert into tbl1 values (501), (505) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl1 VALUES (501), (505)" +== 419 +-- truncate_limit: 100 +-- Basic table +create table tprt (col1 int) partition by range (col1) +-- +TABLE: name="tprt" schema="" table="tprt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tprt (col1 int) PARTITION BY RANGE (col1)" +== 420 +-- truncate_limit: 100 +create table tprt_1 partition of tprt for values from (1) to (501) +-- +TABLE: name="tprt_1" schema="" table="tprt_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tprt_1 PARTITION OF tprt FOR VALUES FROM (1) TO (501)" +== 421 +-- truncate_limit: 100 +create table tprt_2 partition of tprt for values from (501) to (1001) +-- +TABLE: name="tprt_2" schema="" table="tprt_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tprt_2 PARTITION OF tprt FOR VALUES FROM (501) TO (1001)" +== 422 +-- truncate_limit: 100 +create table tprt_3 partition of tprt for values from (1001) to (2001) +-- +TABLE: name="tprt_3" schema="" table="tprt_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tprt_3 PARTITION OF tprt FOR VALUES FROM (1001) TO (2001)" +== 423 +-- truncate_limit: 100 +create table tprt_4 partition of tprt for values from (2001) to (3001) +-- +TABLE: name="tprt_4" schema="" table="tprt_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tprt_4 PARTITION OF tprt FOR VALUES FROM (2001) TO (3001)" +== 424 +-- truncate_limit: 100 +create table tprt_5 partition of tprt for values from (3001) to (4001) +-- +TABLE: name="tprt_5" schema="" table="tprt_5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tprt_5 PARTITION OF tprt FOR VALUES FROM (3001) TO (4001)" +== 425 +-- truncate_limit: 100 +create table tprt_6 partition of tprt for values from (4001) to (5001) +-- +TABLE: name="tprt_6" schema="" table="tprt_6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tprt_6 PARTITION OF tprt FOR VALUES FROM (4001) TO (5001)" +== 426 +-- truncate_limit: 100 +create index tprt1_idx on tprt_1 (col1) +-- +TABLE: name="tprt_1" schema="" table="tprt_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tprt1_idx ON tprt_1 USING btree (col1)" +== 427 +-- truncate_limit: 100 +create index tprt2_idx on tprt_2 (col1) +-- +TABLE: name="tprt_2" schema="" table="tprt_2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tprt2_idx ON tprt_2 USING btree (col1)" +== 428 +-- truncate_limit: 100 +create index tprt3_idx on tprt_3 (col1) +-- +TABLE: name="tprt_3" schema="" table="tprt_3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tprt3_idx ON tprt_3 USING btree (col1)" +== 429 +-- truncate_limit: 100 +create index tprt4_idx on tprt_4 (col1) +-- +TABLE: name="tprt_4" schema="" table="tprt_4" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tprt4_idx ON tprt_4 USING btree (col1)" +== 430 +-- truncate_limit: 100 +create index tprt5_idx on tprt_5 (col1) +-- +TABLE: name="tprt_5" schema="" table="tprt_5" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tprt5_idx ON tprt_5 USING btree (col1)" +== 431 +-- truncate_limit: 100 +create index tprt6_idx on tprt_6 (col1) +-- +TABLE: name="tprt_6" schema="" table="tprt_6" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tprt6_idx ON tprt_6 USING btree (col1)" +== 432 +-- truncate_limit: 100 +insert into tprt values (10), (20), (501), (502), (505), (1001), (4500) +-- +TABLE: name="tprt" schema="" table="tprt" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tprt VALUES (10), (20), (501), (502), (505), (1001), (4500)" +== 433 +-- truncate_limit: 100 +set enable_hashjoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 434 +-- truncate_limit: 100 +set enable_mergejoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 435 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 join tprt on tbl1.col1 > tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM tbl1 JOIN tprt ON tbl1.col1 >..." +== 436 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 join tprt on tbl1.col1 = tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM tbl1 JOIN tprt ON tbl1.col1 =..." +== 437 +-- truncate_limit: 100 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 > tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tbl1 JOIN tprt ON tbl1.col1 > tprt.col1 ORDER BY tbl1.col1, tprt.col1" +== 438 +-- truncate_limit: 100 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 = tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tbl1 JOIN tprt ON tbl1.col1 = tprt.col1 ORDER BY tbl1.col1, tprt.col1" +== 439 +-- truncate_limit: 100 +-- Multiple partitions +insert into tbl1 values (1001), (1010), (1011) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl1 VALUES (1001), (1010), (1011)" +== 440 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 inner join tprt on tbl1.col1 > tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM tbl1 JOIN tprt ON tbl1.col1 >..." +== 441 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 inner join tprt on tbl1.col1 = tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM tbl1 JOIN tprt ON tbl1.col1 =..." +== 442 +-- truncate_limit: 100 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 > tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tbl1 JOIN tprt ON tbl1.col1 > tprt.col1 ORDER BY tbl1.col1, tprt.col1" +== 443 +-- truncate_limit: 100 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 = tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tbl1 JOIN tprt ON tbl1.col1 = tprt.col1 ORDER BY tbl1.col1, tprt.col1" +== 444 +-- truncate_limit: 100 +-- Last partition +delete from tbl1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tbl1" +== 445 +-- truncate_limit: 100 +insert into tbl1 values (4400) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl1 VALUES (4400)" +== 446 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 join tprt on tbl1.col1 < tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM tbl1 JOIN tprt ON tbl1.col1 <..." +== 447 +-- truncate_limit: 100 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 < tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tbl1 JOIN tprt ON tbl1.col1 < tprt.col1 ORDER BY tbl1.col1, tprt.col1" +== 448 +-- truncate_limit: 100 +-- No matching partition +delete from tbl1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tbl1" +== 449 +-- truncate_limit: 100 +insert into tbl1 values (10000) +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tbl1 VALUES (10000)" +== 450 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from tbl1 join tprt on tbl1.col1 = tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM tbl1 JOIN tprt ON tbl1.col1 =..." +== 451 +-- truncate_limit: 100 +select tbl1.col1, tprt.col1 from tbl1 +inner join tprt on tbl1.col1 = tprt.col1 +order by tbl1.col1, tprt.col1 +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=Select +TABLE: name="tprt" schema="" table="tprt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tbl1 JOIN tprt ON tbl1.col1 = tprt.col1 ORDER BY tbl1.col1, tprt.col1" +== 452 +-- truncate_limit: 100 +drop table tbl1, tprt +-- +TABLE: name="tbl1" schema="" table="tbl1" ctx=DDL +TABLE: name="tprt" schema="" table="tprt" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbl1, tprt" +== 453 +-- truncate_limit: 100 +-- Test with columns defined in varying orders between each level +create table part_abc (a int not null, b int not null, c int not null) partition by list (a) +-- +TABLE: name="part_abc" schema="" table="part_abc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_abc (a int NOT NULL, b int NOT NULL, c int NOT NULL) PARTITION BY LIST (a)" +== 454 +-- truncate_limit: 100 +create table part_bac (b int not null, a int not null, c int not null) partition by list (b) +-- +TABLE: name="part_bac" schema="" table="part_bac" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_bac (b int NOT NULL, a int NOT NULL, c int NOT NULL) PARTITION BY LIST (b)" +== 455 +-- truncate_limit: 100 +create table part_cab (c int not null, a int not null, b int not null) partition by list (c) +-- +TABLE: name="part_cab" schema="" table="part_cab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_cab (c int NOT NULL, a int NOT NULL, b int NOT NULL) PARTITION BY LIST (c)" +== 456 +-- truncate_limit: 100 +create table part_abc_p1 (a int not null, b int not null, c int not null) +-- +TABLE: name="part_abc_p1" schema="" table="part_abc_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_abc_p1 (a int NOT NULL, b int NOT NULL, c int NOT NULL)" +== 457 +-- truncate_limit: 100 +alter table part_abc attach partition part_bac for values in(1) +-- +TABLE: name="part_abc" schema="" table="part_abc" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_abc ATTACH PARTITION part_bac FOR VALUES IN (1)" +== 458 +-- truncate_limit: 100 +alter table part_bac attach partition part_cab for values in(2) +-- +TABLE: name="part_bac" schema="" table="part_bac" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_bac ATTACH PARTITION part_cab FOR VALUES IN (2)" +== 459 +-- truncate_limit: 100 +alter table part_cab attach partition part_abc_p1 for values in(3) +-- +TABLE: name="part_cab" schema="" table="part_cab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_cab ATTACH PARTITION part_abc_p1 FOR VALUES IN (3)" +== 460 +-- truncate_limit: 100 +prepare part_abc_q1 (int, int, int) as +select * from part_abc where a = $1 and b = $2 and c = $3 +-- +TABLE: name="part_abc" schema="" table="part_abc" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE part_abc_q1(int, int, int) AS SELECT * FROM part_abc WHERE a = $1 AND b = $2 AND c = $3" +== 461 +-- truncate_limit: 100 +-- Single partition should be scanned. +explain (analyze, costs off, summary off, timing off) execute part_abc_q1 (1, 2, 3) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE part_abc_q1(1, 2, 3)" +== 462 +-- truncate_limit: 100 +deallocate part_abc_q1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE part_abc_q1" +== 463 +-- truncate_limit: 100 +drop table part_abc +-- +TABLE: name="part_abc" schema="" table="part_abc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_abc" +== 464 +-- truncate_limit: 100 +-- Ensure that an Append node properly handles a sub-partitioned table +-- matching without any of its leaf partitions matching the clause. +create table listp (a int, b int) partition by list (a) +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp (a int, b int) PARTITION BY LIST (a)" +== 465 +-- truncate_limit: 100 +create table listp_1 partition of listp for values in(1) partition by list (b) +-- +TABLE: name="listp_1" schema="" table="listp_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp_1 PARTITION OF listp FOR VALUES IN (1) PARTITION BY LIST (b)" +== 466 +-- truncate_limit: 100 +create table listp_1_1 partition of listp_1 for values in(1) +-- +TABLE: name="listp_1_1" schema="" table="listp_1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp_1_1 PARTITION OF listp_1 FOR VALUES IN (1)" +== 467 +-- truncate_limit: 100 +create table listp_2 partition of listp for values in(2) partition by list (b) +-- +TABLE: name="listp_2" schema="" table="listp_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp_2 PARTITION OF listp FOR VALUES IN (2) PARTITION BY LIST (b)" +== 468 +-- truncate_limit: 100 +create table listp_2_1 partition of listp_2 for values in(2) +-- +TABLE: name="listp_2_1" schema="" table="listp_2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp_2_1 PARTITION OF listp_2 FOR VALUES IN (2)" +== 469 +-- truncate_limit: 100 +select * from listp where b = 1 +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM listp WHERE b = 1" +== 470 +-- truncate_limit: 100 +-- Ensure that an Append node properly can handle selection of all first level +-- partitions before finally detecting the correct set of 2nd level partitions +-- which match the given parameter. +prepare q1 (int,int) as select * from listp where b in ($1,$2) +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q1(int, int) AS SELECT * FROM listp WHERE b IN ($1, $2)" +== 471 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute q1 (1,1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE q1(1, 1)" +== 472 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute q1 (2,2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE q1(2, 2)" +== 473 +-- truncate_limit: 100 +-- Try with no matching partitions. +explain (analyze, costs off, summary off, timing off) execute q1 (0,0) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE q1(0, 0)" +== 474 +-- truncate_limit: 100 +deallocate q1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q1" +== 475 +-- truncate_limit: 100 +-- Test more complex cases where a not-equal condition further eliminates partitions. +prepare q1 (int,int,int,int) as select * from listp where b in($1,$2) and $3 <> b and $4 <> b +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q1(int, int, int, int) AS SELECT * FROM listp WHERE b IN ($1, $2) AND $3 <> b AND $4 <> b" +== 476 +-- truncate_limit: 100 +-- Both partitions allowed by IN clause, but one disallowed by <> clause +explain (analyze, costs off, summary off, timing off) execute q1 (1,2,2,0) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE q1(1, 2, 2, 0)" +== 477 +-- truncate_limit: 100 +-- Both partitions allowed by IN clause, then both excluded again by <> clauses. +explain (analyze, costs off, summary off, timing off) execute q1 (1,2,2,1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE q1(1, 2, 2, 1)" +== 478 +-- truncate_limit: 100 +-- Ensure Params that evaluate to NULL properly prune away all partitions +explain (analyze, costs off, summary off, timing off) +select * from listp where a = (select null::int) +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM listp WHERE a = (SELECT NULL:..." +== 479 +-- truncate_limit: 100 +drop table listp +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE listp" +== 480 +-- truncate_limit: 100 +|-- +-- check that stable query clauses are only used in run-time pruning +|-- +create table stable_qual_pruning (a timestamp) partition by range (a) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stable_qual_pruning (a timestamp) PARTITION BY RANGE (a)" +== 481 +-- truncate_limit: 100 +create table stable_qual_pruning1 partition of stable_qual_pruning + for values from ('2000-01-01') to ('2000-02-01') +-- +TABLE: name="stable_qual_pruning1" schema="" table="stable_qual_pruning1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stable_qual_pruning1 PARTITION OF stable_qual_pruning FOR VALUES FROM ('2000-01-01')..." +== 482 +-- truncate_limit: 100 +create table stable_qual_pruning2 partition of stable_qual_pruning + for values from ('2000-02-01') to ('2000-03-01') +-- +TABLE: name="stable_qual_pruning2" schema="" table="stable_qual_pruning2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stable_qual_pruning2 PARTITION OF stable_qual_pruning FOR VALUES FROM ('2000-02-01')..." +== 483 +-- truncate_limit: 100 +create table stable_qual_pruning3 partition of stable_qual_pruning + for values from ('3000-02-01') to ('3000-03-01') +-- +TABLE: name="stable_qual_pruning3" schema="" table="stable_qual_pruning3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stable_qual_pruning3 PARTITION OF stable_qual_pruning FOR VALUES FROM ('3000-02-01')..." +== 484 +-- truncate_limit: 100 +-- comparison against a stable value requires run-time pruning +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning where a < localtimestamp +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM stable_qual_pruning WHERE a <..." +== 485 +-- truncate_limit: 100 +-- timestamp < timestamptz comparison is only stable, not immutable +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning where a < '2000-02-01'::timestamptz +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM stable_qual_pruning WHERE a <..." +== 486 +-- truncate_limit: 100 +-- check ScalarArrayOp cases +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2010-02-01', '2020-01-01']::timestamp[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM stable_qual_pruning WHERE a =..." +== 487 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2000-02-01', '2010-01-01']::timestamp[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM stable_qual_pruning WHERE a =..." +== 488 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2000-02-01', localtimestamp]::timestamp[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM stable_qual_pruning WHERE a =..." +== 489 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2010-02-01', '2020-01-01']::timestamptz[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM stable_qual_pruning WHERE a =..." +== 490 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(array['2000-02-01', '2010-01-01']::timestamptz[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM stable_qual_pruning WHERE a =..." +== 491 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from stable_qual_pruning + where a = any(null::timestamptz[]) +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM stable_qual_pruning WHERE a =..." +== 492 +-- truncate_limit: 100 +drop table stable_qual_pruning +-- +TABLE: name="stable_qual_pruning" schema="" table="stable_qual_pruning" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE stable_qual_pruning" +== 493 +-- truncate_limit: 100 +|-- +-- Check that pruning with composite range partitioning works correctly when +-- it must ignore clauses for trailing keys once it has seen a clause with +-- non-inclusive operator for an earlier key +|-- +create table mc3p (a int, b int, c int) partition by range (a, abs(b), c) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p (a int, b int, c int) PARTITION BY RANGE (a, (abs(b)), c)" +== 494 +-- truncate_limit: 100 +create table mc3p0 partition of mc3p + for values from (0, 0, 0) to (0, maxvalue, maxvalue) +-- +TABLE: name="mc3p0" schema="" table="mc3p0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p0 PARTITION OF mc3p FOR VALUES FROM (0, 0, 0) TO (0, maxvalue, maxvalue)" +== 495 +-- truncate_limit: 100 +create table mc3p1 partition of mc3p + for values from (1, 1, 1) to (2, minvalue, minvalue) +-- +TABLE: name="mc3p1" schema="" table="mc3p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p1 PARTITION OF mc3p FOR VALUES FROM (1, 1, 1) TO (2, minvalue, minvalue)" +== 496 +-- truncate_limit: 100 +create table mc3p2 partition of mc3p + for values from (2, minvalue, minvalue) to (3, maxvalue, maxvalue) +-- +TABLE: name="mc3p2" schema="" table="mc3p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mc3p2 PARTITION OF mc3p FOR VALUES FROM (2, minvalue, minvalue) TO (3, maxvalue, max..." +== 497 +-- truncate_limit: 100 +insert into mc3p values (0, 1, 1), (1, 1, 1), (2, 1, 1) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mc3p VALUES (0, 1, 1), (1, 1, 1), (2, 1, 1)" +== 498 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from mc3p where a < 3 and abs(b) = 1 +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM mc3p WHERE a < 3 AND abs(b) = 1" +== 499 +-- truncate_limit: 100 +|-- +-- Check that pruning with composite range partitioning works correctly when +-- a combination of runtime parameters is specified, not all of whose values +-- are available at the same time +|-- +prepare ps1 as + select * from mc3p where a = $1 and abs(b) < (select 3) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ps1 AS SELECT * FROM mc3p WHERE a = $1 AND abs(b) < (SELECT 3)" +== 500 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +execute ps1(1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ps1(1)" +== 501 +-- truncate_limit: 100 +deallocate ps1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ps1" +== 502 +-- truncate_limit: 100 +prepare ps2 as + select * from mc3p where a <= $1 and abs(b) < (select 3) +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ps2 AS SELECT * FROM mc3p WHERE a <= $1 AND abs(b) < (SELECT 3)" +== 503 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +execute ps2(1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE ps2(1)" +== 504 +-- truncate_limit: 100 +deallocate ps2 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ps2" +== 505 +-- truncate_limit: 100 +drop table mc3p +-- +TABLE: name="mc3p" schema="" table="mc3p" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mc3p" +== 506 +-- truncate_limit: 100 +-- Ensure runtime pruning works with initplans params with boolean types +create table boolvalues (value bool not null) +-- +TABLE: name="boolvalues" schema="" table="boolvalues" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolvalues (value bool NOT NULL)" +== 507 +-- truncate_limit: 100 +insert into boolvalues values('t'),('f') +-- +TABLE: name="boolvalues" schema="" table="boolvalues" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO boolvalues VALUES ('t'), ('f')" +== 508 +-- truncate_limit: 100 +create table boolp (a bool) partition by list (a) +-- +TABLE: name="boolp" schema="" table="boolp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolp (a bool) PARTITION BY LIST (a)" +== 509 +-- truncate_limit: 100 +create table boolp_t partition of boolp for values in('t') +-- +TABLE: name="boolp_t" schema="" table="boolp_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolp_t PARTITION OF boolp FOR VALUES IN ('t')" +== 510 +-- truncate_limit: 100 +create table boolp_f partition of boolp for values in('f') +-- +TABLE: name="boolp_f" schema="" table="boolp_f" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE boolp_f PARTITION OF boolp FOR VALUES IN ('f')" +== 511 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from boolp where a = (select value from boolvalues where value) +-- +TABLE: name="boolp" schema="" table="boolp" ctx=Select +TABLE: name="boolvalues" schema="" table="boolvalues" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="value" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM boolp WHERE a = (SELECT value..." +== 512 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from boolp where a = (select value from boolvalues where not value) +-- +TABLE: name="boolp" schema="" table="boolp" ctx=Select +TABLE: name="boolvalues" schema="" table="boolvalues" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="value" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM boolp WHERE a = (SELECT value..." +== 513 +-- truncate_limit: 100 +drop table boolp +-- +TABLE: name="boolp" schema="" table="boolp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE boolp" +== 514 +-- truncate_limit: 100 +|-- +-- Test run-time pruning of MergeAppend subnodes +|-- +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 515 +-- truncate_limit: 100 +set enable_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO OFF" +== 516 +-- truncate_limit: 100 +create table ma_test (a int, b int) partition by range (a) +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ma_test (a int, b int) PARTITION BY RANGE (a)" +== 517 +-- truncate_limit: 100 +create table ma_test_p1 partition of ma_test for values from (0) to (10) +-- +TABLE: name="ma_test_p1" schema="" table="ma_test_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ma_test_p1 PARTITION OF ma_test FOR VALUES FROM (0) TO (10)" +== 518 +-- truncate_limit: 100 +create table ma_test_p2 partition of ma_test for values from (10) to (20) +-- +TABLE: name="ma_test_p2" schema="" table="ma_test_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ma_test_p2 PARTITION OF ma_test FOR VALUES FROM (10) TO (20)" +== 519 +-- truncate_limit: 100 +create table ma_test_p3 partition of ma_test for values from (20) to (30) +-- +TABLE: name="ma_test_p3" schema="" table="ma_test_p3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ma_test_p3 PARTITION OF ma_test FOR VALUES FROM (20) TO (30)" +== 520 +-- truncate_limit: 100 +insert into ma_test select x,x from generate_series(0,29) t(x) +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ma_test SELECT x, x FROM generate_series(0, 29) t(x)" +== 521 +-- truncate_limit: 100 +create index on ma_test (b) +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON ma_test USING btree (b)" +== 522 +-- truncate_limit: 100 +analyze ma_test +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ma_test" +== 523 +-- truncate_limit: 100 +prepare mt_q1 (int) as select a from ma_test where a >= $1 and a % 10 = 5 order by b +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE mt_q1(int) AS SELECT a FROM ma_test WHERE a >= $1 AND (a % 10) = 5 ORDER BY b" +== 524 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute mt_q1(15) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE mt_q1(15)" +== 525 +-- truncate_limit: 100 +execute mt_q1(15) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE mt_q1(15)" +== 526 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) execute mt_q1(25) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE mt_q1(25)" +== 527 +-- truncate_limit: 100 +execute mt_q1(25) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE mt_q1(25)" +== 528 +-- truncate_limit: 100 +-- Ensure MergeAppend behaves correctly when no subplans match +explain (analyze, costs off, summary off, timing off) execute mt_q1(35) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE mt_q1(35)" +== 529 +-- truncate_limit: 100 +execute mt_q1(35) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE mt_q1(35)" +== 530 +-- truncate_limit: 100 +deallocate mt_q1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE mt_q1" +== 531 +-- truncate_limit: 100 +prepare mt_q2 (int) as select * from ma_test where a >= $1 order by b limit 1 +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=Select +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE mt_q2(int) AS SELECT * FROM ma_test WHERE a >= $1 ORDER BY b LIMIT 1" +== 532 +-- truncate_limit: 100 +-- Ensure output list looks sane when the MergeAppend has no subplans. +explain (analyze, verbose, costs off, summary off, timing off) execute mt_q2 (35) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, VERBOSE, COSTS OFF, SUMMARY OFF, TIMING OFF) EXECUTE mt_q2(35)" +== 533 +-- truncate_limit: 100 +deallocate mt_q2 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE mt_q2" +== 534 +-- truncate_limit: 100 +-- ensure initplan params properly prune partitions +explain (analyze, costs off, summary off, timing off) select * from ma_test where a >= (select min(b) from ma_test_p2) order by b +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=Select +TABLE: name="ma_test_p2" schema="" table="ma_test_p2" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM ma_test WHERE a >= (SELECT mi..." +== 535 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 536 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 537 +-- truncate_limit: 100 +drop table ma_test +-- +TABLE: name="ma_test" schema="" table="ma_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ma_test" +== 538 +-- truncate_limit: 100 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexonlyscan" +== 539 +-- truncate_limit: 100 +|-- +-- check that pruning works properly when the partition key is of a +-- pseudotype +|-- + +-- array type list partition key +create table pp_arrpart (a int[]) partition by list (a) +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_arrpart (a int[]) PARTITION BY LIST (a)" +== 540 +-- truncate_limit: 100 +create table pp_arrpart1 partition of pp_arrpart for values in ('{1}') +-- +TABLE: name="pp_arrpart1" schema="" table="pp_arrpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_arrpart1 PARTITION OF pp_arrpart FOR VALUES IN ('{1}')" +== 541 +-- truncate_limit: 100 +create table pp_arrpart2 partition of pp_arrpart for values in ('{2, 3}', '{4, 5}') +-- +TABLE: name="pp_arrpart2" schema="" table="pp_arrpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_arrpart2 PARTITION OF pp_arrpart FOR VALUES IN ('{2, 3}', '{4, 5}')" +== 542 +-- truncate_limit: 100 +explain (costs off) select * from pp_arrpart where a = '{1}' +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_arrpart WHERE a = '{1}'" +== 543 +-- truncate_limit: 100 +explain (costs off) select * from pp_arrpart where a = '{1, 2}' +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_arrpart WHERE a = '{1, 2}'" +== 544 +-- truncate_limit: 100 +explain (costs off) select * from pp_arrpart where a in ('{4, 5}', '{1}') +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_arrpart WHERE a IN ('{4, 5}', '{1}')" +== 545 +-- truncate_limit: 100 +explain (costs off) update pp_arrpart set a = a where a = '{1}' +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE pp_arrpart SET a = a WHERE a = '{1}'" +== 546 +-- truncate_limit: 100 +explain (costs off) delete from pp_arrpart where a = '{1}' +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM pp_arrpart WHERE a = '{1}'" +== 547 +-- truncate_limit: 100 +drop table pp_arrpart +-- +TABLE: name="pp_arrpart" schema="" table="pp_arrpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp_arrpart" +== 548 +-- truncate_limit: 100 +-- array type hash partition key +create table pph_arrpart (a int[]) partition by hash (a) +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pph_arrpart (a int[]) PARTITION BY HASH (a)" +== 549 +-- truncate_limit: 100 +create table pph_arrpart1 partition of pph_arrpart for values with (modulus 2, remainder 0) +-- +TABLE: name="pph_arrpart1" schema="" table="pph_arrpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pph_arrpart1 PARTITION OF pph_arrpart FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 550 +-- truncate_limit: 100 +create table pph_arrpart2 partition of pph_arrpart for values with (modulus 2, remainder 1) +-- +TABLE: name="pph_arrpart2" schema="" table="pph_arrpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pph_arrpart2 PARTITION OF pph_arrpart FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 551 +-- truncate_limit: 100 +insert into pph_arrpart values ('{1}'), ('{1, 2}'), ('{4, 5}') +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pph_arrpart VALUES ('{1}'), ('{1, 2}'), ('{4, 5}')" +== 552 +-- truncate_limit: 100 +select tableoid::regclass, * from pph_arrpart order by 1 +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM pph_arrpart ORDER BY 1" +== 553 +-- truncate_limit: 100 +explain (costs off) select * from pph_arrpart where a = '{1}' +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pph_arrpart WHERE a = '{1}'" +== 554 +-- truncate_limit: 100 +explain (costs off) select * from pph_arrpart where a = '{1, 2}' +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pph_arrpart WHERE a = '{1, 2}'" +== 555 +-- truncate_limit: 100 +explain (costs off) select * from pph_arrpart where a in ('{4, 5}', '{1}') +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pph_arrpart WHERE a IN ('{4, 5}', '{1}')" +== 556 +-- truncate_limit: 100 +drop table pph_arrpart +-- +TABLE: name="pph_arrpart" schema="" table="pph_arrpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pph_arrpart" +== 557 +-- truncate_limit: 100 +-- enum type list partition key +create type pp_colors as enum ('green', 'blue', 'black') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE pp_colors AS ENUM ('green', 'blue', 'black')" +== 558 +-- truncate_limit: 100 +create table pp_enumpart (a pp_colors) partition by list (a) +-- +TABLE: name="pp_enumpart" schema="" table="pp_enumpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_enumpart (a pp_colors) PARTITION BY LIST (a)" +== 559 +-- truncate_limit: 100 +create table pp_enumpart_green partition of pp_enumpart for values in ('green') +-- +TABLE: name="pp_enumpart_green" schema="" table="pp_enumpart_green" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_enumpart_green PARTITION OF pp_enumpart FOR VALUES IN ('green')" +== 560 +-- truncate_limit: 100 +create table pp_enumpart_blue partition of pp_enumpart for values in ('blue') +-- +TABLE: name="pp_enumpart_blue" schema="" table="pp_enumpart_blue" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_enumpart_blue PARTITION OF pp_enumpart FOR VALUES IN ('blue')" +== 561 +-- truncate_limit: 100 +explain (costs off) select * from pp_enumpart where a = 'blue' +-- +TABLE: name="pp_enumpart" schema="" table="pp_enumpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_enumpart WHERE a = 'blue'" +== 562 +-- truncate_limit: 100 +explain (costs off) select * from pp_enumpart where a = 'black' +-- +TABLE: name="pp_enumpart" schema="" table="pp_enumpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_enumpart WHERE a = 'black'" +== 563 +-- truncate_limit: 100 +drop table pp_enumpart +-- +TABLE: name="pp_enumpart" schema="" table="pp_enumpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp_enumpart" +== 564 +-- truncate_limit: 100 +drop type pp_colors +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE pp_colors" +== 565 +-- truncate_limit: 100 +-- record type as partition key +create type pp_rectype as (a int, b int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE pp_rectype AS (a int, b int)" +== 566 +-- truncate_limit: 100 +create table pp_recpart (a pp_rectype) partition by list (a) +-- +TABLE: name="pp_recpart" schema="" table="pp_recpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_recpart (a pp_rectype) PARTITION BY LIST (a)" +== 567 +-- truncate_limit: 100 +create table pp_recpart_11 partition of pp_recpart for values in ('(1,1)') +-- +TABLE: name="pp_recpart_11" schema="" table="pp_recpart_11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_recpart_11 PARTITION OF pp_recpart FOR VALUES IN ('(1,1)')" +== 568 +-- truncate_limit: 100 +create table pp_recpart_23 partition of pp_recpart for values in ('(2,3)') +-- +TABLE: name="pp_recpart_23" schema="" table="pp_recpart_23" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_recpart_23 PARTITION OF pp_recpart FOR VALUES IN ('(2,3)')" +== 569 +-- truncate_limit: 100 +explain (costs off) select * from pp_recpart where a = '(1,1)'::pp_rectype +-- +TABLE: name="pp_recpart" schema="" table="pp_recpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_recpart WHERE a = '(1,1)'::pp_rectype" +== 570 +-- truncate_limit: 100 +explain (costs off) select * from pp_recpart where a = '(1,2)'::pp_rectype +-- +TABLE: name="pp_recpart" schema="" table="pp_recpart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_recpart WHERE a = '(1,2)'::pp_rectype" +== 571 +-- truncate_limit: 100 +drop table pp_recpart +-- +TABLE: name="pp_recpart" schema="" table="pp_recpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp_recpart" +== 572 +-- truncate_limit: 100 +drop type pp_rectype +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE pp_rectype" +== 573 +-- truncate_limit: 100 +-- range type partition key +create table pp_intrangepart (a int4range) partition by list (a) +-- +TABLE: name="pp_intrangepart" schema="" table="pp_intrangepart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_intrangepart (a int4range) PARTITION BY LIST (a)" +== 574 +-- truncate_limit: 100 +create table pp_intrangepart12 partition of pp_intrangepart for values in ('[1,2]') +-- +TABLE: name="pp_intrangepart12" schema="" table="pp_intrangepart12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_intrangepart12 PARTITION OF pp_intrangepart FOR VALUES IN ('[1,2]')" +== 575 +-- truncate_limit: 100 +create table pp_intrangepart2inf partition of pp_intrangepart for values in ('[2,)') +-- +TABLE: name="pp_intrangepart2inf" schema="" table="pp_intrangepart2inf" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_intrangepart2inf PARTITION OF pp_intrangepart FOR VALUES IN ('[2,)')" +== 576 +-- truncate_limit: 100 +explain (costs off) select * from pp_intrangepart where a = '[1,2]'::int4range +-- +TABLE: name="pp_intrangepart" schema="" table="pp_intrangepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_intrangepart WHERE a = '[1,2]'::int4range" +== 577 +-- truncate_limit: 100 +explain (costs off) select * from pp_intrangepart where a = '(1,2)'::int4range +-- +TABLE: name="pp_intrangepart" schema="" table="pp_intrangepart" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_intrangepart WHERE a = '(1,2)'::int4range" +== 578 +-- truncate_limit: 100 +drop table pp_intrangepart +-- +TABLE: name="pp_intrangepart" schema="" table="pp_intrangepart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp_intrangepart" +== 579 +-- truncate_limit: 100 +|-- +-- Ensure the enable_partition_prune GUC properly disables partition pruning. +|-- + +create table pp_lp (a int, value int) partition by list (a) +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_lp (a int, value int) PARTITION BY LIST (a)" +== 580 +-- truncate_limit: 100 +create table pp_lp1 partition of pp_lp for values in(1) +-- +TABLE: name="pp_lp1" schema="" table="pp_lp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_lp1 PARTITION OF pp_lp FOR VALUES IN (1)" +== 581 +-- truncate_limit: 100 +create table pp_lp2 partition of pp_lp for values in(2) +-- +TABLE: name="pp_lp2" schema="" table="pp_lp2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pp_lp2 PARTITION OF pp_lp FOR VALUES IN (2)" +== 582 +-- truncate_limit: 100 +explain (costs off) select * from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_lp WHERE a = 1" +== 583 +-- truncate_limit: 100 +explain (costs off) update pp_lp set value = 10 where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE pp_lp SET value = 10 WHERE a = 1" +== 584 +-- truncate_limit: 100 +explain (costs off) delete from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM pp_lp WHERE a = 1" +== 585 +-- truncate_limit: 100 +set enable_partition_pruning = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partition_pruning TO OFF" +== 586 +-- truncate_limit: 100 +set constraint_exclusion = 'partition' +-- +STMT: VariableSetStmt +TRUNCATED: "SET constraint_exclusion TO partition" +== 587 +-- truncate_limit: 100 +-- this should not affect the result. + +explain (costs off) select * from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_lp WHERE a = 1" +== 588 +-- truncate_limit: 100 +explain (costs off) update pp_lp set value = 10 where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE pp_lp SET value = 10 WHERE a = 1" +== 589 +-- truncate_limit: 100 +explain (costs off) delete from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM pp_lp WHERE a = 1" +== 590 +-- truncate_limit: 100 +set constraint_exclusion = 'off' +-- +STMT: VariableSetStmt +TRUNCATED: "SET constraint_exclusion TO OFF" +== 591 +-- truncate_limit: 100 +-- this should not affect the result. + +explain (costs off) select * from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_lp WHERE a = 1" +== 592 +-- truncate_limit: 100 +explain (costs off) update pp_lp set value = 10 where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE pp_lp SET value = 10 WHERE a = 1" +== 593 +-- truncate_limit: 100 +explain (costs off) delete from pp_lp where a = 1 +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM pp_lp WHERE a = 1" +== 594 +-- truncate_limit: 100 +drop table pp_lp +-- +TABLE: name="pp_lp" schema="" table="pp_lp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp_lp" +== 595 +-- truncate_limit: 100 +-- Ensure enable_partition_prune does not affect non-partitioned tables. + +create table inh_lp (a int, value int) +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_lp (a int, value int)" +== 596 +-- truncate_limit: 100 +create table inh_lp1 (a int, value int, check(a = 1)) inherits (inh_lp) +-- +TABLE: name="inh_lp1" schema="" table="inh_lp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_lp1 (a int, value int, CHECK (a = 1)) INHERITS (inh_lp)" +== 597 +-- truncate_limit: 100 +create table inh_lp2 (a int, value int, check(a = 2)) inherits (inh_lp) +-- +TABLE: name="inh_lp2" schema="" table="inh_lp2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE inh_lp2 (a int, value int, CHECK (a = 2)) INHERITS (inh_lp)" +== 598 +-- truncate_limit: 100 +set constraint_exclusion = 'partition' +-- +STMT: VariableSetStmt +TRUNCATED: "SET constraint_exclusion TO partition" +== 599 +-- truncate_limit: 100 +-- inh_lp2 should be removed in the following 3 cases. +explain (costs off) select * from inh_lp where a = 1 +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM inh_lp WHERE a = 1" +== 600 +-- truncate_limit: 100 +explain (costs off) update inh_lp set value = 10 where a = 1 +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE inh_lp SET value = 10 WHERE a = 1" +== 601 +-- truncate_limit: 100 +explain (costs off) delete from inh_lp where a = 1 +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM inh_lp WHERE a = 1" +== 602 +-- truncate_limit: 100 +-- Ensure we don't exclude normal relations when we only expect to exclude +-- inheritance children +explain (costs off) update inh_lp1 set value = 10 where a = 2 +-- +TABLE: name="inh_lp1" schema="" table="inh_lp1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE inh_lp1 SET value = 10 WHERE a = 2" +== 603 +-- truncate_limit: 100 +drop table inh_lp cascade +-- +TABLE: name="inh_lp" schema="" table="inh_lp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE inh_lp CASCADE" +== 604 +-- truncate_limit: 100 +reset enable_partition_pruning +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_partition_pruning" +== 605 +-- truncate_limit: 100 +reset constraint_exclusion +-- +STMT: VariableSetStmt +TRUNCATED: "RESET constraint_exclusion" +== 606 +-- truncate_limit: 100 +-- Check pruning for a partition tree containing only temporary relations +create temp table pp_temp_parent (a int) partition by list (a) +-- +TABLE: name="pp_temp_parent" schema="" table="pp_temp_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pp_temp_parent (a int) PARTITION BY LIST (a)" +== 607 +-- truncate_limit: 100 +create temp table pp_temp_part_1 partition of pp_temp_parent for values in (1) +-- +TABLE: name="pp_temp_part_1" schema="" table="pp_temp_part_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pp_temp_part_1 PARTITION OF pp_temp_parent FOR VALUES IN (1)" +== 608 +-- truncate_limit: 100 +create temp table pp_temp_part_def partition of pp_temp_parent default +-- +TABLE: name="pp_temp_part_def" schema="" table="pp_temp_part_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pp_temp_part_def PARTITION OF pp_temp_parent DEFAULT" +== 609 +-- truncate_limit: 100 +explain (costs off) select * from pp_temp_parent where true +-- +TABLE: name="pp_temp_parent" schema="" table="pp_temp_parent" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_temp_parent WHERE true" +== 610 +-- truncate_limit: 100 +explain (costs off) select * from pp_temp_parent where a = 2 +-- +TABLE: name="pp_temp_parent" schema="" table="pp_temp_parent" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pp_temp_parent WHERE a = 2" +== 611 +-- truncate_limit: 100 +drop table pp_temp_parent +-- +TABLE: name="pp_temp_parent" schema="" table="pp_temp_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pp_temp_parent" +== 612 +-- truncate_limit: 100 +-- Stress run-time partition pruning a bit more, per bug reports +create temp table p (a int, b int, c int) partition by list (a) +-- +TABLE: name="p" schema="" table="p" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE p (a int, b int, c int) PARTITION BY LIST (a)" +== 613 +-- truncate_limit: 100 +create temp table p1 partition of p for values in (1) +-- +TABLE: name="p1" schema="" table="p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE p1 PARTITION OF p FOR VALUES IN (1)" +== 614 +-- truncate_limit: 100 +create temp table p2 partition of p for values in (2) +-- +TABLE: name="p2" schema="" table="p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE p2 PARTITION OF p FOR VALUES IN (2)" +== 615 +-- truncate_limit: 100 +create temp table q (a int, b int, c int) partition by list (a) +-- +TABLE: name="q" schema="" table="q" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE q (a int, b int, c int) PARTITION BY LIST (a)" +== 616 +-- truncate_limit: 100 +create temp table q1 partition of q for values in (1) partition by list (b) +-- +TABLE: name="q1" schema="" table="q1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE q1 PARTITION OF q FOR VALUES IN (1) PARTITION BY LIST (b)" +== 617 +-- truncate_limit: 100 +create temp table q11 partition of q1 for values in (1) partition by list (c) +-- +TABLE: name="q11" schema="" table="q11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE q11 PARTITION OF q1 FOR VALUES IN (1) PARTITION BY LIST (c)" +== 618 +-- truncate_limit: 100 +create temp table q111 partition of q11 for values in (1) +-- +TABLE: name="q111" schema="" table="q111" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE q111 PARTITION OF q11 FOR VALUES IN (1)" +== 619 +-- truncate_limit: 100 +create temp table q2 partition of q for values in (2) partition by list (b) +-- +TABLE: name="q2" schema="" table="q2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE q2 PARTITION OF q FOR VALUES IN (2) PARTITION BY LIST (b)" +== 620 +-- truncate_limit: 100 +create temp table q21 partition of q2 for values in (1) +-- +TABLE: name="q21" schema="" table="q21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE q21 PARTITION OF q2 FOR VALUES IN (1)" +== 621 +-- truncate_limit: 100 +create temp table q22 partition of q2 for values in (2) +-- +TABLE: name="q22" schema="" table="q22" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE q22 PARTITION OF q2 FOR VALUES IN (2)" +== 622 +-- truncate_limit: 100 +insert into q22 values (2, 2, 3) +-- +TABLE: name="q22" schema="" table="q22" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO q22 VALUES (2, 2, 3)" +== 623 +-- truncate_limit: 100 +explain (costs off) +select * +from ( + select * from p + union all + select * from q1 + union all + select 1, 1, 1 + ) s(a, b, c) +where s.a = 1 and s.b = 1 and s.c = (select 1) +-- +TABLE: name="p" schema="" table="p" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="b" +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ((SELECT * FROM p UNION ALL SELECT * FROM q1) UNION ALL SELECT ..." +== 624 +-- truncate_limit: 100 +select * +from ( + select * from p + union all + select * from q1 + union all + select 1, 1, 1 + ) s(a, b, c) +where s.a = 1 and s.b = 1 and s.c = (select 1) +-- +TABLE: name="p" schema="" table="p" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="b" +FILTER: schema="" table="s" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ((SELECT * FROM p UNION ALL SELECT * FROM q1) UNION ALL SELECT ...) s(a, b, c) WHER..." +== 625 +-- truncate_limit: 100 +prepare q (int, int) as +select * +from ( + select * from p + union all + select * from q1 + union all + select 1, 1, 1 + ) s(a, b, c) +where s.a = $1 and s.b = $2 and s.c = (select 1) +-- +TABLE: name="p" schema="" table="p" ctx=Select +TABLE: name="q1" schema="" table="q1" ctx=Select +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="s" column="b" +FILTER: schema="" table="s" column="c" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q(int, int) AS SELECT * FROM ((SELECT * FROM p UNION ALL SELECT * FROM q1) UNION ALL SELE..." +== 626 +-- truncate_limit: 100 +explain (costs off) execute q (1, 1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE q(1, 1)" +== 627 +-- truncate_limit: 100 +execute q (1, 1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q(1, 1)" +== 628 +-- truncate_limit: 100 +drop table p, q +-- +TABLE: name="p" schema="" table="p" ctx=DDL +TABLE: name="q" schema="" table="q" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE p, q" +== 629 +-- truncate_limit: 100 +-- Ensure run-time pruning works correctly when we match a partitioned table +-- on the first level but find no matching partitions on the second level. +create table listp (a int, b int) partition by list (a) +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp (a int, b int) PARTITION BY LIST (a)" +== 630 +-- truncate_limit: 100 +create table listp1 partition of listp for values in(1) +-- +TABLE: name="listp1" schema="" table="listp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp1 PARTITION OF listp FOR VALUES IN (1)" +== 631 +-- truncate_limit: 100 +create table listp2 partition of listp for values in(2) partition by list(b) +-- +TABLE: name="listp2" schema="" table="listp2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp2 PARTITION OF listp FOR VALUES IN (2) PARTITION BY LIST (b)" +== 632 +-- truncate_limit: 100 +create table listp2_10 partition of listp2 for values in (10) +-- +TABLE: name="listp2_10" schema="" table="listp2_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp2_10 PARTITION OF listp2 FOR VALUES IN (10)" +== 633 +-- truncate_limit: 100 +explain (analyze, costs off, summary off, timing off) +select * from listp where a = (select 2) and b <> 10 +-- +TABLE: name="listp" schema="" table="listp" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) SELECT * FROM listp WHERE a = (SELECT 2) AN..." +== 634 +-- truncate_limit: 100 +|-- +-- check that a partition directly accessed in a query is excluded with +-- constraint_exclusion = on +|-- + +-- turn off partition pruning, so that it doesn't interfere +set enable_partition_pruning to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_partition_pruning TO OFF" +== 635 +-- truncate_limit: 100 +-- setting constraint_exclusion to 'partition' disables exclusion +set constraint_exclusion to 'partition' +-- +STMT: VariableSetStmt +TRUNCATED: "SET constraint_exclusion TO partition" +== 636 +-- truncate_limit: 100 +explain (costs off) select * from listp1 where a = 2 +-- +TABLE: name="listp1" schema="" table="listp1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM listp1 WHERE a = 2" +== 637 +-- truncate_limit: 100 +explain (costs off) update listp1 set a = 1 where a = 2 +-- +TABLE: name="listp1" schema="" table="listp1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE listp1 SET a = 1 WHERE a = 2" +== 638 +-- truncate_limit: 100 +-- constraint exclusion enabled +set constraint_exclusion to 'on' +-- +STMT: VariableSetStmt +TRUNCATED: "SET constraint_exclusion TO ON" +== 639 +-- truncate_limit: 100 +explain (costs off) select * from listp1 where a = 2 +-- +TABLE: name="listp1" schema="" table="listp1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM listp1 WHERE a = 2" +== 640 +-- truncate_limit: 100 +explain (costs off) update listp1 set a = 1 where a = 2 +-- +TABLE: name="listp1" schema="" table="listp1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE listp1 SET a = 1 WHERE a = 2" +== 641 +-- truncate_limit: 100 +reset constraint_exclusion +-- +STMT: VariableSetStmt +TRUNCATED: "RESET constraint_exclusion" +== 642 +-- truncate_limit: 100 +reset enable_partition_pruning +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_partition_pruning" +== 643 +-- truncate_limit: 100 +drop table listp +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE listp" +== 644 +-- truncate_limit: 100 +-- Ensure run-time pruning works correctly for nested Append nodes +set parallel_setup_cost to 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 645 +-- truncate_limit: 100 +set parallel_tuple_cost to 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 646 +-- truncate_limit: 100 +create table listp (a int) partition by list(a) +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp (a int) PARTITION BY LIST (a)" +== 647 +-- truncate_limit: 100 +create table listp_12 partition of listp for values in(1,2) partition by list(a) +-- +TABLE: name="listp_12" schema="" table="listp_12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp_12 PARTITION OF listp FOR VALUES IN (1, 2) PARTITION BY LIST (a)" +== 648 +-- truncate_limit: 100 +create table listp_12_1 partition of listp_12 for values in(1) +-- +TABLE: name="listp_12_1" schema="" table="listp_12_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp_12_1 PARTITION OF listp_12 FOR VALUES IN (1)" +== 649 +-- truncate_limit: 100 +create table listp_12_2 partition of listp_12 for values in(2) +-- +TABLE: name="listp_12_2" schema="" table="listp_12_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE listp_12_2 PARTITION OF listp_12 FOR VALUES IN (2)" +== 650 +-- truncate_limit: 100 +-- Force the 2nd subnode of the Append to be non-parallel. This results in +-- a nested Append node because the mixed parallel / non-parallel paths cannot +-- be pulled into the top-level Append. +alter table listp_12_1 set (parallel_workers = 0) +-- +TABLE: name="listp_12_1" schema="" table="listp_12_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE listp_12_1 SET (parallel_workers=0)" +== 651 +-- truncate_limit: 100 +-- Ensure that listp_12_2 is not scanned. (The nested Append is not seen in +-- the plan as it's pulled in setref.c due to having just a single subnode). +select explain_parallel_append('select * from listp where a = (select 1);') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT explain_parallel_append('select * from listp where a = (select 1);')" +== 652 +-- truncate_limit: 100 +-- Like the above but throw some more complexity at the planner by adding +-- a UNION ALL. We expect both sides of the union not to scan the +-- non-required partitions. +select explain_parallel_append( +'select * from listp where a = (select 1) + union all +select * from listp where a = (select 2);') +-- +FUNCTION: name="explain_parallel_append" function="explain_parallel_append" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 653 +-- truncate_limit: 100 +drop table listp +-- +TABLE: name="listp" schema="" table="listp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE listp" +== 654 +-- truncate_limit: 100 +reset parallel_tuple_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_tuple_cost" +== 655 +-- truncate_limit: 100 +reset parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 656 +-- truncate_limit: 100 +-- Test case for run-time pruning with a nested Merge Append +set enable_sort to 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO 0" +== 657 +-- truncate_limit: 100 +create table rangep (a int, b int) partition by range (a) +-- +TABLE: name="rangep" schema="" table="rangep" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rangep (a int, b int) PARTITION BY RANGE (a)" +== 658 +-- truncate_limit: 100 +create table rangep_0_to_100 partition of rangep for values from (0) to (100) partition by list (b) +-- +TABLE: name="rangep_0_to_100" schema="" table="rangep_0_to_100" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rangep_0_to_100 PARTITION OF rangep FOR VALUES FROM (0) TO (100) PARTITION BY LIST (b)" +== 659 +-- truncate_limit: 100 +-- We need 3 sub-partitions. 1 to validate pruning worked and another two +-- because a single remaining partition would be pulled up to the main Append. +create table rangep_0_to_100_1 partition of rangep_0_to_100 for values in(1) +-- +TABLE: name="rangep_0_to_100_1" schema="" table="rangep_0_to_100_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rangep_0_to_100_1 PARTITION OF rangep_0_to_100 FOR VALUES IN (1)" +== 660 +-- truncate_limit: 100 +create table rangep_0_to_100_2 partition of rangep_0_to_100 for values in(2) +-- +TABLE: name="rangep_0_to_100_2" schema="" table="rangep_0_to_100_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rangep_0_to_100_2 PARTITION OF rangep_0_to_100 FOR VALUES IN (2)" +== 661 +-- truncate_limit: 100 +create table rangep_0_to_100_3 partition of rangep_0_to_100 for values in(3) +-- +TABLE: name="rangep_0_to_100_3" schema="" table="rangep_0_to_100_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rangep_0_to_100_3 PARTITION OF rangep_0_to_100 FOR VALUES IN (3)" +== 662 +-- truncate_limit: 100 +create table rangep_100_to_200 partition of rangep for values from (100) to (200) +-- +TABLE: name="rangep_100_to_200" schema="" table="rangep_100_to_200" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rangep_100_to_200 PARTITION OF rangep FOR VALUES FROM (100) TO (200)" +== 663 +-- truncate_limit: 100 +create index on rangep (a) +-- +TABLE: name="rangep" schema="" table="rangep" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON rangep USING btree (a)" +== 664 +-- truncate_limit: 100 +-- Ensure run-time pruning works on the nested Merge Append +explain (analyze on, costs off, timing off, summary off) +select * from rangep where b IN((select 1),(select 2)) order by a +-- +TABLE: name="rangep" schema="" table="rangep" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE ON, COSTS OFF, TIMING OFF, SUMMARY OFF) SELECT * FROM rangep WHERE b IN ((SELECT..." +== 665 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 666 +-- truncate_limit: 100 +drop table rangep +-- +TABLE: name="rangep" schema="" table="rangep" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rangep" +== 667 +-- truncate_limit: 100 +|-- +-- Check that gen_prune_steps_from_opexps() works well for various cases of +-- clauses for different partition keys +|-- + +create table rp_prefix_test1 (a int, b varchar) partition by range(a, b) +-- +TABLE: name="rp_prefix_test1" schema="" table="rp_prefix_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test1 (a int, b varchar) PARTITION BY RANGE (a, b)" +== 668 +-- truncate_limit: 100 +create table rp_prefix_test1_p1 partition of rp_prefix_test1 for values from (1, 'a') to (1, 'b') +-- +TABLE: name="rp_prefix_test1_p1" schema="" table="rp_prefix_test1_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test1_p1 PARTITION OF rp_prefix_test1 FOR VALUES FROM (1, 'a') TO (1, 'b')" +== 669 +-- truncate_limit: 100 +create table rp_prefix_test1_p2 partition of rp_prefix_test1 for values from (2, 'a') to (2, 'b') +-- +TABLE: name="rp_prefix_test1_p2" schema="" table="rp_prefix_test1_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test1_p2 PARTITION OF rp_prefix_test1 FOR VALUES FROM (2, 'a') TO (2, 'b')" +== 670 +-- truncate_limit: 100 +-- Don't call get_steps_using_prefix() with the last partition key b plus +-- an empty prefix +explain (costs off) select * from rp_prefix_test1 where a <= 1 and b = 'a' +-- +TABLE: name="rp_prefix_test1" schema="" table="rp_prefix_test1" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rp_prefix_test1 WHERE a <= 1 AND b = 'a'" +== 671 +-- truncate_limit: 100 +create table rp_prefix_test2 (a int, b int, c int) partition by range(a, b, c) +-- +TABLE: name="rp_prefix_test2" schema="" table="rp_prefix_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test2 (a int, b int, c int) PARTITION BY RANGE (a, b, c)" +== 672 +-- truncate_limit: 100 +create table rp_prefix_test2_p1 partition of rp_prefix_test2 for values from (1, 1, 0) to (1, 1, 10) +-- +TABLE: name="rp_prefix_test2_p1" schema="" table="rp_prefix_test2_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test2_p1 PARTITION OF rp_prefix_test2 FOR VALUES FROM (1, 1, 0) TO (1, 1, 10)" +== 673 +-- truncate_limit: 100 +create table rp_prefix_test2_p2 partition of rp_prefix_test2 for values from (2, 2, 0) to (2, 2, 10) +-- +TABLE: name="rp_prefix_test2_p2" schema="" table="rp_prefix_test2_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test2_p2 PARTITION OF rp_prefix_test2 FOR VALUES FROM (2, 2, 0) TO (2, 2, 10)" +== 674 +-- truncate_limit: 100 +-- Don't call get_steps_using_prefix() with the last partition key c plus +-- an invalid prefix (ie, b = 1) +explain (costs off) select * from rp_prefix_test2 where a <= 1 and b = 1 and c >= 0 +-- +TABLE: name="rp_prefix_test2" schema="" table="rp_prefix_test2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rp_prefix_test2 WHERE a <= 1 AND b = 1 AND c >= 0" +== 675 +-- truncate_limit: 100 +create table rp_prefix_test3 (a int, b int, c int, d int) partition by range(a, b, c, d) +-- +TABLE: name="rp_prefix_test3" schema="" table="rp_prefix_test3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test3 (a int, b int, c int, d int) PARTITION BY RANGE (a, b, c, d)" +== 676 +-- truncate_limit: 100 +create table rp_prefix_test3_p1 partition of rp_prefix_test3 for values from (1, 1, 1, 0) to (1, 1, 1, 10) +-- +TABLE: name="rp_prefix_test3_p1" schema="" table="rp_prefix_test3_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test3_p1 PARTITION OF rp_prefix_test3 FOR VALUES FROM (1, 1, 1, 0) TO (1, ..." +== 677 +-- truncate_limit: 100 +create table rp_prefix_test3_p2 partition of rp_prefix_test3 for values from (2, 2, 2, 0) to (2, 2, 2, 10) +-- +TABLE: name="rp_prefix_test3_p2" schema="" table="rp_prefix_test3_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rp_prefix_test3_p2 PARTITION OF rp_prefix_test3 FOR VALUES FROM (2, 2, 2, 0) TO (2, ..." +== 678 +-- truncate_limit: 100 +-- Test that get_steps_using_prefix() handles a prefix that contains multiple +-- clauses for the partition key b (ie, b >= 1 and b >= 2) +explain (costs off) select * from rp_prefix_test3 where a >= 1 and b >= 1 and b >= 2 and c >= 2 and d >= 0 +-- +TABLE: name="rp_prefix_test3" schema="" table="rp_prefix_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rp_prefix_test3 WHERE a >= 1 AND b >= 1 AND b >= 2 AND c >= 2 A..." +== 679 +-- truncate_limit: 100 +-- Test that get_steps_using_prefix() handles a prefix that contains multiple +-- clauses for the partition key b (ie, b >= 1 and b = 2) (This also tests +-- that the caller arranges clauses in that prefix in the required order) +explain (costs off) select * from rp_prefix_test3 where a >= 1 and b >= 1 and b = 2 and c = 2 and d >= 0 +-- +TABLE: name="rp_prefix_test3" schema="" table="rp_prefix_test3" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="d" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rp_prefix_test3 WHERE a >= 1 AND b >= 1 AND b = 2 AND c = 2 AND..." +== 680 +-- truncate_limit: 100 +drop table rp_prefix_test1 +-- +TABLE: name="rp_prefix_test1" schema="" table="rp_prefix_test1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rp_prefix_test1" +== 681 +-- truncate_limit: 100 +drop table rp_prefix_test2 +-- +TABLE: name="rp_prefix_test2" schema="" table="rp_prefix_test2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rp_prefix_test2" +== 682 +-- truncate_limit: 100 +drop table rp_prefix_test3 +-- +TABLE: name="rp_prefix_test3" schema="" table="rp_prefix_test3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rp_prefix_test3" +== 683 +-- truncate_limit: 100 +|-- +-- Test that get_steps_using_prefix() handles IS NULL clauses correctly +|-- +create table hp_prefix_test (a int, b int, c int, d int) + partition by hash (a part_test_int4_ops, b part_test_int4_ops, c part_test_int4_ops, d part_test_int4_ops) +-- +TABLE: name="hp_prefix_test" schema="" table="hp_prefix_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp_prefix_test (a int, b int, c int, d int) PARTITION BY HASH (a part_test_int4_ops,..." +== 684 +-- truncate_limit: 100 +-- create 8 partitions +select 'create table hp_prefix_test_p' || x::text || ' partition of hp_prefix_test for values with (modulus 8, remainder ' || x::text || ');' +from generate_Series(0,7) x +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(0, 7) x" +== 685 +-- truncate_limit: 100 +-- insert 16 rows, one row for each test to perform. +insert into hp_prefix_test +select + case a when 0 then null else 1 end, + case b when 0 then null else 2 end, + case c when 0 then null else 3 end, + case d when 0 then null else 4 end +from + generate_series(0,1) a, + generate_series(0,1) b, + generate_Series(0,1) c, + generate_Series(0,1) d +-- +TABLE: name="hp_prefix_test" schema="" table="hp_prefix_test" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hp_prefix_test SELECT ... FROM generate_series(0, 1) a, generate_series(0, 1) b, gene..." +== 686 +-- truncate_limit: 100 +-- Ensure partition pruning works correctly for each combination of IS NULL +-- and equality quals. This may seem a little excessive, but there have been +-- a number of bugs in this area over the years. We make use of row only +-- output to reduce the size of the expected results. +select + 'explain (costs off) select tableoid::regclass,* from hp_prefix_test where ' || + string_agg(c.colname || case when g.s & (1 << c.colpos) = 0 then ' is null' else ' = ' || (colpos+1)::text end, ' and ' order by c.colpos) +from (values('a',0),('b',1),('c',2),('d',3)) c(colname, colpos), generate_Series(0,15) g(s) +group by g.s +order by g.s +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) c(colname, colpos), generate_series(0, 15) g(s) GROUP BY g.s ORDER..." +== 687 +-- truncate_limit: 100 +-- And ensure we get exactly 1 row from each. Again, all 16 possible combinations. +select + 'select tableoid::regclass,* from hp_prefix_test where ' || + string_agg(c.colname || case when g.s & (1 << c.colpos) = 0 then ' is null' else ' = ' || (colpos+1)::text end, ' and ' order by c.colpos) +from (values('a',0),('b',1),('c',2),('d',3)) c(colname, colpos), generate_Series(0,15) g(s) +group by g.s +order by g.s +-- +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) c(colname, colpos), generate_series(0, 15) g(s) GROUP BY g.s ORDER..." +== 688 +-- truncate_limit: 100 +drop table hp_prefix_test +-- +TABLE: name="hp_prefix_test" schema="" table="hp_prefix_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hp_prefix_test" +== 689 +-- truncate_limit: 100 +|-- +-- Check that gen_partprune_steps() detects self-contradiction from clauses +-- regardless of the order of the clauses (Here we use a custom operator to +-- prevent the equivclass.c machinery from reordering the clauses) +|-- + +create operator === ( + leftarg = int4, + rightarg = int4, + procedure = int4eq, + commutator = ===, + hashes +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR === (leftarg = int4, rightarg = int4, procedure = int4eq, commutator = ===, hashes)" +== 690 +-- truncate_limit: 100 +create operator class part_test_int4_ops2 +for type int4 +using hash as +operator 1 ===, +function 2 part_hashint4_noop(int4, int8) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS part_test_int4_ops2 FOR TYPE int4 USING hash AS OPERATOR 1 ===, FUNCTION 2 ..." +== 691 +-- truncate_limit: 100 +create table hp_contradict_test (a int, b int) partition by hash (a part_test_int4_ops2, b part_test_int4_ops2) +-- +TABLE: name="hp_contradict_test" schema="" table="hp_contradict_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp_contradict_test (a int, b int) PARTITION BY HASH (a part_test_int4_ops2, b part_t..." +== 692 +-- truncate_limit: 100 +create table hp_contradict_test_p1 partition of hp_contradict_test for values with (modulus 2, remainder 0) +-- +TABLE: name="hp_contradict_test_p1" schema="" table="hp_contradict_test_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp_contradict_test_p1 PARTITION OF hp_contradict_test FOR VALUES WITH (MODULUS 2, RE..." +== 693 +-- truncate_limit: 100 +create table hp_contradict_test_p2 partition of hp_contradict_test for values with (modulus 2, remainder 1) +-- +TABLE: name="hp_contradict_test_p2" schema="" table="hp_contradict_test_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hp_contradict_test_p2 PARTITION OF hp_contradict_test FOR VALUES WITH (MODULUS 2, RE..." +== 694 +-- truncate_limit: 100 +explain (costs off) select * from hp_contradict_test where a is null and a === 1 and b === 1 +-- +TABLE: name="hp_contradict_test" schema="" table="hp_contradict_test" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp_contradict_test WHERE a IS NULL AND a === 1 AND b === 1" +== 695 +-- truncate_limit: 100 +explain (costs off) select * from hp_contradict_test where a === 1 and b === 1 and a is null +-- +TABLE: name="hp_contradict_test" schema="" table="hp_contradict_test" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM hp_contradict_test WHERE a === 1 AND b === 1 AND a IS NULL" +== 696 +-- truncate_limit: 100 +drop table hp_contradict_test +-- +TABLE: name="hp_contradict_test" schema="" table="hp_contradict_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hp_contradict_test" +== 697 +-- truncate_limit: 100 +drop operator class part_test_int4_ops2 using hash +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS part_test_int4_ops2 USING hash" +== 698 +-- truncate_limit: 100 +drop operator ===(int4, int4) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR ===(int4, int4)" diff --git a/parser/testdata/summary_truncate/postgres_regress/password.metadata.json b/parser/testdata/summary_truncate/postgres_regress/password.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/password.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/password.test b/parser/testdata/summary_truncate/postgres_regress/password.test new file mode 100644 index 0000000..7c39fca --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/password.test @@ -0,0 +1,376 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for password types +|-- + +-- Tests for GUC password_encryption +SET password_encryption = 'novalue' +-- +STMT: VariableSetStmt +TRUNCATED: "SET password_encryption TO novalue" +== 002 +-- truncate_limit: 100 +-- error +SET password_encryption = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET password_encryption TO TRUE" +== 003 +-- truncate_limit: 100 +-- error +SET password_encryption = 'md5' +-- +STMT: VariableSetStmt +TRUNCATED: "SET password_encryption TO md5" +== 004 +-- truncate_limit: 100 +-- ok +SET password_encryption = 'scram-sha-256' +-- +STMT: VariableSetStmt +TRUNCATED: "SET password_encryption TO \"scram-sha-256\"" +== 005 +-- truncate_limit: 100 +-- ok + +-- consistency of password entries +SET password_encryption = 'md5' +-- +STMT: VariableSetStmt +TRUNCATED: "SET password_encryption TO md5" +== 006 +-- truncate_limit: 100 +CREATE ROLE regress_passwd1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd1" +== 007 +-- truncate_limit: 100 +ALTER ROLE regress_passwd1 PASSWORD 'role_pwd1' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_passwd1 WITH PASSWORD 'role_pwd1'" +== 008 +-- truncate_limit: 100 +CREATE ROLE regress_passwd2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd2" +== 009 +-- truncate_limit: 100 +ALTER ROLE regress_passwd2 PASSWORD 'role_pwd2' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_passwd2 WITH PASSWORD 'role_pwd2'" +== 010 +-- truncate_limit: 100 +SET password_encryption = 'scram-sha-256' +-- +STMT: VariableSetStmt +TRUNCATED: "SET password_encryption TO \"scram-sha-256\"" +== 011 +-- truncate_limit: 100 +CREATE ROLE regress_passwd3 PASSWORD 'role_pwd3' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd3 WITH PASSWORD 'role_pwd3'" +== 012 +-- truncate_limit: 100 +CREATE ROLE regress_passwd4 PASSWORD NULL +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd4 WITH PASSWORD NULL" +== 013 +-- truncate_limit: 100 +-- check list of created entries +|-- +-- The scram secret will look something like: +-- SCRAM-SHA-256$4096:E4HxLGtnRzsYwg==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo= +|-- +-- Since the salt is random, the exact value stored will be different on every test +-- run. Use a regular expression to mask the changing parts. +SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+/=]+)\$([a-zA-Z0-9+=/]+):([a-zA-Z0-9+/=]+)', '\1$\2:$:') as rolpassword_masked + FROM pg_authid + WHERE rolname LIKE 'regress_passwd%' + ORDER BY rolname, rolpassword +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FUNCTION: name="regexp_replace" function="regexp_replace" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname LIKE 'regress_passwd%' ORDER BY rolname, rolpassword" +== 014 +-- truncate_limit: 100 +-- Rename a role +ALTER ROLE regress_passwd2 RENAME TO regress_passwd2_new +-- +STMT: RenameStmt +TRUNCATED: "ALTER ROLE regress_passwd2 RENAME TO regress_passwd2_new" +== 015 +-- truncate_limit: 100 +-- md5 entry should have been removed +SELECT rolname, rolpassword + FROM pg_authid + WHERE rolname LIKE 'regress_passwd2_new' + ORDER BY rolname, rolpassword +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT rolname, rolpassword FROM pg_authid WHERE ... ORDER BY rolname, rolpassword" +== 016 +-- truncate_limit: 100 +ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER ROLE regress_passwd2_new RENAME TO regress_passwd2" +== 017 +-- truncate_limit: 100 +-- Change passwords with ALTER USER. With plaintext or already-encrypted +-- passwords. +SET password_encryption = 'md5' +-- +STMT: VariableSetStmt +TRUNCATED: "SET password_encryption TO md5" +== 018 +-- truncate_limit: 100 +-- encrypt with MD5 +ALTER ROLE regress_passwd2 PASSWORD 'foo' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_passwd2 WITH PASSWORD 'foo'" +== 019 +-- truncate_limit: 100 +-- already encrypted, use as they are +ALTER ROLE regress_passwd1 PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_passwd1 WITH PASSWORD 'md5cd3578025fe2c3d7ed1b9a9b26238b70'" +== 020 +-- truncate_limit: 100 +ALTER ROLE regress_passwd3 PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbVgVZtuz6gpJQQqUMZ7IQJK5yI=:ps75jrHeYU4lXCcXI4O8oIdJ3eO8o2jirjruw9phBTo=' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_passwd3 WITH PASSWORD 'SCRAM-SHA-256$4096:VLK4RMaQLCvNtQ==$6YtlR4t69SguDiwFvbV..." +== 021 +-- truncate_limit: 100 +SET password_encryption = 'scram-sha-256' +-- +STMT: VariableSetStmt +TRUNCATED: "SET password_encryption TO \"scram-sha-256\"" +== 022 +-- truncate_limit: 100 +-- create SCRAM secret +ALTER ROLE regress_passwd4 PASSWORD 'foo' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_passwd4 WITH PASSWORD 'foo'" +== 023 +-- truncate_limit: 100 +-- already encrypted with MD5, use as it is +CREATE ROLE regress_passwd5 PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd5 WITH PASSWORD 'md5e73a4b11df52a6068f8b39f90be36023'" +== 024 +-- truncate_limit: 100 +-- This looks like a valid SCRAM-SHA-256 secret, but it is not +-- so it should be hashed with SCRAM-SHA-256. +CREATE ROLE regress_passwd6 PASSWORD 'SCRAM-SHA-256$1234' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd6 WITH PASSWORD 'SCRAM-SHA-256$1234'" +== 025 +-- truncate_limit: 100 +-- These may look like valid MD5 secrets, but they are not, so they +-- should be hashed with SCRAM-SHA-256. +-- trailing garbage at the end +CREATE ROLE regress_passwd7 PASSWORD 'md5012345678901234567890123456789zz' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd7 WITH PASSWORD 'md5012345678901234567890123456789zz'" +== 026 +-- truncate_limit: 100 +-- invalid length +CREATE ROLE regress_passwd8 PASSWORD 'md501234567890123456789012345678901zz' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd8 WITH PASSWORD 'md501234567890123456789012345678901zz'" +== 027 +-- truncate_limit: 100 +-- Changing the SCRAM iteration count +SET scram_iterations = 1024 +-- +STMT: VariableSetStmt +TRUNCATED: "SET scram_iterations TO 1024" +== 028 +-- truncate_limit: 100 +CREATE ROLE regress_passwd9 PASSWORD 'alterediterationcount' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd9 WITH PASSWORD 'alterediterationcount'" +== 029 +-- truncate_limit: 100 +SELECT rolname, regexp_replace(rolpassword, '(SCRAM-SHA-256)\$(\d+):([a-zA-Z0-9+/=]+)\$([a-zA-Z0-9+=/]+):([a-zA-Z0-9+/=]+)', '\1$\2:$:') as rolpassword_masked + FROM pg_authid + WHERE rolname LIKE 'regress_passwd%' + ORDER BY rolname, rolpassword +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FUNCTION: name="regexp_replace" function="regexp_replace" schema="" ctx=Call +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname LIKE 'regress_passwd%' ORDER BY rolname, rolpassword" +== 030 +-- truncate_limit: 100 +-- An empty password is not allowed, in any form +CREATE ROLE regress_passwd_empty PASSWORD '' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd_empty WITH PASSWORD ''" +== 031 +-- truncate_limit: 100 +ALTER ROLE regress_passwd_empty PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_passwd_empty WITH PASSWORD 'md585939a5ce845f1a1b620742e3c659e0a'" +== 032 +-- truncate_limit: 100 +ALTER ROLE regress_passwd_empty PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27ZFKbZ2nV+vtnYM995pDh9ca6WSi120=:qVV5NeluNfUPkwm7Vqat25RjSPLkGeoZBQs6wVv+um4=' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_passwd_empty WITH PASSWORD 'SCRAM-SHA-256$4096:hpFyHTUsSWcR7O9P$LgZFIt6Oqdo27Z..." +== 033 +-- truncate_limit: 100 +SELECT rolpassword FROM pg_authid WHERE rolname='regress_passwd_empty' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT rolpassword FROM pg_authid WHERE rolname = 'regress_passwd_empty'" +== 034 +-- truncate_limit: 100 +-- Test with invalid stored and server keys. +|-- +-- The first is valid, to act as a control. The others have too long +-- stored/server keys. They will be re-hashed. +CREATE ROLE regress_passwd_sha_len0 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd_sha_len0 WITH PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky..." +== 035 +-- truncate_limit: 100 +CREATE ROLE regress_passwd_sha_len1 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96RqwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZI=' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd_sha_len1 WITH PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky..." +== 036 +-- truncate_limit: 100 +CREATE ROLE regress_passwd_sha_len2 PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky+A30sewHIH3VHQLRN9vYsuzlgNyGNKCh37dy96Rqw=:COPdlNiIkrsacU5QoxydEuOH6e/KfiipeETb/bPw8ZIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_passwd_sha_len2 WITH PASSWORD 'SCRAM-SHA-256$4096:A6xHKoH/494E941doaPOYg==$Ky..." +== 037 +-- truncate_limit: 100 +-- Check that the invalid secrets were re-hashed. A re-hashed secret +-- should not contain the original salt. +SELECT rolname, rolpassword not like '%A6xHKoH/494E941doaPOYg==%' as is_rolpassword_rehashed + FROM pg_authid + WHERE rolname LIKE 'regress_passwd_sha_len%' + ORDER BY rolname +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname LIKE 'regress_passwd_sha_len%' ORDER BY rolname" +== 038 +-- truncate_limit: 100 +DROP ROLE regress_passwd1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd1" +== 039 +-- truncate_limit: 100 +DROP ROLE regress_passwd2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd2" +== 040 +-- truncate_limit: 100 +DROP ROLE regress_passwd3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd3" +== 041 +-- truncate_limit: 100 +DROP ROLE regress_passwd4 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd4" +== 042 +-- truncate_limit: 100 +DROP ROLE regress_passwd5 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd5" +== 043 +-- truncate_limit: 100 +DROP ROLE regress_passwd6 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd6" +== 044 +-- truncate_limit: 100 +DROP ROLE regress_passwd7 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd7" +== 045 +-- truncate_limit: 100 +DROP ROLE regress_passwd8 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd8" +== 046 +-- truncate_limit: 100 +DROP ROLE regress_passwd9 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd9" +== 047 +-- truncate_limit: 100 +DROP ROLE regress_passwd_empty +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd_empty" +== 048 +-- truncate_limit: 100 +DROP ROLE regress_passwd_sha_len0 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd_sha_len0" +== 049 +-- truncate_limit: 100 +DROP ROLE regress_passwd_sha_len1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd_sha_len1" +== 050 +-- truncate_limit: 100 +DROP ROLE regress_passwd_sha_len2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_passwd_sha_len2" +== 051 +-- truncate_limit: 100 +-- all entries should have been removed +SELECT rolname, rolpassword + FROM pg_authid + WHERE rolname LIKE 'regress_passwd%' + ORDER BY rolname, rolpassword +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT rolname, rolpassword FROM pg_authid WHERE ... ORDER BY rolname, rolpassword" diff --git a/parser/testdata/summary_truncate/postgres_regress/path.metadata.json b/parser/testdata/summary_truncate/postgres_regress/path.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/path.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/path.test b/parser/testdata/summary_truncate/postgres_regress/path.test new file mode 100644 index 0000000..04137c6 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/path.test @@ -0,0 +1,193 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PATH +|-- + +--DROP TABLE PATH_TBL; + +CREATE TABLE PATH_TBL (f1 path) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE path_tbl (f1 path)" +== 002 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('[(1,2),(3,4)]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('[(1,2),(3,4)]')" +== 003 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES (' ( ( 1 , 2 ) , ( 3 , 4 ) ) ') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES (' ( ( 1 , 2 ) , ( 3 , 4 ) ) ')" +== 004 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('[ (0,0),(3,0),(4,5),(1,6) ]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('[ (0,0),(3,0),(4,5),(1,6) ]')" +== 005 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('((1,2) ,(3,4 ))') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('((1,2) ,(3,4 ))')" +== 006 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('1,2 ,3,4 ') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('1,2 ,3,4 ')" +== 007 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES (' [1,2,3, 4] ') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES (' [1,2,3, 4] ')" +== 008 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('((10,20))') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('((10,20))')" +== 009 +-- truncate_limit: 100 +-- Only one point + +INSERT INTO PATH_TBL VALUES ('[ 11,12,13,14 ]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('[ 11,12,13,14 ]')" +== 010 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('( 11,12,13,14) ') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('( 11,12,13,14) ')" +== 011 +-- truncate_limit: 100 +-- bad values for parser testing +INSERT INTO PATH_TBL VALUES ('[]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('[]')" +== 012 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('[(,2),(3,4)]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('[(,2),(3,4)]')" +== 013 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('[(1,2),(3,4)') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('[(1,2),(3,4)')" +== 014 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('(1,2,3,4') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('(1,2,3,4')" +== 015 +-- truncate_limit: 100 +INSERT INTO PATH_TBL VALUES ('(1,2),(3,4)]') +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO path_tbl VALUES ('(1,2),(3,4)]')" +== 016 +-- truncate_limit: 100 +SELECT f1 AS open_path FROM PATH_TBL WHERE isopen(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FUNCTION: name="isopen" function="isopen" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS open_path FROM path_tbl WHERE isopen(f1)" +== 017 +-- truncate_limit: 100 +SELECT f1 AS closed_path FROM PATH_TBL WHERE isclosed(f1) +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FUNCTION: name="isclosed" function="isclosed" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS closed_path FROM path_tbl WHERE isclosed(f1)" +== 018 +-- truncate_limit: 100 +SELECT pclose(f1) AS closed_path FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="pclose" function="pclose" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pclose(f1) AS closed_path FROM path_tbl" +== 019 +-- truncate_limit: 100 +SELECT popen(f1) AS open_path FROM PATH_TBL +-- +TABLE: name="path_tbl" schema="" table="path_tbl" ctx=Select +FUNCTION: name="popen" function="popen" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT popen(f1) AS open_path FROM path_tbl" +== 020 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('[(1,2),(3)]', 'path') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('[(1,2),(3)]', 'path')" +== 021 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'path') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'path')" +== 022 +-- truncate_limit: 100 +SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path')" +== 023 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('[(1,2,6),(3,4,6)]', 'path') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('[(1,2,6),(3,4,6)]', 'path')" diff --git a/parser/testdata/summary_truncate/postgres_regress/pg_lsn.metadata.json b/parser/testdata/summary_truncate/postgres_regress/pg_lsn.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/pg_lsn.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/pg_lsn.test b/parser/testdata/summary_truncate/postgres_regress/pg_lsn.test new file mode 100644 index 0000000..622ef60 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/pg_lsn.test @@ -0,0 +1,243 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PG_LSN +|-- + +CREATE TABLE PG_LSN_TBL (f1 pg_lsn) +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pg_lsn_tbl (f1 pg_lsn)" +== 002 +-- truncate_limit: 100 +-- Largest and smallest input +INSERT INTO PG_LSN_TBL VALUES ('0/0') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pg_lsn_tbl VALUES ('0/0')" +== 003 +-- truncate_limit: 100 +INSERT INTO PG_LSN_TBL VALUES ('FFFFFFFF/FFFFFFFF') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pg_lsn_tbl VALUES ('FFFFFFFF/FFFFFFFF')" +== 004 +-- truncate_limit: 100 +-- Incorrect input +INSERT INTO PG_LSN_TBL VALUES ('G/0') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pg_lsn_tbl VALUES ('G/0')" +== 005 +-- truncate_limit: 100 +INSERT INTO PG_LSN_TBL VALUES ('-1/0') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pg_lsn_tbl VALUES ('-1/0')" +== 006 +-- truncate_limit: 100 +INSERT INTO PG_LSN_TBL VALUES (' 0/12345678') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pg_lsn_tbl VALUES (' 0/12345678')" +== 007 +-- truncate_limit: 100 +INSERT INTO PG_LSN_TBL VALUES ('ABCD/') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pg_lsn_tbl VALUES ('ABCD/')" +== 008 +-- truncate_limit: 100 +INSERT INTO PG_LSN_TBL VALUES ('/ABCD') +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pg_lsn_tbl VALUES ('/ABCD')" +== 009 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('16AE7F7', 'pg_lsn') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('16AE7F7', 'pg_lsn')" +== 010 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn')" +== 011 +-- truncate_limit: 100 +-- Min/Max aggregation +SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(f1), max(f1) FROM pg_lsn_tbl" +== 012 +-- truncate_limit: 100 +DROP TABLE PG_LSN_TBL +-- +TABLE: name="pg_lsn_tbl" schema="" table="pg_lsn_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pg_lsn_tbl" +== 013 +-- truncate_limit: 100 +-- Operators +SELECT '0/16AE7F8' = '0/16AE7F8'::pg_lsn +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F8' = '0/16AE7F8'::pg_lsn" +== 014 +-- truncate_limit: 100 +SELECT '0/16AE7F8'::pg_lsn != '0/16AE7F7' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F8'::pg_lsn <> '0/16AE7F7'" +== 015 +-- truncate_limit: 100 +SELECT '0/16AE7F7' < '0/16AE7F8'::pg_lsn +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F7' < '0/16AE7F8'::pg_lsn" +== 016 +-- truncate_limit: 100 +SELECT '0/16AE7F8' > pg_lsn '0/16AE7F7' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F8' > '0/16AE7F7'::pg_lsn" +== 017 +-- truncate_limit: 100 +SELECT '0/16AE7F7'::pg_lsn - '0/16AE7F8'::pg_lsn +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F7'::pg_lsn - '0/16AE7F8'::pg_lsn" +== 018 +-- truncate_limit: 100 +SELECT '0/16AE7F8'::pg_lsn - '0/16AE7F7'::pg_lsn +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F8'::pg_lsn - '0/16AE7F7'::pg_lsn" +== 019 +-- truncate_limit: 100 +SELECT '0/16AE7F7'::pg_lsn + 16::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F7'::pg_lsn + 16::numeric" +== 020 +-- truncate_limit: 100 +SELECT 16::numeric + '0/16AE7F7'::pg_lsn +-- +STMT: SelectStmt +TRUNCATED: "SELECT 16::numeric + '0/16AE7F7'::pg_lsn" +== 021 +-- truncate_limit: 100 +SELECT '0/16AE7F7'::pg_lsn - 16::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F7'::pg_lsn - 16::numeric" +== 022 +-- truncate_limit: 100 +SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 1::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 1::numeric" +== 023 +-- truncate_limit: 100 +SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 2::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'FFFFFFFF/FFFFFFFE'::pg_lsn + 2::numeric" +== 024 +-- truncate_limit: 100 +-- out of range error +SELECT '0/1'::pg_lsn - 1::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/1'::pg_lsn - 1::numeric" +== 025 +-- truncate_limit: 100 +SELECT '0/1'::pg_lsn - 2::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/1'::pg_lsn - 2::numeric" +== 026 +-- truncate_limit: 100 +-- out of range error +SELECT '0/0'::pg_lsn + ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/0'::pg_lsn + ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn)" +== 027 +-- truncate_limit: 100 +SELECT 'FFFFFFFF/FFFFFFFF'::pg_lsn - ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'FFFFFFFF/FFFFFFFF'::pg_lsn - ('FFFFFFFF/FFFFFFFF'::pg_lsn - '0/0'::pg_lsn)" +== 028 +-- truncate_limit: 100 +SELECT '0/16AE7F7'::pg_lsn + 'NaN'::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F7'::pg_lsn + 'NaN'::numeric" +== 029 +-- truncate_limit: 100 +SELECT '0/16AE7F7'::pg_lsn - 'NaN'::numeric +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0/16AE7F7'::pg_lsn - 'NaN'::numeric" +== 030 +-- truncate_limit: 100 +-- Check btree and hash opclasses +EXPLAIN (COSTS OFF) +SELECT DISTINCT (i || '/' || j)::pg_lsn f + FROM generate_series(1, 10) i, + generate_series(1, 10) j, + generate_series(1, 5) k + WHERE i <= 10 AND j > 0 AND j <= 10 + ORDER BY f +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="j" +FILTER: schema="" table="" column="j" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT ((i || '/') || j)::pg_lsn AS f FROM generate_series(1, 10) i,..." +== 031 +-- truncate_limit: 100 +SELECT DISTINCT (i || '/' || j)::pg_lsn f + FROM generate_series(1, 10) i, + generate_series(1, 10) j, + generate_series(1, 5) k + WHERE i <= 10 AND j > 0 AND j <= 10 + ORDER BY f +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="j" +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ... AS ... FROM generate_series(1, 10) i, generate_series(1, 10) j, generate_seri..." diff --git a/parser/testdata/summary_truncate/postgres_regress/plancache.metadata.json b/parser/testdata/summary_truncate/postgres_regress/plancache.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/plancache.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/plancache.test b/parser/testdata/summary_truncate/postgres_regress/plancache.test new file mode 100644 index 0000000..d778179 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/plancache.test @@ -0,0 +1,753 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests to exercise the plan caching/invalidation mechanism +|-- + +CREATE TEMP TABLE pcachetest AS SELECT * FROM int8_tbl +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE pcachetest AS SELECT * FROM int8_tbl" +== 002 +-- truncate_limit: 100 +-- create and use a cached plan +PREPARE prepstmt AS SELECT * FROM pcachetest +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE prepstmt AS SELECT * FROM pcachetest" +== 003 +-- truncate_limit: 100 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt" +== 004 +-- truncate_limit: 100 +-- and one with parameters +PREPARE prepstmt2(bigint) AS SELECT * FROM pcachetest WHERE q1 = $1 +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE prepstmt2(bigint) AS SELECT * FROM pcachetest WHERE q1 = $1" +== 005 +-- truncate_limit: 100 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt2(123)" +== 006 +-- truncate_limit: 100 +-- invalidate the plans and see what happens +DROP TABLE pcachetest +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pcachetest" +== 007 +-- truncate_limit: 100 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt" +== 008 +-- truncate_limit: 100 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt2(123)" +== 009 +-- truncate_limit: 100 +-- recreate the temp table (this demonstrates that the raw plan is +-- purely textual and doesn't depend on OIDs, for instance) +CREATE TEMP TABLE pcachetest AS SELECT * FROM int8_tbl ORDER BY 2 +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE pcachetest AS SELECT * FROM int8_tbl ORDER BY 2" +== 010 +-- truncate_limit: 100 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt" +== 011 +-- truncate_limit: 100 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt2(123)" +== 012 +-- truncate_limit: 100 +-- prepared statements should prevent change in output tupdesc, +-- since clients probably aren't expecting that to change on the fly +ALTER TABLE pcachetest ADD COLUMN q3 bigint +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pcachetest ADD COLUMN q3 bigint" +== 013 +-- truncate_limit: 100 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt" +== 014 +-- truncate_limit: 100 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt2(123)" +== 015 +-- truncate_limit: 100 +-- but we're nice guys and will let you undo your mistake +ALTER TABLE pcachetest DROP COLUMN q3 +-- +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pcachetest DROP q3" +== 016 +-- truncate_limit: 100 +EXECUTE prepstmt +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt" +== 017 +-- truncate_limit: 100 +EXECUTE prepstmt2(123) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE prepstmt2(123)" +== 018 +-- truncate_limit: 100 +-- Try it with a view, which isn't directly used in the resulting plan +-- but should trigger invalidation anyway +CREATE TEMP VIEW pcacheview AS + SELECT * FROM pcachetest +-- +TABLE: name="pcacheview" schema="" table="pcacheview" ctx=DDL +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW pcacheview AS SELECT * FROM pcachetest" +== 019 +-- truncate_limit: 100 +PREPARE vprep AS SELECT * FROM pcacheview +-- +TABLE: name="pcacheview" schema="" table="pcacheview" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE vprep AS SELECT * FROM pcacheview" +== 020 +-- truncate_limit: 100 +EXECUTE vprep +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE vprep" +== 021 +-- truncate_limit: 100 +CREATE OR REPLACE TEMP VIEW pcacheview AS + SELECT q1, q2/2 AS q2 FROM pcachetest +-- +TABLE: name="pcacheview" schema="" table="pcacheview" ctx=DDL +TABLE: name="pcachetest" schema="" table="pcachetest" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW pcacheview AS SELECT q1, q2 / 2 AS q2 FROM pcachetest" +== 022 +-- truncate_limit: 100 +EXECUTE vprep +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE vprep" +== 023 +-- truncate_limit: 100 +-- Check basic SPI plan invalidation + +create function cache_test(int) returns int as $$ +declare total int; +begin + create temp table t1(f1 int); + insert into t1 values($1); + insert into t1 values(11); + insert into t1 values(12); + insert into t1 values(13); + select sum(f1) into total from t1; + drop table t1; + return total; +end +$$ language plpgsql +-- +FUNCTION: name="cache_test" function="cache_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION cache_test(int) RETURNS int AS $$\ndeclare total int;\nbegin\n\tcreate temp table t1(..." +== 024 +-- truncate_limit: 100 +select cache_test(1) +-- +FUNCTION: name="cache_test" function="cache_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cache_test(1)" +== 025 +-- truncate_limit: 100 +select cache_test(2) +-- +FUNCTION: name="cache_test" function="cache_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cache_test(2)" +== 026 +-- truncate_limit: 100 +select cache_test(3) +-- +FUNCTION: name="cache_test" function="cache_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cache_test(3)" +== 027 +-- truncate_limit: 100 +-- Check invalidation of plpgsql "simple expression" + +create temp view v1 as + select 2+2 as f1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v1 AS SELECT 2 + 2 AS f1" +== 028 +-- truncate_limit: 100 +create function cache_test_2() returns int as $$ +begin + return f1 from v1; +end$$ language plpgsql +-- +FUNCTION: name="cache_test_2" function="cache_test_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION cache_test_2() RETURNS int AS $$\nbegin\n\treturn f1 from v1;\nend$$ LANGUAGE plpgsql" +== 029 +-- truncate_limit: 100 +select cache_test_2() +-- +FUNCTION: name="cache_test_2" function="cache_test_2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cache_test_2()" +== 030 +-- truncate_limit: 100 +create or replace temp view v1 as + select 2+2+4 as f1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW v1 AS SELECT (2 + 2) + 4 AS f1" +== 031 +-- truncate_limit: 100 +select cache_test_2() +-- +FUNCTION: name="cache_test_2" function="cache_test_2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cache_test_2()" +== 032 +-- truncate_limit: 100 +create or replace temp view v1 as + select 2+2+4+(select max(unique1) from tenk1) as f1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW v1 AS SELECT ((2 + 2) + 4) + (SELECT max(unique1) FROM tenk1) AS f1" +== 033 +-- truncate_limit: 100 +select cache_test_2() +-- +FUNCTION: name="cache_test_2" function="cache_test_2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cache_test_2()" +== 034 +-- truncate_limit: 100 +--- Check that change of search_path is honored when re-using cached plan + +create schema s1 + create table abc (f1 int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA s1 CREATE TABLE abc (f1 int)" +== 035 +-- truncate_limit: 100 +create schema s2 + create table abc (f1 int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA s2 CREATE TABLE abc (f1 int)" +== 036 +-- truncate_limit: 100 +insert into s1.abc values(123) +-- +TABLE: name="s1.abc" schema="s1" table="abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO s1.abc VALUES (123)" +== 037 +-- truncate_limit: 100 +insert into s2.abc values(456) +-- +TABLE: name="s2.abc" schema="s2" table="abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO s2.abc VALUES (456)" +== 038 +-- truncate_limit: 100 +set search_path = s1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO s1" +== 039 +-- truncate_limit: 100 +prepare p1 as select f1 from abc +-- +TABLE: name="abc" schema="" table="abc" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE p1 AS SELECT f1 FROM abc" +== 040 +-- truncate_limit: 100 +execute p1 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p1" +== 041 +-- truncate_limit: 100 +set search_path = s2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO s2" +== 042 +-- truncate_limit: 100 +select f1 from abc +-- +TABLE: name="abc" schema="" table="abc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM abc" +== 043 +-- truncate_limit: 100 +execute p1 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p1" +== 044 +-- truncate_limit: 100 +alter table s1.abc add column f2 float8 +-- +TABLE: name="s1.abc" schema="s1" table="abc" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE s1.abc ADD COLUMN f2 float8" +== 045 +-- truncate_limit: 100 +-- force replan + +execute p1 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p1" +== 046 +-- truncate_limit: 100 +drop schema s1 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA s1 CASCADE" +== 047 +-- truncate_limit: 100 +drop schema s2 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA s2 CASCADE" +== 048 +-- truncate_limit: 100 +reset search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 049 +-- truncate_limit: 100 +-- Check that invalidation deals with regclass constants + +create temp sequence seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE seq" +== 050 +-- truncate_limit: 100 +prepare p2 as select nextval('seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE p2 AS SELECT nextval('seq')" +== 051 +-- truncate_limit: 100 +execute p2 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p2" +== 052 +-- truncate_limit: 100 +drop sequence seq +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE seq" +== 053 +-- truncate_limit: 100 +create temp sequence seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE seq" +== 054 +-- truncate_limit: 100 +execute p2 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p2" +== 055 +-- truncate_limit: 100 +-- Check DDL via SPI, immediately followed by SPI plan re-use +-- (bug in original coding) + +create function cachebug() returns void as $$ +declare r int; +begin + drop table if exists temptable cascade; + create temp table temptable as select * from generate_series(1,3) as f1; + create temp view vv as select * from temptable; + for r in select * from vv loop + raise notice '%', r; + end loop; +end$$ language plpgsql +-- +FUNCTION: name="cachebug" function="cachebug" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION cachebug() RETURNS void AS $$\ndeclare r int;\nbegin\n drop table if exists temptab..." +== 056 +-- truncate_limit: 100 +select cachebug() +-- +FUNCTION: name="cachebug" function="cachebug" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cachebug()" +== 057 +-- truncate_limit: 100 +select cachebug() +-- +FUNCTION: name="cachebug" function="cachebug" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cachebug()" +== 058 +-- truncate_limit: 100 +-- Check that addition or removal of any partition is correctly dealt with by +-- default partition table when it is being used in prepared statement. +create table pc_list_parted (a int) partition by list(a) +-- +TABLE: name="pc_list_parted" schema="" table="pc_list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pc_list_parted (a int) PARTITION BY LIST (a)" +== 059 +-- truncate_limit: 100 +create table pc_list_part_null partition of pc_list_parted for values in (null) +-- +TABLE: name="pc_list_part_null" schema="" table="pc_list_part_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pc_list_part_null PARTITION OF pc_list_parted FOR VALUES IN (NULL)" +== 060 +-- truncate_limit: 100 +create table pc_list_part_1 partition of pc_list_parted for values in (1) +-- +TABLE: name="pc_list_part_1" schema="" table="pc_list_part_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pc_list_part_1 PARTITION OF pc_list_parted FOR VALUES IN (1)" +== 061 +-- truncate_limit: 100 +create table pc_list_part_def partition of pc_list_parted default +-- +TABLE: name="pc_list_part_def" schema="" table="pc_list_part_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pc_list_part_def PARTITION OF pc_list_parted DEFAULT" +== 062 +-- truncate_limit: 100 +prepare pstmt_def_insert (int) as insert into pc_list_part_def values($1) +-- +TABLE: name="pc_list_part_def" schema="" table="pc_list_part_def" ctx=DML +STMT: PrepareStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "PREPARE pstmt_def_insert(int) AS INSERT INTO pc_list_part_def VALUES ($1)" +== 063 +-- truncate_limit: 100 +-- should fail +execute pstmt_def_insert(null) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE pstmt_def_insert(NULL)" +== 064 +-- truncate_limit: 100 +execute pstmt_def_insert(1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE pstmt_def_insert(1)" +== 065 +-- truncate_limit: 100 +create table pc_list_part_2 partition of pc_list_parted for values in (2) +-- +TABLE: name="pc_list_part_2" schema="" table="pc_list_part_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pc_list_part_2 PARTITION OF pc_list_parted FOR VALUES IN (2)" +== 066 +-- truncate_limit: 100 +execute pstmt_def_insert(2) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE pstmt_def_insert(2)" +== 067 +-- truncate_limit: 100 +alter table pc_list_parted detach partition pc_list_part_null +-- +TABLE: name="pc_list_parted" schema="" table="pc_list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pc_list_parted DETACH PARTITION pc_list_part_null" +== 068 +-- truncate_limit: 100 +-- should be ok +execute pstmt_def_insert(null) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE pstmt_def_insert(NULL)" +== 069 +-- truncate_limit: 100 +drop table pc_list_part_1 +-- +TABLE: name="pc_list_part_1" schema="" table="pc_list_part_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pc_list_part_1" +== 070 +-- truncate_limit: 100 +-- should be ok +execute pstmt_def_insert(1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE pstmt_def_insert(1)" +== 071 +-- truncate_limit: 100 +drop table pc_list_parted, pc_list_part_null +-- +TABLE: name="pc_list_parted" schema="" table="pc_list_parted" ctx=DDL +TABLE: name="pc_list_part_null" schema="" table="pc_list_part_null" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pc_list_parted, pc_list_part_null" +== 072 +-- truncate_limit: 100 +deallocate pstmt_def_insert +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE pstmt_def_insert" +== 073 +-- truncate_limit: 100 +-- Test plan_cache_mode + +create table test_mode (a int) +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_mode (a int)" +== 074 +-- truncate_limit: 100 +insert into test_mode select 1 from generate_series(1,1000) union all select 2 +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_mode SELECT 1 FROM generate_series(1, 1000) UNION ALL SELECT 2" +== 075 +-- truncate_limit: 100 +create index on test_mode (a) +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_mode USING btree (a)" +== 076 +-- truncate_limit: 100 +analyze test_mode +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE test_mode" +== 077 +-- truncate_limit: 100 +prepare test_mode_pp (int) as select count(*) from test_mode where a = $1 +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE test_mode_pp(int) AS SELECT count(*) FROM test_mode WHERE a = $1" +== 078 +-- truncate_limit: 100 +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT name, generic_plans, custom_plans FROM pg_prepared_statements WHERE name = 'test_mode_pp'" +== 079 +-- truncate_limit: 100 +-- up to 5 executions, custom plan is used +set plan_cache_mode to auto +-- +STMT: VariableSetStmt +TRUNCATED: "SET plan_cache_mode TO auto" +== 080 +-- truncate_limit: 100 +explain (costs off) execute test_mode_pp(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE test_mode_pp(2)" +== 081 +-- truncate_limit: 100 +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT name, generic_plans, custom_plans FROM pg_prepared_statements WHERE name = 'test_mode_pp'" +== 082 +-- truncate_limit: 100 +-- force generic plan +set plan_cache_mode to force_generic_plan +-- +STMT: VariableSetStmt +TRUNCATED: "SET plan_cache_mode TO force_generic_plan" +== 083 +-- truncate_limit: 100 +explain (costs off) execute test_mode_pp(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE test_mode_pp(2)" +== 084 +-- truncate_limit: 100 +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT name, generic_plans, custom_plans FROM pg_prepared_statements WHERE name = 'test_mode_pp'" +== 085 +-- truncate_limit: 100 +-- get to generic plan by 5 executions +set plan_cache_mode to auto +-- +STMT: VariableSetStmt +TRUNCATED: "SET plan_cache_mode TO auto" +== 086 +-- truncate_limit: 100 +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE test_mode_pp(1)" +== 087 +-- truncate_limit: 100 +-- 1x +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE test_mode_pp(1)" +== 088 +-- truncate_limit: 100 +-- 2x +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE test_mode_pp(1)" +== 089 +-- truncate_limit: 100 +-- 3x +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE test_mode_pp(1)" +== 090 +-- truncate_limit: 100 +-- 4x +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT name, generic_plans, custom_plans FROM pg_prepared_statements WHERE name = 'test_mode_pp'" +== 091 +-- truncate_limit: 100 +execute test_mode_pp(1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE test_mode_pp(1)" +== 092 +-- truncate_limit: 100 +-- 5x +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT name, generic_plans, custom_plans FROM pg_prepared_statements WHERE name = 'test_mode_pp'" +== 093 +-- truncate_limit: 100 +-- we should now get a really bad plan +explain (costs off) execute test_mode_pp(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE test_mode_pp(2)" +== 094 +-- truncate_limit: 100 +-- but we can force a custom plan +set plan_cache_mode to force_custom_plan +-- +STMT: VariableSetStmt +TRUNCATED: "SET plan_cache_mode TO force_custom_plan" +== 095 +-- truncate_limit: 100 +explain (costs off) execute test_mode_pp(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE test_mode_pp(2)" +== 096 +-- truncate_limit: 100 +select name, generic_plans, custom_plans from pg_prepared_statements + where name = 'test_mode_pp' +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT name, generic_plans, custom_plans FROM pg_prepared_statements WHERE name = 'test_mode_pp'" +== 097 +-- truncate_limit: 100 +drop table test_mode +-- +TABLE: name="test_mode" schema="" table="test_mode" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_mode" diff --git a/parser/testdata/summary_truncate/postgres_regress/plpgsql.metadata.json b/parser/testdata/summary_truncate/postgres_regress/plpgsql.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/plpgsql.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/plpgsql.test b/parser/testdata/summary_truncate/postgres_regress/plpgsql.test new file mode 100644 index 0000000..b3f6193 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/plpgsql.test @@ -0,0 +1,9894 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PLPGSQL +|-- +-- Scenario: +|-- +-- A building with a modern TP cable installation where any +-- of the wall connectors can be used to plug in phones, +-- ethernet interfaces or local office hubs. The backside +-- of the wall connectors is wired to one of several patch- +-- fields in the building. +|-- +-- In the patchfields, there are hubs and all the slots +-- representing the wall connectors. In addition there are +-- slots that can represent a phone line from the central +-- phone system. +|-- +-- Triggers ensure consistency of the patching information. +|-- +-- Functions are used to build up powerful views that let +-- you look behind the wall when looking at a patchfield +-- or into a room. +|-- + + +create table Room ( + roomno char(8), + comment text +) +-- +TABLE: name="room" schema="" table="room" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE room (roomno char(8), comment text)" +== 002 +-- truncate_limit: 100 +create unique index Room_rno on Room using btree (roomno bpchar_ops) +-- +TABLE: name="room" schema="" table="room" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX room_rno ON room USING btree (roomno bpchar_ops)" +== 003 +-- truncate_limit: 100 +create table WSlot ( + slotname char(20), + roomno char(8), + slotlink char(20), + backlink char(20) +) +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE wslot (slotname char(20), roomno char(8), slotlink char(20), backlink char(20))" +== 004 +-- truncate_limit: 100 +create unique index WSlot_name on WSlot using btree (slotname bpchar_ops) +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX wslot_name ON wslot USING btree (slotname bpchar_ops)" +== 005 +-- truncate_limit: 100 +create table PField ( + name text, + comment text +) +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pfield (name text, comment text)" +== 006 +-- truncate_limit: 100 +create unique index PField_name on PField using btree (name text_ops) +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX pfield_name ON pfield USING btree (name text_ops)" +== 007 +-- truncate_limit: 100 +create table PSlot ( + slotname char(20), + pfname text, + slotlink char(20), + backlink char(20) +) +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pslot (slotname char(20), pfname text, slotlink char(20), backlink char(20))" +== 008 +-- truncate_limit: 100 +create unique index PSlot_name on PSlot using btree (slotname bpchar_ops) +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX pslot_name ON pslot USING btree (slotname bpchar_ops)" +== 009 +-- truncate_limit: 100 +create table PLine ( + slotname char(20), + phonenumber char(20), + comment text, + backlink char(20) +) +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pline (slotname char(20), phonenumber char(20), comment text, backlink char(20))" +== 010 +-- truncate_limit: 100 +create unique index PLine_name on PLine using btree (slotname bpchar_ops) +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX pline_name ON pline USING btree (slotname bpchar_ops)" +== 011 +-- truncate_limit: 100 +create table Hub ( + name char(14), + comment text, + nslots integer +) +-- +TABLE: name="hub" schema="" table="hub" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hub (name char(14), comment text, nslots int)" +== 012 +-- truncate_limit: 100 +create unique index Hub_name on Hub using btree (name bpchar_ops) +-- +TABLE: name="hub" schema="" table="hub" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX hub_name ON hub USING btree (name bpchar_ops)" +== 013 +-- truncate_limit: 100 +create table HSlot ( + slotname char(20), + hubname char(14), + slotno integer, + slotlink char(20) +) +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hslot (slotname char(20), hubname char(14), slotno int, slotlink char(20))" +== 014 +-- truncate_limit: 100 +create unique index HSlot_name on HSlot using btree (slotname bpchar_ops) +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX hslot_name ON hslot USING btree (slotname bpchar_ops)" +== 015 +-- truncate_limit: 100 +create index HSlot_hubname on HSlot using btree (hubname bpchar_ops) +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hslot_hubname ON hslot USING btree (hubname bpchar_ops)" +== 016 +-- truncate_limit: 100 +create table System ( + name text, + comment text +) +-- +TABLE: name="system" schema="" table="system" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE system (name text, comment text)" +== 017 +-- truncate_limit: 100 +create unique index System_name on System using btree (name text_ops) +-- +TABLE: name="system" schema="" table="system" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX system_name ON system USING btree (name text_ops)" +== 018 +-- truncate_limit: 100 +create table IFace ( + slotname char(20), + sysname text, + ifname text, + slotlink char(20) +) +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iface (slotname char(20), sysname text, ifname text, slotlink char(20))" +== 019 +-- truncate_limit: 100 +create unique index IFace_name on IFace using btree (slotname bpchar_ops) +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX iface_name ON iface USING btree (slotname bpchar_ops)" +== 020 +-- truncate_limit: 100 +create table PHone ( + slotname char(20), + comment text, + slotlink char(20) +) +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE phone (slotname char(20), comment text, slotlink char(20))" +== 021 +-- truncate_limit: 100 +create unique index PHone_name on PHone using btree (slotname bpchar_ops) +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX phone_name ON phone USING btree (slotname bpchar_ops)" +== 022 +-- truncate_limit: 100 +-- ************************************************************ +-- * +-- * Trigger procedures and functions for the patchfield +-- * test of PL/pgSQL +-- * +-- ************************************************************ + + +-- ************************************************************ +-- * AFTER UPDATE on Room +-- * - If room no changes let wall slots follow +-- ************************************************************ +create function tg_room_au() returns trigger as ' +begin + if new.roomno != old.roomno then + update WSlot set roomno = new.roomno where roomno = old.roomno; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_room_au" function="tg_room_au" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_room_au() RETURNS trigger AS $$\nbegin\n if new.roomno != old.roomno then\n ..." +== 023 +-- truncate_limit: 100 +create trigger tg_room_au after update + on Room for each row execute procedure tg_room_au() +-- +TABLE: name="room" schema="" table="room" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_room_au AFTER UPDATE ON room FOR EACH ROW EXECUTE FUNCTION tg_room_au()" +== 024 +-- truncate_limit: 100 +-- ************************************************************ +-- * AFTER DELETE on Room +-- * - delete wall slots in this room +-- ************************************************************ +create function tg_room_ad() returns trigger as ' +begin + delete from WSlot where roomno = old.roomno; + return old; +end; +' language plpgsql +-- +FUNCTION: name="tg_room_ad" function="tg_room_ad" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_room_ad() RETURNS trigger AS $$\nbegin\n delete from WSlot where roomno = old..." +== 025 +-- truncate_limit: 100 +create trigger tg_room_ad after delete + on Room for each row execute procedure tg_room_ad() +-- +TABLE: name="room" schema="" table="room" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_room_ad AFTER DELETE ON room FOR EACH ROW EXECUTE FUNCTION tg_room_ad()" +== 026 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on WSlot +-- * - Check that room exists +-- ************************************************************ +create function tg_wslot_biu() returns trigger as $$ +begin + if count(*) = 0 from Room where roomno = new.roomno then + raise exception 'Room % does not exist', new.roomno; + end if; + return new; +end; +$$ language plpgsql +-- +FUNCTION: name="tg_wslot_biu" function="tg_wslot_biu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_wslot_biu() RETURNS trigger AS $$\nbegin\n if count(*) = 0 from Room where ro..." +== 027 +-- truncate_limit: 100 +create trigger tg_wslot_biu before insert or update + on WSlot for each row execute procedure tg_wslot_biu() +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_wslot_biu BEFORE INSERT OR UPDATE ON wslot FOR EACH ROW EXECUTE FUNCTION tg_wsl..." +== 028 +-- truncate_limit: 100 +-- ************************************************************ +-- * AFTER UPDATE on PField +-- * - Let PSlots of this field follow +-- ************************************************************ +create function tg_pfield_au() returns trigger as ' +begin + if new.name != old.name then + update PSlot set pfname = new.name where pfname = old.name; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_pfield_au" function="tg_pfield_au" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_pfield_au() RETURNS trigger AS $$\nbegin\n if new.name != old.name then\n ..." +== 029 +-- truncate_limit: 100 +create trigger tg_pfield_au after update + on PField for each row execute procedure tg_pfield_au() +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_pfield_au AFTER UPDATE ON pfield FOR EACH ROW EXECUTE FUNCTION tg_pfield_au()" +== 030 +-- truncate_limit: 100 +-- ************************************************************ +-- * AFTER DELETE on PField +-- * - Remove all slots of this patchfield +-- ************************************************************ +create function tg_pfield_ad() returns trigger as ' +begin + delete from PSlot where pfname = old.name; + return old; +end; +' language plpgsql +-- +FUNCTION: name="tg_pfield_ad" function="tg_pfield_ad" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_pfield_ad() RETURNS trigger AS $$\nbegin\n delete from PSlot where pfname = o..." +== 031 +-- truncate_limit: 100 +create trigger tg_pfield_ad after delete + on PField for each row execute procedure tg_pfield_ad() +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_pfield_ad AFTER DELETE ON pfield FOR EACH ROW EXECUTE FUNCTION tg_pfield_ad()" +== 032 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on PSlot +-- * - Ensure that our patchfield does exist +-- ************************************************************ +create function tg_pslot_biu() returns trigger as $proc$ +declare + pfrec record; + ps alias for new; +begin + select into pfrec * from PField where name = ps.pfname; + if not found then + raise exception $$Patchfield "%" does not exist$$, ps.pfname; + end if; + return ps; +end; +$proc$ language plpgsql +-- +FUNCTION: name="tg_pslot_biu" function="tg_pslot_biu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_pslot_biu() RETURNS trigger AS '\ndeclare\n pfrec\trecord;\n ps ali..." +== 033 +-- truncate_limit: 100 +create trigger tg_pslot_biu before insert or update + on PSlot for each row execute procedure tg_pslot_biu() +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_pslot_biu BEFORE INSERT OR UPDATE ON pslot FOR EACH ROW EXECUTE FUNCTION tg_psl..." +== 034 +-- truncate_limit: 100 +-- ************************************************************ +-- * AFTER UPDATE on System +-- * - If system name changes let interfaces follow +-- ************************************************************ +create function tg_system_au() returns trigger as ' +begin + if new.name != old.name then + update IFace set sysname = new.name where sysname = old.name; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_system_au" function="tg_system_au" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_system_au() RETURNS trigger AS $$\nbegin\n if new.name != old.name then\n ..." +== 035 +-- truncate_limit: 100 +create trigger tg_system_au after update + on System for each row execute procedure tg_system_au() +-- +TABLE: name="system" schema="" table="system" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_system_au AFTER UPDATE ON system FOR EACH ROW EXECUTE FUNCTION tg_system_au()" +== 036 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on IFace +-- * - set the slotname to IF.sysname.ifname +-- ************************************************************ +create function tg_iface_biu() returns trigger as $$ +declare + sname text; + sysrec record; +begin + select into sysrec * from system where name = new.sysname; + if not found then + raise exception $q$system "%" does not exist$q$, new.sysname; + end if; + sname := 'IF.' || new.sysname; + sname := sname || '.'; + sname := sname || new.ifname; + if length(sname) > 20 then + raise exception 'IFace slotname "%" too long (20 char max)', sname; + end if; + new.slotname := sname; + return new; +end; +$$ language plpgsql +-- +FUNCTION: name="tg_iface_biu" function="tg_iface_biu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_iface_biu() RETURNS trigger AS $$\ndeclare\n sname\ttext;\n sysrec\trecord;\nb..." +== 037 +-- truncate_limit: 100 +create trigger tg_iface_biu before insert or update + on IFace for each row execute procedure tg_iface_biu() +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_iface_biu BEFORE INSERT OR UPDATE ON iface FOR EACH ROW EXECUTE FUNCTION tg_ifa..." +== 038 +-- truncate_limit: 100 +-- ************************************************************ +-- * AFTER INSERT or UPDATE or DELETE on Hub +-- * - insert/delete/rename slots as required +-- ************************************************************ +create function tg_hub_a() returns trigger as ' +declare + hname text; + dummy integer; +begin + if tg_op = ''INSERT'' then + dummy := tg_hub_adjustslots(new.name, 0, new.nslots); + return new; + end if; + if tg_op = ''UPDATE'' then + if new.name != old.name then + update HSlot set hubname = new.name where hubname = old.name; + end if; + dummy := tg_hub_adjustslots(new.name, old.nslots, new.nslots); + return new; + end if; + if tg_op = ''DELETE'' then + dummy := tg_hub_adjustslots(old.name, old.nslots, 0); + return old; + end if; +end; +' language plpgsql +-- +FUNCTION: name="tg_hub_a" function="tg_hub_a" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_hub_a() RETURNS trigger AS $$\ndeclare\n hname\ttext;\n dummy\tinteger;\nbegin..." +== 039 +-- truncate_limit: 100 +create trigger tg_hub_a after insert or update or delete + on Hub for each row execute procedure tg_hub_a() +-- +TABLE: name="hub" schema="" table="hub" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_hub_a AFTER INSERT OR DELETE OR UPDATE ON hub FOR EACH ROW EXECUTE FUNCTION tg_..." +== 040 +-- truncate_limit: 100 +-- ************************************************************ +-- * Support function to add/remove slots of Hub +-- ************************************************************ +create function tg_hub_adjustslots(hname bpchar, + oldnslots integer, + newnslots integer) +returns integer as ' +begin + if newnslots = oldnslots then + return 0; + end if; + if newnslots < oldnslots then + delete from HSlot where hubname = hname and slotno > newnslots; + return 0; + end if; + for i in oldnslots + 1 .. newnslots loop + insert into HSlot (slotname, hubname, slotno, slotlink) + values (''HS.dummy'', hname, i, ''''); + end loop; + return 0; +end +' language plpgsql +-- +FUNCTION: name="tg_hub_adjustslots" function="tg_hub_adjustslots" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_hub_adjustslots(hname bpchar, oldnslots int, newnslots int) RETURNS int AS $$\n..." +== 041 +-- truncate_limit: 100 +-- Test comments +COMMENT ON FUNCTION tg_hub_adjustslots_wrong(bpchar, integer, integer) IS 'function with args' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON FUNCTION tg_hub_adjustslots_wrong(bpchar, int, int) IS 'function with args'" +== 042 +-- truncate_limit: 100 +COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, integer, integer) IS 'function with args' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, int, int) IS 'function with args'" +== 043 +-- truncate_limit: 100 +COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, integer, integer) IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, int, int) IS NULL" +== 044 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on HSlot +-- * - prevent from manual manipulation +-- * - set the slotname to HS.hubname.slotno +-- ************************************************************ +create function tg_hslot_biu() returns trigger as ' +declare + sname text; + xname HSlot.slotname%TYPE; + hubrec record; +begin + select into hubrec * from Hub where name = new.hubname; + if not found then + raise exception ''no manual manipulation of HSlot''; + end if; + if new.slotno < 1 or new.slotno > hubrec.nslots then + raise exception ''no manual manipulation of HSlot''; + end if; + if tg_op = ''UPDATE'' and new.hubname != old.hubname then + if count(*) > 0 from Hub where name = old.hubname then + raise exception ''no manual manipulation of HSlot''; + end if; + end if; + sname := ''HS.'' || trim(new.hubname); + sname := sname || ''.''; + sname := sname || new.slotno::text; + if length(sname) > 20 then + raise exception ''HSlot slotname "%" too long (20 char max)'', sname; + end if; + new.slotname := sname; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_hslot_biu" function="tg_hslot_biu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_hslot_biu() RETURNS trigger AS $$\ndeclare\n sname\ttext;\n xname\tHSlot.slot..." +== 045 +-- truncate_limit: 100 +create trigger tg_hslot_biu before insert or update + on HSlot for each row execute procedure tg_hslot_biu() +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_hslot_biu BEFORE INSERT OR UPDATE ON hslot FOR EACH ROW EXECUTE FUNCTION tg_hsl..." +== 046 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE DELETE on HSlot +-- * - prevent from manual manipulation +-- ************************************************************ +create function tg_hslot_bd() returns trigger as ' +declare + hubrec record; +begin + select into hubrec * from Hub where name = old.hubname; + if not found then + return old; + end if; + if old.slotno > hubrec.nslots then + return old; + end if; + raise exception ''no manual manipulation of HSlot''; +end; +' language plpgsql +-- +FUNCTION: name="tg_hslot_bd" function="tg_hslot_bd" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_hslot_bd() RETURNS trigger AS $$\ndeclare\n hubrec\trecord;\nbegin\n select i..." +== 047 +-- truncate_limit: 100 +create trigger tg_hslot_bd before delete + on HSlot for each row execute procedure tg_hslot_bd() +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_hslot_bd BEFORE DELETE ON hslot FOR EACH ROW EXECUTE FUNCTION tg_hslot_bd()" +== 048 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE INSERT on all slots +-- * - Check name prefix +-- ************************************************************ +create function tg_chkslotname() returns trigger as ' +begin + if substr(new.slotname, 1, 2) != tg_argv[0] then + raise exception ''slotname must begin with %'', tg_argv[0]; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_chkslotname" function="tg_chkslotname" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_chkslotname() RETURNS trigger AS $$\nbegin\n if substr(new.slotname, 1, 2) !=..." +== 049 +-- truncate_limit: 100 +create trigger tg_chkslotname before insert + on PSlot for each row execute procedure tg_chkslotname('PS') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotname BEFORE INSERT ON pslot FOR EACH ROW EXECUTE FUNCTION tg_chkslotname..." +== 050 +-- truncate_limit: 100 +create trigger tg_chkslotname before insert + on WSlot for each row execute procedure tg_chkslotname('WS') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotname BEFORE INSERT ON wslot FOR EACH ROW EXECUTE FUNCTION tg_chkslotname..." +== 051 +-- truncate_limit: 100 +create trigger tg_chkslotname before insert + on PLine for each row execute procedure tg_chkslotname('PL') +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotname BEFORE INSERT ON pline FOR EACH ROW EXECUTE FUNCTION tg_chkslotname..." +== 052 +-- truncate_limit: 100 +create trigger tg_chkslotname before insert + on IFace for each row execute procedure tg_chkslotname('IF') +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotname BEFORE INSERT ON iface FOR EACH ROW EXECUTE FUNCTION tg_chkslotname..." +== 053 +-- truncate_limit: 100 +create trigger tg_chkslotname before insert + on PHone for each row execute procedure tg_chkslotname('PH') +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotname BEFORE INSERT ON phone FOR EACH ROW EXECUTE FUNCTION tg_chkslotname..." +== 054 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on all slots with slotlink +-- * - Set slotlink to empty string if NULL value given +-- ************************************************************ +create function tg_chkslotlink() returns trigger as ' +begin + if new.slotlink isnull then + new.slotlink := ''''; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_chkslotlink" function="tg_chkslotlink" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_chkslotlink() RETURNS trigger AS $$\nbegin\n if new.slotlink isnull then\n ..." +== 055 +-- truncate_limit: 100 +create trigger tg_chkslotlink before insert or update + on PSlot for each row execute procedure tg_chkslotlink() +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotlink BEFORE INSERT OR UPDATE ON pslot FOR EACH ROW EXECUTE FUNCTION tg_c..." +== 056 +-- truncate_limit: 100 +create trigger tg_chkslotlink before insert or update + on WSlot for each row execute procedure tg_chkslotlink() +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotlink BEFORE INSERT OR UPDATE ON wslot FOR EACH ROW EXECUTE FUNCTION tg_c..." +== 057 +-- truncate_limit: 100 +create trigger tg_chkslotlink before insert or update + on IFace for each row execute procedure tg_chkslotlink() +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotlink BEFORE INSERT OR UPDATE ON iface FOR EACH ROW EXECUTE FUNCTION tg_c..." +== 058 +-- truncate_limit: 100 +create trigger tg_chkslotlink before insert or update + on HSlot for each row execute procedure tg_chkslotlink() +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotlink BEFORE INSERT OR UPDATE ON hslot FOR EACH ROW EXECUTE FUNCTION tg_c..." +== 059 +-- truncate_limit: 100 +create trigger tg_chkslotlink before insert or update + on PHone for each row execute procedure tg_chkslotlink() +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkslotlink BEFORE INSERT OR UPDATE ON phone FOR EACH ROW EXECUTE FUNCTION tg_c..." +== 060 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE INSERT or UPDATE on all slots with backlink +-- * - Set backlink to empty string if NULL value given +-- ************************************************************ +create function tg_chkbacklink() returns trigger as ' +begin + if new.backlink isnull then + new.backlink := ''''; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_chkbacklink" function="tg_chkbacklink" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_chkbacklink() RETURNS trigger AS $$\nbegin\n if new.backlink isnull then\n ..." +== 061 +-- truncate_limit: 100 +create trigger tg_chkbacklink before insert or update + on PSlot for each row execute procedure tg_chkbacklink() +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkbacklink BEFORE INSERT OR UPDATE ON pslot FOR EACH ROW EXECUTE FUNCTION tg_c..." +== 062 +-- truncate_limit: 100 +create trigger tg_chkbacklink before insert or update + on WSlot for each row execute procedure tg_chkbacklink() +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkbacklink BEFORE INSERT OR UPDATE ON wslot FOR EACH ROW EXECUTE FUNCTION tg_c..." +== 063 +-- truncate_limit: 100 +create trigger tg_chkbacklink before insert or update + on PLine for each row execute procedure tg_chkbacklink() +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_chkbacklink BEFORE INSERT OR UPDATE ON pline FOR EACH ROW EXECUTE FUNCTION tg_c..." +== 064 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE UPDATE on PSlot +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_pslot_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from PSlot where slotname = old.slotname; + insert into PSlot ( + slotname, + pfname, + slotlink, + backlink + ) values ( + new.slotname, + new.pfname, + new.slotlink, + new.backlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_pslot_bu" function="tg_pslot_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_pslot_bu() RETURNS trigger AS $$\nbegin\n if new.slotname != old.slotname the..." +== 065 +-- truncate_limit: 100 +create trigger tg_pslot_bu before update + on PSlot for each row execute procedure tg_pslot_bu() +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_pslot_bu BEFORE UPDATE ON pslot FOR EACH ROW EXECUTE FUNCTION tg_pslot_bu()" +== 066 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE UPDATE on WSlot +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_wslot_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from WSlot where slotname = old.slotname; + insert into WSlot ( + slotname, + roomno, + slotlink, + backlink + ) values ( + new.slotname, + new.roomno, + new.slotlink, + new.backlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_wslot_bu" function="tg_wslot_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_wslot_bu() RETURNS trigger AS $$\nbegin\n if new.slotname != old.slotname the..." +== 067 +-- truncate_limit: 100 +create trigger tg_wslot_bu before update + on WSlot for each row execute procedure tg_Wslot_bu() +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_wslot_bu BEFORE UPDATE ON wslot FOR EACH ROW EXECUTE FUNCTION tg_wslot_bu()" +== 068 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE UPDATE on PLine +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_pline_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from PLine where slotname = old.slotname; + insert into PLine ( + slotname, + phonenumber, + comment, + backlink + ) values ( + new.slotname, + new.phonenumber, + new.comment, + new.backlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_pline_bu" function="tg_pline_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_pline_bu() RETURNS trigger AS $$\nbegin\n if new.slotname != old.slotname the..." +== 069 +-- truncate_limit: 100 +create trigger tg_pline_bu before update + on PLine for each row execute procedure tg_pline_bu() +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_pline_bu BEFORE UPDATE ON pline FOR EACH ROW EXECUTE FUNCTION tg_pline_bu()" +== 070 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE UPDATE on IFace +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_iface_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from IFace where slotname = old.slotname; + insert into IFace ( + slotname, + sysname, + ifname, + slotlink + ) values ( + new.slotname, + new.sysname, + new.ifname, + new.slotlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_iface_bu" function="tg_iface_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_iface_bu() RETURNS trigger AS $$\nbegin\n if new.slotname != old.slotname the..." +== 071 +-- truncate_limit: 100 +create trigger tg_iface_bu before update + on IFace for each row execute procedure tg_iface_bu() +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_iface_bu BEFORE UPDATE ON iface FOR EACH ROW EXECUTE FUNCTION tg_iface_bu()" +== 072 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE UPDATE on HSlot +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_hslot_bu() returns trigger as ' +begin + if new.slotname != old.slotname or new.hubname != old.hubname then + delete from HSlot where slotname = old.slotname; + insert into HSlot ( + slotname, + hubname, + slotno, + slotlink + ) values ( + new.slotname, + new.hubname, + new.slotno, + new.slotlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_hslot_bu" function="tg_hslot_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_hslot_bu() RETURNS trigger AS $$\nbegin\n if new.slotname != old.slotname or ..." +== 073 +-- truncate_limit: 100 +create trigger tg_hslot_bu before update + on HSlot for each row execute procedure tg_hslot_bu() +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_hslot_bu BEFORE UPDATE ON hslot FOR EACH ROW EXECUTE FUNCTION tg_hslot_bu()" +== 074 +-- truncate_limit: 100 +-- ************************************************************ +-- * BEFORE UPDATE on PHone +-- * - do delete/insert instead of update if name changes +-- ************************************************************ +create function tg_phone_bu() returns trigger as ' +begin + if new.slotname != old.slotname then + delete from PHone where slotname = old.slotname; + insert into PHone ( + slotname, + comment, + slotlink + ) values ( + new.slotname, + new.comment, + new.slotlink + ); + return null; + end if; + return new; +end; +' language plpgsql +-- +FUNCTION: name="tg_phone_bu" function="tg_phone_bu" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_phone_bu() RETURNS trigger AS $$\nbegin\n if new.slotname != old.slotname the..." +== 075 +-- truncate_limit: 100 +create trigger tg_phone_bu before update + on PHone for each row execute procedure tg_phone_bu() +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_phone_bu BEFORE UPDATE ON phone FOR EACH ROW EXECUTE FUNCTION tg_phone_bu()" +== 076 +-- truncate_limit: 100 +-- ************************************************************ +-- * AFTER INSERT or UPDATE or DELETE on slot with backlink +-- * - Ensure that the opponent correctly points back to us +-- ************************************************************ +create function tg_backlink_a() returns trigger as ' +declare + dummy integer; +begin + if tg_op = ''INSERT'' then + if new.backlink != '''' then + dummy := tg_backlink_set(new.backlink, new.slotname); + end if; + return new; + end if; + if tg_op = ''UPDATE'' then + if new.backlink != old.backlink then + if old.backlink != '''' then + dummy := tg_backlink_unset(old.backlink, old.slotname); + end if; + if new.backlink != '''' then + dummy := tg_backlink_set(new.backlink, new.slotname); + end if; + else + if new.slotname != old.slotname and new.backlink != '''' then + dummy := tg_slotlink_set(new.backlink, new.slotname); + end if; + end if; + return new; + end if; + if tg_op = ''DELETE'' then + if old.backlink != '''' then + dummy := tg_backlink_unset(old.backlink, old.slotname); + end if; + return old; + end if; +end; +' language plpgsql +-- +FUNCTION: name="tg_backlink_a" function="tg_backlink_a" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_backlink_a() RETURNS trigger AS $$\ndeclare\n dummy\tinteger;\nbegin\n if tg_..." +== 077 +-- truncate_limit: 100 +create trigger tg_backlink_a after insert or update or delete + on PSlot for each row execute procedure tg_backlink_a('PS') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_backlink_a AFTER INSERT OR DELETE OR UPDATE ON pslot FOR EACH ROW EXECUTE FUNCT..." +== 078 +-- truncate_limit: 100 +create trigger tg_backlink_a after insert or update or delete + on WSlot for each row execute procedure tg_backlink_a('WS') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_backlink_a AFTER INSERT OR DELETE OR UPDATE ON wslot FOR EACH ROW EXECUTE FUNCT..." +== 079 +-- truncate_limit: 100 +create trigger tg_backlink_a after insert or update or delete + on PLine for each row execute procedure tg_backlink_a('PL') +-- +TABLE: name="pline" schema="" table="pline" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_backlink_a AFTER INSERT OR DELETE OR UPDATE ON pline FOR EACH ROW EXECUTE FUNCT..." +== 080 +-- truncate_limit: 100 +-- ************************************************************ +-- * Support function to set the opponents backlink field +-- * if it does not already point to the requested slot +-- ************************************************************ +create function tg_backlink_set(myname bpchar, blname bpchar) +returns integer as ' +declare + mytype char(2); + link char(4); + rec record; +begin + mytype := substr(myname, 1, 2); + link := mytype || substr(blname, 1, 2); + if link = ''PLPL'' then + raise exception + ''backlink between two phone lines does not make sense''; + end if; + if link in (''PLWS'', ''WSPL'') then + raise exception + ''direct link of phone line to wall slot not permitted''; + end if; + if mytype = ''PS'' then + select into rec * from PSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.backlink != blname then + update PSlot set backlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''WS'' then + select into rec * from WSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.backlink != blname then + update WSlot set backlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''PL'' then + select into rec * from PLine where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.backlink != blname then + update PLine set backlink = blname where slotname = myname; + end if; + return 0; + end if; + raise exception ''illegal backlink beginning with %'', mytype; +end; +' language plpgsql +-- +FUNCTION: name="tg_backlink_set" function="tg_backlink_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_backlink_set(myname bpchar, blname bpchar) RETURNS int AS $$\ndeclare\n mytyp..." +== 081 +-- truncate_limit: 100 +-- ************************************************************ +-- * Support function to clear out the backlink field if +-- * it still points to specific slot +-- ************************************************************ +create function tg_backlink_unset(bpchar, bpchar) +returns integer as ' +declare + myname alias for $1; + blname alias for $2; + mytype char(2); + rec record; +begin + mytype := substr(myname, 1, 2); + if mytype = ''PS'' then + select into rec * from PSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.backlink = blname then + update PSlot set backlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''WS'' then + select into rec * from WSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.backlink = blname then + update WSlot set backlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''PL'' then + select into rec * from PLine where slotname = myname; + if not found then + return 0; + end if; + if rec.backlink = blname then + update PLine set backlink = '''' where slotname = myname; + end if; + return 0; + end if; +end +' language plpgsql +-- +FUNCTION: name="tg_backlink_unset" function="tg_backlink_unset" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_backlink_unset(bpchar, bpchar) RETURNS int AS $$\ndeclare\n myname\talias for ..." +== 082 +-- truncate_limit: 100 +-- ************************************************************ +-- * AFTER INSERT or UPDATE or DELETE on slot with slotlink +-- * - Ensure that the opponent correctly points back to us +-- ************************************************************ +create function tg_slotlink_a() returns trigger as ' +declare + dummy integer; +begin + if tg_op = ''INSERT'' then + if new.slotlink != '''' then + dummy := tg_slotlink_set(new.slotlink, new.slotname); + end if; + return new; + end if; + if tg_op = ''UPDATE'' then + if new.slotlink != old.slotlink then + if old.slotlink != '''' then + dummy := tg_slotlink_unset(old.slotlink, old.slotname); + end if; + if new.slotlink != '''' then + dummy := tg_slotlink_set(new.slotlink, new.slotname); + end if; + else + if new.slotname != old.slotname and new.slotlink != '''' then + dummy := tg_slotlink_set(new.slotlink, new.slotname); + end if; + end if; + return new; + end if; + if tg_op = ''DELETE'' then + if old.slotlink != '''' then + dummy := tg_slotlink_unset(old.slotlink, old.slotname); + end if; + return old; + end if; +end; +' language plpgsql +-- +FUNCTION: name="tg_slotlink_a" function="tg_slotlink_a" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_slotlink_a() RETURNS trigger AS $$\ndeclare\n dummy\tinteger;\nbegin\n if tg_..." +== 083 +-- truncate_limit: 100 +create trigger tg_slotlink_a after insert or update or delete + on PSlot for each row execute procedure tg_slotlink_a('PS') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_slotlink_a AFTER INSERT OR DELETE OR UPDATE ON pslot FOR EACH ROW EXECUTE FUNCT..." +== 084 +-- truncate_limit: 100 +create trigger tg_slotlink_a after insert or update or delete + on WSlot for each row execute procedure tg_slotlink_a('WS') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_slotlink_a AFTER INSERT OR DELETE OR UPDATE ON wslot FOR EACH ROW EXECUTE FUNCT..." +== 085 +-- truncate_limit: 100 +create trigger tg_slotlink_a after insert or update or delete + on IFace for each row execute procedure tg_slotlink_a('IF') +-- +TABLE: name="iface" schema="" table="iface" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_slotlink_a AFTER INSERT OR DELETE OR UPDATE ON iface FOR EACH ROW EXECUTE FUNCT..." +== 086 +-- truncate_limit: 100 +create trigger tg_slotlink_a after insert or update or delete + on HSlot for each row execute procedure tg_slotlink_a('HS') +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_slotlink_a AFTER INSERT OR DELETE OR UPDATE ON hslot FOR EACH ROW EXECUTE FUNCT..." +== 087 +-- truncate_limit: 100 +create trigger tg_slotlink_a after insert or update or delete + on PHone for each row execute procedure tg_slotlink_a('PH') +-- +TABLE: name="phone" schema="" table="phone" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_slotlink_a AFTER INSERT OR DELETE OR UPDATE ON phone FOR EACH ROW EXECUTE FUNCT..." +== 088 +-- truncate_limit: 100 +-- ************************************************************ +-- * Support function to set the opponents slotlink field +-- * if it does not already point to the requested slot +-- ************************************************************ +create function tg_slotlink_set(bpchar, bpchar) +returns integer as ' +declare + myname alias for $1; + blname alias for $2; + mytype char(2); + link char(4); + rec record; +begin + mytype := substr(myname, 1, 2); + link := mytype || substr(blname, 1, 2); + if link = ''PHPH'' then + raise exception + ''slotlink between two phones does not make sense''; + end if; + if link in (''PHHS'', ''HSPH'') then + raise exception + ''link of phone to hub does not make sense''; + end if; + if link in (''PHIF'', ''IFPH'') then + raise exception + ''link of phone to hub does not make sense''; + end if; + if link in (''PSWS'', ''WSPS'') then + raise exception + ''slotlink from patchslot to wallslot not permitted''; + end if; + if mytype = ''PS'' then + select into rec * from PSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update PSlot set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''WS'' then + select into rec * from WSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update WSlot set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''IF'' then + select into rec * from IFace where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update IFace set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''HS'' then + select into rec * from HSlot where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update HSlot set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + if mytype = ''PH'' then + select into rec * from PHone where slotname = myname; + if not found then + raise exception ''% does not exist'', myname; + end if; + if rec.slotlink != blname then + update PHone set slotlink = blname where slotname = myname; + end if; + return 0; + end if; + raise exception ''illegal slotlink beginning with %'', mytype; +end; +' language plpgsql +-- +FUNCTION: name="tg_slotlink_set" function="tg_slotlink_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_slotlink_set(bpchar, bpchar) RETURNS int AS $$\ndeclare\n myname\talias for $1..." +== 089 +-- truncate_limit: 100 +-- ************************************************************ +-- * Support function to clear out the slotlink field if +-- * it still points to specific slot +-- ************************************************************ +create function tg_slotlink_unset(bpchar, bpchar) +returns integer as ' +declare + myname alias for $1; + blname alias for $2; + mytype char(2); + rec record; +begin + mytype := substr(myname, 1, 2); + if mytype = ''PS'' then + select into rec * from PSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update PSlot set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''WS'' then + select into rec * from WSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update WSlot set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''IF'' then + select into rec * from IFace where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update IFace set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''HS'' then + select into rec * from HSlot where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update HSlot set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; + if mytype = ''PH'' then + select into rec * from PHone where slotname = myname; + if not found then + return 0; + end if; + if rec.slotlink = blname then + update PHone set slotlink = '''' where slotname = myname; + end if; + return 0; + end if; +end; +' language plpgsql +-- +FUNCTION: name="tg_slotlink_unset" function="tg_slotlink_unset" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tg_slotlink_unset(bpchar, bpchar) RETURNS int AS $$\ndeclare\n myname\talias for ..." +== 090 +-- truncate_limit: 100 +-- ************************************************************ +-- * Describe the backside of a patchfield slot +-- ************************************************************ +create function pslot_backlink_view(bpchar) +returns text as ' +<> +declare + rec record; + bltype char(2); + retval text; +begin + select into rec * from PSlot where slotname = $1; + if not found then + return ''''; + end if; + if rec.backlink = '''' then + return ''-''; + end if; + bltype := substr(rec.backlink, 1, 2); + if bltype = ''PL'' then + declare + rec record; + begin + select into rec * from PLine where slotname = "outer".rec.backlink; + retval := ''Phone line '' || trim(rec.phonenumber); + if rec.comment != '''' then + retval := retval || '' (''; + retval := retval || rec.comment; + retval := retval || '')''; + end if; + return retval; + end; + end if; + if bltype = ''WS'' then + select into rec * from WSlot where slotname = rec.backlink; + retval := trim(rec.slotname) || '' in room ''; + retval := retval || trim(rec.roomno); + retval := retval || '' -> ''; + return retval || wslot_slotlink_view(rec.slotname); + end if; + return rec.backlink; +end; +' language plpgsql +-- +FUNCTION: name="pslot_backlink_view" function="pslot_backlink_view" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION pslot_backlink_view(bpchar) RETURNS text AS $$\n<>\ndeclare\n rec\t\trecord;..." +== 091 +-- truncate_limit: 100 +-- ************************************************************ +-- * Describe the front of a patchfield slot +-- ************************************************************ +create function pslot_slotlink_view(bpchar) +returns text as ' +declare + psrec record; + sltype char(2); + retval text; +begin + select into psrec * from PSlot where slotname = $1; + if not found then + return ''''; + end if; + if psrec.slotlink = '''' then + return ''-''; + end if; + sltype := substr(psrec.slotlink, 1, 2); + if sltype = ''PS'' then + retval := trim(psrec.slotlink) || '' -> ''; + return retval || pslot_backlink_view(psrec.slotlink); + end if; + if sltype = ''HS'' then + retval := comment from Hub H, HSlot HS + where HS.slotname = psrec.slotlink + and H.name = HS.hubname; + retval := retval || '' slot ''; + retval := retval || slotno::text from HSlot + where slotname = psrec.slotlink; + return retval; + end if; + return psrec.slotlink; +end; +' language plpgsql +-- +FUNCTION: name="pslot_slotlink_view" function="pslot_slotlink_view" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION pslot_slotlink_view(bpchar) RETURNS text AS $$\ndeclare\n psrec\trecord;\n slty..." +== 092 +-- truncate_limit: 100 +-- ************************************************************ +-- * Describe the front of a wall connector slot +-- ************************************************************ +create function wslot_slotlink_view(bpchar) +returns text as ' +declare + rec record; + sltype char(2); + retval text; +begin + select into rec * from WSlot where slotname = $1; + if not found then + return ''''; + end if; + if rec.slotlink = '''' then + return ''-''; + end if; + sltype := substr(rec.slotlink, 1, 2); + if sltype = ''PH'' then + select into rec * from PHone where slotname = rec.slotlink; + retval := ''Phone '' || trim(rec.slotname); + if rec.comment != '''' then + retval := retval || '' (''; + retval := retval || rec.comment; + retval := retval || '')''; + end if; + return retval; + end if; + if sltype = ''IF'' then + declare + syrow System%RowType; + ifrow IFace%ROWTYPE; + begin + select into ifrow * from IFace where slotname = rec.slotlink; + select into syrow * from System where name = ifrow.sysname; + retval := syrow.name || '' IF ''; + retval := retval || ifrow.ifname; + if syrow.comment != '''' then + retval := retval || '' (''; + retval := retval || syrow.comment; + retval := retval || '')''; + end if; + return retval; + end; + end if; + return rec.slotlink; +end; +' language plpgsql +-- +FUNCTION: name="wslot_slotlink_view" function="wslot_slotlink_view" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION wslot_slotlink_view(bpchar) RETURNS text AS $$\ndeclare\n rec\t\trecord;\n sltyp..." +== 093 +-- truncate_limit: 100 +-- ************************************************************ +-- * View of a patchfield describing backside and patches +-- ************************************************************ +create view Pfield_v1 as select PF.pfname, PF.slotname, + pslot_backlink_view(PF.slotname) as backside, + pslot_slotlink_view(PF.slotname) as patch + from PSlot PF +-- +TABLE: name="pfield_v1" schema="" table="pfield_v1" ctx=DDL +TABLE: name="pslot" schema="" table="pslot" ctx=Select +ALIAS: "pf"="pslot" +FUNCTION: name="pslot_backlink_view" function="pslot_backlink_view" schema="" ctx=Call +FUNCTION: name="pslot_slotlink_view" function="pslot_slotlink_view" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW pfield_v1 AS SELECT pf.pfname, pf.slotname, pslot_backlink_view(pf.slotname) AS backs..." +== 094 +-- truncate_limit: 100 +|-- +-- First we build the house - so we create the rooms +|-- +insert into Room values ('001', 'Entrance') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('001', 'Entrance')" +== 095 +-- truncate_limit: 100 +insert into Room values ('002', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('002', 'Office')" +== 096 +-- truncate_limit: 100 +insert into Room values ('003', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('003', 'Office')" +== 097 +-- truncate_limit: 100 +insert into Room values ('004', 'Technical') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('004', 'Technical')" +== 098 +-- truncate_limit: 100 +insert into Room values ('101', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('101', 'Office')" +== 099 +-- truncate_limit: 100 +insert into Room values ('102', 'Conference') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('102', 'Conference')" +== 100 +-- truncate_limit: 100 +insert into Room values ('103', 'Restroom') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('103', 'Restroom')" +== 101 +-- truncate_limit: 100 +insert into Room values ('104', 'Technical') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('104', 'Technical')" +== 102 +-- truncate_limit: 100 +insert into Room values ('105', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('105', 'Office')" +== 103 +-- truncate_limit: 100 +insert into Room values ('106', 'Office') +-- +TABLE: name="room" schema="" table="room" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO room VALUES ('106', 'Office')" +== 104 +-- truncate_limit: 100 +|-- +-- Second we install the wall connectors +|-- +insert into WSlot values ('WS.001.1a', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.001.1a', '001', '', '')" +== 105 +-- truncate_limit: 100 +insert into WSlot values ('WS.001.1b', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.001.1b', '001', '', '')" +== 106 +-- truncate_limit: 100 +insert into WSlot values ('WS.001.2a', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.001.2a', '001', '', '')" +== 107 +-- truncate_limit: 100 +insert into WSlot values ('WS.001.2b', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.001.2b', '001', '', '')" +== 108 +-- truncate_limit: 100 +insert into WSlot values ('WS.001.3a', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.001.3a', '001', '', '')" +== 109 +-- truncate_limit: 100 +insert into WSlot values ('WS.001.3b', '001', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.001.3b', '001', '', '')" +== 110 +-- truncate_limit: 100 +insert into WSlot values ('WS.002.1a', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.002.1a', '002', '', '')" +== 111 +-- truncate_limit: 100 +insert into WSlot values ('WS.002.1b', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.002.1b', '002', '', '')" +== 112 +-- truncate_limit: 100 +insert into WSlot values ('WS.002.2a', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.002.2a', '002', '', '')" +== 113 +-- truncate_limit: 100 +insert into WSlot values ('WS.002.2b', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.002.2b', '002', '', '')" +== 114 +-- truncate_limit: 100 +insert into WSlot values ('WS.002.3a', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.002.3a', '002', '', '')" +== 115 +-- truncate_limit: 100 +insert into WSlot values ('WS.002.3b', '002', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.002.3b', '002', '', '')" +== 116 +-- truncate_limit: 100 +insert into WSlot values ('WS.003.1a', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.003.1a', '003', '', '')" +== 117 +-- truncate_limit: 100 +insert into WSlot values ('WS.003.1b', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.003.1b', '003', '', '')" +== 118 +-- truncate_limit: 100 +insert into WSlot values ('WS.003.2a', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.003.2a', '003', '', '')" +== 119 +-- truncate_limit: 100 +insert into WSlot values ('WS.003.2b', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.003.2b', '003', '', '')" +== 120 +-- truncate_limit: 100 +insert into WSlot values ('WS.003.3a', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.003.3a', '003', '', '')" +== 121 +-- truncate_limit: 100 +insert into WSlot values ('WS.003.3b', '003', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.003.3b', '003', '', '')" +== 122 +-- truncate_limit: 100 +insert into WSlot values ('WS.101.1a', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.101.1a', '101', '', '')" +== 123 +-- truncate_limit: 100 +insert into WSlot values ('WS.101.1b', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.101.1b', '101', '', '')" +== 124 +-- truncate_limit: 100 +insert into WSlot values ('WS.101.2a', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.101.2a', '101', '', '')" +== 125 +-- truncate_limit: 100 +insert into WSlot values ('WS.101.2b', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.101.2b', '101', '', '')" +== 126 +-- truncate_limit: 100 +insert into WSlot values ('WS.101.3a', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.101.3a', '101', '', '')" +== 127 +-- truncate_limit: 100 +insert into WSlot values ('WS.101.3b', '101', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.101.3b', '101', '', '')" +== 128 +-- truncate_limit: 100 +insert into WSlot values ('WS.102.1a', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.102.1a', '102', '', '')" +== 129 +-- truncate_limit: 100 +insert into WSlot values ('WS.102.1b', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.102.1b', '102', '', '')" +== 130 +-- truncate_limit: 100 +insert into WSlot values ('WS.102.2a', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.102.2a', '102', '', '')" +== 131 +-- truncate_limit: 100 +insert into WSlot values ('WS.102.2b', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.102.2b', '102', '', '')" +== 132 +-- truncate_limit: 100 +insert into WSlot values ('WS.102.3a', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.102.3a', '102', '', '')" +== 133 +-- truncate_limit: 100 +insert into WSlot values ('WS.102.3b', '102', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.102.3b', '102', '', '')" +== 134 +-- truncate_limit: 100 +insert into WSlot values ('WS.105.1a', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.105.1a', '105', '', '')" +== 135 +-- truncate_limit: 100 +insert into WSlot values ('WS.105.1b', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.105.1b', '105', '', '')" +== 136 +-- truncate_limit: 100 +insert into WSlot values ('WS.105.2a', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.105.2a', '105', '', '')" +== 137 +-- truncate_limit: 100 +insert into WSlot values ('WS.105.2b', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.105.2b', '105', '', '')" +== 138 +-- truncate_limit: 100 +insert into WSlot values ('WS.105.3a', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.105.3a', '105', '', '')" +== 139 +-- truncate_limit: 100 +insert into WSlot values ('WS.105.3b', '105', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.105.3b', '105', '', '')" +== 140 +-- truncate_limit: 100 +insert into WSlot values ('WS.106.1a', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.106.1a', '106', '', '')" +== 141 +-- truncate_limit: 100 +insert into WSlot values ('WS.106.1b', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.106.1b', '106', '', '')" +== 142 +-- truncate_limit: 100 +insert into WSlot values ('WS.106.2a', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.106.2a', '106', '', '')" +== 143 +-- truncate_limit: 100 +insert into WSlot values ('WS.106.2b', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.106.2b', '106', '', '')" +== 144 +-- truncate_limit: 100 +insert into WSlot values ('WS.106.3a', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.106.3a', '106', '', '')" +== 145 +-- truncate_limit: 100 +insert into WSlot values ('WS.106.3b', '106', '', '') +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wslot VALUES ('WS.106.3b', '106', '', '')" +== 146 +-- truncate_limit: 100 +|-- +-- Now create the patch fields and their slots +|-- +insert into PField values ('PF0_1', 'Wallslots basement') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pfield VALUES ('PF0_1', 'Wallslots basement')" +== 147 +-- truncate_limit: 100 +|-- +-- The cables for these will be made later, so they are unconnected for now +|-- +insert into PSlot values ('PS.base.a1', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.a1', 'PF0_1', '', '')" +== 148 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.a2', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.a2', 'PF0_1', '', '')" +== 149 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.a3', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.a3', 'PF0_1', '', '')" +== 150 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.a4', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.a4', 'PF0_1', '', '')" +== 151 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.a5', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.a5', 'PF0_1', '', '')" +== 152 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.a6', 'PF0_1', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.a6', 'PF0_1', '', '')" +== 153 +-- truncate_limit: 100 +|-- +-- These are already wired to the wall connectors +|-- +insert into PSlot values ('PS.base.b1', 'PF0_1', '', 'WS.002.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.b1', 'PF0_1', '', 'WS.002.1a')" +== 154 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.b2', 'PF0_1', '', 'WS.002.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.b2', 'PF0_1', '', 'WS.002.1b')" +== 155 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.b3', 'PF0_1', '', 'WS.002.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.b3', 'PF0_1', '', 'WS.002.2a')" +== 156 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.b4', 'PF0_1', '', 'WS.002.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.b4', 'PF0_1', '', 'WS.002.2b')" +== 157 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.b5', 'PF0_1', '', 'WS.002.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.b5', 'PF0_1', '', 'WS.002.3a')" +== 158 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.b6', 'PF0_1', '', 'WS.002.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.b6', 'PF0_1', '', 'WS.002.3b')" +== 159 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.c1', 'PF0_1', '', 'WS.003.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.c1', 'PF0_1', '', 'WS.003.1a')" +== 160 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.c2', 'PF0_1', '', 'WS.003.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.c2', 'PF0_1', '', 'WS.003.1b')" +== 161 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.c3', 'PF0_1', '', 'WS.003.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.c3', 'PF0_1', '', 'WS.003.2a')" +== 162 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.c4', 'PF0_1', '', 'WS.003.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.c4', 'PF0_1', '', 'WS.003.2b')" +== 163 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.c5', 'PF0_1', '', 'WS.003.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.c5', 'PF0_1', '', 'WS.003.3a')" +== 164 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.c6', 'PF0_1', '', 'WS.003.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.c6', 'PF0_1', '', 'WS.003.3b')" +== 165 +-- truncate_limit: 100 +|-- +-- This patchfield will be renamed later into PF0_2 - so its +-- slots references in pfname should follow +|-- +insert into PField values ('PF0_X', 'Phonelines basement') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pfield VALUES ('PF0_X', 'Phonelines basement')" +== 166 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.ta1', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.ta1', 'PF0_X', '', '')" +== 167 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.ta2', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.ta2', 'PF0_X', '', '')" +== 168 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.ta3', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.ta3', 'PF0_X', '', '')" +== 169 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.ta4', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.ta4', 'PF0_X', '', '')" +== 170 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.ta5', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.ta5', 'PF0_X', '', '')" +== 171 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.ta6', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.ta6', 'PF0_X', '', '')" +== 172 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.tb1', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.tb1', 'PF0_X', '', '')" +== 173 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.tb2', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.tb2', 'PF0_X', '', '')" +== 174 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.tb3', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.tb3', 'PF0_X', '', '')" +== 175 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.tb4', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.tb4', 'PF0_X', '', '')" +== 176 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.tb5', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.tb5', 'PF0_X', '', '')" +== 177 +-- truncate_limit: 100 +insert into PSlot values ('PS.base.tb6', 'PF0_X', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.base.tb6', 'PF0_X', '', '')" +== 178 +-- truncate_limit: 100 +insert into PField values ('PF1_1', 'Wallslots first floor') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pfield VALUES ('PF1_1', 'Wallslots first floor')" +== 179 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.a1', 'PF1_1', '', 'WS.101.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.a1', 'PF1_1', '', 'WS.101.1a')" +== 180 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.a2', 'PF1_1', '', 'WS.101.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.a2', 'PF1_1', '', 'WS.101.1b')" +== 181 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.a3', 'PF1_1', '', 'WS.101.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.a3', 'PF1_1', '', 'WS.101.2a')" +== 182 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.a4', 'PF1_1', '', 'WS.101.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.a4', 'PF1_1', '', 'WS.101.2b')" +== 183 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.a5', 'PF1_1', '', 'WS.101.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.a5', 'PF1_1', '', 'WS.101.3a')" +== 184 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.a6', 'PF1_1', '', 'WS.101.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.a6', 'PF1_1', '', 'WS.101.3b')" +== 185 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.b1', 'PF1_1', '', 'WS.102.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.b1', 'PF1_1', '', 'WS.102.1a')" +== 186 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.b2', 'PF1_1', '', 'WS.102.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.b2', 'PF1_1', '', 'WS.102.1b')" +== 187 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.b3', 'PF1_1', '', 'WS.102.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.b3', 'PF1_1', '', 'WS.102.2a')" +== 188 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.b4', 'PF1_1', '', 'WS.102.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.b4', 'PF1_1', '', 'WS.102.2b')" +== 189 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.b5', 'PF1_1', '', 'WS.102.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.b5', 'PF1_1', '', 'WS.102.3a')" +== 190 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.b6', 'PF1_1', '', 'WS.102.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.b6', 'PF1_1', '', 'WS.102.3b')" +== 191 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.c1', 'PF1_1', '', 'WS.105.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.c1', 'PF1_1', '', 'WS.105.1a')" +== 192 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.c2', 'PF1_1', '', 'WS.105.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.c2', 'PF1_1', '', 'WS.105.1b')" +== 193 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.c3', 'PF1_1', '', 'WS.105.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.c3', 'PF1_1', '', 'WS.105.2a')" +== 194 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.c4', 'PF1_1', '', 'WS.105.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.c4', 'PF1_1', '', 'WS.105.2b')" +== 195 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.c5', 'PF1_1', '', 'WS.105.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.c5', 'PF1_1', '', 'WS.105.3a')" +== 196 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.c6', 'PF1_1', '', 'WS.105.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.c6', 'PF1_1', '', 'WS.105.3b')" +== 197 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.d1', 'PF1_1', '', 'WS.106.1a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.d1', 'PF1_1', '', 'WS.106.1a')" +== 198 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.d2', 'PF1_1', '', 'WS.106.1b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.d2', 'PF1_1', '', 'WS.106.1b')" +== 199 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.d3', 'PF1_1', '', 'WS.106.2a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.d3', 'PF1_1', '', 'WS.106.2a')" +== 200 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.d4', 'PF1_1', '', 'WS.106.2b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.d4', 'PF1_1', '', 'WS.106.2b')" +== 201 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.d5', 'PF1_1', '', 'WS.106.3a') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.d5', 'PF1_1', '', 'WS.106.3a')" +== 202 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.d6', 'PF1_1', '', 'WS.106.3b') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.d6', 'PF1_1', '', 'WS.106.3b')" +== 203 +-- truncate_limit: 100 +|-- +-- Now we wire the wall connectors 1a-2a in room 001 to the +-- patchfield. In the second update we make an error, and +-- correct it after +|-- +update PSlot set backlink = 'WS.001.1a' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET backlink = 'WS.001.1a' WHERE slotname = 'PS.base.a1'" +== 204 +-- truncate_limit: 100 +update PSlot set backlink = 'WS.001.1b' where slotname = 'PS.base.a3' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET backlink = 'WS.001.1b' WHERE slotname = 'PS.base.a3'" +== 205 +-- truncate_limit: 100 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wslot WHERE roomno = '001' ORDER BY slotname" +== 206 +-- truncate_limit: 100 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pslot WHERE slotname ~ 'PS.base.a' ORDER BY slotname" +== 207 +-- truncate_limit: 100 +update PSlot set backlink = 'WS.001.2a' where slotname = 'PS.base.a3' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET backlink = 'WS.001.2a' WHERE slotname = 'PS.base.a3'" +== 208 +-- truncate_limit: 100 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wslot WHERE roomno = '001' ORDER BY slotname" +== 209 +-- truncate_limit: 100 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pslot WHERE slotname ~ 'PS.base.a' ORDER BY slotname" +== 210 +-- truncate_limit: 100 +update PSlot set backlink = 'WS.001.1b' where slotname = 'PS.base.a2' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET backlink = 'WS.001.1b' WHERE slotname = 'PS.base.a2'" +== 211 +-- truncate_limit: 100 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wslot WHERE roomno = '001' ORDER BY slotname" +== 212 +-- truncate_limit: 100 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pslot WHERE slotname ~ 'PS.base.a' ORDER BY slotname" +== 213 +-- truncate_limit: 100 +|-- +-- Same procedure for 2b-3b but this time updating the WSlot instead +-- of the PSlot. Due to the triggers the result is the same: +-- WSlot and corresponding PSlot point to each other. +|-- +update WSlot set backlink = 'PS.base.a4' where slotname = 'WS.001.2b' +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE wslot SET backlink = 'PS.base.a4' WHERE slotname = 'WS.001.2b'" +== 214 +-- truncate_limit: 100 +update WSlot set backlink = 'PS.base.a6' where slotname = 'WS.001.3a' +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE wslot SET backlink = 'PS.base.a6' WHERE slotname = 'WS.001.3a'" +== 215 +-- truncate_limit: 100 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wslot WHERE roomno = '001' ORDER BY slotname" +== 216 +-- truncate_limit: 100 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pslot WHERE slotname ~ 'PS.base.a' ORDER BY slotname" +== 217 +-- truncate_limit: 100 +update WSlot set backlink = 'PS.base.a6' where slotname = 'WS.001.3b' +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE wslot SET backlink = 'PS.base.a6' WHERE slotname = 'WS.001.3b'" +== 218 +-- truncate_limit: 100 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wslot WHERE roomno = '001' ORDER BY slotname" +== 219 +-- truncate_limit: 100 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pslot WHERE slotname ~ 'PS.base.a' ORDER BY slotname" +== 220 +-- truncate_limit: 100 +update WSlot set backlink = 'PS.base.a5' where slotname = 'WS.001.3a' +-- +TABLE: name="wslot" schema="" table="wslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE wslot SET backlink = 'PS.base.a5' WHERE slotname = 'WS.001.3a'" +== 221 +-- truncate_limit: 100 +select * from WSlot where roomno = '001' order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +FILTER: schema="" table="" column="roomno" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wslot WHERE roomno = '001' ORDER BY slotname" +== 222 +-- truncate_limit: 100 +select * from PSlot where slotname ~ 'PS.base.a' order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +FILTER: schema="" table="" column="slotname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pslot WHERE slotname ~ 'PS.base.a' ORDER BY slotname" +== 223 +-- truncate_limit: 100 +insert into PField values ('PF1_2', 'Phonelines first floor') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pfield VALUES ('PF1_2', 'Phonelines first floor')" +== 224 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.ta1', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.ta1', 'PF1_2', '', '')" +== 225 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.ta2', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.ta2', 'PF1_2', '', '')" +== 226 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.ta3', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.ta3', 'PF1_2', '', '')" +== 227 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.ta4', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.ta4', 'PF1_2', '', '')" +== 228 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.ta5', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.ta5', 'PF1_2', '', '')" +== 229 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.ta6', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.ta6', 'PF1_2', '', '')" +== 230 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.tb1', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.tb1', 'PF1_2', '', '')" +== 231 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.tb2', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.tb2', 'PF1_2', '', '')" +== 232 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.tb3', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.tb3', 'PF1_2', '', '')" +== 233 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.tb4', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.tb4', 'PF1_2', '', '')" +== 234 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.tb5', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.tb5', 'PF1_2', '', '')" +== 235 +-- truncate_limit: 100 +insert into PSlot values ('PS.first.tb6', 'PF1_2', '', '') +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pslot VALUES ('PS.first.tb6', 'PF1_2', '', '')" +== 236 +-- truncate_limit: 100 +|-- +-- Fix the wrong name for patchfield PF0_2 +|-- +update PField set name = 'PF0_2' where name = 'PF0_X' +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pfield SET name = 'PF0_2' WHERE name = 'PF0_X'" +== 237 +-- truncate_limit: 100 +select * from PSlot order by slotname +-- +TABLE: name="pslot" schema="" table="pslot" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pslot ORDER BY slotname" +== 238 +-- truncate_limit: 100 +select * from WSlot order by slotname +-- +TABLE: name="wslot" schema="" table="wslot" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM wslot ORDER BY slotname" +== 239 +-- truncate_limit: 100 +|-- +-- Install the central phone system and create the phone numbers. +-- They are wired on insert to the patchfields. Again the +-- triggers automatically tell the PSlots to update their +-- backlink field. +|-- +insert into PLine values ('PL.001', '-0', 'Central call', 'PS.base.ta1') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.001', '-0', 'Central call', 'PS.base.ta1')" +== 240 +-- truncate_limit: 100 +insert into PLine values ('PL.002', '-101', '', 'PS.base.ta2') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.002', '-101', '', 'PS.base.ta2')" +== 241 +-- truncate_limit: 100 +insert into PLine values ('PL.003', '-102', '', 'PS.base.ta3') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.003', '-102', '', 'PS.base.ta3')" +== 242 +-- truncate_limit: 100 +insert into PLine values ('PL.004', '-103', '', 'PS.base.ta5') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.004', '-103', '', 'PS.base.ta5')" +== 243 +-- truncate_limit: 100 +insert into PLine values ('PL.005', '-104', '', 'PS.base.ta6') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.005', '-104', '', 'PS.base.ta6')" +== 244 +-- truncate_limit: 100 +insert into PLine values ('PL.006', '-106', '', 'PS.base.tb2') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.006', '-106', '', 'PS.base.tb2')" +== 245 +-- truncate_limit: 100 +insert into PLine values ('PL.007', '-108', '', 'PS.base.tb3') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.007', '-108', '', 'PS.base.tb3')" +== 246 +-- truncate_limit: 100 +insert into PLine values ('PL.008', '-109', '', 'PS.base.tb4') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.008', '-109', '', 'PS.base.tb4')" +== 247 +-- truncate_limit: 100 +insert into PLine values ('PL.009', '-121', '', 'PS.base.tb5') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.009', '-121', '', 'PS.base.tb5')" +== 248 +-- truncate_limit: 100 +insert into PLine values ('PL.010', '-122', '', 'PS.base.tb6') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.010', '-122', '', 'PS.base.tb6')" +== 249 +-- truncate_limit: 100 +insert into PLine values ('PL.015', '-134', '', 'PS.first.ta1') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.015', '-134', '', 'PS.first.ta1')" +== 250 +-- truncate_limit: 100 +insert into PLine values ('PL.016', '-137', '', 'PS.first.ta3') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.016', '-137', '', 'PS.first.ta3')" +== 251 +-- truncate_limit: 100 +insert into PLine values ('PL.017', '-139', '', 'PS.first.ta4') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.017', '-139', '', 'PS.first.ta4')" +== 252 +-- truncate_limit: 100 +insert into PLine values ('PL.018', '-362', '', 'PS.first.tb1') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.018', '-362', '', 'PS.first.tb1')" +== 253 +-- truncate_limit: 100 +insert into PLine values ('PL.019', '-363', '', 'PS.first.tb2') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.019', '-363', '', 'PS.first.tb2')" +== 254 +-- truncate_limit: 100 +insert into PLine values ('PL.020', '-364', '', 'PS.first.tb3') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.020', '-364', '', 'PS.first.tb3')" +== 255 +-- truncate_limit: 100 +insert into PLine values ('PL.021', '-365', '', 'PS.first.tb5') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.021', '-365', '', 'PS.first.tb5')" +== 256 +-- truncate_limit: 100 +insert into PLine values ('PL.022', '-367', '', 'PS.first.tb6') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.022', '-367', '', 'PS.first.tb6')" +== 257 +-- truncate_limit: 100 +insert into PLine values ('PL.028', '-501', 'Fax entrance', 'PS.base.ta2') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.028', '-501', 'Fax entrance', 'PS.base.ta2')" +== 258 +-- truncate_limit: 100 +insert into PLine values ('PL.029', '-502', 'Fax first floor', 'PS.first.ta1') +-- +TABLE: name="pline" schema="" table="pline" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pline VALUES ('PL.029', '-502', 'Fax first floor', 'PS.first.ta1')" +== 259 +-- truncate_limit: 100 +|-- +-- Buy some phones, plug them into the wall and patch the +-- phone lines to the corresponding patchfield slots. +|-- +insert into PHone values ('PH.hc001', 'Hicom standard', 'WS.001.1a') +-- +TABLE: name="phone" schema="" table="phone" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO phone VALUES ('PH.hc001', 'Hicom standard', 'WS.001.1a')" +== 260 +-- truncate_limit: 100 +update PSlot set slotlink = 'PS.base.ta1' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET slotlink = 'PS.base.ta1' WHERE slotname = 'PS.base.a1'" +== 261 +-- truncate_limit: 100 +insert into PHone values ('PH.hc002', 'Hicom standard', 'WS.002.1a') +-- +TABLE: name="phone" schema="" table="phone" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO phone VALUES ('PH.hc002', 'Hicom standard', 'WS.002.1a')" +== 262 +-- truncate_limit: 100 +update PSlot set slotlink = 'PS.base.ta5' where slotname = 'PS.base.b1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET slotlink = 'PS.base.ta5' WHERE slotname = 'PS.base.b1'" +== 263 +-- truncate_limit: 100 +insert into PHone values ('PH.hc003', 'Hicom standard', 'WS.002.2a') +-- +TABLE: name="phone" schema="" table="phone" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO phone VALUES ('PH.hc003', 'Hicom standard', 'WS.002.2a')" +== 264 +-- truncate_limit: 100 +update PSlot set slotlink = 'PS.base.tb2' where slotname = 'PS.base.b3' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET slotlink = 'PS.base.tb2' WHERE slotname = 'PS.base.b3'" +== 265 +-- truncate_limit: 100 +insert into PHone values ('PH.fax001', 'Canon fax', 'WS.001.2a') +-- +TABLE: name="phone" schema="" table="phone" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO phone VALUES ('PH.fax001', 'Canon fax', 'WS.001.2a')" +== 266 +-- truncate_limit: 100 +update PSlot set slotlink = 'PS.base.ta2' where slotname = 'PS.base.a3' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET slotlink = 'PS.base.ta2' WHERE slotname = 'PS.base.a3'" +== 267 +-- truncate_limit: 100 +|-- +-- Install a hub at one of the patchfields, plug a computers +-- ethernet interface into the wall and patch it to the hub. +|-- +insert into Hub values ('base.hub1', 'Patchfield PF0_1 hub', 16) +-- +TABLE: name="hub" schema="" table="hub" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hub VALUES ('base.hub1', 'Patchfield PF0_1 hub', 16)" +== 268 +-- truncate_limit: 100 +insert into System values ('orion', 'PC') +-- +TABLE: name="system" schema="" table="system" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO system VALUES ('orion', 'PC')" +== 269 +-- truncate_limit: 100 +insert into IFace values ('IF', 'orion', 'eth0', 'WS.002.1b') +-- +TABLE: name="iface" schema="" table="iface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iface VALUES ('IF', 'orion', 'eth0', 'WS.002.1b')" +== 270 +-- truncate_limit: 100 +update PSlot set slotlink = 'HS.base.hub1.1' where slotname = 'PS.base.b2' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET slotlink = 'HS.base.hub1.1' WHERE slotname = 'PS.base.b2'" +== 271 +-- truncate_limit: 100 +|-- +-- Now we take a look at the patchfield +|-- +select * from PField_v1 where pfname = 'PF0_1' order by slotname +-- +TABLE: name="pfield_v1" schema="" table="pfield_v1" ctx=Select +FILTER: schema="" table="" column="pfname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pfield_v1 WHERE pfname = 'PF0_1' ORDER BY slotname" +== 272 +-- truncate_limit: 100 +select * from PField_v1 where pfname = 'PF0_2' order by slotname +-- +TABLE: name="pfield_v1" schema="" table="pfield_v1" ctx=Select +FILTER: schema="" table="" column="pfname" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pfield_v1 WHERE pfname = 'PF0_2' ORDER BY slotname" +== 273 +-- truncate_limit: 100 +|-- +-- Finally we want errors +|-- +insert into PField values ('PF1_1', 'should fail due to unique index') +-- +TABLE: name="pfield" schema="" table="pfield" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pfield VALUES ('PF1_1', 'should fail due to unique index')" +== 274 +-- truncate_limit: 100 +update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET backlink = 'WS.not.there' WHERE slotname = 'PS.base.a1'" +== 275 +-- truncate_limit: 100 +update PSlot set backlink = 'XX.illegal' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET backlink = 'XX.illegal' WHERE slotname = 'PS.base.a1'" +== 276 +-- truncate_limit: 100 +update PSlot set slotlink = 'PS.not.there' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET slotlink = 'PS.not.there' WHERE slotname = 'PS.base.a1'" +== 277 +-- truncate_limit: 100 +update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1' +-- +TABLE: name="pslot" schema="" table="pslot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pslot SET slotlink = 'XX.illegal' WHERE slotname = 'PS.base.a1'" +== 278 +-- truncate_limit: 100 +insert into HSlot values ('HS', 'base.hub1', 1, '') +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hslot VALUES ('HS', 'base.hub1', 1, '')" +== 279 +-- truncate_limit: 100 +insert into HSlot values ('HS', 'base.hub1', 20, '') +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hslot VALUES ('HS', 'base.hub1', 20, '')" +== 280 +-- truncate_limit: 100 +delete from HSlot +-- +TABLE: name="hslot" schema="" table="hslot" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM hslot" +== 281 +-- truncate_limit: 100 +insert into IFace values ('IF', 'notthere', 'eth0', '') +-- +TABLE: name="iface" schema="" table="iface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iface VALUES ('IF', 'notthere', 'eth0', '')" +== 282 +-- truncate_limit: 100 +insert into IFace values ('IF', 'orion', 'ethernet_interface_name_too_long', '') +-- +TABLE: name="iface" schema="" table="iface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iface VALUES ('IF', 'orion', 'ethernet_interface_name_too_long', '')" +== 283 +-- truncate_limit: 100 +|-- +-- The following tests are unrelated to the scenario outlined above; +-- they merely exercise specific parts of PL/pgSQL +|-- + +|-- +-- Test recursion, per bug report 7-Sep-01 +|-- +CREATE FUNCTION recursion_test(int,int) RETURNS text AS ' +DECLARE rslt text; +BEGIN + IF $1 <= 0 THEN + rslt = CAST($2 AS TEXT); + ELSE + rslt = CAST($1 AS TEXT) || '','' || recursion_test($1 - 1, $2); + END IF; + RETURN rslt; +END;' LANGUAGE plpgsql +-- +FUNCTION: name="recursion_test" function="recursion_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION recursion_test(int, int) RETURNS text AS $$\nDECLARE rslt text;\nBEGIN\n IF $1 <=..." +== 284 +-- truncate_limit: 100 +SELECT recursion_test(4,3) +-- +FUNCTION: name="recursion_test" function="recursion_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT recursion_test(4, 3)" +== 285 +-- truncate_limit: 100 +|-- +-- Test the FOUND magic variable +|-- +CREATE TABLE found_test_tbl (a int) +-- +TABLE: name="found_test_tbl" schema="" table="found_test_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE found_test_tbl (a int)" +== 286 +-- truncate_limit: 100 +create function test_found() + returns boolean as ' + declare + begin + insert into found_test_tbl values (1); + if FOUND then + insert into found_test_tbl values (2); + end if; + + update found_test_tbl set a = 100 where a = 1; + if FOUND then + insert into found_test_tbl values (3); + end if; + + delete from found_test_tbl where a = 9999; -- matches no rows + if not FOUND then + insert into found_test_tbl values (4); + end if; + + for i in 1 .. 10 loop + -- no need to do anything + end loop; + if FOUND then + insert into found_test_tbl values (5); + end if; + + -- never executes the loop + for i in 2 .. 1 loop + -- no need to do anything + end loop; + if not FOUND then + insert into found_test_tbl values (6); + end if; + return true; + end;' language plpgsql +-- +FUNCTION: name="test_found" function="test_found" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_found() RETURNS boolean AS $$\n declare\n begin\n insert into found_test_tbl..." +== 287 +-- truncate_limit: 100 +select test_found() +-- +FUNCTION: name="test_found" function="test_found" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_found()" +== 288 +-- truncate_limit: 100 +select * from found_test_tbl +-- +TABLE: name="found_test_tbl" schema="" table="found_test_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM found_test_tbl" +== 289 +-- truncate_limit: 100 +|-- +-- Test set-returning functions for PL/pgSQL +|-- + +create function test_table_func_rec() returns setof found_test_tbl as ' +DECLARE + rec RECORD; +BEGIN + FOR rec IN select * from found_test_tbl LOOP + RETURN NEXT rec; + END LOOP; + RETURN; +END;' language plpgsql +-- +FUNCTION: name="test_table_func_rec" function="test_table_func_rec" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_table_func_rec() RETURNS SETOF found_test_tbl AS $$\nDECLARE\n\trec RECORD;\nBEG..." +== 290 +-- truncate_limit: 100 +select * from test_table_func_rec() +-- +FUNCTION: name="test_table_func_rec" function="test_table_func_rec" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_table_func_rec()" +== 291 +-- truncate_limit: 100 +create function test_table_func_row() returns setof found_test_tbl as ' +DECLARE + row found_test_tbl%ROWTYPE; +BEGIN + FOR row IN select * from found_test_tbl LOOP + RETURN NEXT row; + END LOOP; + RETURN; +END;' language plpgsql +-- +FUNCTION: name="test_table_func_row" function="test_table_func_row" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_table_func_row() RETURNS SETOF found_test_tbl AS $$\nDECLARE\n\trow found_test_..." +== 292 +-- truncate_limit: 100 +select * from test_table_func_row() +-- +FUNCTION: name="test_table_func_row" function="test_table_func_row" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_table_func_row()" +== 293 +-- truncate_limit: 100 +create function test_ret_set_scalar(int,int) returns setof int as ' +DECLARE + i int; +BEGIN + FOR i IN $1 .. $2 LOOP + RETURN NEXT i + 1; + END LOOP; + RETURN; +END;' language plpgsql +-- +FUNCTION: name="test_ret_set_scalar" function="test_ret_set_scalar" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_ret_set_scalar(int, int) RETURNS SETOF int AS $$\nDECLARE\n\ti int;\nBEGIN\n\tFOR ..." +== 294 +-- truncate_limit: 100 +select * from test_ret_set_scalar(1,10) +-- +FUNCTION: name="test_ret_set_scalar" function="test_ret_set_scalar" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_ret_set_scalar(1, 10)" +== 295 +-- truncate_limit: 100 +create function test_ret_set_rec_dyn(int) returns setof record as ' +DECLARE + retval RECORD; +BEGIN + IF $1 > 10 THEN + SELECT INTO retval 5, 10, 15; + RETURN NEXT retval; + RETURN NEXT retval; + ELSE + SELECT INTO retval 50, 5::numeric, ''xxx''::text; + RETURN NEXT retval; + RETURN NEXT retval; + END IF; + RETURN; +END;' language plpgsql +-- +FUNCTION: name="test_ret_set_rec_dyn" function="test_ret_set_rec_dyn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_ret_set_rec_dyn(int) RETURNS SETOF record AS $$\nDECLARE\n\tretval RECORD;\nBEGI..." +== 296 +-- truncate_limit: 100 +SELECT * FROM test_ret_set_rec_dyn(1500) AS (a int, b int, c int) +-- +FUNCTION: name="test_ret_set_rec_dyn" function="test_ret_set_rec_dyn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_ret_set_rec_dyn(1500) AS (a int, b int, c int)" +== 297 +-- truncate_limit: 100 +SELECT * FROM test_ret_set_rec_dyn(5) AS (a int, b numeric, c text) +-- +FUNCTION: name="test_ret_set_rec_dyn" function="test_ret_set_rec_dyn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_ret_set_rec_dyn(5) AS (a int, b numeric, c text)" +== 298 +-- truncate_limit: 100 +create function test_ret_rec_dyn(int) returns record as ' +DECLARE + retval RECORD; +BEGIN + IF $1 > 10 THEN + SELECT INTO retval 5, 10, 15; + RETURN retval; + ELSE + SELECT INTO retval 50, 5::numeric, ''xxx''::text; + RETURN retval; + END IF; +END;' language plpgsql +-- +FUNCTION: name="test_ret_rec_dyn" function="test_ret_rec_dyn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_ret_rec_dyn(int) RETURNS record AS $$\nDECLARE\n\tretval RECORD;\nBEGIN\n\tIF $1 >..." +== 299 +-- truncate_limit: 100 +SELECT * FROM test_ret_rec_dyn(1500) AS (a int, b int, c int) +-- +FUNCTION: name="test_ret_rec_dyn" function="test_ret_rec_dyn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_ret_rec_dyn(1500) AS (a int, b int, c int)" +== 300 +-- truncate_limit: 100 +SELECT * FROM test_ret_rec_dyn(5) AS (a int, b numeric, c text) +-- +FUNCTION: name="test_ret_rec_dyn" function="test_ret_rec_dyn" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_ret_rec_dyn(5) AS (a int, b numeric, c text)" +== 301 +-- truncate_limit: 100 +|-- +-- Test some simple polymorphism cases. +|-- + +create function f1(x anyelement) returns anyelement as $$ +begin + return x + 1; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anyelement) RETURNS anyelement AS $$\nbegin\n return x + 1;\nend$$ LANGUAGE pl..." +== 302 +-- truncate_limit: 100 +select f1(42) as int, f1(4.5) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(42) AS \"int\", f1(4.5) AS num" +== 303 +-- truncate_limit: 100 +select f1(point(3,4)) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(point(3, 4))" +== 304 +-- truncate_limit: 100 +-- fail for lack of + operator + +drop function f1(x anyelement) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(x anyelement)" +== 305 +-- truncate_limit: 100 +create function f1(x anyelement) returns anyarray as $$ +begin + return array[x + 1, x + 2]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anyelement) RETURNS anyarray AS $$\nbegin\n return array[x + 1, x + 2];\nend$$..." +== 306 +-- truncate_limit: 100 +select f1(42) as int, f1(4.5) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(42) AS \"int\", f1(4.5) AS num" +== 307 +-- truncate_limit: 100 +drop function f1(x anyelement) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(x anyelement)" +== 308 +-- truncate_limit: 100 +create function f1(x anyarray) returns anyelement as $$ +begin + return x[1]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anyarray) RETURNS anyelement AS $$\nbegin\n return x[1];\nend$$ LANGUAGE plpgsql" +== 309 +-- truncate_limit: 100 +select f1(array[2,4]) as int, f1(array[4.5, 7.7]) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(ARRAY[2, 4]) AS \"int\", f1(ARRAY[4.5, 7.7]) AS num" +== 310 +-- truncate_limit: 100 +select f1(stavalues1) from pg_statistic +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(stavalues1) FROM pg_statistic" +== 311 +-- truncate_limit: 100 +-- fail, can't infer element type + +drop function f1(x anyarray) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(x anyarray)" +== 312 +-- truncate_limit: 100 +create function f1(x anyarray) returns anyarray as $$ +begin + return x; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anyarray) RETURNS anyarray AS $$\nbegin\n return x;\nend$$ LANGUAGE plpgsql" +== 313 +-- truncate_limit: 100 +select f1(array[2,4]) as int, f1(array[4.5, 7.7]) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(ARRAY[2, 4]) AS \"int\", f1(ARRAY[4.5, 7.7]) AS num" +== 314 +-- truncate_limit: 100 +select f1(stavalues1) from pg_statistic +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(stavalues1) FROM pg_statistic" +== 315 +-- truncate_limit: 100 +-- fail, can't infer element type + +drop function f1(x anyarray) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(x anyarray)" +== 316 +-- truncate_limit: 100 +-- fail, can't infer type: +create function f1(x anyelement) returns anyrange as $$ +begin + return array[x + 1, x + 2]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anyelement) RETURNS anyrange AS $$\nbegin\n return array[x + 1, x + 2];\nend$$..." +== 317 +-- truncate_limit: 100 +create function f1(x anyrange) returns anyarray as $$ +begin + return array[lower(x), upper(x)]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anyrange) RETURNS anyarray AS $$\nbegin\n return array[lower(x), upper(x)];\ne..." +== 318 +-- truncate_limit: 100 +select f1(int4range(42, 49)) as int, f1(float8range(4.5, 7.8)) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(int4range(42, 49)) AS \"int\", f1(float8range(4.5, 7.8)) AS num" +== 319 +-- truncate_limit: 100 +drop function f1(x anyrange) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(x anyrange)" +== 320 +-- truncate_limit: 100 +create function f1(x anycompatible, y anycompatible) returns anycompatiblearray as $$ +begin + return array[x, y]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anycompatible, y anycompatible) RETURNS anycompatiblearray AS $$\nbegin\n ret..." +== 321 +-- truncate_limit: 100 +select f1(2, 4) as int, f1(2, 4.5) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(2, 4) AS \"int\", f1(2, 4.5) AS num" +== 322 +-- truncate_limit: 100 +drop function f1(x anycompatible, y anycompatible) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(x anycompatible, y anycompatible)" +== 323 +-- truncate_limit: 100 +create function f1(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$ +begin + return array[lower(x), upper(x), y, z]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anycompatiblerange, y anycompatible, z anycompatible) RETURNS anycompatiblea..." +== 324 +-- truncate_limit: 100 +select f1(int4range(42, 49), 11, 2::smallint) as int, f1(float8range(4.5, 7.8), 7.8, 11::real) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 325 +-- truncate_limit: 100 +select f1(int4range(42, 49), 11, 4.5) as fail +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(int4range(42, 49), 11, 4.5) AS fail" +== 326 +-- truncate_limit: 100 +-- range type doesn't fit + +drop function f1(x anycompatiblerange, y anycompatible, z anycompatible) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(x anycompatiblerange, y anycompatible, z anycompatible)" +== 327 +-- truncate_limit: 100 +-- fail, can't infer type: +create function f1(x anycompatible) returns anycompatiblerange as $$ +begin + return array[x + 1, x + 2]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anycompatible) RETURNS anycompatiblerange AS $$\nbegin\n return array[x + 1, ..." +== 328 +-- truncate_limit: 100 +create function f1(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$ +begin + return x; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(x anycompatiblerange, y anycompatiblearray) RETURNS anycompatiblerange AS $$\nb..." +== 329 +-- truncate_limit: 100 +select f1(int4range(42, 49), array[11]) as int, f1(float8range(4.5, 7.8), array[7]) as num +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(int4range(42, 49), ARRAY[11]) AS \"int\", f1(float8range(4.5, 7.8), ARRAY[7]) AS num" +== 330 +-- truncate_limit: 100 +drop function f1(x anycompatiblerange, y anycompatiblearray) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(x anycompatiblerange, y anycompatiblearray)" +== 331 +-- truncate_limit: 100 +create function f1(a anyelement, b anyarray, + c anycompatible, d anycompatible, + OUT x anyarray, OUT y anycompatiblearray) +as $$ +begin + x := a || b; + y := array[c, d]; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(a anyelement, b anyarray, c anycompatible, d anycompatible, OUT x anyarray, OU..." +== 332 +-- truncate_limit: 100 +select x, pg_typeof(x), y, pg_typeof(y) + from f1(11, array[1, 2], 42, 34.5) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x), y, pg_typeof(y) FROM f1(11, ARRAY[1, 2], 42, 34.5)" +== 333 +-- truncate_limit: 100 +select x, pg_typeof(x), y, pg_typeof(y) + from f1(11, array[1, 2], point(1,2), point(3,4)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x), y, pg_typeof(y) FROM f1(11, ARRAY[1, 2], point(1, 2), point(3, 4))" +== 334 +-- truncate_limit: 100 +select x, pg_typeof(x), y, pg_typeof(y) + from f1(11, '{1,2}', point(1,2), '(3,4)') +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x), y, pg_typeof(y) FROM f1(11, '{1,2}', point(1, 2), '(3,4)')" +== 335 +-- truncate_limit: 100 +select x, pg_typeof(x), y, pg_typeof(y) + from f1(11, array[1, 2.2], 42, 34.5) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x), y, pg_typeof(y) FROM f1(11, ARRAY[1, 2.2], 42, 34.5)" +== 336 +-- truncate_limit: 100 +-- fail + +drop function f1(a anyelement, b anyarray, + c anycompatible, d anycompatible) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(a anyelement, b anyarray, c anycompatible, d anycompatible)" +== 337 +-- truncate_limit: 100 +|-- +-- Test handling of OUT parameters, including polymorphic cases. +-- Note that RETURN is optional with OUT params; we try both ways. +|-- + +-- wrong way to do it: +create function f1(in i int, out j int) returns int as $$ +begin + return i+1; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(IN i int, OUT j int) RETURNS int AS $$\nbegin\n return i+1;\nend$$ LANGUAGE plpgsql" +== 338 +-- truncate_limit: 100 +create function f1(in i int, out j int) as $$ +begin + j := i+1; + return; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(IN i int, OUT j int) AS $$\nbegin\n j := i+1;\n return;\nend$$ LANGUAGE plpgsql" +== 339 +-- truncate_limit: 100 +select f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(42)" +== 340 +-- truncate_limit: 100 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM f1(42)" +== 341 +-- truncate_limit: 100 +create or replace function f1(inout i int) as $$ +begin + i := i+1; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION f1(INOUT i int) AS $$\nbegin\n i := i+1;\nend$$ LANGUAGE plpgsql" +== 342 +-- truncate_limit: 100 +select f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(42)" +== 343 +-- truncate_limit: 100 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM f1(42)" +== 344 +-- truncate_limit: 100 +drop function f1(int) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(int)" +== 345 +-- truncate_limit: 100 +create function f1(in i int, out j int) returns setof int as $$ +begin + j := i+1; + return next; + j := i+2; + return next; + return; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(IN i int, OUT j int) RETURNS SETOF int AS $$\nbegin\n j := i+1;\n return next;\n..." +== 346 +-- truncate_limit: 100 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM f1(42)" +== 347 +-- truncate_limit: 100 +drop function f1(int) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(int)" +== 348 +-- truncate_limit: 100 +create function f1(in i int, out j int, out k text) as $$ +begin + j := i; + j := j+1; + k := 'foo'; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(IN i int, OUT j int, OUT k text) AS $$\nbegin\n j := i;\n j := j+1;\n k := 'foo..." +== 349 +-- truncate_limit: 100 +select f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1(42)" +== 350 +-- truncate_limit: 100 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM f1(42)" +== 351 +-- truncate_limit: 100 +drop function f1(int) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(int)" +== 352 +-- truncate_limit: 100 +create function f1(in i int, out j int, out k text) returns setof record as $$ +begin + j := i+1; + k := 'foo'; + return next; + j := j+1; + k := 'foot'; + return next; +end$$ language plpgsql +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1(IN i int, OUT j int, OUT k text) RETURNS SETOF record AS $$\nbegin\n j := i+1;\n..." +== 353 +-- truncate_limit: 100 +select * from f1(42) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM f1(42)" +== 354 +-- truncate_limit: 100 +drop function f1(int) +-- +FUNCTION: name="f1" function="f1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f1(int)" +== 355 +-- truncate_limit: 100 +create function duplic(in i anyelement, out j anyelement, out k anyarray) as $$ +begin + j := i; + k := array[j,j]; + return; +end$$ language plpgsql +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION duplic(IN i anyelement, OUT j anyelement, OUT k anyarray) AS $$\nbegin\n j := i;\n ..." +== 356 +-- truncate_limit: 100 +select * from duplic(42) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM duplic(42)" +== 357 +-- truncate_limit: 100 +select * from duplic('foo'::text) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM duplic('foo'::text)" +== 358 +-- truncate_limit: 100 +drop function duplic(anyelement) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION duplic(anyelement)" +== 359 +-- truncate_limit: 100 +create function duplic(in i anycompatiblerange, out j anycompatible, out k anycompatiblearray) as $$ +begin + j := lower(i); + k := array[lower(i),upper(i)]; + return; +end$$ language plpgsql +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION duplic(IN i anycompatiblerange, OUT j anycompatible, OUT k anycompatiblearray) AS..." +== 360 +-- truncate_limit: 100 +select * from duplic(int4range(42,49)) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM duplic(int4range(42, 49))" +== 361 +-- truncate_limit: 100 +select * from duplic(textrange('aaa', 'bbb')) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM duplic(textrange('aaa', 'bbb'))" +== 362 +-- truncate_limit: 100 +drop function duplic(anycompatiblerange) +-- +FUNCTION: name="duplic" function="duplic" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION duplic(anycompatiblerange)" +== 363 +-- truncate_limit: 100 +|-- +-- test PERFORM +|-- + +create table perform_test ( + a INT, + b INT +) +-- +TABLE: name="perform_test" schema="" table="perform_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE perform_test (a int, b int)" +== 364 +-- truncate_limit: 100 +create function perform_simple_func(int) returns boolean as ' +BEGIN + IF $1 < 20 THEN + INSERT INTO perform_test VALUES ($1, $1 + 10); + RETURN TRUE; + ELSE + RETURN FALSE; + END IF; +END;' language plpgsql +-- +FUNCTION: name="perform_simple_func" function="perform_simple_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION perform_simple_func(int) RETURNS boolean AS $$\nBEGIN\n\tIF $1 < 20 THEN\n\t\tINSERT IN..." +== 365 +-- truncate_limit: 100 +create function perform_test_func() returns void as ' +BEGIN + IF FOUND then + INSERT INTO perform_test VALUES (100, 100); + END IF; + + PERFORM perform_simple_func(5); + + IF FOUND then + INSERT INTO perform_test VALUES (100, 100); + END IF; + + PERFORM perform_simple_func(50); + + IF FOUND then + INSERT INTO perform_test VALUES (100, 100); + END IF; + + RETURN; +END;' language plpgsql +-- +FUNCTION: name="perform_test_func" function="perform_test_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION perform_test_func() RETURNS void AS $$\nBEGIN\n\tIF FOUND then\n\t\tINSERT INTO perform..." +== 366 +-- truncate_limit: 100 +SELECT perform_test_func() +-- +FUNCTION: name="perform_test_func" function="perform_test_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT perform_test_func()" +== 367 +-- truncate_limit: 100 +SELECT * FROM perform_test +-- +TABLE: name="perform_test" schema="" table="perform_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM perform_test" +== 368 +-- truncate_limit: 100 +drop table perform_test +-- +TABLE: name="perform_test" schema="" table="perform_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE perform_test" +== 369 +-- truncate_limit: 100 +|-- +-- Test proper snapshot handling in simple expressions +|-- + +create temp table users(login text, id serial) +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE users (login text, id serial)" +== 370 +-- truncate_limit: 100 +create function sp_id_user(a_login text) returns int as $$ +declare x int; +begin + select into x id from users where login = a_login; + if found then return x; end if; + return 0; +end$$ language plpgsql stable +-- +FUNCTION: name="sp_id_user" function="sp_id_user" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sp_id_user(a_login text) RETURNS int AS $$\ndeclare x int;\nbegin\n select into x i..." +== 371 +-- truncate_limit: 100 +insert into users values('user1') +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO users VALUES ('user1')" +== 372 +-- truncate_limit: 100 +select sp_id_user('user1') +-- +FUNCTION: name="sp_id_user" function="sp_id_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sp_id_user('user1')" +== 373 +-- truncate_limit: 100 +select sp_id_user('userx') +-- +FUNCTION: name="sp_id_user" function="sp_id_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sp_id_user('userx')" +== 374 +-- truncate_limit: 100 +create function sp_add_user(a_login text) returns int as $$ +declare my_id_user int; +begin + my_id_user = sp_id_user( a_login ); + IF my_id_user > 0 THEN + RETURN -1; -- error code for existing user + END IF; + INSERT INTO users ( login ) VALUES ( a_login ); + my_id_user = sp_id_user( a_login ); + IF my_id_user = 0 THEN + RETURN -2; -- error code for insertion failure + END IF; + RETURN my_id_user; +end$$ language plpgsql +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sp_add_user(a_login text) RETURNS int AS $$\ndeclare my_id_user int;\nbegin\n my_id..." +== 375 +-- truncate_limit: 100 +select sp_add_user('user1') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sp_add_user('user1')" +== 376 +-- truncate_limit: 100 +select sp_add_user('user2') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sp_add_user('user2')" +== 377 +-- truncate_limit: 100 +select sp_add_user('user2') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sp_add_user('user2')" +== 378 +-- truncate_limit: 100 +select sp_add_user('user3') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sp_add_user('user3')" +== 379 +-- truncate_limit: 100 +select sp_add_user('user3') +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sp_add_user('user3')" +== 380 +-- truncate_limit: 100 +drop function sp_add_user(text) +-- +FUNCTION: name="sp_add_user" function="sp_add_user" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION sp_add_user(text)" +== 381 +-- truncate_limit: 100 +drop function sp_id_user(text) +-- +FUNCTION: name="sp_id_user" function="sp_id_user" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION sp_id_user(text)" +== 382 +-- truncate_limit: 100 +|-- +-- tests for refcursors +|-- +create table rc_test (a int, b int) +-- +TABLE: name="rc_test" schema="" table="rc_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rc_test (a int, b int)" +== 383 +-- truncate_limit: 100 +copy rc_test from stdin +-- +TABLE: name="rc_test" schema="" table="rc_test" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY rc_test FROM STDIN" +== 384 +-- truncate_limit: 100 +create function return_unnamed_refcursor() returns refcursor as $$ +declare + rc refcursor; +begin + open rc for select a from rc_test; + return rc; +end +$$ language plpgsql +-- +FUNCTION: name="return_unnamed_refcursor" function="return_unnamed_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION return_unnamed_refcursor() RETURNS refcursor AS $$\ndeclare\n rc refcursor;\nbegi..." +== 385 +-- truncate_limit: 100 +create function use_refcursor(rc refcursor) returns int as $$ +declare + rc refcursor; + x record; +begin + rc := return_unnamed_refcursor(); + fetch next from rc into x; + return x.a; +end +$$ language plpgsql +-- +FUNCTION: name="use_refcursor" function="use_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION use_refcursor(rc refcursor) RETURNS int AS $$\ndeclare\n rc refcursor;\n x rec..." +== 386 +-- truncate_limit: 100 +select use_refcursor(return_unnamed_refcursor()) +-- +FUNCTION: name="use_refcursor" function="use_refcursor" schema="" ctx=Call +FUNCTION: name="return_unnamed_refcursor" function="return_unnamed_refcursor" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT use_refcursor(return_unnamed_refcursor())" +== 387 +-- truncate_limit: 100 +create function return_refcursor(rc refcursor) returns refcursor as $$ +begin + open rc for select a from rc_test; + return rc; +end +$$ language plpgsql +-- +FUNCTION: name="return_refcursor" function="return_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION return_refcursor(rc refcursor) RETURNS refcursor AS $$\nbegin\n open rc for sele..." +== 388 +-- truncate_limit: 100 +create function refcursor_test1(refcursor) returns refcursor as $$ +begin + perform return_refcursor($1); + return $1; +end +$$ language plpgsql +-- +FUNCTION: name="refcursor_test1" function="refcursor_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION refcursor_test1(refcursor) RETURNS refcursor AS $$\nbegin\n perform return_refcu..." +== 389 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 390 +-- truncate_limit: 100 +select refcursor_test1('test1') +-- +FUNCTION: name="refcursor_test1" function="refcursor_test1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT refcursor_test1('test1')" +== 391 +-- truncate_limit: 100 +fetch next in test1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH test1" +== 392 +-- truncate_limit: 100 +select refcursor_test1('test2') +-- +FUNCTION: name="refcursor_test1" function="refcursor_test1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT refcursor_test1('test2')" +== 393 +-- truncate_limit: 100 +fetch all from test2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL test2" +== 394 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 395 +-- truncate_limit: 100 +-- should fail +fetch next from test1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH test1" +== 396 +-- truncate_limit: 100 +create function refcursor_test2(int, int) returns boolean as $$ +declare + c1 cursor (param1 int, param2 int) for select * from rc_test where a > param1 and b > param2; + nonsense record; +begin + open c1($1, $2); + fetch c1 into nonsense; + close c1; + if found then + return true; + else + return false; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="refcursor_test2" function="refcursor_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION refcursor_test2(int, int) RETURNS boolean AS $$\ndeclare\n c1 cursor (param1 int..." +== 397 +-- truncate_limit: 100 +select refcursor_test2(20000, 20000) as "Should be false", + refcursor_test2(20, 20) as "Should be true" +-- +FUNCTION: name="refcursor_test2" function="refcursor_test2" schema="" ctx=Call +FUNCTION: name="refcursor_test2" function="refcursor_test2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 398 +-- truncate_limit: 100 +-- should fail +create function constant_refcursor() returns refcursor as $$ +declare + rc constant refcursor; +begin + open rc for select a from rc_test; + return rc; +end +$$ language plpgsql +-- +FUNCTION: name="constant_refcursor" function="constant_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION constant_refcursor() RETURNS refcursor AS $$\ndeclare\n rc constant refcursor;\nb..." +== 399 +-- truncate_limit: 100 +select constant_refcursor() +-- +FUNCTION: name="constant_refcursor" function="constant_refcursor" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT constant_refcursor()" +== 400 +-- truncate_limit: 100 +-- but it's okay like this +create or replace function constant_refcursor() returns refcursor as $$ +declare + rc constant refcursor := 'my_cursor_name'; +begin + open rc for select a from rc_test; + return rc; +end +$$ language plpgsql +-- +FUNCTION: name="constant_refcursor" function="constant_refcursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION constant_refcursor() RETURNS refcursor AS $$\ndeclare\n rc constant r..." +== 401 +-- truncate_limit: 100 +select constant_refcursor() +-- +FUNCTION: name="constant_refcursor" function="constant_refcursor" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT constant_refcursor()" +== 402 +-- truncate_limit: 100 +|-- +-- tests for cursors with named parameter arguments +|-- +create function namedparmcursor_test1(int, int) returns boolean as $$ +declare + c1 cursor (param1 int, param12 int) for select * from rc_test where a > param1 and b > param12; + nonsense record; +begin + open c1(param12 := $2, param1 := $1); + fetch c1 into nonsense; + close c1; + if found then + return true; + else + return false; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test1" function="namedparmcursor_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test1(int, int) RETURNS boolean AS $$\ndeclare\n c1 cursor (para..." +== 403 +-- truncate_limit: 100 +select namedparmcursor_test1(20000, 20000) as "Should be false", + namedparmcursor_test1(20, 20) as "Should be true" +-- +FUNCTION: name="namedparmcursor_test1" function="namedparmcursor_test1" schema="" ctx=Call +FUNCTION: name="namedparmcursor_test1" function="namedparmcursor_test1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 404 +-- truncate_limit: 100 +-- mixing named and positional argument notations +create function namedparmcursor_test2(int, int) returns boolean as $$ +declare + c1 cursor (param1 int, param2 int) for select * from rc_test where a > param1 and b > param2; + nonsense record; +begin + open c1(param1 := $1, $2); + fetch c1 into nonsense; + close c1; + if found then + return true; + else + return false; + end if; +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test2" function="namedparmcursor_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test2(int, int) RETURNS boolean AS $$\ndeclare\n c1 cursor (para..." +== 405 +-- truncate_limit: 100 +select namedparmcursor_test2(20, 20) +-- +FUNCTION: name="namedparmcursor_test2" function="namedparmcursor_test2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT namedparmcursor_test2(20, 20)" +== 406 +-- truncate_limit: 100 +-- mixing named and positional: param2 is given twice, once in named notation +-- and second time in positional notation. Should throw an error at parse time +create function namedparmcursor_test3() returns void as $$ +declare + c1 cursor (param1 int, param2 int) for select * from rc_test where a > param1 and b > param2; +begin + open c1(param2 := 20, 21); +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test3" function="namedparmcursor_test3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test3() RETURNS void AS $$\ndeclare\n c1 cursor (param1 int, par..." +== 407 +-- truncate_limit: 100 +-- mixing named and positional: same as previous test, but param1 is duplicated +create function namedparmcursor_test4() returns void as $$ +declare + c1 cursor (param1 int, param2 int) for select * from rc_test where a > param1 and b > param2; +begin + open c1(20, param1 := 21); +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test4" function="namedparmcursor_test4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test4() RETURNS void AS $$\ndeclare\n c1 cursor (param1 int, par..." +== 408 +-- truncate_limit: 100 +-- duplicate named parameter, should throw an error at parse time +create function namedparmcursor_test5() returns void as $$ +declare + c1 cursor (p1 int, p2 int) for + select * from tenk1 where thousand = p1 and tenthous = p2; +begin + open c1 (p2 := 77, p2 := 42); +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test5" function="namedparmcursor_test5" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test5() RETURNS void AS $$\ndeclare\n c1 cursor (p1 int, p2 int) f..." +== 409 +-- truncate_limit: 100 +-- not enough parameters, should throw an error at parse time +create function namedparmcursor_test6() returns void as $$ +declare + c1 cursor (p1 int, p2 int) for + select * from tenk1 where thousand = p1 and tenthous = p2; +begin + open c1 (p2 := 77); +end +$$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test6" function="namedparmcursor_test6" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test6() RETURNS void AS $$\ndeclare\n c1 cursor (p1 int, p2 int) f..." +== 410 +-- truncate_limit: 100 +-- division by zero runtime error, the context given in the error message +-- should be sensible +create function namedparmcursor_test7() returns void as $$ +declare + c1 cursor (p1 int, p2 int) for + select * from tenk1 where thousand = p1 and tenthous = p2; +begin + open c1 (p2 := 77, p1 := 42/0); +end $$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test7" function="namedparmcursor_test7" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test7() RETURNS void AS $$\ndeclare\n c1 cursor (p1 int, p2 int) f..." +== 411 +-- truncate_limit: 100 +select namedparmcursor_test7() +-- +FUNCTION: name="namedparmcursor_test7" function="namedparmcursor_test7" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT namedparmcursor_test7()" +== 412 +-- truncate_limit: 100 +-- check that line comments work correctly within the argument list +-- (this used to require a special hack in the code; it no longer does, +-- but let's keep the test anyway) +create function namedparmcursor_test8() returns int4 as $$ +declare + c1 cursor (p1 int, p2 int) for + select count(*) from tenk1 where thousand = p1 and tenthous = p2; + n int4; +begin + open c1 (77 -- test + , 42); + fetch c1 into n; + return n; +end $$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test8" function="namedparmcursor_test8" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test8() RETURNS int4 AS $$\ndeclare\n c1 cursor (p1 int, p2 int) f..." +== 413 +-- truncate_limit: 100 +select namedparmcursor_test8() +-- +FUNCTION: name="namedparmcursor_test8" function="namedparmcursor_test8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT namedparmcursor_test8()" +== 414 +-- truncate_limit: 100 +-- cursor parameter name can match plpgsql variable or unreserved keyword +create function namedparmcursor_test9(p1 int) returns int4 as $$ +declare + c1 cursor (p1 int, p2 int, debug int) for + select count(*) from tenk1 where thousand = p1 and tenthous = p2 + and four = debug; + p2 int4 := 1006; + n int4; +begin + open c1 (p1 := p1, p2 := p2, debug := 2); + fetch c1 into n; + return n; +end $$ language plpgsql +-- +FUNCTION: name="namedparmcursor_test9" function="namedparmcursor_test9" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namedparmcursor_test9(p1 int) RETURNS int4 AS $$\ndeclare\n c1 cursor (p1 int, p2 ..." +== 415 +-- truncate_limit: 100 +select namedparmcursor_test9(6) +-- +FUNCTION: name="namedparmcursor_test9" function="namedparmcursor_test9" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT namedparmcursor_test9(6)" +== 416 +-- truncate_limit: 100 +|-- +-- tests for "raise" processing +|-- +create function raise_test1(int) returns int as $$ +begin + raise notice 'This message has too many parameters!', $1; + return $1; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test1" function="raise_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION raise_test1(int) RETURNS int AS $$\nbegin\n raise notice 'This message has too m..." +== 417 +-- truncate_limit: 100 +create function raise_test2(int) returns int as $$ +begin + raise notice 'This message has too few parameters: %, %, %', $1, $1; + return $1; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test2" function="raise_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION raise_test2(int) RETURNS int AS $$\nbegin\n raise notice 'This message has too f..." +== 418 +-- truncate_limit: 100 +create function raise_test3(int) returns int as $$ +begin + raise notice 'This message has no parameters (despite having %% signs in it)!'; + return $1; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test3" function="raise_test3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION raise_test3(int) RETURNS int AS $$\nbegin\n raise notice 'This message has no pa..." +== 419 +-- truncate_limit: 100 +select raise_test3(1) +-- +FUNCTION: name="raise_test3" function="raise_test3" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test3(1)" +== 420 +-- truncate_limit: 100 +-- Test re-RAISE inside a nested exception block. This case is allowed +-- by Oracle's PL/SQL but was handled differently by PG before 9.1. + +CREATE FUNCTION reraise_test() RETURNS void AS $$ +BEGIN + BEGIN + RAISE syntax_error; + EXCEPTION + WHEN syntax_error THEN + BEGIN + raise notice 'exception % thrown in inner block, reraising', sqlerrm; + RAISE; + EXCEPTION + WHEN OTHERS THEN + raise notice 'RIGHT - exception % caught in inner block', sqlerrm; + END; + END; +EXCEPTION + WHEN OTHERS THEN + raise notice 'WRONG - exception % caught in outer block', sqlerrm; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="reraise_test" function="reraise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION reraise_test() RETURNS void AS $$\nBEGIN\n BEGIN\n RAISE syntax_error;\n EX..." +== 421 +-- truncate_limit: 100 +SELECT reraise_test() +-- +FUNCTION: name="reraise_test" function="reraise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reraise_test()" +== 422 +-- truncate_limit: 100 +|-- +-- reject function definitions that contain malformed SQL queries at +-- compile-time, where possible +|-- +create function bad_sql1() returns int as $$ +declare a int; +begin + a := 5; + Johnny Yuma; + a := 10; + return a; +end$$ language plpgsql +-- +FUNCTION: name="bad_sql1" function="bad_sql1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bad_sql1() RETURNS int AS $$\ndeclare a int;\nbegin\n a := 5;\n Johnny Yuma;\n ..." +== 423 +-- truncate_limit: 100 +create function bad_sql2() returns int as $$ +declare r record; +begin + for r in select I fought the law, the law won LOOP + raise notice 'in loop'; + end loop; + return 5; +end;$$ language plpgsql +-- +FUNCTION: name="bad_sql2" function="bad_sql2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bad_sql2() RETURNS int AS $$\ndeclare r record;\nbegin\n for r in select I fought..." +== 424 +-- truncate_limit: 100 +-- a RETURN expression is mandatory, except for void-returning +-- functions, where it is not allowed +create function missing_return_expr() returns int as $$ +begin + return ; +end;$$ language plpgsql +-- +FUNCTION: name="missing_return_expr" function="missing_return_expr" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION missing_return_expr() RETURNS int AS $$\nbegin\n return ;\nend;$$ LANGUAGE plpgsql" +== 425 +-- truncate_limit: 100 +create function void_return_expr() returns void as $$ +begin + return 5; +end;$$ language plpgsql +-- +FUNCTION: name="void_return_expr" function="void_return_expr" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION void_return_expr() RETURNS void AS $$\nbegin\n return 5;\nend;$$ LANGUAGE plpgsql" +== 426 +-- truncate_limit: 100 +-- VOID functions are allowed to omit RETURN +create function void_return_expr() returns void as $$ +begin + perform 2+2; +end;$$ language plpgsql +-- +FUNCTION: name="void_return_expr" function="void_return_expr" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION void_return_expr() RETURNS void AS $$\nbegin\n perform 2+2;\nend;$$ LANGUAGE plpgsql" +== 427 +-- truncate_limit: 100 +select void_return_expr() +-- +FUNCTION: name="void_return_expr" function="void_return_expr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT void_return_expr()" +== 428 +-- truncate_limit: 100 +-- but ordinary functions are not +create function missing_return_expr() returns int as $$ +begin + perform 2+2; +end;$$ language plpgsql +-- +FUNCTION: name="missing_return_expr" function="missing_return_expr" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION missing_return_expr() RETURNS int AS $$\nbegin\n perform 2+2;\nend;$$ LANGUAGE pl..." +== 429 +-- truncate_limit: 100 +select missing_return_expr() +-- +FUNCTION: name="missing_return_expr" function="missing_return_expr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT missing_return_expr()" +== 430 +-- truncate_limit: 100 +drop function void_return_expr() +-- +FUNCTION: name="void_return_expr" function="void_return_expr" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION void_return_expr()" +== 431 +-- truncate_limit: 100 +drop function missing_return_expr() +-- +FUNCTION: name="missing_return_expr" function="missing_return_expr" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION missing_return_expr()" +== 432 +-- truncate_limit: 100 +|-- +-- EXECUTE ... INTO test +|-- + +create table eifoo (i integer, y integer) +-- +TABLE: name="eifoo" schema="" table="eifoo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE eifoo (i int, y int)" +== 433 +-- truncate_limit: 100 +create type eitype as (i integer, y integer) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE eitype AS (i int, y int)" +== 434 +-- truncate_limit: 100 +create or replace function execute_into_test(varchar) returns record as $$ +declare + _r record; + _rt eifoo%rowtype; + _v eitype; + i int; + j int; + k int; +begin + execute 'insert into '||$1||' values(10,15)'; + execute 'select (row).* from (select row(10,1)::eifoo) s' into _r; + raise notice '% %', _r.i, _r.y; + execute 'select * from '||$1||' limit 1' into _rt; + raise notice '% %', _rt.i, _rt.y; + execute 'select *, 20 from '||$1||' limit 1' into i, j, k; + raise notice '% % %', i, j, k; + execute 'select 1,2' into _v; + return _v; +end; $$ language plpgsql +-- +FUNCTION: name="execute_into_test" function="execute_into_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION execute_into_test(varchar) RETURNS record AS $$\ndeclare\n _r record;..." +== 435 +-- truncate_limit: 100 +select execute_into_test('eifoo') +-- +FUNCTION: name="execute_into_test" function="execute_into_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT execute_into_test('eifoo')" +== 436 +-- truncate_limit: 100 +drop table eifoo cascade +-- +TABLE: name="eifoo" schema="" table="eifoo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE eifoo CASCADE" +== 437 +-- truncate_limit: 100 +drop type eitype cascade +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE eitype CASCADE" +== 438 +-- truncate_limit: 100 +|-- +-- SQLSTATE and SQLERRM test +|-- + +create function excpt_test1() returns void as $$ +begin + raise notice '% %', sqlstate, sqlerrm; +end; $$ language plpgsql +-- +FUNCTION: name="excpt_test1" function="excpt_test1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION excpt_test1() RETURNS void AS $$\nbegin\n raise notice '% %', sqlstate, sqlerrm;..." +== 439 +-- truncate_limit: 100 +-- should fail: SQLSTATE and SQLERRM are only in defined EXCEPTION +-- blocks +select excpt_test1() +-- +FUNCTION: name="excpt_test1" function="excpt_test1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT excpt_test1()" +== 440 +-- truncate_limit: 100 +create function excpt_test2() returns void as $$ +begin + begin + begin + raise notice '% %', sqlstate, sqlerrm; + end; + end; +end; $$ language plpgsql +-- +FUNCTION: name="excpt_test2" function="excpt_test2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION excpt_test2() RETURNS void AS $$\nbegin\n begin\n begin\n raise ..." +== 441 +-- truncate_limit: 100 +-- should fail +select excpt_test2() +-- +FUNCTION: name="excpt_test2" function="excpt_test2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT excpt_test2()" +== 442 +-- truncate_limit: 100 +create function excpt_test3() returns void as $$ +begin + begin + raise exception 'user exception'; + exception when others then + raise notice 'caught exception % %', sqlstate, sqlerrm; + begin + raise notice '% %', sqlstate, sqlerrm; + perform 10/0; + exception + when substring_error then + -- this exception handler shouldn't be invoked + raise notice 'unexpected exception: % %', sqlstate, sqlerrm; + when division_by_zero then + raise notice 'caught exception % %', sqlstate, sqlerrm; + end; + raise notice '% %', sqlstate, sqlerrm; + end; +end; $$ language plpgsql +-- +FUNCTION: name="excpt_test3" function="excpt_test3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION excpt_test3() RETURNS void AS $$\nbegin\n begin\n raise exception 'user ex..." +== 443 +-- truncate_limit: 100 +select excpt_test3() +-- +FUNCTION: name="excpt_test3" function="excpt_test3" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT excpt_test3()" +== 444 +-- truncate_limit: 100 +create function excpt_test4() returns text as $$ +begin + begin perform 1/0; + exception when others then return sqlerrm; end; +end; $$ language plpgsql +-- +FUNCTION: name="excpt_test4" function="excpt_test4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION excpt_test4() RETURNS text AS $$\nbegin\n\tbegin perform 1/0;\n\texception when others..." +== 445 +-- truncate_limit: 100 +select excpt_test4() +-- +FUNCTION: name="excpt_test4" function="excpt_test4" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT excpt_test4()" +== 446 +-- truncate_limit: 100 +drop function excpt_test1() +-- +FUNCTION: name="excpt_test1" function="excpt_test1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION excpt_test1()" +== 447 +-- truncate_limit: 100 +drop function excpt_test2() +-- +FUNCTION: name="excpt_test2" function="excpt_test2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION excpt_test2()" +== 448 +-- truncate_limit: 100 +drop function excpt_test3() +-- +FUNCTION: name="excpt_test3" function="excpt_test3" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION excpt_test3()" +== 449 +-- truncate_limit: 100 +drop function excpt_test4() +-- +FUNCTION: name="excpt_test4" function="excpt_test4" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION excpt_test4()" +== 450 +-- truncate_limit: 100 +-- parameters of raise stmt can be expressions +create function raise_exprs() returns void as $$ +declare + a integer[] = '{10,20,30}'; + c varchar = 'xyz'; + i integer; +begin + i := 2; + raise notice '%; %; %; %; %; %', a, a[i], c, (select c || 'abc'), row(10,'aaa',NULL,30), NULL; +end;$$ language plpgsql +-- +FUNCTION: name="raise_exprs" function="raise_exprs" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION raise_exprs() RETURNS void AS $$\ndeclare\n a integer[] = '{10,20,30}';\n c va..." +== 451 +-- truncate_limit: 100 +select raise_exprs() +-- +FUNCTION: name="raise_exprs" function="raise_exprs" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_exprs()" +== 452 +-- truncate_limit: 100 +drop function raise_exprs() +-- +FUNCTION: name="raise_exprs" function="raise_exprs" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION raise_exprs()" +== 453 +-- truncate_limit: 100 +-- regression test: verify that multiple uses of same plpgsql datum within +-- a SQL command all get mapped to the same $n parameter. The return value +-- of the SELECT is not important, we only care that it doesn't fail with +-- a complaint about an ungrouped column reference. +create function multi_datum_use(p1 int) returns bool as $$ +declare + x int; + y int; +begin + select into x,y unique1/p1, unique1/$1 from tenk1 group by unique1/p1; + return x = y; +end$$ language plpgsql +-- +FUNCTION: name="multi_datum_use" function="multi_datum_use" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION multi_datum_use(p1 int) RETURNS bool AS $$\ndeclare\n x int;\n y int;\nbegin\n sele..." +== 454 +-- truncate_limit: 100 +select multi_datum_use(42) +-- +FUNCTION: name="multi_datum_use" function="multi_datum_use" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT multi_datum_use(42)" +== 455 +-- truncate_limit: 100 +|-- +-- Test STRICT limiter in both planned and EXECUTE invocations. +-- Note that a data-modifying query is quasi strict (disallow multi rows) +-- by default in the planned case, but not in EXECUTE. +|-- + +create temp table foo (f1 int, f2 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (f1 int, f2 int)" +== 456 +-- truncate_limit: 100 +insert into foo values (1,2), (3,4) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (1, 2), (3, 4)" +== 457 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should work + insert into foo values(5,6) returning * into x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should wo..." +== 458 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 459 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail due to implicit strict + insert into foo values(7,8),(9,10) returning * into x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should fa..." +== 460 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 461 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should work + execute 'insert into foo values(5,6) returning *' into x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should wo..." +== 462 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 463 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- this should work since EXECUTE isn't as picky + execute 'insert into foo values(7,8),(9,10) returning *' into x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- this shou..." +== 464 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 465 +-- truncate_limit: 100 +select * from foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 466 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should work + select * from foo where f1 = 3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should wo..." +== 467 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 468 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail, no rows + select * from foo where f1 = 0 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should fa..." +== 469 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 470 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail, too many rows + select * from foo where f1 > 3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should fa..." +== 471 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 472 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should work + execute 'select * from foo where f1 = 3' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should wo..." +== 473 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 474 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail, no rows + execute 'select * from foo where f1 = 0' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should fa..." +== 475 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 476 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- should fail, too many rows + execute 'select * from foo where f1 > 3' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- should fa..." +== 477 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 478 +-- truncate_limit: 100 +drop function stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION stricttest()" +== 479 +-- truncate_limit: 100 +-- test printing parameters after failure due to STRICT + +set plpgsql.print_strict_params to true +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.print_strict_params\" TO TRUE" +== 480 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare +x record; +p1 int := 2; +p3 text := 'foo'; +begin + -- no rows + select * from foo where f1 = p1 and f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare\nx record;\np1 int := 2;\np3 text..." +== 481 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 482 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare +x record; +p1 int := 2; +p3 text := $a$'Valame Dios!' dijo Sancho; 'no le dije yo a vuestra merced que mirase bien lo que hacia?'$a$; +begin + -- no rows + select * from foo where f1 = p1 and f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare\nx record;\np1 int := 2;\np3 text..." +== 483 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 484 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare +x record; +p1 int := 2; +p3 text := 'foo'; +begin + -- too many rows + select * from foo where f1 > p1 or f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare\nx record;\np1 int := 2;\np3 text..." +== 485 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 486 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- too many rows, no params + select * from foo where f1 > 3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- too many ..." +== 487 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 488 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- no rows + execute 'select * from foo where f1 = $1 or f1::text = $2' using 0, 'foo' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- no rows\n ..." +== 489 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 490 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- too many rows + execute 'select * from foo where f1 > $1' using 1 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- too many ..." +== 491 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 492 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +declare x record; +begin + -- too many rows, no parameters + execute 'select * from foo where f1 > 3' into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\ndeclare x record;\nbegin\n -- too many ..." +== 493 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 494 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +-- override the global +#print_strict_params off +declare +x record; +p1 int := 2; +p3 text := 'foo'; +begin + -- too many rows + select * from foo where f1 > p1 or f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\n-- override the global\n#print_strict_p..." +== 495 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 496 +-- truncate_limit: 100 +reset plpgsql.print_strict_params +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"plpgsql.print_strict_params\"" +== 497 +-- truncate_limit: 100 +create or replace function stricttest() returns void as $$ +-- override the global +#print_strict_params on +declare +x record; +p1 int := 2; +p3 text := 'foo'; +begin + -- too many rows + select * from foo where f1 > p1 or f1::text = p3 into strict x; + raise notice 'x.f1 = %, x.f2 = %', x.f1, x.f2; +end$$ language plpgsql +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stricttest() RETURNS void AS $$\n-- override the global\n#print_strict_p..." +== 498 +-- truncate_limit: 100 +select stricttest() +-- +FUNCTION: name="stricttest" function="stricttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stricttest()" +== 499 +-- truncate_limit: 100 +-- test warnings and errors +set plpgsql.extra_warnings to 'all' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_warnings\" TO \"all\"" +== 500 +-- truncate_limit: 100 +set plpgsql.extra_warnings to 'none' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_warnings\" TO \"none\"" +== 501 +-- truncate_limit: 100 +set plpgsql.extra_errors to 'all' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_errors\" TO \"all\"" +== 502 +-- truncate_limit: 100 +set plpgsql.extra_errors to 'none' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_errors\" TO \"none\"" +== 503 +-- truncate_limit: 100 +-- test warnings when shadowing a variable + +set plpgsql.extra_warnings to 'shadowed_variables' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_warnings\" TO shadowed_variables" +== 504 +-- truncate_limit: 100 +-- simple shadowing of input and output parameters +create or replace function shadowtest(in1 int) + returns table (out1 int) as $$ +declare +in1 int; +out1 int; +begin +end +$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION shadowtest(in1 int) RETURNS TABLE (out1 int) AS $$\ndeclare\nin1 int;\nou..." +== 505 +-- truncate_limit: 100 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT shadowtest(1)" +== 506 +-- truncate_limit: 100 +set plpgsql.extra_warnings to 'shadowed_variables' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_warnings\" TO shadowed_variables" +== 507 +-- truncate_limit: 100 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT shadowtest(1)" +== 508 +-- truncate_limit: 100 +create or replace function shadowtest(in1 int) + returns table (out1 int) as $$ +declare +in1 int; +out1 int; +begin +end +$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION shadowtest(in1 int) RETURNS TABLE (out1 int) AS $$\ndeclare\nin1 int;\nou..." +== 509 +-- truncate_limit: 100 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT shadowtest(1)" +== 510 +-- truncate_limit: 100 +drop function shadowtest(int) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION shadowtest(int)" +== 511 +-- truncate_limit: 100 +-- shadowing in a second DECLARE block +create or replace function shadowtest() + returns void as $$ +declare +f1 int; +begin + declare + f1 int; + begin + end; +end$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION shadowtest() RETURNS void AS $$\ndeclare\nf1 int;\nbegin\n\tdeclare\n\tf1 int..." +== 512 +-- truncate_limit: 100 +drop function shadowtest() +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION shadowtest()" +== 513 +-- truncate_limit: 100 +-- several levels of shadowing +create or replace function shadowtest(in1 int) + returns void as $$ +declare +in1 int; +begin + declare + in1 int; + begin + end; +end$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION shadowtest(in1 int) RETURNS void AS $$\ndeclare\nin1 int;\nbegin\n\tdeclare..." +== 514 +-- truncate_limit: 100 +drop function shadowtest(int) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION shadowtest(int)" +== 515 +-- truncate_limit: 100 +-- shadowing in cursor definitions +create or replace function shadowtest() + returns void as $$ +declare +f1 int; +c1 cursor (f1 int) for select 1; +begin +end$$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION shadowtest() RETURNS void AS $$\ndeclare\nf1 int;\nc1 cursor (f1 int) for..." +== 516 +-- truncate_limit: 100 +drop function shadowtest() +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION shadowtest()" +== 517 +-- truncate_limit: 100 +-- test errors when shadowing a variable + +set plpgsql.extra_errors to 'shadowed_variables' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_errors\" TO shadowed_variables" +== 518 +-- truncate_limit: 100 +create or replace function shadowtest(f1 int) + returns boolean as $$ +declare f1 int; begin return 1; end $$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION shadowtest(f1 int) RETURNS boolean AS $$\ndeclare f1 int; begin return ..." +== 519 +-- truncate_limit: 100 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT shadowtest(1)" +== 520 +-- truncate_limit: 100 +reset plpgsql.extra_errors +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"plpgsql.extra_errors\"" +== 521 +-- truncate_limit: 100 +reset plpgsql.extra_warnings +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"plpgsql.extra_warnings\"" +== 522 +-- truncate_limit: 100 +create or replace function shadowtest(f1 int) + returns boolean as $$ +declare f1 int; begin return 1; end $$ language plpgsql +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION shadowtest(f1 int) RETURNS boolean AS $$\ndeclare f1 int; begin return ..." +== 523 +-- truncate_limit: 100 +select shadowtest(1) +-- +FUNCTION: name="shadowtest" function="shadowtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT shadowtest(1)" +== 524 +-- truncate_limit: 100 +-- runtime extra checks +set plpgsql.extra_warnings to 'too_many_rows' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_warnings\" TO too_many_rows" +== 525 +-- truncate_limit: 100 +do $$ +declare x int; +begin + select v from generate_series(1,2) g(v) into x; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare x int;\nbegin\n select v from generate_series(1,2) g(v) into x;\nend;\n$$" +== 526 +-- truncate_limit: 100 +set plpgsql.extra_errors to 'too_many_rows' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_errors\" TO too_many_rows" +== 527 +-- truncate_limit: 100 +do $$ +declare x int; +begin + select v from generate_series(1,2) g(v) into x; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare x int;\nbegin\n select v from generate_series(1,2) g(v) into x;\nend;\n$$" +== 528 +-- truncate_limit: 100 +reset plpgsql.extra_errors +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"plpgsql.extra_errors\"" +== 529 +-- truncate_limit: 100 +reset plpgsql.extra_warnings +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"plpgsql.extra_warnings\"" +== 530 +-- truncate_limit: 100 +set plpgsql.extra_warnings to 'strict_multi_assignment' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_warnings\" TO strict_multi_assignment" +== 531 +-- truncate_limit: 100 +do $$ +declare + x int; + y int; +begin + select 1 into x, y; + select 1,2 into x, y; + select 1,2,3 into x, y; +end +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare\n x int;\n y int;\nbegin\n select 1 into x, y;\n select 1,2 into x, y;\n select 1,2,..." +== 532 +-- truncate_limit: 100 +set plpgsql.extra_errors to 'strict_multi_assignment' +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.extra_errors\" TO strict_multi_assignment" +== 533 +-- truncate_limit: 100 +do $$ +declare + x int; + y int; +begin + select 1 into x, y; + select 1,2 into x, y; + select 1,2,3 into x, y; +end +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare\n x int;\n y int;\nbegin\n select 1 into x, y;\n select 1,2 into x, y;\n select 1,2,..." +== 534 +-- truncate_limit: 100 +create table test_01(a int, b int, c int) +-- +TABLE: name="test_01" schema="" table="test_01" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_01 (a int, b int, c int)" +== 535 +-- truncate_limit: 100 +alter table test_01 drop column a +-- +TABLE: name="test_01" schema="" table="test_01" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_01 DROP a" +== 536 +-- truncate_limit: 100 +-- the check is active only when source table is not empty +insert into test_01 values(10,20) +-- +TABLE: name="test_01" schema="" table="test_01" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_01 VALUES (10, 20)" +== 537 +-- truncate_limit: 100 +do $$ +declare + x int; + y int; +begin + select * from test_01 into x, y; -- should be ok + raise notice 'ok'; + select * from test_01 into x; -- should to fail +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare\n x int;\n y int;\nbegin\n select * from test_01 into x, y; -- should be ok\n raise ..." +== 538 +-- truncate_limit: 100 +do $$ +declare + t test_01; +begin + select 1, 2 into t; -- should be ok + raise notice 'ok'; + select 1, 2, 3 into t; -- should fail; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare\n t test_01;\nbegin\n select 1, 2 into t; -- should be ok\n raise notice 'ok';\n se..." +== 539 +-- truncate_limit: 100 +do $$ +declare + t test_01; +begin + select 1 into t; -- should fail; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare\n t test_01;\nbegin\n select 1 into t; -- should fail;\nend;\n$$" +== 540 +-- truncate_limit: 100 +drop table test_01 +-- +TABLE: name="test_01" schema="" table="test_01" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_01" +== 541 +-- truncate_limit: 100 +reset plpgsql.extra_errors +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"plpgsql.extra_errors\"" +== 542 +-- truncate_limit: 100 +reset plpgsql.extra_warnings +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"plpgsql.extra_warnings\"" +== 543 +-- truncate_limit: 100 +-- test scrollable cursor support + +create function sc_test() returns setof integer as $$ +declare + c scroll cursor for select f1 from int4_tbl; + x integer; +begin + open c; + fetch last from c into x; + while found loop + return next x; + fetch prior from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sc_test() RETURNS SETOF int AS $$\ndeclare\n c scroll cursor for select f1 from in..." +== 544 +-- truncate_limit: 100 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sc_test()" +== 545 +-- truncate_limit: 100 +create or replace function sc_test() returns setof integer as $$ +declare + c no scroll cursor for select f1 from int4_tbl; + x integer; +begin + open c; + fetch last from c into x; + while found loop + return next x; + fetch prior from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION sc_test() RETURNS SETOF int AS $$\ndeclare\n c no scroll cursor for sel..." +== 546 +-- truncate_limit: 100 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sc_test()" +== 547 +-- truncate_limit: 100 +-- fails because of NO SCROLL specification + +create or replace function sc_test() returns setof integer as $$ +declare + c refcursor; + x integer; +begin + open c scroll for select f1 from int4_tbl; + fetch last from c into x; + while found loop + return next x; + fetch prior from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION sc_test() RETURNS SETOF int AS $$\ndeclare\n c refcursor;\n x integer;\n..." +== 548 +-- truncate_limit: 100 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sc_test()" +== 549 +-- truncate_limit: 100 +create or replace function sc_test() returns setof integer as $$ +declare + c refcursor; + x integer; +begin + open c scroll for execute 'select f1 from int4_tbl'; + fetch last from c into x; + while found loop + return next x; + fetch relative -2 from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION sc_test() RETURNS SETOF int AS $$\ndeclare\n c refcursor;\n x integer;\n..." +== 550 +-- truncate_limit: 100 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sc_test()" +== 551 +-- truncate_limit: 100 +create or replace function sc_test() returns setof integer as $$ +declare + c refcursor; + x integer; +begin + open c scroll for execute 'select f1 from int4_tbl'; + fetch last from c into x; + while found loop + return next x; + move backward 2 from c; + fetch relative -1 from c into x; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION sc_test() RETURNS SETOF int AS $$\ndeclare\n c refcursor;\n x integer;\n..." +== 552 +-- truncate_limit: 100 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sc_test()" +== 553 +-- truncate_limit: 100 +create or replace function sc_test() returns setof integer as $$ +declare + c cursor for select * from generate_series(1, 10); + x integer; +begin + open c; + loop + move relative 2 in c; + if not found then + exit; + end if; + fetch next from c into x; + if found then + return next x; + end if; + end loop; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION sc_test() RETURNS SETOF int AS $$\ndeclare\n c cursor for select * from..." +== 554 +-- truncate_limit: 100 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sc_test()" +== 555 +-- truncate_limit: 100 +create or replace function sc_test() returns setof integer as $$ +declare + c cursor for select * from generate_series(1, 10); + x integer; +begin + open c; + move forward all in c; + fetch backward from c into x; + if found then + return next x; + end if; + close c; +end; +$$ language plpgsql +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION sc_test() RETURNS SETOF int AS $$\ndeclare\n c cursor for select * from..." +== 556 +-- truncate_limit: 100 +select * from sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sc_test()" +== 557 +-- truncate_limit: 100 +drop function sc_test() +-- +FUNCTION: name="sc_test" function="sc_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION sc_test()" +== 558 +-- truncate_limit: 100 +-- test qualified variable names + +create function pl_qual_names (param1 int) returns void as $$ +<> +declare + param1 int := 1; +begin + <> + declare + param1 int := 2; + begin + raise notice 'param1 = %', param1; + raise notice 'pl_qual_names.param1 = %', pl_qual_names.param1; + raise notice 'outerblock.param1 = %', outerblock.param1; + raise notice 'innerblock.param1 = %', innerblock.param1; + end; +end; +$$ language plpgsql +-- +FUNCTION: name="pl_qual_names" function="pl_qual_names" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION pl_qual_names(param1 int) RETURNS void AS $$\n<>\ndeclare\n param1 int ..." +== 559 +-- truncate_limit: 100 +select pl_qual_names(42) +-- +FUNCTION: name="pl_qual_names" function="pl_qual_names" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pl_qual_names(42)" +== 560 +-- truncate_limit: 100 +drop function pl_qual_names(int) +-- +FUNCTION: name="pl_qual_names" function="pl_qual_names" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION pl_qual_names(int)" +== 561 +-- truncate_limit: 100 +-- tests for RETURN QUERY +create function ret_query1(out int, out int) returns setof record as $$ +begin + $1 := -1; + $2 := -2; + return next; + return query select x + 1, x * 10 from generate_series(0, 10) s (x); + return next; +end; +$$ language plpgsql +-- +FUNCTION: name="ret_query1" function="ret_query1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ret_query1(OUT int, OUT int) RETURNS SETOF record AS $$\nbegin\n $1 := -1;\n $..." +== 562 +-- truncate_limit: 100 +select * from ret_query1() +-- +FUNCTION: name="ret_query1" function="ret_query1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ret_query1()" +== 563 +-- truncate_limit: 100 +create type record_type as (x text, y int, z boolean) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE record_type AS (x text, y int, z boolean)" +== 564 +-- truncate_limit: 100 +create or replace function ret_query2(lim int) returns setof record_type as $$ +begin + return query select fipshash(s.x::text), s.x, s.x > 0 + from generate_series(-8, lim) s (x) where s.x % 2 = 0; +end; +$$ language plpgsql +-- +FUNCTION: name="ret_query2" function="ret_query2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION ret_query2(lim int) RETURNS SETOF record_type AS $$\nbegin\n return q..." +== 565 +-- truncate_limit: 100 +select * from ret_query2(8) +-- +FUNCTION: name="ret_query2" function="ret_query2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ret_query2(8)" +== 566 +-- truncate_limit: 100 +-- test EXECUTE USING +create function exc_using(int, text) returns int as $$ +declare i int; +begin + for i in execute 'select * from generate_series(1,$1)' using $1+1 loop + raise notice '%', i; + end loop; + execute 'select $2 + $2*3 + length($1)' into i using $2,$1; + return i; +end +$$ language plpgsql +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION exc_using(int, text) RETURNS int AS $$\ndeclare i int;\nbegin\n for i in execute 's..." +== 567 +-- truncate_limit: 100 +select exc_using(5, 'foobar') +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exc_using(5, 'foobar')" +== 568 +-- truncate_limit: 100 +drop function exc_using(int, text) +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION exc_using(int, text)" +== 569 +-- truncate_limit: 100 +create or replace function exc_using(int) returns void as $$ +declare + c refcursor; + i int; +begin + open c for execute 'select * from generate_series(1,$1)' using $1+1; + loop + fetch c into i; + exit when not found; + raise notice '%', i; + end loop; + close c; + return; +end; +$$ language plpgsql +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION exc_using(int) RETURNS void AS $$\ndeclare\n c refcursor;\n i int;\nbegi..." +== 570 +-- truncate_limit: 100 +select exc_using(5) +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT exc_using(5)" +== 571 +-- truncate_limit: 100 +drop function exc_using(int) +-- +FUNCTION: name="exc_using" function="exc_using" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION exc_using(int)" +== 572 +-- truncate_limit: 100 +-- test FOR-over-cursor + +create or replace function forc01() returns void as $$ +declare + c cursor(r1 integer, r2 integer) + for select * from generate_series(r1,r2) i; + c2 cursor + for select * from generate_series(41,43) i; +begin + -- assign portal names to cursors to get stable output + c := 'c'; + c2 := 'c2'; + for r in c(5,7) loop + raise notice '% from %', r.i, c; + end loop; + -- again, to test if cursor was closed properly + for r in c(9,10) loop + raise notice '% from %', r.i, c; + end loop; + -- and test a parameterless cursor + for r in c2 loop + raise notice '% from %', r.i, c2; + end loop; + -- and try it with a hand-assigned name + raise notice 'after loop, c2 = %', c2; + c2 := 'special_name'; + for r in c2 loop + raise notice '% from %', r.i, c2; + end loop; + raise notice 'after loop, c2 = %', c2; + -- and try it with a generated name + -- (which we can't show in the output because it's variable) + c2 := null; + for r in c2 loop + raise notice '%', r.i; + end loop; + raise notice 'after loop, c2 = %', c2; + return; +end; +$$ language plpgsql +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION forc01() RETURNS void AS $$\ndeclare\n c cursor(r1 integer, r2 integer)..." +== 573 +-- truncate_limit: 100 +select forc01() +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT forc01()" +== 574 +-- truncate_limit: 100 +-- try updating the cursor's current row + +create temp table forc_test as + select n as i, n as j from generate_series(1,10) n +-- +TABLE: name="forc_test" schema="" table="forc_test" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE forc_test AS SELECT n AS i, n AS j FROM generate_series(1, 10) n" +== 575 +-- truncate_limit: 100 +create or replace function forc01() returns void as $$ +declare + c cursor for select * from forc_test; +begin + for r in c loop + raise notice '%, %', r.i, r.j; + update forc_test set i = i * 100, j = r.j * 2 where current of c; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION forc01() RETURNS void AS $$\ndeclare\n c cursor for select * from forc_..." +== 576 +-- truncate_limit: 100 +select forc01() +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT forc01()" +== 577 +-- truncate_limit: 100 +select * from forc_test +-- +TABLE: name="forc_test" schema="" table="forc_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM forc_test" +== 578 +-- truncate_limit: 100 +-- same, with a cursor whose portal name doesn't match variable name +create or replace function forc01() returns void as $$ +declare + c refcursor := 'fooled_ya'; + r record; +begin + open c for select * from forc_test; + loop + fetch c into r; + exit when not found; + raise notice '%, %', r.i, r.j; + update forc_test set i = i * 100, j = r.j * 2 where current of c; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION forc01() RETURNS void AS $$\ndeclare\n c refcursor := 'fooled_ya';\n r ..." +== 579 +-- truncate_limit: 100 +select forc01() +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT forc01()" +== 580 +-- truncate_limit: 100 +select * from forc_test +-- +TABLE: name="forc_test" schema="" table="forc_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM forc_test" +== 581 +-- truncate_limit: 100 +drop function forc01() +-- +FUNCTION: name="forc01" function="forc01" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION forc01()" +== 582 +-- truncate_limit: 100 +-- it's okay to re-use a cursor variable name, even when bound + +do $$ +declare cnt int := 0; + c1 cursor for select * from forc_test; +begin + for r1 in c1 loop + declare c1 cursor for select * from forc_test; + begin + for r2 in c1 loop + cnt := cnt + 1; + end loop; + end; + end loop; + raise notice 'cnt = %', cnt; +end $$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare cnt int := 0;\n c1 cursor for select * from forc_test;\nbegin\n for r1 in c1 loop\n ..." +== 583 +-- truncate_limit: 100 +-- fail because cursor has no query bound to it + +create or replace function forc_bad() returns void as $$ +declare + c refcursor; +begin + for r in c loop + raise notice '%', r.i; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="forc_bad" function="forc_bad" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION forc_bad() RETURNS void AS $$\ndeclare\n c refcursor;\nbegin\n for r in ..." +== 584 +-- truncate_limit: 100 +-- test RETURN QUERY EXECUTE + +create or replace function return_dquery() +returns setof int as $$ +begin + return query execute 'select * from (values(10),(20)) f'; + return query execute 'select * from (values($1),($2)) f' using 40,50; +end; +$$ language plpgsql +-- +FUNCTION: name="return_dquery" function="return_dquery" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION return_dquery() RETURNS SETOF int AS $$\nbegin\n return query execute '..." +== 585 +-- truncate_limit: 100 +select * from return_dquery() +-- +FUNCTION: name="return_dquery" function="return_dquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM return_dquery()" +== 586 +-- truncate_limit: 100 +drop function return_dquery() +-- +FUNCTION: name="return_dquery" function="return_dquery" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION return_dquery()" +== 587 +-- truncate_limit: 100 +-- test RETURN QUERY with dropped columns + +create table tabwithcols(a int, b int, c int, d int) +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tabwithcols (a int, b int, c int, d int)" +== 588 +-- truncate_limit: 100 +insert into tabwithcols values(10,20,30,40),(50,60,70,80) +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tabwithcols VALUES (10, 20, 30, 40), (50, 60, 70, 80)" +== 589 +-- truncate_limit: 100 +create or replace function returnqueryf() +returns setof tabwithcols as $$ +begin + return query select * from tabwithcols; + return query execute 'select * from tabwithcols'; +end; +$$ language plpgsql +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION returnqueryf() RETURNS SETOF tabwithcols AS $$\nbegin\n return query se..." +== 590 +-- truncate_limit: 100 +select * from returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM returnqueryf()" +== 591 +-- truncate_limit: 100 +alter table tabwithcols drop column b +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tabwithcols DROP b" +== 592 +-- truncate_limit: 100 +select * from returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM returnqueryf()" +== 593 +-- truncate_limit: 100 +alter table tabwithcols drop column d +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tabwithcols DROP d" +== 594 +-- truncate_limit: 100 +select * from returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM returnqueryf()" +== 595 +-- truncate_limit: 100 +alter table tabwithcols add column d int +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tabwithcols ADD COLUMN d int" +== 596 +-- truncate_limit: 100 +select * from returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM returnqueryf()" +== 597 +-- truncate_limit: 100 +drop function returnqueryf() +-- +FUNCTION: name="returnqueryf" function="returnqueryf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION returnqueryf()" +== 598 +-- truncate_limit: 100 +drop table tabwithcols +-- +TABLE: name="tabwithcols" schema="" table="tabwithcols" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tabwithcols" +== 599 +-- truncate_limit: 100 +|-- +-- Tests for composite-type results +|-- + +create type compostype as (x int, y varchar) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE compostype AS (x int, y varchar)" +== 600 +-- truncate_limit: 100 +-- test: use of variable of composite type in return statement +create or replace function compos() returns compostype as $$ +declare + v compostype; +begin + v := (1, 'hello'); + return v; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS compostype AS $$\ndeclare\n v compostype;\nbegin\n v :=..." +== 601 +-- truncate_limit: 100 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT compos()" +== 602 +-- truncate_limit: 100 +-- test: use of variable of record type in return statement +create or replace function compos() returns compostype as $$ +declare + v record; +begin + v := (1, 'hello'::varchar); + return v; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS compostype AS $$\ndeclare\n v record;\nbegin\n v := (1,..." +== 603 +-- truncate_limit: 100 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT compos()" +== 604 +-- truncate_limit: 100 +-- test: use of row expr in return statement +create or replace function compos() returns compostype as $$ +begin + return (1, 'hello'::varchar); +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS compostype AS $$\nbegin\n return (1, 'hello'::varchar)..." +== 605 +-- truncate_limit: 100 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT compos()" +== 606 +-- truncate_limit: 100 +-- this does not work currently (no implicit casting) +create or replace function compos() returns compostype as $$ +begin + return (1, 'hello'); +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS compostype AS $$\nbegin\n return (1, 'hello');\nend;\n$$..." +== 607 +-- truncate_limit: 100 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT compos()" +== 608 +-- truncate_limit: 100 +-- ... but this does +create or replace function compos() returns compostype as $$ +begin + return (1, 'hello')::compostype; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS compostype AS $$\nbegin\n return (1, 'hello')::compost..." +== 609 +-- truncate_limit: 100 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT compos()" +== 610 +-- truncate_limit: 100 +drop function compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION compos()" +== 611 +-- truncate_limit: 100 +-- test: return a row expr as record. +create or replace function composrec() returns record as $$ +declare + v record; +begin + v := (1, 'hello'); + return v; +end; +$$ language plpgsql +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION composrec() RETURNS record AS $$\ndeclare\n v record;\nbegin\n v := (1, ..." +== 612 +-- truncate_limit: 100 +select composrec() +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT composrec()" +== 613 +-- truncate_limit: 100 +-- test: return row expr in return statement. +create or replace function composrec() returns record as $$ +begin + return (1, 'hello'); +end; +$$ language plpgsql +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION composrec() RETURNS record AS $$\nbegin\n return (1, 'hello');\nend;\n$$ ..." +== 614 +-- truncate_limit: 100 +select composrec() +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT composrec()" +== 615 +-- truncate_limit: 100 +drop function composrec() +-- +FUNCTION: name="composrec" function="composrec" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION composrec()" +== 616 +-- truncate_limit: 100 +-- test: row expr in RETURN NEXT statement. +create or replace function compos() returns setof compostype as $$ +begin + for i in 1..3 + loop + return next (1, 'hello'::varchar); + end loop; + return next null::compostype; + return next (2, 'goodbye')::compostype; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS SETOF compostype AS $$\nbegin\n for i in 1..3\n loop\n ..." +== 617 +-- truncate_limit: 100 +select * from compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM compos()" +== 618 +-- truncate_limit: 100 +drop function compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION compos()" +== 619 +-- truncate_limit: 100 +-- test: use invalid expr in return statement. +create or replace function compos() returns compostype as $$ +begin + return 1 + 1; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS compostype AS $$\nbegin\n return 1 + 1;\nend;\n$$ LANGUA..." +== 620 +-- truncate_limit: 100 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT compos()" +== 621 +-- truncate_limit: 100 +-- RETURN variable is a different code path ... +create or replace function compos() returns compostype as $$ +declare x int := 42; +begin + return x; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS compostype AS $$\ndeclare x int := 42;\nbegin\n return ..." +== 622 +-- truncate_limit: 100 +select * from compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM compos()" +== 623 +-- truncate_limit: 100 +drop function compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION compos()" +== 624 +-- truncate_limit: 100 +-- test: invalid use of composite variable in scalar-returning function +create or replace function compos() returns int as $$ +declare + v compostype; +begin + v := (1, 'hello'); + return v; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS int AS $$\ndeclare\n v compostype;\nbegin\n v := (1, 'h..." +== 625 +-- truncate_limit: 100 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT compos()" +== 626 +-- truncate_limit: 100 +-- test: invalid use of composite expression in scalar-returning function +create or replace function compos() returns int as $$ +begin + return (1, 'hello')::compostype; +end; +$$ language plpgsql +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION compos() RETURNS int AS $$\nbegin\n return (1, 'hello')::compostype;\nen..." +== 627 +-- truncate_limit: 100 +select compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT compos()" +== 628 +-- truncate_limit: 100 +drop function compos() +-- +FUNCTION: name="compos" function="compos" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION compos()" +== 629 +-- truncate_limit: 100 +drop type compostype +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE compostype" +== 630 +-- truncate_limit: 100 +|-- +-- Tests for 8.4's new RAISE features +|-- + +create or replace function raise_test() returns void as $$ +begin + raise notice '% % %', 1, 2, 3 + using errcode = '55001', detail = 'some detail info', hint = 'some hint'; + raise '% % %', 1, 2, 3 + using errcode = 'division_by_zero', detail = 'some detail info'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise notice '% % %', 1, 2, 3\n..." +== 631 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 632 +-- truncate_limit: 100 +-- Since we can't actually see the thrown SQLSTATE in default psql output, +-- test it like this; this also tests re-RAISE + +create or replace function raise_test() returns void as $$ +begin + raise 'check me' + using errcode = 'division_by_zero', detail = 'some detail info'; + exception + when others then + raise notice 'SQLSTATE: % SQLERRM: %', sqlstate, sqlerrm; + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise 'check me'\n using er..." +== 633 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 634 +-- truncate_limit: 100 +create or replace function raise_test() returns void as $$ +begin + raise 'check me' + using errcode = '1234F', detail = 'some detail info'; + exception + when others then + raise notice 'SQLSTATE: % SQLERRM: %', sqlstate, sqlerrm; + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise 'check me'\n using er..." +== 635 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 636 +-- truncate_limit: 100 +-- SQLSTATE specification in WHEN +create or replace function raise_test() returns void as $$ +begin + raise 'check me' + using errcode = '1234F', detail = 'some detail info'; + exception + when sqlstate '1234F' then + raise notice 'SQLSTATE: % SQLERRM: %', sqlstate, sqlerrm; + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise 'check me'\n using er..." +== 637 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 638 +-- truncate_limit: 100 +create or replace function raise_test() returns void as $$ +begin + raise division_by_zero using detail = 'some detail info'; + exception + when others then + raise notice 'SQLSTATE: % SQLERRM: %', sqlstate, sqlerrm; + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise division_by_zero using d..." +== 639 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 640 +-- truncate_limit: 100 +create or replace function raise_test() returns void as $$ +begin + raise division_by_zero; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise division_by_zero;\nend;\n$..." +== 641 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 642 +-- truncate_limit: 100 +create or replace function raise_test() returns void as $$ +begin + raise sqlstate '1234F'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise sqlstate '1234F';\nend;\n$..." +== 643 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 644 +-- truncate_limit: 100 +create or replace function raise_test() returns void as $$ +begin + raise division_by_zero using message = 'custom' || ' message'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise division_by_zero using m..." +== 645 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 646 +-- truncate_limit: 100 +create or replace function raise_test() returns void as $$ +begin + raise using message = 'custom' || ' message', errcode = '22012'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise using message = 'custom'..." +== 647 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 648 +-- truncate_limit: 100 +-- conflict on message +create or replace function raise_test() returns void as $$ +begin + raise notice 'some message' using message = 'custom' || ' message', errcode = '22012'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise notice 'some message' us..." +== 649 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 650 +-- truncate_limit: 100 +-- conflict on errcode +create or replace function raise_test() returns void as $$ +begin + raise division_by_zero using message = 'custom' || ' message', errcode = '22012'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise division_by_zero using m..." +== 651 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 652 +-- truncate_limit: 100 +-- nothing to re-RAISE +create or replace function raise_test() returns void as $$ +begin + raise; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise;\nend;\n$$ LANGUAGE plpgsql" +== 653 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 654 +-- truncate_limit: 100 +-- test access to exception data +create function zero_divide() returns int as $$ +declare v int := 0; +begin + return 10 / v; +end; +$$ language plpgsql parallel safe +-- +FUNCTION: name="zero_divide" function="zero_divide" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION zero_divide() RETURNS int AS $$\ndeclare v int := 0;\nbegin\n return 10 / v;\nend;\n$..." +== 655 +-- truncate_limit: 100 +create or replace function raise_test() returns void as $$ +begin + raise exception 'custom exception' + using detail = 'some detail of custom exception', + hint = 'some hint related to custom exception'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n raise exception 'custom except..." +== 656 +-- truncate_limit: 100 +create function stacked_diagnostics_test() returns void as $$ +declare _sqlstate text; + _message text; + _context text; +begin + perform zero_divide(); +exception when others then + get stacked diagnostics + _sqlstate = returned_sqlstate, + _message = message_text, + _context = pg_exception_context; + raise notice 'sqlstate: %, message: %, context: [%]', + _sqlstate, _message, replace(_context, E'\n', ' <- '); +end; +$$ language plpgsql +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION stacked_diagnostics_test() RETURNS void AS $$\ndeclare _sqlstate text;\n _me..." +== 657 +-- truncate_limit: 100 +select stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stacked_diagnostics_test()" +== 658 +-- truncate_limit: 100 +create or replace function stacked_diagnostics_test() returns void as $$ +declare _detail text; + _hint text; + _message text; +begin + perform raise_test(); +exception when others then + get stacked diagnostics + _message = message_text, + _detail = pg_exception_detail, + _hint = pg_exception_hint; + raise notice 'message: %, detail: %, hint: %', _message, _detail, _hint; +end; +$$ language plpgsql +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stacked_diagnostics_test() RETURNS void AS $$\ndeclare _detail text;\n ..." +== 659 +-- truncate_limit: 100 +select stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stacked_diagnostics_test()" +== 660 +-- truncate_limit: 100 +-- fail, cannot use stacked diagnostics statement outside handler +create or replace function stacked_diagnostics_test() returns void as $$ +declare _detail text; + _hint text; + _message text; +begin + get stacked diagnostics + _message = message_text, + _detail = pg_exception_detail, + _hint = pg_exception_hint; + raise notice 'message: %, detail: %, hint: %', _message, _detail, _hint; +end; +$$ language plpgsql +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stacked_diagnostics_test() RETURNS void AS $$\ndeclare _detail text;\n ..." +== 661 +-- truncate_limit: 100 +select stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stacked_diagnostics_test()" +== 662 +-- truncate_limit: 100 +drop function stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION stacked_diagnostics_test()" +== 663 +-- truncate_limit: 100 +-- Test that an error recovery subtransaction is parallel safe + +create function error_trap_test() returns text as $$ +begin + perform zero_divide(); + return 'no error detected!'; +exception when division_by_zero then + return 'division_by_zero detected'; +end; +$$ language plpgsql parallel safe +-- +FUNCTION: name="error_trap_test" function="error_trap_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION error_trap_test() RETURNS text AS $$\nbegin\n perform zero_divide();\n return 'no ..." +== 664 +-- truncate_limit: 100 +set debug_parallel_query to on +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO ON" +== 665 +-- truncate_limit: 100 +explain (verbose, costs off) select error_trap_test() +-- +FUNCTION: name="error_trap_test" function="error_trap_test" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT error_trap_test()" +== 666 +-- truncate_limit: 100 +select error_trap_test() +-- +FUNCTION: name="error_trap_test" function="error_trap_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT error_trap_test()" +== 667 +-- truncate_limit: 100 +reset debug_parallel_query +-- +STMT: VariableSetStmt +TRUNCATED: "RESET debug_parallel_query" +== 668 +-- truncate_limit: 100 +drop function error_trap_test() +-- +FUNCTION: name="error_trap_test" function="error_trap_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION error_trap_test()" +== 669 +-- truncate_limit: 100 +drop function zero_divide() +-- +FUNCTION: name="zero_divide" function="zero_divide" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION zero_divide()" +== 670 +-- truncate_limit: 100 +-- check cases where implicit SQLSTATE variable could be confused with +-- SQLSTATE as a keyword, cf bug #5524 +create or replace function raise_test() returns void as $$ +begin + perform 1/0; +exception + when sqlstate '22012' then + raise notice using message = sqlstate; + raise sqlstate '22012' using message = 'substitute message'; +end; +$$ language plpgsql +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION raise_test() RETURNS void AS $$\nbegin\n perform 1/0;\nexception\n when ..." +== 671 +-- truncate_limit: 100 +select raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT raise_test()" +== 672 +-- truncate_limit: 100 +drop function raise_test() +-- +FUNCTION: name="raise_test" function="raise_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION raise_test()" +== 673 +-- truncate_limit: 100 +-- test passing column_name, constraint_name, datatype_name, table_name +-- and schema_name error fields + +create or replace function stacked_diagnostics_test() returns void as $$ +declare _column_name text; + _constraint_name text; + _datatype_name text; + _table_name text; + _schema_name text; +begin + raise exception using + column = '>>some column name<<', + constraint = '>>some constraint name<<', + datatype = '>>some datatype name<<', + table = '>>some table name<<', + schema = '>>some schema name<<'; +exception when others then + get stacked diagnostics + _column_name = column_name, + _constraint_name = constraint_name, + _datatype_name = pg_datatype_name, + _table_name = table_name, + _schema_name = schema_name; + raise notice 'column %, constraint %, type %, table %, schema %', + _column_name, _constraint_name, _datatype_name, _table_name, _schema_name; +end; +$$ language plpgsql +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION stacked_diagnostics_test() RETURNS void AS $$\ndeclare _column_name tex..." +== 674 +-- truncate_limit: 100 +select stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stacked_diagnostics_test()" +== 675 +-- truncate_limit: 100 +drop function stacked_diagnostics_test() +-- +FUNCTION: name="stacked_diagnostics_test" function="stacked_diagnostics_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION stacked_diagnostics_test()" +== 676 +-- truncate_limit: 100 +-- test variadic functions + +create or replace function vari(variadic int[]) +returns void as $$ +begin + for i in array_lower($1,1)..array_upper($1,1) loop + raise notice '%', $1[i]; + end loop; end; +$$ language plpgsql +-- +FUNCTION: name="vari" function="vari" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION vari(VARIADIC int[]) RETURNS void AS $$\nbegin\n for i in array_lower($..." +== 677 +-- truncate_limit: 100 +select vari(1,2,3,4,5) +-- +FUNCTION: name="vari" function="vari" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT vari(1, 2, 3, 4, 5)" +== 678 +-- truncate_limit: 100 +select vari(3,4,5) +-- +FUNCTION: name="vari" function="vari" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT vari(3, 4, 5)" +== 679 +-- truncate_limit: 100 +select vari(variadic array[5,6,7]) +-- +FUNCTION: name="vari" function="vari" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT vari(VARIADIC ARRAY[5, 6, 7])" +== 680 +-- truncate_limit: 100 +drop function vari(int[]) +-- +FUNCTION: name="vari" function="vari" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION vari(int[])" +== 681 +-- truncate_limit: 100 +-- coercion test +create or replace function pleast(variadic numeric[]) +returns numeric as $$ +declare aux numeric = $1[array_lower($1,1)]; +begin + for i in array_lower($1,1)+1..array_upper($1,1) loop + if $1[i] < aux then aux := $1[i]; end if; + end loop; + return aux; +end; +$$ language plpgsql immutable strict +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION pleast(VARIADIC numeric[]) RETURNS numeric AS $$\ndeclare aux numeric =..." +== 682 +-- truncate_limit: 100 +select pleast(10,1,2,3,-16) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pleast(10, 1, 2, 3, -16)" +== 683 +-- truncate_limit: 100 +select pleast(10.2,2.2,-1.1) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pleast(10.2, 2.2, -1.1)" +== 684 +-- truncate_limit: 100 +select pleast(10.2,10, -20) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pleast(10.2, 10, -20)" +== 685 +-- truncate_limit: 100 +select pleast(10,20, -1.0) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pleast(10, 20, -1.0)" +== 686 +-- truncate_limit: 100 +-- in case of conflict, non-variadic version is preferred +create or replace function pleast(numeric) +returns numeric as $$ +begin + raise notice 'non-variadic function called'; + return $1; +end; +$$ language plpgsql immutable strict +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION pleast(numeric) RETURNS numeric AS $$\nbegin\n raise notice 'non-variad..." +== 687 +-- truncate_limit: 100 +select pleast(10) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pleast(10)" +== 688 +-- truncate_limit: 100 +drop function pleast(numeric[]) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION pleast(numeric[])" +== 689 +-- truncate_limit: 100 +drop function pleast(numeric) +-- +FUNCTION: name="pleast" function="pleast" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION pleast(numeric)" +== 690 +-- truncate_limit: 100 +-- test table functions + +create function tftest(int) returns table(a int, b int) as $$ +begin + return query select $1, $1+i from generate_series(1,5) g(i); +end; +$$ language plpgsql immutable strict +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tftest(int) RETURNS TABLE (a int, b int) AS $$\nbegin\n return query select $1, $1..." +== 691 +-- truncate_limit: 100 +select * from tftest(10) +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tftest(10)" +== 692 +-- truncate_limit: 100 +create or replace function tftest(a1 int) returns table(a int, b int) as $$ +begin + a := a1; b := a1 + 1; + return next; + a := a1 * 10; b := a1 * 10 + 1; + return next; +end; +$$ language plpgsql immutable strict +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION tftest(a1 int) RETURNS TABLE (a int, b int) AS $$\nbegin\n a := a1; b :..." +== 693 +-- truncate_limit: 100 +select * from tftest(10) +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tftest(10)" +== 694 +-- truncate_limit: 100 +drop function tftest(int) +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION tftest(int)" +== 695 +-- truncate_limit: 100 +create function rttest() +returns setof int as $$ +declare rc int; +begin + return query values(10),(20); + get diagnostics rc = row_count; + raise notice '% %', found, rc; + return query select * from (values(10),(20)) f(a) where false; + get diagnostics rc = row_count; + raise notice '% %', found, rc; + return query execute 'values(10),(20)'; + get diagnostics rc = row_count; + raise notice '% %', found, rc; + return query execute 'select * from (values(10),(20)) f(a) where false'; + get diagnostics rc = row_count; + raise notice '% %', found, rc; +end; +$$ language plpgsql +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rttest() RETURNS SETOF int AS $$\ndeclare rc int;\nbegin\n return query values(10),..." +== 696 +-- truncate_limit: 100 +select * from rttest() +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rttest()" +== 697 +-- truncate_limit: 100 +-- check some error cases, too + +create or replace function rttest() +returns setof int as $$ +begin + return query select 10 into no_such_table; +end; +$$ language plpgsql +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rttest() RETURNS SETOF int AS $$\nbegin\n return query select 10 into n..." +== 698 +-- truncate_limit: 100 +select * from rttest() +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rttest()" +== 699 +-- truncate_limit: 100 +create or replace function rttest() +returns setof int as $$ +begin + return query execute 'select 10 into no_such_table'; +end; +$$ language plpgsql +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rttest() RETURNS SETOF int AS $$\nbegin\n return query execute 'select ..." +== 700 +-- truncate_limit: 100 +select * from rttest() +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rttest()" +== 701 +-- truncate_limit: 100 +select * from no_such_table +-- +TABLE: name="no_such_table" schema="" table="no_such_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM no_such_table" +== 702 +-- truncate_limit: 100 +drop function rttest() +-- +FUNCTION: name="rttest" function="rttest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rttest()" +== 703 +-- truncate_limit: 100 +-- Test for proper cleanup at subtransaction exit. This example +-- exposed a bug in PG 8.2. + +CREATE FUNCTION leaker_1(fail BOOL) RETURNS INTEGER AS $$ +DECLARE + v_var INTEGER; +BEGIN + BEGIN + v_var := (leaker_2(fail)).error_code; + EXCEPTION + WHEN others THEN RETURN 0; + END; + RETURN 1; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="leaker_1" function="leaker_1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION leaker_1(fail bool) RETURNS int AS $$\nDECLARE\n v_var INTEGER;\nBEGIN\n BEGIN\n ..." +== 704 +-- truncate_limit: 100 +CREATE FUNCTION leaker_2(fail BOOL, OUT error_code INTEGER, OUT new_id INTEGER) + RETURNS RECORD AS $$ +BEGIN + IF fail THEN + RAISE EXCEPTION 'fail ...'; + END IF; + error_code := 1; + new_id := 1; + RETURN; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="leaker_2" function="leaker_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION leaker_2(fail bool, OUT error_code int, OUT new_id int) RETURNS record AS $$\nBEGI..." +== 705 +-- truncate_limit: 100 +SELECT * FROM leaker_1(false) +-- +FUNCTION: name="leaker_1" function="leaker_1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM leaker_1(false)" +== 706 +-- truncate_limit: 100 +SELECT * FROM leaker_1(true) +-- +FUNCTION: name="leaker_1" function="leaker_1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM leaker_1(true)" +== 707 +-- truncate_limit: 100 +DROP FUNCTION leaker_1(bool) +-- +FUNCTION: name="leaker_1" function="leaker_1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION leaker_1(bool)" +== 708 +-- truncate_limit: 100 +DROP FUNCTION leaker_2(bool) +-- +FUNCTION: name="leaker_2" function="leaker_2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION leaker_2(bool)" +== 709 +-- truncate_limit: 100 +-- Test for appropriate cleanup of non-simple expression evaluations +-- (bug in all versions prior to August 2010) + +CREATE FUNCTION nonsimple_expr_test() RETURNS text[] AS $$ +DECLARE + arr text[]; + lr text; + i integer; +BEGIN + arr := array[array['foo','bar'], array['baz', 'quux']]; + lr := 'fool'; + i := 1; + -- use sub-SELECTs to make expressions non-simple + arr[(SELECT i)][(SELECT i+1)] := (SELECT lr); + RETURN arr; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION nonsimple_expr_test() RETURNS text[] AS $$\nDECLARE\n arr text[];\n lr text;\n i i..." +== 710 +-- truncate_limit: 100 +SELECT nonsimple_expr_test() +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nonsimple_expr_test()" +== 711 +-- truncate_limit: 100 +DROP FUNCTION nonsimple_expr_test() +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION nonsimple_expr_test()" +== 712 +-- truncate_limit: 100 +CREATE FUNCTION nonsimple_expr_test() RETURNS integer AS $$ +declare + i integer NOT NULL := 0; +begin + begin + i := (SELECT NULL::integer); -- should throw error + exception + WHEN OTHERS THEN + i := (SELECT 1::integer); + end; + return i; +end; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION nonsimple_expr_test() RETURNS int AS $$\ndeclare\n i integer NOT NULL := 0;\nbegin..." +== 713 +-- truncate_limit: 100 +SELECT nonsimple_expr_test() +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nonsimple_expr_test()" +== 714 +-- truncate_limit: 100 +DROP FUNCTION nonsimple_expr_test() +-- +FUNCTION: name="nonsimple_expr_test" function="nonsimple_expr_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION nonsimple_expr_test()" +== 715 +-- truncate_limit: 100 +|-- +-- Test cases involving recursion and error recovery in simple expressions +-- (bugs in all versions before October 2010). The problems are most +-- easily exposed by mutual recursion between plpgsql and sql functions. +|-- + +create function recurse(float8) returns float8 as +$$ +begin + if ($1 > 0) then + return sql_recurse($1 - 1); + else + return $1; + end if; +end; +$$ language plpgsql +-- +FUNCTION: name="recurse" function="recurse" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION recurse(float8) RETURNS float8 AS $$\nbegin\n if ($1 > 0) then\n return sql_recu..." +== 716 +-- truncate_limit: 100 +-- "limit" is to prevent this from being inlined +create function sql_recurse(float8) returns float8 as +$$ select recurse($1) limit 1; $$ language sql +-- +FUNCTION: name="sql_recurse" function="sql_recurse" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sql_recurse(float8) RETURNS float8 AS $$ select recurse($1) limit 1; $$ LANGUAGE sql" +== 717 +-- truncate_limit: 100 +select recurse(10) +-- +FUNCTION: name="recurse" function="recurse" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT recurse(10)" +== 718 +-- truncate_limit: 100 +create function error1(text) returns text language sql as +$$ SELECT relname::text FROM pg_class c WHERE c.oid = $1::regclass $$ +-- +FUNCTION: name="error1" function="error1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION error1(text) RETURNS text LANGUAGE sql AS $$ SELECT relname::text FROM pg_class c..." +== 719 +-- truncate_limit: 100 +create function error2(p_name_table text) returns text language plpgsql as $$ +begin + return error1(p_name_table); +end$$ +-- +FUNCTION: name="error2" function="error2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION error2(p_name_table text) RETURNS text LANGUAGE plpgsql AS $$\nbegin\n return erro..." +== 720 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 721 +-- truncate_limit: 100 +create table public.stuffs (stuff text) +-- +TABLE: name="public.stuffs" schema="public" table="stuffs" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE public.stuffs (stuff text)" +== 722 +-- truncate_limit: 100 +SAVEPOINT a +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT a" +== 723 +-- truncate_limit: 100 +select error2('nonexistent.stuffs') +-- +FUNCTION: name="error2" function="error2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT error2('nonexistent.stuffs')" +== 724 +-- truncate_limit: 100 +ROLLBACK TO a +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT a" +== 725 +-- truncate_limit: 100 +select error2('public.stuffs') +-- +FUNCTION: name="error2" function="error2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT error2('public.stuffs')" +== 726 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 727 +-- truncate_limit: 100 +drop function error2(p_name_table text) +-- +FUNCTION: name="error2" function="error2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION error2(p_name_table text)" +== 728 +-- truncate_limit: 100 +drop function error1(text) +-- +FUNCTION: name="error1" function="error1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION error1(text)" +== 729 +-- truncate_limit: 100 +-- Test for proper handling of cast-expression caching + +create function sql_to_date(integer) returns date as $$ +select $1::text::date +$$ language sql immutable strict +-- +FUNCTION: name="sql_to_date" function="sql_to_date" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sql_to_date(int) RETURNS date AS $$\nselect $1::text::date\n$$ LANGUAGE sql IMMUTAB..." +== 730 +-- truncate_limit: 100 +create cast (integer as date) with function sql_to_date(integer) as assignment +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (int AS date) WITH FUNCTION sql_to_date(int) AS ASSIGNMENT" +== 731 +-- truncate_limit: 100 +create function cast_invoker(integer) returns date as $$ +begin + return $1; +end$$ language plpgsql +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION cast_invoker(int) RETURNS date AS $$\nbegin\n return $1;\nend$$ LANGUAGE plpgsql" +== 732 +-- truncate_limit: 100 +select cast_invoker(20150717) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cast_invoker(20150717)" +== 733 +-- truncate_limit: 100 +select cast_invoker(20150718) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cast_invoker(20150718)" +== 734 +-- truncate_limit: 100 +-- second call crashed in pre-release 9.5 + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 735 +-- truncate_limit: 100 +select cast_invoker(20150717) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cast_invoker(20150717)" +== 736 +-- truncate_limit: 100 +select cast_invoker(20150718) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cast_invoker(20150718)" +== 737 +-- truncate_limit: 100 +savepoint s1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT s1" +== 738 +-- truncate_limit: 100 +select cast_invoker(20150718) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cast_invoker(20150718)" +== 739 +-- truncate_limit: 100 +select cast_invoker(-1) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cast_invoker(-1)" +== 740 +-- truncate_limit: 100 +-- fails +rollback to savepoint s1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT s1" +== 741 +-- truncate_limit: 100 +select cast_invoker(20150719) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cast_invoker(20150719)" +== 742 +-- truncate_limit: 100 +select cast_invoker(20150720) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cast_invoker(20150720)" +== 743 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 744 +-- truncate_limit: 100 +drop function cast_invoker(integer) +-- +FUNCTION: name="cast_invoker" function="cast_invoker" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION cast_invoker(int)" +== 745 +-- truncate_limit: 100 +drop function sql_to_date(integer) cascade +-- +FUNCTION: name="sql_to_date" function="sql_to_date" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION sql_to_date(int) CASCADE" +== 746 +-- truncate_limit: 100 +-- Test handling of cast cache inside DO blocks +-- (to check the original crash case, this must be a cast not previously +-- used in this session) + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 747 +-- truncate_limit: 100 +do $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$ +-- +STMT: DoStmt +TRUNCATED: "DO $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$" +== 748 +-- truncate_limit: 100 +do $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$ +-- +STMT: DoStmt +TRUNCATED: "DO $$ declare x text[]; begin x := '{1.23, 4.56}'::numeric[]; end $$" +== 749 +-- truncate_limit: 100 +end +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 750 +-- truncate_limit: 100 +-- Test for consistent reporting of error context + +create function fail() returns int language plpgsql as $$ +begin + return 1/0; +end +$$ +-- +FUNCTION: name="fail" function="fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fail() RETURNS int LANGUAGE plpgsql AS $$\nbegin\n return 1/0;\nend\n$$" +== 751 +-- truncate_limit: 100 +select fail() +-- +FUNCTION: name="fail" function="fail" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT fail()" +== 752 +-- truncate_limit: 100 +select fail() +-- +FUNCTION: name="fail" function="fail" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT fail()" +== 753 +-- truncate_limit: 100 +drop function fail() +-- +FUNCTION: name="fail" function="fail" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION fail()" +== 754 +-- truncate_limit: 100 +-- Test handling of string literals. + +set standard_conforming_strings = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET standard_conforming_strings TO OFF" +== 755 +-- truncate_limit: 100 +create or replace function strtest() returns text as $$ +begin + raise notice 'foo\\bar\041baz'; + return 'foo\\bar\041baz'; +end +$$ language plpgsql +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION strtest() RETURNS text AS $$\nbegin\n raise notice 'foo\\\\bar\\041baz';\n ..." +== 756 +-- truncate_limit: 100 +select strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strtest()" +== 757 +-- truncate_limit: 100 +create or replace function strtest() returns text as $$ +begin + raise notice E'foo\\bar\041baz'; + return E'foo\\bar\041baz'; +end +$$ language plpgsql +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION strtest() RETURNS text AS $$\nbegin\n raise notice E'foo\\\\bar\\041baz';\n..." +== 758 +-- truncate_limit: 100 +select strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strtest()" +== 759 +-- truncate_limit: 100 +set standard_conforming_strings = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET standard_conforming_strings TO ON" +== 760 +-- truncate_limit: 100 +create or replace function strtest() returns text as $$ +begin + raise notice 'foo\\bar\041baz\'; + return 'foo\\bar\041baz\'; +end +$$ language plpgsql +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION strtest() RETURNS text AS $$\nbegin\n raise notice 'foo\\\\bar\\041baz\\';\n..." +== 761 +-- truncate_limit: 100 +select strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strtest()" +== 762 +-- truncate_limit: 100 +create or replace function strtest() returns text as $$ +begin + raise notice E'foo\\bar\041baz'; + return E'foo\\bar\041baz'; +end +$$ language plpgsql +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION strtest() RETURNS text AS $$\nbegin\n raise notice E'foo\\\\bar\\041baz';\n..." +== 763 +-- truncate_limit: 100 +select strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strtest()" +== 764 +-- truncate_limit: 100 +drop function strtest() +-- +FUNCTION: name="strtest" function="strtest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION strtest()" +== 765 +-- truncate_limit: 100 +-- Test anonymous code blocks. + +DO $$ +DECLARE r record; +BEGIN + FOR r IN SELECT rtrim(roomno) AS roomno, comment FROM Room ORDER BY roomno + LOOP + RAISE NOTICE '%, %', r.roomno, r.comment; + END LOOP; +END$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE r record;\nBEGIN\n FOR r IN SELECT rtrim(roomno) AS roomno, comment FROM Room ORDE..." +== 766 +-- truncate_limit: 100 +-- these are to check syntax error reporting +DO LANGUAGE plpgsql $$begin return 1; end$$ +-- +STMT: DoStmt +TRUNCATED: "DO LANGUAGE plpgsql $$begin return 1; end$$" +== 767 +-- truncate_limit: 100 +DO $$ +DECLARE r record; +BEGIN + FOR r IN SELECT rtrim(roomno) AS roomno, foo FROM Room ORDER BY roomno + LOOP + RAISE NOTICE '%, %', r.roomno, r.comment; + END LOOP; +END$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE r record;\nBEGIN\n FOR r IN SELECT rtrim(roomno) AS roomno, foo FROM Room ORDER BY..." +== 768 +-- truncate_limit: 100 +-- Check handling of errors thrown from/into anonymous code blocks. +do $outer$ +begin + for i in 1..10 loop + begin + execute $ex$ + do $$ + declare x int = 0; + begin + x := 1 / x; + end; + $$; + $ex$; + exception when division_by_zero then + raise notice 'caught division by zero'; + end; + end loop; +end; +$outer$ +-- +STMT: DoStmt +TRUNCATED: "DO $outer$\nbegin\n for i in 1..10 loop\n begin\n execute $ex$\n do $$\n declare x int ..." +== 769 +-- truncate_limit: 100 +-- Check variable scoping -- a var is not available in its own or prior +-- default expressions, but it is available in later ones. + +do $$ +declare x int := x + 1; -- error +begin + raise notice 'x = %', x; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare x int := x + 1; -- error\nbegin\n raise notice 'x = %', x;\nend;\n$$" +== 770 +-- truncate_limit: 100 +do $$ +declare y int := x + 1; -- error + x int := 42; +begin + raise notice 'x = %, y = %', x, y; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare y int := x + 1; -- error\n x int := 42;\nbegin\n raise notice 'x = %, y = %',..." +== 771 +-- truncate_limit: 100 +do $$ +declare x int := 42; + y int := x + 1; +begin + raise notice 'x = %, y = %', x, y; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare x int := 42;\n y int := x + 1;\nbegin\n raise notice 'x = %, y = %', x, y;\nend..." +== 772 +-- truncate_limit: 100 +do $$ +declare x int := 42; +begin + declare y int := x + 1; + x int := x + 2; + z int := x * 10; + begin + raise notice 'x = %, y = %, z = %', x, y, z; + end; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare x int := 42;\nbegin\n declare y int := x + 1;\n x int := x + 2;\n z ..." +== 773 +-- truncate_limit: 100 +-- Check handling of conflicts between plpgsql vars and table columns. + +set plpgsql.variable_conflict = error +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.variable_conflict\" TO error" +== 774 +-- truncate_limit: 100 +create function conflict_test() returns setof int8_tbl as $$ +declare r record; + q1 bigint := 42; +begin + for r in select q1,q2 from int8_tbl loop + return next r; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION conflict_test() RETURNS SETOF int8_tbl AS $$\ndeclare r record;\n q1 bigint := 42;..." +== 775 +-- truncate_limit: 100 +select * from conflict_test() +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM conflict_test()" +== 776 +-- truncate_limit: 100 +create or replace function conflict_test() returns setof int8_tbl as $$ +#variable_conflict use_variable +declare r record; + q1 bigint := 42; +begin + for r in select q1,q2 from int8_tbl loop + return next r; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION conflict_test() RETURNS SETOF int8_tbl AS $$\n#variable_conflict use_va..." +== 777 +-- truncate_limit: 100 +select * from conflict_test() +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM conflict_test()" +== 778 +-- truncate_limit: 100 +create or replace function conflict_test() returns setof int8_tbl as $$ +#variable_conflict use_column +declare r record; + q1 bigint := 42; +begin + for r in select q1,q2 from int8_tbl loop + return next r; + end loop; +end; +$$ language plpgsql +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION conflict_test() RETURNS SETOF int8_tbl AS $$\n#variable_conflict use_co..." +== 779 +-- truncate_limit: 100 +select * from conflict_test() +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM conflict_test()" +== 780 +-- truncate_limit: 100 +drop function conflict_test() +-- +FUNCTION: name="conflict_test" function="conflict_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION conflict_test()" +== 781 +-- truncate_limit: 100 +-- Check that an unreserved keyword can be used as a variable name + +create function unreserved_test() returns int as $$ +declare + forward int := 21; +begin + forward := forward * 2; + return forward; +end +$$ language plpgsql +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION unreserved_test() RETURNS int AS $$\ndeclare\n forward int := 21;\nbegin\n forward ..." +== 782 +-- truncate_limit: 100 +select unreserved_test() +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unreserved_test()" +== 783 +-- truncate_limit: 100 +create or replace function unreserved_test() returns int as $$ +declare + return int := 42; +begin + return := return + 1; + return return; +end +$$ language plpgsql +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION unreserved_test() RETURNS int AS $$\ndeclare\n return int := 42;\nbegin\n..." +== 784 +-- truncate_limit: 100 +select unreserved_test() +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unreserved_test()" +== 785 +-- truncate_limit: 100 +create or replace function unreserved_test() returns int as $$ +declare + comment int := 21; +begin + comment := comment * 2; + comment on function unreserved_test() is 'this is a test'; + return comment; +end +$$ language plpgsql +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION unreserved_test() RETURNS int AS $$\ndeclare\n comment int := 21;\nbegin..." +== 786 +-- truncate_limit: 100 +select unreserved_test() +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unreserved_test()" +== 787 +-- truncate_limit: 100 +select obj_description('unreserved_test()'::regprocedure, 'pg_proc') +-- +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT obj_description('unreserved_test()'::regprocedure, 'pg_proc')" +== 788 +-- truncate_limit: 100 +drop function unreserved_test() +-- +FUNCTION: name="unreserved_test" function="unreserved_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION unreserved_test()" +== 789 +-- truncate_limit: 100 +|-- +-- Test FOREACH over arrays +|-- + +create function foreach_test(anyarray) +returns void as $$ +declare x int; +begin + foreach x in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION foreach_test(anyarray) RETURNS void AS $$\ndeclare x int;\nbegin\n foreach x in arr..." +== 790 +-- truncate_limit: 100 +select foreach_test(ARRAY[1,2,3,4]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[1, 2, 3, 4])" +== 791 +-- truncate_limit: 100 +select foreach_test(ARRAY[[1,2],[3,4]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[ARRAY[1, 2], ARRAY[3, 4]])" +== 792 +-- truncate_limit: 100 +create or replace function foreach_test(anyarray) +returns void as $$ +declare x int; +begin + foreach x slice 1 in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION foreach_test(anyarray) RETURNS void AS $$\ndeclare x int;\nbegin\n forea..." +== 793 +-- truncate_limit: 100 +-- should fail +select foreach_test(ARRAY[1,2,3,4]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[1, 2, 3, 4])" +== 794 +-- truncate_limit: 100 +select foreach_test(ARRAY[[1,2],[3,4]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[ARRAY[1, 2], ARRAY[3, 4]])" +== 795 +-- truncate_limit: 100 +create or replace function foreach_test(anyarray) +returns void as $$ +declare x int[]; +begin + foreach x slice 1 in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION foreach_test(anyarray) RETURNS void AS $$\ndeclare x int[];\nbegin\n for..." +== 796 +-- truncate_limit: 100 +select foreach_test(ARRAY[1,2,3,4]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[1, 2, 3, 4])" +== 797 +-- truncate_limit: 100 +select foreach_test(ARRAY[[1,2],[3,4]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[ARRAY[1, 2], ARRAY[3, 4]])" +== 798 +-- truncate_limit: 100 +-- higher level of slicing +create or replace function foreach_test(anyarray) +returns void as $$ +declare x int[]; +begin + foreach x slice 2 in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION foreach_test(anyarray) RETURNS void AS $$\ndeclare x int[];\nbegin\n for..." +== 799 +-- truncate_limit: 100 +-- should fail +select foreach_test(ARRAY[1,2,3,4]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[1, 2, 3, 4])" +== 800 +-- truncate_limit: 100 +-- ok +select foreach_test(ARRAY[[1,2],[3,4]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[ARRAY[1, 2], ARRAY[3, 4]])" +== 801 +-- truncate_limit: 100 +select foreach_test(ARRAY[[[1,2]],[[3,4]]]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[ARRAY[ARRAY[1, 2]], ARRAY[ARRAY[3, 4]]])" +== 802 +-- truncate_limit: 100 +create type xy_tuple AS (x int, y int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE xy_tuple AS (x int, y int)" +== 803 +-- truncate_limit: 100 +-- iteration over array of records +create or replace function foreach_test(anyarray) +returns void as $$ +declare r record; +begin + foreach r in array $1 + loop + raise notice '%', r; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION foreach_test(anyarray) RETURNS void AS $$\ndeclare r record;\nbegin\n fo..." +== 804 +-- truncate_limit: 100 +select foreach_test(ARRAY[(10,20),(40,69),(35,78)]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[(10, 20), (40, 69), (35, 78)]::xy_tuple[])" +== 805 +-- truncate_limit: 100 +select foreach_test(ARRAY[[(10,20),(40,69)],[(35,78),(88,76)]]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[ARRAY[(10, 20), (40, 69)], ARRAY[(35, 78), (88, 76)]]::xy_tuple[])" +== 806 +-- truncate_limit: 100 +create or replace function foreach_test(anyarray) +returns void as $$ +declare x int; y int; +begin + foreach x, y in array $1 + loop + raise notice 'x = %, y = %', x, y; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION foreach_test(anyarray) RETURNS void AS $$\ndeclare x int; y int;\nbegin\n..." +== 807 +-- truncate_limit: 100 +select foreach_test(ARRAY[(10,20),(40,69),(35,78)]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[(10, 20), (40, 69), (35, 78)]::xy_tuple[])" +== 808 +-- truncate_limit: 100 +select foreach_test(ARRAY[[(10,20),(40,69)],[(35,78),(88,76)]]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[ARRAY[(10, 20), (40, 69)], ARRAY[(35, 78), (88, 76)]]::xy_tuple[])" +== 809 +-- truncate_limit: 100 +-- slicing over array of composite types +create or replace function foreach_test(anyarray) +returns void as $$ +declare x xy_tuple[]; +begin + foreach x slice 1 in array $1 + loop + raise notice '%', x; + end loop; + end; +$$ language plpgsql +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION foreach_test(anyarray) RETURNS void AS $$\ndeclare x xy_tuple[];\nbegin\n..." +== 810 +-- truncate_limit: 100 +select foreach_test(ARRAY[(10,20),(40,69),(35,78)]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[(10, 20), (40, 69), (35, 78)]::xy_tuple[])" +== 811 +-- truncate_limit: 100 +select foreach_test(ARRAY[[(10,20),(40,69)],[(35,78),(88,76)]]::xy_tuple[]) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT foreach_test(ARRAY[ARRAY[(10, 20), (40, 69)], ARRAY[(35, 78), (88, 76)]]::xy_tuple[])" +== 812 +-- truncate_limit: 100 +drop function foreach_test(anyarray) +-- +FUNCTION: name="foreach_test" function="foreach_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION foreach_test(anyarray)" +== 813 +-- truncate_limit: 100 +drop type xy_tuple +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE xy_tuple" +== 814 +-- truncate_limit: 100 +|-- +-- Assorted tests for array subscript assignment +|-- + +create temp table rtype (id int, ar text[]) +-- +TABLE: name="rtype" schema="" table="rtype" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE rtype (id int, ar text[])" +== 815 +-- truncate_limit: 100 +create function arrayassign1() returns text[] language plpgsql as $$ +declare + r record; +begin + r := row(12, '{foo,bar,baz}')::rtype; + r.ar[2] := 'replace'; + return r.ar; +end$$ +-- +FUNCTION: name="arrayassign1" function="arrayassign1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION arrayassign1() RETURNS text[] LANGUAGE plpgsql AS $$\ndeclare\n r record;\nbegin\n r..." +== 816 +-- truncate_limit: 100 +select arrayassign1() +-- +FUNCTION: name="arrayassign1" function="arrayassign1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT arrayassign1()" +== 817 +-- truncate_limit: 100 +select arrayassign1() +-- +FUNCTION: name="arrayassign1" function="arrayassign1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT arrayassign1()" +== 818 +-- truncate_limit: 100 +-- try again to exercise internal caching + +create domain orderedarray as int[2] + constraint sorted check (value[1] < value[2]) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN orderedarray AS int[2] CONSTRAINT sorted CHECK (value[1] < value[2])" +== 819 +-- truncate_limit: 100 +select '{1,2}'::orderedarray +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{1,2}'::orderedarray" +== 820 +-- truncate_limit: 100 +select '{2,1}'::orderedarray +-- +STMT: SelectStmt +TRUNCATED: "SELECT '{2,1}'::orderedarray" +== 821 +-- truncate_limit: 100 +-- fail + +create function testoa(x1 int, x2 int, x3 int) returns orderedarray +language plpgsql as $$ +declare res orderedarray; +begin + res := array[x1, x2]; + res[2] := x3; + return res; +end$$ +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testoa(x1 int, x2 int, x3 int) RETURNS orderedarray LANGUAGE plpgsql AS $$\ndeclar..." +== 822 +-- truncate_limit: 100 +select testoa(1,2,3) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testoa(1, 2, 3)" +== 823 +-- truncate_limit: 100 +select testoa(1,2,3) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testoa(1, 2, 3)" +== 824 +-- truncate_limit: 100 +-- try again to exercise internal caching +select testoa(2,1,3) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testoa(2, 1, 3)" +== 825 +-- truncate_limit: 100 +-- fail at initial assign +select testoa(1,2,1) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testoa(1, 2, 1)" +== 826 +-- truncate_limit: 100 +-- fail at update + +drop function arrayassign1() +-- +FUNCTION: name="arrayassign1" function="arrayassign1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION arrayassign1()" +== 827 +-- truncate_limit: 100 +drop function testoa(x1 int, x2 int, x3 int) +-- +FUNCTION: name="testoa" function="testoa" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION testoa(x1 int, x2 int, x3 int)" +== 828 +-- truncate_limit: 100 +|-- +-- Test handling of expanded arrays +|-- + +create function returns_rw_array(int) returns int[] +language plpgsql as $$ + declare r int[]; + begin r := array[$1, $1]; return r; end; +$$ stable +-- +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION returns_rw_array(int) RETURNS int[] LANGUAGE plpgsql AS $$\n declare r int[];\n b..." +== 829 +-- truncate_limit: 100 +create function consumes_rw_array(int[]) returns int +language plpgsql as $$ + begin return $1[1]; end; +$$ stable +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION consumes_rw_array(int[]) RETURNS int LANGUAGE plpgsql AS $$\n begin return $1[1];..." +== 830 +-- truncate_limit: 100 +select consumes_rw_array(returns_rw_array(42)) +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT consumes_rw_array(returns_rw_array(42))" +== 831 +-- truncate_limit: 100 +-- bug #14174 +explain (verbose, costs off) +select i, a from + (select returns_rw_array(1) as a offset 0) ss, + lateral consumes_rw_array(a) i +-- +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT i, a FROM (SELECT returns_rw_array(1) AS a OFFSET 0) ss, LATE..." +== 832 +-- truncate_limit: 100 +select i, a from + (select returns_rw_array(1) as a offset 0) ss, + lateral consumes_rw_array(a) i +-- +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i, a FROM (SELECT returns_rw_array(1) AS a OFFSET 0) ss, LATERAL consumes_rw_array(a) i" +== 833 +-- truncate_limit: 100 +explain (verbose, costs off) +select consumes_rw_array(a), a from returns_rw_array(1) a +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT consumes_rw_array(a), a FROM returns_rw_array(1) a" +== 834 +-- truncate_limit: 100 +select consumes_rw_array(a), a from returns_rw_array(1) a +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT consumes_rw_array(a), a FROM returns_rw_array(1) a" +== 835 +-- truncate_limit: 100 +explain (verbose, costs off) +select consumes_rw_array(a), a from + (values (returns_rw_array(1)), (returns_rw_array(2))) v(a) +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT consumes_rw_array(a), a FROM (VALUES (returns_rw_array(1)), (..." +== 836 +-- truncate_limit: 100 +select consumes_rw_array(a), a from + (values (returns_rw_array(1)), (returns_rw_array(2))) v(a) +-- +FUNCTION: name="consumes_rw_array" function="consumes_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +FUNCTION: name="returns_rw_array" function="returns_rw_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT consumes_rw_array(a), a FROM (VALUES (returns_rw_array(1)), (returns_rw_array(2))) v(a)" +== 837 +-- truncate_limit: 100 +do $$ +declare a int[] := array[1,2]; +begin + a := a || 3; + raise notice 'a = %', a; +end$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare a int[] := array[1,2];\nbegin\n a := a || 3;\n raise notice 'a = %', a;\nend$$" +== 838 +-- truncate_limit: 100 +|-- +-- Test access to call stack +|-- + +create function inner_func(int) +returns int as $$ +declare _context text; +begin + get diagnostics _context = pg_context; + raise notice '***%***', _context; + -- lets do it again, just for fun.. + get diagnostics _context = pg_context; + raise notice '***%***', _context; + raise notice 'lets make sure we didnt break anything'; + return 2 * $1; +end; +$$ language plpgsql +-- +FUNCTION: name="inner_func" function="inner_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION inner_func(int) RETURNS int AS $$\ndeclare _context text;\nbegin\n get diagnostics ..." +== 839 +-- truncate_limit: 100 +create or replace function outer_func(int) +returns int as $$ +declare + myresult int; +begin + raise notice 'calling down into inner_func()'; + myresult := inner_func($1); + raise notice 'inner_func() done'; + return myresult; +end; +$$ language plpgsql +-- +FUNCTION: name="outer_func" function="outer_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION outer_func(int) RETURNS int AS $$\ndeclare\n myresult int;\nbegin\n rais..." +== 840 +-- truncate_limit: 100 +create or replace function outer_outer_func(int) +returns int as $$ +declare + myresult int; +begin + raise notice 'calling down into outer_func()'; + myresult := outer_func($1); + raise notice 'outer_func() done'; + return myresult; +end; +$$ language plpgsql +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION outer_outer_func(int) RETURNS int AS $$\ndeclare\n myresult int;\nbegin\n..." +== 841 +-- truncate_limit: 100 +select outer_outer_func(10) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT outer_outer_func(10)" +== 842 +-- truncate_limit: 100 +-- repeated call should work +select outer_outer_func(20) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT outer_outer_func(20)" +== 843 +-- truncate_limit: 100 +drop function outer_outer_func(int) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION outer_outer_func(int)" +== 844 +-- truncate_limit: 100 +drop function outer_func(int) +-- +FUNCTION: name="outer_func" function="outer_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION outer_func(int)" +== 845 +-- truncate_limit: 100 +drop function inner_func(int) +-- +FUNCTION: name="inner_func" function="inner_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION inner_func(int)" +== 846 +-- truncate_limit: 100 +-- access to call stack from exception +create function inner_func(int) +returns int as $$ +declare + _context text; + sx int := 5; +begin + begin + perform sx / 0; + exception + when division_by_zero then + get diagnostics _context = pg_context; + raise notice '***%***', _context; + end; + + -- lets do it again, just for fun.. + get diagnostics _context = pg_context; + raise notice '***%***', _context; + raise notice 'lets make sure we didnt break anything'; + return 2 * $1; +end; +$$ language plpgsql +-- +FUNCTION: name="inner_func" function="inner_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION inner_func(int) RETURNS int AS $$\ndeclare\n _context text;\n sx int := 5;\nbegin\n ..." +== 847 +-- truncate_limit: 100 +create or replace function outer_func(int) +returns int as $$ +declare + myresult int; +begin + raise notice 'calling down into inner_func()'; + myresult := inner_func($1); + raise notice 'inner_func() done'; + return myresult; +end; +$$ language plpgsql +-- +FUNCTION: name="outer_func" function="outer_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION outer_func(int) RETURNS int AS $$\ndeclare\n myresult int;\nbegin\n rais..." +== 848 +-- truncate_limit: 100 +create or replace function outer_outer_func(int) +returns int as $$ +declare + myresult int; +begin + raise notice 'calling down into outer_func()'; + myresult := outer_func($1); + raise notice 'outer_func() done'; + return myresult; +end; +$$ language plpgsql +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION outer_outer_func(int) RETURNS int AS $$\ndeclare\n myresult int;\nbegin\n..." +== 849 +-- truncate_limit: 100 +select outer_outer_func(10) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT outer_outer_func(10)" +== 850 +-- truncate_limit: 100 +-- repeated call should work +select outer_outer_func(20) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT outer_outer_func(20)" +== 851 +-- truncate_limit: 100 +drop function outer_outer_func(int) +-- +FUNCTION: name="outer_outer_func" function="outer_outer_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION outer_outer_func(int)" +== 852 +-- truncate_limit: 100 +drop function outer_func(int) +-- +FUNCTION: name="outer_func" function="outer_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION outer_func(int)" +== 853 +-- truncate_limit: 100 +drop function inner_func(int) +-- +FUNCTION: name="inner_func" function="inner_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION inner_func(int)" +== 854 +-- truncate_limit: 100 +-- Test pg_routine_oid +create function current_function(text) +returns regprocedure as $$ +declare + fn_oid regprocedure; +begin + get diagnostics fn_oid = pg_routine_oid; + return fn_oid; +end; +$$ language plpgsql +-- +FUNCTION: name="current_function" function="current_function" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION current_function(text) RETURNS regprocedure AS $$\ndeclare\n fn_oid regprocedure;\n..." +== 855 +-- truncate_limit: 100 +select current_function('foo') +-- +FUNCTION: name="current_function" function="current_function" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_function('foo')" +== 856 +-- truncate_limit: 100 +drop function current_function(text) +-- +FUNCTION: name="current_function" function="current_function" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION current_function(text)" +== 857 +-- truncate_limit: 100 +-- shouldn't fail in DO, even though there's no useful data +do $$ +declare + fn_oid oid; +begin + get diagnostics fn_oid = pg_routine_oid; + raise notice 'pg_routine_oid = %', fn_oid; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare\n fn_oid oid;\nbegin\n get diagnostics fn_oid = pg_routine_oid;\n raise notice 'pg_r..." +== 858 +-- truncate_limit: 100 +|-- +-- Test ASSERT +|-- + +do $$ +begin + assert 1=1; -- should succeed +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nbegin\n assert 1=1; -- should succeed\nend;\n$$" +== 859 +-- truncate_limit: 100 +do $$ +begin + assert 1=0; -- should fail +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nbegin\n assert 1=0; -- should fail\nend;\n$$" +== 860 +-- truncate_limit: 100 +do $$ +begin + assert NULL; -- should fail +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nbegin\n assert NULL; -- should fail\nend;\n$$" +== 861 +-- truncate_limit: 100 +-- check controlling GUC +set plpgsql.check_asserts = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET \"plpgsql.check_asserts\" TO OFF" +== 862 +-- truncate_limit: 100 +do $$ +begin + assert 1=0; -- won't be tested +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nbegin\n assert 1=0; -- won't be tested\nend;\n$$" +== 863 +-- truncate_limit: 100 +reset plpgsql.check_asserts +-- +STMT: VariableSetStmt +TRUNCATED: "RESET \"plpgsql.check_asserts\"" +== 864 +-- truncate_limit: 100 +-- test custom message +do $$ +declare var text := 'some value'; +begin + assert 1=0, format('assertion failed, var = "%s"', var); +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare var text := 'some value';\nbegin\n assert 1=0, format('assertion failed, var = \"%s\"'..." +== 865 +-- truncate_limit: 100 +-- ensure assertions are not trapped by 'others' +do $$ +begin + assert 1=0, 'unhandled assertion'; +exception when others then + null; -- do nothing +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nbegin\n assert 1=0, 'unhandled assertion';\nexception when others then\n null; -- do nothing..." +== 866 +-- truncate_limit: 100 +-- Test use of plpgsql in a domain check constraint (cf. bug #14414) + +create function plpgsql_domain_check(val int) returns boolean as $$ +begin return val > 0; end +$$ language plpgsql immutable +-- +FUNCTION: name="plpgsql_domain_check" function="plpgsql_domain_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION plpgsql_domain_check(val int) RETURNS boolean AS $$\nbegin return val > 0; end\n$$ ..." +== 867 +-- truncate_limit: 100 +create domain plpgsql_domain as integer check(plpgsql_domain_check(value)) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN plpgsql_domain AS int CHECK (plpgsql_domain_check(value))" +== 868 +-- truncate_limit: 100 +do $$ +declare v_test plpgsql_domain; +begin + v_test := 1; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare v_test plpgsql_domain;\nbegin\n v_test := 1;\nend;\n$$" +== 869 +-- truncate_limit: 100 +do $$ +declare v_test plpgsql_domain := 1; +begin + v_test := 0; -- fail +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare v_test plpgsql_domain := 1;\nbegin\n v_test := 0; -- fail\nend;\n$$" +== 870 +-- truncate_limit: 100 +-- Test handling of expanded array passed to a domain constraint (bug #14472) + +create function plpgsql_arr_domain_check(val int[]) returns boolean as $$ +begin return val[1] > 0; end +$$ language plpgsql immutable +-- +FUNCTION: name="plpgsql_arr_domain_check" function="plpgsql_arr_domain_check" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION plpgsql_arr_domain_check(val int[]) RETURNS boolean AS $$\nbegin return val[1] > 0..." +== 871 +-- truncate_limit: 100 +create domain plpgsql_arr_domain as int[] check(plpgsql_arr_domain_check(value)) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN plpgsql_arr_domain AS int[] CHECK (plpgsql_arr_domain_check(value))" +== 872 +-- truncate_limit: 100 +do $$ +declare v_test plpgsql_arr_domain; +begin + v_test := array[1]; + v_test := v_test || 2; +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare v_test plpgsql_arr_domain;\nbegin\n v_test := array[1];\n v_test := v_test || 2;\nend..." +== 873 +-- truncate_limit: 100 +do $$ +declare v_test plpgsql_arr_domain := array[1]; +begin + v_test := 0 || v_test; -- fail +end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\ndeclare v_test plpgsql_arr_domain := array[1];\nbegin\n v_test := 0 || v_test; -- fail\nend;\n$$" +== 874 +-- truncate_limit: 100 +|-- +-- test usage of transition tables in AFTER triggers +|-- + +CREATE TABLE transition_table_base (id int PRIMARY KEY, val text) +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE transition_table_base (id int PRIMARY KEY, val text)" +== 875 +-- truncate_limit: 100 +CREATE FUNCTION transition_table_base_ins_func() + RETURNS trigger + LANGUAGE plpgsql +AS $$ +DECLARE + t text; + l text; +BEGIN + t = ''; + FOR l IN EXECUTE + $q$ + EXPLAIN (TIMING off, COSTS off, VERBOSE on) + SELECT * FROM newtable + $q$ LOOP + t = t || l || E'\n'; + END LOOP; + + RAISE INFO '%', t; + RETURN new; +END; +$$ +-- +FUNCTION: name="transition_table_base_ins_func" function="transition_table_base_ins_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION transition_table_base_ins_func() RETURNS trigger LANGUAGE plpgsql AS $$\nDECLARE\n ..." +== 876 +-- truncate_limit: 100 +CREATE TRIGGER transition_table_base_ins_trig + AFTER INSERT ON transition_table_base + REFERENCING OLD TABLE AS oldtable NEW TABLE AS newtable + FOR EACH STATEMENT + EXECUTE PROCEDURE transition_table_base_ins_func() +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER transition_table_base_ins_trig AFTER INSERT ON transition_table_base REFERENCING O..." +== 877 +-- truncate_limit: 100 +CREATE TRIGGER transition_table_base_ins_trig + AFTER INSERT ON transition_table_base + REFERENCING NEW TABLE AS newtable + FOR EACH STATEMENT + EXECUTE PROCEDURE transition_table_base_ins_func() +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER transition_table_base_ins_trig AFTER INSERT ON transition_table_base REFERENCING N..." +== 878 +-- truncate_limit: 100 +INSERT INTO transition_table_base VALUES (1, 'One'), (2, 'Two') +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO transition_table_base VALUES (1, 'One'), (2, 'Two')" +== 879 +-- truncate_limit: 100 +INSERT INTO transition_table_base VALUES (3, 'Three'), (4, 'Four') +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO transition_table_base VALUES (3, 'Three'), (4, 'Four')" +== 880 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION transition_table_base_upd_func() + RETURNS trigger + LANGUAGE plpgsql +AS $$ +DECLARE + t text; + l text; +BEGIN + t = ''; + FOR l IN EXECUTE + $q$ + EXPLAIN (TIMING off, COSTS off, VERBOSE on) + SELECT * FROM oldtable ot FULL JOIN newtable nt USING (id) + $q$ LOOP + t = t || l || E'\n'; + END LOOP; + + RAISE INFO '%', t; + RETURN new; +END; +$$ +-- +FUNCTION: name="transition_table_base_upd_func" function="transition_table_base_upd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION transition_table_base_upd_func() RETURNS trigger LANGUAGE plpgsql AS $..." +== 881 +-- truncate_limit: 100 +CREATE TRIGGER transition_table_base_upd_trig + AFTER UPDATE ON transition_table_base + REFERENCING OLD TABLE AS oldtable NEW TABLE AS newtable + FOR EACH STATEMENT + EXECUTE PROCEDURE transition_table_base_upd_func() +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER transition_table_base_upd_trig AFTER UPDATE ON transition_table_base REFERENCING O..." +== 882 +-- truncate_limit: 100 +UPDATE transition_table_base + SET val = '*' || val || '*' + WHERE id BETWEEN 2 AND 3 +-- +TABLE: name="transition_table_base" schema="" table="transition_table_base" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE transition_table_base SET val = ('*' || val) || '*' WHERE id BETWEEN 2 AND 3" +== 883 +-- truncate_limit: 100 +CREATE TABLE transition_table_level1 +( + level1_no serial NOT NULL , + level1_node_name varchar(255), + PRIMARY KEY (level1_no) +) WITHOUT OIDS +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE transition_table_level1 (level1_no serial NOT NULL, level1_node_name varchar(255), P..." +== 884 +-- truncate_limit: 100 +CREATE TABLE transition_table_level2 +( + level2_no serial NOT NULL , + parent_no int NOT NULL, + level1_node_name varchar(255), + PRIMARY KEY (level2_no) +) WITHOUT OIDS +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE transition_table_level2 (level2_no serial NOT NULL, parent_no int NOT NULL, level1_n..." +== 885 +-- truncate_limit: 100 +CREATE TABLE transition_table_status +( + level int NOT NULL, + node_no int NOT NULL, + status int, + PRIMARY KEY (level, node_no) +) WITHOUT OIDS +-- +TABLE: name="transition_table_status" schema="" table="transition_table_status" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE transition_table_status (level int NOT NULL, node_no int NOT NULL, status int, PRIMA..." +== 886 +-- truncate_limit: 100 +CREATE FUNCTION transition_table_level1_ri_parent_del_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ + DECLARE n bigint; + BEGIN + PERFORM FROM p JOIN transition_table_level2 c ON c.parent_no = p.level1_no; + IF FOUND THEN + RAISE EXCEPTION 'RI error'; + END IF; + RETURN NULL; + END; +$$ +-- +FUNCTION: name="transition_table_level1_ri_parent_del_func" function="transition_table_level1_ri_parent_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION transition_table_level1_ri_parent_del_func() RETURNS trigger LANGUAGE plpgsql AS ..." +== 887 +-- truncate_limit: 100 +CREATE TRIGGER transition_table_level1_ri_parent_del_trigger + AFTER DELETE ON transition_table_level1 + REFERENCING OLD TABLE AS p + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level1_ri_parent_del_func() +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER transition_table_level1_ri_parent_del_trigger AFTER DELETE ON transition_table_lev..." +== 888 +-- truncate_limit: 100 +CREATE FUNCTION transition_table_level1_ri_parent_upd_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ + DECLARE + x int; + BEGIN + WITH p AS (SELECT level1_no, sum(delta) cnt + FROM (SELECT level1_no, 1 AS delta FROM i + UNION ALL + SELECT level1_no, -1 AS delta FROM d) w + GROUP BY level1_no + HAVING sum(delta) < 0) + SELECT level1_no + FROM p JOIN transition_table_level2 c ON c.parent_no = p.level1_no + INTO x; + IF FOUND THEN + RAISE EXCEPTION 'RI error'; + END IF; + RETURN NULL; + END; +$$ +-- +FUNCTION: name="transition_table_level1_ri_parent_upd_func" function="transition_table_level1_ri_parent_upd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION transition_table_level1_ri_parent_upd_func() RETURNS trigger LANGUAGE plpgsql AS ..." +== 889 +-- truncate_limit: 100 +CREATE TRIGGER transition_table_level1_ri_parent_upd_trigger + AFTER UPDATE ON transition_table_level1 + REFERENCING OLD TABLE AS d NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level1_ri_parent_upd_func() +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER transition_table_level1_ri_parent_upd_trigger AFTER UPDATE ON transition_table_lev..." +== 890 +-- truncate_limit: 100 +CREATE FUNCTION transition_table_level2_ri_child_insupd_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ + BEGIN + PERFORM FROM i + LEFT JOIN transition_table_level1 p + ON p.level1_no IS NOT NULL AND p.level1_no = i.parent_no + WHERE p.level1_no IS NULL; + IF FOUND THEN + RAISE EXCEPTION 'RI error'; + END IF; + RETURN NULL; + END; +$$ +-- +FUNCTION: name="transition_table_level2_ri_child_insupd_func" function="transition_table_level2_ri_child_insupd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION transition_table_level2_ri_child_insupd_func() RETURNS trigger LANGUAGE plpgsql A..." +== 891 +-- truncate_limit: 100 +CREATE TRIGGER transition_table_level2_ri_child_ins_trigger + AFTER INSERT ON transition_table_level2 + REFERENCING NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level2_ri_child_insupd_func() +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER transition_table_level2_ri_child_ins_trigger AFTER INSERT ON transition_table_leve..." +== 892 +-- truncate_limit: 100 +CREATE TRIGGER transition_table_level2_ri_child_upd_trigger + AFTER UPDATE ON transition_table_level2 + REFERENCING NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level2_ri_child_insupd_func() +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER transition_table_level2_ri_child_upd_trigger AFTER UPDATE ON transition_table_leve..." +== 893 +-- truncate_limit: 100 +-- create initial test data +INSERT INTO transition_table_level1 (level1_no) + SELECT generate_series(1,200) +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO transition_table_level1 (level1_no) SELECT generate_series(1, 200)" +== 894 +-- truncate_limit: 100 +ANALYZE transition_table_level1 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE transition_table_level1" +== 895 +-- truncate_limit: 100 +INSERT INTO transition_table_level2 (level2_no, parent_no) + SELECT level2_no, level2_no / 50 + 1 AS parent_no + FROM generate_series(1,9999) level2_no +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO transition_table_level2 (...) SELECT ... FROM generate_series(1, 9999) level2_no" +== 896 +-- truncate_limit: 100 +ANALYZE transition_table_level2 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE transition_table_level2" +== 897 +-- truncate_limit: 100 +INSERT INTO transition_table_status (level, node_no, status) + SELECT 1, level1_no, 0 FROM transition_table_level1 +-- +TABLE: name="transition_table_status" schema="" table="transition_table_status" ctx=DML +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO transition_table_status (level, node_no, status) SELECT ... FROM transition_table_level1" +== 898 +-- truncate_limit: 100 +INSERT INTO transition_table_status (level, node_no, status) + SELECT 2, level2_no, 0 FROM transition_table_level2 +-- +TABLE: name="transition_table_status" schema="" table="transition_table_status" ctx=DML +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO transition_table_status (level, node_no, status) SELECT ... FROM transition_table_level2" +== 899 +-- truncate_limit: 100 +ANALYZE transition_table_status +-- +TABLE: name="transition_table_status" schema="" table="transition_table_status" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE transition_table_status" +== 900 +-- truncate_limit: 100 +INSERT INTO transition_table_level1(level1_no) + SELECT generate_series(201,1000) +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO transition_table_level1 (level1_no) SELECT generate_series(201, 1000)" +== 901 +-- truncate_limit: 100 +ANALYZE transition_table_level1 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE transition_table_level1" +== 902 +-- truncate_limit: 100 +-- behave reasonably if someone tries to modify a transition table +CREATE FUNCTION transition_table_level2_bad_usage_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ + BEGIN + INSERT INTO dx VALUES (1000000, 1000000, 'x'); + RETURN NULL; + END; +$$ +-- +FUNCTION: name="transition_table_level2_bad_usage_func" function="transition_table_level2_bad_usage_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION transition_table_level2_bad_usage_func() RETURNS trigger LANGUAGE plpgsql AS $$\n ..." +== 903 +-- truncate_limit: 100 +CREATE TRIGGER transition_table_level2_bad_usage_trigger + AFTER DELETE ON transition_table_level2 + REFERENCING OLD TABLE AS dx + FOR EACH STATEMENT EXECUTE PROCEDURE + transition_table_level2_bad_usage_func() +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER transition_table_level2_bad_usage_trigger AFTER DELETE ON transition_table_level2 ..." +== 904 +-- truncate_limit: 100 +DELETE FROM transition_table_level2 + WHERE level2_no BETWEEN 301 AND 305 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM transition_table_level2 WHERE level2_no BETWEEN 301 AND 305" +== 905 +-- truncate_limit: 100 +DROP TRIGGER transition_table_level2_bad_usage_trigger + ON transition_table_level2 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER transition_table_level2_bad_usage_trigger ON transition_table_level2" +== 906 +-- truncate_limit: 100 +-- attempt modifications which would break RI (should all fail) +DELETE FROM transition_table_level1 + WHERE level1_no = 25 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM transition_table_level1 WHERE level1_no = 25" +== 907 +-- truncate_limit: 100 +UPDATE transition_table_level1 SET level1_no = -1 + WHERE level1_no = 30 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE transition_table_level1 SET level1_no = -1 WHERE level1_no = 30" +== 908 +-- truncate_limit: 100 +INSERT INTO transition_table_level2 (level2_no, parent_no) + VALUES (10000, 10000) +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO transition_table_level2 (level2_no, parent_no) VALUES (10000, 10000)" +== 909 +-- truncate_limit: 100 +UPDATE transition_table_level2 SET parent_no = 2000 + WHERE level2_no = 40 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE transition_table_level2 SET parent_no = 2000 WHERE level2_no = 40" +== 910 +-- truncate_limit: 100 +-- attempt modifications which would not break RI (should all succeed) +DELETE FROM transition_table_level1 + WHERE level1_no BETWEEN 201 AND 1000 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM transition_table_level1 WHERE level1_no BETWEEN 201 AND 1000" +== 911 +-- truncate_limit: 100 +DELETE FROM transition_table_level1 + WHERE level1_no BETWEEN 100000000 AND 100000010 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM transition_table_level1 WHERE level1_no BETWEEN 100000000 AND 100000010" +== 912 +-- truncate_limit: 100 +SELECT count(*) FROM transition_table_level1 +-- +TABLE: name="transition_table_level1" schema="" table="transition_table_level1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM transition_table_level1" +== 913 +-- truncate_limit: 100 +DELETE FROM transition_table_level2 + WHERE level2_no BETWEEN 211 AND 220 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM transition_table_level2 WHERE level2_no BETWEEN 211 AND 220" +== 914 +-- truncate_limit: 100 +SELECT count(*) FROM transition_table_level2 +-- +TABLE: name="transition_table_level2" schema="" table="transition_table_level2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM transition_table_level2" +== 915 +-- truncate_limit: 100 +CREATE TABLE alter_table_under_transition_tables +( + id int PRIMARY KEY, + name text +) +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE alter_table_under_transition_tables (id int PRIMARY KEY, name text)" +== 916 +-- truncate_limit: 100 +CREATE FUNCTION alter_table_under_transition_tables_upd_func() + RETURNS TRIGGER + LANGUAGE plpgsql +AS $$ +BEGIN + RAISE WARNING 'old table = %, new table = %', + (SELECT string_agg(id || '=' || name, ',') FROM d), + (SELECT string_agg(id || '=' || name, ',') FROM i); + RAISE NOTICE 'one = %', (SELECT 1 FROM alter_table_under_transition_tables LIMIT 1); + RETURN NULL; +END; +$$ +-- +FUNCTION: name="alter_table_under_transition_tables_upd_func" function="alter_table_under_transition_tables_upd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION alter_table_under_transition_tables_upd_func() RETURNS trigger LANGUAGE plpgsql A..." +== 917 +-- truncate_limit: 100 +-- should fail, TRUNCATE is not compatible with transition tables +CREATE TRIGGER alter_table_under_transition_tables_upd_trigger + AFTER TRUNCATE OR UPDATE ON alter_table_under_transition_tables + REFERENCING OLD TABLE AS d NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + alter_table_under_transition_tables_upd_func() +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER alter_table_under_transition_tables_upd_trigger AFTER UPDATE OR TRUNCATE ON alter_..." +== 918 +-- truncate_limit: 100 +-- should work +CREATE TRIGGER alter_table_under_transition_tables_upd_trigger + AFTER UPDATE ON alter_table_under_transition_tables + REFERENCING OLD TABLE AS d NEW TABLE AS i + FOR EACH STATEMENT EXECUTE PROCEDURE + alter_table_under_transition_tables_upd_func() +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER alter_table_under_transition_tables_upd_trigger AFTER UPDATE ON alter_table_under_..." +== 919 +-- truncate_limit: 100 +INSERT INTO alter_table_under_transition_tables + VALUES (1, '1'), (2, '2'), (3, '3') +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO alter_table_under_transition_tables VALUES (1, '1'), (2, '2'), (3, '3')" +== 920 +-- truncate_limit: 100 +UPDATE alter_table_under_transition_tables + SET name = name || name +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE alter_table_under_transition_tables SET name = name || name" +== 921 +-- truncate_limit: 100 +-- now change 'name' to an integer to see what happens... +ALTER TABLE alter_table_under_transition_tables + ALTER COLUMN name TYPE int USING name::integer +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alter_table_under_transition_tables ALTER COLUMN name TYPE int USING name::int" +== 922 +-- truncate_limit: 100 +UPDATE alter_table_under_transition_tables + SET name = (name::text || name::text)::integer +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE alter_table_under_transition_tables SET name = (name::text || name::text)::int" +== 923 +-- truncate_limit: 100 +-- now drop column 'name' +ALTER TABLE alter_table_under_transition_tables + DROP column name +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE alter_table_under_transition_tables DROP name" +== 924 +-- truncate_limit: 100 +UPDATE alter_table_under_transition_tables + SET id = id +-- +TABLE: name="alter_table_under_transition_tables" schema="" table="alter_table_under_transition_tables" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE alter_table_under_transition_tables SET id = id" +== 925 +-- truncate_limit: 100 +|-- +-- Test multiple reference to a transition table +|-- + +CREATE TABLE multi_test (i int) +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE multi_test (i int)" +== 926 +-- truncate_limit: 100 +INSERT INTO multi_test VALUES (1) +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO multi_test VALUES (1)" +== 927 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION multi_test_trig() RETURNS trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'count = %', (SELECT COUNT(*) FROM new_test); + RAISE NOTICE 'count union = %', + (SELECT COUNT(*) + FROM (SELECT * FROM new_test UNION ALL SELECT * FROM new_test) ss); + RETURN NULL; +END$$ +-- +FUNCTION: name="multi_test_trig" function="multi_test_trig" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION multi_test_trig() RETURNS trigger LANGUAGE plpgsql AS $$\nBEGIN\n RAI..." +== 928 +-- truncate_limit: 100 +CREATE TRIGGER my_trigger AFTER UPDATE ON multi_test + REFERENCING NEW TABLE AS new_test OLD TABLE as old_test + FOR EACH STATEMENT EXECUTE PROCEDURE multi_test_trig() +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_trigger AFTER UPDATE ON multi_test REFERENCING NEW TABLE new_test OLD TABLE old..." +== 929 +-- truncate_limit: 100 +UPDATE multi_test SET i = i +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE multi_test SET i = i" +== 930 +-- truncate_limit: 100 +DROP TABLE multi_test +-- +TABLE: name="multi_test" schema="" table="multi_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE multi_test" +== 931 +-- truncate_limit: 100 +DROP FUNCTION multi_test_trig() +-- +FUNCTION: name="multi_test_trig" function="multi_test_trig" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION multi_test_trig()" +== 932 +-- truncate_limit: 100 +|-- +-- Check type parsing and record fetching from partitioned tables +|-- + +CREATE TABLE partitioned_table (a int, b text) PARTITION BY LIST (a) +-- +TABLE: name="partitioned_table" schema="" table="partitioned_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE partitioned_table (a int, b text) PARTITION BY LIST (a)" +== 933 +-- truncate_limit: 100 +CREATE TABLE pt_part1 PARTITION OF partitioned_table FOR VALUES IN (1) +-- +TABLE: name="pt_part1" schema="" table="pt_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt_part1 PARTITION OF partitioned_table FOR VALUES IN (1)" +== 934 +-- truncate_limit: 100 +CREATE TABLE pt_part2 PARTITION OF partitioned_table FOR VALUES IN (2) +-- +TABLE: name="pt_part2" schema="" table="pt_part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pt_part2 PARTITION OF partitioned_table FOR VALUES IN (2)" +== 935 +-- truncate_limit: 100 +INSERT INTO partitioned_table VALUES (1, 'Row 1') +-- +TABLE: name="partitioned_table" schema="" table="partitioned_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO partitioned_table VALUES (1, 'Row 1')" +== 936 +-- truncate_limit: 100 +INSERT INTO partitioned_table VALUES (2, 'Row 2') +-- +TABLE: name="partitioned_table" schema="" table="partitioned_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO partitioned_table VALUES (2, 'Row 2')" +== 937 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION get_from_partitioned_table(partitioned_table.a%type) +RETURNS partitioned_table AS $$ +DECLARE + a_val partitioned_table.a%TYPE; + result partitioned_table%ROWTYPE; +BEGIN + a_val := $1; + SELECT * INTO result FROM partitioned_table WHERE a = a_val; + RETURN result; +END; $$ LANGUAGE plpgsql +-- +FUNCTION: name="get_from_partitioned_table" function="get_from_partitioned_table" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION get_from_partitioned_table(partitioned_table.a%type) RETURNS partition..." +== 938 +-- truncate_limit: 100 +SELECT * FROM get_from_partitioned_table(1) AS t +-- +FUNCTION: name="get_from_partitioned_table" function="get_from_partitioned_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM get_from_partitioned_table(1) t" +== 939 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION list_partitioned_table() +RETURNS SETOF public.partitioned_table.a%TYPE AS $$ +DECLARE + row public.partitioned_table%ROWTYPE; + a_val public.partitioned_table.a%TYPE; +BEGIN + FOR row IN SELECT * FROM public.partitioned_table ORDER BY a LOOP + a_val := row.a; + RETURN NEXT a_val; + END LOOP; + RETURN; +END; $$ LANGUAGE plpgsql +-- +FUNCTION: name="list_partitioned_table" function="list_partitioned_table" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION list_partitioned_table() RETURNS SETOF public.partitioned_table.a%type..." +== 940 +-- truncate_limit: 100 +SELECT * FROM list_partitioned_table() AS t +-- +FUNCTION: name="list_partitioned_table" function="list_partitioned_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM list_partitioned_table() t" +== 941 +-- truncate_limit: 100 +|-- +-- Check argument name is used instead of $n in error message +|-- +CREATE FUNCTION fx(x WSlot) RETURNS void AS $$ +BEGIN + GET DIAGNOSTICS x = ROW_COUNT; + RETURN; +END; $$ LANGUAGE plpgsql +-- +FUNCTION: name="fx" function="fx" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fx(x wslot) RETURNS void AS $$\nBEGIN\n GET DIAGNOSTICS x = ROW_COUNT;\n RETURN;\nE..." diff --git a/parser/testdata/summary_truncate/postgres_regress/point.metadata.json b/parser/testdata/summary_truncate/postgres_regress/point.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/point.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/point.test b/parser/testdata/summary_truncate/postgres_regress/point.test new file mode 100644 index 0000000..4796b85 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/point.test @@ -0,0 +1,394 @@ +== 001 +-- truncate_limit: 100 +|-- +-- POINT +|-- + +-- avoid bit-exact output here because operations may not be bit-exact. +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO 0" +== 002 +-- truncate_limit: 100 +-- point_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. + +INSERT INTO POINT_TBL(f1) VALUES ('asdfasdf') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1) VALUES ('asdfasdf')" +== 003 +-- truncate_limit: 100 +INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1) VALUES ('(10.0 10.0)')" +== 004 +-- truncate_limit: 100 +INSERT INTO POINT_TBL(f1) VALUES ('(10.0, 10.0) x') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1) VALUES ('(10.0, 10.0) x')" +== 005 +-- truncate_limit: 100 +INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1) VALUES ('(10.0,10.0')" +== 006 +-- truncate_limit: 100 +INSERT INTO POINT_TBL(f1) VALUES ('(10.0, 1e+500)') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1) VALUES ('(10.0, 1e+500)')" +== 007 +-- truncate_limit: 100 +-- Out of range + + +SELECT * FROM POINT_TBL +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM point_tbl" +== 008 +-- truncate_limit: 100 +-- left of +SELECT p.* FROM POINT_TBL p WHERE p.f1 << '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE p.f1 << '(0.0, 0.0)'" +== 009 +-- truncate_limit: 100 +-- right of +SELECT p.* FROM POINT_TBL p WHERE '(0.0,0.0)' >> p.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE '(0.0,0.0)' >> p.f1" +== 010 +-- truncate_limit: 100 +-- above +SELECT p.* FROM POINT_TBL p WHERE '(0.0,0.0)' |>> p.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE '(0.0,0.0)' |>> p.f1" +== 011 +-- truncate_limit: 100 +-- below +SELECT p.* FROM POINT_TBL p WHERE p.f1 <<| '(0.0, 0.0)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE p.f1 <<| '(0.0, 0.0)'" +== 012 +-- truncate_limit: 100 +-- equal +SELECT p.* FROM POINT_TBL p WHERE p.f1 ~= '(5.1, 34.5)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE p.f1 ~= '(5.1, 34.5)'" +== 013 +-- truncate_limit: 100 +-- point in box +SELECT p.* FROM POINT_TBL p + WHERE p.f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE p.f1 <@ '(0,0,100,100)'::box" +== 014 +-- truncate_limit: 100 +SELECT p.* FROM POINT_TBL p + WHERE box '(0,0,100,100)' @> p.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE '(0,0,100,100)'::box @> p.f1" +== 015 +-- truncate_limit: 100 +SELECT p.* FROM POINT_TBL p + WHERE not p.f1 <@ box '(0,0,100,100)' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE NOT p.f1 <@ '(0,0,100,100)'::box" +== 016 +-- truncate_limit: 100 +SELECT p.* FROM POINT_TBL p + WHERE p.f1 <@ path '[(0,0),(-10,0),(-10,10)]' +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE p.f1 <@ '[(0,0),(-10,0),(-10,10)]'::path" +== 017 +-- truncate_limit: 100 +SELECT p.* FROM POINT_TBL p + WHERE not box '(0,0,100,100)' @> p.f1 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +FILTER: schema="" table="p" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p.* FROM point_tbl p WHERE NOT '(0,0,100,100)'::box @> p.f1" +== 018 +-- truncate_limit: 100 +SELECT p.f1, p.f1 <-> point '(0,0)' AS dist + FROM POINT_TBL p + ORDER BY dist +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT p.f1, p.f1 <-> point '(0,0)' AS dist FROM point_tbl p ORDER BY dist" +== 019 +-- truncate_limit: 100 +SELECT p1.f1 AS point1, p2.f1 AS point2, p1.f1 <-> p2.f1 AS dist + FROM POINT_TBL p1, POINT_TBL p2 + ORDER BY dist, p1.f1[0], p2.f1[0] +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM point_tbl p1, point_tbl p2 ORDER BY dist, p1.f1[0], p2.f1[0]" +== 020 +-- truncate_limit: 100 +SELECT p1.f1 AS point1, p2.f1 AS point2 + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT p1.f1 AS point1, p2.f1 AS point2 FROM point_tbl p1, point_tbl p2 WHERE (p1.f1 <-> p2.f1) > 3" +== 021 +-- truncate_limit: 100 +-- put distance result into output to allow sorting with GEQ optimizer - tgl 97/05/10 +SELECT p1.f1 AS point1, p2.f1 AS point2, (p1.f1 <-> p2.f1) AS distance + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1 + ORDER BY distance, p1.f1[0], p2.f1[0] +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM point_tbl p1, point_tbl p2 WHERE ... ORDER BY distance, p1.f1[0], p2.f1[0]" +== 022 +-- truncate_limit: 100 +-- put distance result into output to allow sorting with GEQ optimizer - tgl 97/05/10 +SELECT p1.f1 AS point1, p2.f1 AS point2, (p1.f1 <-> p2.f1) AS distance + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1 and p1.f1 |>> p2.f1 + ORDER BY distance +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=Select +ALIAS: "p1"="point_tbl" +ALIAS: "p2"="point_tbl" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +FILTER: schema="" table="p1" column="f1" +FILTER: schema="" table="p2" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM point_tbl p1, point_tbl p2 WHERE ... ORDER BY distance" +== 023 +-- truncate_limit: 100 +-- Test that GiST indexes provide same behavior as sequential scan +CREATE TEMP TABLE point_gist_tbl(f1 point) +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE point_gist_tbl (f1 point)" +== 024 +-- truncate_limit: 100 +INSERT INTO point_gist_tbl SELECT '(0,0)' FROM generate_series(0,1000) +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_gist_tbl SELECT '(0,0)' FROM generate_series(0, 1000)" +== 025 +-- truncate_limit: 100 +CREATE INDEX point_gist_tbl_index ON point_gist_tbl USING gist (f1) +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX point_gist_tbl_index ON point_gist_tbl USING gist (f1)" +== 026 +-- truncate_limit: 100 +INSERT INTO point_gist_tbl VALUES ('(0.0000009,0.0000009)') +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_gist_tbl VALUES ('(0.0000009,0.0000009)')" +== 027 +-- truncate_limit: 100 +SET enable_seqscan TO true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO TRUE" +== 028 +-- truncate_limit: 100 +SET enable_indexscan TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO FALSE" +== 029 +-- truncate_limit: 100 +SET enable_bitmapscan TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO FALSE" +== 030 +-- truncate_limit: 100 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000009,0.0000009)'::point +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000009,0.0000009)'::point" +== 031 +-- truncate_limit: 100 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 <@ '(0.0000009,0.0000009),(0.0000009,0.0000009)'::box +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_gist_tbl WHERE f1 <@ '(0.0000009,0.0000009),(0.0000009,0.0000009)'::box" +== 032 +-- truncate_limit: 100 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point" +== 033 +-- truncate_limit: 100 +SET enable_seqscan TO false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO FALSE" +== 034 +-- truncate_limit: 100 +SET enable_indexscan TO true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO TRUE" +== 035 +-- truncate_limit: 100 +SET enable_bitmapscan TO true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO TRUE" +== 036 +-- truncate_limit: 100 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000009,0.0000009)'::point +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000009,0.0000009)'::point" +== 037 +-- truncate_limit: 100 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 <@ '(0.0000009,0.0000009),(0.0000009,0.0000009)'::box +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_gist_tbl WHERE f1 <@ '(0.0000009,0.0000009),(0.0000009,0.0000009)'::box" +== 038 +-- truncate_limit: 100 +SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point +-- +TABLE: name="point_gist_tbl" schema="" table="point_gist_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point" +== 039 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 040 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 041 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 042 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('1,y', 'point') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('1,y', 'point')" +== 043 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('1,y', 'point') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('1,y', 'point')" diff --git a/parser/testdata/summary_truncate/postgres_regress/polygon.metadata.json b/parser/testdata/summary_truncate/postgres_regress/polygon.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/polygon.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/polygon.test b/parser/testdata/summary_truncate/postgres_regress/polygon.test new file mode 100644 index 0000000..6a665bb --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/polygon.test @@ -0,0 +1,568 @@ +== 001 +-- truncate_limit: 100 +|-- +-- POLYGON +|-- +-- polygon logic +|-- + +CREATE TABLE POLYGON_TBL(f1 polygon) +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE polygon_tbl (f1 polygon)" +== 002 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('(2.0,0.0),(2.0,4.0),(0.0,0.0)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(2.0,0.0),(2.0,4.0),(0.0,0.0)')" +== 003 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('(3.0,1.0),(3.0,3.0),(1.0,0.0)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(3.0,1.0),(3.0,3.0),(1.0,0.0)')" +== 004 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('(1,2),(3,4),(5,6),(7,8)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(1,2),(3,4),(5,6),(7,8)')" +== 005 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('(7,8),(5,6),(3,4),(1,2)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(7,8),(5,6),(3,4),(1,2)')" +== 006 +-- truncate_limit: 100 +-- Reverse +INSERT INTO POLYGON_TBL(f1) VALUES ('(1,2),(7,8),(5,6),(3,-4)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(1,2),(7,8),(5,6),(3,-4)')" +== 007 +-- truncate_limit: 100 +-- degenerate polygons +INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0,0.0)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(0.0,0.0)')" +== 008 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0,1.0),(0.0,1.0)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(0.0,1.0),(0.0,1.0)')" +== 009 +-- truncate_limit: 100 +-- bad polygon input strings +INSERT INTO POLYGON_TBL(f1) VALUES ('0.0') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('0.0')" +== 010 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('(0.0 0.0') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(0.0 0.0')" +== 011 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2)') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(0,1,2)')" +== 012 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('(0,1,2,3') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('(0,1,2,3')" +== 013 +-- truncate_limit: 100 +INSERT INTO POLYGON_TBL(f1) VALUES ('asdf') +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO polygon_tbl (f1) VALUES ('asdf')" +== 014 +-- truncate_limit: 100 +SELECT * FROM POLYGON_TBL +-- +TABLE: name="polygon_tbl" schema="" table="polygon_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM polygon_tbl" +== 015 +-- truncate_limit: 100 +|-- +-- Test the SP-GiST index +|-- + +CREATE TABLE quad_poly_tbl (id int, p polygon) +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE quad_poly_tbl (id int, p polygon)" +== 016 +-- truncate_limit: 100 +INSERT INTO quad_poly_tbl + SELECT (x - 1) * 100 + y, polygon(circle(point(x * 10, y * 10), 1 + (x + y) % 10)) + FROM generate_series(1, 100) x, + generate_series(1, 100) y +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DML +FUNCTION: name="polygon" function="polygon" schema="" ctx=Call +FUNCTION: name="circle" function="circle" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quad_poly_tbl SELECT ... FROM generate_series(1, 100) x, generate_series(1, 100) y" +== 017 +-- truncate_limit: 100 +INSERT INTO quad_poly_tbl + SELECT i, polygon '((200, 300),(210, 310),(230, 290))' + FROM generate_series(10001, 11000) AS i +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quad_poly_tbl SELECT ... FROM generate_series(10001, 11000) i" +== 018 +-- truncate_limit: 100 +INSERT INTO quad_poly_tbl + VALUES + (11001, NULL), + (11002, NULL), + (11003, NULL) +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quad_poly_tbl VALUES (11001, NULL), (11002, NULL), (11003, NULL)" +== 019 +-- truncate_limit: 100 +CREATE INDEX quad_poly_tbl_idx ON quad_poly_tbl USING spgist(p) +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX quad_poly_tbl_idx ON quad_poly_tbl USING spgist (p)" +== 020 +-- truncate_limit: 100 +-- get reference results for ORDER BY distance from seq scan +SET enable_seqscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 021 +-- truncate_limit: 100 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 022 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 023 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_poly_tbl_ord_seq2 AS +SELECT rank() OVER (ORDER BY p <-> point '123,456') n, p <-> point '123,456' dist, id +FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl_ord_seq2" schema="" table="quad_poly_tbl_ord_seq2" ctx=DDL +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_poly_tbl_ord_seq2 AS SELECT rank() OVER (ORDER BY p <-> point '123,4..." +== 024 +-- truncate_limit: 100 +-- check results from index scan +SET enable_seqscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 025 +-- truncate_limit: 100 +SET enable_indexscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 026 +-- truncate_limit: 100 +SET enable_bitmapscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 027 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p << polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p << '((300,300),(400,600),(600,500)..." +== 028 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p << polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p << '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 029 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p &< polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p &< '((300,300),(400,600),(600,500)..." +== 030 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p &< polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p &< '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 031 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p && polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p && '((300,300),(400,600),(600,500)..." +== 032 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p && polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p && '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 033 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p &> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p &> '((300,300),(400,600),(600,500)..." +== 034 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p &> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p &> '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 035 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p >> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p >> '((300,300),(400,600),(600,500)..." +== 036 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p >> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p >> '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 037 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p <<| polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p <<| '((300,300),(400,600),(600,500..." +== 038 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p <<| polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p <<| '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 039 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p &<| polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p &<| '((300,300),(400,600),(600,500..." +== 040 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p &<| polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p &<| '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 041 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p |&> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p |&> '((300,300),(400,600),(600,500..." +== 042 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p |&> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p |&> '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 043 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p |>> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p |>> '((300,300),(400,600),(600,500..." +== 044 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p |>> polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p |>> '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 045 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p <@ '((300,300),(400,600),(600,500)..." +== 046 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p <@ '((300,300),(400,600),(600,500),(700,200))'::polygon" +== 047 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p @> polygon '((340,550),(343,552),(341,553))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p @> '((340,550),(343,552),(341,553)..." +== 048 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p @> polygon '((340,550),(343,552),(341,553))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p @> '((340,550),(343,552),(341,553))'::polygon" +== 049 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM quad_poly_tbl WHERE p ~= polygon '((200, 300),(210, 310),(230, 290))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM quad_poly_tbl WHERE p ~= '((200, 300),(210, 310),(230, 2..." +== 050 +-- truncate_limit: 100 +SELECT count(*) FROM quad_poly_tbl WHERE p ~= polygon '((200, 300),(210, 310),(230, 290))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM quad_poly_tbl WHERE p ~= '((200, 300),(210, 310),(230, 290))'::polygon" +== 051 +-- truncate_limit: 100 +-- test ORDER BY distance +SET enable_indexscan = ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 052 +-- truncate_limit: 100 +SET enable_bitmapscan = OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 053 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT rank() OVER (ORDER BY p <-> point '123,456') n, p <-> point '123,456' dist, id +FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT rank() OVER (ORDER BY p <-> point '123,456') AS n, p <-> point '123,..." +== 054 +-- truncate_limit: 100 +CREATE TEMP TABLE quad_poly_tbl_ord_idx2 AS +SELECT rank() OVER (ORDER BY p <-> point '123,456') n, p <-> point '123,456' dist, id +FROM quad_poly_tbl WHERE p <@ polygon '((300,300),(400,600),(600,500),(700,200))' +-- +TABLE: name="quad_poly_tbl_ord_idx2" schema="" table="quad_poly_tbl_ord_idx2" ctx=DDL +TABLE: name="quad_poly_tbl" schema="" table="quad_poly_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="p" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE quad_poly_tbl_ord_idx2 AS SELECT rank() OVER (ORDER BY p <-> point '123,4..." +== 055 +-- truncate_limit: 100 +SELECT * +FROM quad_poly_tbl_ord_seq2 seq FULL JOIN quad_poly_tbl_ord_idx2 idx + ON seq.n = idx.n AND seq.id = idx.id AND + (seq.dist = idx.dist OR seq.dist IS NULL AND idx.dist IS NULL) +WHERE seq.id IS NULL OR idx.id IS NULL +-- +TABLE: name="quad_poly_tbl_ord_seq2" schema="" table="quad_poly_tbl_ord_seq2" ctx=Select +TABLE: name="quad_poly_tbl_ord_idx2" schema="" table="quad_poly_tbl_ord_idx2" ctx=Select +ALIAS: "idx"="quad_poly_tbl_ord_idx2" +ALIAS: "seq"="quad_poly_tbl_ord_seq2" +FILTER: schema="" table="seq" column="id" +FILTER: schema="" table="idx" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quad_poly_tbl_ord_seq2 seq FULL JOIN quad_poly_tbl_ord_idx2 idx ON seq.n = idx.n AN..." +== 056 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 057 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 058 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 059 +-- truncate_limit: 100 +-- test non-error-throwing API for some core types +SELECT pg_input_is_valid('(2.0,0.8,0.1)', 'polygon') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(2.0,0.8,0.1)', 'polygon')" +== 060 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('(2.0,0.8,0.1)', 'polygon') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(2.0,0.8,0.1)', 'polygon')" +== 061 +-- truncate_limit: 100 +SELECT pg_input_is_valid('(2.0,xyz)', 'polygon') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(2.0,xyz)', 'polygon')" +== 062 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('(2.0,xyz)', 'polygon') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(2.0,xyz)', 'polygon')" diff --git a/parser/testdata/summary_truncate/postgres_regress/polymorphism.metadata.json b/parser/testdata/summary_truncate/postgres_regress/polymorphism.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/polymorphism.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/polymorphism.test b/parser/testdata/summary_truncate/postgres_regress/polymorphism.test new file mode 100644 index 0000000..30e49f2 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/polymorphism.test @@ -0,0 +1,3658 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for polymorphic SQL functions and aggregates based on them. +-- Tests for other features related to function-calling have snuck in, too. +|-- + +create function polyf(x anyelement) returns anyelement as $$ + select x + 1 +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anyelement) RETURNS anyelement AS $$\n select x + 1\n$$ LANGUAGE sql" +== 002 +-- truncate_limit: 100 +select polyf(42) as int, polyf(4.5) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(42) AS \"int\", polyf(4.5) AS num" +== 003 +-- truncate_limit: 100 +select polyf(point(3,4)) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(point(3, 4))" +== 004 +-- truncate_limit: 100 +-- fail for lack of + operator + +drop function polyf(x anyelement) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anyelement)" +== 005 +-- truncate_limit: 100 +create function polyf(x anyelement) returns anyarray as $$ + select array[x + 1, x + 2] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anyelement) RETURNS anyarray AS $$\n select array[x + 1, x + 2]\n$$ LANGUA..." +== 006 +-- truncate_limit: 100 +select polyf(42) as int, polyf(4.5) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(42) AS \"int\", polyf(4.5) AS num" +== 007 +-- truncate_limit: 100 +drop function polyf(x anyelement) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anyelement)" +== 008 +-- truncate_limit: 100 +create function polyf(x anyarray) returns anyelement as $$ + select x[1] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anyarray) RETURNS anyelement AS $$\n select x[1]\n$$ LANGUAGE sql" +== 009 +-- truncate_limit: 100 +select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(ARRAY[2, 4]) AS \"int\", polyf(ARRAY[4.5, 7.7]) AS num" +== 010 +-- truncate_limit: 100 +select polyf(stavalues1) from pg_statistic +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(stavalues1) FROM pg_statistic" +== 011 +-- truncate_limit: 100 +-- fail, can't infer element type + +drop function polyf(x anyarray) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anyarray)" +== 012 +-- truncate_limit: 100 +create function polyf(x anyarray) returns anyarray as $$ + select x +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anyarray) RETURNS anyarray AS $$\n select x\n$$ LANGUAGE sql" +== 013 +-- truncate_limit: 100 +select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(ARRAY[2, 4]) AS \"int\", polyf(ARRAY[4.5, 7.7]) AS num" +== 014 +-- truncate_limit: 100 +select polyf(stavalues1) from pg_statistic +-- +TABLE: name="pg_statistic" schema="" table="pg_statistic" ctx=Select +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(stavalues1) FROM pg_statistic" +== 015 +-- truncate_limit: 100 +-- fail, can't infer element type + +drop function polyf(x anyarray) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anyarray)" +== 016 +-- truncate_limit: 100 +-- fail, can't infer type: +create function polyf(x anyelement) returns anyrange as $$ + select array[x + 1, x + 2] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anyelement) RETURNS anyrange AS $$\n select array[x + 1, x + 2]\n$$ LANGUA..." +== 017 +-- truncate_limit: 100 +create function polyf(x anyrange) returns anyarray as $$ + select array[lower(x), upper(x)] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anyrange) RETURNS anyarray AS $$\n select array[lower(x), upper(x)]\n$$ LA..." +== 018 +-- truncate_limit: 100 +select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4range(42, 49)) AS \"int\", polyf(float8range(4.5, 7.8)) AS num" +== 019 +-- truncate_limit: 100 +drop function polyf(x anyrange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anyrange)" +== 020 +-- truncate_limit: 100 +create function polyf(x anycompatible, y anycompatible) returns anycompatiblearray as $$ + select array[x, y] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anycompatible, y anycompatible) RETURNS anycompatiblearray AS $$\n select..." +== 021 +-- truncate_limit: 100 +select polyf(2, 4) as int, polyf(2, 4.5) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(2, 4) AS \"int\", polyf(2, 4.5) AS num" +== 022 +-- truncate_limit: 100 +drop function polyf(x anycompatible, y anycompatible) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anycompatible, y anycompatible)" +== 023 +-- truncate_limit: 100 +create function polyf(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$ + select array[lower(x), upper(x), y, z] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anycompatiblerange, y anycompatible, z anycompatible) RETURNS anycompatib..." +== 024 +-- truncate_limit: 100 +select polyf(int4range(42, 49), 11, 2::smallint) as int, polyf(float8range(4.5, 7.8), 7.8, 11::real) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 025 +-- truncate_limit: 100 +select polyf(int4range(42, 49), 11, 4.5) as fail +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4range(42, 49), 11, 4.5) AS fail" +== 026 +-- truncate_limit: 100 +-- range type doesn't fit + +drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anycompatiblerange, y anycompatible, z anycompatible)" +== 027 +-- truncate_limit: 100 +create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$ + select array[lower(x), upper(x), y, z] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) RETURNS anycom..." +== 028 +-- truncate_limit: 100 +select polyf(multirange(int4range(42, 49)), 11, 2::smallint) as int, polyf(multirange(float8range(4.5, 7.8)), 7.8, 11::real) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 029 +-- truncate_limit: 100 +select polyf(multirange(int4range(42, 49)), 11, 4.5) as fail +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(multirange(int4range(42, 49)), 11, 4.5) AS fail" +== 030 +-- truncate_limit: 100 +-- range type doesn't fit + +drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anycompatiblemultirange, y anycompatible, z anycompatible)" +== 031 +-- truncate_limit: 100 +-- fail, can't infer type: +create function polyf(x anycompatible) returns anycompatiblerange as $$ + select array[x + 1, x + 2] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anycompatible) RETURNS anycompatiblerange AS $$\n select array[x + 1, x +..." +== 032 +-- truncate_limit: 100 +create function polyf(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$ + select x +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anycompatiblerange, y anycompatiblearray) RETURNS anycompatiblerange AS $..." +== 033 +-- truncate_limit: 100 +select polyf(int4range(42, 49), array[11]) as int, polyf(float8range(4.5, 7.8), array[7]) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4range(42, 49), ARRAY[11]) AS \"int\", polyf(float8range(4.5, 7.8), ARRAY[7]) AS num" +== 034 +-- truncate_limit: 100 +drop function polyf(x anycompatiblerange, y anycompatiblearray) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anycompatiblerange, y anycompatiblearray)" +== 035 +-- truncate_limit: 100 +-- fail, can't infer type: +create function polyf(x anycompatible) returns anycompatiblemultirange as $$ + select array[x + 1, x + 2] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anycompatible) RETURNS anycompatiblemultirange AS $$\n select array[x + 1..." +== 036 +-- truncate_limit: 100 +create function polyf(x anycompatiblemultirange, y anycompatiblearray) returns anycompatiblemultirange as $$ + select x +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(x anycompatiblemultirange, y anycompatiblearray) RETURNS anycompatiblemulti..." +== 037 +-- truncate_limit: 100 +select polyf(multirange(int4range(42, 49)), array[11]) as int, polyf(multirange(float8range(4.5, 7.8)), array[7]) as num +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 038 +-- truncate_limit: 100 +drop function polyf(x anycompatiblemultirange, y anycompatiblearray) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(x anycompatiblemultirange, y anycompatiblearray)" +== 039 +-- truncate_limit: 100 +create function polyf(a anyelement, b anyarray, + c anycompatible, d anycompatible, + OUT x anyarray, OUT y anycompatiblearray) +as $$ + select a || b, array[c, d] +$$ language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(a anyelement, b anyarray, c anycompatible, d anycompatible, OUT x anyarray,..." +== 040 +-- truncate_limit: 100 +select x, pg_typeof(x), y, pg_typeof(y) + from polyf(11, array[1, 2], 42, 34.5) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x), y, pg_typeof(y) FROM polyf(11, ARRAY[1, 2], 42, 34.5)" +== 041 +-- truncate_limit: 100 +select x, pg_typeof(x), y, pg_typeof(y) + from polyf(11, array[1, 2], point(1,2), point(3,4)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x), y, pg_typeof(y) FROM polyf(11, ARRAY[1, 2], point(1, 2), point(3, 4))" +== 042 +-- truncate_limit: 100 +select x, pg_typeof(x), y, pg_typeof(y) + from polyf(11, '{1,2}', point(1,2), '(3,4)') +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x), y, pg_typeof(y) FROM polyf(11, '{1,2}', point(1, 2), '(3,4)')" +== 043 +-- truncate_limit: 100 +select x, pg_typeof(x), y, pg_typeof(y) + from polyf(11, array[1, 2.2], 42, 34.5) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x), y, pg_typeof(y) FROM polyf(11, ARRAY[1, 2.2], 42, 34.5)" +== 044 +-- truncate_limit: 100 +-- fail + +drop function polyf(a anyelement, b anyarray, + c anycompatible, d anycompatible) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(a anyelement, b anyarray, c anycompatible, d anycompatible)" +== 045 +-- truncate_limit: 100 +create function polyf(anyrange) returns anymultirange +as 'select multirange($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(anyrange) RETURNS anymultirange AS $$select multirange($1);$$ LANGUAGE sql" +== 046 +-- truncate_limit: 100 +select polyf(int4range(1,10)) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4range(1, 10))" +== 047 +-- truncate_limit: 100 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(NULL)" +== 048 +-- truncate_limit: 100 +drop function polyf(anyrange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(anyrange)" +== 049 +-- truncate_limit: 100 +create function polyf(anymultirange) returns anyelement +as 'select lower($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(anymultirange) RETURNS anyelement AS $$select lower($1);$$ LANGUAGE sql" +== 050 +-- truncate_limit: 100 +select polyf(int4multirange(int4range(1,10), int4range(20,30))) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4multirange(int4range(1, 10), int4range(20, 30)))" +== 051 +-- truncate_limit: 100 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(NULL)" +== 052 +-- truncate_limit: 100 +drop function polyf(anymultirange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(anymultirange)" +== 053 +-- truncate_limit: 100 +create function polyf(anycompatiblerange) returns anycompatiblemultirange +as 'select multirange($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(anycompatiblerange) RETURNS anycompatiblemultirange AS $$select multirange(..." +== 054 +-- truncate_limit: 100 +select polyf(int4range(1,10)) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4range(1, 10))" +== 055 +-- truncate_limit: 100 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(NULL)" +== 056 +-- truncate_limit: 100 +drop function polyf(anycompatiblerange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(anycompatiblerange)" +== 057 +-- truncate_limit: 100 +create function polyf(anymultirange) returns anyrange +as 'select range_merge($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(anymultirange) RETURNS anyrange AS $$select range_merge($1);$$ LANGUAGE sql" +== 058 +-- truncate_limit: 100 +select polyf(int4multirange(int4range(1,10), int4range(20,30))) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4multirange(int4range(1, 10), int4range(20, 30)))" +== 059 +-- truncate_limit: 100 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(NULL)" +== 060 +-- truncate_limit: 100 +drop function polyf(anymultirange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(anymultirange)" +== 061 +-- truncate_limit: 100 +create function polyf(anycompatiblemultirange) returns anycompatiblerange +as 'select range_merge($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(anycompatiblemultirange) RETURNS anycompatiblerange AS $$select range_merge..." +== 062 +-- truncate_limit: 100 +select polyf(int4multirange(int4range(1,10), int4range(20,30))) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4multirange(int4range(1, 10), int4range(20, 30)))" +== 063 +-- truncate_limit: 100 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(NULL)" +== 064 +-- truncate_limit: 100 +drop function polyf(anycompatiblemultirange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(anycompatiblemultirange)" +== 065 +-- truncate_limit: 100 +create function polyf(anycompatiblemultirange) returns anycompatible +as 'select lower($1);' language sql +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION polyf(anycompatiblemultirange) RETURNS anycompatible AS $$select lower($1);$$ LAN..." +== 066 +-- truncate_limit: 100 +select polyf(int4multirange(int4range(1,10), int4range(20,30))) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(int4multirange(int4range(1, 10), int4range(20, 30)))" +== 067 +-- truncate_limit: 100 +select polyf(null) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT polyf(NULL)" +== 068 +-- truncate_limit: 100 +drop function polyf(anycompatiblemultirange) +-- +FUNCTION: name="polyf" function="polyf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION polyf(anycompatiblemultirange)" +== 069 +-- truncate_limit: 100 +|-- +-- Polymorphic aggregate tests +|-- +-- Legend: +----------- +-- A = type is ANY +-- P = type is polymorphic +-- N = type is non-polymorphic +-- B = aggregate base type +-- S = aggregate state type +-- R = aggregate return type +-- 1 = arg1 of a function +-- 2 = arg2 of a function +-- ag = aggregate +-- tf = trans (state) function +-- ff = final function +-- rt = return type of a function +-- -> = implies +-- => = allowed +-- !> = not allowed +-- E = exists +-- NE = not-exists +|-- +-- Possible states: +-- ---------------- +-- B = (A || P || N) +-- when (B = A) -> (tf2 = NE) +-- S = (P || N) +-- ff = (E || NE) +-- tf1 = (P || N) +-- tf2 = (NE || P || N) +-- R = (P || N) + +-- create functions for use as tf and ff with the needed combinations of +-- argument polymorphism, but within the constraints of valid aggregate +-- functions, i.e. tf arg1 and tf return type must match + +-- polymorphic single arg transfn +CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="stfp" function="stfp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS $$select $1$$ LANGUAGE sql" +== 070 +-- truncate_limit: 100 +-- non-polymorphic single arg transfn +CREATE FUNCTION stfnp(int[]) RETURNS int[] AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="stfnp" function="stfnp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION stfnp(int[]) RETURNS int[] AS $$select $1$$ LANGUAGE sql" +== 071 +-- truncate_limit: 100 +-- dual polymorphic transfn +CREATE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS +'select $1 || $2' LANGUAGE SQL +-- +FUNCTION: name="tfp" function="tfp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tfp(anyarray, anyelement) RETURNS anyarray AS $$select $1 || $2$$ LANGUAGE sql" +== 072 +-- truncate_limit: 100 +-- dual non-polymorphic transfn +CREATE FUNCTION tfnp(int[],int) RETURNS int[] AS +'select $1 || $2' LANGUAGE SQL +-- +FUNCTION: name="tfnp" function="tfnp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tfnp(int[], int) RETURNS int[] AS $$select $1 || $2$$ LANGUAGE sql" +== 073 +-- truncate_limit: 100 +-- arg1 only polymorphic transfn +CREATE FUNCTION tf1p(anyarray,int) RETURNS anyarray AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="tf1p" function="tf1p" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tf1p(anyarray, int) RETURNS anyarray AS $$select $1$$ LANGUAGE sql" +== 074 +-- truncate_limit: 100 +-- arg2 only polymorphic transfn +CREATE FUNCTION tf2p(int[],anyelement) RETURNS int[] AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="tf2p" function="tf2p" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tf2p(int[], anyelement) RETURNS int[] AS $$select $1$$ LANGUAGE sql" +== 075 +-- truncate_limit: 100 +-- multi-arg polymorphic +CREATE FUNCTION sum3(anyelement,anyelement,anyelement) returns anyelement AS +'select $1+$2+$3' language sql strict +-- +FUNCTION: name="sum3" function="sum3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sum3(anyelement, anyelement, anyelement) RETURNS anyelement AS $$select $1+$2+$3$..." +== 076 +-- truncate_limit: 100 +-- finalfn polymorphic +CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS +'select $1' LANGUAGE SQL +-- +FUNCTION: name="ffp" function="ffp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS $$select $1$$ LANGUAGE sql" +== 077 +-- truncate_limit: 100 +-- finalfn non-polymorphic +CREATE FUNCTION ffnp(int[]) returns int[] as +'select $1' LANGUAGE SQL +-- +FUNCTION: name="ffnp" function="ffnp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ffnp(int[]) RETURNS int[] AS $$select $1$$ LANGUAGE sql" +== 078 +-- truncate_limit: 100 +-- Try to cover all the possible states: +|-- +-- Note: in Cases 1 & 2, we are trying to return P. Therefore, if the transfn +-- is stfnp, tfnp, or tf2p, we must use ffp as finalfn, because stfnp, tfnp, +-- and tf2p do not return P. Conversely, in Cases 3 & 4, we are trying to +-- return N. Therefore, if the transfn is stfp, tfp, or tf1p, we must use ffnp +-- as finalfn, because stfp, tfp, and tf1p do not return N. +|-- +-- Case1 (R = P) && (B = A) +-- ------------------------ +-- S tf1 +-- ------- +-- N N +-- should CREATE +CREATE AGGREGATE myaggp01a(*) (SFUNC = stfnp, STYPE = int4[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp01a (*) (sfunc = stfnp, stype = int4[], finalfunc = ffp, initcond = '{}')" +== 079 +-- truncate_limit: 100 +-- P N +-- should ERROR: stfnp(anyarray) not matched by stfnp(int[]) +CREATE AGGREGATE myaggp02a(*) (SFUNC = stfnp, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp02a (*) (sfunc = stfnp, stype = anyarray, finalfunc = ffp, initcond = '{}')" +== 080 +-- truncate_limit: 100 +-- N P +-- should CREATE +CREATE AGGREGATE myaggp03a(*) (SFUNC = stfp, STYPE = int4[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp03a (*) (sfunc = stfp, stype = int4[], finalfunc = ffp, initcond = '{}')" +== 081 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp03b(*) (SFUNC = stfp, STYPE = int4[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp03b (*) (sfunc = stfp, stype = int4[], initcond = '{}')" +== 082 +-- truncate_limit: 100 +-- P P +-- should ERROR: we have no way to resolve S +CREATE AGGREGATE myaggp04a(*) (SFUNC = stfp, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp04a (*) (sfunc = stfp, stype = anyarray, finalfunc = ffp, initcond = '{}')" +== 083 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp04b(*) (SFUNC = stfp, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp04b (*) (sfunc = stfp, stype = anyarray, initcond = '{}')" +== 084 +-- truncate_limit: 100 +-- Case2 (R = P) && ((B = P) || (B = N)) +-- ------------------------------------- +-- S tf1 B tf2 +-- ----------------------- +-- N N N N +-- should CREATE +CREATE AGGREGATE myaggp05a(BASETYPE = int, SFUNC = tfnp, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp05a (basetype = int, sfunc = tfnp, stype = int[], finalfunc = ffp, initcon..." +== 085 +-- truncate_limit: 100 +-- N N N P +-- should CREATE +CREATE AGGREGATE myaggp06a(BASETYPE = int, SFUNC = tf2p, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp06a (basetype = int, sfunc = tf2p, stype = int[], finalfunc = ffp, initcon..." +== 086 +-- truncate_limit: 100 +-- N N P N +-- should ERROR: tfnp(int[], anyelement) not matched by tfnp(int[], int) +CREATE AGGREGATE myaggp07a(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp07a (basetype = anyelement, sfunc = tfnp, stype = int[], finalfunc = ffp, ..." +== 087 +-- truncate_limit: 100 +-- N N P P +-- should CREATE +CREATE AGGREGATE myaggp08a(BASETYPE = anyelement, SFUNC = tf2p, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp08a (basetype = anyelement, sfunc = tf2p, stype = int[], finalfunc = ffp, ..." +== 088 +-- truncate_limit: 100 +-- N P N N +-- should CREATE +CREATE AGGREGATE myaggp09a(BASETYPE = int, SFUNC = tf1p, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp09a (basetype = int, sfunc = tf1p, stype = int[], finalfunc = ffp, initcon..." +== 089 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp09b(BASETYPE = int, SFUNC = tf1p, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp09b (basetype = int, sfunc = tf1p, stype = int[], initcond = '{}')" +== 090 +-- truncate_limit: 100 +-- N P N P +-- should CREATE +CREATE AGGREGATE myaggp10a(BASETYPE = int, SFUNC = tfp, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp10a (basetype = int, sfunc = tfp, stype = int[], finalfunc = ffp, initcond..." +== 091 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp10b(BASETYPE = int, SFUNC = tfp, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp10b (basetype = int, sfunc = tfp, stype = int[], initcond = '{}')" +== 092 +-- truncate_limit: 100 +-- N P P N +-- should ERROR: tf1p(int[],anyelement) not matched by tf1p(anyarray,int) +CREATE AGGREGATE myaggp11a(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp11a (basetype = anyelement, sfunc = tf1p, stype = int[], finalfunc = ffp, ..." +== 093 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp11b(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp11b (basetype = anyelement, sfunc = tf1p, stype = int[], initcond = '{}')" +== 094 +-- truncate_limit: 100 +-- N P P P +-- should ERROR: tfp(int[],anyelement) not matched by tfp(anyarray,anyelement) +CREATE AGGREGATE myaggp12a(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[], + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp12a (basetype = anyelement, sfunc = tfp, stype = int[], finalfunc = ffp, i..." +== 095 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp12b(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp12b (basetype = anyelement, sfunc = tfp, stype = int[], initcond = '{}')" +== 096 +-- truncate_limit: 100 +-- P N N N +-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int) +CREATE AGGREGATE myaggp13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp13a (basetype = int, sfunc = tfnp, stype = anyarray, finalfunc = ffp, init..." +== 097 +-- truncate_limit: 100 +-- P N N P +-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement) +CREATE AGGREGATE myaggp14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp14a (basetype = int, sfunc = tf2p, stype = anyarray, finalfunc = ffp, init..." +== 098 +-- truncate_limit: 100 +-- P N P N +-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int) +CREATE AGGREGATE myaggp15a(BASETYPE = anyelement, SFUNC = tfnp, + STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp15a (basetype = anyelement, sfunc = tfnp, stype = anyarray, finalfunc = ff..." +== 099 +-- truncate_limit: 100 +-- P N P P +-- should ERROR: tf2p(anyarray, anyelement) not matched by tf2p(int[],anyelement) +CREATE AGGREGATE myaggp16a(BASETYPE = anyelement, SFUNC = tf2p, + STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp16a (basetype = anyelement, sfunc = tf2p, stype = anyarray, finalfunc = ff..." +== 100 +-- truncate_limit: 100 +-- P P N N +-- should ERROR: we have no way to resolve S +CREATE AGGREGATE myaggp17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp17a (basetype = int, sfunc = tf1p, stype = anyarray, finalfunc = ffp, init..." +== 101 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp17b(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp17b (basetype = int, sfunc = tf1p, stype = anyarray, initcond = '{}')" +== 102 +-- truncate_limit: 100 +-- P P N P +-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement) +CREATE AGGREGATE myaggp18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray, + FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp18a (basetype = int, sfunc = tfp, stype = anyarray, finalfunc = ffp, initc..." +== 103 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp18b(BASETYPE = int, SFUNC = tfp, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp18b (basetype = int, sfunc = tfp, stype = anyarray, initcond = '{}')" +== 104 +-- truncate_limit: 100 +-- P P P N +-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int) +CREATE AGGREGATE myaggp19a(BASETYPE = anyelement, SFUNC = tf1p, + STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp19a (basetype = anyelement, sfunc = tf1p, stype = anyarray, finalfunc = ff..." +== 105 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp19b(BASETYPE = anyelement, SFUNC = tf1p, + STYPE = anyarray, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp19b (basetype = anyelement, sfunc = tf1p, stype = anyarray, initcond = '{}')" +== 106 +-- truncate_limit: 100 +-- P P P P +-- should CREATE +CREATE AGGREGATE myaggp20a(BASETYPE = anyelement, SFUNC = tfp, + STYPE = anyarray, FINALFUNC = ffp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp20a (basetype = anyelement, sfunc = tfp, stype = anyarray, finalfunc = ffp..." +== 107 +-- truncate_limit: 100 +CREATE AGGREGATE myaggp20b(BASETYPE = anyelement, SFUNC = tfp, + STYPE = anyarray, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggp20b (basetype = anyelement, sfunc = tfp, stype = anyarray, initcond = '{}')" +== 108 +-- truncate_limit: 100 +-- Case3 (R = N) && (B = A) +-- ------------------------ +-- S tf1 +-- ------- +-- N N +-- should CREATE +CREATE AGGREGATE myaggn01a(*) (SFUNC = stfnp, STYPE = int4[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn01a (*) (sfunc = stfnp, stype = int4[], finalfunc = ffnp, initcond = '{}')" +== 109 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn01b(*) (SFUNC = stfnp, STYPE = int4[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn01b (*) (sfunc = stfnp, stype = int4[], initcond = '{}')" +== 110 +-- truncate_limit: 100 +-- P N +-- should ERROR: stfnp(anyarray) not matched by stfnp(int[]) +CREATE AGGREGATE myaggn02a(*) (SFUNC = stfnp, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn02a (*) (sfunc = stfnp, stype = anyarray, finalfunc = ffnp, initcond = '{}')" +== 111 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn02b(*) (SFUNC = stfnp, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn02b (*) (sfunc = stfnp, stype = anyarray, initcond = '{}')" +== 112 +-- truncate_limit: 100 +-- N P +-- should CREATE +CREATE AGGREGATE myaggn03a(*) (SFUNC = stfp, STYPE = int4[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn03a (*) (sfunc = stfp, stype = int4[], finalfunc = ffnp, initcond = '{}')" +== 113 +-- truncate_limit: 100 +-- P P +-- should ERROR: ffnp(anyarray) not matched by ffnp(int[]) +CREATE AGGREGATE myaggn04a(*) (SFUNC = stfp, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn04a (*) (sfunc = stfp, stype = anyarray, finalfunc = ffnp, initcond = '{}')" +== 114 +-- truncate_limit: 100 +-- Case4 (R = N) && ((B = P) || (B = N)) +-- ------------------------------------- +-- S tf1 B tf2 +-- ----------------------- +-- N N N N +-- should CREATE +CREATE AGGREGATE myaggn05a(BASETYPE = int, SFUNC = tfnp, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn05a (basetype = int, sfunc = tfnp, stype = int[], finalfunc = ffnp, initco..." +== 115 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn05b(BASETYPE = int, SFUNC = tfnp, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn05b (basetype = int, sfunc = tfnp, stype = int[], initcond = '{}')" +== 116 +-- truncate_limit: 100 +-- N N N P +-- should CREATE +CREATE AGGREGATE myaggn06a(BASETYPE = int, SFUNC = tf2p, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn06a (basetype = int, sfunc = tf2p, stype = int[], finalfunc = ffnp, initco..." +== 117 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn06b(BASETYPE = int, SFUNC = tf2p, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn06b (basetype = int, sfunc = tf2p, stype = int[], initcond = '{}')" +== 118 +-- truncate_limit: 100 +-- N N P N +-- should ERROR: tfnp(int[], anyelement) not matched by tfnp(int[], int) +CREATE AGGREGATE myaggn07a(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn07a (basetype = anyelement, sfunc = tfnp, stype = int[], finalfunc = ffnp,..." +== 119 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn07b(BASETYPE = anyelement, SFUNC = tfnp, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn07b (basetype = anyelement, sfunc = tfnp, stype = int[], initcond = '{}')" +== 120 +-- truncate_limit: 100 +-- N N P P +-- should CREATE +CREATE AGGREGATE myaggn08a(BASETYPE = anyelement, SFUNC = tf2p, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn08a (basetype = anyelement, sfunc = tf2p, stype = int[], finalfunc = ffnp,..." +== 121 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn08b(BASETYPE = anyelement, SFUNC = tf2p, STYPE = int[], + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn08b (basetype = anyelement, sfunc = tf2p, stype = int[], initcond = '{}')" +== 122 +-- truncate_limit: 100 +-- N P N N +-- should CREATE +CREATE AGGREGATE myaggn09a(BASETYPE = int, SFUNC = tf1p, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn09a (basetype = int, sfunc = tf1p, stype = int[], finalfunc = ffnp, initco..." +== 123 +-- truncate_limit: 100 +-- N P N P +-- should CREATE +CREATE AGGREGATE myaggn10a(BASETYPE = int, SFUNC = tfp, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn10a (basetype = int, sfunc = tfp, stype = int[], finalfunc = ffnp, initcon..." +== 124 +-- truncate_limit: 100 +-- N P P N +-- should ERROR: tf1p(int[],anyelement) not matched by tf1p(anyarray,int) +CREATE AGGREGATE myaggn11a(BASETYPE = anyelement, SFUNC = tf1p, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn11a (basetype = anyelement, sfunc = tf1p, stype = int[], finalfunc = ffnp,..." +== 125 +-- truncate_limit: 100 +-- N P P P +-- should ERROR: tfp(int[],anyelement) not matched by tfp(anyarray,anyelement) +CREATE AGGREGATE myaggn12a(BASETYPE = anyelement, SFUNC = tfp, STYPE = int[], + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn12a (basetype = anyelement, sfunc = tfp, stype = int[], finalfunc = ffnp, ..." +== 126 +-- truncate_limit: 100 +-- P N N N +-- should ERROR: tfnp(anyarray, int) not matched by tfnp(int[],int) +CREATE AGGREGATE myaggn13a(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn13a (basetype = int, sfunc = tfnp, stype = anyarray, finalfunc = ffnp, ini..." +== 127 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn13b(BASETYPE = int, SFUNC = tfnp, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn13b (basetype = int, sfunc = tfnp, stype = anyarray, initcond = '{}')" +== 128 +-- truncate_limit: 100 +-- P N N P +-- should ERROR: tf2p(anyarray, int) not matched by tf2p(int[],anyelement) +CREATE AGGREGATE myaggn14a(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn14a (basetype = int, sfunc = tf2p, stype = anyarray, finalfunc = ffnp, ini..." +== 129 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn14b(BASETYPE = int, SFUNC = tf2p, STYPE = anyarray, + INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn14b (basetype = int, sfunc = tf2p, stype = anyarray, initcond = '{}')" +== 130 +-- truncate_limit: 100 +-- P N P N +-- should ERROR: tfnp(anyarray, anyelement) not matched by tfnp(int[],int) +CREATE AGGREGATE myaggn15a(BASETYPE = anyelement, SFUNC = tfnp, + STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn15a (basetype = anyelement, sfunc = tfnp, stype = anyarray, finalfunc = ff..." +== 131 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn15b(BASETYPE = anyelement, SFUNC = tfnp, + STYPE = anyarray, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn15b (basetype = anyelement, sfunc = tfnp, stype = anyarray, initcond = '{}')" +== 132 +-- truncate_limit: 100 +-- P N P P +-- should ERROR: tf2p(anyarray, anyelement) not matched by tf2p(int[],anyelement) +CREATE AGGREGATE myaggn16a(BASETYPE = anyelement, SFUNC = tf2p, + STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn16a (basetype = anyelement, sfunc = tf2p, stype = anyarray, finalfunc = ff..." +== 133 +-- truncate_limit: 100 +CREATE AGGREGATE myaggn16b(BASETYPE = anyelement, SFUNC = tf2p, + STYPE = anyarray, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn16b (basetype = anyelement, sfunc = tf2p, stype = anyarray, initcond = '{}')" +== 134 +-- truncate_limit: 100 +-- P P N N +-- should ERROR: ffnp(anyarray) not matched by ffnp(int[]) +CREATE AGGREGATE myaggn17a(BASETYPE = int, SFUNC = tf1p, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn17a (basetype = int, sfunc = tf1p, stype = anyarray, finalfunc = ffnp, ini..." +== 135 +-- truncate_limit: 100 +-- P P N P +-- should ERROR: tfp(anyarray, int) not matched by tfp(anyarray, anyelement) +CREATE AGGREGATE myaggn18a(BASETYPE = int, SFUNC = tfp, STYPE = anyarray, + FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn18a (basetype = int, sfunc = tfp, stype = anyarray, finalfunc = ffnp, init..." +== 136 +-- truncate_limit: 100 +-- P P P N +-- should ERROR: tf1p(anyarray, anyelement) not matched by tf1p(anyarray, int) +CREATE AGGREGATE myaggn19a(BASETYPE = anyelement, SFUNC = tf1p, + STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn19a (basetype = anyelement, sfunc = tf1p, stype = anyarray, finalfunc = ff..." +== 137 +-- truncate_limit: 100 +-- P P P P +-- should ERROR: ffnp(anyarray) not matched by ffnp(int[]) +CREATE AGGREGATE myaggn20a(BASETYPE = anyelement, SFUNC = tfp, + STYPE = anyarray, FINALFUNC = ffnp, INITCOND = '{}') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE myaggn20a (basetype = anyelement, sfunc = tfp, stype = anyarray, finalfunc = ffn..." +== 138 +-- truncate_limit: 100 +-- multi-arg polymorphic +CREATE AGGREGATE mysum2(anyelement,anyelement) (SFUNC = sum3, + STYPE = anyelement, INITCOND = '0') +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE mysum2 (anyelement, anyelement) (sfunc = sum3, stype = anyelement, initcond = '0')" +== 139 +-- truncate_limit: 100 +-- create test data for polymorphic aggregates +create temp table t(f1 int, f2 int[], f3 text) +-- +TABLE: name="t" schema="" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t (f1 int, f2 int[], f3 text)" +== 140 +-- truncate_limit: 100 +insert into t values(1,array[1],'a') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1, ARRAY[1], 'a')" +== 141 +-- truncate_limit: 100 +insert into t values(1,array[11],'b') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1, ARRAY[11], 'b')" +== 142 +-- truncate_limit: 100 +insert into t values(1,array[111],'c') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (1, ARRAY[111], 'c')" +== 143 +-- truncate_limit: 100 +insert into t values(2,array[2],'a') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (2, ARRAY[2], 'a')" +== 144 +-- truncate_limit: 100 +insert into t values(2,array[22],'b') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (2, ARRAY[22], 'b')" +== 145 +-- truncate_limit: 100 +insert into t values(2,array[222],'c') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (2, ARRAY[222], 'c')" +== 146 +-- truncate_limit: 100 +insert into t values(3,array[3],'a') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (3, ARRAY[3], 'a')" +== 147 +-- truncate_limit: 100 +insert into t values(3,array[3],'b') +-- +TABLE: name="t" schema="" table="t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t VALUES (3, ARRAY[3], 'b')" +== 148 +-- truncate_limit: 100 +-- test the successfully created polymorphic aggregates +select f3, myaggp01a(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp01a" function="myaggp01a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp01a(*) FROM t GROUP BY f3 ORDER BY f3" +== 149 +-- truncate_limit: 100 +select f3, myaggp03a(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp03a" function="myaggp03a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp03a(*) FROM t GROUP BY f3 ORDER BY f3" +== 150 +-- truncate_limit: 100 +select f3, myaggp03b(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp03b" function="myaggp03b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp03b(*) FROM t GROUP BY f3 ORDER BY f3" +== 151 +-- truncate_limit: 100 +select f3, myaggp05a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp05a" function="myaggp05a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp05a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 152 +-- truncate_limit: 100 +select f3, myaggp06a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp06a" function="myaggp06a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp06a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 153 +-- truncate_limit: 100 +select f3, myaggp08a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp08a" function="myaggp08a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp08a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 154 +-- truncate_limit: 100 +select f3, myaggp09a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp09a" function="myaggp09a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp09a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 155 +-- truncate_limit: 100 +select f3, myaggp09b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp09b" function="myaggp09b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp09b(f1) FROM t GROUP BY f3 ORDER BY f3" +== 156 +-- truncate_limit: 100 +select f3, myaggp10a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp10a" function="myaggp10a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp10a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 157 +-- truncate_limit: 100 +select f3, myaggp10b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp10b" function="myaggp10b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp10b(f1) FROM t GROUP BY f3 ORDER BY f3" +== 158 +-- truncate_limit: 100 +select f3, myaggp20a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp20a" function="myaggp20a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp20a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 159 +-- truncate_limit: 100 +select f3, myaggp20b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggp20b" function="myaggp20b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggp20b(f1) FROM t GROUP BY f3 ORDER BY f3" +== 160 +-- truncate_limit: 100 +select f3, myaggn01a(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn01a" function="myaggn01a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn01a(*) FROM t GROUP BY f3 ORDER BY f3" +== 161 +-- truncate_limit: 100 +select f3, myaggn01b(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn01b" function="myaggn01b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn01b(*) FROM t GROUP BY f3 ORDER BY f3" +== 162 +-- truncate_limit: 100 +select f3, myaggn03a(*) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn03a" function="myaggn03a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn03a(*) FROM t GROUP BY f3 ORDER BY f3" +== 163 +-- truncate_limit: 100 +select f3, myaggn05a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn05a" function="myaggn05a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn05a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 164 +-- truncate_limit: 100 +select f3, myaggn05b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn05b" function="myaggn05b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn05b(f1) FROM t GROUP BY f3 ORDER BY f3" +== 165 +-- truncate_limit: 100 +select f3, myaggn06a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn06a" function="myaggn06a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn06a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 166 +-- truncate_limit: 100 +select f3, myaggn06b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn06b" function="myaggn06b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn06b(f1) FROM t GROUP BY f3 ORDER BY f3" +== 167 +-- truncate_limit: 100 +select f3, myaggn08a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn08a" function="myaggn08a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn08a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 168 +-- truncate_limit: 100 +select f3, myaggn08b(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn08b" function="myaggn08b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn08b(f1) FROM t GROUP BY f3 ORDER BY f3" +== 169 +-- truncate_limit: 100 +select f3, myaggn09a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn09a" function="myaggn09a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn09a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 170 +-- truncate_limit: 100 +select f3, myaggn10a(f1) from t group by f3 order by f3 +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="myaggn10a" function="myaggn10a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f3, myaggn10a(f1) FROM t GROUP BY f3 ORDER BY f3" +== 171 +-- truncate_limit: 100 +select mysum2(f1, f1 + 1) from t +-- +TABLE: name="t" schema="" table="t" ctx=Select +FUNCTION: name="mysum2" function="mysum2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT mysum2(f1, f1 + 1) FROM t" +== 172 +-- truncate_limit: 100 +-- test inlining of polymorphic SQL functions +create function bleat(int) returns int as $$ +begin + raise notice 'bleat %', $1; + return $1; +end$$ language plpgsql +-- +FUNCTION: name="bleat" function="bleat" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bleat(int) RETURNS int AS $$\nbegin\n raise notice 'bleat %', $1;\n return $1;\nend..." +== 173 +-- truncate_limit: 100 +create function sql_if(bool, anyelement, anyelement) returns anyelement as $$ +select case when $1 then $2 else $3 end $$ language sql +-- +FUNCTION: name="sql_if" function="sql_if" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sql_if(bool, anyelement, anyelement) RETURNS anyelement AS $$\nselect case when $1..." +== 174 +-- truncate_limit: 100 +-- Note this would fail with integer overflow, never mind wrong bleat() output, +-- if the CASE expression were not successfully inlined +select f1, sql_if(f1 > 0, bleat(f1), bleat(f1 + 1)) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="sql_if" function="sql_if" schema="" ctx=Call +FUNCTION: name="bleat" function="bleat" schema="" ctx=Call +FUNCTION: name="bleat" function="bleat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, sql_if(f1 > 0, bleat(f1), bleat(f1 + 1)) FROM int4_tbl" +== 175 +-- truncate_limit: 100 +select q2, sql_if(q2 > 0, q2, q2 + 1) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="sql_if" function="sql_if" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT q2, sql_if(q2 > 0, q2, q2 + 1) FROM int8_tbl" +== 176 +-- truncate_limit: 100 +-- another sort of polymorphic aggregate + +CREATE AGGREGATE array_larger_accum (anyarray) +( + sfunc = array_larger, + stype = anyarray, + initcond = '{}' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE array_larger_accum (anyarray) (sfunc = array_larger, stype = anyarray, initcond ..." +== 177 +-- truncate_limit: 100 +SELECT array_larger_accum(i) +FROM (VALUES (ARRAY[1,2]), (ARRAY[3,4])) as t(i) +-- +FUNCTION: name="array_larger_accum" function="array_larger_accum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_larger_accum(i) FROM (VALUES (ARRAY[1, 2]), (ARRAY[3, 4])) t(i)" +== 178 +-- truncate_limit: 100 +SELECT array_larger_accum(i) +FROM (VALUES (ARRAY[row(1,2),row(3,4)]), (ARRAY[row(5,6),row(7,8)])) as t(i) +-- +FUNCTION: name="array_larger_accum" function="array_larger_accum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_larger_accum(i) FROM (VALUES (...)) t(i)" +== 179 +-- truncate_limit: 100 +-- another kind of polymorphic aggregate + +create function add_group(grp anyarray, ad anyelement, size integer) + returns anyarray + as $$ +begin + if grp is null then + return array[ad]; + end if; + if array_upper(grp, 1) < size then + return grp || ad; + end if; + return grp; +end; +$$ + language plpgsql immutable +-- +FUNCTION: name="add_group" function="add_group" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION add_group(grp anyarray, ad anyelement, size int) RETURNS anyarray AS $$\nbegin\n i..." +== 180 +-- truncate_limit: 100 +create aggregate build_group(anyelement, integer) ( + SFUNC = add_group, + STYPE = anyarray +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE build_group (anyelement, int) (sfunc = add_group, stype = anyarray)" +== 181 +-- truncate_limit: 100 +select build_group(q1,3) from int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="build_group" function="build_group" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT build_group(q1, 3) FROM int8_tbl" +== 182 +-- truncate_limit: 100 +-- this should fail because stype isn't compatible with arg +create aggregate build_group(int8, integer) ( + SFUNC = add_group, + STYPE = int2[] +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE build_group (int8, int) (sfunc = add_group, stype = int2[])" +== 183 +-- truncate_limit: 100 +-- but we can make a non-poly agg from a poly sfunc if types are OK +create aggregate build_group(int8, integer) ( + SFUNC = add_group, + STYPE = int8[] +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE build_group (int8, int) (sfunc = add_group, stype = int8[])" +== 184 +-- truncate_limit: 100 +-- check proper resolution of data types for polymorphic transfn/finalfn + +create function first_el_transfn(anyarray, anyelement) returns anyarray as +'select $1 || $2' language sql immutable +-- +FUNCTION: name="first_el_transfn" function="first_el_transfn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION first_el_transfn(anyarray, anyelement) RETURNS anyarray AS $$select $1 || $2$$ LA..." +== 185 +-- truncate_limit: 100 +create function first_el(anyarray) returns anyelement as +'select $1[1]' language sql strict immutable +-- +FUNCTION: name="first_el" function="first_el" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION first_el(anyarray) RETURNS anyelement AS $$select $1[1]$$ LANGUAGE sql RETURNS NU..." +== 186 +-- truncate_limit: 100 +create aggregate first_el_agg_f8(float8) ( + SFUNC = array_append, + STYPE = float8[], + FINALFUNC = first_el +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE first_el_agg_f8 (float8) (sfunc = array_append, stype = float8[], finalfunc = fi..." +== 187 +-- truncate_limit: 100 +create aggregate first_el_agg_any(anyelement) ( + SFUNC = first_el_transfn, + STYPE = anyarray, + FINALFUNC = first_el +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE first_el_agg_any (anyelement) (sfunc = first_el_transfn, stype = anyarray, final..." +== 188 +-- truncate_limit: 100 +select first_el_agg_f8(x::float8) from generate_series(1,10) x +-- +FUNCTION: name="first_el_agg_f8" function="first_el_agg_f8" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT first_el_agg_f8(x::float8) FROM generate_series(1, 10) x" +== 189 +-- truncate_limit: 100 +select first_el_agg_any(x) from generate_series(1,10) x +-- +FUNCTION: name="first_el_agg_any" function="first_el_agg_any" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT first_el_agg_any(x) FROM generate_series(1, 10) x" +== 190 +-- truncate_limit: 100 +select first_el_agg_f8(x::float8) over(order by x) from generate_series(1,10) x +-- +FUNCTION: name="first_el_agg_f8" function="first_el_agg_f8" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT first_el_agg_f8(x::float8) OVER (ORDER BY x) FROM generate_series(1, 10) x" +== 191 +-- truncate_limit: 100 +select first_el_agg_any(x) over(order by x) from generate_series(1,10) x +-- +FUNCTION: name="first_el_agg_any" function="first_el_agg_any" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT first_el_agg_any(x) OVER (ORDER BY x) FROM generate_series(1, 10) x" +== 192 +-- truncate_limit: 100 +-- check that we can apply functions taking ANYARRAY to pg_stats +select distinct array_ndims(histogram_bounds) from pg_stats +where histogram_bounds is not null +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +FUNCTION: name="array_ndims" function="array_ndims" schema="" ctx=Call +FILTER: schema="" table="" column="histogram_bounds" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT array_ndims(histogram_bounds) FROM pg_stats WHERE histogram_bounds IS NOT NULL" +== 193 +-- truncate_limit: 100 +-- such functions must protect themselves if varying element type isn't OK +-- (WHERE clause here is to avoid possibly getting a collation error instead) +select max(histogram_bounds) from pg_stats where tablename = 'pg_am' +-- +TABLE: name="pg_stats" schema="" table="pg_stats" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT max(histogram_bounds) FROM pg_stats WHERE tablename = 'pg_am'" +== 194 +-- truncate_limit: 100 +-- another corner case is the input functions for polymorphic pseudotypes +select array_in('{1,2,3}','int4'::regtype,-1) +-- +FUNCTION: name="array_in" function="array_in" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_in('{1,2,3}', 'int4'::regtype, -1)" +== 195 +-- truncate_limit: 100 +-- this has historically worked +select * from array_in('{1,2,3}','int4'::regtype,-1) +-- +FUNCTION: name="array_in" function="array_in" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_in('{1,2,3}', 'int4'::regtype, -1)" +== 196 +-- truncate_limit: 100 +-- this not +select anyrange_in('[10,20)','int4range'::regtype,-1) +-- +FUNCTION: name="anyrange_in" function="anyrange_in" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anyrange_in('[10,20)', 'int4range'::regtype, -1)" +== 197 +-- truncate_limit: 100 +-- test variadic polymorphic functions + +create function myleast(variadic anyarray) returns anyelement as $$ + select min($1[i]) from generate_subscripts($1,1) g(i) +$$ language sql immutable strict +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION myleast(VARIADIC anyarray) RETURNS anyelement AS $$\n select min($1[i]) from gene..." +== 198 +-- truncate_limit: 100 +select myleast(10, 1, 20, 33) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myleast(10, 1, 20, 33)" +== 199 +-- truncate_limit: 100 +select myleast(1.1, 0.22, 0.55) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myleast(1.1, 0.22, 0.55)" +== 200 +-- truncate_limit: 100 +select myleast('z'::text) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myleast('z'::text)" +== 201 +-- truncate_limit: 100 +select myleast() +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myleast()" +== 202 +-- truncate_limit: 100 +-- fail + +-- test with variadic call parameter +select myleast(variadic array[1,2,3,4,-1]) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myleast(VARIADIC ARRAY[1, 2, 3, 4, -1])" +== 203 +-- truncate_limit: 100 +select myleast(variadic array[1.1, -5.5]) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myleast(VARIADIC ARRAY[1.1, -5.5])" +== 204 +-- truncate_limit: 100 +--test with empty variadic call parameter +select myleast(variadic array[]::int[]) +-- +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT myleast(VARIADIC ARRAY[]::int[])" +== 205 +-- truncate_limit: 100 +-- an example with some ordinary arguments too +create function concat(text, variadic anyarray) returns text as $$ + select array_to_string($2, $1); +$$ language sql immutable strict +-- +FUNCTION: name="concat" function="concat" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION concat(text, VARIADIC anyarray) RETURNS text AS $$\n select array_to_string($2, $..." +== 206 +-- truncate_limit: 100 +select concat('%', 1, 2, 3, 4, 5) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat('%', 1, 2, 3, 4, 5)" +== 207 +-- truncate_limit: 100 +select concat('|', 'a'::text, 'b', 'c') +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat('|', 'a'::text, 'b', 'c')" +== 208 +-- truncate_limit: 100 +select concat('|', variadic array[1,2,33]) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat('|', VARIADIC ARRAY[1, 2, 33])" +== 209 +-- truncate_limit: 100 +select concat('|', variadic array[]::int[]) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat('|', VARIADIC ARRAY[]::int[])" +== 210 +-- truncate_limit: 100 +drop function concat(text, anyarray) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION concat(text, anyarray)" +== 211 +-- truncate_limit: 100 +-- mix variadic with anyelement +create function formarray(anyelement, variadic anyarray) returns anyarray as $$ + select array_prepend($1, $2); +$$ language sql immutable strict +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION formarray(anyelement, VARIADIC anyarray) RETURNS anyarray AS $$\n select array_pr..." +== 212 +-- truncate_limit: 100 +select formarray(1,2,3,4,5) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT formarray(1, 2, 3, 4, 5)" +== 213 +-- truncate_limit: 100 +select formarray(1.1, variadic array[1.2,55.5]) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT formarray(1.1, VARIADIC ARRAY[1.2, 55.5])" +== 214 +-- truncate_limit: 100 +select formarray(1.1, array[1.2,55.5]) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT formarray(1.1, ARRAY[1.2, 55.5])" +== 215 +-- truncate_limit: 100 +-- fail without variadic +select formarray(1, 'x'::text) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT formarray(1, 'x'::text)" +== 216 +-- truncate_limit: 100 +-- fail, type mismatch +select formarray(1, variadic array['x'::text]) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT formarray(1, VARIADIC ARRAY['x'::text])" +== 217 +-- truncate_limit: 100 +-- fail, type mismatch + +drop function formarray(anyelement, variadic anyarray) +-- +FUNCTION: name="formarray" function="formarray" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION formarray(anyelement, VARIADIC anyarray)" +== 218 +-- truncate_limit: 100 +-- test pg_typeof() function +select pg_typeof(null) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(NULL)" +== 219 +-- truncate_limit: 100 +-- unknown +select pg_typeof(0) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(0)" +== 220 +-- truncate_limit: 100 +-- integer +select pg_typeof(0.0) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(0.0)" +== 221 +-- truncate_limit: 100 +-- numeric +select pg_typeof(1+1 = 2) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof((1 + 1) = 2)" +== 222 +-- truncate_limit: 100 +-- boolean +select pg_typeof('x') +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof('x')" +== 223 +-- truncate_limit: 100 +-- unknown +select pg_typeof('' || '') +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof('' || '')" +== 224 +-- truncate_limit: 100 +-- text +select pg_typeof(pg_typeof(0)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(pg_typeof(0))" +== 225 +-- truncate_limit: 100 +-- regtype +select pg_typeof(array[1.2,55.5]) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(ARRAY[1.2, 55.5])" +== 226 +-- truncate_limit: 100 +-- numeric[] +select pg_typeof(myleast(10, 1, 20, 33)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="myleast" function="myleast" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(myleast(10, 1, 20, 33))" +== 227 +-- truncate_limit: 100 +-- polymorphic input + +-- test functions with default parameters + +-- test basic functionality +create function dfunc(a int = 1, int = 2) returns int as $$ + select $1 + $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a int = 1, int = 2) RETURNS int AS $$\n select $1 + $2;\n$$ LANGUAGE sql" +== 228 +-- truncate_limit: 100 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc()" +== 229 +-- truncate_limit: 100 +select dfunc(10) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(10)" +== 230 +-- truncate_limit: 100 +select dfunc(10, 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(10, 20)" +== 231 +-- truncate_limit: 100 +select dfunc(10, 20, 30) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(10, 20, 30)" +== 232 +-- truncate_limit: 100 +-- fail + +drop function dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc()" +== 233 +-- truncate_limit: 100 +-- fail +drop function dfunc(int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int)" +== 234 +-- truncate_limit: 100 +-- fail +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int, int)" +== 235 +-- truncate_limit: 100 +-- ok + +-- fail: defaults must be at end of argument list +create function dfunc(a int = 1, b int) returns int as $$ + select $1 + $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a int = 1, b int) RETURNS int AS $$\n select $1 + $2;\n$$ LANGUAGE sql" +== 236 +-- truncate_limit: 100 +-- however, this should work: +create function dfunc(a int = 1, out sum int, b int = 2) as $$ + select $1 + $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a int = 1, OUT sum int, b int = 2) AS $$\n select $1 + $2;\n$$ LANGUAGE sql" +== 237 +-- truncate_limit: 100 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc()" +== 238 +-- truncate_limit: 100 +-- verify it lists properly + +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int, int)" +== 239 +-- truncate_limit: 100 +-- check implicit coercion +create function dfunc(a int DEFAULT 1.0, int DEFAULT '-1') returns int as $$ + select $1 + $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a int = 1.0, int = '-1') RETURNS int AS $$\n select $1 + $2;\n$$ LANGUAGE sql" +== 240 +-- truncate_limit: 100 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc()" +== 241 +-- truncate_limit: 100 +create function dfunc(a text DEFAULT 'Hello', b text DEFAULT 'World') returns text as $$ + select $1 || ', ' || $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a text = 'Hello', b text = 'World') RETURNS text AS $$\n select $1 || ', ' ..." +== 242 +-- truncate_limit: 100 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc()" +== 243 +-- truncate_limit: 100 +-- fail: which dfunc should be called? int or text +select dfunc('Hi') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('Hi')" +== 244 +-- truncate_limit: 100 +-- ok +select dfunc('Hi', 'City') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('Hi', 'City')" +== 245 +-- truncate_limit: 100 +-- ok +select dfunc(0) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(0)" +== 246 +-- truncate_limit: 100 +-- ok +select dfunc(10, 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(10, 20)" +== 247 +-- truncate_limit: 100 +-- ok + +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int, int)" +== 248 +-- truncate_limit: 100 +drop function dfunc(text, text) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(text, text)" +== 249 +-- truncate_limit: 100 +create function dfunc(int = 1, int = 2) returns int as $$ + select 2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(int = 1, int = 2) RETURNS int AS $$\n select 2;\n$$ LANGUAGE sql" +== 250 +-- truncate_limit: 100 +create function dfunc(int = 1, int = 2, int = 3, int = 4) returns int as $$ + select 4; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(int = 1, int = 2, int = 3, int = 4) RETURNS int AS $$\n select 4;\n$$ LANGUA..." +== 251 +-- truncate_limit: 100 +-- Now, dfunc(nargs = 2) and dfunc(nargs = 4) are ambiguous when called +-- with 0 to 2 arguments. + +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc()" +== 252 +-- truncate_limit: 100 +-- fail +select dfunc(1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(1)" +== 253 +-- truncate_limit: 100 +-- fail +select dfunc(1, 2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(1, 2)" +== 254 +-- truncate_limit: 100 +-- fail +select dfunc(1, 2, 3) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(1, 2, 3)" +== 255 +-- truncate_limit: 100 +-- ok +select dfunc(1, 2, 3, 4) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(1, 2, 3, 4)" +== 256 +-- truncate_limit: 100 +-- ok + +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int, int)" +== 257 +-- truncate_limit: 100 +drop function dfunc(int, int, int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int, int, int, int)" +== 258 +-- truncate_limit: 100 +-- default values are not allowed for output parameters +create function dfunc(out int = 20) returns int as $$ + select 1; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(OUT int = 20) RETURNS int AS $$\n select 1;\n$$ LANGUAGE sql" +== 259 +-- truncate_limit: 100 +-- polymorphic parameter test +create function dfunc(anyelement = 'World'::text) returns text as $$ + select 'Hello, ' || $1::text; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(anyelement = 'World'::text) RETURNS text AS $$\n select 'Hello, ' || $1::te..." +== 260 +-- truncate_limit: 100 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc()" +== 261 +-- truncate_limit: 100 +select dfunc(0) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(0)" +== 262 +-- truncate_limit: 100 +select dfunc(to_date('20081215','YYYYMMDD')) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(to_date('20081215', 'YYYYMMDD'))" +== 263 +-- truncate_limit: 100 +select dfunc('City'::text) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('City'::text)" +== 264 +-- truncate_limit: 100 +drop function dfunc(anyelement) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(anyelement)" +== 265 +-- truncate_limit: 100 +-- check defaults for variadics + +create function dfunc(a variadic int[]) returns int as +$$ select array_upper($1, 1) $$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(VARIADIC a int[]) RETURNS int AS $$ select array_upper($1, 1) $$ LANGUAGE sql" +== 266 +-- truncate_limit: 100 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc()" +== 267 +-- truncate_limit: 100 +-- fail +select dfunc(10) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(10)" +== 268 +-- truncate_limit: 100 +select dfunc(10,20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(10, 20)" +== 269 +-- truncate_limit: 100 +create or replace function dfunc(a variadic int[] default array[]::int[]) returns int as +$$ select array_upper($1, 1) $$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dfunc(VARIADIC a int[] = ARRAY[]::int[]) RETURNS int AS $$ select arra..." +== 270 +-- truncate_limit: 100 +select dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc()" +== 271 +-- truncate_limit: 100 +-- now ok +select dfunc(10) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(10)" +== 272 +-- truncate_limit: 100 +select dfunc(10,20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(10, 20)" +== 273 +-- truncate_limit: 100 +-- can't remove the default once it exists +create or replace function dfunc(a variadic int[]) returns int as +$$ select array_upper($1, 1) $$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dfunc(VARIADIC a int[]) RETURNS int AS $$ select array_upper($1, 1) $$..." +== 274 +-- truncate_limit: 100 +drop function dfunc(a variadic int[]) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(VARIADIC a int[])" +== 275 +-- truncate_limit: 100 +-- Ambiguity should be reported only if there's not a better match available + +create function dfunc(int = 1, int = 2, int = 3) returns int as $$ + select 3; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(int = 1, int = 2, int = 3) RETURNS int AS $$\n select 3;\n$$ LANGUAGE sql" +== 276 +-- truncate_limit: 100 +create function dfunc(int = 1, int = 2) returns int as $$ + select 2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(int = 1, int = 2) RETURNS int AS $$\n select 2;\n$$ LANGUAGE sql" +== 277 +-- truncate_limit: 100 +create function dfunc(text) returns text as $$ + select $1; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(text) RETURNS text AS $$\n select $1;\n$$ LANGUAGE sql" +== 278 +-- truncate_limit: 100 +-- dfunc(narg=2) and dfunc(narg=3) are ambiguous +select dfunc(1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(1)" +== 279 +-- truncate_limit: 100 +-- fail + +-- but this works since the ambiguous functions aren't preferred anyway +select dfunc('Hi') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('Hi')" +== 280 +-- truncate_limit: 100 +drop function dfunc(int, int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int, int, int)" +== 281 +-- truncate_limit: 100 +drop function dfunc(int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int, int)" +== 282 +-- truncate_limit: 100 +drop function dfunc(text) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(text)" +== 283 +-- truncate_limit: 100 +|-- +-- Tests for named- and mixed-notation function calling +|-- + +create function dfunc(a int, b int, c int = 0, d int = 0) + returns table (a int, b int, c int, d int) as $$ + select $1, $2, $3, $4; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a int, b int, c int = 0, d int = 0) RETURNS TABLE (a int, b int, c int, d i..." +== 284 +-- truncate_limit: 100 +select (dfunc(10,20,30)).* +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (dfunc(10, 20, 30)).*" +== 285 +-- truncate_limit: 100 +select (dfunc(a := 10, b := 20, c := 30)).* +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (dfunc(a := 10, b := 20, c := 30)).*" +== 286 +-- truncate_limit: 100 +select * from dfunc(a := 10, b := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(a := 10, b := 20)" +== 287 +-- truncate_limit: 100 +select * from dfunc(b := 10, a := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(b := 10, a := 20)" +== 288 +-- truncate_limit: 100 +select * from dfunc(0) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(0)" +== 289 +-- truncate_limit: 100 +-- fail +select * from dfunc(1,2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(1, 2)" +== 290 +-- truncate_limit: 100 +select * from dfunc(1,2,c := 3) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(1, 2, c := 3)" +== 291 +-- truncate_limit: 100 +select * from dfunc(1,2,d := 3) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(1, 2, d := 3)" +== 292 +-- truncate_limit: 100 +select * from dfunc(x := 20, b := 10, x := 30) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(x := 20, b := 10, x := 30)" +== 293 +-- truncate_limit: 100 +-- fail, duplicate name +select * from dfunc(10, b := 20, 30) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(10, b := 20, 30)" +== 294 +-- truncate_limit: 100 +-- fail, named args must be last +select * from dfunc(x := 10, b := 20, c := 30) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(x := 10, b := 20, c := 30)" +== 295 +-- truncate_limit: 100 +-- fail, unknown param +select * from dfunc(10, 10, a := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(10, 10, a := 20)" +== 296 +-- truncate_limit: 100 +-- fail, a overlaps positional parameter +select * from dfunc(1,c := 2,d := 3) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(1, c := 2, d := 3)" +== 297 +-- truncate_limit: 100 +-- fail, no value for b + +drop function dfunc(int, int, int, int) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(int, int, int, int)" +== 298 +-- truncate_limit: 100 +-- test with different parameter types +create function dfunc(a varchar, b numeric, c date = current_date) + returns table (a varchar, b numeric, c date) as $$ + select $1, $2, $3; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a varchar, b numeric, c date = current_date) RETURNS TABLE (a varchar, b nu..." +== 299 +-- truncate_limit: 100 +select (dfunc('Hello World', 20, '2009-07-25'::date)).* +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (dfunc('Hello World', 20, '2009-07-25'::date)).*" +== 300 +-- truncate_limit: 100 +select * from dfunc('Hello World', 20, '2009-07-25'::date) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc('Hello World', 20, '2009-07-25'::date)" +== 301 +-- truncate_limit: 100 +select * from dfunc(c := '2009-07-25'::date, a := 'Hello World', b := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(c := '2009-07-25'::date, a := 'Hello World', b := 20)" +== 302 +-- truncate_limit: 100 +select * from dfunc('Hello World', b := 20, c := '2009-07-25'::date) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc('Hello World', b := 20, c := '2009-07-25'::date)" +== 303 +-- truncate_limit: 100 +select * from dfunc('Hello World', c := '2009-07-25'::date, b := 20) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc('Hello World', c := '2009-07-25'::date, b := 20)" +== 304 +-- truncate_limit: 100 +select * from dfunc('Hello World', c := 20, b := '2009-07-25'::date) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc('Hello World', c := 20, b := '2009-07-25'::date)" +== 305 +-- truncate_limit: 100 +-- fail + +drop function dfunc(varchar, numeric, date) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(varchar, numeric, date)" +== 306 +-- truncate_limit: 100 +-- test out parameters with named params +create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric) +returns record as $$ + select $1, $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a varchar = 'def a', OUT _a varchar, c numeric = NULL, OUT _c numeric) RETU..." +== 307 +-- truncate_limit: 100 +select (dfunc()).* +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (dfunc()).*" +== 308 +-- truncate_limit: 100 +select * from dfunc() +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc()" +== 309 +-- truncate_limit: 100 +select * from dfunc('Hello', 100) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc('Hello', 100)" +== 310 +-- truncate_limit: 100 +select * from dfunc(a := 'Hello', c := 100) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(a := 'Hello', c := 100)" +== 311 +-- truncate_limit: 100 +select * from dfunc(c := 100, a := 'Hello') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(c := 100, a := 'Hello')" +== 312 +-- truncate_limit: 100 +select * from dfunc('Hello') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc('Hello')" +== 313 +-- truncate_limit: 100 +select * from dfunc('Hello', c := 100) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc('Hello', c := 100)" +== 314 +-- truncate_limit: 100 +select * from dfunc(c := 100) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfunc(c := 100)" +== 315 +-- truncate_limit: 100 +-- fail, can no longer change an input parameter's name +create or replace function dfunc(a varchar = 'def a', out _a varchar, x numeric = NULL, out _c numeric) +returns record as $$ + select $1, $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dfunc(a varchar = 'def a', OUT _a varchar, x numeric = NULL, OUT _c nu..." +== 316 +-- truncate_limit: 100 +create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric = NULL, out _c numeric) +returns record as $$ + select $1, $2; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dfunc(a varchar = 'def a', OUT _a varchar, numeric = NULL, OUT _c nume..." +== 317 +-- truncate_limit: 100 +drop function dfunc(varchar, numeric) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(varchar, numeric)" +== 318 +-- truncate_limit: 100 +--fail, named parameters are not unique +create function testpolym(a int, a int) returns int as $$ select 1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testpolym(a int, a int) RETURNS int AS $$ select 1;$$ LANGUAGE sql" +== 319 +-- truncate_limit: 100 +create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testpolym(int, OUT a int, OUT a int) RETURNS int AS $$ select 1;$$ LANGUAGE sql" +== 320 +-- truncate_limit: 100 +create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testpolym(OUT a int, INOUT a int) RETURNS int AS $$ select 1;$$ LANGUAGE sql" +== 321 +-- truncate_limit: 100 +create function testpolym(a int, inout a int) returns int as $$ select 1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testpolym(a int, INOUT a int) RETURNS int AS $$ select 1;$$ LANGUAGE sql" +== 322 +-- truncate_limit: 100 +-- valid +create function testpolym(a int, out a int) returns int as $$ select $1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testpolym(a int, OUT a int) RETURNS int AS $$ select $1;$$ LANGUAGE sql" +== 323 +-- truncate_limit: 100 +select testpolym(37) +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testpolym(37)" +== 324 +-- truncate_limit: 100 +drop function testpolym(int) +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION testpolym(int)" +== 325 +-- truncate_limit: 100 +create function testpolym(a int) returns table(a int) as $$ select $1;$$ language sql +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testpolym(a int) RETURNS TABLE (a int) AS $$ select $1;$$ LANGUAGE sql" +== 326 +-- truncate_limit: 100 +select * from testpolym(37) +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testpolym(37)" +== 327 +-- truncate_limit: 100 +drop function testpolym(int) +-- +FUNCTION: name="testpolym" function="testpolym" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION testpolym(int)" +== 328 +-- truncate_limit: 100 +-- test polymorphic params and defaults +create function dfunc(a anyelement, b anyelement = null, flag bool = true) +returns anyelement as $$ + select case when $3 then $1 else $2 end; +$$ language sql +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dfunc(a anyelement, b anyelement = NULL, flag bool = true) RETURNS anyelement AS ..." +== 329 +-- truncate_limit: 100 +select dfunc(1,2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(1, 2)" +== 330 +-- truncate_limit: 100 +select dfunc('a'::text, 'b') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b')" +== 331 +-- truncate_limit: 100 +-- positional notation with default + +select dfunc(a := 1, b := 2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 1, b := 2)" +== 332 +-- truncate_limit: 100 +select dfunc(a := 'a'::text, b := 'b') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 'a'::text, b := 'b')" +== 333 +-- truncate_limit: 100 +select dfunc(a := 'a'::text, b := 'b', flag := false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 'a'::text, b := 'b', flag := false)" +== 334 +-- truncate_limit: 100 +-- named notation + +select dfunc(b := 'b'::text, a := 'a') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(b := 'b'::text, a := 'a')" +== 335 +-- truncate_limit: 100 +-- named notation with default +select dfunc(a := 'a'::text, flag := true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 'a'::text, flag := true)" +== 336 +-- truncate_limit: 100 +-- named notation with default +select dfunc(a := 'a'::text, flag := false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 'a'::text, flag := false)" +== 337 +-- truncate_limit: 100 +-- named notation with default +select dfunc(b := 'b'::text, a := 'a', flag := true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(b := 'b'::text, a := 'a', flag := true)" +== 338 +-- truncate_limit: 100 +-- named notation + +select dfunc('a'::text, 'b', false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b', false)" +== 339 +-- truncate_limit: 100 +-- full positional notation +select dfunc('a'::text, 'b', flag := false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b', flag := false)" +== 340 +-- truncate_limit: 100 +-- mixed notation +select dfunc('a'::text, 'b', true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b', true)" +== 341 +-- truncate_limit: 100 +-- full positional notation +select dfunc('a'::text, 'b', flag := true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b', flag := true)" +== 342 +-- truncate_limit: 100 +-- mixed notation + +-- ansi/sql syntax +select dfunc(a => 1, b => 2) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 1, b := 2)" +== 343 +-- truncate_limit: 100 +select dfunc(a => 'a'::text, b => 'b') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 'a'::text, b := 'b')" +== 344 +-- truncate_limit: 100 +select dfunc(a => 'a'::text, b => 'b', flag => false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 'a'::text, b := 'b', flag := false)" +== 345 +-- truncate_limit: 100 +-- named notation + +select dfunc(b => 'b'::text, a => 'a') +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(b := 'b'::text, a := 'a')" +== 346 +-- truncate_limit: 100 +-- named notation with default +select dfunc(a => 'a'::text, flag => true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 'a'::text, flag := true)" +== 347 +-- truncate_limit: 100 +-- named notation with default +select dfunc(a => 'a'::text, flag => false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 'a'::text, flag := false)" +== 348 +-- truncate_limit: 100 +-- named notation with default +select dfunc(b => 'b'::text, a => 'a', flag => true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(b := 'b'::text, a := 'a', flag := true)" +== 349 +-- truncate_limit: 100 +-- named notation + +select dfunc('a'::text, 'b', false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b', false)" +== 350 +-- truncate_limit: 100 +-- full positional notation +select dfunc('a'::text, 'b', flag => false) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b', flag := false)" +== 351 +-- truncate_limit: 100 +-- mixed notation +select dfunc('a'::text, 'b', true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b', true)" +== 352 +-- truncate_limit: 100 +-- full positional notation +select dfunc('a'::text, 'b', flag => true) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc('a'::text, 'b', flag := true)" +== 353 +-- truncate_limit: 100 +-- mixed notation + +-- this tests lexer edge cases around => +select dfunc(a =>-1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := -1)" +== 354 +-- truncate_limit: 100 +select dfunc(a =>+1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := + 1)" +== 355 +-- truncate_limit: 100 +select dfunc(a =>/**/1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 1)" +== 356 +-- truncate_limit: 100 +select dfunc(a =>--comment to be removed by psql + 1) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dfunc(a := 1)" +== 357 +-- truncate_limit: 100 +-- need DO to protect the -- from psql +do $$ + declare r integer; + begin + select dfunc(a=>-- comment + 1) into r; + raise info 'r = %', r; + end; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\n declare r integer;\n begin\n select dfunc(a=>-- comment\n 1) into r;\n raise info..." +== 358 +-- truncate_limit: 100 +-- check reverse-listing of named-arg calls +CREATE VIEW dfview AS + SELECT q1, q2, + dfunc(q1,q2, flag := q1>q2) as c3, + dfunc(q1, flag := q1 q2) AS c3, dfunc(q1, flag := q1 <..." +== 359 +-- truncate_limit: 100 +select * from dfview +-- +TABLE: name="dfview" schema="" table="dfview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dfview" +== 360 +-- truncate_limit: 100 +drop view dfview +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW dfview" +== 361 +-- truncate_limit: 100 +drop function dfunc(anyelement, anyelement, bool) +-- +FUNCTION: name="dfunc" function="dfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dfunc(anyelement, anyelement, bool)" +== 362 +-- truncate_limit: 100 +|-- +-- Tests for ANYCOMPATIBLE polymorphism family +|-- + +create function anyctest(anycompatible, anycompatible) +returns anycompatible as $$ + select greatest($1, $2) +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatible, anycompatible) RETURNS anycompatible AS $$\n select great..." +== 363 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12) x" +== 364 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12.3) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12.3) x" +== 365 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, point(1,2)) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, point(1, 2)) x" +== 366 +-- truncate_limit: 100 +-- fail +select x, pg_typeof(x) from anyctest('11', '12.3') x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest('11', '12.3') x" +== 367 +-- truncate_limit: 100 +-- defaults to text + +drop function anyctest(anycompatible, anycompatible) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(anycompatible, anycompatible)" +== 368 +-- truncate_limit: 100 +create function anyctest(anycompatible, anycompatible) +returns anycompatiblearray as $$ + select array[$1, $2] +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatible, anycompatible) RETURNS anycompatiblearray AS $$\n select ..." +== 369 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12) x" +== 370 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12.3) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12.3) x" +== 371 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, array[1,2]) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, ARRAY[1, 2]) x" +== 372 +-- truncate_limit: 100 +-- fail + +drop function anyctest(anycompatible, anycompatible) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(anycompatible, anycompatible)" +== 373 +-- truncate_limit: 100 +create function anyctest(anycompatible, anycompatiblearray) +returns anycompatiblearray as $$ + select array[$1] || $2 +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatible, anycompatiblearray) RETURNS anycompatiblearray AS $$\n se..." +== 374 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, array[12]) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, ARRAY[12]) x" +== 375 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, array[12.3]) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, ARRAY[12.3]) x" +== 376 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(12.3, array[13]) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(12.3, ARRAY[13]) x" +== 377 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(12.3, '{13,14.4}') x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(12.3, '{13,14.4}') x" +== 378 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, array[point(1,2)]) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, ARRAY[point(1, 2)]) x" +== 379 +-- truncate_limit: 100 +-- fail +select x, pg_typeof(x) from anyctest(11, 12) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12) x" +== 380 +-- truncate_limit: 100 +-- fail + +drop function anyctest(anycompatible, anycompatiblearray) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(anycompatible, anycompatiblearray)" +== 381 +-- truncate_limit: 100 +create function anyctest(anycompatible, anycompatiblerange) +returns anycompatiblerange as $$ + select $2 +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatible, anycompatiblerange) RETURNS anycompatiblerange AS $$\n se..." +== 382 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, int4range(4,7)) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, int4range(4, 7)) x" +== 383 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, numrange(4,7)) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, numrange(4, 7)) x" +== 384 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12) x" +== 385 +-- truncate_limit: 100 +-- fail +select x, pg_typeof(x) from anyctest(11.2, int4range(4,7)) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11.2, int4range(4, 7)) x" +== 386 +-- truncate_limit: 100 +-- fail +select x, pg_typeof(x) from anyctest(11.2, '[4,7)') x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11.2, '[4,7)') x" +== 387 +-- truncate_limit: 100 +-- fail + +drop function anyctest(anycompatible, anycompatiblerange) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(anycompatible, anycompatiblerange)" +== 388 +-- truncate_limit: 100 +create function anyctest(anycompatiblerange, anycompatiblerange) +returns anycompatible as $$ + select lower($1) + upper($2) +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatiblerange, anycompatiblerange) RETURNS anycompatible AS $$\n se..." +== 389 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(int4range(11,12), int4range(4,7)) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(int4range(11, 12), int4range(4, 7)) x" +== 390 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(int4range(11,12), numrange(4,7)) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(int4range(11, 12), numrange(4, 7)) x" +== 391 +-- truncate_limit: 100 +-- fail + +drop function anyctest(anycompatiblerange, anycompatiblerange) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(anycompatiblerange, anycompatiblerange)" +== 392 +-- truncate_limit: 100 +-- fail, can't infer result type: +create function anyctest(anycompatible) +returns anycompatiblerange as $$ + select $1 +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatible) RETURNS anycompatiblerange AS $$\n select $1\n$$ LANGUAGE sql" +== 393 +-- truncate_limit: 100 +create function anyctest(anycompatible, anycompatiblemultirange) +returns anycompatiblemultirange as $$ + select $2 +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatible, anycompatiblemultirange) RETURNS anycompatiblemultirange ..." +== 394 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, multirange(int4range(4,7))) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, multirange(int4range(4, 7))) x" +== 395 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, multirange(numrange(4,7))) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, multirange(numrange(4, 7))) x" +== 396 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12) x" +== 397 +-- truncate_limit: 100 +-- fail +select x, pg_typeof(x) from anyctest(11.2, multirange(int4range(4,7))) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11.2, multirange(int4range(4, 7))) x" +== 398 +-- truncate_limit: 100 +-- fail +select x, pg_typeof(x) from anyctest(11.2, '{[4,7)}') x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11.2, '{[4,7)}') x" +== 399 +-- truncate_limit: 100 +-- fail + +drop function anyctest(anycompatible, anycompatiblemultirange) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(anycompatible, anycompatiblemultirange)" +== 400 +-- truncate_limit: 100 +create function anyctest(anycompatiblemultirange, anycompatiblemultirange) +returns anycompatible as $$ + select lower($1) + upper($2) +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatiblemultirange, anycompatiblemultirange) RETURNS anycompatible ..." +== 401 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(int4range(4,7))) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(multirange(int4range(11, 12)), multirange(int4range(4, 7))) x" +== 402 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(numrange(4,7))) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="multirange" function="multirange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(multirange(int4range(11, 12)), multirange(numrange(4, 7))) x" +== 403 +-- truncate_limit: 100 +-- fail + +drop function anyctest(anycompatiblemultirange, anycompatiblemultirange) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(anycompatiblemultirange, anycompatiblemultirange)" +== 404 +-- truncate_limit: 100 +-- fail, can't infer result type: +create function anyctest(anycompatible) +returns anycompatiblemultirange as $$ + select $1 +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatible) RETURNS anycompatiblemultirange AS $$\n select $1\n$$ LANG..." +== 405 +-- truncate_limit: 100 +create function anyctest(anycompatiblenonarray, anycompatiblenonarray) +returns anycompatiblearray as $$ + select array[$1, $2] +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(anycompatiblenonarray, anycompatiblenonarray) RETURNS anycompatiblearray..." +== 406 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12) x" +== 407 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12.3) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12.3) x" +== 408 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(array[11], array[1,2]) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(ARRAY[11], ARRAY[1, 2]) x" +== 409 +-- truncate_limit: 100 +-- fail + +drop function anyctest(anycompatiblenonarray, anycompatiblenonarray) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(anycompatiblenonarray, anycompatiblenonarray)" +== 410 +-- truncate_limit: 100 +create function anyctest(a anyelement, b anyarray, + c anycompatible, d anycompatible) +returns anycompatiblearray as $$ + select array[c, d] +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(a anyelement, b anyarray, c anycompatible, d anycompatible) RETURNS anyc..." +== 411 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, array[1, 2], 42, 34.5) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, ARRAY[1, 2], 42, 34.5) x" +== 412 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, array[1, 2], point(1,2), point(3,4)) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, ARRAY[1, 2], point(1, 2), point(3, 4)) x" +== 413 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, '{1,2}', point(1,2), '(3,4)') x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, '{1,2}', point(1, 2), '(3,4)') x" +== 414 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, array[1, 2.2], 42, 34.5) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, ARRAY[1, 2.2], 42, 34.5) x" +== 415 +-- truncate_limit: 100 +-- fail + +drop function anyctest(a anyelement, b anyarray, + c anycompatible, d anycompatible) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(a anyelement, b anyarray, c anycompatible, d anycompatible)" +== 416 +-- truncate_limit: 100 +create function anyctest(variadic anycompatiblearray) +returns anycompatiblearray as $$ + select $1 +$$ language sql +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyctest(VARIADIC anycompatiblearray) RETURNS anycompatiblearray AS $$\n select $..." +== 417 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12) x" +== 418 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, 12.2) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, 12.2) x" +== 419 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, '12') x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, '12') x" +== 420 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(11, '12.2') x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(11, '12.2') x" +== 421 +-- truncate_limit: 100 +-- fail +select x, pg_typeof(x) from anyctest(variadic array[11, 12]) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(VARIADIC ARRAY[11, 12]) x" +== 422 +-- truncate_limit: 100 +select x, pg_typeof(x) from anyctest(variadic array[11, 12.2]) x +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, pg_typeof(x) FROM anyctest(VARIADIC ARRAY[11, 12.2]) x" +== 423 +-- truncate_limit: 100 +drop function anyctest(variadic anycompatiblearray) +-- +FUNCTION: name="anyctest" function="anyctest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyctest(VARIADIC anycompatiblearray)" diff --git a/parser/testdata/summary_truncate/postgres_regress/portals.metadata.json b/parser/testdata/summary_truncate/postgres_regress/portals.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/portals.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/portals.test b/parser/testdata/summary_truncate/postgres_regress/portals.test new file mode 100644 index 0000000..e636128 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/portals.test @@ -0,0 +1,2323 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Cursor regression tests +|-- + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 002 +-- truncate_limit: 100 +DECLARE foo1 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo1 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 003 +-- truncate_limit: 100 +DECLARE foo2 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo2 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 004 +-- truncate_limit: 100 +DECLARE foo3 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo3 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 005 +-- truncate_limit: 100 +DECLARE foo4 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo4 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 006 +-- truncate_limit: 100 +DECLARE foo5 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo5 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 007 +-- truncate_limit: 100 +DECLARE foo6 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo6 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 008 +-- truncate_limit: 100 +DECLARE foo7 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo7 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 009 +-- truncate_limit: 100 +DECLARE foo8 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo8 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 010 +-- truncate_limit: 100 +DECLARE foo9 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo9 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 011 +-- truncate_limit: 100 +DECLARE foo10 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo10 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 012 +-- truncate_limit: 100 +DECLARE foo11 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo11 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 013 +-- truncate_limit: 100 +DECLARE foo12 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo12 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 014 +-- truncate_limit: 100 +DECLARE foo13 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo13 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 015 +-- truncate_limit: 100 +DECLARE foo14 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo14 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 016 +-- truncate_limit: 100 +DECLARE foo15 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo15 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 017 +-- truncate_limit: 100 +DECLARE foo16 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo16 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 018 +-- truncate_limit: 100 +DECLARE foo17 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo17 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 019 +-- truncate_limit: 100 +DECLARE foo18 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo18 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 020 +-- truncate_limit: 100 +DECLARE foo19 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo19 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 021 +-- truncate_limit: 100 +DECLARE foo20 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo20 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 022 +-- truncate_limit: 100 +DECLARE foo21 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo21 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 023 +-- truncate_limit: 100 +DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2" +== 024 +-- truncate_limit: 100 +DECLARE foo23 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo23 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 025 +-- truncate_limit: 100 +FETCH 1 in foo1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo1" +== 026 +-- truncate_limit: 100 +FETCH 2 in foo2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 2 foo2" +== 027 +-- truncate_limit: 100 +FETCH 3 in foo3 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 3 foo3" +== 028 +-- truncate_limit: 100 +FETCH 4 in foo4 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 4 foo4" +== 029 +-- truncate_limit: 100 +FETCH 5 in foo5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 5 foo5" +== 030 +-- truncate_limit: 100 +FETCH 6 in foo6 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 6 foo6" +== 031 +-- truncate_limit: 100 +FETCH 7 in foo7 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 7 foo7" +== 032 +-- truncate_limit: 100 +FETCH 8 in foo8 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 8 foo8" +== 033 +-- truncate_limit: 100 +FETCH 9 in foo9 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 9 foo9" +== 034 +-- truncate_limit: 100 +FETCH 10 in foo10 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 10 foo10" +== 035 +-- truncate_limit: 100 +FETCH 11 in foo11 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 11 foo11" +== 036 +-- truncate_limit: 100 +FETCH 12 in foo12 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 12 foo12" +== 037 +-- truncate_limit: 100 +FETCH 13 in foo13 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 13 foo13" +== 038 +-- truncate_limit: 100 +FETCH 14 in foo14 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 14 foo14" +== 039 +-- truncate_limit: 100 +FETCH 15 in foo15 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 15 foo15" +== 040 +-- truncate_limit: 100 +FETCH 16 in foo16 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 16 foo16" +== 041 +-- truncate_limit: 100 +FETCH 17 in foo17 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 17 foo17" +== 042 +-- truncate_limit: 100 +FETCH 18 in foo18 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 18 foo18" +== 043 +-- truncate_limit: 100 +FETCH 19 in foo19 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 19 foo19" +== 044 +-- truncate_limit: 100 +FETCH 20 in foo20 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 20 foo20" +== 045 +-- truncate_limit: 100 +FETCH 21 in foo21 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 21 foo21" +== 046 +-- truncate_limit: 100 +FETCH 22 in foo22 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 22 foo22" +== 047 +-- truncate_limit: 100 +FETCH 23 in foo23 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 23 foo23" +== 048 +-- truncate_limit: 100 +FETCH backward 1 in foo23 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR foo23" +== 049 +-- truncate_limit: 100 +FETCH backward 2 in foo22 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 2 foo22" +== 050 +-- truncate_limit: 100 +FETCH backward 3 in foo21 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 3 foo21" +== 051 +-- truncate_limit: 100 +FETCH backward 4 in foo20 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 4 foo20" +== 052 +-- truncate_limit: 100 +FETCH backward 5 in foo19 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 5 foo19" +== 053 +-- truncate_limit: 100 +FETCH backward 6 in foo18 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 6 foo18" +== 054 +-- truncate_limit: 100 +FETCH backward 7 in foo17 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 7 foo17" +== 055 +-- truncate_limit: 100 +FETCH backward 8 in foo16 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 8 foo16" +== 056 +-- truncate_limit: 100 +FETCH backward 9 in foo15 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 9 foo15" +== 057 +-- truncate_limit: 100 +FETCH backward 10 in foo14 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 10 foo14" +== 058 +-- truncate_limit: 100 +FETCH backward 11 in foo13 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 11 foo13" +== 059 +-- truncate_limit: 100 +FETCH backward 12 in foo12 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 12 foo12" +== 060 +-- truncate_limit: 100 +FETCH backward 13 in foo11 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 13 foo11" +== 061 +-- truncate_limit: 100 +FETCH backward 14 in foo10 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 14 foo10" +== 062 +-- truncate_limit: 100 +FETCH backward 15 in foo9 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 15 foo9" +== 063 +-- truncate_limit: 100 +FETCH backward 16 in foo8 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 16 foo8" +== 064 +-- truncate_limit: 100 +FETCH backward 17 in foo7 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 17 foo7" +== 065 +-- truncate_limit: 100 +FETCH backward 18 in foo6 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 18 foo6" +== 066 +-- truncate_limit: 100 +FETCH backward 19 in foo5 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 19 foo5" +== 067 +-- truncate_limit: 100 +FETCH backward 20 in foo4 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 20 foo4" +== 068 +-- truncate_limit: 100 +FETCH backward 21 in foo3 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 21 foo3" +== 069 +-- truncate_limit: 100 +FETCH backward 22 in foo2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 22 foo2" +== 070 +-- truncate_limit: 100 +FETCH backward 23 in foo1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD 23 foo1" +== 071 +-- truncate_limit: 100 +CLOSE foo1 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo1" +== 072 +-- truncate_limit: 100 +CLOSE foo2 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo2" +== 073 +-- truncate_limit: 100 +CLOSE foo3 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo3" +== 074 +-- truncate_limit: 100 +CLOSE foo4 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo4" +== 075 +-- truncate_limit: 100 +CLOSE foo5 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo5" +== 076 +-- truncate_limit: 100 +CLOSE foo6 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo6" +== 077 +-- truncate_limit: 100 +CLOSE foo7 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo7" +== 078 +-- truncate_limit: 100 +CLOSE foo8 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo8" +== 079 +-- truncate_limit: 100 +CLOSE foo9 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo9" +== 080 +-- truncate_limit: 100 +CLOSE foo10 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo10" +== 081 +-- truncate_limit: 100 +CLOSE foo11 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo11" +== 082 +-- truncate_limit: 100 +CLOSE foo12 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo12" +== 083 +-- truncate_limit: 100 +-- leave some cursors open, to test that auto-close works. + +-- record this in the system view as well (don't query the time field there +-- however) +SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors ORDER BY 1 +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors ORDER BY 1" +== 084 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 085 +-- truncate_limit: 100 +SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors" +== 086 +-- truncate_limit: 100 +|-- +-- NO SCROLL disallows backward fetching +|-- + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 087 +-- truncate_limit: 100 +DECLARE foo24 NO SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo24 NO SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 088 +-- truncate_limit: 100 +FETCH 1 FROM foo24 +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo24" +== 089 +-- truncate_limit: 100 +FETCH BACKWARD 1 FROM foo24 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR foo24" +== 090 +-- truncate_limit: 100 +-- should fail + +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 091 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 092 +-- truncate_limit: 100 +DECLARE foo24 NO SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo24 NO SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2" +== 093 +-- truncate_limit: 100 +FETCH 1 FROM foo24 +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo24" +== 094 +-- truncate_limit: 100 +FETCH ABSOLUTE 2 FROM foo24 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ABSOLUTE 2 foo24" +== 095 +-- truncate_limit: 100 +-- allowed + +FETCH ABSOLUTE 1 FROM foo24 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FIRST foo24" +== 096 +-- truncate_limit: 100 +-- should fail + +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 097 +-- truncate_limit: 100 +|-- +-- Cursors outside transaction blocks +|-- + + +SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors" +== 098 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 099 +-- truncate_limit: 100 +DECLARE foo25 SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo25 SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2" +== 100 +-- truncate_limit: 100 +FETCH FROM foo25 +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo25" +== 101 +-- truncate_limit: 100 +FETCH FROM foo25 +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo25" +== 102 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 103 +-- truncate_limit: 100 +FETCH FROM foo25 +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo25" +== 104 +-- truncate_limit: 100 +FETCH BACKWARD FROM foo25 +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR foo25" +== 105 +-- truncate_limit: 100 +FETCH ABSOLUTE -1 FROM foo25 +-- +STMT: FetchStmt +TRUNCATED: "FETCH LAST foo25" +== 106 +-- truncate_limit: 100 +SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors" +== 107 +-- truncate_limit: 100 +CLOSE foo25 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo25" +== 108 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 109 +-- truncate_limit: 100 +DECLARE foo25ns NO SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo25ns NO SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2" +== 110 +-- truncate_limit: 100 +FETCH FROM foo25ns +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo25ns" +== 111 +-- truncate_limit: 100 +FETCH FROM foo25ns +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo25ns" +== 112 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 113 +-- truncate_limit: 100 +FETCH FROM foo25ns +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo25ns" +== 114 +-- truncate_limit: 100 +FETCH ABSOLUTE 4 FROM foo25ns +-- +STMT: FetchStmt +TRUNCATED: "FETCH ABSOLUTE 4 foo25ns" +== 115 +-- truncate_limit: 100 +FETCH ABSOLUTE 4 FROM foo25ns +-- +STMT: FetchStmt +TRUNCATED: "FETCH ABSOLUTE 4 foo25ns" +== 116 +-- truncate_limit: 100 +-- fail + +SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors" +== 117 +-- truncate_limit: 100 +CLOSE foo25ns +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo25ns" +== 118 +-- truncate_limit: 100 +|-- +-- ROLLBACK should close holdable cursors +|-- + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 119 +-- truncate_limit: 100 +DECLARE foo26 CURSOR WITH HOLD FOR SELECT * FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo26 CURSOR WITH HOLD FOR SELECT * FROM tenk1 ORDER BY unique2" +== 120 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 121 +-- truncate_limit: 100 +-- should fail +FETCH FROM foo26 +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo26" +== 122 +-- truncate_limit: 100 +|-- +-- Parameterized DECLARE needs to insert param values into the cursor portal +|-- + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 123 +-- truncate_limit: 100 +CREATE FUNCTION declares_cursor(text) + RETURNS void + AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1;' + LANGUAGE SQL +-- +FUNCTION: name="declares_cursor" function="declares_cursor" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION declares_cursor(text) RETURNS void AS $$DECLARE c CURSOR FOR SELECT stringu1 FROM..." +== 124 +-- truncate_limit: 100 +SELECT declares_cursor('AB%') +-- +FUNCTION: name="declares_cursor" function="declares_cursor" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT declares_cursor('AB%')" +== 125 +-- truncate_limit: 100 +FETCH ALL FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c" +== 126 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 127 +-- truncate_limit: 100 +|-- +-- Test behavior of both volatile and stable functions inside a cursor; +-- in particular we want to see what happens during commit of a holdable +-- cursor +|-- + +create temp table tt1(f1 int) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt1 (f1 int)" +== 128 +-- truncate_limit: 100 +create function count_tt1_v() returns int8 as +'select count(*) from tt1' language sql volatile +-- +FUNCTION: name="count_tt1_v" function="count_tt1_v" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION count_tt1_v() RETURNS int8 AS $$select count(*) from tt1$$ LANGUAGE sql VOLATILE" +== 129 +-- truncate_limit: 100 +create function count_tt1_s() returns int8 as +'select count(*) from tt1' language sql stable +-- +FUNCTION: name="count_tt1_s" function="count_tt1_s" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION count_tt1_s() RETURNS int8 AS $$select count(*) from tt1$$ LANGUAGE sql STABLE" +== 130 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 131 +-- truncate_limit: 100 +insert into tt1 values(1) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt1 VALUES (1)" +== 132 +-- truncate_limit: 100 +declare c1 cursor for select count_tt1_v(), count_tt1_s() +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT count_tt1_v(), count_tt1_s()" +== 133 +-- truncate_limit: 100 +insert into tt1 values(2) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt1 VALUES (2)" +== 134 +-- truncate_limit: 100 +fetch all from c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c1" +== 135 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 136 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 137 +-- truncate_limit: 100 +insert into tt1 values(1) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt1 VALUES (1)" +== 138 +-- truncate_limit: 100 +declare c2 cursor with hold for select count_tt1_v(), count_tt1_s() +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c2 CURSOR WITH HOLD FOR SELECT count_tt1_v(), count_tt1_s()" +== 139 +-- truncate_limit: 100 +insert into tt1 values(2) +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt1 VALUES (2)" +== 140 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 141 +-- truncate_limit: 100 +delete from tt1 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tt1" +== 142 +-- truncate_limit: 100 +fetch all from c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c2" +== 143 +-- truncate_limit: 100 +drop function count_tt1_v() +-- +FUNCTION: name="count_tt1_v" function="count_tt1_v" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION count_tt1_v()" +== 144 +-- truncate_limit: 100 +drop function count_tt1_s() +-- +FUNCTION: name="count_tt1_s" function="count_tt1_s" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION count_tt1_s()" +== 145 +-- truncate_limit: 100 +-- Create a cursor with the BINARY option and check the pg_cursors view +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 146 +-- truncate_limit: 100 +SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors" +== 147 +-- truncate_limit: 100 +DECLARE bc BINARY CURSOR FOR SELECT * FROM tenk1 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE bc BINARY CURSOR FOR SELECT * FROM tenk1" +== 148 +-- truncate_limit: 100 +SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors ORDER BY 1 +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors ORDER BY 1" +== 149 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 150 +-- truncate_limit: 100 +-- We should not see the portal that is created internally to +-- implement EXECUTE in pg_cursors +PREPARE cprep AS + SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE cprep AS SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors" +== 151 +-- truncate_limit: 100 +EXECUTE cprep +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE cprep" +== 152 +-- truncate_limit: 100 +-- test CLOSE ALL; +SELECT name FROM pg_cursors ORDER BY 1 +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name FROM pg_cursors ORDER BY 1" +== 153 +-- truncate_limit: 100 +CLOSE ALL +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE ALL" +== 154 +-- truncate_limit: 100 +SELECT name FROM pg_cursors ORDER BY 1 +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name FROM pg_cursors ORDER BY 1" +== 155 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 156 +-- truncate_limit: 100 +DECLARE foo1 CURSOR WITH HOLD FOR SELECT 1 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo1 CURSOR WITH HOLD FOR SELECT 1" +== 157 +-- truncate_limit: 100 +DECLARE foo2 CURSOR WITHOUT HOLD FOR SELECT 1 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo2 CURSOR FOR SELECT 1" +== 158 +-- truncate_limit: 100 +SELECT name FROM pg_cursors ORDER BY 1 +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name FROM pg_cursors ORDER BY 1" +== 159 +-- truncate_limit: 100 +CLOSE ALL +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE ALL" +== 160 +-- truncate_limit: 100 +SELECT name FROM pg_cursors ORDER BY 1 +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name FROM pg_cursors ORDER BY 1" +== 161 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 162 +-- truncate_limit: 100 +|-- +-- Tests for updatable cursors +|-- + +CREATE TEMP TABLE uctest(f1 int, f2 text) +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE uctest (f1 int, f2 text)" +== 163 +-- truncate_limit: 100 +INSERT INTO uctest VALUES (1, 'one'), (2, 'two'), (3, 'three') +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uctest VALUES (1, 'one'), (2, 'two'), (3, 'three')" +== 164 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 165 +-- truncate_limit: 100 +-- Check DELETE WHERE CURRENT +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 166 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest" +== 167 +-- truncate_limit: 100 +FETCH 2 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 2 c1" +== 168 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c1" +== 169 +-- truncate_limit: 100 +-- should show deletion +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 170 +-- truncate_limit: 100 +-- cursor did not move +FETCH ALL FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c1" +== 171 +-- truncate_limit: 100 +-- cursor is insensitive +MOVE BACKWARD ALL IN c1 +-- +STMT: FetchStmt +TRUNCATED: "MOVE BACKWARD ALL c1" +== 172 +-- truncate_limit: 100 +FETCH ALL FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c1" +== 173 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 174 +-- truncate_limit: 100 +-- should still see deletion +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 175 +-- truncate_limit: 100 +-- Check UPDATE WHERE CURRENT; this time use FOR UPDATE +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 176 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE" +== 177 +-- truncate_limit: 100 +FETCH c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 178 +-- truncate_limit: 100 +UPDATE uctest SET f1 = 8 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = 8 WHERE CURRENT OF c1" +== 179 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 180 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 181 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 182 +-- truncate_limit: 100 +-- Check repeated-update and update-then-delete cases +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 183 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest" +== 184 +-- truncate_limit: 100 +FETCH c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 185 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 186 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 187 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 188 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 189 +-- truncate_limit: 100 +-- insensitive cursor should not show effects of updates or deletes +FETCH RELATIVE 0 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH RELATIVE 0 c1" +== 190 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c1" +== 191 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 192 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c1" +== 193 +-- truncate_limit: 100 +-- no-op +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 194 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 195 +-- truncate_limit: 100 +-- no-op +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 196 +-- truncate_limit: 100 +FETCH RELATIVE 0 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH RELATIVE 0 c1" +== 197 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 198 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 199 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 200 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE" +== 201 +-- truncate_limit: 100 +FETCH c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 202 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 203 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 204 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 205 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 206 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c1" +== 207 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 208 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c1" +== 209 +-- truncate_limit: 100 +-- no-op +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 210 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 211 +-- truncate_limit: 100 +-- no-op +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 212 +-- truncate_limit: 100 +--- FOR UPDATE cursors can't currently scroll back, so this is an error: +FETCH RELATIVE 0 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH RELATIVE 0 c1" +== 213 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 214 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 215 +-- truncate_limit: 100 +-- Check insensitive cursor with INSERT +-- (The above tests don't test the SQL notion of an insensitive cursor +-- correctly, because per SQL standard, changes from WHERE CURRENT OF +-- commands should be visible in the cursor. So here we make the +-- changes with a command that is independent of the cursor.) +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 216 +-- truncate_limit: 100 +DECLARE c1 INSENSITIVE CURSOR FOR SELECT * FROM uctest +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 INSENSITIVE CURSOR FOR SELECT * FROM uctest" +== 217 +-- truncate_limit: 100 +INSERT INTO uctest VALUES (10, 'ten') +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uctest VALUES (10, 'ten')" +== 218 +-- truncate_limit: 100 +FETCH NEXT FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 219 +-- truncate_limit: 100 +FETCH NEXT FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 220 +-- truncate_limit: 100 +FETCH NEXT FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 221 +-- truncate_limit: 100 +-- insert not visible +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 222 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 223 +-- truncate_limit: 100 +DELETE FROM uctest WHERE f1 = 10 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE f1 = 10" +== 224 +-- truncate_limit: 100 +-- restore test table state + +-- Check inheritance cases +CREATE TEMP TABLE ucchild () inherits (uctest) +-- +TABLE: name="ucchild" schema="" table="ucchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE ucchild () INHERITS (uctest)" +== 225 +-- truncate_limit: 100 +INSERT INTO ucchild values(100, 'hundred') +-- +TABLE: name="ucchild" schema="" table="ucchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ucchild VALUES (100, 'hundred')" +== 226 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 227 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 228 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE" +== 229 +-- truncate_limit: 100 +FETCH 1 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 230 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 231 +-- truncate_limit: 100 +FETCH 1 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 232 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 233 +-- truncate_limit: 100 +FETCH 1 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 234 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 235 +-- truncate_limit: 100 +FETCH 1 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 236 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 237 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 238 +-- truncate_limit: 100 +-- Can update from a self-join, but only if FOR UPDATE says which to use +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 239 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = (b.f1 + 5)" +== 240 +-- truncate_limit: 100 +FETCH 1 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 241 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 242 +-- truncate_limit: 100 +-- fail +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 243 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 244 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR UPDATE +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = (b.f1 + 5) FOR UPDATE" +== 245 +-- truncate_limit: 100 +FETCH 1 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 246 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 247 +-- truncate_limit: 100 +-- fail +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 248 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 249 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR SHARE OF a +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = (b.f1 + 5) FOR SHARE OF a" +== 250 +-- truncate_limit: 100 +FETCH 1 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 251 +-- truncate_limit: 100 +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1" +== 252 +-- truncate_limit: 100 +SELECT * FROM uctest +-- +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uctest" +== 253 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 254 +-- truncate_limit: 100 +-- Check various error cases + +DELETE FROM uctest WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c1" +== 255 +-- truncate_limit: 100 +-- fail, no such cursor +DECLARE cx CURSOR WITH HOLD FOR SELECT * FROM uctest +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE cx CURSOR WITH HOLD FOR SELECT * FROM uctest" +== 256 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF cx +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF cx" +== 257 +-- truncate_limit: 100 +-- fail, can't use held cursor +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 258 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT * FROM tenk2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT * FROM tenk2" +== 259 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c" +== 260 +-- truncate_limit: 100 +-- fail, cursor on wrong table +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 261 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 262 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT * FROM tenk2 FOR SHARE +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT * FROM tenk2 FOR SHARE" +== 263 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c" +== 264 +-- truncate_limit: 100 +-- fail, cursor on wrong table +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 265 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 266 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT * FROM tenk1 JOIN tenk2 USING (unique1) +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT * FROM tenk1 JOIN tenk2 USING (unique1)" +== 267 +-- truncate_limit: 100 +DELETE FROM tenk1 WHERE CURRENT OF c +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tenk1 WHERE CURRENT OF c" +== 268 +-- truncate_limit: 100 +-- fail, cursor is on a join +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 269 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 270 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT f1,count(*) FROM uctest GROUP BY f1 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT f1, count(*) FROM uctest GROUP BY f1" +== 271 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c" +== 272 +-- truncate_limit: 100 +-- fail, cursor is on aggregation +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 273 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 274 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM uctest +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM uctest" +== 275 +-- truncate_limit: 100 +DELETE FROM uctest WHERE CURRENT OF c1 +-- +TABLE: name="uctest" schema="" table="uctest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uctest WHERE CURRENT OF c1" +== 276 +-- truncate_limit: 100 +-- fail, no current row +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 277 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 278 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT MIN(f1) FROM uctest FOR UPDATE +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT min(f1) FROM uctest FOR UPDATE" +== 279 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 280 +-- truncate_limit: 100 +-- WHERE CURRENT OF may someday work with views, but today is not that day. +-- For now, just make sure it errors out cleanly. +CREATE TEMP VIEW ucview AS SELECT * FROM uctest +-- +TABLE: name="ucview" schema="" table="ucview" ctx=DDL +TABLE: name="uctest" schema="" table="uctest" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW ucview AS SELECT * FROM uctest" +== 281 +-- truncate_limit: 100 +CREATE RULE ucrule AS ON DELETE TO ucview DO INSTEAD + DELETE FROM uctest WHERE f1 = OLD.f1 +-- +TABLE: name="ucview" schema="" table="ucview" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE ucrule AS ON DELETE TO ucview DO INSTEAD DELETE FROM uctest WHERE f1 = old.f1" +== 282 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 283 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT * FROM ucview +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT * FROM ucview" +== 284 +-- truncate_limit: 100 +FETCH FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 285 +-- truncate_limit: 100 +DELETE FROM ucview WHERE CURRENT OF c1 +-- +TABLE: name="ucview" schema="" table="ucview" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ucview WHERE CURRENT OF c1" +== 286 +-- truncate_limit: 100 +-- fail, views not supported +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 287 +-- truncate_limit: 100 +-- Check WHERE CURRENT OF with an index-only scan +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 288 +-- truncate_limit: 100 +EXPLAIN (costs off) +DECLARE c1 CURSOR FOR SELECT stringu1 FROM onek WHERE stringu1 = 'DZAAAA' +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DECLARE c1 CURSOR FOR SELECT stringu1 FROM onek WHERE stringu1 = 'DZAAAA'" +== 289 +-- truncate_limit: 100 +DECLARE c1 CURSOR FOR SELECT stringu1 FROM onek WHERE stringu1 = 'DZAAAA' +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 CURSOR FOR SELECT stringu1 FROM onek WHERE stringu1 = 'DZAAAA'" +== 290 +-- truncate_limit: 100 +FETCH FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH c1" +== 291 +-- truncate_limit: 100 +DELETE FROM onek WHERE CURRENT OF c1 +-- +TABLE: name="onek" schema="" table="onek" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM onek WHERE CURRENT OF c1" +== 292 +-- truncate_limit: 100 +SELECT stringu1 FROM onek WHERE stringu1 = 'DZAAAA' +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT stringu1 FROM onek WHERE stringu1 = 'DZAAAA'" +== 293 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 294 +-- truncate_limit: 100 +-- Check behavior with rewinding to a previous child scan node, +-- as per bug #15395 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 295 +-- truncate_limit: 100 +CREATE TABLE current_check (currentid int, payload text) +-- +TABLE: name="current_check" schema="" table="current_check" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE current_check (currentid int, payload text)" +== 296 +-- truncate_limit: 100 +CREATE TABLE current_check_1 () INHERITS (current_check) +-- +TABLE: name="current_check_1" schema="" table="current_check_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE current_check_1 () INHERITS (current_check)" +== 297 +-- truncate_limit: 100 +CREATE TABLE current_check_2 () INHERITS (current_check) +-- +TABLE: name="current_check_2" schema="" table="current_check_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE current_check_2 () INHERITS (current_check)" +== 298 +-- truncate_limit: 100 +INSERT INTO current_check_1 SELECT i, 'p' || i FROM generate_series(1,9) i +-- +TABLE: name="current_check_1" schema="" table="current_check_1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO current_check_1 SELECT i, 'p' || i FROM generate_series(1, 9) i" +== 299 +-- truncate_limit: 100 +INSERT INTO current_check_2 SELECT i, 'P' || i FROM generate_series(10,19) i +-- +TABLE: name="current_check_2" schema="" table="current_check_2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO current_check_2 SELECT i, 'P' || i FROM generate_series(10, 19) i" +== 300 +-- truncate_limit: 100 +DECLARE c1 SCROLL CURSOR FOR SELECT * FROM current_check +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 SCROLL CURSOR FOR SELECT * FROM current_check" +== 301 +-- truncate_limit: 100 +-- This tests the fetch-backwards code path +FETCH ABSOLUTE 12 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ABSOLUTE 12 c1" +== 302 +-- truncate_limit: 100 +FETCH ABSOLUTE 8 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ABSOLUTE 8 c1" +== 303 +-- truncate_limit: 100 +DELETE FROM current_check WHERE CURRENT OF c1 RETURNING * +-- +TABLE: name="current_check" schema="" table="current_check" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM current_check WHERE CURRENT OF c1 RETURNING *" +== 304 +-- truncate_limit: 100 +-- This tests the ExecutorRewind code path +FETCH ABSOLUTE 13 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ABSOLUTE 13 c1" +== 305 +-- truncate_limit: 100 +FETCH ABSOLUTE 1 FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH FIRST c1" +== 306 +-- truncate_limit: 100 +DELETE FROM current_check WHERE CURRENT OF c1 RETURNING * +-- +TABLE: name="current_check" schema="" table="current_check" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM current_check WHERE CURRENT OF c1 RETURNING *" +== 307 +-- truncate_limit: 100 +SELECT * FROM current_check +-- +TABLE: name="current_check" schema="" table="current_check" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM current_check" +== 308 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 309 +-- truncate_limit: 100 +-- Make sure snapshot management works okay, per bug report in +-- 235395b90909301035v7228ce63q392931f15aa74b31@mail.gmail.com +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 310 +-- truncate_limit: 100 +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE" +== 311 +-- truncate_limit: 100 +CREATE TABLE cursor (a int) +-- +TABLE: name="cursor" schema="" table="cursor" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cursor (a int)" +== 312 +-- truncate_limit: 100 +INSERT INTO cursor VALUES (1) +-- +TABLE: name="cursor" schema="" table="cursor" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cursor VALUES (1)" +== 313 +-- truncate_limit: 100 +DECLARE c1 NO SCROLL CURSOR FOR SELECT * FROM cursor FOR UPDATE +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 NO SCROLL CURSOR FOR SELECT * FROM cursor FOR UPDATE" +== 314 +-- truncate_limit: 100 +UPDATE cursor SET a = 2 +-- +TABLE: name="cursor" schema="" table="cursor" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE cursor SET a = 2" +== 315 +-- truncate_limit: 100 +FETCH ALL FROM c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c1" +== 316 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 317 +-- truncate_limit: 100 +DROP TABLE cursor +-- +TABLE: name="cursor" schema="" table="cursor" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cursor" +== 318 +-- truncate_limit: 100 +-- Check rewinding a cursor containing a stable function in LIMIT, +-- per bug report in 8336843.9833.1399385291498.JavaMail.root@quick +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 319 +-- truncate_limit: 100 +create function nochange(int) returns int + as 'select $1 limit 1' language sql stable +-- +FUNCTION: name="nochange" function="nochange" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION nochange(int) RETURNS int AS $$select $1 limit 1$$ LANGUAGE sql STABLE" +== 320 +-- truncate_limit: 100 +declare c cursor for select * from int8_tbl limit nochange(3) +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT * FROM int8_tbl LIMIT nochange(3)" +== 321 +-- truncate_limit: 100 +fetch all from c +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c" +== 322 +-- truncate_limit: 100 +move backward all in c +-- +STMT: FetchStmt +TRUNCATED: "MOVE BACKWARD ALL c" +== 323 +-- truncate_limit: 100 +fetch all from c +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c" +== 324 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 325 +-- truncate_limit: 100 +-- Check handling of non-backwards-scan-capable plans with scroll cursors +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 326 +-- truncate_limit: 100 +explain (costs off) declare c1 cursor for select (select 42) as x +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DECLARE c1 CURSOR FOR SELECT (SELECT 42) AS x" +== 327 +-- truncate_limit: 100 +explain (costs off) declare c1 scroll cursor for select (select 42) as x +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DECLARE c1 SCROLL CURSOR FOR SELECT (SELECT 42) AS x" +== 328 +-- truncate_limit: 100 +declare c1 scroll cursor for select (select 42) as x +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 SCROLL CURSOR FOR SELECT (SELECT 42) AS x" +== 329 +-- truncate_limit: 100 +fetch all in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c1" +== 330 +-- truncate_limit: 100 +fetch backward all in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c1" +== 331 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 332 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 333 +-- truncate_limit: 100 +explain (costs off) declare c2 cursor for select generate_series(1,3) as g +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DECLARE c2 CURSOR FOR SELECT generate_series(1, 3) AS g" +== 334 +-- truncate_limit: 100 +explain (costs off) declare c2 scroll cursor for select generate_series(1,3) as g +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DECLARE c2 SCROLL CURSOR FOR SELECT generate_series(1, 3) AS g" +== 335 +-- truncate_limit: 100 +declare c2 scroll cursor for select generate_series(1,3) as g +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c2 SCROLL CURSOR FOR SELECT generate_series(1, 3) AS g" +== 336 +-- truncate_limit: 100 +fetch all in c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c2" +== 337 +-- truncate_limit: 100 +fetch backward all in c2 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c2" +== 338 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 339 +-- truncate_limit: 100 +-- Check fetching of toasted datums via cursors. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 340 +-- truncate_limit: 100 +-- Other compression algorithms may cause the compressed data to be stored +-- inline. Use pglz to ensure consistent results. +set default_toast_compression = 'pglz' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_toast_compression TO pglz" +== 341 +-- truncate_limit: 100 +create table toasted_data (f1 int[]) +-- +TABLE: name="toasted_data" schema="" table="toasted_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE toasted_data (f1 int[])" +== 342 +-- truncate_limit: 100 +insert into toasted_data + select array_agg(i) from generate_series(12345678, 12345678 + 1000) i +-- +TABLE: name="toasted_data" schema="" table="toasted_data" ctx=DML +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO toasted_data SELECT array_agg(i) FROM generate_series(12345678, 12345678 + 1000) i" +== 343 +-- truncate_limit: 100 +declare local_portal cursor for select * from toasted_data +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE local_portal CURSOR FOR SELECT * FROM toasted_data" +== 344 +-- truncate_limit: 100 +fetch all in local_portal +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL local_portal" +== 345 +-- truncate_limit: 100 +declare held_portal cursor with hold for select * from toasted_data +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE held_portal CURSOR WITH HOLD FOR SELECT * FROM toasted_data" +== 346 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 347 +-- truncate_limit: 100 +drop table toasted_data +-- +TABLE: name="toasted_data" schema="" table="toasted_data" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE toasted_data" +== 348 +-- truncate_limit: 100 +fetch all in held_portal +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL held_portal" +== 349 +-- truncate_limit: 100 +reset default_toast_compression +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_toast_compression" diff --git a/parser/testdata/summary_truncate/postgres_regress/portals_p2.metadata.json b/parser/testdata/summary_truncate/postgres_regress/portals_p2.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/portals_p2.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/portals_p2.test b/parser/testdata/summary_truncate/postgres_regress/portals_p2.test new file mode 100644 index 0000000..d417434 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/portals_p2.test @@ -0,0 +1,263 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PORTALS_P2 +|-- + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 002 +-- truncate_limit: 100 +DECLARE foo13 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 50 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo13 CURSOR FOR SELECT * FROM onek WHERE unique1 = 50" +== 003 +-- truncate_limit: 100 +DECLARE foo14 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 51 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo14 CURSOR FOR SELECT * FROM onek WHERE unique1 = 51" +== 004 +-- truncate_limit: 100 +DECLARE foo15 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 52 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo15 CURSOR FOR SELECT * FROM onek WHERE unique1 = 52" +== 005 +-- truncate_limit: 100 +DECLARE foo16 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 53 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo16 CURSOR FOR SELECT * FROM onek WHERE unique1 = 53" +== 006 +-- truncate_limit: 100 +DECLARE foo17 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 54 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo17 CURSOR FOR SELECT * FROM onek WHERE unique1 = 54" +== 007 +-- truncate_limit: 100 +DECLARE foo18 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 55 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo18 CURSOR FOR SELECT * FROM onek WHERE unique1 = 55" +== 008 +-- truncate_limit: 100 +DECLARE foo19 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 56 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo19 CURSOR FOR SELECT * FROM onek WHERE unique1 = 56" +== 009 +-- truncate_limit: 100 +DECLARE foo20 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 57 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo20 CURSOR FOR SELECT * FROM onek WHERE unique1 = 57" +== 010 +-- truncate_limit: 100 +DECLARE foo21 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 58 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo21 CURSOR FOR SELECT * FROM onek WHERE unique1 = 58" +== 011 +-- truncate_limit: 100 +DECLARE foo22 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 59 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo22 CURSOR FOR SELECT * FROM onek WHERE unique1 = 59" +== 012 +-- truncate_limit: 100 +DECLARE foo23 CURSOR FOR + SELECT * FROM onek WHERE unique1 = 60 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo23 CURSOR FOR SELECT * FROM onek WHERE unique1 = 60" +== 013 +-- truncate_limit: 100 +DECLARE foo24 CURSOR FOR + SELECT * FROM onek2 WHERE unique1 = 50 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo24 CURSOR FOR SELECT * FROM onek2 WHERE unique1 = 50" +== 014 +-- truncate_limit: 100 +DECLARE foo25 CURSOR FOR + SELECT * FROM onek2 WHERE unique1 = 60 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo25 CURSOR FOR SELECT * FROM onek2 WHERE unique1 = 60" +== 015 +-- truncate_limit: 100 +FETCH all in foo13 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo13" +== 016 +-- truncate_limit: 100 +FETCH all in foo14 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo14" +== 017 +-- truncate_limit: 100 +FETCH all in foo15 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo15" +== 018 +-- truncate_limit: 100 +FETCH all in foo16 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo16" +== 019 +-- truncate_limit: 100 +FETCH all in foo17 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo17" +== 020 +-- truncate_limit: 100 +FETCH all in foo18 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo18" +== 021 +-- truncate_limit: 100 +FETCH all in foo19 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo19" +== 022 +-- truncate_limit: 100 +FETCH all in foo20 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo20" +== 023 +-- truncate_limit: 100 +FETCH all in foo21 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo21" +== 024 +-- truncate_limit: 100 +FETCH all in foo22 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo22" +== 025 +-- truncate_limit: 100 +FETCH all in foo23 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo23" +== 026 +-- truncate_limit: 100 +FETCH all in foo24 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo24" +== 027 +-- truncate_limit: 100 +FETCH all in foo25 +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL foo25" +== 028 +-- truncate_limit: 100 +CLOSE foo13 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo13" +== 029 +-- truncate_limit: 100 +CLOSE foo14 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo14" +== 030 +-- truncate_limit: 100 +CLOSE foo15 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo15" +== 031 +-- truncate_limit: 100 +CLOSE foo16 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo16" +== 032 +-- truncate_limit: 100 +CLOSE foo17 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo17" +== 033 +-- truncate_limit: 100 +CLOSE foo18 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo18" +== 034 +-- truncate_limit: 100 +CLOSE foo19 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo19" +== 035 +-- truncate_limit: 100 +CLOSE foo20 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo20" +== 036 +-- truncate_limit: 100 +CLOSE foo21 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo21" +== 037 +-- truncate_limit: 100 +CLOSE foo22 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo22" +== 038 +-- truncate_limit: 100 +CLOSE foo23 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo23" +== 039 +-- truncate_limit: 100 +CLOSE foo24 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo24" +== 040 +-- truncate_limit: 100 +CLOSE foo25 +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE foo25" +== 041 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" diff --git a/parser/testdata/summary_truncate/postgres_regress/predicate.metadata.json b/parser/testdata/summary_truncate/postgres_regress/predicate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/predicate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/predicate.test b/parser/testdata/summary_truncate/postgres_regress/predicate.test new file mode 100644 index 0000000..578683c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/predicate.test @@ -0,0 +1,515 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for predicate handling +|-- + +|-- +-- Test that restrictions that are always true are ignored, and that are always +-- false are replaced with constant-FALSE +|-- +-- Currently we only check for NullTest quals and OR clauses that include +-- NullTest quals. We may extend it in the future. +|-- +CREATE TABLE pred_tab (a int NOT NULL, b int, c int NOT NULL) +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pred_tab (a int NOT NULL, b int, c int NOT NULL)" +== 002 +-- truncate_limit: 100 +|-- +-- Test restriction clauses +|-- + +-- Ensure the IS_NOT_NULL qual is ignored when the column is non-nullable +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t WHERE t.a IS NOT NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t"="pred_tab" +FILTER: schema="" table="t" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.a IS NOT NULL" +== 003 +-- truncate_limit: 100 +-- Ensure the IS_NOT_NULL qual is not ignored on a nullable column +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t WHERE t.b IS NOT NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t"="pred_tab" +FILTER: schema="" table="t" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.b IS NOT NULL" +== 004 +-- truncate_limit: 100 +-- Ensure the IS_NULL qual is reduced to constant-FALSE for non-nullable +-- columns +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t WHERE t.a IS NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t"="pred_tab" +FILTER: schema="" table="t" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.a IS NULL" +== 005 +-- truncate_limit: 100 +-- Ensure the IS_NULL qual is not reduced to constant-FALSE on nullable +-- columns +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t WHERE t.b IS NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t"="pred_tab" +FILTER: schema="" table="t" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.b IS NULL" +== 006 +-- truncate_limit: 100 +|-- +-- Tests for OR clauses in restriction clauses +|-- + +-- Ensure the OR clause is ignored when an OR branch is always true +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t WHERE t.a IS NOT NULL OR t.b = 1 +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t"="pred_tab" +FILTER: schema="" table="t" column="a" +FILTER: schema="" table="t" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.a IS NOT NULL OR t.b = 1" +== 007 +-- truncate_limit: 100 +-- Ensure the OR clause is not ignored for NullTests that can't be proven +-- always true +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t WHERE t.b IS NOT NULL OR t.a = 1 +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t"="pred_tab" +FILTER: schema="" table="t" column="b" +FILTER: schema="" table="t" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.b IS NOT NULL OR t.a = 1" +== 008 +-- truncate_limit: 100 +-- Ensure the OR clause is reduced to constant-FALSE when all branches are +-- provably false +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t WHERE t.a IS NULL OR t.c IS NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t"="pred_tab" +FILTER: schema="" table="t" column="a" +FILTER: schema="" table="t" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.a IS NULL OR t.c IS NULL" +== 009 +-- truncate_limit: 100 +-- Ensure the OR clause is not reduced to constant-FALSE when not all branches +-- are provably false +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t WHERE t.b IS NULL OR t.c IS NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t"="pred_tab" +FILTER: schema="" table="t" column="b" +FILTER: schema="" table="t" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.b IS NULL OR t.c IS NULL" +== 010 +-- truncate_limit: 100 +|-- +-- Test join clauses +|-- + +-- Ensure the IS_NOT_NULL qual is ignored, since a) it's on a NOT NULL column, +-- and b) its Var is not nullable by any outer joins +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON t1.a IS NOT NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON t1.a IS NOT NULL" +== 011 +-- truncate_limit: 100 +-- Ensure the IS_NOT_NULL qual is not ignored when columns are made nullable +-- by an outer join +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + FULL JOIN pred_tab t2 ON t1.a = t2.a + LEFT JOIN pred_tab t3 ON t2.a IS NOT NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +ALIAS: "t3"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 FULL JOIN pred_tab t2 ON t1.a = t2.a LEFT JOIN pred..." +== 012 +-- truncate_limit: 100 +-- Ensure the IS_NULL qual is reduced to constant-FALSE, since a) it's on a NOT +-- NULL column, and b) its Var is not nullable by any outer joins +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON t1.a IS NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON t1.a IS NULL" +== 013 +-- truncate_limit: 100 +-- Ensure the IS_NULL qual is not reduced to constant-FALSE when the column is +-- nullable by an outer join +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON t1.a = 1 + LEFT JOIN pred_tab t3 ON t2.a IS NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +ALIAS: "t3"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON t1.a = 1 LEFT JOIN pred_ta..." +== 014 +-- truncate_limit: 100 +|-- +-- Tests for OR clauses in join clauses +|-- + +-- Ensure the OR clause is ignored when an OR branch is provably always true +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON t1.a IS NOT NULL OR t2.b = 1 +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON t1.a IS NOT NULL OR t2.b = 1" +== 015 +-- truncate_limit: 100 +-- Ensure the NullTest is not ignored when the column is nullable by an outer +-- join +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + FULL JOIN pred_tab t2 ON t1.a = t2.a + LEFT JOIN pred_tab t3 ON t2.a IS NOT NULL OR t2.b = 1 +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +ALIAS: "t3"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 FULL JOIN pred_tab t2 ON t1.a = t2.a LEFT JOIN pred..." +== 016 +-- truncate_limit: 100 +-- Ensure the OR clause is reduced to constant-FALSE when all OR branches are +-- provably false +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON (t1.a IS NULL OR t1.c IS NULL) +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON t1.a IS NULL OR t1.c IS NULL" +== 017 +-- truncate_limit: 100 +-- Ensure the OR clause is not reduced to constant-FALSE when a column is +-- made nullable from an outer join +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON t1.a = 1 + LEFT JOIN pred_tab t3 ON t2.a IS NULL OR t2.c IS NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +ALIAS: "t3"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON t1.a = 1 LEFT JOIN pred_ta..." +== 018 +-- truncate_limit: 100 +DROP TABLE pred_tab +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pred_tab" +== 019 +-- truncate_limit: 100 +-- Validate we handle IS NULL and IS NOT NULL quals correctly with inheritance +-- parents. +CREATE TABLE pred_parent (a int) +-- +TABLE: name="pred_parent" schema="" table="pred_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pred_parent (a int)" +== 020 +-- truncate_limit: 100 +CREATE TABLE pred_child () INHERITS (pred_parent) +-- +TABLE: name="pred_child" schema="" table="pred_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pred_child () INHERITS (pred_parent)" +== 021 +-- truncate_limit: 100 +ALTER TABLE ONLY pred_parent ALTER a SET NOT NULL +-- +TABLE: name="pred_parent" schema="" table="pred_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY pred_parent ALTER COLUMN a SET NOT NULL" +== 022 +-- truncate_limit: 100 +-- Ensure that the scan on pred_child contains the IS NOT NULL qual. +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NOT NULL +-- +TABLE: name="pred_parent" schema="" table="pred_parent" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_parent WHERE a IS NOT NULL" +== 023 +-- truncate_limit: 100 +-- Ensure we only scan pred_child and not pred_parent +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NULL +-- +TABLE: name="pred_parent" schema="" table="pred_parent" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_parent WHERE a IS NULL" +== 024 +-- truncate_limit: 100 +ALTER TABLE pred_parent ALTER a DROP NOT NULL +-- +TABLE: name="pred_parent" schema="" table="pred_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pred_parent ALTER COLUMN a DROP NOT NULL" +== 025 +-- truncate_limit: 100 +ALTER TABLE pred_child ALTER a SET NOT NULL +-- +TABLE: name="pred_child" schema="" table="pred_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pred_child ALTER COLUMN a SET NOT NULL" +== 026 +-- truncate_limit: 100 +-- Ensure the IS NOT NULL qual is removed from the pred_child scan. +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NOT NULL +-- +TABLE: name="pred_parent" schema="" table="pred_parent" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_parent WHERE a IS NOT NULL" +== 027 +-- truncate_limit: 100 +-- Ensure we only scan pred_parent and not pred_child +EXPLAIN (COSTS OFF) +SELECT * FROM pred_parent WHERE a IS NULL +-- +TABLE: name="pred_parent" schema="" table="pred_parent" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_parent WHERE a IS NULL" +== 028 +-- truncate_limit: 100 +DROP TABLE pred_parent, pred_child +-- +TABLE: name="pred_parent" schema="" table="pred_parent" ctx=DDL +TABLE: name="pred_child" schema="" table="pred_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pred_parent, pred_child" +== 029 +-- truncate_limit: 100 +-- Validate we do not reduce a clone clause to a constant true or false +CREATE TABLE pred_tab (a int, b int) +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pred_tab (a int, b int)" +== 030 +-- truncate_limit: 100 +CREATE TABLE pred_tab_notnull (a int, b int NOT NULL) +-- +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pred_tab_notnull (a int, b int NOT NULL)" +== 031 +-- truncate_limit: 100 +INSERT INTO pred_tab VALUES (1, 1) +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pred_tab VALUES (1, 1)" +== 032 +-- truncate_limit: 100 +INSERT INTO pred_tab VALUES (2, 2) +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pred_tab VALUES (2, 2)" +== 033 +-- truncate_limit: 100 +INSERT INTO pred_tab_notnull VALUES (2, 2) +-- +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pred_tab_notnull VALUES (2, 2)" +== 034 +-- truncate_limit: 100 +INSERT INTO pred_tab_notnull VALUES (3, 3) +-- +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pred_tab_notnull VALUES (3, 3)" +== 035 +-- truncate_limit: 100 +ANALYZE pred_tab +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pred_tab" +== 036 +-- truncate_limit: 100 +ANALYZE pred_tab_notnull +-- +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pred_tab_notnull" +== 037 +-- truncate_limit: 100 +-- Ensure the IS_NOT_NULL qual is not reduced to constant true and removed +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON TRUE + LEFT JOIN pred_tab_notnull t3 ON t2.a = t3.a + LEFT JOIN pred_tab t4 ON t3.b IS NOT NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +ALIAS: "t3"="pred_tab_notnull" +ALIAS: "t4"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON true LEFT JOIN pred_tab_no..." +== 038 +-- truncate_limit: 100 +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON TRUE + LEFT JOIN pred_tab_notnull t3 ON t2.a = t3.a + LEFT JOIN pred_tab t4 ON t3.b IS NOT NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +ALIAS: "t3"="pred_tab_notnull" +ALIAS: "t4"="pred_tab" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON true LEFT JOIN pred_tab_notnull t3 ON t2.a = t..." +== 039 +-- truncate_limit: 100 +-- Ensure the IS_NULL qual is not reduced to constant false +EXPLAIN (COSTS OFF) +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON TRUE + LEFT JOIN pred_tab_notnull t3 ON t2.a = t3.a + LEFT JOIN pred_tab t4 ON t3.b IS NULL AND t3.a IS NOT NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +ALIAS: "t3"="pred_tab_notnull" +ALIAS: "t4"="pred_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON true LEFT JOIN pred_tab_no..." +== 040 +-- truncate_limit: 100 +SELECT * FROM pred_tab t1 + LEFT JOIN pred_tab t2 ON TRUE + LEFT JOIN pred_tab_notnull t3 ON t2.a = t3.a + LEFT JOIN pred_tab t4 ON t3.b IS NULL AND t3.a IS NOT NULL +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=Select +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=Select +ALIAS: "t1"="pred_tab" +ALIAS: "t2"="pred_tab" +ALIAS: "t3"="pred_tab_notnull" +ALIAS: "t4"="pred_tab" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pred_tab t1 LEFT JOIN pred_tab t2 ON true LEFT JOIN pred_tab_notnull t3 ON t2.a = t..." +== 041 +-- truncate_limit: 100 +DROP TABLE pred_tab +-- +TABLE: name="pred_tab" schema="" table="pred_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pred_tab" +== 042 +-- truncate_limit: 100 +DROP TABLE pred_tab_notnull +-- +TABLE: name="pred_tab_notnull" schema="" table="pred_tab_notnull" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pred_tab_notnull" diff --git a/parser/testdata/summary_truncate/postgres_regress/prepare.metadata.json b/parser/testdata/summary_truncate/postgres_regress/prepare.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/prepare.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/prepare.test b/parser/testdata/summary_truncate/postgres_regress/prepare.test new file mode 100644 index 0000000..63ca131 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/prepare.test @@ -0,0 +1,268 @@ +== 001 +-- truncate_limit: 100 +-- Regression tests for prepareable statements. We query the content +-- of the pg_prepared_statements view as prepared statements are +-- created and removed. + +SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements" +== 002 +-- truncate_limit: 100 +PREPARE q1 AS SELECT 1 AS a +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q1 AS SELECT 1 AS a" +== 003 +-- truncate_limit: 100 +EXECUTE q1 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q1" +== 004 +-- truncate_limit: 100 +SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements" +== 005 +-- truncate_limit: 100 +-- should fail +PREPARE q1 AS SELECT 2 +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q1 AS SELECT 2" +== 006 +-- truncate_limit: 100 +-- should succeed +DEALLOCATE q1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q1" +== 007 +-- truncate_limit: 100 +PREPARE q1 AS SELECT 2 +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q1 AS SELECT 2" +== 008 +-- truncate_limit: 100 +EXECUTE q1 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q1" +== 009 +-- truncate_limit: 100 +PREPARE q2 AS SELECT 2 AS b +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q2 AS SELECT 2 AS b" +== 010 +-- truncate_limit: 100 +SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements" +== 011 +-- truncate_limit: 100 +-- sql92 syntax +DEALLOCATE PREPARE q1 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q1" +== 012 +-- truncate_limit: 100 +SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements" +== 013 +-- truncate_limit: 100 +DEALLOCATE PREPARE q2 +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q2" +== 014 +-- truncate_limit: 100 +-- the view should return the empty set again +SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements" +== 015 +-- truncate_limit: 100 +-- parameterized queries +PREPARE q2(text) AS + SELECT datname, datistemplate, datallowconn + FROM pg_database WHERE datname = $1 +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FILTER: schema="" table="" column="datname" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q2(text) AS SELECT datname, datistemplate, datallowconn FROM pg_database WHERE datname = $1" +== 016 +-- truncate_limit: 100 +EXECUTE q2('postgres') +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q2('postgres')" +== 017 +-- truncate_limit: 100 +PREPARE q3(text, int, float, boolean, smallint) AS + SELECT * FROM tenk1 WHERE string4 = $1 AND (four = $2 OR + ten = $3::bigint OR true = $4 OR odd = $5::int) + ORDER BY unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="string4" +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="ten" +FILTER: schema="" table="" column="odd" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q3(text, int, double precision, boolean, smallint) AS SELECT * FROM tenk1 WHERE string4 =..." +== 018 +-- truncate_limit: 100 +EXECUTE q3('AAAAxx', 5::smallint, 10.5::float, false, 4::bigint) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q3('AAAAxx', 5::smallint, (10.5)::double precision, false, 4::bigint)" +== 019 +-- truncate_limit: 100 +-- too few params +EXECUTE q3('bool') +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q3('bool')" +== 020 +-- truncate_limit: 100 +-- too many params +EXECUTE q3('bytea', 5::smallint, 10.5::float, false, 4::bigint, true) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q3('bytea', 5::smallint, (10.5)::double precision, false, 4::bigint, true)" +== 021 +-- truncate_limit: 100 +-- wrong param types +EXECUTE q3(5::smallint, 10.5::float, false, 4::bigint, 'bytea') +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q3(5::smallint, (10.5)::double precision, false, 4::bigint, 'bytea')" +== 022 +-- truncate_limit: 100 +-- invalid type +PREPARE q4(nonexistenttype) AS SELECT $1 +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q4(nonexistenttype) AS SELECT $1" +== 023 +-- truncate_limit: 100 +-- create table as execute +PREPARE q5(int, text) AS + SELECT * FROM tenk1 WHERE unique1 = $1 OR stringu1 = $2 + ORDER BY unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="stringu1" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q5(int, text) AS SELECT * FROM tenk1 WHERE unique1 = $1 OR stringu1 = $2 ORDER BY unique1" +== 024 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE q5_prep_results AS EXECUTE q5(200, 'DTAAAA') +-- +TABLE: name="q5_prep_results" schema="" table="q5_prep_results" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TEMPORARY TABLE q5_prep_results AS EXECUTE q5(200, 'DTAAAA')" +== 025 +-- truncate_limit: 100 +SELECT * FROM q5_prep_results +-- +TABLE: name="q5_prep_results" schema="" table="q5_prep_results" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM q5_prep_results" +== 026 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE q5_prep_nodata AS EXECUTE q5(200, 'DTAAAA') + WITH NO DATA +-- +TABLE: name="q5_prep_nodata" schema="" table="q5_prep_nodata" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TEMPORARY TABLE q5_prep_nodata AS EXECUTE q5(200, 'DTAAAA') WITH NO DATA" +== 027 +-- truncate_limit: 100 +SELECT * FROM q5_prep_nodata +-- +TABLE: name="q5_prep_nodata" schema="" table="q5_prep_nodata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM q5_prep_nodata" +== 028 +-- truncate_limit: 100 +-- unknown or unspecified parameter types: should succeed +PREPARE q6 AS + SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="stringu1" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q6 AS SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2" +== 029 +-- truncate_limit: 100 +PREPARE q7(unknown) AS + SELECT * FROM road WHERE thepath = $1 +-- +TABLE: name="road" schema="" table="road" ctx=Select +FILTER: schema="" table="" column="thepath" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q7(unknown) AS SELECT * FROM road WHERE thepath = $1" +== 030 +-- truncate_limit: 100 +-- DML statements +PREPARE q8 AS + UPDATE tenk1 SET stringu1 = $2 WHERE unique1 = $1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DML +STMT: PrepareStmt +STMT: UpdateStmt +TRUNCATED: "PREPARE q8 AS UPDATE tenk1 SET stringu1 = $2 WHERE unique1 = $1" +== 031 +-- truncate_limit: 100 +SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements + ORDER BY name +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, parameter_types, result_types FROM pg_prepared_statements ORDER BY name" +== 032 +-- truncate_limit: 100 +-- test DEALLOCATE ALL; +DEALLOCATE ALL +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ALL" +== 033 +-- truncate_limit: 100 +SELECT name, statement, parameter_types FROM pg_prepared_statements + ORDER BY name +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, statement, parameter_types FROM pg_prepared_statements ORDER BY name" diff --git a/parser/testdata/summary_truncate/postgres_regress/prepared_xacts.metadata.json b/parser/testdata/summary_truncate/postgres_regress/prepared_xacts.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/prepared_xacts.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/prepared_xacts.test b/parser/testdata/summary_truncate/postgres_regress/prepared_xacts.test new file mode 100644 index 0000000..a65c4d1 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/prepared_xacts.test @@ -0,0 +1,605 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PREPARED TRANSACTIONS (two-phase commit) +|-- +-- We can't readily test persistence of prepared xacts within the +-- regression script framework, unfortunately. Note that a crash +-- isn't really needed ... stopping and starting the postmaster would +-- be enough, but we can't even do that here. + + +-- create a simple table that we'll use in the tests +CREATE TABLE pxtest1 (foobar VARCHAR(10)) +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pxtest1 (foobar varchar(10))" +== 002 +-- truncate_limit: 100 +INSERT INTO pxtest1 VALUES ('aaa') +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest1 VALUES ('aaa')" +== 003 +-- truncate_limit: 100 +-- Test PREPARE TRANSACTION +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 004 +-- truncate_limit: 100 +UPDATE pxtest1 SET foobar = 'bbb' WHERE foobar = 'aaa' +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pxtest1 SET foobar = 'bbb' WHERE foobar = 'aaa'" +== 005 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 006 +-- truncate_limit: 100 +PREPARE TRANSACTION 'regress_foo1' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_foo1'" +== 007 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 008 +-- truncate_limit: 100 +-- Test pg_prepared_xacts system view +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 009 +-- truncate_limit: 100 +-- Test ROLLBACK PREPARED +ROLLBACK PREPARED 'regress_foo1' +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK PREPARED 'regress_foo1'" +== 010 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 011 +-- truncate_limit: 100 +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 012 +-- truncate_limit: 100 +-- Test COMMIT PREPARED +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 013 +-- truncate_limit: 100 +INSERT INTO pxtest1 VALUES ('ddd') +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest1 VALUES ('ddd')" +== 014 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 015 +-- truncate_limit: 100 +PREPARE TRANSACTION 'regress_foo2' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_foo2'" +== 016 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 017 +-- truncate_limit: 100 +COMMIT PREPARED 'regress_foo2' +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT PREPARED 'regress_foo2'" +== 018 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 019 +-- truncate_limit: 100 +-- Test duplicate gids +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 020 +-- truncate_limit: 100 +UPDATE pxtest1 SET foobar = 'eee' WHERE foobar = 'ddd' +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pxtest1 SET foobar = 'eee' WHERE foobar = 'ddd'" +== 021 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 022 +-- truncate_limit: 100 +PREPARE TRANSACTION 'regress_foo3' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_foo3'" +== 023 +-- truncate_limit: 100 +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 024 +-- truncate_limit: 100 +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 025 +-- truncate_limit: 100 +INSERT INTO pxtest1 VALUES ('fff') +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest1 VALUES ('fff')" +== 026 +-- truncate_limit: 100 +-- This should fail, because the gid foo3 is already in use +PREPARE TRANSACTION 'regress_foo3' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_foo3'" +== 027 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 028 +-- truncate_limit: 100 +ROLLBACK PREPARED 'regress_foo3' +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK PREPARED 'regress_foo3'" +== 029 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 030 +-- truncate_limit: 100 +-- Test serialization failure (SSI) +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 031 +-- truncate_limit: 100 +UPDATE pxtest1 SET foobar = 'eee' WHERE foobar = 'ddd' +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pxtest1 SET foobar = 'eee' WHERE foobar = 'ddd'" +== 032 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 033 +-- truncate_limit: 100 +PREPARE TRANSACTION 'regress_foo4' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_foo4'" +== 034 +-- truncate_limit: 100 +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 035 +-- truncate_limit: 100 +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 036 +-- truncate_limit: 100 +SELECT * FROM pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest1" +== 037 +-- truncate_limit: 100 +-- This should fail, because the two transactions have a write-skew anomaly +INSERT INTO pxtest1 VALUES ('fff') +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest1 VALUES ('fff')" +== 038 +-- truncate_limit: 100 +PREPARE TRANSACTION 'regress_foo5' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_foo5'" +== 039 +-- truncate_limit: 100 +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 040 +-- truncate_limit: 100 +ROLLBACK PREPARED 'regress_foo4' +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK PREPARED 'regress_foo4'" +== 041 +-- truncate_limit: 100 +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 042 +-- truncate_limit: 100 +-- Clean up +DROP TABLE pxtest1 +-- +TABLE: name="pxtest1" schema="" table="pxtest1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pxtest1" +== 043 +-- truncate_limit: 100 +-- Test detection of session-level and xact-level locks on same object +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 044 +-- truncate_limit: 100 +SELECT pg_advisory_lock(1) +-- +FUNCTION: name="pg_advisory_lock" function="pg_advisory_lock" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_advisory_lock(1)" +== 045 +-- truncate_limit: 100 +SELECT pg_advisory_xact_lock_shared(1) +-- +FUNCTION: name="pg_advisory_xact_lock_shared" function="pg_advisory_xact_lock_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_advisory_xact_lock_shared(1)" +== 046 +-- truncate_limit: 100 +PREPARE TRANSACTION 'regress_foo6' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_foo6'" +== 047 +-- truncate_limit: 100 +-- fails + +-- Test subtransactions +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 048 +-- truncate_limit: 100 +CREATE TABLE pxtest2 (a int) +-- +TABLE: name="pxtest2" schema="" table="pxtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pxtest2 (a int)" +== 049 +-- truncate_limit: 100 +INSERT INTO pxtest2 VALUES (1) +-- +TABLE: name="pxtest2" schema="" table="pxtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest2 VALUES (1)" +== 050 +-- truncate_limit: 100 +SAVEPOINT a +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT a" +== 051 +-- truncate_limit: 100 +INSERT INTO pxtest2 VALUES (2) +-- +TABLE: name="pxtest2" schema="" table="pxtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest2 VALUES (2)" +== 052 +-- truncate_limit: 100 +ROLLBACK TO a +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT a" +== 053 +-- truncate_limit: 100 +SAVEPOINT b +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT b" +== 054 +-- truncate_limit: 100 +INSERT INTO pxtest2 VALUES (3) +-- +TABLE: name="pxtest2" schema="" table="pxtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest2 VALUES (3)" +== 055 +-- truncate_limit: 100 +PREPARE TRANSACTION 'regress_sub1' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_sub1'" +== 056 +-- truncate_limit: 100 +CREATE TABLE pxtest3(fff int) +-- +TABLE: name="pxtest3" schema="" table="pxtest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pxtest3 (fff int)" +== 057 +-- truncate_limit: 100 +-- Test shared invalidation +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 058 +-- truncate_limit: 100 +DROP TABLE pxtest3 +-- +TABLE: name="pxtest3" schema="" table="pxtest3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pxtest3" +== 059 +-- truncate_limit: 100 +CREATE TABLE pxtest4 (a int) +-- +TABLE: name="pxtest4" schema="" table="pxtest4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pxtest4 (a int)" +== 060 +-- truncate_limit: 100 +INSERT INTO pxtest4 VALUES (1) +-- +TABLE: name="pxtest4" schema="" table="pxtest4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest4 VALUES (1)" +== 061 +-- truncate_limit: 100 +INSERT INTO pxtest4 VALUES (2) +-- +TABLE: name="pxtest4" schema="" table="pxtest4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pxtest4 VALUES (2)" +== 062 +-- truncate_limit: 100 +DECLARE foo CURSOR FOR SELECT * FROM pxtest4 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo CURSOR FOR SELECT * FROM pxtest4" +== 063 +-- truncate_limit: 100 +-- Fetch 1 tuple, keeping the cursor open + FETCH 1 FROM foo +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo" +== 064 +-- truncate_limit: 100 +PREPARE TRANSACTION 'regress_sub2' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'regress_sub2'" +== 065 +-- truncate_limit: 100 +-- No such cursor +FETCH 1 FROM foo +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo" +== 066 +-- truncate_limit: 100 +-- Table doesn't exist, the creation hasn't been committed yet +SELECT * FROM pxtest2 +-- +TABLE: name="pxtest2" schema="" table="pxtest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest2" +== 067 +-- truncate_limit: 100 +-- There should be two prepared transactions +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 068 +-- truncate_limit: 100 +-- pxtest3 should be locked because of the pending DROP +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 069 +-- truncate_limit: 100 +lock table pxtest3 in access share mode nowait +-- +TABLE: name="pxtest3" schema="" table="pxtest3" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE pxtest3 IN ACCESS SHARE MODE NOWAIT" +== 070 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 071 +-- truncate_limit: 100 +-- Disconnect, we will continue testing in a different backend + +-- There should still be two prepared transactions +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 072 +-- truncate_limit: 100 +-- pxtest3 should still be locked because of the pending DROP +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 073 +-- truncate_limit: 100 +lock table pxtest3 in access share mode nowait +-- +TABLE: name="pxtest3" schema="" table="pxtest3" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE pxtest3 IN ACCESS SHARE MODE NOWAIT" +== 074 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 075 +-- truncate_limit: 100 +-- Commit table creation +COMMIT PREPARED 'regress_sub1' +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT PREPARED 'regress_sub1'" +== 076 +-- truncate_limit: 100 +SELECT * FROM pxtest2 +-- +TABLE: name="pxtest2" schema="" table="pxtest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest2" +== 077 +-- truncate_limit: 100 +-- There should be one prepared transaction +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 078 +-- truncate_limit: 100 +-- Commit table drop +COMMIT PREPARED 'regress_sub2' +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT PREPARED 'regress_sub2'" +== 079 +-- truncate_limit: 100 +SELECT * FROM pxtest3 +-- +TABLE: name="pxtest3" schema="" table="pxtest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pxtest3" +== 080 +-- truncate_limit: 100 +-- There should be no prepared transactions +SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FILTER: schema="" table="" column="gid" +STMT: SelectStmt +TRUNCATED: "SELECT gid FROM pg_prepared_xacts WHERE gid ~ '^regress_' ORDER BY gid" +== 081 +-- truncate_limit: 100 +-- Clean up +DROP TABLE pxtest2 +-- +TABLE: name="pxtest2" schema="" table="pxtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pxtest2" +== 082 +-- truncate_limit: 100 +DROP TABLE pxtest3 +-- +TABLE: name="pxtest3" schema="" table="pxtest3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pxtest3" +== 083 +-- truncate_limit: 100 +-- will still be there if prepared xacts are disabled +DROP TABLE pxtest4 +-- +TABLE: name="pxtest4" schema="" table="pxtest4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pxtest4" diff --git a/parser/testdata/summary_truncate/postgres_regress/privileges.metadata.json b/parser/testdata/summary_truncate/postgres_regress/privileges.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/privileges.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/privileges.test b/parser/testdata/summary_truncate/postgres_regress/privileges.test new file mode 100644 index 0000000..1dba999 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/privileges.test @@ -0,0 +1,2542 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test access privileges +|-- + +-- Clean up in case a prior regression run failed + +-- Suppress NOTICE messages when users/groups don't exist +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 002 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_group1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_group1" +== 003 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_group2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_group2" +== 004 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_user1" +== 005 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_user2" +== 006 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_user3" +== 007 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_user4 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_user4" +== 008 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_user5 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_user5" +== 009 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_user6 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_user6" +== 010 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_priv_user7 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_priv_user7" +== 011 +-- truncate_limit: 100 +SELECT lo_unlink(oid) FROM pg_largeobject_metadata WHERE oid >= 1000 AND oid < 3000 ORDER BY oid +-- +TABLE: name="pg_largeobject_metadata" schema="" table="pg_largeobject_metadata" ctx=Select +FUNCTION: name="lo_unlink" function="lo_unlink" schema="" ctx=Call +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT lo_unlink(oid) FROM pg_largeobject_metadata WHERE oid >= 1000 AND oid < 3000 ORDER BY oid" +== 012 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 013 +-- truncate_limit: 100 +-- test proper begins here + +CREATE USER regress_priv_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user1" +== 014 +-- truncate_limit: 100 +CREATE USER regress_priv_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user2" +== 015 +-- truncate_limit: 100 +CREATE USER regress_priv_user3 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user3" +== 016 +-- truncate_limit: 100 +CREATE USER regress_priv_user4 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user4" +== 017 +-- truncate_limit: 100 +CREATE USER regress_priv_user5 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user5" +== 018 +-- truncate_limit: 100 +CREATE USER regress_priv_user5 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user5" +== 019 +-- truncate_limit: 100 +-- duplicate +CREATE USER regress_priv_user6 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user6" +== 020 +-- truncate_limit: 100 +CREATE USER regress_priv_user7 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user7" +== 021 +-- truncate_limit: 100 +CREATE USER regress_priv_user8 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user8" +== 022 +-- truncate_limit: 100 +CREATE USER regress_priv_user9 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user9" +== 023 +-- truncate_limit: 100 +CREATE USER regress_priv_user10 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user10" +== 024 +-- truncate_limit: 100 +CREATE ROLE regress_priv_role +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_priv_role" +== 025 +-- truncate_limit: 100 +-- circular ADMIN OPTION grants should be disallowed +GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION" +== 026 +-- truncate_limit: 100 +GRANT regress_priv_user1 TO regress_priv_user3 WITH ADMIN OPTION GRANTED BY regress_priv_user2 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user3 WITH ADMIN OPTION GRANTED BY regress_priv_user2" +== 027 +-- truncate_limit: 100 +GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION GRANTED BY regress_priv_user3 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION GRANTED BY regress_priv_user3" +== 028 +-- truncate_limit: 100 +-- need CASCADE to revoke grant or admin option if dependent grants exist +REVOKE ADMIN OPTION FOR regress_priv_user1 FROM regress_priv_user2 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE ADMIN OPTION FOR regress_priv_user1 FROM regress_priv_user2" +== 029 +-- truncate_limit: 100 +-- fail +REVOKE regress_priv_user1 FROM regress_priv_user2 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE regress_priv_user1 FROM regress_priv_user2" +== 030 +-- truncate_limit: 100 +-- fail +SELECT member::regrole, admin_option FROM pg_auth_members WHERE roleid = 'regress_priv_user1'::regrole +-- +TABLE: name="pg_auth_members" schema="" table="pg_auth_members" ctx=Select +FILTER: schema="" table="" column="roleid" +STMT: SelectStmt +TRUNCATED: "SELECT member::regrole, admin_option FROM pg_auth_members WHERE ..." +== 031 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 032 +-- truncate_limit: 100 +REVOKE ADMIN OPTION FOR regress_priv_user1 FROM regress_priv_user2 CASCADE +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE ADMIN OPTION FOR regress_priv_user1 FROM regress_priv_user2 CASCADE" +== 033 +-- truncate_limit: 100 +SELECT member::regrole, admin_option FROM pg_auth_members WHERE roleid = 'regress_priv_user1'::regrole +-- +TABLE: name="pg_auth_members" schema="" table="pg_auth_members" ctx=Select +FILTER: schema="" table="" column="roleid" +STMT: SelectStmt +TRUNCATED: "SELECT member::regrole, admin_option FROM pg_auth_members WHERE ..." +== 034 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 035 +-- truncate_limit: 100 +REVOKE regress_priv_user1 FROM regress_priv_user2 CASCADE +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE regress_priv_user1 FROM regress_priv_user2 CASCADE" +== 036 +-- truncate_limit: 100 +SELECT member::regrole, admin_option FROM pg_auth_members WHERE roleid = 'regress_priv_user1'::regrole +-- +TABLE: name="pg_auth_members" schema="" table="pg_auth_members" ctx=Select +FILTER: schema="" table="" column="roleid" +STMT: SelectStmt +TRUNCATED: "SELECT member::regrole, admin_option FROM pg_auth_members WHERE ..." +== 037 +-- truncate_limit: 100 +-- inferred grantor must be a role with ADMIN OPTION +GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION" +== 038 +-- truncate_limit: 100 +GRANT regress_priv_user2 TO regress_priv_user3 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user2 TO regress_priv_user3" +== 039 +-- truncate_limit: 100 +SET ROLE regress_priv_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_priv_user3" +== 040 +-- truncate_limit: 100 +GRANT regress_priv_user1 TO regress_priv_user4 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user4" +== 041 +-- truncate_limit: 100 +SELECT grantor::regrole FROM pg_auth_members WHERE roleid = 'regress_priv_user1'::regrole and member = 'regress_priv_user4'::regrole +-- +TABLE: name="pg_auth_members" schema="" table="pg_auth_members" ctx=Select +FILTER: schema="" table="" column="roleid" +FILTER: schema="" table="" column="member" +STMT: SelectStmt +TRUNCATED: "SELECT grantor::regrole FROM pg_auth_members WHERE ..." +== 042 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 043 +-- truncate_limit: 100 +REVOKE regress_priv_user2 FROM regress_priv_user3 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE regress_priv_user2 FROM regress_priv_user3" +== 044 +-- truncate_limit: 100 +REVOKE regress_priv_user1 FROM regress_priv_user2 CASCADE +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE regress_priv_user1 FROM regress_priv_user2 CASCADE" +== 045 +-- truncate_limit: 100 +-- test GRANTED BY with DROP OWNED and REASSIGN OWNED +GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user2 WITH ADMIN OPTION" +== 046 +-- truncate_limit: 100 +GRANT regress_priv_user1 TO regress_priv_user3 GRANTED BY regress_priv_user2 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user3 GRANTED BY regress_priv_user2" +== 047 +-- truncate_limit: 100 +DROP ROLE regress_priv_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user2" +== 048 +-- truncate_limit: 100 +-- fail, dependency +REASSIGN OWNED BY regress_priv_user2 TO regress_priv_user4 +-- +STMT: ReassignOwnedStmt +TRUNCATED: "REASSIGN OWNED BY regress_priv_user2 TO regress_priv_user4" +== 049 +-- truncate_limit: 100 +DROP ROLE regress_priv_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user2" +== 050 +-- truncate_limit: 100 +-- still fail, REASSIGN OWNED doesn't help +DROP OWNED BY regress_priv_user2 +-- +STMT: DropOwnedStmt +TRUNCATED: "DROP OWNED BY regress_priv_user2" +== 051 +-- truncate_limit: 100 +DROP ROLE regress_priv_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user2" +== 052 +-- truncate_limit: 100 +-- ok now, DROP OWNED does the job + +-- test that removing granted role or grantee role removes dependency +GRANT regress_priv_user1 TO regress_priv_user3 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user3 WITH ADMIN OPTION" +== 053 +-- truncate_limit: 100 +GRANT regress_priv_user1 TO regress_priv_user4 GRANTED BY regress_priv_user3 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user4 GRANTED BY regress_priv_user3" +== 054 +-- truncate_limit: 100 +DROP ROLE regress_priv_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user3" +== 055 +-- truncate_limit: 100 +-- should fail, dependency +DROP ROLE regress_priv_user4 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user4" +== 056 +-- truncate_limit: 100 +-- ok +DROP ROLE regress_priv_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user3" +== 057 +-- truncate_limit: 100 +-- ok now +GRANT regress_priv_user1 TO regress_priv_user5 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user5 WITH ADMIN OPTION" +== 058 +-- truncate_limit: 100 +GRANT regress_priv_user1 TO regress_priv_user6 GRANTED BY regress_priv_user5 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user1 TO regress_priv_user6 GRANTED BY regress_priv_user5" +== 059 +-- truncate_limit: 100 +DROP ROLE regress_priv_user5 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user5" +== 060 +-- truncate_limit: 100 +-- should fail, dependency +DROP ROLE regress_priv_user1, regress_priv_user5 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user1, regress_priv_user5" +== 061 +-- truncate_limit: 100 +-- ok, despite order + +-- recreate the roles we just dropped +CREATE USER regress_priv_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user1" +== 062 +-- truncate_limit: 100 +CREATE USER regress_priv_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user2" +== 063 +-- truncate_limit: 100 +CREATE USER regress_priv_user3 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user3" +== 064 +-- truncate_limit: 100 +CREATE USER regress_priv_user4 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user4" +== 065 +-- truncate_limit: 100 +CREATE USER regress_priv_user5 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_priv_user5" +== 066 +-- truncate_limit: 100 +GRANT pg_read_all_data TO regress_priv_user6 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT pg_read_all_data TO regress_priv_user6" +== 067 +-- truncate_limit: 100 +GRANT pg_write_all_data TO regress_priv_user7 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT pg_write_all_data TO regress_priv_user7" +== 068 +-- truncate_limit: 100 +GRANT pg_read_all_settings TO regress_priv_user8 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT pg_read_all_settings TO regress_priv_user8 WITH ADMIN OPTION" +== 069 +-- truncate_limit: 100 +GRANT regress_priv_user9 TO regress_priv_user8 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user9 TO regress_priv_user8" +== 070 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user8" +== 071 +-- truncate_limit: 100 +GRANT pg_read_all_settings TO regress_priv_user9 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT pg_read_all_settings TO regress_priv_user9 WITH ADMIN OPTION" +== 072 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user9 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user9" +== 073 +-- truncate_limit: 100 +GRANT pg_read_all_settings TO regress_priv_user10 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT pg_read_all_settings TO regress_priv_user10" +== 074 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user8" +== 075 +-- truncate_limit: 100 +REVOKE pg_read_all_settings FROM regress_priv_user10 GRANTED BY regress_priv_user9 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE pg_read_all_settings FROM regress_priv_user10 GRANTED BY regress_priv_user9" +== 076 +-- truncate_limit: 100 +REVOKE ADMIN OPTION FOR pg_read_all_settings FROM regress_priv_user9 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE ADMIN OPTION FOR pg_read_all_settings FROM regress_priv_user9" +== 077 +-- truncate_limit: 100 +REVOKE pg_read_all_settings FROM regress_priv_user9 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE pg_read_all_settings FROM regress_priv_user9" +== 078 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 079 +-- truncate_limit: 100 +REVOKE regress_priv_user9 FROM regress_priv_user8 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE regress_priv_user9 FROM regress_priv_user8" +== 080 +-- truncate_limit: 100 +REVOKE ADMIN OPTION FOR pg_read_all_settings FROM regress_priv_user8 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE ADMIN OPTION FOR pg_read_all_settings FROM regress_priv_user8" +== 081 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user8" +== 082 +-- truncate_limit: 100 +SET ROLE pg_read_all_settings +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO pg_read_all_settings" +== 083 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 084 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 085 +-- truncate_limit: 100 +REVOKE SET OPTION FOR pg_read_all_settings FROM regress_priv_user8 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE SET OPTION FOR pg_read_all_settings FROM regress_priv_user8" +== 086 +-- truncate_limit: 100 +GRANT pg_read_all_stats TO regress_priv_user8 WITH SET FALSE +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT pg_read_all_stats TO regress_priv_user8 WITH SET FALSE" +== 087 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user8" +== 088 +-- truncate_limit: 100 +SET ROLE pg_read_all_settings +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO pg_read_all_settings" +== 089 +-- truncate_limit: 100 +-- fail, no SET option any more +SET ROLE pg_read_all_stats +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO pg_read_all_stats" +== 090 +-- truncate_limit: 100 +-- fail, granted without SET option +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 091 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 092 +-- truncate_limit: 100 +-- test interaction of SET SESSION AUTHORIZATION and SET ROLE, +-- as well as propagation of these settings to parallel workers +GRANT regress_priv_user9 TO regress_priv_user8 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_user9 TO regress_priv_user8" +== 093 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user8 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user8" +== 094 +-- truncate_limit: 100 +SET ROLE regress_priv_user9 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_priv_user9" +== 095 +-- truncate_limit: 100 +SET debug_parallel_query = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 0" +== 096 +-- truncate_limit: 100 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT session_user, current_role, current_user, current_setting('role') AS role" +== 097 +-- truncate_limit: 100 +SET debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 1" +== 098 +-- truncate_limit: 100 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT session_user, current_role, current_user, current_setting('role') AS role" +== 099 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 100 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user10 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user10" +== 101 +-- truncate_limit: 100 +SET debug_parallel_query = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 0" +== 102 +-- truncate_limit: 100 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT session_user, current_role, current_user, current_setting('role') AS role" +== 103 +-- truncate_limit: 100 +SET debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 1" +== 104 +-- truncate_limit: 100 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT session_user, current_role, current_user, current_setting('role') AS role" +== 105 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 106 +-- truncate_limit: 100 +SET debug_parallel_query = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 0" +== 107 +-- truncate_limit: 100 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT session_user, current_role, current_user, current_setting('role') AS role" +== 108 +-- truncate_limit: 100 +SET debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 1" +== 109 +-- truncate_limit: 100 +SELECT session_user, current_role, current_user, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT session_user, current_role, current_user, current_setting('role') AS role" +== 110 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 111 +-- truncate_limit: 100 +-- session_user at this point is installation-dependent +SET debug_parallel_query = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 0" +== 112 +-- truncate_limit: 100 +SELECT session_user = current_role as c_r_ok, session_user = current_user as c_u_ok, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 113 +-- truncate_limit: 100 +SET debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 1" +== 114 +-- truncate_limit: 100 +SELECT session_user = current_role as c_r_ok, session_user = current_user as c_u_ok, current_setting('role') as role +-- +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 115 +-- truncate_limit: 100 +RESET debug_parallel_query +-- +STMT: VariableSetStmt +TRUNCATED: "RESET debug_parallel_query" +== 116 +-- truncate_limit: 100 +REVOKE pg_read_all_settings FROM regress_priv_user8 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE pg_read_all_settings FROM regress_priv_user8" +== 117 +-- truncate_limit: 100 +DROP USER regress_priv_user10 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user10" +== 118 +-- truncate_limit: 100 +DROP USER regress_priv_user9 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user9" +== 119 +-- truncate_limit: 100 +DROP USER regress_priv_user8 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_user8" +== 120 +-- truncate_limit: 100 +CREATE GROUP regress_priv_group1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE GROUP regress_priv_group1" +== 121 +-- truncate_limit: 100 +CREATE GROUP regress_priv_group2 WITH ADMIN regress_priv_user1 USER regress_priv_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE GROUP regress_priv_group2 WITH ADMIN regress_priv_user1 ROLE regress_priv_user2" +== 122 +-- truncate_limit: 100 +ALTER GROUP regress_priv_group1 ADD USER regress_priv_user4 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER GROUP regress_priv_group1 ADD USER regress_priv_user4" +== 123 +-- truncate_limit: 100 +GRANT regress_priv_group2 TO regress_priv_user2 GRANTED BY regress_priv_user1 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_group2 TO regress_priv_user2 GRANTED BY regress_priv_user1" +== 124 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user3" +== 125 +-- truncate_limit: 100 +ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2" +== 126 +-- truncate_limit: 100 +-- fail +ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2" +== 127 +-- truncate_limit: 100 +-- fail +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 128 +-- truncate_limit: 100 +ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2" +== 129 +-- truncate_limit: 100 +ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER GROUP regress_priv_group2 ADD USER regress_priv_user2" +== 130 +-- truncate_limit: 100 +-- duplicate +ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2" +== 131 +-- truncate_limit: 100 +ALTER USER regress_priv_user2 PASSWORD 'verysecret' +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_priv_user2 WITH PASSWORD 'verysecret'" +== 132 +-- truncate_limit: 100 +-- not permitted +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 133 +-- truncate_limit: 100 +ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2 +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER GROUP regress_priv_group2 DROP USER regress_priv_user2" +== 134 +-- truncate_limit: 100 +REVOKE ADMIN OPTION FOR regress_priv_group2 FROM regress_priv_user1 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE ADMIN OPTION FOR regress_priv_group2 FROM regress_priv_user1" +== 135 +-- truncate_limit: 100 +GRANT regress_priv_group2 TO regress_priv_user4 WITH ADMIN OPTION +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_group2 TO regress_priv_user4 WITH ADMIN OPTION" +== 136 +-- truncate_limit: 100 +-- prepare non-leakproof function for later +CREATE FUNCTION leak(integer,integer) RETURNS boolean + AS 'int4lt' + LANGUAGE internal IMMUTABLE STRICT +-- +FUNCTION: name="leak" function="leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION leak(int, int) RETURNS boolean AS $$int4lt$$ LANGUAGE internal IMMUTABLE RETURNS ..." +== 137 +-- truncate_limit: 100 +-- but deliberately not LEAKPROOF +ALTER FUNCTION leak(integer,integer) OWNER TO regress_priv_user1 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER FUNCTION leak(int, int) OWNER TO regress_priv_user1" +== 138 +-- truncate_limit: 100 +-- test owner privileges + +GRANT regress_priv_role TO regress_priv_user1 WITH ADMIN OPTION GRANTED BY regress_priv_role +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_role TO regress_priv_user1 WITH ADMIN OPTION GRANTED BY regress_priv_role" +== 139 +-- truncate_limit: 100 +-- error, doesn't have ADMIN OPTION +GRANT regress_priv_role TO regress_priv_user1 WITH ADMIN OPTION GRANTED BY CURRENT_ROLE +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_role TO regress_priv_user1 WITH ADMIN OPTION GRANTED BY CURRENT_ROLE" +== 140 +-- truncate_limit: 100 +REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY foo +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY foo" +== 141 +-- truncate_limit: 100 +-- error +REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY regress_priv_user2 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY regress_priv_user2" +== 142 +-- truncate_limit: 100 +-- warning, noop +REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY CURRENT_USER +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE ADMIN OPTION FOR regress_priv_role FROM regress_priv_user1 GRANTED BY CURRENT_USER" +== 143 +-- truncate_limit: 100 +REVOKE regress_priv_role FROM regress_priv_user1 GRANTED BY CURRENT_ROLE +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE regress_priv_role FROM regress_priv_user1 GRANTED BY CURRENT_ROLE" +== 144 +-- truncate_limit: 100 +DROP ROLE regress_priv_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_priv_role" +== 145 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 146 +-- truncate_limit: 100 +SELECT session_user, current_user +-- +STMT: SelectStmt +TRUNCATED: "SELECT session_user, current_user" +== 147 +-- truncate_limit: 100 +CREATE TABLE atest1 ( a int, b text ) +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atest1 (a int, b text)" +== 148 +-- truncate_limit: 100 +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest1" +== 149 +-- truncate_limit: 100 +INSERT INTO atest1 VALUES (1, 'one') +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atest1 VALUES (1, 'one')" +== 150 +-- truncate_limit: 100 +DELETE FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atest1" +== 151 +-- truncate_limit: 100 +UPDATE atest1 SET a = 1 WHERE b = 'blech' +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atest1 SET a = 1 WHERE b = 'blech'" +== 152 +-- truncate_limit: 100 +TRUNCATE atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE atest1" +== 153 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 154 +-- truncate_limit: 100 +LOCK atest1 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE atest1" +== 155 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 156 +-- truncate_limit: 100 +REVOKE ALL ON atest1 FROM PUBLIC +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON atest1 FROM public" +== 157 +-- truncate_limit: 100 +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest1" +== 158 +-- truncate_limit: 100 +GRANT ALL ON atest1 TO regress_priv_user2 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON atest1 TO regress_priv_user2" +== 159 +-- truncate_limit: 100 +GRANT SELECT ON atest1 TO regress_priv_user3, regress_priv_user4 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON atest1 TO regress_priv_user3, regress_priv_user4" +== 160 +-- truncate_limit: 100 +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest1" +== 161 +-- truncate_limit: 100 +CREATE TABLE atest2 (col1 varchar(10), col2 boolean) +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atest2 (col1 varchar(10), col2 boolean)" +== 162 +-- truncate_limit: 100 +GRANT SELECT ON atest2 TO regress_priv_user2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON atest2 TO regress_priv_user2" +== 163 +-- truncate_limit: 100 +GRANT UPDATE ON atest2 TO regress_priv_user3 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON atest2 TO regress_priv_user3" +== 164 +-- truncate_limit: 100 +GRANT INSERT ON atest2 TO regress_priv_user4 GRANTED BY CURRENT_USER +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON atest2 TO regress_priv_user4 GRANTED BY CURRENT_USER" +== 165 +-- truncate_limit: 100 +GRANT TRUNCATE ON atest2 TO regress_priv_user5 GRANTED BY CURRENT_ROLE +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT truncate ON atest2 TO regress_priv_user5 GRANTED BY CURRENT_ROLE" +== 166 +-- truncate_limit: 100 +GRANT TRUNCATE ON atest2 TO regress_priv_user4 GRANTED BY regress_priv_user5 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT truncate ON atest2 TO regress_priv_user4 GRANTED BY regress_priv_user5" +== 167 +-- truncate_limit: 100 +-- error + + +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user2" +== 168 +-- truncate_limit: 100 +SELECT session_user, current_user +-- +STMT: SelectStmt +TRUNCATED: "SELECT session_user, current_user" +== 169 +-- truncate_limit: 100 +-- try various combinations of queries on atest1 and atest2 + +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest1" +== 170 +-- truncate_limit: 100 +-- ok +SELECT * FROM atest2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest2" +== 171 +-- truncate_limit: 100 +-- ok +INSERT INTO atest1 VALUES (2, 'two') +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atest1 VALUES (2, 'two')" +== 172 +-- truncate_limit: 100 +-- ok +INSERT INTO atest2 VALUES ('foo', true) +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atest2 VALUES ('foo', true)" +== 173 +-- truncate_limit: 100 +-- fail +INSERT INTO atest1 SELECT 1, b FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atest1 SELECT 1, b FROM atest1" +== 174 +-- truncate_limit: 100 +-- ok +UPDATE atest1 SET a = 1 WHERE a = 2 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atest1 SET a = 1 WHERE a = 2" +== 175 +-- truncate_limit: 100 +-- ok +UPDATE atest2 SET col2 = NOT col2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atest2 SET col2 = NOT col2" +== 176 +-- truncate_limit: 100 +-- fail +SELECT * FROM atest1 FOR UPDATE +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest1 FOR UPDATE" +== 177 +-- truncate_limit: 100 +-- ok +SELECT * FROM atest2 FOR UPDATE +-- +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest2 FOR UPDATE" +== 178 +-- truncate_limit: 100 +-- fail +DELETE FROM atest2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atest2" +== 179 +-- truncate_limit: 100 +-- fail +TRUNCATE atest2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE atest2" +== 180 +-- truncate_limit: 100 +-- fail +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 181 +-- truncate_limit: 100 +LOCK atest2 IN ACCESS EXCLUSIVE MODE +-- +TABLE: name="atest2" schema="" table="atest2" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE atest2" +== 182 +-- truncate_limit: 100 +-- fail +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 183 +-- truncate_limit: 100 +COPY atest2 FROM stdin +-- +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY atest2 FROM STDIN" +== 184 +-- truncate_limit: 100 +-- fail +GRANT ALL ON atest1 TO PUBLIC +-- +TABLE: name="atest1" schema="" table="atest1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON atest1 TO public" +== 185 +-- truncate_limit: 100 +-- fail + +-- checks in subquery, both ok +SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) ) +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest2" schema="" table="atest2" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest1 WHERE b IN (SELECT col1 FROM atest2)" +== 186 +-- truncate_limit: 100 +SELECT * FROM atest1 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest1" +== 187 +-- truncate_limit: 100 +-- ok + + +-- test leaky-function protections in selfuncs + +-- regress_priv_user1 will own a table and provide views for it. +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 188 +-- truncate_limit: 100 +CREATE TABLE atest12 as + SELECT x AS a, 10001 - x AS b FROM generate_series(1,10000) x +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE atest12 AS SELECT x AS a, 10001 - x AS b FROM generate_series(1, 10000) x" +== 189 +-- truncate_limit: 100 +CREATE INDEX ON atest12 (a) +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON atest12 USING btree (a)" +== 190 +-- truncate_limit: 100 +CREATE INDEX ON atest12 (abs(a)) +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +FUNCTION: name="abs" function="abs" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON atest12 USING btree (abs(a))" +== 191 +-- truncate_limit: 100 +-- results below depend on having quite accurate stats for atest12, so... +ALTER TABLE atest12 SET (autovacuum_enabled = off) +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE atest12 SET (autovacuum_enabled=off)" +== 192 +-- truncate_limit: 100 +SET default_statistics_target = 10000 +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_statistics_target TO 10000" +== 193 +-- truncate_limit: 100 +VACUUM ANALYZE atest12 +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) atest12" +== 194 +-- truncate_limit: 100 +RESET default_statistics_target +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_statistics_target" +== 195 +-- truncate_limit: 100 +CREATE OPERATOR <<< (procedure = leak, leftarg = integer, rightarg = integer, + restrict = scalarltsel) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR <<< (procedure = leak, leftarg = int, rightarg = int, restrict = scalarltsel)" +== 196 +-- truncate_limit: 100 +-- views with leaky operator +CREATE VIEW atest12v AS + SELECT * FROM atest12 WHERE b <<< 5 +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=DDL +TABLE: name="atest12" schema="" table="atest12" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW atest12v AS SELECT * FROM atest12 WHERE b <<< 5" +== 197 +-- truncate_limit: 100 +CREATE VIEW atest12sbv WITH (security_barrier=true) AS + SELECT * FROM atest12 WHERE b <<< 5 +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=DDL +TABLE: name="atest12" schema="" table="atest12" ctx=Select +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW atest12sbv WITH (security_barrier=true) AS SELECT * FROM atest12 WHERE b <<< 5" +== 198 +-- truncate_limit: 100 +-- This plan should use nestloop, knowing that few rows will be selected. +EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +ALIAS: "x"="atest12v" +ALIAS: "y"="atest12v" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b" +== 199 +-- truncate_limit: 100 +-- And this one. +EXPLAIN (COSTS OFF) SELECT * FROM atest12 x, atest12 y + WHERE x.a = y.b and abs(y.a) <<< 5 +-- +TABLE: name="atest12" schema="" table="atest12" ctx=Select +TABLE: name="atest12" schema="" table="atest12" ctx=Select +ALIAS: "x"="atest12" +ALIAS: "y"="atest12" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +FILTER: schema="" table="y" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12 x, atest12 y WHERE x.a = y.b AND abs(y.a) <<< 5" +== 200 +-- truncate_limit: 100 +-- This should also be a nestloop, but the security barrier forces the inner +-- scan to be materialized +EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y WHERE x.a = y.b +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +ALIAS: "x"="atest12sbv" +ALIAS: "y"="atest12sbv" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y WHERE x.a = y.b" +== 201 +-- truncate_limit: 100 +-- Check if regress_priv_user2 can break security. +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user2" +== 202 +-- truncate_limit: 100 +CREATE FUNCTION leak2(integer,integer) RETURNS boolean + AS $$begin raise notice 'leak % %', $1, $2; return $1 > $2; end$$ + LANGUAGE plpgsql immutable +-- +FUNCTION: name="leak2" function="leak2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION leak2(int, int) RETURNS boolean AS $$begin raise notice 'leak % %', $1, $2; retur..." +== 203 +-- truncate_limit: 100 +CREATE OPERATOR >>> (procedure = leak2, leftarg = integer, rightarg = integer, + restrict = scalargtsel) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR >>> (procedure = leak2, leftarg = int, rightarg = int, restrict = scalargtsel)" +== 204 +-- truncate_limit: 100 +-- These should not show any "leak" notices before failing. +EXPLAIN (COSTS OFF) SELECT * FROM atest12 WHERE a >>> 0 +-- +TABLE: name="atest12" schema="" table="atest12" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12 WHERE a >>> 0" +== 205 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM atest12v WHERE a >>> 0 +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12v WHERE a >>> 0" +== 206 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv WHERE a >>> 0 +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv WHERE a >>> 0" +== 207 +-- truncate_limit: 100 +-- Now regress_priv_user1 grants access to regress_priv_user2 via the views. +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 208 +-- truncate_limit: 100 +GRANT SELECT ON atest12v TO PUBLIC +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON atest12v TO public" +== 209 +-- truncate_limit: 100 +GRANT SELECT ON atest12sbv TO PUBLIC +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON atest12sbv TO public" +== 210 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user2" +== 211 +-- truncate_limit: 100 +-- These plans should continue to use a nestloop, since they execute with the +-- privileges of the view owner. +EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +ALIAS: "x"="atest12v" +ALIAS: "y"="atest12v" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b" +== 212 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y WHERE x.a = y.b +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +ALIAS: "x"="atest12sbv" +ALIAS: "y"="atest12sbv" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y WHERE x.a = y.b" +== 213 +-- truncate_limit: 100 +-- A non-security barrier view does not guard against information leakage. +EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y + WHERE x.a = y.b and abs(y.a) <<< 5 +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +ALIAS: "x"="atest12v" +ALIAS: "y"="atest12v" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +FILTER: schema="" table="y" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b AND abs(y.a) <<< 5" +== 214 +-- truncate_limit: 100 +-- But a security barrier view isolates the leaky operator. +EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y + WHERE x.a = y.b and abs(y.a) <<< 5 +-- +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +TABLE: name="atest12sbv" schema="" table="atest12sbv" ctx=Select +ALIAS: "x"="atest12sbv" +ALIAS: "y"="atest12sbv" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +FILTER: schema="" table="y" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y WHERE x.a = y.b AND abs(y.a) <<< 5" +== 215 +-- truncate_limit: 100 +-- Now regress_priv_user1 grants sufficient access to regress_priv_user2. +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 216 +-- truncate_limit: 100 +GRANT SELECT (a, b) ON atest12 TO PUBLIC +-- +TABLE: name="atest12" schema="" table="atest12" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (a, b) ON atest12 TO public" +== 217 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user2" +== 218 +-- truncate_limit: 100 +-- regress_priv_user2 should continue to get a good row estimate. +EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b +-- +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +TABLE: name="atest12v" schema="" table="atest12v" ctx=Select +ALIAS: "x"="atest12v" +ALIAS: "y"="atest12v" +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b" +== 219 +-- truncate_limit: 100 +-- But not for this, due to lack of table-wide permissions needed +-- to make use of the expression index's statistics. +EXPLAIN (COSTS OFF) SELECT * FROM atest12 x, atest12 y + WHERE x.a = y.b and abs(y.a) <<< 5 +-- +TABLE: name="atest12" schema="" table="atest12" ctx=Select +TABLE: name="atest12" schema="" table="atest12" ctx=Select +ALIAS: "x"="atest12" +ALIAS: "y"="atest12" +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="b" +FILTER: schema="" table="y" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM atest12 x, atest12 y WHERE x.a = y.b AND abs(y.a) <<< 5" +== 220 +-- truncate_limit: 100 +-- clean up (regress_priv_user1's objects are all dropped later) +DROP FUNCTION leak2(integer, integer) CASCADE +-- +FUNCTION: name="leak2" function="leak2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION leak2(int, int) CASCADE" +== 221 +-- truncate_limit: 100 +-- groups + +SET SESSION AUTHORIZATION regress_priv_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user3" +== 222 +-- truncate_limit: 100 +CREATE TABLE atest3 (one int, two int, three int) +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atest3 (one int, two int, three int)" +== 223 +-- truncate_limit: 100 +GRANT DELETE ON atest3 TO GROUP regress_priv_group2 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT delete ON atest3 TO regress_priv_group2" +== 224 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 225 +-- truncate_limit: 100 +SELECT * FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest3" +== 226 +-- truncate_limit: 100 +-- fail +DELETE FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atest3" +== 227 +-- truncate_limit: 100 +-- ok + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 228 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 229 +-- truncate_limit: 100 +ALTER ROLE regress_priv_user1 NOINHERIT +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_priv_user1 WITH NOINHERIT" +== 230 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 231 +-- truncate_limit: 100 +SAVEPOINT s1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT s1" +== 232 +-- truncate_limit: 100 +DELETE FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atest3" +== 233 +-- truncate_limit: 100 +-- ok because grant-level option is unchanged +ROLLBACK TO s1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT s1" +== 234 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 235 +-- truncate_limit: 100 +GRANT regress_priv_group2 TO regress_priv_user1 WITH INHERIT FALSE +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_priv_group2 TO regress_priv_user1 WITH INHERIT FALSE" +== 236 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 237 +-- truncate_limit: 100 +DELETE FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atest3" +== 238 +-- truncate_limit: 100 +-- fail +ROLLBACK TO s1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT s1" +== 239 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 240 +-- truncate_limit: 100 +REVOKE INHERIT OPTION FOR regress_priv_group2 FROM regress_priv_user1 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE INHERIT OPTION FOR regress_priv_group2 FROM regress_priv_user1" +== 241 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 242 +-- truncate_limit: 100 +DELETE FROM atest3 +-- +TABLE: name="atest3" schema="" table="atest3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM atest3" +== 243 +-- truncate_limit: 100 +-- also fail +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 244 +-- truncate_limit: 100 +-- views + +SET SESSION AUTHORIZATION regress_priv_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user3" +== 245 +-- truncate_limit: 100 +CREATE VIEW atestv1 AS SELECT * FROM atest1 +-- +TABLE: name="atestv1" schema="" table="atestv1" ctx=DDL +TABLE: name="atest1" schema="" table="atest1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW atestv1 AS SELECT * FROM atest1" +== 246 +-- truncate_limit: 100 +-- ok +/* The next *should* fail, but it's not implemented that way yet. */ +CREATE VIEW atestv2 AS SELECT * FROM atest2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=DDL +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW atestv2 AS SELECT * FROM atest2" +== 247 +-- truncate_limit: 100 +CREATE VIEW atestv3 AS SELECT * FROM atest3 +-- +TABLE: name="atestv3" schema="" table="atestv3" ctx=DDL +TABLE: name="atest3" schema="" table="atest3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW atestv3 AS SELECT * FROM atest3" +== 248 +-- truncate_limit: 100 +-- ok +/* Empty view is a corner case that failed in 9.2. */ +CREATE VIEW atestv0 AS SELECT 0 as x WHERE false +-- +TABLE: name="atestv0" schema="" table="atestv0" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW atestv0 AS SELECT 0 AS x WHERE false" +== 249 +-- truncate_limit: 100 +-- ok + +SELECT * FROM atestv1 +-- +TABLE: name="atestv1" schema="" table="atestv1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv1" +== 250 +-- truncate_limit: 100 +-- ok +SELECT * FROM atestv2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv2" +== 251 +-- truncate_limit: 100 +-- fail +GRANT SELECT ON atestv1, atestv3 TO regress_priv_user4 +-- +TABLE: name="atestv1" schema="" table="atestv1" ctx=DDL +TABLE: name="atestv3" schema="" table="atestv3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON atestv1, atestv3 TO regress_priv_user4" +== 252 +-- truncate_limit: 100 +GRANT SELECT ON atestv2 TO regress_priv_user2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON atestv2 TO regress_priv_user2" +== 253 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user4" +== 254 +-- truncate_limit: 100 +SELECT * FROM atestv1 +-- +TABLE: name="atestv1" schema="" table="atestv1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv1" +== 255 +-- truncate_limit: 100 +-- ok +SELECT * FROM atestv2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv2" +== 256 +-- truncate_limit: 100 +-- fail +SELECT * FROM atestv3 +-- +TABLE: name="atestv3" schema="" table="atestv3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv3" +== 257 +-- truncate_limit: 100 +-- ok +SELECT * FROM atestv0 +-- +TABLE: name="atestv0" schema="" table="atestv0" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv0" +== 258 +-- truncate_limit: 100 +-- fail + +-- Appendrels excluded by constraints failed to check permissions in 8.4-9.2. +select * from + ((select a.q1 as x from int8_tbl a offset 0) + union all + (select b.q2 as x from int8_tbl b offset 0)) ss +where false +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ((SELECT ... FROM int8_tbl a OFFSET 0) UNION ALL (SELECT ... FROM int8_tbl b OFFSET..." +== 259 +-- truncate_limit: 100 +set constraint_exclusion = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET constraint_exclusion TO ON" +== 260 +-- truncate_limit: 100 +select * from + ((select a.q1 as x, random() from int8_tbl a where q1 > 0) + union all + (select b.q2 as x, random() from int8_tbl b where q2 > 0)) ss +where x < 0 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM int8_tbl a WHERE ... UNION ALL SELECT ... FROM int8_tbl b WHERE ....." +== 261 +-- truncate_limit: 100 +reset constraint_exclusion +-- +STMT: VariableSetStmt +TRUNCATED: "RESET constraint_exclusion" +== 262 +-- truncate_limit: 100 +CREATE VIEW atestv4 AS SELECT * FROM atestv3 +-- +TABLE: name="atestv4" schema="" table="atestv4" ctx=DDL +TABLE: name="atestv3" schema="" table="atestv3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW atestv4 AS SELECT * FROM atestv3" +== 263 +-- truncate_limit: 100 +-- nested view +SELECT * FROM atestv4 +-- +TABLE: name="atestv4" schema="" table="atestv4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv4" +== 264 +-- truncate_limit: 100 +-- ok +GRANT SELECT ON atestv4 TO regress_priv_user2 +-- +TABLE: name="atestv4" schema="" table="atestv4" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON atestv4 TO regress_priv_user2" +== 265 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user2" +== 266 +-- truncate_limit: 100 +-- Two complex cases: + +SELECT * FROM atestv3 +-- +TABLE: name="atestv3" schema="" table="atestv3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv3" +== 267 +-- truncate_limit: 100 +-- fail +SELECT * FROM atestv4 +-- +TABLE: name="atestv4" schema="" table="atestv4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv4" +== 268 +-- truncate_limit: 100 +-- ok (even though regress_priv_user2 cannot access underlying atestv3) + +SELECT * FROM atest2 +-- +TABLE: name="atest2" schema="" table="atest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest2" +== 269 +-- truncate_limit: 100 +-- ok +SELECT * FROM atestv2 +-- +TABLE: name="atestv2" schema="" table="atestv2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atestv2" +== 270 +-- truncate_limit: 100 +-- fail (even though regress_priv_user2 can access underlying atest2) + +-- Test column level permissions + +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 271 +-- truncate_limit: 100 +CREATE TABLE atest5 (one int, two int unique, three int, four int unique) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atest5 (one int, two int UNIQUE, three int, four int UNIQUE)" +== 272 +-- truncate_limit: 100 +CREATE TABLE atest6 (one int, two int, blue int) +-- +TABLE: name="atest6" schema="" table="atest6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE atest6 (one int, two int, blue int)" +== 273 +-- truncate_limit: 100 +GRANT SELECT (one), INSERT (two), UPDATE (three) ON atest5 TO regress_priv_user4 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (one), insert (two), update (three) ON atest5 TO regress_priv_user4" +== 274 +-- truncate_limit: 100 +GRANT ALL (one) ON atest5 TO regress_priv_user3 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL (one) ON atest5 TO regress_priv_user3" +== 275 +-- truncate_limit: 100 +INSERT INTO atest5 VALUES (1,2,3) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atest5 VALUES (1, 2, 3)" +== 276 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user4" +== 277 +-- truncate_limit: 100 +SELECT * FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest5" +== 278 +-- truncate_limit: 100 +-- fail +SELECT one FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT one FROM atest5" +== 279 +-- truncate_limit: 100 +-- ok +COPY atest5 (one) TO stdout +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY atest5(one) TO STDOUT" +== 280 +-- truncate_limit: 100 +-- ok +SELECT two FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT two FROM atest5" +== 281 +-- truncate_limit: 100 +-- fail +COPY atest5 (two) TO stdout +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY atest5(two) TO STDOUT" +== 282 +-- truncate_limit: 100 +-- fail +SELECT atest5 FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT atest5 FROM atest5" +== 283 +-- truncate_limit: 100 +-- fail +COPY atest5 (one,two) TO stdout +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY atest5(one, two) TO STDOUT" +== 284 +-- truncate_limit: 100 +-- fail +SELECT 1 FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM atest5" +== 285 +-- truncate_limit: 100 +-- ok +SELECT 1 FROM atest5 a JOIN atest5 b USING (one) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM atest5 a JOIN atest5 b USING (one)" +== 286 +-- truncate_limit: 100 +-- ok +SELECT 1 FROM atest5 a JOIN atest5 b USING (two) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM atest5 a JOIN atest5 b USING (two)" +== 287 +-- truncate_limit: 100 +-- fail +SELECT 1 FROM atest5 a NATURAL JOIN atest5 b +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM atest5 a NATURAL JOIN atest5 b" +== 288 +-- truncate_limit: 100 +-- fail +SELECT * FROM (atest5 a JOIN atest5 b USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (atest5 a JOIN atest5 b USING (one) ) j" +== 289 +-- truncate_limit: 100 +-- fail +SELECT j.* FROM (atest5 a JOIN atest5 b USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT j.* FROM (atest5 a JOIN atest5 b USING (one) ) j" +== 290 +-- truncate_limit: 100 +-- fail +SELECT (j.*) IS NULL FROM (atest5 a JOIN atest5 b USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT j.* IS NULL FROM (atest5 a JOIN atest5 b USING (one) ) j" +== 291 +-- truncate_limit: 100 +-- fail +SELECT one FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT one FROM (atest5 a JOIN atest5 b(one, x, y, z) USING (one) ) j" +== 292 +-- truncate_limit: 100 +-- ok +SELECT j.one FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT j.one FROM (atest5 a JOIN atest5 b(one, x, y, z) USING (one) ) j" +== 293 +-- truncate_limit: 100 +-- ok +SELECT two FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT two FROM (atest5 a JOIN atest5 b(one, x, y, z) USING (one) ) j" +== 294 +-- truncate_limit: 100 +-- fail +SELECT j.two FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT j.two FROM (atest5 a JOIN atest5 b(one, x, y, z) USING (one) ) j" +== 295 +-- truncate_limit: 100 +-- fail +SELECT y FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT y FROM (atest5 a JOIN atest5 b(one, x, y, z) USING (one) ) j" +== 296 +-- truncate_limit: 100 +-- fail +SELECT j.y FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) j +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT j.y FROM (atest5 a JOIN atest5 b(one, x, y, z) USING (one) ) j" +== 297 +-- truncate_limit: 100 +-- fail +SELECT * FROM (atest5 a JOIN atest5 b USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest5 a JOIN atest5 b USING (one)" +== 298 +-- truncate_limit: 100 +-- fail +SELECT a.* FROM (atest5 a JOIN atest5 b USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT a.* FROM atest5 a JOIN atest5 b USING (one)" +== 299 +-- truncate_limit: 100 +-- fail +SELECT (a.*) IS NULL FROM (atest5 a JOIN atest5 b USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT a.* IS NULL FROM atest5 a JOIN atest5 b USING (one)" +== 300 +-- truncate_limit: 100 +-- fail +SELECT two FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT two FROM atest5 a JOIN atest5 b(one, x, y, z) USING (one)" +== 301 +-- truncate_limit: 100 +-- fail +SELECT a.two FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT a.two FROM atest5 a JOIN atest5 b(one, x, y, z) USING (one)" +== 302 +-- truncate_limit: 100 +-- fail +SELECT y FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT y FROM atest5 a JOIN atest5 b(one, x, y, z) USING (one)" +== 303 +-- truncate_limit: 100 +-- fail +SELECT b.y FROM (atest5 a JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT b.y FROM atest5 a JOIN atest5 b(one, x, y, z) USING (one)" +== 304 +-- truncate_limit: 100 +-- fail +SELECT y FROM (atest5 a LEFT JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT y FROM atest5 a LEFT JOIN atest5 b(one, x, y, z) USING (one)" +== 305 +-- truncate_limit: 100 +-- fail +SELECT b.y FROM (atest5 a LEFT JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT b.y FROM atest5 a LEFT JOIN atest5 b(one, x, y, z) USING (one)" +== 306 +-- truncate_limit: 100 +-- fail +SELECT y FROM (atest5 a FULL JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT y FROM atest5 a FULL JOIN atest5 b(one, x, y, z) USING (one)" +== 307 +-- truncate_limit: 100 +-- fail +SELECT b.y FROM (atest5 a FULL JOIN atest5 b(one,x,y,z) USING (one)) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +ALIAS: "a"="atest5" +ALIAS: "b"="atest5" +STMT: SelectStmt +TRUNCATED: "SELECT b.y FROM atest5 a FULL JOIN atest5 b(one, x, y, z) USING (one)" +== 308 +-- truncate_limit: 100 +-- fail +SELECT 1 FROM atest5 WHERE two = 2 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +FILTER: schema="" table="" column="two" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM atest5 WHERE two = 2" +== 309 +-- truncate_limit: 100 +-- fail +SELECT * FROM atest1, atest5 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM atest1, atest5" +== 310 +-- truncate_limit: 100 +-- fail +SELECT atest1.* FROM atest1, atest5 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT atest1.* FROM atest1, atest5" +== 311 +-- truncate_limit: 100 +-- ok +SELECT atest1.*,atest5.one FROM atest1, atest5 +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT atest1.*, atest5.one FROM atest1, atest5" +== 312 +-- truncate_limit: 100 +-- ok +SELECT atest1.*,atest5.one FROM atest1 JOIN atest5 ON (atest1.a = atest5.two) +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT atest1.*, atest5.one FROM atest1 JOIN atest5 ON atest1.a = atest5.two" +== 313 +-- truncate_limit: 100 +-- fail +SELECT atest1.*,atest5.one FROM atest1 JOIN atest5 ON (atest1.a = atest5.one) +-- +TABLE: name="atest1" schema="" table="atest1" ctx=Select +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT atest1.*, atest5.one FROM atest1 JOIN atest5 ON atest1.a = atest5.one" +== 314 +-- truncate_limit: 100 +-- ok +SELECT one, two FROM atest5 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT one, two FROM atest5" +== 315 +-- truncate_limit: 100 +-- fail + +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 316 +-- truncate_limit: 100 +GRANT SELECT (one,two) ON atest6 TO regress_priv_user4 +-- +TABLE: name="atest6" schema="" table="atest6" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (one, two) ON atest6 TO regress_priv_user4" +== 317 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user4" +== 318 +-- truncate_limit: 100 +SELECT one, two FROM atest5 NATURAL JOIN atest6 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest6" schema="" table="atest6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT one, two FROM atest5 NATURAL JOIN atest6" +== 319 +-- truncate_limit: 100 +-- fail still + +SET SESSION AUTHORIZATION regress_priv_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user1" +== 320 +-- truncate_limit: 100 +GRANT SELECT (two) ON atest5 TO regress_priv_user4 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (two) ON atest5 TO regress_priv_user4" +== 321 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_priv_user4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_priv_user4" +== 322 +-- truncate_limit: 100 +SELECT one, two FROM atest5 NATURAL JOIN atest6 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +TABLE: name="atest6" schema="" table="atest6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT one, two FROM atest5 NATURAL JOIN atest6" +== 323 +-- truncate_limit: 100 +-- ok now + +-- test column-level privileges for INSERT and UPDATE +INSERT INTO atest5 (two) VALUES (3) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atest5 (two) VALUES (3)" +== 324 +-- truncate_limit: 100 +-- ok +COPY atest5 FROM stdin +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY atest5 FROM STDIN" +== 325 +-- truncate_limit: 100 +-- fail +COPY atest5 (two) FROM stdin +-- +TABLE: name="atest5" schema="" table="atest5" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY atest5(two) FROM STDIN" +== 326 +-- truncate_limit: 100 +-- ok +1 +INSERT INTO atest5 (three) VALUES (4) +-- +ERROR: syntax error at or near "1" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 327 +-- truncate_limit: 100 +-- fail +INSERT INTO atest5 VALUES (5,5,5) +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atest5 VALUES (5, 5, 5)" +== 328 +-- truncate_limit: 100 +-- fail +UPDATE atest5 SET three = 10 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atest5 SET three = 10" +== 329 +-- truncate_limit: 100 +-- ok +UPDATE atest5 SET one = 8 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atest5 SET one = 8" +== 330 +-- truncate_limit: 100 +-- fail +UPDATE atest5 SET three = 5, one = 2 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE atest5 SET three = 5, one = 2" +== 331 +-- truncate_limit: 100 +-- fail +-- Check that column level privs are enforced in RETURNING +-- Ok. +INSERT INTO atest5(two) VALUES (6) ON CONFLICT (two) DO UPDATE set three = 10 +-- +TABLE: name="atest5" schema="" table="atest5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO atest5 (two) VALUES (6) ON CONFLICT (two) DO UPDATE SET three = 10" diff --git a/parser/testdata/summary_truncate/postgres_regress/psql.metadata.json b/parser/testdata/summary_truncate/postgres_regress/psql.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/psql.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/psql.test b/parser/testdata/summary_truncate/postgres_regress/psql.test new file mode 100644 index 0000000..8426bc8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/psql.test @@ -0,0 +1,1410 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for psql features that aren't closely connected to any +-- specific server features +|-- + +-- \set + +-- fail: invalid name +-- fail: invalid value for special variable +-- check handling of built-in boolean variable + +-- ; + +SELECT 1 as one, 2 as two +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one, 2 AS two" +== 002 +-- truncate_limit: 100 +SELECT 3 as three, 4 as four \gx + +-- \gx should work in FETCH_COUNT mode too + +SELECT 1 as one, 2 as two +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +-- truncate_limit: 100 +SELECT 3 as three, 4 as four \gx + + +-- ; + +SELECT 1 as one, 2 as two \g (format=csv csv_fieldsep='\t') +SELECT 1 as one, 2 as two \gx (title='foo bar') + +-- \bind (extended query protocol) + +SELECT 1 \bind +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +SELECT $1 \bind 'foo' +-- +ERROR: syntax error at or near "\" +CURSORPOS: 11 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- truncate_limit: 100 +SELECT $1, $2 \bind 'foo' 'bar' +-- +ERROR: syntax error at or near "\" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +-- truncate_limit: 100 +-- errors +-- parse error +SELECT foo \bind +-- +ERROR: syntax error at or near "\" +CURSORPOS: 37 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- truncate_limit: 100 +-- tcop error +SELECT 1 \ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +-- truncate_limit: 100 +SELECT 2 \bind +-- +ERROR: syntax error at or near "\" +CURSORPOS: 10 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- truncate_limit: 100 +-- bind error +SELECT $1, $2 \bind 'foo' +-- +ERROR: syntax error at or near "\" +CURSORPOS: 29 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 010 +-- truncate_limit: 100 +-- ; + +select 10 as test01, 20 as test02, 'Hello' as test03 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 10 AS test01, 20 AS test02, 'Hello' AS test03" +== 011 +-- truncate_limit: 100 +-- should fail: bad variable name +select 10 as "bad name" + +select 97 as "EOF", 'ok' as _foo +-- +ERROR: syntax error at or near "select" +CURSORPOS: 60 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 012 +-- truncate_limit: 100 +-- multiple backslash commands in one line +select 1 as x, 2 as y +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS x, 2 AS y" +== 013 +-- truncate_limit: 100 +select 3 as x, 4 as y +-- +STMT: SelectStmt +TRUNCATED: "SELECT 3 AS x, 4 AS y" +== 014 +-- truncate_limit: 100 +select 5 as x, 6 as y +-- +STMT: SelectStmt +TRUNCATED: "SELECT 5 AS x, 6 AS y" +== 015 +-- truncate_limit: 100 +select 7 as x, 8 as y +-- +STMT: SelectStmt +TRUNCATED: "SELECT 7 AS x, 8 AS y" +== 016 +-- truncate_limit: 100 +-- NULL should unset the variable +select 1 as var1, NULL as var2, 3 as var3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS var1, NULL AS var2, 3 AS var3" +== 017 +-- truncate_limit: 100 +-- ; +select 10 as test01, 20 as test02 from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 10 AS test01, 20 AS test02 FROM generate_series(1, 3)" +== 018 +-- truncate_limit: 100 +select 10 as test01, 20 as test02 from generate_series(1,0) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 10 AS test01, 20 AS test02 FROM generate_series(1, 0)" +== 019 +-- truncate_limit: 100 +-- ; +select a from generate_series(1, 10) as a where a = 11 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM generate_series(1, 10) a WHERE a = 11" +== 020 +-- truncate_limit: 100 +-- ; + +select 1 as x, 2 as y +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS x, 2 AS y" +== 021 +-- truncate_limit: 100 +select 3 as x, 4 as y +-- +STMT: SelectStmt +TRUNCATED: "SELECT 3 AS x, 4 AS y" +== 022 +-- truncate_limit: 100 +select 10 as test01, 20 as test02 from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 10 AS test01, 20 AS test02 FROM generate_series(1, 3)" +== 023 +-- truncate_limit: 100 +select 10 as test01, 20 as test02 from generate_series(1,0) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 10 AS test01, 20 AS test02 FROM generate_series(1, 0)" +== 024 +-- truncate_limit: 100 +-- ; + +SELECT + NULL AS zero, + 1 AS one, + 2.0 AS two, + 'three' AS three, + $1 AS four, + sin($2) as five, + 'foo'::varchar(4) as six, + CURRENT_DATE AS now + +-- should work with tuple-returning utilities, such as EXECUTE +PREPARE test AS SELECT 1 AS first, 2 AS second +-- +ERROR: syntax error at or near "PREPARE" +CURSORPOS: 239 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 025 +-- truncate_limit: 100 +EXECUTE test +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE test" +== 026 +-- truncate_limit: 100 +EXPLAIN EXECUTE test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN EXECUTE test" +== 027 +-- truncate_limit: 100 +-- should fail cleanly - syntax error +SELECT 1 + +-- +ERROR: syntax error at end of input +CURSORPOS: 49 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 028 +-- truncate_limit: 100 +-- check behavior with empty results +SELECT +-- +STMT: SelectStmt +TRUNCATED: "SELECT" +== 029 +-- truncate_limit: 100 +CREATE TABLE bububu(a int) +-- +TABLE: name="bububu" schema="" table="bububu" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bububu (a int)" +== 030 +-- truncate_limit: 100 +-- subject command should not have executed +TABLE bububu +-- +TABLE: name="bububu" schema="" table="bububu" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bububu" +== 031 +-- truncate_limit: 100 +-- fail + +-- query buffer should remain unchanged +SELECT 1 AS x, 'Hello', 2 AS y, true AS "dirty\name" + +-- all on one line +SELECT 3 AS x, 'Hello', 4 AS y, true AS "dirty\name" +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 123 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 032 +-- truncate_limit: 100 +-- test for server bug #17983 with empty statement in aborted transaction +set search_path = default +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO DEFAULT" +== 033 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 034 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 035 +-- truncate_limit: 100 +-- ; + +create temporary table gexec_test(a int, b text, c date, d float) +-- +TABLE: name="gexec_test" schema="" table="gexec_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE gexec_test (a int, b text, c date, d double precision)" +== 036 +-- truncate_limit: 100 +select format('create index on gexec_test(%I)', attname) +from pg_attribute +where attrelid = 'gexec_test'::regclass and attnum > 0 +order by attnum + +-- ; +-- (though the fetch limit applies to the executed queries not the meta query) + +select 'select 1 as ones', 'select x.y, x.y*2 as double from generate_series(1,4) as x(y)' +union all +select 'drop table gexec_test', NULL +union all +select 'drop table gexec_test', 'select ''2000-01-01''::date as party_over' + + +-- \setenv, \getenv + +-- ensure MYVAR isn't set +-- in which case, reading it doesn't change the target +-- now set it + +-- show all pset options + +-- test multi-line headers, wrapping, and newline indicators +-- in aligned, unaligned, and wrapped formats +prepare q as select array_to_string(array_agg(repeat('x',2*n)),E'\n') as "ab + +c", array_to_string(array_agg(repeat('y',20-2*n)),E'\n') as "a +bc" from generate_series(1,10) as n(n) group by n>1 order by n>1 +-- +ERROR: syntax error at or near "select" +CURSORPOS: 233 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 037 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 038 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 039 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 040 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 041 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 042 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 043 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 044 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 045 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 046 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 047 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 048 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 049 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 050 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 051 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 052 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 053 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 054 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 055 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 056 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 057 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 058 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 059 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 060 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 061 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 062 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 063 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 064 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 065 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 066 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 067 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 068 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 069 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 070 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 071 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 072 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 073 +-- truncate_limit: 100 +deallocate q +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q" +== 074 +-- truncate_limit: 100 +-- test single-line header and data +prepare q as select repeat('x',2*n) as "0123456789abcdef", repeat('y',20-2*n) as "0123456789" from generate_series(1,10) as n +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q AS SELECT repeat('x', 2 * n) AS \"0123456789abcdef\", repeat('y', 20 - (2 * n)) AS \"01234..." +== 075 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 076 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 077 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 078 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 079 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 080 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 081 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 082 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 083 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 084 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 085 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 086 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 087 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 088 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 089 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 090 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 091 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 092 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 093 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 094 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 095 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 096 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 097 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 098 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 099 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 100 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 101 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 102 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 103 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 104 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 105 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 106 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 107 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 108 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 109 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 110 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 111 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 112 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 113 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 114 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 115 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 116 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 117 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 118 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 119 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 120 +-- truncate_limit: 100 +deallocate q +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q" +== 121 +-- truncate_limit: 100 +-- support table for output-format tests (useful to create a footer) + +create table psql_serial_tab (id serial) +-- +TABLE: name="psql_serial_tab" schema="" table="psql_serial_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE psql_serial_tab (id serial)" +== 122 +-- truncate_limit: 100 +-- test header/footer/tuples_only behavior in aligned/unaligned/wrapped cases + + +-- empty table is a special case for this format +select 1 where false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 WHERE false" +== 123 +-- truncate_limit: 100 +-- check conditional am display + +CREATE SCHEMA tableam_display +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA tableam_display" +== 124 +-- truncate_limit: 100 +CREATE ROLE regress_display_role +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_display_role" +== 125 +-- truncate_limit: 100 +ALTER SCHEMA tableam_display OWNER TO regress_display_role +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SCHEMA tableam_display OWNER TO regress_display_role" +== 126 +-- truncate_limit: 100 +SET search_path TO tableam_display +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO tableam_display" +== 127 +-- truncate_limit: 100 +CREATE ACCESS METHOD heap_psql TYPE TABLE HANDLER heap_tableam_handler +-- +STMT: CreateAmStmt +TRUNCATED: "CREATE ACCESS METHOD heap_psql TYPE TABLE HANDLER heap_tableam_handler" +== 128 +-- truncate_limit: 100 +SET ROLE TO regress_display_role +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_display_role" +== 129 +-- truncate_limit: 100 +-- Use only relations with a physical size of zero. +CREATE TABLE tbl_heap_psql(f1 int, f2 char(100)) using heap_psql +-- +TABLE: name="tbl_heap_psql" schema="" table="tbl_heap_psql" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_heap_psql (f1 int, f2 char(100)) USING heap_psql" +== 130 +-- truncate_limit: 100 +CREATE TABLE tbl_heap(f1 int, f2 char(100)) using heap +-- +TABLE: name="tbl_heap" schema="" table="tbl_heap" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbl_heap (f1 int, f2 char(100)) USING heap" +== 131 +-- truncate_limit: 100 +CREATE VIEW view_heap_psql AS SELECT f1 from tbl_heap_psql +-- +TABLE: name="view_heap_psql" schema="" table="view_heap_psql" ctx=DDL +TABLE: name="tbl_heap_psql" schema="" table="tbl_heap_psql" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view_heap_psql AS SELECT f1 FROM tbl_heap_psql" +== 132 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW mat_view_heap_psql USING heap_psql AS SELECT f1 from tbl_heap_psql +-- +TABLE: name="mat_view_heap_psql" schema="" table="mat_view_heap_psql" ctx=DDL +TABLE: name="tbl_heap_psql" schema="" table="tbl_heap_psql" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW mat_view_heap_psql USING heap_psql AS SELECT f1 FROM tbl_heap_psql" +== 133 +-- truncate_limit: 100 +-- AM is displayed for tables, indexes and materialized views. +-- But not for views and sequences. +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 134 +-- truncate_limit: 100 +RESET search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 135 +-- truncate_limit: 100 +DROP SCHEMA tableam_display CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA tableam_display CASCADE" +== 136 +-- truncate_limit: 100 +DROP ACCESS METHOD heap_psql +-- +STMT: DropStmt +TRUNCATED: "DROP ACCESS METHOD heap_psql" +== 137 +-- truncate_limit: 100 +DROP ROLE regress_display_role +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_display_role" +== 138 +-- truncate_limit: 100 +-- test numericlocale (as best we can without control of psql's locale) + + +select n, -n as m, n * 111 as x, '1e90'::float8 as f +from generate_series(0,3) n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT n, - n AS m, n * 111 AS x, '1e90'::float8 AS f FROM generate_series(0, 3) n" +== 139 +-- truncate_limit: 100 +-- test asciidoc output format + + + +prepare q as + select 'some|text' as "a|title", ' ' as "empty ", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q AS SELECT 'some|text' AS \"a|title\", ' ' AS \"empty \", n AS \"int\" FROM generate_se..." +== 140 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 141 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 142 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 143 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 144 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 145 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 146 +-- truncate_limit: 100 +deallocate q +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q" +== 147 +-- truncate_limit: 100 +-- test csv output format + + + +prepare q as + select 'some"text' as "a""title", E' \n' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q AS SELECT 'some\"text' AS \"a\"\"title\", ' \n' AS junk, ' ' AS empty, n AS \"int..." +== 148 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 149 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 150 +-- truncate_limit: 100 +deallocate q +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q" +== 151 +-- truncate_limit: 100 +-- special cases +select 'comma,comma' as comma, 'semi;semi' as semi +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'comma,comma' AS comma, 'semi;semi' AS semi" +== 152 +-- truncate_limit: 100 +select 'comma,comma' as comma, 'semi;semi' as semi +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'comma,comma' AS comma, 'semi;semi' AS semi" +== 153 +-- truncate_limit: 100 +select '\.' as data +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\\\\.' AS data" +== 154 +-- truncate_limit: 100 +select '\' as d1, '' as d2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\\\\' AS d1, '' AS d2" +== 155 +-- truncate_limit: 100 +-- illegal csv separators + + +-- test html output format + + + +prepare q as + select 'some"text' as "a&title", E' \n' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q AS SELECT 'some\"text' AS \"a&title\", ' \n' AS junk, ' ' AS empty, n AS \"int\"..." +== 156 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 157 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 158 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 159 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 160 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 161 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 162 +-- truncate_limit: 100 +deallocate q +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q" +== 163 +-- truncate_limit: 100 +-- test latex output format + + + +prepare q as + select 'some\more_text' as "a$title", E' #%&^~|\n{bar}' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q AS SELECT E'some\\\\more_text' AS \"a$title\", ' #%&^~|\n{bar}' AS junk, ' ' AS empt..." +== 164 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 165 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 166 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 167 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 168 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 169 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 170 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 171 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 172 +-- truncate_limit: 100 +deallocate q +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q" +== 173 +-- truncate_limit: 100 +-- test latex-longtable output format + + + +prepare q as + select 'some\more_text' as "a$title", E' #%&^~|\n{bar}' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q AS SELECT E'some\\\\more_text' AS \"a$title\", ' #%&^~|\n{bar}' AS junk, ' ' AS empt..." +== 174 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 175 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 176 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 177 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 178 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 179 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 180 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 181 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 182 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 183 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 184 +-- truncate_limit: 100 +deallocate q +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q" +== 185 +-- truncate_limit: 100 +-- test troff-ms output format + + + +prepare q as + select 'some\text' as "a\title", E' \n' as "junk", + ' ' as "empty", n as int + from generate_series(1,2) as n +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE q AS SELECT E'some\\\\text' AS \"a\\title\", ' \n' AS junk, ' ' AS empty, n AS \"in..." +== 186 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 187 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 188 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 189 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 190 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 191 +-- truncate_limit: 100 +execute q +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE q" +== 192 +-- truncate_limit: 100 +deallocate q +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE q" +== 193 +-- truncate_limit: 100 +-- check ambiguous format requests + + +-- clean up after output format tests + +drop table psql_serial_tab +-- +TABLE: name="psql_serial_tab" schema="" table="psql_serial_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE psql_serial_tab" +== 194 +-- truncate_limit: 100 +-- \echo and allied features + + + + + +-- tests for \if ... \endif + + select 'okay' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'okay'" +== 195 +-- truncate_limit: 100 +select 'still okay' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'still okay'" +== 196 +-- truncate_limit: 100 +not okay +-- +ERROR: syntax error at or near "not" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary_truncate/postgres_regress/psql_crosstab.metadata.json b/parser/testdata/summary_truncate/postgres_regress/psql_crosstab.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/psql_crosstab.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/psql_crosstab.test b/parser/testdata/summary_truncate/postgres_regress/psql_crosstab.test new file mode 100644 index 0000000..f50a4c0 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/psql_crosstab.test @@ -0,0 +1,158 @@ +== 001 +-- truncate_limit: 100 +|-- +-- \crosstabview +|-- + +CREATE TABLE ctv_data (v, h, c, i, d) AS +VALUES + ('v1','h2','foo', 3, '2015-04-01'::date), + ('v2','h1','bar', 3, '2015-01-02'), + ('v1','h0','baz', NULL, '2015-07-12'), + ('v0','h4','qux', 4, '2015-07-15'), + ('v0','h4','dbl', -3, '2014-12-15'), + ('v0',NULL,'qux', 5, '2014-07-15'), + ('v1','h2','quux',7, '2015-04-04') +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctv_data(v, h, c, i, d) AS VALUES ('v1', 'h2', 'foo', 3, '2015-04-01'::date), ('v2',..." +== 002 +-- truncate_limit: 100 +-- make plans more stable +ANALYZE ctv_data +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ctv_data" +== 003 +-- truncate_limit: 100 +-- running \crosstabview after query uses query in buffer +SELECT v, EXTRACT(year FROM d), count(*) + FROM ctv_data + GROUP BY 1, 2 + ORDER BY 1, 2 +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=Select +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT v, extract ('year' FROM d), count(*) FROM ctv_data GROUP BY 1, 2 ORDER BY 1, 2" +== 004 +-- truncate_limit: 100 +-- basic usage with 3 columns + +-- ordered months in horizontal header, quoted column name +SELECT v, to_char(d, 'Mon') AS "month name", EXTRACT(month FROM d) AS num, + count(*) FROM ctv_data GROUP BY 1,2,3 ORDER BY 1 + +-- ordered months in vertical header, ordered years in horizontal header +SELECT EXTRACT(year FROM d) AS year, to_char(d,'Mon') AS """month"" name", + EXTRACT(month FROM d) AS month, + format('sum=%s avg=%s', sum(i), avg(i)::numeric(2,1)) + FROM ctv_data + GROUP BY EXTRACT(year FROM d), to_char(d,'Mon'), EXTRACT(month FROM d) +ORDER BY month + +-- combine contents vertically into the same cell (V/H duplicates) +SELECT v, h, string_agg(c, E'\n') FROM ctv_data GROUP BY v, h ORDER BY 1,2,3 + +-- horizontal ASC order from window function +SELECT v,h, string_agg(c, E'\n') AS c, row_number() OVER(ORDER BY h) AS r +FROM ctv_data GROUP BY v, h ORDER BY 1,3,2 + +-- horizontal DESC order from window function +SELECT v, h, string_agg(c, E'\n') AS c, row_number() OVER(ORDER BY h DESC) AS r +FROM ctv_data GROUP BY v, h ORDER BY 1,3,2 + +-- horizontal ASC order from window function, NULLs pushed rightmost +SELECT v,h, string_agg(c, E'\n') AS c, row_number() OVER(ORDER BY h NULLS LAST) AS r +FROM ctv_data GROUP BY v, h ORDER BY 1,3,2 + +-- only null, no column name, 2 columns: error +SELECT null,null \crosstabview + +-- only null, no column name, 3 columns: works +SELECT null,null,null \crosstabview + +-- null display +SELECT v,h, string_agg(i::text, E'\n') AS i FROM ctv_data +GROUP BY v, h ORDER BY h,v + +-- refer to columns by position +SELECT v,h,string_agg(i::text, E'\n'), string_agg(c, E'\n') +FROM ctv_data GROUP BY v, h ORDER BY h,v + +-- refer to columns by positions and names mixed +SELECT v,h, string_agg(i::text, E'\n') AS i, string_agg(c, E'\n') AS c +FROM ctv_data GROUP BY v, h ORDER BY h,v + +-- refer to columns by quoted names, check downcasing of unquoted name +SELECT 1 as "22", 2 as b, 3 as "Foo" + +-- error: bad column name +SELECT v,h,c,i FROM ctv_data + +-- error: need to quote name +SELECT 1 as "22", 2 as b, 3 as "Foo" + +-- error: need to not quote name +SELECT 1 as "22", 2 as b, 3 as "Foo" + +-- error: bad column number +SELECT v,h,i,c FROM ctv_data + +-- error: same H and V columns +SELECT v,h,i,c FROM ctv_data + +-- error: too many columns +SELECT a,a,1 FROM generate_series(1,3000) AS a + +-- error: only one column +SELECT 1 \crosstabview + +DROP TABLE ctv_data +-- +ERROR: syntax error at or near "SELECT" +CURSORPOS: 291 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- truncate_limit: 100 +-- check error reporting (bug #14476) +CREATE TABLE ctv_data (x int, y int, v text) +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctv_data (x int, y int, v text)" +== 006 +-- truncate_limit: 100 +INSERT INTO ctv_data SELECT 1, x, '*' || x FROM generate_series(1,10) x +-- +TABLE: name="ctv_data" schema="" table="ctv_data" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ctv_data SELECT 1, x, '*' || x FROM generate_series(1, 10) x" +== 007 +-- truncate_limit: 100 +SELECT * FROM ctv_data \crosstabview + +INSERT INTO ctv_data VALUES (1, 10, '*') +-- +ERROR: syntax error at or near "\" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +-- truncate_limit: 100 +-- duplicate data to cause error +SELECT * FROM ctv_data \crosstabview + +DROP TABLE ctv_data +-- +ERROR: syntax error at or near "\" +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary_truncate/postgres_regress/publication.metadata.json b/parser/testdata/summary_truncate/postgres_regress/publication.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/publication.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/publication.test b/parser/testdata/summary_truncate/postgres_regress/publication.test new file mode 100644 index 0000000..0172704 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/publication.test @@ -0,0 +1,4537 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PUBLICATION +|-- +CREATE ROLE regress_publication_user LOGIN SUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_publication_user WITH LOGIN SUPERUSER" +== 002 +-- truncate_limit: 100 +CREATE ROLE regress_publication_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_publication_user2" +== 003 +-- truncate_limit: 100 +CREATE ROLE regress_publication_user_dummy LOGIN NOSUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_publication_user_dummy WITH LOGIN NOSUPERUSER" +== 004 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION 'regress_publication_user' +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_publication_user" +== 005 +-- truncate_limit: 100 +-- suppress warning that depends on wal_level +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 006 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_default +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_default" +== 007 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 008 +-- truncate_limit: 100 +COMMENT ON PUBLICATION testpub_default IS 'test publication' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON PUBLICATION testpub_default IS 'test publication'" +== 009 +-- truncate_limit: 100 +SELECT obj_description(p.oid, 'pg_publication') FROM pg_publication p +-- +TABLE: name="pg_publication" schema="" table="pg_publication" ctx=Select +ALIAS: "p"="pg_publication" +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT obj_description(p.oid, 'pg_publication') FROM pg_publication p" +== 010 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 011 +-- truncate_limit: 100 +CREATE PUBLICATION testpib_ins_trunct WITH (publish = insert) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpib_ins_trunct WITH (publish = insert)" +== 012 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 013 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default SET (publish = update) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default SET (publish = update)" +== 014 +-- truncate_limit: 100 +-- error cases +CREATE PUBLICATION testpub_xxx WITH (foo) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_xxx WITH (foo)" +== 015 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_xxx WITH (publish = 'cluster, vacuum')" +== 016 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_xxx WITH (publish_via_partition_root = 'true', publish_via_partition_root = '0') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_xxx WITH (publish_via_partition_root = true, publish_via_partition_roo..." +== 017 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete') +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default SET (publish = 'insert, update, delete')" +== 018 +-- truncate_limit: 100 +--- adding tables +CREATE SCHEMA pub_test +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA pub_test" +== 019 +-- truncate_limit: 100 +CREATE TABLE testpub_tbl1 (id serial primary key, data text) +-- +TABLE: name="testpub_tbl1" schema="" table="testpub_tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl1 (id serial PRIMARY KEY, data text)" +== 020 +-- truncate_limit: 100 +CREATE TABLE pub_test.testpub_nopk (foo int, bar int) +-- +TABLE: name="pub_test.testpub_nopk" schema="pub_test" table="testpub_nopk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_test.testpub_nopk (foo int, bar int)" +== 021 +-- truncate_limit: 100 +CREATE VIEW testpub_view AS SELECT 1 +-- +TABLE: name="testpub_view" schema="" table="testpub_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW testpub_view AS SELECT 1" +== 022 +-- truncate_limit: 100 +CREATE TABLE testpub_parted (a int) PARTITION BY LIST (a) +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_parted (a int) PARTITION BY LIST (a)" +== 023 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 024 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_foralltables FOR ALL TABLES WITH (publish = 'insert')" +== 025 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 026 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_foralltables SET (publish = 'insert, update') +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_foralltables SET (publish = 'insert, update')" +== 027 +-- truncate_limit: 100 +CREATE TABLE testpub_tbl2 (id serial primary key, data text) +-- +TABLE: name="testpub_tbl2" schema="" table="testpub_tbl2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl2 (id serial PRIMARY KEY, data text)" +== 028 +-- truncate_limit: 100 +-- fail - can't add to for all tables publication +ALTER PUBLICATION testpub_foralltables ADD TABLE testpub_tbl2 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_foralltables ADD TABLE testpub_tbl2" +== 029 +-- truncate_limit: 100 +-- fail - can't drop from all tables publication +ALTER PUBLICATION testpub_foralltables DROP TABLE testpub_tbl2 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_foralltables DROP TABLE testpub_tbl2" +== 030 +-- truncate_limit: 100 +-- fail - can't add to for all tables publication +ALTER PUBLICATION testpub_foralltables SET TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_foralltables SET TABLE pub_test.testpub_nopk" +== 031 +-- truncate_limit: 100 +-- fail - can't add schema to 'FOR ALL TABLES' publication +ALTER PUBLICATION testpub_foralltables ADD TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_foralltables ADD TABLES IN SCHEMA pub_test" +== 032 +-- truncate_limit: 100 +-- fail - can't drop schema from 'FOR ALL TABLES' publication +ALTER PUBLICATION testpub_foralltables DROP TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_foralltables DROP TABLES IN SCHEMA pub_test" +== 033 +-- truncate_limit: 100 +-- fail - can't set schema to 'FOR ALL TABLES' publication +ALTER PUBLICATION testpub_foralltables SET TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_foralltables SET TABLES IN SCHEMA pub_test" +== 034 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 035 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_fortable FOR TABLE testpub_tbl1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortable FOR TABLE testpub_tbl1" +== 036 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 037 +-- truncate_limit: 100 +-- should be able to add schema to 'FOR TABLE' publication +ALTER PUBLICATION testpub_fortable ADD TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLES IN SCHEMA pub_test" +== 038 +-- truncate_limit: 100 +-- should be able to drop schema from 'FOR TABLE' publication +ALTER PUBLICATION testpub_fortable DROP TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable DROP TABLES IN SCHEMA pub_test" +== 039 +-- truncate_limit: 100 +-- should be able to set schema to 'FOR TABLE' publication +ALTER PUBLICATION testpub_fortable SET TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable SET TABLES IN SCHEMA pub_test" +== 040 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 041 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pub_test +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pub_test" +== 042 +-- truncate_limit: 100 +-- should be able to create publication with schema and table of the same +-- schema +CREATE PUBLICATION testpub_for_tbl_schema FOR TABLES IN SCHEMA pub_test, TABLE pub_test.testpub_nopk +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_for_tbl_schema FOR TABLES IN SCHEMA pub_test, TABLE pub_test.testpub_nopk" +== 043 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 044 +-- truncate_limit: 100 +-- weird parser corner case +CREATE PUBLICATION testpub_parsertst FOR TABLE pub_test.testpub_nopk, CURRENT_SCHEMA +-- +ERROR: invalid table name +CURSORPOS: 99 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 045 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_parsertst FOR TABLES IN SCHEMA foo, test.foo +-- +ERROR: invalid schema name +CURSORPOS: 64 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 046 +-- truncate_limit: 100 +-- should be able to add a table of the same schema to the schema publication +ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk" +== 047 +-- truncate_limit: 100 +-- should be able to drop the table +ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk" +== 048 +-- truncate_limit: 100 +-- fail - can't drop a table from the schema publication which isn't in the +-- publication +ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_forschema DROP TABLE pub_test.testpub_nopk" +== 049 +-- truncate_limit: 100 +-- should be able to set table to schema publication +ALTER PUBLICATION testpub_forschema SET TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_forschema SET TABLE pub_test.testpub_nopk" +== 050 +-- truncate_limit: 100 +SELECT pubname, puballtables FROM pg_publication WHERE pubname = 'testpub_foralltables' +-- +TABLE: name="pg_publication" schema="" table="pg_publication" ctx=Select +FILTER: schema="" table="" column="pubname" +STMT: SelectStmt +TRUNCATED: "SELECT pubname, puballtables FROM pg_publication WHERE pubname = 'testpub_foralltables'" +== 051 +-- truncate_limit: 100 +DROP TABLE testpub_tbl2 +-- +TABLE: name="testpub_tbl2" schema="" table="testpub_tbl2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_tbl2" +== 052 +-- truncate_limit: 100 +DROP PUBLICATION testpub_foralltables, testpub_fortable, testpub_forschema, testpub_for_tbl_schema +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_foralltables, testpub_fortable, testpub_forschema, testpub_for_tbl_schema" +== 053 +-- truncate_limit: 100 +CREATE TABLE testpub_tbl3 (a int) +-- +TABLE: name="testpub_tbl3" schema="" table="testpub_tbl3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl3 (a int)" +== 054 +-- truncate_limit: 100 +CREATE TABLE testpub_tbl3a (b text) INHERITS (testpub_tbl3) +-- +TABLE: name="testpub_tbl3a" schema="" table="testpub_tbl3a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl3a (b text) INHERITS (testpub_tbl3)" +== 055 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 056 +-- truncate_limit: 100 +CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3" +== 057 +-- truncate_limit: 100 +CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3" +== 058 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 059 +-- truncate_limit: 100 +DROP TABLE testpub_tbl3, testpub_tbl3a +-- +TABLE: name="testpub_tbl3" schema="" table="testpub_tbl3" ctx=DDL +TABLE: name="testpub_tbl3a" schema="" table="testpub_tbl3a" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_tbl3, testpub_tbl3a" +== 060 +-- truncate_limit: 100 +DROP PUBLICATION testpub3, testpub4 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub3, testpub4" +== 061 +-- truncate_limit: 100 +-- Tests for partitioned tables +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 062 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_forparted +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forparted" +== 063 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_forparted1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forparted1" +== 064 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 065 +-- truncate_limit: 100 +CREATE TABLE testpub_parted1 (LIKE testpub_parted) +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_parted1 (LIKE testpub_parted)" +== 066 +-- truncate_limit: 100 +CREATE TABLE testpub_parted2 (LIKE testpub_parted) +-- +TABLE: name="testpub_parted2" schema="" table="testpub_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_parted2 (LIKE testpub_parted)" +== 067 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_forparted1 SET (publish='insert') +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_forparted1 SET (publish = 'insert')" +== 068 +-- truncate_limit: 100 +ALTER TABLE testpub_parted ATTACH PARTITION testpub_parted1 FOR VALUES IN (1) +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_parted ATTACH PARTITION testpub_parted1 FOR VALUES IN (1)" +== 069 +-- truncate_limit: 100 +ALTER TABLE testpub_parted ATTACH PARTITION testpub_parted2 FOR VALUES IN (2) +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_parted ATTACH PARTITION testpub_parted2 FOR VALUES IN (2)" +== 070 +-- truncate_limit: 100 +-- works despite missing REPLICA IDENTITY, because updates are not replicated +UPDATE testpub_parted1 SET a = 1 +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_parted1 SET a = 1" +== 071 +-- truncate_limit: 100 +-- only parent is listed as being in publication, not the partition +ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_forparted ADD TABLE testpub_parted" +== 072 +-- truncate_limit: 100 +-- works despite missing REPLICA IDENTITY, because no actual update happened +UPDATE testpub_parted SET a = 1 WHERE false +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_parted SET a = 1 WHERE false" +== 073 +-- truncate_limit: 100 +-- should now fail, because parent's publication replicates updates +UPDATE testpub_parted1 SET a = 1 +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_parted1 SET a = 1" +== 074 +-- truncate_limit: 100 +ALTER TABLE testpub_parted DETACH PARTITION testpub_parted1 +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_parted DETACH PARTITION testpub_parted1" +== 075 +-- truncate_limit: 100 +-- works again, because parent's publication is no longer considered +UPDATE testpub_parted1 SET a = 1 +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_parted1 SET a = 1" +== 076 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_forparted SET (publish_via_partition_root = true) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_forparted SET (publish_via_partition_root = true)" +== 077 +-- truncate_limit: 100 +-- still fail, because parent's publication replicates updates +UPDATE testpub_parted2 SET a = 2 +-- +TABLE: name="testpub_parted2" schema="" table="testpub_parted2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_parted2 SET a = 2" +== 078 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_forparted DROP TABLE testpub_parted +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_forparted DROP TABLE testpub_parted" +== 079 +-- truncate_limit: 100 +-- works again, because update is no longer replicated +UPDATE testpub_parted2 SET a = 2 +-- +TABLE: name="testpub_parted2" schema="" table="testpub_parted2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_parted2 SET a = 2" +== 080 +-- truncate_limit: 100 +DROP TABLE testpub_parted1, testpub_parted2 +-- +TABLE: name="testpub_parted1" schema="" table="testpub_parted1" ctx=DDL +TABLE: name="testpub_parted2" schema="" table="testpub_parted2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_parted1, testpub_parted2" +== 081 +-- truncate_limit: 100 +DROP PUBLICATION testpub_forparted, testpub_forparted1 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_forparted, testpub_forparted1" +== 082 +-- truncate_limit: 100 +-- Tests for row filters +CREATE TABLE testpub_rf_tbl1 (a integer, b text) +-- +TABLE: name="testpub_rf_tbl1" schema="" table="testpub_rf_tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_rf_tbl1 (a int, b text)" +== 083 +-- truncate_limit: 100 +CREATE TABLE testpub_rf_tbl2 (c text, d integer) +-- +TABLE: name="testpub_rf_tbl2" schema="" table="testpub_rf_tbl2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_rf_tbl2 (c text, d int)" +== 084 +-- truncate_limit: 100 +CREATE TABLE testpub_rf_tbl3 (e integer) +-- +TABLE: name="testpub_rf_tbl3" schema="" table="testpub_rf_tbl3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_rf_tbl3 (e int)" +== 085 +-- truncate_limit: 100 +CREATE TABLE testpub_rf_tbl4 (g text) +-- +TABLE: name="testpub_rf_tbl4" schema="" table="testpub_rf_tbl4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_rf_tbl4 (g text)" +== 086 +-- truncate_limit: 100 +CREATE TABLE testpub_rf_tbl5 (a xml) +-- +TABLE: name="testpub_rf_tbl5" schema="" table="testpub_rf_tbl5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_rf_tbl5 (a xml)" +== 087 +-- truncate_limit: 100 +CREATE SCHEMA testpub_rf_schema1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA testpub_rf_schema1" +== 088 +-- truncate_limit: 100 +CREATE TABLE testpub_rf_schema1.testpub_rf_tbl5 (h integer) +-- +TABLE: name="testpub_rf_schema1.testpub_rf_tbl5" schema="testpub_rf_schema1" table="testpub_rf_tbl5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_rf_schema1.testpub_rf_tbl5 (h int)" +== 089 +-- truncate_limit: 100 +CREATE SCHEMA testpub_rf_schema2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA testpub_rf_schema2" +== 090 +-- truncate_limit: 100 +CREATE TABLE testpub_rf_schema2.testpub_rf_tbl6 (i integer) +-- +TABLE: name="testpub_rf_schema2.testpub_rf_tbl6" schema="testpub_rf_schema2" table="testpub_rf_tbl6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_rf_schema2.testpub_rf_tbl6 (i int)" +== 091 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 092 +-- truncate_limit: 100 +-- Firstly, test using the option publish='insert' because the row filter +-- validation of referenced columns is less strict than for delete/update. +CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, TABLE testpub_rf_tbl2 WHERE (c <> 'test' A..." +== 093 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 094 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000)" +== 095 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2" +== 096 +-- truncate_limit: 100 +-- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression) +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500)" +== 097 +-- truncate_limit: 100 +-- test \d (now it displays filter information) +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 098 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert')" +== 099 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_rf_no FOR TABLE testpub_rf_tbl1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_rf_no FOR TABLE testpub_rf_tbl1" +== 100 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 101 +-- truncate_limit: 100 +DROP PUBLICATION testpub_rf_yes, testpub_rf_no +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_rf_yes, testpub_rf_no" +== 102 +-- truncate_limit: 100 +-- some more syntax tests to exercise other parser pathways +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 103 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_syntax1 FOR TABLE testpub_rf_tbl1, ONLY testpub_rf_tbl3 WHERE (e < 999) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_syntax1 FOR TABLE testpub_rf_tbl1, TABLE ONLY testpub_rf_tbl3 WHERE (e..." +== 104 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 105 +-- truncate_limit: 100 +DROP PUBLICATION testpub_syntax1 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_syntax1" +== 106 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 107 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_syntax2 FOR TABLE testpub_rf_tbl1, testpub_rf_schema1.testpub_rf_tbl5 WHERE (h < 999) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_syntax2 FOR TABLE testpub_rf_tbl1, TABLE testpub_rf_schema1.testpub_rf..." +== 108 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 109 +-- truncate_limit: 100 +DROP PUBLICATION testpub_syntax2 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_syntax2" +== 110 +-- truncate_limit: 100 +-- fail - schemas don't allow WHERE clause +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 111 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_syntax3 FOR TABLES IN SCHEMA testpub_rf_schema1 WHERE (a = 123) +-- +ERROR: syntax error at or near "WHERE" +CURSORPOS: 76 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 112 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_syntax3 FOR TABLES IN SCHEMA testpub_rf_schema1, testpub_rf_schema1 WHERE (a = 123) +-- +ERROR: WHERE clause not allowed for schema +CURSORPOS: 77 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 113 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 114 +-- truncate_limit: 100 +-- fail - duplicate tables are not allowed if that table has any WHERE clause +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 115 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_dups FOR TABLE testpub_rf_tbl1 WHERE (a = 1), testpub_rf_tbl1 WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_dups FOR TABLE testpub_rf_tbl1 WHERE (a = 1), TABLE testpub_rf_tbl1 WI..." +== 116 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_dups FOR TABLE testpub_rf_tbl1, testpub_rf_tbl1 WHERE (a = 2) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_dups FOR TABLE testpub_rf_tbl1, TABLE testpub_rf_tbl1 WHERE (a = 2) WI..." +== 117 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 118 +-- truncate_limit: 100 +-- fail - publication WHERE clause must be boolean +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (1234) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (1234)" +== 119 +-- truncate_limit: 100 +-- fail - aggregate functions not allowed in WHERE clause +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e < AVG(e)) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e < avg(e))" +== 120 +-- truncate_limit: 100 +-- fail - user-defined operators are not allowed +CREATE FUNCTION testpub_rf_func1(integer, integer) RETURNS boolean AS $$ SELECT hashint4($1) > $2 $$ LANGUAGE SQL +-- +FUNCTION: name="testpub_rf_func1" function="testpub_rf_func1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testpub_rf_func1(int, int) RETURNS boolean AS $$ SELECT hashint4($1) > $2 $$ LANG..." +== 121 +-- truncate_limit: 100 +CREATE OPERATOR =#> (PROCEDURE = testpub_rf_func1, LEFTARG = integer, RIGHTARG = integer) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR =#> (procedure = testpub_rf_func1, leftarg = int, rightarg = int)" +== 122 +-- truncate_limit: 100 +CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl3 WHERE (e =#> 27) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl3 WHERE (e =#> 27)" +== 123 +-- truncate_limit: 100 +-- fail - user-defined functions are not allowed +CREATE FUNCTION testpub_rf_func2() RETURNS integer AS $$ BEGIN RETURN 123; END; $$ LANGUAGE plpgsql +-- +FUNCTION: name="testpub_rf_func2" function="testpub_rf_func2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testpub_rf_func2() RETURNS int AS $$ BEGIN RETURN 123; END; $$ LANGUAGE plpgsql" +== 124 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (a >= testpub_rf_func2()) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (a >= testpub_rf_func2())" +== 125 +-- truncate_limit: 100 +-- fail - non-immutable functions are not allowed. random() is volatile. +ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (a < random()) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (a < random())" +== 126 +-- truncate_limit: 100 +-- fail - user-defined collations are not allowed +CREATE COLLATION user_collation FROM "C" +-- +STMT: DefineStmt +TRUNCATED: "CREATE COLLATION user_collation FROM \"C\"" +== 127 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (b < '2' COLLATE user_collation) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl1 WHERE (b < '2' COLLATE user_collation)" +== 128 +-- truncate_limit: 100 +-- ok - NULLIF is allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (NULLIF(1,2) = a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE ((NULLIF(1, 2)) = a)" +== 129 +-- truncate_limit: 100 +-- ok - built-in operators are allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IS NULL) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IS NULL)" +== 130 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE ((a > 5) IS FALSE) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a > 5 IS FALSE)" +== 131 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IS DISTINCT FROM 5) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IS DISTINCT FROM 5)" +== 132 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE ((a, a + 1) < (2, 3)) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE ((a, a + 1) < (2, 3))" +== 133 +-- truncate_limit: 100 +-- ok - built-in type coercions between two binary compatible datatypes are allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (b::varchar < '2') +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (b::varchar < '2')" +== 134 +-- truncate_limit: 100 +-- ok - immutable built-in functions are allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl4 WHERE (length(g) < 6) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl4 WHERE (length(g) < 6)" +== 135 +-- truncate_limit: 100 +-- fail - user-defined types are not allowed +CREATE TYPE rf_bug_status AS ENUM ('new', 'open', 'closed') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE rf_bug_status AS ENUM ('new', 'open', 'closed')" +== 136 +-- truncate_limit: 100 +CREATE TABLE rf_bug (id serial, description text, status rf_bug_status) +-- +TABLE: name="rf_bug" schema="" table="rf_bug" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_bug (id serial, description text, status rf_bug_status)" +== 137 +-- truncate_limit: 100 +CREATE PUBLICATION testpub6 FOR TABLE rf_bug WHERE (status = 'open') WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub6 FOR TABLE rf_bug WHERE (status = 'open') WITH (publish = 'insert')" +== 138 +-- truncate_limit: 100 +DROP TABLE rf_bug +-- +TABLE: name="rf_bug" schema="" table="rf_bug" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rf_bug" +== 139 +-- truncate_limit: 100 +DROP TYPE rf_bug_status +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE rf_bug_status" +== 140 +-- truncate_limit: 100 +-- fail - row filter expression is not simple +CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl1 WHERE (a IN (SELECT generate_series(1,5))) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl1 WHERE (a IN (SELECT generate_series(1, 5)))" +== 141 +-- truncate_limit: 100 +-- fail - system columns are not allowed +CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl1 WHERE ('(0,1)'::tid = ctid) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub6 FOR TABLE testpub_rf_tbl1 WHERE ('(0,1)'::tid = ctid)" +== 142 +-- truncate_limit: 100 +-- ok - conditional expressions are allowed +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl5 WHERE (a IS DOCUMENT) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl5 WHERE (a IS DOCUMENT)" +== 143 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl5 WHERE (xmlexists('//foo[text() = ''bar'']' PASSING BY VALUE a)) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl5 WHERE (xmlexists ('//foo[text() = ''bar'']' ..." +== 144 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (NULLIF(1, 2) = a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE ((NULLIF(1, 2)) = a)" +== 145 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (CASE a WHEN 5 THEN true ELSE false END) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (CASE a WHEN 5 THEN true ELSE false END)" +== 146 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (COALESCE(b, 'foo') = 'foo') +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (COALESCE(b, 'foo') = 'foo')" +== 147 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (GREATEST(a, 10) > 10) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (GREATEST(a, 10) > 10)" +== 148 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IN (2, 4, 6)) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (a IN (2, 4, 6))" +== 149 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (ARRAY[a] <@ ARRAY[2, 4, 6]) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (ARRAY[a] <@ ARRAY[2, 4, 6])" +== 150 +-- truncate_limit: 100 +ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (ROW(a, 2) IS NULL) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl1 WHERE (ROW(a, 2) IS NULL)" +== 151 +-- truncate_limit: 100 +-- fail - WHERE not allowed in DROP +ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl1 WHERE (e < 27) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl1 WHERE (e < 27)" +== 152 +-- truncate_limit: 100 +-- fail - cannot ALTER SET table which is a member of a pre-existing schema +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 153 +-- truncate_limit: 100 +CREATE PUBLICATION testpub6 FOR TABLES IN SCHEMA testpub_rf_schema2 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub6 FOR TABLES IN SCHEMA testpub_rf_schema2" +== 154 +-- truncate_limit: 100 +-- should be able to set publication with schema and table of the same schema +ALTER PUBLICATION testpub6 SET TABLES IN SCHEMA testpub_rf_schema2, TABLE testpub_rf_schema2.testpub_rf_tbl6 WHERE (i < 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLES IN SCHEMA testpub_rf_schema2, TABLE testpub_rf_schema2.test..." +== 155 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 156 +-- truncate_limit: 100 +DROP TABLE testpub_rf_tbl1 +-- +TABLE: name="testpub_rf_tbl1" schema="" table="testpub_rf_tbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_rf_tbl1" +== 157 +-- truncate_limit: 100 +DROP TABLE testpub_rf_tbl2 +-- +TABLE: name="testpub_rf_tbl2" schema="" table="testpub_rf_tbl2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_rf_tbl2" +== 158 +-- truncate_limit: 100 +DROP TABLE testpub_rf_tbl3 +-- +TABLE: name="testpub_rf_tbl3" schema="" table="testpub_rf_tbl3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_rf_tbl3" +== 159 +-- truncate_limit: 100 +DROP TABLE testpub_rf_tbl4 +-- +TABLE: name="testpub_rf_tbl4" schema="" table="testpub_rf_tbl4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_rf_tbl4" +== 160 +-- truncate_limit: 100 +DROP TABLE testpub_rf_tbl5 +-- +TABLE: name="testpub_rf_tbl5" schema="" table="testpub_rf_tbl5" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_rf_tbl5" +== 161 +-- truncate_limit: 100 +DROP TABLE testpub_rf_schema1.testpub_rf_tbl5 +-- +TABLE: name="testpub_rf_schema1.testpub_rf_tbl5" schema="testpub_rf_schema1" table="testpub_rf_tbl5" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_rf_schema1.testpub_rf_tbl5" +== 162 +-- truncate_limit: 100 +DROP TABLE testpub_rf_schema2.testpub_rf_tbl6 +-- +TABLE: name="testpub_rf_schema2.testpub_rf_tbl6" schema="testpub_rf_schema2" table="testpub_rf_tbl6" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_rf_schema2.testpub_rf_tbl6" +== 163 +-- truncate_limit: 100 +DROP SCHEMA testpub_rf_schema1 +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA testpub_rf_schema1" +== 164 +-- truncate_limit: 100 +DROP SCHEMA testpub_rf_schema2 +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA testpub_rf_schema2" +== 165 +-- truncate_limit: 100 +DROP PUBLICATION testpub5 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub5" +== 166 +-- truncate_limit: 100 +DROP PUBLICATION testpub6 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub6" +== 167 +-- truncate_limit: 100 +DROP OPERATOR =#>(integer, integer) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR =#>(int, int)" +== 168 +-- truncate_limit: 100 +DROP FUNCTION testpub_rf_func1(integer, integer) +-- +FUNCTION: name="testpub_rf_func1" function="testpub_rf_func1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION testpub_rf_func1(int, int)" +== 169 +-- truncate_limit: 100 +DROP FUNCTION testpub_rf_func2() +-- +FUNCTION: name="testpub_rf_func2" function="testpub_rf_func2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION testpub_rf_func2()" +== 170 +-- truncate_limit: 100 +DROP COLLATION user_collation +-- +STMT: DropStmt +TRUNCATED: "DROP COLLATION user_collation" +== 171 +-- truncate_limit: 100 +-- ====================================================== +-- More row filter tests for validating column references +CREATE TABLE rf_tbl_abcd_nopk(a int, b int, c int, d int) +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_tbl_abcd_nopk (a int, b int, c int, d int)" +== 172 +-- truncate_limit: 100 +CREATE TABLE rf_tbl_abcd_pk(a int, b int, c int, d int, PRIMARY KEY(a,b)) +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_tbl_abcd_pk (a int, b int, c int, d int, PRIMARY KEY (a, b))" +== 173 +-- truncate_limit: 100 +CREATE TABLE rf_tbl_abcd_part_pk (a int PRIMARY KEY, b int) PARTITION by RANGE (a) +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_tbl_abcd_part_pk (a int PRIMARY KEY, b int) PARTITION BY RANGE (a)" +== 174 +-- truncate_limit: 100 +CREATE TABLE rf_tbl_abcd_part_pk_1 (b int, a int PRIMARY KEY) +-- +TABLE: name="rf_tbl_abcd_part_pk_1" schema="" table="rf_tbl_abcd_part_pk_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_tbl_abcd_part_pk_1 (b int, a int PRIMARY KEY)" +== 175 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_part_pk ATTACH PARTITION rf_tbl_abcd_part_pk_1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_part_pk ATTACH PARTITION rf_tbl_abcd_part_pk_1 FOR VALUES FROM (1) TO (10)" +== 176 +-- truncate_limit: 100 +-- Case 1. REPLICA IDENTITY DEFAULT (means use primary key or nothing) +-- 1a. REPLICA IDENTITY is DEFAULT and table has a PK. +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 177 +-- truncate_limit: 100 +CREATE PUBLICATION testpub6 FOR TABLE rf_tbl_abcd_pk WHERE (a > 99) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub6 FOR TABLE rf_tbl_abcd_pk WHERE (a > 99)" +== 178 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 179 +-- truncate_limit: 100 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 180 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (b > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (b > 99)" +== 181 +-- truncate_limit: 100 +-- ok - "b" is a PK col +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 182 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99)" +== 183 +-- truncate_limit: 100 +-- fail - "c" is not part of the PK +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 184 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (d > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (d > 99)" +== 185 +-- truncate_limit: 100 +-- fail - "d" is not part of the PK +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 186 +-- truncate_limit: 100 +-- 1b. REPLICA IDENTITY is DEFAULT and table has no PK +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99)" +== 187 +-- truncate_limit: 100 +-- fail - "a" is not part of REPLICA IDENTITY +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 188 +-- truncate_limit: 100 +-- Case 2. REPLICA IDENTITY FULL +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY FULL +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY FULL" +== 189 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY FULL +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY FULL" +== 190 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99)" +== 191 +-- truncate_limit: 100 +-- ok - "c" is in REPLICA IDENTITY now even though not in PK +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 192 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99)" +== 193 +-- truncate_limit: 100 +-- ok - "a" is in REPLICA IDENTITY now +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 194 +-- truncate_limit: 100 +-- Case 3. REPLICA IDENTITY NOTHING +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY NOTHING +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY NOTHING" +== 195 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY NOTHING +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY NOTHING" +== 196 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (a > 99)" +== 197 +-- truncate_limit: 100 +-- fail - "a" is in PK but it is not part of REPLICA IDENTITY NOTHING +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 198 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99)" +== 199 +-- truncate_limit: 100 +-- fail - "c" is not in PK and not in REPLICA IDENTITY NOTHING +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 200 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99)" +== 201 +-- truncate_limit: 100 +-- fail - "a" is not in REPLICA IDENTITY NOTHING +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 202 +-- truncate_limit: 100 +-- Case 4. REPLICA IDENTITY INDEX +ALTER TABLE rf_tbl_abcd_pk ALTER COLUMN c SET NOT NULL +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_pk ALTER COLUMN c SET NOT NULL" +== 203 +-- truncate_limit: 100 +CREATE UNIQUE INDEX idx_abcd_pk_c ON rf_tbl_abcd_pk(c) +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX idx_abcd_pk_c ON rf_tbl_abcd_pk USING btree (c)" +== 204 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY USING INDEX idx_abcd_pk_c +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY USING INDEX idx_abcd_pk_c" +== 205 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_nopk ALTER COLUMN c SET NOT NULL +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_nopk ALTER COLUMN c SET NOT NULL" +== 206 +-- truncate_limit: 100 +CREATE UNIQUE INDEX idx_abcd_nopk_c ON rf_tbl_abcd_nopk(c) +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX idx_abcd_nopk_c ON rf_tbl_abcd_nopk USING btree (c)" +== 207 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY USING INDEX idx_abcd_nopk_c +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY USING INDEX idx_abcd_nopk_c" +== 208 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (a > 99)" +== 209 +-- truncate_limit: 100 +-- fail - "a" is in PK but it is not part of REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 210 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99)" +== 211 +-- truncate_limit: 100 +-- ok - "c" is not in PK but it is part of REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 212 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99)" +== 213 +-- truncate_limit: 100 +-- fail - "a" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 214 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (c > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (c > 99)" +== 215 +-- truncate_limit: 100 +-- ok - "c" is part of REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 216 +-- truncate_limit: 100 +-- Tests for partitioned table + +-- set PUBLISH_VIA_PARTITION_ROOT to false and test row filter for partitioned +-- table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 0)" +== 217 +-- truncate_limit: 100 +-- fail - cannot use row filter for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (a > 99)" +== 218 +-- truncate_limit: 100 +-- ok - can use row filter for partition +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 WHERE (a > 99)" +== 219 +-- truncate_limit: 100 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_part_pk SET a = 1" +== 220 +-- truncate_limit: 100 +-- set PUBLISH_VIA_PARTITION_ROOT to true and test row filter for partitioned +-- table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 1)" +== 221 +-- truncate_limit: 100 +-- ok - can use row filter for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (a > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (a > 99)" +== 222 +-- truncate_limit: 100 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_part_pk SET a = 1" +== 223 +-- truncate_limit: 100 +-- fail - cannot set PUBLISH_VIA_PARTITION_ROOT to false if any row filter is +-- used for partitioned table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 0)" +== 224 +-- truncate_limit: 100 +-- remove partitioned table's row filter +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk" +== 225 +-- truncate_limit: 100 +-- ok - we don't have row filter for partitioned table. +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 0)" +== 226 +-- truncate_limit: 100 +-- Now change the root filter to use a column "b" +-- (which is not in the replica identity) +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 WHERE (b > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 WHERE (b > 99)" +== 227 +-- truncate_limit: 100 +-- ok - we don't have row filter for partitioned table. +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 0)" +== 228 +-- truncate_limit: 100 +-- fail - "b" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_part_pk SET a = 1" +== 229 +-- truncate_limit: 100 +-- set PUBLISH_VIA_PARTITION_ROOT to true +-- can use row filter for partitioned table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 1)" +== 230 +-- truncate_limit: 100 +-- ok - can use row filter for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (b > 99) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (b > 99)" +== 231 +-- truncate_limit: 100 +-- fail - "b" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_part_pk SET a = 1" +== 232 +-- truncate_limit: 100 +DROP PUBLICATION testpub6 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub6" +== 233 +-- truncate_limit: 100 +DROP TABLE rf_tbl_abcd_pk +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rf_tbl_abcd_pk" +== 234 +-- truncate_limit: 100 +DROP TABLE rf_tbl_abcd_nopk +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rf_tbl_abcd_nopk" +== 235 +-- truncate_limit: 100 +DROP TABLE rf_tbl_abcd_part_pk +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rf_tbl_abcd_part_pk" +== 236 +-- truncate_limit: 100 +-- ====================================================== + +-- fail - duplicate tables are not allowed if that table has any column lists +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 237 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_dups FOR TABLE testpub_tbl1 (a), testpub_tbl1 WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_dups FOR TABLE testpub_tbl1(a), TABLE testpub_tbl1 WITH (publish = 'in..." +== 238 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_dups FOR TABLE testpub_tbl1, testpub_tbl1 (a) WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_dups FOR TABLE testpub_tbl1, TABLE testpub_tbl1(a) WITH (publish = 'in..." +== 239 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 240 +-- truncate_limit: 100 +-- test for column lists +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 241 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_fortable FOR TABLE testpub_tbl1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortable FOR TABLE testpub_tbl1" +== 242 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_fortable_insert WITH (publish = 'insert') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortable_insert WITH (publish = 'insert')" +== 243 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 244 +-- truncate_limit: 100 +CREATE TABLE testpub_tbl5 (a int PRIMARY KEY, b text, c text, + d int generated always as (a + length(b)) stored) +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl5 (a int PRIMARY KEY, b text, c text, d int GENERATED ALWAYS AS (a + leng..." +== 245 +-- truncate_limit: 100 +-- error: column "x" does not exist +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, x) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5(a, x)" +== 246 +-- truncate_limit: 100 +-- error: replica identity "a" not included in the column list +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (b, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5(b, c)" +== 247 +-- truncate_limit: 100 +UPDATE testpub_tbl5 SET a = 1 +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl5 SET a = 1" +== 248 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl5 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl5" +== 249 +-- truncate_limit: 100 +-- error: generated column "d" can't be in list +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, d) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5(a, d)" +== 250 +-- truncate_limit: 100 +-- error: system attributes "ctid" not allowed in column list +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, ctid) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5(a, ctid)" +== 251 +-- truncate_limit: 100 +-- ok +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5(a, c)" +== 252 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl5 DROP COLUMN c +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl5 DROP c" +== 253 +-- truncate_limit: 100 +-- no dice +-- ok: for insert-only publication, any column list is acceptable +ALTER PUBLICATION testpub_fortable_insert ADD TABLE testpub_tbl5 (b, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable_insert ADD TABLE testpub_tbl5(b, c)" +== 254 +-- truncate_limit: 100 +/* not all replica identities are good enough */ +CREATE UNIQUE INDEX testpub_tbl5_b_key ON testpub_tbl5 (b, c) +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX testpub_tbl5_b_key ON testpub_tbl5 USING btree (b, c)" +== 255 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl5 ALTER b SET NOT NULL, ALTER c SET NOT NULL +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl5 ALTER COLUMN b SET NOT NULL, ALTER COLUMN c SET NOT NULL" +== 256 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl5 REPLICA IDENTITY USING INDEX testpub_tbl5_b_key +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl5 REPLICA IDENTITY USING INDEX testpub_tbl5_b_key" +== 257 +-- truncate_limit: 100 +-- error: replica identity (b,c) is not covered by column list (a, c) +UPDATE testpub_tbl5 SET a = 1 +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl5 SET a = 1" +== 258 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl5 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl5" +== 259 +-- truncate_limit: 100 +-- error: change the replica identity to "b", and column list to (a, c) +-- then update fails, because (a, c) does not cover replica identity +ALTER TABLE testpub_tbl5 REPLICA IDENTITY USING INDEX testpub_tbl5_b_key +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl5 REPLICA IDENTITY USING INDEX testpub_tbl5_b_key" +== 260 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5 (a, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5(a, c)" +== 261 +-- truncate_limit: 100 +UPDATE testpub_tbl5 SET a = 1 +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl5 SET a = 1" +== 262 +-- truncate_limit: 100 +/* But if upd/del are not published, it works OK */ +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 263 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_table_ins WITH (publish = 'insert, truncate') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_table_ins WITH (publish = 'insert, truncate')" +== 264 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 265 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_table_ins ADD TABLE testpub_tbl5 (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_table_ins ADD TABLE testpub_tbl5(a)" +== 266 +-- truncate_limit: 100 +-- ok + +-- error: cannot work with deferrable primary keys +CREATE TABLE testpub_tbl5d (a int PRIMARY KEY DEFERRABLE) +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl5d (a int PRIMARY KEY DEFERRABLE)" +== 267 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5d +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl5d" +== 268 +-- truncate_limit: 100 +UPDATE testpub_tbl5d SET a = 1 +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl5d SET a = 1" +== 269 +-- truncate_limit: 100 +/* but works fine with FULL replica identity */ +ALTER TABLE testpub_tbl5d REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl5d REPLICA IDENTITY FULL" +== 270 +-- truncate_limit: 100 +UPDATE testpub_tbl5d SET a = 1 +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl5d SET a = 1" +== 271 +-- truncate_limit: 100 +DROP TABLE testpub_tbl5d +-- +TABLE: name="testpub_tbl5d" schema="" table="testpub_tbl5d" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_tbl5d" +== 272 +-- truncate_limit: 100 +-- tests with REPLICA IDENTITY FULL +CREATE TABLE testpub_tbl6 (a int, b text, c text) +-- +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl6 (a int, b text, c text)" +== 273 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl6 REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl6 REPLICA IDENTITY FULL" +== 274 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl6 (a, b, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl6(a, b, c)" +== 275 +-- truncate_limit: 100 +UPDATE testpub_tbl6 SET a = 1 +-- +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl6 SET a = 1" +== 276 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl6 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable DROP TABLE testpub_tbl6" +== 277 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl6 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl6" +== 278 +-- truncate_limit: 100 +-- ok +UPDATE testpub_tbl6 SET a = 1 +-- +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl6 SET a = 1" +== 279 +-- truncate_limit: 100 +-- make sure changing the column list is propagated to the catalog +CREATE TABLE testpub_tbl7 (a int primary key, b text, c text) +-- +TABLE: name="testpub_tbl7" schema="" table="testpub_tbl7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl7 (a int PRIMARY KEY, b text, c text)" +== 280 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl7 (a, b) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable ADD TABLE testpub_tbl7(a, b)" +== 281 +-- truncate_limit: 100 +-- ok: the column list is the same, we should skip this table (or at least not fail) +ALTER PUBLICATION testpub_fortable SET TABLE testpub_tbl7 (a, b) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable SET TABLE testpub_tbl7(a, b)" +== 282 +-- truncate_limit: 100 +-- ok: the column list changes, make sure the catalog gets updated +ALTER PUBLICATION testpub_fortable SET TABLE testpub_tbl7 (a, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortable SET TABLE testpub_tbl7(a, c)" +== 283 +-- truncate_limit: 100 +-- column list for partitioned tables has to cover replica identities for +-- all child relations +CREATE TABLE testpub_tbl8 (a int, b text, c text) PARTITION BY HASH (a) +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl8 (a int, b text, c text) PARTITION BY HASH (a)" +== 284 +-- truncate_limit: 100 +-- first partition has replica identity "a" +CREATE TABLE testpub_tbl8_0 PARTITION OF testpub_tbl8 FOR VALUES WITH (modulus 2, remainder 0) +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl8_0 PARTITION OF testpub_tbl8 FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 285 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_0 ADD PRIMARY KEY (a) +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_0 ADD PRIMARY KEY (a)" +== 286 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY USING INDEX testpub_tbl8_0_pkey +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY USING INDEX testpub_tbl8_0_pkey" +== 287 +-- truncate_limit: 100 +-- second partition has replica identity "b" +CREATE TABLE testpub_tbl8_1 PARTITION OF testpub_tbl8 FOR VALUES WITH (modulus 2, remainder 1) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl8_1 PARTITION OF testpub_tbl8 FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 288 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (b) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (b)" +== 289 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey" +== 290 +-- truncate_limit: 100 +-- ok: column list covers both "a" and "b" +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 291 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_col_list FOR TABLE testpub_tbl8 (a, b) WITH (publish_via_partition_root = 'true') +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_col_list FOR TABLE testpub_tbl8(a, b) WITH (publish_via_partition_root..." +== 292 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 293 +-- truncate_limit: 100 +-- ok: the same thing, but try plain ADD TABLE +ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8" +== 294 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, b) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8(a, b)" +== 295 +-- truncate_limit: 100 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl8 SET a = 1" +== 296 +-- truncate_limit: 100 +-- failure: column list does not cover replica identity for the second partition +ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8" +== 297 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8(a, c)" +== 298 +-- truncate_limit: 100 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl8 SET a = 1" +== 299 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8" +== 300 +-- truncate_limit: 100 +-- failure: one of the partitions has REPLICA IDENTITY FULL +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY FULL" +== 301 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8(a, c)" +== 302 +-- truncate_limit: 100 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl8 SET a = 1" +== 303 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list DROP TABLE testpub_tbl8" +== 304 +-- truncate_limit: 100 +-- add table and then try changing replica identity +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey" +== 305 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, b) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8(a, b)" +== 306 +-- truncate_limit: 100 +-- failure: replica identity full can't be used with a column list +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY FULL" +== 307 +-- truncate_limit: 100 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl8 SET a = 1" +== 308 +-- truncate_limit: 100 +-- failure: replica identity has to be covered by the column list +ALTER TABLE testpub_tbl8_1 DROP CONSTRAINT testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 DROP CONSTRAINT testpub_tbl8_1_pkey" +== 309 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (c) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (c)" +== 310 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey" +== 311 +-- truncate_limit: 100 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl8 SET a = 1" +== 312 +-- truncate_limit: 100 +DROP TABLE testpub_tbl8 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_tbl8" +== 313 +-- truncate_limit: 100 +-- column list for partitioned tables has to cover replica identities for +-- all child relations +CREATE TABLE testpub_tbl8 (a int, b text, c text) PARTITION BY HASH (a) +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl8 (a int, b text, c text) PARTITION BY HASH (a)" +== 314 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8 (a, b) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_col_list ADD TABLE testpub_tbl8(a, b)" +== 315 +-- truncate_limit: 100 +-- first partition has replica identity "a" +CREATE TABLE testpub_tbl8_0 (a int, b text, c text) +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl8_0 (a int, b text, c text)" +== 316 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_0 ADD PRIMARY KEY (a) +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_0 ADD PRIMARY KEY (a)" +== 317 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY USING INDEX testpub_tbl8_0_pkey +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY USING INDEX testpub_tbl8_0_pkey" +== 318 +-- truncate_limit: 100 +-- second partition has replica identity "b" +CREATE TABLE testpub_tbl8_1 (a int, b text, c text) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl8_1 (a int, b text, c text)" +== 319 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (c) +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 ADD PRIMARY KEY (c)" +== 320 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey +-- +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey" +== 321 +-- truncate_limit: 100 +-- ok: attaching first partition works, because (a) is in column list +ALTER TABLE testpub_tbl8 ATTACH PARTITION testpub_tbl8_0 FOR VALUES WITH (modulus 2, remainder 0) +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8 ATTACH PARTITION testpub_tbl8_0 FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 322 +-- truncate_limit: 100 +-- failure: second partition has replica identity (c), which si not in column list +ALTER TABLE testpub_tbl8 ATTACH PARTITION testpub_tbl8_1 FOR VALUES WITH (modulus 2, remainder 1) +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8 ATTACH PARTITION testpub_tbl8_1 FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 323 +-- truncate_limit: 100 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl8 SET a = 1" +== 324 +-- truncate_limit: 100 +-- failure: changing replica identity to FULL for partition fails, because +-- of the column list on the parent +ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY FULL +-- +TABLE: name="testpub_tbl8_0" schema="" table="testpub_tbl8_0" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY FULL" +== 325 +-- truncate_limit: 100 +UPDATE testpub_tbl8 SET a = 1 +-- +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl8 SET a = 1" +== 326 +-- truncate_limit: 100 +-- test that using column list for table is disallowed if any schemas are +-- part of the publication +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 327 +-- truncate_limit: 100 +-- failure - cannot use column list and schema together +CREATE PUBLICATION testpub_tbl9 FOR TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_tbl9 FOR TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a)" +== 328 +-- truncate_limit: 100 +-- ok - only publish schema +CREATE PUBLICATION testpub_tbl9 FOR TABLES IN SCHEMA public +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_tbl9 FOR TABLES IN SCHEMA public" +== 329 +-- truncate_limit: 100 +-- failure - add a table with column list when there is already a schema in the +-- publication +ALTER PUBLICATION testpub_tbl9 ADD TABLE public.testpub_tbl7(a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_tbl9 ADD TABLE public.testpub_tbl7(a)" +== 330 +-- truncate_limit: 100 +-- ok - only publish table with column list +ALTER PUBLICATION testpub_tbl9 SET TABLE public.testpub_tbl7(a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_tbl9 SET TABLE public.testpub_tbl7(a)" +== 331 +-- truncate_limit: 100 +-- failure - specify a schema when there is already a column list in the +-- publication +ALTER PUBLICATION testpub_tbl9 ADD TABLES IN SCHEMA public +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_tbl9 ADD TABLES IN SCHEMA public" +== 332 +-- truncate_limit: 100 +-- failure - cannot SET column list and schema together +ALTER PUBLICATION testpub_tbl9 SET TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_tbl9 SET TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a)" +== 333 +-- truncate_limit: 100 +-- ok - drop table +ALTER PUBLICATION testpub_tbl9 DROP TABLE public.testpub_tbl7 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_tbl9 DROP TABLE public.testpub_tbl7" +== 334 +-- truncate_limit: 100 +-- failure - cannot ADD column list and schema together +ALTER PUBLICATION testpub_tbl9 ADD TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_tbl9 ADD TABLES IN SCHEMA public, TABLE public.testpub_tbl7(a)" +== 335 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 336 +-- truncate_limit: 100 +DROP TABLE testpub_tbl5, testpub_tbl6, testpub_tbl7, testpub_tbl8, testpub_tbl8_1 +-- +TABLE: name="testpub_tbl5" schema="" table="testpub_tbl5" ctx=DDL +TABLE: name="testpub_tbl6" schema="" table="testpub_tbl6" ctx=DDL +TABLE: name="testpub_tbl7" schema="" table="testpub_tbl7" ctx=DDL +TABLE: name="testpub_tbl8" schema="" table="testpub_tbl8" ctx=DDL +TABLE: name="testpub_tbl8_1" schema="" table="testpub_tbl8_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_tbl5, testpub_tbl6, testpub_tbl7, testpub_tbl8, testpub_tbl8_1" +== 337 +-- truncate_limit: 100 +DROP PUBLICATION testpub_table_ins, testpub_fortable, testpub_fortable_insert, testpub_col_list, testpub_tbl9 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_table_ins, testpub_fortable, testpub_fortable_insert, testpub_col_list, ..." +== 338 +-- truncate_limit: 100 +-- ====================================================== + +-- Test combination of column list and row filter +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 339 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_both_filters +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_both_filters" +== 340 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 341 +-- truncate_limit: 100 +CREATE TABLE testpub_tbl_both_filters (a int, b int, c int, PRIMARY KEY (a,c)) +-- +TABLE: name="testpub_tbl_both_filters" schema="" table="testpub_tbl_both_filters" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl_both_filters (a int, b int, c int, PRIMARY KEY (a, c))" +== 342 +-- truncate_limit: 100 +ALTER TABLE testpub_tbl_both_filters REPLICA IDENTITY USING INDEX testpub_tbl_both_filters_pkey +-- +TABLE: name="testpub_tbl_both_filters" schema="" table="testpub_tbl_both_filters" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testpub_tbl_both_filters REPLICA IDENTITY USING INDEX testpub_tbl_both_filters_pkey" +== 343 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_both_filters ADD TABLE testpub_tbl_both_filters (a,c) WHERE (c != 1) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_both_filters ADD TABLE testpub_tbl_both_filters(a, c) WHERE (c <> 1)" +== 344 +-- truncate_limit: 100 +DROP TABLE testpub_tbl_both_filters +-- +TABLE: name="testpub_tbl_both_filters" schema="" table="testpub_tbl_both_filters" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_tbl_both_filters" +== 345 +-- truncate_limit: 100 +DROP PUBLICATION testpub_both_filters +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_both_filters" +== 346 +-- truncate_limit: 100 +-- ====================================================== + +-- More column list tests for validating column references +CREATE TABLE rf_tbl_abcd_nopk(a int, b int, c int, d int) +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_tbl_abcd_nopk (a int, b int, c int, d int)" +== 347 +-- truncate_limit: 100 +CREATE TABLE rf_tbl_abcd_pk(a int, b int, c int, d int, PRIMARY KEY(a,b)) +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_tbl_abcd_pk (a int, b int, c int, d int, PRIMARY KEY (a, b))" +== 348 +-- truncate_limit: 100 +CREATE TABLE rf_tbl_abcd_part_pk (a int PRIMARY KEY, b int) PARTITION by RANGE (a) +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_tbl_abcd_part_pk (a int PRIMARY KEY, b int) PARTITION BY RANGE (a)" +== 349 +-- truncate_limit: 100 +CREATE TABLE rf_tbl_abcd_part_pk_1 (b int, a int PRIMARY KEY) +-- +TABLE: name="rf_tbl_abcd_part_pk_1" schema="" table="rf_tbl_abcd_part_pk_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rf_tbl_abcd_part_pk_1 (b int, a int PRIMARY KEY)" +== 350 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_part_pk ATTACH PARTITION rf_tbl_abcd_part_pk_1 FOR VALUES FROM (1) TO (10) +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_part_pk ATTACH PARTITION rf_tbl_abcd_part_pk_1 FOR VALUES FROM (1) TO (10)" +== 351 +-- truncate_limit: 100 +-- Case 1. REPLICA IDENTITY DEFAULT (means use primary key or nothing) + +-- 1a. REPLICA IDENTITY is DEFAULT and table has a PK. +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 352 +-- truncate_limit: 100 +CREATE PUBLICATION testpub6 FOR TABLE rf_tbl_abcd_pk (a, b) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub6 FOR TABLE rf_tbl_abcd_pk(a, b)" +== 353 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 354 +-- truncate_limit: 100 +-- ok - (a,b) covers all PK cols +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 355 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a, b, c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk(a, b, c)" +== 356 +-- truncate_limit: 100 +-- ok - (a,b,c) covers all PK cols +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 357 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk(a)" +== 358 +-- truncate_limit: 100 +-- fail - "b" is missing from the column list +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 359 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (b) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk(b)" +== 360 +-- truncate_limit: 100 +-- fail - "a" is missing from the column list +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 361 +-- truncate_limit: 100 +-- 1b. REPLICA IDENTITY is DEFAULT and table has no PK +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk(a)" +== 362 +-- truncate_limit: 100 +-- ok - there's no replica identity, so any column list works +-- note: it fails anyway, just a bit later because UPDATE requires RI +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 363 +-- truncate_limit: 100 +-- Case 2. REPLICA IDENTITY FULL +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY FULL +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY FULL" +== 364 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY FULL +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY FULL" +== 365 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk(c)" +== 366 +-- truncate_limit: 100 +-- fail - with REPLICA IDENTITY FULL no column list is allowed +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 367 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (a, b, c, d) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk(a, b, c, d)" +== 368 +-- truncate_limit: 100 +-- fail - with REPLICA IDENTITY FULL no column list is allowed +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 369 +-- truncate_limit: 100 +-- Case 3. REPLICA IDENTITY NOTHING +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY NOTHING +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY NOTHING" +== 370 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY NOTHING +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY NOTHING" +== 371 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk(a)" +== 372 +-- truncate_limit: 100 +-- ok - REPLICA IDENTITY NOTHING means all column lists are valid +-- it still fails later because without RI we can't replicate updates +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 373 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a, b, c, d) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk(a, b, c, d)" +== 374 +-- truncate_limit: 100 +-- ok - REPLICA IDENTITY NOTHING means all column lists are valid +-- it still fails later because without RI we can't replicate updates +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 375 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (d) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk(d)" +== 376 +-- truncate_limit: 100 +-- ok - REPLICA IDENTITY NOTHING means all column lists are valid +-- it still fails later because without RI we can't replicate updates +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 377 +-- truncate_limit: 100 +-- Case 4. REPLICA IDENTITY INDEX +ALTER TABLE rf_tbl_abcd_pk ALTER COLUMN c SET NOT NULL +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_pk ALTER COLUMN c SET NOT NULL" +== 378 +-- truncate_limit: 100 +CREATE UNIQUE INDEX idx_abcd_pk_c ON rf_tbl_abcd_pk(c) +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX idx_abcd_pk_c ON rf_tbl_abcd_pk USING btree (c)" +== 379 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY USING INDEX idx_abcd_pk_c +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY USING INDEX idx_abcd_pk_c" +== 380 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_nopk ALTER COLUMN c SET NOT NULL +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_nopk ALTER COLUMN c SET NOT NULL" +== 381 +-- truncate_limit: 100 +CREATE UNIQUE INDEX idx_abcd_nopk_c ON rf_tbl_abcd_nopk(c) +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX idx_abcd_nopk_c ON rf_tbl_abcd_nopk USING btree (c)" +== 382 +-- truncate_limit: 100 +ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY USING INDEX idx_abcd_nopk_c +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY USING INDEX idx_abcd_nopk_c" +== 383 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk(a)" +== 384 +-- truncate_limit: 100 +-- fail - column list "a" does not cover the REPLICA IDENTITY INDEX on "c" +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 385 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk (c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk(c)" +== 386 +-- truncate_limit: 100 +-- ok - column list "c" does cover the REPLICA IDENTITY INDEX on "c" +UPDATE rf_tbl_abcd_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_pk SET a = 1" +== 387 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk(a)" +== 388 +-- truncate_limit: 100 +-- fail - column list "a" does not cover the REPLICA IDENTITY INDEX on "c" +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 389 +-- truncate_limit: 100 +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk (c) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk(c)" +== 390 +-- truncate_limit: 100 +-- ok - column list "c" does cover the REPLICA IDENTITY INDEX on "c" +UPDATE rf_tbl_abcd_nopk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_nopk SET a = 1" +== 391 +-- truncate_limit: 100 +-- Tests for partitioned table + +-- set PUBLISH_VIA_PARTITION_ROOT to false and test column list for partitioned +-- table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 0)" +== 392 +-- truncate_limit: 100 +-- fail - cannot use column list for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk(a)" +== 393 +-- truncate_limit: 100 +-- ok - can use column list for partition +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1(a)" +== 394 +-- truncate_limit: 100 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_part_pk SET a = 1" +== 395 +-- truncate_limit: 100 +-- set PUBLISH_VIA_PARTITION_ROOT to true and test column list for partitioned +-- table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 1)" +== 396 +-- truncate_limit: 100 +-- ok - can use column list for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk (a) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk(a)" +== 397 +-- truncate_limit: 100 +-- ok - "a" is a PK col +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_part_pk SET a = 1" +== 398 +-- truncate_limit: 100 +-- fail - cannot set PUBLISH_VIA_PARTITION_ROOT to false if any column list is +-- used for partitioned table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 0)" +== 399 +-- truncate_limit: 100 +-- remove partitioned table's column list +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk" +== 400 +-- truncate_limit: 100 +-- ok - we don't have column list for partitioned table. +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 0)" +== 401 +-- truncate_limit: 100 +-- Now change the root column list to use a column "b" +-- (which is not in the replica identity) +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1 (b) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk_1(b)" +== 402 +-- truncate_limit: 100 +-- ok - we don't have column list for partitioned table. +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 0)" +== 403 +-- truncate_limit: 100 +-- fail - "b" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_part_pk SET a = 1" +== 404 +-- truncate_limit: 100 +-- set PUBLISH_VIA_PARTITION_ROOT to true +-- can use column list for partitioned table +ALTER PUBLICATION testpub6 SET (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET (publish_via_partition_root = 1)" +== 405 +-- truncate_limit: 100 +-- ok - can use column list for partitioned table +ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk (b) +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk(b)" +== 406 +-- truncate_limit: 100 +-- fail - "b" is not in REPLICA IDENTITY INDEX +UPDATE rf_tbl_abcd_part_pk SET a = 1 +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rf_tbl_abcd_part_pk SET a = 1" +== 407 +-- truncate_limit: 100 +DROP PUBLICATION testpub6 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub6" +== 408 +-- truncate_limit: 100 +DROP TABLE rf_tbl_abcd_pk +-- +TABLE: name="rf_tbl_abcd_pk" schema="" table="rf_tbl_abcd_pk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rf_tbl_abcd_pk" +== 409 +-- truncate_limit: 100 +DROP TABLE rf_tbl_abcd_nopk +-- +TABLE: name="rf_tbl_abcd_nopk" schema="" table="rf_tbl_abcd_nopk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rf_tbl_abcd_nopk" +== 410 +-- truncate_limit: 100 +DROP TABLE rf_tbl_abcd_part_pk +-- +TABLE: name="rf_tbl_abcd_part_pk" schema="" table="rf_tbl_abcd_part_pk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rf_tbl_abcd_part_pk" +== 411 +-- truncate_limit: 100 +-- ====================================================== + +-- Test cache invalidation FOR ALL TABLES publication +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 412 +-- truncate_limit: 100 +CREATE TABLE testpub_tbl4(a int) +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_tbl4 (a int)" +== 413 +-- truncate_limit: 100 +INSERT INTO testpub_tbl4 values(1) +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testpub_tbl4 VALUES (1)" +== 414 +-- truncate_limit: 100 +UPDATE testpub_tbl4 set a = 2 +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl4 SET a = 2" +== 415 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_foralltables FOR ALL TABLES +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_foralltables FOR ALL TABLES" +== 416 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 417 +-- truncate_limit: 100 +-- fail missing REPLICA IDENTITY +UPDATE testpub_tbl4 set a = 3 +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl4 SET a = 3" +== 418 +-- truncate_limit: 100 +DROP PUBLICATION testpub_foralltables +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_foralltables" +== 419 +-- truncate_limit: 100 +-- should pass after dropping the publication +UPDATE testpub_tbl4 set a = 3 +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE testpub_tbl4 SET a = 3" +== 420 +-- truncate_limit: 100 +DROP TABLE testpub_tbl4 +-- +TABLE: name="testpub_tbl4" schema="" table="testpub_tbl4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_tbl4" +== 421 +-- truncate_limit: 100 +-- fail - view +CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_view +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_view" +== 422 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE testpub_temptbl(a int) +-- +TABLE: name="testpub_temptbl" schema="" table="testpub_temptbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE testpub_temptbl (a int)" +== 423 +-- truncate_limit: 100 +-- fail - temporary table +CREATE PUBLICATION testpub_fortemptbl FOR TABLE testpub_temptbl +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortemptbl FOR TABLE testpub_temptbl" +== 424 +-- truncate_limit: 100 +DROP TABLE testpub_temptbl +-- +TABLE: name="testpub_temptbl" schema="" table="testpub_temptbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_temptbl" +== 425 +-- truncate_limit: 100 +CREATE UNLOGGED TABLE testpub_unloggedtbl(a int) +-- +TABLE: name="testpub_unloggedtbl" schema="" table="testpub_unloggedtbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE testpub_unloggedtbl (a int)" +== 426 +-- truncate_limit: 100 +-- fail - unlogged table +CREATE PUBLICATION testpub_forunloggedtbl FOR TABLE testpub_unloggedtbl +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forunloggedtbl FOR TABLE testpub_unloggedtbl" +== 427 +-- truncate_limit: 100 +DROP TABLE testpub_unloggedtbl +-- +TABLE: name="testpub_unloggedtbl" schema="" table="testpub_unloggedtbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_unloggedtbl" +== 428 +-- truncate_limit: 100 +-- fail - system table +CREATE PUBLICATION testpub_forsystemtbl FOR TABLE pg_publication +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forsystemtbl FOR TABLE pg_publication" +== 429 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 430 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1, pub_test.testpub_nopk +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1, TABLE pub_test.testpub_nopk" +== 431 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 432 +-- truncate_limit: 100 +-- fail - already added +ALTER PUBLICATION testpub_fortbl ADD TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_fortbl ADD TABLE testpub_tbl1" +== 433 +-- truncate_limit: 100 +-- fail - already added +CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortbl FOR TABLE testpub_tbl1" +== 434 +-- truncate_limit: 100 +-- fail - view +ALTER PUBLICATION testpub_default ADD TABLE testpub_view +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default ADD TABLE testpub_view" +== 435 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default ADD TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default ADD TABLE testpub_tbl1" +== 436 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default SET TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default SET TABLE testpub_tbl1" +== 437 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default ADD TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default ADD TABLE pub_test.testpub_nopk" +== 438 +-- truncate_limit: 100 +ALTER PUBLICATION testpib_ins_trunct ADD TABLE pub_test.testpub_nopk, testpub_tbl1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpib_ins_trunct ADD TABLE pub_test.testpub_nopk, TABLE testpub_tbl1" +== 439 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default DROP TABLE testpub_tbl1, pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default DROP TABLE testpub_tbl1, TABLE pub_test.testpub_nopk" +== 440 +-- truncate_limit: 100 +-- fail - nonexistent +ALTER PUBLICATION testpub_default DROP TABLE pub_test.testpub_nopk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default DROP TABLE pub_test.testpub_nopk" +== 441 +-- truncate_limit: 100 +-- verify relation cache invalidation when a primary key is added using +-- an existing index +CREATE TABLE pub_test.testpub_addpk (id int not null, data int) +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_test.testpub_addpk (id int NOT NULL, data int)" +== 442 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default ADD TABLE pub_test.testpub_addpk +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub_default ADD TABLE pub_test.testpub_addpk" +== 443 +-- truncate_limit: 100 +INSERT INTO pub_test.testpub_addpk VALUES(1, 11) +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pub_test.testpub_addpk VALUES (1, 11)" +== 444 +-- truncate_limit: 100 +CREATE UNIQUE INDEX testpub_addpk_id_idx ON pub_test.testpub_addpk(id) +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX testpub_addpk_id_idx ON pub_test.testpub_addpk USING btree (id)" +== 445 +-- truncate_limit: 100 +-- fail: +UPDATE pub_test.testpub_addpk SET id = 2 +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_test.testpub_addpk SET id = 2" +== 446 +-- truncate_limit: 100 +ALTER TABLE pub_test.testpub_addpk ADD PRIMARY KEY USING INDEX testpub_addpk_id_idx +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE pub_test.testpub_addpk ADD PRIMARY KEY USING INDEX testpub_addpk_id_idx" +== 447 +-- truncate_limit: 100 +-- now it should work: +UPDATE pub_test.testpub_addpk SET id = 2 +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_test.testpub_addpk SET id = 2" +== 448 +-- truncate_limit: 100 +DROP TABLE pub_test.testpub_addpk +-- +TABLE: name="pub_test.testpub_addpk" schema="pub_test" table="testpub_addpk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pub_test.testpub_addpk" +== 449 +-- truncate_limit: 100 +-- permissions +SET ROLE regress_publication_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user2" +== 450 +-- truncate_limit: 100 +CREATE PUBLICATION testpub2 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub2" +== 451 +-- truncate_limit: 100 +-- fail + +SET ROLE regress_publication_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user" +== 452 +-- truncate_limit: 100 +GRANT CREATE ON DATABASE regression TO regress_publication_user2 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON DATABASE regression TO regress_publication_user2" +== 453 +-- truncate_limit: 100 +SET ROLE regress_publication_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user2" +== 454 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 455 +-- truncate_limit: 100 +CREATE PUBLICATION testpub2 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub2" +== 456 +-- truncate_limit: 100 +-- ok +CREATE PUBLICATION testpub3 FOR TABLES IN SCHEMA pub_test +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub3 FOR TABLES IN SCHEMA pub_test" +== 457 +-- truncate_limit: 100 +-- fail +CREATE PUBLICATION testpub3 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub3" +== 458 +-- truncate_limit: 100 +-- ok +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 459 +-- truncate_limit: 100 +ALTER PUBLICATION testpub2 ADD TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub2 ADD TABLE testpub_tbl1" +== 460 +-- truncate_limit: 100 +-- fail +ALTER PUBLICATION testpub3 ADD TABLES IN SCHEMA pub_test +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub3 ADD TABLES IN SCHEMA pub_test" +== 461 +-- truncate_limit: 100 +-- fail + +SET ROLE regress_publication_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user" +== 462 +-- truncate_limit: 100 +GRANT regress_publication_user TO regress_publication_user2 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_publication_user TO regress_publication_user2" +== 463 +-- truncate_limit: 100 +SET ROLE regress_publication_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user2" +== 464 +-- truncate_limit: 100 +ALTER PUBLICATION testpub2 ADD TABLE testpub_tbl1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub2 ADD TABLE testpub_tbl1" +== 465 +-- truncate_limit: 100 +-- ok + +DROP PUBLICATION testpub2 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub2" +== 466 +-- truncate_limit: 100 +DROP PUBLICATION testpub3 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub3" +== 467 +-- truncate_limit: 100 +SET ROLE regress_publication_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user" +== 468 +-- truncate_limit: 100 +CREATE ROLE regress_publication_user3 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_publication_user3" +== 469 +-- truncate_limit: 100 +GRANT regress_publication_user2 TO regress_publication_user3 +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_publication_user2 TO regress_publication_user3" +== 470 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 471 +-- truncate_limit: 100 +CREATE PUBLICATION testpub4 FOR TABLES IN SCHEMA pub_test +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub4 FOR TABLES IN SCHEMA pub_test" +== 472 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 473 +-- truncate_limit: 100 +ALTER PUBLICATION testpub4 OWNER TO regress_publication_user3 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER PUBLICATION testpub4 OWNER TO regress_publication_user3" +== 474 +-- truncate_limit: 100 +SET ROLE regress_publication_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user3" +== 475 +-- truncate_limit: 100 +-- fail - new owner must be superuser +ALTER PUBLICATION testpub4 owner to regress_publication_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER PUBLICATION testpub4 OWNER TO regress_publication_user2" +== 476 +-- truncate_limit: 100 +-- fail +ALTER PUBLICATION testpub4 owner to regress_publication_user +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER PUBLICATION testpub4 OWNER TO regress_publication_user" +== 477 +-- truncate_limit: 100 +-- ok + +SET ROLE regress_publication_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user" +== 478 +-- truncate_limit: 100 +DROP PUBLICATION testpub4 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub4" +== 479 +-- truncate_limit: 100 +DROP ROLE regress_publication_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_publication_user3" +== 480 +-- truncate_limit: 100 +REVOKE CREATE ON DATABASE regression FROM regress_publication_user2 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE create ON DATABASE regression FROM regress_publication_user2" +== 481 +-- truncate_limit: 100 +DROP TABLE testpub_parted +-- +TABLE: name="testpub_parted" schema="" table="testpub_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_parted" +== 482 +-- truncate_limit: 100 +DROP TABLE testpub_tbl1 +-- +TABLE: name="testpub_tbl1" schema="" table="testpub_tbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_tbl1" +== 483 +-- truncate_limit: 100 +-- fail - must be owner of publication +SET ROLE regress_publication_user_dummy +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_publication_user_dummy" +== 484 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default RENAME TO testpub_dummy +-- +STMT: RenameStmt +TRUNCATED: "ALTER PUBLICATION testpub_default RENAME TO testpub_dummy" +== 485 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 486 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default RENAME TO testpub_foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER PUBLICATION testpub_default RENAME TO testpub_foo" +== 487 +-- truncate_limit: 100 +-- rename back to keep the rest simple +ALTER PUBLICATION testpub_foo RENAME TO testpub_default +-- +STMT: RenameStmt +TRUNCATED: "ALTER PUBLICATION testpub_foo RENAME TO testpub_default" +== 488 +-- truncate_limit: 100 +ALTER PUBLICATION testpub_default OWNER TO regress_publication_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER PUBLICATION testpub_default OWNER TO regress_publication_user2" +== 489 +-- truncate_limit: 100 +-- adding schemas and tables +CREATE SCHEMA pub_test1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA pub_test1" +== 490 +-- truncate_limit: 100 +CREATE SCHEMA pub_test2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA pub_test2" +== 491 +-- truncate_limit: 100 +CREATE SCHEMA pub_test3 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA pub_test3" +== 492 +-- truncate_limit: 100 +CREATE SCHEMA "CURRENT_SCHEMA" +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA \"CURRENT_SCHEMA\"" +== 493 +-- truncate_limit: 100 +CREATE TABLE pub_test1.tbl (id int, data text) +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_test1.tbl (id int, data text)" +== 494 +-- truncate_limit: 100 +CREATE TABLE pub_test1.tbl1 (id serial primary key, data text) +-- +TABLE: name="pub_test1.tbl1" schema="pub_test1" table="tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_test1.tbl1 (id serial PRIMARY KEY, data text)" +== 495 +-- truncate_limit: 100 +CREATE TABLE pub_test2.tbl1 (id serial primary key, data text) +-- +TABLE: name="pub_test2.tbl1" schema="pub_test2" table="tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_test2.tbl1 (id serial PRIMARY KEY, data text)" +== 496 +-- truncate_limit: 100 +CREATE TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA"(id int) +-- +TABLE: name="\"CURRENT_SCHEMA\".\"CURRENT_SCHEMA\"" schema="CURRENT_SCHEMA" table="CURRENT_SCHEMA" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE \"CURRENT_SCHEMA\".\"CURRENT_SCHEMA\" (id int)" +== 497 +-- truncate_limit: 100 +-- suppress warning that depends on wal_level +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 498 +-- truncate_limit: 100 +CREATE PUBLICATION testpub1_forschema FOR TABLES IN SCHEMA pub_test1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub1_forschema FOR TABLES IN SCHEMA pub_test1" +== 499 +-- truncate_limit: 100 +CREATE PUBLICATION testpub2_forschema FOR TABLES IN SCHEMA pub_test1, pub_test2, pub_test3 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub2_forschema FOR TABLES IN SCHEMA pub_test1, TABLES IN SCHEMA pub_test2,..." +== 500 +-- truncate_limit: 100 +-- check create publication on CURRENT_SCHEMA +CREATE PUBLICATION testpub3_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub3_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA" +== 501 +-- truncate_limit: 100 +CREATE PUBLICATION testpub4_forschema FOR TABLES IN SCHEMA "CURRENT_SCHEMA" +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub4_forschema FOR TABLES IN SCHEMA \"CURRENT_SCHEMA\"" +== 502 +-- truncate_limit: 100 +CREATE PUBLICATION testpub5_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA, "CURRENT_SCHEMA" +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub5_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA, TABLES IN SCHEMA \"CURR..." +== 503 +-- truncate_limit: 100 +CREATE PUBLICATION testpub6_forschema FOR TABLES IN SCHEMA "CURRENT_SCHEMA", CURRENT_SCHEMA +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub6_forschema FOR TABLES IN SCHEMA \"CURRENT_SCHEMA\", TABLES IN SCHEMA CUR..." +== 504 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_fortable FOR TABLE "CURRENT_SCHEMA"."CURRENT_SCHEMA" +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortable FOR TABLE \"CURRENT_SCHEMA\".\"CURRENT_SCHEMA\"" +== 505 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 506 +-- truncate_limit: 100 +-- check create publication on CURRENT_SCHEMA where search_path is not set +SET SEARCH_PATH='' +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO ''" +== 507 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA CURRENT_SCHEMA" +== 508 +-- truncate_limit: 100 +RESET SEARCH_PATH +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 509 +-- truncate_limit: 100 +-- check create publication on CURRENT_SCHEMA where TABLE/TABLES in SCHEMA +-- is not specified +CREATE PUBLICATION testpub_forschema1 FOR CURRENT_SCHEMA +-- +ERROR: invalid publication object list +CURSORPOS: 138 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 510 +-- truncate_limit: 100 +-- check create publication on CURRENT_SCHEMA along with FOR TABLE +CREATE PUBLICATION testpub_forschema1 FOR TABLE CURRENT_SCHEMA +-- +ERROR: syntax error at or near "CURRENT_SCHEMA" +CURSORPOS: 116 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 511 +-- truncate_limit: 100 +-- check create publication on a schema that does not exist +CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA non_existent_schema +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA non_existent_schema" +== 512 +-- truncate_limit: 100 +-- check create publication on a system schema +CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pg_catalog +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forschema FOR TABLES IN SCHEMA pg_catalog" +== 513 +-- truncate_limit: 100 +-- check create publication on an object which is not schema +CREATE PUBLICATION testpub1_forschema1 FOR TABLES IN SCHEMA testpub_view +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub1_forschema1 FOR TABLES IN SCHEMA testpub_view" +== 514 +-- truncate_limit: 100 +-- dropping the schema should reflect the change in publication +DROP SCHEMA pub_test3 +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA pub_test3" +== 515 +-- truncate_limit: 100 +-- renaming the schema should reflect the change in publication +ALTER SCHEMA pub_test1 RENAME to pub_test1_renamed +-- +STMT: RenameStmt +TRUNCATED: "ALTER SCHEMA pub_test1 RENAME TO pub_test1_renamed" +== 516 +-- truncate_limit: 100 +ALTER SCHEMA pub_test1_renamed RENAME to pub_test1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER SCHEMA pub_test1_renamed RENAME TO pub_test1" +== 517 +-- truncate_limit: 100 +-- alter publication add schema +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test2 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test2" +== 518 +-- truncate_limit: 100 +-- add non existent schema +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA non_existent_schema +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA non_existent_schema" +== 519 +-- truncate_limit: 100 +-- add a schema which is already added to the publication +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA pub_test1" +== 520 +-- truncate_limit: 100 +-- alter publication drop schema +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2" +== 521 +-- truncate_limit: 100 +-- drop schema that is not present in the publication +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test2" +== 522 +-- truncate_limit: 100 +-- drop a schema that does not exist in the system +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA non_existent_schema +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA non_existent_schema" +== 523 +-- truncate_limit: 100 +-- drop all schemas +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1" +== 524 +-- truncate_limit: 100 +-- alter publication set multiple schema +ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test2 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, TABLES IN SCHEMA pub_test2" +== 525 +-- truncate_limit: 100 +-- alter publication set non-existent schema +ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA non_existent_schema +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA non_existent_schema" +== 526 +-- truncate_limit: 100 +-- alter publication set it duplicate schemas should set the schemas after +-- removing the duplicate schemas +ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, pub_test1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1, TABLES IN SCHEMA pub_test1" +== 527 +-- truncate_limit: 100 +-- Verify that it fails to add a schema with a column specification +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA foo (a, b) +-- +ERROR: syntax error at or near "(" +CURSORPOS: 131 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 528 +-- truncate_limit: 100 +ALTER PUBLICATION testpub1_forschema ADD TABLES IN SCHEMA foo, bar (a, b) +-- +ERROR: column specification not allowed for schema +CURSORPOS: 64 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 529 +-- truncate_limit: 100 +-- cleanup pub_test1 schema for invalidation tests +ALTER PUBLICATION testpub2_forschema DROP TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub2_forschema DROP TABLES IN SCHEMA pub_test1" +== 530 +-- truncate_limit: 100 +DROP PUBLICATION testpub3_forschema, testpub4_forschema, testpub5_forschema, testpub6_forschema, testpub_fortable +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub3_forschema, testpub4_forschema, testpub5_forschema, testpub6_forschema, ..." +== 531 +-- truncate_limit: 100 +DROP SCHEMA "CURRENT_SCHEMA" CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA \"CURRENT_SCHEMA\" CASCADE" +== 532 +-- truncate_limit: 100 +-- verify relation cache invalidations through update statement for the +-- default REPLICA IDENTITY on the relation, if schema is part of the +-- publication then update will fail because relation's relreplident +-- option will be set, if schema is not part of the publication then update +-- will be successful. +INSERT INTO pub_test1.tbl VALUES(1, 'test') +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pub_test1.tbl VALUES (1, 'test')" +== 533 +-- truncate_limit: 100 +-- fail +UPDATE pub_test1.tbl SET id = 2 +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_test1.tbl SET id = 2" +== 534 +-- truncate_limit: 100 +ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema DROP TABLES IN SCHEMA pub_test1" +== 535 +-- truncate_limit: 100 +-- success +UPDATE pub_test1.tbl SET id = 2 +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_test1.tbl SET id = 2" +== 536 +-- truncate_limit: 100 +ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub1_forschema SET TABLES IN SCHEMA pub_test1" +== 537 +-- truncate_limit: 100 +-- fail +UPDATE pub_test1.tbl SET id = 2 +-- +TABLE: name="pub_test1.tbl" schema="pub_test1" table="tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_test1.tbl SET id = 2" +== 538 +-- truncate_limit: 100 +-- verify invalidation of partition table having parent and child tables in +-- different schema +CREATE SCHEMA pub_testpart1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA pub_testpart1" +== 539 +-- truncate_limit: 100 +CREATE SCHEMA pub_testpart2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA pub_testpart2" +== 540 +-- truncate_limit: 100 +CREATE TABLE pub_testpart1.parent1 (a int) partition by list (a) +-- +TABLE: name="pub_testpart1.parent1" schema="pub_testpart1" table="parent1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_testpart1.parent1 (a int) PARTITION BY LIST (a)" +== 541 +-- truncate_limit: 100 +CREATE TABLE pub_testpart2.child_parent1 partition of pub_testpart1.parent1 for values in (1) +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_testpart2.child_parent1 PARTITION OF pub_testpart1.parent1 FOR VALUES IN (1)" +== 542 +-- truncate_limit: 100 +INSERT INTO pub_testpart2.child_parent1 values(1) +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pub_testpart2.child_parent1 VALUES (1)" +== 543 +-- truncate_limit: 100 +UPDATE pub_testpart2.child_parent1 set a = 1 +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_testpart2.child_parent1 SET a = 1" +== 544 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 545 +-- truncate_limit: 100 +CREATE PUBLICATION testpubpart_forschema FOR TABLES IN SCHEMA pub_testpart1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpubpart_forschema FOR TABLES IN SCHEMA pub_testpart1" +== 546 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 547 +-- truncate_limit: 100 +-- fail +UPDATE pub_testpart1.parent1 set a = 1 +-- +TABLE: name="pub_testpart1.parent1" schema="pub_testpart1" table="parent1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_testpart1.parent1 SET a = 1" +== 548 +-- truncate_limit: 100 +UPDATE pub_testpart2.child_parent1 set a = 1 +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_testpart2.child_parent1 SET a = 1" +== 549 +-- truncate_limit: 100 +DROP PUBLICATION testpubpart_forschema +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpubpart_forschema" +== 550 +-- truncate_limit: 100 +-- verify invalidation of partition tables for schema publication that has +-- parent and child tables of different partition hierarchies +CREATE TABLE pub_testpart2.parent2 (a int) partition by list (a) +-- +TABLE: name="pub_testpart2.parent2" schema="pub_testpart2" table="parent2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_testpart2.parent2 (a int) PARTITION BY LIST (a)" +== 551 +-- truncate_limit: 100 +CREATE TABLE pub_testpart1.child_parent2 partition of pub_testpart2.parent2 for values in (1) +-- +TABLE: name="pub_testpart1.child_parent2" schema="pub_testpart1" table="child_parent2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pub_testpart1.child_parent2 PARTITION OF pub_testpart2.parent2 FOR VALUES IN (1)" +== 552 +-- truncate_limit: 100 +INSERT INTO pub_testpart1.child_parent2 values(1) +-- +TABLE: name="pub_testpart1.child_parent2" schema="pub_testpart1" table="child_parent2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pub_testpart1.child_parent2 VALUES (1)" +== 553 +-- truncate_limit: 100 +UPDATE pub_testpart1.child_parent2 set a = 1 +-- +TABLE: name="pub_testpart1.child_parent2" schema="pub_testpart1" table="child_parent2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_testpart1.child_parent2 SET a = 1" +== 554 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 555 +-- truncate_limit: 100 +CREATE PUBLICATION testpubpart_forschema FOR TABLES IN SCHEMA pub_testpart2 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpubpart_forschema FOR TABLES IN SCHEMA pub_testpart2" +== 556 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 557 +-- truncate_limit: 100 +-- fail +UPDATE pub_testpart2.child_parent1 set a = 1 +-- +TABLE: name="pub_testpart2.child_parent1" schema="pub_testpart2" table="child_parent1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_testpart2.child_parent1 SET a = 1" +== 558 +-- truncate_limit: 100 +UPDATE pub_testpart2.parent2 set a = 1 +-- +TABLE: name="pub_testpart2.parent2" schema="pub_testpart2" table="parent2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_testpart2.parent2 SET a = 1" +== 559 +-- truncate_limit: 100 +UPDATE pub_testpart1.child_parent2 set a = 1 +-- +TABLE: name="pub_testpart1.child_parent2" schema="pub_testpart1" table="child_parent2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pub_testpart1.child_parent2 SET a = 1" +== 560 +-- truncate_limit: 100 +-- alter publication set 'TABLES IN SCHEMA' on an empty publication. +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 561 +-- truncate_limit: 100 +CREATE PUBLICATION testpub3_forschema +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub3_forschema" +== 562 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 563 +-- truncate_limit: 100 +ALTER PUBLICATION testpub3_forschema SET TABLES IN SCHEMA pub_test1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION testpub3_forschema SET TABLES IN SCHEMA pub_test1" +== 564 +-- truncate_limit: 100 +-- create publication including both 'FOR TABLE' and 'FOR TABLES IN SCHEMA' +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 565 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_forschema_fortable FOR TABLES IN SCHEMA pub_test1, TABLE pub_test2.tbl1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_forschema_fortable FOR TABLES IN SCHEMA pub_test1, TABLE pub_test2.tbl1" +== 566 +-- truncate_limit: 100 +CREATE PUBLICATION testpub_fortable_forschema FOR TABLE pub_test2.tbl1, TABLES IN SCHEMA pub_test1 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION testpub_fortable_forschema FOR TABLE pub_test2.tbl1, TABLES IN SCHEMA pub_test1" +== 567 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 568 +-- truncate_limit: 100 +-- fail specifying table without any of 'FOR TABLES IN SCHEMA' or +--'FOR TABLE' or 'FOR ALL TABLES' +CREATE PUBLICATION testpub_error FOR pub_test2.tbl1 +-- +ERROR: invalid publication object list +CURSORPOS: 138 +FILENAME: gram.y +FUNCNAME: preprocess_pubobj_list +== 569 +-- truncate_limit: 100 +DROP VIEW testpub_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW testpub_view" +== 570 +-- truncate_limit: 100 +DROP PUBLICATION testpub_default +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_default" +== 571 +-- truncate_limit: 100 +DROP PUBLICATION testpib_ins_trunct +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpib_ins_trunct" +== 572 +-- truncate_limit: 100 +DROP PUBLICATION testpub_fortbl +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_fortbl" +== 573 +-- truncate_limit: 100 +DROP PUBLICATION testpub1_forschema +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub1_forschema" +== 574 +-- truncate_limit: 100 +DROP PUBLICATION testpub2_forschema +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub2_forschema" +== 575 +-- truncate_limit: 100 +DROP PUBLICATION testpub3_forschema +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub3_forschema" +== 576 +-- truncate_limit: 100 +DROP PUBLICATION testpub_forschema_fortable +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_forschema_fortable" +== 577 +-- truncate_limit: 100 +DROP PUBLICATION testpub_fortable_forschema +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpub_fortable_forschema" +== 578 +-- truncate_limit: 100 +DROP PUBLICATION testpubpart_forschema +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION testpubpart_forschema" +== 579 +-- truncate_limit: 100 +DROP SCHEMA pub_test CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA pub_test CASCADE" +== 580 +-- truncate_limit: 100 +DROP SCHEMA pub_test1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA pub_test1 CASCADE" +== 581 +-- truncate_limit: 100 +DROP SCHEMA pub_test2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA pub_test2 CASCADE" +== 582 +-- truncate_limit: 100 +DROP SCHEMA pub_testpart1 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA pub_testpart1 CASCADE" +== 583 +-- truncate_limit: 100 +DROP SCHEMA pub_testpart2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA pub_testpart2 CASCADE" +== 584 +-- truncate_limit: 100 +-- Test the list of partitions published with or without +-- 'PUBLISH_VIA_PARTITION_ROOT' parameter +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 585 +-- truncate_limit: 100 +CREATE SCHEMA sch1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA sch1" +== 586 +-- truncate_limit: 100 +CREATE SCHEMA sch2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA sch2" +== 587 +-- truncate_limit: 100 +CREATE TABLE sch1.tbl1 (a int) PARTITION BY RANGE(a) +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sch1.tbl1 (a int) PARTITION BY RANGE (a)" +== 588 +-- truncate_limit: 100 +CREATE TABLE sch2.tbl1_part1 PARTITION OF sch1.tbl1 FOR VALUES FROM (1) to (10) +-- +TABLE: name="sch2.tbl1_part1" schema="sch2" table="tbl1_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sch2.tbl1_part1 PARTITION OF sch1.tbl1 FOR VALUES FROM (1) TO (10)" +== 589 +-- truncate_limit: 100 +-- Schema publication that does not include the schema that has the parent table +CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch2 WITH (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch2 WITH (publish_via_partition_root = 1)" +== 590 +-- truncate_limit: 100 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_publication_tables" +== 591 +-- truncate_limit: 100 +DROP PUBLICATION pub +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION pub" +== 592 +-- truncate_limit: 100 +-- Table publication that does not include the parent table +CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (publish_via_partition_root = 1)" +== 593 +-- truncate_limit: 100 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_publication_tables" +== 594 +-- truncate_limit: 100 +-- Table publication that includes both the parent table and the child table +ALTER PUBLICATION pub ADD TABLE sch1.tbl1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION pub ADD TABLE sch1.tbl1" +== 595 +-- truncate_limit: 100 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_publication_tables" +== 596 +-- truncate_limit: 100 +DROP PUBLICATION pub +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION pub" +== 597 +-- truncate_limit: 100 +-- Schema publication that does not include the schema that has the parent table +CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch2 WITH (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch2 WITH (publish_via_partition_root = 0)" +== 598 +-- truncate_limit: 100 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_publication_tables" +== 599 +-- truncate_limit: 100 +DROP PUBLICATION pub +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION pub" +== 600 +-- truncate_limit: 100 +-- Table publication that does not include the parent table +CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (PUBLISH_VIA_PARTITION_ROOT=0) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (publish_via_partition_root = 0)" +== 601 +-- truncate_limit: 100 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_publication_tables" +== 602 +-- truncate_limit: 100 +-- Table publication that includes both the parent table and the child table +ALTER PUBLICATION pub ADD TABLE sch1.tbl1 +-- +STMT: AlterPublicationStmt +TRUNCATED: "ALTER PUBLICATION pub ADD TABLE sch1.tbl1" +== 603 +-- truncate_limit: 100 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_publication_tables" +== 604 +-- truncate_limit: 100 +DROP PUBLICATION pub +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION pub" +== 605 +-- truncate_limit: 100 +DROP TABLE sch2.tbl1_part1 +-- +TABLE: name="sch2.tbl1_part1" schema="sch2" table="tbl1_part1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sch2.tbl1_part1" +== 606 +-- truncate_limit: 100 +DROP TABLE sch1.tbl1 +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sch1.tbl1" +== 607 +-- truncate_limit: 100 +CREATE TABLE sch1.tbl1 (a int) PARTITION BY RANGE(a) +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sch1.tbl1 (a int) PARTITION BY RANGE (a)" +== 608 +-- truncate_limit: 100 +CREATE TABLE sch1.tbl1_part1 PARTITION OF sch1.tbl1 FOR VALUES FROM (1) to (10) +-- +TABLE: name="sch1.tbl1_part1" schema="sch1" table="tbl1_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sch1.tbl1_part1 PARTITION OF sch1.tbl1 FOR VALUES FROM (1) TO (10)" +== 609 +-- truncate_limit: 100 +CREATE TABLE sch1.tbl1_part2 PARTITION OF sch1.tbl1 FOR VALUES FROM (10) to (20) +-- +TABLE: name="sch1.tbl1_part2" schema="sch1" table="tbl1_part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sch1.tbl1_part2 PARTITION OF sch1.tbl1 FOR VALUES FROM (10) TO (20)" +== 610 +-- truncate_limit: 100 +CREATE TABLE sch1.tbl1_part3 (a int) PARTITION BY RANGE(a) +-- +TABLE: name="sch1.tbl1_part3" schema="sch1" table="tbl1_part3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sch1.tbl1_part3 (a int) PARTITION BY RANGE (a)" +== 611 +-- truncate_limit: 100 +ALTER TABLE sch1.tbl1 ATTACH PARTITION sch1.tbl1_part3 FOR VALUES FROM (20) to (30) +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE sch1.tbl1 ATTACH PARTITION sch1.tbl1_part3 FOR VALUES FROM (20) TO (30)" +== 612 +-- truncate_limit: 100 +CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch1 WITH (PUBLISH_VIA_PARTITION_ROOT=1) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch1 WITH (publish_via_partition_root = 1)" +== 613 +-- truncate_limit: 100 +SELECT * FROM pg_publication_tables +-- +TABLE: name="pg_publication_tables" schema="" table="pg_publication_tables" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_publication_tables" +== 614 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 615 +-- truncate_limit: 100 +DROP PUBLICATION pub +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION pub" +== 616 +-- truncate_limit: 100 +DROP TABLE sch1.tbl1 +-- +TABLE: name="sch1.tbl1" schema="sch1" table="tbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sch1.tbl1" +== 617 +-- truncate_limit: 100 +DROP SCHEMA sch1 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA sch1 CASCADE" +== 618 +-- truncate_limit: 100 +DROP SCHEMA sch2 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA sch2 CASCADE" +== 619 +-- truncate_limit: 100 +-- Test that the INSERT ON CONFLICT command correctly checks REPLICA IDENTITY +-- when the target table is published. +CREATE TABLE testpub_insert_onconfl_no_ri (a int unique, b int) +-- +TABLE: name="testpub_insert_onconfl_no_ri" schema="" table="testpub_insert_onconfl_no_ri" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_insert_onconfl_no_ri (a int UNIQUE, b int)" +== 620 +-- truncate_limit: 100 +CREATE TABLE testpub_insert_onconfl_parted (a int unique, b int) PARTITION by RANGE (a) +-- +TABLE: name="testpub_insert_onconfl_parted" schema="" table="testpub_insert_onconfl_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_insert_onconfl_parted (a int UNIQUE, b int) PARTITION BY RANGE (a)" +== 621 +-- truncate_limit: 100 +CREATE TABLE testpub_insert_onconfl_part_no_ri PARTITION OF testpub_insert_onconfl_parted FOR VALUES FROM (1) TO (10) +-- +TABLE: name="testpub_insert_onconfl_part_no_ri" schema="" table="testpub_insert_onconfl_part_no_ri" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_insert_onconfl_part_no_ri PARTITION OF testpub_insert_onconfl_parted FOR VAL..." +== 622 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 623 +-- truncate_limit: 100 +CREATE PUBLICATION pub1 FOR ALL TABLES +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION pub1 FOR ALL TABLES" +== 624 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 625 +-- truncate_limit: 100 +-- fail - missing REPLICA IDENTITY +INSERT INTO testpub_insert_onconfl_no_ri VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = 2 +-- +TABLE: name="testpub_insert_onconfl_no_ri" schema="" table="testpub_insert_onconfl_no_ri" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testpub_insert_onconfl_no_ri VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = 2" +== 626 +-- truncate_limit: 100 +-- ok - no updates +INSERT INTO testpub_insert_onconfl_no_ri VALUES (1, 1) ON CONFLICT DO NOTHING +-- +TABLE: name="testpub_insert_onconfl_no_ri" schema="" table="testpub_insert_onconfl_no_ri" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testpub_insert_onconfl_no_ri VALUES (1, 1) ON CONFLICT DO NOTHING" +== 627 +-- truncate_limit: 100 +-- fail - missing REPLICA IDENTITY in partition testpub_insert_onconfl_no_ri +INSERT INTO testpub_insert_onconfl_parted VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = 2 +-- +TABLE: name="testpub_insert_onconfl_parted" schema="" table="testpub_insert_onconfl_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testpub_insert_onconfl_parted VALUES (1, 1) ON CONFLICT (a) DO UPDATE SET b = 2" +== 628 +-- truncate_limit: 100 +-- ok - no updates +INSERT INTO testpub_insert_onconfl_parted VALUES (1, 1) ON CONFLICT DO NOTHING +-- +TABLE: name="testpub_insert_onconfl_parted" schema="" table="testpub_insert_onconfl_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testpub_insert_onconfl_parted VALUES (1, 1) ON CONFLICT DO NOTHING" +== 629 +-- truncate_limit: 100 +DROP PUBLICATION pub1 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION pub1" +== 630 +-- truncate_limit: 100 +DROP TABLE testpub_insert_onconfl_no_ri +-- +TABLE: name="testpub_insert_onconfl_no_ri" schema="" table="testpub_insert_onconfl_no_ri" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_insert_onconfl_no_ri" +== 631 +-- truncate_limit: 100 +DROP TABLE testpub_insert_onconfl_parted +-- +TABLE: name="testpub_insert_onconfl_parted" schema="" table="testpub_insert_onconfl_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_insert_onconfl_parted" +== 632 +-- truncate_limit: 100 +-- Test that the MERGE command correctly checks REPLICA IDENTITY when the +-- target table is published. +CREATE TABLE testpub_merge_no_ri (a int, b int) +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_merge_no_ri (a int, b int)" +== 633 +-- truncate_limit: 100 +CREATE TABLE testpub_merge_pk (a int primary key, b int) +-- +TABLE: name="testpub_merge_pk" schema="" table="testpub_merge_pk" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testpub_merge_pk (a int PRIMARY KEY, b int)" +== 634 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 635 +-- truncate_limit: 100 +CREATE PUBLICATION pub1 FOR ALL TABLES +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION pub1 FOR ALL TABLES" +== 636 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 637 +-- truncate_limit: 100 +-- fail - missing REPLICA IDENTITY +MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 + WHEN MATCHED THEN UPDATE SET b = s.b +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 WHEN MATCHED THEN UPDATE SET ..." +== 638 +-- truncate_limit: 100 +-- fail - missing REPLICA IDENTITY +MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 + WHEN MATCHED THEN DELETE +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 WHEN MATCHED THEN DELETE" +== 639 +-- truncate_limit: 100 +-- ok - insert and do nothing are not restricted +MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 + WHEN MATCHED THEN DO NOTHING + WHEN NOT MATCHED THEN INSERT (a, b) VALUES (0, 0) +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO testpub_merge_no_ri USING testpub_merge_pk s ON s.a >= 1 WHEN MATCHED THEN DO NOTHING ..." +== 640 +-- truncate_limit: 100 +-- ok - REPLICA IDENTITY is DEFAULT and table has a PK +MERGE INTO testpub_merge_pk USING testpub_merge_no_ri s ON s.a >= 1 + WHEN MATCHED AND s.a > 0 THEN UPDATE SET b = s.b + WHEN MATCHED THEN DELETE +-- +TABLE: name="testpub_merge_pk" schema="" table="testpub_merge_pk" ctx=DML +STMT: MergeStmt +TRUNCATED: "MERGE INTO testpub_merge_pk USING testpub_merge_no_ri s ON s.a >= 1 WHEN MATCHED AND s.a > 0 THEN..." +== 641 +-- truncate_limit: 100 +DROP PUBLICATION pub1 +-- +STMT: DropStmt +TRUNCATED: "DROP PUBLICATION pub1" +== 642 +-- truncate_limit: 100 +DROP TABLE testpub_merge_no_ri +-- +TABLE: name="testpub_merge_no_ri" schema="" table="testpub_merge_no_ri" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_merge_no_ri" +== 643 +-- truncate_limit: 100 +DROP TABLE testpub_merge_pk +-- +TABLE: name="testpub_merge_pk" schema="" table="testpub_merge_pk" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testpub_merge_pk" +== 644 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 645 +-- truncate_limit: 100 +DROP ROLE regress_publication_user, regress_publication_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_publication_user, regress_publication_user2" +== 646 +-- truncate_limit: 100 +DROP ROLE regress_publication_user_dummy +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_publication_user_dummy" +== 647 +-- truncate_limit: 100 +-- stage objects for pg_dump tests +CREATE SCHEMA pubme CREATE TABLE t0 (c int, d int) CREATE TABLE t1 (c int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA pubme CREATE TABLE t0 (c int, d int) CREATE TABLE t1 (c int)" +== 648 +-- truncate_limit: 100 +CREATE SCHEMA pubme2 CREATE TABLE t0 (c int, d int) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA pubme2 CREATE TABLE t0 (c int, d int)" +== 649 +-- truncate_limit: 100 +SET client_min_messages = 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 650 +-- truncate_limit: 100 +CREATE PUBLICATION dump_pub_qual_1ct FOR + TABLE ONLY pubme.t0 (c, d) WHERE (c > 0) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION dump_pub_qual_1ct FOR TABLE ONLY pubme.t0(c, d) WHERE (c > 0)" +== 651 +-- truncate_limit: 100 +CREATE PUBLICATION dump_pub_qual_2ct FOR + TABLE ONLY pubme.t0 (c) WHERE (c > 0), + TABLE ONLY pubme.t1 (c) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION dump_pub_qual_2ct FOR TABLE ONLY pubme.t0(c) WHERE (c > 0), TABLE ONLY pubme.t..." +== 652 +-- truncate_limit: 100 +CREATE PUBLICATION dump_pub_nsp_1ct FOR + TABLES IN SCHEMA pubme +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION dump_pub_nsp_1ct FOR TABLES IN SCHEMA pubme" +== 653 +-- truncate_limit: 100 +CREATE PUBLICATION dump_pub_nsp_2ct FOR + TABLES IN SCHEMA pubme, + TABLES IN SCHEMA pubme2 +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION dump_pub_nsp_2ct FOR TABLES IN SCHEMA pubme, TABLES IN SCHEMA pubme2" +== 654 +-- truncate_limit: 100 +CREATE PUBLICATION dump_pub_all FOR + TABLE ONLY pubme.t0, + TABLE ONLY pubme.t1 WHERE (c < 0), + TABLES IN SCHEMA pubme, + TABLES IN SCHEMA pubme2 + WITH (publish_via_partition_root = true) +-- +STMT: CreatePublicationStmt +TRUNCATED: "CREATE PUBLICATION dump_pub_all FOR TABLE ONLY pubme.t0, TABLE ONLY pubme.t1 WHERE (c < 0), TABLE..." +== 655 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" diff --git a/parser/testdata/summary_truncate/postgres_regress/random.metadata.json b/parser/testdata/summary_truncate/postgres_regress/random.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/random.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/random.test b/parser/testdata/summary_truncate/postgres_regress/random.test new file mode 100644 index 0000000..b0907de --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/random.test @@ -0,0 +1,610 @@ +== 001 +-- truncate_limit: 100 +|-- +-- RANDOM +-- Test random() and allies +|-- +-- Tests in this file may have a small probability of failure, +-- since we are dealing with randomness. Try to keep the failure +-- risk for any one test case under 1e-9. +|-- + +-- There should be no duplicates in 1000 random() values. +-- (Assuming 52 random bits in the float8 results, we could +-- take as many as 3000 values and still have less than 1e-9 chance +-- of failure, per https://en.wikipedia.org/wiki/Birthday_problem) +SELECT r, count(*) +FROM (SELECT random() r FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT r, count(*) FROM (SELECT ... FROM generate_series(1, 1000)) ss GROUP BY r HAVING count(*) > 1" +== 002 +-- truncate_limit: 100 +-- The range should be [0, 1). We can expect that at least one out of 2000 +-- random values is in the lowest or highest 1% of the range with failure +-- probability less than about 1e-9. + +SELECT count(*) FILTER (WHERE r < 0 OR r >= 1) AS out_of_range, + (count(*) FILTER (WHERE r < 0.01)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 0.99)) > 0 AS has_large +FROM (SELECT random() r FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 2000)) ss" +== 003 +-- truncate_limit: 100 +-- Check for uniform distribution using the Kolmogorov-Smirnov test. + +CREATE FUNCTION ks_test_uniform_random() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random() r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs(i/n-r)) < c / sqrt(n) FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_uniform_random" function="ks_test_uniform_random" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ks_test_uniform_random() RETURNS boolean AS $$\nDECLARE\n n int := 1000; --..." +== 004 +-- truncate_limit: 100 +-- As written, ks_test_uniform_random() returns true about 99.9% +-- of the time. To get down to a roughly 1e-9 test failure rate, +-- just run it 3 times and accept if any one of them passes. +SELECT ks_test_uniform_random() OR + ks_test_uniform_random() OR + ks_test_uniform_random() AS uniform +-- +FUNCTION: name="ks_test_uniform_random" function="ks_test_uniform_random" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random" function="ks_test_uniform_random" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random" function="ks_test_uniform_random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ks_test_uniform_random() OR ks_test_uniform_random() OR ks_test_uniform_random() AS uniform" +== 005 +-- truncate_limit: 100 +-- now test random_normal() + +-- As above, there should be no duplicates in 1000 random_normal() values. +SELECT r, count(*) +FROM (SELECT random_normal() r FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT r, count(*) FROM (SELECT ... FROM generate_series(1, 1000)) ss GROUP BY r HAVING count(*) > 1" +== 006 +-- truncate_limit: 100 +-- ... unless we force the range (standard deviation) to zero. +-- This is a good place to check that the mean input does something, too. +SELECT r, count(*) +FROM (SELECT random_normal(10, 0) r FROM generate_series(1, 100)) ss +GROUP BY r +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT r, count(*) FROM (SELECT ... FROM generate_series(1, 100)) ss GROUP BY r" +== 007 +-- truncate_limit: 100 +SELECT r, count(*) +FROM (SELECT random_normal(-10, 0) r FROM generate_series(1, 100)) ss +GROUP BY r +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT r, count(*) FROM (SELECT ... FROM generate_series(1, 100)) ss GROUP BY r" +== 008 +-- truncate_limit: 100 +-- Check standard normal distribution using the Kolmogorov-Smirnov test. + +CREATE FUNCTION ks_test_normal_random() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random_normal() r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs((1+erf(r/sqrt(2)))/2 - i/n)) < c / sqrt(n) + FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_normal_random" function="ks_test_normal_random" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ks_test_normal_random() RETURNS boolean AS $$\nDECLARE\n n int := 1000; -- ..." +== 009 +-- truncate_limit: 100 +-- As above, ks_test_normal_random() returns true about 99.9% +-- of the time, so try it 3 times and accept if any test passes. +SELECT ks_test_normal_random() OR + ks_test_normal_random() OR + ks_test_normal_random() AS standard_normal +-- +FUNCTION: name="ks_test_normal_random" function="ks_test_normal_random" schema="" ctx=Call +FUNCTION: name="ks_test_normal_random" function="ks_test_normal_random" schema="" ctx=Call +FUNCTION: name="ks_test_normal_random" function="ks_test_normal_random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 010 +-- truncate_limit: 100 +-- Test random(min, max) + +-- invalid range bounds +SELECT random(1, 0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(1, 0)" +== 011 +-- truncate_limit: 100 +SELECT random(1000000000001, 1000000000000) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(1000000000001, 1000000000000)" +== 012 +-- truncate_limit: 100 +SELECT random(-2.0, -3.0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(-2.0, -3.0)" +== 013 +-- truncate_limit: 100 +SELECT random('NaN'::numeric, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random('NaN'::numeric, 10)" +== 014 +-- truncate_limit: 100 +SELECT random('-Inf'::numeric, 0) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random('-Inf'::numeric, 0)" +== 015 +-- truncate_limit: 100 +SELECT random(0, 'NaN'::numeric) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(0, 'NaN'::numeric)" +== 016 +-- truncate_limit: 100 +SELECT random(0, 'Inf'::numeric) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(0, 'Inf'::numeric)" +== 017 +-- truncate_limit: 100 +-- empty range is OK +SELECT random(101, 101) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(101, 101)" +== 018 +-- truncate_limit: 100 +SELECT random(1000000000001, 1000000000001) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(1000000000001, 1000000000001)" +== 019 +-- truncate_limit: 100 +SELECT random(3.14, 3.14) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(3.14, 3.14)" +== 020 +-- truncate_limit: 100 +-- There should be no triple duplicates in 1000 full-range 32-bit random() +-- values. (Each of the C(1000, 3) choices of triplets from the 1000 values +-- has a probability of 1/(2^32)^2 of being a triple duplicate, so the +-- average number of triple duplicates is 1000 * 999 * 998 / 6 / 2^64, which +-- is roughly 9e-12.) +SELECT r, count(*) +FROM (SELECT random(-2147483648, 2147483647) r + FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 2 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT r, count(*) FROM (SELECT ... FROM generate_series(1, 1000)) ss GROUP BY r HAVING count(*) > 2" +== 021 +-- truncate_limit: 100 +-- There should be no duplicates in 1000 full-range 64-bit random() values. +SELECT r, count(*) +FROM (SELECT random_normal(-9223372036854775808, 9223372036854775807) r + FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT r, count(*) FROM (SELECT ... FROM generate_series(1, 1000)) ss GROUP BY r HAVING count(*) > 1" +== 022 +-- truncate_limit: 100 +-- There should be no duplicates in 1000 15-digit random() numeric values. +SELECT r, count(*) +FROM (SELECT random_normal(0, 1 - 1e-15) r + FROM generate_series(1, 1000)) ss +GROUP BY r HAVING count(*) > 1 +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT r, count(*) FROM (SELECT ... FROM generate_series(1, 1000)) ss GROUP BY r HAVING count(*) > 1" +== 023 +-- truncate_limit: 100 +-- Expect at least one out of 2000 random values to be in the lowest and +-- highest 1% of the range. +SELECT (count(*) FILTER (WHERE r < -2104533975)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 2104533974)) > 0 AS has_large +FROM (SELECT random(-2147483648, 2147483647) r FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 2000)) ss" +== 024 +-- truncate_limit: 100 +SELECT count(*) FILTER (WHERE r < -1500000000 OR r > 1500000000) AS out_of_range, + (count(*) FILTER (WHERE r < -1470000000)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 1470000000)) > 0 AS has_large +FROM (SELECT random(-1500000000, 1500000000) r FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 2000)) ss" +== 025 +-- truncate_limit: 100 +SELECT (count(*) FILTER (WHERE r < -9038904596117680292)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 9038904596117680291)) > 0 AS has_large +FROM (SELECT random(-9223372036854775808, 9223372036854775807) r + FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 2000)) ss" +== 026 +-- truncate_limit: 100 +SELECT count(*) FILTER (WHERE r < -1500000000000000 OR r > 1500000000000000) AS out_of_range, + (count(*) FILTER (WHERE r < -1470000000000000)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 1470000000000000)) > 0 AS has_large +FROM (SELECT random(-1500000000000000, 1500000000000000) r + FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 2000)) ss" +== 027 +-- truncate_limit: 100 +SELECT count(*) FILTER (WHERE r < -1.5 OR r > 1.5) AS out_of_range, + (count(*) FILTER (WHERE r < -1.47)) > 0 AS has_small, + (count(*) FILTER (WHERE r > 1.47)) > 0 AS has_large +FROM (SELECT random(-1.500000000000000, 1.500000000000000) r + FROM generate_series(1, 2000)) ss +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 2000)) ss" +== 028 +-- truncate_limit: 100 +-- Every possible value should occur at least once in 2500 random() values +-- chosen from a range with 100 distinct values. +SELECT min(r), max(r), count(r) FROM ( + SELECT DISTINCT random(-50, 49) r FROM generate_series(1, 2500)) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(r), max(r), count(r) FROM (SELECT DISTINCT ... AS ... FROM generate_series(1, 2500))" +== 029 +-- truncate_limit: 100 +SELECT min(r), max(r), count(r) FROM ( + SELECT DISTINCT random(123000000000, 123000000099) r + FROM generate_series(1, 2500)) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(r), max(r), count(r) FROM (SELECT DISTINCT ... AS ... FROM generate_series(1, 2500))" +== 030 +-- truncate_limit: 100 +SELECT min(r), max(r), count(r) FROM ( + SELECT DISTINCT random(-0.5, 0.49) r FROM generate_series(1, 2500)) +-- +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(r), max(r), count(r) FROM (SELECT DISTINCT ... AS ... FROM generate_series(1, 2500))" +== 031 +-- truncate_limit: 100 +-- Check for uniform distribution using the Kolmogorov-Smirnov test. + +CREATE FUNCTION ks_test_uniform_random_int_in_range() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random(0, 999999) / 1000000.0 r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs(i/n-r)) < c / sqrt(n) FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_uniform_random_int_in_range" function="ks_test_uniform_random_int_in_range" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ks_test_uniform_random_int_in_range() RETURNS boolean AS $$\nDECLARE\n n int := 10..." +== 032 +-- truncate_limit: 100 +SELECT ks_test_uniform_random_int_in_range() OR + ks_test_uniform_random_int_in_range() OR + ks_test_uniform_random_int_in_range() AS uniform_int +-- +FUNCTION: name="ks_test_uniform_random_int_in_range" function="ks_test_uniform_random_int_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_int_in_range" function="ks_test_uniform_random_int_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_int_in_range" function="ks_test_uniform_random_int_in_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 033 +-- truncate_limit: 100 +CREATE FUNCTION ks_test_uniform_random_bigint_in_range() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random(0, 999999999999) / 1000000000000.0 r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs(i/n-r)) < c / sqrt(n) FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_uniform_random_bigint_in_range" function="ks_test_uniform_random_bigint_in_range" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ks_test_uniform_random_bigint_in_range() RETURNS boolean AS $$\nDECLARE\n n int :=..." +== 034 +-- truncate_limit: 100 +SELECT ks_test_uniform_random_bigint_in_range() OR + ks_test_uniform_random_bigint_in_range() OR + ks_test_uniform_random_bigint_in_range() AS uniform_bigint +-- +FUNCTION: name="ks_test_uniform_random_bigint_in_range" function="ks_test_uniform_random_bigint_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_bigint_in_range" function="ks_test_uniform_random_bigint_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_bigint_in_range" function="ks_test_uniform_random_bigint_in_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 035 +-- truncate_limit: 100 +CREATE FUNCTION ks_test_uniform_random_numeric_in_range() +RETURNS boolean AS +$$ +DECLARE + n int := 1000; -- Number of samples + c float8 := 1.94947; -- Critical value for 99.9% confidence + ok boolean; +BEGIN + ok := ( + WITH samples AS ( + SELECT random(0, 0.999999) r FROM generate_series(1, n) ORDER BY 1 + ), indexed_samples AS ( + SELECT (row_number() OVER())-1.0 i, r FROM samples + ) + SELECT max(abs(i/n-r)) < c / sqrt(n) FROM indexed_samples + ); + RETURN ok; +END +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="ks_test_uniform_random_numeric_in_range" function="ks_test_uniform_random_numeric_in_range" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION ks_test_uniform_random_numeric_in_range() RETURNS boolean AS $$\nDECLARE\n n int :..." +== 036 +-- truncate_limit: 100 +SELECT ks_test_uniform_random_numeric_in_range() OR + ks_test_uniform_random_numeric_in_range() OR + ks_test_uniform_random_numeric_in_range() AS uniform_numeric +-- +FUNCTION: name="ks_test_uniform_random_numeric_in_range" function="ks_test_uniform_random_numeric_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_numeric_in_range" function="ks_test_uniform_random_numeric_in_range" schema="" ctx=Call +FUNCTION: name="ks_test_uniform_random_numeric_in_range" function="ks_test_uniform_random_numeric_in_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 037 +-- truncate_limit: 100 +-- setseed() should produce a reproducible series of random() values. + +SELECT setseed(0.5) +-- +FUNCTION: name="setseed" function="setseed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setseed(0.5)" +== 038 +-- truncate_limit: 100 +SELECT random() FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random() FROM generate_series(1, 10)" +== 039 +-- truncate_limit: 100 +-- Likewise for random_normal(); however, since its implementation relies +-- on libm functions that have different roundoff behaviors on different +-- machines, we have to round off the results a bit to get consistent output. +SET extra_float_digits = -1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO -1" +== 040 +-- truncate_limit: 100 +SELECT random_normal() FROM generate_series(1, 10) +-- +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random_normal() FROM generate_series(1, 10)" +== 041 +-- truncate_limit: 100 +SELECT random_normal(mean => 1, stddev => 0.1) r FROM generate_series(1, 10) +-- +FUNCTION: name="random_normal" function="random_normal" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random_normal(mean := 1, stddev := 0.1) AS r FROM generate_series(1, 10)" +== 042 +-- truncate_limit: 100 +-- Reproducible random(min, max) values. +SELECT random(1, 6) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(1, 6) FROM generate_series(1, 10)" +== 043 +-- truncate_limit: 100 +SELECT random(-2147483648, 2147483647) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(-2147483648, 2147483647) FROM generate_series(1, 10)" +== 044 +-- truncate_limit: 100 +SELECT random(-9223372036854775808, 9223372036854775807) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(-9223372036854775808, 9223372036854775807) FROM generate_series(1, 10)" +== 045 +-- truncate_limit: 100 +SELECT random(-1e30, 1e30) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(-1e30, 1e30) FROM generate_series(1, 10)" +== 046 +-- truncate_limit: 100 +SELECT random(-0.4, 0.4) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(-0.4, 0.4) FROM generate_series(1, 10)" +== 047 +-- truncate_limit: 100 +SELECT random(0, 1 - 1e-30) FROM generate_series(1, 10) +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT random(0, 1 - 1e-30) FROM generate_series(1, 10)" +== 048 +-- truncate_limit: 100 +SELECT n, random(0, trim_scale(abs(1 - 10.0^(-n)))) FROM generate_series(-20, 20) n +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="trim_scale" function="trim_scale" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT n, random(0, trim_scale(abs(1 - (10.0 ^ (- n))))) FROM generate_series(-20, 20) n" diff --git a/parser/testdata/summary_truncate/postgres_regress/rangefuncs.metadata.json b/parser/testdata/summary_truncate/postgres_regress/rangefuncs.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rangefuncs.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/rangefuncs.test b/parser/testdata/summary_truncate/postgres_regress/rangefuncs.test new file mode 100644 index 0000000..5f1b5ea --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rangefuncs.test @@ -0,0 +1,3413 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE rngfunc2(rngfuncid int, f2 int) +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rngfunc2 (rngfuncid int, f2 int)" +== 002 +-- truncate_limit: 100 +INSERT INTO rngfunc2 VALUES(1, 11) +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rngfunc2 VALUES (1, 11)" +== 003 +-- truncate_limit: 100 +INSERT INTO rngfunc2 VALUES(2, 22) +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rngfunc2 VALUES (2, 22)" +== 004 +-- truncate_limit: 100 +INSERT INTO rngfunc2 VALUES(1, 111) +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rngfunc2 VALUES (1, 111)" +== 005 +-- truncate_limit: 100 +CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQL +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rngfunct(int) RETURNS SETOF rngfunc2 AS $$SELECT * FROM rngfunc2 WHERE rngfuncid ..." +== 006 +-- truncate_limit: 100 +-- function with ORDINALITY +select * from rngfunct(1) with ordinality as z(a,b,ord) +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunct(1) WITH ORDINALITY z(a, b, ord)" +== 007 +-- truncate_limit: 100 +select * from rngfunct(1) with ordinality as z(a,b,ord) where b > 100 +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunct(1) WITH ORDINALITY z(a, b, ord) WHERE b > 100" +== 008 +-- truncate_limit: 100 +-- ordinal 2, not 1 +-- ordinality vs. column names and types +select a,b,ord from rngfunct(1) with ordinality as z(a,b,ord) +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, ord FROM rngfunct(1) WITH ORDINALITY z(a, b, ord)" +== 009 +-- truncate_limit: 100 +select a,ord from unnest(array['a','b']) with ordinality as z(a,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, ord FROM unnest(ARRAY['a', 'b']) WITH ORDINALITY z(a, ord)" +== 010 +-- truncate_limit: 100 +select * from unnest(array['a','b']) with ordinality as z(a,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest(ARRAY['a', 'b']) WITH ORDINALITY z(a, ord)" +== 011 +-- truncate_limit: 100 +select a,ord from unnest(array[1.0::float8]) with ordinality as z(a,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, ord FROM unnest(ARRAY[(1.0)::float8]) WITH ORDINALITY z(a, ord)" +== 012 +-- truncate_limit: 100 +select * from unnest(array[1.0::float8]) with ordinality as z(a,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest(ARRAY[(1.0)::float8]) WITH ORDINALITY z(a, ord)" +== 013 +-- truncate_limit: 100 +select row_to_json(s.*) from generate_series(11,14) with ordinality s +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(s.*) FROM generate_series(11, 14) WITH ORDINALITY s" +== 014 +-- truncate_limit: 100 +-- ordinality vs. views +create temporary view vw_ord as select * from (values (1)) v(n) join rngfunct(1) with ordinality as z(a,b,ord) on (n=ord) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW vw_ord AS SELECT * FROM (VALUES (1)) v(n) JOIN rngfunct(1) WITH ORDINALITY ..." +== 015 +-- truncate_limit: 100 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_ord" +== 016 +-- truncate_limit: 100 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +TRUNCATED: "SELECT definition FROM pg_views WHERE viewname = 'vw_ord'" +== 017 +-- truncate_limit: 100 +drop view vw_ord +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_ord" +== 018 +-- truncate_limit: 100 +-- multiple functions +select * from rows from(rngfunct(1),rngfunct(2)) with ordinality as z(a,b,c,d,ord) +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (rngfunct(1) , rngfunct(2) ) WITH ORDINALITY z(a, b, c, d, ord)" +== 019 +-- truncate_limit: 100 +create temporary view vw_ord as select * from (values (1)) v(n) join rows from(rngfunct(1),rngfunct(2)) with ordinality as z(a,b,c,d,ord) on (n=ord) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW vw_ord AS SELECT * FROM (VALUES (1)) v(n) JOIN ROWS FROM (rngfunct(1) , rng..." +== 020 +-- truncate_limit: 100 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_ord" +== 021 +-- truncate_limit: 100 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +TRUNCATED: "SELECT definition FROM pg_views WHERE viewname = 'vw_ord'" +== 022 +-- truncate_limit: 100 +drop view vw_ord +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_ord" +== 023 +-- truncate_limit: 100 +-- expansions of unnest() +select * from unnest(array[10,20],array['foo','bar'],array[1.0]) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest(ARRAY[10, 20], ARRAY['foo', 'bar'], ARRAY[1.0])" +== 024 +-- truncate_limit: 100 +select * from unnest(array[10,20],array['foo','bar'],array[1.0]) with ordinality as z(a,b,c,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest(ARRAY[10, 20], ARRAY['foo', 'bar'], ARRAY[1.0]) WITH ORDINALITY z(a, b, c, ord)" +== 025 +-- truncate_limit: 100 +select * from rows from(unnest(array[10,20],array['foo','bar'],array[1.0])) with ordinality as z(a,b,c,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (unnest(ARRAY[10, 20], ARRAY['foo', 'bar'], ARRAY[1.0]) ) WITH ORDINALITY..." +== 026 +-- truncate_limit: 100 +select * from rows from(unnest(array[10,20],array['foo','bar']), generate_series(101,102)) with ordinality as z(a,b,c,ord) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (unnest(ARRAY[10, 20], ARRAY['foo', 'bar']) , generate_series(101, 102) )..." +== 027 +-- truncate_limit: 100 +create temporary view vw_ord as select * from unnest(array[10,20],array['foo','bar'],array[1.0]) as z(a,b,c) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW vw_ord AS SELECT * FROM unnest(ARRAY[10, 20], ARRAY['foo', 'bar'], ARRAY[1...." +== 028 +-- truncate_limit: 100 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_ord" +== 029 +-- truncate_limit: 100 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +TRUNCATED: "SELECT definition FROM pg_views WHERE viewname = 'vw_ord'" +== 030 +-- truncate_limit: 100 +drop view vw_ord +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_ord" +== 031 +-- truncate_limit: 100 +create temporary view vw_ord as select * from rows from(unnest(array[10,20],array['foo','bar'],array[1.0])) as z(a,b,c) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW vw_ord AS SELECT * FROM ROWS FROM (unnest(ARRAY[10, 20], ARRAY['foo', 'bar'..." +== 032 +-- truncate_limit: 100 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_ord" +== 033 +-- truncate_limit: 100 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +TRUNCATED: "SELECT definition FROM pg_views WHERE viewname = 'vw_ord'" +== 034 +-- truncate_limit: 100 +drop view vw_ord +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_ord" +== 035 +-- truncate_limit: 100 +create temporary view vw_ord as select * from rows from(unnest(array[10,20],array['foo','bar']), generate_series(1,2)) as z(a,b,c) +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=DDL +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW vw_ord AS SELECT * FROM ROWS FROM (unnest(ARRAY[10, 20], ARRAY['foo', 'bar'..." +== 036 +-- truncate_limit: 100 +select * from vw_ord +-- +TABLE: name="vw_ord" schema="" table="vw_ord" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_ord" +== 037 +-- truncate_limit: 100 +select definition from pg_views where viewname='vw_ord' +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="viewname" +STMT: SelectStmt +TRUNCATED: "SELECT definition FROM pg_views WHERE viewname = 'vw_ord'" +== 038 +-- truncate_limit: 100 +drop view vw_ord +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_ord" +== 039 +-- truncate_limit: 100 +-- ordinality and multiple functions vs. rewind and reverse scan +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 040 +-- truncate_limit: 100 +declare rf_cur scroll cursor for select * from rows from(generate_series(1,5),generate_series(1,2)) with ordinality as g(i,j,o) +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE rf_cur SCROLL CURSOR FOR SELECT * FROM ROWS FROM (generate_series(1, 5) , generate_series..." +== 041 +-- truncate_limit: 100 +fetch all from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL rf_cur" +== 042 +-- truncate_limit: 100 +fetch backward all from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL rf_cur" +== 043 +-- truncate_limit: 100 +fetch all from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL rf_cur" +== 044 +-- truncate_limit: 100 +fetch next from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH rf_cur" +== 045 +-- truncate_limit: 100 +fetch next from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH rf_cur" +== 046 +-- truncate_limit: 100 +fetch prior from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR rf_cur" +== 047 +-- truncate_limit: 100 +fetch absolute 1 from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH FIRST rf_cur" +== 048 +-- truncate_limit: 100 +fetch next from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH rf_cur" +== 049 +-- truncate_limit: 100 +fetch next from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH rf_cur" +== 050 +-- truncate_limit: 100 +fetch next from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH rf_cur" +== 051 +-- truncate_limit: 100 +fetch prior from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR rf_cur" +== 052 +-- truncate_limit: 100 +fetch prior from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR rf_cur" +== 053 +-- truncate_limit: 100 +fetch prior from rf_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR rf_cur" +== 054 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 055 +-- truncate_limit: 100 +-- function with implicit LATERAL +select * from rngfunc2, rngfunct(rngfunc2.rngfuncid) z where rngfunc2.f2 = z.f2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="rngfunc2" column="f2" +FILTER: schema="" table="z" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc2, rngfunct(rngfunc2.rngfuncid) z WHERE rngfunc2.f2 = z.f2" +== 056 +-- truncate_limit: 100 +-- function with implicit LATERAL and explicit ORDINALITY +select * from rngfunc2, rngfunct(rngfunc2.rngfuncid) with ordinality as z(rngfuncid,f2,ord) where rngfunc2.f2 = z.f2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="rngfunc2" column="f2" +FILTER: schema="" table="z" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc2, rngfunct(rngfunc2.rngfuncid) WITH ORDINALITY z(rngfuncid, f2, ord) WHERE ..." +== 057 +-- truncate_limit: 100 +-- function in subselect +select * from rngfunc2 where f2 in (select f2 from rngfunct(rngfunc2.rngfuncid) z where z.rngfuncid = rngfunc2.rngfuncid) ORDER BY 1,2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="z" column="rngfuncid" +FILTER: schema="" table="rngfunc2" column="rngfuncid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc2 WHERE ... ORDER BY 1, 2" +== 058 +-- truncate_limit: 100 +-- function in subselect +select * from rngfunc2 where f2 in (select f2 from rngfunct(1) z where z.rngfuncid = rngfunc2.rngfuncid) ORDER BY 1,2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="z" column="rngfuncid" +FILTER: schema="" table="rngfunc2" column="rngfuncid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc2 WHERE f2 IN (SELECT f2 FROM rngfunct(1) z WHERE ...) ORDER BY 1, 2" +== 059 +-- truncate_limit: 100 +-- function in subselect +select * from rngfunc2 where f2 in (select f2 from rngfunct(rngfunc2.rngfuncid) z where z.rngfuncid = 1) ORDER BY 1,2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=Select +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="z" column="rngfuncid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc2 WHERE ... ORDER BY 1, 2" +== 060 +-- truncate_limit: 100 +-- nested functions +select rngfunct.rngfuncid, rngfunct.f2 from rngfunct(sin(pi()/2)::int) ORDER BY 1,2 +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=Call +FUNCTION: name="sin" function="sin" schema="" ctx=Call +FUNCTION: name="pi" function="pi" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rngfunct.rngfuncid, rngfunct.f2 FROM rngfunct(sin(pi() / 2)::int) ORDER BY 1, 2" +== 061 +-- truncate_limit: 100 +CREATE TABLE rngfunc (rngfuncid int, rngfuncsubid int, rngfuncname text, primary key(rngfuncid,rngfuncsubid)) +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rngfunc (rngfuncid int, rngfuncsubid int, rngfuncname text, PRIMARY KEY (rngfuncid, ..." +== 062 +-- truncate_limit: 100 +INSERT INTO rngfunc VALUES(1,1,'Joe') +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rngfunc VALUES (1, 1, 'Joe')" +== 063 +-- truncate_limit: 100 +INSERT INTO rngfunc VALUES(1,2,'Ed') +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rngfunc VALUES (1, 2, 'Ed')" +== 064 +-- truncate_limit: 100 +INSERT INTO rngfunc VALUES(2,1,'Mary') +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rngfunc VALUES (2, 1, 'Mary')" +== 065 +-- truncate_limit: 100 +-- sql, proretset = f, prorettype = b +CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc1(int) RETURNS int AS $$SELECT $1;$$ LANGUAGE sql" +== 066 +-- truncate_limit: 100 +SELECT * FROM getrngfunc1(1) AS t1 +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc1(1) t1" +== 067 +-- truncate_limit: 100 +SELECT * FROM getrngfunc1(1) WITH ORDINALITY AS t1(v,o) +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc1(1) WITH ORDINALITY t1(v, o)" +== 068 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1)" +== 069 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 070 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 071 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1) WITH ORDINALITY as t1(v,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1) WITH ORDINALITY t1(v, o)" +== 072 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 073 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 074 +-- truncate_limit: 100 +-- sql, proretset = t, prorettype = b +CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc2(int) RETURNS SETOF int AS $$SELECT rngfuncid FROM rngfunc WHERE rngfu..." +== 075 +-- truncate_limit: 100 +SELECT * FROM getrngfunc2(1) AS t1 +-- +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc2(1) t1" +== 076 +-- truncate_limit: 100 +SELECT * FROM getrngfunc2(1) WITH ORDINALITY AS t1(v,o) +-- +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc2(1) WITH ORDINALITY t1(v, o)" +== 077 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1)" +== 078 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 079 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 080 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1) WITH ORDINALITY AS t1(v,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1) WITH ORDINALITY t1(v, o)" +== 081 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 082 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 083 +-- truncate_limit: 100 +-- sql, proretset = t, prorettype = b +CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc3(int) RETURNS SETOF text AS $$SELECT rngfuncname FROM rngfunc WHERE rn..." +== 084 +-- truncate_limit: 100 +SELECT * FROM getrngfunc3(1) AS t1 +-- +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc3(1) t1" +== 085 +-- truncate_limit: 100 +SELECT * FROM getrngfunc3(1) WITH ORDINALITY AS t1(v,o) +-- +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc3(1) WITH ORDINALITY t1(v, o)" +== 086 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1)" +== 087 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 088 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 089 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1) WITH ORDINALITY AS t1(v,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1) WITH ORDINALITY t1(v, o)" +== 090 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 091 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 092 +-- truncate_limit: 100 +-- sql, proretset = f, prorettype = c +CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS $$SELECT * FROM rngfunc WHERE rngfuncid = $1;..." +== 093 +-- truncate_limit: 100 +SELECT * FROM getrngfunc4(1) AS t1 +-- +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc4(1) t1" +== 094 +-- truncate_limit: 100 +SELECT * FROM getrngfunc4(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc4(1) WITH ORDINALITY t1(a, b, c, o)" +== 095 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1)" +== 096 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 097 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 098 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1) WITH ORDINALITY t1(a, b, c, o)" +== 099 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 100 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 101 +-- truncate_limit: 100 +-- sql, proretset = t, prorettype = c +CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc5(int) RETURNS SETOF rngfunc AS $$SELECT * FROM rngfunc WHERE rngfuncid..." +== 102 +-- truncate_limit: 100 +SELECT * FROM getrngfunc5(1) AS t1 +-- +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc5(1) t1" +== 103 +-- truncate_limit: 100 +SELECT * FROM getrngfunc5(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc5(1) WITH ORDINALITY t1(a, b, c, o)" +== 104 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1)" +== 105 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 106 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 107 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1) WITH ORDINALITY t1(a, b, c, o)" +== 108 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 109 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 110 +-- truncate_limit: 100 +-- sql, proretset = f, prorettype = record +CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc6(int) RETURNS record AS $$SELECT * FROM rngfunc WHERE rngfuncid = $1;$..." +== 111 +-- truncate_limit: 100 +SELECT * FROM getrngfunc6(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text) +-- +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc6(1) t1 (rngfuncid int, rngfuncsubid int, rngfuncname text)" +== 112 +-- truncate_limit: 100 +SELECT * FROM ROWS FROM( getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY +-- +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text)) W..." +== 113 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc6(1) AS +(rngfuncid int, rngfuncsubid int, rngfuncname text) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rn..." +== 114 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 115 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 116 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS + SELECT * FROM ROWS FROM( getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) + WITH ORDINALITY +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM ROWS FROM (getrngfunc6(1) AS (rngfuncid int, rngfuncsu..." +== 117 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 118 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 119 +-- truncate_limit: 100 +-- sql, proretset = t, prorettype = record +CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL +-- +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc7(int) RETURNS SETOF record AS $$SELECT * FROM rngfunc WHERE rngfuncid ..." +== 120 +-- truncate_limit: 100 +SELECT * FROM getrngfunc7(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text) +-- +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc7(1) t1 (rngfuncid int, rngfuncsubid int, rngfuncname text)" +== 121 +-- truncate_limit: 100 +SELECT * FROM ROWS FROM( getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY +-- +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text)) W..." +== 122 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc7(1) AS +(rngfuncid int, rngfuncsubid int, rngfuncname text) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rn..." +== 123 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 124 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 125 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS + SELECT * FROM ROWS FROM( getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) + WITH ORDINALITY +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM ROWS FROM (getrngfunc7(1) AS (rngfuncid int, rngfuncsu..." +== 126 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 127 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 128 +-- truncate_limit: 100 +-- plpgsql, proretset = f, prorettype = b +CREATE FUNCTION getrngfunc8(int) RETURNS int AS 'DECLARE rngfuncint int; BEGIN SELECT rngfuncid into rngfuncint FROM rngfunc WHERE rngfuncid = $1; RETURN rngfuncint; END;' LANGUAGE plpgsql +-- +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc8(int) RETURNS int AS $$DECLARE rngfuncint int; BEGIN SELECT rngfuncid ..." +== 129 +-- truncate_limit: 100 +SELECT * FROM getrngfunc8(1) AS t1 +-- +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc8(1) t1" +== 130 +-- truncate_limit: 100 +SELECT * FROM getrngfunc8(1) WITH ORDINALITY AS t1(v,o) +-- +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc8(1) WITH ORDINALITY t1(v, o)" +== 131 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc8(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc8(1)" +== 132 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 133 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 134 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc8(1) WITH ORDINALITY AS t1(v,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc8(1) WITH ORDINALITY t1(v, o)" +== 135 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 136 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 137 +-- truncate_limit: 100 +-- plpgsql, proretset = f, prorettype = c +CREATE FUNCTION getrngfunc9(int) RETURNS rngfunc AS 'DECLARE rngfunctup rngfunc%ROWTYPE; BEGIN SELECT * into rngfunctup FROM rngfunc WHERE rngfuncid = $1; RETURN rngfunctup; END;' LANGUAGE plpgsql +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION getrngfunc9(int) RETURNS rngfunc AS $$DECLARE rngfunctup rngfunc%ROWTYPE; BEGIN S..." +== 138 +-- truncate_limit: 100 +SELECT * FROM getrngfunc9(1) AS t1 +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc9(1) t1" +== 139 +-- truncate_limit: 100 +SELECT * FROM getrngfunc9(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM getrngfunc9(1) WITH ORDINALITY t1(a, b, c, o)" +== 140 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc9(1) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc9(1)" +== 141 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 142 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 143 +-- truncate_limit: 100 +CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc9(1) WITH ORDINALITY AS t1(a,b,c,o) +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=DDL +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc9(1) WITH ORDINALITY t1(a, b, c, o)" +== 144 +-- truncate_limit: 100 +SELECT * FROM vw_getrngfunc +-- +TABLE: name="vw_getrngfunc" schema="" table="vw_getrngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_getrngfunc" +== 145 +-- truncate_limit: 100 +DROP VIEW vw_getrngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_getrngfunc" +== 146 +-- truncate_limit: 100 +-- mix 'n match kinds, to exercise expandRTE and related logic + +select * from rows from(getrngfunc1(1),getrngfunc2(1),getrngfunc3(1),getrngfunc4(1),getrngfunc5(1), + getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc8(1),getrngfunc9(1)) + with ordinality as t1(a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u) +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (getrngfunc1(1) , getrngfunc2(1) , getrngfunc3(1) , getrngfunc4(1) , getr..." +== 147 +-- truncate_limit: 100 +select * from rows from(getrngfunc9(1),getrngfunc8(1), + getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc5(1),getrngfunc4(1),getrngfunc3(1),getrngfunc2(1),getrngfunc1(1)) + with ordinality as t1(a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u) +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=Call +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=Call +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=Call +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=Call +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=Call +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=Call +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (getrngfunc9(1) , getrngfunc8(1) , getrngfunc7(1) AS (rngfuncid int, rngf..." +== 148 +-- truncate_limit: 100 +create temporary view vw_rngfunc as + select * from rows from(getrngfunc9(1), + getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text), + getrngfunc1(1)) + with ordinality as t1(a,b,c,d,e,f,g,n) +-- +TABLE: name="vw_rngfunc" schema="" table="vw_rngfunc" ctx=DDL +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=Call +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=Call +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW vw_rngfunc AS SELECT * FROM ROWS FROM (getrngfunc9(1) , getrngfunc7(1) AS (..." +== 149 +-- truncate_limit: 100 +select * from vw_rngfunc +-- +TABLE: name="vw_rngfunc" schema="" table="vw_rngfunc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vw_rngfunc" +== 150 +-- truncate_limit: 100 +select pg_get_viewdef('vw_rngfunc') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vw_rngfunc')" +== 151 +-- truncate_limit: 100 +drop view vw_rngfunc +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vw_rngfunc" +== 152 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc1(int) +-- +FUNCTION: name="getrngfunc1" function="getrngfunc1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc1(int)" +== 153 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc2(int) +-- +FUNCTION: name="getrngfunc2" function="getrngfunc2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc2(int)" +== 154 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc3(int) +-- +FUNCTION: name="getrngfunc3" function="getrngfunc3" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc3(int)" +== 155 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc4(int) +-- +FUNCTION: name="getrngfunc4" function="getrngfunc4" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc4(int)" +== 156 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc5(int) +-- +FUNCTION: name="getrngfunc5" function="getrngfunc5" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc5(int)" +== 157 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc6(int) +-- +FUNCTION: name="getrngfunc6" function="getrngfunc6" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc6(int)" +== 158 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc7(int) +-- +FUNCTION: name="getrngfunc7" function="getrngfunc7" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc7(int)" +== 159 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc8(int) +-- +FUNCTION: name="getrngfunc8" function="getrngfunc8" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc8(int)" +== 160 +-- truncate_limit: 100 +DROP FUNCTION getrngfunc9(int) +-- +FUNCTION: name="getrngfunc9" function="getrngfunc9" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION getrngfunc9(int)" +== 161 +-- truncate_limit: 100 +DROP FUNCTION rngfunct(int) +-- +FUNCTION: name="rngfunct" function="rngfunct" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfunct(int)" +== 162 +-- truncate_limit: 100 +DROP TABLE rngfunc2 +-- +TABLE: name="rngfunc2" schema="" table="rngfunc2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rngfunc2" +== 163 +-- truncate_limit: 100 +DROP TABLE rngfunc +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rngfunc" +== 164 +-- truncate_limit: 100 +-- Rescan tests -- +CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1" +== 165 +-- truncate_limit: 100 +CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2" +== 166 +-- truncate_limit: 100 +CREATE TYPE rngfunc_rescan_t AS (i integer, s bigint) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE rngfunc_rescan_t AS (i int, s bigint)" +== 167 +-- truncate_limit: 100 +CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQL +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rngfunc_sql(int, int) RETURNS SETOF rngfunc_rescan_t AS $$SELECT i, nextval('rngf..." +== 168 +-- truncate_limit: 100 +-- plpgsql functions use materialize mode +CREATE FUNCTION rngfunc_mat(int,int) RETURNS setof rngfunc_rescan_t AS 'begin for i in $1..$2 loop return next (i, nextval(''rngfunc_rescan_seq2'')); end loop; end;' LANGUAGE plpgsql +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rngfunc_mat(int, int) RETURNS SETOF rngfunc_rescan_t AS $$begin for i in $1..$2 l..." +== 169 +-- truncate_limit: 100 +--invokes ExecReScanFunctionScan - all these cases should materialize the function only once +-- LEFT JOIN on a condition that the planner can't prove to be true is used to ensure the function +-- is on the inner path of a nestloop join + +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 170 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN rngfunc_sql(11,13) ON (r+i)<100 +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r) LEFT JOIN rngfunc_sql(11, 13) ON (r + i) < 100" +== 171 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 172 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN rngfunc_sql(11,13) WITH ORDINALITY AS f(i,s,o) ON (r+i)<100 +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r) LEFT JOIN rngfunc_sql(11, 13) WITH ORDINALITY f(i, s, o) ON (r ..." +== 173 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 174 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN rngfunc_mat(11,13) ON (r+i)<100 +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r) LEFT JOIN rngfunc_mat(11, 13) ON (r + i) < 100" +== 175 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 176 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN rngfunc_mat(11,13) WITH ORDINALITY AS f(i,s,o) ON (r+i)<100 +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r) LEFT JOIN rngfunc_mat(11, 13) WITH ORDINALITY f(i, s, o) ON (r ..." +== 177 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 178 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN ROWS FROM( rngfunc_sql(11,13), rngfunc_mat(11,13) ) WITH ORDINALITY AS f(i1,s1,i2,s2,o) ON (r+i1+i2)<100 +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r) LEFT JOIN ROWS FROM (rngfunc_sql(11, 13) , rngfunc_mat(11, 13) ..." +== 179 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN generate_series(11,13) f(i) ON (r+i)<100 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r) LEFT JOIN generate_series(11, 13) f(i) ON (r + i) < 100" +== 180 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN generate_series(11,13) WITH ORDINALITY AS f(i,o) ON (r+i)<100 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r) LEFT JOIN generate_series(11, 13) WITH ORDINALITY f(i, o) ON (r..." +== 181 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN unnest(array[10,20,30]) f(i) ON (r+i)<100 +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r) LEFT JOIN unnest(ARRAY[10, 20, 30]) f(i) ON (r + i) < 100" +== 182 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r) LEFT JOIN unnest(array[10,20,30]) WITH ORDINALITY AS f(i,o) ON (r+i)<100 +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r) LEFT JOIN unnest(ARRAY[10, 20, 30]) WITH ORDINALITY f(i, o) ON ..." +== 183 +-- truncate_limit: 100 +--invokes ExecReScanFunctionScan with chgParam != NULL (using implied LATERAL) + +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 184 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_sql(10+r,13) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), rngfunc_sql(10 + r, 13)" +== 185 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 186 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_sql(10+r,13) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), rngfunc_sql(10 + r, 13) WITH ORDINALITY f(i, s, o)" +== 187 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 188 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_sql(11,10+r) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), rngfunc_sql(11, 10 + r)" +== 189 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 190 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_sql(11,10+r) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), rngfunc_sql(11, 10 + r) WITH ORDINALITY f(i, s, o)" +== 191 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 192 +-- truncate_limit: 100 +SELECT * FROM (VALUES (11,12),(13,15),(16,20)) v(r1,r2), rngfunc_sql(r1,r2) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (11, 12), (13, 15), (16, 20)) v(r1, r2), rngfunc_sql(r1, r2)" +== 193 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 194 +-- truncate_limit: 100 +SELECT * FROM (VALUES (11,12),(13,15),(16,20)) v(r1,r2), rngfunc_sql(r1,r2) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r1, r2), rngfunc_sql(r1, r2) WITH ORDINALITY f(i, s, o)" +== 195 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 196 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_mat(10+r,13) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), rngfunc_mat(10 + r, 13)" +== 197 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 198 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_mat(10+r,13) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), rngfunc_mat(10 + r, 13) WITH ORDINALITY f(i, s, o)" +== 199 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 200 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_mat(11,10+r) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), rngfunc_mat(11, 10 + r)" +== 201 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 202 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), rngfunc_mat(11,10+r) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), rngfunc_mat(11, 10 + r) WITH ORDINALITY f(i, s, o)" +== 203 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 204 +-- truncate_limit: 100 +SELECT * FROM (VALUES (11,12),(13,15),(16,20)) v(r1,r2), rngfunc_mat(r1,r2) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (11, 12), (13, 15), (16, 20)) v(r1, r2), rngfunc_mat(r1, r2)" +== 205 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 206 +-- truncate_limit: 100 +SELECT * FROM (VALUES (11,12),(13,15),(16,20)) v(r1,r2), rngfunc_mat(r1,r2) WITH ORDINALITY AS f(i,s,o) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r1, r2), rngfunc_mat(r1, r2) WITH ORDINALITY f(i, s, o)" +== 207 +-- truncate_limit: 100 +-- selective rescan of multiple functions: + +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 208 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), ROWS FROM( rngfunc_sql(11,11), rngfunc_mat(10+r,13) ) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r), ROWS FROM (rngfunc_sql(11, 11) , rngfunc_mat(10 + r, 13) )" +== 209 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 210 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), ROWS FROM( rngfunc_sql(10+r,13), rngfunc_mat(11,11) ) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r), ROWS FROM (rngfunc_sql(10 + r, 13) , rngfunc_mat(11, 11) )" +== 211 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 212 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), ROWS FROM( rngfunc_sql(10+r,13), rngfunc_mat(10+r,13) ) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r), ROWS FROM (rngfunc_sql(10 + r, 13) , rngfunc_mat(10 + r, 13) )" +== 213 +-- truncate_limit: 100 +SELECT setval('rngfunc_rescan_seq1',1,false),setval('rngfunc_rescan_seq2',1,false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('rngfunc_rescan_seq1', 1, false), setval('rngfunc_rescan_seq2', 1, false)" +== 214 +-- truncate_limit: 100 +SELECT * FROM generate_series(1,2) r1, generate_series(r1,3) r2, ROWS FROM( rngfunc_sql(10+r1,13), rngfunc_mat(10+r2,13) ) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=Call +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(1, 2) r1, generate_series(r1, 3) r2, ROWS FROM (rngfunc_sql(10 + r1..." +== 215 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), generate_series(10+r,20-r) f(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), generate_series(10 + r, 20 - r) f(i)" +== 216 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), generate_series(10+r,20-r) WITH ORDINALITY AS f(i,o) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), generate_series(10 + r, 20 - r) WITH ORDINALITY f(i, o)" +== 217 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), unnest(array[r*10,r*20,r*30]) f(i) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (1), (2), (3)) v(r), unnest(ARRAY[r * 10, r * 20, r * 30]) f(i)" +== 218 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v(r), unnest(array[r*10,r*20,r*30]) WITH ORDINALITY AS f(i,o) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(r), unnest(ARRAY[r * 10, r * 20, r * 30]) WITH ORDINALITY f(i, o)" +== 219 +-- truncate_limit: 100 +-- deep nesting + +SELECT * FROM (VALUES (1),(2),(3)) v1(r1), + LATERAL (SELECT r1, * FROM (VALUES (10),(20),(30)) v2(r2) + LEFT JOIN generate_series(21,23) f(i) ON ((r2+i)<100) OFFSET 0) s1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v1(r1), LATERAL (SELECT ... FROM (VALUES (...)) v2(r2) LEFT JOIN gen..." +== 220 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v1(r1), + LATERAL (SELECT r1, * FROM (VALUES (10),(20),(30)) v2(r2) + LEFT JOIN generate_series(20+r1,23) f(i) ON ((r2+i)<100) OFFSET 0) s1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v1(r1), LATERAL (SELECT ... FROM (VALUES (...)) v2(r2) LEFT JOIN gen..." +== 221 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v1(r1), + LATERAL (SELECT r1, * FROM (VALUES (10),(20),(30)) v2(r2) + LEFT JOIN generate_series(r2,r2+3) f(i) ON ((r2+i)<100) OFFSET 0) s1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v1(r1), LATERAL (SELECT ... FROM (VALUES (...)) v2(r2) LEFT JOIN gen..." +== 222 +-- truncate_limit: 100 +SELECT * FROM (VALUES (1),(2),(3)) v1(r1), + LATERAL (SELECT r1, * FROM (VALUES (10),(20),(30)) v2(r2) + LEFT JOIN generate_series(r1,2+r2/5) f(i) ON ((r2+i)<100) OFFSET 0) s1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v1(r1), LATERAL (SELECT ... FROM (VALUES (...)) v2(r2) LEFT JOIN gen..." +== 223 +-- truncate_limit: 100 +-- check handling of FULL JOIN with multiple lateral references (bug #15741) + +SELECT * +FROM (VALUES (1),(2)) v1(r1) + LEFT JOIN LATERAL ( + SELECT * + FROM generate_series(1, v1.r1) AS gs1 + LEFT JOIN LATERAL ( + SELECT * + FROM generate_series(1, gs1) AS gs2 + LEFT JOIN generate_series(1, gs2) AS gs3 ON TRUE + ) AS ss1 ON TRUE + FULL JOIN generate_series(1, v1.r1) AS gs4 ON FALSE + ) AS ss0 ON TRUE +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v1(r1) LEFT JOIN LATERAL (SELECT * FROM generate_series(1, v1.r1) gs..." +== 224 +-- truncate_limit: 100 +DROP FUNCTION rngfunc_sql(int,int) +-- +FUNCTION: name="rngfunc_sql" function="rngfunc_sql" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfunc_sql(int, int)" +== 225 +-- truncate_limit: 100 +DROP FUNCTION rngfunc_mat(int,int) +-- +FUNCTION: name="rngfunc_mat" function="rngfunc_mat" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfunc_mat(int, int)" +== 226 +-- truncate_limit: 100 +DROP SEQUENCE rngfunc_rescan_seq1 +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE rngfunc_rescan_seq1" +== 227 +-- truncate_limit: 100 +DROP SEQUENCE rngfunc_rescan_seq2 +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE rngfunc_rescan_seq2" +== 228 +-- truncate_limit: 100 +|-- +-- Test cases involving OUT parameters +|-- + +CREATE FUNCTION rngfunc(in f1 int, out f2 int) +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rngfunc(IN f1 int, OUT f2 int) AS $$select $1+1$$ LANGUAGE sql" +== 229 +-- truncate_limit: 100 +SELECT rngfunc(42) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rngfunc(42)" +== 230 +-- truncate_limit: 100 +SELECT * FROM rngfunc(42) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc(42)" +== 231 +-- truncate_limit: 100 +SELECT * FROM rngfunc(42) AS p(x) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc(42) p(x)" +== 232 +-- truncate_limit: 100 +-- explicit spec of return type is OK +CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS int +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfunc(IN f1 int, OUT f2 int) RETURNS int AS $$select $1+1$$ LANGUAGE..." +== 233 +-- truncate_limit: 100 +-- error, wrong result type +CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS float +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfunc(IN f1 int, OUT f2 int) RETURNS double precision AS $$select $1..." +== 234 +-- truncate_limit: 100 +-- with multiple OUT params you must get a RECORD result +CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) RETURNS int +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfunc(IN f1 int, OUT f2 int, OUT f3 text) RETURNS int AS $$select $1..." +== 235 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) +RETURNS record +AS 'select $1+1' LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfunc(IN f1 int, OUT f2 int, OUT f3 text) RETURNS record AS $$select..." +== 236 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text) +AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql +-- +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfuncr(IN f1 int, OUT f2 int, OUT text) AS $$select $1-1, $1::text |..." +== 237 +-- truncate_limit: 100 +SELECT f1, rngfuncr(f1) FROM int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, rngfuncr(f1) FROM int4_tbl" +== 238 +-- truncate_limit: 100 +SELECT * FROM rngfuncr(42) +-- +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfuncr(42)" +== 239 +-- truncate_limit: 100 +SELECT * FROM rngfuncr(42) AS p(a,b) +-- +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfuncr(42) p(a, b)" +== 240 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION rngfuncb(in f1 int, inout f2 int, out text) +AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sql +-- +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfuncb(IN f1 int, INOUT f2 int, OUT text) AS $$select $2-1, $1::text..." +== 241 +-- truncate_limit: 100 +SELECT f1, rngfuncb(f1, f1/2) FROM int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, rngfuncb(f1, f1 / 2) FROM int4_tbl" +== 242 +-- truncate_limit: 100 +SELECT * FROM rngfuncb(42, 99) +-- +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfuncb(42, 99)" +== 243 +-- truncate_limit: 100 +SELECT * FROM rngfuncb(42, 99) AS p(a,b) +-- +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfuncb(42, 99) p(a, b)" +== 244 +-- truncate_limit: 100 +-- Can reference function with or without OUT params for DROP, etc +DROP FUNCTION rngfunc(int) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfunc(int)" +== 245 +-- truncate_limit: 100 +DROP FUNCTION rngfuncr(in f2 int, out f1 int, out text) +-- +FUNCTION: name="rngfuncr" function="rngfuncr" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfuncr(IN f2 int, OUT f1 int, OUT text)" +== 246 +-- truncate_limit: 100 +DROP FUNCTION rngfuncb(in f1 int, inout f2 int) +-- +FUNCTION: name="rngfuncb" function="rngfuncb" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfuncb(IN f1 int, INOUT f2 int)" +== 247 +-- truncate_limit: 100 +|-- +-- For my next trick, polymorphic OUT parameters +|-- + +CREATE FUNCTION dup (f1 anyelement, f2 out anyelement, f3 out anyarray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dup(f1 anyelement, OUT f2 anyelement, OUT f3 anyarray) AS $$select $1, array[$1,$..." +== 248 +-- truncate_limit: 100 +SELECT dup(22) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup(22)" +== 249 +-- truncate_limit: 100 +SELECT dup('xyz') +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup('xyz')" +== 250 +-- truncate_limit: 100 +-- fails +SELECT dup('xyz'::text) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup('xyz'::text)" +== 251 +-- truncate_limit: 100 +SELECT * FROM dup('xyz'::text) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM dup('xyz'::text)" +== 252 +-- truncate_limit: 100 +-- fails, as we are attempting to rename first argument +CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dup(INOUT f2 anyelement, OUT f3 anyarray) AS $$select $1, array[$1,$1]..." +== 253 +-- truncate_limit: 100 +DROP FUNCTION dup(anyelement) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dup(anyelement)" +== 254 +-- truncate_limit: 100 +-- equivalent behavior, though different name exposed for input arg +CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dup(INOUT f2 anyelement, OUT f3 anyarray) AS $$select $1, array[$1,$1]..." +== 255 +-- truncate_limit: 100 +SELECT dup(22) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup(22)" +== 256 +-- truncate_limit: 100 +DROP FUNCTION dup(anyelement) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dup(anyelement)" +== 257 +-- truncate_limit: 100 +-- fails, no way to deduce outputs +CREATE FUNCTION bad (f1 int, out f2 anyelement, out f3 anyarray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="bad" function="bad" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bad(f1 int, OUT f2 anyelement, OUT f3 anyarray) AS $$select $1, array[$1,$1]$$ LA..." +== 258 +-- truncate_limit: 100 +CREATE FUNCTION dup (f1 anycompatible, f2 anycompatiblearray, f3 out anycompatible, f4 out anycompatiblearray) +AS 'select $1, $2' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dup(f1 anycompatible, f2 anycompatiblearray, OUT f3 anycompatible, OUT f4 anycomp..." +== 259 +-- truncate_limit: 100 +SELECT dup(22, array[44]) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup(22, ARRAY[44])" +== 260 +-- truncate_limit: 100 +SELECT dup(4.5, array[44]) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup(4.5, ARRAY[44])" +== 261 +-- truncate_limit: 100 +SELECT dup(22, array[44::bigint]) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup(22, ARRAY[44::bigint])" +== 262 +-- truncate_limit: 100 +SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, array[44::bigint]) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="dup" function="dup" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, ARRAY[44::bigint])" +== 263 +-- truncate_limit: 100 +DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray)" +== 264 +-- truncate_limit: 100 +CREATE FUNCTION dup (f1 anycompatiblerange, f2 out anycompatible, f3 out anycompatiblearray, f4 out anycompatiblerange) +AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sql +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dup(f1 anycompatiblerange, OUT f2 anycompatible, OUT f3 anycompatiblearray, OUT f..." +== 265 +-- truncate_limit: 100 +SELECT dup(int4range(4,7)) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup(int4range(4, 7))" +== 266 +-- truncate_limit: 100 +SELECT dup(numrange(4,7)) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup(numrange(4, 7))" +== 267 +-- truncate_limit: 100 +SELECT dup(textrange('aaa', 'bbb')) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dup(textrange('aaa', 'bbb'))" +== 268 +-- truncate_limit: 100 +DROP FUNCTION dup(f1 anycompatiblerange) +-- +FUNCTION: name="dup" function="dup" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dup(f1 anycompatiblerange)" +== 269 +-- truncate_limit: 100 +-- fails, no way to deduce outputs +CREATE FUNCTION bad (f1 anyarray, out f2 anycompatible, out f3 anycompatiblearray) +AS 'select $1, array[$1,$1]' LANGUAGE sql +-- +FUNCTION: name="bad" function="bad" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bad(f1 anyarray, OUT f2 anycompatible, OUT f3 anycompatiblearray) AS $$select $1,..." +== 270 +-- truncate_limit: 100 +|-- +-- table functions +|-- + +CREATE OR REPLACE FUNCTION rngfunc() +RETURNS TABLE(a int) +AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfunc() RETURNS TABLE (a int) AS $$ SELECT a FROM generate_series(1,..." +== 271 +-- truncate_limit: 100 +SELECT * FROM rngfunc() +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc()" +== 272 +-- truncate_limit: 100 +DROP FUNCTION rngfunc() +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfunc()" +== 273 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION rngfunc(int) +RETURNS TABLE(a int, b int) +AS $$ SELECT a, b + FROM generate_series(1,$1) a(a), + generate_series(1,$1) b(b) $$ LANGUAGE sql +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfunc(int) RETURNS TABLE (a int, b int) AS $$ SELECT a, b\n F..." +== 274 +-- truncate_limit: 100 +SELECT * FROM rngfunc(3) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc(3)" +== 275 +-- truncate_limit: 100 +DROP FUNCTION rngfunc(int) +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfunc(int)" +== 276 +-- truncate_limit: 100 +-- case that causes change of typmod knowledge during inlining +CREATE OR REPLACE FUNCTION rngfunc() +RETURNS TABLE(a varchar(5)) +AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sql STABLE +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfunc() RETURNS TABLE (a varchar(5)) AS $$ SELECT 'hello'::varchar(5..." +== 277 +-- truncate_limit: 100 +SELECT * FROM rngfunc() GROUP BY 1 +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfunc() GROUP BY 1" +== 278 +-- truncate_limit: 100 +DROP FUNCTION rngfunc() +-- +FUNCTION: name="rngfunc" function="rngfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfunc()" +== 279 +-- truncate_limit: 100 +|-- +-- some tests on SQL functions with RETURNING +|-- + +create temp table tt(f1 serial, data text) +-- +TABLE: name="tt" schema="" table="tt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt (f1 serial, data text)" +== 280 +-- truncate_limit: 100 +create function insert_tt(text) returns int as +$$ insert into tt(data) values($1) returning f1 $$ +language sql +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION insert_tt(text) RETURNS int AS $$ insert into tt(data) values($1) returning f1 $$..." +== 281 +-- truncate_limit: 100 +select insert_tt('foo') +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT insert_tt('foo')" +== 282 +-- truncate_limit: 100 +select insert_tt('bar') +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT insert_tt('bar')" +== 283 +-- truncate_limit: 100 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt" +== 284 +-- truncate_limit: 100 +-- insert will execute to completion even if function needs just 1 row +create or replace function insert_tt(text) returns int as +$$ insert into tt(data) values($1),($1||$1) returning f1 $$ +language sql +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION insert_tt(text) RETURNS int AS $$ insert into tt(data) values($1),($1|..." +== 285 +-- truncate_limit: 100 +select insert_tt('fool') +-- +FUNCTION: name="insert_tt" function="insert_tt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT insert_tt('fool')" +== 286 +-- truncate_limit: 100 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt" +== 287 +-- truncate_limit: 100 +-- setof does what's expected +create or replace function insert_tt2(text,text) returns setof int as +$$ insert into tt(data) values($1),($2) returning f1 $$ +language sql +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION insert_tt2(text, text) RETURNS SETOF int AS $$ insert into tt(data) va..." +== 288 +-- truncate_limit: 100 +select insert_tt2('foolish','barrish') +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT insert_tt2('foolish', 'barrish')" +== 289 +-- truncate_limit: 100 +select * from insert_tt2('baz','quux') +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM insert_tt2('baz', 'quux')" +== 290 +-- truncate_limit: 100 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt" +== 291 +-- truncate_limit: 100 +-- limit doesn't prevent execution to completion +select insert_tt2('foolish','barrish') limit 1 +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT insert_tt2('foolish', 'barrish') LIMIT 1" +== 292 +-- truncate_limit: 100 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt" +== 293 +-- truncate_limit: 100 +-- triggers will fire, too +create function noticetrigger() returns trigger as $$ +begin + raise notice 'noticetrigger % %', new.f1, new.data; + return null; +end $$ language plpgsql +-- +FUNCTION: name="noticetrigger" function="noticetrigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION noticetrigger() RETURNS trigger AS $$\nbegin\n raise notice 'noticetrigger % %', n..." +== 294 +-- truncate_limit: 100 +create trigger tnoticetrigger after insert on tt for each row +execute procedure noticetrigger() +-- +TABLE: name="tt" schema="" table="tt" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tnoticetrigger AFTER INSERT ON tt FOR EACH ROW EXECUTE FUNCTION noticetrigger()" +== 295 +-- truncate_limit: 100 +select insert_tt2('foolme','barme') limit 1 +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT insert_tt2('foolme', 'barme') LIMIT 1" +== 296 +-- truncate_limit: 100 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt" +== 297 +-- truncate_limit: 100 +-- and rules work +create temp table tt_log(f1 int, data text) +-- +TABLE: name="tt_log" schema="" table="tt_log" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt_log (f1 int, data text)" +== 298 +-- truncate_limit: 100 +create rule insert_tt_rule as on insert to tt do also + insert into tt_log values(new.*) +-- +TABLE: name="tt" schema="" table="tt" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE insert_tt_rule AS ON INSERT TO tt DO INSERT INTO tt_log VALUES (new.*)" +== 299 +-- truncate_limit: 100 +select insert_tt2('foollog','barlog') limit 1 +-- +FUNCTION: name="insert_tt2" function="insert_tt2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT insert_tt2('foollog', 'barlog') LIMIT 1" +== 300 +-- truncate_limit: 100 +select * from tt +-- +TABLE: name="tt" schema="" table="tt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt" +== 301 +-- truncate_limit: 100 +-- note that nextval() gets executed a second time in the rule expansion, +-- which is expected. +select * from tt_log +-- +TABLE: name="tt_log" schema="" table="tt_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tt_log" +== 302 +-- truncate_limit: 100 +-- test case for a whole-row-variable bug +create function rngfunc1(n integer, out a text, out b text) + returns setof record + language sql + as $$ select 'foo ' || i, 'bar ' || i from generate_series(1,$1) i $$ +-- +FUNCTION: name="rngfunc1" function="rngfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rngfunc1(n int, OUT a text, OUT b text) RETURNS SETOF record LANGUAGE sql AS $$ s..." +== 303 +-- truncate_limit: 100 +set work_mem='64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 304 +-- truncate_limit: 100 +select t.a, t, t.a from rngfunc1(10000) t limit 1 +-- +FUNCTION: name="rngfunc1" function="rngfunc1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT t.a, t, t.a FROM rngfunc1(10000) t LIMIT 1" +== 305 +-- truncate_limit: 100 +reset work_mem +-- +STMT: VariableSetStmt +TRUNCATED: "RESET work_mem" +== 306 +-- truncate_limit: 100 +select t.a, t, t.a from rngfunc1(10000) t limit 1 +-- +FUNCTION: name="rngfunc1" function="rngfunc1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT t.a, t, t.a FROM rngfunc1(10000) t LIMIT 1" +== 307 +-- truncate_limit: 100 +drop function rngfunc1(n integer) +-- +FUNCTION: name="rngfunc1" function="rngfunc1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfunc1(n int)" +== 308 +-- truncate_limit: 100 +-- test use of SQL functions returning record +-- this is supported in some cases where the query doesn't specify +-- the actual record type ... + +create function array_to_set(anyarray) returns setof record as $$ + select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i +$$ language sql strict immutable +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION array_to_set(anyarray) RETURNS SETOF record AS $$\n select i AS \"index\", $1[i] AS..." +== 309 +-- truncate_limit: 100 +select array_to_set(array['one', 'two']) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_set(ARRAY['one', 'two'])" +== 310 +-- truncate_limit: 100 +select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_to_set(ARRAY['one', 'two']) t (f1 int, f2 text)" +== 311 +-- truncate_limit: 100 +select * from array_to_set(array['one', 'two']) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_to_set(ARRAY['one', 'two'])" +== 312 +-- truncate_limit: 100 +-- fail +-- after-the-fact coercion of the columns is now possible, too +select * from array_to_set(array['one', 'two']) as t(f1 numeric(4,2),f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_to_set(ARRAY['one', 'two']) t (f1 numeric(4, 2), f2 text)" +== 313 +-- truncate_limit: 100 +-- and if it doesn't work, you get a compile-time not run-time error +select * from array_to_set(array['one', 'two']) as t(f1 point,f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_to_set(ARRAY['one', 'two']) t (f1 point, f2 text)" +== 314 +-- truncate_limit: 100 +-- with "strict", this function can't be inlined in FROM +explain (verbose, costs off) + select * from array_to_set(array['one', 'two']) as t(f1 numeric(4,2),f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM array_to_set(ARRAY['one', 'two']) t (f1 numeric(4, 2),..." +== 315 +-- truncate_limit: 100 +-- but without, it can be: + +create or replace function array_to_set(anyarray) returns setof record as $$ + select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i +$$ language sql immutable +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION array_to_set(anyarray) RETURNS SETOF record AS $$\n select i AS \"index..." +== 316 +-- truncate_limit: 100 +select array_to_set(array['one', 'two']) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_set(ARRAY['one', 'two'])" +== 317 +-- truncate_limit: 100 +select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_to_set(ARRAY['one', 'two']) t (f1 int, f2 text)" +== 318 +-- truncate_limit: 100 +select * from array_to_set(array['one', 'two']) as t(f1 numeric(4,2),f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_to_set(ARRAY['one', 'two']) t (f1 numeric(4, 2), f2 text)" +== 319 +-- truncate_limit: 100 +select * from array_to_set(array['one', 'two']) as t(f1 point,f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM array_to_set(ARRAY['one', 'two']) t (f1 point, f2 text)" +== 320 +-- truncate_limit: 100 +explain (verbose, costs off) + select * from array_to_set(array['one', 'two']) as t(f1 numeric(4,2),f2 text) +-- +FUNCTION: name="array_to_set" function="array_to_set" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM array_to_set(ARRAY['one', 'two']) t (f1 numeric(4, 2),..." +== 321 +-- truncate_limit: 100 +create temp table rngfunc(f1 int8, f2 int8) +-- +TABLE: name="rngfunc" schema="" table="rngfunc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE rngfunc (f1 int8, f2 int8)" +== 322 +-- truncate_limit: 100 +create function testrngfunc() returns record as $$ + insert into rngfunc values (1,2) returning *; +$$ language sql +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testrngfunc() RETURNS record AS $$\n insert into rngfunc values (1,2) returning *..." +== 323 +-- truncate_limit: 100 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testrngfunc()" +== 324 +-- truncate_limit: 100 +select * from testrngfunc() as t(f1 int8,f2 int8) +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc() t (f1 int8, f2 int8)" +== 325 +-- truncate_limit: 100 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc()" +== 326 +-- truncate_limit: 100 +-- fail + +drop function testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION testrngfunc()" +== 327 +-- truncate_limit: 100 +create function testrngfunc() returns setof record as $$ + insert into rngfunc values (1,2), (3,4) returning *; +$$ language sql +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testrngfunc() RETURNS SETOF record AS $$\n insert into rngfunc values (1,2), (3,4..." +== 328 +-- truncate_limit: 100 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testrngfunc()" +== 329 +-- truncate_limit: 100 +select * from testrngfunc() as t(f1 int8,f2 int8) +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc() t (f1 int8, f2 int8)" +== 330 +-- truncate_limit: 100 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc()" +== 331 +-- truncate_limit: 100 +-- fail + +drop function testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION testrngfunc()" +== 332 +-- truncate_limit: 100 +-- Check that typmod imposed by a composite type is honored +create type rngfunc_type as (f1 numeric(35,6), f2 numeric(35,2)) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE rngfunc_type AS (f1 numeric(35, 6), f2 numeric(35, 2))" +== 333 +-- truncate_limit: 100 +create function testrngfunc() returns rngfunc_type as $$ + select 7.136178319899999964, 7.136178319899999964; +$$ language sql immutable +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testrngfunc() RETURNS rngfunc_type AS $$\n select 7.136178319899999964, 7.1361783..." +== 334 +-- truncate_limit: 100 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT testrngfunc()" +== 335 +-- truncate_limit: 100 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testrngfunc()" +== 336 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM testrngfunc()" +== 337 +-- truncate_limit: 100 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc()" +== 338 +-- truncate_limit: 100 +create or replace function testrngfunc() returns rngfunc_type as $$ + select 7.136178319899999964, 7.136178319899999964; +$$ language sql volatile +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION testrngfunc() RETURNS rngfunc_type AS $$\n select 7.136178319899999964..." +== 339 +-- truncate_limit: 100 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT testrngfunc()" +== 340 +-- truncate_limit: 100 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testrngfunc()" +== 341 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM testrngfunc()" +== 342 +-- truncate_limit: 100 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc()" +== 343 +-- truncate_limit: 100 +drop function testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION testrngfunc()" +== 344 +-- truncate_limit: 100 +create function testrngfunc() returns setof rngfunc_type as $$ + select 7.136178319899999964, 7.136178319899999964; +$$ language sql immutable +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION testrngfunc() RETURNS SETOF rngfunc_type AS $$\n select 7.136178319899999964, 7.1..." +== 345 +-- truncate_limit: 100 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT testrngfunc()" +== 346 +-- truncate_limit: 100 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testrngfunc()" +== 347 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM testrngfunc()" +== 348 +-- truncate_limit: 100 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc()" +== 349 +-- truncate_limit: 100 +create or replace function testrngfunc() returns setof rngfunc_type as $$ + select 7.136178319899999964, 7.136178319899999964; +$$ language sql volatile +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION testrngfunc() RETURNS SETOF rngfunc_type AS $$\n select 7.136178319899..." +== 350 +-- truncate_limit: 100 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT testrngfunc()" +== 351 +-- truncate_limit: 100 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testrngfunc()" +== 352 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM testrngfunc()" +== 353 +-- truncate_limit: 100 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc()" +== 354 +-- truncate_limit: 100 +create or replace function testrngfunc() returns setof rngfunc_type as $$ + select 1, 2 union select 3, 4 order by 1; +$$ language sql immutable +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION testrngfunc() RETURNS SETOF rngfunc_type AS $$\n select 1, 2 union sel..." +== 355 +-- truncate_limit: 100 +explain (verbose, costs off) +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT testrngfunc()" +== 356 +-- truncate_limit: 100 +select testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT testrngfunc()" +== 357 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM testrngfunc()" +== 358 +-- truncate_limit: 100 +select * from testrngfunc() +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc()" +== 359 +-- truncate_limit: 100 +-- Check a couple of error cases while we're here +select * from testrngfunc() as t(f1 int8,f2 int8) +-- +FUNCTION: name="testrngfunc" function="testrngfunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testrngfunc() t (f1 int8, f2 int8)" +== 360 +-- truncate_limit: 100 +-- fail, composite result +select * from pg_get_keywords() as t(f1 int8,f2 int8) +-- +FUNCTION: name="pg_get_keywords" function="pg_get_keywords" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_get_keywords() t (f1 int8, f2 int8)" +== 361 +-- truncate_limit: 100 +-- fail, OUT params +select * from sin(3) as t(f1 int8,f2 int8) +-- +FUNCTION: name="sin" function="sin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM sin(3) t (f1 int8, f2 int8)" +== 362 +-- truncate_limit: 100 +-- fail, scalar result type + +drop type rngfunc_type cascade +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE rngfunc_type CASCADE" +== 363 +-- truncate_limit: 100 +|-- +-- Check some cases involving added/dropped columns in a rowtype result +|-- + +create temp table users (userid text, seq int, email text, todrop bool, moredrop int, enabled bool) +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE users (userid text, seq int, email text, todrop bool, moredrop int, enable..." +== 364 +-- truncate_limit: 100 +insert into users values ('id',1,'email',true,11,true) +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO users VALUES ('id', 1, 'email', true, 11, true)" +== 365 +-- truncate_limit: 100 +insert into users values ('id2',2,'email2',true,12,true) +-- +TABLE: name="users" schema="" table="users" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO users VALUES ('id2', 2, 'email2', true, 12, true)" +== 366 +-- truncate_limit: 100 +alter table users drop column todrop +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE users DROP todrop" +== 367 +-- truncate_limit: 100 +create or replace function get_first_user() returns users as +$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$ +language sql stable +-- +FUNCTION: name="get_first_user" function="get_first_user" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION get_first_user() RETURNS users AS $$ SELECT * FROM users ORDER BY user..." +== 368 +-- truncate_limit: 100 +SELECT get_first_user() +-- +FUNCTION: name="get_first_user" function="get_first_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT get_first_user()" +== 369 +-- truncate_limit: 100 +SELECT * FROM get_first_user() +-- +FUNCTION: name="get_first_user" function="get_first_user" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM get_first_user()" +== 370 +-- truncate_limit: 100 +create or replace function get_users() returns setof users as +$$ SELECT * FROM users ORDER BY userid; $$ +language sql stable +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION get_users() RETURNS SETOF users AS $$ SELECT * FROM users ORDER BY use..." +== 371 +-- truncate_limit: 100 +SELECT get_users() +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT get_users()" +== 372 +-- truncate_limit: 100 +SELECT * FROM get_users() +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM get_users()" +== 373 +-- truncate_limit: 100 +SELECT * FROM get_users() WITH ORDINALITY +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM get_users() WITH ORDINALITY" +== 374 +-- truncate_limit: 100 +-- make sure ordinality copes + +-- multiple functions vs. dropped columns +SELECT * FROM ROWS FROM(generate_series(10,11), get_users()) WITH ORDINALITY +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (generate_series(10, 11) , get_users() ) WITH ORDINALITY" +== 375 +-- truncate_limit: 100 +SELECT * FROM ROWS FROM(get_users(), generate_series(10,11)) WITH ORDINALITY +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ROWS FROM (get_users() , generate_series(10, 11) ) WITH ORDINALITY" +== 376 +-- truncate_limit: 100 +-- check that we can cope with post-parsing changes in rowtypes +create temp view usersview as +SELECT * FROM ROWS FROM(get_users(), generate_series(10,11)) WITH ORDINALITY +-- +TABLE: name="usersview" schema="" table="usersview" ctx=DDL +FUNCTION: name="get_users" function="get_users" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW usersview AS SELECT * FROM ROWS FROM (get_users() , generate_series(10, 11)..." +== 377 +-- truncate_limit: 100 +select * from usersview +-- +TABLE: name="usersview" schema="" table="usersview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM usersview" +== 378 +-- truncate_limit: 100 +alter table users add column junk text +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE users ADD COLUMN junk text" +== 379 +-- truncate_limit: 100 +select * from usersview +-- +TABLE: name="usersview" schema="" table="usersview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM usersview" +== 380 +-- truncate_limit: 100 +alter table users drop column moredrop +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE users DROP moredrop" +== 381 +-- truncate_limit: 100 +-- fail, view has reference + +-- We used to have a bug that would allow the above to succeed, posing +-- hazards for later execution of the view. Check that the internal +-- defenses for those hazards haven't bit-rotted, in case some other +-- bug with similar symptoms emerges. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 382 +-- truncate_limit: 100 +-- destroy the dependency entry that prevents the DROP: +delete from pg_depend where + objid = (select oid from pg_rewrite + where ev_class = 'usersview'::regclass and rulename = '_RETURN') + and refobjsubid = 5 +returning pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as ref, + deptype +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=DML +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="rulename" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM pg_depend WHERE ... RETURNING pg_describe_object(classid, objid, objsubid) AS obj, pg..." +== 383 +-- truncate_limit: 100 +alter table users drop column moredrop +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE users DROP moredrop" +== 384 +-- truncate_limit: 100 +select * from usersview +-- +TABLE: name="usersview" schema="" table="usersview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM usersview" +== 385 +-- truncate_limit: 100 +-- expect clean failure +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 386 +-- truncate_limit: 100 +alter table users alter column seq type numeric +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE users ALTER COLUMN seq TYPE numeric" +== 387 +-- truncate_limit: 100 +-- fail, view has reference + +-- likewise, check we don't crash if the dependency goes wrong +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 388 +-- truncate_limit: 100 +-- destroy the dependency entry that prevents the ALTER: +delete from pg_depend where + objid = (select oid from pg_rewrite + where ev_class = 'usersview'::regclass and rulename = '_RETURN') + and refobjsubid = 2 +returning pg_describe_object(classid, objid, objsubid) as obj, + pg_describe_object(refclassid, refobjid, refobjsubid) as ref, + deptype +-- +TABLE: name="pg_depend" schema="" table="pg_depend" ctx=DML +TABLE: name="pg_rewrite" schema="" table="pg_rewrite" ctx=Select +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FILTER: schema="" table="" column="ev_class" +FILTER: schema="" table="" column="rulename" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM pg_depend WHERE ... RETURNING pg_describe_object(classid, objid, objsubid) AS obj, pg..." +== 389 +-- truncate_limit: 100 +alter table users alter column seq type numeric +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE users ALTER COLUMN seq TYPE numeric" +== 390 +-- truncate_limit: 100 +select * from usersview +-- +TABLE: name="usersview" schema="" table="usersview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM usersview" +== 391 +-- truncate_limit: 100 +-- expect clean failure +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 392 +-- truncate_limit: 100 +drop view usersview +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW usersview" +== 393 +-- truncate_limit: 100 +drop function get_first_user() +-- +FUNCTION: name="get_first_user" function="get_first_user" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION get_first_user()" +== 394 +-- truncate_limit: 100 +drop function get_users() +-- +FUNCTION: name="get_users" function="get_users" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION get_users()" +== 395 +-- truncate_limit: 100 +drop table users +-- +TABLE: name="users" schema="" table="users" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE users" +== 396 +-- truncate_limit: 100 +-- check behavior with type coercion required for a set-op + +create or replace function rngfuncbar() returns setof text as +$$ select 'foo'::varchar union all select 'bar'::varchar ; $$ +language sql stable +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfuncbar() RETURNS SETOF text AS $$ select 'foo'::varchar union all ..." +== 397 +-- truncate_limit: 100 +select rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rngfuncbar()" +== 398 +-- truncate_limit: 100 +select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfuncbar()" +== 399 +-- truncate_limit: 100 +-- this function is now inlinable, too: +explain (verbose, costs off) select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM rngfuncbar()" +== 400 +-- truncate_limit: 100 +drop function rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfuncbar()" +== 401 +-- truncate_limit: 100 +-- check handling of a SQL function with multiple OUT params (bug #5777) + +create or replace function rngfuncbar(out integer, out numeric) as +$$ select (1, 2.1) $$ language sql +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfuncbar(OUT int, OUT numeric) AS $$ select (1, 2.1) $$ LANGUAGE sql" +== 402 +-- truncate_limit: 100 +select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfuncbar()" +== 403 +-- truncate_limit: 100 +create or replace function rngfuncbar(out integer, out numeric) as +$$ select (1, 2) $$ language sql +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfuncbar(OUT int, OUT numeric) AS $$ select (1, 2) $$ LANGUAGE sql" +== 404 +-- truncate_limit: 100 +select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfuncbar()" +== 405 +-- truncate_limit: 100 +-- fail + +create or replace function rngfuncbar(out integer, out numeric) as +$$ select (1, 2.1, 3) $$ language sql +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION rngfuncbar(OUT int, OUT numeric) AS $$ select (1, 2.1, 3) $$ LANGUAGE sql" +== 406 +-- truncate_limit: 100 +select * from rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rngfuncbar()" +== 407 +-- truncate_limit: 100 +-- fail + +drop function rngfuncbar() +-- +FUNCTION: name="rngfuncbar" function="rngfuncbar" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rngfuncbar()" +== 408 +-- truncate_limit: 100 +-- check whole-row-Var handling in nested lateral functions (bug #11703) + +create function extractq2(t int8_tbl) returns int8 as $$ + select t.q2 +$$ language sql immutable +-- +FUNCTION: name="extractq2" function="extractq2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION extractq2(t int8_tbl) RETURNS int8 AS $$\n select t.q2\n$$ LANGUAGE sql IMMUTABLE" +== 409 +-- truncate_limit: 100 +explain (verbose, costs off) +select x from int8_tbl, extractq2(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2" function="extractq2" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT x FROM int8_tbl, extractq2(int8_tbl) f(x)" +== 410 +-- truncate_limit: 100 +select x from int8_tbl, extractq2(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2" function="extractq2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x FROM int8_tbl, extractq2(int8_tbl) f(x)" +== 411 +-- truncate_limit: 100 +create function extractq2_2(t int8_tbl) returns table(ret1 int8) as $$ + select extractq2(t) offset 0 +$$ language sql immutable +-- +FUNCTION: name="extractq2_2" function="extractq2_2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION extractq2_2(t int8_tbl) RETURNS TABLE (ret1 int8) AS $$\n select extractq2(t) off..." +== 412 +-- truncate_limit: 100 +explain (verbose, costs off) +select x from int8_tbl, extractq2_2(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2_2" function="extractq2_2" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT x FROM int8_tbl, extractq2_2(int8_tbl) f(x)" +== 413 +-- truncate_limit: 100 +select x from int8_tbl, extractq2_2(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2_2" function="extractq2_2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x FROM int8_tbl, extractq2_2(int8_tbl) f(x)" +== 414 +-- truncate_limit: 100 +-- without the "offset 0", this function gets optimized quite differently + +create function extractq2_2_opt(t int8_tbl) returns table(ret1 int8) as $$ + select extractq2(t) +$$ language sql immutable +-- +FUNCTION: name="extractq2_2_opt" function="extractq2_2_opt" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION extractq2_2_opt(t int8_tbl) RETURNS TABLE (ret1 int8) AS $$\n select extractq2(t)..." +== 415 +-- truncate_limit: 100 +explain (verbose, costs off) +select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2_2_opt" function="extractq2_2_opt" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT x FROM int8_tbl, extractq2_2_opt(int8_tbl) f(x)" +== 416 +-- truncate_limit: 100 +select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="extractq2_2_opt" function="extractq2_2_opt" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x FROM int8_tbl, extractq2_2_opt(int8_tbl) f(x)" +== 417 +-- truncate_limit: 100 +-- check handling of nulls in SRF results (bug #7808) + +create type rngfunc2 as (a integer, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE rngfunc2 AS (a int, b text)" +== 418 +-- truncate_limit: 100 +select *, row_to_json(u) from unnest(array[(1,'foo')::rngfunc2, null::rngfunc2]) u +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, row_to_json(u) FROM unnest(ARRAY[(1, 'foo')::rngfunc2, NULL::rngfunc2]) u" +== 419 +-- truncate_limit: 100 +select *, row_to_json(u) from unnest(array[null::rngfunc2, null::rngfunc2]) u +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, row_to_json(u) FROM unnest(ARRAY[NULL::rngfunc2, NULL::rngfunc2]) u" +== 420 +-- truncate_limit: 100 +select *, row_to_json(u) from unnest(array[null::rngfunc2, (1,'foo')::rngfunc2, null::rngfunc2]) u +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, row_to_json(u) FROM unnest(ARRAY[NULL::rngfunc2, (1, 'foo')::rngfunc2, NULL::rngfunc2]) u" +== 421 +-- truncate_limit: 100 +select *, row_to_json(u) from unnest(array[]::rngfunc2[]) u +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, row_to_json(u) FROM unnest(ARRAY[]::rngfunc2[]) u" +== 422 +-- truncate_limit: 100 +drop type rngfunc2 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE rngfunc2" +== 423 +-- truncate_limit: 100 +-- check handling of functions pulled up into function RTEs (bug #17227) + +explain (verbose, costs off) +select * from + (select jsonb_path_query_array(module->'lectures', '$[*]') as lecture + from unnest(array['{"lectures": [{"id": "1"}]}'::jsonb]) + as unnested_modules(module)) as ss, + jsonb_to_recordset(ss.lecture) as j (id text) +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="jsonb_to_recordset" function="jsonb_to_recordset" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (SELECT jsonb_path_query_array(module -> 'lectures', '..." +== 424 +-- truncate_limit: 100 +select * from + (select jsonb_path_query_array(module->'lectures', '$[*]') as lecture + from unnest(array['{"lectures": [{"id": "1"}]}'::jsonb]) + as unnested_modules(module)) as ss, + jsonb_to_recordset(ss.lecture) as j (id text) +-- +FUNCTION: name="jsonb_path_query_array" function="jsonb_path_query_array" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="jsonb_to_recordset" function="jsonb_to_recordset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM unnest(ARRAY['{\"lectures\": [{\"id\": \"1\"}]}'::jsonb]) unnested_modul..." +== 425 +-- truncate_limit: 100 +-- check detection of mismatching record types with a const-folded expression + +with a(b) as (values (row(1,2,3))) +select * from a, coalesce(b) as c(d int, e int) +-- +CTE: "a" +STMT: SelectStmt +TRUNCATED: "WITH a(b) AS (VALUES (ROW(1, 2, 3))) SELECT * FROM a, COALESCE(b) c (d int, e int)" +== 426 +-- truncate_limit: 100 +-- fail +with a(b) as (values (row(1,2,3))) +select * from a, coalesce(b) as c(d int, e int, f int, g int) +-- +CTE: "a" +STMT: SelectStmt +TRUNCATED: "WITH a(b) AS (VALUES (ROW(1, 2, 3))) SELECT * FROM a, COALESCE(b) c (d int, e int, f int, g int)" +== 427 +-- truncate_limit: 100 +-- fail +with a(b) as (values (row(1,2,3))) +select * from a, coalesce(b) as c(d int, e int, f float) +-- +CTE: "a" +STMT: SelectStmt +TRUNCATED: "WITH a(b) AS (VALUES (...)) SELECT * FROM a, COALESCE(b) c (d int, e int, f double precision)" +== 428 +-- truncate_limit: 100 +-- fail +select * from int8_tbl, coalesce(row(1)) as (a int, b int) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl, COALESCE(ROW(1)) AS (a int, b int)" diff --git a/parser/testdata/summary_truncate/postgres_regress/rangetypes.metadata.json b/parser/testdata/summary_truncate/postgres_regress/rangetypes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rangetypes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/rangetypes.test b/parser/testdata/summary_truncate/postgres_regress/rangetypes.test new file mode 100644 index 0000000..051c790 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rangetypes.test @@ -0,0 +1,3616 @@ +== 001 +-- truncate_limit: 100 +-- Tests for range data types. + +|-- +-- test input parser +-- (type textrange was already made in test_setup.sql) +|-- + +-- negative tests; should fail +select ''::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::textrange" +== 002 +-- truncate_limit: 100 +select '-[a,z)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-[a,z)'::textrange" +== 003 +-- truncate_limit: 100 +select '[a,z) - '::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[a,z) - '::textrange" +== 004 +-- truncate_limit: 100 +select '(",a)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(\",a)'::textrange" +== 005 +-- truncate_limit: 100 +select '(,,a)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(,,a)'::textrange" +== 006 +-- truncate_limit: 100 +select '(),a)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(),a)'::textrange" +== 007 +-- truncate_limit: 100 +select '(a,))'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(a,))'::textrange" +== 008 +-- truncate_limit: 100 +select '(],a)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(],a)'::textrange" +== 009 +-- truncate_limit: 100 +select '(a,])'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(a,])'::textrange" +== 010 +-- truncate_limit: 100 +select '[z,a]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[z,a]'::textrange" +== 011 +-- truncate_limit: 100 +-- should succeed +select ' empty '::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' empty '::textrange" +== 012 +-- truncate_limit: 100 +select ' ( empty, empty ) '::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' ( empty, empty ) '::textrange" +== 013 +-- truncate_limit: 100 +select ' ( " a " " a ", " z " " z " ) '::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' ( \" a \" \" a \", \" z \" \" z \" ) '::textrange" +== 014 +-- truncate_limit: 100 +select '(a,)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(a,)'::textrange" +== 015 +-- truncate_limit: 100 +select '[,z]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[,z]'::textrange" +== 016 +-- truncate_limit: 100 +select '[a,]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[a,]'::textrange" +== 017 +-- truncate_limit: 100 +select '(,)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(,)'::textrange" +== 018 +-- truncate_limit: 100 +select '[ , ]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[ , ]'::textrange" +== 019 +-- truncate_limit: 100 +select '["",""]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\"\",\"\"]'::textrange" +== 020 +-- truncate_limit: 100 +select '[",",","]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[\",\",\",\"]'::textrange" +== 021 +-- truncate_limit: 100 +select '["\\","\\"]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'[\"\\\\\\\\\",\"\\\\\\\\\"]'::textrange" +== 022 +-- truncate_limit: 100 +select '(\\,a)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'(\\\\\\\\,a)'::textrange" +== 023 +-- truncate_limit: 100 +select '((,z)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '((,z)'::textrange" +== 024 +-- truncate_limit: 100 +select '([,z)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '([,z)'::textrange" +== 025 +-- truncate_limit: 100 +select '(!,()'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(!,()'::textrange" +== 026 +-- truncate_limit: 100 +select '(!,[)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(!,[)'::textrange" +== 027 +-- truncate_limit: 100 +select '[a,a]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[a,a]'::textrange" +== 028 +-- truncate_limit: 100 +-- these are allowed but normalize to empty: +select '[a,a)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[a,a)'::textrange" +== 029 +-- truncate_limit: 100 +select '(a,a]'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(a,a]'::textrange" +== 030 +-- truncate_limit: 100 +select '(a,a)'::textrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(a,a)'::textrange" +== 031 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +select pg_input_is_valid('(1,4)', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1,4)', 'int4range')" +== 032 +-- truncate_limit: 100 +select pg_input_is_valid('(1,4', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1,4', 'int4range')" +== 033 +-- truncate_limit: 100 +select * from pg_input_error_info('(1,4', 'int4range') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(1,4', 'int4range')" +== 034 +-- truncate_limit: 100 +select pg_input_is_valid('(4,1)', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(4,1)', 'int4range')" +== 035 +-- truncate_limit: 100 +select * from pg_input_error_info('(4,1)', 'int4range') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(4,1)', 'int4range')" +== 036 +-- truncate_limit: 100 +select pg_input_is_valid('(4,zed)', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(4,zed)', 'int4range')" +== 037 +-- truncate_limit: 100 +select * from pg_input_error_info('(4,zed)', 'int4range') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(4,zed)', 'int4range')" +== 038 +-- truncate_limit: 100 +select pg_input_is_valid('[1,2147483647]', 'int4range') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('[1,2147483647]', 'int4range')" +== 039 +-- truncate_limit: 100 +select * from pg_input_error_info('[1,2147483647]', 'int4range') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('[1,2147483647]', 'int4range')" +== 040 +-- truncate_limit: 100 +select pg_input_is_valid('[2000-01-01,5874897-12-31]', 'daterange') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('[2000-01-01,5874897-12-31]', 'daterange')" +== 041 +-- truncate_limit: 100 +select * from pg_input_error_info('[2000-01-01,5874897-12-31]', 'daterange') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('[2000-01-01,5874897-12-31]', 'daterange')" +== 042 +-- truncate_limit: 100 +|-- +-- create some test data and test the operators +|-- + +CREATE TABLE numrange_test (nr NUMRANGE) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE numrange_test (nr numrange)" +== 043 +-- truncate_limit: 100 +create index numrange_test_btree on numrange_test(nr) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX numrange_test_btree ON numrange_test USING btree (nr)" +== 044 +-- truncate_limit: 100 +INSERT INTO numrange_test VALUES('[,)') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test VALUES ('[,)')" +== 045 +-- truncate_limit: 100 +INSERT INTO numrange_test VALUES('[3,]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test VALUES ('[3,]')" +== 046 +-- truncate_limit: 100 +INSERT INTO numrange_test VALUES('[, 5)') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test VALUES ('[, 5)')" +== 047 +-- truncate_limit: 100 +INSERT INTO numrange_test VALUES(numrange(1.1, 2.2)) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test VALUES (numrange(1.1, 2.2))" +== 048 +-- truncate_limit: 100 +INSERT INTO numrange_test VALUES('empty') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test VALUES ('empty')" +== 049 +-- truncate_limit: 100 +INSERT INTO numrange_test VALUES(numrange(1.7, 1.7, '[]')) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test VALUES (numrange(1.7, 1.7, '[]'))" +== 050 +-- truncate_limit: 100 +SELECT nr, isempty(nr), lower(nr), upper(nr) FROM numrange_test +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="isempty" function="isempty" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nr, isempty(nr), lower(nr), upper(nr) FROM numrange_test" +== 051 +-- truncate_limit: 100 +SELECT nr, lower_inc(nr), lower_inf(nr), upper_inc(nr), upper_inf(nr) FROM numrange_test +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="lower_inc" function="lower_inc" schema="" ctx=Call +FUNCTION: name="lower_inf" function="lower_inf" schema="" ctx=Call +FUNCTION: name="upper_inc" function="upper_inc" schema="" ctx=Call +FUNCTION: name="upper_inf" function="upper_inf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nr, lower_inc(nr), lower_inf(nr), upper_inc(nr), upper_inf(nr) FROM numrange_test" +== 052 +-- truncate_limit: 100 +SELECT * FROM numrange_test WHERE range_contains(nr, numrange(1.9,1.91)) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_contains" function="range_contains" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="range_contains" function="range_contains" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE range_contains(nr, numrange(1.9, 1.91))" +== 053 +-- truncate_limit: 100 +SELECT * FROM numrange_test WHERE nr @> numrange(1.0,10000.1) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr @> numrange(1.0, 10000.1)" +== 054 +-- truncate_limit: 100 +SELECT * FROM numrange_test WHERE range_contained_by(numrange(-1e7,-10000.1), nr) +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_contained_by" function="range_contained_by" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="range_contained_by" function="range_contained_by" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE range_contained_by(numrange(-1e7, -10000.1), nr)" +== 055 +-- truncate_limit: 100 +SELECT * FROM numrange_test WHERE 1.9 <@ nr +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE 1.9 <@ nr" +== 056 +-- truncate_limit: 100 +select * from numrange_test where nr = 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr = 'empty'" +== 057 +-- truncate_limit: 100 +select * from numrange_test where nr = '(1.1, 2.2)' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr = '(1.1, 2.2)'" +== 058 +-- truncate_limit: 100 +select * from numrange_test where nr = '[1.1, 2.2)' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr = '[1.1, 2.2)'" +== 059 +-- truncate_limit: 100 +select * from numrange_test where nr < 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr < 'empty'" +== 060 +-- truncate_limit: 100 +select * from numrange_test where nr < numrange(-1000.0, -1000.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr < numrange(-1000.0, -1000.0, '[]')" +== 061 +-- truncate_limit: 100 +select * from numrange_test where nr < numrange(0.0, 1.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr < numrange(0.0, 1.0, '[]')" +== 062 +-- truncate_limit: 100 +select * from numrange_test where nr < numrange(1000.0, 1001.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr < numrange(1000.0, 1001.0, '[]')" +== 063 +-- truncate_limit: 100 +select * from numrange_test where nr <= 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr <= 'empty'" +== 064 +-- truncate_limit: 100 +select * from numrange_test where nr >= 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr >= 'empty'" +== 065 +-- truncate_limit: 100 +select * from numrange_test where nr > 'empty' +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr > 'empty'" +== 066 +-- truncate_limit: 100 +select * from numrange_test where nr > numrange(-1001.0, -1000.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr > numrange(-1001.0, -1000.0, '[]')" +== 067 +-- truncate_limit: 100 +select * from numrange_test where nr > numrange(0.0, 1.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr > numrange(0.0, 1.0, '[]')" +== 068 +-- truncate_limit: 100 +select * from numrange_test where nr > numrange(1000.0, 1000.0,'[]') +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test WHERE nr > numrange(1000.0, 1000.0, '[]')" +== 069 +-- truncate_limit: 100 +select numrange(2.0, 1.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(2.0, 1.0)" +== 070 +-- truncate_limit: 100 +select numrange(2.0, 3.0) -|- numrange(3.0, 4.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(2.0, 3.0) -|- numrange(3.0, 4.0)" +== 071 +-- truncate_limit: 100 +select range_adjacent(numrange(2.0, 3.0), numrange(3.1, 4.0)) +-- +FUNCTION: name="range_adjacent" function="range_adjacent" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_adjacent(numrange(2.0, 3.0), numrange(3.1, 4.0))" +== 072 +-- truncate_limit: 100 +select range_adjacent(numrange(2.0, 3.0), numrange(3.1, null)) +-- +FUNCTION: name="range_adjacent" function="range_adjacent" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_adjacent(numrange(2.0, 3.0), numrange(3.1, NULL))" +== 073 +-- truncate_limit: 100 +select numrange(2.0, 3.0, '[]') -|- numrange(3.0, 4.0, '()') +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(2.0, 3.0, '[]') -|- numrange(3.0, 4.0, '()')" +== 074 +-- truncate_limit: 100 +select numrange(1.0, 2.0) -|- numrange(2.0, 3.0,'[]') +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) -|- numrange(2.0, 3.0, '[]')" +== 075 +-- truncate_limit: 100 +select range_adjacent(numrange(2.0, 3.0, '(]'), numrange(1.0, 2.0, '(]')) +-- +FUNCTION: name="range_adjacent" function="range_adjacent" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_adjacent(numrange(2.0, 3.0, '(]'), numrange(1.0, 2.0, '(]'))" +== 076 +-- truncate_limit: 100 +select numrange(1.1, 3.3) <@ numrange(0.1,10.1) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.1, 3.3) <@ numrange(0.1, 10.1)" +== 077 +-- truncate_limit: 100 +select numrange(0.1, 10.1) <@ numrange(1.1,3.3) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(0.1, 10.1) <@ numrange(1.1, 3.3)" +== 078 +-- truncate_limit: 100 +select numrange(1.1, 2.2) - numrange(2.0, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.1, 2.2) - numrange(2.0, 3.0)" +== 079 +-- truncate_limit: 100 +select numrange(1.1, 2.2) - numrange(2.2, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.1, 2.2) - numrange(2.2, 3.0)" +== 080 +-- truncate_limit: 100 +select numrange(1.1, 2.2,'[]') - numrange(2.0, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.1, 2.2, '[]') - numrange(2.0, 3.0)" +== 081 +-- truncate_limit: 100 +select range_minus(numrange(10.1,12.2,'[]'), numrange(110.0,120.2,'(]')) +-- +FUNCTION: name="range_minus" function="range_minus" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_minus(numrange(10.1, 12.2, '[]'), numrange(110.0, 120.2, '(]'))" +== 082 +-- truncate_limit: 100 +select range_minus(numrange(10.1,12.2,'[]'), numrange(0.0,120.2,'(]')) +-- +FUNCTION: name="range_minus" function="range_minus" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_minus(numrange(10.1, 12.2, '[]'), numrange(0.0, 120.2, '(]'))" +== 083 +-- truncate_limit: 100 +select numrange(4.5, 5.5, '[]') && numrange(5.5, 6.5) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(4.5, 5.5, '[]') && numrange(5.5, 6.5)" +== 084 +-- truncate_limit: 100 +select numrange(1.0, 2.0) << numrange(3.0, 4.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) << numrange(3.0, 4.0)" +== 085 +-- truncate_limit: 100 +select numrange(1.0, 3.0,'[]') << numrange(3.0, 4.0,'[]') +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 3.0, '[]') << numrange(3.0, 4.0, '[]')" +== 086 +-- truncate_limit: 100 +select numrange(1.0, 3.0,'()') << numrange(3.0, 4.0,'()') +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 3.0, '()') << numrange(3.0, 4.0, '()')" +== 087 +-- truncate_limit: 100 +select numrange(1.0, 2.0) >> numrange(3.0, 4.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) >> numrange(3.0, 4.0)" +== 088 +-- truncate_limit: 100 +select numrange(3.0, 70.0) &< numrange(6.6, 100.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(3.0, 70.0) &< numrange(6.6, 100.0)" +== 089 +-- truncate_limit: 100 +select numrange(1.1, 2.2) < numrange(1.0, 200.2) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.1, 2.2) < numrange(1.0, 200.2)" +== 090 +-- truncate_limit: 100 +select numrange(1.1, 2.2) < numrange(1.1, 1.2) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.1, 2.2) < numrange(1.1, 1.2)" +== 091 +-- truncate_limit: 100 +select numrange(1.0, 2.0) + numrange(2.0, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) + numrange(2.0, 3.0)" +== 092 +-- truncate_limit: 100 +select numrange(1.0, 2.0) + numrange(1.5, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) + numrange(1.5, 3.0)" +== 093 +-- truncate_limit: 100 +select numrange(1.0, 2.0) + numrange(2.5, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) + numrange(2.5, 3.0)" +== 094 +-- truncate_limit: 100 +-- should fail + +select range_merge(numrange(1.0, 2.0), numrange(2.0, 3.0)) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_merge(numrange(1.0, 2.0), numrange(2.0, 3.0))" +== 095 +-- truncate_limit: 100 +select range_merge(numrange(1.0, 2.0), numrange(1.5, 3.0)) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_merge(numrange(1.0, 2.0), numrange(1.5, 3.0))" +== 096 +-- truncate_limit: 100 +select range_merge(numrange(1.0, 2.0), numrange(2.5, 3.0)) +-- +FUNCTION: name="range_merge" function="range_merge" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_merge(numrange(1.0, 2.0), numrange(2.5, 3.0))" +== 097 +-- truncate_limit: 100 +-- shouldn't fail + +select numrange(1.0, 2.0) * numrange(2.0, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) * numrange(2.0, 3.0)" +== 098 +-- truncate_limit: 100 +select numrange(1.0, 2.0) * numrange(1.5, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) * numrange(1.5, 3.0)" +== 099 +-- truncate_limit: 100 +select numrange(1.0, 2.0) * numrange(2.5, 3.0) +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numrange(1.0, 2.0) * numrange(2.5, 3.0)" +== 100 +-- truncate_limit: 100 +select range_intersect_agg(nr) from numrange_test +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nr) FROM numrange_test" +== 101 +-- truncate_limit: 100 +select range_intersect_agg(nr) from numrange_test where false +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nr) FROM numrange_test WHERE false" +== 102 +-- truncate_limit: 100 +select range_intersect_agg(nr) from numrange_test where nr @> 4.0 +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +FUNCTION: name="range_intersect_agg" function="range_intersect_agg" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT range_intersect_agg(nr) FROM numrange_test WHERE nr @> 4.0" +== 103 +-- truncate_limit: 100 +analyze numrange_test +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE numrange_test" +== 104 +-- truncate_limit: 100 +create table numrange_test2(nr numrange) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE numrange_test2 (nr numrange)" +== 105 +-- truncate_limit: 100 +create index numrange_test2_hash_idx on numrange_test2 using hash (nr) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX numrange_test2_hash_idx ON numrange_test2 USING hash (nr)" +== 106 +-- truncate_limit: 100 +INSERT INTO numrange_test2 VALUES('[, 5)') +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test2 VALUES ('[, 5)')" +== 107 +-- truncate_limit: 100 +INSERT INTO numrange_test2 VALUES(numrange(1.1, 2.2)) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test2 VALUES (numrange(1.1, 2.2))" +== 108 +-- truncate_limit: 100 +INSERT INTO numrange_test2 VALUES(numrange(1.1, 2.2)) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test2 VALUES (numrange(1.1, 2.2))" +== 109 +-- truncate_limit: 100 +INSERT INTO numrange_test2 VALUES(numrange(1.1, 2.2,'()')) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test2 VALUES (numrange(1.1, 2.2, '()'))" +== 110 +-- truncate_limit: 100 +INSERT INTO numrange_test2 VALUES('empty') +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numrange_test2 VALUES ('empty')" +== 111 +-- truncate_limit: 100 +select * from numrange_test2 where nr = 'empty'::numrange +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test2 WHERE nr = 'empty'::numrange" +== 112 +-- truncate_limit: 100 +select * from numrange_test2 where nr = numrange(1.1, 2.2) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test2 WHERE nr = numrange(1.1, 2.2)" +== 113 +-- truncate_limit: 100 +select * from numrange_test2 where nr = numrange(1.1, 2.3) +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test2 WHERE nr = numrange(1.1, 2.3)" +== 114 +-- truncate_limit: 100 +set enable_nestloop=t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO t" +== 115 +-- truncate_limit: 100 +set enable_hashjoin=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO f" +== 116 +-- truncate_limit: 100 +set enable_mergejoin=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO f" +== 117 +-- truncate_limit: 100 +select * from numrange_test natural join numrange_test2 order by nr +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test NATURAL JOIN numrange_test2 ORDER BY nr" +== 118 +-- truncate_limit: 100 +set enable_nestloop=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO f" +== 119 +-- truncate_limit: 100 +set enable_hashjoin=t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO t" +== 120 +-- truncate_limit: 100 +set enable_mergejoin=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO f" +== 121 +-- truncate_limit: 100 +select * from numrange_test natural join numrange_test2 order by nr +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test NATURAL JOIN numrange_test2 ORDER BY nr" +== 122 +-- truncate_limit: 100 +set enable_nestloop=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO f" +== 123 +-- truncate_limit: 100 +set enable_hashjoin=f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO f" +== 124 +-- truncate_limit: 100 +set enable_mergejoin=t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO t" +== 125 +-- truncate_limit: 100 +select * from numrange_test natural join numrange_test2 order by nr +-- +TABLE: name="numrange_test" schema="" table="numrange_test" ctx=Select +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numrange_test NATURAL JOIN numrange_test2 ORDER BY nr" +== 126 +-- truncate_limit: 100 +set enable_nestloop to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO DEFAULT" +== 127 +-- truncate_limit: 100 +set enable_hashjoin to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO DEFAULT" +== 128 +-- truncate_limit: 100 +set enable_mergejoin to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO DEFAULT" +== 129 +-- truncate_limit: 100 +-- keep numrange_test around to help exercise dump/reload +DROP TABLE numrange_test2 +-- +TABLE: name="numrange_test2" schema="" table="numrange_test2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE numrange_test2" +== 130 +-- truncate_limit: 100 +|-- +-- Apply a subset of the above tests on a collatable type, too +|-- + +CREATE TABLE textrange_test (tr textrange) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE textrange_test (tr textrange)" +== 131 +-- truncate_limit: 100 +create index textrange_test_btree on textrange_test(tr) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX textrange_test_btree ON textrange_test USING btree (tr)" +== 132 +-- truncate_limit: 100 +INSERT INTO textrange_test VALUES('[,)') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO textrange_test VALUES ('[,)')" +== 133 +-- truncate_limit: 100 +INSERT INTO textrange_test VALUES('["a",]') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO textrange_test VALUES ('[\"a\",]')" +== 134 +-- truncate_limit: 100 +INSERT INTO textrange_test VALUES('[,"q")') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO textrange_test VALUES ('[,\"q\")')" +== 135 +-- truncate_limit: 100 +INSERT INTO textrange_test VALUES(textrange('b', 'g')) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO textrange_test VALUES (textrange('b', 'g'))" +== 136 +-- truncate_limit: 100 +INSERT INTO textrange_test VALUES('empty') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO textrange_test VALUES ('empty')" +== 137 +-- truncate_limit: 100 +INSERT INTO textrange_test VALUES(textrange('d', 'd', '[]')) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=DML +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO textrange_test VALUES (textrange('d', 'd', '[]'))" +== 138 +-- truncate_limit: 100 +SELECT tr, isempty(tr), lower(tr), upper(tr) FROM textrange_test +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="isempty" function="isempty" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tr, isempty(tr), lower(tr), upper(tr) FROM textrange_test" +== 139 +-- truncate_limit: 100 +SELECT tr, lower_inc(tr), lower_inf(tr), upper_inc(tr), upper_inf(tr) FROM textrange_test +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="lower_inc" function="lower_inc" schema="" ctx=Call +FUNCTION: name="lower_inf" function="lower_inf" schema="" ctx=Call +FUNCTION: name="upper_inc" function="upper_inc" schema="" ctx=Call +FUNCTION: name="upper_inf" function="upper_inf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tr, lower_inc(tr), lower_inf(tr), upper_inc(tr), upper_inf(tr) FROM textrange_test" +== 140 +-- truncate_limit: 100 +SELECT * FROM textrange_test WHERE range_contains(tr, textrange('f', 'fx')) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="range_contains" function="range_contains" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="range_contains" function="range_contains" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM textrange_test WHERE range_contains(tr, textrange('f', 'fx'))" +== 141 +-- truncate_limit: 100 +SELECT * FROM textrange_test WHERE tr @> textrange('a', 'z') +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM textrange_test WHERE tr @> textrange('a', 'z')" +== 142 +-- truncate_limit: 100 +SELECT * FROM textrange_test WHERE range_contained_by(textrange('0','9'), tr) +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FUNCTION: name="range_contained_by" function="range_contained_by" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FUNCTION: name="range_contained_by" function="range_contained_by" schema="" ctx=Call +FUNCTION: name="textrange" function="textrange" schema="" ctx=Call +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM textrange_test WHERE range_contained_by(textrange('0', '9'), tr)" +== 143 +-- truncate_limit: 100 +SELECT * FROM textrange_test WHERE 'e'::text <@ tr +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM textrange_test WHERE 'e'::text <@ tr" +== 144 +-- truncate_limit: 100 +select * from textrange_test where tr = 'empty' +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM textrange_test WHERE tr = 'empty'" +== 145 +-- truncate_limit: 100 +select * from textrange_test where tr = '("b","g")' +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM textrange_test WHERE tr = '(\"b\",\"g\")'" +== 146 +-- truncate_limit: 100 +select * from textrange_test where tr = '["b","g")' +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM textrange_test WHERE tr = '[\"b\",\"g\")'" +== 147 +-- truncate_limit: 100 +select * from textrange_test where tr < 'empty' +-- +TABLE: name="textrange_test" schema="" table="textrange_test" ctx=Select +FILTER: schema="" table="" column="tr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM textrange_test WHERE tr < 'empty'" +== 148 +-- truncate_limit: 100 +-- test canonical form for int4range +select int4range(1, 10, '[]') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4range(1, 10, '[]')" +== 149 +-- truncate_limit: 100 +select int4range(1, 10, '[)') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4range(1, 10, '[)')" +== 150 +-- truncate_limit: 100 +select int4range(1, 10, '(]') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4range(1, 10, '(]')" +== 151 +-- truncate_limit: 100 +select int4range(1, 10, '()') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4range(1, 10, '()')" +== 152 +-- truncate_limit: 100 +select int4range(1, 2, '()') +-- +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4range(1, 2, '()')" +== 153 +-- truncate_limit: 100 +-- test canonical form for daterange +select daterange('2000-01-10'::date, '2000-01-20'::date, '[]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('2000-01-10'::date, '2000-01-20'::date, '[]')" +== 154 +-- truncate_limit: 100 +select daterange('2000-01-10'::date, '2000-01-20'::date, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('2000-01-10'::date, '2000-01-20'::date, '[)')" +== 155 +-- truncate_limit: 100 +select daterange('2000-01-10'::date, '2000-01-20'::date, '(]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('2000-01-10'::date, '2000-01-20'::date, '(]')" +== 156 +-- truncate_limit: 100 +select daterange('2000-01-10'::date, '2000-01-20'::date, '()') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('2000-01-10'::date, '2000-01-20'::date, '()')" +== 157 +-- truncate_limit: 100 +select daterange('2000-01-10'::date, '2000-01-11'::date, '()') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('2000-01-10'::date, '2000-01-11'::date, '()')" +== 158 +-- truncate_limit: 100 +select daterange('2000-01-10'::date, '2000-01-11'::date, '(]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('2000-01-10'::date, '2000-01-11'::date, '(]')" +== 159 +-- truncate_limit: 100 +select daterange('-infinity'::date, '2000-01-01'::date, '()') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('-infinity'::date, '2000-01-01'::date, '()')" +== 160 +-- truncate_limit: 100 +select daterange('-infinity'::date, '2000-01-01'::date, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('-infinity'::date, '2000-01-01'::date, '[)')" +== 161 +-- truncate_limit: 100 +select daterange('2000-01-01'::date, 'infinity'::date, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('2000-01-01'::date, 'infinity'::date, '[)')" +== 162 +-- truncate_limit: 100 +select daterange('2000-01-01'::date, 'infinity'::date, '[]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT daterange('2000-01-01'::date, 'infinity'::date, '[]')" +== 163 +-- truncate_limit: 100 +-- test GiST index that's been built incrementally +create table test_range_gist(ir int4range) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_range_gist (ir int4range)" +== 164 +-- truncate_limit: 100 +create index test_range_gist_idx on test_range_gist using gist (ir) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_range_gist_idx ON test_range_gist USING gist (ir)" +== 165 +-- truncate_limit: 100 +insert into test_range_gist select int4range(g, g+10) from generate_series(1,2000) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_gist SELECT int4range(g, g + 10) FROM generate_series(1, 2000) g" +== 166 +-- truncate_limit: 100 +insert into test_range_gist select 'empty'::int4range from generate_series(1,500) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_gist SELECT 'empty'::int4range FROM generate_series(1, 500) g" +== 167 +-- truncate_limit: 100 +insert into test_range_gist select int4range(g, g+10000) from generate_series(1,1000) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_gist SELECT int4range(g, g + 10000) FROM generate_series(1, 1000) g" +== 168 +-- truncate_limit: 100 +insert into test_range_gist select 'empty'::int4range from generate_series(1,500) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_gist SELECT 'empty'::int4range FROM generate_series(1, 500) g" +== 169 +-- truncate_limit: 100 +insert into test_range_gist select int4range(NULL,g*10,'(]') from generate_series(1,100) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_gist SELECT int4range(NULL, g * 10, '(]') FROM generate_series(1, 100) g" +== 170 +-- truncate_limit: 100 +insert into test_range_gist select int4range(g*10,NULL,'(]') from generate_series(1,100) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_gist SELECT int4range(g * 10, NULL, '(]') FROM generate_series(1, 100) g" +== 171 +-- truncate_limit: 100 +insert into test_range_gist select int4range(g, g+10) from generate_series(1,2000) g +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_gist SELECT int4range(g, g + 10) FROM generate_series(1, 2000) g" +== 172 +-- truncate_limit: 100 +-- test statistics and selectivity estimation as well +|-- +-- We don't check the accuracy of selectivity estimation, but at least check +-- it doesn't fall. +analyze test_range_gist +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE test_range_gist" +== 173 +-- truncate_limit: 100 +-- first, verify non-indexed results +SET enable_seqscan = t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO t" +== 174 +-- truncate_limit: 100 +SET enable_indexscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO f" +== 175 +-- truncate_limit: 100 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO f" +== 176 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> 'empty'::int4range" +== 177 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir = int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir = int4range(10, 20)" +== 178 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> 10 +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> 10" +== 179 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> int4range(10, 20)" +== 180 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir && int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir && int4range(10, 20)" +== 181 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir <@ int4range(10, 50)" +== 182 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir << int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir << int4range(100, 500)" +== 183 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir >> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir >> int4range(100, 500)" +== 184 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &< int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir &< int4range(100, 500)" +== 185 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir &> int4range(100, 500)" +== 186 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir -|- int4range(100, 500)" +== 187 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> '{}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> '{}'::int4multirange" +== 188 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 189 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir && '{(10,20),(30,40),(50,60)}'::int4multirange" +== 190 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange" +== 191 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 192 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 193 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 194 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 195 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 196 +-- truncate_limit: 100 +-- now check same queries using index +SET enable_seqscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO f" +== 197 +-- truncate_limit: 100 +SET enable_indexscan = t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO t" +== 198 +-- truncate_limit: 100 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO f" +== 199 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> 'empty'::int4range" +== 200 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir = int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir = int4range(10, 20)" +== 201 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> 10 +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> 10" +== 202 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> int4range(10, 20)" +== 203 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir && int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir && int4range(10, 20)" +== 204 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir <@ int4range(10, 50)" +== 205 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir << int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir << int4range(100, 500)" +== 206 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir >> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir >> int4range(100, 500)" +== 207 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &< int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir &< int4range(100, 500)" +== 208 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir &> int4range(100, 500)" +== 209 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir -|- int4range(100, 500)" +== 210 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> '{}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> '{}'::int4multirange" +== 211 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 212 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir && '{(10,20),(30,40),(50,60)}'::int4multirange" +== 213 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange" +== 214 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 215 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 216 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 217 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 218 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 219 +-- truncate_limit: 100 +-- now check same queries using a bulk-loaded index +drop index test_range_gist_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX test_range_gist_idx" +== 220 +-- truncate_limit: 100 +create index test_range_gist_idx on test_range_gist using gist (ir) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_range_gist_idx ON test_range_gist USING gist (ir)" +== 221 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> 'empty'::int4range" +== 222 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir = int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir = int4range(10, 20)" +== 223 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> 10 +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> 10" +== 224 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> int4range(10, 20)" +== 225 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir && int4range(10,20) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir && int4range(10, 20)" +== 226 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir <@ int4range(10, 50)" +== 227 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir << int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir << int4range(100, 500)" +== 228 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir >> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir >> int4range(100, 500)" +== 229 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &< int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir &< int4range(100, 500)" +== 230 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &> int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir &> int4range(100, 500)" +== 231 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir -|- int4range(100, 500)" +== 232 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> '{}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir @> '{}'::int4multirange" +== 233 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir @> int4multirange(int4range(10,20), int4range(30,40)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 234 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir && '{(10,20),(30,40),(50,60)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir && '{(10,20),(30,40),(50,60)}'::int4multirange" +== 235 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ir <@ '{(10,30),(40,60),(70,90)}'::int4multirange" +== 236 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir << int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 237 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir >> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 238 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &< int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 239 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir &> int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 240 +-- truncate_limit: 100 +select count(*) from test_range_gist where ir -|- int4multirange(int4range(100,200), int4range(400,500)) +-- +TABLE: name="test_range_gist" schema="" table="test_range_gist" ctx=Select +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4multirange" function="int4multirange" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_gist WHERE ..." +== 241 +-- truncate_limit: 100 +-- test SP-GiST index that's been built incrementally +create table test_range_spgist(ir int4range) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_range_spgist (ir int4range)" +== 242 +-- truncate_limit: 100 +create index test_range_spgist_idx on test_range_spgist using spgist (ir) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_range_spgist_idx ON test_range_spgist USING spgist (ir)" +== 243 +-- truncate_limit: 100 +insert into test_range_spgist select int4range(g, g+10) from generate_series(1,2000) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_spgist SELECT int4range(g, g + 10) FROM generate_series(1, 2000) g" +== 244 +-- truncate_limit: 100 +insert into test_range_spgist select 'empty'::int4range from generate_series(1,500) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_spgist SELECT 'empty'::int4range FROM generate_series(1, 500) g" +== 245 +-- truncate_limit: 100 +insert into test_range_spgist select int4range(g, g+10000) from generate_series(1,1000) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_spgist SELECT int4range(g, g + 10000) FROM generate_series(1, 1000) g" +== 246 +-- truncate_limit: 100 +insert into test_range_spgist select 'empty'::int4range from generate_series(1,500) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_spgist SELECT 'empty'::int4range FROM generate_series(1, 500) g" +== 247 +-- truncate_limit: 100 +insert into test_range_spgist select int4range(NULL,g*10,'(]') from generate_series(1,100) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_spgist SELECT int4range(NULL, g * 10, '(]') FROM generate_series(1, 100) g" +== 248 +-- truncate_limit: 100 +insert into test_range_spgist select int4range(g*10,NULL,'(]') from generate_series(1,100) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_spgist SELECT int4range(g * 10, NULL, '(]') FROM generate_series(1, 100) g" +== 249 +-- truncate_limit: 100 +insert into test_range_spgist select int4range(g, g+10) from generate_series(1,2000) g +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_spgist SELECT int4range(g, g + 10) FROM generate_series(1, 2000) g" +== 250 +-- truncate_limit: 100 +-- first, verify non-indexed results +SET enable_seqscan = t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO t" +== 251 +-- truncate_limit: 100 +SET enable_indexscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO f" +== 252 +-- truncate_limit: 100 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO f" +== 253 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> 'empty'::int4range" +== 254 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir = int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir = int4range(10, 20)" +== 255 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> 10 +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> 10" +== 256 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> int4range(10, 20)" +== 257 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir && int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir && int4range(10, 20)" +== 258 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir <@ int4range(10, 50)" +== 259 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir << int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir << int4range(100, 500)" +== 260 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir >> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir >> int4range(100, 500)" +== 261 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir &< int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir &< int4range(100, 500)" +== 262 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir &> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir &> int4range(100, 500)" +== 263 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir -|- int4range(100, 500)" +== 264 +-- truncate_limit: 100 +-- now check same queries using index +SET enable_seqscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO f" +== 265 +-- truncate_limit: 100 +SET enable_indexscan = t +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO t" +== 266 +-- truncate_limit: 100 +SET enable_bitmapscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO f" +== 267 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> 'empty'::int4range" +== 268 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir = int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir = int4range(10, 20)" +== 269 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> 10 +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> 10" +== 270 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> int4range(10, 20)" +== 271 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir && int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir && int4range(10, 20)" +== 272 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir <@ int4range(10, 50)" +== 273 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir << int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir << int4range(100, 500)" +== 274 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir >> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir >> int4range(100, 500)" +== 275 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir &< int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir &< int4range(100, 500)" +== 276 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir &> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir &> int4range(100, 500)" +== 277 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir -|- int4range(100, 500)" +== 278 +-- truncate_limit: 100 +-- now check same queries using a bulk-loaded index +drop index test_range_spgist_idx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX test_range_spgist_idx" +== 279 +-- truncate_limit: 100 +create index test_range_spgist_idx on test_range_spgist using spgist (ir) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_range_spgist_idx ON test_range_spgist USING spgist (ir)" +== 280 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> 'empty'::int4range +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> 'empty'::int4range" +== 281 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir = int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir = int4range(10, 20)" +== 282 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> 10 +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> 10" +== 283 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir @> int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir @> int4range(10, 20)" +== 284 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir && int4range(10,20) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir && int4range(10, 20)" +== 285 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir <@ int4range(10,50) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir <@ int4range(10, 50)" +== 286 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir << int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir << int4range(100, 500)" +== 287 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir >> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir >> int4range(100, 500)" +== 288 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir &< int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir &< int4range(100, 500)" +== 289 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir &> int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir &> int4range(100, 500)" +== 290 +-- truncate_limit: 100 +select count(*) from test_range_spgist where ir -|- int4range(100,500) +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_spgist WHERE ir -|- int4range(100, 500)" +== 291 +-- truncate_limit: 100 +-- test index-only scans +explain (costs off) +select ir from test_range_spgist where ir -|- int4range(10,20) order by ir +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ir FROM test_range_spgist WHERE ir -|- int4range(10, 20) ORDER BY ir" +== 292 +-- truncate_limit: 100 +select ir from test_range_spgist where ir -|- int4range(10,20) order by ir +-- +TABLE: name="test_range_spgist" schema="" table="test_range_spgist" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="ir" +STMT: SelectStmt +TRUNCATED: "SELECT ir FROM test_range_spgist WHERE ir -|- int4range(10, 20) ORDER BY ir" +== 293 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 294 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 295 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 296 +-- truncate_limit: 100 +-- test elem <@ range operator +create table test_range_elem(i int4) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_range_elem (i int4)" +== 297 +-- truncate_limit: 100 +create index test_range_elem_idx on test_range_elem (i) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_range_elem_idx ON test_range_elem USING btree (i)" +== 298 +-- truncate_limit: 100 +insert into test_range_elem select i from generate_series(1,100) i +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_elem SELECT i FROM generate_series(1, 100) i" +== 299 +-- truncate_limit: 100 +SET enable_seqscan = f +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO f" +== 300 +-- truncate_limit: 100 +select count(*) from test_range_elem where i <@ int4range(10,50) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_elem WHERE i <@ int4range(10, 50)" +== 301 +-- truncate_limit: 100 +-- also test spgist index on anyrange expression +create index on test_range_elem using spgist(int4range(i,i+10)) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DDL +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_range_elem USING spgist (int4range(i, i + 10))" +== 302 +-- truncate_limit: 100 +explain (costs off) +select count(*) from test_range_elem where int4range(i,i+10) <@ int4range(10,30) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_range_elem WHERE int4range(i, i + 10) <@ int4range(..." +== 303 +-- truncate_limit: 100 +select count(*) from test_range_elem where int4range(i,i+10) <@ int4range(10,30) +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=Select +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_range_elem WHERE int4range(i, i + 10) <@ int4range(10, 30)" +== 304 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 305 +-- truncate_limit: 100 +drop table test_range_elem +-- +TABLE: name="test_range_elem" schema="" table="test_range_elem" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_range_elem" +== 306 +-- truncate_limit: 100 +|-- +-- Btree_gist is not included by default, so to test exclusion +-- constraints with range types, use singleton int ranges for the "=" +-- portion of the constraint. +|-- + +create table test_range_excl( + room int4range, + speaker int4range, + during tsrange, + exclude using gist (room with =, during with &&), + exclude using gist (speaker with =, during with &&) +) +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_range_excl (room int4range, speaker int4range, during tsrange, EXCLUDE USING gi..." +== 307 +-- truncate_limit: 100 +insert into test_range_excl + values(int4range(123, 123, '[]'), int4range(1, 1, '[]'), '[2010-01-02 10:00, 2010-01-02 11:00)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_excl VALUES (...)" +== 308 +-- truncate_limit: 100 +insert into test_range_excl + values(int4range(123, 123, '[]'), int4range(2, 2, '[]'), '[2010-01-02 11:00, 2010-01-02 12:00)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_excl VALUES (...)" +== 309 +-- truncate_limit: 100 +insert into test_range_excl + values(int4range(123, 123, '[]'), int4range(3, 3, '[]'), '[2010-01-02 10:10, 2010-01-02 11:00)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_excl VALUES (...)" +== 310 +-- truncate_limit: 100 +insert into test_range_excl + values(int4range(124, 124, '[]'), int4range(3, 3, '[]'), '[2010-01-02 10:10, 2010-01-02 11:10)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_excl VALUES (...)" +== 311 +-- truncate_limit: 100 +insert into test_range_excl + values(int4range(125, 125, '[]'), int4range(1, 1, '[]'), '[2010-01-02 10:10, 2010-01-02 11:00)') +-- +TABLE: name="test_range_excl" schema="" table="test_range_excl" ctx=DML +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_range_excl VALUES (...)" +== 312 +-- truncate_limit: 100 +-- test bigint ranges +select int8range(10000000000::int8, 20000000000::int8,'(]') +-- +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int8range((10000000000)::int8, (20000000000)::int8, '(]')" +== 313 +-- truncate_limit: 100 +-- test tstz ranges +set timezone to '-08' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-08\"" +== 314 +-- truncate_limit: 100 +select '[2010-01-01 01:00:00 -05, 2010-01-01 02:00:00 -08)'::tstzrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[2010-01-01 01:00:00 -05, 2010-01-01 02:00:00 -08)'::tstzrange" +== 315 +-- truncate_limit: 100 +-- should fail +select '[2010-01-01 01:00:00 -08, 2010-01-01 02:00:00 -05)'::tstzrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[2010-01-01 01:00:00 -08, 2010-01-01 02:00:00 -05)'::tstzrange" +== 316 +-- truncate_limit: 100 +set timezone to default +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO DEFAULT" +== 317 +-- truncate_limit: 100 +|-- +-- Test user-defined range of floats +-- (type float8range was already made in test_setup.sql) +|-- + +--should fail +create type bogus_float8range as range (subtype=float8, subtype_diff=float4mi) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE bogus_float8range AS RANGE (subtype = float8, subtype_diff = float4mi)" +== 318 +-- truncate_limit: 100 +select '[123.001, 5.e9)'::float8range @> 888.882::float8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[123.001, 5.e9)'::float8range @> (888.882)::float8" +== 319 +-- truncate_limit: 100 +create table float8range_test(f8r float8range, i int) +-- +TABLE: name="float8range_test" schema="" table="float8range_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE float8range_test (f8r float8range, i int)" +== 320 +-- truncate_limit: 100 +insert into float8range_test values(float8range(-100.00007, '1.111113e9'), 42) +-- +TABLE: name="float8range_test" schema="" table="float8range_test" ctx=DML +FUNCTION: name="float8range" function="float8range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8range_test VALUES (float8range(-100.00007, '1.111113e9'), 42)" +== 321 +-- truncate_limit: 100 +select * from float8range_test +-- +TABLE: name="float8range_test" schema="" table="float8range_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float8range_test" +== 322 +-- truncate_limit: 100 +drop table float8range_test +-- +TABLE: name="float8range_test" schema="" table="float8range_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE float8range_test" +== 323 +-- truncate_limit: 100 +|-- +-- Test range types over domains +|-- + +create domain mydomain as int4 +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN mydomain AS int4" +== 324 +-- truncate_limit: 100 +create type mydomainrange as range(subtype=mydomain) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE mydomainrange AS RANGE (subtype = mydomain)" +== 325 +-- truncate_limit: 100 +select '[4,50)'::mydomainrange @> 7::mydomain +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[4,50)'::mydomainrange @> 7::mydomain" +== 326 +-- truncate_limit: 100 +drop domain mydomain +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN mydomain" +== 327 +-- truncate_limit: 100 +-- fail +drop domain mydomain cascade +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN mydomain CASCADE" +== 328 +-- truncate_limit: 100 +|-- +-- Test domains over range types +|-- + +create domain restrictedrange as int4range check (upper(value) < 10) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN restrictedrange AS int4range CHECK (upper(value) < 10)" +== 329 +-- truncate_limit: 100 +select '[4,5)'::restrictedrange @> 7 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[4,5)'::restrictedrange @> 7" +== 330 +-- truncate_limit: 100 +select '[4,50)'::restrictedrange @> 7 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[4,50)'::restrictedrange @> 7" +== 331 +-- truncate_limit: 100 +-- should fail +drop domain restrictedrange +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN restrictedrange" +== 332 +-- truncate_limit: 100 +|-- +-- Test multiple range types over the same subtype +|-- + +create type textrange1 as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange1 AS RANGE (subtype = text, \"collation\" = \"C\")" +== 333 +-- truncate_limit: 100 +create type textrange2 as range(subtype=text, collation="C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange2 AS RANGE (subtype = text, \"collation\" = \"C\")" +== 334 +-- truncate_limit: 100 +select textrange1('a','Z') @> 'b'::text +-- +FUNCTION: name="textrange1" function="textrange1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange1('a', 'Z') @> 'b'::text" +== 335 +-- truncate_limit: 100 +select textrange2('a','z') @> 'b'::text +-- +FUNCTION: name="textrange2" function="textrange2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT textrange2('a', 'z') @> 'b'::text" +== 336 +-- truncate_limit: 100 +drop type textrange1 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange1" +== 337 +-- truncate_limit: 100 +drop type textrange2 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange2" +== 338 +-- truncate_limit: 100 +|-- +-- Test polymorphic type system +|-- + +create function anyarray_anyrange_func(a anyarray, r anyrange) + returns anyelement as 'select $1[1] + lower($2);' language sql +-- +FUNCTION: name="anyarray_anyrange_func" function="anyarray_anyrange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anyarray_anyrange_func(a anyarray, r anyrange) RETURNS anyelement AS $$select $1[..." +== 339 +-- truncate_limit: 100 +select anyarray_anyrange_func(ARRAY[1,2], int4range(10,20)) +-- +FUNCTION: name="anyarray_anyrange_func" function="anyarray_anyrange_func" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anyarray_anyrange_func(ARRAY[1, 2], int4range(10, 20))" +== 340 +-- truncate_limit: 100 +-- should fail +select anyarray_anyrange_func(ARRAY[1,2], numrange(10,20)) +-- +FUNCTION: name="anyarray_anyrange_func" function="anyarray_anyrange_func" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anyarray_anyrange_func(ARRAY[1, 2], numrange(10, 20))" +== 341 +-- truncate_limit: 100 +drop function anyarray_anyrange_func(anyarray, anyrange) +-- +FUNCTION: name="anyarray_anyrange_func" function="anyarray_anyrange_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anyarray_anyrange_func(anyarray, anyrange)" +== 342 +-- truncate_limit: 100 +-- should fail +create function bogus_func(anyelement) + returns anyrange as 'select int4range(1,10)' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bogus_func(anyelement) RETURNS anyrange AS $$select int4range(1,10)$$ LANGUAGE sql" +== 343 +-- truncate_limit: 100 +-- should fail +create function bogus_func(int) + returns anyrange as 'select int4range(1,10)' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bogus_func(int) RETURNS anyrange AS $$select int4range(1,10)$$ LANGUAGE sql" +== 344 +-- truncate_limit: 100 +create function range_add_bounds(anyrange) + returns anyelement as 'select lower($1) + upper($1)' language sql +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION range_add_bounds(anyrange) RETURNS anyelement AS $$select lower($1) + upper($1)$$..." +== 345 +-- truncate_limit: 100 +select range_add_bounds(int4range(1, 17)) +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_add_bounds(int4range(1, 17))" +== 346 +-- truncate_limit: 100 +select range_add_bounds(numrange(1.0001, 123.123)) +-- +FUNCTION: name="range_add_bounds" function="range_add_bounds" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT range_add_bounds(numrange(1.0001, 123.123))" +== 347 +-- truncate_limit: 100 +create function rangetypes_sql(q anyrange, b anyarray, out c anyelement) + as $$ select upper($1) + $2[1] $$ + language sql +-- +FUNCTION: name="rangetypes_sql" function="rangetypes_sql" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rangetypes_sql(q anyrange, b anyarray, OUT c anyelement) AS $$ select upper($1) +..." +== 348 +-- truncate_limit: 100 +select rangetypes_sql(int4range(1,10), ARRAY[2,20]) +-- +FUNCTION: name="rangetypes_sql" function="rangetypes_sql" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rangetypes_sql(int4range(1, 10), ARRAY[2, 20])" +== 349 +-- truncate_limit: 100 +select rangetypes_sql(numrange(1,10), ARRAY[2,20]) +-- +FUNCTION: name="rangetypes_sql" function="rangetypes_sql" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rangetypes_sql(numrange(1, 10), ARRAY[2, 20])" +== 350 +-- truncate_limit: 100 +-- match failure + +create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange) + returns anycompatible as 'select $1[1] + lower($2);' language sql +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatibler..." +== 351 +-- truncate_limit: 100 +select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20)) +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anycompatiblearray_anycompatiblerange_func(ARRAY[1, 2], int4range(10, 20))" +== 352 +-- truncate_limit: 100 +select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], numrange(10,20)) +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anycompatiblearray_anycompatiblerange_func(ARRAY[1, 2], numrange(10, 20))" +== 353 +-- truncate_limit: 100 +-- should fail +select anycompatiblearray_anycompatiblerange_func(ARRAY[1.1,2], int4range(10,20)) +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT anycompatiblearray_anycompatiblerange_func(ARRAY[1.1, 2], int4range(10, 20))" +== 354 +-- truncate_limit: 100 +drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, anycompatiblerange) +-- +FUNCTION: name="anycompatiblearray_anycompatiblerange_func" function="anycompatiblearray_anycompatiblerange_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION anycompatiblearray_anycompatiblerange_func(anycompatiblearray, anycompatiblerange)" +== 355 +-- truncate_limit: 100 +-- should fail +create function bogus_func(anycompatible) + returns anycompatiblerange as 'select int4range(1,10)' language sql +-- +FUNCTION: name="bogus_func" function="bogus_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bogus_func(anycompatible) RETURNS anycompatiblerange AS $$select int4range(1,10)$..." +== 356 +-- truncate_limit: 100 +|-- +-- Arrays of ranges +|-- + +select ARRAY[numrange(1.1, 1.2), numrange(12.3, 155.5)] +-- +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +FUNCTION: name="numrange" function="numrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[numrange(1.1, 1.2), numrange(12.3, 155.5)]" +== 357 +-- truncate_limit: 100 +create table i8r_array (f1 int, f2 int8range[]) +-- +TABLE: name="i8r_array" schema="" table="i8r_array" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE i8r_array (f1 int, f2 int8range[])" +== 358 +-- truncate_limit: 100 +insert into i8r_array values (42, array[int8range(1,10), int8range(2,20)]) +-- +TABLE: name="i8r_array" schema="" table="i8r_array" ctx=DML +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +FUNCTION: name="int8range" function="int8range" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO i8r_array VALUES (42, ARRAY[int8range(1, 10), int8range(2, 20)])" +== 359 +-- truncate_limit: 100 +select * from i8r_array +-- +TABLE: name="i8r_array" schema="" table="i8r_array" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM i8r_array" +== 360 +-- truncate_limit: 100 +drop table i8r_array +-- +TABLE: name="i8r_array" schema="" table="i8r_array" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE i8r_array" +== 361 +-- truncate_limit: 100 +|-- +-- Ranges of arrays +|-- + +create type arrayrange as range (subtype=int4[]) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE arrayrange AS RANGE (subtype = int4[])" +== 362 +-- truncate_limit: 100 +select arrayrange(ARRAY[1,2], ARRAY[2,1]) +-- +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT arrayrange(ARRAY[1, 2], ARRAY[2, 1])" +== 363 +-- truncate_limit: 100 +select arrayrange(ARRAY[2,1], ARRAY[1,2]) +-- +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT arrayrange(ARRAY[2, 1], ARRAY[1, 2])" +== 364 +-- truncate_limit: 100 +-- fail + +select array[1,1] <@ arrayrange(array[1,2], array[2,1]) +-- +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, 1] <@ arrayrange(ARRAY[1, 2], ARRAY[2, 1])" +== 365 +-- truncate_limit: 100 +select array[1,3] <@ arrayrange(array[1,2], array[2,1]) +-- +FUNCTION: name="arrayrange" function="arrayrange" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[1, 3] <@ arrayrange(ARRAY[1, 2], ARRAY[2, 1])" +== 366 +-- truncate_limit: 100 +|-- +-- Ranges of composites +|-- + +create type two_ints as (a int, b int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE two_ints AS (a int, b int)" +== 367 +-- truncate_limit: 100 +create type two_ints_range as range (subtype = two_ints) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE two_ints_range AS RANGE (subtype = two_ints)" +== 368 +-- truncate_limit: 100 +-- with debug_parallel_query on, this exercises tqueue.c's range remapping +select *, row_to_json(upper(t)) as u from + (values (two_ints_range(row(1,2), row(3,4))), + (two_ints_range(row(5,6), row(7,8)))) v(t) +-- +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="two_ints_range" function="two_ints_range" schema="" ctx=Call +FUNCTION: name="two_ints_range" function="two_ints_range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, row_to_json(upper(t)) AS u FROM (VALUES (...)) v(t)" +== 369 +-- truncate_limit: 100 +-- this must be rejected to avoid self-inclusion issues: +alter type two_ints add attribute c two_ints_range +-- +TABLE: name="two_ints" schema="" table="two_ints" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TYPE two_ints ADD ATTRIBUTE c two_ints_range" +== 370 +-- truncate_limit: 100 +drop type two_ints cascade +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE two_ints CASCADE" +== 371 +-- truncate_limit: 100 +|-- +-- Check behavior when subtype lacks a hash function +|-- + +create type varbitrange as range (subtype = varbit) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE varbitrange AS RANGE (subtype = varbit)" +== 372 +-- truncate_limit: 100 +set enable_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO OFF" +== 373 +-- truncate_limit: 100 +-- try to make it pick a hash setop implementation + +select '(01,10)'::varbitrange except select '(10,11)'::varbitrange +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(01,10)'::varbitrange EXCEPT SELECT '(10,11)'::varbitrange" +== 374 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 375 +-- truncate_limit: 100 +|-- +-- OUT/INOUT/TABLE functions +|-- + +-- infer anyrange from anyrange +create function outparam_succeed(i anyrange, out r anyrange, out t text) + as $$ select $1, 'foo'::text $$ language sql +-- +FUNCTION: name="outparam_succeed" function="outparam_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION outparam_succeed(i anyrange, OUT r anyrange, OUT t text) AS $$ select $1, 'foo'::..." +== 376 +-- truncate_limit: 100 +select * from outparam_succeed(int4range(1,2)) +-- +FUNCTION: name="outparam_succeed" function="outparam_succeed" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM outparam_succeed(int4range(1, 2))" +== 377 +-- truncate_limit: 100 +create function outparam2_succeed(r anyrange, out lu anyarray, out ul anyarray) + as $$ select array[lower($1), upper($1)], array[upper($1), lower($1)] $$ + language sql +-- +FUNCTION: name="outparam2_succeed" function="outparam2_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION outparam2_succeed(r anyrange, OUT lu anyarray, OUT ul anyarray) AS $$ select arra..." +== 378 +-- truncate_limit: 100 +select * from outparam2_succeed(int4range(1,11)) +-- +FUNCTION: name="outparam2_succeed" function="outparam2_succeed" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM outparam2_succeed(int4range(1, 11))" +== 379 +-- truncate_limit: 100 +-- infer anyarray from anyrange +create function outparam_succeed2(i anyrange, out r anyarray, out t text) + as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql +-- +FUNCTION: name="outparam_succeed2" function="outparam_succeed2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION outparam_succeed2(i anyrange, OUT r anyarray, OUT t text) AS $$ select ARRAY[uppe..." +== 380 +-- truncate_limit: 100 +select * from outparam_succeed2(int4range(int4range(1,2))) +-- +FUNCTION: name="outparam_succeed2" function="outparam_succeed2" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM outparam_succeed2(int4range(int4range(1, 2)))" +== 381 +-- truncate_limit: 100 +-- infer anyelement from anyrange +create function inoutparam_succeed(out i anyelement, inout r anyrange) + as $$ select upper($1), $1 $$ language sql +-- +FUNCTION: name="inoutparam_succeed" function="inoutparam_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION inoutparam_succeed(OUT i anyelement, INOUT r anyrange) AS $$ select upper($1), $1..." +== 382 +-- truncate_limit: 100 +select * from inoutparam_succeed(int4range(1,2)) +-- +FUNCTION: name="inoutparam_succeed" function="inoutparam_succeed" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM inoutparam_succeed(int4range(1, 2))" +== 383 +-- truncate_limit: 100 +create function table_succeed(r anyrange) + returns table(l anyelement, u anyelement) + as $$ select lower($1), upper($1) $$ + language sql +-- +FUNCTION: name="table_succeed" function="table_succeed" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION table_succeed(r anyrange) RETURNS TABLE (l anyelement, u anyelement) AS $$ select..." +== 384 +-- truncate_limit: 100 +select * from table_succeed(int4range(1,11)) +-- +FUNCTION: name="table_succeed" function="table_succeed" schema="" ctx=Call +FUNCTION: name="int4range" function="int4range" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM table_succeed(int4range(1, 11))" +== 385 +-- truncate_limit: 100 +-- should fail +create function outparam_fail(i anyelement, out r anyrange, out t text) + as $$ select '[1,10]', 'foo' $$ language sql +-- +FUNCTION: name="outparam_fail" function="outparam_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION outparam_fail(i anyelement, OUT r anyrange, OUT t text) AS $$ select '[1,10]', 'f..." +== 386 +-- truncate_limit: 100 +--should fail +create function inoutparam_fail(inout i anyelement, out r anyrange) + as $$ select $1, '[1,10]' $$ language sql +-- +FUNCTION: name="inoutparam_fail" function="inoutparam_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION inoutparam_fail(INOUT i anyelement, OUT r anyrange) AS $$ select $1, '[1,10]' $$ ..." +== 387 +-- truncate_limit: 100 +--should fail +create function table_fail(i anyelement) returns table(i anyelement, r anyrange) + as $$ select $1, '[1,10]' $$ language sql +-- +FUNCTION: name="table_fail" function="table_fail" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION table_fail(i anyelement) RETURNS TABLE (i anyelement, r anyrange) AS $$ select $1..." +== 388 +-- truncate_limit: 100 +|-- +-- Test support functions +|-- + +-- empty range +explain (verbose, costs off) +select current_date <@ daterange 'empty' +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT current_date <@ 'empty'::daterange" +== 389 +-- truncate_limit: 100 +-- unbounded range +explain (verbose, costs off) +select current_date <@ daterange(NULL, NULL) +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT current_date <@ daterange(NULL, NULL)" +== 390 +-- truncate_limit: 100 +-- only lower bound present +explain (verbose, costs off) +select current_date <@ daterange('2000-01-01', NULL, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT current_date <@ daterange('2000-01-01', NULL, '[)')" +== 391 +-- truncate_limit: 100 +-- only upper bound present +explain (verbose, costs off) +select current_date <@ daterange(NULL, '2000-01-01', '(]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT current_date <@ daterange(NULL, '2000-01-01', '(]')" +== 392 +-- truncate_limit: 100 +-- lower range "-Infinity" excluded +explain (verbose, costs off) +select current_date <@ daterange('-Infinity', '1997-04-10'::date, '()') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT current_date <@ daterange('-Infinity', '1997-04-10'::date, '()')" +== 393 +-- truncate_limit: 100 +-- lower range "-Infinity" included +explain (verbose, costs off) +select current_date <@ daterange('-Infinity', '1997-04-10'::date, '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT current_date <@ daterange('-Infinity', '1997-04-10'::date, '[)')" +== 394 +-- truncate_limit: 100 +-- upper range "Infinity" excluded +explain (verbose, costs off) +select current_date <@ daterange('2002-09-25'::date, 'Infinity', '[)') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT current_date <@ daterange('2002-09-25'::date, 'Infinity', '[)')" +== 395 +-- truncate_limit: 100 +-- upper range "Infinity" included +explain (verbose, costs off) +select current_date <@ daterange('2002-09-25'::date, 'Infinity', '[]') +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT current_date <@ daterange('2002-09-25'::date, 'Infinity', '[]')" +== 396 +-- truncate_limit: 100 +-- should also work if we use "@>" +explain (verbose, costs off) +select daterange('-Infinity', '1997-04-10'::date, '()') @> current_date +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT daterange('-Infinity', '1997-04-10'::date, '()') @> current_date" +== 397 +-- truncate_limit: 100 +explain (verbose, costs off) +select daterange('2002-09-25'::date, 'Infinity', '[]') @> current_date +-- +FUNCTION: name="daterange" function="daterange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT daterange('2002-09-25'::date, 'Infinity', '[]') @> current_date" +== 398 +-- truncate_limit: 100 +-- Check that volatile cases are not optimized +explain (verbose, costs off) +select now() <@ tstzrange('2024-01-20 00:00', '2024-01-21 00:00') +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="tstzrange" function="tstzrange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT now() <@ tstzrange('2024-01-20 00:00', '2024-01-21 00:00')" +== 399 +-- truncate_limit: 100 +explain (verbose, costs off) -- unsafe! +select clock_timestamp() <@ tstzrange('2024-01-20 00:00', '2024-01-21 00:00') +-- +FUNCTION: name="clock_timestamp" function="clock_timestamp" schema="" ctx=Call +FUNCTION: name="tstzrange" function="tstzrange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT clock_timestamp() <@ tstzrange('2024-01-20 00:00', '2024-01-2..." +== 400 +-- truncate_limit: 100 +explain (verbose, costs off) +select clock_timestamp() <@ tstzrange('2024-01-20 00:00', NULL) +-- +FUNCTION: name="clock_timestamp" function="clock_timestamp" schema="" ctx=Call +FUNCTION: name="tstzrange" function="tstzrange" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT clock_timestamp() <@ tstzrange('2024-01-20 00:00', NULL)" +== 401 +-- truncate_limit: 100 +-- test a custom range type with a non-default operator class +create type textrange_supp as range ( + subtype = text, + subtype_opclass = text_pattern_ops +) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange_supp AS RANGE (subtype = text, subtype_opclass = text_pattern_ops)" +== 402 +-- truncate_limit: 100 +create temp table text_support_test (t text collate "C") +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE text_support_test (t text COLLATE \"C\")" +== 403 +-- truncate_limit: 100 +insert into text_support_test values ('a'), ('c'), ('d'), ('ch') +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO text_support_test VALUES ('a'), ('c'), ('d'), ('ch')" +== 404 +-- truncate_limit: 100 +explain (costs off) +select * from text_support_test where t <@ textrange_supp('a', 'd') +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=Select +FUNCTION: name="textrange_supp" function="textrange_supp" schema="" ctx=Call +FUNCTION: name="textrange_supp" function="textrange_supp" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM text_support_test WHERE t <@ textrange_supp('a', 'd')" +== 405 +-- truncate_limit: 100 +select * from text_support_test where t <@ textrange_supp('a', 'd') +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=Select +FUNCTION: name="textrange_supp" function="textrange_supp" schema="" ctx=Call +FUNCTION: name="textrange_supp" function="textrange_supp" schema="" ctx=Call +FILTER: schema="" table="" column="t" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM text_support_test WHERE t <@ textrange_supp('a', 'd')" +== 406 +-- truncate_limit: 100 +drop table text_support_test +-- +TABLE: name="text_support_test" schema="" table="text_support_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE text_support_test" +== 407 +-- truncate_limit: 100 +drop type textrange_supp +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE textrange_supp" diff --git a/parser/testdata/summary_truncate/postgres_regress/regex.metadata.json b/parser/testdata/summary_truncate/postgres_regress/regex.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/regex.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/regex.test b/parser/testdata/summary_truncate/postgres_regress/regex.test new file mode 100644 index 0000000..16f88ea --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/regex.test @@ -0,0 +1,737 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Regular expression tests +|-- + +-- Don't want to have to double backslashes in regexes +set standard_conforming_strings = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET standard_conforming_strings TO ON" +== 002 +-- truncate_limit: 100 +-- Test simple quantified backrefs +select 'bbbbb' ~ '^([bc])\1*$' as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbbbb' ~ E'^([bc])\\\\1*$' AS t" +== 003 +-- truncate_limit: 100 +select 'ccc' ~ '^([bc])\1*$' as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'ccc' ~ E'^([bc])\\\\1*$' AS t" +== 004 +-- truncate_limit: 100 +select 'xxx' ~ '^([bc])\1*$' as f +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'xxx' ~ E'^([bc])\\\\1*$' AS f" +== 005 +-- truncate_limit: 100 +select 'bbc' ~ '^([bc])\1*$' as f +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bbc' ~ E'^([bc])\\\\1*$' AS f" +== 006 +-- truncate_limit: 100 +select 'b' ~ '^([bc])\1*$' as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'b' ~ E'^([bc])\\\\1*$' AS t" +== 007 +-- truncate_limit: 100 +-- Test quantified backref within a larger expression +select 'abc abc abc' ~ '^(\w+)( \1)+$' as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'abc abc abc' ~ E'^(\\\\w+)( \\\\1)+$' AS t" +== 008 +-- truncate_limit: 100 +select 'abc abd abc' ~ '^(\w+)( \1)+$' as f +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'abc abd abc' ~ E'^(\\\\w+)( \\\\1)+$' AS f" +== 009 +-- truncate_limit: 100 +select 'abc abc abd' ~ '^(\w+)( \1)+$' as f +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'abc abc abd' ~ E'^(\\\\w+)( \\\\1)+$' AS f" +== 010 +-- truncate_limit: 100 +select 'abc abc abc' ~ '^(.+)( \1)+$' as t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'abc abc abc' ~ E'^(.+)( \\\\1)+$' AS t" +== 011 +-- truncate_limit: 100 +select 'abc abd abc' ~ '^(.+)( \1)+$' as f +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'abc abd abc' ~ E'^(.+)( \\\\1)+$' AS f" +== 012 +-- truncate_limit: 100 +select 'abc abc abd' ~ '^(.+)( \1)+$' as f +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'abc abc abd' ~ E'^(.+)( \\\\1)+$' AS f" +== 013 +-- truncate_limit: 100 +-- Test some cases that crashed in 9.2beta1 due to pmatch[] array overrun +select substring('asd TO foo' from ' TO (([a-z0-9._]+|"([^"]+|"")+")+)') +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('asd TO foo' FROM ' TO (([a-z0-9._]+|\"([^\"]+|\"\")+\")+)')" +== 014 +-- truncate_limit: 100 +select substring('a' from '((a))+') +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('a' FROM '((a))+')" +== 015 +-- truncate_limit: 100 +select substring('a' from '((a)+)') +-- +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT SUBSTRING('a' FROM '((a)+)')" +== 016 +-- truncate_limit: 100 +-- Test regexp_match() +select regexp_match('abc', '') +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_match('abc', '')" +== 017 +-- truncate_limit: 100 +select regexp_match('abc', 'bc') +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_match('abc', 'bc')" +== 018 +-- truncate_limit: 100 +select regexp_match('abc', 'd') is null +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_match('abc', 'd') IS NULL" +== 019 +-- truncate_limit: 100 +select regexp_match('abc', '(B)(c)', 'i') +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_match('abc', '(B)(c)', 'i')" +== 020 +-- truncate_limit: 100 +select regexp_match('abc', 'Bd', 'ig') +-- +FUNCTION: name="regexp_match" function="regexp_match" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_match('abc', 'Bd', 'ig')" +== 021 +-- truncate_limit: 100 +-- error + +-- Test lookahead constraints +select regexp_matches('ab', 'a(?=b)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('ab', 'a(?=b)b*')" +== 022 +-- truncate_limit: 100 +select regexp_matches('a', 'a(?=b)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('a', 'a(?=b)b*')" +== 023 +-- truncate_limit: 100 +select regexp_matches('abc', 'a(?=b)b*(?=c)c*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('abc', 'a(?=b)b*(?=c)c*')" +== 024 +-- truncate_limit: 100 +select regexp_matches('ab', 'a(?=b)b*(?=c)c*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('ab', 'a(?=b)b*(?=c)c*')" +== 025 +-- truncate_limit: 100 +select regexp_matches('ab', 'a(?!b)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('ab', 'a(?!b)b*')" +== 026 +-- truncate_limit: 100 +select regexp_matches('a', 'a(?!b)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('a', 'a(?!b)b*')" +== 027 +-- truncate_limit: 100 +select regexp_matches('b', '(?=b)b') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('b', '(?=b)b')" +== 028 +-- truncate_limit: 100 +select regexp_matches('a', '(?=b)b') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('a', '(?=b)b')" +== 029 +-- truncate_limit: 100 +-- Test lookbehind constraints +select regexp_matches('abb', '(?<=a)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('abb', '(?<=a)b*')" +== 030 +-- truncate_limit: 100 +select regexp_matches('a', 'a(?<=a)b*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('a', 'a(?<=a)b*')" +== 031 +-- truncate_limit: 100 +select regexp_matches('abc', 'a(?<=a)b*(?<=b)c*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('abc', 'a(?<=a)b*(?<=b)c*')" +== 032 +-- truncate_limit: 100 +select regexp_matches('ab', 'a(?<=a)b*(?<=b)c*') +-- +FUNCTION: name="regexp_matches" function="regexp_matches" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT regexp_matches('ab', 'a(?<=a)b*(?<=b)c*')" +== 033 +-- truncate_limit: 100 +select regexp_matches('ab', 'a*(? 0 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_relation_size('reloptions_test') > 0" +== 037 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = + (SELECT reltoastrelid FROM pg_class + WHERE oid = 'reloptions_test'::regclass) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reloptions FROM pg_class WHERE oid = (SELECT reltoastrelid FROM pg_class WHERE ...)" +== 038 +-- truncate_limit: 100 +ALTER TABLE reloptions_test RESET (vacuum_truncate) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE reloptions_test RESET (vacuum_truncate)" +== 039 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass" +== 040 +-- truncate_limit: 100 +INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO reloptions_test VALUES (1, NULL), (NULL, NULL)" +== 041 +-- truncate_limit: 100 +-- Do an aggressive vacuum to prevent page-skipping. +VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) reloptions_test +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FREEZE, DISABLE_PAGE_SKIPPING) reloptions_test" +== 042 +-- truncate_limit: 100 +SELECT pg_relation_size('reloptions_test') = 0 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_relation_size('reloptions_test') = 0" +== 043 +-- truncate_limit: 100 +-- Test toast.* options +DROP TABLE reloptions_test +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE reloptions_test" +== 044 +-- truncate_limit: 100 +CREATE TABLE reloptions_test (s VARCHAR) + WITH (toast.autovacuum_vacuum_cost_delay = 23) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE reloptions_test (s varchar) WITH (toast.autovacuum_vacuum_cost_delay=23)" +== 045 +-- truncate_limit: 100 +SELECT reltoastrelid as toast_oid + FROM pg_class WHERE oid = 'reloptions_test'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltoastrelid AS toast_oid FROM pg_class WHERE oid = 'reloptions_test'::regclass" +== 046 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = :toast_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 45 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 047 +-- truncate_limit: 100 +ALTER TABLE reloptions_test SET (toast.autovacuum_vacuum_cost_delay = 24) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE reloptions_test SET (toast.autovacuum_vacuum_cost_delay=24)" +== 048 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = :toast_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 45 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 049 +-- truncate_limit: 100 +ALTER TABLE reloptions_test RESET (toast.autovacuum_vacuum_cost_delay) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE reloptions_test RESET (toast.autovacuum_vacuum_cost_delay)" +== 050 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = :toast_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 45 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 051 +-- truncate_limit: 100 +-- Fail on non-existent options in toast namespace +CREATE TABLE reloptions_test2 (i int) WITH (toast.not_existing_option = 42) +-- +TABLE: name="reloptions_test2" schema="" table="reloptions_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE reloptions_test2 (i int) WITH (toast.not_existing_option=42)" +== 052 +-- truncate_limit: 100 +-- Mix TOAST & heap +DROP TABLE reloptions_test +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE reloptions_test" +== 053 +-- truncate_limit: 100 +CREATE TABLE reloptions_test (s VARCHAR) WITH + (toast.autovacuum_vacuum_cost_delay = 23, + autovacuum_vacuum_cost_delay = 24, fillfactor = 40) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE reloptions_test (s varchar) WITH (toast.autovacuum_vacuum_cost_delay=23, autovacuum_..." +== 054 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass" +== 055 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = ( + SELECT reltoastrelid FROM pg_class WHERE oid = 'reloptions_test'::regclass) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reloptions FROM pg_class WHERE oid = (SELECT reltoastrelid FROM pg_class WHERE ...)" +== 056 +-- truncate_limit: 100 +|-- +-- CREATE INDEX, ALTER INDEX for btrees +|-- + +CREATE INDEX reloptions_test_idx ON reloptions_test (s) WITH (fillfactor=30) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX reloptions_test_idx ON reloptions_test USING btree (s) WITH (fillfactor=30)" +== 057 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass" +== 058 +-- truncate_limit: 100 +-- Fail when option and namespace do not exist +CREATE INDEX reloptions_test_idx ON reloptions_test (s) + WITH (not_existing_option=2) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX reloptions_test_idx ON reloptions_test USING btree (s) WITH (not_existing_option=2)" +== 059 +-- truncate_limit: 100 +CREATE INDEX reloptions_test_idx ON reloptions_test (s) + WITH (not_existing_ns.fillfactor=2) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX reloptions_test_idx ON reloptions_test USING btree (s) WITH (not_existing_ns.fillfac..." +== 060 +-- truncate_limit: 100 +-- Check allowed ranges +CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=1) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX reloptions_test_idx2 ON reloptions_test USING btree (s) WITH (fillfactor=1)" +== 061 +-- truncate_limit: 100 +CREATE INDEX reloptions_test_idx2 ON reloptions_test (s) WITH (fillfactor=130) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX reloptions_test_idx2 ON reloptions_test USING btree (s) WITH (fillfactor=130)" +== 062 +-- truncate_limit: 100 +-- Check ALTER +ALTER INDEX reloptions_test_idx SET (fillfactor=40) +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX reloptions_test_idx SET (fillfactor=40)" +== 063 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx'::regclass" +== 064 +-- truncate_limit: 100 +-- Check ALTER on empty reloption list +CREATE INDEX reloptions_test_idx3 ON reloptions_test (s) +-- +TABLE: name="reloptions_test" schema="" table="reloptions_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX reloptions_test_idx3 ON reloptions_test USING btree (s)" +== 065 +-- truncate_limit: 100 +ALTER INDEX reloptions_test_idx3 SET (fillfactor=40) +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX reloptions_test_idx3 SET (fillfactor=40)" +== 066 +-- truncate_limit: 100 +SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx3'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test_idx3'::regclass" diff --git a/parser/testdata/summary_truncate/postgres_regress/replica_identity.metadata.json b/parser/testdata/summary_truncate/postgres_regress/replica_identity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/replica_identity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/replica_identity.test b/parser/testdata/summary_truncate/postgres_regress/replica_identity.test new file mode 100644 index 0000000..2bbb96f --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/replica_identity.test @@ -0,0 +1,454 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE test_replica_identity ( + id serial primary key, + keya text not null, + keyb text not null, + nonkey text, + CONSTRAINT test_replica_identity_unique_defer UNIQUE (keya, keyb) DEFERRABLE, + CONSTRAINT test_replica_identity_unique_nondefer UNIQUE (keya, keyb) +) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_replica_identity (id serial PRIMARY KEY, keya text NOT NULL, keyb text NOT NULL..." +== 002 +-- truncate_limit: 100 +CREATE TABLE test_replica_identity_othertable (id serial primary key) +-- +TABLE: name="test_replica_identity_othertable" schema="" table="test_replica_identity_othertable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_replica_identity_othertable (id serial PRIMARY KEY)" +== 003 +-- truncate_limit: 100 +CREATE TABLE test_replica_identity_t3 (id serial constraint pk primary key deferrable) +-- +TABLE: name="test_replica_identity_t3" schema="" table="test_replica_identity_t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_replica_identity_t3 (id serial CONSTRAINT pk PRIMARY KEY DEFERRABLE)" +== 004 +-- truncate_limit: 100 +CREATE INDEX test_replica_identity_keyab ON test_replica_identity (keya, keyb) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_replica_identity_keyab ON test_replica_identity USING btree (keya, keyb)" +== 005 +-- truncate_limit: 100 +CREATE UNIQUE INDEX test_replica_identity_keyab_key ON test_replica_identity (keya, keyb) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX test_replica_identity_keyab_key ON test_replica_identity USING btree (keya, k..." +== 006 +-- truncate_limit: 100 +CREATE UNIQUE INDEX test_replica_identity_nonkey ON test_replica_identity (keya, nonkey) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX test_replica_identity_nonkey ON test_replica_identity USING btree (keya, nonkey)" +== 007 +-- truncate_limit: 100 +CREATE INDEX test_replica_identity_hash ON test_replica_identity USING hash (nonkey) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_replica_identity_hash ON test_replica_identity USING hash (nonkey)" +== 008 +-- truncate_limit: 100 +CREATE UNIQUE INDEX test_replica_identity_expr ON test_replica_identity (keya, keyb, (3)) +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX test_replica_identity_expr ON test_replica_identity USING btree (keya, keyb, ..." +== 009 +-- truncate_limit: 100 +CREATE UNIQUE INDEX test_replica_identity_partial ON test_replica_identity (keya, keyb) WHERE keyb != '3' +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX test_replica_identity_partial ON test_replica_identity USING btree (keya, key..." +== 010 +-- truncate_limit: 100 +-- default is 'd'/DEFAULT for user created tables +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass" +== 011 +-- truncate_limit: 100 +-- but 'none' for system tables +SELECT relreplident FROM pg_class WHERE oid = 'pg_class'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'pg_class'::regclass" +== 012 +-- truncate_limit: 100 +SELECT relreplident FROM pg_class WHERE oid = 'pg_constraint'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'pg_constraint'::regclass" +== 013 +-- truncate_limit: 100 +---- +-- Make sure we detect ineligible indexes +---- + +-- fail, not unique +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab" +== 014 +-- truncate_limit: 100 +-- fail, not a candidate key, nullable column +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_nonkey +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_nonkey" +== 015 +-- truncate_limit: 100 +-- fail, hash indexes cannot do uniqueness +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_hash +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_hash" +== 016 +-- truncate_limit: 100 +-- fail, expression index +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_expr +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_expr" +== 017 +-- truncate_limit: 100 +-- fail, partial index +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_partial +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_partial" +== 018 +-- truncate_limit: 100 +-- fail, not our index +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_othertable_pkey +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_othertable_pkey" +== 019 +-- truncate_limit: 100 +-- fail, deferrable +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_unique_defer +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_unique_defer" +== 020 +-- truncate_limit: 100 +-- fail, deferrable +ALTER TABLE test_replica_identity_t3 REPLICA IDENTITY USING INDEX pk +-- +TABLE: name="test_replica_identity_t3" schema="" table="test_replica_identity_t3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity_t3 REPLICA IDENTITY USING INDEX pk" +== 021 +-- truncate_limit: 100 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass" +== 022 +-- truncate_limit: 100 +---- +-- Make sure index cases succeed +---- + +-- succeed, primary key +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_pkey +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_pkey" +== 023 +-- truncate_limit: 100 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass" +== 024 +-- truncate_limit: 100 +-- succeed, nondeferrable unique constraint over nonnullable cols +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_unique_nondefer +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_unique_nondefer" +== 025 +-- truncate_limit: 100 +-- succeed unique index over nonnullable cols +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab_key +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab_key" +== 026 +-- truncate_limit: 100 +ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab_key +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY USING INDEX test_replica_identity_keyab_key" +== 027 +-- truncate_limit: 100 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass" +== 028 +-- truncate_limit: 100 +SELECT count(*) FROM pg_index WHERE indrelid = 'test_replica_identity'::regclass AND indisreplident +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="indisreplident" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_index WHERE indrelid = 'test_replica_identity'::regclass AND indisreplident" +== 029 +-- truncate_limit: 100 +---- +-- Make sure non index cases work +---- +ALTER TABLE test_replica_identity REPLICA IDENTITY DEFAULT +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY DEFAULT" +== 030 +-- truncate_limit: 100 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass" +== 031 +-- truncate_limit: 100 +SELECT count(*) FROM pg_index WHERE indrelid = 'test_replica_identity'::regclass AND indisreplident +-- +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="" column="indisreplident" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_index WHERE indrelid = 'test_replica_identity'::regclass AND indisreplident" +== 032 +-- truncate_limit: 100 +ALTER TABLE test_replica_identity REPLICA IDENTITY FULL +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY FULL" +== 033 +-- truncate_limit: 100 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass" +== 034 +-- truncate_limit: 100 +ALTER TABLE test_replica_identity REPLICA IDENTITY NOTHING +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity REPLICA IDENTITY NOTHING" +== 035 +-- truncate_limit: 100 +SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass" +== 036 +-- truncate_limit: 100 +--- +-- Test that ALTER TABLE rewrite preserves nondefault replica identity +--- + +-- constraint variant +CREATE TABLE test_replica_identity2 (id int UNIQUE NOT NULL) +-- +TABLE: name="test_replica_identity2" schema="" table="test_replica_identity2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_replica_identity2 (id int UNIQUE NOT NULL)" +== 037 +-- truncate_limit: 100 +ALTER TABLE test_replica_identity2 REPLICA IDENTITY USING INDEX test_replica_identity2_id_key +-- +TABLE: name="test_replica_identity2" schema="" table="test_replica_identity2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity2 REPLICA IDENTITY USING INDEX test_replica_identity2_id_key" +== 038 +-- truncate_limit: 100 +ALTER TABLE test_replica_identity2 ALTER COLUMN id TYPE bigint +-- +TABLE: name="test_replica_identity2" schema="" table="test_replica_identity2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity2 ALTER COLUMN id TYPE bigint" +== 039 +-- truncate_limit: 100 +-- straight index variant +CREATE TABLE test_replica_identity3 (id int NOT NULL) +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_replica_identity3 (id int NOT NULL)" +== 040 +-- truncate_limit: 100 +CREATE UNIQUE INDEX test_replica_identity3_id_key ON test_replica_identity3 (id) +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX test_replica_identity3_id_key ON test_replica_identity3 USING btree (id)" +== 041 +-- truncate_limit: 100 +ALTER TABLE test_replica_identity3 REPLICA IDENTITY USING INDEX test_replica_identity3_id_key +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity3 REPLICA IDENTITY USING INDEX test_replica_identity3_id_key" +== 042 +-- truncate_limit: 100 +ALTER TABLE test_replica_identity3 ALTER COLUMN id TYPE bigint +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity3 ALTER COLUMN id TYPE bigint" +== 043 +-- truncate_limit: 100 +-- ALTER TABLE DROP NOT NULL is not allowed for columns part of an index +-- used as replica identity. +ALTER TABLE test_replica_identity3 ALTER COLUMN id DROP NOT NULL +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_replica_identity3 ALTER COLUMN id DROP NOT NULL" +== 044 +-- truncate_limit: 100 +|-- +-- Test that replica identity can be set on an index that's not yet valid. +-- (This matches the way pg_dump will try to dump a partitioned table.) +|-- +CREATE TABLE test_replica_identity4(id integer NOT NULL) PARTITION BY LIST (id) +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_replica_identity4 (id int NOT NULL) PARTITION BY LIST (id)" +== 045 +-- truncate_limit: 100 +CREATE TABLE test_replica_identity4_1(id integer NOT NULL) +-- +TABLE: name="test_replica_identity4_1" schema="" table="test_replica_identity4_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_replica_identity4_1 (id int NOT NULL)" +== 046 +-- truncate_limit: 100 +ALTER TABLE ONLY test_replica_identity4 + ATTACH PARTITION test_replica_identity4_1 FOR VALUES IN (1) +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY test_replica_identity4 ATTACH PARTITION test_replica_identity4_1 FOR VALUES IN (1)" +== 047 +-- truncate_limit: 100 +ALTER TABLE ONLY test_replica_identity4 + ADD CONSTRAINT test_replica_identity4_pkey PRIMARY KEY (id) +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY test_replica_identity4 ADD CONSTRAINT test_replica_identity4_pkey PRIMARY KEY (id)" +== 048 +-- truncate_limit: 100 +ALTER TABLE ONLY test_replica_identity4 + REPLICA IDENTITY USING INDEX test_replica_identity4_pkey +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY test_replica_identity4 REPLICA IDENTITY USING INDEX test_replica_identity4_pkey" +== 049 +-- truncate_limit: 100 +ALTER TABLE ONLY test_replica_identity4_1 + ADD CONSTRAINT test_replica_identity4_1_pkey PRIMARY KEY (id) +-- +TABLE: name="test_replica_identity4_1" schema="" table="test_replica_identity4_1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY test_replica_identity4_1 ADD CONSTRAINT test_replica_identity4_1_pkey PRIMARY KE..." +== 050 +-- truncate_limit: 100 +ALTER INDEX test_replica_identity4_pkey + ATTACH PARTITION test_replica_identity4_1_pkey +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX test_replica_identity4_pkey ATTACH PARTITION test_replica_identity4_1_pkey" +== 051 +-- truncate_limit: 100 +DROP TABLE test_replica_identity +-- +TABLE: name="test_replica_identity" schema="" table="test_replica_identity" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_replica_identity" +== 052 +-- truncate_limit: 100 +DROP TABLE test_replica_identity2 +-- +TABLE: name="test_replica_identity2" schema="" table="test_replica_identity2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_replica_identity2" +== 053 +-- truncate_limit: 100 +DROP TABLE test_replica_identity3 +-- +TABLE: name="test_replica_identity3" schema="" table="test_replica_identity3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_replica_identity3" +== 054 +-- truncate_limit: 100 +DROP TABLE test_replica_identity4 +-- +TABLE: name="test_replica_identity4" schema="" table="test_replica_identity4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_replica_identity4" +== 055 +-- truncate_limit: 100 +DROP TABLE test_replica_identity_othertable +-- +TABLE: name="test_replica_identity_othertable" schema="" table="test_replica_identity_othertable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_replica_identity_othertable" +== 056 +-- truncate_limit: 100 +DROP TABLE test_replica_identity_t3 +-- +TABLE: name="test_replica_identity_t3" schema="" table="test_replica_identity_t3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_replica_identity_t3" diff --git a/parser/testdata/summary_truncate/postgres_regress/returning.metadata.json b/parser/testdata/summary_truncate/postgres_regress/returning.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/returning.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/returning.test b/parser/testdata/summary_truncate/postgres_regress/returning.test new file mode 100644 index 0000000..53e56ea --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/returning.test @@ -0,0 +1,645 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test INSERT/UPDATE/DELETE RETURNING +|-- + +-- Simple cases + +CREATE TEMP TABLE foo (f1 serial, f2 text, f3 int default 42) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (f1 serial, f2 text, f3 int DEFAULT 42)" +== 002 +-- truncate_limit: 100 +INSERT INTO foo (f2,f3) + VALUES ('test', DEFAULT), ('More', 11), (upper('more'), 7+9) + RETURNING *, f1+f3 AS sum +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo (f2, f3) VALUES (...) RETURNING *, f1 + f3 AS sum" +== 003 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 004 +-- truncate_limit: 100 +UPDATE foo SET f2 = lower(f2), f3 = DEFAULT RETURNING foo.*, f1+f3 AS sum13 +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE foo SET f2 = lower(f2), f3 = DEFAULT RETURNING foo.*, f1 + f3 AS sum13" +== 005 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 006 +-- truncate_limit: 100 +DELETE FROM foo WHERE f1 > 2 RETURNING f3, f2, f1, least(f1,f3) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM foo WHERE f1 > 2 RETURNING f3, f2, f1, LEAST(f1, f3)" +== 007 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 008 +-- truncate_limit: 100 +-- Subplans and initplans in the RETURNING list + +INSERT INTO foo SELECT f1+10, f2, f3+99 FROM foo + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo SELECT ... FROM foo RETURNING *, f1 + 112 IN (SELECT q1 FROM int8_tbl) AS subplan..." +== 009 +-- truncate_limit: 100 +UPDATE foo SET f3 = f3 * 2 + WHERE f1 > 10 + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE foo SET ... = ... WHERE ... RETURNING *, f1 + 112 IN (SELECT q1 FROM int8_tbl) AS subplan,..." +== 010 +-- truncate_limit: 100 +DELETE FROM foo + WHERE f1 > 10 + RETURNING *, f1+112 IN (SELECT q1 FROM int8_tbl) AS subplan, + EXISTS(SELECT * FROM int4_tbl) AS initplan +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM foo WHERE ... RETURNING *, f1 + 112 IN (SELECT q1 FROM int8_tbl) AS subplan, EXISTS (..." +== 011 +-- truncate_limit: 100 +-- Joins + +UPDATE foo SET f3 = f3*2 + FROM int4_tbl i + WHERE foo.f1 + 123455 = i.f1 + RETURNING foo.*, i.f1 as "i.f1" +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: UpdateStmt +TRUNCATED: "UPDATE foo SET f3 = f3 * 2 FROM int4_tbl i WHERE ... RETURNING foo.*, i.f1 AS \"i.f1\"" +== 012 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 013 +-- truncate_limit: 100 +DELETE FROM foo + USING int4_tbl i + WHERE foo.f1 + 123455 = i.f1 + RETURNING foo.*, i.f1 as "i.f1" +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +STMT: DeleteStmt +TRUNCATED: "DELETE FROM foo USING int4_tbl i WHERE (foo.f1 + 123455) = i.f1 RETURNING foo.*, i.f1 AS \"i.f1\"" +== 014 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 015 +-- truncate_limit: 100 +-- Check inheritance cases + +CREATE TEMP TABLE foochild (fc int) INHERITS (foo) +-- +TABLE: name="foochild" schema="" table="foochild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foochild (fc int) INHERITS (foo)" +== 016 +-- truncate_limit: 100 +INSERT INTO foochild VALUES(123,'child',999,-123) +-- +TABLE: name="foochild" schema="" table="foochild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foochild VALUES (123, 'child', 999, -123)" +== 017 +-- truncate_limit: 100 +ALTER TABLE foo ADD COLUMN f4 int8 DEFAULT 99 +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE foo ADD COLUMN f4 int8 DEFAULT 99" +== 018 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 019 +-- truncate_limit: 100 +SELECT * FROM foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foochild" +== 020 +-- truncate_limit: 100 +UPDATE foo SET f4 = f4 + f3 WHERE f4 = 99 RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE foo SET f4 = f4 + f3 WHERE f4 = 99 RETURNING *" +== 021 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 022 +-- truncate_limit: 100 +SELECT * FROM foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foochild" +== 023 +-- truncate_limit: 100 +UPDATE foo SET f3 = f3*2 + FROM int8_tbl i + WHERE foo.f1 = i.q2 + RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: UpdateStmt +TRUNCATED: "UPDATE foo SET f3 = f3 * 2 FROM int8_tbl i WHERE foo.f1 = i.q2 RETURNING *" +== 024 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 025 +-- truncate_limit: 100 +SELECT * FROM foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foochild" +== 026 +-- truncate_limit: 100 +DELETE FROM foo + USING int8_tbl i + WHERE foo.f1 = i.q2 + RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +STMT: DeleteStmt +TRUNCATED: "DELETE FROM foo USING int8_tbl i WHERE foo.f1 = i.q2 RETURNING *" +== 027 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 028 +-- truncate_limit: 100 +SELECT * FROM foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foochild" +== 029 +-- truncate_limit: 100 +DROP TABLE foochild +-- +TABLE: name="foochild" schema="" table="foochild" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE foochild" +== 030 +-- truncate_limit: 100 +-- Rules and views + +CREATE TEMP VIEW voo AS SELECT f1, f2 FROM foo +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW voo AS SELECT f1, f2 FROM foo" +== 031 +-- truncate_limit: 100 +CREATE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57) +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE voo_i AS ON INSERT TO voo DO INSTEAD INSERT INTO foo VALUES (new.*, 57)" +== 032 +-- truncate_limit: 100 +INSERT INTO voo VALUES(11,'zit') +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO voo VALUES (11, 'zit')" +== 033 +-- truncate_limit: 100 +-- fails: +INSERT INTO voo VALUES(12,'zoo') RETURNING *, f1*2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO voo VALUES (12, 'zoo') RETURNING *, f1 * 2" +== 034 +-- truncate_limit: 100 +-- fails, incompatible list: +CREATE OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57) RETURNING * +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD INSERT INTO foo VALUES (new.*, 57) RE..." +== 035 +-- truncate_limit: 100 +CREATE OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD + INSERT INTO foo VALUES(new.*, 57) RETURNING f1, f2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE voo_i AS ON INSERT TO voo DO INSTEAD INSERT INTO foo VALUES (new.*, 57) RE..." +== 036 +-- truncate_limit: 100 +-- should still work +INSERT INTO voo VALUES(13,'zit2') +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO voo VALUES (13, 'zit2')" +== 037 +-- truncate_limit: 100 +-- works now +INSERT INTO voo VALUES(14,'zoo2') RETURNING * +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO voo VALUES (14, 'zoo2') RETURNING *" +== 038 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 039 +-- truncate_limit: 100 +SELECT * FROM voo +-- +TABLE: name="voo" schema="" table="voo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM voo" +== 040 +-- truncate_limit: 100 +CREATE OR REPLACE RULE voo_u AS ON UPDATE TO voo DO INSTEAD + UPDATE foo SET f1 = new.f1, f2 = new.f2 WHERE f1 = old.f1 + RETURNING f1, f2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE voo_u AS ON UPDATE TO voo DO INSTEAD UPDATE foo SET f1 = new.f1, f2 = new...." +== 041 +-- truncate_limit: 100 +update voo set f1 = f1 + 1 where f2 = 'zoo2' +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE voo SET f1 = f1 + 1 WHERE f2 = 'zoo2'" +== 042 +-- truncate_limit: 100 +update voo set f1 = f1 + 1 where f2 = 'zoo2' RETURNING *, f1*2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE voo SET f1 = f1 + 1 WHERE f2 = 'zoo2' RETURNING *, f1 * 2" +== 043 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 044 +-- truncate_limit: 100 +SELECT * FROM voo +-- +TABLE: name="voo" schema="" table="voo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM voo" +== 045 +-- truncate_limit: 100 +CREATE OR REPLACE RULE voo_d AS ON DELETE TO voo DO INSTEAD + DELETE FROM foo WHERE f1 = old.f1 + RETURNING f1, f2 +-- +TABLE: name="voo" schema="" table="voo" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE voo_d AS ON DELETE TO voo DO INSTEAD DELETE FROM foo WHERE f1 = old.f1 RET..." +== 046 +-- truncate_limit: 100 +DELETE FROM foo WHERE f1 = 13 +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM foo WHERE f1 = 13" +== 047 +-- truncate_limit: 100 +DELETE FROM foo WHERE f2 = 'zit' RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM foo WHERE f2 = 'zit' RETURNING *" +== 048 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 049 +-- truncate_limit: 100 +SELECT * FROM voo +-- +TABLE: name="voo" schema="" table="voo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM voo" +== 050 +-- truncate_limit: 100 +-- Check use of a whole-row variable for an un-flattenable view +CREATE TEMP VIEW foo_v AS SELECT * FROM foo OFFSET 0 +-- +TABLE: name="foo_v" schema="" table="foo_v" ctx=DDL +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW foo_v AS SELECT * FROM foo OFFSET 0" +== 051 +-- truncate_limit: 100 +UPDATE foo SET f2 = foo_v.f2 FROM foo_v WHERE foo_v.f1 = foo.f1 + RETURNING foo_v +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +TABLE: name="foo_v" schema="" table="foo_v" ctx=Select +STMT: UpdateStmt +TRUNCATED: "UPDATE foo SET f2 = foo_v.f2 FROM foo_v WHERE foo_v.f1 = foo.f1 RETURNING foo_v" +== 052 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 053 +-- truncate_limit: 100 +-- Check use of a whole-row variable for an inlined set-returning function +CREATE FUNCTION foo_f() RETURNS SETOF foo AS + $$ SELECT * FROM foo OFFSET 0 $$ LANGUAGE sql STABLE +-- +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION foo_f() RETURNS SETOF foo AS $$ SELECT * FROM foo OFFSET 0 $$ LANGUAGE sql STABLE" +== 054 +-- truncate_limit: 100 +UPDATE foo SET f2 = foo_f.f2 FROM foo_f() WHERE foo_f.f1 = foo.f1 + RETURNING foo_f +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE foo SET f2 = foo_f.f2 FROM foo_f() WHERE foo_f.f1 = foo.f1 RETURNING foo_f" +== 055 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 056 +-- truncate_limit: 100 +DROP FUNCTION foo_f() +-- +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION foo_f()" +== 057 +-- truncate_limit: 100 +-- As above, but SRF is defined to return a composite type +CREATE TYPE foo_t AS (f1 int, f2 text, f3 int, f4 int8) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE foo_t AS (f1 int, f2 text, f3 int, f4 int8)" +== 058 +-- truncate_limit: 100 +CREATE FUNCTION foo_f() RETURNS SETOF foo_t AS + $$ SELECT * FROM foo OFFSET 0 $$ LANGUAGE sql STABLE +-- +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION foo_f() RETURNS SETOF foo_t AS $$ SELECT * FROM foo OFFSET 0 $$ LANGUAGE sql STABLE" +== 059 +-- truncate_limit: 100 +UPDATE foo SET f2 = foo_f.f2 FROM foo_f() WHERE foo_f.f1 = foo.f1 + RETURNING foo_f +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE foo SET f2 = foo_f.f2 FROM foo_f() WHERE foo_f.f1 = foo.f1 RETURNING foo_f" +== 060 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 061 +-- truncate_limit: 100 +DROP FUNCTION foo_f() +-- +FUNCTION: name="foo_f" function="foo_f" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION foo_f()" +== 062 +-- truncate_limit: 100 +DROP TYPE foo_t +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE foo_t" +== 063 +-- truncate_limit: 100 +-- Try a join case + +CREATE TEMP TABLE joinme (f2j text, other int) +-- +TABLE: name="joinme" schema="" table="joinme" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE joinme (f2j text, other int)" +== 064 +-- truncate_limit: 100 +INSERT INTO joinme VALUES('more', 12345) +-- +TABLE: name="joinme" schema="" table="joinme" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO joinme VALUES ('more', 12345)" +== 065 +-- truncate_limit: 100 +INSERT INTO joinme VALUES('zoo2', 54321) +-- +TABLE: name="joinme" schema="" table="joinme" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO joinme VALUES ('zoo2', 54321)" +== 066 +-- truncate_limit: 100 +INSERT INTO joinme VALUES('other', 0) +-- +TABLE: name="joinme" schema="" table="joinme" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO joinme VALUES ('other', 0)" +== 067 +-- truncate_limit: 100 +CREATE TEMP VIEW joinview AS + SELECT foo.*, other FROM foo JOIN joinme ON (f2 = f2j) +-- +TABLE: name="joinview" schema="" table="joinview" ctx=DDL +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="joinme" schema="" table="joinme" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW joinview AS SELECT foo.*, other FROM foo JOIN joinme ON f2 = f2j" +== 068 +-- truncate_limit: 100 +SELECT * FROM joinview +-- +TABLE: name="joinview" schema="" table="joinview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM joinview" +== 069 +-- truncate_limit: 100 +CREATE RULE joinview_u AS ON UPDATE TO joinview DO INSTEAD + UPDATE foo SET f1 = new.f1, f3 = new.f3 + FROM joinme WHERE f2 = f2j AND f2 = old.f2 + RETURNING foo.*, other +-- +TABLE: name="joinview" schema="" table="joinview" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE joinview_u AS ON UPDATE TO joinview DO INSTEAD UPDATE foo SET f1 = new.f1, f3 = new.f..." +== 070 +-- truncate_limit: 100 +UPDATE joinview SET f1 = f1 + 1 WHERE f3 = 57 RETURNING *, other + 1 +-- +TABLE: name="joinview" schema="" table="joinview" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE joinview SET f1 = f1 + 1 WHERE f3 = 57 RETURNING *, other + 1" +== 071 +-- truncate_limit: 100 +SELECT * FROM joinview +-- +TABLE: name="joinview" schema="" table="joinview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM joinview" +== 072 +-- truncate_limit: 100 +SELECT * FROM foo +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo" +== 073 +-- truncate_limit: 100 +SELECT * FROM voo +-- +TABLE: name="voo" schema="" table="voo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM voo" +== 074 +-- truncate_limit: 100 +-- Check aliased target relation +INSERT INTO foo AS bar DEFAULT VALUES RETURNING * +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +ALIAS: "bar"="foo" +STMT: InsertStmt +TRUNCATED: "INSERT INTO foo AS bar DEFAULT VALUES RETURNING *" +== 075 +-- truncate_limit: 100 +-- ok +INSERT INTO foo AS bar DEFAULT VALUES RETURNING foo.* +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +ALIAS: "bar"="foo" +STMT: InsertStmt +TRUNCATED: "INSERT INTO foo AS bar DEFAULT VALUES RETURNING foo.*" +== 076 +-- truncate_limit: 100 +-- fails, wrong name +INSERT INTO foo AS bar DEFAULT VALUES RETURNING bar.* +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +ALIAS: "bar"="foo" +STMT: InsertStmt +TRUNCATED: "INSERT INTO foo AS bar DEFAULT VALUES RETURNING bar.*" +== 077 +-- truncate_limit: 100 +-- ok +INSERT INTO foo AS bar DEFAULT VALUES RETURNING bar.f3 +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +ALIAS: "bar"="foo" +STMT: InsertStmt +TRUNCATED: "INSERT INTO foo AS bar DEFAULT VALUES RETURNING bar.f3" diff --git a/parser/testdata/summary_truncate/postgres_regress/roleattributes.metadata.json b/parser/testdata/summary_truncate/postgres_regress/roleattributes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/roleattributes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/roleattributes.test b/parser/testdata/summary_truncate/postgres_regress/roleattributes.test new file mode 100644 index 0000000..d5b7a32 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/roleattributes.test @@ -0,0 +1,553 @@ +== 001 +-- truncate_limit: 100 +-- default for superuser is false +CREATE ROLE regress_test_def_superuser +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_def_superuser" +== 002 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_superuser' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_def_superuser'" +== 003 +-- truncate_limit: 100 +CREATE ROLE regress_test_superuser WITH SUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_superuser WITH SUPERUSER" +== 004 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_superuser' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_superuser'" +== 005 +-- truncate_limit: 100 +ALTER ROLE regress_test_superuser WITH NOSUPERUSER +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_superuser WITH NOSUPERUSER" +== 006 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_superuser' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_superuser'" +== 007 +-- truncate_limit: 100 +ALTER ROLE regress_test_superuser WITH SUPERUSER +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_superuser WITH SUPERUSER" +== 008 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_superuser' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_superuser'" +== 009 +-- truncate_limit: 100 +-- default for inherit is true +CREATE ROLE regress_test_def_inherit +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_def_inherit" +== 010 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_inherit' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_def_inherit'" +== 011 +-- truncate_limit: 100 +CREATE ROLE regress_test_inherit WITH NOINHERIT +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_inherit WITH NOINHERIT" +== 012 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_inherit' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_inherit'" +== 013 +-- truncate_limit: 100 +ALTER ROLE regress_test_inherit WITH INHERIT +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_inherit WITH INHERIT" +== 014 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_inherit' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_inherit'" +== 015 +-- truncate_limit: 100 +ALTER ROLE regress_test_inherit WITH NOINHERIT +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_inherit WITH NOINHERIT" +== 016 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_inherit' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_inherit'" +== 017 +-- truncate_limit: 100 +-- default for create role is false +CREATE ROLE regress_test_def_createrole +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_def_createrole" +== 018 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_createrole' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_def_createrole'" +== 019 +-- truncate_limit: 100 +CREATE ROLE regress_test_createrole WITH CREATEROLE +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_createrole WITH CREATEROLE" +== 020 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createrole' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_createrole'" +== 021 +-- truncate_limit: 100 +ALTER ROLE regress_test_createrole WITH NOCREATEROLE +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_createrole WITH NOCREATEROLE" +== 022 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createrole' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_createrole'" +== 023 +-- truncate_limit: 100 +ALTER ROLE regress_test_createrole WITH CREATEROLE +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_createrole WITH CREATEROLE" +== 024 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createrole' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_createrole'" +== 025 +-- truncate_limit: 100 +-- default for create database is false +CREATE ROLE regress_test_def_createdb +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_def_createdb" +== 026 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_createdb' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_def_createdb'" +== 027 +-- truncate_limit: 100 +CREATE ROLE regress_test_createdb WITH CREATEDB +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_createdb WITH CREATEDB" +== 028 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createdb' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_createdb'" +== 029 +-- truncate_limit: 100 +ALTER ROLE regress_test_createdb WITH NOCREATEDB +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_createdb WITH NOCREATEDB" +== 030 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createdb' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_createdb'" +== 031 +-- truncate_limit: 100 +ALTER ROLE regress_test_createdb WITH CREATEDB +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_createdb WITH CREATEDB" +== 032 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_createdb' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_createdb'" +== 033 +-- truncate_limit: 100 +-- default for can login is false for role +CREATE ROLE regress_test_def_role_canlogin +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_def_role_canlogin" +== 034 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_role_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_def_role_canlogin'" +== 035 +-- truncate_limit: 100 +CREATE ROLE regress_test_role_canlogin WITH LOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_role_canlogin WITH LOGIN" +== 036 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_role_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_role_canlogin'" +== 037 +-- truncate_limit: 100 +ALTER ROLE regress_test_role_canlogin WITH NOLOGIN +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_role_canlogin WITH NOLOGIN" +== 038 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_role_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_role_canlogin'" +== 039 +-- truncate_limit: 100 +ALTER ROLE regress_test_role_canlogin WITH LOGIN +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_role_canlogin WITH LOGIN" +== 040 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_role_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_role_canlogin'" +== 041 +-- truncate_limit: 100 +-- default for can login is true for user +CREATE USER regress_test_def_user_canlogin +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_test_def_user_canlogin" +== 042 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_user_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_def_user_canlogin'" +== 043 +-- truncate_limit: 100 +CREATE USER regress_test_user_canlogin WITH NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_test_user_canlogin WITH NOLOGIN" +== 044 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_user_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_user_canlogin'" +== 045 +-- truncate_limit: 100 +ALTER USER regress_test_user_canlogin WITH LOGIN +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_user_canlogin WITH LOGIN" +== 046 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_user_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_user_canlogin'" +== 047 +-- truncate_limit: 100 +ALTER USER regress_test_user_canlogin WITH NOLOGIN +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_user_canlogin WITH NOLOGIN" +== 048 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_user_canlogin' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_user_canlogin'" +== 049 +-- truncate_limit: 100 +-- default for replication is false +CREATE ROLE regress_test_def_replication +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_def_replication" +== 050 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_replication' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_def_replication'" +== 051 +-- truncate_limit: 100 +CREATE ROLE regress_test_replication WITH REPLICATION +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_replication WITH REPLICATION" +== 052 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_replication' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_replication'" +== 053 +-- truncate_limit: 100 +ALTER ROLE regress_test_replication WITH NOREPLICATION +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_replication WITH NOREPLICATION" +== 054 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_replication' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_replication'" +== 055 +-- truncate_limit: 100 +ALTER ROLE regress_test_replication WITH REPLICATION +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_replication WITH REPLICATION" +== 056 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_replication' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_replication'" +== 057 +-- truncate_limit: 100 +-- default for bypassrls is false +CREATE ROLE regress_test_def_bypassrls +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_def_bypassrls" +== 058 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_def_bypassrls' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_def_bypassrls'" +== 059 +-- truncate_limit: 100 +CREATE ROLE regress_test_bypassrls WITH BYPASSRLS +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_test_bypassrls WITH BYPASSRLS" +== 060 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_bypassrls' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_bypassrls'" +== 061 +-- truncate_limit: 100 +ALTER ROLE regress_test_bypassrls WITH NOBYPASSRLS +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_bypassrls WITH NOBYPASSRLS" +== 062 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_bypassrls' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_bypassrls'" +== 063 +-- truncate_limit: 100 +ALTER ROLE regress_test_bypassrls WITH BYPASSRLS +-- +STMT: AlterRoleStmt +TRUNCATED: "ALTER ROLE regress_test_bypassrls WITH BYPASSRLS" +== 064 +-- truncate_limit: 100 +SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolreplication, rolbypassrls, rolconnlimit, rolpassword, rolvaliduntil FROM pg_authid WHERE rolname = 'regress_test_bypassrls' +-- +TABLE: name="pg_authid" schema="" table="pg_authid" ctx=Select +FILTER: schema="" table="" column="rolname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_authid WHERE rolname = 'regress_test_bypassrls'" +== 065 +-- truncate_limit: 100 +-- clean up roles +DROP ROLE regress_test_def_superuser +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_def_superuser" +== 066 +-- truncate_limit: 100 +DROP ROLE regress_test_superuser +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_superuser" +== 067 +-- truncate_limit: 100 +DROP ROLE regress_test_def_inherit +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_def_inherit" +== 068 +-- truncate_limit: 100 +DROP ROLE regress_test_inherit +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_inherit" +== 069 +-- truncate_limit: 100 +DROP ROLE regress_test_def_createrole +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_def_createrole" +== 070 +-- truncate_limit: 100 +DROP ROLE regress_test_createrole +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_createrole" +== 071 +-- truncate_limit: 100 +DROP ROLE regress_test_def_createdb +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_def_createdb" +== 072 +-- truncate_limit: 100 +DROP ROLE regress_test_createdb +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_createdb" +== 073 +-- truncate_limit: 100 +DROP ROLE regress_test_def_role_canlogin +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_def_role_canlogin" +== 074 +-- truncate_limit: 100 +DROP ROLE regress_test_role_canlogin +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_role_canlogin" +== 075 +-- truncate_limit: 100 +DROP USER regress_test_def_user_canlogin +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_def_user_canlogin" +== 076 +-- truncate_limit: 100 +DROP USER regress_test_user_canlogin +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_user_canlogin" +== 077 +-- truncate_limit: 100 +DROP ROLE regress_test_def_replication +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_def_replication" +== 078 +-- truncate_limit: 100 +DROP ROLE regress_test_replication +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_replication" +== 079 +-- truncate_limit: 100 +DROP ROLE regress_test_def_bypassrls +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_def_bypassrls" +== 080 +-- truncate_limit: 100 +DROP ROLE regress_test_bypassrls +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_test_bypassrls" diff --git a/parser/testdata/summary_truncate/postgres_regress/rowsecurity.metadata.json b/parser/testdata/summary_truncate/postgres_regress/rowsecurity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rowsecurity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/rowsecurity.test b/parser/testdata/summary_truncate/postgres_regress/rowsecurity.test new file mode 100644 index 0000000..ab90e30 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rowsecurity.test @@ -0,0 +1,6370 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test of Row-level security feature +|-- + +-- Clean up in case a prior regression run failed + +-- Suppress NOTICE messages when users/groups don't exist +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 002 +-- truncate_limit: 100 +DROP USER IF EXISTS regress_rls_alice +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_rls_alice" +== 003 +-- truncate_limit: 100 +DROP USER IF EXISTS regress_rls_bob +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_rls_bob" +== 004 +-- truncate_limit: 100 +DROP USER IF EXISTS regress_rls_carol +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_rls_carol" +== 005 +-- truncate_limit: 100 +DROP USER IF EXISTS regress_rls_dave +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_rls_dave" +== 006 +-- truncate_limit: 100 +DROP USER IF EXISTS regress_rls_exempt_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_rls_exempt_user" +== 007 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_rls_group1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_rls_group1" +== 008 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_rls_group2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_rls_group2" +== 009 +-- truncate_limit: 100 +DROP SCHEMA IF EXISTS regress_rls_schema CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA IF EXISTS regress_rls_schema CASCADE" +== 010 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 011 +-- truncate_limit: 100 +-- initial setup +CREATE USER regress_rls_alice NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_rls_alice WITH NOLOGIN" +== 012 +-- truncate_limit: 100 +CREATE USER regress_rls_bob NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_rls_bob WITH NOLOGIN" +== 013 +-- truncate_limit: 100 +CREATE USER regress_rls_carol NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_rls_carol WITH NOLOGIN" +== 014 +-- truncate_limit: 100 +CREATE USER regress_rls_dave NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_rls_dave WITH NOLOGIN" +== 015 +-- truncate_limit: 100 +CREATE USER regress_rls_exempt_user BYPASSRLS NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_rls_exempt_user WITH BYPASSRLS NOLOGIN" +== 016 +-- truncate_limit: 100 +CREATE ROLE regress_rls_group1 NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rls_group1 WITH NOLOGIN" +== 017 +-- truncate_limit: 100 +CREATE ROLE regress_rls_group2 NOLOGIN +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_rls_group2 WITH NOLOGIN" +== 018 +-- truncate_limit: 100 +GRANT regress_rls_group1 TO regress_rls_bob +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_rls_group1 TO regress_rls_bob" +== 019 +-- truncate_limit: 100 +GRANT regress_rls_group2 TO regress_rls_carol +-- +STMT: GrantRoleStmt +TRUNCATED: "GRANT regress_rls_group2 TO regress_rls_carol" +== 020 +-- truncate_limit: 100 +CREATE SCHEMA regress_rls_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_rls_schema" +== 021 +-- truncate_limit: 100 +GRANT ALL ON SCHEMA regress_rls_schema to public +-- +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON SCHEMA regress_rls_schema TO public" +== 022 +-- truncate_limit: 100 +SET search_path = regress_rls_schema +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO regress_rls_schema" +== 023 +-- truncate_limit: 100 +-- setup of malicious function +CREATE OR REPLACE FUNCTION f_leak(text) RETURNS bool + COST 0.0000001 LANGUAGE plpgsql + AS 'BEGIN RAISE NOTICE ''f_leak => %'', $1; RETURN true; END' +-- +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION f_leak(text) RETURNS bool COST 0.0000001 LANGUAGE plpgsql AS $$BEGIN R..." +== 024 +-- truncate_limit: 100 +GRANT EXECUTE ON FUNCTION f_leak(text) TO public +-- +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT execute ON FUNCTION f_leak(text) TO public" +== 025 +-- truncate_limit: 100 +-- BASIC Row-Level Security Scenario + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 026 +-- truncate_limit: 100 +CREATE TABLE uaccount ( + pguser name primary key, + seclv int +) +-- +TABLE: name="uaccount" schema="" table="uaccount" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE uaccount (pguser name PRIMARY KEY, seclv int)" +== 027 +-- truncate_limit: 100 +GRANT SELECT ON uaccount TO public +-- +TABLE: name="uaccount" schema="" table="uaccount" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON uaccount TO public" +== 028 +-- truncate_limit: 100 +INSERT INTO uaccount VALUES + ('regress_rls_alice', 99), + ('regress_rls_bob', 1), + ('regress_rls_carol', 2), + ('regress_rls_dave', 3) +-- +TABLE: name="uaccount" schema="" table="uaccount" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uaccount VALUES (...)" +== 029 +-- truncate_limit: 100 +CREATE TABLE category ( + cid int primary key, + cname text +) +-- +TABLE: name="category" schema="" table="category" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE category (cid int PRIMARY KEY, cname text)" +== 030 +-- truncate_limit: 100 +GRANT ALL ON category TO public +-- +TABLE: name="category" schema="" table="category" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON category TO public" +== 031 +-- truncate_limit: 100 +INSERT INTO category VALUES + (11, 'novel'), + (22, 'science fiction'), + (33, 'technology'), + (44, 'manga') +-- +TABLE: name="category" schema="" table="category" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO category VALUES (...)" +== 032 +-- truncate_limit: 100 +CREATE TABLE document ( + did int primary key, + cid int references category(cid), + dlevel int not null, + dauthor name, + dtitle text +) +-- +TABLE: name="document" schema="" table="document" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE document (did int PRIMARY KEY, cid int REFERENCES category (cid), dlevel int NOT NUL..." +== 033 +-- truncate_limit: 100 +GRANT ALL ON document TO public +-- +TABLE: name="document" schema="" table="document" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON document TO public" +== 034 +-- truncate_limit: 100 +INSERT INTO document VALUES + ( 1, 11, 1, 'regress_rls_bob', 'my first novel'), + ( 2, 11, 2, 'regress_rls_bob', 'my second novel'), + ( 3, 22, 2, 'regress_rls_bob', 'my science fiction'), + ( 4, 44, 1, 'regress_rls_bob', 'my first manga'), + ( 5, 44, 2, 'regress_rls_bob', 'my second manga'), + ( 6, 22, 1, 'regress_rls_carol', 'great science fiction'), + ( 7, 33, 2, 'regress_rls_carol', 'great technology book'), + ( 8, 44, 1, 'regress_rls_carol', 'great manga'), + ( 9, 22, 1, 'regress_rls_dave', 'awesome science fiction'), + (10, 33, 2, 'regress_rls_dave', 'awesome technology book') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...)" +== 035 +-- truncate_limit: 100 +ALTER TABLE document ENABLE ROW LEVEL SECURITY +-- +TABLE: name="document" schema="" table="document" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE document ENABLE ROW LEVEL SECURITY" +== 036 +-- truncate_limit: 100 +-- user's security level must be higher than or equal to document's +CREATE POLICY p1 ON document AS PERMISSIVE + USING (dlevel <= (SELECT seclv FROM uaccount WHERE pguser = current_user)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON document TO public USING (dlevel <= (SELECT seclv FROM uaccount WHERE pguser ..." +== 037 +-- truncate_limit: 100 +-- try to create a policy of bogus type +CREATE POLICY p1 ON document AS UGLY + USING (dlevel <= (SELECT seclv FROM uaccount WHERE pguser = current_user)) +-- +ERROR: unrecognized row security option "ugly" +CURSORPOS: 73 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 038 +-- truncate_limit: 100 +-- but Dave isn't allowed to anything at cid 50 or above +-- this is to make sure that we sort the policies by name first +-- when applying WITH CHECK, a later INSERT by Dave should fail due +-- to p1r first +CREATE POLICY p2r ON document AS RESTRICTIVE TO regress_rls_dave + USING (cid <> 44 AND cid < 50) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2r ON document AS RESTRICTIVE TO regress_rls_dave USING (cid <> 44 AND cid < 50)" +== 039 +-- truncate_limit: 100 +-- and Dave isn't allowed to see manga documents +CREATE POLICY p1r ON document AS RESTRICTIVE TO regress_rls_dave + USING (cid <> 44) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1r ON document AS RESTRICTIVE TO regress_rls_dave USING (cid <> 44)" +== 040 +-- truncate_limit: 100 +SELECT * FROM pg_policies WHERE schemaname = 'regress_rls_schema' AND tablename = 'document' ORDER BY policyname +-- +TABLE: name="pg_policies" schema="" table="pg_policies" ctx=Select +FILTER: schema="" table="" column="schemaname" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_policies WHERE ... ORDER BY policyname" +== 041 +-- truncate_limit: 100 +-- viewpoint from regress_rls_bob +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 042 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 043 +-- truncate_limit: 100 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did" +== 044 +-- truncate_limit: 100 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did" +== 045 +-- truncate_limit: 100 +-- try a sampled version +SELECT * FROM document TABLESAMPLE BERNOULLI(50) REPEATABLE(0) + WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document TABLESAMPLE bernoulli(50) REPEATABLE (0) WHERE f_leak(dtitle) ORDER BY did" +== 046 +-- truncate_limit: 100 +-- viewpoint from regress_rls_carol +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 047 +-- truncate_limit: 100 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did" +== 048 +-- truncate_limit: 100 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did" +== 049 +-- truncate_limit: 100 +-- try a sampled version +SELECT * FROM document TABLESAMPLE BERNOULLI(50) REPEATABLE(0) + WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document TABLESAMPLE bernoulli(50) REPEATABLE (0) WHERE f_leak(dtitle) ORDER BY did" +== 050 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle)" +== 051 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle)" +== 052 +-- truncate_limit: 100 +-- viewpoint from regress_rls_dave +SET SESSION AUTHORIZATION regress_rls_dave +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_dave" +== 053 +-- truncate_limit: 100 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did" +== 054 +-- truncate_limit: 100 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did" +== 055 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle)" +== 056 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle)" +== 057 +-- truncate_limit: 100 +-- 44 would technically fail for both p2r and p1r, but we should get an error +-- back from p1r for this because it sorts first +INSERT INTO document VALUES (100, 44, 1, 'regress_rls_dave', 'testing sorting of policies') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (100, 44, 1, 'regress_rls_dave', 'testing sorting of policies')" +== 058 +-- truncate_limit: 100 +-- fail +-- Just to see a p2r error +INSERT INTO document VALUES (100, 55, 1, 'regress_rls_dave', 'testing sorting of policies') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (100, 55, 1, 'regress_rls_dave', 'testing sorting of policies')" +== 059 +-- truncate_limit: 100 +-- fail + +-- only owner can change policies +ALTER POLICY p1 ON document USING (true) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY p1 ON document USING (true)" +== 060 +-- truncate_limit: 100 +--fail +DROP POLICY p1 ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p1 ON document" +== 061 +-- truncate_limit: 100 +--fail + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 062 +-- truncate_limit: 100 +ALTER POLICY p1 ON document USING (dauthor = current_user) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY p1 ON document USING (dauthor = current_user)" +== 063 +-- truncate_limit: 100 +-- viewpoint from regress_rls_bob again +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 064 +-- truncate_limit: 100 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did" +== 065 +-- truncate_limit: 100 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER by did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did" +== 066 +-- truncate_limit: 100 +-- viewpoint from rls_regres_carol again +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 067 +-- truncate_limit: 100 +SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE f_leak(dtitle) ORDER BY did" +== 068 +-- truncate_limit: 100 +SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER by did +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) ORDER BY did" +== 069 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle)" +== 070 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle) +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle)" +== 071 +-- truncate_limit: 100 +-- interaction of FK/PK constraints +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 072 +-- truncate_limit: 100 +CREATE POLICY p2 ON category + USING (CASE WHEN current_user = 'regress_rls_bob' THEN cid IN (11, 33) + WHEN current_user = 'regress_rls_carol' THEN cid IN (22, 44) + ELSE false END) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON category TO public USING (CASE WHEN current_user = 'regress_rls_bob' THEN cid..." +== 073 +-- truncate_limit: 100 +ALTER TABLE category ENABLE ROW LEVEL SECURITY +-- +TABLE: name="category" schema="" table="category" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE category ENABLE ROW LEVEL SECURITY" +== 074 +-- truncate_limit: 100 +-- cannot delete PK referenced by invisible FK +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 075 +-- truncate_limit: 100 +SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +ALIAS: "c"="category" +ALIAS: "d"="document" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document d FULL JOIN category c ON d.cid = c.cid ORDER BY d.did, c.cid" +== 076 +-- truncate_limit: 100 +DELETE FROM category WHERE cid = 33 +-- +TABLE: name="category" schema="" table="category" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM category WHERE cid = 33" +== 077 +-- truncate_limit: 100 +-- fails with FK violation + +-- can insert FK referencing invisible PK +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 078 +-- truncate_limit: 100 +SELECT * FROM document d FULL OUTER JOIN category c on d.cid = c.cid ORDER BY d.did, c.cid +-- +TABLE: name="document" schema="" table="document" ctx=Select +TABLE: name="category" schema="" table="category" ctx=Select +ALIAS: "c"="category" +ALIAS: "d"="document" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document d FULL JOIN category c ON d.cid = c.cid ORDER BY d.did, c.cid" +== 079 +-- truncate_limit: 100 +INSERT INTO document VALUES (11, 33, 1, current_user, 'hoge') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (11, 33, 1, current_user, 'hoge')" +== 080 +-- truncate_limit: 100 +-- UNIQUE or PRIMARY KEY constraint violation DOES reveal presence of row +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 081 +-- truncate_limit: 100 +INSERT INTO document VALUES (8, 44, 1, 'regress_rls_bob', 'my third manga') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (8, 44, 1, 'regress_rls_bob', 'my third manga')" +== 082 +-- truncate_limit: 100 +-- Must fail with unique violation, revealing presence of did we can't see +SELECT * FROM document WHERE did = 8 +-- +TABLE: name="document" schema="" table="document" ctx=Select +FILTER: schema="" table="" column="did" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE did = 8" +== 083 +-- truncate_limit: 100 +-- and confirm we can't see it + +-- RLS policies are checked before constraints +INSERT INTO document VALUES (8, 44, 1, 'regress_rls_carol', 'my third manga') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (8, 44, 1, 'regress_rls_carol', 'my third manga')" +== 084 +-- truncate_limit: 100 +-- Should fail with RLS check violation, not duplicate key violation +UPDATE document SET did = 8, dauthor = 'regress_rls_carol' WHERE did = 5 +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE document SET did = 8, dauthor = 'regress_rls_carol' WHERE did = 5" +== 085 +-- truncate_limit: 100 +-- Should fail with RLS check violation, not duplicate key violation + +-- database superuser does bypass RLS policy when enabled +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 086 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 087 +-- truncate_limit: 100 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document" +== 088 +-- truncate_limit: 100 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM category" +== 089 +-- truncate_limit: 100 +-- database superuser does bypass RLS policy when disabled +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 090 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 091 +-- truncate_limit: 100 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document" +== 092 +-- truncate_limit: 100 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM category" +== 093 +-- truncate_limit: 100 +-- database non-superuser with bypass privilege can bypass RLS policy when disabled +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_exempt_user" +== 094 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 095 +-- truncate_limit: 100 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document" +== 096 +-- truncate_limit: 100 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM category" +== 097 +-- truncate_limit: 100 +-- RLS policy does not apply to table owner when RLS enabled. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 098 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 099 +-- truncate_limit: 100 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document" +== 100 +-- truncate_limit: 100 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM category" +== 101 +-- truncate_limit: 100 +-- RLS policy does not apply to table owner when RLS disabled. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 102 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 103 +-- truncate_limit: 100 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document" +== 104 +-- truncate_limit: 100 +SELECT * FROM category +-- +TABLE: name="category" schema="" table="category" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM category" +== 105 +-- truncate_limit: 100 +|-- +-- Table inheritance and RLS policy +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 106 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 107 +-- truncate_limit: 100 +CREATE TABLE t1 (id int not null primary key, a int, junk1 text, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int, junk1 text, b text)" +== 108 +-- truncate_limit: 100 +ALTER TABLE t1 DROP COLUMN junk1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t1 DROP junk1" +== 109 +-- truncate_limit: 100 +-- just a disturbing factor +GRANT ALL ON t1 TO public +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON t1 TO public" +== 110 +-- truncate_limit: 100 +COPY t1 FROM stdin WITH +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY t1 FROM STDIN" +== 111 +-- truncate_limit: 100 +CREATE TABLE t2 (c float) INHERITS (t1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t2 (c double precision) INHERITS (t1)" +== 112 +-- truncate_limit: 100 +GRANT ALL ON t2 TO public +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON t2 TO public" +== 113 +-- truncate_limit: 100 +COPY t2 FROM stdin +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY t2 FROM STDIN" +== 114 +-- truncate_limit: 100 +CREATE TABLE t3 (id int not null primary key, c text, b text, a int) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t3 (id int NOT NULL PRIMARY KEY, c text, b text, a int)" +== 115 +-- truncate_limit: 100 +ALTER TABLE t3 INHERIT t1 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t3 INHERIT t1" +== 116 +-- truncate_limit: 100 +GRANT ALL ON t3 TO public +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON t3 TO public" +== 117 +-- truncate_limit: 100 +COPY t3(id, a,b,c) FROM stdin +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY t3(id, a, b, c) FROM STDIN" +== 118 +-- truncate_limit: 100 +CREATE POLICY p1 ON t1 FOR ALL TO PUBLIC USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON t1 TO public USING ((a % 2) = 0)" +== 119 +-- truncate_limit: 100 +-- be even number +CREATE POLICY p2 ON t2 FOR ALL TO PUBLIC USING (a % 2 = 1) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON t2 TO public USING ((a % 2) = 1)" +== 120 +-- truncate_limit: 100 +-- be odd number + +ALTER TABLE t1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t1 ENABLE ROW LEVEL SECURITY" +== 121 +-- truncate_limit: 100 +ALTER TABLE t2 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t2 ENABLE ROW LEVEL SECURITY" +== 122 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 123 +-- truncate_limit: 100 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 124 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1" +== 125 +-- truncate_limit: 100 +SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 WHERE f_leak(b)" +== 126 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b)" +== 127 +-- truncate_limit: 100 +-- reference to system column +SELECT tableoid::regclass, * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM t1" +== 128 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT *, t1 FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT *, t1 FROM t1" +== 129 +-- truncate_limit: 100 +-- reference to whole-row reference +SELECT *, t1 FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT *, t1 FROM t1" +== 130 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT *, t1 FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT *, t1 FROM t1" +== 131 +-- truncate_limit: 100 +-- for share/update lock +SELECT * FROM t1 FOR SHARE +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 FOR SHARE" +== 132 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 FOR SHARE +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 FOR SHARE" +== 133 +-- truncate_limit: 100 +SELECT * FROM t1 WHERE f_leak(b) FOR SHARE +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 WHERE f_leak(b) FOR SHARE" +== 134 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) FOR SHARE +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) FOR SHARE" +== 135 +-- truncate_limit: 100 +-- union all query +SELECT a, b, tableoid::regclass FROM t2 UNION ALL SELECT a, b, tableoid::regclass FROM t3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b, tableoid::regclass FROM t2 UNION ALL SELECT a, b, tableoid::regclass FROM t3" +== 136 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT a, b, tableoid::regclass FROM t2 UNION ALL SELECT a, b, tableoid::regclass FROM t3 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b, tableoid::regclass FROM t2 UNION ALL SELECT a, b, tableoid::regc..." +== 137 +-- truncate_limit: 100 +-- superuser is allowed to bypass RLS checks +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 138 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 139 +-- truncate_limit: 100 +SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 WHERE f_leak(b)" +== 140 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b)" +== 141 +-- truncate_limit: 100 +-- non-superuser with bypass privilege can bypass RLS policy when disabled +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_exempt_user" +== 142 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 143 +-- truncate_limit: 100 +SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 WHERE f_leak(b)" +== 144 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b)" +== 145 +-- truncate_limit: 100 +|-- +-- Partitioned Tables +|-- + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 146 +-- truncate_limit: 100 +CREATE TABLE part_document ( + did int, + cid int, + dlevel int not null, + dauthor name, + dtitle text +) PARTITION BY RANGE (cid) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_document (did int, cid int, dlevel int NOT NULL, dauthor name, dtitle text) PAR..." +== 147 +-- truncate_limit: 100 +GRANT ALL ON part_document TO public +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON part_document TO public" +== 148 +-- truncate_limit: 100 +-- Create partitions for document categories +CREATE TABLE part_document_fiction PARTITION OF part_document FOR VALUES FROM (11) to (12) +-- +TABLE: name="part_document_fiction" schema="" table="part_document_fiction" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_document_fiction PARTITION OF part_document FOR VALUES FROM (11) TO (12)" +== 149 +-- truncate_limit: 100 +CREATE TABLE part_document_satire PARTITION OF part_document FOR VALUES FROM (55) to (56) +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_document_satire PARTITION OF part_document FOR VALUES FROM (55) TO (56)" +== 150 +-- truncate_limit: 100 +CREATE TABLE part_document_nonfiction PARTITION OF part_document FOR VALUES FROM (99) to (100) +-- +TABLE: name="part_document_nonfiction" schema="" table="part_document_nonfiction" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_document_nonfiction PARTITION OF part_document FOR VALUES FROM (99) TO (100)" +== 151 +-- truncate_limit: 100 +GRANT ALL ON part_document_fiction TO public +-- +TABLE: name="part_document_fiction" schema="" table="part_document_fiction" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON part_document_fiction TO public" +== 152 +-- truncate_limit: 100 +GRANT ALL ON part_document_satire TO public +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON part_document_satire TO public" +== 153 +-- truncate_limit: 100 +GRANT ALL ON part_document_nonfiction TO public +-- +TABLE: name="part_document_nonfiction" schema="" table="part_document_nonfiction" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON part_document_nonfiction TO public" +== 154 +-- truncate_limit: 100 +INSERT INTO part_document VALUES + ( 1, 11, 1, 'regress_rls_bob', 'my first novel'), + ( 2, 11, 2, 'regress_rls_bob', 'my second novel'), + ( 3, 99, 2, 'regress_rls_bob', 'my science textbook'), + ( 4, 55, 1, 'regress_rls_bob', 'my first satire'), + ( 5, 99, 2, 'regress_rls_bob', 'my history book'), + ( 6, 11, 1, 'regress_rls_carol', 'great science fiction'), + ( 7, 99, 2, 'regress_rls_carol', 'great technology book'), + ( 8, 55, 2, 'regress_rls_carol', 'great satire'), + ( 9, 11, 1, 'regress_rls_dave', 'awesome science fiction'), + (10, 99, 2, 'regress_rls_dave', 'awesome technology book') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_document VALUES (...)" +== 155 +-- truncate_limit: 100 +ALTER TABLE part_document ENABLE ROW LEVEL SECURITY +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_document ENABLE ROW LEVEL SECURITY" +== 156 +-- truncate_limit: 100 +-- Create policy on parent +-- user's security level must be higher than or equal to document's +CREATE POLICY pp1 ON part_document AS PERMISSIVE + USING (dlevel <= (SELECT seclv FROM uaccount WHERE pguser = current_user)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY pp1 ON part_document TO public USING (dlevel <= (SELECT seclv FROM uaccount WHERE p..." +== 157 +-- truncate_limit: 100 +-- Dave is only allowed to see cid < 55 +CREATE POLICY pp1r ON part_document AS RESTRICTIVE TO regress_rls_dave + USING (cid < 55) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY pp1r ON part_document AS RESTRICTIVE TO regress_rls_dave USING (cid < 55)" +== 158 +-- truncate_limit: 100 +SELECT * FROM pg_policies WHERE schemaname = 'regress_rls_schema' AND tablename like '%part_document%' ORDER BY policyname +-- +TABLE: name="pg_policies" schema="" table="pg_policies" ctx=Select +FILTER: schema="" table="" column="schemaname" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_policies WHERE ... ORDER BY policyname" +== 159 +-- truncate_limit: 100 +-- viewpoint from regress_rls_bob +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 160 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 161 +-- truncate_limit: 100 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did" +== 162 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle)" +== 163 +-- truncate_limit: 100 +-- viewpoint from regress_rls_carol +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 164 +-- truncate_limit: 100 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did" +== 165 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle)" +== 166 +-- truncate_limit: 100 +-- viewpoint from regress_rls_dave +SET SESSION AUTHORIZATION regress_rls_dave +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_dave" +== 167 +-- truncate_limit: 100 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did" +== 168 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle)" +== 169 +-- truncate_limit: 100 +-- pp1 ERROR +INSERT INTO part_document VALUES (100, 11, 5, 'regress_rls_dave', 'testing pp1') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_document VALUES (100, 11, 5, 'regress_rls_dave', 'testing pp1')" +== 170 +-- truncate_limit: 100 +-- fail +-- pp1r ERROR +INSERT INTO part_document VALUES (100, 99, 1, 'regress_rls_dave', 'testing pp1r') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_document VALUES (100, 99, 1, 'regress_rls_dave', 'testing pp1r')" +== 171 +-- truncate_limit: 100 +-- fail + +-- Show that RLS policy does not apply for direct inserts to children +-- This should fail with RLS POLICY pp1r violation. +INSERT INTO part_document VALUES (100, 55, 1, 'regress_rls_dave', 'testing RLS with partitions') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_document VALUES (100, 55, 1, 'regress_rls_dave', 'testing RLS with partitions')" +== 172 +-- truncate_limit: 100 +-- fail +-- But this should succeed. +INSERT INTO part_document_satire VALUES (100, 55, 1, 'regress_rls_dave', 'testing RLS with partitions') +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_document_satire VALUES (...)" +== 173 +-- truncate_limit: 100 +-- success +-- We still cannot see the row using the parent +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did" +== 174 +-- truncate_limit: 100 +-- But we can if we look directly +SELECT * FROM part_document_satire WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document_satire WHERE f_leak(dtitle) ORDER BY did" +== 175 +-- truncate_limit: 100 +-- Turn on RLS and create policy on child to show RLS is checked before constraints +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 176 +-- truncate_limit: 100 +ALTER TABLE part_document_satire ENABLE ROW LEVEL SECURITY +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_document_satire ENABLE ROW LEVEL SECURITY" +== 177 +-- truncate_limit: 100 +CREATE POLICY pp3 ON part_document_satire AS RESTRICTIVE + USING (cid < 55) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY pp3 ON part_document_satire AS RESTRICTIVE TO public USING (cid < 55)" +== 178 +-- truncate_limit: 100 +-- This should fail with RLS violation now. +SET SESSION AUTHORIZATION regress_rls_dave +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_dave" +== 179 +-- truncate_limit: 100 +INSERT INTO part_document_satire VALUES (101, 55, 1, 'regress_rls_dave', 'testing RLS with partitions') +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_document_satire VALUES (...)" +== 180 +-- truncate_limit: 100 +-- fail +-- And now we cannot see directly into the partition either, due to RLS +SELECT * FROM part_document_satire WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document_satire WHERE f_leak(dtitle) ORDER BY did" +== 181 +-- truncate_limit: 100 +-- The parent looks same as before +-- viewpoint from regress_rls_dave +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did" +== 182 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle)" +== 183 +-- truncate_limit: 100 +-- viewpoint from regress_rls_carol +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 184 +-- truncate_limit: 100 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did" +== 185 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle)" +== 186 +-- truncate_limit: 100 +-- only owner can change policies +ALTER POLICY pp1 ON part_document USING (true) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY pp1 ON part_document USING (true)" +== 187 +-- truncate_limit: 100 +--fail +DROP POLICY pp1 ON part_document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY pp1 ON part_document" +== 188 +-- truncate_limit: 100 +--fail + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 189 +-- truncate_limit: 100 +ALTER POLICY pp1 ON part_document USING (dauthor = current_user) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY pp1 ON part_document USING (dauthor = current_user)" +== 190 +-- truncate_limit: 100 +-- viewpoint from regress_rls_bob again +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 191 +-- truncate_limit: 100 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did" +== 192 +-- truncate_limit: 100 +-- viewpoint from rls_regres_carol again +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 193 +-- truncate_limit: 100 +SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document WHERE f_leak(dtitle) ORDER BY did" +== 194 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle) +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="dtitle" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle)" +== 195 +-- truncate_limit: 100 +-- database superuser does bypass RLS policy when enabled +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 196 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 197 +-- truncate_limit: 100 +SELECT * FROM part_document ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document ORDER BY did" +== 198 +-- truncate_limit: 100 +SELECT * FROM part_document_satire ORDER by did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document_satire ORDER BY did" +== 199 +-- truncate_limit: 100 +-- database non-superuser with bypass privilege can bypass RLS policy when disabled +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_exempt_user" +== 200 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 201 +-- truncate_limit: 100 +SELECT * FROM part_document ORDER BY did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document ORDER BY did" +== 202 +-- truncate_limit: 100 +SELECT * FROM part_document_satire ORDER by did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document_satire ORDER BY did" +== 203 +-- truncate_limit: 100 +-- RLS policy does not apply to table owner when RLS enabled. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 204 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 205 +-- truncate_limit: 100 +SELECT * FROM part_document ORDER by did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document ORDER BY did" +== 206 +-- truncate_limit: 100 +SELECT * FROM part_document_satire ORDER by did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document_satire ORDER BY did" +== 207 +-- truncate_limit: 100 +-- When RLS disabled, other users get ERROR. +SET SESSION AUTHORIZATION regress_rls_dave +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_dave" +== 208 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 209 +-- truncate_limit: 100 +SELECT * FROM part_document ORDER by did +-- +TABLE: name="part_document" schema="" table="part_document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document ORDER BY did" +== 210 +-- truncate_limit: 100 +SELECT * FROM part_document_satire ORDER by did +-- +TABLE: name="part_document_satire" schema="" table="part_document_satire" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM part_document_satire ORDER BY did" +== 211 +-- truncate_limit: 100 +-- Check behavior with a policy that uses a SubPlan not an InitPlan. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 212 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 213 +-- truncate_limit: 100 +CREATE POLICY pp3 ON part_document AS RESTRICTIVE + USING ((SELECT dlevel <= seclv FROM uaccount WHERE pguser = current_user)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY pp3 ON part_document AS RESTRICTIVE TO public USING ((SELECT dlevel <= seclv FROM u..." +== 214 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 215 +-- truncate_limit: 100 +INSERT INTO part_document VALUES (100, 11, 5, 'regress_rls_carol', 'testing pp3') +-- +TABLE: name="part_document" schema="" table="part_document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO part_document VALUES (100, 11, 5, 'regress_rls_carol', 'testing pp3')" +== 216 +-- truncate_limit: 100 +-- fail + +----- Dependencies ----- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 217 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 218 +-- truncate_limit: 100 +CREATE TABLE dependee (x integer, y integer) +-- +TABLE: name="dependee" schema="" table="dependee" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dependee (x int, y int)" +== 219 +-- truncate_limit: 100 +CREATE TABLE dependent (x integer, y integer) +-- +TABLE: name="dependent" schema="" table="dependent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE dependent (x int, y int)" +== 220 +-- truncate_limit: 100 +CREATE POLICY d1 ON dependent FOR ALL + TO PUBLIC + USING (x = (SELECT d.x FROM dependee d WHERE d.y = y)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY d1 ON dependent TO public USING (x = (SELECT d.x FROM dependee d WHERE d.y = y))" +== 221 +-- truncate_limit: 100 +DROP TABLE dependee +-- +TABLE: name="dependee" schema="" table="dependee" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE dependee" +== 222 +-- truncate_limit: 100 +-- Should fail without CASCADE due to dependency on row security qual? + +DROP TABLE dependee CASCADE +-- +TABLE: name="dependee" schema="" table="dependee" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE dependee CASCADE" +== 223 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM dependent +-- +TABLE: name="dependent" schema="" table="dependent" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM dependent" +== 224 +-- truncate_limit: 100 +-- After drop, should be unqualified + +----- RECURSION ---- + +|-- +-- Simple recursion +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 225 +-- truncate_limit: 100 +CREATE TABLE rec1 (x integer, y integer) +-- +TABLE: name="rec1" schema="" table="rec1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rec1 (x int, y int)" +== 226 +-- truncate_limit: 100 +CREATE POLICY r1 ON rec1 USING (x = (SELECT r.x FROM rec1 r WHERE y = r.y)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY r1 ON rec1 TO public USING (x = (SELECT r.x FROM rec1 r WHERE y = r.y))" +== 227 +-- truncate_limit: 100 +ALTER TABLE rec1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="rec1" schema="" table="rec1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rec1 ENABLE ROW LEVEL SECURITY" +== 228 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 229 +-- truncate_limit: 100 +SELECT * FROM rec1 +-- +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rec1" +== 230 +-- truncate_limit: 100 +-- fail, direct recursion + +|-- +-- Mutual recursion +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 231 +-- truncate_limit: 100 +CREATE TABLE rec2 (a integer, b integer) +-- +TABLE: name="rec2" schema="" table="rec2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rec2 (a int, b int)" +== 232 +-- truncate_limit: 100 +ALTER POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2 WHERE b = y)) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2 WHERE b = y))" +== 233 +-- truncate_limit: 100 +CREATE POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1 WHERE y = b)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY r2 ON rec2 TO public USING (a = (SELECT x FROM rec1 WHERE y = b))" +== 234 +-- truncate_limit: 100 +ALTER TABLE rec2 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="rec2" schema="" table="rec2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rec2 ENABLE ROW LEVEL SECURITY" +== 235 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 236 +-- truncate_limit: 100 +SELECT * FROM rec1 +-- +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rec1" +== 237 +-- truncate_limit: 100 +-- fail, mutual recursion + +|-- +-- Mutual recursion via views +|-- +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 238 +-- truncate_limit: 100 +CREATE VIEW rec1v AS SELECT * FROM rec1 +-- +TABLE: name="rec1v" schema="" table="rec1v" ctx=DDL +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rec1v AS SELECT * FROM rec1" +== 239 +-- truncate_limit: 100 +CREATE VIEW rec2v AS SELECT * FROM rec2 +-- +TABLE: name="rec2v" schema="" table="rec2v" ctx=DDL +TABLE: name="rec2" schema="" table="rec2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rec2v AS SELECT * FROM rec2" +== 240 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 241 +-- truncate_limit: 100 +ALTER POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2v WHERE b = y)) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2v WHERE b = y))" +== 242 +-- truncate_limit: 100 +ALTER POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1v WHERE y = b)) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1v WHERE y = b))" +== 243 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 244 +-- truncate_limit: 100 +SELECT * FROM rec1 +-- +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rec1" +== 245 +-- truncate_limit: 100 +-- fail, mutual recursion via views + +|-- +-- Mutual recursion via .s.b views +|-- +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 246 +-- truncate_limit: 100 +DROP VIEW rec1v, rec2v CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rec1v, rec2v CASCADE" +== 247 +-- truncate_limit: 100 +CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1 +-- +TABLE: name="rec1v" schema="" table="rec1v" ctx=DDL +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1" +== 248 +-- truncate_limit: 100 +CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2 +-- +TABLE: name="rec2v" schema="" table="rec2v" ctx=DDL +TABLE: name="rec2" schema="" table="rec2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2" +== 249 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 250 +-- truncate_limit: 100 +CREATE POLICY r1 ON rec1 USING (x = (SELECT a FROM rec2v WHERE b = y)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY r1 ON rec1 TO public USING (x = (SELECT a FROM rec2v WHERE b = y))" +== 251 +-- truncate_limit: 100 +CREATE POLICY r2 ON rec2 USING (a = (SELECT x FROM rec1v WHERE y = b)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY r2 ON rec2 TO public USING (a = (SELECT x FROM rec1v WHERE y = b))" +== 252 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 253 +-- truncate_limit: 100 +SELECT * FROM rec1 +-- +TABLE: name="rec1" schema="" table="rec1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rec1" +== 254 +-- truncate_limit: 100 +-- fail, mutual recursion via s.b. views + +|-- +-- recursive RLS and VIEWs in policy +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 255 +-- truncate_limit: 100 +CREATE TABLE s1 (a int, b text) +-- +TABLE: name="s1" schema="" table="s1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE s1 (a int, b text)" +== 256 +-- truncate_limit: 100 +INSERT INTO s1 (SELECT x, public.fipshash(x::text) FROM generate_series(-10,10) x) +-- +TABLE: name="s1" schema="" table="s1" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO s1 SELECT x, public.fipshash(x::text) FROM generate_series(-10, 10) x" +== 257 +-- truncate_limit: 100 +CREATE TABLE s2 (x int, y text) +-- +TABLE: name="s2" schema="" table="s2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE s2 (x int, y text)" +== 258 +-- truncate_limit: 100 +INSERT INTO s2 (SELECT x, public.fipshash(x::text) FROM generate_series(-6,6) x) +-- +TABLE: name="s2" schema="" table="s2" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO s2 SELECT x, public.fipshash(x::text) FROM generate_series(-6, 6) x" +== 259 +-- truncate_limit: 100 +GRANT SELECT ON s1, s2 TO regress_rls_bob +-- +TABLE: name="s1" schema="" table="s1" ctx=DDL +TABLE: name="s2" schema="" table="s2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON s1, s2 TO regress_rls_bob" +== 260 +-- truncate_limit: 100 +CREATE POLICY p1 ON s1 USING (a in (select x from s2 where y like '%2f%')) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON s1 TO public USING (a IN (SELECT x FROM s2 WHERE y LIKE '%2f%'))" +== 261 +-- truncate_limit: 100 +CREATE POLICY p2 ON s2 USING (x in (select a from s1 where b like '%22%')) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON s2 TO public USING (x IN (SELECT a FROM s1 WHERE b LIKE '%22%'))" +== 262 +-- truncate_limit: 100 +CREATE POLICY p3 ON s1 FOR INSERT WITH CHECK (a = (SELECT a FROM s1)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3 ON s1 FOR INSERT TO public WITH CHECK (a = (SELECT a FROM s1))" +== 263 +-- truncate_limit: 100 +ALTER TABLE s1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="s1" schema="" table="s1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE s1 ENABLE ROW LEVEL SECURITY" +== 264 +-- truncate_limit: 100 +ALTER TABLE s2 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="s2" schema="" table="s2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE s2 ENABLE ROW LEVEL SECURITY" +== 265 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 266 +-- truncate_limit: 100 +CREATE VIEW v2 AS SELECT * FROM s2 WHERE y like '%af%' +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="s2" schema="" table="s2" ctx=Select +FILTER: schema="" table="" column="y" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v2 AS SELECT * FROM s2 WHERE y LIKE '%af%'" +== 267 +-- truncate_limit: 100 +SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM s1 WHERE f_leak(b)" +== 268 +-- truncate_limit: 100 +-- fail (infinite recursion) + +INSERT INTO s1 VALUES (1, 'foo') +-- +TABLE: name="s1" schema="" table="s1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO s1 VALUES (1, 'foo')" +== 269 +-- truncate_limit: 100 +-- fail (infinite recursion) + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 270 +-- truncate_limit: 100 +DROP POLICY p3 on s1 +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p3 ON s1" +== 271 +-- truncate_limit: 100 +ALTER POLICY p2 ON s2 USING (x % 2 = 0) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY p2 ON s2 USING ((x % 2) = 0)" +== 272 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 273 +-- truncate_limit: 100 +SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM s1 WHERE f_leak(b)" +== 274 +-- truncate_limit: 100 +-- OK +EXPLAIN (COSTS OFF) SELECT * FROM only s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM ONLY s1 WHERE f_leak(b)" +== 275 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 276 +-- truncate_limit: 100 +ALTER POLICY p1 ON s1 USING (a in (select x from v2)) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY p1 ON s1 USING (a IN (SELECT x FROM v2))" +== 277 +-- truncate_limit: 100 +-- using VIEW in RLS policy +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 278 +-- truncate_limit: 100 +SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM s1 WHERE f_leak(b)" +== 279 +-- truncate_limit: 100 +-- OK +EXPLAIN (COSTS OFF) SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM s1 WHERE f_leak(b)" +== 280 +-- truncate_limit: 100 +SELECT (SELECT x FROM s1 LIMIT 1) xx, * FROM s2 WHERE y like '%28%' +-- +TABLE: name="s2" schema="" table="s2" ctx=Select +TABLE: name="s1" schema="" table="s1" ctx=Select +FILTER: schema="" table="" column="y" +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT x FROM s1 LIMIT 1) AS xx, * FROM s2 WHERE y LIKE '%28%'" +== 281 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT (SELECT x FROM s1 LIMIT 1) xx, * FROM s2 WHERE y like '%28%' +-- +TABLE: name="s2" schema="" table="s2" ctx=Select +TABLE: name="s1" schema="" table="s1" ctx=Select +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT (SELECT x FROM s1 LIMIT 1) AS xx, * FROM s2 WHERE y LIKE '%28%'" +== 282 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 283 +-- truncate_limit: 100 +ALTER POLICY p2 ON s2 USING (x in (select a from s1 where b like '%d2%')) +-- +STMT: AlterPolicyStmt +TRUNCATED: "ALTER POLICY p2 ON s2 USING (x IN (SELECT a FROM s1 WHERE b LIKE '%d2%'))" +== 284 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 285 +-- truncate_limit: 100 +SELECT * FROM s1 WHERE f_leak(b) +-- +TABLE: name="s1" schema="" table="s1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM s1 WHERE f_leak(b)" +== 286 +-- truncate_limit: 100 +-- fail (infinite recursion via view) + +-- prepared statement with regress_rls_alice privilege +PREPARE p1(int) AS SELECT * FROM t1 WHERE a <= $1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE p1(int) AS SELECT * FROM t1 WHERE a <= $1" +== 287 +-- truncate_limit: 100 +EXECUTE p1(2) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p1(2)" +== 288 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE p1(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE p1(2)" +== 289 +-- truncate_limit: 100 +-- superuser is allowed to bypass RLS checks +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 290 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 291 +-- truncate_limit: 100 +SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 WHERE f_leak(b)" +== 292 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1 WHERE f_leak(b)" +== 293 +-- truncate_limit: 100 +-- plan cache should be invalidated +EXECUTE p1(2) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p1(2)" +== 294 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE p1(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE p1(2)" +== 295 +-- truncate_limit: 100 +PREPARE p2(int) AS SELECT * FROM t1 WHERE a = $1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE p2(int) AS SELECT * FROM t1 WHERE a = $1" +== 296 +-- truncate_limit: 100 +EXECUTE p2(2) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p2(2)" +== 297 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE p2(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE p2(2)" +== 298 +-- truncate_limit: 100 +-- also, case when privilege switch from superuser +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 299 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 300 +-- truncate_limit: 100 +EXECUTE p2(2) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p2(2)" +== 301 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE p2(2) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE p2(2)" +== 302 +-- truncate_limit: 100 +|-- +-- UPDATE / DELETE and Row-level security +|-- +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 303 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) UPDATE t1 SET b = b || b WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE t1 SET b = b || b WHERE f_leak(b)" +== 304 +-- truncate_limit: 100 +UPDATE t1 SET b = b || b WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE t1 SET b = b || b WHERE f_leak(b)" +== 305 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) UPDATE only t1 SET b = b || '_updt' WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE ONLY t1 SET b = b || '_updt' WHERE f_leak(b)" +== 306 +-- truncate_limit: 100 +UPDATE only t1 SET b = b || '_updt' WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE ONLY t1 SET b = b || '_updt' WHERE f_leak(b)" +== 307 +-- truncate_limit: 100 +-- returning clause with system column +UPDATE only t1 SET b = b WHERE f_leak(b) RETURNING tableoid::regclass, *, t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE ONLY t1 SET b = b WHERE f_leak(b) RETURNING tableoid::regclass, *, t1" +== 308 +-- truncate_limit: 100 +UPDATE t1 SET b = b WHERE f_leak(b) RETURNING * +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE t1 SET b = b WHERE f_leak(b) RETURNING *" +== 309 +-- truncate_limit: 100 +UPDATE t1 SET b = b WHERE f_leak(b) RETURNING tableoid::regclass, *, t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE t1 SET b = b WHERE f_leak(b) RETURNING tableoid::regclass, *, t1" +== 310 +-- truncate_limit: 100 +-- updates with from clause +EXPLAIN (COSTS OFF) UPDATE t2 SET b=t2.b FROM t3 +WHERE t2.a = 3 and t3.a = 2 AND f_leak(t2.b) AND f_leak(t3.b) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t3" schema="" table="t3" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE t2 SET b = t2.b FROM t3 WHERE t2.a = 3 AND t3.a = 2 AND f_leak(t2.b) A..." +== 311 +-- truncate_limit: 100 +UPDATE t2 SET b=t2.b FROM t3 +WHERE t2.a = 3 and t3.a = 2 AND f_leak(t2.b) AND f_leak(t3.b) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t3" schema="" table="t3" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE t2 SET b = t2.b FROM t3 WHERE t2.a = 3 AND t3.a = 2 AND f_leak(t2.b) AND f_leak(t3.b)" +== 312 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) UPDATE t1 SET b=t1.b FROM t2 +WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +TABLE: name="t2" schema="" table="t2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE t1 SET b = t1.b FROM t2 WHERE t1.a = 3 AND t2.a = 3 AND f_leak(t1.b) A..." +== 313 +-- truncate_limit: 100 +UPDATE t1 SET b=t1.b FROM t2 +WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +TABLE: name="t2" schema="" table="t2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE t1 SET b = t1.b FROM t2 WHERE t1.a = 3 AND t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b)" +== 314 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) UPDATE t2 SET b=t2.b FROM t1 +WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE t2 SET b = t2.b FROM t1 WHERE t1.a = 3 AND t2.a = 3 AND f_leak(t1.b) A..." +== 315 +-- truncate_limit: 100 +UPDATE t2 SET b=t2.b FROM t1 +WHERE t1.a = 3 and t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE t2 SET b = t2.b FROM t1 WHERE t1.a = 3 AND t2.a = 3 AND f_leak(t1.b) AND f_leak(t2.b)" +== 316 +-- truncate_limit: 100 +-- updates with from clause self join +EXPLAIN (COSTS OFF) UPDATE t2 t2_1 SET b = t2_2.b FROM t2 t2_2 +WHERE t2_1.a = 3 AND t2_2.a = t2_1.a AND t2_2.b = t2_1.b +AND f_leak(t2_1.b) AND f_leak(t2_2.b) RETURNING *, t2_1, t2_2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t2" schema="" table="t2" ctx=Select +ALIAS: "t2_1"="t2" +ALIAS: "t2_2"="t2" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE t2 t2_1 SET b = t2_2.b FROM t2 t2_2 WHERE t2_1.a = 3 AND t2_2.a = t2_1..." +== 317 +-- truncate_limit: 100 +UPDATE t2 t2_1 SET b = t2_2.b FROM t2 t2_2 +WHERE t2_1.a = 3 AND t2_2.a = t2_1.a AND t2_2.b = t2_1.b +AND f_leak(t2_1.b) AND f_leak(t2_2.b) RETURNING *, t2_1, t2_2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t2" schema="" table="t2" ctx=Select +ALIAS: "t2_1"="t2" +ALIAS: "t2_2"="t2" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE t2 t2_1 SET b = t2_2.b FROM t2 t2_2 WHERE ... RETURNING *, t2_1, t2_2" +== 318 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) UPDATE t1 t1_1 SET b = t1_2.b FROM t1 t1_2 +WHERE t1_1.a = 4 AND t1_2.a = t1_1.a AND t1_2.b = t1_1.b +AND f_leak(t1_1.b) AND f_leak(t1_2.b) RETURNING *, t1_1, t1_2 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +ALIAS: "t1_1"="t1" +ALIAS: "t1_2"="t1" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE t1 t1_1 SET b = t1_2.b FROM t1 t1_2 WHERE t1_1.a = 4 AND t1_2.a = t1_1..." +== 319 +-- truncate_limit: 100 +UPDATE t1 t1_1 SET b = t1_2.b FROM t1 t1_2 +WHERE t1_1.a = 4 AND t1_2.a = t1_1.a AND t1_2.b = t1_1.b +AND f_leak(t1_1.b) AND f_leak(t1_2.b) RETURNING *, t1_1, t1_2 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +ALIAS: "t1_1"="t1" +ALIAS: "t1_2"="t1" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE t1 t1_1 SET b = t1_2.b FROM t1 t1_2 WHERE ... RETURNING *, t1_1, t1_2" +== 320 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 321 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 322 +-- truncate_limit: 100 +SELECT * FROM t1 ORDER BY a,b +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 ORDER BY a, b" +== 323 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 324 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 325 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) DELETE FROM only t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM ONLY t1 WHERE f_leak(b)" +== 326 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) DELETE FROM t1 WHERE f_leak(b) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM t1 WHERE f_leak(b)" +== 327 +-- truncate_limit: 100 +DELETE FROM only t1 WHERE f_leak(b) RETURNING tableoid::regclass, *, t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ONLY t1 WHERE f_leak(b) RETURNING tableoid::regclass, *, t1" +== 328 +-- truncate_limit: 100 +DELETE FROM t1 WHERE f_leak(b) RETURNING tableoid::regclass, *, t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM t1 WHERE f_leak(b) RETURNING tableoid::regclass, *, t1" +== 329 +-- truncate_limit: 100 +|-- +-- S.b. view on top of Row-level security +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 330 +-- truncate_limit: 100 +CREATE TABLE b1 (a int, b text) +-- +TABLE: name="b1" schema="" table="b1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE b1 (a int, b text)" +== 331 +-- truncate_limit: 100 +INSERT INTO b1 (SELECT x, public.fipshash(x::text) FROM generate_series(-10,10) x) +-- +TABLE: name="b1" schema="" table="b1" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO b1 SELECT x, public.fipshash(x::text) FROM generate_series(-10, 10) x" +== 332 +-- truncate_limit: 100 +CREATE POLICY p1 ON b1 USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON b1 TO public USING ((a % 2) = 0)" +== 333 +-- truncate_limit: 100 +ALTER TABLE b1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="b1" schema="" table="b1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE b1 ENABLE ROW LEVEL SECURITY" +== 334 +-- truncate_limit: 100 +GRANT ALL ON b1 TO regress_rls_bob +-- +TABLE: name="b1" schema="" table="b1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON b1 TO regress_rls_bob" +== 335 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 336 +-- truncate_limit: 100 +CREATE VIEW bv1 WITH (security_barrier) AS SELECT * FROM b1 WHERE a > 0 WITH CHECK OPTION +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DDL +TABLE: name="b1" schema="" table="b1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW bv1 WITH (security_barrier) AS SELECT * FROM b1 WHERE a > 0 WITH CHECK OPTION" +== 337 +-- truncate_limit: 100 +GRANT ALL ON bv1 TO regress_rls_carol +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON bv1 TO regress_rls_carol" +== 338 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 339 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM bv1 WHERE f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM bv1 WHERE f_leak(b)" +== 340 +-- truncate_limit: 100 +SELECT * FROM bv1 WHERE f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bv1 WHERE f_leak(b)" +== 341 +-- truncate_limit: 100 +INSERT INTO bv1 VALUES (-1, 'xxx') +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bv1 VALUES (-1, 'xxx')" +== 342 +-- truncate_limit: 100 +-- should fail view WCO +INSERT INTO bv1 VALUES (11, 'xxx') +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bv1 VALUES (11, 'xxx')" +== 343 +-- truncate_limit: 100 +-- should fail RLS check +INSERT INTO bv1 VALUES (12, 'xxx') +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bv1 VALUES (12, 'xxx')" +== 344 +-- truncate_limit: 100 +-- ok + +EXPLAIN (COSTS OFF) UPDATE bv1 SET b = 'yyy' WHERE a = 4 AND f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE bv1 SET b = 'yyy' WHERE a = 4 AND f_leak(b)" +== 345 +-- truncate_limit: 100 +UPDATE bv1 SET b = 'yyy' WHERE a = 4 AND f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE bv1 SET b = 'yyy' WHERE a = 4 AND f_leak(b)" +== 346 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) DELETE FROM bv1 WHERE a = 6 AND f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM bv1 WHERE a = 6 AND f_leak(b)" +== 347 +-- truncate_limit: 100 +DELETE FROM bv1 WHERE a = 6 AND f_leak(b) +-- +TABLE: name="bv1" schema="" table="bv1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM bv1 WHERE a = 6 AND f_leak(b)" +== 348 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 349 +-- truncate_limit: 100 +SELECT * FROM b1 +-- +TABLE: name="b1" schema="" table="b1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM b1" +== 350 +-- truncate_limit: 100 +|-- +-- INSERT ... ON CONFLICT DO UPDATE and Row-level security +|-- + +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 351 +-- truncate_limit: 100 +DROP POLICY p1 ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p1 ON document" +== 352 +-- truncate_limit: 100 +DROP POLICY p1r ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p1r ON document" +== 353 +-- truncate_limit: 100 +CREATE POLICY p1 ON document FOR SELECT USING (true) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON document FOR SELECT TO public USING (true)" +== 354 +-- truncate_limit: 100 +CREATE POLICY p2 ON document FOR INSERT WITH CHECK (dauthor = current_user) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON document FOR INSERT TO public WITH CHECK (dauthor = current_user)" +== 355 +-- truncate_limit: 100 +CREATE POLICY p3 ON document FOR UPDATE + USING (cid = (SELECT cid from category WHERE cname = 'novel')) + WITH CHECK (dauthor = current_user) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3 ON document FOR UPDATE TO public USING (cid = (SELECT cid FROM category WHERE cn..." +== 356 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 357 +-- truncate_limit: 100 +-- Exists... +SELECT * FROM document WHERE did = 2 +-- +TABLE: name="document" schema="" table="document" ctx=Select +FILTER: schema="" table="" column="did" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE did = 2" +== 358 +-- truncate_limit: 100 +-- ...so violates actual WITH CHECK OPTION within UPDATE (not INSERT, since +-- alternative UPDATE path happens to be taken): +INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_carol', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, dauthor = EXCLUDED.dauthor +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ..." +== 359 +-- truncate_limit: 100 +-- Violates USING qual for UPDATE policy p3. +|-- +-- UPDATE path is taken, but UPDATE fails purely because *existing* row to be +-- updated is not a "novel"/cid 11 (row is not leaked, even though we have +-- SELECT privileges sufficient to see the row in this instance): +INSERT INTO document VALUES (33, 22, 1, 'regress_rls_bob', 'okay science fiction') +-- +TABLE: name="document" schema="" table="document" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (33, 22, 1, 'regress_rls_bob', 'okay science fiction')" +== 360 +-- truncate_limit: 100 +-- preparation for next statement +INSERT INTO document VALUES (33, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'Some novel, replaces sci-fi') -- takes UPDATE path + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET dtitle = excluded.dtitle" +== 361 +-- truncate_limit: 100 +-- Fine (we UPDATE, since INSERT WCOs and UPDATE security barrier quals + WCOs +-- not violated): +INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ... RETURNING *" +== 362 +-- truncate_limit: 100 +-- Fine (we INSERT, so "cid = 33" ("technology") isn't evaluated): +INSERT INTO document VALUES (78, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'some technology novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, cid = 33 RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ... RETURNING *" +== 363 +-- truncate_limit: 100 +-- Fine (same query, but we UPDATE, so "cid = 33", ("technology") is not the +-- case in respect of *existing* tuple): +INSERT INTO document VALUES (78, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'some technology novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, cid = 33 RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ... RETURNING *" +== 364 +-- truncate_limit: 100 +-- Same query a third time, but now fails due to existing tuple finally not +-- passing quals: +INSERT INTO document VALUES (78, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'some technology novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, cid = 33 RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ... RETURNING *" +== 365 +-- truncate_limit: 100 +-- Don't fail just because INSERT doesn't satisfy WITH CHECK option that +-- originated as a barrier/USING() qual from the UPDATE. Note that the UPDATE +-- path *isn't* taken, and so UPDATE-related policy does not apply: +INSERT INTO document VALUES (79, (SELECT cid from category WHERE cname = 'technology'), 1, 'regress_rls_bob', 'technology book, can only insert') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ... RETURNING *" +== 366 +-- truncate_limit: 100 +-- But this time, the same statement fails, because the UPDATE path is taken, +-- and updating the row just inserted falls afoul of security barrier qual +-- (enforced as WCO) -- what we might have updated target tuple to is +-- irrelevant, in fact. +INSERT INTO document VALUES (79, (SELECT cid from category WHERE cname = 'technology'), 1, 'regress_rls_bob', 'technology book, can only insert') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ... RETURNING *" +== 367 +-- truncate_limit: 100 +-- Test default USING qual enforced as WCO +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 368 +-- truncate_limit: 100 +DROP POLICY p1 ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p1 ON document" +== 369 +-- truncate_limit: 100 +DROP POLICY p2 ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p2 ON document" +== 370 +-- truncate_limit: 100 +DROP POLICY p3 ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p3 ON document" +== 371 +-- truncate_limit: 100 +CREATE POLICY p3_with_default ON document FOR UPDATE + USING (cid = (SELECT cid from category WHERE cname = 'novel')) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3_with_default ON document FOR UPDATE TO public USING (cid = (SELECT cid FROM cate..." +== 372 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 373 +-- truncate_limit: 100 +-- Just because WCO-style enforcement of USING quals occurs with +-- existing/target tuple does not mean that the implementation can be allowed +-- to fail to also enforce this qual against the final tuple appended to +-- relation (since in the absence of an explicit WCO, this is also interpreted +-- as an UPDATE/ALL WCO in general). +|-- +-- UPDATE path is taken here (fails due to existing tuple). Note that this is +-- not reported as a "USING expression", because it's an RLS UPDATE check that originated as +-- a USING qual for the purposes of RLS in general, as opposed to an explicit +-- USING qual that is ordinarily a security barrier. We leave it up to the +-- UPDATE to make this fail: +INSERT INTO document VALUES (79, (SELECT cid from category WHERE cname = 'technology'), 1, 'regress_rls_bob', 'technology book, can only insert') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ... RETURNING *" +== 374 +-- truncate_limit: 100 +-- UPDATE path is taken here. Existing tuple passes, since its cid +-- corresponds to "novel", but default USING qual is enforced against +-- post-UPDATE tuple too (as always when updating with a policy that lacks an +-- explicit WCO), and so this fails: +INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'technology'), 1, 'regress_rls_bob', 'my first novel') + ON CONFLICT (did) DO UPDATE SET cid = EXCLUDED.cid, dtitle = EXCLUDED.dtitle RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET ... = ... RETURNING *" +== 375 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 376 +-- truncate_limit: 100 +DROP POLICY p3_with_default ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p3_with_default ON document" +== 377 +-- truncate_limit: 100 +|-- +-- Test ALL policies with ON CONFLICT DO UPDATE (much the same as existing UPDATE +-- tests) +|-- +CREATE POLICY p3_with_all ON document FOR ALL + USING (cid = (SELECT cid from category WHERE cname = 'novel')) + WITH CHECK (dauthor = current_user) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3_with_all ON document TO public USING (cid = (SELECT cid FROM category WHERE cnam..." +== 378 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 379 +-- truncate_limit: 100 +-- Fails, since ALL WCO is enforced in insert path: +INSERT INTO document VALUES (80, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_carol', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle, cid = 33 +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET dtitle = excluded.dtitle, cid = 33" +== 380 +-- truncate_limit: 100 +-- Fails, since ALL policy USING qual is enforced (existing, target tuple is in +-- violation, since it has the "manga" cid): +INSERT INTO document VALUES (4, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET dtitle = excluded.dtitle" +== 381 +-- truncate_limit: 100 +-- Fails, since ALL WCO are enforced: +INSERT INTO document VALUES (1, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'my first novel') + ON CONFLICT (did) DO UPDATE SET dauthor = 'regress_rls_carol' +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +FILTER: schema="" table="" column="cname" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO document VALUES (...) ON CONFLICT (did) DO UPDATE SET dauthor = 'regress_rls_carol'" +== 382 +-- truncate_limit: 100 +|-- +-- MERGE +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 383 +-- truncate_limit: 100 +DROP POLICY p3_with_all ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p3_with_all ON document" +== 384 +-- truncate_limit: 100 +ALTER TABLE document ADD COLUMN dnotes text DEFAULT '' +-- +TABLE: name="document" schema="" table="document" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE document ADD COLUMN dnotes text DEFAULT ''" +== 385 +-- truncate_limit: 100 +-- all documents are readable +CREATE POLICY p1 ON document FOR SELECT USING (true) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON document FOR SELECT TO public USING (true)" +== 386 +-- truncate_limit: 100 +-- one may insert documents only authored by them +CREATE POLICY p2 ON document FOR INSERT WITH CHECK (dauthor = current_user) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON document FOR INSERT TO public WITH CHECK (dauthor = current_user)" +== 387 +-- truncate_limit: 100 +-- one may only update documents in 'novel' category and new dlevel must be > 0 +CREATE POLICY p3 ON document FOR UPDATE + USING (cid = (SELECT cid from category WHERE cname = 'novel')) + WITH CHECK (dlevel > 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3 ON document FOR UPDATE TO public USING (cid = (SELECT cid FROM category WHERE cn..." +== 388 +-- truncate_limit: 100 +-- one may only delete documents in 'manga' category +CREATE POLICY p4 ON document FOR DELETE + USING (cid = (SELECT cid from category WHERE cname = 'manga')) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p4 ON document FOR DELETE TO public USING (cid = (SELECT cid FROM category WHERE cn..." +== 389 +-- truncate_limit: 100 +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document" +== 390 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 391 +-- truncate_limit: 100 +-- Fails, since update violates WITH CHECK qual on dlevel +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge1 ', dlevel = 0 +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 392 +-- truncate_limit: 100 +-- Should be OK since USING and WITH CHECK quals pass +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge2 ' +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 393 +-- truncate_limit: 100 +-- Even when dlevel is updated explicitly, but to the existing value +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge3 ', dlevel = 1 +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 394 +-- truncate_limit: 100 +-- There is a MATCH for did = 3, but UPDATE's USING qual does not allow +-- updating an item in category 'science fiction' +MERGE INTO document d +USING (SELECT 3 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 395 +-- truncate_limit: 100 +-- The same thing with DELETE action, but fails again because no permissions +-- to delete items in 'science fiction' category that did 3 belongs to. +MERGE INTO document d +USING (SELECT 3 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + DELETE +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT 3 AS sdid) s ON did = s.sdid WHEN MATCHED THEN DELETE" +== 396 +-- truncate_limit: 100 +-- Document with did 4 belongs to 'manga' category which is allowed for +-- deletion. But this fails because the UPDATE action is matched first and +-- UPDATE policy does not allow updation in the category. +MERGE INTO document d +USING (SELECT 4 as sdid) s +ON did = s.sdid +WHEN MATCHED AND dnotes = '' THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +WHEN MATCHED THEN + DELETE +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED AND dnotes = '' THEN UPDA..." +== 397 +-- truncate_limit: 100 +-- UPDATE action is not matched this time because of the WHEN qual. +-- DELETE still fails because role regress_rls_bob does not have SELECT +-- privileges on 'manga' category row in the category table. +MERGE INTO document d +USING (SELECT 4 as sdid) s +ON did = s.sdid +WHEN MATCHED AND dnotes <> '' THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +WHEN MATCHED THEN + DELETE +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED AND dnotes <> '' THEN UPD..." +== 398 +-- truncate_limit: 100 +-- OK if DELETE is replaced with DO NOTHING +MERGE INTO document d +USING (SELECT 4 as sdid) s +ON did = s.sdid +WHEN MATCHED AND dnotes <> '' THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +WHEN MATCHED THEN + DO NOTHING +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED AND dnotes <> '' THEN UPD..." +== 399 +-- truncate_limit: 100 +SELECT * FROM document WHERE did = 4 +-- +TABLE: name="document" schema="" table="document" ctx=Select +FILTER: schema="" table="" column="did" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE did = 4" +== 400 +-- truncate_limit: 100 +-- Switch to regress_rls_carol role and try the DELETE again. It should succeed +-- this time +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 401 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 402 +-- truncate_limit: 100 +MERGE INTO document d +USING (SELECT 4 as sdid) s +ON did = s.sdid +WHEN MATCHED AND dnotes <> '' THEN + UPDATE SET dnotes = dnotes || ' notes added by merge ' +WHEN MATCHED THEN + DELETE +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED AND dnotes <> '' THEN UPD..." +== 403 +-- truncate_limit: 100 +-- Switch back to regress_rls_bob role +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 404 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 405 +-- truncate_limit: 100 +-- Try INSERT action. This fails because we are trying to insert +-- dauthor = regress_rls_dave and INSERT's WITH CHECK does not allow +-- that +MERGE INTO document d +USING (SELECT 12 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + DELETE +WHEN NOT MATCHED THEN + INSERT VALUES (12, 11, 1, 'regress_rls_dave', 'another novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN DELETE WHEN NOT MATC..." +== 406 +-- truncate_limit: 100 +-- This should be fine +MERGE INTO document d +USING (SELECT 12 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + DELETE +WHEN NOT MATCHED THEN + INSERT VALUES (12, 11, 1, 'regress_rls_bob', 'another novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN DELETE WHEN NOT MATC..." +== 407 +-- truncate_limit: 100 +-- ok +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge4 ' +WHEN NOT MATCHED THEN + INSERT VALUES (12, 11, 1, 'regress_rls_bob', 'another novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 408 +-- truncate_limit: 100 +-- drop and create a new SELECT policy which prevents us from reading +-- any document except with category 'novel' +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 409 +-- truncate_limit: 100 +DROP POLICY p1 ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p1 ON document" +== 410 +-- truncate_limit: 100 +CREATE POLICY p1 ON document FOR SELECT + USING (cid = (SELECT cid from category WHERE cname = 'novel')) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON document FOR SELECT TO public USING (cid = (SELECT cid FROM category WHERE cn..." +== 411 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 412 +-- truncate_limit: 100 +-- MERGE can no longer see the matching row and hence attempts the +-- NOT MATCHED action, which results in unique key violation +MERGE INTO document d +USING (SELECT 7 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge5 ' +WHEN NOT MATCHED THEN + INSERT VALUES (12, 11, 1, 'regress_rls_bob', 'another novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 413 +-- truncate_limit: 100 +-- UPDATE action fails if new row is not visible +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge6 ', + cid = (SELECT cid from category WHERE cname = 'technology') +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +ALIAS: "d"="document" +FILTER: schema="" table="" column="cname" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 414 +-- truncate_limit: 100 +-- but OK if new row is visible +MERGE INTO document d +USING (SELECT 1 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge7 ', + cid = (SELECT cid from category WHERE cname = 'novel') +-- +TABLE: name="document" schema="" table="document" ctx=DML +TABLE: name="category" schema="" table="category" ctx=Select +ALIAS: "d"="document" +FILTER: schema="" table="" column="cname" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 415 +-- truncate_limit: 100 +-- OK to insert a new row that is not visible +MERGE INTO document d +USING (SELECT 13 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge8 ' +WHEN NOT MATCHED THEN + INSERT VALUES (13, 44, 1, 'regress_rls_bob', 'new manga') +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 416 +-- truncate_limit: 100 +SELECT * FROM document WHERE did = 13 +-- +TABLE: name="document" schema="" table="document" ctx=Select +FILTER: schema="" table="" column="did" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document WHERE did = 13" +== 417 +-- truncate_limit: 100 +-- but not OK if RETURNING is used +MERGE INTO document d +USING (SELECT 14 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge9 ' +WHEN NOT MATCHED THEN + INSERT VALUES (14, 44, 1, 'regress_rls_bob', 'new manga') +RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 418 +-- truncate_limit: 100 +-- but OK if new row is visible +MERGE INTO document d +USING (SELECT 14 as sdid) s +ON did = s.sdid +WHEN MATCHED THEN + UPDATE SET dnotes = dnotes || ' notes added by merge10 ' +WHEN NOT MATCHED THEN + INSERT VALUES (14, 11, 1, 'regress_rls_bob', 'new novel') +RETURNING * +-- +TABLE: name="document" schema="" table="document" ctx=DML +ALIAS: "d"="document" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO document d USING (SELECT ...) s ON did = s.sdid WHEN MATCHED THEN UPDATE SET dnotes = ..." +== 419 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 420 +-- truncate_limit: 100 +-- drop the restrictive SELECT policy so that we can look at the +-- final state of the table +DROP POLICY p1 ON document +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p1 ON document" +== 421 +-- truncate_limit: 100 +-- Just check everything went per plan +SELECT * FROM document +-- +TABLE: name="document" schema="" table="document" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM document" +== 422 +-- truncate_limit: 100 +|-- +-- ROLE/GROUP +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 423 +-- truncate_limit: 100 +CREATE TABLE z1 (a int, b text) +-- +TABLE: name="z1" schema="" table="z1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE z1 (a int, b text)" +== 424 +-- truncate_limit: 100 +CREATE TABLE z2 (a int, b text) +-- +TABLE: name="z2" schema="" table="z2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE z2 (a int, b text)" +== 425 +-- truncate_limit: 100 +GRANT SELECT ON z1,z2 TO regress_rls_group1, regress_rls_group2, + regress_rls_bob, regress_rls_carol +-- +TABLE: name="z1" schema="" table="z1" ctx=DDL +TABLE: name="z2" schema="" table="z2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON z1, z2 TO regress_rls_group1, regress_rls_group2, regress_rls_bob, regress_rls_carol" +== 426 +-- truncate_limit: 100 +INSERT INTO z1 VALUES + (1, 'aba'), + (2, 'bbb'), + (3, 'ccc'), + (4, 'dad') +-- +TABLE: name="z1" schema="" table="z1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO z1 VALUES (1, 'aba'), (2, 'bbb'), (3, 'ccc'), (4, 'dad')" +== 427 +-- truncate_limit: 100 +CREATE POLICY p1 ON z1 TO regress_rls_group1 USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON z1 TO regress_rls_group1 USING ((a % 2) = 0)" +== 428 +-- truncate_limit: 100 +CREATE POLICY p2 ON z1 TO regress_rls_group2 USING (a % 2 = 1) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON z1 TO regress_rls_group2 USING ((a % 2) = 1)" +== 429 +-- truncate_limit: 100 +ALTER TABLE z1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="z1" schema="" table="z1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE z1 ENABLE ROW LEVEL SECURITY" +== 430 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 431 +-- truncate_limit: 100 +SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM z1 WHERE f_leak(b)" +== 432 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b)" +== 433 +-- truncate_limit: 100 +PREPARE plancache_test AS SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE plancache_test AS SELECT * FROM z1 WHERE f_leak(b)" +== 434 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test" +== 435 +-- truncate_limit: 100 +PREPARE plancache_test2 AS WITH q AS MATERIALIZED (SELECT * FROM z1 WHERE f_leak(b)) SELECT * FROM q,z2 +-- +TABLE: name="z2" schema="" table="z2" ctx=Select +TABLE: name="z1" schema="" table="z1" ctx=Select +CTE: "q" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE plancache_test2 AS WITH q AS MATERIALIZED (SELECT * FROM z1 WHERE f_leak(b)) SELECT * FRO..." +== 436 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test2 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test2" +== 437 +-- truncate_limit: 100 +PREPARE plancache_test3 AS WITH q AS MATERIALIZED (SELECT * FROM z2) SELECT * FROM q,z1 WHERE f_leak(z1.b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +TABLE: name="z2" schema="" table="z2" ctx=Select +CTE: "q" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="z1" column="b" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE plancache_test3 AS WITH q AS MATERIALIZED (SELECT * FROM z2) SELECT * FROM q, z1 WHERE f_..." +== 438 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test3 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test3" +== 439 +-- truncate_limit: 100 +SET ROLE regress_rls_group1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rls_group1" +== 440 +-- truncate_limit: 100 +SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM z1 WHERE f_leak(b)" +== 441 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b)" +== 442 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test" +== 443 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test2 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test2" +== 444 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test3 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test3" +== 445 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 446 +-- truncate_limit: 100 +SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM z1 WHERE f_leak(b)" +== 447 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b)" +== 448 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test" +== 449 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test2 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test2" +== 450 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test3 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test3" +== 451 +-- truncate_limit: 100 +SET ROLE regress_rls_group2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rls_group2" +== 452 +-- truncate_limit: 100 +SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM z1 WHERE f_leak(b)" +== 453 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM z1 WHERE f_leak(b)" +== 454 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test" +== 455 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test2 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test2" +== 456 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE plancache_test3 +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE plancache_test3" +== 457 +-- truncate_limit: 100 +|-- +-- Views should follow policy for view owner. +|-- +-- View and Table owner are the same. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 458 +-- truncate_limit: 100 +CREATE VIEW rls_view AS SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rls_view AS SELECT * FROM z1 WHERE f_leak(b)" +== 459 +-- truncate_limit: 100 +GRANT SELECT ON rls_view TO regress_rls_bob +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rls_view TO regress_rls_bob" +== 460 +-- truncate_limit: 100 +-- Query as role that is not owner of view or table. Should return all records. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 461 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 462 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 463 +-- truncate_limit: 100 +-- Query as view/table owner. Should return all records. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 464 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 465 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 466 +-- truncate_limit: 100 +DROP VIEW rls_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rls_view" +== 467 +-- truncate_limit: 100 +-- View and Table owners are different. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 468 +-- truncate_limit: 100 +CREATE VIEW rls_view AS SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rls_view AS SELECT * FROM z1 WHERE f_leak(b)" +== 469 +-- truncate_limit: 100 +GRANT SELECT ON rls_view TO regress_rls_alice +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rls_view TO regress_rls_alice" +== 470 +-- truncate_limit: 100 +-- Query as role that is not owner of view but is owner of table. +-- Should return records based on view owner policies. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 471 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 472 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 473 +-- truncate_limit: 100 +-- Query as role that is not owner of table but is owner of view. +-- Should return records based on view owner policies. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 474 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 475 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 476 +-- truncate_limit: 100 +-- Query as role that is not the owner of the table or view without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 477 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 478 +-- truncate_limit: 100 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 479 +-- truncate_limit: 100 +--fail - permission denied. + +-- Query as role that is not the owner of the table or view with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 480 +-- truncate_limit: 100 +GRANT SELECT ON rls_view TO regress_rls_carol +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rls_view TO regress_rls_carol" +== 481 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 482 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 483 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 484 +-- truncate_limit: 100 +-- Policy requiring access to another table. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 485 +-- truncate_limit: 100 +CREATE TABLE z1_blacklist (a int) +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE z1_blacklist (a int)" +== 486 +-- truncate_limit: 100 +INSERT INTO z1_blacklist VALUES (3), (4) +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO z1_blacklist VALUES (3), (4)" +== 487 +-- truncate_limit: 100 +CREATE POLICY p3 ON z1 AS RESTRICTIVE USING (a NOT IN (SELECT a FROM z1_blacklist)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3 ON z1 AS RESTRICTIVE TO public USING (NOT a IN (SELECT a FROM z1_blacklist))" +== 488 +-- truncate_limit: 100 +-- Query as role that is not owner of table but is owner of view without permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 489 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 490 +-- truncate_limit: 100 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 491 +-- truncate_limit: 100 +--fail - permission denied. + +-- Query as role that is not the owner of the table or view without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 492 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 493 +-- truncate_limit: 100 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 494 +-- truncate_limit: 100 +--fail - permission denied. + +-- Query as role that is not owner of table but is owner of view with permissions. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 495 +-- truncate_limit: 100 +GRANT SELECT ON z1_blacklist TO regress_rls_bob +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON z1_blacklist TO regress_rls_bob" +== 496 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 497 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 498 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 499 +-- truncate_limit: 100 +-- Query as role that is not the owner of the table or view with permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 500 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 501 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 502 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 503 +-- truncate_limit: 100 +REVOKE SELECT ON z1_blacklist FROM regress_rls_bob +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE select ON z1_blacklist FROM regress_rls_bob" +== 504 +-- truncate_limit: 100 +DROP POLICY p3 ON z1 +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p3 ON z1" +== 505 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 506 +-- truncate_limit: 100 +DROP VIEW rls_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rls_view" +== 507 +-- truncate_limit: 100 +|-- +-- Security invoker views should follow policy for current user. +|-- +-- View and table owner are the same. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 508 +-- truncate_limit: 100 +CREATE VIEW rls_view WITH (security_invoker) AS + SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rls_view WITH (security_invoker) AS SELECT * FROM z1 WHERE f_leak(b)" +== 509 +-- truncate_limit: 100 +GRANT SELECT ON rls_view TO regress_rls_bob +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rls_view TO regress_rls_bob" +== 510 +-- truncate_limit: 100 +GRANT SELECT ON rls_view TO regress_rls_carol +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rls_view TO regress_rls_carol" +== 511 +-- truncate_limit: 100 +-- Query as table owner. Should return all records. +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 512 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 513 +-- truncate_limit: 100 +-- Queries as other users. +-- Should return records based on current user's policies. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 514 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 515 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 516 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 517 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 518 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 519 +-- truncate_limit: 100 +-- View and table owners are different. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 520 +-- truncate_limit: 100 +DROP VIEW rls_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rls_view" +== 521 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 522 +-- truncate_limit: 100 +CREATE VIEW rls_view WITH (security_invoker) AS + SELECT * FROM z1 WHERE f_leak(b) +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +TABLE: name="z1" schema="" table="z1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rls_view WITH (security_invoker) AS SELECT * FROM z1 WHERE f_leak(b)" +== 523 +-- truncate_limit: 100 +GRANT SELECT ON rls_view TO regress_rls_alice +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rls_view TO regress_rls_alice" +== 524 +-- truncate_limit: 100 +GRANT SELECT ON rls_view TO regress_rls_carol +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rls_view TO regress_rls_carol" +== 525 +-- truncate_limit: 100 +-- Query as table owner. Should return all records. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 526 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 527 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 528 +-- truncate_limit: 100 +-- Queries as other users. +-- Should return records based on current user's policies. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 529 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 530 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 531 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 532 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 533 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 534 +-- truncate_limit: 100 +-- Policy requiring access to another table. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 535 +-- truncate_limit: 100 +CREATE POLICY p3 ON z1 AS RESTRICTIVE USING (a NOT IN (SELECT a FROM z1_blacklist)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3 ON z1 AS RESTRICTIVE TO public USING (NOT a IN (SELECT a FROM z1_blacklist))" +== 536 +-- truncate_limit: 100 +-- Query as role that is not owner of table but is owner of view without permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 537 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 538 +-- truncate_limit: 100 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 539 +-- truncate_limit: 100 +--fail - permission denied. + +-- Query as role that is not the owner of the table or view without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 540 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 541 +-- truncate_limit: 100 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 542 +-- truncate_limit: 100 +--fail - permission denied. + +-- Query as role that is not owner of table but is owner of view with permissions. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 543 +-- truncate_limit: 100 +GRANT SELECT ON z1_blacklist TO regress_rls_bob +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON z1_blacklist TO regress_rls_bob" +== 544 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 545 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 546 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 547 +-- truncate_limit: 100 +-- Query as role that is not the owner of the table or view without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 548 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 549 +-- truncate_limit: 100 +--fail - permission denied. +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 550 +-- truncate_limit: 100 +--fail - permission denied. + +-- Query as role that is not the owner of the table or view with permissions. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 551 +-- truncate_limit: 100 +GRANT SELECT ON z1_blacklist TO regress_rls_carol +-- +TABLE: name="z1_blacklist" schema="" table="z1_blacklist" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON z1_blacklist TO regress_rls_carol" +== 552 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 553 +-- truncate_limit: 100 +SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rls_view" +== 554 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_view +-- +TABLE: name="rls_view" schema="" table="rls_view" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_view" +== 555 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 556 +-- truncate_limit: 100 +DROP VIEW rls_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rls_view" +== 557 +-- truncate_limit: 100 +|-- +-- Command specific +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 558 +-- truncate_limit: 100 +CREATE TABLE x1 (a int, b text, c text) +-- +TABLE: name="x1" schema="" table="x1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE x1 (a int, b text, c text)" +== 559 +-- truncate_limit: 100 +GRANT ALL ON x1 TO PUBLIC +-- +TABLE: name="x1" schema="" table="x1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON x1 TO public" +== 560 +-- truncate_limit: 100 +INSERT INTO x1 VALUES + (1, 'abc', 'regress_rls_bob'), + (2, 'bcd', 'regress_rls_bob'), + (3, 'cde', 'regress_rls_carol'), + (4, 'def', 'regress_rls_carol'), + (5, 'efg', 'regress_rls_bob'), + (6, 'fgh', 'regress_rls_bob'), + (7, 'fgh', 'regress_rls_carol'), + (8, 'fgh', 'regress_rls_carol') +-- +TABLE: name="x1" schema="" table="x1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO x1 VALUES (...)" +== 561 +-- truncate_limit: 100 +CREATE POLICY p0 ON x1 FOR ALL USING (c = current_user) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p0 ON x1 TO public USING (c = current_user)" +== 562 +-- truncate_limit: 100 +CREATE POLICY p1 ON x1 FOR SELECT USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON x1 FOR SELECT TO public USING ((a % 2) = 0)" +== 563 +-- truncate_limit: 100 +CREATE POLICY p2 ON x1 FOR INSERT WITH CHECK (a % 2 = 1) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON x1 FOR INSERT TO public WITH CHECK ((a % 2) = 1)" +== 564 +-- truncate_limit: 100 +CREATE POLICY p3 ON x1 FOR UPDATE USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3 ON x1 FOR UPDATE TO public USING ((a % 2) = 0)" +== 565 +-- truncate_limit: 100 +CREATE POLICY p4 ON x1 FOR DELETE USING (a < 8) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p4 ON x1 FOR DELETE TO public USING (a < 8)" +== 566 +-- truncate_limit: 100 +ALTER TABLE x1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="x1" schema="" table="x1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE x1 ENABLE ROW LEVEL SECURITY" +== 567 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 568 +-- truncate_limit: 100 +SELECT * FROM x1 WHERE f_leak(b) ORDER BY a ASC +-- +TABLE: name="x1" schema="" table="x1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x1 WHERE f_leak(b) ORDER BY a ASC" +== 569 +-- truncate_limit: 100 +UPDATE x1 SET b = b || '_updt' WHERE f_leak(b) RETURNING * +-- +TABLE: name="x1" schema="" table="x1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE x1 SET b = b || '_updt' WHERE f_leak(b) RETURNING *" +== 570 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 571 +-- truncate_limit: 100 +SELECT * FROM x1 WHERE f_leak(b) ORDER BY a ASC +-- +TABLE: name="x1" schema="" table="x1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM x1 WHERE f_leak(b) ORDER BY a ASC" +== 572 +-- truncate_limit: 100 +UPDATE x1 SET b = b || '_updt' WHERE f_leak(b) RETURNING * +-- +TABLE: name="x1" schema="" table="x1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE x1 SET b = b || '_updt' WHERE f_leak(b) RETURNING *" +== 573 +-- truncate_limit: 100 +DELETE FROM x1 WHERE f_leak(b) RETURNING * +-- +TABLE: name="x1" schema="" table="x1" ctx=DML +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM x1 WHERE f_leak(b) RETURNING *" +== 574 +-- truncate_limit: 100 +|-- +-- Duplicate Policy Names +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 575 +-- truncate_limit: 100 +CREATE TABLE y1 (a int, b text) +-- +TABLE: name="y1" schema="" table="y1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE y1 (a int, b text)" +== 576 +-- truncate_limit: 100 +CREATE TABLE y2 (a int, b text) +-- +TABLE: name="y2" schema="" table="y2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE y2 (a int, b text)" +== 577 +-- truncate_limit: 100 +GRANT ALL ON y1, y2 TO regress_rls_bob +-- +TABLE: name="y1" schema="" table="y1" ctx=DDL +TABLE: name="y2" schema="" table="y2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON y1, y2 TO regress_rls_bob" +== 578 +-- truncate_limit: 100 +CREATE POLICY p1 ON y1 FOR ALL USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON y1 TO public USING ((a % 2) = 0)" +== 579 +-- truncate_limit: 100 +CREATE POLICY p2 ON y1 FOR SELECT USING (a > 2) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON y1 FOR SELECT TO public USING (a > 2)" +== 580 +-- truncate_limit: 100 +CREATE POLICY p1 ON y1 FOR SELECT USING (a % 2 = 1) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON y1 FOR SELECT TO public USING ((a % 2) = 1)" +== 581 +-- truncate_limit: 100 +--fail +CREATE POLICY p1 ON y2 FOR ALL USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON y2 TO public USING ((a % 2) = 0)" +== 582 +-- truncate_limit: 100 +--OK + +ALTER TABLE y1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="y1" schema="" table="y1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE y1 ENABLE ROW LEVEL SECURITY" +== 583 +-- truncate_limit: 100 +ALTER TABLE y2 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="y2" schema="" table="y2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE y2 ENABLE ROW LEVEL SECURITY" +== 584 +-- truncate_limit: 100 +|-- +-- Expression structure with SBV +|-- +-- Create view as table owner. RLS should NOT be applied. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 585 +-- truncate_limit: 100 +CREATE VIEW rls_sbv WITH (security_barrier) AS + SELECT * FROM y1 WHERE f_leak(b) +-- +TABLE: name="rls_sbv" schema="" table="rls_sbv" ctx=DDL +TABLE: name="y1" schema="" table="y1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rls_sbv WITH (security_barrier) AS SELECT * FROM y1 WHERE f_leak(b)" +== 586 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_sbv WHERE (a = 1) +-- +TABLE: name="rls_sbv" schema="" table="rls_sbv" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_sbv WHERE a = 1" +== 587 +-- truncate_limit: 100 +DROP VIEW rls_sbv +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rls_sbv" +== 588 +-- truncate_limit: 100 +-- Create view as role that does not own table. RLS should be applied. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 589 +-- truncate_limit: 100 +CREATE VIEW rls_sbv WITH (security_barrier) AS + SELECT * FROM y1 WHERE f_leak(b) +-- +TABLE: name="rls_sbv" schema="" table="rls_sbv" ctx=DDL +TABLE: name="y1" schema="" table="y1" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rls_sbv WITH (security_barrier) AS SELECT * FROM y1 WHERE f_leak(b)" +== 590 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM rls_sbv WHERE (a = 1) +-- +TABLE: name="rls_sbv" schema="" table="rls_sbv" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rls_sbv WHERE a = 1" +== 591 +-- truncate_limit: 100 +DROP VIEW rls_sbv +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rls_sbv" +== 592 +-- truncate_limit: 100 +|-- +-- Expression structure +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 593 +-- truncate_limit: 100 +INSERT INTO y2 (SELECT x, public.fipshash(x::text) FROM generate_series(0,20) x) +-- +TABLE: name="y2" schema="" table="y2" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y2 SELECT x, public.fipshash(x::text) FROM generate_series(0, 20) x" +== 594 +-- truncate_limit: 100 +CREATE POLICY p2 ON y2 USING (a % 3 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON y2 TO public USING ((a % 3) = 0)" +== 595 +-- truncate_limit: 100 +CREATE POLICY p3 ON y2 USING (a % 4 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p3 ON y2 TO public USING ((a % 4) = 0)" +== 596 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 597 +-- truncate_limit: 100 +SELECT * FROM y2 WHERE f_leak(b) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y2 WHERE f_leak(b)" +== 598 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM y2 WHERE f_leak(b) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM y2 WHERE f_leak(b)" +== 599 +-- truncate_limit: 100 +|-- +-- Qual push-down of leaky functions, when not referring to table +|-- +SELECT * FROM y2 WHERE f_leak('abc') +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y2 WHERE f_leak('abc')" +== 600 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM y2 WHERE f_leak('abc') +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM y2 WHERE f_leak('abc')" +== 601 +-- truncate_limit: 100 +CREATE TABLE test_qual_pushdown ( + abc text +) +-- +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_qual_pushdown (abc text)" +== 602 +-- truncate_limit: 100 +INSERT INTO test_qual_pushdown VALUES ('abc'),('def') +-- +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_qual_pushdown VALUES ('abc'), ('def')" +== 603 +-- truncate_limit: 100 +SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(abc) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="abc" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y2 JOIN test_qual_pushdown ON b = abc WHERE f_leak(abc)" +== 604 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(abc) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="abc" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM y2 JOIN test_qual_pushdown ON b = abc WHERE f_leak(abc)" +== 605 +-- truncate_limit: 100 +SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(b) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y2 JOIN test_qual_pushdown ON b = abc WHERE f_leak(b)" +== 606 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM y2 JOIN test_qual_pushdown ON (b = abc) WHERE f_leak(b) +-- +TABLE: name="y2" schema="" table="y2" ctx=Select +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM y2 JOIN test_qual_pushdown ON b = abc WHERE f_leak(b)" +== 607 +-- truncate_limit: 100 +DROP TABLE test_qual_pushdown +-- +TABLE: name="test_qual_pushdown" schema="" table="test_qual_pushdown" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_qual_pushdown" +== 608 +-- truncate_limit: 100 +|-- +-- Plancache invalidate on user change. +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 609 +-- truncate_limit: 100 +DROP TABLE t1 CASCADE +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1 CASCADE" +== 610 +-- truncate_limit: 100 +CREATE TABLE t1 (a integer) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (a int)" +== 611 +-- truncate_limit: 100 +GRANT SELECT ON t1 TO regress_rls_bob, regress_rls_carol +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON t1 TO regress_rls_bob, regress_rls_carol" +== 612 +-- truncate_limit: 100 +CREATE POLICY p1 ON t1 TO regress_rls_bob USING ((a % 2) = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON t1 TO regress_rls_bob USING ((a % 2) = 0)" +== 613 +-- truncate_limit: 100 +CREATE POLICY p2 ON t1 TO regress_rls_carol USING ((a % 4) = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p2 ON t1 TO regress_rls_carol USING ((a % 4) = 0)" +== 614 +-- truncate_limit: 100 +ALTER TABLE t1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t1 ENABLE ROW LEVEL SECURITY" +== 615 +-- truncate_limit: 100 +-- Prepare as regress_rls_bob +SET ROLE regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rls_bob" +== 616 +-- truncate_limit: 100 +PREPARE role_inval AS SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE role_inval AS SELECT * FROM t1" +== 617 +-- truncate_limit: 100 +-- Check plan +EXPLAIN (COSTS OFF) EXECUTE role_inval +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE role_inval" +== 618 +-- truncate_limit: 100 +-- Change to regress_rls_carol +SET ROLE regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rls_carol" +== 619 +-- truncate_limit: 100 +-- Check plan- should be different +EXPLAIN (COSTS OFF) EXECUTE role_inval +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE role_inval" +== 620 +-- truncate_limit: 100 +-- Change back to regress_rls_bob +SET ROLE regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_rls_bob" +== 621 +-- truncate_limit: 100 +-- Check plan- should be back to original +EXPLAIN (COSTS OFF) EXECUTE role_inval +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE role_inval" +== 622 +-- truncate_limit: 100 +|-- +-- CTE and RLS +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 623 +-- truncate_limit: 100 +DROP TABLE t1 CASCADE +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1 CASCADE" +== 624 +-- truncate_limit: 100 +CREATE TABLE t1 (a integer, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (a int, b text)" +== 625 +-- truncate_limit: 100 +CREATE POLICY p1 ON t1 USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON t1 TO public USING ((a % 2) = 0)" +== 626 +-- truncate_limit: 100 +ALTER TABLE t1 ENABLE ROW LEVEL SECURITY +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t1 ENABLE ROW LEVEL SECURITY" +== 627 +-- truncate_limit: 100 +GRANT ALL ON t1 TO regress_rls_bob +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON t1 TO regress_rls_bob" +== 628 +-- truncate_limit: 100 +INSERT INTO t1 (SELECT x, public.fipshash(x::text) FROM generate_series(0,20) x) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 SELECT x, public.fipshash(x::text) FROM generate_series(0, 20) x" +== 629 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 630 +-- truncate_limit: 100 +WITH cte1 AS MATERIALIZED (SELECT * FROM t1 WHERE f_leak(b)) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +CTE: "cte1" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "WITH cte1 AS MATERIALIZED (SELECT * FROM t1 WHERE f_leak(b)) SELECT * FROM cte1" +== 631 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +WITH cte1 AS MATERIALIZED (SELECT * FROM t1 WHERE f_leak(b)) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +CTE: "cte1" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) WITH cte1 AS MATERIALIZED (SELECT * FROM t1 WHERE f_leak(b)) SELECT * FROM cte1" +== 632 +-- truncate_limit: 100 +WITH cte1 AS (UPDATE t1 SET a = a + 1 RETURNING *) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +CTE: "cte1" +STMT: SelectStmt +STMT: UpdateStmt +TRUNCATED: "WITH cte1 AS (UPDATE t1 SET a = a + 1 RETURNING *) SELECT * FROM cte1" +== 633 +-- truncate_limit: 100 +--fail +WITH cte1 AS (UPDATE t1 SET a = a RETURNING *) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +CTE: "cte1" +STMT: SelectStmt +STMT: UpdateStmt +TRUNCATED: "WITH cte1 AS (UPDATE t1 SET a = a RETURNING *) SELECT * FROM cte1" +== 634 +-- truncate_limit: 100 +--ok + +WITH cte1 AS (INSERT INTO t1 VALUES (21, 'Fail') RETURNING *) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +CTE: "cte1" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH cte1 AS (INSERT INTO t1 VALUES (21, 'Fail') RETURNING *) SELECT * FROM cte1" +== 635 +-- truncate_limit: 100 +--fail +WITH cte1 AS (INSERT INTO t1 VALUES (20, 'Success') RETURNING *) SELECT * FROM cte1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +CTE: "cte1" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH cte1 AS (INSERT INTO t1 VALUES (20, 'Success') RETURNING *) SELECT * FROM cte1" +== 636 +-- truncate_limit: 100 +--ok + +|-- +-- Rename Policy +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 637 +-- truncate_limit: 100 +ALTER POLICY p1 ON t1 RENAME TO p1 +-- +STMT: RenameStmt +TRUNCATED: "ALTER POLICY p1 ON t1 RENAME TO p1" +== 638 +-- truncate_limit: 100 +--fail + +SELECT polname, relname + FROM pg_policy pol + JOIN pg_class pc ON (pc.oid = pol.polrelid) + WHERE relname = 't1' +-- +TABLE: name="pg_policy" schema="" table="pg_policy" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pol"="pg_policy" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_policy pol JOIN pg_class pc ON pc.oid = pol.polrelid WHERE relname = 't1'" +== 639 +-- truncate_limit: 100 +ALTER POLICY p1 ON t1 RENAME TO p2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER POLICY p1 ON t1 RENAME TO p2" +== 640 +-- truncate_limit: 100 +--ok + +SELECT polname, relname + FROM pg_policy pol + JOIN pg_class pc ON (pc.oid = pol.polrelid) + WHERE relname = 't1' +-- +TABLE: name="pg_policy" schema="" table="pg_policy" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "pc"="pg_class" +ALIAS: "pol"="pg_policy" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_policy pol JOIN pg_class pc ON pc.oid = pol.polrelid WHERE relname = 't1'" +== 641 +-- truncate_limit: 100 +|-- +-- Check INSERT SELECT +|-- +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 642 +-- truncate_limit: 100 +CREATE TABLE t2 (a integer, b text) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t2 (a int, b text)" +== 643 +-- truncate_limit: 100 +INSERT INTO t2 (SELECT * FROM t1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2 SELECT * FROM t1" +== 644 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) INSERT INTO t2 (SELECT * FROM t1) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO t2 SELECT * FROM t1" +== 645 +-- truncate_limit: 100 +SELECT * FROM t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t2" +== 646 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t2" +== 647 +-- truncate_limit: 100 +CREATE TABLE t3 AS SELECT * FROM t1 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE t3 AS SELECT * FROM t1" +== 648 +-- truncate_limit: 100 +SELECT * FROM t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t3" +== 649 +-- truncate_limit: 100 +SELECT * INTO t4 FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t4" schema="" table="t4" ctx=DDL +STMT: SelectStmt +TRUNCATED: "SELECT * INTO t4 FROM t1" +== 650 +-- truncate_limit: 100 +SELECT * FROM t4 +-- +TABLE: name="t4" schema="" table="t4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t4" +== 651 +-- truncate_limit: 100 +|-- +-- RLS with JOIN +|-- +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 652 +-- truncate_limit: 100 +CREATE TABLE blog (id integer, author text, post text) +-- +TABLE: name="blog" schema="" table="blog" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE blog (id int, author text, post text)" +== 653 +-- truncate_limit: 100 +CREATE TABLE comment (blog_id integer, message text) +-- +TABLE: name="comment" schema="" table="comment" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE comment (blog_id int, message text)" +== 654 +-- truncate_limit: 100 +GRANT ALL ON blog, comment TO regress_rls_bob +-- +TABLE: name="blog" schema="" table="blog" ctx=DDL +TABLE: name="comment" schema="" table="comment" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON blog, comment TO regress_rls_bob" +== 655 +-- truncate_limit: 100 +CREATE POLICY blog_1 ON blog USING (id % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY blog_1 ON blog TO public USING ((id % 2) = 0)" +== 656 +-- truncate_limit: 100 +ALTER TABLE blog ENABLE ROW LEVEL SECURITY +-- +TABLE: name="blog" schema="" table="blog" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE blog ENABLE ROW LEVEL SECURITY" +== 657 +-- truncate_limit: 100 +INSERT INTO blog VALUES + (1, 'alice', 'blog #1'), + (2, 'bob', 'blog #1'), + (3, 'alice', 'blog #2'), + (4, 'alice', 'blog #3'), + (5, 'john', 'blog #1') +-- +TABLE: name="blog" schema="" table="blog" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO blog VALUES (...)" +== 658 +-- truncate_limit: 100 +INSERT INTO comment VALUES + (1, 'cool blog'), + (1, 'fun blog'), + (3, 'crazy blog'), + (5, 'what?'), + (4, 'insane!'), + (2, 'who did it?') +-- +TABLE: name="comment" schema="" table="comment" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO comment VALUES (...)" +== 659 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 660 +-- truncate_limit: 100 +-- Check RLS JOIN with Non-RLS. +SELECT id, author, message FROM blog JOIN comment ON id = blog_id +-- +TABLE: name="blog" schema="" table="blog" ctx=Select +TABLE: name="comment" schema="" table="comment" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id, author, message FROM blog JOIN comment ON id = blog_id" +== 661 +-- truncate_limit: 100 +-- Check Non-RLS JOIN with RLS. +SELECT id, author, message FROM comment JOIN blog ON id = blog_id +-- +TABLE: name="comment" schema="" table="comment" ctx=Select +TABLE: name="blog" schema="" table="blog" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id, author, message FROM comment JOIN blog ON id = blog_id" +== 662 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 663 +-- truncate_limit: 100 +CREATE POLICY comment_1 ON comment USING (blog_id < 4) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY comment_1 ON comment TO public USING (blog_id < 4)" +== 664 +-- truncate_limit: 100 +ALTER TABLE comment ENABLE ROW LEVEL SECURITY +-- +TABLE: name="comment" schema="" table="comment" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE comment ENABLE ROW LEVEL SECURITY" +== 665 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 666 +-- truncate_limit: 100 +-- Check RLS JOIN RLS +SELECT id, author, message FROM blog JOIN comment ON id = blog_id +-- +TABLE: name="blog" schema="" table="blog" ctx=Select +TABLE: name="comment" schema="" table="comment" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id, author, message FROM blog JOIN comment ON id = blog_id" +== 667 +-- truncate_limit: 100 +SELECT id, author, message FROM comment JOIN blog ON id = blog_id +-- +TABLE: name="comment" schema="" table="comment" ctx=Select +TABLE: name="blog" schema="" table="blog" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id, author, message FROM comment JOIN blog ON id = blog_id" +== 668 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 669 +-- truncate_limit: 100 +DROP TABLE blog, comment +-- +TABLE: name="blog" schema="" table="blog" ctx=DDL +TABLE: name="comment" schema="" table="comment" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE blog, comment" +== 670 +-- truncate_limit: 100 +|-- +-- Default Deny Policy +|-- +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 671 +-- truncate_limit: 100 +DROP POLICY p2 ON t1 +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY p2 ON t1" +== 672 +-- truncate_limit: 100 +ALTER TABLE t1 OWNER TO regress_rls_alice +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t1 OWNER TO regress_rls_alice" +== 673 +-- truncate_limit: 100 +-- Check that default deny does not apply to superuser. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 674 +-- truncate_limit: 100 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 675 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1" +== 676 +-- truncate_limit: 100 +-- Check that default deny does not apply to table owner. +SET SESSION AUTHORIZATION regress_rls_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_alice" +== 677 +-- truncate_limit: 100 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 678 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1" +== 679 +-- truncate_limit: 100 +-- Check that default deny applies to non-owner/non-superuser when RLS on. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 680 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 681 +-- truncate_limit: 100 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 682 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1" +== 683 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 684 +-- truncate_limit: 100 +SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 685 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM t1" +== 686 +-- truncate_limit: 100 +|-- +-- COPY TO/FROM +|-- + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 687 +-- truncate_limit: 100 +DROP TABLE copy_t CASCADE +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE copy_t CASCADE" +== 688 +-- truncate_limit: 100 +CREATE TABLE copy_t (a integer, b text) +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE copy_t (a int, b text)" +== 689 +-- truncate_limit: 100 +CREATE POLICY p1 ON copy_t USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON copy_t TO public USING ((a % 2) = 0)" +== 690 +-- truncate_limit: 100 +ALTER TABLE copy_t ENABLE ROW LEVEL SECURITY +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE copy_t ENABLE ROW LEVEL SECURITY" +== 691 +-- truncate_limit: 100 +GRANT ALL ON copy_t TO regress_rls_bob, regress_rls_exempt_user +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON copy_t TO regress_rls_bob, regress_rls_exempt_user" +== 692 +-- truncate_limit: 100 +INSERT INTO copy_t (SELECT x, public.fipshash(x::text) FROM generate_series(0,10) x) +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copy_t SELECT x, public.fipshash(x::text) FROM generate_series(0, 10) x" +== 693 +-- truncate_limit: 100 +-- Check COPY TO as Superuser/owner. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 694 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 695 +-- truncate_limit: 100 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH (DELIMITER ',')" +== 696 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 697 +-- truncate_limit: 100 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH (DELIMITER ',')" +== 698 +-- truncate_limit: 100 +-- Check COPY TO as user with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 699 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 700 +-- truncate_limit: 100 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH (DELIMITER ',')" +== 701 +-- truncate_limit: 100 +--fail - would be affected by RLS +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 702 +-- truncate_limit: 100 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH (DELIMITER ',')" +== 703 +-- truncate_limit: 100 +--ok + +-- Check COPY TO as user with permissions and BYPASSRLS +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_exempt_user" +== 704 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 705 +-- truncate_limit: 100 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH (DELIMITER ',')" +== 706 +-- truncate_limit: 100 +--ok +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 707 +-- truncate_limit: 100 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH (DELIMITER ',')" +== 708 +-- truncate_limit: 100 +--ok + +-- Check COPY TO as user without permissions. SET row_security TO OFF; +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 709 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 710 +-- truncate_limit: 100 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH (DELIMITER ',')" +== 711 +-- truncate_limit: 100 +--fail - would be affected by RLS +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 712 +-- truncate_limit: 100 +COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY (SELECT * FROM copy_t ORDER BY a ASC) TO STDOUT WITH (DELIMITER ',')" +== 713 +-- truncate_limit: 100 +--fail - permission denied + +-- Check COPY relation TO; keep it just one row to avoid reordering issues +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 714 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 715 +-- truncate_limit: 100 +CREATE TABLE copy_rel_to (a integer, b text) +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE copy_rel_to (a int, b text)" +== 716 +-- truncate_limit: 100 +CREATE POLICY p1 ON copy_rel_to USING (a % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY p1 ON copy_rel_to TO public USING ((a % 2) = 0)" +== 717 +-- truncate_limit: 100 +ALTER TABLE copy_rel_to ENABLE ROW LEVEL SECURITY +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE copy_rel_to ENABLE ROW LEVEL SECURITY" +== 718 +-- truncate_limit: 100 +GRANT ALL ON copy_rel_to TO regress_rls_bob, regress_rls_exempt_user +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON copy_rel_to TO regress_rls_bob, regress_rls_exempt_user" +== 719 +-- truncate_limit: 100 +INSERT INTO copy_rel_to VALUES (1, public.fipshash('1')) +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=DML +FUNCTION: name="public.fipshash" function="fipshash" schema="public" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copy_rel_to VALUES (1, public.fipshash('1'))" +== 720 +-- truncate_limit: 100 +-- Check COPY TO as Superuser/owner. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 721 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 722 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 723 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 724 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 725 +-- truncate_limit: 100 +-- Check COPY TO as user with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 726 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 727 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 728 +-- truncate_limit: 100 +--fail - would be affected by RLS +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 729 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 730 +-- truncate_limit: 100 +--ok + +-- Check COPY TO as user with permissions and BYPASSRLS +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_exempt_user" +== 731 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 732 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 733 +-- truncate_limit: 100 +--ok +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 734 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 735 +-- truncate_limit: 100 +--ok + +-- Check COPY TO as user without permissions. SET row_security TO OFF; +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 736 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 737 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 738 +-- truncate_limit: 100 +--fail - permission denied +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 739 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 740 +-- truncate_limit: 100 +--fail - permission denied + +-- Check behavior with a child table. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 741 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 742 +-- truncate_limit: 100 +CREATE TABLE copy_rel_to_child () INHERITS (copy_rel_to) +-- +TABLE: name="copy_rel_to_child" schema="" table="copy_rel_to_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE copy_rel_to_child () INHERITS (copy_rel_to)" +== 743 +-- truncate_limit: 100 +INSERT INTO copy_rel_to_child VALUES (1, 'one'), (2, 'two') +-- +TABLE: name="copy_rel_to_child" schema="" table="copy_rel_to_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO copy_rel_to_child VALUES (1, 'one'), (2, 'two')" +== 744 +-- truncate_limit: 100 +-- Check COPY TO as Superuser/owner. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 745 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 746 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 747 +-- truncate_limit: 100 +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 748 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 749 +-- truncate_limit: 100 +-- Check COPY TO as user with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 750 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 751 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 752 +-- truncate_limit: 100 +--fail - would be affected by RLS +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 753 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 754 +-- truncate_limit: 100 +--ok + +-- Check COPY TO as user with permissions and BYPASSRLS +SET SESSION AUTHORIZATION regress_rls_exempt_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_exempt_user" +== 755 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 756 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 757 +-- truncate_limit: 100 +--ok +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 758 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 759 +-- truncate_limit: 100 +--ok + +-- Check COPY TO as user without permissions. SET row_security TO OFF; +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 760 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 761 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 762 +-- truncate_limit: 100 +--fail - permission denied +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 763 +-- truncate_limit: 100 +COPY copy_rel_to TO STDOUT WITH DELIMITER ',' +-- +TABLE: name="copy_rel_to" schema="" table="copy_rel_to" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_rel_to TO STDOUT WITH (DELIMITER ',')" +== 764 +-- truncate_limit: 100 +--fail - permission denied + +-- Check COPY FROM as Superuser/owner. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 765 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 766 +-- truncate_limit: 100 +COPY copy_t FROM STDIN +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_t FROM STDIN" +== 767 +-- truncate_limit: 100 +--ok +1 abc +2 bcd +3 cde +4 def +SET row_security TO ON +-- +ERROR: syntax error at or near "1" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 768 +-- truncate_limit: 100 +-- Check COPY FROM as user with permissions. +SET SESSION AUTHORIZATION regress_rls_bob +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_bob" +== 769 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 770 +-- truncate_limit: 100 +COPY copy_t FROM STDIN +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_t FROM STDIN" +== 771 +-- truncate_limit: 100 +--fail - would be affected by RLS. +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" +== 772 +-- truncate_limit: 100 +-- Check COPY FROM as user without permissions. +SET SESSION AUTHORIZATION regress_rls_carol +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rls_carol" +== 773 +-- truncate_limit: 100 +SET row_security TO OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO OFF" +== 774 +-- truncate_limit: 100 +COPY copy_t FROM STDIN +-- +TABLE: name="copy_t" schema="" table="copy_t" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY copy_t FROM STDIN" +== 775 +-- truncate_limit: 100 +--fail - permission denied. +SET row_security TO ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET row_security TO ON" diff --git a/parser/testdata/summary_truncate/postgres_regress/rowtypes.metadata.json b/parser/testdata/summary_truncate/postgres_regress/rowtypes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rowtypes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/rowtypes.test b/parser/testdata/summary_truncate/postgres_regress/rowtypes.test new file mode 100644 index 0000000..be476f8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rowtypes.test @@ -0,0 +1,1898 @@ +== 001 +-- truncate_limit: 100 +|-- +-- ROWTYPES +|-- + +-- Make both a standalone composite type and a table rowtype + +create type complex as (r float8, i float8) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE complex AS (r float8, i float8)" +== 002 +-- truncate_limit: 100 +create temp table fullname (first text, last text) +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE fullname (first text, last text)" +== 003 +-- truncate_limit: 100 +-- Nested composite + +create type quad as (c1 complex, c2 complex) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE quad AS (c1 complex, c2 complex)" +== 004 +-- truncate_limit: 100 +-- Some simple tests of I/O conversions and row construction + +select (1.1,2.2)::complex, row((3.3,4.4),(5.5,null))::quad +-- +STMT: SelectStmt +TRUNCATED: "SELECT (1.1, 2.2)::complex, ROW((3.3, 4.4), (5.5, NULL))::quad" +== 005 +-- truncate_limit: 100 +select row('Joe', 'Blow')::fullname, '(Joe,Blow)'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW('Joe', 'Blow')::fullname, '(Joe,Blow)'::fullname" +== 006 +-- truncate_limit: 100 +select '(Joe,von Blow)'::fullname, '(Joe,d''Blow)'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(Joe,von Blow)'::fullname, '(Joe,d''Blow)'::fullname" +== 007 +-- truncate_limit: 100 +select '(Joe,"von""Blow")'::fullname, E'(Joe,d\\\\Blow)'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(Joe,\"von\"\"Blow\")'::fullname, E'(Joe,d\\\\\\\\Blow)'::fullname" +== 008 +-- truncate_limit: 100 +select '(Joe,"Blow,Jr")'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(Joe,\"Blow,Jr\")'::fullname" +== 009 +-- truncate_limit: 100 +select '(Joe,)'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(Joe,)'::fullname" +== 010 +-- truncate_limit: 100 +-- ok, null 2nd column +select '(Joe)'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(Joe)'::fullname" +== 011 +-- truncate_limit: 100 +-- bad +select '(Joe,,)'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(Joe,,)'::fullname" +== 012 +-- truncate_limit: 100 +-- bad +select '[]'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT '[]'::fullname" +== 013 +-- truncate_limit: 100 +-- bad +select ' (Joe,Blow) '::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' (Joe,Blow) '::fullname" +== 014 +-- truncate_limit: 100 +-- ok, extra whitespace +select '(Joe,Blow) /'::fullname +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(Joe,Blow) /'::fullname" +== 015 +-- truncate_limit: 100 +-- bad + +-- test non-error-throwing API +SELECT pg_input_is_valid('(1,2)', 'complex') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1,2)', 'complex')" +== 016 +-- truncate_limit: 100 +SELECT pg_input_is_valid('(1,2', 'complex') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1,2', 'complex')" +== 017 +-- truncate_limit: 100 +SELECT pg_input_is_valid('(1,zed)', 'complex') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(1,zed)', 'complex')" +== 018 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('(1,zed)', 'complex') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(1,zed)', 'complex')" +== 019 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('(1,1e400)', 'complex') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(1,1e400)', 'complex')" +== 020 +-- truncate_limit: 100 +create temp table quadtable(f1 int, q quad) +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE quadtable (f1 int, q quad)" +== 021 +-- truncate_limit: 100 +insert into quadtable values (1, ((3.3,4.4),(5.5,6.6))) +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quadtable VALUES (1, ((3.3, 4.4), (5.5, 6.6)))" +== 022 +-- truncate_limit: 100 +insert into quadtable values (2, ((null,4.4),(5.5,6.6))) +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quadtable VALUES (2, ((NULL, 4.4), (5.5, 6.6)))" +== 023 +-- truncate_limit: 100 +select * from quadtable +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quadtable" +== 024 +-- truncate_limit: 100 +select f1, q.c1 from quadtable +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, q.c1 FROM quadtable" +== 025 +-- truncate_limit: 100 +-- fails, q is a table reference + +select f1, (q).c1, (qq.q).c1.i from quadtable qq +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=Select +ALIAS: "qq"="quadtable" +STMT: SelectStmt +TRUNCATED: "SELECT f1, (q).c1, (qq.q).c1.i FROM quadtable qq" +== 026 +-- truncate_limit: 100 +create temp table people (fn fullname, bd date) +-- +TABLE: name="people" schema="" table="people" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE people (fn fullname, bd date)" +== 027 +-- truncate_limit: 100 +insert into people values ('(Joe,Blow)', '1984-01-10') +-- +TABLE: name="people" schema="" table="people" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO people VALUES ('(Joe,Blow)', '1984-01-10')" +== 028 +-- truncate_limit: 100 +select * from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM people" +== 029 +-- truncate_limit: 100 +-- at the moment this will not work due to ALTER TABLE inadequacy: +alter table fullname add column suffix text default '' +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fullname ADD COLUMN suffix text DEFAULT ''" +== 030 +-- truncate_limit: 100 +-- but this should work: +alter table fullname add column suffix text default null +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fullname ADD COLUMN suffix text DEFAULT NULL" +== 031 +-- truncate_limit: 100 +select * from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM people" +== 032 +-- truncate_limit: 100 +-- test insertion/updating of subfields +update people set fn.suffix = 'Jr' +-- +TABLE: name="people" schema="" table="people" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE people SET fn.suffix = 'Jr'" +== 033 +-- truncate_limit: 100 +select * from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM people" +== 034 +-- truncate_limit: 100 +insert into quadtable (f1, q.c1.r, q.c2.i) values(44,55,66) +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO quadtable (f1, q.c1.r, q.c2.i) VALUES (44, 55, 66)" +== 035 +-- truncate_limit: 100 +update quadtable set q.c1.r = 12 where f1 = 2 +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE quadtable SET q.c1.r = 12 WHERE f1 = 2" +== 036 +-- truncate_limit: 100 +update quadtable set q.c1 = 12 +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE quadtable SET q.c1 = 12" +== 037 +-- truncate_limit: 100 +-- error, type mismatch + +select * from quadtable +-- +TABLE: name="quadtable" schema="" table="quadtable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM quadtable" +== 038 +-- truncate_limit: 100 +-- The object here is to ensure that toasted references inside +-- composite values don't cause problems. The large f1 value will +-- be toasted inside pp, it must still work after being copied to people. + +create temp table pp (f1 text) +-- +TABLE: name="pp" schema="" table="pp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pp (f1 text)" +== 039 +-- truncate_limit: 100 +insert into pp values (repeat('abcdefghijkl', 100000)) +-- +TABLE: name="pp" schema="" table="pp" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pp VALUES (repeat('abcdefghijkl', 100000))" +== 040 +-- truncate_limit: 100 +insert into people select ('Jim', f1, null)::fullname, current_date from pp +-- +TABLE: name="people" schema="" table="people" ctx=DML +TABLE: name="pp" schema="" table="pp" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO people SELECT ('Jim', f1, NULL)::fullname, current_date FROM pp" +== 041 +-- truncate_limit: 100 +select (fn).first, substr((fn).last, 1, 20), length((fn).last) from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (fn).first, substr((fn).last, 1, 20), length((fn).last) FROM people" +== 042 +-- truncate_limit: 100 +-- try an update on a toasted composite value, too +update people set fn.first = 'Jack' +-- +TABLE: name="people" schema="" table="people" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE people SET fn.first = 'Jack'" +== 043 +-- truncate_limit: 100 +select (fn).first, substr((fn).last, 1, 20), length((fn).last) from people +-- +TABLE: name="people" schema="" table="people" ctx=Select +FUNCTION: name="substr" function="substr" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (fn).first, substr((fn).last, 1, 20), length((fn).last) FROM people" +== 044 +-- truncate_limit: 100 +-- Test row comparison semantics. Prior to PG 8.2 we did this in a totally +-- non-spec-compliant way. + +select ROW(1,2) < ROW(1,3) as true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) < ROW(1, 3) AS \"true\"" +== 045 +-- truncate_limit: 100 +select ROW(1,2) < ROW(1,1) as false +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) < ROW(1, 1) AS \"false\"" +== 046 +-- truncate_limit: 100 +select ROW(1,2) < ROW(1,NULL) as null +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) < ROW(1, NULL) AS \"null\"" +== 047 +-- truncate_limit: 100 +select ROW(1,2,3) < ROW(1,3,NULL) as true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2, 3) < ROW(1, 3, NULL) AS \"true\"" +== 048 +-- truncate_limit: 100 +-- the NULL is not examined +select ROW(11,'ABC') < ROW(11,'DEF') as true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(11, 'ABC') < ROW(11, 'DEF') AS \"true\"" +== 049 +-- truncate_limit: 100 +select ROW(11,'ABC') > ROW(11,'DEF') as false +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(11, 'ABC') > ROW(11, 'DEF') AS \"false\"" +== 050 +-- truncate_limit: 100 +select ROW(12,'ABC') > ROW(11,'DEF') as true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(12, 'ABC') > ROW(11, 'DEF') AS \"true\"" +== 051 +-- truncate_limit: 100 +-- = and <> have different NULL-behavior than < etc +select ROW(1,2,3) < ROW(1,NULL,4) as null +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2, 3) < ROW(1, NULL, 4) AS \"null\"" +== 052 +-- truncate_limit: 100 +select ROW(1,2,3) = ROW(1,NULL,4) as false +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2, 3) = ROW(1, NULL, 4) AS \"false\"" +== 053 +-- truncate_limit: 100 +select ROW(1,2,3) <> ROW(1,NULL,4) as true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2, 3) <> ROW(1, NULL, 4) AS \"true\"" +== 054 +-- truncate_limit: 100 +-- We allow operators beyond the six standard ones, if they have btree +-- operator classes. +select ROW('ABC','DEF') ~<=~ ROW('DEF','ABC') as true +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW('ABC', 'DEF') ~<=~ ROW('DEF', 'ABC') AS \"true\"" +== 055 +-- truncate_limit: 100 +select ROW('ABC','DEF') ~>=~ ROW('DEF','ABC') as false +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW('ABC', 'DEF') ~>=~ ROW('DEF', 'ABC') AS \"false\"" +== 056 +-- truncate_limit: 100 +select ROW('ABC','DEF') ~~ ROW('DEF','ABC') as fail +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW('ABC', 'DEF') ~~ ROW('DEF', 'ABC') AS fail" +== 057 +-- truncate_limit: 100 +-- Comparisons of ROW() expressions can cope with some type mismatches +select ROW(1,2) = ROW(1,2::int8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) = ROW(1, 2::int8)" +== 058 +-- truncate_limit: 100 +select ROW(1,2) in (ROW(3,4), ROW(1,2)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) IN (ROW(3, 4), ROW(1, 2))" +== 059 +-- truncate_limit: 100 +select ROW(1,2) in (ROW(3,4), ROW(1,2::int8)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) IN (ROW(3, 4), ROW(1, 2::int8))" +== 060 +-- truncate_limit: 100 +-- Check row comparison with a subselect +select unique1, unique2 from tenk1 +where (unique1, unique2) < any (select ten, ten from tenk1 where hundred < 3) + and unique1 <= 20 +order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM tenk1 WHERE ... ORDER BY 1" +== 061 +-- truncate_limit: 100 +-- Also check row comparison with an indexable condition +explain (costs off) +select thousand, tenthous from tenk1 +where (thousand, tenthous) >= (997, 5000) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, tenthous FROM tenk1 WHERE (thousand, tenthous) >= (997, 5000..." +== 062 +-- truncate_limit: 100 +select thousand, tenthous from tenk1 +where (thousand, tenthous) >= (997, 5000) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT thousand, tenthous FROM tenk1 WHERE ... ORDER BY thousand, tenthous" +== 063 +-- truncate_limit: 100 +explain (costs off) +select thousand, tenthous, four from tenk1 +where (thousand, tenthous, four) > (998, 5000, 3) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, tenthous, four FROM tenk1 WHERE (thousand, tenthous, four) >..." +== 064 +-- truncate_limit: 100 +select thousand, tenthous, four from tenk1 +where (thousand, tenthous, four) > (998, 5000, 3) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT thousand, tenthous, four FROM tenk1 WHERE ... ORDER BY thousand, tenthous" +== 065 +-- truncate_limit: 100 +explain (costs off) +select thousand, tenthous from tenk1 +where (998, 5000) < (thousand, tenthous) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, tenthous FROM tenk1 WHERE (998, 5000) < (thousand, tenthous)..." +== 066 +-- truncate_limit: 100 +select thousand, tenthous from tenk1 +where (998, 5000) < (thousand, tenthous) +order by thousand, tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT thousand, tenthous FROM tenk1 WHERE ... ORDER BY thousand, tenthous" +== 067 +-- truncate_limit: 100 +explain (costs off) +select thousand, hundred from tenk1 +where (998, 5000) < (thousand, hundred) +order by thousand, hundred +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT thousand, hundred FROM tenk1 WHERE (998, 5000) < (thousand, hundred) O..." +== 068 +-- truncate_limit: 100 +select thousand, hundred from tenk1 +where (998, 5000) < (thousand, hundred) +order by thousand, hundred +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT thousand, hundred FROM tenk1 WHERE ... ORDER BY thousand, hundred" +== 069 +-- truncate_limit: 100 +-- Test case for bug #14010: indexed row comparisons fail with nulls +create temp table test_table (a text, b text) +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_table (a text, b text)" +== 070 +-- truncate_limit: 100 +insert into test_table values ('a', 'b') +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_table VALUES ('a', 'b')" +== 071 +-- truncate_limit: 100 +insert into test_table select 'a', null from generate_series(1,1000) +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_table SELECT 'a', NULL FROM generate_series(1, 1000)" +== 072 +-- truncate_limit: 100 +insert into test_table values ('b', 'a') +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_table VALUES ('b', 'a')" +== 073 +-- truncate_limit: 100 +create index on test_table (a,b) +-- +TABLE: name="test_table" schema="" table="test_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_table USING btree (a, b)" +== 074 +-- truncate_limit: 100 +set enable_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO OFF" +== 075 +-- truncate_limit: 100 +explain (costs off) +select a,b from test_table where (a,b) > ('a','a') order by a,b +-- +TABLE: name="test_table" schema="" table="test_table" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT a, b FROM test_table WHERE (a, b) > ('a', 'a') ORDER BY a, b" +== 076 +-- truncate_limit: 100 +select a,b from test_table where (a,b) > ('a','a') order by a,b +-- +TABLE: name="test_table" schema="" table="test_table" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM test_table WHERE (a, b) > ('a', 'a') ORDER BY a, b" +== 077 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 078 +-- truncate_limit: 100 +-- Check row comparisons with IN +select * from int8_tbl i8 where i8 in (row(123,456)) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="" column="i8" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl i8 WHERE i8 IN (ROW(123, 456))" +== 079 +-- truncate_limit: 100 +-- fail, type mismatch + +explain (costs off) +select * from int8_tbl i8 +where i8 in (row(123,456)::int8_tbl, '(4567890123456789,123)') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="" column="i8" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl i8 WHERE i8 IN (ROW(123, 456)::int8_tbl, '(45678901234..." +== 080 +-- truncate_limit: 100 +select * from int8_tbl i8 +where i8 in (row(123,456)::int8_tbl, '(4567890123456789,123)') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +FILTER: schema="" table="" column="i8" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl i8 WHERE i8 IN (ROW(123, 456)::int8_tbl, '(4567890123456789,123)')" +== 081 +-- truncate_limit: 100 +-- Check ability to select columns from an anonymous rowtype +select (row(1, 2.0)).f1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (ROW(1, 2.0)).f1" +== 082 +-- truncate_limit: 100 +select (row(1, 2.0)).f2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (ROW(1, 2.0)).f2" +== 083 +-- truncate_limit: 100 +select (row(1, 2.0)).nosuch +-- +STMT: SelectStmt +TRUNCATED: "SELECT (ROW(1, 2.0)).nosuch" +== 084 +-- truncate_limit: 100 +-- fail +select (row(1, 2.0)).* +-- +STMT: SelectStmt +TRUNCATED: "SELECT (ROW(1, 2.0)).*" +== 085 +-- truncate_limit: 100 +select (r).f1 from (select row(1, 2.0) as r) ss +-- +STMT: SelectStmt +TRUNCATED: "SELECT (r).f1 FROM (SELECT ROW(1, 2.0) AS r) ss" +== 086 +-- truncate_limit: 100 +select (r).f3 from (select row(1, 2.0) as r) ss +-- +STMT: SelectStmt +TRUNCATED: "SELECT (r).f3 FROM (SELECT ROW(1, 2.0) AS r) ss" +== 087 +-- truncate_limit: 100 +-- fail +select (r).* from (select row(1, 2.0) as r) ss +-- +STMT: SelectStmt +TRUNCATED: "SELECT (r).* FROM (SELECT ROW(1, 2.0) AS r) ss" +== 088 +-- truncate_limit: 100 +-- Check some corner cases involving empty rowtypes +select ROW() +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW()" +== 089 +-- truncate_limit: 100 +select ROW() IS NULL +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW() IS NULL" +== 090 +-- truncate_limit: 100 +select ROW() = ROW() +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW() = ROW()" +== 091 +-- truncate_limit: 100 +-- Check ability to create arrays of anonymous rowtypes +select array[ row(1,2), row(3,4), row(5,6) ] +-- +STMT: SelectStmt +TRUNCATED: "SELECT ARRAY[ROW(1, 2), ROW(3, 4), ROW(5, 6)]" +== 092 +-- truncate_limit: 100 +-- Check ability to compare an anonymous row to elements of an array +select row(1,1.1) = any (array[ row(7,7.7), row(1,1.1), row(0,0.0) ]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 1.1) = ANY(ARRAY[ROW(7, 7.7), ROW(1, 1.1), ROW(0, 0.0)])" +== 093 +-- truncate_limit: 100 +select row(1,1.1) = any (array[ row(7,7.7), row(1,1.0), row(0,0.0) ]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 1.1) = ANY(ARRAY[ROW(7, 7.7), ROW(1, 1.0), ROW(0, 0.0)])" +== 094 +-- truncate_limit: 100 +-- Check behavior with a non-comparable rowtype +create type cantcompare as (p point, r float8) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE cantcompare AS (p point, r float8)" +== 095 +-- truncate_limit: 100 +create temp table cc (f1 cantcompare) +-- +TABLE: name="cc" schema="" table="cc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE cc (f1 cantcompare)" +== 096 +-- truncate_limit: 100 +insert into cc values('("(1,2)",3)') +-- +TABLE: name="cc" schema="" table="cc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cc VALUES ('(\"(1,2)\",3)')" +== 097 +-- truncate_limit: 100 +insert into cc values('("(4,5)",6)') +-- +TABLE: name="cc" schema="" table="cc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cc VALUES ('(\"(4,5)\",6)')" +== 098 +-- truncate_limit: 100 +select * from cc order by f1 +-- +TABLE: name="cc" schema="" table="cc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cc ORDER BY f1" +== 099 +-- truncate_limit: 100 +-- fail, but should complain about cantcompare + +|-- +-- Tests for record_{eq,cmp} +|-- + +create type testtype1 as (a int, b int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype1 AS (a int, b int)" +== 100 +-- truncate_limit: 100 +-- all true +select row(1, 2)::testtype1 < row(1, 3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 < ROW(1, 3)::testtype1" +== 101 +-- truncate_limit: 100 +select row(1, 2)::testtype1 <= row(1, 3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 <= ROW(1, 3)::testtype1" +== 102 +-- truncate_limit: 100 +select row(1, 2)::testtype1 = row(1, 2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 = ROW(1, 2)::testtype1" +== 103 +-- truncate_limit: 100 +select row(1, 2)::testtype1 <> row(1, 3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 <> ROW(1, 3)::testtype1" +== 104 +-- truncate_limit: 100 +select row(1, 3)::testtype1 >= row(1, 2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 3)::testtype1 >= ROW(1, 2)::testtype1" +== 105 +-- truncate_limit: 100 +select row(1, 3)::testtype1 > row(1, 2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 3)::testtype1 > ROW(1, 2)::testtype1" +== 106 +-- truncate_limit: 100 +-- all false +select row(1, -2)::testtype1 < row(1, -3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 < ROW(1, -3)::testtype1" +== 107 +-- truncate_limit: 100 +select row(1, -2)::testtype1 <= row(1, -3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 <= ROW(1, -3)::testtype1" +== 108 +-- truncate_limit: 100 +select row(1, -2)::testtype1 = row(1, -3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 = ROW(1, -3)::testtype1" +== 109 +-- truncate_limit: 100 +select row(1, -2)::testtype1 <> row(1, -2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 <> ROW(1, -2)::testtype1" +== 110 +-- truncate_limit: 100 +select row(1, -3)::testtype1 >= row(1, -2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -3)::testtype1 >= ROW(1, -2)::testtype1" +== 111 +-- truncate_limit: 100 +select row(1, -3)::testtype1 > row(1, -2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -3)::testtype1 > ROW(1, -2)::testtype1" +== 112 +-- truncate_limit: 100 +-- true, but see *< below +select row(1, -2)::testtype1 < row(1, 3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 < ROW(1, 3)::testtype1" +== 113 +-- truncate_limit: 100 +-- mismatches +create type testtype3 as (a int, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype3 AS (a int, b text)" +== 114 +-- truncate_limit: 100 +select row(1, 2)::testtype1 < row(1, 'abc')::testtype3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 < ROW(1, 'abc')::testtype3" +== 115 +-- truncate_limit: 100 +select row(1, 2)::testtype1 <> row(1, 'abc')::testtype3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 <> ROW(1, 'abc')::testtype3" +== 116 +-- truncate_limit: 100 +create type testtype5 as (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype5 AS (a int)" +== 117 +-- truncate_limit: 100 +select row(1, 2)::testtype1 < row(1)::testtype5 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 < ROW(1)::testtype5" +== 118 +-- truncate_limit: 100 +select row(1, 2)::testtype1 <> row(1)::testtype5 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 <> ROW(1)::testtype5" +== 119 +-- truncate_limit: 100 +-- non-comparable types +create type testtype6 as (a int, b point) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype6 AS (a int, b point)" +== 120 +-- truncate_limit: 100 +select row(1, '(1,2)')::testtype6 < row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, '(1,2)')::testtype6 < ROW(1, '(1,3)')::testtype6" +== 121 +-- truncate_limit: 100 +select row(1, '(1,2)')::testtype6 <> row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, '(1,2)')::testtype6 <> ROW(1, '(1,3)')::testtype6" +== 122 +-- truncate_limit: 100 +drop type testtype1, testtype3, testtype5, testtype6 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE testtype1, testtype3, testtype5, testtype6" +== 123 +-- truncate_limit: 100 +|-- +-- Tests for record_image_{eq,cmp} +|-- + +create type testtype1 as (a int, b int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype1 AS (a int, b int)" +== 124 +-- truncate_limit: 100 +-- all true +select row(1, 2)::testtype1 *< row(1, 3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 *< ROW(1, 3)::testtype1" +== 125 +-- truncate_limit: 100 +select row(1, 2)::testtype1 *<= row(1, 3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 *<= ROW(1, 3)::testtype1" +== 126 +-- truncate_limit: 100 +select row(1, 2)::testtype1 *= row(1, 2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 *= ROW(1, 2)::testtype1" +== 127 +-- truncate_limit: 100 +select row(1, 2)::testtype1 *<> row(1, 3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 *<> ROW(1, 3)::testtype1" +== 128 +-- truncate_limit: 100 +select row(1, 3)::testtype1 *>= row(1, 2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 3)::testtype1 *>= ROW(1, 2)::testtype1" +== 129 +-- truncate_limit: 100 +select row(1, 3)::testtype1 *> row(1, 2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 3)::testtype1 *> ROW(1, 2)::testtype1" +== 130 +-- truncate_limit: 100 +-- all false +select row(1, -2)::testtype1 *< row(1, -3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 *< ROW(1, -3)::testtype1" +== 131 +-- truncate_limit: 100 +select row(1, -2)::testtype1 *<= row(1, -3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 *<= ROW(1, -3)::testtype1" +== 132 +-- truncate_limit: 100 +select row(1, -2)::testtype1 *= row(1, -3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 *= ROW(1, -3)::testtype1" +== 133 +-- truncate_limit: 100 +select row(1, -2)::testtype1 *<> row(1, -2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 *<> ROW(1, -2)::testtype1" +== 134 +-- truncate_limit: 100 +select row(1, -3)::testtype1 *>= row(1, -2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -3)::testtype1 *>= ROW(1, -2)::testtype1" +== 135 +-- truncate_limit: 100 +select row(1, -3)::testtype1 *> row(1, -2)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -3)::testtype1 *> ROW(1, -2)::testtype1" +== 136 +-- truncate_limit: 100 +-- This returns the "wrong" order because record_image_cmp works on +-- unsigned datums without knowing about the actual data type. +select row(1, -2)::testtype1 *< row(1, 3)::testtype1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, -2)::testtype1 *< ROW(1, 3)::testtype1" +== 137 +-- truncate_limit: 100 +-- other types +create type testtype2 as (a smallint, b bool) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype2 AS (a smallint, b bool)" +== 138 +-- truncate_limit: 100 +-- byval different sizes +select row(1, true)::testtype2 *< row(2, true)::testtype2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, true)::testtype2 *< ROW(2, true)::testtype2" +== 139 +-- truncate_limit: 100 +select row(-2, true)::testtype2 *< row(-1, true)::testtype2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(-2, true)::testtype2 *< ROW(-1, true)::testtype2" +== 140 +-- truncate_limit: 100 +select row(0, false)::testtype2 *< row(0, true)::testtype2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(0, false)::testtype2 *< ROW(0, true)::testtype2" +== 141 +-- truncate_limit: 100 +select row(0, false)::testtype2 *<> row(0, true)::testtype2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(0, false)::testtype2 *<> ROW(0, true)::testtype2" +== 142 +-- truncate_limit: 100 +create type testtype3 as (a int, b text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype3 AS (a int, b text)" +== 143 +-- truncate_limit: 100 +-- variable length +select row(1, 'abc')::testtype3 *< row(1, 'abd')::testtype3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 'abc')::testtype3 *< ROW(1, 'abd')::testtype3" +== 144 +-- truncate_limit: 100 +select row(1, 'abc')::testtype3 *< row(1, 'abcd')::testtype3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 'abc')::testtype3 *< ROW(1, 'abcd')::testtype3" +== 145 +-- truncate_limit: 100 +select row(1, 'abc')::testtype3 *> row(1, 'abd')::testtype3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 'abc')::testtype3 *> ROW(1, 'abd')::testtype3" +== 146 +-- truncate_limit: 100 +select row(1, 'abc')::testtype3 *<> row(1, 'abd')::testtype3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 'abc')::testtype3 *<> ROW(1, 'abd')::testtype3" +== 147 +-- truncate_limit: 100 +create type testtype4 as (a int, b point) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype4 AS (a int, b point)" +== 148 +-- truncate_limit: 100 +-- by ref, fixed length +select row(1, '(1,2)')::testtype4 *< row(1, '(1,3)')::testtype4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, '(1,2)')::testtype4 *< ROW(1, '(1,3)')::testtype4" +== 149 +-- truncate_limit: 100 +select row(1, '(1,2)')::testtype4 *<> row(1, '(1,3)')::testtype4 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, '(1,2)')::testtype4 *<> ROW(1, '(1,3)')::testtype4" +== 150 +-- truncate_limit: 100 +-- mismatches +select row(1, 2)::testtype1 *< row(1, 'abc')::testtype3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 *< ROW(1, 'abc')::testtype3" +== 151 +-- truncate_limit: 100 +select row(1, 2)::testtype1 *<> row(1, 'abc')::testtype3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 *<> ROW(1, 'abc')::testtype3" +== 152 +-- truncate_limit: 100 +create type testtype5 as (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype5 AS (a int)" +== 153 +-- truncate_limit: 100 +select row(1, 2)::testtype1 *< row(1)::testtype5 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 *< ROW(1)::testtype5" +== 154 +-- truncate_limit: 100 +select row(1, 2)::testtype1 *<> row(1)::testtype5 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2)::testtype1 *<> ROW(1)::testtype5" +== 155 +-- truncate_limit: 100 +-- non-comparable types +create type testtype6 as (a int, b point) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE testtype6 AS (a int, b point)" +== 156 +-- truncate_limit: 100 +select row(1, '(1,2)')::testtype6 *< row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, '(1,2)')::testtype6 *< ROW(1, '(1,3)')::testtype6" +== 157 +-- truncate_limit: 100 +select row(1, '(1,2)')::testtype6 *>= row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, '(1,2)')::testtype6 *>= ROW(1, '(1,3)')::testtype6" +== 158 +-- truncate_limit: 100 +select row(1, '(1,2)')::testtype6 *<> row(1, '(1,3)')::testtype6 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, '(1,2)')::testtype6 *<> ROW(1, '(1,3)')::testtype6" +== 159 +-- truncate_limit: 100 +-- anonymous rowtypes in coldeflists +select q.a, q.b = row(2), q.c = array[row(3)], q.d = row(row(4)) from + unnest(array[row(1, row(2), array[row(3)], row(row(4))), + row(2, row(3), array[row(4)], row(row(5)))]) + as q(a int, b record, c record[], d record) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest(ARRAY[ROW(1, ROW(2), ARRAY[ROW(3)], ROW(ROW(4))), ROW(2, ROW(3), ARRAY[ROW..." +== 160 +-- truncate_limit: 100 +drop type testtype1, testtype2, testtype3, testtype4, testtype5, testtype6 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE testtype1, testtype2, testtype3, testtype4, testtype5, testtype6" +== 161 +-- truncate_limit: 100 +|-- +-- Test case derived from bug #5716: check multiple uses of a rowtype result +|-- + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 162 +-- truncate_limit: 100 +CREATE TABLE price ( + id SERIAL PRIMARY KEY, + active BOOLEAN NOT NULL, + price NUMERIC +) +-- +TABLE: name="price" schema="" table="price" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE price (id serial PRIMARY KEY, active boolean NOT NULL, price numeric)" +== 163 +-- truncate_limit: 100 +CREATE TYPE price_input AS ( + id INTEGER, + price NUMERIC +) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE price_input AS (id int, price numeric)" +== 164 +-- truncate_limit: 100 +CREATE TYPE price_key AS ( + id INTEGER +) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE price_key AS (id int)" +== 165 +-- truncate_limit: 100 +CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$ + SELECT $1.id +$$ LANGUAGE SQL +-- +FUNCTION: name="price_key_from_table" function="price_key_from_table" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$\n SELECT $1.id\n$$ LANGUAGE sql" +== 166 +-- truncate_limit: 100 +CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$ + SELECT $1.id +$$ LANGUAGE SQL +-- +FUNCTION: name="price_key_from_input" function="price_key_from_input" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$\n SELECT $1.id\n$$ LAN..." +== 167 +-- truncate_limit: 100 +insert into price values (1,false,42), (10,false,100), (11,true,17.99) +-- +TABLE: name="price" schema="" table="price" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO price VALUES (1, false, 42), (10, false, 100), (11, true, 17.99)" +== 168 +-- truncate_limit: 100 +UPDATE price + SET active = true, price = input_prices.price + FROM unnest(ARRAY[(10, 123.00), (11, 99.99)]::price_input[]) input_prices + WHERE price_key_from_table(price.*) = price_key_from_input(input_prices.*) +-- +TABLE: name="price" schema="" table="price" ctx=DML +FUNCTION: name="price_key_from_table" function="price_key_from_table" schema="" ctx=Call +FUNCTION: name="price_key_from_input" function="price_key_from_input" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE price SET ... = ... FROM unnest(ARRAY[(10, 123.00), (11, 99.99)]::price_input[]) input_pri..." +== 169 +-- truncate_limit: 100 +select * from price +-- +TABLE: name="price" schema="" table="price" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM price" +== 170 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 171 +-- truncate_limit: 100 +|-- +-- Test case derived from bug #9085: check * qualification of composite +-- parameters for SQL functions +|-- + +create temp table compos (f1 int, f2 text) +-- +TABLE: name="compos" schema="" table="compos" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE compos (f1 int, f2 text)" +== 172 +-- truncate_limit: 100 +create function fcompos1(v compos) returns void as $$ +insert into compos values (v); -- fail +$$ language sql +-- +FUNCTION: name="fcompos1" function="fcompos1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fcompos1(v compos) RETURNS void AS $$\ninsert into compos values (v); -- fail\n$$ ..." +== 173 +-- truncate_limit: 100 +create function fcompos1(v compos) returns void as $$ +insert into compos values (v.*); +$$ language sql +-- +FUNCTION: name="fcompos1" function="fcompos1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fcompos1(v compos) RETURNS void AS $$\ninsert into compos values (v.*);\n$$ LANGUAG..." +== 174 +-- truncate_limit: 100 +create function fcompos2(v compos) returns void as $$ +select fcompos1(v); +$$ language sql +-- +FUNCTION: name="fcompos2" function="fcompos2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fcompos2(v compos) RETURNS void AS $$\nselect fcompos1(v);\n$$ LANGUAGE sql" +== 175 +-- truncate_limit: 100 +create function fcompos3(v compos) returns void as $$ +select fcompos1(fcompos3.v.*); +$$ language sql +-- +FUNCTION: name="fcompos3" function="fcompos3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fcompos3(v compos) RETURNS void AS $$\nselect fcompos1(fcompos3.v.*);\n$$ LANGUAGE sql" +== 176 +-- truncate_limit: 100 +select fcompos1(row(1,'one')) +-- +FUNCTION: name="fcompos1" function="fcompos1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT fcompos1(ROW(1, 'one'))" +== 177 +-- truncate_limit: 100 +select fcompos2(row(2,'two')) +-- +FUNCTION: name="fcompos2" function="fcompos2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT fcompos2(ROW(2, 'two'))" +== 178 +-- truncate_limit: 100 +select fcompos3(row(3,'three')) +-- +FUNCTION: name="fcompos3" function="fcompos3" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT fcompos3(ROW(3, 'three'))" +== 179 +-- truncate_limit: 100 +select * from compos +-- +TABLE: name="compos" schema="" table="compos" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM compos" +== 180 +-- truncate_limit: 100 +|-- +-- We allow I/O conversion casts from composite types to strings to be +-- invoked via cast syntax, but not functional syntax. This is because +-- the latter is too prone to be invoked unintentionally. +|-- +select cast (fullname as text) from fullname +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT fullname::text FROM fullname" +== 181 +-- truncate_limit: 100 +select fullname::text from fullname +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT fullname::text FROM fullname" +== 182 +-- truncate_limit: 100 +select text(fullname) from fullname +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +FUNCTION: name="text" function="text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT text(fullname) FROM fullname" +== 183 +-- truncate_limit: 100 +-- error +select fullname.text from fullname +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT fullname.text FROM fullname" +== 184 +-- truncate_limit: 100 +-- error +-- same, but RECORD instead of named composite type: +select cast (row('Jim', 'Beam') as text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW('Jim', 'Beam')::text" +== 185 +-- truncate_limit: 100 +select (row('Jim', 'Beam'))::text +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW('Jim', 'Beam')::text" +== 186 +-- truncate_limit: 100 +select text(row('Jim', 'Beam')) +-- +FUNCTION: name="text" function="text" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT text(ROW('Jim', 'Beam'))" +== 187 +-- truncate_limit: 100 +-- error +select (row('Jim', 'Beam')).text +-- +STMT: SelectStmt +TRUNCATED: "SELECT (ROW('Jim', 'Beam')).text" +== 188 +-- truncate_limit: 100 +-- error + +|-- +-- Check the equivalence of functional and column notation +|-- +insert into fullname values ('Joe', 'Blow') +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fullname VALUES ('Joe', 'Blow')" +== 189 +-- truncate_limit: 100 +select f.last from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +STMT: SelectStmt +TRUNCATED: "SELECT f.last FROM fullname f" +== 190 +-- truncate_limit: 100 +select last(f) from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +FUNCTION: name="last" function="last" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT last(f) FROM fullname f" +== 191 +-- truncate_limit: 100 +create function longname(fullname) returns text language sql +as $$select $1.first || ' ' || $1.last$$ +-- +FUNCTION: name="longname" function="longname" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION longname(fullname) RETURNS text LANGUAGE sql AS $$select $1.first || ' ' || $1.la..." +== 192 +-- truncate_limit: 100 +select f.longname from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +STMT: SelectStmt +TRUNCATED: "SELECT f.longname FROM fullname f" +== 193 +-- truncate_limit: 100 +select longname(f) from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +FUNCTION: name="longname" function="longname" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT longname(f) FROM fullname f" +== 194 +-- truncate_limit: 100 +-- Starting in v11, the notational form does matter if there's ambiguity +alter table fullname add column longname text +-- +TABLE: name="fullname" schema="" table="fullname" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE fullname ADD COLUMN longname text" +== 195 +-- truncate_limit: 100 +select f.longname from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +STMT: SelectStmt +TRUNCATED: "SELECT f.longname FROM fullname f" +== 196 +-- truncate_limit: 100 +select longname(f) from fullname f +-- +TABLE: name="fullname" schema="" table="fullname" ctx=Select +ALIAS: "f"="fullname" +FUNCTION: name="longname" function="longname" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT longname(f) FROM fullname f" +== 197 +-- truncate_limit: 100 +|-- +-- Test that composite values are seen to have the correct column names +-- (bug #11210 and other reports) +|-- + +select row_to_json(i) from int8_tbl i +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(i) FROM int8_tbl i" +== 198 +-- truncate_limit: 100 +-- since "i" is of type "int8_tbl", attaching aliases doesn't change anything: +select row_to_json(i) from int8_tbl i(x,y) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i"="int8_tbl" +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(i) FROM int8_tbl i(x, y)" +== 199 +-- truncate_limit: 100 +-- in these examples, we'll report the exposed column names of the subselect: +select row_to_json(ss) from + (select q1, q2 from int8_tbl) as ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(ss) FROM (SELECT q1, q2 FROM int8_tbl) ss" +== 200 +-- truncate_limit: 100 +select row_to_json(ss) from + (select q1, q2 from int8_tbl offset 0) as ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(ss) FROM (SELECT q1, q2 FROM int8_tbl OFFSET 0) ss" +== 201 +-- truncate_limit: 100 +select row_to_json(ss) from + (select q1 as a, q2 as b from int8_tbl) as ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(ss) FROM (SELECT q1 AS a, q2 AS b FROM int8_tbl) ss" +== 202 +-- truncate_limit: 100 +select row_to_json(ss) from + (select q1 as a, q2 as b from int8_tbl offset 0) as ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(ss) FROM (SELECT q1 AS a, q2 AS b FROM int8_tbl OFFSET 0) ss" +== 203 +-- truncate_limit: 100 +select row_to_json(ss) from + (select q1 as a, q2 as b from int8_tbl) as ss(x,y) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(ss) FROM (SELECT q1 AS a, q2 AS b FROM int8_tbl) ss(x, y)" +== 204 +-- truncate_limit: 100 +select row_to_json(ss) from + (select q1 as a, q2 as b from int8_tbl offset 0) as ss(x,y) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(ss) FROM (SELECT q1 AS a, q2 AS b FROM int8_tbl OFFSET 0) ss(x, y)" +== 205 +-- truncate_limit: 100 +explain (costs off) +select row_to_json(q) from + (select thousand, tenthous from tenk1 + where thousand = 42 and tenthous < 2000 offset 0) q +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT row_to_json(q) FROM (SELECT thousand, tenthous FROM tenk1 WHERE thousa..." +== 206 +-- truncate_limit: 100 +select row_to_json(q) from + (select thousand, tenthous from tenk1 + where thousand = 42 and tenthous < 2000 offset 0) q +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q) FROM (SELECT thousand, tenthous FROM tenk1 WHERE ... OFFSET 0) q" +== 207 +-- truncate_limit: 100 +select row_to_json(q) from + (select thousand as x, tenthous as y from tenk1 + where thousand = 42 and tenthous < 2000 offset 0) q +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q) FROM (SELECT thousand AS x, tenthous AS y FROM tenk1 WHERE ... OFFSET 0) q" +== 208 +-- truncate_limit: 100 +select row_to_json(q) from + (select thousand as x, tenthous as y from tenk1 + where thousand = 42 and tenthous < 2000 offset 0) q(a,b) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +FILTER: schema="" table="" column="tenthous" +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(q) FROM (SELECT ... FROM tenk1 WHERE ... OFFSET 0) q(a, b)" +== 209 +-- truncate_limit: 100 +create temp table tt1 as select * from int8_tbl limit 2 +-- +TABLE: name="tt1" schema="" table="tt1" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt1 AS SELECT * FROM int8_tbl LIMIT 2" +== 210 +-- truncate_limit: 100 +create temp table tt2 () inherits(tt1) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt2 () INHERITS (tt1)" +== 211 +-- truncate_limit: 100 +insert into tt2 values(0,0) +-- +TABLE: name="tt2" schema="" table="tt2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt2 VALUES (0, 0)" +== 212 +-- truncate_limit: 100 +select row_to_json(r) from (select q2,q1 from tt1 offset 0) r +-- +TABLE: name="tt1" schema="" table="tt1" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(r) FROM (SELECT q2, q1 FROM tt1 OFFSET 0) r" +== 213 +-- truncate_limit: 100 +-- check no-op rowtype conversions +create temp table tt3 () inherits(tt2) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tt3 () INHERITS (tt2)" +== 214 +-- truncate_limit: 100 +insert into tt3 values(33,44) +-- +TABLE: name="tt3" schema="" table="tt3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tt3 VALUES (33, 44)" +== 215 +-- truncate_limit: 100 +select row_to_json(tt3::tt2::tt1) from tt3 +-- +TABLE: name="tt3" schema="" table="tt3" ctx=Select +FUNCTION: name="row_to_json" function="row_to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT row_to_json(tt3::tt2::tt1) FROM tt3" +== 216 +-- truncate_limit: 100 +|-- +-- IS [NOT] NULL should not recurse into nested composites (bug #14235) +|-- + +explain (verbose, costs off) +select r, r is null as isnull, r is not null as isnotnull +from (values (1,row(1,2)), (1,row(null,null)), (1,null), + (null,row(1,2)), (null,row(null,null)), (null,null) ) r(a,b) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT r, r IS NULL AS \"isnull\", r IS NOT NULL AS isnotnull FROM (VA..." +== 217 +-- truncate_limit: 100 +select r, r is null as isnull, r is not null as isnotnull +from (values (1,row(1,2)), (1,row(null,null)), (1,null), + (null,row(1,2)), (null,row(null,null)), (null,null) ) r(a,b) +-- +STMT: SelectStmt +TRUNCATED: "SELECT r, r IS NULL AS \"isnull\", r IS NOT NULL AS isnotnull FROM (VALUES (...)) r(a, b)" +== 218 +-- truncate_limit: 100 +explain (verbose, costs off) +with r(a,b) as materialized + (values (1,row(1,2)), (1,row(null,null)), (1,null), + (null,row(1,2)), (null,row(null,null)), (null,null) ) +select r, r is null as isnull, r is not null as isnotnull from r +-- +CTE: "r" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH r(a, b) AS MATERIALIZED (VALUES (1, ROW(1, 2)), (1, ROW(NULL, N..." +== 219 +-- truncate_limit: 100 +with r(a,b) as materialized + (values (1,row(1,2)), (1,row(null,null)), (1,null), + (null,row(1,2)), (null,row(null,null)), (null,null) ) +select r, r is null as isnull, r is not null as isnotnull from r +-- +CTE: "r" +STMT: SelectStmt +TRUNCATED: "WITH r(a, b) AS MATERIALIZED (...) SELECT ... FROM r" +== 220 +-- truncate_limit: 100 +|-- +-- Check parsing of indirect references to composite values (bug #18077) +|-- +explain (verbose, costs off) +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select * from cte2 as t +where (select * from (select c as c1) s + where (select (c1).f1 > 0)) is not null +-- +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH cte(c) AS MATERIALIZED (SELECT ROW(1, 2)), cte2(c) AS (SELECT *..." +== 221 +-- truncate_limit: 100 +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select * from cte2 as t +where (select * from (select c as c1) s + where (select (c1).f1 > 0)) is not null +-- +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: SelectStmt +TRUNCATED: "WITH cte(c) AS MATERIALIZED (...), cte2(c) AS (...) SELECT * FROM cte2 t WHERE ..." +== 222 +-- truncate_limit: 100 +-- Also check deparsing of such cases +create view composite_v as +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select 1 as one from cte2 as t +where (select * from (select c as c1) s + where (select (c1).f1 > 0)) is not null +-- +TABLE: name="composite_v" schema="" table="composite_v" ctx=DDL +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW composite_v AS WITH cte(c) AS MATERIALIZED (SELECT ROW(1, 2)), cte2(c) AS (SELECT * F..." +== 223 +-- truncate_limit: 100 +select pg_get_viewdef('composite_v', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('composite_v', true)" +== 224 +-- truncate_limit: 100 +drop view composite_v +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW composite_v" +== 225 +-- truncate_limit: 100 +|-- +-- Check cases where the composite comes from a proven-dummy rel (bug #18576) +|-- +explain (verbose, costs off) +select (ss.a).x, (ss.a).n from + (select information_schema._pg_expandarray(array[1,2]) AS a) ss +-- +FUNCTION: name="information_schema._pg_expandarray" function="_pg_expandarray" schema="information_schema" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT (ss.a).x, (ss.a).n FROM (SELECT information_schema._pg_expand..." +== 226 +-- truncate_limit: 100 +explain (verbose, costs off) +select (ss.a).x, (ss.a).n from + (select information_schema._pg_expandarray(array[1,2]) AS a) ss +where false +-- +FUNCTION: name="information_schema._pg_expandarray" function="_pg_expandarray" schema="information_schema" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT (ss.a).x, (ss.a).n FROM (SELECT information_schema._pg_expand..." +== 227 +-- truncate_limit: 100 +explain (verbose, costs off) +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select (c).f1 from cte2 as t +-- +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH cte(c) AS MATERIALIZED (SELECT ROW(1, 2)), cte2(c) AS (SELECT *..." +== 228 +-- truncate_limit: 100 +explain (verbose, costs off) +with cte(c) as materialized (select row(1, 2)), + cte2(c) as (select * from cte) +select (c).f1 from cte2 as t +where false +-- +ALIAS: "t"="cte2" +CTE: "cte" +CTE: "cte2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH cte(c) AS MATERIALIZED (SELECT ROW(1, 2)), cte2(c) AS (SELECT *..." +== 229 +-- truncate_limit: 100 +|-- +-- Tests for component access / FieldSelect +|-- +CREATE TABLE compositetable(a text, b text) +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE compositetable (a text, b text)" +== 230 +-- truncate_limit: 100 +INSERT INTO compositetable(a, b) VALUES('fa', 'fb') +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO compositetable (a, b) VALUES ('fa', 'fb')" +== 231 +-- truncate_limit: 100 +-- composite type columns can't directly be accessed (error) +SELECT d.a FROM (SELECT compositetable AS d FROM compositetable) s +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d.a FROM (SELECT compositetable AS d FROM compositetable) s" +== 232 +-- truncate_limit: 100 +-- but can be accessed with proper parens +SELECT (d).a, (d).b FROM (SELECT compositetable AS d FROM compositetable) s +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT (d).a, (d).b FROM (SELECT compositetable AS d FROM compositetable) s" +== 233 +-- truncate_limit: 100 +-- system columns can't be accessed in composite types (error) +SELECT (d).ctid FROM (SELECT compositetable AS d FROM compositetable) s +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT (d).ctid FROM (SELECT compositetable AS d FROM compositetable) s" +== 234 +-- truncate_limit: 100 +-- accessing non-existing column in NULL datum errors out +SELECT (NULL::compositetable).nonexistent +-- +STMT: SelectStmt +TRUNCATED: "SELECT (NULL::compositetable).nonexistent" +== 235 +-- truncate_limit: 100 +-- existing column in a NULL composite yield NULL +SELECT (NULL::compositetable).a +-- +STMT: SelectStmt +TRUNCATED: "SELECT (NULL::compositetable).a" +== 236 +-- truncate_limit: 100 +-- oids can't be accessed in composite types (error) +SELECT (NULL::compositetable).oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT (NULL::compositetable).oid" +== 237 +-- truncate_limit: 100 +DROP TABLE compositetable +-- +TABLE: name="compositetable" schema="" table="compositetable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE compositetable" diff --git a/parser/testdata/summary_truncate/postgres_regress/rules.metadata.json b/parser/testdata/summary_truncate/postgres_regress/rules.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rules.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/rules.test b/parser/testdata/summary_truncate/postgres_regress/rules.test new file mode 100644 index 0000000..3a55ea9 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/rules.test @@ -0,0 +1,5245 @@ +== 001 +-- truncate_limit: 100 +|-- +-- RULES +-- From Jan's original setup_ruletest.sql and run_ruletest.sql +-- - thomas 1998-09-13 +|-- + +|-- +-- Tables and rules for the view test +|-- +create table rtest_t1 (a int4, b int4) +-- +TABLE: name="rtest_t1" schema="" table="rtest_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t1 (a int4, b int4)" +== 002 +-- truncate_limit: 100 +create table rtest_t2 (a int4, b int4) +-- +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t2 (a int4, b int4)" +== 003 +-- truncate_limit: 100 +create table rtest_t3 (a int4, b int4) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t3 (a int4, b int4)" +== 004 +-- truncate_limit: 100 +create view rtest_v1 as select * from rtest_t1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DDL +TABLE: name="rtest_t1" schema="" table="rtest_t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rtest_v1 AS SELECT * FROM rtest_t1" +== 005 +-- truncate_limit: 100 +create rule rtest_v1_ins as on insert to rtest_v1 do instead + insert into rtest_t1 values (new.a, new.b) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_v1_ins AS ON INSERT TO rtest_v1 DO INSTEAD INSERT INTO rtest_t1 VALUES (new.a, ..." +== 006 +-- truncate_limit: 100 +create rule rtest_v1_upd as on update to rtest_v1 do instead + update rtest_t1 set a = new.a, b = new.b + where a = old.a +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_v1_upd AS ON UPDATE TO rtest_v1 DO INSTEAD UPDATE rtest_t1 SET a = new.a, b = n..." +== 007 +-- truncate_limit: 100 +create rule rtest_v1_del as on delete to rtest_v1 do instead + delete from rtest_t1 where a = old.a +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_v1_del AS ON DELETE TO rtest_v1 DO INSTEAD DELETE FROM rtest_t1 WHERE a = old.a" +== 008 +-- truncate_limit: 100 +-- Test comments +COMMENT ON RULE rtest_v1_bad ON rtest_v1 IS 'bad rule' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON RULE rtest_v1_bad ON rtest_v1 IS 'bad rule'" +== 009 +-- truncate_limit: 100 +COMMENT ON RULE rtest_v1_del ON rtest_v1 IS 'delete rule' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON RULE rtest_v1_del ON rtest_v1 IS 'delete rule'" +== 010 +-- truncate_limit: 100 +COMMENT ON RULE rtest_v1_del ON rtest_v1 IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON RULE rtest_v1_del ON rtest_v1 IS NULL" +== 011 +-- truncate_limit: 100 +|-- +-- Tables and rules for the constraint update/delete test +|-- +-- Note: +-- Now that we have multiple action rule support, we check +-- both possible syntaxes to define them (The last action +-- can but must not have a semicolon at the end). +|-- +create table rtest_system (sysname text, sysdesc text) +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_system (sysname text, sysdesc text)" +== 012 +-- truncate_limit: 100 +create table rtest_interface (sysname text, ifname text) +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_interface (sysname text, ifname text)" +== 013 +-- truncate_limit: 100 +create table rtest_person (pname text, pdesc text) +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_person (pname text, pdesc text)" +== 014 +-- truncate_limit: 100 +create table rtest_admin (pname text, sysname text) +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_admin (pname text, sysname text)" +== 015 +-- truncate_limit: 100 +create rule rtest_sys_upd as on update to rtest_system do also ( + update rtest_interface set sysname = new.sysname + where sysname = old.sysname; + update rtest_admin set sysname = new.sysname + where sysname = old.sysname + ) +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_sys_upd AS ON UPDATE TO rtest_system DO (UPDATE rtest_interface SET sysname = n..." +== 016 +-- truncate_limit: 100 +create rule rtest_sys_del as on delete to rtest_system do also ( + delete from rtest_interface where sysname = old.sysname; + delete from rtest_admin where sysname = old.sysname; + ) +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_sys_del AS ON DELETE TO rtest_system DO (DELETE FROM rtest_interface WHERE sysn..." +== 017 +-- truncate_limit: 100 +create rule rtest_pers_upd as on update to rtest_person do also + update rtest_admin set pname = new.pname where pname = old.pname +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_pers_upd AS ON UPDATE TO rtest_person DO UPDATE rtest_admin SET pname = new.pna..." +== 018 +-- truncate_limit: 100 +create rule rtest_pers_del as on delete to rtest_person do also + delete from rtest_admin where pname = old.pname +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_pers_del AS ON DELETE TO rtest_person DO DELETE FROM rtest_admin WHERE pname = ..." +== 019 +-- truncate_limit: 100 +|-- +-- Tables and rules for the logging test +|-- +create table rtest_emp (ename char(20), salary numeric) +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_emp (ename char(20), salary numeric)" +== 020 +-- truncate_limit: 100 +create table rtest_emplog (ename char(20), who name, action char(10), newsal numeric, oldsal numeric) +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_emplog (ename char(20), who name, action char(10), newsal numeric, oldsal nume..." +== 021 +-- truncate_limit: 100 +create table rtest_empmass (ename char(20), salary numeric) +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_empmass (ename char(20), salary numeric)" +== 022 +-- truncate_limit: 100 +create rule rtest_emp_ins as on insert to rtest_emp do + insert into rtest_emplog values (new.ename, current_user, + 'hired', new.salary, '0.00') +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_emp_ins AS ON INSERT TO rtest_emp DO INSERT INTO rtest_emplog VALUES (new.ename..." +== 023 +-- truncate_limit: 100 +create rule rtest_emp_upd as on update to rtest_emp where new.salary != old.salary do + insert into rtest_emplog values (new.ename, current_user, + 'honored', new.salary, old.salary) +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_emp_upd AS ON UPDATE TO rtest_emp WHERE ... DO INSERT INTO rtest_emplog VALUES ..." +== 024 +-- truncate_limit: 100 +create rule rtest_emp_del as on delete to rtest_emp do + insert into rtest_emplog values (old.ename, current_user, + 'fired', '0.00', old.salary) +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_emp_del AS ON DELETE TO rtest_emp DO INSERT INTO rtest_emplog VALUES (old.ename..." +== 025 +-- truncate_limit: 100 +|-- +-- Tables and rules for the multiple cascaded qualified instead +-- rule test +|-- +create table rtest_t4 (a int4, b text) +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t4 (a int4, b text)" +== 026 +-- truncate_limit: 100 +create table rtest_t5 (a int4, b text) +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t5 (a int4, b text)" +== 027 +-- truncate_limit: 100 +create table rtest_t6 (a int4, b text) +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t6 (a int4, b text)" +== 028 +-- truncate_limit: 100 +create table rtest_t7 (a int4, b text) +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t7 (a int4, b text)" +== 029 +-- truncate_limit: 100 +create table rtest_t8 (a int4, b text) +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t8 (a int4, b text)" +== 030 +-- truncate_limit: 100 +create table rtest_t9 (a int4, b text) +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_t9 (a int4, b text)" +== 031 +-- truncate_limit: 100 +create rule rtest_t4_ins1 as on insert to rtest_t4 + where new.a >= 10 and new.a < 20 do instead + insert into rtest_t5 values (new.a, new.b) +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_t4_ins1 AS ON INSERT TO rtest_t4 WHERE ... DO INSTEAD INSERT INTO rtest_t5 VALU..." +== 032 +-- truncate_limit: 100 +create rule rtest_t4_ins2 as on insert to rtest_t4 + where new.a >= 20 and new.a < 30 do + insert into rtest_t6 values (new.a, new.b) +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_t4_ins2 AS ON INSERT TO rtest_t4 WHERE ... DO INSERT INTO rtest_t6 VALUES (new...." +== 033 +-- truncate_limit: 100 +create rule rtest_t5_ins as on insert to rtest_t5 + where new.a > 15 do + insert into rtest_t7 values (new.a, new.b) +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_t5_ins AS ON INSERT TO rtest_t5 WHERE ... DO INSERT INTO rtest_t7 VALUES (new.a..." +== 034 +-- truncate_limit: 100 +create rule rtest_t6_ins as on insert to rtest_t6 + where new.a > 25 do instead + insert into rtest_t8 values (new.a, new.b) +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_t6_ins AS ON INSERT TO rtest_t6 WHERE ... DO INSTEAD INSERT INTO rtest_t8 VALUE..." +== 035 +-- truncate_limit: 100 +|-- +-- Tables and rules for the rule fire order test +|-- +-- As of PG 7.3, the rules should fire in order by name, regardless +-- of INSTEAD attributes or creation order. +|-- +create table rtest_order1 (a int4) +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_order1 (a int4)" +== 036 +-- truncate_limit: 100 +create table rtest_order2 (a int4, b int4, c text) +-- +TABLE: name="rtest_order2" schema="" table="rtest_order2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_order2 (a int4, b int4, c text)" +== 037 +-- truncate_limit: 100 +create sequence rtest_seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE rtest_seq" +== 038 +-- truncate_limit: 100 +create rule rtest_order_r3 as on insert to rtest_order1 do instead + insert into rtest_order2 values (new.a, nextval('rtest_seq'), + 'rule 3 - this should run 3rd') +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_order_r3 AS ON INSERT TO rtest_order1 DO INSTEAD INSERT INTO rtest_order2 VALUE..." +== 039 +-- truncate_limit: 100 +create rule rtest_order_r4 as on insert to rtest_order1 + where a < 100 do instead + insert into rtest_order2 values (new.a, nextval('rtest_seq'), + 'rule 4 - this should run 4th') +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_order_r4 AS ON INSERT TO rtest_order1 WHERE ... DO INSTEAD INSERT INTO rtest_or..." +== 040 +-- truncate_limit: 100 +create rule rtest_order_r2 as on insert to rtest_order1 do + insert into rtest_order2 values (new.a, nextval('rtest_seq'), + 'rule 2 - this should run 2nd') +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_order_r2 AS ON INSERT TO rtest_order1 DO INSERT INTO rtest_order2 VALUES (new.a..." +== 041 +-- truncate_limit: 100 +create rule rtest_order_r1 as on insert to rtest_order1 do instead + insert into rtest_order2 values (new.a, nextval('rtest_seq'), + 'rule 1 - this should run 1st') +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_order_r1 AS ON INSERT TO rtest_order1 DO INSTEAD INSERT INTO rtest_order2 VALUE..." +== 042 +-- truncate_limit: 100 +|-- +-- Tables and rules for the instead nothing test +|-- +create table rtest_nothn1 (a int4, b text) +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_nothn1 (a int4, b text)" +== 043 +-- truncate_limit: 100 +create table rtest_nothn2 (a int4, b text) +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_nothn2 (a int4, b text)" +== 044 +-- truncate_limit: 100 +create table rtest_nothn3 (a int4, b text) +-- +TABLE: name="rtest_nothn3" schema="" table="rtest_nothn3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_nothn3 (a int4, b text)" +== 045 +-- truncate_limit: 100 +create table rtest_nothn4 (a int4, b text) +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_nothn4 (a int4, b text)" +== 046 +-- truncate_limit: 100 +create rule rtest_nothn_r1 as on insert to rtest_nothn1 + where new.a >= 10 and new.a < 20 do instead nothing +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_nothn_r1 AS ON INSERT TO rtest_nothn1 WHERE ... DO INSTEAD NOTHING" +== 047 +-- truncate_limit: 100 +create rule rtest_nothn_r2 as on insert to rtest_nothn1 + where new.a >= 30 and new.a < 40 do instead nothing +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_nothn_r2 AS ON INSERT TO rtest_nothn1 WHERE ... DO INSTEAD NOTHING" +== 048 +-- truncate_limit: 100 +create rule rtest_nothn_r3 as on insert to rtest_nothn2 + where new.a >= 100 do instead + insert into rtest_nothn3 values (new.a, new.b) +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_nothn_r3 AS ON INSERT TO rtest_nothn2 WHERE ... DO INSTEAD INSERT INTO rtest_no..." +== 049 +-- truncate_limit: 100 +create rule rtest_nothn_r4 as on insert to rtest_nothn2 + do instead nothing +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rtest_nothn_r4 AS ON INSERT TO rtest_nothn2 DO INSTEAD NOTHING" +== 050 +-- truncate_limit: 100 +|-- +-- Tests on a view that is select * of a table +-- and has insert/update/delete instead rules to +-- behave close like the real table. +|-- + +|-- +-- We need test date later +|-- +insert into rtest_t2 values (1, 21) +-- +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t2 VALUES (1, 21)" +== 051 +-- truncate_limit: 100 +insert into rtest_t2 values (2, 22) +-- +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t2 VALUES (2, 22)" +== 052 +-- truncate_limit: 100 +insert into rtest_t2 values (3, 23) +-- +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t2 VALUES (3, 23)" +== 053 +-- truncate_limit: 100 +insert into rtest_t3 values (1, 31) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t3 VALUES (1, 31)" +== 054 +-- truncate_limit: 100 +insert into rtest_t3 values (2, 32) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t3 VALUES (2, 32)" +== 055 +-- truncate_limit: 100 +insert into rtest_t3 values (3, 33) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t3 VALUES (3, 33)" +== 056 +-- truncate_limit: 100 +insert into rtest_t3 values (4, 34) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t3 VALUES (4, 34)" +== 057 +-- truncate_limit: 100 +insert into rtest_t3 values (5, 35) +-- +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t3 VALUES (5, 35)" +== 058 +-- truncate_limit: 100 +-- insert values +insert into rtest_v1 values (1, 11) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 VALUES (1, 11)" +== 059 +-- truncate_limit: 100 +insert into rtest_v1 values (2, 12) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 VALUES (2, 12)" +== 060 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 061 +-- truncate_limit: 100 +-- delete with constant expression +delete from rtest_v1 where a = 1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_v1 WHERE a = 1" +== 062 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 063 +-- truncate_limit: 100 +insert into rtest_v1 values (1, 11) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 VALUES (1, 11)" +== 064 +-- truncate_limit: 100 +delete from rtest_v1 where b = 12 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_v1 WHERE b = 12" +== 065 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 066 +-- truncate_limit: 100 +insert into rtest_v1 values (2, 12) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 VALUES (2, 12)" +== 067 +-- truncate_limit: 100 +insert into rtest_v1 values (2, 13) +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 VALUES (2, 13)" +== 068 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 069 +-- truncate_limit: 100 +** Remember the delete rule on rtest_v1: It says +** DO INSTEAD DELETE FROM rtest_t1 WHERE a = old.a +** So this time both rows with a = 2 must get deleted +delete from rtest_v1 where b = 12 +-- +ERROR: syntax error at or near "**" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 070 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 071 +-- truncate_limit: 100 +delete from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_v1" +== 072 +-- truncate_limit: 100 +-- insert select +insert into rtest_v1 select * from rtest_t2 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 SELECT * FROM rtest_t2" +== 073 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 074 +-- truncate_limit: 100 +delete from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_v1" +== 075 +-- truncate_limit: 100 +-- same with swapped targetlist +insert into rtest_v1 (b, a) select b, a from rtest_t2 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 (b, a) SELECT b, a FROM rtest_t2" +== 076 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 077 +-- truncate_limit: 100 +-- now with only one target attribute +insert into rtest_v1 (a) select a from rtest_t3 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 (a) SELECT a FROM rtest_t3" +== 078 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 079 +-- truncate_limit: 100 +select * from rtest_v1 where b isnull +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1 WHERE b IS NULL" +== 080 +-- truncate_limit: 100 +-- let attribute a differ (must be done on rtest_t1 - see above) +update rtest_t1 set a = a + 10 where b isnull +-- +TABLE: name="rtest_t1" schema="" table="rtest_t1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_t1 SET a = a + 10 WHERE b IS NULL" +== 081 +-- truncate_limit: 100 +delete from rtest_v1 where b isnull +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_v1 WHERE b IS NULL" +== 082 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 083 +-- truncate_limit: 100 +-- now updates with constant expression +update rtest_v1 set b = 42 where a = 2 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_v1 SET b = 42 WHERE a = 2" +== 084 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 085 +-- truncate_limit: 100 +update rtest_v1 set b = 99 where b = 42 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_v1 SET b = 99 WHERE b = 42" +== 086 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 087 +-- truncate_limit: 100 +update rtest_v1 set b = 88 where b < 50 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_v1 SET b = 88 WHERE b < 50" +== 088 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 089 +-- truncate_limit: 100 +delete from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_v1" +== 090 +-- truncate_limit: 100 +insert into rtest_v1 select rtest_t2.a, rtest_t3.b + from rtest_t2, rtest_t3 + where rtest_t2.a = rtest_t3.a +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=Select +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=Select +FILTER: schema="" table="rtest_t2" column="a" +FILTER: schema="" table="rtest_t3" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 SELECT rtest_t2.a, rtest_t3.b FROM rtest_t2, rtest_t3 WHERE ..." +== 091 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 092 +-- truncate_limit: 100 +-- updates in a mergejoin +update rtest_v1 set b = rtest_t2.b from rtest_t2 where rtest_v1.a = rtest_t2.a +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t2" schema="" table="rtest_t2" ctx=Select +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_v1 SET b = rtest_t2.b FROM rtest_t2 WHERE rtest_v1.a = rtest_t2.a" +== 093 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 094 +-- truncate_limit: 100 +insert into rtest_v1 select * from rtest_t3 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_v1 SELECT * FROM rtest_t3" +== 095 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 096 +-- truncate_limit: 100 +update rtest_t1 set a = a + 10 where b > 30 +-- +TABLE: name="rtest_t1" schema="" table="rtest_t1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_t1 SET a = a + 10 WHERE b > 30" +== 097 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 098 +-- truncate_limit: 100 +update rtest_v1 set a = rtest_t3.a + 20 from rtest_t3 where rtest_v1.b = rtest_t3.b +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=DML +TABLE: name="rtest_t3" schema="" table="rtest_t3" ctx=Select +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_v1 SET a = rtest_t3.a + 20 FROM rtest_t3 WHERE rtest_v1.b = rtest_t3.b" +== 099 +-- truncate_limit: 100 +select * from rtest_v1 +-- +TABLE: name="rtest_v1" schema="" table="rtest_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_v1" +== 100 +-- truncate_limit: 100 +|-- +-- Test for constraint updates/deletes +|-- +insert into rtest_system values ('orion', 'Linux Jan Wieck') +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_system VALUES ('orion', 'Linux Jan Wieck')" +== 101 +-- truncate_limit: 100 +insert into rtest_system values ('notjw', 'WinNT Jan Wieck (notebook)') +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_system VALUES ('notjw', 'WinNT Jan Wieck (notebook)')" +== 102 +-- truncate_limit: 100 +insert into rtest_system values ('neptun', 'Fileserver') +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_system VALUES ('neptun', 'Fileserver')" +== 103 +-- truncate_limit: 100 +insert into rtest_interface values ('orion', 'eth0') +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_interface VALUES ('orion', 'eth0')" +== 104 +-- truncate_limit: 100 +insert into rtest_interface values ('orion', 'eth1') +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_interface VALUES ('orion', 'eth1')" +== 105 +-- truncate_limit: 100 +insert into rtest_interface values ('notjw', 'eth0') +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_interface VALUES ('notjw', 'eth0')" +== 106 +-- truncate_limit: 100 +insert into rtest_interface values ('neptun', 'eth0') +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_interface VALUES ('neptun', 'eth0')" +== 107 +-- truncate_limit: 100 +insert into rtest_person values ('jw', 'Jan Wieck') +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_person VALUES ('jw', 'Jan Wieck')" +== 108 +-- truncate_limit: 100 +insert into rtest_person values ('bm', 'Bruce Momjian') +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_person VALUES ('bm', 'Bruce Momjian')" +== 109 +-- truncate_limit: 100 +insert into rtest_admin values ('jw', 'orion') +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_admin VALUES ('jw', 'orion')" +== 110 +-- truncate_limit: 100 +insert into rtest_admin values ('jw', 'notjw') +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_admin VALUES ('jw', 'notjw')" +== 111 +-- truncate_limit: 100 +insert into rtest_admin values ('bm', 'neptun') +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_admin VALUES ('bm', 'neptun')" +== 112 +-- truncate_limit: 100 +update rtest_system set sysname = 'pluto' where sysname = 'neptun' +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_system SET sysname = 'pluto' WHERE sysname = 'neptun'" +== 113 +-- truncate_limit: 100 +select * from rtest_interface +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_interface" +== 114 +-- truncate_limit: 100 +select * from rtest_admin +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_admin" +== 115 +-- truncate_limit: 100 +update rtest_person set pname = 'jwieck' where pdesc = 'Jan Wieck' +-- +TABLE: name="rtest_person" schema="" table="rtest_person" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_person SET pname = 'jwieck' WHERE pdesc = 'Jan Wieck'" +== 116 +-- truncate_limit: 100 +-- Note: use ORDER BY here to ensure consistent output across all systems. +-- The above UPDATE affects two rows with equal keys, so they could be +-- updated in either order depending on the whim of the local qsort(). + +select * from rtest_admin order by pname, sysname +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_admin ORDER BY pname, sysname" +== 117 +-- truncate_limit: 100 +delete from rtest_system where sysname = 'orion' +-- +TABLE: name="rtest_system" schema="" table="rtest_system" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_system WHERE sysname = 'orion'" +== 118 +-- truncate_limit: 100 +select * from rtest_interface +-- +TABLE: name="rtest_interface" schema="" table="rtest_interface" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_interface" +== 119 +-- truncate_limit: 100 +select * from rtest_admin +-- +TABLE: name="rtest_admin" schema="" table="rtest_admin" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_admin" +== 120 +-- truncate_limit: 100 +|-- +-- Rule qualification test +|-- +insert into rtest_emp values ('wiecc', '5000.00') +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_emp VALUES ('wiecc', '5000.00')" +== 121 +-- truncate_limit: 100 +insert into rtest_emp values ('gates', '80000.00') +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_emp VALUES ('gates', '80000.00')" +== 122 +-- truncate_limit: 100 +update rtest_emp set ename = 'wiecx' where ename = 'wiecc' +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_emp SET ename = 'wiecx' WHERE ename = 'wiecc'" +== 123 +-- truncate_limit: 100 +update rtest_emp set ename = 'wieck', salary = '6000.00' where ename = 'wiecx' +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_emp SET ename = 'wieck', salary = '6000.00' WHERE ename = 'wiecx'" +== 124 +-- truncate_limit: 100 +update rtest_emp set salary = '7000.00' where ename = 'wieck' +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_emp SET salary = '7000.00' WHERE ename = 'wieck'" +== 125 +-- truncate_limit: 100 +delete from rtest_emp where ename = 'gates' +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_emp WHERE ename = 'gates'" +== 126 +-- truncate_limit: 100 +select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM rtest_emplog ORDER BY ename, action, newsal" +== 127 +-- truncate_limit: 100 +insert into rtest_empmass values ('meyer', '4000.00') +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_empmass VALUES ('meyer', '4000.00')" +== 128 +-- truncate_limit: 100 +insert into rtest_empmass values ('maier', '5000.00') +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_empmass VALUES ('maier', '5000.00')" +== 129 +-- truncate_limit: 100 +insert into rtest_empmass values ('mayr', '6000.00') +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_empmass VALUES ('mayr', '6000.00')" +== 130 +-- truncate_limit: 100 +insert into rtest_emp select * from rtest_empmass +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_emp SELECT * FROM rtest_empmass" +== 131 +-- truncate_limit: 100 +select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM rtest_emplog ORDER BY ename, action, newsal" +== 132 +-- truncate_limit: 100 +update rtest_empmass set salary = salary + '1000.00' +-- +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_empmass SET salary = salary + '1000.00'" +== 133 +-- truncate_limit: 100 +update rtest_emp set salary = rtest_empmass.salary from rtest_empmass where rtest_emp.ename = rtest_empmass.ename +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=Select +STMT: UpdateStmt +TRUNCATED: "UPDATE rtest_emp SET salary = rtest_empmass.salary FROM rtest_empmass WHERE ..." +== 134 +-- truncate_limit: 100 +select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM rtest_emplog ORDER BY ename, action, newsal" +== 135 +-- truncate_limit: 100 +delete from rtest_emp using rtest_empmass where rtest_emp.ename = rtest_empmass.ename +-- +TABLE: name="rtest_emp" schema="" table="rtest_emp" ctx=DML +TABLE: name="rtest_empmass" schema="" table="rtest_empmass" ctx=Select +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_emp USING rtest_empmass WHERE rtest_emp.ename = rtest_empmass.ename" +== 136 +-- truncate_limit: 100 +select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal +-- +TABLE: name="rtest_emplog" schema="" table="rtest_emplog" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM rtest_emplog ORDER BY ename, action, newsal" +== 137 +-- truncate_limit: 100 +|-- +-- Multiple cascaded qualified instead rule test +|-- +insert into rtest_t4 values (1, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (1, 'Record should go to rtest_t4')" +== 138 +-- truncate_limit: 100 +insert into rtest_t4 values (2, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (2, 'Record should go to rtest_t4')" +== 139 +-- truncate_limit: 100 +insert into rtest_t4 values (10, 'Record should go to rtest_t5') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (10, 'Record should go to rtest_t5')" +== 140 +-- truncate_limit: 100 +insert into rtest_t4 values (15, 'Record should go to rtest_t5') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (15, 'Record should go to rtest_t5')" +== 141 +-- truncate_limit: 100 +insert into rtest_t4 values (19, 'Record should go to rtest_t5 and t7') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (19, 'Record should go to rtest_t5 and t7')" +== 142 +-- truncate_limit: 100 +insert into rtest_t4 values (20, 'Record should go to rtest_t4 and t6') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (20, 'Record should go to rtest_t4 and t6')" +== 143 +-- truncate_limit: 100 +insert into rtest_t4 values (26, 'Record should go to rtest_t4 and t8') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (26, 'Record should go to rtest_t4 and t8')" +== 144 +-- truncate_limit: 100 +insert into rtest_t4 values (28, 'Record should go to rtest_t4 and t8') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (28, 'Record should go to rtest_t4 and t8')" +== 145 +-- truncate_limit: 100 +insert into rtest_t4 values (30, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (30, 'Record should go to rtest_t4')" +== 146 +-- truncate_limit: 100 +insert into rtest_t4 values (40, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 VALUES (40, 'Record should go to rtest_t4')" +== 147 +-- truncate_limit: 100 +select * from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t4" +== 148 +-- truncate_limit: 100 +select * from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t5" +== 149 +-- truncate_limit: 100 +select * from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t6" +== 150 +-- truncate_limit: 100 +select * from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t7" +== 151 +-- truncate_limit: 100 +select * from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t8" +== 152 +-- truncate_limit: 100 +delete from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_t4" +== 153 +-- truncate_limit: 100 +delete from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_t5" +== 154 +-- truncate_limit: 100 +delete from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_t6" +== 155 +-- truncate_limit: 100 +delete from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_t7" +== 156 +-- truncate_limit: 100 +delete from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_t8" +== 157 +-- truncate_limit: 100 +insert into rtest_t9 values (1, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (1, 'Record should go to rtest_t4')" +== 158 +-- truncate_limit: 100 +insert into rtest_t9 values (2, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (2, 'Record should go to rtest_t4')" +== 159 +-- truncate_limit: 100 +insert into rtest_t9 values (10, 'Record should go to rtest_t5') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (10, 'Record should go to rtest_t5')" +== 160 +-- truncate_limit: 100 +insert into rtest_t9 values (15, 'Record should go to rtest_t5') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (15, 'Record should go to rtest_t5')" +== 161 +-- truncate_limit: 100 +insert into rtest_t9 values (19, 'Record should go to rtest_t5 and t7') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (19, 'Record should go to rtest_t5 and t7')" +== 162 +-- truncate_limit: 100 +insert into rtest_t9 values (20, 'Record should go to rtest_t4 and t6') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (20, 'Record should go to rtest_t4 and t6')" +== 163 +-- truncate_limit: 100 +insert into rtest_t9 values (26, 'Record should go to rtest_t4 and t8') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (26, 'Record should go to rtest_t4 and t8')" +== 164 +-- truncate_limit: 100 +insert into rtest_t9 values (28, 'Record should go to rtest_t4 and t8') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (28, 'Record should go to rtest_t4 and t8')" +== 165 +-- truncate_limit: 100 +insert into rtest_t9 values (30, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (30, 'Record should go to rtest_t4')" +== 166 +-- truncate_limit: 100 +insert into rtest_t9 values (40, 'Record should go to rtest_t4') +-- +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t9 VALUES (40, 'Record should go to rtest_t4')" +== 167 +-- truncate_limit: 100 +insert into rtest_t4 select * from rtest_t9 where a < 20 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=Select +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 SELECT * FROM rtest_t9 WHERE a < 20" +== 168 +-- truncate_limit: 100 +select * from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t4" +== 169 +-- truncate_limit: 100 +select * from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t5" +== 170 +-- truncate_limit: 100 +select * from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t6" +== 171 +-- truncate_limit: 100 +select * from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t7" +== 172 +-- truncate_limit: 100 +select * from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t8" +== 173 +-- truncate_limit: 100 +insert into rtest_t4 select * from rtest_t9 where b ~ 'and t8' +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=Select +FILTER: schema="" table="" column="b" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 SELECT * FROM rtest_t9 WHERE b ~ 'and t8'" +== 174 +-- truncate_limit: 100 +select * from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t4" +== 175 +-- truncate_limit: 100 +select * from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t5" +== 176 +-- truncate_limit: 100 +select * from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t6" +== 177 +-- truncate_limit: 100 +select * from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t7" +== 178 +-- truncate_limit: 100 +select * from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t8" +== 179 +-- truncate_limit: 100 +insert into rtest_t4 select a + 1, b from rtest_t9 where a in (20, 30, 40) +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=DML +TABLE: name="rtest_t9" schema="" table="rtest_t9" ctx=Select +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_t4 SELECT a + 1, b FROM rtest_t9 WHERE a IN (20, 30, 40)" +== 180 +-- truncate_limit: 100 +select * from rtest_t4 +-- +TABLE: name="rtest_t4" schema="" table="rtest_t4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t4" +== 181 +-- truncate_limit: 100 +select * from rtest_t5 +-- +TABLE: name="rtest_t5" schema="" table="rtest_t5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t5" +== 182 +-- truncate_limit: 100 +select * from rtest_t6 +-- +TABLE: name="rtest_t6" schema="" table="rtest_t6" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t6" +== 183 +-- truncate_limit: 100 +select * from rtest_t7 +-- +TABLE: name="rtest_t7" schema="" table="rtest_t7" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t7" +== 184 +-- truncate_limit: 100 +select * from rtest_t8 +-- +TABLE: name="rtest_t8" schema="" table="rtest_t8" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_t8" +== 185 +-- truncate_limit: 100 +|-- +-- Check that the ordering of rules fired is correct +|-- +insert into rtest_order1 values (1) +-- +TABLE: name="rtest_order1" schema="" table="rtest_order1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_order1 VALUES (1)" +== 186 +-- truncate_limit: 100 +select * from rtest_order2 +-- +TABLE: name="rtest_order2" schema="" table="rtest_order2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_order2" +== 187 +-- truncate_limit: 100 +|-- +-- Check if instead nothing w/without qualification works +|-- +insert into rtest_nothn1 values (1, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (1, 'want this')" +== 188 +-- truncate_limit: 100 +insert into rtest_nothn1 values (2, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (2, 'want this')" +== 189 +-- truncate_limit: 100 +insert into rtest_nothn1 values (10, 'don''t want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (10, 'don''t want this')" +== 190 +-- truncate_limit: 100 +insert into rtest_nothn1 values (19, 'don''t want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (19, 'don''t want this')" +== 191 +-- truncate_limit: 100 +insert into rtest_nothn1 values (20, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (20, 'want this')" +== 192 +-- truncate_limit: 100 +insert into rtest_nothn1 values (29, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (29, 'want this')" +== 193 +-- truncate_limit: 100 +insert into rtest_nothn1 values (30, 'don''t want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (30, 'don''t want this')" +== 194 +-- truncate_limit: 100 +insert into rtest_nothn1 values (39, 'don''t want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (39, 'don''t want this')" +== 195 +-- truncate_limit: 100 +insert into rtest_nothn1 values (40, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (40, 'want this')" +== 196 +-- truncate_limit: 100 +insert into rtest_nothn1 values (50, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (50, 'want this')" +== 197 +-- truncate_limit: 100 +insert into rtest_nothn1 values (60, 'want this') +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 VALUES (60, 'want this')" +== 198 +-- truncate_limit: 100 +select * from rtest_nothn1 +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_nothn1" +== 199 +-- truncate_limit: 100 +insert into rtest_nothn2 values (10, 'too small') +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn2 VALUES (10, 'too small')" +== 200 +-- truncate_limit: 100 +insert into rtest_nothn2 values (50, 'too small') +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn2 VALUES (50, 'too small')" +== 201 +-- truncate_limit: 100 +insert into rtest_nothn2 values (100, 'OK') +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn2 VALUES (100, 'OK')" +== 202 +-- truncate_limit: 100 +insert into rtest_nothn2 values (200, 'OK') +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn2 VALUES (200, 'OK')" +== 203 +-- truncate_limit: 100 +select * from rtest_nothn2 +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_nothn2" +== 204 +-- truncate_limit: 100 +select * from rtest_nothn3 +-- +TABLE: name="rtest_nothn3" schema="" table="rtest_nothn3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_nothn3" +== 205 +-- truncate_limit: 100 +delete from rtest_nothn1 +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_nothn1" +== 206 +-- truncate_limit: 100 +delete from rtest_nothn2 +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_nothn2" +== 207 +-- truncate_limit: 100 +delete from rtest_nothn3 +-- +TABLE: name="rtest_nothn3" schema="" table="rtest_nothn3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_nothn3" +== 208 +-- truncate_limit: 100 +insert into rtest_nothn4 values (1, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (1, 'want this')" +== 209 +-- truncate_limit: 100 +insert into rtest_nothn4 values (2, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (2, 'want this')" +== 210 +-- truncate_limit: 100 +insert into rtest_nothn4 values (10, 'don''t want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (10, 'don''t want this')" +== 211 +-- truncate_limit: 100 +insert into rtest_nothn4 values (19, 'don''t want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (19, 'don''t want this')" +== 212 +-- truncate_limit: 100 +insert into rtest_nothn4 values (20, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (20, 'want this')" +== 213 +-- truncate_limit: 100 +insert into rtest_nothn4 values (29, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (29, 'want this')" +== 214 +-- truncate_limit: 100 +insert into rtest_nothn4 values (30, 'don''t want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (30, 'don''t want this')" +== 215 +-- truncate_limit: 100 +insert into rtest_nothn4 values (39, 'don''t want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (39, 'don''t want this')" +== 216 +-- truncate_limit: 100 +insert into rtest_nothn4 values (40, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (40, 'want this')" +== 217 +-- truncate_limit: 100 +insert into rtest_nothn4 values (50, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (50, 'want this')" +== 218 +-- truncate_limit: 100 +insert into rtest_nothn4 values (60, 'want this') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (60, 'want this')" +== 219 +-- truncate_limit: 100 +insert into rtest_nothn1 select * from rtest_nothn4 +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=DML +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn1 SELECT * FROM rtest_nothn4" +== 220 +-- truncate_limit: 100 +select * from rtest_nothn1 +-- +TABLE: name="rtest_nothn1" schema="" table="rtest_nothn1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_nothn1" +== 221 +-- truncate_limit: 100 +delete from rtest_nothn4 +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_nothn4" +== 222 +-- truncate_limit: 100 +insert into rtest_nothn4 values (10, 'too small') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (10, 'too small')" +== 223 +-- truncate_limit: 100 +insert into rtest_nothn4 values (50, 'too small') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (50, 'too small')" +== 224 +-- truncate_limit: 100 +insert into rtest_nothn4 values (100, 'OK') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (100, 'OK')" +== 225 +-- truncate_limit: 100 +insert into rtest_nothn4 values (200, 'OK') +-- +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn4 VALUES (200, 'OK')" +== 226 +-- truncate_limit: 100 +insert into rtest_nothn2 select * from rtest_nothn4 +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=DML +TABLE: name="rtest_nothn4" schema="" table="rtest_nothn4" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_nothn2 SELECT * FROM rtest_nothn4" +== 227 +-- truncate_limit: 100 +select * from rtest_nothn2 +-- +TABLE: name="rtest_nothn2" schema="" table="rtest_nothn2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_nothn2" +== 228 +-- truncate_limit: 100 +select * from rtest_nothn3 +-- +TABLE: name="rtest_nothn3" schema="" table="rtest_nothn3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_nothn3" +== 229 +-- truncate_limit: 100 +create table rtest_view1 (a int4, b text, v bool) +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_view1 (a int4, b text, v bool)" +== 230 +-- truncate_limit: 100 +create table rtest_view2 (a int4) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_view2 (a int4)" +== 231 +-- truncate_limit: 100 +create table rtest_view3 (a int4, b text) +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_view3 (a int4, b text)" +== 232 +-- truncate_limit: 100 +create table rtest_view4 (a int4, b text, c int4) +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_view4 (a int4, b text, c int4)" +== 233 +-- truncate_limit: 100 +create view rtest_vview1 as select a, b from rtest_view1 X + where 0 < (select count(*) from rtest_view2 Y where Y.a = X.a) +-- +TABLE: name="rtest_vview1" schema="" table="rtest_vview1" ctx=DDL +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=Select +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=Select +ALIAS: "x"="rtest_view1" +ALIAS: "y"="rtest_view2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="y" column="a" +FILTER: schema="" table="x" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rtest_vview1 AS SELECT a, b FROM rtest_view1 x WHERE 0 < (SELECT count(*) FROM rtest_..." +== 234 +-- truncate_limit: 100 +create view rtest_vview2 as select a, b from rtest_view1 where v +-- +TABLE: name="rtest_vview2" schema="" table="rtest_vview2" ctx=DDL +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=Select +FILTER: schema="" table="" column="v" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rtest_vview2 AS SELECT a, b FROM rtest_view1 WHERE v" +== 235 +-- truncate_limit: 100 +create view rtest_vview3 as select a, b from rtest_vview2 X + where 0 < (select count(*) from rtest_view2 Y where Y.a = X.a) +-- +TABLE: name="rtest_vview3" schema="" table="rtest_vview3" ctx=DDL +TABLE: name="rtest_vview2" schema="" table="rtest_vview2" ctx=Select +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=Select +ALIAS: "x"="rtest_vview2" +ALIAS: "y"="rtest_view2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="y" column="a" +FILTER: schema="" table="x" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rtest_vview3 AS SELECT a, b FROM rtest_vview2 x WHERE 0 < (SELECT count(*) FROM rtest..." +== 236 +-- truncate_limit: 100 +create view rtest_vview4 as select X.a, X.b, count(Y.a) as refcount + from rtest_view1 X, rtest_view2 Y + where X.a = Y.a + group by X.a, X.b +-- +TABLE: name="rtest_vview4" schema="" table="rtest_vview4" ctx=DDL +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=Select +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=Select +ALIAS: "x"="rtest_view1" +ALIAS: "y"="rtest_view2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rtest_vview4 AS SELECT x.a, x.b, count(y.a) AS refcount FROM rtest_view1 x, rtest_vie..." +== 237 +-- truncate_limit: 100 +create function rtest_viewfunc1(int4) returns int4 as + 'select count(*)::int4 from rtest_view2 where a = $1' + language sql +-- +FUNCTION: name="rtest_viewfunc1" function="rtest_viewfunc1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rtest_viewfunc1(int4) RETURNS int4 AS $$select count(*)::int4 from rtest_view2 wh..." +== 238 +-- truncate_limit: 100 +create view rtest_vview5 as select a, b, rtest_viewfunc1(a) as refcount + from rtest_view1 +-- +TABLE: name="rtest_vview5" schema="" table="rtest_vview5" ctx=DDL +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=Select +FUNCTION: name="rtest_viewfunc1" function="rtest_viewfunc1" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rtest_vview5 AS SELECT a, b, rtest_viewfunc1(a) AS refcount FROM rtest_view1" +== 239 +-- truncate_limit: 100 +insert into rtest_view1 values (1, 'item 1', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view1 VALUES (1, 'item 1', 't')" +== 240 +-- truncate_limit: 100 +insert into rtest_view1 values (2, 'item 2', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view1 VALUES (2, 'item 2', 't')" +== 241 +-- truncate_limit: 100 +insert into rtest_view1 values (3, 'item 3', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view1 VALUES (3, 'item 3', 't')" +== 242 +-- truncate_limit: 100 +insert into rtest_view1 values (4, 'item 4', 'f') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view1 VALUES (4, 'item 4', 'f')" +== 243 +-- truncate_limit: 100 +insert into rtest_view1 values (5, 'item 5', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view1 VALUES (5, 'item 5', 't')" +== 244 +-- truncate_limit: 100 +insert into rtest_view1 values (6, 'item 6', 'f') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view1 VALUES (6, 'item 6', 'f')" +== 245 +-- truncate_limit: 100 +insert into rtest_view1 values (7, 'item 7', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view1 VALUES (7, 'item 7', 't')" +== 246 +-- truncate_limit: 100 +insert into rtest_view1 values (8, 'item 8', 't') +-- +TABLE: name="rtest_view1" schema="" table="rtest_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view1 VALUES (8, 'item 8', 't')" +== 247 +-- truncate_limit: 100 +insert into rtest_view2 values (2) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view2 VALUES (2)" +== 248 +-- truncate_limit: 100 +insert into rtest_view2 values (2) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view2 VALUES (2)" +== 249 +-- truncate_limit: 100 +insert into rtest_view2 values (4) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view2 VALUES (4)" +== 250 +-- truncate_limit: 100 +insert into rtest_view2 values (5) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view2 VALUES (5)" +== 251 +-- truncate_limit: 100 +insert into rtest_view2 values (7) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view2 VALUES (7)" +== 252 +-- truncate_limit: 100 +insert into rtest_view2 values (7) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view2 VALUES (7)" +== 253 +-- truncate_limit: 100 +insert into rtest_view2 values (7) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view2 VALUES (7)" +== 254 +-- truncate_limit: 100 +insert into rtest_view2 values (7) +-- +TABLE: name="rtest_view2" schema="" table="rtest_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view2 VALUES (7)" +== 255 +-- truncate_limit: 100 +select * from rtest_vview1 +-- +TABLE: name="rtest_vview1" schema="" table="rtest_vview1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_vview1" +== 256 +-- truncate_limit: 100 +select * from rtest_vview2 +-- +TABLE: name="rtest_vview2" schema="" table="rtest_vview2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_vview2" +== 257 +-- truncate_limit: 100 +select * from rtest_vview3 +-- +TABLE: name="rtest_vview3" schema="" table="rtest_vview3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_vview3" +== 258 +-- truncate_limit: 100 +select * from rtest_vview4 order by a, b +-- +TABLE: name="rtest_vview4" schema="" table="rtest_vview4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_vview4 ORDER BY a, b" +== 259 +-- truncate_limit: 100 +select * from rtest_vview5 +-- +TABLE: name="rtest_vview5" schema="" table="rtest_vview5" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_vview5" +== 260 +-- truncate_limit: 100 +insert into rtest_view3 select * from rtest_vview1 where a < 7 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +TABLE: name="rtest_vview1" schema="" table="rtest_vview1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view3 SELECT * FROM rtest_vview1 WHERE a < 7" +== 261 +-- truncate_limit: 100 +select * from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_view3" +== 262 +-- truncate_limit: 100 +delete from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_view3" +== 263 +-- truncate_limit: 100 +insert into rtest_view3 select * from rtest_vview2 where a != 5 and b !~ '2' +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +TABLE: name="rtest_vview2" schema="" table="rtest_vview2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view3 SELECT * FROM rtest_vview2 WHERE a <> 5 AND b !~ '2'" +== 264 +-- truncate_limit: 100 +select * from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_view3" +== 265 +-- truncate_limit: 100 +delete from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_view3" +== 266 +-- truncate_limit: 100 +insert into rtest_view3 select * from rtest_vview3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +TABLE: name="rtest_vview3" schema="" table="rtest_vview3" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view3 SELECT * FROM rtest_vview3" +== 267 +-- truncate_limit: 100 +select * from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_view3" +== 268 +-- truncate_limit: 100 +delete from rtest_view3 +-- +TABLE: name="rtest_view3" schema="" table="rtest_view3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_view3" +== 269 +-- truncate_limit: 100 +insert into rtest_view4 select * from rtest_vview4 where 3 > refcount +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DML +TABLE: name="rtest_vview4" schema="" table="rtest_vview4" ctx=Select +FILTER: schema="" table="" column="refcount" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view4 SELECT * FROM rtest_vview4 WHERE 3 > refcount" +== 270 +-- truncate_limit: 100 +select * from rtest_view4 order by a, b +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_view4 ORDER BY a, b" +== 271 +-- truncate_limit: 100 +delete from rtest_view4 +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_view4" +== 272 +-- truncate_limit: 100 +insert into rtest_view4 select * from rtest_vview5 where a > 2 and refcount = 0 +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DML +TABLE: name="rtest_vview5" schema="" table="rtest_vview5" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="refcount" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_view4 SELECT * FROM rtest_vview5 WHERE a > 2 AND refcount = 0" +== 273 +-- truncate_limit: 100 +select * from rtest_view4 +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_view4" +== 274 +-- truncate_limit: 100 +delete from rtest_view4 +-- +TABLE: name="rtest_view4" schema="" table="rtest_view4" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rtest_view4" +== 275 +-- truncate_limit: 100 +|-- +-- Test for computations in views +|-- +create table rtest_comp ( + part text, + unit char(4), + size float +) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_comp (part text, unit char(4), size double precision)" +== 276 +-- truncate_limit: 100 +create table rtest_unitfact ( + unit char(4), + factor float +) +-- +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rtest_unitfact (unit char(4), factor double precision)" +== 277 +-- truncate_limit: 100 +create view rtest_vcomp as + select X.part, (X.size * Y.factor) as size_in_cm + from rtest_comp X, rtest_unitfact Y + where X.unit = Y.unit +-- +TABLE: name="rtest_vcomp" schema="" table="rtest_vcomp" ctx=DDL +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=Select +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=Select +ALIAS: "x"="rtest_comp" +ALIAS: "y"="rtest_unitfact" +FILTER: schema="" table="x" column="unit" +FILTER: schema="" table="y" column="unit" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rtest_vcomp AS SELECT x.part, x.size * y.factor AS size_in_cm FROM rtest_comp x, rtes..." +== 278 +-- truncate_limit: 100 +insert into rtest_unitfact values ('m', 100.0) +-- +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_unitfact VALUES ('m', 100.0)" +== 279 +-- truncate_limit: 100 +insert into rtest_unitfact values ('cm', 1.0) +-- +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_unitfact VALUES ('cm', 1.0)" +== 280 +-- truncate_limit: 100 +insert into rtest_unitfact values ('inch', 2.54) +-- +TABLE: name="rtest_unitfact" schema="" table="rtest_unitfact" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_unitfact VALUES ('inch', 2.54)" +== 281 +-- truncate_limit: 100 +insert into rtest_comp values ('p1', 'm', 5.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_comp VALUES ('p1', 'm', 5.0)" +== 282 +-- truncate_limit: 100 +insert into rtest_comp values ('p2', 'm', 3.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_comp VALUES ('p2', 'm', 3.0)" +== 283 +-- truncate_limit: 100 +insert into rtest_comp values ('p3', 'cm', 5.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_comp VALUES ('p3', 'cm', 5.0)" +== 284 +-- truncate_limit: 100 +insert into rtest_comp values ('p4', 'cm', 15.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_comp VALUES ('p4', 'cm', 15.0)" +== 285 +-- truncate_limit: 100 +insert into rtest_comp values ('p5', 'inch', 7.0) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_comp VALUES ('p5', 'inch', 7.0)" +== 286 +-- truncate_limit: 100 +insert into rtest_comp values ('p6', 'inch', 4.4) +-- +TABLE: name="rtest_comp" schema="" table="rtest_comp" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rtest_comp VALUES ('p6', 'inch', 4.4)" +== 287 +-- truncate_limit: 100 +select * from rtest_vcomp order by part +-- +TABLE: name="rtest_vcomp" schema="" table="rtest_vcomp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_vcomp ORDER BY part" +== 288 +-- truncate_limit: 100 +select * from rtest_vcomp where size_in_cm > 10.0 order by size_in_cm using > +-- +TABLE: name="rtest_vcomp" schema="" table="rtest_vcomp" ctx=Select +FILTER: schema="" table="" column="size_in_cm" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rtest_vcomp WHERE size_in_cm > 10.0 ORDER BY size_in_cm USING >" +== 289 +-- truncate_limit: 100 +|-- +-- In addition run the (slightly modified) queries from the +-- programmers manual section on the rule system. +|-- +CREATE TABLE shoe_data ( + shoename char(10), -- primary key + sh_avail integer, -- available # of pairs + slcolor char(10), -- preferred shoelace color + slminlen float, -- minimum shoelace length + slmaxlen float, -- maximum shoelace length + slunit char(8) -- length unit +) +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE shoe_data (shoename char(10), sh_avail int, slcolor char(10), slminlen double precis..." +== 290 +-- truncate_limit: 100 +CREATE TABLE shoelace_data ( + sl_name char(10), -- primary key + sl_avail integer, -- available # of pairs + sl_color char(10), -- shoelace color + sl_len float, -- shoelace length + sl_unit char(8) -- length unit +) +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE shoelace_data (sl_name char(10), sl_avail int, sl_color char(10), sl_len double prec..." +== 291 +-- truncate_limit: 100 +CREATE TABLE unit ( + un_name char(8), -- the primary key + un_fact float -- factor to transform to cm +) +-- +TABLE: name="unit" schema="" table="unit" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unit (un_name char(8), un_fact double precision)" +== 292 +-- truncate_limit: 100 +CREATE VIEW shoe AS + SELECT sh.shoename, + sh.sh_avail, + sh.slcolor, + sh.slminlen, + sh.slminlen * un.un_fact AS slminlen_cm, + sh.slmaxlen, + sh.slmaxlen * un.un_fact AS slmaxlen_cm, + sh.slunit + FROM shoe_data sh, unit un + WHERE sh.slunit = un.un_name +-- +TABLE: name="shoe" schema="" table="shoe" ctx=DDL +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=Select +TABLE: name="unit" schema="" table="unit" ctx=Select +ALIAS: "sh"="shoe_data" +ALIAS: "un"="unit" +FILTER: schema="" table="sh" column="slunit" +FILTER: schema="" table="un" column="un_name" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW shoe AS SELECT sh.shoename, sh.sh_avail, sh.slcolor, sh.slminlen, sh.slminlen * un.un..." +== 293 +-- truncate_limit: 100 +CREATE VIEW shoelace AS + SELECT s.sl_name, + s.sl_avail, + s.sl_color, + s.sl_len, + s.sl_unit, + s.sl_len * u.un_fact AS sl_len_cm + FROM shoelace_data s, unit u + WHERE s.sl_unit = u.un_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DDL +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=Select +TABLE: name="unit" schema="" table="unit" ctx=Select +ALIAS: "s"="shoelace_data" +ALIAS: "u"="unit" +FILTER: schema="" table="s" column="sl_unit" +FILTER: schema="" table="u" column="un_name" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW shoelace AS SELECT s.sl_name, s.sl_avail, s.sl_color, s.sl_len, s.sl_unit, s.sl_len *..." +== 294 +-- truncate_limit: 100 +CREATE VIEW shoe_ready AS + SELECT rsh.shoename, + rsh.sh_avail, + rsl.sl_name, + rsl.sl_avail, + int4smaller(rsh.sh_avail, rsl.sl_avail) AS total_avail + FROM shoe rsh, shoelace rsl + WHERE rsl.sl_color = rsh.slcolor + AND rsl.sl_len_cm >= rsh.slminlen_cm + AND rsl.sl_len_cm <= rsh.slmaxlen_cm +-- +TABLE: name="shoe_ready" schema="" table="shoe_ready" ctx=DDL +TABLE: name="shoe" schema="" table="shoe" ctx=Select +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +ALIAS: "rsh"="shoe" +ALIAS: "rsl"="shoelace" +FUNCTION: name="int4smaller" function="int4smaller" schema="" ctx=Call +FILTER: schema="" table="rsl" column="sl_color" +FILTER: schema="" table="rsh" column="slcolor" +FILTER: schema="" table="rsl" column="sl_len_cm" +FILTER: schema="" table="rsh" column="slminlen_cm" +FILTER: schema="" table="rsl" column="sl_len_cm" +FILTER: schema="" table="rsh" column="slmaxlen_cm" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW shoe_ready AS SELECT rsh.shoename, rsh.sh_avail, rsl.sl_name, rsl.sl_avail, int4small..." +== 295 +-- truncate_limit: 100 +INSERT INTO unit VALUES ('cm', 1.0) +-- +TABLE: name="unit" schema="" table="unit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unit VALUES ('cm', 1.0)" +== 296 +-- truncate_limit: 100 +INSERT INTO unit VALUES ('m', 100.0) +-- +TABLE: name="unit" schema="" table="unit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unit VALUES ('m', 100.0)" +== 297 +-- truncate_limit: 100 +INSERT INTO unit VALUES ('inch', 2.54) +-- +TABLE: name="unit" schema="" table="unit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO unit VALUES ('inch', 2.54)" +== 298 +-- truncate_limit: 100 +INSERT INTO shoe_data VALUES ('sh1', 2, 'black', 70.0, 90.0, 'cm') +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoe_data VALUES ('sh1', 2, 'black', 70.0, 90.0, 'cm')" +== 299 +-- truncate_limit: 100 +INSERT INTO shoe_data VALUES ('sh2', 0, 'black', 30.0, 40.0, 'inch') +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoe_data VALUES ('sh2', 0, 'black', 30.0, 40.0, 'inch')" +== 300 +-- truncate_limit: 100 +INSERT INTO shoe_data VALUES ('sh3', 4, 'brown', 50.0, 65.0, 'cm') +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoe_data VALUES ('sh3', 4, 'brown', 50.0, 65.0, 'cm')" +== 301 +-- truncate_limit: 100 +INSERT INTO shoe_data VALUES ('sh4', 3, 'brown', 40.0, 50.0, 'inch') +-- +TABLE: name="shoe_data" schema="" table="shoe_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoe_data VALUES ('sh4', 3, 'brown', 40.0, 50.0, 'inch')" +== 302 +-- truncate_limit: 100 +INSERT INTO shoelace_data VALUES ('sl1', 5, 'black', 80.0, 'cm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_data VALUES ('sl1', 5, 'black', 80.0, 'cm')" +== 303 +-- truncate_limit: 100 +INSERT INTO shoelace_data VALUES ('sl2', 6, 'black', 100.0, 'cm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_data VALUES ('sl2', 6, 'black', 100.0, 'cm')" +== 304 +-- truncate_limit: 100 +INSERT INTO shoelace_data VALUES ('sl3', 0, 'black', 35.0 , 'inch') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_data VALUES ('sl3', 0, 'black', 35.0, 'inch')" +== 305 +-- truncate_limit: 100 +INSERT INTO shoelace_data VALUES ('sl4', 8, 'black', 40.0 , 'inch') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_data VALUES ('sl4', 8, 'black', 40.0, 'inch')" +== 306 +-- truncate_limit: 100 +INSERT INTO shoelace_data VALUES ('sl5', 4, 'brown', 1.0 , 'm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_data VALUES ('sl5', 4, 'brown', 1.0, 'm')" +== 307 +-- truncate_limit: 100 +INSERT INTO shoelace_data VALUES ('sl6', 0, 'brown', 0.9 , 'm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_data VALUES ('sl6', 0, 'brown', 0.9, 'm')" +== 308 +-- truncate_limit: 100 +INSERT INTO shoelace_data VALUES ('sl7', 7, 'brown', 60 , 'cm') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_data VALUES ('sl7', 7, 'brown', 60, 'cm')" +== 309 +-- truncate_limit: 100 +INSERT INTO shoelace_data VALUES ('sl8', 1, 'brown', 40 , 'inch') +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_data VALUES ('sl8', 1, 'brown', 40, 'inch')" +== 310 +-- truncate_limit: 100 +-- SELECTs in doc +SELECT * FROM shoelace ORDER BY sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoelace ORDER BY sl_name" +== 311 +-- truncate_limit: 100 +SELECT * FROM shoe_ready WHERE total_avail >= 2 ORDER BY 1 +-- +TABLE: name="shoe_ready" schema="" table="shoe_ready" ctx=Select +FILTER: schema="" table="" column="total_avail" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoe_ready WHERE total_avail >= 2 ORDER BY 1" +== 312 +-- truncate_limit: 100 +CREATE TABLE shoelace_log ( + sl_name char(10), -- shoelace changed + sl_avail integer, -- new available value + log_who name, -- who did it + log_when timestamp -- when + ) +-- +TABLE: name="shoelace_log" schema="" table="shoelace_log" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE shoelace_log (sl_name char(10), sl_avail int, log_who name, log_when timestamp)" +== 313 +-- truncate_limit: 100 +-- Want "log_who" to be CURRENT_USER, +-- but that is non-portable for the regression test +-- - thomas 1999-02-21 + + CREATE RULE log_shoelace AS ON UPDATE TO shoelace_data + WHERE NEW.sl_avail != OLD.sl_avail + DO INSERT INTO shoelace_log VALUES ( + NEW.sl_name, + NEW.sl_avail, + 'Al Bundy', + 'epoch' + ) +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE log_shoelace AS ON UPDATE TO shoelace_data WHERE ... DO INSERT INTO shoelace_log VALU..." +== 314 +-- truncate_limit: 100 +UPDATE shoelace_data SET sl_avail = 6 WHERE sl_name = 'sl7' +-- +TABLE: name="shoelace_data" schema="" table="shoelace_data" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE shoelace_data SET sl_avail = 6 WHERE sl_name = 'sl7'" +== 315 +-- truncate_limit: 100 +SELECT * FROM shoelace_log +-- +TABLE: name="shoelace_log" schema="" table="shoelace_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoelace_log" +== 316 +-- truncate_limit: 100 +CREATE RULE shoelace_ins AS ON INSERT TO shoelace + DO INSTEAD + INSERT INTO shoelace_data VALUES ( + NEW.sl_name, + NEW.sl_avail, + NEW.sl_color, + NEW.sl_len, + NEW.sl_unit) +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE shoelace_ins AS ON INSERT TO shoelace DO INSTEAD INSERT INTO shoelace_data VALUES (ne..." +== 317 +-- truncate_limit: 100 +CREATE RULE shoelace_upd AS ON UPDATE TO shoelace + DO INSTEAD + UPDATE shoelace_data SET + sl_name = NEW.sl_name, + sl_avail = NEW.sl_avail, + sl_color = NEW.sl_color, + sl_len = NEW.sl_len, + sl_unit = NEW.sl_unit + WHERE sl_name = OLD.sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE shoelace_upd AS ON UPDATE TO shoelace DO INSTEAD UPDATE shoelace_data SET sl_name = n..." +== 318 +-- truncate_limit: 100 +CREATE RULE shoelace_del AS ON DELETE TO shoelace + DO INSTEAD + DELETE FROM shoelace_data + WHERE sl_name = OLD.sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE shoelace_del AS ON DELETE TO shoelace DO INSTEAD DELETE FROM shoelace_data WHERE sl_n..." +== 319 +-- truncate_limit: 100 +CREATE TABLE shoelace_arrive ( + arr_name char(10), + arr_quant integer + ) +-- +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE shoelace_arrive (arr_name char(10), arr_quant int)" +== 320 +-- truncate_limit: 100 +CREATE TABLE shoelace_ok ( + ok_name char(10), + ok_quant integer + ) +-- +TABLE: name="shoelace_ok" schema="" table="shoelace_ok" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE shoelace_ok (ok_name char(10), ok_quant int)" +== 321 +-- truncate_limit: 100 +CREATE RULE shoelace_ok_ins AS ON INSERT TO shoelace_ok + DO INSTEAD + UPDATE shoelace SET + sl_avail = sl_avail + NEW.ok_quant + WHERE sl_name = NEW.ok_name +-- +TABLE: name="shoelace_ok" schema="" table="shoelace_ok" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE shoelace_ok_ins AS ON INSERT TO shoelace_ok DO INSTEAD UPDATE shoelace SET sl_avail =..." +== 322 +-- truncate_limit: 100 +INSERT INTO shoelace_arrive VALUES ('sl3', 10) +-- +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_arrive VALUES ('sl3', 10)" +== 323 +-- truncate_limit: 100 +INSERT INTO shoelace_arrive VALUES ('sl6', 20) +-- +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_arrive VALUES ('sl6', 20)" +== 324 +-- truncate_limit: 100 +INSERT INTO shoelace_arrive VALUES ('sl8', 20) +-- +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_arrive VALUES ('sl8', 20)" +== 325 +-- truncate_limit: 100 +SELECT * FROM shoelace ORDER BY sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoelace ORDER BY sl_name" +== 326 +-- truncate_limit: 100 +insert into shoelace_ok select * from shoelace_arrive +-- +TABLE: name="shoelace_ok" schema="" table="shoelace_ok" ctx=DML +TABLE: name="shoelace_arrive" schema="" table="shoelace_arrive" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace_ok SELECT * FROM shoelace_arrive" +== 327 +-- truncate_limit: 100 +SELECT * FROM shoelace ORDER BY sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoelace ORDER BY sl_name" +== 328 +-- truncate_limit: 100 +SELECT * FROM shoelace_log ORDER BY sl_name +-- +TABLE: name="shoelace_log" schema="" table="shoelace_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoelace_log ORDER BY sl_name" +== 329 +-- truncate_limit: 100 +CREATE VIEW shoelace_obsolete AS + SELECT * FROM shoelace WHERE NOT EXISTS + (SELECT shoename FROM shoe WHERE slcolor = sl_color) +-- +TABLE: name="shoelace_obsolete" schema="" table="shoelace_obsolete" ctx=DDL +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +TABLE: name="shoe" schema="" table="shoe" ctx=Select +FILTER: schema="" table="" column="slcolor" +FILTER: schema="" table="" column="sl_color" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW shoelace_obsolete AS SELECT * FROM shoelace WHERE NOT EXISTS (SELECT shoename FROM sh..." +== 330 +-- truncate_limit: 100 +CREATE VIEW shoelace_candelete AS + SELECT * FROM shoelace_obsolete WHERE sl_avail = 0 +-- +TABLE: name="shoelace_candelete" schema="" table="shoelace_candelete" ctx=DDL +TABLE: name="shoelace_obsolete" schema="" table="shoelace_obsolete" ctx=Select +FILTER: schema="" table="" column="sl_avail" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW shoelace_candelete AS SELECT * FROM shoelace_obsolete WHERE sl_avail = 0" +== 331 +-- truncate_limit: 100 +insert into shoelace values ('sl9', 0, 'pink', 35.0, 'inch', 0.0) +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace VALUES ('sl9', 0, 'pink', 35.0, 'inch', 0.0)" +== 332 +-- truncate_limit: 100 +insert into shoelace values ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0) +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace VALUES ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0)" +== 333 +-- truncate_limit: 100 +-- Unsupported (even though a similar updatable view construct is) +insert into shoelace values ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0) + on conflict do nothing +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace VALUES ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0) ON CONFLICT DO NOTHING" +== 334 +-- truncate_limit: 100 +SELECT * FROM shoelace_obsolete ORDER BY sl_len_cm +-- +TABLE: name="shoelace_obsolete" schema="" table="shoelace_obsolete" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoelace_obsolete ORDER BY sl_len_cm" +== 335 +-- truncate_limit: 100 +SELECT * FROM shoelace_candelete +-- +TABLE: name="shoelace_candelete" schema="" table="shoelace_candelete" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoelace_candelete" +== 336 +-- truncate_limit: 100 +DELETE FROM shoelace WHERE EXISTS + (SELECT * FROM shoelace_candelete + WHERE sl_name = shoelace.sl_name) +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +TABLE: name="shoelace_candelete" schema="" table="shoelace_candelete" ctx=Select +FILTER: schema="" table="" column="sl_name" +FILTER: schema="" table="shoelace" column="sl_name" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM shoelace WHERE EXISTS (SELECT * FROM shoelace_candelete WHERE ...)" +== 337 +-- truncate_limit: 100 +SELECT * FROM shoelace ORDER BY sl_name +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoelace ORDER BY sl_name" +== 338 +-- truncate_limit: 100 +SELECT * FROM shoe ORDER BY shoename +-- +TABLE: name="shoe" schema="" table="shoe" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shoe ORDER BY shoename" +== 339 +-- truncate_limit: 100 +SELECT count(*) FROM shoe +-- +TABLE: name="shoe" schema="" table="shoe" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM shoe" +== 340 +-- truncate_limit: 100 +|-- +-- Simple test of qualified ON INSERT ... this did not work in 7.0 ... +|-- +create table rules_foo (f1 int) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_foo (f1 int)" +== 341 +-- truncate_limit: 100 +create table rules_foo2 (f1 int) +-- +TABLE: name="rules_foo2" schema="" table="rules_foo2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_foo2 (f1 int)" +== 342 +-- truncate_limit: 100 +create rule rules_foorule as on insert to rules_foo where f1 < 100 +do instead nothing +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rules_foorule AS ON INSERT TO rules_foo WHERE f1 < 100 DO INSTEAD NOTHING" +== 343 +-- truncate_limit: 100 +insert into rules_foo values(1) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rules_foo VALUES (1)" +== 344 +-- truncate_limit: 100 +insert into rules_foo values(1001) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rules_foo VALUES (1001)" +== 345 +-- truncate_limit: 100 +select * from rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rules_foo" +== 346 +-- truncate_limit: 100 +drop rule rules_foorule on rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE rules_foorule ON rules_foo" +== 347 +-- truncate_limit: 100 +-- this should fail because f1 is not exposed for unqualified reference: +create rule rules_foorule as on insert to rules_foo where f1 < 100 +do instead insert into rules_foo2 values (f1) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rules_foorule AS ON INSERT TO rules_foo WHERE ... DO INSTEAD INSERT INTO rules_foo2 V..." +== 348 +-- truncate_limit: 100 +-- this is the correct way: +create rule rules_foorule as on insert to rules_foo where f1 < 100 +do instead insert into rules_foo2 values (new.f1) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rules_foorule AS ON INSERT TO rules_foo WHERE ... DO INSTEAD INSERT INTO rules_foo2 V..." +== 349 +-- truncate_limit: 100 +insert into rules_foo values(2) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rules_foo VALUES (2)" +== 350 +-- truncate_limit: 100 +insert into rules_foo values(100) +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rules_foo VALUES (100)" +== 351 +-- truncate_limit: 100 +select * from rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rules_foo" +== 352 +-- truncate_limit: 100 +select * from rules_foo2 +-- +TABLE: name="rules_foo2" schema="" table="rules_foo2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rules_foo2" +== 353 +-- truncate_limit: 100 +drop rule rules_foorule on rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE rules_foorule ON rules_foo" +== 354 +-- truncate_limit: 100 +drop table rules_foo +-- +TABLE: name="rules_foo" schema="" table="rules_foo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rules_foo" +== 355 +-- truncate_limit: 100 +drop table rules_foo2 +-- +TABLE: name="rules_foo2" schema="" table="rules_foo2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rules_foo2" +== 356 +-- truncate_limit: 100 +|-- +-- Test rules containing INSERT ... SELECT, which is a very ugly special +-- case as of 7.1. Example is based on bug report from Joel Burton. +|-- +create table pparent (pid int, txt text) +-- +TABLE: name="pparent" schema="" table="pparent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pparent (pid int, txt text)" +== 357 +-- truncate_limit: 100 +insert into pparent values (1,'parent1') +-- +TABLE: name="pparent" schema="" table="pparent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pparent VALUES (1, 'parent1')" +== 358 +-- truncate_limit: 100 +insert into pparent values (2,'parent2') +-- +TABLE: name="pparent" schema="" table="pparent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pparent VALUES (2, 'parent2')" +== 359 +-- truncate_limit: 100 +create table cchild (pid int, descrip text) +-- +TABLE: name="cchild" schema="" table="cchild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cchild (pid int, descrip text)" +== 360 +-- truncate_limit: 100 +insert into cchild values (1,'descrip1') +-- +TABLE: name="cchild" schema="" table="cchild" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO cchild VALUES (1, 'descrip1')" +== 361 +-- truncate_limit: 100 +create view vview as + select pparent.pid, txt, descrip from + pparent left join cchild using (pid) +-- +TABLE: name="vview" schema="" table="vview" ctx=DDL +TABLE: name="pparent" schema="" table="pparent" ctx=Select +TABLE: name="cchild" schema="" table="cchild" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vview AS SELECT pparent.pid, txt, descrip FROM pparent LEFT JOIN cchild USING (pid)" +== 362 +-- truncate_limit: 100 +create rule rrule as + on update to vview do instead +( + insert into cchild (pid, descrip) + select old.pid, new.descrip where old.descrip isnull; + update cchild set descrip = new.descrip where cchild.pid = old.pid; +) +-- +TABLE: name="vview" schema="" table="vview" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rrule AS ON UPDATE TO vview DO INSTEAD (INSERT INTO cchild (pid, descrip) SELECT old...." +== 363 +-- truncate_limit: 100 +select * from vview +-- +TABLE: name="vview" schema="" table="vview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vview" +== 364 +-- truncate_limit: 100 +update vview set descrip='test1' where pid=1 +-- +TABLE: name="vview" schema="" table="vview" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE vview SET descrip = 'test1' WHERE pid = 1" +== 365 +-- truncate_limit: 100 +select * from vview +-- +TABLE: name="vview" schema="" table="vview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vview" +== 366 +-- truncate_limit: 100 +update vview set descrip='test2' where pid=2 +-- +TABLE: name="vview" schema="" table="vview" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE vview SET descrip = 'test2' WHERE pid = 2" +== 367 +-- truncate_limit: 100 +select * from vview +-- +TABLE: name="vview" schema="" table="vview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vview" +== 368 +-- truncate_limit: 100 +update vview set descrip='test3' where pid=3 +-- +TABLE: name="vview" schema="" table="vview" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE vview SET descrip = 'test3' WHERE pid = 3" +== 369 +-- truncate_limit: 100 +select * from vview +-- +TABLE: name="vview" schema="" table="vview" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vview" +== 370 +-- truncate_limit: 100 +select * from cchild +-- +TABLE: name="cchild" schema="" table="cchild" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM cchild" +== 371 +-- truncate_limit: 100 +drop rule rrule on vview +-- +TABLE: name="vview" schema="" table="vview" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE rrule ON vview" +== 372 +-- truncate_limit: 100 +drop view vview +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vview" +== 373 +-- truncate_limit: 100 +drop table pparent +-- +TABLE: name="pparent" schema="" table="pparent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pparent" +== 374 +-- truncate_limit: 100 +drop table cchild +-- +TABLE: name="cchild" schema="" table="cchild" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE cchild" +== 375 +-- truncate_limit: 100 +|-- +-- Check that ruleutils are working +|-- + +-- temporarily disable fancy output, so view changes create less diff noise + +SELECT viewname, definition FROM pg_views +WHERE schemaname = 'pg_catalog' +ORDER BY viewname +-- +TABLE: name="pg_views" schema="" table="pg_views" ctx=Select +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +TRUNCATED: "SELECT viewname, definition FROM pg_views WHERE schemaname = 'pg_catalog' ORDER BY viewname" +== 376 +-- truncate_limit: 100 +SELECT tablename, rulename, definition FROM pg_rules +WHERE schemaname = 'pg_catalog' +ORDER BY tablename, rulename +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="schemaname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_rules WHERE schemaname = 'pg_catalog' ORDER BY tablename, rulename" +== 377 +-- truncate_limit: 100 +-- restore normal output mode + +|-- +-- CREATE OR REPLACE RULE +|-- + +CREATE TABLE ruletest_tbl (a int, b int) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ruletest_tbl (a int, b int)" +== 378 +-- truncate_limit: 100 +CREATE TABLE ruletest_tbl2 (a int, b int) +-- +TABLE: name="ruletest_tbl2" schema="" table="ruletest_tbl2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ruletest_tbl2 (a int, b int)" +== 379 +-- truncate_limit: 100 +CREATE OR REPLACE RULE myrule AS ON INSERT TO ruletest_tbl + DO INSTEAD INSERT INTO ruletest_tbl2 VALUES (10, 10) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE myrule AS ON INSERT TO ruletest_tbl DO INSTEAD INSERT INTO ruletest_tbl2 V..." +== 380 +-- truncate_limit: 100 +INSERT INTO ruletest_tbl VALUES (99, 99) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ruletest_tbl VALUES (99, 99)" +== 381 +-- truncate_limit: 100 +CREATE OR REPLACE RULE myrule AS ON INSERT TO ruletest_tbl + DO INSTEAD INSERT INTO ruletest_tbl2 VALUES (1000, 1000) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE myrule AS ON INSERT TO ruletest_tbl DO INSTEAD INSERT INTO ruletest_tbl2 V..." +== 382 +-- truncate_limit: 100 +INSERT INTO ruletest_tbl VALUES (99, 99) +-- +TABLE: name="ruletest_tbl" schema="" table="ruletest_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ruletest_tbl VALUES (99, 99)" +== 383 +-- truncate_limit: 100 +SELECT * FROM ruletest_tbl2 +-- +TABLE: name="ruletest_tbl2" schema="" table="ruletest_tbl2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ruletest_tbl2" +== 384 +-- truncate_limit: 100 +-- Check that rewrite rules splitting one INSERT into multiple +-- conditional statements does not disable FK checking. +create table rule_and_refint_t1 ( + id1a integer, + id1b integer, + + primary key (id1a, id1b) +) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_and_refint_t1 (id1a int, id1b int, PRIMARY KEY (id1a, id1b))" +== 385 +-- truncate_limit: 100 +create table rule_and_refint_t2 ( + id2a integer, + id2c integer, + + primary key (id2a, id2c) +) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_and_refint_t2 (id2a int, id2c int, PRIMARY KEY (id2a, id2c))" +== 386 +-- truncate_limit: 100 +create table rule_and_refint_t3 ( + id3a integer, + id3b integer, + id3c integer, + data text, + + primary key (id3a, id3b, id3c), + + foreign key (id3a, id3b) references rule_and_refint_t1 (id1a, id1b), + foreign key (id3a, id3c) references rule_and_refint_t2 (id2a, id2c) +) +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_and_refint_t3 (id3a int, id3b int, id3c int, data text, PRIMARY KEY (id3a, id3b..." +== 387 +-- truncate_limit: 100 +insert into rule_and_refint_t1 values (1, 11) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t1 VALUES (1, 11)" +== 388 +-- truncate_limit: 100 +insert into rule_and_refint_t1 values (1, 12) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t1 VALUES (1, 12)" +== 389 +-- truncate_limit: 100 +insert into rule_and_refint_t1 values (2, 21) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t1 VALUES (2, 21)" +== 390 +-- truncate_limit: 100 +insert into rule_and_refint_t1 values (2, 22) +-- +TABLE: name="rule_and_refint_t1" schema="" table="rule_and_refint_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t1 VALUES (2, 22)" +== 391 +-- truncate_limit: 100 +insert into rule_and_refint_t2 values (1, 11) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t2 VALUES (1, 11)" +== 392 +-- truncate_limit: 100 +insert into rule_and_refint_t2 values (1, 12) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t2 VALUES (1, 12)" +== 393 +-- truncate_limit: 100 +insert into rule_and_refint_t2 values (2, 21) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t2 VALUES (2, 21)" +== 394 +-- truncate_limit: 100 +insert into rule_and_refint_t2 values (2, 22) +-- +TABLE: name="rule_and_refint_t2" schema="" table="rule_and_refint_t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t2 VALUES (2, 22)" +== 395 +-- truncate_limit: 100 +insert into rule_and_refint_t3 values (1, 11, 11, 'row1') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 11, 11, 'row1')" +== 396 +-- truncate_limit: 100 +insert into rule_and_refint_t3 values (1, 11, 12, 'row2') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 11, 12, 'row2')" +== 397 +-- truncate_limit: 100 +insert into rule_and_refint_t3 values (1, 12, 11, 'row3') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 12, 11, 'row3')" +== 398 +-- truncate_limit: 100 +insert into rule_and_refint_t3 values (1, 12, 12, 'row4') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 12, 12, 'row4')" +== 399 +-- truncate_limit: 100 +insert into rule_and_refint_t3 values (1, 11, 13, 'row5') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 11, 13, 'row5')" +== 400 +-- truncate_limit: 100 +insert into rule_and_refint_t3 values (1, 13, 11, 'row6') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 13, 11, 'row6')" +== 401 +-- truncate_limit: 100 +-- Ordinary table +insert into rule_and_refint_t3 values (1, 13, 11, 'row6') + on conflict do nothing +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 13, 11, 'row6') ON CONFLICT DO NOTHING" +== 402 +-- truncate_limit: 100 +-- rule not fired, so fk violation +insert into rule_and_refint_t3 values (1, 13, 11, 'row6') + on conflict (id3a, id3b, id3c) do update + set id3b = excluded.id3b +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (...) ON CONFLICT (id3a, id3b, id3c) DO UPDATE SET ... = ..." +== 403 +-- truncate_limit: 100 +-- rule fired, so unsupported +insert into shoelace values ('sl9', 0, 'pink', 35.0, 'inch', 0.0) + on conflict (sl_name) do update + set sl_avail = excluded.sl_avail +-- +TABLE: name="shoelace" schema="" table="shoelace" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shoelace VALUES (...) ON CONFLICT (sl_name) DO UPDATE SET sl_avail = excluded.sl_avail" +== 404 +-- truncate_limit: 100 +create rule rule_and_refint_t3_ins as on insert to rule_and_refint_t3 + where (exists (select 1 from rule_and_refint_t3 + where (((rule_and_refint_t3.id3a = new.id3a) + and (rule_and_refint_t3.id3b = new.id3b)) + and (rule_and_refint_t3.id3c = new.id3c)))) + do instead update rule_and_refint_t3 set data = new.data + where (((rule_and_refint_t3.id3a = new.id3a) + and (rule_and_refint_t3.id3b = new.id3b)) + and (rule_and_refint_t3.id3c = new.id3c)) +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rule_and_refint_t3_ins AS ON INSERT TO rule_and_refint_t3 WHERE ... DO INSTEAD UPDATE..." +== 405 +-- truncate_limit: 100 +insert into rule_and_refint_t3 values (1, 11, 13, 'row7') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 11, 13, 'row7')" +== 406 +-- truncate_limit: 100 +insert into rule_and_refint_t3 values (1, 13, 11, 'row8') +-- +TABLE: name="rule_and_refint_t3" schema="" table="rule_and_refint_t3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_and_refint_t3 VALUES (1, 13, 11, 'row8')" +== 407 +-- truncate_limit: 100 +|-- +-- disallow dropping a view's rule (bug #5072) +|-- + +create view rules_fooview as select 'rules_foo'::text +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rules_fooview AS SELECT 'rules_foo'::text" +== 408 +-- truncate_limit: 100 +drop rule "_RETURN" on rules_fooview +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE \"_RETURN\" ON rules_fooview" +== 409 +-- truncate_limit: 100 +drop view rules_fooview +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rules_fooview" +== 410 +-- truncate_limit: 100 +|-- +-- We used to allow converting a table to a view by creating a "_RETURN" +-- rule for it, but no more. +|-- + +create table rules_fooview (x int, y text) +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_fooview (x int, y text)" +== 411 +-- truncate_limit: 100 +create rule "_RETURN" as on select to rules_fooview do instead + select 1 as x, 'aaa'::text as y +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE \"_RETURN\" AS ON SELECT TO rules_fooview DO INSTEAD SELECT 1 AS x, 'aaa'::text AS y" +== 412 +-- truncate_limit: 100 +drop table rules_fooview +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rules_fooview" +== 413 +-- truncate_limit: 100 +-- likewise, converting a partitioned table or partition to view is not allowed +create table rules_fooview (x int, y text) partition by list (x) +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_fooview (x int, y text) PARTITION BY LIST (x)" +== 414 +-- truncate_limit: 100 +create rule "_RETURN" as on select to rules_fooview do instead + select 1 as x, 'aaa'::text as y +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE \"_RETURN\" AS ON SELECT TO rules_fooview DO INSTEAD SELECT 1 AS x, 'aaa'::text AS y" +== 415 +-- truncate_limit: 100 +create table rules_fooview_part partition of rules_fooview for values in (1) +-- +TABLE: name="rules_fooview_part" schema="" table="rules_fooview_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_fooview_part PARTITION OF rules_fooview FOR VALUES IN (1)" +== 416 +-- truncate_limit: 100 +create rule "_RETURN" as on select to rules_fooview_part do instead + select 1 as x, 'aaa'::text as y +-- +TABLE: name="rules_fooview_part" schema="" table="rules_fooview_part" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE \"_RETURN\" AS ON SELECT TO rules_fooview_part DO INSTEAD SELECT 1 AS x, 'aaa'::text AS y" +== 417 +-- truncate_limit: 100 +drop table rules_fooview +-- +TABLE: name="rules_fooview" schema="" table="rules_fooview" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rules_fooview" +== 418 +-- truncate_limit: 100 +|-- +-- check for planner problems with complex inherited UPDATES +|-- + +create table id (id serial primary key, name text) +-- +TABLE: name="id" schema="" table="id" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE id (id serial PRIMARY KEY, name text)" +== 419 +-- truncate_limit: 100 +-- currently, must respecify PKEY for each inherited subtable +create table test_1 (id integer primary key) inherits (id) +-- +TABLE: name="test_1" schema="" table="test_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_1 (id int PRIMARY KEY) INHERITS (id)" +== 420 +-- truncate_limit: 100 +create table test_2 (id integer primary key) inherits (id) +-- +TABLE: name="test_2" schema="" table="test_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_2 (id int PRIMARY KEY) INHERITS (id)" +== 421 +-- truncate_limit: 100 +create table test_3 (id integer primary key) inherits (id) +-- +TABLE: name="test_3" schema="" table="test_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_3 (id int PRIMARY KEY) INHERITS (id)" +== 422 +-- truncate_limit: 100 +insert into test_1 (name) values ('Test 1') +-- +TABLE: name="test_1" schema="" table="test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_1 (name) VALUES ('Test 1')" +== 423 +-- truncate_limit: 100 +insert into test_1 (name) values ('Test 2') +-- +TABLE: name="test_1" schema="" table="test_1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_1 (name) VALUES ('Test 2')" +== 424 +-- truncate_limit: 100 +insert into test_2 (name) values ('Test 3') +-- +TABLE: name="test_2" schema="" table="test_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_2 (name) VALUES ('Test 3')" +== 425 +-- truncate_limit: 100 +insert into test_2 (name) values ('Test 4') +-- +TABLE: name="test_2" schema="" table="test_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_2 (name) VALUES ('Test 4')" +== 426 +-- truncate_limit: 100 +insert into test_3 (name) values ('Test 5') +-- +TABLE: name="test_3" schema="" table="test_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_3 (name) VALUES ('Test 5')" +== 427 +-- truncate_limit: 100 +insert into test_3 (name) values ('Test 6') +-- +TABLE: name="test_3" schema="" table="test_3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_3 (name) VALUES ('Test 6')" +== 428 +-- truncate_limit: 100 +create view id_ordered as select * from id order by id +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DDL +TABLE: name="id" schema="" table="id" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW id_ordered AS SELECT * FROM id ORDER BY id" +== 429 +-- truncate_limit: 100 +create rule update_id_ordered as on update to id_ordered + do instead update id set name = new.name where id = old.id +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE update_id_ordered AS ON UPDATE TO id_ordered DO INSTEAD UPDATE id SET name = new.name..." +== 430 +-- truncate_limit: 100 +select * from id_ordered +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM id_ordered" +== 431 +-- truncate_limit: 100 +update id_ordered set name = 'update 2' where id = 2 +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE id_ordered SET name = 'update 2' WHERE id = 2" +== 432 +-- truncate_limit: 100 +update id_ordered set name = 'update 4' where id = 4 +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE id_ordered SET name = 'update 4' WHERE id = 4" +== 433 +-- truncate_limit: 100 +update id_ordered set name = 'update 5' where id = 5 +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE id_ordered SET name = 'update 5' WHERE id = 5" +== 434 +-- truncate_limit: 100 +select * from id_ordered +-- +TABLE: name="id_ordered" schema="" table="id_ordered" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM id_ordered" +== 435 +-- truncate_limit: 100 +drop table id cascade +-- +TABLE: name="id" schema="" table="id" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE id CASCADE" +== 436 +-- truncate_limit: 100 +|-- +-- check corner case where an entirely-dummy subplan is created by +-- constraint exclusion +|-- + +create temp table t1 (a integer primary key) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (a int PRIMARY KEY)" +== 437 +-- truncate_limit: 100 +create temp table t1_1 (check (a >= 0 and a < 10)) inherits (t1) +-- +TABLE: name="t1_1" schema="" table="t1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1_1 (CHECK (a >= 0 AND a < 10)) INHERITS (t1)" +== 438 +-- truncate_limit: 100 +create temp table t1_2 (check (a >= 10 and a < 20)) inherits (t1) +-- +TABLE: name="t1_2" schema="" table="t1_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1_2 (CHECK (a >= 10 AND a < 20)) INHERITS (t1)" +== 439 +-- truncate_limit: 100 +create rule t1_ins_1 as on insert to t1 + where new.a >= 0 and new.a < 10 + do instead + insert into t1_1 values (new.a) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE t1_ins_1 AS ON INSERT TO t1 WHERE ... DO INSTEAD INSERT INTO t1_1 VALUES (new.a)" +== 440 +-- truncate_limit: 100 +create rule t1_ins_2 as on insert to t1 + where new.a >= 10 and new.a < 20 + do instead + insert into t1_2 values (new.a) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE t1_ins_2 AS ON INSERT TO t1 WHERE ... DO INSTEAD INSERT INTO t1_2 VALUES (new.a)" +== 441 +-- truncate_limit: 100 +create rule t1_upd_1 as on update to t1 + where old.a >= 0 and old.a < 10 + do instead + update t1_1 set a = new.a where a = old.a +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE t1_upd_1 AS ON UPDATE TO t1 WHERE ... DO INSTEAD UPDATE t1_1 SET a = new.a WHERE a = ..." +== 442 +-- truncate_limit: 100 +create rule t1_upd_2 as on update to t1 + where old.a >= 10 and old.a < 20 + do instead + update t1_2 set a = new.a where a = old.a +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE t1_upd_2 AS ON UPDATE TO t1 WHERE ... DO INSTEAD UPDATE t1_2 SET a = new.a WHERE a = ..." +== 443 +-- truncate_limit: 100 +set constraint_exclusion = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET constraint_exclusion TO ON" +== 444 +-- truncate_limit: 100 +insert into t1 select * from generate_series(5,19,1) g +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 SELECT * FROM generate_series(5, 19, 1) g" +== 445 +-- truncate_limit: 100 +update t1 set a = 4 where a = 5 +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE t1 SET a = 4 WHERE a = 5" +== 446 +-- truncate_limit: 100 +select * from only t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY t1" +== 447 +-- truncate_limit: 100 +select * from only t1_1 +-- +TABLE: name="t1_1" schema="" table="t1_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY t1_1" +== 448 +-- truncate_limit: 100 +select * from only t1_2 +-- +TABLE: name="t1_2" schema="" table="t1_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY t1_2" +== 449 +-- truncate_limit: 100 +reset constraint_exclusion +-- +STMT: VariableSetStmt +TRUNCATED: "RESET constraint_exclusion" +== 450 +-- truncate_limit: 100 +-- test FOR UPDATE in rules + +create table rules_base(f1 int, f2 int) +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_base (f1 int, f2 int)" +== 451 +-- truncate_limit: 100 +insert into rules_base values(1,2), (11,12) +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rules_base VALUES (1, 2), (11, 12)" +== 452 +-- truncate_limit: 100 +create rule r1 as on update to rules_base do instead + select * from rules_base where f1 = 1 for update +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r1 AS ON UPDATE TO rules_base DO INSTEAD SELECT * FROM rules_base WHERE f1 = 1 FOR UP..." +== 453 +-- truncate_limit: 100 +update rules_base set f2 = f2 + 1 +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rules_base SET f2 = f2 + 1" +== 454 +-- truncate_limit: 100 +create or replace rule r1 as on update to rules_base do instead + select * from rules_base where f1 = 11 for update of rules_base +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE r1 AS ON UPDATE TO rules_base DO INSTEAD SELECT * FROM rules_base WHERE f1..." +== 455 +-- truncate_limit: 100 +update rules_base set f2 = f2 + 1 +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rules_base SET f2 = f2 + 1" +== 456 +-- truncate_limit: 100 +create or replace rule r1 as on update to rules_base do instead + select * from rules_base where f1 = 11 for update of old +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE r1 AS ON UPDATE TO rules_base DO INSTEAD SELECT * FROM rules_base WHERE f1..." +== 457 +-- truncate_limit: 100 +-- error +drop table rules_base +-- +TABLE: name="rules_base" schema="" table="rules_base" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rules_base" +== 458 +-- truncate_limit: 100 +-- test various flavors of pg_get_viewdef() + +select pg_get_viewdef('shoe'::regclass) as unpretty +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('shoe'::regclass) AS unpretty" +== 459 +-- truncate_limit: 100 +select pg_get_viewdef('shoe'::regclass,true) as pretty +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('shoe'::regclass, true) AS pretty" +== 460 +-- truncate_limit: 100 +select pg_get_viewdef('shoe'::regclass,0) as prettier +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('shoe'::regclass, 0) AS prettier" +== 461 +-- truncate_limit: 100 +|-- +-- check multi-row VALUES in rules +|-- + +create table rules_src(f1 int, f2 int default 0) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_src (f1 int, f2 int DEFAULT 0)" +== 462 +-- truncate_limit: 100 +create table rules_log(f1 int, f2 int, tag text, id serial) +-- +TABLE: name="rules_log" schema="" table="rules_log" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_log (f1 int, f2 int, tag text, id serial)" +== 463 +-- truncate_limit: 100 +insert into rules_src values(1,2), (11,12) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rules_src VALUES (1, 2), (11, 12)" +== 464 +-- truncate_limit: 100 +create rule r1 as on update to rules_src do also + insert into rules_log values(old.*, 'old', default), (new.*, 'new', default) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r1 AS ON UPDATE TO rules_src DO INSERT INTO rules_log VALUES (old.*, 'old', DEFAULT),..." +== 465 +-- truncate_limit: 100 +update rules_src set f2 = f2 + 1 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rules_src SET f2 = f2 + 1" +== 466 +-- truncate_limit: 100 +update rules_src set f2 = f2 * 10 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rules_src SET f2 = f2 * 10" +== 467 +-- truncate_limit: 100 +select * from rules_src +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rules_src" +== 468 +-- truncate_limit: 100 +select * from rules_log +-- +TABLE: name="rules_log" schema="" table="rules_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rules_log" +== 469 +-- truncate_limit: 100 +create rule r2 as on update to rules_src do also + values(old.*, 'old'), (new.*, 'new') +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r2 AS ON UPDATE TO rules_src DO VALUES (old.*, 'old'), (new.*, 'new')" +== 470 +-- truncate_limit: 100 +update rules_src set f2 = f2 / 10 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rules_src SET f2 = f2 / 10" +== 471 +-- truncate_limit: 100 +create rule r3 as on insert to rules_src do also + insert into rules_log values(null, null, '-', default), (new.*, 'new', default) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r3 AS ON INSERT TO rules_src DO INSERT INTO rules_log VALUES (NULL, NULL, '-', DEFAUL..." +== 472 +-- truncate_limit: 100 +insert into rules_src values(22,23), (33,default) +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rules_src VALUES (22, 23), (33, DEFAULT)" +== 473 +-- truncate_limit: 100 +select * from rules_src +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rules_src" +== 474 +-- truncate_limit: 100 +select * from rules_log +-- +TABLE: name="rules_log" schema="" table="rules_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rules_log" +== 475 +-- truncate_limit: 100 +create rule r4 as on delete to rules_src do notify rules_src_deletion +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r4 AS ON DELETE TO rules_src DO NOTIFY rules_src_deletion" +== 476 +-- truncate_limit: 100 +|-- +-- Ensure an aliased target relation for insert is correctly deparsed. +|-- +create rule r5 as on insert to rules_src do instead insert into rules_log AS trgt SELECT NEW.* RETURNING trgt.f1, trgt.f2 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r5 AS ON INSERT TO rules_src DO INSTEAD INSERT INTO rules_log AS trgt SELECT new.* RE..." +== 477 +-- truncate_limit: 100 +create rule r6 as on update to rules_src do instead UPDATE rules_log AS trgt SET tag = 'updated' WHERE trgt.f1 = new.f1 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r6 AS ON UPDATE TO rules_src DO INSTEAD UPDATE rules_log trgt SET tag = 'updated' WHE..." +== 478 +-- truncate_limit: 100 +|-- +-- Check deparse disambiguation of INSERT/UPDATE/DELETE targets. +|-- +create rule r7 as on delete to rules_src do instead + with wins as (insert into int4_tbl as trgt values (0) returning *), + wupd as (update int4_tbl trgt set f1 = f1+1 returning *), + wdel as (delete from int4_tbl trgt where f1 = 0 returning *) + insert into rules_log AS trgt select old.* from wins, wupd, wdel + returning trgt.f1, trgt.f2 +-- +TABLE: name="rules_src" schema="" table="rules_src" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r7 AS ON DELETE TO rules_src DO INSTEAD WITH wins AS (INSERT INTO int4_tbl AS trgt VA..." +== 479 +-- truncate_limit: 100 +-- check display of all rules added above + +|-- +-- Also check multiassignment deparsing. +|-- +create table rule_t1(f1 int, f2 int) +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_t1 (f1 int, f2 int)" +== 480 +-- truncate_limit: 100 +create table rule_dest(f1 int, f2 int[], tag text) +-- +TABLE: name="rule_dest" schema="" table="rule_dest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_dest (f1 int, f2 int[], tag text)" +== 481 +-- truncate_limit: 100 +create rule rr as on update to rule_t1 do instead UPDATE rule_dest trgt + SET (f2[1], f1, tag) = (SELECT new.f2, new.f1, 'updated'::varchar) + WHERE trgt.f1 = new.f1 RETURNING new.* +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rr AS ON UPDATE TO rule_t1 DO INSTEAD UPDATE rule_dest trgt SET (f2[1], f1, tag) = (S..." +== 482 +-- truncate_limit: 100 +drop table rule_t1, rule_dest +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +TABLE: name="rule_dest" schema="" table="rule_dest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rule_t1, rule_dest" +== 483 +-- truncate_limit: 100 +|-- +-- Test implicit LATERAL references to old/new in rules +|-- +CREATE TABLE rule_t1(a int, b text DEFAULT 'xxx', c int) +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_t1 (a int, b text DEFAULT 'xxx', c int)" +== 484 +-- truncate_limit: 100 +CREATE VIEW rule_v1 AS SELECT * FROM rule_t1 +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rule_v1 AS SELECT * FROM rule_t1" +== 485 +-- truncate_limit: 100 +CREATE RULE v1_ins AS ON INSERT TO rule_v1 + DO ALSO INSERT INTO rule_t1 + SELECT * FROM (SELECT a + 10 FROM rule_t1 WHERE a = NEW.a) tt +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE v1_ins AS ON INSERT TO rule_v1 DO INSERT INTO rule_t1 SELECT * FROM (SELECT a + 10 FR..." +== 486 +-- truncate_limit: 100 +CREATE RULE v1_upd AS ON UPDATE TO rule_v1 + DO ALSO UPDATE rule_t1 t + SET c = tt.a * 10 + FROM (SELECT a FROM rule_t1 WHERE a = OLD.a) tt WHERE t.a = tt.a +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE v1_upd AS ON UPDATE TO rule_v1 DO UPDATE rule_t1 t SET c = tt.a * 10 FROM (SELECT a F..." +== 487 +-- truncate_limit: 100 +INSERT INTO rule_v1 VALUES (1, 'a'), (2, 'b') +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_v1 VALUES (1, 'a'), (2, 'b')" +== 488 +-- truncate_limit: 100 +UPDATE rule_v1 SET b = upper(b) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE rule_v1 SET b = upper(b)" +== 489 +-- truncate_limit: 100 +SELECT * FROM rule_t1 +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rule_t1" +== 490 +-- truncate_limit: 100 +DROP TABLE rule_t1 CASCADE +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rule_t1 CASCADE" +== 491 +-- truncate_limit: 100 +|-- +-- check alter rename rule +|-- +CREATE TABLE rule_t1 (a INT) +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_t1 (a int)" +== 492 +-- truncate_limit: 100 +CREATE VIEW rule_v1 AS SELECT * FROM rule_t1 +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rule_v1 AS SELECT * FROM rule_t1" +== 493 +-- truncate_limit: 100 +CREATE RULE InsertRule AS + ON INSERT TO rule_v1 + DO INSTEAD + INSERT INTO rule_t1 VALUES(new.a) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE insertrule AS ON INSERT TO rule_v1 DO INSTEAD INSERT INTO rule_t1 VALUES (new.a)" +== 494 +-- truncate_limit: 100 +ALTER RULE InsertRule ON rule_v1 RENAME to NewInsertRule +-- +STMT: RenameStmt +TRUNCATED: "ALTER RULE insertrule ON rule_v1 RENAME TO newinsertrule" +== 495 +-- truncate_limit: 100 +INSERT INTO rule_v1 VALUES(1) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rule_v1 VALUES (1)" +== 496 +-- truncate_limit: 100 +SELECT * FROM rule_v1 +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rule_v1" +== 497 +-- truncate_limit: 100 +|-- +-- error conditions for alter rename rule +|-- +ALTER RULE InsertRule ON rule_v1 RENAME TO NewInsertRule +-- +STMT: RenameStmt +TRUNCATED: "ALTER RULE insertrule ON rule_v1 RENAME TO newinsertrule" +== 498 +-- truncate_limit: 100 +-- doesn't exist +ALTER RULE NewInsertRule ON rule_v1 RENAME TO "_RETURN" +-- +STMT: RenameStmt +TRUNCATED: "ALTER RULE newinsertrule ON rule_v1 RENAME TO \"_RETURN\"" +== 499 +-- truncate_limit: 100 +-- already exists +ALTER RULE "_RETURN" ON rule_v1 RENAME TO abc +-- +STMT: RenameStmt +TRUNCATED: "ALTER RULE \"_RETURN\" ON rule_v1 RENAME TO abc" +== 500 +-- truncate_limit: 100 +-- ON SELECT rule cannot be renamed + +DROP VIEW rule_v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rule_v1" +== 501 +-- truncate_limit: 100 +DROP TABLE rule_t1 +-- +TABLE: name="rule_t1" schema="" table="rule_t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rule_t1" +== 502 +-- truncate_limit: 100 +|-- +-- check display of VALUES in view definitions +|-- +create view rule_v1 as values(1,2) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rule_v1 AS VALUES (1, 2)" +== 503 +-- truncate_limit: 100 +alter table rule_v1 rename column column2 to q2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE rule_v1 RENAME COLUMN column2 TO q2" +== 504 +-- truncate_limit: 100 +drop view rule_v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rule_v1" +== 505 +-- truncate_limit: 100 +create view rule_v1(x) as values(1,2) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rule_v1 (x) AS VALUES (1, 2)" +== 506 +-- truncate_limit: 100 +drop view rule_v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rule_v1" +== 507 +-- truncate_limit: 100 +create view rule_v1(x) as select * from (values(1,2)) v +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rule_v1 (x) AS SELECT * FROM (VALUES (1, 2)) v" +== 508 +-- truncate_limit: 100 +drop view rule_v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rule_v1" +== 509 +-- truncate_limit: 100 +create view rule_v1(x) as select * from (values(1,2)) v(q,w) +-- +TABLE: name="rule_v1" schema="" table="rule_v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rule_v1 (x) AS SELECT * FROM (VALUES (1, 2)) v(q, w)" +== 510 +-- truncate_limit: 100 +drop view rule_v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rule_v1" +== 511 +-- truncate_limit: 100 +|-- +-- Check DO INSTEAD rules with ON CONFLICT +|-- +CREATE TABLE hats ( + hat_name char(10) primary key, + hat_color char(10) -- hat color +) +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hats (hat_name char(10) PRIMARY KEY, hat_color char(10))" +== 512 +-- truncate_limit: 100 +CREATE TABLE hat_data ( + hat_name char(10), + hat_color char(10) -- hat color +) +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hat_data (hat_name char(10), hat_color char(10))" +== 513 +-- truncate_limit: 100 +create unique index hat_data_unique_idx + on hat_data (hat_name COLLATE "C" bpchar_pattern_ops) +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX hat_data_unique_idx ON hat_data USING btree (hat_name COLLATE \"C\" bpchar_patt..." +== 514 +-- truncate_limit: 100 +-- DO NOTHING with ON CONFLICT +CREATE RULE hat_nosert AS ON INSERT TO hats + DO INSTEAD + INSERT INTO hat_data VALUES ( + NEW.hat_name, + NEW.hat_color) + ON CONFLICT (hat_name COLLATE "C" bpchar_pattern_ops) WHERE hat_color = 'green' + DO NOTHING + RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE hat_nosert AS ON INSERT TO hats DO INSTEAD INSERT INTO hat_data VALUES (new.hat_name,..." +== 515 +-- truncate_limit: 100 +SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename" +== 516 +-- truncate_limit: 100 +-- Works (projects row) +INSERT INTO hats VALUES ('h7', 'black') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hats VALUES ('h7', 'black') RETURNING *" +== 517 +-- truncate_limit: 100 +-- Works (does nothing) +INSERT INTO hats VALUES ('h7', 'black') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hats VALUES ('h7', 'black') RETURNING *" +== 518 +-- truncate_limit: 100 +SELECT tablename, rulename, definition FROM pg_rules + WHERE tablename = 'hats' +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT tablename, rulename, definition FROM pg_rules WHERE tablename = 'hats'" +== 519 +-- truncate_limit: 100 +DROP RULE hat_nosert ON hats +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE hat_nosert ON hats" +== 520 +-- truncate_limit: 100 +-- DO NOTHING without ON CONFLICT +CREATE RULE hat_nosert_all AS ON INSERT TO hats + DO INSTEAD + INSERT INTO hat_data VALUES ( + NEW.hat_name, + NEW.hat_color) + ON CONFLICT + DO NOTHING + RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE hat_nosert_all AS ON INSERT TO hats DO INSTEAD INSERT INTO hat_data VALUES (new.hat_n..." +== 521 +-- truncate_limit: 100 +SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename" +== 522 +-- truncate_limit: 100 +DROP RULE hat_nosert_all ON hats +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE hat_nosert_all ON hats" +== 523 +-- truncate_limit: 100 +-- Works (does nothing) +INSERT INTO hats VALUES ('h7', 'black') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hats VALUES ('h7', 'black') RETURNING *" +== 524 +-- truncate_limit: 100 +-- DO UPDATE with a WHERE clause +CREATE RULE hat_upsert AS ON INSERT TO hats + DO INSTEAD + INSERT INTO hat_data VALUES ( + NEW.hat_name, + NEW.hat_color) + ON CONFLICT (hat_name) + DO UPDATE + SET hat_name = hat_data.hat_name, hat_color = excluded.hat_color + WHERE excluded.hat_color <> 'forbidden' AND hat_data.* != excluded.* + RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE hat_upsert AS ON INSERT TO hats DO INSTEAD INSERT INTO hat_data VALUES (new.hat_name,..." +== 525 +-- truncate_limit: 100 +SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename" +== 526 +-- truncate_limit: 100 +-- Works (does upsert) +INSERT INTO hats VALUES ('h8', 'black') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hats VALUES ('h8', 'black') RETURNING *" +== 527 +-- truncate_limit: 100 +SELECT * FROM hat_data WHERE hat_name = 'h8' +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=Select +FILTER: schema="" table="" column="hat_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hat_data WHERE hat_name = 'h8'" +== 528 +-- truncate_limit: 100 +INSERT INTO hats VALUES ('h8', 'white') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hats VALUES ('h8', 'white') RETURNING *" +== 529 +-- truncate_limit: 100 +SELECT * FROM hat_data WHERE hat_name = 'h8' +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=Select +FILTER: schema="" table="" column="hat_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hat_data WHERE hat_name = 'h8'" +== 530 +-- truncate_limit: 100 +INSERT INTO hats VALUES ('h8', 'forbidden') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hats VALUES ('h8', 'forbidden') RETURNING *" +== 531 +-- truncate_limit: 100 +SELECT * FROM hat_data WHERE hat_name = 'h8' +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=Select +FILTER: schema="" table="" column="hat_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hat_data WHERE hat_name = 'h8'" +== 532 +-- truncate_limit: 100 +SELECT tablename, rulename, definition FROM pg_rules + WHERE tablename = 'hats' +-- +TABLE: name="pg_rules" schema="" table="pg_rules" ctx=Select +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT tablename, rulename, definition FROM pg_rules WHERE tablename = 'hats'" +== 533 +-- truncate_limit: 100 +-- ensure explain works for on insert conflict rules +explain (costs off) INSERT INTO hats VALUES ('h8', 'forbidden') RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO hats VALUES ('h8', 'forbidden') RETURNING *" +== 534 +-- truncate_limit: 100 +-- ensure upserting into a rule, with a CTE (different offsets!) works +WITH data(hat_name, hat_color) AS MATERIALIZED ( + VALUES ('h8', 'green'), + ('h9', 'blue'), + ('h7', 'forbidden') +) +INSERT INTO hats + SELECT * FROM data +RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +CTE: "data" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH data(hat_name, hat_color) AS MATERIALIZED (...) INSERT INTO hats SELECT * FROM data RETURNING *" +== 535 +-- truncate_limit: 100 +EXPLAIN (costs off) +WITH data(hat_name, hat_color) AS MATERIALIZED ( + VALUES ('h8', 'green'), + ('h9', 'blue'), + ('h7', 'forbidden') +) +INSERT INTO hats + SELECT * FROM data +RETURNING * +-- +TABLE: name="hats" schema="" table="hats" ctx=DML +CTE: "data" +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) WITH data(hat_name, hat_color) AS MATERIALIZED (VALUES ('h8', 'green'), ('h9'..." +== 536 +-- truncate_limit: 100 +SELECT * FROM hat_data WHERE hat_name IN ('h8', 'h9', 'h7') ORDER BY hat_name +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=Select +FILTER: schema="" table="" column="hat_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM hat_data WHERE hat_name IN ('h8', 'h9', 'h7') ORDER BY hat_name" +== 537 +-- truncate_limit: 100 +DROP RULE hat_upsert ON hats +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE hat_upsert ON hats" +== 538 +-- truncate_limit: 100 +drop table hats +-- +TABLE: name="hats" schema="" table="hats" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hats" +== 539 +-- truncate_limit: 100 +drop table hat_data +-- +TABLE: name="hat_data" schema="" table="hat_data" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hat_data" +== 540 +-- truncate_limit: 100 +-- test for pg_get_functiondef properly regurgitating SET parameters +-- Note that the function is kept around to stress pg_dump. +CREATE FUNCTION func_with_set_params() RETURNS integer + AS 'select 1;' + LANGUAGE SQL + SET search_path TO PG_CATALOG + SET extra_float_digits TO 2 + SET work_mem TO '4MB' + SET datestyle to iso, mdy + SET local_preload_libraries TO "Mixed/Case", 'c:/''a"/path', '', '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789' + IMMUTABLE STRICT +-- +FUNCTION: name="func_with_set_params" function="func_with_set_params" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION func_with_set_params() RETURNS int AS $$select 1;$$ LANGUAGE sql SET search_path ..." +== 541 +-- truncate_limit: 100 +SELECT pg_get_functiondef('func_with_set_params()'::regprocedure) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef('func_with_set_params()'::regprocedure)" +== 542 +-- truncate_limit: 100 +-- tests for pg_get_*def with invalid objects +SELECT pg_get_constraintdef(0) +-- +FUNCTION: name="pg_get_constraintdef" function="pg_get_constraintdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_constraintdef(0)" +== 543 +-- truncate_limit: 100 +SELECT pg_get_functiondef(0) +-- +FUNCTION: name="pg_get_functiondef" function="pg_get_functiondef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_functiondef(0)" +== 544 +-- truncate_limit: 100 +SELECT pg_get_indexdef(0) +-- +FUNCTION: name="pg_get_indexdef" function="pg_get_indexdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_indexdef(0)" +== 545 +-- truncate_limit: 100 +SELECT pg_get_ruledef(0) +-- +FUNCTION: name="pg_get_ruledef" function="pg_get_ruledef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_ruledef(0)" +== 546 +-- truncate_limit: 100 +SELECT pg_get_statisticsobjdef(0) +-- +FUNCTION: name="pg_get_statisticsobjdef" function="pg_get_statisticsobjdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_statisticsobjdef(0)" +== 547 +-- truncate_limit: 100 +SELECT pg_get_triggerdef(0) +-- +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_triggerdef(0)" +== 548 +-- truncate_limit: 100 +SELECT pg_get_viewdef(0) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef(0)" +== 549 +-- truncate_limit: 100 +SELECT pg_get_function_arguments(0) +-- +FUNCTION: name="pg_get_function_arguments" function="pg_get_function_arguments" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_function_arguments(0)" +== 550 +-- truncate_limit: 100 +SELECT pg_get_function_identity_arguments(0) +-- +FUNCTION: name="pg_get_function_identity_arguments" function="pg_get_function_identity_arguments" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_function_identity_arguments(0)" +== 551 +-- truncate_limit: 100 +SELECT pg_get_function_result(0) +-- +FUNCTION: name="pg_get_function_result" function="pg_get_function_result" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_function_result(0)" +== 552 +-- truncate_limit: 100 +SELECT pg_get_function_arg_default(0, 0) +-- +FUNCTION: name="pg_get_function_arg_default" function="pg_get_function_arg_default" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_function_arg_default(0, 0)" +== 553 +-- truncate_limit: 100 +SELECT pg_get_function_arg_default('pg_class'::regclass, 0) +-- +FUNCTION: name="pg_get_function_arg_default" function="pg_get_function_arg_default" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_function_arg_default('pg_class'::regclass, 0)" +== 554 +-- truncate_limit: 100 +SELECT pg_get_partkeydef(0) +-- +FUNCTION: name="pg_get_partkeydef" function="pg_get_partkeydef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_partkeydef(0)" +== 555 +-- truncate_limit: 100 +-- test rename for a rule defined on a partitioned table +CREATE TABLE rules_parted_table (a int) PARTITION BY LIST (a) +-- +TABLE: name="rules_parted_table" schema="" table="rules_parted_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_parted_table (a int) PARTITION BY LIST (a)" +== 556 +-- truncate_limit: 100 +CREATE TABLE rules_parted_table_1 PARTITION OF rules_parted_table FOR VALUES IN (1) +-- +TABLE: name="rules_parted_table_1" schema="" table="rules_parted_table_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rules_parted_table_1 PARTITION OF rules_parted_table FOR VALUES IN (1)" +== 557 +-- truncate_limit: 100 +CREATE RULE rules_parted_table_insert AS ON INSERT to rules_parted_table + DO INSTEAD INSERT INTO rules_parted_table_1 VALUES (NEW.*) +-- +TABLE: name="rules_parted_table" schema="" table="rules_parted_table" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rules_parted_table_insert AS ON INSERT TO rules_parted_table DO INSTEAD INSERT INTO r..." +== 558 +-- truncate_limit: 100 +ALTER RULE rules_parted_table_insert ON rules_parted_table RENAME TO rules_parted_table_insert_redirect +-- +STMT: RenameStmt +TRUNCATED: "ALTER RULE rules_parted_table_insert ON rules_parted_table RENAME TO rules_parted_table_insert_re..." +== 559 +-- truncate_limit: 100 +DROP TABLE rules_parted_table +-- +TABLE: name="rules_parted_table" schema="" table="rules_parted_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE rules_parted_table" +== 560 +-- truncate_limit: 100 +|-- +-- test MERGE +|-- +CREATE TABLE rule_merge1 (a int, b text) +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_merge1 (a int, b text)" +== 561 +-- truncate_limit: 100 +CREATE TABLE rule_merge2 (a int, b text) +-- +TABLE: name="rule_merge2" schema="" table="rule_merge2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE rule_merge2 (a int, b text)" +== 562 +-- truncate_limit: 100 +CREATE RULE rule1 AS ON INSERT TO rule_merge1 + DO INSTEAD INSERT INTO rule_merge2 VALUES (NEW.*) +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rule1 AS ON INSERT TO rule_merge1 DO INSTEAD INSERT INTO rule_merge2 VALUES (new.*)" +== 563 +-- truncate_limit: 100 +CREATE RULE rule2 AS ON UPDATE TO rule_merge1 + DO INSTEAD UPDATE rule_merge2 SET a = NEW.a, b = NEW.b + WHERE a = OLD.a +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rule2 AS ON UPDATE TO rule_merge1 DO INSTEAD UPDATE rule_merge2 SET a = new.a, b = ne..." +== 564 +-- truncate_limit: 100 +CREATE RULE rule3 AS ON DELETE TO rule_merge1 + DO INSTEAD DELETE FROM rule_merge2 WHERE a = OLD.a +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rule3 AS ON DELETE TO rule_merge1 DO INSTEAD DELETE FROM rule_merge2 WHERE a = old.a" +== 565 +-- truncate_limit: 100 +-- MERGE not supported for table with rules +MERGE INTO rule_merge1 t USING (SELECT 1 AS a) s + ON t.a = s.a + WHEN MATCHED AND t.a < 2 THEN + UPDATE SET b = b || ' updated by merge' + WHEN MATCHED AND t.a > 2 THEN + DELETE + WHEN NOT MATCHED THEN + INSERT VALUES (s.a, '') +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DML +ALIAS: "t"="rule_merge1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rule_merge1 t USING (SELECT ...) s ON t.a = s.a WHEN MATCHED AND t.a < 2 THEN UPDATE S..." +== 566 +-- truncate_limit: 100 +-- should be ok with the other table though +MERGE INTO rule_merge2 t USING (SELECT 1 AS a) s + ON t.a = s.a + WHEN MATCHED AND t.a < 2 THEN + UPDATE SET b = b || ' updated by merge' + WHEN MATCHED AND t.a > 2 THEN + DELETE + WHEN NOT MATCHED THEN + INSERT VALUES (s.a, '') +-- +TABLE: name="rule_merge2" schema="" table="rule_merge2" ctx=DML +ALIAS: "t"="rule_merge2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rule_merge2 t USING (SELECT ...) s ON t.a = s.a WHEN MATCHED AND t.a < 2 THEN UPDATE S..." +== 567 +-- truncate_limit: 100 +-- also ok if the rules are disabled +ALTER TABLE rule_merge1 DISABLE RULE rule1 +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rule_merge1 DISABLE RULE rule1" +== 568 +-- truncate_limit: 100 +ALTER TABLE rule_merge1 DISABLE RULE rule2 +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rule_merge1 DISABLE RULE rule2" +== 569 +-- truncate_limit: 100 +ALTER TABLE rule_merge1 DISABLE RULE rule3 +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE rule_merge1 DISABLE RULE rule3" +== 570 +-- truncate_limit: 100 +MERGE INTO rule_merge1 t USING (SELECT 1 AS a) s + ON t.a = s.a + WHEN MATCHED AND t.a < 2 THEN + UPDATE SET b = b || ' updated by merge' + WHEN MATCHED AND t.a > 2 THEN + DELETE + WHEN NOT MATCHED THEN + INSERT VALUES (s.a, '') +-- +TABLE: name="rule_merge1" schema="" table="rule_merge1" ctx=DML +ALIAS: "t"="rule_merge1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rule_merge1 t USING (SELECT ...) s ON t.a = s.a WHEN MATCHED AND t.a < 2 THEN UPDATE S..." +== 571 +-- truncate_limit: 100 +-- test deparsing +CREATE TABLE sf_target(id int, data text, filling int[]) +-- +TABLE: name="sf_target" schema="" table="sf_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sf_target (id int, data text, filling int[])" +== 572 +-- truncate_limit: 100 +CREATE FUNCTION merge_sf_test() + RETURNS TABLE(action text, a int, b text, id int, data text, filling int[]) + LANGUAGE sql +BEGIN ATOMIC + MERGE INTO sf_target t + USING rule_merge1 s + ON (s.a = t.id) +WHEN MATCHED + AND (s.a + t.id) = 42 + THEN UPDATE SET data = repeat(t.data, s.a) || s.b, id = length(s.b) +WHEN NOT MATCHED + AND (s.b IS NOT NULL) + THEN INSERT (data, id) + VALUES (s.b, s.a) +WHEN MATCHED + AND length(s.b || t.data) > 10 + THEN UPDATE SET data = s.b +WHEN MATCHED + AND s.a > 200 + THEN UPDATE SET filling[s.a] = t.id +WHEN MATCHED + AND s.a > 100 + THEN DELETE +WHEN MATCHED + THEN DO NOTHING +WHEN NOT MATCHED + AND s.a > 200 + THEN INSERT DEFAULT VALUES +WHEN NOT MATCHED + AND s.a > 100 + THEN INSERT (id, data) OVERRIDING USER VALUE + VALUES (s.a, DEFAULT) +WHEN NOT MATCHED + AND s.a > 0 + THEN INSERT + VALUES (s.a, s.b, DEFAULT) +WHEN NOT MATCHED + THEN INSERT (filling[1], id) + VALUES (s.a, s.a) +RETURNING + merge_action() AS action, * +-- +ERROR: syntax error at end of input +CURSORPOS: 982 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 573 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 574 +-- truncate_limit: 100 +CREATE FUNCTION merge_sf_test2() + RETURNS void + LANGUAGE sql +BEGIN ATOMIC + MERGE INTO sf_target t + USING rule_merge1 s + ON (s.a = t.id) +WHEN NOT MATCHED + THEN INSERT (data, id) + VALUES (s.a, s.a) +WHEN MATCHED + THEN UPDATE SET data = s.b +WHEN NOT MATCHED BY SOURCE + THEN DELETE +-- +ERROR: syntax error at end of input +CURSORPOS: 289 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 575 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 576 +-- truncate_limit: 100 +DROP FUNCTION merge_sf_test +-- +FUNCTION: name="merge_sf_test" function="merge_sf_test" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION merge_sf_test" +== 577 +-- truncate_limit: 100 +DROP FUNCTION merge_sf_test2 +-- +FUNCTION: name="merge_sf_test2" function="merge_sf_test2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION merge_sf_test2" +== 578 +-- truncate_limit: 100 +DROP TABLE sf_target +-- +TABLE: name="sf_target" schema="" table="sf_target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sf_target" +== 579 +-- truncate_limit: 100 +|-- +-- Test enabling/disabling +|-- +CREATE TABLE ruletest1 (a int) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ruletest1 (a int)" +== 580 +-- truncate_limit: 100 +CREATE TABLE ruletest2 (b int) +-- +TABLE: name="ruletest2" schema="" table="ruletest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ruletest2 (b int)" +== 581 +-- truncate_limit: 100 +CREATE RULE rule1 AS ON INSERT TO ruletest1 + DO INSTEAD INSERT INTO ruletest2 VALUES (NEW.*) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rule1 AS ON INSERT TO ruletest1 DO INSTEAD INSERT INTO ruletest2 VALUES (new.*)" +== 582 +-- truncate_limit: 100 +INSERT INTO ruletest1 VALUES (1) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ruletest1 VALUES (1)" +== 583 +-- truncate_limit: 100 +ALTER TABLE ruletest1 DISABLE RULE rule1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ruletest1 DISABLE RULE rule1" +== 584 +-- truncate_limit: 100 +INSERT INTO ruletest1 VALUES (2) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ruletest1 VALUES (2)" +== 585 +-- truncate_limit: 100 +ALTER TABLE ruletest1 ENABLE RULE rule1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ruletest1 ENABLE RULE rule1" +== 586 +-- truncate_limit: 100 +SET session_replication_role = replica +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_replication_role TO replica" +== 587 +-- truncate_limit: 100 +INSERT INTO ruletest1 VALUES (3) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ruletest1 VALUES (3)" +== 588 +-- truncate_limit: 100 +ALTER TABLE ruletest1 ENABLE REPLICA RULE rule1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ruletest1 ENABLE REPLICA RULE rule1" +== 589 +-- truncate_limit: 100 +INSERT INTO ruletest1 VALUES (4) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ruletest1 VALUES (4)" +== 590 +-- truncate_limit: 100 +RESET session_replication_role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_replication_role" +== 591 +-- truncate_limit: 100 +INSERT INTO ruletest1 VALUES (5) +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ruletest1 VALUES (5)" +== 592 +-- truncate_limit: 100 +SELECT * FROM ruletest1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ruletest1" +== 593 +-- truncate_limit: 100 +SELECT * FROM ruletest2 +-- +TABLE: name="ruletest2" schema="" table="ruletest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ruletest2" +== 594 +-- truncate_limit: 100 +DROP TABLE ruletest1 +-- +TABLE: name="ruletest1" schema="" table="ruletest1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ruletest1" +== 595 +-- truncate_limit: 100 +DROP TABLE ruletest2 +-- +TABLE: name="ruletest2" schema="" table="ruletest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ruletest2" +== 596 +-- truncate_limit: 100 +|-- +-- Test non-SELECT rule on security invoker view. +-- Should use view owner's permissions. +|-- +CREATE USER regress_rule_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_rule_user1" +== 597 +-- truncate_limit: 100 +CREATE TABLE ruletest_t1 (x int) +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ruletest_t1 (x int)" +== 598 +-- truncate_limit: 100 +CREATE TABLE ruletest_t2 (x int) +-- +TABLE: name="ruletest_t2" schema="" table="ruletest_t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ruletest_t2 (x int)" +== 599 +-- truncate_limit: 100 +CREATE VIEW ruletest_v1 WITH (security_invoker=true) AS + SELECT * FROM ruletest_t1 +-- +TABLE: name="ruletest_v1" schema="" table="ruletest_v1" ctx=DDL +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ruletest_v1 WITH (security_invoker=true) AS SELECT * FROM ruletest_t1" +== 600 +-- truncate_limit: 100 +GRANT INSERT ON ruletest_v1 TO regress_rule_user1 +-- +TABLE: name="ruletest_v1" schema="" table="ruletest_v1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON ruletest_v1 TO regress_rule_user1" +== 601 +-- truncate_limit: 100 +CREATE RULE rule1 AS ON INSERT TO ruletest_v1 + DO INSTEAD INSERT INTO ruletest_t2 VALUES (NEW.*) +-- +TABLE: name="ruletest_v1" schema="" table="ruletest_v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rule1 AS ON INSERT TO ruletest_v1 DO INSTEAD INSERT INTO ruletest_t2 VALUES (new.*)" +== 602 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rule_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rule_user1" +== 603 +-- truncate_limit: 100 +INSERT INTO ruletest_v1 VALUES (1) +-- +TABLE: name="ruletest_v1" schema="" table="ruletest_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ruletest_v1 VALUES (1)" +== 604 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 605 +-- truncate_limit: 100 +-- Test that main query's relation's permissions are checked before +-- the rule action's relation's. +CREATE TABLE ruletest_t3 (x int) +-- +TABLE: name="ruletest_t3" schema="" table="ruletest_t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ruletest_t3 (x int)" +== 606 +-- truncate_limit: 100 +CREATE RULE rule2 AS ON UPDATE TO ruletest_t1 + DO INSTEAD INSERT INTO ruletest_t2 VALUES (OLD.*) +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rule2 AS ON UPDATE TO ruletest_t1 DO INSTEAD INSERT INTO ruletest_t2 VALUES (old.*)" +== 607 +-- truncate_limit: 100 +REVOKE ALL ON ruletest_t2 FROM regress_rule_user1 +-- +TABLE: name="ruletest_t2" schema="" table="ruletest_t2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON ruletest_t2 FROM regress_rule_user1" +== 608 +-- truncate_limit: 100 +REVOKE ALL ON ruletest_t3 FROM regress_rule_user1 +-- +TABLE: name="ruletest_t3" schema="" table="ruletest_t3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON ruletest_t3 FROM regress_rule_user1" +== 609 +-- truncate_limit: 100 +ALTER TABLE ruletest_t1 OWNER TO regress_rule_user1 +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ruletest_t1 OWNER TO regress_rule_user1" +== 610 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_rule_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_rule_user1" +== 611 +-- truncate_limit: 100 +UPDATE ruletest_t1 t1 SET x = 0 FROM ruletest_t3 t3 WHERE t1.x = t3.x +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DML +TABLE: name="ruletest_t3" schema="" table="ruletest_t3" ctx=Select +ALIAS: "t1"="ruletest_t1" +ALIAS: "t3"="ruletest_t3" +STMT: UpdateStmt +TRUNCATED: "UPDATE ruletest_t1 t1 SET x = 0 FROM ruletest_t3 t3 WHERE t1.x = t3.x" +== 612 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 613 +-- truncate_limit: 100 +SELECT * FROM ruletest_t1 +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ruletest_t1" +== 614 +-- truncate_limit: 100 +SELECT * FROM ruletest_t2 +-- +TABLE: name="ruletest_t2" schema="" table="ruletest_t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ruletest_t2" +== 615 +-- truncate_limit: 100 +DROP VIEW ruletest_v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW ruletest_v1" +== 616 +-- truncate_limit: 100 +DROP RULE rule2 ON ruletest_t1 +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE rule2 ON ruletest_t1" +== 617 +-- truncate_limit: 100 +DROP TABLE ruletest_t3 +-- +TABLE: name="ruletest_t3" schema="" table="ruletest_t3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ruletest_t3" +== 618 +-- truncate_limit: 100 +DROP TABLE ruletest_t2 +-- +TABLE: name="ruletest_t2" schema="" table="ruletest_t2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ruletest_t2" +== 619 +-- truncate_limit: 100 +DROP TABLE ruletest_t1 +-- +TABLE: name="ruletest_t1" schema="" table="ruletest_t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ruletest_t1" +== 620 +-- truncate_limit: 100 +DROP USER regress_rule_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_rule_user1" diff --git a/parser/testdata/summary_truncate/postgres_regress/sanity_check.metadata.json b/parser/testdata/summary_truncate/postgres_regress/sanity_check.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sanity_check.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/sanity_check.test b/parser/testdata/summary_truncate/postgres_regress/sanity_check.test new file mode 100644 index 0000000..380c8ce --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sanity_check.test @@ -0,0 +1,55 @@ +== 001 +-- truncate_limit: 100 +VACUUM +-- +STMT: VacuumStmt +TRUNCATED: "VACUUM" +== 002 +-- truncate_limit: 100 +|-- +-- Sanity check: every system catalog that has OIDs should have +-- a unique index on OID. This ensures that the OIDs will be unique, +-- even after the OID counter wraps around. +-- We exclude non-system tables from the check by looking at nspname. +|-- +SELECT relname, nspname + FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace JOIN pg_attribute a ON (attrelid = c.oid AND attname = 'oid') + WHERE relkind = 'r' and c.oid < 16384 + AND ((nspname ~ '^pg_') IS NOT FALSE) + AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid + AND indkey[0] = a.attnum AND indnatts = 1 + AND indisunique AND indimmediate) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_namespace" schema="" table="pg_namespace" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +ALIAS: "n"="pg_namespace" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="nspname" +FILTER: schema="" table="" column="indrelid" +FILTER: schema="" table="c" column="oid" +FILTER: schema="" table="" column="indkey" +FILTER: schema="" table="a" column="attnum" +FILTER: schema="" table="" column="indnatts" +FILTER: schema="" table="" column="indisunique" +FILTER: schema="" table="" column="indimmediate" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace JOIN pg_attribute a O..." +== 003 +-- truncate_limit: 100 +-- check that relations without storage don't have relfilenode +SELECT relname, relkind + FROM pg_class + WHERE relkind IN ('v', 'c', 'f', 'p', 'I') + AND relfilenode <> 0 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relfilenode" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relkind FROM pg_class WHERE ..." diff --git a/parser/testdata/summary_truncate/postgres_regress/security_label.metadata.json b/parser/testdata/summary_truncate/postgres_regress/security_label.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/security_label.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/security_label.test b/parser/testdata/summary_truncate/postgres_regress/security_label.test new file mode 100644 index 0000000..146c9eb --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/security_label.test @@ -0,0 +1,198 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test for facilities of security label +|-- + +-- initial setups +SET client_min_messages TO 'warning' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO warning" +== 002 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_seclabel_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_seclabel_user1" +== 003 +-- truncate_limit: 100 +DROP ROLE IF EXISTS regress_seclabel_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_seclabel_user2" +== 004 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 005 +-- truncate_limit: 100 +CREATE USER regress_seclabel_user1 WITH CREATEROLE +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_seclabel_user1 WITH CREATEROLE" +== 006 +-- truncate_limit: 100 +CREATE USER regress_seclabel_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_seclabel_user2" +== 007 +-- truncate_limit: 100 +CREATE TABLE seclabel_tbl1 (a int, b text) +-- +TABLE: name="seclabel_tbl1" schema="" table="seclabel_tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE seclabel_tbl1 (a int, b text)" +== 008 +-- truncate_limit: 100 +CREATE TABLE seclabel_tbl2 (x int, y text) +-- +TABLE: name="seclabel_tbl2" schema="" table="seclabel_tbl2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE seclabel_tbl2 (x int, y text)" +== 009 +-- truncate_limit: 100 +CREATE VIEW seclabel_view1 AS SELECT * FROM seclabel_tbl2 +-- +TABLE: name="seclabel_view1" schema="" table="seclabel_view1" ctx=DDL +TABLE: name="seclabel_tbl2" schema="" table="seclabel_tbl2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW seclabel_view1 AS SELECT * FROM seclabel_tbl2" +== 010 +-- truncate_limit: 100 +CREATE FUNCTION seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql +-- +FUNCTION: name="seclabel_four" function="seclabel_four" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION seclabel_four() RETURNS int AS $$SELECT 4$$ LANGUAGE sql" +== 011 +-- truncate_limit: 100 +CREATE DOMAIN seclabel_domain AS text +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN seclabel_domain AS text" +== 012 +-- truncate_limit: 100 +ALTER TABLE seclabel_tbl1 OWNER TO regress_seclabel_user1 +-- +TABLE: name="seclabel_tbl1" schema="" table="seclabel_tbl1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE seclabel_tbl1 OWNER TO regress_seclabel_user1" +== 013 +-- truncate_limit: 100 +ALTER TABLE seclabel_tbl2 OWNER TO regress_seclabel_user2 +-- +TABLE: name="seclabel_tbl2" schema="" table="seclabel_tbl2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE seclabel_tbl2 OWNER TO regress_seclabel_user2" +== 014 +-- truncate_limit: 100 +|-- +-- Test of SECURITY LABEL statement without a plugin +|-- +SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified' +-- +STMT: SecLabelStmt +TRUNCATED: "SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified'" +== 015 +-- truncate_limit: 100 +-- fail +SECURITY LABEL FOR 'dummy' ON TABLE seclabel_tbl1 IS 'classified' +-- +STMT: SecLabelStmt +TRUNCATED: "SECURITY LABEL FOR dummy ON TABLE seclabel_tbl1 IS 'classified'" +== 016 +-- truncate_limit: 100 +-- fail +SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...' +-- +STMT: SecLabelStmt +TRUNCATED: "SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...'" +== 017 +-- truncate_limit: 100 +-- fail +SECURITY LABEL ON TABLE seclabel_tbl3 IS 'unclassified' +-- +STMT: SecLabelStmt +TRUNCATED: "SECURITY LABEL ON TABLE seclabel_tbl3 IS 'unclassified'" +== 018 +-- truncate_limit: 100 +-- fail + +SECURITY LABEL ON ROLE regress_seclabel_user1 IS 'classified' +-- +STMT: SecLabelStmt +TRUNCATED: "SECURITY LABEL ON ROLE regress_seclabel_user1 IS 'classified'" +== 019 +-- truncate_limit: 100 +-- fail +SECURITY LABEL FOR 'dummy' ON ROLE regress_seclabel_user1 IS 'classified' +-- +STMT: SecLabelStmt +TRUNCATED: "SECURITY LABEL FOR dummy ON ROLE regress_seclabel_user1 IS 'classified'" +== 020 +-- truncate_limit: 100 +-- fail +SECURITY LABEL ON ROLE regress_seclabel_user1 IS '...invalid label...' +-- +STMT: SecLabelStmt +TRUNCATED: "SECURITY LABEL ON ROLE regress_seclabel_user1 IS '...invalid label...'" +== 021 +-- truncate_limit: 100 +-- fail +SECURITY LABEL ON ROLE regress_seclabel_user3 IS 'unclassified' +-- +STMT: SecLabelStmt +TRUNCATED: "SECURITY LABEL ON ROLE regress_seclabel_user3 IS 'unclassified'" +== 022 +-- truncate_limit: 100 +-- fail + +-- clean up objects +DROP FUNCTION seclabel_four() +-- +FUNCTION: name="seclabel_four" function="seclabel_four" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION seclabel_four()" +== 023 +-- truncate_limit: 100 +DROP DOMAIN seclabel_domain +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN seclabel_domain" +== 024 +-- truncate_limit: 100 +DROP VIEW seclabel_view1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW seclabel_view1" +== 025 +-- truncate_limit: 100 +DROP TABLE seclabel_tbl1 +-- +TABLE: name="seclabel_tbl1" schema="" table="seclabel_tbl1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE seclabel_tbl1" +== 026 +-- truncate_limit: 100 +DROP TABLE seclabel_tbl2 +-- +TABLE: name="seclabel_tbl2" schema="" table="seclabel_tbl2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE seclabel_tbl2" +== 027 +-- truncate_limit: 100 +DROP USER regress_seclabel_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_seclabel_user1" +== 028 +-- truncate_limit: 100 +DROP USER regress_seclabel_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_seclabel_user2" diff --git a/parser/testdata/summary_truncate/postgres_regress/select.metadata.json b/parser/testdata/summary_truncate/postgres_regress/select.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/select.test b/parser/testdata/summary_truncate/postgres_regress/select.test new file mode 100644 index 0000000..275377d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select.test @@ -0,0 +1,811 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SELECT +|-- + +-- btree index +-- awk '{if($1<10){print;}else{next;}}' onek.data | sort +0n -1 +|-- +SELECT * FROM onek + WHERE onek.unique1 < 10 + ORDER BY onek.unique1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM onek WHERE onek.unique1 < 10 ORDER BY onek.unique1" +== 002 +-- truncate_limit: 100 +|-- +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 +|-- +SELECT onek.unique1, onek.stringu1 FROM onek + WHERE onek.unique1 < 20 + ORDER BY unique1 using > +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT onek.unique1, onek.stringu1 FROM onek WHERE onek.unique1 < 20 ORDER BY unique1 USING >" +== 003 +-- truncate_limit: 100 +|-- +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 +|-- +SELECT onek.unique1, onek.stringu1 FROM onek + WHERE onek.unique1 > 980 + ORDER BY stringu1 using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT onek.unique1, onek.stringu1 FROM onek WHERE onek.unique1 > 980 ORDER BY stringu1 USING <" +== 004 +-- truncate_limit: 100 +|-- +-- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | +-- sort +1d -2 +0nr -1 +|-- +SELECT onek.unique1, onek.string4 FROM onek + WHERE onek.unique1 > 980 + ORDER BY string4 using <, unique1 using > +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE onek.unique1 > 980 ORDER BY string4 USING <, unique1 USING >" +== 005 +-- truncate_limit: 100 +|-- +-- awk '{if($1>980){print $1,$16;}else{next;}}' onek.data | +-- sort +1dr -2 +0n -1 +|-- +SELECT onek.unique1, onek.string4 FROM onek + WHERE onek.unique1 > 980 + ORDER BY string4 using >, unique1 using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE onek.unique1 > 980 ORDER BY string4 USING >, unique1 USING <" +== 006 +-- truncate_limit: 100 +|-- +-- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | +-- sort +0nr -1 +1d -2 +|-- +SELECT onek.unique1, onek.string4 FROM onek + WHERE onek.unique1 < 20 + ORDER BY unique1 using >, string4 using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE onek.unique1 < 20 ORDER BY unique1 USING >, string4 USING <" +== 007 +-- truncate_limit: 100 +|-- +-- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data | +-- sort +0n -1 +1dr -2 +|-- +SELECT onek.unique1, onek.string4 FROM onek + WHERE onek.unique1 < 20 + ORDER BY unique1 using <, string4 using > +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek WHERE onek.unique1 < 20 ORDER BY unique1 USING <, string4 USING >" +== 008 +-- truncate_limit: 100 +|-- +-- test partial btree indexes +|-- +-- As of 7.2, planner probably won't pick an indexscan without stats, +-- so ANALYZE first. Also, we want to prevent it from picking a bitmapscan +-- followed by sort, because that could hide index ordering problems. +|-- +ANALYZE onek2 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE onek2" +== 009 +-- truncate_limit: 100 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 010 +-- truncate_limit: 100 +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 011 +-- truncate_limit: 100 +SET enable_sort TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO OFF" +== 012 +-- truncate_limit: 100 +|-- +-- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1 +|-- +SELECT onek2.* FROM onek2 WHERE onek2.unique1 < 10 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="onek2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT onek2.* FROM onek2 WHERE onek2.unique1 < 10" +== 013 +-- truncate_limit: 100 +|-- +-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1 +|-- +SELECT onek2.unique1, onek2.stringu1 FROM onek2 + WHERE onek2.unique1 < 20 + ORDER BY unique1 using > +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="onek2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT onek2.unique1, onek2.stringu1 FROM onek2 WHERE onek2.unique1 < 20 ORDER BY unique1 USING >" +== 014 +-- truncate_limit: 100 +|-- +-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2 +|-- +SELECT onek2.unique1, onek2.stringu1 FROM onek2 + WHERE onek2.unique1 > 980 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="onek2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT onek2.unique1, onek2.stringu1 FROM onek2 WHERE onek2.unique1 > 980" +== 015 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 016 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 017 +-- truncate_limit: 100 +RESET enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 018 +-- truncate_limit: 100 +|-- +-- awk '{print $1,$2;}' person.data | +-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | +-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data | +-- awk 'BEGIN{FS=" ";}{if(NF!=2){print $4,$5;}else{print;}}' - stud_emp.data +|-- +-- SELECT name, age FROM person*; ??? check if different +SELECT p.name, p.age FROM person* p +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +STMT: SelectStmt +TRUNCATED: "SELECT p.name, p.age FROM person p" +== 019 +-- truncate_limit: 100 +|-- +-- awk '{print $1,$2;}' person.data | +-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | +-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data | +-- awk 'BEGIN{FS=" ";}{if(NF!=1){print $4,$5;}else{print;}}' - stud_emp.data | +-- sort +1nr -2 +|-- +SELECT p.name, p.age FROM person* p ORDER BY age using >, name +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +STMT: SelectStmt +TRUNCATED: "SELECT p.name, p.age FROM person p ORDER BY age USING >, name" +== 020 +-- truncate_limit: 100 +|-- +-- Test some cases involving whole-row Var referencing a subquery +|-- +select foo from (select 1 offset 0) as foo +-- +STMT: SelectStmt +TRUNCATED: "SELECT foo FROM (SELECT 1 OFFSET 0) foo" +== 021 +-- truncate_limit: 100 +select foo from (select null offset 0) as foo +-- +STMT: SelectStmt +TRUNCATED: "SELECT foo FROM (SELECT NULL OFFSET 0) foo" +== 022 +-- truncate_limit: 100 +select foo from (select 'xyzzy',1,null offset 0) as foo +-- +STMT: SelectStmt +TRUNCATED: "SELECT foo FROM (SELECT 'xyzzy', 1, NULL OFFSET 0) foo" +== 023 +-- truncate_limit: 100 +|-- +-- Test VALUES lists +|-- +select * from onek, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j) + WHERE onek.unique1 = v.i and onek.stringu1 = v.j +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +FILTER: schema="" table="v" column="i" +FILTER: schema="" table="onek" column="stringu1" +FILTER: schema="" table="v" column="j" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM onek, (VALUES (...)) v(i, j) WHERE onek.unique1 = v.i AND onek.stringu1 = v.j" +== 024 +-- truncate_limit: 100 +-- a more complex case +-- looks like we're coding lisp :-) +select * from onek, + (values ((select i from + (values(10000), (2), (389), (1000), (2000), ((select 10029))) as foo(i) + order by i asc limit 1))) bar (i) + where onek.unique1 = bar.i +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="onek" column="unique1" +FILTER: schema="" table="bar" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM onek, (VALUES (...)) bar(i) WHERE onek.unique1 = bar.i" +== 025 +-- truncate_limit: 100 +-- try VALUES in a subquery +select * from onek + where (unique1,ten) in (values (1,1), (20,0), (99,9), (17,99)) + order by unique1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="ten" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM onek WHERE (unique1, ten) IN (VALUES (...)) ORDER BY unique1" +== 026 +-- truncate_limit: 100 +-- VALUES is also legal as a standalone query or a set-operation member +VALUES (1,2), (3,4+4), (7,77.7) +-- +STMT: SelectStmt +TRUNCATED: "VALUES (1, 2), (3, 4 + 4), (7, 77.7)" +== 027 +-- truncate_limit: 100 +VALUES (1,2), (3,4+4), (7,77.7) +UNION ALL +SELECT 2+2, 57 +UNION ALL +TABLE int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "(VALUES (1, 2), (3, 4 + 4), (7, 77.7) UNION ALL SELECT 2 + 2, 57) UNION ALL SELECT * FROM int8_tbl" +== 028 +-- truncate_limit: 100 +-- corner case: VALUES with no columns +CREATE TEMP TABLE nocols() +-- +TABLE: name="nocols" schema="" table="nocols" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE nocols ()" +== 029 +-- truncate_limit: 100 +INSERT INTO nocols DEFAULT VALUES +-- +TABLE: name="nocols" schema="" table="nocols" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO nocols DEFAULT VALUES" +== 030 +-- truncate_limit: 100 +SELECT * FROM nocols n, LATERAL (VALUES(n.*)) v +-- +TABLE: name="nocols" schema="" table="nocols" ctx=Select +ALIAS: "n"="nocols" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nocols n, LATERAL (VALUES (n.*)) v" +== 031 +-- truncate_limit: 100 +|-- +-- Test ORDER BY options +|-- + +CREATE TEMP TABLE foo (f1 int) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (f1 int)" +== 032 +-- truncate_limit: 100 +INSERT INTO foo VALUES (42),(3),(10),(7),(null),(null),(1) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (42), (3), (10), (7), (NULL), (NULL), (1)" +== 033 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1" +== 034 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 ASC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 ASC" +== 035 +-- truncate_limit: 100 +-- same thing +SELECT * FROM foo ORDER BY f1 NULLS FIRST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 NULLS FIRST" +== 036 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 DESC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 DESC" +== 037 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 DESC NULLS LAST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 DESC NULLS LAST" +== 038 +-- truncate_limit: 100 +-- check if indexscans do the right things +CREATE INDEX fooi ON foo (f1) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fooi ON foo USING btree (f1)" +== 039 +-- truncate_limit: 100 +SET enable_sort = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO FALSE" +== 040 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1" +== 041 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 NULLS FIRST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 NULLS FIRST" +== 042 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 DESC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 DESC" +== 043 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 DESC NULLS LAST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 DESC NULLS LAST" +== 044 +-- truncate_limit: 100 +DROP INDEX fooi +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX fooi" +== 045 +-- truncate_limit: 100 +CREATE INDEX fooi ON foo (f1 DESC) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fooi ON foo USING btree (f1 DESC)" +== 046 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1" +== 047 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 NULLS FIRST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 NULLS FIRST" +== 048 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 DESC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 DESC" +== 049 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 DESC NULLS LAST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 DESC NULLS LAST" +== 050 +-- truncate_limit: 100 +DROP INDEX fooi +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX fooi" +== 051 +-- truncate_limit: 100 +CREATE INDEX fooi ON foo (f1 DESC NULLS LAST) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fooi ON foo USING btree (f1 DESC NULLS LAST)" +== 052 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1" +== 053 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 NULLS FIRST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 NULLS FIRST" +== 054 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 DESC +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 DESC" +== 055 +-- truncate_limit: 100 +SELECT * FROM foo ORDER BY f1 DESC NULLS LAST +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo ORDER BY f1 DESC NULLS LAST" +== 056 +-- truncate_limit: 100 +|-- +-- Test planning of some cases with partial indexes +|-- + +-- partial index is usable +explain (costs off) +select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM onek2 WHERE unique2 = 11 AND stringu1 = 'ATAAAA'" +== 057 +-- truncate_limit: 100 +select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM onek2 WHERE unique2 = 11 AND stringu1 = 'ATAAAA'" +== 058 +-- truncate_limit: 100 +-- actually run the query with an analyze to use the partial index +explain (costs off, analyze on, timing off, summary off) +select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, ANALYZE ON, TIMING OFF, SUMMARY OFF) SELECT * FROM onek2 WHERE unique2 = 11 A..." +== 059 +-- truncate_limit: 100 +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 = 'ATAAAA'" +== 060 +-- truncate_limit: 100 +select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 = 'ATAAAA'" +== 061 +-- truncate_limit: 100 +-- partial index predicate implies clause, so no need for retest +explain (costs off) +select * from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM onek2 WHERE unique2 = 11 AND stringu1 < 'B'" +== 062 +-- truncate_limit: 100 +select * from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM onek2 WHERE unique2 = 11 AND stringu1 < 'B'" +== 063 +-- truncate_limit: 100 +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 < 'B'" +== 064 +-- truncate_limit: 100 +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 < 'B'" +== 065 +-- truncate_limit: 100 +-- but if it's an update target, must retest anyway +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 < 'B' FOR UPDATE" +== 066 +-- truncate_limit: 100 +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 < 'B' FOR UPDATE" +== 067 +-- truncate_limit: 100 +-- partial index is not applicable +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 < 'C' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 < 'C'" +== 068 +-- truncate_limit: 100 +select unique2 from onek2 where unique2 = 11 and stringu1 < 'C' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 < 'C'" +== 069 +-- truncate_limit: 100 +-- partial index implies clause, but bitmap scan must recheck predicate anyway +SET enable_indexscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 070 +-- truncate_limit: 100 +explain (costs off) +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 < 'B'" +== 071 +-- truncate_limit: 100 +select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT unique2 FROM onek2 WHERE unique2 = 11 AND stringu1 < 'B'" +== 072 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 073 +-- truncate_limit: 100 +-- check multi-index cases too +explain (costs off) +select unique1, unique2 from onek2 + where (unique2 = 11 or unique1 = 0) and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, unique2 FROM onek2 WHERE (unique2 = 11 OR unique1 = 0) AND st..." +== 074 +-- truncate_limit: 100 +select unique1, unique2 from onek2 + where (unique2 = 11 or unique1 = 0) and stringu1 < 'B' +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM onek2 WHERE (unique2 = 11 OR unique1 = 0) AND stringu1 < 'B'" +== 075 +-- truncate_limit: 100 +explain (costs off) +select unique1, unique2 from onek2 + where (unique2 = 11 and stringu1 < 'B') or unique1 = 0 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1, unique2 FROM onek2 WHERE (unique2 = 11 AND stringu1 < 'B') OR..." +== 076 +-- truncate_limit: 100 +select unique1, unique2 from onek2 + where (unique2 = 11 and stringu1 < 'B') or unique1 = 0 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="stringu1" +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT unique1, unique2 FROM onek2 WHERE (unique2 = 11 AND stringu1 < 'B') OR unique1 = 0" +== 077 +-- truncate_limit: 100 +|-- +-- Test some corner cases that have been known to confuse the planner +|-- + +-- ORDER BY on a constant doesn't really need any sorting +SELECT 1 AS x ORDER BY x +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS x ORDER BY x" +== 078 +-- truncate_limit: 100 +-- But ORDER BY on a set-valued expression does +create function sillysrf(int) returns setof int as + 'values (1),(10),(2),($1)' language sql immutable +-- +FUNCTION: name="sillysrf" function="sillysrf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sillysrf(int) RETURNS SETOF int AS $$values (1),(10),(2),($1)$$ LANGUAGE sql IMMU..." +== 079 +-- truncate_limit: 100 +select sillysrf(42) +-- +FUNCTION: name="sillysrf" function="sillysrf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sillysrf(42)" +== 080 +-- truncate_limit: 100 +select sillysrf(-1) order by 1 +-- +FUNCTION: name="sillysrf" function="sillysrf" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sillysrf(-1) ORDER BY 1" +== 081 +-- truncate_limit: 100 +drop function sillysrf(int) +-- +FUNCTION: name="sillysrf" function="sillysrf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION sillysrf(int)" +== 082 +-- truncate_limit: 100 +-- X = X isn't a no-op, it's effectively X IS NOT NULL assuming = is strict +-- (see bug #5084) +select * from (values (2),(null),(1)) v(k) where k = k order by k +-- +FILTER: schema="" table="" column="k" +FILTER: schema="" table="" column="k" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (2), (NULL), (1)) v(k) WHERE k = k ORDER BY k" +== 083 +-- truncate_limit: 100 +select * from (values (2),(null),(1)) v(k) where k = k +-- +FILTER: schema="" table="" column="k" +FILTER: schema="" table="" column="k" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (2), (NULL), (1)) v(k) WHERE k = k" +== 084 +-- truncate_limit: 100 +-- Test partitioned tables with no partitions, which should be handled the +-- same as the non-inheritance case when expanding its RTE. +create table list_parted_tbl (a int,b int) partition by list (a) +-- +TABLE: name="list_parted_tbl" schema="" table="list_parted_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted_tbl (a int, b int) PARTITION BY LIST (a)" +== 085 +-- truncate_limit: 100 +create table list_parted_tbl1 partition of list_parted_tbl + for values in (1) partition by list(b) +-- +TABLE: name="list_parted_tbl1" schema="" table="list_parted_tbl1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted_tbl1 PARTITION OF list_parted_tbl FOR VALUES IN (1) PARTITION BY LIST (b)" +== 086 +-- truncate_limit: 100 +explain (costs off) select * from list_parted_tbl +-- +TABLE: name="list_parted_tbl" schema="" table="list_parted_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM list_parted_tbl" +== 087 +-- truncate_limit: 100 +drop table list_parted_tbl +-- +TABLE: name="list_parted_tbl" schema="" table="list_parted_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE list_parted_tbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/select_distinct.metadata.json b/parser/testdata/summary_truncate/postgres_regress/select_distinct.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_distinct.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/select_distinct.test b/parser/testdata/summary_truncate/postgres_regress/select_distinct.test new file mode 100644 index 0000000..03242fb --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_distinct.test @@ -0,0 +1,639 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SELECT_DISTINCT +|-- + +|-- +-- awk '{print $3;}' onek.data | sort -n | uniq +|-- +SELECT DISTINCT two FROM onek ORDER BY 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT two FROM onek ORDER BY 1" +== 002 +-- truncate_limit: 100 +|-- +-- awk '{print $5;}' onek.data | sort -n | uniq +|-- +SELECT DISTINCT ten FROM onek ORDER BY 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ten FROM onek ORDER BY 1" +== 003 +-- truncate_limit: 100 +|-- +-- awk '{print $16;}' onek.data | sort -d | uniq +|-- +SELECT DISTINCT string4 FROM onek ORDER BY 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT string4 FROM onek ORDER BY 1" +== 004 +-- truncate_limit: 100 +|-- +-- awk '{print $3,$16,$5;}' onek.data | sort -d | uniq | +-- sort +0n -1 +1d -2 +2n -3 +|-- +SELECT DISTINCT two, string4, ten + FROM onek + ORDER BY two using <, string4 using <, ten using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT two, string4, ten FROM onek ORDER BY two USING <, string4 USING <, ten USING <" +== 005 +-- truncate_limit: 100 +|-- +-- awk '{print $2;}' person.data | +-- awk '{if(NF!=1){print $2;}else{print;}}' - emp.data | +-- awk '{if(NF!=1){print $2;}else{print;}}' - student.data | +-- awk 'BEGIN{FS=" ";}{if(NF!=1){print $5;}else{print;}}' - stud_emp.data | +-- sort -n -r | uniq +|-- +SELECT DISTINCT p.age FROM person* p ORDER BY age using > +-- +TABLE: name="person" schema="" table="person" ctx=Select +ALIAS: "p"="person" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT p.age FROM person p ORDER BY age USING >" +== 006 +-- truncate_limit: 100 +|-- +-- Check mentioning same column more than once +|-- + +EXPLAIN (VERBOSE, COSTS OFF) +SELECT count(*) FROM + (SELECT DISTINCT two, four, two FROM tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM (SELECT DISTINCT two, four, two FROM tenk1) ss" +== 007 +-- truncate_limit: 100 +SELECT count(*) FROM + (SELECT DISTINCT two, four, two FROM tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT DISTINCT two, four, two FROM tenk1) ss" +== 008 +-- truncate_limit: 100 +|-- +-- Compare results between plans using sorting and plans using hash +-- aggregation. Force spilling in both cases by setting work_mem low. +|-- + +SET work_mem='64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 009 +-- truncate_limit: 100 +-- Produce results with sorting. + +SET enable_hashagg=FALSE +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 010 +-- truncate_limit: 100 +SET jit_above_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO 0" +== 011 +-- truncate_limit: 100 +EXPLAIN (costs off) +SELECT DISTINCT g%1000 FROM generate_series(0,9999) g +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT g % 1000 FROM generate_series(0, 9999) g" +== 012 +-- truncate_limit: 100 +CREATE TABLE distinct_group_1 AS +SELECT DISTINCT g%1000 FROM generate_series(0,9999) g +-- +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE distinct_group_1 AS SELECT DISTINCT g % 1000 FROM generate_series(0, 9999) g" +== 013 +-- truncate_limit: 100 +SET jit_above_cost TO DEFAULT +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO DEFAULT" +== 014 +-- truncate_limit: 100 +CREATE TABLE distinct_group_2 AS +SELECT DISTINCT (g%1000)::text FROM generate_series(0,9999) g +-- +TABLE: name="distinct_group_2" schema="" table="distinct_group_2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE distinct_group_2 AS SELECT DISTINCT (g % 1000)::text FROM generate_series(0, 9999) g" +== 015 +-- truncate_limit: 100 +SET enable_seqscan = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO 0" +== 016 +-- truncate_limit: 100 +-- Check to see we get an incremental sort plan +EXPLAIN (costs off) +SELECT DISTINCT hundred, two FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT hundred, two FROM tenk1" +== 017 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 018 +-- truncate_limit: 100 +SET enable_hashagg=TRUE +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO TRUE" +== 019 +-- truncate_limit: 100 +-- Produce results with hash aggregation. + +SET enable_sort=FALSE +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO FALSE" +== 020 +-- truncate_limit: 100 +SET jit_above_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO 0" +== 021 +-- truncate_limit: 100 +EXPLAIN (costs off) +SELECT DISTINCT g%1000 FROM generate_series(0,9999) g +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT g % 1000 FROM generate_series(0, 9999) g" +== 022 +-- truncate_limit: 100 +CREATE TABLE distinct_hash_1 AS +SELECT DISTINCT g%1000 FROM generate_series(0,9999) g +-- +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE distinct_hash_1 AS SELECT DISTINCT g % 1000 FROM generate_series(0, 9999) g" +== 023 +-- truncate_limit: 100 +SET jit_above_cost TO DEFAULT +-- +STMT: VariableSetStmt +TRUNCATED: "SET jit_above_cost TO DEFAULT" +== 024 +-- truncate_limit: 100 +CREATE TABLE distinct_hash_2 AS +SELECT DISTINCT (g%1000)::text FROM generate_series(0,9999) g +-- +TABLE: name="distinct_hash_2" schema="" table="distinct_hash_2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE distinct_hash_2 AS SELECT DISTINCT (g % 1000)::text FROM generate_series(0, 9999) g" +== 025 +-- truncate_limit: 100 +SET enable_sort=TRUE +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO TRUE" +== 026 +-- truncate_limit: 100 +SET work_mem TO DEFAULT +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO DEFAULT" +== 027 +-- truncate_limit: 100 +-- Compare results + +(SELECT * FROM distinct_hash_1 EXCEPT SELECT * FROM distinct_group_1) + UNION ALL +(SELECT * FROM distinct_group_1 EXCEPT SELECT * FROM distinct_hash_1) +-- +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=Select +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=Select +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=Select +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM distinct_hash_1 EXCEPT SELECT * FROM distinct_group_1) UNION ALL (SELECT * FROM di..." +== 028 +-- truncate_limit: 100 +(SELECT * FROM distinct_hash_1 EXCEPT SELECT * FROM distinct_group_1) + UNION ALL +(SELECT * FROM distinct_group_1 EXCEPT SELECT * FROM distinct_hash_1) +-- +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=Select +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=Select +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=Select +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT * FROM distinct_hash_1 EXCEPT SELECT * FROM distinct_group_1) UNION ALL (SELECT * FROM di..." +== 029 +-- truncate_limit: 100 +DROP TABLE distinct_hash_1 +-- +TABLE: name="distinct_hash_1" schema="" table="distinct_hash_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE distinct_hash_1" +== 030 +-- truncate_limit: 100 +DROP TABLE distinct_hash_2 +-- +TABLE: name="distinct_hash_2" schema="" table="distinct_hash_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE distinct_hash_2" +== 031 +-- truncate_limit: 100 +DROP TABLE distinct_group_1 +-- +TABLE: name="distinct_group_1" schema="" table="distinct_group_1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE distinct_group_1" +== 032 +-- truncate_limit: 100 +DROP TABLE distinct_group_2 +-- +TABLE: name="distinct_group_2" schema="" table="distinct_group_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE distinct_group_2" +== 033 +-- truncate_limit: 100 +-- Test parallel DISTINCT +SET parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 034 +-- truncate_limit: 100 +SET parallel_setup_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 035 +-- truncate_limit: 100 +SET min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 036 +-- truncate_limit: 100 +SET max_parallel_workers_per_gather=2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 037 +-- truncate_limit: 100 +-- Ensure we get a parallel plan +EXPLAIN (costs off) +SELECT DISTINCT four FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT four FROM tenk1" +== 038 +-- truncate_limit: 100 +-- Ensure the parallel plan produces the correct results +SELECT DISTINCT four FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT four FROM tenk1" +== 039 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION distinct_func(a INT) RETURNS INT AS $$ + BEGIN + RETURN a; + END; +$$ LANGUAGE plpgsql PARALLEL UNSAFE +-- +FUNCTION: name="distinct_func" function="distinct_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION distinct_func(a int) RETURNS int AS $$\n BEGIN\n RETURN a;\n END;\n$$..." +== 040 +-- truncate_limit: 100 +-- Ensure we don't do parallel distinct with a parallel unsafe function +EXPLAIN (COSTS OFF) +SELECT DISTINCT distinct_func(1) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="distinct_func" function="distinct_func" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT distinct_func(1) FROM tenk1" +== 041 +-- truncate_limit: 100 +-- make the function parallel safe +CREATE OR REPLACE FUNCTION distinct_func(a INT) RETURNS INT AS $$ + BEGIN + RETURN a; + END; +$$ LANGUAGE plpgsql PARALLEL SAFE +-- +FUNCTION: name="distinct_func" function="distinct_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION distinct_func(a int) RETURNS int AS $$\n BEGIN\n RETURN a;\n END;\n$$..." +== 042 +-- truncate_limit: 100 +-- Ensure we do parallel distinct now that the function is parallel safe +EXPLAIN (COSTS OFF) +SELECT DISTINCT distinct_func(1) FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="distinct_func" function="distinct_func" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT distinct_func(1) FROM tenk1" +== 043 +-- truncate_limit: 100 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers_per_gather" +== 044 +-- truncate_limit: 100 +RESET min_parallel_table_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_table_scan_size" +== 045 +-- truncate_limit: 100 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 046 +-- truncate_limit: 100 +RESET parallel_tuple_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_tuple_cost" +== 047 +-- truncate_limit: 100 +|-- +-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when +-- all of the distinct_pathkeys have been marked as redundant +|-- + +-- Ensure we get a plan with a Limit 1 +EXPLAIN (COSTS OFF) +SELECT DISTINCT four FROM tenk1 WHERE four = 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT four FROM tenk1 WHERE four = 0" +== 048 +-- truncate_limit: 100 +-- Ensure the above gives us the correct result +SELECT DISTINCT four FROM tenk1 WHERE four = 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT four FROM tenk1 WHERE four = 0" +== 049 +-- truncate_limit: 100 +-- Ensure we get a plan with a Limit 1 +EXPLAIN (COSTS OFF) +SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="two" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0" +== 050 +-- truncate_limit: 100 +-- Ensure no rows are returned +SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="two" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT four FROM tenk1 WHERE four = 0 AND two <> 0" +== 051 +-- truncate_limit: 100 +-- Ensure we get a plan with a Limit 1 when the SELECT list contains constants +EXPLAIN (COSTS OFF) +SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT four, 1, 2, 3 FROM tenk1 WHERE four = 0" +== 052 +-- truncate_limit: 100 +-- Ensure we only get 1 row +SELECT DISTINCT four,1,2,3 FROM tenk1 WHERE four = 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT four, 1, 2, 3 FROM tenk1 WHERE four = 0" +== 053 +-- truncate_limit: 100 +SET parallel_setup_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 054 +-- truncate_limit: 100 +SET min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 055 +-- truncate_limit: 100 +SET max_parallel_workers_per_gather=2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 2" +== 056 +-- truncate_limit: 100 +-- Ensure we get a plan with a Limit 1 in both partial distinct and final +-- distinct +EXPLAIN (COSTS OFF) +SELECT DISTINCT four FROM tenk1 WHERE four = 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT four FROM tenk1 WHERE four = 10" +== 057 +-- truncate_limit: 100 +RESET max_parallel_workers_per_gather +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers_per_gather" +== 058 +-- truncate_limit: 100 +RESET min_parallel_table_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_table_scan_size" +== 059 +-- truncate_limit: 100 +RESET parallel_setup_cost +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_setup_cost" +== 060 +-- truncate_limit: 100 +|-- +-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its +-- very own regression file. +|-- + +CREATE TEMP TABLE disttable (f1 integer) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE disttable (f1 int)" +== 061 +-- truncate_limit: 100 +INSERT INTO DISTTABLE VALUES(1) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO disttable VALUES (1)" +== 062 +-- truncate_limit: 100 +INSERT INTO DISTTABLE VALUES(2) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO disttable VALUES (2)" +== 063 +-- truncate_limit: 100 +INSERT INTO DISTTABLE VALUES(3) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO disttable VALUES (3)" +== 064 +-- truncate_limit: 100 +INSERT INTO DISTTABLE VALUES(NULL) +-- +TABLE: name="disttable" schema="" table="disttable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO disttable VALUES (NULL)" +== 065 +-- truncate_limit: 100 +-- basic cases +SELECT f1, f1 IS DISTINCT FROM 2 as "not 2" FROM disttable +-- +TABLE: name="disttable" schema="" table="disttable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1 IS DISTINCT FROM 2 AS \"not 2\" FROM disttable" +== 066 +-- truncate_limit: 100 +SELECT f1, f1 IS DISTINCT FROM NULL as "not null" FROM disttable +-- +TABLE: name="disttable" schema="" table="disttable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1 IS DISTINCT FROM NULL AS \"not null\" FROM disttable" +== 067 +-- truncate_limit: 100 +SELECT f1, f1 IS DISTINCT FROM f1 as "false" FROM disttable +-- +TABLE: name="disttable" schema="" table="disttable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1 IS DISTINCT FROM f1 AS \"false\" FROM disttable" +== 068 +-- truncate_limit: 100 +SELECT f1, f1 IS DISTINCT FROM f1+1 as "not null" FROM disttable +-- +TABLE: name="disttable" schema="" table="disttable" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1, f1 IS DISTINCT FROM (f1 + 1) AS \"not null\" FROM disttable" +== 069 +-- truncate_limit: 100 +-- check that optimizer constant-folds it properly +SELECT 1 IS DISTINCT FROM 2 as "yes" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 IS DISTINCT FROM 2 AS yes" +== 070 +-- truncate_limit: 100 +SELECT 2 IS DISTINCT FROM 2 as "no" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 IS DISTINCT FROM 2 AS no" +== 071 +-- truncate_limit: 100 +SELECT 2 IS DISTINCT FROM null as "yes" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 IS DISTINCT FROM NULL AS yes" +== 072 +-- truncate_limit: 100 +SELECT null IS DISTINCT FROM null as "no" +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL IS DISTINCT FROM NULL AS no" +== 073 +-- truncate_limit: 100 +-- negated form +SELECT 1 IS NOT DISTINCT FROM 2 as "no" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 IS NOT DISTINCT FROM 2 AS no" +== 074 +-- truncate_limit: 100 +SELECT 2 IS NOT DISTINCT FROM 2 as "yes" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 IS NOT DISTINCT FROM 2 AS yes" +== 075 +-- truncate_limit: 100 +SELECT 2 IS NOT DISTINCT FROM null as "no" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 IS NOT DISTINCT FROM NULL AS no" +== 076 +-- truncate_limit: 100 +SELECT null IS NOT DISTINCT FROM null as "yes" +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL IS NOT DISTINCT FROM NULL AS yes" diff --git a/parser/testdata/summary_truncate/postgres_regress/select_distinct_on.metadata.json b/parser/testdata/summary_truncate/postgres_regress/select_distinct_on.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_distinct_on.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/select_distinct_on.test b/parser/testdata/summary_truncate/postgres_regress/select_distinct_on.test new file mode 100644 index 0000000..2de8bee --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_distinct_on.test @@ -0,0 +1,94 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SELECT_DISTINCT_ON +|-- + +SELECT DISTINCT ON (string4) string4, two, ten + FROM onek + ORDER BY string4 using <, two using >, ten using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (string4) ... AS ... FROM onek ORDER BY string4 USING <, two USING >, ten USING <" +== 002 +-- truncate_limit: 100 +-- this will fail due to conflict of ordering requirements +SELECT DISTINCT ON (string4, ten) string4, two, ten + FROM onek + ORDER BY string4 using <, two using <, ten using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (string4, ten) ... AS ... FROM onek ORDER BY string4 USING <, two USING <, ten..." +== 003 +-- truncate_limit: 100 +SELECT DISTINCT ON (string4, ten) string4, ten, two + FROM onek + ORDER BY string4 using <, ten using >, two using < +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (string4, ten) ... AS ... FROM onek ORDER BY string4 USING <, ten USING >, two..." +== 004 +-- truncate_limit: 100 +-- bug #5049: early 8.4.x chokes on volatile DISTINCT ON clauses +select distinct on (1) floor(random()) as r, f1 from int4_tbl order by 1,2 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="floor" function="floor" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (1) floor(random()) AS r, f1 FROM int4_tbl ORDER BY 1, 2" +== 005 +-- truncate_limit: 100 +|-- +-- Test the planner's ability to use a LIMIT 1 instead of a Unique node when +-- all of the distinct_pathkeys have been marked as redundant +|-- + +-- Ensure we also get a LIMIT plan with DISTINCT ON +EXPLAIN (COSTS OFF) +SELECT DISTINCT ON (four) four,two + FROM tenk1 WHERE four = 0 ORDER BY 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT ON (four) four, two FROM tenk1 WHERE four = 0 ORDER BY 1" +== 006 +-- truncate_limit: 100 +-- and check the result of the above query is correct +SELECT DISTINCT ON (four) four,two + FROM tenk1 WHERE four = 0 ORDER BY 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (four) four, two FROM tenk1 WHERE four = 0 ORDER BY 1" +== 007 +-- truncate_limit: 100 +-- Ensure a Sort -> Limit is used when the ORDER BY contains additional cols +EXPLAIN (COSTS OFF) +SELECT DISTINCT ON (four) four,two + FROM tenk1 WHERE four = 0 ORDER BY 1,2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT ON (four) four, two FROM tenk1 WHERE four = 0 ORDER BY 1, 2" +== 008 +-- truncate_limit: 100 +-- Same again but use a column that is indexed so that we get an index scan +-- then a limit +EXPLAIN (COSTS OFF) +SELECT DISTINCT ON (four) four,hundred + FROM tenk1 WHERE four = 0 ORDER BY 1,2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT ON (four) four, hundred FROM tenk1 WHERE four = 0 ORDER BY 1, 2" diff --git a/parser/testdata/summary_truncate/postgres_regress/select_having.metadata.json b/parser/testdata/summary_truncate/postgres_regress/select_having.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_having.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/select_having.test b/parser/testdata/summary_truncate/postgres_regress/select_having.test new file mode 100644 index 0000000..336b52b --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_having.test @@ -0,0 +1,212 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SELECT_HAVING +|-- + +-- load test data +CREATE TABLE test_having (a int, b int, c char(8), d char) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_having (a int, b int, c char(8), d char(1))" +== 002 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (0, 1, 'XXXX', 'A') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (0, 1, 'XXXX', 'A')" +== 003 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (1, 2, 'AAAA', 'b') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (1, 2, 'AAAA', 'b')" +== 004 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (2, 2, 'AAAA', 'c') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (2, 2, 'AAAA', 'c')" +== 005 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (3, 3, 'BBBB', 'D') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (3, 3, 'BBBB', 'D')" +== 006 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (4, 3, 'BBBB', 'e') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (4, 3, 'BBBB', 'e')" +== 007 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (5, 3, 'bbbb', 'F') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (5, 3, 'bbbb', 'F')" +== 008 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (6, 4, 'cccc', 'g') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (6, 4, 'cccc', 'g')" +== 009 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (7, 4, 'cccc', 'h') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (7, 4, 'cccc', 'h')" +== 010 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (8, 4, 'CCCC', 'I') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (8, 4, 'CCCC', 'I')" +== 011 +-- truncate_limit: 100 +INSERT INTO test_having VALUES (9, 4, 'CCCC', 'j') +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_having VALUES (9, 4, 'CCCC', 'j')" +== 012 +-- truncate_limit: 100 +SELECT b, c FROM test_having + GROUP BY b, c HAVING count(*) = 1 ORDER BY b, c +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT b, c FROM test_having GROUP BY b, c HAVING count(*) = 1 ORDER BY b, c" +== 013 +-- truncate_limit: 100 +-- HAVING is effectively equivalent to WHERE in this case +SELECT b, c FROM test_having + GROUP BY b, c HAVING b = 3 ORDER BY b, c +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT b, c FROM test_having GROUP BY b, c HAVING b = 3 ORDER BY b, c" +== 014 +-- truncate_limit: 100 +SELECT lower(c), count(c) FROM test_having + GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a) + ORDER BY lower(c) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_having GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a) ORDER BY low..." +== 015 +-- truncate_limit: 100 +SELECT c, max(a) FROM test_having + GROUP BY c HAVING count(*) > 2 OR min(a) = max(a) + ORDER BY c +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c, max(a) FROM test_having GROUP BY c HAVING count(*) > 2 OR min(a) = max(a) ORDER BY c" +== 016 +-- truncate_limit: 100 +-- test degenerate cases involving HAVING without GROUP BY +-- Per SQL spec, these should generate 0 or 1 row, even without aggregates + +SELECT min(a), max(a) FROM test_having HAVING min(a) = max(a) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(a), max(a) FROM test_having HAVING min(a) = max(a)" +== 017 +-- truncate_limit: 100 +SELECT min(a), max(a) FROM test_having HAVING min(a) < max(a) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(a), max(a) FROM test_having HAVING min(a) < max(a)" +== 018 +-- truncate_limit: 100 +-- errors: ungrouped column references +SELECT a FROM test_having HAVING min(a) < max(a) +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a FROM test_having HAVING min(a) < max(a)" +== 019 +-- truncate_limit: 100 +SELECT 1 AS one FROM test_having HAVING a > 1 +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one FROM test_having HAVING a > 1" +== 020 +-- truncate_limit: 100 +-- the really degenerate case: need not scan table at all +SELECT 1 AS one FROM test_having HAVING 1 > 2 +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one FROM test_having HAVING 1 > 2" +== 021 +-- truncate_limit: 100 +SELECT 1 AS one FROM test_having HAVING 1 < 2 +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one FROM test_having HAVING 1 < 2" +== 022 +-- truncate_limit: 100 +-- and just to prove that we aren't scanning the table: +SELECT 1 AS one FROM test_having WHERE 1/a = 1 HAVING 1 < 2 +-- +TABLE: name="test_having" schema="" table="test_having" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one FROM test_having WHERE (1 / a) = 1 HAVING 1 < 2" +== 023 +-- truncate_limit: 100 +DROP TABLE test_having +-- +TABLE: name="test_having" schema="" table="test_having" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_having" diff --git a/parser/testdata/summary_truncate/postgres_regress/select_implicit.metadata.json b/parser/testdata/summary_truncate/postgres_regress/select_implicit.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_implicit.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/select_implicit.test b/parser/testdata/summary_truncate/postgres_regress/select_implicit.test new file mode 100644 index 0000000..8d0f38d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_implicit.test @@ -0,0 +1,472 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SELECT_IMPLICIT +-- Test cases for queries with ordering terms missing from the target list. +-- This used to be called "junkfilter.sql". +-- The parser uses the term "resjunk" to handle these cases. +-- - thomas 1998-07-09 +|-- + +-- load test data +CREATE TABLE test_missing_target (a int, b int, c char(8), d char) +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_missing_target (a int, b int, c char(8), d char(1))" +== 002 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (0, 1, 'XXXX', 'A') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (0, 1, 'XXXX', 'A')" +== 003 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (1, 2, 'ABAB', 'b') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (1, 2, 'ABAB', 'b')" +== 004 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (2, 2, 'ABAB', 'c') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (2, 2, 'ABAB', 'c')" +== 005 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (3, 3, 'BBBB', 'D') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (3, 3, 'BBBB', 'D')" +== 006 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (4, 3, 'BBBB', 'e') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (4, 3, 'BBBB', 'e')" +== 007 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (5, 3, 'bbbb', 'F') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (5, 3, 'bbbb', 'F')" +== 008 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (6, 4, 'cccc', 'g') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (6, 4, 'cccc', 'g')" +== 009 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (7, 4, 'cccc', 'h') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (7, 4, 'cccc', 'h')" +== 010 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (8, 4, 'CCCC', 'I') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (8, 4, 'CCCC', 'I')" +== 011 +-- truncate_limit: 100 +INSERT INTO test_missing_target VALUES (9, 4, 'CCCC', 'j') +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_missing_target VALUES (9, 4, 'CCCC', 'j')" +== 012 +-- truncate_limit: 100 +-- w/ existing GROUP BY target +SELECT c, count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY c +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c, count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY c" +== 013 +-- truncate_limit: 100 +-- w/o existing GROUP BY target using a relation name in GROUP BY clause +SELECT count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY c +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_missing_target GROUP BY test_missing_target.c ORDER BY c" +== 014 +-- truncate_limit: 100 +-- w/o existing GROUP BY target and w/o existing a different ORDER BY target +-- failure expected +SELECT count(*) FROM test_missing_target GROUP BY a ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_missing_target GROUP BY a ORDER BY b" +== 015 +-- truncate_limit: 100 +-- w/o existing GROUP BY target and w/o existing same ORDER BY target +SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b" +== 016 +-- truncate_limit: 100 +-- w/ existing GROUP BY target using a relation name in target +SELECT test_missing_target.b, count(*) + FROM test_missing_target GROUP BY b ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT test_missing_target.b, count(*) FROM test_missing_target GROUP BY b ORDER BY b" +== 017 +-- truncate_limit: 100 +-- w/o existing GROUP BY target +SELECT c FROM test_missing_target ORDER BY a +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT c FROM test_missing_target ORDER BY a" +== 018 +-- truncate_limit: 100 +-- w/o existing ORDER BY target +SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b desc +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_missing_target GROUP BY b ORDER BY b DESC" +== 019 +-- truncate_limit: 100 +-- group using reference number +SELECT count(*) FROM test_missing_target ORDER BY 1 desc +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_missing_target ORDER BY 1 DESC" +== 020 +-- truncate_limit: 100 +-- order using reference number +SELECT c, count(*) FROM test_missing_target GROUP BY 1 ORDER BY 1 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c, count(*) FROM test_missing_target GROUP BY 1 ORDER BY 1" +== 021 +-- truncate_limit: 100 +-- group using reference number out of range +-- failure expected +SELECT c, count(*) FROM test_missing_target GROUP BY 3 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT c, count(*) FROM test_missing_target GROUP BY 3" +== 022 +-- truncate_limit: 100 +-- group w/o existing GROUP BY and ORDER BY target under ambiguous condition +-- failure expected +SELECT count(*) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY b ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_missing_target x, test_missing_target y WHERE ... GROUP BY b ORDER BY b" +== 023 +-- truncate_limit: 100 +-- order w/ target under ambiguous condition +-- failure NOT expected +SELECT a, a FROM test_missing_target + ORDER BY a +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, a FROM test_missing_target ORDER BY a" +== 024 +-- truncate_limit: 100 +-- order expression w/ target under ambiguous condition +-- failure NOT expected +SELECT a/2, a/2 FROM test_missing_target + ORDER BY a/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a / 2, a / 2 FROM test_missing_target ORDER BY a / 2" +== 025 +-- truncate_limit: 100 +-- group expression w/ target under ambiguous condition +-- failure NOT expected +SELECT a/2, a/2 FROM test_missing_target + GROUP BY a/2 ORDER BY a/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a / 2, a / 2 FROM test_missing_target GROUP BY a / 2 ORDER BY a / 2" +== 026 +-- truncate_limit: 100 +-- group w/ existing GROUP BY target under ambiguous condition +SELECT x.b, count(*) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b ORDER BY x.b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_missing_target x, test_missing_target y WHERE ... GROUP BY x.b ORDER BY x.b" +== 027 +-- truncate_limit: 100 +-- group w/o existing GROUP BY target under ambiguous condition +SELECT count(*) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b ORDER BY x.b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_missing_target x, test_missing_target y WHERE ... GROUP BY x.b ORDER BY x.b" +== 028 +-- truncate_limit: 100 +-- group w/o existing GROUP BY target under ambiguous condition +-- into a table +CREATE TABLE test_missing_target2 AS +SELECT count(*) +FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b ORDER BY x.b +-- +TABLE: name="test_missing_target2" schema="" table="test_missing_target2" ctx=DDL +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test_missing_target2 AS SELECT count(*) FROM test_missing_target x, test_missing_tar..." +== 029 +-- truncate_limit: 100 +SELECT * FROM test_missing_target2 +-- +TABLE: name="test_missing_target2" schema="" table="test_missing_target2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_missing_target2" +== 030 +-- truncate_limit: 100 +-- Functions and expressions + +-- w/ existing GROUP BY target +SELECT a%2, count(b) FROM test_missing_target +GROUP BY test_missing_target.a%2 +ORDER BY test_missing_target.a%2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_missing_target GROUP BY test_missing_target.a % 2 ORDER BY test_missing_targ..." +== 031 +-- truncate_limit: 100 +-- w/o existing GROUP BY target using a relation name in GROUP BY clause +SELECT count(c) FROM test_missing_target +GROUP BY lower(test_missing_target.c) +ORDER BY lower(test_missing_target.c) +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_missing_target GROUP BY lower(test_missing_target.c) ORDER BY lower(test_mis..." +== 032 +-- truncate_limit: 100 +-- w/o existing GROUP BY target and w/o existing a different ORDER BY target +-- failure expected +SELECT count(a) FROM test_missing_target GROUP BY a ORDER BY b +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(a) FROM test_missing_target GROUP BY a ORDER BY b" +== 033 +-- truncate_limit: 100 +-- w/o existing GROUP BY target and w/o existing same ORDER BY target +SELECT count(b) FROM test_missing_target GROUP BY b/2 ORDER BY b/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(b) FROM test_missing_target GROUP BY b / 2 ORDER BY b / 2" +== 034 +-- truncate_limit: 100 +-- w/ existing GROUP BY target using a relation name in target +SELECT lower(test_missing_target.c), count(c) + FROM test_missing_target GROUP BY lower(c) ORDER BY lower(c) +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_missing_target GROUP BY lower(c) ORDER BY lower(c)" +== 035 +-- truncate_limit: 100 +-- w/o existing GROUP BY target +SELECT a FROM test_missing_target ORDER BY upper(d) +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a FROM test_missing_target ORDER BY upper(d)" +== 036 +-- truncate_limit: 100 +-- w/o existing ORDER BY target +SELECT count(b) FROM test_missing_target + GROUP BY (b + 1) / 2 ORDER BY (b + 1) / 2 desc +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(b) FROM test_missing_target GROUP BY (b + 1) / 2 ORDER BY (b + 1) / 2 DESC" +== 037 +-- truncate_limit: 100 +-- group w/o existing GROUP BY and ORDER BY target under ambiguous condition +-- failure expected +SELECT count(x.a) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY b/2 ORDER BY b/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_missing_target x, test_missing_target y WHERE ... GROUP BY b / 2 ORDER BY b / 2" +== 038 +-- truncate_limit: 100 +-- group w/ existing GROUP BY target under ambiguous condition +SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b/2 ORDER BY x.b/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_missing_target x, test_missing_target y WHERE ... GROUP BY x.b / 2 ORDER BY ..." +== 039 +-- truncate_limit: 100 +-- group w/o existing GROUP BY target under ambiguous condition +-- failure expected due to ambiguous b in count(b) +SELECT count(b) FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b/2 +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(b) FROM test_missing_target x, test_missing_target y WHERE x.a = y.a GROUP BY x.b / 2" +== 040 +-- truncate_limit: 100 +-- group w/o existing GROUP BY target under ambiguous condition +-- into a table +CREATE TABLE test_missing_target3 AS +SELECT count(x.b) +FROM test_missing_target x, test_missing_target y + WHERE x.a = y.a + GROUP BY x.b/2 ORDER BY x.b/2 +-- +TABLE: name="test_missing_target3" schema="" table="test_missing_target3" ctx=DDL +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=Select +ALIAS: "x"="test_missing_target" +ALIAS: "y"="test_missing_target" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="x" column="a" +FILTER: schema="" table="y" column="a" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test_missing_target3 AS SELECT count(x.b) FROM test_missing_target x, test_missing_t..." +== 041 +-- truncate_limit: 100 +SELECT * FROM test_missing_target3 +-- +TABLE: name="test_missing_target3" schema="" table="test_missing_target3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM test_missing_target3" +== 042 +-- truncate_limit: 100 +-- Cleanup +DROP TABLE test_missing_target +-- +TABLE: name="test_missing_target" schema="" table="test_missing_target" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_missing_target" +== 043 +-- truncate_limit: 100 +DROP TABLE test_missing_target2 +-- +TABLE: name="test_missing_target2" schema="" table="test_missing_target2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_missing_target2" +== 044 +-- truncate_limit: 100 +DROP TABLE test_missing_target3 +-- +TABLE: name="test_missing_target3" schema="" table="test_missing_target3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_missing_target3" diff --git a/parser/testdata/summary_truncate/postgres_regress/select_into.metadata.json b/parser/testdata/summary_truncate/postgres_regress/select_into.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_into.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/select_into.test b/parser/testdata/summary_truncate/postgres_regress/select_into.test new file mode 100644 index 0000000..dce605d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_into.test @@ -0,0 +1,583 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SELECT_INTO +|-- + +SELECT * + INTO TABLE sitmp1 + FROM onek + WHERE onek.unique1 < 2 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="sitmp1" schema="" table="sitmp1" ctx=DDL +FILTER: schema="" table="onek" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT * INTO sitmp1 FROM onek WHERE onek.unique1 < 2" +== 002 +-- truncate_limit: 100 +DROP TABLE sitmp1 +-- +TABLE: name="sitmp1" schema="" table="sitmp1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sitmp1" +== 003 +-- truncate_limit: 100 +SELECT * + INTO TABLE sitmp1 + FROM onek2 + WHERE onek2.unique1 < 2 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=Select +TABLE: name="sitmp1" schema="" table="sitmp1" ctx=DDL +FILTER: schema="" table="onek2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT * INTO sitmp1 FROM onek2 WHERE onek2.unique1 < 2" +== 004 +-- truncate_limit: 100 +DROP TABLE sitmp1 +-- +TABLE: name="sitmp1" schema="" table="sitmp1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sitmp1" +== 005 +-- truncate_limit: 100 +|-- +-- SELECT INTO and INSERT permission, if owner is not allowed to insert. +|-- +CREATE SCHEMA selinto_schema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA selinto_schema" +== 006 +-- truncate_limit: 100 +CREATE USER regress_selinto_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_selinto_user" +== 007 +-- truncate_limit: 100 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_selinto_user + REVOKE INSERT ON TABLES FROM regress_selinto_user +-- +STMT: AlterDefaultPrivilegesStmt +TRUNCATED: "ALTER DEFAULT PRIVILEGES FOR ROLE regress_selinto_user REVOKE insert ON TABLES FROM regress_selin..." +== 008 +-- truncate_limit: 100 +GRANT ALL ON SCHEMA selinto_schema TO public +-- +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON SCHEMA selinto_schema TO public" +== 009 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_selinto_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_selinto_user" +== 010 +-- truncate_limit: 100 +-- WITH DATA, passes. +CREATE TABLE selinto_schema.tbl_withdata1 (a) + AS SELECT generate_series(1,3) WITH DATA +-- +TABLE: name="selinto_schema.tbl_withdata1" schema="selinto_schema" table="tbl_withdata1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE selinto_schema.tbl_withdata1(a) AS SELECT generate_series(1, 3)" +== 011 +-- truncate_limit: 100 +INSERT INTO selinto_schema.tbl_withdata1 VALUES (4) +-- +TABLE: name="selinto_schema.tbl_withdata1" schema="selinto_schema" table="tbl_withdata1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO selinto_schema.tbl_withdata1 VALUES (4)" +== 012 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE selinto_schema.tbl_withdata2 (a) AS + SELECT generate_series(1,3) WITH DATA +-- +TABLE: name="selinto_schema.tbl_withdata2" schema="selinto_schema" table="tbl_withdata2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE selinto_schema.tbl_withdata2(a..." +== 013 +-- truncate_limit: 100 +-- WITH NO DATA, passes. +CREATE TABLE selinto_schema.tbl_nodata1 (a) AS + SELECT generate_series(1,3) WITH NO DATA +-- +TABLE: name="selinto_schema.tbl_nodata1" schema="selinto_schema" table="tbl_nodata1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE selinto_schema.tbl_nodata1(a) AS SELECT generate_series(1, 3) WITH NO DATA" +== 014 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE selinto_schema.tbl_nodata2 (a) AS + SELECT generate_series(1,3) WITH NO DATA +-- +TABLE: name="selinto_schema.tbl_nodata2" schema="selinto_schema" table="tbl_nodata2" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE selinto_schema.tbl_nodata2(a) ..." +== 015 +-- truncate_limit: 100 +-- EXECUTE and WITH DATA, passes. +PREPARE data_sel AS SELECT generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE data_sel AS SELECT generate_series(1, 3)" +== 016 +-- truncate_limit: 100 +CREATE TABLE selinto_schema.tbl_withdata3 (a) AS + EXECUTE data_sel WITH DATA +-- +TABLE: name="selinto_schema.tbl_withdata3" schema="selinto_schema" table="tbl_withdata3" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TABLE selinto_schema.tbl_withdata3(a) AS EXECUTE data_sel" +== 017 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE selinto_schema.tbl_withdata4 (a) AS + EXECUTE data_sel WITH DATA +-- +TABLE: name="selinto_schema.tbl_withdata4" schema="selinto_schema" table="tbl_withdata4" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE selinto_schema.tbl_withdata4(a..." +== 018 +-- truncate_limit: 100 +-- EXECUTE and WITH NO DATA, passes. +CREATE TABLE selinto_schema.tbl_nodata3 (a) AS + EXECUTE data_sel WITH NO DATA +-- +TABLE: name="selinto_schema.tbl_nodata3" schema="selinto_schema" table="tbl_nodata3" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TABLE selinto_schema.tbl_nodata3(a) AS EXECUTE data_sel WITH NO DATA" +== 019 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE selinto_schema.tbl_nodata4 (a) AS + EXECUTE data_sel WITH NO DATA +-- +TABLE: name="selinto_schema.tbl_nodata4" schema="selinto_schema" table="tbl_nodata4" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE selinto_schema.tbl_nodata4(a) ..." +== 020 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 021 +-- truncate_limit: 100 +ALTER DEFAULT PRIVILEGES FOR ROLE regress_selinto_user + GRANT INSERT ON TABLES TO regress_selinto_user +-- +STMT: AlterDefaultPrivilegesStmt +TRUNCATED: "ALTER DEFAULT PRIVILEGES FOR ROLE regress_selinto_user GRANT insert ON TABLES TO regress_selinto_..." +== 022 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_selinto_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_selinto_user" +== 023 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 024 +-- truncate_limit: 100 +DEALLOCATE data_sel +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE data_sel" +== 025 +-- truncate_limit: 100 +DROP SCHEMA selinto_schema CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA selinto_schema CASCADE" +== 026 +-- truncate_limit: 100 +DROP USER regress_selinto_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_selinto_user" +== 027 +-- truncate_limit: 100 +-- Tests for WITH NO DATA and column name consistency +CREATE TABLE ctas_base (i int, j int) +-- +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ctas_base (i int, j int)" +== 028 +-- truncate_limit: 100 +INSERT INTO ctas_base VALUES (1, 2) +-- +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ctas_base VALUES (1, 2)" +== 029 +-- truncate_limit: 100 +CREATE TABLE ctas_nodata (ii, jj, kk) AS SELECT i, j FROM ctas_base +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_nodata(ii, jj, kk) AS SELECT i, j FROM ctas_base" +== 030 +-- truncate_limit: 100 +-- Error +CREATE TABLE ctas_nodata (ii, jj, kk) AS SELECT i, j FROM ctas_base WITH NO DATA +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_nodata(ii, jj, kk) AS SELECT i, j FROM ctas_base WITH NO DATA" +== 031 +-- truncate_limit: 100 +-- Error +CREATE TABLE ctas_nodata (ii, jj) AS SELECT i, j FROM ctas_base +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_nodata(ii, jj) AS SELECT i, j FROM ctas_base" +== 032 +-- truncate_limit: 100 +-- OK +CREATE TABLE ctas_nodata_2 (ii, jj) AS SELECT i, j FROM ctas_base WITH NO DATA +-- +TABLE: name="ctas_nodata_2" schema="" table="ctas_nodata_2" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_nodata_2(ii, jj) AS SELECT i, j FROM ctas_base WITH NO DATA" +== 033 +-- truncate_limit: 100 +-- OK +CREATE TABLE ctas_nodata_3 (ii) AS SELECT i, j FROM ctas_base +-- +TABLE: name="ctas_nodata_3" schema="" table="ctas_nodata_3" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_nodata_3(ii) AS SELECT i, j FROM ctas_base" +== 034 +-- truncate_limit: 100 +-- OK +CREATE TABLE ctas_nodata_4 (ii) AS SELECT i, j FROM ctas_base WITH NO DATA +-- +TABLE: name="ctas_nodata_4" schema="" table="ctas_nodata_4" ctx=DDL +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_nodata_4(ii) AS SELECT i, j FROM ctas_base WITH NO DATA" +== 035 +-- truncate_limit: 100 +-- OK +SELECT * FROM ctas_nodata +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ctas_nodata" +== 036 +-- truncate_limit: 100 +SELECT * FROM ctas_nodata_2 +-- +TABLE: name="ctas_nodata_2" schema="" table="ctas_nodata_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ctas_nodata_2" +== 037 +-- truncate_limit: 100 +SELECT * FROM ctas_nodata_3 +-- +TABLE: name="ctas_nodata_3" schema="" table="ctas_nodata_3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ctas_nodata_3" +== 038 +-- truncate_limit: 100 +SELECT * FROM ctas_nodata_4 +-- +TABLE: name="ctas_nodata_4" schema="" table="ctas_nodata_4" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ctas_nodata_4" +== 039 +-- truncate_limit: 100 +DROP TABLE ctas_base +-- +TABLE: name="ctas_base" schema="" table="ctas_base" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ctas_base" +== 040 +-- truncate_limit: 100 +DROP TABLE ctas_nodata +-- +TABLE: name="ctas_nodata" schema="" table="ctas_nodata" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ctas_nodata" +== 041 +-- truncate_limit: 100 +DROP TABLE ctas_nodata_2 +-- +TABLE: name="ctas_nodata_2" schema="" table="ctas_nodata_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ctas_nodata_2" +== 042 +-- truncate_limit: 100 +DROP TABLE ctas_nodata_3 +-- +TABLE: name="ctas_nodata_3" schema="" table="ctas_nodata_3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ctas_nodata_3" +== 043 +-- truncate_limit: 100 +DROP TABLE ctas_nodata_4 +-- +TABLE: name="ctas_nodata_4" schema="" table="ctas_nodata_4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ctas_nodata_4" +== 044 +-- truncate_limit: 100 +|-- +-- CREATE TABLE AS/SELECT INTO as last command in a SQL function +-- have been known to cause problems +|-- +CREATE FUNCTION make_table() RETURNS VOID +AS $$ + CREATE TABLE created_table AS SELECT * FROM int8_tbl; +$$ LANGUAGE SQL +-- +FUNCTION: name="make_table" function="make_table" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION make_table() RETURNS void AS $$\n CREATE TABLE created_table AS SELECT * FROM int..." +== 045 +-- truncate_limit: 100 +SELECT make_table() +-- +FUNCTION: name="make_table" function="make_table" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_table()" +== 046 +-- truncate_limit: 100 +SELECT * FROM created_table +-- +TABLE: name="created_table" schema="" table="created_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM created_table" +== 047 +-- truncate_limit: 100 +-- Try EXPLAIN ANALYZE SELECT INTO and EXPLAIN ANALYZE CREATE TABLE AS +-- WITH NO DATA, but hide the outputs since they won't be stable. +DO $$ +BEGIN + EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl'; + EXECUTE 'EXPLAIN ANALYZE CREATE TABLE easi2 AS SELECT * FROM int8_tbl WITH NO DATA'; +END$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n\tEXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl';\n\tEXECUTE 'EXPLAIN ..." +== 048 +-- truncate_limit: 100 +DROP TABLE created_table +-- +TABLE: name="created_table" schema="" table="created_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE created_table" +== 049 +-- truncate_limit: 100 +DROP TABLE easi, easi2 +-- +TABLE: name="easi" schema="" table="easi" ctx=DDL +TABLE: name="easi2" schema="" table="easi2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE easi, easi2" +== 050 +-- truncate_limit: 100 +|-- +-- Disallowed uses of SELECT ... INTO. All should fail +|-- +DECLARE foo CURSOR FOR SELECT 1 INTO int4_tbl +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo CURSOR FOR SELECT 1 INTO int4_tbl" +== 051 +-- truncate_limit: 100 +COPY (SELECT 1 INTO frak UNION SELECT 2) TO 'blob' +-- +TABLE: name="frak" schema="" table="frak" ctx=DDL +STMT: CopyStmt +TRUNCATED: "COPY (SELECT 1 INTO frak UNION SELECT 2) TO 'blob'" +== 052 +-- truncate_limit: 100 +SELECT * FROM (SELECT 1 INTO f) bar +-- +TABLE: name="f" schema="" table="f" ctx=DDL +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT 1 INTO f) bar" +== 053 +-- truncate_limit: 100 +CREATE VIEW foo AS SELECT 1 INTO int4_tbl +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW foo AS SELECT 1 INTO int4_tbl" +== 054 +-- truncate_limit: 100 +INSERT INTO int4_tbl SELECT 1 INTO f +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +TABLE: name="f" schema="" table="f" ctx=DDL +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl SELECT 1 INTO f" +== 055 +-- truncate_limit: 100 +-- Test CREATE TABLE AS ... IF NOT EXISTS +CREATE TABLE ctas_ine_tbl AS SELECT 1 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_ine_tbl AS SELECT 1" +== 056 +-- truncate_limit: 100 +CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0" +== 057 +-- truncate_limit: 100 +-- error +CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0" +== 058 +-- truncate_limit: 100 +-- ok +CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA" +== 059 +-- truncate_limit: 100 +-- error +CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA" +== 060 +-- truncate_limit: 100 +-- ok +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0" +== 061 +-- truncate_limit: 100 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS ..." +== 062 +-- truncate_limit: 100 +-- ok +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE ctas_ine_tbl AS SELECT 1 / 0 ..." +== 063 +-- truncate_limit: 100 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS SELECT 1 / 0 WITH NO DATA +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS ..." +== 064 +-- truncate_limit: 100 +-- ok +PREPARE ctas_ine_query AS SELECT 1 / 0 +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ctas_ine_query AS SELECT 1 / 0" +== 065 +-- truncate_limit: 100 +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE ctas_ine_tbl AS EXECUTE ctas_ine_query +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE ctas_ine_tbl AS EXECUTE ctas_i..." +== 066 +-- truncate_limit: 100 +-- error +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) + CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS EXECUTE ctas_ine_query +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) CREATE TABLE IF NOT EXISTS ctas_ine_tbl AS ..." +== 067 +-- truncate_limit: 100 +-- ok +DROP TABLE ctas_ine_tbl +-- +TABLE: name="ctas_ine_tbl" schema="" table="ctas_ine_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ctas_ine_tbl" diff --git a/parser/testdata/summary_truncate/postgres_regress/select_parallel.metadata.json b/parser/testdata/summary_truncate/postgres_regress/select_parallel.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_parallel.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/select_parallel.test b/parser/testdata/summary_truncate/postgres_regress/select_parallel.test new file mode 100644 index 0000000..4ac0caa --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_parallel.test @@ -0,0 +1,2010 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PARALLEL +|-- + +create function sp_parallel_restricted(int) returns int as + $$begin return $1; end$$ language plpgsql parallel restricted +-- +FUNCTION: name="sp_parallel_restricted" function="sp_parallel_restricted" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sp_parallel_restricted(int) RETURNS int AS $$begin return $1; end$$ LANGUAGE plpg..." +== 002 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 003 +-- truncate_limit: 100 +-- encourage use of parallel plans +set parallel_setup_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 004 +-- truncate_limit: 100 +set parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 005 +-- truncate_limit: 100 +set min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 006 +-- truncate_limit: 100 +set max_parallel_workers_per_gather=4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 4" +== 007 +-- truncate_limit: 100 +-- Parallel Append with partial-subplans +explain (costs off) + select round(avg(aa)), sum(aa) from a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT round(avg(aa)), sum(aa) FROM a_star" +== 008 +-- truncate_limit: 100 +select round(avg(aa)), sum(aa) from a_star a1 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "a1"="a_star" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(avg(aa)), sum(aa) FROM a_star a1" +== 009 +-- truncate_limit: 100 +-- Parallel Append with both partial and non-partial subplans +alter table c_star set (parallel_workers = 0) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c_star SET (parallel_workers=0)" +== 010 +-- truncate_limit: 100 +alter table d_star set (parallel_workers = 0) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE d_star SET (parallel_workers=0)" +== 011 +-- truncate_limit: 100 +explain (costs off) + select round(avg(aa)), sum(aa) from a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT round(avg(aa)), sum(aa) FROM a_star" +== 012 +-- truncate_limit: 100 +select round(avg(aa)), sum(aa) from a_star a2 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "a2"="a_star" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(avg(aa)), sum(aa) FROM a_star a2" +== 013 +-- truncate_limit: 100 +-- Parallel Append with only non-partial subplans +alter table a_star set (parallel_workers = 0) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE a_star SET (parallel_workers=0)" +== 014 +-- truncate_limit: 100 +alter table b_star set (parallel_workers = 0) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE b_star SET (parallel_workers=0)" +== 015 +-- truncate_limit: 100 +alter table e_star set (parallel_workers = 0) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE e_star SET (parallel_workers=0)" +== 016 +-- truncate_limit: 100 +alter table f_star set (parallel_workers = 0) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE f_star SET (parallel_workers=0)" +== 017 +-- truncate_limit: 100 +explain (costs off) + select round(avg(aa)), sum(aa) from a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT round(avg(aa)), sum(aa) FROM a_star" +== 018 +-- truncate_limit: 100 +select round(avg(aa)), sum(aa) from a_star a3 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "a3"="a_star" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(avg(aa)), sum(aa) FROM a_star a3" +== 019 +-- truncate_limit: 100 +-- Disable Parallel Append +alter table a_star reset (parallel_workers) +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE a_star RESET (parallel_workers)" +== 020 +-- truncate_limit: 100 +alter table b_star reset (parallel_workers) +-- +TABLE: name="b_star" schema="" table="b_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE b_star RESET (parallel_workers)" +== 021 +-- truncate_limit: 100 +alter table c_star reset (parallel_workers) +-- +TABLE: name="c_star" schema="" table="c_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE c_star RESET (parallel_workers)" +== 022 +-- truncate_limit: 100 +alter table d_star reset (parallel_workers) +-- +TABLE: name="d_star" schema="" table="d_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE d_star RESET (parallel_workers)" +== 023 +-- truncate_limit: 100 +alter table e_star reset (parallel_workers) +-- +TABLE: name="e_star" schema="" table="e_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE e_star RESET (parallel_workers)" +== 024 +-- truncate_limit: 100 +alter table f_star reset (parallel_workers) +-- +TABLE: name="f_star" schema="" table="f_star" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE f_star RESET (parallel_workers)" +== 025 +-- truncate_limit: 100 +set enable_parallel_append to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_parallel_append TO OFF" +== 026 +-- truncate_limit: 100 +explain (costs off) + select round(avg(aa)), sum(aa) from a_star +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT round(avg(aa)), sum(aa) FROM a_star" +== 027 +-- truncate_limit: 100 +select round(avg(aa)), sum(aa) from a_star a4 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=Select +ALIAS: "a4"="a_star" +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT round(avg(aa)), sum(aa) FROM a_star a4" +== 028 +-- truncate_limit: 100 +reset enable_parallel_append +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_parallel_append" +== 029 +-- truncate_limit: 100 +-- Parallel Append that runs serially +create function sp_test_func() returns setof text as +$$ select 'foo'::varchar union all select 'bar'::varchar $$ +language sql stable +-- +FUNCTION: name="sp_test_func" function="sp_test_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sp_test_func() RETURNS SETOF text AS $$ select 'foo'::varchar union all select 'b..." +== 030 +-- truncate_limit: 100 +select sp_test_func() order by 1 +-- +FUNCTION: name="sp_test_func" function="sp_test_func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sp_test_func() ORDER BY 1" +== 031 +-- truncate_limit: 100 +-- Parallel Append is not to be used when the subpath depends on the outer param +create table part_pa_test(a int, b int) partition by range(a) +-- +TABLE: name="part_pa_test" schema="" table="part_pa_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_pa_test (a int, b int) PARTITION BY RANGE (a)" +== 032 +-- truncate_limit: 100 +create table part_pa_test_p1 partition of part_pa_test for values from (minvalue) to (0) +-- +TABLE: name="part_pa_test_p1" schema="" table="part_pa_test_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_pa_test_p1 PARTITION OF part_pa_test FOR VALUES FROM (minvalue) TO (0)" +== 033 +-- truncate_limit: 100 +create table part_pa_test_p2 partition of part_pa_test for values from (0) to (maxvalue) +-- +TABLE: name="part_pa_test_p2" schema="" table="part_pa_test_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_pa_test_p2 PARTITION OF part_pa_test FOR VALUES FROM (0) TO (maxvalue)" +== 034 +-- truncate_limit: 100 +explain (costs off) + select (select max((select pa1.b from part_pa_test pa1 where pa1.a = pa2.a))) + from part_pa_test pa2 +-- +TABLE: name="part_pa_test" schema="" table="part_pa_test" ctx=Select +TABLE: name="part_pa_test" schema="" table="part_pa_test" ctx=Select +ALIAS: "pa1"="part_pa_test" +ALIAS: "pa2"="part_pa_test" +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="pa1" column="a" +FILTER: schema="" table="pa2" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT (SELECT max((SELECT pa1.b FROM part_pa_test pa1 WHERE pa1.a = pa2.a)))..." +== 035 +-- truncate_limit: 100 +drop table part_pa_test +-- +TABLE: name="part_pa_test" schema="" table="part_pa_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE part_pa_test" +== 036 +-- truncate_limit: 100 +-- test with leader participation disabled +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO OFF" +== 037 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1 where stringu1 = 'GRAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 WHERE stringu1 = 'GRAAAA'" +== 038 +-- truncate_limit: 100 +select count(*) from tenk1 where stringu1 = 'GRAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 WHERE stringu1 = 'GRAAAA'" +== 039 +-- truncate_limit: 100 +-- test with leader participation disabled, but no workers available (so +-- the leader will have to run the plan despite the setting) +set max_parallel_workers = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers TO 0" +== 040 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1 where stringu1 = 'GRAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 WHERE stringu1 = 'GRAAAA'" +== 041 +-- truncate_limit: 100 +select count(*) from tenk1 where stringu1 = 'GRAAAA' +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 WHERE stringu1 = 'GRAAAA'" +== 042 +-- truncate_limit: 100 +reset max_parallel_workers +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers" +== 043 +-- truncate_limit: 100 +reset parallel_leader_participation +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_leader_participation" +== 044 +-- truncate_limit: 100 +-- test that parallel_restricted function doesn't run in worker +alter table tenk1 set (parallel_workers = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk1 SET (parallel_workers=4)" +== 045 +-- truncate_limit: 100 +explain (verbose, costs off) +select sp_parallel_restricted(unique1) from tenk1 + where stringu1 = 'GRAAAA' order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sp_parallel_restricted" function="sp_parallel_restricted" schema="" ctx=Call +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT sp_parallel_restricted(unique1) FROM tenk1 WHERE stringu1 = '..." +== 046 +-- truncate_limit: 100 +-- test parallel plan when group by expression is in target list. +explain (costs off) + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT length(stringu1) FROM tenk1 GROUP BY length(stringu1)" +== 047 +-- truncate_limit: 100 +select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(stringu1) FROM tenk1 GROUP BY length(stringu1)" +== 048 +-- truncate_limit: 100 +explain (costs off) + select stringu1, count(*) from tenk1 group by stringu1 order by stringu1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT stringu1, count(*) FROM tenk1 GROUP BY stringu1 ORDER BY stringu1" +== 049 +-- truncate_limit: 100 +-- test that parallel plan for aggregates is not selected when +-- target list contains parallel restricted clause. +explain (costs off) + select sum(sp_parallel_restricted(unique1)) from tenk1 + group by(sp_parallel_restricted(unique1)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sp_parallel_restricted" function="sp_parallel_restricted" schema="" ctx=Call +FUNCTION: name="sp_parallel_restricted" function="sp_parallel_restricted" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(sp_parallel_restricted(unique1)) FROM tenk1 GROUP BY sp_parallel_r..." +== 050 +-- truncate_limit: 100 +-- test prepared statement +prepare tenk1_count(integer) As select count((unique1)) from tenk1 where hundred > $1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE tenk1_count(int) AS SELECT count(unique1) FROM tenk1 WHERE hundred > $1" +== 051 +-- truncate_limit: 100 +explain (costs off) execute tenk1_count(1) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE tenk1_count(1)" +== 052 +-- truncate_limit: 100 +execute tenk1_count(1) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE tenk1_count(1)" +== 053 +-- truncate_limit: 100 +deallocate tenk1_count +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE tenk1_count" +== 054 +-- truncate_limit: 100 +-- test parallel plans for queries containing un-correlated subplans. +alter table tenk2 set (parallel_workers = 0) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk2 SET (parallel_workers=0)" +== 055 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1 where (two, four) not in + (select hundred, thousand from tenk2 where thousand > 100) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="two" +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 WHERE NOT (two, four) IN (SELECT hundred, thousand..." +== 056 +-- truncate_limit: 100 +select count(*) from tenk1 where (two, four) not in + (select hundred, thousand from tenk2 where thousand > 100) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="two" +FILTER: schema="" table="" column="four" +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 WHERE NOT (two, four) IN (SELECT ... FROM tenk2 WHERE thousand > 100)" +== 057 +-- truncate_limit: 100 +-- this is not parallel-safe due to use of random() within SubLink's testexpr: +explain (costs off) + select * from tenk1 where (unique1 + random())::integer not in + (select ten from tenk2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 WHERE NOT (unique1 + random())::int IN (SELECT ten FROM t..." +== 058 +-- truncate_limit: 100 +alter table tenk2 reset (parallel_workers) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk2 RESET (parallel_workers)" +== 059 +-- truncate_limit: 100 +-- test parallel plan for a query containing initplan. +set enable_indexscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 060 +-- truncate_limit: 100 +set enable_indexonlyscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexonlyscan TO OFF" +== 061 +-- truncate_limit: 100 +set enable_bitmapscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 062 +-- truncate_limit: 100 +alter table tenk2 set (parallel_workers = 2) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk2 SET (parallel_workers=2)" +== 063 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1 + where tenk1.unique1 = (Select max(tenk2.unique1) from tenk2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 WHERE tenk1.unique1 = (SELECT max(tenk2.unique1) F..." +== 064 +-- truncate_limit: 100 +select count(*) from tenk1 + where tenk1.unique1 = (Select max(tenk2.unique1) from tenk2) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 WHERE tenk1.unique1 = (SELECT max(tenk2.unique1) FROM tenk2)" +== 065 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 066 +-- truncate_limit: 100 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexonlyscan" +== 067 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 068 +-- truncate_limit: 100 +alter table tenk2 reset (parallel_workers) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk2 RESET (parallel_workers)" +== 069 +-- truncate_limit: 100 +-- test parallel index scans. +set enable_seqscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 070 +-- truncate_limit: 100 +set enable_bitmapscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 071 +-- truncate_limit: 100 +set random_page_cost = 2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET random_page_cost TO 2" +== 072 +-- truncate_limit: 100 +explain (costs off) + select count((unique1)) from tenk1 where hundred > 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(unique1) FROM tenk1 WHERE hundred > 1" +== 073 +-- truncate_limit: 100 +select count((unique1)) from tenk1 where hundred > 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT count(unique1) FROM tenk1 WHERE hundred > 1" +== 074 +-- truncate_limit: 100 +-- Parallel ScalarArrayOp index scan +explain (costs off) + select count((unique1)) from tenk1 + where hundred = any ((select array_agg(i) from generate_series(1, 100, 15) i)::int[]) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(unique1) FROM tenk1 WHERE hundred = ANY((SELECT array_agg(i) FRO..." +== 075 +-- truncate_limit: 100 +select count((unique1)) from tenk1 +where hundred = any ((select array_agg(i) from generate_series(1, 100, 15) i)::int[]) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT count(unique1) FROM tenk1 WHERE ..." +== 076 +-- truncate_limit: 100 +-- test parallel index-only scans. +explain (costs off) + select count(*) from tenk1 where thousand > 95 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 WHERE thousand > 95" +== 077 +-- truncate_limit: 100 +select count(*) from tenk1 where thousand > 95 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 WHERE thousand > 95" +== 078 +-- truncate_limit: 100 +-- test rescan cases too +set enable_material = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_material TO FALSE" +== 079 +-- truncate_limit: 100 +explain (costs off) +select * from + (select count(unique1) from tenk1 where hundred > 10) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT count(unique1) FROM tenk1 WHERE hundred > 10) ss RIGHT ..." +== 080 +-- truncate_limit: 100 +select * from + (select count(unique1) from tenk1 where hundred > 10) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM tenk1 WHERE ...) ss RIGHT JOIN (VALUES (1), (2), (3)) v(x) ON true" +== 081 +-- truncate_limit: 100 +explain (costs off) +select * from + (select count(*) from tenk1 where thousand > 99) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT count(*) FROM tenk1 WHERE thousand > 99) ss RIGHT JOIN ..." +== 082 +-- truncate_limit: 100 +select * from + (select count(*) from tenk1 where thousand > 99) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT count(*) FROM tenk1 WHERE ...) ss RIGHT JOIN (VALUES (...)) v(x) ON true" +== 083 +-- truncate_limit: 100 +-- test rescans for a Limit node with a parallel node beneath it. +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 084 +-- truncate_limit: 100 +set enable_indexonlyscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexonlyscan TO OFF" +== 085 +-- truncate_limit: 100 +set enable_indexscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 086 +-- truncate_limit: 100 +alter table tenk1 set (parallel_workers = 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk1 SET (parallel_workers=0)" +== 087 +-- truncate_limit: 100 +alter table tenk2 set (parallel_workers = 1) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk2 SET (parallel_workers=1)" +== 088 +-- truncate_limit: 100 +explain (costs off) +select count(*) from tenk1 + left join (select tenk2.unique1 from tenk2 order by 1 limit 1000) ss + on tenk1.unique1 < ss.unique1 + 1 + where tenk1.unique1 < 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 LEFT JOIN (SELECT tenk2.unique1 FROM tenk2 ORDER B..." +== 089 +-- truncate_limit: 100 +select count(*) from tenk1 + left join (select tenk2.unique1 from tenk2 order by 1 limit 1000) ss + on tenk1.unique1 < ss.unique1 + 1 + where tenk1.unique1 < 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 LEFT JOIN (SELECT ... FROM tenk2 ORDER BY 1 LIMIT 1000) ss ON tenk1.unique1..." +== 090 +-- truncate_limit: 100 +--reset the value of workers for each table as it was before this test. +alter table tenk1 set (parallel_workers = 4) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk1 SET (parallel_workers=4)" +== 091 +-- truncate_limit: 100 +alter table tenk2 reset (parallel_workers) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk2 RESET (parallel_workers)" +== 092 +-- truncate_limit: 100 +reset enable_material +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_material" +== 093 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 094 +-- truncate_limit: 100 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexonlyscan" +== 095 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 096 +-- truncate_limit: 100 +-- test parallel bitmap heap scan. +set enable_seqscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 097 +-- truncate_limit: 100 +set enable_indexscan to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 098 +-- truncate_limit: 100 +set enable_hashjoin to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 099 +-- truncate_limit: 100 +set enable_mergejoin to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_mergejoin TO OFF" +== 100 +-- truncate_limit: 100 +set enable_material to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_material TO OFF" +== 101 +-- truncate_limit: 100 +-- test prefetching, if the platform allows it +DO $$ +BEGIN + SET effective_io_concurrency = 50; +EXCEPTION WHEN invalid_parameter_value THEN +END $$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nBEGIN\n SET effective_io_concurrency = 50;\nEXCEPTION WHEN invalid_parameter_value THEN\nEND $$" +== 102 +-- truncate_limit: 100 +set work_mem='64kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET work_mem TO \"64kB\"" +== 103 +-- truncate_limit: 100 +--set small work mem to force lossy pages +explain (costs off) + select count(*) from tenk1, tenk2 where tenk1.hundred > 1 and tenk2.thousand=0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="hundred" +FILTER: schema="" table="tenk2" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1, tenk2 WHERE tenk1.hundred > 1 AND tenk2.thousand = 0" +== 104 +-- truncate_limit: 100 +select count(*) from tenk1, tenk2 where tenk1.hundred > 1 and tenk2.thousand=0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="hundred" +FILTER: schema="" table="tenk2" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1, tenk2 WHERE tenk1.hundred > 1 AND tenk2.thousand = 0" +== 105 +-- truncate_limit: 100 +create table bmscantest (a int, t text) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bmscantest (a int, t text)" +== 106 +-- truncate_limit: 100 +insert into bmscantest select r, 'fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' FROM generate_series(1,100000) r +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bmscantest SELECT ... FROM generate_series(1, 100000) r" +== 107 +-- truncate_limit: 100 +create index i_bmtest ON bmscantest(a) +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX i_bmtest ON bmscantest USING btree (a)" +== 108 +-- truncate_limit: 100 +select count(*) from bmscantest where a>1 +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM bmscantest WHERE a > 1" +== 109 +-- truncate_limit: 100 +-- test accumulation of stats for parallel nodes +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 110 +-- truncate_limit: 100 +alter table tenk2 set (parallel_workers = 0) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk2 SET (parallel_workers=0)" +== 111 +-- truncate_limit: 100 +explain (analyze, timing off, summary off, costs off) + select count(*) from tenk1, tenk2 where tenk1.hundred > 1 + and tenk2.thousand=0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="hundred" +FILTER: schema="" table="tenk2" column="thousand" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, SUMMARY OFF, COSTS OFF) SELECT count(*) FROM tenk1, tenk2 WHERE ten..." +== 112 +-- truncate_limit: 100 +alter table tenk2 reset (parallel_workers) +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tenk2 RESET (parallel_workers)" +== 113 +-- truncate_limit: 100 +reset work_mem +-- +STMT: VariableSetStmt +TRUNCATED: "RESET work_mem" +== 114 +-- truncate_limit: 100 +create function explain_parallel_sort_stats() returns setof text +language plpgsql as +$$ +declare ln text; +begin + for ln in + explain (analyze, timing off, summary off, costs off) + select * from + (select ten from tenk1 where ten < 100 order by ten) ss + right join (values (1),(2),(3)) v(x) on true + loop + ln := regexp_replace(ln, 'Memory: \S*', 'Memory: xxx'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_parallel_sort_stats" function="explain_parallel_sort_stats" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION explain_parallel_sort_stats() RETURNS SETOF text LANGUAGE plpgsql AS $$\ndeclare l..." +== 115 +-- truncate_limit: 100 +select * from explain_parallel_sort_stats() +-- +FUNCTION: name="explain_parallel_sort_stats" function="explain_parallel_sort_stats" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM explain_parallel_sort_stats()" +== 116 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 117 +-- truncate_limit: 100 +reset enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 118 +-- truncate_limit: 100 +reset enable_mergejoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_mergejoin" +== 119 +-- truncate_limit: 100 +reset enable_material +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_material" +== 120 +-- truncate_limit: 100 +reset effective_io_concurrency +-- +STMT: VariableSetStmt +TRUNCATED: "RESET effective_io_concurrency" +== 121 +-- truncate_limit: 100 +drop table bmscantest +-- +TABLE: name="bmscantest" schema="" table="bmscantest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE bmscantest" +== 122 +-- truncate_limit: 100 +drop function explain_parallel_sort_stats() +-- +FUNCTION: name="explain_parallel_sort_stats" function="explain_parallel_sort_stats" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION explain_parallel_sort_stats()" +== 123 +-- truncate_limit: 100 +-- test parallel merge join path. +set enable_hashjoin to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 124 +-- truncate_limit: 100 +set enable_nestloop to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_nestloop TO OFF" +== 125 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1, tenk2 where tenk1.unique1 = tenk2.unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +FILTER: schema="" table="tenk2" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1, tenk2 WHERE tenk1.unique1 = tenk2.unique1" +== 126 +-- truncate_limit: 100 +select count(*) from tenk1, tenk2 where tenk1.unique1 = tenk2.unique1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="tenk1" column="unique1" +FILTER: schema="" table="tenk2" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1, tenk2 WHERE tenk1.unique1 = tenk2.unique1" +== 127 +-- truncate_limit: 100 +reset enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 128 +-- truncate_limit: 100 +reset enable_nestloop +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_nestloop" +== 129 +-- truncate_limit: 100 +-- test gather merge +set enable_hashagg = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 130 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 GROUP BY twenty" +== 131 +-- truncate_limit: 100 +select count(*) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 GROUP BY twenty" +== 132 +-- truncate_limit: 100 +--test expressions in targetlist are pushed down for gather merge +create function sp_simple_func(var1 integer) returns integer +as $$ +begin + return var1 + 10; +end; +$$ language plpgsql PARALLEL SAFE +-- +FUNCTION: name="sp_simple_func" function="sp_simple_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sp_simple_func(var1 int) RETURNS int AS $$\nbegin\n return var1 + 10;\nend;\n$..." +== 133 +-- truncate_limit: 100 +explain (costs off, verbose) + select ten, sp_simple_func(ten) from tenk1 where ten < 100 order by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sp_simple_func" function="sp_simple_func" schema="" ctx=Call +FILTER: schema="" table="" column="ten" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT ten, sp_simple_func(ten) FROM tenk1 WHERE ten < 100 ORDER BY ten" +== 134 +-- truncate_limit: 100 +drop function sp_simple_func(integer) +-- +FUNCTION: name="sp_simple_func" function="sp_simple_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION sp_simple_func(int)" +== 135 +-- truncate_limit: 100 +-- test handling of SRFs in targetlist (bug in 10.0) + +explain (costs off) + select count(*), generate_series(1,2) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*), generate_series(1, 2) FROM tenk1 GROUP BY twenty" +== 136 +-- truncate_limit: 100 +select count(*), generate_series(1,2) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*), generate_series(1, 2) FROM tenk1 GROUP BY twenty" +== 137 +-- truncate_limit: 100 +-- test gather merge with parallel leader participation disabled +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO OFF" +== 138 +-- truncate_limit: 100 +explain (costs off) + select count(*) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 GROUP BY twenty" +== 139 +-- truncate_limit: 100 +select count(*) from tenk1 group by twenty +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 GROUP BY twenty" +== 140 +-- truncate_limit: 100 +reset parallel_leader_participation +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_leader_participation" +== 141 +-- truncate_limit: 100 +--test rescan behavior of gather merge +set enable_material = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_material TO FALSE" +== 142 +-- truncate_limit: 100 +explain (costs off) +select * from + (select string4, count(unique2) + from tenk1 group by string4 order by string4) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT string4, count(unique2) FROM tenk1 GROUP BY string4 ORD..." +== 143 +-- truncate_limit: 100 +select * from + (select string4, count(unique2) + from tenk1 group by string4 order by string4) ss + right join (values (1),(2),(3)) v(x) on true +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM tenk1 GROUP BY string4 ORDER BY string4) ss RIGHT JOIN (VALUES (....." +== 144 +-- truncate_limit: 100 +reset enable_material +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_material" +== 145 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 146 +-- truncate_limit: 100 +-- check parallelized int8 aggregate (bug #14897) +explain (costs off) +select avg(unique1::int8) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT avg(unique1::int8) FROM tenk1" +== 147 +-- truncate_limit: 100 +select avg(unique1::int8) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT avg(unique1::int8) FROM tenk1" +== 148 +-- truncate_limit: 100 +-- gather merge test with a LIMIT +explain (costs off) + select fivethous from tenk1 order by fivethous limit 4 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT fivethous FROM tenk1 ORDER BY fivethous LIMIT 4" +== 149 +-- truncate_limit: 100 +select fivethous from tenk1 order by fivethous limit 4 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT fivethous FROM tenk1 ORDER BY fivethous LIMIT 4" +== 150 +-- truncate_limit: 100 +-- gather merge test with 0 worker +set max_parallel_workers = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers TO 0" +== 151 +-- truncate_limit: 100 +explain (costs off) + select string4 from tenk1 order by string4 limit 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT string4 FROM tenk1 ORDER BY string4 LIMIT 5" +== 152 +-- truncate_limit: 100 +select string4 from tenk1 order by string4 limit 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT string4 FROM tenk1 ORDER BY string4 LIMIT 5" +== 153 +-- truncate_limit: 100 +-- gather merge test with 0 workers, with parallel leader +-- participation disabled (the leader will have to run the plan +-- despite the setting) +set parallel_leader_participation = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_leader_participation TO OFF" +== 154 +-- truncate_limit: 100 +explain (costs off) + select string4 from tenk1 order by string4 limit 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT string4 FROM tenk1 ORDER BY string4 LIMIT 5" +== 155 +-- truncate_limit: 100 +select string4 from tenk1 order by string4 limit 5 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT string4 FROM tenk1 ORDER BY string4 LIMIT 5" +== 156 +-- truncate_limit: 100 +reset parallel_leader_participation +-- +STMT: VariableSetStmt +TRUNCATED: "RESET parallel_leader_participation" +== 157 +-- truncate_limit: 100 +reset max_parallel_workers +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_workers" +== 158 +-- truncate_limit: 100 +create function parallel_safe_volatile(a int) returns int as + $$ begin return a; end; $$ parallel safe volatile language plpgsql +-- +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION parallel_safe_volatile(a int) RETURNS int AS $$ begin return a; end; $$ PARALLEL ..." +== 159 +-- truncate_limit: 100 +-- Test gather merge atop of a sort of a partial path +explain (costs off) +select * from tenk1 where four = 2 +order by four, hundred, parallel_safe_volatile(thousand) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=Call +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 WHERE four = 2 ORDER BY four, hundred, parallel_safe_vola..." +== 160 +-- truncate_limit: 100 +-- Test gather merge atop of an incremental sort a of partial path +set min_parallel_index_scan_size = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_index_scan_size TO 0" +== 161 +-- truncate_limit: 100 +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 162 +-- truncate_limit: 100 +explain (costs off) +select * from tenk1 where four = 2 +order by four, hundred, parallel_safe_volatile(thousand) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=Call +FILTER: schema="" table="" column="four" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 WHERE four = 2 ORDER BY four, hundred, parallel_safe_vola..." +== 163 +-- truncate_limit: 100 +reset min_parallel_index_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_index_scan_size" +== 164 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 165 +-- truncate_limit: 100 +-- Test GROUP BY with a gather merge path atop of a sort of a partial path +explain (costs off) +select count(*) from tenk1 +group by twenty, parallel_safe_volatile(two) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 GROUP BY twenty, parallel_safe_volatile(two)" +== 166 +-- truncate_limit: 100 +drop function parallel_safe_volatile(int) +-- +FUNCTION: name="parallel_safe_volatile" function="parallel_safe_volatile" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION parallel_safe_volatile(int)" +== 167 +-- truncate_limit: 100 +SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 168 +-- truncate_limit: 100 +SET LOCAL debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL debug_parallel_query TO 1" +== 169 +-- truncate_limit: 100 +explain (costs off) + select stringu1::int2 from tenk1 where unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT stringu1::int2 FROM tenk1 WHERE unique1 = 1" +== 170 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 171 +-- truncate_limit: 100 +-- exercise record typmod remapping between backends +CREATE FUNCTION make_record(n int) + RETURNS RECORD LANGUAGE plpgsql PARALLEL SAFE AS +$$ +BEGIN + RETURN CASE n + WHEN 1 THEN ROW(1) + WHEN 2 THEN ROW(1, 2) + WHEN 3 THEN ROW(1, 2, 3) + WHEN 4 THEN ROW(1, 2, 3, 4) + ELSE ROW(1, 2, 3, 4, 5) + END; +END; +$$ +-- +FUNCTION: name="make_record" function="make_record" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION make_record(n int) RETURNS record LANGUAGE plpgsql PARALLEL safe AS $$\nBEGIN\n RE..." +== 172 +-- truncate_limit: 100 +SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 173 +-- truncate_limit: 100 +SET LOCAL debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL debug_parallel_query TO 1" +== 174 +-- truncate_limit: 100 +SELECT make_record(x) FROM (SELECT generate_series(1, 5) x) ss ORDER BY x +-- +FUNCTION: name="make_record" function="make_record" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_record(x) FROM (SELECT generate_series(1, 5) AS x) ss ORDER BY x" +== 175 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 176 +-- truncate_limit: 100 +DROP function make_record(n int) +-- +FUNCTION: name="make_record" function="make_record" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION make_record(n int)" +== 177 +-- truncate_limit: 100 +-- test the sanity of parallel query after the active role is dropped. +drop role if exists regress_parallel_worker +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE IF EXISTS regress_parallel_worker" +== 178 +-- truncate_limit: 100 +create role regress_parallel_worker +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_parallel_worker" +== 179 +-- truncate_limit: 100 +set role regress_parallel_worker +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_parallel_worker" +== 180 +-- truncate_limit: 100 +reset session authorization +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 181 +-- truncate_limit: 100 +drop role regress_parallel_worker +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_parallel_worker" +== 182 +-- truncate_limit: 100 +set debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 1" +== 183 +-- truncate_limit: 100 +select count(*) from tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1" +== 184 +-- truncate_limit: 100 +reset debug_parallel_query +-- +STMT: VariableSetStmt +TRUNCATED: "RESET debug_parallel_query" +== 185 +-- truncate_limit: 100 +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 186 +-- truncate_limit: 100 +-- Window function calculation can't be pushed to workers. +explain (costs off, verbose) + select count(*) from tenk1 a where (unique1, two) in + (select unique1, row_number() over() from tenk1 b) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +FILTER: schema="" table="" column="two" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT count(*) FROM tenk1 a WHERE (unique1, two) IN (SELECT unique1..." +== 187 +-- truncate_limit: 100 +-- LIMIT/OFFSET within sub-selects can't be pushed to workers. +explain (costs off) + select * from tenk1 a where two in + (select two from tenk1 b where stringu1 like '%AAAA' limit 3) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="two" +FILTER: schema="" table="" column="stringu1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a WHERE two IN (SELECT two FROM tenk1 b WHERE stringu1 LI..." +== 188 +-- truncate_limit: 100 +-- to increase the parallel query test coverage +SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 189 +-- truncate_limit: 100 +SET LOCAL debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL debug_parallel_query TO 1" +== 190 +-- truncate_limit: 100 +EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (ANALYZE, TIMING OFF, SUMMARY OFF, COSTS OFF) SELECT * FROM tenk1" +== 191 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 192 +-- truncate_limit: 100 +-- provoke error in worker +-- (make the error message long enough to require multiple bufferloads) +SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 193 +-- truncate_limit: 100 +SET LOCAL debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL debug_parallel_query TO 1" +== 194 +-- truncate_limit: 100 +select (stringu1 || repeat('abcd', 5000))::int2 from tenk1 where unique1 = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT (stringu1 || repeat('abcd', 5000))::int2 FROM tenk1 WHERE unique1 = 1" +== 195 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 196 +-- truncate_limit: 100 +-- test interaction with set-returning functions +SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT settings" +== 197 +-- truncate_limit: 100 +-- multiple subqueries under a single Gather node +-- must set parallel_setup_cost > 0 to discourage multiple Gather nodes +SET LOCAL parallel_setup_cost = 10 +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL parallel_setup_cost TO 10" +== 198 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT unique1 FROM tenk1 WHERE fivethous = tenthous + 1 +UNION ALL +SELECT unique1 FROM tenk1 WHERE fivethous = tenthous + 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="tenthous" +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="tenthous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE fivethous = (tenthous + 1) UNION ALL SELECT u..." +== 199 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT settings +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT settings" +== 200 +-- truncate_limit: 100 +-- can't use multiple subqueries under a single Gather node due to initPlans +EXPLAIN (COSTS OFF) +SELECT unique1 FROM tenk1 WHERE fivethous = + (SELECT unique1 FROM tenk1 WHERE fivethous = 1 LIMIT 1) +UNION ALL +SELECT unique1 FROM tenk1 WHERE fivethous = + (SELECT unique2 FROM tenk1 WHERE fivethous = 1 LIMIT 1) +ORDER BY 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="fivethous" +FILTER: schema="" table="" column="fivethous" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 WHERE fivethous = (SELECT unique1 FROM tenk1 WHERE ..." +== 201 +-- truncate_limit: 100 +-- test interaction with SRFs +SELECT * FROM information_schema.foreign_data_wrapper_options +ORDER BY 1, 2, 3 +-- +TABLE: name="information_schema.foreign_data_wrapper_options" schema="information_schema" table="foreign_data_wrapper_options" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.foreign_data_wrapper_options ORDER BY 1, 2, 3" +== 202 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT generate_series(1, two), array(select generate_series(1, two)) + FROM tenk1 ORDER BY tenthous +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT generate_series(1, two), ARRAY(SELECT generate_series(1, two)..." +== 203 +-- truncate_limit: 100 +-- must disallow pushing sort below gather when pathkey contains an SRF +EXPLAIN (VERBOSE, COSTS OFF) +SELECT unnest(ARRAY[]::integer[]) + 1 AS pathkey + FROM tenk1 t1 JOIN tenk1 t2 ON TRUE + ORDER BY pathkey +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT unnest(ARRAY[]::int[]) + 1 AS pathkey FROM tenk1 t1 JOIN tenk..." +== 204 +-- truncate_limit: 100 +-- test passing expanded-value representations to workers +CREATE FUNCTION make_some_array(int,int) returns int[] as +$$declare x int[]; + begin + x[1] := $1; + x[2] := $2; + return x; + end$$ language plpgsql parallel safe +-- +FUNCTION: name="make_some_array" function="make_some_array" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION make_some_array(int, int) RETURNS int[] AS $$declare x int[];\n begin\n x[1] :=..." +== 205 +-- truncate_limit: 100 +CREATE TABLE fooarr(f1 text, f2 int[], f3 text) +-- +TABLE: name="fooarr" schema="" table="fooarr" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fooarr (f1 text, f2 int[], f3 text)" +== 206 +-- truncate_limit: 100 +INSERT INTO fooarr VALUES('1', ARRAY[1,2], 'one') +-- +TABLE: name="fooarr" schema="" table="fooarr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fooarr VALUES ('1', ARRAY[1, 2], 'one')" +== 207 +-- truncate_limit: 100 +PREPARE pstmt(text, int[]) AS SELECT * FROM fooarr WHERE f1 = $1 AND f2 = $2 +-- +TABLE: name="fooarr" schema="" table="fooarr" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE pstmt(text, int[]) AS SELECT * FROM fooarr WHERE f1 = $1 AND f2 = $2" +== 208 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) EXECUTE pstmt('1', make_some_array(1,2)) +-- +STMT: ExplainStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) EXECUTE pstmt('1', make_some_array(1, 2))" +== 209 +-- truncate_limit: 100 +EXECUTE pstmt('1', make_some_array(1,2)) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE pstmt('1', make_some_array(1, 2))" +== 210 +-- truncate_limit: 100 +DEALLOCATE pstmt +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE pstmt" +== 211 +-- truncate_limit: 100 +-- test interaction between subquery and partial_paths +CREATE VIEW tenk1_vw_sec WITH (security_barrier) AS SELECT * FROM tenk1 +-- +TABLE: name="tenk1_vw_sec" schema="" table="tenk1_vw_sec" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tenk1_vw_sec WITH (security_barrier) AS SELECT * FROM tenk1" +== 212 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT 1 FROM tenk1_vw_sec + WHERE (SELECT sum(f1) FROM int4_tbl WHERE f1 < unique1) < 100 +-- +TABLE: name="tenk1_vw_sec" schema="" table="tenk1_vw_sec" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM tenk1_vw_sec WHERE (SELECT sum(f1) FROM int4_tbl WHERE f1 < uni..." +== 213 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 214 +-- truncate_limit: 100 +-- test that function option SET ROLE works in parallel workers. +create role regress_parallel_worker +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_parallel_worker" +== 215 +-- truncate_limit: 100 +create function set_and_report_role() returns text as + $$ select current_setting('role') $$ language sql parallel safe + set role = regress_parallel_worker +-- +FUNCTION: name="set_and_report_role" function="set_and_report_role" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION set_and_report_role() RETURNS text AS $$ select current_setting('role') $$ LANGUA..." +== 216 +-- truncate_limit: 100 +create function set_role_and_error(int) returns int as + $$ select 1 / $1 $$ language sql parallel safe + set role = regress_parallel_worker +-- +FUNCTION: name="set_role_and_error" function="set_role_and_error" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION set_role_and_error(int) RETURNS int AS $$ select 1 / $1 $$ LANGUAGE sql PARALLEL ..." +== 217 +-- truncate_limit: 100 +set debug_parallel_query = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 0" +== 218 +-- truncate_limit: 100 +select set_and_report_role() +-- +FUNCTION: name="set_and_report_role" function="set_and_report_role" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_and_report_role()" +== 219 +-- truncate_limit: 100 +select set_role_and_error(0) +-- +FUNCTION: name="set_role_and_error" function="set_role_and_error" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_role_and_error(0)" +== 220 +-- truncate_limit: 100 +set debug_parallel_query = 1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO 1" +== 221 +-- truncate_limit: 100 +select set_and_report_role() +-- +FUNCTION: name="set_and_report_role" function="set_and_report_role" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_and_report_role()" +== 222 +-- truncate_limit: 100 +select set_role_and_error(0) +-- +FUNCTION: name="set_role_and_error" function="set_role_and_error" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_role_and_error(0)" +== 223 +-- truncate_limit: 100 +reset debug_parallel_query +-- +STMT: VariableSetStmt +TRUNCATED: "RESET debug_parallel_query" +== 224 +-- truncate_limit: 100 +drop function set_and_report_role() +-- +FUNCTION: name="set_and_report_role" function="set_and_report_role" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION set_and_report_role()" +== 225 +-- truncate_limit: 100 +drop function set_role_and_error(int) +-- +FUNCTION: name="set_role_and_error" function="set_role_and_error" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION set_role_and_error(int)" +== 226 +-- truncate_limit: 100 +drop role regress_parallel_worker +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_parallel_worker" +== 227 +-- truncate_limit: 100 +-- don't freeze in ParallelFinish while holding an LWLock +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 228 +-- truncate_limit: 100 +CREATE FUNCTION my_cmp (int4, int4) +RETURNS int LANGUAGE sql AS +$$ + SELECT + CASE WHEN $1 < $2 THEN -1 + WHEN $1 > $2 THEN 1 + ELSE 0 + END; +$$ +-- +FUNCTION: name="my_cmp" function="my_cmp" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION my_cmp(int4, int4) RETURNS int LANGUAGE sql AS $$\n\tSELECT\n\t\tCASE WHEN $1 < $2 THE..." +== 229 +-- truncate_limit: 100 +CREATE TABLE parallel_hang (i int4) +-- +TABLE: name="parallel_hang" schema="" table="parallel_hang" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parallel_hang (i int4)" +== 230 +-- truncate_limit: 100 +INSERT INTO parallel_hang + (SELECT * FROM generate_series(1, 400) gs) +-- +TABLE: name="parallel_hang" schema="" table="parallel_hang" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parallel_hang SELECT * FROM generate_series(1, 400) gs" +== 231 +-- truncate_limit: 100 +CREATE OPERATOR CLASS int4_custom_ops FOR TYPE int4 USING btree AS + OPERATOR 1 < (int4, int4), OPERATOR 2 <= (int4, int4), + OPERATOR 3 = (int4, int4), OPERATOR 4 >= (int4, int4), + OPERATOR 5 > (int4, int4), FUNCTION 1 my_cmp(int4, int4) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS int4_custom_ops FOR TYPE int4 USING btree AS OPERATOR 1 <(int4, int4), OPER..." +== 232 +-- truncate_limit: 100 +CREATE UNIQUE INDEX parallel_hang_idx + ON parallel_hang + USING btree (i int4_custom_ops) +-- +TABLE: name="parallel_hang" schema="" table="parallel_hang" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX parallel_hang_idx ON parallel_hang USING btree (i int4_custom_ops)" +== 233 +-- truncate_limit: 100 +SET debug_parallel_query = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET debug_parallel_query TO ON" +== 234 +-- truncate_limit: 100 +DELETE FROM parallel_hang WHERE 380 <= i AND i <= 420 +-- +TABLE: name="parallel_hang" schema="" table="parallel_hang" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parallel_hang WHERE 380 <= i AND i <= 420" +== 235 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" diff --git a/parser/testdata/summary_truncate/postgres_regress/select_views.metadata.json b/parser/testdata/summary_truncate/postgres_regress/select_views.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_views.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/select_views.test b/parser/testdata/summary_truncate/postgres_regress/select_views.test new file mode 100644 index 0000000..8a95967 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/select_views.test @@ -0,0 +1,553 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SELECT_VIEWS +-- test the views defined in CREATE_VIEWS +|-- + +SELECT * FROM street +-- +TABLE: name="street" schema="" table="street" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM street" +== 002 +-- truncate_limit: 100 +SELECT name, #thepath FROM iexit ORDER BY name COLLATE "C", 2 +-- +TABLE: name="iexit" schema="" table="iexit" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT name, # thepath FROM iexit ORDER BY name COLLATE \"C\", 2" +== 003 +-- truncate_limit: 100 +SELECT * FROM toyemp WHERE name = 'sharon' +-- +TABLE: name="toyemp" schema="" table="toyemp" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM toyemp WHERE name = 'sharon'" +== 004 +-- truncate_limit: 100 +|-- +-- Test for Leaky view scenario +|-- +CREATE ROLE regress_alice +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_alice" +== 005 +-- truncate_limit: 100 +CREATE FUNCTION f_leak (text) + RETURNS bool LANGUAGE 'plpgsql' COST 0.0000001 + AS 'BEGIN RAISE NOTICE ''f_leak => %'', $1; RETURN true; END' +-- +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f_leak(text) RETURNS bool LANGUAGE plpgsql COST 0.0000001 AS $$BEGIN RAISE NOTICE..." +== 006 +-- truncate_limit: 100 +CREATE TABLE customer ( + cid int primary key, + name text not null, + tel text, + passwd text +) +-- +TABLE: name="customer" schema="" table="customer" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE customer (cid int PRIMARY KEY, name text NOT NULL, tel text, passwd text)" +== 007 +-- truncate_limit: 100 +CREATE TABLE credit_card ( + cid int references customer(cid), + cnum text, + climit int +) +-- +TABLE: name="credit_card" schema="" table="credit_card" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE credit_card (cid int REFERENCES customer (cid), cnum text, climit int)" +== 008 +-- truncate_limit: 100 +CREATE TABLE credit_usage ( + cid int references customer(cid), + ymd date, + usage int +) +-- +TABLE: name="credit_usage" schema="" table="credit_usage" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE credit_usage (cid int REFERENCES customer (cid), ymd date, usage int)" +== 009 +-- truncate_limit: 100 +INSERT INTO customer + VALUES (101, 'regress_alice', '+81-12-3456-7890', 'passwd123'), + (102, 'regress_bob', '+01-234-567-8901', 'beafsteak'), + (103, 'regress_eve', '+49-8765-43210', 'hamburger') +-- +TABLE: name="customer" schema="" table="customer" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO customer VALUES (...)" +== 010 +-- truncate_limit: 100 +INSERT INTO credit_card + VALUES (101, '1111-2222-3333-4444', 4000), + (102, '5555-6666-7777-8888', 3000), + (103, '9801-2345-6789-0123', 2000) +-- +TABLE: name="credit_card" schema="" table="credit_card" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO credit_card VALUES (...)" +== 011 +-- truncate_limit: 100 +INSERT INTO credit_usage + VALUES (101, '2011-09-15', 120), + (101, '2011-10-05', 90), + (101, '2011-10-18', 110), + (101, '2011-10-21', 200), + (101, '2011-11-10', 80), + (102, '2011-09-22', 300), + (102, '2011-10-12', 120), + (102, '2011-10-28', 200), + (103, '2011-10-15', 480) +-- +TABLE: name="credit_usage" schema="" table="credit_usage" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO credit_usage VALUES (...)" +== 012 +-- truncate_limit: 100 +CREATE VIEW my_property_normal AS + SELECT * FROM customer WHERE name = current_user +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=DDL +TABLE: name="customer" schema="" table="customer" ctx=Select +FILTER: schema="" table="" column="name" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW my_property_normal AS SELECT * FROM customer WHERE name = current_user" +== 013 +-- truncate_limit: 100 +CREATE VIEW my_property_secure WITH (security_barrier) AS + SELECT * FROM customer WHERE name = current_user +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=DDL +TABLE: name="customer" schema="" table="customer" ctx=Select +FILTER: schema="" table="" column="name" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW my_property_secure WITH (security_barrier) AS SELECT * FROM customer WHERE name = cur..." +== 014 +-- truncate_limit: 100 +CREATE VIEW my_credit_card_normal AS + SELECT * FROM customer l NATURAL JOIN credit_card r + WHERE l.name = current_user +-- +TABLE: name="my_credit_card_normal" schema="" table="my_credit_card_normal" ctx=DDL +TABLE: name="customer" schema="" table="customer" ctx=Select +TABLE: name="credit_card" schema="" table="credit_card" ctx=Select +ALIAS: "l"="customer" +ALIAS: "r"="credit_card" +FILTER: schema="" table="l" column="name" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW my_credit_card_normal AS SELECT * FROM customer l NATURAL JOIN credit_card r WHERE l...." +== 015 +-- truncate_limit: 100 +CREATE VIEW my_credit_card_secure WITH (security_barrier) AS + SELECT * FROM customer l NATURAL JOIN credit_card r + WHERE l.name = current_user +-- +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=DDL +TABLE: name="customer" schema="" table="customer" ctx=Select +TABLE: name="credit_card" schema="" table="credit_card" ctx=Select +ALIAS: "l"="customer" +ALIAS: "r"="credit_card" +FILTER: schema="" table="l" column="name" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW my_credit_card_secure WITH (security_barrier) AS SELECT * FROM customer l NATURAL JOI..." +== 016 +-- truncate_limit: 100 +CREATE VIEW my_credit_card_usage_normal AS + SELECT * FROM my_credit_card_secure l NATURAL JOIN credit_usage r +-- +TABLE: name="my_credit_card_usage_normal" schema="" table="my_credit_card_usage_normal" ctx=DDL +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=Select +TABLE: name="credit_usage" schema="" table="credit_usage" ctx=Select +ALIAS: "l"="my_credit_card_secure" +ALIAS: "r"="credit_usage" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW my_credit_card_usage_normal AS SELECT * FROM my_credit_card_secure l NATURAL JOIN cre..." +== 017 +-- truncate_limit: 100 +CREATE VIEW my_credit_card_usage_secure WITH (security_barrier) AS + SELECT * FROM my_credit_card_secure l NATURAL JOIN credit_usage r +-- +TABLE: name="my_credit_card_usage_secure" schema="" table="my_credit_card_usage_secure" ctx=DDL +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=Select +TABLE: name="credit_usage" schema="" table="credit_usage" ctx=Select +ALIAS: "l"="my_credit_card_secure" +ALIAS: "r"="credit_usage" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW my_credit_card_usage_secure WITH (security_barrier) AS SELECT * FROM my_credit_card_s..." +== 018 +-- truncate_limit: 100 +GRANT SELECT ON my_property_normal TO public +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON my_property_normal TO public" +== 019 +-- truncate_limit: 100 +GRANT SELECT ON my_property_secure TO public +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON my_property_secure TO public" +== 020 +-- truncate_limit: 100 +GRANT SELECT ON my_credit_card_normal TO public +-- +TABLE: name="my_credit_card_normal" schema="" table="my_credit_card_normal" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON my_credit_card_normal TO public" +== 021 +-- truncate_limit: 100 +GRANT SELECT ON my_credit_card_secure TO public +-- +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON my_credit_card_secure TO public" +== 022 +-- truncate_limit: 100 +GRANT SELECT ON my_credit_card_usage_normal TO public +-- +TABLE: name="my_credit_card_usage_normal" schema="" table="my_credit_card_usage_normal" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON my_credit_card_usage_normal TO public" +== 023 +-- truncate_limit: 100 +GRANT SELECT ON my_credit_card_usage_secure TO public +-- +TABLE: name="my_credit_card_usage_secure" schema="" table="my_credit_card_usage_secure" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON my_credit_card_usage_secure TO public" +== 024 +-- truncate_limit: 100 +|-- +-- Run leaky view scenarios +|-- +SET SESSION AUTHORIZATION regress_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alice" +== 025 +-- truncate_limit: 100 +|-- +-- scenario: if a qualifier with tiny-cost is given, it shall be launched +-- prior to the security policy of the view. +|-- +SELECT * FROM my_property_normal WHERE f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_property_normal WHERE f_leak(passwd)" +== 026 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM my_property_normal WHERE f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM my_property_normal WHERE f_leak(passwd)" +== 027 +-- truncate_limit: 100 +SELECT * FROM my_property_secure WHERE f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_property_secure WHERE f_leak(passwd)" +== 028 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM my_property_secure WHERE f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM my_property_secure WHERE f_leak(passwd)" +== 029 +-- truncate_limit: 100 +|-- +-- scenario: qualifiers can be pushed down if they contain leaky functions, +-- provided they aren't passed data from inside the view. +|-- +SELECT * FROM my_property_normal v + WHERE f_leak('passwd') AND f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +ALIAS: "v"="my_property_normal" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_property_normal v WHERE f_leak('passwd') AND f_leak(passwd)" +== 030 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM my_property_normal v + WHERE f_leak('passwd') AND f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +ALIAS: "v"="my_property_normal" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM my_property_normal v WHERE f_leak('passwd') AND f_leak(passwd)" +== 031 +-- truncate_limit: 100 +SELECT * FROM my_property_secure v + WHERE f_leak('passwd') AND f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +ALIAS: "v"="my_property_secure" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_property_secure v WHERE f_leak('passwd') AND f_leak(passwd)" +== 032 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM my_property_secure v + WHERE f_leak('passwd') AND f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +ALIAS: "v"="my_property_secure" +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM my_property_secure v WHERE f_leak('passwd') AND f_leak(passwd)" +== 033 +-- truncate_limit: 100 +|-- +-- scenario: if a qualifier references only one-side of a particular join- +-- tree, it shall be distributed to the most deep scan plan as +-- possible as we can. +|-- +SELECT * FROM my_credit_card_normal WHERE f_leak(cnum) +-- +TABLE: name="my_credit_card_normal" schema="" table="my_credit_card_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_credit_card_normal WHERE f_leak(cnum)" +== 034 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_normal WHERE f_leak(cnum) +-- +TABLE: name="my_credit_card_normal" schema="" table="my_credit_card_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_normal WHERE f_leak(cnum)" +== 035 +-- truncate_limit: 100 +SELECT * FROM my_credit_card_secure WHERE f_leak(cnum) +-- +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_credit_card_secure WHERE f_leak(cnum)" +== 036 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_secure WHERE f_leak(cnum) +-- +TABLE: name="my_credit_card_secure" schema="" table="my_credit_card_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_secure WHERE f_leak(cnum)" +== 037 +-- truncate_limit: 100 +|-- +-- scenario: an external qualifier can be pushed-down by in-front-of the +-- views with "security_barrier" attribute, except for operators +-- implemented with leakproof functions. +|-- +SELECT * FROM my_credit_card_usage_normal + WHERE f_leak(cnum) AND ymd >= '2011-10-01' AND ymd < '2011-11-01' +-- +TABLE: name="my_credit_card_usage_normal" schema="" table="my_credit_card_usage_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +FILTER: schema="" table="" column="ymd" +FILTER: schema="" table="" column="ymd" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_credit_card_usage_normal WHERE ..." +== 038 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_normal + WHERE f_leak(cnum) AND ymd >= '2011-10-01' AND ymd < '2011-11-01' +-- +TABLE: name="my_credit_card_usage_normal" schema="" table="my_credit_card_usage_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +FILTER: schema="" table="" column="ymd" +FILTER: schema="" table="" column="ymd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_normal WHERE f_leak(cnum) AND ymd >= '2011..." +== 039 +-- truncate_limit: 100 +SELECT * FROM my_credit_card_usage_secure + WHERE f_leak(cnum) AND ymd >= '2011-10-01' AND ymd < '2011-11-01' +-- +TABLE: name="my_credit_card_usage_secure" schema="" table="my_credit_card_usage_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +FILTER: schema="" table="" column="ymd" +FILTER: schema="" table="" column="ymd" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_credit_card_usage_secure WHERE ..." +== 040 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_secure + WHERE f_leak(cnum) AND ymd >= '2011-10-01' AND ymd < '2011-11-01' +-- +TABLE: name="my_credit_card_usage_secure" schema="" table="my_credit_card_usage_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="cnum" +FILTER: schema="" table="" column="ymd" +FILTER: schema="" table="" column="ymd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM my_credit_card_usage_secure WHERE f_leak(cnum) AND ymd >= '2011..." +== 041 +-- truncate_limit: 100 +|-- +-- Test for the case when security_barrier gets changed between rewriter +-- and planner stage. +|-- +PREPARE p1 AS SELECT * FROM my_property_normal WHERE f_leak(passwd) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE p1 AS SELECT * FROM my_property_normal WHERE f_leak(passwd)" +== 042 +-- truncate_limit: 100 +PREPARE p2 AS SELECT * FROM my_property_secure WHERE f_leak(passwd) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=Select +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FUNCTION: name="f_leak" function="f_leak" schema="" ctx=Call +FILTER: schema="" table="" column="passwd" +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE p2 AS SELECT * FROM my_property_secure WHERE f_leak(passwd)" +== 043 +-- truncate_limit: 100 +EXECUTE p1 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p1" +== 044 +-- truncate_limit: 100 +EXECUTE p2 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p2" +== 045 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 046 +-- truncate_limit: 100 +ALTER VIEW my_property_normal SET (security_barrier=true) +-- +TABLE: name="my_property_normal" schema="" table="my_property_normal" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW my_property_normal SET (security_barrier=true)" +== 047 +-- truncate_limit: 100 +ALTER VIEW my_property_secure SET (security_barrier=false) +-- +TABLE: name="my_property_secure" schema="" table="my_property_secure" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW my_property_secure SET (security_barrier=false)" +== 048 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_alice +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_alice" +== 049 +-- truncate_limit: 100 +EXECUTE p1 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p1" +== 050 +-- truncate_limit: 100 +-- To be perform as a view with security-barrier +EXECUTE p2 +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE p2" +== 051 +-- truncate_limit: 100 +-- To be perform as a view without security-barrier + +-- Cleanup. +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 052 +-- truncate_limit: 100 +DROP ROLE regress_alice +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_alice" diff --git a/parser/testdata/summary_truncate/postgres_regress/sequence.metadata.json b/parser/testdata/summary_truncate/postgres_regress/sequence.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sequence.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/sequence.test b/parser/testdata/summary_truncate/postgres_regress/sequence.test new file mode 100644 index 0000000..43624b6 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sequence.test @@ -0,0 +1,1834 @@ +== 001 +-- truncate_limit: 100 +|-- +-- CREATE SEQUENCE +|-- + +-- various error cases +CREATE SEQUENCE sequence_testx INCREMENT BY 0 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx INCREMENT 0" +== 002 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx INCREMENT BY -1 MINVALUE 20 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx INCREMENT -1 MINVALUE 20" +== 003 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx INCREMENT BY 1 MAXVALUE -20 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx INCREMENT 1 MAXVALUE -20" +== 004 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx INCREMENT BY -1 START 10 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx INCREMENT -1 START 10" +== 005 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx INCREMENT BY 1 START -10 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx INCREMENT 1 START -10" +== 006 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx CACHE 0 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx CACHE 0" +== 007 +-- truncate_limit: 100 +-- OWNED BY errors +CREATE SEQUENCE sequence_testx OWNED BY nobody +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx OWNED BY nobody" +== 008 +-- truncate_limit: 100 +-- nonsense word +CREATE SEQUENCE sequence_testx OWNED BY pg_class_oid_index.oid +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx OWNED BY pg_class_oid_index.oid" +== 009 +-- truncate_limit: 100 +-- not a table +CREATE SEQUENCE sequence_testx OWNED BY pg_class.relname +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx OWNED BY pg_class.relname" +== 010 +-- truncate_limit: 100 +-- not same schema +CREATE TABLE sequence_test_table (a int) +-- +TABLE: name="sequence_test_table" schema="" table="sequence_test_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sequence_test_table (a int)" +== 011 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx OWNED BY sequence_test_table.b +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx OWNED BY sequence_test_table.b" +== 012 +-- truncate_limit: 100 +-- wrong column +DROP TABLE sequence_test_table +-- +TABLE: name="sequence_test_table" schema="" table="sequence_test_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sequence_test_table" +== 013 +-- truncate_limit: 100 +-- sequence data types +CREATE SEQUENCE sequence_test5 AS integer +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test5 AS int" +== 014 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test6 AS smallint +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test6 AS smallint" +== 015 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test7 AS bigint +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test7 AS bigint" +== 016 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test8 AS integer MAXVALUE 100000 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test8 AS int MAXVALUE 100000" +== 017 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test9 AS integer INCREMENT BY -1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test9 AS int INCREMENT -1" +== 018 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test10 AS integer MINVALUE -100000 START 1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test10 AS int MINVALUE -100000 START 1" +== 019 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test11 AS smallint +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test11 AS smallint" +== 020 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test12 AS smallint INCREMENT -1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test12 AS smallint INCREMENT -1" +== 021 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test13 AS smallint MINVALUE -32768 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test13 AS smallint MINVALUE -32768" +== 022 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test14 AS smallint MAXVALUE 32767 INCREMENT -1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test14 AS smallint MAXVALUE 32767 INCREMENT -1" +== 023 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx AS text +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx AS text" +== 024 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx AS nosuchtype +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx AS nosuchtype" +== 025 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx AS smallint MAXVALUE 100000 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx AS smallint MAXVALUE 100000" +== 026 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_testx AS smallint MINVALUE -100000 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_testx AS smallint MINVALUE -100000" +== 027 +-- truncate_limit: 100 +ALTER SEQUENCE sequence_test5 AS smallint +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test5 AS smallint" +== 028 +-- truncate_limit: 100 +-- success, max will be adjusted +ALTER SEQUENCE sequence_test8 AS smallint +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test8 AS smallint" +== 029 +-- truncate_limit: 100 +-- fail, max has to be adjusted +ALTER SEQUENCE sequence_test8 AS smallint MAXVALUE 20000 +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test8 AS smallint MAXVALUE 20000" +== 030 +-- truncate_limit: 100 +-- ok now +ALTER SEQUENCE sequence_test9 AS smallint +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test9 AS smallint" +== 031 +-- truncate_limit: 100 +-- success, min will be adjusted +ALTER SEQUENCE sequence_test10 AS smallint +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test10 AS smallint" +== 032 +-- truncate_limit: 100 +-- fail, min has to be adjusted +ALTER SEQUENCE sequence_test10 AS smallint MINVALUE -20000 +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test10 AS smallint MINVALUE -20000" +== 033 +-- truncate_limit: 100 +-- ok now + +ALTER SEQUENCE sequence_test11 AS int +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test11 AS int" +== 034 +-- truncate_limit: 100 +-- max will be adjusted +ALTER SEQUENCE sequence_test12 AS int +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test12 AS int" +== 035 +-- truncate_limit: 100 +-- min will be adjusted +ALTER SEQUENCE sequence_test13 AS int +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test13 AS int" +== 036 +-- truncate_limit: 100 +-- min and max will be adjusted +ALTER SEQUENCE sequence_test14 AS int +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test14 AS int" +== 037 +-- truncate_limit: 100 +-- min and max will be adjusted + +--- +--- test creation of SERIAL column +--- + +CREATE TABLE serialTest1 (f1 text, f2 serial) +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE serialtest1 (f1 text, f2 serial)" +== 038 +-- truncate_limit: 100 +INSERT INTO serialTest1 VALUES ('foo') +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest1 VALUES ('foo')" +== 039 +-- truncate_limit: 100 +INSERT INTO serialTest1 VALUES ('bar') +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest1 VALUES ('bar')" +== 040 +-- truncate_limit: 100 +INSERT INTO serialTest1 VALUES ('force', 100) +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest1 VALUES ('force', 100)" +== 041 +-- truncate_limit: 100 +INSERT INTO serialTest1 VALUES ('wrong', NULL) +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest1 VALUES ('wrong', NULL)" +== 042 +-- truncate_limit: 100 +SELECT * FROM serialTest1 +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM serialtest1" +== 043 +-- truncate_limit: 100 +SELECT pg_get_serial_sequence('serialTest1', 'f2') +-- +FUNCTION: name="pg_get_serial_sequence" function="pg_get_serial_sequence" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_serial_sequence('serialTest1', 'f2')" +== 044 +-- truncate_limit: 100 +-- test smallserial / bigserial +CREATE TABLE serialTest2 (f1 text, f2 serial, f3 smallserial, f4 serial2, + f5 bigserial, f6 serial8) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE serialtest2 (f1 text, f2 serial, f3 smallserial, f4 serial2, f5 bigserial, f6 serial8)" +== 045 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1) + VALUES ('test_defaults') +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1) VALUES ('test_defaults')" +== 046 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1, f2, f3, f4, f5, f6) + VALUES ('test_max_vals', 2147483647, 32767, 32767, 9223372036854775807, + 9223372036854775807), + ('test_min_vals', -2147483648, -32768, -32768, -9223372036854775808, + -9223372036854775808) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f2, f3, f4, f5, f6) VALUES (...)" +== 047 +-- truncate_limit: 100 +-- All these INSERTs should fail: +INSERT INTO serialTest2 (f1, f3) + VALUES ('bogus', -32769) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f3) VALUES ('bogus', -32769)" +== 048 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1, f4) + VALUES ('bogus', -32769) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f4) VALUES ('bogus', -32769)" +== 049 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1, f3) + VALUES ('bogus', 32768) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f3) VALUES ('bogus', 32768)" +== 050 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1, f4) + VALUES ('bogus', 32768) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f4) VALUES ('bogus', 32768)" +== 051 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1, f5) + VALUES ('bogus', -9223372036854775809) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f5) VALUES ('bogus', -9223372036854775809)" +== 052 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1, f6) + VALUES ('bogus', -9223372036854775809) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f6) VALUES ('bogus', -9223372036854775809)" +== 053 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1, f5) + VALUES ('bogus', 9223372036854775808) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f5) VALUES ('bogus', 9223372036854775808)" +== 054 +-- truncate_limit: 100 +INSERT INTO serialTest2 (f1, f6) + VALUES ('bogus', 9223372036854775808) +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest2 (f1, f6) VALUES ('bogus', 9223372036854775808)" +== 055 +-- truncate_limit: 100 +SELECT * FROM serialTest2 ORDER BY f2 ASC +-- +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM serialtest2 ORDER BY f2 ASC" +== 056 +-- truncate_limit: 100 +SELECT nextval('serialTest2_f2_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('serialTest2_f2_seq')" +== 057 +-- truncate_limit: 100 +SELECT nextval('serialTest2_f3_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('serialTest2_f3_seq')" +== 058 +-- truncate_limit: 100 +SELECT nextval('serialTest2_f4_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('serialTest2_f4_seq')" +== 059 +-- truncate_limit: 100 +SELECT nextval('serialTest2_f5_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('serialTest2_f5_seq')" +== 060 +-- truncate_limit: 100 +SELECT nextval('serialTest2_f6_seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('serialTest2_f6_seq')" +== 061 +-- truncate_limit: 100 +-- basic sequence operations using both text and oid references +CREATE SEQUENCE sequence_test +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test" +== 062 +-- truncate_limit: 100 +CREATE SEQUENCE IF NOT EXISTS sequence_test +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE IF NOT EXISTS sequence_test" +== 063 +-- truncate_limit: 100 +SELECT nextval('sequence_test'::text) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test'::text)" +== 064 +-- truncate_limit: 100 +SELECT nextval('sequence_test'::regclass) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test'::regclass)" +== 065 +-- truncate_limit: 100 +SELECT currval('sequence_test'::text) +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currval('sequence_test'::text)" +== 066 +-- truncate_limit: 100 +SELECT currval('sequence_test'::regclass) +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currval('sequence_test'::regclass)" +== 067 +-- truncate_limit: 100 +SELECT setval('sequence_test'::text, 32) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test'::text, 32)" +== 068 +-- truncate_limit: 100 +SELECT nextval('sequence_test'::regclass) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test'::regclass)" +== 069 +-- truncate_limit: 100 +SELECT setval('sequence_test'::text, 99, false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test'::text, 99, false)" +== 070 +-- truncate_limit: 100 +SELECT nextval('sequence_test'::regclass) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test'::regclass)" +== 071 +-- truncate_limit: 100 +SELECT setval('sequence_test'::regclass, 32) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test'::regclass, 32)" +== 072 +-- truncate_limit: 100 +SELECT nextval('sequence_test'::text) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test'::text)" +== 073 +-- truncate_limit: 100 +SELECT setval('sequence_test'::regclass, 99, false) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test'::regclass, 99, false)" +== 074 +-- truncate_limit: 100 +SELECT nextval('sequence_test'::text) +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test'::text)" +== 075 +-- truncate_limit: 100 +DISCARD SEQUENCES +-- +STMT: DiscardStmt +TRUNCATED: "DISCARD SEQUENCES" +== 076 +-- truncate_limit: 100 +SELECT currval('sequence_test'::regclass) +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currval('sequence_test'::regclass)" +== 077 +-- truncate_limit: 100 +DROP SEQUENCE sequence_test +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE sequence_test" +== 078 +-- truncate_limit: 100 +-- renaming sequences +CREATE SEQUENCE foo_seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE foo_seq" +== 079 +-- truncate_limit: 100 +ALTER TABLE foo_seq RENAME TO foo_seq_new +-- +TABLE: name="foo_seq" schema="" table="foo_seq" ctx=DDL +TABLE: name="foo_seq_new" schema="" table="foo_seq_new" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE foo_seq RENAME TO foo_seq_new" +== 080 +-- truncate_limit: 100 +SELECT * FROM foo_seq_new +-- +TABLE: name="foo_seq_new" schema="" table="foo_seq_new" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo_seq_new" +== 081 +-- truncate_limit: 100 +SELECT nextval('foo_seq_new') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('foo_seq_new')" +== 082 +-- truncate_limit: 100 +SELECT nextval('foo_seq_new') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('foo_seq_new')" +== 083 +-- truncate_limit: 100 +-- log_cnt can be higher if there is a checkpoint just at the right +-- time, so just test for the expected range +SELECT last_value, log_cnt IN (31, 32) AS log_cnt_ok, is_called FROM foo_seq_new +-- +TABLE: name="foo_seq_new" schema="" table="foo_seq_new" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT last_value, log_cnt IN (31, 32) AS log_cnt_ok, is_called FROM foo_seq_new" +== 084 +-- truncate_limit: 100 +DROP SEQUENCE foo_seq_new +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE foo_seq_new" +== 085 +-- truncate_limit: 100 +-- renaming serial sequences +ALTER TABLE serialtest1_f2_seq RENAME TO serialtest1_f2_foo +-- +TABLE: name="serialtest1_f2_seq" schema="" table="serialtest1_f2_seq" ctx=DDL +TABLE: name="serialtest1_f2_foo" schema="" table="serialtest1_f2_foo" ctx=DDL +STMT: RenameStmt +TRUNCATED: "ALTER TABLE serialtest1_f2_seq RENAME TO serialtest1_f2_foo" +== 086 +-- truncate_limit: 100 +INSERT INTO serialTest1 VALUES ('more') +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serialtest1 VALUES ('more')" +== 087 +-- truncate_limit: 100 +SELECT * FROM serialTest1 +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM serialtest1" +== 088 +-- truncate_limit: 100 +|-- +-- Check dependencies of serial and ordinary sequences +|-- +CREATE TEMP SEQUENCE myseq2 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE myseq2" +== 089 +-- truncate_limit: 100 +CREATE TEMP SEQUENCE myseq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE myseq3" +== 090 +-- truncate_limit: 100 +CREATE TEMP TABLE t1 ( + f1 serial, + f2 int DEFAULT nextval('myseq2'), + f3 int DEFAULT nextval('myseq3'::text) +) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (f1 serial, f2 int DEFAULT nextval('myseq2'), f3 int DEFAULT nextval('m..." +== 091 +-- truncate_limit: 100 +-- Both drops should fail, but with different error messages: +DROP SEQUENCE t1_f1_seq +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE t1_f1_seq" +== 092 +-- truncate_limit: 100 +DROP SEQUENCE myseq2 +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE myseq2" +== 093 +-- truncate_limit: 100 +-- This however will work: +DROP SEQUENCE myseq3 +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE myseq3" +== 094 +-- truncate_limit: 100 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1" +== 095 +-- truncate_limit: 100 +-- Fails because no longer existent: +DROP SEQUENCE t1_f1_seq +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE t1_f1_seq" +== 096 +-- truncate_limit: 100 +-- Now OK: +DROP SEQUENCE myseq2 +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE myseq2" +== 097 +-- truncate_limit: 100 +|-- +-- Alter sequence +|-- + +ALTER SEQUENCE IF EXISTS sequence_test2 RESTART WITH 24 + INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE IF EXISTS sequence_test2 RESTART 24 INCREMENT 4 MAXVALUE 36 MINVALUE 5 CYCLE" +== 098 +-- truncate_limit: 100 +ALTER SEQUENCE serialTest1 CYCLE +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE serialtest1 CYCLE" +== 099 +-- truncate_limit: 100 +-- error, not a sequence + +CREATE SEQUENCE sequence_test2 START WITH 32 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test2 START 32" +== 100 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test4 INCREMENT BY -1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test4 INCREMENT -1" +== 101 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 102 +-- truncate_limit: 100 +SELECT nextval('sequence_test4') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test4')" +== 103 +-- truncate_limit: 100 +ALTER SEQUENCE sequence_test2 RESTART +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test2 RESTART" +== 104 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 105 +-- truncate_limit: 100 +ALTER SEQUENCE sequence_test2 RESTART WITH 0 +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test2 RESTART 0" +== 106 +-- truncate_limit: 100 +-- error +ALTER SEQUENCE sequence_test4 RESTART WITH 40 +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test4 RESTART 40" +== 107 +-- truncate_limit: 100 +-- error + +-- test CYCLE and NO CYCLE +ALTER SEQUENCE sequence_test2 RESTART WITH 24 + INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test2 RESTART 24 INCREMENT 4 MAXVALUE 36 MINVALUE 5 CYCLE" +== 108 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 109 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 110 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 111 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 112 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 113 +-- truncate_limit: 100 +-- cycled + +ALTER SEQUENCE sequence_test2 RESTART WITH 24 + NO CYCLE +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test2 RESTART 24 NO CYCLE" +== 114 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 115 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 116 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 117 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 118 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 119 +-- truncate_limit: 100 +-- error + +ALTER SEQUENCE sequence_test2 RESTART WITH -24 START WITH -24 + INCREMENT BY -4 MINVALUE -36 MAXVALUE -5 CYCLE +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test2 RESTART -24 START -24 INCREMENT -4 MINVALUE -36 MAXVALUE -5 CYCLE" +== 120 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 121 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 122 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 123 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 124 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 125 +-- truncate_limit: 100 +-- cycled + +ALTER SEQUENCE sequence_test2 RESTART WITH -24 + NO CYCLE +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test2 RESTART -24 NO CYCLE" +== 126 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 127 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 128 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 129 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 130 +-- truncate_limit: 100 +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 131 +-- truncate_limit: 100 +-- error + +-- reset +ALTER SEQUENCE IF EXISTS sequence_test2 RESTART WITH 32 START WITH 32 + INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE IF EXISTS sequence_test2 RESTART 32 START 32 INCREMENT 4 MAXVALUE 36 MINVALUE 5 CYCLE" +== 132 +-- truncate_limit: 100 +SELECT setval('sequence_test2', -100) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test2', -100)" +== 133 +-- truncate_limit: 100 +-- error +SELECT setval('sequence_test2', 100) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test2', 100)" +== 134 +-- truncate_limit: 100 +-- error +SELECT setval('sequence_test2', 5) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test2', 5)" +== 135 +-- truncate_limit: 100 +CREATE SEQUENCE sequence_test3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE sequence_test3" +== 136 +-- truncate_limit: 100 +-- not read from, to test is_called + + +-- Information schema +SELECT * FROM information_schema.sequences + WHERE sequence_name ~ ANY(ARRAY['sequence_test', 'serialtest']) + ORDER BY sequence_name ASC +-- +TABLE: name="information_schema.sequences" schema="information_schema" table="sequences" ctx=Select +FILTER: schema="" table="" column="sequence_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.sequences WHERE ... ORDER BY sequence_name ASC" +== 137 +-- truncate_limit: 100 +SELECT schemaname, sequencename, start_value, min_value, max_value, increment_by, cycle, cache_size, last_value +FROM pg_sequences +WHERE sequencename ~ ANY(ARRAY['sequence_test', 'serialtest']) + ORDER BY sequencename ASC +-- +TABLE: name="pg_sequences" schema="" table="pg_sequences" ctx=Select +FILTER: schema="" table="" column="sequencename" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_sequences WHERE ... ORDER BY sequencename ASC" +== 138 +-- truncate_limit: 100 +SELECT * FROM pg_sequence_parameters('sequence_test4'::regclass) +-- +FUNCTION: name="pg_sequence_parameters" function="pg_sequence_parameters" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_sequence_parameters('sequence_test4'::regclass)" +== 139 +-- truncate_limit: 100 +-- Test comments +COMMENT ON SEQUENCE asdf IS 'won''t work' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON SEQUENCE asdf IS 'won''t work'" +== 140 +-- truncate_limit: 100 +COMMENT ON SEQUENCE sequence_test2 IS 'will work' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON SEQUENCE sequence_test2 IS 'will work'" +== 141 +-- truncate_limit: 100 +COMMENT ON SEQUENCE sequence_test2 IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON SEQUENCE sequence_test2 IS NULL" +== 142 +-- truncate_limit: 100 +-- Test lastval() +CREATE SEQUENCE seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq" +== 143 +-- truncate_limit: 100 +SELECT nextval('seq') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq')" +== 144 +-- truncate_limit: 100 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lastval()" +== 145 +-- truncate_limit: 100 +SELECT setval('seq', 99) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('seq', 99)" +== 146 +-- truncate_limit: 100 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lastval()" +== 147 +-- truncate_limit: 100 +DISCARD SEQUENCES +-- +STMT: DiscardStmt +TRUNCATED: "DISCARD SEQUENCES" +== 148 +-- truncate_limit: 100 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lastval()" +== 149 +-- truncate_limit: 100 +CREATE SEQUENCE seq2 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq2" +== 150 +-- truncate_limit: 100 +SELECT nextval('seq2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq2')" +== 151 +-- truncate_limit: 100 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lastval()" +== 152 +-- truncate_limit: 100 +DROP SEQUENCE seq2 +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE seq2" +== 153 +-- truncate_limit: 100 +-- should fail +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lastval()" +== 154 +-- truncate_limit: 100 +-- unlogged sequences +-- (more tests in src/test/recovery/) +CREATE UNLOGGED SEQUENCE sequence_test_unlogged +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE UNLOGGED SEQUENCE sequence_test_unlogged" +== 155 +-- truncate_limit: 100 +ALTER SEQUENCE sequence_test_unlogged SET LOGGED +-- +TABLE: name="sequence_test_unlogged" schema="" table="sequence_test_unlogged" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER SEQUENCE sequence_test_unlogged SET LOGGED" +== 156 +-- truncate_limit: 100 +ALTER SEQUENCE sequence_test_unlogged SET UNLOGGED +-- +TABLE: name="sequence_test_unlogged" schema="" table="sequence_test_unlogged" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER SEQUENCE sequence_test_unlogged SET UNLOGGED" +== 157 +-- truncate_limit: 100 +DROP SEQUENCE sequence_test_unlogged +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE sequence_test_unlogged" +== 158 +-- truncate_limit: 100 +-- Test sequences in read-only transactions +CREATE TEMPORARY SEQUENCE sequence_test_temp1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE sequence_test_temp1" +== 159 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 160 +-- truncate_limit: 100 +SELECT nextval('sequence_test_temp1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test_temp1')" +== 161 +-- truncate_limit: 100 +-- ok +SELECT nextval('sequence_test2') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('sequence_test2')" +== 162 +-- truncate_limit: 100 +-- error +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 163 +-- truncate_limit: 100 +START TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ ONLY" +== 164 +-- truncate_limit: 100 +SELECT setval('sequence_test_temp1', 1) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test_temp1', 1)" +== 165 +-- truncate_limit: 100 +-- ok +SELECT setval('sequence_test2', 1) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('sequence_test2', 1)" +== 166 +-- truncate_limit: 100 +-- error +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 167 +-- truncate_limit: 100 +-- privileges tests + +CREATE USER regress_seq_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_seq_user" +== 168 +-- truncate_limit: 100 +-- nextval +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 169 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 170 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 171 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 172 +-- truncate_limit: 100 +GRANT SELECT ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON seq3 TO regress_seq_user" +== 173 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 174 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 175 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 176 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 177 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 178 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 179 +-- truncate_limit: 100 +GRANT UPDATE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON seq3 TO regress_seq_user" +== 180 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 181 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 182 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 183 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 184 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 185 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 186 +-- truncate_limit: 100 +GRANT USAGE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT usage ON seq3 TO regress_seq_user" +== 187 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 188 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 189 +-- truncate_limit: 100 +-- currval +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 190 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 191 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 192 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 193 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 194 +-- truncate_limit: 100 +GRANT SELECT ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON seq3 TO regress_seq_user" +== 195 +-- truncate_limit: 100 +SELECT currval('seq3') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currval('seq3')" +== 196 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 197 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 198 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 199 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 200 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 201 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 202 +-- truncate_limit: 100 +GRANT UPDATE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON seq3 TO regress_seq_user" +== 203 +-- truncate_limit: 100 +SELECT currval('seq3') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currval('seq3')" +== 204 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 205 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 206 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 207 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 208 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 209 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 210 +-- truncate_limit: 100 +GRANT USAGE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT usage ON seq3 TO regress_seq_user" +== 211 +-- truncate_limit: 100 +SELECT currval('seq3') +-- +FUNCTION: name="currval" function="currval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currval('seq3')" +== 212 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 213 +-- truncate_limit: 100 +-- lastval +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 214 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 215 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 216 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 217 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 218 +-- truncate_limit: 100 +GRANT SELECT ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON seq3 TO regress_seq_user" +== 219 +-- truncate_limit: 100 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lastval()" +== 220 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 221 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 222 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 223 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 224 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 225 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 226 +-- truncate_limit: 100 +GRANT UPDATE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON seq3 TO regress_seq_user" +== 227 +-- truncate_limit: 100 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lastval()" +== 228 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 229 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 230 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 231 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 232 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 233 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 234 +-- truncate_limit: 100 +GRANT USAGE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT usage ON seq3 TO regress_seq_user" +== 235 +-- truncate_limit: 100 +SELECT lastval() +-- +FUNCTION: name="lastval" function="lastval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT lastval()" +== 236 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 237 +-- truncate_limit: 100 +-- setval +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 238 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 239 +-- truncate_limit: 100 +CREATE SEQUENCE seq3 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE seq3" +== 240 +-- truncate_limit: 100 +REVOKE ALL ON seq3 FROM regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON seq3 FROM regress_seq_user" +== 241 +-- truncate_limit: 100 +SAVEPOINT save +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT save" +== 242 +-- truncate_limit: 100 +SELECT setval('seq3', 5) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('seq3', 5)" +== 243 +-- truncate_limit: 100 +ROLLBACK TO save +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT save" +== 244 +-- truncate_limit: 100 +GRANT UPDATE ON seq3 TO regress_seq_user +-- +TABLE: name="seq3" schema="" table="seq3" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON seq3 TO regress_seq_user" +== 245 +-- truncate_limit: 100 +SELECT setval('seq3', 5) +-- +FUNCTION: name="setval" function="setval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setval('seq3', 5)" +== 246 +-- truncate_limit: 100 +SELECT nextval('seq3') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('seq3')" +== 247 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 248 +-- truncate_limit: 100 +-- ALTER SEQUENCE +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 249 +-- truncate_limit: 100 +SET LOCAL SESSION AUTHORIZATION regress_seq_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL session_authorization TO regress_seq_user" +== 250 +-- truncate_limit: 100 +ALTER SEQUENCE sequence_test2 START WITH 1 +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE sequence_test2 START 1" +== 251 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 252 +-- truncate_limit: 100 +-- Sequences should get wiped out as well: +DROP TABLE serialTest1, serialTest2 +-- +TABLE: name="serialtest1" schema="" table="serialtest1" ctx=DDL +TABLE: name="serialtest2" schema="" table="serialtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE serialtest1, serialtest2" +== 253 +-- truncate_limit: 100 +-- Make sure sequences are gone: +SELECT * FROM information_schema.sequences WHERE sequence_name IN + ('sequence_test2', 'serialtest2_f2_seq', 'serialtest2_f3_seq', + 'serialtest2_f4_seq', 'serialtest2_f5_seq', 'serialtest2_f6_seq') + ORDER BY sequence_name ASC +-- +TABLE: name="information_schema.sequences" schema="information_schema" table="sequences" ctx=Select +FILTER: schema="" table="" column="sequence_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.sequences WHERE ... ORDER BY sequence_name ASC" +== 254 +-- truncate_limit: 100 +DROP USER regress_seq_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_seq_user" +== 255 +-- truncate_limit: 100 +DROP SEQUENCE seq +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE seq" +== 256 +-- truncate_limit: 100 +-- cache tests +CREATE SEQUENCE test_seq1 CACHE 10 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE test_seq1 CACHE 10" +== 257 +-- truncate_limit: 100 +SELECT nextval('test_seq1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('test_seq1')" +== 258 +-- truncate_limit: 100 +SELECT nextval('test_seq1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('test_seq1')" +== 259 +-- truncate_limit: 100 +SELECT nextval('test_seq1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('test_seq1')" +== 260 +-- truncate_limit: 100 +DROP SEQUENCE test_seq1 +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE test_seq1" diff --git a/parser/testdata/summary_truncate/postgres_regress/spgist.metadata.json b/parser/testdata/summary_truncate/postgres_regress/spgist.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/spgist.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/spgist.test b/parser/testdata/summary_truncate/postgres_regress/spgist.test new file mode 100644 index 0000000..9ba0142 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/spgist.test @@ -0,0 +1,301 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test SP-GiST indexes. +|-- +-- There are other tests to test different SP-GiST opclasses. This is for +-- testing SP-GiST code itself. + +create table spgist_point_tbl(id int4, p point) +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE spgist_point_tbl (id int4, p point)" +== 002 +-- truncate_limit: 100 +create index spgist_point_idx on spgist_point_tbl using spgist(p) with (fillfactor = 75) +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX spgist_point_idx ON spgist_point_tbl USING spgist (p) WITH (fillfactor=75)" +== 003 +-- truncate_limit: 100 +-- Test vacuum-root operation. It gets invoked when the root is also a leaf, +-- i.e. the index is very small. +insert into spgist_point_tbl (id, p) +select g, point(g*10, g*10) from generate_series(1, 10) g +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO spgist_point_tbl (id, p) SELECT g, point(g * 10, g * 10) FROM generate_series(1, 10) g" +== 004 +-- truncate_limit: 100 +delete from spgist_point_tbl where id < 5 +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM spgist_point_tbl WHERE id < 5" +== 005 +-- truncate_limit: 100 +vacuum spgist_point_tbl +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM spgist_point_tbl" +== 006 +-- truncate_limit: 100 +-- Insert more data, to make the index a few levels deep. +insert into spgist_point_tbl (id, p) +select g, point(g*10, g*10) from generate_series(1, 10000) g +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO spgist_point_tbl (id, p) SELECT ... FROM generate_series(1, 10000) g" +== 007 +-- truncate_limit: 100 +insert into spgist_point_tbl (id, p) +select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO spgist_point_tbl (id, p) SELECT ... FROM generate_series(1, 10000) g" +== 008 +-- truncate_limit: 100 +-- To test vacuum, delete some entries from all over the index. +delete from spgist_point_tbl where id % 2 = 1 +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM spgist_point_tbl WHERE (id % 2) = 1" +== 009 +-- truncate_limit: 100 +-- And also delete some concentration of values. (SP-GiST doesn't currently +-- attempt to delete pages even when they become empty, but if it did, this +-- would exercise it) +delete from spgist_point_tbl where id < 10000 +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM spgist_point_tbl WHERE id < 10000" +== 010 +-- truncate_limit: 100 +vacuum spgist_point_tbl +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM spgist_point_tbl" +== 011 +-- truncate_limit: 100 +-- Test rescan paths (cf. bug #15378) +-- use box and && rather than point, so that rescan happens when the +-- traverse stack is non-empty + +create table spgist_box_tbl(id serial, b box) +-- +TABLE: name="spgist_box_tbl" schema="" table="spgist_box_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE spgist_box_tbl (id serial, b box)" +== 012 +-- truncate_limit: 100 +insert into spgist_box_tbl(b) +select box(point(i,j),point(i+s,j+s)) + from generate_series(1,100,5) i, + generate_series(1,100,5) j, + generate_series(1,10) s +-- +TABLE: name="spgist_box_tbl" schema="" table="spgist_box_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO spgist_box_tbl (...) SELECT ... FROM generate_series(1, 100, 5) i, generate_series(1,..." +== 013 +-- truncate_limit: 100 +create index spgist_box_idx on spgist_box_tbl using spgist (b) +-- +TABLE: name="spgist_box_tbl" schema="" table="spgist_box_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX spgist_box_idx ON spgist_box_tbl USING spgist (b)" +== 014 +-- truncate_limit: 100 +select count(*) + from (values (point(5,5)),(point(8,8)),(point(12,12))) v(p) + where exists(select * from spgist_box_tbl b where b.b && box(v.p,v.p)) +-- +TABLE: name="spgist_box_tbl" schema="" table="spgist_box_tbl" ctx=Select +ALIAS: "b"="spgist_box_tbl" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="box" function="box" schema="" ctx=Call +FILTER: schema="" table="b" column="b" +FILTER: schema="" table="v" column="p" +FILTER: schema="" table="v" column="p" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (VALUES (...)) v(p) WHERE EXISTS (SELECT * FROM spgist_box_tbl b WHERE ...)" +== 015 +-- truncate_limit: 100 +-- The point opclass's choose method only uses the spgMatchNode action, +-- so the other actions are not tested by the above. Create an index using +-- text opclass, which uses the others actions. + +create table spgist_text_tbl(id int4, t text) +-- +TABLE: name="spgist_text_tbl" schema="" table="spgist_text_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE spgist_text_tbl (id int4, t text)" +== 016 +-- truncate_limit: 100 +create index spgist_text_idx on spgist_text_tbl using spgist(t) +-- +TABLE: name="spgist_text_tbl" schema="" table="spgist_text_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX spgist_text_idx ON spgist_text_tbl USING spgist (t)" +== 017 +-- truncate_limit: 100 +insert into spgist_text_tbl (id, t) +select g, 'f' || repeat('o', 100) || g from generate_series(1, 10000) g +union all +select g, 'baaaaaaaaaaaaaar' || g from generate_series(1, 1000) g +-- +TABLE: name="spgist_text_tbl" schema="" table="spgist_text_tbl" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO spgist_text_tbl (...) SELECT ... FROM generate_series(1, 10000) g UNION ALL SELECT ....." +== 018 +-- truncate_limit: 100 +-- Do a lot of insertions that have to split an existing node. Hopefully +-- one of these will cause the page to run out of space, causing the inner +-- tuple to be moved to another page. +insert into spgist_text_tbl (id, t) +select -g, 'f' || repeat('o', 100-g) || 'surprise' from generate_series(1, 100) g +-- +TABLE: name="spgist_text_tbl" schema="" table="spgist_text_tbl" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO spgist_text_tbl (id, t) SELECT ... FROM generate_series(1, 100) g" +== 019 +-- truncate_limit: 100 +-- Test out-of-range fillfactor values +create index spgist_point_idx2 on spgist_point_tbl using spgist(p) with (fillfactor = 9) +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX spgist_point_idx2 ON spgist_point_tbl USING spgist (p) WITH (fillfactor=9)" +== 020 +-- truncate_limit: 100 +create index spgist_point_idx2 on spgist_point_tbl using spgist(p) with (fillfactor = 101) +-- +TABLE: name="spgist_point_tbl" schema="" table="spgist_point_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX spgist_point_idx2 ON spgist_point_tbl USING spgist (p) WITH (fillfactor=101)" +== 021 +-- truncate_limit: 100 +-- Modify fillfactor in existing index +alter index spgist_point_idx set (fillfactor = 90) +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX spgist_point_idx SET (fillfactor=90)" +== 022 +-- truncate_limit: 100 +reindex index spgist_point_idx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX INDEX spgist_point_idx" +== 023 +-- truncate_limit: 100 +-- Test index over a domain +create domain spgist_text as varchar +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN spgist_text AS varchar" +== 024 +-- truncate_limit: 100 +create table spgist_domain_tbl (f1 spgist_text) +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE spgist_domain_tbl (f1 spgist_text)" +== 025 +-- truncate_limit: 100 +create index spgist_domain_idx on spgist_domain_tbl using spgist(f1) +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX spgist_domain_idx ON spgist_domain_tbl USING spgist (f1)" +== 026 +-- truncate_limit: 100 +insert into spgist_domain_tbl values('fee'), ('fi'), ('fo'), ('fum') +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO spgist_domain_tbl VALUES ('fee'), ('fi'), ('fo'), ('fum')" +== 027 +-- truncate_limit: 100 +explain (costs off) +select * from spgist_domain_tbl where f1 = 'fo' +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM spgist_domain_tbl WHERE f1 = 'fo'" +== 028 +-- truncate_limit: 100 +select * from spgist_domain_tbl where f1 = 'fo' +-- +TABLE: name="spgist_domain_tbl" schema="" table="spgist_domain_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM spgist_domain_tbl WHERE f1 = 'fo'" +== 029 +-- truncate_limit: 100 +-- test an unlogged table, mostly to get coverage of spgistbuildempty +create unlogged table spgist_unlogged_tbl(id serial, b box) +-- +TABLE: name="spgist_unlogged_tbl" schema="" table="spgist_unlogged_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE UNLOGGED TABLE spgist_unlogged_tbl (id serial, b box)" +== 030 +-- truncate_limit: 100 +create index spgist_unlogged_idx on spgist_unlogged_tbl using spgist (b) +-- +TABLE: name="spgist_unlogged_tbl" schema="" table="spgist_unlogged_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX spgist_unlogged_idx ON spgist_unlogged_tbl USING spgist (b)" +== 031 +-- truncate_limit: 100 +insert into spgist_unlogged_tbl(b) +select box(point(i,j)) + from generate_series(1,100,5) i, + generate_series(1,10,5) j +-- +TABLE: name="spgist_unlogged_tbl" schema="" table="spgist_unlogged_tbl" ctx=DML +FUNCTION: name="box" function="box" schema="" ctx=Call +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO spgist_unlogged_tbl (...) SELECT ... FROM generate_series(1, 100, 5) i, generate_seri..." diff --git a/parser/testdata/summary_truncate/postgres_regress/sqljson.metadata.json b/parser/testdata/summary_truncate/postgres_regress/sqljson.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sqljson.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/sqljson.test b/parser/testdata/summary_truncate/postgres_regress/sqljson.test new file mode 100644 index 0000000..388cf9d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sqljson.test @@ -0,0 +1,1596 @@ +== 001 +-- truncate_limit: 100 +-- JSON() +SELECT JSON() +-- +ERROR: syntax error at or near ")" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +SELECT JSON(NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON(NULL )" +== 003 +-- truncate_limit: 100 +SELECT JSON('{ "a" : 1 } ') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON('{ \"a\" : 1 } ' )" +== 004 +-- truncate_limit: 100 +SELECT JSON('{ "a" : 1 } ' FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON('{ \"a\" : 1 } ' FORMAT JSON )" +== 005 +-- truncate_limit: 100 +SELECT JSON('{ "a" : 1 } ' FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON('{ \"a\" : 1 } ' FORMAT JSON ENCODING utf8 )" +== 006 +-- truncate_limit: 100 +SELECT JSON('{ "a" : 1 } '::bytea FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON('{ \"a\" : 1 } '::bytea FORMAT JSON ENCODING utf8 )" +== 007 +-- truncate_limit: 100 +SELECT pg_typeof(JSON('{ "a" : 1 } ')) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(JSON('{ \"a\" : 1 } ' ))" +== 008 +-- truncate_limit: 100 +SELECT JSON(' 1 '::json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON(' 1 '::pg_catalog.json )" +== 009 +-- truncate_limit: 100 +SELECT JSON(' 1 '::jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON(' 1 '::jsonb )" +== 010 +-- truncate_limit: 100 +SELECT JSON(' 1 '::json WITH UNIQUE KEYS) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON(' 1 '::pg_catalog.json WITH UNIQUE KEYS)" +== 011 +-- truncate_limit: 100 +SELECT JSON(123) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON(123 )" +== 012 +-- truncate_limit: 100 +SELECT JSON('{"a": 1, "a": 2}') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON('{\"a\": 1, \"a\": 2}' )" +== 013 +-- truncate_limit: 100 +SELECT JSON('{"a": 1, "a": 2}' WITH UNIQUE KEYS) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON('{\"a\": 1, \"a\": 2}' WITH UNIQUE KEYS)" +== 014 +-- truncate_limit: 100 +SELECT JSON('{"a": 1, "a": 2}' WITHOUT UNIQUE KEYS) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON('{\"a\": 1, \"a\": 2}' )" +== 015 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123') +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' )" +== 016 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' FORMAT JSON) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' FORMAT JSON )" +== 017 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123'::bytea FORMAT JSON) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123'::bytea FORMAT JSON )" +== 018 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123'::bytea FORMAT JSON ENCODING UTF8) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123'::bytea FORMAT JSON ENCODING utf8 )" +== 019 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' WITH UNIQUE KEYS) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' WITH UNIQUE KEYS)" +== 020 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' WITHOUT UNIQUE KEYS) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' )" +== 021 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123') +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON('123' )" +== 022 +-- truncate_limit: 100 +SELECT pg_typeof(JSON('123')) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(JSON('123' ))" +== 023 +-- truncate_limit: 100 +-- JSON_SCALAR() +SELECT JSON_SCALAR() +-- +ERROR: syntax error at or near ")" +CURSORPOS: 37 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 024 +-- truncate_limit: 100 +SELECT JSON_SCALAR(NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR(NULL)" +== 025 +-- truncate_limit: 100 +SELECT JSON_SCALAR(NULL::int) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR(NULL::int)" +== 026 +-- truncate_limit: 100 +SELECT JSON_SCALAR(123) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR(123)" +== 027 +-- truncate_limit: 100 +SELECT JSON_SCALAR(123.45) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR(123.45)" +== 028 +-- truncate_limit: 100 +SELECT JSON_SCALAR(123.45::numeric) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR((123.45)::numeric)" +== 029 +-- truncate_limit: 100 +SELECT JSON_SCALAR(true) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR(true)" +== 030 +-- truncate_limit: 100 +SELECT JSON_SCALAR(false) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR(false)" +== 031 +-- truncate_limit: 100 +SELECT JSON_SCALAR(' 123.45') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR(' 123.45')" +== 032 +-- truncate_limit: 100 +SELECT JSON_SCALAR('2020-06-07'::date) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR('2020-06-07'::date)" +== 033 +-- truncate_limit: 100 +SELECT JSON_SCALAR('2020-06-07 01:02:03'::timestamp) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR('2020-06-07 01:02:03'::timestamp)" +== 034 +-- truncate_limit: 100 +SELECT JSON_SCALAR('{}'::json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR('{}'::pg_catalog.json)" +== 035 +-- truncate_limit: 100 +SELECT JSON_SCALAR('{}'::jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SCALAR('{}'::jsonb)" +== 036 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR(123) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR(123)" +== 037 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR('123') +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SCALAR('123')" +== 038 +-- truncate_limit: 100 +-- JSON_SERIALIZE() +SELECT JSON_SERIALIZE() +-- +ERROR: syntax error at or near ")" +CURSORPOS: 43 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 039 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE(NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE(NULL )" +== 040 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE(JSON('{ "a" : 1 } ')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE(JSON('{ \"a\" : 1 } ' ) )" +== 041 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE('{ "a" : 1 } ') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('{ \"a\" : 1 } ' )" +== 042 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE('1') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('1' )" +== 043 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE('1' FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('1' FORMAT JSON )" +== 044 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING bytea) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('{ \"a\" : 1 } ' RETURNING bytea )" +== 045 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING varchar) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('{ \"a\" : 1 } ' RETURNING varchar )" +== 046 +-- truncate_limit: 100 +SELECT pg_typeof(JSON_SERIALIZE(NULL)) +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_typeof(JSON_SERIALIZE(NULL ))" +== 047 +-- truncate_limit: 100 +-- only string types or bytea allowed +SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('{ \"a\" : 1 } ' RETURNING jsonb )" +== 048 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}') +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}' )" +== 049 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}' RETURNING bytea) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_SERIALIZE('{}' RETURNING bytea )" +== 050 +-- truncate_limit: 100 +-- JSON_OBJECT() +SELECT JSON_OBJECT() +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT()" +== 051 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING pg_catalog.json)" +== 052 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING json FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING pg_catalog.json FORMAT JSON)" +== 053 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING jsonb)" +== 054 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING jsonb FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING jsonb FORMAT JSON)" +== 055 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING text)" +== 056 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING text FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING text FORMAT JSON)" +== 057 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING text FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING text FORMAT JSON ENCODING utf8)" +== 058 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING text FORMAT JSON ENCODING INVALID_ENCODING) +-- +ERROR: unrecognized JSON encoding: invalid_encoding +FILENAME: gram.y +FUNCNAME: base_yyparse +== 059 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING bytea) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING bytea)" +== 060 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING bytea FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING bytea FORMAT JSON)" +== 061 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING bytea FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING bytea FORMAT JSON ENCODING utf8)" +== 062 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING bytea FORMAT JSON ENCODING UTF16) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING bytea FORMAT JSON ENCODING utf16)" +== 063 +-- truncate_limit: 100 +SELECT JSON_OBJECT(RETURNING bytea FORMAT JSON ENCODING UTF32) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT( RETURNING bytea FORMAT JSON ENCODING utf32)" +== 064 +-- truncate_limit: 100 +SELECT JSON_OBJECT('foo': NULL::int FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('foo': NULL::int FORMAT JSON)" +== 065 +-- truncate_limit: 100 +SELECT JSON_OBJECT('foo': NULL::int FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('foo': NULL::int FORMAT JSON ENCODING utf8)" +== 066 +-- truncate_limit: 100 +SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('foo': NULL::pg_catalog.json FORMAT JSON)" +== 067 +-- truncate_limit: 100 +SELECT JSON_OBJECT('foo': NULL::json FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('foo': NULL::pg_catalog.json FORMAT JSON ENCODING utf8)" +== 068 +-- truncate_limit: 100 +SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON)" +== 069 +-- truncate_limit: 100 +SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('foo': NULL::jsonb FORMAT JSON ENCODING utf8)" +== 070 +-- truncate_limit: 100 +SELECT JSON_OBJECT(NULL: 1) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(NULL: 1)" +== 071 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': 2 + 3) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': 2 + 3)" +== 072 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a' VALUE 2 + 3) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': 2 + 3)" +== 073 +-- truncate_limit: 100 +--SELECT JSON_OBJECT(KEY 'a' VALUE 2 + 3); +SELECT JSON_OBJECT('a' || 2: 1) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a' || 2: 1)" +== 074 +-- truncate_limit: 100 +SELECT JSON_OBJECT(('a' || 2) VALUE 1) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a' || 2: 1)" +== 075 +-- truncate_limit: 100 +--SELECT JSON_OBJECT('a' || 2 VALUE 1); +--SELECT JSON_OBJECT(KEY 'a' || 2 VALUE 1); +SELECT JSON_OBJECT('a': 2::text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': 2::text)" +== 076 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a' VALUE 2::text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': 2::text)" +== 077 +-- truncate_limit: 100 +--SELECT JSON_OBJECT(KEY 'a' VALUE 2::text); +SELECT JSON_OBJECT(1::text: 2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1::text: 2)" +== 078 +-- truncate_limit: 100 +SELECT JSON_OBJECT((1::text) VALUE 2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1::text: 2)" +== 079 +-- truncate_limit: 100 +--SELECT JSON_OBJECT(1::text VALUE 2); +--SELECT JSON_OBJECT(KEY 1::text VALUE 2); +SELECT JSON_OBJECT(json '[1]': 123) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('[1]'::pg_catalog.json: 123)" +== 080 +-- truncate_limit: 100 +SELECT JSON_OBJECT(ARRAY[1,2,3]: 'aaa') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(ARRAY[1, 2, 3]: 'aaa')" +== 081 +-- truncate_limit: 100 +SELECT JSON_OBJECT( + 'a': '123', + 1.23: 123, + 'c': json '[ 1,true,{ } ]', + 'd': jsonb '{ "x" : 123.45 }' +) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 082 +-- truncate_limit: 100 +SELECT JSON_OBJECT( + 'a': '123', + 1.23: 123, + 'c': json '[ 1,true,{ } ]', + 'd': jsonb '{ "x" : 123.45 }' + RETURNING jsonb +) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 083 +-- truncate_limit: 100 +/* +SELECT JSON_OBJECT( + 'a': '123', + KEY 1.23 VALUE 123, + 'c' VALUE json '[1, true, {}]' +); +*/ + +SELECT JSON_OBJECT('a': '123', 'b': JSON_OBJECT('a': 111, 'b': 'aaa')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': '123', 'b': JSON_OBJECT('a': 111, 'b': 'aaa'))" +== 084 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': '123', 'b': JSON_OBJECT('a': 111, 'b': 'aaa' RETURNING jsonb)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': '123', 'b': JSON_OBJECT('a': 111, 'b': 'aaa' RETURNING jsonb))" +== 085 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING text)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING text))" +== 086 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING text) FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING text) FORMAT JSON)" +== 087 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING bytea)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING bytea))" +== 088 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING bytea) FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING bytea) FORMAT JSON)" +== 089 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2)" +== 090 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2 NULL ON NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2)" +== 091 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2 ABSENT ON NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': '1', 'b': NULL, 'c': 2 ABSENT ON NULL)" +== 092 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '2': NULL, '3': 1, repeat('x', 1000): 1, 2: repeat('a', 100) WITH UNIQUE) +-- +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '2': NULL, '3': 1, repeat('x', 1000): 1, 2: repeat('a', 100) WITH UNIQUE)" +== 093 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '1': NULL WITH UNIQUE) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '1': NULL WITH UNIQUE)" +== 094 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '1': NULL ABSENT ON NULL WITH UNIQUE) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '1': NULL ABSENT ON NULL WITH UNIQUE)" +== 095 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '1': NULL NULL ON NULL WITH UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '1': NULL WITH UNIQUE RETURNING jsonb)" +== 096 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '1': NULL ABSENT ON NULL WITH UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '1': NULL ABSENT ON NULL WITH UNIQUE RETURNING jsonb)" +== 097 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 NULL ON NULL WITH UNIQUE) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 WITH UNIQUE)" +== 098 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITH UNIQUE) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITH UNIQUE)" +== 099 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITHOUT UNIQUE) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL)" +== 100 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITH UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITH UNIQUE RETURNING jsonb)" +== 101 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL WITHOUT UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT(1: 1, '2': NULL, '1': 1 ABSENT ON NULL RETURNING jsonb)" +== 102 +-- truncate_limit: 100 +SELECT JSON_OBJECT(1: 1, '2': NULL, '3': 1, 4: NULL, '5': 'a' ABSENT ON NULL WITH UNIQUE RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 103 +-- truncate_limit: 100 +-- BUG: https://postgr.es/m/CADXhmgTJtJZK9A3Na_ry%2BXrq-ghjcejBRhcRMzWZvbd__QdgJA%40mail.gmail.com +-- datum_to_jsonb_internal() didn't catch keys that are casts instead of a simple scalar +CREATE TYPE mood AS ENUM ('happy', 'sad', 'neutral') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE mood AS ENUM ('happy', 'sad', 'neutral')" +== 104 +-- truncate_limit: 100 +CREATE FUNCTION mood_to_json(mood) RETURNS json AS $$ + SELECT to_json($1::text); +$$ LANGUAGE sql IMMUTABLE +-- +FUNCTION: name="mood_to_json" function="mood_to_json" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mood_to_json(mood) RETURNS pg_catalog.json AS $$\n SELECT to_json($1::text);\n$$ L..." +== 105 +-- truncate_limit: 100 +CREATE CAST (mood AS json) WITH FUNCTION mood_to_json(mood) AS IMPLICIT +-- +STMT: CreateCastStmt +TRUNCATED: "CREATE CAST (mood AS pg_catalog.json) WITH FUNCTION mood_to_json(mood) AS IMPLICIT" +== 106 +-- truncate_limit: 100 +SELECT JSON_OBJECT('happy'::mood: '123'::jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('happy'::mood: '123'::jsonb)" +== 107 +-- truncate_limit: 100 +DROP CAST (mood AS json) +-- +STMT: DropStmt +TRUNCATED: "DROP CAST (mood AS pg_catalog.json)" +== 108 +-- truncate_limit: 100 +DROP FUNCTION mood_to_json +-- +FUNCTION: name="mood_to_json" function="mood_to_json" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION mood_to_json" +== 109 +-- truncate_limit: 100 +DROP TYPE mood +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE mood" +== 110 +-- truncate_limit: 100 +-- JSON_ARRAY() +SELECT JSON_ARRAY() +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY()" +== 111 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING pg_catalog.json)" +== 112 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING json FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING pg_catalog.json FORMAT JSON)" +== 113 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING jsonb)" +== 114 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING jsonb FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING jsonb FORMAT JSON)" +== 115 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING text)" +== 116 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING text FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING text FORMAT JSON)" +== 117 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING text FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING text FORMAT JSON ENCODING utf8)" +== 118 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING text FORMAT JSON ENCODING INVALID_ENCODING) +-- +ERROR: unrecognized JSON encoding: invalid_encoding +FILENAME: gram.y +FUNCNAME: base_yyparse +== 119 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING bytea) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING bytea)" +== 120 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING bytea FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING bytea FORMAT JSON)" +== 121 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING bytea FORMAT JSON ENCODING UTF8) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING bytea FORMAT JSON ENCODING utf8)" +== 122 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING bytea FORMAT JSON ENCODING UTF16) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING bytea FORMAT JSON ENCODING utf16)" +== 123 +-- truncate_limit: 100 +SELECT JSON_ARRAY(RETURNING bytea FORMAT JSON ENCODING UTF32) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY( RETURNING bytea FORMAT JSON ENCODING utf32)" +== 124 +-- truncate_limit: 100 +SELECT JSON_ARRAY('aaa', 111, true, array[1,2,3], NULL, json '{"a": [1]}', jsonb '["a",3]') +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 125 +-- truncate_limit: 100 +SELECT JSON_ARRAY('a', NULL, 'b' NULL ON NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY('a', NULL, 'b' NULL ON NULL)" +== 126 +-- truncate_limit: 100 +SELECT JSON_ARRAY('a', NULL, 'b' ABSENT ON NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY('a', NULL, 'b')" +== 127 +-- truncate_limit: 100 +SELECT JSON_ARRAY(NULL, NULL, 'b' ABSENT ON NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(NULL, NULL, 'b')" +== 128 +-- truncate_limit: 100 +SELECT JSON_ARRAY('a', NULL, 'b' NULL ON NULL RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY('a', NULL, 'b' NULL ON NULL RETURNING jsonb)" +== 129 +-- truncate_limit: 100 +SELECT JSON_ARRAY('a', NULL, 'b' ABSENT ON NULL RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY('a', NULL, 'b' RETURNING jsonb)" +== 130 +-- truncate_limit: 100 +SELECT JSON_ARRAY(NULL, NULL, 'b' ABSENT ON NULL RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(NULL, NULL, 'b' RETURNING jsonb)" +== 131 +-- truncate_limit: 100 +SELECT JSON_ARRAY(JSON_ARRAY('{ "a" : 123 }' RETURNING text)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(JSON_ARRAY('{ \"a\" : 123 }' RETURNING text))" +== 132 +-- truncate_limit: 100 +SELECT JSON_ARRAY(JSON_ARRAY('{ "a" : 123 }' FORMAT JSON RETURNING text)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(JSON_ARRAY('{ \"a\" : 123 }' FORMAT JSON RETURNING text))" +== 133 +-- truncate_limit: 100 +SELECT JSON_ARRAY(JSON_ARRAY('{ "a" : 123 }' FORMAT JSON RETURNING text) FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(JSON_ARRAY('{ \"a\" : 123 }' FORMAT JSON RETURNING text) FORMAT JSON)" +== 134 +-- truncate_limit: 100 +SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL), (4)) foo(i)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL), (4)) foo(i))" +== 135 +-- truncate_limit: 100 +SELECT JSON_ARRAY(SELECT i FROM (VALUES (NULL::int[]), ('{1,2}'), (NULL), (NULL), ('{3,4}'), (NULL)) foo(i)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(SELECT i FROM (VALUES (...)) foo(i))" +== 136 +-- truncate_limit: 100 +SELECT JSON_ARRAY(SELECT i FROM (VALUES (NULL::int[]), ('{1,2}'), (NULL), (NULL), ('{3,4}'), (NULL)) foo(i) RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(SELECT i FROM (VALUES (...)) foo(i) RETURNING jsonb)" +== 137 +-- truncate_limit: 100 +--SELECT JSON_ARRAY(SELECT i FROM (VALUES (NULL::int[]), ('{1,2}'), (NULL), (NULL), ('{3,4}'), (NULL)) foo(i) NULL ON NULL); +--SELECT JSON_ARRAY(SELECT i FROM (VALUES (NULL::int[]), ('{1,2}'), (NULL), (NULL), ('{3,4}'), (NULL)) foo(i) NULL ON NULL RETURNING jsonb); +SELECT JSON_ARRAY(SELECT i FROM (VALUES (3), (1), (NULL), (2)) foo(i) ORDER BY i) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(SELECT i FROM (VALUES (3), (1), (NULL), (2)) foo(i) ORDER BY i)" +== 138 +-- truncate_limit: 100 +SELECT JSON_ARRAY(WITH x AS (SELECT 1) VALUES (TRUE)) +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(WITH x AS (SELECT 1) VALUES (true))" +== 139 +-- truncate_limit: 100 +-- Should fail +SELECT JSON_ARRAY(SELECT FROM (VALUES (1)) foo(i)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(SELECT FROM (VALUES (1)) foo(i))" +== 140 +-- truncate_limit: 100 +SELECT JSON_ARRAY(SELECT i, i FROM (VALUES (1)) foo(i)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(SELECT i, i FROM (VALUES (1)) foo(i))" +== 141 +-- truncate_limit: 100 +SELECT JSON_ARRAY(SELECT * FROM (VALUES (1, 2)) foo(i, j)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(SELECT * FROM (VALUES (1, 2)) foo(i, j))" +== 142 +-- truncate_limit: 100 +-- JSON_ARRAYAGG() +SELECT JSON_ARRAYAGG(i) IS NULL, + JSON_ARRAYAGG(i RETURNING jsonb) IS NULL +FROM generate_series(1, 0) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 0) i" +== 143 +-- truncate_limit: 100 +SELECT JSON_ARRAYAGG(i), + JSON_ARRAYAGG(i RETURNING jsonb) +FROM generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAYAGG(i), JSON_ARRAYAGG(i RETURNING jsonb) FROM generate_series(1, 5) i" +== 144 +-- truncate_limit: 100 +SELECT JSON_ARRAYAGG(i ORDER BY i DESC) +FROM generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAYAGG(i ORDER BY i DESC) FROM generate_series(1, 5) i" +== 145 +-- truncate_limit: 100 +SELECT JSON_ARRAYAGG(i::text::json) +FROM generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAYAGG(i::text::pg_catalog.json) FROM generate_series(1, 5) i" +== 146 +-- truncate_limit: 100 +SELECT JSON_ARRAYAGG(JSON_ARRAY(i, i + 1 RETURNING text) FORMAT JSON) +FROM generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAYAGG(JSON_ARRAY(i, i + 1 RETURNING text) FORMAT JSON) FROM generate_series(1, 5) i" +== 147 +-- truncate_limit: 100 +SELECT JSON_ARRAYAGG(NULL), + JSON_ARRAYAGG(NULL RETURNING jsonb) +FROM generate_series(1, 5) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAYAGG(NULL), JSON_ARRAYAGG(NULL RETURNING jsonb) FROM generate_series(1, 5)" +== 148 +-- truncate_limit: 100 +SELECT JSON_ARRAYAGG(NULL NULL ON NULL), + JSON_ARRAYAGG(NULL NULL ON NULL RETURNING jsonb) +FROM generate_series(1, 5) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 5)" +== 149 +-- truncate_limit: 100 +SELECT + JSON_ARRAYAGG(bar) as no_options, + JSON_ARRAYAGG(bar RETURNING jsonb) as returning_jsonb, + JSON_ARRAYAGG(bar ABSENT ON NULL) as absent_on_null, + JSON_ARRAYAGG(bar ABSENT ON NULL RETURNING jsonb) as absentonnull_returning_jsonb, + JSON_ARRAYAGG(bar NULL ON NULL) as null_on_null, + JSON_ARRAYAGG(bar NULL ON NULL RETURNING jsonb) as nullonnull_returning_jsonb, + JSON_ARRAYAGG(foo) as row_no_options, + JSON_ARRAYAGG(foo RETURNING jsonb) as row_returning_jsonb, + JSON_ARRAYAGG(foo ORDER BY bar) FILTER (WHERE bar > 2) as row_filtered_agg, + JSON_ARRAYAGG(foo ORDER BY bar RETURNING jsonb) FILTER (WHERE bar > 2) as row_filtered_agg_returning_jsonb +FROM + (VALUES (NULL), (3), (1), (NULL), (NULL), (5), (2), (4), (NULL)) foo(bar) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) foo(bar)" +== 150 +-- truncate_limit: 100 +SELECT + bar, JSON_ARRAYAGG(bar) FILTER (WHERE bar > 2) OVER (PARTITION BY foo.bar % 2) +FROM + (VALUES (NULL), (3), (1), (NULL), (NULL), (5), (2), (4), (NULL), (5), (4)) foo(bar) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) foo(bar)" +== 151 +-- truncate_limit: 100 +-- JSON_OBJECTAGG() +SELECT JSON_OBJECTAGG('key': 1) IS NULL, + JSON_OBJECTAGG('key': 1 RETURNING jsonb) IS NULL +WHERE FALSE +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... WHERE false" +== 152 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(NULL: 1) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(NULL: 1)" +== 153 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(NULL: 1 RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(NULL: 1 RETURNING jsonb)" +== 154 +-- truncate_limit: 100 +SELECT + JSON_OBJECTAGG(i: i), +-- JSON_OBJECTAGG(i VALUE i), +-- JSON_OBJECTAGG(KEY i VALUE i), + JSON_OBJECTAGG(i: i RETURNING jsonb) +FROM + generate_series(1, 5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(i: i), JSON_OBJECTAGG(i: i RETURNING jsonb) FROM generate_series(1, 5) i" +== 155 +-- truncate_limit: 100 +SELECT + JSON_OBJECTAGG(k: v), + JSON_OBJECTAGG(k: v NULL ON NULL), + JSON_OBJECTAGG(k: v ABSENT ON NULL), + JSON_OBJECTAGG(k: v RETURNING jsonb), + JSON_OBJECTAGG(k: v NULL ON NULL RETURNING jsonb), + JSON_OBJECTAGG(k: v ABSENT ON NULL RETURNING jsonb) +FROM + (VALUES (1, 1), (1, NULL), (2, NULL), (3, 3)) foo(k, v) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) foo(k, v)" +== 156 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(k: v WITH UNIQUE KEYS) +FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(k: v WITH UNIQUE) FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v)" +== 157 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS) +FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE) FROM (VALUES (...)) foo(k, v)" +== 158 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS) +FROM (VALUES (1, 1), (0, NULL), (3, NULL), (2, 2), (4, NULL)) foo(k, v) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE) FROM (VALUES (...)) foo(k, v)" +== 159 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(k: v WITH UNIQUE KEYS RETURNING jsonb) +FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(k: v WITH UNIQUE RETURNING jsonb) FROM (VALUES (...)) foo(k, v)" +== 160 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING jsonb) +FROM (VALUES (1, 1), (1, NULL), (2, 2)) foo(k, v) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE RETURNING jsonb) FROM (VALUES (...)) foo(k, v)" +== 161 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE KEYS RETURNING jsonb) +FROM (VALUES (1, 1), (0, NULL),(4, null), (5, null),(6, null),(2, 2)) foo(k, v) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL WITH UNIQUE RETURNING jsonb) FROM (VALUES (...)) foo(k, v)" +== 162 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(mod(i,100): (i)::text FORMAT JSON WITH UNIQUE) +FROM generate_series(0, 199) i +-- +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECTAGG(mod(i, 100): i::text FORMAT JSON WITH UNIQUE) FROM generate_series(0, 199) i" +== 163 +-- truncate_limit: 100 +-- Test JSON_OBJECT deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_OBJECT('foo' : '1' FORMAT JSON, 'bar' : 'baz' RETURNING json) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('foo': '1' FORMAT JSON, 'bar': 'baz' RETURNING pg..." +== 164 +-- truncate_limit: 100 +CREATE VIEW json_object_view AS +SELECT JSON_OBJECT('foo' : '1' FORMAT JSON, 'bar' : 'baz' RETURNING json) +-- +TABLE: name="json_object_view" schema="" table="json_object_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_object_view AS SELECT JSON_OBJECT('foo': '1' FORMAT JSON, 'bar': 'baz' RETURNING..." +== 165 +-- truncate_limit: 100 +DROP VIEW json_object_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW json_object_view" +== 166 +-- truncate_limit: 100 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v WITH UNIQUE KEYS) OVER (ORDER BY k) +FROM (VALUES (1,1), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) a(k, v)" +== 167 +-- truncate_limit: 100 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v WITH UNIQUE KEYS) OVER (ORDER BY k) +FROM (VALUES (1,1), (1,2), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) a(k, v)" +== 168 +-- truncate_limit: 100 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v ABSENT ON NULL WITH UNIQUE KEYS) + OVER (ORDER BY k) +FROM (VALUES (1,1), (1,null), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) a(k, v)" +== 169 +-- truncate_limit: 100 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v ABSENT ON NULL) +OVER (ORDER BY k) +FROM (VALUES (1,1), (1,null), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) a(k, v)" +== 170 +-- truncate_limit: 100 +SELECT to_json(a) AS a, JSON_OBJECTAGG(k : v ABSENT ON NULL) +OVER (ORDER BY k RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) +FROM (VALUES (1,1), (1,null), (2,2)) a(k,v) +-- +FUNCTION: name="to_json" function="to_json" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) a(k, v)" +== 171 +-- truncate_limit: 100 +-- Test JSON_ARRAY deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_ARRAY('1' FORMAT JSON, 2 RETURNING json) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_ARRAY('1' FORMAT JSON, 2 RETURNING pg_catalog.json)" +== 172 +-- truncate_limit: 100 +CREATE VIEW json_array_view AS +SELECT JSON_ARRAY('1' FORMAT JSON, 2 RETURNING json) +-- +TABLE: name="json_array_view" schema="" table="json_array_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_array_view AS SELECT JSON_ARRAY('1' FORMAT JSON, 2 RETURNING pg_catalog.json)" +== 173 +-- truncate_limit: 100 +DROP VIEW json_array_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW json_array_view" +== 174 +-- truncate_limit: 100 +-- Test JSON_OBJECTAGG deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING text) FILTER (WHERE i > 3) +FROM generate_series(1,5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE..." +== 175 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING text) OVER (PARTITION BY i % 2) +FROM generate_series(1,5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE..." +== 176 +-- truncate_limit: 100 +CREATE VIEW json_objectagg_view AS +SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING text) FILTER (WHERE i > 3) +FROM generate_series(1,5) i +-- +TABLE: name="json_objectagg_view" schema="" table="json_objectagg_view" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_objectagg_view AS SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH ..." +== 177 +-- truncate_limit: 100 +DROP VIEW json_objectagg_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW json_objectagg_view" +== 178 +-- truncate_limit: 100 +-- Test JSON_ARRAYAGG deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RETURNING text) FILTER (WHERE i > 3) +FROM generate_series(1,5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RE..." +== 179 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RETURNING text) OVER (PARTITION BY i % 2) +FROM generate_series(1,5) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RE..." +== 180 +-- truncate_limit: 100 +CREATE VIEW json_arrayagg_view AS +SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RETURNING text) FILTER (WHERE i > 3) +FROM generate_series(1,5) i +-- +TABLE: name="json_arrayagg_view" schema="" table="json_arrayagg_view" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_arrayagg_view AS SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NU..." +== 181 +-- truncate_limit: 100 +DROP VIEW json_arrayagg_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW json_arrayagg_view" +== 182 +-- truncate_limit: 100 +-- Test JSON_ARRAY(subquery) deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL), (4)) foo(i) RETURNING jsonb) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL), (4)) foo(i..." +== 183 +-- truncate_limit: 100 +CREATE VIEW json_array_subquery_view AS +SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL), (4)) foo(i) RETURNING jsonb) +-- +TABLE: name="json_array_subquery_view" schema="" table="json_array_subquery_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_array_subquery_view AS SELECT JSON_ARRAY(SELECT i FROM (VALUES (1), (2), (NULL),..." +== 184 +-- truncate_limit: 100 +DROP VIEW json_array_subquery_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW json_array_subquery_view" +== 185 +-- truncate_limit: 100 +-- IS JSON predicate +SELECT NULL IS JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL IS JSON" +== 186 +-- truncate_limit: 100 +SELECT NULL IS NOT JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT NOT NULL IS JSON" +== 187 +-- truncate_limit: 100 +SELECT NULL::json IS JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::pg_catalog.json IS JSON" +== 188 +-- truncate_limit: 100 +SELECT NULL::jsonb IS JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::jsonb IS JSON" +== 189 +-- truncate_limit: 100 +SELECT NULL::text IS JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::text IS JSON" +== 190 +-- truncate_limit: 100 +SELECT NULL::bytea IS JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::bytea IS JSON" +== 191 +-- truncate_limit: 100 +SELECT NULL::int IS JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT NULL::int IS JSON" +== 192 +-- truncate_limit: 100 +SELECT '' IS JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT '' IS JSON" +== 193 +-- truncate_limit: 100 +SELECT bytea '\x00' IS JSON +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'\\\\x00'::bytea IS JSON" +== 194 +-- truncate_limit: 100 +CREATE TABLE test_is_json (js text) +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_is_json (js text)" +== 195 +-- truncate_limit: 100 +INSERT INTO test_is_json VALUES + (NULL), + (''), + ('123'), + ('"aaa "'), + ('true'), + ('null'), + ('[]'), + ('[1, "2", {}]'), + ('{}'), + ('{ "a": 1, "b": null }'), + ('{ "a": 1, "a": null }'), + ('{ "a": 1, "b": [{ "a": 1 }, { "a": 2 }] }'), + ('{ "a": 1, "b": [{ "a": 1, "b": 0, "a": 2 }] }'), + ('aaa'), + ('{a:1}'), + ('["a",]') +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_is_json VALUES (...)" +== 196 +-- truncate_limit: 100 +SELECT + js, + js IS JSON "IS JSON", + js IS NOT JSON "IS NOT JSON", + js IS JSON VALUE "IS VALUE", + js IS JSON OBJECT "IS OBJECT", + js IS JSON ARRAY "IS ARRAY", + js IS JSON SCALAR "IS SCALAR", + js IS JSON WITHOUT UNIQUE KEYS "WITHOUT UNIQUE", + js IS JSON WITH UNIQUE KEYS "WITH UNIQUE" +FROM + test_is_json +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_is_json" +== 197 +-- truncate_limit: 100 +SELECT + js, + js IS JSON "IS JSON", + js IS NOT JSON "IS NOT JSON", + js IS JSON VALUE "IS VALUE", + js IS JSON OBJECT "IS OBJECT", + js IS JSON ARRAY "IS ARRAY", + js IS JSON SCALAR "IS SCALAR", + js IS JSON WITHOUT UNIQUE KEYS "WITHOUT UNIQUE", + js IS JSON WITH UNIQUE KEYS "WITH UNIQUE" +FROM + (SELECT js::json FROM test_is_json WHERE js IS JSON) foo(js) +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=Select +FILTER: schema="" table="" column="js" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM test_is_json WHERE ...) foo(js)" +== 198 +-- truncate_limit: 100 +SELECT + js0, + js IS JSON "IS JSON", + js IS NOT JSON "IS NOT JSON", + js IS JSON VALUE "IS VALUE", + js IS JSON OBJECT "IS OBJECT", + js IS JSON ARRAY "IS ARRAY", + js IS JSON SCALAR "IS SCALAR", + js IS JSON WITHOUT UNIQUE KEYS "WITHOUT UNIQUE", + js IS JSON WITH UNIQUE KEYS "WITH UNIQUE" +FROM + (SELECT js, js::bytea FROM test_is_json WHERE js IS JSON) foo(js0, js) +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=Select +FILTER: schema="" table="" column="js" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM test_is_json WHERE ...) foo(js0, js)" +== 199 +-- truncate_limit: 100 +SELECT + js, + js IS JSON "IS JSON", + js IS NOT JSON "IS NOT JSON", + js IS JSON VALUE "IS VALUE", + js IS JSON OBJECT "IS OBJECT", + js IS JSON ARRAY "IS ARRAY", + js IS JSON SCALAR "IS SCALAR", + js IS JSON WITHOUT UNIQUE KEYS "WITHOUT UNIQUE", + js IS JSON WITH UNIQUE KEYS "WITH UNIQUE" +FROM + (SELECT js::jsonb FROM test_is_json WHERE js IS JSON) foo(js) +-- +TABLE: name="test_is_json" schema="" table="test_is_json" ctx=Select +FILTER: schema="" table="" column="js" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM test_is_json WHERE ...) foo(js)" +== 200 +-- truncate_limit: 100 +-- Test IS JSON deparsing +EXPLAIN (VERBOSE, COSTS OFF) +SELECT '1' IS JSON AS "any", ('1' || i) IS JSON SCALAR AS "scalar", '[]' IS NOT JSON ARRAY AS "array", '{}' IS JSON OBJECT WITH UNIQUE AS "object" FROM generate_series(1, 3) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT '1' IS JSON AS \"any\", '1' || i IS JSON SCALAR AS scalar, NOT ..." +== 201 +-- truncate_limit: 100 +CREATE VIEW is_json_view AS +SELECT '1' IS JSON AS "any", ('1' || i) IS JSON SCALAR AS "scalar", '[]' IS NOT JSON ARRAY AS "array", '{}' IS JSON OBJECT WITH UNIQUE AS "object" FROM generate_series(1, 3) i +-- +TABLE: name="is_json_view" schema="" table="is_json_view" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW is_json_view AS SELECT '1' IS JSON AS \"any\", '1' || i IS JSON SCALAR AS scalar, NOT '..." +== 202 +-- truncate_limit: 100 +DROP VIEW is_json_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW is_json_view" +== 203 +-- truncate_limit: 100 +-- Test implicit coercion to a fixed-length type specified in RETURNING +SELECT JSON_SERIALIZE('{ "a" : 1 } ' RETURNING varchar(2)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('{ \"a\" : 1 } ' RETURNING varchar(2) )" +== 204 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING varchar(2))) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': JSON_OBJECT('b': 1 RETURNING varchar(2)))" +== 205 +-- truncate_limit: 100 +SELECT JSON_ARRAY(JSON_ARRAY('{ "a" : 123 }' RETURNING varchar(2))) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_ARRAY(JSON_ARRAY('{ \"a\" : 123 }' RETURNING varchar(2)))" +== 206 +-- truncate_limit: 100 +SELECT JSON_ARRAYAGG(('111' || i)::bytea FORMAT JSON NULL ON NULL RETURNING varchar(2)) FROM generate_series(1,1) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 1) i" +== 207 +-- truncate_limit: 100 +SELECT JSON_OBJECTAGG(i: ('111' || i)::bytea FORMAT JSON WITH UNIQUE RETURNING varchar(2)) FROM generate_series(1, 1) i +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 1) i" +== 208 +-- truncate_limit: 100 +-- Now try domain over fixed-length type +CREATE DOMAIN sqljson_char2 AS char(2) CHECK (VALUE NOT IN ('12')) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN sqljson_char2 AS char(2) CHECK (value NOT IN ('12'))" +== 209 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE('123' RETURNING sqljson_char2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('123' RETURNING sqljson_char2 )" +== 210 +-- truncate_limit: 100 +SELECT JSON_SERIALIZE('12' RETURNING sqljson_char2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_SERIALIZE('12' RETURNING sqljson_char2 )" +== 211 +-- truncate_limit: 100 +-- Bug #18657: JsonValueExpr.raw_expr was not initialized in ExecInitExprRec() +-- causing the Aggrefs contained in it to also not be initialized, which led +-- to a crash in ExecBuildAggTrans() as mentioned in the bug report: +-- https://postgr.es/m/18657-1b90ccce2b16bdb8@postgresql.org +CREATE FUNCTION volatile_one() RETURNS int AS $$ BEGIN RETURN 1; END; $$ LANGUAGE plpgsql VOLATILE +-- +FUNCTION: name="volatile_one" function="volatile_one" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION volatile_one() RETURNS int AS $$ BEGIN RETURN 1; END; $$ LANGUAGE plpgsql VOLATILE" +== 212 +-- truncate_limit: 100 +CREATE FUNCTION stable_one() RETURNS int AS $$ BEGIN RETURN 1; END; $$ LANGUAGE plpgsql STABLE +-- +FUNCTION: name="stable_one" function="stable_one" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION stable_one() RETURNS int AS $$ BEGIN RETURN 1; END; $$ LANGUAGE plpgsql STABLE" +== 213 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': volatile_one() RETURNING text) FORMAT JSON) +-- +FUNCTION: name="volatile_one" function="volatile_one" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': volatile_one() RETURNING..." +== 214 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': volatile_one() RETURNING text) FORMAT JSON) +-- +FUNCTION: name="volatile_one" function="volatile_one" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': volatile_one() RETURNING text) FORMAT JSON)" +== 215 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': stable_one() RETURNING text) FORMAT JSON) +-- +FUNCTION: name="stable_one" function="stable_one" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': stable_one() RETURNING t..." +== 216 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': stable_one() RETURNING text) FORMAT JSON) +-- +FUNCTION: name="stable_one" function="stable_one" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': stable_one() RETURNING text) FORMAT JSON)" +== 217 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': 1 RETURNING text) FORMAT JSON) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': 1 RETURNING text) FORMAT..." +== 218 +-- truncate_limit: 100 +SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': 1 RETURNING text) FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_OBJECT('a': JSON_OBJECTAGG('b': 1 RETURNING text) FORMAT JSON)" +== 219 +-- truncate_limit: 100 +DROP FUNCTION volatile_one, stable_one +-- +FUNCTION: name="volatile_one" function="volatile_one" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION volatile_one, stable_one" diff --git a/parser/testdata/summary_truncate/postgres_regress/sqljson_jsontable.metadata.json b/parser/testdata/summary_truncate/postgres_regress/sqljson_jsontable.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sqljson_jsontable.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/sqljson_jsontable.test b/parser/testdata/summary_truncate/postgres_regress/sqljson_jsontable.test new file mode 100644 index 0000000..003d2d2 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sqljson_jsontable.test @@ -0,0 +1,1143 @@ +== 001 +-- truncate_limit: 100 +-- JSON_TABLE + +-- Should fail (JSON_TABLE can be used only in FROM clause) +SELECT JSON_TABLE('[]', '$') +-- +ERROR: syntax error at or near "(" +CURSORPOS: 93 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +-- Only allow EMPTY and ERROR for ON ERROR +SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[]' , 'strict $.a' COLUMNS (js2 int PATH '$')DEFAULT 1 ON ERROR)" +== 003 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') NULL ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[]' , 'strict $.a' COLUMNS (js2 int PATH '$')NULL ON ERROR)" +== 004 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') EMPTY ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[]' , 'strict $.a' COLUMNS (js2 int PATH '$')EMPTY ARRAY ON ERROR)" +== 005 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE('[]', 'strict $.a' COLUMNS (js2 int PATH '$') ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[]' , 'strict $.a' COLUMNS (js2 int PATH '$')ERROR ON ERROR)" +== 006 +-- truncate_limit: 100 +-- Column and path names must be distinct +SELECT * FROM JSON_TABLE(jsonb'"1.23"', '$.a' as js2 COLUMNS (js2 int path '$')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"1.23\"'::jsonb , '$.a' AS js2 COLUMNS (js2 int PATH '$'))" +== 007 +-- truncate_limit: 100 +-- Should fail (no columns) +SELECT * FROM JSON_TABLE(NULL, '$' COLUMNS ()) +-- +ERROR: syntax error at or near ")" +CURSORPOS: 73 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE (NULL::jsonb, '$' COLUMNS (v1 timestamp)) AS f (v1, v2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE(NULL::jsonb , '$' COLUMNS (v1 timestamp )) f(v1, v2)" +== 009 +-- truncate_limit: 100 +--duplicated column name +SELECT * FROM JSON_TABLE(jsonb'"1.23"', '$.a' COLUMNS (js2 int path '$', js2 int path '$')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"1.23\"'::jsonb , '$.a' COLUMNS (js2 int PATH '$', js2 int PATH '$'))" +== 010 +-- truncate_limit: 100 +--return composite data type. +create type comp as (a int, b int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE comp AS (a int, b int)" +== 011 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '{"rec": "(1,2)"}', '$' COLUMNS (id FOR ORDINALITY, comp comp path '$.rec' omit quotes)) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('{\"rec\": \"(1,2)\"}'::jsonb , '$' COLUMNS (id FOR ORDINALITY, comp comp P..." +== 012 +-- truncate_limit: 100 +drop type comp +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE comp" +== 013 +-- truncate_limit: 100 +-- NULL => empty table +SELECT * FROM JSON_TABLE(NULL::jsonb, '$' COLUMNS (foo int)) bar +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE(NULL::jsonb , '$' COLUMNS (foo int )) bar" +== 014 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb'"1.23"', 'strict $.a' COLUMNS (js2 int PATH '$')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"1.23\"'::jsonb , 'strict $.a' COLUMNS (js2 int PATH '$'))" +== 015 +-- truncate_limit: 100 +|-- +SELECT * FROM JSON_TABLE(jsonb '123', '$' + COLUMNS (item int PATH '$', foo int)) bar +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('123'::jsonb , '$' COLUMNS (item int PATH '$', foo int )) bar" +== 016 +-- truncate_limit: 100 +-- JSON_TABLE: basic functionality +CREATE DOMAIN jsonb_test_domain AS text CHECK (value <> 'foo') +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN jsonb_test_domain AS text CHECK (value <> 'foo')" +== 017 +-- truncate_limit: 100 +CREATE TEMP TABLE json_table_test (js) AS + (VALUES + ('1'), + ('[]'), + ('{}'), + ('[1, 1.23, "2", "aaaaaaa", "foo", null, false, true, {"aaa": 123}, "[1,2]", "\"str\""]') + ) +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE json_table_test(js) AS VALUES ('1'), ('[]'), ('{}'), (E'[1, 1.23, \"2\", \"aa..." +== 018 +-- truncate_limit: 100 +-- Regular "unformatted" columns +SELECT * +FROM json_table_test vals + LEFT OUTER JOIN + JSON_TABLE( + vals.js::jsonb, 'lax $[*]' + COLUMNS ( + id FOR ORDINALITY, + "int" int PATH '$', + "text" text PATH '$', + "char(4)" char(4) PATH '$', + "bool" bool PATH '$', + "numeric" numeric PATH '$', + "domain" jsonb_test_domain PATH '$', + js json PATH '$', + jb jsonb PATH '$' + ) + ) jt + ON true +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=Select +ALIAS: "vals"="json_table_test" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_table_test vals LEFT JOIN JSON_TABLE(vals.js::jsonb , 'lax $[*]' COLUMNS (id ..." +== 019 +-- truncate_limit: 100 +-- "formatted" columns +SELECT * +FROM json_table_test vals + LEFT OUTER JOIN + JSON_TABLE( + vals.js::jsonb, 'lax $[*]' + COLUMNS ( + id FOR ORDINALITY, + jst text FORMAT JSON PATH '$', + jsc char(4) FORMAT JSON PATH '$', + jsv varchar(4) FORMAT JSON PATH '$', + jsb jsonb FORMAT JSON PATH '$', + jsbq jsonb FORMAT JSON PATH '$' OMIT QUOTES + ) + ) jt + ON true +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=Select +ALIAS: "vals"="json_table_test" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_table_test vals LEFT JOIN JSON_TABLE(vals.js::jsonb , 'lax $[*]' COLUMNS (id ..." +== 020 +-- truncate_limit: 100 +-- EXISTS columns +SELECT * +FROM json_table_test vals + LEFT OUTER JOIN + JSON_TABLE( + vals.js::jsonb, 'lax $[*]' + COLUMNS ( + id FOR ORDINALITY, + exists1 bool EXISTS PATH '$.aaa', + exists2 int EXISTS PATH '$.aaa', + exists3 int EXISTS PATH 'strict $.aaa' UNKNOWN ON ERROR, + exists4 text EXISTS PATH 'strict $.aaa' FALSE ON ERROR + ) + ) jt + ON true +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=Select +ALIAS: "vals"="json_table_test" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_table_test vals LEFT JOIN JSON_TABLE(vals.js::jsonb , 'lax $[*]' COLUMNS (id ..." +== 021 +-- truncate_limit: 100 +-- Other miscellaneous checks +SELECT * +FROM json_table_test vals + LEFT OUTER JOIN + JSON_TABLE( + vals.js::jsonb, 'lax $[*]' + COLUMNS ( + id FOR ORDINALITY, + aaa int, -- "aaa" has implicit path '$."aaa"' + aaa1 int PATH '$.aaa', + js2 json PATH '$', + jsb2w jsonb PATH '$' WITH WRAPPER, + jsb2q jsonb PATH '$' OMIT QUOTES, + ia int[] PATH '$', + ta text[] PATH '$', + jba jsonb[] PATH '$' + ) + ) jt + ON true +-- +TABLE: name="json_table_test" schema="" table="json_table_test" ctx=Select +ALIAS: "vals"="json_table_test" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_table_test vals LEFT JOIN JSON_TABLE(vals.js::jsonb , 'lax $[*]' COLUMNS (id ..." +== 022 +-- truncate_limit: 100 +-- Test using casts in DEFAULT .. ON ERROR expression +SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' + COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT '"foo1"'::jsonb::text ON EMPTY)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('{\"d1\": \"H\"}'::jsonb , '$' COLUMNS (js1 jsonb_test_domain PATH '$.a2' DE..." +== 023 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' + COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo'::jsonb_test_domain ON EMPTY)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('{\"d1\": \"H\"}'::jsonb , '$' COLUMNS (js1 jsonb_test_domain PATH '$.a2' DE..." +== 024 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '{"d1": "H"}', '$' + COLUMNS (js1 jsonb_test_domain PATH '$.a2' DEFAULT 'foo1'::jsonb_test_domain ON EMPTY)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('{\"d1\": \"H\"}'::jsonb , '$' COLUMNS (js1 jsonb_test_domain PATH '$.a2' DE..." +== 025 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '{"d1": "foo"}', '$' + COLUMNS (js1 jsonb_test_domain PATH '$.d1' DEFAULT 'foo2'::jsonb_test_domain ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('{\"d1\": \"foo\"}'::jsonb , '$' COLUMNS (js1 jsonb_test_domain PATH '$.d1' ..." +== 026 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '{"d1": "foo"}', '$' + COLUMNS (js1 oid[] PATH '$.d2' DEFAULT '{1}'::int[]::oid[] ON EMPTY)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('{\"d1\": \"foo\"}'::jsonb , '$' COLUMNS (js1 oid[] PATH '$.d2' DEFAULT '{1}..." +== 027 +-- truncate_limit: 100 +-- JSON_TABLE: Test backward parsing + +CREATE VIEW jsonb_table_view2 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + "int" int PATH '$', + "text" text PATH '$', + "char(4)" char(4) PATH '$', + "bool" bool PATH '$', + "numeric" numeric PATH '$', + "domain" jsonb_test_domain PATH '$')) +-- +TABLE: name="jsonb_table_view2" schema="" table="jsonb_table_view2" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW jsonb_table_view2 AS SELECT * FROM JSON_TABLE('null'::jsonb , 'lax $[*]' PASSING 1 + ..." +== 028 +-- truncate_limit: 100 +CREATE VIEW jsonb_table_view3 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + js json PATH '$', + jb jsonb PATH '$', + jst text FORMAT JSON PATH '$', + jsc char(4) FORMAT JSON PATH '$', + jsv varchar(4) FORMAT JSON PATH '$')) +-- +TABLE: name="jsonb_table_view3" schema="" table="jsonb_table_view3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW jsonb_table_view3 AS SELECT * FROM JSON_TABLE('null'::jsonb , 'lax $[*]' PASSING 1 + ..." +== 029 +-- truncate_limit: 100 +CREATE VIEW jsonb_table_view4 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + jsb jsonb FORMAT JSON PATH '$', + jsbq jsonb FORMAT JSON PATH '$' OMIT QUOTES, + aaa int, -- implicit path '$."aaa"', + aaa1 int PATH '$.aaa')) +-- +TABLE: name="jsonb_table_view4" schema="" table="jsonb_table_view4" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW jsonb_table_view4 AS SELECT * FROM JSON_TABLE('null'::jsonb , 'lax $[*]' PASSING 1 + ..." +== 030 +-- truncate_limit: 100 +CREATE VIEW jsonb_table_view5 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + exists1 bool EXISTS PATH '$.aaa', + exists2 int EXISTS PATH '$.aaa' TRUE ON ERROR, + exists3 text EXISTS PATH 'strict $.aaa' UNKNOWN ON ERROR)) +-- +TABLE: name="jsonb_table_view5" schema="" table="jsonb_table_view5" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW jsonb_table_view5 AS SELECT * FROM JSON_TABLE('null'::jsonb , 'lax $[*]' PASSING 1 + ..." +== 031 +-- truncate_limit: 100 +CREATE VIEW jsonb_table_view6 AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + js2 json PATH '$', + jsb2w jsonb PATH '$' WITH WRAPPER, + jsb2q jsonb PATH '$' OMIT QUOTES, + ia int[] PATH '$', + ta text[] PATH '$', + jba jsonb[] PATH '$')) +-- +TABLE: name="jsonb_table_view6" schema="" table="jsonb_table_view6" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW jsonb_table_view6 AS SELECT * FROM JSON_TABLE('null'::jsonb , 'lax $[*]' PASSING 1 + ..." +== 032 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view2 +-- +TABLE: name="jsonb_table_view2" schema="" table="jsonb_table_view2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view2" +== 033 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view3 +-- +TABLE: name="jsonb_table_view3" schema="" table="jsonb_table_view3" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view3" +== 034 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view4 +-- +TABLE: name="jsonb_table_view4" schema="" table="jsonb_table_view4" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view4" +== 035 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view5 +-- +TABLE: name="jsonb_table_view5" schema="" table="jsonb_table_view5" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view5" +== 036 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view6 +-- +TABLE: name="jsonb_table_view6" schema="" table="jsonb_table_view6" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM jsonb_table_view6" +== 037 +-- truncate_limit: 100 +-- JSON_TABLE() with alias +EXPLAIN (COSTS OFF, VERBOSE) +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + id FOR ORDINALITY, + "int" int PATH '$', + "text" text PATH '$' + )) json_table_func +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM JSON_TABLE('null'::jsonb , 'lax $[*]' PASSING 1 + 2 A..." +== 038 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF, FORMAT JSON, VERBOSE) +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + id FOR ORDINALITY, + "int" int PATH '$', + "text" text PATH '$' + )) json_table_func +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, FORMAT \"json\", VERBOSE) SELECT * FROM JSON_TABLE('null'::jsonb , 'lax $[*]' P..." +== 039 +-- truncate_limit: 100 +DROP VIEW jsonb_table_view2 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW jsonb_table_view2" +== 040 +-- truncate_limit: 100 +DROP VIEW jsonb_table_view3 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW jsonb_table_view3" +== 041 +-- truncate_limit: 100 +DROP VIEW jsonb_table_view4 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW jsonb_table_view4" +== 042 +-- truncate_limit: 100 +DROP VIEW jsonb_table_view5 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW jsonb_table_view5" +== 043 +-- truncate_limit: 100 +DROP VIEW jsonb_table_view6 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW jsonb_table_view6" +== 044 +-- truncate_limit: 100 +DROP DOMAIN jsonb_test_domain +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN jsonb_test_domain" +== 045 +-- truncate_limit: 100 +-- JSON_TABLE: only one FOR ORDINALITY columns allowed +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (id FOR ORDINALITY, id2 FOR ORDINALITY, a int PATH '$.a' ERROR ON EMPTY)) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (id FOR ORDINALITY, id2 FOR ORDINALITY, a int..." +== 046 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (id FOR ORDINALITY, a int PATH '$' ERROR ON EMPTY)) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (id FOR ORDINALITY, a int PATH '$' ERROR ON EM..." +== 047 +-- truncate_limit: 100 +-- JSON_TABLE: ON EMPTY/ON ERROR behavior +SELECT * +FROM + (VALUES ('1'), ('"err"')) vals(js), + JSON_TABLE(vals.js::jsonb, '$' COLUMNS (a int PATH '$')) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) vals(js), JSON_TABLE(vals.js::jsonb , '$' COLUMNS (a int PATH '$')) jt" +== 048 +-- truncate_limit: 100 +SELECT * +FROM + (VALUES ('1'), ('"err"')) vals(js) + LEFT OUTER JOIN + JSON_TABLE(vals.js::jsonb, '$' COLUMNS (a int PATH '$' ERROR ON ERROR)) jt + ON true +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) vals(js) LEFT JOIN JSON_TABLE(vals.js::jsonb , '$' COLUMNS (a int PA..." +== 049 +-- truncate_limit: 100 +-- TABLE-level ERROR ON ERROR is not propagated to columns +SELECT * +FROM + (VALUES ('1'), ('"err"')) vals(js) + LEFT OUTER JOIN + JSON_TABLE(vals.js::jsonb, '$' COLUMNS (a int PATH '$' ERROR ON ERROR)) jt + ON true +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) vals(js) LEFT JOIN JSON_TABLE(vals.js::jsonb , '$' COLUMNS (a int PA..." +== 050 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int PATH '$.a' ERROR ON EMPTY)) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (a int PATH '$.a' ERROR ON EMPTY)) jt" +== 051 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int PATH 'strict $.a' ERROR ON ERROR) ERROR ON ERROR) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (a int PATH 'strict $.a' ERROR ON ERROR)ERROR O..." +== 052 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int PATH 'lax $.a' ERROR ON EMPTY) ERROR ON ERROR) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (a int PATH 'lax $.a' ERROR ON EMPTY)ERROR ON E..." +== 053 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int PATH '$' DEFAULT 1 ON EMPTY DEFAULT 2 ON ERROR)) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a int PATH '$' DEFAULT 1 ON EMPTY DEFAULT 2 ..." +== 054 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int PATH 'strict $.a' DEFAULT 1 ON EMPTY DEFAULT 2 ON ERROR)) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a int PATH 'strict $.a' DEFAULT 1 ON EMPTY D..." +== 055 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int PATH 'lax $.a' DEFAULT 1 ON EMPTY DEFAULT 2 ON ERROR)) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a int PATH 'lax $.a' DEFAULT 1 ON EMPTY DEFA..." +== 056 +-- truncate_limit: 100 +-- JSON_TABLE: EXISTS PATH types +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int4 EXISTS PATH '$.a' ERROR ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a int4 EXISTS PATH '$.a' ERROR ON ERROR))" +== 057 +-- truncate_limit: 100 +-- ok; can cast to int4 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int4 EXISTS PATH '$' ERROR ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a int4 EXISTS PATH '$' ERROR ON ERROR))" +== 058 +-- truncate_limit: 100 +-- ok; can cast to int4 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int2 EXISTS PATH '$.a')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a int2 EXISTS PATH '$.a'))" +== 059 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a int8 EXISTS PATH '$.a')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a int8 EXISTS PATH '$.a'))" +== 060 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a float4 EXISTS PATH '$.a')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a float4 EXISTS PATH '$.a'))" +== 061 +-- truncate_limit: 100 +-- Default FALSE (ON ERROR) doesn't fit char(3) +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a char(3) EXISTS PATH '$.a')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a char(3) EXISTS PATH '$.a'))" +== 062 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a char(3) EXISTS PATH '$.a' ERROR ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a char(3) EXISTS PATH '$.a' ERROR ON ERROR))" +== 063 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a char(5) EXISTS PATH '$.a' ERROR ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a char(5) EXISTS PATH '$.a' ERROR ON ERROR))" +== 064 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a json EXISTS PATH '$.a')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a pg_catalog.json EXISTS PATH '$.a'))" +== 065 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a jsonb EXISTS PATH '$.a')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a jsonb EXISTS PATH '$.a'))" +== 066 +-- truncate_limit: 100 +-- EXISTS PATH domain over int +CREATE DOMAIN dint4 AS int +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN dint4 AS int" +== 067 +-- truncate_limit: 100 +CREATE DOMAIN dint4_0 AS int CHECK (VALUE <> 0 ) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN dint4_0 AS int CHECK (value <> 0)" +== 068 +-- truncate_limit: 100 +SELECT a, a::bool FROM JSON_TABLE(jsonb '"a"', '$' COLUMNS (a dint4 EXISTS PATH '$.a' )) +-- +STMT: SelectStmt +TRUNCATED: "SELECT a, a::bool FROM JSON_TABLE('\"a\"'::jsonb , '$' COLUMNS (a dint4 EXISTS PATH '$.a'))" +== 069 +-- truncate_limit: 100 +SELECT a, a::bool FROM JSON_TABLE(jsonb '{"a":1}', '$' COLUMNS (a dint4_0 EXISTS PATH '$.b')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT a, a::bool FROM JSON_TABLE('{\"a\":1}'::jsonb , '$' COLUMNS (a dint4_0 EXISTS PATH '$.b'))" +== 070 +-- truncate_limit: 100 +SELECT a, a::bool FROM JSON_TABLE(jsonb '{"a":1}', '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' ERROR ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM JSON_TABLE('{\"a\":1}'::jsonb , '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' ERROR ON E..." +== 071 +-- truncate_limit: 100 +SELECT a, a::bool FROM JSON_TABLE(jsonb '{"a":1}', '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' FALSE ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM JSON_TABLE('{\"a\":1}'::jsonb , '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' FALSE ON E..." +== 072 +-- truncate_limit: 100 +SELECT a, a::bool FROM JSON_TABLE(jsonb '{"a":1}', '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' TRUE ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM JSON_TABLE('{\"a\":1}'::jsonb , '$' COLUMNS (a dint4_0 EXISTS PATH '$.b' TRUE ON ER..." +== 073 +-- truncate_limit: 100 +DROP DOMAIN dint4, dint4_0 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN dint4, dint4_0" +== 074 +-- truncate_limit: 100 +-- JSON_TABLE: WRAPPER/QUOTES clauses on scalar columns +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text PATH '$' KEEP QUOTES ON SCALAR STRING)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text PATH '$' KEEP QUOTES))" +== 075 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text PATH '$' OMIT QUOTES ON SCALAR STRING)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text PATH '$' OMIT QUOTES))" +== 076 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' KEEP QUOTES)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text FORMAT JSON PATH '$' KEEP QUOT..." +== 077 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' OMIT QUOTES)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text FORMAT JSON PATH '$' OMIT QUOT..." +== 078 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' WITHOUT WRAPPER KEEP QUOTES)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text FORMAT JSON PATH '$' WITHOUT W..." +== 079 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text PATH '$' WITHOUT WRAPPER OMIT QUOTES)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text PATH '$' WITHOUT WRAPPER OMIT ..." +== 080 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' WITH WRAPPER)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text FORMAT JSON PATH '$' WITH UNCO..." +== 081 +-- truncate_limit: 100 +-- Error: OMIT QUOTES should not be specified when WITH WRAPPER is present +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text PATH '$' WITH WRAPPER OMIT QUOTES)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text PATH '$' WITH UNCONDITIONAL WR..." +== 082 +-- truncate_limit: 100 +-- But KEEP QUOTES (the default) is fine +SELECT * FROM JSON_TABLE(jsonb '"world"', '$' COLUMNS (item text FORMAT JSON PATH '$' WITH WRAPPER KEEP QUOTES)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('\"world\"'::jsonb , '$' COLUMNS (item text FORMAT JSON PATH '$' WITH UNCO..." +== 083 +-- truncate_limit: 100 +-- Test PASSING args +SELECT * +FROM JSON_TABLE( + jsonb '[1,2,3]', + '$[*] ? (@ < $x)' + PASSING 3 AS x + COLUMNS (y text FORMAT JSON PATH '$') + ) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[1,2,3]'::jsonb , '$[*] ? (@ < $x)' PASSING 3 AS x COLUMNS (y text FOR..." +== 084 +-- truncate_limit: 100 +-- PASSING arguments are also passed to column paths +SELECT * +FROM JSON_TABLE( + jsonb '[1,2,3]', + '$[*] ? (@ < $x)' + PASSING 10 AS x, 3 AS y + COLUMNS (a text FORMAT JSON PATH '$ ? (@ < $y)') + ) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[1,2,3]'::jsonb , '$[*] ? (@ < $x)' PASSING 10 AS x, 3 AS y COLUMNS (..." +== 085 +-- truncate_limit: 100 +-- Should fail (not supported) +SELECT * FROM JSON_TABLE(jsonb '{"a": 123}', '$' || '.' || 'a' COLUMNS (foo int)) +-- +ERROR: only string constants are supported in JSON_TABLE path specification +CURSORPOS: 77 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 086 +-- truncate_limit: 100 +-- JsonPathQuery() error message mentioning column name +SELECT * FROM JSON_TABLE('{"a": [{"b": "1"}, {"b": "2"}]}', '$' COLUMNS (b json path '$.a[*].b' ERROR ON ERROR)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('{\"a\": [{\"b\": \"1\"}, {\"b\": \"2\"}]}' , '$' COLUMNS (b pg_catalog.json PATH ..." +== 087 +-- truncate_limit: 100 +-- JSON_TABLE: nested paths + +-- Duplicate path names +SELECT * FROM JSON_TABLE( + jsonb '[]', '$' AS a + COLUMNS ( + b int, + NESTED PATH '$' AS a + COLUMNS ( + c int + ) + ) +) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[]'::jsonb , '$' AS a COLUMNS (b int , NESTED PATH '$' AS a COLUMNS (c ..." +== 088 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE( + jsonb '[]', '$' AS a + COLUMNS ( + b int, + NESTED PATH '$' AS n_a + COLUMNS ( + c int + ) + ) +) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[]'::jsonb , '$' AS a COLUMNS (b int , NESTED PATH '$' AS n_a COLUMNS (..." +== 089 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE( + jsonb '[]', '$' + COLUMNS ( + b int, + NESTED PATH '$' AS b + COLUMNS ( + c int + ) + ) +) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[]'::jsonb , '$' COLUMNS (b int , NESTED PATH '$' AS b COLUMNS (c int )..." +== 090 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE( + jsonb '[]', '$' + COLUMNS ( + NESTED PATH '$' AS a + COLUMNS ( + b int + ), + NESTED PATH '$' + COLUMNS ( + NESTED PATH '$' AS a + COLUMNS ( + c int + ) + ) + ) +) jt +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('[]'::jsonb , '$' COLUMNS (NESTED PATH '$' AS a COLUMNS (b int ), NESTED..." +== 091 +-- truncate_limit: 100 +-- JSON_TABLE: plan execution + +CREATE TEMP TABLE jsonb_table_test (js jsonb) +-- +TABLE: name="jsonb_table_test" schema="" table="jsonb_table_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE jsonb_table_test (js jsonb)" +== 092 +-- truncate_limit: 100 +INSERT INTO jsonb_table_test +VALUES ( + '[ + {"a": 1, "b": [], "c": []}, + {"a": 2, "b": [1, 2, 3], "c": [10, null, 20]}, + {"a": 3, "b": [1, 2], "c": []}, + {"x": "4", "b": [1, 2], "c": 123} + ]' +) +-- +TABLE: name="jsonb_table_test" schema="" table="jsonb_table_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO jsonb_table_test VALUES (...)" +== 093 +-- truncate_limit: 100 +select + jt.* +from + jsonb_table_test jtt, + json_table ( + jtt.js,'strict $[*]' as p + columns ( + n for ordinality, + a int path 'lax $.a' default -1 on empty, + nested path 'strict $.b[*]' as pb columns (b_id for ordinality, b int path '$' ), + nested path 'strict $.c[*]' as pc columns (c_id for ordinality, c int path '$' ) + ) + ) jt +-- +TABLE: name="jsonb_table_test" schema="" table="jsonb_table_test" ctx=Select +ALIAS: "jtt"="jsonb_table_test" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM jsonb_table_test jtt, JSON_TABLE(jtt.js , 'strict $[*]' AS p COLUMNS (n FOR ORDI..." +== 094 +-- truncate_limit: 100 +-- PASSING arguments are passed to nested paths and their columns' paths +SELECT * +FROM + generate_series(1, 3) x, + generate_series(1, 3) y, + JSON_TABLE(jsonb + '[[1,2,3],[2,3,4,5],[3,4,5,6]]', + 'strict $[*] ? (@[*] <= $x)' + PASSING x AS x, y AS y + COLUMNS ( + y text FORMAT JSON PATH '$', + NESTED PATH 'strict $[*] ? (@ == $y)' + COLUMNS ( + z int PATH '$' + ) + ) + ) jt +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(1, 3) x, generate_series(1, 3) y, JSON_TABLE('[[1,2,3],[2,3,4,5],[3..." +== 095 +-- truncate_limit: 100 +-- JSON_TABLE: Test backward parsing with nested paths + +CREATE VIEW jsonb_table_view_nested AS +SELECT * FROM + JSON_TABLE( + jsonb 'null', 'lax $[*]' PASSING 1 + 2 AS a, json '"foo"' AS "b c" + COLUMNS ( + id FOR ORDINALITY, + NESTED PATH '$[1]' AS p1 COLUMNS ( + a1 int, + NESTED PATH '$[*]' AS "p1 1" COLUMNS ( + a11 text + ), + b1 text + ), + NESTED PATH '$[2]' AS p2 COLUMNS ( + NESTED PATH '$[*]' AS "p2:1" COLUMNS ( + a21 text + ), + NESTED PATH '$[*]' AS p22 COLUMNS ( + a22 text + ) + ) + ) + ) +-- +TABLE: name="jsonb_table_view_nested" schema="" table="jsonb_table_view_nested" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW jsonb_table_view_nested AS SELECT * FROM JSON_TABLE('null'::jsonb , 'lax $[*]' PASSIN..." +== 096 +-- truncate_limit: 100 +DROP VIEW jsonb_table_view_nested +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW jsonb_table_view_nested" +== 097 +-- truncate_limit: 100 +CREATE TABLE s (js jsonb) +-- +TABLE: name="s" schema="" table="s" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE s (js jsonb)" +== 098 +-- truncate_limit: 100 +INSERT INTO s VALUES + ('{"a":{"za":[{"z1": [11,2222]},{"z21": [22, 234,2345]},{"z22": [32, 204,145]}]},"c": 3}'), + ('{"a":{"za":[{"z1": [21,4222]},{"z21": [32, 134,1345]}]},"c": 10}') +-- +TABLE: name="s" schema="" table="s" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO s VALUES (...)" +== 099 +-- truncate_limit: 100 +-- error +SELECT sub.* FROM s, + JSON_TABLE(js, '$' PASSING 32 AS x, 13 AS y COLUMNS ( + xx int path '$.c', + NESTED PATH '$.a.za[1]' columns (NESTED PATH '$.z21[*]' COLUMNS (z21 int path '$?(@ >= $"x")' ERROR ON ERROR)) + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM s, JSON_TABLE(js , '$' PASSING 32 AS x, 13 AS y COLUMNS (xx int PATH '$.c', NES..." +== 100 +-- truncate_limit: 100 +-- Parent columns xx1, xx appear before NESTED ones +SELECT sub.* FROM s, + (VALUES (23)) x(x), generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y COLUMNS ( + NESTED PATH '$.a.za[2]' COLUMNS ( + NESTED PATH '$.z22[*]' as z22 COLUMNS (c int PATH '$')), + NESTED PATH '$.a.za[1]' columns (d int[] PATH '$.z21'), + NESTED PATH '$.a.za[0]' columns (NESTED PATH '$.z1[*]' as z1 COLUMNS (a int PATH '$')), + xx1 int PATH '$.c', + NESTED PATH '$.a.za[1]' columns (NESTED PATH '$.z21[*]' as z21 COLUMNS (b int PATH '$')), + xx int PATH '$.c' + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM s, (VALUES (23)) x(x), generate_series(13, 13) y, JSON_TABLE(js , '$' AS c1 PASSI..." +== 101 +-- truncate_limit: 100 +-- Test applying PASSING variables at different nesting levels +SELECT sub.* FROM s, + (VALUES (23)) x(x), generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y COLUMNS ( + xx1 int PATH '$.c', + NESTED PATH '$.a.za[0].z1[*]' COLUMNS (NESTED PATH '$ ?(@ >= ($"x" -2))' COLUMNS (a int PATH '$')), + NESTED PATH '$.a.za[0]' COLUMNS (NESTED PATH '$.z1[*] ? (@ >= ($"x" -2))' COLUMNS (b int PATH '$')) + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM s, (VALUES (23)) x(x), generate_series(13, 13) y, JSON_TABLE(js , '$' AS c1 PASSI..." +== 102 +-- truncate_limit: 100 +-- Test applying PASSING variable to paths all the levels +SELECT sub.* FROM s, + (VALUES (23)) x(x), + generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y + COLUMNS ( + xx1 int PATH '$.c', + NESTED PATH '$.a.za[1]' + COLUMNS (NESTED PATH '$.z21[*]' COLUMNS (b int PATH '$')), + NESTED PATH '$.a.za[1] ? (@.z21[*] >= ($"x"-1))' COLUMNS + (NESTED PATH '$.z21[*] ? (@ >= ($"y" + 3))' as z22 COLUMNS (a int PATH '$ ? (@ >= ($"y" + 12))')), + NESTED PATH '$.a.za[1]' COLUMNS + (NESTED PATH '$.z21[*] ? (@ >= ($"y" +121))' as z21 COLUMNS (c int PATH '$ ? (@ > ($"x" +111))')) + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM s, (VALUES (23)) x(x), generate_series(13, 13) y, JSON_TABLE(js , '$' AS c1 PASSI..." +== 103 +-- truncate_limit: 100 +----- test on empty behavior +SELECT sub.* FROM s, + (values(23)) x(x), + generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y + COLUMNS ( + xx1 int PATH '$.c', + NESTED PATH '$.a.za[2]' COLUMNS (NESTED PATH '$.z22[*]' as z22 COLUMNS (c int PATH '$')), + NESTED PATH '$.a.za[1]' COLUMNS (d json PATH '$ ? (@.z21[*] == ($"x" -1))'), + NESTED PATH '$.a.za[0]' COLUMNS (NESTED PATH '$.z1[*] ? (@ >= ($"x" -2))' as z1 COLUMNS (a int PATH '$')), + NESTED PATH '$.a.za[1]' COLUMNS + (NESTED PATH '$.z21[*] ? (@ >= ($"y" +121))' as z21 COLUMNS (b int PATH '$ ? (@ > ($"x" +111))' DEFAULT 0 ON EMPTY)) + )) sub +-- +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM s, (VALUES (23)) x(x), generate_series(13, 13) y, JSON_TABLE(js , '$' AS c1 PASSI..." +== 104 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW jsonb_table_view7 AS +SELECT sub.* FROM s, + (values(23)) x(x), + generate_series(13, 13) y, + JSON_TABLE(js, '$' AS c1 PASSING x AS x, y AS y + COLUMNS ( + xx1 int PATH '$.c', + NESTED PATH '$.a.za[2]' COLUMNS (NESTED PATH '$.z22[*]' as z22 COLUMNS (c int PATH '$' WITHOUT WRAPPER OMIT QUOTES)), + NESTED PATH '$.a.za[1]' COLUMNS (d json PATH '$ ? (@.z21[*] == ($"x" -1))' WITH WRAPPER), + NESTED PATH '$.a.za[0]' COLUMNS (NESTED PATH '$.z1[*] ? (@ >= ($"x" -2))' as z1 COLUMNS (a int PATH '$' KEEP QUOTES)), + NESTED PATH '$.a.za[1]' COLUMNS + (NESTED PATH '$.z21[*] ? (@ >= ($"y" +121))' as z21 COLUMNS (b int PATH '$ ? (@ > ($"x" +111))' DEFAULT 0 ON EMPTY)) + )) sub +-- +TABLE: name="jsonb_table_view7" schema="" table="jsonb_table_view7" ctx=DDL +TABLE: name="s" schema="" table="s" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW jsonb_table_view7 AS SELECT sub.* FROM s, (VALUES (23)) x(x), generate_ser..." +== 105 +-- truncate_limit: 100 +DROP VIEW jsonb_table_view7 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW jsonb_table_view7" +== 106 +-- truncate_limit: 100 +DROP TABLE s +-- +TABLE: name="s" schema="" table="s" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE s" +== 107 +-- truncate_limit: 100 +-- Prevent ON EMPTY specification on EXISTS columns +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on empty)) +-- +ERROR: syntax error at or near "empty" +CURSORPOS: 131 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 108 +-- truncate_limit: 100 +-- Test ON ERROR / EMPTY value validity for the function and column types; +-- all fail +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int) NULL ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (a int )NULL ON ERROR)" +== 109 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int true on empty)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (a int TRUE ON EMPTY))" +== 110 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int omit quotes true on error)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (a int OMIT QUOTES TRUE ON ERROR))" +== 111 +-- truncate_limit: 100 +SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on error)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM JSON_TABLE('1'::jsonb , '$' COLUMNS (a int EXISTS EMPTY OBJECT ON ERROR))" +== 112 +-- truncate_limit: 100 +-- Test JSON_TABLE() column deparsing -- don't emit default ON ERROR / EMPTY +-- behavior +CREATE VIEW json_table_view8 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$')) +-- +TABLE: name="json_table_view8" schema="" table="json_table_view8" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_table_view8 AS SELECT * FROM JSON_TABLE('\"a\"' , '$' COLUMNS (a text PATH '$'))" +== 113 +-- truncate_limit: 100 +CREATE VIEW json_table_view9 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') ERROR ON ERROR) +-- +TABLE: name="json_table_view9" schema="" table="json_table_view9" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_table_view9 AS SELECT * FROM JSON_TABLE('\"a\"' , '$' COLUMNS (a text PATH '$')ERR..." +== 114 +-- truncate_limit: 100 +DROP VIEW json_table_view8, json_table_view9 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW json_table_view8, json_table_view9" +== 115 +-- truncate_limit: 100 +-- Test JSON_TABLE() deparsing -- don't emit default ON ERROR behavior +CREATE VIEW json_table_view8 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') EMPTY ON ERROR) +-- +TABLE: name="json_table_view8" schema="" table="json_table_view8" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_table_view8 AS SELECT * FROM JSON_TABLE('\"a\"' , '$' COLUMNS (a text PATH '$')EMP..." +== 116 +-- truncate_limit: 100 +CREATE VIEW json_table_view9 AS SELECT * from JSON_TABLE('"a"', '$' COLUMNS (a text PATH '$') EMPTY ARRAY ON ERROR) +-- +TABLE: name="json_table_view9" schema="" table="json_table_view9" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW json_table_view9 AS SELECT * FROM JSON_TABLE('\"a\"' , '$' COLUMNS (a text PATH '$')EMP..." +== 117 +-- truncate_limit: 100 +DROP VIEW json_table_view8, json_table_view9 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW json_table_view8, json_table_view9" diff --git a/parser/testdata/summary_truncate/postgres_regress/sqljson_queryfuncs.metadata.json b/parser/testdata/summary_truncate/postgres_regress/sqljson_queryfuncs.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sqljson_queryfuncs.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/sqljson_queryfuncs.test b/parser/testdata/summary_truncate/postgres_regress/sqljson_queryfuncs.test new file mode 100644 index 0000000..17c5e3b --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sqljson_queryfuncs.test @@ -0,0 +1,2075 @@ +== 001 +-- truncate_limit: 100 +-- JSON_EXISTS +SELECT JSON_EXISTS(NULL::jsonb, '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS(NULL::jsonb , '$')" +== 002 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '[]', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('[]'::jsonb , '$')" +== 003 +-- truncate_limit: 100 +SELECT JSON_EXISTS(JSON_OBJECT(RETURNING jsonb), '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS(JSON_OBJECT( RETURNING jsonb) , '$')" +== 004 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '1', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('1'::jsonb , '$')" +== 005 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb 'null', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('null'::jsonb , '$')" +== 006 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '[]', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('[]'::jsonb , '$')" +== 007 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '1', '$.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('1'::jsonb , '$.a')" +== 008 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '1', 'strict $.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('1'::jsonb , 'strict $.a')" +== 009 +-- truncate_limit: 100 +-- FALSE on error +SELECT JSON_EXISTS(jsonb '1', 'strict $.a' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('1'::jsonb , 'strict $.a' ERROR ON ERROR)" +== 010 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb 'null', '$.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('null'::jsonb , '$.a')" +== 011 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '[]', '$.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('[]'::jsonb , '$.a')" +== 012 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '[1, "aaa", {"a": 1}]', 'strict $.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('[1, \"aaa\", {\"a\": 1}]'::jsonb , 'strict $.a')" +== 013 +-- truncate_limit: 100 +-- FALSE on error +SELECT JSON_EXISTS(jsonb '[1, "aaa", {"a": 1}]', 'lax $.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('[1, \"aaa\", {\"a\": 1}]'::jsonb , 'lax $.a')" +== 014 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '{}', '$.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{}'::jsonb , '$.a')" +== 015 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '{"b": 1, "a": 2}', '$.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"b\": 1, \"a\": 2}'::jsonb , '$.a')" +== 016 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '1', '$.a.b') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('1'::jsonb , '$.a.b')" +== 017 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '{"a": {"b": 1}}', '$.a.b') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"a\": {\"b\": 1}}'::jsonb , '$.a.b')" +== 018 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.a.b') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"a\": 1, \"b\": 2}'::jsonb , '$.a.b')" +== 019 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.* ? (@ > $x)' PASSING 1 AS x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"a\": 1, \"b\": 2}'::jsonb , '$.* ? (@ > $x)' PASSING 1 AS x)" +== 020 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.* ? (@ > $x)' PASSING '1' AS x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"a\": 1, \"b\": 2}'::jsonb , '$.* ? (@ > $x)' PASSING '1' AS x)" +== 021 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.* ? (@ > $x && @ < $y)' PASSING 0 AS x, 2 AS y) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"a\": 1, \"b\": 2}'::jsonb , '$.* ? (@ > $x && @ < $y)' PASSING 0 AS x, 2 AS y)" +== 022 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '{"a": 1, "b": 2}', '$.* ? (@ > $x && @ < $y)' PASSING 0 AS x, 1 AS y) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"a\": 1, \"b\": 2}'::jsonb , '$.* ? (@ > $x && @ < $y)' PASSING 0 AS x, 1 AS y)" +== 023 +-- truncate_limit: 100 +-- extension: boolean expressions +SELECT JSON_EXISTS(jsonb '1', '$ > 2') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('1'::jsonb , '$ > 2')" +== 024 +-- truncate_limit: 100 +SELECT JSON_EXISTS(jsonb '1', '$.a > 2' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('1'::jsonb , '$.a > 2' ERROR ON ERROR)" +== 025 +-- truncate_limit: 100 +-- JSON_VALUE +SELECT JSON_VALUE(NULL::jsonb, '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE(NULL::jsonb , '$')" +== 026 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('null'::jsonb , '$')" +== 027 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$' RETURNING int) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('null'::jsonb , '$' RETURNING int )" +== 028 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'true', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('true'::jsonb , '$')" +== 029 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'true', '$' RETURNING bool) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('true'::jsonb , '$' RETURNING bool )" +== 030 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '123', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('123'::jsonb , '$')" +== 031 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING int) + 234 +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('123'::jsonb , '$' RETURNING int ) + 234" +== 032 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('123'::jsonb , '$' RETURNING text )" +== 033 +-- truncate_limit: 100 +/* jsonb bytea ??? */ +SELECT JSON_VALUE(jsonb '123', '$' RETURNING bytea ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('123'::jsonb , '$' RETURNING bytea ERROR ON ERROR)" +== 034 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1.23', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1.23'::jsonb , '$')" +== 035 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1.23', '$' RETURNING int) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1.23'::jsonb , '$' RETURNING int )" +== 036 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"1.23"', '$' RETURNING numeric) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"1.23\"'::jsonb , '$' RETURNING numeric )" +== 037 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"1.23"', '$' RETURNING int ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"1.23\"'::jsonb , '$' RETURNING int ERROR ON ERROR)" +== 038 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$')" +== 039 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING text )" +== 040 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING char(5)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING char(5) )" +== 041 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING char(2) ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING char(2) ERROR ON ERROR)" +== 042 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING char(2)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING char(2) )" +== 043 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING char(3) ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING char(3) ERROR ON ERROR)" +== 044 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING pg_catalog.json )" +== 045 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING jsonb )" +== 046 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING json ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING pg_catalog.json ERROR ON ERROR)" +== 047 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING jsonb ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING jsonb ERROR ON ERROR)" +== 048 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"\"aaa\""', '$' RETURNING json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE(E'\"\\\\\"aaa\\\\\"\"'::jsonb , '$' RETURNING pg_catalog.json )" +== 049 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"\"aaa\""', '$' RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE(E'\"\\\\\"aaa\\\\\"\"'::jsonb , '$' RETURNING jsonb )" +== 050 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING int) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING int )" +== 051 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING int ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING int ERROR ON ERROR)" +== 052 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"aaa"', '$' RETURNING int DEFAULT 111 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"'::jsonb , '$' RETURNING int DEFAULT 111 ON ERROR)" +== 053 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"123"', '$' RETURNING int) + 234 +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"123\"'::jsonb , '$' RETURNING int ) + 234" +== 054 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"2017-02-20"', '$' RETURNING date) + 9 +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"2017-02-20\"'::jsonb , '$' RETURNING date ) + 9" +== 055 +-- truncate_limit: 100 +-- Test NULL checks execution in domain types +CREATE DOMAIN sqljsonb_int_not_null AS int NOT NULL +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN sqljsonb_int_not_null AS int NOT NULL" +== 056 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$' RETURNING sqljsonb_int_not_null) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('null'::jsonb , '$' RETURNING sqljsonb_int_not_null )" +== 057 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$' RETURNING sqljsonb_int_not_null ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('null'::jsonb , '$' RETURNING sqljsonb_int_not_null ERROR ON ERROR)" +== 058 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$' RETURNING sqljsonb_int_not_null DEFAULT 2 ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 059 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', '$.a' RETURNING sqljsonb_int_not_null DEFAULT 2 ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 060 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', '$.a' RETURNING sqljsonb_int_not_null DEFAULT NULL ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 061 +-- truncate_limit: 100 +CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple')" +== 062 +-- truncate_limit: 100 +CREATE DOMAIN rgb AS rainbow CHECK (VALUE IN ('red', 'green', 'blue')) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN rgb AS rainbow CHECK (value IN ('red', 'green', 'blue'))" +== 063 +-- truncate_limit: 100 +SELECT JSON_VALUE('"purple"'::jsonb, 'lax $[*]' RETURNING rgb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"purple\"'::jsonb , 'lax $[*]' RETURNING rgb )" +== 064 +-- truncate_limit: 100 +SELECT JSON_VALUE('"purple"'::jsonb, 'lax $[*]' RETURNING rgb ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"purple\"'::jsonb , 'lax $[*]' RETURNING rgb ERROR ON ERROR)" +== 065 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '[]', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[]'::jsonb , '$')" +== 066 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '[]', '$' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[]'::jsonb , '$' ERROR ON ERROR)" +== 067 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '{}', '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{}'::jsonb , '$')" +== 068 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '{}', '$' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{}'::jsonb , '$' ERROR ON ERROR)" +== 069 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', '$.a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , '$.a')" +== 070 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'strict $.a' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'strict $.a' ERROR ON ERROR)" +== 071 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'strict $.a' DEFAULT 'error' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'strict $.a' DEFAULT 'error' ON ERROR)" +== 072 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'lax $.a' ERROR ON ERROR)" +== 073 +-- truncate_limit: 100 +-- NULL ON EMPTY +SELECT JSON_VALUE(jsonb '1', 'lax $.a' ERROR ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'lax $.a' ERROR ON EMPTY ERROR ON ERROR)" +== 074 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'strict $.*' DEFAULT 2 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'strict $.*' DEFAULT 2 ON ERROR)" +== 075 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' DEFAULT 2 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'lax $.a' DEFAULT 2 ON ERROR)" +== 076 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' DEFAULT '2' ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'lax $.a' DEFAULT '2' ON EMPTY)" +== 077 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' NULL ON EMPTY DEFAULT '2' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'lax $.a' NULL ON EMPTY DEFAULT '2' ON ERROR)" +== 078 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' DEFAULT '2' ON EMPTY DEFAULT '3' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'lax $.a' DEFAULT '2' ON EMPTY DEFAULT '3' ON ERROR)" +== 079 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', 'lax $.a' ERROR ON EMPTY DEFAULT '3' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , 'lax $.a' ERROR ON EMPTY DEFAULT '3' ON ERROR)" +== 080 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '[1,2]', '$[*]' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[1,2]'::jsonb , '$[*]' ERROR ON ERROR)" +== 081 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '[1,2]', '$[*]' DEFAULT '0' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[1,2]'::jsonb , '$[*]' DEFAULT '0' ON ERROR)" +== 082 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '[" "]', '$[*]' RETURNING int ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[\" \"]'::jsonb , '$[*]' RETURNING int ERROR ON ERROR)" +== 083 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '[" "]', '$[*]' RETURNING int DEFAULT 2 + 3 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[\" \"]'::jsonb , '$[*]' RETURNING int DEFAULT 2 + 3 ON ERROR)" +== 084 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '["1"]', '$[*]' RETURNING int DEFAULT 2 + 3 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[\"1\"]'::jsonb , '$[*]' RETURNING int DEFAULT 2 + 3 ON ERROR)" +== 085 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '["1"]', '$[*]' RETURNING int FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[\"1\"]'::jsonb , '$[*]' RETURNING int FORMAT JSON )" +== 086 +-- truncate_limit: 100 +-- RETURNING FORMAT not allowed + +-- RETUGNING pseudo-types not allowed +SELECT JSON_VALUE(jsonb '["1"]', '$[*]' RETURNING record) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('[\"1\"]'::jsonb , '$[*]' RETURNING record )" +== 087 +-- truncate_limit: 100 +SELECT + x, + JSON_VALUE( + jsonb '{"a": 1, "b": 2}', + '$.* ? (@ > $x)' PASSING x AS x + RETURNING int + DEFAULT -1 ON EMPTY + DEFAULT -2 ON ERROR + ) y +FROM + generate_series(0, 2) x +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(0, 2) x" +== 088 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$a' PASSING point ' (1, 2 )' AS a) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('null'::jsonb , '$a' PASSING point ' (1, 2 )' AS a)" +== 089 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$a' PASSING point ' (1, 2 )' AS a RETURNING point) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('null'::jsonb , '$a' PASSING point ' (1, 2 )' AS a RETURNING point )" +== 090 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$a' PASSING point ' (1, 2 )' AS a RETURNING point ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 091 +-- truncate_limit: 100 +-- Test PASSING and RETURNING date/time types +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('null'::jsonb , '$ts' PASSING '2018-02-21 12:34:56 +10'::timestamptz AS ts)" +== 092 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING timestamptz) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 093 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING timestamp) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 094 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING date '2018-02-21 12:34:56 +10' AS ts RETURNING date) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 095 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING time '2018-02-21 12:34:56 +10' AS ts RETURNING time) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 096 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timetz '2018-02-21 12:34:56 +10' AS ts RETURNING timetz) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 097 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamp '2018-02-21 12:34:56 +10' AS ts RETURNING timestamp) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 098 +-- truncate_limit: 100 +-- Also test RETURNING json[b] +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 099 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 100 +-- truncate_limit: 100 +-- Test that numeric JSON values are coerced uniformly +select json_value('{"a": 1.234}', '$.a' returning int error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": 1.234}' , '$.a' RETURNING int ERROR ON ERROR)" +== 101 +-- truncate_limit: 100 +select json_value('{"a": "1.234"}', '$.a' returning int error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": \"1.234\"}' , '$.a' RETURNING int ERROR ON ERROR)" +== 102 +-- truncate_limit: 100 +-- JSON_QUERY + +SELECT JSON_VALUE(NULL::jsonb, '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE(NULL::jsonb , '$')" +== 103 +-- truncate_limit: 100 +SELECT + JSON_QUERY(js, '$') AS "unspec", + JSON_QUERY(js, '$' WITHOUT WRAPPER) AS "without", + JSON_QUERY(js, '$' WITH CONDITIONAL WRAPPER) AS "with cond", + JSON_QUERY(js, '$' WITH UNCONDITIONAL ARRAY WRAPPER) AS "with uncond", + JSON_QUERY(js, '$' WITH ARRAY WRAPPER) AS "with" +FROM + (VALUES + (jsonb 'null'), + ('12.3'), + ('true'), + ('"aaa"'), + ('[1, null, "2"]'), + ('{"a": 1, "b": [2]}') + ) foo(js) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) foo(js)" +== 104 +-- truncate_limit: 100 +SELECT + JSON_QUERY(js, 'strict $[*]') AS "unspec", + JSON_QUERY(js, 'strict $[*]' WITHOUT WRAPPER) AS "without", + JSON_QUERY(js, 'strict $[*]' WITH CONDITIONAL WRAPPER) AS "with cond", + JSON_QUERY(js, 'strict $[*]' WITH UNCONDITIONAL ARRAY WRAPPER) AS "with uncond", + JSON_QUERY(js, 'strict $[*]' WITH ARRAY WRAPPER) AS "with" +FROM + (VALUES + (jsonb '1'), + ('[]'), + ('[null]'), + ('[12.3]'), + ('[true]'), + ('["aaa"]'), + ('[[1, 2, 3]]'), + ('[{"a": 1, "b": [2]}]'), + ('[1, "2", null, [3]]') + ) foo(js) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) foo(js)" +== 105 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING text )" +== 106 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text KEEP QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING text KEEP QUOTES)" +== 107 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text KEEP QUOTES ON SCALAR STRING) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING text KEEP QUOTES)" +== 108 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text OMIT QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING text OMIT QUOTES)" +== 109 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING text OMIT QUOTES ON SCALAR STRING) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING text OMIT QUOTES)" +== 110 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' OMIT QUOTES ERROR ON ERROR)" +== 111 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING json OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING pg_catalog.json OMIT QUOTES ERROR ON ERROR)" +== 112 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING bytea FORMAT JSON OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING bytea FORMAT JSON OMIT QUOTES ERROR ON ERROR)" +== 113 +-- truncate_limit: 100 +-- Behavior when a RETURNING type has typmod != -1 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING char(3) ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING char(3) ERROR ON ERROR)" +== 114 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING char(3)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING char(3) )" +== 115 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$' RETURNING char(3) OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$' RETURNING char(3) OMIT QUOTES ERROR ON ERROR)" +== 116 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$.a' RETURNING char(2) OMIT QUOTES DEFAULT 'bb' ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"aaa\"'::jsonb , '$.a' RETURNING char(2) OMIT QUOTES DEFAULT 'bb' ON EMPTY)" +== 117 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"aaa"', '$.a' RETURNING char(2) OMIT QUOTES DEFAULT '"bb"'::jsonb ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 118 +-- truncate_limit: 100 +-- OMIT QUOTES behavior should not be specified when WITH WRAPPER used: +-- Should fail +SELECT JSON_QUERY(jsonb '[1]', '$' WITH WRAPPER OMIT QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1]'::jsonb , '$' WITH UNCONDITIONAL WRAPPER OMIT QUOTES)" +== 119 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1]', '$' WITH CONDITIONAL WRAPPER OMIT QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1]'::jsonb , '$' WITH CONDITIONAL WRAPPER OMIT QUOTES)" +== 120 +-- truncate_limit: 100 +-- Should succeed +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITH CONDITIONAL WRAPPER KEEP QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[\"1\"]'::jsonb , '$[*]' WITH CONDITIONAL WRAPPER KEEP QUOTES)" +== 121 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITH UNCONDITIONAL WRAPPER KEEP QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[\"1\"]'::jsonb , '$[*]' WITH UNCONDITIONAL WRAPPER KEEP QUOTES)" +== 122 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITH WRAPPER KEEP QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[\"1\"]'::jsonb , '$[*]' WITH UNCONDITIONAL WRAPPER KEEP QUOTES)" +== 123 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITHOUT WRAPPER OMIT QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[\"1\"]'::jsonb , '$[*]' WITHOUT WRAPPER OMIT QUOTES)" +== 124 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '["1"]', '$[*]' WITHOUT WRAPPER KEEP QUOTES) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[\"1\"]'::jsonb , '$[*]' WITHOUT WRAPPER KEEP QUOTES)" +== 125 +-- truncate_limit: 100 +-- test QUOTES behavior. +SELECT JSON_QUERY(jsonb'{"rec": "{1,2,3}"}', '$.rec' returning int[] omit quotes) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"rec\": \"{1,2,3}\"}'::jsonb , '$.rec' RETURNING int[] OMIT QUOTES)" +== 126 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb'{"rec": "{1,2,3}"}', '$.rec' returning int[] keep quotes) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"rec\": \"{1,2,3}\"}'::jsonb , '$.rec' RETURNING int[] KEEP QUOTES)" +== 127 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb'{"rec": "{1,2,3}"}', '$.rec' returning int[] keep quotes error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"rec\": \"{1,2,3}\"}'::jsonb , '$.rec' RETURNING int[] KEEP QUOTES ERROR ON ERROR)" +== 128 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb'{"rec": "[1,2]"}', '$.rec' returning int4range omit quotes) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"rec\": \"[1,2]\"}'::jsonb , '$.rec' RETURNING int4range OMIT QUOTES)" +== 129 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb'{"rec": "[1,2]"}', '$.rec' returning int4range keep quotes) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"rec\": \"[1,2]\"}'::jsonb , '$.rec' RETURNING int4range KEEP QUOTES)" +== 130 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb'{"rec": "[1,2]"}', '$.rec' returning int4range keep quotes error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 131 +-- truncate_limit: 100 +CREATE DOMAIN qf_char_domain AS char(1) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN qf_char_domain AS char(1)" +== 132 +-- truncate_limit: 100 +CREATE DOMAIN qf_jsonb_domain AS jsonb +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN qf_jsonb_domain AS jsonb" +== 133 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"1"', '$' RETURNING qf_char_domain OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"1\"'::jsonb , '$' RETURNING qf_char_domain OMIT QUOTES ERROR ON ERROR)" +== 134 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"1"', '$' RETURNING qf_jsonb_domain OMIT QUOTES ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"1\"'::jsonb , '$' RETURNING qf_jsonb_domain OMIT QUOTES ERROR ON ERROR)" +== 135 +-- truncate_limit: 100 +DROP DOMAIN qf_char_domain, qf_jsonb_domain +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN qf_char_domain, qf_jsonb_domain" +== 136 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]')" +== 137 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' NULL ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' NULL ON EMPTY)" +== 138 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' EMPTY ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' EMPTY ARRAY ON EMPTY)" +== 139 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' EMPTY ARRAY ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' EMPTY ARRAY ON EMPTY)" +== 140 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' EMPTY OBJECT ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' EMPTY OBJECT ON EMPTY)" +== 141 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' ERROR ON EMPTY)" +== 142 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' DEFAULT '"empty"' ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' DEFAULT '\"empty\"' ON EMPTY)" +== 143 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY NULL ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' ERROR ON EMPTY NULL ON ERROR)" +== 144 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY EMPTY ARRAY ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' ERROR ON EMPTY EMPTY ARRAY ON ERROR)" +== 145 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' ERROR ON EMPTY EMPTY OBJECT ON ERROR)" +== 146 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' ERROR ON EMPTY ERROR ON ERROR)" +== 147 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[]', '$[*]' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[]'::jsonb , '$[*]' ERROR ON ERROR)" +== 148 +-- truncate_limit: 100 +-- NULL ON EMPTY + +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$[*]' ERROR ON ERROR)" +== 149 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' DEFAULT '"empty"' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$[*]' DEFAULT '\"empty\"' ON ERROR)" +== 150 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING pg_catalog.json )" +== 151 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING json FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING pg_catalog.json FORMAT JSON )" +== 152 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING jsonb )" +== 153 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING jsonb FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING jsonb FORMAT JSON )" +== 154 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING text )" +== 155 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING char(10)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING char(10) )" +== 156 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING text FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING text FORMAT JSON )" +== 157 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING bytea) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING bytea )" +== 158 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$' RETURNING bytea FORMAT JSON) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$' RETURNING bytea FORMAT JSON )" +== 159 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' RETURNING bytea EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$[*]' RETURNING bytea EMPTY OBJECT ON ERROR)" +== 160 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' RETURNING bytea FORMAT JSON EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$[*]' RETURNING bytea FORMAT JSON EMPTY OBJECT ON ERROR)" +== 161 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' RETURNING json EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$[*]' RETURNING pg_catalog.json EMPTY OBJECT ON ERROR)" +== 162 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2]', '$[*]' RETURNING jsonb EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2]'::jsonb , '$[*]' RETURNING jsonb EMPTY OBJECT ON ERROR)" +== 163 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[3,4]', '$[*]' RETURNING bigint[] EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[3,4]'::jsonb , '$[*]' RETURNING bigint[] EMPTY OBJECT ON ERROR)" +== 164 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"[3,4]"', '$[*]' RETURNING bigint[] EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"[3,4]\"'::jsonb , '$[*]' RETURNING bigint[] EMPTY OBJECT ON ERROR)" +== 165 +-- truncate_limit: 100 +-- Coercion fails with quotes on +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING int2 error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING int2 ERROR ON ERROR)" +== 166 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING int4 error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING int4 ERROR ON ERROR)" +== 167 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING int8 error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING int8 ERROR ON ERROR)" +== 168 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING bool error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING bool ERROR ON ERROR)" +== 169 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING numeric error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING numeric ERROR ON ERROR)" +== 170 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING real error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING real ERROR ON ERROR)" +== 171 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING float8 error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING float8 ERROR ON ERROR)" +== 172 +-- truncate_limit: 100 +-- Fine with OMIT QUOTES +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING int2 omit quotes error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING int2 OMIT QUOTES ERROR ON ERROR)" +== 173 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '"123.1"', '$' RETURNING float8 omit quotes error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"123.1\"'::jsonb , '$' RETURNING float8 OMIT QUOTES ERROR ON ERROR)" +== 174 +-- truncate_limit: 100 +-- RETUGNING pseudo-types not allowed +SELECT JSON_QUERY(jsonb '[3,4]', '$[*]' RETURNING anyarray EMPTY OBJECT ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[3,4]'::jsonb , '$[*]' RETURNING anyarray EMPTY OBJECT ON ERROR)" +== 175 +-- truncate_limit: 100 +SELECT + x, y, + JSON_QUERY( + jsonb '[1,2,3,4,5,null]', + '$[*] ? (@ >= $x && @ <= $y)' + PASSING x AS x, y AS y + WITH CONDITIONAL WRAPPER + EMPTY ARRAY ON EMPTY + ) list +FROM + generate_series(0, 4) x, + generate_series(0, 4) y +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(0, 4) x, generate_series(0, 4) y" +== 176 +-- truncate_limit: 100 +-- record type returning with quotes behavior. +CREATE TYPE comp_abc AS (a text, b int, c timestamp) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE comp_abc AS (a text, b int, c timestamp)" +== 177 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb'{"rec": "(abc,42,01.02.2003)"}', '$.rec' returning comp_abc omit quotes) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"rec\": \"(abc,42,01.02.2003)\"}'::jsonb , '$.rec' RETURNING comp_abc OMIT QUOTES)" +== 178 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb'{"rec": "(abc,42,01.02.2003)"}', '$.rec' returning comp_abc keep quotes) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"rec\": \"(abc,42,01.02.2003)\"}'::jsonb , '$.rec' RETURNING comp_abc KEEP QUOTES)" +== 179 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb'{"rec": "(abc,42,01.02.2003)"}', '$.rec' returning comp_abc keep quotes error on error) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 180 +-- truncate_limit: 100 +DROP TYPE comp_abc +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE comp_abc" +== 181 +-- truncate_limit: 100 +-- Extension: record types returning +CREATE TYPE sqljsonb_rec AS (a int, t text, js json, jb jsonb, jsa json[]) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE sqljsonb_rec AS (a int, t text, js pg_catalog.json, jb jsonb, jsa pg_catalog.json[])" +== 182 +-- truncate_limit: 100 +CREATE TYPE sqljsonb_reca AS (reca sqljsonb_rec[]) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE sqljsonb_reca AS (reca sqljsonb_rec[])" +== 183 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[{"a": 1, "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING sqljsonb_rec) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 184 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[{"a": "a", "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING sqljsonb_rec ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 185 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[{"a": "a", "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING sqljsonb_rec) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 186 +-- truncate_limit: 100 +SELECT * FROM unnest((JSON_QUERY(jsonb '{"jsa": [{"a": 1, "b": ["foo"]}, {"a": 2, "c": {}}, 123]}', '$' RETURNING sqljsonb_rec)).jsa) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((JSON_QUERY('{\"jsa\": [{\"a\": 1, \"b\": [\"foo\"]}, {\"a\": 2, \"c\": {}}, 123]}'::js..." +== 187 +-- truncate_limit: 100 +SELECT * FROM unnest((JSON_QUERY(jsonb '{"reca": [{"a": 1, "t": ["foo", []]}, {"a": 2, "jb": [{}, true]}]}', '$' RETURNING sqljsonb_reca)).reca) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest((JSON_QUERY('{\"reca\": [{\"a\": 1, \"t\": [\"foo\", []]}, {\"a\": 2, \"jb\": [{}, true]..." +== 188 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[{"a": 1, "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING jsonpath) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 189 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[{"a": 1, "b": "foo", "t": "aaa", "js": [1, "2", {}], "jb": {"x": [1, "2", {}]}}, {"a": 2}]', '$[0]' RETURNING jsonpath ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 190 +-- truncate_limit: 100 +-- Extension: array types returning +SELECT JSON_QUERY(jsonb '[1,2,null,"3"]', '$[*]' RETURNING int[] WITH WRAPPER) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2,null,\"3\"]'::jsonb , '$[*]' RETURNING int[] WITH UNCONDITIONAL WRAPPER)" +== 191 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2,null,"a"]', '$[*]' RETURNING int[] WITH WRAPPER ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 192 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '[1,2,null,"a"]', '$[*]' RETURNING int[] WITH WRAPPER) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('[1,2,null,\"a\"]'::jsonb , '$[*]' RETURNING int[] WITH UNCONDITIONAL WRAPPER)" +== 193 +-- truncate_limit: 100 +SELECT * FROM unnest(JSON_QUERY(jsonb '[{"a": 1, "t": ["foo", []]}, {"a": 2, "jb": [{}, true]}]', '$' RETURNING sqljsonb_rec[])) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest(JSON_QUERY('[{\"a\": 1, \"t\": [\"foo\", []]}, {\"a\": 2, \"jb\": [{}, true]}]'::jsonb..." +== 194 +-- truncate_limit: 100 +-- Extension: domain types returning +SELECT JSON_QUERY(jsonb '{"a": 1}', '$.a' RETURNING sqljsonb_int_not_null) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"a\": 1}'::jsonb , '$.a' RETURNING sqljsonb_int_not_null )" +== 195 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '{"a": 1}', '$.b' RETURNING sqljsonb_int_not_null) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"a\": 1}'::jsonb , '$.b' RETURNING sqljsonb_int_not_null )" +== 196 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '{"a": 1}', '$.b' RETURNING sqljsonb_int_not_null ERROR ON EMPTY ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 197 +-- truncate_limit: 100 +-- Test timestamptz passing and output +SELECT JSON_QUERY(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('null'::jsonb , '$ts' PASSING '2018-02-21 12:34:56 +10'::timestamptz AS ts)" +== 198 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING json) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 199 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING jsonb) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 200 +-- truncate_limit: 100 +-- Test constraints + +CREATE TABLE test_jsonb_constraints ( + js text, + i int, + x jsonb DEFAULT JSON_QUERY(jsonb '[1,2]', '$[*]' WITH WRAPPER) + CONSTRAINT test_jsonb_constraint1 + CHECK (js IS JSON) + CONSTRAINT test_jsonb_constraint2 + CHECK (JSON_EXISTS(js::jsonb, '$.a' PASSING i + 5 AS int, i::text AS "TXT", array[1,2,3] as arr)) + CONSTRAINT test_jsonb_constraint3 + CHECK (JSON_VALUE(js::jsonb, '$.a' RETURNING int DEFAULT '12' ON EMPTY ERROR ON ERROR) > i) + CONSTRAINT test_jsonb_constraint4 + CHECK (JSON_QUERY(js::jsonb, '$.a' WITH CONDITIONAL WRAPPER EMPTY OBJECT ON ERROR) = jsonb '[10]') + CONSTRAINT test_jsonb_constraint5 + CHECK (JSON_QUERY(js::jsonb, '$.a' RETURNING char(5) OMIT QUOTES EMPTY ARRAY ON EMPTY) > 'a' COLLATE "C") +) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_jsonb_constraints (js text, i int, x jsonb DEFAULT (JSON_QUERY('[1,2]'::jsonb ,..." +== 201 +-- truncate_limit: 100 +SELECT check_clause +FROM information_schema.check_constraints +WHERE constraint_name LIKE 'test_jsonb_constraint%' +ORDER BY 1 +-- +TABLE: name="information_schema.check_constraints" schema="information_schema" table="check_constraints" ctx=Select +FILTER: schema="" table="" column="constraint_name" +STMT: SelectStmt +TRUNCATED: "SELECT check_clause FROM information_schema.check_constraints WHERE ... ORDER BY 1" +== 202 +-- truncate_limit: 100 +SELECT pg_get_expr(adbin, adrelid) +FROM pg_attrdef +WHERE adrelid = 'test_jsonb_constraints'::regclass +ORDER BY 1 +-- +TABLE: name="pg_attrdef" schema="" table="pg_attrdef" ctx=Select +FUNCTION: name="pg_get_expr" function="pg_get_expr" schema="" ctx=Call +FILTER: schema="" table="" column="adrelid" +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_expr(adbin, adrelid) FROM pg_attrdef WHERE ... ORDER BY 1" +== 203 +-- truncate_limit: 100 +INSERT INTO test_jsonb_constraints VALUES ('', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_constraints VALUES ('', 1)" +== 204 +-- truncate_limit: 100 +INSERT INTO test_jsonb_constraints VALUES ('1', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_constraints VALUES ('1', 1)" +== 205 +-- truncate_limit: 100 +INSERT INTO test_jsonb_constraints VALUES ('[]') +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_constraints VALUES ('[]')" +== 206 +-- truncate_limit: 100 +INSERT INTO test_jsonb_constraints VALUES ('{"b": 1}', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_constraints VALUES ('{\"b\": 1}', 1)" +== 207 +-- truncate_limit: 100 +INSERT INTO test_jsonb_constraints VALUES ('{"a": 1}', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_constraints VALUES ('{\"a\": 1}', 1)" +== 208 +-- truncate_limit: 100 +INSERT INTO test_jsonb_constraints VALUES ('{"a": 10}', 1) +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_jsonb_constraints VALUES ('{\"a\": 10}', 1)" +== 209 +-- truncate_limit: 100 +DROP TABLE test_jsonb_constraints +-- +TABLE: name="test_jsonb_constraints" schema="" table="test_jsonb_constraints" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_jsonb_constraints" +== 210 +-- truncate_limit: 100 +-- Test mutabilily of query functions +CREATE TABLE test_jsonb_mutability(js jsonb, b int) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_jsonb_mutability (js jsonb, b int)" +== 211 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$')))" +== 212 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a[0]')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a[0]')))" +== 213 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.time()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.time()')))" +== 214 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.date()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.date()')))" +== 215 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.time_tz()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.time_tz()')))" +== 216 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.timestamp()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.timestamp()')))" +== 217 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.timestamp_tz()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.timestamp_tz()')))" +== 218 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.date() < $.time_tz())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.date() < $.time_tz(..." +== 219 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.date() < $.time())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.date() < $.time())')))" +== 220 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.time() < $.time())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.time() < $.time())')))" +== 221 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.time() < $.time_tz())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.time() < $.time_tz(..." +== 222 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp() < $.timestamp_tz())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.timestamp() < $.tim..." +== 223 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp_tz() < $.timestamp_tz())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.timestamp_tz() < $...." +== 224 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.time() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.time() < $.datetime..." +== 225 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.date() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.date() < $.datetime..." +== 226 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.timestamp() < $.dat..." +== 227 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp() < $.datetime("HH:MI"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.timestamp() < $.dat..." +== 228 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp_tz() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.timestamp_tz() < $...." +== 229 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp_tz() < $.datetime("HH:MI"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.timestamp_tz() < $...." +== 230 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.date() < $x' PASSING '12:34'::timetz AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.date() < $x' PASSING '12:3..." +== 231 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.date() < $x' PASSING '1234'::int AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.date() < $x' PASSING '1234..." +== 232 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.timestamp(2) < $.timestamp(3))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.timestamp(2) < $.ti..." +== 233 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime()')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.datetime()')))" +== 234 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@ < $.datetime())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@ < $.datetime())')))" +== 235 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime() < $.datetime())')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.datetime() < $.date..." +== 236 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime() < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.datetime() < $.date..." +== 237 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime("HH:MI TZH") < $.datetime("HH:MI TZH"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.datetime(\"HH:MI TZH..." +== 238 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime("HH:MI") < $.datetime("YY-MM-DD HH:MI"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.datetime(\"HH:MI\") <..." +== 239 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.a ? (@.datetime("HH:MI TZH") < $.datetime("YY-MM-DD HH:MI"))')) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.a ? (@.datetime(\"HH:MI TZH..." +== 240 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime("HH:MI TZH") < $x' PASSING '12:34'::timetz AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.datetime(\"HH:MI TZH\") < $x..." +== 241 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime("HH:MI TZH") < $y' PASSING '12:34'::timetz AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.datetime(\"HH:MI TZH\") < $y..." +== 242 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime() < $x' PASSING '12:34'::timetz AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.datetime() < $x' PASSING '..." +== 243 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime() < $x' PASSING '1234'::int AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.datetime() < $x' PASSING '..." +== 244 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime() ? (@ == $x)' PASSING '12:34'::time AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.datetime() ? (@ == $x)' PA..." +== 245 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$.datetime("YY-MM-DD") ? (@ == $x)' PASSING '2020-07-14'::date AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$.datetime(\"YY-MM-DD\") ? (@ ..." +== 246 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$[1, $.a ? (@.datetime() == $x)]' PASSING '12:34'::time AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$[1, $.a ? (@.datetime() == ..." +== 247 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$[1, 0 to $.a ? (@.datetime() == $x)]' PASSING '12:34'::time AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$[1, 0 to $.a ? (@.datetime(..." +== 248 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_QUERY(js, '$[1, $.a ? (@.datetime("HH:MI") == $x)]' PASSING '12:34'::time AS x)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_QUERY(js , '$[1, $.a ? (@.datetime(\"HH:M..." +== 249 +-- truncate_limit: 100 +CREATE INDEX ON test_jsonb_mutability (JSON_VALUE(js, '$' DEFAULT random()::int ON ERROR)) +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON test_jsonb_mutability USING btree ((JSON_VALUE(js , '$' DEFAULT random()::int ON ..." +== 250 +-- truncate_limit: 100 +-- DEFAULT expression +CREATE OR REPLACE FUNCTION ret_setint() RETURNS SETOF integer AS +$$ +BEGIN + RETURN QUERY EXECUTE 'select 1 union all select 1'; +END; +$$ +LANGUAGE plpgsql IMMUTABLE +-- +FUNCTION: name="ret_setint" function="ret_setint" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION ret_setint() RETURNS SETOF int AS $$\nBEGIN\n RETURN QUERY EXECUTE 's..." +== 251 +-- truncate_limit: 100 +SELECT JSON_QUERY(js, '$' RETURNING int DEFAULT ret_setint() ON ERROR) FROM test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=Select +FUNCTION: name="ret_setint" function="ret_setint" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY(js , '$' RETURNING int DEFAULT ret_setint() ON ERROR) FROM test_jsonb_mutability" +== 252 +-- truncate_limit: 100 +SELECT JSON_QUERY(js, '$' RETURNING int DEFAULT b + 1 ON ERROR) FROM test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY(js , '$' RETURNING int DEFAULT b + 1 ON ERROR) FROM test_jsonb_mutability" +== 253 +-- truncate_limit: 100 +SELECT JSON_QUERY(js, '$' RETURNING int DEFAULT sum(1) over() ON ERROR) FROM test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM test_jsonb_mutability" +== 254 +-- truncate_limit: 100 +SELECT JSON_QUERY(js, '$' RETURNING int DEFAULT (SELECT 1) ON ERROR) FROM test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY(js , '$' RETURNING int DEFAULT (SELECT 1) ON ERROR) FROM test_jsonb_mutability" +== 255 +-- truncate_limit: 100 +DROP TABLE test_jsonb_mutability +-- +TABLE: name="test_jsonb_mutability" schema="" table="test_jsonb_mutability" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_jsonb_mutability" +== 256 +-- truncate_limit: 100 +DROP FUNCTION ret_setint +-- +FUNCTION: name="ret_setint" function="ret_setint" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION ret_setint" +== 257 +-- truncate_limit: 100 +CREATE DOMAIN queryfuncs_test_domain AS text CHECK (value <> 'foo') +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN queryfuncs_test_domain AS text CHECK (value <> 'foo')" +== 258 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '{"d1": "H"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT 'foo'::queryfuncs_test_domain ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 259 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '{"d1": "H"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT 'foo1'::queryfuncs_test_domain ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 260 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '{"d1": "H"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT '"foo1"'::jsonb::text ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 261 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '{"d1": "foo"}', '$.a2' RETURNING queryfuncs_test_domain DEFAULT 'foo1'::queryfuncs_test_domain ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 262 +-- truncate_limit: 100 +-- Check the cases where a coercion-related expression is masking an +-- unsupported expressions + +-- CoerceViaIO +SELECT JSON_QUERY('"a"', '$.a' RETURNING int DEFAULT (SELECT '"1"')::jsonb ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"a\"' , '$.a' RETURNING int DEFAULT (SELECT '\"1\"')::jsonb ON ERROR)" +== 263 +-- truncate_limit: 100 +-- CoerceToDomain +SELECT JSON_QUERY('"a"', '$.a' RETURNING queryfuncs_test_domain DEFAULT (select '"1"')::queryfuncs_test_domain ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 264 +-- truncate_limit: 100 +-- RelabelType +SELECT JSON_QUERY('"a"', '$.a' RETURNING int DEFAULT (SELECT 1)::oid::int ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"a\"' , '$.a' RETURNING int DEFAULT (SELECT 1)::oid::int ON ERROR)" +== 265 +-- truncate_limit: 100 +-- ArrayCoerceExpr +SELECT JSON_QUERY('"a"', '$.a' RETURNING int[] DEFAULT (SELECT '{1}')::oid[]::int[] ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"a\"' , '$.a' RETURNING int[] DEFAULT (SELECT '{1}')::oid[]::int[] ON ERROR)" +== 266 +-- truncate_limit: 100 +-- CollateExpr +SELECT JSON_QUERY('"a"', '$.a' RETURNING int[] DEFAULT (SELECT '{1}')::text COLLATE "C" ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('\"a\"' , '$.a' RETURNING int[] DEFAULT (SELECT '{1}')::text COLLATE \"C\" ON ERROR)" +== 267 +-- truncate_limit: 100 +-- ConvertRowtypeExpr +CREATE TABLE someparent (a int) +-- +TABLE: name="someparent" schema="" table="someparent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE someparent (a int)" +== 268 +-- truncate_limit: 100 +CREATE TABLE somechild () INHERITS (someparent) +-- +TABLE: name="somechild" schema="" table="somechild" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE somechild () INHERITS (someparent)" +== 269 +-- truncate_limit: 100 +SELECT JSON_QUERY('"a"', '$.a' RETURNING someparent DEFAULT (SELECT '(1)')::somechild::someparent ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 270 +-- truncate_limit: 100 +DROP DOMAIN queryfuncs_test_domain +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN queryfuncs_test_domain" +== 271 +-- truncate_limit: 100 +DROP TABLE someparent, somechild +-- +TABLE: name="someparent" schema="" table="someparent" ctx=DDL +TABLE: name="somechild" schema="" table="somechild" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE someparent, somechild" +== 272 +-- truncate_limit: 100 +-- Extension: non-constant JSON path +SELECT JSON_EXISTS(jsonb '{"a": 123}', '$' || '.' || 'a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"a\": 123}'::jsonb , ('$' || '.') || 'a')" +== 273 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '{"a": 123}', '$' || '.' || 'a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": 123}'::jsonb , ('$' || '.') || 'a')" +== 274 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '{"a": 123}', '$' || '.' || 'b' DEFAULT 'foo' ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('{\"a\": 123}'::jsonb , ('$' || '.') || 'b' DEFAULT 'foo' ON EMPTY)" +== 275 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '{"a": 123}', '$' || '.' || 'a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"a\": 123}'::jsonb , ('$' || '.') || 'a')" +== 276 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '{"a": 123}', '$' || '.' || 'a' WITH WRAPPER) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"a\": 123}'::jsonb , ('$' || '.') || 'a' WITH UNCONDITIONAL WRAPPER)" +== 277 +-- truncate_limit: 100 +-- Should fail (invalid path) +SELECT JSON_QUERY(jsonb '{"a": 123}', 'error' || ' ' || 'error') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('{\"a\": 123}'::jsonb , ('error' || ' ') || 'error')" +== 278 +-- truncate_limit: 100 +-- Non-jsonb inputs automatically coerced to jsonb +SELECT JSON_EXISTS(json '{"a": 123}', '$' || '.' || 'a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('{\"a\": 123}'::pg_catalog.json , ('$' || '.') || 'a')" +== 279 +-- truncate_limit: 100 +SELECT JSON_QUERY(NULL FORMAT JSON, '$') +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY(NULL FORMAT JSON , '$')" +== 280 +-- truncate_limit: 100 +-- Test non-const jsonpath +CREATE TEMP TABLE jsonpaths (path) AS SELECT '$' +-- +TABLE: name="jsonpaths" schema="" table="jsonpaths" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE jsonpaths(path) AS SELECT '$'" +== 281 +-- truncate_limit: 100 +SELECT json_value('"aaa"', path RETURNING json) FROM jsonpaths +-- +TABLE: name="jsonpaths" schema="" table="jsonpaths" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"aaa\"' , path RETURNING pg_catalog.json ) FROM jsonpaths" +== 282 +-- truncate_limit: 100 +-- Test PASSING argument parsing +SELECT JSON_QUERY(jsonb 'null', '$xyz' PASSING 1 AS xy) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('null'::jsonb , '$xyz' PASSING 1 AS xy)" +== 283 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb 'null', '$xy' PASSING 1 AS xyz) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('null'::jsonb , '$xy' PASSING 1 AS xyz)" +== 284 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb 'null', '$xyz' PASSING 1 AS xyz) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('null'::jsonb , '$xyz' PASSING 1 AS xyz)" +== 285 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb 'null', '$Xyz' PASSING 1 AS Xyz) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('null'::jsonb , '$Xyz' PASSING 1 AS xyz)" +== 286 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb 'null', '$Xyz' PASSING 1 AS "Xyz") +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('null'::jsonb , '$Xyz' PASSING 1 AS \"Xyz\")" +== 287 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb 'null', '$"Xyz"' PASSING 1 AS "Xyz") +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('null'::jsonb , '$\"Xyz\"' PASSING 1 AS \"Xyz\")" +== 288 +-- truncate_limit: 100 +-- Test ON ERROR / EMPTY value validity for the function; all fail. +SELECT JSON_EXISTS(jsonb '1', '$' DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_EXISTS('1'::jsonb , '$' DEFAULT 1 ON ERROR)" +== 289 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1', '$' EMPTY ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1'::jsonb , '$' EMPTY ARRAY ON ERROR)" +== 290 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '1', '$' TRUE ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('1'::jsonb , '$' TRUE ON ERROR)" +== 291 +-- truncate_limit: 100 +-- Test implicit coercion to a domain over fixed-length type specified in +-- RETURNING +CREATE DOMAIN queryfuncs_char2 AS char(2) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN queryfuncs_char2 AS char(2)" +== 292 +-- truncate_limit: 100 +CREATE DOMAIN queryfuncs_char2_chk AS char(2) CHECK (VALUE NOT IN ('12')) +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN queryfuncs_char2_chk AS char(2) CHECK (value NOT IN ('12'))" +== 293 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '123', '$' RETURNING queryfuncs_char2 ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('123'::jsonb , '$' RETURNING queryfuncs_char2 ERROR ON ERROR)" +== 294 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '123', '$' RETURNING queryfuncs_char2 DEFAULT '1' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('123'::jsonb , '$' RETURNING queryfuncs_char2 DEFAULT '1' ON ERROR)" +== 295 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '123', '$' RETURNING queryfuncs_char2_chk ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('123'::jsonb , '$' RETURNING queryfuncs_char2_chk ERROR ON ERROR)" +== 296 +-- truncate_limit: 100 +SELECT JSON_QUERY(jsonb '123', '$' RETURNING queryfuncs_char2_chk DEFAULT '1' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_QUERY('123'::jsonb , '$' RETURNING queryfuncs_char2_chk DEFAULT '1' ON ERROR)" +== 297 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING queryfuncs_char2 ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('123'::jsonb , '$' RETURNING queryfuncs_char2 ERROR ON ERROR)" +== 298 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING queryfuncs_char2 DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('123'::jsonb , '$' RETURNING queryfuncs_char2 DEFAULT 1 ON ERROR)" +== 299 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING queryfuncs_char2_chk ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('123'::jsonb , '$' RETURNING queryfuncs_char2_chk ERROR ON ERROR)" +== 300 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '123', '$' RETURNING queryfuncs_char2_chk DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('123'::jsonb , '$' RETURNING queryfuncs_char2_chk DEFAULT 1 ON ERROR)" +== 301 +-- truncate_limit: 100 +DROP DOMAIN queryfuncs_char2, queryfuncs_char2_chk +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN queryfuncs_char2, queryfuncs_char2_chk" +== 302 +-- truncate_limit: 100 +-- Test coercion to domain over another fixed-length type of the ON ERROR / +-- EMPTY expressions. Ask user to cast the DEFAULT expression explicitly if +-- automatic casting cannot be done, for example, from int to bit(2). +CREATE DOMAIN queryfuncs_d_varbit3 AS varbit(3) CHECK (VALUE <> '01') +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN queryfuncs_d_varbit3 AS varbit(3) CHECK (value <> '01')" +== 303 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING queryfuncs_d_varbit3 DEFAULT '111111' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1234'::jsonb , '$' RETURNING queryfuncs_d_varbit3 DEFAULT '111111' ON ERROR)" +== 304 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING queryfuncs_d_varbit3 DEFAULT '010' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1234'::jsonb , '$' RETURNING queryfuncs_d_varbit3 DEFAULT '010' ON ERROR)" +== 305 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING queryfuncs_d_varbit3 DEFAULT '01' ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1234'::jsonb , '$' RETURNING queryfuncs_d_varbit3 DEFAULT '01' ON ERROR)" +== 306 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"111"', '$' RETURNING bit(2) ERROR ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"111\"'::jsonb , '$' RETURNING pg_catalog.bit(2) ERROR ON ERROR)" +== 307 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING bit(3) DEFAULT 1 ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('1234'::jsonb , '$' RETURNING pg_catalog.bit(3) DEFAULT 1 ON ERROR)" +== 308 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '1234', '$' RETURNING bit(3) DEFAULT 1::bit(3) ON ERROR) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 309 +-- truncate_limit: 100 +SELECT JSON_VALUE(jsonb '"111"', '$.a' RETURNING bit(3) DEFAULT '1111' ON EMPTY) +-- +STMT: SelectStmt +TRUNCATED: "SELECT JSON_VALUE('\"111\"'::jsonb , '$.a' RETURNING pg_catalog.bit(3) DEFAULT '1111' ON EMPTY)" +== 310 +-- truncate_limit: 100 +DROP DOMAIN queryfuncs_d_varbit3 +-- +STMT: DropStmt +TRUNCATED: "DROP DOMAIN queryfuncs_d_varbit3" diff --git a/parser/testdata/summary_truncate/postgres_regress/stats.metadata.json b/parser/testdata/summary_truncate/postgres_regress/stats.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/stats.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/stats.test b/parser/testdata/summary_truncate/postgres_regress/stats.test new file mode 100644 index 0000000..a091102 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/stats.test @@ -0,0 +1,3593 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test cumulative stats system +|-- +-- Must be run after tenk2 has been created (by create_table), +-- populated (by create_misc) and indexed (by create_index). +|-- + +-- conditio sine qua non +SHOW track_counts +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW track_counts" +== 002 +-- truncate_limit: 100 +-- must be on + +-- ensure that both seqscan and indexscan plans are allowed +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 003 +-- truncate_limit: 100 +SET enable_indexscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 004 +-- truncate_limit: 100 +-- for the moment, we don't want index-only scans here +SET enable_indexonlyscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexonlyscan TO OFF" +== 005 +-- truncate_limit: 100 +-- not enabled by default, but we want to test it... +SET track_functions TO 'all' +-- +STMT: VariableSetStmt +TRUNCATED: "SET track_functions TO \"all\"" +== 006 +-- truncate_limit: 100 +-- record dboid for later use +SELECT oid AS dboid from pg_database where datname = current_database() +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +TRUNCATED: "SELECT oid AS dboid FROM pg_database WHERE datname = current_database()" +== 007 +-- truncate_limit: 100 +-- save counters +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 008 +-- truncate_limit: 100 +SET LOCAL stats_fetch_consistency = snapshot +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL stats_fetch_consistency TO snapshot" +== 009 +-- truncate_limit: 100 +CREATE TABLE prevstats AS +SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch, + (b.heap_blks_read + b.heap_blks_hit) AS heap_blks, + (b.idx_blks_read + b.idx_blks_hit) AS idx_blks, + pg_stat_get_snapshot_timestamp() as snap_ts + FROM pg_catalog.pg_stat_user_tables AS t, + pg_catalog.pg_statio_user_tables AS b + WHERE t.relname='tenk2' AND b.relname='tenk2' +-- +TABLE: name="prevstats" schema="" table="prevstats" ctx=DDL +TABLE: name="pg_catalog.pg_stat_user_tables" schema="pg_catalog" table="pg_stat_user_tables" ctx=Select +TABLE: name="pg_catalog.pg_statio_user_tables" schema="pg_catalog" table="pg_statio_user_tables" ctx=Select +ALIAS: "b"="pg_catalog.pg_statio_user_tables" +ALIAS: "t"="pg_catalog.pg_stat_user_tables" +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +FILTER: schema="" table="t" column="relname" +FILTER: schema="" table="b" column="relname" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE prevstats AS SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch, b.heap_..." +== 010 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 011 +-- truncate_limit: 100 +-- test effects of TRUNCATE on n_live_tup/n_dead_tup counters +CREATE TABLE trunc_stats_test(id serial) +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_stats_test (id serial)" +== 012 +-- truncate_limit: 100 +CREATE TABLE trunc_stats_test1(id serial, stuff text) +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_stats_test1 (id serial, stuff text)" +== 013 +-- truncate_limit: 100 +CREATE TABLE trunc_stats_test2(id serial) +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_stats_test2 (id serial)" +== 014 +-- truncate_limit: 100 +CREATE TABLE trunc_stats_test3(id serial, stuff text) +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_stats_test3 (id serial, stuff text)" +== 015 +-- truncate_limit: 100 +CREATE TABLE trunc_stats_test4(id serial) +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_stats_test4 (id serial)" +== 016 +-- truncate_limit: 100 +-- check that n_live_tup is reset to 0 after truncate +INSERT INTO trunc_stats_test DEFAULT VALUES +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test DEFAULT VALUES" +== 017 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test DEFAULT VALUES +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test DEFAULT VALUES" +== 018 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test DEFAULT VALUES +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test DEFAULT VALUES" +== 019 +-- truncate_limit: 100 +TRUNCATE trunc_stats_test +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_stats_test" +== 020 +-- truncate_limit: 100 +-- test involving a truncate in a transaction; 4 ins but only 1 live +INSERT INTO trunc_stats_test1 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test1 DEFAULT VALUES" +== 021 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test1 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test1 DEFAULT VALUES" +== 022 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test1 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test1 DEFAULT VALUES" +== 023 +-- truncate_limit: 100 +UPDATE trunc_stats_test1 SET id = id + 10 WHERE id IN (1, 2) +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trunc_stats_test1 SET id = id + 10 WHERE id IN (1, 2)" +== 024 +-- truncate_limit: 100 +DELETE FROM trunc_stats_test1 WHERE id = 3 +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trunc_stats_test1 WHERE id = 3" +== 025 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 026 +-- truncate_limit: 100 +UPDATE trunc_stats_test1 SET id = id + 100 +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trunc_stats_test1 SET id = id + 100" +== 027 +-- truncate_limit: 100 +TRUNCATE trunc_stats_test1 +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_stats_test1" +== 028 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test1 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test1 DEFAULT VALUES" +== 029 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 030 +-- truncate_limit: 100 +-- use a savepoint: 1 insert, 1 live +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 031 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test2 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test2 DEFAULT VALUES" +== 032 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test2 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test2 DEFAULT VALUES" +== 033 +-- truncate_limit: 100 +SAVEPOINT p1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT p1" +== 034 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test2 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test2 DEFAULT VALUES" +== 035 +-- truncate_limit: 100 +TRUNCATE trunc_stats_test2 +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_stats_test2" +== 036 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test2 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test2 DEFAULT VALUES" +== 037 +-- truncate_limit: 100 +RELEASE SAVEPOINT p1 +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE p1" +== 038 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 039 +-- truncate_limit: 100 +-- rollback a savepoint: this should count 4 inserts and have 2 +-- live tuples after commit (and 2 dead ones due to aborted subxact) +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 040 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test3 DEFAULT VALUES" +== 041 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test3 DEFAULT VALUES" +== 042 +-- truncate_limit: 100 +SAVEPOINT p1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT p1" +== 043 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test3 DEFAULT VALUES" +== 044 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test3 DEFAULT VALUES" +== 045 +-- truncate_limit: 100 +TRUNCATE trunc_stats_test3 +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_stats_test3" +== 046 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test3 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test3 DEFAULT VALUES" +== 047 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT p1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT p1" +== 048 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 049 +-- truncate_limit: 100 +-- rollback a truncate: this should count 2 inserts and produce 2 dead tuples +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 050 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test4 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test4 DEFAULT VALUES" +== 051 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test4 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test4 DEFAULT VALUES" +== 052 +-- truncate_limit: 100 +TRUNCATE trunc_stats_test4 +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_stats_test4" +== 053 +-- truncate_limit: 100 +INSERT INTO trunc_stats_test4 DEFAULT VALUES +-- +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trunc_stats_test4 DEFAULT VALUES" +== 054 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 055 +-- truncate_limit: 100 +-- do a seqscan +SELECT count(*) FROM tenk2 +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk2" +== 056 +-- truncate_limit: 100 +-- do an indexscan +-- make sure it is not a bitmap scan, which might skip fetching heap tuples +SET enable_bitmapscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 057 +-- truncate_limit: 100 +SELECT count(*) FROM tenk2 WHERE unique1 = 1 +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk2 WHERE unique1 = 1" +== 058 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 059 +-- truncate_limit: 100 +-- ensure pending stats are flushed +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 060 +-- truncate_limit: 100 +-- check effects +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 061 +-- truncate_limit: 100 +SET LOCAL stats_fetch_consistency = snapshot +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL stats_fetch_consistency TO snapshot" +== 062 +-- truncate_limit: 100 +SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup + FROM pg_stat_user_tables + WHERE relname like 'trunc_stats_test%' order by relname +-- +TABLE: name="pg_stat_user_tables" schema="" table="pg_stat_user_tables" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_user_tables WHERE relname LIKE 'trunc_stats_test%' ORDER BY relname" +== 063 +-- truncate_limit: 100 +SELECT st.seq_scan >= pr.seq_scan + 1, + st.seq_tup_read >= pr.seq_tup_read + cl.reltuples, + st.idx_scan >= pr.idx_scan + 1, + st.idx_tup_fetch >= pr.idx_tup_fetch + 1 + FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr + WHERE st.relname='tenk2' AND cl.relname='tenk2' +-- +TABLE: name="pg_stat_user_tables" schema="" table="pg_stat_user_tables" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="prevstats" schema="" table="prevstats" ctx=Select +ALIAS: "cl"="pg_class" +ALIAS: "pr"="prevstats" +ALIAS: "st"="pg_stat_user_tables" +FILTER: schema="" table="st" column="relname" +FILTER: schema="" table="cl" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_user_tables st, pg_class cl, prevstats pr WHERE ..." +== 064 +-- truncate_limit: 100 +SELECT st.heap_blks_read + st.heap_blks_hit >= pr.heap_blks + cl.relpages, + st.idx_blks_read + st.idx_blks_hit >= pr.idx_blks + 1 + FROM pg_statio_user_tables AS st, pg_class AS cl, prevstats AS pr + WHERE st.relname='tenk2' AND cl.relname='tenk2' +-- +TABLE: name="pg_statio_user_tables" schema="" table="pg_statio_user_tables" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="prevstats" schema="" table="prevstats" ctx=Select +ALIAS: "cl"="pg_class" +ALIAS: "pr"="prevstats" +ALIAS: "st"="pg_statio_user_tables" +FILTER: schema="" table="st" column="relname" +FILTER: schema="" table="cl" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_statio_user_tables st, pg_class cl, prevstats pr WHERE ..." +== 065 +-- truncate_limit: 100 +SELECT pr.snap_ts < pg_stat_get_snapshot_timestamp() as snapshot_newer +FROM prevstats AS pr +-- +TABLE: name="prevstats" schema="" table="prevstats" ctx=Select +ALIAS: "pr"="prevstats" +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pr.snap_ts < pg_stat_get_snapshot_timestamp() AS snapshot_newer FROM prevstats pr" +== 066 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 067 +-- truncate_limit: 100 +---- +-- Basic tests for track_functions +--- +CREATE FUNCTION stats_test_func1() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN END;$$ +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION stats_test_func1() RETURNS void LANGUAGE plpgsql AS $$BEGIN END;$$" +== 068 +-- truncate_limit: 100 +SELECT 'stats_test_func1()'::regprocedure::oid AS stats_test_func1_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'stats_test_func1()'::regprocedure::oid AS stats_test_func1_oid" +== 069 +-- truncate_limit: 100 +CREATE FUNCTION stats_test_func2() RETURNS VOID LANGUAGE plpgsql AS $$BEGIN END;$$ +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION stats_test_func2() RETURNS void LANGUAGE plpgsql AS $$BEGIN END;$$" +== 070 +-- truncate_limit: 100 +SELECT 'stats_test_func2()'::regprocedure::oid AS stats_test_func2_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'stats_test_func2()'::regprocedure::oid AS stats_test_func2_oid" +== 071 +-- truncate_limit: 100 +-- test that stats are accumulated +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 072 +-- truncate_limit: 100 +SET LOCAL stats_fetch_consistency = none +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL stats_fetch_consistency TO \"none\"" +== 073 +-- truncate_limit: 100 +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 074 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 075 +-- truncate_limit: 100 +SELECT stats_test_func1() +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stats_test_func1()" +== 076 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 077 +-- truncate_limit: 100 +SELECT stats_test_func1() +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stats_test_func1()" +== 078 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 079 +-- truncate_limit: 100 +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 080 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 081 +-- truncate_limit: 100 +-- Verify that function stats are not transactional + +-- rolled back savepoint in committing transaction +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 082 +-- truncate_limit: 100 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stats_test_func2()" +== 083 +-- truncate_limit: 100 +SAVEPOINT foo +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT foo" +== 084 +-- truncate_limit: 100 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stats_test_func2()" +== 085 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT foo +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT foo" +== 086 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_function_calls(:stats_test_func2_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 087 +-- truncate_limit: 100 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stats_test_func2()" +== 088 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 089 +-- truncate_limit: 100 +-- rolled back transaction +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 090 +-- truncate_limit: 100 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stats_test_func2()" +== 091 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 092 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 093 +-- truncate_limit: 100 +-- check collected stats +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 92 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 094 +-- truncate_limit: 100 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func2_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 095 +-- truncate_limit: 100 +-- check that a rolled back drop function stats leaves stats alive +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 096 +-- truncate_limit: 100 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 097 +-- truncate_limit: 100 +DROP FUNCTION stats_test_func1() +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION stats_test_func1()" +== 098 +-- truncate_limit: 100 +-- shouldn't be visible via view +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 100 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 099 +-- truncate_limit: 100 +-- but still via oid access +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 100 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 101 +-- truncate_limit: 100 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 102 +-- truncate_limit: 100 +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 103 +-- truncate_limit: 100 +-- check that function dropped in main transaction leaves no stats behind +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 104 +-- truncate_limit: 100 +DROP FUNCTION stats_test_func1() +-- +FUNCTION: name="stats_test_func1" function="stats_test_func1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION stats_test_func1()" +== 105 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 106 +-- truncate_limit: 100 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func1_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 107 +-- truncate_limit: 100 +SELECT pg_stat_get_function_calls(:stats_test_func1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 108 +-- truncate_limit: 100 +-- check that function dropped in a subtransaction leaves no stats behind +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 109 +-- truncate_limit: 100 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stats_test_func2()" +== 110 +-- truncate_limit: 100 +SAVEPOINT a +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT a" +== 111 +-- truncate_limit: 100 +SELECT stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT stats_test_func2()" +== 112 +-- truncate_limit: 100 +SAVEPOINT b +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT b" +== 113 +-- truncate_limit: 100 +DROP FUNCTION stats_test_func2() +-- +FUNCTION: name="stats_test_func2" function="stats_test_func2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION stats_test_func2()" +== 114 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 115 +-- truncate_limit: 100 +SELECT funcname, calls FROM pg_stat_user_functions WHERE funcid = :stats_test_func2_oid +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 116 +-- truncate_limit: 100 +SELECT pg_stat_get_function_calls(:stats_test_func2_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 35 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 117 +-- truncate_limit: 100 +-- Check that stats for relations are dropped. For that we need to access stats +-- by oid after the DROP TABLE. Save oids. +CREATE TABLE drop_stats_test() +-- +TABLE: name="drop_stats_test" schema="" table="drop_stats_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE drop_stats_test ()" +== 118 +-- truncate_limit: 100 +INSERT INTO drop_stats_test DEFAULT VALUES +-- +TABLE: name="drop_stats_test" schema="" table="drop_stats_test" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO drop_stats_test DEFAULT VALUES" +== 119 +-- truncate_limit: 100 +SELECT 'drop_stats_test'::regclass::oid AS drop_stats_test_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'drop_stats_test'::regclass::oid AS drop_stats_test_oid" +== 120 +-- truncate_limit: 100 +CREATE TABLE drop_stats_test_xact() +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE drop_stats_test_xact ()" +== 121 +-- truncate_limit: 100 +INSERT INTO drop_stats_test_xact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO drop_stats_test_xact DEFAULT VALUES" +== 122 +-- truncate_limit: 100 +SELECT 'drop_stats_test_xact'::regclass::oid AS drop_stats_test_xact_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'drop_stats_test_xact'::regclass::oid AS drop_stats_test_xact_oid" +== 123 +-- truncate_limit: 100 +CREATE TABLE drop_stats_test_subxact() +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE drop_stats_test_subxact ()" +== 124 +-- truncate_limit: 100 +INSERT INTO drop_stats_test_subxact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO drop_stats_test_subxact DEFAULT VALUES" +== 125 +-- truncate_limit: 100 +SELECT 'drop_stats_test_subxact'::regclass::oid AS drop_stats_test_subxact_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'drop_stats_test_subxact'::regclass::oid AS drop_stats_test_subxact_oid" +== 126 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 127 +-- truncate_limit: 100 +SELECT pg_stat_get_live_tuples(:drop_stats_test_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 128 +-- truncate_limit: 100 +DROP TABLE drop_stats_test +-- +TABLE: name="drop_stats_test" schema="" table="drop_stats_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE drop_stats_test" +== 129 +-- truncate_limit: 100 +SELECT pg_stat_get_live_tuples(:drop_stats_test_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 130 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 131 +-- truncate_limit: 100 +-- check that rollback protects against having stats dropped and that local +-- modifications don't pose a problem +SELECT pg_stat_get_live_tuples(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 146 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 132 +-- truncate_limit: 100 +SELECT pg_stat_get_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 133 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 134 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 135 +-- truncate_limit: 100 +INSERT INTO drop_stats_test_xact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO drop_stats_test_xact DEFAULT VALUES" +== 136 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 137 +-- truncate_limit: 100 +DROP TABLE drop_stats_test_xact +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE drop_stats_test_xact" +== 138 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 139 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 140 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 141 +-- truncate_limit: 100 +SELECT pg_stat_get_live_tuples(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 142 +-- truncate_limit: 100 +SELECT pg_stat_get_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 143 +-- truncate_limit: 100 +-- transactional drop +SELECT pg_stat_get_live_tuples(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 54 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 144 +-- truncate_limit: 100 +SELECT pg_stat_get_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 145 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 146 +-- truncate_limit: 100 +INSERT INTO drop_stats_test_xact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO drop_stats_test_xact DEFAULT VALUES" +== 147 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 148 +-- truncate_limit: 100 +DROP TABLE drop_stats_test_xact +-- +TABLE: name="drop_stats_test_xact" schema="" table="drop_stats_test_xact" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE drop_stats_test_xact" +== 149 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 150 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 151 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 152 +-- truncate_limit: 100 +SELECT pg_stat_get_live_tuples(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 153 +-- truncate_limit: 100 +SELECT pg_stat_get_tuples_inserted(:drop_stats_test_xact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 36 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 154 +-- truncate_limit: 100 +-- savepoint rollback (2 levels) +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 65 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 155 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 156 +-- truncate_limit: 100 +INSERT INTO drop_stats_test_subxact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO drop_stats_test_subxact DEFAULT VALUES" +== 157 +-- truncate_limit: 100 +SAVEPOINT sp1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp1" +== 158 +-- truncate_limit: 100 +INSERT INTO drop_stats_test_subxact DEFAULT VALUES +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO drop_stats_test_subxact DEFAULT VALUES" +== 159 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 160 +-- truncate_limit: 100 +SAVEPOINT sp2 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp2" +== 161 +-- truncate_limit: 100 +DROP TABLE drop_stats_test_subxact +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE drop_stats_test_subxact" +== 162 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT sp2 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT sp2" +== 163 +-- truncate_limit: 100 +SELECT pg_stat_get_xact_tuples_inserted(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 41 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 164 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 165 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 166 +-- truncate_limit: 100 +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 167 +-- truncate_limit: 100 +-- savepoint rolback (1 level) +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 168 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 169 +-- truncate_limit: 100 +SAVEPOINT sp1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp1" +== 170 +-- truncate_limit: 100 +DROP TABLE drop_stats_test_subxact +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE drop_stats_test_subxact" +== 171 +-- truncate_limit: 100 +SAVEPOINT sp2 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp2" +== 172 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT sp1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT sp1" +== 173 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 174 +-- truncate_limit: 100 +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 175 +-- truncate_limit: 100 +-- and now actually drop +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 57 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 176 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 177 +-- truncate_limit: 100 +SAVEPOINT sp1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp1" +== 178 +-- truncate_limit: 100 +DROP TABLE drop_stats_test_subxact +-- +TABLE: name="drop_stats_test_subxact" schema="" table="drop_stats_test_subxact" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE drop_stats_test_subxact" +== 179 +-- truncate_limit: 100 +SAVEPOINT sp2 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp2" +== 180 +-- truncate_limit: 100 +RELEASE SAVEPOINT sp1 +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE sp1" +== 181 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 182 +-- truncate_limit: 100 +SELECT pg_stat_get_live_tuples(:drop_stats_test_subxact_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 183 +-- truncate_limit: 100 +DROP TABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats_test4 +-- +TABLE: name="trunc_stats_test" schema="" table="trunc_stats_test" ctx=DDL +TABLE: name="trunc_stats_test1" schema="" table="trunc_stats_test1" ctx=DDL +TABLE: name="trunc_stats_test2" schema="" table="trunc_stats_test2" ctx=DDL +TABLE: name="trunc_stats_test3" schema="" table="trunc_stats_test3" ctx=DDL +TABLE: name="trunc_stats_test4" schema="" table="trunc_stats_test4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trunc_stats_test, trunc_stats_test1, trunc_stats_test2, trunc_stats_test3, trunc_stats..." +== 184 +-- truncate_limit: 100 +DROP TABLE prevstats +-- +TABLE: name="prevstats" schema="" table="prevstats" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE prevstats" +== 185 +-- truncate_limit: 100 +----- +-- Test that last_seq_scan, last_idx_scan are correctly maintained +|-- +-- Perform test using a temporary table. That way autovacuum etc won't +-- interfere. To be able to check that timestamps increase, we sleep for 100ms +-- between tests, assuming that there aren't systems with a coarser timestamp +-- granularity. +----- + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 186 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE test_last_scan(idx_col int primary key, noidx_col int) +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_last_scan (idx_col int PRIMARY KEY, noidx_col int)" +== 187 +-- truncate_limit: 100 +INSERT INTO test_last_scan(idx_col, noidx_col) VALUES(1, 1) +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_last_scan (idx_col, noidx_col) VALUES (1, 1)" +== 188 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 189 +-- truncate_limit: 100 +SELECT last_seq_scan, last_idx_scan FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +TRUNCATED: "SELECT last_seq_scan, last_idx_scan FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass" +== 190 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 191 +-- truncate_limit: 100 +SELECT pg_stat_reset_single_table_counters('test_last_scan'::regclass) +-- +FUNCTION: name="pg_stat_reset_single_table_counters" function="pg_stat_reset_single_table_counters" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_single_table_counters('test_last_scan'::regclass)" +== 192 +-- truncate_limit: 100 +SELECT seq_scan, idx_scan FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +TRUNCATED: "SELECT seq_scan, idx_scan FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass" +== 193 +-- truncate_limit: 100 +-- ensure we start out with exactly one index and sequential scan +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 194 +-- truncate_limit: 100 +SET LOCAL enable_seqscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO ON" +== 195 +-- truncate_limit: 100 +SET LOCAL enable_indexscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO ON" +== 196 +-- truncate_limit: 100 +SET LOCAL enable_bitmapscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_bitmapscan TO OFF" +== 197 +-- truncate_limit: 100 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE noidx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="noidx_col" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_last_scan WHERE noidx_col = 1" +== 198 +-- truncate_limit: 100 +SELECT count(*) FROM test_last_scan WHERE noidx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="noidx_col" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_last_scan WHERE noidx_col = 1" +== 199 +-- truncate_limit: 100 +SET LOCAL enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO OFF" +== 200 +-- truncate_limit: 100 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_last_scan WHERE idx_col = 1" +== 201 +-- truncate_limit: 100 +SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_last_scan WHERE idx_col = 1" +== 202 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 203 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 204 +-- truncate_limit: 100 +-- fetch timestamps from before the next test +SELECT last_seq_scan AS test_last_seq, last_idx_scan AS test_last_idx +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass" +== 205 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 206 +-- truncate_limit: 100 +-- assume a minimum timestamp granularity of 100ms + +-- cause one sequential scan +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 207 +-- truncate_limit: 100 +SET LOCAL enable_seqscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO ON" +== 208 +-- truncate_limit: 100 +SET LOCAL enable_indexscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO OFF" +== 209 +-- truncate_limit: 100 +SET LOCAL enable_bitmapscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_bitmapscan TO OFF" +== 210 +-- truncate_limit: 100 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE noidx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="noidx_col" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_last_scan WHERE noidx_col = 1" +== 211 +-- truncate_limit: 100 +SELECT count(*) FROM test_last_scan WHERE noidx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="noidx_col" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_last_scan WHERE noidx_col = 1" +== 212 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 213 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 214 +-- truncate_limit: 100 +-- check that just sequential scan stats were incremented +SELECT seq_scan, :'test_last_seq' < last_seq_scan AS seq_ok, idx_scan, :'test_last_idx' = last_idx_scan AS idx_ok +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +ERROR: syntax error at or near ":" +CURSORPOS: 76 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 215 +-- truncate_limit: 100 +-- fetch timestamps from before the next test +SELECT last_seq_scan AS test_last_seq, last_idx_scan AS test_last_idx +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass" +== 216 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 217 +-- truncate_limit: 100 +-- cause one index scan +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 218 +-- truncate_limit: 100 +SET LOCAL enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO OFF" +== 219 +-- truncate_limit: 100 +SET LOCAL enable_indexscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO ON" +== 220 +-- truncate_limit: 100 +SET LOCAL enable_bitmapscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_bitmapscan TO OFF" +== 221 +-- truncate_limit: 100 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_last_scan WHERE idx_col = 1" +== 222 +-- truncate_limit: 100 +SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_last_scan WHERE idx_col = 1" +== 223 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 224 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 225 +-- truncate_limit: 100 +-- check that just index scan stats were incremented +SELECT seq_scan, :'test_last_seq' = last_seq_scan AS seq_ok, idx_scan, :'test_last_idx' < last_idx_scan AS idx_ok +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +ERROR: syntax error at or near ":" +CURSORPOS: 71 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 226 +-- truncate_limit: 100 +-- fetch timestamps from before the next test +SELECT last_seq_scan AS test_last_seq, last_idx_scan AS test_last_idx +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass" +== 227 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 228 +-- truncate_limit: 100 +-- cause one bitmap index scan +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 229 +-- truncate_limit: 100 +SET LOCAL enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_seqscan TO OFF" +== 230 +-- truncate_limit: 100 +SET LOCAL enable_indexscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO OFF" +== 231 +-- truncate_limit: 100 +SET LOCAL enable_bitmapscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_bitmapscan TO ON" +== 232 +-- truncate_limit: 100 +EXPLAIN (COSTS off) SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_last_scan WHERE idx_col = 1" +== 233 +-- truncate_limit: 100 +SELECT count(*) FROM test_last_scan WHERE idx_col = 1 +-- +TABLE: name="test_last_scan" schema="" table="test_last_scan" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="idx_col" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_last_scan WHERE idx_col = 1" +== 234 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 235 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 236 +-- truncate_limit: 100 +-- check that just index scan stats were incremented +SELECT seq_scan, :'test_last_seq' = last_seq_scan AS seq_ok, idx_scan, :'test_last_idx' < last_idx_scan AS idx_ok +FROM pg_stat_all_tables WHERE relid = 'test_last_scan'::regclass +-- +ERROR: syntax error at or near ":" +CURSORPOS: 71 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 237 +-- truncate_limit: 100 +----- +-- Test reset of some stats for shared table +----- + +-- This updates the comment of the database currently in use in +-- pg_shdescription with a fake value, then sets it back to its +-- original value. +SELECT shobj_description(d.oid, 'pg_database') as description_before + FROM pg_database d WHERE datname = current_database() +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=Select +ALIAS: "d"="pg_database" +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FUNCTION: name="shobj_description" function="shobj_description" schema="" ctx=Call +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_database d WHERE datname = current_database()" +== 238 +-- truncate_limit: 100 +-- force some stats in pg_shdescription. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 239 +-- truncate_limit: 100 +SELECT current_database() as datname +-- +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT current_database() AS datname" +== 240 +-- truncate_limit: 100 +COMMENT ON DATABASE :"datname" IS 'This is a test comment' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 241 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 242 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 243 +-- truncate_limit: 100 +-- check that the stats are reset. +SELECT (n_tup_ins + n_tup_upd) > 0 AS has_data FROM pg_stat_all_tables + WHERE relid = 'pg_shdescription'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_all_tables WHERE relid = 'pg_shdescription'::regclass" +== 244 +-- truncate_limit: 100 +SELECT pg_stat_reset_single_table_counters('pg_shdescription'::regclass) +-- +FUNCTION: name="pg_stat_reset_single_table_counters" function="pg_stat_reset_single_table_counters" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_single_table_counters('pg_shdescription'::regclass)" +== 245 +-- truncate_limit: 100 +SELECT (n_tup_ins + n_tup_upd) > 0 AS has_data FROM pg_stat_all_tables + WHERE relid = 'pg_shdescription'::regclass +-- +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +FILTER: schema="" table="" column="relid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_all_tables WHERE relid = 'pg_shdescription'::regclass" +== 246 +-- truncate_limit: 100 +-- set back comment + COMMENT ON DATABASE :"datname" IS :'description_before' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 43 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 247 +-- truncate_limit: 100 +COMMENT ON DATABASE :"datname" IS NULL +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 248 +-- truncate_limit: 100 +----- +-- Test that various stats views are being properly populated +----- + +-- Test that sessions is incremented when a new session is started in pg_stat_database +SELECT sessions AS db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database()) +-- +TABLE: name="pg_stat_database" schema="" table="pg_stat_database" ctx=Select +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +TRUNCATED: "SELECT sessions AS db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT ...)" +== 249 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 250 +-- truncate_limit: 100 +SELECT sessions > :db_stat_sessions FROM pg_stat_database WHERE datname = (SELECT current_database()) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 251 +-- truncate_limit: 100 +-- Test pg_stat_checkpointer checkpointer-related stats, together with pg_stat_wal +SELECT num_requested AS rqst_ckpts_before FROM pg_stat_checkpointer +-- +TABLE: name="pg_stat_checkpointer" schema="" table="pg_stat_checkpointer" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT num_requested AS rqst_ckpts_before FROM pg_stat_checkpointer" +== 252 +-- truncate_limit: 100 +-- Test pg_stat_wal (and make a temp table so our temp schema exists) +SELECT wal_bytes AS wal_bytes_before FROM pg_stat_wal +-- +TABLE: name="pg_stat_wal" schema="" table="pg_stat_wal" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT wal_bytes AS wal_bytes_before FROM pg_stat_wal" +== 253 +-- truncate_limit: 100 +CREATE TEMP TABLE test_stats_temp AS SELECT 17 +-- +TABLE: name="test_stats_temp" schema="" table="test_stats_temp" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_stats_temp AS SELECT 17" +== 254 +-- truncate_limit: 100 +DROP TABLE test_stats_temp +-- +TABLE: name="test_stats_temp" schema="" table="test_stats_temp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_stats_temp" +== 255 +-- truncate_limit: 100 +-- Checkpoint twice: The checkpointer reports stats after reporting completion +-- of the checkpoint. But after a second checkpoint we'll see at least the +-- results of the first. +CHECKPOINT +-- +STMT: CheckPointStmt +TRUNCATED: "CHECKPOINT" +== 256 +-- truncate_limit: 100 +CHECKPOINT +-- +STMT: CheckPointStmt +TRUNCATED: "CHECKPOINT" +== 257 +-- truncate_limit: 100 +SELECT num_requested > :rqst_ckpts_before FROM pg_stat_checkpointer +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 258 +-- truncate_limit: 100 +SELECT wal_bytes > :wal_bytes_before FROM pg_stat_wal +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 259 +-- truncate_limit: 100 +-- Test pg_stat_get_backend_idset() and some allied functions. +-- In particular, verify that their notion of backend ID matches +-- our temp schema index. +SELECT (current_schemas(true))[1] = ('pg_temp_' || beid::text) AS match +FROM pg_stat_get_backend_idset() beid +WHERE pg_stat_get_backend_pid(beid) = pg_backend_pid() +-- +FUNCTION: name="pg_stat_get_backend_pid" function="pg_stat_get_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="current_schemas" function="current_schemas" schema="" ctx=Call +FUNCTION: name="pg_stat_get_backend_idset" function="pg_stat_get_backend_idset" schema="" ctx=Call +FUNCTION: name="pg_stat_get_backend_pid" function="pg_stat_get_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="beid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_get_backend_idset() beid WHERE ..." +== 260 +-- truncate_limit: 100 +----- +-- Test that resetting stats works for reset timestamp +----- + +-- Test that reset_slru with a specified SLRU works. +SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp'" +== 261 +-- truncate_limit: 100 +SELECT stats_reset AS slru_notify_reset_ts FROM pg_stat_slru WHERE name = 'notify' +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS slru_notify_reset_ts FROM pg_stat_slru WHERE name = 'notify'" +== 262 +-- truncate_limit: 100 +SELECT pg_stat_reset_slru('commit_timestamp') +-- +FUNCTION: name="pg_stat_reset_slru" function="pg_stat_reset_slru" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_slru('commit_timestamp')" +== 263 +-- truncate_limit: 100 +SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 264 +-- truncate_limit: 100 +SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp' +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS slru_commit_ts_reset_ts FROM pg_stat_slru WHERE name = 'commit_timestamp'" +== 265 +-- truncate_limit: 100 +-- Test that multiple SLRUs are reset when no specific SLRU provided to reset function +SELECT pg_stat_reset_slru() +-- +FUNCTION: name="pg_stat_reset_slru" function="pg_stat_reset_slru" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_slru()" +== 266 +-- truncate_limit: 100 +SELECT stats_reset > :'slru_commit_ts_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'commit_timestamp' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 267 +-- truncate_limit: 100 +SELECT stats_reset > :'slru_notify_reset_ts'::timestamptz FROM pg_stat_slru WHERE name = 'notify' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 268 +-- truncate_limit: 100 +-- Test that reset_shared with archiver specified as the stats type works +SELECT stats_reset AS archiver_reset_ts FROM pg_stat_archiver +-- +TABLE: name="pg_stat_archiver" schema="" table="pg_stat_archiver" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS archiver_reset_ts FROM pg_stat_archiver" +== 269 +-- truncate_limit: 100 +SELECT pg_stat_reset_shared('archiver') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_shared('archiver')" +== 270 +-- truncate_limit: 100 +SELECT stats_reset > :'archiver_reset_ts'::timestamptz FROM pg_stat_archiver +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 271 +-- truncate_limit: 100 +-- Test that reset_shared with bgwriter specified as the stats type works +SELECT stats_reset AS bgwriter_reset_ts FROM pg_stat_bgwriter +-- +TABLE: name="pg_stat_bgwriter" schema="" table="pg_stat_bgwriter" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS bgwriter_reset_ts FROM pg_stat_bgwriter" +== 272 +-- truncate_limit: 100 +SELECT pg_stat_reset_shared('bgwriter') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_shared('bgwriter')" +== 273 +-- truncate_limit: 100 +SELECT stats_reset > :'bgwriter_reset_ts'::timestamptz FROM pg_stat_bgwriter +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 274 +-- truncate_limit: 100 +-- Test that reset_shared with checkpointer specified as the stats type works +SELECT stats_reset AS checkpointer_reset_ts FROM pg_stat_checkpointer +-- +TABLE: name="pg_stat_checkpointer" schema="" table="pg_stat_checkpointer" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS checkpointer_reset_ts FROM pg_stat_checkpointer" +== 275 +-- truncate_limit: 100 +SELECT pg_stat_reset_shared('checkpointer') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_shared('checkpointer')" +== 276 +-- truncate_limit: 100 +SELECT stats_reset > :'checkpointer_reset_ts'::timestamptz FROM pg_stat_checkpointer +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 277 +-- truncate_limit: 100 +-- Test that reset_shared with recovery_prefetch specified as the stats type works +SELECT stats_reset AS recovery_prefetch_reset_ts FROM pg_stat_recovery_prefetch +-- +TABLE: name="pg_stat_recovery_prefetch" schema="" table="pg_stat_recovery_prefetch" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS recovery_prefetch_reset_ts FROM pg_stat_recovery_prefetch" +== 278 +-- truncate_limit: 100 +SELECT pg_stat_reset_shared('recovery_prefetch') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_shared('recovery_prefetch')" +== 279 +-- truncate_limit: 100 +SELECT stats_reset > :'recovery_prefetch_reset_ts'::timestamptz FROM pg_stat_recovery_prefetch +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 280 +-- truncate_limit: 100 +-- Test that reset_shared with slru specified as the stats type works +SELECT max(stats_reset) AS slru_reset_ts FROM pg_stat_slru +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(stats_reset) AS slru_reset_ts FROM pg_stat_slru" +== 281 +-- truncate_limit: 100 +SELECT pg_stat_reset_shared('slru') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_shared('slru')" +== 282 +-- truncate_limit: 100 +SELECT max(stats_reset) > :'slru_reset_ts'::timestamptz FROM pg_stat_slru +-- +ERROR: syntax error at or near ":" +CURSORPOS: 27 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 283 +-- truncate_limit: 100 +-- Test that reset_shared with wal specified as the stats type works +SELECT stats_reset AS wal_reset_ts FROM pg_stat_wal +-- +TABLE: name="pg_stat_wal" schema="" table="pg_stat_wal" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS wal_reset_ts FROM pg_stat_wal" +== 284 +-- truncate_limit: 100 +SELECT pg_stat_reset_shared('wal') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_shared('wal')" +== 285 +-- truncate_limit: 100 +SELECT stats_reset > :'wal_reset_ts'::timestamptz FROM pg_stat_wal +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 286 +-- truncate_limit: 100 +-- Test error case for reset_shared with unknown stats type +SELECT pg_stat_reset_shared('unknown') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_shared('unknown')" +== 287 +-- truncate_limit: 100 +-- Test that reset works for pg_stat_database + +-- Since pg_stat_database stats_reset starts out as NULL, reset it once first so we have something to compare it to +SELECT pg_stat_reset() +-- +FUNCTION: name="pg_stat_reset" function="pg_stat_reset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset()" +== 288 +-- truncate_limit: 100 +SELECT stats_reset AS db_reset_ts FROM pg_stat_database WHERE datname = (SELECT current_database()) +-- +TABLE: name="pg_stat_database" schema="" table="pg_stat_database" ctx=Select +FUNCTION: name="current_database" function="current_database" schema="" ctx=Call +FILTER: schema="" table="" column="datname" +STMT: SelectStmt +TRUNCATED: "SELECT stats_reset AS db_reset_ts FROM pg_stat_database WHERE datname = (SELECT current_database())" +== 289 +-- truncate_limit: 100 +SELECT pg_stat_reset() +-- +FUNCTION: name="pg_stat_reset" function="pg_stat_reset" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset()" +== 290 +-- truncate_limit: 100 +SELECT stats_reset > :'db_reset_ts'::timestamptz FROM pg_stat_database WHERE datname = (SELECT current_database()) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 291 +-- truncate_limit: 100 +---- +-- pg_stat_get_snapshot_timestamp behavior +---- +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 292 +-- truncate_limit: 100 +SET LOCAL stats_fetch_consistency = snapshot +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL stats_fetch_consistency TO snapshot" +== 293 +-- truncate_limit: 100 +-- no snapshot yet, return NULL +SELECT pg_stat_get_snapshot_timestamp() +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_snapshot_timestamp()" +== 294 +-- truncate_limit: 100 +-- any attempt at accessing stats will build snapshot +SELECT pg_stat_get_function_calls(0) +-- +FUNCTION: name="pg_stat_get_function_calls" function="pg_stat_get_function_calls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_function_calls(0)" +== 295 +-- truncate_limit: 100 +SELECT pg_stat_get_snapshot_timestamp() >= NOW() +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_snapshot_timestamp() >= now()" +== 296 +-- truncate_limit: 100 +-- shows NULL again after clearing +SELECT pg_stat_clear_snapshot() +-- +FUNCTION: name="pg_stat_clear_snapshot" function="pg_stat_clear_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_clear_snapshot()" +== 297 +-- truncate_limit: 100 +SELECT pg_stat_get_snapshot_timestamp() +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_snapshot_timestamp()" +== 298 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 299 +-- truncate_limit: 100 +---- +-- Changing stats_fetch_consistency in a transaction. +---- +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 300 +-- truncate_limit: 100 +-- Stats filled under the cache mode +SET LOCAL stats_fetch_consistency = cache +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL stats_fetch_consistency TO cache" +== 301 +-- truncate_limit: 100 +SELECT pg_stat_get_function_calls(0) +-- +FUNCTION: name="pg_stat_get_function_calls" function="pg_stat_get_function_calls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_function_calls(0)" +== 302 +-- truncate_limit: 100 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok" +== 303 +-- truncate_limit: 100 +-- Success in accessing pre-existing snapshot data. +SET LOCAL stats_fetch_consistency = snapshot +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL stats_fetch_consistency TO snapshot" +== 304 +-- truncate_limit: 100 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok" +== 305 +-- truncate_limit: 100 +SELECT pg_stat_get_function_calls(0) +-- +FUNCTION: name="pg_stat_get_function_calls" function="pg_stat_get_function_calls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_function_calls(0)" +== 306 +-- truncate_limit: 100 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok" +== 307 +-- truncate_limit: 100 +-- Snapshot cleared. +SET LOCAL stats_fetch_consistency = none +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL stats_fetch_consistency TO \"none\"" +== 308 +-- truncate_limit: 100 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok" +== 309 +-- truncate_limit: 100 +SELECT pg_stat_get_function_calls(0) +-- +FUNCTION: name="pg_stat_get_function_calls" function="pg_stat_get_function_calls" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_function_calls(0)" +== 310 +-- truncate_limit: 100 +SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok +-- +FUNCTION: name="pg_stat_get_snapshot_timestamp" function="pg_stat_get_snapshot_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_snapshot_timestamp() IS NOT NULL AS snapshot_ok" +== 311 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 312 +-- truncate_limit: 100 +---- +-- pg_stat_have_stats behavior +---- +-- fixed-numbered stats exist +SELECT pg_stat_have_stats('bgwriter', 0, 0) +-- +FUNCTION: name="pg_stat_have_stats" function="pg_stat_have_stats" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_have_stats('bgwriter', 0, 0)" +== 313 +-- truncate_limit: 100 +-- unknown stats kinds error out +SELECT pg_stat_have_stats('zaphod', 0, 0) +-- +FUNCTION: name="pg_stat_have_stats" function="pg_stat_have_stats" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_have_stats('zaphod', 0, 0)" +== 314 +-- truncate_limit: 100 +-- db stats have objoid 0 +SELECT pg_stat_have_stats('database', :dboid, 1) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 65 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 315 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('database', :dboid, 0) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 316 +-- truncate_limit: 100 +-- pg_stat_have_stats returns true for committed index creation +CREATE table stats_test_tab1 as select generate_series(1,10) a +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE stats_test_tab1 AS SELECT generate_series(1, 10) AS a" +== 317 +-- truncate_limit: 100 +CREATE index stats_test_idx1 on stats_test_tab1(a) +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX stats_test_idx1 ON stats_test_tab1 USING btree (a)" +== 318 +-- truncate_limit: 100 +SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid" +== 319 +-- truncate_limit: 100 +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 320 +-- truncate_limit: 100 +select a from stats_test_tab1 where a = 3 +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM stats_test_tab1 WHERE a = 3" +== 321 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 322 +-- truncate_limit: 100 +-- pg_stat_have_stats returns false for dropped index with stats +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 104 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 323 +-- truncate_limit: 100 +DROP index stats_test_idx1 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX stats_test_idx1" +== 324 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 325 +-- truncate_limit: 100 +-- pg_stat_have_stats returns false for rolled back index creation +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 326 +-- truncate_limit: 100 +CREATE index stats_test_idx1 on stats_test_tab1(a) +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX stats_test_idx1 ON stats_test_tab1 USING btree (a)" +== 327 +-- truncate_limit: 100 +SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid" +== 328 +-- truncate_limit: 100 +select a from stats_test_tab1 where a = 3 +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM stats_test_tab1 WHERE a = 3" +== 329 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 330 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 331 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 332 +-- truncate_limit: 100 +-- pg_stat_have_stats returns true for reindex CONCURRENTLY +CREATE index stats_test_idx1 on stats_test_tab1(a) +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX stats_test_idx1 ON stats_test_tab1 USING btree (a)" +== 333 +-- truncate_limit: 100 +SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid" +== 334 +-- truncate_limit: 100 +select a from stats_test_tab1 where a = 3 +-- +TABLE: name="stats_test_tab1" schema="" table="stats_test_tab1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM stats_test_tab1 WHERE a = 3" +== 335 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 336 +-- truncate_limit: 100 +REINDEX index CONCURRENTLY stats_test_idx1 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (CONCURRENTLY) INDEX stats_test_idx1" +== 337 +-- truncate_limit: 100 +-- false for previous oid +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 65 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 338 +-- truncate_limit: 100 +-- true for new oid +SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'stats_test_idx1'::regclass::oid AS stats_test_idx1_oid" +== 339 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 340 +-- truncate_limit: 100 +-- pg_stat_have_stats returns true for a rolled back drop index with stats +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 341 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 342 +-- truncate_limit: 100 +DROP index stats_test_idx1 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX stats_test_idx1" +== 343 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 344 +-- truncate_limit: 100 +SELECT pg_stat_have_stats('relation', :dboid, :stats_test_idx1_oid) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 39 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 345 +-- truncate_limit: 100 +-- put enable_seqscan back to on +SET enable_seqscan TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 346 +-- truncate_limit: 100 +-- ensure that stats accessors handle NULL input correctly +SELECT pg_stat_get_replication_slot(NULL) +-- +FUNCTION: name="pg_stat_get_replication_slot" function="pg_stat_get_replication_slot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_replication_slot(NULL)" +== 347 +-- truncate_limit: 100 +SELECT pg_stat_get_subscription_stats(NULL) +-- +FUNCTION: name="pg_stat_get_subscription_stats" function="pg_stat_get_subscription_stats" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_subscription_stats(NULL)" +== 348 +-- truncate_limit: 100 +-- Test that the following operations are tracked in pg_stat_io: +-- - reads of target blocks into shared buffers +-- - writes of shared buffers to permanent storage +-- - extends of relations using shared buffers +-- - fsyncs done to ensure the durability of data dirtying shared buffers +-- - shared buffer hits + +-- There is no test for blocks evicted from shared buffers, because we cannot +-- be sure of the state of shared buffers at the point the test is run. + +-- Create a regular table and insert some data to generate IOCONTEXT_NORMAL +-- extends. +SELECT sum(extends) AS io_sum_shared_before_extends + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io WHERE context = 'normal' AND object = 'relation'" +== 349 +-- truncate_limit: 100 +SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs + FROM pg_stat_io + WHERE object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs FROM pg_stat_io WHERE object = 'relation'" +== 350 +-- truncate_limit: 100 +CREATE TABLE test_io_shared(a int) +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_io_shared (a int)" +== 351 +-- truncate_limit: 100 +INSERT INTO test_io_shared SELECT i FROM generate_series(1,100)i +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_io_shared SELECT i FROM generate_series(1, 100) i" +== 352 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 353 +-- truncate_limit: 100 +SELECT sum(extends) AS io_sum_shared_after_extends + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io WHERE context = 'normal' AND object = 'relation'" +== 354 +-- truncate_limit: 100 +SELECT :io_sum_shared_after_extends > :io_sum_shared_before_extends +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 355 +-- truncate_limit: 100 +-- After a checkpoint, there should be some additional IOCONTEXT_NORMAL writes +-- and fsyncs. +-- See comment above for rationale for two explicit CHECKPOINTs. +CHECKPOINT +-- +STMT: CheckPointStmt +TRUNCATED: "CHECKPOINT" +== 356 +-- truncate_limit: 100 +CHECKPOINT +-- +STMT: CheckPointStmt +TRUNCATED: "CHECKPOINT" +== 357 +-- truncate_limit: 100 +SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs + FROM pg_stat_io + WHERE object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs FROM pg_stat_io WHERE object = 'relation'" +== 358 +-- truncate_limit: 100 +SELECT :io_sum_shared_after_writes > :io_sum_shared_before_writes +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 359 +-- truncate_limit: 100 +SELECT current_setting('fsync') = 'off' + OR :io_sum_shared_after_fsyncs > :io_sum_shared_before_fsyncs +-- +ERROR: syntax error at or near ":" +CURSORPOS: 46 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 360 +-- truncate_limit: 100 +-- Change the tablespace so that the table is rewritten directly, then SELECT +-- from it to cause it to be read back into shared buffers. +SELECT sum(reads) AS io_sum_shared_before_reads + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT sum(reads) AS io_sum_shared_before_reads FROM pg_stat_io WHERE ..." +== 361 +-- truncate_limit: 100 +-- Do this in a transaction to prevent spurious failures due to concurrent accesses to our newly +-- rewritten table, e.g. by autovacuum. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 362 +-- truncate_limit: 100 +ALTER TABLE test_io_shared SET TABLESPACE regress_tblspace +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_io_shared SET TABLESPACE regress_tblspace" +== 363 +-- truncate_limit: 100 +-- SELECT from the table so that the data is read into shared buffers and +-- context 'normal', object 'relation' reads are counted. +SELECT COUNT(*) FROM test_io_shared +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_io_shared" +== 364 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 365 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 366 +-- truncate_limit: 100 +SELECT sum(reads) AS io_sum_shared_after_reads + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT sum(reads) AS io_sum_shared_after_reads FROM pg_stat_io WHERE ..." +== 367 +-- truncate_limit: 100 +SELECT :io_sum_shared_after_reads > :io_sum_shared_before_reads +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 368 +-- truncate_limit: 100 +SELECT sum(hits) AS io_sum_shared_before_hits + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT sum(hits) AS io_sum_shared_before_hits FROM pg_stat_io WHERE ..." +== 369 +-- truncate_limit: 100 +-- Select from the table again to count hits. +-- Ensure we generate hits by forcing a nested loop self-join with no +-- materialize node. The outer side's buffer will stay pinned, preventing its +-- eviction, while we loop through the inner side and generate hits. +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 370 +-- truncate_limit: 100 +SET LOCAL enable_nestloop TO on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_nestloop TO ON" +== 371 +-- truncate_limit: 100 +SET LOCAL enable_mergejoin TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_mergejoin TO OFF" +== 372 +-- truncate_limit: 100 +SET LOCAL enable_hashjoin TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_hashjoin TO OFF" +== 373 +-- truncate_limit: 100 +SET LOCAL enable_material TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_material TO OFF" +== 374 +-- truncate_limit: 100 +-- ensure plan stays as we expect it to +EXPLAIN (COSTS OFF) SELECT COUNT(*) FROM test_io_shared t1 INNER JOIN test_io_shared t2 USING (a) +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +ALIAS: "t1"="test_io_shared" +ALIAS: "t2"="test_io_shared" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_io_shared t1 JOIN test_io_shared t2 USING (a)" +== 375 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_io_shared t1 INNER JOIN test_io_shared t2 USING (a) +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=Select +ALIAS: "t1"="test_io_shared" +ALIAS: "t2"="test_io_shared" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_io_shared t1 JOIN test_io_shared t2 USING (a)" +== 376 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 377 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 378 +-- truncate_limit: 100 +SELECT sum(hits) AS io_sum_shared_after_hits + FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT sum(hits) AS io_sum_shared_after_hits FROM pg_stat_io WHERE ..." +== 379 +-- truncate_limit: 100 +SELECT :io_sum_shared_after_hits > :io_sum_shared_before_hits +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 380 +-- truncate_limit: 100 +DROP TABLE test_io_shared +-- +TABLE: name="test_io_shared" schema="" table="test_io_shared" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE test_io_shared" +== 381 +-- truncate_limit: 100 +-- Test that the follow IOCONTEXT_LOCAL IOOps are tracked in pg_stat_io: +-- - eviction of local buffers in order to reuse them +-- - reads of temporary table blocks into local buffers +-- - writes of local buffers to permanent storage +-- - extends of temporary tables + +-- Set temp_buffers to its minimum so that we can trigger writes with fewer +-- inserted tuples. Do so in a new session in case temporary tables have been +-- accessed by previous tests in this session. +SET temp_buffers TO 100 +-- +STMT: VariableSetStmt +TRUNCATED: "SET temp_buffers TO 100" +== 382 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE test_io_local(a int, b TEXT) +-- +TABLE: name="test_io_local" schema="" table="test_io_local" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_io_local (a int, b text)" +== 383 +-- truncate_limit: 100 +SELECT sum(extends) AS extends, sum(evictions) AS evictions, sum(writes) AS writes + FROM pg_stat_io + WHERE context = 'normal' AND object = 'temp relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation'" +== 384 +-- truncate_limit: 100 +-- Insert tuples into the temporary table, generating extends in the stats. +-- Insert enough values that we need to reuse and write out dirty local +-- buffers, generating evictions and writes. +INSERT INTO test_io_local SELECT generate_series(1, 5000) as id, repeat('a', 200) +-- +TABLE: name="test_io_local" schema="" table="test_io_local" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_io_local SELECT generate_series(1, 5000) AS id, repeat('a', 200)" +== 385 +-- truncate_limit: 100 +-- Ensure the table is large enough to exceed our temp_buffers setting. +SELECT pg_relation_size('test_io_local') / current_setting('block_size')::int8 > 100 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (pg_relation_size('test_io_local') / current_setting('block_size')::int8) > 100" +== 386 +-- truncate_limit: 100 +SELECT sum(reads) AS io_sum_local_before_reads + FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT sum(reads) AS io_sum_local_before_reads FROM pg_stat_io WHERE ..." +== 387 +-- truncate_limit: 100 +-- Read in evicted buffers, generating reads. +SELECT COUNT(*) FROM test_io_local +-- +TABLE: name="test_io_local" schema="" table="test_io_local" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_io_local" +== 388 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 389 +-- truncate_limit: 100 +SELECT sum(evictions) AS evictions, + sum(reads) AS reads, + sum(writes) AS writes, + sum(extends) AS extends + FROM pg_stat_io + WHERE context = 'normal' AND object = 'temp relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation'" +== 390 +-- truncate_limit: 100 +SELECT :io_sum_local_after_evictions > :io_sum_local_before_evictions, + :io_sum_local_after_reads > :io_sum_local_before_reads, + :io_sum_local_after_writes > :io_sum_local_before_writes, + :io_sum_local_after_extends > :io_sum_local_before_extends +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 391 +-- truncate_limit: 100 +-- Change the tablespaces so that the temporary table is rewritten to other +-- local buffers, exercising a different codepath than standard local buffer +-- writes. +ALTER TABLE test_io_local SET TABLESPACE regress_tblspace +-- +TABLE: name="test_io_local" schema="" table="test_io_local" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_io_local SET TABLESPACE regress_tblspace" +== 392 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 393 +-- truncate_limit: 100 +SELECT sum(writes) AS io_sum_local_new_tblspc_writes + FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +FILTER: schema="" table="" column="object" +STMT: SelectStmt +TRUNCATED: "SELECT sum(writes) AS io_sum_local_new_tblspc_writes FROM pg_stat_io WHERE ..." +== 394 +-- truncate_limit: 100 +SELECT :io_sum_local_new_tblspc_writes > :io_sum_local_after_writes +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 395 +-- truncate_limit: 100 +RESET temp_buffers +-- +STMT: VariableSetStmt +TRUNCATED: "RESET temp_buffers" +== 396 +-- truncate_limit: 100 +-- Test that reuse of strategy buffers and reads of blocks into these reused +-- buffers while VACUUMing are tracked in pg_stat_io. If there is sufficient +-- demand for shared buffers from concurrent queries, some buffers may be +-- pinned by other backends before they can be reused. In such cases, the +-- backend will evict a buffer from outside the ring and add it to the +-- ring. This is considered an eviction and not a reuse. + +-- Set wal_skip_threshold smaller than the expected size of +-- test_io_vac_strategy so that, even if wal_level is minimal, VACUUM FULL will +-- fsync the newly rewritten test_io_vac_strategy instead of writing it to WAL. +-- Writing it to WAL will result in the newly written relation pages being in +-- shared buffers -- preventing us from testing BAS_VACUUM BufferAccessStrategy +-- reads. +SET wal_skip_threshold = '1 kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET wal_skip_threshold TO \"1 kB\"" +== 397 +-- truncate_limit: 100 +SELECT sum(reuses) AS reuses, sum(reads) AS reads, sum(evictions) AS evictions + FROM pg_stat_io WHERE context = 'vacuum' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io WHERE context = 'vacuum'" +== 398 +-- truncate_limit: 100 +CREATE TABLE test_io_vac_strategy(a int, b int) WITH (autovacuum_enabled = 'false') +-- +TABLE: name="test_io_vac_strategy" schema="" table="test_io_vac_strategy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_io_vac_strategy (a int, b int) WITH (autovacuum_enabled=false)" +== 399 +-- truncate_limit: 100 +INSERT INTO test_io_vac_strategy SELECT i, i from generate_series(1, 4500)i +-- +TABLE: name="test_io_vac_strategy" schema="" table="test_io_vac_strategy" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_io_vac_strategy SELECT i, i FROM generate_series(1, 4500) i" +== 400 +-- truncate_limit: 100 +-- Ensure that the next VACUUM will need to perform IO by rewriting the table +-- first with VACUUM (FULL). +VACUUM (FULL) test_io_vac_strategy +-- +TABLE: name="test_io_vac_strategy" schema="" table="test_io_vac_strategy" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) test_io_vac_strategy" +== 401 +-- truncate_limit: 100 +-- Use the minimum BUFFER_USAGE_LIMIT to cause reuses or evictions with the +-- smallest table possible. +VACUUM (PARALLEL 0, BUFFER_USAGE_LIMIT 128) test_io_vac_strategy +-- +TABLE: name="test_io_vac_strategy" schema="" table="test_io_vac_strategy" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 0, BUFFER_USAGE_LIMIT 128) test_io_vac_strategy" +== 402 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 403 +-- truncate_limit: 100 +SELECT sum(reuses) AS reuses, sum(reads) AS reads, sum(evictions) AS evictions + FROM pg_stat_io WHERE context = 'vacuum' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io WHERE context = 'vacuum'" +== 404 +-- truncate_limit: 100 +SELECT :io_sum_vac_strategy_after_reads > :io_sum_vac_strategy_before_reads +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 405 +-- truncate_limit: 100 +SELECT (:io_sum_vac_strategy_after_reuses + :io_sum_vac_strategy_after_evictions) > + (:io_sum_vac_strategy_before_reuses + :io_sum_vac_strategy_before_evictions) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 406 +-- truncate_limit: 100 +RESET wal_skip_threshold +-- +STMT: VariableSetStmt +TRUNCATED: "RESET wal_skip_threshold" +== 407 +-- truncate_limit: 100 +-- Test that extends done by a CTAS, which uses a BAS_BULKWRITE +-- BufferAccessStrategy, are tracked in pg_stat_io. +SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_before + FROM pg_stat_io WHERE context = 'bulkwrite' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io WHERE context = 'bulkwrite'" +== 408 +-- truncate_limit: 100 +CREATE TABLE test_io_bulkwrite_strategy AS SELECT i FROM generate_series(1,100)i +-- +TABLE: name="test_io_bulkwrite_strategy" schema="" table="test_io_bulkwrite_strategy" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test_io_bulkwrite_strategy AS SELECT i FROM generate_series(1, 100) i" +== 409 +-- truncate_limit: 100 +SELECT pg_stat_force_next_flush() +-- +FUNCTION: name="pg_stat_force_next_flush" function="pg_stat_force_next_flush" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_force_next_flush()" +== 410 +-- truncate_limit: 100 +SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_after + FROM pg_stat_io WHERE context = 'bulkwrite' +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="context" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io WHERE context = 'bulkwrite'" +== 411 +-- truncate_limit: 100 +SELECT :io_sum_bulkwrite_strategy_extends_after > :io_sum_bulkwrite_strategy_extends_before +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 412 +-- truncate_limit: 100 +-- Test IO stats reset +SELECT pg_stat_have_stats('io', 0, 0) +-- +FUNCTION: name="pg_stat_have_stats" function="pg_stat_have_stats" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_have_stats('io', 0, 0)" +== 413 +-- truncate_limit: 100 +SELECT sum(evictions) + sum(reuses) + sum(extends) + sum(fsyncs) + sum(reads) + sum(writes) + sum(writebacks) + sum(hits) AS io_stats_pre_reset + FROM pg_stat_io +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io" +== 414 +-- truncate_limit: 100 +SELECT pg_stat_reset_shared('io') +-- +FUNCTION: name="pg_stat_reset_shared" function="pg_stat_reset_shared" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_shared('io')" +== 415 +-- truncate_limit: 100 +SELECT sum(evictions) + sum(reuses) + sum(extends) + sum(fsyncs) + sum(reads) + sum(writes) + sum(writebacks) + sum(hits) AS io_stats_post_reset + FROM pg_stat_io +-- +TABLE: name="pg_stat_io" schema="" table="pg_stat_io" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_io" +== 416 +-- truncate_limit: 100 +SELECT :io_stats_post_reset < :io_stats_pre_reset +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 417 +-- truncate_limit: 100 +-- test BRIN index doesn't block HOT update +CREATE TABLE brin_hot ( + id integer PRIMARY KEY, + val integer NOT NULL +) WITH (autovacuum_enabled = off, fillfactor = 70) +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_hot (id int PRIMARY KEY, val int NOT NULL) WITH (autovacuum_enabled=off, fillfa..." +== 418 +-- truncate_limit: 100 +INSERT INTO brin_hot SELECT *, 0 FROM generate_series(1, 235) +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_hot SELECT *, 0 FROM generate_series(1, 235)" +== 419 +-- truncate_limit: 100 +CREATE INDEX val_brin ON brin_hot using brin(val) +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX val_brin ON brin_hot USING brin (val)" +== 420 +-- truncate_limit: 100 +CREATE FUNCTION wait_for_hot_stats() RETURNS void AS $$ +DECLARE + start_time timestamptz := clock_timestamp(); + updated bool; +BEGIN + -- we don't want to wait forever; loop will exit after 30 seconds + FOR i IN 1 .. 300 LOOP + SELECT (pg_stat_get_tuples_hot_updated('brin_hot'::regclass::oid) > 0) INTO updated; + EXIT WHEN updated; + + -- wait a little + PERFORM pg_sleep_for('100 milliseconds'); + -- reset stats snapshot so we can test again + PERFORM pg_stat_clear_snapshot(); + END LOOP; + -- report time waited in postmaster log (where it won't change test output) + RAISE log 'wait_for_hot_stats delayed % seconds', + EXTRACT(epoch FROM clock_timestamp() - start_time); +END +$$ LANGUAGE plpgsql +-- +FUNCTION: name="wait_for_hot_stats" function="wait_for_hot_stats" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION wait_for_hot_stats() RETURNS void AS $$\nDECLARE\n start_time timestamptz := clock..." +== 421 +-- truncate_limit: 100 +UPDATE brin_hot SET val = -3 WHERE id = 42 +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brin_hot SET val = -3 WHERE id = 42" +== 422 +-- truncate_limit: 100 +-- We can't just call wait_for_hot_stats() at this point, because we only +-- transmit stats when the session goes idle, and we probably didn't +-- transmit the last couple of counts yet thanks to the rate-limiting logic +-- in pgstat_report_stat(). But instead of waiting for the rate limiter's +-- timeout to elapse, let's just start a new session. The old one will +-- then send its stats before dying. + +SELECT wait_for_hot_stats() +-- +FUNCTION: name="wait_for_hot_stats" function="wait_for_hot_stats" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT wait_for_hot_stats()" +== 423 +-- truncate_limit: 100 +SELECT pg_stat_get_tuples_hot_updated('brin_hot'::regclass::oid) +-- +FUNCTION: name="pg_stat_get_tuples_hot_updated" function="pg_stat_get_tuples_hot_updated" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_get_tuples_hot_updated('brin_hot'::regclass::oid)" +== 424 +-- truncate_limit: 100 +DROP TABLE brin_hot +-- +TABLE: name="brin_hot" schema="" table="brin_hot" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_hot" +== 425 +-- truncate_limit: 100 +DROP FUNCTION wait_for_hot_stats() +-- +FUNCTION: name="wait_for_hot_stats" function="wait_for_hot_stats" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION wait_for_hot_stats()" +== 426 +-- truncate_limit: 100 +-- Test handling of index predicates - updating attributes in precicates +-- should not block HOT when summarizing indexes are involved. We update +-- a row that was not indexed due to the index predicate, and becomes +-- indexable - the HOT-updated tuple is forwarded to the BRIN index. +CREATE TABLE brin_hot_2 (a int, b int) +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_hot_2 (a int, b int)" +== 427 +-- truncate_limit: 100 +INSERT INTO brin_hot_2 VALUES (1, 100) +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_hot_2 VALUES (1, 100)" +== 428 +-- truncate_limit: 100 +CREATE INDEX ON brin_hot_2 USING brin (b) WHERE a = 2 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_hot_2 USING brin (b) WHERE a = 2" +== 429 +-- truncate_limit: 100 +UPDATE brin_hot_2 SET a = 2 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brin_hot_2 SET a = 2" +== 430 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_2 WHERE a = 2 AND b = 100 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_2 WHERE a = 2 AND b = 100" +== 431 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_hot_2 WHERE a = 2 AND b = 100 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_hot_2 WHERE a = 2 AND b = 100" +== 432 +-- truncate_limit: 100 +SET enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 433 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_2 WHERE a = 2 AND b = 100 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_2 WHERE a = 2 AND b = 100" +== 434 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_hot_2 WHERE a = 2 AND b = 100 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_hot_2 WHERE a = 2 AND b = 100" +== 435 +-- truncate_limit: 100 +DROP TABLE brin_hot_2 +-- +TABLE: name="brin_hot_2" schema="" table="brin_hot_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_hot_2" +== 436 +-- truncate_limit: 100 +-- Test that updates to indexed columns are still propagated to the +-- BRIN column. +-- https://postgr.es/m/05ebcb44-f383-86e3-4f31-0a97a55634cf@enterprisedb.com +CREATE TABLE brin_hot_3 (a int, filler text) WITH (fillfactor = 10) +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE brin_hot_3 (a int, filler text) WITH (fillfactor=10)" +== 437 +-- truncate_limit: 100 +INSERT INTO brin_hot_3 SELECT 1, repeat(' ', 500) FROM generate_series(1, 20) +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO brin_hot_3 SELECT 1, repeat(' ', 500) FROM generate_series(1, 20)" +== 438 +-- truncate_limit: 100 +CREATE INDEX ON brin_hot_3 USING brin (a) WITH (pages_per_range = 1) +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON brin_hot_3 USING brin (a) WITH (pages_per_range=1)" +== 439 +-- truncate_limit: 100 +UPDATE brin_hot_3 SET a = 2 +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE brin_hot_3 SET a = 2" +== 440 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_3 WHERE a = 2 +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM brin_hot_3 WHERE a = 2" +== 441 +-- truncate_limit: 100 +SELECT COUNT(*) FROM brin_hot_3 WHERE a = 2 +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM brin_hot_3 WHERE a = 2" +== 442 +-- truncate_limit: 100 +DROP TABLE brin_hot_3 +-- +TABLE: name="brin_hot_3" schema="" table="brin_hot_3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE brin_hot_3" +== 443 +-- truncate_limit: 100 +SET enable_seqscan = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 444 +-- truncate_limit: 100 +-- Test that estimation of relation size works with tuples wider than the +-- relation fillfactor. We create a table with wide inline attributes and +-- low fillfactor, insert rows and then see how many rows EXPLAIN shows +-- before running analyze. We disable autovacuum so that it does not +-- interfere with the test. +CREATE TABLE table_fillfactor ( + n char(1000) +) with (fillfactor=10, autovacuum_enabled=off) +-- +TABLE: name="table_fillfactor" schema="" table="table_fillfactor" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE table_fillfactor (n char(1000)) WITH (fillfactor=10, autovacuum_enabled=off)" +== 445 +-- truncate_limit: 100 +INSERT INTO table_fillfactor +SELECT 'x' FROM generate_series(1,1000) +-- +TABLE: name="table_fillfactor" schema="" table="table_fillfactor" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO table_fillfactor SELECT 'x' FROM generate_series(1, 1000)" +== 446 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM table_fillfactor') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM table_fillfactor')" +== 447 +-- truncate_limit: 100 +DROP TABLE table_fillfactor +-- +TABLE: name="table_fillfactor" schema="" table="table_fillfactor" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE table_fillfactor" diff --git a/parser/testdata/summary_truncate/postgres_regress/stats_ext.metadata.json b/parser/testdata/summary_truncate/postgres_regress/stats_ext.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/stats_ext.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/stats_ext.test b/parser/testdata/summary_truncate/postgres_regress/stats_ext.test new file mode 100644 index 0000000..4d36ae9 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/stats_ext.test @@ -0,0 +1,6196 @@ +== 001 +-- truncate_limit: 100 +-- Generic extended statistics support + +|-- +-- Note: tables for which we check estimated row counts should be created +-- with autovacuum_enabled = off, so that we don't have unstable results +-- from auto-analyze happening when we didn't expect it. +|-- + +-- check the number of estimated/actual rows in the top node +create function check_estimated_rows(text) returns table (estimated int, actual int) +language plpgsql as +$$ +declare + ln text; + tmp text[]; + first_row bool := true; +begin + for ln in + execute format('explain analyze %s', $1) + loop + if first_row then + first_row := false; + tmp := regexp_match(ln, 'rows=(\d*) .* rows=(\d*)'); + return query select tmp[1]::int, tmp[2]::int; + end if; + end loop; +end; +$$ +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION check_estimated_rows(text) RETURNS TABLE (estimated int, actual int) LANGUAGE plp..." +== 002 +-- truncate_limit: 100 +-- Verify failures +CREATE TABLE ext_stats_test (x text, y int, z int) +-- +TABLE: name="ext_stats_test" schema="" table="ext_stats_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ext_stats_test (x text, y int, z int)" +== 003 +-- truncate_limit: 100 +CREATE STATISTICS tst +-- +ERROR: syntax error at end of input +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +CREATE STATISTICS tst ON a, b +-- +ERROR: syntax error at end of input +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- truncate_limit: 100 +CREATE STATISTICS tst FROM sometab +-- +ERROR: syntax error at or near "FROM" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +-- truncate_limit: 100 +CREATE STATISTICS tst ON a, b FROM nonexistent +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON a, b FROM nonexistent" +== 007 +-- truncate_limit: 100 +CREATE STATISTICS tst ON a, b FROM ext_stats_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON a, b FROM ext_stats_test" +== 008 +-- truncate_limit: 100 +CREATE STATISTICS tst ON x, x, y FROM ext_stats_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON x, x, y FROM ext_stats_test" +== 009 +-- truncate_limit: 100 +CREATE STATISTICS tst ON x, x, y, x, x, y, x, x, y FROM ext_stats_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON x, x, y, x, x, y, x, x, y FROM ext_stats_test" +== 010 +-- truncate_limit: 100 +CREATE STATISTICS tst ON x, x, y, x, x, (x || 'x'), (y + 1), (x || 'x'), (x || 'x'), (y + 1) FROM ext_stats_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON x, x, y, x, x, (x || 'x'), (y + 1), (x || 'x'), (x || 'x'), (y + 1) FROM..." +== 011 +-- truncate_limit: 100 +CREATE STATISTICS tst ON (x || 'x'), (x || 'x'), (y + 1), (x || 'x'), (x || 'x'), (y + 1), (x || 'x'), (x || 'x'), (y + 1) FROM ext_stats_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON (x || 'x'), (x || 'x'), (y + 1), (x || 'x'), (x || 'x'), (y + 1), (x || ..." +== 012 +-- truncate_limit: 100 +CREATE STATISTICS tst ON (x || 'x'), (x || 'x'), y FROM ext_stats_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON (x || 'x'), (x || 'x'), y FROM ext_stats_test" +== 013 +-- truncate_limit: 100 +CREATE STATISTICS tst (unrecognized) ON x, y FROM ext_stats_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst (unrecognized) ON x, y FROM ext_stats_test" +== 014 +-- truncate_limit: 100 +-- unsupported targets +CREATE STATISTICS tst ON a FROM (VALUES (x)) AS foo +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON a FROM (VALUES (x)) foo" +== 015 +-- truncate_limit: 100 +CREATE STATISTICS tst ON a FROM foo NATURAL JOIN bar +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON a FROM foo NATURAL JOIN bar" +== 016 +-- truncate_limit: 100 +CREATE STATISTICS tst ON a FROM (SELECT * FROM ext_stats_test) AS foo +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON a FROM (SELECT * FROM ext_stats_test) foo" +== 017 +-- truncate_limit: 100 +CREATE STATISTICS tst ON a FROM ext_stats_test s TABLESAMPLE system (x) +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON a FROM ext_stats_test s TABLESAMPLE system(x)" +== 018 +-- truncate_limit: 100 +CREATE STATISTICS tst ON a FROM XMLTABLE('foo' PASSING 'bar' COLUMNS a text) +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON a FROM xmltable(('foo') PASSING 'bar' COLUMNS a text)" +== 019 +-- truncate_limit: 100 +CREATE STATISTICS tst ON a FROM JSON_TABLE(jsonb '123', '$' COLUMNS (item int)) +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON a FROM JSON_TABLE('123'::jsonb , '$' COLUMNS (item int ))" +== 020 +-- truncate_limit: 100 +CREATE FUNCTION tftest(int) returns table(a int, b int) as $$ +SELECT $1, $1+i FROM generate_series(1,5) g(i); +$$ LANGUAGE sql IMMUTABLE STRICT +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tftest(int) RETURNS TABLE (a int, b int) AS $$\nSELECT $1, $1+i FROM generate_seri..." +== 021 +-- truncate_limit: 100 +CREATE STATISTICS alt_stat2 ON a FROM tftest(1) +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS alt_stat2 ON a FROM tftest(1)" +== 022 +-- truncate_limit: 100 +DROP FUNCTION tftest +-- +FUNCTION: name="tftest" function="tftest" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION tftest" +== 023 +-- truncate_limit: 100 +-- incorrect expressions +CREATE STATISTICS tst ON (y) FROM ext_stats_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tst ON (y) FROM ext_stats_test" +== 024 +-- truncate_limit: 100 +-- single column reference +CREATE STATISTICS tst ON y + z FROM ext_stats_test +-- +ERROR: syntax error at or near "+" +CURSORPOS: 55 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 025 +-- truncate_limit: 100 +-- missing parentheses +CREATE STATISTICS tst ON (x, y) FROM ext_stats_test +-- +ERROR: syntax error at or near "," +CURSORPOS: 51 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 026 +-- truncate_limit: 100 +-- tuple expression +DROP TABLE ext_stats_test +-- +TABLE: name="ext_stats_test" schema="" table="ext_stats_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ext_stats_test" +== 027 +-- truncate_limit: 100 +-- Ensure stats are dropped sanely, and test IF NOT EXISTS while at it +CREATE TABLE ab1 (a INTEGER, b INTEGER, c INTEGER) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab1 (a int, b int, c int)" +== 028 +-- truncate_limit: 100 +CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1" +== 029 +-- truncate_limit: 100 +COMMENT ON STATISTICS ab1_a_b_stats IS 'new comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON STATISTICS ab1_a_b_stats IS 'new comment'" +== 030 +-- truncate_limit: 100 +CREATE ROLE regress_stats_ext +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_stats_ext" +== 031 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_stats_ext +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_ext" +== 032 +-- truncate_limit: 100 +COMMENT ON STATISTICS ab1_a_b_stats IS 'changed comment' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON STATISTICS ab1_a_b_stats IS 'changed comment'" +== 033 +-- truncate_limit: 100 +DROP STATISTICS ab1_a_b_stats +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS ab1_a_b_stats" +== 034 +-- truncate_limit: 100 +ALTER STATISTICS ab1_a_b_stats RENAME TO ab1_a_b_stats_new +-- +STMT: RenameStmt +TRUNCATED: "ALTER STATISTICS ab1_a_b_stats RENAME TO ab1_a_b_stats_new" +== 035 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 036 +-- truncate_limit: 100 +DROP ROLE regress_stats_ext +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_stats_ext" +== 037 +-- truncate_limit: 100 +CREATE STATISTICS pg_temp.stats_ext_temp ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS pg_temp.stats_ext_temp ON a, b FROM ab1" +== 038 +-- truncate_limit: 100 +SELECT regexp_replace(pg_describe_object(tableoid, oid, 0), + 'pg_temp_[0-9]*', 'pg_temp_REDACTED') AS descr, + pg_statistics_obj_is_visible(oid) AS visible + FROM pg_statistic_ext + WHERE stxname = 'stats_ext_temp' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FUNCTION: name="regexp_replace" function="regexp_replace" schema="" ctx=Call +FUNCTION: name="pg_describe_object" function="pg_describe_object" schema="" ctx=Call +FUNCTION: name="pg_statistics_obj_is_visible" function="pg_statistics_obj_is_visible" schema="" ctx=Call +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_statistic_ext WHERE stxname = 'stats_ext_temp'" +== 039 +-- truncate_limit: 100 +DROP STATISTICS stats_ext_temp +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS stats_ext_temp" +== 040 +-- truncate_limit: 100 +-- shall fail +DROP STATISTICS pg_temp.stats_ext_temp +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS pg_temp.stats_ext_temp" +== 041 +-- truncate_limit: 100 +CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS IF NOT EXISTS ab1_a_b_stats ON a, b FROM ab1" +== 042 +-- truncate_limit: 100 +DROP STATISTICS ab1_a_b_stats +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS ab1_a_b_stats" +== 043 +-- truncate_limit: 100 +CREATE SCHEMA regress_schema_2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA regress_schema_2" +== 044 +-- truncate_limit: 100 +CREATE STATISTICS regress_schema_2.ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS regress_schema_2.ab1_a_b_stats ON a, b FROM ab1" +== 045 +-- truncate_limit: 100 +-- Let's also verify the pg_get_statisticsobjdef output looks sane. +SELECT pg_get_statisticsobjdef(oid) FROM pg_statistic_ext WHERE stxname = 'ab1_a_b_stats' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FUNCTION: name="pg_get_statisticsobjdef" function="pg_get_statisticsobjdef" schema="" ctx=Call +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_statisticsobjdef(oid) FROM pg_statistic_ext WHERE stxname = 'ab1_a_b_stats'" +== 046 +-- truncate_limit: 100 +DROP STATISTICS regress_schema_2.ab1_a_b_stats +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS regress_schema_2.ab1_a_b_stats" +== 047 +-- truncate_limit: 100 +-- Ensure statistics are dropped when columns are +CREATE STATISTICS ab1_b_c_stats ON b, c FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_b_c_stats ON b, c FROM ab1" +== 048 +-- truncate_limit: 100 +CREATE STATISTICS ab1_a_b_c_stats ON a, b, c FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_a_b_c_stats ON a, b, c FROM ab1" +== 049 +-- truncate_limit: 100 +CREATE STATISTICS ab1_b_a_stats ON b, a FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_b_a_stats ON b, a FROM ab1" +== 050 +-- truncate_limit: 100 +ALTER TABLE ab1 DROP COLUMN a +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ab1 DROP a" +== 051 +-- truncate_limit: 100 +-- Ensure statistics are dropped when table is +SELECT stxname FROM pg_statistic_ext WHERE stxname LIKE 'ab1%' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +TRUNCATED: "SELECT stxname FROM pg_statistic_ext WHERE stxname LIKE 'ab1%'" +== 052 +-- truncate_limit: 100 +DROP TABLE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ab1" +== 053 +-- truncate_limit: 100 +SELECT stxname FROM pg_statistic_ext WHERE stxname LIKE 'ab1%' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +TRUNCATED: "SELECT stxname FROM pg_statistic_ext WHERE stxname LIKE 'ab1%'" +== 054 +-- truncate_limit: 100 +-- Ensure things work sanely with SET STATISTICS 0 +CREATE TABLE ab1 (a INTEGER, b INTEGER) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab1 (a int, b int)" +== 055 +-- truncate_limit: 100 +ALTER TABLE ab1 ALTER a SET STATISTICS 0 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ab1 ALTER COLUMN a SET STATISTICS 0" +== 056 +-- truncate_limit: 100 +INSERT INTO ab1 SELECT a, a%23 FROM generate_series(1, 1000) a +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ab1 SELECT a, a % 23 FROM generate_series(1, 1000) a" +== 057 +-- truncate_limit: 100 +CREATE STATISTICS ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_a_b_stats ON a, b FROM ab1" +== 058 +-- truncate_limit: 100 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ab1" +== 059 +-- truncate_limit: 100 +ALTER TABLE ab1 ALTER a SET STATISTICS -1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ab1 ALTER COLUMN a SET STATISTICS -1" +== 060 +-- truncate_limit: 100 +-- setting statistics target 0 skips the statistics, without printing any message, so check catalog +ALTER STATISTICS ab1_a_b_stats SET STATISTICS 0 +-- +STMT: AlterStatsStmt +TRUNCATED: "ALTER STATISTICS ab1_a_b_stats SET STATISTICS 0" +== 061 +-- truncate_limit: 100 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ab1" +== 062 +-- truncate_limit: 100 +SELECT stxname, stxdndistinct, stxddependencies, stxdmcv, stxdinherit + FROM pg_statistic_ext s LEFT JOIN pg_statistic_ext_data d ON (d.stxoid = s.oid) + WHERE s.stxname = 'ab1_a_b_stats' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_statistic_ext s LEFT JOIN pg_statistic_ext_data d ON d.stxoid = s.oid WHERE ..." +== 063 +-- truncate_limit: 100 +ALTER STATISTICS ab1_a_b_stats SET STATISTICS -1 +-- +STMT: AlterStatsStmt +TRUNCATED: "ALTER STATISTICS ab1_a_b_stats SET STATISTICS -1" +== 064 +-- truncate_limit: 100 +-- partial analyze doesn't build stats either +ANALYZE ab1 (a) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ab1(a)" +== 065 +-- truncate_limit: 100 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ab1" +== 066 +-- truncate_limit: 100 +DROP TABLE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ab1" +== 067 +-- truncate_limit: 100 +ALTER STATISTICS ab1_a_b_stats SET STATISTICS 0 +-- +STMT: AlterStatsStmt +TRUNCATED: "ALTER STATISTICS ab1_a_b_stats SET STATISTICS 0" +== 068 +-- truncate_limit: 100 +ALTER STATISTICS IF EXISTS ab1_a_b_stats SET STATISTICS 0 +-- +STMT: AlterStatsStmt +TRUNCATED: "ALTER STATISTICS IF EXISTS ab1_a_b_stats SET STATISTICS 0" +== 069 +-- truncate_limit: 100 +-- Ensure we can build statistics for tables with inheritance. +CREATE TABLE ab1 (a INTEGER, b INTEGER) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab1 (a int, b int)" +== 070 +-- truncate_limit: 100 +CREATE TABLE ab1c () INHERITS (ab1) +-- +TABLE: name="ab1c" schema="" table="ab1c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab1c () INHERITS (ab1)" +== 071 +-- truncate_limit: 100 +INSERT INTO ab1 VALUES (1,1) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ab1 VALUES (1, 1)" +== 072 +-- truncate_limit: 100 +CREATE STATISTICS ab1_a_b_stats ON a, b FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_a_b_stats ON a, b FROM ab1" +== 073 +-- truncate_limit: 100 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ab1" +== 074 +-- truncate_limit: 100 +DROP TABLE ab1 CASCADE +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ab1 CASCADE" +== 075 +-- truncate_limit: 100 +-- Tests for stats with inheritance +CREATE TABLE stxdinh(a int, b int) +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stxdinh (a int, b int)" +== 076 +-- truncate_limit: 100 +CREATE TABLE stxdinh1() INHERITS(stxdinh) +-- +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stxdinh1 () INHERITS (stxdinh)" +== 077 +-- truncate_limit: 100 +CREATE TABLE stxdinh2() INHERITS(stxdinh) +-- +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stxdinh2 () INHERITS (stxdinh)" +== 078 +-- truncate_limit: 100 +INSERT INTO stxdinh SELECT mod(a,50), mod(a,100) FROM generate_series(0, 1999) a +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO stxdinh SELECT mod(a, 50), mod(a, 100) FROM generate_series(0, 1999) a" +== 079 +-- truncate_limit: 100 +INSERT INTO stxdinh1 SELECT mod(a,100), mod(a,100) FROM generate_series(0, 999) a +-- +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO stxdinh1 SELECT mod(a, 100), mod(a, 100) FROM generate_series(0, 999) a" +== 080 +-- truncate_limit: 100 +INSERT INTO stxdinh2 SELECT mod(a,100), mod(a,100) FROM generate_series(0, 999) a +-- +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO stxdinh2 SELECT mod(a, 100), mod(a, 100) FROM generate_series(0, 999) a" +== 081 +-- truncate_limit: 100 +VACUUM ANALYZE stxdinh, stxdinh1, stxdinh2 +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DDL +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DDL +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) stxdinh, stxdinh1, stxdinh2" +== 082 +-- truncate_limit: 100 +-- Ensure non-inherited stats are not applied to inherited query +-- Without stats object, it looks like this +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* GROUP BY 1, 2')" +== 083 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* WHERE a = 0 AND b = 0')" +== 084 +-- truncate_limit: 100 +CREATE STATISTICS stxdinh ON a, b FROM stxdinh +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS stxdinh ON a, b FROM stxdinh" +== 085 +-- truncate_limit: 100 +VACUUM ANALYZE stxdinh, stxdinh1, stxdinh2 +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DDL +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DDL +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) stxdinh, stxdinh1, stxdinh2" +== 086 +-- truncate_limit: 100 +-- See if the extended stats affect the estimates +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* GROUP BY 1, 2')" +== 087 +-- truncate_limit: 100 +-- Dependencies are applied at individual relations (within append), so +-- this estimate changes a bit because we improve estimates for the parent +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinh* WHERE a = 0 AND b = 0')" +== 088 +-- truncate_limit: 100 +-- Ensure correct (non-inherited) stats are applied to inherited query +SELECT * FROM check_estimated_rows('SELECT a, b FROM ONLY stxdinh GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT a, b FROM ONLY stxdinh GROUP BY 1, 2')" +== 089 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT a, b FROM ONLY stxdinh WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT a, b FROM ONLY stxdinh WHERE a = 0 AND b = 0')" +== 090 +-- truncate_limit: 100 +DROP TABLE stxdinh, stxdinh1, stxdinh2 +-- +TABLE: name="stxdinh" schema="" table="stxdinh" ctx=DDL +TABLE: name="stxdinh1" schema="" table="stxdinh1" ctx=DDL +TABLE: name="stxdinh2" schema="" table="stxdinh2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE stxdinh, stxdinh1, stxdinh2" +== 091 +-- truncate_limit: 100 +-- Ensure inherited stats ARE applied to inherited query in partitioned table +CREATE TABLE stxdinp(i int, a int, b int) PARTITION BY RANGE (i) +-- +TABLE: name="stxdinp" schema="" table="stxdinp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stxdinp (i int, a int, b int) PARTITION BY RANGE (i)" +== 092 +-- truncate_limit: 100 +CREATE TABLE stxdinp1 PARTITION OF stxdinp FOR VALUES FROM (1) TO (100) +-- +TABLE: name="stxdinp1" schema="" table="stxdinp1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stxdinp1 PARTITION OF stxdinp FOR VALUES FROM (1) TO (100)" +== 093 +-- truncate_limit: 100 +INSERT INTO stxdinp SELECT 1, a/100, a/100 FROM generate_series(1, 999) a +-- +TABLE: name="stxdinp" schema="" table="stxdinp" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO stxdinp SELECT 1, a / 100, a / 100 FROM generate_series(1, 999) a" +== 094 +-- truncate_limit: 100 +CREATE STATISTICS stxdinp ON (a + 1), a, b FROM stxdinp +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS stxdinp ON (a + 1), a, b FROM stxdinp" +== 095 +-- truncate_limit: 100 +VACUUM ANALYZE stxdinp +-- +TABLE: name="stxdinp" schema="" table="stxdinp" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) stxdinp" +== 096 +-- truncate_limit: 100 +-- partitions are processed recursively +SELECT 1 FROM pg_statistic_ext WHERE stxrelid = 'stxdinp'::regclass +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxrelid" +STMT: SelectStmt +TRUNCATED: "SELECT 1 FROM pg_statistic_ext WHERE stxrelid = 'stxdinp'::regclass" +== 097 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinp GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT a, b FROM stxdinp GROUP BY 1, 2')" +== 098 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT a + 1, b FROM ONLY stxdinp GROUP BY 1, 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT a + 1, b FROM ONLY stxdinp GROUP BY 1, 2')" +== 099 +-- truncate_limit: 100 +DROP TABLE stxdinp +-- +TABLE: name="stxdinp" schema="" table="stxdinp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE stxdinp" +== 100 +-- truncate_limit: 100 +-- basic test for statistics on expressions +CREATE TABLE ab1 (a INTEGER, b INTEGER, c TIMESTAMP, d TIMESTAMPTZ) +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ab1 (a int, b int, c timestamp, d timestamptz)" +== 101 +-- truncate_limit: 100 +-- expression stats may be built on a single expression column +CREATE STATISTICS ab1_exprstat_1 ON (a+b) FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_exprstat_1 ON (a + b) FROM ab1" +== 102 +-- truncate_limit: 100 +-- with a single expression, we only enable expression statistics +CREATE STATISTICS ab1_exprstat_2 ON (a+b) FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_exprstat_2 ON (a + b) FROM ab1" +== 103 +-- truncate_limit: 100 +SELECT stxkind FROM pg_statistic_ext WHERE stxname = 'ab1_exprstat_2' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +TRUNCATED: "SELECT stxkind FROM pg_statistic_ext WHERE stxname = 'ab1_exprstat_2'" +== 104 +-- truncate_limit: 100 +-- adding anything to the expression builds all statistics kinds +CREATE STATISTICS ab1_exprstat_3 ON (a+b), a FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_exprstat_3 ON (a + b), a FROM ab1" +== 105 +-- truncate_limit: 100 +SELECT stxkind FROM pg_statistic_ext WHERE stxname = 'ab1_exprstat_3' +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +FILTER: schema="" table="" column="stxname" +STMT: SelectStmt +TRUNCATED: "SELECT stxkind FROM pg_statistic_ext WHERE stxname = 'ab1_exprstat_3'" +== 106 +-- truncate_limit: 100 +-- date_trunc on timestamptz is not immutable, but that should not matter +CREATE STATISTICS ab1_exprstat_4 ON date_trunc('day', d) FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_exprstat_4 ON (date_trunc('day', d)) FROM ab1" +== 107 +-- truncate_limit: 100 +-- date_trunc on timestamp is immutable +CREATE STATISTICS ab1_exprstat_5 ON date_trunc('day', c) FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_exprstat_5 ON (date_trunc('day', c)) FROM ab1" +== 108 +-- truncate_limit: 100 +-- check use of a boolean-returning expression +CREATE STATISTICS ab1_exprstat_6 ON + (case a when 1 then true else false end), b FROM ab1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ab1_exprstat_6 ON (CASE a WHEN 1 THEN true ELSE false END), b FROM ab1" +== 109 +-- truncate_limit: 100 +-- insert some data and run analyze, to test that these cases build properly +INSERT INTO ab1 +SELECT x / 10, x / 3, + '2020-10-01'::timestamp + x * interval '1 day', + '2020-10-01'::timestamptz + x * interval '1 day' +FROM generate_series(1, 100) x +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ab1 SELECT ... FROM generate_series(1, 100) x" +== 110 +-- truncate_limit: 100 +ANALYZE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ab1" +== 111 +-- truncate_limit: 100 +-- apply some stats +SELECT * FROM check_estimated_rows('SELECT * FROM ab1 WHERE (case a when 1 then true else false end) AND b=2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM ab1 WHERE (case a when 1 then true else false e..." +== 112 +-- truncate_limit: 100 +DROP TABLE ab1 +-- +TABLE: name="ab1" schema="" table="ab1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ab1" +== 113 +-- truncate_limit: 100 +-- Verify supported object types for extended statistics +CREATE schema tststats +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA tststats" +== 114 +-- truncate_limit: 100 +CREATE TABLE tststats.t (a int, b int, c text) +-- +TABLE: name="tststats.t" schema="tststats" table="t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tststats.t (a int, b int, c text)" +== 115 +-- truncate_limit: 100 +CREATE INDEX ti ON tststats.t (a, b) +-- +TABLE: name="tststats.t" schema="tststats" table="t" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ti ON tststats.t USING btree (a, b)" +== 116 +-- truncate_limit: 100 +CREATE SEQUENCE tststats.s +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE tststats.s" +== 117 +-- truncate_limit: 100 +CREATE VIEW tststats.v AS SELECT * FROM tststats.t +-- +TABLE: name="tststats.v" schema="tststats" table="v" ctx=DDL +TABLE: name="tststats.t" schema="tststats" table="t" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tststats.v AS SELECT * FROM tststats.t" +== 118 +-- truncate_limit: 100 +CREATE MATERIALIZED VIEW tststats.mv AS SELECT * FROM tststats.t +-- +TABLE: name="tststats.mv" schema="tststats" table="mv" ctx=DDL +TABLE: name="tststats.t" schema="tststats" table="t" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW tststats.mv AS SELECT * FROM tststats.t" +== 119 +-- truncate_limit: 100 +CREATE TYPE tststats.ty AS (a int, b int, c text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE tststats.ty AS (a int, b int, c text)" +== 120 +-- truncate_limit: 100 +CREATE FOREIGN DATA WRAPPER extstats_dummy_fdw +-- +STMT: CreateFdwStmt +TRUNCATED: "CREATE FOREIGN DATA WRAPPER extstats_dummy_fdw" +== 121 +-- truncate_limit: 100 +CREATE SERVER extstats_dummy_srv FOREIGN DATA WRAPPER extstats_dummy_fdw +-- +STMT: CreateForeignServerStmt +TRUNCATED: "CREATE SERVER extstats_dummy_srv FOREIGN DATA WRAPPER extstats_dummy_fdw" +== 122 +-- truncate_limit: 100 +CREATE FOREIGN TABLE tststats.f (a int, b int, c text) SERVER extstats_dummy_srv +-- +STMT: CreateForeignTableStmt +TRUNCATED: "CREATE FOREIGN TABLE tststats.f (a int, b int, c text) SERVER extstats_dummy_srv" +== 123 +-- truncate_limit: 100 +CREATE TABLE tststats.pt (a int, b int, c text) PARTITION BY RANGE (a, b) +-- +TABLE: name="tststats.pt" schema="tststats" table="pt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tststats.pt (a int, b int, c text) PARTITION BY RANGE (a, b)" +== 124 +-- truncate_limit: 100 +CREATE TABLE tststats.pt1 PARTITION OF tststats.pt FOR VALUES FROM (-10, -10) TO (10, 10) +-- +TABLE: name="tststats.pt1" schema="tststats" table="pt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tststats.pt1 PARTITION OF tststats.pt FOR VALUES FROM (-10, -10) TO (10, 10)" +== 125 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s1 ON a, b FROM tststats.t +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s1 ON a, b FROM tststats.t" +== 126 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s2 ON a, b FROM tststats.ti +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s2 ON a, b FROM tststats.ti" +== 127 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s3 ON a, b FROM tststats.s +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s3 ON a, b FROM tststats.s" +== 128 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s4 ON a, b FROM tststats.v +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s4 ON a, b FROM tststats.v" +== 129 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s5 ON a, b FROM tststats.mv +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s5 ON a, b FROM tststats.mv" +== 130 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s6 ON a, b FROM tststats.ty +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s6 ON a, b FROM tststats.ty" +== 131 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s7 ON a, b FROM tststats.f +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s7 ON a, b FROM tststats.f" +== 132 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s8 ON a, b FROM tststats.pt +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s8 ON a, b FROM tststats.pt" +== 133 +-- truncate_limit: 100 +CREATE STATISTICS tststats.s9 ON a, b FROM tststats.pt1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.s9 ON a, b FROM tststats.pt1" +== 134 +-- truncate_limit: 100 +DO $$ +DECLARE + relname text := reltoastrelid::regclass FROM pg_class WHERE oid = 'tststats.t'::regclass; +BEGIN + EXECUTE 'CREATE STATISTICS tststats.s10 ON a, b FROM ' || relname; +EXCEPTION WHEN wrong_object_type THEN + RAISE NOTICE 'stats on toast table not created'; +END; +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n\trelname text := reltoastrelid::regclass FROM pg_class WHERE oid = 'tststats.t'::re..." +== 135 +-- truncate_limit: 100 +DROP SCHEMA tststats CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA tststats CASCADE" +== 136 +-- truncate_limit: 100 +DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE" +== 137 +-- truncate_limit: 100 +-- n-distinct tests +CREATE TABLE ndistinct ( + filler1 TEXT, + filler2 NUMERIC, + a INT, + b INT, + filler3 DATE, + c INT, + d INT +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ndistinct (filler1 text, filler2 numeric, a int, b int, filler3 date, c int, d int) ..." +== 138 +-- truncate_limit: 100 +-- over-estimates when using only per-column statistics +INSERT INTO ndistinct (a, b, c, filler1) + SELECT i/100, i/100, i/100, (i/100) || ' dollars and zero cents' + FROM generate_series(1,1000) s(i) +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ndistinct (a, b, c, filler1) SELECT ... FROM generate_series(1, 1000) s(i)" +== 139 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 140 +-- truncate_limit: 100 +-- Group Aggregate, due to over-estimate of the number of groups +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 141 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c')" +== 142 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c')" +== 143 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d')" +== 144 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d')" +== 145 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)')" +== 146 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)')" +== 147 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)')" +== 148 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)')" +== 149 +-- truncate_limit: 100 +-- correct command +CREATE STATISTICS s10 ON a, b, c FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s10 ON a, b, c FROM ndistinct" +== 150 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 151 +-- truncate_limit: 100 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT s.stxkind, d.stxdndistinct FROM pg_statistic_ext s, pg_statistic_ext_data d WHERE ..." +== 152 +-- truncate_limit: 100 +-- minor improvement, make sure the ctid does not break the matching +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY ctid, a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY ctid, a, b')" +== 153 +-- truncate_limit: 100 +-- Hash Aggregate, thanks to estimates improved by the statistic +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 154 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c')" +== 155 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c')" +== 156 +-- truncate_limit: 100 +-- partial improvement (match on attributes) +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)')" +== 157 +-- truncate_limit: 100 +-- expressions - no improvement +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)')" +== 158 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)')" +== 159 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)')" +== 160 +-- truncate_limit: 100 +-- last two plans keep using Group Aggregate, because 'd' is not covered +-- by the statistic and while it's NULL-only we assume 200 values for it +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d')" +== 161 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d')" +== 162 +-- truncate_limit: 100 +TRUNCATE TABLE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE ndistinct" +== 163 +-- truncate_limit: 100 +-- under-estimates when using only per-column statistics +INSERT INTO ndistinct (a, b, c, filler1) + SELECT mod(i,13), mod(i,17), mod(i,19), + mod(i,23) || ' dollars and zero cents' + FROM generate_series(1,1000) s(i) +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ndistinct (a, b, c, filler1) SELECT ... FROM generate_series(1, 1000) s(i)" +== 164 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 165 +-- truncate_limit: 100 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT s.stxkind, d.stxdndistinct FROM pg_statistic_ext s, pg_statistic_ext_data d WHERE ..." +== 166 +-- truncate_limit: 100 +-- correct estimates +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 167 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c')" +== 168 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d')" +== 169 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d')" +== 170 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, d')" +== 171 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)')" +== 172 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)')" +== 173 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)')" +== 174 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)')" +== 175 +-- truncate_limit: 100 +DROP STATISTICS s10 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s10" +== 176 +-- truncate_limit: 100 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT s.stxkind, d.stxdndistinct FROM pg_statistic_ext s, pg_statistic_ext_data d WHERE ..." +== 177 +-- truncate_limit: 100 +-- dropping the statistics results in under-estimates +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 178 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c')" +== 179 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, c, d')" +== 180 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY b, c, d')" +== 181 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, d') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, d')" +== 182 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (a+1)')" +== 183 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)')" +== 184 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)')" +== 185 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)')" +== 186 +-- truncate_limit: 100 +-- ndistinct estimates with statistics on expressions +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)')" +== 187 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)')" +== 188 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)')" +== 189 +-- truncate_limit: 100 +CREATE STATISTICS s10 (ndistinct) ON (a+1), (b+100), (2*c) FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s10 (ndistinct) ON (a + 1), (b + 100), (2 * c) FROM ndistinct" +== 190 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 191 +-- truncate_limit: 100 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT s.stxkind, d.stxdndistinct FROM pg_statistic_ext s, pg_statistic_ext_data d WHERE ..." +== 192 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100)')" +== 193 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a+1), (b+100), (2*c)')" +== 194 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (a+1), (b+100)')" +== 195 +-- truncate_limit: 100 +DROP STATISTICS s10 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s10" +== 196 +-- truncate_limit: 100 +-- a mix of attributes and expressions +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 197 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (2*c)')" +== 198 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (2*c)')" +== 199 +-- truncate_limit: 100 +CREATE STATISTICS s10 (ndistinct) ON a, b, (2*c) FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s10 (ndistinct) ON a, b, (2 * c) FROM ndistinct" +== 200 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 201 +-- truncate_limit: 100 +SELECT s.stxkind, d.stxdndistinct + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxrelid = 'ndistinct'::regclass + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxrelid" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT s.stxkind, d.stxdndistinct FROM pg_statistic_ext s, pg_statistic_ext_data d WHERE ..." +== 202 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 203 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (2*c)')" +== 204 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (2*c)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (2*c)')" +== 205 +-- truncate_limit: 100 +DROP STATISTICS s10 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s10" +== 206 +-- truncate_limit: 100 +-- combination of multiple ndistinct statistics, with/without expressions +TRUNCATE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE ndistinct" +== 207 +-- truncate_limit: 100 +-- two mostly independent groups of columns +INSERT INTO ndistinct (a, b, c, d) + SELECT mod(i,3), mod(i,9), mod(i,5), mod(i,20) + FROM generate_series(1,1000) s(i) +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ndistinct (a, b, c, d) SELECT ... FROM generate_series(1, 1000) s(i)" +== 208 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 209 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 210 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)')" +== 211 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b')" +== 212 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)')" +== 213 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c')" +== 214 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)')" +== 215 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)')" +== 216 +-- truncate_limit: 100 +-- basic statistics on both attributes (no expressions) +CREATE STATISTICS s11 (ndistinct) ON a, b FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s11 (ndistinct) ON a, b FROM ndistinct" +== 217 +-- truncate_limit: 100 +CREATE STATISTICS s12 (ndistinct) ON c, d FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s12 (ndistinct) ON c, d FROM ndistinct" +== 218 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 219 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 220 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)')" +== 221 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b')" +== 222 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)')" +== 223 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c')" +== 224 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)')" +== 225 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)')" +== 226 +-- truncate_limit: 100 +-- replace the second statistics by statistics on expressions + +DROP STATISTICS s12 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s12" +== 227 +-- truncate_limit: 100 +CREATE STATISTICS s12 (ndistinct) ON (c * 10), (d - 1) FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s12 (ndistinct) ON (c * 10), (d - 1) FROM ndistinct" +== 228 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 229 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 230 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)')" +== 231 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b')" +== 232 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)')" +== 233 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c')" +== 234 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)')" +== 235 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)')" +== 236 +-- truncate_limit: 100 +-- replace the second statistics by statistics on both attributes and expressions + +DROP STATISTICS s12 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s12" +== 237 +-- truncate_limit: 100 +CREATE STATISTICS s12 (ndistinct) ON c, d, (c * 10), (d - 1) FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s12 (ndistinct) ON c, d, (c * 10), (d - 1) FROM ndistinct" +== 238 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 239 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 240 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)')" +== 241 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b')" +== 242 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)')" +== 243 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c')" +== 244 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)')" +== 245 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)')" +== 246 +-- truncate_limit: 100 +-- replace the other statistics by statistics on both attributes and expressions + +DROP STATISTICS s11 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s11" +== 247 +-- truncate_limit: 100 +CREATE STATISTICS s11 (ndistinct) ON a, b, (a*5), (b+1) FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s11 (ndistinct) ON a, b, (a * 5), (b + 1) FROM ndistinct" +== 248 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 249 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 250 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)')" +== 251 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b')" +== 252 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)')" +== 253 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c')" +== 254 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)')" +== 255 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)')" +== 256 +-- truncate_limit: 100 +-- replace statistics by somewhat overlapping ones (this expected to get worse estimate +-- because the first statistics shall be applied to 3 columns, and the second one can't +-- be really applied) + +DROP STATISTICS s11 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s11" +== 257 +-- truncate_limit: 100 +DROP STATISTICS s12 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s12" +== 258 +-- truncate_limit: 100 +CREATE STATISTICS s11 (ndistinct) ON a, b, (a*5), (b+1) FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s11 (ndistinct) ON a, b, (a * 5), (b + 1) FROM ndistinct" +== 259 +-- truncate_limit: 100 +CREATE STATISTICS s12 (ndistinct) ON a, (b+1), (c * 10) FROM ndistinct +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s12 (ndistinct) ON a, (b + 1), (c * 10) FROM ndistinct" +== 260 +-- truncate_limit: 100 +ANALYZE ndistinct +-- +TABLE: name="ndistinct" schema="" table="ndistinct" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE ndistinct" +== 261 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b')" +== 262 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1)')" +== 263 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), b')" +== 264 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1)')" +== 265 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY (a*5), (b+1), c')" +== 266 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, b, (c*10)')" +== 267 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT COUNT(*) FROM ndistinct GROUP BY a, (b+1), c, (d - 1)')" +== 268 +-- truncate_limit: 100 +DROP STATISTICS s11 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s11" +== 269 +-- truncate_limit: 100 +DROP STATISTICS s12 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS s12" +== 270 +-- truncate_limit: 100 +-- functional dependencies tests +CREATE TABLE functional_dependencies ( + filler1 TEXT, + filler2 NUMERIC, + a INT, + b TEXT, + filler3 DATE, + c INT, + d TEXT +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE functional_dependencies (filler1 text, filler2 numeric, a int, b text, filler3 date,..." +== 271 +-- truncate_limit: 100 +CREATE INDEX fdeps_ab_idx ON functional_dependencies (a, b) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fdeps_ab_idx ON functional_dependencies USING btree (a, b)" +== 272 +-- truncate_limit: 100 +CREATE INDEX fdeps_abc_idx ON functional_dependencies (a, b, c) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fdeps_abc_idx ON functional_dependencies USING btree (a, b, c)" +== 273 +-- truncate_limit: 100 +-- random data (no functional dependencies) +INSERT INTO functional_dependencies (a, b, c, filler1) + SELECT mod(i, 5), mod(i, 7), mod(i, 11), i FROM generate_series(1,1000) s(i) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO functional_dependencies (a, b, c, filler1) SELECT ... FROM generate_series(1, 1000) s(i)" +== 274 +-- truncate_limit: 100 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies" +== 275 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 276 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 277 +-- truncate_limit: 100 +-- create statistics +CREATE STATISTICS func_deps_stat (dependencies) ON a, b, c FROM functional_dependencies +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS func_deps_stat (dependencies) ON a, b, c FROM functional_dependencies" +== 278 +-- truncate_limit: 100 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies" +== 279 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 280 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 281 +-- truncate_limit: 100 +-- a => b, a => c, b => c +TRUNCATE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE functional_dependencies" +== 282 +-- truncate_limit: 100 +DROP STATISTICS func_deps_stat +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS func_deps_stat" +== 283 +-- truncate_limit: 100 +-- now do the same thing, but with expressions +INSERT INTO functional_dependencies (a, b, c, filler1) + SELECT i, i, i, i FROM generate_series(1,5000) s(i) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO functional_dependencies (a, b, c, filler1) SELECT ... FROM generate_series(1, 5000) s(i)" +== 284 +-- truncate_limit: 100 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies" +== 285 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AND mod(b::int, 13) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AN..." +== 286 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AND mod(b::int, 13) = 1 AND mod(c, 7) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AN..." +== 287 +-- truncate_limit: 100 +-- create statistics +CREATE STATISTICS func_deps_stat (dependencies) ON (mod(a,11)), (mod(b::int, 13)), (mod(c, 7)) FROM functional_dependencies +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS func_deps_stat (dependencies) ON (mod(a, 11)), (mod(b::int, 13)), (mod(c, 7)) F..." +== 288 +-- truncate_limit: 100 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies" +== 289 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AND mod(b::int, 13) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AN..." +== 290 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AND mod(b::int, 13) = 1 AND mod(c, 7) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE mod(a, 11) = 1 AN..." +== 291 +-- truncate_limit: 100 +-- a => b, a => c, b => c +TRUNCATE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE functional_dependencies" +== 292 +-- truncate_limit: 100 +DROP STATISTICS func_deps_stat +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS func_deps_stat" +== 293 +-- truncate_limit: 100 +INSERT INTO functional_dependencies (a, b, c, filler1) + SELECT mod(i,100), mod(i,50), mod(i,25), i FROM generate_series(1,5000) s(i) +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO functional_dependencies (a, b, c, filler1) SELECT ... FROM generate_series(1, 5000) s(i)" +== 294 +-- truncate_limit: 100 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies" +== 295 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 296 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 297 +-- truncate_limit: 100 +-- IN +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND ..." +== 298 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND ..." +== 299 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 5..." +== 300 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 5..." +== 301 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, 76) AND b IN (''1'', ''26'') AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, ..." +== 302 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, 76) AND b IN (''1'', ''26'') AND c IN (1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, ..." +== 303 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 26, 27, 51, 52, 76, 77) AND b IN (''1'', ''2'', ''26'', ''27'') AND c IN (1, 2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 26, 2..." +== 304 +-- truncate_limit: 100 +-- OR clauses referencing the same attribute +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51)..." +== 305 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND (b = ''1'' OR b = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51)..." +== 306 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 2 OR a = 51 OR a = 52) AND (b = ''1'' OR b = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 2 O..." +== 307 +-- truncate_limit: 100 +-- OR clauses referencing different attributes +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR b = ''1'') AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR b = ''1..." +== 308 +-- truncate_limit: 100 +-- ANY +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 51]) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 309 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 51]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 310 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 311 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 26, 51, 76]) AND b = ANY (ARRAY[''1'', ''26'']) AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 312 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 26, 51, 76]) AND b = ANY (ARRAY[''1'', ''26'']) AND c = ANY (ARRAY[1])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 313 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 2, 26, 27, 51, 52, 76, 77]) AND b = ANY (ARRAY[''1'', ''2'', ''26'', ''27'']) AND c = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 314 +-- truncate_limit: 100 +-- ANY with inequalities should not benefit from functional dependencies +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a < ANY (ARRAY[1, 51]) AND b > ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a < ANY (ARRAY[1,..." +== 315 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a >= ANY (ARRAY[1, 51]) AND b <= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a >= ANY (ARRAY[1..." +== 316 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a <= ANY (ARRAY[1, 2, 51, 52]) AND b >= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a <= ANY (ARRAY[1..." +== 317 +-- truncate_limit: 100 +-- ALL (should not benefit from functional dependencies) +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ALL (ARRAY[''1''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND ..." +== 318 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND ..." +== 319 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 5..." +== 320 +-- truncate_limit: 100 +-- create statistics +CREATE STATISTICS func_deps_stat (dependencies) ON a, b, c FROM functional_dependencies +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS func_deps_stat (dependencies) ON a, b, c FROM functional_dependencies" +== 321 +-- truncate_limit: 100 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies" +== 322 +-- truncate_limit: 100 +-- print the detected dependencies +SELECT dependencies FROM pg_stats_ext WHERE statistics_name = 'func_deps_stat' +-- +TABLE: name="pg_stats_ext" schema="" table="pg_stats_ext" ctx=Select +FILTER: schema="" table="" column="statistics_name" +STMT: SelectStmt +TRUNCATED: "SELECT dependencies FROM pg_stats_ext WHERE statistics_name = 'func_deps_stat'" +== 323 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 324 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 325 +-- truncate_limit: 100 +-- IN +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND ..." +== 326 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND ..." +== 327 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 5..." +== 328 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 5..." +== 329 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, 76) AND b IN (''1'', ''26'') AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, ..." +== 330 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, 76) AND b IN (''1'', ''26'') AND c IN (1)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 26, 51, ..." +== 331 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 26, 27, 51, 52, 76, 77) AND b IN (''1'', ''2'', ''26'', ''27'') AND c IN (1, 2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 26, 2..." +== 332 +-- truncate_limit: 100 +-- OR clauses referencing the same attribute +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51)..." +== 333 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND (b = ''1'' OR b = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51)..." +== 334 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 2 OR a = 51 OR a = 52) AND (b = ''1'' OR b = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 2 O..." +== 335 +-- truncate_limit: 100 +-- OR clauses referencing different attributes are incompatible +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR b = ''1'') AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR b = ''1..." +== 336 +-- truncate_limit: 100 +-- ANY +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 51]) AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 337 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 51]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 338 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 339 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 26, 51, 76]) AND b = ANY (ARRAY[''1'', ''26'']) AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 340 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 26, 51, 76]) AND b = ANY (ARRAY[''1'', ''26'']) AND c = ANY (ARRAY[1])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 341 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1, 2, 26, 27, 51, 52, 76, 77]) AND b = ANY (ARRAY[''1'', ''2'', ''26'', ''27'']) AND c = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = ANY (ARRAY[1,..." +== 342 +-- truncate_limit: 100 +-- ANY with inequalities should not benefit from functional dependencies +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a < ANY (ARRAY[1, 51]) AND b > ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a < ANY (ARRAY[1,..." +== 343 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a >= ANY (ARRAY[1, 51]) AND b <= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a >= ANY (ARRAY[1..." +== 344 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a <= ANY (ARRAY[1, 2, 51, 52]) AND b >= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a <= ANY (ARRAY[1..." +== 345 +-- truncate_limit: 100 +-- ALL (should not benefit from functional dependencies) +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ALL (ARRAY[''1''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND ..." +== 346 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND b = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 51) AND ..." +== 347 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 52) AND b = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a IN (1, 2, 51, 5..." +== 348 +-- truncate_limit: 100 +-- changing the type of column c causes all its stats to be dropped, reverting +-- to default estimates without any statistics, i.e. 0.5% selectivity for each +-- condition +ALTER TABLE functional_dependencies ALTER COLUMN c TYPE numeric +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE functional_dependencies ALTER COLUMN c TYPE numeric" +== 349 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 350 +-- truncate_limit: 100 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies" +== 351 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE a = 1 AND b = ''1..." +== 352 +-- truncate_limit: 100 +DROP STATISTICS func_deps_stat +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS func_deps_stat" +== 353 +-- truncate_limit: 100 +-- now try functional dependencies with expressions + +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND u..." +== 354 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND upper(b) = ''1'' AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND u..." +== 355 +-- truncate_limit: 100 +-- IN +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 10..." +== 356 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 10..." +== 357 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4,..." +== 358 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4,..." +== 359 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52, 102, 152) AND upper(b) IN (''1'', ''26'') AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52..." +== 360 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52, 102, 152) AND upper(b) IN (''1'', ''26'') AND (c + 1) IN (2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52..." +== 361 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 52, 54, 102, 104, 152, 154) AND upper(b) IN (''1'', ''2'', ''26'', ''27'') AND (c + 1) IN (2, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4,..." +== 362 +-- truncate_limit: 100 +-- OR clauses referencing the same attribute +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (..." +== 363 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND (upper(b) = ''1'' OR upper(b) = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (..." +== 364 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 4 OR (a * 2) = 102 OR (a * 2) = 104) AND (upper(b) = ''1'' OR upper(b) = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (..." +== 365 +-- truncate_limit: 100 +-- OR clauses referencing different attributes +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR upper(b) = ''1'') AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR u..." +== 366 +-- truncate_limit: 100 +-- ANY +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 102]) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 367 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 102]) AND upper(b) = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 368 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 4, 102, 104]) AND upper(b) = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 369 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 52, 102, 152]) AND upper(b) = ANY (ARRAY[''1'', ''26'']) AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 370 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 52, 102, 152]) AND upper(b) = ANY (ARRAY[''1'', ''26'']) AND (c + 1) = ANY (ARRAY[2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 371 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 4, 52, 54, 102, 104, 152, 154]) AND upper(b) = ANY (ARRAY[''1'', ''2'', ''26'', ''27'']) AND (c + 1) = ANY (ARRAY[2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 372 +-- truncate_limit: 100 +-- ANY with inequalities should not benefit from functional dependencies +-- the estimates however improve thanks to having expression statistics +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) < ANY (ARRAY[2, 102]) AND upper(b) > ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) < ANY (AR..." +== 373 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) >= ANY (ARRAY[2, 102]) AND upper(b) <= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) >= ANY (A..." +== 374 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) <= ANY (ARRAY[2, 4, 102, 104]) AND upper(b) >= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) <= ANY (A..." +== 375 +-- truncate_limit: 100 +-- ALL (should not benefit from functional dependencies) +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ALL (ARRAY[''1''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 10..." +== 376 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 10..." +== 377 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4,..." +== 378 +-- truncate_limit: 100 +-- create statistics on expressions +CREATE STATISTICS func_deps_stat (dependencies) ON (a * 2), upper(b), (c + 1) FROM functional_dependencies +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS func_deps_stat (dependencies) ON (a * 2), (upper(b)), (c + 1) FROM functional_d..." +== 379 +-- truncate_limit: 100 +ANALYZE functional_dependencies +-- +TABLE: name="functional_dependencies" schema="" table="functional_dependencies" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies" +== 380 +-- truncate_limit: 100 +-- print the detected dependencies +SELECT dependencies FROM pg_stats_ext WHERE statistics_name = 'func_deps_stat' +-- +TABLE: name="pg_stats_ext" schema="" table="pg_stats_ext" ctx=Select +FILTER: schema="" table="" column="statistics_name" +STMT: SelectStmt +TRUNCATED: "SELECT dependencies FROM pg_stats_ext WHERE statistics_name = 'func_deps_stat'" +== 381 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND u..." +== 382 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND upper(b) = ''1'' AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = 2 AND u..." +== 383 +-- truncate_limit: 100 +-- IN +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 10..." +== 384 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 10..." +== 385 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) IN (''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4,..." +== 386 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4,..." +== 387 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52, 102, 152) AND upper(b) IN (''1'', ''26'') AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52..." +== 388 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52, 102, 152) AND upper(b) IN (''1'', ''26'') AND (c + 1) IN (2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 52..." +== 389 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 52, 54, 102, 104, 152, 154) AND upper(b) IN (''1'', ''2'', ''26'', ''27'') AND (c + 1) IN (2, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4,..." +== 390 +-- truncate_limit: 100 +-- OR clauses referencing the same attribute +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (..." +== 391 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND (upper(b) = ''1'' OR upper(b) = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (..." +== 392 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 4 OR (a * 2) = 102 OR (a * 2) = 104) AND (upper(b) = ''1'' OR upper(b) = ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (..." +== 393 +-- truncate_limit: 100 +-- OR clauses referencing different attributes +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR upper(b) = ''1'') AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR u..." +== 394 +-- truncate_limit: 100 +-- ANY +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 102]) AND upper(b) = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 395 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 102]) AND upper(b) = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 396 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 4, 102, 104]) AND upper(b) = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 397 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 52, 102, 152]) AND upper(b) = ANY (ARRAY[''1'', ''26'']) AND (c + 1) = 2') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 398 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 52, 102, 152]) AND upper(b) = ANY (ARRAY[''1'', ''26'']) AND (c + 1) = ANY (ARRAY[2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 399 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (ARRAY[2, 4, 52, 54, 102, 104, 152, 154]) AND upper(b) = ANY (ARRAY[''1'', ''2'', ''26'', ''27'']) AND (c + 1) = ANY (ARRAY[2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) = ANY (AR..." +== 400 +-- truncate_limit: 100 +-- ANY with inequalities should not benefit from functional dependencies +-- the estimates however improve thanks to having expression statistics +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) < ANY (ARRAY[2, 102]) AND upper(b) > ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) < ANY (AR..." +== 401 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) >= ANY (ARRAY[2, 102]) AND upper(b) <= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) >= ANY (A..." +== 402 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) <= ANY (ARRAY[2, 4, 102, 104]) AND upper(b) >= ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) <= ANY (A..." +== 403 +-- truncate_limit: 100 +-- ALL (should not benefit from functional dependencies) +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ALL (ARRAY[''1''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 10..." +== 404 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 102) AND upper(b) = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 10..." +== 405 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4, 102, 104) AND upper(b) = ALL (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a * 2) IN (2, 4,..." +== 406 +-- truncate_limit: 100 +-- check the ability to use multiple functional dependencies +CREATE TABLE functional_dependencies_multi ( + a INTEGER, + b INTEGER, + c INTEGER, + d INTEGER +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE functional_dependencies_multi (a int, b int, c int, d int) WITH (autovacuum_enabled=..." +== 407 +-- truncate_limit: 100 +INSERT INTO functional_dependencies_multi (a, b, c, d) + SELECT + mod(i,7), + mod(i,7), + mod(i,11), + mod(i,11) + FROM generate_series(1,5000) s(i) +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO functional_dependencies_multi (a, b, c, d) SELECT ... FROM generate_series(1, 5000) s(i)" +== 408 +-- truncate_limit: 100 +ANALYZE functional_dependencies_multi +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies_multi" +== 409 +-- truncate_limit: 100 +-- estimates without any functional dependencies +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b..." +== 410 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND 0 = b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND 0..." +== 411 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE c = 0 AND d..." +== 412 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b = 0 AND c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b..." +== 413 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND b = 0 AND 0 = c AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND b..." +== 414 +-- truncate_limit: 100 +-- create separate functional dependencies +CREATE STATISTICS functional_dependencies_multi_1 (dependencies) ON a, b FROM functional_dependencies_multi +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS functional_dependencies_multi_1 (dependencies) ON a, b FROM functional_dependen..." +== 415 +-- truncate_limit: 100 +CREATE STATISTICS functional_dependencies_multi_2 (dependencies) ON c, d FROM functional_dependencies_multi +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS functional_dependencies_multi_2 (dependencies) ON c, d FROM functional_dependen..." +== 416 +-- truncate_limit: 100 +ANALYZE functional_dependencies_multi +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE functional_dependencies_multi" +== 417 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b..." +== 418 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND 0 = b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND 0..." +== 419 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE c = 0 AND d..." +== 420 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b = 0 AND c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE a = 0 AND b..." +== 421 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND b = 0 AND 0 = c AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies_multi WHERE 0 = a AND b..." +== 422 +-- truncate_limit: 100 +DROP TABLE functional_dependencies_multi +-- +TABLE: name="functional_dependencies_multi" schema="" table="functional_dependencies_multi" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE functional_dependencies_multi" +== 423 +-- truncate_limit: 100 +-- MCV lists +CREATE TABLE mcv_lists ( + filler1 TEXT, + filler2 NUMERIC, + a INT, + b VARCHAR, + filler3 DATE, + c INT, + d TEXT, + ia INT[] +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcv_lists (filler1 text, filler2 numeric, a int, b varchar, filler3 date, c int, d t..." +== 424 +-- truncate_limit: 100 +-- random data (no MCV list) +INSERT INTO mcv_lists (a, b, c, filler1) + SELECT mod(i,37), mod(i,41), mod(i,43), mod(i,47) FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists (a, b, c, filler1) SELECT ... FROM generate_series(1, 5000) s(i)" +== 425 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 426 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''')" +== 427 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1')" +== 428 +-- truncate_limit: 100 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c FROM mcv_lists" +== 429 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 430 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''')" +== 431 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1')" +== 432 +-- truncate_limit: 100 +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mcv_lists" +== 433 +-- truncate_limit: 100 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS mcv_lists_stats" +== 434 +-- truncate_limit: 100 +-- random data (no MCV list), but with expression +INSERT INTO mcv_lists (a, b, c, filler1) + SELECT i, i, i, i FROM generate_series(1,1000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists (a, b, c, filler1) SELECT i, i, i, i FROM generate_series(1, 1000) s(i)" +== 435 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 436 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11)..." +== 437 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11) = 1 AND mod(c,13) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11)..." +== 438 +-- truncate_limit: 100 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON (mod(a,7)), (mod(b::int,11)), (mod(c,13)) FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats (mcv) ON (mod(a, 7)), (mod(b::int, 11)), (mod(c, 13)) FROM mcv_..." +== 439 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 440 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11)..." +== 441 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11) = 1 AND mod(c,13) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,7) = 1 AND mod(b::int,11)..." +== 442 +-- truncate_limit: 100 +-- 100 distinct combinations, all in the MCV list +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mcv_lists" +== 443 +-- truncate_limit: 100 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS mcv_lists_stats" +== 444 +-- truncate_limit: 100 +INSERT INTO mcv_lists (a, b, c, ia, filler1) + SELECT mod(i,100), mod(i,50), mod(i,25), array[mod(i,25)], i + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists (a, b, c, ia, filler1) SELECT ... FROM generate_series(1, 5000) s(i)" +== 445 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 446 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''')" +== 447 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = a AND ''1'' = b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = a AND ''1'' = b')" +== 448 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 1 AND b < ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 1 AND b < ''1''')" +== 449 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > a AND ''1'' > b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > a AND ''1'' > b')" +== 450 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 0 AND b <= ''0''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 0 AND b <= ''0''')" +== 451 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 0 >= a AND ''0'' >= b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 0 >= a AND ''0'' >= b')" +== 452 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1')" +== 453 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND b < ''1'' AND c < 5') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND b < ''1'' AND c < 5')" +== 454 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND ''1'' > b AND 5 > c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND ''1'' > b AND 5 > c')" +== 455 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 4 AND b <= ''0'' AND c <= 4') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 4 AND b <= ''0'' AND c <= 4')" +== 456 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 4 >= a AND ''0'' >= b AND 4 >= c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 4 >= a AND ''0'' >= b AND 4 >= c')" +== 457 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1')" +== 458 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR ..." +== 459 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52) AND b IN ( ''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52) AND b IN ( ..." +== 460 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52, NULL) AND b IN ( ''1'', ''2'', NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52, NULL) AND b..." +== 461 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[1, 2, 51, 52]) A..." +== 462 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[NULL, 1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2'', NULL])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[NULL, 1, 2, 51, ..." +== 463 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, 2, 3]) AND b IN (''1'', ''2'', ''3'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, 2, 3]) AND b..." +== 464 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, NULL, 2, 3]) AND b IN (''1'', ''2'', NULL, ''3'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, NULL, 2, 3])..." +== 465 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > A..." +== 466 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > ANY (ARRAY[1, 2, 3, NULL])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > A..." +== 467 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN (''1'', ''2'', ''3'') AND c > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN ..." +== 468 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN (''1'', ''2'', NULL, ''3'') AND c > ANY (ARRAY[1, 2, NULL, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN ..." +== 469 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[4,5]) AND 4 = ANY(ia)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[4,5]) AND 4 = AN..." +== 470 +-- truncate_limit: 100 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c, ia FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c, ia FROM mcv_lists" +== 471 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 472 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''')" +== 473 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = a AND ''1'' = b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = a AND ''1'' = b')" +== 474 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 1 AND b < ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 1 AND b < ''1''')" +== 475 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > a AND ''1'' > b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > a AND ''1'' > b')" +== 476 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 0 AND b <= ''0''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 0 AND b <= ''0''')" +== 477 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 0 >= a AND ''0'' >= b') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 0 >= a AND ''0'' >= b')" +== 478 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1'' AND c = 1')" +== 479 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND b < ''1'' AND c < 5') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND b < ''1'' AND c < 5')" +== 480 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND ''1'' > b AND 5 > c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < 5 AND ''1'' > b AND 5 > c')" +== 481 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 4 AND b <= ''0'' AND c <= 4') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= 4 AND b <= ''0'' AND c <= 4')" +== 482 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 4 >= a AND ''0'' >= b AND 4 >= c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 4 >= a AND ''0'' >= b AND 4 >= c')" +== 483 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1')" +== 484 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR ..." +== 485 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''1'' OR c = 1 OR ..." +== 486 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52) AND b IN ( ''1'', ''2'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52) AND b IN ( ..." +== 487 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52, NULL) AND b IN ( ''1'', ''2'', NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (1, 2, 51, 52, NULL) AND b..." +== 488 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2''])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[1, 2, 51, 52]) A..." +== 489 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[NULL, 1, 2, 51, 52]) AND b = ANY (ARRAY[''1'', ''2'', NULL])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[NULL, 1, 2, 51, ..." +== 490 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, 2, 3]) AND b IN (''1'', ''2'', ''3'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, 2, 3]) AND b..." +== 491 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, NULL, 2, 3]) AND b IN (''1'', ''2'', NULL, ''3'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a <= ANY (ARRAY[1, NULL, 2, 3])..." +== 492 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > A..." +== 493 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > ANY (ARRAY[1, 2, 3, NULL])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND c > A..." +== 494 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN (''1'', ''2'', ''3'') AND c > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN ..." +== 495 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN (''1'', ''2'', NULL, ''3'') AND c > ANY (ARRAY[1, 2, NULL, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a < ALL (ARRAY[4, 5]) AND b IN ..." +== 496 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[4,5]) AND 4 = ANY(ia)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = ANY (ARRAY[4,5]) AND 4 = AN..." +== 497 +-- truncate_limit: 100 +-- check change of unrelated column type does not reset the MCV statistics +ALTER TABLE mcv_lists ALTER COLUMN d TYPE VARCHAR(64) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mcv_lists ALTER COLUMN d TYPE varchar(64)" +== 498 +-- truncate_limit: 100 +SELECT d.stxdmcv IS NOT NULL + FROM pg_statistic_ext s, pg_statistic_ext_data d + WHERE s.stxname = 'mcv_lists_stats' + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FILTER: schema="" table="s" column="stxname" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT d.stxdmcv IS NOT NULL FROM pg_statistic_ext s, pg_statistic_ext_data d WHERE ..." +== 499 +-- truncate_limit: 100 +-- check change of column type resets the MCV statistics +ALTER TABLE mcv_lists ALTER COLUMN c TYPE numeric +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE mcv_lists ALTER COLUMN c TYPE numeric" +== 500 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''')" +== 501 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 502 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 AND b = ''1''')" +== 503 +-- truncate_limit: 100 +-- 100 distinct combinations, all in the MCV list, but with expressions +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mcv_lists" +== 504 +-- truncate_limit: 100 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS mcv_lists_stats" +== 505 +-- truncate_limit: 100 +INSERT INTO mcv_lists (a, b, c, filler1) + SELECT i, i, i, i FROM generate_series(1,1000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists (a, b, c, filler1) SELECT i, i, i, i FROM generate_series(1, 1000) s(i)" +== 506 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 507 +-- truncate_limit: 100 +-- without any stats on the expressions, we have to use default selectivities, which +-- is why the estimates here are different from the pre-computed case above + +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10..." +== 508 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::in..." +== 509 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10) < 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10..." +== 510 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::in..." +== 511 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1 AND mod(c,5) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10..." +== 512 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10) = 1 OR mod(c,25) = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10)..." +== 513 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NULL) AND mod(b::int,10) IN ( 1, 2, NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NUL..." +== 514 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51, 52]) AND mod(b::int,10) = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51..." +== 515 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL, 2, 3]) AND mod(b::int,10) IN (1, 2, NULL, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL..." +== 516 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) AND mod(b::int,10) IN (1, 2, 3) AND mod(c,5) > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) A..." +== 517 +-- truncate_limit: 100 +-- create statistics with expressions only (we create three separate stats, in order not to build more complex extended stats) +CREATE STATISTICS mcv_lists_stats_1 ON (mod(a,20)) FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats_1 ON (mod(a, 20)) FROM mcv_lists" +== 518 +-- truncate_limit: 100 +CREATE STATISTICS mcv_lists_stats_2 ON (mod(b::int,10)) FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats_2 ON (mod(b::int, 10)) FROM mcv_lists" +== 519 +-- truncate_limit: 100 +CREATE STATISTICS mcv_lists_stats_3 ON (mod(c,5)) FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats_3 ON (mod(c, 5)) FROM mcv_lists" +== 520 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 521 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10..." +== 522 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::in..." +== 523 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10) < 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10..." +== 524 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::in..." +== 525 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1 AND mod(c,5) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10..." +== 526 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10) = 1 OR mod(c,25) = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10)..." +== 527 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NULL) AND mod(b::int,10) IN ( 1, 2, NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NUL..." +== 528 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51, 52]) AND mod(b::int,10) = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51..." +== 529 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL, 2, 3]) AND mod(b::int,10) IN (1, 2, NULL, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL..." +== 530 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) AND mod(b::int,10) IN (1, 2, 3) AND mod(c,5) > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) A..." +== 531 +-- truncate_limit: 100 +DROP STATISTICS mcv_lists_stats_1 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS mcv_lists_stats_1" +== 532 +-- truncate_limit: 100 +DROP STATISTICS mcv_lists_stats_2 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS mcv_lists_stats_2" +== 533 +-- truncate_limit: 100 +DROP STATISTICS mcv_lists_stats_3 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS mcv_lists_stats_3" +== 534 +-- truncate_limit: 100 +-- create statistics with both MCV and expressions +CREATE STATISTICS mcv_lists_stats (mcv) ON (mod(a,20)), (mod(b::int,10)), (mod(c,5)) FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats (mcv) ON (mod(a, 20)), (mod(b::int, 10)), (mod(c, 5)) FROM mcv_..." +== 535 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 536 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10..." +== 537 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 = mod(a,20) AND 1 = mod(b::in..." +== 538 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10) < 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < 1 AND mod(b::int,10..." +== 539 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::int,10)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE 1 > mod(a,20) AND 1 > mod(b::in..." +== 540 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10) = 1 AND mod(c,5) = 1') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 AND mod(b::int,10..." +== 541 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10) = 1 OR mod(c,25) = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10)..." +== 542 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NULL) AND mod(b::int,10) IN ( 1, 2, NULL)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) IN (1, 2, 51, 52, NUL..." +== 543 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51, 52]) AND mod(b::int,10) = ANY (ARRAY[1, 2])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = ANY (ARRAY[1, 2, 51..." +== 544 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL, 2, 3]) AND mod(b::int,10) IN (1, 2, NULL, 3)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) <= ANY (ARRAY[1, NULL..." +== 545 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) AND mod(b::int,10) IN (1, 2, 3) AND mod(c,5) > ANY (ARRAY[1, 2, 3])') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) < ALL (ARRAY[4, 5]) A..." +== 546 +-- truncate_limit: 100 +-- we can't use the statistic for OR clauses that are not fully covered (missing 'd' attribute) +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10) = 1 OR mod(c,5) = 1 OR d IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE mod(a,20) = 1 OR mod(b::int,10)..." +== 547 +-- truncate_limit: 100 +-- 100 distinct combinations with NULL values, all in the MCV list +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mcv_lists" +== 548 +-- truncate_limit: 100 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS mcv_lists_stats" +== 549 +-- truncate_limit: 100 +INSERT INTO mcv_lists (a, b, c, filler1) + SELECT + (CASE WHEN mod(i,100) = 1 THEN NULL ELSE mod(i,100) END), + (CASE WHEN mod(i,50) = 1 THEN NULL ELSE mod(i,50) END), + (CASE WHEN mod(i,25) = 1 THEN NULL ELSE mod(i,25) END), + i + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists (a, b, c, filler1) SELECT ... FROM generate_series(1, 5000) s(i)" +== 550 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 551 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL')" +== 552 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL AND c IS NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL AND c I..." +== 553 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NOT NULL')" +== 554 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NOT NULL AND b IS NULL AND c IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NOT NULL AND b IS NULL AND..." +== 555 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (0, 1) AND b IN (''0'', ''1'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (0, 1) AND b IN (''0'', ''..." +== 556 +-- truncate_limit: 100 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, c FROM mcv_lists" +== 557 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 558 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL')" +== 559 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL AND c IS NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NULL AND c I..." +== 560 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND b IS NOT NULL')" +== 561 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NOT NULL AND b IS NULL AND c IS NOT NULL') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NOT NULL AND b IS NULL AND..." +== 562 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (0, 1) AND b IN (''0'', ''1'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IN (0, 1) AND b IN (''0'', ''..." +== 563 +-- truncate_limit: 100 +-- test pg_mcv_list_items with a very simple (single item) MCV list +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mcv_lists" +== 564 +-- truncate_limit: 100 +INSERT INTO mcv_lists (a, b, c) SELECT 1, 2, 3 FROM generate_series(1,1000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists (a, b, c) SELECT 1, 2, 3 FROM generate_series(1, 1000) s(i)" +== 565 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 566 +-- truncate_limit: 100 +SELECT m.* + FROM pg_statistic_ext s, pg_statistic_ext_data d, + pg_mcv_list_items(d.stxdmcv) m + WHERE s.stxname = 'mcv_lists_stats' + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FUNCTION: name="pg_mcv_list_items" function="pg_mcv_list_items" schema="" ctx=Call +FILTER: schema="" table="s" column="stxname" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT m.* FROM pg_statistic_ext s, pg_statistic_ext_data d, pg_mcv_list_items(d.stxdmcv) m WHERE..." +== 567 +-- truncate_limit: 100 +-- 2 distinct combinations with NULL values, all in the MCV list +TRUNCATE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE mcv_lists" +== 568 +-- truncate_limit: 100 +DROP STATISTICS mcv_lists_stats +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS mcv_lists_stats" +== 569 +-- truncate_limit: 100 +INSERT INTO mcv_lists (a, b, c, d) + SELECT + NULL, -- always NULL + (CASE WHEN mod(i,2) = 0 THEN NULL ELSE 'x' END), + (CASE WHEN mod(i,2) = 0 THEN NULL ELSE 0 END), + (CASE WHEN mod(i,2) = 0 THEN NULL ELSE 'x' END) + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists (a, b, c, d) SELECT ... FROM generate_series(1, 5000) s(i)" +== 570 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 571 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''')" +== 572 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''x'' OR d = ''x''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''x'' OR d = ''x''')" +== 573 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND (b = ''x'' OR d = ''x'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND (b = ''x'' OR d =..." +== 574 +-- truncate_limit: 100 +-- create statistics +CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, d FROM mcv_lists +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_stats (mcv) ON a, b, d FROM mcv_lists" +== 575 +-- truncate_limit: 100 +ANALYZE mcv_lists +-- +TABLE: name="mcv_lists" schema="" table="mcv_lists" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists" +== 576 +-- truncate_limit: 100 +-- test pg_mcv_list_items with MCV list containing variable-length data and NULLs +SELECT m.* + FROM pg_statistic_ext s, pg_statistic_ext_data d, + pg_mcv_list_items(d.stxdmcv) m + WHERE s.stxname = 'mcv_lists_stats' + AND d.stxoid = s.oid +-- +TABLE: name="pg_statistic_ext" schema="" table="pg_statistic_ext" ctx=Select +TABLE: name="pg_statistic_ext_data" schema="" table="pg_statistic_ext_data" ctx=Select +ALIAS: "d"="pg_statistic_ext_data" +ALIAS: "s"="pg_statistic_ext" +FUNCTION: name="pg_mcv_list_items" function="pg_mcv_list_items" schema="" ctx=Call +FILTER: schema="" table="s" column="stxname" +FILTER: schema="" table="d" column="stxoid" +FILTER: schema="" table="s" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT m.* FROM pg_statistic_ext s, pg_statistic_ext_data d, pg_mcv_list_items(d.stxdmcv) m WHERE..." +== 577 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE b = ''x'' OR d = ''x''')" +== 578 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''x'' OR d = ''x''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a = 1 OR b = ''x'' OR d = ''x''')" +== 579 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND (b = ''x'' OR d = ''x'')') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists WHERE a IS NULL AND (b = ''x'' OR d =..." +== 580 +-- truncate_limit: 100 +-- mcv with pass-by-ref fixlen types, e.g. uuid +CREATE TABLE mcv_lists_uuid ( + a UUID, + b UUID, + c UUID +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcv_lists_uuid (a uuid, b uuid, c uuid) WITH (autovacuum_enabled=off)" +== 581 +-- truncate_limit: 100 +INSERT INTO mcv_lists_uuid (a, b, c) + SELECT + fipshash(mod(i,100)::text)::uuid, + fipshash(mod(i,50)::text)::uuid, + fipshash(mod(i,25)::text)::uuid + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DML +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists_uuid (a, b, c) SELECT ... FROM generate_series(1, 5000) s(i)" +== 582 +-- truncate_limit: 100 +ANALYZE mcv_lists_uuid +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_uuid" +== 583 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND b = ''e7f6c011-776e-8db7-cd33-0b54174fd76f''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-c..." +== 584 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND b = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND c = ''e7f6c011-776e-8db7-cd33-0b54174fd76f''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-c..." +== 585 +-- truncate_limit: 100 +CREATE STATISTICS mcv_lists_uuid_stats (mcv) ON a, b, c + FROM mcv_lists_uuid +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_uuid_stats (mcv) ON a, b, c FROM mcv_lists_uuid" +== 586 +-- truncate_limit: 100 +ANALYZE mcv_lists_uuid +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_uuid" +== 587 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND b = ''e7f6c011-776e-8db7-cd33-0b54174fd76f''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-c..." +== 588 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND b = ''e7f6c011-776e-8db7-cd33-0b54174fd76f'' AND c = ''e7f6c011-776e-8db7-cd33-0b54174fd76f''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_uuid WHERE a = ''e7f6c011-776e-8db7-c..." +== 589 +-- truncate_limit: 100 +DROP TABLE mcv_lists_uuid +-- +TABLE: name="mcv_lists_uuid" schema="" table="mcv_lists_uuid" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcv_lists_uuid" +== 590 +-- truncate_limit: 100 +-- mcv with arrays +CREATE TABLE mcv_lists_arrays ( + a TEXT[], + b NUMERIC[], + c INT[] +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists_arrays" schema="" table="mcv_lists_arrays" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcv_lists_arrays (a text[], b numeric[], c int[]) WITH (autovacuum_enabled=off)" +== 591 +-- truncate_limit: 100 +INSERT INTO mcv_lists_arrays (a, b, c) + SELECT + ARRAY[fipshash((i/100)::text), fipshash((i/100-1)::text), fipshash((i/100+1)::text)], + ARRAY[(i/100-1)::numeric/1000, (i/100)::numeric/1000, (i/100+1)::numeric/1000], + ARRAY[(i/100-1), i/100, (i/100+1)] + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists_arrays" schema="" table="mcv_lists_arrays" ctx=DML +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists_arrays (a, b, c) SELECT ... FROM generate_series(1, 5000) s(i)" +== 592 +-- truncate_limit: 100 +CREATE STATISTICS mcv_lists_arrays_stats (mcv) ON a, b, c + FROM mcv_lists_arrays +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_arrays_stats (mcv) ON a, b, c FROM mcv_lists_arrays" +== 593 +-- truncate_limit: 100 +ANALYZE mcv_lists_arrays +-- +TABLE: name="mcv_lists_arrays" schema="" table="mcv_lists_arrays" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_arrays" +== 594 +-- truncate_limit: 100 +-- mcv with bool +CREATE TABLE mcv_lists_bool ( + a BOOL, + b BOOL, + c BOOL +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists_bool" schema="" table="mcv_lists_bool" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcv_lists_bool (a bool, b bool, c bool) WITH (autovacuum_enabled=off)" +== 595 +-- truncate_limit: 100 +INSERT INTO mcv_lists_bool (a, b, c) + SELECT + (mod(i,2) = 0), (mod(i,4) = 0), (mod(i,8) = 0) + FROM generate_series(1,10000) s(i) +-- +TABLE: name="mcv_lists_bool" schema="" table="mcv_lists_bool" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists_bool (a, b, c) SELECT ... FROM generate_series(1, 10000) s(i)" +== 596 +-- truncate_limit: 100 +ANALYZE mcv_lists_bool +-- +TABLE: name="mcv_lists_bool" schema="" table="mcv_lists_bool" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_bool" +== 597 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c')" +== 598 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND c')" +== 599 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND NOT b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND NOT b AND c')" +== 600 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND NOT c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND NOT c')" +== 601 +-- truncate_limit: 100 +CREATE STATISTICS mcv_lists_bool_stats (mcv) ON a, b, c + FROM mcv_lists_bool +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_bool_stats (mcv) ON a, b, c FROM mcv_lists_bool" +== 602 +-- truncate_limit: 100 +ANALYZE mcv_lists_bool +-- +TABLE: name="mcv_lists_bool" schema="" table="mcv_lists_bool" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_bool" +== 603 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE a AND b AND c')" +== 604 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND c')" +== 605 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND NOT b AND c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND NOT b AND c')" +== 606 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND NOT c') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND b AND NOT c')" +== 607 +-- truncate_limit: 100 +-- mcv covering just a small fraction of data +CREATE TABLE mcv_lists_partial ( + a INT, + b INT, + c INT +) +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcv_lists_partial (a int, b int, c int)" +== 608 +-- truncate_limit: 100 +-- 10 frequent groups, each with 100 elements +INSERT INTO mcv_lists_partial (a, b, c) + SELECT + mod(i,10), + mod(i,10), + mod(i,10) + FROM generate_series(0,999) s(i) +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists_partial (a, b, c) SELECT ... FROM generate_series(0, 999) s(i)" +== 609 +-- truncate_limit: 100 +-- 100 groups that will make it to the MCV list (includes the 10 frequent ones) +INSERT INTO mcv_lists_partial (a, b, c) + SELECT + i, + i, + i + FROM generate_series(0,99) s(i) +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists_partial (a, b, c) SELECT i, i, i FROM generate_series(0, 99) s(i)" +== 610 +-- truncate_limit: 100 +-- 4000 groups in total, most of which won't make it (just a single item) +INSERT INTO mcv_lists_partial (a, b, c) + SELECT + i, + i, + i + FROM generate_series(0,3999) s(i) +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists_partial (a, b, c) SELECT i, i, i FROM generate_series(0, 3999) s(i)" +== 611 +-- truncate_limit: 100 +ANALYZE mcv_lists_partial +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_partial" +== 612 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c =..." +== 613 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 0')" +== 614 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 AND b = 10 AND c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 AND b = 10 AND c..." +== 615 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 OR b = 10 OR c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 OR b = 10 OR c =..." +== 616 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c =..." +== 617 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 10')" +== 618 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0 AND c = 0) OR (a = 1 AND b = 1 AND c = 1) OR (a = 2 AND b = 2 AND c = 2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0 AND c ..." +== 619 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0) OR (a = 0 AND c = 0) OR (b = 0 AND c = 0)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0) OR (a..." +== 620 +-- truncate_limit: 100 +CREATE STATISTICS mcv_lists_partial_stats (mcv) ON a, b, c + FROM mcv_lists_partial +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_partial_stats (mcv) ON a, b, c FROM mcv_lists_partial" +== 621 +-- truncate_limit: 100 +ANALYZE mcv_lists_partial +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_partial" +== 622 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c =..." +== 623 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 0')" +== 624 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 AND b = 10 AND c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 AND b = 10 AND c..." +== 625 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 OR b = 10 OR c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 10 OR b = 10 OR c =..." +== 626 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 AND b = 0 AND c =..." +== 627 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 10') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE a = 0 OR b = 0 OR c = 10')" +== 628 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0 AND c = 0) OR (a = 1 AND b = 1 AND c = 1) OR (a = 2 AND b = 2 AND c = 2)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0 AND c ..." +== 629 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0) OR (a = 0 AND c = 0) OR (b = 0 AND c = 0)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_partial WHERE (a = 0 AND b = 0) OR (a..." +== 630 +-- truncate_limit: 100 +DROP TABLE mcv_lists_partial +-- +TABLE: name="mcv_lists_partial" schema="" table="mcv_lists_partial" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcv_lists_partial" +== 631 +-- truncate_limit: 100 +-- check the ability to use multiple MCV lists +CREATE TABLE mcv_lists_multi ( + a INTEGER, + b INTEGER, + c INTEGER, + d INTEGER +) +WITH (autovacuum_enabled = off) +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mcv_lists_multi (a int, b int, c int, d int) WITH (autovacuum_enabled=off)" +== 632 +-- truncate_limit: 100 +INSERT INTO mcv_lists_multi (a, b, c, d) + SELECT + mod(i,5), + mod(i,5), + mod(i,7), + mod(i,7) + FROM generate_series(1,5000) s(i) +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mcv_lists_multi (a, b, c, d) SELECT ... FROM generate_series(1, 5000) s(i)" +== 633 +-- truncate_limit: 100 +ANALYZE mcv_lists_multi +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_multi" +== 634 +-- truncate_limit: 100 +-- estimates without any mcv statistics +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0')" +== 635 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE c = 0 AND d = 0')" +== 636 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 AND c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 AND c = 0')" +== 637 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 OR c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 OR c = 0')" +== 638 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0 AND c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0 AND c = 0..." +== 639 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE (a = 0 AND b = 0) OR (c = 0 AND d = 0)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE (a = 0 AND b = 0) OR (c =..." +== 640 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 OR b = 0 OR c = 0 OR d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 OR b = 0 OR c = 0 O..." +== 641 +-- truncate_limit: 100 +-- create separate MCV statistics +CREATE STATISTICS mcv_lists_multi_1 (mcv) ON a, b FROM mcv_lists_multi +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_multi_1 (mcv) ON a, b FROM mcv_lists_multi" +== 642 +-- truncate_limit: 100 +CREATE STATISTICS mcv_lists_multi_2 (mcv) ON c, d FROM mcv_lists_multi +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS mcv_lists_multi_2 (mcv) ON c, d FROM mcv_lists_multi" +== 643 +-- truncate_limit: 100 +ANALYZE mcv_lists_multi +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE mcv_lists_multi" +== 644 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0')" +== 645 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE c = 0 AND d = 0')" +== 646 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 AND c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 AND c = 0')" +== 647 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 OR c = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE b = 0 OR c = 0')" +== 648 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0 AND c = 0 AND d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 AND b = 0 AND c = 0..." +== 649 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE (a = 0 AND b = 0) OR (c = 0 AND d = 0)') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE (a = 0 AND b = 0) OR (c =..." +== 650 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 OR b = 0 OR c = 0 OR d = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_multi WHERE a = 0 OR b = 0 OR c = 0 O..." +== 651 +-- truncate_limit: 100 +DROP TABLE mcv_lists_multi +-- +TABLE: name="mcv_lists_multi" schema="" table="mcv_lists_multi" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mcv_lists_multi" +== 652 +-- truncate_limit: 100 +-- statistics on integer expressions +CREATE TABLE expr_stats (a int, b int, c int) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE expr_stats (a int, b int, c int)" +== 653 +-- truncate_limit: 100 +INSERT INTO expr_stats SELECT mod(i,10), mod(i,10), mod(i,10) FROM generate_series(1,1000) s(i) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO expr_stats SELECT mod(i, 10), mod(i, 10), mod(i, 10) FROM generate_series(1, 1000) s(i)" +== 654 +-- truncate_limit: 100 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE expr_stats" +== 655 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (2*a) = 0 AND (3*b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (2*a) = 0 AND (3*b) = 0')" +== 656 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (a+b) = 0 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (a+b) = 0 AND (a-b) = 0')" +== 657 +-- truncate_limit: 100 +CREATE STATISTICS expr_stats_1 (mcv) ON (a+b), (a-b), (2*a), (3*b) FROM expr_stats +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS expr_stats_1 (mcv) ON (a + b), (a - b), (2 * a), (3 * b) FROM expr_stats" +== 658 +-- truncate_limit: 100 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE expr_stats" +== 659 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (2*a) = 0 AND (3*b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (2*a) = 0 AND (3*b) = 0')" +== 660 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (a+b) = 0 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE (a+b) = 0 AND (a-b) = 0')" +== 661 +-- truncate_limit: 100 +DROP STATISTICS expr_stats_1 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS expr_stats_1" +== 662 +-- truncate_limit: 100 +DROP TABLE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE expr_stats" +== 663 +-- truncate_limit: 100 +-- statistics on a mix columns and expressions +CREATE TABLE expr_stats (a int, b int, c int) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE expr_stats (a int, b int, c int)" +== 664 +-- truncate_limit: 100 +INSERT INTO expr_stats SELECT mod(i,10), mod(i,10), mod(i,10) FROM generate_series(1,1000) s(i) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO expr_stats SELECT mod(i, 10), mod(i, 10), mod(i, 10) FROM generate_series(1, 1000) s(i)" +== 665 +-- truncate_limit: 100 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE expr_stats" +== 666 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (2*a) = 0 AND (3*b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (2*a) = 0 AND (3*b) ..." +== 667 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 3 AND b = 3 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 3 AND b = 3 AND (a-b) = 0')" +== 668 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND b = 1 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND b = 1 AND (a-b) = 0')" +== 669 +-- truncate_limit: 100 +CREATE STATISTICS expr_stats_1 (mcv) ON a, b, (2*a), (3*b), (a+b), (a-b) FROM expr_stats +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS expr_stats_1 (mcv) ON a, b, (2 * a), (3 * b), (a + b), (a - b) FROM expr_stats" +== 670 +-- truncate_limit: 100 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE expr_stats" +== 671 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (2*a) = 0 AND (3*b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (2*a) = 0 AND (3*b) ..." +== 672 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 3 AND b = 3 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 3 AND b = 3 AND (a-b) = 0')" +== 673 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND b = 1 AND (a-b) = 0') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND b = 1 AND (a-b) = 0')" +== 674 +-- truncate_limit: 100 +DROP TABLE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE expr_stats" +== 675 +-- truncate_limit: 100 +-- statistics on expressions with different data types +CREATE TABLE expr_stats (a int, b name, c text) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE expr_stats (a int, b name, c text)" +== 676 +-- truncate_limit: 100 +INSERT INTO expr_stats SELECT mod(i,10), fipshash(mod(i,10)::text), fipshash(mod(i,10)::text) FROM generate_series(1,1000) s(i) +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO expr_stats SELECT ... FROM generate_series(1, 1000) s(i)" +== 677 +-- truncate_limit: 100 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE expr_stats" +== 678 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (b || c) <= ''z'' AND (c || b) >= ''0''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (b || c) <= ''z'' AN..." +== 679 +-- truncate_limit: 100 +CREATE STATISTICS expr_stats_1 (mcv) ON a, b, (b || c), (c || b) FROM expr_stats +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS expr_stats_1 (mcv) ON a, b, (b || c), (c || b) FROM expr_stats" +== 680 +-- truncate_limit: 100 +ANALYZE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE expr_stats" +== 681 +-- truncate_limit: 100 +SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (b || c) <= ''z'' AND (c || b) >= ''0''') +-- +FUNCTION: name="check_estimated_rows" function="check_estimated_rows" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM check_estimated_rows('SELECT * FROM expr_stats WHERE a = 0 AND (b || c) <= ''z'' AN..." +== 682 +-- truncate_limit: 100 +DROP TABLE expr_stats +-- +TABLE: name="expr_stats" schema="" table="expr_stats" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE expr_stats" +== 683 +-- truncate_limit: 100 +-- test handling of a mix of compatible and incompatible expressions +CREATE TABLE expr_stats_incompatible_test ( + c0 double precision, + c1 boolean NOT NULL +) +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE expr_stats_incompatible_test (c0 double precision, c1 boolean NOT NULL)" +== 684 +-- truncate_limit: 100 +CREATE STATISTICS expr_stat_comp_1 ON c0, c1 FROM expr_stats_incompatible_test +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS expr_stat_comp_1 ON c0, c1 FROM expr_stats_incompatible_test" +== 685 +-- truncate_limit: 100 +INSERT INTO expr_stats_incompatible_test VALUES (1234,false), (5678,true) +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO expr_stats_incompatible_test VALUES (1234, false), (5678, true)" +== 686 +-- truncate_limit: 100 +ANALYZE expr_stats_incompatible_test +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE expr_stats_incompatible_test" +== 687 +-- truncate_limit: 100 +SELECT c0 FROM ONLY expr_stats_incompatible_test WHERE +( + upper('x') LIKE ('x'||('[0,1]'::int4range)) + AND + (c0 IN (0, 1) OR c1) +) +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FUNCTION: name="upper" function="upper" schema="" ctx=Call +FILTER: schema="" table="" column="c0" +FILTER: schema="" table="" column="c1" +STMT: SelectStmt +TRUNCATED: "SELECT c0 FROM ONLY expr_stats_incompatible_test WHERE ..." +== 688 +-- truncate_limit: 100 +DROP TABLE expr_stats_incompatible_test +-- +TABLE: name="expr_stats_incompatible_test" schema="" table="expr_stats_incompatible_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE expr_stats_incompatible_test" +== 689 +-- truncate_limit: 100 +-- Permission tests. Users should not be able to see specific data values in +-- the extended statistics, if they lack permission to see those values in +-- the underlying table. +|-- +-- Currently this is only relevant for MCV stats. +CREATE SCHEMA tststats +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA tststats" +== 690 +-- truncate_limit: 100 +CREATE TABLE tststats.priv_test_tbl ( + a int, + b int +) +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tststats.priv_test_tbl (a int, b int)" +== 691 +-- truncate_limit: 100 +INSERT INTO tststats.priv_test_tbl + SELECT mod(i,5), mod(i,10) FROM generate_series(1,100) s(i) +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DML +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="mod" function="mod" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tststats.priv_test_tbl SELECT mod(i, 5), mod(i, 10) FROM generate_series(1, 100) s(i)" +== 692 +-- truncate_limit: 100 +CREATE STATISTICS tststats.priv_test_stats (mcv) ON a, b + FROM tststats.priv_test_tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS tststats.priv_test_stats (mcv) ON a, b FROM tststats.priv_test_tbl" +== 693 +-- truncate_limit: 100 +ANALYZE tststats.priv_test_tbl +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE tststats.priv_test_tbl" +== 694 +-- truncate_limit: 100 +-- Check printing info about extended statistics by \dX +create table stts_t1 (a int, b int) +-- +TABLE: name="stts_t1" schema="" table="stts_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stts_t1 (a int, b int)" +== 695 +-- truncate_limit: 100 +create statistics (ndistinct) on a, b from stts_t1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS (ndistinct) ON a, b FROM stts_t1" +== 696 +-- truncate_limit: 100 +create statistics (ndistinct, dependencies) on a, b from stts_t1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS (ndistinct, dependencies) ON a, b FROM stts_t1" +== 697 +-- truncate_limit: 100 +create statistics (ndistinct, dependencies, mcv) on a, b from stts_t1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS (ndistinct, dependencies, mcv) ON a, b FROM stts_t1" +== 698 +-- truncate_limit: 100 +create table stts_t2 (a int, b int, c int) +-- +TABLE: name="stts_t2" schema="" table="stts_t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stts_t2 (a int, b int, c int)" +== 699 +-- truncate_limit: 100 +create statistics on b, c from stts_t2 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ON b, c FROM stts_t2" +== 700 +-- truncate_limit: 100 +create table stts_t3 (col1 int, col2 int, col3 int) +-- +TABLE: name="stts_t3" schema="" table="stts_t3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stts_t3 (col1 int, col2 int, col3 int)" +== 701 +-- truncate_limit: 100 +create statistics stts_hoge on col1, col2, col3 from stts_t3 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS stts_hoge ON col1, col2, col3 FROM stts_t3" +== 702 +-- truncate_limit: 100 +create schema stts_s1 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA stts_s1" +== 703 +-- truncate_limit: 100 +create schema stts_s2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA stts_s2" +== 704 +-- truncate_limit: 100 +create statistics stts_s1.stts_foo on col1, col2 from stts_t3 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS stts_s1.stts_foo ON col1, col2 FROM stts_t3" +== 705 +-- truncate_limit: 100 +create statistics stts_s2.stts_yama (dependencies, mcv) on col1, col3 from stts_t3 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS stts_s2.stts_yama (dependencies, mcv) ON col1, col3 FROM stts_t3" +== 706 +-- truncate_limit: 100 +insert into stts_t1 select i,i from generate_series(1,100) i +-- +TABLE: name="stts_t1" schema="" table="stts_t1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO stts_t1 SELECT i, i FROM generate_series(1, 100) i" +== 707 +-- truncate_limit: 100 +analyze stts_t1 +-- +TABLE: name="stts_t1" schema="" table="stts_t1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE stts_t1" +== 708 +-- truncate_limit: 100 +set search_path to public, stts_s1, stts_s2, tststats +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO public, stts_s1, stts_s2, tststats" +== 709 +-- truncate_limit: 100 +create statistics (mcv) ON a, b, (a+b), (a-b) FROM stts_t1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS (mcv) ON a, b, (a + b), (a - b) FROM stts_t1" +== 710 +-- truncate_limit: 100 +create statistics (mcv) ON a, b, (a+b), (a-b) FROM stts_t1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS (mcv) ON a, b, (a + b), (a - b) FROM stts_t1" +== 711 +-- truncate_limit: 100 +create statistics (mcv) ON (a+b), (a-b) FROM stts_t1 +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS (mcv) ON (a + b), (a - b) FROM stts_t1" +== 712 +-- truncate_limit: 100 +drop statistics stts_t1_a_b_expr_expr_stat +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS stts_t1_a_b_expr_expr_stat" +== 713 +-- truncate_limit: 100 +drop statistics stts_t1_a_b_expr_expr_stat1 +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS stts_t1_a_b_expr_expr_stat1" +== 714 +-- truncate_limit: 100 +drop statistics stts_t1_expr_expr_stat +-- +STMT: DropStmt +TRUNCATED: "DROP STATISTICS stts_t1_expr_expr_stat" +== 715 +-- truncate_limit: 100 +set search_path to public, stts_s1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO public, stts_s1" +== 716 +-- truncate_limit: 100 +create role regress_stats_ext nosuperuser +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_stats_ext WITH NOSUPERUSER" +== 717 +-- truncate_limit: 100 +set role regress_stats_ext +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_stats_ext" +== 718 +-- truncate_limit: 100 +reset role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 719 +-- truncate_limit: 100 +drop table stts_t1, stts_t2, stts_t3 +-- +TABLE: name="stts_t1" schema="" table="stts_t1" ctx=DDL +TABLE: name="stts_t2" schema="" table="stts_t2" ctx=DDL +TABLE: name="stts_t3" schema="" table="stts_t3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE stts_t1, stts_t2, stts_t3" +== 720 +-- truncate_limit: 100 +drop schema stts_s1, stts_s2 cascade +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA stts_s1, stts_s2 CASCADE" +== 721 +-- truncate_limit: 100 +drop user regress_stats_ext +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_stats_ext" +== 722 +-- truncate_limit: 100 +reset search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 723 +-- truncate_limit: 100 +-- User with no access +CREATE USER regress_stats_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_stats_user1" +== 724 +-- truncate_limit: 100 +GRANT USAGE ON SCHEMA tststats TO regress_stats_user1 +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON SCHEMA tststats TO regress_stats_user1" +== 725 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 726 +-- truncate_limit: 100 +SELECT * FROM tststats.priv_test_tbl +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_tbl" +== 727 +-- truncate_limit: 100 +-- Permission denied + +-- Check individual columns if we don't have table privilege +SELECT * FROM tststats.priv_test_tbl + WHERE a = 1 and tststats.priv_test_tbl.* > (1, 1) is not null +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_tbl WHERE a = 1 AND tststats.priv_test_tbl.* > (1, 1) IS NOT NULL" +== 728 +-- truncate_limit: 100 +-- Attempt to gain access using a leaky operator +CREATE FUNCTION op_leak(int, int) RETURNS bool + AS 'BEGIN RAISE NOTICE ''op_leak => %, %'', $1, $2; RETURN $1 < $2; END' + LANGUAGE plpgsql +-- +FUNCTION: name="op_leak" function="op_leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION op_leak(int, int) RETURNS bool AS $$BEGIN RAISE NOTICE 'op_leak => %, %', $1, $2;..." +== 729 +-- truncate_limit: 100 +CREATE OPERATOR <<< (procedure = op_leak, leftarg = int, rightarg = int, + restrict = scalarltsel) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR <<< (procedure = op_leak, leftarg = int, rightarg = int, restrict = scalarltsel)" +== 730 +-- truncate_limit: 100 +CREATE FUNCTION op_leak(record, record) RETURNS bool + AS 'BEGIN RAISE NOTICE ''op_leak => %, %'', $1, $2; RETURN $1 < $2; END' + LANGUAGE plpgsql +-- +FUNCTION: name="op_leak" function="op_leak" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION op_leak(record, record) RETURNS bool AS $$BEGIN RAISE NOTICE 'op_leak => %, %', $..." +== 731 +-- truncate_limit: 100 +CREATE OPERATOR <<< (procedure = op_leak, leftarg = record, rightarg = record, + restrict = scalarltsel) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR <<< (procedure = op_leak, leftarg = record, rightarg = record, restrict = scalarl..." +== 732 +-- truncate_limit: 100 +SELECT * FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0" +== 733 +-- truncate_limit: 100 +-- Permission denied +SELECT * FROM tststats.priv_test_tbl t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +ALIAS: "t"="tststats.priv_test_tbl" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_tbl t WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL)" +== 734 +-- truncate_limit: 100 +-- Permission denied +DELETE FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0" +== 735 +-- truncate_limit: 100 +-- Permission denied + +-- Grant access via a security barrier view, but hide all data +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 736 +-- truncate_limit: 100 +CREATE VIEW tststats.priv_test_view WITH (security_barrier=true) + AS SELECT * FROM tststats.priv_test_tbl WHERE false +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=DDL +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tststats.priv_test_view WITH (security_barrier=true) AS SELECT * FROM tststats.priv_t..." +== 737 +-- truncate_limit: 100 +GRANT SELECT, DELETE ON tststats.priv_test_view TO regress_stats_user1 +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select, delete ON tststats.priv_test_view TO regress_stats_user1" +== 738 +-- truncate_limit: 100 +-- Should now have access via the view, but see nothing and leak nothing +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 739 +-- truncate_limit: 100 +SELECT * FROM tststats.priv_test_view WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_view WHERE a <<< 0 AND b <<< 0" +== 740 +-- truncate_limit: 100 +-- Should not leak +SELECT * FROM tststats.priv_test_view t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=Select +ALIAS: "t"="tststats.priv_test_view" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_view t WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL)" +== 741 +-- truncate_limit: 100 +-- Should not leak +DELETE FROM tststats.priv_test_view WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_view" schema="tststats" table="priv_test_view" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tststats.priv_test_view WHERE a <<< 0 AND b <<< 0" +== 742 +-- truncate_limit: 100 +-- Should not leak + +-- Grant table access, but hide all data with RLS +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 743 +-- truncate_limit: 100 +ALTER TABLE tststats.priv_test_tbl ENABLE ROW LEVEL SECURITY +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tststats.priv_test_tbl ENABLE ROW LEVEL SECURITY" +== 744 +-- truncate_limit: 100 +CREATE POLICY priv_test_tbl_pol ON tststats.priv_test_tbl USING (2 * a < 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY priv_test_tbl_pol ON tststats.priv_test_tbl TO public USING ((2 * a) < 0)" +== 745 +-- truncate_limit: 100 +GRANT SELECT, DELETE ON tststats.priv_test_tbl TO regress_stats_user1 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select, delete ON tststats.priv_test_tbl TO regress_stats_user1" +== 746 +-- truncate_limit: 100 +-- Should now have direct table access, but see nothing and leak nothing +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 747 +-- truncate_limit: 100 +SELECT * FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0" +== 748 +-- truncate_limit: 100 +-- Should not leak +SELECT * FROM tststats.priv_test_tbl t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=Select +ALIAS: "t"="tststats.priv_test_tbl" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_tbl t WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL)" +== 749 +-- truncate_limit: 100 +-- Should not leak +DELETE FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0" +== 750 +-- truncate_limit: 100 +-- Should not leak + +-- Create plain inheritance parent table with no access permissions +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 751 +-- truncate_limit: 100 +CREATE TABLE tststats.priv_test_parent_tbl (a int, b int) +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tststats.priv_test_parent_tbl (a int, b int)" +== 752 +-- truncate_limit: 100 +ALTER TABLE tststats.priv_test_tbl INHERIT tststats.priv_test_parent_tbl +-- +TABLE: name="tststats.priv_test_tbl" schema="tststats" table="priv_test_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tststats.priv_test_tbl INHERIT tststats.priv_test_parent_tbl" +== 753 +-- truncate_limit: 100 +-- Should not have access to parent, and should leak nothing +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 754 +-- truncate_limit: 100 +SELECT * FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0" +== 755 +-- truncate_limit: 100 +-- Permission denied +SELECT * FROM tststats.priv_test_parent_tbl t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=Select +ALIAS: "t"="tststats.priv_test_parent_tbl" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_parent_tbl t WHERE ..." +== 756 +-- truncate_limit: 100 +-- Permission denied +DELETE FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0" +== 757 +-- truncate_limit: 100 +-- Permission denied + +-- Grant table access to parent, but hide all data with RLS +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 758 +-- truncate_limit: 100 +ALTER TABLE tststats.priv_test_parent_tbl ENABLE ROW LEVEL SECURITY +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tststats.priv_test_parent_tbl ENABLE ROW LEVEL SECURITY" +== 759 +-- truncate_limit: 100 +CREATE POLICY priv_test_parent_tbl_pol ON tststats.priv_test_parent_tbl USING (2 * a < 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY priv_test_parent_tbl_pol ON tststats.priv_test_parent_tbl TO public USING ((2 * a) ..." +== 760 +-- truncate_limit: 100 +GRANT SELECT, DELETE ON tststats.priv_test_parent_tbl TO regress_stats_user1 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select, delete ON tststats.priv_test_parent_tbl TO regress_stats_user1" +== 761 +-- truncate_limit: 100 +-- Should now have direct table access to parent, but see nothing and leak nothing +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 762 +-- truncate_limit: 100 +SELECT * FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0" +== 763 +-- truncate_limit: 100 +-- Should not leak +SELECT * FROM tststats.priv_test_parent_tbl t + WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL) +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=Select +ALIAS: "t"="tststats.priv_test_parent_tbl" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tststats.priv_test_parent_tbl t WHERE ..." +== 764 +-- truncate_limit: 100 +-- Should not leak +DELETE FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0 +-- +TABLE: name="tststats.priv_test_parent_tbl" schema="tststats" table="priv_test_parent_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0" +== 765 +-- truncate_limit: 100 +-- Should not leak + +-- privilege checks for pg_stats_ext and pg_stats_ext_exprs +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 766 +-- truncate_limit: 100 +CREATE TABLE stats_ext_tbl (id INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, col TEXT) +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stats_ext_tbl (id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, col text)" +== 767 +-- truncate_limit: 100 +INSERT INTO stats_ext_tbl (col) VALUES ('secret'), ('secret'), ('very secret') +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO stats_ext_tbl (col) VALUES ('secret'), ('secret'), ('very secret')" +== 768 +-- truncate_limit: 100 +CREATE STATISTICS s_col ON id, col FROM stats_ext_tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s_col ON id, col FROM stats_ext_tbl" +== 769 +-- truncate_limit: 100 +CREATE STATISTICS s_expr ON mod(id, 2), lower(col) FROM stats_ext_tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS s_expr ON (mod(id, 2)), (lower(col)) FROM stats_ext_tbl" +== 770 +-- truncate_limit: 100 +ANALYZE stats_ext_tbl +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE stats_ext_tbl" +== 771 +-- truncate_limit: 100 +-- unprivileged role should not have access +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 772 +-- truncate_limit: 100 +SELECT statistics_name, most_common_vals FROM pg_stats_ext x + WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*) +-- +TABLE: name="pg_stats_ext" schema="" table="pg_stats_ext" ctx=Select +ALIAS: "x"="pg_stats_ext" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stats_ext x WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*)" +== 773 +-- truncate_limit: 100 +SELECT statistics_name, most_common_vals FROM pg_stats_ext_exprs x + WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*) +-- +TABLE: name="pg_stats_ext_exprs" schema="" table="pg_stats_ext_exprs" ctx=Select +ALIAS: "x"="pg_stats_ext_exprs" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stats_ext_exprs x WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*)" +== 774 +-- truncate_limit: 100 +-- give unprivileged role ownership of table +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 775 +-- truncate_limit: 100 +ALTER TABLE stats_ext_tbl OWNER TO regress_stats_user1 +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE stats_ext_tbl OWNER TO regress_stats_user1" +== 776 +-- truncate_limit: 100 +-- unprivileged role should now have access +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 777 +-- truncate_limit: 100 +SELECT statistics_name, most_common_vals FROM pg_stats_ext x + WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*) +-- +TABLE: name="pg_stats_ext" schema="" table="pg_stats_ext" ctx=Select +ALIAS: "x"="pg_stats_ext" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stats_ext x WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*)" +== 778 +-- truncate_limit: 100 +SELECT statistics_name, most_common_vals FROM pg_stats_ext_exprs x + WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*) +-- +TABLE: name="pg_stats_ext_exprs" schema="" table="pg_stats_ext_exprs" ctx=Select +ALIAS: "x"="pg_stats_ext_exprs" +FILTER: schema="" table="" column="tablename" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stats_ext_exprs x WHERE tablename = 'stats_ext_tbl' ORDER BY ROW(x.*)" +== 779 +-- truncate_limit: 100 +-- CREATE STATISTICS checks for CREATE on the schema +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 780 +-- truncate_limit: 100 +CREATE SCHEMA sts_sch1 CREATE TABLE sts_sch1.tbl (a INT, b INT, c INT GENERATED ALWAYS AS (b * 2) STORED) +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA sts_sch1 CREATE TABLE sts_sch1.tbl (a int, b int, c int GENERATED ALWAYS AS (b * 2)..." +== 781 +-- truncate_limit: 100 +CREATE SCHEMA sts_sch2 +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA sts_sch2" +== 782 +-- truncate_limit: 100 +GRANT USAGE ON SCHEMA sts_sch1, sts_sch2 TO regress_stats_user1 +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON SCHEMA sts_sch1, sts_sch2 TO regress_stats_user1" +== 783 +-- truncate_limit: 100 +ALTER TABLE sts_sch1.tbl OWNER TO regress_stats_user1 +-- +TABLE: name="sts_sch1.tbl" schema="sts_sch1" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE sts_sch1.tbl OWNER TO regress_stats_user1" +== 784 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 785 +-- truncate_limit: 100 +CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl" +== 786 +-- truncate_limit: 100 +CREATE STATISTICS sts_sch2.fail ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS sts_sch2.fail ON a, b, c FROM sts_sch1.tbl" +== 787 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 788 +-- truncate_limit: 100 +GRANT CREATE ON SCHEMA sts_sch1 TO regress_stats_user1 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON SCHEMA sts_sch1 TO regress_stats_user1" +== 789 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 790 +-- truncate_limit: 100 +CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl" +== 791 +-- truncate_limit: 100 +CREATE STATISTICS sts_sch2.fail ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS sts_sch2.fail ON a, b, c FROM sts_sch1.tbl" +== 792 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 793 +-- truncate_limit: 100 +REVOKE CREATE ON SCHEMA sts_sch1 FROM regress_stats_user1 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE create ON SCHEMA sts_sch1 FROM regress_stats_user1" +== 794 +-- truncate_limit: 100 +GRANT CREATE ON SCHEMA sts_sch2 TO regress_stats_user1 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON SCHEMA sts_sch2 TO regress_stats_user1" +== 795 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 796 +-- truncate_limit: 100 +CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl" +== 797 +-- truncate_limit: 100 +CREATE STATISTICS sts_sch2.pass1 ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS sts_sch2.pass1 ON a, b, c FROM sts_sch1.tbl" +== 798 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 799 +-- truncate_limit: 100 +GRANT CREATE ON SCHEMA sts_sch1, sts_sch2 TO regress_stats_user1 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON SCHEMA sts_sch1, sts_sch2 TO regress_stats_user1" +== 800 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 801 +-- truncate_limit: 100 +CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS ON a, b, c FROM sts_sch1.tbl" +== 802 +-- truncate_limit: 100 +CREATE STATISTICS sts_sch2.pass2 ON a, b, c FROM sts_sch1.tbl +-- +STMT: CreateStatsStmt +TRUNCATED: "CREATE STATISTICS sts_sch2.pass2 ON a, b, c FROM sts_sch1.tbl" +== 803 +-- truncate_limit: 100 +-- re-creating statistics via ALTER TABLE bypasses checks for CREATE on schema +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 804 +-- truncate_limit: 100 +REVOKE CREATE ON SCHEMA sts_sch1, sts_sch2 FROM regress_stats_user1 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE create ON SCHEMA sts_sch1, sts_sch2 FROM regress_stats_user1" +== 805 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_stats_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_stats_user1" +== 806 +-- truncate_limit: 100 +ALTER TABLE sts_sch1.tbl ALTER COLUMN a TYPE SMALLINT +-- +TABLE: name="sts_sch1.tbl" schema="sts_sch1" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE sts_sch1.tbl ALTER COLUMN a TYPE smallint" +== 807 +-- truncate_limit: 100 +ALTER TABLE sts_sch1.tbl ALTER COLUMN c SET EXPRESSION AS (a * 3) +-- +TABLE: name="sts_sch1.tbl" schema="sts_sch1" table="tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE sts_sch1.tbl ALTER COLUMN c SET EXPRESSION AS (a * 3)" +== 808 +-- truncate_limit: 100 +-- Tidy up +DROP OPERATOR <<< (int, int) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR <<<(int, int)" +== 809 +-- truncate_limit: 100 +DROP FUNCTION op_leak(int, int) +-- +FUNCTION: name="op_leak" function="op_leak" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION op_leak(int, int)" +== 810 +-- truncate_limit: 100 +DROP OPERATOR <<< (record, record) +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR <<<(record, record)" +== 811 +-- truncate_limit: 100 +DROP FUNCTION op_leak(record, record) +-- +FUNCTION: name="op_leak" function="op_leak" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION op_leak(record, record)" +== 812 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 813 +-- truncate_limit: 100 +DROP TABLE stats_ext_tbl +-- +TABLE: name="stats_ext_tbl" schema="" table="stats_ext_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE stats_ext_tbl" +== 814 +-- truncate_limit: 100 +DROP SCHEMA tststats CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA tststats CASCADE" +== 815 +-- truncate_limit: 100 +DROP SCHEMA sts_sch1, sts_sch2 CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA sts_sch1, sts_sch2 CASCADE" +== 816 +-- truncate_limit: 100 +DROP USER regress_stats_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_stats_user1" diff --git a/parser/testdata/summary_truncate/postgres_regress/strings.metadata.json b/parser/testdata/summary_truncate/postgres_regress/strings.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/strings.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/strings.test b/parser/testdata/summary_truncate/postgres_regress/strings.test new file mode 100644 index 0000000..209da30 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/strings.test @@ -0,0 +1,869 @@ +== 001 +-- truncate_limit: 100 +|-- +-- STRINGS +-- Test various data entry syntaxes. +|-- + +-- SQL string continuation syntax +-- E021-03 character string literals +SELECT 'first line' +' - next line' + ' - third line' + AS "Three lines to one"; + +-- illegal string continuation syntax +SELECT 'first line' +' - next line' /* this comment is not allowed here */ +' - third line' + AS "Illegal comment within continuation"; + +-- Unicode escapes +SET standard_conforming_strings TO on; + +SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061"; +SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*'; +SELECT U&'a\\b' AS "a\b"; + +SELECT U&' \' UESCAPE '!' AS "tricky"; +SELECT 'tricky' AS U&"\" UESCAPE '!'; + +SELECT U&'wrong: \061'; +SELECT U&'wrong: \+0061'; +SELECT U&'wrong: +0061' UESCAPE +; +SELECT U&'wrong: +0061' UESCAPE '+'; + +SELECT U&'wrong: \db99'; +SELECT U&'wrong: \db99xy'; +SELECT U&'wrong: \db99\\'; +SELECT U&'wrong: \db99\0061'; +SELECT U&'wrong: \+00db99\+000061'; +SELECT U&'wrong: \+2FFFFF'; + +-- while we're here, check the same cases in E-style literals +SELECT E'd\u0061t\U00000061' AS "data"; +SELECT E'a\\b' AS "a\b"; +SELECT E'wrong: \u061'; +SELECT E'wrong: \U0061'; +SELECT E'wrong: \udb99'; +SELECT E'wrong: \udb99xy'; +SELECT E'wrong: \udb99\\'; +SELECT E'wrong: \udb99\u0061'; +SELECT E'wrong: \U0000db99\U00000061'; +SELECT E'wrong: \U002FFFFF'; + +SET standard_conforming_strings TO off; + +SELECT U&'d\0061t\+000061' AS U&"d\0061t\+000061"; +SELECT U&'d!0061t\+000061' UESCAPE '!' AS U&"d*0061t\+000061" UESCAPE '*'; + +SELECT U&' \' UESCAPE '!' AS "tricky"; +SELECT 'tricky' AS U&"\" UESCAPE '!'; + +SELECT U&'wrong: \061'; +SELECT U&'wrong: \+0061'; +SELECT U&'wrong: +0061' UESCAPE '+'; + +RESET standard_conforming_strings; + +-- bytea +SET bytea_output TO hex; +SELECT E'\\xDeAdBeEf'::bytea; +SELECT E'\\x De Ad Be Ef '::bytea; +SELECT E'\\xDeAdBeE'::bytea; +SELECT E'\\xDeAdBeEx'::bytea; +SELECT E'\\xDe00BeEf'::bytea; +SELECT E'DeAdBeEf'::bytea; +SELECT E'De\\000dBeEf'::bytea; +SELECT E'De\123dBeEf'::bytea; +SELECT E'De\\123dBeEf'::bytea; +SELECT E'De\\678dBeEf'::bytea; + +SET bytea_output TO escape; +SELECT E'\\xDeAdBeEf'::bytea; +SELECT E'\\x De Ad Be Ef '::bytea; +SELECT E'\\xDe00BeEf'::bytea; +SELECT E'DeAdBeEf'::bytea; +SELECT E'De\\000dBeEf'::bytea; +SELECT E'De\\123dBeEf'::bytea; + +-- Test non-error-throwing API too +SELECT pg_input_is_valid(E'\\xDeAdBeE', 'bytea'); +SELECT * FROM pg_input_error_info(E'\\xDeAdBeE', 'bytea'); +SELECT * FROM pg_input_error_info(E'\\xDeAdBeEx', 'bytea'); +SELECT * FROM pg_input_error_info(E'foo\\99bar', 'bytea'); + +|-- +-- test conversions between various string types +-- E021-10 implicit casting among the character data types +|-- + +SELECT CAST(f1 AS text) AS "text(char)" FROM CHAR_TBL; + +SELECT CAST(f1 AS text) AS "text(varchar)" FROM VARCHAR_TBL; + +SELECT CAST(name 'namefield' AS text) AS "text(name)"; + +-- since this is an explicit cast, it should truncate w/o error: +SELECT CAST(f1 AS char(10)) AS "char(text)" FROM TEXT_TBL; +-- note: implicit-cast case is tested in char.sql + +SELECT CAST(f1 AS char(20)) AS "char(text)" FROM TEXT_TBL; + +SELECT CAST(f1 AS char(10)) AS "char(varchar)" FROM VARCHAR_TBL; + +SELECT CAST(name 'namefield' AS char(10)) AS "char(name)"; + +SELECT CAST(f1 AS varchar) AS "varchar(text)" FROM TEXT_TBL; + +SELECT CAST(f1 AS varchar) AS "varchar(char)" FROM CHAR_TBL; + +SELECT CAST(name 'namefield' AS varchar) AS "varchar(name)"; + +|-- +-- test SQL string functions +-- E### and T### are feature reference numbers from SQL99 +|-- + +-- E021-09 trim function +SELECT TRIM(BOTH FROM ' bunch o blanks ') = 'bunch o blanks' AS "bunch o blanks"; + +SELECT TRIM(LEADING FROM ' bunch o blanks ') = 'bunch o blanks ' AS "bunch o blanks "; + +SELECT TRIM(TRAILING FROM ' bunch o blanks ') = ' bunch o blanks' AS " bunch o blanks"; + +SELECT TRIM(BOTH 'x' FROM 'xxxxxsome Xsxxxxx') = 'some Xs' AS "some Xs"; + +-- E021-06 substring expression +SELECT SUBSTRING('1234567890' FROM 3) = '34567890' AS "34567890"; + +SELECT SUBSTRING('1234567890' FROM 4 FOR 3) = '456' AS "456"; + +-- test overflow cases +SELECT SUBSTRING('string' FROM 2 FOR 2147483646) AS "tring"; +SELECT SUBSTRING('string' FROM -10 FOR 2147483646) AS "string"; +SELECT SUBSTRING('string' FROM -10 FOR -2147483646) AS "error"; + +-- T581 regular expression substring (with SQL's bizarre regexp syntax) +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"(b_d)#"%' ESCAPE '#') AS "bcd"; +-- obsolete SQL99 syntax +SELECT SUBSTRING('abcdefg' FROM 'a#"(b_d)#"%' FOR '#') AS "bcd"; + +-- No match should return NULL +SELECT SUBSTRING('abcdefg' SIMILAR '#"(b_d)#"%' ESCAPE '#') IS NULL AS "True"; + +-- Null inputs should return NULL +SELECT SUBSTRING('abcdefg' SIMILAR '%' ESCAPE NULL) IS NULL AS "True"; +SELECT SUBSTRING(NULL SIMILAR '%' ESCAPE '#') IS NULL AS "True"; +SELECT SUBSTRING('abcdefg' SIMILAR NULL ESCAPE '#') IS NULL AS "True"; + +-- The first and last parts should act non-greedy +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"%#"g' ESCAPE '#') AS "bcdef"; +SELECT SUBSTRING('abcdefg' SIMILAR 'a*#"%#"g*' ESCAPE '#') AS "abcdefg"; + +-- Vertical bar in any part affects only that part +SELECT SUBSTRING('abcdefg' SIMILAR 'a|b#"%#"g' ESCAPE '#') AS "bcdef"; +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"%#"x|g' ESCAPE '#') AS "bcdef"; +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"%|ab#"g' ESCAPE '#') AS "bcdef"; + +-- Can't have more than two part separators +SELECT SUBSTRING('abcdefg' SIMILAR 'a*#"%#"g*#"x' ESCAPE '#') AS "error"; + +-- Postgres extension: with 0 or 1 separator, assume parts 1 and 3 are empty +SELECT SUBSTRING('abcdefg' SIMILAR 'a#"%g' ESCAPE '#') AS "bcdefg"; +SELECT SUBSTRING('abcdefg' SIMILAR 'a%g' ESCAPE '#') AS "abcdefg"; + +-- substring() with just two arguments is not allowed by SQL spec; +-- we accept it, but we interpret the pattern as a POSIX regexp not SQL +SELECT SUBSTRING('abcdefg' FROM 'c.e') AS "cde"; + +-- With a parenthesized subexpression, return only what matches the subexpr +SELECT SUBSTRING('abcdefg' FROM 'b(.*)f') AS "cde"; +-- Check case where we have a match, but not a subexpression match +SELECT SUBSTRING('foo' FROM 'foo(bar)?') IS NULL AS t; + +-- Check behavior of SIMILAR TO, which uses largely the same regexp variant +SELECT 'abcdefg' SIMILAR TO '_bcd%' AS true; +SELECT 'abcdefg' SIMILAR TO 'bcd%' AS false; +SELECT 'abcdefg' SIMILAR TO '_bcd#%' ESCAPE '#' AS false; +SELECT 'abcd%' SIMILAR TO '_bcd#%' ESCAPE '#' AS true; +-- Postgres uses '\' as the default escape character, which is not per spec +SELECT 'abcdefg' SIMILAR TO '_bcd\%' AS false; +-- and an empty string to mean "no escape", which is also not per spec +SELECT 'abcd\efg' SIMILAR TO '_bcd\%' ESCAPE '' AS true; +-- these behaviors are per spec, though: +SELECT 'abcdefg' SIMILAR TO '_bcd%' ESCAPE NULL AS null; +SELECT 'abcdefg' SIMILAR TO '_bcd#%' ESCAPE '##' AS error; + +-- Characters that should be left alone in character classes when a +-- SIMILAR TO regexp pattern is converted to POSIX style. +-- Underscore "_" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '_[_[:alpha:]_]_'; +-- Percentage "%" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '%[%[:alnum:]%]%'; +-- Dot "." +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '.[.[:alnum:].].'; +-- Dollar "$" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '$[$[:alnum:]$]$'; +-- Opening parenthesis "(" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '()[([:alnum:](]()'; +-- Caret "^" +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '^[^[:alnum:]^[^^][[^^]][\^][[\^]]\^]^'; +-- Closing square bracket "]" at the beginning of character class +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '[]%][^]%][^%]%'; +-- Closing square bracket effective after two carets at the beginning +-- of character class. +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '[^^]^'; +-- Closing square bracket after an escape sequence at the beginning of +-- a character closes the character class +EXPLAIN (COSTS OFF) SELECT * FROM TEXT_TBL WHERE f1 SIMILAR TO '[|a]%' ESCAPE '|'; + +-- Test backslash escapes in regexp_replace's replacement string +SELECT regexp_replace('1112223333', E'(\\d{3})(\\d{3})(\\d{4})', E'(\\1) \\2-\\3'); +SELECT regexp_replace('foobarrbazz', E'(.)\\1', E'X\\&Y', 'g'); +SELECT regexp_replace('foobarrbazz', E'(.)\\1', E'X\\\\Y', 'g'); +-- not an error, though perhaps it should be: +SELECT regexp_replace('foobarrbazz', E'(.)\\1', E'X\\Y\\1Z\\'); + +SELECT regexp_replace('AAA BBB CCC ', E'\\s+', ' ', 'g'); +SELECT regexp_replace('AAA', '^|$', 'Z', 'g'); +SELECT regexp_replace('AAA aaa', 'A+', 'Z', 'gi'); +-- invalid regexp option +SELECT regexp_replace('AAA aaa', 'A+', 'Z', 'z'); + +-- extended regexp_replace tests +SELECT regexp_replace('A PostgreSQL function', 'A|e|i|o|u', 'X', 1); +SELECT regexp_replace('A PostgreSQL function', 'A|e|i|o|u', 'X', 1, 2); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 0, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 1, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 2, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 3, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 9, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'A|e|i|o|u', 'X', 7, 0, 'i'); +-- 'g' flag should be ignored when N is specified +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, 1, 'g'); +-- errors +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', -1, 0, 'i'); +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', 1, -1, 'i'); +-- erroneous invocation of non-extended form +SELECT regexp_replace('A PostgreSQL function', 'a|e|i|o|u', 'X', '1'); + +-- regexp_count tests +SELECT regexp_count('123123123123123', '(12)3'); +SELECT regexp_count('123123123123', '123', 1); +SELECT regexp_count('123123123123', '123', 3); +SELECT regexp_count('123123123123', '123', 33); +SELECT regexp_count('ABCABCABCABC', 'Abc', 1, ''); +SELECT regexp_count('ABCABCABCABC', 'Abc', 1, 'i'); +-- errors +SELECT regexp_count('123123123123', '123', 0); +SELECT regexp_count('123123123123', '123', -3); + +-- regexp_like tests +SELECT regexp_like('Steven', '^Ste(v|ph)en$'); +SELECT regexp_like('a'||CHR(10)||'d', 'a.d', 'n'); +SELECT regexp_like('a'||CHR(10)||'d', 'a.d', 's'); +SELECT regexp_like('abc', ' a . c ', 'x'); +SELECT regexp_like('abc', 'a.c', 'g'); -- error + +-- regexp_instr tests +SELECT regexp_instr('abcdefghi', 'd.f'); +SELECT regexp_instr('abcdefghi', 'd.q'); +SELECT regexp_instr('abcabcabc', 'a.c'); +SELECT regexp_instr('abcabcabc', 'a.c', 2); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 3); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 4); +SELECT regexp_instr('abcabcabc', 'A.C', 1, 2, 0, 'i'); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 0); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 1); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 2); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 3); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 4); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 0, 'i', 5); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 0); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 1); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 2); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 3); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 4); +SELECT regexp_instr('1234567890', '(123)(4(56)(78))', 1, 1, 1, 'i', 5); +-- Check case where we have a match, but not a subexpression match +SELECT regexp_instr('foo', 'foo(bar)?', 1, 1, 0, '', 1); +-- errors +SELECT regexp_instr('abcabcabc', 'a.c', 0, 1); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 0); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 1, -1); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 1, 2); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 1, 0, 'g'); +SELECT regexp_instr('abcabcabc', 'a.c', 1, 1, 0, '', -1); + +-- regexp_substr tests +SELECT regexp_substr('abcdefghi', 'd.f'); +SELECT regexp_substr('abcdefghi', 'd.q') IS NULL AS t; +SELECT regexp_substr('abcabcabc', 'a.c'); +SELECT regexp_substr('abcabcabc', 'a.c', 2); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 3); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 4) IS NULL AS t; +SELECT regexp_substr('abcabcabc', 'A.C', 1, 2, 'i'); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 0); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 1); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 2); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 3); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 4); +SELECT regexp_substr('1234567890', '(123)(4(56)(78))', 1, 1, 'i', 5) IS NULL AS t; +-- Check case where we have a match, but not a subexpression match +SELECT regexp_substr('foo', 'foo(bar)?', 1, 1, '', 1) IS NULL AS t; +-- errors +SELECT regexp_substr('abcabcabc', 'a.c', 0, 1); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 0); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 1, 'g'); +SELECT regexp_substr('abcabcabc', 'a.c', 1, 1, '', -1); + +-- set so we can tell NULL from empty string + +-- return all matches from regexp +SELECT regexp_matches('foobarbequebaz', $re$(bar)(beque)$re$); + +-- test case insensitive +SELECT regexp_matches('foObARbEqUEbAz', $re$(bar)(beque)$re$, 'i'); + +-- global option - more than one match +SELECT regexp_matches('foobarbequebazilbarfbonk', $re$(b[^b]+)(b[^b]+)$re$, 'g'); + +-- empty capture group (matched empty string) +SELECT regexp_matches('foobarbequebaz', $re$(bar)(.*)(beque)$re$); +-- no match +SELECT regexp_matches('foobarbequebaz', $re$(bar)(.+)(beque)$re$); +-- optional capture group did not match, null entry in array +SELECT regexp_matches('foobarbequebaz', $re$(bar)(.+)?(beque)$re$); + +-- no capture groups +SELECT regexp_matches('foobarbequebaz', $re$barbeque$re$); + +-- start/end-of-line matches are of zero length +SELECT regexp_matches('foo' || chr(10) || 'bar' || chr(10) || 'bequq' || chr(10) || 'baz', '^', 'mg'); +SELECT regexp_matches('foo' || chr(10) || 'bar' || chr(10) || 'bequq' || chr(10) || 'baz', '$', 'mg'); +SELECT regexp_matches('1' || chr(10) || '2' || chr(10) || '3' || chr(10) || '4' || chr(10), '^.?', 'mg'); +SELECT regexp_matches(chr(10) || '1' || chr(10) || '2' || chr(10) || '3' || chr(10) || '4' || chr(10), '.?$', 'mg'); +SELECT regexp_matches(chr(10) || '1' || chr(10) || '2' || chr(10) || '3' || chr(10) || '4', '.?$', 'mg'); + +-- give me errors +SELECT regexp_matches('foobarbequebaz', $re$(bar)(beque)$re$, 'gz'); +SELECT regexp_matches('foobarbequebaz', $re$(barbeque$re$); +SELECT regexp_matches('foobarbequebaz', $re$(bar)(beque){2,1}$re$); + +-- split string on regexp +SELECT foo, length(foo) FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', $re$\s+$re$) AS foo; +SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', $re$\s+$re$); + +SELECT foo, length(foo) FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', $re$\s*$re$) AS foo; +SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', $re$\s*$re$); +SELECT foo, length(foo) FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', '') AS foo; +SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', ''); +-- case insensitive +SELECT foo, length(foo) FROM regexp_split_to_table('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'i') AS foo; +SELECT regexp_split_to_array('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'i'); +-- no match of pattern +SELECT foo, length(foo) FROM regexp_split_to_table('the quick brown fox jumps over the lazy dog', 'nomatch') AS foo; +SELECT regexp_split_to_array('the quick brown fox jumps over the lazy dog', 'nomatch'); +-- some corner cases +SELECT regexp_split_to_array('123456','1'); +SELECT regexp_split_to_array('123456','6'); +SELECT regexp_split_to_array('123456','.'); +SELECT regexp_split_to_array('123456',''); +SELECT regexp_split_to_array('123456','(?:)'); +SELECT regexp_split_to_array('1',''); +-- errors +SELECT foo, length(foo) FROM regexp_split_to_table('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'zippy') AS foo; +SELECT regexp_split_to_array('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'iz'); +-- global option meaningless for regexp_split +SELECT foo, length(foo) FROM regexp_split_to_table('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'g') AS foo; +SELECT regexp_split_to_array('thE QUick bROWn FOx jUMPs ovEr The lazy dOG', 'e', 'g'); + +-- change NULL-display back + +-- E021-11 position expression +SELECT POSITION('4' IN '1234567890') = '4' AS "4"; + +SELECT POSITION('5' IN '1234567890') = '5' AS "5"; + +-- T312 character overlay function +SELECT OVERLAY('abcdef' PLACING '45' FROM 4) AS "abc45f"; + +SELECT OVERLAY('yabadoo' PLACING 'daba' FROM 5) AS "yabadaba"; + +SELECT OVERLAY('yabadoo' PLACING 'daba' FROM 5 FOR 0) AS "yabadabadoo"; + +SELECT OVERLAY('babosa' PLACING 'ubb' FROM 2 FOR 4) AS "bubba"; + +|-- +-- test LIKE +-- Be sure to form every test as a LIKE/NOT LIKE pair. +|-- + +-- simplest examples +-- E061-04 like predicate +SELECT 'hawkeye' LIKE 'h%' AS "true"; +SELECT 'hawkeye' NOT LIKE 'h%' AS "false"; + +SELECT 'hawkeye' LIKE 'H%' AS "false"; +SELECT 'hawkeye' NOT LIKE 'H%' AS "true"; + +SELECT 'hawkeye' LIKE 'indio%' AS "false"; +SELECT 'hawkeye' NOT LIKE 'indio%' AS "true"; + +SELECT 'hawkeye' LIKE 'h%eye' AS "true"; +SELECT 'hawkeye' NOT LIKE 'h%eye' AS "false"; + +SELECT 'indio' LIKE '_ndio' AS "true"; +SELECT 'indio' NOT LIKE '_ndio' AS "false"; + +SELECT 'indio' LIKE 'in__o' AS "true"; +SELECT 'indio' NOT LIKE 'in__o' AS "false"; + +SELECT 'indio' LIKE 'in_o' AS "false"; +SELECT 'indio' NOT LIKE 'in_o' AS "true"; + +SELECT 'abc'::name LIKE '_b_' AS "true"; +SELECT 'abc'::name NOT LIKE '_b_' AS "false"; + +SELECT 'abc'::bytea LIKE '_b_'::bytea AS "true"; +SELECT 'abc'::bytea NOT LIKE '_b_'::bytea AS "false"; + +-- unused escape character +SELECT 'hawkeye' LIKE 'h%' ESCAPE '#' AS "true"; +SELECT 'hawkeye' NOT LIKE 'h%' ESCAPE '#' AS "false"; + +SELECT 'indio' LIKE 'ind_o' ESCAPE '$' AS "true"; +SELECT 'indio' NOT LIKE 'ind_o' ESCAPE '$' AS "false"; + +-- escape character +-- E061-05 like predicate with escape clause +SELECT 'h%' LIKE 'h#%' ESCAPE '#' AS "true"; +SELECT 'h%' NOT LIKE 'h#%' ESCAPE '#' AS "false"; + +SELECT 'h%wkeye' LIKE 'h#%' ESCAPE '#' AS "false"; +SELECT 'h%wkeye' NOT LIKE 'h#%' ESCAPE '#' AS "true"; + +SELECT 'h%wkeye' LIKE 'h#%%' ESCAPE '#' AS "true"; +SELECT 'h%wkeye' NOT LIKE 'h#%%' ESCAPE '#' AS "false"; + +SELECT 'h%awkeye' LIKE 'h#%a%k%e' ESCAPE '#' AS "true"; +SELECT 'h%awkeye' NOT LIKE 'h#%a%k%e' ESCAPE '#' AS "false"; + +SELECT 'indio' LIKE '_ndio' ESCAPE '$' AS "true"; +SELECT 'indio' NOT LIKE '_ndio' ESCAPE '$' AS "false"; + +SELECT 'i_dio' LIKE 'i$_d_o' ESCAPE '$' AS "true"; +SELECT 'i_dio' NOT LIKE 'i$_d_o' ESCAPE '$' AS "false"; + +SELECT 'i_dio' LIKE 'i$_nd_o' ESCAPE '$' AS "false"; +SELECT 'i_dio' NOT LIKE 'i$_nd_o' ESCAPE '$' AS "true"; + +SELECT 'i_dio' LIKE 'i$_d%o' ESCAPE '$' AS "true"; +SELECT 'i_dio' NOT LIKE 'i$_d%o' ESCAPE '$' AS "false"; + +SELECT 'a_c'::bytea LIKE 'a$__'::bytea ESCAPE '$'::bytea AS "true"; +SELECT 'a_c'::bytea NOT LIKE 'a$__'::bytea ESCAPE '$'::bytea AS "false"; + +-- escape character same as pattern character +SELECT 'maca' LIKE 'm%aca' ESCAPE '%' AS "true"; +SELECT 'maca' NOT LIKE 'm%aca' ESCAPE '%' AS "false"; + +SELECT 'ma%a' LIKE 'm%a%%a' ESCAPE '%' AS "true"; +SELECT 'ma%a' NOT LIKE 'm%a%%a' ESCAPE '%' AS "false"; + +SELECT 'bear' LIKE 'b_ear' ESCAPE '_' AS "true"; +SELECT 'bear' NOT LIKE 'b_ear' ESCAPE '_' AS "false"; + +SELECT 'be_r' LIKE 'b_e__r' ESCAPE '_' AS "true"; +SELECT 'be_r' NOT LIKE 'b_e__r' ESCAPE '_' AS "false"; + +SELECT 'be_r' LIKE '__e__r' ESCAPE '_' AS "false"; +SELECT 'be_r' NOT LIKE '__e__r' ESCAPE '_' AS "true"; + + +|-- +-- test ILIKE (case-insensitive LIKE) +-- Be sure to form every test as an ILIKE/NOT ILIKE pair. +|-- + +SELECT 'hawkeye' ILIKE 'h%' AS "true"; +SELECT 'hawkeye' NOT ILIKE 'h%' AS "false"; + +SELECT 'hawkeye' ILIKE 'H%' AS "true"; +SELECT 'hawkeye' NOT ILIKE 'H%' AS "false"; + +SELECT 'hawkeye' ILIKE 'H%Eye' AS "true"; +SELECT 'hawkeye' NOT ILIKE 'H%Eye' AS "false"; + +SELECT 'Hawkeye' ILIKE 'h%' AS "true"; +SELECT 'Hawkeye' NOT ILIKE 'h%' AS "false"; + +SELECT 'ABC'::name ILIKE '_b_' AS "true"; +SELECT 'ABC'::name NOT ILIKE '_b_' AS "false"; + +|-- +-- test %/_ combination cases, cf bugs #4821 and #5478 +|-- + +SELECT 'foo' LIKE '_%' as t, 'f' LIKE '_%' as t, '' LIKE '_%' as f; +SELECT 'foo' LIKE '%_' as t, 'f' LIKE '%_' as t, '' LIKE '%_' as f; + +SELECT 'foo' LIKE '__%' as t, 'foo' LIKE '___%' as t, 'foo' LIKE '____%' as f; +SELECT 'foo' LIKE '%__' as t, 'foo' LIKE '%___' as t, 'foo' LIKE '%____' as f; + +SELECT 'jack' LIKE '%____%' AS t; + + +|-- +-- basic tests of LIKE with indexes +|-- + +CREATE TABLE texttest (a text PRIMARY KEY, b int); +SELECT * FROM texttest WHERE a LIKE '%1%'; + +CREATE TABLE byteatest (a bytea PRIMARY KEY, b int); +SELECT * FROM byteatest WHERE a LIKE '%1%'; + +DROP TABLE texttest, byteatest; + + +|-- +-- test implicit type conversion +|-- + +-- E021-07 character concatenation +SELECT 'unknown' || ' and unknown' AS "Concat unknown types"; + +SELECT text 'text' || ' and unknown' AS "Concat text to unknown type"; + +SELECT char(20) 'characters' || ' and text' AS "Concat char to unknown type"; + +SELECT text 'text' || char(20) ' and characters' AS "Concat text to char"; + +SELECT text 'text' || varchar ' and varchar' AS "Concat text to varchar"; + +|-- +-- test substr with toasted text values +|-- +CREATE TABLE toasttest(f1 text); + +insert into toasttest values(repeat('1234567890',10000)); +insert into toasttest values(repeat('1234567890',10000)); + +|-- +-- Ensure that some values are uncompressed, to test the faster substring +-- operation used in that case +|-- +alter table toasttest alter column f1 set storage external; +insert into toasttest values(repeat('1234567890',10000)); +insert into toasttest values(repeat('1234567890',10000)); + +-- If the starting position is zero or less, then return from the start of the string +-- adjusting the length to be consistent with the "negative start" per SQL. +SELECT substr(f1, -1, 5) from toasttest; + +-- If the length is less than zero, an ERROR is thrown. +SELECT substr(f1, 5, -1) from toasttest; + +-- If no third argument (length) is provided, the length to the end of the +-- string is assumed. +SELECT substr(f1, 99995) from toasttest; + +-- If start plus length is > string length, the result is truncated to +-- string length +SELECT substr(f1, 99995, 10) from toasttest; + +TRUNCATE TABLE toasttest; +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +-- expect >0 blocks +SELECT pg_relation_size(reltoastrelid) = 0 AS is_empty + FROM pg_class where relname = 'toasttest'; + +TRUNCATE TABLE toasttest; +ALTER TABLE toasttest set (toast_tuple_target = 4080); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +INSERT INTO toasttest values (repeat('1234567890',300)); +-- expect 0 blocks +SELECT pg_relation_size(reltoastrelid) = 0 AS is_empty + FROM pg_class where relname = 'toasttest'; + +DROP TABLE toasttest; + +|-- +-- test substr with toasted bytea values +|-- +CREATE TABLE toasttest(f1 bytea); + +insert into toasttest values(decode(repeat('1234567890',10000),'escape')); +insert into toasttest values(decode(repeat('1234567890',10000),'escape')); + +|-- +-- Ensure that some values are uncompressed, to test the faster substring +-- operation used in that case +|-- +alter table toasttest alter column f1 set storage external; +insert into toasttest values(decode(repeat('1234567890',10000),'escape')); +insert into toasttest values(decode(repeat('1234567890',10000),'escape')); + +-- If the starting position is zero or less, then return from the start of the string +-- adjusting the length to be consistent with the "negative start" per SQL. +SELECT substr(f1, -1, 5) from toasttest; + +-- If the length is less than zero, an ERROR is thrown. +SELECT substr(f1, 5, -1) from toasttest; + +-- If no third argument (length) is provided, the length to the end of the +-- string is assumed. +SELECT substr(f1, 99995) from toasttest; + +-- If start plus length is > string length, the result is truncated to +-- string length +SELECT substr(f1, 99995, 10) from toasttest; + +DROP TABLE toasttest; + +-- test internally compressing datums + +-- this tests compressing a datum to a very small size which exercises a +-- corner case in packed-varlena handling: even though small, the compressed +-- datum must be given a 4-byte header because there are no bits to indicate +-- compression in a 1-byte header + +CREATE TABLE toasttest (c char(4096)); +INSERT INTO toasttest VALUES('x'); +SELECT length(c), c::text FROM toasttest; +SELECT c FROM toasttest; +DROP TABLE toasttest; + +|-- +-- test length +|-- + +SELECT length('abcdef') AS "length_6"; + +|-- +-- test strpos +|-- + +SELECT strpos('abcdef', 'cd') AS "pos_3"; + +SELECT strpos('abcdef', 'xy') AS "pos_0"; + +SELECT strpos('abcdef', '') AS "pos_1"; + +SELECT strpos('', 'xy') AS "pos_0"; + +SELECT strpos('', '') AS "pos_1"; + +|-- +-- test replace +|-- +SELECT replace('abcdef', 'de', '45') AS "abc45f"; + +SELECT replace('yabadabadoo', 'ba', '123') AS "ya123da123doo"; + +SELECT replace('yabadoo', 'bad', '') AS "yaoo"; + +|-- +-- test split_part +|-- +select split_part('','@',1) AS "empty string"; + +select split_part('','@',-1) AS "empty string"; + +select split_part('joeuser@mydatabase','',1) AS "joeuser@mydatabase"; + +select split_part('joeuser@mydatabase','',2) AS "empty string"; + +select split_part('joeuser@mydatabase','',-1) AS "joeuser@mydatabase"; + +select split_part('joeuser@mydatabase','',-2) AS "empty string"; + +select split_part('joeuser@mydatabase','@',0) AS "an error"; + +select split_part('joeuser@mydatabase','@@',1) AS "joeuser@mydatabase"; + +select split_part('joeuser@mydatabase','@@',2) AS "empty string"; + +select split_part('joeuser@mydatabase','@',1) AS "joeuser"; + +select split_part('joeuser@mydatabase','@',2) AS "mydatabase"; + +select split_part('joeuser@mydatabase','@',3) AS "empty string"; + +select split_part('@joeuser@mydatabase@','@',2) AS "joeuser"; + +select split_part('joeuser@mydatabase','@',-1) AS "mydatabase"; + +select split_part('joeuser@mydatabase','@',-2) AS "joeuser"; + +select split_part('joeuser@mydatabase','@',-3) AS "empty string"; + +select split_part('@joeuser@mydatabase@','@',-2) AS "mydatabase"; + +|-- +-- test to_bin, to_oct, and to_hex +|-- +select to_bin(-1234) AS "11111111111111111111101100101110"; +select to_bin(-1234::bigint); +select to_bin(256*256*256 - 1) AS "111111111111111111111111"; +select to_bin(256::bigint*256::bigint*256::bigint*256::bigint - 1) AS "11111111111111111111111111111111"; + +select to_oct(-1234) AS "37777775456"; +select to_oct(-1234::bigint) AS "1777777777777777775456"; +select to_oct(256*256*256 - 1) AS "77777777"; +select to_oct(256::bigint*256::bigint*256::bigint*256::bigint - 1) AS "37777777777"; + +select to_hex(-1234) AS "fffffb2e"; +select to_hex(-1234::bigint) AS "fffffffffffffb2e"; +select to_hex(256*256*256 - 1) AS "ffffff"; +select to_hex(256::bigint*256::bigint*256::bigint*256::bigint - 1) AS "ffffffff"; + +|-- +-- SHA-2 +|-- +SET bytea_output TO hex; + +SELECT sha224(''); +SELECT sha224('The quick brown fox jumps over the lazy dog.'); + +SELECT sha256(''); +SELECT sha256('The quick brown fox jumps over the lazy dog.'); + +SELECT sha384(''); +SELECT sha384('The quick brown fox jumps over the lazy dog.'); + +SELECT sha512(''); +SELECT sha512('The quick brown fox jumps over the lazy dog.'); + +|-- +-- encode/decode +|-- +SELECT encode('\x1234567890abcdef00', 'hex'); +SELECT decode('1234567890abcdef00', 'hex'); +SELECT encode(('\x' || repeat('1234567890abcdef0001', 7))::bytea, 'base64'); +SELECT decode(encode(('\x' || repeat('1234567890abcdef0001', 7))::bytea, + 'base64'), 'base64'); +SELECT encode('\x1234567890abcdef00', 'escape'); +SELECT decode(encode('\x1234567890abcdef00', 'escape'), 'escape'); + +|-- +-- get_bit/set_bit etc +|-- +SELECT get_bit('\x1234567890abcdef00'::bytea, 43); +SELECT get_bit('\x1234567890abcdef00'::bytea, 99); -- error +SELECT set_bit('\x1234567890abcdef00'::bytea, 43, 0); +SELECT set_bit('\x1234567890abcdef00'::bytea, 99, 0); -- error +SELECT get_byte('\x1234567890abcdef00'::bytea, 3); +SELECT get_byte('\x1234567890abcdef00'::bytea, 99); -- error +SELECT set_byte('\x1234567890abcdef00'::bytea, 7, 11); +SELECT set_byte('\x1234567890abcdef00'::bytea, 99, 11); -- error + +|-- +-- test behavior of escape_string_warning and standard_conforming_strings options +|-- +set escape_string_warning = off; +set standard_conforming_strings = off; + +show escape_string_warning; +show standard_conforming_strings; + +set escape_string_warning = on; +set standard_conforming_strings = on; + +show escape_string_warning; +show standard_conforming_strings; + +select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6; + +set standard_conforming_strings = off; + +select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6; + +set escape_string_warning = off; +set standard_conforming_strings = on; + +select 'a\bcd' as f1, 'a\b''cd' as f2, 'a\b''''cd' as f3, 'abcd\' as f4, 'ab\''cd' as f5, '\\' as f6; + +set standard_conforming_strings = off; + +select 'a\\bcd' as f1, 'a\\b\'cd' as f2, 'a\\b\'''cd' as f3, 'abcd\\' as f4, 'ab\\\'cd' as f5, '\\\\' as f6; + +reset standard_conforming_strings; + + +|-- +-- Additional string functions +|-- +SET bytea_output TO escape; + +SELECT initcap('hi THOMAS'); + +SELECT lpad('hi', 5, 'xy'); +SELECT lpad('hi', 5); +SELECT lpad('hi', -5, 'xy'); +SELECT lpad('hello', 2); +SELECT lpad('hi', 5, ''); + +SELECT rpad('hi', 5, 'xy'); +SELECT rpad('hi', 5); +SELECT rpad('hi', -5, 'xy'); +SELECT rpad('hello', 2); +SELECT rpad('hi', 5, ''); + +SELECT ltrim('zzzytrim', 'xyz'); + +SELECT translate('', '14', 'ax'); +SELECT translate('12345', '14', 'ax'); +SELECT translate('12345', '134', 'a'); + +SELECT ascii('x'); +SELECT ascii(''); + +SELECT chr(65); +SELECT chr(0); + +SELECT repeat('Pg', 4); +SELECT repeat('Pg', -4); + +SELECT SUBSTRING('1234567890'::bytea FROM 3) "34567890"; +SELECT SUBSTRING('1234567890'::bytea FROM 4 FOR 3) AS "456"; +SELECT SUBSTRING('string'::bytea FROM 2 FOR 2147483646) AS "tring"; +SELECT SUBSTRING('string'::bytea FROM -10 FOR 2147483646) AS "string"; +SELECT SUBSTRING('string'::bytea FROM -10 FOR -2147483646) AS "error"; + +SELECT trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea); +SELECT trim(leading E'\\000'::bytea from E'\\000Tom\\000'::bytea); +SELECT trim(trailing E'\\000'::bytea from E'\\000Tom\\000'::bytea); +SELECT btrim(E'\\000trim\\000'::bytea, E'\\000'::bytea); +SELECT btrim(''::bytea, E'\\000'::bytea); +SELECT btrim(E'\\000trim\\000'::bytea, ''::bytea); +SELECT encode(overlay(E'Th\\000omas'::bytea placing E'Th\\001omas'::bytea from 2),'escape'); +SELECT encode(overlay(E'Th\\000omas'::bytea placing E'\\002\\003'::bytea from 8),'escape'); +SELECT encode(overlay(E'Th\\000omas'::bytea placing E'\\002\\003'::bytea from 5 for 3),'escape'); + +SELECT bit_count('\x1234567890'::bytea); + +SELECT unistr('\0064at\+0000610'); +SELECT unistr('d\u0061t\U000000610'); +SELECT unistr('a\\b'); +-- errors: +SELECT unistr('wrong: \db99'); +SELECT unistr('wrong: \db99\0061'); +SELECT unistr('wrong: \+00db99\+000061'); +SELECT unistr('wrong: \+2FFFFF'); +SELECT unistr('wrong: \udb99\u0061'); +SELECT unistr('wrong: \U0000db99\U00000061'); +SELECT unistr('wrong: \U002FFFFF'); +SELECT unistr('wrong: \xyz'); +-- +ERROR: syntax error at or near "' - third line'" +CURSORPOS: 318 +FILENAME: scan.l +FUNCNAME: scanner_yyerror diff --git a/parser/testdata/summary_truncate/postgres_regress/subscription.metadata.json b/parser/testdata/summary_truncate/postgres_regress/subscription.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/subscription.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/subscription.test b/parser/testdata/summary_truncate/postgres_regress/subscription.test new file mode 100644 index 0000000..b39244a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/subscription.test @@ -0,0 +1,1048 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SUBSCRIPTION +|-- + +CREATE ROLE regress_subscription_user LOGIN SUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_subscription_user WITH LOGIN SUPERUSER" +== 002 +-- truncate_limit: 100 +CREATE ROLE regress_subscription_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_subscription_user2" +== 003 +-- truncate_limit: 100 +CREATE ROLE regress_subscription_user3 IN ROLE pg_create_subscription +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_subscription_user3 WITH IN ROLE pg_create_subscription" +== 004 +-- truncate_limit: 100 +CREATE ROLE regress_subscription_user_dummy LOGIN NOSUPERUSER +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_subscription_user_dummy WITH LOGIN NOSUPERUSER" +== 005 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION 'regress_subscription_user' +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user" +== 006 +-- truncate_limit: 100 +-- fail - no publications +CREATE SUBSCRIPTION regress_testsub CONNECTION 'foo' +-- +ERROR: syntax error at end of input +CURSORPOS: 79 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 007 +-- truncate_limit: 100 +-- fail - no connection +CREATE SUBSCRIPTION regress_testsub PUBLICATION foo +-- +ERROR: syntax error at or near "PUBLICATION" +CURSORPOS: 61 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 008 +-- truncate_limit: 100 +-- fail - cannot do CREATE SUBSCRIPTION CREATE SLOT inside transaction block +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 009 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'testconn' PUBLICATION testpub WITH (create_slot) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'testconn' PUBLICATION testpub WITH (create_slot)" +== 010 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 011 +-- truncate_limit: 100 +-- fail - invalid connection string +CREATE SUBSCRIPTION regress_testsub CONNECTION 'testconn' PUBLICATION testpub +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'testconn' PUBLICATION testpub" +== 012 +-- truncate_limit: 100 +-- fail - duplicate publications +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION foo, testpub, foo WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION foo, tes..." +== 013 +-- truncate_limit: 100 +-- ok +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 014 +-- truncate_limit: 100 +COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription'" +== 015 +-- truncate_limit: 100 +SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s +-- +TABLE: name="pg_subscription" schema="" table="pg_subscription" ctx=Select +ALIAS: "s"="pg_subscription" +FUNCTION: name="obj_description" function="obj_description" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s" +== 016 +-- truncate_limit: 100 +-- Check if the subscription stats are created and stats_reset is updated +-- by pg_stat_reset_subscription_stats(). +SELECT subname, stats_reset IS NULL stats_reset_is_null FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_stat_subscription_stats" schema="" table="pg_stat_subscription_stats" ctx=Select +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub'" +== 017 +-- truncate_limit: 100 +SELECT pg_stat_reset_subscription_stats(oid) FROM pg_subscription WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_subscription" schema="" table="pg_subscription" ctx=Select +FUNCTION: name="pg_stat_reset_subscription_stats" function="pg_stat_reset_subscription_stats" schema="" ctx=Call +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_subscription_stats(oid) FROM pg_subscription WHERE subname = 'regress_testsub'" +== 018 +-- truncate_limit: 100 +SELECT subname, stats_reset IS NULL stats_reset_is_null FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_stat_subscription_stats" schema="" table="pg_stat_subscription_stats" ctx=Select +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub'" +== 019 +-- truncate_limit: 100 +-- Reset the stats again and check if the new reset_stats is updated. +SELECT stats_reset as prev_stats_reset FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_stat_subscription_stats" schema="" table="pg_stat_subscription_stats" ctx=Select +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub'" +== 020 +-- truncate_limit: 100 +SELECT pg_stat_reset_subscription_stats(oid) FROM pg_subscription WHERE subname = 'regress_testsub' +-- +TABLE: name="pg_subscription" schema="" table="pg_subscription" ctx=Select +FUNCTION: name="pg_stat_reset_subscription_stats" function="pg_stat_reset_subscription_stats" schema="" ctx=Call +FILTER: schema="" table="" column="subname" +STMT: SelectStmt +TRUNCATED: "SELECT pg_stat_reset_subscription_stats(oid) FROM pg_subscription WHERE subname = 'regress_testsub'" +== 021 +-- truncate_limit: 100 +SELECT :'prev_stats_reset' < stats_reset FROM pg_stat_subscription_stats WHERE subname = 'regress_testsub' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 8 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 022 +-- truncate_limit: 100 +-- fail - name already exists +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 023 +-- truncate_limit: 100 +-- fail - must be superuser +SET SESSION AUTHORIZATION 'regress_subscription_user2' +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user2" +== 024 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION foo WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION foo WIT..." +== 025 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION 'regress_subscription_user' +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user" +== 026 +-- truncate_limit: 100 +-- fail - invalid option combinations +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, copy_data = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 027 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, enabled = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 028 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, create_slot = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 029 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, enabled = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 030 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, enabled = false, create_slot = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 031 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 032 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, enabled = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 033 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, create_slot = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub2 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 034 +-- truncate_limit: 100 +-- ok - with slot_name = NONE +CREATE SUBSCRIPTION regress_testsub3 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub3 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 035 +-- truncate_limit: 100 +-- fail +ALTER SUBSCRIPTION regress_testsub3 ENABLE +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub3 ENABLE" +== 036 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub3 REFRESH PUBLICATION +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub3 REFRESH PUBLICATION" +== 037 +-- truncate_limit: 100 +-- fail - origin must be either none or any +CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false, origin = foo) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 038 +-- truncate_limit: 100 +-- now it works +CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (slot_name = NONE, connect = false, origin = none) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub4 CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub..." +== 039 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub4 SET (origin = any) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub4 SET (origin = any)" +== 040 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub3 +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub3" +== 041 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub4 +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub4" +== 042 +-- truncate_limit: 100 +-- fail, connection string does not parse +CREATE SUBSCRIPTION regress_testsub5 CONNECTION 'i_dont_exist=param' PUBLICATION testpub +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub5 CONNECTION 'i_dont_exist=param' PUBLICATION testpub" +== 043 +-- truncate_limit: 100 +-- fail, connection string parses, but doesn't work (and does so without +-- connecting, so this is reliable and safe) +CREATE SUBSCRIPTION regress_testsub5 CONNECTION 'port=-1' PUBLICATION testpub +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub5 CONNECTION 'port=-1' PUBLICATION testpub" +== 044 +-- truncate_limit: 100 +-- fail - invalid connection string during ALTER +ALTER SUBSCRIPTION regress_testsub CONNECTION 'foobar' +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub CONNECTION 'foobar'" +== 045 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET PUBLICATION testpub2, testpub3 WITH (refresh = false)" +== 046 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist2' +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist2'" +== 047 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname') +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = 'newname')" +== 048 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (password_required = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (password_required = false)" +== 049 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = true)" +== 050 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (password_required = true) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (password_required = true)" +== 051 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (run_as_owner = false)" +== 052 +-- truncate_limit: 100 +-- fail +ALTER SUBSCRIPTION regress_testsub SET (slot_name = '') +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = '')" +== 053 +-- truncate_limit: 100 +-- fail +ALTER SUBSCRIPTION regress_doesnotexist CONNECTION 'dbname=regress_doesnotexist2' +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_doesnotexist CONNECTION 'dbname=regress_doesnotexist2'" +== 054 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (create_slot = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (create_slot = false)" +== 055 +-- truncate_limit: 100 +-- ok +ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/12345') +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/12345')" +== 056 +-- truncate_limit: 100 +-- ok - with lsn = NONE +ALTER SUBSCRIPTION regress_testsub SKIP (lsn = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SKIP (lsn = NONE)" +== 057 +-- truncate_limit: 100 +-- fail +ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/0') +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SKIP (lsn = '0/0')" +== 058 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 059 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub ENABLE +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub ENABLE" +== 060 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub DISABLE +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub DISABLE" +== 061 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 062 +-- truncate_limit: 100 +-- fail - must be owner of subscription +SET ROLE regress_subscription_user_dummy +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_subscription_user_dummy" +== 063 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_dummy +-- +STMT: RenameStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_dummy" +== 064 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 065 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_foo +-- +STMT: RenameStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub_foo" +== 066 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = local)" +== 067 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub_foo SET (synchronous_commit = foobar)" +== 068 +-- truncate_limit: 100 +-- rename back to keep the rest simple +ALTER SUBSCRIPTION regress_testsub_foo RENAME TO regress_testsub +-- +STMT: RenameStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub_foo RENAME TO regress_testsub" +== 069 +-- truncate_limit: 100 +-- ok, we're a superuser +ALTER SUBSCRIPTION regress_testsub OWNER TO regress_subscription_user2 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub OWNER TO regress_subscription_user2" +== 070 +-- truncate_limit: 100 +-- fail - cannot do DROP SUBSCRIPTION inside transaction block with slot name +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 071 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 072 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 073 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE)" +== 074 +-- truncate_limit: 100 +-- now it works +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 075 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 076 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 077 +-- truncate_limit: 100 +DROP SUBSCRIPTION IF EXISTS regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION IF EXISTS regress_testsub" +== 078 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 079 +-- truncate_limit: 100 +-- fail + +-- fail - binary must be boolean +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, binary = foo) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 080 +-- truncate_limit: 100 +-- now it works +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, binary = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 081 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (binary = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (\"binary\" = false)" +== 082 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE)" +== 083 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 084 +-- truncate_limit: 100 +-- fail - streaming must be boolean or 'parallel' +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, streaming = foo) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 085 +-- truncate_limit: 100 +-- now it works +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, streaming = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 086 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (streaming = parallel) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (streaming = parallel)" +== 087 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (streaming = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (streaming = false)" +== 088 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE)" +== 089 +-- truncate_limit: 100 +-- fail - publication already exists +ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub WITH (refresh = false)" +== 090 +-- truncate_limit: 100 +-- fail - publication used more than once +ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub1 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub1 WITH (refresh = false)" +== 091 +-- truncate_limit: 100 +-- ok - add two publications into subscription +ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false)" +== 092 +-- truncate_limit: 100 +-- fail - publications already exist +ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub ADD PUBLICATION testpub1, testpub2 WITH (refresh = false)" +== 093 +-- truncate_limit: 100 +-- fail - publication used more than once +ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub1 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub1 WITH (refresh = false)" +== 094 +-- truncate_limit: 100 +-- fail - all publications are deleted +ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub, testpub1, testpub2 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub, testpub1, testpub2 WITH (refresh = f..." +== 095 +-- truncate_limit: 100 +-- fail - publication does not exist in subscription +ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub3 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub3 WITH (refresh = false)" +== 096 +-- truncate_limit: 100 +-- ok - delete publications +ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (refresh = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub DROP PUBLICATION testpub1, testpub2 WITH (refresh = false)" +== 097 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 098 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION mypub + WITH (connect = false, create_slot = false, copy_data = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION mypub WI..." +== 099 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub ENABLE +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub ENABLE" +== 100 +-- truncate_limit: 100 +-- fail - ALTER SUBSCRIPTION with refresh is not allowed in a transaction +-- block or function +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 101 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET PUBLICATION mypub WITH (refresh = true) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET PUBLICATION mypub WITH (refresh = true)" +== 102 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 103 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 104 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub REFRESH PUBLICATION +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub REFRESH PUBLICATION" +== 105 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 106 +-- truncate_limit: 100 +CREATE FUNCTION func() RETURNS VOID AS +$$ ALTER SUBSCRIPTION regress_testsub SET PUBLICATION mypub WITH (refresh = true) $$ LANGUAGE SQL +-- +FUNCTION: name="func" function="func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION func() RETURNS void AS $$ ALTER SUBSCRIPTION regress_testsub SET PUBLICATION mypu..." +== 107 +-- truncate_limit: 100 +SELECT func() +-- +FUNCTION: name="func" function="func" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT func()" +== 108 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub DISABLE +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub DISABLE" +== 109 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE)" +== 110 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 111 +-- truncate_limit: 100 +DROP FUNCTION func +-- +FUNCTION: name="func" function="func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION func" +== 112 +-- truncate_limit: 100 +-- fail - two_phase must be boolean +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, two_phase = foo) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 113 +-- truncate_limit: 100 +-- now it works +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, two_phase = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 114 +-- truncate_limit: 100 +--fail - alter of two_phase option not supported. +ALTER SUBSCRIPTION regress_testsub SET (two_phase = false) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (two_phase = false)" +== 115 +-- truncate_limit: 100 +-- but can alter streaming when two_phase enabled +ALTER SUBSCRIPTION regress_testsub SET (streaming = true) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (streaming = true)" +== 116 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE)" +== 117 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 118 +-- truncate_limit: 100 +-- two_phase and streaming are compatible. +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, streaming = true, two_phase = true) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 119 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE)" +== 120 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 121 +-- truncate_limit: 100 +-- fail - disable_on_error must be boolean +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, disable_on_error = foo) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 122 +-- truncate_limit: 100 +-- now it works +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, disable_on_error = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 123 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (disable_on_error = true) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (disable_on_error = true)" +== 124 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE)" +== 125 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 126 +-- truncate_limit: 100 +-- let's do some tests with pg_create_subscription rather than superuser +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user3" +== 127 +-- truncate_limit: 100 +-- fail, not enough privileges +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 128 +-- truncate_limit: 100 +-- fail, must specify password +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 129 +-- truncate_limit: 100 +GRANT CREATE ON DATABASE REGRESSION TO regress_subscription_user3 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON DATABASE regression TO regress_subscription_user3" +== 130 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user3" +== 131 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 132 +-- truncate_limit: 100 +-- fail, can't set password_required=false +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 133 +-- truncate_limit: 100 +GRANT CREATE ON DATABASE REGRESSION TO regress_subscription_user3 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON DATABASE regression TO regress_subscription_user3" +== 134 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user3" +== 135 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false, password_required = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub ..." +== 136 +-- truncate_limit: 100 +-- ok +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 137 +-- truncate_limit: 100 +GRANT CREATE ON DATABASE REGRESSION TO regress_subscription_user3 +-- +STMT: GrantStmt +TRUNCATED: "GRANT create ON DATABASE regression TO regress_subscription_user3" +== 138 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user3" +== 139 +-- truncate_limit: 100 +CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist password=regress_fakepassword' PUBLICATION testpub WITH (connect = false) +-- +STMT: CreateSubscriptionStmt +TRUNCATED: "CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist password=regress_fake..." +== 140 +-- truncate_limit: 100 +-- we cannot give the subscription away to some random user +ALTER SUBSCRIPTION regress_testsub OWNER TO regress_subscription_user +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub OWNER TO regress_subscription_user" +== 141 +-- truncate_limit: 100 +-- but we can rename the subscription we just created +ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub2" +== 142 +-- truncate_limit: 100 +-- ok, even after losing pg_create_subscription we can still rename it +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 143 +-- truncate_limit: 100 +REVOKE pg_create_subscription FROM regress_subscription_user3 +-- +STMT: GrantRoleStmt +TRUNCATED: "REVOKE pg_create_subscription FROM regress_subscription_user3" +== 144 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user3" +== 145 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub2 RENAME TO regress_testsub +-- +STMT: RenameStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub2 RENAME TO regress_testsub" +== 146 +-- truncate_limit: 100 +-- fail, after losing CREATE on the database we can't rename it any more +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 147 +-- truncate_limit: 100 +REVOKE CREATE ON DATABASE REGRESSION FROM regress_subscription_user3 +-- +STMT: GrantStmt +TRUNCATED: "REVOKE create ON DATABASE regression FROM regress_subscription_user3" +== 148 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_subscription_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_subscription_user3" +== 149 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub2 +-- +STMT: RenameStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub RENAME TO regress_testsub2" +== 150 +-- truncate_limit: 100 +-- fail - cannot do ALTER SUBSCRIPTION SET (failover) inside transaction block +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 151 +-- truncate_limit: 100 +ALTER SUBSCRIPTION regress_testsub SET (failover) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (failover)" +== 152 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 153 +-- truncate_limit: 100 +-- ok, owning it is enough for this stuff +ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE) +-- +STMT: AlterSubscriptionStmt +TRUNCATED: "ALTER SUBSCRIPTION regress_testsub SET (slot_name = NONE)" +== 154 +-- truncate_limit: 100 +DROP SUBSCRIPTION regress_testsub +-- +STMT: DropSubscriptionStmt +TRUNCATED: "DROP SUBSCRIPTION regress_testsub" +== 155 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 156 +-- truncate_limit: 100 +DROP ROLE regress_subscription_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_subscription_user" +== 157 +-- truncate_limit: 100 +DROP ROLE regress_subscription_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_subscription_user2" +== 158 +-- truncate_limit: 100 +DROP ROLE regress_subscription_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_subscription_user3" +== 159 +-- truncate_limit: 100 +DROP ROLE regress_subscription_user_dummy +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_subscription_user_dummy" diff --git a/parser/testdata/summary_truncate/postgres_regress/subselect.metadata.json b/parser/testdata/summary_truncate/postgres_regress/subselect.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/subselect.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/subselect.test b/parser/testdata/summary_truncate/postgres_regress/subselect.test new file mode 100644 index 0000000..a30ce98 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/subselect.test @@ -0,0 +1,3098 @@ +== 001 +-- truncate_limit: 100 +|-- +-- SUBSELECT +|-- + +SELECT 1 AS one WHERE 1 IN (SELECT 1) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one WHERE 1 IN (SELECT 1)" +== 002 +-- truncate_limit: 100 +SELECT 1 AS zero WHERE 1 NOT IN (SELECT 1) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS zero WHERE NOT 1 IN (SELECT 1)" +== 003 +-- truncate_limit: 100 +SELECT 1 AS zero WHERE 1 IN (SELECT 2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS zero WHERE 1 IN (SELECT 2)" +== 004 +-- truncate_limit: 100 +-- Check grammar's handling of extra parens in assorted contexts + +SELECT * FROM (SELECT 1 AS x) ss +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT 1 AS x) ss" +== 005 +-- truncate_limit: 100 +SELECT * FROM ((SELECT 1 AS x)) ss +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT 1 AS x) ss" +== 006 +-- truncate_limit: 100 +SELECT * FROM ((SELECT 1 AS x)), ((SELECT * FROM ((SELECT 2 AS y)))) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT 1 AS x), (SELECT * FROM (SELECT 2 AS y))" +== 007 +-- truncate_limit: 100 +(SELECT 2) UNION SELECT 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 UNION SELECT 2" +== 008 +-- truncate_limit: 100 +((SELECT 2)) UNION SELECT 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2 UNION SELECT 2" +== 009 +-- truncate_limit: 100 +SELECT ((SELECT 2) UNION SELECT 2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT 2 UNION SELECT 2)" +== 010 +-- truncate_limit: 100 +SELECT (((SELECT 2)) UNION SELECT 2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT 2 UNION SELECT 2)" +== 011 +-- truncate_limit: 100 +SELECT (SELECT ARRAY[1,2,3])[1] +-- +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT ARRAY[1, 2, 3])[1]" +== 012 +-- truncate_limit: 100 +SELECT ((SELECT ARRAY[1,2,3]))[2] +-- +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT ARRAY[1, 2, 3])[2]" +== 013 +-- truncate_limit: 100 +SELECT (((SELECT ARRAY[1,2,3])))[3] +-- +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT ARRAY[1, 2, 3])[3]" +== 014 +-- truncate_limit: 100 +-- Set up some simple test tables + +CREATE TABLE SUBSELECT_TBL ( + f1 integer, + f2 integer, + f3 float +) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE subselect_tbl (f1 int, f2 int, f3 double precision)" +== 015 +-- truncate_limit: 100 +INSERT INTO SUBSELECT_TBL VALUES (1, 2, 3) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO subselect_tbl VALUES (1, 2, 3)" +== 016 +-- truncate_limit: 100 +INSERT INTO SUBSELECT_TBL VALUES (2, 3, 4) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO subselect_tbl VALUES (2, 3, 4)" +== 017 +-- truncate_limit: 100 +INSERT INTO SUBSELECT_TBL VALUES (3, 4, 5) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO subselect_tbl VALUES (3, 4, 5)" +== 018 +-- truncate_limit: 100 +INSERT INTO SUBSELECT_TBL VALUES (1, 1, 1) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO subselect_tbl VALUES (1, 1, 1)" +== 019 +-- truncate_limit: 100 +INSERT INTO SUBSELECT_TBL VALUES (2, 2, 2) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO subselect_tbl VALUES (2, 2, 2)" +== 020 +-- truncate_limit: 100 +INSERT INTO SUBSELECT_TBL VALUES (3, 3, 3) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO subselect_tbl VALUES (3, 3, 3)" +== 021 +-- truncate_limit: 100 +INSERT INTO SUBSELECT_TBL VALUES (6, 7, 8) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO subselect_tbl VALUES (6, 7, 8)" +== 022 +-- truncate_limit: 100 +INSERT INTO SUBSELECT_TBL VALUES (8, 9, NULL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO subselect_tbl VALUES (8, 9, NULL)" +== 023 +-- truncate_limit: 100 +SELECT * FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM subselect_tbl" +== 024 +-- truncate_limit: 100 +-- Uncorrelated subselects + +SELECT f1 AS "Constant Select" FROM SUBSELECT_TBL + WHERE f1 IN (SELECT 1) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Constant Select\" FROM subselect_tbl WHERE f1 IN (SELECT 1)" +== 025 +-- truncate_limit: 100 +SELECT f1 AS "Uncorrelated Field" FROM SUBSELECT_TBL + WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Uncorrelated Field\" FROM subselect_tbl WHERE f1 IN (SELECT f2 FROM subselect_tbl)" +== 026 +-- truncate_limit: 100 +SELECT f1 AS "Uncorrelated Field" FROM SUBSELECT_TBL + WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE + f2 IN (SELECT f1 FROM SUBSELECT_TBL)) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Uncorrelated Field\" FROM subselect_tbl WHERE ..." +== 027 +-- truncate_limit: 100 +SELECT f1, f2 + FROM SUBSELECT_TBL + WHERE (f1, f2) NOT IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL + WHERE f3 IS NOT NULL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="" column="f3" +STMT: SelectStmt +TRUNCATED: "SELECT f1, f2 FROM subselect_tbl WHERE NOT (f1, f2) IN (SELECT ... FROM subselect_tbl WHERE ...)" +== 028 +-- truncate_limit: 100 +-- Correlated subselects + +SELECT f1 AS "Correlated Field", f2 AS "Second Field" + FROM SUBSELECT_TBL upper + WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE f1 = upper.f1) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "upper"="subselect_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="upper" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Correlated Field\", f2 AS \"Second Field\" FROM subselect_tbl upper WHERE ..." +== 029 +-- truncate_limit: 100 +SELECT f1 AS "Correlated Field", f3 AS "Second Field" + FROM SUBSELECT_TBL upper + WHERE f1 IN + (SELECT f2 FROM SUBSELECT_TBL WHERE CAST(upper.f2 AS float) = f3) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "upper"="subselect_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="upper" column="f2" +FILTER: schema="" table="" column="f3" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Correlated Field\", f3 AS \"Second Field\" FROM subselect_tbl upper WHERE ..." +== 030 +-- truncate_limit: 100 +SELECT f1 AS "Correlated Field", f3 AS "Second Field" + FROM SUBSELECT_TBL upper + WHERE f3 IN (SELECT upper.f1 + f2 FROM SUBSELECT_TBL + WHERE f2 = CAST(f3 AS integer)) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "upper"="subselect_tbl" +FILTER: schema="" table="" column="f3" +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="" column="f3" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Correlated Field\", f3 AS \"Second Field\" FROM subselect_tbl upper WHERE ..." +== 031 +-- truncate_limit: 100 +SELECT f1 AS "Correlated Field" + FROM SUBSELECT_TBL + WHERE (f1, f2) IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL + WHERE f3 IS NOT NULL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +FILTER: schema="" table="" column="f3" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Correlated Field\" FROM subselect_tbl WHERE ..." +== 032 +-- truncate_limit: 100 +-- Check ROWCOMPARE cases, both correlated and not + +EXPLAIN (VERBOSE, COSTS OFF) +SELECT ROW(1, 2) = (SELECT f1, f2) AS eq FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT ROW(1, 2) = (SELECT f1, f2) AS eq FROM subselect_tbl" +== 033 +-- truncate_limit: 100 +SELECT ROW(1, 2) = (SELECT f1, f2) AS eq FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) = (SELECT f1, f2) AS eq FROM subselect_tbl" +== 034 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT ROW(1, 2) = (SELECT 3, 4) AS eq FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT ROW(1, 2) = (SELECT 3, 4) AS eq FROM subselect_tbl" +== 035 +-- truncate_limit: 100 +SELECT ROW(1, 2) = (SELECT 3, 4) AS eq FROM SUBSELECT_TBL +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) = (SELECT 3, 4) AS eq FROM subselect_tbl" +== 036 +-- truncate_limit: 100 +SELECT ROW(1, 2) = (SELECT f1, f2 FROM SUBSELECT_TBL) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ROW(1, 2) = (SELECT f1, f2 FROM subselect_tbl)" +== 037 +-- truncate_limit: 100 +-- error + +-- Subselects without aliases + +SELECT count FROM (SELECT COUNT(DISTINCT name) FROM road) +-- +TABLE: name="road" schema="" table="road" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count FROM (SELECT count(DISTINCT name) FROM road)" +== 038 +-- truncate_limit: 100 +SELECT COUNT(*) FROM (SELECT DISTINCT name FROM road) +-- +TABLE: name="road" schema="" table="road" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT DISTINCT name FROM road)" +== 039 +-- truncate_limit: 100 +SELECT * FROM (SELECT * FROM int4_tbl), (VALUES (123456)) WHERE f1 = column1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="column1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM int4_tbl), (VALUES (123456)) WHERE f1 = column1" +== 040 +-- truncate_limit: 100 +CREATE VIEW view_unnamed_ss AS +SELECT * FROM (SELECT * FROM (SELECT abs(f1) AS a1 FROM int4_tbl)), + (SELECT * FROM int8_tbl) + WHERE a1 < 10 AND q1 > a1 ORDER BY q1, q2 +-- +TABLE: name="view_unnamed_ss" schema="" table="view_unnamed_ss" ctx=DDL +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a1" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="a1" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view_unnamed_ss AS SELECT * FROM (SELECT * FROM (SELECT abs(f1) AS a1 FROM int4_tbl))..." +== 041 +-- truncate_limit: 100 +SELECT * FROM view_unnamed_ss +-- +TABLE: name="view_unnamed_ss" schema="" table="view_unnamed_ss" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM view_unnamed_ss" +== 042 +-- truncate_limit: 100 +DROP VIEW view_unnamed_ss +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW view_unnamed_ss" +== 043 +-- truncate_limit: 100 +-- Test matching of locking clause to correct alias + +CREATE VIEW view_unnamed_ss_locking AS +SELECT * FROM (SELECT * FROM int4_tbl), int8_tbl AS unnamed_subquery + WHERE f1 = q1 + FOR UPDATE OF unnamed_subquery +-- +TABLE: name="view_unnamed_ss_locking" schema="" table="view_unnamed_ss_locking" ctx=DDL +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "unnamed_subquery"="int8_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="q1" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW view_unnamed_ss_locking AS SELECT * FROM (SELECT * FROM int4_tbl), int8_tbl unnamed_s..." +== 044 +-- truncate_limit: 100 +DROP VIEW view_unnamed_ss_locking +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW view_unnamed_ss_locking" +== 045 +-- truncate_limit: 100 +|-- +-- Use some existing tables in the regression test +|-- + +SELECT ss.f1 AS "Correlated Field", ss.f3 AS "Second Field" + FROM SUBSELECT_TBL ss + WHERE f1 NOT IN (SELECT f1+1 FROM INT4_TBL + WHERE f1 != ss.f1 AND f1 < 2147483647) +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "ss"="subselect_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="ss" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT ss.f1 AS \"Correlated Field\", ss.f3 AS \"Second Field\" FROM subselect_tbl ss WHERE ..." +== 046 +-- truncate_limit: 100 +select q1, float8(count(*)) / (select count(*) from int8_tbl) +from int8_tbl group by q1 order by q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="float8" function="float8" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT q1, float8(count(*)) / (SELECT count(*) FROM int8_tbl) FROM int8_tbl GROUP BY q1 ORDER BY q1" +== 047 +-- truncate_limit: 100 +-- Unspecified-type literals in output columns should resolve as text + +SELECT *, pg_typeof(f1) FROM + (SELECT 'foo' AS f1 FROM generate_series(1,3)) ss ORDER BY 1 +-- +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT *, pg_typeof(f1) FROM (SELECT 'foo' AS f1 FROM generate_series(1, 3)) ss ORDER BY 1" +== 048 +-- truncate_limit: 100 +-- ... unless there's context to suggest differently + +explain (verbose, costs off) select '42' union all select '43' +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT '42' UNION ALL SELECT '43'" +== 049 +-- truncate_limit: 100 +explain (verbose, costs off) select '42' union all select 43 +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT '42' UNION ALL SELECT 43" +== 050 +-- truncate_limit: 100 +-- check materialization of an initplan reference (bug #14524) +explain (verbose, costs off) +select 1 = all (select (select 1)) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT 1 = ALL (SELECT (SELECT 1))" +== 051 +-- truncate_limit: 100 +select 1 = all (select (select 1)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 = ALL (SELECT (SELECT 1))" +== 052 +-- truncate_limit: 100 +|-- +-- Check EXISTS simplification with LIMIT +|-- +explain (costs off) +select * from int4_tbl o where exists + (select 1 from int4_tbl i where i.f1=o.f1 limit null) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="o" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl o WHERE EXISTS (SELECT 1 FROM int4_tbl i WHERE i.f1 = ..." +== 053 +-- truncate_limit: 100 +explain (costs off) +select * from int4_tbl o where not exists + (select 1 from int4_tbl i where i.f1=o.f1 limit 1) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="o" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl o WHERE NOT EXISTS (SELECT 1 FROM int4_tbl i WHERE i.f..." +== 054 +-- truncate_limit: 100 +explain (costs off) +select * from int4_tbl o where exists + (select 1 from int4_tbl i where i.f1=o.f1 limit 0) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FILTER: schema="" table="i" column="f1" +FILTER: schema="" table="o" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int4_tbl o WHERE EXISTS (SELECT 1 FROM int4_tbl i WHERE i.f1 = ..." +== 055 +-- truncate_limit: 100 +|-- +-- Test cases to catch unpleasant interactions between IN-join processing +-- and subquery pullup. +|-- + +select count(*) from + (select 1 from tenk1 a + where unique1 IN (select hundred from tenk1 b)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT 1 FROM tenk1 a WHERE unique1 IN (SELECT hundred FROM tenk1 b)) ss" +== 056 +-- truncate_limit: 100 +select count(distinct ss.ten) from + (select ten from tenk1 a + where unique1 IN (select hundred from tenk1 b)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT ss.ten) FROM (SELECT ten FROM tenk1 a WHERE ...) ss" +== 057 +-- truncate_limit: 100 +select count(*) from + (select 1 from tenk1 a + where unique1 IN (select distinct hundred from tenk1 b)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT 1 FROM tenk1 a WHERE ...) ss" +== 058 +-- truncate_limit: 100 +select count(distinct ss.ten) from + (select ten from tenk1 a + where unique1 IN (select distinct hundred from tenk1 b)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT ss.ten) FROM (SELECT ten FROM tenk1 a WHERE ...) ss" +== 059 +-- truncate_limit: 100 +|-- +-- Test cases to check for overenthusiastic optimization of +-- "IN (SELECT DISTINCT ...)" and related cases. Per example from +-- Luca Pireddu and Michael Fuhr. +|-- + +CREATE TEMP TABLE foo (id integer) +-- +TABLE: name="foo" schema="" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE foo (id int)" +== 060 +-- truncate_limit: 100 +CREATE TEMP TABLE bar (id1 integer, id2 integer) +-- +TABLE: name="bar" schema="" table="bar" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE bar (id1 int, id2 int)" +== 061 +-- truncate_limit: 100 +INSERT INTO foo VALUES (1) +-- +TABLE: name="foo" schema="" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO foo VALUES (1)" +== 062 +-- truncate_limit: 100 +INSERT INTO bar VALUES (1, 1) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar VALUES (1, 1)" +== 063 +-- truncate_limit: 100 +INSERT INTO bar VALUES (2, 2) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar VALUES (2, 2)" +== 064 +-- truncate_limit: 100 +INSERT INTO bar VALUES (3, 1) +-- +TABLE: name="bar" schema="" table="bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO bar VALUES (3, 1)" +== 065 +-- truncate_limit: 100 +-- These cases require an extra level of distinct-ing above subquery s +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT DISTINCT id1, id2 FROM bar) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo WHERE id IN (SELECT id2 FROM (SELECT DISTINCT id1, id2 FROM bar) s)" +== 066 +-- truncate_limit: 100 +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT id1,id2 FROM bar GROUP BY id1,id2) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo WHERE id IN (SELECT id2 FROM (SELECT id1, id2 FROM bar GROUP BY id1, id2) s)" +== 067 +-- truncate_limit: 100 +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT id1, id2 FROM bar UNION + SELECT id1, id2 FROM bar) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo WHERE id IN (SELECT id2 FROM (SELECT ... FROM bar UNION SELECT ... FROM bar) s)" +== 068 +-- truncate_limit: 100 +-- These cases do not +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT DISTINCT ON (id2) id1, id2 FROM bar) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo WHERE id IN (SELECT id2 FROM (SELECT DISTINCT ON (id2) id1, id2 FROM bar) s)" +== 069 +-- truncate_limit: 100 +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT id2 FROM bar GROUP BY id2) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo WHERE id IN (SELECT id2 FROM (SELECT id2 FROM bar GROUP BY id2) s)" +== 070 +-- truncate_limit: 100 +SELECT * FROM foo WHERE id IN + (SELECT id2 FROM (SELECT id2 FROM bar UNION + SELECT id2 FROM bar) AS s) +-- +TABLE: name="foo" schema="" table="foo" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +TABLE: name="bar" schema="" table="bar" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM foo WHERE id IN (SELECT id2 FROM (SELECT id2 FROM bar UNION SELECT id2 FROM bar) s)" +== 071 +-- truncate_limit: 100 +|-- +-- Test case to catch problems with multiply nested sub-SELECTs not getting +-- recalculated properly. Per bug report from Didier Moens. +|-- + +CREATE TABLE orderstest ( + approver_ref integer, + po_ref integer, + ordercanceled boolean +) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE orderstest (approver_ref int, po_ref int, ordercanceled boolean)" +== 072 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (1, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (1, 1, false)" +== 073 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (66, 5, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (66, 5, false)" +== 074 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (66, 6, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (66, 6, false)" +== 075 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (66, 7, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (66, 7, false)" +== 076 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (66, 1, true) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (66, 1, true)" +== 077 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (66, 8, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (66, 8, false)" +== 078 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (66, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (66, 1, false)" +== 079 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (77, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (77, 1, false)" +== 080 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (1, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (1, 1, false)" +== 081 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (66, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (66, 1, false)" +== 082 +-- truncate_limit: 100 +INSERT INTO orderstest VALUES (1, 1, false) +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO orderstest VALUES (1, 1, false)" +== 083 +-- truncate_limit: 100 +CREATE VIEW orders_view AS +SELECT *, +(SELECT CASE + WHEN ord.approver_ref=1 THEN '---' ELSE 'Approved' + END) AS "Approved", +(SELECT CASE + WHEN ord.ordercanceled + THEN 'Canceled' + ELSE + (SELECT CASE + WHEN ord.po_ref=1 + THEN + (SELECT CASE + WHEN ord.approver_ref=1 + THEN '---' + ELSE 'Approved' + END) + ELSE 'PO' + END) +END) AS "Status", +(CASE + WHEN ord.ordercanceled + THEN 'Canceled' + ELSE + (CASE + WHEN ord.po_ref=1 + THEN + (CASE + WHEN ord.approver_ref=1 + THEN '---' + ELSE 'Approved' + END) + ELSE 'PO' + END) +END) AS "Status_OK" +FROM orderstest ord +-- +TABLE: name="orders_view" schema="" table="orders_view" ctx=DDL +TABLE: name="orderstest" schema="" table="orderstest" ctx=Select +ALIAS: "ord"="orderstest" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW orders_view AS SELECT *, (SELECT CASE WHEN ord.approver_ref = 1 THEN '---' ELSE 'Appr..." +== 084 +-- truncate_limit: 100 +SELECT * FROM orders_view +-- +TABLE: name="orders_view" schema="" table="orders_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM orders_view" +== 085 +-- truncate_limit: 100 +DROP TABLE orderstest cascade +-- +TABLE: name="orderstest" schema="" table="orderstest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE orderstest CASCADE" +== 086 +-- truncate_limit: 100 +|-- +-- Test cases to catch situations where rule rewriter fails to propagate +-- hasSubLinks flag correctly. Per example from Kyle Bateman. +|-- + +create temp table parts ( + partnum text, + cost float8 +) +-- +TABLE: name="parts" schema="" table="parts" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parts (partnum text, cost float8)" +== 087 +-- truncate_limit: 100 +create temp table shipped ( + ttype char(2), + ordnum int4, + partnum text, + value float8 +) +-- +TABLE: name="shipped" schema="" table="shipped" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE shipped (ttype char(2), ordnum int4, partnum text, value float8)" +== 088 +-- truncate_limit: 100 +create temp view shipped_view as + select * from shipped where ttype = 'wt' +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DDL +TABLE: name="shipped" schema="" table="shipped" ctx=Select +FILTER: schema="" table="" column="ttype" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW shipped_view AS SELECT * FROM shipped WHERE ttype = 'wt'" +== 089 +-- truncate_limit: 100 +create rule shipped_view_insert as on insert to shipped_view do instead + insert into shipped values('wt', new.ordnum, new.partnum, new.value) +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE shipped_view_insert AS ON INSERT TO shipped_view DO INSTEAD INSERT INTO shipped VALUE..." +== 090 +-- truncate_limit: 100 +insert into parts (partnum, cost) values (1, 1234.56) +-- +TABLE: name="parts" schema="" table="parts" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parts (partnum, cost) VALUES (1, 1234.56)" +== 091 +-- truncate_limit: 100 +insert into shipped_view (ordnum, partnum, value) + values (0, 1, (select cost from parts where partnum = '1')) +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DML +TABLE: name="parts" schema="" table="parts" ctx=Select +FILTER: schema="" table="" column="partnum" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shipped_view (ordnum, partnum, value) VALUES (0, 1, (SELECT cost FROM parts WHERE ...))" +== 092 +-- truncate_limit: 100 +select * from shipped_view +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shipped_view" +== 093 +-- truncate_limit: 100 +create rule shipped_view_update as on update to shipped_view do instead + update shipped set partnum = new.partnum, value = new.value + where ttype = new.ttype and ordnum = new.ordnum +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE shipped_view_update AS ON UPDATE TO shipped_view DO INSTEAD UPDATE shipped SET partnu..." +== 094 +-- truncate_limit: 100 +update shipped_view set value = 11 + from int4_tbl a join int4_tbl b + on (a.f1 = (select f1 from int4_tbl c where c.f1=b.f1)) + where ordnum = a.f1 +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +ALIAS: "c"="int4_tbl" +FILTER: schema="" table="c" column="f1" +FILTER: schema="" table="b" column="f1" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE shipped_view SET ... = ... FROM int4_tbl a JOIN int4_tbl b ON a.f1 = (SELECT f1 FROM int4_..." +== 095 +-- truncate_limit: 100 +select * from shipped_view +-- +TABLE: name="shipped_view" schema="" table="shipped_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM shipped_view" +== 096 +-- truncate_limit: 100 +select f1, ss1 as relabel from + (select *, (select sum(f1) from int4_tbl b where f1 >= a.f1) as ss1 + from int4_tbl a) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "a"="int4_tbl" +ALIAS: "b"="int4_tbl" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="a" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1, ss1 AS relabel FROM (SELECT ... FROM int4_tbl a) ss" +== 097 +-- truncate_limit: 100 +|-- +-- Test cases involving PARAM_EXEC parameters and min/max index optimizations. +-- Per bug report from David Sanchez i Gregori. +|-- + +select * from ( + select max(unique1) from tenk1 as a + where exists (select 1 from tenk1 as b where b.thousand = a.unique2) +) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="max" function="max" schema="" ctx=Call +FILTER: schema="" table="b" column="thousand" +FILTER: schema="" table="a" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT max(unique1) FROM tenk1 a WHERE EXISTS (SELECT 1 FROM tenk1 b WHERE ...)) ss" +== 098 +-- truncate_limit: 100 +select * from ( + select min(unique1) from tenk1 as a + where not exists (select 1 from tenk1 as b where b.unique2 = 10000) +) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="b" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT min(unique1) FROM tenk1 a WHERE ...) ss" +== 099 +-- truncate_limit: 100 +|-- +-- Test that an IN implemented using a UniquePath does unique-ification +-- with the right semantics, as per bug #4113. (Unfortunately we have +-- no simple way to ensure that this test case actually chooses that type +-- of plan, but it does in releases 7.4-8.3. Note that an ordering difference +-- here might mean that some other plan type is being used, rendering the test +-- pointless.) +|-- + +create temp table numeric_table (num_col numeric) +-- +TABLE: name="numeric_table" schema="" table="numeric_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE numeric_table (num_col numeric)" +== 100 +-- truncate_limit: 100 +insert into numeric_table values (1), (1.000000000000000000001), (2), (3) +-- +TABLE: name="numeric_table" schema="" table="numeric_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numeric_table VALUES (1), (1.000000000000000000001), (2), (3)" +== 101 +-- truncate_limit: 100 +create temp table float_table (float_col float8) +-- +TABLE: name="float_table" schema="" table="float_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE float_table (float_col float8)" +== 102 +-- truncate_limit: 100 +insert into float_table values (1), (2), (3) +-- +TABLE: name="float_table" schema="" table="float_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float_table VALUES (1), (2), (3)" +== 103 +-- truncate_limit: 100 +select * from float_table + where float_col in (select num_col from numeric_table) +-- +TABLE: name="float_table" schema="" table="float_table" ctx=Select +TABLE: name="numeric_table" schema="" table="numeric_table" ctx=Select +FILTER: schema="" table="" column="float_col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM float_table WHERE float_col IN (SELECT num_col FROM numeric_table)" +== 104 +-- truncate_limit: 100 +select * from numeric_table + where num_col in (select float_col from float_table) +-- +TABLE: name="numeric_table" schema="" table="numeric_table" ctx=Select +TABLE: name="float_table" schema="" table="float_table" ctx=Select +FILTER: schema="" table="" column="num_col" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM numeric_table WHERE num_col IN (SELECT float_col FROM float_table)" +== 105 +-- truncate_limit: 100 +|-- +-- Test case for bug #4290: bogus calculation of subplan param sets +|-- + +create temp table ta (id int primary key, val int) +-- +TABLE: name="ta" schema="" table="ta" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE ta (id int PRIMARY KEY, val int)" +== 106 +-- truncate_limit: 100 +insert into ta values(1,1) +-- +TABLE: name="ta" schema="" table="ta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ta VALUES (1, 1)" +== 107 +-- truncate_limit: 100 +insert into ta values(2,2) +-- +TABLE: name="ta" schema="" table="ta" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ta VALUES (2, 2)" +== 108 +-- truncate_limit: 100 +create temp table tb (id int primary key, aval int) +-- +TABLE: name="tb" schema="" table="tb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tb (id int PRIMARY KEY, aval int)" +== 109 +-- truncate_limit: 100 +insert into tb values(1,1) +-- +TABLE: name="tb" schema="" table="tb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tb VALUES (1, 1)" +== 110 +-- truncate_limit: 100 +insert into tb values(2,1) +-- +TABLE: name="tb" schema="" table="tb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tb VALUES (2, 1)" +== 111 +-- truncate_limit: 100 +insert into tb values(3,2) +-- +TABLE: name="tb" schema="" table="tb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tb VALUES (3, 2)" +== 112 +-- truncate_limit: 100 +insert into tb values(4,2) +-- +TABLE: name="tb" schema="" table="tb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tb VALUES (4, 2)" +== 113 +-- truncate_limit: 100 +create temp table tc (id int primary key, aid int) +-- +TABLE: name="tc" schema="" table="tc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tc (id int PRIMARY KEY, aid int)" +== 114 +-- truncate_limit: 100 +insert into tc values(1,1) +-- +TABLE: name="tc" schema="" table="tc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tc VALUES (1, 1)" +== 115 +-- truncate_limit: 100 +insert into tc values(2,2) +-- +TABLE: name="tc" schema="" table="tc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tc VALUES (2, 2)" +== 116 +-- truncate_limit: 100 +select + ( select min(tb.id) from tb + where tb.aval = (select ta.val from ta where ta.id = tc.aid) ) as min_tb_id +from tc +-- +TABLE: name="tc" schema="" table="tc" ctx=Select +TABLE: name="tb" schema="" table="tb" ctx=Select +TABLE: name="ta" schema="" table="ta" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="tb" column="aval" +FILTER: schema="" table="ta" column="id" +FILTER: schema="" table="tc" column="aid" +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT min(tb.id) FROM tb WHERE ...) AS min_tb_id FROM tc" +== 117 +-- truncate_limit: 100 +|-- +-- Test case for 8.3 "failed to locate grouping columns" bug +|-- + +create temp table t1 (f1 numeric(14,0), f2 varchar(30)) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (f1 numeric(14, 0), f2 varchar(30))" +== 118 +-- truncate_limit: 100 +select * from + (select distinct f1, f2, (select f2 from t1 x where x.f1 = up.f1) as fs + from t1 up) ss +group by f1,f2,fs +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t1" schema="" table="t1" ctx=Select +ALIAS: "up"="t1" +ALIAS: "x"="t1" +FILTER: schema="" table="x" column="f1" +FILTER: schema="" table="up" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT DISTINCT ... AS ... FROM t1 up) ss GROUP BY f1, f2, fs" +== 119 +-- truncate_limit: 100 +|-- +-- Test case for bug #5514 (mishandling of whole-row Vars in subselects) +|-- + +create temp table table_a(id integer) +-- +TABLE: name="table_a" schema="" table="table_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE table_a (id int)" +== 120 +-- truncate_limit: 100 +insert into table_a values (42) +-- +TABLE: name="table_a" schema="" table="table_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO table_a VALUES (42)" +== 121 +-- truncate_limit: 100 +create temp view view_a as select * from table_a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=DDL +TABLE: name="table_a" schema="" table="table_a" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW view_a AS SELECT * FROM table_a" +== 122 +-- truncate_limit: 100 +select view_a from view_a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT view_a FROM view_a" +== 123 +-- truncate_limit: 100 +select (select view_a) from view_a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT view_a) FROM view_a" +== 124 +-- truncate_limit: 100 +select (select (select view_a)) from view_a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT (SELECT view_a)) FROM view_a" +== 125 +-- truncate_limit: 100 +select (select (a.*)::text) from view_a a +-- +TABLE: name="view_a" schema="" table="view_a" ctx=Select +ALIAS: "a"="view_a" +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT a.*::text) FROM view_a a" +== 126 +-- truncate_limit: 100 +|-- +-- Test case for bug #19037: no relation entry for relid N +|-- + +explain (costs off) +select (1 = any(array_agg(f1))) = any (select false) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 = ANY(array_agg(f1)) = ANY (SELECT false) FROM int4_tbl" +== 127 +-- truncate_limit: 100 +select (1 = any(array_agg(f1))) = any (select false) from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 1 = ANY(array_agg(f1)) = ANY (SELECT false) FROM int4_tbl" +== 128 +-- truncate_limit: 100 +|-- +-- Check that whole-row Vars reading the result of a subselect don't include +-- any junk columns therein +|-- + +select q from (select max(f1) from int4_tbl group by f1 order by f1) q +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT q FROM (SELECT max(f1) FROM int4_tbl GROUP BY f1 ORDER BY f1) q" +== 129 +-- truncate_limit: 100 +with q as (select max(f1) from int4_tbl group by f1 order by f1) + select q from q +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "q" +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH q AS (SELECT max(f1) FROM int4_tbl GROUP BY f1 ORDER BY f1) SELECT q FROM q" +== 130 +-- truncate_limit: 100 +|-- +-- Test case for sublinks pulled up into joinaliasvars lists in an +-- inherited update/delete query +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 131 +-- truncate_limit: 100 +-- this shouldn't delete anything, but be safe + +delete from road +where exists ( + select 1 + from + int4_tbl cross join + ( select f1, array(select q1 from int8_tbl) as arr + from text_tbl ) ss + where road.name = ss.f1 ) +-- +TABLE: name="road" schema="" table="road" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FILTER: schema="" table="road" column="name" +FILTER: schema="" table="ss" column="f1" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "DELETE FROM road WHERE ..." +== 132 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 133 +-- truncate_limit: 100 +|-- +-- Test case for sublinks pushed down into subselects via join alias expansion +|-- + +select + (select sq1) as qq1 +from + (select exists(select 1 from int4_tbl where f1 = q2) as sq1, 42 as dummy + from int8_tbl) sq0 + join + int4_tbl i4 on dummy = i4.f1 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT sq1) AS qq1 FROM (SELECT ... FROM int8_tbl) sq0 JOIN int4_tbl i4 ON dummy = i4.f1" +== 134 +-- truncate_limit: 100 +|-- +-- Test case for subselect within UPDATE of INSERT...ON CONFLICT DO UPDATE +|-- +create temp table upsert(key int4 primary key, val text) +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE upsert (key int4 PRIMARY KEY, val text)" +== 135 +-- truncate_limit: 100 +insert into upsert values(1, 'val') on conflict (key) do update set val = 'not seen' +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (1, 'val') ON CONFLICT (key) DO UPDATE SET val = 'not seen'" +== 136 +-- truncate_limit: 100 +insert into upsert values(1, 'val') on conflict (key) do update set val = 'seen with subselect ' || (select f1 from int4_tbl where f1 != 0 limit 1)::text +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (1, 'val') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 137 +-- truncate_limit: 100 +select * from upsert +-- +TABLE: name="upsert" schema="" table="upsert" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM upsert" +== 138 +-- truncate_limit: 100 +with aa as (select 'int4_tbl' u from int4_tbl limit 1) +insert into upsert values (1, 'x'), (999, 'y') +on conflict (key) do update set val = (select u from aa) +returning * +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "aa" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aa AS (...) INSERT INTO upsert VALUES (...) ON CONFLICT (key) DO UPDATE SET ... = ... RETURN..." +== 139 +-- truncate_limit: 100 +|-- +-- Test case for cross-type partial matching in hashed subplan (bug #7597) +|-- + +create temp table outer_7597 (f1 int4, f2 int4) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE outer_7597 (f1 int4, f2 int4)" +== 140 +-- truncate_limit: 100 +insert into outer_7597 values (0, 0) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_7597 VALUES (0, 0)" +== 141 +-- truncate_limit: 100 +insert into outer_7597 values (1, 0) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_7597 VALUES (1, 0)" +== 142 +-- truncate_limit: 100 +insert into outer_7597 values (0, null) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_7597 VALUES (0, NULL)" +== 143 +-- truncate_limit: 100 +insert into outer_7597 values (1, null) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_7597 VALUES (1, NULL)" +== 144 +-- truncate_limit: 100 +create temp table inner_7597(c1 int8, c2 int8) +-- +TABLE: name="inner_7597" schema="" table="inner_7597" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE inner_7597 (c1 int8, c2 int8)" +== 145 +-- truncate_limit: 100 +insert into inner_7597 values(0, null) +-- +TABLE: name="inner_7597" schema="" table="inner_7597" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inner_7597 VALUES (0, NULL)" +== 146 +-- truncate_limit: 100 +select * from outer_7597 where (f1, f2) not in (select * from inner_7597) +-- +TABLE: name="outer_7597" schema="" table="outer_7597" ctx=Select +TABLE: name="inner_7597" schema="" table="inner_7597" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM outer_7597 WHERE NOT (f1, f2) IN (SELECT * FROM inner_7597)" +== 147 +-- truncate_limit: 100 +|-- +-- Similar test case using text that verifies that collation +-- information is passed through by execTuplesEqual() in nodeSubplan.c +-- (otherwise it would error in texteq()) +|-- + +create temp table outer_text (f1 text, f2 text) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE outer_text (f1 text, f2 text)" +== 148 +-- truncate_limit: 100 +insert into outer_text values ('a', 'a') +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_text VALUES ('a', 'a')" +== 149 +-- truncate_limit: 100 +insert into outer_text values ('b', 'a') +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_text VALUES ('b', 'a')" +== 150 +-- truncate_limit: 100 +insert into outer_text values ('a', null) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_text VALUES ('a', NULL)" +== 151 +-- truncate_limit: 100 +insert into outer_text values ('b', null) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO outer_text VALUES ('b', NULL)" +== 152 +-- truncate_limit: 100 +create temp table inner_text (c1 text, c2 text) +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE inner_text (c1 text, c2 text)" +== 153 +-- truncate_limit: 100 +insert into inner_text values ('a', null) +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inner_text VALUES ('a', NULL)" +== 154 +-- truncate_limit: 100 +insert into inner_text values ('123', '456') +-- +TABLE: name="inner_text" schema="" table="inner_text" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO inner_text VALUES ('123', '456')" +== 155 +-- truncate_limit: 100 +select * from outer_text where (f1, f2) not in (select * from inner_text) +-- +TABLE: name="outer_text" schema="" table="outer_text" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM outer_text WHERE NOT (f1, f2) IN (SELECT * FROM inner_text)" +== 156 +-- truncate_limit: 100 +|-- +-- Another test case for cross-type hashed subplans: comparison of +-- inner-side values must be done with appropriate operator +|-- + +explain (verbose, costs off) +select 'foo'::text in (select 'bar'::name union all select 'bar'::name) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT 'foo'::text IN (SELECT 'bar'::name UNION ALL SELECT 'bar'::name)" +== 157 +-- truncate_limit: 100 +select 'foo'::text in (select 'bar'::name union all select 'bar'::name) +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo'::text IN (SELECT 'bar'::name UNION ALL SELECT 'bar'::name)" +== 158 +-- truncate_limit: 100 +|-- +-- Test that we don't try to hash nested records (bug #17363) +-- (Hashing could be supported, but for now we don't) +|-- + +explain (verbose, costs off) +select row(row(row(1))) = any (select row(row(1))) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT ROW(ROW(ROW(1))) = ANY (SELECT ROW(ROW(1)))" +== 159 +-- truncate_limit: 100 +select row(row(row(1))) = any (select row(row(1))) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ROW(ROW(ROW(1))) = ANY (SELECT ROW(ROW(1)))" +== 160 +-- truncate_limit: 100 +|-- +-- Test case for premature memory release during hashing of subplan output +|-- + +select '1'::text in (select '1'::name union all select '1'::name) +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::text IN (SELECT '1'::name UNION ALL SELECT '1'::name)" +== 161 +-- truncate_limit: 100 +|-- +-- Test that we don't try to use a hashed subplan if the simplified +-- testexpr isn't of the right shape +|-- + +-- this fails by default, of course +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q1 IN (SELECT c1 FROM inner_text)" +== 162 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 163 +-- truncate_limit: 100 +-- make an operator to allow it to succeed +create function bogus_int8_text_eq(int8, text) returns boolean +language sql as 'select $1::text = $2' +-- +FUNCTION: name="bogus_int8_text_eq" function="bogus_int8_text_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bogus_int8_text_eq(int8, text) RETURNS boolean LANGUAGE sql AS $$select $1::text ..." +== 164 +-- truncate_limit: 100 +create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR = (procedure = bogus_int8_text_eq, leftarg = int8, rightarg = text)" +== 165 +-- truncate_limit: 100 +explain (costs off) +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl WHERE q1 IN (SELECT c1 FROM inner_text)" +== 166 +-- truncate_limit: 100 +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q1 IN (SELECT c1 FROM inner_text)" +== 167 +-- truncate_limit: 100 +-- inlining of this function results in unusual number of hash clauses, +-- which we can still cope with +create or replace function bogus_int8_text_eq(int8, text) returns boolean +language sql as 'select $1::text = $2 and $1::text = $2' +-- +FUNCTION: name="bogus_int8_text_eq" function="bogus_int8_text_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION bogus_int8_text_eq(int8, text) RETURNS boolean LANGUAGE sql AS $$selec..." +== 168 +-- truncate_limit: 100 +explain (costs off) +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl WHERE q1 IN (SELECT c1 FROM inner_text)" +== 169 +-- truncate_limit: 100 +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q1 IN (SELECT c1 FROM inner_text)" +== 170 +-- truncate_limit: 100 +-- inlining of this function causes LHS and RHS to be switched, +-- which we can't cope with, so hashing should be abandoned +create or replace function bogus_int8_text_eq(int8, text) returns boolean +language sql as 'select $2 = $1::text' +-- +FUNCTION: name="bogus_int8_text_eq" function="bogus_int8_text_eq" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION bogus_int8_text_eq(int8, text) RETURNS boolean LANGUAGE sql AS $$selec..." +== 171 +-- truncate_limit: 100 +explain (costs off) +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM int8_tbl WHERE q1 IN (SELECT c1 FROM inner_text)" +== 172 +-- truncate_limit: 100 +select * from int8_tbl where q1 in (select c1 from inner_text) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="inner_text" schema="" table="inner_text" ctx=Select +FILTER: schema="" table="" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl WHERE q1 IN (SELECT c1 FROM inner_text)" +== 173 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 174 +-- truncate_limit: 100 +-- to get rid of the bogus operator + +|-- +-- Test resolution of hashed vs non-hashed implementation of EXISTS subplan +|-- +explain (costs off) +select count(*) from tenk1 t +where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "k"="tenk1" +ALIAS: "t"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="k" column="unique1" +FILTER: schema="" table="t" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 t WHERE EXISTS (SELECT 1 FROM tenk1 k WHERE k.uniq..." +== 175 +-- truncate_limit: 100 +select count(*) from tenk1 t +where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "k"="tenk1" +ALIAS: "t"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="k" column="unique1" +FILTER: schema="" table="t" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 t WHERE EXISTS (SELECT 1 FROM tenk1 k WHERE ...) OR ten < 0" +== 176 +-- truncate_limit: 100 +explain (costs off) +select count(*) from tenk1 t +where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0) + and thousand = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "k"="tenk1" +ALIAS: "t"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="k" column="unique1" +FILTER: schema="" table="t" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 t WHERE (EXISTS (SELECT 1 FROM tenk1 k WHERE k.uni..." +== 177 +-- truncate_limit: 100 +select count(*) from tenk1 t +where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0) + and thousand = 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "k"="tenk1" +ALIAS: "t"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="k" column="unique1" +FILTER: schema="" table="t" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 t WHERE ..." +== 178 +-- truncate_limit: 100 +-- It's possible for the same EXISTS to get resolved both ways +create temp table exists_tbl (c1 int, c2 int, c3 int) partition by list (c1) +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE exists_tbl (c1 int, c2 int, c3 int) PARTITION BY LIST (c1)" +== 179 +-- truncate_limit: 100 +create temp table exists_tbl_null partition of exists_tbl for values in (null) +-- +TABLE: name="exists_tbl_null" schema="" table="exists_tbl_null" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE exists_tbl_null PARTITION OF exists_tbl FOR VALUES IN (NULL)" +== 180 +-- truncate_limit: 100 +create temp table exists_tbl_def partition of exists_tbl default +-- +TABLE: name="exists_tbl_def" schema="" table="exists_tbl_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE exists_tbl_def PARTITION OF exists_tbl DEFAULT" +== 181 +-- truncate_limit: 100 +insert into exists_tbl select x, x/2, x+1 from generate_series(0,10) x +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO exists_tbl SELECT x, x / 2, x + 1 FROM generate_series(0, 10) x" +== 182 +-- truncate_limit: 100 +analyze exists_tbl +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE exists_tbl" +== 183 +-- truncate_limit: 100 +explain (costs off) +select * from exists_tbl t1 + where (exists(select 1 from exists_tbl t2 where t1.c1 = t2.c2) or c3 < 0) +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=Select +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=Select +ALIAS: "t1"="exists_tbl" +ALIAS: "t2"="exists_tbl" +FILTER: schema="" table="t1" column="c1" +FILTER: schema="" table="t2" column="c2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM exists_tbl t1 WHERE EXISTS (SELECT 1 FROM exists_tbl t2 WHERE t..." +== 184 +-- truncate_limit: 100 +select * from exists_tbl t1 + where (exists(select 1 from exists_tbl t2 where t1.c1 = t2.c2) or c3 < 0) +-- +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=Select +TABLE: name="exists_tbl" schema="" table="exists_tbl" ctx=Select +ALIAS: "t1"="exists_tbl" +ALIAS: "t2"="exists_tbl" +FILTER: schema="" table="t1" column="c1" +FILTER: schema="" table="t2" column="c2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM exists_tbl t1 WHERE EXISTS (SELECT 1 FROM exists_tbl t2 WHERE t1.c1 = t2.c2) OR c3 < 0" +== 185 +-- truncate_limit: 100 +|-- +-- Test case for planner bug with nested EXISTS handling +|-- +select a.thousand from tenk1 a, tenk1 b +where a.thousand = b.thousand + and exists ( select 1 from tenk1 c where b.hundred = c.hundred + and not exists ( select 1 from tenk1 d + where a.thousand = d.thousand ) ) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +ALIAS: "c"="tenk1" +ALIAS: "d"="tenk1" +FILTER: schema="" table="a" column="thousand" +FILTER: schema="" table="b" column="thousand" +FILTER: schema="" table="b" column="hundred" +FILTER: schema="" table="c" column="hundred" +FILTER: schema="" table="a" column="thousand" +FILTER: schema="" table="d" column="thousand" +STMT: SelectStmt +TRUNCATED: "SELECT a.thousand FROM tenk1 a, tenk1 b WHERE ..." +== 186 +-- truncate_limit: 100 +|-- +-- Check that nested sub-selects are not pulled up if they contain volatiles +|-- +explain (verbose, costs off) + select x, x from + (select (select now()) as x from (values(1),(2)) v(y)) ss +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT x, x FROM (SELECT (SELECT now()) AS x FROM (VALUES (1), (2)) ..." +== 187 +-- truncate_limit: 100 +explain (verbose, costs off) + select x, x from + (select (select random()) as x from (values(1),(2)) v(y)) ss +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT x, x FROM (SELECT (SELECT random()) AS x FROM (VALUES (1), (2..." +== 188 +-- truncate_limit: 100 +explain (verbose, costs off) + select x, x from + (select (select now() where y=y) as x from (values(1),(2)) v(y)) ss +-- +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT x, x FROM (SELECT (SELECT now() WHERE y = y) AS x FROM (VALUE..." +== 189 +-- truncate_limit: 100 +explain (verbose, costs off) + select x, x from + (select (select random() where y=y) as x from (values(1),(2)) v(y)) ss +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="y" +FILTER: schema="" table="" column="y" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT x, x FROM (SELECT (SELECT random() WHERE y = y) AS x FROM (VA..." +== 190 +-- truncate_limit: 100 +|-- +-- Test rescan of a hashed subplan (the use of random() is to prevent the +-- sub-select from being pulled up, which would result in not hashing) +|-- +explain (verbose, costs off) +select sum(ss.tst::int) from + onek o cross join lateral ( + select i.ten in (select f1 from int4_tbl where f1 <= o.hundred) as tst, + random() as r + from onek i where i.unique1 = o.unique1 ) ss +where o.ten = 0 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="onek" +ALIAS: "o"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="i" column="unique1" +FILTER: schema="" table="o" column="unique1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="o" column="hundred" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT sum(ss.tst::int) FROM onek o CROSS JOIN LATERAL (SELECT i.ten..." +== 191 +-- truncate_limit: 100 +select sum(ss.tst::int) from + onek o cross join lateral ( + select i.ten in (select f1 from int4_tbl where f1 <= o.hundred) as tst, + random() as r + from onek i where i.unique1 = o.unique1 ) ss +where o.ten = 0 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="onek" +ALIAS: "o"="onek" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="i" column="unique1" +FILTER: schema="" table="o" column="unique1" +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="o" column="hundred" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek o CROSS JOIN LATERAL (SELECT ... FROM onek i WHERE ...) ss WHERE o.ten = 0" +== 192 +-- truncate_limit: 100 +|-- +-- Test rescan of a SetOp node +|-- +explain (costs off) +select count(*) from + onek o cross join lateral ( + select * from onek i1 where i1.unique1 = o.unique1 + except + select * from onek i2 where i2.unique1 = o.unique2 + ) ss +where o.ten = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "i1"="onek" +ALIAS: "i2"="onek" +ALIAS: "o"="onek" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="i1" column="unique1" +FILTER: schema="" table="o" column="unique1" +FILTER: schema="" table="i2" column="unique1" +FILTER: schema="" table="o" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM onek o CROSS JOIN LATERAL (SELECT * FROM onek i1 WHERE i..." +== 193 +-- truncate_limit: 100 +select count(*) from + onek o cross join lateral ( + select * from onek i1 where i1.unique1 = o.unique1 + except + select * from onek i2 where i2.unique1 = o.unique2 + ) ss +where o.ten = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "i1"="onek" +ALIAS: "i2"="onek" +ALIAS: "o"="onek" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="i1" column="unique1" +FILTER: schema="" table="o" column="unique1" +FILTER: schema="" table="i2" column="unique1" +FILTER: schema="" table="o" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek o CROSS JOIN LATERAL (SELECT * FROM onek i1 WHERE ... EXCEPT SELECT * FROM o..." +== 194 +-- truncate_limit: 100 +|-- +-- Test rescan of a RecursiveUnion node +|-- +explain (costs off) +select sum(o.four), sum(ss.a) from + onek o cross join lateral ( + with recursive x(a) as + (select o.four as a + union + select a + 1 from x + where a < 10) + select * from x + ) ss +where o.ten = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "o"="onek" +CTE: "x" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT sum(o.four), sum(ss.a) FROM onek o CROSS JOIN LATERAL (WITH RECURSIVE ..." +== 195 +-- truncate_limit: 100 +select sum(o.four), sum(ss.a) from + onek o cross join lateral ( + with recursive x(a) as + (select o.four as a + union + select a + 1 from x + where a < 10) + select * from x + ) ss +where o.ten = 1 +-- +TABLE: name="onek" schema="" table="onek" ctx=Select +ALIAS: "o"="onek" +CTE: "x" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="o" column="ten" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM onek o CROSS JOIN LATERAL (WITH RECURSIVE x(a) AS (...) SELECT * FROM x) ss WHERE..." +== 196 +-- truncate_limit: 100 +|-- +-- Check we don't misoptimize a NOT IN where the subquery returns no rows. +|-- +create temp table notinouter (a int) +-- +TABLE: name="notinouter" schema="" table="notinouter" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE notinouter (a int)" +== 197 +-- truncate_limit: 100 +create temp table notininner (b int not null) +-- +TABLE: name="notininner" schema="" table="notininner" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE notininner (b int NOT NULL)" +== 198 +-- truncate_limit: 100 +insert into notinouter values (null), (1) +-- +TABLE: name="notinouter" schema="" table="notinouter" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO notinouter VALUES (NULL), (1)" +== 199 +-- truncate_limit: 100 +select * from notinouter where a not in (select b from notininner) +-- +TABLE: name="notinouter" schema="" table="notinouter" ctx=Select +TABLE: name="notininner" schema="" table="notininner" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM notinouter WHERE NOT a IN (SELECT b FROM notininner)" +== 200 +-- truncate_limit: 100 +|-- +-- Check we behave sanely in corner case of empty SELECT list (bug #8648) +|-- +create temp table nocolumns() +-- +TABLE: name="nocolumns" schema="" table="nocolumns" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE nocolumns ()" +== 201 +-- truncate_limit: 100 +select exists(select * from nocolumns) +-- +TABLE: name="nocolumns" schema="" table="nocolumns" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT EXISTS (SELECT * FROM nocolumns)" +== 202 +-- truncate_limit: 100 +|-- +-- Check behavior with a SubPlan in VALUES (bug #14924) +|-- +select val.x + from generate_series(1,10) as s(i), + lateral ( + values ((select s.i + 1)), (s.i + 101) + ) as val(x) +where s.i < 10 and (select val.x) < 110 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="s" column="i" +STMT: SelectStmt +TRUNCATED: "SELECT val.x FROM generate_series(1, 10) s(i), LATERAL (VALUES (...)) val(x) WHERE ..." +== 203 +-- truncate_limit: 100 +-- another variant of that (bug #16213) +explain (verbose, costs off) +select * from +(values + (3 not in (select * from (values (1), (2)) ss1)), + (false) +) ss +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (VALUES (NOT 3 IN (SELECT * FROM (VALUES (1), (2)) ss1..." +== 204 +-- truncate_limit: 100 +select * from +(values + (3 not in (select * from (values (1), (2)) ss1)), + (false) +) ss +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (NOT 3 IN (SELECT * FROM (VALUES (1), (2)) ss1)), (false)) ss" +== 205 +-- truncate_limit: 100 +|-- +-- Check sane behavior with nested IN SubLinks +|-- +explain (verbose, costs off) +select * from int4_tbl where + (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in + (select ten from tenk1 b) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int4_tbl WHERE CASE WHEN f1 IN (SELECT unique1 FROM te..." +== 206 +-- truncate_limit: 100 +select * from int4_tbl where + (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in + (select ten from tenk1 b) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl WHERE ..." +== 207 +-- truncate_limit: 100 +|-- +-- Check for incorrect optimization when IN subquery contains a SRF +|-- +explain (verbose, costs off) +select * from int4_tbl o where (f1, f1) in + (select f1, generate_series(1,50) / 10 g from int4_tbl i group by f1) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int4_tbl o WHERE (f1, f1) IN (SELECT f1, generate_seri..." +== 208 +-- truncate_limit: 100 +select * from int4_tbl o where (f1, f1) in + (select f1, generate_series(1,50) / 10 g from int4_tbl i group by f1) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i"="int4_tbl" +ALIAS: "o"="int4_tbl" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl o WHERE (f1, f1) IN (SELECT ... FROM int4_tbl i GROUP BY f1)" +== 209 +-- truncate_limit: 100 +|-- +-- check for over-optimization of whole-row Var referencing an Append plan +|-- +select (select q from + (select 1,2,3 where f1 > 0 + union all + select 4,5,6.0 where f1 <= 0 + ) q ) +from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT q FROM (SELECT ... WHERE f1 > 0 UNION ALL SELECT ... WHERE f1 <= 0) q) FROM int4_tbl" +== 210 +-- truncate_limit: 100 +|-- +-- Check for sane handling of a lateral reference in a subquery's quals +-- (most of the complication here is to prevent the test case from being +-- flattened too much) +|-- +explain (verbose, costs off) +select * from + int4_tbl i4, + lateral ( + select i4.f1 > 1 as b, 1 as id + from (select random() order by 1) as t1 + union all + select true as b, 2 as id + ) as t2 +where b and f1 >= 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM int4_tbl i4, LATERAL (SELECT i4.f1 > 1 AS b, 1 AS id F..." +== 211 +-- truncate_limit: 100 +select * from + int4_tbl i4, + lateral ( + select i4.f1 > 1 as b, 1 as id + from (select random() order by 1) as t1 + union all + select true as b, 2 as id + ) as t2 +where b and f1 >= 0 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4_tbl i4, LATERAL (SELECT ... FROM (SELECT ... ORDER BY 1) t1 UNION ALL SELECT ...." +== 212 +-- truncate_limit: 100 +|-- +-- Check that volatile quals aren't pushed down past a DISTINCT: +-- nextval() should not be called more than the nominal number of times +|-- +create temp sequence ts1 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE TEMPORARY SEQUENCE ts1" +== 213 +-- truncate_limit: 100 +select * from + (select distinct ten from tenk1) ss + where ten < 10 + nextval('ts1') + order by 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +FILTER: schema="" table="" column="ten" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT DISTINCT ten FROM tenk1) ss WHERE ten < (10 + nextval('ts1')) ORDER BY 1" +== 214 +-- truncate_limit: 100 +select nextval('ts1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('ts1')" +== 215 +-- truncate_limit: 100 +|-- +-- Check that volatile quals aren't pushed down past a set-returning function; +-- while a nonvolatile qual can be, if it doesn't reference the SRF. +|-- +create function tattle(x int, y int) returns bool +volatile language plpgsql as $$ +begin + raise notice 'x = %, y = %', x, y; + return x > y; +end$$ +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tattle(x int, y int) RETURNS bool VOLATILE LANGUAGE plpgsql AS $$\nbegin\n raise n..." +== 216 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, 8) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (SELECT 9 AS x, unnest(ARRAY[1, 2, 3, 11, 12, 13]) AS ..." +== 217 +-- truncate_limit: 100 +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, 8) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT 9 AS x, unnest(ARRAY[1, 2, 3, 11, 12, 13]) AS u) ss WHERE tattle(x, 8)" +== 218 +-- truncate_limit: 100 +-- if we pretend it's stable, we get different results: +alter function tattle(x int, y int) stable +-- +STMT: AlterFunctionStmt +TRUNCATED: "ALTER FUNCTION tattle(x int, y int) STABLE" +== 219 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, 8) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (SELECT 9 AS x, unnest(ARRAY[1, 2, 3, 11, 12, 13]) AS ..." +== 220 +-- truncate_limit: 100 +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, 8) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT 9 AS x, unnest(ARRAY[1, 2, 3, 11, 12, 13]) AS u) ss WHERE tattle(x, 8)" +== 221 +-- truncate_limit: 100 +-- although even a stable qual should not be pushed down if it references SRF +explain (verbose, costs off) +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, u) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="u" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM (SELECT 9 AS x, unnest(ARRAY[1, 2, 3, 11, 12, 13]) AS ..." +== 222 +-- truncate_limit: 100 +select * from + (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss + where tattle(x, u) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="tattle" function="tattle" schema="" ctx=Call +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="u" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT 9 AS x, unnest(ARRAY[1, 2, 3, 11, 12, 13]) AS u) ss WHERE tattle(x, u)" +== 223 +-- truncate_limit: 100 +drop function tattle(x int, y int) +-- +FUNCTION: name="tattle" function="tattle" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION tattle(x int, y int)" +== 224 +-- truncate_limit: 100 +|-- +-- Test that LIMIT can be pushed to SORT through a subquery that just projects +-- columns. We check for that having happened by looking to see if EXPLAIN +-- ANALYZE shows that a top-N sort was used. We must suppress or filter away +-- all the non-invariant parts of the EXPLAIN ANALYZE output. +|-- +create table sq_limit (pk int primary key, c1 int, c2 int) +-- +TABLE: name="sq_limit" schema="" table="sq_limit" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sq_limit (pk int PRIMARY KEY, c1 int, c2 int)" +== 225 +-- truncate_limit: 100 +insert into sq_limit values + (1, 1, 1), + (2, 2, 2), + (3, 3, 3), + (4, 4, 4), + (5, 1, 1), + (6, 2, 2), + (7, 3, 3), + (8, 4, 4) +-- +TABLE: name="sq_limit" schema="" table="sq_limit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sq_limit VALUES (...)" +== 226 +-- truncate_limit: 100 +create function explain_sq_limit() returns setof text language plpgsql as +$$ +declare ln text; +begin + for ln in + explain (analyze, summary off, timing off, costs off) + select * from (select pk,c2 from sq_limit order by c1,pk) as x limit 3 + loop + ln := regexp_replace(ln, 'Memory: \S*', 'Memory: xxx'); + return next ln; + end loop; +end; +$$ +-- +FUNCTION: name="explain_sq_limit" function="explain_sq_limit" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION explain_sq_limit() RETURNS SETOF text LANGUAGE plpgsql AS $$\ndeclare ln text;\nbeg..." +== 227 +-- truncate_limit: 100 +select * from explain_sq_limit() +-- +FUNCTION: name="explain_sq_limit" function="explain_sq_limit" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM explain_sq_limit()" +== 228 +-- truncate_limit: 100 +select * from (select pk,c2 from sq_limit order by c1,pk) as x limit 3 +-- +TABLE: name="sq_limit" schema="" table="sq_limit" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT pk, c2 FROM sq_limit ORDER BY c1, pk) x LIMIT 3" +== 229 +-- truncate_limit: 100 +drop function explain_sq_limit() +-- +FUNCTION: name="explain_sq_limit" function="explain_sq_limit" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION explain_sq_limit()" +== 230 +-- truncate_limit: 100 +drop table sq_limit +-- +TABLE: name="sq_limit" schema="" table="sq_limit" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE sq_limit" +== 231 +-- truncate_limit: 100 +|-- +-- Ensure that backward scan direction isn't propagated into +-- expression subqueries (bug #15336) +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 232 +-- truncate_limit: 100 +declare c1 scroll cursor for + select * from generate_series(1,4) i + where i <> all (values (2),(3)) +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c1 SCROLL CURSOR FOR SELECT * FROM generate_series(1, 4) i WHERE i <> ALL (VALUES (2), (3))" +== 233 +-- truncate_limit: 100 +move forward all in c1 +-- +STMT: FetchStmt +TRUNCATED: "MOVE ALL c1" +== 234 +-- truncate_limit: 100 +fetch backward all in c1 +-- +STMT: FetchStmt +TRUNCATED: "FETCH BACKWARD ALL c1" +== 235 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 236 +-- truncate_limit: 100 +|-- +-- Check that JsonConstructorExpr is treated as non-strict, and thus can be +-- wrapped in a PlaceHolderVar +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 237 +-- truncate_limit: 100 +create temp table json_tab (a int) +-- +TABLE: name="json_tab" schema="" table="json_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE json_tab (a int)" +== 238 +-- truncate_limit: 100 +insert into json_tab values (1) +-- +TABLE: name="json_tab" schema="" table="json_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO json_tab VALUES (1)" +== 239 +-- truncate_limit: 100 +explain (verbose, costs off) +select * from json_tab t1 left join (select json_array(1, a) from json_tab t2) s on false +-- +TABLE: name="json_tab" schema="" table="json_tab" ctx=Select +TABLE: name="json_tab" schema="" table="json_tab" ctx=Select +ALIAS: "t1"="json_tab" +ALIAS: "t2"="json_tab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM json_tab t1 LEFT JOIN (SELECT JSON_ARRAY(1, a) FROM js..." +== 240 +-- truncate_limit: 100 +select * from json_tab t1 left join (select json_array(1, a) from json_tab t2) s on false +-- +TABLE: name="json_tab" schema="" table="json_tab" ctx=Select +TABLE: name="json_tab" schema="" table="json_tab" ctx=Select +ALIAS: "t1"="json_tab" +ALIAS: "t2"="json_tab" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM json_tab t1 LEFT JOIN (SELECT JSON_ARRAY(1, a) FROM json_tab t2) s ON false" +== 241 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 242 +-- truncate_limit: 100 +|-- +-- Verify that we correctly flatten cases involving a subquery output +-- expression that doesn't need to be wrapped in a PlaceHolderVar +|-- + +explain (costs off) +select tname, attname from ( +select relname::information_schema.sql_identifier as tname, * from + (select * from pg_class c) ss1) ss2 + right join pg_attribute a on a.attrelid = ss2.oid +where tname = 'tenk1' and attnum = 1 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="tname" +FILTER: schema="" table="" column="attnum" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT tname, attname FROM (SELECT relname::information_schema.sql_identifier..." +== 243 +-- truncate_limit: 100 +select tname, attname from ( +select relname::information_schema.sql_identifier as tname, * from + (select * from pg_class c) ss1) ss2 + right join pg_attribute a on a.attrelid = ss2.oid +where tname = 'tenk1' and attnum = 1 +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "c"="pg_class" +FILTER: schema="" table="" column="tname" +FILTER: schema="" table="" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM (SELECT * FROM pg_class c) ss1) ss2 RIGHT JOIN pg_attribute a ON..." +== 244 +-- truncate_limit: 100 +-- Check behavior when there's a lateral reference in the output expression +explain (verbose, costs off) +select t1.ten, sum(x) from + tenk1 t1 left join lateral ( + select t1.ten + t2.ten as x, t2.fivethous from tenk1 t2 + ) ss on t1.unique1 = ss.fivethous +group by t1.ten +order by t1.ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.ten, sum(x) FROM tenk1 t1 LEFT JOIN LATERAL (SELECT t1.ten..." +== 245 +-- truncate_limit: 100 +select t1.ten, sum(x) from + tenk1 t1 left join lateral ( + select t1.ten + t2.ten as x, t2.fivethous from tenk1 t2 + ) ss on t1.unique1 = ss.fivethous +group by t1.ten +order by t1.ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 t1 LEFT JOIN LATERAL (SELECT ... FROM tenk1 t2) ss ON t1.unique1 = ss.fivet..." +== 246 +-- truncate_limit: 100 +explain (verbose, costs off) +select t1.q1, x from + int8_tbl t1 left join + (int8_tbl t2 left join + lateral (select t2.q1+t3.q1 as x, * from int8_tbl t3) t3 on t2.q2 = t3.q2) + on t1.q2 = t2.q2 +order by 1, 2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.q1, x FROM int8_tbl t1 LEFT JOIN (int8_tbl t2 LEFT JOIN LA..." +== 247 +-- truncate_limit: 100 +select t1.q1, x from + int8_tbl t1 left join + (int8_tbl t2 left join + lateral (select t2.q1+t3.q1 as x, * from int8_tbl t3) t3 on t2.q2 = t3.q2) + on t1.q2 = t2.q2 +order by 1, 2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "t1"="int8_tbl" +ALIAS: "t2"="int8_tbl" +ALIAS: "t3"="int8_tbl" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM int8_tbl t1 LEFT JOIN (int8_tbl t2 LEFT JOIN LATERAL (SELECT ... FROM int8_tbl t3..." +== 248 +-- truncate_limit: 100 +|-- +-- Tests for CTE inlining behavior +|-- + +-- Basic subquery that can be inlined +explain (verbose, costs off) +with x as (select * from (select f1 from subselect_tbl) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS (SELECT * FROM (SELECT f1 FROM subselect_tbl) ss) SELECT *..." +== 249 +-- truncate_limit: 100 +-- Explicitly request materialization +explain (verbose, costs off) +with x as materialized (select * from (select f1 from subselect_tbl) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS MATERIALIZED (SELECT * FROM (SELECT f1 FROM subselect_tbl)..." +== 250 +-- truncate_limit: 100 +-- Stable functions are safe to inline +explain (verbose, costs off) +with x as (select * from (select f1, now() from subselect_tbl) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS (SELECT * FROM (SELECT f1, now() FROM subselect_tbl) ss) S..." +== 251 +-- truncate_limit: 100 +-- Volatile functions prevent inlining +explain (verbose, costs off) +with x as (select * from (select f1, random() from subselect_tbl) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS (SELECT * FROM (SELECT f1, random() FROM subselect_tbl) ss..." +== 252 +-- truncate_limit: 100 +-- SELECT FOR UPDATE cannot be inlined +explain (verbose, costs off) +with x as (select * from (select f1 from subselect_tbl for update) ss) +select * from x where f1 = 1 +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS (SELECT * FROM (SELECT f1 FROM subselect_tbl FOR UPDATE) s..." +== 253 +-- truncate_limit: 100 +-- Multiply-referenced CTEs are inlined only when requested +explain (verbose, costs off) +with x as (select * from (select f1, now() as n from subselect_tbl) ss) +select * from x, x x2 where x.n = x2.n +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "x2"="x" +CTE: "x" +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="x" column="n" +FILTER: schema="" table="x2" column="n" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS (SELECT * FROM (SELECT f1, now() AS n FROM subselect_tbl) ..." +== 254 +-- truncate_limit: 100 +explain (verbose, costs off) +with x as not materialized (select * from (select f1, now() as n from subselect_tbl) ss) +select * from x, x x2 where x.n = x2.n +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +ALIAS: "x2"="x" +CTE: "x" +FUNCTION: name="now" function="now" schema="" ctx=Call +FILTER: schema="" table="x" column="n" +FILTER: schema="" table="x2" column="n" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS NOT MATERIALIZED (SELECT * FROM (SELECT f1, now() AS n FRO..." +== 255 +-- truncate_limit: 100 +-- Multiply-referenced CTEs can't be inlined if they contain outer self-refs +explain (verbose, costs off) +with recursive x(a) as + ((values ('a'), ('b')) + union all + (with z as not materialized (select * from x) + select z.a || z1.a as a from z cross join z as z1 + where length(z.a || z1.a) < 5)) +select * from x +-- +ALIAS: "z1"="z" +CTE: "x" +CTE: "z" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z1" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH RECURSIVE x(a) AS (VALUES ('a'), ('b') UNION ALL (WITH z AS NOT..." +== 256 +-- truncate_limit: 100 +with recursive x(a) as + ((values ('a'), ('b')) + union all + (with z as not materialized (select * from x) + select z.a || z1.a as a from z cross join z as z1 + where length(z.a || z1.a) < 5)) +select * from x +-- +ALIAS: "z1"="z" +CTE: "x" +CTE: "z" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z1" column="a" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(a) AS (...) SELECT * FROM x" +== 257 +-- truncate_limit: 100 +explain (verbose, costs off) +with recursive x(a) as + ((values ('a'), ('b')) + union all + (with z as not materialized (select * from x) + select z.a || z.a as a from z + where length(z.a || z.a) < 5)) +select * from x +-- +CTE: "x" +CTE: "z" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH RECURSIVE x(a) AS (VALUES ('a'), ('b') UNION ALL (WITH z AS NOT..." +== 258 +-- truncate_limit: 100 +with recursive x(a) as + ((values ('a'), ('b')) + union all + (with z as not materialized (select * from x) + select z.a || z.a as a from z + where length(z.a || z.a) < 5)) +select * from x +-- +CTE: "x" +CTE: "z" +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="z" column="a" +FILTER: schema="" table="z" column="a" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(a) AS (...) SELECT * FROM x" +== 259 +-- truncate_limit: 100 +-- Check handling of outer references +explain (verbose, costs off) +with x as (select * from int4_tbl) +select * from (with y as (select * from x) select * from y) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "y" +CTE: "x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS (SELECT * FROM int4_tbl) SELECT * FROM (WITH y AS (SELECT ..." +== 260 +-- truncate_limit: 100 +explain (verbose, costs off) +with x as materialized (select * from int4_tbl) +select * from (with y as (select * from x) select * from y) ss +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "y" +CTE: "x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS MATERIALIZED (SELECT * FROM int4_tbl) SELECT * FROM (WITH ..." +== 261 +-- truncate_limit: 100 +-- Ensure that we inline the correct CTE when there are +-- multiple CTEs with the same name +explain (verbose, costs off) +with x as (select 1 as y) +select * from (with x as (select 2 as y) select * from x) ss +-- +CTE: "x" +CTE: "x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS (SELECT 1 AS y) SELECT * FROM (WITH x AS (SELECT 2 AS y) S..." +== 262 +-- truncate_limit: 100 +-- Row marks are not pushed into CTEs +explain (verbose, costs off) +with x as (select * from subselect_tbl) +select * from x for update +-- +TABLE: name="subselect_tbl" schema="" table="subselect_tbl" ctx=Select +CTE: "x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH x AS (SELECT * FROM subselect_tbl) SELECT * FROM x FOR UPDATE" +== 263 +-- truncate_limit: 100 +-- Pull up direct-correlated ANY_SUBLINKs +explain (costs off) +select * from tenk1 A where hundred in (select hundred from tenk2 B where B.odd = A.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +FILTER: schema="" table="" column="hundred" +FILTER: schema="" table="b" column="odd" +FILTER: schema="" table="a" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a WHERE hundred IN (SELECT hundred FROM tenk2 b WHERE b.o..." +== 264 +-- truncate_limit: 100 +explain (costs off) +select * from tenk1 A where exists +(select 1 from tenk2 B +where A.hundred in (select C.hundred FROM tenk2 C +WHERE c.odd = b.odd)) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="a" column="hundred" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a WHERE EXISTS (SELECT 1 FROM tenk2 b WHERE a.hundred IN ..." +== 265 +-- truncate_limit: 100 +-- we should only try to pull up the sublink into RHS of a left join +-- but a.hundred is not available. +explain (costs off) +SELECT * FROM tenk1 A LEFT JOIN tenk2 B +ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a LEFT JOIN tenk2 b ON a.hundred IN (SELECT c.hundred FRO..." +== 266 +-- truncate_limit: 100 +-- we should only try to pull up the sublink into RHS of a left join +-- but a.odd is not available for this. +explain (costs off) +SELECT * FROM tenk1 A LEFT JOIN tenk2 B +ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = a.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="a" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a LEFT JOIN tenk2 b ON b.hundred IN (SELECT c.hundred FRO..." +== 267 +-- truncate_limit: 100 +-- should be able to pull up since all the references are available. +explain (costs off) +SELECT * FROM tenk1 A LEFT JOIN tenk2 B +ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a LEFT JOIN tenk2 b ON b.hundred IN (SELECT c.hundred FRO..." +== 268 +-- truncate_limit: 100 +-- we can pull up the sublink into the inner JoinExpr. +explain (costs off) +SELECT * FROM tenk1 A INNER JOIN tenk2 B +ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd) +WHERE a.thousand < 750 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FILTER: schema="" table="a" column="thousand" +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a JOIN tenk2 b ON a.hundred IN (SELECT c.hundred FROM ten..." +== 269 +-- truncate_limit: 100 +-- we can pull up the aggregate sublink into RHS of a left join. +explain (costs off) +SELECT * FROM tenk1 A LEFT JOIN tenk2 B +ON B.hundred in (SELECT min(c.hundred) FROM tenk2 C WHERE c.odd = b.odd) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk2" +ALIAS: "c"="tenk2" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="c" column="odd" +FILTER: schema="" table="b" column="odd" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 a LEFT JOIN tenk2 b ON b.hundred IN (SELECT min(c.hundred..." diff --git a/parser/testdata/summary_truncate/postgres_regress/sysviews.metadata.json b/parser/testdata/summary_truncate/postgres_regress/sysviews.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sysviews.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/sysviews.test b/parser/testdata/summary_truncate/postgres_regress/sysviews.test new file mode 100644 index 0000000..76f79ac --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/sysviews.test @@ -0,0 +1,253 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Test assorted system views +|-- +-- This test is mainly meant to provide some code coverage for the +-- set-returning functions that underlie certain system views. +-- The output of most of these functions is very environment-dependent, +-- so our ability to test with fixed expected output is pretty limited; +-- but even a trivial check of count(*) will exercise the normal code path +-- through the SRF. + +select count(*) >= 0 as ok from pg_available_extension_versions +-- +TABLE: name="pg_available_extension_versions" schema="" table="pg_available_extension_versions" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) >= 0 AS ok FROM pg_available_extension_versions" +== 002 +-- truncate_limit: 100 +select count(*) >= 0 as ok from pg_available_extensions +-- +TABLE: name="pg_available_extensions" schema="" table="pg_available_extensions" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) >= 0 AS ok FROM pg_available_extensions" +== 003 +-- truncate_limit: 100 +-- The entire output of pg_backend_memory_contexts is not stable, +-- we test only the existence and basic condition of TopMemoryContext. +select name, ident, parent, level, total_bytes >= free_bytes + from pg_backend_memory_contexts where level = 0 +-- +TABLE: name="pg_backend_memory_contexts" schema="" table="pg_backend_memory_contexts" ctx=Select +FILTER: schema="" table="" column="level" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_backend_memory_contexts WHERE level = 0" +== 004 +-- truncate_limit: 100 +-- We can exercise some MemoryContext type stats functions. Most of the +-- column values are too platform-dependant to display. + +-- Ensure stats from the bump allocator look sane. Bump isn't a commonly +-- used context, but it is used in tuplesort.c, so open a cursor to keep +-- the tuplesort alive long enough for us to query the context stats. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 005 +-- truncate_limit: 100 +declare cur cursor for select left(a,10), b + from (values(repeat('a', 512 * 1024),1),(repeat('b', 512),2)) v(a,b) + order by v.a desc +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE cur CURSOR FOR SELECT \"left\"(a, 10), b FROM (VALUES (repeat('a', 512 * 1024), 1), (repeat..." +== 006 +-- truncate_limit: 100 +fetch 1 from cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH cur" +== 007 +-- truncate_limit: 100 +select name, parent, total_bytes > 0, total_nblocks, free_bytes > 0, free_chunks +from pg_backend_memory_contexts where name = 'Caller tuples' +-- +TABLE: name="pg_backend_memory_contexts" schema="" table="pg_backend_memory_contexts" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_backend_memory_contexts WHERE name = 'Caller tuples'" +== 008 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 009 +-- truncate_limit: 100 +-- At introduction, pg_config had 23 entries; it may grow +select count(*) > 20 as ok from pg_config +-- +TABLE: name="pg_config" schema="" table="pg_config" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 20 AS ok FROM pg_config" +== 010 +-- truncate_limit: 100 +-- We expect no cursors in this test; see also portals.sql +select count(*) = 0 as ok from pg_cursors +-- +TABLE: name="pg_cursors" schema="" table="pg_cursors" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) = 0 AS ok FROM pg_cursors" +== 011 +-- truncate_limit: 100 +select count(*) >= 0 as ok from pg_file_settings +-- +TABLE: name="pg_file_settings" schema="" table="pg_file_settings" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) >= 0 AS ok FROM pg_file_settings" +== 012 +-- truncate_limit: 100 +-- There will surely be at least one rule, with no errors. +select count(*) > 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err + from pg_hba_file_rules +-- +TABLE: name="pg_hba_file_rules" schema="" table="pg_hba_file_rules" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_hba_file_rules" +== 013 +-- truncate_limit: 100 +-- There may be no rules, and there should be no errors. +select count(*) >= 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err + from pg_ident_file_mappings +-- +TABLE: name="pg_ident_file_mappings" schema="" table="pg_ident_file_mappings" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_ident_file_mappings" +== 014 +-- truncate_limit: 100 +-- There will surely be at least one active lock +select count(*) > 0 as ok from pg_locks +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM pg_locks" +== 015 +-- truncate_limit: 100 +-- We expect no prepared statements in this test; see also prepare.sql +select count(*) = 0 as ok from pg_prepared_statements +-- +TABLE: name="pg_prepared_statements" schema="" table="pg_prepared_statements" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) = 0 AS ok FROM pg_prepared_statements" +== 016 +-- truncate_limit: 100 +-- See also prepared_xacts.sql +select count(*) >= 0 as ok from pg_prepared_xacts +-- +TABLE: name="pg_prepared_xacts" schema="" table="pg_prepared_xacts" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) >= 0 AS ok FROM pg_prepared_xacts" +== 017 +-- truncate_limit: 100 +-- There will surely be at least one SLRU cache +select count(*) > 0 as ok from pg_stat_slru +-- +TABLE: name="pg_stat_slru" schema="" table="pg_stat_slru" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) > 0 AS ok FROM pg_stat_slru" +== 018 +-- truncate_limit: 100 +-- There must be only one record +select count(*) = 1 as ok from pg_stat_wal +-- +TABLE: name="pg_stat_wal" schema="" table="pg_stat_wal" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) = 1 AS ok FROM pg_stat_wal" +== 019 +-- truncate_limit: 100 +-- We expect no walreceiver running in this test +select count(*) = 0 as ok from pg_stat_wal_receiver +-- +TABLE: name="pg_stat_wal_receiver" schema="" table="pg_stat_wal_receiver" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) = 0 AS ok FROM pg_stat_wal_receiver" +== 020 +-- truncate_limit: 100 +-- This is to record the prevailing planner enable_foo settings during +-- a regression test run. +select name, setting from pg_settings where name like 'enable%' +-- +TABLE: name="pg_settings" schema="" table="pg_settings" ctx=Select +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "SELECT name, setting FROM pg_settings WHERE name LIKE 'enable%'" +== 021 +-- truncate_limit: 100 +-- There are always wait event descriptions for various types. InjectionPoint +-- may be present or absent, depending on history since last postmaster start. +select type, count(*) > 0 as ok FROM pg_wait_events + where type <> 'InjectionPoint' group by type order by type COLLATE "C" +-- +TABLE: name="pg_wait_events" schema="" table="pg_wait_events" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="type" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_wait_events WHERE ... GROUP BY type ORDER BY type COLLATE \"C\"" +== 022 +-- truncate_limit: 100 +-- Test that the pg_timezone_names and pg_timezone_abbrevs views are +-- more-or-less working. We can't test their contents in any great detail +-- without the outputs changing anytime IANA updates the underlying data, +-- but it seems reasonable to expect at least one entry per major meridian. +-- (At the time of writing, the actual counts are around 38 because of +-- zones using fractional GMT offsets, so this is a pretty loose test.) +select count(distinct utc_offset) >= 24 as ok from pg_timezone_names +-- +TABLE: name="pg_timezone_names" schema="" table="pg_timezone_names" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT utc_offset) >= 24 AS ok FROM pg_timezone_names" +== 023 +-- truncate_limit: 100 +select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs +-- +TABLE: name="pg_timezone_abbrevs" schema="" table="pg_timezone_abbrevs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT utc_offset) >= 24 AS ok FROM pg_timezone_abbrevs" +== 024 +-- truncate_limit: 100 +-- Let's check the non-default timezone abbreviation sets, too +set timezone_abbreviations = 'Australia' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone_abbreviations TO \"Australia\"" +== 025 +-- truncate_limit: 100 +select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs +-- +TABLE: name="pg_timezone_abbrevs" schema="" table="pg_timezone_abbrevs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT utc_offset) >= 24 AS ok FROM pg_timezone_abbrevs" +== 026 +-- truncate_limit: 100 +set timezone_abbreviations = 'India' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone_abbreviations TO \"India\"" +== 027 +-- truncate_limit: 100 +select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs +-- +TABLE: name="pg_timezone_abbrevs" schema="" table="pg_timezone_abbrevs" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT utc_offset) >= 24 AS ok FROM pg_timezone_abbrevs" diff --git a/parser/testdata/summary_truncate/postgres_regress/tablesample.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tablesample.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tablesample.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tablesample.test b/parser/testdata/summary_truncate/postgres_regress/tablesample.test new file mode 100644 index 0000000..410d346 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tablesample.test @@ -0,0 +1,438 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE test_tablesample (id int, name text) WITH (fillfactor=10) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_tablesample (id int, name text) WITH (fillfactor=10)" +== 002 +-- truncate_limit: 100 +-- use fillfactor so we don't have to load too much data to get multiple pages + +INSERT INTO test_tablesample + SELECT i, repeat(i::text, 200) FROM generate_series(0, 9) s(i) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_tablesample SELECT i, repeat(i::text, 200) FROM generate_series(0, 9) s(i)" +== 003 +-- truncate_limit: 100 +SELECT t.id FROM test_tablesample AS t TABLESAMPLE SYSTEM (50) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +ALIAS: "t"="test_tablesample" +STMT: SelectStmt +TRUNCATED: "SELECT t.id FROM test_tablesample t TABLESAMPLE system(50) REPEATABLE (0)" +== 004 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (100.0/11) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE system(100.0 / 11) REPEATABLE (0)" +== 005 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE system(50) REPEATABLE (0)" +== 006 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (50) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE bernoulli(50) REPEATABLE (0)" +== 007 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (5.5) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE bernoulli(5.5) REPEATABLE (0)" +== 008 +-- truncate_limit: 100 +-- 100% should give repeatable count results (ie, all rows) in any case +SELECT count(*) FROM test_tablesample TABLESAMPLE SYSTEM (100) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tablesample TABLESAMPLE system(100)" +== 009 +-- truncate_limit: 100 +SELECT count(*) FROM test_tablesample TABLESAMPLE SYSTEM (100) REPEATABLE (1+2) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tablesample TABLESAMPLE system(100) REPEATABLE (1 + 2)" +== 010 +-- truncate_limit: 100 +SELECT count(*) FROM test_tablesample TABLESAMPLE SYSTEM (100) REPEATABLE (0.4) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tablesample TABLESAMPLE system(100) REPEATABLE (0.4)" +== 011 +-- truncate_limit: 100 +CREATE VIEW test_tablesample_v1 AS + SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (10*2) REPEATABLE (2) +-- +TABLE: name="test_tablesample_v1" schema="" table="test_tablesample_v1" ctx=DDL +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW test_tablesample_v1 AS SELECT id FROM test_tablesample TABLESAMPLE system(10 * 2) REP..." +== 012 +-- truncate_limit: 100 +CREATE VIEW test_tablesample_v2 AS + SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (99) +-- +TABLE: name="test_tablesample_v2" schema="" table="test_tablesample_v2" ctx=DDL +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW test_tablesample_v2 AS SELECT id FROM test_tablesample TABLESAMPLE system(99)" +== 013 +-- truncate_limit: 100 +-- check a sampled query doesn't affect cursor in progress +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 014 +-- truncate_limit: 100 +DECLARE tablesample_cur SCROLL CURSOR FOR + SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (0) +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE tablesample_cur SCROLL CURSOR FOR SELECT id FROM test_tablesample TABLESAMPLE system(50) ..." +== 015 +-- truncate_limit: 100 +FETCH FIRST FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH FIRST tablesample_cur" +== 016 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 017 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 018 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (0) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE system(50) REPEATABLE (0)" +== 019 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 020 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 021 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 022 +-- truncate_limit: 100 +FETCH FIRST FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH FIRST tablesample_cur" +== 023 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 024 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 025 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 026 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 027 +-- truncate_limit: 100 +FETCH NEXT FROM tablesample_cur +-- +STMT: FetchStmt +TRUNCATED: "FETCH tablesample_cur" +== 028 +-- truncate_limit: 100 +CLOSE tablesample_cur +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE tablesample_cur" +== 029 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 030 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) + SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (2) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT id FROM test_tablesample TABLESAMPLE system(50) REPEATABLE (2)" +== 031 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) + SELECT * FROM test_tablesample_v1 +-- +TABLE: name="test_tablesample_v1" schema="" table="test_tablesample_v1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM test_tablesample_v1" +== 032 +-- truncate_limit: 100 +-- check inheritance behavior +explain (costs off) + select count(*) from person tablesample bernoulli (100) +-- +TABLE: name="person" schema="" table="person" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM person TABLESAMPLE bernoulli(100)" +== 033 +-- truncate_limit: 100 +select count(*) from person tablesample bernoulli (100) +-- +TABLE: name="person" schema="" table="person" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM person TABLESAMPLE bernoulli(100)" +== 034 +-- truncate_limit: 100 +select count(*) from person +-- +TABLE: name="person" schema="" table="person" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM person" +== 035 +-- truncate_limit: 100 +-- check that collations get assigned within the tablesample arguments +SELECT count(*) FROM test_tablesample TABLESAMPLE bernoulli (('1'::text < '0'::text)::int) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tablesample TABLESAMPLE bernoulli(('1'::text < '0'::text)::int)" +== 036 +-- truncate_limit: 100 +-- check behavior during rescans, as well as correct handling of min/max pct +select * from + (values (0),(100)) v(pct), + lateral (select count(*) from tenk1 tablesample bernoulli (pct)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(pct), LATERAL (SELECT ... FROM tenk1 TABLESAMPLE bernoulli(pct)) ss" +== 037 +-- truncate_limit: 100 +select * from + (values (0),(100)) v(pct), + lateral (select count(*) from tenk1 tablesample system (pct)) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (VALUES (...)) v(pct), LATERAL (SELECT count(*) FROM tenk1 TABLESAMPLE system(pct)) ss" +== 038 +-- truncate_limit: 100 +explain (costs off) +select pct, count(unique1) from + (values (0),(100)) v(pct), + lateral (select * from tenk1 tablesample bernoulli (pct)) ss + group by pct +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT pct, count(unique1) FROM (VALUES (0), (100)) v(pct), LATERAL (SELECT *..." +== 039 +-- truncate_limit: 100 +select pct, count(unique1) from + (values (0),(100)) v(pct), + lateral (select * from tenk1 tablesample bernoulli (pct)) ss + group by pct +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(pct), LATERAL (SELECT * FROM tenk1 TABLESAMPLE bernoulli(pct)) s..." +== 040 +-- truncate_limit: 100 +select pct, count(unique1) from + (values (0),(100)) v(pct), + lateral (select * from tenk1 tablesample system (pct)) ss + group by pct +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(pct), LATERAL (SELECT * FROM tenk1 TABLESAMPLE system(pct)) ss G..." +== 041 +-- truncate_limit: 100 +-- errors +SELECT id FROM test_tablesample TABLESAMPLE FOOBAR (1) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE foobar(1)" +== 042 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (NULL) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE system(NULL)" +== 043 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (NULL) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE system(50) REPEATABLE (NULL)" +== 044 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (-1) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE bernoulli(-1)" +== 045 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (200) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE bernoulli(200)" +== 046 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (-1) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE system(-1)" +== 047 +-- truncate_limit: 100 +SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (200) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample TABLESAMPLE system(200)" +== 048 +-- truncate_limit: 100 +SELECT id FROM test_tablesample_v1 TABLESAMPLE BERNOULLI (1) +-- +TABLE: name="test_tablesample_v1" schema="" table="test_tablesample_v1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT id FROM test_tablesample_v1 TABLESAMPLE bernoulli(1)" +== 049 +-- truncate_limit: 100 +INSERT INTO test_tablesample_v1 VALUES(1) +-- +TABLE: name="test_tablesample_v1" schema="" table="test_tablesample_v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_tablesample_v1 VALUES (1)" +== 050 +-- truncate_limit: 100 +WITH query_select AS (SELECT * FROM test_tablesample) +SELECT * FROM query_select TABLESAMPLE BERNOULLI (5.5) REPEATABLE (1) +-- +TABLE: name="test_tablesample" schema="" table="test_tablesample" ctx=Select +CTE: "query_select" +STMT: SelectStmt +TRUNCATED: "WITH query_select AS (...) SELECT * FROM query_select TABLESAMPLE bernoulli(5.5) REPEATABLE (1)" +== 051 +-- truncate_limit: 100 +SELECT q.* FROM (SELECT * FROM test_tablesample) as q TABLESAMPLE BERNOULLI (5) +-- +ERROR: syntax error at or near "TABLESAMPLE" +CURSORPOS: 55 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 052 +-- truncate_limit: 100 +-- check partitioned tables support tablesample +create table parted_sample (a int) partition by list (a) +-- +TABLE: name="parted_sample" schema="" table="parted_sample" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_sample (a int) PARTITION BY LIST (a)" +== 053 +-- truncate_limit: 100 +create table parted_sample_1 partition of parted_sample for values in (1) +-- +TABLE: name="parted_sample_1" schema="" table="parted_sample_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_sample_1 PARTITION OF parted_sample FOR VALUES IN (1)" +== 054 +-- truncate_limit: 100 +create table parted_sample_2 partition of parted_sample for values in (2) +-- +TABLE: name="parted_sample_2" schema="" table="parted_sample_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_sample_2 PARTITION OF parted_sample FOR VALUES IN (2)" +== 055 +-- truncate_limit: 100 +explain (costs off) + select * from parted_sample tablesample bernoulli (100) +-- +TABLE: name="parted_sample" schema="" table="parted_sample" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM parted_sample TABLESAMPLE bernoulli(100)" +== 056 +-- truncate_limit: 100 +drop table parted_sample, parted_sample_1, parted_sample_2 +-- +TABLE: name="parted_sample" schema="" table="parted_sample" ctx=DDL +TABLE: name="parted_sample_1" schema="" table="parted_sample_1" ctx=DDL +TABLE: name="parted_sample_2" schema="" table="parted_sample_2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_sample, parted_sample_1, parted_sample_2" diff --git a/parser/testdata/summary_truncate/postgres_regress/tablespace.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tablespace.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tablespace.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tablespace.test b/parser/testdata/summary_truncate/postgres_regress/tablespace.test new file mode 100644 index 0000000..599f79a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tablespace.test @@ -0,0 +1,1606 @@ +== 001 +-- truncate_limit: 100 +-- relative tablespace locations are not allowed +CREATE TABLESPACE regress_tblspace LOCATION 'relative' +-- +STMT: CreateTableSpaceStmt +TRUNCATED: "CREATE TABLESPACE regress_tblspace LOCATION 'relative'" +== 002 +-- truncate_limit: 100 +-- fail + +-- empty tablespace locations are not usually allowed +CREATE TABLESPACE regress_tblspace LOCATION '' +-- +STMT: CreateTableSpaceStmt +TRUNCATED: "CREATE TABLESPACE regress_tblspace LOCATION ''" +== 003 +-- truncate_limit: 100 +-- fail + +-- as a special developer-only option to allow us to use tablespaces +-- with streaming replication on the same server, an empty location +-- can be allowed as a way to say that the tablespace should be created +-- as a directory in pg_tblspc, rather than being a symlink +SET allow_in_place_tablespaces = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET allow_in_place_tablespaces TO TRUE" +== 004 +-- truncate_limit: 100 +-- create a tablespace using WITH clause +CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (some_nonexistent_parameter = true) +-- +STMT: CreateTableSpaceStmt +TRUNCATED: "CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (some_nonexistent_parameter=true)" +== 005 +-- truncate_limit: 100 +-- fail +CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (random_page_cost = 3.0) +-- +STMT: CreateTableSpaceStmt +TRUNCATED: "CREATE TABLESPACE regress_tblspacewith LOCATION '' WITH (random_page_cost=3.0)" +== 006 +-- truncate_limit: 100 +-- ok + +-- check to see the parameter was used +SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith' +-- +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +FILTER: schema="" table="" column="spcname" +STMT: SelectStmt +TRUNCATED: "SELECT spcoptions FROM pg_tablespace WHERE spcname = 'regress_tblspacewith'" +== 007 +-- truncate_limit: 100 +-- drop the tablespace so we can re-use the location +DROP TABLESPACE regress_tblspacewith +-- +STMT: DropTableSpaceStmt +TRUNCATED: "DROP TABLESPACE regress_tblspacewith" +== 008 +-- truncate_limit: 100 +-- This returns a relative path as of an effect of allow_in_place_tablespaces, +-- masking the tablespace OID used in the path name. +SELECT regexp_replace(pg_tablespace_location(oid), '(pg_tblspc)/(\d+)', '\1/NNN') + FROM pg_tablespace WHERE spcname = 'regress_tblspace' +-- +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +FUNCTION: name="regexp_replace" function="regexp_replace" schema="" ctx=Call +FUNCTION: name="pg_tablespace_location" function="pg_tablespace_location" schema="" ctx=Call +FILTER: schema="" table="" column="spcname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_tablespace WHERE spcname = 'regress_tblspace'" +== 009 +-- truncate_limit: 100 +-- try setting and resetting some properties for the new tablespace +ALTER TABLESPACE regress_tblspace SET (random_page_cost = 1.0, seq_page_cost = 1.1) +-- +STMT: AlterTableSpaceOptionsStmt +TRUNCATED: "ALTER TABLESPACE regress_tblspace SET (random_page_cost=1.0, seq_page_cost=1.1)" +== 010 +-- truncate_limit: 100 +ALTER TABLESPACE regress_tblspace SET (some_nonexistent_parameter = true) +-- +STMT: AlterTableSpaceOptionsStmt +TRUNCATED: "ALTER TABLESPACE regress_tblspace SET (some_nonexistent_parameter=true)" +== 011 +-- truncate_limit: 100 +-- fail +ALTER TABLESPACE regress_tblspace RESET (random_page_cost = 2.0) +-- +STMT: AlterTableSpaceOptionsStmt +TRUNCATED: "ALTER TABLESPACE regress_tblspace RESET (random_page_cost=2.0)" +== 012 +-- truncate_limit: 100 +-- fail +ALTER TABLESPACE regress_tblspace RESET (random_page_cost, effective_io_concurrency) +-- +STMT: AlterTableSpaceOptionsStmt +TRUNCATED: "ALTER TABLESPACE regress_tblspace RESET (random_page_cost, effective_io_concurrency)" +== 013 +-- truncate_limit: 100 +-- ok + +-- REINDEX (TABLESPACE) +-- catalogs and system tablespaces +-- system catalog, fail +REINDEX (TABLESPACE regress_tblspace) TABLE pg_am +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace) TABLE pg_am" +== 014 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_am +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE pg_am" +== 015 +-- truncate_limit: 100 +-- shared catalog, fail +REINDEX (TABLESPACE regress_tblspace) TABLE pg_authid +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace) TABLE pg_authid" +== 016 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_authid +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE pg_authid" +== 017 +-- truncate_limit: 100 +-- toast relations, fail +REINDEX (TABLESPACE regress_tblspace) INDEX pg_toast.pg_toast_1260_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace) INDEX pg_toast.pg_toast_1260_index" +== 018 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) INDEX CONCURRENTLY pg_toast.pg_toast_1260_index +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) INDEX pg_toast.pg_toast_1260_index" +== 019 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) TABLE pg_toast.pg_toast_1260 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace) TABLE pg_toast.pg_toast_1260" +== 020 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_toast.pg_toast_1260 +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE pg_toast.pg_toast_1260" +== 021 +-- truncate_limit: 100 +-- system catalog, fail +REINDEX (TABLESPACE pg_global) TABLE pg_authid +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE pg_global) TABLE pg_authid" +== 022 +-- truncate_limit: 100 +REINDEX (TABLESPACE pg_global) TABLE CONCURRENTLY pg_authid +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE pg_global, CONCURRENTLY) TABLE pg_authid" +== 023 +-- truncate_limit: 100 +-- table with toast relation +CREATE TABLE regress_tblspace_test_tbl (num1 bigint, num2 double precision, t text) +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE regress_tblspace_test_tbl (num1 bigint, num2 double precision, t text)" +== 024 +-- truncate_limit: 100 +INSERT INTO regress_tblspace_test_tbl (num1, num2, t) + SELECT round(random()*100), random(), 'text' + FROM generate_series(1, 10) s(i) +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DML +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO regress_tblspace_test_tbl (num1, num2, t) SELECT ... FROM generate_series(1, 10) s(i)" +== 025 +-- truncate_limit: 100 +CREATE INDEX regress_tblspace_test_tbl_idx ON regress_tblspace_test_tbl (num1) +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX regress_tblspace_test_tbl_idx ON regress_tblspace_test_tbl USING btree (num1)" +== 026 +-- truncate_limit: 100 +-- move to global tablespace, fail +REINDEX (TABLESPACE pg_global) INDEX regress_tblspace_test_tbl_idx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE pg_global) INDEX regress_tblspace_test_tbl_idx" +== 027 +-- truncate_limit: 100 +REINDEX (TABLESPACE pg_global) INDEX CONCURRENTLY regress_tblspace_test_tbl_idx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE pg_global, CONCURRENTLY) INDEX regress_tblspace_test_tbl_idx" +== 028 +-- truncate_limit: 100 +-- check transactional behavior of REINDEX (TABLESPACE) +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 029 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) INDEX regress_tblspace_test_tbl_idx +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace) INDEX regress_tblspace_test_tbl_idx" +== 030 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) TABLE regress_tblspace_test_tbl +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace) TABLE regress_tblspace_test_tbl" +== 031 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 032 +-- truncate_limit: 100 +-- no relation moved to the new tablespace +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +TRUNCATED: "SELECT c.relname FROM pg_class c, pg_tablespace s WHERE ..." +== 033 +-- truncate_limit: 100 +-- check that all indexes are moved to a new tablespace with different +-- relfilenode. +-- Save first the existing relfilenode for the toast and main relations. +SELECT relfilenode as main_filenode FROM pg_class + WHERE relname = 'regress_tblspace_test_tbl_idx' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relfilenode AS main_filenode FROM pg_class WHERE relname = 'regress_tblspace_test_tbl_idx'" +== 034 +-- truncate_limit: 100 +SELECT relfilenode as toast_filenode FROM pg_class + WHERE oid = + (SELECT i.indexrelid + FROM pg_class c, + pg_index i + WHERE i.indrelid = c.reltoastrelid AND + c.relname = 'regress_tblspace_test_tbl') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_index" schema="" table="pg_index" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "i"="pg_index" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="i" column="indrelid" +FILTER: schema="" table="c" column="reltoastrelid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relfilenode AS toast_filenode FROM pg_class WHERE ..." +== 035 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) TABLE regress_tblspace_test_tbl +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace) TABLE regress_tblspace_test_tbl" +== 036 +-- truncate_limit: 100 +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' + ORDER BY c.relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +TRUNCATED: "SELECT c.relname FROM pg_class c, pg_tablespace s WHERE ... ORDER BY c.relname" +== 037 +-- truncate_limit: 100 +ALTER TABLE regress_tblspace_test_tbl SET TABLESPACE regress_tblspace +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE regress_tblspace_test_tbl SET TABLESPACE regress_tblspace" +== 038 +-- truncate_limit: 100 +ALTER TABLE regress_tblspace_test_tbl SET TABLESPACE pg_default +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE regress_tblspace_test_tbl SET TABLESPACE pg_default" +== 039 +-- truncate_limit: 100 +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' + ORDER BY c.relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +TRUNCATED: "SELECT c.relname FROM pg_class c, pg_tablespace s WHERE ... ORDER BY c.relname" +== 040 +-- truncate_limit: 100 +-- Move back to the default tablespace. +ALTER INDEX regress_tblspace_test_tbl_idx SET TABLESPACE pg_default +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX regress_tblspace_test_tbl_idx SET TABLESPACE pg_default" +== 041 +-- truncate_limit: 100 +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' + ORDER BY c.relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +TRUNCATED: "SELECT c.relname FROM pg_class c, pg_tablespace s WHERE ... ORDER BY c.relname" +== 042 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE regress_tblspace_test_tbl +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE regress_tblspace_test_tbl" +== 043 +-- truncate_limit: 100 +SELECT c.relname FROM pg_class c, pg_tablespace s + WHERE c.reltablespace = s.oid AND s.spcname = 'regress_tblspace' + ORDER BY c.relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_tablespace" schema="" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="s" column="oid" +FILTER: schema="" table="s" column="spcname" +STMT: SelectStmt +TRUNCATED: "SELECT c.relname FROM pg_class c, pg_tablespace s WHERE ... ORDER BY c.relname" +== 044 +-- truncate_limit: 100 +SELECT relfilenode = :main_filenode AS main_same FROM pg_class + WHERE relname = 'regress_tblspace_test_tbl_idx' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 045 +-- truncate_limit: 100 +SELECT relfilenode = :toast_filenode as toast_same FROM pg_class + WHERE oid = + (SELECT i.indexrelid + FROM pg_class c, + pg_index i + WHERE i.indrelid = c.reltoastrelid AND + c.relname = 'regress_tblspace_test_tbl') +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 046 +-- truncate_limit: 100 +DROP TABLE regress_tblspace_test_tbl +-- +TABLE: name="regress_tblspace_test_tbl" schema="" table="regress_tblspace_test_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE regress_tblspace_test_tbl" +== 047 +-- truncate_limit: 100 +-- REINDEX (TABLESPACE) with partitions +-- Create a partition tree and check the set of relations reindexed +-- with their new tablespace. +CREATE TABLE tbspace_reindex_part (c1 int, c2 int) PARTITION BY RANGE (c1) +-- +TABLE: name="tbspace_reindex_part" schema="" table="tbspace_reindex_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbspace_reindex_part (c1 int, c2 int) PARTITION BY RANGE (c1)" +== 048 +-- truncate_limit: 100 +CREATE TABLE tbspace_reindex_part_0 PARTITION OF tbspace_reindex_part + FOR VALUES FROM (0) TO (10) PARTITION BY list (c2) +-- +TABLE: name="tbspace_reindex_part_0" schema="" table="tbspace_reindex_part_0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbspace_reindex_part_0 PARTITION OF tbspace_reindex_part FOR VALUES FROM (0) TO (10)..." +== 049 +-- truncate_limit: 100 +CREATE TABLE tbspace_reindex_part_0_1 PARTITION OF tbspace_reindex_part_0 + FOR VALUES IN (1) +-- +TABLE: name="tbspace_reindex_part_0_1" schema="" table="tbspace_reindex_part_0_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbspace_reindex_part_0_1 PARTITION OF tbspace_reindex_part_0 FOR VALUES IN (1)" +== 050 +-- truncate_limit: 100 +CREATE TABLE tbspace_reindex_part_0_2 PARTITION OF tbspace_reindex_part_0 + FOR VALUES IN (2) +-- +TABLE: name="tbspace_reindex_part_0_2" schema="" table="tbspace_reindex_part_0_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbspace_reindex_part_0_2 PARTITION OF tbspace_reindex_part_0 FOR VALUES IN (2)" +== 051 +-- truncate_limit: 100 +-- This partitioned table will have no partitions. +CREATE TABLE tbspace_reindex_part_10 PARTITION OF tbspace_reindex_part + FOR VALUES FROM (10) TO (20) PARTITION BY list (c2) +-- +TABLE: name="tbspace_reindex_part_10" schema="" table="tbspace_reindex_part_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tbspace_reindex_part_10 PARTITION OF tbspace_reindex_part FOR VALUES FROM (10) TO (2..." +== 052 +-- truncate_limit: 100 +-- Create some partitioned indexes +CREATE INDEX tbspace_reindex_part_index ON ONLY tbspace_reindex_part (c1) +-- +TABLE: name="tbspace_reindex_part" schema="" table="tbspace_reindex_part" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbspace_reindex_part_index ON ONLY tbspace_reindex_part USING btree (c1)" +== 053 +-- truncate_limit: 100 +CREATE INDEX tbspace_reindex_part_index_0 ON ONLY tbspace_reindex_part_0 (c1) +-- +TABLE: name="tbspace_reindex_part_0" schema="" table="tbspace_reindex_part_0" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbspace_reindex_part_index_0 ON ONLY tbspace_reindex_part_0 USING btree (c1)" +== 054 +-- truncate_limit: 100 +ALTER INDEX tbspace_reindex_part_index ATTACH PARTITION tbspace_reindex_part_index_0 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX tbspace_reindex_part_index ATTACH PARTITION tbspace_reindex_part_index_0" +== 055 +-- truncate_limit: 100 +-- This partitioned index will have no partitions. +CREATE INDEX tbspace_reindex_part_index_10 ON ONLY tbspace_reindex_part_10 (c1) +-- +TABLE: name="tbspace_reindex_part_10" schema="" table="tbspace_reindex_part_10" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbspace_reindex_part_index_10 ON ONLY tbspace_reindex_part_10 USING btree (c1)" +== 056 +-- truncate_limit: 100 +ALTER INDEX tbspace_reindex_part_index ATTACH PARTITION tbspace_reindex_part_index_10 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX tbspace_reindex_part_index ATTACH PARTITION tbspace_reindex_part_index_10" +== 057 +-- truncate_limit: 100 +CREATE INDEX tbspace_reindex_part_index_0_1 ON ONLY tbspace_reindex_part_0_1 (c1) +-- +TABLE: name="tbspace_reindex_part_0_1" schema="" table="tbspace_reindex_part_0_1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbspace_reindex_part_index_0_1 ON ONLY tbspace_reindex_part_0_1 USING btree (c1)" +== 058 +-- truncate_limit: 100 +ALTER INDEX tbspace_reindex_part_index_0 ATTACH PARTITION tbspace_reindex_part_index_0_1 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX tbspace_reindex_part_index_0 ATTACH PARTITION tbspace_reindex_part_index_0_1" +== 059 +-- truncate_limit: 100 +CREATE INDEX tbspace_reindex_part_index_0_2 ON ONLY tbspace_reindex_part_0_2 (c1) +-- +TABLE: name="tbspace_reindex_part_0_2" schema="" table="tbspace_reindex_part_0_2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tbspace_reindex_part_index_0_2 ON ONLY tbspace_reindex_part_0_2 USING btree (c1)" +== 060 +-- truncate_limit: 100 +ALTER INDEX tbspace_reindex_part_index_0 ATTACH PARTITION tbspace_reindex_part_index_0_2 +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX tbspace_reindex_part_index_0 ATTACH PARTITION tbspace_reindex_part_index_0_2" +== 061 +-- truncate_limit: 100 +SELECT relid, parentrelid, level FROM pg_partition_tree('tbspace_reindex_part_index') + ORDER BY relid, level +-- +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_partition_tree('tbspace_reindex_part_index') ORDER BY relid, level" +== 062 +-- truncate_limit: 100 +-- Track the original tablespace, relfilenode and OID of each index +-- in the tree. +CREATE TEMP TABLE reindex_temp_before AS + SELECT oid, relname, relfilenode, reltablespace + FROM pg_class + WHERE relname ~ 'tbspace_reindex_part_index' +-- +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=DDL +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE reindex_temp_before AS SELECT oid, relname, relfilenode, reltablespace FRO..." +== 063 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE tbspace_reindex_part +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE tbspace_reindex_part" +== 064 +-- truncate_limit: 100 +-- REINDEX CONCURRENTLY changes the OID of the old relation, hence a check +-- based on the relation name below. +SELECT b.relname, + CASE WHEN a.relfilenode = b.relfilenode THEN 'relfilenode is unchanged' + ELSE 'relfilenode has changed' END AS filenode, + CASE WHEN a.reltablespace = b.reltablespace THEN 'reltablespace is unchanged' + ELSE 'reltablespace has changed' END AS tbspace + FROM reindex_temp_before b JOIN pg_class a ON b.relname = a.relname + ORDER BY 1 +-- +TABLE: name="reindex_temp_before" schema="" table="reindex_temp_before" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a"="pg_class" +ALIAS: "b"="reindex_temp_before" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM reindex_temp_before b JOIN pg_class a ON b.relname = a.relname ORDER BY 1" +== 065 +-- truncate_limit: 100 +DROP TABLE tbspace_reindex_part +-- +TABLE: name="tbspace_reindex_part" schema="" table="tbspace_reindex_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tbspace_reindex_part" +== 066 +-- truncate_limit: 100 +-- create a schema we can use +CREATE SCHEMA testschema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA testschema" +== 067 +-- truncate_limit: 100 +-- try a table +CREATE TABLE testschema.foo (i int) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.foo" schema="testschema" table="foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.foo (i int) TABLESPACE regress_tblspace" +== 068 +-- truncate_limit: 100 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'foo' +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c WHERE ..." +== 069 +-- truncate_limit: 100 +INSERT INTO testschema.foo VALUES(1) +-- +TABLE: name="testschema.foo" schema="testschema" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testschema.foo VALUES (1)" +== 070 +-- truncate_limit: 100 +INSERT INTO testschema.foo VALUES(2) +-- +TABLE: name="testschema.foo" schema="testschema" table="foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testschema.foo VALUES (2)" +== 071 +-- truncate_limit: 100 +-- tables from dynamic sources +CREATE TABLE testschema.asselect TABLESPACE regress_tblspace AS SELECT 1 +-- +TABLE: name="testschema.asselect" schema="testschema" table="asselect" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE testschema.asselect TABLESPACE regress_tblspace AS SELECT 1" +== 072 +-- truncate_limit: 100 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'asselect' +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c WHERE ..." +== 073 +-- truncate_limit: 100 +PREPARE selectsource(int) AS SELECT $1 +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE selectsource(int) AS SELECT $1" +== 074 +-- truncate_limit: 100 +CREATE TABLE testschema.asexecute TABLESPACE regress_tblspace + AS EXECUTE selectsource(2) +-- +TABLE: name="testschema.asexecute" schema="testschema" table="asexecute" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TABLE testschema.asexecute TABLESPACE regress_tblspace AS EXECUTE selectsource(2)" +== 075 +-- truncate_limit: 100 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'asexecute' +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c WHERE ..." +== 076 +-- truncate_limit: 100 +-- index +CREATE INDEX foo_idx on testschema.foo(i) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.foo" schema="testschema" table="foo" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX foo_idx ON testschema.foo USING btree (i) TABLESPACE regress_tblspace" +== 077 +-- truncate_limit: 100 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'foo_idx' +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c WHERE ..." +== 078 +-- truncate_limit: 100 +-- check \d output + +|-- +-- partitioned table +|-- +CREATE TABLE testschema.part (a int) PARTITION BY LIST (a) +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part (a int) PARTITION BY LIST (a)" +== 079 +-- truncate_limit: 100 +SET default_tablespace TO pg_global +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO pg_global" +== 080 +-- truncate_limit: 100 +CREATE TABLE testschema.part_1 PARTITION OF testschema.part FOR VALUES IN (1) +-- +TABLE: name="testschema.part_1" schema="testschema" table="part_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_1 PARTITION OF testschema.part FOR VALUES IN (1)" +== 081 +-- truncate_limit: 100 +RESET default_tablespace +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_tablespace" +== 082 +-- truncate_limit: 100 +CREATE TABLE testschema.part_1 PARTITION OF testschema.part FOR VALUES IN (1) +-- +TABLE: name="testschema.part_1" schema="testschema" table="part_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_1 PARTITION OF testschema.part FOR VALUES IN (1)" +== 083 +-- truncate_limit: 100 +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO regress_tblspace" +== 084 +-- truncate_limit: 100 +CREATE TABLE testschema.part_2 PARTITION OF testschema.part FOR VALUES IN (2) +-- +TABLE: name="testschema.part_2" schema="testschema" table="part_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_2 PARTITION OF testschema.part FOR VALUES IN (2)" +== 085 +-- truncate_limit: 100 +SET default_tablespace TO pg_global +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO pg_global" +== 086 +-- truncate_limit: 100 +CREATE TABLE testschema.part_3 PARTITION OF testschema.part FOR VALUES IN (3) +-- +TABLE: name="testschema.part_3" schema="testschema" table="part_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_3 PARTITION OF testschema.part FOR VALUES IN (3)" +== 087 +-- truncate_limit: 100 +ALTER TABLE testschema.part SET TABLESPACE regress_tblspace +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.part SET TABLESPACE regress_tblspace" +== 088 +-- truncate_limit: 100 +CREATE TABLE testschema.part_3 PARTITION OF testschema.part FOR VALUES IN (3) +-- +TABLE: name="testschema.part_3" schema="testschema" table="part_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_3 PARTITION OF testschema.part FOR VALUES IN (3)" +== 089 +-- truncate_limit: 100 +CREATE TABLE testschema.part_4 PARTITION OF testschema.part FOR VALUES IN (4) + TABLESPACE pg_default +-- +TABLE: name="testschema.part_4" schema="testschema" table="part_4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_4 PARTITION OF testschema.part FOR VALUES IN (4) TABLESPACE pg_default" +== 090 +-- truncate_limit: 100 +CREATE TABLE testschema.part_56 PARTITION OF testschema.part FOR VALUES IN (5, 6) + PARTITION BY LIST (a) +-- +TABLE: name="testschema.part_56" schema="testschema" table="part_56" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_56 PARTITION OF testschema.part FOR VALUES IN (5, 6) PARTITION BY LI..." +== 091 +-- truncate_limit: 100 +ALTER TABLE testschema.part SET TABLESPACE pg_default +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.part SET TABLESPACE pg_default" +== 092 +-- truncate_limit: 100 +CREATE TABLE testschema.part_78 PARTITION OF testschema.part FOR VALUES IN (7, 8) + PARTITION BY LIST (a) +-- +TABLE: name="testschema.part_78" schema="testschema" table="part_78" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_78 PARTITION OF testschema.part FOR VALUES IN (7, 8) PARTITION BY LI..." +== 093 +-- truncate_limit: 100 +CREATE TABLE testschema.part_910 PARTITION OF testschema.part FOR VALUES IN (9, 10) + PARTITION BY LIST (a) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.part_910" schema="testschema" table="part_910" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_910 PARTITION OF testschema.part FOR VALUES IN (9, 10) PARTITION BY ..." +== 094 +-- truncate_limit: 100 +RESET default_tablespace +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_tablespace" +== 095 +-- truncate_limit: 100 +CREATE TABLE testschema.part_78 PARTITION OF testschema.part FOR VALUES IN (7, 8) + PARTITION BY LIST (a) +-- +TABLE: name="testschema.part_78" schema="testschema" table="part_78" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part_78 PARTITION OF testschema.part FOR VALUES IN (7, 8) PARTITION BY LI..." +== 096 +-- truncate_limit: 100 +SELECT relname, spcname FROM pg_catalog.pg_class c + JOIN pg_catalog.pg_namespace n ON (c.relnamespace = n.oid) + LEFT JOIN pg_catalog.pg_tablespace t ON c.reltablespace = t.oid + where c.relname LIKE 'part%' AND n.nspname = 'testschema' order by relname +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +TABLE: name="pg_catalog.pg_namespace" schema="pg_catalog" table="pg_namespace" ctx=Select +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "n"="pg_catalog.pg_namespace" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="n" column="nspname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid LE..." +== 097 +-- truncate_limit: 100 +RESET default_tablespace +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_tablespace" +== 098 +-- truncate_limit: 100 +DROP TABLE testschema.part +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testschema.part" +== 099 +-- truncate_limit: 100 +-- partitioned index +CREATE TABLE testschema.part (a int) PARTITION BY LIST (a) +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part (a int) PARTITION BY LIST (a)" +== 100 +-- truncate_limit: 100 +CREATE TABLE testschema.part1 PARTITION OF testschema.part FOR VALUES IN (1) +-- +TABLE: name="testschema.part1" schema="testschema" table="part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part1 PARTITION OF testschema.part FOR VALUES IN (1)" +== 101 +-- truncate_limit: 100 +CREATE INDEX part_a_idx ON testschema.part (a) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.part" schema="testschema" table="part" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX part_a_idx ON testschema.part USING btree (a) TABLESPACE regress_tblspace" +== 102 +-- truncate_limit: 100 +CREATE TABLE testschema.part2 PARTITION OF testschema.part FOR VALUES IN (2) +-- +TABLE: name="testschema.part2" schema="testschema" table="part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.part2 PARTITION OF testschema.part FOR VALUES IN (2)" +== 103 +-- truncate_limit: 100 +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname LIKE 'part%_idx' ORDER BY relname +-- +TABLE: name="pg_catalog.pg_tablespace" schema="pg_catalog" table="pg_tablespace" ctx=Select +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=Select +ALIAS: "c"="pg_catalog.pg_class" +ALIAS: "t"="pg_catalog.pg_tablespace" +FILTER: schema="" table="c" column="reltablespace" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c WHERE ... ORDER BY relname" +== 104 +-- truncate_limit: 100 +-- partitioned rels cannot specify the default tablespace. These fail: +CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE pg_default +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE pg_default" +== 105 +-- truncate_limit: 100 +CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE pg_default) PARTITION BY LIST (a) +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE pg_default) PARTITION BY L..." +== 106 +-- truncate_limit: 100 +SET default_tablespace TO 'pg_default' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO pg_default" +== 107 +-- truncate_limit: 100 +CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.dflt (a int PRIMARY KEY) PARTITION BY LIST (a) TABLESPACE regress_tblspace" +== 108 +-- truncate_limit: 100 +CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a) +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITIO..." +== 109 +-- truncate_limit: 100 +-- but these work: +CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITION BY LIST (a) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.dflt (a int PRIMARY KEY USING INDEX TABLESPACE regress_tblspace) PARTITIO..." +== 110 +-- truncate_limit: 100 +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO ''" +== 111 +-- truncate_limit: 100 +CREATE TABLE testschema.dflt2 (a int PRIMARY KEY) PARTITION BY LIST (a) +-- +TABLE: name="testschema.dflt2" schema="testschema" table="dflt2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.dflt2 (a int PRIMARY KEY) PARTITION BY LIST (a)" +== 112 +-- truncate_limit: 100 +DROP TABLE testschema.dflt, testschema.dflt2 +-- +TABLE: name="testschema.dflt" schema="testschema" table="dflt" ctx=DDL +TABLE: name="testschema.dflt2" schema="testschema" table="dflt2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testschema.dflt, testschema.dflt2" +== 113 +-- truncate_limit: 100 +-- check that default_tablespace doesn't affect ALTER TABLE index rebuilds +CREATE TABLE testschema.test_default_tab(id bigint) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.test_default_tab (id bigint) TABLESPACE regress_tblspace" +== 114 +-- truncate_limit: 100 +INSERT INTO testschema.test_default_tab VALUES (1) +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testschema.test_default_tab VALUES (1)" +== 115 +-- truncate_limit: 100 +CREATE INDEX test_index1 on testschema.test_default_tab (id) +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_index1 ON testschema.test_default_tab USING btree (id)" +== 116 +-- truncate_limit: 100 +CREATE INDEX test_index2 on testschema.test_default_tab (id) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_index2 ON testschema.test_default_tab USING btree (id) TABLESPACE regress_tblspace" +== 117 +-- truncate_limit: 100 +ALTER TABLE testschema.test_default_tab ADD CONSTRAINT test_index3 PRIMARY KEY (id) +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab ADD CONSTRAINT test_index3 PRIMARY KEY (id)" +== 118 +-- truncate_limit: 100 +ALTER TABLE testschema.test_default_tab ADD CONSTRAINT test_index4 UNIQUE (id) USING INDEX TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab ADD CONSTRAINT test_index4 UNIQUE (id) USING INDEX TABLES..." +== 119 +-- truncate_limit: 100 +-- use a custom tablespace for default_tablespace +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO regress_tblspace" +== 120 +-- truncate_limit: 100 +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab ALTER COLUMN id TYPE bigint" +== 121 +-- truncate_limit: 100 +SELECT * FROM testschema.test_default_tab +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testschema.test_default_tab" +== 122 +-- truncate_limit: 100 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE int +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab ALTER COLUMN id TYPE int" +== 123 +-- truncate_limit: 100 +SELECT * FROM testschema.test_default_tab +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testschema.test_default_tab" +== 124 +-- truncate_limit: 100 +-- now use the default tablespace for default_tablespace +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO ''" +== 125 +-- truncate_limit: 100 +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE int +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab ALTER COLUMN id TYPE int" +== 126 +-- truncate_limit: 100 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab ALTER id TYPE bigint +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab ALTER COLUMN id TYPE bigint" +== 127 +-- truncate_limit: 100 +DROP TABLE testschema.test_default_tab +-- +TABLE: name="testschema.test_default_tab" schema="testschema" table="test_default_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testschema.test_default_tab" +== 128 +-- truncate_limit: 100 +-- check that default_tablespace doesn't affect ALTER TABLE index rebuilds +-- (this time with a partitioned table) +CREATE TABLE testschema.test_default_tab_p(id bigint, val bigint) + PARTITION BY LIST (id) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.test_default_tab_p (id bigint, val bigint) PARTITION BY LIST (id) TABLESP..." +== 129 +-- truncate_limit: 100 +CREATE TABLE testschema.test_default_tab_p1 PARTITION OF testschema.test_default_tab_p + FOR VALUES IN (1) +-- +TABLE: name="testschema.test_default_tab_p1" schema="testschema" table="test_default_tab_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.test_default_tab_p1 PARTITION OF testschema.test_default_tab_p FOR VALUES..." +== 130 +-- truncate_limit: 100 +INSERT INTO testschema.test_default_tab_p VALUES (1) +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testschema.test_default_tab_p VALUES (1)" +== 131 +-- truncate_limit: 100 +CREATE INDEX test_index1 on testschema.test_default_tab_p (val) +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_index1 ON testschema.test_default_tab_p USING btree (val)" +== 132 +-- truncate_limit: 100 +CREATE INDEX test_index2 on testschema.test_default_tab_p (val) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_index2 ON testschema.test_default_tab_p USING btree (val) TABLESPACE regress_tb..." +== 133 +-- truncate_limit: 100 +ALTER TABLE testschema.test_default_tab_p ADD CONSTRAINT test_index3 PRIMARY KEY (id) +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab_p ADD CONSTRAINT test_index3 PRIMARY KEY (id)" +== 134 +-- truncate_limit: 100 +ALTER TABLE testschema.test_default_tab_p ADD CONSTRAINT test_index4 UNIQUE (id) USING INDEX TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab_p ADD CONSTRAINT test_index4 UNIQUE (id) USING INDEX TABL..." +== 135 +-- truncate_limit: 100 +-- use a custom tablespace for default_tablespace +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO regress_tblspace" +== 136 +-- truncate_limit: 100 +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab_p ALTER val TYPE bigint +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab_p ALTER COLUMN val TYPE bigint" +== 137 +-- truncate_limit: 100 +SELECT * FROM testschema.test_default_tab_p +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testschema.test_default_tab_p" +== 138 +-- truncate_limit: 100 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab_p ALTER val TYPE int +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab_p ALTER COLUMN val TYPE int" +== 139 +-- truncate_limit: 100 +SELECT * FROM testschema.test_default_tab_p +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testschema.test_default_tab_p" +== 140 +-- truncate_limit: 100 +-- now use the default tablespace for default_tablespace +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO ''" +== 141 +-- truncate_limit: 100 +-- tablespace should not change if no rewrite +ALTER TABLE testschema.test_default_tab_p ALTER val TYPE int +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab_p ALTER COLUMN val TYPE int" +== 142 +-- truncate_limit: 100 +-- tablespace should not change even if there is an index rewrite +ALTER TABLE testschema.test_default_tab_p ALTER val TYPE bigint +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_default_tab_p ALTER COLUMN val TYPE bigint" +== 143 +-- truncate_limit: 100 +DROP TABLE testschema.test_default_tab_p +-- +TABLE: name="testschema.test_default_tab_p" schema="testschema" table="test_default_tab_p" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testschema.test_default_tab_p" +== 144 +-- truncate_limit: 100 +-- check that default_tablespace affects index additions in ALTER TABLE +CREATE TABLE testschema.test_tab(id int) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.test_tab (id int) TABLESPACE regress_tblspace" +== 145 +-- truncate_limit: 100 +INSERT INTO testschema.test_tab VALUES (1) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testschema.test_tab VALUES (1)" +== 146 +-- truncate_limit: 100 +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO regress_tblspace" +== 147 +-- truncate_limit: 100 +ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_unique UNIQUE (id) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_unique UNIQUE (id)" +== 148 +-- truncate_limit: 100 +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO ''" +== 149 +-- truncate_limit: 100 +ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_pkey PRIMARY KEY (id) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_pkey PRIMARY KEY (id)" +== 150 +-- truncate_limit: 100 +SELECT * FROM testschema.test_tab +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM testschema.test_tab" +== 151 +-- truncate_limit: 100 +DROP TABLE testschema.test_tab +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testschema.test_tab" +== 152 +-- truncate_limit: 100 +-- check that default_tablespace is handled correctly by multi-command +-- ALTER TABLE that includes a tablespace-preserving rewrite +CREATE TABLE testschema.test_tab(a int, b int, c int) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.test_tab (a int, b int, c int)" +== 153 +-- truncate_limit: 100 +SET default_tablespace TO regress_tblspace +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO regress_tblspace" +== 154 +-- truncate_limit: 100 +ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_unique UNIQUE (a) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_tab ADD CONSTRAINT test_tab_unique UNIQUE (a)" +== 155 +-- truncate_limit: 100 +CREATE INDEX test_tab_a_idx ON testschema.test_tab (a) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_tab_a_idx ON testschema.test_tab USING btree (a)" +== 156 +-- truncate_limit: 100 +SET default_tablespace TO '' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_tablespace TO ''" +== 157 +-- truncate_limit: 100 +CREATE INDEX test_tab_b_idx ON testschema.test_tab (b) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX test_tab_b_idx ON testschema.test_tab USING btree (b)" +== 158 +-- truncate_limit: 100 +ALTER TABLE testschema.test_tab ALTER b TYPE bigint, ADD UNIQUE (c) +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.test_tab ALTER COLUMN b TYPE bigint, ADD UNIQUE (c)" +== 159 +-- truncate_limit: 100 +DROP TABLE testschema.test_tab +-- +TABLE: name="testschema.test_tab" schema="testschema" table="test_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE testschema.test_tab" +== 160 +-- truncate_limit: 100 +-- let's try moving a table from one place to another +CREATE TABLE testschema.atable AS VALUES (1), (2) +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE testschema.atable AS VALUES (1), (2)" +== 161 +-- truncate_limit: 100 +CREATE UNIQUE INDEX anindex ON testschema.atable(column1) +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX anindex ON testschema.atable USING btree (column1)" +== 162 +-- truncate_limit: 100 +ALTER TABLE testschema.atable SET TABLESPACE regress_tblspace +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.atable SET TABLESPACE regress_tblspace" +== 163 +-- truncate_limit: 100 +ALTER INDEX testschema.anindex SET TABLESPACE regress_tblspace +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX testschema.anindex SET TABLESPACE regress_tblspace" +== 164 +-- truncate_limit: 100 +ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_global +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_global" +== 165 +-- truncate_limit: 100 +ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_default +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_default" +== 166 +-- truncate_limit: 100 +ALTER INDEX testschema.part_a_idx SET TABLESPACE regress_tblspace +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX testschema.part_a_idx SET TABLESPACE regress_tblspace" +== 167 +-- truncate_limit: 100 +INSERT INTO testschema.atable VALUES(3) +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testschema.atable VALUES (3)" +== 168 +-- truncate_limit: 100 +-- ok +INSERT INTO testschema.atable VALUES(1) +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testschema.atable VALUES (1)" +== 169 +-- truncate_limit: 100 +-- fail (checks index) +SELECT COUNT(*) FROM testschema.atable +-- +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testschema.atable" +== 170 +-- truncate_limit: 100 +-- checks heap + +-- let's try moving a materialized view from one place to another +CREATE MATERIALIZED VIEW testschema.amv AS SELECT * FROM testschema.atable +-- +TABLE: name="testschema.amv" schema="testschema" table="amv" ctx=DDL +TABLE: name="testschema.atable" schema="testschema" table="atable" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW testschema.amv AS SELECT * FROM testschema.atable" +== 171 +-- truncate_limit: 100 +ALTER MATERIALIZED VIEW testschema.amv SET TABLESPACE regress_tblspace +-- +TABLE: name="testschema.amv" schema="testschema" table="amv" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER MATERIALIZED VIEW testschema.amv SET TABLESPACE regress_tblspace" +== 172 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW testschema.amv +-- +TABLE: name="testschema.amv" schema="testschema" table="amv" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW testschema.amv" +== 173 +-- truncate_limit: 100 +SELECT COUNT(*) FROM testschema.amv +-- +TABLE: name="testschema.amv" schema="testschema" table="amv" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM testschema.amv" +== 174 +-- truncate_limit: 100 +-- Will fail with bad path +CREATE TABLESPACE regress_badspace LOCATION '/no/such/location' +-- +STMT: CreateTableSpaceStmt +TRUNCATED: "CREATE TABLESPACE regress_badspace LOCATION '/no/such/location'" +== 175 +-- truncate_limit: 100 +-- No such tablespace +CREATE TABLE bar (i int) TABLESPACE regress_nosuchspace +-- +TABLE: name="bar" schema="" table="bar" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE bar (i int) TABLESPACE regress_nosuchspace" +== 176 +-- truncate_limit: 100 +-- Fail, in use for some partitioned object +DROP TABLESPACE regress_tblspace +-- +STMT: DropTableSpaceStmt +TRUNCATED: "DROP TABLESPACE regress_tblspace" +== 177 +-- truncate_limit: 100 +ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_default +-- +STMT: AlterTableStmt +TRUNCATED: "ALTER INDEX testschema.part_a_idx SET TABLESPACE pg_default" +== 178 +-- truncate_limit: 100 +-- Fail, not empty +DROP TABLESPACE regress_tblspace +-- +STMT: DropTableSpaceStmt +TRUNCATED: "DROP TABLESPACE regress_tblspace" +== 179 +-- truncate_limit: 100 +-- Adequate cache initialization before GRANT +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 180 +-- truncate_limit: 100 +GRANT ALL ON TABLESPACE regress_tblspace TO PUBLIC +-- +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON TABLESPACE regress_tblspace TO public" +== 181 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 182 +-- truncate_limit: 100 +CREATE ROLE regress_tablespace_user1 login +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_tablespace_user1 WITH LOGIN" +== 183 +-- truncate_limit: 100 +CREATE ROLE regress_tablespace_user2 login +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_tablespace_user2 WITH LOGIN" +== 184 +-- truncate_limit: 100 +GRANT USAGE ON SCHEMA testschema TO regress_tablespace_user2 +-- +STMT: GrantStmt +TRUNCATED: "GRANT usage ON SCHEMA testschema TO regress_tablespace_user2" +== 185 +-- truncate_limit: 100 +ALTER TABLESPACE regress_tblspace OWNER TO regress_tablespace_user1 +-- +STMT: AlterOwnerStmt +TRUNCATED: "ALTER TABLESPACE regress_tblspace OWNER TO regress_tablespace_user1" +== 186 +-- truncate_limit: 100 +CREATE TABLE testschema.tablespace_acl (c int) +-- +TABLE: name="testschema.tablespace_acl" schema="testschema" table="tablespace_acl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testschema.tablespace_acl (c int)" +== 187 +-- truncate_limit: 100 +-- new owner lacks permission to create this index from scratch +CREATE INDEX k ON testschema.tablespace_acl (c) TABLESPACE regress_tblspace +-- +TABLE: name="testschema.tablespace_acl" schema="testschema" table="tablespace_acl" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX k ON testschema.tablespace_acl USING btree (c) TABLESPACE regress_tblspace" +== 188 +-- truncate_limit: 100 +ALTER TABLE testschema.tablespace_acl OWNER TO regress_tablespace_user2 +-- +TABLE: name="testschema.tablespace_acl" schema="testschema" table="tablespace_acl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.tablespace_acl OWNER TO regress_tablespace_user2" +== 189 +-- truncate_limit: 100 +SET SESSION ROLE regress_tablespace_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_tablespace_user2" +== 190 +-- truncate_limit: 100 +CREATE TABLE tablespace_table (i int) TABLESPACE regress_tblspace +-- +TABLE: name="tablespace_table" schema="" table="tablespace_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tablespace_table (i int) TABLESPACE regress_tblspace" +== 191 +-- truncate_limit: 100 +-- fail +ALTER TABLE testschema.tablespace_acl ALTER c TYPE bigint +-- +TABLE: name="testschema.tablespace_acl" schema="testschema" table="tablespace_acl" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testschema.tablespace_acl ALTER COLUMN c TYPE bigint" +== 192 +-- truncate_limit: 100 +REINDEX (TABLESPACE regress_tblspace) TABLE tablespace_table +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace) TABLE tablespace_table" +== 193 +-- truncate_limit: 100 +-- fail +REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE tablespace_table +-- +STMT: ReindexStmt +TRUNCATED: "REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE tablespace_table" +== 194 +-- truncate_limit: 100 +-- fail +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 195 +-- truncate_limit: 100 +ALTER TABLESPACE regress_tblspace RENAME TO regress_tblspace_renamed +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLESPACE regress_tblspace RENAME TO regress_tblspace_renamed" +== 196 +-- truncate_limit: 100 +ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +TRUNCATED: "ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default" +== 197 +-- truncate_limit: 100 +ALTER INDEX ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +TRUNCATED: "ALTER INDEX ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default" +== 198 +-- truncate_limit: 100 +ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +TRUNCATED: "ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default" +== 199 +-- truncate_limit: 100 +-- Should show notice that nothing was done +ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +TRUNCATED: "ALTER TABLE ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default" +== 200 +-- truncate_limit: 100 +ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default +-- +STMT: AlterTableMoveAllStmt +TRUNCATED: "ALTER MATERIALIZED VIEW ALL IN TABLESPACE regress_tblspace_renamed SET TABLESPACE pg_default" +== 201 +-- truncate_limit: 100 +-- Should succeed +DROP TABLESPACE regress_tblspace_renamed +-- +STMT: DropTableSpaceStmt +TRUNCATED: "DROP TABLESPACE regress_tblspace_renamed" +== 202 +-- truncate_limit: 100 +DROP SCHEMA testschema CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SCHEMA testschema CASCADE" +== 203 +-- truncate_limit: 100 +DROP ROLE regress_tablespace_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_tablespace_user1" +== 204 +-- truncate_limit: 100 +DROP ROLE regress_tablespace_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_tablespace_user2" diff --git a/parser/testdata/summary_truncate/postgres_regress/temp.metadata.json b/parser/testdata/summary_truncate/postgres_regress/temp.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/temp.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/temp.test b/parser/testdata/summary_truncate/postgres_regress/temp.test new file mode 100644 index 0000000..89e99e8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/temp.test @@ -0,0 +1,1188 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TEMP +-- Test temp relations and indexes +|-- + +-- test temp table/index masking + +CREATE TABLE temptest(col int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE temptest (col int)" +== 002 +-- truncate_limit: 100 +CREATE INDEX i_temptest ON temptest(col) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX i_temptest ON temptest USING btree (col)" +== 003 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest(tcol int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest (tcol int)" +== 004 +-- truncate_limit: 100 +CREATE INDEX i_temptest ON temptest(tcol) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX i_temptest ON temptest USING btree (tcol)" +== 005 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 006 +-- truncate_limit: 100 +DROP INDEX i_temptest +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX i_temptest" +== 007 +-- truncate_limit: 100 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temptest" +== 008 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 009 +-- truncate_limit: 100 +DROP INDEX i_temptest +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX i_temptest" +== 010 +-- truncate_limit: 100 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temptest" +== 011 +-- truncate_limit: 100 +-- test temp table selects + +CREATE TABLE temptest(col int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE temptest (col int)" +== 012 +-- truncate_limit: 100 +INSERT INTO temptest VALUES (1) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temptest VALUES (1)" +== 013 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest(tcol float) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest (tcol double precision)" +== 014 +-- truncate_limit: 100 +INSERT INTO temptest VALUES (2.1) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temptest VALUES (2.1)" +== 015 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 016 +-- truncate_limit: 100 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temptest" +== 017 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 018 +-- truncate_limit: 100 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temptest" +== 019 +-- truncate_limit: 100 +-- test temp table deletion + +CREATE TEMP TABLE temptest(col int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest (col int)" +== 020 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 021 +-- truncate_limit: 100 +-- Test ON COMMIT DELETE ROWS + +CREATE TEMP TABLE temptest(col int) ON COMMIT DELETE ROWS +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest (col int) ON COMMIT DELETE ROWS" +== 022 +-- truncate_limit: 100 +-- while we're here, verify successful truncation of index with SQL function +CREATE INDEX ON temptest(bit_length('')) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +FUNCTION: name="bit_length" function="bit_length" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON temptest USING btree (bit_length(''))" +== 023 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 024 +-- truncate_limit: 100 +INSERT INTO temptest VALUES (1) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temptest VALUES (1)" +== 025 +-- truncate_limit: 100 +INSERT INTO temptest VALUES (2) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temptest VALUES (2)" +== 026 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 027 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 028 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 029 +-- truncate_limit: 100 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temptest" +== 030 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 031 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest(col) ON COMMIT DELETE ROWS AS SELECT 1 +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest(col) ON COMMIT DELETE ROWS AS SELECT 1" +== 032 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 033 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 034 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 035 +-- truncate_limit: 100 +DROP TABLE temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temptest" +== 036 +-- truncate_limit: 100 +-- Test ON COMMIT DROP + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 037 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest(col int) ON COMMIT DROP +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest (col int) ON COMMIT DROP" +== 038 +-- truncate_limit: 100 +INSERT INTO temptest VALUES (1) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temptest VALUES (1)" +== 039 +-- truncate_limit: 100 +INSERT INTO temptest VALUES (2) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temptest VALUES (2)" +== 040 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 041 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 042 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 043 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 044 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest(col) ON COMMIT DROP AS SELECT 1 +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest(col) ON COMMIT DROP AS SELECT 1" +== 045 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 046 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 047 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 048 +-- truncate_limit: 100 +-- Test it with a CHECK condition that produces a toasted pg_constraint entry +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 049 +-- truncate_limit: 100 +do $$ +begin + execute format($cmd$ + CREATE TEMP TABLE temptest (col text CHECK (col < %L)) ON COMMIT DROP + $cmd$, + (SELECT string_agg(g.i::text || ':' || random()::text, '|') + FROM generate_series(1, 100) g(i))); +end$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nbegin\n execute format($cmd$\n CREATE TEMP TABLE temptest (col text CHECK (col < %L)) ON ..." +== 050 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 051 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 052 +-- truncate_limit: 100 +SELECT * FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest" +== 053 +-- truncate_limit: 100 +-- ON COMMIT is only allowed for TEMP + +CREATE TABLE temptest(col int) ON COMMIT DELETE ROWS +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE temptest (col int) ON COMMIT DELETE ROWS" +== 054 +-- truncate_limit: 100 +CREATE TABLE temptest(col) ON COMMIT DELETE ROWS AS SELECT 1 +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE temptest(col) ON COMMIT DELETE ROWS AS SELECT 1" +== 055 +-- truncate_limit: 100 +-- Test foreign keys +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 056 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest1(col int PRIMARY KEY) +-- +TABLE: name="temptest1" schema="" table="temptest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest1 (col int PRIMARY KEY)" +== 057 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest2(col int REFERENCES temptest1) + ON COMMIT DELETE ROWS +-- +TABLE: name="temptest2" schema="" table="temptest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest2 (col int REFERENCES temptest1) ON COMMIT DELETE ROWS" +== 058 +-- truncate_limit: 100 +INSERT INTO temptest1 VALUES (1) +-- +TABLE: name="temptest1" schema="" table="temptest1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temptest1 VALUES (1)" +== 059 +-- truncate_limit: 100 +INSERT INTO temptest2 VALUES (1) +-- +TABLE: name="temptest2" schema="" table="temptest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temptest2 VALUES (1)" +== 060 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 061 +-- truncate_limit: 100 +SELECT * FROM temptest1 +-- +TABLE: name="temptest1" schema="" table="temptest1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest1" +== 062 +-- truncate_limit: 100 +SELECT * FROM temptest2 +-- +TABLE: name="temptest2" schema="" table="temptest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temptest2" +== 063 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 064 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest3(col int PRIMARY KEY) ON COMMIT DELETE ROWS +-- +TABLE: name="temptest3" schema="" table="temptest3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest3 (col int PRIMARY KEY) ON COMMIT DELETE ROWS" +== 065 +-- truncate_limit: 100 +CREATE TEMP TABLE temptest4(col int REFERENCES temptest3) +-- +TABLE: name="temptest4" schema="" table="temptest4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest4 (col int REFERENCES temptest3)" +== 066 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 067 +-- truncate_limit: 100 +-- Test manipulation of temp schema's placement in search path + +create table public.whereami (f1 text) +-- +TABLE: name="public.whereami" schema="public" table="whereami" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE public.whereami (f1 text)" +== 068 +-- truncate_limit: 100 +insert into public.whereami values ('public') +-- +TABLE: name="public.whereami" schema="public" table="whereami" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO public.whereami VALUES ('public')" +== 069 +-- truncate_limit: 100 +create temp table whereami (f1 text) +-- +TABLE: name="whereami" schema="" table="whereami" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE whereami (f1 text)" +== 070 +-- truncate_limit: 100 +insert into whereami values ('temp') +-- +TABLE: name="whereami" schema="" table="whereami" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO whereami VALUES ('temp')" +== 071 +-- truncate_limit: 100 +create function public.whoami() returns text + as $$select 'public'::text$$ language sql +-- +FUNCTION: name="public.whoami" function="whoami" schema="public" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION public.whoami() RETURNS text AS $$select 'public'::text$$ LANGUAGE sql" +== 072 +-- truncate_limit: 100 +create function pg_temp.whoami() returns text + as $$select 'temp'::text$$ language sql +-- +FUNCTION: name="pg_temp.whoami" function="whoami" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION pg_temp.whoami() RETURNS text AS $$select 'temp'::text$$ LANGUAGE sql" +== 073 +-- truncate_limit: 100 +-- default should have pg_temp implicitly first, but only for tables +select * from whereami +-- +TABLE: name="whereami" schema="" table="whereami" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM whereami" +== 074 +-- truncate_limit: 100 +select whoami() +-- +FUNCTION: name="whoami" function="whoami" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT whoami()" +== 075 +-- truncate_limit: 100 +-- can list temp first explicitly, but it still doesn't affect functions +set search_path = pg_temp, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO pg_temp, public" +== 076 +-- truncate_limit: 100 +select * from whereami +-- +TABLE: name="whereami" schema="" table="whereami" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM whereami" +== 077 +-- truncate_limit: 100 +select whoami() +-- +FUNCTION: name="whoami" function="whoami" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT whoami()" +== 078 +-- truncate_limit: 100 +-- or put it last for security +set search_path = public, pg_temp +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO public, pg_temp" +== 079 +-- truncate_limit: 100 +select * from whereami +-- +TABLE: name="whereami" schema="" table="whereami" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM whereami" +== 080 +-- truncate_limit: 100 +select whoami() +-- +FUNCTION: name="whoami" function="whoami" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT whoami()" +== 081 +-- truncate_limit: 100 +-- you can invoke a temp function explicitly, though +select pg_temp.whoami() +-- +FUNCTION: name="pg_temp.whoami" function="whoami" schema="pg_temp" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_temp.whoami()" +== 082 +-- truncate_limit: 100 +drop table public.whereami +-- +TABLE: name="public.whereami" schema="public" table="whereami" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE public.whereami" +== 083 +-- truncate_limit: 100 +-- types in temp schema +set search_path = pg_temp, public +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO pg_temp, public" +== 084 +-- truncate_limit: 100 +create domain pg_temp.nonempty as text check (value <> '') +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN pg_temp.nonempty AS text CHECK (value <> '')" +== 085 +-- truncate_limit: 100 +-- function-syntax invocation of types matches rules for functions +select nonempty('') +-- +FUNCTION: name="nonempty" function="nonempty" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nonempty('')" +== 086 +-- truncate_limit: 100 +select pg_temp.nonempty('') +-- +FUNCTION: name="pg_temp.nonempty" function="nonempty" schema="pg_temp" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_temp.nonempty('')" +== 087 +-- truncate_limit: 100 +-- other syntax matches rules for tables +select ''::nonempty +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::nonempty" +== 088 +-- truncate_limit: 100 +reset search_path +-- +STMT: VariableSetStmt +TRUNCATED: "RESET search_path" +== 089 +-- truncate_limit: 100 +-- For partitioned temp tables, ON COMMIT actions ignore storage-less +-- partitioned tables. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 090 +-- truncate_limit: 100 +create temp table temp_parted_oncommit (a int) + partition by list (a) on commit delete rows +-- +TABLE: name="temp_parted_oncommit" schema="" table="temp_parted_oncommit" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted_oncommit (a int) PARTITION BY LIST (a) ON COMMIT DELETE ROWS" +== 091 +-- truncate_limit: 100 +create temp table temp_parted_oncommit_1 + partition of temp_parted_oncommit + for values in (1) on commit delete rows +-- +TABLE: name="temp_parted_oncommit_1" schema="" table="temp_parted_oncommit_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted_oncommit_1 PARTITION OF temp_parted_oncommit FOR VALUES IN (1)..." +== 092 +-- truncate_limit: 100 +insert into temp_parted_oncommit values (1) +-- +TABLE: name="temp_parted_oncommit" schema="" table="temp_parted_oncommit" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temp_parted_oncommit VALUES (1)" +== 093 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 094 +-- truncate_limit: 100 +-- partitions are emptied by the previous commit +select * from temp_parted_oncommit +-- +TABLE: name="temp_parted_oncommit" schema="" table="temp_parted_oncommit" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temp_parted_oncommit" +== 095 +-- truncate_limit: 100 +drop table temp_parted_oncommit +-- +TABLE: name="temp_parted_oncommit" schema="" table="temp_parted_oncommit" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_parted_oncommit" +== 096 +-- truncate_limit: 100 +-- Check dependencies between ON COMMIT actions with a partitioned +-- table and its partitions. Using ON COMMIT DROP on a parent removes +-- the whole set. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 097 +-- truncate_limit: 100 +create temp table temp_parted_oncommit_test (a int) + partition by list (a) on commit drop +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted_oncommit_test (a int) PARTITION BY LIST (a) ON COMMIT DROP" +== 098 +-- truncate_limit: 100 +create temp table temp_parted_oncommit_test1 + partition of temp_parted_oncommit_test + for values in (1) on commit delete rows +-- +TABLE: name="temp_parted_oncommit_test1" schema="" table="temp_parted_oncommit_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted_oncommit_test1 PARTITION OF temp_parted_oncommit_test FOR VALU..." +== 099 +-- truncate_limit: 100 +create temp table temp_parted_oncommit_test2 + partition of temp_parted_oncommit_test + for values in (2) on commit drop +-- +TABLE: name="temp_parted_oncommit_test2" schema="" table="temp_parted_oncommit_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted_oncommit_test2 PARTITION OF temp_parted_oncommit_test FOR VALU..." +== 100 +-- truncate_limit: 100 +insert into temp_parted_oncommit_test values (1), (2) +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temp_parted_oncommit_test VALUES (1), (2)" +== 101 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 102 +-- truncate_limit: 100 +-- no relations remain in this case. +select relname from pg_class where relname ~ '^temp_parted_oncommit_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ~ '^temp_parted_oncommit_test'" +== 103 +-- truncate_limit: 100 +-- Using ON COMMIT DELETE on a partitioned table does not remove +-- all rows if partitions preserve their data. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 104 +-- truncate_limit: 100 +create temp table temp_parted_oncommit_test (a int) + partition by list (a) on commit delete rows +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted_oncommit_test (a int) PARTITION BY LIST (a) ON COMMIT DELETE ROWS" +== 105 +-- truncate_limit: 100 +create temp table temp_parted_oncommit_test1 + partition of temp_parted_oncommit_test + for values in (1) on commit preserve rows +-- +TABLE: name="temp_parted_oncommit_test1" schema="" table="temp_parted_oncommit_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted_oncommit_test1 PARTITION OF temp_parted_oncommit_test FOR VALU..." +== 106 +-- truncate_limit: 100 +create temp table temp_parted_oncommit_test2 + partition of temp_parted_oncommit_test + for values in (2) on commit drop +-- +TABLE: name="temp_parted_oncommit_test2" schema="" table="temp_parted_oncommit_test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_parted_oncommit_test2 PARTITION OF temp_parted_oncommit_test FOR VALU..." +== 107 +-- truncate_limit: 100 +insert into temp_parted_oncommit_test values (1), (2) +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temp_parted_oncommit_test VALUES (1), (2)" +== 108 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 109 +-- truncate_limit: 100 +-- Data from the remaining partition is still here as its rows are +-- preserved. +select * from temp_parted_oncommit_test +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temp_parted_oncommit_test" +== 110 +-- truncate_limit: 100 +-- two relations remain in this case. +select relname from pg_class where relname ~ '^temp_parted_oncommit_test' + order by relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ~ '^temp_parted_oncommit_test' ORDER BY relname" +== 111 +-- truncate_limit: 100 +drop table temp_parted_oncommit_test +-- +TABLE: name="temp_parted_oncommit_test" schema="" table="temp_parted_oncommit_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_parted_oncommit_test" +== 112 +-- truncate_limit: 100 +-- Check dependencies between ON COMMIT actions with inheritance trees. +-- Using ON COMMIT DROP on a parent removes the whole set. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 113 +-- truncate_limit: 100 +create temp table temp_inh_oncommit_test (a int) on commit drop +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_inh_oncommit_test (a int) ON COMMIT DROP" +== 114 +-- truncate_limit: 100 +create temp table temp_inh_oncommit_test1 () + inherits(temp_inh_oncommit_test) on commit delete rows +-- +TABLE: name="temp_inh_oncommit_test1" schema="" table="temp_inh_oncommit_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_inh_oncommit_test1 () INHERITS (temp_inh_oncommit_test) ON COMMIT DEL..." +== 115 +-- truncate_limit: 100 +insert into temp_inh_oncommit_test1 values (1) +-- +TABLE: name="temp_inh_oncommit_test1" schema="" table="temp_inh_oncommit_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temp_inh_oncommit_test1 VALUES (1)" +== 116 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 117 +-- truncate_limit: 100 +-- no relations remain in this case +select relname from pg_class where relname ~ '^temp_inh_oncommit_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ~ '^temp_inh_oncommit_test'" +== 118 +-- truncate_limit: 100 +-- Data on the parent is removed, and the child goes away. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 119 +-- truncate_limit: 100 +create temp table temp_inh_oncommit_test (a int) on commit delete rows +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_inh_oncommit_test (a int) ON COMMIT DELETE ROWS" +== 120 +-- truncate_limit: 100 +create temp table temp_inh_oncommit_test1 () + inherits(temp_inh_oncommit_test) on commit drop +-- +TABLE: name="temp_inh_oncommit_test1" schema="" table="temp_inh_oncommit_test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temp_inh_oncommit_test1 () INHERITS (temp_inh_oncommit_test) ON COMMIT DROP" +== 121 +-- truncate_limit: 100 +insert into temp_inh_oncommit_test1 values (1) +-- +TABLE: name="temp_inh_oncommit_test1" schema="" table="temp_inh_oncommit_test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temp_inh_oncommit_test1 VALUES (1)" +== 122 +-- truncate_limit: 100 +insert into temp_inh_oncommit_test values (1) +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO temp_inh_oncommit_test VALUES (1)" +== 123 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 124 +-- truncate_limit: 100 +select * from temp_inh_oncommit_test +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM temp_inh_oncommit_test" +== 125 +-- truncate_limit: 100 +-- one relation remains +select relname from pg_class where relname ~ '^temp_inh_oncommit_test' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relname FROM pg_class WHERE relname ~ '^temp_inh_oncommit_test'" +== 126 +-- truncate_limit: 100 +drop table temp_inh_oncommit_test +-- +TABLE: name="temp_inh_oncommit_test" schema="" table="temp_inh_oncommit_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE temp_inh_oncommit_test" +== 127 +-- truncate_limit: 100 +-- Tests with two-phase commit +-- Transactions creating objects in a temporary namespace cannot be used +-- with two-phase commit. + +-- These cases generate errors about temporary namespace. +-- Function creation +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 128 +-- truncate_limit: 100 +create function pg_temp.twophase_func() returns void as + $$ select '2pc_func'::text $$ language sql +-- +FUNCTION: name="pg_temp.twophase_func" function="twophase_func" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION pg_temp.twophase_func() RETURNS void AS $$ select '2pc_func'::text $$ LANGUAGE sql" +== 129 +-- truncate_limit: 100 +prepare transaction 'twophase_func' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_func'" +== 130 +-- truncate_limit: 100 +-- Function drop +create function pg_temp.twophase_func() returns void as + $$ select '2pc_func'::text $$ language sql +-- +FUNCTION: name="pg_temp.twophase_func" function="twophase_func" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION pg_temp.twophase_func() RETURNS void AS $$ select '2pc_func'::text $$ LANGUAGE sql" +== 131 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 132 +-- truncate_limit: 100 +drop function pg_temp.twophase_func() +-- +FUNCTION: name="pg_temp.twophase_func" function="twophase_func" schema="pg_temp" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION pg_temp.twophase_func()" +== 133 +-- truncate_limit: 100 +prepare transaction 'twophase_func' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_func'" +== 134 +-- truncate_limit: 100 +-- Operator creation +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 135 +-- truncate_limit: 100 +create operator pg_temp.@@ (leftarg = int4, rightarg = int4, procedure = int4mi) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR pg_temp.@@ (leftarg = int4, rightarg = int4, procedure = int4mi)" +== 136 +-- truncate_limit: 100 +prepare transaction 'twophase_operator' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_operator'" +== 137 +-- truncate_limit: 100 +-- These generate errors about temporary tables. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 138 +-- truncate_limit: 100 +create type pg_temp.twophase_type as (a int) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE pg_temp.twophase_type AS (a int)" +== 139 +-- truncate_limit: 100 +prepare transaction 'twophase_type' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_type'" +== 140 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 141 +-- truncate_limit: 100 +create view pg_temp.twophase_view as select 1 +-- +TABLE: name="pg_temp.twophase_view" schema="pg_temp" table="twophase_view" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW pg_temp.twophase_view AS SELECT 1" +== 142 +-- truncate_limit: 100 +prepare transaction 'twophase_view' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_view'" +== 143 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 144 +-- truncate_limit: 100 +create sequence pg_temp.twophase_seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE pg_temp.twophase_seq" +== 145 +-- truncate_limit: 100 +prepare transaction 'twophase_sequence' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_sequence'" +== 146 +-- truncate_limit: 100 +-- Temporary tables cannot be used with two-phase commit. +create temp table twophase_tab (a int) +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE twophase_tab (a int)" +== 147 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 148 +-- truncate_limit: 100 +select a from twophase_tab +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a FROM twophase_tab" +== 149 +-- truncate_limit: 100 +prepare transaction 'twophase_tab' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_tab'" +== 150 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 151 +-- truncate_limit: 100 +insert into twophase_tab values (1) +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO twophase_tab VALUES (1)" +== 152 +-- truncate_limit: 100 +prepare transaction 'twophase_tab' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_tab'" +== 153 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 154 +-- truncate_limit: 100 +lock twophase_tab in access exclusive mode +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=DDL +STMT: LockStmt +TRUNCATED: "LOCK TABLE twophase_tab" +== 155 +-- truncate_limit: 100 +prepare transaction 'twophase_tab' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_tab'" +== 156 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 157 +-- truncate_limit: 100 +drop table twophase_tab +-- +TABLE: name="twophase_tab" schema="" table="twophase_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE twophase_tab" +== 158 +-- truncate_limit: 100 +prepare transaction 'twophase_tab' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_tab'" +== 159 +-- truncate_limit: 100 +-- Corner case: current_schema may create a temporary schema if namespace +-- creation is pending, so check after that. First reset the connection +-- to remove the temporary namespace. +SET search_path TO 'pg_temp' +-- +STMT: VariableSetStmt +TRUNCATED: "SET search_path TO pg_temp" +== 160 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 161 +-- truncate_limit: 100 +SELECT current_schema() ~ 'pg_temp' AS is_temp_schema +-- +FUNCTION: name="current_schema" function="current_schema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT \"current_schema\"() ~ 'pg_temp' AS is_temp_schema" +== 162 +-- truncate_limit: 100 +PREPARE TRANSACTION 'twophase_search' +-- +STMT: TransactionStmt +TRUNCATED: "PREPARE TRANSACTION 'twophase_search'" diff --git a/parser/testdata/summary_truncate/postgres_regress/test_setup.metadata.json b/parser/testdata/summary_truncate/postgres_regress/test_setup.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/test_setup.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/test_setup.test b/parser/testdata/summary_truncate/postgres_regress/test_setup.test new file mode 100644 index 0000000..656164e --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/test_setup.test @@ -0,0 +1,669 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TEST_SETUP --- prepare environment expected by regression test scripts +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +|-- +-- synchronous_commit=off delays when hint bits may be set. Some plans change +-- depending on the number of all-visible pages, which in turn can be +-- influenced by the delayed hint bits. Force synchronous_commit=on to avoid +-- that source of variability. +|-- +SET synchronous_commit = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET synchronous_commit TO ON" +== 002 +-- truncate_limit: 100 +|-- +-- Postgres formerly made the public schema read/write by default, +-- and most of the core regression tests still expect that. +|-- +GRANT ALL ON SCHEMA public TO public +-- +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON SCHEMA public TO public" +== 003 +-- truncate_limit: 100 +-- Create a tablespace we can use in tests. +SET allow_in_place_tablespaces = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET allow_in_place_tablespaces TO TRUE" +== 004 +-- truncate_limit: 100 +CREATE TABLESPACE regress_tblspace LOCATION '' +-- +STMT: CreateTableSpaceStmt +TRUNCATED: "CREATE TABLESPACE regress_tblspace LOCATION ''" +== 005 +-- truncate_limit: 100 +|-- +-- These tables have traditionally been referenced by many tests, +-- so create and populate them. Insert only non-error values here. +-- (Some subsequent tests try to insert erroneous values. That's okay +-- because the table won't actually change. Do not change the contents +-- of these tables in later tests, as it may affect other tests.) +|-- + +CREATE TABLE CHAR_TBL(f1 char(4)) +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE char_tbl (f1 char(4))" +== 006 +-- truncate_limit: 100 +INSERT INTO CHAR_TBL (f1) VALUES + ('a'), + ('ab'), + ('abcd'), + ('abcd ') +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO char_tbl (f1) VALUES ('a'), ('ab'), ('abcd'), ('abcd ')" +== 007 +-- truncate_limit: 100 +VACUUM CHAR_TBL +-- +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM char_tbl" +== 008 +-- truncate_limit: 100 +CREATE TABLE FLOAT8_TBL(f1 float8) +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE float8_tbl (f1 float8)" +== 009 +-- truncate_limit: 100 +INSERT INTO FLOAT8_TBL(f1) VALUES + ('0.0'), + ('-34.84'), + ('-1004.30'), + ('-1.2345678901234e+200'), + ('-1.2345678901234e-200') +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO float8_tbl (f1) VALUES (...)" +== 010 +-- truncate_limit: 100 +VACUUM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM float8_tbl" +== 011 +-- truncate_limit: 100 +CREATE TABLE INT2_TBL(f1 int2) +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE int2_tbl (f1 int2)" +== 012 +-- truncate_limit: 100 +INSERT INTO INT2_TBL(f1) VALUES + ('0 '), + (' 1234 '), + (' -1234'), + ('32767'), -- largest and smallest values + ('-32767') +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int2_tbl (f1) VALUES ('0 '), (' 1234 '), (' -1234'), ('32767'), ('-32767')" +== 013 +-- truncate_limit: 100 +VACUUM INT2_TBL +-- +TABLE: name="int2_tbl" schema="" table="int2_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM int2_tbl" +== 014 +-- truncate_limit: 100 +CREATE TABLE INT4_TBL(f1 int4) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE int4_tbl (f1 int4)" +== 015 +-- truncate_limit: 100 +INSERT INTO INT4_TBL(f1) VALUES + (' 0 '), + ('123456 '), + (' -123456'), + ('2147483647'), -- largest and smallest values + ('-2147483647') +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int4_tbl (f1) VALUES (...)" +== 016 +-- truncate_limit: 100 +VACUUM INT4_TBL +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM int4_tbl" +== 017 +-- truncate_limit: 100 +CREATE TABLE INT8_TBL(q1 int8, q2 int8) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE int8_tbl (q1 int8, q2 int8)" +== 018 +-- truncate_limit: 100 +INSERT INTO INT8_TBL VALUES + (' 123 ',' 456'), + ('123 ','4567890123456789'), + ('4567890123456789','123'), + (+4567890123456789,'4567890123456789'), + ('+4567890123456789','-4567890123456789') +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO int8_tbl VALUES (...)" +== 019 +-- truncate_limit: 100 +VACUUM INT8_TBL +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM int8_tbl" +== 020 +-- truncate_limit: 100 +CREATE TABLE POINT_TBL(f1 point) +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE point_tbl (f1 point)" +== 021 +-- truncate_limit: 100 +INSERT INTO POINT_TBL(f1) VALUES + ('(0.0,0.0)'), + ('(-10.0,0.0)'), + ('(-3.0,4.0)'), + ('(5.1, 34.5)'), + ('(-5.0,-12.0)'), + ('(1e-300,-1e-300)'), -- To underflow + ('(1e+300,Inf)'), -- To overflow + ('(Inf,1e+300)'), -- Transposed + (' ( Nan , NaN ) '), + ('10.0,10.0') +-- +TABLE: name="point_tbl" schema="" table="point_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO point_tbl (f1) VALUES (...)" +== 022 +-- truncate_limit: 100 +-- We intentionally don't vacuum point_tbl here; geometry depends on that + +CREATE TABLE TEXT_TBL (f1 text) +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE text_tbl (f1 text)" +== 023 +-- truncate_limit: 100 +INSERT INTO TEXT_TBL VALUES + ('doh!'), + ('hi de ho neighbor') +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO text_tbl VALUES ('doh!'), ('hi de ho neighbor')" +== 024 +-- truncate_limit: 100 +VACUUM TEXT_TBL +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM text_tbl" +== 025 +-- truncate_limit: 100 +CREATE TABLE VARCHAR_TBL(f1 varchar(4)) +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE varchar_tbl (f1 varchar(4))" +== 026 +-- truncate_limit: 100 +INSERT INTO VARCHAR_TBL (f1) VALUES + ('a'), + ('ab'), + ('abcd'), + ('abcd ') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('a'), ('ab'), ('abcd'), ('abcd ')" +== 027 +-- truncate_limit: 100 +VACUUM VARCHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM varchar_tbl" +== 028 +-- truncate_limit: 100 +CREATE TABLE onek ( + unique1 int4, + unique2 int4, + two int4, + four int4, + ten int4, + twenty int4, + hundred int4, + thousand int4, + twothousand int4, + fivethous int4, + tenthous int4, + odd int4, + even int4, + stringu1 name, + stringu2 name, + string4 name +) +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE onek (unique1 int4, unique2 int4, two int4, four int4, ten int4, twenty int4, hundre..." +== 029 +-- truncate_limit: 100 +COPY onek FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 030 +-- truncate_limit: 100 +VACUUM ANALYZE onek +-- +TABLE: name="onek" schema="" table="onek" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) onek" +== 031 +-- truncate_limit: 100 +CREATE TABLE onek2 AS SELECT * FROM onek +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +TABLE: name="onek" schema="" table="onek" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE onek2 AS SELECT * FROM onek" +== 032 +-- truncate_limit: 100 +VACUUM ANALYZE onek2 +-- +TABLE: name="onek2" schema="" table="onek2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) onek2" +== 033 +-- truncate_limit: 100 +CREATE TABLE tenk1 ( + unique1 int4, + unique2 int4, + two int4, + four int4, + ten int4, + twenty int4, + hundred int4, + thousand int4, + twothousand int4, + fivethous int4, + tenthous int4, + odd int4, + even int4, + stringu1 name, + stringu2 name, + string4 name +) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tenk1 (unique1 int4, unique2 int4, two int4, four int4, ten int4, twenty int4, hundr..." +== 034 +-- truncate_limit: 100 +COPY tenk1 FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 17 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 035 +-- truncate_limit: 100 +VACUUM ANALYZE tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) tenk1" +== 036 +-- truncate_limit: 100 +CREATE TABLE tenk2 AS SELECT * FROM tenk1 +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE tenk2 AS SELECT * FROM tenk1" +== 037 +-- truncate_limit: 100 +VACUUM ANALYZE tenk2 +-- +TABLE: name="tenk2" schema="" table="tenk2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) tenk2" +== 038 +-- truncate_limit: 100 +CREATE TABLE person ( + name text, + age int4, + location point +) +-- +TABLE: name="person" schema="" table="person" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE person (name text, age int4, location point)" +== 039 +-- truncate_limit: 100 +COPY person FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 18 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 040 +-- truncate_limit: 100 +VACUUM ANALYZE person +-- +TABLE: name="person" schema="" table="person" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) person" +== 041 +-- truncate_limit: 100 +CREATE TABLE emp ( + salary int4, + manager name +) INHERITS (person) +-- +TABLE: name="emp" schema="" table="emp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE emp (salary int4, manager name) INHERITS (person)" +== 042 +-- truncate_limit: 100 +COPY emp FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 15 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 043 +-- truncate_limit: 100 +VACUUM ANALYZE emp +-- +TABLE: name="emp" schema="" table="emp" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) emp" +== 044 +-- truncate_limit: 100 +CREATE TABLE student ( + gpa float8 +) INHERITS (person) +-- +TABLE: name="student" schema="" table="student" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE student (gpa float8) INHERITS (person)" +== 045 +-- truncate_limit: 100 +COPY student FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 046 +-- truncate_limit: 100 +VACUUM ANALYZE student +-- +TABLE: name="student" schema="" table="student" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) student" +== 047 +-- truncate_limit: 100 +CREATE TABLE stud_emp ( + percent int4 +) INHERITS (emp, student) +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stud_emp (percent int4) INHERITS (emp, student)" +== 048 +-- truncate_limit: 100 +COPY stud_emp FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 049 +-- truncate_limit: 100 +VACUUM ANALYZE stud_emp +-- +TABLE: name="stud_emp" schema="" table="stud_emp" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) stud_emp" +== 050 +-- truncate_limit: 100 +CREATE TABLE road ( + name text, + thepath path +) +-- +TABLE: name="road" schema="" table="road" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE road (name text, thepath path)" +== 051 +-- truncate_limit: 100 +COPY road FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 16 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 052 +-- truncate_limit: 100 +VACUUM ANALYZE road +-- +TABLE: name="road" schema="" table="road" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) road" +== 053 +-- truncate_limit: 100 +CREATE TABLE ihighway () INHERITS (road) +-- +TABLE: name="ihighway" schema="" table="ihighway" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ihighway () INHERITS (road)" +== 054 +-- truncate_limit: 100 +INSERT INTO ihighway + SELECT * + FROM ONLY road + WHERE name ~ 'I- .*' +-- +TABLE: name="ihighway" schema="" table="ihighway" ctx=DML +TABLE: name="road" schema="" table="road" ctx=Select +FILTER: schema="" table="" column="name" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ihighway SELECT * FROM ONLY road WHERE name ~ 'I- .*'" +== 055 +-- truncate_limit: 100 +VACUUM ANALYZE ihighway +-- +TABLE: name="ihighway" schema="" table="ihighway" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) ihighway" +== 056 +-- truncate_limit: 100 +CREATE TABLE shighway ( + surface text +) INHERITS (road) +-- +TABLE: name="shighway" schema="" table="shighway" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE shighway (surface text) INHERITS (road)" +== 057 +-- truncate_limit: 100 +INSERT INTO shighway + SELECT *, 'asphalt' + FROM ONLY road + WHERE name ~ 'State Hwy.*' +-- +TABLE: name="shighway" schema="" table="shighway" ctx=DML +TABLE: name="road" schema="" table="road" ctx=Select +FILTER: schema="" table="" column="name" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO shighway SELECT *, 'asphalt' FROM ONLY road WHERE name ~ 'State Hwy.*'" +== 058 +-- truncate_limit: 100 +VACUUM ANALYZE shighway +-- +TABLE: name="shighway" schema="" table="shighway" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) shighway" +== 059 +-- truncate_limit: 100 +|-- +-- We must have some enum type in the database for opr_sanity and type_sanity. +|-- + +create type stoplight as enum ('red', 'yellow', 'green') +-- +STMT: CreateEnumStmt +TRUNCATED: "CREATE TYPE stoplight AS ENUM ('red', 'yellow', 'green')" +== 060 +-- truncate_limit: 100 +|-- +-- Also create some non-built-in range types. +|-- + +create type float8range as range (subtype = float8, subtype_diff = float8mi) +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE float8range AS RANGE (subtype = float8, subtype_diff = float8mi)" +== 061 +-- truncate_limit: 100 +create type textrange as range (subtype = text, collation = "C") +-- +STMT: CreateRangeStmt +TRUNCATED: "CREATE TYPE textrange AS RANGE (subtype = text, \"collation\" = \"C\")" +== 062 +-- truncate_limit: 100 +|-- +-- Create some C functions that will be used by various tests. +|-- + +CREATE FUNCTION binary_coercible(oid, oid) + RETURNS bool + AS :'regresslib', 'binary_coercible' + LANGUAGE C STRICT STABLE PARALLEL SAFE +-- +ERROR: syntax error at or near ":" +CURSORPOS: 138 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 063 +-- truncate_limit: 100 +CREATE FUNCTION ttdummy () + RETURNS trigger + AS :'regresslib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 55 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 064 +-- truncate_limit: 100 +-- Use hand-rolled hash functions and operator classes to get predictable +-- result on different machines. The hash function for int4 simply returns +-- the sum of the values passed to it and the one for text returns the length +-- of the non-empty string value passed to it or 0. + +create function part_hashint4_noop(value int4, seed int8) + returns int8 as $$ + select value + seed; + $$ language sql strict immutable parallel safe +-- +FUNCTION: name="part_hashint4_noop" function="part_hashint4_noop" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION part_hashint4_noop(value int4, seed int8) RETURNS int8 AS $$\n select value + s..." +== 065 +-- truncate_limit: 100 +create operator class part_test_int4_ops for type int4 using hash as + operator 1 =, + function 2 part_hashint4_noop(int4, int8) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS part_test_int4_ops FOR TYPE int4 USING hash AS OPERATOR 1 =, FUNCTION 2 par..." +== 066 +-- truncate_limit: 100 +create function part_hashtext_length(value text, seed int8) + returns int8 as $$ + select length(coalesce(value, ''))::int8 + $$ language sql strict immutable parallel safe +-- +FUNCTION: name="part_hashtext_length" function="part_hashtext_length" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION part_hashtext_length(value text, seed int8) RETURNS int8 AS $$\n select length(..." +== 067 +-- truncate_limit: 100 +create operator class part_test_text_ops for type text using hash as + operator 1 =, + function 2 part_hashtext_length(text, int8) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS part_test_text_ops FOR TYPE text USING hash AS OPERATOR 1 =, FUNCTION 2 par..." +== 068 +-- truncate_limit: 100 +|-- +-- These functions are used in tests that used to use md5(), which we now +-- mostly avoid so that the tests will pass in FIPS mode. +|-- + +create function fipshash(bytea) + returns text + strict immutable parallel safe leakproof + return substr(encode(sha256($1), 'hex'), 1, 32) +-- +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fipshash(bytea) RETURNS text RETURNS NULL ON NULL INPUT IMMUTABLE PARALLEL safe L..." +== 069 +-- truncate_limit: 100 +create function fipshash(text) + returns text + strict immutable parallel safe leakproof + return substr(encode(sha256($1::bytea), 'hex'), 1, 32) +-- +FUNCTION: name="fipshash" function="fipshash" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION fipshash(text) RETURNS text RETURNS NULL ON NULL INPUT IMMUTABLE PARALLEL safe LE..." diff --git a/parser/testdata/summary_truncate/postgres_regress/text.metadata.json b/parser/testdata/summary_truncate/postgres_regress/text.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/text.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/text.test b/parser/testdata/summary_truncate/postgres_regress/text.test new file mode 100644 index 0000000..b4975d7 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/text.test @@ -0,0 +1,547 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TEXT +|-- + +SELECT text 'this is a text string' = text 'this is a text string' AS true +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'this is a text string'::text = 'this is a text string'::text AS \"true\"" +== 002 +-- truncate_limit: 100 +SELECT text 'this is a text string' = text 'this is a text strin' AS false +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'this is a text string'::text = 'this is a text strin'::text AS \"false\"" +== 003 +-- truncate_limit: 100 +-- text_tbl was already created and filled in test_setup.sql. +SELECT * FROM TEXT_TBL +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM text_tbl" +== 004 +-- truncate_limit: 100 +-- As of 8.3 we have removed most implicit casts to text, so that for example +-- this no longer works: + +select length(42) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(42)" +== 005 +-- truncate_limit: 100 +-- But as a special exception for usability's sake, we still allow implicit +-- casting to text in concatenations, so long as the other input is text or +-- an unknown literal. So these work: + +select 'four: '::text || 2+2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'four: '::text || (2 + 2)" +== 006 +-- truncate_limit: 100 +select 'four: ' || 2+2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'four: ' || (2 + 2)" +== 007 +-- truncate_limit: 100 +-- but not this: + +select 3 || 4.0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 3 || 4.0" +== 008 +-- truncate_limit: 100 +/* + * various string functions + */ +select concat('one') +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat('one')" +== 009 +-- truncate_limit: 100 +select concat(1,2,3,'hello',true, false, to_date('20100309','YYYYMMDD')) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat(1, 2, 3, 'hello', true, false, to_date('20100309', 'YYYYMMDD'))" +== 010 +-- truncate_limit: 100 +select concat_ws('#','one') +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat_ws('#', 'one')" +== 011 +-- truncate_limit: 100 +select concat_ws('#',1,2,3,'hello',true, false, to_date('20100309','YYYYMMDD')) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +FUNCTION: name="to_date" function="to_date" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat_ws('#', 1, 2, 3, 'hello', true, false, to_date('20100309', 'YYYYMMDD'))" +== 012 +-- truncate_limit: 100 +select concat_ws(',',10,20,null,30) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat_ws(',', 10, 20, NULL, 30)" +== 013 +-- truncate_limit: 100 +select concat_ws('',10,20,null,30) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat_ws('', 10, 20, NULL, 30)" +== 014 +-- truncate_limit: 100 +select concat_ws(NULL,10,20,null,30) is null +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat_ws(NULL, 10, 20, NULL, 30) IS NULL" +== 015 +-- truncate_limit: 100 +select reverse('abcde') +-- +FUNCTION: name="reverse" function="reverse" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT reverse('abcde')" +== 016 +-- truncate_limit: 100 +select i, left('ahoj', i), right('ahoj', i) from generate_series(-5, 5) t(i) order by i +-- +FUNCTION: name="left" function="left" schema="" ctx=Call +FUNCTION: name="right" function="right" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT i, \"left\"('ahoj', i), \"right\"('ahoj', i) FROM generate_series(-5, 5) t(i) ORDER BY i" +== 017 +-- truncate_limit: 100 +select quote_literal('') +-- +FUNCTION: name="quote_literal" function="quote_literal" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT quote_literal('')" +== 018 +-- truncate_limit: 100 +select quote_literal('abc''') +-- +FUNCTION: name="quote_literal" function="quote_literal" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT quote_literal('abc''')" +== 019 +-- truncate_limit: 100 +select quote_literal(e'\\') +-- +FUNCTION: name="quote_literal" function="quote_literal" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT quote_literal(E'\\\\')" +== 020 +-- truncate_limit: 100 +-- check variadic labeled argument +select concat(variadic array[1,2,3]) +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat(VARIADIC ARRAY[1, 2, 3])" +== 021 +-- truncate_limit: 100 +select concat_ws(',', variadic array[1,2,3]) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat_ws(',', VARIADIC ARRAY[1, 2, 3])" +== 022 +-- truncate_limit: 100 +select concat_ws(',', variadic NULL::int[]) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat_ws(',', VARIADIC NULL::int[])" +== 023 +-- truncate_limit: 100 +select concat(variadic NULL::int[]) is NULL +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat(VARIADIC NULL::int[]) IS NULL" +== 024 +-- truncate_limit: 100 +select concat(variadic '{}'::int[]) = '' +-- +FUNCTION: name="concat" function="concat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat(VARIADIC '{}'::int[]) = ''" +== 025 +-- truncate_limit: 100 +--should fail +select concat_ws(',', variadic 10) +-- +FUNCTION: name="concat_ws" function="concat_ws" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT concat_ws(',', VARIADIC 10)" +== 026 +-- truncate_limit: 100 +/* + * format + */ +select format(NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format(NULL)" +== 027 +-- truncate_limit: 100 +select format('Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello')" +== 028 +-- truncate_limit: 100 +select format('Hello %s', 'World') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello %s', 'World')" +== 029 +-- truncate_limit: 100 +select format('Hello %%') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello %%')" +== 030 +-- truncate_limit: 100 +select format('Hello %%%%') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello %%%%')" +== 031 +-- truncate_limit: 100 +-- should fail +select format('Hello %s %s', 'World') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello %s %s', 'World')" +== 032 +-- truncate_limit: 100 +select format('Hello %s') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello %s')" +== 033 +-- truncate_limit: 100 +select format('Hello %x', 20) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello %x', 20)" +== 034 +-- truncate_limit: 100 +-- check literal and sql identifiers +select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('INSERT INTO %I VALUES(%L,%L)', 'mytab', 10, 'Hello')" +== 035 +-- truncate_limit: 100 +select format('%s%s%s','Hello', NULL,'World') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%s%s%s', 'Hello', NULL, 'World')" +== 036 +-- truncate_limit: 100 +select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', 10, NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('INSERT INTO %I VALUES(%L,%L)', 'mytab', 10, NULL)" +== 037 +-- truncate_limit: 100 +select format('INSERT INTO %I VALUES(%L,%L)', 'mytab', NULL, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('INSERT INTO %I VALUES(%L,%L)', 'mytab', NULL, 'Hello')" +== 038 +-- truncate_limit: 100 +-- should fail, sql identifier cannot be NULL +select format('INSERT INTO %I VALUES(%L,%L)', NULL, 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('INSERT INTO %I VALUES(%L,%L)', NULL, 10, 'Hello')" +== 039 +-- truncate_limit: 100 +-- check positional placeholders +select format('%1$s %3$s', 1, 2, 3) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%1$s %3$s', 1, 2, 3)" +== 040 +-- truncate_limit: 100 +select format('%1$s %12$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%1$s %12$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)" +== 041 +-- truncate_limit: 100 +-- should fail +select format('%1$s %4$s', 1, 2, 3) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%1$s %4$s', 1, 2, 3)" +== 042 +-- truncate_limit: 100 +select format('%1$s %13$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%1$s %13$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)" +== 043 +-- truncate_limit: 100 +select format('%0$s', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%0$s', 'Hello')" +== 044 +-- truncate_limit: 100 +select format('%*0$s', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%*0$s', 'Hello')" +== 045 +-- truncate_limit: 100 +select format('%1$', 1) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%1$', 1)" +== 046 +-- truncate_limit: 100 +select format('%1$1', 1) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%1$1', 1)" +== 047 +-- truncate_limit: 100 +-- check mix of positional and ordered placeholders +select format('Hello %s %1$s %s', 'World', 'Hello again') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello %s %1$s %s', 'World', 'Hello again')" +== 048 +-- truncate_limit: 100 +select format('Hello %s %s, %2$s %2$s', 'World', 'Hello again') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello %s %s, %2$s %2$s', 'World', 'Hello again')" +== 049 +-- truncate_limit: 100 +-- check variadic labeled arguments +select format('%s, %s', variadic array['Hello','World']) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%s, %s', VARIADIC ARRAY['Hello', 'World'])" +== 050 +-- truncate_limit: 100 +select format('%s, %s', variadic array[1, 2]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%s, %s', VARIADIC ARRAY[1, 2])" +== 051 +-- truncate_limit: 100 +select format('%s, %s', variadic array[true, false]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%s, %s', VARIADIC ARRAY[true, false])" +== 052 +-- truncate_limit: 100 +select format('%s, %s', variadic array[true, false]::text[]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%s, %s', VARIADIC ARRAY[true, false]::text[])" +== 053 +-- truncate_limit: 100 +-- check variadic with positional placeholders +select format('%2$s, %1$s', variadic array['first', 'second']) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%2$s, %1$s', VARIADIC ARRAY['first', 'second'])" +== 054 +-- truncate_limit: 100 +select format('%2$s, %1$s', variadic array[1, 2]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('%2$s, %1$s', VARIADIC ARRAY[1, 2])" +== 055 +-- truncate_limit: 100 +-- variadic argument can be array type NULL, but should not be referenced +select format('Hello', variadic NULL::int[]) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('Hello', VARIADIC NULL::int[])" +== 056 +-- truncate_limit: 100 +-- variadic argument allows simulating more than FUNC_MAX_ARGS parameters +select format(string_agg('%s',','), variadic array_agg(i)) +from generate_series(1,200) g(i) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +FUNCTION: name="string_agg" function="string_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format(string_agg('%s', ','), VARIADIC array_agg(i)) FROM generate_series(1, 200) g(i)" +== 057 +-- truncate_limit: 100 +-- check field widths and left, right alignment +select format('>>%10s<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%10s<<', 'Hello')" +== 058 +-- truncate_limit: 100 +select format('>>%10s<<', NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%10s<<', NULL)" +== 059 +-- truncate_limit: 100 +select format('>>%10s<<', '') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%10s<<', '')" +== 060 +-- truncate_limit: 100 +select format('>>%-10s<<', '') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%-10s<<', '')" +== 061 +-- truncate_limit: 100 +select format('>>%-10s<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%-10s<<', 'Hello')" +== 062 +-- truncate_limit: 100 +select format('>>%-10s<<', NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%-10s<<', NULL)" +== 063 +-- truncate_limit: 100 +select format('>>%1$10s<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%1$10s<<', 'Hello')" +== 064 +-- truncate_limit: 100 +select format('>>%1$-10I<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%1$-10I<<', 'Hello')" +== 065 +-- truncate_limit: 100 +select format('>>%2$*1$L<<', 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%2$*1$L<<', 10, 'Hello')" +== 066 +-- truncate_limit: 100 +select format('>>%2$*1$L<<', 10, NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%2$*1$L<<', 10, NULL)" +== 067 +-- truncate_limit: 100 +select format('>>%2$*1$L<<', -10, NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%2$*1$L<<', -10, NULL)" +== 068 +-- truncate_limit: 100 +select format('>>%*s<<', 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%*s<<', 10, 'Hello')" +== 069 +-- truncate_limit: 100 +select format('>>%*1$s<<', 10, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%*1$s<<', 10, 'Hello')" +== 070 +-- truncate_limit: 100 +select format('>>%-s<<', 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%-s<<', 'Hello')" +== 071 +-- truncate_limit: 100 +select format('>>%10L<<', NULL) +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%10L<<', NULL)" +== 072 +-- truncate_limit: 100 +select format('>>%2$*1$L<<', NULL, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%2$*1$L<<', NULL, 'Hello')" +== 073 +-- truncate_limit: 100 +select format('>>%2$*1$L<<', 0, 'Hello') +-- +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT format('>>%2$*1$L<<', 0, 'Hello')" diff --git a/parser/testdata/summary_truncate/postgres_regress/tid.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tid.test b/parser/testdata/summary_truncate/postgres_regress/tid.test new file mode 100644 index 0000000..359a8d8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tid.test @@ -0,0 +1,321 @@ +== 001 +-- truncate_limit: 100 +-- basic tests for the TID data type + +SELECT + '(0,0)'::tid as tid00, + '(0,1)'::tid as tid01, + '(-1,0)'::tid as tidm10, + '(4294967295,65535)'::tid as tidmax +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 002 +-- truncate_limit: 100 +SELECT '(4294967296,1)'::tid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(4294967296,1)'::tid" +== 003 +-- truncate_limit: 100 +-- error +SELECT '(1,65536)'::tid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1,65536)'::tid" +== 004 +-- truncate_limit: 100 +-- error + +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('(0)', 'tid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(0)', 'tid')" +== 005 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('(0)', 'tid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(0)', 'tid')" +== 006 +-- truncate_limit: 100 +SELECT pg_input_is_valid('(0,-1)', 'tid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('(0,-1)', 'tid')" +== 007 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('(0,-1)', 'tid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('(0,-1)', 'tid')" +== 008 +-- truncate_limit: 100 +-- tests for functions related to TID handling + +CREATE TABLE tid_tab (a int) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tid_tab (a int)" +== 009 +-- truncate_limit: 100 +-- min() and max() for TIDs +INSERT INTO tid_tab VALUES (1), (2) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tid_tab VALUES (1), (2)" +== 010 +-- truncate_limit: 100 +SELECT min(ctid) FROM tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(ctid) FROM tid_tab" +== 011 +-- truncate_limit: 100 +SELECT max(ctid) FROM tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT max(ctid) FROM tid_tab" +== 012 +-- truncate_limit: 100 +TRUNCATE tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE tid_tab" +== 013 +-- truncate_limit: 100 +-- Tests for currtid2() with various relation kinds + +-- Materialized view +CREATE MATERIALIZED VIEW tid_matview AS SELECT a FROM tid_tab +-- +TABLE: name="tid_matview" schema="" table="tid_matview" ctx=DDL +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW tid_matview AS SELECT a FROM tid_tab" +== 014 +-- truncate_limit: 100 +SELECT currtid2('tid_matview'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_matview'::text, '(0,1)'::tid)" +== 015 +-- truncate_limit: 100 +-- fails +INSERT INTO tid_tab VALUES (1) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tid_tab VALUES (1)" +== 016 +-- truncate_limit: 100 +REFRESH MATERIALIZED VIEW tid_matview +-- +TABLE: name="tid_matview" schema="" table="tid_matview" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW tid_matview" +== 017 +-- truncate_limit: 100 +SELECT currtid2('tid_matview'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_matview'::text, '(0,1)'::tid)" +== 018 +-- truncate_limit: 100 +-- ok +DROP MATERIALIZED VIEW tid_matview +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW tid_matview" +== 019 +-- truncate_limit: 100 +TRUNCATE tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE tid_tab" +== 020 +-- truncate_limit: 100 +-- Sequence +CREATE SEQUENCE tid_seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE tid_seq" +== 021 +-- truncate_limit: 100 +SELECT currtid2('tid_seq'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_seq'::text, '(0,1)'::tid)" +== 022 +-- truncate_limit: 100 +-- ok +DROP SEQUENCE tid_seq +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE tid_seq" +== 023 +-- truncate_limit: 100 +-- Index, fails with incorrect relation type +CREATE INDEX tid_ind ON tid_tab(a) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tid_ind ON tid_tab USING btree (a)" +== 024 +-- truncate_limit: 100 +SELECT currtid2('tid_ind'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_ind'::text, '(0,1)'::tid)" +== 025 +-- truncate_limit: 100 +-- fails +DROP INDEX tid_ind +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX tid_ind" +== 026 +-- truncate_limit: 100 +-- Partitioned table, no storage +CREATE TABLE tid_part (a int) PARTITION BY RANGE (a) +-- +TABLE: name="tid_part" schema="" table="tid_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tid_part (a int) PARTITION BY RANGE (a)" +== 027 +-- truncate_limit: 100 +SELECT currtid2('tid_part'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_part'::text, '(0,1)'::tid)" +== 028 +-- truncate_limit: 100 +-- fails +DROP TABLE tid_part +-- +TABLE: name="tid_part" schema="" table="tid_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tid_part" +== 029 +-- truncate_limit: 100 +-- Views +-- ctid not defined in the view +CREATE VIEW tid_view_no_ctid AS SELECT a FROM tid_tab +-- +TABLE: name="tid_view_no_ctid" schema="" table="tid_view_no_ctid" ctx=DDL +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tid_view_no_ctid AS SELECT a FROM tid_tab" +== 030 +-- truncate_limit: 100 +SELECT currtid2('tid_view_no_ctid'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_view_no_ctid'::text, '(0,1)'::tid)" +== 031 +-- truncate_limit: 100 +-- fails +DROP VIEW tid_view_no_ctid +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW tid_view_no_ctid" +== 032 +-- truncate_limit: 100 +-- ctid fetched directly from the source table. +CREATE VIEW tid_view_with_ctid AS SELECT ctid, a FROM tid_tab +-- +TABLE: name="tid_view_with_ctid" schema="" table="tid_view_with_ctid" ctx=DDL +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tid_view_with_ctid AS SELECT ctid, a FROM tid_tab" +== 033 +-- truncate_limit: 100 +SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid)" +== 034 +-- truncate_limit: 100 +-- fails +INSERT INTO tid_tab VALUES (1) +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tid_tab VALUES (1)" +== 035 +-- truncate_limit: 100 +SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_view_with_ctid'::text, '(0,1)'::tid)" +== 036 +-- truncate_limit: 100 +-- ok +DROP VIEW tid_view_with_ctid +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW tid_view_with_ctid" +== 037 +-- truncate_limit: 100 +TRUNCATE tid_tab +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE tid_tab" +== 038 +-- truncate_limit: 100 +-- ctid attribute with incorrect data type +CREATE VIEW tid_view_fake_ctid AS SELECT 1 AS ctid, 2 AS a +-- +TABLE: name="tid_view_fake_ctid" schema="" table="tid_view_fake_ctid" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW tid_view_fake_ctid AS SELECT 1 AS ctid, 2 AS a" +== 039 +-- truncate_limit: 100 +SELECT currtid2('tid_view_fake_ctid'::text, '(0,1)'::tid) +-- +FUNCTION: name="currtid2" function="currtid2" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT currtid2('tid_view_fake_ctid'::text, '(0,1)'::tid)" +== 040 +-- truncate_limit: 100 +-- fails +DROP VIEW tid_view_fake_ctid +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW tid_view_fake_ctid" +== 041 +-- truncate_limit: 100 +DROP TABLE tid_tab CASCADE +-- +TABLE: name="tid_tab" schema="" table="tid_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tid_tab CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/tidrangescan.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tidrangescan.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tidrangescan.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tidrangescan.test b/parser/testdata/summary_truncate/postgres_regress/tidrangescan.test new file mode 100644 index 0000000..ed4c449 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tidrangescan.test @@ -0,0 +1,402 @@ +== 001 +-- truncate_limit: 100 +-- tests for tidrangescans + +SET enable_seqscan TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 002 +-- truncate_limit: 100 +CREATE TABLE tidrangescan(id integer, data text) +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tidrangescan (id int, data text)" +== 003 +-- truncate_limit: 100 +-- empty table +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid < '(1, 0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid < '(1, 0)'" +== 004 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid < '(1, 0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid < '(1, 0)'" +== 005 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid > '(9, 0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid > '(9, 0)'" +== 006 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid > '(9, 0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid > '(9, 0)'" +== 007 +-- truncate_limit: 100 +-- insert enough tuples to fill at least two pages +INSERT INTO tidrangescan SELECT i,repeat('x', 100) FROM generate_series(1,200) AS s(i) +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tidrangescan SELECT i, repeat('x', 100) FROM generate_series(1, 200) s(i)" +== 008 +-- truncate_limit: 100 +-- remove all tuples after the 10th tuple on each page. Trying to ensure +-- we get the same layout with all CPU architectures and smaller than standard +-- page sizes. +DELETE FROM tidrangescan +WHERE substring(ctid::text FROM ',(\d+)\)')::integer > 10 OR substring(ctid::text FROM '\((\d+),')::integer > 2 +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DML +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.substring" function="substring" schema="pg_catalog" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tidrangescan WHERE ..." +== 009 +-- truncate_limit: 100 +VACUUM tidrangescan +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM tidrangescan" +== 010 +-- truncate_limit: 100 +-- range scans with upper bound +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)'" +== 011 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)'" +== 012 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid <= '(1,5)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid <= '(1,5)'" +== 013 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid <= '(1,5)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid <= '(1,5)'" +== 014 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)'" +== 015 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)'" +== 016 +-- truncate_limit: 100 +-- range scans with lower bound +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid > '(2,8)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid > '(2,8)'" +== 017 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid > '(2,8)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid > '(2,8)'" +== 018 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE '(2,8)' < ctid +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE '(2,8)' < ctid" +== 019 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE '(2,8)' < ctid +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE '(2,8)' < ctid" +== 020 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid >= '(2,8)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid >= '(2,8)'" +== 021 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid >= '(2,8)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid >= '(2,8)'" +== 022 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid >= '(100,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid >= '(100,0)'" +== 023 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid >= '(100,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid >= '(100,0)'" +== 024 +-- truncate_limit: 100 +-- range scans with both bounds +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE ctid > '(1,4)' AND '(1,7)' >= ctid +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE ctid > '(1,4)' AND '(1,7)' >= ctid" +== 025 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid > '(1,4)' AND '(1,7)' >= ctid +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid > '(1,4)' AND '(1,7)' >= ctid" +== 026 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT ctid FROM tidrangescan WHERE '(1,7)' >= ctid AND ctid > '(1,4)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid FROM tidrangescan WHERE '(1,7)' >= ctid AND ctid > '(1,4)'" +== 027 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE '(1,7)' >= ctid AND ctid > '(1,4)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE '(1,7)' >= ctid AND ctid > '(1,4)'" +== 028 +-- truncate_limit: 100 +-- extreme offsets +SELECT ctid FROM tidrangescan WHERE ctid > '(0,65535)' AND ctid < '(1,0)' LIMIT 1 +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid > '(0,65535)' AND ctid < '(1,0)' LIMIT 1" +== 029 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' LIMIT 1 +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' LIMIT 1" +== 030 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid > '(4294967295,65535)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid > '(4294967295,65535)'" +== 031 +-- truncate_limit: 100 +SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid < '(0,0)'" +== 032 +-- truncate_limit: 100 +-- NULLs in the range cannot return tuples +SELECT ctid FROM tidrangescan WHERE ctid >= (SELECT NULL::tid) +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid FROM tidrangescan WHERE ctid >= (SELECT NULL::tid)" +== 033 +-- truncate_limit: 100 +-- rescans +EXPLAIN (COSTS OFF) +SELECT t.ctid,t2.c FROM tidrangescan t, +LATERAL (SELECT count(*) c FROM tidrangescan t2 WHERE t2.ctid <= t.ctid) t2 +WHERE t.ctid < '(1,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +ALIAS: "t"="tidrangescan" +ALIAS: "t2"="tidrangescan" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t" column="ctid" +FILTER: schema="" table="t2" column="ctid" +FILTER: schema="" table="t" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t.ctid, t2.c FROM tidrangescan t, LATERAL (SELECT count(*) AS c FROM t..." +== 034 +-- truncate_limit: 100 +SELECT t.ctid,t2.c FROM tidrangescan t, +LATERAL (SELECT count(*) c FROM tidrangescan t2 WHERE t2.ctid <= t.ctid) t2 +WHERE t.ctid < '(1,0)' +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=Select +ALIAS: "t"="tidrangescan" +ALIAS: "t2"="tidrangescan" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t" column="ctid" +FILTER: schema="" table="t2" column="ctid" +FILTER: schema="" table="t" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tidrangescan t, LATERAL (SELECT ... FROM tidrangescan t2 WHERE ...) t2 WHERE ..." +== 035 +-- truncate_limit: 100 +-- cursors + +-- Ensure we get a TID Range scan without a Materialize node. +EXPLAIN (COSTS OFF) +DECLARE c SCROLL CURSOR FOR SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)' +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DECLARE c SCROLL CURSOR FOR SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)'" +== 036 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 037 +-- truncate_limit: 100 +DECLARE c SCROLL CURSOR FOR SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)' +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c SCROLL CURSOR FOR SELECT ctid FROM tidrangescan WHERE ctid < '(1,0)'" +== 038 +-- truncate_limit: 100 +FETCH NEXT c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 039 +-- truncate_limit: 100 +FETCH NEXT c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 040 +-- truncate_limit: 100 +FETCH PRIOR c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 041 +-- truncate_limit: 100 +FETCH FIRST c +-- +STMT: FetchStmt +TRUNCATED: "FETCH FIRST c" +== 042 +-- truncate_limit: 100 +FETCH LAST c +-- +STMT: FetchStmt +TRUNCATED: "FETCH LAST c" +== 043 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 044 +-- truncate_limit: 100 +DROP TABLE tidrangescan +-- +TABLE: name="tidrangescan" schema="" table="tidrangescan" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tidrangescan" +== 045 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" diff --git a/parser/testdata/summary_truncate/postgres_regress/tidscan.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tidscan.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tidscan.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tidscan.test b/parser/testdata/summary_truncate/postgres_regress/tidscan.test new file mode 100644 index 0000000..e0ee55e --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tidscan.test @@ -0,0 +1,438 @@ +== 001 +-- truncate_limit: 100 +-- tests for tidscans + +CREATE TABLE tidscan(id integer) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tidscan (id int)" +== 002 +-- truncate_limit: 100 +-- only insert a few rows, we don't want to spill onto a second table page +INSERT INTO tidscan VALUES (1), (2), (3) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tidscan VALUES (1), (2), (3)" +== 003 +-- truncate_limit: 100 +-- show ctids +SELECT ctid, * FROM tidscan +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ctid, * FROM tidscan" +== 004 +-- truncate_limit: 100 +-- ctid equality - implemented as tidscan +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE ctid = '(0,1)' +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid, * FROM tidscan WHERE ctid = '(0,1)'" +== 005 +-- truncate_limit: 100 +SELECT ctid, * FROM tidscan WHERE ctid = '(0,1)' +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, * FROM tidscan WHERE ctid = '(0,1)'" +== 006 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE '(0,1)' = ctid +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid, * FROM tidscan WHERE '(0,1)' = ctid" +== 007 +-- truncate_limit: 100 +SELECT ctid, * FROM tidscan WHERE '(0,1)' = ctid +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, * FROM tidscan WHERE '(0,1)' = ctid" +== 008 +-- truncate_limit: 100 +-- OR'd clauses +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE ctid = '(0,2)' OR '(0,1)' = ctid +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid, * FROM tidscan WHERE ctid = '(0,2)' OR '(0,1)' = ctid" +== 009 +-- truncate_limit: 100 +SELECT ctid, * FROM tidscan WHERE ctid = '(0,2)' OR '(0,1)' = ctid +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, * FROM tidscan WHERE ctid = '(0,2)' OR '(0,1)' = ctid" +== 010 +-- truncate_limit: 100 +-- ctid = ScalarArrayOp - implemented as tidscan +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[])" +== 011 +-- truncate_limit: 100 +SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[])" +== 012 +-- truncate_limit: 100 +-- ctid != ScalarArrayOp - can't be implemented as tidscan +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan WHERE ctid != ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid, * FROM tidscan WHERE ctid <> ANY(ARRAY['(0,1)', '(0,2)']::tid[])" +== 013 +-- truncate_limit: 100 +SELECT ctid, * FROM tidscan WHERE ctid != ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, * FROM tidscan WHERE ctid <> ANY(ARRAY['(0,1)', '(0,2)']::tid[])" +== 014 +-- truncate_limit: 100 +-- tid equality extracted from sub-AND clauses +EXPLAIN (COSTS OFF) +SELECT ctid, * FROM tidscan +WHERE (id = 3 AND ctid IN ('(0,2)', '(0,3)')) OR (ctid = '(0,1)' AND id = 1) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="id" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT ctid, * FROM tidscan WHERE (id = 3 AND ctid IN ('(0,2)', '(0,3)')) OR ..." +== 015 +-- truncate_limit: 100 +SELECT ctid, * FROM tidscan +WHERE (id = 3 AND ctid IN ('(0,2)', '(0,3)')) OR (ctid = '(0,1)' AND id = 1) +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="ctid" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ctid, * FROM tidscan WHERE ..." +== 016 +-- truncate_limit: 100 +-- nestloop-with-inner-tidscan joins on tid +SET enable_hashjoin TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 017 +-- truncate_limit: 100 +-- otherwise hash join might win +EXPLAIN (COSTS OFF) +SELECT t1.ctid, t1.*, t2.ctid, t2.* +FROM tidscan t1 JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1 +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +ALIAS: "t1"="tidscan" +ALIAS: "t2"="tidscan" +FILTER: schema="" table="t1" column="id" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.ctid, t1.*, t2.ctid, t2.* FROM tidscan t1 JOIN tidscan t2 ON t1.cti..." +== 018 +-- truncate_limit: 100 +SELECT t1.ctid, t1.*, t2.ctid, t2.* +FROM tidscan t1 JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1 +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +ALIAS: "t1"="tidscan" +ALIAS: "t2"="tidscan" +FILTER: schema="" table="t1" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tidscan t1 JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1" +== 019 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT t1.ctid, t1.*, t2.ctid, t2.* +FROM tidscan t1 LEFT JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1 +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +ALIAS: "t1"="tidscan" +ALIAS: "t2"="tidscan" +FILTER: schema="" table="t1" column="id" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.ctid, t1.*, t2.ctid, t2.* FROM tidscan t1 LEFT JOIN tidscan t2 ON t..." +== 020 +-- truncate_limit: 100 +SELECT t1.ctid, t1.*, t2.ctid, t2.* +FROM tidscan t1 LEFT JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1 +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +ALIAS: "t1"="tidscan" +ALIAS: "t2"="tidscan" +FILTER: schema="" table="t1" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tidscan t1 LEFT JOIN tidscan t2 ON t1.ctid = t2.ctid WHERE t1.id = 1" +== 021 +-- truncate_limit: 100 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 022 +-- truncate_limit: 100 +-- exercise backward scan and rewind +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 023 +-- truncate_limit: 100 +DECLARE c CURSOR FOR +SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[]) +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT ctid, * FROM tidscan WHERE ctid = ANY(ARRAY['(0,1)', '(0,2)']::tid[])" +== 024 +-- truncate_limit: 100 +FETCH ALL FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH ALL c" +== 025 +-- truncate_limit: 100 +FETCH BACKWARD 1 FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 026 +-- truncate_limit: 100 +FETCH FIRST FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH FIRST c" +== 027 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 028 +-- truncate_limit: 100 +-- tidscan via CURRENT OF +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 029 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT ctid, * FROM tidscan +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT ctid, * FROM tidscan" +== 030 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 031 +-- truncate_limit: 100 +-- skip one row +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 032 +-- truncate_limit: 100 +-- perform update +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +UPDATE tidscan SET id = -id WHERE CURRENT OF c RETURNING * +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) UPDATE tidscan SET id = - id WHERE CURRENT ..." +== 033 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 034 +-- truncate_limit: 100 +-- perform update +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +UPDATE tidscan SET id = -id WHERE CURRENT OF c RETURNING * +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) UPDATE tidscan SET id = - id WHERE CURRENT ..." +== 035 +-- truncate_limit: 100 +SELECT * FROM tidscan +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tidscan" +== 036 +-- truncate_limit: 100 +-- position cursor past any rows +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 037 +-- truncate_limit: 100 +-- should error out +EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +UPDATE tidscan SET id = -id WHERE CURRENT OF c RETURNING * +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) UPDATE tidscan SET id = - id WHERE CURRENT ..." +== 038 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 039 +-- truncate_limit: 100 +-- bulk joins on CTID +-- (these plans don't use TID scans, but this still seems like an +-- appropriate place for these tests) +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid" +== 040 +-- truncate_limit: 100 +SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid" +== 041 +-- truncate_limit: 100 +SET enable_hashjoin TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashjoin TO OFF" +== 042 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid" +== 043 +-- truncate_limit: 100 +SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM tenk1 t1 JOIN tenk1 t2 ON t1.ctid = t2.ctid" +== 044 +-- truncate_limit: 100 +RESET enable_hashjoin +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashjoin" +== 045 +-- truncate_limit: 100 +-- check predicate lock on CTID +BEGIN ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 046 +-- truncate_limit: 100 +SELECT * FROM tidscan WHERE ctid = '(0,1)' +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=Select +FILTER: schema="" table="" column="ctid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tidscan WHERE ctid = '(0,1)'" +== 047 +-- truncate_limit: 100 +-- locktype should be 'tuple' +SELECT locktype, mode FROM pg_locks WHERE pid = pg_backend_pid() AND mode = 'SIReadLock' +-- +TABLE: name="pg_locks" schema="" table="pg_locks" ctx=Select +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FUNCTION: name="pg_backend_pid" function="pg_backend_pid" schema="" ctx=Call +FILTER: schema="" table="" column="pid" +FILTER: schema="" table="" column="mode" +STMT: SelectStmt +TRUNCATED: "SELECT locktype, mode FROM pg_locks WHERE pid = pg_backend_pid() AND mode = 'SIReadLock'" +== 048 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 049 +-- truncate_limit: 100 +DROP TABLE tidscan +-- +TABLE: name="tidscan" schema="" table="tidscan" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tidscan" diff --git a/parser/testdata/summary_truncate/postgres_regress/time.metadata.json b/parser/testdata/summary_truncate/postgres_regress/time.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/time.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/time.test b/parser/testdata/summary_truncate/postgres_regress/time.test new file mode 100644 index 0000000..6b10075 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/time.test @@ -0,0 +1,348 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TIME +|-- + +CREATE TABLE TIME_TBL (f1 time(2)) +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE time_tbl (f1 time(2))" +== 002 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('00:00') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('00:00')" +== 003 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('01:00') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('01:00')" +== 004 +-- truncate_limit: 100 +-- as of 7.4, timezone spec should be accepted and ignored +INSERT INTO TIME_TBL VALUES ('02:03 PST') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('02:03 PST')" +== 005 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('11:59 EDT') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('11:59 EDT')" +== 006 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('12:00') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('12:00')" +== 007 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('12:01') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('12:01')" +== 008 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('23:59') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('23:59')" +== 009 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('11:59:59.99 PM')" +== 010 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('2003-03-07 15:36:39 America/New_York') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('2003-03-07 15:36:39 America/New_York')" +== 011 +-- truncate_limit: 100 +INSERT INTO TIME_TBL VALUES ('2003-07-07 15:36:39 America/New_York') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('2003-07-07 15:36:39 America/New_York')" +== 012 +-- truncate_limit: 100 +-- this should fail (the timezone offset is not known) +INSERT INTO TIME_TBL VALUES ('15:36:39 America/New_York') +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO time_tbl VALUES ('15:36:39 America/New_York')" +== 013 +-- truncate_limit: 100 +SELECT f1 AS "Time" FROM TIME_TBL +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Time\" FROM time_tbl" +== 014 +-- truncate_limit: 100 +SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07' +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Three\" FROM time_tbl WHERE f1 < '05:06:07'" +== 015 +-- truncate_limit: 100 +SELECT f1 AS "Five" FROM TIME_TBL WHERE f1 > '05:06:07' +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Five\" FROM time_tbl WHERE f1 > '05:06:07'" +== 016 +-- truncate_limit: 100 +SELECT f1 AS "None" FROM TIME_TBL WHERE f1 < '00:00' +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"None\" FROM time_tbl WHERE f1 < '00:00'" +== 017 +-- truncate_limit: 100 +SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00' +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Eight\" FROM time_tbl WHERE f1 >= '00:00'" +== 018 +-- truncate_limit: 100 +-- Check edge cases +SELECT '23:59:59.999999'::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '23:59:59.999999'::time" +== 019 +-- truncate_limit: 100 +SELECT '23:59:59.9999999'::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '23:59:59.9999999'::time" +== 020 +-- truncate_limit: 100 +-- rounds up +SELECT '23:59:60'::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '23:59:60'::time" +== 021 +-- truncate_limit: 100 +-- rounds up +SELECT '24:00:00'::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '24:00:00'::time" +== 022 +-- truncate_limit: 100 +-- allowed +SELECT '24:00:00.01'::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '24:00:00.01'::time" +== 023 +-- truncate_limit: 100 +-- not allowed +SELECT '23:59:60.01'::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '23:59:60.01'::time" +== 024 +-- truncate_limit: 100 +-- not allowed +SELECT '24:01:00'::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '24:01:00'::time" +== 025 +-- truncate_limit: 100 +-- not allowed +SELECT '25:00:00'::time +-- +STMT: SelectStmt +TRUNCATED: "SELECT '25:00:00'::time" +== 026 +-- truncate_limit: 100 +-- not allowed + +-- Test non-error-throwing API +SELECT pg_input_is_valid('12:00:00', 'time') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('12:00:00', 'time')" +== 027 +-- truncate_limit: 100 +SELECT pg_input_is_valid('25:00:00', 'time') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('25:00:00', 'time')" +== 028 +-- truncate_limit: 100 +SELECT pg_input_is_valid('15:36:39 America/New_York', 'time') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('15:36:39 America/New_York', 'time')" +== 029 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('25:00:00', 'time') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('25:00:00', 'time')" +== 030 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('15:36:39 America/New_York', 'time') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('15:36:39 America/New_York', 'time')" +== 031 +-- truncate_limit: 100 +|-- +-- TIME simple math +|-- +-- We now make a distinction between time and intervals, +-- and adding two times together makes no sense at all. +-- Leave in one query to show that it is rejected, +-- and do the rest of the testing in horology.sql +-- where we do mixed-type arithmetic. - thomas 2000-12-02 + +SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL +-- +TABLE: name="time_tbl" schema="" table="time_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 + '00:01'::time AS \"Illegal\" FROM time_tbl" +== 032 +-- truncate_limit: 100 +|-- +-- test EXTRACT +|-- +SELECT EXTRACT(MICROSECOND FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('microsecond' FROM '2020-05-26 13:30:25.575401'::time)" +== 033 +-- truncate_limit: 100 +SELECT EXTRACT(MILLISECOND FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millisecond' FROM '2020-05-26 13:30:25.575401'::time)" +== 034 +-- truncate_limit: 100 +SELECT EXTRACT(SECOND FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('second' FROM '2020-05-26 13:30:25.575401'::time)" +== 035 +-- truncate_limit: 100 +SELECT EXTRACT(MINUTE FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('minute' FROM '2020-05-26 13:30:25.575401'::time)" +== 036 +-- truncate_limit: 100 +SELECT EXTRACT(HOUR FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('hour' FROM '2020-05-26 13:30:25.575401'::time)" +== 037 +-- truncate_limit: 100 +SELECT EXTRACT(DAY FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('day' FROM '2020-05-26 13:30:25.575401'::time)" +== 038 +-- truncate_limit: 100 +-- error +SELECT EXTRACT(FORTNIGHT FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('fortnight' FROM '2020-05-26 13:30:25.575401'::time)" +== 039 +-- truncate_limit: 100 +-- error +SELECT EXTRACT(TIMEZONE FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('timezone' FROM '2020-05-26 13:30:25.575401'::time)" +== 040 +-- truncate_limit: 100 +-- error +SELECT EXTRACT(EPOCH FROM TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '2020-05-26 13:30:25.575401'::time)" +== 041 +-- truncate_limit: 100 +-- date_part implementation is mostly the same as extract, so only +-- test a few cases for additional coverage. +SELECT date_part('microsecond', TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('microsecond', '2020-05-26 13:30:25.575401'::time)" +== 042 +-- truncate_limit: 100 +SELECT date_part('millisecond', TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('millisecond', '2020-05-26 13:30:25.575401'::time)" +== 043 +-- truncate_limit: 100 +SELECT date_part('second', TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('second', '2020-05-26 13:30:25.575401'::time)" +== 044 +-- truncate_limit: 100 +SELECT date_part('epoch', TIME '2020-05-26 13:30:25.575401') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('epoch', '2020-05-26 13:30:25.575401'::time)" diff --git a/parser/testdata/summary_truncate/postgres_regress/timestamp.metadata.json b/parser/testdata/summary_truncate/postgres_regress/timestamp.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/timestamp.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/timestamp.test b/parser/testdata/summary_truncate/postgres_regress/timestamp.test new file mode 100644 index 0000000..4a194cf --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/timestamp.test @@ -0,0 +1,1506 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TIMESTAMP +|-- + +CREATE TABLE TIMESTAMP_TBL (d1 timestamp(2) without time zone) +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE timestamp_tbl (d1 timestamp(2))" +== 002 +-- truncate_limit: 100 +-- Test shorthand input values +-- We can't just "select" the results since they aren't constants; test for +-- equality instead. We can do that by running the test inside a transaction +-- block, within which the value of 'now' shouldn't change, and so these +-- related values shouldn't either. + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 003 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('today') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('today')" +== 004 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('yesterday') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('yesterday')" +== 005 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('tomorrow')" +== 006 +-- truncate_limit: 100 +-- time zone should be ignored by this data type +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow EST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('tomorrow EST')" +== 007 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('tomorrow zulu')" +== 008 +-- truncate_limit: 100 +SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'today' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS one FROM timestamp_tbl WHERE d1 = 'today'::timestamp" +== 009 +-- truncate_limit: 100 +SELECT count(*) AS Three FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'tomorrow' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS three FROM timestamp_tbl WHERE d1 = 'tomorrow'::timestamp" +== 010 +-- truncate_limit: 100 +SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'yesterday' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS one FROM timestamp_tbl WHERE d1 = 'yesterday'::timestamp" +== 011 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 012 +-- truncate_limit: 100 +DELETE FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM timestamp_tbl" +== 013 +-- truncate_limit: 100 +-- Verify that 'now' *does* change over a reasonable interval such as 100 msec, +-- and that it doesn't change over the same interval within a transaction block + +INSERT INTO TIMESTAMP_TBL VALUES ('now') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('now')" +== 014 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 015 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 016 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('now') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('now')" +== 017 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 018 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('now') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('now')" +== 019 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 020 +-- truncate_limit: 100 +SELECT count(*) AS two FROM TIMESTAMP_TBL WHERE d1 = timestamp(2) without time zone 'now' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS two FROM timestamp_tbl WHERE d1 = 'now'::timestamp(2)" +== 021 +-- truncate_limit: 100 +SELECT count(d1) AS three, count(DISTINCT d1) AS two FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(d1) AS three, count(DISTINCT d1) AS two FROM timestamp_tbl" +== 022 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 023 +-- truncate_limit: 100 +TRUNCATE TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE timestamp_tbl" +== 024 +-- truncate_limit: 100 +-- Special values +INSERT INTO TIMESTAMP_TBL VALUES ('-infinity') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('-infinity')" +== 025 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('infinity') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('infinity')" +== 026 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('epoch') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('epoch')" +== 027 +-- truncate_limit: 100 +SELECT timestamp 'infinity' = timestamp '+infinity' AS t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::timestamp = '+infinity'::timestamp AS t" +== 028 +-- truncate_limit: 100 +-- Postgres v6.0 standard output format +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Mon Feb 10 17:32:01 1997 PST')" +== 029 +-- truncate_limit: 100 +-- Variations on Postgres v6.1 standard output format +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Mon Feb 10 17:32:01.000001 1997 PST')" +== 030 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Mon Feb 10 17:32:01.999999 1997 PST')" +== 031 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Mon Feb 10 17:32:01.4 1997 PST')" +== 032 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Mon Feb 10 17:32:01.5 1997 PST')" +== 033 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Mon Feb 10 17:32:01.6 1997 PST')" +== 034 +-- truncate_limit: 100 +-- ISO 8601 format +INSERT INTO TIMESTAMP_TBL VALUES ('1997-01-02') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997-01-02')" +== 035 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-01-02 03:04:05') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997-01-02 03:04:05')" +== 036 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-08') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997-02-10 17:32:01-08')" +== 037 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-0800') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997-02-10 17:32:01-0800')" +== 038 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 -08:00') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997-02-10 17:32:01 -08:00')" +== 039 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 -0800') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('19970210 173201 -0800')" +== 040 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 17:32:01 -07:00') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997-06-10 17:32:01 -07:00')" +== 041 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('2001-09-22T18:19:20') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('2001-09-22T18:19:20')" +== 042 +-- truncate_limit: 100 +-- POSIX format (note that the timezone abbrev is just decoration here) +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 08:14:01 GMT+8') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('2000-03-15 08:14:01 GMT+8')" +== 043 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 13:14:02 GMT-1') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('2000-03-15 13:14:02 GMT-1')" +== 044 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 12:14:03 GMT-2') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('2000-03-15 12:14:03 GMT-2')" +== 045 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 03:14:04 PST+8') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('2000-03-15 03:14:04 PST+8')" +== 046 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 02:14:05 MST+7:00') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('2000-03-15 02:14:05 MST+7:00')" +== 047 +-- truncate_limit: 100 +-- Variations for acceptable input formats +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997 -0800') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 10 17:32:01 1997 -0800')" +== 048 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 10 17:32:01 1997')" +== 049 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 5:32PM 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 10 5:32PM 1997')" +== 050 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('1997/02/10 17:32:01-0800') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997/02/10 17:32:01-0800')" +== 051 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997-02-10 17:32:01 PST')" +== 052 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb-10-1997 17:32:01 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb-10-1997 17:32:01 PST')" +== 053 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('02-10-1997 17:32:01 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('02-10-1997 17:32:01 PST')" +== 054 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 PST') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('19970210 173201 PST')" +== 055 +-- truncate_limit: 100 +set datestyle to ymd +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO ymd" +== 056 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('97FEB10 5:32:01PM UTC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('97FEB10 5:32:01PM UTC')" +== 057 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('97/02/10 17:32:01 UTC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('97/02/10 17:32:01 UTC')" +== 058 +-- truncate_limit: 100 +reset datestyle +-- +STMT: VariableSetStmt +TRUNCATED: "RESET datestyle" +== 059 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('1997.041 17:32:01 UTC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997.041 17:32:01 UTC')" +== 060 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 America/New_York') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('19970210 173201 America/New_York')" +== 061 +-- truncate_limit: 100 +-- this fails (even though TZ is a no-op, we still look it up) +INSERT INTO TIMESTAMP_TBL VALUES ('19970710 173201 America/Does_not_exist') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('19970710 173201 America/Does_not_exist')" +== 062 +-- truncate_limit: 100 +-- Test non-error-throwing API +SELECT pg_input_is_valid('now', 'timestamp') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('now', 'timestamp')" +== 063 +-- truncate_limit: 100 +SELECT pg_input_is_valid('garbage', 'timestamp') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('garbage', 'timestamp')" +== 064 +-- truncate_limit: 100 +SELECT pg_input_is_valid('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp')" +== 065 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('garbage', 'timestamp') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('garbage', 'timestamp')" +== 066 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp')" +== 067 +-- truncate_limit: 100 +-- Check date conversion and date arithmetic +INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 18:32:01 PDT') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('1997-06-10 18:32:01 PDT')" +== 068 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 10 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 10 17:32:01 1997')" +== 069 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 11 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 11 17:32:01 1997')" +== 070 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 12 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 12 17:32:01 1997')" +== 071 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 13 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 13 17:32:01 1997')" +== 072 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 14 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 14 17:32:01 1997')" +== 073 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 15 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 15 17:32:01 1997')" +== 074 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 1997')" +== 075 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0097 BC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 0097 BC')" +== 076 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0097') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 0097')" +== 077 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 0597') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 0597')" +== 078 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1097') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 1097')" +== 079 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1697') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 1697')" +== 080 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1797') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 1797')" +== 081 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1897') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 1897')" +== 082 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 1997')" +== 083 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 2097') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 2097')" +== 084 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 28 17:32:01 1996')" +== 085 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 29 17:32:01 1996')" +== 086 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Mar 01 17:32:01 1996')" +== 087 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Dec 30 17:32:01 1996')" +== 088 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1996') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Dec 31 17:32:01 1996')" +== 089 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Jan 01 17:32:01 1997')" +== 090 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 28 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 28 17:32:01 1997')" +== 091 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 29 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 29 17:32:01 1997')" +== 092 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Mar 01 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Mar 01 17:32:01 1997')" +== 093 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 30 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Dec 30 17:32:01 1997')" +== 094 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1997') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Dec 31 17:32:01 1997')" +== 095 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 1999') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Dec 31 17:32:01 1999')" +== 096 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2000') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Jan 01 17:32:01 2000')" +== 097 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Dec 31 17:32:01 2000') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Dec 31 17:32:01 2000')" +== 098 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Jan 01 17:32:01 2001')" +== 099 +-- truncate_limit: 100 +-- Currently unsupported syntax and ranges +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 -0097')" +== 100 +-- truncate_limit: 100 +INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC') +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamp_tbl VALUES ('Feb 16 17:32:01 5097 BC')" +== 101 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamp_tbl" +== 102 +-- truncate_limit: 100 +-- Check behavior at the boundaries of the timestamp range +SELECT '4714-11-24 00:00:00 BC'::timestamp +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-24 00:00:00 BC'::timestamp" +== 103 +-- truncate_limit: 100 +SELECT '4714-11-23 23:59:59 BC'::timestamp +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-23 23:59:59 BC'::timestamp" +== 104 +-- truncate_limit: 100 +-- out of range +SELECT '294276-12-31 23:59:59'::timestamp +-- +STMT: SelectStmt +TRUNCATED: "SELECT '294276-12-31 23:59:59'::timestamp" +== 105 +-- truncate_limit: 100 +SELECT '294277-01-01 00:00:00'::timestamp +-- +STMT: SelectStmt +TRUNCATED: "SELECT '294277-01-01 00:00:00'::timestamp" +== 106 +-- truncate_limit: 100 +-- out of range + +-- Demonstrate functions and operators +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 > timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamp_tbl WHERE d1 > '1997-01-02'::timestamp" +== 107 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 < timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamp_tbl WHERE d1 < '1997-01-02'::timestamp" +== 108 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 = timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamp_tbl WHERE d1 = '1997-01-02'::timestamp" +== 109 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 != timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamp_tbl WHERE d1 <> '1997-01-02'::timestamp" +== 110 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 <= timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamp_tbl WHERE d1 <= '1997-01-02'::timestamp" +== 111 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMP_TBL + WHERE d1 >= timestamp without time zone '1997-01-02' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamp_tbl WHERE d1 >= '1997-01-02'::timestamp" +== 112 +-- truncate_limit: 100 +SELECT d1 - timestamp without time zone '1997-01-02' AS diff + FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 - '1997-01-02'::timestamp AS diff FROM timestamp_tbl WHERE ..." +== 113 +-- truncate_limit: 100 +SELECT date_trunc( 'week', timestamp '2004-02-29 15:44:17.71393' ) AS week_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('week', '2004-02-29 15:44:17.71393'::timestamp) AS week_trunc" +== 114 +-- truncate_limit: 100 +-- verify date_bin behaves the same as date_trunc for relevant intervals + +-- case 1: AD dates, origin < input +SELECT + str, + interval, + date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2001-01-01') AS equal +FROM ( + VALUES + ('week', '7 d'), + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamp '2020-02-29 15:44:17.71393')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) intervals(str, \"interval\"), (VALUES (...)) ts(ts)" +== 115 +-- truncate_limit: 100 +-- case 2: BC dates, origin < input +SELECT + str, + interval, + date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2000-01-01 BC') AS equal +FROM ( + VALUES + ('week', '7 d'), + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamp '0055-6-10 15:44:17.71393 BC')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) intervals(str, \"interval\"), (VALUES (...)) ts(ts)" +== 116 +-- truncate_limit: 100 +-- case 3: AD dates, origin > input +SELECT + str, + interval, + date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '2020-03-02') AS equal +FROM ( + VALUES + ('week', '7 d'), + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamp '2020-02-29 15:44:17.71393')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) intervals(str, \"interval\"), (VALUES (...)) ts(ts)" +== 117 +-- truncate_limit: 100 +-- case 4: BC dates, origin > input +SELECT + str, + interval, + date_trunc(str, ts) = date_bin(interval::interval, ts, timestamp '0055-06-17 BC') AS equal +FROM ( + VALUES + ('week', '7 d'), + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamp '0055-6-10 15:44:17.71393 BC')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) intervals(str, \"interval\"), (VALUES (...)) ts(ts)" +== 118 +-- truncate_limit: 100 +-- bin timestamps into arbitrary intervals +SELECT + interval, + ts, + origin, + date_bin(interval::interval, ts, origin) +FROM ( + VALUES + ('15 days'), + ('2 hours'), + ('1 hour 30 minutes'), + ('15 minutes'), + ('10 seconds'), + ('100 milliseconds'), + ('250 microseconds') +) intervals (interval), +(VALUES (timestamp '2020-02-11 15:44:17.71393')) ts (ts), +(VALUES (timestamp '2001-01-01')) origin (origin) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) intervals(\"interval\"), (VALUES (...)) ts(ts), (VALUES (...)) origi..." +== 119 +-- truncate_limit: 100 +-- shift bins using the origin parameter: +SELECT date_bin('5 min'::interval, timestamp '2020-02-01 01:01:01', timestamp '2020-02-01 00:02:30') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 120 +-- truncate_limit: 100 +-- test roundoff edge case when source < origin +SELECT date_bin('30 minutes'::interval, timestamp '2024-02-01 15:00:00', timestamp '2024-02-01 17:00:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 121 +-- truncate_limit: 100 +-- disallow intervals with months or years +SELECT date_bin('5 months'::interval, timestamp '2020-02-01 01:01:01', timestamp '2001-01-01') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('5 months'::interval, '2020-02-01 01:01:01'::timestamp, '2001-01-01'::timestamp)" +== 122 +-- truncate_limit: 100 +SELECT date_bin('5 years'::interval, timestamp '2020-02-01 01:01:01', timestamp '2001-01-01') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('5 years'::interval, '2020-02-01 01:01:01'::timestamp, '2001-01-01'::timestamp)" +== 123 +-- truncate_limit: 100 +-- disallow zero intervals +SELECT date_bin('0 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp '1970-01-01 00:00:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 124 +-- truncate_limit: 100 +-- disallow negative intervals +SELECT date_bin('-2 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp '1970-01-01 00:00:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 125 +-- truncate_limit: 100 +-- test overflow cases +select date_bin('15 minutes'::interval, timestamp '294276-12-30', timestamp '4000-12-20 BC') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('15 minutes'::interval, '294276-12-30'::timestamp, '4000-12-20 BC'::timestamp)" +== 126 +-- truncate_limit: 100 +select date_bin('200000000 days'::interval, '2024-02-01'::timestamp, '2024-01-01'::timestamp) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('200000000 days'::interval, '2024-02-01'::timestamp, '2024-01-01'::timestamp)" +== 127 +-- truncate_limit: 100 +select date_bin('365000 days'::interval, '4400-01-01 BC'::timestamp, '4000-01-01 BC'::timestamp) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('365000 days'::interval, '4400-01-01 BC'::timestamp, '4000-01-01 BC'::timestamp)" +== 128 +-- truncate_limit: 100 +-- Test casting within a BETWEEN qualifier +SELECT d1 - timestamp without time zone '1997-01-02' AS diff + FROM TIMESTAMP_TBL + WHERE d1 BETWEEN timestamp without time zone '1902-01-01' + AND timestamp without time zone '2038-01-01' +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 - '1997-01-02'::timestamp AS diff FROM timestamp_tbl WHERE ..." +== 129 +-- truncate_limit: 100 +-- DATE_PART (timestamp_part) +SELECT d1 as "timestamp", + date_part( 'year', d1) AS year, date_part( 'month', d1) AS month, + date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour, + date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamp_tbl" +== 130 +-- truncate_limit: 100 +SELECT d1 as "timestamp", + date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec, + date_part( 'usec', d1) AS usec + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamp_tbl" +== 131 +-- truncate_limit: 100 +SELECT d1 as "timestamp", + date_part( 'isoyear', d1) AS isoyear, date_part( 'week', d1) AS week, + date_part( 'isodow', d1) AS isodow, date_part( 'dow', d1) AS dow, + date_part( 'doy', d1) AS doy + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamp_tbl" +== 132 +-- truncate_limit: 100 +SELECT d1 as "timestamp", + date_part( 'decade', d1) AS decade, + date_part( 'century', d1) AS century, + date_part( 'millennium', d1) AS millennium, + round(date_part( 'julian', d1)) AS julian, + date_part( 'epoch', d1) AS epoch + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamp_tbl" +== 133 +-- truncate_limit: 100 +-- extract implementation is mostly the same as date_part, so only +-- test a few cases for additional coverage. +SELECT d1 as "timestamp", + extract(microseconds from d1) AS microseconds, + extract(milliseconds from d1) AS milliseconds, + extract(seconds from d1) AS seconds, + round(extract(julian from d1)) AS julian, + extract(epoch from d1) AS epoch + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamp_tbl" +== 134 +-- truncate_limit: 100 +-- value near upper bound uses special case in code +SELECT date_part('epoch', '294270-01-01 00:00:00'::timestamp) +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('epoch', '294270-01-01 00:00:00'::timestamp)" +== 135 +-- truncate_limit: 100 +SELECT extract(epoch from '294270-01-01 00:00:00'::timestamp) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '294270-01-01 00:00:00'::timestamp)" +== 136 +-- truncate_limit: 100 +-- another internal overflow test case +SELECT extract(epoch from '5000-01-01 00:00:00'::timestamp) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '5000-01-01 00:00:00'::timestamp)" +== 137 +-- truncate_limit: 100 +-- test edge-case overflow in timestamp subtraction +SELECT timestamp '294276-12-31 23:59:59' - timestamp '1999-12-23 19:59:04.224193' AS ok +-- +STMT: SelectStmt +TRUNCATED: "SELECT '294276-12-31 23:59:59'::timestamp - '1999-12-23 19:59:04.224193'::timestamp AS ok" +== 138 +-- truncate_limit: 100 +SELECT timestamp '294276-12-31 23:59:59' - timestamp '1999-12-23 19:59:04.224192' AS overflows +-- +STMT: SelectStmt +TRUNCATED: "SELECT '294276-12-31 23:59:59'::timestamp - '1999-12-23 19:59:04.224192'::timestamp AS overflows" +== 139 +-- truncate_limit: 100 +-- TO_CHAR() +SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') FROM timestamp_tbl" +== 140 +-- truncate_limit: 100 +SELECT to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM') FROM timestamp_tbl" +== 141 +-- truncate_limit: 100 +SELECT to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J') FROM timestamp_tbl" +== 142 +-- truncate_limit: 100 +SELECT to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamp_tbl" +== 143 +-- truncate_limit: 100 +SELECT to_char(d1, 'HH HH12 HH24 MI SS SSSS') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'HH HH12 HH24 MI SS SSSS') FROM timestamp_tbl" +== 144 +-- truncate_limit: 100 +SELECT to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, E'\"HH:MI:SS is\" HH:MI:SS \"\\\\\"text between quote marks\\\\\"\"') FROM timestamp_tbl" +== 145 +-- truncate_limit: 100 +SELECT to_char(d1, 'HH24--text--MI--text--SS') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'HH24--text--MI--text--SS') FROM timestamp_tbl" +== 146 +-- truncate_limit: 100 +SELECT to_char(d1, 'YYYYTH YYYYth Jth') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'YYYYTH YYYYth Jth') FROM timestamp_tbl" +== 147 +-- truncate_limit: 100 +SELECT to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamp_tbl" +== 148 +-- truncate_limit: 100 +SELECT to_char(d1, 'IYYY IYY IY I IW IDDD ID') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'IYYY IYY IY I IW IDDD ID') FROM timestamp_tbl" +== 149 +-- truncate_limit: 100 +SELECT to_char(d1, 'FMIYYY FMIYY FMIY FMI FMIW FMIDDD FMID') + FROM TIMESTAMP_TBL +-- +TABLE: name="timestamp_tbl" schema="" table="timestamp_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'FMIYYY FMIYY FMIY FMI FMIW FMIDDD FMID') FROM timestamp_tbl" +== 150 +-- truncate_limit: 100 +SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US') + FROM (VALUES + ('2018-11-02 12:34:56'::timestamp), + ('2018-11-02 12:34:56.78'), + ('2018-11-02 12:34:56.78901'), + ('2018-11-02 12:34:56.78901234') + ) d(d) +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) d(d)" +== 151 +-- truncate_limit: 100 +-- Roman months, with upper and lower case. +SELECT i, + to_char(i * interval '1mon', 'rm'), + to_char(i * interval '1mon', 'RM') + FROM generate_series(-13, 13) i +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(-13, 13) i" +== 152 +-- truncate_limit: 100 +-- timestamp numeric fields constructor +SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887) +-- +FUNCTION: name="make_timestamp" function="make_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamp(2014, 12, 28, 6, 30, 45.887)" +== 153 +-- truncate_limit: 100 +SELECT make_timestamp(-44, 3, 15, 12, 30, 15) +-- +FUNCTION: name="make_timestamp" function="make_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamp(-44, 3, 15, 12, 30, 15)" +== 154 +-- truncate_limit: 100 +-- should fail +select make_timestamp(0, 7, 15, 12, 30, 15) +-- +FUNCTION: name="make_timestamp" function="make_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamp(0, 7, 15, 12, 30, 15)" +== 155 +-- truncate_limit: 100 +-- generate_series for timestamp +select * from generate_series('2020-01-01 00:00'::timestamp, + '2020-01-02 03:00'::timestamp, + '1 hour'::interval) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('2020-01-01 00:00'::timestamp, '2020-01-02 03:00'::timestamp, '1 ho..." +== 156 +-- truncate_limit: 100 +-- the LIMIT should allow this to terminate in a reasonable amount of time +-- (but that unfortunately doesn't work yet for SELECT * FROM ...) +select generate_series('2022-01-01 00:00'::timestamp, + 'infinity'::timestamp, + '1 month'::interval) limit 10 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... LIMIT 10" +== 157 +-- truncate_limit: 100 +-- errors +select * from generate_series('2020-01-01 00:00'::timestamp, + '2020-01-02 03:00'::timestamp, + '0 hour'::interval) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('2020-01-01 00:00'::timestamp, '2020-01-02 03:00'::timestamp, '0 ho..." +== 158 +-- truncate_limit: 100 +select generate_series(timestamp '1995-08-06 12:12:12', timestamp '1996-08-06 12:12:12', interval 'infinity') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 159 +-- truncate_limit: 100 +select generate_series(timestamp '1995-08-06 12:12:12', timestamp '1996-08-06 12:12:12', interval '-infinity') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 160 +-- truncate_limit: 100 +-- test arithmetic with infinite timestamps +select timestamp 'infinity' - timestamp 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::timestamp - 'infinity'::timestamp" +== 161 +-- truncate_limit: 100 +select timestamp 'infinity' - timestamp '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::timestamp - '-infinity'::timestamp" +== 162 +-- truncate_limit: 100 +select timestamp '-infinity' - timestamp 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::timestamp - 'infinity'::timestamp" +== 163 +-- truncate_limit: 100 +select timestamp '-infinity' - timestamp '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::timestamp - '-infinity'::timestamp" +== 164 +-- truncate_limit: 100 +select timestamp 'infinity' - timestamp '1995-08-06 12:12:12' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::timestamp - '1995-08-06 12:12:12'::timestamp" +== 165 +-- truncate_limit: 100 +select timestamp '-infinity' - timestamp '1995-08-06 12:12:12' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::timestamp - '1995-08-06 12:12:12'::timestamp" +== 166 +-- truncate_limit: 100 +-- test age() with infinite timestamps +select age(timestamp 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('infinity'::timestamp)" +== 167 +-- truncate_limit: 100 +select age(timestamp '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('-infinity'::timestamp)" +== 168 +-- truncate_limit: 100 +select age(timestamp 'infinity', timestamp 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('infinity'::timestamp, 'infinity'::timestamp)" +== 169 +-- truncate_limit: 100 +select age(timestamp 'infinity', timestamp '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('infinity'::timestamp, '-infinity'::timestamp)" +== 170 +-- truncate_limit: 100 +select age(timestamp '-infinity', timestamp 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('-infinity'::timestamp, 'infinity'::timestamp)" +== 171 +-- truncate_limit: 100 +select age(timestamp '-infinity', timestamp '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('-infinity'::timestamp, '-infinity'::timestamp)" diff --git a/parser/testdata/summary_truncate/postgres_regress/timestamptz.metadata.json b/parser/testdata/summary_truncate/postgres_regress/timestamptz.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/timestamptz.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/timestamptz.test b/parser/testdata/summary_truncate/postgres_regress/timestamptz.test new file mode 100644 index 0000000..a2a6fd2 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/timestamptz.test @@ -0,0 +1,2991 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TIMESTAMPTZ +|-- + +CREATE TABLE TIMESTAMPTZ_TBL (d1 timestamp(2) with time zone) +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE timestamptz_tbl (d1 timestamp (2) with time zone)" +== 002 +-- truncate_limit: 100 +-- Test shorthand input values +-- We can't just "select" the results since they aren't constants; test for +-- equality instead. We can do that by running the test inside a transaction +-- block, within which the value of 'now' shouldn't change, and so these +-- related values shouldn't either. + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 003 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('today') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('today')" +== 004 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('yesterday') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('yesterday')" +== 005 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('tomorrow')" +== 006 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow EST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('tomorrow EST')" +== 007 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow zulu') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('tomorrow zulu')" +== 008 +-- truncate_limit: 100 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'today' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS one FROM timestamptz_tbl WHERE d1 = 'today'::timestamp with time zone" +== 009 +-- truncate_limit: 100 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS one FROM timestamptz_tbl WHERE d1 = 'tomorrow'::timestamp with time zone" +== 010 +-- truncate_limit: 100 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'yesterday' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS one FROM timestamptz_tbl WHERE d1 = 'yesterday'::timestamp with time zone" +== 011 +-- truncate_limit: 100 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow EST' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS one FROM timestamptz_tbl WHERE d1 = 'tomorrow EST'::timestamp with time zone" +== 012 +-- truncate_limit: 100 +SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow zulu' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS one FROM timestamptz_tbl WHERE d1 = 'tomorrow zulu'::timestamp with time zone" +== 013 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 014 +-- truncate_limit: 100 +DELETE FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM timestamptz_tbl" +== 015 +-- truncate_limit: 100 +-- Verify that 'now' *does* change over a reasonable interval such as 100 msec, +-- and that it doesn't change over the same interval within a transaction block + +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('now')" +== 016 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 017 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 018 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('now')" +== 019 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 020 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('now') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('now')" +== 021 +-- truncate_limit: 100 +SELECT pg_sleep(0.1) +-- +FUNCTION: name="pg_sleep" function="pg_sleep" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_sleep(0.1)" +== 022 +-- truncate_limit: 100 +SELECT count(*) AS two FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp(2) with time zone 'now' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS two FROM timestamptz_tbl WHERE d1 = 'now'::timestamp (2) with time zone" +== 023 +-- truncate_limit: 100 +SELECT count(d1) AS three, count(DISTINCT d1) AS two FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(d1) AS three, count(DISTINCT d1) AS two FROM timestamptz_tbl" +== 024 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 025 +-- truncate_limit: 100 +TRUNCATE TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE timestamptz_tbl" +== 026 +-- truncate_limit: 100 +-- Special values +INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('-infinity')" +== 027 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('infinity')" +== 028 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('epoch')" +== 029 +-- truncate_limit: 100 +SELECT timestamptz 'infinity' = timestamptz '+infinity' AS t +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::timestamptz = '+infinity'::timestamptz AS t" +== 030 +-- truncate_limit: 100 +-- Postgres v6.0 standard output format +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Mon Feb 10 17:32:01 1997 PST')" +== 031 +-- truncate_limit: 100 +-- Variations on Postgres v6.1 standard output format +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Mon Feb 10 17:32:01.000001 1997 PST')" +== 032 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Mon Feb 10 17:32:01.999999 1997 PST')" +== 033 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Mon Feb 10 17:32:01.4 1997 PST')" +== 034 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Mon Feb 10 17:32:01.5 1997 PST')" +== 035 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Mon Feb 10 17:32:01.6 1997 PST')" +== 036 +-- truncate_limit: 100 +-- ISO 8601 format +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997-01-02')" +== 037 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02 03:04:05') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997-01-02 03:04:05')" +== 038 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-08') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997-02-10 17:32:01-08')" +== 039 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-0800') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997-02-10 17:32:01-0800')" +== 040 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 -08:00') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997-02-10 17:32:01 -08:00')" +== 041 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 -0800') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('19970210 173201 -0800')" +== 042 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 17:32:01 -07:00') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997-06-10 17:32:01 -07:00')" +== 043 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2001-09-22T18:19:20') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('2001-09-22T18:19:20')" +== 044 +-- truncate_limit: 100 +-- POSIX format (note that the timezone abbrev is just decoration here) +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 08:14:01 GMT+8') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('2000-03-15 08:14:01 GMT+8')" +== 045 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 13:14:02 GMT-1') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('2000-03-15 13:14:02 GMT-1')" +== 046 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 12:14:03 GMT-2') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('2000-03-15 12:14:03 GMT-2')" +== 047 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 03:14:04 PST+8') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('2000-03-15 03:14:04 PST+8')" +== 048 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 02:14:05 MST+7:00') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('2000-03-15 02:14:05 MST+7:00')" +== 049 +-- truncate_limit: 100 +-- Variations for acceptable input formats +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997 -0800') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 10 17:32:01 1997 -0800')" +== 050 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 10 17:32:01 1997')" +== 051 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 5:32PM 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 10 5:32PM 1997')" +== 052 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997/02/10 17:32:01-0800') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997/02/10 17:32:01-0800')" +== 053 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997-02-10 17:32:01 PST')" +== 054 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb-10-1997 17:32:01 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb-10-1997 17:32:01 PST')" +== 055 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('02-10-1997 17:32:01 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('02-10-1997 17:32:01 PST')" +== 056 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 PST') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('19970210 173201 PST')" +== 057 +-- truncate_limit: 100 +set datestyle to ymd +-- +STMT: VariableSetStmt +TRUNCATED: "SET datestyle TO ymd" +== 058 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('97FEB10 5:32:01PM UTC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('97FEB10 5:32:01PM UTC')" +== 059 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('97/02/10 17:32:01 UTC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('97/02/10 17:32:01 UTC')" +== 060 +-- truncate_limit: 100 +reset datestyle +-- +STMT: VariableSetStmt +TRUNCATED: "RESET datestyle" +== 061 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997.041 17:32:01 UTC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997.041 17:32:01 UTC')" +== 062 +-- truncate_limit: 100 +-- timestamps at different timezones +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 America/New_York') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('19970210 173201 America/New_York')" +== 063 +-- truncate_limit: 100 +SELECT '19970210 173201' AT TIME ZONE 'America/New_York' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '19970210 173201' AT TIME ZONE 'America/New_York'" +== 064 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/New_York') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('19970710 173201 America/New_York')" +== 065 +-- truncate_limit: 100 +SELECT '19970710 173201' AT TIME ZONE 'America/New_York' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '19970710 173201' AT TIME ZONE 'America/New_York'" +== 066 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970710 173201 America/Does_not_exist') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('19970710 173201 America/Does_not_exist')" +== 067 +-- truncate_limit: 100 +SELECT '19970710 173201' AT TIME ZONE 'America/Does_not_exist' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '19970710 173201' AT TIME ZONE 'America/Does_not_exist'" +== 068 +-- truncate_limit: 100 +-- Daylight saving time for timestamps beyond 32-bit time_t range. +SELECT '20500710 173201 Europe/Helsinki'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20500710 173201 Europe/Helsinki'::timestamptz" +== 069 +-- truncate_limit: 100 +-- DST +SELECT '20500110 173201 Europe/Helsinki'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '20500110 173201 Europe/Helsinki'::timestamptz" +== 070 +-- truncate_limit: 100 +-- non-DST + +SELECT '205000-07-10 17:32:01 Europe/Helsinki'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '205000-07-10 17:32:01 Europe/Helsinki'::timestamptz" +== 071 +-- truncate_limit: 100 +-- DST +SELECT '205000-01-10 17:32:01 Europe/Helsinki'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '205000-01-10 17:32:01 Europe/Helsinki'::timestamptz" +== 072 +-- truncate_limit: 100 +-- non-DST + +-- Test non-error-throwing API +SELECT pg_input_is_valid('now', 'timestamptz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('now', 'timestamptz')" +== 073 +-- truncate_limit: 100 +SELECT pg_input_is_valid('garbage', 'timestamptz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('garbage', 'timestamptz')" +== 074 +-- truncate_limit: 100 +SELECT pg_input_is_valid('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz')" +== 075 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('garbage', 'timestamptz') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('garbage', 'timestamptz')" +== 076 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz')" +== 077 +-- truncate_limit: 100 +-- Check date conversion and date arithmetic +INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 18:32:01 PDT') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('1997-06-10 18:32:01 PDT')" +== 078 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 10 17:32:01 1997')" +== 079 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 11 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 11 17:32:01 1997')" +== 080 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 12 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 12 17:32:01 1997')" +== 081 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 13 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 13 17:32:01 1997')" +== 082 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 14 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 14 17:32:01 1997')" +== 083 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 15 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 15 17:32:01 1997')" +== 084 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 1997')" +== 085 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097 BC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 0097 BC')" +== 086 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 0097')" +== 087 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0597') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 0597')" +== 088 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1097') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 1097')" +== 089 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1697') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 1697')" +== 090 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1797') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 1797')" +== 091 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1897') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 1897')" +== 092 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 1997')" +== 093 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 2097') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 2097')" +== 094 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 28 17:32:01 1996')" +== 095 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 29 17:32:01 1996')" +== 096 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Mar 01 17:32:01 1996')" +== 097 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Dec 30 17:32:01 1996')" +== 098 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1996') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Dec 31 17:32:01 1996')" +== 099 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Jan 01 17:32:01 1997')" +== 100 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 28 17:32:01 1997')" +== 101 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 29 17:32:01 1997')" +== 102 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Mar 01 17:32:01 1997')" +== 103 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Dec 30 17:32:01 1997')" +== 104 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Dec 31 17:32:01 1997')" +== 105 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1999') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Dec 31 17:32:01 1999')" +== 106 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2000') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Jan 01 17:32:01 2000')" +== 107 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 2000') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Dec 31 17:32:01 2000')" +== 108 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Jan 01 17:32:01 2001')" +== 109 +-- truncate_limit: 100 +-- Currently unsupported syntax and ranges +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 -0097')" +== 110 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC') +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tbl VALUES ('Feb 16 17:32:01 5097 BC')" +== 111 +-- truncate_limit: 100 +-- Alternative field order that we've historically supported (sort of) +-- with regular and POSIXy timezone specs +SELECT 'Wed Jul 11 10:51:14 America/New_York 2001'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Wed Jul 11 10:51:14 America/New_York 2001'::timestamptz" +== 112 +-- truncate_limit: 100 +SELECT 'Wed Jul 11 10:51:14 GMT-4 2001'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Wed Jul 11 10:51:14 GMT-4 2001'::timestamptz" +== 113 +-- truncate_limit: 100 +SELECT 'Wed Jul 11 10:51:14 GMT+4 2001'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Wed Jul 11 10:51:14 GMT+4 2001'::timestamptz" +== 114 +-- truncate_limit: 100 +SELECT 'Wed Jul 11 10:51:14 PST-03:00 2001'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Wed Jul 11 10:51:14 PST-03:00 2001'::timestamptz" +== 115 +-- truncate_limit: 100 +SELECT 'Wed Jul 11 10:51:14 PST+03:00 2001'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Wed Jul 11 10:51:14 PST+03:00 2001'::timestamptz" +== 116 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamptz_tbl" +== 117 +-- truncate_limit: 100 +-- Check behavior at the boundaries of the timestamp range +SELECT '4714-11-24 00:00:00+00 BC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-24 00:00:00+00 BC'::timestamptz" +== 118 +-- truncate_limit: 100 +SELECT '4714-11-23 16:00:00-08 BC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-23 16:00:00-08 BC'::timestamptz" +== 119 +-- truncate_limit: 100 +SELECT 'Sun Nov 23 16:00:00 4714 PST BC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'Sun Nov 23 16:00:00 4714 PST BC'::timestamptz" +== 120 +-- truncate_limit: 100 +SELECT '4714-11-23 23:59:59+00 BC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '4714-11-23 23:59:59+00 BC'::timestamptz" +== 121 +-- truncate_limit: 100 +-- out of range +SELECT '294276-12-31 23:59:59+00'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '294276-12-31 23:59:59+00'::timestamptz" +== 122 +-- truncate_limit: 100 +SELECT '294276-12-31 15:59:59-08'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '294276-12-31 15:59:59-08'::timestamptz" +== 123 +-- truncate_limit: 100 +SELECT '294277-01-01 00:00:00+00'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '294277-01-01 00:00:00+00'::timestamptz" +== 124 +-- truncate_limit: 100 +-- out of range +SELECT '294277-12-31 16:00:00-08'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '294277-12-31 16:00:00-08'::timestamptz" +== 125 +-- truncate_limit: 100 +-- out of range + +-- Demonstrate functions and operators +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 > timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamptz_tbl WHERE d1 > '1997-01-02'::timestamp with time zone" +== 126 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 < timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamptz_tbl WHERE d1 < '1997-01-02'::timestamp with time zone" +== 127 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 = timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamptz_tbl WHERE d1 = '1997-01-02'::timestamp with time zone" +== 128 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 != timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamptz_tbl WHERE d1 <> '1997-01-02'::timestamp with time zone" +== 129 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 <= timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamptz_tbl WHERE d1 <= '1997-01-02'::timestamp with time zone" +== 130 +-- truncate_limit: 100 +SELECT d1 FROM TIMESTAMPTZ_TBL + WHERE d1 >= timestamp with time zone '1997-01-02' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 FROM timestamptz_tbl WHERE d1 >= '1997-01-02'::timestamp with time zone" +== 131 +-- truncate_limit: 100 +SELECT d1 - timestamp with time zone '1997-01-02' AS diff + FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'" +== 132 +-- truncate_limit: 100 +SELECT date_trunc( 'week', timestamp with time zone '2004-02-29 15:44:17.71393' ) AS week_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('week', '2004-02-29 15:44:17.71393'::timestamp with time zone) AS week_trunc" +== 133 +-- truncate_limit: 100 +SELECT date_trunc('day', timestamp with time zone '2001-02-16 20:38:40+00', 'Australia/Sydney') as sydney_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 134 +-- truncate_limit: 100 +-- zone name +SELECT date_trunc('day', timestamp with time zone '2001-02-16 20:38:40+00', 'GMT') as gmt_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('day', '2001-02-16 20:38:40+00'::timestamp with time zone, 'GMT') AS gmt_trunc" +== 135 +-- truncate_limit: 100 +-- fixed-offset abbreviation +SELECT date_trunc('day', timestamp with time zone '2001-02-16 20:38:40+00', 'VET') as vet_trunc +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_trunc('day', '2001-02-16 20:38:40+00'::timestamp with time zone, 'VET') AS vet_trunc" +== 136 +-- truncate_limit: 100 +-- variable-offset abbreviation + +-- verify date_bin behaves the same as date_trunc for relevant intervals +SELECT + str, + interval, + date_trunc(str, ts, 'Australia/Sydney') = date_bin(interval::interval, ts, timestamp with time zone '2001-01-01+11') AS equal +FROM ( + VALUES + ('day', '1 d'), + ('hour', '1 h'), + ('minute', '1 m'), + ('second', '1 s'), + ('millisecond', '1 ms'), + ('microsecond', '1 us') +) intervals (str, interval), +(VALUES (timestamptz '2020-02-29 15:44:17.71393+00')) ts (ts) +-- +FUNCTION: name="date_trunc" function="date_trunc" schema="" ctx=Call +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) intervals(str, \"interval\"), (VALUES (...)) ts(ts)" +== 137 +-- truncate_limit: 100 +-- bin timestamps into arbitrary intervals +SELECT + interval, + ts, + origin, + date_bin(interval::interval, ts, origin) +FROM ( + VALUES + ('15 days'), + ('2 hours'), + ('1 hour 30 minutes'), + ('15 minutes'), + ('10 seconds'), + ('100 milliseconds'), + ('250 microseconds') +) intervals (interval), +(VALUES (timestamptz '2020-02-11 15:44:17.71393')) ts (ts), +(VALUES (timestamptz '2001-01-01')) origin (origin) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) intervals(\"interval\"), (VALUES (...)) ts(ts), (VALUES (...)) origi..." +== 138 +-- truncate_limit: 100 +-- shift bins using the origin parameter: +SELECT date_bin('5 min'::interval, timestamptz '2020-02-01 01:01:01+00', timestamptz '2020-02-01 00:02:30+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 139 +-- truncate_limit: 100 +-- test roundoff edge case when source < origin +SELECT date_bin('30 minutes'::interval, timestamptz '2024-02-01 15:00:00', timestamptz '2024-02-01 17:00:00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 140 +-- truncate_limit: 100 +-- disallow intervals with months or years +SELECT date_bin('5 months'::interval, timestamp with time zone '2020-02-01 01:01:01+00', timestamp with time zone '2001-01-01+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 141 +-- truncate_limit: 100 +SELECT date_bin('5 years'::interval, timestamp with time zone '2020-02-01 01:01:01+00', timestamp with time zone '2001-01-01+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 142 +-- truncate_limit: 100 +-- disallow zero intervals +SELECT date_bin('0 days'::interval, timestamp with time zone '1970-01-01 01:00:00+00' , timestamp with time zone '1970-01-01 00:00:00+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 143 +-- truncate_limit: 100 +-- disallow negative intervals +SELECT date_bin('-2 days'::interval, timestamp with time zone '1970-01-01 01:00:00+00' , timestamp with time zone '1970-01-01 00:00:00+00') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 144 +-- truncate_limit: 100 +-- test overflow cases +select date_bin('15 minutes'::interval, timestamptz '294276-12-30', timestamptz '4000-12-20 BC') +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('15 minutes'::interval, '294276-12-30'::timestamptz, '4000-12-20 BC'::timestamptz)" +== 145 +-- truncate_limit: 100 +select date_bin('200000000 days'::interval, '2024-02-01'::timestamptz, '2024-01-01'::timestamptz) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('200000000 days'::interval, '2024-02-01'::timestamptz, '2024-01-01'::timestamptz)" +== 146 +-- truncate_limit: 100 +select date_bin('365000 days'::interval, '4400-01-01 BC'::timestamptz, '4000-01-01 BC'::timestamptz) +-- +FUNCTION: name="date_bin" function="date_bin" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_bin('365000 days'::interval, '4400-01-01 BC'::timestamptz, '4000-01-01 BC'::timestamptz)" +== 147 +-- truncate_limit: 100 +-- Test casting within a BETWEEN qualifier +SELECT d1 - timestamp with time zone '1997-01-02' AS diff + FROM TIMESTAMPTZ_TBL + WHERE d1 BETWEEN timestamp with time zone '1902-01-01' AND timestamp with time zone '2038-01-01' +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FILTER: schema="" table="" column="d1" +STMT: SelectStmt +TRUNCATED: "SELECT d1 - '1997-01-02'::timestamp with time zone AS diff FROM timestamptz_tbl WHERE ..." +== 148 +-- truncate_limit: 100 +-- DATE_PART (timestamptz_part) +SELECT d1 as timestamptz, + date_part( 'year', d1) AS year, date_part( 'month', d1) AS month, + date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour, + date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl" +== 149 +-- truncate_limit: 100 +SELECT d1 as timestamptz, + date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec, + date_part( 'usec', d1) AS usec + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl" +== 150 +-- truncate_limit: 100 +SELECT d1 as timestamptz, + date_part( 'isoyear', d1) AS isoyear, date_part( 'week', d1) AS week, + date_part( 'isodow', d1) AS isodow, date_part( 'dow', d1) AS dow, + date_part( 'doy', d1) AS doy + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl" +== 151 +-- truncate_limit: 100 +SELECT d1 as timestamptz, + date_part( 'decade', d1) AS decade, + date_part( 'century', d1) AS century, + date_part( 'millennium', d1) AS millennium, + round(date_part( 'julian', d1)) AS julian, + date_part( 'epoch', d1) AS epoch + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl" +== 152 +-- truncate_limit: 100 +SELECT d1 as timestamptz, + date_part( 'timezone', d1) AS timezone, + date_part( 'timezone_hour', d1) AS timezone_hour, + date_part( 'timezone_minute', d1) AS timezone_minute + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl" +== 153 +-- truncate_limit: 100 +-- extract implementation is mostly the same as date_part, so only +-- test a few cases for additional coverage. +SELECT d1 as "timestamp", + extract(microseconds from d1) AS microseconds, + extract(milliseconds from d1) AS milliseconds, + extract(seconds from d1) AS seconds, + round(extract(julian from d1)) AS julian, + extract(epoch from d1) AS epoch + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="round" function="round" schema="" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl" +== 154 +-- truncate_limit: 100 +-- value near upper bound uses special case in code +SELECT date_part('epoch', '294270-01-01 00:00:00+00'::timestamptz) +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('epoch', '294270-01-01 00:00:00+00'::timestamptz)" +== 155 +-- truncate_limit: 100 +SELECT extract(epoch from '294270-01-01 00:00:00+00'::timestamptz) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '294270-01-01 00:00:00+00'::timestamptz)" +== 156 +-- truncate_limit: 100 +-- another internal overflow test case +SELECT extract(epoch from '5000-01-01 00:00:00+00'::timestamptz) +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '5000-01-01 00:00:00+00'::timestamptz)" +== 157 +-- truncate_limit: 100 +-- test edge-case overflow in timestamp subtraction +SELECT timestamptz '294276-12-31 23:59:59 UTC' - timestamptz '1999-12-23 19:59:04.224193 UTC' AS ok +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 158 +-- truncate_limit: 100 +SELECT timestamptz '294276-12-31 23:59:59 UTC' - timestamptz '1999-12-23 19:59:04.224192 UTC' AS overflows +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 159 +-- truncate_limit: 100 +-- TO_CHAR() +SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') FROM timestamptz_tbl" +== 160 +-- truncate_limit: 100 +SELECT to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM') FROM timestamptz_tbl" +== 161 +-- truncate_limit: 100 +SELECT to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J') FROM timestamptz_tbl" +== 162 +-- truncate_limit: 100 +SELECT to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl" +== 163 +-- truncate_limit: 100 +SELECT to_char(d1, 'HH HH12 HH24 MI SS SSSS') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'HH HH12 HH24 MI SS SSSS') FROM timestamptz_tbl" +== 164 +-- truncate_limit: 100 +SELECT to_char(d1, E'"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, E'\"HH:MI:SS is\" HH:MI:SS \"\\\\\"text between quote marks\\\\\"\"') FROM timestamptz_tbl" +== 165 +-- truncate_limit: 100 +SELECT to_char(d1, 'HH24--text--MI--text--SS') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'HH24--text--MI--text--SS') FROM timestamptz_tbl" +== 166 +-- truncate_limit: 100 +SELECT to_char(d1, 'YYYYTH YYYYth Jth') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'YYYYTH YYYYth Jth') FROM timestamptz_tbl" +== 167 +-- truncate_limit: 100 +SELECT to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timestamptz_tbl" +== 168 +-- truncate_limit: 100 +SELECT to_char(d1, 'IYYY IYY IY I IW IDDD ID') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'IYYY IYY IY I IW IDDD ID') FROM timestamptz_tbl" +== 169 +-- truncate_limit: 100 +SELECT to_char(d1, 'FMIYYY FMIYY FMIY FMI FMIW FMIDDD FMID') + FROM TIMESTAMPTZ_TBL +-- +TABLE: name="timestamptz_tbl" schema="" table="timestamptz_tbl" ctx=Select +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(d1, 'FMIYYY FMIYY FMIY FMI FMIW FMIDDD FMID') FROM timestamptz_tbl" +== 170 +-- truncate_limit: 100 +SELECT to_char(d, 'FF1 FF2 FF3 FF4 FF5 FF6 ff1 ff2 ff3 ff4 ff5 ff6 MS US') + FROM (VALUES + ('2018-11-02 12:34:56'::timestamptz), + ('2018-11-02 12:34:56.78'), + ('2018-11-02 12:34:56.78901'), + ('2018-11-02 12:34:56.78901234') + ) d(d) +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) d(d)" +== 171 +-- truncate_limit: 100 +-- Check OF, TZH, TZM with various zone offsets, particularly fractional hours +SET timezone = '00:00' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"00:00\"" +== 172 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 173 +-- truncate_limit: 100 +SET timezone = '+02:00' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"+02:00\"" +== 174 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 175 +-- truncate_limit: 100 +SET timezone = '-13:00' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-13:00\"" +== 176 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 177 +-- truncate_limit: 100 +SET timezone = '-00:30' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-00:30\"" +== 178 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 179 +-- truncate_limit: 100 +SET timezone = '00:30' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"00:30\"" +== 180 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 181 +-- truncate_limit: 100 +SET timezone = '-04:30' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-04:30\"" +== 182 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 183 +-- truncate_limit: 100 +SET timezone = '04:30' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"04:30\"" +== 184 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 185 +-- truncate_limit: 100 +SET timezone = '-04:15' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-04:15\"" +== 186 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 187 +-- truncate_limit: 100 +SET timezone = '04:15' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"04:15\"" +== 188 +-- truncate_limit: 100 +SELECT to_char(now(), 'OF') as "OF", to_char(now(), 'TZH:TZM') as "TZH:TZM" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'OF') AS \"OF\", to_char(now(), 'TZH:TZM') AS \"TZH:TZM\"" +== 189 +-- truncate_limit: 100 +RESET timezone +-- +STMT: VariableSetStmt +TRUNCATED: "RESET timezone" +== 190 +-- truncate_limit: 100 +-- Check of, tzh, tzm with various zone offsets. +SET timezone = '00:00' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"00:00\"" +== 191 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "Of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS \"Of\", to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 192 +-- truncate_limit: 100 +SET timezone = '+02:00' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"+02:00\"" +== 193 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS of, to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 194 +-- truncate_limit: 100 +SET timezone = '-13:00' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-13:00\"" +== 195 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS of, to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 196 +-- truncate_limit: 100 +SET timezone = '-00:30' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-00:30\"" +== 197 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS of, to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 198 +-- truncate_limit: 100 +SET timezone = '00:30' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"00:30\"" +== 199 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS of, to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 200 +-- truncate_limit: 100 +SET timezone = '-04:30' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-04:30\"" +== 201 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS of, to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 202 +-- truncate_limit: 100 +SET timezone = '04:30' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"04:30\"" +== 203 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS of, to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 204 +-- truncate_limit: 100 +SET timezone = '-04:15' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"-04:15\"" +== 205 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS of, to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 206 +-- truncate_limit: 100 +SET timezone = '04:15' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"04:15\"" +== 207 +-- truncate_limit: 100 +SELECT to_char(now(), 'of') as "of", to_char(now(), 'tzh:tzm') as "tzh:tzm" +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_char(now(), 'of') AS of, to_char(now(), 'tzh:tzm') AS \"tzh:tzm\"" +== 208 +-- truncate_limit: 100 +RESET timezone +-- +STMT: VariableSetStmt +TRUNCATED: "RESET timezone" +== 209 +-- truncate_limit: 100 +CREATE TABLE TIMESTAMPTZ_TST (a int , b timestamptz) +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE timestamptz_tst (a int, b timestamptz)" +== 210 +-- truncate_limit: 100 +-- Test year field value with len > 4 +INSERT INTO TIMESTAMPTZ_TST VALUES(1, 'Sat Mar 12 23:58:48 1000 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tst VALUES (1, 'Sat Mar 12 23:58:48 1000 IST')" +== 211 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TST VALUES(2, 'Sat Mar 12 23:58:48 10000 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tst VALUES (2, 'Sat Mar 12 23:58:48 10000 IST')" +== 212 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TST VALUES(3, 'Sat Mar 12 23:58:48 100000 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tst VALUES (3, 'Sat Mar 12 23:58:48 100000 IST')" +== 213 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TST VALUES(3, '10000 Mar 12 23:58:48 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tst VALUES (3, '10000 Mar 12 23:58:48 IST')" +== 214 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TST VALUES(4, '100000312 23:58:48 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tst VALUES (4, '100000312 23:58:48 IST')" +== 215 +-- truncate_limit: 100 +INSERT INTO TIMESTAMPTZ_TST VALUES(4, '1000000312 23:58:48 IST') +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timestamptz_tst VALUES (4, '1000000312 23:58:48 IST')" +== 216 +-- truncate_limit: 100 +--Verify data +SELECT * FROM TIMESTAMPTZ_TST ORDER BY a +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM timestamptz_tst ORDER BY a" +== 217 +-- truncate_limit: 100 +--Cleanup +DROP TABLE TIMESTAMPTZ_TST +-- +TABLE: name="timestamptz_tst" schema="" table="timestamptz_tst" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE timestamptz_tst" +== 218 +-- truncate_limit: 100 +-- test timestamptz constructors +set TimeZone to 'America/New_York' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"America/New_York\"" +== 219 +-- truncate_limit: 100 +-- numeric timezone +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33) +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1973, 7, 15, 8, 15, 55.33)" +== 220 +-- truncate_limit: 100 +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '+2') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1973, 7, 15, 8, 15, 55.33, '+2')" +== 221 +-- truncate_limit: 100 +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '-2') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1973, 7, 15, 8, 15, 55.33, '-2')" +== 222 +-- truncate_limit: 100 +WITH tzs (tz) AS (VALUES + ('+1'), ('+1:'), ('+1:0'), ('+100'), ('+1:00'), ('+01:00'), + ('+10'), ('+1000'), ('+10:'), ('+10:0'), ('+10:00'), ('+10:00:'), + ('+10:00:1'), ('+10:00:01'), + ('+10:00:10')) + SELECT make_timestamptz(2010, 2, 27, 3, 45, 00, tz), tz FROM tzs +-- +CTE: "tzs" +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH tzs(tz) AS (VALUES (...)) SELECT make_timestamptz(2010, 2, 27, 3, 45, 0, tz), tz FROM tzs" +== 223 +-- truncate_limit: 100 +-- these should fail +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '2') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1973, 7, 15, 8, 15, 55.33, '2')" +== 224 +-- truncate_limit: 100 +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '+16') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '+16')" +== 225 +-- truncate_limit: 100 +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '-16') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, '-16')" +== 226 +-- truncate_limit: 100 +-- should be true +SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33, '+2') = '1973-07-15 08:15:55.33+02'::timestamptz +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1973, 7, 15, 8, 15, 55.33, '+2') = '1973-07-15 08:15:55.33+02'::timestamptz" +== 227 +-- truncate_limit: 100 +-- full timezone names +SELECT make_timestamptz(2014, 12, 10, 0, 0, 0, 'Europe/Prague') = timestamptz '2014-12-10 00:00:00 Europe/Prague' +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 228 +-- truncate_limit: 100 +SELECT make_timestamptz(2014, 12, 10, 0, 0, 0, 'Europe/Prague') AT TIME ZONE 'UTC' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2014, 12, 10, 0, 0, 0, 'Europe/Prague') AT TIME ZONE 'UTC'" +== 229 +-- truncate_limit: 100 +SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Asia/Singapore') AT TIME ZONE 'UTC' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Asia/Singapore') AT TIME ZONE 'UTC'" +== 230 +-- truncate_limit: 100 +SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Pacific/Honolulu') AT TIME ZONE 'UTC' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Pacific/Honolulu') AT TIME ZONE 'UTC'" +== 231 +-- truncate_limit: 100 +SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Europe/Paris') AT TIME ZONE 'UTC' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1881, 12, 10, 0, 0, 0, 'Europe/Paris') AT TIME ZONE 'UTC'" +== 232 +-- truncate_limit: 100 +SELECT make_timestamptz(1910, 12, 24, 0, 0, 0, 'Nehwon/Lankhmar') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(1910, 12, 24, 0, 0, 0, 'Nehwon/Lankhmar')" +== 233 +-- truncate_limit: 100 +-- abbreviations +SELECT make_timestamptz(2008, 12, 10, 10, 10, 10, 'EST') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2008, 12, 10, 10, 10, 10, 'EST')" +== 234 +-- truncate_limit: 100 +SELECT make_timestamptz(2008, 12, 10, 10, 10, 10, 'EDT') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2008, 12, 10, 10, 10, 10, 'EDT')" +== 235 +-- truncate_limit: 100 +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, 'FOO8BAR') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, 'FOO8BAR')" +== 236 +-- truncate_limit: 100 +-- POSIX +SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, 'PST8PDT,M3.2.0,M11.1.0') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2014, 12, 10, 10, 10, 10, 'PST8PDT,M3.2.0,M11.1.0')" +== 237 +-- truncate_limit: 100 +RESET TimeZone +-- +STMT: VariableSetStmt +TRUNCATED: "RESET timezone" +== 238 +-- truncate_limit: 100 +-- generate_series for timestamptz +select * from generate_series('2020-01-01 00:00'::timestamptz, + '2020-01-02 03:00'::timestamptz, + '1 hour'::interval) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('2020-01-01 00:00'::timestamptz, '2020-01-02 03:00'::timestamptz, '..." +== 239 +-- truncate_limit: 100 +-- the LIMIT should allow this to terminate in a reasonable amount of time +-- (but that unfortunately doesn't work yet for SELECT * FROM ...) +select generate_series('2022-01-01 00:00'::timestamptz, + 'infinity'::timestamptz, + '1 month'::interval) limit 10 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... LIMIT 10" +== 240 +-- truncate_limit: 100 +-- errors +select * from generate_series('2020-01-01 00:00'::timestamptz, + '2020-01-02 03:00'::timestamptz, + '0 hour'::interval) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('2020-01-01 00:00'::timestamptz, '2020-01-02 03:00'::timestamptz, '..." +== 241 +-- truncate_limit: 100 +select generate_series(timestamptz '1995-08-06 12:12:12', timestamptz '1996-08-06 12:12:12', interval 'infinity') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 242 +-- truncate_limit: 100 +select generate_series(timestamptz '1995-08-06 12:12:12', timestamptz '1996-08-06 12:12:12', interval '-infinity') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 243 +-- truncate_limit: 100 +-- Interval crossing time shift for Europe/Warsaw timezone (with DST) +SET TimeZone to 'UTC' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"UTC\"" +== 244 +-- truncate_limit: 100 +SELECT date_add('2022-10-30 00:00:00+01'::timestamptz, + '1 day'::interval) +-- +FUNCTION: name="date_add" function="date_add" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_add('2022-10-30 00:00:00+01'::timestamptz, '1 day'::interval)" +== 245 +-- truncate_limit: 100 +SELECT date_add('2021-10-31 00:00:00+02'::timestamptz, + '1 day'::interval, + 'Europe/Warsaw') +-- +FUNCTION: name="date_add" function="date_add" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_add('2021-10-31 00:00:00+02'::timestamptz, '1 day'::interval, 'Europe/Warsaw')" +== 246 +-- truncate_limit: 100 +SELECT date_subtract('2022-10-30 00:00:00+01'::timestamptz, + '1 day'::interval) +-- +FUNCTION: name="date_subtract" function="date_subtract" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_subtract('2022-10-30 00:00:00+01'::timestamptz, '1 day'::interval)" +== 247 +-- truncate_limit: 100 +SELECT date_subtract('2021-10-31 00:00:00+02'::timestamptz, + '1 day'::interval, + 'Europe/Warsaw') +-- +FUNCTION: name="date_subtract" function="date_subtract" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_subtract('2021-10-31 00:00:00+02'::timestamptz, '1 day'::interval, 'Europe/Warsaw')" +== 248 +-- truncate_limit: 100 +SELECT * FROM generate_series('2021-12-31 23:00:00+00'::timestamptz, + '2020-12-31 23:00:00+00'::timestamptz, + '-1 month'::interval, + 'Europe/Warsaw') +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series('2021-12-31 23:00:00+00'::timestamptz, '2020-12-31 23:00:00+00'::ti..." +== 249 +-- truncate_limit: 100 +RESET TimeZone +-- +STMT: VariableSetStmt +TRUNCATED: "RESET timezone" +== 250 +-- truncate_limit: 100 +|-- +-- Test behavior with a dynamic (time-varying) timezone abbreviation. +-- These tests rely on the knowledge that MSK (Europe/Moscow standard time) +-- moved forwards in Mar 2011 and backwards again in Oct 2014. +|-- + +SET TimeZone to 'UTC' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"UTC\"" +== 251 +-- truncate_limit: 100 +SELECT '2011-03-27 00:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 00:00:00 Europe/Moscow'::timestamptz" +== 252 +-- truncate_limit: 100 +SELECT '2011-03-27 01:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 01:00:00 Europe/Moscow'::timestamptz" +== 253 +-- truncate_limit: 100 +SELECT '2011-03-27 01:59:59 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 01:59:59 Europe/Moscow'::timestamptz" +== 254 +-- truncate_limit: 100 +SELECT '2011-03-27 02:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:00:00 Europe/Moscow'::timestamptz" +== 255 +-- truncate_limit: 100 +SELECT '2011-03-27 02:00:01 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:00:01 Europe/Moscow'::timestamptz" +== 256 +-- truncate_limit: 100 +SELECT '2011-03-27 02:59:59 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:59:59 Europe/Moscow'::timestamptz" +== 257 +-- truncate_limit: 100 +SELECT '2011-03-27 03:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 03:00:00 Europe/Moscow'::timestamptz" +== 258 +-- truncate_limit: 100 +SELECT '2011-03-27 03:00:01 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 03:00:01 Europe/Moscow'::timestamptz" +== 259 +-- truncate_limit: 100 +SELECT '2011-03-27 04:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 04:00:00 Europe/Moscow'::timestamptz" +== 260 +-- truncate_limit: 100 +SELECT '2011-03-27 00:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 00:00:00 MSK'::timestamptz" +== 261 +-- truncate_limit: 100 +SELECT '2011-03-27 01:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 01:00:00 MSK'::timestamptz" +== 262 +-- truncate_limit: 100 +SELECT '2011-03-27 01:59:59 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 01:59:59 MSK'::timestamptz" +== 263 +-- truncate_limit: 100 +SELECT '2011-03-27 02:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:00:00 MSK'::timestamptz" +== 264 +-- truncate_limit: 100 +SELECT '2011-03-27 02:00:01 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:00:01 MSK'::timestamptz" +== 265 +-- truncate_limit: 100 +SELECT '2011-03-27 02:59:59 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:59:59 MSK'::timestamptz" +== 266 +-- truncate_limit: 100 +SELECT '2011-03-27 03:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 03:00:00 MSK'::timestamptz" +== 267 +-- truncate_limit: 100 +SELECT '2011-03-27 03:00:01 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 03:00:01 MSK'::timestamptz" +== 268 +-- truncate_limit: 100 +SELECT '2011-03-27 04:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 04:00:00 MSK'::timestamptz" +== 269 +-- truncate_limit: 100 +SELECT '2014-10-26 00:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 00:00:00 Europe/Moscow'::timestamptz" +== 270 +-- truncate_limit: 100 +SELECT '2014-10-26 00:59:59 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 00:59:59 Europe/Moscow'::timestamptz" +== 271 +-- truncate_limit: 100 +SELECT '2014-10-26 01:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 01:00:00 Europe/Moscow'::timestamptz" +== 272 +-- truncate_limit: 100 +SELECT '2014-10-26 01:00:01 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 01:00:01 Europe/Moscow'::timestamptz" +== 273 +-- truncate_limit: 100 +SELECT '2014-10-26 02:00:00 Europe/Moscow'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 02:00:00 Europe/Moscow'::timestamptz" +== 274 +-- truncate_limit: 100 +SELECT '2014-10-26 00:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 00:00:00 MSK'::timestamptz" +== 275 +-- truncate_limit: 100 +SELECT '2014-10-26 00:59:59 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 00:59:59 MSK'::timestamptz" +== 276 +-- truncate_limit: 100 +SELECT '2014-10-26 01:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 01:00:00 MSK'::timestamptz" +== 277 +-- truncate_limit: 100 +SELECT '2014-10-26 01:00:01 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 01:00:01 MSK'::timestamptz" +== 278 +-- truncate_limit: 100 +SELECT '2014-10-26 02:00:00 MSK'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 02:00:00 MSK'::timestamptz" +== 279 +-- truncate_limit: 100 +SELECT '2011-03-27 00:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 00:00:00'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 280 +-- truncate_limit: 100 +SELECT '2011-03-27 01:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 01:00:00'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 281 +-- truncate_limit: 100 +SELECT '2011-03-27 01:59:59'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 01:59:59'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 282 +-- truncate_limit: 100 +SELECT '2011-03-27 02:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:00:00'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 283 +-- truncate_limit: 100 +SELECT '2011-03-27 02:00:01'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:00:01'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 284 +-- truncate_limit: 100 +SELECT '2011-03-27 02:59:59'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:59:59'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 285 +-- truncate_limit: 100 +SELECT '2011-03-27 03:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 03:00:00'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 286 +-- truncate_limit: 100 +SELECT '2011-03-27 03:00:01'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 03:00:01'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 287 +-- truncate_limit: 100 +SELECT '2011-03-27 04:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 04:00:00'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 288 +-- truncate_limit: 100 +SELECT '2011-03-27 00:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 00:00:00'::timestamp AT TIME ZONE 'MSK'" +== 289 +-- truncate_limit: 100 +SELECT '2011-03-27 01:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 01:00:00'::timestamp AT TIME ZONE 'MSK'" +== 290 +-- truncate_limit: 100 +SELECT '2011-03-27 01:59:59'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 01:59:59'::timestamp AT TIME ZONE 'MSK'" +== 291 +-- truncate_limit: 100 +SELECT '2011-03-27 02:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:00:00'::timestamp AT TIME ZONE 'MSK'" +== 292 +-- truncate_limit: 100 +SELECT '2011-03-27 02:00:01'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:00:01'::timestamp AT TIME ZONE 'MSK'" +== 293 +-- truncate_limit: 100 +SELECT '2011-03-27 02:59:59'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 02:59:59'::timestamp AT TIME ZONE 'MSK'" +== 294 +-- truncate_limit: 100 +SELECT '2011-03-27 03:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 03:00:00'::timestamp AT TIME ZONE 'MSK'" +== 295 +-- truncate_limit: 100 +SELECT '2011-03-27 03:00:01'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 03:00:01'::timestamp AT TIME ZONE 'MSK'" +== 296 +-- truncate_limit: 100 +SELECT '2011-03-27 04:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 04:00:00'::timestamp AT TIME ZONE 'MSK'" +== 297 +-- truncate_limit: 100 +SELECT '2014-10-26 00:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 00:00:00'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 298 +-- truncate_limit: 100 +SELECT '2014-10-26 00:59:59'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 00:59:59'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 299 +-- truncate_limit: 100 +SELECT '2014-10-26 01:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 01:00:00'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 300 +-- truncate_limit: 100 +SELECT '2014-10-26 01:00:01'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 01:00:01'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 301 +-- truncate_limit: 100 +SELECT '2014-10-26 02:00:00'::timestamp AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 02:00:00'::timestamp AT TIME ZONE 'Europe/Moscow'" +== 302 +-- truncate_limit: 100 +SELECT '2014-10-26 00:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 00:00:00'::timestamp AT TIME ZONE 'MSK'" +== 303 +-- truncate_limit: 100 +SELECT '2014-10-26 00:59:59'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 00:59:59'::timestamp AT TIME ZONE 'MSK'" +== 304 +-- truncate_limit: 100 +SELECT '2014-10-26 01:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 01:00:00'::timestamp AT TIME ZONE 'MSK'" +== 305 +-- truncate_limit: 100 +SELECT '2014-10-26 01:00:01'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 01:00:01'::timestamp AT TIME ZONE 'MSK'" +== 306 +-- truncate_limit: 100 +SELECT '2014-10-26 02:00:00'::timestamp AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-26 02:00:00'::timestamp AT TIME ZONE 'MSK'" +== 307 +-- truncate_limit: 100 +SELECT make_timestamptz(2014, 10, 26, 0, 0, 0, 'MSK') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2014, 10, 26, 0, 0, 0, 'MSK')" +== 308 +-- truncate_limit: 100 +SELECT make_timestamptz(2014, 10, 26, 1, 0, 0, 'MSK') +-- +FUNCTION: name="make_timestamptz" function="make_timestamptz" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT make_timestamptz(2014, 10, 26, 1, 0, 0, 'MSK')" +== 309 +-- truncate_limit: 100 +SELECT to_timestamp( 0) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(0)" +== 310 +-- truncate_limit: 100 +-- 1970-01-01 00:00:00+00 +SELECT to_timestamp( 946684800) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(946684800)" +== 311 +-- truncate_limit: 100 +-- 2000-01-01 00:00:00+00 +SELECT to_timestamp(1262349296.7890123) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(1262349296.7890123)" +== 312 +-- truncate_limit: 100 +-- 2010-01-01 12:34:56.789012+00 +-- edge cases +SELECT to_timestamp(-210866803200) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(-210866803200)" +== 313 +-- truncate_limit: 100 +-- 4714-11-24 00:00:00+00 BC +-- upper limit varies between integer and float timestamps, so hard to test +-- nonfinite values +SELECT to_timestamp(' Infinity'::float) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp(' Infinity'::double precision)" +== 314 +-- truncate_limit: 100 +SELECT to_timestamp('-Infinity'::float) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('-Infinity'::double precision)" +== 315 +-- truncate_limit: 100 +SELECT to_timestamp('NaN'::float) +-- +FUNCTION: name="to_timestamp" function="to_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_timestamp('NaN'::double precision)" +== 316 +-- truncate_limit: 100 +SET TimeZone to 'Europe/Moscow' +-- +STMT: VariableSetStmt +TRUNCATED: "SET timezone TO \"Europe/Moscow\"" +== 317 +-- truncate_limit: 100 +SELECT '2011-03-26 21:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 21:00:00 UTC'::timestamptz" +== 318 +-- truncate_limit: 100 +SELECT '2011-03-26 22:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 22:00:00 UTC'::timestamptz" +== 319 +-- truncate_limit: 100 +SELECT '2011-03-26 22:59:59 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 22:59:59 UTC'::timestamptz" +== 320 +-- truncate_limit: 100 +SELECT '2011-03-26 23:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:00:00 UTC'::timestamptz" +== 321 +-- truncate_limit: 100 +SELECT '2011-03-26 23:00:01 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:00:01 UTC'::timestamptz" +== 322 +-- truncate_limit: 100 +SELECT '2011-03-26 23:59:59 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:59:59 UTC'::timestamptz" +== 323 +-- truncate_limit: 100 +SELECT '2011-03-27 00:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 00:00:00 UTC'::timestamptz" +== 324 +-- truncate_limit: 100 +SELECT '2014-10-25 21:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 21:00:00 UTC'::timestamptz" +== 325 +-- truncate_limit: 100 +SELECT '2014-10-25 21:59:59 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 21:59:59 UTC'::timestamptz" +== 326 +-- truncate_limit: 100 +SELECT '2014-10-25 22:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 22:00:00 UTC'::timestamptz" +== 327 +-- truncate_limit: 100 +SELECT '2014-10-25 22:00:01 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 22:00:01 UTC'::timestamptz" +== 328 +-- truncate_limit: 100 +SELECT '2014-10-25 23:00:00 UTC'::timestamptz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 23:00:00 UTC'::timestamptz" +== 329 +-- truncate_limit: 100 +RESET TimeZone +-- +STMT: VariableSetStmt +TRUNCATED: "RESET timezone" +== 330 +-- truncate_limit: 100 +SELECT '2011-03-26 21:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 21:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 331 +-- truncate_limit: 100 +SELECT '2011-03-26 22:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 22:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 332 +-- truncate_limit: 100 +SELECT '2011-03-26 22:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 22:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 333 +-- truncate_limit: 100 +SELECT '2011-03-26 23:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 334 +-- truncate_limit: 100 +SELECT '2011-03-26 23:00:01 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:00:01 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 335 +-- truncate_limit: 100 +SELECT '2011-03-26 23:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 336 +-- truncate_limit: 100 +SELECT '2011-03-27 00:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 00:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 337 +-- truncate_limit: 100 +SELECT '2014-10-25 21:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 21:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 338 +-- truncate_limit: 100 +SELECT '2014-10-25 21:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 21:59:59 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 339 +-- truncate_limit: 100 +SELECT '2014-10-25 22:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 22:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 340 +-- truncate_limit: 100 +SELECT '2014-10-25 22:00:01 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 22:00:01 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 341 +-- truncate_limit: 100 +SELECT '2014-10-25 23:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 23:00:00 UTC'::timestamptz AT TIME ZONE 'Europe/Moscow'" +== 342 +-- truncate_limit: 100 +SELECT '2011-03-26 21:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 21:00:00 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 343 +-- truncate_limit: 100 +SELECT '2011-03-26 22:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 22:00:00 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 344 +-- truncate_limit: 100 +SELECT '2011-03-26 22:59:59 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 22:59:59 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 345 +-- truncate_limit: 100 +SELECT '2011-03-26 23:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:00:00 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 346 +-- truncate_limit: 100 +SELECT '2011-03-26 23:00:01 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:00:01 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 347 +-- truncate_limit: 100 +SELECT '2011-03-26 23:59:59 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-26 23:59:59 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 348 +-- truncate_limit: 100 +SELECT '2011-03-27 00:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2011-03-27 00:00:00 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 349 +-- truncate_limit: 100 +SELECT '2014-10-25 21:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 21:00:00 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 350 +-- truncate_limit: 100 +SELECT '2014-10-25 21:59:59 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 21:59:59 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 351 +-- truncate_limit: 100 +SELECT '2014-10-25 22:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 22:00:00 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 352 +-- truncate_limit: 100 +SELECT '2014-10-25 22:00:01 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 22:00:01 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 353 +-- truncate_limit: 100 +SELECT '2014-10-25 23:00:00 UTC'::timestamptz AT TIME ZONE 'MSK' +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT '2014-10-25 23:00:00 UTC'::timestamptz AT TIME ZONE 'MSK'" +== 354 +-- truncate_limit: 100 +|-- +-- Test LOCAL time zone +|-- +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 355 +-- truncate_limit: 100 +SET LOCAL TIME ZONE 'Europe/Paris' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO \"Europe/Paris\"" +== 356 +-- truncate_limit: 100 +VALUES (CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "VALUES ('1978-07-07 19:38 America/New_York'::timestamp with time zone AT LOCAL)" +== 357 +-- truncate_limit: 100 +VALUES (TIMESTAMP '1978-07-07 19:38' AT LOCAL) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "VALUES ('1978-07-07 19:38'::timestamp AT LOCAL)" +== 358 +-- truncate_limit: 100 +SET LOCAL TIME ZONE 'Australia/Sydney' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO \"Australia/Sydney\"" +== 359 +-- truncate_limit: 100 +VALUES (CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "VALUES ('1978-07-07 19:38 America/New_York'::timestamp with time zone AT LOCAL)" +== 360 +-- truncate_limit: 100 +VALUES (TIMESTAMP '1978-07-07 19:38' AT LOCAL) +-- +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "VALUES ('1978-07-07 19:38'::timestamp AT LOCAL)" +== 361 +-- truncate_limit: 100 +SET LOCAL TimeZone TO 'UTC' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO \"UTC\"" +== 362 +-- truncate_limit: 100 +CREATE VIEW timestamp_local_view AS + SELECT CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE) AT LOCAL AS ttz_at_local, + timezone(CAST('1978-07-07 19:38 America/New_York' AS TIMESTAMP WITH TIME ZONE)) AS ttz_func, + TIMESTAMP '1978-07-07 19:38' AT LOCAL AS t_at_local, + timezone(TIMESTAMP '1978-07-07 19:38') AS t_func +-- +TABLE: name="timestamp_local_view" schema="" table="timestamp_local_view" ctx=DDL +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW timestamp_local_view AS SELECT '1978-07-07 19:38 America/New_York'::timestamp with ti..." +== 363 +-- truncate_limit: 100 +SELECT pg_get_viewdef('timestamp_local_view', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('timestamp_local_view', true)" +== 364 +-- truncate_limit: 100 +TABLE timestamp_local_view +-- +TABLE: name="timestamp_local_view" schema="" table="timestamp_local_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM timestamp_local_view" +== 365 +-- truncate_limit: 100 +DROP VIEW timestamp_local_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW timestamp_local_view" +== 366 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 367 +-- truncate_limit: 100 +|-- +-- Test that AT TIME ZONE isn't misoptimized when using an index (bug #14504) +|-- +create temp table tmptz (f1 timestamptz primary key) +-- +TABLE: name="tmptz" schema="" table="tmptz" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tmptz (f1 timestamptz PRIMARY KEY)" +== 368 +-- truncate_limit: 100 +insert into tmptz values ('2017-01-18 00:00+00') +-- +TABLE: name="tmptz" schema="" table="tmptz" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tmptz VALUES ('2017-01-18 00:00+00')" +== 369 +-- truncate_limit: 100 +explain (costs off) +select * from tmptz where f1 at time zone 'utc' = '2017-01-18 00:00' +-- +TABLE: name="tmptz" schema="" table="tmptz" ctx=Select +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tmptz WHERE f1 AT TIME ZONE 'utc' = '2017-01-18 00:00'" +== 370 +-- truncate_limit: 100 +select * from tmptz where f1 at time zone 'utc' = '2017-01-18 00:00' +-- +TABLE: name="tmptz" schema="" table="tmptz" ctx=Select +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tmptz WHERE f1 AT TIME ZONE 'utc' = '2017-01-18 00:00'" +== 371 +-- truncate_limit: 100 +-- test arithmetic with infinite timestamps +SELECT timestamptz 'infinity' - timestamptz 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::timestamptz - 'infinity'::timestamptz" +== 372 +-- truncate_limit: 100 +SELECT timestamptz 'infinity' - timestamptz '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::timestamptz - '-infinity'::timestamptz" +== 373 +-- truncate_limit: 100 +SELECT timestamptz '-infinity' - timestamptz 'infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::timestamptz - 'infinity'::timestamptz" +== 374 +-- truncate_limit: 100 +SELECT timestamptz '-infinity' - timestamptz '-infinity' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::timestamptz - '-infinity'::timestamptz" +== 375 +-- truncate_limit: 100 +SELECT timestamptz 'infinity' - timestamptz '1995-08-06 12:12:12' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'infinity'::timestamptz - '1995-08-06 12:12:12'::timestamptz" +== 376 +-- truncate_limit: 100 +SELECT timestamptz '-infinity' - timestamptz '1995-08-06 12:12:12' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '-infinity'::timestamptz - '1995-08-06 12:12:12'::timestamptz" +== 377 +-- truncate_limit: 100 +-- test age() with infinite timestamps +SELECT age(timestamptz 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('infinity'::timestamptz)" +== 378 +-- truncate_limit: 100 +SELECT age(timestamptz '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('-infinity'::timestamptz)" +== 379 +-- truncate_limit: 100 +SELECT age(timestamptz 'infinity', timestamptz 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('infinity'::timestamptz, 'infinity'::timestamptz)" +== 380 +-- truncate_limit: 100 +SELECT age(timestamptz 'infinity', timestamptz '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('infinity'::timestamptz, '-infinity'::timestamptz)" +== 381 +-- truncate_limit: 100 +SELECT age(timestamptz '-infinity', timestamptz 'infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('-infinity'::timestamptz, 'infinity'::timestamptz)" +== 382 +-- truncate_limit: 100 +SELECT age(timestamptz '-infinity', timestamptz '-infinity') +-- +FUNCTION: name="age" function="age" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT age('-infinity'::timestamptz, '-infinity'::timestamptz)" diff --git a/parser/testdata/summary_truncate/postgres_regress/timetz.metadata.json b/parser/testdata/summary_truncate/postgres_regress/timetz.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/timetz.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/timetz.test b/parser/testdata/summary_truncate/postgres_regress/timetz.test new file mode 100644 index 0000000..88761df --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/timetz.test @@ -0,0 +1,463 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TIMETZ +|-- + +CREATE TABLE TIMETZ_TBL (f1 time(2) with time zone) +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE timetz_tbl (f1 time (2) with time zone)" +== 002 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('00:01 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('00:01 PDT')" +== 003 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('01:00 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('01:00 PDT')" +== 004 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('02:03 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('02:03 PDT')" +== 005 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('07:07 PST') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('07:07 PST')" +== 006 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('08:08 EDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('08:08 EDT')" +== 007 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('11:59 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('11:59 PDT')" +== 008 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('12:00 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('12:00 PDT')" +== 009 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('12:01 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('12:01 PDT')" +== 010 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('23:59 PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('23:59 PDT')" +== 011 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('11:59:59.99 PM PDT') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('11:59:59.99 PM PDT')" +== 012 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('2003-03-07 15:36:39 America/New_York') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('2003-03-07 15:36:39 America/New_York')" +== 013 +-- truncate_limit: 100 +INSERT INTO TIMETZ_TBL VALUES ('2003-07-07 15:36:39 America/New_York') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('2003-07-07 15:36:39 America/New_York')" +== 014 +-- truncate_limit: 100 +-- this should fail (the timezone offset is not known) +INSERT INTO TIMETZ_TBL VALUES ('15:36:39 America/New_York') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('15:36:39 America/New_York')" +== 015 +-- truncate_limit: 100 +-- this should fail (timezone not specified without a date) +INSERT INTO TIMETZ_TBL VALUES ('15:36:39 m2') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('15:36:39 m2')" +== 016 +-- truncate_limit: 100 +-- this should fail (dynamic timezone abbreviation without a date) +INSERT INTO TIMETZ_TBL VALUES ('15:36:39 MSK m2') +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO timetz_tbl VALUES ('15:36:39 MSK m2')" +== 017 +-- truncate_limit: 100 +SELECT f1 AS "Time TZ" FROM TIMETZ_TBL +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Time TZ\" FROM timetz_tbl" +== 018 +-- truncate_limit: 100 +SELECT f1 AS "Three" FROM TIMETZ_TBL WHERE f1 < '05:06:07-07' +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Three\" FROM timetz_tbl WHERE f1 < '05:06:07-07'" +== 019 +-- truncate_limit: 100 +SELECT f1 AS "Seven" FROM TIMETZ_TBL WHERE f1 > '05:06:07-07' +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Seven\" FROM timetz_tbl WHERE f1 > '05:06:07-07'" +== 020 +-- truncate_limit: 100 +SELECT f1 AS "None" FROM TIMETZ_TBL WHERE f1 < '00:00-07' +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"None\" FROM timetz_tbl WHERE f1 < '00:00-07'" +== 021 +-- truncate_limit: 100 +SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00-07' +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS \"Ten\" FROM timetz_tbl WHERE f1 >= '00:00-07'" +== 022 +-- truncate_limit: 100 +-- Check edge cases +SELECT '23:59:59.999999 PDT'::timetz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '23:59:59.999999 PDT'::timetz" +== 023 +-- truncate_limit: 100 +SELECT '23:59:59.9999999 PDT'::timetz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '23:59:59.9999999 PDT'::timetz" +== 024 +-- truncate_limit: 100 +-- rounds up +SELECT '23:59:60 PDT'::timetz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '23:59:60 PDT'::timetz" +== 025 +-- truncate_limit: 100 +-- rounds up +SELECT '24:00:00 PDT'::timetz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '24:00:00 PDT'::timetz" +== 026 +-- truncate_limit: 100 +-- allowed +SELECT '24:00:00.01 PDT'::timetz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '24:00:00.01 PDT'::timetz" +== 027 +-- truncate_limit: 100 +-- not allowed +SELECT '23:59:60.01 PDT'::timetz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '23:59:60.01 PDT'::timetz" +== 028 +-- truncate_limit: 100 +-- not allowed +SELECT '24:01:00 PDT'::timetz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '24:01:00 PDT'::timetz" +== 029 +-- truncate_limit: 100 +-- not allowed +SELECT '25:00:00 PDT'::timetz +-- +STMT: SelectStmt +TRUNCATED: "SELECT '25:00:00 PDT'::timetz" +== 030 +-- truncate_limit: 100 +-- not allowed + +-- Test non-error-throwing API +SELECT pg_input_is_valid('12:00:00 PDT', 'timetz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('12:00:00 PDT', 'timetz')" +== 031 +-- truncate_limit: 100 +SELECT pg_input_is_valid('25:00:00 PDT', 'timetz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('25:00:00 PDT', 'timetz')" +== 032 +-- truncate_limit: 100 +SELECT pg_input_is_valid('15:36:39 America/New_York', 'timetz') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('15:36:39 America/New_York', 'timetz')" +== 033 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('25:00:00 PDT', 'timetz') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('25:00:00 PDT', 'timetz')" +== 034 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('15:36:39 America/New_York', 'timetz') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('15:36:39 America/New_York', 'timetz')" +== 035 +-- truncate_limit: 100 +|-- +-- TIME simple math +|-- +-- We now make a distinction between time and intervals, +-- and adding two times together makes no sense at all. +-- Leave in one query to show that it is rejected, +-- and do the rest of the testing in horology.sql +-- where we do mixed-type arithmetic. - thomas 2000-12-02 + +SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 + '00:01'::time with time zone AS \"Illegal\" FROM timetz_tbl" +== 036 +-- truncate_limit: 100 +|-- +-- test EXTRACT +|-- +SELECT EXTRACT(MICROSECOND FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('microsecond' FROM '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 037 +-- truncate_limit: 100 +SELECT EXTRACT(MILLISECOND FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('millisecond' FROM '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 038 +-- truncate_limit: 100 +SELECT EXTRACT(SECOND FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('second' FROM '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 039 +-- truncate_limit: 100 +SELECT EXTRACT(MINUTE FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('minute' FROM '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 040 +-- truncate_limit: 100 +SELECT EXTRACT(HOUR FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('hour' FROM '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 041 +-- truncate_limit: 100 +SELECT EXTRACT(DAY FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('day' FROM '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 042 +-- truncate_limit: 100 +-- error +SELECT EXTRACT(FORTNIGHT FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('fortnight' FROM '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 043 +-- truncate_limit: 100 +-- error +SELECT EXTRACT(TIMEZONE FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04:30') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('timezone' FROM '2020-05-26 13:30:25.575401-04:30'::time with time zone)" +== 044 +-- truncate_limit: 100 +SELECT EXTRACT(TIMEZONE_HOUR FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04:30') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('timezone_hour' FROM '2020-05-26 13:30:25.575401-04:30'::time with time zone)" +== 045 +-- truncate_limit: 100 +SELECT EXTRACT(TIMEZONE_MINUTE FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04:30') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('timezone_minute' FROM '2020-05-26 13:30:25.575401-04:30'::time with time zone)" +== 046 +-- truncate_limit: 100 +SELECT EXTRACT(EPOCH FROM TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT extract ('epoch' FROM '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 047 +-- truncate_limit: 100 +-- date_part implementation is mostly the same as extract, so only +-- test a few cases for additional coverage. +SELECT date_part('microsecond', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('microsecond', '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 048 +-- truncate_limit: 100 +SELECT date_part('millisecond', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('millisecond', '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 049 +-- truncate_limit: 100 +SELECT date_part('second', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('second', '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 050 +-- truncate_limit: 100 +SELECT date_part('epoch', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04') +-- +FUNCTION: name="date_part" function="date_part" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT date_part('epoch', '2020-05-26 13:30:25.575401-04'::time with time zone)" +== 051 +-- truncate_limit: 100 +|-- +-- Test timetz_zone, timetz_izone, AT LOCAL +|-- +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 052 +-- truncate_limit: 100 +SET LOCAL TimeZone TO 'UTC' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL timezone TO \"UTC\"" +== 053 +-- truncate_limit: 100 +CREATE VIEW timetz_local_view AS + SELECT f1 AS dat, + timezone(f1) AS dat_func, + f1 AT LOCAL AS dat_at_local, + f1 AT TIME ZONE current_setting('TimeZone') AS dat_at_tz, + f1 AT TIME ZONE INTERVAL '00:00' AS dat_at_int + FROM TIMETZ_TBL + ORDER BY f1 +-- +TABLE: name="timetz_local_view" schema="" table="timetz_local_view" ctx=DDL +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FUNCTION: name="timezone" function="timezone" schema="" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW timetz_local_view AS SELECT f1 AS dat, timezone(f1) AS dat_func, f1 AT LOCAL AS dat_a..." +== 054 +-- truncate_limit: 100 +SELECT pg_get_viewdef('timetz_local_view', true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('timetz_local_view', true)" +== 055 +-- truncate_limit: 100 +TABLE timetz_local_view +-- +TABLE: name="timetz_local_view" schema="" table="timetz_local_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM timetz_local_view" +== 056 +-- truncate_limit: 100 +SELECT f1 AS dat, + f1 AT TIME ZONE 'UTC+10' AS dat_at_tz, + f1 AT TIME ZONE INTERVAL '-10:00' AS dat_at_int + FROM TIMETZ_TBL + ORDER BY f1 +-- +TABLE: name="timetz_tbl" schema="" table="timetz_tbl" ctx=Select +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.timezone" function="timezone" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM timetz_tbl ORDER BY f1" +== 057 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" diff --git a/parser/testdata/summary_truncate/postgres_regress/transactions.metadata.json b/parser/testdata/summary_truncate/postgres_regress/transactions.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/transactions.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/transactions.test b/parser/testdata/summary_truncate/postgres_regress/transactions.test new file mode 100644 index 0000000..e0264d3 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/transactions.test @@ -0,0 +1,3477 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TRANSACTIONS +|-- + +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 002 +-- truncate_limit: 100 +CREATE TABLE xacttest (a smallint, b real) +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE xacttest (a smallint, b real)" +== 003 +-- truncate_limit: 100 +INSERT INTO xacttest VALUES + (56, 7.8), + (100, 99.097), + (0, 0.09561), + (42, 324.78) +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xacttest VALUES (56, 7.8), (100, 99.097), (0, 0.09561), (42, 324.78)" +== 004 +-- truncate_limit: 100 +INSERT INTO xacttest (a, b) VALUES (777, 777.777) +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xacttest (a, b) VALUES (777, 777.777)" +== 005 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 006 +-- truncate_limit: 100 +-- should retrieve one value-- +SELECT a FROM xacttest WHERE a > 100 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM xacttest WHERE a > 100" +== 007 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 008 +-- truncate_limit: 100 +CREATE TABLE disappear (a int4) +-- +TABLE: name="disappear" schema="" table="disappear" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE disappear (a int4)" +== 009 +-- truncate_limit: 100 +DELETE FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM xacttest" +== 010 +-- truncate_limit: 100 +-- should be empty +SELECT * FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xacttest" +== 011 +-- truncate_limit: 100 +ABORT +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 012 +-- truncate_limit: 100 +-- should not exist +SELECT oid FROM pg_class WHERE relname = 'disappear' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT oid FROM pg_class WHERE relname = 'disappear'" +== 013 +-- truncate_limit: 100 +-- should have members again +SELECT * FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xacttest" +== 014 +-- truncate_limit: 100 +-- Test that transaction characteristics cannot be reset. +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 015 +-- truncate_limit: 100 +SELECT COUNT(*) FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM xacttest" +== 016 +-- truncate_limit: 100 +RESET transaction_isolation +-- +STMT: VariableSetStmt +TRUNCATED: "RESET transaction_isolation" +== 017 +-- truncate_limit: 100 +-- error +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 018 +-- truncate_limit: 100 +BEGIN TRANSACTION READ ONLY +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN READ ONLY" +== 019 +-- truncate_limit: 100 +SELECT COUNT(*) FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM xacttest" +== 020 +-- truncate_limit: 100 +RESET transaction_read_only +-- +STMT: VariableSetStmt +TRUNCATED: "RESET transaction_read_only" +== 021 +-- truncate_limit: 100 +-- error +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 022 +-- truncate_limit: 100 +BEGIN TRANSACTION DEFERRABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN DEFERRABLE" +== 023 +-- truncate_limit: 100 +SELECT COUNT(*) FROM xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM xacttest" +== 024 +-- truncate_limit: 100 +RESET transaction_deferrable +-- +STMT: VariableSetStmt +TRUNCATED: "RESET transaction_deferrable" +== 025 +-- truncate_limit: 100 +-- error +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 026 +-- truncate_limit: 100 +CREATE FUNCTION errfunc() RETURNS int LANGUAGE SQL AS 'SELECT 1' +SET transaction_read_only = on +-- +FUNCTION: name="errfunc" function="errfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION errfunc() RETURNS int LANGUAGE sql AS $$SELECT 1$$ SET transaction_read_only TO ON" +== 027 +-- truncate_limit: 100 +-- error + +-- Read-only tests + +CREATE TABLE writetest (a int) +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE writetest (a int)" +== 028 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE temptest (a int) +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE temptest (a int)" +== 029 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 030 +-- truncate_limit: 100 +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY, DEFERRABLE" +== 031 +-- truncate_limit: 100 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM writetest" +== 032 +-- truncate_limit: 100 +-- ok +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ WRITE" +== 033 +-- truncate_limit: 100 +--fail +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 034 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 035 +-- truncate_limit: 100 +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ ONLY" +== 036 +-- truncate_limit: 100 +-- ok +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ WRITE" +== 037 +-- truncate_limit: 100 +-- ok +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ ONLY" +== 038 +-- truncate_limit: 100 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM writetest" +== 039 +-- truncate_limit: 100 +-- ok +SAVEPOINT x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 040 +-- truncate_limit: 100 +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ ONLY" +== 041 +-- truncate_limit: 100 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM writetest" +== 042 +-- truncate_limit: 100 +-- ok +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ ONLY" +== 043 +-- truncate_limit: 100 +-- ok +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ WRITE" +== 044 +-- truncate_limit: 100 +--fail +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 045 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 046 +-- truncate_limit: 100 +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ WRITE" +== 047 +-- truncate_limit: 100 +-- ok +SAVEPOINT x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 048 +-- truncate_limit: 100 +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ WRITE" +== 049 +-- truncate_limit: 100 +-- ok +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ ONLY" +== 050 +-- truncate_limit: 100 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM writetest" +== 051 +-- truncate_limit: 100 +-- ok +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ ONLY" +== 052 +-- truncate_limit: 100 +-- ok +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ WRITE" +== 053 +-- truncate_limit: 100 +--fail +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 054 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 055 +-- truncate_limit: 100 +SET TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ WRITE" +== 056 +-- truncate_limit: 100 +-- ok +SAVEPOINT x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 057 +-- truncate_limit: 100 +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ ONLY" +== 058 +-- truncate_limit: 100 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM writetest" +== 059 +-- truncate_limit: 100 +-- ok +ROLLBACK TO SAVEPOINT x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 060 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 061 +-- truncate_limit: 100 +-- off +SAVEPOINT y +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT y" +== 062 +-- truncate_limit: 100 +SET TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION READ ONLY" +== 063 +-- truncate_limit: 100 +-- ok +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM writetest" +== 064 +-- truncate_limit: 100 +-- ok +RELEASE SAVEPOINT y +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE y" +== 065 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 066 +-- truncate_limit: 100 +-- off +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 067 +-- truncate_limit: 100 +SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY +-- +STMT: VariableSetStmt +TRUNCATED: "SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY" +== 068 +-- truncate_limit: 100 +DROP TABLE writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE writetest" +== 069 +-- truncate_limit: 100 +-- fail +INSERT INTO writetest VALUES (1) +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO writetest VALUES (1)" +== 070 +-- truncate_limit: 100 +-- fail +SELECT * FROM writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM writetest" +== 071 +-- truncate_limit: 100 +-- ok +DELETE FROM temptest +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM temptest" +== 072 +-- truncate_limit: 100 +-- ok +UPDATE temptest SET a = 0 FROM writetest WHERE temptest.a = 1 AND writetest.a = temptest.a +-- +TABLE: name="temptest" schema="" table="temptest" ctx=DML +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: UpdateStmt +TRUNCATED: "UPDATE temptest SET a = 0 FROM writetest WHERE temptest.a = 1 AND writetest.a = temptest.a" +== 073 +-- truncate_limit: 100 +-- ok +PREPARE test AS UPDATE writetest SET a = 0 +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DML +STMT: PrepareStmt +STMT: UpdateStmt +TRUNCATED: "PREPARE test AS UPDATE writetest SET a = 0" +== 074 +-- truncate_limit: 100 +-- ok +EXECUTE test +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE test" +== 075 +-- truncate_limit: 100 +-- fail +SELECT * FROM writetest, temptest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=Select +TABLE: name="temptest" schema="" table="temptest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM writetest, temptest" +== 076 +-- truncate_limit: 100 +-- ok +CREATE TABLE test AS SELECT * FROM writetest +-- +TABLE: name="test" schema="" table="test" ctx=DDL +TABLE: name="writetest" schema="" table="writetest" ctx=Select +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE test AS SELECT * FROM writetest" +== 077 +-- truncate_limit: 100 +-- fail + +START TRANSACTION READ WRITE +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION READ WRITE" +== 078 +-- truncate_limit: 100 +DROP TABLE writetest +-- +TABLE: name="writetest" schema="" table="writetest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE writetest" +== 079 +-- truncate_limit: 100 +-- ok +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 080 +-- truncate_limit: 100 +-- Subtransactions, basic tests +-- create & drop tables +SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE +-- +STMT: VariableSetStmt +TRUNCATED: "SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE" +== 081 +-- truncate_limit: 100 +CREATE TABLE trans_foobar (a int) +-- +TABLE: name="trans_foobar" schema="" table="trans_foobar" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_foobar (a int)" +== 082 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 083 +-- truncate_limit: 100 +CREATE TABLE trans_foo (a int) +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_foo (a int)" +== 084 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 085 +-- truncate_limit: 100 +DROP TABLE trans_foo +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trans_foo" +== 086 +-- truncate_limit: 100 +CREATE TABLE trans_bar (a int) +-- +TABLE: name="trans_bar" schema="" table="trans_bar" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_bar (a int)" +== 087 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 088 +-- truncate_limit: 100 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE one" +== 089 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 090 +-- truncate_limit: 100 +CREATE TABLE trans_baz (a int) +-- +TABLE: name="trans_baz" schema="" table="trans_baz" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_baz (a int)" +== 091 +-- truncate_limit: 100 +RELEASE SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE two" +== 092 +-- truncate_limit: 100 +drop TABLE trans_foobar +-- +TABLE: name="trans_foobar" schema="" table="trans_foobar" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trans_foobar" +== 093 +-- truncate_limit: 100 +CREATE TABLE trans_barbaz (a int) +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_barbaz (a int)" +== 094 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 095 +-- truncate_limit: 100 +-- should exist: trans_barbaz, trans_baz, trans_foo +SELECT * FROM trans_foo +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trans_foo" +== 096 +-- truncate_limit: 100 +-- should be empty +SELECT * FROM trans_bar +-- +TABLE: name="trans_bar" schema="" table="trans_bar" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trans_bar" +== 097 +-- truncate_limit: 100 +-- shouldn't exist +SELECT * FROM trans_barbaz +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trans_barbaz" +== 098 +-- truncate_limit: 100 +-- should be empty +SELECT * FROM trans_baz +-- +TABLE: name="trans_baz" schema="" table="trans_baz" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trans_baz" +== 099 +-- truncate_limit: 100 +-- should be empty + +-- inserts +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 100 +-- truncate_limit: 100 +INSERT INTO trans_foo VALUES (1) +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_foo VALUES (1)" +== 101 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 102 +-- truncate_limit: 100 +INSERT into trans_bar VALUES (1) +-- +TABLE: name="trans_bar" schema="" table="trans_bar" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_bar VALUES (1)" +== 103 +-- truncate_limit: 100 +ROLLBACK TO one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 104 +-- truncate_limit: 100 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE one" +== 105 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 106 +-- truncate_limit: 100 +INSERT into trans_barbaz VALUES (1) +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_barbaz VALUES (1)" +== 107 +-- truncate_limit: 100 +RELEASE two +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE two" +== 108 +-- truncate_limit: 100 +SAVEPOINT three +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT three" +== 109 +-- truncate_limit: 100 +SAVEPOINT four +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT four" +== 110 +-- truncate_limit: 100 +INSERT INTO trans_foo VALUES (2) +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_foo VALUES (2)" +== 111 +-- truncate_limit: 100 +RELEASE SAVEPOINT four +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE four" +== 112 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT three +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT three" +== 113 +-- truncate_limit: 100 +RELEASE SAVEPOINT three +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE three" +== 114 +-- truncate_limit: 100 +INSERT INTO trans_foo VALUES (3) +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_foo VALUES (3)" +== 115 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 116 +-- truncate_limit: 100 +SELECT * FROM trans_foo +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trans_foo" +== 117 +-- truncate_limit: 100 +-- should have 1 and 3 +SELECT * FROM trans_barbaz +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trans_barbaz" +== 118 +-- truncate_limit: 100 +-- should have 1 + +-- test whole-tree commit +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 119 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 120 +-- truncate_limit: 100 +SELECT trans_foo +-- +STMT: SelectStmt +TRUNCATED: "SELECT trans_foo" +== 121 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 122 +-- truncate_limit: 100 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE one" +== 123 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 124 +-- truncate_limit: 100 +CREATE TABLE savepoints (a int) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE savepoints (a int)" +== 125 +-- truncate_limit: 100 +SAVEPOINT three +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT three" +== 126 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (1) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (1)" +== 127 +-- truncate_limit: 100 +SAVEPOINT four +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT four" +== 128 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (2) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (2)" +== 129 +-- truncate_limit: 100 +SAVEPOINT five +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT five" +== 130 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (3) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (3)" +== 131 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT five +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT five" +== 132 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 133 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 134 +-- truncate_limit: 100 +-- should not be in a transaction block +SELECT * FROM savepoints +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM savepoints" +== 135 +-- truncate_limit: 100 +-- test whole-tree rollback +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 136 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 137 +-- truncate_limit: 100 +DELETE FROM savepoints WHERE a=1 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM savepoints WHERE a = 1" +== 138 +-- truncate_limit: 100 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE one" +== 139 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 140 +-- truncate_limit: 100 +DELETE FROM savepoints WHERE a=1 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM savepoints WHERE a = 1" +== 141 +-- truncate_limit: 100 +SAVEPOINT three +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT three" +== 142 +-- truncate_limit: 100 +DELETE FROM savepoints WHERE a=2 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM savepoints WHERE a = 2" +== 143 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 144 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 145 +-- truncate_limit: 100 +-- should not be in a transaction block + +SELECT * FROM savepoints +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM savepoints" +== 146 +-- truncate_limit: 100 +-- test whole-tree commit on an aborted subtransaction +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 147 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (4) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (4)" +== 148 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 149 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (5) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (5)" +== 150 +-- truncate_limit: 100 +SELECT trans_foo +-- +STMT: SelectStmt +TRUNCATED: "SELECT trans_foo" +== 151 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 152 +-- truncate_limit: 100 +SELECT * FROM savepoints +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM savepoints" +== 153 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 154 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (6) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (6)" +== 155 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 156 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (7) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (7)" +== 157 +-- truncate_limit: 100 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE one" +== 158 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (8) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (8)" +== 159 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 160 +-- truncate_limit: 100 +-- rows 6 and 8 should have been created by the same xact +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=6 AND b.a=8 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +ALIAS: "a"="savepoints" +ALIAS: "b"="savepoints" +FILTER: schema="" table="a" column="a" +FILTER: schema="" table="b" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a = 6 AND b.a = 8" +== 161 +-- truncate_limit: 100 +-- rows 6 and 7 should have been created by different xacts +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=6 AND b.a=7 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +ALIAS: "a"="savepoints" +ALIAS: "b"="savepoints" +FILTER: schema="" table="a" column="a" +FILTER: schema="" table="b" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a = 6 AND b.a = 7" +== 162 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 163 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (9) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (9)" +== 164 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 165 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (10) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (10)" +== 166 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 167 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (11) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (11)" +== 168 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 169 +-- truncate_limit: 100 +SELECT a FROM savepoints WHERE a in (9, 10, 11) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM savepoints WHERE a IN (9, 10, 11)" +== 170 +-- truncate_limit: 100 +-- rows 9 and 11 should have been created by different xacts +SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a=9 AND b.a=11 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +ALIAS: "a"="savepoints" +ALIAS: "b"="savepoints" +FILTER: schema="" table="a" column="a" +FILTER: schema="" table="b" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a.xmin = b.xmin FROM savepoints a, savepoints b WHERE a.a = 9 AND b.a = 11" +== 171 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 172 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (12) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (12)" +== 173 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 174 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (13) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (13)" +== 175 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 176 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (14) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (14)" +== 177 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 178 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (15) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (15)" +== 179 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 180 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (16) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (16)" +== 181 +-- truncate_limit: 100 +SAVEPOINT three +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT three" +== 182 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (17) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (17)" +== 183 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 184 +-- truncate_limit: 100 +SELECT a FROM savepoints WHERE a BETWEEN 12 AND 17 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM savepoints WHERE a BETWEEN 12 AND 17" +== 185 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 186 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (18) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (18)" +== 187 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 188 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (19) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (19)" +== 189 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 190 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (20) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (20)" +== 191 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 192 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (21) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (21)" +== 193 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 194 +-- truncate_limit: 100 +INSERT INTO savepoints VALUES (22) +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO savepoints VALUES (22)" +== 195 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 196 +-- truncate_limit: 100 +SELECT a FROM savepoints WHERE a BETWEEN 18 AND 22 +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT a FROM savepoints WHERE a BETWEEN 18 AND 22" +== 197 +-- truncate_limit: 100 +DROP TABLE savepoints +-- +TABLE: name="savepoints" schema="" table="savepoints" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE savepoints" +== 198 +-- truncate_limit: 100 +-- only in a transaction block: +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 199 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 200 +-- truncate_limit: 100 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE one" +== 201 +-- truncate_limit: 100 +-- Only "rollback to" allowed in aborted state +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 202 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 203 +-- truncate_limit: 100 +SELECT 0/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 0 / 0" +== 204 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 205 +-- truncate_limit: 100 +-- ignored till the end of ... + RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE one" +== 206 +-- truncate_limit: 100 +-- ignored till the end of ... + ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 207 +-- truncate_limit: 100 +SELECT 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1" +== 208 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 209 +-- truncate_limit: 100 +SELECT 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1" +== 210 +-- truncate_limit: 100 +-- this should work + +-- check non-transactional behavior of cursors +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 211 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT unique2 FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT unique2 FROM tenk1 ORDER BY unique2" +== 212 +-- truncate_limit: 100 +SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT one" +== 213 +-- truncate_limit: 100 +FETCH 10 FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 10 c" +== 214 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT one" +== 215 +-- truncate_limit: 100 +FETCH 10 FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 10 c" +== 216 +-- truncate_limit: 100 +RELEASE SAVEPOINT one +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE one" +== 217 +-- truncate_limit: 100 +FETCH 10 FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 10 c" +== 218 +-- truncate_limit: 100 +CLOSE c +-- +STMT: ClosePortalStmt +TRUNCATED: "CLOSE c" +== 219 +-- truncate_limit: 100 +DECLARE c CURSOR FOR SELECT unique2/0 FROM tenk1 ORDER BY unique2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c CURSOR FOR SELECT unique2 / 0 FROM tenk1 ORDER BY unique2" +== 220 +-- truncate_limit: 100 +SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT two" +== 221 +-- truncate_limit: 100 +FETCH 10 FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 10 c" +== 222 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT two" +== 223 +-- truncate_limit: 100 +-- c is now dead to the world ... + FETCH 10 FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 10 c" +== 224 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT two" +== 225 +-- truncate_limit: 100 +RELEASE SAVEPOINT two +-- +STMT: TransactionStmt +TRUNCATED: "RELEASE two" +== 226 +-- truncate_limit: 100 +FETCH 10 FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH FORWARD 10 c" +== 227 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 228 +-- truncate_limit: 100 +|-- +-- Check that "stable" functions are really stable. They should not be +-- able to see the partial results of the calling query. (Ideally we would +-- also check that they don't see commits of concurrent transactions, but +-- that's a mite hard to do within the limitations of pg_regress.) +|-- +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xacttest" +== 229 +-- truncate_limit: 100 +create or replace function max_xacttest() returns smallint language sql as +'select max(a) from xacttest' stable +-- +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION max_xacttest() RETURNS smallint LANGUAGE sql AS $$select max(a) from x..." +== 230 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 231 +-- truncate_limit: 100 +update xacttest set a = max_xacttest() + 10 where a > 0 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE xacttest SET a = max_xacttest() + 10 WHERE a > 0" +== 232 +-- truncate_limit: 100 +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xacttest" +== 233 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 234 +-- truncate_limit: 100 +-- But a volatile function can see the partial results of the calling query +create or replace function max_xacttest() returns smallint language sql as +'select max(a) from xacttest' volatile +-- +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION max_xacttest() RETURNS smallint LANGUAGE sql AS $$select max(a) from x..." +== 235 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 236 +-- truncate_limit: 100 +update xacttest set a = max_xacttest() + 10 where a > 0 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE xacttest SET a = max_xacttest() + 10 WHERE a > 0" +== 237 +-- truncate_limit: 100 +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xacttest" +== 238 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 239 +-- truncate_limit: 100 +-- Now the same test with plpgsql (since it depends on SPI which is different) +create or replace function max_xacttest() returns smallint language plpgsql as +'begin return max(a) from xacttest; end' stable +-- +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION max_xacttest() RETURNS smallint LANGUAGE plpgsql AS $$begin return max..." +== 240 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 241 +-- truncate_limit: 100 +update xacttest set a = max_xacttest() + 10 where a > 0 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE xacttest SET a = max_xacttest() + 10 WHERE a > 0" +== 242 +-- truncate_limit: 100 +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xacttest" +== 243 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 244 +-- truncate_limit: 100 +create or replace function max_xacttest() returns smallint language plpgsql as +'begin return max(a) from xacttest; end' volatile +-- +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION max_xacttest() RETURNS smallint LANGUAGE plpgsql AS $$begin return max..." +== 245 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 246 +-- truncate_limit: 100 +update xacttest set a = max_xacttest() + 10 where a > 0 +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=DML +FUNCTION: name="max_xacttest" function="max_xacttest" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE xacttest SET a = max_xacttest() + 10 WHERE a > 0" +== 247 +-- truncate_limit: 100 +select * from xacttest +-- +TABLE: name="xacttest" schema="" table="xacttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xacttest" +== 248 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 249 +-- truncate_limit: 100 +-- test case for problems with dropping an open relation during abort +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 250 +-- truncate_limit: 100 +savepoint x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 251 +-- truncate_limit: 100 +CREATE TABLE koju (a INT UNIQUE) +-- +TABLE: name="koju" schema="" table="koju" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE koju (a int UNIQUE)" +== 252 +-- truncate_limit: 100 +INSERT INTO koju VALUES (1) +-- +TABLE: name="koju" schema="" table="koju" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO koju VALUES (1)" +== 253 +-- truncate_limit: 100 +INSERT INTO koju VALUES (1) +-- +TABLE: name="koju" schema="" table="koju" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO koju VALUES (1)" +== 254 +-- truncate_limit: 100 +rollback to x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 255 +-- truncate_limit: 100 +CREATE TABLE koju (a INT UNIQUE) +-- +TABLE: name="koju" schema="" table="koju" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE koju (a int UNIQUE)" +== 256 +-- truncate_limit: 100 +INSERT INTO koju VALUES (1) +-- +TABLE: name="koju" schema="" table="koju" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO koju VALUES (1)" +== 257 +-- truncate_limit: 100 +INSERT INTO koju VALUES (1) +-- +TABLE: name="koju" schema="" table="koju" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO koju VALUES (1)" +== 258 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 259 +-- truncate_limit: 100 +DROP TABLE trans_foo +-- +TABLE: name="trans_foo" schema="" table="trans_foo" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trans_foo" +== 260 +-- truncate_limit: 100 +DROP TABLE trans_baz +-- +TABLE: name="trans_baz" schema="" table="trans_baz" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trans_baz" +== 261 +-- truncate_limit: 100 +DROP TABLE trans_barbaz +-- +TABLE: name="trans_barbaz" schema="" table="trans_barbaz" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trans_barbaz" +== 262 +-- truncate_limit: 100 +-- test case for problems with revalidating an open relation during abort +create function inverse(int) returns float8 as +$$ +begin + analyze revalidate_bug; + return 1::float8/$1; +exception + when division_by_zero then return 0; +end$$ language plpgsql volatile +-- +FUNCTION: name="inverse" function="inverse" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION inverse(int) RETURNS float8 AS $$\nbegin\n analyze revalidate_bug;\n return 1::flo..." +== 263 +-- truncate_limit: 100 +create table revalidate_bug (c float8 unique) +-- +TABLE: name="revalidate_bug" schema="" table="revalidate_bug" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE revalidate_bug (c float8 UNIQUE)" +== 264 +-- truncate_limit: 100 +insert into revalidate_bug values (1) +-- +TABLE: name="revalidate_bug" schema="" table="revalidate_bug" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO revalidate_bug VALUES (1)" +== 265 +-- truncate_limit: 100 +insert into revalidate_bug values (inverse(0)) +-- +TABLE: name="revalidate_bug" schema="" table="revalidate_bug" ctx=DML +FUNCTION: name="inverse" function="inverse" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO revalidate_bug VALUES (inverse(0))" +== 266 +-- truncate_limit: 100 +drop table revalidate_bug +-- +TABLE: name="revalidate_bug" schema="" table="revalidate_bug" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE revalidate_bug" +== 267 +-- truncate_limit: 100 +drop function inverse(int) +-- +FUNCTION: name="inverse" function="inverse" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION inverse(int)" +== 268 +-- truncate_limit: 100 +-- verify that cursors created during an aborted subtransaction are +-- closed, but that we do not rollback the effect of any FETCHs +-- performed in the aborted subtransaction +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 269 +-- truncate_limit: 100 +savepoint x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 270 +-- truncate_limit: 100 +create table trans_abc (a int) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_abc (a int)" +== 271 +-- truncate_limit: 100 +insert into trans_abc values (5) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (5)" +== 272 +-- truncate_limit: 100 +insert into trans_abc values (10) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (10)" +== 273 +-- truncate_limit: 100 +declare foo cursor for select * from trans_abc +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo CURSOR FOR SELECT * FROM trans_abc" +== 274 +-- truncate_limit: 100 +fetch from foo +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo" +== 275 +-- truncate_limit: 100 +rollback to x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 276 +-- truncate_limit: 100 +-- should fail +fetch from foo +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo" +== 277 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 278 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 279 +-- truncate_limit: 100 +create table trans_abc (a int) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_abc (a int)" +== 280 +-- truncate_limit: 100 +insert into trans_abc values (5) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (5)" +== 281 +-- truncate_limit: 100 +insert into trans_abc values (10) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (10)" +== 282 +-- truncate_limit: 100 +insert into trans_abc values (15) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (15)" +== 283 +-- truncate_limit: 100 +declare foo cursor for select * from trans_abc +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE foo CURSOR FOR SELECT * FROM trans_abc" +== 284 +-- truncate_limit: 100 +fetch from foo +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo" +== 285 +-- truncate_limit: 100 +savepoint x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 286 +-- truncate_limit: 100 +fetch from foo +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo" +== 287 +-- truncate_limit: 100 +rollback to x +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" +== 288 +-- truncate_limit: 100 +fetch from foo +-- +STMT: FetchStmt +TRUNCATED: "FETCH foo" +== 289 +-- truncate_limit: 100 +abort +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 290 +-- truncate_limit: 100 +-- Test for proper cleanup after a failure in a cursor portal +-- that was created in an outer subtransaction +CREATE FUNCTION invert(x float8) RETURNS float8 LANGUAGE plpgsql AS +$$ begin return 1/x; end $$ +-- +FUNCTION: name="invert" function="invert" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION invert(x float8) RETURNS float8 LANGUAGE plpgsql AS $$ begin return 1/x; end $$" +== 291 +-- truncate_limit: 100 +CREATE FUNCTION create_temp_tab() RETURNS text +LANGUAGE plpgsql AS $$ +BEGIN + CREATE TEMP TABLE new_table (f1 float8); + -- case of interest is that we fail while holding an open + -- relcache reference to new_table + INSERT INTO new_table SELECT invert(0.0); + RETURN 'foo'; +END $$ +-- +FUNCTION: name="create_temp_tab" function="create_temp_tab" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION create_temp_tab() RETURNS text LANGUAGE plpgsql AS $$\nBEGIN\n CREATE TEMP TABLE n..." +== 292 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 293 +-- truncate_limit: 100 +DECLARE ok CURSOR FOR SELECT * FROM int8_tbl +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE ok CURSOR FOR SELECT * FROM int8_tbl" +== 294 +-- truncate_limit: 100 +DECLARE ctt CURSOR FOR SELECT create_temp_tab() +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE ctt CURSOR FOR SELECT create_temp_tab()" +== 295 +-- truncate_limit: 100 +FETCH ok +-- +STMT: FetchStmt +TRUNCATED: "FETCH ok" +== 296 +-- truncate_limit: 100 +SAVEPOINT s1 +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT s1" +== 297 +-- truncate_limit: 100 +FETCH ok +-- +STMT: FetchStmt +TRUNCATED: "FETCH ok" +== 298 +-- truncate_limit: 100 +-- should work +FETCH ctt +-- +STMT: FetchStmt +TRUNCATED: "FETCH ctt" +== 299 +-- truncate_limit: 100 +-- error occurs here +ROLLBACK TO s1 +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT s1" +== 300 +-- truncate_limit: 100 +FETCH ok +-- +STMT: FetchStmt +TRUNCATED: "FETCH ok" +== 301 +-- truncate_limit: 100 +-- should work +FETCH ctt +-- +STMT: FetchStmt +TRUNCATED: "FETCH ctt" +== 302 +-- truncate_limit: 100 +-- must be rejected +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 303 +-- truncate_limit: 100 +DROP FUNCTION create_temp_tab() +-- +FUNCTION: name="create_temp_tab" function="create_temp_tab" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION create_temp_tab()" +== 304 +-- truncate_limit: 100 +DROP FUNCTION invert(x float8) +-- +FUNCTION: name="invert" function="invert" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION invert(x float8)" +== 305 +-- truncate_limit: 100 +-- Tests for AND CHAIN + +CREATE TABLE trans_abc (a int) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_abc (a int)" +== 306 +-- truncate_limit: 100 +-- set nondefault value so we have something to override below +SET default_transaction_read_only = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_transaction_read_only TO ON" +== 307 +-- truncate_limit: 100 +START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE" +== 308 +-- truncate_limit: 100 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 309 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 310 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 311 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (1) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (1)" +== 312 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (2) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (2)" +== 313 +-- truncate_limit: 100 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 314 +-- truncate_limit: 100 +-- TBLOCK_END +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 315 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 316 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 317 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES ('error') +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES ('error')" +== 318 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (3) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (3)" +== 319 +-- truncate_limit: 100 +-- check it's really aborted +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 320 +-- truncate_limit: 100 +-- TBLOCK_ABORT_END +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 321 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 322 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 323 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (4) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (4)" +== 324 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 325 +-- truncate_limit: 100 +START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE" +== 326 +-- truncate_limit: 100 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 327 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 328 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 329 +-- truncate_limit: 100 +SAVEPOINT x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 330 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES ('error') +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES ('error')" +== 331 +-- truncate_limit: 100 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 332 +-- truncate_limit: 100 +-- TBLOCK_ABORT_PENDING +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 333 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 334 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 335 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (5) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (5)" +== 336 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 337 +-- truncate_limit: 100 +START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE" +== 338 +-- truncate_limit: 100 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 339 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 340 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 341 +-- truncate_limit: 100 +SAVEPOINT x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 342 +-- truncate_limit: 100 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 343 +-- truncate_limit: 100 +-- TBLOCK_SUBCOMMIT +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 344 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 345 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 346 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 347 +-- truncate_limit: 100 +START TRANSACTION ISOLATION LEVEL READ COMMITTED, READ WRITE, DEFERRABLE +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION ISOLATION LEVEL READ COMMITTED, READ WRITE, DEFERRABLE" +== 348 +-- truncate_limit: 100 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 349 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 350 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 351 +-- truncate_limit: 100 +SAVEPOINT x +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT x" +== 352 +-- truncate_limit: 100 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 353 +-- truncate_limit: 100 +-- TBLOCK_SUBCOMMIT +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 354 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 355 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 356 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 357 +-- truncate_limit: 100 +-- different mix of options just for fun +START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE +-- +STMT: TransactionStmt +TRUNCATED: "START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE" +== 358 +-- truncate_limit: 100 +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 359 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 360 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 361 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (6) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES (6)" +== 362 +-- truncate_limit: 100 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK AND CHAIN" +== 363 +-- truncate_limit: 100 +-- TBLOCK_ABORT_PENDING +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 364 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 365 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 366 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES ('error') +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_abc VALUES ('error')" +== 367 +-- truncate_limit: 100 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK AND CHAIN" +== 368 +-- truncate_limit: 100 +-- TBLOCK_ABORT_END +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 369 +-- truncate_limit: 100 +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 370 +-- truncate_limit: 100 +SHOW transaction_deferrable +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_deferrable" +== 371 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 372 +-- truncate_limit: 100 +-- not allowed outside a transaction block +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 373 +-- truncate_limit: 100 +-- error +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK AND CHAIN" +== 374 +-- truncate_limit: 100 +-- error + +SELECT * FROM trans_abc ORDER BY 1 +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trans_abc ORDER BY 1" +== 375 +-- truncate_limit: 100 +RESET default_transaction_read_only +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_transaction_read_only" +== 376 +-- truncate_limit: 100 +DROP TABLE trans_abc +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trans_abc" +== 377 +-- truncate_limit: 100 +-- Test assorted behaviors around the implicit transaction block created +-- when multiple SQL commands are sent in a single Query message. These +-- tests rely on the fact that psql will not break SQL commands apart at a +-- backslash-quoted semicolon, but will send them as one Query. + +create temp table i_table (f1 int) +-- +TABLE: name="i_table" schema="" table="i_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE i_table (f1 int)" +== 378 +-- truncate_limit: 100 +-- psql will show all results of a multi-statement Query +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 66 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 379 +-- truncate_limit: 100 +SELECT 2\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 380 +-- truncate_limit: 100 +SELECT 3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 3" +== 381 +-- truncate_limit: 100 +-- this implicitly commits: +insert into i_table values(1)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 58 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 382 +-- truncate_limit: 100 +select * from i_table +-- +TABLE: name="i_table" schema="" table="i_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM i_table" +== 383 +-- truncate_limit: 100 +-- 1/0 error will cause rolling back the whole implicit transaction +insert into i_table values(2)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 98 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 384 +-- truncate_limit: 100 +select * from i_table\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 385 +-- truncate_limit: 100 +select 1/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0" +== 386 +-- truncate_limit: 100 +select * from i_table +-- +TABLE: name="i_table" schema="" table="i_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM i_table" +== 387 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 388 +-- truncate_limit: 100 +-- we are not in a transaction at this point + +-- can use regular begin/commit/rollback within a single Query +begin\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 115 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 389 +-- truncate_limit: 100 +insert into i_table values(3)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 390 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 391 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 392 +-- truncate_limit: 100 +-- we are not in a transaction at this point +begin\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 51 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 393 +-- truncate_limit: 100 +insert into i_table values(4)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 394 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 395 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 396 +-- truncate_limit: 100 +-- we are not in a transaction at this point + +-- begin converts implicit transaction into a regular one that +-- can extend past the end of the Query +select 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 158 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 397 +-- truncate_limit: 100 +begin\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 398 +-- truncate_limit: 100 +insert into i_table values(5) +-- +TABLE: name="i_table" schema="" table="i_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO i_table VALUES (5)" +== 399 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 400 +-- truncate_limit: 100 +select 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 401 +-- truncate_limit: 100 +begin\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 402 +-- truncate_limit: 100 +insert into i_table values(6) +-- +TABLE: name="i_table" schema="" table="i_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO i_table VALUES (6)" +== 403 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 404 +-- truncate_limit: 100 +-- commit in implicit-transaction state commits but issues a warning. +insert into i_table values(7)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 100 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 405 +-- truncate_limit: 100 +commit\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 406 +-- truncate_limit: 100 +insert into i_table values(8)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 30 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 407 +-- truncate_limit: 100 +select 1/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0" +== 408 +-- truncate_limit: 100 +-- similarly, rollback aborts but issues a warning. +insert into i_table values(9)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 82 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 409 +-- truncate_limit: 100 +rollback\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 410 +-- truncate_limit: 100 +select 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2" +== 411 +-- truncate_limit: 100 +select * from i_table +-- +TABLE: name="i_table" schema="" table="i_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM i_table" +== 412 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 413 +-- truncate_limit: 100 +-- we are not in a transaction at this point + +-- implicit transaction block is still a transaction block, for e.g. VACUUM +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 131 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 414 +-- truncate_limit: 100 +VACUUM +-- +STMT: VacuumStmt +TRUNCATED: "VACUUM" +== 415 +-- truncate_limit: 100 +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 416 +-- truncate_limit: 100 +COMMIT\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 417 +-- truncate_limit: 100 +VACUUM +-- +STMT: VacuumStmt +TRUNCATED: "VACUUM" +== 418 +-- truncate_limit: 100 +-- we disallow savepoint-related commands in implicit-transaction state +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 81 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 419 +-- truncate_limit: 100 +SAVEPOINT sp +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp" +== 420 +-- truncate_limit: 100 +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 421 +-- truncate_limit: 100 +COMMIT\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 422 +-- truncate_limit: 100 +SAVEPOINT sp +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT sp" +== 423 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT sp\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 424 +-- truncate_limit: 100 +SELECT 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 2" +== 425 +-- truncate_limit: 100 +SELECT 2\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 426 +-- truncate_limit: 100 +RELEASE SAVEPOINT sp\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 427 +-- truncate_limit: 100 +SELECT 3 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 3" +== 428 +-- truncate_limit: 100 +-- but this is OK, because the BEGIN converts it to a regular xact +SELECT 1\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 76 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 429 +-- truncate_limit: 100 +BEGIN\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 6 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 430 +-- truncate_limit: 100 +SAVEPOINT sp\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 13 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 431 +-- truncate_limit: 100 +ROLLBACK TO SAVEPOINT sp\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 432 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 433 +-- truncate_limit: 100 +-- Tests for AND CHAIN in implicit transaction blocks + +SET TRANSACTION READ ONLY\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 81 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 434 +-- truncate_limit: 100 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 435 +-- truncate_limit: 100 +-- error +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 436 +-- truncate_limit: 100 +SET TRANSACTION READ ONLY\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 26 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 437 +-- truncate_limit: 100 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK AND CHAIN" +== 438 +-- truncate_limit: 100 +-- error +SHOW transaction_read_only +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW transaction_read_only" +== 439 +-- truncate_limit: 100 +CREATE TABLE trans_abc (a int) +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_abc (a int)" +== 440 +-- truncate_limit: 100 +-- COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN +INSERT INTO trans_abc VALUES (7)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 80 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 441 +-- truncate_limit: 100 +COMMIT\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 442 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (8)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 33 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 443 +-- truncate_limit: 100 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 444 +-- truncate_limit: 100 +-- 7 commit, 8 error +INSERT INTO trans_abc VALUES (9)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 54 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 445 +-- truncate_limit: 100 +ROLLBACK\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 446 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (10)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 447 +-- truncate_limit: 100 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK AND CHAIN" +== 448 +-- truncate_limit: 100 +-- 9 rollback, 10 error + +-- COMMIT/ROLLBACK AND CHAIN + COMMIT/ROLLBACK +INSERT INTO trans_abc VALUES (11)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 106 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 449 +-- truncate_limit: 100 +COMMIT AND CHAIN\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 17 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 450 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (12)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 451 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 452 +-- truncate_limit: 100 +-- 11 error, 12 not reached +INSERT INTO trans_abc VALUES (13)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 62 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 453 +-- truncate_limit: 100 +ROLLBACK AND CHAIN\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 19 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 454 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (14)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 455 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 456 +-- truncate_limit: 100 +-- 13 error, 14 not reached + +-- START TRANSACTION + COMMIT/ROLLBACK AND CHAIN +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 128 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 457 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (15)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 458 +-- truncate_limit: 100 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 459 +-- truncate_limit: 100 +-- 15 ok +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 460 +-- truncate_limit: 100 +-- transaction is active at this point +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 461 +-- truncate_limit: 100 +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 50 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 462 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (16)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 463 +-- truncate_limit: 100 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK AND CHAIN" +== 464 +-- truncate_limit: 100 +-- 16 ok +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 465 +-- truncate_limit: 100 +-- transaction is active at this point +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 466 +-- truncate_limit: 100 +SET default_transaction_isolation = 'read committed' +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_transaction_isolation TO \"read committed\"" +== 467 +-- truncate_limit: 100 +-- START TRANSACTION + COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 117 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 468 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (17)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 469 +-- truncate_limit: 100 +COMMIT\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 7 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 470 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (18)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 471 +-- truncate_limit: 100 +COMMIT AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT AND CHAIN" +== 472 +-- truncate_limit: 100 +-- 17 commit, 18 error +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 473 +-- truncate_limit: 100 +-- out of transaction block + +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 79 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 474 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (19)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 475 +-- truncate_limit: 100 +ROLLBACK\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 9 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 476 +-- truncate_limit: 100 +INSERT INTO trans_abc VALUES (20)\ +-- +ERROR: syntax error at or near "\" +CURSORPOS: 34 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 477 +-- truncate_limit: 100 +ROLLBACK AND CHAIN +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK AND CHAIN" +== 478 +-- truncate_limit: 100 +-- 19 rollback, 20 error +SHOW transaction_isolation +-- +STMT: VariableShowStmt +TRUNCATED: "SHOW TRANSACTION ISOLATION LEVEL" +== 479 +-- truncate_limit: 100 +-- out of transaction block + +RESET default_transaction_isolation +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_transaction_isolation" +== 480 +-- truncate_limit: 100 +SELECT * FROM trans_abc ORDER BY 1 +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trans_abc ORDER BY 1" +== 481 +-- truncate_limit: 100 +DROP TABLE trans_abc +-- +TABLE: name="trans_abc" schema="" table="trans_abc" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trans_abc" +== 482 +-- truncate_limit: 100 +-- TRANSACTION SNAPSHOT +-- Incorrect identifier. +BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL REPEATABLE READ" +== 483 +-- truncate_limit: 100 +SET TRANSACTION SNAPSHOT 'Incorrect Identifier' +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION SNAPSHOT 'Incorrect Identifier'" +== 484 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 485 +-- truncate_limit: 100 +-- Correct identifier, missing file. +BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL REPEATABLE READ" +== 486 +-- truncate_limit: 100 +SET TRANSACTION SNAPSHOT 'FFF-FFF-F' +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION SNAPSHOT 'FFF-FFF-F'" +== 487 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 488 +-- truncate_limit: 100 +-- Test for successful cleanup of an aborted transaction at session exit. +-- THIS MUST BE THE LAST TEST IN THIS FILE. + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 489 +-- truncate_limit: 100 +select 1/0 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 / 0" +== 490 +-- truncate_limit: 100 +rollback to X +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT x" diff --git a/parser/testdata/summary_truncate/postgres_regress/triggers.metadata.json b/parser/testdata/summary_truncate/postgres_regress/triggers.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/triggers.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/triggers.test b/parser/testdata/summary_truncate/postgres_regress/triggers.test new file mode 100644 index 0000000..78f069a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/triggers.test @@ -0,0 +1,9044 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TRIGGERS +|-- + +-- directory paths and dlsuffix are passed to us in environment variables + + +CREATE FUNCTION autoinc () + RETURNS trigger + AS :'autoinclib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 144 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 002 +-- truncate_limit: 100 +CREATE FUNCTION check_primary_key () + RETURNS trigger + AS :'refintlib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 59 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 003 +-- truncate_limit: 100 +CREATE FUNCTION check_foreign_key () + RETURNS trigger + AS :'refintlib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 59 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 004 +-- truncate_limit: 100 +CREATE FUNCTION trigger_return_old () + RETURNS trigger + AS :'regresslib' + LANGUAGE C +-- +ERROR: syntax error at or near ":" +CURSORPOS: 74 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 005 +-- truncate_limit: 100 +CREATE FUNCTION set_ttdummy (int4) + RETURNS int4 + AS :'regresslib' + LANGUAGE C STRICT +-- +ERROR: syntax error at or near ":" +CURSORPOS: 68 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 006 +-- truncate_limit: 100 +create table pkeys (pkey1 int4 not null, pkey2 text not null) +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pkeys (pkey1 int4 NOT NULL, pkey2 text NOT NULL)" +== 007 +-- truncate_limit: 100 +create table fkeys (fkey1 int4, fkey2 text, fkey3 int) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkeys (fkey1 int4, fkey2 text, fkey3 int)" +== 008 +-- truncate_limit: 100 +create table fkeys2 (fkey21 int4, fkey22 text, pkey23 int not null) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE fkeys2 (fkey21 int4, fkey22 text, pkey23 int NOT NULL)" +== 009 +-- truncate_limit: 100 +create index fkeys_i on fkeys (fkey1, fkey2) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fkeys_i ON fkeys USING btree (fkey1, fkey2)" +== 010 +-- truncate_limit: 100 +create index fkeys2_i on fkeys2 (fkey21, fkey22) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fkeys2_i ON fkeys2 USING btree (fkey21, fkey22)" +== 011 +-- truncate_limit: 100 +create index fkeys2p_i on fkeys2 (pkey23) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX fkeys2p_i ON fkeys2 USING btree (pkey23)" +== 012 +-- truncate_limit: 100 +insert into pkeys values (10, '1') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pkeys VALUES (10, '1')" +== 013 +-- truncate_limit: 100 +insert into pkeys values (20, '2') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pkeys VALUES (20, '2')" +== 014 +-- truncate_limit: 100 +insert into pkeys values (30, '3') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pkeys VALUES (30, '3')" +== 015 +-- truncate_limit: 100 +insert into pkeys values (40, '4') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pkeys VALUES (40, '4')" +== 016 +-- truncate_limit: 100 +insert into pkeys values (50, '5') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pkeys VALUES (50, '5')" +== 017 +-- truncate_limit: 100 +insert into pkeys values (60, '6') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pkeys VALUES (60, '6')" +== 018 +-- truncate_limit: 100 +create unique index pkeys_i on pkeys (pkey1, pkey2) +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX pkeys_i ON pkeys USING btree (pkey1, pkey2)" +== 019 +-- truncate_limit: 100 +|-- +-- For fkeys: +-- (fkey1, fkey2) --> pkeys (pkey1, pkey2) +-- (fkey3) --> fkeys2 (pkey23) +|-- +create trigger check_fkeys_pkey_exist + before insert or update on fkeys + for each row + execute function + check_primary_key ('fkey1', 'fkey2', 'pkeys', 'pkey1', 'pkey2') +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER check_fkeys_pkey_exist BEFORE INSERT OR UPDATE ON fkeys FOR EACH ROW EXECUTE FUNCT..." +== 020 +-- truncate_limit: 100 +create trigger check_fkeys_pkey2_exist + before insert or update on fkeys + for each row + execute function check_primary_key ('fkey3', 'fkeys2', 'pkey23') +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER check_fkeys_pkey2_exist BEFORE INSERT OR UPDATE ON fkeys FOR EACH ROW EXECUTE FUNC..." +== 021 +-- truncate_limit: 100 +|-- +-- For fkeys2: +-- (fkey21, fkey22) --> pkeys (pkey1, pkey2) +|-- +create trigger check_fkeys2_pkey_exist + before insert or update on fkeys2 + for each row + execute procedure + check_primary_key ('fkey21', 'fkey22', 'pkeys', 'pkey1', 'pkey2') +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER check_fkeys2_pkey_exist BEFORE INSERT OR UPDATE ON fkeys2 FOR EACH ROW EXECUTE FUN..." +== 022 +-- truncate_limit: 100 +-- Test comments +COMMENT ON TRIGGER check_fkeys2_pkey_bad ON fkeys2 IS 'wrong' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TRIGGER check_fkeys2_pkey_bad ON fkeys2 IS 'wrong'" +== 023 +-- truncate_limit: 100 +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS 'right' +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS 'right'" +== 024 +-- truncate_limit: 100 +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS NULL +-- +STMT: CommentStmt +TRUNCATED: "COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS NULL" +== 025 +-- truncate_limit: 100 +|-- +-- For pkeys: +-- ON DELETE/UPDATE (pkey1, pkey2) CASCADE: +-- fkeys (fkey1, fkey2) and fkeys2 (fkey21, fkey22) +|-- +create trigger check_pkeys_fkey_cascade + before delete or update on pkeys + for each row + execute procedure + check_foreign_key (2, 'cascade', 'pkey1', 'pkey2', + 'fkeys', 'fkey1', 'fkey2', 'fkeys2', 'fkey21', 'fkey22') +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER check_pkeys_fkey_cascade BEFORE DELETE OR UPDATE ON pkeys FOR EACH ROW EXECUTE FUN..." +== 026 +-- truncate_limit: 100 +|-- +-- For fkeys2: +-- ON DELETE/UPDATE (pkey23) RESTRICT: +-- fkeys (fkey3) +|-- +create trigger check_fkeys2_fkey_restrict + before delete or update on fkeys2 + for each row + execute procedure check_foreign_key (1, 'restrict', 'pkey23', 'fkeys', 'fkey3') +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER check_fkeys2_fkey_restrict BEFORE DELETE OR UPDATE ON fkeys2 FOR EACH ROW EXECUTE ..." +== 027 +-- truncate_limit: 100 +insert into fkeys2 values (10, '1', 1) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys2 VALUES (10, '1', 1)" +== 028 +-- truncate_limit: 100 +insert into fkeys2 values (30, '3', 2) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys2 VALUES (30, '3', 2)" +== 029 +-- truncate_limit: 100 +insert into fkeys2 values (40, '4', 5) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys2 VALUES (40, '4', 5)" +== 030 +-- truncate_limit: 100 +insert into fkeys2 values (50, '5', 3) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys2 VALUES (50, '5', 3)" +== 031 +-- truncate_limit: 100 +-- no key in pkeys +insert into fkeys2 values (70, '5', 3) +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys2 VALUES (70, '5', 3)" +== 032 +-- truncate_limit: 100 +insert into fkeys values (10, '1', 2) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys VALUES (10, '1', 2)" +== 033 +-- truncate_limit: 100 +insert into fkeys values (30, '3', 3) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys VALUES (30, '3', 3)" +== 034 +-- truncate_limit: 100 +insert into fkeys values (40, '4', 2) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys VALUES (40, '4', 2)" +== 035 +-- truncate_limit: 100 +insert into fkeys values (50, '5', 2) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys VALUES (50, '5', 2)" +== 036 +-- truncate_limit: 100 +-- no key in pkeys +insert into fkeys values (70, '5', 1) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys VALUES (70, '5', 1)" +== 037 +-- truncate_limit: 100 +-- no key in fkeys2 +insert into fkeys values (60, '6', 4) +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fkeys VALUES (60, '6', 4)" +== 038 +-- truncate_limit: 100 +delete from pkeys where pkey1 = 30 and pkey2 = '3' +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pkeys WHERE pkey1 = 30 AND pkey2 = '3'" +== 039 +-- truncate_limit: 100 +delete from pkeys where pkey1 = 40 and pkey2 = '4' +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pkeys WHERE pkey1 = 40 AND pkey2 = '4'" +== 040 +-- truncate_limit: 100 +update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 50 and pkey2 = '5' +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pkeys SET pkey1 = 7, pkey2 = '70' WHERE pkey1 = 50 AND pkey2 = '5'" +== 041 +-- truncate_limit: 100 +update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 10 and pkey2 = '1' +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pkeys SET pkey1 = 7, pkey2 = '70' WHERE pkey1 = 10 AND pkey2 = '1'" +== 042 +-- truncate_limit: 100 +SELECT trigger_name, event_manipulation, event_object_schema, event_object_table, + action_order, action_condition, action_orientation, action_timing, + action_reference_old_table, action_reference_new_table + FROM information_schema.triggers + WHERE event_object_table in ('pkeys', 'fkeys', 'fkeys2') + ORDER BY trigger_name COLLATE "C", 2 +-- +TABLE: name="information_schema.triggers" schema="information_schema" table="triggers" ctx=Select +FILTER: schema="" table="" column="event_object_table" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.triggers WHERE ... ORDER BY trigger_name COLLATE \"C\", 2" +== 043 +-- truncate_limit: 100 +DROP TABLE pkeys +-- +TABLE: name="pkeys" schema="" table="pkeys" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pkeys" +== 044 +-- truncate_limit: 100 +DROP TABLE fkeys +-- +TABLE: name="fkeys" schema="" table="fkeys" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fkeys" +== 045 +-- truncate_limit: 100 +DROP TABLE fkeys2 +-- +TABLE: name="fkeys2" schema="" table="fkeys2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fkeys2" +== 046 +-- truncate_limit: 100 +-- Check behavior when trigger returns unmodified trigtuple +create table trigtest (f1 int, f2 text) +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigtest (f1 int, f2 text)" +== 047 +-- truncate_limit: 100 +create trigger trigger_return_old + before insert or delete or update on trigtest + for each row execute procedure trigger_return_old() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigger_return_old BEFORE INSERT OR DELETE OR UPDATE ON trigtest FOR EACH ROW EXEC..." +== 048 +-- truncate_limit: 100 +insert into trigtest values(1, 'foo') +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigtest VALUES (1, 'foo')" +== 049 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 050 +-- truncate_limit: 100 +update trigtest set f2 = f2 || 'bar' +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigtest SET f2 = f2 || 'bar'" +== 051 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 052 +-- truncate_limit: 100 +delete from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trigtest" +== 053 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 054 +-- truncate_limit: 100 +-- Also check what happens when such a trigger runs before or after others +create function f1_times_10() returns trigger as +$$ begin new.f1 := new.f1 * 10; return new; end $$ language plpgsql +-- +FUNCTION: name="f1_times_10" function="f1_times_10" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f1_times_10() RETURNS trigger AS $$ begin new.f1 := new.f1 * 10; return new; end ..." +== 055 +-- truncate_limit: 100 +create trigger trigger_alpha + before insert or update on trigtest + for each row execute procedure f1_times_10() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigger_alpha BEFORE INSERT OR UPDATE ON trigtest FOR EACH ROW EXECUTE FUNCTION f1..." +== 056 +-- truncate_limit: 100 +insert into trigtest values(1, 'foo') +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigtest VALUES (1, 'foo')" +== 057 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 058 +-- truncate_limit: 100 +update trigtest set f2 = f2 || 'bar' +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigtest SET f2 = f2 || 'bar'" +== 059 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 060 +-- truncate_limit: 100 +delete from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trigtest" +== 061 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 062 +-- truncate_limit: 100 +create trigger trigger_zed + before insert or update on trigtest + for each row execute procedure f1_times_10() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigger_zed BEFORE INSERT OR UPDATE ON trigtest FOR EACH ROW EXECUTE FUNCTION f1_t..." +== 063 +-- truncate_limit: 100 +insert into trigtest values(1, 'foo') +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigtest VALUES (1, 'foo')" +== 064 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 065 +-- truncate_limit: 100 +update trigtest set f2 = f2 || 'bar' +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigtest SET f2 = f2 || 'bar'" +== 066 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 067 +-- truncate_limit: 100 +delete from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trigtest" +== 068 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 069 +-- truncate_limit: 100 +drop trigger trigger_alpha on trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trigger_alpha ON trigtest" +== 070 +-- truncate_limit: 100 +insert into trigtest values(1, 'foo') +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigtest VALUES (1, 'foo')" +== 071 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 072 +-- truncate_limit: 100 +update trigtest set f2 = f2 || 'bar' +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigtest SET f2 = f2 || 'bar'" +== 073 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 074 +-- truncate_limit: 100 +delete from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trigtest" +== 075 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 076 +-- truncate_limit: 100 +drop table trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigtest" +== 077 +-- truncate_limit: 100 +-- Check behavior with an implicit column default, too (bug #16644) +create table trigtest ( + a integer, + b bool default true not null, + c text default 'xyzzy' not null) +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigtest (a int, b bool DEFAULT true NOT NULL, c text DEFAULT 'xyzzy' NOT NULL)" +== 078 +-- truncate_limit: 100 +create trigger trigger_return_old + before insert or delete or update on trigtest + for each row execute procedure trigger_return_old() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigger_return_old BEFORE INSERT OR DELETE OR UPDATE ON trigtest FOR EACH ROW EXEC..." +== 079 +-- truncate_limit: 100 +insert into trigtest values(1) +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigtest VALUES (1)" +== 080 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 081 +-- truncate_limit: 100 +alter table trigtest add column d integer default 42 not null +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigtest ADD COLUMN d int DEFAULT 42 NOT NULL" +== 082 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 083 +-- truncate_limit: 100 +update trigtest set a = 2 where a = 1 returning * +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigtest SET a = 2 WHERE a = 1 RETURNING *" +== 084 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 085 +-- truncate_limit: 100 +alter table trigtest drop column b +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigtest DROP b" +== 086 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 087 +-- truncate_limit: 100 +update trigtest set a = 2 where a = 1 returning * +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigtest SET a = 2 WHERE a = 1 RETURNING *" +== 088 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 089 +-- truncate_limit: 100 +drop table trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigtest" +== 090 +-- truncate_limit: 100 +create sequence ttdummy_seq increment 10 start 0 minvalue 0 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE ttdummy_seq INCREMENT 10 START 0 MINVALUE 0" +== 091 +-- truncate_limit: 100 +create table tttest ( + price_id int4, + price_val int4, + price_on int4, + price_off int4 default 999999 +) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tttest (price_id int4, price_val int4, price_on int4, price_off int4 DEFAULT 999999)" +== 092 +-- truncate_limit: 100 +create trigger ttdummy + before delete or update on tttest + for each row + execute procedure + ttdummy (price_on, price_off) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER ttdummy BEFORE DELETE OR UPDATE ON tttest FOR EACH ROW EXECUTE FUNCTION ttdummy('p..." +== 093 +-- truncate_limit: 100 +create trigger ttserial + before insert or update on tttest + for each row + execute procedure + autoinc (price_on, ttdummy_seq) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER ttserial BEFORE INSERT OR UPDATE ON tttest FOR EACH ROW EXECUTE FUNCTION autoinc('..." +== 094 +-- truncate_limit: 100 +insert into tttest values (1, 1, null) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tttest VALUES (1, 1, NULL)" +== 095 +-- truncate_limit: 100 +insert into tttest values (2, 2, null) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tttest VALUES (2, 2, NULL)" +== 096 +-- truncate_limit: 100 +insert into tttest values (3, 3, 0) +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tttest VALUES (3, 3, 0)" +== 097 +-- truncate_limit: 100 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest" +== 098 +-- truncate_limit: 100 +delete from tttest where price_id = 2 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tttest WHERE price_id = 2" +== 099 +-- truncate_limit: 100 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest" +== 100 +-- truncate_limit: 100 +-- what do we see ? + +-- get current prices +select * from tttest where price_off = 999999 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +FILTER: schema="" table="" column="price_off" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest WHERE price_off = 999999" +== 101 +-- truncate_limit: 100 +-- change price for price_id == 3 +update tttest set price_val = 30 where price_id = 3 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tttest SET price_val = 30 WHERE price_id = 3" +== 102 +-- truncate_limit: 100 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest" +== 103 +-- truncate_limit: 100 +-- now we want to change pric_id in ALL tuples +-- this gets us not what we need +update tttest set price_id = 5 where price_id = 3 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tttest SET price_id = 5 WHERE price_id = 3" +== 104 +-- truncate_limit: 100 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest" +== 105 +-- truncate_limit: 100 +-- restore data as before last update: +select set_ttdummy(0) +-- +FUNCTION: name="set_ttdummy" function="set_ttdummy" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_ttdummy(0)" +== 106 +-- truncate_limit: 100 +delete from tttest where price_id = 5 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM tttest WHERE price_id = 5" +== 107 +-- truncate_limit: 100 +update tttest set price_off = 999999 where price_val = 30 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tttest SET price_off = 999999 WHERE price_val = 30" +== 108 +-- truncate_limit: 100 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest" +== 109 +-- truncate_limit: 100 +-- and try change price_id now! +update tttest set price_id = 5 where price_id = 3 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tttest SET price_id = 5 WHERE price_id = 3" +== 110 +-- truncate_limit: 100 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest" +== 111 +-- truncate_limit: 100 +-- isn't it what we need ? + +select set_ttdummy(1) +-- +FUNCTION: name="set_ttdummy" function="set_ttdummy" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_ttdummy(1)" +== 112 +-- truncate_limit: 100 +-- we want to correct some "date" +update tttest set price_on = -1 where price_id = 1 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tttest SET price_on = -1 WHERE price_id = 1" +== 113 +-- truncate_limit: 100 +-- but this doesn't work + +-- try in this way +select set_ttdummy(0) +-- +FUNCTION: name="set_ttdummy" function="set_ttdummy" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT set_ttdummy(0)" +== 114 +-- truncate_limit: 100 +update tttest set price_on = -1 where price_id = 1 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE tttest SET price_on = -1 WHERE price_id = 1" +== 115 +-- truncate_limit: 100 +select * from tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest" +== 116 +-- truncate_limit: 100 +-- isn't it what we need ? + +-- get price for price_id == 5 as it was @ "date" 35 +select * from tttest where price_on <= 35 and price_off > 35 and price_id = 5 +-- +TABLE: name="tttest" schema="" table="tttest" ctx=Select +FILTER: schema="" table="" column="price_on" +FILTER: schema="" table="" column="price_off" +FILTER: schema="" table="" column="price_id" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tttest WHERE price_on <= 35 AND price_off > 35 AND price_id = 5" +== 117 +-- truncate_limit: 100 +drop table tttest +-- +TABLE: name="tttest" schema="" table="tttest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tttest" +== 118 +-- truncate_limit: 100 +drop sequence ttdummy_seq +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE ttdummy_seq" +== 119 +-- truncate_limit: 100 +|-- +-- tests for per-statement triggers +|-- + +CREATE TABLE log_table (tstamp timestamp default timeofday()::timestamp) +-- +TABLE: name="log_table" schema="" table="log_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE log_table (tstamp timestamp DEFAULT (timeofday()::timestamp))" +== 120 +-- truncate_limit: 100 +CREATE TABLE main_table (a int unique, b int) +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE main_table (a int UNIQUE, b int)" +== 121 +-- truncate_limit: 100 +COPY main_table (a,b) FROM stdin +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY main_table(a, b) FROM STDIN" +== 122 +-- truncate_limit: 100 +CREATE FUNCTION trigger_func() RETURNS trigger LANGUAGE plpgsql AS ' +BEGIN + RAISE NOTICE ''trigger_func(%) called: action = %, when = %, level = %'', TG_ARGV[0], TG_OP, TG_WHEN, TG_LEVEL; + RETURN NULL; +END;' +-- +FUNCTION: name="trigger_func" function="trigger_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trigger_func() RETURNS trigger LANGUAGE plpgsql AS $$\nBEGIN\n\tRAISE NOTICE 'trigge..." +== 123 +-- truncate_limit: 100 +CREATE TRIGGER before_ins_stmt_trig BEFORE INSERT ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('before_ins_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER before_ins_stmt_trig BEFORE INSERT ON main_table EXECUTE FUNCTION trigger_func('be..." +== 124 +-- truncate_limit: 100 +CREATE TRIGGER after_ins_stmt_trig AFTER INSERT ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('after_ins_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_ins_stmt_trig AFTER INSERT ON main_table EXECUTE FUNCTION trigger_func('afte..." +== 125 +-- truncate_limit: 100 +|-- +-- if neither 'FOR EACH ROW' nor 'FOR EACH STATEMENT' was specified, +-- CREATE TRIGGER should default to 'FOR EACH STATEMENT' +|-- +CREATE TRIGGER after_upd_stmt_trig AFTER UPDATE ON main_table +EXECUTE PROCEDURE trigger_func('after_upd_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_upd_stmt_trig AFTER UPDATE ON main_table EXECUTE FUNCTION trigger_func('afte..." +== 126 +-- truncate_limit: 100 +-- Both insert and update statement level triggers (before and after) should +-- fire. Doesn't fire UPDATE before trigger, but only because one isn't +-- defined. +INSERT INTO main_table (a, b) VALUES (5, 10) ON CONFLICT (a) + DO UPDATE SET b = EXCLUDED.b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO main_table (a, b) VALUES (5, 10) ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 127 +-- truncate_limit: 100 +CREATE TRIGGER after_upd_row_trig AFTER UPDATE ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_row') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_upd_row_trig AFTER UPDATE ON main_table FOR EACH ROW EXECUTE FUNCTION trigge..." +== 128 +-- truncate_limit: 100 +INSERT INTO main_table DEFAULT VALUES +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO main_table DEFAULT VALUES" +== 129 +-- truncate_limit: 100 +UPDATE main_table SET a = a + 1 WHERE b < 30 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_table SET a = a + 1 WHERE b < 30" +== 130 +-- truncate_limit: 100 +-- UPDATE that effects zero rows should still call per-statement trigger +UPDATE main_table SET a = a + 2 WHERE b > 100 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_table SET a = a + 2 WHERE b > 100" +== 131 +-- truncate_limit: 100 +-- constraint now unneeded +ALTER TABLE main_table DROP CONSTRAINT main_table_a_key +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE main_table DROP CONSTRAINT main_table_a_key" +== 132 +-- truncate_limit: 100 +-- COPY should fire per-row and per-statement INSERT triggers +COPY main_table (a, b) FROM stdin +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY main_table(a, b) FROM STDIN" +== 133 +-- truncate_limit: 100 +SELECT * FROM main_table ORDER BY a, b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM main_table ORDER BY a, b" +== 134 +-- truncate_limit: 100 +|-- +-- test triggers with WHEN clause +|-- + +CREATE TRIGGER modified_a BEFORE UPDATE OF a ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) EXECUTE PROCEDURE trigger_func('modified_a') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER modified_a BEFORE UPDATE OF a ON main_table FOR EACH ROW WHEN (old.a <> new.a) EXE..." +== 135 +-- truncate_limit: 100 +CREATE TRIGGER modified_any BEFORE UPDATE OF a ON main_table +FOR EACH ROW WHEN (OLD.* IS DISTINCT FROM NEW.*) EXECUTE PROCEDURE trigger_func('modified_any') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER modified_any BEFORE UPDATE OF a ON main_table FOR EACH ROW WHEN (old.* IS DISTINCT..." +== 136 +-- truncate_limit: 100 +CREATE TRIGGER insert_a AFTER INSERT ON main_table +FOR EACH ROW WHEN (NEW.a = 123) EXECUTE PROCEDURE trigger_func('insert_a') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER insert_a AFTER INSERT ON main_table FOR EACH ROW WHEN (new.a = 123) EXECUTE FUNCTI..." +== 137 +-- truncate_limit: 100 +CREATE TRIGGER delete_a AFTER DELETE ON main_table +FOR EACH ROW WHEN (OLD.a = 123) EXECUTE PROCEDURE trigger_func('delete_a') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER delete_a AFTER DELETE ON main_table FOR EACH ROW WHEN (old.a = 123) EXECUTE FUNCTI..." +== 138 +-- truncate_limit: 100 +CREATE TRIGGER insert_when BEFORE INSERT ON main_table +FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE trigger_func('insert_when') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER insert_when BEFORE INSERT ON main_table WHEN (true) EXECUTE FUNCTION trigger_func(..." +== 139 +-- truncate_limit: 100 +CREATE TRIGGER delete_when AFTER DELETE ON main_table +FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE trigger_func('delete_when') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER delete_when AFTER DELETE ON main_table WHEN (true) EXECUTE FUNCTION trigger_func('..." +== 140 +-- truncate_limit: 100 +SELECT trigger_name, event_manipulation, event_object_schema, event_object_table, + action_order, action_condition, action_orientation, action_timing, + action_reference_old_table, action_reference_new_table + FROM information_schema.triggers + WHERE event_object_table IN ('main_table') + ORDER BY trigger_name COLLATE "C", 2 +-- +TABLE: name="information_schema.triggers" schema="information_schema" table="triggers" ctx=Select +FILTER: schema="" table="" column="event_object_table" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.triggers WHERE ... ORDER BY trigger_name COLLATE \"C\", 2" +== 141 +-- truncate_limit: 100 +INSERT INTO main_table (a) VALUES (123), (456) +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO main_table (a) VALUES (123), (456)" +== 142 +-- truncate_limit: 100 +COPY main_table FROM stdin +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY main_table FROM STDIN" +== 143 +-- truncate_limit: 100 +DELETE FROM main_table WHERE a IN (123, 456) +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM main_table WHERE a IN (123, 456)" +== 144 +-- truncate_limit: 100 +UPDATE main_table SET a = 50, b = 60 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_table SET a = 50, b = 60" +== 145 +-- truncate_limit: 100 +SELECT * FROM main_table ORDER BY a, b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM main_table ORDER BY a, b" +== 146 +-- truncate_limit: 100 +SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE ..." +== 147 +-- truncate_limit: 100 +SELECT pg_get_triggerdef(oid, false) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_triggerdef(oid, false) FROM pg_trigger WHERE ..." +== 148 +-- truncate_limit: 100 +SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_any' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE ..." +== 149 +-- truncate_limit: 100 +-- Test RENAME TRIGGER +ALTER TRIGGER modified_a ON main_table RENAME TO modified_modified_a +-- +STMT: RenameStmt +TRUNCATED: "ALTER TRIGGER modified_a ON main_table RENAME TO modified_modified_a" +== 150 +-- truncate_limit: 100 +SELECT count(*) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a'" +== 151 +-- truncate_limit: 100 +SELECT count(*) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_modified_a' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_trigger WHERE ..." +== 152 +-- truncate_limit: 100 +DROP TRIGGER modified_modified_a ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER modified_modified_a ON main_table" +== 153 +-- truncate_limit: 100 +DROP TRIGGER modified_any ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER modified_any ON main_table" +== 154 +-- truncate_limit: 100 +DROP TRIGGER insert_a ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER insert_a ON main_table" +== 155 +-- truncate_limit: 100 +DROP TRIGGER delete_a ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER delete_a ON main_table" +== 156 +-- truncate_limit: 100 +DROP TRIGGER insert_when ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER insert_when ON main_table" +== 157 +-- truncate_limit: 100 +DROP TRIGGER delete_when ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER delete_when ON main_table" +== 158 +-- truncate_limit: 100 +-- Test WHEN condition accessing system columns. +create table table_with_oids(a int) +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE table_with_oids (a int)" +== 159 +-- truncate_limit: 100 +insert into table_with_oids values (1) +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO table_with_oids VALUES (1)" +== 160 +-- truncate_limit: 100 +create trigger oid_unchanged_trig after update on table_with_oids + for each row + when (new.tableoid = old.tableoid AND new.tableoid <> 0) + execute procedure trigger_func('after_upd_oid_unchanged') +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER oid_unchanged_trig AFTER UPDATE ON table_with_oids FOR EACH ROW WHEN (new.tableoid..." +== 161 +-- truncate_limit: 100 +update table_with_oids set a = a + 1 +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE table_with_oids SET a = a + 1" +== 162 +-- truncate_limit: 100 +drop table table_with_oids +-- +TABLE: name="table_with_oids" schema="" table="table_with_oids" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE table_with_oids" +== 163 +-- truncate_limit: 100 +-- Test column-level triggers +DROP TRIGGER after_upd_row_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER after_upd_row_trig ON main_table" +== 164 +-- truncate_limit: 100 +CREATE TRIGGER before_upd_a_row_trig BEFORE UPDATE OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_upd_a_row') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER before_upd_a_row_trig BEFORE UPDATE OF a ON main_table FOR EACH ROW EXECUTE FUNCTI..." +== 165 +-- truncate_limit: 100 +CREATE TRIGGER after_upd_b_row_trig AFTER UPDATE OF b ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_b_row') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_upd_b_row_trig AFTER UPDATE OF b ON main_table FOR EACH ROW EXECUTE FUNCTION..." +== 166 +-- truncate_limit: 100 +CREATE TRIGGER after_upd_a_b_row_trig AFTER UPDATE OF a, b ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_a_b_row') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_upd_a_b_row_trig AFTER UPDATE OF a, b ON main_table FOR EACH ROW EXECUTE FUN..." +== 167 +-- truncate_limit: 100 +CREATE TRIGGER before_upd_a_stmt_trig BEFORE UPDATE OF a ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('before_upd_a_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER before_upd_a_stmt_trig BEFORE UPDATE OF a ON main_table EXECUTE FUNCTION trigger_f..." +== 168 +-- truncate_limit: 100 +CREATE TRIGGER after_upd_b_stmt_trig AFTER UPDATE OF b ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('after_upd_b_stmt') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_upd_b_stmt_trig AFTER UPDATE OF b ON main_table EXECUTE FUNCTION trigger_fun..." +== 169 +-- truncate_limit: 100 +SELECT pg_get_triggerdef(oid) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'after_upd_a_b_row_trig' +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="pg_get_triggerdef" function="pg_get_triggerdef" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_triggerdef(oid) FROM pg_trigger WHERE ..." +== 170 +-- truncate_limit: 100 +UPDATE main_table SET a = 50 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_table SET a = 50" +== 171 +-- truncate_limit: 100 +UPDATE main_table SET b = 10 +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_table SET b = 10" +== 172 +-- truncate_limit: 100 +|-- +-- Test case for bug with BEFORE trigger followed by AFTER trigger with WHEN +|-- + +CREATE TABLE some_t (some_col boolean NOT NULL) +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE some_t (some_col boolean NOT NULL)" +== 173 +-- truncate_limit: 100 +CREATE FUNCTION dummy_update_func() RETURNS trigger AS $$ +BEGIN + RAISE NOTICE 'dummy_update_func(%) called: action = %, old = %, new = %', + TG_ARGV[0], TG_OP, OLD, NEW; + RETURN NEW; +END; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="dummy_update_func" function="dummy_update_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION dummy_update_func() RETURNS trigger AS $$\nBEGIN\n RAISE NOTICE 'dummy_update_func..." +== 174 +-- truncate_limit: 100 +CREATE TRIGGER some_trig_before BEFORE UPDATE ON some_t FOR EACH ROW + EXECUTE PROCEDURE dummy_update_func('before') +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER some_trig_before BEFORE UPDATE ON some_t FOR EACH ROW EXECUTE FUNCTION dummy_updat..." +== 175 +-- truncate_limit: 100 +CREATE TRIGGER some_trig_aftera AFTER UPDATE ON some_t FOR EACH ROW + WHEN (NOT OLD.some_col AND NEW.some_col) + EXECUTE PROCEDURE dummy_update_func('aftera') +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER some_trig_aftera AFTER UPDATE ON some_t FOR EACH ROW WHEN (NOT old.some_col AND ne..." +== 176 +-- truncate_limit: 100 +CREATE TRIGGER some_trig_afterb AFTER UPDATE ON some_t FOR EACH ROW + WHEN (NOT NEW.some_col) + EXECUTE PROCEDURE dummy_update_func('afterb') +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER some_trig_afterb AFTER UPDATE ON some_t FOR EACH ROW WHEN (NOT new.some_col) EXECU..." +== 177 +-- truncate_limit: 100 +INSERT INTO some_t VALUES (TRUE) +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO some_t VALUES (true)" +== 178 +-- truncate_limit: 100 +UPDATE some_t SET some_col = TRUE +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE some_t SET some_col = true" +== 179 +-- truncate_limit: 100 +UPDATE some_t SET some_col = FALSE +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE some_t SET some_col = false" +== 180 +-- truncate_limit: 100 +UPDATE some_t SET some_col = TRUE +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE some_t SET some_col = true" +== 181 +-- truncate_limit: 100 +DROP TABLE some_t +-- +TABLE: name="some_t" schema="" table="some_t" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE some_t" +== 182 +-- truncate_limit: 100 +-- bogus cases +CREATE TRIGGER error_upd_and_col BEFORE UPDATE OR UPDATE OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_upd_and_col') +-- +ERROR: duplicate trigger events specified at or near "ON" +CURSORPOS: 78 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 183 +-- truncate_limit: 100 +CREATE TRIGGER error_upd_a_a BEFORE UPDATE OF a, a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_upd_a_a') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER error_upd_a_a BEFORE UPDATE OF a, a ON main_table FOR EACH ROW EXECUTE FUNCTION tr..." +== 184 +-- truncate_limit: 100 +CREATE TRIGGER error_ins_a BEFORE INSERT OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_ins_a') +-- +ERROR: syntax error at or near "OF" +CURSORPOS: 42 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 185 +-- truncate_limit: 100 +CREATE TRIGGER error_ins_when BEFORE INSERT OR UPDATE ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) +EXECUTE PROCEDURE trigger_func('error_ins_old') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER error_ins_when BEFORE INSERT OR UPDATE ON main_table FOR EACH ROW WHEN (old.a <> n..." +== 186 +-- truncate_limit: 100 +CREATE TRIGGER error_del_when BEFORE DELETE OR UPDATE ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) +EXECUTE PROCEDURE trigger_func('error_del_new') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER error_del_when BEFORE DELETE OR UPDATE ON main_table FOR EACH ROW WHEN (old.a <> n..." +== 187 +-- truncate_limit: 100 +CREATE TRIGGER error_del_when BEFORE INSERT OR UPDATE ON main_table +FOR EACH ROW WHEN (NEW.tableoid <> 0) +EXECUTE PROCEDURE trigger_func('error_when_sys_column') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER error_del_when BEFORE INSERT OR UPDATE ON main_table FOR EACH ROW WHEN (new.tableo..." +== 188 +-- truncate_limit: 100 +CREATE TRIGGER error_stmt_when BEFORE UPDATE OF a ON main_table +FOR EACH STATEMENT WHEN (OLD.* IS DISTINCT FROM NEW.*) +EXECUTE PROCEDURE trigger_func('error_stmt_when') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER error_stmt_when BEFORE UPDATE OF a ON main_table WHEN (old.* IS DISTINCT FROM new...." +== 189 +-- truncate_limit: 100 +-- check dependency restrictions +ALTER TABLE main_table DROP COLUMN b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE main_table DROP b" +== 190 +-- truncate_limit: 100 +-- this should succeed, but we'll roll it back to keep the triggers around +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 191 +-- truncate_limit: 100 +DROP TRIGGER after_upd_a_b_row_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER after_upd_a_b_row_trig ON main_table" +== 192 +-- truncate_limit: 100 +DROP TRIGGER after_upd_b_row_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER after_upd_b_row_trig ON main_table" +== 193 +-- truncate_limit: 100 +DROP TRIGGER after_upd_b_stmt_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER after_upd_b_stmt_trig ON main_table" +== 194 +-- truncate_limit: 100 +ALTER TABLE main_table DROP COLUMN b +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE main_table DROP b" +== 195 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 196 +-- truncate_limit: 100 +-- Test enable/disable triggers + +create table trigtest (i serial primary key) +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigtest (i serial PRIMARY KEY)" +== 197 +-- truncate_limit: 100 +-- test that disabling RI triggers works +create table trigtest2 (i int references trigtest(i) on delete cascade) +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigtest2 (i int REFERENCES trigtest (i) ON DELETE CASCADE)" +== 198 +-- truncate_limit: 100 +create function trigtest() returns trigger as $$ +begin + raise notice '% % % %', TG_TABLE_NAME, TG_OP, TG_WHEN, TG_LEVEL; + return new; +end;$$ language plpgsql +-- +FUNCTION: name="trigtest" function="trigtest" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trigtest() RETURNS trigger AS $$\nbegin\n\traise notice '% % % %', TG_TABLE_NAME, TG..." +== 199 +-- truncate_limit: 100 +create trigger trigtest_b_row_tg before insert or update or delete on trigtest +for each row execute procedure trigtest() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_b_row_tg BEFORE INSERT OR DELETE OR UPDATE ON trigtest FOR EACH ROW EXECU..." +== 200 +-- truncate_limit: 100 +create trigger trigtest_a_row_tg after insert or update or delete on trigtest +for each row execute procedure trigtest() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_a_row_tg AFTER INSERT OR DELETE OR UPDATE ON trigtest FOR EACH ROW EXECUT..." +== 201 +-- truncate_limit: 100 +create trigger trigtest_b_stmt_tg before insert or update or delete on trigtest +for each statement execute procedure trigtest() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_b_stmt_tg BEFORE INSERT OR DELETE OR UPDATE ON trigtest EXECUTE FUNCTION ..." +== 202 +-- truncate_limit: 100 +create trigger trigtest_a_stmt_tg after insert or update or delete on trigtest +for each statement execute procedure trigtest() +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigtest_a_stmt_tg AFTER INSERT OR DELETE OR UPDATE ON trigtest EXECUTE FUNCTION t..." +== 203 +-- truncate_limit: 100 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trigtest DEFAULT VALUES" +== 204 +-- truncate_limit: 100 +alter table trigtest disable trigger trigtest_b_row_tg +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigtest DISABLE TRIGGER trigtest_b_row_tg" +== 205 +-- truncate_limit: 100 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trigtest DEFAULT VALUES" +== 206 +-- truncate_limit: 100 +alter table trigtest disable trigger user +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigtest DISABLE TRIGGER USER" +== 207 +-- truncate_limit: 100 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trigtest DEFAULT VALUES" +== 208 +-- truncate_limit: 100 +alter table trigtest enable trigger trigtest_a_stmt_tg +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigtest ENABLE TRIGGER trigtest_a_stmt_tg" +== 209 +-- truncate_limit: 100 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trigtest DEFAULT VALUES" +== 210 +-- truncate_limit: 100 +set session_replication_role = replica +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_replication_role TO replica" +== 211 +-- truncate_limit: 100 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trigtest DEFAULT VALUES" +== 212 +-- truncate_limit: 100 +-- does not trigger +alter table trigtest enable always trigger trigtest_a_stmt_tg +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigtest ENABLE ALWAYS TRIGGER trigtest_a_stmt_tg" +== 213 +-- truncate_limit: 100 +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trigtest DEFAULT VALUES" +== 214 +-- truncate_limit: 100 +-- now it does +reset session_replication_role +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_replication_role" +== 215 +-- truncate_limit: 100 +insert into trigtest2 values(1) +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigtest2 VALUES (1)" +== 216 +-- truncate_limit: 100 +insert into trigtest2 values(2) +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigtest2 VALUES (2)" +== 217 +-- truncate_limit: 100 +delete from trigtest where i=2 +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trigtest WHERE i = 2" +== 218 +-- truncate_limit: 100 +select * from trigtest2 +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest2" +== 219 +-- truncate_limit: 100 +alter table trigtest disable trigger all +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigtest DISABLE TRIGGER ALL" +== 220 +-- truncate_limit: 100 +delete from trigtest where i=1 +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trigtest WHERE i = 1" +== 221 +-- truncate_limit: 100 +select * from trigtest2 +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest2" +== 222 +-- truncate_limit: 100 +-- ensure we still insert, even when all triggers are disabled +insert into trigtest default values +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO trigtest DEFAULT VALUES" +== 223 +-- truncate_limit: 100 +select * from trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trigtest" +== 224 +-- truncate_limit: 100 +drop table trigtest2 +-- +TABLE: name="trigtest2" schema="" table="trigtest2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigtest2" +== 225 +-- truncate_limit: 100 +drop table trigtest +-- +TABLE: name="trigtest" schema="" table="trigtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigtest" +== 226 +-- truncate_limit: 100 +-- dump trigger data +CREATE TABLE trigger_test ( + i int, + v varchar +) +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigger_test (i int, v varchar)" +== 227 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION trigger_data() RETURNS trigger +LANGUAGE plpgsql AS $$ + +declare + + argstr text; + relid text; + +begin + + relid := TG_relid::regclass; + + -- plpgsql can't discover its trigger data in a hash like perl and python + -- can, or by a sort of reflection like tcl can, + -- so we have to hard code the names. + raise NOTICE 'TG_NAME: %', TG_name; + raise NOTICE 'TG_WHEN: %', TG_when; + raise NOTICE 'TG_LEVEL: %', TG_level; + raise NOTICE 'TG_OP: %', TG_op; + raise NOTICE 'TG_RELID::regclass: %', relid; + raise NOTICE 'TG_RELNAME: %', TG_relname; + raise NOTICE 'TG_TABLE_NAME: %', TG_table_name; + raise NOTICE 'TG_TABLE_SCHEMA: %', TG_table_schema; + raise NOTICE 'TG_NARGS: %', TG_nargs; + + argstr := '['; + for i in 0 .. TG_nargs - 1 loop + if i > 0 then + argstr := argstr || ', '; + end if; + argstr := argstr || TG_argv[i]; + end loop; + argstr := argstr || ']'; + raise NOTICE 'TG_ARGV: %', argstr; + + if TG_OP != 'INSERT' then + raise NOTICE 'OLD: %', OLD; + end if; + + if TG_OP != 'DELETE' then + raise NOTICE 'NEW: %', NEW; + end if; + + if TG_OP = 'DELETE' then + return OLD; + else + return NEW; + end if; + +end; +$$ +-- +FUNCTION: name="trigger_data" function="trigger_data" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION trigger_data() RETURNS trigger LANGUAGE plpgsql AS $$\n\ndeclare\n\n\targst..." +== 228 +-- truncate_limit: 100 +CREATE TRIGGER show_trigger_data_trig +BEFORE INSERT OR UPDATE OR DELETE ON trigger_test +FOR EACH ROW EXECUTE PROCEDURE trigger_data(23,'skidoo') +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER show_trigger_data_trig BEFORE INSERT OR DELETE OR UPDATE ON trigger_test FOR EACH ..." +== 229 +-- truncate_limit: 100 +insert into trigger_test values(1,'insert') +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigger_test VALUES (1, 'insert')" +== 230 +-- truncate_limit: 100 +update trigger_test set v = 'update' where i = 1 +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigger_test SET v = 'update' WHERE i = 1" +== 231 +-- truncate_limit: 100 +delete from trigger_test +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trigger_test" +== 232 +-- truncate_limit: 100 +DROP TRIGGER show_trigger_data_trig on trigger_test +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER show_trigger_data_trig ON trigger_test" +== 233 +-- truncate_limit: 100 +DROP FUNCTION trigger_data() +-- +FUNCTION: name="trigger_data" function="trigger_data" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION trigger_data()" +== 234 +-- truncate_limit: 100 +DROP TABLE trigger_test +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigger_test" +== 235 +-- truncate_limit: 100 +|-- +-- Test use of row comparisons on OLD/NEW +|-- + +CREATE TABLE trigger_test (f1 int, f2 text, f3 text) +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigger_test (f1 int, f2 text, f3 text)" +== 236 +-- truncate_limit: 100 +-- this is the obvious (and wrong...) way to compare rows +CREATE FUNCTION mytrigger() RETURNS trigger LANGUAGE plpgsql as $$ +begin + if row(old.*) = row(new.*) then + raise notice 'row % not changed', new.f1; + else + raise notice 'row % changed', new.f1; + end if; + return new; +end$$ +-- +FUNCTION: name="mytrigger" function="mytrigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION mytrigger() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n\tif row(old.*) = row(new..." +== 237 +-- truncate_limit: 100 +CREATE TRIGGER t +BEFORE UPDATE ON trigger_test +FOR EACH ROW EXECUTE PROCEDURE mytrigger() +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER t BEFORE UPDATE ON trigger_test FOR EACH ROW EXECUTE FUNCTION mytrigger()" +== 238 +-- truncate_limit: 100 +INSERT INTO trigger_test VALUES(1, 'foo', 'bar') +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigger_test VALUES (1, 'foo', 'bar')" +== 239 +-- truncate_limit: 100 +INSERT INTO trigger_test VALUES(2, 'baz', 'quux') +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigger_test VALUES (2, 'baz', 'quux')" +== 240 +-- truncate_limit: 100 +UPDATE trigger_test SET f3 = 'bar' +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigger_test SET f3 = 'bar'" +== 241 +-- truncate_limit: 100 +UPDATE trigger_test SET f3 = NULL +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigger_test SET f3 = NULL" +== 242 +-- truncate_limit: 100 +-- this demonstrates that the above isn't really working as desired: +UPDATE trigger_test SET f3 = NULL +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigger_test SET f3 = NULL" +== 243 +-- truncate_limit: 100 +-- the right way when considering nulls is +CREATE OR REPLACE FUNCTION mytrigger() RETURNS trigger LANGUAGE plpgsql as $$ +begin + if row(old.*) is distinct from row(new.*) then + raise notice 'row % changed', new.f1; + else + raise notice 'row % not changed', new.f1; + end if; + return new; +end$$ +-- +FUNCTION: name="mytrigger" function="mytrigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION mytrigger() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n\tif row(old.*..." +== 244 +-- truncate_limit: 100 +UPDATE trigger_test SET f3 = 'bar' +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigger_test SET f3 = 'bar'" +== 245 +-- truncate_limit: 100 +UPDATE trigger_test SET f3 = NULL +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigger_test SET f3 = NULL" +== 246 +-- truncate_limit: 100 +UPDATE trigger_test SET f3 = NULL +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trigger_test SET f3 = NULL" +== 247 +-- truncate_limit: 100 +DROP TABLE trigger_test +-- +TABLE: name="trigger_test" schema="" table="trigger_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigger_test" +== 248 +-- truncate_limit: 100 +DROP FUNCTION mytrigger() +-- +FUNCTION: name="mytrigger" function="mytrigger" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION mytrigger()" +== 249 +-- truncate_limit: 100 +-- Test snapshot management in serializable transactions involving triggers +-- per bug report in 6bc73d4c0910042358k3d1adff3qa36f8df75198ecea@mail.gmail.com +CREATE FUNCTION serializable_update_trig() RETURNS trigger LANGUAGE plpgsql AS +$$ +declare + rec record; +begin + new.description = 'updated in trigger'; + return new; +end; +$$ +-- +FUNCTION: name="serializable_update_trig" function="serializable_update_trig" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION serializable_update_trig() RETURNS trigger LANGUAGE plpgsql AS $$\ndeclare\n\trec re..." +== 250 +-- truncate_limit: 100 +CREATE TABLE serializable_update_tab ( + id int, + filler text, + description text +) +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE serializable_update_tab (id int, filler text, description text)" +== 251 +-- truncate_limit: 100 +CREATE TRIGGER serializable_update_trig BEFORE UPDATE ON serializable_update_tab + FOR EACH ROW EXECUTE PROCEDURE serializable_update_trig() +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER serializable_update_trig BEFORE UPDATE ON serializable_update_tab FOR EACH ROW EXE..." +== 252 +-- truncate_limit: 100 +INSERT INTO serializable_update_tab SELECT a, repeat('xyzxz', 100), 'new' + FROM generate_series(1, 50) a +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO serializable_update_tab SELECT ... FROM generate_series(1, 50) a" +== 253 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 254 +-- truncate_limit: 100 +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: VariableSetStmt +TRUNCATED: "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE" +== 255 +-- truncate_limit: 100 +UPDATE serializable_update_tab SET description = 'no no', id = 1 WHERE id = 1 +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE serializable_update_tab SET description = 'no no', id = 1 WHERE id = 1" +== 256 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 257 +-- truncate_limit: 100 +SELECT description FROM serializable_update_tab WHERE id = 1 +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=Select +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT description FROM serializable_update_tab WHERE id = 1" +== 258 +-- truncate_limit: 100 +DROP TABLE serializable_update_tab +-- +TABLE: name="serializable_update_tab" schema="" table="serializable_update_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE serializable_update_tab" +== 259 +-- truncate_limit: 100 +-- minimal update trigger + +CREATE TABLE min_updates_test ( + f1 text, + f2 int, + f3 int) +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE min_updates_test (f1 text, f2 int, f3 int)" +== 260 +-- truncate_limit: 100 +INSERT INTO min_updates_test VALUES ('a',1,2),('b','2',null) +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO min_updates_test VALUES ('a', 1, 2), ('b', '2', NULL)" +== 261 +-- truncate_limit: 100 +CREATE TRIGGER z_min_update +BEFORE UPDATE ON min_updates_test +FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger() +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER z_min_update BEFORE UPDATE ON min_updates_test FOR EACH ROW EXECUTE FUNCTION suppr..." +== 262 +-- truncate_limit: 100 +UPDATE min_updates_test SET f1 = f1 +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE min_updates_test SET f1 = f1" +== 263 +-- truncate_limit: 100 +UPDATE min_updates_test SET f2 = f2 + 1 +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE min_updates_test SET f2 = f2 + 1" +== 264 +-- truncate_limit: 100 +UPDATE min_updates_test SET f3 = 2 WHERE f3 is null +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE min_updates_test SET f3 = 2 WHERE f3 IS NULL" +== 265 +-- truncate_limit: 100 +SELECT * FROM min_updates_test +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM min_updates_test" +== 266 +-- truncate_limit: 100 +DROP TABLE min_updates_test +-- +TABLE: name="min_updates_test" schema="" table="min_updates_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE min_updates_test" +== 267 +-- truncate_limit: 100 +|-- +-- Test triggers on views +|-- + +CREATE VIEW main_view AS SELECT a, b FROM main_table +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +TABLE: name="main_table" schema="" table="main_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW main_view AS SELECT a, b FROM main_table" +== 268 +-- truncate_limit: 100 +-- VIEW trigger function +CREATE OR REPLACE FUNCTION view_trigger() RETURNS trigger +LANGUAGE plpgsql AS $$ +declare + argstr text := ''; +begin + for i in 0 .. TG_nargs - 1 loop + if i > 0 then + argstr := argstr || ', '; + end if; + argstr := argstr || TG_argv[i]; + end loop; + + raise notice '% % % % (%)', TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, argstr; + + if TG_LEVEL = 'ROW' then + if TG_OP = 'INSERT' then + raise NOTICE 'NEW: %', NEW; + INSERT INTO main_table VALUES (NEW.a, NEW.b); + RETURN NEW; + end if; + + if TG_OP = 'UPDATE' then + raise NOTICE 'OLD: %, NEW: %', OLD, NEW; + UPDATE main_table SET a = NEW.a, b = NEW.b WHERE a = OLD.a AND b = OLD.b; + if NOT FOUND then RETURN NULL; end if; + RETURN NEW; + end if; + + if TG_OP = 'DELETE' then + raise NOTICE 'OLD: %', OLD; + DELETE FROM main_table WHERE a = OLD.a AND b = OLD.b; + if NOT FOUND then RETURN NULL; end if; + RETURN OLD; + end if; + end if; + + RETURN NULL; +end; +$$ +-- +FUNCTION: name="view_trigger" function="view_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION view_trigger() RETURNS trigger LANGUAGE plpgsql AS $$\ndeclare\n args..." +== 269 +-- truncate_limit: 100 +-- Before row triggers aren't allowed on views +CREATE TRIGGER invalid_trig BEFORE INSERT ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_ins_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig BEFORE INSERT ON main_view FOR EACH ROW EXECUTE FUNCTION trigger_func..." +== 270 +-- truncate_limit: 100 +CREATE TRIGGER invalid_trig BEFORE UPDATE ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_upd_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig BEFORE UPDATE ON main_view FOR EACH ROW EXECUTE FUNCTION trigger_func..." +== 271 +-- truncate_limit: 100 +CREATE TRIGGER invalid_trig BEFORE DELETE ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_del_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig BEFORE DELETE ON main_view FOR EACH ROW EXECUTE FUNCTION trigger_func..." +== 272 +-- truncate_limit: 100 +-- After row triggers aren't allowed on views +CREATE TRIGGER invalid_trig AFTER INSERT ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_ins_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig AFTER INSERT ON main_view FOR EACH ROW EXECUTE FUNCTION trigger_func(..." +== 273 +-- truncate_limit: 100 +CREATE TRIGGER invalid_trig AFTER UPDATE ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_upd_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig AFTER UPDATE ON main_view FOR EACH ROW EXECUTE FUNCTION trigger_func(..." +== 274 +-- truncate_limit: 100 +CREATE TRIGGER invalid_trig AFTER DELETE ON main_view +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_del_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig AFTER DELETE ON main_view FOR EACH ROW EXECUTE FUNCTION trigger_func(..." +== 275 +-- truncate_limit: 100 +-- Truncate triggers aren't allowed on views +CREATE TRIGGER invalid_trig BEFORE TRUNCATE ON main_view +EXECUTE PROCEDURE trigger_func('before_tru_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig BEFORE TRUNCATE ON main_view EXECUTE FUNCTION trigger_func('before_tr..." +== 276 +-- truncate_limit: 100 +CREATE TRIGGER invalid_trig AFTER TRUNCATE ON main_view +EXECUTE PROCEDURE trigger_func('before_tru_row') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig AFTER TRUNCATE ON main_view EXECUTE FUNCTION trigger_func('before_tru..." +== 277 +-- truncate_limit: 100 +-- INSTEAD OF triggers aren't allowed on tables +CREATE TRIGGER invalid_trig INSTEAD OF INSERT ON main_table +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_ins') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig INSTEAD OF INSERT ON main_table FOR EACH ROW EXECUTE FUNCTION view_tr..." +== 278 +-- truncate_limit: 100 +CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_table +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_table FOR EACH ROW EXECUTE FUNCTION view_tr..." +== 279 +-- truncate_limit: 100 +CREATE TRIGGER invalid_trig INSTEAD OF DELETE ON main_table +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_del') +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig INSTEAD OF DELETE ON main_table FOR EACH ROW EXECUTE FUNCTION view_tr..." +== 280 +-- truncate_limit: 100 +-- Don't support WHEN clauses with INSTEAD OF triggers +CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_view +FOR EACH ROW WHEN (OLD.a <> NEW.a) EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_view FOR EACH ROW WHEN (old.a <> new.a) EXE..." +== 281 +-- truncate_limit: 100 +-- Don't support column-level INSTEAD OF triggers +CREATE TRIGGER invalid_trig INSTEAD OF UPDATE OF a ON main_view +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig INSTEAD OF UPDATE OF a ON main_view FOR EACH ROW EXECUTE FUNCTION vie..." +== 282 +-- truncate_limit: 100 +-- Don't support statement-level INSTEAD OF triggers +CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_view +EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER invalid_trig INSTEAD OF UPDATE ON main_view EXECUTE FUNCTION view_trigger('instead..." +== 283 +-- truncate_limit: 100 +-- Valid INSTEAD OF triggers +CREATE TRIGGER instead_of_insert_trig INSTEAD OF INSERT ON main_view +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_ins') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER instead_of_insert_trig INSTEAD OF INSERT ON main_view FOR EACH ROW EXECUTE FUNCTIO..." +== 284 +-- truncate_limit: 100 +CREATE TRIGGER instead_of_update_trig INSTEAD OF UPDATE ON main_view +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_upd') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER instead_of_update_trig INSTEAD OF UPDATE ON main_view FOR EACH ROW EXECUTE FUNCTIO..." +== 285 +-- truncate_limit: 100 +CREATE TRIGGER instead_of_delete_trig INSTEAD OF DELETE ON main_view +FOR EACH ROW EXECUTE PROCEDURE view_trigger('instead_of_del') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER instead_of_delete_trig INSTEAD OF DELETE ON main_view FOR EACH ROW EXECUTE FUNCTIO..." +== 286 +-- truncate_limit: 100 +-- Valid BEFORE statement VIEW triggers +CREATE TRIGGER before_ins_stmt_trig BEFORE INSERT ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('before_view_ins_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER before_ins_stmt_trig BEFORE INSERT ON main_view EXECUTE FUNCTION view_trigger('bef..." +== 287 +-- truncate_limit: 100 +CREATE TRIGGER before_upd_stmt_trig BEFORE UPDATE ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('before_view_upd_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER before_upd_stmt_trig BEFORE UPDATE ON main_view EXECUTE FUNCTION view_trigger('bef..." +== 288 +-- truncate_limit: 100 +CREATE TRIGGER before_del_stmt_trig BEFORE DELETE ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('before_view_del_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER before_del_stmt_trig BEFORE DELETE ON main_view EXECUTE FUNCTION view_trigger('bef..." +== 289 +-- truncate_limit: 100 +-- Valid AFTER statement VIEW triggers +CREATE TRIGGER after_ins_stmt_trig AFTER INSERT ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('after_view_ins_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_ins_stmt_trig AFTER INSERT ON main_view EXECUTE FUNCTION view_trigger('after..." +== 290 +-- truncate_limit: 100 +CREATE TRIGGER after_upd_stmt_trig AFTER UPDATE ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('after_view_upd_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_upd_stmt_trig AFTER UPDATE ON main_view EXECUTE FUNCTION view_trigger('after..." +== 291 +-- truncate_limit: 100 +CREATE TRIGGER after_del_stmt_trig AFTER DELETE ON main_view +FOR EACH STATEMENT EXECUTE PROCEDURE view_trigger('after_view_del_stmt') +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER after_del_stmt_trig AFTER DELETE ON main_view EXECUTE FUNCTION view_trigger('after..." +== 292 +-- truncate_limit: 100 +-- Insert into view using trigger +INSERT INTO main_view VALUES (20, 30) +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO main_view VALUES (20, 30)" +== 293 +-- truncate_limit: 100 +INSERT INTO main_view VALUES (21, 31) RETURNING a, b +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO main_view VALUES (21, 31) RETURNING a, b" +== 294 +-- truncate_limit: 100 +-- Table trigger will prevent updates +UPDATE main_view SET b = 31 WHERE a = 20 +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_view SET b = 31 WHERE a = 20" +== 295 +-- truncate_limit: 100 +UPDATE main_view SET b = 32 WHERE a = 21 AND b = 31 RETURNING a, b +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_view SET b = 32 WHERE a = 21 AND b = 31 RETURNING a, b" +== 296 +-- truncate_limit: 100 +-- Remove table trigger to allow updates +DROP TRIGGER before_upd_a_row_trig ON main_table +-- +TABLE: name="main_table" schema="" table="main_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER before_upd_a_row_trig ON main_table" +== 297 +-- truncate_limit: 100 +UPDATE main_view SET b = 31 WHERE a = 20 +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_view SET b = 31 WHERE a = 20" +== 298 +-- truncate_limit: 100 +UPDATE main_view SET b = 32 WHERE a = 21 AND b = 31 RETURNING a, b +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_view SET b = 32 WHERE a = 21 AND b = 31 RETURNING a, b" +== 299 +-- truncate_limit: 100 +-- Before and after stmt triggers should fire even when no rows are affected +UPDATE main_view SET b = 0 WHERE false +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE main_view SET b = 0 WHERE false" +== 300 +-- truncate_limit: 100 +-- Delete from view using trigger +DELETE FROM main_view WHERE a IN (20,21) +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM main_view WHERE a IN (20, 21)" +== 301 +-- truncate_limit: 100 +DELETE FROM main_view WHERE a = 31 RETURNING a, b +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM main_view WHERE a = 31 RETURNING a, b" +== 302 +-- truncate_limit: 100 +-- Describe view should list triggers + +-- Test dropping view triggers +DROP TRIGGER instead_of_insert_trig ON main_view +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER instead_of_insert_trig ON main_view" +== 303 +-- truncate_limit: 100 +DROP TRIGGER instead_of_delete_trig ON main_view +-- +TABLE: name="main_view" schema="" table="main_view" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER instead_of_delete_trig ON main_view" +== 304 +-- truncate_limit: 100 +DROP VIEW main_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW main_view" +== 305 +-- truncate_limit: 100 +|-- +-- Test triggers on a join view +|-- +CREATE TABLE country_table ( + country_id serial primary key, + country_name text unique not null, + continent text not null +) +-- +TABLE: name="country_table" schema="" table="country_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE country_table (country_id serial PRIMARY KEY, country_name text UNIQUE NOT NULL, con..." +== 306 +-- truncate_limit: 100 +INSERT INTO country_table (country_name, continent) + VALUES ('Japan', 'Asia'), + ('UK', 'Europe'), + ('USA', 'North America') + RETURNING * +-- +TABLE: name="country_table" schema="" table="country_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO country_table (country_name, continent) VALUES (...) RETURNING *" +== 307 +-- truncate_limit: 100 +CREATE TABLE city_table ( + city_id serial primary key, + city_name text not null, + population bigint, + country_id int references country_table +) +-- +TABLE: name="city_table" schema="" table="city_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE city_table (city_id serial PRIMARY KEY, city_name text NOT NULL, population bigint, ..." +== 308 +-- truncate_limit: 100 +CREATE VIEW city_view AS + SELECT city_id, city_name, population, country_name, continent + FROM city_table ci + LEFT JOIN country_table co ON co.country_id = ci.country_id +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DDL +TABLE: name="city_table" schema="" table="city_table" ctx=Select +TABLE: name="country_table" schema="" table="country_table" ctx=Select +ALIAS: "ci"="city_table" +ALIAS: "co"="country_table" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW city_view AS SELECT city_id, city_name, population, country_name, continent FROM city..." +== 309 +-- truncate_limit: 100 +CREATE FUNCTION city_insert() RETURNS trigger LANGUAGE plpgsql AS $$ +declare + ctry_id int; +begin + if NEW.country_name IS NOT NULL then + SELECT country_id, continent INTO ctry_id, NEW.continent + FROM country_table WHERE country_name = NEW.country_name; + if NOT FOUND then + raise exception 'No such country: "%"', NEW.country_name; + end if; + else + NEW.continent := NULL; + end if; + + if NEW.city_id IS NOT NULL then + INSERT INTO city_table + VALUES(NEW.city_id, NEW.city_name, NEW.population, ctry_id); + else + INSERT INTO city_table(city_name, population, country_id) + VALUES(NEW.city_name, NEW.population, ctry_id) + RETURNING city_id INTO NEW.city_id; + end if; + + RETURN NEW; +end; +$$ +-- +FUNCTION: name="city_insert" function="city_insert" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION city_insert() RETURNS trigger LANGUAGE plpgsql AS $$\ndeclare\n ctry_id int;\nbeg..." +== 310 +-- truncate_limit: 100 +CREATE TRIGGER city_insert_trig INSTEAD OF INSERT ON city_view +FOR EACH ROW EXECUTE PROCEDURE city_insert() +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER city_insert_trig INSTEAD OF INSERT ON city_view FOR EACH ROW EXECUTE FUNCTION city..." +== 311 +-- truncate_limit: 100 +CREATE FUNCTION city_delete() RETURNS trigger LANGUAGE plpgsql AS $$ +begin + DELETE FROM city_table WHERE city_id = OLD.city_id; + if NOT FOUND then RETURN NULL; end if; + RETURN OLD; +end; +$$ +-- +FUNCTION: name="city_delete" function="city_delete" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION city_delete() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n DELETE FROM city_t..." +== 312 +-- truncate_limit: 100 +CREATE TRIGGER city_delete_trig INSTEAD OF DELETE ON city_view +FOR EACH ROW EXECUTE PROCEDURE city_delete() +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER city_delete_trig INSTEAD OF DELETE ON city_view FOR EACH ROW EXECUTE FUNCTION city..." +== 313 +-- truncate_limit: 100 +CREATE FUNCTION city_update() RETURNS trigger LANGUAGE plpgsql AS $$ +declare + ctry_id int; +begin + if NEW.country_name IS DISTINCT FROM OLD.country_name then + SELECT country_id, continent INTO ctry_id, NEW.continent + FROM country_table WHERE country_name = NEW.country_name; + if NOT FOUND then + raise exception 'No such country: "%"', NEW.country_name; + end if; + + UPDATE city_table SET city_name = NEW.city_name, + population = NEW.population, + country_id = ctry_id + WHERE city_id = OLD.city_id; + else + UPDATE city_table SET city_name = NEW.city_name, + population = NEW.population + WHERE city_id = OLD.city_id; + NEW.continent := OLD.continent; + end if; + + if NOT FOUND then RETURN NULL; end if; + RETURN NEW; +end; +$$ +-- +FUNCTION: name="city_update" function="city_update" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION city_update() RETURNS trigger LANGUAGE plpgsql AS $$\ndeclare\n ctry_id int;\nbeg..." +== 314 +-- truncate_limit: 100 +CREATE TRIGGER city_update_trig INSTEAD OF UPDATE ON city_view +FOR EACH ROW EXECUTE PROCEDURE city_update() +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER city_update_trig INSTEAD OF UPDATE ON city_view FOR EACH ROW EXECUTE FUNCTION city..." +== 315 +-- truncate_limit: 100 +-- INSERT .. RETURNING +INSERT INTO city_view(city_name) VALUES('Tokyo') RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO city_view (city_name) VALUES ('Tokyo') RETURNING *" +== 316 +-- truncate_limit: 100 +INSERT INTO city_view(city_name, population) VALUES('London', 7556900) RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO city_view (city_name, population) VALUES ('London', 7556900) RETURNING *" +== 317 +-- truncate_limit: 100 +INSERT INTO city_view(city_name, country_name) VALUES('Washington DC', 'USA') RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO city_view (city_name, country_name) VALUES ('Washington DC', 'USA') RETURNING *" +== 318 +-- truncate_limit: 100 +INSERT INTO city_view(city_id, city_name) VALUES(123456, 'New York') RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO city_view (city_id, city_name) VALUES (123456, 'New York') RETURNING *" +== 319 +-- truncate_limit: 100 +INSERT INTO city_view VALUES(234567, 'Birmingham', 1016800, 'UK', 'EU') RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO city_view VALUES (234567, 'Birmingham', 1016800, 'UK', 'EU') RETURNING *" +== 320 +-- truncate_limit: 100 +-- UPDATE .. RETURNING +UPDATE city_view SET country_name = 'Japon' WHERE city_name = 'Tokyo' +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view SET country_name = 'Japon' WHERE city_name = 'Tokyo'" +== 321 +-- truncate_limit: 100 +-- error +UPDATE city_view SET country_name = 'Japan' WHERE city_name = 'Takyo' +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view SET country_name = 'Japan' WHERE city_name = 'Takyo'" +== 322 +-- truncate_limit: 100 +-- no match +UPDATE city_view SET country_name = 'Japan' WHERE city_name = 'Tokyo' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view SET country_name = 'Japan' WHERE city_name = 'Tokyo' RETURNING *" +== 323 +-- truncate_limit: 100 +-- OK + +UPDATE city_view SET population = 13010279 WHERE city_name = 'Tokyo' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view SET population = 13010279 WHERE city_name = 'Tokyo' RETURNING *" +== 324 +-- truncate_limit: 100 +UPDATE city_view SET country_name = 'UK' WHERE city_name = 'New York' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view SET country_name = 'UK' WHERE city_name = 'New York' RETURNING *" +== 325 +-- truncate_limit: 100 +UPDATE city_view SET country_name = 'USA', population = 8391881 WHERE city_name = 'New York' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view SET ... = ... WHERE city_name = 'New York' RETURNING *" +== 326 +-- truncate_limit: 100 +UPDATE city_view SET continent = 'EU' WHERE continent = 'Europe' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view SET continent = 'EU' WHERE continent = 'Europe' RETURNING *" +== 327 +-- truncate_limit: 100 +UPDATE city_view v1 SET country_name = v2.country_name FROM city_view v2 + WHERE v2.city_name = 'Birmingham' AND v1.city_name = 'London' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +TABLE: name="city_view" schema="" table="city_view" ctx=Select +ALIAS: "v1"="city_view" +ALIAS: "v2"="city_view" +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view v1 SET country_name = v2.country_name FROM city_view v2 WHERE ... RETURNING *" +== 328 +-- truncate_limit: 100 +-- DELETE .. RETURNING +DELETE FROM city_view WHERE city_name = 'Birmingham' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM city_view WHERE city_name = 'Birmingham' RETURNING *" +== 329 +-- truncate_limit: 100 +-- read-only view with WHERE clause +CREATE VIEW european_city_view AS + SELECT * FROM city_view WHERE continent = 'Europe' +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +TABLE: name="city_view" schema="" table="city_view" ctx=Select +FILTER: schema="" table="" column="continent" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW european_city_view AS SELECT * FROM city_view WHERE continent = 'Europe'" +== 330 +-- truncate_limit: 100 +SELECT count(*) FROM european_city_view +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM european_city_view" +== 331 +-- truncate_limit: 100 +CREATE FUNCTION no_op_trig_fn() RETURNS trigger LANGUAGE plpgsql +AS 'begin RETURN NULL; end' +-- +FUNCTION: name="no_op_trig_fn" function="no_op_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION no_op_trig_fn() RETURNS trigger LANGUAGE plpgsql AS $$begin RETURN NULL; end$$" +== 332 +-- truncate_limit: 100 +CREATE TRIGGER no_op_trig INSTEAD OF INSERT OR UPDATE OR DELETE +ON european_city_view FOR EACH ROW EXECUTE PROCEDURE no_op_trig_fn() +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER no_op_trig INSTEAD OF INSERT OR DELETE OR UPDATE ON european_city_view FOR EACH RO..." +== 333 +-- truncate_limit: 100 +INSERT INTO european_city_view VALUES (0, 'x', 10000, 'y', 'z') +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO european_city_view VALUES (0, 'x', 10000, 'y', 'z')" +== 334 +-- truncate_limit: 100 +UPDATE european_city_view SET population = 10000 +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE european_city_view SET population = 10000" +== 335 +-- truncate_limit: 100 +DELETE FROM european_city_view +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM european_city_view" +== 336 +-- truncate_limit: 100 +-- rules bypassing no-op triggers +CREATE RULE european_city_insert_rule AS ON INSERT TO european_city_view +DO INSTEAD INSERT INTO city_view +VALUES (NEW.city_id, NEW.city_name, NEW.population, NEW.country_name, NEW.continent) +RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE european_city_insert_rule AS ON INSERT TO european_city_view DO INSTEAD INSERT INTO c..." +== 337 +-- truncate_limit: 100 +CREATE RULE european_city_update_rule AS ON UPDATE TO european_city_view +DO INSTEAD UPDATE city_view SET + city_name = NEW.city_name, + population = NEW.population, + country_name = NEW.country_name +WHERE city_id = OLD.city_id +RETURNING NEW.* +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE european_city_update_rule AS ON UPDATE TO european_city_view DO INSTEAD UPDATE city_v..." +== 338 +-- truncate_limit: 100 +CREATE RULE european_city_delete_rule AS ON DELETE TO european_city_view +DO INSTEAD DELETE FROM city_view WHERE city_id = OLD.city_id RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE european_city_delete_rule AS ON DELETE TO european_city_view DO INSTEAD DELETE FROM c..." +== 339 +-- truncate_limit: 100 +-- INSERT not limited by view's WHERE clause, but UPDATE AND DELETE are +INSERT INTO european_city_view(city_name, country_name) + VALUES ('Cambridge', 'USA') RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO european_city_view (city_name, country_name) VALUES ('Cambridge', 'USA') RETURNING *" +== 340 +-- truncate_limit: 100 +UPDATE european_city_view SET country_name = 'UK' + WHERE city_name = 'Cambridge' +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE european_city_view SET country_name = 'UK' WHERE city_name = 'Cambridge'" +== 341 +-- truncate_limit: 100 +DELETE FROM european_city_view WHERE city_name = 'Cambridge' +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM european_city_view WHERE city_name = 'Cambridge'" +== 342 +-- truncate_limit: 100 +-- UPDATE and DELETE via rule and trigger +UPDATE city_view SET country_name = 'UK' + WHERE city_name = 'Cambridge' RETURNING * +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view SET country_name = 'UK' WHERE city_name = 'Cambridge' RETURNING *" +== 343 +-- truncate_limit: 100 +UPDATE european_city_view SET population = 122800 + WHERE city_name = 'Cambridge' RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE european_city_view SET population = 122800 WHERE city_name = 'Cambridge' RETURNING *" +== 344 +-- truncate_limit: 100 +DELETE FROM european_city_view WHERE city_name = 'Cambridge' RETURNING * +-- +TABLE: name="european_city_view" schema="" table="european_city_view" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM european_city_view WHERE city_name = 'Cambridge' RETURNING *" +== 345 +-- truncate_limit: 100 +-- join UPDATE test +UPDATE city_view v SET population = 599657 + FROM city_table ci, country_table co + WHERE ci.city_name = 'Washington DC' and co.country_name = 'USA' + AND v.city_id = ci.city_id AND v.country_name = co.country_name + RETURNING co.country_id, v.country_name, + v.city_id, v.city_name, v.population +-- +TABLE: name="city_view" schema="" table="city_view" ctx=DML +TABLE: name="city_table" schema="" table="city_table" ctx=Select +TABLE: name="country_table" schema="" table="country_table" ctx=Select +ALIAS: "ci"="city_table" +ALIAS: "co"="country_table" +ALIAS: "v"="city_view" +STMT: UpdateStmt +TRUNCATED: "UPDATE city_view v SET ... = ... FROM city_table ci, country_table co WHERE ... RETURNING co.coun..." +== 346 +-- truncate_limit: 100 +SELECT * FROM city_view +-- +TABLE: name="city_view" schema="" table="city_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM city_view" +== 347 +-- truncate_limit: 100 +DROP TABLE city_table CASCADE +-- +TABLE: name="city_table" schema="" table="city_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE city_table CASCADE" +== 348 +-- truncate_limit: 100 +DROP TABLE country_table +-- +TABLE: name="country_table" schema="" table="country_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE country_table" +== 349 +-- truncate_limit: 100 +-- Test pg_trigger_depth() + +create table depth_a (id int not null primary key) +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE depth_a (id int NOT NULL PRIMARY KEY)" +== 350 +-- truncate_limit: 100 +create table depth_b (id int not null primary key) +-- +TABLE: name="depth_b" schema="" table="depth_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE depth_b (id int NOT NULL PRIMARY KEY)" +== 351 +-- truncate_limit: 100 +create table depth_c (id int not null primary key) +-- +TABLE: name="depth_c" schema="" table="depth_c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE depth_c (id int NOT NULL PRIMARY KEY)" +== 352 +-- truncate_limit: 100 +create function depth_a_tf() returns trigger + language plpgsql as $$ +begin + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + insert into depth_b values (new.id); + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + return new; +end; +$$ +-- +FUNCTION: name="depth_a_tf" function="depth_a_tf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION depth_a_tf() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n raise notice '%: dept..." +== 353 +-- truncate_limit: 100 +create trigger depth_a_tr before insert on depth_a + for each row execute procedure depth_a_tf() +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER depth_a_tr BEFORE INSERT ON depth_a FOR EACH ROW EXECUTE FUNCTION depth_a_tf()" +== 354 +-- truncate_limit: 100 +create function depth_b_tf() returns trigger + language plpgsql as $$ +begin + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + begin + execute 'insert into depth_c values (' || new.id::text || ')'; + exception + when sqlstate 'U9999' then + raise notice 'SQLSTATE = U9999: depth = %', pg_trigger_depth(); + end; + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + if new.id = 1 then + execute 'insert into depth_c values (' || new.id::text || ')'; + end if; + return new; +end; +$$ +-- +FUNCTION: name="depth_b_tf" function="depth_b_tf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION depth_b_tf() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n raise notice '%: dept..." +== 355 +-- truncate_limit: 100 +create trigger depth_b_tr before insert on depth_b + for each row execute procedure depth_b_tf() +-- +TABLE: name="depth_b" schema="" table="depth_b" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER depth_b_tr BEFORE INSERT ON depth_b FOR EACH ROW EXECUTE FUNCTION depth_b_tf()" +== 356 +-- truncate_limit: 100 +create function depth_c_tf() returns trigger + language plpgsql as $$ +begin + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + if new.id = 1 then + raise exception sqlstate 'U9999'; + end if; + raise notice '%: depth = %', tg_name, pg_trigger_depth(); + return new; +end; +$$ +-- +FUNCTION: name="depth_c_tf" function="depth_c_tf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION depth_c_tf() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n raise notice '%: dept..." +== 357 +-- truncate_limit: 100 +create trigger depth_c_tr before insert on depth_c + for each row execute procedure depth_c_tf() +-- +TABLE: name="depth_c" schema="" table="depth_c" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER depth_c_tr BEFORE INSERT ON depth_c FOR EACH ROW EXECUTE FUNCTION depth_c_tf()" +== 358 +-- truncate_limit: 100 +select pg_trigger_depth() +-- +FUNCTION: name="pg_trigger_depth" function="pg_trigger_depth" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_trigger_depth()" +== 359 +-- truncate_limit: 100 +insert into depth_a values (1) +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO depth_a VALUES (1)" +== 360 +-- truncate_limit: 100 +select pg_trigger_depth() +-- +FUNCTION: name="pg_trigger_depth" function="pg_trigger_depth" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_trigger_depth()" +== 361 +-- truncate_limit: 100 +insert into depth_a values (2) +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO depth_a VALUES (2)" +== 362 +-- truncate_limit: 100 +select pg_trigger_depth() +-- +FUNCTION: name="pg_trigger_depth" function="pg_trigger_depth" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_trigger_depth()" +== 363 +-- truncate_limit: 100 +drop table depth_a, depth_b, depth_c +-- +TABLE: name="depth_a" schema="" table="depth_a" ctx=DDL +TABLE: name="depth_b" schema="" table="depth_b" ctx=DDL +TABLE: name="depth_c" schema="" table="depth_c" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE depth_a, depth_b, depth_c" +== 364 +-- truncate_limit: 100 +drop function depth_a_tf() +-- +FUNCTION: name="depth_a_tf" function="depth_a_tf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION depth_a_tf()" +== 365 +-- truncate_limit: 100 +drop function depth_b_tf() +-- +FUNCTION: name="depth_b_tf" function="depth_b_tf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION depth_b_tf()" +== 366 +-- truncate_limit: 100 +drop function depth_c_tf() +-- +FUNCTION: name="depth_c_tf" function="depth_c_tf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION depth_c_tf()" +== 367 +-- truncate_limit: 100 +|-- +-- Test updates to rows during firing of BEFORE ROW triggers. +-- As of 9.2, such cases should be rejected (see bug #6123). +|-- + +create temp table parent ( + aid int not null primary key, + val1 text, + val2 text, + val3 text, + val4 text, + bcnt int not null default 0) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parent (aid int NOT NULL PRIMARY KEY, val1 text, val2 text, val3 text, val..." +== 368 +-- truncate_limit: 100 +create temp table child ( + bid int not null primary key, + aid int not null, + val1 text) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE child (bid int NOT NULL PRIMARY KEY, aid int NOT NULL, val1 text)" +== 369 +-- truncate_limit: 100 +create function parent_upd_func() + returns trigger language plpgsql as +$$ +begin + if old.val1 <> new.val1 then + new.val2 = new.val1; + delete from child where child.aid = new.aid and child.val1 = new.val1; + end if; + return new; +end; +$$ +-- +FUNCTION: name="parent_upd_func" function="parent_upd_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION parent_upd_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n if old.val1 <> n..." +== 370 +-- truncate_limit: 100 +create trigger parent_upd_trig before update on parent + for each row execute procedure parent_upd_func() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_upd_trig BEFORE UPDATE ON parent FOR EACH ROW EXECUTE FUNCTION parent_upd_f..." +== 371 +-- truncate_limit: 100 +create function parent_del_func() + returns trigger language plpgsql as +$$ +begin + delete from child where aid = old.aid; + return old; +end; +$$ +-- +FUNCTION: name="parent_del_func" function="parent_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION parent_del_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n delete from chil..." +== 372 +-- truncate_limit: 100 +create trigger parent_del_trig before delete on parent + for each row execute procedure parent_del_func() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_del_trig BEFORE DELETE ON parent FOR EACH ROW EXECUTE FUNCTION parent_del_f..." +== 373 +-- truncate_limit: 100 +create function child_ins_func() + returns trigger language plpgsql as +$$ +begin + update parent set bcnt = bcnt + 1 where aid = new.aid; + return new; +end; +$$ +-- +FUNCTION: name="child_ins_func" function="child_ins_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION child_ins_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n update parent set..." +== 374 +-- truncate_limit: 100 +create trigger child_ins_trig after insert on child + for each row execute procedure child_ins_func() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child_ins_trig AFTER INSERT ON child FOR EACH ROW EXECUTE FUNCTION child_ins_func()" +== 375 +-- truncate_limit: 100 +create function child_del_func() + returns trigger language plpgsql as +$$ +begin + update parent set bcnt = bcnt - 1 where aid = old.aid; + return old; +end; +$$ +-- +FUNCTION: name="child_del_func" function="child_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION child_del_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n update parent set..." +== 376 +-- truncate_limit: 100 +create trigger child_del_trig after delete on child + for each row execute procedure child_del_func() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child_del_trig AFTER DELETE ON child FOR EACH ROW EXECUTE FUNCTION child_del_func()" +== 377 +-- truncate_limit: 100 +insert into parent values (1, 'a', 'a', 'a', 'a', 0) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES (1, 'a', 'a', 'a', 'a', 0)" +== 378 +-- truncate_limit: 100 +insert into child values (10, 1, 'b') +-- +TABLE: name="child" schema="" table="child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child VALUES (10, 1, 'b')" +== 379 +-- truncate_limit: 100 +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 380 +-- truncate_limit: 100 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM child" +== 381 +-- truncate_limit: 100 +update parent set val1 = 'b' where aid = 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parent SET val1 = 'b' WHERE aid = 1" +== 382 +-- truncate_limit: 100 +-- should fail +merge into parent p using (values (1)) as v(id) on p.aid = v.id + when matched then update set val1 = 'b' +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +ALIAS: "p"="parent" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO parent p USING (VALUES (1)) v(id) ON p.aid = v.id WHEN MATCHED THEN UPDATE SET val1 = 'b'" +== 383 +-- truncate_limit: 100 +-- should fail +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 384 +-- truncate_limit: 100 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM child" +== 385 +-- truncate_limit: 100 +delete from parent where aid = 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parent WHERE aid = 1" +== 386 +-- truncate_limit: 100 +-- should fail +merge into parent p using (values (1)) as v(id) on p.aid = v.id + when matched then delete +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +ALIAS: "p"="parent" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO parent p USING (VALUES (1)) v(id) ON p.aid = v.id WHEN MATCHED THEN DELETE" +== 387 +-- truncate_limit: 100 +-- should fail +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 388 +-- truncate_limit: 100 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM child" +== 389 +-- truncate_limit: 100 +-- replace the trigger function with one that restarts the deletion after +-- having modified a child +create or replace function parent_del_func() + returns trigger language plpgsql as +$$ +begin + delete from child where aid = old.aid; + if found then + delete from parent where aid = old.aid; + return null; -- cancel outer deletion + end if; + return old; +end; +$$ +-- +FUNCTION: name="parent_del_func" function="parent_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION parent_del_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n delet..." +== 390 +-- truncate_limit: 100 +delete from parent where aid = 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parent WHERE aid = 1" +== 391 +-- truncate_limit: 100 +select * from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 392 +-- truncate_limit: 100 +select * from child +-- +TABLE: name="child" schema="" table="child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM child" +== 393 +-- truncate_limit: 100 +drop table parent, child +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent, child" +== 394 +-- truncate_limit: 100 +drop function parent_upd_func() +-- +FUNCTION: name="parent_upd_func" function="parent_upd_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION parent_upd_func()" +== 395 +-- truncate_limit: 100 +drop function parent_del_func() +-- +FUNCTION: name="parent_del_func" function="parent_del_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION parent_del_func()" +== 396 +-- truncate_limit: 100 +drop function child_ins_func() +-- +FUNCTION: name="child_ins_func" function="child_ins_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION child_ins_func()" +== 397 +-- truncate_limit: 100 +drop function child_del_func() +-- +FUNCTION: name="child_del_func" function="child_del_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION child_del_func()" +== 398 +-- truncate_limit: 100 +-- similar case, but with a self-referencing FK so that parent and child +-- rows can be affected by a single operation + +create temp table self_ref_trigger ( + id int primary key, + parent int references self_ref_trigger, + data text, + nchildren int not null default 0 +) +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE self_ref_trigger (id int PRIMARY KEY, parent int REFERENCES self_ref_trigg..." +== 399 +-- truncate_limit: 100 +create function self_ref_trigger_ins_func() + returns trigger language plpgsql as +$$ +begin + if new.parent is not null then + update self_ref_trigger set nchildren = nchildren + 1 + where id = new.parent; + end if; + return new; +end; +$$ +-- +FUNCTION: name="self_ref_trigger_ins_func" function="self_ref_trigger_ins_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION self_ref_trigger_ins_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n if new..." +== 400 +-- truncate_limit: 100 +create trigger self_ref_trigger_ins_trig before insert on self_ref_trigger + for each row execute procedure self_ref_trigger_ins_func() +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER self_ref_trigger_ins_trig BEFORE INSERT ON self_ref_trigger FOR EACH ROW EXECUTE F..." +== 401 +-- truncate_limit: 100 +create function self_ref_trigger_del_func() + returns trigger language plpgsql as +$$ +begin + if old.parent is not null then + update self_ref_trigger set nchildren = nchildren - 1 + where id = old.parent; + end if; + return old; +end; +$$ +-- +FUNCTION: name="self_ref_trigger_del_func" function="self_ref_trigger_del_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION self_ref_trigger_del_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n if old..." +== 402 +-- truncate_limit: 100 +create trigger self_ref_trigger_del_trig before delete on self_ref_trigger + for each row execute procedure self_ref_trigger_del_func() +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER self_ref_trigger_del_trig BEFORE DELETE ON self_ref_trigger FOR EACH ROW EXECUTE F..." +== 403 +-- truncate_limit: 100 +insert into self_ref_trigger values (1, null, 'root') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO self_ref_trigger VALUES (1, NULL, 'root')" +== 404 +-- truncate_limit: 100 +insert into self_ref_trigger values (2, 1, 'root child A') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO self_ref_trigger VALUES (2, 1, 'root child A')" +== 405 +-- truncate_limit: 100 +insert into self_ref_trigger values (3, 1, 'root child B') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO self_ref_trigger VALUES (3, 1, 'root child B')" +== 406 +-- truncate_limit: 100 +insert into self_ref_trigger values (4, 2, 'grandchild 1') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO self_ref_trigger VALUES (4, 2, 'grandchild 1')" +== 407 +-- truncate_limit: 100 +insert into self_ref_trigger values (5, 3, 'grandchild 2') +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO self_ref_trigger VALUES (5, 3, 'grandchild 2')" +== 408 +-- truncate_limit: 100 +update self_ref_trigger set data = 'root!' where id = 1 +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE self_ref_trigger SET data = 'root!' WHERE id = 1" +== 409 +-- truncate_limit: 100 +select * from self_ref_trigger +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM self_ref_trigger" +== 410 +-- truncate_limit: 100 +delete from self_ref_trigger +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM self_ref_trigger" +== 411 +-- truncate_limit: 100 +select * from self_ref_trigger +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM self_ref_trigger" +== 412 +-- truncate_limit: 100 +drop table self_ref_trigger +-- +TABLE: name="self_ref_trigger" schema="" table="self_ref_trigger" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE self_ref_trigger" +== 413 +-- truncate_limit: 100 +drop function self_ref_trigger_ins_func() +-- +FUNCTION: name="self_ref_trigger_ins_func" function="self_ref_trigger_ins_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION self_ref_trigger_ins_func()" +== 414 +-- truncate_limit: 100 +drop function self_ref_trigger_del_func() +-- +FUNCTION: name="self_ref_trigger_del_func" function="self_ref_trigger_del_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION self_ref_trigger_del_func()" +== 415 +-- truncate_limit: 100 +|-- +-- Check that statement triggers work correctly even with all children excluded +|-- + +create table stmt_trig_on_empty_upd (a int) +-- +TABLE: name="stmt_trig_on_empty_upd" schema="" table="stmt_trig_on_empty_upd" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stmt_trig_on_empty_upd (a int)" +== 416 +-- truncate_limit: 100 +create table stmt_trig_on_empty_upd1 () inherits (stmt_trig_on_empty_upd) +-- +TABLE: name="stmt_trig_on_empty_upd1" schema="" table="stmt_trig_on_empty_upd1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stmt_trig_on_empty_upd1 () INHERITS (stmt_trig_on_empty_upd)" +== 417 +-- truncate_limit: 100 +create function update_stmt_notice() returns trigger as $$ +begin + raise notice 'updating %', TG_TABLE_NAME; + return null; +end; +$$ language plpgsql +-- +FUNCTION: name="update_stmt_notice" function="update_stmt_notice" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION update_stmt_notice() RETURNS trigger AS $$\nbegin\n\traise notice 'updating %', TG_T..." +== 418 +-- truncate_limit: 100 +create trigger before_stmt_trigger + before update on stmt_trig_on_empty_upd + execute procedure update_stmt_notice() +-- +TABLE: name="stmt_trig_on_empty_upd" schema="" table="stmt_trig_on_empty_upd" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER before_stmt_trigger BEFORE UPDATE ON stmt_trig_on_empty_upd EXECUTE FUNCTION updat..." +== 419 +-- truncate_limit: 100 +create trigger before_stmt_trigger + before update on stmt_trig_on_empty_upd1 + execute procedure update_stmt_notice() +-- +TABLE: name="stmt_trig_on_empty_upd1" schema="" table="stmt_trig_on_empty_upd1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER before_stmt_trigger BEFORE UPDATE ON stmt_trig_on_empty_upd1 EXECUTE FUNCTION upda..." +== 420 +-- truncate_limit: 100 +-- inherited no-op update +update stmt_trig_on_empty_upd set a = a where false returning a+1 as aa +-- +TABLE: name="stmt_trig_on_empty_upd" schema="" table="stmt_trig_on_empty_upd" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE stmt_trig_on_empty_upd SET a = a WHERE false RETURNING a + 1 AS aa" +== 421 +-- truncate_limit: 100 +-- simple no-op update +update stmt_trig_on_empty_upd1 set a = a where false returning a+1 as aa +-- +TABLE: name="stmt_trig_on_empty_upd1" schema="" table="stmt_trig_on_empty_upd1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE stmt_trig_on_empty_upd1 SET a = a WHERE false RETURNING a + 1 AS aa" +== 422 +-- truncate_limit: 100 +drop table stmt_trig_on_empty_upd cascade +-- +TABLE: name="stmt_trig_on_empty_upd" schema="" table="stmt_trig_on_empty_upd" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE stmt_trig_on_empty_upd CASCADE" +== 423 +-- truncate_limit: 100 +drop function update_stmt_notice() +-- +FUNCTION: name="update_stmt_notice" function="update_stmt_notice" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION update_stmt_notice()" +== 424 +-- truncate_limit: 100 +|-- +-- Check that index creation (or DDL in general) is prohibited in a trigger +|-- + +create table trigger_ddl_table ( + col1 integer, + col2 integer +) +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigger_ddl_table (col1 int, col2 int)" +== 425 +-- truncate_limit: 100 +create function trigger_ddl_func() returns trigger as $$ +begin + alter table trigger_ddl_table add primary key (col1); + return new; +end$$ language plpgsql +-- +FUNCTION: name="trigger_ddl_func" function="trigger_ddl_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trigger_ddl_func() RETURNS trigger AS $$\nbegin\n alter table trigger_ddl_table ad..." +== 426 +-- truncate_limit: 100 +create trigger trigger_ddl_func before insert on trigger_ddl_table for each row + execute procedure trigger_ddl_func() +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trigger_ddl_func BEFORE INSERT ON trigger_ddl_table FOR EACH ROW EXECUTE FUNCTION ..." +== 427 +-- truncate_limit: 100 +insert into trigger_ddl_table values (1, 42) +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigger_ddl_table VALUES (1, 42)" +== 428 +-- truncate_limit: 100 +-- fail + +create or replace function trigger_ddl_func() returns trigger as $$ +begin + create index on trigger_ddl_table (col2); + return new; +end$$ language plpgsql +-- +FUNCTION: name="trigger_ddl_func" function="trigger_ddl_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION trigger_ddl_func() RETURNS trigger AS $$\nbegin\n create index on trigg..." +== 429 +-- truncate_limit: 100 +insert into trigger_ddl_table values (1, 42) +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trigger_ddl_table VALUES (1, 42)" +== 430 +-- truncate_limit: 100 +-- fail + +drop table trigger_ddl_table +-- +TABLE: name="trigger_ddl_table" schema="" table="trigger_ddl_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigger_ddl_table" +== 431 +-- truncate_limit: 100 +drop function trigger_ddl_func() +-- +FUNCTION: name="trigger_ddl_func" function="trigger_ddl_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION trigger_ddl_func()" +== 432 +-- truncate_limit: 100 +|-- +-- Verify behavior of before and after triggers with INSERT...ON CONFLICT +-- DO UPDATE +|-- +create table upsert (key int4 primary key, color text) +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE upsert (key int4 PRIMARY KEY, color text)" +== 433 +-- truncate_limit: 100 +create function upsert_before_func() + returns trigger language plpgsql as +$$ +begin + if (TG_OP = 'UPDATE') then + raise warning 'before update (old): %', old.*::text; + raise warning 'before update (new): %', new.*::text; + elsif (TG_OP = 'INSERT') then + raise warning 'before insert (new): %', new.*::text; + if new.key % 2 = 0 then + new.key := new.key + 1; + new.color := new.color || ' trig modified'; + raise warning 'before insert (new, modified): %', new.*::text; + end if; + end if; + return new; +end; +$$ +-- +FUNCTION: name="upsert_before_func" function="upsert_before_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION upsert_before_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n if (TG_OP = '..." +== 434 +-- truncate_limit: 100 +create trigger upsert_before_trig before insert or update on upsert + for each row execute procedure upsert_before_func() +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER upsert_before_trig BEFORE INSERT OR UPDATE ON upsert FOR EACH ROW EXECUTE FUNCTION..." +== 435 +-- truncate_limit: 100 +create function upsert_after_func() + returns trigger language plpgsql as +$$ +begin + if (TG_OP = 'UPDATE') then + raise warning 'after update (old): %', old.*::text; + raise warning 'after update (new): %', new.*::text; + elsif (TG_OP = 'INSERT') then + raise warning 'after insert (new): %', new.*::text; + end if; + return null; +end; +$$ +-- +FUNCTION: name="upsert_after_func" function="upsert_after_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION upsert_after_func() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n if (TG_OP = 'U..." +== 436 +-- truncate_limit: 100 +create trigger upsert_after_trig after insert or update on upsert + for each row execute procedure upsert_after_func() +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER upsert_after_trig AFTER INSERT OR UPDATE ON upsert FOR EACH ROW EXECUTE FUNCTION u..." +== 437 +-- truncate_limit: 100 +insert into upsert values(1, 'black') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (1, 'black') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 438 +-- truncate_limit: 100 +insert into upsert values(2, 'red') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (2, 'red') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 439 +-- truncate_limit: 100 +insert into upsert values(3, 'orange') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (3, 'orange') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 440 +-- truncate_limit: 100 +insert into upsert values(4, 'green') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (4, 'green') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 441 +-- truncate_limit: 100 +insert into upsert values(5, 'purple') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (5, 'purple') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 442 +-- truncate_limit: 100 +insert into upsert values(6, 'white') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (6, 'white') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 443 +-- truncate_limit: 100 +insert into upsert values(7, 'pink') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (7, 'pink') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 444 +-- truncate_limit: 100 +insert into upsert values(8, 'yellow') on conflict (key) do update set color = 'updated ' || upsert.color +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert VALUES (8, 'yellow') ON CONFLICT (key) DO UPDATE SET ... = ..." +== 445 +-- truncate_limit: 100 +select * from upsert +-- +TABLE: name="upsert" schema="" table="upsert" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM upsert" +== 446 +-- truncate_limit: 100 +drop table upsert +-- +TABLE: name="upsert" schema="" table="upsert" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE upsert" +== 447 +-- truncate_limit: 100 +drop function upsert_before_func() +-- +FUNCTION: name="upsert_before_func" function="upsert_before_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION upsert_before_func()" +== 448 +-- truncate_limit: 100 +drop function upsert_after_func() +-- +FUNCTION: name="upsert_after_func" function="upsert_after_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION upsert_after_func()" +== 449 +-- truncate_limit: 100 +|-- +-- Verify that triggers with transition tables are not allowed on +-- views +|-- + +create table my_table (i int) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE my_table (i int)" +== 450 +-- truncate_limit: 100 +create view my_view as select * from my_table +-- +TABLE: name="my_view" schema="" table="my_view" ctx=DDL +TABLE: name="my_table" schema="" table="my_table" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW my_view AS SELECT * FROM my_table" +== 451 +-- truncate_limit: 100 +create function my_trigger_function() returns trigger as $$ begin end; $$ language plpgsql +-- +FUNCTION: name="my_trigger_function" function="my_trigger_function" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION my_trigger_function() RETURNS trigger AS $$ begin end; $$ LANGUAGE plpgsql" +== 452 +-- truncate_limit: 100 +create trigger my_trigger after update on my_view referencing old table as old_table + for each statement execute procedure my_trigger_function() +-- +TABLE: name="my_view" schema="" table="my_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_trigger AFTER UPDATE ON my_view REFERENCING OLD TABLE old_table EXECUTE FUNCTIO..." +== 453 +-- truncate_limit: 100 +drop function my_trigger_function() +-- +FUNCTION: name="my_trigger_function" function="my_trigger_function" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION my_trigger_function()" +== 454 +-- truncate_limit: 100 +drop view my_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW my_view" +== 455 +-- truncate_limit: 100 +drop table my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE my_table" +== 456 +-- truncate_limit: 100 +|-- +-- Verify cases that are unsupported with partitioned tables +|-- +create table parted_trig (a int) partition by list (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig (a int) PARTITION BY LIST (a)" +== 457 +-- truncate_limit: 100 +create function trigger_nothing() returns trigger + language plpgsql as $$ begin end; $$ +-- +FUNCTION: name="trigger_nothing" function="trigger_nothing" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trigger_nothing() RETURNS trigger LANGUAGE plpgsql AS $$ begin end; $$" +== 458 +-- truncate_limit: 100 +create trigger failed instead of update on parted_trig + for each row execute procedure trigger_nothing() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER failed INSTEAD OF UPDATE ON parted_trig FOR EACH ROW EXECUTE FUNCTION trigger_noth..." +== 459 +-- truncate_limit: 100 +create trigger failed after update on parted_trig + referencing old table as old_table + for each row execute procedure trigger_nothing() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER failed AFTER UPDATE ON parted_trig REFERENCING OLD TABLE old_table FOR EACH ROW EX..." +== 460 +-- truncate_limit: 100 +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_trig" +== 461 +-- truncate_limit: 100 +|-- +-- Verify trigger creation for partitioned tables, and drop behavior +|-- +create table trigpart (a int, b int) partition by range (a) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigpart (a int, b int) PARTITION BY RANGE (a)" +== 462 +-- truncate_limit: 100 +create table trigpart1 partition of trigpart for values from (0) to (1000) +-- +TABLE: name="trigpart1" schema="" table="trigpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigpart1 PARTITION OF trigpart FOR VALUES FROM (0) TO (1000)" +== 463 +-- truncate_limit: 100 +create trigger trg1 after insert on trigpart for each row execute procedure trigger_nothing() +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trg1 AFTER INSERT ON trigpart FOR EACH ROW EXECUTE FUNCTION trigger_nothing()" +== 464 +-- truncate_limit: 100 +create table trigpart2 partition of trigpart for values from (1000) to (2000) +-- +TABLE: name="trigpart2" schema="" table="trigpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigpart2 PARTITION OF trigpart FOR VALUES FROM (1000) TO (2000)" +== 465 +-- truncate_limit: 100 +create table trigpart3 (like trigpart) +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigpart3 (LIKE trigpart)" +== 466 +-- truncate_limit: 100 +alter table trigpart attach partition trigpart3 for values from (2000) to (3000) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigpart ATTACH PARTITION trigpart3 FOR VALUES FROM (2000) TO (3000)" +== 467 +-- truncate_limit: 100 +create table trigpart4 partition of trigpart for values from (3000) to (4000) partition by range (a) +-- +TABLE: name="trigpart4" schema="" table="trigpart4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigpart4 PARTITION OF trigpart FOR VALUES FROM (3000) TO (4000) PARTITION BY RANGE (a)" +== 468 +-- truncate_limit: 100 +create table trigpart41 partition of trigpart4 for values from (3000) to (3500) +-- +TABLE: name="trigpart41" schema="" table="trigpart41" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigpart41 PARTITION OF trigpart4 FOR VALUES FROM (3000) TO (3500)" +== 469 +-- truncate_limit: 100 +create table trigpart42 (like trigpart) +-- +TABLE: name="trigpart42" schema="" table="trigpart42" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigpart42 (LIKE trigpart)" +== 470 +-- truncate_limit: 100 +alter table trigpart4 attach partition trigpart42 for values from (3500) to (4000) +-- +TABLE: name="trigpart4" schema="" table="trigpart4" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigpart4 ATTACH PARTITION trigpart42 FOR VALUES FROM (3500) TO (4000)" +== 471 +-- truncate_limit: 100 +select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger + where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text" +== 472 +-- truncate_limit: 100 +drop trigger trg1 on trigpart1 +-- +TABLE: name="trigpart1" schema="" table="trigpart1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trg1 ON trigpart1" +== 473 +-- truncate_limit: 100 +-- fail +drop trigger trg1 on trigpart2 +-- +TABLE: name="trigpart2" schema="" table="trigpart2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trg1 ON trigpart2" +== 474 +-- truncate_limit: 100 +-- fail +drop trigger trg1 on trigpart3 +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trg1 ON trigpart3" +== 475 +-- truncate_limit: 100 +-- fail +drop table trigpart2 +-- +TABLE: name="trigpart2" schema="" table="trigpart2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigpart2" +== 476 +-- truncate_limit: 100 +-- ok, trigger should be gone in that partition +select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger + where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text" +== 477 +-- truncate_limit: 100 +drop trigger trg1 on trigpart +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trg1 ON trigpart" +== 478 +-- truncate_limit: 100 +-- ok, all gone +select tgrelid::regclass, tgname, tgfoid::regproc from pg_trigger + where tgrelid::regclass::text like 'trigpart%' order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text" +== 479 +-- truncate_limit: 100 +-- check detach behavior +create trigger trg1 after insert on trigpart for each row execute procedure trigger_nothing() +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trg1 AFTER INSERT ON trigpart FOR EACH ROW EXECUTE FUNCTION trigger_nothing()" +== 480 +-- truncate_limit: 100 +alter table trigpart detach partition trigpart3 +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigpart DETACH PARTITION trigpart3" +== 481 +-- truncate_limit: 100 +drop trigger trg1 on trigpart3 +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trg1 ON trigpart3" +== 482 +-- truncate_limit: 100 +-- fail due to "does not exist" +alter table trigpart detach partition trigpart4 +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigpart DETACH PARTITION trigpart4" +== 483 +-- truncate_limit: 100 +drop trigger trg1 on trigpart41 +-- +TABLE: name="trigpart41" schema="" table="trigpart41" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trg1 ON trigpart41" +== 484 +-- truncate_limit: 100 +-- fail due to "does not exist" +drop table trigpart4 +-- +TABLE: name="trigpart4" schema="" table="trigpart4" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigpart4" +== 485 +-- truncate_limit: 100 +alter table trigpart attach partition trigpart3 for values from (2000) to (3000) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigpart ATTACH PARTITION trigpart3 FOR VALUES FROM (2000) TO (3000)" +== 486 +-- truncate_limit: 100 +alter table trigpart detach partition trigpart3 +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigpart DETACH PARTITION trigpart3" +== 487 +-- truncate_limit: 100 +alter table trigpart attach partition trigpart3 for values from (2000) to (3000) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigpart ATTACH PARTITION trigpart3 FOR VALUES FROM (2000) TO (3000)" +== 488 +-- truncate_limit: 100 +drop table trigpart3 +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigpart3" +== 489 +-- truncate_limit: 100 +select tgrelid::regclass::text, tgname, tgfoid::regproc, tgenabled, tgisinternal from pg_trigger + where tgname ~ '^trg1' order by 1 +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE tgname ~ '^trg1' ORDER BY 1" +== 490 +-- truncate_limit: 100 +create table trigpart3 (like trigpart) +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigpart3 (LIKE trigpart)" +== 491 +-- truncate_limit: 100 +create trigger trg1 after insert on trigpart3 for each row execute procedure trigger_nothing() +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trg1 AFTER INSERT ON trigpart3 FOR EACH ROW EXECUTE FUNCTION trigger_nothing()" +== 492 +-- truncate_limit: 100 +alter table trigpart attach partition trigpart3 FOR VALUES FROM (2000) to (3000) +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigpart ATTACH PARTITION trigpart3 FOR VALUES FROM (2000) TO (3000)" +== 493 +-- truncate_limit: 100 +-- fail +drop table trigpart3 +-- +TABLE: name="trigpart3" schema="" table="trigpart3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigpart3" +== 494 +-- truncate_limit: 100 +-- check display of unrelated triggers +create trigger samename after delete on trigpart execute function trigger_nothing() +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER samename AFTER DELETE ON trigpart EXECUTE FUNCTION trigger_nothing()" +== 495 +-- truncate_limit: 100 +create trigger samename after delete on trigpart1 execute function trigger_nothing() +-- +TABLE: name="trigpart1" schema="" table="trigpart1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER samename AFTER DELETE ON trigpart1 EXECUTE FUNCTION trigger_nothing()" +== 496 +-- truncate_limit: 100 +drop table trigpart +-- +TABLE: name="trigpart" schema="" table="trigpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trigpart" +== 497 +-- truncate_limit: 100 +drop function trigger_nothing() +-- +FUNCTION: name="trigger_nothing" function="trigger_nothing" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION trigger_nothing()" +== 498 +-- truncate_limit: 100 +|-- +-- Verify that triggers are fired for partitioned tables +|-- +create table parted_stmt_trig (a int) partition by list (a) +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_stmt_trig (a int) PARTITION BY LIST (a)" +== 499 +-- truncate_limit: 100 +create table parted_stmt_trig1 partition of parted_stmt_trig for values in (1) +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_stmt_trig1 PARTITION OF parted_stmt_trig FOR VALUES IN (1)" +== 500 +-- truncate_limit: 100 +create table parted_stmt_trig2 partition of parted_stmt_trig for values in (2) +-- +TABLE: name="parted_stmt_trig2" schema="" table="parted_stmt_trig2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_stmt_trig2 PARTITION OF parted_stmt_trig FOR VALUES IN (2)" +== 501 +-- truncate_limit: 100 +create table parted2_stmt_trig (a int) partition by list (a) +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted2_stmt_trig (a int) PARTITION BY LIST (a)" +== 502 +-- truncate_limit: 100 +create table parted2_stmt_trig1 partition of parted2_stmt_trig for values in (1) +-- +TABLE: name="parted2_stmt_trig1" schema="" table="parted2_stmt_trig1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted2_stmt_trig1 PARTITION OF parted2_stmt_trig FOR VALUES IN (1)" +== 503 +-- truncate_limit: 100 +create table parted2_stmt_trig2 partition of parted2_stmt_trig for values in (2) +-- +TABLE: name="parted2_stmt_trig2" schema="" table="parted2_stmt_trig2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted2_stmt_trig2 PARTITION OF parted2_stmt_trig FOR VALUES IN (2)" +== 504 +-- truncate_limit: 100 +create or replace function trigger_notice() returns trigger as $$ + begin + raise notice 'trigger % on % % % for %', TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL; + if TG_LEVEL = 'ROW' then + return NEW; + end if; + return null; + end; + $$ language plpgsql +-- +FUNCTION: name="trigger_notice" function="trigger_notice" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION trigger_notice() RETURNS trigger AS $$\n begin\n raise notice 'trigg..." +== 505 +-- truncate_limit: 100 +-- insert/update/delete statement-level triggers on the parent +create trigger trig_ins_before before insert on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_ins_before BEFORE INSERT ON parted_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 506 +-- truncate_limit: 100 +create trigger trig_ins_after after insert on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_ins_after AFTER INSERT ON parted_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 507 +-- truncate_limit: 100 +create trigger trig_upd_before before update on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_upd_before BEFORE UPDATE ON parted_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 508 +-- truncate_limit: 100 +create trigger trig_upd_after after update on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_upd_after AFTER UPDATE ON parted_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 509 +-- truncate_limit: 100 +create trigger trig_del_before before delete on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_del_before BEFORE DELETE ON parted_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 510 +-- truncate_limit: 100 +create trigger trig_del_after after delete on parted_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_del_after AFTER DELETE ON parted_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 511 +-- truncate_limit: 100 +-- insert/update/delete row-level triggers on the parent +create trigger trig_ins_after_parent after insert on parted_stmt_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_ins_after_parent AFTER INSERT ON parted_stmt_trig FOR EACH ROW EXECUTE FUNCTI..." +== 512 +-- truncate_limit: 100 +create trigger trig_upd_after_parent after update on parted_stmt_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_upd_after_parent AFTER UPDATE ON parted_stmt_trig FOR EACH ROW EXECUTE FUNCTI..." +== 513 +-- truncate_limit: 100 +create trigger trig_del_after_parent after delete on parted_stmt_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_del_after_parent AFTER DELETE ON parted_stmt_trig FOR EACH ROW EXECUTE FUNCTI..." +== 514 +-- truncate_limit: 100 +-- insert/update/delete row-level triggers on the first partition +create trigger trig_ins_before_child before insert on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_ins_before_child BEFORE INSERT ON parted_stmt_trig1 FOR EACH ROW EXECUTE FUNC..." +== 515 +-- truncate_limit: 100 +create trigger trig_ins_after_child after insert on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_ins_after_child AFTER INSERT ON parted_stmt_trig1 FOR EACH ROW EXECUTE FUNCTI..." +== 516 +-- truncate_limit: 100 +create trigger trig_upd_before_child before update on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_upd_before_child BEFORE UPDATE ON parted_stmt_trig1 FOR EACH ROW EXECUTE FUNC..." +== 517 +-- truncate_limit: 100 +create trigger trig_upd_after_child after update on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_upd_after_child AFTER UPDATE ON parted_stmt_trig1 FOR EACH ROW EXECUTE FUNCTI..." +== 518 +-- truncate_limit: 100 +create trigger trig_del_before_child before delete on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_del_before_child BEFORE DELETE ON parted_stmt_trig1 FOR EACH ROW EXECUTE FUNC..." +== 519 +-- truncate_limit: 100 +create trigger trig_del_after_child after delete on parted_stmt_trig1 + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_del_after_child AFTER DELETE ON parted_stmt_trig1 FOR EACH ROW EXECUTE FUNCTI..." +== 520 +-- truncate_limit: 100 +-- insert/update/delete statement-level triggers on the parent +create trigger trig_ins_before_3 before insert on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_ins_before_3 BEFORE INSERT ON parted2_stmt_trig EXECUTE FUNCTION trigger_noti..." +== 521 +-- truncate_limit: 100 +create trigger trig_ins_after_3 after insert on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_ins_after_3 AFTER INSERT ON parted2_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 522 +-- truncate_limit: 100 +create trigger trig_upd_before_3 before update on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_upd_before_3 BEFORE UPDATE ON parted2_stmt_trig EXECUTE FUNCTION trigger_noti..." +== 523 +-- truncate_limit: 100 +create trigger trig_upd_after_3 after update on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_upd_after_3 AFTER UPDATE ON parted2_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 524 +-- truncate_limit: 100 +create trigger trig_del_before_3 before delete on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_del_before_3 BEFORE DELETE ON parted2_stmt_trig EXECUTE FUNCTION trigger_noti..." +== 525 +-- truncate_limit: 100 +create trigger trig_del_after_3 after delete on parted2_stmt_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_del_after_3 AFTER DELETE ON parted2_stmt_trig EXECUTE FUNCTION trigger_notice()" +== 526 +-- truncate_limit: 100 +with ins (a) as ( + insert into parted2_stmt_trig values (1), (2) returning a +) insert into parted_stmt_trig select a from ins returning tableoid::regclass, a +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DML +CTE: "ins" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH ins(a) AS (...) INSERT INTO parted_stmt_trig SELECT a FROM ins RETURNING tableoid::regclass, a" +== 527 +-- truncate_limit: 100 +with upd as ( + update parted2_stmt_trig set a = a +) update parted_stmt_trig set a = a +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DML +CTE: "upd" +STMT: UpdateStmt +TRUNCATED: "WITH upd AS (UPDATE parted2_stmt_trig SET a = a) UPDATE parted_stmt_trig SET a = a" +== 528 +-- truncate_limit: 100 +delete from parted_stmt_trig +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parted_stmt_trig" +== 529 +-- truncate_limit: 100 +-- insert via copy on the parent +copy parted_stmt_trig(a) from stdin +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY parted_stmt_trig(a) FROM STDIN" +== 530 +-- truncate_limit: 100 +-- insert via copy on the first partition +copy parted_stmt_trig1(a) from stdin +-- +TABLE: name="parted_stmt_trig1" schema="" table="parted_stmt_trig1" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY parted_stmt_trig1(a) FROM STDIN" +== 531 +-- truncate_limit: 100 +-- Disabling a trigger in the parent table should disable children triggers too +alter table parted_stmt_trig disable trigger trig_ins_after_parent +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_stmt_trig DISABLE TRIGGER trig_ins_after_parent" +== 532 +-- truncate_limit: 100 +insert into parted_stmt_trig values (1) +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_stmt_trig VALUES (1)" +== 533 +-- truncate_limit: 100 +alter table parted_stmt_trig enable trigger trig_ins_after_parent +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_stmt_trig ENABLE TRIGGER trig_ins_after_parent" +== 534 +-- truncate_limit: 100 +insert into parted_stmt_trig values (1) +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_stmt_trig VALUES (1)" +== 535 +-- truncate_limit: 100 +drop table parted_stmt_trig, parted2_stmt_trig +-- +TABLE: name="parted_stmt_trig" schema="" table="parted_stmt_trig" ctx=DDL +TABLE: name="parted2_stmt_trig" schema="" table="parted2_stmt_trig" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_stmt_trig, parted2_stmt_trig" +== 536 +-- truncate_limit: 100 +-- Verify that triggers fire in alphabetical order +create table parted_trig (a int) partition by range (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig (a int) PARTITION BY RANGE (a)" +== 537 +-- truncate_limit: 100 +create table parted_trig_1 partition of parted_trig for values from (0) to (1000) + partition by range (a) +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig_1 PARTITION OF parted_trig FOR VALUES FROM (0) TO (1000) PARTITION BY RA..." +== 538 +-- truncate_limit: 100 +create table parted_trig_1_1 partition of parted_trig_1 for values from (0) to (100) +-- +TABLE: name="parted_trig_1_1" schema="" table="parted_trig_1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig_1_1 PARTITION OF parted_trig_1 FOR VALUES FROM (0) TO (100)" +== 539 +-- truncate_limit: 100 +create table parted_trig_2 partition of parted_trig for values from (1000) to (2000) +-- +TABLE: name="parted_trig_2" schema="" table="parted_trig_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig_2 PARTITION OF parted_trig FOR VALUES FROM (1000) TO (2000)" +== 540 +-- truncate_limit: 100 +create trigger zzz after insert on parted_trig for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER zzz AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE FUNCTION trigger_notice()" +== 541 +-- truncate_limit: 100 +create trigger mmm after insert on parted_trig_1_1 for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig_1_1" schema="" table="parted_trig_1_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER mmm AFTER INSERT ON parted_trig_1_1 FOR EACH ROW EXECUTE FUNCTION trigger_notice()" +== 542 +-- truncate_limit: 100 +create trigger aaa after insert on parted_trig_1 for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER aaa AFTER INSERT ON parted_trig_1 FOR EACH ROW EXECUTE FUNCTION trigger_notice()" +== 543 +-- truncate_limit: 100 +create trigger bbb after insert on parted_trig for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER bbb AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE FUNCTION trigger_notice()" +== 544 +-- truncate_limit: 100 +create trigger qqq after insert on parted_trig_1_1 for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig_1_1" schema="" table="parted_trig_1_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER qqq AFTER INSERT ON parted_trig_1_1 FOR EACH ROW EXECUTE FUNCTION trigger_notice()" +== 545 +-- truncate_limit: 100 +insert into parted_trig values (50), (1500) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig VALUES (50), (1500)" +== 546 +-- truncate_limit: 100 +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_trig" +== 547 +-- truncate_limit: 100 +-- Verify that the correct triggers fire for cross-partition updates +create table parted_trig (a int) partition by list (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig (a int) PARTITION BY LIST (a)" +== 548 +-- truncate_limit: 100 +create table parted_trig1 partition of parted_trig for values in (1) +-- +TABLE: name="parted_trig1" schema="" table="parted_trig1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig1 PARTITION OF parted_trig FOR VALUES IN (1)" +== 549 +-- truncate_limit: 100 +create table parted_trig2 partition of parted_trig for values in (2) +-- +TABLE: name="parted_trig2" schema="" table="parted_trig2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig2 PARTITION OF parted_trig FOR VALUES IN (2)" +== 550 +-- truncate_limit: 100 +insert into parted_trig values (1) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig VALUES (1)" +== 551 +-- truncate_limit: 100 +create or replace function trigger_notice() returns trigger as $$ + begin + raise notice 'trigger % on % % % for %', TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL; + if TG_LEVEL = 'ROW' then + if TG_OP = 'DELETE' then + return OLD; + else + return NEW; + end if; + end if; + return null; + end; + $$ language plpgsql +-- +FUNCTION: name="trigger_notice" function="trigger_notice" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION trigger_notice() RETURNS trigger AS $$\n begin\n raise notice 'trigg..." +== 552 +-- truncate_limit: 100 +create trigger parted_trig_before_stmt before insert or update or delete on parted_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_trig_before_stmt BEFORE INSERT OR DELETE OR UPDATE ON parted_trig EXECUTE F..." +== 553 +-- truncate_limit: 100 +create trigger parted_trig_before_row before insert or update or delete on parted_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_trig_before_row BEFORE INSERT OR DELETE OR UPDATE ON parted_trig FOR EACH R..." +== 554 +-- truncate_limit: 100 +create trigger parted_trig_after_row after insert or update or delete on parted_trig + for each row execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_trig_after_row AFTER INSERT OR DELETE OR UPDATE ON parted_trig FOR EACH ROW..." +== 555 +-- truncate_limit: 100 +create trigger parted_trig_after_stmt after insert or update or delete on parted_trig + for each statement execute procedure trigger_notice() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_trig_after_stmt AFTER INSERT OR DELETE OR UPDATE ON parted_trig EXECUTE FUN..." +== 556 +-- truncate_limit: 100 +update parted_trig set a = 2 where a = 1 +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted_trig SET a = 2 WHERE a = 1" +== 557 +-- truncate_limit: 100 +-- update action in merge should behave the same +merge into parted_trig using (select 1) as ss on true + when matched and a = 2 then update set a = 1 +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO parted_trig USING (SELECT 1) ss ON true WHEN MATCHED AND a = 2 THEN UPDATE SET a = 1" +== 558 +-- truncate_limit: 100 +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_trig" +== 559 +-- truncate_limit: 100 +-- Verify propagation of trigger arguments to partitions +create table parted_trig (a int) partition by list (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig (a int) PARTITION BY LIST (a)" +== 560 +-- truncate_limit: 100 +create table parted_trig1 partition of parted_trig for values in (1) +-- +TABLE: name="parted_trig1" schema="" table="parted_trig1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig1 PARTITION OF parted_trig FOR VALUES IN (1)" +== 561 +-- truncate_limit: 100 +create or replace function trigger_notice() returns trigger as $$ + declare + arg1 text = TG_ARGV[0]; + arg2 integer = TG_ARGV[1]; + begin + raise notice 'trigger % on % % % for % args % %', + TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, arg1, arg2; + return null; + end; + $$ language plpgsql +-- +FUNCTION: name="trigger_notice" function="trigger_notice" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION trigger_notice() RETURNS trigger AS $$\n declare\n arg1 text = TG_AR..." +== 562 +-- truncate_limit: 100 +create trigger aaa after insert on parted_trig + for each row execute procedure trigger_notice('quirky', 1) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER aaa AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE FUNCTION trigger_notice('quir..." +== 563 +-- truncate_limit: 100 +-- Verify propagation of trigger arguments to partitions attached after creating trigger +create table parted_trig2 partition of parted_trig for values in (2) +-- +TABLE: name="parted_trig2" schema="" table="parted_trig2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig2 PARTITION OF parted_trig FOR VALUES IN (2)" +== 564 +-- truncate_limit: 100 +create table parted_trig3 (like parted_trig) +-- +TABLE: name="parted_trig3" schema="" table="parted_trig3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig3 (LIKE parted_trig)" +== 565 +-- truncate_limit: 100 +alter table parted_trig attach partition parted_trig3 for values in (3) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trig ATTACH PARTITION parted_trig3 FOR VALUES IN (3)" +== 566 +-- truncate_limit: 100 +insert into parted_trig values (1), (2), (3) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig VALUES (1), (2), (3)" +== 567 +-- truncate_limit: 100 +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_trig" +== 568 +-- truncate_limit: 100 +-- test irregular partitions (i.e., different column definitions), +-- including that the WHEN clause works +create function bark(text) returns bool language plpgsql immutable + as $$ begin raise notice '% <- woof!', $1; return true; end; $$ +-- +FUNCTION: name="bark" function="bark" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION bark(text) RETURNS bool LANGUAGE plpgsql IMMUTABLE AS $$ begin raise notice '% <-..." +== 569 +-- truncate_limit: 100 +create or replace function trigger_notice_ab() returns trigger as $$ + begin + raise notice 'trigger % on % % % for %: (a,b)=(%,%)', + TG_NAME, TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, + NEW.a, NEW.b; + if TG_LEVEL = 'ROW' then + return NEW; + end if; + return null; + end; + $$ language plpgsql +-- +FUNCTION: name="trigger_notice_ab" function="trigger_notice_ab" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION trigger_notice_ab() RETURNS trigger AS $$\n begin\n raise notice 'tr..." +== 570 +-- truncate_limit: 100 +create table parted_irreg_ancestor (fd text, b text, fd2 int, fd3 int, a int) + partition by range (b) +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_irreg_ancestor (fd text, b text, fd2 int, fd3 int, a int) PARTITION BY RANGE (b)" +== 571 +-- truncate_limit: 100 +alter table parted_irreg_ancestor drop column fd, + drop column fd2, drop column fd3 +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_irreg_ancestor DROP fd, DROP fd2, DROP fd3" +== 572 +-- truncate_limit: 100 +create table parted_irreg (fd int, a int, fd2 int, b text) + partition by range (b) +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_irreg (fd int, a int, fd2 int, b text) PARTITION BY RANGE (b)" +== 573 +-- truncate_limit: 100 +alter table parted_irreg drop column fd, drop column fd2 +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_irreg DROP fd, DROP fd2" +== 574 +-- truncate_limit: 100 +alter table parted_irreg_ancestor attach partition parted_irreg + for values from ('aaaa') to ('zzzz') +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_irreg_ancestor ATTACH PARTITION parted_irreg FOR VALUES FROM ('aaaa') TO ('zzzz')" +== 575 +-- truncate_limit: 100 +create table parted1_irreg (b text, fd int, a int) +-- +TABLE: name="parted1_irreg" schema="" table="parted1_irreg" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted1_irreg (b text, fd int, a int)" +== 576 +-- truncate_limit: 100 +alter table parted1_irreg drop column fd +-- +TABLE: name="parted1_irreg" schema="" table="parted1_irreg" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted1_irreg DROP fd" +== 577 +-- truncate_limit: 100 +alter table parted_irreg attach partition parted1_irreg + for values from ('aaaa') to ('bbbb') +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_irreg ATTACH PARTITION parted1_irreg FOR VALUES FROM ('aaaa') TO ('bbbb')" +== 578 +-- truncate_limit: 100 +create trigger parted_trig after insert on parted_irreg + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_trig AFTER INSERT ON parted_irreg FOR EACH ROW EXECUTE FUNCTION trigger_not..." +== 579 +-- truncate_limit: 100 +create trigger parted_trig_odd after insert on parted_irreg for each row + when (bark(new.b) AND new.a % 2 = 1) execute procedure trigger_notice_ab() +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_trig_odd AFTER INSERT ON parted_irreg FOR EACH ROW WHEN (bark(new.b) AND (n..." +== 580 +-- truncate_limit: 100 +-- we should hear barking for every insert, but parted_trig_odd only emits +-- noise for odd values of a. parted_trig does it for all inserts. +insert into parted_irreg values (1, 'aardvark'), (2, 'aanimals') +-- +TABLE: name="parted_irreg" schema="" table="parted_irreg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_irreg VALUES (1, 'aardvark'), (2, 'aanimals')" +== 581 +-- truncate_limit: 100 +insert into parted1_irreg values ('aardwolf', 2) +-- +TABLE: name="parted1_irreg" schema="" table="parted1_irreg" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted1_irreg VALUES ('aardwolf', 2)" +== 582 +-- truncate_limit: 100 +insert into parted_irreg_ancestor values ('aasvogel', 3) +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_irreg_ancestor VALUES ('aasvogel', 3)" +== 583 +-- truncate_limit: 100 +drop table parted_irreg_ancestor +-- +TABLE: name="parted_irreg_ancestor" schema="" table="parted_irreg_ancestor" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_irreg_ancestor" +== 584 +-- truncate_limit: 100 +-- Before triggers and partitions +create table parted (a int, b int, c text) partition by list (a) +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted (a int, b int, c text) PARTITION BY LIST (a)" +== 585 +-- truncate_limit: 100 +create table parted_1 partition of parted for values in (1) + partition by list (b) +-- +TABLE: name="parted_1" schema="" table="parted_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_1 PARTITION OF parted FOR VALUES IN (1) PARTITION BY LIST (b)" +== 586 +-- truncate_limit: 100 +create table parted_1_1 partition of parted_1 for values in (1) +-- +TABLE: name="parted_1_1" schema="" table="parted_1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_1_1 PARTITION OF parted_1 FOR VALUES IN (1)" +== 587 +-- truncate_limit: 100 +create function parted_trigfunc() returns trigger language plpgsql as $$ +begin + new.a = new.a + 1; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION parted_trigfunc() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n new.a = new.a + ..." +== 588 +-- truncate_limit: 100 +insert into parted values (1, 1, 'uno uno v1') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (1, 1, 'uno uno v1')" +== 589 +-- truncate_limit: 100 +-- works +create trigger t before insert or update or delete on parted + for each row execute function parted_trigfunc() +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER t BEFORE INSERT OR DELETE OR UPDATE ON parted FOR EACH ROW EXECUTE FUNCTION parted..." +== 590 +-- truncate_limit: 100 +insert into parted values (1, 1, 'uno uno v2') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (1, 1, 'uno uno v2')" +== 591 +-- truncate_limit: 100 +-- fail +update parted set c = c || 'v3' +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted SET c = c || 'v3'" +== 592 +-- truncate_limit: 100 +-- fail +create or replace function parted_trigfunc() returns trigger language plpgsql as $$ +begin + new.b = new.b + 1; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION parted_trigfunc() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n new.b..." +== 593 +-- truncate_limit: 100 +insert into parted values (1, 1, 'uno uno v4') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (1, 1, 'uno uno v4')" +== 594 +-- truncate_limit: 100 +-- fail +update parted set c = c || 'v5' +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted SET c = c || 'v5'" +== 595 +-- truncate_limit: 100 +-- fail +create or replace function parted_trigfunc() returns trigger language plpgsql as $$ +begin + new.c = new.c || ' did '|| TG_OP; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION parted_trigfunc() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n new.c..." +== 596 +-- truncate_limit: 100 +insert into parted values (1, 1, 'uno uno') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (1, 1, 'uno uno')" +== 597 +-- truncate_limit: 100 +-- works +update parted set c = c || ' v6' +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted SET c = c || ' v6'" +== 598 +-- truncate_limit: 100 +-- works +select tableoid::regclass, * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM parted" +== 599 +-- truncate_limit: 100 +-- update itself moves tuple to new partition; trigger still works +truncate table parted +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted" +== 600 +-- truncate_limit: 100 +create table parted_2 partition of parted for values in (2) +-- +TABLE: name="parted_2" schema="" table="parted_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_2 PARTITION OF parted FOR VALUES IN (2)" +== 601 +-- truncate_limit: 100 +insert into parted values (1, 1, 'uno uno v5') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (1, 1, 'uno uno v5')" +== 602 +-- truncate_limit: 100 +update parted set a = 2 +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted SET a = 2" +== 603 +-- truncate_limit: 100 +select tableoid::regclass, * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM parted" +== 604 +-- truncate_limit: 100 +-- both trigger and update change the partition +create or replace function parted_trigfunc2() returns trigger language plpgsql as $$ +begin + new.a = new.a + 1; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc2" function="parted_trigfunc2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION parted_trigfunc2() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n new...." +== 605 +-- truncate_limit: 100 +create trigger t2 before update on parted + for each row execute function parted_trigfunc2() +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER t2 BEFORE UPDATE ON parted FOR EACH ROW EXECUTE FUNCTION parted_trigfunc2()" +== 606 +-- truncate_limit: 100 +truncate table parted +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE parted" +== 607 +-- truncate_limit: 100 +insert into parted values (1, 1, 'uno uno v6') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (1, 1, 'uno uno v6')" +== 608 +-- truncate_limit: 100 +create table parted_3 partition of parted for values in (3) +-- +TABLE: name="parted_3" schema="" table="parted_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_3 PARTITION OF parted FOR VALUES IN (3)" +== 609 +-- truncate_limit: 100 +update parted set a = a + 1 +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted SET a = a + 1" +== 610 +-- truncate_limit: 100 +select tableoid::regclass, * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM parted" +== 611 +-- truncate_limit: 100 +-- there's no partition for a=0, but this update works anyway because +-- the trigger causes the tuple to be routed to another partition +update parted set a = 0 +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted SET a = 0" +== 612 +-- truncate_limit: 100 +select tableoid::regclass, * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM parted" +== 613 +-- truncate_limit: 100 +drop table parted +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted" +== 614 +-- truncate_limit: 100 +create table parted (a int, b int, c text) partition by list ((a + b)) +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted (a int, b int, c text) PARTITION BY LIST ((a + b))" +== 615 +-- truncate_limit: 100 +create or replace function parted_trigfunc() returns trigger language plpgsql as $$ +begin + new.a = new.a + new.b; + return new; +end; +$$ +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION parted_trigfunc() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\n new.a..." +== 616 +-- truncate_limit: 100 +create table parted_1 partition of parted for values in (1, 2) +-- +TABLE: name="parted_1" schema="" table="parted_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_1 PARTITION OF parted FOR VALUES IN (1, 2)" +== 617 +-- truncate_limit: 100 +create table parted_2 partition of parted for values in (3, 4) +-- +TABLE: name="parted_2" schema="" table="parted_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_2 PARTITION OF parted FOR VALUES IN (3, 4)" +== 618 +-- truncate_limit: 100 +create trigger t before insert or update on parted + for each row execute function parted_trigfunc() +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER t BEFORE INSERT OR UPDATE ON parted FOR EACH ROW EXECUTE FUNCTION parted_trigfunc()" +== 619 +-- truncate_limit: 100 +insert into parted values (0, 1, 'zero win') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (0, 1, 'zero win')" +== 620 +-- truncate_limit: 100 +insert into parted values (1, 1, 'one fail') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (1, 1, 'one fail')" +== 621 +-- truncate_limit: 100 +insert into parted values (1, 2, 'two fail') +-- +TABLE: name="parted" schema="" table="parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted VALUES (1, 2, 'two fail')" +== 622 +-- truncate_limit: 100 +select * from parted +-- +TABLE: name="parted" schema="" table="parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parted" +== 623 +-- truncate_limit: 100 +drop table parted +-- +TABLE: name="parted" schema="" table="parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted" +== 624 +-- truncate_limit: 100 +drop function parted_trigfunc() +-- +FUNCTION: name="parted_trigfunc" function="parted_trigfunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION parted_trigfunc()" +== 625 +-- truncate_limit: 100 +|-- +-- Constraint triggers and partitioned tables +create table parted_constr_ancestor (a int, b text) + partition by range (b) +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_constr_ancestor (a int, b text) PARTITION BY RANGE (b)" +== 626 +-- truncate_limit: 100 +create table parted_constr (a int, b text) + partition by range (b) +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_constr (a int, b text) PARTITION BY RANGE (b)" +== 627 +-- truncate_limit: 100 +alter table parted_constr_ancestor attach partition parted_constr + for values from ('aaaa') to ('zzzz') +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_constr_ancestor ATTACH PARTITION parted_constr FOR VALUES FROM ('aaaa') TO ('z..." +== 628 +-- truncate_limit: 100 +create table parted1_constr (a int, b text) +-- +TABLE: name="parted1_constr" schema="" table="parted1_constr" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted1_constr (a int, b text)" +== 629 +-- truncate_limit: 100 +alter table parted_constr attach partition parted1_constr + for values from ('aaaa') to ('bbbb') +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_constr ATTACH PARTITION parted1_constr FOR VALUES FROM ('aaaa') TO ('bbbb')" +== 630 +-- truncate_limit: 100 +create constraint trigger parted_trig after insert on parted_constr_ancestor + deferrable + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE CONSTRAINT TRIGGER parted_trig AFTER INSERT ON parted_constr_ancestor DEFERRABLE FOR EACH ..." +== 631 +-- truncate_limit: 100 +create constraint trigger parted_trig_two after insert on parted_constr + deferrable initially deferred + for each row when (bark(new.b) AND new.a % 2 = 1) + execute procedure trigger_notice_ab() +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE CONSTRAINT TRIGGER parted_trig_two AFTER INSERT ON parted_constr DEFERRABLE INITIALLY DEFE..." +== 632 +-- truncate_limit: 100 +-- The immediate constraint is fired immediately; the WHEN clause of the +-- deferred constraint is also called immediately. The deferred constraint +-- is fired at commit time. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 633 +-- truncate_limit: 100 +insert into parted_constr values (1, 'aardvark') +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_constr VALUES (1, 'aardvark')" +== 634 +-- truncate_limit: 100 +insert into parted1_constr values (2, 'aardwolf') +-- +TABLE: name="parted1_constr" schema="" table="parted1_constr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted1_constr VALUES (2, 'aardwolf')" +== 635 +-- truncate_limit: 100 +insert into parted_constr_ancestor values (3, 'aasvogel') +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_constr_ancestor VALUES (3, 'aasvogel')" +== 636 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 637 +-- truncate_limit: 100 +-- The WHEN clause is immediate, and both constraint triggers are fired at +-- commit time. +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 638 +-- truncate_limit: 100 +set constraints parted_trig deferred +-- +STMT: ConstraintsSetStmt +TRUNCATED: "SET CONSTRAINTS parted_trig DEFERRED" +== 639 +-- truncate_limit: 100 +insert into parted_constr values (1, 'aardvark') +-- +TABLE: name="parted_constr" schema="" table="parted_constr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_constr VALUES (1, 'aardvark')" +== 640 +-- truncate_limit: 100 +insert into parted1_constr values (2, 'aardwolf'), (3, 'aasvogel') +-- +TABLE: name="parted1_constr" schema="" table="parted1_constr" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted1_constr VALUES (2, 'aardwolf'), (3, 'aasvogel')" +== 641 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 642 +-- truncate_limit: 100 +drop table parted_constr_ancestor +-- +TABLE: name="parted_constr_ancestor" schema="" table="parted_constr_ancestor" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_constr_ancestor" +== 643 +-- truncate_limit: 100 +drop function bark(text) +-- +FUNCTION: name="bark" function="bark" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION bark(text)" +== 644 +-- truncate_limit: 100 +-- Test that the WHEN clause is set properly to partitions +create table parted_trigger (a int, b text) partition by range (a) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger (a int, b text) PARTITION BY RANGE (a)" +== 645 +-- truncate_limit: 100 +create table parted_trigger_1 partition of parted_trigger for values from (0) to (1000) +-- +TABLE: name="parted_trigger_1" schema="" table="parted_trigger_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_1 PARTITION OF parted_trigger FOR VALUES FROM (0) TO (1000)" +== 646 +-- truncate_limit: 100 +create table parted_trigger_2 (drp int, a int, b text) +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_2 (drp int, a int, b text)" +== 647 +-- truncate_limit: 100 +alter table parted_trigger_2 drop column drp +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger_2 DROP drp" +== 648 +-- truncate_limit: 100 +alter table parted_trigger attach partition parted_trigger_2 for values from (1000) to (2000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger ATTACH PARTITION parted_trigger_2 FOR VALUES FROM (1000) TO (2000)" +== 649 +-- truncate_limit: 100 +create trigger parted_trigger after update on parted_trigger + for each row when (new.a % 2 = 1 and length(old.b) >= 2) execute procedure trigger_notice_ab() +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_trigger AFTER UPDATE ON parted_trigger FOR EACH ROW WHEN ((new.a % 2) = 1 A..." +== 650 +-- truncate_limit: 100 +create table parted_trigger_3 (b text, a int) partition by range (length(b)) +-- +TABLE: name="parted_trigger_3" schema="" table="parted_trigger_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3 (b text, a int) PARTITION BY RANGE ((length(b)))" +== 651 +-- truncate_limit: 100 +create table parted_trigger_3_1 partition of parted_trigger_3 for values from (1) to (3) +-- +TABLE: name="parted_trigger_3_1" schema="" table="parted_trigger_3_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3_1 PARTITION OF parted_trigger_3 FOR VALUES FROM (1) TO (3)" +== 652 +-- truncate_limit: 100 +create table parted_trigger_3_2 partition of parted_trigger_3 for values from (3) to (5) +-- +TABLE: name="parted_trigger_3_2" schema="" table="parted_trigger_3_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3_2 PARTITION OF parted_trigger_3 FOR VALUES FROM (3) TO (5)" +== 653 +-- truncate_limit: 100 +alter table parted_trigger attach partition parted_trigger_3 for values from (2000) to (3000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger ATTACH PARTITION parted_trigger_3 FOR VALUES FROM (2000) TO (3000)" +== 654 +-- truncate_limit: 100 +insert into parted_trigger values + (0, 'a'), (1, 'bbb'), (2, 'bcd'), (3, 'c'), + (1000, 'c'), (1001, 'ddd'), (1002, 'efg'), (1003, 'f'), + (2000, 'e'), (2001, 'fff'), (2002, 'ghi'), (2003, 'h') +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trigger VALUES (...)" +== 655 +-- truncate_limit: 100 +update parted_trigger set a = a + 2 +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted_trigger SET a = a + 2" +== 656 +-- truncate_limit: 100 +-- notice for odd 'a' values, long 'b' values +drop table parted_trigger +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_trigger" +== 657 +-- truncate_limit: 100 +-- try a constraint trigger, also +create table parted_referenced (a int) +-- +TABLE: name="parted_referenced" schema="" table="parted_referenced" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_referenced (a int)" +== 658 +-- truncate_limit: 100 +create table unparted_trigger (a int, b text) +-- +TABLE: name="unparted_trigger" schema="" table="unparted_trigger" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE unparted_trigger (a int, b text)" +== 659 +-- truncate_limit: 100 +-- for comparison purposes +create table parted_trigger (a int, b text) partition by range (a) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger (a int, b text) PARTITION BY RANGE (a)" +== 660 +-- truncate_limit: 100 +create table parted_trigger_1 partition of parted_trigger for values from (0) to (1000) +-- +TABLE: name="parted_trigger_1" schema="" table="parted_trigger_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_1 PARTITION OF parted_trigger FOR VALUES FROM (0) TO (1000)" +== 661 +-- truncate_limit: 100 +create table parted_trigger_2 (drp int, a int, b text) +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_2 (drp int, a int, b text)" +== 662 +-- truncate_limit: 100 +alter table parted_trigger_2 drop column drp +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger_2 DROP drp" +== 663 +-- truncate_limit: 100 +alter table parted_trigger attach partition parted_trigger_2 for values from (1000) to (2000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger ATTACH PARTITION parted_trigger_2 FOR VALUES FROM (1000) TO (2000)" +== 664 +-- truncate_limit: 100 +create constraint trigger parted_trigger after update on parted_trigger + from parted_referenced + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE CONSTRAINT TRIGGER parted_trigger AFTER UPDATE ON parted_trigger FROM parted_referenced FO..." +== 665 +-- truncate_limit: 100 +create constraint trigger parted_trigger after update on unparted_trigger + from parted_referenced + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="unparted_trigger" schema="" table="unparted_trigger" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE CONSTRAINT TRIGGER parted_trigger AFTER UPDATE ON unparted_trigger FROM parted_referenced ..." +== 666 +-- truncate_limit: 100 +create table parted_trigger_3 (b text, a int) partition by range (length(b)) +-- +TABLE: name="parted_trigger_3" schema="" table="parted_trigger_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3 (b text, a int) PARTITION BY RANGE ((length(b)))" +== 667 +-- truncate_limit: 100 +create table parted_trigger_3_1 partition of parted_trigger_3 for values from (1) to (3) +-- +TABLE: name="parted_trigger_3_1" schema="" table="parted_trigger_3_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3_1 PARTITION OF parted_trigger_3 FOR VALUES FROM (1) TO (3)" +== 668 +-- truncate_limit: 100 +create table parted_trigger_3_2 partition of parted_trigger_3 for values from (3) to (5) +-- +TABLE: name="parted_trigger_3_2" schema="" table="parted_trigger_3_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3_2 PARTITION OF parted_trigger_3 FOR VALUES FROM (3) TO (5)" +== 669 +-- truncate_limit: 100 +alter table parted_trigger attach partition parted_trigger_3 for values from (2000) to (3000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger ATTACH PARTITION parted_trigger_3 FOR VALUES FROM (2000) TO (3000)" +== 670 +-- truncate_limit: 100 +select tgname, conname, t.tgrelid::regclass, t.tgconstrrelid::regclass, + c.conrelid::regclass, c.confrelid::regclass + from pg_trigger t join pg_constraint c on (t.tgconstraint = c.oid) + where tgname = 'parted_trigger' + order by t.tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_constraint" schema="" table="pg_constraint" ctx=Select +ALIAS: "c"="pg_constraint" +ALIAS: "t"="pg_trigger" +FILTER: schema="" table="" column="tgname" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger t JOIN pg_constraint c ON t.tgconstraint = c.oid WHERE ... ORDER BY t...." +== 671 +-- truncate_limit: 100 +drop table parted_referenced, parted_trigger, unparted_trigger +-- +TABLE: name="parted_referenced" schema="" table="parted_referenced" ctx=DDL +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +TABLE: name="unparted_trigger" schema="" table="unparted_trigger" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_referenced, parted_trigger, unparted_trigger" +== 672 +-- truncate_limit: 100 +-- verify that the "AFTER UPDATE OF columns" event is propagated correctly +create table parted_trigger (a int, b text) partition by range (a) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger (a int, b text) PARTITION BY RANGE (a)" +== 673 +-- truncate_limit: 100 +create table parted_trigger_1 partition of parted_trigger for values from (0) to (1000) +-- +TABLE: name="parted_trigger_1" schema="" table="parted_trigger_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_1 PARTITION OF parted_trigger FOR VALUES FROM (0) TO (1000)" +== 674 +-- truncate_limit: 100 +create table parted_trigger_2 (drp int, a int, b text) +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_2 (drp int, a int, b text)" +== 675 +-- truncate_limit: 100 +alter table parted_trigger_2 drop column drp +-- +TABLE: name="parted_trigger_2" schema="" table="parted_trigger_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger_2 DROP drp" +== 676 +-- truncate_limit: 100 +alter table parted_trigger attach partition parted_trigger_2 for values from (1000) to (2000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger ATTACH PARTITION parted_trigger_2 FOR VALUES FROM (1000) TO (2000)" +== 677 +-- truncate_limit: 100 +create trigger parted_trigger after update of b on parted_trigger + for each row execute procedure trigger_notice_ab() +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_trigger AFTER UPDATE OF b ON parted_trigger FOR EACH ROW EXECUTE FUNCTION t..." +== 678 +-- truncate_limit: 100 +create table parted_trigger_3 (b text, a int) partition by range (length(b)) +-- +TABLE: name="parted_trigger_3" schema="" table="parted_trigger_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3 (b text, a int) PARTITION BY RANGE ((length(b)))" +== 679 +-- truncate_limit: 100 +create table parted_trigger_3_1 partition of parted_trigger_3 for values from (1) to (4) +-- +TABLE: name="parted_trigger_3_1" schema="" table="parted_trigger_3_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3_1 PARTITION OF parted_trigger_3 FOR VALUES FROM (1) TO (4)" +== 680 +-- truncate_limit: 100 +create table parted_trigger_3_2 partition of parted_trigger_3 for values from (4) to (8) +-- +TABLE: name="parted_trigger_3_2" schema="" table="parted_trigger_3_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trigger_3_2 PARTITION OF parted_trigger_3 FOR VALUES FROM (4) TO (8)" +== 681 +-- truncate_limit: 100 +alter table parted_trigger attach partition parted_trigger_3 for values from (2000) to (3000) +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parted_trigger ATTACH PARTITION parted_trigger_3 FOR VALUES FROM (2000) TO (3000)" +== 682 +-- truncate_limit: 100 +insert into parted_trigger values (0, 'a'), (1000, 'c'), (2000, 'e'), (2001, 'eeee') +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trigger VALUES (0, 'a'), (1000, 'c'), (2000, 'e'), (2001, 'eeee')" +== 683 +-- truncate_limit: 100 +update parted_trigger set a = a + 2 +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted_trigger SET a = a + 2" +== 684 +-- truncate_limit: 100 +-- no notices here +update parted_trigger set b = b || 'b' +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parted_trigger SET b = b || 'b'" +== 685 +-- truncate_limit: 100 +-- all triggers should fire +drop table parted_trigger +-- +TABLE: name="parted_trigger" schema="" table="parted_trigger" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_trigger" +== 686 +-- truncate_limit: 100 +drop function trigger_notice_ab() +-- +FUNCTION: name="trigger_notice_ab" function="trigger_notice_ab" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION trigger_notice_ab()" +== 687 +-- truncate_limit: 100 +-- Make sure we don't end up with unnecessary copies of triggers, when +-- cloning them. +create table trg_clone (a int) partition by range (a) +-- +TABLE: name="trg_clone" schema="" table="trg_clone" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trg_clone (a int) PARTITION BY RANGE (a)" +== 688 +-- truncate_limit: 100 +create table trg_clone1 partition of trg_clone for values from (0) to (1000) +-- +TABLE: name="trg_clone1" schema="" table="trg_clone1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trg_clone1 PARTITION OF trg_clone FOR VALUES FROM (0) TO (1000)" +== 689 +-- truncate_limit: 100 +alter table trg_clone add constraint uniq unique (a) deferrable +-- +TABLE: name="trg_clone" schema="" table="trg_clone" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trg_clone ADD CONSTRAINT uniq UNIQUE (a) DEFERRABLE" +== 690 +-- truncate_limit: 100 +create table trg_clone2 partition of trg_clone for values from (1000) to (2000) +-- +TABLE: name="trg_clone2" schema="" table="trg_clone2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trg_clone2 PARTITION OF trg_clone FOR VALUES FROM (1000) TO (2000)" +== 691 +-- truncate_limit: 100 +create table trg_clone3 partition of trg_clone for values from (2000) to (3000) + partition by range (a) +-- +TABLE: name="trg_clone3" schema="" table="trg_clone3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trg_clone3 PARTITION OF trg_clone FOR VALUES FROM (2000) TO (3000) PARTITION BY RANG..." +== 692 +-- truncate_limit: 100 +create table trg_clone_3_3 partition of trg_clone3 for values from (2000) to (2100) +-- +TABLE: name="trg_clone_3_3" schema="" table="trg_clone_3_3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trg_clone_3_3 PARTITION OF trg_clone3 FOR VALUES FROM (2000) TO (2100)" +== 693 +-- truncate_limit: 100 +select tgrelid::regclass, count(*) from pg_trigger + where tgrelid::regclass in ('trg_clone', 'trg_clone1', 'trg_clone2', + 'trg_clone3', 'trg_clone_3_3') + group by tgrelid::regclass order by tgrelid::regclass +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... GROUP BY tgrelid::regclass ORDER BY tgrelid::regclass" +== 694 +-- truncate_limit: 100 +drop table trg_clone +-- +TABLE: name="trg_clone" schema="" table="trg_clone" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trg_clone" +== 695 +-- truncate_limit: 100 +-- Test the interaction between ALTER TABLE .. DISABLE TRIGGER and +-- both kinds of inheritance. Historically, legacy inheritance has +-- not recursed to children, so that behavior is preserved. +create table parent (a int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a int)" +== 696 +-- truncate_limit: 100 +create table child1 () inherits (parent) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child1 () INHERITS (parent)" +== 697 +-- truncate_limit: 100 +create function trig_nothing() returns trigger language plpgsql + as $$ begin return null; end $$ +-- +FUNCTION: name="trig_nothing" function="trig_nothing" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trig_nothing() RETURNS trigger LANGUAGE plpgsql AS $$ begin return null; end $$" +== 698 +-- truncate_limit: 100 +create trigger tg after insert on parent + for each row execute function trig_nothing() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg AFTER INSERT ON parent FOR EACH ROW EXECUTE FUNCTION trig_nothing()" +== 699 +-- truncate_limit: 100 +create trigger tg after insert on child1 + for each row execute function trig_nothing() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg AFTER INSERT ON child1 FOR EACH ROW EXECUTE FUNCTION trig_nothing()" +== 700 +-- truncate_limit: 100 +alter table parent disable trigger tg +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent DISABLE TRIGGER tg" +== 701 +-- truncate_limit: 100 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text" +== 702 +-- truncate_limit: 100 +alter table only parent enable always trigger tg +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parent ENABLE ALWAYS TRIGGER tg" +== 703 +-- truncate_limit: 100 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text" +== 704 +-- truncate_limit: 100 +drop table parent, child1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent, child1" +== 705 +-- truncate_limit: 100 +create table parent (a int) partition by list (a) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a int) PARTITION BY LIST (a)" +== 706 +-- truncate_limit: 100 +create table child1 partition of parent for values in (1) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child1 PARTITION OF parent FOR VALUES IN (1)" +== 707 +-- truncate_limit: 100 +create trigger tg after insert on parent + for each row execute procedure trig_nothing() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg AFTER INSERT ON parent FOR EACH ROW EXECUTE FUNCTION trig_nothing()" +== 708 +-- truncate_limit: 100 +create trigger tg_stmt after insert on parent + for statement execute procedure trig_nothing() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg_stmt AFTER INSERT ON parent EXECUTE FUNCTION trig_nothing()" +== 709 +-- truncate_limit: 100 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgname +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text, tgname" +== 710 +-- truncate_limit: 100 +alter table only parent enable always trigger tg +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY parent ENABLE ALWAYS TRIGGER tg" +== 711 +-- truncate_limit: 100 +-- no recursion because ONLY +alter table parent enable always trigger tg_stmt +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ENABLE ALWAYS TRIGGER tg_stmt" +== 712 +-- truncate_limit: 100 +-- no recursion because statement trigger +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgname +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text, tgname" +== 713 +-- truncate_limit: 100 +-- The following is a no-op for the parent trigger but not so +-- for the child trigger, so recursion should be applied. +alter table parent enable always trigger tg +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ENABLE ALWAYS TRIGGER tg" +== 714 +-- truncate_limit: 100 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgname +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text, tgname" +== 715 +-- truncate_limit: 100 +-- This variant malfunctioned in some releases. +alter table parent disable trigger user +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent DISABLE TRIGGER USER" +== 716 +-- truncate_limit: 100 +select tgrelid::regclass, tgname, tgenabled from pg_trigger + where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgname +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text, tgname" +== 717 +-- truncate_limit: 100 +drop table parent, child1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent, child1" +== 718 +-- truncate_limit: 100 +-- Check processing of foreign key triggers +create table parent (a int primary key, f int references parent) + partition by list (a) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a int PRIMARY KEY, f int REFERENCES parent) PARTITION BY LIST (a)" +== 719 +-- truncate_limit: 100 +create table child1 partition of parent for values in (1) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child1 PARTITION OF parent FOR VALUES IN (1)" +== 720 +-- truncate_limit: 100 +select tgrelid::regclass, rtrim(tgname, '0123456789') as tgname, + tgfoid::regproc, tgenabled + from pg_trigger where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgfoid +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="rtrim" function="rtrim" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text, tgfoid" +== 721 +-- truncate_limit: 100 +alter table parent disable trigger all +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent DISABLE TRIGGER ALL" +== 722 +-- truncate_limit: 100 +select tgrelid::regclass, rtrim(tgname, '0123456789') as tgname, + tgfoid::regproc, tgenabled + from pg_trigger where tgrelid in ('parent'::regclass, 'child1'::regclass) + order by tgrelid::regclass::text, tgfoid +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +FUNCTION: name="rtrim" function="rtrim" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text, tgfoid" +== 723 +-- truncate_limit: 100 +drop table parent, child1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent, child1" +== 724 +-- truncate_limit: 100 +-- Verify that firing state propagates correctly on creation, too +CREATE TABLE trgfire (i int) PARTITION BY RANGE (i) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trgfire (i int) PARTITION BY RANGE (i)" +== 725 +-- truncate_limit: 100 +CREATE TABLE trgfire1 PARTITION OF trgfire FOR VALUES FROM (1) TO (10) +-- +TABLE: name="trgfire1" schema="" table="trgfire1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trgfire1 PARTITION OF trgfire FOR VALUES FROM (1) TO (10)" +== 726 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION tgf() RETURNS trigger LANGUAGE plpgsql + AS $$ begin raise exception 'except'; end $$ +-- +FUNCTION: name="tgf" function="tgf" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION tgf() RETURNS trigger LANGUAGE plpgsql AS $$ begin raise exception 'ex..." +== 727 +-- truncate_limit: 100 +CREATE TRIGGER tg AFTER INSERT ON trgfire FOR EACH ROW EXECUTE FUNCTION tgf() +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tg AFTER INSERT ON trgfire FOR EACH ROW EXECUTE FUNCTION tgf()" +== 728 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (1) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (1)" +== 729 +-- truncate_limit: 100 +ALTER TABLE trgfire DISABLE TRIGGER tg +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trgfire DISABLE TRIGGER tg" +== 730 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (1) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (1)" +== 731 +-- truncate_limit: 100 +CREATE TABLE trgfire2 PARTITION OF trgfire FOR VALUES FROM (10) TO (20) +-- +TABLE: name="trgfire2" schema="" table="trgfire2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trgfire2 PARTITION OF trgfire FOR VALUES FROM (10) TO (20)" +== 732 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (11) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (11)" +== 733 +-- truncate_limit: 100 +CREATE TABLE trgfire3 (LIKE trgfire) +-- +TABLE: name="trgfire3" schema="" table="trgfire3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trgfire3 (LIKE trgfire)" +== 734 +-- truncate_limit: 100 +ALTER TABLE trgfire ATTACH PARTITION trgfire3 FOR VALUES FROM (20) TO (30) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trgfire ATTACH PARTITION trgfire3 FOR VALUES FROM (20) TO (30)" +== 735 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (21) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (21)" +== 736 +-- truncate_limit: 100 +CREATE TABLE trgfire4 PARTITION OF trgfire FOR VALUES FROM (30) TO (40) PARTITION BY LIST (i) +-- +TABLE: name="trgfire4" schema="" table="trgfire4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trgfire4 PARTITION OF trgfire FOR VALUES FROM (30) TO (40) PARTITION BY LIST (i)" +== 737 +-- truncate_limit: 100 +CREATE TABLE trgfire4_30 PARTITION OF trgfire4 FOR VALUES IN (30) +-- +TABLE: name="trgfire4_30" schema="" table="trgfire4_30" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trgfire4_30 PARTITION OF trgfire4 FOR VALUES IN (30)" +== 738 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (30) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (30)" +== 739 +-- truncate_limit: 100 +CREATE TABLE trgfire5 (LIKE trgfire) PARTITION BY LIST (i) +-- +TABLE: name="trgfire5" schema="" table="trgfire5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trgfire5 (LIKE trgfire) PARTITION BY LIST (i)" +== 740 +-- truncate_limit: 100 +CREATE TABLE trgfire5_40 PARTITION OF trgfire5 FOR VALUES IN (40) +-- +TABLE: name="trgfire5_40" schema="" table="trgfire5_40" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trgfire5_40 PARTITION OF trgfire5 FOR VALUES IN (40)" +== 741 +-- truncate_limit: 100 +ALTER TABLE trgfire ATTACH PARTITION trgfire5 FOR VALUES FROM (40) TO (50) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trgfire ATTACH PARTITION trgfire5 FOR VALUES FROM (40) TO (50)" +== 742 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (40) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (40)" +== 743 +-- truncate_limit: 100 +SELECT tgrelid::regclass, tgenabled FROM pg_trigger + WHERE tgrelid::regclass IN (SELECT oid from pg_class where relname LIKE 'trgfire%') + ORDER BY tgrelid::regclass::text +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT tgrelid::regclass, tgenabled FROM pg_trigger WHERE ... ORDER BY tgrelid::regclass::text" +== 744 +-- truncate_limit: 100 +ALTER TABLE trgfire ENABLE TRIGGER tg +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trgfire ENABLE TRIGGER tg" +== 745 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (1) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (1)" +== 746 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (11) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (11)" +== 747 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (21) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (21)" +== 748 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (30) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (30)" +== 749 +-- truncate_limit: 100 +INSERT INTO trgfire VALUES (40) +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trgfire VALUES (40)" +== 750 +-- truncate_limit: 100 +DROP TABLE trgfire +-- +TABLE: name="trgfire" schema="" table="trgfire" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trgfire" +== 751 +-- truncate_limit: 100 +DROP FUNCTION tgf() +-- +FUNCTION: name="tgf" function="tgf" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION tgf()" +== 752 +-- truncate_limit: 100 +|-- +-- Test the interaction between transition tables and both kinds of +-- inheritance. We'll dump the contents of the transition tables in a +-- format that shows the attribute order, so that we can distinguish +-- tuple formats (though not dropped attributes). +|-- + +create or replace function dump_insert() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, new table = %', + TG_NAME, + (select string_agg(new_table::text, ', ' order by a) from new_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_insert" function="dump_insert" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dump_insert() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n raise..." +== 753 +-- truncate_limit: 100 +create or replace function dump_update() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, old table = %, new table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' order by a) from old_table), + (select string_agg(new_table::text, ', ' order by a) from new_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_update" function="dump_update" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dump_update() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n raise..." +== 754 +-- truncate_limit: 100 +create or replace function dump_delete() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, old table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' order by a) from old_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_delete" function="dump_delete" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dump_delete() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n raise..." +== 755 +-- truncate_limit: 100 +|-- +-- Verify behavior of statement triggers on partition hierarchy with +-- transition tables. Tuples should appear to each trigger in the +-- format of the relation the trigger is attached to. +|-- + +-- set up a partition hierarchy with some different TupleDescriptors +create table parent (a text, b int) partition by list (a) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a text, b int) PARTITION BY LIST (a)" +== 756 +-- truncate_limit: 100 +-- a child matching parent +create table child1 partition of parent for values in ('AAA') +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child1 PARTITION OF parent FOR VALUES IN ('AAA')" +== 757 +-- truncate_limit: 100 +-- a child with a dropped column +create table child2 (x int, a text, b int) +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child2 (x int, a text, b int)" +== 758 +-- truncate_limit: 100 +alter table child2 drop column x +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child2 DROP x" +== 759 +-- truncate_limit: 100 +alter table parent attach partition child2 for values in ('BBB') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ATTACH PARTITION child2 FOR VALUES IN ('BBB')" +== 760 +-- truncate_limit: 100 +-- a child with a different column order +create table child3 (b int, a text) +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child3 (b int, a text)" +== 761 +-- truncate_limit: 100 +alter table parent attach partition child3 for values in ('CCC') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ATTACH PARTITION child3 FOR VALUES IN ('CCC')" +== 762 +-- truncate_limit: 100 +create trigger parent_insert_trig + after insert on parent referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_insert_trig AFTER INSERT ON parent REFERENCING NEW TABLE new_table EXECUTE ..." +== 763 +-- truncate_limit: 100 +create trigger parent_update_trig + after update on parent referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_update_trig AFTER UPDATE ON parent REFERENCING OLD TABLE old_table NEW TABL..." +== 764 +-- truncate_limit: 100 +create trigger parent_delete_trig + after delete on parent referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_delete_trig AFTER DELETE ON parent REFERENCING OLD TABLE old_table EXECUTE ..." +== 765 +-- truncate_limit: 100 +create trigger child1_insert_trig + after insert on child1 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child1_insert_trig AFTER INSERT ON child1 REFERENCING NEW TABLE new_table EXECUTE ..." +== 766 +-- truncate_limit: 100 +create trigger child1_update_trig + after update on child1 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child1_update_trig AFTER UPDATE ON child1 REFERENCING OLD TABLE old_table NEW TABL..." +== 767 +-- truncate_limit: 100 +create trigger child1_delete_trig + after delete on child1 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child1_delete_trig AFTER DELETE ON child1 REFERENCING OLD TABLE old_table EXECUTE ..." +== 768 +-- truncate_limit: 100 +create trigger child2_insert_trig + after insert on child2 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child2_insert_trig AFTER INSERT ON child2 REFERENCING NEW TABLE new_table EXECUTE ..." +== 769 +-- truncate_limit: 100 +create trigger child2_update_trig + after update on child2 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child2_update_trig AFTER UPDATE ON child2 REFERENCING OLD TABLE old_table NEW TABL..." +== 770 +-- truncate_limit: 100 +create trigger child2_delete_trig + after delete on child2 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child2_delete_trig AFTER DELETE ON child2 REFERENCING OLD TABLE old_table EXECUTE ..." +== 771 +-- truncate_limit: 100 +create trigger child3_insert_trig + after insert on child3 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child3_insert_trig AFTER INSERT ON child3 REFERENCING NEW TABLE new_table EXECUTE ..." +== 772 +-- truncate_limit: 100 +create trigger child3_update_trig + after update on child3 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child3_update_trig AFTER UPDATE ON child3 REFERENCING OLD TABLE old_table NEW TABL..." +== 773 +-- truncate_limit: 100 +create trigger child3_delete_trig + after delete on child3 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child3_delete_trig AFTER DELETE ON child3 REFERENCING OLD TABLE old_table EXECUTE ..." +== 774 +-- truncate_limit: 100 +SELECT trigger_name, event_manipulation, event_object_schema, event_object_table, + action_order, action_condition, action_orientation, action_timing, + action_reference_old_table, action_reference_new_table + FROM information_schema.triggers + WHERE event_object_table IN ('parent', 'child1', 'child2', 'child3') + ORDER BY trigger_name COLLATE "C", 2 +-- +TABLE: name="information_schema.triggers" schema="information_schema" table="triggers" ctx=Select +FILTER: schema="" table="" column="event_object_table" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.triggers WHERE ... ORDER BY trigger_name COLLATE \"C\", 2" +== 775 +-- truncate_limit: 100 +-- insert directly into children sees respective child-format tuples +insert into child1 values ('AAA', 42) +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child1 VALUES ('AAA', 42)" +== 776 +-- truncate_limit: 100 +insert into child2 values ('BBB', 42) +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child2 VALUES ('BBB', 42)" +== 777 +-- truncate_limit: 100 +insert into child3 values (42, 'CCC') +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child3 VALUES (42, 'CCC')" +== 778 +-- truncate_limit: 100 +-- update via parent sees parent-format tuples +update parent set b = b + 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parent SET b = b + 1" +== 779 +-- truncate_limit: 100 +-- delete via parent sees parent-format tuples +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parent" +== 780 +-- truncate_limit: 100 +-- insert into parent sees parent-format tuples +insert into parent values ('AAA', 42) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES ('AAA', 42)" +== 781 +-- truncate_limit: 100 +insert into parent values ('BBB', 42) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES ('BBB', 42)" +== 782 +-- truncate_limit: 100 +insert into parent values ('CCC', 42) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES ('CCC', 42)" +== 783 +-- truncate_limit: 100 +-- delete from children sees respective child-format tuples +delete from child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM child1" +== 784 +-- truncate_limit: 100 +delete from child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM child2" +== 785 +-- truncate_limit: 100 +delete from child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM child3" +== 786 +-- truncate_limit: 100 +-- copy into parent sees parent-format tuples +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY parent(a, b) FROM STDIN" +== 787 +-- truncate_limit: 100 +-- check detach/reattach behavior; statement triggers with transition tables +-- should not prevent a table from becoming a partition again +alter table parent detach partition child1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent DETACH PARTITION child1" +== 788 +-- truncate_limit: 100 +alter table parent attach partition child1 for values in ('AAA') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ATTACH PARTITION child1 FOR VALUES IN ('AAA')" +== 789 +-- truncate_limit: 100 +-- DML affecting parent sees tuples collected from children even if +-- there is no transition table trigger on the children +drop trigger child1_insert_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child1_insert_trig ON child1" +== 790 +-- truncate_limit: 100 +drop trigger child1_update_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child1_update_trig ON child1" +== 791 +-- truncate_limit: 100 +drop trigger child1_delete_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child1_delete_trig ON child1" +== 792 +-- truncate_limit: 100 +drop trigger child2_insert_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child2_insert_trig ON child2" +== 793 +-- truncate_limit: 100 +drop trigger child2_update_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child2_update_trig ON child2" +== 794 +-- truncate_limit: 100 +drop trigger child2_delete_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child2_delete_trig ON child2" +== 795 +-- truncate_limit: 100 +drop trigger child3_insert_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child3_insert_trig ON child3" +== 796 +-- truncate_limit: 100 +drop trigger child3_update_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child3_update_trig ON child3" +== 797 +-- truncate_limit: 100 +drop trigger child3_delete_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child3_delete_trig ON child3" +== 798 +-- truncate_limit: 100 +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parent" +== 799 +-- truncate_limit: 100 +-- copy into parent sees tuples collected from children even if there +-- is no transition-table trigger on the children +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY parent(a, b) FROM STDIN" +== 800 +-- truncate_limit: 100 +-- insert into parent with a before trigger on a child tuple before +-- insertion, and we capture the newly modified row in parent format +create or replace function intercept_insert() returns trigger language plpgsql as +$$ + begin + new.b = new.b + 1000; + return new; + end; +$$ +-- +FUNCTION: name="intercept_insert" function="intercept_insert" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION intercept_insert() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n ..." +== 801 +-- truncate_limit: 100 +create trigger intercept_insert_child3 + before insert on child3 + for each row execute procedure intercept_insert() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER intercept_insert_child3 BEFORE INSERT ON child3 FOR EACH ROW EXECUTE FUNCTION inte..." +== 802 +-- truncate_limit: 100 +-- insert, parent trigger sees post-modification parent-format tuple +insert into parent values ('AAA', 42), ('BBB', 42), ('CCC', 66) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES ('AAA', 42), ('BBB', 42), ('CCC', 66)" +== 803 +-- truncate_limit: 100 +-- copy, parent trigger sees post-modification parent-format tuple +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY parent(a, b) FROM STDIN" +== 804 +-- truncate_limit: 100 +drop table child1, child2, child3, parent +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +TABLE: name="child2" schema="" table="child2" ctx=DDL +TABLE: name="child3" schema="" table="child3" ctx=DDL +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE child1, child2, child3, parent" +== 805 +-- truncate_limit: 100 +drop function intercept_insert() +-- +FUNCTION: name="intercept_insert" function="intercept_insert" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION intercept_insert()" +== 806 +-- truncate_limit: 100 +|-- +-- Verify prohibition of row triggers with transition triggers on +-- partitions +|-- +create table parent (a text, b int) partition by list (a) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a text, b int) PARTITION BY LIST (a)" +== 807 +-- truncate_limit: 100 +create table child partition of parent for values in ('AAA') +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child PARTITION OF parent FOR VALUES IN ('AAA')" +== 808 +-- truncate_limit: 100 +-- adding row trigger with transition table fails +create trigger child_row_trig + after insert on child referencing new table as new_table + for each row execute procedure dump_insert() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child_row_trig AFTER INSERT ON child REFERENCING NEW TABLE new_table FOR EACH ROW ..." +== 809 +-- truncate_limit: 100 +-- detaching it first works +alter table parent detach partition child +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent DETACH PARTITION child" +== 810 +-- truncate_limit: 100 +create trigger child_row_trig + after insert on child referencing new table as new_table + for each row execute procedure dump_insert() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child_row_trig AFTER INSERT ON child REFERENCING NEW TABLE new_table FOR EACH ROW ..." +== 811 +-- truncate_limit: 100 +-- but now we're not allowed to reattach it +alter table parent attach partition child for values in ('AAA') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ATTACH PARTITION child FOR VALUES IN ('AAA')" +== 812 +-- truncate_limit: 100 +-- drop the trigger, and now we're allowed to attach it again +drop trigger child_row_trig on child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child_row_trig ON child" +== 813 +-- truncate_limit: 100 +alter table parent attach partition child for values in ('AAA') +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE parent ATTACH PARTITION child FOR VALUES IN ('AAA')" +== 814 +-- truncate_limit: 100 +drop table child, parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE child, parent" +== 815 +-- truncate_limit: 100 +|-- +-- Verify access of transition tables with UPDATE triggers and tuples +-- moved across partitions. +|-- +create or replace function dump_update_new() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, new table = %', TG_NAME, + (select string_agg(new_table::text, ', ' order by a) from new_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_update_new" function="dump_update_new" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dump_update_new() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n r..." +== 816 +-- truncate_limit: 100 +create or replace function dump_update_old() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = %, old table = %', TG_NAME, + (select string_agg(old_table::text, ', ' order by a) from old_table); + return null; + end; +$$ +-- +FUNCTION: name="dump_update_old" function="dump_update_old" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dump_update_old() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n r..." +== 817 +-- truncate_limit: 100 +create table trans_tab_parent (a text) partition by list (a) +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_tab_parent (a text) PARTITION BY LIST (a)" +== 818 +-- truncate_limit: 100 +create table trans_tab_child1 partition of trans_tab_parent for values in ('AAA1', 'AAA2') +-- +TABLE: name="trans_tab_child1" schema="" table="trans_tab_child1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_tab_child1 PARTITION OF trans_tab_parent FOR VALUES IN ('AAA1', 'AAA2')" +== 819 +-- truncate_limit: 100 +create table trans_tab_child2 partition of trans_tab_parent for values in ('BBB1', 'BBB2') +-- +TABLE: name="trans_tab_child2" schema="" table="trans_tab_child2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trans_tab_child2 PARTITION OF trans_tab_parent FOR VALUES IN ('BBB1', 'BBB2')" +== 820 +-- truncate_limit: 100 +create trigger trans_tab_parent_update_trig + after update on trans_tab_parent referencing old table as old_table + for each statement execute procedure dump_update_old() +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trans_tab_parent_update_trig AFTER UPDATE ON trans_tab_parent REFERENCING OLD TABL..." +== 821 +-- truncate_limit: 100 +create trigger trans_tab_parent_insert_trig + after insert on trans_tab_parent referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trans_tab_parent_insert_trig AFTER INSERT ON trans_tab_parent REFERENCING NEW TABL..." +== 822 +-- truncate_limit: 100 +create trigger trans_tab_parent_delete_trig + after delete on trans_tab_parent referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trans_tab_parent_delete_trig AFTER DELETE ON trans_tab_parent REFERENCING OLD TABL..." +== 823 +-- truncate_limit: 100 +insert into trans_tab_parent values ('AAA1'), ('BBB1') +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trans_tab_parent VALUES ('AAA1'), ('BBB1')" +== 824 +-- truncate_limit: 100 +-- should not trigger access to new table when moving across partitions. +update trans_tab_parent set a = 'BBB2' where a = 'AAA1' +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trans_tab_parent SET a = 'BBB2' WHERE a = 'AAA1'" +== 825 +-- truncate_limit: 100 +drop trigger trans_tab_parent_update_trig on trans_tab_parent +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trans_tab_parent_update_trig ON trans_tab_parent" +== 826 +-- truncate_limit: 100 +create trigger trans_tab_parent_update_trig + after update on trans_tab_parent referencing new table as new_table + for each statement execute procedure dump_update_new() +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trans_tab_parent_update_trig AFTER UPDATE ON trans_tab_parent REFERENCING NEW TABL..." +== 827 +-- truncate_limit: 100 +-- should not trigger access to old table when moving across partitions. +update trans_tab_parent set a = 'AAA2' where a = 'BBB1' +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE trans_tab_parent SET a = 'AAA2' WHERE a = 'BBB1'" +== 828 +-- truncate_limit: 100 +delete from trans_tab_parent +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM trans_tab_parent" +== 829 +-- truncate_limit: 100 +-- clean up +drop table trans_tab_parent, trans_tab_child1, trans_tab_child2 +-- +TABLE: name="trans_tab_parent" schema="" table="trans_tab_parent" ctx=DDL +TABLE: name="trans_tab_child1" schema="" table="trans_tab_child1" ctx=DDL +TABLE: name="trans_tab_child2" schema="" table="trans_tab_child2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trans_tab_parent, trans_tab_child1, trans_tab_child2" +== 830 +-- truncate_limit: 100 +drop function dump_update_new, dump_update_old +-- +FUNCTION: name="dump_update_new" function="dump_update_new" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dump_update_new, dump_update_old" +== 831 +-- truncate_limit: 100 +|-- +-- Verify behavior of statement triggers on (non-partition) +-- inheritance hierarchy with transition tables; similar to the +-- partition case, except there is no rerouting on insertion and child +-- tables can have extra columns +|-- + +-- set up inheritance hierarchy with different TupleDescriptors +create table parent (a text, b int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a text, b int)" +== 832 +-- truncate_limit: 100 +-- a child matching parent +create table child1 () inherits (parent) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child1 () INHERITS (parent)" +== 833 +-- truncate_limit: 100 +-- a child with a different column order +create table child2 (b int, a text) +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child2 (b int, a text)" +== 834 +-- truncate_limit: 100 +alter table child2 inherit parent +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child2 INHERIT parent" +== 835 +-- truncate_limit: 100 +-- a child with an extra column +create table child3 (c text) inherits (parent) +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child3 (c text) INHERITS (parent)" +== 836 +-- truncate_limit: 100 +create trigger parent_insert_trig + after insert on parent referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_insert_trig AFTER INSERT ON parent REFERENCING NEW TABLE new_table EXECUTE ..." +== 837 +-- truncate_limit: 100 +create trigger parent_update_trig + after update on parent referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_update_trig AFTER UPDATE ON parent REFERENCING OLD TABLE old_table NEW TABL..." +== 838 +-- truncate_limit: 100 +create trigger parent_delete_trig + after delete on parent referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_delete_trig AFTER DELETE ON parent REFERENCING OLD TABLE old_table EXECUTE ..." +== 839 +-- truncate_limit: 100 +create trigger child1_insert_trig + after insert on child1 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child1_insert_trig AFTER INSERT ON child1 REFERENCING NEW TABLE new_table EXECUTE ..." +== 840 +-- truncate_limit: 100 +create trigger child1_update_trig + after update on child1 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child1_update_trig AFTER UPDATE ON child1 REFERENCING OLD TABLE old_table NEW TABL..." +== 841 +-- truncate_limit: 100 +create trigger child1_delete_trig + after delete on child1 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child1_delete_trig AFTER DELETE ON child1 REFERENCING OLD TABLE old_table EXECUTE ..." +== 842 +-- truncate_limit: 100 +create trigger child2_insert_trig + after insert on child2 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child2_insert_trig AFTER INSERT ON child2 REFERENCING NEW TABLE new_table EXECUTE ..." +== 843 +-- truncate_limit: 100 +create trigger child2_update_trig + after update on child2 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child2_update_trig AFTER UPDATE ON child2 REFERENCING OLD TABLE old_table NEW TABL..." +== 844 +-- truncate_limit: 100 +create trigger child2_delete_trig + after delete on child2 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child2_delete_trig AFTER DELETE ON child2 REFERENCING OLD TABLE old_table EXECUTE ..." +== 845 +-- truncate_limit: 100 +create trigger child3_insert_trig + after insert on child3 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child3_insert_trig AFTER INSERT ON child3 REFERENCING NEW TABLE new_table EXECUTE ..." +== 846 +-- truncate_limit: 100 +create trigger child3_update_trig + after update on child3 referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child3_update_trig AFTER UPDATE ON child3 REFERENCING OLD TABLE old_table NEW TABL..." +== 847 +-- truncate_limit: 100 +create trigger child3_delete_trig + after delete on child3 referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child3_delete_trig AFTER DELETE ON child3 REFERENCING OLD TABLE old_table EXECUTE ..." +== 848 +-- truncate_limit: 100 +-- insert directly into children sees respective child-format tuples +insert into child1 values ('AAA', 42) +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child1 VALUES ('AAA', 42)" +== 849 +-- truncate_limit: 100 +insert into child2 values (42, 'BBB') +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child2 VALUES (42, 'BBB')" +== 850 +-- truncate_limit: 100 +insert into child3 values ('CCC', 42, 'foo') +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child3 VALUES ('CCC', 42, 'foo')" +== 851 +-- truncate_limit: 100 +-- update via parent sees parent-format tuples +update parent set b = b + 1 +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE parent SET b = b + 1" +== 852 +-- truncate_limit: 100 +-- delete via parent sees parent-format tuples +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parent" +== 853 +-- truncate_limit: 100 +-- reinsert values into children for next test... +insert into child1 values ('AAA', 42) +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child1 VALUES ('AAA', 42)" +== 854 +-- truncate_limit: 100 +insert into child2 values (42, 'BBB') +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child2 VALUES (42, 'BBB')" +== 855 +-- truncate_limit: 100 +insert into child3 values ('CCC', 42, 'foo') +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child3 VALUES ('CCC', 42, 'foo')" +== 856 +-- truncate_limit: 100 +-- delete from children sees respective child-format tuples +delete from child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM child1" +== 857 +-- truncate_limit: 100 +delete from child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM child2" +== 858 +-- truncate_limit: 100 +delete from child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM child3" +== 859 +-- truncate_limit: 100 +-- copy into parent sees parent-format tuples (no rerouting, so these +-- are really inserted into the parent) +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY parent(a, b) FROM STDIN" +== 860 +-- truncate_limit: 100 +-- same behavior for copy if there is an index (interesting because rows are +-- captured by a different code path in copyfrom.c if there are indexes) +create index on parent(b) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON parent USING btree (b)" +== 861 +-- truncate_limit: 100 +copy parent (a, b) from stdin +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: CopyStmt +TRUNCATED: "COPY parent(a, b) FROM STDIN" +== 862 +-- truncate_limit: 100 +-- check disinherit/reinherit behavior; statement triggers with transition +-- tables should not prevent a table from becoming an inheritance child again +alter table child1 no inherit parent +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child1 NO INHERIT parent" +== 863 +-- truncate_limit: 100 +alter table child1 inherit parent +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child1 INHERIT parent" +== 864 +-- truncate_limit: 100 +-- DML affecting parent sees tuples collected from children even if +-- there is no transition table trigger on the children +drop trigger child1_insert_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child1_insert_trig ON child1" +== 865 +-- truncate_limit: 100 +drop trigger child1_update_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child1_update_trig ON child1" +== 866 +-- truncate_limit: 100 +drop trigger child1_delete_trig on child1 +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child1_delete_trig ON child1" +== 867 +-- truncate_limit: 100 +drop trigger child2_insert_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child2_insert_trig ON child2" +== 868 +-- truncate_limit: 100 +drop trigger child2_update_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child2_update_trig ON child2" +== 869 +-- truncate_limit: 100 +drop trigger child2_delete_trig on child2 +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child2_delete_trig ON child2" +== 870 +-- truncate_limit: 100 +drop trigger child3_insert_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child3_insert_trig ON child3" +== 871 +-- truncate_limit: 100 +drop trigger child3_update_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child3_update_trig ON child3" +== 872 +-- truncate_limit: 100 +drop trigger child3_delete_trig on child3 +-- +TABLE: name="child3" schema="" table="child3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child3_delete_trig ON child3" +== 873 +-- truncate_limit: 100 +delete from parent +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parent" +== 874 +-- truncate_limit: 100 +drop table child1, child2, child3, parent +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +TABLE: name="child2" schema="" table="child2" ctx=DDL +TABLE: name="child3" schema="" table="child3" ctx=DDL +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE child1, child2, child3, parent" +== 875 +-- truncate_limit: 100 +|-- +-- Verify prohibition of row triggers with transition triggers on +-- inheritance children +|-- +create table parent (a text, b int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a text, b int)" +== 876 +-- truncate_limit: 100 +create table child () inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child () INHERITS (parent)" +== 877 +-- truncate_limit: 100 +-- adding row trigger with transition table fails +create trigger child_row_trig + after insert on child referencing new table as new_table + for each row execute procedure dump_insert() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child_row_trig AFTER INSERT ON child REFERENCING NEW TABLE new_table FOR EACH ROW ..." +== 878 +-- truncate_limit: 100 +-- disinheriting it first works +alter table child no inherit parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child NO INHERIT parent" +== 879 +-- truncate_limit: 100 +create trigger child_row_trig + after insert on child referencing new table as new_table + for each row execute procedure dump_insert() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER child_row_trig AFTER INSERT ON child REFERENCING NEW TABLE new_table FOR EACH ROW ..." +== 880 +-- truncate_limit: 100 +-- but now we're not allowed to make it inherit anymore +alter table child inherit parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child INHERIT parent" +== 881 +-- truncate_limit: 100 +-- drop the trigger, and now we're allowed to make it inherit again +drop trigger child_row_trig on child +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER child_row_trig ON child" +== 882 +-- truncate_limit: 100 +alter table child inherit parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE child INHERIT parent" +== 883 +-- truncate_limit: 100 +drop table child, parent +-- +TABLE: name="child" schema="" table="child" ctx=DDL +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE child, parent" +== 884 +-- truncate_limit: 100 +|-- +-- Verify behavior of queries with wCTEs, where multiple transition +-- tuplestores can be active at the same time because there are +-- multiple DML statements that might fire triggers with transition +-- tables +|-- +create table table1 (a int) +-- +TABLE: name="table1" schema="" table="table1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE table1 (a int)" +== 885 +-- truncate_limit: 100 +create table table2 (a text) +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE table2 (a text)" +== 886 +-- truncate_limit: 100 +create trigger table1_trig + after insert on table1 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="table1" schema="" table="table1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER table1_trig AFTER INSERT ON table1 REFERENCING NEW TABLE new_table EXECUTE FUNCTIO..." +== 887 +-- truncate_limit: 100 +create trigger table2_trig + after insert on table2 referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER table2_trig AFTER INSERT ON table2 REFERENCING NEW TABLE new_table EXECUTE FUNCTIO..." +== 888 +-- truncate_limit: 100 +with wcte as (insert into table1 values (42)) + insert into table2 values ('hello world') +-- +TABLE: name="table2" schema="" table="table2" ctx=DML +TABLE: name="table1" schema="" table="table1" ctx=DML +CTE: "wcte" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH wcte AS (INSERT INTO table1 VALUES (42)) INSERT INTO table2 VALUES ('hello world')" +== 889 +-- truncate_limit: 100 +with wcte as (insert into table1 values (43)) + insert into table1 values (44) +-- +TABLE: name="table1" schema="" table="table1" ctx=DML +TABLE: name="table1" schema="" table="table1" ctx=DML +CTE: "wcte" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH wcte AS (INSERT INTO table1 VALUES (43)) INSERT INTO table1 VALUES (44)" +== 890 +-- truncate_limit: 100 +select * from table1 +-- +TABLE: name="table1" schema="" table="table1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM table1" +== 891 +-- truncate_limit: 100 +select * from table2 +-- +TABLE: name="table2" schema="" table="table2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM table2" +== 892 +-- truncate_limit: 100 +drop table table1 +-- +TABLE: name="table1" schema="" table="table1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE table1" +== 893 +-- truncate_limit: 100 +drop table table2 +-- +TABLE: name="table2" schema="" table="table2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE table2" +== 894 +-- truncate_limit: 100 +|-- +-- Verify behavior of INSERT ... ON CONFLICT DO UPDATE ... with +-- transition tables. +|-- + +create table my_table (a int primary key, b text) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE my_table (a int PRIMARY KEY, b text)" +== 895 +-- truncate_limit: 100 +create trigger my_table_insert_trig + after insert on my_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_table_insert_trig AFTER INSERT ON my_table REFERENCING NEW TABLE new_table EXEC..." +== 896 +-- truncate_limit: 100 +create trigger my_table_update_trig + after update on my_table referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_table_update_trig AFTER UPDATE ON my_table REFERENCING OLD TABLE old_table NEW ..." +== 897 +-- truncate_limit: 100 +-- inserts only +insert into my_table values (1, 'AAA'), (2, 'BBB') + on conflict (a) do + update set b = my_table.b || ':' || excluded.b +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO my_table VALUES (1, 'AAA'), (2, 'BBB') ON CONFLICT (a) DO UPDATE SET ... = ..." +== 898 +-- truncate_limit: 100 +-- mixture of inserts and updates +insert into my_table values (1, 'AAA'), (2, 'BBB'), (3, 'CCC'), (4, 'DDD') + on conflict (a) do + update set b = my_table.b || ':' || excluded.b +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO my_table VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ..." +== 899 +-- truncate_limit: 100 +-- updates only +insert into my_table values (3, 'CCC'), (4, 'DDD') + on conflict (a) do + update set b = my_table.b || ':' || excluded.b +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO my_table VALUES (3, 'CCC'), (4, 'DDD') ON CONFLICT (a) DO UPDATE SET ... = ..." +== 900 +-- truncate_limit: 100 +|-- +-- now using a partitioned table +|-- + +create table iocdu_tt_parted (a int primary key, b text) partition by list (a) +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iocdu_tt_parted (a int PRIMARY KEY, b text) PARTITION BY LIST (a)" +== 901 +-- truncate_limit: 100 +create table iocdu_tt_parted1 partition of iocdu_tt_parted for values in (1) +-- +TABLE: name="iocdu_tt_parted1" schema="" table="iocdu_tt_parted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iocdu_tt_parted1 PARTITION OF iocdu_tt_parted FOR VALUES IN (1)" +== 902 +-- truncate_limit: 100 +create table iocdu_tt_parted2 partition of iocdu_tt_parted for values in (2) +-- +TABLE: name="iocdu_tt_parted2" schema="" table="iocdu_tt_parted2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iocdu_tt_parted2 PARTITION OF iocdu_tt_parted FOR VALUES IN (2)" +== 903 +-- truncate_limit: 100 +create table iocdu_tt_parted3 partition of iocdu_tt_parted for values in (3) +-- +TABLE: name="iocdu_tt_parted3" schema="" table="iocdu_tt_parted3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iocdu_tt_parted3 PARTITION OF iocdu_tt_parted FOR VALUES IN (3)" +== 904 +-- truncate_limit: 100 +create table iocdu_tt_parted4 partition of iocdu_tt_parted for values in (4) +-- +TABLE: name="iocdu_tt_parted4" schema="" table="iocdu_tt_parted4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE iocdu_tt_parted4 PARTITION OF iocdu_tt_parted FOR VALUES IN (4)" +== 905 +-- truncate_limit: 100 +create trigger iocdu_tt_parted_insert_trig + after insert on iocdu_tt_parted referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER iocdu_tt_parted_insert_trig AFTER INSERT ON iocdu_tt_parted REFERENCING NEW TABLE ..." +== 906 +-- truncate_limit: 100 +create trigger iocdu_tt_parted_update_trig + after update on iocdu_tt_parted referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER iocdu_tt_parted_update_trig AFTER UPDATE ON iocdu_tt_parted REFERENCING OLD TABLE ..." +== 907 +-- truncate_limit: 100 +-- inserts only +insert into iocdu_tt_parted values (1, 'AAA'), (2, 'BBB') + on conflict (a) do + update set b = iocdu_tt_parted.b || ':' || excluded.b +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iocdu_tt_parted VALUES (1, 'AAA'), (2, 'BBB') ON CONFLICT (a) DO UPDATE SET ... = ..." +== 908 +-- truncate_limit: 100 +-- mixture of inserts and updates +insert into iocdu_tt_parted values (1, 'AAA'), (2, 'BBB'), (3, 'CCC'), (4, 'DDD') + on conflict (a) do + update set b = iocdu_tt_parted.b || ':' || excluded.b +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iocdu_tt_parted VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ..." +== 909 +-- truncate_limit: 100 +-- updates only +insert into iocdu_tt_parted values (3, 'CCC'), (4, 'DDD') + on conflict (a) do + update set b = iocdu_tt_parted.b || ':' || excluded.b +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO iocdu_tt_parted VALUES (3, 'CCC'), (4, 'DDD') ON CONFLICT (a) DO UPDATE SET ... = ..." +== 910 +-- truncate_limit: 100 +drop table iocdu_tt_parted +-- +TABLE: name="iocdu_tt_parted" schema="" table="iocdu_tt_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE iocdu_tt_parted" +== 911 +-- truncate_limit: 100 +|-- +-- Verify that you can't create a trigger with transition tables for +-- more than one event. +|-- + +create trigger my_table_multievent_trig + after insert or update on my_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_table_multievent_trig AFTER INSERT OR UPDATE ON my_table REFERENCING NEW TABLE ..." +== 912 +-- truncate_limit: 100 +|-- +-- Verify that you can't create a trigger with transition tables with +-- a column list. +|-- + +create trigger my_table_col_update_trig + after update of b on my_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_table_col_update_trig AFTER UPDATE OF b ON my_table REFERENCING NEW TABLE new_t..." +== 913 +-- truncate_limit: 100 +drop table my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE my_table" +== 914 +-- truncate_limit: 100 +|-- +-- Test firing of triggers with transition tables by foreign key cascades +|-- + +create table refd_table (a int primary key, b text) +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE refd_table (a int PRIMARY KEY, b text)" +== 915 +-- truncate_limit: 100 +create table trig_table (a int, b text, + foreign key (a) references refd_table on update cascade on delete cascade +) +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trig_table (a int, b text, FOREIGN KEY (a) REFERENCES refd_table ON UPDATE CASCADE O..." +== 916 +-- truncate_limit: 100 +create trigger trig_table_before_trig + before insert or update or delete on trig_table + for each statement execute procedure trigger_func('trig_table') +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_table_before_trig BEFORE INSERT OR DELETE OR UPDATE ON trig_table EXECUTE FUN..." +== 917 +-- truncate_limit: 100 +create trigger trig_table_insert_trig + after insert on trig_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_table_insert_trig AFTER INSERT ON trig_table REFERENCING NEW TABLE new_table ..." +== 918 +-- truncate_limit: 100 +create trigger trig_table_update_trig + after update on trig_table referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_table_update_trig AFTER UPDATE ON trig_table REFERENCING OLD TABLE old_table ..." +== 919 +-- truncate_limit: 100 +create trigger trig_table_delete_trig + after delete on trig_table referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_table_delete_trig AFTER DELETE ON trig_table REFERENCING OLD TABLE old_table ..." +== 920 +-- truncate_limit: 100 +insert into refd_table values + (1, 'one'), + (2, 'two'), + (3, 'three') +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO refd_table VALUES (1, 'one'), (2, 'two'), (3, 'three')" +== 921 +-- truncate_limit: 100 +insert into trig_table values + (1, 'one a'), + (1, 'one b'), + (2, 'two a'), + (2, 'two b'), + (3, 'three a'), + (3, 'three b') +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trig_table VALUES (...)" +== 922 +-- truncate_limit: 100 +update refd_table set a = 11 where b = 'one' +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE refd_table SET a = 11 WHERE b = 'one'" +== 923 +-- truncate_limit: 100 +select * from trig_table +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trig_table" +== 924 +-- truncate_limit: 100 +delete from refd_table where length(b) = 3 +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DML +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM refd_table WHERE length(b) = 3" +== 925 +-- truncate_limit: 100 +select * from trig_table +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trig_table" +== 926 +-- truncate_limit: 100 +drop table refd_table, trig_table +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DDL +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE refd_table, trig_table" +== 927 +-- truncate_limit: 100 +|-- +-- Test that we can drop a not-yet-fired deferred trigger +|-- + +create table refd_table (id int primary key) +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE refd_table (id int PRIMARY KEY)" +== 928 +-- truncate_limit: 100 +create table trig_table (fk int references refd_table initially deferred) +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trig_table (fk int REFERENCES refd_table INITIALLY DEFERRED)" +== 929 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 930 +-- truncate_limit: 100 +insert into trig_table values (1) +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trig_table VALUES (1)" +== 931 +-- truncate_limit: 100 +drop table refd_table cascade +-- +TABLE: name="refd_table" schema="" table="refd_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE refd_table CASCADE" +== 932 +-- truncate_limit: 100 +commit +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 933 +-- truncate_limit: 100 +drop table trig_table +-- +TABLE: name="trig_table" schema="" table="trig_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trig_table" +== 934 +-- truncate_limit: 100 +|-- +-- self-referential FKs are even more fun +|-- + +create table self_ref (a int primary key, + b int references self_ref(a) on delete cascade) +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE self_ref (a int PRIMARY KEY, b int REFERENCES self_ref (a) ON DELETE CASCADE)" +== 935 +-- truncate_limit: 100 +create trigger self_ref_before_trig + before delete on self_ref + for each statement execute procedure trigger_func('self_ref') +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER self_ref_before_trig BEFORE DELETE ON self_ref EXECUTE FUNCTION trigger_func('self..." +== 936 +-- truncate_limit: 100 +create trigger self_ref_r_trig + after delete on self_ref referencing old table as old_table + for each row execute procedure dump_delete() +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER self_ref_r_trig AFTER DELETE ON self_ref REFERENCING OLD TABLE old_table FOR EACH ..." +== 937 +-- truncate_limit: 100 +create trigger self_ref_s_trig + after delete on self_ref referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER self_ref_s_trig AFTER DELETE ON self_ref REFERENCING OLD TABLE old_table EXECUTE F..." +== 938 +-- truncate_limit: 100 +insert into self_ref values (1, null), (2, 1), (3, 2) +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO self_ref VALUES (1, NULL), (2, 1), (3, 2)" +== 939 +-- truncate_limit: 100 +delete from self_ref where a = 1 +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM self_ref WHERE a = 1" +== 940 +-- truncate_limit: 100 +-- without AR trigger, cascaded deletes all end up in one transition table +drop trigger self_ref_r_trig on self_ref +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER self_ref_r_trig ON self_ref" +== 941 +-- truncate_limit: 100 +insert into self_ref values (1, null), (2, 1), (3, 2), (4, 3) +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO self_ref VALUES (1, NULL), (2, 1), (3, 2), (4, 3)" +== 942 +-- truncate_limit: 100 +delete from self_ref where a = 1 +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM self_ref WHERE a = 1" +== 943 +-- truncate_limit: 100 +drop table self_ref +-- +TABLE: name="self_ref" schema="" table="self_ref" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE self_ref" +== 944 +-- truncate_limit: 100 +|-- +-- test transition tables with MERGE +|-- +create table merge_target_table (a int primary key, b text) +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE merge_target_table (a int PRIMARY KEY, b text)" +== 945 +-- truncate_limit: 100 +create trigger merge_target_table_insert_trig + after insert on merge_target_table referencing new table as new_table + for each statement execute procedure dump_insert() +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_target_table_insert_trig AFTER INSERT ON merge_target_table REFERENCING NEW ..." +== 946 +-- truncate_limit: 100 +create trigger merge_target_table_update_trig + after update on merge_target_table referencing old table as old_table new table as new_table + for each statement execute procedure dump_update() +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_target_table_update_trig AFTER UPDATE ON merge_target_table REFERENCING OLD ..." +== 947 +-- truncate_limit: 100 +create trigger merge_target_table_delete_trig + after delete on merge_target_table referencing old table as old_table + for each statement execute procedure dump_delete() +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER merge_target_table_delete_trig AFTER DELETE ON merge_target_table REFERENCING OLD ..." +== 948 +-- truncate_limit: 100 +create table merge_source_table (a int, b text) +-- +TABLE: name="merge_source_table" schema="" table="merge_source_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE merge_source_table (a int, b text)" +== 949 +-- truncate_limit: 100 +insert into merge_source_table + values (1, 'initial1'), (2, 'initial2'), + (3, 'initial3'), (4, 'initial4') +-- +TABLE: name="merge_source_table" schema="" table="merge_source_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO merge_source_table VALUES (...)" +== 950 +-- truncate_limit: 100 +merge into merge_target_table t +using merge_source_table s +on t.a = s.a +when not matched then + insert values (a, b) +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DML +ALIAS: "t"="merge_target_table" +STMT: MergeStmt +TRUNCATED: "MERGE INTO merge_target_table t USING merge_source_table s ON t.a = s.a WHEN NOT MATCHED THEN INS..." +== 951 +-- truncate_limit: 100 +merge into merge_target_table t +using merge_source_table s +on t.a = s.a +when matched and s.a <= 2 then + update set b = t.b || ' updated by merge' +when matched and s.a > 2 then + delete +when not matched then + insert values (a, b) +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DML +ALIAS: "t"="merge_target_table" +STMT: MergeStmt +TRUNCATED: "MERGE INTO merge_target_table t USING merge_source_table s ON t.a = s.a WHEN MATCHED AND s.a <= 2..." +== 952 +-- truncate_limit: 100 +merge into merge_target_table t +using merge_source_table s +on t.a = s.a +when matched and s.a <= 2 then + update set b = t.b || ' updated again by merge' +when matched and s.a > 2 then + delete +when not matched then + insert values (a, b) +-- +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DML +ALIAS: "t"="merge_target_table" +STMT: MergeStmt +TRUNCATED: "MERGE INTO merge_target_table t USING merge_source_table s ON t.a = s.a WHEN MATCHED AND s.a <= 2..." +== 953 +-- truncate_limit: 100 +drop table merge_source_table, merge_target_table +-- +TABLE: name="merge_source_table" schema="" table="merge_source_table" ctx=DDL +TABLE: name="merge_target_table" schema="" table="merge_target_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE merge_source_table, merge_target_table" +== 954 +-- truncate_limit: 100 +-- cleanup +drop function dump_insert() +-- +FUNCTION: name="dump_insert" function="dump_insert" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dump_insert()" +== 955 +-- truncate_limit: 100 +drop function dump_update() +-- +FUNCTION: name="dump_update" function="dump_update" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dump_update()" +== 956 +-- truncate_limit: 100 +drop function dump_delete() +-- +FUNCTION: name="dump_delete" function="dump_delete" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dump_delete()" +== 957 +-- truncate_limit: 100 +|-- +-- Tests for CREATE OR REPLACE TRIGGER +|-- +create table my_table (id integer) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE my_table (id int)" +== 958 +-- truncate_limit: 100 +create function funcA() returns trigger as $$ +begin + raise notice 'hello from funcA'; + return null; +end; $$ language plpgsql +-- +FUNCTION: name="funca" function="funca" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION funca() RETURNS trigger AS $$\nbegin\n raise notice 'hello from funcA';\n return n..." +== 959 +-- truncate_limit: 100 +create function funcB() returns trigger as $$ +begin + raise notice 'hello from funcB'; + return null; +end; $$ language plpgsql +-- +FUNCTION: name="funcb" function="funcb" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION funcb() RETURNS trigger AS $$\nbegin\n raise notice 'hello from funcB';\n return n..." +== 960 +-- truncate_limit: 100 +create trigger my_trig + after insert on my_table + for each row execute procedure funcA() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_trig AFTER INSERT ON my_table FOR EACH ROW EXECUTE FUNCTION funca()" +== 961 +-- truncate_limit: 100 +create trigger my_trig + before insert on my_table + for each row execute procedure funcB() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_trig BEFORE INSERT ON my_table FOR EACH ROW EXECUTE FUNCTION funcb()" +== 962 +-- truncate_limit: 100 +-- should fail + +insert into my_table values (1) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO my_table VALUES (1)" +== 963 +-- truncate_limit: 100 +create or replace trigger my_trig + before insert on my_table + for each row execute procedure funcB() +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE OR REPLACE TRIGGER my_trig BEFORE INSERT ON my_table FOR EACH ROW EXECUTE FUNCTION funcb()" +== 964 +-- truncate_limit: 100 +-- OK + +insert into my_table values (2) +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO my_table VALUES (2)" +== 965 +-- truncate_limit: 100 +-- this insert should become a no-op + +table my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM my_table" +== 966 +-- truncate_limit: 100 +drop table my_table +-- +TABLE: name="my_table" schema="" table="my_table" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE my_table" +== 967 +-- truncate_limit: 100 +-- test CREATE OR REPLACE TRIGGER on partition table +create table parted_trig (a int) partition by range (a) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig (a int) PARTITION BY RANGE (a)" +== 968 +-- truncate_limit: 100 +create table parted_trig_1 partition of parted_trig + for values from (0) to (1000) partition by range (a) +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig_1 PARTITION OF parted_trig FOR VALUES FROM (0) TO (1000) PARTITION BY RA..." +== 969 +-- truncate_limit: 100 +create table parted_trig_1_1 partition of parted_trig_1 for values from (0) to (100) +-- +TABLE: name="parted_trig_1_1" schema="" table="parted_trig_1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig_1_1 PARTITION OF parted_trig_1 FOR VALUES FROM (0) TO (100)" +== 970 +-- truncate_limit: 100 +create table parted_trig_2 partition of parted_trig for values from (1000) to (2000) +-- +TABLE: name="parted_trig_2" schema="" table="parted_trig_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parted_trig_2 PARTITION OF parted_trig FOR VALUES FROM (1000) TO (2000)" +== 971 +-- truncate_limit: 100 +create table default_parted_trig partition of parted_trig default +-- +TABLE: name="default_parted_trig" schema="" table="default_parted_trig" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE default_parted_trig PARTITION OF parted_trig DEFAULT" +== 972 +-- truncate_limit: 100 +-- test that trigger can be replaced by another one +-- at the same level of partition table +create or replace trigger my_trig + after insert on parted_trig + for each row execute procedure funcA() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE OR REPLACE TRIGGER my_trig AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE FUNCTION funca()" +== 973 +-- truncate_limit: 100 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig (a) VALUES (50)" +== 974 +-- truncate_limit: 100 +create or replace trigger my_trig + after insert on parted_trig + for each row execute procedure funcB() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE OR REPLACE TRIGGER my_trig AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE FUNCTION funcb()" +== 975 +-- truncate_limit: 100 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig (a) VALUES (50)" +== 976 +-- truncate_limit: 100 +-- test that child trigger cannot be replaced directly +create or replace trigger my_trig + after insert on parted_trig + for each row execute procedure funcA() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE OR REPLACE TRIGGER my_trig AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE FUNCTION funca()" +== 977 +-- truncate_limit: 100 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig (a) VALUES (50)" +== 978 +-- truncate_limit: 100 +create or replace trigger my_trig + after insert on parted_trig_1 + for each row execute procedure funcB() +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE OR REPLACE TRIGGER my_trig AFTER INSERT ON parted_trig_1 FOR EACH ROW EXECUTE FUNCTION fun..." +== 979 +-- truncate_limit: 100 +-- should fail +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig (a) VALUES (50)" +== 980 +-- truncate_limit: 100 +drop trigger my_trig on parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER my_trig ON parted_trig" +== 981 +-- truncate_limit: 100 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig (a) VALUES (50)" +== 982 +-- truncate_limit: 100 +-- test that user trigger can be overwritten by one defined at upper level +create trigger my_trig + after insert on parted_trig_1 + for each row execute procedure funcA() +-- +TABLE: name="parted_trig_1" schema="" table="parted_trig_1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_trig AFTER INSERT ON parted_trig_1 FOR EACH ROW EXECUTE FUNCTION funca()" +== 983 +-- truncate_limit: 100 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig (a) VALUES (50)" +== 984 +-- truncate_limit: 100 +create trigger my_trig + after insert on parted_trig + for each row execute procedure funcB() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER my_trig AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE FUNCTION funcb()" +== 985 +-- truncate_limit: 100 +-- should fail +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig (a) VALUES (50)" +== 986 +-- truncate_limit: 100 +create or replace trigger my_trig + after insert on parted_trig + for each row execute procedure funcB() +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE OR REPLACE TRIGGER my_trig AFTER INSERT ON parted_trig FOR EACH ROW EXECUTE FUNCTION funcb()" +== 987 +-- truncate_limit: 100 +insert into parted_trig (a) values (50) +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parted_trig (a) VALUES (50)" +== 988 +-- truncate_limit: 100 +-- cleanup +drop table parted_trig +-- +TABLE: name="parted_trig" schema="" table="parted_trig" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parted_trig" +== 989 +-- truncate_limit: 100 +drop function funcA() +-- +FUNCTION: name="funca" function="funca" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION funca()" +== 990 +-- truncate_limit: 100 +drop function funcB() +-- +FUNCTION: name="funcb" function="funcb" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION funcb()" +== 991 +-- truncate_limit: 100 +-- Leave around some objects for other tests +create table trigger_parted (a int primary key) partition by list (a) +-- +TABLE: name="trigger_parted" schema="" table="trigger_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigger_parted (a int PRIMARY KEY) PARTITION BY LIST (a)" +== 992 +-- truncate_limit: 100 +create function trigger_parted_trigfunc() returns trigger language plpgsql as + $$ begin end; $$ +-- +FUNCTION: name="trigger_parted_trigfunc" function="trigger_parted_trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trigger_parted_trigfunc() RETURNS trigger LANGUAGE plpgsql AS $$ begin end; $$" +== 993 +-- truncate_limit: 100 +create trigger aft_row after insert or update on trigger_parted + for each row execute function trigger_parted_trigfunc() +-- +TABLE: name="trigger_parted" schema="" table="trigger_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER aft_row AFTER INSERT OR UPDATE ON trigger_parted FOR EACH ROW EXECUTE FUNCTION tri..." +== 994 +-- truncate_limit: 100 +create table trigger_parted_p1 partition of trigger_parted for values in (1) + partition by list (a) +-- +TABLE: name="trigger_parted_p1" schema="" table="trigger_parted_p1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigger_parted_p1 PARTITION OF trigger_parted FOR VALUES IN (1) PARTITION BY LIST (a)" +== 995 +-- truncate_limit: 100 +create table trigger_parted_p1_1 partition of trigger_parted_p1 for values in (1) +-- +TABLE: name="trigger_parted_p1_1" schema="" table="trigger_parted_p1_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigger_parted_p1_1 PARTITION OF trigger_parted_p1 FOR VALUES IN (1)" +== 996 +-- truncate_limit: 100 +create table trigger_parted_p2 partition of trigger_parted for values in (2) + partition by list (a) +-- +TABLE: name="trigger_parted_p2" schema="" table="trigger_parted_p2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigger_parted_p2 PARTITION OF trigger_parted FOR VALUES IN (2) PARTITION BY LIST (a)" +== 997 +-- truncate_limit: 100 +create table trigger_parted_p2_2 partition of trigger_parted_p2 for values in (2) +-- +TABLE: name="trigger_parted_p2_2" schema="" table="trigger_parted_p2_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trigger_parted_p2_2 PARTITION OF trigger_parted_p2 FOR VALUES IN (2)" +== 998 +-- truncate_limit: 100 +alter table only trigger_parted_p2 disable trigger aft_row +-- +TABLE: name="trigger_parted_p2" schema="" table="trigger_parted_p2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE ONLY trigger_parted_p2 DISABLE TRIGGER aft_row" +== 999 +-- truncate_limit: 100 +alter table trigger_parted_p2_2 enable always trigger aft_row +-- +TABLE: name="trigger_parted_p2_2" schema="" table="trigger_parted_p2_2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE trigger_parted_p2_2 ENABLE ALWAYS TRIGGER aft_row" +== 1000 +-- truncate_limit: 100 +-- verify transition table conversion slot's lifetime +-- https://postgr.es/m/39a71864-b120-5a5c-8cc5-c632b6f16761@amazon.com +create table convslot_test_parent (col1 text primary key) +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE convslot_test_parent (col1 text PRIMARY KEY)" +== 1001 +-- truncate_limit: 100 +create table convslot_test_child (col1 text primary key, + foreign key (col1) references convslot_test_parent(col1) on delete cascade on update cascade +) +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE convslot_test_child (col1 text PRIMARY KEY, FOREIGN KEY (col1) REFERENCES convslot_t..." +== 1002 +-- truncate_limit: 100 +alter table convslot_test_child add column col2 text not null default 'tutu' +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE convslot_test_child ADD COLUMN col2 text NOT NULL DEFAULT 'tutu'" +== 1003 +-- truncate_limit: 100 +insert into convslot_test_parent(col1) values ('1') +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO convslot_test_parent (col1) VALUES ('1')" +== 1004 +-- truncate_limit: 100 +insert into convslot_test_child(col1) values ('1') +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO convslot_test_child (col1) VALUES ('1')" +== 1005 +-- truncate_limit: 100 +insert into convslot_test_parent(col1) values ('3') +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO convslot_test_parent (col1) VALUES ('3')" +== 1006 +-- truncate_limit: 100 +insert into convslot_test_child(col1) values ('3') +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO convslot_test_child (col1) VALUES ('3')" +== 1007 +-- truncate_limit: 100 +create function convslot_trig1() +returns trigger +language plpgsql +AS $$ +begin +raise notice 'trigger = %, old_table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' order by col1) from old_table); +return null; +end; $$ +-- +FUNCTION: name="convslot_trig1" function="convslot_trig1" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION convslot_trig1() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\nraise notice 'trigg..." +== 1008 +-- truncate_limit: 100 +create function convslot_trig2() +returns trigger +language plpgsql +AS $$ +begin +raise notice 'trigger = %, new table = %', + TG_NAME, + (select string_agg(new_table::text, ', ' order by col1) from new_table); +return null; +end; $$ +-- +FUNCTION: name="convslot_trig2" function="convslot_trig2" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION convslot_trig2() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\nraise notice 'trigg..." +== 1009 +-- truncate_limit: 100 +create trigger but_trigger after update on convslot_test_child +referencing new table as new_table +for each statement execute function convslot_trig2() +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER but_trigger AFTER UPDATE ON convslot_test_child REFERENCING NEW TABLE new_table EX..." +== 1010 +-- truncate_limit: 100 +update convslot_test_parent set col1 = col1 || '1' +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE convslot_test_parent SET col1 = col1 || '1'" +== 1011 +-- truncate_limit: 100 +create function convslot_trig3() +returns trigger +language plpgsql +AS $$ +begin +raise notice 'trigger = %, old_table = %, new table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' order by col1) from old_table), + (select string_agg(new_table::text, ', ' order by col1) from new_table); +return null; +end; $$ +-- +FUNCTION: name="convslot_trig3" function="convslot_trig3" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION convslot_trig3() RETURNS trigger LANGUAGE plpgsql AS $$\nbegin\nraise notice 'trigg..." +== 1012 +-- truncate_limit: 100 +create trigger but_trigger2 after update on convslot_test_child +referencing old table as old_table new table as new_table +for each statement execute function convslot_trig3() +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER but_trigger2 AFTER UPDATE ON convslot_test_child REFERENCING OLD TABLE old_table N..." +== 1013 +-- truncate_limit: 100 +update convslot_test_parent set col1 = col1 || '1' +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE convslot_test_parent SET col1 = col1 || '1'" +== 1014 +-- truncate_limit: 100 +create trigger bdt_trigger after delete on convslot_test_child +referencing old table as old_table +for each statement execute function convslot_trig1() +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER bdt_trigger AFTER DELETE ON convslot_test_child REFERENCING OLD TABLE old_table EX..." +== 1015 +-- truncate_limit: 100 +delete from convslot_test_parent +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM convslot_test_parent" +== 1016 +-- truncate_limit: 100 +drop table convslot_test_child, convslot_test_parent +-- +TABLE: name="convslot_test_child" schema="" table="convslot_test_child" ctx=DDL +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE convslot_test_child, convslot_test_parent" +== 1017 +-- truncate_limit: 100 +drop function convslot_trig1() +-- +FUNCTION: name="convslot_trig1" function="convslot_trig1" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION convslot_trig1()" +== 1018 +-- truncate_limit: 100 +drop function convslot_trig2() +-- +FUNCTION: name="convslot_trig2" function="convslot_trig2" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION convslot_trig2()" +== 1019 +-- truncate_limit: 100 +drop function convslot_trig3() +-- +FUNCTION: name="convslot_trig3" function="convslot_trig3" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION convslot_trig3()" +== 1020 +-- truncate_limit: 100 +-- Bug #17607: variant of above in which trigger function raises an error; +-- we don't see any ill effects unless trigger tuple requires mapping + +create table convslot_test_parent (id int primary key, val int) +partition by range (id) +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE convslot_test_parent (id int PRIMARY KEY, val int) PARTITION BY RANGE (id)" +== 1021 +-- truncate_limit: 100 +create table convslot_test_part (val int, id int not null) +-- +TABLE: name="convslot_test_part" schema="" table="convslot_test_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE convslot_test_part (val int, id int NOT NULL)" +== 1022 +-- truncate_limit: 100 +alter table convslot_test_parent + attach partition convslot_test_part for values from (1) to (1000) +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE convslot_test_parent ATTACH PARTITION convslot_test_part FOR VALUES FROM (1) TO (1000)" +== 1023 +-- truncate_limit: 100 +create function convslot_trig4() returns trigger as +$$begin raise exception 'BOOM!'; end$$ language plpgsql +-- +FUNCTION: name="convslot_trig4" function="convslot_trig4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION convslot_trig4() RETURNS trigger AS $$begin raise exception 'BOOM!'; end$$ LANGUA..." +== 1024 +-- truncate_limit: 100 +create trigger convslot_test_parent_update + after update on convslot_test_parent + referencing old table as old_rows new table as new_rows + for each statement execute procedure convslot_trig4() +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER convslot_test_parent_update AFTER UPDATE ON convslot_test_parent REFERENCING OLD T..." +== 1025 +-- truncate_limit: 100 +insert into convslot_test_parent (id, val) values (1, 2) +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO convslot_test_parent (id, val) VALUES (1, 2)" +== 1026 +-- truncate_limit: 100 +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 1027 +-- truncate_limit: 100 +savepoint svp +-- +STMT: TransactionStmt +TRUNCATED: "SAVEPOINT svp" +== 1028 +-- truncate_limit: 100 +update convslot_test_parent set val = 3 +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE convslot_test_parent SET val = 3" +== 1029 +-- truncate_limit: 100 +-- error expected +rollback to savepoint svp +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK TO SAVEPOINT svp" +== 1030 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 1031 +-- truncate_limit: 100 +drop table convslot_test_parent +-- +TABLE: name="convslot_test_parent" schema="" table="convslot_test_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE convslot_test_parent" +== 1032 +-- truncate_limit: 100 +drop function convslot_trig4() +-- +FUNCTION: name="convslot_trig4" function="convslot_trig4" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION convslot_trig4()" +== 1033 +-- truncate_limit: 100 +-- Test trigger renaming on partitioned tables +create table grandparent (id int, primary key (id)) partition by range (id) +-- +TABLE: name="grandparent" schema="" table="grandparent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE grandparent (id int, PRIMARY KEY (id)) PARTITION BY RANGE (id)" +== 1034 +-- truncate_limit: 100 +create table middle partition of grandparent for values from (1) to (10) +partition by range (id) +-- +TABLE: name="middle" schema="" table="middle" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE middle PARTITION OF grandparent FOR VALUES FROM (1) TO (10) PARTITION BY RANGE (id)" +== 1035 +-- truncate_limit: 100 +create table chi partition of middle for values from (1) to (5) +-- +TABLE: name="chi" schema="" table="chi" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE chi PARTITION OF middle FOR VALUES FROM (1) TO (5)" +== 1036 +-- truncate_limit: 100 +create table cho partition of middle for values from (6) to (10) +-- +TABLE: name="cho" schema="" table="cho" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE cho PARTITION OF middle FOR VALUES FROM (6) TO (10)" +== 1037 +-- truncate_limit: 100 +create function f () returns trigger as +$$ begin return new; end; $$ +language plpgsql +-- +FUNCTION: name="f" function="f" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION f() RETURNS trigger AS $$ begin return new; end; $$ LANGUAGE plpgsql" +== 1038 +-- truncate_limit: 100 +create trigger a after insert on grandparent +for each row execute procedure f() +-- +TABLE: name="grandparent" schema="" table="grandparent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER a AFTER INSERT ON grandparent FOR EACH ROW EXECUTE FUNCTION f()" +== 1039 +-- truncate_limit: 100 +alter trigger a on grandparent rename to b +-- +STMT: RenameStmt +TRUNCATED: "ALTER TRIGGER a ON grandparent RENAME TO b" +== 1040 +-- truncate_limit: 100 +select tgrelid::regclass, tgname, +(select tgname from pg_trigger tr where tr.oid = pg_trigger.tgparentid) parent_tgname +from pg_trigger where tgrelid in (select relid from pg_partition_tree('grandparent')) +order by tgname, tgrelid::regclass::text COLLATE "C" +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +ALIAS: "tr"="pg_trigger" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="tr" column="oid" +FILTER: schema="" table="pg_trigger" column="tgparentid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgname, tgrelid::regclass::text COLLATE \"C\"" +== 1041 +-- truncate_limit: 100 +alter trigger a on only grandparent rename to b +-- +ERROR: syntax error at or near "only" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 1042 +-- truncate_limit: 100 +-- ONLY not supported +alter trigger b on middle rename to c +-- +STMT: RenameStmt +TRUNCATED: "ALTER TRIGGER b ON middle RENAME TO c" +== 1043 +-- truncate_limit: 100 +-- can't rename trigger on partition +create trigger c after insert on middle +for each row execute procedure f() +-- +TABLE: name="middle" schema="" table="middle" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER c AFTER INSERT ON middle FOR EACH ROW EXECUTE FUNCTION f()" +== 1044 +-- truncate_limit: 100 +alter trigger b on grandparent rename to c +-- +STMT: RenameStmt +TRUNCATED: "ALTER TRIGGER b ON grandparent RENAME TO c" +== 1045 +-- truncate_limit: 100 +-- Rename cascading does not affect statement triggers +create trigger p after insert on grandparent for each statement execute function f() +-- +TABLE: name="grandparent" schema="" table="grandparent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER p AFTER INSERT ON grandparent EXECUTE FUNCTION f()" +== 1046 +-- truncate_limit: 100 +create trigger p after insert on middle for each statement execute function f() +-- +TABLE: name="middle" schema="" table="middle" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER p AFTER INSERT ON middle EXECUTE FUNCTION f()" +== 1047 +-- truncate_limit: 100 +alter trigger p on grandparent rename to q +-- +STMT: RenameStmt +TRUNCATED: "ALTER TRIGGER p ON grandparent RENAME TO q" +== 1048 +-- truncate_limit: 100 +select tgrelid::regclass, tgname, +(select tgname from pg_trigger tr where tr.oid = pg_trigger.tgparentid) parent_tgname +from pg_trigger where tgrelid in (select relid from pg_partition_tree('grandparent')) +order by tgname, tgrelid::regclass::text COLLATE "C" +-- +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +TABLE: name="pg_trigger" schema="" table="pg_trigger" ctx=Select +ALIAS: "tr"="pg_trigger" +FUNCTION: name="pg_partition_tree" function="pg_partition_tree" schema="" ctx=Call +FILTER: schema="" table="" column="tgrelid" +FILTER: schema="" table="tr" column="oid" +FILTER: schema="" table="pg_trigger" column="tgparentid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_trigger WHERE ... ORDER BY tgname, tgrelid::regclass::text COLLATE \"C\"" +== 1049 +-- truncate_limit: 100 +drop table grandparent +-- +TABLE: name="grandparent" schema="" table="grandparent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE grandparent" +== 1050 +-- truncate_limit: 100 +-- Trigger renaming does not recurse on legacy inheritance +create table parent (a int) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parent (a int)" +== 1051 +-- truncate_limit: 100 +create table child () inherits (parent) +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE child () INHERITS (parent)" +== 1052 +-- truncate_limit: 100 +create trigger parenttrig after insert on parent +for each row execute procedure f() +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parenttrig AFTER INSERT ON parent FOR EACH ROW EXECUTE FUNCTION f()" +== 1053 +-- truncate_limit: 100 +create trigger parenttrig after insert on child +for each row execute procedure f() +-- +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parenttrig AFTER INSERT ON child FOR EACH ROW EXECUTE FUNCTION f()" +== 1054 +-- truncate_limit: 100 +alter trigger parenttrig on parent rename to anothertrig +-- +STMT: RenameStmt +TRUNCATED: "ALTER TRIGGER parenttrig ON parent RENAME TO anothertrig" +== 1055 +-- truncate_limit: 100 +drop table parent, child +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +TABLE: name="child" schema="" table="child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parent, child" +== 1056 +-- truncate_limit: 100 +drop function f() +-- +FUNCTION: name="f" function="f" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION f()" diff --git a/parser/testdata/summary_truncate/postgres_regress/truncate.metadata.json b/parser/testdata/summary_truncate/postgres_regress/truncate.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/truncate.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/truncate.test b/parser/testdata/summary_truncate/postgres_regress/truncate.test new file mode 100644 index 0000000..97df7a8 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/truncate.test @@ -0,0 +1,1497 @@ +== 001 +-- truncate_limit: 100 +-- Test basic TRUNCATE functionality. +CREATE TABLE truncate_a (col1 integer primary key) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncate_a (col1 int PRIMARY KEY)" +== 002 +-- truncate_limit: 100 +INSERT INTO truncate_a VALUES (1) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO truncate_a VALUES (1)" +== 003 +-- truncate_limit: 100 +INSERT INTO truncate_a VALUES (2) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO truncate_a VALUES (2)" +== 004 +-- truncate_limit: 100 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_a" +== 005 +-- truncate_limit: 100 +-- Roll truncate back +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 006 +-- truncate_limit: 100 +TRUNCATE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a" +== 007 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 008 +-- truncate_limit: 100 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_a" +== 009 +-- truncate_limit: 100 +-- Commit the truncate this time +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 010 +-- truncate_limit: 100 +TRUNCATE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a" +== 011 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 012 +-- truncate_limit: 100 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_a" +== 013 +-- truncate_limit: 100 +-- Test foreign-key checks +CREATE TABLE trunc_b (a int REFERENCES truncate_a) +-- +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_b (a int REFERENCES truncate_a)" +== 014 +-- truncate_limit: 100 +CREATE TABLE trunc_c (a serial PRIMARY KEY) +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_c (a serial PRIMARY KEY)" +== 015 +-- truncate_limit: 100 +CREATE TABLE trunc_d (a int REFERENCES trunc_c) +-- +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_d (a int REFERENCES trunc_c)" +== 016 +-- truncate_limit: 100 +CREATE TABLE trunc_e (a int REFERENCES truncate_a, b int REFERENCES trunc_c) +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_e (a int REFERENCES truncate_a, b int REFERENCES trunc_c)" +== 017 +-- truncate_limit: 100 +TRUNCATE TABLE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a" +== 018 +-- truncate_limit: 100 +-- fail +TRUNCATE TABLE truncate_a,trunc_b +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a, trunc_b" +== 019 +-- truncate_limit: 100 +-- fail +TRUNCATE TABLE truncate_a,trunc_b,trunc_e +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a, trunc_b, trunc_e" +== 020 +-- truncate_limit: 100 +-- ok +TRUNCATE TABLE truncate_a,trunc_e +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a, trunc_e" +== 021 +-- truncate_limit: 100 +-- fail +TRUNCATE TABLE trunc_c +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c" +== 022 +-- truncate_limit: 100 +-- fail +TRUNCATE TABLE trunc_c,trunc_d +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c, trunc_d" +== 023 +-- truncate_limit: 100 +-- fail +TRUNCATE TABLE trunc_c,trunc_d,trunc_e +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c, trunc_d, trunc_e" +== 024 +-- truncate_limit: 100 +-- ok +TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c, trunc_d, trunc_e, truncate_a" +== 025 +-- truncate_limit: 100 +-- fail +TRUNCATE TABLE trunc_c,trunc_d,trunc_e,truncate_a,trunc_b +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c, trunc_d, trunc_e, truncate_a, trunc_b" +== 026 +-- truncate_limit: 100 +-- ok + +TRUNCATE TABLE truncate_a RESTRICT +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a" +== 027 +-- truncate_limit: 100 +-- fail +TRUNCATE TABLE truncate_a CASCADE +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a CASCADE" +== 028 +-- truncate_limit: 100 +-- ok + +-- circular references +ALTER TABLE truncate_a ADD FOREIGN KEY (col1) REFERENCES trunc_c +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE truncate_a ADD FOREIGN KEY (col1) REFERENCES trunc_c" +== 029 +-- truncate_limit: 100 +-- Add some data to verify that truncating actually works ... +INSERT INTO trunc_c VALUES (1) +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_c VALUES (1)" +== 030 +-- truncate_limit: 100 +INSERT INTO truncate_a VALUES (1) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO truncate_a VALUES (1)" +== 031 +-- truncate_limit: 100 +INSERT INTO trunc_b VALUES (1) +-- +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_b VALUES (1)" +== 032 +-- truncate_limit: 100 +INSERT INTO trunc_d VALUES (1) +-- +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_d VALUES (1)" +== 033 +-- truncate_limit: 100 +INSERT INTO trunc_e VALUES (1,1) +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_e VALUES (1, 1)" +== 034 +-- truncate_limit: 100 +TRUNCATE TABLE trunc_c +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c" +== 035 +-- truncate_limit: 100 +TRUNCATE TABLE trunc_c,truncate_a +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c, truncate_a" +== 036 +-- truncate_limit: 100 +TRUNCATE TABLE trunc_c,truncate_a,trunc_d +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c, truncate_a, trunc_d" +== 037 +-- truncate_limit: 100 +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c, truncate_a, trunc_d, trunc_e" +== 038 +-- truncate_limit: 100 +TRUNCATE TABLE trunc_c,truncate_a,trunc_d,trunc_e,trunc_b +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c, truncate_a, trunc_d, trunc_e, trunc_b" +== 039 +-- truncate_limit: 100 +-- Verify that truncating did actually work +SELECT * FROM truncate_a + UNION ALL + SELECT * FROM trunc_c + UNION ALL + SELECT * FROM trunc_b + UNION ALL + SELECT * FROM trunc_d +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=Select +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=Select +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=Select +STMT: SelectStmt +TRUNCATED: "((SELECT * FROM truncate_a UNION ALL SELECT * FROM trunc_c) UNION ALL SELECT * FROM trunc_b) UNIO..." +== 040 +-- truncate_limit: 100 +SELECT * FROM trunc_e +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_e" +== 041 +-- truncate_limit: 100 +-- Add data again to test TRUNCATE ... CASCADE +INSERT INTO trunc_c VALUES (1) +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_c VALUES (1)" +== 042 +-- truncate_limit: 100 +INSERT INTO truncate_a VALUES (1) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO truncate_a VALUES (1)" +== 043 +-- truncate_limit: 100 +INSERT INTO trunc_b VALUES (1) +-- +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_b VALUES (1)" +== 044 +-- truncate_limit: 100 +INSERT INTO trunc_d VALUES (1) +-- +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_d VALUES (1)" +== 045 +-- truncate_limit: 100 +INSERT INTO trunc_e VALUES (1,1) +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_e VALUES (1, 1)" +== 046 +-- truncate_limit: 100 +TRUNCATE TABLE trunc_c CASCADE +-- +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_c CASCADE" +== 047 +-- truncate_limit: 100 +-- ok + +SELECT * FROM truncate_a + UNION ALL + SELECT * FROM trunc_c + UNION ALL + SELECT * FROM trunc_b + UNION ALL + SELECT * FROM trunc_d +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=Select +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=Select +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=Select +STMT: SelectStmt +TRUNCATED: "((SELECT * FROM truncate_a UNION ALL SELECT * FROM trunc_c) UNION ALL SELECT * FROM trunc_b) UNIO..." +== 048 +-- truncate_limit: 100 +SELECT * FROM trunc_e +-- +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_e" +== 049 +-- truncate_limit: 100 +DROP TABLE truncate_a,trunc_c,trunc_b,trunc_d,trunc_e CASCADE +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +TABLE: name="trunc_c" schema="" table="trunc_c" ctx=DDL +TABLE: name="trunc_b" schema="" table="trunc_b" ctx=DDL +TABLE: name="trunc_d" schema="" table="trunc_d" ctx=DDL +TABLE: name="trunc_e" schema="" table="trunc_e" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE truncate_a, trunc_c, trunc_b, trunc_d, trunc_e CASCADE" +== 050 +-- truncate_limit: 100 +-- Test TRUNCATE with inheritance + +CREATE TABLE trunc_f (col1 integer primary key) +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_f (col1 int PRIMARY KEY)" +== 051 +-- truncate_limit: 100 +INSERT INTO trunc_f VALUES (1) +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_f VALUES (1)" +== 052 +-- truncate_limit: 100 +INSERT INTO trunc_f VALUES (2) +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_f VALUES (2)" +== 053 +-- truncate_limit: 100 +CREATE TABLE trunc_fa (col2a text) INHERITS (trunc_f) +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_fa (col2a text) INHERITS (trunc_f)" +== 054 +-- truncate_limit: 100 +INSERT INTO trunc_fa VALUES (3, 'three') +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_fa VALUES (3, 'three')" +== 055 +-- truncate_limit: 100 +CREATE TABLE trunc_fb (col2b int) INHERITS (trunc_f) +-- +TABLE: name="trunc_fb" schema="" table="trunc_fb" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_fb (col2b int) INHERITS (trunc_f)" +== 056 +-- truncate_limit: 100 +INSERT INTO trunc_fb VALUES (4, 444) +-- +TABLE: name="trunc_fb" schema="" table="trunc_fb" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_fb VALUES (4, 444)" +== 057 +-- truncate_limit: 100 +CREATE TABLE trunc_faa (col3 text) INHERITS (trunc_fa) +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_faa (col3 text) INHERITS (trunc_fa)" +== 058 +-- truncate_limit: 100 +INSERT INTO trunc_faa VALUES (5, 'five', 'FIVE') +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_faa VALUES (5, 'five', 'FIVE')" +== 059 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 060 +-- truncate_limit: 100 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_f" +== 061 +-- truncate_limit: 100 +TRUNCATE trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_f" +== 062 +-- truncate_limit: 100 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_f" +== 063 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 064 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 065 +-- truncate_limit: 100 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_f" +== 066 +-- truncate_limit: 100 +TRUNCATE ONLY trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE ONLY trunc_f" +== 067 +-- truncate_limit: 100 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_f" +== 068 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 069 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 070 +-- truncate_limit: 100 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_f" +== 071 +-- truncate_limit: 100 +SELECT * FROM trunc_fa +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_fa" +== 072 +-- truncate_limit: 100 +SELECT * FROM trunc_faa +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_faa" +== 073 +-- truncate_limit: 100 +TRUNCATE ONLY trunc_fb, ONLY trunc_fa +-- +TABLE: name="trunc_fb" schema="" table="trunc_fb" ctx=DDL +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE ONLY trunc_fb, ONLY trunc_fa" +== 074 +-- truncate_limit: 100 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_f" +== 075 +-- truncate_limit: 100 +SELECT * FROM trunc_fa +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_fa" +== 076 +-- truncate_limit: 100 +SELECT * FROM trunc_faa +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_faa" +== 077 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 078 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 079 +-- truncate_limit: 100 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_f" +== 080 +-- truncate_limit: 100 +SELECT * FROM trunc_fa +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_fa" +== 081 +-- truncate_limit: 100 +SELECT * FROM trunc_faa +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_faa" +== 082 +-- truncate_limit: 100 +TRUNCATE ONLY trunc_fb, trunc_fa +-- +TABLE: name="trunc_fb" schema="" table="trunc_fb" ctx=DDL +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE ONLY trunc_fb, trunc_fa" +== 083 +-- truncate_limit: 100 +SELECT * FROM trunc_f +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_f" +== 084 +-- truncate_limit: 100 +SELECT * FROM trunc_fa +-- +TABLE: name="trunc_fa" schema="" table="trunc_fa" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_fa" +== 085 +-- truncate_limit: 100 +SELECT * FROM trunc_faa +-- +TABLE: name="trunc_faa" schema="" table="trunc_faa" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_faa" +== 086 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 087 +-- truncate_limit: 100 +DROP TABLE trunc_f CASCADE +-- +TABLE: name="trunc_f" schema="" table="trunc_f" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trunc_f CASCADE" +== 088 +-- truncate_limit: 100 +-- Test ON TRUNCATE triggers + +CREATE TABLE trunc_trigger_test (f1 int, f2 text, f3 text) +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_trigger_test (f1 int, f2 text, f3 text)" +== 089 +-- truncate_limit: 100 +CREATE TABLE trunc_trigger_log (tgop text, tglevel text, tgwhen text, + tgargv text, tgtable name, rowcount bigint) +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_trigger_log (tgop text, tglevel text, tgwhen text, tgargv text, tgtable name, ..." +== 090 +-- truncate_limit: 100 +CREATE FUNCTION trunctrigger() RETURNS trigger as $$ +declare c bigint; +begin + execute 'select count(*) from ' || quote_ident(tg_table_name) into c; + insert into trunc_trigger_log values + (TG_OP, TG_LEVEL, TG_WHEN, TG_ARGV[0], tg_table_name, c); + return null; +end; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="trunctrigger" function="trunctrigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trunctrigger() RETURNS trigger AS $$\ndeclare c bigint;\nbegin\n execute 'select ..." +== 091 +-- truncate_limit: 100 +-- basic before trigger +INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux') +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_trigger_test VALUES (1, 'foo', 'bar'), (2, 'baz', 'quux')" +== 092 +-- truncate_limit: 100 +CREATE TRIGGER t +BEFORE TRUNCATE ON trunc_trigger_test +FOR EACH STATEMENT +EXECUTE PROCEDURE trunctrigger('before trigger truncate') +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER t BEFORE TRUNCATE ON trunc_trigger_test EXECUTE FUNCTION trunctrigger('before trig..." +== 093 +-- truncate_limit: 100 +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS \"Row count in test table\" FROM trunc_trigger_test" +== 094 +-- truncate_limit: 100 +SELECT * FROM trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_trigger_log" +== 095 +-- truncate_limit: 100 +TRUNCATE trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_trigger_test" +== 096 +-- truncate_limit: 100 +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS \"Row count in test table\" FROM trunc_trigger_test" +== 097 +-- truncate_limit: 100 +SELECT * FROM trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_trigger_log" +== 098 +-- truncate_limit: 100 +DROP TRIGGER t ON trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER t ON trunc_trigger_test" +== 099 +-- truncate_limit: 100 +truncate trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_trigger_log" +== 100 +-- truncate_limit: 100 +-- same test with an after trigger +INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux') +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_trigger_test VALUES (1, 'foo', 'bar'), (2, 'baz', 'quux')" +== 101 +-- truncate_limit: 100 +CREATE TRIGGER tt +AFTER TRUNCATE ON trunc_trigger_test +FOR EACH STATEMENT +EXECUTE PROCEDURE trunctrigger('after trigger truncate') +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tt AFTER TRUNCATE ON trunc_trigger_test EXECUTE FUNCTION trunctrigger('after trigg..." +== 102 +-- truncate_limit: 100 +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS \"Row count in test table\" FROM trunc_trigger_test" +== 103 +-- truncate_limit: 100 +SELECT * FROM trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_trigger_log" +== 104 +-- truncate_limit: 100 +TRUNCATE trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_trigger_test" +== 105 +-- truncate_limit: 100 +SELECT count(*) as "Row count in test table" FROM trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS \"Row count in test table\" FROM trunc_trigger_test" +== 106 +-- truncate_limit: 100 +SELECT * FROM trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM trunc_trigger_log" +== 107 +-- truncate_limit: 100 +DROP TABLE trunc_trigger_test +-- +TABLE: name="trunc_trigger_test" schema="" table="trunc_trigger_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trunc_trigger_test" +== 108 +-- truncate_limit: 100 +DROP TABLE trunc_trigger_log +-- +TABLE: name="trunc_trigger_log" schema="" table="trunc_trigger_log" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trunc_trigger_log" +== 109 +-- truncate_limit: 100 +DROP FUNCTION trunctrigger() +-- +FUNCTION: name="trunctrigger" function="trunctrigger" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION trunctrigger()" +== 110 +-- truncate_limit: 100 +-- test TRUNCATE ... RESTART IDENTITY +CREATE SEQUENCE truncate_a_id1 START WITH 33 +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE truncate_a_id1 START 33" +== 111 +-- truncate_limit: 100 +CREATE TABLE truncate_a (id serial, + id1 integer default nextval('truncate_a_id1')) +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncate_a (id serial, id1 int DEFAULT nextval('truncate_a_id1'))" +== 112 +-- truncate_limit: 100 +ALTER SEQUENCE truncate_a_id1 OWNED BY truncate_a.id1 +-- +STMT: AlterSeqStmt +TRUNCATED: "ALTER SEQUENCE truncate_a_id1 OWNED BY truncate_a.id1" +== 113 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 114 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 115 +-- truncate_limit: 100 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_a" +== 116 +-- truncate_limit: 100 +TRUNCATE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a" +== 117 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 118 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 119 +-- truncate_limit: 100 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_a" +== 120 +-- truncate_limit: 100 +TRUNCATE truncate_a RESTART IDENTITY +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a RESTART IDENTITY" +== 121 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 122 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 123 +-- truncate_limit: 100 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_a" +== 124 +-- truncate_limit: 100 +CREATE TABLE truncate_b (id int GENERATED ALWAYS AS IDENTITY (START WITH 44)) +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncate_b (id int GENERATED ALWAYS AS IDENTITY (START 44 ))" +== 125 +-- truncate_limit: 100 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_b DEFAULT VALUES" +== 126 +-- truncate_limit: 100 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_b DEFAULT VALUES" +== 127 +-- truncate_limit: 100 +SELECT * FROM truncate_b +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_b" +== 128 +-- truncate_limit: 100 +TRUNCATE truncate_b +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_b" +== 129 +-- truncate_limit: 100 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_b DEFAULT VALUES" +== 130 +-- truncate_limit: 100 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_b DEFAULT VALUES" +== 131 +-- truncate_limit: 100 +SELECT * FROM truncate_b +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_b" +== 132 +-- truncate_limit: 100 +TRUNCATE truncate_b RESTART IDENTITY +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_b RESTART IDENTITY" +== 133 +-- truncate_limit: 100 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_b DEFAULT VALUES" +== 134 +-- truncate_limit: 100 +INSERT INTO truncate_b DEFAULT VALUES +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_b DEFAULT VALUES" +== 135 +-- truncate_limit: 100 +SELECT * FROM truncate_b +-- +TABLE: name="truncate_b" schema="" table="truncate_b" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_b" +== 136 +-- truncate_limit: 100 +-- check rollback of a RESTART IDENTITY operation +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 137 +-- truncate_limit: 100 +TRUNCATE truncate_a RESTART IDENTITY +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncate_a RESTART IDENTITY" +== 138 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 139 +-- truncate_limit: 100 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_a" +== 140 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 141 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 142 +-- truncate_limit: 100 +INSERT INTO truncate_a DEFAULT VALUES +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO truncate_a DEFAULT VALUES" +== 143 +-- truncate_limit: 100 +SELECT * FROM truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM truncate_a" +== 144 +-- truncate_limit: 100 +DROP TABLE truncate_a +-- +TABLE: name="truncate_a" schema="" table="truncate_a" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE truncate_a" +== 145 +-- truncate_limit: 100 +SELECT nextval('truncate_a_id1') +-- +FUNCTION: name="nextval" function="nextval" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nextval('truncate_a_id1')" +== 146 +-- truncate_limit: 100 +-- fail, seq should have been dropped + +-- partitioned table +CREATE TABLE truncparted (a int, b char) PARTITION BY LIST (a) +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncparted (a int, b char(1)) PARTITION BY LIST (a)" +== 147 +-- truncate_limit: 100 +-- error, can't truncate a partitioned table +TRUNCATE ONLY truncparted +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE ONLY truncparted" +== 148 +-- truncate_limit: 100 +CREATE TABLE truncparted1 PARTITION OF truncparted FOR VALUES IN (1) +-- +TABLE: name="truncparted1" schema="" table="truncparted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncparted1 PARTITION OF truncparted FOR VALUES IN (1)" +== 149 +-- truncate_limit: 100 +INSERT INTO truncparted VALUES (1, 'a') +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO truncparted VALUES (1, 'a')" +== 150 +-- truncate_limit: 100 +-- error, must truncate partitions +TRUNCATE ONLY truncparted +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE ONLY truncparted" +== 151 +-- truncate_limit: 100 +TRUNCATE truncparted +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncparted" +== 152 +-- truncate_limit: 100 +DROP TABLE truncparted +-- +TABLE: name="truncparted" schema="" table="truncparted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE truncparted" +== 153 +-- truncate_limit: 100 +-- foreign key on partitioned table: partition key is referencing column. +-- Make sure truncate did execute on all tables +CREATE FUNCTION tp_ins_data() RETURNS void LANGUAGE plpgsql AS $$ + BEGIN + INSERT INTO truncprim VALUES (1), (100), (150); + INSERT INTO truncpart VALUES (1), (100), (150); + END +$$ +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tp_ins_data() RETURNS void LANGUAGE plpgsql AS $$\n BEGIN\n\tINSERT INTO truncprim ..." +== 154 +-- truncate_limit: 100 +CREATE FUNCTION tp_chk_data(OUT pktb regclass, OUT pkval int, OUT fktb regclass, OUT fkval int) + RETURNS SETOF record LANGUAGE plpgsql AS $$ + BEGIN + RETURN QUERY SELECT + pk.tableoid::regclass, pk.a, fk.tableoid::regclass, fk.a + FROM truncprim pk FULL JOIN truncpart fk USING (a) + ORDER BY 2, 4; + END +$$ +-- +FUNCTION: name="tp_chk_data" function="tp_chk_data" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION tp_chk_data(OUT pktb regclass, OUT pkval int, OUT fktb regclass, OUT fkval int) R..." +== 155 +-- truncate_limit: 100 +CREATE TABLE truncprim (a int PRIMARY KEY) +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncprim (a int PRIMARY KEY)" +== 156 +-- truncate_limit: 100 +CREATE TABLE truncpart (a int REFERENCES truncprim) + PARTITION BY RANGE (a) +-- +TABLE: name="truncpart" schema="" table="truncpart" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncpart (a int REFERENCES truncprim) PARTITION BY RANGE (a)" +== 157 +-- truncate_limit: 100 +CREATE TABLE truncpart_1 PARTITION OF truncpart FOR VALUES FROM (0) TO (100) +-- +TABLE: name="truncpart_1" schema="" table="truncpart_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncpart_1 PARTITION OF truncpart FOR VALUES FROM (0) TO (100)" +== 158 +-- truncate_limit: 100 +CREATE TABLE truncpart_2 PARTITION OF truncpart FOR VALUES FROM (100) TO (200) + PARTITION BY RANGE (a) +-- +TABLE: name="truncpart_2" schema="" table="truncpart_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncpart_2 PARTITION OF truncpart FOR VALUES FROM (100) TO (200) PARTITION BY RANGE..." +== 159 +-- truncate_limit: 100 +CREATE TABLE truncpart_2_1 PARTITION OF truncpart_2 FOR VALUES FROM (100) TO (150) +-- +TABLE: name="truncpart_2_1" schema="" table="truncpart_2_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncpart_2_1 PARTITION OF truncpart_2 FOR VALUES FROM (100) TO (150)" +== 160 +-- truncate_limit: 100 +CREATE TABLE truncpart_2_d PARTITION OF truncpart_2 DEFAULT +-- +TABLE: name="truncpart_2_d" schema="" table="truncpart_2_d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE truncpart_2_d PARTITION OF truncpart_2 DEFAULT" +== 161 +-- truncate_limit: 100 +TRUNCATE TABLE truncprim +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncprim" +== 162 +-- truncate_limit: 100 +-- should fail + +select tp_ins_data() +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tp_ins_data()" +== 163 +-- truncate_limit: 100 +-- should truncate everything +TRUNCATE TABLE truncprim, truncpart +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +TABLE: name="truncpart" schema="" table="truncpart" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncprim, truncpart" +== 164 +-- truncate_limit: 100 +select * from tp_chk_data() +-- +FUNCTION: name="tp_chk_data" function="tp_chk_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tp_chk_data()" +== 165 +-- truncate_limit: 100 +select tp_ins_data() +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tp_ins_data()" +== 166 +-- truncate_limit: 100 +-- should truncate everything +TRUNCATE TABLE truncprim CASCADE +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncprim CASCADE" +== 167 +-- truncate_limit: 100 +SELECT * FROM tp_chk_data() +-- +FUNCTION: name="tp_chk_data" function="tp_chk_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tp_chk_data()" +== 168 +-- truncate_limit: 100 +SELECT tp_ins_data() +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tp_ins_data()" +== 169 +-- truncate_limit: 100 +-- should truncate all partitions +TRUNCATE TABLE truncpart +-- +TABLE: name="truncpart" schema="" table="truncpart" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE truncpart" +== 170 +-- truncate_limit: 100 +SELECT * FROM tp_chk_data() +-- +FUNCTION: name="tp_chk_data" function="tp_chk_data" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tp_chk_data()" +== 171 +-- truncate_limit: 100 +DROP TABLE truncprim, truncpart +-- +TABLE: name="truncprim" schema="" table="truncprim" ctx=DDL +TABLE: name="truncpart" schema="" table="truncpart" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE truncprim, truncpart" +== 172 +-- truncate_limit: 100 +DROP FUNCTION tp_ins_data(), tp_chk_data() +-- +FUNCTION: name="tp_ins_data" function="tp_ins_data" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION tp_ins_data(), tp_chk_data()" +== 173 +-- truncate_limit: 100 +-- test cascade when referencing a partitioned table +CREATE TABLE trunc_a (a INT PRIMARY KEY) PARTITION BY RANGE (a) +-- +TABLE: name="trunc_a" schema="" table="trunc_a" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_a (a int PRIMARY KEY) PARTITION BY RANGE (a)" +== 174 +-- truncate_limit: 100 +CREATE TABLE trunc_a1 PARTITION OF trunc_a FOR VALUES FROM (0) TO (10) +-- +TABLE: name="trunc_a1" schema="" table="trunc_a1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_a1 PARTITION OF trunc_a FOR VALUES FROM (0) TO (10)" +== 175 +-- truncate_limit: 100 +CREATE TABLE trunc_a2 PARTITION OF trunc_a FOR VALUES FROM (10) TO (20) + PARTITION BY RANGE (a) +-- +TABLE: name="trunc_a2" schema="" table="trunc_a2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_a2 PARTITION OF trunc_a FOR VALUES FROM (10) TO (20) PARTITION BY RANGE (a)" +== 176 +-- truncate_limit: 100 +CREATE TABLE trunc_a21 PARTITION OF trunc_a2 FOR VALUES FROM (10) TO (12) +-- +TABLE: name="trunc_a21" schema="" table="trunc_a21" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_a21 PARTITION OF trunc_a2 FOR VALUES FROM (10) TO (12)" +== 177 +-- truncate_limit: 100 +CREATE TABLE trunc_a22 PARTITION OF trunc_a2 FOR VALUES FROM (12) TO (16) +-- +TABLE: name="trunc_a22" schema="" table="trunc_a22" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_a22 PARTITION OF trunc_a2 FOR VALUES FROM (12) TO (16)" +== 178 +-- truncate_limit: 100 +CREATE TABLE trunc_a2d PARTITION OF trunc_a2 DEFAULT +-- +TABLE: name="trunc_a2d" schema="" table="trunc_a2d" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_a2d PARTITION OF trunc_a2 DEFAULT" +== 179 +-- truncate_limit: 100 +CREATE TABLE trunc_a3 PARTITION OF trunc_a FOR VALUES FROM (20) TO (30) +-- +TABLE: name="trunc_a3" schema="" table="trunc_a3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE trunc_a3 PARTITION OF trunc_a FOR VALUES FROM (20) TO (30)" +== 180 +-- truncate_limit: 100 +INSERT INTO trunc_a VALUES (0), (5), (10), (15), (20), (25) +-- +TABLE: name="trunc_a" schema="" table="trunc_a" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO trunc_a VALUES (0), (5), (10), (15), (20), (25)" +== 181 +-- truncate_limit: 100 +-- truncate a partition cascading to a table +CREATE TABLE ref_b ( + b INT PRIMARY KEY, + a INT REFERENCES trunc_a(a) ON DELETE CASCADE +) +-- +TABLE: name="ref_b" schema="" table="ref_b" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref_b (b int PRIMARY KEY, a int REFERENCES trunc_a (a) ON DELETE CASCADE)" +== 182 +-- truncate_limit: 100 +INSERT INTO ref_b VALUES (10, 0), (50, 5), (100, 10), (150, 15) +-- +TABLE: name="ref_b" schema="" table="ref_b" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ref_b VALUES (10, 0), (50, 5), (100, 10), (150, 15)" +== 183 +-- truncate_limit: 100 +TRUNCATE TABLE trunc_a1 CASCADE +-- +TABLE: name="trunc_a1" schema="" table="trunc_a1" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_a1 CASCADE" +== 184 +-- truncate_limit: 100 +SELECT a FROM ref_b +-- +TABLE: name="ref_b" schema="" table="ref_b" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a FROM ref_b" +== 185 +-- truncate_limit: 100 +DROP TABLE ref_b +-- +TABLE: name="ref_b" schema="" table="ref_b" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE ref_b" +== 186 +-- truncate_limit: 100 +-- truncate a partition cascading to a partitioned table +CREATE TABLE ref_c ( + c INT PRIMARY KEY, + a INT REFERENCES trunc_a(a) ON DELETE CASCADE +) PARTITION BY RANGE (c) +-- +TABLE: name="ref_c" schema="" table="ref_c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref_c (c int PRIMARY KEY, a int REFERENCES trunc_a (a) ON DELETE CASCADE) PARTITION ..." +== 187 +-- truncate_limit: 100 +CREATE TABLE ref_c1 PARTITION OF ref_c FOR VALUES FROM (100) TO (200) +-- +TABLE: name="ref_c1" schema="" table="ref_c1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref_c1 PARTITION OF ref_c FOR VALUES FROM (100) TO (200)" +== 188 +-- truncate_limit: 100 +CREATE TABLE ref_c2 PARTITION OF ref_c FOR VALUES FROM (200) TO (300) +-- +TABLE: name="ref_c2" schema="" table="ref_c2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref_c2 PARTITION OF ref_c FOR VALUES FROM (200) TO (300)" +== 189 +-- truncate_limit: 100 +INSERT INTO ref_c VALUES (100, 10), (150, 15), (200, 20), (250, 25) +-- +TABLE: name="ref_c" schema="" table="ref_c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ref_c VALUES (100, 10), (150, 15), (200, 20), (250, 25)" +== 190 +-- truncate_limit: 100 +TRUNCATE TABLE trunc_a21 CASCADE +-- +TABLE: name="trunc_a21" schema="" table="trunc_a21" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE trunc_a21 CASCADE" +== 191 +-- truncate_limit: 100 +SELECT a as "from table ref_c" FROM ref_c +-- +TABLE: name="ref_c" schema="" table="ref_c" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a AS \"from table ref_c\" FROM ref_c" +== 192 +-- truncate_limit: 100 +SELECT a as "from table trunc_a" FROM trunc_a ORDER BY a +-- +TABLE: name="trunc_a" schema="" table="trunc_a" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a AS \"from table trunc_a\" FROM trunc_a ORDER BY a" +== 193 +-- truncate_limit: 100 +DROP TABLE trunc_a, ref_c +-- +TABLE: name="trunc_a" schema="" table="trunc_a" ctx=DDL +TABLE: name="ref_c" schema="" table="ref_c" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE trunc_a, ref_c" diff --git a/parser/testdata/summary_truncate/postgres_regress/tsdicts.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tsdicts.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tsdicts.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tsdicts.test b/parser/testdata/summary_truncate/postgres_regress/tsdicts.test new file mode 100644 index 0000000..bf6e34d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tsdicts.test @@ -0,0 +1,994 @@ +== 001 +-- truncate_limit: 100 +--Test text search dictionaries and configurations + +-- Test ISpell dictionary with ispell affix file +CREATE TEXT SEARCH DICTIONARY ispell ( + Template=ispell, + DictFile=ispell_sample, + AffFile=ispell_sample +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY ispell (template = ispell, dictfile = ispell_sample, afffile = ispe..." +== 002 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'skies')" +== 003 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'bookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'bookings')" +== 004 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'booking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'booking')" +== 005 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'foot') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'foot')" +== 006 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'foots') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'foots')" +== 007 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'rebookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'rebookings')" +== 008 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'rebooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'rebooking')" +== 009 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'rebook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'rebook')" +== 010 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'unbookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'unbookings')" +== 011 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'unbooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'unbooking')" +== 012 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'unbook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'unbook')" +== 013 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'footklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'footklubber')" +== 014 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'footballklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'footballklubber')" +== 015 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'ballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'ballyklubber')" +== 016 +-- truncate_limit: 100 +SELECT ts_lexize('ispell', 'footballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('ispell', 'footballyklubber')" +== 017 +-- truncate_limit: 100 +-- Test ISpell dictionary with hunspell affix file +CREATE TEXT SEARCH DICTIONARY hunspell ( + Template=ispell, + DictFile=ispell_sample, + AffFile=hunspell_sample +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell (template = ispell, dictfile = ispell_sample, afffile = hu..." +== 018 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'skies')" +== 019 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'bookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'bookings')" +== 020 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'booking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'booking')" +== 021 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'foot') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'foot')" +== 022 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'foots') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'foots')" +== 023 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'rebookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'rebookings')" +== 024 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'rebooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'rebooking')" +== 025 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'rebook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'rebook')" +== 026 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'unbookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'unbookings')" +== 027 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'unbooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'unbooking')" +== 028 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'unbook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'unbook')" +== 029 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'footklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'footklubber')" +== 030 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'footballklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'footballklubber')" +== 031 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'ballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'ballyklubber')" +== 032 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell', 'footballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell', 'footballyklubber')" +== 033 +-- truncate_limit: 100 +-- Test ISpell dictionary with hunspell affix file with FLAG long parameter +CREATE TEXT SEARCH DICTIONARY hunspell_long ( + Template=ispell, + DictFile=hunspell_sample_long, + AffFile=hunspell_sample_long +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell_long (template = ispell, dictfile = hunspell_sample_long, ..." +== 034 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'skies')" +== 035 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'bookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'bookings')" +== 036 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'booking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'booking')" +== 037 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'foot') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'foot')" +== 038 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'foots') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'foots')" +== 039 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'rebookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'rebookings')" +== 040 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'rebooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'rebooking')" +== 041 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'rebook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'rebook')" +== 042 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'unbookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'unbookings')" +== 043 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'unbooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'unbooking')" +== 044 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'unbook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'unbook')" +== 045 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'booked') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'booked')" +== 046 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'footklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'footklubber')" +== 047 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'footballklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'footballklubber')" +== 048 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'ballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'ballyklubber')" +== 049 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'ballsklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'ballsklubber')" +== 050 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'footballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'footballyklubber')" +== 051 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_long', 'ex-machina') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_long', 'ex-machina')" +== 052 +-- truncate_limit: 100 +-- Test ISpell dictionary with hunspell affix file with FLAG num parameter +CREATE TEXT SEARCH DICTIONARY hunspell_num ( + Template=ispell, + DictFile=hunspell_sample_num, + AffFile=hunspell_sample_num +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell_num (template = ispell, dictfile = hunspell_sample_num, af..." +== 053 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'skies')" +== 054 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'sk') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'sk')" +== 055 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'bookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'bookings')" +== 056 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'booking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'booking')" +== 057 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'foot') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'foot')" +== 058 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'foots') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'foots')" +== 059 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'rebookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'rebookings')" +== 060 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'rebooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'rebooking')" +== 061 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'rebook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'rebook')" +== 062 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'unbookings') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'unbookings')" +== 063 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'unbooking') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'unbooking')" +== 064 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'unbook') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'unbook')" +== 065 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'booked') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'booked')" +== 066 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'footklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'footklubber')" +== 067 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'footballklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'footballklubber')" +== 068 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'ballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'ballyklubber')" +== 069 +-- truncate_limit: 100 +SELECT ts_lexize('hunspell_num', 'footballyklubber') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('hunspell_num', 'footballyklubber')" +== 070 +-- truncate_limit: 100 +-- Test suitability of affix and dict files +CREATE TEXT SEARCH DICTIONARY hunspell_err ( + Template=ispell, + DictFile=ispell_sample, + AffFile=hunspell_sample_long +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell_err (template = ispell, dictfile = ispell_sample, afffile ..." +== 071 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY hunspell_err ( + Template=ispell, + DictFile=ispell_sample, + AffFile=hunspell_sample_num +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell_err (template = ispell, dictfile = ispell_sample, afffile ..." +== 072 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY hunspell_invalid_1 ( + Template=ispell, + DictFile=hunspell_sample_long, + AffFile=ispell_sample +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell_invalid_1 (template = ispell, dictfile = hunspell_sample_l..." +== 073 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY hunspell_invalid_2 ( + Template=ispell, + DictFile=hunspell_sample_long, + AffFile=hunspell_sample_num +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell_invalid_2 (template = ispell, dictfile = hunspell_sample_l..." +== 074 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY hunspell_invalid_3 ( + Template=ispell, + DictFile=hunspell_sample_num, + AffFile=ispell_sample +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell_invalid_3 (template = ispell, dictfile = hunspell_sample_n..." +== 075 +-- truncate_limit: 100 +CREATE TEXT SEARCH DICTIONARY hunspell_err ( + Template=ispell, + DictFile=hunspell_sample_num, + AffFile=hunspell_sample_long +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY hunspell_err (template = ispell, dictfile = hunspell_sample_num, af..." +== 076 +-- truncate_limit: 100 +-- Synonym dictionary +CREATE TEXT SEARCH DICTIONARY synonym ( + Template=synonym, + Synonyms=synonym_sample +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY synonym (template = synonym, synonyms = synonym_sample)" +== 077 +-- truncate_limit: 100 +SELECT ts_lexize('synonym', 'PoStGrEs') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('synonym', 'PoStGrEs')" +== 078 +-- truncate_limit: 100 +SELECT ts_lexize('synonym', 'Gogle') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('synonym', 'Gogle')" +== 079 +-- truncate_limit: 100 +SELECT ts_lexize('synonym', 'indices') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('synonym', 'indices')" +== 080 +-- truncate_limit: 100 +-- test altering boolean parameters +SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym' +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +FILTER: schema="" table="" column="dictname" +STMT: SelectStmt +TRUNCATED: "SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym'" +== 081 +-- truncate_limit: 100 +ALTER TEXT SEARCH DICTIONARY synonym (CaseSensitive = 1) +-- +STMT: AlterTSDictionaryStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY synonym (casesensitive = 1)" +== 082 +-- truncate_limit: 100 +SELECT ts_lexize('synonym', 'PoStGrEs') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('synonym', 'PoStGrEs')" +== 083 +-- truncate_limit: 100 +SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym' +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +FILTER: schema="" table="" column="dictname" +STMT: SelectStmt +TRUNCATED: "SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym'" +== 084 +-- truncate_limit: 100 +ALTER TEXT SEARCH DICTIONARY synonym (CaseSensitive = 2) +-- +STMT: AlterTSDictionaryStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY synonym (casesensitive = 2)" +== 085 +-- truncate_limit: 100 +-- fail + +ALTER TEXT SEARCH DICTIONARY synonym (CaseSensitive = off) +-- +STMT: AlterTSDictionaryStmt +TRUNCATED: "ALTER TEXT SEARCH DICTIONARY synonym (casesensitive = off)" +== 086 +-- truncate_limit: 100 +SELECT ts_lexize('synonym', 'PoStGrEs') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('synonym', 'PoStGrEs')" +== 087 +-- truncate_limit: 100 +SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym' +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +FILTER: schema="" table="" column="dictname" +STMT: SelectStmt +TRUNCATED: "SELECT dictinitoption FROM pg_ts_dict WHERE dictname = 'synonym'" +== 088 +-- truncate_limit: 100 +-- Create and simple test thesaurus dictionary +-- More tests in configuration checks because ts_lexize() +-- cannot pass more than one word to thesaurus. +CREATE TEXT SEARCH DICTIONARY thesaurus ( + Template=thesaurus, + DictFile=thesaurus_sample, + Dictionary=english_stem +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY thesaurus (template = thesaurus, dictfile = thesaurus_sample, dicti..." +== 089 +-- truncate_limit: 100 +SELECT ts_lexize('thesaurus', 'one') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('thesaurus', 'one')" +== 090 +-- truncate_limit: 100 +-- Test ispell dictionary in configuration +CREATE TEXT SEARCH CONFIGURATION ispell_tst ( + COPY=english +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION ispell_tst (copy = english)" +== 091 +-- truncate_limit: 100 +ALTER TEXT SEARCH CONFIGURATION ispell_tst ALTER MAPPING FOR + word, numword, asciiword, hword, numhword, asciihword, hword_part, hword_numpart, hword_asciipart + WITH ispell, english_stem +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION ispell_tst ALTER MAPPING FOR word, numword, asciiword, hword, num..." +== 092 +-- truncate_limit: 100 +SELECT to_tsvector('ispell_tst', 'Booking the skies after rebookings for footballklubber from a foot') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 093 +-- truncate_limit: 100 +SELECT to_tsquery('ispell_tst', 'footballklubber') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('ispell_tst', 'footballklubber')" +== 094 +-- truncate_limit: 100 +SELECT to_tsquery('ispell_tst', 'footballyklubber:b & rebookings:A & sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('ispell_tst', 'footballyklubber:b & rebookings:A & sky')" +== 095 +-- truncate_limit: 100 +-- Test ispell dictionary with hunspell affix in configuration +CREATE TEXT SEARCH CONFIGURATION hunspell_tst ( + COPY=ispell_tst +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION hunspell_tst (copy = ispell_tst)" +== 096 +-- truncate_limit: 100 +ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING + REPLACE ispell WITH hunspell +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING REPLACE ispell WITH hunspell" +== 097 +-- truncate_limit: 100 +SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 098 +-- truncate_limit: 100 +SELECT to_tsquery('hunspell_tst', 'footballklubber') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('hunspell_tst', 'footballklubber')" +== 099 +-- truncate_limit: 100 +SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky')" +== 100 +-- truncate_limit: 100 +SELECT to_tsquery('hunspell_tst', 'footballyklubber:b <-> sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('hunspell_tst', 'footballyklubber:b <-> sky')" +== 101 +-- truncate_limit: 100 +SELECT phraseto_tsquery('hunspell_tst', 'footballyklubber sky') +-- +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT phraseto_tsquery('hunspell_tst', 'footballyklubber sky')" +== 102 +-- truncate_limit: 100 +-- Test ispell dictionary with hunspell affix with FLAG long in configuration +ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING + REPLACE hunspell WITH hunspell_long +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING REPLACE hunspell WITH hunspell_long" +== 103 +-- truncate_limit: 100 +SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 104 +-- truncate_limit: 100 +SELECT to_tsquery('hunspell_tst', 'footballklubber') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('hunspell_tst', 'footballklubber')" +== 105 +-- truncate_limit: 100 +SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky')" +== 106 +-- truncate_limit: 100 +-- Test ispell dictionary with hunspell affix with FLAG num in configuration +ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING + REPLACE hunspell_long WITH hunspell_num +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION hunspell_tst ALTER MAPPING REPLACE hunspell_long WITH hunspell_num" +== 107 +-- truncate_limit: 100 +SELECT to_tsvector('hunspell_tst', 'Booking the skies after rebookings for footballklubber from a foot') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 108 +-- truncate_limit: 100 +SELECT to_tsquery('hunspell_tst', 'footballklubber') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('hunspell_tst', 'footballklubber')" +== 109 +-- truncate_limit: 100 +SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('hunspell_tst', 'footballyklubber:b & rebookings:A & sky')" +== 110 +-- truncate_limit: 100 +-- Test synonym dictionary in configuration +CREATE TEXT SEARCH CONFIGURATION synonym_tst ( + COPY=english +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION synonym_tst (copy = english)" +== 111 +-- truncate_limit: 100 +ALTER TEXT SEARCH CONFIGURATION synonym_tst ALTER MAPPING FOR + asciiword, hword_asciipart, asciihword + WITH synonym, english_stem +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION synonym_tst ALTER MAPPING FOR asciiword, hword_asciipart, asciihw..." +== 112 +-- truncate_limit: 100 +SELECT to_tsvector('synonym_tst', 'Postgresql is often called as postgres or pgsql and pronounced as postgre') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 113 +-- truncate_limit: 100 +SELECT to_tsvector('synonym_tst', 'Most common mistake is to write Gogle instead of Google') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('synonym_tst', 'Most common mistake is to write Gogle instead of Google')" +== 114 +-- truncate_limit: 100 +SELECT to_tsvector('synonym_tst', 'Indexes or indices - Which is right plural form of index?') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('synonym_tst', 'Indexes or indices - Which is right plural form of index?')" +== 115 +-- truncate_limit: 100 +SELECT to_tsquery('synonym_tst', 'Index & indices') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('synonym_tst', 'Index & indices')" +== 116 +-- truncate_limit: 100 +-- test thesaurus in configuration +-- see thesaurus_sample.ths to understand 'odd' resulting tsvector +CREATE TEXT SEARCH CONFIGURATION thesaurus_tst ( + COPY=synonym_tst +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION thesaurus_tst (copy = synonym_tst)" +== 117 +-- truncate_limit: 100 +ALTER TEXT SEARCH CONFIGURATION thesaurus_tst ALTER MAPPING FOR + asciiword, hword_asciipart, asciihword + WITH synonym, thesaurus, english_stem +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION thesaurus_tst ALTER MAPPING FOR asciiword, hword_asciipart, ascii..." +== 118 +-- truncate_limit: 100 +SELECT to_tsvector('thesaurus_tst', 'one postgres one two one two three one') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('thesaurus_tst', 'one postgres one two one two three one')" +== 119 +-- truncate_limit: 100 +SELECT to_tsvector('thesaurus_tst', 'Supernovae star is very new star and usually called supernovae (abbreviation SN)') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 120 +-- truncate_limit: 100 +SELECT to_tsvector('thesaurus_tst', 'Booking tickets is looking like a booking a tickets') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('thesaurus_tst', 'Booking tickets is looking like a booking a tickets')" +== 121 +-- truncate_limit: 100 +-- invalid: non-lowercase quoted identifiers +CREATE TEXT SEARCH DICTIONARY tsdict_case +( + Template = ispell, + "DictFile" = ispell_sample, + "AffFile" = ispell_sample +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH DICTIONARY tsdict_case (template = ispell, \"DictFile\" = ispell_sample, \"AffFil..." +== 122 +-- truncate_limit: 100 +-- Test grammar for configurations +CREATE TEXT SEARCH CONFIGURATION dummy_tst (COPY=english) +-- +STMT: DefineStmt +TRUNCATED: "CREATE TEXT SEARCH CONFIGURATION dummy_tst (copy = english)" +== 123 +-- truncate_limit: 100 +-- Overridden mapping change with duplicated tokens. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + ALTER MAPPING FOR word, word WITH ispell +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION dummy_tst ALTER MAPPING FOR word, word WITH ispell" +== 124 +-- truncate_limit: 100 +-- Not a token supported by the configuration's parser, fails. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING FOR not_a_token, not_a_token +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION dummy_tst DROP MAPPING FOR not_a_token, not_a_token" +== 125 +-- truncate_limit: 100 +-- Not a token supported by the configuration's parser, fails even +-- with IF EXISTS. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING IF EXISTS FOR not_a_token, not_a_token +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION dummy_tst DROP MAPPING IF EXISTS FOR not_a_token, not_a_token" +== 126 +-- truncate_limit: 100 +-- Token supported by the configuration's parser, succeeds. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING FOR word, word +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION dummy_tst DROP MAPPING FOR word, word" +== 127 +-- truncate_limit: 100 +-- No mapping for token supported by the configuration's parser, fails. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING FOR word +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION dummy_tst DROP MAPPING FOR word" +== 128 +-- truncate_limit: 100 +-- Token supported by the configuration's parser, cannot be found, +-- succeeds with IF EXISTS. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + DROP MAPPING IF EXISTS FOR word, word +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION dummy_tst DROP MAPPING IF EXISTS FOR word, word" +== 129 +-- truncate_limit: 100 +-- Re-add mapping, with duplicated tokens supported by the parser. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + ADD MAPPING FOR word, word WITH ispell +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION dummy_tst ADD MAPPING FOR word, word WITH ispell" +== 130 +-- truncate_limit: 100 +-- Not a token supported by the configuration's parser, fails. +ALTER TEXT SEARCH CONFIGURATION dummy_tst + ADD MAPPING FOR not_a_token WITH ispell +-- +STMT: AlterTSConfigurationStmt +TRUNCATED: "ALTER TEXT SEARCH CONFIGURATION dummy_tst ADD MAPPING FOR not_a_token WITH ispell" +== 131 +-- truncate_limit: 100 +DROP TEXT SEARCH CONFIGURATION dummy_tst +-- +STMT: DropStmt +TRUNCATED: "DROP TEXT SEARCH CONFIGURATION dummy_tst" diff --git a/parser/testdata/summary_truncate/postgres_regress/tsearch.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tsearch.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tsearch.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tsearch.test b/parser/testdata/summary_truncate/postgres_regress/tsearch.test new file mode 100644 index 0000000..579990c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tsearch.test @@ -0,0 +1,3874 @@ +== 001 +-- truncate_limit: 100 +-- directory paths are passed to us in environment variables + +|-- +-- Sanity checks for text search catalogs +|-- +-- NB: we assume the oidjoins test will have caught any dangling links, +-- that is OID or REGPROC fields that are not zero and do not match some +-- row in the linked-to table. However, if we want to enforce that a link +-- field can't be 0, we have to check it here. + +-- Find unexpected zero link entries + +SELECT oid, prsname +FROM pg_ts_parser +WHERE prsnamespace = 0 OR prsstart = 0 OR prstoken = 0 OR prsend = 0 OR + -- prsheadline is optional + prslextype = 0 +-- +TABLE: name="pg_ts_parser" schema="" table="pg_ts_parser" ctx=Select +FILTER: schema="" table="" column="prsnamespace" +FILTER: schema="" table="" column="prsstart" +FILTER: schema="" table="" column="prstoken" +FILTER: schema="" table="" column="prsend" +FILTER: schema="" table="" column="prslextype" +STMT: SelectStmt +TRUNCATED: "SELECT oid, prsname FROM pg_ts_parser WHERE ..." +== 002 +-- truncate_limit: 100 +SELECT oid, dictname +FROM pg_ts_dict +WHERE dictnamespace = 0 OR dictowner = 0 OR dicttemplate = 0 +-- +TABLE: name="pg_ts_dict" schema="" table="pg_ts_dict" ctx=Select +FILTER: schema="" table="" column="dictnamespace" +FILTER: schema="" table="" column="dictowner" +FILTER: schema="" table="" column="dicttemplate" +STMT: SelectStmt +TRUNCATED: "SELECT oid, dictname FROM pg_ts_dict WHERE dictnamespace = 0 OR dictowner = 0 OR dicttemplate = 0" +== 003 +-- truncate_limit: 100 +SELECT oid, tmplname +FROM pg_ts_template +WHERE tmplnamespace = 0 OR tmpllexize = 0 +-- +TABLE: name="pg_ts_template" schema="" table="pg_ts_template" ctx=Select +FILTER: schema="" table="" column="tmplnamespace" +FILTER: schema="" table="" column="tmpllexize" +STMT: SelectStmt +TRUNCATED: "SELECT oid, tmplname FROM pg_ts_template WHERE tmplnamespace = 0 OR tmpllexize = 0" +== 004 +-- truncate_limit: 100 +-- tmplinit is optional + +SELECT oid, cfgname +FROM pg_ts_config +WHERE cfgnamespace = 0 OR cfgowner = 0 OR cfgparser = 0 +-- +TABLE: name="pg_ts_config" schema="" table="pg_ts_config" ctx=Select +FILTER: schema="" table="" column="cfgnamespace" +FILTER: schema="" table="" column="cfgowner" +FILTER: schema="" table="" column="cfgparser" +STMT: SelectStmt +TRUNCATED: "SELECT oid, cfgname FROM pg_ts_config WHERE cfgnamespace = 0 OR cfgowner = 0 OR cfgparser = 0" +== 005 +-- truncate_limit: 100 +SELECT mapcfg, maptokentype, mapseqno +FROM pg_ts_config_map +WHERE mapcfg = 0 OR mapdict = 0 +-- +TABLE: name="pg_ts_config_map" schema="" table="pg_ts_config_map" ctx=Select +FILTER: schema="" table="" column="mapcfg" +FILTER: schema="" table="" column="mapdict" +STMT: SelectStmt +TRUNCATED: "SELECT mapcfg, maptokentype, mapseqno FROM pg_ts_config_map WHERE mapcfg = 0 OR mapdict = 0" +== 006 +-- truncate_limit: 100 +-- Look for pg_ts_config_map entries that aren't one of parser's token types +SELECT * FROM + ( SELECT oid AS cfgid, (ts_token_type(cfgparser)).tokid AS tokid + FROM pg_ts_config ) AS tt +RIGHT JOIN pg_ts_config_map AS m + ON (tt.cfgid=m.mapcfg AND tt.tokid=m.maptokentype) +WHERE + tt.cfgid IS NULL OR tt.tokid IS NULL +-- +TABLE: name="pg_ts_config_map" schema="" table="pg_ts_config_map" ctx=Select +TABLE: name="pg_ts_config" schema="" table="pg_ts_config" ctx=Select +ALIAS: "m"="pg_ts_config_map" +FUNCTION: name="ts_token_type" function="ts_token_type" schema="" ctx=Call +FILTER: schema="" table="tt" column="cfgid" +FILTER: schema="" table="tt" column="tokid" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM pg_ts_config) tt RIGHT JOIN pg_ts_config_map m ON tt.cfgid = m.map..." +== 007 +-- truncate_limit: 100 +-- Load some test data +CREATE TABLE test_tsvector( + t text, + a tsvector +) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_tsvector (t text, a tsvector)" +== 008 +-- truncate_limit: 100 +COPY test_tsvector FROM :'filename' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 25 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 009 +-- truncate_limit: 100 +ANALYZE test_tsvector +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE test_tsvector" +== 010 +-- truncate_limit: 100 +-- test basic text search behavior without indexes, then with + +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 011 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'" +== 012 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'" +== 013 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'" +== 014 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'" +== 015 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'" +== 016 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'" +== 017 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ ANY('{wr,qh}')" +== 018 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'" +== 019 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'" +== 020 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'" +== 021 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'" +== 022 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'" +== 023 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'" +== 024 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'" +== 025 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'" +== 026 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'" +== 027 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'" +== 028 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'" +== 029 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'" +== 030 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'" +== 031 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'" +== 032 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'" +== 033 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'" +== 034 +-- truncate_limit: 100 +create index wowidx on test_tsvector using gist (a) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx ON test_tsvector USING gist (a)" +== 035 +-- truncate_limit: 100 +SET enable_seqscan=OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 036 +-- truncate_limit: 100 +SET enable_indexscan=ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 037 +-- truncate_limit: 100 +SET enable_bitmapscan=OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 038 +-- truncate_limit: 100 +explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 039 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 040 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'" +== 041 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'" +== 042 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'" +== 043 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'" +== 044 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'" +== 045 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'" +== 046 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ ANY('{wr,qh}')" +== 047 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'" +== 048 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'" +== 049 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'" +== 050 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'" +== 051 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'" +== 052 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'" +== 053 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'" +== 054 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'" +== 055 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'" +== 056 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'" +== 057 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'" +== 058 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'" +== 059 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'" +== 060 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'" +== 061 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'" +== 062 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'" +== 063 +-- truncate_limit: 100 +SET enable_indexscan=OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO OFF" +== 064 +-- truncate_limit: 100 +SET enable_bitmapscan=ON +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO ON" +== 065 +-- truncate_limit: 100 +explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 066 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 067 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'" +== 068 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'" +== 069 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'" +== 070 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'" +== 071 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'" +== 072 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'" +== 073 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ ANY('{wr,qh}')" +== 074 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'" +== 075 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'" +== 076 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'" +== 077 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'" +== 078 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'" +== 079 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'" +== 080 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'" +== 081 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'" +== 082 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'" +== 083 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'" +== 084 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'" +== 085 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'" +== 086 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'" +== 087 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'" +== 088 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'" +== 089 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'" +== 090 +-- truncate_limit: 100 +-- Test siglen parameter of GiST tsvector_ops +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(foo=1)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(foo=1))" +== 091 +-- truncate_limit: 100 +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=0)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=0))" +== 092 +-- truncate_limit: 100 +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=2048)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=2048))" +== 093 +-- truncate_limit: 100 +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=100,foo='bar')) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=100, foo='bar'))" +== 094 +-- truncate_limit: 100 +CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=100, siglen = 200)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx1 ON test_tsvector USING gist (a tsvector_ops(siglen=100, siglen=200))" +== 095 +-- truncate_limit: 100 +CREATE INDEX wowidx2 ON test_tsvector USING gist (a tsvector_ops(siglen=1)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx2 ON test_tsvector USING gist (a tsvector_ops(siglen=1))" +== 096 +-- truncate_limit: 100 +DROP INDEX wowidx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX wowidx" +== 097 +-- truncate_limit: 100 +EXPLAIN (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 098 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 099 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'" +== 100 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'" +== 101 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'" +== 102 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'" +== 103 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'" +== 104 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'" +== 105 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ ANY('{wr,qh}')" +== 106 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'" +== 107 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'" +== 108 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'" +== 109 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'" +== 110 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'" +== 111 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'" +== 112 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'" +== 113 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'" +== 114 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'" +== 115 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'" +== 116 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'" +== 117 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'" +== 118 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'" +== 119 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'" +== 120 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'" +== 121 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'" +== 122 +-- truncate_limit: 100 +DROP INDEX wowidx2 +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX wowidx2" +== 123 +-- truncate_limit: 100 +CREATE INDEX wowidx ON test_tsvector USING gist (a tsvector_ops(siglen=484)) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx ON test_tsvector USING gist (a tsvector_ops(siglen=484))" +== 124 +-- truncate_limit: 100 +EXPLAIN (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 125 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 126 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'" +== 127 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'" +== 128 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'" +== 129 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'" +== 130 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'" +== 131 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'" +== 132 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ ANY('{wr,qh}')" +== 133 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'" +== 134 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'" +== 135 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'" +== 136 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'" +== 137 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'" +== 138 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'" +== 139 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'" +== 140 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'" +== 141 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'" +== 142 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'" +== 143 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'" +== 144 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'" +== 145 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'" +== 146 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'" +== 147 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'" +== 148 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'" +== 149 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 150 +-- truncate_limit: 100 +RESET enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 151 +-- truncate_limit: 100 +RESET enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 152 +-- truncate_limit: 100 +DROP INDEX wowidx +-- +STMT: DropStmt +TRUNCATED: "DROP INDEX wowidx" +== 153 +-- truncate_limit: 100 +CREATE INDEX wowidx ON test_tsvector USING gin (a) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX wowidx ON test_tsvector USING gin (a)" +== 154 +-- truncate_limit: 100 +SET enable_seqscan=OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 155 +-- truncate_limit: 100 +-- GIN only supports bitmapscan, so no need to test plain indexscan + +explain (costs off) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 156 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'" +== 157 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh'" +== 158 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt'" +== 159 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt'" +== 160 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)'" +== 161 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'" +== 162 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*'" +== 163 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ any ('{wr,qh}') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ ANY('{wr,qh}')" +== 164 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'no_such_lexeme'" +== 165 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!no_such_lexeme'" +== 166 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'pl <-> yh'" +== 167 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'yh <-> pl'" +== 168 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'qe <2> qt'" +== 169 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> yh'" +== 170 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!pl <-> !yh'" +== 171 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!yh <-> pl'" +== 172 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!qe <2> qt'" +== 173 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(pl <-> yh)'" +== 174 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(yh <-> pl)'" +== 175 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!(qe <2> qt)'" +== 176 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:A'" +== 177 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wd:D'" +== 178 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:A'" +== 179 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!wd:D'" +== 180 +-- truncate_limit: 100 +-- Test optimization of non-empty GIN_SEARCH_MODE_ALL queries +EXPLAIN (COSTS OFF) +SELECT count(*) FROM test_tsvector WHERE a @@ '!qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ '!qh'" +== 181 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ '!qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ '!qh'" +== 182 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr' AND a @@ '!qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM test_tsvector WHERE a @@ 'wr' AND a @@ '!qh'" +== 183 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ 'wr' AND a @@ '!qh' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ 'wr' AND a @@ '!qh'" +== 184 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 185 +-- truncate_limit: 100 +INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH')" +== 186 +-- truncate_limit: 100 +SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10 +-- +FUNCTION: name="ts_stat" function="ts_stat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10" +== 187 +-- truncate_limit: 100 +SELECT * FROM ts_stat('SELECT a FROM test_tsvector', 'AB') ORDER BY ndoc DESC, nentry DESC, word +-- +FUNCTION: name="ts_stat" function="ts_stat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_stat('SELECT a FROM test_tsvector', 'AB') ORDER BY ndoc DESC, nentry DESC, word" +== 188 +-- truncate_limit: 100 +--dictionaries and to_tsvector + +SELECT ts_lexize('english_stem', 'skies') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('english_stem', 'skies')" +== 189 +-- truncate_limit: 100 +SELECT ts_lexize('english_stem', 'identity') +-- +FUNCTION: name="ts_lexize" function="ts_lexize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_lexize('english_stem', 'identity')" +== 190 +-- truncate_limit: 100 +SELECT * FROM ts_token_type('default') +-- +FUNCTION: name="ts_token_type" function="ts_token_type" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_token_type('default')" +== 191 +-- truncate_limit: 100 +SELECT * FROM ts_parse('default', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf qwer jf sdjk ewr1> ewri2 +/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 + wow < jqw <> qwerty') +-- +FUNCTION: name="ts_parse" function="ts_parse" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_parse('default', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&d..." +== 192 +-- truncate_limit: 100 +SELECT to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf qwer jf sdjk ewr1> ewri2 +/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 + wow < jqw <> qwerty') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 193 +-- truncate_limit: 100 +SELECT length(to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf qwer jf sdjk ewr1> ewri2 +/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234 + wow < jqw <> qwerty')) +-- +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 194 +-- truncate_limit: 100 +-- ts_debug + +SELECT * from ts_debug('english', 'abc&nm1;def©ghiõjkl') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_debug('english', 'abc&nm1;def©ghiõjkl') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_debug('english', 'http://www.harewoodsolutions.co.uk/press.aspx')" +== 196 +-- truncate_limit: 100 +SELECT * from ts_debug('english', 'http://aew.wer0c.ewr/id?ad=qwe&dw') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_debug('english', 'http://aew.wer0c.ewr/id?ad=qwe&dw')" +== 197 +-- truncate_limit: 100 +SELECT * from ts_debug('english', 'http://5aew.werc.ewr:8100/?') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_debug('english', 'http://5aew.werc.ewr:8100/?')" +== 198 +-- truncate_limit: 100 +SELECT * from ts_debug('english', '5aew.werc.ewr:8100/?xx') +-- +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ts_debug('english', '5aew.werc.ewr:8100/?xx')" +== 199 +-- truncate_limit: 100 +SELECT token, alias, + dictionaries, dictionaries is null as dnull, array_dims(dictionaries) as ddims, + lexemes, lexemes is null as lnull, array_dims(lexemes) as ldims +from ts_debug('english', 'a title') +-- +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="array_dims" function="array_dims" schema="" ctx=Call +FUNCTION: name="ts_debug" function="ts_debug" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM ts_debug('english', 'a title')" +== 200 +-- truncate_limit: 100 +-- to_tsquery + +SELECT to_tsquery('english', 'qwe & sKies ') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 'qwe & sKies ')" +== 201 +-- truncate_limit: 100 +SELECT to_tsquery('simple', 'qwe & sKies ') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('simple', 'qwe & sKies ')" +== 202 +-- truncate_limit: 100 +SELECT to_tsquery('english', '''the wether'':dc & '' sKies '':BC ') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '''the wether'':dc & '' sKies '':BC ')" +== 203 +-- truncate_limit: 100 +SELECT to_tsquery('english', 'asd&(and|fghj)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 'asd&(and|fghj)')" +== 204 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(asd&and)|fghj') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(asd&and)|fghj')" +== 205 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(asd&!and)|fghj') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(asd&!and)|fghj')" +== 206 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(the|and&(i&1))&fghj') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(the|and&(i&1))&fghj')" +== 207 +-- truncate_limit: 100 +SELECT plainto_tsquery('english', 'the and z 1))& fghj') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT plainto_tsquery('english', 'the and z 1))& fghj')" +== 208 +-- truncate_limit: 100 +SELECT plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd')" +== 209 +-- truncate_limit: 100 +SELECT plainto_tsquery('english', 'foo bar') || plainto_tsquery('english', 'asd fg') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT plainto_tsquery('english', 'foo bar') || plainto_tsquery('english', 'asd fg')" +== 210 +-- truncate_limit: 100 +SELECT plainto_tsquery('english', 'foo bar') || !!plainto_tsquery('english', 'asd fg') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT plainto_tsquery('english', 'foo bar') || (!! plainto_tsquery('english', 'asd fg'))" +== 211 +-- truncate_limit: 100 +SELECT plainto_tsquery('english', 'foo bar') && 'asd | fg' +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT plainto_tsquery('english', 'foo bar') && 'asd | fg'" +== 212 +-- truncate_limit: 100 +-- Check stop word deletion, a and s are stop-words +SELECT to_tsquery('english', '!(a & !b) & c') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '!(a & !b) & c')" +== 213 +-- truncate_limit: 100 +SELECT to_tsquery('english', '!(a & !b)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '!(a & !b)')" +== 214 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(1 <-> 2) <-> a') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(1 <-> 2) <-> a')" +== 215 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(1 <-> a) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(1 <-> a) <-> 2')" +== 216 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(a <-> 1) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(a <-> 1) <-> 2')" +== 217 +-- truncate_limit: 100 +SELECT to_tsquery('english', 'a <-> (1 <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 'a <-> (1 <-> 2)')" +== 218 +-- truncate_limit: 100 +SELECT to_tsquery('english', '1 <-> (a <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '1 <-> (a <-> 2)')" +== 219 +-- truncate_limit: 100 +SELECT to_tsquery('english', '1 <-> (2 <-> a)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '1 <-> (2 <-> a)')" +== 220 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(1 <-> 2) <3> a') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(1 <-> 2) <3> a')" +== 221 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(1 <-> a) <3> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(1 <-> a) <3> 2')" +== 222 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(a <-> 1) <3> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(a <-> 1) <3> 2')" +== 223 +-- truncate_limit: 100 +SELECT to_tsquery('english', 'a <3> (1 <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 'a <3> (1 <-> 2)')" +== 224 +-- truncate_limit: 100 +SELECT to_tsquery('english', '1 <3> (a <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '1 <3> (a <-> 2)')" +== 225 +-- truncate_limit: 100 +SELECT to_tsquery('english', '1 <3> (2 <-> a)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '1 <3> (2 <-> a)')" +== 226 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(1 <3> 2) <-> a') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(1 <3> 2) <-> a')" +== 227 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(1 <3> a) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(1 <3> a) <-> 2')" +== 228 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(a <3> 1) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(a <3> 1) <-> 2')" +== 229 +-- truncate_limit: 100 +SELECT to_tsquery('english', 'a <-> (1 <3> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 'a <-> (1 <3> 2)')" +== 230 +-- truncate_limit: 100 +SELECT to_tsquery('english', '1 <-> (a <3> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '1 <-> (a <3> 2)')" +== 231 +-- truncate_limit: 100 +SELECT to_tsquery('english', '1 <-> (2 <3> a)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '1 <-> (2 <3> a)')" +== 232 +-- truncate_limit: 100 +SELECT to_tsquery('english', '((a <-> 1) <-> 2) <-> s') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '((a <-> 1) <-> 2) <-> s')" +== 233 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(2 <-> (a <-> 1)) <-> s') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(2 <-> (a <-> 1)) <-> s')" +== 234 +-- truncate_limit: 100 +SELECT to_tsquery('english', '((1 <-> a) <-> 2) <-> s') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '((1 <-> a) <-> 2) <-> s')" +== 235 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(2 <-> (1 <-> a)) <-> s') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(2 <-> (1 <-> a)) <-> s')" +== 236 +-- truncate_limit: 100 +SELECT to_tsquery('english', 's <-> ((a <-> 1) <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 's <-> ((a <-> 1) <-> 2)')" +== 237 +-- truncate_limit: 100 +SELECT to_tsquery('english', 's <-> (2 <-> (a <-> 1))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 's <-> (2 <-> (a <-> 1))')" +== 238 +-- truncate_limit: 100 +SELECT to_tsquery('english', 's <-> ((1 <-> a) <-> 2)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 's <-> ((1 <-> a) <-> 2)')" +== 239 +-- truncate_limit: 100 +SELECT to_tsquery('english', 's <-> (2 <-> (1 <-> a))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 's <-> (2 <-> (1 <-> a))')" +== 240 +-- truncate_limit: 100 +SELECT to_tsquery('english', '((a <-> 1) <-> s) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '((a <-> 1) <-> s) <-> 2')" +== 241 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(s <-> (a <-> 1)) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(s <-> (a <-> 1)) <-> 2')" +== 242 +-- truncate_limit: 100 +SELECT to_tsquery('english', '((1 <-> a) <-> s) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '((1 <-> a) <-> s) <-> 2')" +== 243 +-- truncate_limit: 100 +SELECT to_tsquery('english', '(s <-> (1 <-> a)) <-> 2') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '(s <-> (1 <-> a)) <-> 2')" +== 244 +-- truncate_limit: 100 +SELECT to_tsquery('english', '2 <-> ((a <-> 1) <-> s)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '2 <-> ((a <-> 1) <-> s)')" +== 245 +-- truncate_limit: 100 +SELECT to_tsquery('english', '2 <-> (s <-> (a <-> 1))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '2 <-> (s <-> (a <-> 1))')" +== 246 +-- truncate_limit: 100 +SELECT to_tsquery('english', '2 <-> ((1 <-> a) <-> s)') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '2 <-> ((1 <-> a) <-> s)')" +== 247 +-- truncate_limit: 100 +SELECT to_tsquery('english', '2 <-> (s <-> (1 <-> a))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '2 <-> (s <-> (1 <-> a))')" +== 248 +-- truncate_limit: 100 +SELECT to_tsquery('english', 'foo <-> (a <-> (the <-> bar))') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 'foo <-> (a <-> (the <-> bar))')" +== 249 +-- truncate_limit: 100 +SELECT to_tsquery('english', '((foo <-> a) <-> the) <-> bar') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', '((foo <-> a) <-> the) <-> bar')" +== 250 +-- truncate_limit: 100 +SELECT to_tsquery('english', 'foo <-> a <-> the <-> bar') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('english', 'foo <-> a <-> the <-> bar')" +== 251 +-- truncate_limit: 100 +SELECT phraseto_tsquery('english', 'PostgreSQL can be extended by the user in many ways') +-- +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT phraseto_tsquery('english', 'PostgreSQL can be extended by the user in many ways')" +== 252 +-- truncate_limit: 100 +SELECT ts_rank_cd(to_tsvector('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +'), to_tsquery('english', 'paint&water')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 253 +-- truncate_limit: 100 +SELECT ts_rank_cd(to_tsvector('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +'), to_tsquery('english', 'breath&motion&water')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 254 +-- truncate_limit: 100 +SELECT ts_rank_cd(to_tsvector('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +'), to_tsquery('english', 'ocean')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 255 +-- truncate_limit: 100 +SELECT ts_rank_cd(to_tsvector('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +'), to_tsquery('english', 'painted <-> Ship')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 256 +-- truncate_limit: 100 +SELECT ts_rank_cd(strip(to_tsvector('both stripped')), + to_tsquery('both & stripped')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(strip(to_tsvector('both stripped')), to_tsquery('both & stripped'))" +== 257 +-- truncate_limit: 100 +SELECT ts_rank_cd(to_tsvector('unstripped') || strip(to_tsvector('stripped')), + to_tsquery('unstripped & stripped')) +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 258 +-- truncate_limit: 100 +--headline tests +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'paint&water')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 259 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'breath&motion&water')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 260 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'ocean')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 261 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'day & drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 262 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'day | drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 263 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'day | !drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 264 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'painted <-> Ship & drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 265 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'painted <-> Ship | drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 266 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'painted <-> Ship | !drink')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 267 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', phraseto_tsquery('english', 'painted Ocean')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 268 +-- truncate_limit: 100 +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', phraseto_tsquery('english', 'idle as a painted Ship')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 269 +-- truncate_limit: 100 +SELECT ts_headline('english', +'Lorem ipsum urna. Nullam nullam ullamcorper urna.', +to_tsquery('english','Lorem') && phraseto_tsquery('english','ullamcorper urna'), +'MaxWords=100, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 270 +-- truncate_limit: 100 +SELECT ts_headline('english', +'Lorem ipsum urna. Nullam nullam ullamcorper urna.', +phraseto_tsquery('english','ullamcorper urna'), +'MaxWords=100, MinWords=5') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 271 +-- truncate_limit: 100 +SELECT ts_headline('english', ' + + + +Sea view wow foo bar qq +YES   +ff-bg + + +', +to_tsquery('english', 'sea&foo'), 'HighlightAll=true') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 272 +-- truncate_limit: 100 +SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 <-> 3', 'MaxWords=2, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 <-> 3', 'MaxWords=2, MinWords=1')" +== 273 +-- truncate_limit: 100 +SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 & 3', 'MaxWords=4, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 & 3', 'MaxWords=4, MinWords=1')" +== 274 +-- truncate_limit: 100 +SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 <-> 3', 'MaxWords=4, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('simple', '1 2 3 1 3'::text, '1 <-> 3', 'MaxWords=4, MinWords=1')" +== 275 +-- truncate_limit: 100 +--Check if headline fragments work +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'ocean'), 'MaxFragments=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 276 +-- truncate_limit: 100 +--Check if more than one fragments are displayed +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 277 +-- truncate_limit: 100 +--Fragments when there all query words are not in the document +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'ocean & seahorse'), 'MaxFragments=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 278 +-- truncate_limit: 100 +--FragmentDelimiter option +SELECT ts_headline('english', ' +Day after day, day after day, + We stuck, nor breath nor motion, +As idle as a painted Ship + Upon a painted Ocean. +Water, water, every where + And all the boards did shrink; +Water, water, every where, + Nor any drop to drink. +S. T. Coleridge (1772-1834) +', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2,FragmentDelimiter=***') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 279 +-- truncate_limit: 100 +--Fragments with phrase search +SELECT ts_headline('english', +'Lorem ipsum urna. Nullam nullam ullamcorper urna.', +to_tsquery('english','Lorem') && phraseto_tsquery('english','ullamcorper urna'), +'MaxFragments=100, MaxWords=100, MinWords=1') +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 280 +-- truncate_limit: 100 +-- Edge cases with empty query +SELECT ts_headline('english', +'', to_tsquery('english', '')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('english', '', to_tsquery('english', ''))" +== 281 +-- truncate_limit: 100 +SELECT ts_headline('english', +'foo bar', to_tsquery('english', '')) +-- +FUNCTION: name="ts_headline" function="ts_headline" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_headline('english', 'foo bar', to_tsquery('english', ''))" +== 282 +-- truncate_limit: 100 +--Rewrite sub system + +CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE test_tsquery (txtkeyword text, txtsample text)" +== 283 +-- truncate_limit: 100 +'New York' new <-> york | big <-> apple | nyc +Moscow moskva | moscow +'Sanct Peter' Peterburg | peter | 'Sanct Peterburg' +foo & bar & qq foo & (bar | qq) & city +1 & (2 <-> 3) 2 <-> 4 +5 <-> 6 5 <-> 7 + +ALTER TABLE test_tsquery ADD COLUMN keyword tsquery +-- +ERROR: syntax error at or near "'New York'" +CURSORPOS: 1 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 284 +-- truncate_limit: 100 +UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DML +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword)" +== 285 +-- truncate_limit: 100 +ALTER TABLE test_tsquery ADD COLUMN sample tsquery +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE test_tsquery ADD COLUMN sample tsquery" +== 286 +-- truncate_limit: 100 +UPDATE test_tsquery SET sample = to_tsquery('english', txtsample::text) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DML +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE test_tsquery SET sample = to_tsquery('english', txtsample::text)" +== 287 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword < 'new <-> york'" +== 288 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword <= 'new <-> york'" +== 289 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword = 'new <-> york'" +== 290 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword >= 'new <-> york'" +== 291 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword > 'new <-> york'" +== 292 +-- truncate_limit: 100 +CREATE UNIQUE INDEX bt_tsq ON test_tsquery (keyword) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX bt_tsq ON test_tsquery USING btree (keyword)" +== 293 +-- truncate_limit: 100 +SET enable_seqscan=OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 294 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword < 'new <-> york'" +== 295 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword <= 'new <-> york'" +== 296 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword = 'new <-> york'" +== 297 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword >= 'new <-> york'" +== 298 +-- truncate_limit: 100 +SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new <-> york' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsquery WHERE keyword > 'new <-> york'" +== 299 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 300 +-- truncate_limit: 100 +SELECT ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big & apple | nyc | new & york & city') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 301 +-- truncate_limit: 100 +SELECT ts_rewrite(ts_rewrite('new & !york ', 'york', '!jersey'), + 'jersey', 'mexico') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite(ts_rewrite('new & !york ', 'york', '!jersey'), 'jersey', 'mexico')" +== 302 +-- truncate_limit: 100 +SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text)" +== 303 +-- truncate_limit: 100 +SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text)" +== 304 +-- truncate_limit: 100 +SELECT ts_rewrite('bar & qq & foo & (new <-> york)', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 305 +-- truncate_limit: 100 +SELECT ts_rewrite( 'moscow', 'SELECT keyword, sample FROM test_tsquery') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery')" +== 306 +-- truncate_limit: 100 +SELECT ts_rewrite( 'moscow & hotel', 'SELECT keyword, sample FROM test_tsquery') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery')" +== 307 +-- truncate_limit: 100 +SELECT ts_rewrite( 'bar & qq & foo & (new <-> york)', 'SELECT keyword, sample FROM test_tsquery') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('bar & qq & foo & (new <-> york)', 'SELECT keyword, sample FROM test_tsquery')" +== 308 +-- truncate_limit: 100 +SELECT ts_rewrite('1 & (2 <-> 3)', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('1 & (2 <-> 3)', 'SELECT keyword, sample FROM test_tsquery'::text)" +== 309 +-- truncate_limit: 100 +SELECT ts_rewrite('1 & (2 <2> 3)', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('1 & (2 <2> 3)', 'SELECT keyword, sample FROM test_tsquery'::text)" +== 310 +-- truncate_limit: 100 +SELECT ts_rewrite('5 <-> (1 & (2 <-> 3))', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('5 <-> (1 & (2 <-> 3))', 'SELECT keyword, sample FROM test_tsquery'::text)" +== 311 +-- truncate_limit: 100 +SELECT ts_rewrite('5 <-> (6 | 8)', 'SELECT keyword, sample FROM test_tsquery'::text ) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite('5 <-> (6 | 8)', 'SELECT keyword, sample FROM test_tsquery'::text)" +== 312 +-- truncate_limit: 100 +-- Check empty substitution +SELECT ts_rewrite(to_tsquery('5 & (6 | 5)'), to_tsquery('5'), to_tsquery('')) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite(to_tsquery('5 & (6 | 5)'), to_tsquery('5'), to_tsquery(''))" +== 313 +-- truncate_limit: 100 +SELECT ts_rewrite(to_tsquery('!5'), to_tsquery('5'), to_tsquery('')) +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite(to_tsquery('!5'), to_tsquery('5'), to_tsquery(''))" +== 314 +-- truncate_limit: 100 +SELECT keyword FROM test_tsquery WHERE keyword @> 'new' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT keyword FROM test_tsquery WHERE keyword @> 'new'" +== 315 +-- truncate_limit: 100 +SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow'" +== 316 +-- truncate_limit: 100 +SELECT keyword FROM test_tsquery WHERE keyword <@ 'new' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT keyword FROM test_tsquery WHERE keyword <@ 'new'" +== 317 +-- truncate_limit: 100 +SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow'" +== 318 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'moscow') query" +== 319 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'moscow & hotel') query" +== 320 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') query" +== 321 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'moscow') query" +== 322 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'moscow & hotel') query" +== 323 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') query" +== 324 +-- truncate_limit: 100 +CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops) +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops)" +== 325 +-- truncate_limit: 100 +SET enable_seqscan=OFF +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 326 +-- truncate_limit: 100 +SELECT keyword FROM test_tsquery WHERE keyword @> 'new' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT keyword FROM test_tsquery WHERE keyword @> 'new'" +== 327 +-- truncate_limit: 100 +SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow'" +== 328 +-- truncate_limit: 100 +SELECT keyword FROM test_tsquery WHERE keyword <@ 'new' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT keyword FROM test_tsquery WHERE keyword <@ 'new'" +== 329 +-- truncate_limit: 100 +SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow' +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FILTER: schema="" table="" column="keyword" +STMT: SelectStmt +TRUNCATED: "SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow'" +== 330 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'moscow') query" +== 331 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'moscow & hotel') query" +== 332 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') query" +== 333 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'moscow') query" +== 334 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'moscow & hotel') query" +== 335 +-- truncate_limit: 100 +SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') AS query +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM to_tsquery('english', 'bar & qq & foo & (new <-> york)') query" +== 336 +-- truncate_limit: 100 +SELECT ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz') +-- +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="tsquery_phrase" function="tsquery_phrase" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz')" +== 337 +-- truncate_limit: 100 +SELECT to_tsvector('foo bar') @@ + ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="tsquery_phrase" function="tsquery_phrase" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('foo bar') @@ ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz')" +== 338 +-- truncate_limit: 100 +SELECT to_tsvector('bar baz') @@ + ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="ts_rewrite" function="ts_rewrite" schema="" ctx=Call +FUNCTION: name="tsquery_phrase" function="tsquery_phrase" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('bar baz') @@ ts_rewrite(tsquery_phrase('foo', 'foo'), 'foo', 'bar | baz')" +== 339 +-- truncate_limit: 100 +RESET enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 340 +-- truncate_limit: 100 +--test GUC +SET default_text_search_config=simple +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_text_search_config TO simple" +== 341 +-- truncate_limit: 100 +SELECT to_tsvector('SKIES My booKs') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('SKIES My booKs')" +== 342 +-- truncate_limit: 100 +SELECT plainto_tsquery('SKIES My booKs') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT plainto_tsquery('SKIES My booKs')" +== 343 +-- truncate_limit: 100 +SELECT to_tsquery('SKIES & My | booKs') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('SKIES & My | booKs')" +== 344 +-- truncate_limit: 100 +SET default_text_search_config=english +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_text_search_config TO english" +== 345 +-- truncate_limit: 100 +SELECT to_tsvector('SKIES My booKs') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('SKIES My booKs')" +== 346 +-- truncate_limit: 100 +SELECT plainto_tsquery('SKIES My booKs') +-- +FUNCTION: name="plainto_tsquery" function="plainto_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT plainto_tsquery('SKIES My booKs')" +== 347 +-- truncate_limit: 100 +SELECT to_tsquery('SKIES & My | booKs') +-- +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsquery('SKIES & My | booKs')" +== 348 +-- truncate_limit: 100 +--trigger +CREATE TRIGGER tsvectorupdate +BEFORE UPDATE OR INSERT ON test_tsvector +FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(a, 'pg_catalog.english', t) +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON test_tsvector FOR EACH ROW EXECUTE FUNCT..." +== 349 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty')" +== 350 +-- truncate_limit: 100 +INSERT INTO test_tsvector (t) VALUES ('345 qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_tsvector (t) VALUES ('345 qwerty')" +== 351 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty')" +== 352 +-- truncate_limit: 100 +UPDATE test_tsvector SET t = null WHERE t = '345 qwerty' +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE test_tsvector SET t = NULL WHERE t = '345 qwerty'" +== 353 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty')" +== 354 +-- truncate_limit: 100 +INSERT INTO test_tsvector (t) VALUES ('345 qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_tsvector (t) VALUES ('345 qwerty')" +== 355 +-- truncate_limit: 100 +SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty') +-- +TABLE: name="test_tsvector" schema="" table="test_tsvector" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty')" +== 356 +-- truncate_limit: 100 +-- Test inlining of immutable constant functions + +-- to_tsquery(text) is not immutable, so it won't be inlined +explain (costs off) +select * from test_tsquery, to_tsquery('new') q where txtsample @@ q +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="txtsample" +FILTER: schema="" table="" column="q" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM test_tsquery, to_tsquery('new') q WHERE txtsample @@ q" +== 357 +-- truncate_limit: 100 +-- to_tsquery(regconfig, text) is an immutable function. +-- That allows us to get rid of using function scan and join at all. +explain (costs off) +select * from test_tsquery, to_tsquery('english', 'new') q where txtsample @@ q +-- +TABLE: name="test_tsquery" schema="" table="test_tsquery" ctx=Select +FUNCTION: name="to_tsquery" function="to_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="txtsample" +FILTER: schema="" table="" column="q" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM test_tsquery, to_tsquery('english', 'new') q WHERE txtsample @@ q" +== 358 +-- truncate_limit: 100 +-- test finding items in GIN's pending list +create temp table pendtest (ts tsvector) +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE pendtest (ts tsvector)" +== 359 +-- truncate_limit: 100 +create index pendtest_idx on pendtest using gin(ts) +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX pendtest_idx ON pendtest USING gin (ts)" +== 360 +-- truncate_limit: 100 +insert into pendtest values (to_tsvector('Lore ipsam')) +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=DML +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pendtest VALUES (to_tsvector('Lore ipsam'))" +== 361 +-- truncate_limit: 100 +insert into pendtest values (to_tsvector('Lore ipsum')) +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=DML +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pendtest VALUES (to_tsvector('Lore ipsum'))" +== 362 +-- truncate_limit: 100 +select * from pendtest where 'ipsu:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pendtest WHERE 'ipsu:*'::tsquery @@ ts" +== 363 +-- truncate_limit: 100 +select * from pendtest where 'ipsa:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pendtest WHERE 'ipsa:*'::tsquery @@ ts" +== 364 +-- truncate_limit: 100 +select * from pendtest where 'ips:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pendtest WHERE 'ips:*'::tsquery @@ ts" +== 365 +-- truncate_limit: 100 +select * from pendtest where 'ipt:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pendtest WHERE 'ipt:*'::tsquery @@ ts" +== 366 +-- truncate_limit: 100 +select * from pendtest where 'ipi:*'::tsquery @@ ts +-- +TABLE: name="pendtest" schema="" table="pendtest" ctx=Select +FILTER: schema="" table="" column="ts" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pendtest WHERE 'ipi:*'::tsquery @@ ts" +== 367 +-- truncate_limit: 100 +--check OP_PHRASE on index +create temp table phrase_index_test(fts tsvector) +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE phrase_index_test (fts tsvector)" +== 368 +-- truncate_limit: 100 +insert into phrase_index_test values ('A fat cat has just eaten a rat.') +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO phrase_index_test VALUES ('A fat cat has just eaten a rat.')" +== 369 +-- truncate_limit: 100 +insert into phrase_index_test values (to_tsvector('english', 'A fat cat has just eaten a rat.')) +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=DML +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO phrase_index_test VALUES (to_tsvector('english', 'A fat cat has just eaten a rat.'))" +== 370 +-- truncate_limit: 100 +create index phrase_index_test_idx on phrase_index_test using gin(fts) +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX phrase_index_test_idx ON phrase_index_test USING gin (fts)" +== 371 +-- truncate_limit: 100 +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 372 +-- truncate_limit: 100 +select * from phrase_index_test where fts @@ phraseto_tsquery('english', 'fat cat') +-- +TABLE: name="phrase_index_test" schema="" table="phrase_index_test" ctx=Select +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +FUNCTION: name="phraseto_tsquery" function="phraseto_tsquery" schema="" ctx=Call +FILTER: schema="" table="" column="fts" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM phrase_index_test WHERE fts @@ phraseto_tsquery('english', 'fat cat')" +== 373 +-- truncate_limit: 100 +set enable_seqscan = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 374 +-- truncate_limit: 100 +-- test websearch_to_tsquery function +select websearch_to_tsquery('simple', 'I have a fat:*ABCD cat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'I have a fat:*ABCD cat')" +== 375 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'orange:**AABBCCDD') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'orange:**AABBCCDD')" +== 376 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat:A!cat:B|rat:C<') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat:A!cat:B|rat:C<')" +== 377 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat:A : cat:B') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat:A : cat:B')" +== 378 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat*rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat*rat')" +== 379 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat-rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat-rat')" +== 380 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat_rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat_rat')" +== 381 +-- truncate_limit: 100 +-- weights are completely ignored +select websearch_to_tsquery('simple', 'abc : def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc : def')" +== 382 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'abc:def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc:def')" +== 383 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'a:::b') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'a:::b')" +== 384 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'abc:d') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc:d')" +== 385 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', ':') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', ':')" +== 386 +-- truncate_limit: 100 +-- these operators are ignored +select websearch_to_tsquery('simple', 'abc & def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc & def')" +== 387 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'abc | def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc | def')" +== 388 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'abc <-> def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc <-> def')" +== 389 +-- truncate_limit: 100 +-- parens are ignored, too +select websearch_to_tsquery('simple', 'abc (pg or class)') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc (pg or class)')" +== 390 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', '(foo bar) or (ding dong)') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', '(foo bar) or (ding dong)')" +== 391 +-- truncate_limit: 100 +-- NOT is ignored in quotes +select websearch_to_tsquery('english', 'My brand new smartphone') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'My brand new smartphone')" +== 392 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'My brand "new smartphone"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'My brand \"new smartphone\"')" +== 393 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'My brand "new -smartphone"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'My brand \"new -smartphone\"')" +== 394 +-- truncate_limit: 100 +-- test OR operator +select websearch_to_tsquery('simple', 'cat or rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'cat or rat')" +== 395 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'cat OR rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'cat OR rat')" +== 396 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'cat "OR" rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'cat \"OR\" rat')" +== 397 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'cat OR') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'cat OR')" +== 398 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'OR rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'OR rat')" +== 399 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', '"fat cat OR rat"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', '\"fat cat OR rat\"')" +== 400 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat (cat OR rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat (cat OR rat')" +== 401 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'or OR or') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'or OR or')" +== 402 +-- truncate_limit: 100 +-- OR is an operator here ... +select websearch_to_tsquery('simple', '"fat cat"or"fat rat"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', '\"fat cat\"or\"fat rat\"')" +== 403 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat or(rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat or(rat')" +== 404 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat or)rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat or)rat')" +== 405 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat or&rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat or&rat')" +== 406 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat or|rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat or|rat')" +== 407 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat or!rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat or!rat')" +== 408 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat orrat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat or>rat')" +== 410 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'fat or ') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'fat or ')" +== 411 +-- truncate_limit: 100 +-- ... but not here +select websearch_to_tsquery('simple', 'abc orange') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc orange')" +== 412 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'abc OR1234') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc OR1234')" +== 413 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'abc or-abc') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc or-abc')" +== 414 +-- truncate_limit: 100 +select websearch_to_tsquery('simple', 'abc OR_abc') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('simple', 'abc OR_abc')" +== 415 +-- truncate_limit: 100 +-- test quotes +select websearch_to_tsquery('english', '"pg_class pg') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"pg_class pg')" +== 416 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'pg_class pg"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'pg_class pg\"')" +== 417 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '"pg_class pg"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"pg_class pg\"')" +== 418 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '"pg_class : pg"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"pg_class : pg\"')" +== 419 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'abc "pg_class pg"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'abc \"pg_class pg\"')" +== 420 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '"pg_class pg" def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"pg_class pg\" def')" +== 421 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'abc "pg pg_class pg" def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'abc \"pg pg_class pg\" def')" +== 422 +-- truncate_limit: 100 +select websearch_to_tsquery('english', ' or "pg pg_class pg" or ') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', ' or \"pg pg_class pg\" or ')" +== 423 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '""pg pg_class pg""') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"\"pg pg_class pg\"\"')" +== 424 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'abc """"" def') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'abc \"\"\"\"\" def')" +== 425 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'cat -"fat rat"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'cat -\"fat rat\"')" +== 426 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'cat -"fat rat" cheese') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'cat -\"fat rat\" cheese')" +== 427 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'abc "def -"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'abc \"def -\"')" +== 428 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'abc "def :"') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'abc \"def :\"')" +== 429 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '"A fat cat" has just eaten a -rat.') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"A fat cat\" has just eaten a -rat.')" +== 430 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '"A fat cat" has just eaten OR !rat.') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"A fat cat\" has just eaten OR !rat.')" +== 431 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '"A fat cat" has just (+eaten OR -rat)') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"A fat cat\" has just (+eaten OR -rat)')" +== 432 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'this is ----fine') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'this is ----fine')" +== 433 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '(()) )))) this ||| is && -fine, "dear friend" OR good') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '(()) )))) this ||| is && -fine, \"dear friend\" OR good')" +== 434 +-- truncate_limit: 100 +select websearch_to_tsquery('english', 'an old <-> cat " is fine &&& too') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', 'an old <-> cat \" is fine &&& too')" +== 435 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '"A the" OR just on') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"A the\" OR just on')" +== 436 +-- truncate_limit: 100 +select websearch_to_tsquery('english', '"a fat cat" ate a rat') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('english', '\"a fat cat\" ate a rat')" +== 437 +-- truncate_limit: 100 +select to_tsvector('english', 'A fat cat ate a rat') @@ + websearch_to_tsquery('english', '"a fat cat" ate a rat') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 438 +-- truncate_limit: 100 +select to_tsvector('english', 'A fat grey cat ate a rat') @@ + websearch_to_tsquery('english', '"a fat cat" ate a rat') +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 439 +-- truncate_limit: 100 +-- cases handled by gettoken_tsvector() +select websearch_to_tsquery('''') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('''')" +== 440 +-- truncate_limit: 100 +select websearch_to_tsquery('''abc''''def''') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery('''abc''''def''')" +== 441 +-- truncate_limit: 100 +select websearch_to_tsquery('\abc') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery(E'\\\\abc')" +== 442 +-- truncate_limit: 100 +select websearch_to_tsquery('\') +-- +FUNCTION: name="websearch_to_tsquery" function="websearch_to_tsquery" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT websearch_to_tsquery(E'\\\\')" diff --git a/parser/testdata/summary_truncate/postgres_regress/tsrf.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tsrf.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tsrf.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tsrf.test b/parser/testdata/summary_truncate/postgres_regress/tsrf.test new file mode 100644 index 0000000..00447dd --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tsrf.test @@ -0,0 +1,695 @@ +== 001 +-- truncate_limit: 100 +|-- +-- tsrf - targetlist set returning function tests +|-- + +-- simple srf +SELECT generate_series(1, 3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, 3)" +== 002 +-- truncate_limit: 100 +-- parallel iteration +SELECT generate_series(1, 3), generate_series(3,5) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, 3), generate_series(3, 5)" +== 003 +-- truncate_limit: 100 +-- parallel iteration, different number of rows +SELECT generate_series(1, 2), generate_series(1,4) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, 2), generate_series(1, 4)" +== 004 +-- truncate_limit: 100 +-- srf, with SRF argument +SELECT generate_series(1, generate_series(1, 3)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, generate_series(1, 3))" +== 005 +-- truncate_limit: 100 +-- but we've traditionally rejected the same in FROM +SELECT * FROM generate_series(1, generate_series(1, 3)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM generate_series(1, generate_series(1, 3))" +== 006 +-- truncate_limit: 100 +-- srf, with two SRF arguments +SELECT generate_series(generate_series(1,3), generate_series(2, 4)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(generate_series(1, 3), generate_series(2, 4))" +== 007 +-- truncate_limit: 100 +-- check proper nesting of SRFs in different expressions +explain (verbose, costs off) +SELECT generate_series(1, generate_series(1, 3)), generate_series(2, 4) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT generate_series(1, generate_series(1, 3)), generate_series(2, 4)" +== 008 +-- truncate_limit: 100 +SELECT generate_series(1, generate_series(1, 3)), generate_series(2, 4) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, generate_series(1, 3)), generate_series(2, 4)" +== 009 +-- truncate_limit: 100 +CREATE TABLE few(id int, dataa text, datab text) +-- +TABLE: name="few" schema="" table="few" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE few (id int, dataa text, datab text)" +== 010 +-- truncate_limit: 100 +INSERT INTO few VALUES(1, 'a', 'foo'),(2, 'a', 'bar'),(3, 'b', 'bar') +-- +TABLE: name="few" schema="" table="few" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO few VALUES (1, 'a', 'foo'), (2, 'a', 'bar'), (3, 'b', 'bar')" +== 011 +-- truncate_limit: 100 +-- SRF with a provably-dummy relation +explain (verbose, costs off) +SELECT unnest(ARRAY[1, 2]) FROM few WHERE false +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT unnest(ARRAY[1, 2]) FROM few WHERE false" +== 012 +-- truncate_limit: 100 +SELECT unnest(ARRAY[1, 2]) FROM few WHERE false +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest(ARRAY[1, 2]) FROM few WHERE false" +== 013 +-- truncate_limit: 100 +-- SRF shouldn't prevent upper query from recognizing lower as dummy +explain (verbose, costs off) +SELECT * FROM few f1, + (SELECT unnest(ARRAY[1,2]) FROM few f2 WHERE false OFFSET 0) ss +-- +TABLE: name="few" schema="" table="few" ctx=Select +TABLE: name="few" schema="" table="few" ctx=Select +ALIAS: "f1"="few" +ALIAS: "f2"="few" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM few f1, (SELECT unnest(ARRAY[1, 2]) FROM few f2 WHERE ..." +== 014 +-- truncate_limit: 100 +SELECT * FROM few f1, + (SELECT unnest(ARRAY[1,2]) FROM few f2 WHERE false OFFSET 0) ss +-- +TABLE: name="few" schema="" table="few" ctx=Select +TABLE: name="few" schema="" table="few" ctx=Select +ALIAS: "f1"="few" +ALIAS: "f2"="few" +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM few f1, (SELECT unnest(ARRAY[1, 2]) FROM few f2 WHERE false OFFSET 0) ss" +== 015 +-- truncate_limit: 100 +-- SRF output order of sorting is maintained, if SRF is not referenced +SELECT few.id, generate_series(1,3) g FROM few ORDER BY id DESC +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT few.id, generate_series(1, 3) AS g FROM few ORDER BY id DESC" +== 016 +-- truncate_limit: 100 +-- but SRFs can be referenced in sort +SELECT few.id, generate_series(1,3) g FROM few ORDER BY id, g DESC +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT few.id, generate_series(1, 3) AS g FROM few ORDER BY id, g DESC" +== 017 +-- truncate_limit: 100 +SELECT few.id, generate_series(1,3) g FROM few ORDER BY id, generate_series(1,3) DESC +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT few.id, generate_series(1, 3) AS g FROM few ORDER BY id, generate_series(1, 3) DESC" +== 018 +-- truncate_limit: 100 +-- it's weird to have ORDER BYs that increase the number of results +SELECT few.id FROM few ORDER BY id, generate_series(1,3) DESC +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT few.id FROM few ORDER BY id, generate_series(1, 3) DESC" +== 019 +-- truncate_limit: 100 +-- SRFs are computed after aggregation +SET enable_hashagg TO 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO 0" +== 020 +-- truncate_limit: 100 +-- stable output order +SELECT few.dataa, count(*), min(id), max(id), unnest('{1,1,3}'::int[]) FROM few WHERE few.id = 1 GROUP BY few.dataa +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="few" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few WHERE few.id = 1 GROUP BY few.dataa" +== 021 +-- truncate_limit: 100 +-- unless referenced in GROUP BY clause +SELECT few.dataa, count(*), min(id), max(id), unnest('{1,1,3}'::int[]) FROM few WHERE few.id = 1 GROUP BY few.dataa, unnest('{1,1,3}'::int[]) +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="few" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few WHERE few.id = 1 GROUP BY few.dataa, unnest('{1,1,3}'::int[])" +== 022 +-- truncate_limit: 100 +SELECT few.dataa, count(*), min(id), max(id), unnest('{1,1,3}'::int[]) FROM few WHERE few.id = 1 GROUP BY few.dataa, 5 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="few" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few WHERE few.id = 1 GROUP BY few.dataa, 5" +== 023 +-- truncate_limit: 100 +RESET enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 024 +-- truncate_limit: 100 +-- check HAVING works when GROUP BY does [not] reference SRF output +SELECT dataa, generate_series(1,1), count(*) FROM few GROUP BY 1 HAVING count(*) > 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dataa, generate_series(1, 1), count(*) FROM few GROUP BY 1 HAVING count(*) > 1" +== 025 +-- truncate_limit: 100 +SELECT dataa, generate_series(1,1), count(*) FROM few GROUP BY 1, 2 HAVING count(*) > 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dataa, generate_series(1, 1), count(*) FROM few GROUP BY 1, 2 HAVING count(*) > 1" +== 026 +-- truncate_limit: 100 +-- it's weird to have GROUP BYs that increase the number of results +SELECT few.dataa, count(*) FROM few WHERE dataa = 'a' GROUP BY few.dataa ORDER BY 2 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="dataa" +STMT: SelectStmt +TRUNCATED: "SELECT few.dataa, count(*) FROM few WHERE dataa = 'a' GROUP BY few.dataa ORDER BY 2" +== 027 +-- truncate_limit: 100 +SELECT few.dataa, count(*) FROM few WHERE dataa = 'a' GROUP BY few.dataa, unnest('{1,1,3}'::int[]) ORDER BY 2 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +FILTER: schema="" table="" column="dataa" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few WHERE dataa = 'a' GROUP BY few.dataa, unnest('{1,1,3}'::int[]) ORDER BY 2" +== 028 +-- truncate_limit: 100 +-- SRFs are not allowed if they'd need to be conditionally executed +SELECT q1, case when q1 > 0 then generate_series(1,3) else 0 end FROM int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT q1, CASE WHEN q1 > 0 THEN generate_series(1, 3) ELSE 0 END FROM int8_tbl" +== 029 +-- truncate_limit: 100 +SELECT q1, coalesce(generate_series(1,3), 0) FROM int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT q1, COALESCE(generate_series(1, 3), 0) FROM int8_tbl" +== 030 +-- truncate_limit: 100 +-- SRFs are not allowed in aggregate arguments +SELECT min(generate_series(1, 3)) FROM few +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(generate_series(1, 3)) FROM few" +== 031 +-- truncate_limit: 100 +-- ... unless they're within a sub-select +SELECT sum((3 = ANY(SELECT generate_series(1,4)))::int) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(3 = ANY (SELECT generate_series(1, 4))::int)" +== 032 +-- truncate_limit: 100 +SELECT sum((3 = ANY(SELECT lag(x) over(order by x) + FROM generate_series(1,4) x))::int) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT sum(3 = ANY (SELECT lag(x) OVER (ORDER BY x) FROM generate_series(1, 4) x)::int)" +== 033 +-- truncate_limit: 100 +-- SRFs are not allowed in window function arguments, either +SELECT min(generate_series(1, 3)) OVER() FROM few +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(generate_series(1, 3)) OVER () FROM few" +== 034 +-- truncate_limit: 100 +-- SRFs are normally computed after window functions +SELECT id,lag(id) OVER(), count(*) OVER(), generate_series(1,3) FROM few +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT id, lag(id) OVER (), count(*) OVER (), generate_series(1, 3) FROM few" +== 035 +-- truncate_limit: 100 +-- unless referencing SRFs +SELECT SUM(count(*)) OVER(PARTITION BY generate_series(1,3) ORDER BY generate_series(1,3)), generate_series(1,3) g FROM few GROUP BY g +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few GROUP BY g" +== 036 +-- truncate_limit: 100 +-- sorting + grouping +SELECT few.dataa, count(*), min(id), max(id), generate_series(1,3) FROM few GROUP BY few.dataa ORDER BY 5, 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few GROUP BY few.dataa ORDER BY 5, 1" +== 037 +-- truncate_limit: 100 +-- grouping sets are a bit special, they produce NULLs in columns not actually NULL +set enable_hashagg = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 038 +-- truncate_limit: 100 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab) +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT dataa, datab AS b, generate_series(1, 2) AS g, count(*) FROM few GROUP BY CUBE (dataa, datab)" +== 039 +-- truncate_limit: 100 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab) ORDER BY dataa +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few GROUP BY CUBE (dataa, datab) ORDER BY dataa" +== 040 +-- truncate_limit: 100 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab) ORDER BY g +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few GROUP BY CUBE (dataa, datab) ORDER BY g" +== 041 +-- truncate_limit: 100 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab, g) +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few GROUP BY CUBE (dataa, datab, g)" +== 042 +-- truncate_limit: 100 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab, g) ORDER BY dataa +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few GROUP BY CUBE (dataa, datab, g) ORDER BY dataa" +== 043 +-- truncate_limit: 100 +SELECT dataa, datab b, generate_series(1,2) g, count(*) FROM few GROUP BY CUBE(dataa, datab, g) ORDER BY g +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM few GROUP BY CUBE (dataa, datab, g) ORDER BY g" +== 044 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 045 +-- truncate_limit: 100 +-- case with degenerate ORDER BY +explain (verbose, costs off) +select 'foo' as f, generate_series(1,2) as g from few order by 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT 'foo' AS f, generate_series(1, 2) AS g FROM few ORDER BY 1" +== 046 +-- truncate_limit: 100 +select 'foo' as f, generate_series(1,2) as g from few order by 1 +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'foo' AS f, generate_series(1, 2) AS g FROM few ORDER BY 1" +== 047 +-- truncate_limit: 100 +-- data modification +CREATE TABLE fewmore AS SELECT generate_series(1,3) AS data +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE fewmore AS SELECT generate_series(1, 3) AS data" +== 048 +-- truncate_limit: 100 +INSERT INTO fewmore VALUES(generate_series(4,5)) +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fewmore VALUES (generate_series(4, 5))" +== 049 +-- truncate_limit: 100 +SELECT * FROM fewmore +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM fewmore" +== 050 +-- truncate_limit: 100 +-- SRFs are not allowed in UPDATE (they once were, but it was nonsense) +UPDATE fewmore SET data = generate_series(4,9) +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE fewmore SET data = generate_series(4, 9)" +== 051 +-- truncate_limit: 100 +-- SRFs are not allowed in RETURNING +INSERT INTO fewmore VALUES(1) RETURNING generate_series(1,3) +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO fewmore VALUES (1) RETURNING generate_series(1, 3)" +== 052 +-- truncate_limit: 100 +-- nor standalone VALUES (but surely this is a bug?) +VALUES(1, generate_series(1,2)) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "VALUES (1, generate_series(1, 2))" +== 053 +-- truncate_limit: 100 +-- We allow tSRFs that are not at top level +SELECT int4mul(generate_series(1,2), 10) +-- +FUNCTION: name="int4mul" function="int4mul" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT int4mul(generate_series(1, 2), 10)" +== 054 +-- truncate_limit: 100 +SELECT generate_series(1,3) IS DISTINCT FROM 2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, 3) IS DISTINCT FROM 2" +== 055 +-- truncate_limit: 100 +-- but SRFs in function RTEs must be at top level (annoying restriction) +SELECT * FROM int4mul(generate_series(1,2), 10) +-- +FUNCTION: name="int4mul" function="int4mul" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int4mul(generate_series(1, 2), 10)" +== 056 +-- truncate_limit: 100 +-- DISTINCT ON is evaluated before tSRF evaluation if SRF is not +-- referenced either in ORDER BY or in the DISTINCT ON list. The ORDER +-- BY reference can be implicitly generated, if there's no other ORDER BY. + +-- implicit reference (via implicit ORDER) to all columns +SELECT DISTINCT ON (a) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (a) a, b, generate_series(1, 3) AS g FROM (VALUES (...)) t(a, b)" +== 057 +-- truncate_limit: 100 +-- unreferenced in DISTINCT ON or ORDER BY +SELECT DISTINCT ON (a) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +ORDER BY a, b DESC +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (a) ... AS ... FROM (VALUES (...)) t(a, b) ORDER BY a, b DESC" +== 058 +-- truncate_limit: 100 +-- referenced in ORDER BY +SELECT DISTINCT ON (a) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +ORDER BY a, b DESC, g DESC +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (a) ... AS ... FROM (VALUES (...)) t(a, b) ORDER BY a, b DESC, g DESC" +== 059 +-- truncate_limit: 100 +-- referenced in ORDER BY and DISTINCT ON +SELECT DISTINCT ON (a, b, g) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +ORDER BY a, b DESC, g DESC +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (a, b, g) ... AS ... FROM (VALUES (...)) t(a, b) ORDER BY a, b DESC, g DESC" +== 060 +-- truncate_limit: 100 +-- only SRF mentioned in DISTINCT ON +SELECT DISTINCT ON (g) a, b, generate_series(1,3) g +FROM (VALUES (3, 2), (3,1), (1,1), (1,4), (5,3), (5,1)) AS t(a, b) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT ON (g) a, b, generate_series(1, 3) AS g FROM (VALUES (...)) t(a, b)" +== 061 +-- truncate_limit: 100 +-- LIMIT / OFFSET is evaluated after SRF evaluation +SELECT a, generate_series(1,2) FROM (VALUES(1),(2),(3)) r(a) LIMIT 2 OFFSET 2 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, generate_series(1, 2) FROM (VALUES (1), (2), (3)) r(a) LIMIT 2 OFFSET 2" +== 062 +-- truncate_limit: 100 +-- SRFs are not allowed in LIMIT. +SELECT 1 LIMIT generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 1 LIMIT generate_series(1, 3)" +== 063 +-- truncate_limit: 100 +-- tSRF in correlated subquery, referencing table outside +SELECT (SELECT generate_series(1,3) LIMIT 1 OFFSET few.id) FROM few +-- +TABLE: name="few" schema="" table="few" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT generate_series(1, 3) LIMIT 1 OFFSET few.id) FROM few" +== 064 +-- truncate_limit: 100 +-- tSRF in correlated subquery, referencing SRF outside +SELECT (SELECT generate_series(1,3) LIMIT 1 OFFSET g.i) FROM generate_series(0,3) g(i) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT (SELECT generate_series(1, 3) LIMIT 1 OFFSET g.i) FROM generate_series(0, 3) g(i)" +== 065 +-- truncate_limit: 100 +-- Operators can return sets too +CREATE OPERATOR |@| (PROCEDURE = unnest, RIGHTARG = ANYARRAY) +-- +STMT: DefineStmt +TRUNCATED: "CREATE OPERATOR |@| (procedure = unnest, rightarg = anyarray)" +== 066 +-- truncate_limit: 100 +SELECT |@|ARRAY[1,2,3] +-- +STMT: SelectStmt +TRUNCATED: "SELECT |@| ARRAY[1, 2, 3]" +== 067 +-- truncate_limit: 100 +-- Some fun cases involving duplicate SRF calls +explain (verbose, costs off) +select generate_series(1,3) as x, generate_series(1,3) + 1 as xp1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT generate_series(1, 3) AS x, generate_series(1, 3) + 1 AS xp1" +== 068 +-- truncate_limit: 100 +select generate_series(1,3) as x, generate_series(1,3) + 1 as xp1 +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, 3) AS x, generate_series(1, 3) + 1 AS xp1" +== 069 +-- truncate_limit: 100 +explain (verbose, costs off) +select generate_series(1,3)+1 order by generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT generate_series(1, 3) + 1 ORDER BY generate_series(1, 3)" +== 070 +-- truncate_limit: 100 +select generate_series(1,3)+1 order by generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, 3) + 1 ORDER BY generate_series(1, 3)" +== 071 +-- truncate_limit: 100 +-- Check that SRFs of same nesting level run in lockstep +explain (verbose, costs off) +select generate_series(1,3) as x, generate_series(3,6) + 1 as y +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT generate_series(1, 3) AS x, generate_series(3, 6) + 1 AS y" +== 072 +-- truncate_limit: 100 +select generate_series(1,3) as x, generate_series(3,6) + 1 as y +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, 3) AS x, generate_series(3, 6) + 1 AS y" +== 073 +-- truncate_limit: 100 +-- Clean up +DROP TABLE few +-- +TABLE: name="few" schema="" table="few" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE few" +== 074 +-- truncate_limit: 100 +DROP TABLE fewmore +-- +TABLE: name="fewmore" schema="" table="fewmore" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE fewmore" diff --git a/parser/testdata/summary_truncate/postgres_regress/tstypes.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tstypes.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tstypes.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tstypes.test b/parser/testdata/summary_truncate/postgres_regress/tstypes.test new file mode 100644 index 0000000..bf66b1f --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tstypes.test @@ -0,0 +1,1586 @@ +== 001 +-- truncate_limit: 100 +-- deal with numeric instability of ts_rank +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO 0" +== 002 +-- truncate_limit: 100 +--Base tsvector test + +SELECT '1'::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::tsvector" +== 003 +-- truncate_limit: 100 +SELECT '1 '::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 '::tsvector" +== 004 +-- truncate_limit: 100 +SELECT ' 1'::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' 1'::tsvector" +== 005 +-- truncate_limit: 100 +SELECT ' 1 '::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' 1 '::tsvector" +== 006 +-- truncate_limit: 100 +SELECT '1 2'::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 2'::tsvector" +== 007 +-- truncate_limit: 100 +SELECT '''1 2'''::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT '''1 2'''::tsvector" +== 008 +-- truncate_limit: 100 +SELECT E'''1 \\''2'''::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'''1 \\\\''2'''::tsvector" +== 009 +-- truncate_limit: 100 +SELECT E'''1 \\''2''3'::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'''1 \\\\''2''3'::tsvector" +== 010 +-- truncate_limit: 100 +SELECT E'''1 \\''2'' 3'::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'''1 \\\\''2'' 3'::tsvector" +== 011 +-- truncate_limit: 100 +SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'''1 \\\\''2'' '' 3'' 4 '::tsvector" +== 012 +-- truncate_limit: 100 +SELECT $$'\\as' ab\c ab\\c AB\\\c ab\\\\c$$::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'''\\\\\\\\as'' ab\\\\c ab\\\\\\\\c AB\\\\\\\\\\\\c ab\\\\\\\\\\\\\\\\c'::tsvector" +== 013 +-- truncate_limit: 100 +SELECT tsvectorin(tsvectorout($$'\\as' ab\c ab\\c AB\\\c ab\\\\c$$::tsvector)) +-- +FUNCTION: name="tsvectorin" function="tsvectorin" schema="" ctx=Call +FUNCTION: name="tsvectorout" function="tsvectorout" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tsvectorin(tsvectorout(E'''\\\\\\\\as'' ab\\\\c ab\\\\\\\\c AB\\\\\\\\\\\\c ab\\\\\\\\\\\\\\\\c'::tsvector))" +== 014 +-- truncate_limit: 100 +SELECT '''w'':4A,3B,2C,1D,5 a:8' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '''w'':4A,3B,2C,1D,5 a:8'" +== 015 +-- truncate_limit: 100 +SELECT 'a:3A b:2a'::tsvector || 'ba:1234 a:1B' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:3A b:2a'::tsvector || 'ba:1234 a:1B'" +== 016 +-- truncate_limit: 100 +SELECT $$'' '1' '2'$$::tsvector +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''''' ''1'' ''2'''::tsvector" +== 017 +-- truncate_limit: 100 +-- error, empty lexeme is not allowed + +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('foo', 'tsvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('foo', 'tsvector')" +== 018 +-- truncate_limit: 100 +SELECT pg_input_is_valid($$''$$, 'tsvector') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('''''', 'tsvector')" +== 019 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info($$''$$, 'tsvector') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('''''', 'tsvector')" +== 020 +-- truncate_limit: 100 +--Base tsquery test +SELECT '1'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::tsquery" +== 021 +-- truncate_limit: 100 +SELECT '1 '::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1 '::tsquery" +== 022 +-- truncate_limit: 100 +SELECT ' 1'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' 1'::tsquery" +== 023 +-- truncate_limit: 100 +SELECT ' 1 '::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' 1 '::tsquery" +== 024 +-- truncate_limit: 100 +SELECT '''1 2'''::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '''1 2'''::tsquery" +== 025 +-- truncate_limit: 100 +SELECT E'''1 \\''2'''::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'''1 \\\\''2'''::tsquery" +== 026 +-- truncate_limit: 100 +SELECT '!1'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!1'::tsquery" +== 027 +-- truncate_limit: 100 +SELECT '1|2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1|2'::tsquery" +== 028 +-- truncate_limit: 100 +SELECT '1|!2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1|!2'::tsquery" +== 029 +-- truncate_limit: 100 +SELECT '!1|2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!1|2'::tsquery" +== 030 +-- truncate_limit: 100 +SELECT '!1|!2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!1|!2'::tsquery" +== 031 +-- truncate_limit: 100 +SELECT '!(!1|!2)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!(!1|!2)'::tsquery" +== 032 +-- truncate_limit: 100 +SELECT '!(!1|2)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!(!1|2)'::tsquery" +== 033 +-- truncate_limit: 100 +SELECT '!(1|!2)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!(1|!2)'::tsquery" +== 034 +-- truncate_limit: 100 +SELECT '!(1|2)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!(1|2)'::tsquery" +== 035 +-- truncate_limit: 100 +SELECT '1&2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1&2'::tsquery" +== 036 +-- truncate_limit: 100 +SELECT '!1&2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!1&2'::tsquery" +== 037 +-- truncate_limit: 100 +SELECT '1&!2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1&!2'::tsquery" +== 038 +-- truncate_limit: 100 +SELECT '!1&!2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!1&!2'::tsquery" +== 039 +-- truncate_limit: 100 +SELECT '(1&2)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1&2)'::tsquery" +== 040 +-- truncate_limit: 100 +SELECT '1&(2)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1&(2)'::tsquery" +== 041 +-- truncate_limit: 100 +SELECT '!(1)&2'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!(1)&2'::tsquery" +== 042 +-- truncate_limit: 100 +SELECT '!(1&2)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!(1&2)'::tsquery" +== 043 +-- truncate_limit: 100 +SELECT '1|2&3'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1|2&3'::tsquery" +== 044 +-- truncate_limit: 100 +SELECT '1|(2&3)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1|(2&3)'::tsquery" +== 045 +-- truncate_limit: 100 +SELECT '(1|2)&3'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(1|2)&3'::tsquery" +== 046 +-- truncate_limit: 100 +SELECT '1|2&!3'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1|2&!3'::tsquery" +== 047 +-- truncate_limit: 100 +SELECT '1|!2&3'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1|!2&3'::tsquery" +== 048 +-- truncate_limit: 100 +SELECT '!1|2&3'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!1|2&3'::tsquery" +== 049 +-- truncate_limit: 100 +SELECT '!1|(2&3)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!1|(2&3)'::tsquery" +== 050 +-- truncate_limit: 100 +SELECT '!(1|2)&3'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!(1|2)&3'::tsquery" +== 051 +-- truncate_limit: 100 +SELECT '(!1|2)&3'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '(!1|2)&3'::tsquery" +== 052 +-- truncate_limit: 100 +SELECT '1|(2|(4|(5|6)))'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1|(2|(4|(5|6)))'::tsquery" +== 053 +-- truncate_limit: 100 +SELECT '1|2|4|5|6'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1|2|4|5|6'::tsquery" +== 054 +-- truncate_limit: 100 +SELECT '1&(2&(4&(5&6)))'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1&(2&(4&(5&6)))'::tsquery" +== 055 +-- truncate_limit: 100 +SELECT '1&2&4&5&6'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1&2&4&5&6'::tsquery" +== 056 +-- truncate_limit: 100 +SELECT '1&(2&(4&(5|6)))'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1&(2&(4&(5|6)))'::tsquery" +== 057 +-- truncate_limit: 100 +SELECT '1&(2&(4&(5|!6)))'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1&(2&(4&(5|!6)))'::tsquery" +== 058 +-- truncate_limit: 100 +SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'1&(''2''&('' 4''&(\\\\|5 | ''6 \\\\'' !|&'')))'::tsquery" +== 059 +-- truncate_limit: 100 +SELECT $$'\\as'$$::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT E'''\\\\\\\\as'''::tsquery" +== 060 +-- truncate_limit: 100 +SELECT 'a:* & nbb:*ac | doo:a* | goo'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:* & nbb:*ac | doo:a* | goo'::tsquery" +== 061 +-- truncate_limit: 100 +SELECT '!!b'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!!b'::tsquery" +== 062 +-- truncate_limit: 100 +SELECT '!!!b'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!!!b'::tsquery" +== 063 +-- truncate_limit: 100 +SELECT '!(!b)'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!(!b)'::tsquery" +== 064 +-- truncate_limit: 100 +SELECT 'a & !!b'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a & !!b'::tsquery" +== 065 +-- truncate_limit: 100 +SELECT '!!a & b'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!!a & b'::tsquery" +== 066 +-- truncate_limit: 100 +SELECT '!!a & !!b'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT '!!a & !!b'::tsquery" +== 067 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('foo', 'tsquery') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('foo', 'tsquery')" +== 068 +-- truncate_limit: 100 +SELECT pg_input_is_valid('foo!', 'tsquery') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('foo!', 'tsquery')" +== 069 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('foo!', 'tsquery') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('foo!', 'tsquery')" +== 070 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('a <100000> b', 'tsquery') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('a <100000> b', 'tsquery')" +== 071 +-- truncate_limit: 100 +--comparisons +SELECT 'a' < 'b & c'::tsquery as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a' < 'b & c'::tsquery AS \"true\"" +== 072 +-- truncate_limit: 100 +SELECT 'a' > 'b & c'::tsquery as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a' > 'b & c'::tsquery AS \"false\"" +== 073 +-- truncate_limit: 100 +SELECT 'a | f' < 'b & c'::tsquery as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a | f' < 'b & c'::tsquery AS \"false\"" +== 074 +-- truncate_limit: 100 +SELECT 'a | ff' < 'b & c'::tsquery as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a | ff' < 'b & c'::tsquery AS \"false\"" +== 075 +-- truncate_limit: 100 +SELECT 'a | f | g' < 'b & c'::tsquery as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a | f | g' < 'b & c'::tsquery AS \"false\"" +== 076 +-- truncate_limit: 100 +--concatenation +SELECT numnode( 'new'::tsquery ) +-- +FUNCTION: name="numnode" function="numnode" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numnode('new'::tsquery)" +== 077 +-- truncate_limit: 100 +SELECT numnode( 'new & york'::tsquery ) +-- +FUNCTION: name="numnode" function="numnode" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numnode('new & york'::tsquery)" +== 078 +-- truncate_limit: 100 +SELECT numnode( 'new & york | qwery'::tsquery ) +-- +FUNCTION: name="numnode" function="numnode" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT numnode('new & york | qwery'::tsquery)" +== 079 +-- truncate_limit: 100 +SELECT 'foo & bar'::tsquery && 'asd' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo & bar'::tsquery && 'asd'" +== 080 +-- truncate_limit: 100 +SELECT 'foo & bar'::tsquery || 'asd & fg' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo & bar'::tsquery || 'asd & fg'" +== 081 +-- truncate_limit: 100 +SELECT 'foo & bar'::tsquery || !!'asd & fg'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo & bar'::tsquery || (!! 'asd & fg'::tsquery)" +== 082 +-- truncate_limit: 100 +SELECT 'foo & bar'::tsquery && 'asd | fg' +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'foo & bar'::tsquery && 'asd | fg'" +== 083 +-- truncate_limit: 100 +SELECT 'a' <-> 'b & d'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a' <-> 'b & d'::tsquery" +== 084 +-- truncate_limit: 100 +SELECT 'a & g' <-> 'b & d'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a & g' <-> 'b & d'::tsquery" +== 085 +-- truncate_limit: 100 +SELECT 'a & g' <-> 'b | d'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a & g' <-> 'b | d'::tsquery" +== 086 +-- truncate_limit: 100 +SELECT 'a & g' <-> 'b <-> d'::tsquery +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a & g' <-> 'b <-> d'::tsquery" +== 087 +-- truncate_limit: 100 +SELECT tsquery_phrase('a <3> g', 'b & d', 10) +-- +FUNCTION: name="tsquery_phrase" function="tsquery_phrase" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tsquery_phrase('a <3> g', 'b & d', 10)" +== 088 +-- truncate_limit: 100 +-- tsvector-tsquery operations + +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca' as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca' AS \"true\"" +== 089 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B' as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B' AS \"true\"" +== 090 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:A' as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:A' AS \"true\"" +== 091 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:C' as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:C' AS \"false\"" +== 092 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:CB' as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:CB' AS \"true\"" +== 093 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & c:*C' as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & c:*C' AS \"false\"" +== 094 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & c:*CB' as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & c:*CB' AS \"true\"" +== 095 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64b cb:80c d:34c'::tsvector @@ 'd:AC & c:*C' as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64b cb:80c d:34c'::tsvector @@ 'd:AC & c:*C' AS \"true\"" +== 096 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64c cb:80b d:34c'::tsvector @@ 'd:AC & c:*C' as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64c cb:80b d:34c'::tsvector @@ 'd:AC & c:*C' AS \"true\"" +== 097 +-- truncate_limit: 100 +SELECT 'a b:89 ca:23A,64c cb:80b d:34c'::tsvector @@ 'd:AC & c:*B' as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a b:89 ca:23A,64c cb:80b d:34c'::tsvector @@ 'd:AC & c:*B' AS \"true\"" +== 098 +-- truncate_limit: 100 +SELECT 'wa:1D wb:2A'::tsvector @@ 'w:*D & w:*A'::tsquery as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'wa:1D wb:2A'::tsvector @@ 'w:*D & w:*A'::tsquery AS \"true\"" +== 099 +-- truncate_limit: 100 +SELECT 'wa:1D wb:2A'::tsvector @@ 'w:*D <-> w:*A'::tsquery as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'wa:1D wb:2A'::tsvector @@ 'w:*D <-> w:*A'::tsquery AS \"true\"" +== 100 +-- truncate_limit: 100 +SELECT 'wa:1A wb:2D'::tsvector @@ 'w:*D <-> w:*A'::tsquery as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'wa:1A wb:2D'::tsvector @@ 'w:*D <-> w:*A'::tsquery AS \"false\"" +== 101 +-- truncate_limit: 100 +SELECT 'wa:1A'::tsvector @@ 'w:*A'::tsquery as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'wa:1A'::tsvector @@ 'w:*A'::tsquery AS \"true\"" +== 102 +-- truncate_limit: 100 +SELECT 'wa:1A'::tsvector @@ 'w:*D'::tsquery as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'wa:1A'::tsvector @@ 'w:*D'::tsquery AS \"false\"" +== 103 +-- truncate_limit: 100 +SELECT 'wa:1A'::tsvector @@ '!w:*A'::tsquery as "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'wa:1A'::tsvector @@ '!w:*A'::tsquery AS \"false\"" +== 104 +-- truncate_limit: 100 +SELECT 'wa:1A'::tsvector @@ '!w:*D'::tsquery as "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'wa:1A'::tsvector @@ '!w:*D'::tsquery AS \"true\"" +== 105 +-- truncate_limit: 100 +-- historically, a stripped tsvector matches queries ignoring weights: +SELECT strip('wa:1A'::tsvector) @@ 'w:*A'::tsquery as "true" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip('wa:1A'::tsvector) @@ 'w:*A'::tsquery AS \"true\"" +== 106 +-- truncate_limit: 100 +SELECT strip('wa:1A'::tsvector) @@ 'w:*D'::tsquery as "true" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip('wa:1A'::tsvector) @@ 'w:*D'::tsquery AS \"true\"" +== 107 +-- truncate_limit: 100 +SELECT strip('wa:1A'::tsvector) @@ '!w:*A'::tsquery as "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip('wa:1A'::tsvector) @@ '!w:*A'::tsquery AS \"false\"" +== 108 +-- truncate_limit: 100 +SELECT strip('wa:1A'::tsvector) @@ '!w:*D'::tsquery as "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip('wa:1A'::tsvector) @@ '!w:*D'::tsquery AS \"false\"" +== 109 +-- truncate_limit: 100 +SELECT 'supernova'::tsvector @@ 'super'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'supernova'::tsvector @@ 'super'::tsquery AS \"false\"" +== 110 +-- truncate_limit: 100 +SELECT 'supeanova supernova'::tsvector @@ 'super'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'supeanova supernova'::tsvector @@ 'super'::tsquery AS \"false\"" +== 111 +-- truncate_limit: 100 +SELECT 'supeznova supernova'::tsvector @@ 'super'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'supeznova supernova'::tsvector @@ 'super'::tsquery AS \"false\"" +== 112 +-- truncate_limit: 100 +SELECT 'supernova'::tsvector @@ 'super:*'::tsquery AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'supernova'::tsvector @@ 'super:*'::tsquery AS \"true\"" +== 113 +-- truncate_limit: 100 +SELECT 'supeanova supernova'::tsvector @@ 'super:*'::tsquery AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'supeanova supernova'::tsvector @@ 'super:*'::tsquery AS \"true\"" +== 114 +-- truncate_limit: 100 +SELECT 'supeznova supernova'::tsvector @@ 'super:*'::tsquery AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'supeznova supernova'::tsvector @@ 'super:*'::tsquery AS \"true\"" +== 115 +-- truncate_limit: 100 +--phrase search +SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <-> 2' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <-> 2' AS \"true\"" +== 116 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <2> 2' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <2> 2' AS \"false\"" +== 117 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <-> 3' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <-> 3' AS \"false\"" +== 118 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <2> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 3 1') @@ '1 <2> 3' AS \"true\"" +== 119 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 1 2') @@ '1 <3> 2' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 1 2') @@ '1 <3> 2' AS \"true\"" +== 120 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 11 3') @@ '1 <-> 3' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 11 3') @@ '1 <-> 3' AS \"false\"" +== 121 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 11 3') @@ '1:* <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 11 3') @@ '1:* <-> 3' AS \"true\"" +== 122 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <-> 2 <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <-> 2 <-> 3' AS \"true\"" +== 123 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 3 4') @@ '(1 <-> 2) <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 3 4') @@ '(1 <-> 2) <-> 3' AS \"true\"" +== 124 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <-> (2 <-> 3)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <-> (2 <-> 3)' AS \"true\"" +== 125 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <2> (2 <-> 3)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 3 4') @@ '1 <2> (2 <-> 3)' AS \"false\"" +== 126 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 1 2 3 4') @@ '(1 <-> 2) <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 1 2 3 4') @@ '(1 <-> 2) <-> 3' AS \"true\"" +== 127 +-- truncate_limit: 100 +SELECT to_tsvector('simple', '1 2 1 2 3 4') @@ '1 <-> 2 <-> 3' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '1 2 1 2 3 4') @@ '1 <-> 2 <-> 3' AS \"true\"" +== 128 +-- truncate_limit: 100 +-- without position data, phrase search does not match +SELECT strip(to_tsvector('simple', '1 2 3 4')) @@ '1 <-> 2 <-> 3' AS "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip(to_tsvector('simple', '1 2 3 4')) @@ '1 <-> 2 <-> 3' AS \"false\"" +== 129 +-- truncate_limit: 100 +select to_tsvector('simple', 'q x q y') @@ 'q <-> (x & y)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'q x q y') @@ 'q <-> (x & y)' AS \"false\"" +== 130 +-- truncate_limit: 100 +select to_tsvector('simple', 'q x') @@ 'q <-> (x | y <-> z)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'q x') @@ 'q <-> (x | y <-> z)' AS \"true\"" +== 131 +-- truncate_limit: 100 +select to_tsvector('simple', 'q y') @@ 'q <-> (x | y <-> z)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'q y') @@ 'q <-> (x | y <-> z)' AS \"false\"" +== 132 +-- truncate_limit: 100 +select to_tsvector('simple', 'q y z') @@ 'q <-> (x | y <-> z)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'q y z') @@ 'q <-> (x | y <-> z)' AS \"true\"" +== 133 +-- truncate_limit: 100 +select to_tsvector('simple', 'q y x') @@ 'q <-> (x | y <-> z)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'q y x') @@ 'q <-> (x | y <-> z)' AS \"false\"" +== 134 +-- truncate_limit: 100 +select to_tsvector('simple', 'q x y') @@ 'q <-> (x | y <-> z)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'q x y') @@ 'q <-> (x | y <-> z)' AS \"true\"" +== 135 +-- truncate_limit: 100 +select to_tsvector('simple', 'q x') @@ '(x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'q x') @@ '(x | y <-> z) <-> q' AS \"false\"" +== 136 +-- truncate_limit: 100 +select to_tsvector('simple', 'x q') @@ '(x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x q') @@ '(x | y <-> z) <-> q' AS \"true\"" +== 137 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q') @@ '(x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q') @@ '(x | y <-> z) <-> q' AS \"false\"" +== 138 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y z') @@ '(x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y z') @@ '(x | y <-> z) <-> q' AS \"false\"" +== 139 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y z q') @@ '(x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y z q') @@ '(x | y <-> z) <-> q' AS \"true\"" +== 140 +-- truncate_limit: 100 +select to_tsvector('simple', 'y z q') @@ '(x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'y z q') @@ '(x | y <-> z) <-> q' AS \"true\"" +== 141 +-- truncate_limit: 100 +select to_tsvector('simple', 'y y q') @@ '(x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'y y q') @@ '(x | y <-> z) <-> q' AS \"false\"" +== 142 +-- truncate_limit: 100 +select to_tsvector('simple', 'y y q') @@ '(!x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'y y q') @@ '(!x | y <-> z) <-> q' AS \"true\"" +== 143 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q') @@ '(!x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q') @@ '(!x | y <-> z) <-> q' AS \"true\"" +== 144 +-- truncate_limit: 100 +select to_tsvector('simple', 'y y q') @@ '(x | y <-> !z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'y y q') @@ '(x | y <-> !z) <-> q' AS \"true\"" +== 145 +-- truncate_limit: 100 +select to_tsvector('simple', 'x q') @@ '(x | y <-> !z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x q') @@ '(x | y <-> !z) <-> q' AS \"true\"" +== 146 +-- truncate_limit: 100 +select to_tsvector('simple', 'x q') @@ '(!x | y <-> z) <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x q') @@ '(!x | y <-> z) <-> q' AS \"false\"" +== 147 +-- truncate_limit: 100 +select to_tsvector('simple', 'z q') @@ '(!x | y <-> z) <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'z q') @@ '(!x | y <-> z) <-> q' AS \"true\"" +== 148 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q') @@ '(!x | y) <-> y <-> q' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q') @@ '(!x | y) <-> y <-> q' AS \"false\"" +== 149 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q') @@ '(!x | !y) <-> y <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q') @@ '(!x | !y) <-> y <-> q' AS \"true\"" +== 150 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q') @@ '(x | !y) <-> y <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q') @@ '(x | !y) <-> y <-> q' AS \"true\"" +== 151 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q') @@ '(x | !!z) <-> y <-> q' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q') @@ '(x | !!z) <-> y <-> q' AS \"true\"" +== 152 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q y') @@ '!x <-> y' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q y') @@ '!x <-> y' AS \"true\"" +== 153 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q y') @@ '!x <-> !y' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q y') @@ '!x <-> !y' AS \"true\"" +== 154 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q y') @@ '!x <-> !!y' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q y') @@ '!x <-> !!y' AS \"true\"" +== 155 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q y') @@ '!(x <-> y)' AS "false" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q y') @@ '!(x <-> y)' AS \"false\"" +== 156 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q y') @@ '!(x <2> y)' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q y') @@ '!(x <2> y)' AS \"true\"" +== 157 +-- truncate_limit: 100 +select strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> y' AS "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> y' AS \"false\"" +== 158 +-- truncate_limit: 100 +select strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> !y' AS "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> !y' AS \"false\"" +== 159 +-- truncate_limit: 100 +select strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> !!y' AS "false" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip(to_tsvector('simple', 'x y q y')) @@ '!x <-> !!y' AS \"false\"" +== 160 +-- truncate_limit: 100 +select strip(to_tsvector('simple', 'x y q y')) @@ '!(x <-> y)' AS "true" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip(to_tsvector('simple', 'x y q y')) @@ '!(x <-> y)' AS \"true\"" +== 161 +-- truncate_limit: 100 +select strip(to_tsvector('simple', 'x y q y')) @@ '!(x <2> y)' AS "true" +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip(to_tsvector('simple', 'x y q y')) @@ '!(x <2> y)' AS \"true\"" +== 162 +-- truncate_limit: 100 +select to_tsvector('simple', 'x y q y') @@ '!foo' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', 'x y q y') @@ '!foo' AS \"true\"" +== 163 +-- truncate_limit: 100 +select to_tsvector('simple', '') @@ '!foo' AS "true" +-- +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT to_tsvector('simple', '') @@ '!foo' AS \"true\"" +== 164 +-- truncate_limit: 100 +--ranking +SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s')" +== 165 +-- truncate_limit: 100 +SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s')" +== 166 +-- truncate_limit: 100 +SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s:*') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | s:*')" +== 167 +-- truncate_limit: 100 +SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | sa:*') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 sa:2C d g'::tsvector, 'a | sa:*')" +== 168 +-- truncate_limit: 100 +SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a | s')" +== 169 +-- truncate_limit: 100 +SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a | s')" +== 170 +-- truncate_limit: 100 +SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a & s')" +== 171 +-- truncate_limit: 100 +SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a & s')" +== 172 +-- truncate_limit: 100 +SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank" function="ts_rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a & s')" +== 173 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s')" +== 174 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | s')" +== 175 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | s:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | s:*')" +== 176 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | sa:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 sa:2C d g'::tsvector, 'a | sa:*')" +== 177 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 sa:3C sab:2c d g'::tsvector, 'a | sa:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 sa:3C sab:2c d g'::tsvector, 'a | sa:*')" +== 178 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a | s')" +== 179 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s')" +== 180 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s')" +== 181 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s')" +== 182 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s')" +== 183 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2A d g'::tsvector, 'a <-> s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2A d g'::tsvector, 'a <-> s')" +== 184 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a <-> s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a <-> s')" +== 185 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a <-> s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a <-> s')" +== 186 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2 d:2A g'::tsvector, 'a <-> s') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2 d:2A g'::tsvector, 'a <-> s')" +== 187 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 s:2,3A d:2A g'::tsvector, 'a <2> s:A') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 s:2,3A d:2A g'::tsvector, 'a <2> s:A')" +== 188 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 b:2 s:3A d:2A g'::tsvector, 'a <2> s:A') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 b:2 s:3A d:2A g'::tsvector, 'a <2> s:A')" +== 189 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 sa:2D sb:2A g'::tsvector, 'a <-> s:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 sa:2D sb:2A g'::tsvector, 'a <-> s:*')" +== 190 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:*') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:*')" +== 191 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:* <-> sa:A') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:* <-> sa:A')" +== 192 +-- truncate_limit: 100 +SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:* <-> sa:B') +-- +FUNCTION: name="ts_rank_cd" function="ts_rank_cd" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_rank_cd(' a:1 sa:2A sb:2D g'::tsvector, 'a <-> s:* <-> sa:B')" +== 193 +-- truncate_limit: 100 +SELECT 'a:1 b:2'::tsvector @@ 'a <-> b'::tsquery AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:2'::tsvector @@ 'a <-> b'::tsquery AS \"true\"" +== 194 +-- truncate_limit: 100 +SELECT 'a:1 b:2'::tsvector @@ 'a <0> b'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:2'::tsvector @@ 'a <0> b'::tsquery AS \"false\"" +== 195 +-- truncate_limit: 100 +SELECT 'a:1 b:2'::tsvector @@ 'a <1> b'::tsquery AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:2'::tsvector @@ 'a <1> b'::tsquery AS \"true\"" +== 196 +-- truncate_limit: 100 +SELECT 'a:1 b:2'::tsvector @@ 'a <2> b'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:2'::tsvector @@ 'a <2> b'::tsquery AS \"false\"" +== 197 +-- truncate_limit: 100 +SELECT 'a:1 b:3'::tsvector @@ 'a <-> b'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:3'::tsvector @@ 'a <-> b'::tsquery AS \"false\"" +== 198 +-- truncate_limit: 100 +SELECT 'a:1 b:3'::tsvector @@ 'a <0> b'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:3'::tsvector @@ 'a <0> b'::tsquery AS \"false\"" +== 199 +-- truncate_limit: 100 +SELECT 'a:1 b:3'::tsvector @@ 'a <1> b'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:3'::tsvector @@ 'a <1> b'::tsquery AS \"false\"" +== 200 +-- truncate_limit: 100 +SELECT 'a:1 b:3'::tsvector @@ 'a <2> b'::tsquery AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:3'::tsvector @@ 'a <2> b'::tsquery AS \"true\"" +== 201 +-- truncate_limit: 100 +SELECT 'a:1 b:3'::tsvector @@ 'a <3> b'::tsquery AS "false" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:3'::tsvector @@ 'a <3> b'::tsquery AS \"false\"" +== 202 +-- truncate_limit: 100 +SELECT 'a:1 b:3'::tsvector @@ 'a <0> a:*'::tsquery AS "true" +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'a:1 b:3'::tsvector @@ 'a <0> a:*'::tsquery AS \"true\"" +== 203 +-- truncate_limit: 100 +-- tsvector editing operations + +SELECT strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector) +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector)" +== 204 +-- truncate_limit: 100 +SELECT strip('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector)" +== 205 +-- truncate_limit: 100 +SELECT strip('base hidden rebel spaceship strike'::tsvector) +-- +FUNCTION: name="strip" function="strip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT strip('base hidden rebel spaceship strike'::tsvector)" +== 206 +-- truncate_limit: 100 +SELECT ts_delete(to_tsvector('english', 'Rebel spaceships, striking from a hidden base'), 'spaceship') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +FUNCTION: name="to_tsvector" function="to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 207 +-- truncate_limit: 100 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'base') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'base')" +== 208 +-- truncate_limit: 100 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'bas') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'bas')" +== 209 +-- truncate_limit: 100 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'bases') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'bases')" +== 210 +-- truncate_limit: 100 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, 'spaceship') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 211 +-- truncate_limit: 100 +SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, 'spaceship') +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, 'spaceship')" +== 212 +-- truncate_limit: 100 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, ARRAY['spaceship','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 213 +-- truncate_limit: 100 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, ARRAY['spaceships','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 214 +-- truncate_limit: 100 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, ARRAY['spaceshi','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 215 +-- truncate_limit: 100 +SELECT ts_delete('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector, ARRAY['spaceship','leya','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 216 +-- truncate_limit: 100 +SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, ARRAY['spaceship','leya','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 217 +-- truncate_limit: 100 +SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, ARRAY['spaceship','leya','rebel','rebel']) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 218 +-- truncate_limit: 100 +SELECT ts_delete('base hidden rebel spaceship strike'::tsvector, ARRAY['spaceship','leya','rebel', '', NULL]) +-- +FUNCTION: name="ts_delete" function="ts_delete" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 219 +-- truncate_limit: 100 +SELECT unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector)" +== 220 +-- truncate_limit: 100 +SELECT unnest('base hidden rebel spaceship strike'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unnest('base hidden rebel spaceship strike'::tsvector)" +== 221 +-- truncate_limit: 100 +SELECT * FROM unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector)" +== 222 +-- truncate_limit: 100 +SELECT * FROM unnest('base hidden rebel spaceship strike'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unnest('base hidden rebel spaceship strike'::tsvector)" +== 223 +-- truncate_limit: 100 +SELECT lexeme, positions[1] from unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="unnest" function="unnest" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM unnest('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector)" +== 224 +-- truncate_limit: 100 +SELECT tsvector_to_array('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector) +-- +FUNCTION: name="tsvector_to_array" function="tsvector_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tsvector_to_array('base:7 hidden:6 rebel:1 spaceship:2,33A,34B,35C,36D strike:3'::tsvector)" +== 225 +-- truncate_limit: 100 +SELECT tsvector_to_array('base hidden rebel spaceship strike'::tsvector) +-- +FUNCTION: name="tsvector_to_array" function="tsvector_to_array" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT tsvector_to_array('base hidden rebel spaceship strike'::tsvector)" +== 226 +-- truncate_limit: 100 +SELECT array_to_tsvector(ARRAY['base','hidden','rebel','spaceship','strike']) +-- +FUNCTION: name="array_to_tsvector" function="array_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_tsvector(ARRAY['base', 'hidden', 'rebel', 'spaceship', 'strike'])" +== 227 +-- truncate_limit: 100 +-- null and empty string are disallowed, since we mustn't make an empty lexeme +SELECT array_to_tsvector(ARRAY['base','hidden','rebel','spaceship', NULL]) +-- +FUNCTION: name="array_to_tsvector" function="array_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_tsvector(ARRAY['base', 'hidden', 'rebel', 'spaceship', NULL])" +== 228 +-- truncate_limit: 100 +SELECT array_to_tsvector(ARRAY['base','hidden','rebel','spaceship', '']) +-- +FUNCTION: name="array_to_tsvector" function="array_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_tsvector(ARRAY['base', 'hidden', 'rebel', 'spaceship', ''])" +== 229 +-- truncate_limit: 100 +-- array_to_tsvector must sort and de-dup +SELECT array_to_tsvector(ARRAY['foo','bar','baz','bar']) +-- +FUNCTION: name="array_to_tsvector" function="array_to_tsvector" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT array_to_tsvector(ARRAY['foo', 'bar', 'baz', 'bar'])" +== 230 +-- truncate_limit: 100 +SELECT setweight('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd zxc:81,567,222A'::tsvector, 'c') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setweight('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd zxc:81,567,222A'::tsvector, 'c')" +== 231 +-- truncate_limit: 100 +SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c')" +== 232 +-- truncate_limit: 100 +SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a}') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a}')" +== 233 +-- truncate_limit: 100 +SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a}') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a}')" +== 234 +-- truncate_limit: 100 +SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a,zxc}') +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c', '{a,zxc}')" +== 235 +-- truncate_limit: 100 +SELECT setweight('a asd w:5,6,12B,13A zxc'::tsvector, 'c', ARRAY['a', 'zxc', '', NULL]) +-- +FUNCTION: name="setweight" function="setweight" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT setweight('a asd w:5,6,12B,13A zxc'::tsvector, 'c', ARRAY['a', 'zxc', '', NULL])" +== 236 +-- truncate_limit: 100 +SELECT ts_filter('base:7A empir:17 evil:15 first:11 galact:16 hidden:6A rebel:1A spaceship:2A strike:3A victori:12 won:9'::tsvector, '{a}') +-- +FUNCTION: name="ts_filter" function="ts_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 237 +-- truncate_limit: 100 +SELECT ts_filter('base hidden rebel spaceship strike'::tsvector, '{a}') +-- +FUNCTION: name="ts_filter" function="ts_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_filter('base hidden rebel spaceship strike'::tsvector, '{a}')" +== 238 +-- truncate_limit: 100 +SELECT ts_filter('base hidden rebel spaceship strike'::tsvector, '{a,b,NULL}') +-- +FUNCTION: name="ts_filter" function="ts_filter" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ts_filter('base hidden rebel spaceship strike'::tsvector, '{a,b,NULL}')" diff --git a/parser/testdata/summary_truncate/postgres_regress/tuplesort.metadata.json b/parser/testdata/summary_truncate/postgres_regress/tuplesort.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tuplesort.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/tuplesort.test b/parser/testdata/summary_truncate/postgres_regress/tuplesort.test new file mode 100644 index 0000000..d689e3c --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/tuplesort.test @@ -0,0 +1,869 @@ +== 001 +-- truncate_limit: 100 +-- only use parallelism when explicitly intending to do so +SET max_parallel_maintenance_workers = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_maintenance_workers TO 0" +== 002 +-- truncate_limit: 100 +SET max_parallel_workers = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers TO 0" +== 003 +-- truncate_limit: 100 +-- A table with contents that, when sorted, triggers abbreviated +-- key aborts. One easy way to achieve that is to use uuids that all +-- have the same prefix, as abbreviated keys for uuids just use the +-- first sizeof(Datum) bytes. +CREATE TEMP TABLE abbrev_abort_uuids ( + id serial not null, + abort_increasing uuid, + abort_decreasing uuid, + noabort_increasing uuid, + noabort_decreasing uuid) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE abbrev_abort_uuids (id serial NOT NULL, abort_increasing uuid, abort_decre..." +== 004 +-- truncate_limit: 100 +INSERT INTO abbrev_abort_uuids (abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing) + SELECT + ('00000000-0000-0000-0000-'||to_char(g.i, '000000000000FM'))::uuid abort_increasing, + ('00000000-0000-0000-0000-'||to_char(20000 - g.i, '000000000000FM'))::uuid abort_decreasing, + (to_char(g.i % 10009, '00000000FM')||'-0000-0000-0000-'||to_char(g.i, '000000000000FM'))::uuid noabort_increasing, + (to_char(((20000 - g.i) % 10009), '00000000FM')||'-0000-0000-0000-'||to_char(20000 - g.i, '000000000000FM'))::uuid noabort_decreasing + FROM generate_series(0, 20000, 1) g(i) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO abbrev_abort_uuids (...) SELECT ... FROM generate_series(0, 20000, 1) g(i)" +== 005 +-- truncate_limit: 100 +-- and a few NULLs +INSERT INTO abbrev_abort_uuids(id) VALUES(0) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO abbrev_abort_uuids (id) VALUES (0)" +== 006 +-- truncate_limit: 100 +INSERT INTO abbrev_abort_uuids DEFAULT VALUES +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO abbrev_abort_uuids DEFAULT VALUES" +== 007 +-- truncate_limit: 100 +INSERT INTO abbrev_abort_uuids DEFAULT VALUES +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO abbrev_abort_uuids DEFAULT VALUES" +== 008 +-- truncate_limit: 100 +-- add just a few duplicates +INSERT INTO abbrev_abort_uuids (abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing) + SELECT abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing + FROM abbrev_abort_uuids + WHERE (id < 10 OR id > 19990) AND id % 3 = 0 AND abort_increasing is not null +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DML +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="abort_increasing" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO abbrev_abort_uuids (...) SELECT ... FROM abbrev_abort_uuids WHERE ..." +== 009 +-- truncate_limit: 100 +---- +-- Check sort node uses of tuplesort wrt. abbreviated keys +---- + +-- plain sort triggering abbreviated abort +SELECT abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_increasing OFFSET 20000 - 4 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY abort_increasing OFFSET 20000 - 4" +== 010 +-- truncate_limit: 100 +SELECT abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_decreasing NULLS FIRST OFFSET 20000 - 4 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY abort_decreasing NULLS FIRST OFFSET 20000 - 4" +== 011 +-- truncate_limit: 100 +-- plain sort not triggering abbreviated abort +SELECT noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_increasing OFFSET 20000 - 4 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY noabort_increasing OFFSET 20000 - 4" +== 012 +-- truncate_limit: 100 +SELECT noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing NULLS FIRST OFFSET 20000 - 4 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY noabort_decreasing NULLS FIRST OFFSET 20000 - 4" +== 013 +-- truncate_limit: 100 +-- bounded sort (disables abbreviated keys) +SELECT abort_increasing, noabort_increasing FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5" +== 014 +-- truncate_limit: 100 +SELECT abort_increasing, noabort_increasing FROM abbrev_abort_uuids ORDER BY noabort_increasing NULLS FIRST LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY noabort_increasing NULLS FIRST LIMIT 5" +== 015 +-- truncate_limit: 100 +---- +-- Check index creation uses of tuplesort wrt. abbreviated keys +---- + +-- index creation using abbreviated keys successfully +CREATE INDEX abbrev_abort_uuids__noabort_increasing_idx ON abbrev_abort_uuids (noabort_increasing) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX abbrev_abort_uuids__noabort_increasing_idx ON abbrev_abort_uuids USING btree (noabor..." +== 016 +-- truncate_limit: 100 +CREATE INDEX abbrev_abort_uuids__noabort_decreasing_idx ON abbrev_abort_uuids (noabort_decreasing) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX abbrev_abort_uuids__noabort_decreasing_idx ON abbrev_abort_uuids USING btree (noabor..." +== 017 +-- truncate_limit: 100 +-- verify +EXPLAIN (COSTS OFF) +SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORD..." +== 018 +-- truncate_limit: 100 +SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY noabort_increasing LIMIT 5" +== 019 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORD..." +== 020 +-- truncate_limit: 100 +SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY noabort_decreasing LIMIT 5" +== 021 +-- truncate_limit: 100 +-- index creation using abbreviated keys, hitting abort +CREATE INDEX abbrev_abort_uuids__abort_increasing_idx ON abbrev_abort_uuids (abort_increasing) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX abbrev_abort_uuids__abort_increasing_idx ON abbrev_abort_uuids USING btree (abort_in..." +== 022 +-- truncate_limit: 100 +CREATE INDEX abbrev_abort_uuids__abort_decreasing_idx ON abbrev_abort_uuids (abort_decreasing) +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX abbrev_abort_uuids__abort_decreasing_idx ON abbrev_abort_uuids USING btree (abort_de..." +== 023 +-- truncate_limit: 100 +-- verify +EXPLAIN (COSTS OFF) +SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER B..." +== 024 +-- truncate_limit: 100 +SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5" +== 025 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_decreasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER B..." +== 026 +-- truncate_limit: 100 +SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_decreasing LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY abort_decreasing LIMIT 5" +== 027 +-- truncate_limit: 100 +---- +-- Check CLUSTER uses of tuplesort wrt. abbreviated keys +---- + +-- when aborting, increasing order +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 028 +-- truncate_limit: 100 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO FALSE" +== 029 +-- truncate_limit: 100 +CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__abort_increasing_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__abort_increasing_idx" +== 030 +-- truncate_limit: 100 +-- head +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY ctid LIMIT 5" +== 031 +-- truncate_limit: 100 +-- tail +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid DESC LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY ctid DESC LIMIT 5" +== 032 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 033 +-- truncate_limit: 100 +-- when aborting, decreasing order +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 034 +-- truncate_limit: 100 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO FALSE" +== 035 +-- truncate_limit: 100 +CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__abort_decreasing_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__abort_decreasing_idx" +== 036 +-- truncate_limit: 100 +-- head +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY ctid LIMIT 5" +== 037 +-- truncate_limit: 100 +-- tail +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid DESC LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY ctid DESC LIMIT 5" +== 038 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 039 +-- truncate_limit: 100 +-- when not aborting, increasing order +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 040 +-- truncate_limit: 100 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO FALSE" +== 041 +-- truncate_limit: 100 +CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__noabort_increasing_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__noabort_increasing_idx" +== 042 +-- truncate_limit: 100 +-- head +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY ctid LIMIT 5" +== 043 +-- truncate_limit: 100 +-- tail +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid DESC LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY ctid DESC LIMIT 5" +== 044 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 045 +-- truncate_limit: 100 +-- when no aborting, decreasing order +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 046 +-- truncate_limit: 100 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO FALSE" +== 047 +-- truncate_limit: 100 +CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__noabort_decreasing_idx +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER abbrev_abort_uuids USING abbrev_abort_uuids__noabort_decreasing_idx" +== 048 +-- truncate_limit: 100 +-- head +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY ctid LIMIT 5" +== 049 +-- truncate_limit: 100 +-- tail +SELECT id, abort_increasing, abort_decreasing, noabort_increasing, noabort_decreasing +FROM abbrev_abort_uuids +ORDER BY ctid DESC LIMIT 5 +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM abbrev_abort_uuids ORDER BY ctid DESC LIMIT 5" +== 050 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 051 +-- truncate_limit: 100 +---- +-- test sorting of large datums VALUES +---- + +-- Ensure the order is correct and values look intact +SELECT LEFT(a,10),b FROM + (VALUES(REPEAT('a', 512 * 1024),1),(REPEAT('b', 512 * 1024),2)) v(a,b) +ORDER BY v.a DESC +-- +FUNCTION: name="left" function="left" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT \"left\"(a, 10), b FROM (VALUES (...)) v(a, b) ORDER BY v.a DESC" +== 052 +-- truncate_limit: 100 +---- +-- test forward and backward scans for in-memory and disk based tuplesort +---- + +-- in-memory +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 053 +-- truncate_limit: 100 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO FALSE" +== 054 +-- truncate_limit: 100 +-- unfortunately can't show analyze output confirming sort method, +-- the memory used output wouldn't be stable +EXPLAIN (COSTS OFF) DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids..." +== 055 +-- truncate_limit: 100 +DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_de..." +== 056 +-- truncate_limit: 100 +-- first and second +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 057 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 058 +-- truncate_limit: 100 +-- scroll beyond beginning +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 059 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 060 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 061 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 062 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 063 +-- truncate_limit: 100 +-- scroll beyond end +FETCH LAST FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH LAST c" +== 064 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 065 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 066 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 067 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 068 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 069 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 070 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 071 +-- truncate_limit: 100 +-- disk based +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 072 +-- truncate_limit: 100 +SET LOCAL enable_indexscan = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_indexscan TO FALSE" +== 073 +-- truncate_limit: 100 +SET LOCAL work_mem = '100kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"100kB\"" +== 074 +-- truncate_limit: 100 +-- unfortunately can't show analyze output confirming sort method, +-- the memory used output wouldn't be stable +EXPLAIN (COSTS OFF) DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing +-- +STMT: ExplainStmt +STMT: DeclareCursorStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids..." +== 075 +-- truncate_limit: 100 +DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE c SCROLL CURSOR FOR SELECT noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_de..." +== 076 +-- truncate_limit: 100 +-- first and second +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 077 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 078 +-- truncate_limit: 100 +-- scroll beyond beginning +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 079 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 080 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 081 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 082 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 083 +-- truncate_limit: 100 +-- scroll beyond end +FETCH LAST FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH LAST c" +== 084 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 085 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 086 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 087 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 088 +-- truncate_limit: 100 +FETCH BACKWARD FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH PRIOR c" +== 089 +-- truncate_limit: 100 +FETCH NEXT FROM c +-- +STMT: FetchStmt +TRUNCATED: "FETCH c" +== 090 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 091 +-- truncate_limit: 100 +---- +-- test tuplesort using both in-memory and disk sort +--- + +-- memory based +SELECT + -- fixed-width by-value datum + (array_agg(id ORDER BY id DESC NULLS FIRST))[0:5], + -- fixed-width by-ref datum + (array_agg(abort_increasing ORDER BY abort_increasing DESC NULLS LAST))[0:5], + -- variable-width datum + (array_agg(id::text ORDER BY id::text DESC NULLS LAST))[0:5], + -- fixed width by-value datum tuplesort + percentile_disc(0.99) WITHIN GROUP (ORDER BY id), + -- ensure state is shared + percentile_disc(0.01) WITHIN GROUP (ORDER BY id), + -- fixed width by-ref datum tuplesort + percentile_disc(0.8) WITHIN GROUP (ORDER BY abort_increasing), + -- variable width by-ref datum tuplesort + percentile_disc(0.2) WITHIN GROUP (ORDER BY id::text), + -- multi-column tuplesort + rank('00000000-0000-0000-0000-000000000000', '2', '2') WITHIN GROUP (ORDER BY noabort_increasing, id, id::text) +FROM ( + SELECT * FROM abbrev_abort_uuids + UNION ALL + SELECT NULL, NULL, NULL, NULL, NULL) s +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM abbrev_abort_uuids UNION ALL SELECT ...) s" +== 092 +-- truncate_limit: 100 +-- disk based (see also above) +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 093 +-- truncate_limit: 100 +SET LOCAL work_mem = '100kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"100kB\"" +== 094 +-- truncate_limit: 100 +SELECT + (array_agg(id ORDER BY id DESC NULLS FIRST))[0:5], + (array_agg(abort_increasing ORDER BY abort_increasing DESC NULLS LAST))[0:5], + (array_agg(id::text ORDER BY id::text DESC NULLS LAST))[0:5], + percentile_disc(0.99) WITHIN GROUP (ORDER BY id), + percentile_disc(0.01) WITHIN GROUP (ORDER BY id), + percentile_disc(0.8) WITHIN GROUP (ORDER BY abort_increasing), + percentile_disc(0.2) WITHIN GROUP (ORDER BY id::text), + rank('00000000-0000-0000-0000-000000000000', '2', '2') WITHIN GROUP (ORDER BY noabort_increasing, id, id::text) +FROM ( + SELECT * FROM abbrev_abort_uuids + UNION ALL + SELECT NULL, NULL, NULL, NULL, NULL) s +-- +TABLE: name="abbrev_abort_uuids" schema="" table="abbrev_abort_uuids" ctx=Select +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="percentile_disc" function="percentile_disc" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM abbrev_abort_uuids UNION ALL SELECT ...) s" +== 095 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 096 +-- truncate_limit: 100 +---- +-- test tuplesort mark/restore +--- + +CREATE TEMP TABLE test_mark_restore(col1 int, col2 int, col12 int) +-- +TABLE: name="test_mark_restore" schema="" table="test_mark_restore" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE test_mark_restore (col1 int, col2 int, col12 int)" +== 097 +-- truncate_limit: 100 +-- need a few duplicates for mark/restore to matter +INSERT INTO test_mark_restore(col1, col2, col12) + SELECT a.i, b.i, a.i * b.i FROM generate_series(1, 500) a(i), generate_series(1, 5) b(i) +-- +TABLE: name="test_mark_restore" schema="" table="test_mark_restore" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO test_mark_restore (...) SELECT ... FROM generate_series(1, 500) a(i), generate_series..." +== 098 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 099 +-- truncate_limit: 100 +SET LOCAL enable_nestloop = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_nestloop TO OFF" +== 100 +-- truncate_limit: 100 +SET LOCAL enable_hashjoin = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_hashjoin TO OFF" +== 101 +-- truncate_limit: 100 +SET LOCAL enable_material = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL enable_material TO OFF" +== 102 +-- truncate_limit: 100 +-- set query into variable once, to avoid repetition of the fairly long query +SELECT $$ + SELECT col12, count(distinct a.col1), count(distinct a.col2), count(distinct b.col1), count(distinct b.col2), count(*) + FROM test_mark_restore a + JOIN test_mark_restore b USING(col12) + GROUP BY 1 + HAVING count(*) > 1 + ORDER BY 2 DESC, 1 DESC, 3 DESC, 4 DESC, 5 DESC, 6 DESC + LIMIT 10 +$$ AS qry +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 103 +-- truncate_limit: 100 +-- test mark/restore with in-memory sorts +EXPLAIN (COSTS OFF) :qry +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 104 +-- truncate_limit: 100 +-- test mark/restore with on-disk sorts +SET LOCAL work_mem = '100kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL work_mem TO \"100kB\"" +== 105 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) :qry +-- +ERROR: syntax error at or near ":" +CURSORPOS: 21 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 106 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" diff --git a/parser/testdata/summary_truncate/postgres_regress/txid.metadata.json b/parser/testdata/summary_truncate/postgres_regress/txid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/txid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/txid.test b/parser/testdata/summary_truncate/postgres_regress/txid.test new file mode 100644 index 0000000..f250605 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/txid.test @@ -0,0 +1,373 @@ +== 001 +-- truncate_limit: 100 +-- txid_snapshot data type and related functions +-- Note: these are backward-compatibility functions and types, and have been +-- replaced by new xid8-based variants. See xid.sql. The txid variants will +-- be removed in a future release. + +-- i/o +select '12:13:'::txid_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:13:'::txid_snapshot" +== 002 +-- truncate_limit: 100 +select '12:18:14,16'::txid_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:18:14,16'::txid_snapshot" +== 003 +-- truncate_limit: 100 +select '12:16:14,14'::txid_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:16:14,14'::txid_snapshot" +== 004 +-- truncate_limit: 100 +-- errors +select '31:12:'::txid_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '31:12:'::txid_snapshot" +== 005 +-- truncate_limit: 100 +select '0:1:'::txid_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0:1:'::txid_snapshot" +== 006 +-- truncate_limit: 100 +select '12:13:0'::txid_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:13:0'::txid_snapshot" +== 007 +-- truncate_limit: 100 +select '12:16:14,13'::txid_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:16:14,13'::txid_snapshot" +== 008 +-- truncate_limit: 100 +create temp table snapshot_test ( + nr integer, + snap txid_snapshot +) +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE snapshot_test (nr int, snap txid_snapshot)" +== 009 +-- truncate_limit: 100 +insert into snapshot_test values (1, '12:13:') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO snapshot_test VALUES (1, '12:13:')" +== 010 +-- truncate_limit: 100 +insert into snapshot_test values (2, '12:20:13,15,18') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO snapshot_test VALUES (2, '12:20:13,15,18')" +== 011 +-- truncate_limit: 100 +insert into snapshot_test values (3, '100001:100009:100005,100007,100008') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO snapshot_test VALUES (3, '100001:100009:100005,100007,100008')" +== 012 +-- truncate_limit: 100 +insert into snapshot_test values (4, '100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO snapshot_test VALUES (...)" +== 013 +-- truncate_limit: 100 +select snap from snapshot_test order by nr +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT snap FROM snapshot_test ORDER BY nr" +== 014 +-- truncate_limit: 100 +select txid_snapshot_xmin(snap), + txid_snapshot_xmax(snap), + txid_snapshot_xip(snap) +from snapshot_test order by nr +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="txid_snapshot_xmin" function="txid_snapshot_xmin" schema="" ctx=Call +FUNCTION: name="txid_snapshot_xmax" function="txid_snapshot_xmax" schema="" ctx=Call +FUNCTION: name="txid_snapshot_xip" function="txid_snapshot_xip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM snapshot_test ORDER BY nr" +== 015 +-- truncate_limit: 100 +select id, txid_visible_in_snapshot(id, snap) +from snapshot_test, generate_series(11, 21) id +where nr = 2 +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM snapshot_test, generate_series(11, 21) id WHERE nr = 2" +== 016 +-- truncate_limit: 100 +-- test bsearch +select id, txid_visible_in_snapshot(id, snap) +from snapshot_test, generate_series(90, 160) id +where nr = 4 +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM snapshot_test, generate_series(90, 160) id WHERE nr = 4" +== 017 +-- truncate_limit: 100 +-- test current values also +select txid_current() >= txid_snapshot_xmin(txid_current_snapshot()) +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +FUNCTION: name="txid_snapshot_xmin" function="txid_snapshot_xmin" schema="" ctx=Call +FUNCTION: name="txid_current_snapshot" function="txid_current_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_current() >= txid_snapshot_xmin(txid_current_snapshot())" +== 018 +-- truncate_limit: 100 +-- we can't assume current is always less than xmax, however + +select txid_visible_in_snapshot(txid_current(), txid_current_snapshot()) +-- +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +FUNCTION: name="txid_current_snapshot" function="txid_current_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_visible_in_snapshot(txid_current(), txid_current_snapshot())" +== 019 +-- truncate_limit: 100 +-- test 64bitness + +select txid_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1000100010001000:1000100010001100:1000100010001012,1000100010001013'::txid_snapshot" +== 020 +-- truncate_limit: 100 +select txid_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013') +-- +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 021 +-- truncate_limit: 100 +select txid_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013') +-- +FUNCTION: name="txid_visible_in_snapshot" function="txid_visible_in_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 022 +-- truncate_limit: 100 +-- test 64bit overflow +SELECT txid_snapshot '1:9223372036854775807:3' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1:9223372036854775807:3'::txid_snapshot" +== 023 +-- truncate_limit: 100 +SELECT txid_snapshot '1:9223372036854775808:3' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1:9223372036854775808:3'::txid_snapshot" +== 024 +-- truncate_limit: 100 +-- test txid_current_if_assigned +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 025 +-- truncate_limit: 100 +SELECT txid_current_if_assigned() IS NULL +-- +FUNCTION: name="txid_current_if_assigned" function="txid_current_if_assigned" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_current_if_assigned() IS NULL" +== 026 +-- truncate_limit: 100 +SELECT txid_current() +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_current()" +== 027 +-- truncate_limit: 100 +SELECT txid_current_if_assigned() IS NOT DISTINCT FROM BIGINT :'txid_current' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 63 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 028 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 029 +-- truncate_limit: 100 +-- test xid status functions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 030 +-- truncate_limit: 100 +SELECT txid_current() AS committed +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_current() AS committed" +== 031 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 032 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 033 +-- truncate_limit: 100 +SELECT txid_current() AS rolledback +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_current() AS rolledback" +== 034 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 035 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 036 +-- truncate_limit: 100 +SELECT txid_current() AS inprogress +-- +FUNCTION: name="txid_current" function="txid_current" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_current() AS inprogress" +== 037 +-- truncate_limit: 100 +SELECT txid_status(:committed) AS committed +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 038 +-- truncate_limit: 100 +SELECT txid_status(:rolledback) AS rolledback +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 039 +-- truncate_limit: 100 +SELECT txid_status(:inprogress) AS inprogress +-- +ERROR: syntax error at or near ":" +CURSORPOS: 20 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 040 +-- truncate_limit: 100 +SELECT txid_status(1) +-- +FUNCTION: name="txid_status" function="txid_status" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_status(1)" +== 041 +-- truncate_limit: 100 +-- BootstrapTransactionId is always committed +SELECT txid_status(2) +-- +FUNCTION: name="txid_status" function="txid_status" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_status(2)" +== 042 +-- truncate_limit: 100 +-- FrozenTransactionId is always committed +SELECT txid_status(3) +-- +FUNCTION: name="txid_status" function="txid_status" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT txid_status(3)" +== 043 +-- truncate_limit: 100 +-- in regress testing FirstNormalTransactionId will always be behind oldestXmin + +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 044 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 045 +-- truncate_limit: 100 +CREATE FUNCTION test_future_xid_status(bigint) +RETURNS void +LANGUAGE plpgsql +AS +$$ +BEGIN + PERFORM txid_status($1); + RAISE EXCEPTION 'didn''t ERROR at xid in the future as expected'; +EXCEPTION + WHEN invalid_parameter_value THEN + RAISE NOTICE 'Got expected error for xid in the future'; +END; +$$ +-- +FUNCTION: name="test_future_xid_status" function="test_future_xid_status" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_future_xid_status(bigint) RETURNS void LANGUAGE plpgsql AS $$\nBEGIN\n PERFOR..." +== 046 +-- truncate_limit: 100 +SELECT test_future_xid_status(:inprogress + 10000) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 31 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 047 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" diff --git a/parser/testdata/summary_truncate/postgres_regress/type_sanity.metadata.json b/parser/testdata/summary_truncate/postgres_regress/type_sanity.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/type_sanity.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/type_sanity.test b/parser/testdata/summary_truncate/postgres_regress/type_sanity.test new file mode 100644 index 0000000..666174a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/type_sanity.test @@ -0,0 +1,1302 @@ +== 001 +-- truncate_limit: 100 +|-- +-- TYPE_SANITY +-- Sanity checks for common errors in making type-related system tables: +-- pg_type, pg_class, pg_attribute, pg_range. +|-- +-- None of the SELECTs here should ever find any matching entries, +-- so the expected output is easy to maintain ;-). +-- A test failure indicates someone messed up an entry in the system tables. +|-- +-- NB: we assume the oidjoins test will have caught any dangling links, +-- that is OID or REGPROC fields that are not zero and do not match some +-- row in the linked-to table. However, if we want to enforce that a link +-- field can't be 0, we have to check it here. + +-- **************** pg_type **************** + +-- Look for illegal values in pg_type fields. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typnamespace = 0 OR + (t1.typlen <= 0 AND t1.typlen != -1 AND t1.typlen != -2) OR + (t1.typtype not in ('b', 'c', 'd', 'e', 'm', 'p', 'r')) OR + NOT t1.typisdefined OR + (t1.typalign not in ('c', 's', 'i', 'd')) OR + (t1.typstorage not in ('p', 'x', 'e', 'm')) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typnamespace" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typisdefined" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t1" column="typstorage" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname FROM pg_type t1 WHERE ..." +== 002 +-- truncate_limit: 100 +-- Look for "pass by value" types that can't be passed by value. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typbyval AND + (t1.typlen != 1 OR t1.typalign != 'c') AND + (t1.typlen != 2 OR t1.typalign != 's') AND + (t1.typlen != 4 OR t1.typalign != 'i') AND + (t1.typlen != 8 OR t1.typalign != 'd') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typbyval" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typalign" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname FROM pg_type t1 WHERE ..." +== 003 +-- truncate_limit: 100 +-- Look for "toastable" types that aren't varlena. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typstorage != 'p' AND + (t1.typbyval OR t1.typlen != -1) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typstorage" +FILTER: schema="" table="t1" column="typbyval" +FILTER: schema="" table="t1" column="typlen" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname FROM pg_type t1 WHERE ..." +== 004 +-- truncate_limit: 100 +-- Look for complex types that do not have a typrelid entry, +-- or basic types that do. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE (t1.typtype = 'c' AND t1.typrelid = 0) OR + (t1.typtype != 'c' AND t1.typrelid != 0) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typrelid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typrelid" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname FROM pg_type t1 WHERE ..." +== 005 +-- truncate_limit: 100 +-- Look for types that should have an array type but don't. +-- Generally anything that's not a pseudotype should have an array type. +-- However, we do have a small number of exceptions. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typtype not in ('p') AND t1.typname NOT LIKE E'\\_%' + AND NOT EXISTS + (SELECT 1 FROM pg_type as t2 + WHERE t2.typname = ('_' || t1.typname)::name AND + t2.typelem = t1.oid and t1.typarray = t2.oid) +ORDER BY t1.oid +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typname" +FILTER: schema="" table="t2" column="typname" +FILTER: schema="" table="t1" column="typname" +FILTER: schema="" table="t2" column="typelem" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="t1" column="typarray" +FILTER: schema="" table="t2" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname FROM pg_type t1 WHERE ... ORDER BY t1.oid" +== 006 +-- truncate_limit: 100 +-- Make sure typarray points to a "true" array type of our own base +SELECT t1.oid, t1.typname as basetype, t2.typname as arraytype, + t2.typsubscript +FROM pg_type t1 LEFT JOIN pg_type t2 ON (t1.typarray = t2.oid) +WHERE t1.typarray <> 0 AND + (t2.oid IS NULL OR + t2.typsubscript <> 'array_subscript_handler'::regproc) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typarray" +FILTER: schema="" table="t2" column="oid" +FILTER: schema="" table="t2" column="typsubscript" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type t1 LEFT JOIN pg_type t2 ON t1.typarray = t2.oid WHERE ..." +== 007 +-- truncate_limit: 100 +-- Look for range types that do not have a pg_range entry +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE t1.typtype = 'r' AND + NOT EXISTS(SELECT 1 FROM pg_range r WHERE rngtypid = t1.oid) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +ALIAS: "r"="pg_range" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="" column="rngtypid" +FILTER: schema="" table="t1" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname FROM pg_type t1 WHERE ..." +== 008 +-- truncate_limit: 100 +-- Look for range types whose typalign isn't sufficient +SELECT t1.oid, t1.typname, t1.typalign, t2.typname, t2.typalign +FROM pg_type as t1 + LEFT JOIN pg_range as r ON rngtypid = t1.oid + LEFT JOIN pg_type as t2 ON rngsubtype = t2.oid +WHERE t1.typtype = 'r' AND + (t1.typalign != (CASE WHEN t2.typalign = 'd' THEN 'd'::"char" + ELSE 'i'::"char" END) + OR t2.oid IS NULL) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "r"="pg_range" +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="t2" column="typalign" +FILTER: schema="" table="t2" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type t1 LEFT JOIN pg_range r ON rngtypid = t1.oid LEFT JOIN pg_type t2 ON rngs..." +== 009 +-- truncate_limit: 100 +-- Text conversion routines must be provided. + +SELECT t1.oid, t1.typname +FROM pg_type as t1 +WHERE (t1.typinput = 0 OR t1.typoutput = 0) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="t1" column="typoutput" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname FROM pg_type t1 WHERE t1.typinput = 0 OR t1.typoutput = 0" +== 010 +-- truncate_limit: 100 +-- Check for bogus typinput routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typinput = p1.oid AND NOT + ((p1.pronargs = 1 AND p1.proargtypes[0] = 'cstring'::regtype) OR + (p1.pronargs = 2 AND p1.proargtypes[0] = 'cstring'::regtype AND + p1.proargtypes[1] = 'oid'::regtype) OR + (p1.pronargs = 3 AND p1.proargtypes[0] = 'cstring'::regtype AND + p1.proargtypes[1] = 'oid'::regtype AND + p1.proargtypes[2] = 'int4'::regtype)) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 011 +-- truncate_limit: 100 +-- As of 8.0, this check finds refcursor, which is borrowing +-- other types' I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typinput = p1.oid AND t1.typtype in ('b', 'p') AND NOT + (t1.typelem != 0 AND t1.typlen < 0) AND NOT + (p1.prorettype = t1.oid AND NOT p1.proretset) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ... ORDER BY 1" +== 012 +-- truncate_limit: 100 +-- Varlena array types will point to array_in +-- Exception as of 8.1: int2vector and oidvector have their own I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typinput = p1.oid AND + (t1.typelem != 0 AND t1.typlen < 0) AND NOT + (p1.oid = 'array_in'::regproc) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ... ORDER BY 1" +== 013 +-- truncate_limit: 100 +-- typinput routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typinput = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 014 +-- truncate_limit: 100 +-- Composites, domains, enums, multiranges, ranges should all use the same input routines +SELECT DISTINCT typtype, typinput +FROM pg_type AS t1 +WHERE t1.typtype not in ('b', 'p') +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT typtype, typinput FROM pg_type t1 WHERE t1.typtype NOT IN ('b', 'p') ORDER BY 1" +== 015 +-- truncate_limit: 100 +-- Check for bogus typoutput routines + +-- As of 8.0, this check finds refcursor, which is borrowing +-- other types' I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typoutput = p1.oid AND t1.typtype in ('b', 'p') AND NOT + (p1.pronargs = 1 AND + (p1.proargtypes[0] = t1.oid OR + (p1.oid = 'array_out'::regproc AND + t1.typelem != 0 AND t1.typlen = -1))) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typoutput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ... ORDER BY 1" +== 016 +-- truncate_limit: 100 +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typoutput = p1.oid AND NOT + (p1.prorettype = 'cstring'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typoutput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 017 +-- truncate_limit: 100 +-- typoutput routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typoutput = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typoutput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 018 +-- truncate_limit: 100 +-- Composites, enums, multiranges, ranges should all use the same output routines +SELECT DISTINCT typtype, typoutput +FROM pg_type AS t1 +WHERE t1.typtype not in ('b', 'd', 'p') +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT typtype, typoutput FROM pg_type t1 WHERE ... ORDER BY 1" +== 019 +-- truncate_limit: 100 +-- Domains should have same typoutput as their base types +SELECT t1.oid, t1.typname, t2.oid, t2.typname +FROM pg_type AS t1 LEFT JOIN pg_type AS t2 ON t1.typbasetype = t2.oid +WHERE t1.typtype = 'd' AND t1.typoutput IS DISTINCT FROM t2.typoutput +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typoutput" +FILTER: schema="" table="t2" column="typoutput" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type t1 LEFT JOIN pg_type t2 ON t1.typbasetype = t2.oid WHERE ..." +== 020 +-- truncate_limit: 100 +-- Check for bogus typreceive routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typreceive = p1.oid AND NOT + ((p1.pronargs = 1 AND p1.proargtypes[0] = 'internal'::regtype) OR + (p1.pronargs = 2 AND p1.proargtypes[0] = 'internal'::regtype AND + p1.proargtypes[1] = 'oid'::regtype) OR + (p1.pronargs = 3 AND p1.proargtypes[0] = 'internal'::regtype AND + p1.proargtypes[1] = 'oid'::regtype AND + p1.proargtypes[2] = 'int4'::regtype)) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="proargtypes" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 021 +-- truncate_limit: 100 +-- As of 7.4, this check finds refcursor, which is borrowing +-- other types' I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typreceive = p1.oid AND t1.typtype in ('b', 'p') AND NOT + (t1.typelem != 0 AND t1.typlen < 0) AND NOT + (p1.prorettype = t1.oid AND NOT p1.proretset) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ... ORDER BY 1" +== 022 +-- truncate_limit: 100 +-- Varlena array types will point to array_recv +-- Exception as of 8.1: int2vector and oidvector have their own I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typreceive = p1.oid AND + (t1.typelem != 0 AND t1.typlen < 0) AND NOT + (p1.oid = 'array_recv'::regproc) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="p1" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ... ORDER BY 1" +== 023 +-- truncate_limit: 100 +-- Suspicious if typreceive doesn't take same number of args as typinput +SELECT t1.oid, t1.typname, p1.oid, p1.proname, p2.oid, p2.proname +FROM pg_type AS t1, pg_proc AS p1, pg_proc AS p2 +WHERE t1.typinput = p1.oid AND t1.typreceive = p2.oid AND + p1.pronargs != p2.pronargs +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "p2"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typinput" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p2" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p2" column="pronargs" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type t1, pg_proc p1, pg_proc p2 WHERE ..." +== 024 +-- truncate_limit: 100 +-- typreceive routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typreceive = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typreceive" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 025 +-- truncate_limit: 100 +-- Composites, domains, enums, multiranges, ranges should all use the same receive routines +SELECT DISTINCT typtype, typreceive +FROM pg_type AS t1 +WHERE t1.typtype not in ('b', 'p') +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT typtype, typreceive FROM pg_type t1 WHERE t1.typtype NOT IN ('b', 'p') ORDER BY 1" +== 026 +-- truncate_limit: 100 +-- Check for bogus typsend routines + +-- As of 7.4, this check finds refcursor, which is borrowing +-- other types' I/O routines +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typsend = p1.oid AND t1.typtype in ('b', 'p') AND NOT + (p1.pronargs = 1 AND + (p1.proargtypes[0] = t1.oid OR + (p1.oid = 'array_send'::regproc AND + t1.typelem != 0 AND t1.typlen = -1))) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsend" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ... ORDER BY 1" +== 027 +-- truncate_limit: 100 +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typsend = p1.oid AND NOT + (p1.prorettype = 'bytea'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsend" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 028 +-- truncate_limit: 100 +-- typsend routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typsend = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsend" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 029 +-- truncate_limit: 100 +-- Composites, enums, multiranges, ranges should all use the same send routines +SELECT DISTINCT typtype, typsend +FROM pg_type AS t1 +WHERE t1.typtype not in ('b', 'd', 'p') +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typtype" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT typtype, typsend FROM pg_type t1 WHERE t1.typtype NOT IN ('b', 'd', 'p') ORDER BY 1" +== 030 +-- truncate_limit: 100 +-- Domains should have same typsend as their base types +SELECT t1.oid, t1.typname, t2.oid, t2.typname +FROM pg_type AS t1 LEFT JOIN pg_type AS t2 ON t1.typbasetype = t2.oid +WHERE t1.typtype = 'd' AND t1.typsend IS DISTINCT FROM t2.typsend +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typtype" +FILTER: schema="" table="t1" column="typsend" +FILTER: schema="" table="t2" column="typsend" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type t1 LEFT JOIN pg_type t2 ON t1.typbasetype = t2.oid WHERE ..." +== 031 +-- truncate_limit: 100 +-- Check for bogus typmodin routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typmodin = p1.oid AND NOT + (p1.pronargs = 1 AND + p1.proargtypes[0] = 'cstring[]'::regtype AND + p1.prorettype = 'int4'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typmodin" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 032 +-- truncate_limit: 100 +-- typmodin routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typmodin = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typmodin" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 033 +-- truncate_limit: 100 +-- Check for bogus typmodout routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typmodout = p1.oid AND NOT + (p1.pronargs = 1 AND + p1.proargtypes[0] = 'int4'::regtype AND + p1.prorettype = 'cstring'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typmodout" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 034 +-- truncate_limit: 100 +-- typmodout routines should not be volatile +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typmodout = p1.oid AND p1.provolatile NOT IN ('i', 's') +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typmodout" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="provolatile" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 035 +-- truncate_limit: 100 +-- Array types should have same typmodin/out as their element types + +SELECT t1.oid, t1.typname, t2.oid, t2.typname +FROM pg_type AS t1, pg_type AS t2 +WHERE t1.typelem = t2.oid AND NOT + (t1.typmodin = t2.typmodin AND t1.typmodout = t2.typmodout) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t2" column="oid" +FILTER: schema="" table="t1" column="typmodin" +FILTER: schema="" table="t2" column="typmodin" +FILTER: schema="" table="t1" column="typmodout" +FILTER: schema="" table="t2" column="typmodout" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, t2.oid, t2.typname FROM pg_type t1, pg_type t2 WHERE ..." +== 036 +-- truncate_limit: 100 +-- Array types should have same typdelim as their element types + +SELECT t1.oid, t1.typname, t2.oid, t2.typname +FROM pg_type AS t1, pg_type AS t2 +WHERE t1.typarray = t2.oid AND NOT (t1.typdelim = t2.typdelim) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typarray" +FILTER: schema="" table="t2" column="oid" +FILTER: schema="" table="t1" column="typdelim" +FILTER: schema="" table="t2" column="typdelim" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, t2.oid, t2.typname FROM pg_type t1, pg_type t2 WHERE ..." +== 037 +-- truncate_limit: 100 +-- Look for array types whose typalign isn't sufficient + +SELECT t1.oid, t1.typname, t1.typalign, t2.typname, t2.typalign +FROM pg_type AS t1, pg_type AS t2 +WHERE t1.typarray = t2.oid AND + t2.typalign != (CASE WHEN t1.typalign = 'd' THEN 'd'::"char" + ELSE 'i'::"char" END) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +ALIAS: "t2"="pg_type" +FILTER: schema="" table="t1" column="typarray" +FILTER: schema="" table="t2" column="oid" +FILTER: schema="" table="t2" column="typalign" +FILTER: schema="" table="t1" column="typalign" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type t1, pg_type t2 WHERE ..." +== 038 +-- truncate_limit: 100 +-- Check for typelem set without a handler + +SELECT t1.oid, t1.typname, t1.typelem +FROM pg_type AS t1 +WHERE t1.typelem != 0 AND t1.typsubscript = 0 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typsubscript" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, t1.typelem FROM pg_type t1 WHERE t1.typelem <> 0 AND t1.typsubscript = 0" +== 039 +-- truncate_limit: 100 +-- Check for misuse of standard subscript handlers + +SELECT t1.oid, t1.typname, + t1.typelem, t1.typlen, t1.typbyval +FROM pg_type AS t1 +WHERE t1.typsubscript = 'array_subscript_handler'::regproc AND NOT + (t1.typelem != 0 AND t1.typlen = -1 AND NOT t1.typbyval) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsubscript" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typbyval" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, t1.typelem, t1.typlen, t1.typbyval FROM pg_type t1 WHERE ..." +== 040 +-- truncate_limit: 100 +SELECT t1.oid, t1.typname, + t1.typelem, t1.typlen, t1.typbyval +FROM pg_type AS t1 +WHERE t1.typsubscript = 'raw_array_subscript_handler'::regproc AND NOT + (t1.typelem != 0 AND t1.typlen > 0 AND NOT t1.typbyval) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typsubscript" +FILTER: schema="" table="t1" column="typelem" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="t1" column="typbyval" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, t1.typelem, t1.typlen, t1.typbyval FROM pg_type t1 WHERE ..." +== 041 +-- truncate_limit: 100 +-- Check for bogus typanalyze routines + +SELECT t1.oid, t1.typname, p1.oid, p1.proname +FROM pg_type AS t1, pg_proc AS p1 +WHERE t1.typanalyze = p1.oid AND NOT + (p1.pronargs = 1 AND + p1.proargtypes[0] = 'internal'::regtype AND + p1.prorettype = 'bool'::regtype AND NOT p1.proretset) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p1"="pg_proc" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="t1" column="typanalyze" +FILTER: schema="" table="p1" column="oid" +FILTER: schema="" table="p1" column="pronargs" +FILTER: schema="" table="p1" column="proargtypes" +FILTER: schema="" table="p1" column="prorettype" +FILTER: schema="" table="p1" column="proretset" +STMT: SelectStmt +TRUNCATED: "SELECT t1.oid, t1.typname, p1.oid, p1.proname FROM pg_type t1, pg_proc p1 WHERE ..." +== 042 +-- truncate_limit: 100 +-- there does not seem to be a reason to care about volatility of typanalyze + +-- domains inherit their base type's typanalyze + +SELECT d.oid, d.typname, d.typanalyze, t.oid, t.typname, t.typanalyze +FROM pg_type d JOIN pg_type t ON d.typbasetype = t.oid +WHERE d.typanalyze != t.typanalyze +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "d"="pg_type" +ALIAS: "t"="pg_type" +FILTER: schema="" table="d" column="typanalyze" +FILTER: schema="" table="t" column="typanalyze" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type d JOIN pg_type t ON d.typbasetype = t.oid WHERE d.typanalyze <> t.typanalyze" +== 043 +-- truncate_limit: 100 +-- range_typanalyze should be used for all and only range types +-- (but exclude domains, which we checked above) + +SELECT t.oid, t.typname, t.typanalyze +FROM pg_type t LEFT JOIN pg_range r on t.oid = r.rngtypid +WHERE t.typbasetype = 0 AND + (t.typanalyze = 'range_typanalyze'::regproc) != (r.rngtypid IS NOT NULL) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +ALIAS: "r"="pg_range" +ALIAS: "t"="pg_type" +FILTER: schema="" table="t" column="typbasetype" +FILTER: schema="" table="t" column="typanalyze" +FILTER: schema="" table="r" column="rngtypid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_type t LEFT JOIN pg_range r ON t.oid = r.rngtypid WHERE ..." +== 044 +-- truncate_limit: 100 +-- array_typanalyze should be used for all and only array types +-- (but exclude domains, which we checked above) +-- As of 9.2 this finds int2vector and oidvector, which are weird anyway + +SELECT t.oid, t.typname, t.typanalyze +FROM pg_type t +WHERE t.typbasetype = 0 AND + (t.typanalyze = 'array_typanalyze'::regproc) != + (t.typsubscript = 'array_subscript_handler'::regproc) +ORDER BY 1 +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "t"="pg_type" +FILTER: schema="" table="t" column="typbasetype" +FILTER: schema="" table="t" column="typanalyze" +FILTER: schema="" table="t" column="typsubscript" +STMT: SelectStmt +TRUNCATED: "SELECT t.oid, t.typname, t.typanalyze FROM pg_type t WHERE ... ORDER BY 1" +== 045 +-- truncate_limit: 100 +-- **************** pg_class **************** + +-- Look for illegal values in pg_class fields + +SELECT c1.oid, c1.relname +FROM pg_class as c1 +WHERE relkind NOT IN ('r', 'i', 'S', 't', 'v', 'm', 'c', 'f', 'p', 'I') OR + relpersistence NOT IN ('p', 'u', 't') OR + relreplident NOT IN ('d', 'n', 'f', 'i') +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c1"="pg_class" +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relpersistence" +FILTER: schema="" table="" column="relreplident" +STMT: SelectStmt +TRUNCATED: "SELECT c1.oid, c1.relname FROM pg_class c1 WHERE ..." +== 046 +-- truncate_limit: 100 +-- All tables, indexes, partitioned indexes and matviews should have an +-- access method. +SELECT c1.oid, c1.relname +FROM pg_class as c1 +WHERE c1.relkind NOT IN ('S', 'v', 'f', 'c', 'p') and + c1.relam = 0 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c1"="pg_class" +FILTER: schema="" table="c1" column="relkind" +FILTER: schema="" table="c1" column="relam" +STMT: SelectStmt +TRUNCATED: "SELECT c1.oid, c1.relname FROM pg_class c1 WHERE ..." +== 047 +-- truncate_limit: 100 +-- Conversely, sequences, views, foreign tables, types and partitioned +-- tables shouldn't have them. +SELECT c1.oid, c1.relname +FROM pg_class as c1 +WHERE c1.relkind IN ('S', 'v', 'f', 'c', 'p') and + c1.relam != 0 +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c1"="pg_class" +FILTER: schema="" table="c1" column="relkind" +FILTER: schema="" table="c1" column="relam" +STMT: SelectStmt +TRUNCATED: "SELECT c1.oid, c1.relname FROM pg_class c1 WHERE ..." +== 048 +-- truncate_limit: 100 +-- Indexes and partitioned indexes should have AMs of type 'i'. +SELECT pc.oid, pc.relname, pa.amname, pa.amtype +FROM pg_class as pc JOIN pg_am AS pa ON (pc.relam = pa.oid) +WHERE pc.relkind IN ('i', 'I') and + pa.amtype != 'i' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "pa"="pg_am" +ALIAS: "pc"="pg_class" +FILTER: schema="" table="pc" column="relkind" +FILTER: schema="" table="pa" column="amtype" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_am pa ON pc.relam = pa.oid WHERE ..." +== 049 +-- truncate_limit: 100 +-- Tables, matviews etc should have AMs of type 't' +SELECT pc.oid, pc.relname, pa.amname, pa.amtype +FROM pg_class as pc JOIN pg_am AS pa ON (pc.relam = pa.oid) +WHERE pc.relkind IN ('r', 't', 'm') and + pa.amtype != 't' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_am" schema="" table="pg_am" ctx=Select +ALIAS: "pa"="pg_am" +ALIAS: "pc"="pg_class" +FILTER: schema="" table="pc" column="relkind" +FILTER: schema="" table="pa" column="amtype" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_class pc JOIN pg_am pa ON pc.relam = pa.oid WHERE ..." +== 050 +-- truncate_limit: 100 +-- **************** pg_attribute **************** + +-- Look for illegal values in pg_attribute fields + +SELECT a1.attrelid, a1.attname +FROM pg_attribute as a1 +WHERE a1.attrelid = 0 OR a1.atttypid = 0 OR a1.attnum = 0 OR + a1.attcacheoff != -1 OR a1.attinhcount < 0 OR + (a1.attinhcount = 0 AND NOT a1.attislocal) +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +ALIAS: "a1"="pg_attribute" +FILTER: schema="" table="a1" column="attrelid" +FILTER: schema="" table="a1" column="atttypid" +FILTER: schema="" table="a1" column="attnum" +FILTER: schema="" table="a1" column="attcacheoff" +FILTER: schema="" table="a1" column="attinhcount" +FILTER: schema="" table="a1" column="attinhcount" +FILTER: schema="" table="a1" column="attislocal" +STMT: SelectStmt +TRUNCATED: "SELECT a1.attrelid, a1.attname FROM pg_attribute a1 WHERE ..." +== 051 +-- truncate_limit: 100 +-- Cross-check attnum against parent relation + +SELECT a1.attrelid, a1.attname, c1.oid, c1.relname +FROM pg_attribute AS a1, pg_class AS c1 +WHERE a1.attrelid = c1.oid AND a1.attnum > c1.relnatts +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "a1"="pg_attribute" +ALIAS: "c1"="pg_class" +FILTER: schema="" table="a1" column="attrelid" +FILTER: schema="" table="c1" column="oid" +FILTER: schema="" table="a1" column="attnum" +FILTER: schema="" table="c1" column="relnatts" +STMT: SelectStmt +TRUNCATED: "SELECT a1.attrelid, a1.attname, c1.oid, c1.relname FROM pg_attribute a1, pg_class c1 WHERE ..." +== 052 +-- truncate_limit: 100 +-- Detect missing pg_attribute entries: should have as many non-system +-- attributes as parent relation expects + +SELECT c1.oid, c1.relname +FROM pg_class AS c1 +WHERE c1.relnatts != (SELECT count(*) FROM pg_attribute AS a1 + WHERE a1.attrelid = c1.oid AND a1.attnum > 0) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +ALIAS: "a1"="pg_attribute" +ALIAS: "c1"="pg_class" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="c1" column="relnatts" +FILTER: schema="" table="a1" column="attrelid" +FILTER: schema="" table="c1" column="oid" +FILTER: schema="" table="a1" column="attnum" +STMT: SelectStmt +TRUNCATED: "SELECT c1.oid, c1.relname FROM pg_class c1 WHERE ..." +== 053 +-- truncate_limit: 100 +-- Cross-check against pg_type entry +-- NOTE: we allow attstorage to be 'plain' even when typstorage is not; +-- this is mainly for toast tables. + +SELECT a1.attrelid, a1.attname, t1.oid, t1.typname +FROM pg_attribute AS a1, pg_type AS t1 +WHERE a1.atttypid = t1.oid AND + (a1.attlen != t1.typlen OR + a1.attalign != t1.typalign OR + a1.attbyval != t1.typbyval OR + (a1.attstorage != t1.typstorage AND a1.attstorage != 'p')) +-- +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "a1"="pg_attribute" +ALIAS: "t1"="pg_type" +FILTER: schema="" table="a1" column="atttypid" +FILTER: schema="" table="t1" column="oid" +FILTER: schema="" table="a1" column="attlen" +FILTER: schema="" table="t1" column="typlen" +FILTER: schema="" table="a1" column="attalign" +FILTER: schema="" table="t1" column="typalign" +FILTER: schema="" table="a1" column="attbyval" +FILTER: schema="" table="t1" column="typbyval" +FILTER: schema="" table="a1" column="attstorage" +FILTER: schema="" table="t1" column="typstorage" +FILTER: schema="" table="a1" column="attstorage" +STMT: SelectStmt +TRUNCATED: "SELECT a1.attrelid, a1.attname, t1.oid, t1.typname FROM pg_attribute a1, pg_type t1 WHERE ..." +== 054 +-- truncate_limit: 100 +-- **************** pg_range **************** + +-- Look for illegal values in pg_range fields. + +SELECT r.rngtypid, r.rngsubtype +FROM pg_range as r +WHERE r.rngtypid = 0 OR r.rngsubtype = 0 OR r.rngsubopc = 0 +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +ALIAS: "r"="pg_range" +FILTER: schema="" table="r" column="rngtypid" +FILTER: schema="" table="r" column="rngsubtype" +FILTER: schema="" table="r" column="rngsubopc" +STMT: SelectStmt +TRUNCATED: "SELECT r.rngtypid, r.rngsubtype FROM pg_range r WHERE ..." +== 055 +-- truncate_limit: 100 +-- rngcollation should be specified iff subtype is collatable + +SELECT r.rngtypid, r.rngsubtype, r.rngcollation, t.typcollation +FROM pg_range r JOIN pg_type t ON t.oid = r.rngsubtype +WHERE (rngcollation = 0) != (typcollation = 0) +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +ALIAS: "r"="pg_range" +ALIAS: "t"="pg_type" +FILTER: schema="" table="" column="rngcollation" +FILTER: schema="" table="" column="typcollation" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_range r JOIN pg_type t ON t.oid = r.rngsubtype WHERE ..." +== 056 +-- truncate_limit: 100 +-- opclass had better be a btree opclass accepting the subtype. +-- We must allow anyarray matches, cf IsBinaryCoercible() + +SELECT r.rngtypid, r.rngsubtype, o.opcmethod, o.opcname +FROM pg_range r JOIN pg_opclass o ON o.oid = r.rngsubopc +WHERE o.opcmethod != 403 OR + ((o.opcintype != r.rngsubtype) AND NOT + (o.opcintype = 'pg_catalog.anyarray'::regtype AND + EXISTS(select 1 from pg_catalog.pg_type where + oid = r.rngsubtype and typelem != 0 and + typsubscript = 'array_subscript_handler'::regproc))) +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_opclass" schema="" table="pg_opclass" ctx=Select +TABLE: name="pg_catalog.pg_type" schema="pg_catalog" table="pg_type" ctx=Select +ALIAS: "o"="pg_opclass" +ALIAS: "r"="pg_range" +FILTER: schema="" table="o" column="opcmethod" +FILTER: schema="" table="o" column="opcintype" +FILTER: schema="" table="r" column="rngsubtype" +FILTER: schema="" table="o" column="opcintype" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="r" column="rngsubtype" +FILTER: schema="" table="" column="typelem" +FILTER: schema="" table="" column="typsubscript" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_range r JOIN pg_opclass o ON o.oid = r.rngsubopc WHERE ..." +== 057 +-- truncate_limit: 100 +-- canonical function, if any, had better match the range type + +SELECT r.rngtypid, r.rngsubtype, p.proname +FROM pg_range r JOIN pg_proc p ON p.oid = r.rngcanonical +WHERE pronargs != 1 OR proargtypes[0] != rngtypid OR prorettype != rngtypid +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p"="pg_proc" +ALIAS: "r"="pg_range" +FILTER: schema="" table="" column="pronargs" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="rngtypid" +FILTER: schema="" table="" column="prorettype" +FILTER: schema="" table="" column="rngtypid" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_range r JOIN pg_proc p ON p.oid = r.rngcanonical WHERE ..." +== 058 +-- truncate_limit: 100 +-- subdiff function, if any, had better match the subtype + +SELECT r.rngtypid, r.rngsubtype, p.proname +FROM pg_range r JOIN pg_proc p ON p.oid = r.rngsubdiff +WHERE pronargs != 2 + OR proargtypes[0] != rngsubtype OR proargtypes[1] != rngsubtype + OR prorettype != 'pg_catalog.float8'::regtype +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +ALIAS: "p"="pg_proc" +ALIAS: "r"="pg_range" +FILTER: schema="" table="" column="pronargs" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="rngsubtype" +FILTER: schema="" table="" column="proargtypes" +FILTER: schema="" table="" column="rngsubtype" +FILTER: schema="" table="" column="prorettype" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_range r JOIN pg_proc p ON p.oid = r.rngsubdiff WHERE ..." +== 059 +-- truncate_limit: 100 +-- every range should have a valid multirange + +SELECT r.rngtypid, r.rngsubtype, r.rngmultitypid +FROM pg_range r +WHERE r.rngmultitypid IS NULL OR r.rngmultitypid = 0 +-- +TABLE: name="pg_range" schema="" table="pg_range" ctx=Select +ALIAS: "r"="pg_range" +FILTER: schema="" table="r" column="rngmultitypid" +FILTER: schema="" table="r" column="rngmultitypid" +STMT: SelectStmt +TRUNCATED: "SELECT r.rngtypid, r.rngsubtype, r.rngmultitypid FROM pg_range r WHERE ..." +== 060 +-- truncate_limit: 100 +-- Create a table that holds all the known in-core data types and leave it +-- around so as pg_upgrade is able to test their binary compatibility. +CREATE TABLE tab_core_types AS SELECT + '(11,12)'::point, + '(1,1),(2,2)'::line, + '((11,11),(12,12))'::lseg, + '((11,11),(13,13))'::box, + '((11,12),(13,13),(14,14))'::path AS openedpath, + '[(11,12),(13,13),(14,14)]'::path AS closedpath, + '((11,12),(13,13),(14,14))'::polygon, + '1,1,1'::circle, + 'today'::date, + 'now'::time, + 'now'::timestamp, + 'now'::timetz, + 'now'::timestamptz, + '12 seconds'::interval, + '{"reason":"because"}'::json, + '{"when":"now"}'::jsonb, + '$.a[*] ? (@ > 2)'::jsonpath, + '127.0.0.1'::inet, + '127.0.0.0/8'::cidr, + '00:01:03:86:1c:ba'::macaddr8, + '00:01:03:86:1c:ba'::macaddr, + 2::int2, 4::int4, 8::int8, + 4::float4, '8'::float8, pi()::numeric, + 'foo'::"char", + 'c'::bpchar, + 'abc'::varchar, + 'name'::name, + 'txt'::text, + true::bool, + E'\\xDEADBEEF'::bytea, + B'10001'::bit, + B'10001'::varbit AS varbit, + '12.34'::money, + 'abc'::refcursor, + '1 2'::int2vector, + '1 2'::oidvector, + format('%I=UC/%I', USER, USER)::aclitem AS aclitem, + 'a fat cat sat on a mat and ate a fat rat'::tsvector, + 'fat & rat'::tsquery, + 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid, + '11'::xid8, + 'pg_class'::regclass, + 'regtype'::regtype type, + 'pg_monitor'::regrole, + 'pg_class'::regclass::oid, + '(1,1)'::tid, '2'::xid, '3'::cid, + '10:20:10,14,15'::txid_snapshot, + '10:20:10,14,15'::pg_snapshot, + '16/B374D848'::pg_lsn, + 1::information_schema.cardinal_number, + 'l'::information_schema.character_data, + 'n'::information_schema.sql_identifier, + 'now'::information_schema.time_stamp, + 'YES'::information_schema.yes_or_no, + '(1,2)'::int4range, '{(1,2)}'::int4multirange, + '(3,4)'::int8range, '{(3,4)}'::int8multirange, + '(3,4)'::numrange, '{(3,4)}'::nummultirange, + '(2020-01-02, 2021-02-03)'::daterange, + '{(2020-01-02, 2021-02-03)}'::datemultirange, + '(2020-01-02 03:04:05, 2021-02-03 06:07:08)'::tsrange, + '{(2020-01-02 03:04:05, 2021-02-03 06:07:08)}'::tsmultirange, + '(2020-01-02 03:04:05, 2021-02-03 06:07:08)'::tstzrange, + '{(2020-01-02 03:04:05, 2021-02-03 06:07:08)}'::tstzmultirange +-- +TABLE: name="tab_core_types" schema="" table="tab_core_types" ctx=DDL +FUNCTION: name="pi" function="pi" schema="" ctx=Call +FUNCTION: name="format" function="format" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE tab_core_types AS SELECT '(11,12)'::point, '(1,1),(2,2)'::line, '((11,11),(12,12))':..." +== 061 +-- truncate_limit: 100 +-- Sanity check on the previous table, checking that all core types are +-- included in this table. +SELECT oid, typname, typtype, typelem, typarray + FROM pg_type t + WHERE oid < 16384 AND + -- Exclude pseudotypes and composite types. + typtype NOT IN ('p', 'c') AND + -- These reg* types cannot be pg_upgraded, so discard them. + oid != ALL(ARRAY['regproc', 'regprocedure', 'regoper', + 'regoperator', 'regconfig', 'regdictionary', + 'regnamespace', 'regcollation']::regtype[]) AND + -- Discard types that do not accept input values as these cannot be + -- tested easily. + -- Note: XML might be disabled at compile-time. + oid != ALL(ARRAY['gtsvector', 'pg_node_tree', + 'pg_ndistinct', 'pg_dependencies', 'pg_mcv_list', + 'pg_brin_bloom_summary', + 'pg_brin_minmax_multi_summary', 'xml']::regtype[]) AND + -- Discard arrays. + NOT EXISTS (SELECT 1 FROM pg_type u WHERE u.typarray = t.oid) + -- Exclude everything from the table created above. This checks + -- that no in-core types are missing in tab_core_types. + AND NOT EXISTS (SELECT 1 + FROM pg_attribute a + WHERE a.atttypid=t.oid AND + a.attnum > 0 AND + a.attrelid='tab_core_types'::regclass) +-- +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_type" schema="" table="pg_type" ctx=Select +TABLE: name="pg_attribute" schema="" table="pg_attribute" ctx=Select +ALIAS: "a"="pg_attribute" +ALIAS: "t"="pg_type" +ALIAS: "u"="pg_type" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="typtype" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="u" column="typarray" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="a" column="atttypid" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="a" column="attnum" +FILTER: schema="" table="a" column="attrelid" +STMT: SelectStmt +TRUNCATED: "SELECT oid, typname, typtype, typelem, typarray FROM pg_type t WHERE ..." diff --git a/parser/testdata/summary_truncate/postgres_regress/typed_table.metadata.json b/parser/testdata/summary_truncate/postgres_regress/typed_table.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/typed_table.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/typed_table.test b/parser/testdata/summary_truncate/postgres_regress/typed_table.test new file mode 100644 index 0000000..01e6307 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/typed_table.test @@ -0,0 +1,219 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE ttable1 OF nothing +-- +TABLE: name="ttable1" schema="" table="ttable1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ttable1 OF nothing" +== 002 +-- truncate_limit: 100 +CREATE TYPE person_type AS (id int, name text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE person_type AS (id int, name text)" +== 003 +-- truncate_limit: 100 +CREATE TABLE persons OF person_type +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE persons OF person_type" +== 004 +-- truncate_limit: 100 +CREATE TABLE IF NOT EXISTS persons OF person_type +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE IF NOT EXISTS persons OF person_type" +== 005 +-- truncate_limit: 100 +SELECT * FROM persons +-- +TABLE: name="persons" schema="" table="persons" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM persons" +== 006 +-- truncate_limit: 100 +CREATE FUNCTION get_all_persons() RETURNS SETOF person_type +LANGUAGE SQL +AS $$ + SELECT * FROM persons; +$$ +-- +FUNCTION: name="get_all_persons" function="get_all_persons" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION get_all_persons() RETURNS SETOF person_type LANGUAGE sql AS $$\n SELECT * FROM ..." +== 007 +-- truncate_limit: 100 +SELECT * FROM get_all_persons() +-- +FUNCTION: name="get_all_persons" function="get_all_persons" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM get_all_persons()" +== 008 +-- truncate_limit: 100 +-- certain ALTER TABLE operations on typed tables are not allowed +ALTER TABLE persons ADD COLUMN comment text +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE persons ADD COLUMN comment text" +== 009 +-- truncate_limit: 100 +ALTER TABLE persons DROP COLUMN name +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE persons DROP name" +== 010 +-- truncate_limit: 100 +ALTER TABLE persons RENAME COLUMN id TO num +-- +STMT: RenameStmt +TRUNCATED: "ALTER TABLE persons RENAME COLUMN id TO num" +== 011 +-- truncate_limit: 100 +ALTER TABLE persons ALTER COLUMN name TYPE varchar +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE persons ALTER COLUMN name TYPE varchar" +== 012 +-- truncate_limit: 100 +CREATE TABLE stuff (id int) +-- +TABLE: name="stuff" schema="" table="stuff" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE stuff (id int)" +== 013 +-- truncate_limit: 100 +ALTER TABLE persons INHERIT stuff +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE persons INHERIT stuff" +== 014 +-- truncate_limit: 100 +CREATE TABLE personsx OF person_type (myname WITH OPTIONS NOT NULL) +-- +TABLE: name="personsx" schema="" table="personsx" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE personsx OF person_type (myname NOT NULL)" +== 015 +-- truncate_limit: 100 +-- error + +CREATE TABLE persons2 OF person_type ( + id WITH OPTIONS PRIMARY KEY, + UNIQUE (name) +) +-- +TABLE: name="persons2" schema="" table="persons2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE persons2 OF person_type (id PRIMARY KEY, UNIQUE (name))" +== 016 +-- truncate_limit: 100 +CREATE TABLE persons3 OF person_type ( + PRIMARY KEY (id), + name WITH OPTIONS DEFAULT '' +) +-- +TABLE: name="persons3" schema="" table="persons3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE persons3 OF person_type (PRIMARY KEY (id), name DEFAULT '')" +== 017 +-- truncate_limit: 100 +CREATE TABLE persons4 OF person_type ( + name WITH OPTIONS NOT NULL, + name WITH OPTIONS DEFAULT '' -- error, specified more than once +) +-- +TABLE: name="persons4" schema="" table="persons4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE persons4 OF person_type (name NOT NULL, name DEFAULT '')" +== 018 +-- truncate_limit: 100 +DROP TYPE person_type RESTRICT +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE person_type" +== 019 +-- truncate_limit: 100 +DROP TYPE person_type CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE person_type CASCADE" +== 020 +-- truncate_limit: 100 +CREATE TABLE persons5 OF stuff +-- +TABLE: name="persons5" schema="" table="persons5" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE persons5 OF stuff" +== 021 +-- truncate_limit: 100 +-- only CREATE TYPE AS types may be used + +DROP TABLE stuff +-- +TABLE: name="stuff" schema="" table="stuff" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE stuff" +== 022 +-- truncate_limit: 100 +-- implicit casting + +CREATE TYPE person_type AS (id int, name text) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE person_type AS (id int, name text)" +== 023 +-- truncate_limit: 100 +CREATE TABLE persons OF person_type +-- +TABLE: name="persons" schema="" table="persons" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE persons OF person_type" +== 024 +-- truncate_limit: 100 +INSERT INTO persons VALUES (1, 'test') +-- +TABLE: name="persons" schema="" table="persons" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO persons VALUES (1, 'test')" +== 025 +-- truncate_limit: 100 +CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$ +-- +FUNCTION: name="namelen" function="namelen" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE sql AS $$ SELECT length($1.name) $$" +== 026 +-- truncate_limit: 100 +SELECT id, namelen(persons) FROM persons +-- +TABLE: name="persons" schema="" table="persons" ctx=Select +FUNCTION: name="namelen" function="namelen" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT id, namelen(persons) FROM persons" +== 027 +-- truncate_limit: 100 +CREATE TABLE persons2 OF person_type ( + id WITH OPTIONS PRIMARY KEY, + UNIQUE (name) +) +-- +TABLE: name="persons2" schema="" table="persons2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE persons2 OF person_type (id PRIMARY KEY, UNIQUE (name))" +== 028 +-- truncate_limit: 100 +CREATE TABLE persons3 OF person_type ( + PRIMARY KEY (id), + name NOT NULL DEFAULT '' +) +-- +TABLE: name="persons3" schema="" table="persons3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE persons3 OF person_type (PRIMARY KEY (id), name NOT NULL DEFAULT '')" diff --git a/parser/testdata/summary_truncate/postgres_regress/unicode.metadata.json b/parser/testdata/summary_truncate/postgres_regress/unicode.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/unicode.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/unicode.test b/parser/testdata/summary_truncate/postgres_regress/unicode.test new file mode 100644 index 0000000..6aa9c63 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/unicode.test @@ -0,0 +1,134 @@ +== 001 +-- truncate_limit: 100 +SELECT getdatabaseencoding() <> 'UTF8' AS skip_test +-- +FUNCTION: name="getdatabaseencoding" function="getdatabaseencoding" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT getdatabaseencoding() <> 'UTF8' AS skip_test" +== 002 +-- truncate_limit: 100 +SELECT U&'\0061\0308bc' <> U&'\00E4bc' COLLATE "C" AS sanity_check +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'äbc' <> 'äbc' COLLATE \"C\" AS sanity_check" +== 003 +-- truncate_limit: 100 +SELECT unicode_version() IS NOT NULL +-- +FUNCTION: name="unicode_version" function="unicode_version" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unicode_version() IS NOT NULL" +== 004 +-- truncate_limit: 100 +SELECT unicode_assigned(U&'abc') +-- +FUNCTION: name="unicode_assigned" function="unicode_assigned" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unicode_assigned('abc')" +== 005 +-- truncate_limit: 100 +SELECT unicode_assigned(U&'abc\+10FFFF') +-- +FUNCTION: name="unicode_assigned" function="unicode_assigned" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT unicode_assigned('abc\U0010ffff')" +== 006 +-- truncate_limit: 100 +SELECT normalize('') +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT normalize ('')" +== 007 +-- truncate_limit: 100 +SELECT normalize(U&'\0061\0308\24D1c') = U&'\00E4\24D1c' COLLATE "C" AS test_default +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT normalize ('äⓑc') = 'äⓑc' COLLATE \"C\" AS test_default" +== 008 +-- truncate_limit: 100 +SELECT normalize(U&'\0061\0308\24D1c', NFC) = U&'\00E4\24D1c' COLLATE "C" AS test_nfc +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT normalize ('äⓑc', NFC) = 'äⓑc' COLLATE \"C\" AS test_nfc" +== 009 +-- truncate_limit: 100 +SELECT normalize(U&'\00E4bc', NFC) = U&'\00E4bc' COLLATE "C" AS test_nfc_idem +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT normalize ('äbc', NFC) = 'äbc' COLLATE \"C\" AS test_nfc_idem" +== 010 +-- truncate_limit: 100 +SELECT normalize(U&'\00E4\24D1c', NFD) = U&'\0061\0308\24D1c' COLLATE "C" AS test_nfd +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT normalize ('äⓑc', NFD) = 'äⓑc' COLLATE \"C\" AS test_nfd" +== 011 +-- truncate_limit: 100 +SELECT normalize(U&'\0061\0308\24D1c', NFKC) = U&'\00E4bc' COLLATE "C" AS test_nfkc +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT normalize ('äⓑc', NFKC) = 'äbc' COLLATE \"C\" AS test_nfkc" +== 012 +-- truncate_limit: 100 +SELECT normalize(U&'\00E4\24D1c', NFKD) = U&'\0061\0308bc' COLLATE "C" AS test_nfkd +-- +FUNCTION: name="pg_catalog.normalize" function="normalize" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT normalize ('äⓑc', NFKD) = 'äbc' COLLATE \"C\" AS test_nfkd" +== 013 +-- truncate_limit: 100 +SELECT "normalize"('abc', 'def') +-- +FUNCTION: name="normalize" function="normalize" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT \"normalize\"('abc', 'def')" +== 014 +-- truncate_limit: 100 +-- run-time error + +SELECT U&'\00E4\24D1c' IS NORMALIZED AS test_default +-- +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'äⓑc' IS NORMALIZED AS test_default" +== 015 +-- truncate_limit: 100 +SELECT U&'\00E4\24D1c' IS NFC NORMALIZED AS test_nfc +-- +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT 'äⓑc' IS NFC NORMALIZED AS test_nfc" +== 016 +-- truncate_limit: 100 +SELECT num, val, + val IS NFC NORMALIZED AS NFC, + val IS NFD NORMALIZED AS NFD, + val IS NFKC NORMALIZED AS NFKC, + val IS NFKD NORMALIZED AS NFKD +FROM + (VALUES (1, U&'\00E4bc'), + (2, U&'\0061\0308bc'), + (3, U&'\00E4\24D1c'), + (4, U&'\0061\0308\24D1c'), + (5, '')) vals (num, val) +ORDER BY num +-- +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +FUNCTION: name="pg_catalog.is_normalized" function="is_normalized" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) vals(num, val) ORDER BY num" +== 017 +-- truncate_limit: 100 +SELECT is_normalized('abc', 'def') +-- +FUNCTION: name="is_normalized" function="is_normalized" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT is_normalized('abc', 'def')" diff --git a/parser/testdata/summary_truncate/postgres_regress/union.metadata.json b/parser/testdata/summary_truncate/postgres_regress/union.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/union.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/union.test b/parser/testdata/summary_truncate/postgres_regress/union.test new file mode 100644 index 0000000..ba1d819 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/union.test @@ -0,0 +1,1715 @@ +== 001 +-- truncate_limit: 100 +|-- +-- UNION (also INTERSECT, EXCEPT) +|-- + +-- Simple UNION constructs + +SELECT 1 AS two UNION SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS two UNION SELECT 2 ORDER BY 1" +== 002 +-- truncate_limit: 100 +SELECT 1 AS one UNION SELECT 1 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one UNION SELECT 1 ORDER BY 1" +== 003 +-- truncate_limit: 100 +SELECT 1 AS two UNION ALL SELECT 2 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS two UNION ALL SELECT 2" +== 004 +-- truncate_limit: 100 +SELECT 1 AS two UNION ALL SELECT 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS two UNION ALL SELECT 1" +== 005 +-- truncate_limit: 100 +SELECT 1 AS three UNION SELECT 2 UNION SELECT 3 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1 AS three UNION SELECT 2) UNION SELECT 3 ORDER BY 1" +== 006 +-- truncate_limit: 100 +SELECT 1 AS two UNION SELECT 2 UNION SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1 AS two UNION SELECT 2) UNION SELECT 2 ORDER BY 1" +== 007 +-- truncate_limit: 100 +SELECT 1 AS three UNION SELECT 2 UNION ALL SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1 AS three UNION SELECT 2) UNION ALL SELECT 2 ORDER BY 1" +== 008 +-- truncate_limit: 100 +SELECT 1.1 AS two UNION SELECT 2.2 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1.1 AS two UNION SELECT 2.2 ORDER BY 1" +== 009 +-- truncate_limit: 100 +-- Mixed types + +SELECT 1.1 AS two UNION SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1.1 AS two UNION SELECT 2 ORDER BY 1" +== 010 +-- truncate_limit: 100 +SELECT 1 AS two UNION SELECT 2.2 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS two UNION SELECT 2.2 ORDER BY 1" +== 011 +-- truncate_limit: 100 +SELECT 1 AS one UNION SELECT 1.0::float8 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1 AS one UNION SELECT (1.0)::float8 ORDER BY 1" +== 012 +-- truncate_limit: 100 +SELECT 1.1 AS two UNION ALL SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1.1 AS two UNION ALL SELECT 2 ORDER BY 1" +== 013 +-- truncate_limit: 100 +SELECT 1.0::float8 AS two UNION ALL SELECT 1 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT (1.0)::float8 AS two UNION ALL SELECT 1 ORDER BY 1" +== 014 +-- truncate_limit: 100 +SELECT 1.1 AS three UNION SELECT 2 UNION SELECT 3 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1.1 AS three UNION SELECT 2) UNION SELECT 3 ORDER BY 1" +== 015 +-- truncate_limit: 100 +SELECT 1.1::float8 AS two UNION SELECT 2 UNION SELECT 2.0::float8 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT (1.1)::float8 AS two UNION SELECT 2) UNION SELECT (2.0)::float8 ORDER BY 1" +== 016 +-- truncate_limit: 100 +SELECT 1.1 AS three UNION SELECT 2 UNION ALL SELECT 2 ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1.1 AS three UNION SELECT 2) UNION ALL SELECT 2 ORDER BY 1" +== 017 +-- truncate_limit: 100 +SELECT 1.1 AS two UNION (SELECT 2 UNION ALL SELECT 2) ORDER BY 1 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 1.1 AS two UNION (SELECT 2 UNION ALL SELECT 2) ORDER BY 1" +== 018 +-- truncate_limit: 100 +|-- +-- Try testing from tables... +|-- + +SELECT f1 AS five FROM FLOAT8_TBL +UNION +SELECT f1 FROM FLOAT8_TBL +ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS five FROM float8_tbl UNION SELECT f1 FROM float8_tbl ORDER BY 1" +== 019 +-- truncate_limit: 100 +SELECT f1 AS ten FROM FLOAT8_TBL +UNION ALL +SELECT f1 FROM FLOAT8_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS ten FROM float8_tbl UNION ALL SELECT f1 FROM float8_tbl" +== 020 +-- truncate_limit: 100 +SELECT f1 AS nine FROM FLOAT8_TBL +UNION +SELECT f1 FROM INT4_TBL +ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS nine FROM float8_tbl UNION SELECT f1 FROM int4_tbl ORDER BY 1" +== 021 +-- truncate_limit: 100 +SELECT f1 AS ten FROM FLOAT8_TBL +UNION ALL +SELECT f1 FROM INT4_TBL +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS ten FROM float8_tbl UNION ALL SELECT f1 FROM int4_tbl" +== 022 +-- truncate_limit: 100 +SELECT f1 AS five FROM FLOAT8_TBL + WHERE f1 BETWEEN -1e6 AND 1e6 +UNION +SELECT f1 FROM INT4_TBL + WHERE f1 BETWEEN 0 AND 1000000 +ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS five FROM float8_tbl WHERE ... UNION SELECT f1 FROM int4_tbl WHERE ... ORDER BY 1" +== 023 +-- truncate_limit: 100 +SELECT CAST(f1 AS char(4)) AS three FROM VARCHAR_TBL +UNION +SELECT f1 FROM CHAR_TBL +ORDER BY 1 +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1::char(4) AS three FROM varchar_tbl UNION SELECT f1 FROM char_tbl ORDER BY 1" +== 024 +-- truncate_limit: 100 +SELECT f1 AS three FROM VARCHAR_TBL +UNION +SELECT CAST(f1 AS varchar) FROM CHAR_TBL +ORDER BY 1 +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS three FROM varchar_tbl UNION SELECT f1::varchar FROM char_tbl ORDER BY 1" +== 025 +-- truncate_limit: 100 +SELECT f1 AS eight FROM VARCHAR_TBL +UNION ALL +SELECT f1 FROM CHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 AS eight FROM varchar_tbl UNION ALL SELECT f1 FROM char_tbl" +== 026 +-- truncate_limit: 100 +SELECT f1 AS five FROM TEXT_TBL +UNION +SELECT f1 FROM VARCHAR_TBL +UNION +SELECT TRIM(TRAILING FROM f1) FROM CHAR_TBL +ORDER BY 1 +-- +TABLE: name="text_tbl" schema="" table="text_tbl" ctx=Select +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="char_tbl" schema="" table="char_tbl" ctx=Select +FUNCTION: name="pg_catalog.rtrim" function="rtrim" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "(SELECT ... FROM text_tbl UNION SELECT f1 FROM varchar_tbl) UNION SELECT ... FROM char_tbl ORDER ..." +== 027 +-- truncate_limit: 100 +|-- +-- INTERSECT and EXCEPT +|-- + +SELECT q2 FROM int8_tbl INTERSECT SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q2 FROM int8_tbl INTERSECT SELECT q1 FROM int8_tbl ORDER BY 1" +== 028 +-- truncate_limit: 100 +SELECT q2 FROM int8_tbl INTERSECT ALL SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q2 FROM int8_tbl INTERSECT ALL SELECT q1 FROM int8_tbl ORDER BY 1" +== 029 +-- truncate_limit: 100 +SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1" +== 030 +-- truncate_limit: 100 +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q2 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl ORDER BY 1" +== 031 +-- truncate_limit: 100 +SELECT q2 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q2 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q1 FROM int8_tbl ORDER BY 1" +== 032 +-- truncate_limit: 100 +SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY 1" +== 033 +-- truncate_limit: 100 +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q2 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q2 FROM int8_tbl ORDER BY 1" +== 034 +-- truncate_limit: 100 +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q2 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q2 FROM int8_tbl ORDER BY 1" +== 035 +-- truncate_limit: 100 +SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl FOR NO KEY UPDATE +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl FOR NO KEY UPDATE" +== 036 +-- truncate_limit: 100 +-- nested cases +(SELECT 1,2,3 UNION SELECT 4,5,6) INTERSECT SELECT 4,5,6 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1, 2, 3 UNION SELECT 4, 5, 6) INTERSECT SELECT 4, 5, 6" +== 037 +-- truncate_limit: 100 +(SELECT 1,2,3 UNION SELECT 4,5,6 ORDER BY 1,2) INTERSECT SELECT 4,5,6 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1, 2, 3 UNION SELECT 4, 5, 6 ORDER BY 1, 2) INTERSECT SELECT 4, 5, 6" +== 038 +-- truncate_limit: 100 +(SELECT 1,2,3 UNION SELECT 4,5,6) EXCEPT SELECT 4,5,6 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1, 2, 3 UNION SELECT 4, 5, 6) EXCEPT SELECT 4, 5, 6" +== 039 +-- truncate_limit: 100 +(SELECT 1,2,3 UNION SELECT 4,5,6 ORDER BY 1,2) EXCEPT SELECT 4,5,6 +-- +STMT: SelectStmt +TRUNCATED: "(SELECT 1, 2, 3 UNION SELECT 4, 5, 6 ORDER BY 1, 2) EXCEPT SELECT 4, 5, 6" +== 040 +-- truncate_limit: 100 +-- exercise both hashed and sorted implementations of UNION/INTERSECT/EXCEPT + +set enable_hashagg to on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO ON" +== 041 +-- truncate_limit: 100 +explain (costs off) +select count(*) from + ( select unique1 from tenk1 union select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM (SELECT unique1 FROM tenk1 UNION SELECT fivethous FROM t..." +== 042 +-- truncate_limit: 100 +select count(*) from + ( select unique1 from tenk1 union select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT unique1 FROM tenk1 UNION SELECT fivethous FROM tenk1) ss" +== 043 +-- truncate_limit: 100 +explain (costs off) +select count(*) from + ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM (SELECT unique1 FROM tenk1 INTERSECT SELECT fivethous FR..." +== 044 +-- truncate_limit: 100 +select count(*) from + ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT unique1 FROM tenk1 INTERSECT SELECT fivethous FROM tenk1) ss" +== 045 +-- truncate_limit: 100 +explain (costs off) +select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 EXCEPT SELECT unique2 FROM tenk1 WHERE unique2 <> 10" +== 046 +-- truncate_limit: 100 +select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 EXCEPT SELECT unique2 FROM tenk1 WHERE unique2 <> 10" +== 047 +-- truncate_limit: 100 +set enable_hashagg to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 048 +-- truncate_limit: 100 +explain (costs off) +select count(*) from + ( select unique1 from tenk1 union select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM (SELECT unique1 FROM tenk1 UNION SELECT fivethous FROM t..." +== 049 +-- truncate_limit: 100 +select count(*) from + ( select unique1 from tenk1 union select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT unique1 FROM tenk1 UNION SELECT fivethous FROM tenk1) ss" +== 050 +-- truncate_limit: 100 +explain (costs off) +select count(*) from + ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) FROM (SELECT unique1 FROM tenk1 INTERSECT SELECT fivethous FR..." +== 051 +-- truncate_limit: 100 +select count(*) from + ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (SELECT unique1 FROM tenk1 INTERSECT SELECT fivethous FROM tenk1) ss" +== 052 +-- truncate_limit: 100 +explain (costs off) +select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT unique1 FROM tenk1 EXCEPT SELECT unique2 FROM tenk1 WHERE unique2 <> 10" +== 053 +-- truncate_limit: 100 +select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT unique1 FROM tenk1 EXCEPT SELECT unique2 FROM tenk1 WHERE unique2 <> 10" +== 054 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 055 +-- truncate_limit: 100 +-- non-hashable type +set enable_hashagg to on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO ON" +== 056 +-- truncate_limit: 100 +explain (costs off) +select x from (values ('11'::varbit), ('10'::varbit)) _(x) union select x from (values ('11'::varbit), ('10'::varbit)) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES ('11'::varbit), ('10'::varbit)) _(x) UNION SELECT x FRO..." +== 057 +-- truncate_limit: 100 +set enable_hashagg to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 058 +-- truncate_limit: 100 +explain (costs off) +select x from (values ('11'::varbit), ('10'::varbit)) _(x) union select x from (values ('11'::varbit), ('10'::varbit)) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES ('11'::varbit), ('10'::varbit)) _(x) UNION SELECT x FRO..." +== 059 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 060 +-- truncate_limit: 100 +-- arrays +set enable_hashagg to on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO ON" +== 061 +-- truncate_limit: 100 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 3])) _(x) UNION SELECT x FROM ..." +== 062 +-- truncate_limit: 100 +select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) UNION SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 4])) _(x)" +== 063 +-- truncate_limit: 100 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 3])) _(x) INTERSECT SELECT x F..." +== 064 +-- truncate_limit: 100 +select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) INTERSECT SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 4])) _(x)" +== 065 +-- truncate_limit: 100 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 3])) _(x) EXCEPT SELECT x FROM..." +== 066 +-- truncate_limit: 100 +select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) EXCEPT SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 4])) _(x)" +== 067 +-- truncate_limit: 100 +-- non-hashable type +explain (costs off) +select x from (values (array['10'::varbit]), (array['11'::varbit])) _(x) union select x from (values (array['10'::varbit]), (array['01'::varbit])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ARRAY['10'::varbit]), (ARRAY['11'::varbit])) _(x) UNIO..." +== 068 +-- truncate_limit: 100 +select x from (values (array['10'::varbit]), (array['11'::varbit])) _(x) union select x from (values (array['10'::varbit]), (array['01'::varbit])) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) UNION SELECT x FROM (VALUES (...)) _(x)" +== 069 +-- truncate_limit: 100 +set enable_hashagg to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 070 +-- truncate_limit: 100 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 3])) _(x) UNION SELECT x FROM ..." +== 071 +-- truncate_limit: 100 +select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) UNION SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 4])) _(x)" +== 072 +-- truncate_limit: 100 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 3])) _(x) INTERSECT SELECT x F..." +== 073 +-- truncate_limit: 100 +select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) INTERSECT SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 4])) _(x)" +== 074 +-- truncate_limit: 100 +explain (costs off) +select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 3])) _(x) EXCEPT SELECT x FROM..." +== 075 +-- truncate_limit: 100 +select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) EXCEPT SELECT x FROM (VALUES (ARRAY[1, 2]), (ARRAY[1, 4])) _(x)" +== 076 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 077 +-- truncate_limit: 100 +-- records +set enable_hashagg to on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO ON" +== 078 +-- truncate_limit: 100 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 3))) _(x) UNION SELECT x FROM (VAL..." +== 079 +-- truncate_limit: 100 +select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) UNION SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 4))) _(x)" +== 080 +-- truncate_limit: 100 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 3))) _(x) INTERSECT SELECT x FROM ..." +== 081 +-- truncate_limit: 100 +select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) INTERSECT SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 4))) _(x)" +== 082 +-- truncate_limit: 100 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 3))) _(x) EXCEPT SELECT x FROM (VA..." +== 083 +-- truncate_limit: 100 +select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) EXCEPT SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 4))) _(x)" +== 084 +-- truncate_limit: 100 +-- non-hashable type + +-- With an anonymous row type, the typcache does not report that the +-- type is hashable. (Otherwise, this would fail at execution time.) +explain (costs off) +select x from (values (row('10'::varbit)), (row('11'::varbit))) _(x) union select x from (values (row('10'::varbit)), (row('01'::varbit))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ROW('10'::varbit)), (ROW('11'::varbit))) _(x) UNION SE..." +== 085 +-- truncate_limit: 100 +select x from (values (row('10'::varbit)), (row('11'::varbit))) _(x) union select x from (values (row('10'::varbit)), (row('01'::varbit))) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) UNION SELECT x FROM (VALUES (...)) _(x)" +== 086 +-- truncate_limit: 100 +-- With a defined row type, the typcache can inspect the type's fields +-- for hashability. +create type ct1 as (f1 varbit) +-- +STMT: CompositeTypeStmt +TRUNCATED: "CREATE TYPE ct1 AS (f1 varbit)" +== 087 +-- truncate_limit: 100 +explain (costs off) +select x from (values (row('10'::varbit)::ct1), (row('11'::varbit)::ct1)) _(x) union select x from (values (row('10'::varbit)::ct1), (row('01'::varbit)::ct1)) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ROW('10'::varbit)::ct1), (ROW('11'::varbit)::ct1)) _(x..." +== 088 +-- truncate_limit: 100 +select x from (values (row('10'::varbit)::ct1), (row('11'::varbit)::ct1)) _(x) union select x from (values (row('10'::varbit)::ct1), (row('01'::varbit)::ct1)) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) UNION SELECT x FROM (VALUES (...)) _(x)" +== 089 +-- truncate_limit: 100 +drop type ct1 +-- +STMT: DropStmt +TRUNCATED: "DROP TYPE ct1" +== 090 +-- truncate_limit: 100 +set enable_hashagg to off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 091 +-- truncate_limit: 100 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 3))) _(x) UNION SELECT x FROM (VAL..." +== 092 +-- truncate_limit: 100 +select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) UNION SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 4))) _(x)" +== 093 +-- truncate_limit: 100 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 3))) _(x) INTERSECT SELECT x FROM ..." +== 094 +-- truncate_limit: 100 +select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) INTERSECT SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 4))) _(x)" +== 095 +-- truncate_limit: 100 +explain (costs off) +select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 3))) _(x) EXCEPT SELECT x FROM (VA..." +== 096 +-- truncate_limit: 100 +select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x) +-- +STMT: SelectStmt +TRUNCATED: "SELECT x FROM (VALUES (...)) _(x) EXCEPT SELECT x FROM (VALUES (ROW(1, 2)), (ROW(1, 4))) _(x)" +== 097 +-- truncate_limit: 100 +-- non-sortable type + +-- Ensure we get a HashAggregate plan. Keep enable_hashagg=off to ensure +-- there's no chance of a sort. +explain (costs off) select '123'::xid union select '123'::xid +-- +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT '123'::xid UNION SELECT '123'::xid" +== 098 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 099 +-- truncate_limit: 100 +|-- +-- Mixed types +|-- + +SELECT f1 FROM float8_tbl INTERSECT SELECT f1 FROM int4_tbl ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM float8_tbl INTERSECT SELECT f1 FROM int4_tbl ORDER BY 1" +== 100 +-- truncate_limit: 100 +SELECT f1 FROM float8_tbl EXCEPT SELECT f1 FROM int4_tbl ORDER BY 1 +-- +TABLE: name="float8_tbl" schema="" table="float8_tbl" ctx=Select +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT f1 FROM float8_tbl EXCEPT SELECT f1 FROM int4_tbl ORDER BY 1" +== 101 +-- truncate_limit: 100 +|-- +-- Operator precedence and (((((extra))))) parentheses +|-- + +SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl) UNION ALL SELECT q2 FROM int8_tbl ORD..." +== 102 +-- truncate_limit: 100 +SELECT q1 FROM int8_tbl INTERSECT (((SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM int8_tbl INTERSECT (SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl) ORD..." +== 103 +-- truncate_limit: 100 +(((SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl ORDER BY 1))) UNION ALL SELECT q2 FROM int8_tbl +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl ORDER BY 1) UNION ALL SELECT q2 FROM i..." +== 104 +-- truncate_limit: 100 +SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl) EXCEPT SELECT q1 FROM int8_tbl ORDER ..." +== 105 +-- truncate_limit: 100 +SELECT q1 FROM int8_tbl UNION ALL (((SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1))) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM int8_tbl UNION ALL (SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER B..." +== 106 +-- truncate_limit: 100 +(((SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "(SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl) EXCEPT SELECT q1 FROM int8_tbl ORDER ..." +== 107 +-- truncate_limit: 100 +|-- +-- Subqueries with ORDER BY & LIMIT clauses +|-- + +-- In this syntax, ORDER BY/LIMIT apply to the result of the EXCEPT +SELECT q1,q2 FROM int8_tbl EXCEPT SELECT q2,q1 FROM int8_tbl +ORDER BY q2,q1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1, q2 FROM int8_tbl EXCEPT SELECT q2, q1 FROM int8_tbl ORDER BY q2, q1" +== 108 +-- truncate_limit: 100 +-- This should fail, because q2 isn't a name of an EXCEPT output column +SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1" +== 109 +-- truncate_limit: 100 +-- But this should work: +SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))) ORDER BY 1 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM int8_tbl EXCEPT (SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1) ORDER BY 1" +== 110 +-- truncate_limit: 100 +|-- +-- New syntaxes (7.1) permit new tests +|-- + +(((((select * from int8_tbl))))) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM int8_tbl" +== 111 +-- truncate_limit: 100 +|-- +-- Check behavior with empty select list (allowed since 9.4) +|-- + +select union select +-- +STMT: SelectStmt +TRUNCATED: "SELECT UNION SELECT" +== 112 +-- truncate_limit: 100 +select intersect select +-- +STMT: SelectStmt +TRUNCATED: "SELECT INTERSECT SELECT" +== 113 +-- truncate_limit: 100 +select except select +-- +STMT: SelectStmt +TRUNCATED: "SELECT EXCEPT SELECT" +== 114 +-- truncate_limit: 100 +-- check hashed implementation +set enable_hashagg = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO TRUE" +== 115 +-- truncate_limit: 100 +set enable_sort = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO FALSE" +== 116 +-- truncate_limit: 100 +-- We've no way to check hashed UNION as the empty pathkeys in the Append are +-- fine to make use of Unique, which is cheaper than HashAggregate and we've +-- no means to disable Unique. +explain (costs off) +select from generate_series(1,5) intersect select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT FROM generate_series(1, 5) INTERSECT SELECT FROM generate_series(1, 3)" +== 117 +-- truncate_limit: 100 +select from generate_series(1,5) union all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) UNION ALL SELECT FROM generate_series(1, 3)" +== 118 +-- truncate_limit: 100 +select from generate_series(1,5) intersect select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) INTERSECT SELECT FROM generate_series(1, 3)" +== 119 +-- truncate_limit: 100 +select from generate_series(1,5) intersect all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) INTERSECT ALL SELECT FROM generate_series(1, 3)" +== 120 +-- truncate_limit: 100 +select from generate_series(1,5) except select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) EXCEPT SELECT FROM generate_series(1, 3)" +== 121 +-- truncate_limit: 100 +select from generate_series(1,5) except all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) EXCEPT ALL SELECT FROM generate_series(1, 3)" +== 122 +-- truncate_limit: 100 +-- check sorted implementation +set enable_hashagg = false +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO FALSE" +== 123 +-- truncate_limit: 100 +set enable_sort = true +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO TRUE" +== 124 +-- truncate_limit: 100 +explain (costs off) +select from generate_series(1,5) union select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT FROM generate_series(1, 5) UNION SELECT FROM generate_series(1, 3)" +== 125 +-- truncate_limit: 100 +explain (costs off) +select from generate_series(1,5) intersect select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT FROM generate_series(1, 5) INTERSECT SELECT FROM generate_series(1, 3)" +== 126 +-- truncate_limit: 100 +select from generate_series(1,5) union select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) UNION SELECT FROM generate_series(1, 3)" +== 127 +-- truncate_limit: 100 +select from generate_series(1,5) union all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) UNION ALL SELECT FROM generate_series(1, 3)" +== 128 +-- truncate_limit: 100 +select from generate_series(1,5) intersect select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) INTERSECT SELECT FROM generate_series(1, 3)" +== 129 +-- truncate_limit: 100 +select from generate_series(1,5) intersect all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) INTERSECT ALL SELECT FROM generate_series(1, 3)" +== 130 +-- truncate_limit: 100 +select from generate_series(1,5) except select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) EXCEPT SELECT FROM generate_series(1, 3)" +== 131 +-- truncate_limit: 100 +select from generate_series(1,5) except all select from generate_series(1,3) +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT FROM generate_series(1, 5) EXCEPT ALL SELECT FROM generate_series(1, 3)" +== 132 +-- truncate_limit: 100 +-- Try a variation of the above but with a CTE which contains a column, again +-- with an empty final select list. + +-- Ensure we get the expected 1 row with 0 columns +with cte as materialized (select s from generate_series(1,5) s) +select from cte union select from cte +-- +CTE: "cte" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH cte AS MATERIALIZED (...) SELECT FROM cte UNION SELECT FROM cte" +== 133 +-- truncate_limit: 100 +-- Ensure we get the same result as the above. +with cte as not materialized (select s from generate_series(1,5) s) +select from cte union select from cte +-- +CTE: "cte" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH cte AS NOT MATERIALIZED (...) SELECT FROM cte UNION SELECT FROM cte" +== 134 +-- truncate_limit: 100 +reset enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 135 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 136 +-- truncate_limit: 100 +|-- +-- Check handling of a case with unknown constants. We don't guarantee +-- an undecorated constant will work in all cases, but historically this +-- usage has worked, so test we don't break it. +|-- + +SELECT a.f1 FROM (SELECT 'test' AS f1 FROM varchar_tbl) a +UNION +SELECT b.f1 FROM (SELECT f1 FROM varchar_tbl) b +ORDER BY 1 +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM varchar_tbl) a UNION SELECT ... FROM (SELECT f1 FROM varchar_tbl..." +== 137 +-- truncate_limit: 100 +-- This should fail, but it should produce an error cursor +SELECT '3.4'::numeric UNION SELECT 'foo' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '3.4'::numeric UNION SELECT 'foo'" +== 138 +-- truncate_limit: 100 +|-- +-- Test that expression-index constraints can be pushed down through +-- UNION or UNION ALL +|-- + +CREATE TEMP TABLE t1 (a text, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (a text, b text)" +== 139 +-- truncate_limit: 100 +CREATE INDEX t1_ab_idx on t1 ((a || b)) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX t1_ab_idx ON t1 USING btree ((a || b))" +== 140 +-- truncate_limit: 100 +CREATE TEMP TABLE t2 (ab text primary key) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t2 (ab text PRIMARY KEY)" +== 141 +-- truncate_limit: 100 +INSERT INTO t1 VALUES ('a', 'b'), ('x', 'y') +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 VALUES ('a', 'b'), ('x', 'y')" +== 142 +-- truncate_limit: 100 +INSERT INTO t2 VALUES ('ab'), ('xy') +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2 VALUES ('ab'), ('xy')" +== 143 +-- truncate_limit: 100 +set enable_seqscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO OFF" +== 144 +-- truncate_limit: 100 +set enable_indexscan = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexscan TO ON" +== 145 +-- truncate_limit: 100 +set enable_bitmapscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_bitmapscan TO OFF" +== 146 +-- truncate_limit: 100 +set enable_sort = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_sort TO OFF" +== 147 +-- truncate_limit: 100 +explain (costs off) + SELECT * FROM + (SELECT a || b AS ab FROM t1 + UNION ALL + SELECT * FROM t2) t + WHERE ab = 'ab' +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +FILTER: schema="" table="" column="ab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT a || b AS ab FROM t1 UNION ALL SELECT * FROM t2) t WHER..." +== 148 +-- truncate_limit: 100 +explain (costs off) + SELECT * FROM + (SELECT a || b AS ab FROM t1 + UNION + SELECT * FROM t2) t + WHERE ab = 'ab' +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +FILTER: schema="" table="" column="ab" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT a || b AS ab FROM t1 UNION SELECT * FROM t2) t WHERE ab..." +== 149 +-- truncate_limit: 100 +|-- +-- Test that ORDER BY for UNION ALL can be pushed down to inheritance +-- children. +|-- + +CREATE TEMP TABLE t1c (b text, a text) +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1c (b text, a text)" +== 150 +-- truncate_limit: 100 +ALTER TABLE t1c INHERIT t1 +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE t1c INHERIT t1" +== 151 +-- truncate_limit: 100 +CREATE TEMP TABLE t2c (primary key (ab)) INHERITS (t2) +-- +TABLE: name="t2c" schema="" table="t2c" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t2c (PRIMARY KEY (ab)) INHERITS (t2)" +== 152 +-- truncate_limit: 100 +INSERT INTO t1c VALUES ('v', 'w'), ('c', 'd'), ('m', 'n'), ('e', 'f') +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1c VALUES ('v', 'w'), ('c', 'd'), ('m', 'n'), ('e', 'f')" +== 153 +-- truncate_limit: 100 +INSERT INTO t2c VALUES ('vw'), ('cd'), ('mn'), ('ef') +-- +TABLE: name="t2c" schema="" table="t2c" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2c VALUES ('vw'), ('cd'), ('mn'), ('ef')" +== 154 +-- truncate_limit: 100 +CREATE INDEX t1c_ab_idx on t1c ((a || b)) +-- +TABLE: name="t1c" schema="" table="t1c" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX t1c_ab_idx ON t1c USING btree ((a || b))" +== 155 +-- truncate_limit: 100 +set enable_seqscan = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_seqscan TO ON" +== 156 +-- truncate_limit: 100 +set enable_indexonlyscan = off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_indexonlyscan TO OFF" +== 157 +-- truncate_limit: 100 +explain (costs off) + SELECT * FROM + (SELECT a || b AS ab FROM t1 + UNION ALL + SELECT ab FROM t2) t + ORDER BY 1 LIMIT 8 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT a || b AS ab FROM t1 UNION ALL SELECT ab FROM t2) t ORD..." +== 158 +-- truncate_limit: 100 +SELECT * FROM + (SELECT a || b AS ab FROM t1 + UNION ALL + SELECT ab FROM t2) t + ORDER BY 1 LIMIT 8 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT a || b AS ab FROM t1 UNION ALL SELECT ab FROM t2) t ORDER BY 1 LIMIT 8" +== 159 +-- truncate_limit: 100 +reset enable_seqscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_seqscan" +== 160 +-- truncate_limit: 100 +reset enable_indexscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexscan" +== 161 +-- truncate_limit: 100 +reset enable_bitmapscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_bitmapscan" +== 162 +-- truncate_limit: 100 +reset enable_sort +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_sort" +== 163 +-- truncate_limit: 100 +-- This simpler variant of the above test has been observed to fail differently + +create table events (event_id int primary key) +-- +TABLE: name="events" schema="" table="events" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE events (event_id int PRIMARY KEY)" +== 164 +-- truncate_limit: 100 +create table other_events (event_id int primary key) +-- +TABLE: name="other_events" schema="" table="other_events" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE other_events (event_id int PRIMARY KEY)" +== 165 +-- truncate_limit: 100 +create table events_child () inherits (events) +-- +TABLE: name="events_child" schema="" table="events_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE events_child () INHERITS (events)" +== 166 +-- truncate_limit: 100 +explain (costs off) +select event_id + from (select event_id from events + union all + select event_id from other_events) ss + order by event_id +-- +TABLE: name="events" schema="" table="events" ctx=Select +TABLE: name="other_events" schema="" table="other_events" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT event_id FROM (SELECT event_id FROM events UNION ALL SELECT event_id F..." +== 167 +-- truncate_limit: 100 +drop table events_child, events, other_events +-- +TABLE: name="events_child" schema="" table="events_child" ctx=DDL +TABLE: name="events" schema="" table="events" ctx=DDL +TABLE: name="other_events" schema="" table="other_events" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE events_child, events, other_events" +== 168 +-- truncate_limit: 100 +reset enable_indexonlyscan +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_indexonlyscan" +== 169 +-- truncate_limit: 100 +-- Test constraint exclusion of UNION ALL subqueries +explain (costs off) + SELECT * FROM + (SELECT 1 AS t, * FROM tenk1 a + UNION ALL + SELECT 2 AS t, * FROM tenk1 b) c + WHERE t = 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +FILTER: schema="" table="" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT 1 AS t, * FROM tenk1 a UNION ALL SELECT 2 AS t, * FROM ..." +== 170 +-- truncate_limit: 100 +-- Test that we push quals into UNION sub-selects only when it's safe +explain (costs off) +SELECT * FROM + (SELECT 1 AS t, 2 AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x < 4 +ORDER BY x +-- +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT 1 AS t, 2 AS x UNION SELECT 2 AS t, 4 AS x) ss WHERE x ..." +== 171 +-- truncate_limit: 100 +SELECT * FROM + (SELECT 1 AS t, 2 AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x < 4 +ORDER BY x +-- +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT 1 AS t, 2 AS x UNION SELECT 2 AS t, 4 AS x) ss WHERE x < 4 ORDER BY x" +== 172 +-- truncate_limit: 100 +explain (costs off) +SELECT * FROM + (SELECT 1 AS t, generate_series(1,10) AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x < 4 +ORDER BY x +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT 1 AS t, generate_series(1, 10) AS x UNION SELECT 2 AS t..." +== 173 +-- truncate_limit: 100 +SELECT * FROM + (SELECT 1 AS t, generate_series(1,10) AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x < 4 +ORDER BY x +-- +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... UNION SELECT 2 AS t, 4 AS x) ss WHERE x < 4 ORDER BY x" +== 174 +-- truncate_limit: 100 +explain (costs off) +SELECT * FROM + (SELECT 1 AS t, (random()*3)::int AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x > 3 +ORDER BY x +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT 1 AS t, (random() * 3)::int AS x UNION SELECT 2 AS t, 4..." +== 175 +-- truncate_limit: 100 +SELECT * FROM + (SELECT 1 AS t, (random()*3)::int AS x + UNION + SELECT 2 AS t, 4 AS x) ss +WHERE x > 3 +ORDER BY x +-- +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="x" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... UNION SELECT 2 AS t, 4 AS x) ss WHERE x > 3 ORDER BY x" +== 176 +-- truncate_limit: 100 +-- Test cases where the native ordering of a sub-select has more pathkeys +-- than the outer query cares about +explain (costs off) +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where q2 = q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT q1 FROM (SELECT DISTINCT * FROM int8_tbl i81 UNION ALL SELECT..." +== 177 +-- truncate_limit: 100 +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where q2 = q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT q1 FROM (SELECT DISTINCT * FROM int8_tbl i81 UNION ALL SELECT DISTINCT * FROM int..." +== 178 +-- truncate_limit: 100 +explain (costs off) +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where -q1 = q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT q1 FROM (SELECT DISTINCT * FROM int8_tbl i81 UNION ALL SELECT..." +== 179 +-- truncate_limit: 100 +select distinct q1 from + (select distinct * from int8_tbl i81 + union all + select distinct * from int8_tbl i82) ss +where -q1 = q2 +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i81"="int8_tbl" +ALIAS: "i82"="int8_tbl" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT DISTINCT q1 FROM (SELECT DISTINCT * FROM int8_tbl i81 UNION ALL SELECT DISTINCT * FROM int..." +== 180 +-- truncate_limit: 100 +-- Test proper handling of parameterized appendrel paths when the +-- potential join qual is expensive +create function expensivefunc(int) returns int +language plpgsql immutable strict cost 10000 +as $$begin return $1; end$$ +-- +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION expensivefunc(int) RETURNS int LANGUAGE plpgsql IMMUTABLE RETURNS NULL ON NULL IN..." +== 181 +-- truncate_limit: 100 +create temp table t3 as select generate_series(-1000,1000) as x +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE t3 AS SELECT generate_series(-1000, 1000) AS x" +== 182 +-- truncate_limit: 100 +create index t3i on t3 (expensivefunc(x)) +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX t3i ON t3 USING btree (expensivefunc(x))" +== 183 +-- truncate_limit: 100 +analyze t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t3" +== 184 +-- truncate_limit: 100 +explain (costs off) +select * from + (select * from t3 a union all select * from t3 b) ss + join int4_tbl on f1 = expensivefunc(x) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "a"="t3" +ALIAS: "b"="t3" +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT * FROM t3 a UNION ALL SELECT * FROM t3 b) ss JOIN int4_..." +== 185 +-- truncate_limit: 100 +select * from + (select * from t3 a union all select * from t3 b) ss + join int4_tbl on f1 = expensivefunc(x) +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +TABLE: name="t3" schema="" table="t3" ctx=Select +ALIAS: "a"="t3" +ALIAS: "b"="t3" +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT * FROM t3 a UNION ALL SELECT * FROM t3 b) ss JOIN int4_tbl ON f1 = expensiv..." +== 186 +-- truncate_limit: 100 +drop table t3 +-- +TABLE: name="t3" schema="" table="t3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t3" +== 187 +-- truncate_limit: 100 +drop function expensivefunc(int) +-- +FUNCTION: name="expensivefunc" function="expensivefunc" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION expensivefunc(int)" +== 188 +-- truncate_limit: 100 +-- Test handling of appendrel quals that const-simplify into an AND +explain (costs off) +select * from + (select *, 0 as x from int8_tbl a + union all + select *, 1 as x from int8_tbl b) ss +where (x = 0) or (q1 >= q2 and q1 <= q2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT *, 0 AS x FROM int8_tbl a UNION ALL SELECT *, 1 AS x FR..." +== 189 +-- truncate_limit: 100 +select * from + (select *, 0 as x from int8_tbl a + union all + select *, 1 as x from int8_tbl b) ss +where (x = 0) or (q1 >= q2 and q1 <= q2) +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "a"="int8_tbl" +ALIAS: "b"="int8_tbl" +FILTER: schema="" table="" column="x" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +FILTER: schema="" table="" column="q1" +FILTER: schema="" table="" column="q2" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM int8_tbl a UNION ALL SELECT ... FROM int8_tbl b) ss WHERE ..." +== 190 +-- truncate_limit: 100 +|-- +-- Test the planner's ability to produce cheap startup plans with Append nodes +|-- + +-- Ensure we get a Nested Loop join between tenk1 and tenk2 +explain (costs off) +select t1.unique1 from tenk1 t1 +inner join tenk2 t2 on t1.tenthous = t2.tenthous and t2.thousand = 0 + union all +(values(1)) limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT t1.unique1 FROM tenk1 t1 JOIN tenk2 t2 ON t1.tenthous = t2.tenthous AN..." +== 191 +-- truncate_limit: 100 +-- Ensure there is no problem if cheapest_startup_path is NULL +explain (costs off) +select * from tenk1 t1 +left join lateral + (select t1.tenthous from tenk2 t2 union all (values(1))) +on true limit 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM tenk1 t1 LEFT JOIN LATERAL (SELECT t1.tenthous FROM tenk2 t2 UN..." diff --git a/parser/testdata/summary_truncate/postgres_regress/updatable_views.metadata.json b/parser/testdata/summary_truncate/postgres_regress/updatable_views.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/updatable_views.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/updatable_views.test b/parser/testdata/summary_truncate/postgres_regress/updatable_views.test new file mode 100644 index 0000000..672d695 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/updatable_views.test @@ -0,0 +1,9450 @@ +== 001 +-- truncate_limit: 100 +|-- +-- UPDATABLE VIEWS +|-- + +-- avoid bit-exact output here because operations may not be bit-exact. +SET extra_float_digits = 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET extra_float_digits TO 0" +== 002 +-- truncate_limit: 100 +-- check that non-updatable views and columns are rejected with useful error +-- messages + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified')" +== 003 +-- truncate_limit: 100 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i)" +== 004 +-- truncate_limit: 100 +CREATE VIEW ro_view1 AS SELECT DISTINCT a, b FROM base_tbl +-- +TABLE: name="ro_view1" schema="" table="ro_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view1 AS SELECT DISTINCT a, b FROM base_tbl" +== 005 +-- truncate_limit: 100 +-- DISTINCT not supported +CREATE VIEW ro_view2 AS SELECT a, b FROM base_tbl GROUP BY a, b +-- +TABLE: name="ro_view2" schema="" table="ro_view2" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view2 AS SELECT a, b FROM base_tbl GROUP BY a, b" +== 006 +-- truncate_limit: 100 +-- GROUP BY not supported +CREATE VIEW ro_view3 AS SELECT 1 FROM base_tbl HAVING max(a) > 0 +-- +TABLE: name="ro_view3" schema="" table="ro_view3" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view3 AS SELECT 1 FROM base_tbl HAVING max(a) > 0" +== 007 +-- truncate_limit: 100 +-- HAVING not supported +CREATE VIEW ro_view4 AS SELECT count(*) FROM base_tbl +-- +TABLE: name="ro_view4" schema="" table="ro_view4" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view4 AS SELECT count(*) FROM base_tbl" +== 008 +-- truncate_limit: 100 +-- Aggregate functions not supported +CREATE VIEW ro_view5 AS SELECT a, rank() OVER() FROM base_tbl +-- +TABLE: name="ro_view5" schema="" table="ro_view5" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view5 AS SELECT a, rank() OVER () FROM base_tbl" +== 009 +-- truncate_limit: 100 +-- Window functions not supported +CREATE VIEW ro_view6 AS SELECT a, b FROM base_tbl UNION SELECT -a, b FROM base_tbl +-- +TABLE: name="ro_view6" schema="" table="ro_view6" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view6 AS SELECT a, b FROM base_tbl UNION SELECT - a, b FROM base_tbl" +== 010 +-- truncate_limit: 100 +-- Set ops not supported +CREATE VIEW ro_view7 AS WITH t AS (SELECT a, b FROM base_tbl) SELECT * FROM t +-- +TABLE: name="ro_view7" schema="" table="ro_view7" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +CTE: "t" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view7 AS WITH t AS (SELECT a, b FROM base_tbl) SELECT * FROM t" +== 011 +-- truncate_limit: 100 +-- WITH not supported +CREATE VIEW ro_view8 AS SELECT a, b FROM base_tbl ORDER BY a OFFSET 1 +-- +TABLE: name="ro_view8" schema="" table="ro_view8" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view8 AS SELECT a, b FROM base_tbl ORDER BY a OFFSET 1" +== 012 +-- truncate_limit: 100 +-- OFFSET not supported +CREATE VIEW ro_view9 AS SELECT a, b FROM base_tbl ORDER BY a LIMIT 1 +-- +TABLE: name="ro_view9" schema="" table="ro_view9" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view9 AS SELECT a, b FROM base_tbl ORDER BY a LIMIT 1" +== 013 +-- truncate_limit: 100 +-- LIMIT not supported +CREATE VIEW ro_view10 AS SELECT 1 AS a +-- +TABLE: name="ro_view10" schema="" table="ro_view10" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view10 AS SELECT 1 AS a" +== 014 +-- truncate_limit: 100 +-- No base relations +CREATE VIEW ro_view11 AS SELECT b1.a, b2.b FROM base_tbl b1, base_tbl b2 +-- +TABLE: name="ro_view11" schema="" table="ro_view11" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +ALIAS: "b1"="base_tbl" +ALIAS: "b2"="base_tbl" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view11 AS SELECT b1.a, b2.b FROM base_tbl b1, base_tbl b2" +== 015 +-- truncate_limit: 100 +-- Multiple base relations +CREATE VIEW ro_view12 AS SELECT * FROM generate_series(1, 10) AS g(a) +-- +TABLE: name="ro_view12" schema="" table="ro_view12" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view12 AS SELECT * FROM generate_series(1, 10) g(a)" +== 016 +-- truncate_limit: 100 +-- SRF in rangetable +CREATE VIEW ro_view13 AS SELECT a, b FROM (SELECT * FROM base_tbl) AS t +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view13 AS SELECT a, b FROM (SELECT * FROM base_tbl) t" +== 017 +-- truncate_limit: 100 +-- Subselect in rangetable +CREATE VIEW rw_view14 AS SELECT ctid, a, b FROM base_tbl +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view14 AS SELECT ctid, a, b FROM base_tbl" +== 018 +-- truncate_limit: 100 +-- System columns may be part of an updatable view +CREATE VIEW rw_view15 AS SELECT a, upper(b) FROM base_tbl +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view15 AS SELECT a, upper(b) FROM base_tbl" +== 019 +-- truncate_limit: 100 +-- Expression/function may be part of an updatable view +CREATE VIEW rw_view16 AS SELECT a, b, a AS aa FROM base_tbl +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view16 AS SELECT a, b, a AS aa FROM base_tbl" +== 020 +-- truncate_limit: 100 +-- Repeated column may be part of an updatable view +CREATE VIEW ro_view17 AS SELECT * FROM ro_view1 +-- +TABLE: name="ro_view17" schema="" table="ro_view17" ctx=DDL +TABLE: name="ro_view1" schema="" table="ro_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view17 AS SELECT * FROM ro_view1" +== 021 +-- truncate_limit: 100 +-- Base relation not updatable +CREATE VIEW ro_view18 AS SELECT * FROM (VALUES(1)) AS tmp(a) +-- +TABLE: name="ro_view18" schema="" table="ro_view18" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view18 AS SELECT * FROM (VALUES (1)) tmp(a)" +== 022 +-- truncate_limit: 100 +-- VALUES in rangetable +CREATE SEQUENCE uv_seq +-- +STMT: CreateSeqStmt +TRUNCATED: "CREATE SEQUENCE uv_seq" +== 023 +-- truncate_limit: 100 +CREATE VIEW ro_view19 AS SELECT * FROM uv_seq +-- +TABLE: name="ro_view19" schema="" table="ro_view19" ctx=DDL +TABLE: name="uv_seq" schema="" table="uv_seq" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view19 AS SELECT * FROM uv_seq" +== 024 +-- truncate_limit: 100 +-- View based on a sequence +CREATE VIEW ro_view20 AS SELECT a, b, generate_series(1, a) g FROM base_tbl +-- +TABLE: name="ro_view20" schema="" table="ro_view20" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW ro_view20 AS SELECT a, b, generate_series(1, a) AS g FROM base_tbl" +== 025 +-- truncate_limit: 100 +-- SRF in targetlist not supported + +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE E'r_\\\\_view%' ORDER BY table_name" +== 026 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE E'r_\\\\_view%' ORDER BY table_name" +== 027 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 028 +-- truncate_limit: 100 +-- Read-only views +DELETE FROM ro_view1 +-- +TABLE: name="ro_view1" schema="" table="ro_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ro_view1" +== 029 +-- truncate_limit: 100 +DELETE FROM ro_view2 +-- +TABLE: name="ro_view2" schema="" table="ro_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ro_view2" +== 030 +-- truncate_limit: 100 +DELETE FROM ro_view3 +-- +TABLE: name="ro_view3" schema="" table="ro_view3" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ro_view3" +== 031 +-- truncate_limit: 100 +DELETE FROM ro_view4 +-- +TABLE: name="ro_view4" schema="" table="ro_view4" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ro_view4" +== 032 +-- truncate_limit: 100 +DELETE FROM ro_view5 +-- +TABLE: name="ro_view5" schema="" table="ro_view5" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ro_view5" +== 033 +-- truncate_limit: 100 +DELETE FROM ro_view6 +-- +TABLE: name="ro_view6" schema="" table="ro_view6" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ro_view6" +== 034 +-- truncate_limit: 100 +UPDATE ro_view7 SET a=a+1 +-- +TABLE: name="ro_view7" schema="" table="ro_view7" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ro_view7 SET a = a + 1" +== 035 +-- truncate_limit: 100 +UPDATE ro_view8 SET a=a+1 +-- +TABLE: name="ro_view8" schema="" table="ro_view8" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ro_view8 SET a = a + 1" +== 036 +-- truncate_limit: 100 +UPDATE ro_view9 SET a=a+1 +-- +TABLE: name="ro_view9" schema="" table="ro_view9" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ro_view9 SET a = a + 1" +== 037 +-- truncate_limit: 100 +UPDATE ro_view10 SET a=a+1 +-- +TABLE: name="ro_view10" schema="" table="ro_view10" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ro_view10 SET a = a + 1" +== 038 +-- truncate_limit: 100 +UPDATE ro_view11 SET a=a+1 +-- +TABLE: name="ro_view11" schema="" table="ro_view11" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ro_view11 SET a = a + 1" +== 039 +-- truncate_limit: 100 +UPDATE ro_view12 SET a=a+1 +-- +TABLE: name="ro_view12" schema="" table="ro_view12" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ro_view12 SET a = a + 1" +== 040 +-- truncate_limit: 100 +INSERT INTO ro_view13 VALUES (3, 'Row 3') +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ro_view13 VALUES (3, 'Row 3')" +== 041 +-- truncate_limit: 100 +MERGE INTO ro_view13 AS t USING (VALUES (1, 'Row 1')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO ro_view13 t USING (VALUES (1, 'Row 1')) v(a, b) ON t.a = v.a WHEN MATCHED THEN DELETE" +== 042 +-- truncate_limit: 100 +MERGE INTO ro_view13 AS t USING (VALUES (2, 'Row 2')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = v.b +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO ro_view13 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b =..." +== 043 +-- truncate_limit: 100 +MERGE INTO ro_view13 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.b) +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO ro_view13 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VAL..." +== 044 +-- truncate_limit: 100 +MERGE INTO ro_view13 AS t USING (VALUES (2, 'Row 2')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING + WHEN NOT MATCHED THEN DO NOTHING +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO ro_view13 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED THEN DO NOTHING WHE..." +== 045 +-- truncate_limit: 100 +-- should be OK to do nothing +MERGE INTO ro_view13 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING + WHEN NOT MATCHED THEN DO NOTHING +-- +TABLE: name="ro_view13" schema="" table="ro_view13" ctx=DML +ALIAS: "t"="ro_view13" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO ro_view13 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED THEN DO NOTHING WHE..." +== 046 +-- truncate_limit: 100 +-- should be OK to do nothing +-- Partially updatable view +INSERT INTO rw_view14 VALUES (null, 3, 'Row 3') +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view14 VALUES (NULL, 3, 'Row 3')" +== 047 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view14 (a, b) VALUES (3, 'Row 3') +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view14 (a, b) VALUES (3, 'Row 3')" +== 048 +-- truncate_limit: 100 +-- should be OK +UPDATE rw_view14 SET ctid=null WHERE a=3 +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view14 SET ctid = NULL WHERE a = 3" +== 049 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view14 SET b='ROW 3' WHERE a=3 +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view14 SET b = 'ROW 3' WHERE a = 3" +== 050 +-- truncate_limit: 100 +-- should be OK +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 051 +-- truncate_limit: 100 +DELETE FROM rw_view14 WHERE a=3 +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view14 WHERE a = 3" +== 052 +-- truncate_limit: 100 +-- should be OK +MERGE INTO rw_view14 AS t + USING (VALUES (2, 'Merged row 2'), (3, 'Merged row 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = v.b -- should be OK, except... + WHEN NOT MATCHED THEN INSERT VALUES (null, v.a, v.b) +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +ALIAS: "t"="rw_view14" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view14 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b =..." +== 053 +-- truncate_limit: 100 +-- should fail +MERGE INTO rw_view14 AS t + USING (VALUES (2, 'Merged row 2'), (3, 'Merged row 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = v.b -- should be OK + WHEN NOT MATCHED THEN INSERT (a,b) VALUES (v.a, v.b) +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +ALIAS: "t"="rw_view14" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view14 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b =..." +== 054 +-- truncate_limit: 100 +-- should be OK +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a" +== 055 +-- truncate_limit: 100 +MERGE INTO rw_view14 AS t + USING (VALUES (2, 'Row 2'), (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED AND t.a = 2 THEN UPDATE SET b = v.b -- should be OK + WHEN MATCHED AND t.a = 3 THEN DELETE +-- +TABLE: name="rw_view14" schema="" table="rw_view14" ctx=DML +ALIAS: "t"="rw_view14" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view14 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED AND t.a = 2 THEN UP..." +== 056 +-- truncate_limit: 100 +-- should be OK +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a" +== 057 +-- truncate_limit: 100 +-- Partially updatable view +INSERT INTO rw_view15 VALUES (3, 'ROW 3') +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view15 VALUES (3, 'ROW 3')" +== 058 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view15 (a) VALUES (3) +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view15 (a) VALUES (3)" +== 059 +-- truncate_limit: 100 +-- should be OK +INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT DO NOTHING +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT DO NOTHING" +== 060 +-- truncate_limit: 100 +-- succeeds +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view15" +== 061 +-- truncate_limit: 100 +INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO NOTHING +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO NOTHING" +== 062 +-- truncate_limit: 100 +-- succeeds +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view15" +== 063 +-- truncate_limit: 100 +INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO UPDATE set a = excluded.a +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO UPDATE SET a = excluded.a" +== 064 +-- truncate_limit: 100 +-- succeeds +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view15" +== 065 +-- truncate_limit: 100 +INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO UPDATE set upper = 'blarg' +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view15 (a) VALUES (3) ON CONFLICT (a) DO UPDATE SET upper = 'blarg'" +== 066 +-- truncate_limit: 100 +-- fails +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view15" +== 067 +-- truncate_limit: 100 +SELECT * FROM rw_view15 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view15" +== 068 +-- truncate_limit: 100 +ALTER VIEW rw_view15 ALTER COLUMN upper SET DEFAULT 'NOT SET' +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view15 ALTER COLUMN upper SET DEFAULT 'NOT SET'" +== 069 +-- truncate_limit: 100 +INSERT INTO rw_view15 (a) VALUES (4) +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view15 (a) VALUES (4)" +== 070 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view15 SET upper='ROW 3' WHERE a=3 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view15 SET upper = 'ROW 3' WHERE a = 3" +== 071 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view15 SET upper=DEFAULT WHERE a=3 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view15 SET upper = DEFAULT WHERE a = 3" +== 072 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view15 SET a=4 WHERE a=3 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view15 SET a = 4 WHERE a = 3" +== 073 +-- truncate_limit: 100 +-- should be OK +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 074 +-- truncate_limit: 100 +DELETE FROM rw_view15 WHERE a=4 +-- +TABLE: name="rw_view15" schema="" table="rw_view15" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view15 WHERE a = 4" +== 075 +-- truncate_limit: 100 +-- should be OK +-- Partially updatable view +INSERT INTO rw_view16 VALUES (3, 'Row 3', 3) +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view16 VALUES (3, 'Row 3', 3)" +== 076 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view16 (a, b) VALUES (3, 'Row 3') +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view16 (a, b) VALUES (3, 'Row 3')" +== 077 +-- truncate_limit: 100 +-- should be OK +UPDATE rw_view16 SET a=3, aa=-3 WHERE a=3 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view16 SET a = 3, aa = -3 WHERE a = 3" +== 078 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view16 SET aa=-3 WHERE a=3 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view16 SET aa = -3 WHERE a = 3" +== 079 +-- truncate_limit: 100 +-- should be OK +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 080 +-- truncate_limit: 100 +DELETE FROM rw_view16 WHERE a=-3 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view16 WHERE a = -3" +== 081 +-- truncate_limit: 100 +-- should be OK +-- Read-only views +INSERT INTO ro_view17 VALUES (3, 'ROW 3') +-- +TABLE: name="ro_view17" schema="" table="ro_view17" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ro_view17 VALUES (3, 'ROW 3')" +== 082 +-- truncate_limit: 100 +DELETE FROM ro_view18 +-- +TABLE: name="ro_view18" schema="" table="ro_view18" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ro_view18" +== 083 +-- truncate_limit: 100 +MERGE INTO ro_view18 AS t USING (VALUES (1, 'Row 1')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DO NOTHING +-- +TABLE: name="ro_view18" schema="" table="ro_view18" ctx=DML +ALIAS: "t"="ro_view18" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO ro_view18 t USING (VALUES (1, 'Row 1')) v(a, b) ON t.a = v.a WHEN MATCHED THEN DO NOTHING" +== 084 +-- truncate_limit: 100 +-- should be OK to do nothing +UPDATE ro_view19 SET last_value=1000 +-- +TABLE: name="ro_view19" schema="" table="ro_view19" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ro_view19 SET last_value = 1000" +== 085 +-- truncate_limit: 100 +UPDATE ro_view20 SET b=upper(b) +-- +TABLE: name="ro_view20" schema="" table="ro_view20" ctx=DML +FUNCTION: name="upper" function="upper" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE ro_view20 SET b = upper(b)" +== 086 +-- truncate_limit: 100 +-- A view with a conditional INSTEAD rule but no unconditional INSTEAD rules +-- or INSTEAD OF triggers should be non-updatable and generate useful error +-- messages with appropriate detail +CREATE RULE rw_view16_ins_rule AS ON INSERT TO rw_view16 + WHERE NEW.a > 0 DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a, NEW.b) +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view16_ins_rule AS ON INSERT TO rw_view16 WHERE ... DO INSTEAD INSERT INTO base_tb..." +== 087 +-- truncate_limit: 100 +CREATE RULE rw_view16_upd_rule AS ON UPDATE TO rw_view16 + WHERE OLD.a > 0 DO INSTEAD UPDATE base_tbl SET b=NEW.b WHERE a=OLD.a +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view16_upd_rule AS ON UPDATE TO rw_view16 WHERE ... DO INSTEAD UPDATE base_tbl SET..." +== 088 +-- truncate_limit: 100 +CREATE RULE rw_view16_del_rule AS ON DELETE TO rw_view16 + WHERE OLD.a > 0 DO INSTEAD DELETE FROM base_tbl WHERE a=OLD.a +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view16_del_rule AS ON DELETE TO rw_view16 WHERE ... DO INSTEAD DELETE FROM base_tb..." +== 089 +-- truncate_limit: 100 +INSERT INTO rw_view16 (a, b) VALUES (3, 'Row 3') +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view16 (a, b) VALUES (3, 'Row 3')" +== 090 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view16 SET b='ROW 2' WHERE a=2 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view16 SET b = 'ROW 2' WHERE a = 2" +== 091 +-- truncate_limit: 100 +-- should fail +DELETE FROM rw_view16 WHERE a=2 +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view16 WHERE a = 2" +== 092 +-- truncate_limit: 100 +-- should fail +MERGE INTO rw_view16 AS t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.b) +-- +TABLE: name="rw_view16" schema="" table="rw_view16" ctx=DML +ALIAS: "t"="rw_view16" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view16 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VAL..." +== 093 +-- truncate_limit: 100 +-- should fail + +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 094 +-- truncate_limit: 100 +DROP VIEW ro_view10, ro_view12, ro_view18 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW ro_view10, ro_view12, ro_view18" +== 095 +-- truncate_limit: 100 +DROP SEQUENCE uv_seq CASCADE +-- +STMT: DropStmt +TRUNCATED: "DROP SEQUENCE uv_seq CASCADE" +== 096 +-- truncate_limit: 100 +-- simple updatable view + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified')" +== 097 +-- truncate_limit: 100 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i)" +== 098 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a>0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a > 0" +== 099 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT table_name, is_insertable_into FROM information_schema.tables WHERE table_name = 'rw_view1'" +== 100 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name = 'rw_view1'" +== 101 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name = 'rw_view1' + ORDER BY ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name = 'rw_view1' ORDER BY ordinal_position" +== 102 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (3, 'Row 3') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (3, 'Row 3')" +== 103 +-- truncate_limit: 100 +INSERT INTO rw_view1 (a) VALUES (4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (a) VALUES (4)" +== 104 +-- truncate_limit: 100 +UPDATE rw_view1 SET a=5 WHERE a=4 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET a = 5 WHERE a = 4" +== 105 +-- truncate_limit: 100 +DELETE FROM rw_view1 WHERE b='Row 2' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE b = 'Row 2'" +== 106 +-- truncate_limit: 100 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 107 +-- truncate_limit: 100 +MERGE INTO rw_view1 t + USING (VALUES (0, 'ROW 0'), (1, 'ROW 1'), + (2, 'ROW 2'), (3, 'ROW 3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED AND t.a <= 1 THEN UPDATE SET b = v.b + WHEN MATCHED THEN DELETE + WHEN NOT MATCHED AND a > 0 THEN INSERT (a) VALUES (v.a) + RETURNING merge_action(), v.*, t.* +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED AND t.a <= 1 THEN UP..." +== 108 +-- truncate_limit: 100 +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a" +== 109 +-- truncate_limit: 100 +MERGE INTO rw_view1 t + USING (VALUES (0, 'R0'), (1, 'R1'), + (2, 'R2'), (3, 'R3')) AS v(a,b) ON t.a = v.a + WHEN MATCHED AND t.a <= 1 THEN UPDATE SET b = v.b + WHEN MATCHED THEN DELETE + WHEN NOT MATCHED BY SOURCE THEN DELETE + WHEN NOT MATCHED AND a > 0 THEN INSERT (a) VALUES (v.a) + RETURNING merge_action(), v.*, t.* +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED AND t.a <= 1 THEN UP..." +== 110 +-- truncate_limit: 100 +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a" +== 111 +-- truncate_limit: 100 +EXPLAIN (costs off) UPDATE rw_view1 SET a=6 WHERE a=5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view1 SET a = 6 WHERE a = 5" +== 112 +-- truncate_limit: 100 +EXPLAIN (costs off) DELETE FROM rw_view1 WHERE a=5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM rw_view1 WHERE a = 5" +== 113 +-- truncate_limit: 100 +EXPLAIN (costs off) +MERGE INTO rw_view1 t USING (VALUES (5, 'X')) AS v(a,b) ON t.a = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO rw_view1 t USING (VALUES (5, 'X')) v(a, b) ON t.a = v.a WHEN MATCH..." +== 114 +-- truncate_limit: 100 +EXPLAIN (costs off) +MERGE INTO rw_view1 t + USING (SELECT * FROM generate_series(1,5)) AS s(a) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = 'Updated' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO rw_view1 t USING (SELECT * FROM generate_series(1, 5)) s(a) ON t.a..." +== 115 +-- truncate_limit: 100 +EXPLAIN (costs off) +MERGE INTO rw_view1 t + USING (SELECT * FROM generate_series(1,5)) AS s(a) ON t.a = s.a + WHEN NOT MATCHED BY SOURCE THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO rw_view1 t USING (SELECT * FROM generate_series(1, 5)) s(a) ON t.a..." +== 116 +-- truncate_limit: 100 +EXPLAIN (costs off) +MERGE INTO rw_view1 t + USING (SELECT * FROM generate_series(1,5)) AS s(a) ON t.a = s.a + WHEN NOT MATCHED THEN INSERT (a) VALUES (s.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO rw_view1 t USING (SELECT * FROM generate_series(1, 5)) s(a) ON t.a..." +== 117 +-- truncate_limit: 100 +-- it's still updatable if we add a DO ALSO rule + +CREATE TABLE base_tbl_hist(ts timestamptz default now(), a int, b text) +-- +TABLE: name="base_tbl_hist" schema="" table="base_tbl_hist" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl_hist (ts timestamptz DEFAULT now(), a int, b text)" +== 118 +-- truncate_limit: 100 +CREATE RULE base_tbl_log AS ON INSERT TO rw_view1 DO ALSO + INSERT INTO base_tbl_hist(a,b) VALUES(new.a, new.b) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE base_tbl_log AS ON INSERT TO rw_view1 DO INSERT INTO base_tbl_hist (a, b) VALUES (new..." +== 119 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name = 'rw_view1'" +== 120 +-- truncate_limit: 100 +-- Check behavior with DEFAULTs (bug #17633) + +INSERT INTO rw_view1 VALUES (9, DEFAULT), (10, DEFAULT) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (9, DEFAULT), (10, DEFAULT)" +== 121 +-- truncate_limit: 100 +SELECT a, b FROM base_tbl_hist +-- +TABLE: name="base_tbl_hist" schema="" table="base_tbl_hist" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT a, b FROM base_tbl_hist" +== 122 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 123 +-- truncate_limit: 100 +DROP TABLE base_tbl_hist +-- +TABLE: name="base_tbl_hist" schema="" table="base_tbl_hist" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl_hist" +== 124 +-- truncate_limit: 100 +-- view on top of view + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified')" +== 125 +-- truncate_limit: 100 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i)" +== 126 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl WHERE a>0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl WHERE a > 0" +== 127 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS SELECT aa AS aaa, bb AS bbb FROM rw_view1 WHERE aa<10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="aa" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT aa AS aaa, bb AS bbb FROM rw_view1 WHERE aa < 10" +== 128 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT table_name, is_insertable_into FROM information_schema.tables WHERE table_name = 'rw_view2'" +== 129 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name = 'rw_view2'" +== 130 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name = 'rw_view2' + ORDER BY ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name = 'rw_view2' ORDER BY ordinal_position" +== 131 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (3, 'Row 3') +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (3, 'Row 3')" +== 132 +-- truncate_limit: 100 +INSERT INTO rw_view2 (aaa) VALUES (4) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 (aaa) VALUES (4)" +== 133 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 134 +-- truncate_limit: 100 +UPDATE rw_view2 SET bbb='Row 4' WHERE aaa=4 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = 'Row 4' WHERE aaa = 4" +== 135 +-- truncate_limit: 100 +DELETE FROM rw_view2 WHERE aaa=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2 WHERE aaa = 2" +== 136 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 137 +-- truncate_limit: 100 +MERGE INTO rw_view2 t + USING (VALUES (3, 'R3'), (4, 'R4'), (5, 'R5')) AS v(a,b) ON aaa = v.a + WHEN MATCHED AND aaa = 3 THEN DELETE + WHEN MATCHED THEN UPDATE SET bbb = v.b + WHEN NOT MATCHED THEN INSERT (aaa) VALUES (v.a) + RETURNING merge_action(), v.*, t.* +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (...)) v(a, b) ON aaa = v.a WHEN MATCHED AND aaa = 3 THEN DEL..." +== 138 +-- truncate_limit: 100 +SELECT * FROM rw_view2 ORDER BY aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 ORDER BY aaa" +== 139 +-- truncate_limit: 100 +MERGE INTO rw_view2 t + USING (VALUES (4, 'r4'), (5, 'r5'), (6, 'r6')) AS v(a,b) ON aaa = v.a + WHEN MATCHED AND aaa = 4 THEN DELETE + WHEN MATCHED THEN UPDATE SET bbb = v.b + WHEN NOT MATCHED THEN INSERT (aaa) VALUES (v.a) + WHEN NOT MATCHED BY SOURCE THEN UPDATE SET bbb = 'Not matched by source' + RETURNING merge_action(), v.*, t.* +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (...)) v(a, b) ON aaa = v.a WHEN MATCHED AND aaa = 4 THEN DEL..." +== 140 +-- truncate_limit: 100 +SELECT * FROM rw_view2 ORDER BY aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 ORDER BY aaa" +== 141 +-- truncate_limit: 100 +EXPLAIN (costs off) UPDATE rw_view2 SET aaa=5 WHERE aaa=4 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view2 SET aaa = 5 WHERE aaa = 4" +== 142 +-- truncate_limit: 100 +EXPLAIN (costs off) DELETE FROM rw_view2 WHERE aaa=4 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM rw_view2 WHERE aaa = 4" +== 143 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 144 +-- truncate_limit: 100 +-- view on top of view with rules + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified')" +== 145 +-- truncate_limit: 100 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i)" +== 146 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a>0 OFFSET 0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a > 0 OFFSET 0" +== 147 +-- truncate_limit: 100 +-- not updatable without rules/triggers +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a<10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10" +== 148 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 149 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 150 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 151 +-- truncate_limit: 100 +CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 + DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a, NEW.b) RETURNING * +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 DO INSTEAD INSERT INTO base_tbl VALUES (ne..." +== 152 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 153 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 154 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 155 +-- truncate_limit: 100 +CREATE RULE rw_view1_upd_rule AS ON UPDATE TO rw_view1 + DO INSTEAD UPDATE base_tbl SET b=NEW.b WHERE a=OLD.a RETURNING NEW.* +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view1_upd_rule AS ON UPDATE TO rw_view1 DO INSTEAD UPDATE base_tbl SET b = new.b W..." +== 156 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 157 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 158 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 159 +-- truncate_limit: 100 +CREATE RULE rw_view1_del_rule AS ON DELETE TO rw_view1 + DO INSTEAD DELETE FROM base_tbl WHERE a=OLD.a RETURNING OLD.* +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view1_del_rule AS ON DELETE TO rw_view1 DO INSTEAD DELETE FROM base_tbl WHERE a = ..." +== 160 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 161 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 162 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 163 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (3, 'Row 3') RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (3, 'Row 3') RETURNING *" +== 164 +-- truncate_limit: 100 +UPDATE rw_view2 SET b='Row three' WHERE a=3 RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET b = 'Row three' WHERE a = 3 RETURNING *" +== 165 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 166 +-- truncate_limit: 100 +DELETE FROM rw_view2 WHERE a=3 RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2 WHERE a = 3 RETURNING *" +== 167 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 168 +-- truncate_limit: 100 +MERGE INTO rw_view2 t USING (VALUES (3, 'Row 3')) AS v(a,b) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VALU..." +== 169 +-- truncate_limit: 100 +-- should fail + +EXPLAIN (costs off) UPDATE rw_view2 SET a=3 WHERE a=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view2 SET a = 3 WHERE a = 2" +== 170 +-- truncate_limit: 100 +EXPLAIN (costs off) DELETE FROM rw_view2 WHERE a=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM rw_view2 WHERE a = 2" +== 171 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 172 +-- truncate_limit: 100 +-- view on top of view with triggers + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified')" +== 173 +-- truncate_limit: 100 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i)" +== 174 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a>0 OFFSET 0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a > 0 OFFSET 0" +== 175 +-- truncate_limit: 100 +-- not updatable without rules/triggers +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a<10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10" +== 176 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 177 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into, + is_trigger_updatable, is_trigger_deletable, + is_trigger_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 178 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 179 +-- truncate_limit: 100 +CREATE FUNCTION rw_view1_trig_fn() +RETURNS trigger AS +$$ +BEGIN + IF TG_OP = 'INSERT' THEN + INSERT INTO base_tbl VALUES (NEW.a, NEW.b); + RETURN NEW; + ELSIF TG_OP = 'UPDATE' THEN + UPDATE base_tbl SET b=NEW.b WHERE a=OLD.a; + RETURN NEW; + ELSIF TG_OP = 'DELETE' THEN + DELETE FROM base_tbl WHERE a=OLD.a; + RETURN OLD; + END IF; +END; +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rw_view1_trig_fn() RETURNS trigger AS $$\nBEGIN\n IF TG_OP = 'INSERT' THEN\n INS..." +== 180 +-- truncate_limit: 100 +CREATE TRIGGER rw_view1_ins_trig INSTEAD OF INSERT ON rw_view1 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER rw_view1_ins_trig INSTEAD OF INSERT ON rw_view1 FOR EACH ROW EXECUTE FUNCTION rw_v..." +== 181 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 182 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into, + is_trigger_updatable, is_trigger_deletable, + is_trigger_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 183 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 184 +-- truncate_limit: 100 +CREATE TRIGGER rw_view1_upd_trig INSTEAD OF UPDATE ON rw_view1 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER rw_view1_upd_trig INSTEAD OF UPDATE ON rw_view1 FOR EACH ROW EXECUTE FUNCTION rw_v..." +== 185 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 186 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into, + is_trigger_updatable, is_trigger_deletable, + is_trigger_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 187 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 188 +-- truncate_limit: 100 +CREATE TRIGGER rw_view1_del_trig INSTEAD OF DELETE ON rw_view1 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER rw_view1_del_trig INSTEAD OF DELETE ON rw_view1 FOR EACH ROW EXECUTE FUNCTION rw_v..." +== 189 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 190 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into, + is_trigger_updatable, is_trigger_deletable, + is_trigger_insertable_into + FROM information_schema.views + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'rw_view%' ORDER BY table_name" +== 191 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE 'rw_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 192 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (3, 'Row 3') RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (3, 'Row 3') RETURNING *" +== 193 +-- truncate_limit: 100 +UPDATE rw_view2 SET b='Row three' WHERE a=3 RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET b = 'Row three' WHERE a = 3 RETURNING *" +== 194 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 195 +-- truncate_limit: 100 +DELETE FROM rw_view2 WHERE a=3 RETURNING * +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2 WHERE a = 3 RETURNING *" +== 196 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 197 +-- truncate_limit: 100 +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED AND t.a <= 1 THEN DELETE + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) + RETURNING merge_action(), s.*, t.* +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (SELECT ... FROM generate_series(0, 3) x) s(a, b) ON t.a = s.a WHEN M..." +== 198 +-- truncate_limit: 100 +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a" +== 199 +-- truncate_limit: 100 +MERGE INTO rw_view2 t + USING (SELECT x, 'r'||x FROM generate_series(0,2) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) + WHEN NOT MATCHED BY SOURCE THEN UPDATE SET b = 'Not matched by source' + RETURNING merge_action(), s.*, t.* +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (SELECT ... FROM generate_series(0, 2) x) s(a, b) ON t.a = s.a WHEN M..." +== 200 +-- truncate_limit: 100 +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a" +== 201 +-- truncate_limit: 100 +EXPLAIN (costs off) UPDATE rw_view2 SET a=3 WHERE a=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view2 SET a = 3 WHERE a = 2" +== 202 +-- truncate_limit: 100 +EXPLAIN (costs off) DELETE FROM rw_view2 WHERE a=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM rw_view2 WHERE a = 2" +== 203 +-- truncate_limit: 100 +EXPLAIN (costs off) +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED AND t.a <= 1 THEN DELETE + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO rw_view2 t USING (SELECT x, 'R' || x FROM generate_series(0, 3) x)..." +== 204 +-- truncate_limit: 100 +-- MERGE with incomplete set of INSTEAD OF triggers +DROP TRIGGER rw_view1_del_trig ON rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER rw_view1_del_trig ON rw_view1" +== 205 +-- truncate_limit: 100 +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED AND t.a <= 1 THEN DELETE + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (SELECT ... FROM generate_series(0, 3) x) s(a, b) ON t.a = s.a WHEN M..." +== 206 +-- truncate_limit: 100 +-- should fail +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (SELECT ... FROM generate_series(0, 3) x) s(a, b) ON t.a = s.a WHEN M..." +== 207 +-- truncate_limit: 100 +-- ok + +DROP TRIGGER rw_view1_ins_trig ON rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER rw_view1_ins_trig ON rw_view1" +== 208 +-- truncate_limit: 100 +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (SELECT ... FROM generate_series(0, 3) x) s(a, b) ON t.a = s.a WHEN M..." +== 209 +-- truncate_limit: 100 +-- should fail +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (SELECT ... FROM generate_series(0, 3) x) s(a, b) ON t.a = s.a WHEN M..." +== 210 +-- truncate_limit: 100 +-- ok + +-- MERGE with INSTEAD OF triggers on auto-updatable view +CREATE TRIGGER rw_view2_upd_trig INSTEAD OF UPDATE ON rw_view2 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER rw_view2_upd_trig INSTEAD OF UPDATE ON rw_view2 FOR EACH ROW EXECUTE FUNCTION rw_v..." +== 211 +-- truncate_limit: 100 +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b + WHEN NOT MATCHED AND s.a > 0 THEN INSERT VALUES (s.a, s.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (SELECT ... FROM generate_series(0, 3) x) s(a, b) ON t.a = s.a WHEN M..." +== 212 +-- truncate_limit: 100 +-- should fail +MERGE INTO rw_view2 t + USING (SELECT x, 'R'||x FROM generate_series(0,3) x) AS s(a,b) ON t.a = s.a + WHEN MATCHED THEN UPDATE SET b = s.b +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (SELECT ... FROM generate_series(0, 3) x) s(a, b) ON t.a = s.a WHEN M..." +== 213 +-- truncate_limit: 100 +-- ok +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a" +== 214 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 215 +-- truncate_limit: 100 +DROP FUNCTION rw_view1_trig_fn() +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rw_view1_trig_fn()" +== 216 +-- truncate_limit: 100 +-- update using whole row from view + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified')" +== 217 +-- truncate_limit: 100 +INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i)" +== 218 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl" +== 219 +-- truncate_limit: 100 +CREATE FUNCTION rw_view1_aa(x rw_view1) + RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql +-- +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rw_view1_aa(x rw_view1) RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql" +== 220 +-- truncate_limit: 100 +UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2 + RETURNING rw_view1_aa(v), v.bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "v"="rw_view1" +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=Call +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 v SET bb = 'Updated row 2' WHERE rw_view1_aa(v) = 2 RETURNING rw_view1_aa(v), v.bb" +== 221 +-- truncate_limit: 100 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 222 +-- truncate_limit: 100 +EXPLAIN (costs off) +UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2 + RETURNING rw_view1_aa(v), v.bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "v"="rw_view1" +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=Call +FUNCTION: name="rw_view1_aa" function="rw_view1_aa" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view1 v SET bb = 'Updated row 2' WHERE rw_view1_aa(v) = 2 RETURNING..." +== 223 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 224 +-- truncate_limit: 100 +-- permissions checks + +CREATE USER regress_view_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_view_user1" +== 225 +-- truncate_limit: 100 +CREATE USER regress_view_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_view_user2" +== 226 +-- truncate_limit: 100 +CREATE USER regress_view_user3 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_view_user3" +== 227 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 228 +-- truncate_limit: 100 +CREATE TABLE base_tbl(a int, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b text, c double precision)" +== 229 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0)" +== 230 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl" +== 231 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES ('Row 2', 2.0, 2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 2', 2.0, 2)" +== 232 +-- truncate_limit: 100 +GRANT SELECT ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON base_tbl TO regress_view_user2" +== 233 +-- truncate_limit: 100 +GRANT SELECT ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rw_view1 TO regress_view_user2" +== 234 +-- truncate_limit: 100 +GRANT UPDATE (a,c) ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (a, c) ON base_tbl TO regress_view_user2" +== 235 +-- truncate_limit: 100 +GRANT UPDATE (bb,cc) ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (bb, cc) ON rw_view1 TO regress_view_user2" +== 236 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 237 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 238 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl" +== 239 +-- truncate_limit: 100 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 240 +-- truncate_limit: 100 +-- ok +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 241 +-- truncate_limit: 100 +-- ok +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 242 +-- truncate_limit: 100 +-- ok + +INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0)" +== 243 +-- truncate_limit: 100 +-- not allowed +INSERT INTO rw_view1 VALUES ('Row 3', 3.0, 3) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 3', 3.0, 3)" +== 244 +-- truncate_limit: 100 +-- not allowed +INSERT INTO rw_view2 VALUES ('Row 3', 3.0, 3) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES ('Row 3', 3.0, 3)" +== 245 +-- truncate_limit: 100 +-- not allowed + +MERGE INTO rw_view1 t + USING (VALUES ('Row 3', 3.0, 3)) AS v(b,c,a) ON t.aa = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.b, v.c, v.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (...)) v(b, c, a) ON t.aa = v.a WHEN NOT MATCHED THEN INSERT ..." +== 246 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t + USING (VALUES ('Row 3', 3.0, 3)) AS v(b,c,a) ON t.aa = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.b, v.c, v.a) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (...)) v(b, c, a) ON t.aa = v.a WHEN NOT MATCHED THEN INSERT ..." +== 247 +-- truncate_limit: 100 +-- not allowed + +UPDATE base_tbl SET a=a, c=c +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE base_tbl SET a = a, c = c" +== 248 +-- truncate_limit: 100 +-- ok +UPDATE base_tbl SET b=b +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE base_tbl SET b = b" +== 249 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET bb=bb, cc=cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET bb = bb, cc = cc" +== 250 +-- truncate_limit: 100 +-- ok +UPDATE rw_view1 SET aa=aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET aa = aa" +== 251 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET aa=aa, cc=cc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aa = aa, cc = cc" +== 252 +-- truncate_limit: 100 +-- ok +UPDATE rw_view2 SET bb=bb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bb = bb" +== 253 +-- truncate_limit: 100 +-- not allowed + +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET bb = bb, cc = cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET bb = bb,..." +== 254 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET aa = aa" +== 255 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa, cc = cc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET aa = aa,..." +== 256 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET bb = bb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET bb = bb" +== 257 +-- truncate_limit: 100 +-- not allowed + +DELETE FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM base_tbl" +== 258 +-- truncate_limit: 100 +-- not allowed +DELETE FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1" +== 259 +-- truncate_limit: 100 +-- not allowed +DELETE FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2" +== 260 +-- truncate_limit: 100 +-- not allowed +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 261 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 262 +-- truncate_limit: 100 +GRANT INSERT, DELETE ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert, delete ON base_tbl TO regress_view_user2" +== 263 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 264 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 265 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0)" +== 266 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4)" +== 267 +-- truncate_limit: 100 +-- not allowed +INSERT INTO rw_view2 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES ('Row 4', 4.0, 4)" +== 268 +-- truncate_limit: 100 +-- ok +DELETE FROM base_tbl WHERE a=1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM base_tbl WHERE a = 1" +== 269 +-- truncate_limit: 100 +-- ok +DELETE FROM rw_view1 WHERE aa=2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE aa = 2" +== 270 +-- truncate_limit: 100 +-- not allowed +DELETE FROM rw_view2 WHERE aa=2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2 WHERE aa = 2" +== 271 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED AND bb = 'xxx' THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED AND bb = 'xxx' THEN DELETE" +== 272 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED AND bb = 'xxx' THEN DELETE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED AND bb = 'xxx' THEN DELETE" +== 273 +-- truncate_limit: 100 +-- ok +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 274 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 275 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 276 +-- truncate_limit: 100 +REVOKE INSERT, DELETE ON base_tbl FROM regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE insert, delete ON base_tbl FROM regress_view_user2" +== 277 +-- truncate_limit: 100 +GRANT INSERT, DELETE ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert, delete ON rw_view1 TO regress_view_user2" +== 278 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 279 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 280 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (5, 'Row 5', 5.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (5, 'Row 5', 5.0)" +== 281 +-- truncate_limit: 100 +-- not allowed +INSERT INTO rw_view1 VALUES ('Row 5', 5.0, 5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 5', 5.0, 5)" +== 282 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view2 VALUES ('Row 6', 6.0, 6) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES ('Row 6', 6.0, 6)" +== 283 +-- truncate_limit: 100 +-- not allowed +DELETE FROM base_tbl WHERE a=3 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM base_tbl WHERE a = 3" +== 284 +-- truncate_limit: 100 +-- not allowed +DELETE FROM rw_view1 WHERE aa=3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE aa = 3" +== 285 +-- truncate_limit: 100 +-- ok +DELETE FROM rw_view2 WHERE aa=4 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2 WHERE aa = 4" +== 286 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED AND bb = 'xxx' THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED AND bb = 'xxx' THEN DELETE" +== 287 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED AND bb = 'xxx' THEN DELETE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED AND bb = 'xxx' THEN DELETE" +== 288 +-- truncate_limit: 100 +-- not allowed +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 289 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 290 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 291 +-- truncate_limit: 100 +-- nested-view permissions + +CREATE TABLE base_tbl(a int, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b text, c double precision)" +== 292 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0)" +== 293 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 294 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl" +== 295 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 296 +-- truncate_limit: 100 +-- not allowed +SELECT * FROM rw_view1 FOR UPDATE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1 FOR UPDATE" +== 297 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET b = 'foo' WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b = 'foo' WHERE a = 1" +== 298 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'foo'" +== 299 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 300 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT * FROM rw_view1" +== 301 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 302 +-- truncate_limit: 100 +-- not allowed +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 FOR UPDATE" +== 303 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET b = 'bar' WHERE a = 1" +== 304 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'foo'" +== 305 +-- truncate_limit: 100 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 306 +-- truncate_limit: 100 +GRANT SELECT ON base_tbl TO regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON base_tbl TO regress_view_user1" +== 307 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 308 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 309 +-- truncate_limit: 100 +SELECT * FROM rw_view1 FOR UPDATE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1 FOR UPDATE" +== 310 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET b = 'foo' WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b = 'foo' WHERE a = 1" +== 311 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'foo'" +== 312 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 313 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 314 +-- truncate_limit: 100 +-- not allowed +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 FOR UPDATE" +== 315 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET b = 'bar' WHERE a = 1" +== 316 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'foo'" +== 317 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 318 +-- truncate_limit: 100 +GRANT SELECT ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rw_view1 TO regress_view_user2" +== 319 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 320 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 321 +-- truncate_limit: 100 +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 FOR UPDATE" +== 322 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET b = 'bar' WHERE a = 1" +== 323 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'foo'" +== 324 +-- truncate_limit: 100 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 325 +-- truncate_limit: 100 +GRANT UPDATE ON base_tbl TO regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON base_tbl TO regress_view_user1" +== 326 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 327 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 328 +-- truncate_limit: 100 +SELECT * FROM rw_view1 FOR UPDATE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1 FOR UPDATE" +== 329 +-- truncate_limit: 100 +UPDATE rw_view1 SET b = 'foo' WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b = 'foo' WHERE a = 1" +== 330 +-- truncate_limit: 100 +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'foo'" +== 331 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 332 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 333 +-- truncate_limit: 100 +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 FOR UPDATE" +== 334 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET b = 'bar' WHERE a = 1" +== 335 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'bar' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'bar'" +== 336 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 337 +-- truncate_limit: 100 +GRANT UPDATE ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update ON rw_view1 TO regress_view_user2" +== 338 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 339 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 340 +-- truncate_limit: 100 +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 FOR UPDATE" +== 341 +-- truncate_limit: 100 +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET b = 'bar' WHERE a = 1" +== 342 +-- truncate_limit: 100 +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'fud' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'fud'" +== 343 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 344 +-- truncate_limit: 100 +REVOKE UPDATE ON base_tbl FROM regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE update ON base_tbl FROM regress_view_user1" +== 345 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 346 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 347 +-- truncate_limit: 100 +SELECT * FROM rw_view1 FOR UPDATE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1 FOR UPDATE" +== 348 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET b = 'foo' WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b = 'foo' WHERE a = 1" +== 349 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'foo'" +== 350 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 351 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 352 +-- truncate_limit: 100 +SELECT * FROM rw_view2 FOR UPDATE +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 FOR UPDATE" +== 353 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET b = 'bar' WHERE a = 1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET b = 'bar' WHERE a = 1" +== 354 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET b = 'foo' +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = 'foo'" +== 355 +-- truncate_limit: 100 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 356 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 357 +-- truncate_limit: 100 +-- security invoker view permissions + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 358 +-- truncate_limit: 100 +CREATE TABLE base_tbl(a int, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b text, c double precision)" +== 359 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0)" +== 360 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl" +== 361 +-- truncate_limit: 100 +ALTER VIEW rw_view1 SET (security_invoker = true) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view1 SET (security_invoker=true)" +== 362 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES ('Row 2', 2.0, 2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 2', 2.0, 2)" +== 363 +-- truncate_limit: 100 +GRANT SELECT ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rw_view1 TO regress_view_user2" +== 364 +-- truncate_limit: 100 +GRANT UPDATE (bb,cc) ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (bb, cc) ON rw_view1 TO regress_view_user2" +== 365 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 366 +-- truncate_limit: 100 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 367 +-- truncate_limit: 100 +-- not allowed +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 368 +-- truncate_limit: 100 +-- not allowed +INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0)" +== 369 +-- truncate_limit: 100 +-- not allowed +INSERT INTO rw_view1 VALUES ('Row 3', 3.0, 3) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 3', 3.0, 3)" +== 370 +-- truncate_limit: 100 +-- not allowed +UPDATE base_tbl SET a=a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE base_tbl SET a = a" +== 371 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET bb=bb, cc=cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET bb = bb, cc = cc" +== 372 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET bb = bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET bb = bb" +== 373 +-- truncate_limit: 100 +-- not allowed +DELETE FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM base_tbl" +== 374 +-- truncate_limit: 100 +-- not allowed +DELETE FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1" +== 375 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN DELETE" +== 376 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 377 +-- truncate_limit: 100 +GRANT SELECT ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON base_tbl TO regress_view_user2" +== 378 +-- truncate_limit: 100 +GRANT UPDATE (a,c) ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (a, c) ON base_tbl TO regress_view_user2" +== 379 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 380 +-- truncate_limit: 100 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 381 +-- truncate_limit: 100 +-- ok +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 382 +-- truncate_limit: 100 +-- ok +UPDATE base_tbl SET a=a, c=c +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE base_tbl SET a = a, c = c" +== 383 +-- truncate_limit: 100 +-- ok +UPDATE base_tbl SET b=b +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE base_tbl SET b = b" +== 384 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET cc=cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET cc = cc" +== 385 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET cc = cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET cc = cc" +== 386 +-- truncate_limit: 100 +-- ok +UPDATE rw_view1 SET aa=aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET aa = aa" +== 387 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET bb=bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET bb = bb" +== 388 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET aa = aa" +== 389 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET bb = bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET bb = bb" +== 390 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 391 +-- truncate_limit: 100 +GRANT INSERT, DELETE ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert, delete ON base_tbl TO regress_view_user2" +== 392 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 393 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (3, 'Row 3', 3.0)" +== 394 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4)" +== 395 +-- truncate_limit: 100 +-- not allowed +DELETE FROM base_tbl WHERE a=1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM base_tbl WHERE a = 1" +== 396 +-- truncate_limit: 100 +-- ok +DELETE FROM rw_view1 WHERE aa=2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE aa = 2" +== 397 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN DELETE" +== 398 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 399 +-- truncate_limit: 100 +REVOKE INSERT, DELETE ON base_tbl FROM regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE insert, delete ON base_tbl FROM regress_view_user2" +== 400 +-- truncate_limit: 100 +GRANT INSERT, DELETE ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert, delete ON rw_view1 TO regress_view_user2" +== 401 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 402 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4)" +== 403 +-- truncate_limit: 100 +-- not allowed +DELETE FROM rw_view1 WHERE aa=2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE aa = 2" +== 404 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN DELETE" +== 405 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 406 +-- truncate_limit: 100 +GRANT INSERT, DELETE ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert, delete ON base_tbl TO regress_view_user2" +== 407 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 408 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('Row 4', 4.0, 4)" +== 409 +-- truncate_limit: 100 +-- ok +DELETE FROM rw_view1 WHERE aa=2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE aa = 2" +== 410 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view1 t USING (VALUES (3)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN DELETE +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (3)) v(a) ON t.aa = v.a WHEN MATCHED THEN DELETE" +== 411 +-- truncate_limit: 100 +-- ok +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 412 +-- truncate_limit: 100 +-- ok + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 413 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 414 +-- truncate_limit: 100 +-- ordinary view on top of security invoker view permissions + +CREATE TABLE base_tbl(a int, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b text, c double precision)" +== 415 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 'Row 1', 1.0)" +== 416 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 417 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl" +== 418 +-- truncate_limit: 100 +ALTER VIEW rw_view1 SET (security_invoker = true) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view1 SET (security_invoker=true)" +== 419 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 420 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET aa=aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET aa = aa" +== 421 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (2, 'Row 2', 2.0)) AS v(a,b,c) ON t.aa = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.b, v.c, v.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (...)) v(a, b, c) ON t.aa = v.a WHEN NOT MATCHED THEN INSERT ..." +== 422 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 423 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS SELECT cc AS ccc, aa AS aaa, bb AS bbb FROM rw_view1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT cc AS ccc, aa AS aaa, bb AS bbb FROM rw_view1" +== 424 +-- truncate_limit: 100 +GRANT SELECT, UPDATE ON rw_view2 TO regress_view_user3 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select, update ON rw_view2 TO regress_view_user3" +== 425 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 426 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 427 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (2, 'Row 2', 2.0)) AS v(a,b,c) ON t.aaa = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.c, v.a, v.b) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (...)) v(a, b, c) ON t.aaa = v.a WHEN NOT MATCHED THEN INSERT..." +== 428 +-- truncate_limit: 100 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 429 +-- truncate_limit: 100 +GRANT SELECT ON base_tbl TO regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON base_tbl TO regress_view_user1" +== 430 +-- truncate_limit: 100 +GRANT UPDATE (a, b) ON base_tbl TO regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (a, b) ON base_tbl TO regress_view_user1" +== 431 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 432 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 433 +-- truncate_limit: 100 +-- ok +UPDATE rw_view1 SET aa=aa, bb=bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET aa = aa, bb = bb" +== 434 +-- truncate_limit: 100 +-- ok +UPDATE rw_view1 SET cc=cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET cc = cc" +== 435 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa, bb = bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET aa = aa,..." +== 436 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET cc = cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET cc = cc" +== 437 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 438 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 439 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 440 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 441 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user3" +== 442 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 443 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 444 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 445 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 446 +-- truncate_limit: 100 +GRANT SELECT ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON rw_view1 TO regress_view_user2" +== 447 +-- truncate_limit: 100 +GRANT UPDATE (bb, cc) ON rw_view1 TO regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (bb, cc) ON rw_view1 TO regress_view_user2" +== 448 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 449 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 450 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 451 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 452 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user3" +== 453 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 454 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 455 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 456 +-- truncate_limit: 100 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 457 +-- truncate_limit: 100 +GRANT SELECT ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON base_tbl TO regress_view_user2" +== 458 +-- truncate_limit: 100 +GRANT UPDATE (a, c) ON base_tbl TO regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (a, c) ON base_tbl TO regress_view_user2" +== 459 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 460 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 461 +-- truncate_limit: 100 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 462 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 463 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET ccc = ccc" +== 464 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 465 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 466 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET ccc = ccc" +== 467 +-- truncate_limit: 100 +-- ok + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user3" +== 468 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 469 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 470 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 471 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET ccc = ccc" +== 472 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 473 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 474 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET ccc = ccc" +== 475 +-- truncate_limit: 100 +-- not allowed + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 476 +-- truncate_limit: 100 +GRANT SELECT ON base_tbl TO regress_view_user3 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select ON base_tbl TO regress_view_user3" +== 477 +-- truncate_limit: 100 +GRANT UPDATE (a, c) ON base_tbl TO regress_view_user3 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (a, c) ON base_tbl TO regress_view_user3" +== 478 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user3" +== 479 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 480 +-- truncate_limit: 100 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 481 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 482 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET ccc = ccc" +== 483 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 484 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 485 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET ccc = ccc" +== 486 +-- truncate_limit: 100 +-- ok + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 487 +-- truncate_limit: 100 +REVOKE SELECT, UPDATE ON base_tbl FROM regress_view_user1 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE select, update ON base_tbl FROM regress_view_user1" +== 488 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 489 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 490 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view1 SET aa=aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET aa = aa" +== 491 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.aa = v.a + WHEN MATCHED THEN UPDATE SET aa = aa +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.aa = v.a WHEN MATCHED THEN UPDATE SET aa = aa" +== 492 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 493 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 494 +-- truncate_limit: 100 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 495 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 496 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET ccc = ccc" +== 497 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 498 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 499 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET ccc = ccc" +== 500 +-- truncate_limit: 100 +-- ok + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user3" +== 501 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 502 +-- truncate_limit: 100 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 503 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 504 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET ccc = ccc" +== 505 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 506 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 507 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET ccc = ccc" +== 508 +-- truncate_limit: 100 +-- ok + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 509 +-- truncate_limit: 100 +REVOKE SELECT, UPDATE ON base_tbl FROM regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE select, update ON base_tbl FROM regress_view_user2" +== 510 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 511 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 512 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 513 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 514 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET ccc = ccc" +== 515 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 516 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 517 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET ccc = ccc" +== 518 +-- truncate_limit: 100 +-- not allowed + +SET SESSION AUTHORIZATION regress_view_user3 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user3" +== 519 +-- truncate_limit: 100 +SELECT * FROM rw_view2 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2" +== 520 +-- truncate_limit: 100 +-- ok +UPDATE rw_view2 SET aaa=aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET aaa = aaa" +== 521 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET bbb=bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET bbb = bbb" +== 522 +-- truncate_limit: 100 +-- not allowed +UPDATE rw_view2 SET ccc=ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET ccc = ccc" +== 523 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET aaa = aaa +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET aaa = aaa" +== 524 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET bbb = bbb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET bbb = bbb" +== 525 +-- truncate_limit: 100 +-- not allowed +MERGE INTO rw_view2 t USING (VALUES (1)) AS v(a) ON t.aaa = v.a + WHEN MATCHED THEN UPDATE SET ccc = ccc +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (1)) v(a) ON t.aaa = v.a WHEN MATCHED THEN UPDATE SET ccc = ccc" +== 526 +-- truncate_limit: 100 +-- ok + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 527 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 528 +-- truncate_limit: 100 +DROP USER regress_view_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_view_user1" +== 529 +-- truncate_limit: 100 +DROP USER regress_view_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_view_user2" +== 530 +-- truncate_limit: 100 +DROP USER regress_view_user3 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_view_user3" +== 531 +-- truncate_limit: 100 +-- column defaults + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified', c serial) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified', c serial)" +== 532 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1, 'Row 1') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 'Row 1')" +== 533 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (2, 'Row 2') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (2, 'Row 2')" +== 534 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (3) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (3)" +== 535 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT a AS aa, b AS bb FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT a AS aa, b AS bb FROM base_tbl" +== 536 +-- truncate_limit: 100 +ALTER VIEW rw_view1 ALTER COLUMN bb SET DEFAULT 'View default' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view1 ALTER COLUMN bb SET DEFAULT 'View default'" +== 537 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (4, 'Row 4') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (4, 'Row 4')" +== 538 +-- truncate_limit: 100 +INSERT INTO rw_view1 (aa) VALUES (5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (aa) VALUES (5)" +== 539 +-- truncate_limit: 100 +MERGE INTO rw_view1 t USING (VALUES (6)) AS v(a) ON t.aa = v.a + WHEN NOT MATCHED THEN INSERT (aa) VALUES (v.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (6)) v(a) ON t.aa = v.a WHEN NOT MATCHED THEN INSERT (aa) VAL..." +== 540 +-- truncate_limit: 100 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 541 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 542 +-- truncate_limit: 100 +-- Table having triggers + +CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified')" +== 543 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1, 'Row 1') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 'Row 1')" +== 544 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (2, 'Row 2') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (2, 'Row 2')" +== 545 +-- truncate_limit: 100 +CREATE FUNCTION rw_view1_trig_fn() +RETURNS trigger AS +$$ +BEGIN + IF TG_OP = 'INSERT' THEN + UPDATE base_tbl SET b=NEW.b WHERE a=1; + RETURN NULL; + END IF; + RETURN NULL; +END; +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rw_view1_trig_fn() RETURNS trigger AS $$\nBEGIN\n IF TG_OP = 'INSERT' THEN\n UPD..." +== 546 +-- truncate_limit: 100 +CREATE TRIGGER rw_view1_ins_trig AFTER INSERT ON base_tbl + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER rw_view1_ins_trig AFTER INSERT ON base_tbl FOR EACH ROW EXECUTE FUNCTION rw_view1_..." +== 547 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT a AS aa, b AS bb FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT a AS aa, b AS bb FROM base_tbl" +== 548 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (3, 'Row 3') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (3, 'Row 3')" +== 549 +-- truncate_limit: 100 +select * from base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 550 +-- truncate_limit: 100 +DROP VIEW rw_view1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rw_view1" +== 551 +-- truncate_limit: 100 +DROP TRIGGER rw_view1_ins_trig on base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER rw_view1_ins_trig ON base_tbl" +== 552 +-- truncate_limit: 100 +DROP FUNCTION rw_view1_trig_fn() +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rw_view1_trig_fn()" +== 553 +-- truncate_limit: 100 +DROP TABLE base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl" +== 554 +-- truncate_limit: 100 +-- view with ORDER BY + +CREATE TABLE base_tbl (a int, b int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b int)" +== 555 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1,2), (4,5), (3,-3) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 2), (4, 5), (3, -3)" +== 556 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl ORDER BY a+b +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl ORDER BY a + b" +== 557 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 558 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (7,-8) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (7, -8)" +== 559 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 560 +-- truncate_limit: 100 +EXPLAIN (verbose, costs off) UPDATE rw_view1 SET b = b + 1 RETURNING * +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view1 SET b = b + 1 RETURNING *" +== 561 +-- truncate_limit: 100 +UPDATE rw_view1 SET b = b + 1 RETURNING * +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b = b + 1 RETURNING *" +== 562 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 563 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 564 +-- truncate_limit: 100 +-- multiple array-column updates + +CREATE TABLE base_tbl (a int, arr int[]) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, arr int[])" +== 565 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1,ARRAY[2]), (3,ARRAY[4]) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, ARRAY[2]), (3, ARRAY[4])" +== 566 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl" +== 567 +-- truncate_limit: 100 +UPDATE rw_view1 SET arr[1] = 42, arr[2] = 77 WHERE a = 3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET arr[1] = 42, arr[2] = 77 WHERE a = 3" +== 568 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 569 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 570 +-- truncate_limit: 100 +-- views with updatable and non-updatable columns + +CREATE TABLE base_tbl(a float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a double precision)" +== 571 +-- truncate_limit: 100 +INSERT INTO base_tbl SELECT i/10.0 FROM generate_series(1,10) g(i) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl SELECT i / 10.0 FROM generate_series(1, 10) g(i)" +== 572 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS + SELECT ctid, sin(a) s, a, cos(a) c + FROM base_tbl + WHERE a != 0 + ORDER BY abs(a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FUNCTION: name="sin" function="sin" schema="" ctx=Call +FUNCTION: name="cos" function="cos" schema="" ctx=Call +FUNCTION: name="abs" function="abs" schema="" ctx=Call +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT ctid, sin(a) AS s, a, cos(a) AS c FROM base_tbl WHERE a <> 0 ORDER..." +== 573 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (null, null, 1.1, null) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (NULL, NULL, 1.1, NULL)" +== 574 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view1 (s, c, a) VALUES (null, null, 1.1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (s, c, a) VALUES (NULL, NULL, 1.1)" +== 575 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view1 (s, c, a) VALUES (default, default, 1.1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (s, c, a) VALUES (DEFAULT, DEFAULT, 1.1)" +== 576 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view1 (a) VALUES (1.1) RETURNING a, s, c +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (a) VALUES (1.1) RETURNING a, s, c" +== 577 +-- truncate_limit: 100 +-- OK +UPDATE rw_view1 SET s = s WHERE a = 1.1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET s = s WHERE a = 1.1" +== 578 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view1 SET a = 1.05 WHERE a = 1.1 RETURNING s +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET a = 1.05 WHERE a = 1.1 RETURNING s" +== 579 +-- truncate_limit: 100 +-- OK +DELETE FROM rw_view1 WHERE a = 1.05 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE a = 1.05" +== 580 +-- truncate_limit: 100 +-- OK + +CREATE VIEW rw_view2 AS + SELECT s, c, s/c t, a base_a, ctid + FROM rw_view1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT s, c, s / c AS t, a AS base_a, ctid FROM rw_view1" +== 581 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (null, null, null, 1.1, null) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (NULL, NULL, NULL, 1.1, NULL)" +== 582 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view2(s, c, base_a) VALUES (null, null, 1.1) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 (s, c, base_a) VALUES (NULL, NULL, 1.1)" +== 583 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view2(base_a) VALUES (1.1) RETURNING t +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 (base_a) VALUES (1.1) RETURNING t" +== 584 +-- truncate_limit: 100 +-- OK +UPDATE rw_view2 SET s = s WHERE base_a = 1.1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET s = s WHERE base_a = 1.1" +== 585 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view2 SET t = t WHERE base_a = 1.1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET t = t WHERE base_a = 1.1" +== 586 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view2 SET base_a = 1.05 WHERE base_a = 1.1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET base_a = 1.05 WHERE base_a = 1.1" +== 587 +-- truncate_limit: 100 +-- OK +DELETE FROM rw_view2 WHERE base_a = 1.05 RETURNING base_a, s, c, t +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2 WHERE base_a = 1.05 RETURNING base_a, s, c, t" +== 588 +-- truncate_limit: 100 +-- OK + +CREATE VIEW rw_view3 AS + SELECT s, c, s/c t, ctid + FROM rw_view1 +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view3 AS SELECT s, c, s / c AS t, ctid FROM rw_view1" +== 589 +-- truncate_limit: 100 +INSERT INTO rw_view3 VALUES (null, null, null, null) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view3 VALUES (NULL, NULL, NULL, NULL)" +== 590 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view3(s) VALUES (null) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view3 (s) VALUES (NULL)" +== 591 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view3 SET s = s +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view3 SET s = s" +== 592 +-- truncate_limit: 100 +-- should fail +DELETE FROM rw_view3 WHERE s = sin(0.1) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +FUNCTION: name="sin" function="sin" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view3 WHERE s = sin(0.1)" +== 593 +-- truncate_limit: 100 +-- should be OK +SELECT * FROM base_tbl ORDER BY a +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a" +== 594 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.tables WHERE table_name LIKE E'r_\\\\_view%' ORDER BY table_name" +== 595 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE E'r_\\\\_view%' ORDER BY table_name" +== 596 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name LIKE E'r_\\_view%' + ORDER BY table_name, ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE ... ORDER BY table_name, ordinal_position" +== 597 +-- truncate_limit: 100 +SELECT events & 4 != 0 AS upd, + events & 8 != 0 AS ins, + events & 16 != 0 AS del + FROM pg_catalog.pg_relation_is_updatable('rw_view3'::regclass, false) t(events) +-- +FUNCTION: name="pg_catalog.pg_relation_is_updatable" function="pg_relation_is_updatable" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_catalog.pg_relation_is_updatable('rw_view3'::regclass, false) t(events)" +== 598 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 599 +-- truncate_limit: 100 +-- view on table with GENERATED columns + +CREATE TABLE base_tbl (id int, idplus1 int GENERATED ALWAYS AS (id + 1) STORED) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (id int, idplus1 int GENERATED ALWAYS AS (id + 1) STORED)" +== 600 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl" +== 601 +-- truncate_limit: 100 +INSERT INTO base_tbl (id) VALUES (1) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl (id) VALUES (1)" +== 602 +-- truncate_limit: 100 +INSERT INTO rw_view1 (id) VALUES (2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (id) VALUES (2)" +== 603 +-- truncate_limit: 100 +INSERT INTO base_tbl (id, idplus1) VALUES (3, DEFAULT) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl (id, idplus1) VALUES (3, DEFAULT)" +== 604 +-- truncate_limit: 100 +INSERT INTO rw_view1 (id, idplus1) VALUES (4, DEFAULT) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (id, idplus1) VALUES (4, DEFAULT)" +== 605 +-- truncate_limit: 100 +INSERT INTO base_tbl (id, idplus1) VALUES (5, 6) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl (id, idplus1) VALUES (5, 6)" +== 606 +-- truncate_limit: 100 +-- error +INSERT INTO rw_view1 (id, idplus1) VALUES (6, 7) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (id, idplus1) VALUES (6, 7)" +== 607 +-- truncate_limit: 100 +-- error + +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 608 +-- truncate_limit: 100 +UPDATE base_tbl SET id = 2000 WHERE id = 2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE base_tbl SET id = 2000 WHERE id = 2" +== 609 +-- truncate_limit: 100 +UPDATE rw_view1 SET id = 3000 WHERE id = 3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET id = 3000 WHERE id = 3" +== 610 +-- truncate_limit: 100 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 611 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 612 +-- truncate_limit: 100 +-- inheritance tests + +CREATE TABLE base_tbl_parent (a int) +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl_parent (a int)" +== 613 +-- truncate_limit: 100 +CREATE TABLE base_tbl_child (CHECK (a > 0)) INHERITS (base_tbl_parent) +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl_child (CHECK (a > 0)) INHERITS (base_tbl_parent)" +== 614 +-- truncate_limit: 100 +INSERT INTO base_tbl_parent SELECT * FROM generate_series(-8, -1) +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl_parent SELECT * FROM generate_series(-8, -1)" +== 615 +-- truncate_limit: 100 +INSERT INTO base_tbl_child SELECT * FROM generate_series(1, 8) +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl_child SELECT * FROM generate_series(1, 8)" +== 616 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl_parent +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl_parent" +== 617 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS SELECT * FROM ONLY base_tbl_parent +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT * FROM ONLY base_tbl_parent" +== 618 +-- truncate_limit: 100 +SELECT * FROM rw_view1 ORDER BY a +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1 ORDER BY a" +== 619 +-- truncate_limit: 100 +SELECT * FROM ONLY rw_view1 ORDER BY a +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY rw_view1 ORDER BY a" +== 620 +-- truncate_limit: 100 +SELECT * FROM rw_view2 ORDER BY a +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 ORDER BY a" +== 621 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (-100), (100) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (-100), (100)" +== 622 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (-200), (200) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (-200), (200)" +== 623 +-- truncate_limit: 100 +UPDATE rw_view1 SET a = a*10 WHERE a IN (-1, 1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET a = a * 10 WHERE a IN (-1, 1)" +== 624 +-- truncate_limit: 100 +-- Should produce -10 and 10 +UPDATE ONLY rw_view1 SET a = a*10 WHERE a IN (-2, 2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ONLY rw_view1 SET a = a * 10 WHERE a IN (-2, 2)" +== 625 +-- truncate_limit: 100 +-- Should produce -20 and 20 +UPDATE rw_view2 SET a = a*10 WHERE a IN (-3, 3) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET a = a * 10 WHERE a IN (-3, 3)" +== 626 +-- truncate_limit: 100 +-- Should produce -30 only +UPDATE ONLY rw_view2 SET a = a*10 WHERE a IN (-4, 4) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE ONLY rw_view2 SET a = a * 10 WHERE a IN (-4, 4)" +== 627 +-- truncate_limit: 100 +-- Should produce -40 only + +DELETE FROM rw_view1 WHERE a IN (-5, 5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE a IN (-5, 5)" +== 628 +-- truncate_limit: 100 +-- Should delete -5 and 5 +DELETE FROM ONLY rw_view1 WHERE a IN (-6, 6) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ONLY rw_view1 WHERE a IN (-6, 6)" +== 629 +-- truncate_limit: 100 +-- Should delete -6 and 6 +DELETE FROM rw_view2 WHERE a IN (-7, 7) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2 WHERE a IN (-7, 7)" +== 630 +-- truncate_limit: 100 +-- Should delete -7 only +DELETE FROM ONLY rw_view2 WHERE a IN (-8, 8) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM ONLY rw_view2 WHERE a IN (-8, 8)" +== 631 +-- truncate_limit: 100 +-- Should delete -8 only + +SELECT * FROM ONLY base_tbl_parent ORDER BY a +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY base_tbl_parent ORDER BY a" +== 632 +-- truncate_limit: 100 +SELECT * FROM base_tbl_child ORDER BY a +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl_child ORDER BY a" +== 633 +-- truncate_limit: 100 +MERGE INTO rw_view1 t USING (VALUES (-200), (10)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a+1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (...)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET a = t.a..." +== 634 +-- truncate_limit: 100 +-- Should produce -199 and 11 +MERGE INTO ONLY rw_view1 t USING (VALUES (-100), (20)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a+1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO ONLY rw_view1 t USING (VALUES (...)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET a ..." +== 635 +-- truncate_limit: 100 +-- Should produce -99 and 21 +MERGE INTO rw_view2 t USING (VALUES (-40), (3)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a+1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (...)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET a = t.a..." +== 636 +-- truncate_limit: 100 +-- Should produce -39 only +MERGE INTO ONLY rw_view2 t USING (VALUES (-30), (4)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a+1 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO ONLY rw_view2 t USING (VALUES (...)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET a ..." +== 637 +-- truncate_limit: 100 +-- Should produce -29 only + +SELECT * FROM ONLY base_tbl_parent ORDER BY a +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY base_tbl_parent ORDER BY a" +== 638 +-- truncate_limit: 100 +SELECT * FROM base_tbl_child ORDER BY a +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl_child ORDER BY a" +== 639 +-- truncate_limit: 100 +CREATE TABLE other_tbl_parent (id int) +-- +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE other_tbl_parent (id int)" +== 640 +-- truncate_limit: 100 +CREATE TABLE other_tbl_child () INHERITS (other_tbl_parent) +-- +TABLE: name="other_tbl_child" schema="" table="other_tbl_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE other_tbl_child () INHERITS (other_tbl_parent)" +== 641 +-- truncate_limit: 100 +INSERT INTO other_tbl_parent VALUES (7),(200) +-- +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO other_tbl_parent VALUES (7), (200)" +== 642 +-- truncate_limit: 100 +INSERT INTO other_tbl_child VALUES (8),(100) +-- +TABLE: name="other_tbl_child" schema="" table="other_tbl_child" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO other_tbl_child VALUES (8), (100)" +== 643 +-- truncate_limit: 100 +EXPLAIN (costs off) +UPDATE rw_view1 SET a = a + 1000 FROM other_tbl_parent WHERE a = id +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=Select +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view1 SET a = a + 1000 FROM other_tbl_parent WHERE a = id" +== 644 +-- truncate_limit: 100 +UPDATE rw_view1 SET a = a + 1000 FROM other_tbl_parent WHERE a = id +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=Select +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET a = a + 1000 FROM other_tbl_parent WHERE a = id" +== 645 +-- truncate_limit: 100 +SELECT * FROM ONLY base_tbl_parent ORDER BY a +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM ONLY base_tbl_parent ORDER BY a" +== 646 +-- truncate_limit: 100 +SELECT * FROM base_tbl_child ORDER BY a +-- +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl_child ORDER BY a" +== 647 +-- truncate_limit: 100 +DROP TABLE base_tbl_parent, base_tbl_child CASCADE +-- +TABLE: name="base_tbl_parent" schema="" table="base_tbl_parent" ctx=DDL +TABLE: name="base_tbl_child" schema="" table="base_tbl_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl_parent, base_tbl_child CASCADE" +== 648 +-- truncate_limit: 100 +DROP TABLE other_tbl_parent CASCADE +-- +TABLE: name="other_tbl_parent" schema="" table="other_tbl_parent" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE other_tbl_parent CASCADE" +== 649 +-- truncate_limit: 100 +-- simple WITH CHECK OPTION + +CREATE TABLE base_tbl (a int, b int DEFAULT 10) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b int DEFAULT 10)" +== 650 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1,2), (2,3), (1,-1) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 2), (2, 3), (1, -1)" +== 651 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b + WITH LOCAL CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b WITH LOCAL CHECK OPTION" +== 652 +-- truncate_limit: 100 +SELECT * FROM information_schema.views WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.views WHERE table_name = 'rw_view1'" +== 653 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES(3,4) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (3, 4)" +== 654 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view1 VALUES(4,3) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (4, 3)" +== 655 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view1 VALUES(5,null) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (5, NULL)" +== 656 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view1 SET b = 5 WHERE a = 3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b = 5 WHERE a = 3" +== 657 +-- truncate_limit: 100 +-- ok +UPDATE rw_view1 SET b = -5 WHERE a = 3 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b = -5 WHERE a = 3" +== 658 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view1(a) VALUES (9) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (a) VALUES (9)" +== 659 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view1(a) VALUES (10) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 (a) VALUES (10)" +== 660 +-- truncate_limit: 100 +-- should fail +SELECT * FROM base_tbl ORDER BY a, b +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a, b" +== 661 +-- truncate_limit: 100 +MERGE INTO rw_view1 t USING (VALUES (10)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.a + 1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (10)) v(a) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VALUES (..." +== 662 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view1 t USING (VALUES (11)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a, v.a - 1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (11)) v(a) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VALUES (..." +== 663 +-- truncate_limit: 100 +-- should fail +MERGE INTO rw_view1 t USING (VALUES (1)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a - 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (1)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET a = t.a - 1" +== 664 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view1 t USING (VALUES (2)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a + 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (2)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET a = t.a + 1" +== 665 +-- truncate_limit: 100 +-- should fail +SELECT * FROM base_tbl ORDER BY a, b +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl ORDER BY a, b" +== 666 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 667 +-- truncate_limit: 100 +-- WITH LOCAL/CASCADED CHECK OPTION + +CREATE TABLE base_tbl (a int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int)" +== 668 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a > 0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a > 0" +== 669 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10 + WITH CHECK OPTION +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10 WITH CHECK OPTION" +== 670 +-- truncate_limit: 100 +-- implicitly cascaded +SELECT * FROM information_schema.views WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.views WHERE table_name = 'rw_view2'" +== 671 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (-5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (-5)" +== 672 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view2 VALUES (5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (5)" +== 673 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view2 VALUES (15) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (15)" +== 674 +-- truncate_limit: 100 +-- should fail +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 675 +-- truncate_limit: 100 +UPDATE rw_view2 SET a = a - 10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET a = a - 10" +== 676 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view2 SET a = a + 10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET a = a + 10" +== 677 +-- truncate_limit: 100 +-- should fail + +CREATE OR REPLACE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10 + WITH LOCAL CHECK OPTION +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a < 10 WITH LOCAL CHECK OPTION" +== 678 +-- truncate_limit: 100 +SELECT * FROM information_schema.views WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.views WHERE table_name = 'rw_view2'" +== 679 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (-10) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (-10)" +== 680 +-- truncate_limit: 100 +-- ok, but not in view +INSERT INTO rw_view2 VALUES (20) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (20)" +== 681 +-- truncate_limit: 100 +-- should fail +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 682 +-- truncate_limit: 100 +ALTER VIEW rw_view1 SET (check_option=here) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view1 SET (check_option=here)" +== 683 +-- truncate_limit: 100 +-- invalid +ALTER VIEW rw_view1 SET (check_option=local) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view1 SET (check_option=local)" +== 684 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (-20) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (-20)" +== 685 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view2 VALUES (30) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (30)" +== 686 +-- truncate_limit: 100 +-- should fail + +ALTER VIEW rw_view2 RESET (check_option) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view2 RESET (check_option)" +== 687 +-- truncate_limit: 100 +SELECT * FROM information_schema.views WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.views WHERE table_name = 'rw_view2'" +== 688 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (30) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (30)" +== 689 +-- truncate_limit: 100 +-- ok, but not in view +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 690 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 691 +-- truncate_limit: 100 +-- WITH CHECK OPTION with no local view qual + +CREATE TABLE base_tbl (a int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int)" +== 692 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WITH CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WITH CHECK OPTION" +== 693 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > 0 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > 0" +== 694 +-- truncate_limit: 100 +CREATE VIEW rw_view3 AS SELECT * FROM rw_view2 WITH CHECK OPTION +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DDL +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view3 AS SELECT * FROM rw_view2 WITH CHECK OPTION" +== 695 +-- truncate_limit: 100 +SELECT * FROM information_schema.views WHERE table_name LIKE E'rw\\_view_' ORDER BY table_name +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM information_schema.views WHERE table_name LIKE E'rw\\\\_view_' ORDER BY table_name" +== 696 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (-1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (-1)" +== 697 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view1 VALUES (1) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (1)" +== 698 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view2 VALUES (-2) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (-2)" +== 699 +-- truncate_limit: 100 +-- ok, but not in view +INSERT INTO rw_view2 VALUES (2) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (2)" +== 700 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view3 VALUES (-3) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view3 VALUES (-3)" +== 701 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view3 VALUES (3) +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view3 VALUES (3)" +== 702 +-- truncate_limit: 100 +-- ok + +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 703 +-- truncate_limit: 100 +-- WITH CHECK OPTION with scalar array ops + +CREATE TABLE base_tbl (a int, b int[]) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b int[])" +== 704 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a = ANY (b) + WITH CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a = ANY(b) WITH CHECK OPTION" +== 705 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (1, ARRAY[1,2,3]) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (1, ARRAY[1, 2, 3])" +== 706 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view1 VALUES (10, ARRAY[4,5]) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (10, ARRAY[4, 5])" +== 707 +-- truncate_limit: 100 +-- should fail + +UPDATE rw_view1 SET b[2] = -b[2] WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b[2] = - b[2] WHERE a = 1" +== 708 +-- truncate_limit: 100 +-- ok +UPDATE rw_view1 SET b[1] = -b[1] WHERE a = 1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET b[1] = - b[1] WHERE a = 1" +== 709 +-- truncate_limit: 100 +-- should fail + +PREPARE ins(int, int[]) AS INSERT INTO rw_view1 VALUES($1, $2) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: PrepareStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "PREPARE ins(int, int[]) AS INSERT INTO rw_view1 VALUES ($1, $2)" +== 710 +-- truncate_limit: 100 +EXECUTE ins(2, ARRAY[1,2,3]) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE ins(2, ARRAY[1, 2, 3])" +== 711 +-- truncate_limit: 100 +-- ok +EXECUTE ins(10, ARRAY[4,5]) +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE ins(10, ARRAY[4, 5])" +== 712 +-- truncate_limit: 100 +-- should fail +DEALLOCATE PREPARE ins +-- +STMT: DeallocateStmt +TRUNCATED: "DEALLOCATE ins" +== 713 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 714 +-- truncate_limit: 100 +-- WITH CHECK OPTION with subquery + +CREATE TABLE base_tbl (a int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int)" +== 715 +-- truncate_limit: 100 +CREATE TABLE ref_tbl (a int PRIMARY KEY) +-- +TABLE: name="ref_tbl" schema="" table="ref_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE ref_tbl (a int PRIMARY KEY)" +== 716 +-- truncate_limit: 100 +INSERT INTO ref_tbl SELECT * FROM generate_series(1,10) +-- +TABLE: name="ref_tbl" schema="" table="ref_tbl" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO ref_tbl SELECT * FROM generate_series(1, 10)" +== 717 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS + SELECT * FROM base_tbl b + WHERE EXISTS(SELECT 1 FROM ref_tbl r WHERE r.a = b.a) + WITH CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +TABLE: name="ref_tbl" schema="" table="ref_tbl" ctx=Select +ALIAS: "b"="base_tbl" +ALIAS: "r"="ref_tbl" +FILTER: schema="" table="r" column="a" +FILTER: schema="" table="b" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl b WHERE EXISTS (SELECT 1 FROM ref_tbl r WHERE r.a ..." +== 718 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (5)" +== 719 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view1 VALUES (15) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (15)" +== 720 +-- truncate_limit: 100 +-- should fail + +UPDATE rw_view1 SET a = a + 5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET a = a + 5" +== 721 +-- truncate_limit: 100 +-- ok +UPDATE rw_view1 SET a = a + 5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET a = a + 5" +== 722 +-- truncate_limit: 100 +-- should fail + +EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (5) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO rw_view1 VALUES (5)" +== 723 +-- truncate_limit: 100 +EXPLAIN (costs off) UPDATE rw_view1 SET a = a + 5 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view1 SET a = a + 5" +== 724 +-- truncate_limit: 100 +DROP TABLE base_tbl, ref_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +TABLE: name="ref_tbl" schema="" table="ref_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl, ref_tbl CASCADE" +== 725 +-- truncate_limit: 100 +-- WITH CHECK OPTION with BEFORE trigger on base table + +CREATE TABLE base_tbl (a int, b int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b int)" +== 726 +-- truncate_limit: 100 +CREATE FUNCTION base_tbl_trig_fn() +RETURNS trigger AS +$$ +BEGIN + NEW.b := 10; + RETURN NEW; +END; +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="base_tbl_trig_fn" function="base_tbl_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION base_tbl_trig_fn() RETURNS trigger AS $$\nBEGIN\n NEW.b := 10;\n RETURN NEW;\nEND;\n..." +== 727 +-- truncate_limit: 100 +CREATE TRIGGER base_tbl_trig BEFORE INSERT OR UPDATE ON base_tbl + FOR EACH ROW EXECUTE PROCEDURE base_tbl_trig_fn() +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER base_tbl_trig BEFORE INSERT OR UPDATE ON base_tbl FOR EACH ROW EXECUTE FUNCTION ba..." +== 728 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b WITH CHECK OPTION +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT * FROM base_tbl WHERE a < b WITH CHECK OPTION" +== 729 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (5,0) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (5, 0)" +== 730 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view1 VALUES (15, 20) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (15, 20)" +== 731 +-- truncate_limit: 100 +-- should fail +UPDATE rw_view1 SET a = 20, b = 30 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET a = 20, b = 30" +== 732 +-- truncate_limit: 100 +-- should fail + +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 733 +-- truncate_limit: 100 +DROP FUNCTION base_tbl_trig_fn() +-- +FUNCTION: name="base_tbl_trig_fn" function="base_tbl_trig_fn" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION base_tbl_trig_fn()" +== 734 +-- truncate_limit: 100 +-- WITH LOCAL CHECK OPTION with INSTEAD OF trigger on base view + +CREATE TABLE base_tbl (a int, b int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int, b int)" +== 735 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT a FROM base_tbl WHERE a < b +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT a FROM base_tbl WHERE a < b" +== 736 +-- truncate_limit: 100 +CREATE FUNCTION rw_view1_trig_fn() +RETURNS trigger AS +$$ +BEGIN + IF TG_OP = 'INSERT' THEN + INSERT INTO base_tbl VALUES (NEW.a, 10); + RETURN NEW; + ELSIF TG_OP = 'UPDATE' THEN + UPDATE base_tbl SET a=NEW.a WHERE a=OLD.a; + RETURN NEW; + ELSIF TG_OP = 'DELETE' THEN + DELETE FROM base_tbl WHERE a=OLD.a; + RETURN OLD; + END IF; +END; +$$ +LANGUAGE plpgsql +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION rw_view1_trig_fn() RETURNS trigger AS $$\nBEGIN\n IF TG_OP = 'INSERT' THEN\n INS..." +== 737 +-- truncate_limit: 100 +CREATE TRIGGER rw_view1_trig + INSTEAD OF INSERT OR UPDATE OR DELETE ON rw_view1 + FOR EACH ROW EXECUTE PROCEDURE rw_view1_trig_fn() +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER rw_view1_trig INSTEAD OF INSERT OR DELETE OR UPDATE ON rw_view1 FOR EACH ROW EXECU..." +== 738 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS + SELECT * FROM rw_view1 WHERE a > 0 WITH LOCAL CHECK OPTION +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > 0 WITH LOCAL CHECK OPTION" +== 739 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (-5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (-5)" +== 740 +-- truncate_limit: 100 +-- should fail +MERGE INTO rw_view2 t USING (VALUES (-5)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (-5)) v(a) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VALUES (..." +== 741 +-- truncate_limit: 100 +-- should fail +INSERT INTO rw_view2 VALUES (5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (5)" +== 742 +-- truncate_limit: 100 +-- ok +MERGE INTO rw_view2 t USING (VALUES (6)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (6)) v(a) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VALUES (v.a)" +== 743 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view2 VALUES (50) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (50)" +== 744 +-- truncate_limit: 100 +-- ok, but not in view +MERGE INTO rw_view2 t USING (VALUES (60)) AS v(a) ON t.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (60)) v(a) ON t.a = v.a WHEN NOT MATCHED THEN INSERT VALUES (..." +== 745 +-- truncate_limit: 100 +-- ok, but not in view +UPDATE rw_view2 SET a = a - 10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET a = a - 10" +== 746 +-- truncate_limit: 100 +-- should fail +MERGE INTO rw_view2 t USING (VALUES (6)) AS v(a) ON t.a = v.a + WHEN MATCHED THEN UPDATE SET a = t.a - 10 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (6)) v(a) ON t.a = v.a WHEN MATCHED THEN UPDATE SET a = t.a - 10" +== 747 +-- truncate_limit: 100 +-- should fail +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 748 +-- truncate_limit: 100 +-- Check option won't cascade down to base view with INSTEAD OF triggers + +ALTER VIEW rw_view2 SET (check_option=cascaded) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view2 SET (check_option=cascaded)" +== 749 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (100) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (100)" +== 750 +-- truncate_limit: 100 +-- ok, but not in view (doesn't fail rw_view1's check) +UPDATE rw_view2 SET a = 200 WHERE a = 5 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET a = 200 WHERE a = 5" +== 751 +-- truncate_limit: 100 +-- ok, but not in view (doesn't fail rw_view1's check) +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 752 +-- truncate_limit: 100 +-- Neither local nor cascaded check options work with INSTEAD rules + +DROP TRIGGER rw_view1_trig ON rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER rw_view1_trig ON rw_view1" +== 753 +-- truncate_limit: 100 +CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 + DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a, 10) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 DO INSTEAD INSERT INTO base_tbl VALUES (ne..." +== 754 +-- truncate_limit: 100 +CREATE RULE rw_view1_upd_rule AS ON UPDATE TO rw_view1 + DO INSTEAD UPDATE base_tbl SET a=NEW.a WHERE a=OLD.a +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view1_upd_rule AS ON UPDATE TO rw_view1 DO INSTEAD UPDATE base_tbl SET a = new.a W..." +== 755 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (-10) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (-10)" +== 756 +-- truncate_limit: 100 +-- ok, but not in view (doesn't fail rw_view2's check) +INSERT INTO rw_view2 VALUES (5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (5)" +== 757 +-- truncate_limit: 100 +-- ok +INSERT INTO rw_view2 VALUES (20) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (20)" +== 758 +-- truncate_limit: 100 +-- ok, but not in view (doesn't fail rw_view1's check) +UPDATE rw_view2 SET a = 30 WHERE a = 5 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET a = 30 WHERE a = 5" +== 759 +-- truncate_limit: 100 +-- ok, but not in view (doesn't fail rw_view1's check) +INSERT INTO rw_view2 VALUES (5) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (5)" +== 760 +-- truncate_limit: 100 +-- ok +UPDATE rw_view2 SET a = -5 WHERE a = 5 +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET a = -5 WHERE a = 5" +== 761 +-- truncate_limit: 100 +-- ok, but not in view (doesn't fail rw_view2's check) +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 762 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 763 +-- truncate_limit: 100 +DROP FUNCTION rw_view1_trig_fn() +-- +FUNCTION: name="rw_view1_trig_fn" function="rw_view1_trig_fn" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION rw_view1_trig_fn()" +== 764 +-- truncate_limit: 100 +CREATE TABLE base_tbl (a int) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int)" +== 765 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS SELECT a,10 AS b FROM base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT a, 10 AS b FROM base_tbl" +== 766 +-- truncate_limit: 100 +CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 + DO INSTEAD INSERT INTO base_tbl VALUES (NEW.a) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE rw_view1_ins_rule AS ON INSERT TO rw_view1 DO INSTEAD INSERT INTO base_tbl VALUES (ne..." +== 767 +-- truncate_limit: 100 +CREATE VIEW rw_view2 AS + SELECT * FROM rw_view1 WHERE a > b WITH LOCAL CHECK OPTION +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="b" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT * FROM rw_view1 WHERE a > b WITH LOCAL CHECK OPTION" +== 768 +-- truncate_limit: 100 +INSERT INTO rw_view2 VALUES (2,3) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 VALUES (2, 3)" +== 769 +-- truncate_limit: 100 +-- ok, but not in view (doesn't fail rw_view2's check) +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 770 +-- truncate_limit: 100 +-- security barrier view + +CREATE TABLE base_tbl (person text, visibility text) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (person text, visibility text)" +== 771 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES ('Tom', 'public'), + ('Dick', 'private'), + ('Harry', 'public') +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES ('Tom', 'public'), ('Dick', 'private'), ('Harry', 'public')" +== 772 +-- truncate_limit: 100 +CREATE VIEW rw_view1 AS + SELECT person FROM base_tbl WHERE visibility = 'public' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="visibility" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT person FROM base_tbl WHERE visibility = 'public'" +== 773 +-- truncate_limit: 100 +CREATE FUNCTION snoop(anyelement) +RETURNS boolean AS +$$ +BEGIN + RAISE NOTICE 'snooped value: %', $1; + RETURN true; +END; +$$ +LANGUAGE plpgsql COST 0.000001 +-- +FUNCTION: name="snoop" function="snoop" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION snoop(anyelement) RETURNS boolean AS $$\nBEGIN\n RAISE NOTICE 'snooped value: %', ..." +== 774 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION leakproof(anyelement) +RETURNS boolean AS +$$ +BEGIN + RETURN true; +END; +$$ +LANGUAGE plpgsql STRICT IMMUTABLE LEAKPROOF +-- +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION leakproof(anyelement) RETURNS boolean AS $$\nBEGIN\n RETURN true;\nEND;\n..." +== 775 +-- truncate_limit: 100 +SELECT * FROM rw_view1 WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1 WHERE snoop(person)" +== 776 +-- truncate_limit: 100 +UPDATE rw_view1 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET person = person WHERE snoop(person)" +== 777 +-- truncate_limit: 100 +DELETE FROM rw_view1 WHERE NOT snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE NOT snoop(person)" +== 778 +-- truncate_limit: 100 +ALTER VIEW rw_view1 SET (security_barrier = true) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW rw_view1 SET (security_barrier=true)" +== 779 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT table_name, is_insertable_into FROM information_schema.tables WHERE table_name = 'rw_view1'" +== 780 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view1' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name = 'rw_view1'" +== 781 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name = 'rw_view1' + ORDER BY ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name = 'rw_view1' ORDER BY ordinal_position" +== 782 +-- truncate_limit: 100 +SELECT * FROM rw_view1 WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1 WHERE snoop(person)" +== 783 +-- truncate_limit: 100 +UPDATE rw_view1 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view1 SET person = person WHERE snoop(person)" +== 784 +-- truncate_limit: 100 +DELETE FROM rw_view1 WHERE NOT snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE NOT snoop(person)" +== 785 +-- truncate_limit: 100 +MERGE INTO rw_view1 t + USING (VALUES ('Tom'), ('Dick'), ('Harry')) AS v(person) ON t.person = v.person + WHEN MATCHED AND snoop(t.person) THEN UPDATE SET person = v.person +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view1 t USING (VALUES (...)) v(person) ON t.person = v.person WHEN MATCHED AND snoo..." +== 786 +-- truncate_limit: 100 +EXPLAIN (costs off) SELECT * FROM rw_view1 WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rw_view1 WHERE snoop(person)" +== 787 +-- truncate_limit: 100 +EXPLAIN (costs off) UPDATE rw_view1 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view1 SET person = person WHERE snoop(person)" +== 788 +-- truncate_limit: 100 +EXPLAIN (costs off) DELETE FROM rw_view1 WHERE NOT snoop(person) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM rw_view1 WHERE NOT snoop(person)" +== 789 +-- truncate_limit: 100 +EXPLAIN (costs off) +MERGE INTO rw_view1 t + USING (VALUES ('Tom'), ('Dick'), ('Harry')) AS v(person) ON t.person = v.person + WHEN MATCHED AND snoop(t.person) THEN UPDATE SET person = v.person +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +ALIAS: "t"="rw_view1" +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO rw_view1 t USING (VALUES ('Tom'), ('Dick'), ('Harry')) v(person) O..." +== 790 +-- truncate_limit: 100 +-- security barrier view on top of security barrier view + +CREATE VIEW rw_view2 WITH (security_barrier = true) AS + SELECT * FROM rw_view1 WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 WITH (security_barrier=true) AS SELECT * FROM rw_view1 WHERE snoop(person)" +== 791 +-- truncate_limit: 100 +SELECT table_name, is_insertable_into + FROM information_schema.tables + WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.tables" schema="information_schema" table="tables" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT table_name, is_insertable_into FROM information_schema.tables WHERE table_name = 'rw_view2'" +== 792 +-- truncate_limit: 100 +SELECT table_name, is_updatable, is_insertable_into + FROM information_schema.views + WHERE table_name = 'rw_view2' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name = 'rw_view2'" +== 793 +-- truncate_limit: 100 +SELECT table_name, column_name, is_updatable + FROM information_schema.columns + WHERE table_name = 'rw_view2' + ORDER BY ordinal_position +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name = 'rw_view2' ORDER BY ordinal_position" +== 794 +-- truncate_limit: 100 +SELECT * FROM rw_view2 WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view2 WHERE snoop(person)" +== 795 +-- truncate_limit: 100 +UPDATE rw_view2 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE rw_view2 SET person = person WHERE snoop(person)" +== 796 +-- truncate_limit: 100 +DELETE FROM rw_view2 WHERE NOT snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view2 WHERE NOT snoop(person)" +== 797 +-- truncate_limit: 100 +MERGE INTO rw_view2 t + USING (VALUES ('Tom'), ('Dick'), ('Harry')) AS v(person) ON t.person = v.person + WHEN MATCHED AND snoop(t.person) THEN UPDATE SET person = v.person +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO rw_view2 t USING (VALUES (...)) v(person) ON t.person = v.person WHEN MATCHED AND snoo..." +== 798 +-- truncate_limit: 100 +EXPLAIN (costs off) SELECT * FROM rw_view2 WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=Select +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FILTER: schema="" table="" column="person" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM rw_view2 WHERE snoop(person)" +== 799 +-- truncate_limit: 100 +EXPLAIN (costs off) UPDATE rw_view2 SET person=person WHERE snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE rw_view2 SET person = person WHERE snoop(person)" +== 800 +-- truncate_limit: 100 +EXPLAIN (costs off) DELETE FROM rw_view2 WHERE NOT snoop(person) +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM rw_view2 WHERE NOT snoop(person)" +== 801 +-- truncate_limit: 100 +EXPLAIN (costs off) +MERGE INTO rw_view2 t + USING (VALUES ('Tom'), ('Dick'), ('Harry')) AS v(person) ON t.person = v.person + WHEN MATCHED AND snoop(t.person) THEN UPDATE SET person = v.person +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +ALIAS: "t"="rw_view2" +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) MERGE INTO rw_view2 t USING (VALUES ('Tom'), ('Dick'), ('Harry')) v(person) O..." +== 802 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 803 +-- truncate_limit: 100 +-- security barrier view on top of table with rules + +CREATE TABLE base_tbl(id int PRIMARY KEY, data text, deleted boolean) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (id int PRIMARY KEY, data text, deleted boolean)" +== 804 +-- truncate_limit: 100 +INSERT INTO base_tbl VALUES (1, 'Row 1', false), (2, 'Row 2', true) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 'Row 1', false), (2, 'Row 2', true)" +== 805 +-- truncate_limit: 100 +CREATE RULE base_tbl_ins_rule AS ON INSERT TO base_tbl + WHERE EXISTS (SELECT 1 FROM base_tbl t WHERE t.id = new.id) + DO INSTEAD + UPDATE base_tbl SET data = new.data, deleted = false WHERE id = new.id +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE base_tbl_ins_rule AS ON INSERT TO base_tbl WHERE ... DO INSTEAD UPDATE base_tbl SET d..." +== 806 +-- truncate_limit: 100 +CREATE RULE base_tbl_del_rule AS ON DELETE TO base_tbl + DO INSTEAD + UPDATE base_tbl SET deleted = true WHERE id = old.id +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE base_tbl_del_rule AS ON DELETE TO base_tbl DO INSTEAD UPDATE base_tbl SET deleted = t..." +== 807 +-- truncate_limit: 100 +CREATE VIEW rw_view1 WITH (security_barrier=true) AS + SELECT id, data FROM base_tbl WHERE NOT deleted +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +FILTER: schema="" table="" column="deleted" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 WITH (security_barrier=true) AS SELECT id, data FROM base_tbl WHERE NOT deleted" +== 808 +-- truncate_limit: 100 +SELECT * FROM rw_view1 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM rw_view1" +== 809 +-- truncate_limit: 100 +EXPLAIN (costs off) DELETE FROM rw_view1 WHERE id = 1 AND snoop(data) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: ExplainStmt +STMT: DeleteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) DELETE FROM rw_view1 WHERE id = 1 AND snoop(data)" +== 810 +-- truncate_limit: 100 +DELETE FROM rw_view1 WHERE id = 1 AND snoop(data) +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM rw_view1 WHERE id = 1 AND snoop(data)" +== 811 +-- truncate_limit: 100 +EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (2, 'New row 2') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO rw_view1 VALUES (2, 'New row 2')" +== 812 +-- truncate_limit: 100 +INSERT INTO rw_view1 VALUES (2, 'New row 2') +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES (2, 'New row 2')" +== 813 +-- truncate_limit: 100 +SELECT * FROM base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 814 +-- truncate_limit: 100 +DROP TABLE base_tbl CASCADE +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl CASCADE" +== 815 +-- truncate_limit: 100 +-- security barrier view based on inheritance set +CREATE TABLE t1 (a int, b float, c text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (a int, b double precision, c text)" +== 816 +-- truncate_limit: 100 +CREATE INDEX t1_a_idx ON t1(a) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX t1_a_idx ON t1 USING btree (a)" +== 817 +-- truncate_limit: 100 +INSERT INTO t1 +SELECT i,i,'t1' FROM generate_series(1,10) g(i) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 SELECT i, i, 't1' FROM generate_series(1, 10) g(i)" +== 818 +-- truncate_limit: 100 +ANALYZE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t1" +== 819 +-- truncate_limit: 100 +CREATE TABLE t11 (d text) INHERITS (t1) +-- +TABLE: name="t11" schema="" table="t11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t11 (d text) INHERITS (t1)" +== 820 +-- truncate_limit: 100 +CREATE INDEX t11_a_idx ON t11(a) +-- +TABLE: name="t11" schema="" table="t11" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX t11_a_idx ON t11 USING btree (a)" +== 821 +-- truncate_limit: 100 +INSERT INTO t11 +SELECT i,i,'t11','t11d' FROM generate_series(1,10) g(i) +-- +TABLE: name="t11" schema="" table="t11" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t11 SELECT i, i, 't11', 't11d' FROM generate_series(1, 10) g(i)" +== 822 +-- truncate_limit: 100 +ANALYZE t11 +-- +TABLE: name="t11" schema="" table="t11" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t11" +== 823 +-- truncate_limit: 100 +CREATE TABLE t12 (e int[]) INHERITS (t1) +-- +TABLE: name="t12" schema="" table="t12" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t12 (e int[]) INHERITS (t1)" +== 824 +-- truncate_limit: 100 +CREATE INDEX t12_a_idx ON t12(a) +-- +TABLE: name="t12" schema="" table="t12" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX t12_a_idx ON t12 USING btree (a)" +== 825 +-- truncate_limit: 100 +INSERT INTO t12 +SELECT i,i,'t12','{1,2}'::int[] FROM generate_series(1,10) g(i) +-- +TABLE: name="t12" schema="" table="t12" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t12 SELECT i, i, 't12', '{1,2}'::int[] FROM generate_series(1, 10) g(i)" +== 826 +-- truncate_limit: 100 +ANALYZE t12 +-- +TABLE: name="t12" schema="" table="t12" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t12" +== 827 +-- truncate_limit: 100 +CREATE TABLE t111 () INHERITS (t11, t12) +-- +TABLE: name="t111" schema="" table="t111" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t111 () INHERITS (t11, t12)" +== 828 +-- truncate_limit: 100 +CREATE INDEX t111_a_idx ON t111(a) +-- +TABLE: name="t111" schema="" table="t111" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX t111_a_idx ON t111 USING btree (a)" +== 829 +-- truncate_limit: 100 +INSERT INTO t111 +SELECT i,i,'t111','t111d','{1,1,1}'::int[] FROM generate_series(1,10) g(i) +-- +TABLE: name="t111" schema="" table="t111" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t111 SELECT i, i, 't111', 't111d', '{1,1,1}'::int[] FROM generate_series(1, 10) g(i)" +== 830 +-- truncate_limit: 100 +ANALYZE t111 +-- +TABLE: name="t111" schema="" table="t111" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE t111" +== 831 +-- truncate_limit: 100 +CREATE VIEW v1 WITH (security_barrier=true) AS +SELECT *, (SELECT d FROM t11 WHERE t11.a = t1.a LIMIT 1) AS d +FROM t1 +WHERE a > 5 AND EXISTS(SELECT 1 FROM t12 WHERE t12.a = t1.a) +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +TABLE: name="t11" schema="" table="t11" ctx=Select +TABLE: name="t12" schema="" table="t12" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="t11" column="a" +FILTER: schema="" table="t1" column="a" +FILTER: schema="" table="t12" column="a" +FILTER: schema="" table="t1" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v1 WITH (security_barrier=true) AS SELECT *, (SELECT d FROM t11 WHERE t11.a = t1.a LI..." +== 832 +-- truncate_limit: 100 +SELECT * FROM v1 WHERE a=3 +-- +TABLE: name="v1" schema="" table="v1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v1 WHERE a = 3" +== 833 +-- truncate_limit: 100 +-- should not see anything +SELECT * FROM v1 WHERE a=8 +-- +TABLE: name="v1" schema="" table="v1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v1 WHERE a = 8" +== 834 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND a != 6 +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) UPDATE v1 SET a = 100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND ..." +== 835 +-- truncate_limit: 100 +UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND a != 6 +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE v1 SET a = 100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND a <> 6" +== 836 +-- truncate_limit: 100 +SELECT * FROM v1 WHERE a=100 +-- +TABLE: name="v1" schema="" table="v1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v1 WHERE a = 100" +== 837 +-- truncate_limit: 100 +-- Nothing should have been changed to 100 +SELECT * FROM t1 WHERE a=100 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1 WHERE a = 100" +== 838 +-- truncate_limit: 100 +-- Nothing should have been changed to 100 + +EXPLAIN (VERBOSE, COSTS OFF) +UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8 +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) UPDATE v1 SET a = a + 1 WHERE snoop(a) AND leakproof(a) AND a = 8" +== 839 +-- truncate_limit: 100 +UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8 +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE v1 SET a = a + 1 WHERE snoop(a) AND leakproof(a) AND a = 8" +== 840 +-- truncate_limit: 100 +SELECT * FROM v1 WHERE b=8 +-- +TABLE: name="v1" schema="" table="v1" ctx=Select +FILTER: schema="" table="" column="b" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v1 WHERE b = 8" +== 841 +-- truncate_limit: 100 +DELETE FROM v1 WHERE snoop(a) AND leakproof(a) +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +FUNCTION: name="snoop" function="snoop" schema="" ctx=Call +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM v1 WHERE snoop(a) AND leakproof(a)" +== 842 +-- truncate_limit: 100 +-- should not delete everything, just where a>5 + +TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM t1" +== 843 +-- truncate_limit: 100 +-- verify all a<=5 are intact + +DROP TABLE t1, t11, t12, t111 CASCADE +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +TABLE: name="t11" schema="" table="t11" ctx=DDL +TABLE: name="t12" schema="" table="t12" ctx=DDL +TABLE: name="t111" schema="" table="t111" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1, t11, t12, t111 CASCADE" +== 844 +-- truncate_limit: 100 +DROP FUNCTION snoop(anyelement) +-- +FUNCTION: name="snoop" function="snoop" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION snoop(anyelement)" +== 845 +-- truncate_limit: 100 +DROP FUNCTION leakproof(anyelement) +-- +FUNCTION: name="leakproof" function="leakproof" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION leakproof(anyelement)" +== 846 +-- truncate_limit: 100 +CREATE TABLE tx1 (a integer) +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx1 (a int)" +== 847 +-- truncate_limit: 100 +CREATE TABLE tx2 (b integer) +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx2 (b int)" +== 848 +-- truncate_limit: 100 +CREATE TABLE tx3 (c integer) +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx3 (c int)" +== 849 +-- truncate_limit: 100 +CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS(SELECT 1 FROM tx2 JOIN tx3 ON b=c) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=Select +TABLE: name="tx2" schema="" table="tx2" ctx=Select +TABLE: name="tx3" schema="" table="tx3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS (SELECT 1 FROM tx2 JOIN tx3 ON b = c)" +== 850 +-- truncate_limit: 100 +INSERT INTO vx1 values (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vx1 VALUES (1)" +== 851 +-- truncate_limit: 100 +SELECT * FROM tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tx1" +== 852 +-- truncate_limit: 100 +SELECT * FROM vx1 +-- +TABLE: name="vx1" schema="" table="vx1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vx1" +== 853 +-- truncate_limit: 100 +DROP VIEW vx1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vx1" +== 854 +-- truncate_limit: 100 +DROP TABLE tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx1" +== 855 +-- truncate_limit: 100 +DROP TABLE tx2 +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx2" +== 856 +-- truncate_limit: 100 +DROP TABLE tx3 +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx3" +== 857 +-- truncate_limit: 100 +CREATE TABLE tx1 (a integer) +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx1 (a int)" +== 858 +-- truncate_limit: 100 +CREATE TABLE tx2 (b integer) +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx2 (b int)" +== 859 +-- truncate_limit: 100 +CREATE TABLE tx3 (c integer) +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx3 (c int)" +== 860 +-- truncate_limit: 100 +CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS(SELECT 1 FROM tx2 JOIN tx3 ON b=c) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=Select +TABLE: name="tx2" schema="" table="tx2" ctx=Select +TABLE: name="tx3" schema="" table="tx3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS (SELECT 1 FROM tx2 JOIN tx3 ON b = c)" +== 861 +-- truncate_limit: 100 +INSERT INTO vx1 VALUES (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vx1 VALUES (1)" +== 862 +-- truncate_limit: 100 +INSERT INTO vx1 VALUES (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vx1 VALUES (1)" +== 863 +-- truncate_limit: 100 +SELECT * FROM tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tx1" +== 864 +-- truncate_limit: 100 +SELECT * FROM vx1 +-- +TABLE: name="vx1" schema="" table="vx1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vx1" +== 865 +-- truncate_limit: 100 +DROP VIEW vx1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vx1" +== 866 +-- truncate_limit: 100 +DROP TABLE tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx1" +== 867 +-- truncate_limit: 100 +DROP TABLE tx2 +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx2" +== 868 +-- truncate_limit: 100 +DROP TABLE tx3 +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx3" +== 869 +-- truncate_limit: 100 +CREATE TABLE tx1 (a integer, b integer) +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx1 (a int, b int)" +== 870 +-- truncate_limit: 100 +CREATE TABLE tx2 (b integer, c integer) +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx2 (b int, c int)" +== 871 +-- truncate_limit: 100 +CREATE TABLE tx3 (c integer, d integer) +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE tx3 (c int, d int)" +== 872 +-- truncate_limit: 100 +ALTER TABLE tx1 DROP COLUMN b +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tx1 DROP b" +== 873 +-- truncate_limit: 100 +ALTER TABLE tx2 DROP COLUMN c +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tx2 DROP c" +== 874 +-- truncate_limit: 100 +ALTER TABLE tx3 DROP COLUMN d +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE tx3 DROP d" +== 875 +-- truncate_limit: 100 +CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS(SELECT 1 FROM tx2 JOIN tx3 ON b=c) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DDL +TABLE: name="tx1" schema="" table="tx1" ctx=Select +TABLE: name="tx2" schema="" table="tx2" ctx=Select +TABLE: name="tx3" schema="" table="tx3" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vx1 AS SELECT a FROM tx1 WHERE EXISTS (SELECT 1 FROM tx2 JOIN tx3 ON b = c)" +== 876 +-- truncate_limit: 100 +INSERT INTO vx1 VALUES (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vx1 VALUES (1)" +== 877 +-- truncate_limit: 100 +INSERT INTO vx1 VALUES (1) +-- +TABLE: name="vx1" schema="" table="vx1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vx1 VALUES (1)" +== 878 +-- truncate_limit: 100 +SELECT * FROM tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM tx1" +== 879 +-- truncate_limit: 100 +SELECT * FROM vx1 +-- +TABLE: name="vx1" schema="" table="vx1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vx1" +== 880 +-- truncate_limit: 100 +DROP VIEW vx1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vx1" +== 881 +-- truncate_limit: 100 +DROP TABLE tx1 +-- +TABLE: name="tx1" schema="" table="tx1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx1" +== 882 +-- truncate_limit: 100 +DROP TABLE tx2 +-- +TABLE: name="tx2" schema="" table="tx2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx2" +== 883 +-- truncate_limit: 100 +DROP TABLE tx3 +-- +TABLE: name="tx3" schema="" table="tx3" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE tx3" +== 884 +-- truncate_limit: 100 +|-- +-- Test handling of vars from correlated subqueries in quals from outer +-- security barrier views, per bug #13988 +|-- +CREATE TABLE t1 (a int, b text, c int) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (a int, b text, c int)" +== 885 +-- truncate_limit: 100 +INSERT INTO t1 VALUES (1, 'one', 10) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 VALUES (1, 'one', 10)" +== 886 +-- truncate_limit: 100 +CREATE TABLE t2 (cc int) +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t2 (cc int)" +== 887 +-- truncate_limit: 100 +INSERT INTO t2 VALUES (10), (20) +-- +TABLE: name="t2" schema="" table="t2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t2 VALUES (10), (20)" +== 888 +-- truncate_limit: 100 +CREATE VIEW v1 WITH (security_barrier = true) AS + SELECT * FROM t1 WHERE (a > 0) + WITH CHECK OPTION +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v1 WITH (security_barrier=true) AS SELECT * FROM t1 WHERE a > 0 WITH CHECK OPTION" +== 889 +-- truncate_limit: 100 +CREATE VIEW v2 WITH (security_barrier = true) AS + SELECT * FROM v1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.cc = v1.c) + WITH CHECK OPTION +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="v1" schema="" table="v1" ctx=Select +TABLE: name="t2" schema="" table="t2" ctx=Select +FILTER: schema="" table="t2" column="cc" +FILTER: schema="" table="v1" column="c" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v2 WITH (security_barrier=true) AS SELECT * FROM v1 WHERE EXISTS (SELECT 1 FROM t2 WH..." +== 890 +-- truncate_limit: 100 +INSERT INTO v2 VALUES (2, 'two', 20) +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO v2 VALUES (2, 'two', 20)" +== 891 +-- truncate_limit: 100 +-- ok +INSERT INTO v2 VALUES (-2, 'minus two', 20) +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO v2 VALUES (-2, 'minus two', 20)" +== 892 +-- truncate_limit: 100 +-- not allowed +INSERT INTO v2 VALUES (3, 'three', 30) +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO v2 VALUES (3, 'three', 30)" +== 893 +-- truncate_limit: 100 +-- not allowed + +UPDATE v2 SET b = 'ONE' WHERE a = 1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE v2 SET b = 'ONE' WHERE a = 1" +== 894 +-- truncate_limit: 100 +-- ok +UPDATE v2 SET a = -1 WHERE a = 1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE v2 SET a = -1 WHERE a = 1" +== 895 +-- truncate_limit: 100 +-- not allowed +UPDATE v2 SET c = 30 WHERE a = 1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE v2 SET c = 30 WHERE a = 1" +== 896 +-- truncate_limit: 100 +-- not allowed + +DELETE FROM v2 WHERE a = 2 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM v2 WHERE a = 2" +== 897 +-- truncate_limit: 100 +-- ok +SELECT * FROM v2 +-- +TABLE: name="v2" schema="" table="v2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v2" +== 898 +-- truncate_limit: 100 +DROP VIEW v2 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW v2" +== 899 +-- truncate_limit: 100 +DROP VIEW v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW v1" +== 900 +-- truncate_limit: 100 +DROP TABLE t2 +-- +TABLE: name="t2" schema="" table="t2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t2" +== 901 +-- truncate_limit: 100 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1" +== 902 +-- truncate_limit: 100 +|-- +-- Test sub-select in nested security barrier views, per bug #17972 +|-- +CREATE TABLE t1 (a int) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (a int)" +== 903 +-- truncate_limit: 100 +CREATE VIEW v1 WITH (security_barrier = true) AS + SELECT * FROM t1 +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v1 WITH (security_barrier=true) AS SELECT * FROM t1" +== 904 +-- truncate_limit: 100 +CREATE RULE v1_upd_rule AS ON UPDATE TO v1 DO INSTEAD + UPDATE t1 SET a = NEW.a WHERE a = OLD.a +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE v1_upd_rule AS ON UPDATE TO v1 DO INSTEAD UPDATE t1 SET a = new.a WHERE a = old.a" +== 905 +-- truncate_limit: 100 +CREATE VIEW v2 WITH (security_barrier = true) AS + SELECT * FROM v1 WHERE EXISTS (SELECT 1) +-- +TABLE: name="v2" schema="" table="v2" ctx=DDL +TABLE: name="v1" schema="" table="v1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v2 WITH (security_barrier=true) AS SELECT * FROM v1 WHERE EXISTS (SELECT 1)" +== 906 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) UPDATE v2 SET a = 1 +-- +TABLE: name="v2" schema="" table="v2" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE v2 SET a = 1" +== 907 +-- truncate_limit: 100 +DROP VIEW v2 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW v2" +== 908 +-- truncate_limit: 100 +DROP VIEW v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW v1" +== 909 +-- truncate_limit: 100 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1" +== 910 +-- truncate_limit: 100 +|-- +-- Test CREATE OR REPLACE VIEW turning a non-updatable view into an +-- auto-updatable view and adding check options in a single step +|-- +CREATE TABLE t1 (a int, b text) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE t1 (a int, b text)" +== 911 +-- truncate_limit: 100 +CREATE VIEW v1 AS SELECT null::int AS a +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW v1 AS SELECT NULL::int AS a" +== 912 +-- truncate_limit: 100 +CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1 WHERE a > 0 WITH CHECK OPTION +-- +TABLE: name="v1" schema="" table="v1" ctx=DDL +TABLE: name="t1" schema="" table="t1" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1 WHERE a > 0 WITH CHECK OPTION" +== 913 +-- truncate_limit: 100 +INSERT INTO v1 VALUES (1, 'ok') +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO v1 VALUES (1, 'ok')" +== 914 +-- truncate_limit: 100 +-- ok +INSERT INTO v1 VALUES (-1, 'invalid') +-- +TABLE: name="v1" schema="" table="v1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO v1 VALUES (-1, 'invalid')" +== 915 +-- truncate_limit: 100 +-- should fail + +DROP VIEW v1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW v1" +== 916 +-- truncate_limit: 100 +DROP TABLE t1 +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE t1" +== 917 +-- truncate_limit: 100 +-- check that an auto-updatable view on a partitioned table works correctly +create table uv_pt (a int, b int, v varchar) partition by range (a, b) +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE uv_pt (a int, b int, v varchar) PARTITION BY RANGE (a, b)" +== 918 +-- truncate_limit: 100 +create table uv_pt1 (b int not null, v varchar, a int not null) partition by range (b) +-- +TABLE: name="uv_pt1" schema="" table="uv_pt1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE uv_pt1 (b int NOT NULL, v varchar, a int NOT NULL) PARTITION BY RANGE (b)" +== 919 +-- truncate_limit: 100 +create table uv_pt11 (like uv_pt1) +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE uv_pt11 (LIKE uv_pt1)" +== 920 +-- truncate_limit: 100 +alter table uv_pt11 drop a +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE uv_pt11 DROP a" +== 921 +-- truncate_limit: 100 +alter table uv_pt11 add a int +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE uv_pt11 ADD COLUMN a int" +== 922 +-- truncate_limit: 100 +alter table uv_pt11 drop a +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE uv_pt11 DROP a" +== 923 +-- truncate_limit: 100 +alter table uv_pt11 add a int not null +-- +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE uv_pt11 ADD COLUMN a int NOT NULL" +== 924 +-- truncate_limit: 100 +alter table uv_pt1 attach partition uv_pt11 for values from (2) to (5) +-- +TABLE: name="uv_pt1" schema="" table="uv_pt1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE uv_pt1 ATTACH PARTITION uv_pt11 FOR VALUES FROM (2) TO (5)" +== 925 +-- truncate_limit: 100 +alter table uv_pt attach partition uv_pt1 for values from (1, 2) to (1, 10) +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE uv_pt ATTACH PARTITION uv_pt1 FOR VALUES FROM (1, 2) TO (1, 10)" +== 926 +-- truncate_limit: 100 +create view uv_ptv as select * from uv_pt +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DDL +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW uv_ptv AS SELECT * FROM uv_pt" +== 927 +-- truncate_limit: 100 +select events & 4 != 0 AS upd, + events & 8 != 0 AS ins, + events & 16 != 0 AS del + from pg_catalog.pg_relation_is_updatable('uv_pt'::regclass, false) t(events) +-- +FUNCTION: name="pg_catalog.pg_relation_is_updatable" function="pg_relation_is_updatable" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM pg_catalog.pg_relation_is_updatable('uv_pt'::regclass, false) t(events)" +== 928 +-- truncate_limit: 100 +select pg_catalog.pg_column_is_updatable('uv_pt'::regclass, 1::smallint, false) +-- +FUNCTION: name="pg_catalog.pg_column_is_updatable" function="pg_column_is_updatable" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.pg_column_is_updatable('uv_pt'::regclass, 1::smallint, false)" +== 929 +-- truncate_limit: 100 +select pg_catalog.pg_column_is_updatable('uv_pt'::regclass, 2::smallint, false) +-- +FUNCTION: name="pg_catalog.pg_column_is_updatable" function="pg_column_is_updatable" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_catalog.pg_column_is_updatable('uv_pt'::regclass, 2::smallint, false)" +== 930 +-- truncate_limit: 100 +select table_name, is_updatable, is_insertable_into + from information_schema.views where table_name = 'uv_ptv' +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name = 'uv_ptv'" +== 931 +-- truncate_limit: 100 +select table_name, column_name, is_updatable + from information_schema.columns where table_name = 'uv_ptv' order by column_name +-- +TABLE: name="information_schema.columns" schema="information_schema" table="columns" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.columns WHERE table_name = 'uv_ptv' ORDER BY column_name" +== 932 +-- truncate_limit: 100 +insert into uv_ptv values (1, 2) +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_ptv VALUES (1, 2)" +== 933 +-- truncate_limit: 100 +select tableoid::regclass, * from uv_pt +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM uv_pt" +== 934 +-- truncate_limit: 100 +create view uv_ptv_wco as select * from uv_pt where a = 0 with check option +-- +TABLE: name="uv_ptv_wco" schema="" table="uv_ptv_wco" ctx=DDL +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=Select +FILTER: schema="" table="" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW uv_ptv_wco AS SELECT * FROM uv_pt WHERE a = 0 WITH CHECK OPTION" +== 935 +-- truncate_limit: 100 +insert into uv_ptv_wco values (1, 2) +-- +TABLE: name="uv_ptv_wco" schema="" table="uv_ptv_wco" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_ptv_wco VALUES (1, 2)" +== 936 +-- truncate_limit: 100 +merge into uv_ptv t + using (values (1,2), (1,4)) as v(a,b) on t.a = v.a -- fail: matches 2 src rows + when matched then update set b = t.b + 1 + when not matched then insert values (v.a, v.b + 1) +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DML +ALIAS: "t"="uv_ptv" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO uv_ptv t USING (VALUES (...)) v(a, b) ON t.a = v.a WHEN MATCHED THEN UPDATE SET b = t...." +== 937 +-- truncate_limit: 100 +merge into uv_ptv t + using (values (1,2), (1,4)) as v(a,b) on t.a = v.a and t.b = v.b + when matched then update set b = t.b + 1 + when not matched then insert values (v.a, v.b + 1) +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DML +ALIAS: "t"="uv_ptv" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO uv_ptv t USING (VALUES (...)) v(a, b) ON t.a = v.a AND t.b = v.b WHEN MATCHED THEN UPD..." +== 938 +-- truncate_limit: 100 +-- fail: no partition for b=5 +merge into uv_ptv t + using (values (1,2), (1,3)) as v(a,b) on t.a = v.a and t.b = v.b + when matched then update set b = t.b + 1 + when not matched then insert values (v.a, v.b + 1) +-- +TABLE: name="uv_ptv" schema="" table="uv_ptv" ctx=DML +ALIAS: "t"="uv_ptv" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "MERGE INTO uv_ptv t USING (VALUES (...)) v(a, b) ON t.a = v.a AND t.b = v.b WHEN MATCHED THEN UPD..." +== 939 +-- truncate_limit: 100 +-- ok +select tableoid::regclass, * from uv_pt order by a, b +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass, * FROM uv_pt ORDER BY a, b" +== 940 +-- truncate_limit: 100 +drop view uv_ptv, uv_ptv_wco +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW uv_ptv, uv_ptv_wco" +== 941 +-- truncate_limit: 100 +drop table uv_pt, uv_pt1, uv_pt11 +-- +TABLE: name="uv_pt" schema="" table="uv_pt" ctx=DDL +TABLE: name="uv_pt1" schema="" table="uv_pt1" ctx=DDL +TABLE: name="uv_pt11" schema="" table="uv_pt11" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE uv_pt, uv_pt1, uv_pt11" +== 942 +-- truncate_limit: 100 +-- check that wholerow vars appearing in WITH CHECK OPTION constraint expressions +-- work fine with partitioned tables +create table wcowrtest (a int) partition by list (a) +-- +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE wcowrtest (a int) PARTITION BY LIST (a)" +== 943 +-- truncate_limit: 100 +create table wcowrtest1 partition of wcowrtest for values in (1) +-- +TABLE: name="wcowrtest1" schema="" table="wcowrtest1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE wcowrtest1 PARTITION OF wcowrtest FOR VALUES IN (1)" +== 944 +-- truncate_limit: 100 +create view wcowrtest_v as select * from wcowrtest where wcowrtest = '(2)'::wcowrtest with check option +-- +TABLE: name="wcowrtest_v" schema="" table="wcowrtest_v" ctx=DDL +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=Select +FILTER: schema="" table="" column="wcowrtest" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW wcowrtest_v AS SELECT * FROM wcowrtest WHERE wcowrtest = '(2)'::wcowrtest WITH CHECK ..." +== 945 +-- truncate_limit: 100 +insert into wcowrtest_v values (1) +-- +TABLE: name="wcowrtest_v" schema="" table="wcowrtest_v" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wcowrtest_v VALUES (1)" +== 946 +-- truncate_limit: 100 +alter table wcowrtest add b text +-- +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE wcowrtest ADD COLUMN b text" +== 947 +-- truncate_limit: 100 +create table wcowrtest2 (b text, c int, a int) +-- +TABLE: name="wcowrtest2" schema="" table="wcowrtest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE wcowrtest2 (b text, c int, a int)" +== 948 +-- truncate_limit: 100 +alter table wcowrtest2 drop c +-- +TABLE: name="wcowrtest2" schema="" table="wcowrtest2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE wcowrtest2 DROP c" +== 949 +-- truncate_limit: 100 +alter table wcowrtest attach partition wcowrtest2 for values in (2) +-- +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE wcowrtest ATTACH PARTITION wcowrtest2 FOR VALUES IN (2)" +== 950 +-- truncate_limit: 100 +create table sometable (a int, b text) +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sometable (a int, b text)" +== 951 +-- truncate_limit: 100 +insert into sometable values (1, 'a'), (2, 'b') +-- +TABLE: name="sometable" schema="" table="sometable" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sometable VALUES (1, 'a'), (2, 'b')" +== 952 +-- truncate_limit: 100 +create view wcowrtest_v2 as + select * + from wcowrtest r + where r in (select s from sometable s where r.a = s.a) +with check option +-- +TABLE: name="wcowrtest_v2" schema="" table="wcowrtest_v2" ctx=DDL +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=Select +TABLE: name="sometable" schema="" table="sometable" ctx=Select +ALIAS: "r"="wcowrtest" +ALIAS: "s"="sometable" +FILTER: schema="" table="" column="r" +FILTER: schema="" table="r" column="a" +FILTER: schema="" table="s" column="a" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW wcowrtest_v2 AS SELECT * FROM wcowrtest r WHERE r IN (SELECT s FROM sometable s WHERE..." +== 953 +-- truncate_limit: 100 +-- WITH CHECK qual will be processed with wcowrtest2's +-- rowtype after tuple-routing +insert into wcowrtest_v2 values (2, 'no such row in sometable') +-- +TABLE: name="wcowrtest_v2" schema="" table="wcowrtest_v2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO wcowrtest_v2 VALUES (2, 'no such row in sometable')" +== 954 +-- truncate_limit: 100 +drop view wcowrtest_v, wcowrtest_v2 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW wcowrtest_v, wcowrtest_v2" +== 955 +-- truncate_limit: 100 +drop table wcowrtest, sometable +-- +TABLE: name="wcowrtest" schema="" table="wcowrtest" ctx=DDL +TABLE: name="sometable" schema="" table="sometable" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE wcowrtest, sometable" +== 956 +-- truncate_limit: 100 +-- Check INSERT .. ON CONFLICT DO UPDATE works correctly when the view's +-- columns are named and ordered differently than the underlying table's. +create table uv_iocu_tab (a text unique, b float) +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE uv_iocu_tab (a text UNIQUE, b double precision)" +== 957 +-- truncate_limit: 100 +insert into uv_iocu_tab values ('xyxyxy', 0) +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_tab VALUES ('xyxyxy', 0)" +== 958 +-- truncate_limit: 100 +create view uv_iocu_view as + select b, b+1 as c, a, '2.0'::text as two from uv_iocu_tab +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DDL +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW uv_iocu_view AS SELECT b, b + 1 AS c, a, '2.0'::text AS two FROM uv_iocu_tab" +== 959 +-- truncate_limit: 100 +insert into uv_iocu_view (a, b) values ('xyxyxy', 1) + on conflict (a) do update set b = uv_iocu_view.b +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (a, b) VALUES ('xyxyxy', 1) ON CONFLICT (a) DO UPDATE SET ... = ..." +== 960 +-- truncate_limit: 100 +select * from uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uv_iocu_tab" +== 961 +-- truncate_limit: 100 +insert into uv_iocu_view (a, b) values ('xyxyxy', 1) + on conflict (a) do update set b = excluded.b +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (a, b) VALUES ('xyxyxy', 1) ON CONFLICT (a) DO UPDATE SET b = excluded.b" +== 962 +-- truncate_limit: 100 +select * from uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uv_iocu_tab" +== 963 +-- truncate_limit: 100 +-- OK to access view columns that are not present in underlying base +-- relation in the ON CONFLICT portion of the query +insert into uv_iocu_view (a, b) values ('xyxyxy', 3) + on conflict (a) do update set b = cast(excluded.two as float) +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (a, b) VALUES ('xyxyxy', 3) ON CONFLICT (a) DO UPDATE SET ... = ..." +== 964 +-- truncate_limit: 100 +select * from uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uv_iocu_tab" +== 965 +-- truncate_limit: 100 +explain (costs off) +insert into uv_iocu_view (a, b) values ('xyxyxy', 3) + on conflict (a) do update set b = excluded.b where excluded.c > 0 +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO uv_iocu_view (a, b) VALUES ('xyxyxy', 3) ON CONFLICT (a) DO UPDAT..." +== 966 +-- truncate_limit: 100 +insert into uv_iocu_view (a, b) values ('xyxyxy', 3) + on conflict (a) do update set b = excluded.b where excluded.c > 0 +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (a, b) VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... WHERE ..." +== 967 +-- truncate_limit: 100 +select * from uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uv_iocu_tab" +== 968 +-- truncate_limit: 100 +drop view uv_iocu_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW uv_iocu_view" +== 969 +-- truncate_limit: 100 +drop table uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE uv_iocu_tab" +== 970 +-- truncate_limit: 100 +-- Test whole-row references to the view +create table uv_iocu_tab (a int unique, b text) +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE uv_iocu_tab (a int UNIQUE, b text)" +== 971 +-- truncate_limit: 100 +create view uv_iocu_view as + select b as bb, a as aa, uv_iocu_tab::text as cc from uv_iocu_tab +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DDL +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW uv_iocu_view AS SELECT b AS bb, a AS aa, uv_iocu_tab::text AS cc FROM uv_iocu_tab" +== 972 +-- truncate_limit: 100 +insert into uv_iocu_view (aa,bb) values (1,'x') +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (aa, bb) VALUES (1, 'x')" +== 973 +-- truncate_limit: 100 +explain (costs off) +insert into uv_iocu_view (aa,bb) values (1,'y') + on conflict (aa) do update set bb = 'Rejected: '||excluded.* + where excluded.aa > 0 + and excluded.bb != '' + and excluded.cc is not null +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: ExplainStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) INSERT INTO uv_iocu_view (aa, bb) VALUES (1, 'y') ON CONFLICT (aa) DO UPDATE ..." +== 974 +-- truncate_limit: 100 +insert into uv_iocu_view (aa,bb) values (1,'y') + on conflict (aa) do update set bb = 'Rejected: '||excluded.* + where excluded.aa > 0 + and excluded.bb != '' + and excluded.cc is not null +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (aa, bb) VALUES (1, 'y') ON CONFLICT (aa) DO UPDATE SET ... = ... WHERE ..." +== 975 +-- truncate_limit: 100 +select * from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uv_iocu_view" +== 976 +-- truncate_limit: 100 +-- Test omitting a column of the base relation +delete from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM uv_iocu_view" +== 977 +-- truncate_limit: 100 +insert into uv_iocu_view (aa,bb) values (1,'x') +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (aa, bb) VALUES (1, 'x')" +== 978 +-- truncate_limit: 100 +insert into uv_iocu_view (aa) values (1) + on conflict (aa) do update set bb = 'Rejected: '||excluded.* +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (aa) VALUES (1) ON CONFLICT (aa) DO UPDATE SET ... = ..." +== 979 +-- truncate_limit: 100 +select * from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uv_iocu_view" +== 980 +-- truncate_limit: 100 +alter table uv_iocu_tab alter column b set default 'table default' +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE uv_iocu_tab ALTER COLUMN b SET DEFAULT 'table default'" +== 981 +-- truncate_limit: 100 +insert into uv_iocu_view (aa) values (1) + on conflict (aa) do update set bb = 'Rejected: '||excluded.* +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (aa) VALUES (1) ON CONFLICT (aa) DO UPDATE SET ... = ..." +== 982 +-- truncate_limit: 100 +select * from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uv_iocu_view" +== 983 +-- truncate_limit: 100 +alter view uv_iocu_view alter column bb set default 'view default' +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW uv_iocu_view ALTER COLUMN bb SET DEFAULT 'view default'" +== 984 +-- truncate_limit: 100 +insert into uv_iocu_view (aa) values (1) + on conflict (aa) do update set bb = 'Rejected: '||excluded.* +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (aa) VALUES (1) ON CONFLICT (aa) DO UPDATE SET ... = ..." +== 985 +-- truncate_limit: 100 +select * from uv_iocu_view +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM uv_iocu_view" +== 986 +-- truncate_limit: 100 +-- Should fail to update non-updatable columns +insert into uv_iocu_view (aa) values (1) + on conflict (aa) do update set cc = 'XXX' +-- +TABLE: name="uv_iocu_view" schema="" table="uv_iocu_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO uv_iocu_view (aa) VALUES (1) ON CONFLICT (aa) DO UPDATE SET cc = 'XXX'" +== 987 +-- truncate_limit: 100 +drop view uv_iocu_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW uv_iocu_view" +== 988 +-- truncate_limit: 100 +drop table uv_iocu_tab +-- +TABLE: name="uv_iocu_tab" schema="" table="uv_iocu_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE uv_iocu_tab" +== 989 +-- truncate_limit: 100 +-- ON CONFLICT DO UPDATE permissions checks +create user regress_view_user1 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_view_user1" +== 990 +-- truncate_limit: 100 +create user regress_view_user2 +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_view_user2" +== 991 +-- truncate_limit: 100 +set session authorization regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 992 +-- truncate_limit: 100 +create table base_tbl(a int unique, b text, c float) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tbl (a int UNIQUE, b text, c double precision)" +== 993 +-- truncate_limit: 100 +insert into base_tbl values (1,'xxx',1.0) +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tbl VALUES (1, 'xxx', 1.0)" +== 994 +-- truncate_limit: 100 +create view rw_view1 as select b as bb, c as cc, a as aa from base_tbl +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view1 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl" +== 995 +-- truncate_limit: 100 +grant select (aa,bb) on rw_view1 to regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (aa, bb) ON rw_view1 TO regress_view_user2" +== 996 +-- truncate_limit: 100 +grant insert on rw_view1 to regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert ON rw_view1 TO regress_view_user2" +== 997 +-- truncate_limit: 100 +grant update (bb) on rw_view1 to regress_view_user2 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (bb) ON rw_view1 TO regress_view_user2" +== 998 +-- truncate_limit: 100 +set session authorization regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 999 +-- truncate_limit: 100 +insert into rw_view1 values ('yyy',2.0,1) + on conflict (aa) do update set bb = excluded.cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('yyy', 2.0, 1) ON CONFLICT (aa) DO UPDATE SET bb = excluded.cc" +== 1000 +-- truncate_limit: 100 +-- Not allowed +insert into rw_view1 values ('yyy',2.0,1) + on conflict (aa) do update set bb = rw_view1.cc +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('yyy', 2.0, 1) ON CONFLICT (aa) DO UPDATE SET bb = rw_view1.cc" +== 1001 +-- truncate_limit: 100 +-- Not allowed +insert into rw_view1 values ('yyy',2.0,1) + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('yyy', 2.0, 1) ON CONFLICT (aa) DO UPDATE SET bb = excluded.bb" +== 1002 +-- truncate_limit: 100 +-- OK +insert into rw_view1 values ('zzz',2.0,1) + on conflict (aa) do update set bb = rw_view1.bb||'xxx' +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('zzz', 2.0, 1) ON CONFLICT (aa) DO UPDATE SET bb = rw_view1.bb || 'xxx'" +== 1003 +-- truncate_limit: 100 +-- OK +insert into rw_view1 values ('zzz',2.0,1) + on conflict (aa) do update set cc = 3.0 +-- +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view1 VALUES ('zzz', 2.0, 1) ON CONFLICT (aa) DO UPDATE SET cc = 3.0" +== 1004 +-- truncate_limit: 100 +-- Not allowed +reset session authorization +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 1005 +-- truncate_limit: 100 +select * from base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 1006 +-- truncate_limit: 100 +set session authorization regress_view_user1 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user1" +== 1007 +-- truncate_limit: 100 +grant select (a,b) on base_tbl to regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT select (a, b) ON base_tbl TO regress_view_user2" +== 1008 +-- truncate_limit: 100 +grant insert (a,b) on base_tbl to regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT insert (a, b) ON base_tbl TO regress_view_user2" +== 1009 +-- truncate_limit: 100 +grant update (a,b) on base_tbl to regress_view_user2 +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT update (a, b) ON base_tbl TO regress_view_user2" +== 1010 +-- truncate_limit: 100 +set session authorization regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 1011 +-- truncate_limit: 100 +create view rw_view2 as select b as bb, c as cc, a as aa from base_tbl +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view2 AS SELECT b AS bb, c AS cc, a AS aa FROM base_tbl" +== 1012 +-- truncate_limit: 100 +insert into rw_view2 (aa,bb) values (1,'xxx') + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view2" schema="" table="rw_view2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view2 (aa, bb) VALUES (1, 'xxx') ON CONFLICT (aa) DO UPDATE SET bb = excluded.bb" +== 1013 +-- truncate_limit: 100 +-- Not allowed +create view rw_view3 as select b as bb, a as aa from base_tbl +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DDL +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view3 AS SELECT b AS bb, a AS aa FROM base_tbl" +== 1014 +-- truncate_limit: 100 +insert into rw_view3 (aa,bb) values (1,'xxx') + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view3" schema="" table="rw_view3" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view3 (aa, bb) VALUES (1, 'xxx') ON CONFLICT (aa) DO UPDATE SET bb = excluded.bb" +== 1015 +-- truncate_limit: 100 +-- OK +reset session authorization +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 1016 +-- truncate_limit: 100 +select * from base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 1017 +-- truncate_limit: 100 +set session authorization regress_view_user2 +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_view_user2" +== 1018 +-- truncate_limit: 100 +create view rw_view4 as select aa, bb, cc FROM rw_view1 +-- +TABLE: name="rw_view4" schema="" table="rw_view4" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view4 AS SELECT aa, bb, cc FROM rw_view1" +== 1019 +-- truncate_limit: 100 +insert into rw_view4 (aa,bb) values (1,'yyy') + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view4" schema="" table="rw_view4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view4 (aa, bb) VALUES (1, 'yyy') ON CONFLICT (aa) DO UPDATE SET bb = excluded.bb" +== 1020 +-- truncate_limit: 100 +-- Not allowed +create view rw_view5 as select aa, bb FROM rw_view1 +-- +TABLE: name="rw_view5" schema="" table="rw_view5" ctx=DDL +TABLE: name="rw_view1" schema="" table="rw_view1" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW rw_view5 AS SELECT aa, bb FROM rw_view1" +== 1021 +-- truncate_limit: 100 +insert into rw_view5 (aa,bb) values (1,'yyy') + on conflict (aa) do update set bb = excluded.bb +-- +TABLE: name="rw_view5" schema="" table="rw_view5" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO rw_view5 (aa, bb) VALUES (1, 'yyy') ON CONFLICT (aa) DO UPDATE SET bb = excluded.bb" +== 1022 +-- truncate_limit: 100 +-- OK +reset session authorization +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 1023 +-- truncate_limit: 100 +select * from base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tbl" +== 1024 +-- truncate_limit: 100 +drop view rw_view5 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rw_view5" +== 1025 +-- truncate_limit: 100 +drop view rw_view4 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rw_view4" +== 1026 +-- truncate_limit: 100 +drop view rw_view3 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rw_view3" +== 1027 +-- truncate_limit: 100 +drop view rw_view2 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rw_view2" +== 1028 +-- truncate_limit: 100 +drop view rw_view1 +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW rw_view1" +== 1029 +-- truncate_limit: 100 +drop table base_tbl +-- +TABLE: name="base_tbl" schema="" table="base_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tbl" +== 1030 +-- truncate_limit: 100 +drop user regress_view_user1 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_view_user1" +== 1031 +-- truncate_limit: 100 +drop user regress_view_user2 +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_view_user2" +== 1032 +-- truncate_limit: 100 +-- Test single- and multi-row inserts with table and view defaults. +-- Table defaults should be used, unless overridden by view defaults. +create table base_tab_def (a int, b text default 'Table default', + c text default 'Table default', d text, e text) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tab_def (a int, b text DEFAULT 'Table default', c text DEFAULT 'Table default',..." +== 1033 +-- truncate_limit: 100 +create view base_tab_def_view as select * from base_tab_def +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW base_tab_def_view AS SELECT * FROM base_tab_def" +== 1034 +-- truncate_limit: 100 +alter view base_tab_def_view alter b set default 'View default' +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW base_tab_def_view ALTER COLUMN b SET DEFAULT 'View default'" +== 1035 +-- truncate_limit: 100 +alter view base_tab_def_view alter d set default 'View default' +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW base_tab_def_view ALTER COLUMN d SET DEFAULT 'View default'" +== 1036 +-- truncate_limit: 100 +insert into base_tab_def values (1) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (1)" +== 1037 +-- truncate_limit: 100 +insert into base_tab_def values (2), (3) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (2), (3)" +== 1038 +-- truncate_limit: 100 +insert into base_tab_def values (4, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (4, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1039 +-- truncate_limit: 100 +insert into base_tab_def values (5, default, default, default, default), + (6, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (...)" +== 1040 +-- truncate_limit: 100 +insert into base_tab_def_view values (11) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (11)" +== 1041 +-- truncate_limit: 100 +insert into base_tab_def_view values (12), (13) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (12), (13)" +== 1042 +-- truncate_limit: 100 +insert into base_tab_def_view values (14, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (14, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1043 +-- truncate_limit: 100 +insert into base_tab_def_view values (15, default, default, default, default), + (16, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (...)" +== 1044 +-- truncate_limit: 100 +insert into base_tab_def_view values (17), (default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (17), (DEFAULT)" +== 1045 +-- truncate_limit: 100 +select * from base_tab_def order by a +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tab_def ORDER BY a" +== 1046 +-- truncate_limit: 100 +-- Adding an INSTEAD OF trigger should cause NULLs to be inserted instead of +-- table defaults, where there are no view defaults. +create function base_tab_def_view_instrig_func() returns trigger +as +$$ +begin + insert into base_tab_def values (new.a, new.b, new.c, new.d, new.e); + return new; +end; +$$ +language plpgsql +-- +FUNCTION: name="base_tab_def_view_instrig_func" function="base_tab_def_view_instrig_func" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION base_tab_def_view_instrig_func() RETURNS trigger AS $$\nbegin\n insert into base_t..." +== 1047 +-- truncate_limit: 100 +create trigger base_tab_def_view_instrig instead of insert on base_tab_def_view + for each row execute function base_tab_def_view_instrig_func() +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER base_tab_def_view_instrig INSTEAD OF INSERT ON base_tab_def_view FOR EACH ROW EXEC..." +== 1048 +-- truncate_limit: 100 +truncate base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE base_tab_def" +== 1049 +-- truncate_limit: 100 +insert into base_tab_def values (1) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (1)" +== 1050 +-- truncate_limit: 100 +insert into base_tab_def values (2), (3) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (2), (3)" +== 1051 +-- truncate_limit: 100 +insert into base_tab_def values (4, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (4, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1052 +-- truncate_limit: 100 +insert into base_tab_def values (5, default, default, default, default), + (6, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (...)" +== 1053 +-- truncate_limit: 100 +insert into base_tab_def_view values (11) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (11)" +== 1054 +-- truncate_limit: 100 +insert into base_tab_def_view values (12), (13) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (12), (13)" +== 1055 +-- truncate_limit: 100 +insert into base_tab_def_view values (14, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (14, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1056 +-- truncate_limit: 100 +insert into base_tab_def_view values (15, default, default, default, default), + (16, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (...)" +== 1057 +-- truncate_limit: 100 +insert into base_tab_def_view values (17), (default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (17), (DEFAULT)" +== 1058 +-- truncate_limit: 100 +select * from base_tab_def order by a +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tab_def ORDER BY a" +== 1059 +-- truncate_limit: 100 +-- Using an unconditional DO INSTEAD rule should also cause NULLs to be +-- inserted where there are no view defaults. +drop trigger base_tab_def_view_instrig on base_tab_def_view +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER base_tab_def_view_instrig ON base_tab_def_view" +== 1060 +-- truncate_limit: 100 +drop function base_tab_def_view_instrig_func +-- +FUNCTION: name="base_tab_def_view_instrig_func" function="base_tab_def_view_instrig_func" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION base_tab_def_view_instrig_func" +== 1061 +-- truncate_limit: 100 +create rule base_tab_def_view_ins_rule as on insert to base_tab_def_view + do instead insert into base_tab_def values (new.a, new.b, new.c, new.d, new.e) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE base_tab_def_view_ins_rule AS ON INSERT TO base_tab_def_view DO INSTEAD INSERT INTO b..." +== 1062 +-- truncate_limit: 100 +truncate base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE base_tab_def" +== 1063 +-- truncate_limit: 100 +insert into base_tab_def values (1) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (1)" +== 1064 +-- truncate_limit: 100 +insert into base_tab_def values (2), (3) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (2), (3)" +== 1065 +-- truncate_limit: 100 +insert into base_tab_def values (4, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (4, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1066 +-- truncate_limit: 100 +insert into base_tab_def values (5, default, default, default, default), + (6, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (...)" +== 1067 +-- truncate_limit: 100 +insert into base_tab_def_view values (11) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (11)" +== 1068 +-- truncate_limit: 100 +insert into base_tab_def_view values (12), (13) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (12), (13)" +== 1069 +-- truncate_limit: 100 +insert into base_tab_def_view values (14, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (14, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1070 +-- truncate_limit: 100 +insert into base_tab_def_view values (15, default, default, default, default), + (16, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (...)" +== 1071 +-- truncate_limit: 100 +insert into base_tab_def_view values (17), (default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (17), (DEFAULT)" +== 1072 +-- truncate_limit: 100 +select * from base_tab_def order by a +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tab_def ORDER BY a" +== 1073 +-- truncate_limit: 100 +-- A DO ALSO rule should cause each row to be inserted twice. The first +-- insert should behave the same as an auto-updatable view (using table +-- defaults, unless overridden by view defaults). The second insert should +-- behave the same as a rule-updatable view (inserting NULLs where there are +-- no view defaults). +drop rule base_tab_def_view_ins_rule on base_tab_def_view +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE base_tab_def_view_ins_rule ON base_tab_def_view" +== 1074 +-- truncate_limit: 100 +create rule base_tab_def_view_ins_rule as on insert to base_tab_def_view + do also insert into base_tab_def values (new.a, new.b, new.c, new.d, new.e) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE base_tab_def_view_ins_rule AS ON INSERT TO base_tab_def_view DO INSERT INTO base_tab_..." +== 1075 +-- truncate_limit: 100 +truncate base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE base_tab_def" +== 1076 +-- truncate_limit: 100 +insert into base_tab_def values (1) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (1)" +== 1077 +-- truncate_limit: 100 +insert into base_tab_def values (2), (3) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (2), (3)" +== 1078 +-- truncate_limit: 100 +insert into base_tab_def values (4, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (4, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1079 +-- truncate_limit: 100 +insert into base_tab_def values (5, default, default, default, default), + (6, default, default, default, default) +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def VALUES (...)" +== 1080 +-- truncate_limit: 100 +insert into base_tab_def_view values (11) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (11)" +== 1081 +-- truncate_limit: 100 +insert into base_tab_def_view values (12), (13) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (12), (13)" +== 1082 +-- truncate_limit: 100 +insert into base_tab_def_view values (14, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (14, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1083 +-- truncate_limit: 100 +insert into base_tab_def_view values (15, default, default, default, default), + (16, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (...)" +== 1084 +-- truncate_limit: 100 +insert into base_tab_def_view values (17), (default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (17), (DEFAULT)" +== 1085 +-- truncate_limit: 100 +select * from base_tab_def order by a, c NULLS LAST +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tab_def ORDER BY a, c NULLS LAST" +== 1086 +-- truncate_limit: 100 +-- Test a DO ALSO INSERT ... SELECT rule +drop rule base_tab_def_view_ins_rule on base_tab_def_view +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE base_tab_def_view_ins_rule ON base_tab_def_view" +== 1087 +-- truncate_limit: 100 +create rule base_tab_def_view_ins_rule as on insert to base_tab_def_view + do also insert into base_tab_def (a, b, e) select new.a, new.b, 'xxx' +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE base_tab_def_view_ins_rule AS ON INSERT TO base_tab_def_view DO INSERT INTO base_tab_..." +== 1088 +-- truncate_limit: 100 +truncate base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE base_tab_def" +== 1089 +-- truncate_limit: 100 +insert into base_tab_def_view values (1, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (1, DEFAULT, DEFAULT, DEFAULT, DEFAULT)" +== 1090 +-- truncate_limit: 100 +insert into base_tab_def_view values (2, default, default, default, default), + (3, default, default, default, default) +-- +TABLE: name="base_tab_def_view" schema="" table="base_tab_def_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_def_view VALUES (...)" +== 1091 +-- truncate_limit: 100 +select * from base_tab_def order by a, e nulls first +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tab_def ORDER BY a, e NULLS FIRST" +== 1092 +-- truncate_limit: 100 +drop view base_tab_def_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW base_tab_def_view" +== 1093 +-- truncate_limit: 100 +drop table base_tab_def +-- +TABLE: name="base_tab_def" schema="" table="base_tab_def" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tab_def" +== 1094 +-- truncate_limit: 100 +-- Test defaults with array assignments +create table base_tab (a serial, b int[], c text, d text default 'Table default') +-- +TABLE: name="base_tab" schema="" table="base_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE base_tab (a serial, b int[], c text, d text DEFAULT 'Table default')" +== 1095 +-- truncate_limit: 100 +create view base_tab_view as select c, a, b from base_tab +-- +TABLE: name="base_tab_view" schema="" table="base_tab_view" ctx=DDL +TABLE: name="base_tab" schema="" table="base_tab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW base_tab_view AS SELECT c, a, b FROM base_tab" +== 1096 +-- truncate_limit: 100 +alter view base_tab_view alter column c set default 'View default' +-- +TABLE: name="base_tab_view" schema="" table="base_tab_view" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER VIEW base_tab_view ALTER COLUMN c SET DEFAULT 'View default'" +== 1097 +-- truncate_limit: 100 +insert into base_tab_view (b[1], b[2], c, b[5], b[4], a, b[3]) +values (1, 2, default, 5, 4, default, 3), (10, 11, 'C value', 14, 13, 100, 12) +-- +TABLE: name="base_tab_view" schema="" table="base_tab_view" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO base_tab_view (b[1], b[2], c, b[5], b[4], a, b[3]) VALUES (...)" +== 1098 +-- truncate_limit: 100 +select * from base_tab order by a +-- +TABLE: name="base_tab" schema="" table="base_tab" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM base_tab ORDER BY a" +== 1099 +-- truncate_limit: 100 +drop view base_tab_view +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW base_tab_view" +== 1100 +-- truncate_limit: 100 +drop table base_tab +-- +TABLE: name="base_tab" schema="" table="base_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE base_tab" diff --git a/parser/testdata/summary_truncate/postgres_regress/update.metadata.json b/parser/testdata/summary_truncate/postgres_regress/update.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/update.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/update.test b/parser/testdata/summary_truncate/postgres_regress/update.test new file mode 100644 index 0000000..b65f81f --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/update.test @@ -0,0 +1,2192 @@ +== 001 +-- truncate_limit: 100 +|-- +-- UPDATE syntax tests +|-- + +CREATE TABLE update_test ( + a INT DEFAULT 10, + b INT, + c TEXT +) +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE update_test (a int DEFAULT 10, b int, c text)" +== 002 +-- truncate_limit: 100 +CREATE TABLE upsert_test ( + a INT PRIMARY KEY, + b TEXT +) +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE upsert_test (a int PRIMARY KEY, b text)" +== 003 +-- truncate_limit: 100 +INSERT INTO update_test VALUES (5, 10, 'foo') +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO update_test VALUES (5, 10, 'foo')" +== 004 +-- truncate_limit: 100 +INSERT INTO update_test(b, a) VALUES (15, 10) +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO update_test (b, a) VALUES (15, 10)" +== 005 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 006 +-- truncate_limit: 100 +UPDATE update_test SET a = DEFAULT, b = DEFAULT +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test SET a = DEFAULT, b = DEFAULT" +== 007 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 008 +-- truncate_limit: 100 +-- aliases for the UPDATE target table +UPDATE update_test AS t SET b = 10 WHERE t.a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +ALIAS: "t"="update_test" +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test t SET b = 10 WHERE t.a = 10" +== 009 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 010 +-- truncate_limit: 100 +UPDATE update_test t SET b = t.b + 10 WHERE t.a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +ALIAS: "t"="update_test" +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test t SET b = t.b + 10 WHERE t.a = 10" +== 011 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 012 +-- truncate_limit: 100 +-- error, you're not supposed to qualify the target column +UPDATE update_test t SET t.b = t.b + 10 WHERE t.a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +ALIAS: "t"="update_test" +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test t SET t.b = t.b + 10 WHERE t.a = 10" +== 013 +-- truncate_limit: 100 +|-- +-- Test VALUES in FROM +|-- + +UPDATE update_test SET a=v.i FROM (VALUES(100, 20)) AS v(i, j) + WHERE update_test.b = v.j +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test SET a = v.i FROM (VALUES (100, 20)) v(i, j) WHERE update_test.b = v.j" +== 014 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 015 +-- truncate_limit: 100 +-- fail, wrong data type: +UPDATE update_test SET a = v.* FROM (VALUES(100, 20)) AS v(i, j) + WHERE update_test.b = v.j +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test SET a = v.* FROM (VALUES (100, 20)) v(i, j) WHERE update_test.b = v.j" +== 016 +-- truncate_limit: 100 +|-- +-- Test multiple-set-clause syntax +|-- + +INSERT INTO update_test SELECT a,b+1,c FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO update_test SELECT a, b + 1, c FROM update_test" +== 017 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 018 +-- truncate_limit: 100 +UPDATE update_test SET (c,b,a) = ('bugle', b+11, DEFAULT) WHERE c = 'foo' +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test SET (c, b, a) = ('bugle', b + 11, DEFAULT) WHERE c = 'foo'" +== 019 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 020 +-- truncate_limit: 100 +UPDATE update_test SET (c,b) = ('car', a+b), a = a + 1 WHERE a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test SET (c, b) = ('car', a + b), a = a + 1 WHERE a = 10" +== 021 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 022 +-- truncate_limit: 100 +-- fail, multi assignment to same column: +UPDATE update_test SET (c,b) = ('car', a+b), b = a + 1 WHERE a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test SET (c, b) = ('car', a + b), b = a + 1 WHERE a = 10" +== 023 +-- truncate_limit: 100 +-- uncorrelated sub-select: +UPDATE update_test + SET (b,a) = (select a,b from update_test where b = 41 and c = 'car') + WHERE a = 100 AND b = 20 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +FILTER: schema="" table="" column="b" +FILTER: schema="" table="" column="c" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test SET (b, a) = (SELECT a, b FROM update_test WHERE ...) WHERE a = 100 AND b = 20" +== 024 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 025 +-- truncate_limit: 100 +-- correlated sub-select: +UPDATE update_test o + SET (b,a) = (select a+1,b from update_test i + where i.a=o.a and i.b=o.b and i.c is not distinct from o.c) +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +ALIAS: "i"="update_test" +ALIAS: "o"="update_test" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="o" column="a" +FILTER: schema="" table="i" column="b" +FILTER: schema="" table="o" column="b" +FILTER: schema="" table="i" column="c" +FILTER: schema="" table="o" column="c" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="o" column="a" +FILTER: schema="" table="i" column="b" +FILTER: schema="" table="o" column="b" +FILTER: schema="" table="i" column="c" +FILTER: schema="" table="o" column="c" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test o SET (b, a) = (SELECT a + 1, b FROM update_test i WHERE ...)" +== 026 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 027 +-- truncate_limit: 100 +-- fail, multiple rows supplied: +UPDATE update_test SET (b,a) = (select a+1,b from update_test) +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test SET (b, a) = (SELECT a + 1, b FROM update_test)" +== 028 +-- truncate_limit: 100 +-- set to null if no rows supplied: +UPDATE update_test SET (b,a) = (select a+1,b from update_test where a = 1000) + WHERE a = 11 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test SET (b, a) = (SELECT a + 1, b FROM update_test WHERE a = 1000) WHERE a = 11" +== 029 +-- truncate_limit: 100 +SELECT * FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM update_test" +== 030 +-- truncate_limit: 100 +-- *-expansion should work in this context: +UPDATE update_test SET (a,b) = ROW(v.*) FROM (VALUES(21, 100)) AS v(i, j) + WHERE update_test.a = v.i +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test SET (a, b) = ROW(v.*) FROM (VALUES (21, 100)) v(i, j) WHERE update_test.a = v.i" +== 031 +-- truncate_limit: 100 +-- you might expect this to work, but syntactically it's not a RowExpr: +UPDATE update_test SET (a,b) = (v.*) FROM (VALUES(21, 101)) AS v(i, j) + WHERE update_test.a = v.i +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test SET (a, b) = v.* FROM (VALUES (21, 101)) v(i, j) WHERE update_test.a = v.i" +== 032 +-- truncate_limit: 100 +-- if an alias for the target table is specified, don't allow references +-- to the original table name +UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a = 10 +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +ALIAS: "t"="update_test" +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test t SET b = update_test.b + 10 WHERE t.a = 10" +== 033 +-- truncate_limit: 100 +-- Make sure that we can update to a TOASTed value. +UPDATE update_test SET c = repeat('x', 10000) WHERE c = 'car' +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: UpdateStmt +TRUNCATED: "UPDATE update_test SET c = repeat('x', 10000) WHERE c = 'car'" +== 034 +-- truncate_limit: 100 +SELECT a, b, char_length(c) FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, char_length(c) FROM update_test" +== 035 +-- truncate_limit: 100 +-- Check multi-assignment with a Result node to handle a one-time filter. +EXPLAIN (VERBOSE, COSTS OFF) +UPDATE update_test t + SET (a, b) = (SELECT b, a FROM update_test s WHERE s.a = t.a) + WHERE CURRENT_USER = SESSION_USER +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +ALIAS: "s"="update_test" +ALIAS: "t"="update_test" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="t" column="a" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="t" column="a" +STMT: ExplainStmt +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) UPDATE update_test t SET (a, b) = (SELECT b, a FROM update_test s WH..." +== 036 +-- truncate_limit: 100 +UPDATE update_test t + SET (a, b) = (SELECT b, a FROM update_test s WHERE s.a = t.a) + WHERE CURRENT_USER = SESSION_USER +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DML +TABLE: name="update_test" schema="" table="update_test" ctx=Select +TABLE: name="update_test" schema="" table="update_test" ctx=Select +ALIAS: "s"="update_test" +ALIAS: "t"="update_test" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="t" column="a" +FILTER: schema="" table="s" column="a" +FILTER: schema="" table="t" column="a" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE update_test t SET ... = ... WHERE current_user = session_user" +== 037 +-- truncate_limit: 100 +SELECT a, b, char_length(c) FROM update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=Select +FUNCTION: name="char_length" function="char_length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT a, b, char_length(c) FROM update_test" +== 038 +-- truncate_limit: 100 +-- Test ON CONFLICT DO UPDATE + +INSERT INTO upsert_test VALUES(1, 'Boo'), (3, 'Zoo') +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert_test VALUES (1, 'Boo'), (3, 'Zoo')" +== 039 +-- truncate_limit: 100 +-- uncorrelated sub-select: +WITH aaa AS (SELECT 1 AS a, 'Foo' AS b) INSERT INTO upsert_test + VALUES (1, 'Bar') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b, a FROM aaa) RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +CTE: "aaa" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aaa AS (...) INSERT INTO upsert_test VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... RE..." +== 040 +-- truncate_limit: 100 +-- correlated sub-select: +INSERT INTO upsert_test VALUES (1, 'Baz'), (3, 'Zaz') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b || ', Correlated', a from upsert_test i WHERE i.a = upsert_test.a) + RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +ALIAS: "i"="upsert_test" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="upsert_test" column="a" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="upsert_test" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert_test VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... RETURNING *" +== 041 +-- truncate_limit: 100 +-- correlated sub-select (EXCLUDED.* alias): +INSERT INTO upsert_test VALUES (1, 'Bat'), (3, 'Zot') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b || ', Excluded', a from upsert_test i WHERE i.a = excluded.a) + RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +ALIAS: "i"="upsert_test" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert_test VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... RETURNING *" +== 042 +-- truncate_limit: 100 +-- ON CONFLICT using system attributes in RETURNING, testing both the +-- inserting and updating paths. See bug report at: +-- https://www.postgresql.org/message-id/73436355-6432-49B1-92ED-1FE4F7E7E100%40finefun.com.au +INSERT INTO upsert_test VALUES (2, 'Beeble') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b || ', Excluded', a from upsert_test i WHERE i.a = excluded.a) + RETURNING tableoid::regclass, xmin = pg_current_xact_id()::xid AS xmin_correct, xmax = 0 AS xmax_correct +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +ALIAS: "i"="upsert_test" +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert_test VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... RETURNING tableoid::..." +== 043 +-- truncate_limit: 100 +-- currently xmax is set after a conflict - that's probably not good, +-- but it seems worthwhile to have to be explicit if that changes. +INSERT INTO upsert_test VALUES (2, 'Brox') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b || ', Excluded', a from upsert_test i WHERE i.a = excluded.a) + RETURNING tableoid::regclass, xmin = pg_current_xact_id()::xid AS xmin_correct, xmax = pg_current_xact_id()::xid AS xmax_correct +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=Select +ALIAS: "i"="upsert_test" +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +FILTER: schema="" table="i" column="a" +FILTER: schema="" table="excluded" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert_test VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... RETURNING tableoid::..." +== 044 +-- truncate_limit: 100 +DROP TABLE update_test +-- +TABLE: name="update_test" schema="" table="update_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE update_test" +== 045 +-- truncate_limit: 100 +DROP TABLE upsert_test +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE upsert_test" +== 046 +-- truncate_limit: 100 +-- Test ON CONFLICT DO UPDATE with partitioned table and non-identical children + +CREATE TABLE upsert_test ( + a INT PRIMARY KEY, + b TEXT +) PARTITION BY LIST (a) +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE upsert_test (a int PRIMARY KEY, b text) PARTITION BY LIST (a)" +== 047 +-- truncate_limit: 100 +CREATE TABLE upsert_test_1 PARTITION OF upsert_test FOR VALUES IN (1) +-- +TABLE: name="upsert_test_1" schema="" table="upsert_test_1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE upsert_test_1 PARTITION OF upsert_test FOR VALUES IN (1)" +== 048 +-- truncate_limit: 100 +CREATE TABLE upsert_test_2 (b TEXT, a INT PRIMARY KEY) +-- +TABLE: name="upsert_test_2" schema="" table="upsert_test_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE upsert_test_2 (b text, a int PRIMARY KEY)" +== 049 +-- truncate_limit: 100 +ALTER TABLE upsert_test ATTACH PARTITION upsert_test_2 FOR VALUES IN (2) +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE upsert_test ATTACH PARTITION upsert_test_2 FOR VALUES IN (2)" +== 050 +-- truncate_limit: 100 +INSERT INTO upsert_test VALUES(1, 'Boo'), (2, 'Zoo') +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO upsert_test VALUES (1, 'Boo'), (2, 'Zoo')" +== 051 +-- truncate_limit: 100 +-- uncorrelated sub-select: +WITH aaa AS (SELECT 1 AS a, 'Foo' AS b) INSERT INTO upsert_test + VALUES (1, 'Bar') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b, a FROM aaa) RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +CTE: "aaa" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aaa AS (...) INSERT INTO upsert_test VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... RE..." +== 052 +-- truncate_limit: 100 +-- correlated sub-select: +WITH aaa AS (SELECT 1 AS ctea, ' Foo' AS cteb) INSERT INTO upsert_test + VALUES (1, 'Bar'), (2, 'Baz') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT upsert_test.b||cteb, upsert_test.a FROM aaa) RETURNING * +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DML +CTE: "aaa" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aaa AS (...) INSERT INTO upsert_test VALUES (...) ON CONFLICT (a) DO UPDATE SET ... = ... RE..." +== 053 +-- truncate_limit: 100 +DROP TABLE upsert_test +-- +TABLE: name="upsert_test" schema="" table="upsert_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE upsert_test" +== 054 +-- truncate_limit: 100 +--------------------------- +-- UPDATE with row movement +--------------------------- + +-- When a partitioned table receives an UPDATE to the partitioned key and the +-- new values no longer meet the partition's bound, the row must be moved to +-- the correct partition for the new partition key (if one exists). We must +-- also ensure that updatable views on partitioned tables properly enforce any +-- WITH CHECK OPTION that is defined. The situation with triggers in this case +-- also requires thorough testing as partition key updates causing row +-- movement convert UPDATEs into DELETE+INSERT. + +CREATE TABLE range_parted ( + a text, + b bigint, + c numeric, + d int, + e varchar +) PARTITION BY RANGE (a, b) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE range_parted (a text, b bigint, c numeric, d int, e varchar) PARTITION BY RANGE (a, b)" +== 055 +-- truncate_limit: 100 +-- Create partitions intentionally in descending bound order, so as to test +-- that update-row-movement works with the leaf partitions not in bound order. +CREATE TABLE part_b_20_b_30 (e varchar, c numeric, a text, b bigint, d int) +-- +TABLE: name="part_b_20_b_30" schema="" table="part_b_20_b_30" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_b_20_b_30 (e varchar, c numeric, a text, b bigint, d int)" +== 056 +-- truncate_limit: 100 +ALTER TABLE range_parted ATTACH PARTITION part_b_20_b_30 FOR VALUES FROM ('b', 20) TO ('b', 30) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ATTACH PARTITION part_b_20_b_30 FOR VALUES FROM ('b', 20) TO ('b', 30)" +== 057 +-- truncate_limit: 100 +CREATE TABLE part_b_10_b_20 (e varchar, c numeric, a text, b bigint, d int) PARTITION BY RANGE (c) +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_b_10_b_20 (e varchar, c numeric, a text, b bigint, d int) PARTITION BY RANGE (c)" +== 058 +-- truncate_limit: 100 +CREATE TABLE part_b_1_b_10 PARTITION OF range_parted FOR VALUES FROM ('b', 1) TO ('b', 10) +-- +TABLE: name="part_b_1_b_10" schema="" table="part_b_1_b_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_b_1_b_10 PARTITION OF range_parted FOR VALUES FROM ('b', 1) TO ('b', 10)" +== 059 +-- truncate_limit: 100 +ALTER TABLE range_parted ATTACH PARTITION part_b_10_b_20 FOR VALUES FROM ('b', 10) TO ('b', 20) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ATTACH PARTITION part_b_10_b_20 FOR VALUES FROM ('b', 10) TO ('b', 20)" +== 060 +-- truncate_limit: 100 +CREATE TABLE part_a_10_a_20 PARTITION OF range_parted FOR VALUES FROM ('a', 10) TO ('a', 20) +-- +TABLE: name="part_a_10_a_20" schema="" table="part_a_10_a_20" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_a_10_a_20 PARTITION OF range_parted FOR VALUES FROM ('a', 10) TO ('a', 20)" +== 061 +-- truncate_limit: 100 +CREATE TABLE part_a_1_a_10 PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('a', 10) +-- +TABLE: name="part_a_1_a_10" schema="" table="part_a_1_a_10" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_a_1_a_10 PARTITION OF range_parted FOR VALUES FROM ('a', 1) TO ('a', 10)" +== 062 +-- truncate_limit: 100 +-- Check that partition-key UPDATE works sanely on a partitioned table that +-- does not have any child partitions. +UPDATE part_b_10_b_20 set b = b - 6 +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_b_10_b_20 SET b = b - 6" +== 063 +-- truncate_limit: 100 +-- Create some more partitions following the above pattern of descending bound +-- order, but let's make the situation a bit more complex by having the +-- attribute numbers of the columns vary from their parent partition. +CREATE TABLE part_c_100_200 (e varchar, c numeric, a text, b bigint, d int) PARTITION BY range (abs(d)) +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_c_100_200 (e varchar, c numeric, a text, b bigint, d int) PARTITION BY RANGE ((..." +== 064 +-- truncate_limit: 100 +ALTER TABLE part_c_100_200 DROP COLUMN e, DROP COLUMN c, DROP COLUMN a +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_c_100_200 DROP e, DROP c, DROP a" +== 065 +-- truncate_limit: 100 +ALTER TABLE part_c_100_200 ADD COLUMN c numeric, ADD COLUMN e varchar, ADD COLUMN a text +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_c_100_200 ADD COLUMN c numeric, ADD COLUMN e varchar, ADD COLUMN a text" +== 066 +-- truncate_limit: 100 +ALTER TABLE part_c_100_200 DROP COLUMN b +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_c_100_200 DROP b" +== 067 +-- truncate_limit: 100 +ALTER TABLE part_c_100_200 ADD COLUMN b bigint +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_c_100_200 ADD COLUMN b bigint" +== 068 +-- truncate_limit: 100 +CREATE TABLE part_d_1_15 PARTITION OF part_c_100_200 FOR VALUES FROM (1) TO (15) +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_d_1_15 PARTITION OF part_c_100_200 FOR VALUES FROM (1) TO (15)" +== 069 +-- truncate_limit: 100 +CREATE TABLE part_d_15_20 PARTITION OF part_c_100_200 FOR VALUES FROM (15) TO (20) +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_d_15_20 PARTITION OF part_c_100_200 FOR VALUES FROM (15) TO (20)" +== 070 +-- truncate_limit: 100 +ALTER TABLE part_b_10_b_20 ATTACH PARTITION part_c_100_200 FOR VALUES FROM (100) TO (200) +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_b_10_b_20 ATTACH PARTITION part_c_100_200 FOR VALUES FROM (100) TO (200)" +== 071 +-- truncate_limit: 100 +CREATE TABLE part_c_1_100 (e varchar, d int, c numeric, b bigint, a text) +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_c_1_100 (e varchar, d int, c numeric, b bigint, a text)" +== 072 +-- truncate_limit: 100 +ALTER TABLE part_b_10_b_20 ATTACH PARTITION part_c_1_100 FOR VALUES FROM (1) TO (100) +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE part_b_10_b_20 ATTACH PARTITION part_c_1_100 FOR VALUES FROM (1) TO (100)" +== 073 +-- truncate_limit: 100 +-- The order of subplans should be in bound order +EXPLAIN (costs off) UPDATE range_parted set c = c - 50 WHERE c > 97 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: ExplainStmt +STMT: UpdateStmt +TRUNCATED: "EXPLAIN (COSTS OFF) UPDATE range_parted SET c = c - 50 WHERE c > 97" +== 074 +-- truncate_limit: 100 +-- fail, row movement happens only within the partition subtree. +UPDATE part_c_100_200 set c = c - 20, d = c WHERE c = 105 +-- +TABLE: name="part_c_100_200" schema="" table="part_c_100_200" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_c_100_200 SET c = c - 20, d = c WHERE c = 105" +== 075 +-- truncate_limit: 100 +-- fail, no partition key update, so no attempt to move tuple, +-- but "a = 'a'" violates partition constraint enforced by root partition) +UPDATE part_b_10_b_20 set a = 'a' +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_b_10_b_20 SET a = 'a'" +== 076 +-- truncate_limit: 100 +-- ok, partition key update, no constraint violation +UPDATE range_parted set d = d - 10 WHERE d > 10 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET d = d - 10 WHERE d > 10" +== 077 +-- truncate_limit: 100 +-- ok, no partition key update, no constraint violation +UPDATE range_parted set e = d +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET e = d" +== 078 +-- truncate_limit: 100 +-- No row found +UPDATE part_c_1_100 set c = c + 20 WHERE c = 98 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_c_1_100 SET c = c + 20 WHERE c = 98" +== 079 +-- truncate_limit: 100 +-- ok, row movement +UPDATE part_b_10_b_20 set c = c + 20 returning c, b, a +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_b_10_b_20 SET c = c + 20 RETURNING c, b, a" +== 080 +-- truncate_limit: 100 +-- fail, row movement happens only within the partition subtree. +UPDATE part_b_10_b_20 set b = b - 6 WHERE c > 116 returning * +-- +TABLE: name="part_b_10_b_20" schema="" table="part_b_10_b_20" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_b_10_b_20 SET b = b - 6 WHERE c > 116 RETURNING *" +== 081 +-- truncate_limit: 100 +-- ok, row movement, with subset of rows moved into different partition. +UPDATE range_parted set b = b - 6 WHERE c > 116 returning a, b + c +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET b = b - 6 WHERE c > 116 RETURNING a, b + c" +== 082 +-- truncate_limit: 100 +-- Common table needed for multiple test scenarios. +CREATE TABLE mintab(c1 int) +-- +TABLE: name="mintab" schema="" table="mintab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE mintab (c1 int)" +== 083 +-- truncate_limit: 100 +INSERT into mintab VALUES (120) +-- +TABLE: name="mintab" schema="" table="mintab" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO mintab VALUES (120)" +== 084 +-- truncate_limit: 100 +-- update partition key using updatable view. +CREATE VIEW upview AS SELECT * FROM range_parted WHERE (select c > c1 FROM mintab) WITH CHECK OPTION +-- +TABLE: name="upview" schema="" table="upview" ctx=DDL +TABLE: name="range_parted" schema="" table="range_parted" ctx=Select +TABLE: name="mintab" schema="" table="mintab" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW upview AS SELECT * FROM range_parted WHERE (SELECT c > c1 FROM mintab) WITH CHECK OPTION" +== 085 +-- truncate_limit: 100 +-- ok +UPDATE upview set c = 199 WHERE b = 4 +-- +TABLE: name="upview" schema="" table="upview" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE upview SET c = 199 WHERE b = 4" +== 086 +-- truncate_limit: 100 +-- fail, check option violation +UPDATE upview set c = 120 WHERE b = 4 +-- +TABLE: name="upview" schema="" table="upview" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE upview SET c = 120 WHERE b = 4" +== 087 +-- truncate_limit: 100 +-- fail, row movement with check option violation +UPDATE upview set a = 'b', b = 15, c = 120 WHERE b = 4 +-- +TABLE: name="upview" schema="" table="upview" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE upview SET a = 'b', b = 15, c = 120 WHERE b = 4" +== 088 +-- truncate_limit: 100 +-- ok, row movement, check option passes +UPDATE upview set a = 'b', b = 15 WHERE b = 4 +-- +TABLE: name="upview" schema="" table="upview" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE upview SET a = 'b', b = 15 WHERE b = 4" +== 089 +-- truncate_limit: 100 +-- cleanup +DROP VIEW upview +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW upview" +== 090 +-- truncate_limit: 100 +UPDATE range_parted set c = 95 WHERE a = 'b' and b > 10 and c > 100 returning (range_parted), * +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET c = 95 WHERE a = 'b' AND b > 10 AND c > 100 RETURNING range_parted, *" +== 091 +-- truncate_limit: 100 +CREATE FUNCTION trans_updatetrigfunc() RETURNS trigger LANGUAGE plpgsql AS +$$ + begin + raise notice 'trigger = %, old table = %, new table = %', + TG_NAME, + (select string_agg(old_table::text, ', ' ORDER BY a) FROM old_table), + (select string_agg(new_table::text, ', ' ORDER BY a) FROM new_table); + return null; + end; +$$ +-- +FUNCTION: name="trans_updatetrigfunc" function="trans_updatetrigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trans_updatetrigfunc() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n raise n..." +== 092 +-- truncate_limit: 100 +CREATE TRIGGER trans_updatetrig + AFTER UPDATE ON range_parted REFERENCING OLD TABLE AS old_table NEW TABLE AS new_table + FOR EACH STATEMENT EXECUTE PROCEDURE trans_updatetrigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trans_updatetrig AFTER UPDATE ON range_parted REFERENCING OLD TABLE old_table NEW ..." +== 093 +-- truncate_limit: 100 +UPDATE range_parted set c = (case when c = 96 then 110 else c + 1 end ) WHERE a = 'b' and b > 10 and c >= 96 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET ... = ... WHERE a = 'b' AND b > 10 AND c >= 96" +== 094 +-- truncate_limit: 100 +-- Enabling OLD TABLE capture for both DELETE as well as UPDATE stmt triggers +-- should not cause DELETEd rows to be captured twice. Similar thing for +-- INSERT triggers and inserted rows. +CREATE TRIGGER trans_deletetrig + AFTER DELETE ON range_parted REFERENCING OLD TABLE AS old_table + FOR EACH STATEMENT EXECUTE PROCEDURE trans_updatetrigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trans_deletetrig AFTER DELETE ON range_parted REFERENCING OLD TABLE old_table EXEC..." +== 095 +-- truncate_limit: 100 +CREATE TRIGGER trans_inserttrig + AFTER INSERT ON range_parted REFERENCING NEW TABLE AS new_table + FOR EACH STATEMENT EXECUTE PROCEDURE trans_updatetrigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trans_inserttrig AFTER INSERT ON range_parted REFERENCING NEW TABLE new_table EXEC..." +== 096 +-- truncate_limit: 100 +UPDATE range_parted set c = c + 50 WHERE a = 'b' and b > 10 and c >= 96 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET c = c + 50 WHERE a = 'b' AND b > 10 AND c >= 96" +== 097 +-- truncate_limit: 100 +DROP TRIGGER trans_deletetrig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trans_deletetrig ON range_parted" +== 098 +-- truncate_limit: 100 +DROP TRIGGER trans_inserttrig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trans_inserttrig ON range_parted" +== 099 +-- truncate_limit: 100 +-- Don't drop trans_updatetrig yet. It is required below. + +-- Test with transition tuple conversion happening for rows moved into the +-- new partition. This requires a trigger that references transition table +-- (we already have trans_updatetrig). For inserted rows, the conversion +-- is not usually needed, because the original tuple is already compatible with +-- the desired transition tuple format. But conversion happens when there is a +-- BR trigger because the trigger can change the inserted row. So install a +-- BR triggers on those child partitions where the rows will be moved. +CREATE FUNCTION func_parted_mod_b() RETURNS trigger AS $$ +BEGIN + NEW.b = NEW.b + 1; + return NEW; +END $$ language plpgsql +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION func_parted_mod_b() RETURNS trigger AS $$\nBEGIN\n NEW.b = NEW.b + 1;\n return N..." +== 100 +-- truncate_limit: 100 +CREATE TRIGGER trig_c1_100 BEFORE UPDATE OR INSERT ON part_c_1_100 + FOR EACH ROW EXECUTE PROCEDURE func_parted_mod_b() +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_c1_100 BEFORE INSERT OR UPDATE ON part_c_1_100 FOR EACH ROW EXECUTE FUNCTION ..." +== 101 +-- truncate_limit: 100 +CREATE TRIGGER trig_d1_15 BEFORE UPDATE OR INSERT ON part_d_1_15 + FOR EACH ROW EXECUTE PROCEDURE func_parted_mod_b() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_d1_15 BEFORE INSERT OR UPDATE ON part_d_1_15 FOR EACH ROW EXECUTE FUNCTION fu..." +== 102 +-- truncate_limit: 100 +CREATE TRIGGER trig_d15_20 BEFORE UPDATE OR INSERT ON part_d_15_20 + FOR EACH ROW EXECUTE PROCEDURE func_parted_mod_b() +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_d15_20 BEFORE INSERT OR UPDATE ON part_d_15_20 FOR EACH ROW EXECUTE FUNCTION ..." +== 103 +-- truncate_limit: 100 +UPDATE range_parted set c = (case when c = 96 then 110 else c + 1 end) WHERE a = 'b' and b > 10 and c >= 96 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET ... = ... WHERE a = 'b' AND b > 10 AND c >= 96" +== 104 +-- truncate_limit: 100 +UPDATE range_parted set c = c + 50 WHERE a = 'b' and b > 10 and c >= 96 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET c = c + 50 WHERE a = 'b' AND b > 10 AND c >= 96" +== 105 +-- truncate_limit: 100 +UPDATE range_parted set b = 15 WHERE b = 1 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET b = 15 WHERE b = 1" +== 106 +-- truncate_limit: 100 +DROP TRIGGER trans_updatetrig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trans_updatetrig ON range_parted" +== 107 +-- truncate_limit: 100 +DROP TRIGGER trig_c1_100 ON part_c_1_100 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trig_c1_100 ON part_c_1_100" +== 108 +-- truncate_limit: 100 +DROP TRIGGER trig_d1_15 ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trig_d1_15 ON part_d_1_15" +== 109 +-- truncate_limit: 100 +DROP TRIGGER trig_d15_20 ON part_d_15_20 +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trig_d15_20 ON part_d_15_20" +== 110 +-- truncate_limit: 100 +DROP FUNCTION func_parted_mod_b() +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION func_parted_mod_b()" +== 111 +-- truncate_limit: 100 +-- RLS policies with update-row-movement +----------------------------------------- + +ALTER TABLE range_parted ENABLE ROW LEVEL SECURITY +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE range_parted ENABLE ROW LEVEL SECURITY" +== 112 +-- truncate_limit: 100 +CREATE USER regress_range_parted_user +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE USER regress_range_parted_user" +== 113 +-- truncate_limit: 100 +GRANT ALL ON range_parted, mintab TO regress_range_parted_user +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +TABLE: name="mintab" schema="" table="mintab" ctx=DDL +STMT: GrantStmt +TRUNCATED: "GRANT ALL ON range_parted, mintab TO regress_range_parted_user" +== 114 +-- truncate_limit: 100 +CREATE POLICY seeall ON range_parted AS PERMISSIVE FOR SELECT USING (true) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY seeall ON range_parted FOR SELECT TO public USING (true)" +== 115 +-- truncate_limit: 100 +CREATE POLICY policy_range_parted ON range_parted for UPDATE USING (true) WITH CHECK (c % 2 = 0) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY policy_range_parted ON range_parted FOR UPDATE TO public USING (true) WITH CHECK ((..." +== 116 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_range_parted_user" +== 117 +-- truncate_limit: 100 +-- This should fail with RLS violation error while moving row from +-- part_a_10_a_20 to part_d_1_15, because we are setting 'c' to an odd number. +UPDATE range_parted set a = 'b', c = 151 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'b', c = 151 WHERE a = 'a' AND c = 200" +== 118 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 119 +-- truncate_limit: 100 +-- Create a trigger on part_d_1_15 +CREATE FUNCTION func_d_1_15() RETURNS trigger AS $$ +BEGIN + NEW.c = NEW.c + 1; -- Make even numbers odd, or vice versa + return NEW; +END $$ LANGUAGE plpgsql +-- +FUNCTION: name="func_d_1_15" function="func_d_1_15" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION func_d_1_15() RETURNS trigger AS $$\nBEGIN\n NEW.c = NEW.c + 1; -- Make even numb..." +== 120 +-- truncate_limit: 100 +CREATE TRIGGER trig_d_1_15 BEFORE INSERT ON part_d_1_15 + FOR EACH ROW EXECUTE PROCEDURE func_d_1_15() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_d_1_15 BEFORE INSERT ON part_d_1_15 FOR EACH ROW EXECUTE FUNCTION func_d_1_15()" +== 121 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_range_parted_user" +== 122 +-- truncate_limit: 100 +-- Here, RLS checks should succeed while moving row from part_a_10_a_20 to +-- part_d_1_15. Even though the UPDATE is setting 'c' to an odd number, the +-- trigger at the destination partition again makes it an even number. +UPDATE range_parted set a = 'b', c = 151 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'b', c = 151 WHERE a = 'a' AND c = 200" +== 123 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 124 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_range_parted_user" +== 125 +-- truncate_limit: 100 +-- This should fail with RLS violation error. Even though the UPDATE is setting +-- 'c' to an even number, the trigger at the destination partition again makes +-- it an odd number. +UPDATE range_parted set a = 'b', c = 150 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'b', c = 150 WHERE a = 'a' AND c = 200" +== 126 +-- truncate_limit: 100 +-- Cleanup +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 127 +-- truncate_limit: 100 +DROP TRIGGER trig_d_1_15 ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trig_d_1_15 ON part_d_1_15" +== 128 +-- truncate_limit: 100 +DROP FUNCTION func_d_1_15() +-- +FUNCTION: name="func_d_1_15" function="func_d_1_15" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION func_d_1_15()" +== 129 +-- truncate_limit: 100 +-- Policy expression contains SubPlan +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 130 +-- truncate_limit: 100 +CREATE POLICY policy_range_parted_subplan on range_parted + AS RESTRICTIVE for UPDATE USING (true) + WITH CHECK ((SELECT range_parted.c <= c1 FROM mintab)) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY policy_range_parted_subplan ON range_parted AS RESTRICTIVE FOR UPDATE TO public USI..." +== 131 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_range_parted_user" +== 132 +-- truncate_limit: 100 +-- fail, mintab has row with c1 = 120 +UPDATE range_parted set a = 'b', c = 122 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'b', c = 122 WHERE a = 'a' AND c = 200" +== 133 +-- truncate_limit: 100 +-- ok +UPDATE range_parted set a = 'b', c = 120 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'b', c = 120 WHERE a = 'a' AND c = 200" +== 134 +-- truncate_limit: 100 +-- RLS policy expression contains whole row. + +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 135 +-- truncate_limit: 100 +CREATE POLICY policy_range_parted_wholerow on range_parted AS RESTRICTIVE for UPDATE USING (true) + WITH CHECK (range_parted = row('b', 10, 112, 1, NULL)::range_parted) +-- +STMT: CreatePolicyStmt +TRUNCATED: "CREATE POLICY policy_range_parted_wholerow ON range_parted AS RESTRICTIVE FOR UPDATE TO public US..." +== 136 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_range_parted_user" +== 137 +-- truncate_limit: 100 +-- ok, should pass the RLS check +UPDATE range_parted set a = 'b', c = 112 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'b', c = 112 WHERE a = 'a' AND c = 200" +== 138 +-- truncate_limit: 100 +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 139 +-- truncate_limit: 100 +SET SESSION AUTHORIZATION regress_range_parted_user +-- +STMT: VariableSetStmt +TRUNCATED: "SET session_authorization TO regress_range_parted_user" +== 140 +-- truncate_limit: 100 +-- fail, the whole row RLS check should fail +UPDATE range_parted set a = 'b', c = 116 WHERE a = 'a' and c = 200 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'b', c = 116 WHERE a = 'a' AND c = 200" +== 141 +-- truncate_limit: 100 +-- Cleanup +RESET SESSION AUTHORIZATION +-- +STMT: VariableSetStmt +TRUNCATED: "RESET session_authorization" +== 142 +-- truncate_limit: 100 +DROP POLICY policy_range_parted ON range_parted +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY policy_range_parted ON range_parted" +== 143 +-- truncate_limit: 100 +DROP POLICY policy_range_parted_subplan ON range_parted +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY policy_range_parted_subplan ON range_parted" +== 144 +-- truncate_limit: 100 +DROP POLICY policy_range_parted_wholerow ON range_parted +-- +STMT: DropStmt +TRUNCATED: "DROP POLICY policy_range_parted_wholerow ON range_parted" +== 145 +-- truncate_limit: 100 +REVOKE ALL ON range_parted, mintab FROM regress_range_parted_user +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +TABLE: name="mintab" schema="" table="mintab" ctx=DDL +STMT: GrantStmt +TRUNCATED: "REVOKE ALL ON range_parted, mintab FROM regress_range_parted_user" +== 146 +-- truncate_limit: 100 +DROP USER regress_range_parted_user +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_range_parted_user" +== 147 +-- truncate_limit: 100 +DROP TABLE mintab +-- +TABLE: name="mintab" schema="" table="mintab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE mintab" +== 148 +-- truncate_limit: 100 +CREATE FUNCTION trigfunc() returns trigger language plpgsql as +$$ + begin + raise notice 'trigger = % fired on table % during %', + TG_NAME, TG_TABLE_NAME, TG_OP; + return null; + end; +$$ +-- +FUNCTION: name="trigfunc" function="trigfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION trigfunc() RETURNS trigger LANGUAGE plpgsql AS $$\n begin\n raise notice 'trigg..." +== 149 +-- truncate_limit: 100 +-- Triggers on root partition +CREATE TRIGGER parent_delete_trig + AFTER DELETE ON range_parted for each statement execute procedure trigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_delete_trig AFTER DELETE ON range_parted EXECUTE FUNCTION trigfunc()" +== 150 +-- truncate_limit: 100 +CREATE TRIGGER parent_update_trig + AFTER UPDATE ON range_parted for each statement execute procedure trigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_update_trig AFTER UPDATE ON range_parted EXECUTE FUNCTION trigfunc()" +== 151 +-- truncate_limit: 100 +CREATE TRIGGER parent_insert_trig + AFTER INSERT ON range_parted for each statement execute procedure trigfunc() +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parent_insert_trig AFTER INSERT ON range_parted EXECUTE FUNCTION trigfunc()" +== 152 +-- truncate_limit: 100 +-- Triggers on leaf partition part_c_1_100 +CREATE TRIGGER c1_delete_trig + AFTER DELETE ON part_c_1_100 for each statement execute procedure trigfunc() +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER c1_delete_trig AFTER DELETE ON part_c_1_100 EXECUTE FUNCTION trigfunc()" +== 153 +-- truncate_limit: 100 +CREATE TRIGGER c1_update_trig + AFTER UPDATE ON part_c_1_100 for each statement execute procedure trigfunc() +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER c1_update_trig AFTER UPDATE ON part_c_1_100 EXECUTE FUNCTION trigfunc()" +== 154 +-- truncate_limit: 100 +CREATE TRIGGER c1_insert_trig + AFTER INSERT ON part_c_1_100 for each statement execute procedure trigfunc() +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER c1_insert_trig AFTER INSERT ON part_c_1_100 EXECUTE FUNCTION trigfunc()" +== 155 +-- truncate_limit: 100 +-- Triggers on leaf partition part_d_1_15 +CREATE TRIGGER d1_delete_trig + AFTER DELETE ON part_d_1_15 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER d1_delete_trig AFTER DELETE ON part_d_1_15 EXECUTE FUNCTION trigfunc()" +== 156 +-- truncate_limit: 100 +CREATE TRIGGER d1_update_trig + AFTER UPDATE ON part_d_1_15 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER d1_update_trig AFTER UPDATE ON part_d_1_15 EXECUTE FUNCTION trigfunc()" +== 157 +-- truncate_limit: 100 +CREATE TRIGGER d1_insert_trig + AFTER INSERT ON part_d_1_15 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER d1_insert_trig AFTER INSERT ON part_d_1_15 EXECUTE FUNCTION trigfunc()" +== 158 +-- truncate_limit: 100 +-- Triggers on leaf partition part_d_15_20 +CREATE TRIGGER d15_delete_trig + AFTER DELETE ON part_d_15_20 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER d15_delete_trig AFTER DELETE ON part_d_15_20 EXECUTE FUNCTION trigfunc()" +== 159 +-- truncate_limit: 100 +CREATE TRIGGER d15_update_trig + AFTER UPDATE ON part_d_15_20 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER d15_update_trig AFTER UPDATE ON part_d_15_20 EXECUTE FUNCTION trigfunc()" +== 160 +-- truncate_limit: 100 +CREATE TRIGGER d15_insert_trig + AFTER INSERT ON part_d_15_20 for each statement execute procedure trigfunc() +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER d15_insert_trig AFTER INSERT ON part_d_15_20 EXECUTE FUNCTION trigfunc()" +== 161 +-- truncate_limit: 100 +-- Move all rows from part_c_100_200 to part_c_1_100. None of the delete or +-- insert statement triggers should be fired. +UPDATE range_parted set c = c - 50 WHERE c > 97 +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET c = c - 50 WHERE c > 97" +== 162 +-- truncate_limit: 100 +DROP TRIGGER parent_delete_trig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER parent_delete_trig ON range_parted" +== 163 +-- truncate_limit: 100 +DROP TRIGGER parent_update_trig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER parent_update_trig ON range_parted" +== 164 +-- truncate_limit: 100 +DROP TRIGGER parent_insert_trig ON range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER parent_insert_trig ON range_parted" +== 165 +-- truncate_limit: 100 +DROP TRIGGER c1_delete_trig ON part_c_1_100 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER c1_delete_trig ON part_c_1_100" +== 166 +-- truncate_limit: 100 +DROP TRIGGER c1_update_trig ON part_c_1_100 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER c1_update_trig ON part_c_1_100" +== 167 +-- truncate_limit: 100 +DROP TRIGGER c1_insert_trig ON part_c_1_100 +-- +TABLE: name="part_c_1_100" schema="" table="part_c_1_100" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER c1_insert_trig ON part_c_1_100" +== 168 +-- truncate_limit: 100 +DROP TRIGGER d1_delete_trig ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER d1_delete_trig ON part_d_1_15" +== 169 +-- truncate_limit: 100 +DROP TRIGGER d1_update_trig ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER d1_update_trig ON part_d_1_15" +== 170 +-- truncate_limit: 100 +DROP TRIGGER d1_insert_trig ON part_d_1_15 +-- +TABLE: name="part_d_1_15" schema="" table="part_d_1_15" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER d1_insert_trig ON part_d_1_15" +== 171 +-- truncate_limit: 100 +DROP TRIGGER d15_delete_trig ON part_d_15_20 +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER d15_delete_trig ON part_d_15_20" +== 172 +-- truncate_limit: 100 +DROP TRIGGER d15_update_trig ON part_d_15_20 +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER d15_update_trig ON part_d_15_20" +== 173 +-- truncate_limit: 100 +DROP TRIGGER d15_insert_trig ON part_d_15_20 +-- +TABLE: name="part_d_15_20" schema="" table="part_d_15_20" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER d15_insert_trig ON part_d_15_20" +== 174 +-- truncate_limit: 100 +create table part_def partition of range_parted default +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE part_def PARTITION OF range_parted DEFAULT" +== 175 +-- truncate_limit: 100 +insert into range_parted values ('c', 9) +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO range_parted VALUES ('c', 9)" +== 176 +-- truncate_limit: 100 +-- ok +update part_def set a = 'd' where a = 'c' +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_def SET a = 'd' WHERE a = 'c'" +== 177 +-- truncate_limit: 100 +-- fail +update part_def set a = 'a' where a = 'd' +-- +TABLE: name="part_def" schema="" table="part_def" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_def SET a = 'a' WHERE a = 'd'" +== 178 +-- truncate_limit: 100 +-- Update row movement from non-default to default partition. +-- fail, default partition is not under part_a_10_a_20; +UPDATE part_a_10_a_20 set a = 'ad' WHERE a = 'a' +-- +TABLE: name="part_a_10_a_20" schema="" table="part_a_10_a_20" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE part_a_10_a_20 SET a = 'ad' WHERE a = 'a'" +== 179 +-- truncate_limit: 100 +-- ok +UPDATE range_parted set a = 'ad' WHERE a = 'a' +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'ad' WHERE a = 'a'" +== 180 +-- truncate_limit: 100 +UPDATE range_parted set a = 'bd' WHERE a = 'b' +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'bd' WHERE a = 'b'" +== 181 +-- truncate_limit: 100 +-- Update row movement from default to non-default partitions. +-- ok +UPDATE range_parted set a = 'a' WHERE a = 'ad' +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'a' WHERE a = 'ad'" +== 182 +-- truncate_limit: 100 +UPDATE range_parted set a = 'b' WHERE a = 'bd' +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE range_parted SET a = 'b' WHERE a = 'bd'" +== 183 +-- truncate_limit: 100 +-- Cleanup: range_parted no longer needed. +DROP TABLE range_parted +-- +TABLE: name="range_parted" schema="" table="range_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE range_parted" +== 184 +-- truncate_limit: 100 +CREATE TABLE list_parted ( + a text, + b int +) PARTITION BY list (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted (a text, b int) PARTITION BY LIST (a)" +== 185 +-- truncate_limit: 100 +CREATE TABLE list_part1 PARTITION OF list_parted for VALUES in ('a', 'b') +-- +TABLE: name="list_part1" schema="" table="list_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_part1 PARTITION OF list_parted FOR VALUES IN ('a', 'b')" +== 186 +-- truncate_limit: 100 +CREATE TABLE list_default PARTITION OF list_parted default +-- +TABLE: name="list_default" schema="" table="list_default" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_default PARTITION OF list_parted DEFAULT" +== 187 +-- truncate_limit: 100 +INSERT into list_part1 VALUES ('a', 1) +-- +TABLE: name="list_part1" schema="" table="list_part1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_part1 VALUES ('a', 1)" +== 188 +-- truncate_limit: 100 +INSERT into list_default VALUES ('d', 10) +-- +TABLE: name="list_default" schema="" table="list_default" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_default VALUES ('d', 10)" +== 189 +-- truncate_limit: 100 +-- fail +UPDATE list_default set a = 'a' WHERE a = 'd' +-- +TABLE: name="list_default" schema="" table="list_default" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE list_default SET a = 'a' WHERE a = 'd'" +== 190 +-- truncate_limit: 100 +-- ok +UPDATE list_default set a = 'x' WHERE a = 'd' +-- +TABLE: name="list_default" schema="" table="list_default" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE list_default SET a = 'x' WHERE a = 'd'" +== 191 +-- truncate_limit: 100 +DROP TABLE list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE list_parted" +== 192 +-- truncate_limit: 100 +-- Test retrieval of system columns with non-consistent partition row types. +-- This is only partially supported, as seen in the results. + +create table utrtest (a int, b text) partition by list (a) +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE utrtest (a int, b text) PARTITION BY LIST (a)" +== 193 +-- truncate_limit: 100 +create table utr1 (a int check (a in (1)), q text, b text) +-- +TABLE: name="utr1" schema="" table="utr1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE utr1 (a int CHECK (a IN (1)), q text, b text)" +== 194 +-- truncate_limit: 100 +create table utr2 (a int check (a in (2)), b text) +-- +TABLE: name="utr2" schema="" table="utr2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE utr2 (a int CHECK (a IN (2)), b text)" +== 195 +-- truncate_limit: 100 +alter table utr1 drop column q +-- +TABLE: name="utr1" schema="" table="utr1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE utr1 DROP q" +== 196 +-- truncate_limit: 100 +alter table utrtest attach partition utr1 for values in (1) +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE utrtest ATTACH PARTITION utr1 FOR VALUES IN (1)" +== 197 +-- truncate_limit: 100 +alter table utrtest attach partition utr2 for values in (2) +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE utrtest ATTACH PARTITION utr2 FOR VALUES IN (2)" +== 198 +-- truncate_limit: 100 +insert into utrtest values (1, 'foo') + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO utrtest VALUES (...) RETURNING *, tableoid::regclass, xmin = pg_current_xact_id()::xi..." +== 199 +-- truncate_limit: 100 +insert into utrtest values (2, 'bar') + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO utrtest VALUES (...) RETURNING *, tableoid::regclass, xmin = pg_current_xact_id()::xi..." +== 200 +-- truncate_limit: 100 +-- fails +insert into utrtest values (2, 'bar') + returning *, tableoid::regclass +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO utrtest VALUES (2, 'bar') RETURNING *, tableoid::regclass" +== 201 +-- truncate_limit: 100 +update utrtest set b = b || b from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE utrtest SET ... = ... FROM (VALUES (...)) s(x) WHERE ... RETURNING *, tableoid::regclass, ..." +== 202 +-- truncate_limit: 100 +update utrtest set a = 3 - a from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE utrtest SET ... = ... FROM (VALUES (...)) s(x) WHERE ... RETURNING *, tableoid::regclass, ..." +== 203 +-- truncate_limit: 100 +-- fails + +update utrtest set a = 3 - a from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "UPDATE utrtest SET a = 3 - a FROM (VALUES (...)) s(x) WHERE a = s.x RETURNING *, tableoid::regclass" +== 204 +-- truncate_limit: 100 +delete from utrtest + returning *, tableoid::regclass, xmax = pg_current_xact_id()::xid as xmax_ok +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DML +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM utrtest RETURNING *, tableoid::regclass, xmax = pg_current_xact_id()::xid AS xmax_ok" +== 205 +-- truncate_limit: 100 +drop table utrtest +-- +TABLE: name="utrtest" schema="" table="utrtest" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE utrtest" +== 206 +-- truncate_limit: 100 +-------------- +-- Some more update-partition-key test scenarios below. This time use list +-- partitions. +-------------- + +-- Setup for list partitions +CREATE TABLE list_parted (a numeric, b int, c int8) PARTITION BY list (a) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_parted (a numeric, b int, c int8) PARTITION BY LIST (a)" +== 207 +-- truncate_limit: 100 +CREATE TABLE sub_parted PARTITION OF list_parted for VALUES in (1) PARTITION BY list (b) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sub_parted PARTITION OF list_parted FOR VALUES IN (1) PARTITION BY LIST (b)" +== 208 +-- truncate_limit: 100 +CREATE TABLE sub_part1(b int, c int8, a numeric) +-- +TABLE: name="sub_part1" schema="" table="sub_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sub_part1 (b int, c int8, a numeric)" +== 209 +-- truncate_limit: 100 +ALTER TABLE sub_parted ATTACH PARTITION sub_part1 for VALUES in (1) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE sub_parted ATTACH PARTITION sub_part1 FOR VALUES IN (1)" +== 210 +-- truncate_limit: 100 +CREATE TABLE sub_part2(b int, c int8, a numeric) +-- +TABLE: name="sub_part2" schema="" table="sub_part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE sub_part2 (b int, c int8, a numeric)" +== 211 +-- truncate_limit: 100 +ALTER TABLE sub_parted ATTACH PARTITION sub_part2 for VALUES in (2) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE sub_parted ATTACH PARTITION sub_part2 FOR VALUES IN (2)" +== 212 +-- truncate_limit: 100 +CREATE TABLE list_part1(a numeric, b int, c int8) +-- +TABLE: name="list_part1" schema="" table="list_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE list_part1 (a numeric, b int, c int8)" +== 213 +-- truncate_limit: 100 +ALTER TABLE list_parted ATTACH PARTITION list_part1 for VALUES in (2,3) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE list_parted ATTACH PARTITION list_part1 FOR VALUES IN (2, 3)" +== 214 +-- truncate_limit: 100 +INSERT into list_parted VALUES (2,5,50) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES (2, 5, 50)" +== 215 +-- truncate_limit: 100 +INSERT into list_parted VALUES (3,6,60) +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO list_parted VALUES (3, 6, 60)" +== 216 +-- truncate_limit: 100 +INSERT into sub_parted VALUES (1,1,60) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sub_parted VALUES (1, 1, 60)" +== 217 +-- truncate_limit: 100 +INSERT into sub_parted VALUES (1,2,10) +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO sub_parted VALUES (1, 2, 10)" +== 218 +-- truncate_limit: 100 +-- Test partition constraint violation when intermediate ancestor is used and +-- constraint is inherited from upper root. +UPDATE sub_parted set a = 2 WHERE c = 10 +-- +TABLE: name="sub_parted" schema="" table="sub_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE sub_parted SET a = 2 WHERE c = 10" +== 219 +-- truncate_limit: 100 +-- Test update-partition-key, where the unpruned partitions do not have their +-- partition keys updated. +SELECT tableoid::regclass::text, * FROM list_parted WHERE a = 2 ORDER BY 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text, * FROM list_parted WHERE a = 2 ORDER BY 1" +== 220 +-- truncate_limit: 100 +UPDATE list_parted set b = c + a WHERE a = 2 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE list_parted SET b = c + a WHERE a = 2" +== 221 +-- truncate_limit: 100 +SELECT tableoid::regclass::text, * FROM list_parted WHERE a = 2 ORDER BY 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +FILTER: schema="" table="" column="a" +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text, * FROM list_parted WHERE a = 2 ORDER BY 1" +== 222 +-- truncate_limit: 100 +-- Test the case where BR UPDATE triggers change the partition key. +CREATE FUNCTION func_parted_mod_b() returns trigger as $$ +BEGIN + NEW.b = 2; -- This is changing partition key column. + return NEW; +END $$ LANGUAGE plpgsql +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION func_parted_mod_b() RETURNS trigger AS $$\nBEGIN\n NEW.b = 2; -- This is changing..." +== 223 +-- truncate_limit: 100 +CREATE TRIGGER parted_mod_b before update on sub_part1 + for each row execute procedure func_parted_mod_b() +-- +TABLE: name="sub_part1" schema="" table="sub_part1" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER parted_mod_b BEFORE UPDATE ON sub_part1 FOR EACH ROW EXECUTE FUNCTION func_parted_..." +== 224 +-- truncate_limit: 100 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4" +== 225 +-- truncate_limit: 100 +-- This should do the tuple routing even though there is no explicit +-- partition-key update, because there is a trigger on sub_part1. +UPDATE list_parted set c = 70 WHERE b = 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE list_parted SET c = 70 WHERE b = 1" +== 226 +-- truncate_limit: 100 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4" +== 227 +-- truncate_limit: 100 +DROP TRIGGER parted_mod_b ON sub_part1 +-- +TABLE: name="sub_part1" schema="" table="sub_part1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER parted_mod_b ON sub_part1" +== 228 +-- truncate_limit: 100 +-- If BR DELETE trigger prevented DELETE from happening, we should also skip +-- the INSERT if that delete is part of UPDATE=>DELETE+INSERT. +CREATE OR REPLACE FUNCTION func_parted_mod_b() returns trigger as $$ +BEGIN + raise notice 'Trigger: Got OLD row %, but returning NULL', OLD; + return NULL; +END $$ LANGUAGE plpgsql +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION func_parted_mod_b() RETURNS trigger AS $$\nBEGIN\n raise notice 'Trigg..." +== 229 +-- truncate_limit: 100 +CREATE TRIGGER trig_skip_delete before delete on sub_part2 + for each row execute procedure func_parted_mod_b() +-- +TABLE: name="sub_part2" schema="" table="sub_part2" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER trig_skip_delete BEFORE DELETE ON sub_part2 FOR EACH ROW EXECUTE FUNCTION func_par..." +== 230 +-- truncate_limit: 100 +UPDATE list_parted set b = 1 WHERE c = 70 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE list_parted SET b = 1 WHERE c = 70" +== 231 +-- truncate_limit: 100 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4" +== 232 +-- truncate_limit: 100 +-- Drop the trigger. Now the row should be moved. +DROP TRIGGER trig_skip_delete ON sub_part2 +-- +TABLE: name="sub_part2" schema="" table="sub_part2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER trig_skip_delete ON sub_part2" +== 233 +-- truncate_limit: 100 +UPDATE list_parted set b = 1 WHERE c = 70 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE list_parted SET b = 1 WHERE c = 70" +== 234 +-- truncate_limit: 100 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4" +== 235 +-- truncate_limit: 100 +DROP FUNCTION func_parted_mod_b() +-- +FUNCTION: name="func_parted_mod_b" function="func_parted_mod_b" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION func_parted_mod_b()" +== 236 +-- truncate_limit: 100 +-- UPDATE partition-key with FROM clause. If join produces multiple output +-- rows for the same row to be modified, we should tuple-route the row only +-- once. There should not be any rows inserted. +CREATE TABLE non_parted (id int) +-- +TABLE: name="non_parted" schema="" table="non_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE non_parted (id int)" +== 237 +-- truncate_limit: 100 +INSERT into non_parted VALUES (1), (1), (1), (2), (2), (2), (3), (3), (3) +-- +TABLE: name="non_parted" schema="" table="non_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO non_parted VALUES (1), (1), (1), (2), (2), (2), (3), (3), (3)" +== 238 +-- truncate_limit: 100 +UPDATE list_parted t1 set a = 2 FROM non_parted t2 WHERE t1.a = t2.id and a = 1 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DML +TABLE: name="non_parted" schema="" table="non_parted" ctx=Select +ALIAS: "t1"="list_parted" +ALIAS: "t2"="non_parted" +STMT: UpdateStmt +TRUNCATED: "UPDATE list_parted t1 SET a = 2 FROM non_parted t2 WHERE t1.a = t2.id AND a = 1" +== 239 +-- truncate_limit: 100 +SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4 +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT tableoid::regclass::text, * FROM list_parted ORDER BY 1, 2, 3, 4" +== 240 +-- truncate_limit: 100 +DROP TABLE non_parted +-- +TABLE: name="non_parted" schema="" table="non_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE non_parted" +== 241 +-- truncate_limit: 100 +-- Cleanup: list_parted no longer needed. +DROP TABLE list_parted +-- +TABLE: name="list_parted" schema="" table="list_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE list_parted" +== 242 +-- truncate_limit: 100 +-- create custom operator class and hash function, for the same reason +-- explained in alter_table.sql +create or replace function dummy_hashint4(a int4, seed int8) returns int8 as +$$ begin return (a + seed); end; $$ language 'plpgsql' immutable +-- +FUNCTION: name="dummy_hashint4" function="dummy_hashint4" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION dummy_hashint4(a int4, seed int8) RETURNS int8 AS $$ begin return (a +..." +== 243 +-- truncate_limit: 100 +create operator class custom_opclass for type int4 using hash as +operator 1 = , function 2 dummy_hashint4(int4, int8) +-- +STMT: CreateOpClassStmt +TRUNCATED: "CREATE OPERATOR CLASS custom_opclass FOR TYPE int4 USING hash AS OPERATOR 1 =, FUNCTION 2 dummy_h..." +== 244 +-- truncate_limit: 100 +create table hash_parted ( + a int, + b int +) partition by hash (a custom_opclass, b custom_opclass) +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hash_parted (a int, b int) PARTITION BY HASH (a custom_opclass, b custom_opclass)" +== 245 +-- truncate_limit: 100 +create table hpart1 partition of hash_parted for values with (modulus 2, remainder 1) +-- +TABLE: name="hpart1" schema="" table="hpart1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart1 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 246 +-- truncate_limit: 100 +create table hpart2 partition of hash_parted for values with (modulus 4, remainder 2) +-- +TABLE: name="hpart2" schema="" table="hpart2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart2 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 4, REMAINDER 2)" +== 247 +-- truncate_limit: 100 +create table hpart3 partition of hash_parted for values with (modulus 8, remainder 0) +-- +TABLE: name="hpart3" schema="" table="hpart3" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart3 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 8, REMAINDER 0)" +== 248 +-- truncate_limit: 100 +create table hpart4 partition of hash_parted for values with (modulus 8, remainder 4) +-- +TABLE: name="hpart4" schema="" table="hpart4" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE hpart4 PARTITION OF hash_parted FOR VALUES WITH (MODULUS 8, REMAINDER 4)" +== 249 +-- truncate_limit: 100 +insert into hpart1 values (1, 1) +-- +TABLE: name="hpart1" schema="" table="hpart1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hpart1 VALUES (1, 1)" +== 250 +-- truncate_limit: 100 +insert into hpart2 values (2, 5) +-- +TABLE: name="hpart2" schema="" table="hpart2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hpart2 VALUES (2, 5)" +== 251 +-- truncate_limit: 100 +insert into hpart4 values (3, 4) +-- +TABLE: name="hpart4" schema="" table="hpart4" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO hpart4 VALUES (3, 4)" +== 252 +-- truncate_limit: 100 +-- fail +update hpart1 set a = 3, b=4 where a = 1 +-- +TABLE: name="hpart1" schema="" table="hpart1" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hpart1 SET a = 3, b = 4 WHERE a = 1" +== 253 +-- truncate_limit: 100 +-- ok, row movement +update hash_parted set b = b - 1 where b = 1 +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_parted SET b = b - 1 WHERE b = 1" +== 254 +-- truncate_limit: 100 +-- ok +update hash_parted set b = b + 8 where b = 1 +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE hash_parted SET b = b + 8 WHERE b = 1" +== 255 +-- truncate_limit: 100 +-- cleanup +drop table hash_parted +-- +TABLE: name="hash_parted" schema="" table="hash_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE hash_parted" +== 256 +-- truncate_limit: 100 +drop operator class custom_opclass using hash +-- +STMT: DropStmt +TRUNCATED: "DROP OPERATOR CLASS custom_opclass USING hash" +== 257 +-- truncate_limit: 100 +drop function dummy_hashint4(a int4, seed int8) +-- +FUNCTION: name="dummy_hashint4" function="dummy_hashint4" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION dummy_hashint4(a int4, seed int8)" diff --git a/parser/testdata/summary_truncate/postgres_regress/uuid.metadata.json b/parser/testdata/summary_truncate/postgres_regress/uuid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/uuid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/uuid.test b/parser/testdata/summary_truncate/postgres_regress/uuid.test new file mode 100644 index 0000000..946a6f9 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/uuid.test @@ -0,0 +1,400 @@ +== 001 +-- truncate_limit: 100 +-- regression test for the uuid datatype +-- creating test tables +CREATE TABLE guid1 +( + guid_field UUID, + text_field TEXT DEFAULT(now()) +) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE guid1 (guid_field uuid, text_field text DEFAULT now())" +== 002 +-- truncate_limit: 100 +CREATE TABLE guid2 +( + guid_field UUID, + text_field TEXT DEFAULT(now()) +) +-- +TABLE: name="guid2" schema="" table="guid2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE guid2 (guid_field uuid, text_field text DEFAULT now())" +== 003 +-- truncate_limit: 100 +-- inserting invalid data tests +-- too long +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111F') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('11111111-1111-1111-1111-111111111111F')" +== 004 +-- truncate_limit: 100 +-- too short +INSERT INTO guid1(guid_field) VALUES('{11111111-1111-1111-1111-11111111111}') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('{11111111-1111-1111-1111-11111111111}')" +== 005 +-- truncate_limit: 100 +-- valid data but invalid format +INSERT INTO guid1(guid_field) VALUES('111-11111-1111-1111-1111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('111-11111-1111-1111-1111-111111111111')" +== 006 +-- truncate_limit: 100 +INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-2222-222222222222 ') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('{22222222-2222-2222-2222-222222222222 ')" +== 007 +-- truncate_limit: 100 +-- invalid data +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-G111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('11111111-1111-1111-G111-111111111111')" +== 008 +-- truncate_limit: 100 +INSERT INTO guid1(guid_field) VALUES('11+11111-1111-1111-1111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('11+11111-1111-1111-1111-111111111111')" +== 009 +-- truncate_limit: 100 +-- test non-error-throwing API +SELECT pg_input_is_valid('11', 'uuid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('11', 'uuid')" +== 010 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('11', 'uuid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('11', 'uuid')" +== 011 +-- truncate_limit: 100 +--inserting three input formats +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('11111111-1111-1111-1111-111111111111')" +== 012 +-- truncate_limit: 100 +INSERT INTO guid1(guid_field) VALUES('{22222222-2222-2222-2222-222222222222}') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('{22222222-2222-2222-2222-222222222222}')" +== 013 +-- truncate_limit: 100 +INSERT INTO guid1(guid_field) VALUES('3f3e3c3b3a3039383736353433a2313e') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('3f3e3c3b3a3039383736353433a2313e')" +== 014 +-- truncate_limit: 100 +-- retrieving the inserted data +SELECT guid_field FROM guid1 +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT guid_field FROM guid1" +== 015 +-- truncate_limit: 100 +-- ordering test +SELECT guid_field FROM guid1 ORDER BY guid_field ASC +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT guid_field FROM guid1 ORDER BY guid_field ASC" +== 016 +-- truncate_limit: 100 +SELECT guid_field FROM guid1 ORDER BY guid_field DESC +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT guid_field FROM guid1 ORDER BY guid_field DESC" +== 017 +-- truncate_limit: 100 +-- = operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field = '3f3e3c3b-3a30-3938-3736-353433a2313e' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM guid1 WHERE guid_field = '3f3e3c3b-3a30-3938-3736-353433a2313e'" +== 018 +-- truncate_limit: 100 +-- <> operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field <> '11111111111111111111111111111111' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM guid1 WHERE guid_field <> '11111111111111111111111111111111'" +== 019 +-- truncate_limit: 100 +-- < operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field < '22222222-2222-2222-2222-222222222222' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM guid1 WHERE guid_field < '22222222-2222-2222-2222-222222222222'" +== 020 +-- truncate_limit: 100 +-- <= operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field <= '22222222-2222-2222-2222-222222222222' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM guid1 WHERE guid_field <= '22222222-2222-2222-2222-222222222222'" +== 021 +-- truncate_limit: 100 +-- > operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field > '22222222-2222-2222-2222-222222222222' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM guid1 WHERE guid_field > '22222222-2222-2222-2222-222222222222'" +== 022 +-- truncate_limit: 100 +-- >= operator test +SELECT COUNT(*) FROM guid1 WHERE guid_field >= '22222222-2222-2222-2222-222222222222' +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="guid_field" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM guid1 WHERE guid_field >= '22222222-2222-2222-2222-222222222222'" +== 023 +-- truncate_limit: 100 +-- btree and hash index creation test +CREATE INDEX guid1_btree ON guid1 USING BTREE (guid_field) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX guid1_btree ON guid1 USING btree (guid_field)" +== 024 +-- truncate_limit: 100 +CREATE INDEX guid1_hash ON guid1 USING HASH (guid_field) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX guid1_hash ON guid1 USING hash (guid_field)" +== 025 +-- truncate_limit: 100 +-- unique index test +CREATE UNIQUE INDEX guid1_unique_BTREE ON guid1 USING BTREE (guid_field) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX guid1_unique_btree ON guid1 USING btree (guid_field)" +== 026 +-- truncate_limit: 100 +-- should fail +INSERT INTO guid1(guid_field) VALUES('11111111-1111-1111-1111-111111111111') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('11111111-1111-1111-1111-111111111111')" +== 027 +-- truncate_limit: 100 +-- check to see whether the new indexes are actually there +SELECT count(*) FROM pg_class WHERE relkind='i' AND relname LIKE 'guid%' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="relkind" +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM pg_class WHERE relkind = 'i' AND relname LIKE 'guid%'" +== 028 +-- truncate_limit: 100 +-- populating the test tables with additional records +INSERT INTO guid1(guid_field) VALUES('44444444-4444-4444-4444-444444444444') +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES ('44444444-4444-4444-4444-444444444444')" +== 029 +-- truncate_limit: 100 +INSERT INTO guid2(guid_field) VALUES('11111111-1111-1111-1111-111111111111') +-- +TABLE: name="guid2" schema="" table="guid2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid2 (guid_field) VALUES ('11111111-1111-1111-1111-111111111111')" +== 030 +-- truncate_limit: 100 +INSERT INTO guid2(guid_field) VALUES('{22222222-2222-2222-2222-222222222222}') +-- +TABLE: name="guid2" schema="" table="guid2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid2 (guid_field) VALUES ('{22222222-2222-2222-2222-222222222222}')" +== 031 +-- truncate_limit: 100 +INSERT INTO guid2(guid_field) VALUES('3f3e3c3b3a3039383736353433a2313e') +-- +TABLE: name="guid2" schema="" table="guid2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid2 (guid_field) VALUES ('3f3e3c3b3a3039383736353433a2313e')" +== 032 +-- truncate_limit: 100 +-- join test +SELECT COUNT(*) FROM guid1 g1 INNER JOIN guid2 g2 ON g1.guid_field = g2.guid_field +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +TABLE: name="guid2" schema="" table="guid2" ctx=Select +ALIAS: "g1"="guid1" +ALIAS: "g2"="guid2" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM guid1 g1 JOIN guid2 g2 ON g1.guid_field = g2.guid_field" +== 033 +-- truncate_limit: 100 +SELECT COUNT(*) FROM guid1 g1 LEFT JOIN guid2 g2 ON g1.guid_field = g2.guid_field WHERE g2.guid_field IS NULL +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +TABLE: name="guid2" schema="" table="guid2" ctx=Select +ALIAS: "g1"="guid1" +ALIAS: "g2"="guid2" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="g2" column="guid_field" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM guid1 g1 LEFT JOIN guid2 g2 ON g1.guid_field = g2.guid_field WHERE ..." +== 034 +-- truncate_limit: 100 +-- generation test +TRUNCATE guid1 +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE guid1" +== 035 +-- truncate_limit: 100 +INSERT INTO guid1 (guid_field) VALUES (gen_random_uuid()) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +FUNCTION: name="gen_random_uuid" function="gen_random_uuid" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES (gen_random_uuid())" +== 036 +-- truncate_limit: 100 +INSERT INTO guid1 (guid_field) VALUES (gen_random_uuid()) +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DML +FUNCTION: name="gen_random_uuid" function="gen_random_uuid" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO guid1 (guid_field) VALUES (gen_random_uuid())" +== 037 +-- truncate_limit: 100 +SELECT count(DISTINCT guid_field) FROM guid1 +-- +TABLE: name="guid1" schema="" table="guid1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(DISTINCT guid_field) FROM guid1" +== 038 +-- truncate_limit: 100 +-- extract functions + +-- version +SELECT uuid_extract_version('11111111-1111-5111-8111-111111111111') +-- +FUNCTION: name="uuid_extract_version" function="uuid_extract_version" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT uuid_extract_version('11111111-1111-5111-8111-111111111111')" +== 039 +-- truncate_limit: 100 +-- 5 +SELECT uuid_extract_version(gen_random_uuid()) +-- +FUNCTION: name="uuid_extract_version" function="uuid_extract_version" schema="" ctx=Call +FUNCTION: name="gen_random_uuid" function="gen_random_uuid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT uuid_extract_version(gen_random_uuid())" +== 040 +-- truncate_limit: 100 +-- 4 +SELECT uuid_extract_version('11111111-1111-1111-1111-111111111111') +-- +FUNCTION: name="uuid_extract_version" function="uuid_extract_version" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT uuid_extract_version('11111111-1111-1111-1111-111111111111')" +== 041 +-- truncate_limit: 100 +-- null + +-- timestamp +SELECT uuid_extract_timestamp('C232AB00-9414-11EC-B3C8-9F6BDECED846') = 'Tuesday, February 22, 2022 2:22:22.00 PM GMT+05:00' +-- +FUNCTION: name="uuid_extract_timestamp" function="uuid_extract_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 042 +-- truncate_limit: 100 +-- RFC 4122bis test vector +SELECT uuid_extract_timestamp(gen_random_uuid()) +-- +FUNCTION: name="uuid_extract_timestamp" function="uuid_extract_timestamp" schema="" ctx=Call +FUNCTION: name="gen_random_uuid" function="gen_random_uuid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT uuid_extract_timestamp(gen_random_uuid())" +== 043 +-- truncate_limit: 100 +-- null +SELECT uuid_extract_timestamp('11111111-1111-1111-1111-111111111111') +-- +FUNCTION: name="uuid_extract_timestamp" function="uuid_extract_timestamp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT uuid_extract_timestamp('11111111-1111-1111-1111-111111111111')" +== 044 +-- truncate_limit: 100 +-- null + + +-- clean up +DROP TABLE guid1, guid2 CASCADE +-- +TABLE: name="guid1" schema="" table="guid1" ctx=DDL +TABLE: name="guid2" schema="" table="guid2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE guid1, guid2 CASCADE" diff --git a/parser/testdata/summary_truncate/postgres_regress/vacuum.metadata.json b/parser/testdata/summary_truncate/postgres_regress/vacuum.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/vacuum.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/vacuum.test b/parser/testdata/summary_truncate/postgres_regress/vacuum.test new file mode 100644 index 0000000..4c1e9fe --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/vacuum.test @@ -0,0 +1,2263 @@ +== 001 +-- truncate_limit: 100 +|-- +-- VACUUM +|-- + +CREATE TABLE vactst (i INT) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vactst (i int)" +== 002 +-- truncate_limit: 100 +INSERT INTO vactst VALUES (1) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst VALUES (1)" +== 003 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 004 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 005 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 006 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 007 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 008 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 009 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 010 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 011 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 012 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 013 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 014 +-- truncate_limit: 100 +INSERT INTO vactst VALUES (0) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst VALUES (0)" +== 015 +-- truncate_limit: 100 +SELECT count(*) FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM vactst" +== 016 +-- truncate_limit: 100 +DELETE FROM vactst WHERE i != 0 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM vactst WHERE i <> 0" +== 017 +-- truncate_limit: 100 +SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vactst" +== 018 +-- truncate_limit: 100 +VACUUM FULL vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) vactst" +== 019 +-- truncate_limit: 100 +UPDATE vactst SET i = i + 1 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE vactst SET i = i + 1" +== 020 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 021 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 022 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 023 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 024 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 025 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 026 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 027 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 028 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 029 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 030 +-- truncate_limit: 100 +INSERT INTO vactst SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT * FROM vactst" +== 031 +-- truncate_limit: 100 +INSERT INTO vactst VALUES (0) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst VALUES (0)" +== 032 +-- truncate_limit: 100 +SELECT count(*) FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM vactst" +== 033 +-- truncate_limit: 100 +DELETE FROM vactst WHERE i != 0 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM vactst WHERE i <> 0" +== 034 +-- truncate_limit: 100 +VACUUM (FULL) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) vactst" +== 035 +-- truncate_limit: 100 +DELETE FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM vactst" +== 036 +-- truncate_limit: 100 +SELECT * FROM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vactst" +== 037 +-- truncate_limit: 100 +VACUUM (FULL, FREEZE) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL, FREEZE) vactst" +== 038 +-- truncate_limit: 100 +VACUUM (ANALYZE, FULL) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE, FULL) vactst" +== 039 +-- truncate_limit: 100 +CREATE TABLE vaccluster (i INT PRIMARY KEY) +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vaccluster (i int PRIMARY KEY)" +== 040 +-- truncate_limit: 100 +ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey" +== 041 +-- truncate_limit: 100 +CLUSTER vaccluster +-- +STMT: ClusterStmt +TRUNCATED: "CLUSTER vaccluster" +== 042 +-- truncate_limit: 100 +CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL + AS 'ANALYZE pg_am' +-- +FUNCTION: name="do_analyze" function="do_analyze" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION do_analyze() RETURNS void VOLATILE LANGUAGE sql AS $$ANALYZE pg_am$$" +== 043 +-- truncate_limit: 100 +CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL + AS 'SELECT $1 FROM public.do_analyze()' +-- +FUNCTION: name="wrap_do_analyze" function="wrap_do_analyze" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION wrap_do_analyze(c int) RETURNS int IMMUTABLE LANGUAGE sql AS $$SELECT $1 FROM pub..." +== 044 +-- truncate_limit: 100 +CREATE INDEX ON vaccluster(wrap_do_analyze(i)) +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +FUNCTION: name="wrap_do_analyze" function="wrap_do_analyze" schema="" ctx=Call +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON vaccluster USING btree (wrap_do_analyze(i))" +== 045 +-- truncate_limit: 100 +INSERT INTO vaccluster VALUES (1), (2) +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vaccluster VALUES (1), (2)" +== 046 +-- truncate_limit: 100 +ANALYZE vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vaccluster" +== 047 +-- truncate_limit: 100 +-- Test ANALYZE in transaction, where the transaction surrounding +-- analyze performed modifications. This tests for the bug at +-- https://postgr.es/m/c7988239-d42c-ddc4-41db-171b23b35e4f%40ssinger.info +-- (which hopefully is unlikely to be reintroduced), but also seems +-- independently worthwhile to cover. +INSERT INTO vactst SELECT generate_series(1, 300) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT generate_series(1, 300)" +== 048 +-- truncate_limit: 100 +DELETE FROM vactst WHERE i % 7 = 0 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM vactst WHERE (i % 7) = 0" +== 049 +-- truncate_limit: 100 +-- delete a few rows outside +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 050 +-- truncate_limit: 100 +INSERT INTO vactst SELECT generate_series(301, 400) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vactst SELECT generate_series(301, 400)" +== 051 +-- truncate_limit: 100 +DELETE FROM vactst WHERE i % 5 <> 0 +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM vactst WHERE (i % 5) <> 0" +== 052 +-- truncate_limit: 100 +-- delete a few rows inside +ANALYZE vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vactst" +== 053 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 054 +-- truncate_limit: 100 +-- Test ANALYZE setting relhassubclass=f for non-partitioning inheritance +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 055 +-- truncate_limit: 100 +CREATE TABLE past_inh_parent () +-- +TABLE: name="past_inh_parent" schema="" table="past_inh_parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE past_inh_parent ()" +== 056 +-- truncate_limit: 100 +CREATE TABLE past_inh_child () INHERITS (past_inh_parent) +-- +TABLE: name="past_inh_child" schema="" table="past_inh_child" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE past_inh_child () INHERITS (past_inh_parent)" +== 057 +-- truncate_limit: 100 +INSERT INTO past_inh_child DEFAULT VALUES +-- +TABLE: name="past_inh_child" schema="" table="past_inh_child" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO past_inh_child DEFAULT VALUES" +== 058 +-- truncate_limit: 100 +INSERT INTO past_inh_child DEFAULT VALUES +-- +TABLE: name="past_inh_child" schema="" table="past_inh_child" ctx=DML +STMT: InsertStmt +TRUNCATED: "INSERT INTO past_inh_child DEFAULT VALUES" +== 059 +-- truncate_limit: 100 +ANALYZE past_inh_parent +-- +TABLE: name="past_inh_parent" schema="" table="past_inh_parent" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE past_inh_parent" +== 060 +-- truncate_limit: 100 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_inh_parent'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltuples, relhassubclass FROM pg_class WHERE oid = 'past_inh_parent'::regclass" +== 061 +-- truncate_limit: 100 +DROP TABLE past_inh_child +-- +TABLE: name="past_inh_child" schema="" table="past_inh_child" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE past_inh_child" +== 062 +-- truncate_limit: 100 +ANALYZE past_inh_parent +-- +TABLE: name="past_inh_parent" schema="" table="past_inh_parent" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE past_inh_parent" +== 063 +-- truncate_limit: 100 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_inh_parent'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltuples, relhassubclass FROM pg_class WHERE oid = 'past_inh_parent'::regclass" +== 064 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 065 +-- truncate_limit: 100 +-- Test ANALYZE setting relhassubclass=f for partitioning +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 066 +-- truncate_limit: 100 +CREATE TABLE past_parted (i int) PARTITION BY LIST(i) +-- +TABLE: name="past_parted" schema="" table="past_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE past_parted (i int) PARTITION BY LIST (i)" +== 067 +-- truncate_limit: 100 +CREATE TABLE past_part PARTITION OF past_parted FOR VALUES IN (1) +-- +TABLE: name="past_part" schema="" table="past_part" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE past_part PARTITION OF past_parted FOR VALUES IN (1)" +== 068 +-- truncate_limit: 100 +INSERT INTO past_parted VALUES (1),(1) +-- +TABLE: name="past_parted" schema="" table="past_parted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO past_parted VALUES (1), (1)" +== 069 +-- truncate_limit: 100 +ANALYZE past_parted +-- +TABLE: name="past_parted" schema="" table="past_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE past_parted" +== 070 +-- truncate_limit: 100 +DROP TABLE past_part +-- +TABLE: name="past_part" schema="" table="past_part" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE past_part" +== 071 +-- truncate_limit: 100 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_parted'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltuples, relhassubclass FROM pg_class WHERE oid = 'past_parted'::regclass" +== 072 +-- truncate_limit: 100 +ANALYZE past_parted +-- +TABLE: name="past_parted" schema="" table="past_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE past_parted" +== 073 +-- truncate_limit: 100 +SELECT reltuples, relhassubclass + FROM pg_class WHERE oid = 'past_parted'::regclass +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT reltuples, relhassubclass FROM pg_class WHERE oid = 'past_parted'::regclass" +== 074 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 075 +-- truncate_limit: 100 +VACUUM FULL pg_am +-- +TABLE: name="pg_am" schema="" table="pg_am" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) pg_am" +== 076 +-- truncate_limit: 100 +VACUUM FULL pg_class +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) pg_class" +== 077 +-- truncate_limit: 100 +VACUUM FULL pg_database +-- +TABLE: name="pg_database" schema="" table="pg_database" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) pg_database" +== 078 +-- truncate_limit: 100 +VACUUM FULL vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) vaccluster" +== 079 +-- truncate_limit: 100 +VACUUM FULL vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) vactst" +== 080 +-- truncate_limit: 100 +VACUUM (DISABLE_PAGE_SKIPPING) vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (DISABLE_PAGE_SKIPPING) vaccluster" +== 081 +-- truncate_limit: 100 +-- PARALLEL option +CREATE TABLE pvactst (i INT, a INT[], p POINT) with (autovacuum_enabled = off) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pvactst (i int, a int[], p point) WITH (autovacuum_enabled=off)" +== 082 +-- truncate_limit: 100 +INSERT INTO pvactst SELECT i, array[1,2,3], point(i, i+1) FROM generate_series(1,1000) i +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DML +FUNCTION: name="point" function="point" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pvactst SELECT i, ARRAY[1, 2, 3], point(i, i + 1) FROM generate_series(1, 1000) i" +== 083 +-- truncate_limit: 100 +CREATE INDEX btree_pvactst ON pvactst USING btree (i) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX btree_pvactst ON pvactst USING btree (i)" +== 084 +-- truncate_limit: 100 +CREATE INDEX hash_pvactst ON pvactst USING hash (i) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX hash_pvactst ON pvactst USING hash (i)" +== 085 +-- truncate_limit: 100 +CREATE INDEX brin_pvactst ON pvactst USING brin (i) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX brin_pvactst ON pvactst USING brin (i)" +== 086 +-- truncate_limit: 100 +CREATE INDEX gin_pvactst ON pvactst USING gin (a) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gin_pvactst ON pvactst USING gin (a)" +== 087 +-- truncate_limit: 100 +CREATE INDEX gist_pvactst ON pvactst USING gist (p) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX gist_pvactst ON pvactst USING gist (p)" +== 088 +-- truncate_limit: 100 +CREATE INDEX spgist_pvactst ON pvactst USING spgist (p) +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX spgist_pvactst ON pvactst USING spgist (p)" +== 089 +-- truncate_limit: 100 +CREATE TABLE pvactst2 (i INT) WITH (autovacuum_enabled = off) +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE pvactst2 (i int) WITH (autovacuum_enabled=off)" +== 090 +-- truncate_limit: 100 +INSERT INTO pvactst2 SELECT generate_series(1, 1000) +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO pvactst2 SELECT generate_series(1, 1000)" +== 091 +-- truncate_limit: 100 +CREATE INDEX ON pvactst2 (i) +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON pvactst2 USING btree (i)" +== 092 +-- truncate_limit: 100 +CREATE INDEX ON pvactst2 (i) +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON pvactst2 USING btree (i)" +== 093 +-- truncate_limit: 100 +-- VACUUM invokes parallel index cleanup +SET min_parallel_index_scan_size to 0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_index_scan_size TO 0" +== 094 +-- truncate_limit: 100 +VACUUM (PARALLEL 2) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 2) pvactst" +== 095 +-- truncate_limit: 100 +-- VACUUM invokes parallel bulk-deletion +UPDATE pvactst SET i = i WHERE i < 1000 +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pvactst SET i = i WHERE i < 1000" +== 096 +-- truncate_limit: 100 +VACUUM (PARALLEL 2) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 2) pvactst" +== 097 +-- truncate_limit: 100 +UPDATE pvactst SET i = i WHERE i < 1000 +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE pvactst SET i = i WHERE i < 1000" +== 098 +-- truncate_limit: 100 +VACUUM (PARALLEL 0) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 0) pvactst" +== 099 +-- truncate_limit: 100 +-- disable parallel vacuum + +VACUUM (PARALLEL -1) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL -1) pvactst" +== 100 +-- truncate_limit: 100 +-- error +VACUUM (PARALLEL 2, INDEX_CLEANUP FALSE) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 2, INDEX_CLEANUP FALSE) pvactst" +== 101 +-- truncate_limit: 100 +VACUUM (PARALLEL 2, FULL TRUE) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 2, FULL TRUE) pvactst" +== 102 +-- truncate_limit: 100 +-- error, cannot use both PARALLEL and FULL +VACUUM (PARALLEL) pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL) pvactst" +== 103 +-- truncate_limit: 100 +-- error, cannot use PARALLEL option without parallel degree + +-- Test parallel vacuum using the minimum maintenance_work_mem with and without +-- dead tuples. +SET maintenance_work_mem TO 64 +-- +STMT: VariableSetStmt +TRUNCATED: "SET maintenance_work_mem TO 64" +== 104 +-- truncate_limit: 100 +VACUUM (PARALLEL 2) pvactst2 +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 2) pvactst2" +== 105 +-- truncate_limit: 100 +DELETE FROM pvactst2 WHERE i < 1000 +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM pvactst2 WHERE i < 1000" +== 106 +-- truncate_limit: 100 +VACUUM (PARALLEL 2) pvactst2 +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 2) pvactst2" +== 107 +-- truncate_limit: 100 +RESET maintenance_work_mem +-- +STMT: VariableSetStmt +TRUNCATED: "RESET maintenance_work_mem" +== 108 +-- truncate_limit: 100 +-- Test different combinations of parallel and full options for temporary tables +CREATE TEMPORARY TABLE tmp (a int PRIMARY KEY) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tmp (a int PRIMARY KEY)" +== 109 +-- truncate_limit: 100 +CREATE INDEX tmp_idx1 ON tmp (a) +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX tmp_idx1 ON tmp USING btree (a)" +== 110 +-- truncate_limit: 100 +VACUUM (PARALLEL 1, FULL FALSE) tmp +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 1, FULL FALSE) tmp" +== 111 +-- truncate_limit: 100 +-- parallel vacuum disabled for temp tables +VACUUM (PARALLEL 0, FULL TRUE) tmp +-- +TABLE: name="tmp" schema="" table="tmp" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 0, FULL TRUE) tmp" +== 112 +-- truncate_limit: 100 +-- can specify parallel disabled (even though that's implied by FULL) +RESET min_parallel_index_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_index_scan_size" +== 113 +-- truncate_limit: 100 +DROP TABLE pvactst +-- +TABLE: name="pvactst" schema="" table="pvactst" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pvactst" +== 114 +-- truncate_limit: 100 +DROP TABLE pvactst2 +-- +TABLE: name="pvactst2" schema="" table="pvactst2" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE pvactst2" +== 115 +-- truncate_limit: 100 +-- INDEX_CLEANUP option +CREATE TABLE no_index_cleanup (i INT PRIMARY KEY, t TEXT) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE no_index_cleanup (i int PRIMARY KEY, t text)" +== 116 +-- truncate_limit: 100 +-- Use uncompressed data stored in toast. +CREATE INDEX no_index_cleanup_idx ON no_index_cleanup(t) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX no_index_cleanup_idx ON no_index_cleanup USING btree (t)" +== 117 +-- truncate_limit: 100 +ALTER TABLE no_index_cleanup ALTER COLUMN t SET STORAGE EXTERNAL +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE no_index_cleanup ALTER COLUMN t SET STORAGE external" +== 118 +-- truncate_limit: 100 +INSERT INTO no_index_cleanup(i, t) VALUES (generate_series(1,30), + repeat('1234567890',269)) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO no_index_cleanup (i, t) VALUES (generate_series(1, 30), repeat('1234567890', 269))" +== 119 +-- truncate_limit: 100 +-- index cleanup option is ignored if VACUUM FULL +VACUUM (INDEX_CLEANUP TRUE, FULL TRUE) no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (INDEX_CLEANUP TRUE, FULL TRUE) no_index_cleanup" +== 120 +-- truncate_limit: 100 +VACUUM (FULL TRUE) no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL TRUE) no_index_cleanup" +== 121 +-- truncate_limit: 100 +-- Toast inherits the value from its parent table. +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = false) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup=false)" +== 122 +-- truncate_limit: 100 +DELETE FROM no_index_cleanup WHERE i < 15 +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM no_index_cleanup WHERE i < 15" +== 123 +-- truncate_limit: 100 +-- Nothing is cleaned up. +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM no_index_cleanup" +== 124 +-- truncate_limit: 100 +-- Both parent relation and toast are cleaned up. +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = true) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup=true)" +== 125 +-- truncate_limit: 100 +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM no_index_cleanup" +== 126 +-- truncate_limit: 100 +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = auto) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup=auto)" +== 127 +-- truncate_limit: 100 +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM no_index_cleanup" +== 128 +-- truncate_limit: 100 +-- Parameter is set for both the parent table and its toast relation. +INSERT INTO no_index_cleanup(i, t) VALUES (generate_series(31,60), + repeat('1234567890',269)) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="repeat" function="repeat" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO no_index_cleanup (i, t) VALUES (generate_series(31, 60), repeat('1234567890', 269))" +== 129 +-- truncate_limit: 100 +DELETE FROM no_index_cleanup WHERE i < 45 +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM no_index_cleanup WHERE i < 45" +== 130 +-- truncate_limit: 100 +-- Only toast index is cleaned up. +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = off, + toast.vacuum_index_cleanup = yes) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup=off, toast.vacuum_index_cleanup=yes)" +== 131 +-- truncate_limit: 100 +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM no_index_cleanup" +== 132 +-- truncate_limit: 100 +-- Only parent is cleaned up. +ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup = true, + toast.vacuum_index_cleanup = false) +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE no_index_cleanup SET (vacuum_index_cleanup=true, toast.vacuum_index_cleanup=false)" +== 133 +-- truncate_limit: 100 +VACUUM no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM no_index_cleanup" +== 134 +-- truncate_limit: 100 +-- Test some extra relations. +VACUUM (INDEX_CLEANUP FALSE) vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (INDEX_CLEANUP FALSE) vaccluster" +== 135 +-- truncate_limit: 100 +VACUUM (INDEX_CLEANUP AUTO) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (INDEX_CLEANUP auto) vactst" +== 136 +-- truncate_limit: 100 +-- index cleanup option is ignored if no indexes +VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (INDEX_CLEANUP FALSE, FREEZE TRUE) vaccluster" +== 137 +-- truncate_limit: 100 +-- TRUNCATE option +CREATE TEMP TABLE vac_truncate_test(i INT NOT NULL, j text) + WITH (vacuum_truncate=true, autovacuum_enabled=false) +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE vac_truncate_test (i int NOT NULL, j text) WITH (vacuum_truncate=true, aut..." +== 138 +-- truncate_limit: 100 +INSERT INTO vac_truncate_test VALUES (1, NULL), (NULL, NULL) +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vac_truncate_test VALUES (1, NULL), (NULL, NULL)" +== 139 +-- truncate_limit: 100 +VACUUM (TRUNCATE FALSE, DISABLE_PAGE_SKIPPING) vac_truncate_test +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (TRUNCATE FALSE, DISABLE_PAGE_SKIPPING) vac_truncate_test" +== 140 +-- truncate_limit: 100 +SELECT pg_relation_size('vac_truncate_test') > 0 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_relation_size('vac_truncate_test') > 0" +== 141 +-- truncate_limit: 100 +VACUUM (DISABLE_PAGE_SKIPPING) vac_truncate_test +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (DISABLE_PAGE_SKIPPING) vac_truncate_test" +== 142 +-- truncate_limit: 100 +SELECT pg_relation_size('vac_truncate_test') = 0 +-- +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_relation_size('vac_truncate_test') = 0" +== 143 +-- truncate_limit: 100 +VACUUM (TRUNCATE FALSE, FULL TRUE) vac_truncate_test +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (TRUNCATE FALSE, FULL TRUE) vac_truncate_test" +== 144 +-- truncate_limit: 100 +DROP TABLE vac_truncate_test +-- +TABLE: name="vac_truncate_test" schema="" table="vac_truncate_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vac_truncate_test" +== 145 +-- truncate_limit: 100 +-- partitioned table +CREATE TABLE vacparted (a int, b char) PARTITION BY LIST (a) +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacparted (a int, b char(1)) PARTITION BY LIST (a)" +== 146 +-- truncate_limit: 100 +CREATE TABLE vacparted1 PARTITION OF vacparted FOR VALUES IN (1) +-- +TABLE: name="vacparted1" schema="" table="vacparted1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacparted1 PARTITION OF vacparted FOR VALUES IN (1)" +== 147 +-- truncate_limit: 100 +INSERT INTO vacparted VALUES (1, 'a') +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vacparted VALUES (1, 'a')" +== 148 +-- truncate_limit: 100 +UPDATE vacparted SET b = 'b' +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DML +STMT: UpdateStmt +TRUNCATED: "UPDATE vacparted SET b = 'b'" +== 149 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacparted +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacparted" +== 150 +-- truncate_limit: 100 +VACUUM (FULL) vacparted +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) vacparted" +== 151 +-- truncate_limit: 100 +VACUUM (FREEZE) vacparted +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FREEZE) vacparted" +== 152 +-- truncate_limit: 100 +-- check behavior with duplicate column mentions +VACUUM ANALYZE vacparted(a,b,a) +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacparted(a, b, a)" +== 153 +-- truncate_limit: 100 +ANALYZE vacparted(a,b,b) +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacparted(a, b, b)" +== 154 +-- truncate_limit: 100 +-- partitioned table with index +CREATE TABLE vacparted_i (a int primary key, b varchar(100)) + PARTITION BY HASH (a) +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacparted_i (a int PRIMARY KEY, b varchar(100)) PARTITION BY HASH (a)" +== 155 +-- truncate_limit: 100 +CREATE TABLE vacparted_i1 PARTITION OF vacparted_i + FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- +TABLE: name="vacparted_i1" schema="" table="vacparted_i1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacparted_i1 PARTITION OF vacparted_i FOR VALUES WITH (MODULUS 2, REMAINDER 0)" +== 156 +-- truncate_limit: 100 +CREATE TABLE vacparted_i2 PARTITION OF vacparted_i + FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- +TABLE: name="vacparted_i2" schema="" table="vacparted_i2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacparted_i2 PARTITION OF vacparted_i FOR VALUES WITH (MODULUS 2, REMAINDER 1)" +== 157 +-- truncate_limit: 100 +INSERT INTO vacparted_i SELECT i, 'test_'|| i from generate_series(1,10) i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vacparted_i SELECT i, 'test_' || i FROM generate_series(1, 10) i" +== 158 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacparted_i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacparted_i" +== 159 +-- truncate_limit: 100 +VACUUM (FULL) vacparted_i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) vacparted_i" +== 160 +-- truncate_limit: 100 +VACUUM (FREEZE) vacparted_i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FREEZE) vacparted_i" +== 161 +-- truncate_limit: 100 +SELECT relname, relhasindex FROM pg_class + WHERE relname LIKE 'vacparted_i%' AND relkind IN ('p','r') + ORDER BY relname +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +FILTER: schema="" table="" column="relkind" +STMT: SelectStmt +TRUNCATED: "SELECT relname, relhasindex FROM pg_class WHERE ... ORDER BY relname" +== 162 +-- truncate_limit: 100 +DROP TABLE vacparted_i +-- +TABLE: name="vacparted_i" schema="" table="vacparted_i" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vacparted_i" +== 163 +-- truncate_limit: 100 +-- multiple tables specified +VACUUM vaccluster, vactst +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vaccluster, vactst" +== 164 +-- truncate_limit: 100 +VACUUM vacparted, does_not_exist +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacparted, does_not_exist" +== 165 +-- truncate_limit: 100 +VACUUM (FREEZE) vacparted, vaccluster, vactst +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FREEZE) vacparted, vaccluster, vactst" +== 166 +-- truncate_limit: 100 +VACUUM (FREEZE) does_not_exist, vaccluster +-- +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FREEZE) does_not_exist, vaccluster" +== 167 +-- truncate_limit: 100 +VACUUM ANALYZE vactst, vacparted (a) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vactst, vacparted(a)" +== 168 +-- truncate_limit: 100 +VACUUM ANALYZE vactst (does_not_exist), vacparted (b) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vactst(does_not_exist), vacparted(b)" +== 169 +-- truncate_limit: 100 +VACUUM FULL vacparted, vactst +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) vacparted, vactst" +== 170 +-- truncate_limit: 100 +VACUUM FULL vactst, vacparted (a, b), vaccluster (i) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (FULL) vactst, vacparted(a, b), vaccluster(i)" +== 171 +-- truncate_limit: 100 +ANALYZE vactst, vacparted +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vactst, vacparted" +== 172 +-- truncate_limit: 100 +ANALYZE vacparted (b), vactst +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacparted(b), vactst" +== 173 +-- truncate_limit: 100 +ANALYZE vactst, does_not_exist, vacparted +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vactst, does_not_exist, vacparted" +== 174 +-- truncate_limit: 100 +ANALYZE vactst (i), vacparted (does_not_exist) +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vactst(i), vacparted(does_not_exist)" +== 175 +-- truncate_limit: 100 +ANALYZE vactst, vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vactst, vactst" +== 176 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 177 +-- truncate_limit: 100 +-- ANALYZE behaves differently inside a transaction block +ANALYZE vactst, vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vactst, vactst" +== 178 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 179 +-- truncate_limit: 100 +-- parenthesized syntax for ANALYZE +ANALYZE (VERBOSE) does_not_exist +-- +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE (VERBOSE) does_not_exist" +== 180 +-- truncate_limit: 100 +ANALYZE (nonexistent-arg) does_not_exist +-- +ERROR: syntax error at or near "arg" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 181 +-- truncate_limit: 100 +ANALYZE (nonexistentarg) does_not_exit +-- +TABLE: name="does_not_exit" schema="" table="does_not_exit" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE (NONEXISTENTARG) does_not_exit" +== 182 +-- truncate_limit: 100 +-- ensure argument order independence, and that SKIP_LOCKED on non-existing +-- relation still errors out. Suppress WARNING messages caused by concurrent +-- autovacuums. +SET client_min_messages TO 'ERROR' +-- +STMT: VariableSetStmt +TRUNCATED: "SET client_min_messages TO \"ERROR\"" +== 183 +-- truncate_limit: 100 +ANALYZE (SKIP_LOCKED, VERBOSE) does_not_exist +-- +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE (SKIP_LOCKED, VERBOSE) does_not_exist" +== 184 +-- truncate_limit: 100 +ANALYZE (VERBOSE, SKIP_LOCKED) does_not_exist +-- +TABLE: name="does_not_exist" schema="" table="does_not_exist" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE (VERBOSE, SKIP_LOCKED) does_not_exist" +== 185 +-- truncate_limit: 100 +-- SKIP_LOCKED option +VACUUM (SKIP_LOCKED) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (SKIP_LOCKED) vactst" +== 186 +-- truncate_limit: 100 +VACUUM (SKIP_LOCKED, FULL) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (SKIP_LOCKED, FULL) vactst" +== 187 +-- truncate_limit: 100 +ANALYZE (SKIP_LOCKED) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE (SKIP_LOCKED) vactst" +== 188 +-- truncate_limit: 100 +RESET client_min_messages +-- +STMT: VariableSetStmt +TRUNCATED: "RESET client_min_messages" +== 189 +-- truncate_limit: 100 +-- ensure VACUUM and ANALYZE don't have a problem with serializable +SET default_transaction_isolation = serializable +-- +STMT: VariableSetStmt +TRUNCATED: "SET default_transaction_isolation TO serializable" +== 190 +-- truncate_limit: 100 +VACUUM vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vactst" +== 191 +-- truncate_limit: 100 +ANALYZE vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vactst" +== 192 +-- truncate_limit: 100 +RESET default_transaction_isolation +-- +STMT: VariableSetStmt +TRUNCATED: "RESET default_transaction_isolation" +== 193 +-- truncate_limit: 100 +BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN ISOLATION LEVEL SERIALIZABLE" +== 194 +-- truncate_limit: 100 +ANALYZE vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vactst" +== 195 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 196 +-- truncate_limit: 100 +-- PROCESS_TOAST option +CREATE TABLE vac_option_tab (a INT, t TEXT) +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vac_option_tab (a int, t text)" +== 197 +-- truncate_limit: 100 +INSERT INTO vac_option_tab SELECT a, 't' || a FROM generate_series(1, 10) AS a +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO vac_option_tab SELECT a, 't' || a FROM generate_series(1, 10) a" +== 198 +-- truncate_limit: 100 +ALTER TABLE vac_option_tab ALTER COLUMN t SET STORAGE EXTERNAL +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vac_option_tab ALTER COLUMN t SET STORAGE external" +== 199 +-- truncate_limit: 100 +-- Check the number of vacuums done on table vac_option_tab and on its +-- toast relation, to check that PROCESS_TOAST and PROCESS_MAIN work on +-- what they should. +CREATE VIEW vac_option_tab_counts AS + SELECT CASE WHEN c.relname IS NULL + THEN 'main' ELSE 'toast' END as rel, + s.vacuum_count + FROM pg_stat_all_tables s + LEFT JOIN pg_class c ON s.relid = c.reltoastrelid + WHERE c.relname = 'vac_option_tab' OR s.relname = 'vac_option_tab' + ORDER BY rel +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=DDL +TABLE: name="pg_stat_all_tables" schema="" table="pg_stat_all_tables" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "s"="pg_stat_all_tables" +FILTER: schema="" table="c" column="relname" +FILTER: schema="" table="s" column="relname" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW vac_option_tab_counts AS SELECT CASE WHEN c.relname IS NULL THEN 'main' ELSE 'toast' ..." +== 200 +-- truncate_limit: 100 +VACUUM (PROCESS_TOAST TRUE) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PROCESS_TOAST TRUE) vac_option_tab" +== 201 +-- truncate_limit: 100 +SELECT * FROM vac_option_tab_counts +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vac_option_tab_counts" +== 202 +-- truncate_limit: 100 +VACUUM (PROCESS_TOAST FALSE) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PROCESS_TOAST FALSE) vac_option_tab" +== 203 +-- truncate_limit: 100 +SELECT * FROM vac_option_tab_counts +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vac_option_tab_counts" +== 204 +-- truncate_limit: 100 +VACUUM (PROCESS_TOAST FALSE, FULL) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PROCESS_TOAST FALSE, FULL) vac_option_tab" +== 205 +-- truncate_limit: 100 +-- error + +-- PROCESS_MAIN option +-- Only the toast table is processed. +VACUUM (PROCESS_MAIN FALSE) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PROCESS_MAIN FALSE) vac_option_tab" +== 206 +-- truncate_limit: 100 +SELECT * FROM vac_option_tab_counts +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vac_option_tab_counts" +== 207 +-- truncate_limit: 100 +-- Nothing is processed. +VACUUM (PROCESS_MAIN FALSE, PROCESS_TOAST FALSE) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PROCESS_MAIN FALSE, PROCESS_TOAST FALSE) vac_option_tab" +== 208 +-- truncate_limit: 100 +SELECT * FROM vac_option_tab_counts +-- +TABLE: name="vac_option_tab_counts" schema="" table="vac_option_tab_counts" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vac_option_tab_counts" +== 209 +-- truncate_limit: 100 +-- Check if the filenodes nodes have been updated as wanted after FULL. +SELECT relfilenode AS main_filenode FROM pg_class + WHERE relname = 'vac_option_tab' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FILTER: schema="" table="" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT relfilenode AS main_filenode FROM pg_class WHERE relname = 'vac_option_tab'" +== 210 +-- truncate_limit: 100 +SELECT t.relfilenode AS toast_filenode FROM pg_class c, pg_class t + WHERE c.reltoastrelid = t.oid AND c.relname = 'vac_option_tab' +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +ALIAS: "c"="pg_class" +ALIAS: "t"="pg_class" +FILTER: schema="" table="c" column="reltoastrelid" +FILTER: schema="" table="t" column="oid" +FILTER: schema="" table="c" column="relname" +STMT: SelectStmt +TRUNCATED: "SELECT t.relfilenode AS toast_filenode FROM pg_class c, pg_class t WHERE ..." +== 211 +-- truncate_limit: 100 +-- Only the toast relation is processed. +VACUUM (PROCESS_MAIN FALSE, FULL) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PROCESS_MAIN FALSE, FULL) vac_option_tab" +== 212 +-- truncate_limit: 100 +SELECT relfilenode = :main_filenode AS is_same_main_filenode + FROM pg_class WHERE relname = 'vac_option_tab' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 22 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 213 +-- truncate_limit: 100 +SELECT t.relfilenode = :toast_filenode AS is_same_toast_filenode + FROM pg_class c, pg_class t + WHERE c.reltoastrelid = t.oid AND c.relname = 'vac_option_tab' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 24 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 214 +-- truncate_limit: 100 +-- BUFFER_USAGE_LIMIT option +VACUUM (BUFFER_USAGE_LIMIT '512 kB') vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (BUFFER_USAGE_LIMIT \"512 kB\") vac_option_tab" +== 215 +-- truncate_limit: 100 +ANALYZE (BUFFER_USAGE_LIMIT '512 kB') vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE (BUFFER_USAGE_LIMIT \"512 kB\") vac_option_tab" +== 216 +-- truncate_limit: 100 +-- try disabling the buffer usage limit +VACUUM (BUFFER_USAGE_LIMIT 0) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (BUFFER_USAGE_LIMIT 0) vac_option_tab" +== 217 +-- truncate_limit: 100 +ANALYZE (BUFFER_USAGE_LIMIT 0) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE (BUFFER_USAGE_LIMIT 0) vac_option_tab" +== 218 +-- truncate_limit: 100 +-- value exceeds max size error +VACUUM (BUFFER_USAGE_LIMIT 16777220) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (BUFFER_USAGE_LIMIT 16777220) vac_option_tab" +== 219 +-- truncate_limit: 100 +-- value is less than min size error +VACUUM (BUFFER_USAGE_LIMIT 120) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (BUFFER_USAGE_LIMIT 120) vac_option_tab" +== 220 +-- truncate_limit: 100 +-- integer overflow error +VACUUM (BUFFER_USAGE_LIMIT 10000000000) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (BUFFER_USAGE_LIMIT 10000000000) vac_option_tab" +== 221 +-- truncate_limit: 100 +-- incompatible with VACUUM FULL error +VACUUM (BUFFER_USAGE_LIMIT '512 kB', FULL) vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (BUFFER_USAGE_LIMIT \"512 kB\", FULL) vac_option_tab" +== 222 +-- truncate_limit: 100 +-- SKIP_DATABASE_STATS option +VACUUM (SKIP_DATABASE_STATS) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (SKIP_DATABASE_STATS) vactst" +== 223 +-- truncate_limit: 100 +-- ONLY_DATABASE_STATS option +VACUUM (ONLY_DATABASE_STATS) +-- +STMT: VacuumStmt +TRUNCATED: "VACUUM (ONLY_DATABASE_STATS)" +== 224 +-- truncate_limit: 100 +VACUUM (ONLY_DATABASE_STATS) vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ONLY_DATABASE_STATS) vactst" +== 225 +-- truncate_limit: 100 +-- error + +DROP VIEW vac_option_tab_counts +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW vac_option_tab_counts" +== 226 +-- truncate_limit: 100 +DROP TABLE vac_option_tab +-- +TABLE: name="vac_option_tab" schema="" table="vac_option_tab" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vac_option_tab" +== 227 +-- truncate_limit: 100 +DROP TABLE vaccluster +-- +TABLE: name="vaccluster" schema="" table="vaccluster" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vaccluster" +== 228 +-- truncate_limit: 100 +DROP TABLE vactst +-- +TABLE: name="vactst" schema="" table="vactst" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vactst" +== 229 +-- truncate_limit: 100 +DROP TABLE vacparted +-- +TABLE: name="vacparted" schema="" table="vacparted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vacparted" +== 230 +-- truncate_limit: 100 +DROP TABLE no_index_cleanup +-- +TABLE: name="no_index_cleanup" schema="" table="no_index_cleanup" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE no_index_cleanup" +== 231 +-- truncate_limit: 100 +-- relation ownership, WARNING logs generated as all are skipped. +CREATE TABLE vacowned (a int) +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacowned (a int)" +== 232 +-- truncate_limit: 100 +CREATE TABLE vacowned_parted (a int) PARTITION BY LIST (a) +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacowned_parted (a int) PARTITION BY LIST (a)" +== 233 +-- truncate_limit: 100 +CREATE TABLE vacowned_part1 PARTITION OF vacowned_parted FOR VALUES IN (1) +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacowned_part1 PARTITION OF vacowned_parted FOR VALUES IN (1)" +== 234 +-- truncate_limit: 100 +CREATE TABLE vacowned_part2 PARTITION OF vacowned_parted FOR VALUES IN (2) +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE vacowned_part2 PARTITION OF vacowned_parted FOR VALUES IN (2)" +== 235 +-- truncate_limit: 100 +CREATE ROLE regress_vacuum +-- +STMT: CreateRoleStmt +TRUNCATED: "CREATE ROLE regress_vacuum" +== 236 +-- truncate_limit: 100 +SET ROLE regress_vacuum +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_vacuum" +== 237 +-- truncate_limit: 100 +-- Simple table +VACUUM vacowned +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned" +== 238 +-- truncate_limit: 100 +ANALYZE vacowned +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned" +== 239 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned" +== 240 +-- truncate_limit: 100 +-- Catalog +VACUUM pg_catalog.pg_class +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM pg_catalog.pg_class" +== 241 +-- truncate_limit: 100 +ANALYZE pg_catalog.pg_class +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pg_catalog.pg_class" +== 242 +-- truncate_limit: 100 +VACUUM (ANALYZE) pg_catalog.pg_class +-- +TABLE: name="pg_catalog.pg_class" schema="pg_catalog" table="pg_class" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) pg_catalog.pg_class" +== 243 +-- truncate_limit: 100 +-- Shared catalog +VACUUM pg_catalog.pg_authid +-- +TABLE: name="pg_catalog.pg_authid" schema="pg_catalog" table="pg_authid" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM pg_catalog.pg_authid" +== 244 +-- truncate_limit: 100 +ANALYZE pg_catalog.pg_authid +-- +TABLE: name="pg_catalog.pg_authid" schema="pg_catalog" table="pg_authid" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE pg_catalog.pg_authid" +== 245 +-- truncate_limit: 100 +VACUUM (ANALYZE) pg_catalog.pg_authid +-- +TABLE: name="pg_catalog.pg_authid" schema="pg_catalog" table="pg_authid" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) pg_catalog.pg_authid" +== 246 +-- truncate_limit: 100 +-- Partitioned table and its partitions, nothing owned by other user. +-- Relations are not listed in a single command to test ownership +-- independently. +VACUUM vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_parted" +== 247 +-- truncate_limit: 100 +VACUUM vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_part1" +== 248 +-- truncate_limit: 100 +VACUUM vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_part2" +== 249 +-- truncate_limit: 100 +ANALYZE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_parted" +== 250 +-- truncate_limit: 100 +ANALYZE vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_part1" +== 251 +-- truncate_limit: 100 +ANALYZE vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_part2" +== 252 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_parted" +== 253 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_part1" +== 254 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_part2" +== 255 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 256 +-- truncate_limit: 100 +-- Partitioned table and one partition owned by other user. +ALTER TABLE vacowned_parted OWNER TO regress_vacuum +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vacowned_parted OWNER TO regress_vacuum" +== 257 +-- truncate_limit: 100 +ALTER TABLE vacowned_part1 OWNER TO regress_vacuum +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vacowned_part1 OWNER TO regress_vacuum" +== 258 +-- truncate_limit: 100 +SET ROLE regress_vacuum +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_vacuum" +== 259 +-- truncate_limit: 100 +VACUUM vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_parted" +== 260 +-- truncate_limit: 100 +VACUUM vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_part1" +== 261 +-- truncate_limit: 100 +VACUUM vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_part2" +== 262 +-- truncate_limit: 100 +ANALYZE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_parted" +== 263 +-- truncate_limit: 100 +ANALYZE vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_part1" +== 264 +-- truncate_limit: 100 +ANALYZE vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_part2" +== 265 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_parted" +== 266 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_part1" +== 267 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_part2" +== 268 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 269 +-- truncate_limit: 100 +-- Only one partition owned by other user. +ALTER TABLE vacowned_parted OWNER TO CURRENT_USER +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vacowned_parted OWNER TO CURRENT_USER" +== 270 +-- truncate_limit: 100 +SET ROLE regress_vacuum +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_vacuum" +== 271 +-- truncate_limit: 100 +VACUUM vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_parted" +== 272 +-- truncate_limit: 100 +VACUUM vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_part1" +== 273 +-- truncate_limit: 100 +VACUUM vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_part2" +== 274 +-- truncate_limit: 100 +ANALYZE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_parted" +== 275 +-- truncate_limit: 100 +ANALYZE vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_part1" +== 276 +-- truncate_limit: 100 +ANALYZE vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_part2" +== 277 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_parted" +== 278 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_part1" +== 279 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_part2" +== 280 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 281 +-- truncate_limit: 100 +-- Only partitioned table owned by other user. +ALTER TABLE vacowned_parted OWNER TO regress_vacuum +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vacowned_parted OWNER TO regress_vacuum" +== 282 +-- truncate_limit: 100 +ALTER TABLE vacowned_part1 OWNER TO CURRENT_USER +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE vacowned_part1 OWNER TO CURRENT_USER" +== 283 +-- truncate_limit: 100 +SET ROLE regress_vacuum +-- +STMT: VariableSetStmt +TRUNCATED: "SET role TO regress_vacuum" +== 284 +-- truncate_limit: 100 +VACUUM vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_parted" +== 285 +-- truncate_limit: 100 +VACUUM vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_part1" +== 286 +-- truncate_limit: 100 +VACUUM vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM vacowned_part2" +== 287 +-- truncate_limit: 100 +ANALYZE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_parted" +== 288 +-- truncate_limit: 100 +ANALYZE vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_part1" +== 289 +-- truncate_limit: 100 +ANALYZE vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "ANALYZE vacowned_part2" +== 290 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_parted" +== 291 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_part1 +-- +TABLE: name="vacowned_part1" schema="" table="vacowned_part1" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_part1" +== 292 +-- truncate_limit: 100 +VACUUM (ANALYZE) vacowned_part2 +-- +TABLE: name="vacowned_part2" schema="" table="vacowned_part2" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (ANALYZE) vacowned_part2" +== 293 +-- truncate_limit: 100 +RESET ROLE +-- +STMT: VariableSetStmt +TRUNCATED: "RESET role" +== 294 +-- truncate_limit: 100 +DROP TABLE vacowned +-- +TABLE: name="vacowned" schema="" table="vacowned" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vacowned" +== 295 +-- truncate_limit: 100 +DROP TABLE vacowned_parted +-- +TABLE: name="vacowned_parted" schema="" table="vacowned_parted" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE vacowned_parted" +== 296 +-- truncate_limit: 100 +DROP ROLE regress_vacuum +-- +STMT: DropRoleStmt +TRUNCATED: "DROP ROLE regress_vacuum" diff --git a/parser/testdata/summary_truncate/postgres_regress/vacuum_parallel.metadata.json b/parser/testdata/summary_truncate/postgres_regress/vacuum_parallel.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/vacuum_parallel.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/vacuum_parallel.test b/parser/testdata/summary_truncate/postgres_regress/vacuum_parallel.test new file mode 100644 index 0000000..d0be9a5 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/vacuum_parallel.test @@ -0,0 +1,138 @@ +== 001 +-- truncate_limit: 100 +SET max_parallel_maintenance_workers TO 4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_maintenance_workers TO 4" +== 002 +-- truncate_limit: 100 +SET min_parallel_index_scan_size TO '128kB' +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_index_scan_size TO \"128kB\"" +== 003 +-- truncate_limit: 100 +-- Bug #17245: Make sure that we don't totally fail to VACUUM individual indexes that +-- happen to be below min_parallel_index_scan_size during parallel VACUUM: +CREATE TABLE parallel_vacuum_table (a int) WITH (autovacuum_enabled = off) +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE parallel_vacuum_table (a int) WITH (autovacuum_enabled=off)" +== 004 +-- truncate_limit: 100 +INSERT INTO parallel_vacuum_table SELECT i from generate_series(1, 10000) i +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parallel_vacuum_table SELECT i FROM generate_series(1, 10000) i" +== 005 +-- truncate_limit: 100 +-- Parallel VACUUM will never be used unless there are at least two indexes +-- that exceed min_parallel_index_scan_size. Create two such indexes, and +-- a third index that is smaller than min_parallel_index_scan_size. +CREATE INDEX regular_sized_index ON parallel_vacuum_table(a) +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX regular_sized_index ON parallel_vacuum_table USING btree (a)" +== 006 +-- truncate_limit: 100 +CREATE INDEX typically_sized_index ON parallel_vacuum_table(a) +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX typically_sized_index ON parallel_vacuum_table USING btree (a)" +== 007 +-- truncate_limit: 100 +-- Note: vacuum_in_leader_small_index can apply deduplication, making it ~3x +-- smaller than the other indexes +CREATE INDEX vacuum_in_leader_small_index ON parallel_vacuum_table((1)) +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX vacuum_in_leader_small_index ON parallel_vacuum_table USING btree ((1))" +== 008 +-- truncate_limit: 100 +-- Verify (as best we can) that the cost model for parallel VACUUM +-- will make our VACUUM run in parallel, while always leaving it up to the +-- parallel leader to handle the vacuum_in_leader_small_index index: +SELECT EXISTS ( +SELECT 1 +FROM pg_class +WHERE oid = 'vacuum_in_leader_small_index'::regclass AND + pg_relation_size(oid) < + pg_size_bytes(current_setting('min_parallel_index_scan_size')) +) as leader_will_handle_small_index +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT EXISTS (SELECT 1 FROM pg_class WHERE ...) AS leader_will_handle_small_index" +== 009 +-- truncate_limit: 100 +SELECT count(*) as trigger_parallel_vacuum_nindexes +FROM pg_class +WHERE oid in ('regular_sized_index'::regclass, 'typically_sized_index'::regclass) AND + pg_relation_size(oid) >= + pg_size_bytes(current_setting('min_parallel_index_scan_size')) +-- +TABLE: name="pg_class" schema="" table="pg_class" ctx=Select +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_relation_size" function="pg_relation_size" schema="" ctx=Call +FUNCTION: name="pg_size_bytes" function="pg_size_bytes" schema="" ctx=Call +FUNCTION: name="current_setting" function="current_setting" schema="" ctx=Call +FILTER: schema="" table="" column="oid" +FILTER: schema="" table="" column="oid" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) AS trigger_parallel_vacuum_nindexes FROM pg_class WHERE ..." +== 010 +-- truncate_limit: 100 +-- Parallel VACUUM with B-Tree page deletions, ambulkdelete calls: +DELETE FROM parallel_vacuum_table +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DML +STMT: DeleteStmt +TRUNCATED: "DELETE FROM parallel_vacuum_table" +== 011 +-- truncate_limit: 100 +VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DDL +STMT: VacuumStmt +TRUNCATED: "VACUUM (PARALLEL 4, INDEX_CLEANUP ON) parallel_vacuum_table" +== 012 +-- truncate_limit: 100 +-- Since vacuum_in_leader_small_index uses deduplication, we expect an +-- assertion failure with bug #17245 (in the absence of bugfix): +INSERT INTO parallel_vacuum_table SELECT i FROM generate_series(1, 10000) i +-- +TABLE: name="parallel_vacuum_table" schema="" table="parallel_vacuum_table" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parallel_vacuum_table SELECT i FROM generate_series(1, 10000) i" +== 013 +-- truncate_limit: 100 +RESET max_parallel_maintenance_workers +-- +STMT: VariableSetStmt +TRUNCATED: "RESET max_parallel_maintenance_workers" +== 014 +-- truncate_limit: 100 +RESET min_parallel_index_scan_size +-- +STMT: VariableSetStmt +TRUNCATED: "RESET min_parallel_index_scan_size" diff --git a/parser/testdata/summary_truncate/postgres_regress/varchar.metadata.json b/parser/testdata/summary_truncate/postgres_regress/varchar.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/varchar.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/varchar.test b/parser/testdata/summary_truncate/postgres_regress/varchar.test new file mode 100644 index 0000000..698eb12 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/varchar.test @@ -0,0 +1,207 @@ +== 001 +-- truncate_limit: 100 +|-- +-- VARCHAR +|-- + +|-- +-- Build a table for testing +-- (This temporarily hides the table created in test_setup.sql) +|-- + +CREATE TEMP TABLE VARCHAR_TBL(f1 varchar(1)) +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE varchar_tbl (f1 varchar(1))" +== 002 +-- truncate_limit: 100 +INSERT INTO VARCHAR_TBL (f1) VALUES ('a') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('a')" +== 003 +-- truncate_limit: 100 +INSERT INTO VARCHAR_TBL (f1) VALUES ('A') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('A')" +== 004 +-- truncate_limit: 100 +-- any of the following three input formats are acceptable +INSERT INTO VARCHAR_TBL (f1) VALUES ('1') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('1')" +== 005 +-- truncate_limit: 100 +INSERT INTO VARCHAR_TBL (f1) VALUES (2) +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES (2)" +== 006 +-- truncate_limit: 100 +INSERT INTO VARCHAR_TBL (f1) VALUES ('3') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('3')" +== 007 +-- truncate_limit: 100 +-- zero-length char +INSERT INTO VARCHAR_TBL (f1) VALUES ('') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('')" +== 008 +-- truncate_limit: 100 +-- try varchar's of greater than 1 length +INSERT INTO VARCHAR_TBL (f1) VALUES ('cd') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('cd')" +== 009 +-- truncate_limit: 100 +INSERT INTO VARCHAR_TBL (f1) VALUES ('c ') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('c ')" +== 010 +-- truncate_limit: 100 +SELECT * FROM VARCHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM varchar_tbl" +== 011 +-- truncate_limit: 100 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 <> 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM varchar_tbl c WHERE c.f1 <> 'a'" +== 012 +-- truncate_limit: 100 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 = 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM varchar_tbl c WHERE c.f1 = 'a'" +== 013 +-- truncate_limit: 100 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 < 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM varchar_tbl c WHERE c.f1 < 'a'" +== 014 +-- truncate_limit: 100 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 <= 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM varchar_tbl c WHERE c.f1 <= 'a'" +== 015 +-- truncate_limit: 100 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 > 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM varchar_tbl c WHERE c.f1 > 'a'" +== 016 +-- truncate_limit: 100 +SELECT c.* + FROM VARCHAR_TBL c + WHERE c.f1 >= 'a' +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +ALIAS: "c"="varchar_tbl" +FILTER: schema="" table="c" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT c.* FROM varchar_tbl c WHERE c.f1 >= 'a'" +== 017 +-- truncate_limit: 100 +DROP TABLE VARCHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE varchar_tbl" +== 018 +-- truncate_limit: 100 +|-- +-- Now test longer arrays of char +|-- +-- This varchar_tbl was already created and filled in test_setup.sql. +-- Here we just try to insert bad values. +|-- + +INSERT INTO VARCHAR_TBL (f1) VALUES ('abcde') +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO varchar_tbl (f1) VALUES ('abcde')" +== 019 +-- truncate_limit: 100 +SELECT * FROM VARCHAR_TBL +-- +TABLE: name="varchar_tbl" schema="" table="varchar_tbl" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM varchar_tbl" +== 020 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('abcd ', 'varchar(4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('abcd ', 'varchar(4)')" +== 021 +-- truncate_limit: 100 +SELECT pg_input_is_valid('abcde', 'varchar(4)') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('abcde', 'varchar(4)')" +== 022 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('abcde', 'varchar(4)') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('abcde', 'varchar(4)')" diff --git a/parser/testdata/summary_truncate/postgres_regress/window.metadata.json b/parser/testdata/summary_truncate/postgres_regress/window.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/window.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/window.test b/parser/testdata/summary_truncate/postgres_regress/window.test new file mode 100644 index 0000000..ef3441a --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/window.test @@ -0,0 +1,4627 @@ +== 001 +-- truncate_limit: 100 +|-- +-- WINDOW FUNCTIONS +|-- + +CREATE TEMPORARY TABLE empsalary ( + depname varchar, + empno bigint, + salary int, + enroll_date date +) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE empsalary (depname varchar, empno bigint, salary int, enroll_date date)" +== 002 +-- truncate_limit: 100 +INSERT INTO empsalary VALUES +('develop', 10, 5200, '2007-08-01'), +('sales', 1, 5000, '2006-10-01'), +('personnel', 5, 3500, '2007-12-10'), +('sales', 4, 4800, '2007-08-08'), +('personnel', 2, 3900, '2006-12-23'), +('develop', 7, 4200, '2008-01-01'), +('develop', 9, 4500, '2008-01-01'), +('sales', 3, 4800, '2007-08-01'), +('develop', 8, 6000, '2006-10-01'), +('develop', 11, 5200, '2007-08-15') +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO empsalary VALUES (...)" +== 003 +-- truncate_limit: 100 +SELECT depname, empno, salary, sum(salary) OVER (PARTITION BY depname) FROM empsalary ORDER BY depname, salary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary ORDER BY depname, salary" +== 004 +-- truncate_limit: 100 +SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT depname, empno, salary, rank() OVER (PARTITION BY depname ORDER BY salary) FROM empsalary" +== 005 +-- truncate_limit: 100 +-- with GROUP BY +SELECT four, ten, SUM(SUM(four)) OVER (PARTITION BY four), AVG(ten) FROM tenk1 +GROUP BY four, ten ORDER BY four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 GROUP BY four, ten ORDER BY four, ten" +== 006 +-- truncate_limit: 100 +SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT depname, empno, salary, sum(salary) OVER w FROM empsalary WINDOW w AS (PARTITION BY depname)" +== 007 +-- truncate_limit: 100 +SELECT depname, empno, salary, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary) ORDER BY rank() OVER w" +== 008 +-- truncate_limit: 100 +-- empty window specification +SELECT COUNT(*) OVER () FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) OVER () FROM tenk1 WHERE unique2 < 10" +== 009 +-- truncate_limit: 100 +SELECT COUNT(*) OVER w FROM tenk1 WHERE unique2 < 10 WINDOW w AS () +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) OVER w FROM tenk1 WHERE unique2 < 10 WINDOW w AS ()" +== 010 +-- truncate_limit: 100 +-- no window operation +SELECT four FROM tenk1 WHERE FALSE WINDOW w AS (PARTITION BY ten) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT four FROM tenk1 WHERE false WINDOW w AS (PARTITION BY ten)" +== 011 +-- truncate_limit: 100 +-- cumulative aggregate +SELECT sum(four) OVER (PARTITION BY ten ORDER BY unique2) AS sum_1, ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10" +== 012 +-- truncate_limit: 100 +SELECT row_number() OVER (ORDER BY unique2) FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT row_number() OVER (ORDER BY unique2) FROM tenk1 WHERE unique2 < 10" +== 013 +-- truncate_limit: 100 +SELECT rank() OVER (PARTITION BY four ORDER BY ten) AS rank_1, ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10" +== 014 +-- truncate_limit: 100 +SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT dense_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10" +== 015 +-- truncate_limit: 100 +SELECT percent_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="percent_rank" function="percent_rank" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT percent_rank() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10" +== 016 +-- truncate_limit: 100 +SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="cume_dist" function="cume_dist" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT cume_dist() OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10" +== 017 +-- truncate_limit: 100 +SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ntile(3) OVER (ORDER BY ten, four), ten, four FROM tenk1 WHERE unique2 < 10" +== 018 +-- truncate_limit: 100 +SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ntile(NULL) OVER (ORDER BY ten, four), ten, four FROM tenk1 LIMIT 2" +== 019 +-- truncate_limit: 100 +SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT lag(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10" +== 020 +-- truncate_limit: 100 +SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT lag(ten, four) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10" +== 021 +-- truncate_limit: 100 +SELECT lag(ten, four, 0) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10" +== 022 +-- truncate_limit: 100 +SELECT lag(ten, four, 0.7) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten" +== 023 +-- truncate_limit: 100 +SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT lead(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10" +== 024 +-- truncate_limit: 100 +SELECT lead(ten * 2, 1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10" +== 025 +-- truncate_limit: 100 +SELECT lead(ten * 2, 1, -1) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10" +== 026 +-- truncate_limit: 100 +SELECT lead(ten * 2, 1, -1.4) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten" +== 027 +-- truncate_limit: 100 +SELECT first_value(ten) OVER (PARTITION BY four ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10" +== 028 +-- truncate_limit: 100 +-- last_value returns the last row of the frame, which is CURRENT ROW in ORDER BY window. +SELECT last_value(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT last_value(four) OVER (ORDER BY ten), ten, four FROM tenk1 WHERE unique2 < 10" +== 029 +-- truncate_limit: 100 +SELECT last_value(ten) OVER (PARTITION BY four), ten, four FROM + (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s + ORDER BY four, ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM tenk1 WHERE ... ORDER BY four, ten) s ORDER BY four, ten" +== 030 +-- truncate_limit: 100 +SELECT nth_value(ten, four + 1) OVER (PARTITION BY four), ten, four + FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten)s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM tenk1 WHERE ... ORDER BY four, ten) s" +== 031 +-- truncate_limit: 100 +SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER (PARTITION BY two ORDER BY ten) AS wsum +FROM tenk1 GROUP BY ten, two +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 GROUP BY ten, two" +== 032 +-- truncate_limit: 100 +SELECT count(*) OVER (PARTITION BY four), four FROM (SELECT * FROM tenk1 WHERE two = 1)s WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="" column="two" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM tenk1 WHERE ...) s WHERE unique2 < 10" +== 033 +-- truncate_limit: 100 +SELECT (count(*) OVER (PARTITION BY four ORDER BY ten) + + sum(hundred) OVER (PARTITION BY four ORDER BY ten))::varchar AS cntsum + FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique2 < 10" +== 034 +-- truncate_limit: 100 +-- opexpr with different windows evaluation. +SELECT * FROM( + SELECT count(*) OVER (PARTITION BY four ORDER BY ten) + + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS total, + count(*) OVER (PARTITION BY four ORDER BY ten) AS fourcount, + sum(hundred) OVER (PARTITION BY two ORDER BY ten) AS twosum + FROM tenk1 +)sub +WHERE total <> fourcount + twosum +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="total" +FILTER: schema="" table="" column="fourcount" +FILTER: schema="" table="" column="twosum" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM tenk1) sub WHERE total <> (fourcount + twosum)" +== 035 +-- truncate_limit: 100 +SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10" +== 036 +-- truncate_limit: 100 +SELECT ten, two, sum(hundred) AS gsum, sum(sum(hundred)) OVER win AS wsum +FROM tenk1 GROUP BY ten, two WINDOW win AS (PARTITION BY two ORDER BY ten) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 GROUP BY ten, two WINDOW win AS (PARTITION BY two ORDER BY ten)" +== 037 +-- truncate_limit: 100 +-- more than one window with GROUP BY +SELECT sum(salary), + row_number() OVER (ORDER BY depname), + sum(sum(salary)) OVER (ORDER BY depname DESC) +FROM empsalary GROUP BY depname +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary GROUP BY depname" +== 038 +-- truncate_limit: 100 +-- identical windows with different names +SELECT sum(salary) OVER w1, count(*) OVER w2 +FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary WINDOW w1 AS (ORDER BY salary), w2 AS (ORDER BY salary)" +== 039 +-- truncate_limit: 100 +-- subplan +SELECT lead(ten, (SELECT two FROM tenk1 WHERE s.unique2 = unique2)) OVER (PARTITION BY four ORDER BY ten) +FROM tenk1 s WHERE unique2 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "s"="tenk1" +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +FILTER: schema="" table="s" column="unique2" +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 s WHERE unique2 < 10" +== 040 +-- truncate_limit: 100 +-- empty table +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE FALSE)s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 WHERE false) s" +== 041 +-- truncate_limit: 100 +-- mixture of agg/wfunc in the same window +SELECT sum(salary) OVER w, rank() OVER w FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary WINDOW w AS (PARTITION BY depname ORDER BY salary DESC)" +== 042 +-- truncate_limit: 100 +-- strict aggs +SELECT empno, depname, salary, bonus, depadj, MIN(bonus) OVER (ORDER BY empno), MAX(depadj) OVER () FROM( + SELECT *, + CASE WHEN enroll_date < '2008-01-01' THEN 2008 - extract(YEAR FROM enroll_date) END * 500 AS bonus, + CASE WHEN + AVG(salary) OVER (PARTITION BY depname) < salary + THEN 200 END AS depadj FROM empsalary +)s +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +FUNCTION: name="pg_catalog.extract" function="extract" schema="pg_catalog" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM empsalary) s" +== 043 +-- truncate_limit: 100 +-- window function over ungrouped agg over empty row set (bug before 9.1) +SELECT SUM(COUNT(f1)) OVER () FROM int4_tbl WHERE f1=42 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +STMT: SelectStmt +TRUNCATED: "SELECT sum(count(f1)) OVER () FROM int4_tbl WHERE f1 = 42" +== 044 +-- truncate_limit: 100 +-- window function with ORDER BY an expression involving aggregates (9.1 bug) +select ten, + sum(unique1) + sum(unique2) as res, + rank() over (order by sum(unique1) + sum(unique2)) as rank +from tenk1 +group by ten order by ten +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 GROUP BY ten ORDER BY ten" +== 045 +-- truncate_limit: 100 +-- window and aggregate with GROUP BY expression (9.2 bug) +explain (costs off) +select first_value(max(x)) over (), y + from (select unique1 as x, ten+four as y from tenk1) ss + group by y +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT first_value(max(x)) OVER (), y FROM (SELECT unique1 AS x, ten + four A..." +== 046 +-- truncate_limit: 100 +-- window functions returning pass-by-ref values from different rows +select x, lag(x, 1) over (order by x), lead(x, 3) over (order by x) +from (select x::numeric as x from generate_series(1,10) x) +-- +FUNCTION: name="lag" function="lag" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM generate_series(1, 10) x)" +== 047 +-- truncate_limit: 100 +-- test non-default frame specifications +SELECT four, ten, + sum(ten) over (partition by four order by ten), + last_value(ten) over (partition by four order by ten) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT DISTINCT ... AS ... FROM tenk1) ss" +== 048 +-- truncate_limit: 100 +SELECT four, ten, + sum(ten) over (partition by four order by ten range between unbounded preceding and current row), + last_value(ten) over (partition by four order by ten range between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT DISTINCT ... AS ... FROM tenk1) ss" +== 049 +-- truncate_limit: 100 +SELECT four, ten, + sum(ten) over (partition by four order by ten range between unbounded preceding and unbounded following), + last_value(ten) over (partition by four order by ten range between unbounded preceding and unbounded following) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT DISTINCT ... AS ... FROM tenk1) ss" +== 050 +-- truncate_limit: 100 +SELECT four, ten/4 as two, + sum(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row), + last_value(ten/4) over (partition by four order by ten/4 range between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT DISTINCT ... AS ... FROM tenk1) ss" +== 051 +-- truncate_limit: 100 +SELECT four, ten/4 as two, + sum(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row), + last_value(ten/4) over (partition by four order by ten/4 rows between unbounded preceding and current row) +FROM (select distinct ten, four from tenk1) ss +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT DISTINCT ... AS ... FROM tenk1) ss" +== 052 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four range between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 053 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 054 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between 2 preceding and 2 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 055 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude no others), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 056 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 057 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 058 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between 2 preceding and 2 following exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 059 +-- truncate_limit: 100 +SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 060 +-- truncate_limit: 100 +SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 061 +-- truncate_limit: 100 +SELECT first_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 062 +-- truncate_limit: 100 +SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 063 +-- truncate_limit: 100 +SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 064 +-- truncate_limit: 100 +SELECT last_value(unique1) over (ORDER BY four rows between current row and 2 following exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 065 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between 2 preceding and 1 preceding), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 066 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between 1 following and 3 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 067 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between unbounded preceding and 1 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 068 +-- truncate_limit: 100 +SELECT sum(unique1) over (w range between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10 WINDOW w AS (ORDER BY four)" +== 069 +-- truncate_limit: 100 +SELECT sum(unique1) over (w range between unbounded preceding and current row exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10 WINDOW w AS (ORDER BY four)" +== 070 +-- truncate_limit: 100 +SELECT sum(unique1) over (w range between unbounded preceding and current row exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10 WINDOW w AS (ORDER BY four)" +== 071 +-- truncate_limit: 100 +SELECT sum(unique1) over (w range between unbounded preceding and current row exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 WINDOW w AS (order by four) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10 WINDOW w AS (ORDER BY four)" +== 072 +-- truncate_limit: 100 +SELECT first_value(unique1) over w, + nth_value(unique1, 2) over w AS nth_2, + last_value(unique1) over w, unique1, four +FROM tenk1 WHERE unique1 < 10 +WINDOW w AS (order by four range between current row and unbounded following) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE ... WINDOW w AS (ORDER BY four RANGE BETWEEN CURRENT ROW AND UNBOUNDE..." +== 073 +-- truncate_limit: 100 +SELECT sum(unique1) over + (order by unique1 + rows (SELECT unique1 FROM tenk1 ORDER BY unique1 LIMIT 1) + 1 PRECEDING), + unique1 +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 074 +-- truncate_limit: 100 +CREATE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following) as sum_rows + FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v_window AS SELECT i, sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND ..." +== 075 +-- truncate_limit: 100 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_window" +== 076 +-- truncate_limit: 100 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_window')" +== 077 +-- truncate_limit: 100 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following + exclude current row) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW v_window AS SELECT i, sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRE..." +== 078 +-- truncate_limit: 100 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_window" +== 079 +-- truncate_limit: 100 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_window')" +== 080 +-- truncate_limit: 100 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following + exclude group) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW v_window AS SELECT i, sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRE..." +== 081 +-- truncate_limit: 100 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_window" +== 082 +-- truncate_limit: 100 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_window')" +== 083 +-- truncate_limit: 100 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following + exclude ties) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW v_window AS SELECT i, sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRE..." +== 084 +-- truncate_limit: 100 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_window" +== 085 +-- truncate_limit: 100 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_window')" +== 086 +-- truncate_limit: 100 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i rows between 1 preceding and 1 following + exclude no others) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW v_window AS SELECT i, sum(i) OVER (ORDER BY i ROWS BETWEEN 1 PRE..." +== 087 +-- truncate_limit: 100 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_window" +== 088 +-- truncate_limit: 100 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_window')" +== 089 +-- truncate_limit: 100 +CREATE OR REPLACE TEMP VIEW v_window AS + SELECT i, sum(i) over (order by i groups between 1 preceding and 1 following) as sum_rows FROM generate_series(1, 10) i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE TEMPORARY VIEW v_window AS SELECT i, sum(i) OVER (ORDER BY i GROUPS BETWEEN 1 P..." +== 090 +-- truncate_limit: 100 +SELECT * FROM v_window +-- +TABLE: name="v_window" schema="" table="v_window" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_window" +== 091 +-- truncate_limit: 100 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_window')" +== 092 +-- truncate_limit: 100 +DROP VIEW v_window +-- +STMT: DropStmt +TRUNCATED: "DROP VIEW v_window" +== 093 +-- truncate_limit: 100 +CREATE TEMP VIEW v_window AS + SELECT i, min(i) over (order by i range between '1 day' preceding and '10 days' following) as min_i + FROM generate_series(now(), now()+'100 days'::interval, '1 hour') i +-- +TABLE: name="v_window" schema="" table="v_window" ctx=DDL +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v_window AS SELECT i, min(i) OVER (ORDER BY i RANGE BETWEEN '1 day' PRECEDI..." +== 094 +-- truncate_limit: 100 +SELECT pg_get_viewdef('v_window') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_window')" +== 095 +-- truncate_limit: 100 +-- RANGE offset PRECEDING/FOLLOWING tests + +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 096 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four desc range between 2::int8 preceding and 1::int2 preceding), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 097 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude no others), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 098 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 099 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 100 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 1::int2 preceding exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 101 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude ties), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 102 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four range between 2::int8 preceding and 6::int2 following exclude group), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 103 +-- truncate_limit: 100 +SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 104 +-- truncate_limit: 100 +SELECT sum(unique1) over (partition by four order by unique1 range between 5::int8 preceding and 6::int2 following + exclude current row),unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 105 +-- truncate_limit: 100 +select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 106 +-- truncate_limit: 100 +select sum(salary) over (order by enroll_date desc range between '1 year'::interval preceding and '1 year'::interval following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 107 +-- truncate_limit: 100 +select sum(salary) over (order by enroll_date desc range between '1 year'::interval following and '1 year'::interval following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 108 +-- truncate_limit: 100 +select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + exclude current row), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 109 +-- truncate_limit: 100 +select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + exclude group), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 110 +-- truncate_limit: 100 +select sum(salary) over (order by enroll_date range between '1 year'::interval preceding and '1 year'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 111 +-- truncate_limit: 100 +select first_value(salary) over(order by salary range between 1000 preceding and 1000 following), + lead(salary) over(order by salary range between 1000 preceding and 1000 following), + nth_value(salary, 1) over(order by salary range between 1000 preceding and 1000 following), + salary from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 112 +-- truncate_limit: 100 +select last_value(salary) over(order by salary range between 1000 preceding and 1000 following), + lag(salary) over(order by salary range between 1000 preceding and 1000 following), + salary from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 113 +-- truncate_limit: 100 +select first_value(salary) over(order by salary range between 1000 following and 3000 following + exclude current row), + lead(salary) over(order by salary range between 1000 following and 3000 following exclude ties), + nth_value(salary, 1) over(order by salary range between 1000 following and 3000 following + exclude ties), + salary from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 114 +-- truncate_limit: 100 +select last_value(salary) over(order by salary range between 1000 following and 3000 following + exclude group), + lag(salary) over(order by salary range between 1000 following and 3000 following exclude group), + salary from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 115 +-- truncate_limit: 100 +select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude ties), + last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 116 +-- truncate_limit: 100 +select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude ties), + last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude ties), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 117 +-- truncate_limit: 100 +select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude group), + last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude group), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 118 +-- truncate_limit: 100 +select first_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude current row), + last_value(salary) over(order by enroll_date range between unbounded preceding and '1 year'::interval following + exclude current row), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 119 +-- truncate_limit: 100 +-- RANGE offset PRECEDING/FOLLOWING with null values +select x, y, + first_value(y) over w, + last_value(y) over w +from + (select x, x as y from generate_series(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by x asc nulls first range between 2 preceding and 2 following) +-- +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM ((SELECT ... FROM generate_series(1, 5) x UNION ALL SELECT ...) UNION ALL SELECT ..." +== 120 +-- truncate_limit: 100 +select x, y, + first_value(y) over w, + last_value(y) over w +from + (select x, x as y from generate_series(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by x asc nulls last range between 2 preceding and 2 following) +-- +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM ((SELECT ... FROM generate_series(1, 5) x UNION ALL SELECT ...) UNION ALL SELECT ..." +== 121 +-- truncate_limit: 100 +select x, y, + first_value(y) over w, + last_value(y) over w +from + (select x, x as y from generate_series(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by x desc nulls first range between 2 preceding and 2 following) +-- +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM ((SELECT ... FROM generate_series(1, 5) x UNION ALL SELECT ...) UNION ALL SELECT ..." +== 122 +-- truncate_limit: 100 +select x, y, + first_value(y) over w, + last_value(y) over w +from + (select x, x as y from generate_series(1,5) as x + union all select null, 42 + union all select null, 43) ss +window w as + (order by x desc nulls last range between 2 preceding and 2 following) +-- +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM ((SELECT ... FROM generate_series(1, 5) x UNION ALL SELECT ...) UNION ALL SELECT ..." +== 123 +-- truncate_limit: 100 +-- There is a syntactic ambiguity in the SQL standard. Since +-- UNBOUNDED is a non-reserved word, it could be the name of a +-- function parameter and be used as an expression. There is a +-- grammar hack to resolve such cases as the keyword. The following +-- tests record this behavior. + +CREATE FUNCTION unbounded_syntax_test1a(x int) RETURNS TABLE (a int, b int, c int) +LANGUAGE SQL +BEGIN ATOMIC + SELECT sum(unique1) over (rows between x preceding and x following), + unique1, four + FROM tenk1 WHERE unique1 < 10 +-- +ERROR: syntax error at end of input +CURSORPOS: 525 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 124 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 125 +-- truncate_limit: 100 +CREATE FUNCTION unbounded_syntax_test1b(x int) RETURNS TABLE (a int, b int, c int) +LANGUAGE SQL +AS $$ + SELECT sum(unique1) over (rows between x preceding and x following), + unique1, four + FROM tenk1 WHERE unique1 < 10; +$$ +-- +FUNCTION: name="unbounded_syntax_test1b" function="unbounded_syntax_test1b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION unbounded_syntax_test1b(x int) RETURNS TABLE (a int, b int, c int) LANGUAGE sql A..." +== 126 +-- truncate_limit: 100 +-- These will apply the argument to the window specification inside the function. +SELECT * FROM unbounded_syntax_test1a(2) +-- +FUNCTION: name="unbounded_syntax_test1a" function="unbounded_syntax_test1a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unbounded_syntax_test1a(2)" +== 127 +-- truncate_limit: 100 +SELECT * FROM unbounded_syntax_test1b(2) +-- +FUNCTION: name="unbounded_syntax_test1b" function="unbounded_syntax_test1b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unbounded_syntax_test1b(2)" +== 128 +-- truncate_limit: 100 +CREATE FUNCTION unbounded_syntax_test2a(unbounded int) RETURNS TABLE (a int, b int, c int) +LANGUAGE SQL +BEGIN ATOMIC + SELECT sum(unique1) over (rows between unbounded preceding and unbounded following), + unique1, four + FROM tenk1 WHERE unique1 < 10 +-- +ERROR: syntax error at end of input +CURSORPOS: 259 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 129 +-- truncate_limit: 100 +END +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 130 +-- truncate_limit: 100 +CREATE FUNCTION unbounded_syntax_test2b(unbounded int) RETURNS TABLE (a int, b int, c int) +LANGUAGE SQL +AS $$ + SELECT sum(unique1) over (rows between unbounded preceding and unbounded following), + unique1, four + FROM tenk1 WHERE unique1 < 10; +$$ +-- +FUNCTION: name="unbounded_syntax_test2b" function="unbounded_syntax_test2b" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION unbounded_syntax_test2b(unbounded int) RETURNS TABLE (a int, b int, c int) LANGUA..." +== 131 +-- truncate_limit: 100 +-- These will not apply the argument but instead treat UNBOUNDED as a keyword. +SELECT * FROM unbounded_syntax_test2a(2) +-- +FUNCTION: name="unbounded_syntax_test2a" function="unbounded_syntax_test2a" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unbounded_syntax_test2a(2)" +== 132 +-- truncate_limit: 100 +SELECT * FROM unbounded_syntax_test2b(2) +-- +FUNCTION: name="unbounded_syntax_test2b" function="unbounded_syntax_test2b" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM unbounded_syntax_test2b(2)" +== 133 +-- truncate_limit: 100 +DROP FUNCTION unbounded_syntax_test1a, unbounded_syntax_test1b, + unbounded_syntax_test2a, unbounded_syntax_test2b +-- +FUNCTION: name="unbounded_syntax_test1a" function="unbounded_syntax_test1a" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION unbounded_syntax_test1a, unbounded_syntax_test1b, unbounded_syntax_test2a, unbounde..." +== 134 +-- truncate_limit: 100 +-- Other tests with token UNBOUNDED in potentially problematic position +CREATE FUNCTION unbounded(x int) RETURNS int LANGUAGE SQL IMMUTABLE RETURN x +-- +FUNCTION: name="unbounded" function="unbounded" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION unbounded(x int) RETURNS int LANGUAGE sql IMMUTABLE RETURN x" +== 135 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between 1 preceding and 1 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 136 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between unbounded(1) preceding and unbounded(1) following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="unbounded" function="unbounded" schema="" ctx=Call +FUNCTION: name="unbounded" function="unbounded" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 137 +-- truncate_limit: 100 +SELECT sum(unique1) over (rows between unbounded.x preceding and unbounded.x following), + unique1, four +FROM tenk1, (values (1)) as unbounded(x) WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1, (VALUES (1)) unbounded(x) WHERE unique1 < 10" +== 138 +-- truncate_limit: 100 +DROP FUNCTION unbounded +-- +FUNCTION: name="unbounded" function="unbounded" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION unbounded" +== 139 +-- truncate_limit: 100 +-- Check overflow behavior for various integer sizes + +select x, last_value(x) over (order by x::smallint range between current row and 2147450884 following) +from generate_series(32764, 32766) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(32764, 32766) x" +== 140 +-- truncate_limit: 100 +select x, last_value(x) over (order by x::smallint desc range between current row and 2147450885 following) +from generate_series(-32766, -32764) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(-32766, -32764) x" +== 141 +-- truncate_limit: 100 +select x, last_value(x) over (order by x range between current row and 4 following) +from generate_series(2147483644, 2147483646) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(2147483644, 2147483646) x" +== 142 +-- truncate_limit: 100 +select x, last_value(x) over (order by x desc range between current row and 5 following) +from generate_series(-2147483646, -2147483644) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(-2147483646, -2147483644) x" +== 143 +-- truncate_limit: 100 +select x, last_value(x) over (order by x range between current row and 4 following) +from generate_series(9223372036854775804, 9223372036854775806) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(9223372036854775804, 9223372036854775806) x" +== 144 +-- truncate_limit: 100 +select x, last_value(x) over (order by x desc range between current row and 5 following) +from generate_series(-9223372036854775806, -9223372036854775804) x +-- +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(-9223372036854775806, -9223372036854775804) x" +== 145 +-- truncate_limit: 100 +-- Test in_range for other numeric datatypes + +create temp table numerics( + id int, + f_float4 float4, + f_float8 float8, + f_numeric numeric +) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE numerics (id int, f_float4 float4, f_float8 float8, f_numeric numeric)" +== 146 +-- truncate_limit: 100 +insert into numerics values +(0, '-infinity', '-infinity', '-infinity'), +(1, -3, -3, -3), +(2, -1, -1, -1), +(3, 0, 0, 0), +(4, 1.1, 1.1, 1.1), +(5, 1.12, 1.12, 1.12), +(6, 2, 2, 2), +(7, 100, 100, 100), +(8, 'infinity', 'infinity', 'infinity'), +(9, 'NaN', 'NaN', 'NaN') +-- +TABLE: name="numerics" schema="" table="numerics" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO numerics VALUES (...)" +== 147 +-- truncate_limit: 100 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 1 preceding and 1 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float4 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)" +== 148 +-- truncate_limit: 100 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 1 preceding and 1.1::float4 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float4 RANGE BETWEEN 1 PRECEDING AND (1.1)::floa..." +== 149 +-- truncate_limit: 100 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 'inf' preceding and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float4 RANGE BETWEEN 'inf' PRECEDING AND 'inf' F..." +== 150 +-- truncate_limit: 100 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 'inf' preceding and 'inf' preceding) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float4 RANGE BETWEEN 'inf' PRECEDING AND 'inf' P..." +== 151 +-- truncate_limit: 100 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 'inf' following and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float4 RANGE BETWEEN 'inf' FOLLOWING AND 'inf' F..." +== 152 +-- truncate_limit: 100 +select id, f_float4, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float4 range between + 1.1 preceding and 'NaN' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float4 RANGE BETWEEN 1.1 PRECEDING AND 'NaN' FOL..." +== 153 +-- truncate_limit: 100 +-- error, NaN disallowed + +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 1 preceding and 1 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float8 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)" +== 154 +-- truncate_limit: 100 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 1 preceding and 1.1::float8 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float8 RANGE BETWEEN 1 PRECEDING AND (1.1)::floa..." +== 155 +-- truncate_limit: 100 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 'inf' preceding and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float8 RANGE BETWEEN 'inf' PRECEDING AND 'inf' F..." +== 156 +-- truncate_limit: 100 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 'inf' preceding and 'inf' preceding) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float8 RANGE BETWEEN 'inf' PRECEDING AND 'inf' P..." +== 157 +-- truncate_limit: 100 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 'inf' following and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float8 RANGE BETWEEN 'inf' FOLLOWING AND 'inf' F..." +== 158 +-- truncate_limit: 100 +select id, f_float8, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_float8 range between + 1.1 preceding and 'NaN' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_float8 RANGE BETWEEN 1.1 PRECEDING AND 'NaN' FOL..." +== 159 +-- truncate_limit: 100 +-- error, NaN disallowed + +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_numeric RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING)" +== 160 +-- truncate_limit: 100 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1.1::numeric following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_numeric RANGE BETWEEN 1 PRECEDING AND (1.1)::num..." +== 161 +-- truncate_limit: 100 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 1 preceding and 1.1::float8 following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_numeric RANGE BETWEEN 1 PRECEDING AND (1.1)::flo..." +== 162 +-- truncate_limit: 100 +-- currently unsupported +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 'inf' preceding and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_numeric RANGE BETWEEN 'inf' PRECEDING AND 'inf' ..." +== 163 +-- truncate_limit: 100 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 'inf' preceding and 'inf' preceding) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_numeric RANGE BETWEEN 'inf' PRECEDING AND 'inf' ..." +== 164 +-- truncate_limit: 100 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 'inf' following and 'inf' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_numeric RANGE BETWEEN 'inf' FOLLOWING AND 'inf' ..." +== 165 +-- truncate_limit: 100 +select id, f_numeric, first_value(id) over w, last_value(id) over w +from numerics +window w as (order by f_numeric range between + 1.1 preceding and 'NaN' following) +-- +TABLE: name="numerics" schema="" table="numerics" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM numerics WINDOW w AS (ORDER BY f_numeric RANGE BETWEEN 1.1 PRECEDING AND 'NaN' FO..." +== 166 +-- truncate_limit: 100 +-- error, NaN disallowed + +-- Test in_range for other datetime datatypes + +create temp table datetimes( + id int, + f_time time, + f_timetz timetz, + f_interval interval, + f_timestamptz timestamptz, + f_timestamp timestamp +) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE datetimes (id int, f_time time, f_timetz timetz, f_interval interval, f_ti..." +== 167 +-- truncate_limit: 100 +insert into datetimes values +(0, '10:00', '10:00 BST', '-infinity', '-infinity', '-infinity'), +(1, '11:00', '11:00 BST', '1 year', '2000-10-19 10:23:54+01', '2000-10-19 10:23:54'), +(2, '12:00', '12:00 BST', '2 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), +(3, '13:00', '13:00 BST', '3 years', '2001-10-19 10:23:54+01', '2001-10-19 10:23:54'), +(4, '14:00', '14:00 BST', '4 years', '2002-10-19 10:23:54+01', '2002-10-19 10:23:54'), +(5, '15:00', '15:00 BST', '5 years', '2003-10-19 10:23:54+01', '2003-10-19 10:23:54'), +(6, '15:00', '15:00 BST', '5 years', '2004-10-19 10:23:54+01', '2004-10-19 10:23:54'), +(7, '17:00', '17:00 BST', '7 years', '2005-10-19 10:23:54+01', '2005-10-19 10:23:54'), +(8, '18:00', '18:00 BST', '8 years', '2006-10-19 10:23:54+01', '2006-10-19 10:23:54'), +(9, '19:00', '19:00 BST', '9 years', '2007-10-19 10:23:54+01', '2007-10-19 10:23:54'), +(10, '20:00', '20:00 BST', '10 years', '2008-10-19 10:23:54+01', '2008-10-19 10:23:54'), +(11, '21:00', '21:00 BST', 'infinity', 'infinity', 'infinity') +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO datetimes VALUES (...)" +== 168 +-- truncate_limit: 100 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + '70 min'::interval preceding and '2 hours'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_time RANGE BETWEEN '70 min'::interval PRECEDING..." +== 169 +-- truncate_limit: 100 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time desc range between + '70 min' preceding and '2 hours' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_time DESC RANGE BETWEEN '70 min' PRECEDING AND ..." +== 170 +-- truncate_limit: 100 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time desc range between + '-70 min' preceding and '2 hours' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_time DESC RANGE BETWEEN '-70 min' PRECEDING AND..." +== 171 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_time RANGE BETWEEN 'infinity'::interval PRECEDI..." +== 172 +-- truncate_limit: 100 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_time RANGE BETWEEN 'infinity'::interval PRECEDI..." +== 173 +-- truncate_limit: 100 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_time RANGE BETWEEN 'infinity'::interval FOLLOWI..." +== 174 +-- truncate_limit: 100 +select id, f_time, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_time range between + '-infinity'::interval following and + 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_time RANGE BETWEEN '-infinity'::interval FOLLOW..." +== 175 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + '70 min'::interval preceding and '2 hours'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timetz RANGE BETWEEN '70 min'::interval PRECEDI..." +== 176 +-- truncate_limit: 100 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz desc range between + '70 min' preceding and '2 hours' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timetz DESC RANGE BETWEEN '70 min' PRECEDING AN..." +== 177 +-- truncate_limit: 100 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz desc range between + '70 min' preceding and '-2 hours' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timetz DESC RANGE BETWEEN '70 min' PRECEDING AN..." +== 178 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timetz RANGE BETWEEN 'infinity'::interval PRECE..." +== 179 +-- truncate_limit: 100 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timetz RANGE BETWEEN 'infinity'::interval PRECE..." +== 180 +-- truncate_limit: 100 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timetz RANGE BETWEEN 'infinity'::interval FOLLO..." +== 181 +-- truncate_limit: 100 +select id, f_timetz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timetz range between + 'infinity'::interval following and + '-infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timetz RANGE BETWEEN 'infinity'::interval FOLLO..." +== 182 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + '1 year'::interval preceding and '1 year'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_interval RANGE BETWEEN '1 year'::interval PRECE..." +== 183 +-- truncate_limit: 100 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval desc range between + '1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_interval DESC RANGE BETWEEN '1 year' PRECEDING ..." +== 184 +-- truncate_limit: 100 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval desc range between + '-1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_interval DESC RANGE BETWEEN '-1 year' PRECEDING..." +== 185 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_interval RANGE BETWEEN 'infinity'::interval PRE..." +== 186 +-- truncate_limit: 100 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_interval RANGE BETWEEN 'infinity'::interval PRE..." +== 187 +-- truncate_limit: 100 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_interval RANGE BETWEEN 'infinity'::interval FOL..." +== 188 +-- truncate_limit: 100 +select id, f_interval, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_interval range between + '-infinity'::interval following and + 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_interval RANGE BETWEEN '-infinity'::interval FO..." +== 189 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + '1 year'::interval preceding and '1 year'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamptz RANGE BETWEEN '1 year'::interval PR..." +== 190 +-- truncate_limit: 100 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz desc range between + '1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamptz DESC RANGE BETWEEN '1 year' PRECEDI..." +== 191 +-- truncate_limit: 100 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz desc range between + '1 year' preceding and '-1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamptz DESC RANGE BETWEEN '1 year' PRECEDI..." +== 192 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamptz RANGE BETWEEN 'infinity'::interval ..." +== 193 +-- truncate_limit: 100 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamptz RANGE BETWEEN 'infinity'::interval ..." +== 194 +-- truncate_limit: 100 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamptz RANGE BETWEEN 'infinity'::interval ..." +== 195 +-- truncate_limit: 100 +select id, f_timestamptz, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamptz range between + '-infinity'::interval following and + 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamptz RANGE BETWEEN '-infinity'::interval..." +== 196 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + '1 year'::interval preceding and '1 year'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamp RANGE BETWEEN '1 year'::interval PREC..." +== 197 +-- truncate_limit: 100 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp desc range between + '1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamp DESC RANGE BETWEEN '1 year' PRECEDING..." +== 198 +-- truncate_limit: 100 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp desc range between + '-1 year' preceding and '1 year' following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamp DESC RANGE BETWEEN '-1 year' PRECEDIN..." +== 199 +-- truncate_limit: 100 +-- error, negative offset disallowed + +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + 'infinity'::interval preceding and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamp RANGE BETWEEN 'infinity'::interval PR..." +== 200 +-- truncate_limit: 100 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + 'infinity'::interval preceding and 'infinity'::interval preceding) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamp RANGE BETWEEN 'infinity'::interval PR..." +== 201 +-- truncate_limit: 100 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + 'infinity'::interval following and 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamp RANGE BETWEEN 'infinity'::interval FO..." +== 202 +-- truncate_limit: 100 +select id, f_timestamp, first_value(id) over w, last_value(id) over w +from datetimes +window w as (order by f_timestamp range between + '-infinity'::interval following and + 'infinity'::interval following) +-- +TABLE: name="datetimes" schema="" table="datetimes" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM datetimes WINDOW w AS (ORDER BY f_timestamp RANGE BETWEEN '-infinity'::interval F..." +== 203 +-- truncate_limit: 100 +-- error, negative offset disallowed + +-- RANGE offset PRECEDING/FOLLOWING error cases +select sum(salary) over (order by enroll_date, salary range between '1 year'::interval preceding and '2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 204 +-- truncate_limit: 100 +select sum(salary) over (range between '1 year'::interval preceding and '2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 205 +-- truncate_limit: 100 +select sum(salary) over (order by depname range between '1 year'::interval preceding and '2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 206 +-- truncate_limit: 100 +select max(enroll_date) over (order by enroll_date range between 1 preceding and 2 following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 207 +-- truncate_limit: 100 +select max(enroll_date) over (order by salary range between -1 preceding and 2 following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 208 +-- truncate_limit: 100 +select max(enroll_date) over (order by salary range between 1 preceding and -2 following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 209 +-- truncate_limit: 100 +select max(enroll_date) over (order by salary range between '1 year'::interval preceding and '2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 210 +-- truncate_limit: 100 +select max(enroll_date) over (order by enroll_date range between '1 year'::interval preceding and '-2 years'::interval following + exclude ties), salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 211 +-- truncate_limit: 100 +-- GROUPS tests + +SELECT sum(unique1) over (order by four groups between unbounded preceding and current row), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 212 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between unbounded preceding and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 213 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between current row and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 214 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between 1 preceding and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 215 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between 1 following and unbounded following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 216 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between unbounded preceding and 2 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 217 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 preceding), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 218 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 219 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between 0 preceding and 0 following), + unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 220 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following + exclude current row), unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 221 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following + exclude group), unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 222 +-- truncate_limit: 100 +SELECT sum(unique1) over (order by four groups between 2 preceding and 1 following + exclude ties), unique1, four +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 223 +-- truncate_limit: 100 +SELECT sum(unique1) over (partition by ten + order by four groups between 0 preceding and 0 following),unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 224 +-- truncate_limit: 100 +SELECT sum(unique1) over (partition by ten + order by four groups between 0 preceding and 0 following exclude current row), unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 225 +-- truncate_limit: 100 +SELECT sum(unique1) over (partition by ten + order by four groups between 0 preceding and 0 following exclude group), unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 226 +-- truncate_limit: 100 +SELECT sum(unique1) over (partition by ten + order by four groups between 0 preceding and 0 following exclude ties), unique1, four, ten +FROM tenk1 WHERE unique1 < 10 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM tenk1 WHERE unique1 < 10" +== 227 +-- truncate_limit: 100 +select first_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), + lead(salary) over(order by enroll_date groups between 1 preceding and 1 following), + nth_value(salary, 1) over(order by enroll_date groups between 1 preceding and 1 following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 228 +-- truncate_limit: 100 +select last_value(salary) over(order by enroll_date groups between 1 preceding and 1 following), + lag(salary) over(order by enroll_date groups between 1 preceding and 1 following), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 229 +-- truncate_limit: 100 +select first_value(salary) over(order by enroll_date groups between 1 following and 3 following + exclude current row), + lead(salary) over(order by enroll_date groups between 1 following and 3 following exclude ties), + nth_value(salary, 1) over(order by enroll_date groups between 1 following and 3 following + exclude ties), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="first_value" function="first_value" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 230 +-- truncate_limit: 100 +select last_value(salary) over(order by enroll_date groups between 1 following and 3 following + exclude group), + lag(salary) over(order by enroll_date groups between 1 following and 3 following exclude group), + salary, enroll_date from empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="last_value" function="last_value" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 231 +-- truncate_limit: 100 +-- Show differences in offset interpretation between ROWS, RANGE, and GROUPS +WITH cte (x) AS ( + SELECT * FROM generate_series(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH cte(x) AS (...) SELECT ... FROM cte WINDOW w AS (ORDER BY x ROWS BETWEEN 1 PRECEDING AND 1 F..." +== 232 +-- truncate_limit: 100 +WITH cte (x) AS ( + SELECT * FROM generate_series(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH cte(x) AS (...) SELECT ... FROM cte WINDOW w AS (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 ..." +== 233 +-- truncate_limit: 100 +WITH cte (x) AS ( + SELECT * FROM generate_series(1, 35, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH cte(x) AS (...) SELECT ... FROM cte WINDOW w AS (ORDER BY x GROUPS BETWEEN 1 PRECEDING AND 1..." +== 234 +-- truncate_limit: 100 +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM generate_series(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x rows between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH cte(x) AS (...) SELECT ... FROM cte WINDOW w AS (ORDER BY x ROWS BETWEEN 1 PRECEDING AND 1 F..." +== 235 +-- truncate_limit: 100 +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM generate_series(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x range between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH cte(x) AS (...) SELECT ... FROM cte WINDOW w AS (ORDER BY x RANGE BETWEEN 1 PRECEDING AND 1 ..." +== 236 +-- truncate_limit: 100 +WITH cte (x) AS ( + select 1 union all select 1 union all select 1 union all + SELECT * FROM generate_series(5, 49, 2) +) +SELECT x, (sum(x) over w) +FROM cte +WINDOW w AS (ORDER BY x groups between 1 preceding and 1 following) +-- +CTE: "cte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH cte(x) AS (...) SELECT ... FROM cte WINDOW w AS (ORDER BY x GROUPS BETWEEN 1 PRECEDING AND 1..." +== 237 +-- truncate_limit: 100 +-- with UNION +SELECT count(*) OVER (PARTITION BY four) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2)s LIMIT 0 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk2" schema="" table="tenk2" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk2) s LIMIT 0" +== 238 +-- truncate_limit: 100 +-- check some degenerate cases +create temp table t1 (f1 int, f2 int8) +-- +TABLE: name="t1" schema="" table="t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE t1 (f1 int, f2 int8)" +== 239 +-- truncate_limit: 100 +insert into t1 values (1,1),(1,2),(2,2) +-- +TABLE: name="t1" schema="" table="t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO t1 VALUES (1, 1), (1, 2), (2, 2)" +== 240 +-- truncate_limit: 100 +select f1, sum(f1) over (partition by f1 + range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 WHERE f1 = f2" +== 241 +-- truncate_limit: 100 +-- error, must have order by +explain (costs off) +select f1, sum(f1) over (partition by f1 order by f2 + range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT f1, sum(f1) OVER (PARTITION BY f1 ORDER BY f2 RANGE BETWEEN 1 PRECEDIN..." +== 242 +-- truncate_limit: 100 +select f1, sum(f1) over (partition by f1 order by f2 + range between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 WHERE f1 = f2" +== 243 +-- truncate_limit: 100 +select f1, sum(f1) over (partition by f1, f1 order by f2 + range between 2 preceding and 1 preceding) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 WHERE f1 = f2" +== 244 +-- truncate_limit: 100 +select f1, sum(f1) over (partition by f1, f2 order by f2 + range between 1 following and 2 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 WHERE f1 = f2" +== 245 +-- truncate_limit: 100 +select f1, sum(f1) over (partition by f1 + groups between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 WHERE f1 = f2" +== 246 +-- truncate_limit: 100 +-- error, must have order by +explain (costs off) +select f1, sum(f1) over (partition by f1 order by f2 + groups between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT f1, sum(f1) OVER (PARTITION BY f1 ORDER BY f2 GROUPS BETWEEN 1 PRECEDI..." +== 247 +-- truncate_limit: 100 +select f1, sum(f1) over (partition by f1 order by f2 + groups between 1 preceding and 1 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 WHERE f1 = f2" +== 248 +-- truncate_limit: 100 +select f1, sum(f1) over (partition by f1, f1 order by f2 + groups between 2 preceding and 1 preceding) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 WHERE f1 = f2" +== 249 +-- truncate_limit: 100 +select f1, sum(f1) over (partition by f1, f2 order by f2 + groups between 1 following and 2 following) +from t1 where f1 = f2 +-- +TABLE: name="t1" schema="" table="t1" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="f1" +FILTER: schema="" table="" column="f2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM t1 WHERE f1 = f2" +== 250 +-- truncate_limit: 100 +-- ordering by a non-integer constant is allowed +SELECT rank() OVER (ORDER BY length('abc')) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank() OVER (ORDER BY length('abc'))" +== 251 +-- truncate_limit: 100 +-- can't order by another window function +SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random())) +-- +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank() OVER (ORDER BY rank() OVER (ORDER BY random()))" +== 252 +-- truncate_limit: 100 +-- some other errors +SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="salary" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM empsalary WHERE row_number() OVER (ORDER BY salary) < 10" +== 253 +-- truncate_limit: 100 +SELECT * FROM empsalary INNER JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM empsalary JOIN tenk1 ON row_number() OVER (ORDER BY salary) < 10" +== 254 +-- truncate_limit: 100 +SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1" +== 255 +-- truncate_limit: 100 +SELECT * FROM rank() OVER (ORDER BY random()) +-- +ERROR: syntax error at or near "ORDER" +CURSORPOS: 28 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 256 +-- truncate_limit: 100 +DELETE FROM empsalary WHERE (rank() OVER (ORDER BY random())) > 10 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DML +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM empsalary WHERE rank() OVER (ORDER BY random()) > 10" +== 257 +-- truncate_limit: 100 +DELETE FROM empsalary RETURNING rank() OVER (ORDER BY random()) +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DML +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: DeleteStmt +TRUNCATED: "DELETE FROM empsalary RETURNING rank() OVER (ORDER BY random())" +== 258 +-- truncate_limit: 100 +SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) OVER w FROM tenk1 WINDOW w AS (ORDER BY unique1), w AS (ORDER BY unique1)" +== 259 +-- truncate_limit: 100 +SELECT rank() OVER (PARTITION BY four, ORDER BY ten) FROM tenk1 +-- +ERROR: syntax error at or near "ORDER" +CURSORPOS: 40 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 260 +-- truncate_limit: 100 +SELECT count() OVER () FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count() OVER () FROM tenk1" +== 261 +-- truncate_limit: 100 +SELECT generate_series(1, 100) OVER () FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT generate_series(1, 100) OVER () FROM empsalary" +== 262 +-- truncate_limit: 100 +SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ntile(0) OVER (ORDER BY ten), ten, four FROM tenk1" +== 263 +-- truncate_limit: 100 +SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nth_value" function="nth_value" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT nth_value(four, 0) OVER (ORDER BY ten), ten, four FROM tenk1" +== 264 +-- truncate_limit: 100 +-- filter + +SELECT sum(salary), row_number() OVER (ORDER BY depname), sum( + sum(salary) FILTER (WHERE enroll_date > '2007-01-01') +) FILTER (WHERE depname <> 'sales') OVER (ORDER BY depname DESC) AS "filtered_sum", + depname +FROM empsalary GROUP BY depname +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary GROUP BY depname" +== 265 +-- truncate_limit: 100 +|-- +-- Test SupportRequestOptimizeWindowClause's ability to de-duplicate +-- WindowClauses +|-- + +-- Ensure WindowClause frameOptions are changed so that only a single +-- WindowAgg exists in the plan. +EXPLAIN (COSTS OFF) +SELECT + empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) rn, + rank() OVER (PARTITION BY depname ORDER BY enroll_date ROWS BETWEEN + UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) rnk, + dense_rank() OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND CURRENT ROW) drnk, + ntile(10) OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND UNBOUNDED FOLLOWING) nt, + percent_rank() OVER (PARTITION BY depname ORDER BY enroll_date ROWS BETWEEN + CURRENT ROW AND UNBOUNDED FOLLOWING) pr, + cume_dist() OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND UNBOUNDED FOLLOWING) cd +FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FUNCTION: name="percent_rank" function="percent_rank" schema="" ctx=Call +FUNCTION: name="cume_dist" function="cume_dist" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT empno, depname, row_number() OVER (PARTITION BY depname ORDER BY enrol..." +== 266 +-- truncate_limit: 100 +-- Ensure WindowFuncs which cannot support their WindowClause's frameOptions +-- being changed are untouched +EXPLAIN (COSTS OFF, VERBOSE) +SELECT + empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) rn, + rank() OVER (PARTITION BY depname ORDER BY enroll_date ROWS BETWEEN + UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) rnk, + count(*) OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND CURRENT ROW) cnt +FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT empno, depname, row_number() OVER (PARTITION BY depname ORDER..." +== 267 +-- truncate_limit: 100 +-- Ensure the above query gives us the expected results +SELECT + empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) rn, + rank() OVER (PARTITION BY depname ORDER BY enroll_date ROWS BETWEEN + UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) rnk, + count(*) OVER (PARTITION BY depname ORDER BY enroll_date RANGE BETWEEN + CURRENT ROW AND CURRENT ROW) cnt +FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM empsalary" +== 268 +-- truncate_limit: 100 +-- Test pushdown of quals into a subquery containing window functions + +-- pushdown is safe because all PARTITION BY clauses include depname: +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT depname, + sum(salary) OVER (PARTITION BY depname) depsalary, + min(salary) OVER (PARTITION BY depname || 'A', depname) depminsalary + FROM empsalary) emp +WHERE depname = 'sales' +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="depname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT depname, sum(salary) OVER (PARTITION BY depname) AS dep..." +== 269 +-- truncate_limit: 100 +-- pushdown is unsafe because there's a PARTITION BY clause without depname: +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT depname, + sum(salary) OVER (PARTITION BY enroll_date) enroll_salary, + min(salary) OVER (PARTITION BY depname) depminsalary + FROM empsalary) emp +WHERE depname = 'sales' +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="depname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT depname, sum(salary) OVER (PARTITION BY enroll_date) AS..." +== 270 +-- truncate_limit: 100 +-- Test window function run conditions are properly pushed down into the +-- WindowAgg +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + row_number() OVER (ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, row_number() OVER (ORDER BY empno) AS rn FROM em..." +== 271 +-- truncate_limit: 100 +-- The following 3 statements should result the same result. +SELECT * FROM + (SELECT empno, + row_number() OVER (ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE rn < 3" +== 272 +-- truncate_limit: 100 +SELECT * FROM + (SELECT empno, + row_number() OVER (ORDER BY empno) rn + FROM empsalary) emp +WHERE 3 > rn +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE 3 > rn" +== 273 +-- truncate_limit: 100 +SELECT * FROM + (SELECT empno, + row_number() OVER (ORDER BY empno) rn + FROM empsalary) emp +WHERE 2 >= rn +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE 2 >= rn" +== 274 +-- truncate_limit: 100 +-- Ensure r <= 3 is pushed down into the run condition of the window agg +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + rank() OVER (ORDER BY salary DESC) r + FROM empsalary) emp +WHERE r <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="r" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, rank() OVER (ORDER BY salary DESC) AS r ..." +== 275 +-- truncate_limit: 100 +SELECT * FROM + (SELECT empno, + salary, + rank() OVER (ORDER BY salary DESC) r + FROM empsalary) emp +WHERE r <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="rank" function="rank" schema="" ctx=Call +FILTER: schema="" table="" column="r" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE r <= 3" +== 276 +-- truncate_limit: 100 +-- Ensure dr = 1 is converted to dr <= 1 to get all rows leading up to dr = 1 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + dense_rank() OVER (ORDER BY salary DESC) dr + FROM empsalary) emp +WHERE dr = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FILTER: schema="" table="" column="dr" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, dense_rank() OVER (ORDER BY salary DESC)..." +== 277 +-- truncate_limit: 100 +SELECT * FROM + (SELECT empno, + salary, + dense_rank() OVER (ORDER BY salary DESC) dr + FROM empsalary) emp +WHERE dr = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FILTER: schema="" table="" column="dr" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE dr = 1" +== 278 +-- truncate_limit: 100 +-- Check COUNT() and COUNT(*) +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count(*) OVER (ORDER BY salary DESC) AS ..." +== 279 +-- truncate_limit: 100 +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE c <= 3" +== 280 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(empno) OVER (ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count(empno) OVER (ORDER BY salary DESC)..." +== 281 +-- truncate_limit: 100 +SELECT * FROM + (SELECT empno, + salary, + count(empno) OVER (ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE c <= 3" +== 282 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) c + FROM empsalary) emp +WHERE c >= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count(*) OVER (ORDER BY salary DESC ROWS..." +== 283 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER () c + FROM empsalary) emp +WHERE 11 <= c +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count(*) OVER () AS c FROM empsalary) em..." +== 284 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC) c, + dense_rank() OVER (ORDER BY salary DESC) dr + FROM empsalary) emp +WHERE dr = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="dense_rank" function="dense_rank" schema="" ctx=Call +FILTER: schema="" table="" column="dr" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count(*) OVER (ORDER BY salary DESC) AS ..." +== 285 +-- truncate_limit: 100 +-- Ensure we get a run condition when there's a PARTITION BY clause +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, depname, row_number() OVER (PARTITION BY depname..." +== 286 +-- truncate_limit: 100 +-- and ensure we get the correct results from the above plan +SELECT * FROM + (SELECT empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE rn < 3" +== 287 +-- truncate_limit: 100 +-- ensure that "unused" subquery columns are not removed when the column only +-- exists in the run condition +EXPLAIN (COSTS OFF) +SELECT empno, depname FROM + (SELECT empno, + depname, + row_number() OVER (PARTITION BY depname ORDER BY empno) rn + FROM empsalary) emp +WHERE rn < 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT empno, depname FROM (SELECT empno, depname, row_number() OVER (PARTITI..." +== 288 +-- truncate_limit: 100 +-- likewise with count(empno) instead of row_number() +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + depname, + salary, + count(empno) OVER (PARTITION BY depname ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, depname, salary, count(empno) OVER (PARTITION BY..." +== 289 +-- truncate_limit: 100 +-- and again, check the results are what we expect. +SELECT * FROM + (SELECT empno, + depname, + salary, + count(empno) OVER (PARTITION BY depname ORDER BY salary DESC) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE c <= 3" +== 290 +-- truncate_limit: 100 +-- Ensure we get the correct run condition when the window function is both +-- monotonically increasing and decreasing. +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + depname, + salary, + count(empno) OVER () c + FROM empsalary) emp +WHERE c = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, depname, salary, count(empno) OVER () AS c FROM ..." +== 291 +-- truncate_limit: 100 +-- Try another case with a WindowFunc with a byref return type +SELECT * FROM + (SELECT row_number() OVER (PARTITION BY salary) AS rn, + lead(depname) OVER (PARTITION BY salary) || ' Department' AS n_dep + FROM empsalary) emp +WHERE rn < 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE rn < 1" +== 292 +-- truncate_limit: 100 +-- Some more complex cases with multiple window clauses +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT *, + count(salary) OVER (PARTITION BY depname || '') c1, -- w1 + row_number() OVER (PARTITION BY depname) rn, -- w2 + count(*) OVER (PARTITION BY depname) c2, -- w2 + count(*) OVER (PARTITION BY '' || depname) c3, -- w3 + ntile(2) OVER (PARTITION BY depname) nt -- w2 + FROM empsalary +) e WHERE rn <= 1 AND c1 <= 3 AND nt < 2 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="nt" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT *, count(salary) OVER (PARTITION BY depname || '') AS c..." +== 293 +-- truncate_limit: 100 +-- Ensure we correctly filter out all of the run conditions from each window +SELECT * FROM + (SELECT *, + count(salary) OVER (PARTITION BY depname || '') c1, -- w1 + row_number() OVER (PARTITION BY depname) rn, -- w2 + count(*) OVER (PARTITION BY depname) c2, -- w2 + count(*) OVER (PARTITION BY '' || depname) c3, -- w3 + ntile(2) OVER (PARTITION BY depname) nt -- w2 + FROM empsalary +) e WHERE rn <= 1 AND c1 <= 3 AND nt < 2 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="" column="rn" +FILTER: schema="" table="" column="c1" +FILTER: schema="" table="" column="nt" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) e WHERE rn <= 1 AND c1 <= 3 AND nt < 2" +== 294 +-- truncate_limit: 100 +-- Ensure we remove references to reduced outer joins as nulling rels in run +-- conditions +EXPLAIN (COSTS OFF) +SELECT 1 FROM + (SELECT ntile(e2.salary) OVER (PARTITION BY e1.depname) AS c + FROM empsalary e1 LEFT JOIN empsalary e2 ON TRUE + WHERE e1.empno = e2.empno) s +WHERE s.c = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +ALIAS: "e1"="empsalary" +ALIAS: "e2"="empsalary" +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="s" column="c" +FILTER: schema="" table="e1" column="empno" +FILTER: schema="" table="e2" column="empno" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM (SELECT ntile(e2.salary) OVER (PARTITION BY e1.depname) AS c FR..." +== 295 +-- truncate_limit: 100 +-- Ensure the run condition optimization is used in cases where the WindowFunc +-- has a Var from another query level +EXPLAIN (COSTS OFF) +SELECT 1 FROM + (SELECT ntile(s1.x) OVER () AS c + FROM (SELECT (SELECT 1) AS x) AS s1) s +WHERE s.c = 1 +-- +FUNCTION: name="ntile" function="ntile" schema="" ctx=Call +FILTER: schema="" table="s" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT 1 FROM (SELECT ntile(s1.x) OVER () AS c FROM (SELECT (SELECT 1) AS x) ..." +== 296 +-- truncate_limit: 100 +-- Tests to ensure we don't push down the run condition when it's not valid to +-- do so. + +-- Ensure we don't push down when the frame options show that the window +-- function is not monotonically increasing +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary DESC ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) c + FROM empsalary) emp +WHERE c <= 3 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count(*) OVER (ORDER BY salary DESC ROWS..." +== 297 +-- truncate_limit: 100 +-- Ensure we don't push down when the window function's monotonic properties +-- don't match that of the clauses. +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(*) OVER (ORDER BY salary) c + FROM empsalary) emp +WHERE 3 <= c +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count(*) OVER (ORDER BY salary) AS c FRO..." +== 298 +-- truncate_limit: 100 +-- Ensure we don't use a run condition when there's a volatile function in the +-- WindowFunc +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count(random()) OVER (ORDER BY empno DESC) c + FROM empsalary) emp +WHERE c = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count(random()) OVER (ORDER BY empno DES..." +== 299 +-- truncate_limit: 100 +-- Ensure we don't use a run condition when the WindowFunc contains subplans +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT empno, + salary, + count((SELECT 1)) OVER (ORDER BY empno DESC) c + FROM empsalary) emp +WHERE c = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="c" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT empno, salary, count((SELECT 1)) OVER (ORDER BY empno D..." +== 300 +-- truncate_limit: 100 +-- Test Sort node collapsing +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname, empno order by enroll_date) depminsalary + FROM empsalary) emp +WHERE depname = 'sales' +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="" column="depname" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT depname, sum(salary) OVER (PARTITION BY depname ORDER B..." +== 301 +-- truncate_limit: 100 +-- Ensure that the evaluation order of the WindowAggs results in the WindowAgg +-- with the same sort order that's required by the ORDER BY is evaluated last. +EXPLAIN (COSTS OFF) +SELECT empno, + enroll_date, + depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname order by enroll_date) depminsalary +FROM empsalary +ORDER BY depname, empno +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT empno, enroll_date, depname, sum(salary) OVER (PARTITION BY depname OR..." +== 302 +-- truncate_limit: 100 +-- As above, but with an adjusted ORDER BY to ensure the above plan didn't +-- perform only 2 sorts by accident. +EXPLAIN (COSTS OFF) +SELECT empno, + enroll_date, + depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname order by enroll_date) depminsalary +FROM empsalary +ORDER BY depname, enroll_date +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT empno, enroll_date, depname, sum(salary) OVER (PARTITION BY depname OR..." +== 303 +-- truncate_limit: 100 +SET enable_hashagg TO off +-- +STMT: VariableSetStmt +TRUNCATED: "SET enable_hashagg TO OFF" +== 304 +-- truncate_limit: 100 +-- Ensure we don't get a sort for both DISTINCT and ORDER BY. We expect the +-- sort for the DISTINCT to provide presorted input for the ORDER BY. +EXPLAIN (COSTS OFF) +SELECT DISTINCT + empno, + enroll_date, + depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname order by enroll_date) depminsalary +FROM empsalary +ORDER BY depname, enroll_date +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT empno, enroll_date, depname, sum(salary) OVER (PARTITION BY d..." +== 305 +-- truncate_limit: 100 +-- As above but adjust the ORDER BY clause to help ensure the plan with the +-- minimum amount of sorting wasn't a fluke. +EXPLAIN (COSTS OFF) +SELECT DISTINCT + empno, + enroll_date, + depname, + sum(salary) OVER (PARTITION BY depname order by empno) depsalary, + min(salary) OVER (PARTITION BY depname order by enroll_date) depminsalary +FROM empsalary +ORDER BY depname, empno +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="min" function="min" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT DISTINCT empno, enroll_date, depname, sum(salary) OVER (PARTITION BY d..." +== 306 +-- truncate_limit: 100 +RESET enable_hashagg +-- +STMT: VariableSetStmt +TRUNCATED: "RESET enable_hashagg" +== 307 +-- truncate_limit: 100 +-- Test Sort node reordering +EXPLAIN (COSTS OFF) +SELECT + lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), + lag(1) OVER (PARTITION BY depname ORDER BY salary,enroll_date,empno) +FROM empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="lead" function="lead" schema="" ctx=Call +FUNCTION: name="lag" function="lag" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT lead(1) OVER (PARTITION BY depname ORDER BY salary, enroll_date), lag(..." +== 308 +-- truncate_limit: 100 +-- Test incremental sorting +EXPLAIN (COSTS OFF) +SELECT * FROM + (SELECT depname, + empno, + salary, + enroll_date, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) AS first_emp, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date DESC) AS last_emp + FROM empsalary) emp +WHERE first_emp = 1 OR last_emp = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="first_emp" +FILTER: schema="" table="" column="last_emp" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM (SELECT depname, empno, salary, enroll_date, row_number() OVER ..." +== 309 +-- truncate_limit: 100 +SELECT * FROM + (SELECT depname, + empno, + salary, + enroll_date, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date) AS first_emp, + row_number() OVER (PARTITION BY depname ORDER BY enroll_date DESC) AS last_emp + FROM empsalary) emp +WHERE first_emp = 1 OR last_emp = 1 +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=Select +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="" column="first_emp" +FILTER: schema="" table="" column="last_emp" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM (SELECT ... FROM empsalary) emp WHERE first_emp = 1 OR last_emp = 1" +== 310 +-- truncate_limit: 100 +-- cleanup +DROP TABLE empsalary +-- +TABLE: name="empsalary" schema="" table="empsalary" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE empsalary" +== 311 +-- truncate_limit: 100 +-- test user-defined window function with named args and default args +CREATE FUNCTION nth_value_def(val anyelement, n integer = 1) RETURNS anyelement + LANGUAGE internal WINDOW IMMUTABLE STRICT AS 'window_nth_value' +-- +FUNCTION: name="nth_value_def" function="nth_value_def" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION nth_value_def(val anyelement, n int = 1) RETURNS anyelement LANGUAGE internal WIN..." +== 312 +-- truncate_limit: 100 +SELECT nth_value_def(n := 2, val := ten) OVER (PARTITION BY four), ten, four + FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten) s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nth_value_def" function="nth_value_def" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM tenk1 WHERE ... ORDER BY four, ten) s" +== 313 +-- truncate_limit: 100 +SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four + FROM (SELECT * FROM tenk1 WHERE unique2 < 10 ORDER BY four, ten) s +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="nth_value_def" function="nth_value_def" schema="" ctx=Call +FILTER: schema="" table="" column="unique2" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT * FROM tenk1 WHERE ... ORDER BY four, ten) s" +== 314 +-- truncate_limit: 100 +|-- +-- Test the basic moving-aggregate machinery +|-- + +-- create aggregates that record the series of transform calls (these are +-- intentionally not true inverses) + +CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS +$$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$ +LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="logging_sfunc_nonstrict" function="logging_sfunc_nonstrict" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS $$ SELECT COALESCE($1, ..." +== 315 +-- truncate_limit: 100 +CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS +$$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$ +LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="logging_msfunc_nonstrict" function="logging_msfunc_nonstrict" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS $$ SELECT COALESCE($1,..." +== 316 +-- truncate_limit: 100 +CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS +$$ SELECT $1 || '-' || quote_nullable($2) $$ +LANGUAGE SQL IMMUTABLE +-- +FUNCTION: name="logging_minvfunc_nonstrict" function="logging_minvfunc_nonstrict" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS $$ SELECT $1 || '-' ..." +== 317 +-- truncate_limit: 100 +CREATE AGGREGATE logging_agg_nonstrict (anyelement) +( + stype = text, + sfunc = logging_sfunc_nonstrict, + mstype = text, + msfunc = logging_msfunc_nonstrict, + minvfunc = logging_minvfunc_nonstrict +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE logging_agg_nonstrict (anyelement) (stype = text, sfunc = logging_sfunc_nonstric..." +== 318 +-- truncate_limit: 100 +CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement) +( + stype = text, + sfunc = logging_sfunc_nonstrict, + mstype = text, + msfunc = logging_msfunc_nonstrict, + minvfunc = logging_minvfunc_nonstrict, + initcond = 'I', + minitcond = 'MI' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement) (stype = text, sfunc = logging_sfunc..." +== 319 +-- truncate_limit: 100 +CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS +$$ SELECT $1 || '*' || quote_nullable($2) $$ +LANGUAGE SQL STRICT IMMUTABLE +-- +FUNCTION: name="logging_sfunc_strict" function="logging_sfunc_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS $$ SELECT $1 || '*' || quo..." +== 320 +-- truncate_limit: 100 +CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS +$$ SELECT $1 || '+' || quote_nullable($2) $$ +LANGUAGE SQL STRICT IMMUTABLE +-- +FUNCTION: name="logging_msfunc_strict" function="logging_msfunc_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS $$ SELECT $1 || '+' || qu..." +== 321 +-- truncate_limit: 100 +CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS +$$ SELECT $1 || '-' || quote_nullable($2) $$ +LANGUAGE SQL STRICT IMMUTABLE +-- +FUNCTION: name="logging_minvfunc_strict" function="logging_minvfunc_strict" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS $$ SELECT $1 || '-' || ..." +== 322 +-- truncate_limit: 100 +CREATE AGGREGATE logging_agg_strict (text) +( + stype = text, + sfunc = logging_sfunc_strict, + mstype = text, + msfunc = logging_msfunc_strict, + minvfunc = logging_minvfunc_strict +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE logging_agg_strict (text) (stype = text, sfunc = logging_sfunc_strict, mstype = ..." +== 323 +-- truncate_limit: 100 +CREATE AGGREGATE logging_agg_strict_initcond (anyelement) +( + stype = text, + sfunc = logging_sfunc_strict, + mstype = text, + msfunc = logging_msfunc_strict, + minvfunc = logging_minvfunc_strict, + initcond = 'I', + minitcond = 'MI' +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE logging_agg_strict_initcond (anyelement) (stype = text, sfunc = logging_sfunc_st..." +== 324 +-- truncate_limit: 100 +-- test strict and non-strict cases +SELECT + p::text || ',' || i::text || ':' || COALESCE(v::text, 'NULL') AS row, + logging_agg_nonstrict(v) over wnd as nstrict, + logging_agg_nonstrict_initcond(v) over wnd as nstrict_init, + logging_agg_strict(v::text) over wnd as strict, + logging_agg_strict_initcond(v) over wnd as strict_init +FROM (VALUES + (1, 1, NULL), + (1, 2, 'a'), + (1, 3, 'b'), + (1, 4, NULL), + (1, 5, NULL), + (1, 6, 'c'), + (2, 1, NULL), + (2, 2, 'x'), + (3, 1, 'z') +) AS t(p, i, v) +WINDOW wnd AS (PARTITION BY P ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +ORDER BY p, i +-- +FUNCTION: name="logging_agg_nonstrict" function="logging_agg_nonstrict" schema="" ctx=Call +FUNCTION: name="logging_agg_nonstrict_initcond" function="logging_agg_nonstrict_initcond" schema="" ctx=Call +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="logging_agg_strict_initcond" function="logging_agg_strict_initcond" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(p, i, v) WINDOW wnd AS (PARTITION BY p ORDER BY i ROWS BETWEEN 1..." +== 325 +-- truncate_limit: 100 +-- and again, but with filter +SELECT + p::text || ',' || i::text || ':' || + CASE WHEN f THEN COALESCE(v::text, 'NULL') ELSE '-' END as row, + logging_agg_nonstrict(v) filter(where f) over wnd as nstrict_filt, + logging_agg_nonstrict_initcond(v) filter(where f) over wnd as nstrict_init_filt, + logging_agg_strict(v::text) filter(where f) over wnd as strict_filt, + logging_agg_strict_initcond(v) filter(where f) over wnd as strict_init_filt +FROM (VALUES + (1, 1, true, NULL), + (1, 2, false, 'a'), + (1, 3, true, 'b'), + (1, 4, false, NULL), + (1, 5, false, NULL), + (1, 6, false, 'c'), + (2, 1, false, NULL), + (2, 2, true, 'x'), + (3, 1, true, 'z') +) AS t(p, i, f, v) +WINDOW wnd AS (PARTITION BY p ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +ORDER BY p, i +-- +FUNCTION: name="logging_agg_nonstrict" function="logging_agg_nonstrict" schema="" ctx=Call +FUNCTION: name="logging_agg_nonstrict_initcond" function="logging_agg_nonstrict_initcond" schema="" ctx=Call +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="logging_agg_strict_initcond" function="logging_agg_strict_initcond" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(p, i, f, v) WINDOW wnd AS (PARTITION BY p ORDER BY i ROWS BETWEE..." +== 326 +-- truncate_limit: 100 +-- test that volatile arguments disable moving-aggregate mode +SELECT + i::text || ':' || COALESCE(v::text, 'NULL') as row, + logging_agg_strict(v::text) + over wnd as inverse, + logging_agg_strict(v::text || CASE WHEN random() < 0 then '?' ELSE '' END) + over wnd as noinverse +FROM (VALUES + (1, 'a'), + (2, 'b'), + (3, 'c') +) AS t(i, v) +WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +ORDER BY i +-- +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v) WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CUR..." +== 327 +-- truncate_limit: 100 +SELECT + i::text || ':' || COALESCE(v::text, 'NULL') as row, + logging_agg_strict(v::text) filter(where true) + over wnd as inverse, + logging_agg_strict(v::text) filter(where random() >= 0) + over wnd as noinverse +FROM (VALUES + (1, 'a'), + (2, 'b'), + (3, 'c') +) AS t(i, v) +WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +ORDER BY i +-- +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v) WINDOW wnd AS (ORDER BY i ROWS BETWEEN 1 PRECEDING AND CUR..." +== 328 +-- truncate_limit: 100 +-- test that non-overlapping windows don't use inverse transitions +SELECT + logging_agg_strict(v::text) OVER wnd +FROM (VALUES + (1, 'a'), + (2, 'b'), + (3, 'c') +) AS t(i, v) +WINDOW wnd AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) +ORDER BY i +-- +FUNCTION: name="logging_agg_strict" function="logging_agg_strict" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v) WINDOW wnd AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND CUR..." +== 329 +-- truncate_limit: 100 +-- test that returning NULL from the inverse transition functions +-- restarts the aggregation from scratch. The second aggregate is supposed +-- to test cases where only some aggregates restart, the third one checks +-- that one aggregate restarting doesn't cause others to restart. + +CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS +$$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$ +LANGUAGE SQL STRICT +-- +FUNCTION: name="sum_int_randrestart_minvfunc" function="sum_int_randrestart_minvfunc" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS $$ SELECT CASE WHEN rand..." +== 330 +-- truncate_limit: 100 +CREATE AGGREGATE sum_int_randomrestart (int4) +( + stype = int4, + sfunc = int4pl, + mstype = int4, + msfunc = int4pl, + minvfunc = sum_int_randrestart_minvfunc +) +-- +STMT: DefineStmt +TRUNCATED: "CREATE AGGREGATE sum_int_randomrestart (int4) (stype = int4, sfunc = int4pl, mstype = int4, msfun..." +== 331 +-- truncate_limit: 100 +WITH +vs AS ( + SELECT i, (random() * 100)::int4 AS v + FROM generate_series(1, 100) AS i +), +sum_following AS ( + SELECT i, SUM(v) OVER + (ORDER BY i DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS s + FROM vs +) +SELECT DISTINCT + sum_following.s = sum_int_randomrestart(v) OVER fwd AS eq1, + -sum_following.s = sum_int_randomrestart(-v) OVER fwd AS eq2, + 100*3+(vs.i-1)*3 = length(logging_agg_nonstrict(''::text) OVER fwd) AS eq3 +FROM vs +JOIN sum_following ON sum_following.i = vs.i +WINDOW fwd AS ( + ORDER BY vs.i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING +) +-- +CTE: "vs" +CTE: "sum_following" +FUNCTION: name="sum_int_randomrestart" function="sum_int_randomrestart" schema="" ctx=Call +FUNCTION: name="sum_int_randomrestart" function="sum_int_randomrestart" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="logging_agg_nonstrict" function="logging_agg_nonstrict" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH vs AS (...), sum_following AS (...) SELECT DISTINCT ... AS ... FROM vs JOIN sum_following ON..." +== 332 +-- truncate_limit: 100 +|-- +-- Test various built-in aggregates that have moving-aggregate support +|-- + +-- test inverse transition functions handle NULLs properly +SELECT i,AVG(v::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 333 +-- truncate_limit: 100 +SELECT i,AVG(v::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 334 +-- truncate_limit: 100 +SELECT i,AVG(v::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 335 +-- truncate_limit: 100 +SELECT i,AVG(v::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.5),(2,2.5),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 336 +-- truncate_limit: 100 +SELECT i,AVG(v::interval) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 337 +-- truncate_limit: 100 +-- moving aggregates over infinite intervals +SELECT x + ,avg(x) OVER(ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING ) as curr_next_avg + ,avg(x) OVER(ROWS BETWEEN 1 PRECEDING AND CURRENT ROW ) as prev_curr_avg + ,sum(x) OVER(ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING ) as curr_next_sum + ,sum(x) OVER(ROWS BETWEEN 1 PRECEDING AND CURRENT ROW ) as prev_curr_sum +FROM (VALUES (NULL::interval), + ('infinity'::interval), + ('-2147483648 days -2147483648 months -9223372036854775807 usecs'), -- extreme interval value + ('-infinity'::interval), + ('2147483647 days 2147483647 months 9223372036854775806 usecs'), -- extreme interval value + ('infinity'::interval), + ('6 days'::interval), + ('7 days'::interval), + (NULL::interval), + ('-infinity'::interval)) v(x) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(x)" +== 338 +-- truncate_limit: 100 +--should fail. +SELECT x, avg(x) OVER(ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) +FROM (VALUES (NULL::interval), + ('3 days'::interval), + ('infinity'::timestamptz - now()), + ('6 days'::interval), + ('-infinity'::interval)) v(x) +-- +FUNCTION: name="avg" function="avg" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, avg(x) OVER (ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) FROM (VALUES (...)) v(x)" +== 339 +-- truncate_limit: 100 +--should fail. +SELECT x, sum(x) OVER(ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) +FROM (VALUES (NULL::interval), + ('3 days'::interval), + ('infinity'::timestamptz - now()), + ('6 days'::interval), + ('-infinity'::interval)) v(x) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="now" function="now" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT x, sum(x) OVER (ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) FROM (VALUES (...)) v(x)" +== 340 +-- truncate_limit: 100 +SELECT i,SUM(v::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 341 +-- truncate_limit: 100 +SELECT i,SUM(v::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 342 +-- truncate_limit: 100 +SELECT i,SUM(v::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 343 +-- truncate_limit: 100 +SELECT i,SUM(v::money) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1.10'),(2,'2.20'),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 344 +-- truncate_limit: 100 +SELECT i,SUM(v::interval) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,'1 sec'),(2,'2 sec'),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 345 +-- truncate_limit: 100 +SELECT i,SUM(v::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.1),(2,2.2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 346 +-- truncate_limit: 100 +SELECT SUM(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1.01),(2,2),(3,3)) v(i,n) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(i, n)" +== 347 +-- truncate_limit: 100 +SELECT i,COUNT(v) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 348 +-- truncate_limit: 100 +SELECT i,COUNT(*) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 349 +-- truncate_limit: 100 +SELECT VAR_POP(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 350 +-- truncate_limit: 100 +SELECT VAR_POP(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 351 +-- truncate_limit: 100 +SELECT VAR_POP(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 352 +-- truncate_limit: 100 +SELECT VAR_POP(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_pop" function="var_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 353 +-- truncate_limit: 100 +SELECT VAR_SAMP(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 354 +-- truncate_limit: 100 +SELECT VAR_SAMP(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 355 +-- truncate_limit: 100 +SELECT VAR_SAMP(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 356 +-- truncate_limit: 100 +SELECT VAR_SAMP(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="var_samp" function="var_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 357 +-- truncate_limit: 100 +SELECT VARIANCE(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 358 +-- truncate_limit: 100 +SELECT VARIANCE(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 359 +-- truncate_limit: 100 +SELECT VARIANCE(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 360 +-- truncate_limit: 100 +SELECT VARIANCE(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="variance" function="variance" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 361 +-- truncate_limit: 100 +SELECT STDDEV_POP(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 362 +-- truncate_limit: 100 +SELECT STDDEV_POP(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 363 +-- truncate_limit: 100 +SELECT STDDEV_POP(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 364 +-- truncate_limit: 100 +SELECT STDDEV_POP(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_pop" function="stddev_pop" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 365 +-- truncate_limit: 100 +SELECT STDDEV_SAMP(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 366 +-- truncate_limit: 100 +SELECT STDDEV_SAMP(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 367 +-- truncate_limit: 100 +SELECT STDDEV_SAMP(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 368 +-- truncate_limit: 100 +SELECT STDDEV_SAMP(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(1,NULL),(2,600),(3,470),(4,170),(5,430),(6,300)) r(i,n) +-- +FUNCTION: name="stddev_samp" function="stddev_samp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 369 +-- truncate_limit: 100 +SELECT STDDEV(n::bigint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 370 +-- truncate_limit: 100 +SELECT STDDEV(n::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 371 +-- truncate_limit: 100 +SELECT STDDEV(n::smallint) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 372 +-- truncate_limit: 100 +SELECT STDDEV(n::numeric) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) + FROM (VALUES(0,NULL),(1,600),(2,470),(3,170),(4,430),(5,300)) r(i,n) +-- +FUNCTION: name="stddev" function="stddev" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) r(i, n)" +== 373 +-- truncate_limit: 100 +-- test that inverse transition functions work with various frame options +SELECT i,SUM(v::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND CURRENT ROW) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 374 +-- truncate_limit: 100 +SELECT i,SUM(v::int) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,NULL),(4,NULL)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 375 +-- truncate_limit: 100 +SELECT i,SUM(v::int) OVER (ORDER BY i ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) + FROM (VALUES(1,1),(2,2),(3,3),(4,4)) t(i,v) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(i, v)" +== 376 +-- truncate_limit: 100 +-- ensure aggregate over numeric properly recovers from NaN values +SELECT a, b, + SUM(b) OVER(ORDER BY A ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) +FROM (VALUES(1,1::numeric),(2,2),(3,'NaN'),(4,3),(5,4)) t(a,b) +-- +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) t(a, b)" +== 377 +-- truncate_limit: 100 +-- It might be tempting for someone to add an inverse trans function for +-- float and double precision. This should not be done as it can give incorrect +-- results. This test should fail if anyone ever does this without thinking too +-- hard about it. +SELECT to_char(SUM(n::float8) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING),'999999999999999999999D9') + FROM (VALUES(1,1e20),(2,1)) n(i,n) +-- +FUNCTION: name="to_char" function="to_char" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) n(i, n)" +== 378 +-- truncate_limit: 100 +SELECT i, b, bool_and(b) OVER w, bool_or(b) OVER w + FROM (VALUES (1,true), (2,true), (3,false), (4,false), (5,true)) v(i,b) + WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) +-- +FUNCTION: name="bool_and" function="bool_and" schema="" ctx=Call +FUNCTION: name="bool_or" function="bool_or" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (VALUES (...)) v(i, b) WINDOW w AS (ORDER BY i ROWS BETWEEN CURRENT ROW AND 1 FOL..." +== 379 +-- truncate_limit: 100 +|-- +-- Test WindowAgg costing takes into account the number of rows that need to +-- be fetched before the first row can be output. +|-- + +-- Ensure we get a cheap start up plan as the WindowAgg can output the first +-- row after reading 1 row from the join. +EXPLAIN (COSTS OFF) +SELECT COUNT(*) OVER (ORDER BY t1.unique1) +FROM tenk1 t1 INNER JOIN tenk1 t2 ON t1.unique1 = t2.tenthous +LIMIT 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) OVER (ORDER BY t1.unique1) FROM tenk1 t1 JOIN tenk1 t2 ON t1...." +== 380 +-- truncate_limit: 100 +-- Ensure we get a cheap total plan. Lack of ORDER BY in the WindowClause +-- means that all rows must be read from the join, so a cheap startup plan +-- isn't a good choice. +EXPLAIN (COSTS OFF) +SELECT COUNT(*) OVER () +FROM tenk1 t1 INNER JOIN tenk1 t2 ON t1.unique1 = t2.tenthous +WHERE t2.two = 1 +LIMIT 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="t2" column="two" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) OVER () FROM tenk1 t1 JOIN tenk1 t2 ON t1.unique1 = t2.tentho..." +== 381 +-- truncate_limit: 100 +-- Ensure we get a cheap total plan. This time use UNBOUNDED FOLLOWING, which +-- needs to read all join rows to output the first WindowAgg row. +EXPLAIN (COSTS OFF) +SELECT COUNT(*) OVER (ORDER BY t1.unique1 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) +FROM tenk1 t1 INNER JOIN tenk1 t2 ON t1.unique1 = t2.tenthous +LIMIT 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) OVER (ORDER BY t1.unique1 ROWS BETWEEN UNBOUNDED PRECEDING AN..." +== 382 +-- truncate_limit: 100 +-- Ensure we get a cheap total plan. This time use 10000 FOLLOWING so we need +-- to read all join rows. +EXPLAIN (COSTS OFF) +SELECT COUNT(*) OVER (ORDER BY t1.unique1 ROWS BETWEEN UNBOUNDED PRECEDING AND 10000 FOLLOWING) +FROM tenk1 t1 INNER JOIN tenk1 t2 ON t1.unique1 = t2.tenthous +LIMIT 1 +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "t1"="tenk1" +ALIAS: "t2"="tenk1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT count(*) OVER (ORDER BY t1.unique1 ROWS BETWEEN UNBOUNDED PRECEDING AN..." +== 383 +-- truncate_limit: 100 +-- Tests for problems with failure to walk or mutate expressions +-- within window frame clauses. + +-- test walker (fails with collation error if expressions are not walked) +SELECT array_agg(i) OVER w + FROM generate_series(1,5) i +WINDOW w AS (ORDER BY i ROWS BETWEEN (('foo' < 'foobar')::integer) PRECEDING AND CURRENT ROW) +-- +FUNCTION: name="array_agg" function="array_agg" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM generate_series(1, 5) i WINDOW w AS (ORDER BY i ROWS BETWEEN ('foo' < 'foobar')::..." +== 384 +-- truncate_limit: 100 +-- test mutator (fails when inlined if expressions are not mutated) +CREATE FUNCTION pg_temp.f(group_size BIGINT) RETURNS SETOF integer[] +AS $$ + SELECT array_agg(s) OVER w + FROM generate_series(1,5) s + WINDOW w AS (ORDER BY s ROWS BETWEEN CURRENT ROW AND GROUP_SIZE FOLLOWING) +$$ LANGUAGE SQL STABLE +-- +FUNCTION: name="pg_temp.f" function="f" schema="pg_temp" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION pg_temp.f(group_size bigint) RETURNS SETOF int[] AS $$\n SELECT array_agg(s) OV..." +== 385 +-- truncate_limit: 100 +EXPLAIN (costs off) SELECT * FROM pg_temp.f(2) +-- +FUNCTION: name="pg_temp.f" function="f" schema="pg_temp" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM pg_temp.f(2)" +== 386 +-- truncate_limit: 100 +SELECT * FROM pg_temp.f(2) +-- +FUNCTION: name="pg_temp.f" function="f" schema="pg_temp" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_temp.f(2)" diff --git a/parser/testdata/summary_truncate/postgres_regress/with.metadata.json b/parser/testdata/summary_truncate/postgres_regress/with.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/with.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/with.test b/parser/testdata/summary_truncate/postgres_regress/with.test new file mode 100644 index 0000000..262aac7 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/with.test @@ -0,0 +1,3894 @@ +== 001 +-- truncate_limit: 100 +|-- +-- Tests for common table expressions (WITH query, ... SELECT ...) +|-- + +-- Basic WITH +WITH q1(x,y) AS (SELECT 1,2) +SELECT * FROM q1, q1 AS q2 +-- +ALIAS: "q2"="q1" +CTE: "q1" +STMT: SelectStmt +TRUNCATED: "WITH q1(x, y) AS (SELECT 1, 2) SELECT * FROM q1, q1 q2" +== 002 +-- truncate_limit: 100 +-- Multiple uses are evaluated only once +SELECT count(*) FROM ( + WITH q1(x) AS (SELECT random() FROM generate_series(1, 5)) + SELECT * FROM q1 + UNION + SELECT * FROM q1 +) ss +-- +CTE: "q1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="random" function="random" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (WITH q1(x) AS (...) SELECT * FROM q1 UNION SELECT * FROM q1) ss" +== 003 +-- truncate_limit: 100 +-- WITH RECURSIVE + +-- sum of 1..100 +WITH RECURSIVE t(n) AS ( + VALUES (1) +UNION ALL + SELECT n+1 FROM t WHERE n < 100 +) +SELECT sum(n) FROM t +-- +CTE: "t" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(n) AS (VALUES (1) UNION ALL SELECT n + 1 FROM t WHERE n < 100) SELECT sum(n) FROM t" +== 004 +-- truncate_limit: 100 +WITH RECURSIVE t(n) AS ( + SELECT (VALUES(1)) +UNION ALL + SELECT n+1 FROM t WHERE n < 5 +) +SELECT * FROM t +-- +CTE: "t" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(n) AS (SELECT ... UNION ALL SELECT n + 1 FROM t WHERE n < 5) SELECT * FROM t" +== 005 +-- truncate_limit: 100 +-- UNION DISTINCT requires hashable type +WITH RECURSIVE t(n) AS ( + VALUES ('01'::varbit) +UNION + SELECT n || '10'::varbit FROM t WHERE n < '100'::varbit +) +SELECT n FROM t +-- +CTE: "t" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(n) AS (VALUES ('01'::varbit) UNION SELECT ... FROM t WHERE ...) SELECT n FROM t" +== 006 +-- truncate_limit: 100 +-- recursive view +CREATE RECURSIVE VIEW nums (n) AS + VALUES (1) +UNION ALL + SELECT n+1 FROM nums WHERE n < 5 +-- +CTE: "nums" +FILTER: schema="" table="" column="n" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW nums (n) AS WITH RECURSIVE nums(n) AS (VALUES (1) UNION ALL SELECT n + 1 FROM nums WH..." +== 007 +-- truncate_limit: 100 +SELECT * FROM nums +-- +TABLE: name="nums" schema="" table="nums" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nums" +== 008 +-- truncate_limit: 100 +CREATE OR REPLACE RECURSIVE VIEW nums (n) AS + VALUES (1) +UNION ALL + SELECT n+1 FROM nums WHERE n < 6 +-- +CTE: "nums" +FILTER: schema="" table="" column="n" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE OR REPLACE VIEW nums (n) AS WITH RECURSIVE nums(n) AS (VALUES (1) UNION ALL SELECT n + 1 F..." +== 009 +-- truncate_limit: 100 +SELECT * FROM nums +-- +TABLE: name="nums" schema="" table="nums" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM nums" +== 010 +-- truncate_limit: 100 +-- This is an infinite loop with UNION ALL, but not with UNION +WITH RECURSIVE t(n) AS ( + SELECT 1 +UNION + SELECT 10-n FROM t) +SELECT * FROM t +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(n) AS (SELECT 1 UNION SELECT 10 - n FROM t) SELECT * FROM t" +== 011 +-- truncate_limit: 100 +-- This'd be an infinite loop, but outside query reads only as much as needed +WITH RECURSIVE t(n) AS ( + VALUES (1) +UNION ALL + SELECT n+1 FROM t) +SELECT * FROM t LIMIT 10 +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(n) AS (VALUES (1) UNION ALL SELECT n + 1 FROM t) SELECT * FROM t LIMIT 10" +== 012 +-- truncate_limit: 100 +-- UNION case should have same property +WITH RECURSIVE t(n) AS ( + SELECT 1 +UNION + SELECT n+1 FROM t) +SELECT * FROM t LIMIT 10 +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(n) AS (SELECT 1 UNION SELECT n + 1 FROM t) SELECT * FROM t LIMIT 10" +== 013 +-- truncate_limit: 100 +-- Test behavior with an unknown-type literal in the WITH +WITH q AS (SELECT 'foo' AS x) +SELECT x, pg_typeof(x) FROM q +-- +CTE: "q" +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH q AS (SELECT 'foo' AS x) SELECT x, pg_typeof(x) FROM q" +== 014 +-- truncate_limit: 100 +WITH RECURSIVE t(n) AS ( + SELECT 'foo' +UNION ALL + SELECT n || ' bar' FROM t WHERE length(n) < 20 +) +SELECT n, pg_typeof(n) FROM t +-- +CTE: "t" +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(n) AS (...) SELECT n, pg_typeof(n) FROM t" +== 015 +-- truncate_limit: 100 +-- In a perfect world, this would work and resolve the literal as int ... +-- but for now, we have to be content with resolving to text too soon. +WITH RECURSIVE t(n) AS ( + SELECT '7' +UNION ALL + SELECT n+1 FROM t WHERE n < 10 +) +SELECT n, pg_typeof(n) FROM t +-- +CTE: "t" +FUNCTION: name="pg_typeof" function="pg_typeof" schema="" ctx=Call +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(n) AS (...) SELECT n, pg_typeof(n) FROM t" +== 016 +-- truncate_limit: 100 +-- Deeply nested WITH caused a list-munging problem in v13 +-- Detection of cross-references and self-references +WITH RECURSIVE w1(c1) AS + (WITH w2(c2) AS + (WITH w3(c3) AS + (WITH w4(c4) AS + (WITH w5(c5) AS + (WITH RECURSIVE w6(c6) AS + (WITH w6(c6) AS + (WITH w8(c8) AS + (SELECT 1) + SELECT * FROM w8) + SELECT * FROM w6) + SELECT * FROM w6) + SELECT * FROM w5) + SELECT * FROM w4) + SELECT * FROM w3) + SELECT * FROM w2) +SELECT * FROM w1 +-- +CTE: "w1" +CTE: "w2" +CTE: "w3" +CTE: "w4" +CTE: "w5" +CTE: "w6" +CTE: "w6" +CTE: "w8" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE w1(c1) AS (WITH w2(c2) AS (...) SELECT * FROM w2) SELECT * FROM w1" +== 017 +-- truncate_limit: 100 +-- Detection of invalid self-references +WITH RECURSIVE outermost(x) AS ( + SELECT 1 + UNION (WITH innermost1 AS ( + SELECT 2 + UNION (WITH innermost2 AS ( + SELECT 3 + UNION (WITH innermost3 AS ( + SELECT 4 + UNION (WITH innermost4 AS ( + SELECT 5 + UNION (WITH innermost5 AS ( + SELECT 6 + UNION (WITH innermost6 AS + (SELECT 7) + SELECT * FROM innermost6)) + SELECT * FROM innermost5)) + SELECT * FROM innermost4)) + SELECT * FROM innermost3)) + SELECT * FROM innermost2)) + SELECT * FROM outermost + UNION SELECT * FROM innermost1) + ) + SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost1" +CTE: "innermost2" +CTE: "innermost3" +CTE: "innermost4" +CTE: "innermost5" +CTE: "innermost6" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE outermost(x) AS (...) SELECT * FROM outermost ORDER BY 1" +== 018 +-- truncate_limit: 100 +|-- +-- Some examples with a tree +|-- +-- department structure represented here is as follows: +|-- +-- ROOT-+->A-+->B-+->C +-- | | +-- | +->D-+->F +-- +->E-+->G + +CREATE TEMP TABLE department ( + id INTEGER PRIMARY KEY, -- department ID + parent_department INTEGER REFERENCES department, -- upper department ID + name TEXT -- department name +) +-- +TABLE: name="department" schema="" table="department" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE department (id int PRIMARY KEY, parent_department int REFERENCES departmen..." +== 019 +-- truncate_limit: 100 +INSERT INTO department VALUES (0, NULL, 'ROOT') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO department VALUES (0, NULL, 'ROOT')" +== 020 +-- truncate_limit: 100 +INSERT INTO department VALUES (1, 0, 'A') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO department VALUES (1, 0, 'A')" +== 021 +-- truncate_limit: 100 +INSERT INTO department VALUES (2, 1, 'B') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO department VALUES (2, 1, 'B')" +== 022 +-- truncate_limit: 100 +INSERT INTO department VALUES (3, 2, 'C') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO department VALUES (3, 2, 'C')" +== 023 +-- truncate_limit: 100 +INSERT INTO department VALUES (4, 2, 'D') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO department VALUES (4, 2, 'D')" +== 024 +-- truncate_limit: 100 +INSERT INTO department VALUES (5, 0, 'E') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO department VALUES (5, 0, 'E')" +== 025 +-- truncate_limit: 100 +INSERT INTO department VALUES (6, 4, 'F') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO department VALUES (6, 4, 'F')" +== 026 +-- truncate_limit: 100 +INSERT INTO department VALUES (7, 5, 'G') +-- +TABLE: name="department" schema="" table="department" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO department VALUES (7, 5, 'G')" +== 027 +-- truncate_limit: 100 +-- extract all departments under 'A'. Result should be A, B, C, D and F +WITH RECURSIVE subdepartment AS +( + -- non recursive term + SELECT name as root_name, * FROM department WHERE name = 'A' + + UNION ALL + + -- recursive term + SELECT sd.root_name, d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id +) +SELECT * FROM subdepartment ORDER BY name +-- +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +ALIAS: "d"="department" +ALIAS: "sd"="subdepartment" +CTE: "subdepartment" +FILTER: schema="" table="" column="name" +FILTER: schema="" table="d" column="parent_department" +FILTER: schema="" table="sd" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE subdepartment AS (...) SELECT * FROM subdepartment ORDER BY name" +== 028 +-- truncate_limit: 100 +-- extract all departments under 'A' with "level" number +WITH RECURSIVE subdepartment(level, id, parent_department, name) AS +( + -- non recursive term + SELECT 1, * FROM department WHERE name = 'A' + + UNION ALL + + -- recursive term + SELECT sd.level + 1, d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id +) +SELECT * FROM subdepartment ORDER BY name +-- +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +ALIAS: "d"="department" +ALIAS: "sd"="subdepartment" +CTE: "subdepartment" +FILTER: schema="" table="" column="name" +FILTER: schema="" table="d" column="parent_department" +FILTER: schema="" table="sd" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE subdepartment(level, id, parent_department, name) AS (...) SELECT * FROM subdepart..." +== 029 +-- truncate_limit: 100 +-- extract all departments under 'A' with "level" number. +-- Only shows level 2 or more +WITH RECURSIVE subdepartment(level, id, parent_department, name) AS +( + -- non recursive term + SELECT 1, * FROM department WHERE name = 'A' + + UNION ALL + + -- recursive term + SELECT sd.level + 1, d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id +) +SELECT * FROM subdepartment WHERE level >= 2 ORDER BY name +-- +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +ALIAS: "d"="department" +ALIAS: "sd"="subdepartment" +CTE: "subdepartment" +FILTER: schema="" table="" column="level" +FILTER: schema="" table="" column="name" +FILTER: schema="" table="d" column="parent_department" +FILTER: schema="" table="sd" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE subdepartment(level, id, parent_department, name) AS (...) SELECT * FROM subdepart..." +== 030 +-- truncate_limit: 100 +-- "RECURSIVE" is ignored if the query has no self-reference +WITH RECURSIVE subdepartment AS +( + -- note lack of recursive UNION structure + SELECT * FROM department WHERE name = 'A' +) +SELECT * FROM subdepartment ORDER BY name +-- +TABLE: name="department" schema="" table="department" ctx=Select +CTE: "subdepartment" +FILTER: schema="" table="" column="name" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE subdepartment AS (...) SELECT * FROM subdepartment ORDER BY name" +== 031 +-- truncate_limit: 100 +-- inside subqueries +SELECT count(*) FROM ( + WITH RECURSIVE t(n) AS ( + SELECT 1 UNION ALL SELECT n + 1 FROM t WHERE n < 500 + ) + SELECT * FROM t) AS t WHERE n < ( + SELECT count(*) FROM ( + WITH RECURSIVE t(n) AS ( + SELECT 1 UNION ALL SELECT n + 1 FROM t WHERE n < 100 + ) + SELECT * FROM t WHERE n < 50000 + ) AS t WHERE n < 100) +-- +CTE: "t" +CTE: "t" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="n" +FILTER: schema="" table="" column="n" +FILTER: schema="" table="" column="n" +FILTER: schema="" table="" column="n" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "SELECT count(*) FROM (WITH RECURSIVE t(n) AS (...) SELECT * FROM t) t WHERE ..." +== 032 +-- truncate_limit: 100 +-- use same CTE twice at different subquery levels +WITH q1(x,y) AS ( + SELECT hundred, sum(ten) FROM tenk1 GROUP BY hundred + ) +SELECT count(*) FROM q1 WHERE y > (SELECT sum(y)/100 FROM q1 qsub) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "qsub"="q1" +CTE: "q1" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="y" +STMT: SelectStmt +TRUNCATED: "WITH q1(x, y) AS (...) SELECT count(*) FROM q1 WHERE y > (SELECT sum(y) / 100 FROM q1 qsub)" +== 033 +-- truncate_limit: 100 +-- via a VIEW +CREATE TEMPORARY VIEW vsubdepartment AS + WITH RECURSIVE subdepartment AS + ( + -- non recursive term + SELECT * FROM department WHERE name = 'A' + UNION ALL + -- recursive term + SELECT d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id + ) + SELECT * FROM subdepartment +-- +TABLE: name="vsubdepartment" schema="" table="vsubdepartment" ctx=DDL +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +ALIAS: "d"="department" +ALIAS: "sd"="subdepartment" +CTE: "subdepartment" +FILTER: schema="" table="" column="name" +FILTER: schema="" table="d" column="parent_department" +FILTER: schema="" table="sd" column="id" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW vsubdepartment AS WITH RECURSIVE subdepartment AS (SELECT * FROM department..." +== 034 +-- truncate_limit: 100 +SELECT * FROM vsubdepartment ORDER BY name +-- +TABLE: name="vsubdepartment" schema="" table="vsubdepartment" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM vsubdepartment ORDER BY name" +== 035 +-- truncate_limit: 100 +-- Check reverse listing +SELECT pg_get_viewdef('vsubdepartment'::regclass) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vsubdepartment'::regclass)" +== 036 +-- truncate_limit: 100 +SELECT pg_get_viewdef('vsubdepartment'::regclass, true) +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('vsubdepartment'::regclass, true)" +== 037 +-- truncate_limit: 100 +-- Another reverse-listing example +CREATE VIEW sums_1_100 AS +WITH RECURSIVE t(n) AS ( + VALUES (1) +UNION ALL + SELECT n+1 FROM t WHERE n < 100 +) +SELECT sum(n) FROM t +-- +TABLE: name="sums_1_100" schema="" table="sums_1_100" ctx=DDL +CTE: "t" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +FILTER: schema="" table="" column="n" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW sums_1_100 AS WITH RECURSIVE t(n) AS (VALUES (1) UNION ALL SELECT n + 1 FROM t WHERE ..." +== 038 +-- truncate_limit: 100 +-- corner case in which sub-WITH gets initialized first +with recursive q as ( + select * from department + union all + (with x as (select * from q) + select * from x) + ) +select * from q limit 24 +-- +TABLE: name="department" schema="" table="department" ctx=Select +CTE: "q" +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE q AS (...) SELECT * FROM q LIMIT 24" +== 039 +-- truncate_limit: 100 +with recursive q as ( + select * from department + union all + (with recursive x as ( + select * from department + union all + (select * from q union all select * from x) + ) + select * from x) + ) +select * from q limit 32 +-- +TABLE: name="department" schema="" table="department" ctx=Select +TABLE: name="department" schema="" table="department" ctx=Select +CTE: "q" +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE q AS (...) SELECT * FROM q LIMIT 32" +== 040 +-- truncate_limit: 100 +-- recursive term has sub-UNION +WITH RECURSIVE t(i,j) AS ( + VALUES (1,2) + UNION ALL + SELECT t2.i, t.j+1 FROM + (SELECT 2 AS i UNION ALL SELECT 3 AS i) AS t2 + JOIN t ON (t2.i = t.i+1)) + + SELECT * FROM t +-- +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(i, j) AS (...) SELECT * FROM t" +== 041 +-- truncate_limit: 100 +|-- +-- different tree example +|-- +CREATE TEMPORARY TABLE tree( + id INTEGER PRIMARY KEY, + parent_id INTEGER REFERENCES tree(id) +) +-- +TABLE: name="tree" schema="" table="tree" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE tree (id int PRIMARY KEY, parent_id int REFERENCES tree (id))" +== 042 +-- truncate_limit: 100 +INSERT INTO tree +VALUES (1, NULL), (2, 1), (3,1), (4,2), (5,2), (6,2), (7,3), (8,3), + (9,4), (10,4), (11,7), (12,7), (13,7), (14, 9), (15,11), (16,11) +-- +TABLE: name="tree" schema="" table="tree" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO tree VALUES (...)" +== 043 +-- truncate_limit: 100 +|-- +-- get all paths from "second level" nodes to leaf nodes +|-- +WITH RECURSIVE t(id, path) AS ( + VALUES(1,ARRAY[]::integer[]) +UNION ALL + SELECT tree.id, t.path || tree.id + FROM tree JOIN t ON (tree.parent_id = t.id) +) +SELECT t1.*, t2.* FROM t AS t1 JOIN t AS t2 ON + (t1.path[1] = t2.path[1] AND + array_upper(t1.path,1) = 1 AND + array_upper(t2.path,1) > 1) + ORDER BY t1.id, t2.id +-- +TABLE: name="tree" schema="" table="tree" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +CTE: "t" +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(id, path) AS (...) SELECT ... FROM t t1 JOIN t t2 ON t1.path[1] = t2.path[1] AND..." +== 044 +-- truncate_limit: 100 +-- just count 'em +WITH RECURSIVE t(id, path) AS ( + VALUES(1,ARRAY[]::integer[]) +UNION ALL + SELECT tree.id, t.path || tree.id + FROM tree JOIN t ON (tree.parent_id = t.id) +) +SELECT t1.id, count(t2.*) FROM t AS t1 JOIN t AS t2 ON + (t1.path[1] = t2.path[1] AND + array_upper(t1.path,1) = 1 AND + array_upper(t2.path,1) > 1) + GROUP BY t1.id + ORDER BY t1.id +-- +TABLE: name="tree" schema="" table="tree" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +CTE: "t" +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +FUNCTION: name="array_upper" function="array_upper" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(id, path) AS (...) SELECT ... FROM t t1 JOIN t t2 ON t1.path[1] = t2.path[1] AND..." +== 045 +-- truncate_limit: 100 +-- this variant tickled a whole-row-variable bug in 8.4devel +WITH RECURSIVE t(id, path) AS ( + VALUES(1,ARRAY[]::integer[]) +UNION ALL + SELECT tree.id, t.path || tree.id + FROM tree JOIN t ON (tree.parent_id = t.id) +) +SELECT t1.id, t2.path, t2 FROM t AS t1 JOIN t AS t2 ON +(t1.id=t2.id) +-- +TABLE: name="tree" schema="" table="tree" ctx=Select +ALIAS: "t1"="t" +ALIAS: "t2"="t" +CTE: "t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(id, path) AS (...) SELECT t1.id, t2.path, t2 FROM t t1 JOIN t t2 ON t1.id = t2.id" +== 046 +-- truncate_limit: 100 +CREATE TEMP TABLE duplicates (a INT NOT NULL) +-- +TABLE: name="duplicates" schema="" table="duplicates" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE duplicates (a int NOT NULL)" +== 047 +-- truncate_limit: 100 +INSERT INTO duplicates VALUES(1), (1) +-- +TABLE: name="duplicates" schema="" table="duplicates" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO duplicates VALUES (1), (1)" +== 048 +-- truncate_limit: 100 +-- Try out a recursive UNION case where the non-recursive part's table slot +-- uses TTSOpsBufferHeapTuple and contains duplicate rows. +WITH RECURSIVE cte (a) as ( + SELECT a FROM duplicates + UNION + SELECT a FROM cte +) +SELECT a FROM cte +-- +TABLE: name="duplicates" schema="" table="duplicates" ctx=Select +CTE: "cte" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE cte(a) AS (SELECT a FROM duplicates UNION SELECT a FROM cte) SELECT a FROM cte" +== 049 +-- truncate_limit: 100 +-- test that column statistics from a materialized CTE are available +-- to upper planner (otherwise, we'd get a stupider plan) +explain (costs off) +with x as materialized (select unique1 from tenk1 b) +select count(*) from tenk1 a + where unique1 in (select * from x) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +CTE: "x" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) WITH x AS MATERIALIZED (SELECT unique1 FROM tenk1 b) SELECT count(*) FROM ten..." +== 050 +-- truncate_limit: 100 +explain (costs off) +with x as materialized (insert into tenk1 default values returning unique1) +select count(*) from tenk1 a + where unique1 in (select * from x) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=DML +ALIAS: "a"="tenk1" +CTE: "x" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "EXPLAIN (COSTS OFF) WITH x AS MATERIALIZED (INSERT INTO tenk1 DEFAULT VALUES RETURNING unique1) S..." +== 051 +-- truncate_limit: 100 +-- test that pathkeys from a materialized CTE are propagated up to the +-- outer query +explain (costs off) +with x as materialized (select unique1 from tenk1 b order by unique1) +select count(*) from tenk1 a + where unique1 in (select * from x) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +ALIAS: "a"="tenk1" +ALIAS: "b"="tenk1" +CTE: "x" +FUNCTION: name="count" function="count" schema="" ctx=Call +FILTER: schema="" table="" column="unique1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) WITH x AS MATERIALIZED (SELECT unique1 FROM tenk1 b ORDER BY unique1) SELECT ..." +== 052 +-- truncate_limit: 100 +-- SEARCH clause + +create temp table graph0( f int, t int, label text ) +-- +TABLE: name="graph0" schema="" table="graph0" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE graph0 (f int, t int, label text)" +== 053 +-- truncate_limit: 100 +insert into graph0 values + (1, 2, 'arc 1 -> 2'), + (1, 3, 'arc 1 -> 3'), + (2, 3, 'arc 2 -> 3'), + (1, 4, 'arc 1 -> 4'), + (4, 5, 'arc 4 -> 5') +-- +TABLE: name="graph0" schema="" table="graph0" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO graph0 VALUES (...)" +== 054 +-- truncate_limit: 100 +explain (verbose, costs off) +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH RECURSIVE search_graph(f, t, label) AS (SELECT * FROM graph0 g ..." +== 055 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t SET seq SELECT * FRO..." +== 056 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union distinct + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t SET seq SELECT * FRO..." +== 057 +-- truncate_limit: 100 +explain (verbose, costs off) +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search breadth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH RECURSIVE search_graph(f, t, label) AS (SELECT * FROM graph0 g ..." +== 058 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search breadth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH BREADTH FIRST BY f, t SET seq SELECT * F..." +== 059 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union distinct + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search breadth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH BREADTH FIRST BY f, t SET seq SELECT * F..." +== 060 +-- truncate_limit: 100 +-- a constant initial value causes issues for EXPLAIN +explain (verbose, costs off) +with recursive test as ( + select 1 as x + union all + select x + 1 + from test +) search depth first by x set y +select * from test limit 5 +-- +CTE: "test" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH RECURSIVE test AS (SELECT 1 AS x UNION ALL SELECT x + 1 FROM te..." +== 061 +-- truncate_limit: 100 +with recursive test as ( + select 1 as x + union all + select x + 1 + from test +) search depth first by x set y +select * from test limit 5 +-- +CTE: "test" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE test AS (...) SEARCH DEPTH FIRST BY x SET y SELECT * FROM test LIMIT 5" +== 062 +-- truncate_limit: 100 +explain (verbose, costs off) +with recursive test as ( + select 1 as x + union all + select x + 1 + from test +) search breadth first by x set y +select * from test limit 5 +-- +CTE: "test" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH RECURSIVE test AS (SELECT 1 AS x UNION ALL SELECT x + 1 FROM te..." +== 063 +-- truncate_limit: 100 +with recursive test as ( + select 1 as x + union all + select x + 1 + from test +) search breadth first by x set y +select * from test limit 5 +-- +CTE: "test" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE test AS (...) SEARCH BREADTH FIRST BY x SET y SELECT * FROM test LIMIT 5" +== 064 +-- truncate_limit: 100 +-- various syntax errors +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by foo, tar set seq +select * from search_graph +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY foo, tar SET seq SELECT *..." +== 065 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set label +select * from search_graph +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t SET label SELECT * F..." +== 066 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t, f set seq +select * from search_graph +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t, f SET seq SELECT * ..." +== 067 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t SET seq SELECT * FRO..." +== 068 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + (select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t) +) search depth first by f, t set seq +select * from search_graph order by seq +-- +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t SET seq SELECT * FRO..." +== 069 +-- truncate_limit: 100 +-- check that we distinguish same CTE name used at different levels +-- (this case could be supported, perhaps, but it isn't today) +with recursive x(col) as ( + select 1 + union + (with x as (select * from x) + select * from x) +) search depth first by col set seq +select * from x +-- +CTE: "x" +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(col) AS (...) SEARCH DEPTH FIRST BY col SET seq SELECT * FROM x" +== 070 +-- truncate_limit: 100 +-- test ruleutils and view expansion +create temp view v_search as +with recursive search_graph(f, t, label) as ( + select * from graph0 g + union all + select g.* + from graph0 g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq +select f, t, label from search_graph +-- +TABLE: name="v_search" schema="" table="v_search" ctx=DDL +TABLE: name="graph0" schema="" table="graph0" ctx=Select +TABLE: name="graph0" schema="" table="graph0" ctx=Select +ALIAS: "g"="graph0" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v_search AS WITH RECURSIVE search_graph(f, t, label) AS (SELECT * FROM grap..." +== 071 +-- truncate_limit: 100 +select pg_get_viewdef('v_search') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_search')" +== 072 +-- truncate_limit: 100 +select * from v_search +-- +TABLE: name="v_search" schema="" table="v_search" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_search" +== 073 +-- truncate_limit: 100 +|-- +-- test cycle detection +|-- +create temp table graph( f int, t int, label text ) +-- +TABLE: name="graph" schema="" table="graph" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE graph (f int, t int, label text)" +== 074 +-- truncate_limit: 100 +insert into graph values + (1, 2, 'arc 1 -> 2'), + (1, 3, 'arc 1 -> 3'), + (2, 3, 'arc 2 -> 3'), + (1, 4, 'arc 1 -> 4'), + (4, 5, 'arc 4 -> 5'), + (5, 1, 'arc 5 -> 1') +-- +TABLE: name="graph" schema="" table="graph" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO graph VALUES (...)" +== 075 +-- truncate_limit: 100 +with recursive search_graph(f, t, label, is_cycle, path) as ( + select *, false, array[row(g.f, g.t)] from graph g + union all + select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) + from graph g, search_graph sg + where g.f = sg.t and not is_cycle +) +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +FILTER: schema="" table="" column="is_cycle" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label, is_cycle, path) AS (...) SELECT * FROM search_graph" +== 076 +-- truncate_limit: 100 +-- UNION DISTINCT exercises row type hashing support +with recursive search_graph(f, t, label, is_cycle, path) as ( + select *, false, array[row(g.f, g.t)] from graph g + union distinct + select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) + from graph g, search_graph sg + where g.f = sg.t and not is_cycle +) +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +FILTER: schema="" table="" column="is_cycle" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label, is_cycle, path) AS (...) SELECT * FROM search_graph" +== 077 +-- truncate_limit: 100 +-- ordering by the path column has same effect as SEARCH DEPTH FIRST +with recursive search_graph(f, t, label, is_cycle, path) as ( + select *, false, array[row(g.f, g.t)] from graph g + union all + select g.*, row(g.f, g.t) = any(path), path || row(g.f, g.t) + from graph g, search_graph sg + where g.f = sg.t and not is_cycle +) +select * from search_graph order by path +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +FILTER: schema="" table="" column="is_cycle" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label, is_cycle, path) AS (...) SELECT * FROM search_graph ORDE..." +== 078 +-- truncate_limit: 100 +-- CYCLE clause + +explain (verbose, costs off) +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH RECURSIVE search_graph(f, t, label) AS (SELECT * FROM graph g U..." +== 079 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE f, t SET is_cycle TO true DEFAULT false U..." +== 080 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union distinct + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to 'Y' default 'N' using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE f, t SET is_cycle TO 'Y' DEFAULT 'N' USIN..." +== 081 +-- truncate_limit: 100 +explain (verbose, costs off) +with recursive test as ( + select 0 as x + union all + select (x + 1) % 10 + from test +) cycle x set is_cycle using path +select * from test +-- +CTE: "test" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH RECURSIVE test AS (SELECT 0 AS x UNION ALL SELECT (x + 1) % 10 ..." +== 082 +-- truncate_limit: 100 +with recursive test as ( + select 0 as x + union all + select (x + 1) % 10 + from test +) cycle x set is_cycle using path +select * from test +-- +CTE: "test" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE test AS (...) CYCLE x SET is_cycle TO true DEFAULT false USING path SELECT * FROM ..." +== 083 +-- truncate_limit: 100 +with recursive test as ( + select 0 as x + union all + select (x + 1) % 10 + from test + where not is_cycle -- redundant, but legal +) cycle x set is_cycle using path +select * from test +-- +CTE: "test" +FILTER: schema="" table="" column="is_cycle" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE test AS (...) CYCLE x SET is_cycle TO true DEFAULT false USING path SELECT * FROM ..." +== 084 +-- truncate_limit: 100 +-- multiple CTEs +with recursive +graph(f, t, label) as ( + values (1, 2, 'arc 1 -> 2'), + (1, 3, 'arc 1 -> 3'), + (2, 3, 'arc 2 -> 3'), + (1, 4, 'arc 1 -> 4'), + (4, 5, 'arc 4 -> 5'), + (5, 1, 'arc 5 -> 1') +), +search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to true default false using path +select f, t, label from search_graph +-- +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE graph(f, t, label) AS (...), search_graph(f, t, label) AS (...) CYCLE f, t SET is_..." +== 085 +-- truncate_limit: 100 +-- star expansion +with recursive a as ( + select 1 as b + union all + select * from a +) cycle b set c using p +select * from a +-- +CTE: "a" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE a AS (...) CYCLE b SET c TO true DEFAULT false USING p SELECT * FROM a" +== 086 +-- truncate_limit: 100 +-- search+cycle +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) search depth first by f, t set seq + cycle f, t set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t SET seq CYCLE f, t S..." +== 087 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) search breadth first by f, t set seq + cycle f, t set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH BREADTH FIRST BY f, t SET seq CYCLE f, t..." +== 088 +-- truncate_limit: 100 +-- various syntax errors +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle foo, tar set is_cycle using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE foo, tar SET is_cycle TO true DEFAULT fal..." +== 089 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to true default 55 using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE f, t SET is_cycle TO true DEFAULT 55 USIN..." +== 090 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to point '(1,1)' default point '(0,0)' using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE f, t SET is_cycle TO point '(1,1)' DEFAU..." +== 091 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set label to true default false using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE f, t SET label TO true DEFAULT false USIN..." +== 092 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to true default false using label +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE f, t SET is_cycle TO true DEFAULT false U..." +== 093 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set foo to true default false using foo +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE f, t SET foo TO true DEFAULT false USING ..." +== 094 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t, f set is_cycle to true default false using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) CYCLE f, t, f SET is_cycle TO true DEFAULT fals..." +== 095 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) search depth first by f, t set foo + cycle f, t set foo to true default false using path +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t SET foo CYCLE f, t S..." +== 096 +-- truncate_limit: 100 +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) search depth first by f, t set foo + cycle f, t set is_cycle to true default false using foo +select * from search_graph +-- +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE search_graph(f, t, label) AS (...) SEARCH DEPTH FIRST BY f, t SET foo CYCLE f, t S..." +== 097 +-- truncate_limit: 100 +-- test ruleutils and view expansion +create temp view v_cycle1 as +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle using path +select f, t, label from search_graph +-- +TABLE: name="v_cycle1" schema="" table="v_cycle1" ctx=DDL +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v_cycle1 AS WITH RECURSIVE search_graph(f, t, label) AS (SELECT * FROM grap..." +== 098 +-- truncate_limit: 100 +create temp view v_cycle2 as +with recursive search_graph(f, t, label) as ( + select * from graph g + union all + select g.* + from graph g, search_graph sg + where g.f = sg.t +) cycle f, t set is_cycle to 'Y' default 'N' using path +select f, t, label from search_graph +-- +TABLE: name="v_cycle2" schema="" table="v_cycle2" ctx=DDL +TABLE: name="graph" schema="" table="graph" ctx=Select +TABLE: name="graph" schema="" table="graph" ctx=Select +ALIAS: "g"="graph" +ALIAS: "sg"="search_graph" +CTE: "search_graph" +FILTER: schema="" table="g" column="f" +FILTER: schema="" table="sg" column="t" +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY VIEW v_cycle2 AS WITH RECURSIVE search_graph(f, t, label) AS (SELECT * FROM grap..." +== 099 +-- truncate_limit: 100 +select pg_get_viewdef('v_cycle1') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_cycle1')" +== 100 +-- truncate_limit: 100 +select pg_get_viewdef('v_cycle2') +-- +FUNCTION: name="pg_get_viewdef" function="pg_get_viewdef" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_get_viewdef('v_cycle2')" +== 101 +-- truncate_limit: 100 +select * from v_cycle1 +-- +TABLE: name="v_cycle1" schema="" table="v_cycle1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_cycle1" +== 102 +-- truncate_limit: 100 +select * from v_cycle2 +-- +TABLE: name="v_cycle2" schema="" table="v_cycle2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM v_cycle2" +== 103 +-- truncate_limit: 100 +|-- +-- test multiple WITH queries +|-- +WITH RECURSIVE + y (id) AS (VALUES (1)), + x (id) AS (SELECT * FROM y UNION ALL SELECT id+1 FROM x WHERE id < 5) +SELECT * FROM x +-- +CTE: "y" +CTE: "x" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE y(id) AS (VALUES (1)), x(id) AS (...) SELECT * FROM x" +== 104 +-- truncate_limit: 100 +-- forward reference OK +WITH RECURSIVE + x(id) AS (SELECT * FROM y UNION ALL SELECT id+1 FROM x WHERE id < 5), + y(id) AS (values (1)) + SELECT * FROM x +-- +CTE: "x" +CTE: "y" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(id) AS (...), y(id) AS (VALUES (1)) SELECT * FROM x" +== 105 +-- truncate_limit: 100 +WITH RECURSIVE + x(id) AS + (VALUES (1) UNION ALL SELECT id+1 FROM x WHERE id < 5), + y(id) AS + (VALUES (1) UNION ALL SELECT id+1 FROM y WHERE id < 10) + SELECT y.*, x.* FROM y LEFT JOIN x USING (id) +-- +CTE: "x" +CTE: "y" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(id) AS (...), y(id) AS (...) SELECT y.*, x.* FROM y LEFT JOIN x USING (id)" +== 106 +-- truncate_limit: 100 +WITH RECURSIVE + x(id) AS + (VALUES (1) UNION ALL SELECT id+1 FROM x WHERE id < 5), + y(id) AS + (VALUES (1) UNION ALL SELECT id+1 FROM x WHERE id < 10) + SELECT y.*, x.* FROM y LEFT JOIN x USING (id) +-- +CTE: "x" +CTE: "y" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(id) AS (...), y(id) AS (...) SELECT y.*, x.* FROM y LEFT JOIN x USING (id)" +== 107 +-- truncate_limit: 100 +WITH RECURSIVE + x(id) AS + (SELECT 1 UNION ALL SELECT id+1 FROM x WHERE id < 3 ), + y(id) AS + (SELECT * FROM x UNION ALL SELECT * FROM x), + z(id) AS + (SELECT * FROM x UNION ALL SELECT id+1 FROM z WHERE id < 10) + SELECT * FROM z +-- +CTE: "x" +CTE: "y" +CTE: "z" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(id) AS (...), y(id) AS (...), z(id) AS (...) SELECT * FROM z" +== 108 +-- truncate_limit: 100 +WITH RECURSIVE + x(id) AS + (SELECT 1 UNION ALL SELECT id+1 FROM x WHERE id < 3 ), + y(id) AS + (SELECT * FROM x UNION ALL SELECT * FROM x), + z(id) AS + (SELECT * FROM y UNION ALL SELECT id+1 FROM z WHERE id < 10) + SELECT * FROM z +-- +CTE: "x" +CTE: "y" +CTE: "z" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(id) AS (...), y(id) AS (...), z(id) AS (...) SELECT * FROM z" +== 109 +-- truncate_limit: 100 +|-- +-- Test WITH attached to a data-modifying statement +|-- + +CREATE TEMPORARY TABLE y (a INTEGER) +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE y (a int)" +== 110 +-- truncate_limit: 100 +INSERT INTO y SELECT generate_series(1, 10) +-- +TABLE: name="y" schema="" table="y" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y SELECT generate_series(1, 10)" +== 111 +-- truncate_limit: 100 +WITH t AS ( + SELECT a FROM y +) +INSERT INTO y +SELECT a+20 FROM t RETURNING * +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "t" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH t AS (SELECT a FROM y) INSERT INTO y SELECT a + 20 FROM t RETURNING *" +== 112 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 113 +-- truncate_limit: 100 +WITH t AS ( + SELECT a FROM y +) +UPDATE y SET a = y.a-10 FROM t WHERE y.a > 20 AND t.a = y.a RETURNING y.a +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "t" +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "WITH t AS (...) UPDATE y SET a = y.a - 10 FROM t WHERE y.a > 20 AND t.a = y.a RETURNING y.a" +== 114 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 115 +-- truncate_limit: 100 +WITH RECURSIVE t(a) AS ( + SELECT 11 + UNION ALL + SELECT a+1 FROM t WHERE a < 50 +) +DELETE FROM y USING t WHERE t.a = y.a RETURNING y.a +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +FILTER: schema="" table="" column="a" +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(a) AS (...) DELETE FROM y USING t WHERE t.a = y.a RETURNING y.a" +== 116 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 117 +-- truncate_limit: 100 +DROP TABLE y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE y" +== 118 +-- truncate_limit: 100 +|-- +-- error cases +|-- + +WITH x(n, b) AS (SELECT 1) +SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH x(n, b) AS (SELECT 1) SELECT * FROM x" +== 119 +-- truncate_limit: 100 +-- INTERSECT +WITH RECURSIVE x(n) AS (SELECT 1 INTERSECT SELECT n+1 FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 INTERSECT SELECT n + 1 FROM x) SELECT * FROM x" +== 120 +-- truncate_limit: 100 +WITH RECURSIVE x(n) AS (SELECT 1 INTERSECT ALL SELECT n+1 FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 INTERSECT ALL SELECT n + 1 FROM x) SELECT * FROM x" +== 121 +-- truncate_limit: 100 +-- EXCEPT +WITH RECURSIVE x(n) AS (SELECT 1 EXCEPT SELECT n+1 FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 EXCEPT SELECT n + 1 FROM x) SELECT * FROM x" +== 122 +-- truncate_limit: 100 +WITH RECURSIVE x(n) AS (SELECT 1 EXCEPT ALL SELECT n+1 FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 EXCEPT ALL SELECT n + 1 FROM x) SELECT * FROM x" +== 123 +-- truncate_limit: 100 +-- no non-recursive term +WITH RECURSIVE x(n) AS (SELECT n FROM x) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT n FROM x) SELECT * FROM x" +== 124 +-- truncate_limit: 100 +-- recursive term in the left hand side (strictly speaking, should allow this) +WITH RECURSIVE x(n) AS (SELECT n FROM x UNION ALL SELECT 1) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT n FROM x UNION ALL SELECT 1) SELECT * FROM x" +== 125 +-- truncate_limit: 100 +-- allow this, because we historically have +WITH RECURSIVE x(n) AS ( + WITH x1 AS (SELECT 1 AS n) + SELECT 0 + UNION + SELECT * FROM x1) + SELECT * FROM x +-- +CTE: "x" +CTE: "x1" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (WITH x1 AS (SELECT 1 AS n) SELECT 0 UNION SELECT * FROM x1) SELECT * FROM x" +== 126 +-- truncate_limit: 100 +-- but this should be rejected +WITH RECURSIVE x(n) AS ( + WITH x1 AS (SELECT 1 FROM x) + SELECT 0 + UNION + SELECT * FROM x1) + SELECT * FROM x +-- +CTE: "x" +CTE: "x1" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (WITH x1 AS (...) SELECT 0 UNION SELECT * FROM x1) SELECT * FROM x" +== 127 +-- truncate_limit: 100 +-- and this too +WITH RECURSIVE x(n) AS ( + (WITH x1 AS (SELECT 1 FROM x) SELECT * FROM x1) + UNION + SELECT 0) + SELECT * FROM x +-- +CTE: "x" +CTE: "x1" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS ((WITH x1 AS (...) SELECT * FROM x1) UNION SELECT 0) SELECT * FROM x" +== 128 +-- truncate_limit: 100 +-- and this +WITH RECURSIVE x(n) AS ( + SELECT 0 UNION SELECT 1 + ORDER BY (SELECT n FROM x)) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 0 UNION SELECT 1 ORDER BY (SELECT n FROM x)) SELECT * FROM x" +== 129 +-- truncate_limit: 100 +-- and this +WITH RECURSIVE x(n) AS ( + WITH sub_cte AS (SELECT * FROM x) + DELETE FROM graph RETURNING f) + SELECT * FROM x +-- +TABLE: name="graph" schema="" table="graph" ctx=DML +CTE: "x" +CTE: "sub_cte" +STMT: SelectStmt +STMT: DeleteStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (WITH sub_cte AS (...) DELETE FROM graph RETURNING f) SELECT * FROM x" +== 130 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE y (a INTEGER) +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE y (a int)" +== 131 +-- truncate_limit: 100 +INSERT INTO y SELECT generate_series(1, 10) +-- +TABLE: name="y" schema="" table="y" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y SELECT generate_series(1, 10)" +== 132 +-- truncate_limit: 100 +-- LEFT JOIN + +WITH RECURSIVE x(n) AS (SELECT a FROM y WHERE a = 1 + UNION ALL + SELECT x.n+1 FROM y LEFT JOIN x ON x.n = y.a WHERE n < 10) +SELECT * FROM x +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (...) SELECT * FROM x" +== 133 +-- truncate_limit: 100 +-- RIGHT JOIN +WITH RECURSIVE x(n) AS (SELECT a FROM y WHERE a = 1 + UNION ALL + SELECT x.n+1 FROM x RIGHT JOIN y ON x.n = y.a WHERE n < 10) +SELECT * FROM x +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (...) SELECT * FROM x" +== 134 +-- truncate_limit: 100 +-- FULL JOIN +WITH RECURSIVE x(n) AS (SELECT a FROM y WHERE a = 1 + UNION ALL + SELECT x.n+1 FROM x FULL JOIN y ON x.n = y.a WHERE n < 10) +SELECT * FROM x +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "x" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (...) SELECT * FROM x" +== 135 +-- truncate_limit: 100 +-- subquery +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM x + WHERE n IN (SELECT * FROM x)) + SELECT * FROM x +-- +CTE: "x" +FILTER: schema="" table="" column="n" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM x WHERE ...) SELECT * FROM x" +== 136 +-- truncate_limit: 100 +-- aggregate functions +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT count(*) FROM x) + SELECT * FROM x +-- +CTE: "x" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT count(*) FROM x) SELECT * FROM x" +== 137 +-- truncate_limit: 100 +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT sum(n) FROM x) + SELECT * FROM x +-- +CTE: "x" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT sum(n) FROM x) SELECT * FROM x" +== 138 +-- truncate_limit: 100 +-- ORDER BY +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM x ORDER BY 1) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM x ORDER BY 1) SELECT * FROM x" +== 139 +-- truncate_limit: 100 +-- LIMIT/OFFSET +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM x LIMIT 10 OFFSET 1) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM x LIMIT 10 OFFSET 1) SELECT * FROM x" +== 140 +-- truncate_limit: 100 +-- FOR UPDATE +WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM x FOR UPDATE) + SELECT * FROM x +-- +CTE: "x" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM x FOR UPDATE) SELECT * FROM x" +== 141 +-- truncate_limit: 100 +-- target list has a recursive query name +WITH RECURSIVE x(id) AS (values (1) + UNION ALL + SELECT (SELECT * FROM x) FROM x WHERE id < 5 +) SELECT * FROM x +-- +CTE: "x" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(id) AS (VALUES (1) UNION ALL SELECT ... FROM x WHERE id < 5) SELECT * FROM x" +== 142 +-- truncate_limit: 100 +-- mutual recursive query (not implemented) +WITH RECURSIVE + x (id) AS (SELECT 1 UNION ALL SELECT id+1 FROM y WHERE id < 5), + y (id) AS (SELECT 1 UNION ALL SELECT id+1 FROM x WHERE id < 5) +SELECT * FROM x +-- +CTE: "x" +CTE: "y" +FILTER: schema="" table="" column="id" +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE x(id) AS (...), y(id) AS (...) SELECT * FROM x" +== 143 +-- truncate_limit: 100 +-- non-linear recursion is not allowed +WITH RECURSIVE foo(i) AS + (values (1) + UNION ALL + (SELECT i+1 FROM foo WHERE i < 10 + UNION ALL + SELECT i+1 FROM foo WHERE i < 5) +) SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(i) AS (...) SELECT * FROM foo" +== 144 +-- truncate_limit: 100 +WITH RECURSIVE foo(i) AS + (values (1) + UNION ALL + SELECT * FROM + (SELECT i+1 FROM foo WHERE i < 10 + UNION ALL + SELECT i+1 FROM foo WHERE i < 5) AS t +) SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(i) AS (...) SELECT * FROM foo" +== 145 +-- truncate_limit: 100 +WITH RECURSIVE foo(i) AS + (values (1) + UNION ALL + (SELECT i+1 FROM foo WHERE i < 10 + EXCEPT + SELECT i+1 FROM foo WHERE i < 5) +) SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(i) AS (...) SELECT * FROM foo" +== 146 +-- truncate_limit: 100 +WITH RECURSIVE foo(i) AS + (values (1) + UNION ALL + (SELECT i+1 FROM foo WHERE i < 10 + INTERSECT + SELECT i+1 FROM foo WHERE i < 5) +) SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(i) AS (...) SELECT * FROM foo" +== 147 +-- truncate_limit: 100 +-- Wrong type induced from non-recursive term +WITH RECURSIVE foo(i) AS + (SELECT i FROM (VALUES(1),(2)) t(i) + UNION ALL + SELECT (i+1)::numeric(10,0) FROM foo WHERE i < 10) +SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(i) AS (...) SELECT * FROM foo" +== 148 +-- truncate_limit: 100 +-- rejects different typmod, too (should we allow this?) +WITH RECURSIVE foo(i) AS + (SELECT i::numeric(3,0) FROM (VALUES(1),(2)) t(i) + UNION ALL + SELECT (i+1)::numeric(10,0) FROM foo WHERE i < 10) +SELECT * FROM foo +-- +CTE: "foo" +FILTER: schema="" table="" column="i" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE foo(i) AS (...) SELECT * FROM foo" +== 149 +-- truncate_limit: 100 +-- disallow OLD/NEW reference in CTE +CREATE TEMPORARY TABLE x (n integer) +-- +TABLE: name="x" schema="" table="x" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE x (n int)" +== 150 +-- truncate_limit: 100 +CREATE RULE r2 AS ON UPDATE TO x DO INSTEAD + WITH t AS (SELECT OLD.*) UPDATE y SET a = t.n FROM t +-- +TABLE: name="x" schema="" table="x" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE r2 AS ON UPDATE TO x DO INSTEAD WITH t AS (SELECT old.*) UPDATE y SET a = t.n FROM t" +== 151 +-- truncate_limit: 100 +|-- +-- test for bug #4902 +|-- +with cte(foo) as ( values(42) ) values((select foo from cte)) +-- +CTE: "cte" +STMT: SelectStmt +TRUNCATED: "WITH cte(foo) AS (VALUES (42)) VALUES ((SELECT foo FROM cte))" +== 152 +-- truncate_limit: 100 +with cte(foo) as ( select 42 ) select * from ((select foo from cte)) q +-- +CTE: "cte" +STMT: SelectStmt +TRUNCATED: "WITH cte(foo) AS (SELECT 42) SELECT * FROM (SELECT foo FROM cte) q" +== 153 +-- truncate_limit: 100 +-- test CTE referencing an outer-level variable (to see that changed-parameter +-- signaling still works properly after fixing this bug) +select ( with cte(foo) as ( values(f1) ) + select (select foo from cte) ) +from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "cte" +STMT: SelectStmt +TRUNCATED: "SELECT (WITH cte(foo) AS (VALUES (f1)) SELECT (SELECT foo FROM cte)) FROM int4_tbl" +== 154 +-- truncate_limit: 100 +select ( with cte(foo) as ( values(f1) ) + values((select foo from cte)) ) +from int4_tbl +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +CTE: "cte" +STMT: SelectStmt +TRUNCATED: "SELECT (WITH cte(foo) AS (VALUES (f1)) VALUES ((SELECT foo FROM cte))) FROM int4_tbl" +== 155 +-- truncate_limit: 100 +|-- +-- test for bug #19055: interaction of WITH with aggregates +|-- +-- The reference to cte1 must determine the aggregate's level, +-- even though it contains no Vars referencing cte1 +explain (verbose, costs off) +select f1, (with cte1(x,y) as (select 1,2) + select count((select i4.f1 from cte1))) as ss +from int4_tbl i4 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +CTE: "cte1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT f1, (WITH cte1(x, y) AS (SELECT 1, 2) SELECT count((SELECT i4..." +== 156 +-- truncate_limit: 100 +select f1, (with cte1(x,y) as (select 1,2) + select count((select i4.f1 from cte1))) as ss +from int4_tbl i4 +-- +TABLE: name="int4_tbl" schema="" table="int4_tbl" ctx=Select +ALIAS: "i4"="int4_tbl" +CTE: "cte1" +FUNCTION: name="count" function="count" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT f1, (WITH cte1(x, y) AS (...) SELECT count((SELECT ... FROM cte1))) AS ss FROM int4_tbl i4" +== 157 +-- truncate_limit: 100 +|-- +-- test for nested-recursive-WITH bug +|-- +WITH RECURSIVE t(j) AS ( + WITH RECURSIVE s(i) AS ( + VALUES (1) + UNION ALL + SELECT i+1 FROM s WHERE i < 10 + ) + SELECT i FROM s + UNION ALL + SELECT j+1 FROM t WHERE j < 10 +) +SELECT * FROM t +-- +CTE: "t" +CTE: "s" +FILTER: schema="" table="" column="i" +FILTER: schema="" table="" column="j" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE t(j) AS (...) SELECT * FROM t" +== 158 +-- truncate_limit: 100 +|-- +-- test WITH attached to intermediate-level set operation +|-- + +WITH outermost(x) AS ( + SELECT 1 + UNION (WITH innermost as (SELECT 2) + SELECT * FROM innermost + UNION SELECT 3) +) +SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost" +STMT: SelectStmt +TRUNCATED: "WITH outermost(x) AS (...) SELECT * FROM outermost ORDER BY 1" +== 159 +-- truncate_limit: 100 +WITH outermost(x) AS ( + SELECT 1 + UNION (WITH innermost as (SELECT 2) + SELECT * FROM outermost -- fail + UNION SELECT * FROM innermost) +) +SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost" +STMT: SelectStmt +TRUNCATED: "WITH outermost(x) AS (...) SELECT * FROM outermost ORDER BY 1" +== 160 +-- truncate_limit: 100 +WITH RECURSIVE outermost(x) AS ( + SELECT 1 + UNION (WITH innermost as (SELECT 2) + SELECT * FROM outermost + UNION SELECT * FROM innermost) +) +SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE outermost(x) AS (...) SELECT * FROM outermost ORDER BY 1" +== 161 +-- truncate_limit: 100 +WITH RECURSIVE outermost(x) AS ( + WITH innermost as (SELECT 2 FROM outermost) -- fail + SELECT * FROM innermost + UNION SELECT * from outermost +) +SELECT * FROM outermost ORDER BY 1 +-- +CTE: "outermost" +CTE: "innermost" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE outermost(x) AS (...) SELECT * FROM outermost ORDER BY 1" +== 162 +-- truncate_limit: 100 +|-- +-- This test will fail with the old implementation of PARAM_EXEC parameter +-- assignment, because the "q1" Var passed down to A's targetlist subselect +-- looks exactly like the "A.id" Var passed down to C's subselect, causing +-- the old code to give them the same runtime PARAM_EXEC slot. But the +-- lifespans of the two parameters overlap, thanks to B also reading A. +|-- + +with +A as ( select q2 as id, (select q1) as x from int8_tbl ), +B as ( select id, row_number() over (partition by id) as r from A ), +C as ( select A.id, array(select B.id from B where B.id = A.id) from A ) +select * from C +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +CTE: "a" +CTE: "b" +CTE: "c" +FUNCTION: name="row_number" function="row_number" schema="" ctx=Call +FILTER: schema="" table="b" column="id" +FILTER: schema="" table="a" column="id" +STMT: SelectStmt +TRUNCATED: "WITH a AS (SELECT ... FROM int8_tbl), b AS (SELECT ... FROM a), c AS (...) SELECT * FROM c" +== 163 +-- truncate_limit: 100 +|-- +-- Test CTEs read in non-initialization orders +|-- + +WITH RECURSIVE + tab(id_key,link) AS (VALUES (1,17), (2,17), (3,17), (4,17), (6,17), (5,17)), + iter (id_key, row_type, link) AS ( + SELECT 0, 'base', 17 + UNION ALL ( + WITH remaining(id_key, row_type, link, min) AS ( + SELECT tab.id_key, 'true'::text, iter.link, MIN(tab.id_key) OVER () + FROM tab INNER JOIN iter USING (link) + WHERE tab.id_key > iter.id_key + ), + first_remaining AS ( + SELECT id_key, row_type, link + FROM remaining + WHERE id_key=min + ), + effect AS ( + SELECT tab.id_key, 'new'::text, tab.link + FROM first_remaining e INNER JOIN tab ON e.id_key=tab.id_key + WHERE e.row_type = 'false' + ) + SELECT * FROM first_remaining + UNION ALL SELECT * FROM effect + ) + ) +SELECT * FROM iter +-- +ALIAS: "e"="first_remaining" +CTE: "tab" +CTE: "iter" +CTE: "remaining" +CTE: "first_remaining" +CTE: "effect" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="tab" column="id_key" +FILTER: schema="" table="iter" column="id_key" +FILTER: schema="" table="" column="id_key" +FILTER: schema="" table="" column="min" +FILTER: schema="" table="e" column="row_type" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE tab(id_key, link) AS (...), iter(id_key, row_type, link) AS (...) SELECT * FROM iter" +== 164 +-- truncate_limit: 100 +WITH RECURSIVE + tab(id_key,link) AS (VALUES (1,17), (2,17), (3,17), (4,17), (6,17), (5,17)), + iter (id_key, row_type, link) AS ( + SELECT 0, 'base', 17 + UNION ( + WITH remaining(id_key, row_type, link, min) AS ( + SELECT tab.id_key, 'true'::text, iter.link, MIN(tab.id_key) OVER () + FROM tab INNER JOIN iter USING (link) + WHERE tab.id_key > iter.id_key + ), + first_remaining AS ( + SELECT id_key, row_type, link + FROM remaining + WHERE id_key=min + ), + effect AS ( + SELECT tab.id_key, 'new'::text, tab.link + FROM first_remaining e INNER JOIN tab ON e.id_key=tab.id_key + WHERE e.row_type = 'false' + ) + SELECT * FROM first_remaining + UNION ALL SELECT * FROM effect + ) + ) +SELECT * FROM iter +-- +ALIAS: "e"="first_remaining" +CTE: "tab" +CTE: "iter" +CTE: "remaining" +CTE: "first_remaining" +CTE: "effect" +FUNCTION: name="min" function="min" schema="" ctx=Call +FILTER: schema="" table="tab" column="id_key" +FILTER: schema="" table="iter" column="id_key" +FILTER: schema="" table="" column="id_key" +FILTER: schema="" table="" column="min" +FILTER: schema="" table="e" column="row_type" +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE tab(id_key, link) AS (...), iter(id_key, row_type, link) AS (...) SELECT * FROM iter" +== 165 +-- truncate_limit: 100 +|-- +-- Data-modifying statements in WITH +|-- + +-- INSERT ... RETURNING +WITH t AS ( + INSERT INTO y + VALUES + (11), + (12), + (13), + (14), + (15), + (16), + (17), + (18), + (19), + (20) + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (...) RETURNING *) SELECT * FROM t" +== 166 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 167 +-- truncate_limit: 100 +-- UPDATE ... RETURNING +WITH t AS ( + UPDATE y + SET a=a+1 + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: UpdateStmt +TRUNCATED: "WITH t AS (UPDATE y SET a = a + 1 RETURNING *) SELECT * FROM t" +== 168 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 169 +-- truncate_limit: 100 +-- DELETE ... RETURNING +WITH t AS ( + DELETE FROM y + WHERE a <= 10 + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: DeleteStmt +TRUNCATED: "WITH t AS (DELETE FROM y WHERE a <= 10 RETURNING *) SELECT * FROM t" +== 170 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 171 +-- truncate_limit: 100 +-- forward reference +WITH RECURSIVE t AS ( + INSERT INTO y + SELECT a+5 FROM t2 WHERE a > 5 + RETURNING * +), t2 AS ( + UPDATE y SET a=a-11 RETURNING * +) +SELECT * FROM t +UNION ALL +SELECT * FROM t2 +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +CTE: "t2" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +STMT: InsertStmt +STMT: UpdateStmt +TRUNCATED: "WITH RECURSIVE t AS (...), t2 AS (...) SELECT * FROM t UNION ALL SELECT * FROM t2" +== 172 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 173 +-- truncate_limit: 100 +-- unconditional DO INSTEAD rule +CREATE RULE y_rule AS ON DELETE TO y DO INSTEAD + INSERT INTO y VALUES(42) RETURNING * +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE y_rule AS ON DELETE TO y DO INSTEAD INSERT INTO y VALUES (42) RETURNING *" +== 174 +-- truncate_limit: 100 +WITH t AS ( + DELETE FROM y RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: DeleteStmt +TRUNCATED: "WITH t AS (DELETE FROM y RETURNING *) SELECT * FROM t" +== 175 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 176 +-- truncate_limit: 100 +DROP RULE y_rule ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE y_rule ON y" +== 177 +-- truncate_limit: 100 +-- check merging of outer CTE with CTE in a rule action +CREATE TEMP TABLE bug6051 AS + select i from generate_series(1,3) as t(i) +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE bug6051 AS SELECT i FROM generate_series(1, 3) t(i)" +== 178 +-- truncate_limit: 100 +SELECT * FROM bug6051 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bug6051" +== 179 +-- truncate_limit: 100 +WITH t1 AS ( DELETE FROM bug6051 RETURNING * ) +INSERT INTO bug6051 SELECT * FROM t1 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +CTE: "t1" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +TRUNCATED: "WITH t1 AS (DELETE FROM bug6051 RETURNING *) INSERT INTO bug6051 SELECT * FROM t1" +== 180 +-- truncate_limit: 100 +SELECT * FROM bug6051 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bug6051" +== 181 +-- truncate_limit: 100 +CREATE TEMP TABLE bug6051_2 (i int) +-- +TABLE: name="bug6051_2" schema="" table="bug6051_2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE bug6051_2 (i int)" +== 182 +-- truncate_limit: 100 +CREATE RULE bug6051_ins AS ON INSERT TO bug6051 DO INSTEAD + INSERT INTO bug6051_2 + VALUES(NEW.i) +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE bug6051_ins AS ON INSERT TO bug6051 DO INSTEAD INSERT INTO bug6051_2 VALUES (new.i)" +== 183 +-- truncate_limit: 100 +WITH t1 AS ( DELETE FROM bug6051 RETURNING * ) +INSERT INTO bug6051 SELECT * FROM t1 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +CTE: "t1" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +TRUNCATED: "WITH t1 AS (DELETE FROM bug6051 RETURNING *) INSERT INTO bug6051 SELECT * FROM t1" +== 184 +-- truncate_limit: 100 +SELECT * FROM bug6051 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bug6051" +== 185 +-- truncate_limit: 100 +SELECT * FROM bug6051_2 +-- +TABLE: name="bug6051_2" schema="" table="bug6051_2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bug6051_2" +== 186 +-- truncate_limit: 100 +-- check INSERT ... SELECT rule actions are disallowed on commands +-- that have modifyingCTEs +CREATE OR REPLACE RULE bug6051_ins AS ON INSERT TO bug6051 DO INSTEAD + INSERT INTO bug6051_2 + SELECT NEW.i +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE bug6051_ins AS ON INSERT TO bug6051 DO INSTEAD INSERT INTO bug6051_2 SELEC..." +== 187 +-- truncate_limit: 100 +WITH t1 AS ( DELETE FROM bug6051 RETURNING * ) +INSERT INTO bug6051 SELECT * FROM t1 +-- +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +TABLE: name="bug6051" schema="" table="bug6051" ctx=DML +CTE: "t1" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +TRUNCATED: "WITH t1 AS (DELETE FROM bug6051 RETURNING *) INSERT INTO bug6051 SELECT * FROM t1" +== 188 +-- truncate_limit: 100 +-- silly example to verify that hasModifyingCTE flag is propagated +CREATE TEMP TABLE bug6051_3 AS + SELECT a FROM generate_series(11,13) AS a +-- +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TEMPORARY TABLE bug6051_3 AS SELECT a FROM generate_series(11, 13) a" +== 189 +-- truncate_limit: 100 +CREATE RULE bug6051_3_ins AS ON INSERT TO bug6051_3 DO INSTEAD + SELECT i FROM bug6051_2 +-- +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE bug6051_3_ins AS ON INSERT TO bug6051_3 DO INSTEAD SELECT i FROM bug6051_2" +== 190 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 191 +-- truncate_limit: 100 +SET LOCAL debug_parallel_query = on +-- +STMT: VariableSetStmt +TRUNCATED: "SET LOCAL debug_parallel_query TO ON" +== 192 +-- truncate_limit: 100 +WITH t1 AS ( DELETE FROM bug6051_3 RETURNING * ) + INSERT INTO bug6051_3 SELECT * FROM t1 +-- +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=DML +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=DML +CTE: "t1" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +TRUNCATED: "WITH t1 AS (DELETE FROM bug6051_3 RETURNING *) INSERT INTO bug6051_3 SELECT * FROM t1" +== 193 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 194 +-- truncate_limit: 100 +SELECT * FROM bug6051_3 +-- +TABLE: name="bug6051_3" schema="" table="bug6051_3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM bug6051_3" +== 195 +-- truncate_limit: 100 +-- check case where CTE reference is removed due to optimization +EXPLAIN (VERBOSE, COSTS OFF) +SELECT q1 FROM +( + WITH t_cte AS (SELECT * FROM int8_tbl t) + SELECT q1, (SELECT q2 FROM t_cte WHERE t_cte.q1 = i8.q1) AS t_sub + FROM int8_tbl i8 +) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="int8_tbl" +CTE: "t_cte" +FILTER: schema="" table="t_cte" column="q1" +FILTER: schema="" table="i8" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT q1 FROM (WITH t_cte AS (SELECT * FROM int8_tbl t) SELECT q1, ..." +== 196 +-- truncate_limit: 100 +SELECT q1 FROM +( + WITH t_cte AS (SELECT * FROM int8_tbl t) + SELECT q1, (SELECT q2 FROM t_cte WHERE t_cte.q1 = i8.q1) AS t_sub + FROM int8_tbl i8 +) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="int8_tbl" +CTE: "t_cte" +FILTER: schema="" table="t_cte" column="q1" +FILTER: schema="" table="i8" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM (WITH t_cte AS (...) SELECT ... FROM int8_tbl i8) ss" +== 197 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT q1 FROM +( + WITH t_cte AS MATERIALIZED (SELECT * FROM int8_tbl t) + SELECT q1, (SELECT q2 FROM t_cte WHERE t_cte.q1 = i8.q1) AS t_sub + FROM int8_tbl i8 +) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="int8_tbl" +CTE: "t_cte" +FILTER: schema="" table="t_cte" column="q1" +FILTER: schema="" table="i8" column="q1" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT q1 FROM (WITH t_cte AS MATERIALIZED (SELECT * FROM int8_tbl t..." +== 198 +-- truncate_limit: 100 +SELECT q1 FROM +( + WITH t_cte AS MATERIALIZED (SELECT * FROM int8_tbl t) + SELECT q1, (SELECT q2 FROM t_cte WHERE t_cte.q1 = i8.q1) AS t_sub + FROM int8_tbl i8 +) ss +-- +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=Select +ALIAS: "i8"="int8_tbl" +ALIAS: "t"="int8_tbl" +CTE: "t_cte" +FILTER: schema="" table="t_cte" column="q1" +FILTER: schema="" table="i8" column="q1" +STMT: SelectStmt +TRUNCATED: "SELECT q1 FROM (WITH t_cte AS MATERIALIZED (...) SELECT ... FROM int8_tbl i8) ss" +== 199 +-- truncate_limit: 100 +-- a truly recursive CTE in the same list +WITH RECURSIVE t(a) AS ( + SELECT 0 + UNION ALL + SELECT a+1 FROM t WHERE a+1 < 5 +), t2 as ( + INSERT INTO y + SELECT * FROM t RETURNING * +) +SELECT * FROM t2 JOIN y USING (a) ORDER BY a +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +CTE: "t2" +FILTER: schema="" table="" column="a" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH RECURSIVE t(a) AS (...), t2 AS (...) SELECT * FROM t2 JOIN y USING (a) ORDER BY a" +== 200 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 201 +-- truncate_limit: 100 +-- data-modifying WITH in a modifying statement +WITH t AS ( + DELETE FROM y + WHERE a <= 10 + RETURNING * +) +INSERT INTO y SELECT -a FROM t RETURNING * +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: InsertStmt +STMT: SelectStmt +STMT: DeleteStmt +TRUNCATED: "WITH t AS (DELETE FROM y WHERE a <= 10 RETURNING *) INSERT INTO y SELECT - a FROM t RETURNING *" +== 202 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 203 +-- truncate_limit: 100 +-- check that WITH query is run to completion even if outer query isn't +WITH t AS ( + UPDATE y SET a = a * 100 RETURNING * +) +SELECT * FROM t LIMIT 10 +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: UpdateStmt +TRUNCATED: "WITH t AS (UPDATE y SET a = a * 100 RETURNING *) SELECT * FROM t LIMIT 10" +== 204 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 205 +-- truncate_limit: 100 +-- data-modifying WITH containing INSERT...ON CONFLICT DO UPDATE +CREATE TABLE withz AS SELECT i AS k, (i || ' v')::text v FROM generate_series(1, 16, 3) i +-- +TABLE: name="withz" schema="" table="withz" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE withz AS SELECT i AS k, (i || ' v')::text AS v FROM generate_series(1, 16, 3) i" +== 206 +-- truncate_limit: 100 +ALTER TABLE withz ADD UNIQUE (k) +-- +TABLE: name="withz" schema="" table="withz" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE withz ADD UNIQUE (k)" +== 207 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO withz SELECT i, 'insert' + FROM generate_series(0, 16) i + ON CONFLICT (k) DO UPDATE SET v = withz.v || ', now update' + RETURNING * +) +SELECT * FROM t JOIN y ON t.k = y.a ORDER BY a, k +-- +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "t" +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (...) SELECT * FROM t JOIN y ON t.k = y.a ORDER BY a, k" +== 208 +-- truncate_limit: 100 +-- Test EXCLUDED.* reference within CTE +WITH aa AS ( + INSERT INTO withz VALUES(1, 5) ON CONFLICT (k) DO UPDATE SET v = EXCLUDED.v + WHERE withz.k != EXCLUDED.k + RETURNING * +) +SELECT * FROM aa +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH aa AS (...) SELECT * FROM aa" +== 209 +-- truncate_limit: 100 +-- New query/snapshot demonstrates side-effects of previous query. +SELECT * FROM withz ORDER BY k +-- +TABLE: name="withz" schema="" table="withz" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM withz ORDER BY k" +== 210 +-- truncate_limit: 100 +|-- +-- Ensure subqueries within the update clause work, even if they +-- reference outside values +|-- +WITH aa AS (SELECT 1 a, 2 b) +INSERT INTO withz VALUES(1, 'insert') +ON CONFLICT (k) DO UPDATE SET v = (SELECT b || ' update' FROM aa WHERE a = 1 LIMIT 1) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aa AS (...) INSERT INTO withz VALUES (1, 'insert') ON CONFLICT (k) DO UPDATE SET ... = ..." +== 211 +-- truncate_limit: 100 +WITH aa AS (SELECT 1 a, 2 b) +INSERT INTO withz VALUES(1, 'insert') +ON CONFLICT (k) DO UPDATE SET v = ' update' WHERE withz.k = (SELECT a FROM aa) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aa AS (...) INSERT INTO withz VALUES (...) ON CONFLICT (k) DO UPDATE SET ... = ... WHERE ..." +== 212 +-- truncate_limit: 100 +WITH aa AS (SELECT 1 a, 2 b) +INSERT INTO withz VALUES(1, 'insert') +ON CONFLICT (k) DO UPDATE SET v = (SELECT b || ' update' FROM aa WHERE a = 1 LIMIT 1) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aa AS (...) INSERT INTO withz VALUES (1, 'insert') ON CONFLICT (k) DO UPDATE SET ... = ..." +== 213 +-- truncate_limit: 100 +WITH aa AS (SELECT 'a' a, 'b' b UNION ALL SELECT 'a' a, 'b' b) +INSERT INTO withz VALUES(1, 'insert') +ON CONFLICT (k) DO UPDATE SET v = (SELECT b || ' update' FROM aa WHERE a = 'a' LIMIT 1) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aa AS (...) INSERT INTO withz VALUES (1, 'insert') ON CONFLICT (k) DO UPDATE SET ... = ..." +== 214 +-- truncate_limit: 100 +WITH aa AS (SELECT 1 a, 2 b) +INSERT INTO withz VALUES(1, (SELECT b || ' insert' FROM aa WHERE a = 1 )) +ON CONFLICT (k) DO UPDATE SET v = (SELECT b || ' update' FROM aa WHERE a = 1 LIMIT 1) +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "aa" +FILTER: schema="" table="" column="a" +FILTER: schema="" table="" column="a" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH aa AS (...) INSERT INTO withz VALUES (...) ON CONFLICT (k) DO UPDATE SET ... = ..." +== 215 +-- truncate_limit: 100 +-- Update a row more than once, in different parts of a wCTE. That is +-- an allowed, presumably very rare, edge case, but since it was +-- broken in the past, having a test seems worthwhile. +WITH simpletup AS ( + SELECT 2 k, 'Green' v), +upsert_cte AS ( + INSERT INTO withz VALUES(2, 'Blue') ON CONFLICT (k) DO + UPDATE SET (k, v) = (SELECT k, v FROM simpletup WHERE simpletup.k = withz.k) + RETURNING k, v) +INSERT INTO withz VALUES(2, 'Red') ON CONFLICT (k) DO +UPDATE SET (k, v) = (SELECT k, v FROM upsert_cte WHERE upsert_cte.k = withz.k) +RETURNING k, v +-- +TABLE: name="withz" schema="" table="withz" ctx=DML +TABLE: name="withz" schema="" table="withz" ctx=DML +CTE: "simpletup" +CTE: "upsert_cte" +FILTER: schema="" table="upsert_cte" column="k" +FILTER: schema="" table="withz" column="k" +FILTER: schema="" table="upsert_cte" column="k" +FILTER: schema="" table="withz" column="k" +FILTER: schema="" table="simpletup" column="k" +FILTER: schema="" table="withz" column="k" +FILTER: schema="" table="simpletup" column="k" +FILTER: schema="" table="withz" column="k" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH simpletup AS (...), upsert_cte AS (...) INSERT INTO withz VALUES (...) ON CONFLICT (k) DO UP..." +== 216 +-- truncate_limit: 100 +DROP TABLE withz +-- +TABLE: name="withz" schema="" table="withz" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE withz" +== 217 +-- truncate_limit: 100 +-- WITH referenced by MERGE statement +CREATE TABLE m AS SELECT i AS k, (i || ' v')::text v FROM generate_series(1, 16, 3) i +-- +TABLE: name="m" schema="" table="m" ctx=DDL +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE m AS SELECT i AS k, (i || ' v')::text AS v FROM generate_series(1, 16, 3) i" +== 218 +-- truncate_limit: 100 +ALTER TABLE m ADD UNIQUE (k) +-- +TABLE: name="m" schema="" table="m" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE m ADD UNIQUE (k)" +== 219 +-- truncate_limit: 100 +WITH RECURSIVE cte_basic AS (SELECT 1 a, 'cte_basic val' b) +MERGE INTO m USING (select 0 k, 'merge source SubPlan' v) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_basic" +FILTER: schema="" table="cte_basic" column="a" +FILTER: schema="" table="m" column="k" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "WITH RECURSIVE cte_basic AS (...) MERGE INTO m USING (SELECT ...) o ON m.k = o.k WHEN MATCHED THE..." +== 220 +-- truncate_limit: 100 +-- Basic: +WITH cte_basic AS MATERIALIZED (SELECT 1 a, 'cte_basic val' b) +MERGE INTO m USING (select 0 k, 'merge source SubPlan' v offset 0) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_basic" +FILTER: schema="" table="cte_basic" column="a" +FILTER: schema="" table="m" column="k" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "WITH cte_basic AS MATERIALIZED (...) MERGE INTO m USING (SELECT ... OFFSET 0) o ON m.k = o.k WHEN..." +== 221 +-- truncate_limit: 100 +-- Examine +SELECT * FROM m where k = 0 +-- +TABLE: name="m" schema="" table="m" ctx=Select +FILTER: schema="" table="" column="k" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM m WHERE k = 0" +== 222 +-- truncate_limit: 100 +-- See EXPLAIN output for same query: +EXPLAIN (VERBOSE, COSTS OFF) +WITH cte_basic AS MATERIALIZED (SELECT 1 a, 'cte_basic val' b) +MERGE INTO m USING (select 0 k, 'merge source SubPlan' v offset 0) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_basic WHERE cte_basic.a = m.k LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_basic" +FILTER: schema="" table="cte_basic" column="a" +FILTER: schema="" table="m" column="k" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH cte_basic AS MATERIALIZED (SELECT 1 AS a, 'cte_basic val' AS b)..." +== 223 +-- truncate_limit: 100 +-- InitPlan +WITH cte_init AS MATERIALIZED (SELECT 1 a, 'cte_init val' b) +MERGE INTO m USING (select 1 k, 'merge source InitPlan' v offset 0) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_init WHERE a = 1 LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_init" +FILTER: schema="" table="" column="a" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "WITH cte_init AS MATERIALIZED (...) MERGE INTO m USING (SELECT ... OFFSET 0) o ON m.k = o.k WHEN ..." +== 224 +-- truncate_limit: 100 +-- Examine +SELECT * FROM m where k = 1 +-- +TABLE: name="m" schema="" table="m" ctx=Select +FILTER: schema="" table="" column="k" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM m WHERE k = 1" +== 225 +-- truncate_limit: 100 +-- See EXPLAIN output for same query: +EXPLAIN (VERBOSE, COSTS OFF) +WITH cte_init AS MATERIALIZED (SELECT 1 a, 'cte_init val' b) +MERGE INTO m USING (select 1 k, 'merge source InitPlan' v offset 0) o ON m.k=o.k +WHEN MATCHED THEN UPDATE SET v = (SELECT b || ' merge update' FROM cte_init WHERE a = 1 LIMIT 1) +WHEN NOT MATCHED THEN INSERT VALUES(o.k, o.v) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "cte_init" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH cte_init AS MATERIALIZED (SELECT 1 AS a, 'cte_init val' AS b) M..." +== 226 +-- truncate_limit: 100 +-- MERGE source comes from CTE: +WITH merge_source_cte AS MATERIALIZED (SELECT 15 a, 'merge_source_cte val' b) +MERGE INTO m USING (select * from merge_source_cte) o ON m.k=o.a +WHEN MATCHED THEN UPDATE SET v = (SELECT b || merge_source_cte.*::text || ' merge update' FROM merge_source_cte WHERE a = 15) +WHEN NOT MATCHED THEN INSERT VALUES(o.a, o.b || (SELECT merge_source_cte.*::text || ' merge insert' FROM merge_source_cte)) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "merge_source_cte" +FILTER: schema="" table="" column="a" +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "WITH merge_source_cte AS MATERIALIZED (...) MERGE INTO m USING (SELECT * FROM merge_source_cte) o..." +== 227 +-- truncate_limit: 100 +-- Examine +SELECT * FROM m where k = 15 +-- +TABLE: name="m" schema="" table="m" ctx=Select +FILTER: schema="" table="" column="k" +STMT: SelectStmt +TRUNCATED: "SELECT * FROM m WHERE k = 15" +== 228 +-- truncate_limit: 100 +-- See EXPLAIN output for same query: +EXPLAIN (VERBOSE, COSTS OFF) +WITH merge_source_cte AS MATERIALIZED (SELECT 15 a, 'merge_source_cte val' b) +MERGE INTO m USING (select * from merge_source_cte) o ON m.k=o.a +WHEN MATCHED THEN UPDATE SET v = (SELECT b || merge_source_cte.*::text || ' merge update' FROM merge_source_cte WHERE a = 15) +WHEN NOT MATCHED THEN INSERT VALUES(o.a, o.b || (SELECT merge_source_cte.*::text || ' merge insert' FROM merge_source_cte)) +-- +TABLE: name="m" schema="" table="m" ctx=DML +CTE: "merge_source_cte" +FILTER: schema="" table="" column="a" +STMT: ExplainStmt +STMT: MergeStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH merge_source_cte AS MATERIALIZED (SELECT 15 AS a, 'merge_source..." +== 229 +-- truncate_limit: 100 +DROP TABLE m +-- +TABLE: name="m" schema="" table="m" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE m" +== 230 +-- truncate_limit: 100 +-- check that run to completion happens in proper ordering + +TRUNCATE TABLE y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE y" +== 231 +-- truncate_limit: 100 +INSERT INTO y SELECT generate_series(1, 3) +-- +TABLE: name="y" schema="" table="y" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y SELECT generate_series(1, 3)" +== 232 +-- truncate_limit: 100 +CREATE TEMPORARY TABLE yy (a INTEGER) +-- +TABLE: name="yy" schema="" table="yy" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE yy (a int)" +== 233 +-- truncate_limit: 100 +WITH RECURSIVE t1 AS ( + INSERT INTO y SELECT * FROM y RETURNING * +), t2 AS ( + INSERT INTO yy SELECT * FROM t1 RETURNING * +) +SELECT 1 +-- +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=Select +TABLE: name="yy" schema="" table="yy" ctx=DML +CTE: "t1" +CTE: "t2" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH RECURSIVE t1 AS (INSERT INTO y SELECT * FROM y RETURNING *), t2 AS (...) SELECT 1" +== 234 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 235 +-- truncate_limit: 100 +SELECT * FROM yy +-- +TABLE: name="yy" schema="" table="yy" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM yy" +== 236 +-- truncate_limit: 100 +WITH RECURSIVE t1 AS ( + INSERT INTO yy SELECT * FROM t2 RETURNING * +), t2 AS ( + INSERT INTO y SELECT * FROM y RETURNING * +) +SELECT 1 +-- +TABLE: name="yy" schema="" table="yy" ctx=DML +TABLE: name="y" schema="" table="y" ctx=DML +TABLE: name="y" schema="" table="y" ctx=Select +CTE: "t1" +CTE: "t2" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH RECURSIVE t1 AS (...), t2 AS (INSERT INTO y SELECT * FROM y RETURNING *) SELECT 1" +== 237 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 238 +-- truncate_limit: 100 +SELECT * FROM yy +-- +TABLE: name="yy" schema="" table="yy" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM yy" +== 239 +-- truncate_limit: 100 +-- triggers + +TRUNCATE TABLE y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: TruncateStmt +TRUNCATED: "TRUNCATE y" +== 240 +-- truncate_limit: 100 +INSERT INTO y SELECT generate_series(1, 10) +-- +TABLE: name="y" schema="" table="y" ctx=DML +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO y SELECT generate_series(1, 10)" +== 241 +-- truncate_limit: 100 +CREATE FUNCTION y_trigger() RETURNS trigger AS $$ +begin + raise notice 'y_trigger: a = %', new.a; + return new; +end; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="y_trigger" function="y_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION y_trigger() RETURNS trigger AS $$\nbegin\n raise notice 'y_trigger: a = %', new.a;..." +== 242 +-- truncate_limit: 100 +CREATE TRIGGER y_trig BEFORE INSERT ON y FOR EACH ROW + EXECUTE PROCEDURE y_trigger() +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER y_trig BEFORE INSERT ON y FOR EACH ROW EXECUTE FUNCTION y_trigger()" +== 243 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO y + VALUES + (21), + (22), + (23) + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (21), (22), (23) RETURNING *) SELECT * FROM t" +== 244 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 245 +-- truncate_limit: 100 +DROP TRIGGER y_trig ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER y_trig ON y" +== 246 +-- truncate_limit: 100 +CREATE TRIGGER y_trig AFTER INSERT ON y FOR EACH ROW + EXECUTE PROCEDURE y_trigger() +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER y_trig AFTER INSERT ON y FOR EACH ROW EXECUTE FUNCTION y_trigger()" +== 247 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO y + VALUES + (31), + (32), + (33) + RETURNING * +) +SELECT * FROM t LIMIT 1 +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (31), (32), (33) RETURNING *) SELECT * FROM t LIMIT 1" +== 248 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 249 +-- truncate_limit: 100 +DROP TRIGGER y_trig ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER y_trig ON y" +== 250 +-- truncate_limit: 100 +CREATE OR REPLACE FUNCTION y_trigger() RETURNS trigger AS $$ +begin + raise notice 'y_trigger'; + return null; +end; +$$ LANGUAGE plpgsql +-- +FUNCTION: name="y_trigger" function="y_trigger" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE OR REPLACE FUNCTION y_trigger() RETURNS trigger AS $$\nbegin\n raise notice 'y_trigger';\n ..." +== 251 +-- truncate_limit: 100 +CREATE TRIGGER y_trig AFTER INSERT ON y FOR EACH STATEMENT + EXECUTE PROCEDURE y_trigger() +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: CreateTrigStmt +TRUNCATED: "CREATE TRIGGER y_trig AFTER INSERT ON y EXECUTE FUNCTION y_trigger()" +== 252 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO y + VALUES + (41), + (42), + (43) + RETURNING * +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (41), (42), (43) RETURNING *) SELECT * FROM t" +== 253 +-- truncate_limit: 100 +SELECT * FROM y +-- +TABLE: name="y" schema="" table="y" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM y" +== 254 +-- truncate_limit: 100 +DROP TRIGGER y_trig ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TRIGGER y_trig ON y" +== 255 +-- truncate_limit: 100 +DROP FUNCTION y_trigger() +-- +FUNCTION: name="y_trigger" function="y_trigger" schema="" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP FUNCTION y_trigger()" +== 256 +-- truncate_limit: 100 +-- WITH attached to inherited UPDATE or DELETE + +CREATE TEMP TABLE parent ( id int, val text ) +-- +TABLE: name="parent" schema="" table="parent" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE parent (id int, val text)" +== 257 +-- truncate_limit: 100 +CREATE TEMP TABLE child1 ( ) INHERITS ( parent ) +-- +TABLE: name="child1" schema="" table="child1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE child1 () INHERITS (parent)" +== 258 +-- truncate_limit: 100 +CREATE TEMP TABLE child2 ( ) INHERITS ( parent ) +-- +TABLE: name="child2" schema="" table="child2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE child2 () INHERITS (parent)" +== 259 +-- truncate_limit: 100 +INSERT INTO parent VALUES ( 1, 'p1' ) +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO parent VALUES (1, 'p1')" +== 260 +-- truncate_limit: 100 +INSERT INTO child1 VALUES ( 11, 'c11' ),( 12, 'c12' ) +-- +TABLE: name="child1" schema="" table="child1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child1 VALUES (11, 'c11'), (12, 'c12')" +== 261 +-- truncate_limit: 100 +INSERT INTO child2 VALUES ( 23, 'c21' ),( 24, 'c22' ) +-- +TABLE: name="child2" schema="" table="child2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO child2 VALUES (23, 'c21'), (24, 'c22')" +== 262 +-- truncate_limit: 100 +WITH rcte AS ( SELECT sum(id) AS totalid FROM parent ) +UPDATE parent SET id = id + totalid FROM rcte +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +TABLE: name="parent" schema="" table="parent" ctx=Select +CTE: "rcte" +FUNCTION: name="sum" function="sum" schema="" ctx=Call +STMT: UpdateStmt +STMT: SelectStmt +TRUNCATED: "WITH rcte AS (SELECT sum(id) AS totalid FROM parent) UPDATE parent SET id = id + totalid FROM rcte" +== 263 +-- truncate_limit: 100 +SELECT * FROM parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 264 +-- truncate_limit: 100 +WITH wcte AS ( INSERT INTO child1 VALUES ( 42, 'new' ) RETURNING id AS newid ) +UPDATE parent SET id = id + newid FROM wcte +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +TABLE: name="child1" schema="" table="child1" ctx=DML +CTE: "wcte" +STMT: UpdateStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH wcte AS (...) UPDATE parent SET id = id + newid FROM wcte" +== 265 +-- truncate_limit: 100 +SELECT * FROM parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 266 +-- truncate_limit: 100 +WITH rcte AS ( SELECT max(id) AS maxid FROM parent ) +DELETE FROM parent USING rcte WHERE id = maxid +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +TABLE: name="parent" schema="" table="parent" ctx=Select +CTE: "rcte" +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: DeleteStmt +STMT: SelectStmt +TRUNCATED: "WITH rcte AS (SELECT max(id) AS maxid FROM parent) DELETE FROM parent USING rcte WHERE id = maxid" +== 267 +-- truncate_limit: 100 +SELECT * FROM parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 268 +-- truncate_limit: 100 +WITH wcte AS ( INSERT INTO child2 VALUES ( 42, 'new2' ) RETURNING id AS newid ) +DELETE FROM parent USING wcte WHERE id = newid +-- +TABLE: name="parent" schema="" table="parent" ctx=DML +TABLE: name="child2" schema="" table="child2" ctx=DML +CTE: "wcte" +STMT: DeleteStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH wcte AS (...) DELETE FROM parent USING wcte WHERE id = newid" +== 269 +-- truncate_limit: 100 +SELECT * FROM parent +-- +TABLE: name="parent" schema="" table="parent" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM parent" +== 270 +-- truncate_limit: 100 +-- check EXPLAIN VERBOSE for a wCTE with RETURNING + +EXPLAIN (VERBOSE, COSTS OFF) +WITH wcte AS ( INSERT INTO int8_tbl VALUES ( 42, 47 ) RETURNING q2 ) +DELETE FROM a_star USING wcte WHERE aa = q2 +-- +TABLE: name="a_star" schema="" table="a_star" ctx=DML +TABLE: name="int8_tbl" schema="" table="int8_tbl" ctx=DML +CTE: "wcte" +STMT: ExplainStmt +STMT: DeleteStmt +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) WITH wcte AS (INSERT INTO int8_tbl VALUES (42, 47) RETURNING q2) DEL..." +== 271 +-- truncate_limit: 100 +-- error cases + +-- data-modifying WITH tries to use its own output +WITH RECURSIVE t AS ( + INSERT INTO y + SELECT * FROM t +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH RECURSIVE t AS (INSERT INTO y SELECT * FROM t) VALUES (false)" +== 272 +-- truncate_limit: 100 +-- no RETURNING in a referenced data-modifying WITH +WITH t AS ( + INSERT INTO y VALUES(0) +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (0)) SELECT * FROM t" +== 273 +-- truncate_limit: 100 +-- RETURNING tries to return its own output +WITH RECURSIVE t(action, a) AS ( + MERGE INTO y USING (VALUES (11)) v(a) ON y.a = v.a + WHEN NOT MATCHED THEN INSERT VALUES (v.a) + RETURNING merge_action(), (SELECT a FROM t) +) +SELECT * FROM t +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: MergeStmt +TRUNCATED: "WITH RECURSIVE t(action, a) AS (...) SELECT * FROM t" +== 274 +-- truncate_limit: 100 +-- data-modifying WITH allowed only at the top level +SELECT * FROM ( + WITH t AS (UPDATE y SET a=a+1 RETURNING *) + SELECT * FROM t +) ss +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: UpdateStmt +TRUNCATED: "SELECT * FROM (WITH t AS (UPDATE y SET a = a + 1 RETURNING *) SELECT * FROM t) ss" +== 275 +-- truncate_limit: 100 +-- most variants of rules aren't allowed +CREATE RULE y_rule AS ON INSERT TO y WHERE a=0 DO INSTEAD DELETE FROM y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE RULE y_rule AS ON INSERT TO y WHERE a = 0 DO INSTEAD DELETE FROM y" +== 276 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (0)) VALUES (false)" +== 277 +-- truncate_limit: 100 +CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO INSTEAD NOTHING +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO INSTEAD NOTHING" +== 278 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (0)) VALUES (false)" +== 279 +-- truncate_limit: 100 +CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO INSTEAD NOTIFY foo +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO INSTEAD NOTIFY foo" +== 280 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (0)) VALUES (false)" +== 281 +-- truncate_limit: 100 +CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO ALSO NOTIFY foo +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO NOTIFY foo" +== 282 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (0)) VALUES (false)" +== 283 +-- truncate_limit: 100 +CREATE OR REPLACE RULE y_rule AS ON INSERT TO y + DO INSTEAD (NOTIFY foo; NOTIFY bar) +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: RuleStmt +TRUNCATED: "CREATE OR REPLACE RULE y_rule AS ON INSERT TO y DO INSTEAD (NOTIFY foo; NOTIFY bar)" +== 284 +-- truncate_limit: 100 +WITH t AS ( + INSERT INTO y VALUES(0) +) +VALUES(FALSE) +-- +TABLE: name="y" schema="" table="y" ctx=DML +CTE: "t" +STMT: SelectStmt +STMT: InsertStmt +TRUNCATED: "WITH t AS (INSERT INTO y VALUES (0)) VALUES (false)" +== 285 +-- truncate_limit: 100 +DROP RULE y_rule ON y +-- +TABLE: name="y" schema="" table="y" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP RULE y_rule ON y" +== 286 +-- truncate_limit: 100 +-- check that parser lookahead for WITH doesn't cause any odd behavior +create table foo (with baz) +-- +ERROR: syntax error at or near "with" +CURSORPOS: 90 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 287 +-- truncate_limit: 100 +-- fail, WITH is a reserved word +create table foo (with ordinality) +-- +ERROR: syntax error at or near "with" +CURSORPOS: 52 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 288 +-- truncate_limit: 100 +-- fail, WITH is a reserved word +with ordinality as (select 1 as x) select * from ordinality +-- +CTE: "ordinality" +STMT: SelectStmt +TRUNCATED: "WITH ordinality AS (SELECT 1 AS x) SELECT * FROM ordinality" +== 289 +-- truncate_limit: 100 +-- check sane response to attempt to modify CTE relation +WITH with_test AS (SELECT 42) INSERT INTO with_test VALUES (1) +-- +CTE: "with_test" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH with_test AS (SELECT 42) INSERT INTO with_test VALUES (1)" +== 290 +-- truncate_limit: 100 +-- check response to attempt to modify table with same name as a CTE (perhaps +-- surprisingly it works, because CTEs don't hide tables from data-modifying +-- statements) +create temp table with_test (i int) +-- +TABLE: name="with_test" schema="" table="with_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE with_test (i int)" +== 291 +-- truncate_limit: 100 +with with_test as (select 42) insert into with_test select * from with_test +-- +CTE: "with_test" +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "WITH with_test AS (SELECT 42) INSERT INTO with_test SELECT * FROM with_test" +== 292 +-- truncate_limit: 100 +select * from with_test +-- +TABLE: name="with_test" schema="" table="with_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM with_test" +== 293 +-- truncate_limit: 100 +drop table with_test +-- +TABLE: name="with_test" schema="" table="with_test" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE with_test" diff --git a/parser/testdata/summary_truncate/postgres_regress/write_parallel.metadata.json b/parser/testdata/summary_truncate/postgres_regress/write_parallel.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/write_parallel.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/write_parallel.test b/parser/testdata/summary_truncate/postgres_regress/write_parallel.test new file mode 100644 index 0000000..c68de3d --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/write_parallel.test @@ -0,0 +1,193 @@ +== 001 +-- truncate_limit: 100 +|-- +-- PARALLEL +|-- + +begin +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 002 +-- truncate_limit: 100 +-- encourage use of parallel plans +set parallel_setup_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_setup_cost TO 0" +== 003 +-- truncate_limit: 100 +set parallel_tuple_cost=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET parallel_tuple_cost TO 0" +== 004 +-- truncate_limit: 100 +set min_parallel_table_scan_size=0 +-- +STMT: VariableSetStmt +TRUNCATED: "SET min_parallel_table_scan_size TO 0" +== 005 +-- truncate_limit: 100 +set max_parallel_workers_per_gather=4 +-- +STMT: VariableSetStmt +TRUNCATED: "SET max_parallel_workers_per_gather TO 4" +== 006 +-- truncate_limit: 100 +|-- +-- Test write operations that has an underlying query that is eligible +-- for parallel plans +|-- +explain (costs off) create table parallel_write as + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) CREATE TABLE parallel_write AS SELECT length(stringu1) FROM tenk1 GROUP BY le..." +== 007 +-- truncate_limit: 100 +create table parallel_write as + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE parallel_write AS SELECT length(stringu1) FROM tenk1 GROUP BY length(stringu1)" +== 008 +-- truncate_limit: 100 +drop table parallel_write +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parallel_write" +== 009 +-- truncate_limit: 100 +explain (costs off) select length(stringu1) into parallel_write + from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT length(stringu1) INTO parallel_write FROM tenk1 GROUP BY length(stringu1)" +== 010 +-- truncate_limit: 100 +select length(stringu1) into parallel_write + from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT length(stringu1) INTO parallel_write FROM tenk1 GROUP BY length(stringu1)" +== 011 +-- truncate_limit: 100 +drop table parallel_write +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parallel_write" +== 012 +-- truncate_limit: 100 +explain (costs off) create materialized view parallel_mat_view as + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) CREATE MATERIALIZED VIEW parallel_mat_view AS SELECT length(stringu1) FROM te..." +== 013 +-- truncate_limit: 100 +create materialized view parallel_mat_view as + select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE MATERIALIZED VIEW parallel_mat_view AS SELECT length(stringu1) FROM tenk1 GROUP BY length(..." +== 014 +-- truncate_limit: 100 +create unique index on parallel_mat_view(length) +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE UNIQUE INDEX ON parallel_mat_view USING btree (length)" +== 015 +-- truncate_limit: 100 +refresh materialized view parallel_mat_view +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW parallel_mat_view" +== 016 +-- truncate_limit: 100 +refresh materialized view concurrently parallel_mat_view +-- +TABLE: name="parallel_mat_view" schema="" table="parallel_mat_view" ctx=DDL +STMT: RefreshMatViewStmt +TRUNCATED: "REFRESH MATERIALIZED VIEW CONCURRENTLY parallel_mat_view" +== 017 +-- truncate_limit: 100 +drop materialized view parallel_mat_view +-- +STMT: DropStmt +TRUNCATED: "DROP MATERIALIZED VIEW parallel_mat_view" +== 018 +-- truncate_limit: 100 +prepare prep_stmt as select length(stringu1) from tenk1 group by length(stringu1) +-- +TABLE: name="tenk1" schema="" table="tenk1" ctx=Select +FUNCTION: name="length" function="length" schema="" ctx=Call +FUNCTION: name="length" function="length" schema="" ctx=Call +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE prep_stmt AS SELECT length(stringu1) FROM tenk1 GROUP BY length(stringu1)" +== 019 +-- truncate_limit: 100 +explain (costs off) create table parallel_write as execute prep_stmt +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: ExplainStmt +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "EXPLAIN (COSTS OFF) CREATE TABLE parallel_write AS EXECUTE prep_stmt" +== 020 +-- truncate_limit: 100 +create table parallel_write as execute prep_stmt +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: CreateTableAsStmt +STMT: ExecuteStmt +TRUNCATED: "CREATE TABLE parallel_write AS EXECUTE prep_stmt" +== 021 +-- truncate_limit: 100 +drop table parallel_write +-- +TABLE: name="parallel_write" schema="" table="parallel_write" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE parallel_write" +== 022 +-- truncate_limit: 100 +rollback +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" diff --git a/parser/testdata/summary_truncate/postgres_regress/xid.metadata.json b/parser/testdata/summary_truncate/postgres_regress/xid.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/xid.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/xid.test b/parser/testdata/summary_truncate/postgres_regress/xid.test new file mode 100644 index 0000000..329ade0 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/xid.test @@ -0,0 +1,638 @@ +== 001 +-- truncate_limit: 100 +-- xid and xid8 + +-- values in range, in octal, decimal, hex +select '010'::xid, + '42'::xid, + '0xffffffff'::xid, + '-1'::xid, + '010'::xid8, + '42'::xid8, + '0xffffffffffffffff'::xid8, + '-1'::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 002 +-- truncate_limit: 100 +-- garbage values +select ''::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::xid" +== 003 +-- truncate_limit: 100 +select 'asdf'::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'asdf'::xid" +== 004 +-- truncate_limit: 100 +select ''::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::xid8" +== 005 +-- truncate_limit: 100 +select 'asdf'::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'asdf'::xid8" +== 006 +-- truncate_limit: 100 +-- Also try it with non-error-throwing API +SELECT pg_input_is_valid('42', 'xid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('42', 'xid')" +== 007 +-- truncate_limit: 100 +SELECT pg_input_is_valid('asdf', 'xid') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('asdf', 'xid')" +== 008 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('0xffffffffff', 'xid') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('0xffffffffff', 'xid')" +== 009 +-- truncate_limit: 100 +SELECT pg_input_is_valid('42', 'xid8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('42', 'xid8')" +== 010 +-- truncate_limit: 100 +SELECT pg_input_is_valid('asdf', 'xid8') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('asdf', 'xid8')" +== 011 +-- truncate_limit: 100 +SELECT * FROM pg_input_error_info('0xffffffffffffffffffff', 'xid8') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('0xffffffffffffffffffff', 'xid8')" +== 012 +-- truncate_limit: 100 +-- equality +select '1'::xid = '1'::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid = '1'::xid" +== 013 +-- truncate_limit: 100 +select '1'::xid != '1'::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid <> '1'::xid" +== 014 +-- truncate_limit: 100 +select '1'::xid8 = '1'::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid8 = '1'::xid8" +== 015 +-- truncate_limit: 100 +select '1'::xid8 != '1'::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid8 <> '1'::xid8" +== 016 +-- truncate_limit: 100 +-- conversion +select '1'::xid = '1'::xid8::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid = '1'::xid8::xid" +== 017 +-- truncate_limit: 100 +select '1'::xid != '1'::xid8::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid <> '1'::xid8::xid" +== 018 +-- truncate_limit: 100 +-- we don't want relational operators for xid, due to use of modular arithmetic +select '1'::xid < '2'::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid < '2'::xid" +== 019 +-- truncate_limit: 100 +select '1'::xid <= '2'::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid <= '2'::xid" +== 020 +-- truncate_limit: 100 +select '1'::xid > '2'::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid > '2'::xid" +== 021 +-- truncate_limit: 100 +select '1'::xid >= '2'::xid +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid >= '2'::xid" +== 022 +-- truncate_limit: 100 +-- we want them for xid8 though +select '1'::xid8 < '2'::xid8, '2'::xid8 < '2'::xid8, '2'::xid8 < '1'::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid8 < '2'::xid8, '2'::xid8 < '2'::xid8, '2'::xid8 < '1'::xid8" +== 023 +-- truncate_limit: 100 +select '1'::xid8 <= '2'::xid8, '2'::xid8 <= '2'::xid8, '2'::xid8 <= '1'::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid8 <= '2'::xid8, '2'::xid8 <= '2'::xid8, '2'::xid8 <= '1'::xid8" +== 024 +-- truncate_limit: 100 +select '1'::xid8 > '2'::xid8, '2'::xid8 > '2'::xid8, '2'::xid8 > '1'::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid8 > '2'::xid8, '2'::xid8 > '2'::xid8, '2'::xid8 > '1'::xid8" +== 025 +-- truncate_limit: 100 +select '1'::xid8 >= '2'::xid8, '2'::xid8 >= '2'::xid8, '2'::xid8 >= '1'::xid8 +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1'::xid8 >= '2'::xid8, '2'::xid8 >= '2'::xid8, '2'::xid8 >= '1'::xid8" +== 026 +-- truncate_limit: 100 +-- we also have a 3way compare for btrees +select xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1') +-- +FUNCTION: name="xid8cmp" function="xid8cmp" schema="" ctx=Call +FUNCTION: name="xid8cmp" function="xid8cmp" schema="" ctx=Call +FUNCTION: name="xid8cmp" function="xid8cmp" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xid8cmp('1', '2'), xid8cmp('2', '2'), xid8cmp('2', '1')" +== 027 +-- truncate_limit: 100 +-- min() and max() for xid8 +create table xid8_t1 (x xid8) +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE xid8_t1 (x xid8)" +== 028 +-- truncate_limit: 100 +insert into xid8_t1 values ('0'), ('010'), ('42'), ('0xffffffffffffffff'), ('-1') +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xid8_t1 VALUES ('0'), ('010'), ('42'), ('0xffffffffffffffff'), ('-1')" +== 029 +-- truncate_limit: 100 +select min(x), max(x) from xid8_t1 +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=Select +FUNCTION: name="min" function="min" schema="" ctx=Call +FUNCTION: name="max" function="max" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT min(x), max(x) FROM xid8_t1" +== 030 +-- truncate_limit: 100 +-- xid8 has btree and hash opclasses +create index on xid8_t1 using btree(x) +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON xid8_t1 USING btree (x)" +== 031 +-- truncate_limit: 100 +create index on xid8_t1 using hash(x) +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DDL +STMT: IndexStmt +TRUNCATED: "CREATE INDEX ON xid8_t1 USING hash (x)" +== 032 +-- truncate_limit: 100 +drop table xid8_t1 +-- +TABLE: name="xid8_t1" schema="" table="xid8_t1" ctx=DDL +STMT: DropStmt +TRUNCATED: "DROP TABLE xid8_t1" +== 033 +-- truncate_limit: 100 +-- pg_snapshot data type and related functions + +-- Note: another set of tests similar to this exists in txid.sql, for a limited +-- time (the relevant functions share C code) + +-- i/o +select '12:13:'::pg_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:13:'::pg_snapshot" +== 034 +-- truncate_limit: 100 +select '12:18:14,16'::pg_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:18:14,16'::pg_snapshot" +== 035 +-- truncate_limit: 100 +select '12:16:14,14'::pg_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:16:14,14'::pg_snapshot" +== 036 +-- truncate_limit: 100 +-- errors +select '31:12:'::pg_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '31:12:'::pg_snapshot" +== 037 +-- truncate_limit: 100 +select '0:1:'::pg_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '0:1:'::pg_snapshot" +== 038 +-- truncate_limit: 100 +select '12:13:0'::pg_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:13:0'::pg_snapshot" +== 039 +-- truncate_limit: 100 +select '12:16:14,13'::pg_snapshot +-- +STMT: SelectStmt +TRUNCATED: "SELECT '12:16:14,13'::pg_snapshot" +== 040 +-- truncate_limit: 100 +-- also try it with non-error-throwing API +select pg_input_is_valid('12:13:', 'pg_snapshot') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('12:13:', 'pg_snapshot')" +== 041 +-- truncate_limit: 100 +select pg_input_is_valid('31:12:', 'pg_snapshot') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('31:12:', 'pg_snapshot')" +== 042 +-- truncate_limit: 100 +select * from pg_input_error_info('31:12:', 'pg_snapshot') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('31:12:', 'pg_snapshot')" +== 043 +-- truncate_limit: 100 +select pg_input_is_valid('12:16:14,13', 'pg_snapshot') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('12:16:14,13', 'pg_snapshot')" +== 044 +-- truncate_limit: 100 +select * from pg_input_error_info('12:16:14,13', 'pg_snapshot') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT * FROM pg_input_error_info('12:16:14,13', 'pg_snapshot')" +== 045 +-- truncate_limit: 100 +create temp table snapshot_test ( + nr integer, + snap pg_snapshot +) +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TEMPORARY TABLE snapshot_test (nr int, snap pg_snapshot)" +== 046 +-- truncate_limit: 100 +insert into snapshot_test values (1, '12:13:') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO snapshot_test VALUES (1, '12:13:')" +== 047 +-- truncate_limit: 100 +insert into snapshot_test values (2, '12:20:13,15,18') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO snapshot_test VALUES (2, '12:20:13,15,18')" +== 048 +-- truncate_limit: 100 +insert into snapshot_test values (3, '100001:100009:100005,100007,100008') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO snapshot_test VALUES (3, '100001:100009:100005,100007,100008')" +== 049 +-- truncate_limit: 100 +insert into snapshot_test values (4, '100:150:101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131') +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO snapshot_test VALUES (...)" +== 050 +-- truncate_limit: 100 +select snap from snapshot_test order by nr +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT snap FROM snapshot_test ORDER BY nr" +== 051 +-- truncate_limit: 100 +select pg_snapshot_xmin(snap), + pg_snapshot_xmax(snap), + pg_snapshot_xip(snap) +from snapshot_test order by nr +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="pg_snapshot_xmin" function="pg_snapshot_xmin" schema="" ctx=Call +FUNCTION: name="pg_snapshot_xmax" function="pg_snapshot_xmax" schema="" ctx=Call +FUNCTION: name="pg_snapshot_xip" function="pg_snapshot_xip" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM snapshot_test ORDER BY nr" +== 052 +-- truncate_limit: 100 +select id, pg_visible_in_snapshot(id::text::xid8, snap) +from snapshot_test, generate_series(11, 21) id +where nr = 2 +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM snapshot_test, generate_series(11, 21) id WHERE nr = 2" +== 053 +-- truncate_limit: 100 +-- test bsearch +select id, pg_visible_in_snapshot(id::text::xid8, snap) +from snapshot_test, generate_series(90, 160) id +where nr = 4 +-- +TABLE: name="snapshot_test" schema="" table="snapshot_test" ctx=Select +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="generate_series" function="generate_series" schema="" ctx=Call +FILTER: schema="" table="" column="nr" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM snapshot_test, generate_series(90, 160) id WHERE nr = 4" +== 054 +-- truncate_limit: 100 +-- test current values also +select pg_current_xact_id() >= pg_snapshot_xmin(pg_current_snapshot()) +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_snapshot_xmin" function="pg_snapshot_xmin" schema="" ctx=Call +FUNCTION: name="pg_current_snapshot" function="pg_current_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_current_xact_id() >= pg_snapshot_xmin(pg_current_snapshot())" +== 055 +-- truncate_limit: 100 +-- we can't assume current is always less than xmax, however + +select pg_visible_in_snapshot(pg_current_xact_id(), pg_current_snapshot()) +-- +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +FUNCTION: name="pg_current_snapshot" function="pg_current_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_visible_in_snapshot(pg_current_xact_id(), pg_current_snapshot())" +== 056 +-- truncate_limit: 100 +-- test 64bitness + +select pg_snapshot '1000100010001000:1000100010001100:1000100010001012,1000100010001013' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1000100010001000:1000100010001100:1000100010001012,1000100010001013'::pg_snapshot" +== 057 +-- truncate_limit: 100 +select pg_visible_in_snapshot('1000100010001012', '1000100010001000:1000100010001100:1000100010001012,1000100010001013') +-- +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 058 +-- truncate_limit: 100 +select pg_visible_in_snapshot('1000100010001015', '1000100010001000:1000100010001100:1000100010001012,1000100010001013') +-- +FUNCTION: name="pg_visible_in_snapshot" function="pg_visible_in_snapshot" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 059 +-- truncate_limit: 100 +-- test 64bit overflow +SELECT pg_snapshot '1:9223372036854775807:3' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1:9223372036854775807:3'::pg_snapshot" +== 060 +-- truncate_limit: 100 +SELECT pg_snapshot '1:9223372036854775808:3' +-- +STMT: SelectStmt +TRUNCATED: "SELECT '1:9223372036854775808:3'::pg_snapshot" +== 061 +-- truncate_limit: 100 +-- test pg_current_xact_id_if_assigned +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 062 +-- truncate_limit: 100 +SELECT pg_current_xact_id_if_assigned() IS NULL +-- +FUNCTION: name="pg_current_xact_id_if_assigned" function="pg_current_xact_id_if_assigned" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_current_xact_id_if_assigned() IS NULL" +== 063 +-- truncate_limit: 100 +SELECT pg_current_xact_id() +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_current_xact_id()" +== 064 +-- truncate_limit: 100 +SELECT pg_current_xact_id_if_assigned() IS NOT DISTINCT FROM xid8 :'pg_current_xact_id' +-- +ERROR: syntax error at or near ":" +CURSORPOS: 67 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 065 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 066 +-- truncate_limit: 100 +-- test xid status functions +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 067 +-- truncate_limit: 100 +SELECT pg_current_xact_id() AS committed +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_current_xact_id() AS committed" +== 068 +-- truncate_limit: 100 +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 069 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 070 +-- truncate_limit: 100 +SELECT pg_current_xact_id() AS rolledback +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_current_xact_id() AS rolledback" +== 071 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" +== 072 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 073 +-- truncate_limit: 100 +SELECT pg_current_xact_id() AS inprogress +-- +FUNCTION: name="pg_current_xact_id" function="pg_current_xact_id" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_current_xact_id() AS inprogress" +== 074 +-- truncate_limit: 100 +SELECT pg_xact_status(:committed::text::xid8) AS committed +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 075 +-- truncate_limit: 100 +SELECT pg_xact_status(:rolledback::text::xid8) AS rolledback +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 076 +-- truncate_limit: 100 +SELECT pg_xact_status(:inprogress::text::xid8) AS inprogress +-- +ERROR: syntax error at or near ":" +CURSORPOS: 23 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 077 +-- truncate_limit: 100 +SELECT pg_xact_status('1'::xid8) +-- +FUNCTION: name="pg_xact_status" function="pg_xact_status" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_xact_status('1'::xid8)" +== 078 +-- truncate_limit: 100 +-- BootstrapTransactionId is always committed +SELECT pg_xact_status('2'::xid8) +-- +FUNCTION: name="pg_xact_status" function="pg_xact_status" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_xact_status('2'::xid8)" +== 079 +-- truncate_limit: 100 +-- FrozenTransactionId is always committed +SELECT pg_xact_status('3'::xid8) +-- +FUNCTION: name="pg_xact_status" function="pg_xact_status" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_xact_status('3'::xid8)" +== 080 +-- truncate_limit: 100 +-- in regress testing FirstNormalTransactionId will always be behind oldestXmin + +COMMIT +-- +STMT: TransactionStmt +TRUNCATED: "COMMIT" +== 081 +-- truncate_limit: 100 +BEGIN +-- +STMT: TransactionStmt +TRUNCATED: "BEGIN" +== 082 +-- truncate_limit: 100 +CREATE FUNCTION test_future_xid_status(xid8) +RETURNS void +LANGUAGE plpgsql +AS +$$ +BEGIN + PERFORM pg_xact_status($1); + RAISE EXCEPTION 'didn''t ERROR at xid in the future as expected'; +EXCEPTION + WHEN invalid_parameter_value THEN + RAISE NOTICE 'Got expected error for xid in the future'; +END; +$$ +-- +FUNCTION: name="test_future_xid_status" function="test_future_xid_status" schema="" ctx=DDL +STMT: CreateFunctionStmt +TRUNCATED: "CREATE FUNCTION test_future_xid_status(xid8) RETURNS void LANGUAGE plpgsql AS $$\nBEGIN\n PERFORM ..." +== 083 +-- truncate_limit: 100 +SELECT test_future_xid_status((:inprogress + 10000)::text::xid8) +-- +ERROR: syntax error at or near ":" +CURSORPOS: 32 +FILENAME: scan.l +FUNCNAME: scanner_yyerror +== 084 +-- truncate_limit: 100 +ROLLBACK +-- +STMT: TransactionStmt +TRUNCATED: "ROLLBACK" diff --git a/parser/testdata/summary_truncate/postgres_regress/xml.metadata.json b/parser/testdata/summary_truncate/postgres_regress/xml.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/xml.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/xml.test b/parser/testdata/summary_truncate/postgres_regress/xml.test new file mode 100644 index 0000000..4f54f77 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/xml.test @@ -0,0 +1,2189 @@ +== 001 +-- truncate_limit: 100 +CREATE TABLE xmltest ( + id int, + data xml +) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE xmltest (id int, data xml)" +== 002 +-- truncate_limit: 100 +INSERT INTO xmltest VALUES (1, 'one') +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest VALUES (1, 'one')" +== 003 +-- truncate_limit: 100 +INSERT INTO xmltest VALUES (2, 'two') +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest VALUES (2, 'two')" +== 004 +-- truncate_limit: 100 +INSERT INTO xmltest VALUES (3, 'one', 'xml') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('one', 'xml')" +== 007 +-- truncate_limit: 100 +SELECT pg_input_is_valid('oneoneoneone', 'xml') +-- +FUNCTION: name="pg_input_is_valid" function="pg_input_is_valid" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT pg_input_is_valid('', 'xml')" +== 010 +-- truncate_limit: 100 +SELECT message FROM pg_input_error_info('', 'xml') +-- +FUNCTION: name="pg_input_error_info" function="pg_input_error_info" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT message FROM pg_input_error_info('', 'xml')" +== 011 +-- truncate_limit: 100 +SELECT xmlcomment('test') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlcomment('test')" +== 012 +-- truncate_limit: 100 +SELECT xmlcomment('-test') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlcomment('-test')" +== 013 +-- truncate_limit: 100 +SELECT xmlcomment('test-') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlcomment('test-')" +== 014 +-- truncate_limit: 100 +SELECT xmlcomment('--test') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlcomment('--test')" +== 015 +-- truncate_limit: 100 +SELECT xmlcomment('te st') +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlcomment('te st')" +== 016 +-- truncate_limit: 100 +SELECT xmlconcat(xmlcomment('hello'), + xmlelement(NAME qux, 'foo'), + xmlcomment('world')) +-- +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlconcat(xmlcomment('hello'), xmlelement(name qux, 'foo'), xmlcomment('world'))" +== 017 +-- truncate_limit: 100 +SELECT xmlconcat('hello', 'you') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlconcat('hello', 'you')" +== 018 +-- truncate_limit: 100 +SELECT xmlconcat(1, 2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlconcat(1, 2)" +== 019 +-- truncate_limit: 100 +SELECT xmlconcat('bad', '', NULL, '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlconcat('', NULL, '')" +== 021 +-- truncate_limit: 100 +SELECT xmlconcat('', NULL, '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlconcat('', NULL, '')" +== 022 +-- truncate_limit: 100 +SELECT xmlconcat(NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlconcat(NULL)" +== 023 +-- truncate_limit: 100 +SELECT xmlconcat(NULL, NULL) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlconcat(NULL, NULL)" +== 024 +-- truncate_limit: 100 +SELECT xmlelement(name element, + xmlattributes (1 as one, 'deuce' as two), + 'content') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name element, xmlattributes(1 AS one, 'deuce' AS two), 'content')" +== 025 +-- truncate_limit: 100 +SELECT xmlelement(name element, + xmlattributes ('unnamed and wrong')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name element, xmlattributes('unnamed and wrong'))" +== 026 +-- truncate_limit: 100 +SELECT xmlelement(name element, xmlelement(name nested, 'stuff')) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name element, xmlelement(name nested, 'stuff'))" +== 027 +-- truncate_limit: 100 +SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp +-- +TABLE: name="emp" schema="" table="emp" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name employee, xmlforest(name, age, salary AS pay)) FROM emp" +== 028 +-- truncate_limit: 100 +SELECT xmlelement(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name duplicate, xmlattributes(1 AS a, 2 AS b, 3 AS a))" +== 029 +-- truncate_limit: 100 +SELECT xmlelement(name num, 37) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name num, 37)" +== 030 +-- truncate_limit: 100 +SELECT xmlelement(name foo, text 'bar') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, 'bar'::text)" +== 031 +-- truncate_limit: 100 +SELECT xmlelement(name foo, xml 'bar') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, 'bar'::xml)" +== 032 +-- truncate_limit: 100 +SELECT xmlelement(name foo, text 'br') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, 'br'::text)" +== 033 +-- truncate_limit: 100 +SELECT xmlelement(name foo, xml 'br') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, 'br'::xml)" +== 034 +-- truncate_limit: 100 +SELECT xmlelement(name foo, array[1, 2, 3]) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, ARRAY[1, 2, 3])" +== 035 +-- truncate_limit: 100 +SET xmlbinary TO base64 +-- +STMT: VariableSetStmt +TRUNCATED: "SET xmlbinary TO base64" +== 036 +-- truncate_limit: 100 +SELECT xmlelement(name foo, bytea 'bar') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, 'bar'::bytea)" +== 037 +-- truncate_limit: 100 +SET xmlbinary TO hex +-- +STMT: VariableSetStmt +TRUNCATED: "SET xmlbinary TO hex" +== 038 +-- truncate_limit: 100 +SELECT xmlelement(name foo, bytea 'bar') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, 'bar'::bytea)" +== 039 +-- truncate_limit: 100 +SELECT xmlelement(name foo, xmlattributes(true as bar)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, xmlattributes(true AS bar))" +== 040 +-- truncate_limit: 100 +SELECT xmlelement(name foo, xmlattributes('2009-04-09 00:24:37'::timestamp as bar)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, xmlattributes('2009-04-09 00:24:37'::timestamp AS bar))" +== 041 +-- truncate_limit: 100 +SELECT xmlelement(name foo, xmlattributes('infinity'::timestamp as bar)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, xmlattributes('infinity'::timestamp AS bar))" +== 042 +-- truncate_limit: 100 +SELECT xmlelement(name foo, xmlattributes('<>&"''' as funny, xml 'br' as funnier)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name foo, xmlattributes('<>&\"''' AS funny, 'br'::xml AS funnier))" +== 043 +-- truncate_limit: 100 +SELECT xmlparse(content '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content '')" +== 044 +-- truncate_limit: 100 +SELECT xmlparse(content ' ') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content ' ')" +== 045 +-- truncate_limit: 100 +SELECT xmlparse(content 'abc') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content 'abc')" +== 046 +-- truncate_limit: 100 +SELECT xmlparse(content 'x') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content 'x')" +== 047 +-- truncate_limit: 100 +SELECT xmlparse(content '&') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content '&')" +== 048 +-- truncate_limit: 100 +SELECT xmlparse(content '&idontexist;') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content '&idontexist;')" +== 049 +-- truncate_limit: 100 +SELECT xmlparse(content '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content '')" +== 050 +-- truncate_limit: 100 +SELECT xmlparse(content '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content '')" +== 051 +-- truncate_limit: 100 +SELECT xmlparse(content '&idontexist;') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content '&idontexist;')" +== 052 +-- truncate_limit: 100 +SELECT xmlparse(content '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(content '')" +== 053 +-- truncate_limit: 100 +SELECT xmlparse(document ' ') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document ' ')" +== 054 +-- truncate_limit: 100 +SELECT xmlparse(document 'abc') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document 'abc')" +== 055 +-- truncate_limit: 100 +SELECT xmlparse(document 'x') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document 'x')" +== 056 +-- truncate_limit: 100 +SELECT xmlparse(document '&') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document '&')" +== 057 +-- truncate_limit: 100 +SELECT xmlparse(document '&idontexist;') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document '&idontexist;')" +== 058 +-- truncate_limit: 100 +SELECT xmlparse(document '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document '')" +== 059 +-- truncate_limit: 100 +SELECT xmlparse(document '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document '')" +== 060 +-- truncate_limit: 100 +SELECT xmlparse(document '&idontexist;') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document '&idontexist;')" +== 061 +-- truncate_limit: 100 +SELECT xmlparse(document '') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document '')" +== 062 +-- truncate_limit: 100 +SELECT xmlpi(name foo) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name foo)" +== 063 +-- truncate_limit: 100 +SELECT xmlpi(name xml) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name xml)" +== 064 +-- truncate_limit: 100 +SELECT xmlpi(name xmlstuff) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name xmlstuff)" +== 065 +-- truncate_limit: 100 +SELECT xmlpi(name foo, 'bar') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name foo, 'bar')" +== 066 +-- truncate_limit: 100 +SELECT xmlpi(name foo, 'in?>valid') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name foo, 'in?>valid')" +== 067 +-- truncate_limit: 100 +SELECT xmlpi(name foo, null) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name foo, NULL)" +== 068 +-- truncate_limit: 100 +SELECT xmlpi(name xml, null) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name xml, NULL)" +== 069 +-- truncate_limit: 100 +SELECT xmlpi(name xmlstuff, null) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name xmlstuff, NULL)" +== 070 +-- truncate_limit: 100 +SELECT xmlpi(name "xml-stylesheet", 'href="mystyle.css" type="text/css"') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name \"xml-stylesheet\", 'href=\"mystyle.css\" type=\"text/css\"')" +== 071 +-- truncate_limit: 100 +SELECT xmlpi(name foo, ' bar') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name foo, ' bar')" +== 072 +-- truncate_limit: 100 +SELECT xmlroot(xml '', version no value, standalone no value) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlroot(''::xml, version no value, standalone no value)" +== 073 +-- truncate_limit: 100 +SELECT xmlroot(xml '', version '2.0') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlroot(''::xml, version '2.0')" +== 074 +-- truncate_limit: 100 +SELECT xmlroot(xml '', version no value, standalone yes) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlroot(''::xml, version no value, standalone yes)" +== 075 +-- truncate_limit: 100 +SELECT xmlroot(xml '', version no value, standalone yes) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlroot(''::xml, version no value, standalone yes)" +== 076 +-- truncate_limit: 100 +SELECT xmlroot(xmlroot(xml '', version '1.0'), version '1.1', standalone no) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlroot(xmlroot(''::xml, version '1.0'), version '1.1', standalone no)" +== 077 +-- truncate_limit: 100 +SELECT xmlroot('', version no value, standalone no) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlroot('', version no value, standalone no)" +== 078 +-- truncate_limit: 100 +SELECT xmlroot('', version no value, standalone no value) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 079 +-- truncate_limit: 100 +SELECT xmlroot('', version no value) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlroot('', version no value)" +== 080 +-- truncate_limit: 100 +SELECT xmlroot ( + xmlelement ( + name gazonk, + xmlattributes ( + 'val' AS name, + 1 + 1 AS num + ), + xmlelement ( + NAME qux, + 'foo' + ) + ), + version '1.0', + standalone yes +) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 081 +-- truncate_limit: 100 +SELECT xmlserialize(content data as character varying(20)) FROM xmltest +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content data AS varchar(20)) FROM xmltest" +== 082 +-- truncate_limit: 100 +SELECT xmlserialize(content 'good' as char(10)) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content 'good' AS char(10))" +== 083 +-- truncate_limit: 100 +SELECT xmlserialize(document 'bad' as text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document 'bad' AS text)" +== 084 +-- truncate_limit: 100 +-- indent +SELECT xmlserialize(DOCUMENT '42' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document '42' AS text INDENT)" +== 085 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '42' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content '42' AS text INDENT)" +== 086 +-- truncate_limit: 100 +-- no indent +SELECT xmlserialize(DOCUMENT '42' AS text NO INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document '42' AS text)" +== 087 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '42' AS text NO INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content '42' AS text)" +== 088 +-- truncate_limit: 100 +-- indent non singly-rooted xml +SELECT xmlserialize(DOCUMENT '7342' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document '7342' AS text INDENT)" +== 089 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '7342' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content '7342' AS text INDENT)" +== 090 +-- truncate_limit: 100 +-- indent non singly-rooted xml with mixed contents +SELECT xmlserialize(DOCUMENT 'text node73text node42' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 091 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT 'text node73text node42' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 092 +-- truncate_limit: 100 +-- indent singly-rooted xml with mixed contents +SELECT xmlserialize(DOCUMENT '42text node73' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 093 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '42text node73' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 094 +-- truncate_limit: 100 +-- indent empty string +SELECT xmlserialize(DOCUMENT '' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document '' AS text INDENT)" +== 095 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content '' AS text INDENT)" +== 096 +-- truncate_limit: 100 +-- whitespaces +SELECT xmlserialize(DOCUMENT ' ' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document ' ' AS text INDENT)" +== 097 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT ' ' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content ' ' AS text INDENT)" +== 098 +-- truncate_limit: 100 +-- indent null +SELECT xmlserialize(DOCUMENT NULL AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document NULL AS text INDENT)" +== 099 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT NULL AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content NULL AS text INDENT)" +== 100 +-- truncate_limit: 100 +-- indent with XML declaration +SELECT xmlserialize(DOCUMENT '73' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 101 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '73' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 102 +-- truncate_limit: 100 +-- indent containing DOCTYPE declaration +SELECT xmlserialize(DOCUMENT '' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document '' AS text INDENT)" +== 103 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content '' AS text INDENT)" +== 104 +-- truncate_limit: 100 +-- indent xml with empty element +SELECT xmlserialize(DOCUMENT '' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document '' AS text INDENT)" +== 105 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content '' AS text INDENT)" +== 106 +-- truncate_limit: 100 +-- 'no indent' = not using 'no indent' +SELECT xmlserialize(DOCUMENT '42' AS text) = xmlserialize(DOCUMENT '42' AS text NO INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 107 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT '42' AS text) = xmlserialize(CONTENT '42' AS text NO INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 108 +-- truncate_limit: 100 +-- indent xml strings containing blank nodes +SELECT xmlserialize(DOCUMENT ' ' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(document ' ' AS text INDENT)" +== 109 +-- truncate_limit: 100 +SELECT xmlserialize(CONTENT 'text node ' AS text INDENT) +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlserialize(content 'text node ' AS text INDENT)" +== 110 +-- truncate_limit: 100 +SELECT xml 'bar' IS DOCUMENT +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'bar'::xml IS DOCUMENT" +== 111 +-- truncate_limit: 100 +SELECT xml 'barfoo' IS DOCUMENT +-- +STMT: SelectStmt +TRUNCATED: "SELECT 'barfoo'::xml IS DOCUMENT" +== 112 +-- truncate_limit: 100 +SELECT xml '' IS NOT DOCUMENT +-- +STMT: SelectStmt +TRUNCATED: "SELECT NOT ''::xml IS DOCUMENT" +== 113 +-- truncate_limit: 100 +SELECT xml 'abc' IS NOT DOCUMENT +-- +STMT: SelectStmt +TRUNCATED: "SELECT NOT 'abc'::xml IS DOCUMENT" +== 114 +-- truncate_limit: 100 +SELECT '<>' IS NOT DOCUMENT +-- +STMT: SelectStmt +TRUNCATED: "SELECT NOT '<>' IS DOCUMENT" +== 115 +-- truncate_limit: 100 +SELECT xmlagg(data) FROM xmltest +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xmlagg" function="xmlagg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlagg(data) FROM xmltest" +== 116 +-- truncate_limit: 100 +SELECT xmlagg(data) FROM xmltest WHERE id > 10 +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xmlagg" function="xmlagg" schema="" ctx=Call +FILTER: schema="" table="" column="id" +STMT: SelectStmt +TRUNCATED: "SELECT xmlagg(data) FROM xmltest WHERE id > 10" +== 117 +-- truncate_limit: 100 +SELECT xmlelement(name employees, xmlagg(xmlelement(name name, name))) FROM emp +-- +TABLE: name="emp" schema="" table="emp" ctx=Select +FUNCTION: name="xmlagg" function="xmlagg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlelement(name employees, xmlagg(xmlelement(name name, name))) FROM emp" +== 118 +-- truncate_limit: 100 +-- Check mapping SQL identifier to XML name + +SELECT xmlpi(name ":::_xml_abc135.%-&_") +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name \":::_xml_abc135.%-&_\")" +== 119 +-- truncate_limit: 100 +SELECT xmlpi(name "123") +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlpi(name \"123\")" +== 120 +-- truncate_limit: 100 +PREPARE foo (xml) AS SELECT xmlconcat('', $1) +-- +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE foo(xml) AS SELECT xmlconcat('', $1)" +== 121 +-- truncate_limit: 100 +SET XML OPTION DOCUMENT +-- +STMT: VariableSetStmt +TRUNCATED: "SET xmloption TO \"DOCUMENT\"" +== 122 +-- truncate_limit: 100 +EXECUTE foo ('') +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foo('')" +== 123 +-- truncate_limit: 100 +EXECUTE foo ('bad') +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foo('bad')" +== 124 +-- truncate_limit: 100 +SELECT xml '' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::xml" +== 125 +-- truncate_limit: 100 +SET XML OPTION CONTENT +-- +STMT: VariableSetStmt +TRUNCATED: "SET xmloption TO \"CONTENT\"" +== 126 +-- truncate_limit: 100 +EXECUTE foo ('') +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foo('')" +== 127 +-- truncate_limit: 100 +EXECUTE foo ('good') +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE foo('good')" +== 128 +-- truncate_limit: 100 +SELECT xml ' ' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' '::xml" +== 129 +-- truncate_limit: 100 +SELECT xml ' ' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' '::xml" +== 130 +-- truncate_limit: 100 +SELECT xml '' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::xml" +== 131 +-- truncate_limit: 100 +SELECT xml ' oops ' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' oops '::xml" +== 132 +-- truncate_limit: 100 +SELECT xml ' ' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ' '::xml" +== 133 +-- truncate_limit: 100 +SELECT xml '' +-- +STMT: SelectStmt +TRUNCATED: "SELECT ''::xml" +== 134 +-- truncate_limit: 100 +-- Test backwards parsing + +CREATE VIEW xmlview1 AS SELECT xmlcomment('test') +-- +TABLE: name="xmlview1" schema="" table="xmlview1" ctx=DDL +FUNCTION: name="xmlcomment" function="xmlcomment" schema="" ctx=Call +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview1 AS SELECT xmlcomment('test')" +== 135 +-- truncate_limit: 100 +CREATE VIEW xmlview2 AS SELECT xmlconcat('hello', 'you') +-- +TABLE: name="xmlview2" schema="" table="xmlview2" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview2 AS SELECT xmlconcat('hello', 'you')" +== 136 +-- truncate_limit: 100 +CREATE VIEW xmlview3 AS SELECT xmlelement(name element, xmlattributes (1 as ":one:", 'deuce' as two), 'content&') +-- +TABLE: name="xmlview3" schema="" table="xmlview3" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview3 AS SELECT xmlelement(name element, xmlattributes(1 AS \":one:\", 'deuce' AS tw..." +== 137 +-- truncate_limit: 100 +CREATE VIEW xmlview4 AS SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp +-- +TABLE: name="xmlview4" schema="" table="xmlview4" ctx=DDL +TABLE: name="emp" schema="" table="emp" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview4 AS SELECT xmlelement(name employee, xmlforest(name, age, salary AS pay)) FRO..." +== 138 +-- truncate_limit: 100 +CREATE VIEW xmlview5 AS SELECT xmlparse(content 'x') +-- +TABLE: name="xmlview5" schema="" table="xmlview5" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview5 AS SELECT xmlparse(content 'x')" +== 139 +-- truncate_limit: 100 +CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar') +-- +TABLE: name="xmlview6" schema="" table="xmlview6" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar')" +== 140 +-- truncate_limit: 100 +CREATE VIEW xmlview7 AS SELECT xmlroot(xml '', version no value, standalone yes) +-- +TABLE: name="xmlview7" schema="" table="xmlview7" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview7 AS SELECT xmlroot(''::xml, version no value, standalone yes)" +== 141 +-- truncate_limit: 100 +CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10)) +-- +TABLE: name="xmlview8" schema="" table="xmlview8" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' AS char(10))" +== 142 +-- truncate_limit: 100 +CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text) +-- +TABLE: name="xmlview9" schema="" table="xmlview9" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' AS text)" +== 143 +-- truncate_limit: 100 +CREATE VIEW xmlview10 AS SELECT xmlserialize(document '42' AS text indent) +-- +TABLE: name="xmlview10" schema="" table="xmlview10" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview10 AS SELECT xmlserialize(document '42' AS text INDENT)" +== 144 +-- truncate_limit: 100 +CREATE VIEW xmlview11 AS SELECT xmlserialize(document '42' AS character varying no indent) +-- +TABLE: name="xmlview11" schema="" table="xmlview11" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmlview11 AS SELECT xmlserialize(document '42' AS varchar)" +== 145 +-- truncate_limit: 100 +SELECT table_name, view_definition FROM information_schema.views + WHERE table_name LIKE 'xmlview%' ORDER BY 1 +-- +TABLE: name="information_schema.views" schema="information_schema" table="views" ctx=Select +FILTER: schema="" table="" column="table_name" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM information_schema.views WHERE table_name LIKE 'xmlview%' ORDER BY 1" +== 146 +-- truncate_limit: 100 +-- Text XPath expressions evaluation + +SELECT xpath('/value', data) FROM xmltest +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('/value', data) FROM xmltest" +== 147 +-- truncate_limit: 100 +SELECT xpath(NULL, NULL) IS NULL FROM xmltest +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath(NULL, NULL) IS NULL FROM xmltest" +== 148 +-- truncate_limit: 100 +SELECT xpath('', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('', '')" +== 149 +-- truncate_limit: 100 +SELECT xpath('//text()', 'number one') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 150 +-- truncate_limit: 100 +SELECT xpath('//loc:piece/@id', 'number one', ARRAY[ARRAY['loc', 'http://127.0.0.1']]) +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 151 +-- truncate_limit: 100 +SELECT xpath('//loc:piece', 'number one', ARRAY[ARRAY['loc', 'http://127.0.0.1']]) +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 152 +-- truncate_limit: 100 +SELECT xpath('//loc:piece', 'number one', ARRAY[ARRAY['loc', 'http://127.0.0.1']]) +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 153 +-- truncate_limit: 100 +SELECT xpath('//b', 'one two three etc') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('//b', 'one two three etc')" +== 154 +-- truncate_limit: 100 +SELECT xpath('//text()', '<') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('//text()', '<')" +== 155 +-- truncate_limit: 100 +SELECT xpath('//@value', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('//@value', '')" +== 156 +-- truncate_limit: 100 +SELECT xpath('''<>''', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('''<>''', '')" +== 157 +-- truncate_limit: 100 +SELECT xpath('count(//*)', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('count(//*)', '')" +== 158 +-- truncate_limit: 100 +SELECT xpath('count(//*)=0', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('count(//*)=0', '')" +== 159 +-- truncate_limit: 100 +SELECT xpath('count(//*)=3', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('count(//*)=3', '')" +== 160 +-- truncate_limit: 100 +SELECT xpath('name(/*)', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('name(/*)', '')" +== 161 +-- truncate_limit: 100 +SELECT xpath('/nosuchtag', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('/nosuchtag', '')" +== 162 +-- truncate_limit: 100 +SELECT xpath('root', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('root', '')" +== 163 +-- truncate_limit: 100 +-- Round-trip non-ASCII data through xpath(). +DO $$ +DECLARE + xml_declaration text := ''; + degree_symbol text; + res xml[]; +BEGIN + -- Per the documentation, except when the server encoding is UTF8, xpath() + -- may not work on non-ASCII data. The untranslatable_character and + -- undefined_function traps below, currently dead code, will become relevant + -- if we remove this limitation. + IF current_setting('server_encoding') <> 'UTF8' THEN + RAISE LOG 'skip: encoding % unsupported for xpath', + current_setting('server_encoding'); + RETURN; + END IF; + + degree_symbol := convert_from('\xc2b0', 'UTF8'); + res := xpath('text()', (xml_declaration || + '' || degree_symbol || '')::xml); + IF degree_symbol <> res[1]::text THEN + RAISE 'expected % (%), got % (%)', + degree_symbol, convert_to(degree_symbol, 'UTF8'), + res[1], convert_to(res[1]::text, 'UTF8'); + END IF; +EXCEPTION + -- character with byte sequence 0xc2 0xb0 in encoding "UTF8" has no equivalent in encoding "LATIN8" + WHEN untranslatable_character + -- default conversion function for encoding "UTF8" to "MULE_INTERNAL" does not exist + OR undefined_function + -- unsupported XML feature + OR feature_not_supported THEN + RAISE LOG 'skip: %', SQLERRM; +END +$$ +-- +STMT: DoStmt +TRUNCATED: "DO $$\nDECLARE\n xml_declaration text := '';\n degree_s..." +== 164 +-- truncate_limit: 100 +-- Test xmlexists and xpath_exists +SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF 'Bidford-on-AvonCwmbranBristol') +-- +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 165 +-- truncate_limit: 100 +SELECT xmlexists('//town[text() = ''Cwmbran'']' PASSING BY REF 'Bidford-on-AvonCwmbranBristol') +-- +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 166 +-- truncate_limit: 100 +SELECT xmlexists('count(/nosuchtag)' PASSING BY REF '') +-- +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmlexists ('count(/nosuchtag)' PASSING '')" +== 167 +-- truncate_limit: 100 +SELECT xpath_exists('//town[text() = ''Toronto'']','Bidford-on-AvonCwmbranBristol'::xml) +-- +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 168 +-- truncate_limit: 100 +SELECT xpath_exists('//town[text() = ''Cwmbran'']','Bidford-on-AvonCwmbranBristol'::xml) +-- +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 169 +-- truncate_limit: 100 +SELECT xpath_exists('count(/nosuchtag)', ''::xml) +-- +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath_exists('count(/nosuchtag)', ''::xml)" +== 170 +-- truncate_limit: 100 +INSERT INTO xmltest VALUES (4, 'BudvarfreeCarlinglots'::xml) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest VALUES (...)" +== 171 +-- truncate_limit: 100 +INSERT INTO xmltest VALUES (5, 'MolsonfreeCarlinglots'::xml) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest VALUES (...)" +== 172 +-- truncate_limit: 100 +INSERT INTO xmltest VALUES (6, 'BudvarfreeCarlinglots'::xml) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest VALUES (...)" +== 173 +-- truncate_limit: 100 +INSERT INTO xmltest VALUES (7, 'MolsonfreeCarlinglots'::xml) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest VALUES (...)" +== 174 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beer' PASSING data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE xmlexists ('/menu/beer' PASSING data)" +== 175 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beer' PASSING BY REF data BY REF) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE xmlexists ('/menu/beer' PASSING data)" +== 176 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers' PASSING BY REF data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE xmlexists ('/menu/beers' PASSING data)" +== 177 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xmlexists('/menu/beers/name[text() = ''Molson'']' PASSING BY REF data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE xmlexists ('/menu/beers/name[text() = ''Molson'']' PASSING data)" +== 178 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beer',data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE xpath_exists('/menu/beer', data)" +== 179 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beers',data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE xpath_exists('/menu/beers', data)" +== 180 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/menu/beers/name[text() = ''Molson'']',data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE xpath_exists('/menu/beers/name[text() = ''Molson'']', data)" +== 181 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beer',data,ARRAY[ARRAY['myns','http://myns.com']]) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE ..." +== 182 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beers',data,ARRAY[ARRAY['myns','http://myns.com']]) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE ..." +== 183 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest WHERE xpath_exists('/myns:menu/myns:beers/myns:name[text() = ''Molson'']',data,ARRAY[ARRAY['myns','http://myns.com']]) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="xpath_exists" function="xpath_exists" schema="" ctx=Call +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest WHERE ..." +== 184 +-- truncate_limit: 100 +CREATE TABLE query ( expr TEXT ) +-- +TABLE: name="query" schema="" table="query" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE query (expr text)" +== 185 +-- truncate_limit: 100 +INSERT INTO query VALUES ('/menu/beers/cost[text() = ''lots'']') +-- +TABLE: name="query" schema="" table="query" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO query VALUES ('/menu/beers/cost[text() = ''lots'']')" +== 186 +-- truncate_limit: 100 +SELECT COUNT(id) FROM xmltest, query WHERE xmlexists(expr PASSING BY REF data) +-- +TABLE: name="xmltest" schema="" table="xmltest" ctx=Select +TABLE: name="query" schema="" table="query" ctx=Select +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FUNCTION: name="count" function="count" schema="" ctx=Call +FUNCTION: name="pg_catalog.xmlexists" function="xmlexists" schema="pg_catalog" ctx=Call +FILTER: schema="" table="" column="expr" +FILTER: schema="" table="" column="data" +STMT: SelectStmt +TRUNCATED: "SELECT count(id) FROM xmltest, query WHERE xmlexists (expr PASSING data)" +== 187 +-- truncate_limit: 100 +-- Test xml_is_well_formed and variants + +SELECT xml_is_well_formed_document('bar') +-- +FUNCTION: name="xml_is_well_formed_document" function="xml_is_well_formed_document" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed_document('bar')" +== 188 +-- truncate_limit: 100 +SELECT xml_is_well_formed_document('abc') +-- +FUNCTION: name="xml_is_well_formed_document" function="xml_is_well_formed_document" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed_document('abc')" +== 189 +-- truncate_limit: 100 +SELECT xml_is_well_formed_content('bar') +-- +FUNCTION: name="xml_is_well_formed_content" function="xml_is_well_formed_content" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed_content('bar')" +== 190 +-- truncate_limit: 100 +SELECT xml_is_well_formed_content('abc') +-- +FUNCTION: name="xml_is_well_formed_content" function="xml_is_well_formed_content" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed_content('abc')" +== 191 +-- truncate_limit: 100 +SET xmloption TO DOCUMENT +-- +STMT: VariableSetStmt +TRUNCATED: "SET xmloption TO document" +== 192 +-- truncate_limit: 100 +SELECT xml_is_well_formed('abc') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('abc')" +== 193 +-- truncate_limit: 100 +SELECT xml_is_well_formed('<>') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('<>')" +== 194 +-- truncate_limit: 100 +SELECT xml_is_well_formed('') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('')" +== 195 +-- truncate_limit: 100 +SELECT xml_is_well_formed('bar') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('bar')" +== 196 +-- truncate_limit: 100 +SELECT xml_is_well_formed('barbarbaz') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('baz')" +== 198 +-- truncate_limit: 100 +SELECT xml_is_well_formed('number one') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 199 +-- truncate_limit: 100 +SELECT xml_is_well_formed('bar') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('bar')" +== 200 +-- truncate_limit: 100 +SELECT xml_is_well_formed('bar') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('bar')" +== 201 +-- truncate_limit: 100 +SELECT xml_is_well_formed('&') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('&')" +== 202 +-- truncate_limit: 100 +SELECT xml_is_well_formed('&idontexist;') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('&idontexist;')" +== 203 +-- truncate_limit: 100 +SELECT xml_is_well_formed('') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('')" +== 204 +-- truncate_limit: 100 +SELECT xml_is_well_formed('') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('')" +== 205 +-- truncate_limit: 100 +SELECT xml_is_well_formed('&idontexist;') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('&idontexist;')" +== 206 +-- truncate_limit: 100 +SET xmloption TO CONTENT +-- +STMT: VariableSetStmt +TRUNCATED: "SET xmloption TO content" +== 207 +-- truncate_limit: 100 +SELECT xml_is_well_formed('abc') +-- +FUNCTION: name="xml_is_well_formed" function="xml_is_well_formed" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xml_is_well_formed('abc')" +== 208 +-- truncate_limit: 100 +-- Since xpath() deals with namespaces, it's a bit stricter about +-- what's well-formed and what's not. If we don't obey these rules +-- (i.e. ignore namespace-related errors from libxml), xpath() +-- fails in subtle ways. The following would for example produce +-- the xml value +-- +-- which is invalid because '<' may not appear un-escaped in +-- attribute values. +-- Since different libxml versions emit slightly different +-- error messages, we suppress the DETAIL in this test. +SELECT xpath('/*', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('/*', '')" +== 209 +-- truncate_limit: 100 +-- Again, the XML isn't well-formed for namespace purposes +SELECT xpath('/*', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('/*', '')" +== 210 +-- truncate_limit: 100 +-- XPath deprecates relative namespaces, but they're not supposed to +-- throw an error, only a warning. +SELECT xpath('/*', '') +-- +FUNCTION: name="xpath" function="xpath" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xpath('/*', '')" +== 211 +-- truncate_limit: 100 +-- External entity references should not leak filesystem information. +SELECT XMLPARSE(DOCUMENT ']>&c;') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document ']>&c;')" +== 212 +-- truncate_limit: 100 +SELECT XMLPARSE(DOCUMENT ']>&c;') +-- +STMT: SelectStmt +TRUNCATED: "SELECT xmlparse(document ']>&c;')" +== 213 +-- truncate_limit: 100 +-- This might or might not load the requested DTD, but it mustn't throw error. +SELECT XMLPARSE(DOCUMENT ' ') +-- +STMT: SelectStmt +TRUNCATED: "SELECT ..." +== 214 +-- truncate_limit: 100 +-- XMLPATH tests +CREATE TABLE xmldata(data xml) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE xmldata (data xml)" +== 215 +-- truncate_limit: 100 +INSERT INTO xmldata VALUES(' + + AU + Australia + 3 + + + CN + China + 3 + + + HK + HongKong + 3 + + + IN + India + 3 + + + JP + Japan + 3Sinzo Abe + + + SG + Singapore + 3791 + +') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmldata VALUES (...)" +== 216 +-- truncate_limit: 100 +-- XMLTABLE with columns +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME/text()' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM xmldata) x, LATERAL xmltable(('/ROWS/ROW') PASSING data COLUMNS ..." +== 217 +-- truncate_limit: 100 +CREATE VIEW xmltableview1 AS SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME/text()' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmltableview1" schema="" table="xmltableview1" ctx=DDL +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmltableview1 AS SELECT \"xmltable\".* FROM (SELECT data FROM xmldata) x, LATERAL xmlta..." +== 218 +-- truncate_limit: 100 +SELECT * FROM xmltableview1 +-- +TABLE: name="xmltableview1" schema="" table="xmltableview1" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltableview1" +== 219 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF) SELECT * FROM xmltableview1 +-- +TABLE: name="xmltableview1" schema="" table="xmltableview1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF) SELECT * FROM xmltableview1" +== 220 +-- truncate_limit: 100 +EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM xmltableview1 +-- +TABLE: name="xmltableview1" schema="" table="xmltableview1" ctx=Select +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (COSTS OFF, VERBOSE) SELECT * FROM xmltableview1" +== 221 +-- truncate_limit: 100 +-- errors +SELECT * FROM XMLTABLE (ROW () PASSING null COLUMNS v1 timestamp) AS f (v1, v2) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable((ROW()) PASSING NULL COLUMNS v1 timestamp) AS f(v1, v2)" +== 222 +-- truncate_limit: 100 +SELECT * FROM XMLTABLE (ROW () PASSING null COLUMNS v1 timestamp __pg__is_not_null 1) AS f (v1) +-- +ERROR: option name "__pg__is_not_null" cannot be used in XMLTABLE +CURSORPOS: 66 +FILENAME: gram.y +FUNCNAME: base_yyparse +== 223 +-- truncate_limit: 100 +-- XMLNAMESPACES tests +SELECT * FROM XMLTABLE(XMLNAMESPACES('http://x.y' AS zz), + '/zz:rows/zz:row' + PASSING '10' + COLUMNS a int PATH 'zz:a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(xmlnamespaces('http://x.y' AS zz), ('/zz:rows/zz:row') PASSING '10' + COLUMNS a int PATH 'Zz:a') +-- +TABLE: name="xmltableview2" schema="" table="xmltableview2" ctx=DDL +STMT: ViewStmt +STMT: SelectStmt +TRUNCATED: "CREATE VIEW xmltableview2 AS SELECT * FROM xmltable(xmlnamespaces('http://x.y' AS \"Zz\"), ('/Zz:ro..." +== 225 +-- truncate_limit: 100 +SELECT * FROM xmltableview2 +-- +TABLE: name="xmltableview2" schema="" table="xmltableview2" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltableview2" +== 226 +-- truncate_limit: 100 +SELECT * FROM XMLTABLE(XMLNAMESPACES(DEFAULT 'http://x.y'), + '/rows/row' + PASSING '10' + COLUMNS a int PATH 'a') +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(xmlnamespaces(DEFAULT 'http://x.y'), ('/rows/row') PASSING '' + COLUMNS a text PATH 'foo/namespace::node()') +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('.') PASSING '' COLUMNS a text PATH 'foo/namespace::node()')" +== 228 +-- truncate_limit: 100 +-- used in prepare statements +PREPARE pp AS +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: PrepareStmt +STMT: SelectStmt +TRUNCATED: "PREPARE pp AS SELECT \"xmltable\".* FROM (SELECT data FROM xmldata) x, LATERAL xmltable(('/ROWS/ROW..." +== 229 +-- truncate_limit: 100 +EXECUTE pp +-- +STMT: ExecuteStmt +TRUNCATED: "EXECUTE pp" +== 230 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS "COUNTRY_NAME" text, "REGION_ID" int) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmldata, LATERAL xmltable(('/ROWS/ROW[COUNTRY_NAME=\"Japan\" or COUNTRY_NAME=\"India..." +== 231 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id FOR ORDINALITY, "COUNTRY_NAME" text, "REGION_ID" int) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmldata, LATERAL xmltable(('/ROWS/ROW[COUNTRY_NAME=\"Japan\" or COUNTRY_NAME=\"India..." +== 232 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmldata, LATERAL xmltable(('/ROWS/ROW[COUNTRY_NAME=\"Japan\" or COUNTRY_NAME=\"India..." +== 233 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmldata, LATERAL xmltable(('/ROWS/ROW[COUNTRY_NAME=\"Japan\" or COUNTRY_NAME=\"India..." +== 234 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id FOR ORDINALITY) +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmldata, LATERAL xmltable(('/ROWS/ROW[COUNTRY_NAME=\"Japan\" or COUNTRY_NAME=\"India..." +== 235 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int, rawdata xml PATH '.') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmldata, LATERAL xmltable(('/ROWS/ROW[COUNTRY_NAME=\"Japan\" or COUNTRY_NAME=\"India..." +== 236 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmldata, LATERAL xmltable('/ROWS/ROW[COUNTRY_NAME="Japan" or COUNTRY_NAME="India"]' PASSING data COLUMNS id int PATH '@id', "COUNTRY_NAME" text, "REGION_ID" int, rawdata xml PATH './*') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmldata, LATERAL xmltable(('/ROWS/ROW[COUNTRY_NAME=\"Japan\" or COUNTRY_NAME=\"India..." +== 237 +-- truncate_limit: 100 +SELECT * FROM xmltable('/root' passing 'a1aa2a bbbbxxxcccc' COLUMNS element text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('/root') PASSING 'a1aa2a b..." +== 238 +-- truncate_limit: 100 +SELECT * FROM xmltable('/root' passing 'a1aa2a bbbbxxxcccc' COLUMNS element text PATH 'element/text()') +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('/root') PASSING 'a1aa2a b..." +== 239 +-- truncate_limit: 100 +-- should fail + +-- CDATA test +select * from xmltable('d/r' passing ' &"<>!foo]]>2' columns c text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('d/r') PASSING ' &\"<>!foo]]>'"&<>' COLUMNS ent text) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('/x/a') PASSING ''"'"&<>' COLUMNS ent xml) +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('/x/a') PASSING ''" + + CZ + Czech Republic + 2Milos Zeman + + + DE + Germany + 2 + + + FR + France + 2 + +') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmldata VALUES (...)" +== 247 +-- truncate_limit: 100 +INSERT INTO xmldata VALUES(' + + EG + Egypt + 1 + + + SD + Sudan + 1 + +') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmldata VALUES (...)" +== 248 +-- truncate_limit: 100 +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM xmldata) x, LATERAL xmltable(('/ROWS/ROW') PASSING data COLUMNS ..." +== 249 +-- truncate_limit: 100 +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') + WHERE region_id = 2 +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +FILTER: schema="" table="" column="region_id" +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM xmldata) x, LATERAL xmltable(('/ROWS/ROW') PASSING data COLUMNS ..." +== 250 +-- truncate_limit: 100 +EXPLAIN (VERBOSE, COSTS OFF) +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE', + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') + WHERE region_id = 2 +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +FILTER: schema="" table="" column="region_id" +STMT: ExplainStmt +STMT: SelectStmt +TRUNCATED: "EXPLAIN (VERBOSE, COSTS OFF) SELECT \"xmltable\".* FROM (SELECT data FROM xmldata) x, LATERAL xmlta..." +== 251 +-- truncate_limit: 100 +-- should fail, NULL value +SELECT xmltable.* + FROM (SELECT data FROM xmldata) x, + LATERAL XMLTABLE('/ROWS/ROW' + PASSING data + COLUMNS id int PATH '@id', + _id FOR ORDINALITY, + country_name text PATH 'COUNTRY_NAME' NOT NULL, + country_id text PATH 'COUNTRY_ID', + region_id int PATH 'REGION_ID', + size float PATH 'SIZE' NOT NULL, + unit text PATH 'SIZE/@unit', + premier_name text PATH 'PREMIER_NAME' DEFAULT 'not specified') +-- +TABLE: name="xmldata" schema="" table="xmldata" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM (SELECT ... FROM xmldata) x, LATERAL xmltable(('/ROWS/ROW') PASSING data COLUMNS ..." +== 252 +-- truncate_limit: 100 +-- if all is ok, then result is empty +-- one line xml test +WITH + x AS (SELECT proname, proowner, procost::numeric, pronargs, + array_to_string(proargnames,',') as proargnames, + case when proargtypes <> '' then array_to_string(proargtypes::oid[],',') end as proargtypes + FROM pg_proc WHERE proname = 'f_leak'), + y AS (SELECT xmlelement(name proc, + xmlforest(proname, proowner, + procost, pronargs, + proargnames, proargtypes)) as proc + FROM x), + z AS (SELECT xmltable.* + FROM y, + LATERAL xmltable('/proc' PASSING proc + COLUMNS proname name, + proowner oid, + procost float, + pronargs int, + proargnames text, + proargtypes text)) + SELECT * FROM z + EXCEPT SELECT * FROM x +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +CTE: "x" +CTE: "y" +CTE: "z" +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FILTER: schema="" table="" column="proname" +STMT: SelectStmt +TRUNCATED: "WITH x AS (...), y AS (SELECT ... FROM x), z AS (...) SELECT * FROM z EXCEPT SELECT * FROM x" +== 253 +-- truncate_limit: 100 +-- multi line xml test, result should be empty too +WITH + x AS (SELECT proname, proowner, procost::numeric, pronargs, + array_to_string(proargnames,',') as proargnames, + case when proargtypes <> '' then array_to_string(proargtypes::oid[],',') end as proargtypes + FROM pg_proc), + y AS (SELECT xmlelement(name data, + xmlagg(xmlelement(name proc, + xmlforest(proname, proowner, procost, + pronargs, proargnames, proargtypes)))) as doc + FROM x), + z AS (SELECT xmltable.* + FROM y, + LATERAL xmltable('/data/proc' PASSING doc + COLUMNS proname name, + proowner oid, + procost float, + pronargs int, + proargnames text, + proargtypes text)) + SELECT * FROM z + EXCEPT SELECT * FROM x +-- +TABLE: name="pg_proc" schema="" table="pg_proc" ctx=Select +CTE: "x" +CTE: "y" +CTE: "z" +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FUNCTION: name="array_to_string" function="array_to_string" schema="" ctx=Call +FUNCTION: name="xmlagg" function="xmlagg" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "WITH x AS (...), y AS (SELECT ... FROM x), z AS (...) SELECT * FROM z EXCEPT SELECT * FROM x" +== 254 +-- truncate_limit: 100 +CREATE TABLE xmltest2(x xml, _path text) +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE xmltest2 (x xml, _path text)" +== 255 +-- truncate_limit: 100 +INSERT INTO xmltest2 VALUES('1', 'A') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest2 VALUES ('1', 'A')" +== 256 +-- truncate_limit: 100 +INSERT INTO xmltest2 VALUES('2', 'B') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest2 VALUES ('2', 'B')" +== 257 +-- truncate_limit: 100 +INSERT INTO xmltest2 VALUES('3', 'C') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest2 VALUES ('3', 'C')" +== 258 +-- truncate_limit: 100 +INSERT INTO xmltest2 VALUES('2', 'D') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO xmltest2 VALUES ('2', 'D')" +== 259 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmltest2, LATERAL xmltable('/d/r' PASSING x COLUMNS a int PATH '' || lower(_path) || 'c') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmltest2, LATERAL xmltable(('/d/r') PASSING x COLUMNS a int PATH ('' || lower(_pa..." +== 260 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmltest2, LATERAL xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH '.') +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmltest2, LATERAL xmltable((('/d/r/' || lower(_path)) || 'c') PASSING x COLUMNS a..." +== 261 +-- truncate_limit: 100 +SELECT xmltable.* FROM xmltest2, LATERAL xmltable(('/d/r/' || lower(_path) || 'c') PASSING x COLUMNS a int PATH 'x' DEFAULT ascii(_path) - 54) +-- +TABLE: name="xmltest2" schema="" table="xmltest2" ctx=Select +FUNCTION: name="lower" function="lower" schema="" ctx=Call +FUNCTION: name="ascii" function="ascii" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT ... FROM xmltest2, LATERAL xmltable((('/d/r/' || lower(_path)) || 'c') PASSING x COLUMNS a..." +== 262 +-- truncate_limit: 100 +-- XPath result can be boolean or number too +SELECT * FROM XMLTABLE('*' PASSING 'a' COLUMNS a xml PATH '.', b text PATH '.', c text PATH '"hi"', d boolean PATH '. = "a"', e integer PATH 'string-length(.)') +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('*') PASSING 'a' COLUMNS a xml PATH '.', b text PATH '.', c text P..." +== 263 +-- truncate_limit: 100 +SELECT * FROM XMLTABLE('*' PASSING 'pre&deeppost' COLUMNS x xml PATH '/e/n2', y xml PATH '/') +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('*') PASSING 'pre&deep"', b xml PATH '""') +-- +STMT: SelectStmt +TRUNCATED: "SELECT * FROM xmltable(('.') PASSING xmlelement(name a) COLUMNS a varchar(20) PATH '\"\"', b ..." +== 265 +-- truncate_limit: 100 +SELECT xmltext(NULL) +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmltext(NULL)" +== 266 +-- truncate_limit: 100 +SELECT xmltext('') +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmltext('')" +== 267 +-- truncate_limit: 100 +SELECT xmltext(' ') +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmltext(' ')" +== 268 +-- truncate_limit: 100 +SELECT xmltext('foo `$_-+?=*^%!|/\()[]{}') +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmltext(E'foo `$_-+?=*^%!|/\\\\()[]{}')" +== 269 +-- truncate_limit: 100 +SELECT xmltext('foo & <"bar">') +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmltext('foo & <\"bar\">')" +== 270 +-- truncate_limit: 100 +SELECT xmltext('x'|| '

73

'::xml || .42 || true || 'j'::char) +-- +FUNCTION: name="xmltext" function="xmltext" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT xmltext(((('x' || '

73

'::xml) || .42) || true) || 'j'::char(1))" diff --git a/parser/testdata/summary_truncate/postgres_regress/xmlmap.metadata.json b/parser/testdata/summary_truncate/postgres_regress/xmlmap.metadata.json new file mode 100644 index 0000000..737fd31 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/xmlmap.metadata.json @@ -0,0 +1,3 @@ +{ + "todo": [] +} diff --git a/parser/testdata/summary_truncate/postgres_regress/xmlmap.test b/parser/testdata/summary_truncate/postgres_regress/xmlmap.test new file mode 100644 index 0000000..a28b586 --- /dev/null +++ b/parser/testdata/summary_truncate/postgres_regress/xmlmap.test @@ -0,0 +1,289 @@ +== 001 +-- truncate_limit: 100 +CREATE SCHEMA testxmlschema +-- +STMT: CreateSchemaStmt +TRUNCATED: "CREATE SCHEMA testxmlschema" +== 002 +-- truncate_limit: 100 +CREATE TABLE testxmlschema.test1 (a int, b text) +-- +TABLE: name="testxmlschema.test1" schema="testxmlschema" table="test1" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testxmlschema.test1 (a int, b text)" +== 003 +-- truncate_limit: 100 +INSERT INTO testxmlschema.test1 VALUES (1, 'one'), (2, 'two'), (-1, null) +-- +TABLE: name="testxmlschema.test1" schema="testxmlschema" table="test1" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testxmlschema.test1 VALUES (1, 'one'), (2, 'two'), (-1, NULL)" +== 004 +-- truncate_limit: 100 +CREATE DOMAIN testxmldomain AS varchar +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testxmldomain AS varchar" +== 005 +-- truncate_limit: 100 +CREATE TABLE testxmlschema.test2 (z int, y varchar(500), x char(6), + w numeric(9,2), v smallint, u bigint, t real, + s time, stz timetz, r timestamp, rtz timestamptz, q date, + p xml, o testxmldomain, n bool, m bytea, aaa text) +-- +TABLE: name="testxmlschema.test2" schema="testxmlschema" table="test2" ctx=DDL +STMT: CreateStmt +TRUNCATED: "CREATE TABLE testxmlschema.test2 (z int, y varchar(500), x char(6), w numeric(9, 2), v smallint, ..." +== 006 +-- truncate_limit: 100 +ALTER TABLE testxmlschema.test2 DROP COLUMN aaa +-- +TABLE: name="testxmlschema.test2" schema="testxmlschema" table="test2" ctx=DDL +STMT: AlterTableStmt +TRUNCATED: "ALTER TABLE testxmlschema.test2 DROP aaa" +== 007 +-- truncate_limit: 100 +INSERT INTO testxmlschema.test2 VALUES (55, 'abc', 'def', + 98.6, 2, 999, 0, + '21:07', '21:11 +05', '2009-06-08 21:07:30', '2009-06-08 21:07:30 -07', '2009-06-08', + NULL, 'ABC', true, 'XYZ') +-- +TABLE: name="testxmlschema.test2" schema="testxmlschema" table="test2" ctx=DML +STMT: InsertStmt +STMT: SelectStmt +TRUNCATED: "INSERT INTO testxmlschema.test2 VALUES (...)" +== 008 +-- truncate_limit: 100 +SELECT table_to_xml('testxmlschema.test1', false, false, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml('testxmlschema.test1', false, false, '')" +== 009 +-- truncate_limit: 100 +SELECT table_to_xml('testxmlschema.test1', true, false, 'foo') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml('testxmlschema.test1', true, false, 'foo')" +== 010 +-- truncate_limit: 100 +SELECT table_to_xml('testxmlschema.test1', false, true, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml('testxmlschema.test1', false, true, '')" +== 011 +-- truncate_limit: 100 +SELECT table_to_xml('testxmlschema.test1', true, true, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml('testxmlschema.test1', true, true, '')" +== 012 +-- truncate_limit: 100 +SELECT table_to_xml('testxmlschema.test2', false, false, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml('testxmlschema.test2', false, false, '')" +== 013 +-- truncate_limit: 100 +SELECT table_to_xmlschema('testxmlschema.test1', false, false, '') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xmlschema('testxmlschema.test1', false, false, '')" +== 014 +-- truncate_limit: 100 +SELECT table_to_xmlschema('testxmlschema.test1', true, false, '') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xmlschema('testxmlschema.test1', true, false, '')" +== 015 +-- truncate_limit: 100 +SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo')" +== 016 +-- truncate_limit: 100 +SELECT table_to_xmlschema('testxmlschema.test1', true, true, '') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xmlschema('testxmlschema.test1', true, true, '')" +== 017 +-- truncate_limit: 100 +SELECT table_to_xmlschema('testxmlschema.test2', false, false, '') +-- +FUNCTION: name="table_to_xmlschema" function="table_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xmlschema('testxmlschema.test2', false, false, '')" +== 018 +-- truncate_limit: 100 +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, '') +-- +FUNCTION: name="table_to_xml_and_xmlschema" function="table_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, '')" +== 019 +-- truncate_limit: 100 +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, '') +-- +FUNCTION: name="table_to_xml_and_xmlschema" function="table_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, '')" +== 020 +-- truncate_limit: 100 +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '') +-- +FUNCTION: name="table_to_xml_and_xmlschema" function="table_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '')" +== 021 +-- truncate_limit: 100 +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo') +-- +FUNCTION: name="table_to_xml_and_xmlschema" function="table_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo')" +== 022 +-- truncate_limit: 100 +SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, '') +-- +FUNCTION: name="query_to_xml" function="query_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, '')" +== 023 +-- truncate_limit: 100 +SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, '') +-- +FUNCTION: name="query_to_xmlschema" function="query_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, '')" +== 024 +-- truncate_limit: 100 +SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, '') +-- +FUNCTION: name="query_to_xml_and_xmlschema" function="query_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, '')" +== 025 +-- truncate_limit: 100 +DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2 +-- +STMT: DeclareCursorStmt +TRUNCATED: "DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2" +== 026 +-- truncate_limit: 100 +SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '') +-- +FUNCTION: name="cursor_to_xml" function="cursor_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '')" +== 027 +-- truncate_limit: 100 +SELECT cursor_to_xmlschema('xc'::refcursor, false, true, '') +-- +FUNCTION: name="cursor_to_xmlschema" function="cursor_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cursor_to_xmlschema('xc'::refcursor, false, true, '')" +== 028 +-- truncate_limit: 100 +MOVE BACKWARD ALL IN xc +-- +STMT: FetchStmt +TRUNCATED: "MOVE BACKWARD ALL xc" +== 029 +-- truncate_limit: 100 +SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '') +-- +FUNCTION: name="cursor_to_xml" function="cursor_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '')" +== 030 +-- truncate_limit: 100 +SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '') +-- +FUNCTION: name="cursor_to_xmlschema" function="cursor_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '')" +== 031 +-- truncate_limit: 100 +SELECT schema_to_xml('testxmlschema', false, true, '') +-- +FUNCTION: name="schema_to_xml" function="schema_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT schema_to_xml('testxmlschema', false, true, '')" +== 032 +-- truncate_limit: 100 +SELECT schema_to_xml('testxmlschema', true, false, '') +-- +FUNCTION: name="schema_to_xml" function="schema_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT schema_to_xml('testxmlschema', true, false, '')" +== 033 +-- truncate_limit: 100 +SELECT schema_to_xmlschema('testxmlschema', false, true, '') +-- +FUNCTION: name="schema_to_xmlschema" function="schema_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT schema_to_xmlschema('testxmlschema', false, true, '')" +== 034 +-- truncate_limit: 100 +SELECT schema_to_xmlschema('testxmlschema', true, false, '') +-- +FUNCTION: name="schema_to_xmlschema" function="schema_to_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT schema_to_xmlschema('testxmlschema', true, false, '')" +== 035 +-- truncate_limit: 100 +SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo') +-- +FUNCTION: name="schema_to_xml_and_xmlschema" function="schema_to_xml_and_xmlschema" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo')" +== 036 +-- truncate_limit: 100 +-- test that domains are transformed like their base types + +CREATE DOMAIN testboolxmldomain AS bool +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testboolxmldomain AS bool" +== 037 +-- truncate_limit: 100 +CREATE DOMAIN testdatexmldomain AS date +-- +STMT: CreateDomainStmt +TRUNCATED: "CREATE DOMAIN testdatexmldomain AS date" +== 038 +-- truncate_limit: 100 +CREATE TABLE testxmlschema.test3 + AS SELECT true c1, + true::testboolxmldomain c2, + '2013-02-21'::date c3, + '2013-02-21'::testdatexmldomain c4 +-- +TABLE: name="testxmlschema.test3" schema="testxmlschema" table="test3" ctx=DDL +STMT: CreateTableAsStmt +STMT: SelectStmt +TRUNCATED: "CREATE TABLE testxmlschema.test3 AS SELECT true AS c1, true::testboolxmldomain AS c2, '2013-02-21..." +== 039 +-- truncate_limit: 100 +SELECT xmlforest(c1, c2, c3, c4) FROM testxmlschema.test3 +-- +TABLE: name="testxmlschema.test3" schema="testxmlschema" table="test3" ctx=Select +STMT: SelectStmt +TRUNCATED: "SELECT xmlforest(c1, c2, c3, c4) FROM testxmlschema.test3" +== 040 +-- truncate_limit: 100 +SELECT table_to_xml('testxmlschema.test3', true, true, '') +-- +FUNCTION: name="table_to_xml" function="table_to_xml" schema="" ctx=Call +STMT: SelectStmt +TRUNCATED: "SELECT table_to_xml('testxmlschema.test3', true, true, '')" diff --git a/summary_test.go b/summary_test.go new file mode 100644 index 0000000..f2aadc3 --- /dev/null +++ b/summary_test.go @@ -0,0 +1,132 @@ +package oliphant_test + +import ( + "testing" + + "google.golang.org/protobuf/proto" + + pg_query "github.com/sqlc-dev/oliphant" +) + +var summaryTests = []struct { + input string + truncateLimit int + expected *pg_query.SummaryResult +}{ + // Basic SELECT with filter column + { + input: "SELECT * FROM users WHERE id = 1", + truncateLimit: -1, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{{Name: "users", TableName: "users", Context: pg_query.SummaryResult_Select}}, + FilterColumns: []*pg_query.SummaryResult_FilterColumn{{Column: "id"}}, + StatementTypes: []string{"SelectStmt"}, + }, + }, + // Query truncation + { + input: "SELECT id, name, email FROM users WHERE id = 1", + truncateLimit: 30, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{{Name: "users", TableName: "users", Context: pg_query.SummaryResult_Select}}, + FilterColumns: []*pg_query.SummaryResult_FilterColumn{{Column: "id"}}, + StatementTypes: []string{"SelectStmt"}, + TruncatedQuery: "SELECT ... FROM users WHERE...", + }, + }, + // JOIN with table aliases + { + input: "SELECT * FROM users u JOIN orders o ON u.id = o.user_id", + truncateLimit: -1, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{ + {Name: "users", TableName: "users", Context: pg_query.SummaryResult_Select}, + {Name: "orders", TableName: "orders", Context: pg_query.SummaryResult_Select}, + }, + Aliases: map[string]string{"u": "users", "o": "orders"}, + StatementTypes: []string{"SelectStmt"}, + }, + }, + // Aggregate functions (count, max) + { + input: "SELECT count(*), max(id) FROM users", + truncateLimit: -1, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{{Name: "users", TableName: "users", Context: pg_query.SummaryResult_Select}}, + Functions: []*pg_query.SummaryResult_Function{ + {Name: "count", FunctionName: "count", Context: pg_query.SummaryResult_Call}, + {Name: "max", FunctionName: "max", Context: pg_query.SummaryResult_Call}, + }, + StatementTypes: []string{"SelectStmt"}, + }, + }, + // Common Table Expression (CTE) + { + input: "WITH active_users AS (SELECT * FROM users WHERE active = true) SELECT * FROM active_users", + truncateLimit: -1, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{{Name: "users", TableName: "users", Context: pg_query.SummaryResult_Select}}, + CteNames: []string{"active_users"}, + FilterColumns: []*pg_query.SummaryResult_FilterColumn{{Column: "active"}}, + StatementTypes: []string{"SelectStmt"}, + }, + }, + // Schema-qualified table name + { + input: "SELECT * FROM public.users", + truncateLimit: -1, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{{Name: "public.users", SchemaName: "public", TableName: "users", Context: pg_query.SummaryResult_Select}}, + StatementTypes: []string{"SelectStmt"}, + }, + }, + // INSERT statement + { + input: "INSERT INTO users (name) VALUES ('test')", + truncateLimit: -1, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{{Name: "users", TableName: "users", Context: pg_query.SummaryResult_DML}}, + StatementTypes: []string{"InsertStmt", "SelectStmt"}, + }, + }, + // UPDATE statement + { + input: "UPDATE users SET name = 'test' WHERE id = 1", + truncateLimit: -1, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{{Name: "users", TableName: "users", Context: pg_query.SummaryResult_DML}}, + StatementTypes: []string{"UpdateStmt"}, + }, + }, + // DELETE statement + { + input: "DELETE FROM users WHERE id = 1", + truncateLimit: -1, + expected: &pg_query.SummaryResult{ + Tables: []*pg_query.SummaryResult_Table{{Name: "users", TableName: "users", Context: pg_query.SummaryResult_DML}}, + StatementTypes: []string{"DeleteStmt"}, + }, + }, +} + +func TestSummary(t *testing.T) { + for _, tt := range summaryTests { + t.Run(tt.input, func(t *testing.T) { + result, err := pg_query.Summary(tt.input, tt.truncateLimit) + if err != nil { + t.Fatalf("Summary() error: %s", err) + } + + if !proto.Equal(result, tt.expected) { + t.Errorf("Summary() mismatch:\n got: %v\n expected: %v", result, tt.expected) + } + }) + } +} + +func TestSummaryError(t *testing.T) { + _, err := pg_query.Summary("SELECT * FROM", -1) + if err == nil { + t.Error("expected error for invalid SQL") + } +}